{"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} : \u03a0 {b : V} (p : quiver.path G a b), \u2115\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 $ \u03bb 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 \u2264 p.length :=\nbegin\n  have : \u00ac (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\u03bb a b e, \u2203 p : G.path root a, shortest_path G b = quiver.path.cons p e\n\n-- todo: write this idiomatically\nlemma paths_are_unique : \u2200 {s : V} {p q : (\u00a1geodesic_subgraph G).path root s}, p = q\n| _ (quiver.path.nil) := begin\n  rintro ( _ | _ ),\n  { refl },\n  exfalso,\n  rcases q_\u1fb0_1 with \u27e8_, _, h\u27e9,\n  have : (shortest_path G root).length \u2264 0 :=\n    shortest_path_spec G quiver.path.nil,\n  rw h at this,\n  change _ + 1 \u2264 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 \u27e8_, _, h\u27e9,\n  rintro ( _ | _ ),\n  { have : (shortest_path G root).length \u2264 0 :=\n      shortest_path_spec G quiver.path.nil,\n    rw h at this,\n    change _ + 1 \u2264 0 at this,\n    simpa only [nonpos_iff_eq_zero] using this },\n  { rcases q_\u1fb0_1 with \u27e8_, _, hq\u27e9,\n    rw h at hq,\n    cases hq,\n    congr,\n    apply paths_are_unique }\nend\n\ndef geodesic_path : \u03a0 (gas : \u2115) (t : V), (shortest_path G t).length \u2264 gas \u2192\n      (\u00a1geodesic_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 : \u2203 p, p = shortest_path G t, \n    { refine \u27e8_, rfl\u27e9 },\n    rcases (classical.indefinite_description _ this) with \u27e8p, hp\u27e9,\n    cases p with s t p e,\n    { exact quiver.path.nil },\n    { exfalso, -- out of gas\n      rw \u2190hp at h,\n      simpa using h } },\n  { intros t h,\n    have : \u2203 p, p = shortest_path G t, \n    { refine \u27e8_, rfl\u27e9 },\n    rcases (classical.indefinite_description _ this) with \u27e8p, hp\u27e9,\n    cases p with s t p e,\n    { exact quiver.path.nil },\n    { refine quiver.path.cons _ \u27e8e, p, hp.symm\u27e9,\n      apply ih,\n      rw \u2190hp at h,\n      change _ + 1 \u2264 _ + 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 \u00a1geodesic_subgraph G :=\n{ unique_path := \u03bb b,\n  { default := geodesic_path G _ b (le_refl _),\n    uniq := \u03bb _, 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\u00e4rn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David W\u00e4rn\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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) where\n  as : C\n\nprotected instance quotient.inhabited {C : Type u} [category C]\n    (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {s : C}\n    {t : C} : (s \u27f6 t) \u2192 (s \u27f6 t) \u2192 Prop\n    where\n| intro :\n    \u2200 {a b : C} (f : s \u27f6 a) (m\u2081 m\u2082 : a \u27f6 b) (g : b \u27f6 t),\n      r m\u2081 m\u2082 \u2192 comp_closure r (f \u226b m\u2081 \u226b g) (f \u226b m\u2082 \u226b g)\n\ntheorem comp_left {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : C}\n    {b : C} {c : C} (f : a \u27f6 b) (g\u2081 : b \u27f6 c) (g\u2082 : b \u27f6 c) (h : comp_closure r g\u2081 g\u2082) :\n    comp_closure r (f \u226b g\u2081) (f \u226b g\u2082) :=\n  sorry\n\ntheorem comp_right {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : C}\n    {b : C} {c : C} (g : b \u27f6 c) (f\u2081 : a \u27f6 b) (f\u2082 : a \u27f6 b) (h : comp_closure r f\u2081 f\u2082) :\n    comp_closure r (f\u2081 \u226b g) (f\u2082 \u226b g) :=\n  sorry\n\n/-- Hom-sets of the quotient category. -/\ndef hom {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) (a : quotient r) : Inhabited (hom r a a) :=\n  { default := Quot.mk (comp_closure r) \ud835\udfd9 }\n\n/-- Composition in the quotient category. -/\ndef comp {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : quotient r}\n    {b : quotient r} {c : quotient r} : hom r a b \u2192 hom r b c \u2192 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 \u27f6 as b) =>\n        quot.lift_on hg (fun (g : as b \u27f6 as c) => Quot.mk (comp_closure r) (f \u226b g)) sorry)\n      sorry\n\n@[simp] theorem comp_mk {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop)\n    {a : quotient r} {b : quotient r} {c : quotient r} (f : as a \u27f6 as b) (g : as b \u27f6 as c) :\n    comp r (Quot.mk (comp_closure r) f) (Quot.mk (comp_closure r) g) =\n        Quot.mk (comp_closure r) (f \u226b g) :=\n  rfl\n\nprotected instance category {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop)\n    (_x : C) :\n    \u2200 (_x_1 : C) (f : _x \u27f6 _x_1), functor.map (functor r) f = Quot.mk (comp_closure r) f :=\n  fun (_x_1 : C) (f : _x \u27f6 _x_1) => Eq.refl (functor.map (functor r) f)\n\nprotected theorem induction {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop)\n    {P : {a b : quotient r} \u2192 (a \u27f6 b) \u2192 Prop}\n    (h : \u2200 {x y : C} (f : x \u27f6 y), P (functor.map (functor r) f)) {a : quotient r} {b : quotient r}\n    (f : a \u27f6 b) : P f :=\n  sorry\n\nprotected theorem sound {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : C}\n    {b : C} {f\u2081 : a \u27f6 b} {f\u2082 : a \u27f6 b} (h : r f\u2081 f\u2082) :\n    functor.map (functor r) f\u2081 = functor.map (functor r) f\u2082 :=\n  sorry\n\n/-- The induced functor on the quotient category. -/\ndef lift {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {D : Type u_1}\n    [category D] (F : C \u2964 D)\n    (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 functor.map F f\u2081 = functor.map F f\u2082) :\n    quotient r \u2964 D :=\n  functor.mk (fun (a : quotient r) => functor.obj F (as a))\n    fun (a b : quotient r) (hf : a \u27f6 b) =>\n      quot.lift_on hf (fun (f : as a \u27f6 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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {D : Type u_1}\n    [category D] (F : C \u2964 D)\n    (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 functor.map F f\u2081 = functor.map F f\u2082) :\n    functor r \u22d9 lift r F H \u2245 F :=\n  nat_iso.of_components (fun (X : C) => iso.refl (functor.obj (functor r \u22d9 lift r F H) X)) sorry\n\n@[simp] theorem lift.is_lift_hom {C : Type u} [category C]\n    (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {D : Type u_1} [category D] (F : C \u2964 D)\n    (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 functor.map F f\u2081 = functor.map F f\u2082) (X : C) :\n    nat_trans.app (iso.hom (lift.is_lift r F H)) X = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem lift.is_lift_inv {C : Type u} [category C]\n    (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {D : Type u_1} [category D] (F : C \u2964 D)\n    (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 functor.map F f\u2081 = functor.map F f\u2082) (X : C) :\n    nat_trans.app (iso.inv (lift.is_lift r F H)) X = \ud835\udfd9 :=\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' : \u2200 {W X Y Z : C} (f : W \u27f6 X) (r : R) (g : Y \u27f6 Z), f \u2297 r \u2022 g = r \u2022 (f \u2297 g) := by\n    obviously\n  smul_tensor' : \u2200 {W X Y Z : C} (r : R) (f : W \u27f6 X) (g : Y \u27f6 Z), r \u2022 f \u2297 g = r \u2022 (f \u2297 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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 \u2297 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 \u2297 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\u2080 u\u2081 l \n\nnamespace Mathlib\n\n/-!\n# Functions functorial with respect to equivalences\n\nAn `equiv_functor` is a function from `Type \u2192 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 \u03b1 \u2192 f \u03b2` from\nan equivalence `\u03b1 \u2243 \u03b2`, 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\u2080 \u2192 Type u\u2081) \nwhere\n  map : {\u03b1 \u03b2 : Type u\u2080} \u2192 \u03b1 \u2243 \u03b2 \u2192 f \u03b1 \u2192 f \u03b2\n  map_refl' : autoParam (\u2200 (\u03b1 : Type u\u2080), map (equiv.refl \u03b1) = 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 (\u2200 {\u03b1 \u03b2 \u03b3 : Type u\u2080} (k : \u03b1 \u2243 \u03b2) (h : \u03b2 \u2243 \u03b3), map (equiv.trans k h) = map h \u2218 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\u2080 \u2192 Type u\u2081} [c : equiv_functor f] (\u03b1 : Type u\u2080) : equiv_functor.map (equiv.refl \u03b1) = id := sorry\n\ntheorem equiv_functor.map_trans {f : Type u\u2080 \u2192 Type u\u2081} [c : equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} {\u03b3 : Type u\u2080} (k : \u03b1 \u2243 \u03b2) (h : \u03b2 \u2243 \u03b3) : equiv_functor.map (equiv.trans k h) = equiv_functor.map h \u2218 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\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} (e : \u03b1 \u2243 \u03b2) : f \u03b1 \u2243 f \u03b2 :=\n  equiv.mk (map e) (map (equiv.symm e)) sorry sorry\n\n@[simp] theorem map_equiv_apply (f : Type u\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} (e : \u03b1 \u2243 \u03b2) (x : f \u03b1) : coe_fn (map_equiv f e) x = map e x :=\n  rfl\n\ntheorem map_equiv_symm_apply (f : Type u\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} (e : \u03b1 \u2243 \u03b2) (y : f \u03b2) : 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\u2080 \u2192 Type u\u2081) [equiv_functor f] (\u03b1 : Type u\u2080) : map_equiv f (equiv.refl \u03b1) = equiv.refl (f \u03b1) := sorry\n\n@[simp] theorem map_equiv_symm (f : Type u\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} (e : \u03b1 \u2243 \u03b2) : 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\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} {\u03b3 : Type u\u2080} (ab : \u03b1 \u2243 \u03b2) (bc : \u03b2 \u2243 \u03b3) : 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\u2080 \u2192 Type u\u2081) [Functor f] [is_lawful_functor f] : equiv_functor f :=\n  mk fun (\u03b1 \u03b2 : Type u\u2080) (e : \u03b1 \u2243 \u03b2) => Functor.map \u21d1e\n\ntheorem map_equiv.injective (f : Type u\u2080 \u2192 Type u\u2081) [Applicative f] [is_lawful_applicative f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} (h : Type u\u2080 \u2192 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 : \u2200 {x : F}, x \u2208 S \u2192 x\u207b\u00b9 \u2208 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\u2093'. -/\ntheorem IsSubfield.div_mem {S : Set F} (hS : IsSubfield S) {x y : F} (hx : x \u2208 S) (hy : y \u2208 S) :\n    x / y \u2208 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 : \u2124} {s : Set F} (hs : IsSubfield s) (h : a \u2208 s) :\n    a ^ n \u2208 s := by\n  cases n\n  \u00b7 rw [zpow_ofNat]\n    exact hs.to_is_subring.to_is_submonoid.pow_mem h\n  \u00b7 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\u2093'. -/\ntheorem Preimage.isSubfield {K : Type _} [Field K] (f : F \u2192+* K) {s : Set K} (hs : IsSubfield s) :\n    IsSubfield (f \u207b\u00b9' s) :=\n  { f.isSubring_preimage hs.to_isSubring with\n    inv_mem := fun a (ha : f a \u2208 s) =>\n      show f a\u207b\u00b9 \u2208 s by\n        rw [map_inv\u2080]\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\u2093'. -/\ntheorem Image.isSubfield {K : Type _} [Field K] (f : F \u2192+* K) {s : Set F} (hs : IsSubfield s) :\n    IsSubfield (f '' s) :=\n  { f.isSubring_image hs.to_isSubring with\n    inv_mem := fun a \u27e8x, xmem, ha\u27e9 => \u27e8x\u207b\u00b9, hs.inv_mem xmem, ha \u25b8 map_inv\u2080 f _\u27e9 }\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\u2093'. -/\ntheorem Range.isSubfield {K : Type _} [Field K] (f : F \u2192+* K) : IsSubfield (Set.range f) :=\n  by\n  rw [\u2190 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 | \u2203 y \u2208 Ring.closure S, \u2203 z \u2208 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 \u2286 closure S := fun x hx =>\n  \u27e8x, hx, 1, Ring.closure.isSubring.to_isSubmonoid.one_mem, div_one x\u27e9\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\u2093'. -/\ntheorem closure.isSubmonoid : IsSubmonoid (closure S) :=\n  { mul_mem := by\n      rintro _ _ \u27e8p, hp, q, hq, hq0, rfl\u27e9 \u27e8r, hr, s, hs, hs0, rfl\u27e9 <;>\n        exact\n          \u27e8p * 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\u27e9\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) \u2208 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 \u27e8p, hp, q, hq, rfl\u27e9\n      rcases id hb with \u27e8r, hr, s, hs, rfl\u27e9\n      classical\n        by_cases hq0 : q = 0\n        \u00b7 simp [hb, hq0]\n        by_cases hs0 : s = 0\n        \u00b7 simp [ha, hs0]\n        exact\n          \u27e8p * 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\u27e9\n    zero_mem := h0\n    neg_mem := by\n      rintro _ \u27e8p, hp, q, hq, rfl\u27e9\n      exact \u27e8-p, ring.closure.is_subring.to_is_add_subgroup.neg_mem hp, q, hq, neg_div q p\u27e9\n    inv_mem := by\n      rintro _ \u27e8p, hp, q, hq, rfl\u27e9\n      exact \u27e8q, hq, p, hp, (inv_div _ _).symm\u27e9 }\n#align field.closure.is_subfield Field.closure.isSubfield\n-/\n\n#print Field.mem_closure /-\ntheorem mem_closure {a : F} (ha : a \u2208 S) : a \u2208 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 \u2286 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 \u2286 T) : closure S \u2286 T := by\n  rintro _ \u27e8p, hp, q, hq, hq0, rfl\u27e9 <;>\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 \u2286 t \u2194 s \u2286 t :=\n  \u27e8Set.Subset.trans subset_closure, closure_subset ht\u27e9\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 \u2286 t) : closure s \u2286 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\u1d62_of_directed /-\ntheorem isSubfield_union\u1d62_of_directed {\u03b9 : Type _} [h\u03b9 : Nonempty \u03b9] {s : \u03b9 \u2192 Set F}\n    (hs : \u2200 i, IsSubfield (s i)) (directed : \u2200 i j, \u2203 k, s i \u2286 s k \u2227 s j \u2286 s k) :\n    IsSubfield (\u22c3 i, s i) :=\n  { inv_mem := fun x hx =>\n      let \u27e8i, hi\u27e9 := Set.mem_union\u1d62.1 hx\n      Set.mem_union\u1d62.2 \u27e8i, (hs i).inv_mem hi\u27e9\n    to_isSubring := isSubring_union\u1d62_of_directed (fun i => (hs i).to_isSubring) Directed }\n#align is_subfield_Union_of_directed isSubfield_union\u1d62_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\u2081 : Set.{u1} F} {S\u2082 : Set.{u1} F}, (IsSubfield.{u1} F _inst_1 S\u2081) -> (IsSubfield.{u1} F _inst_1 S\u2082) -> (IsSubfield.{u1} F _inst_1 (Inter.inter.{u1} (Set.{u1} F) (Set.hasInter.{u1} F) S\u2081 S\u2082))\nbut is expected to have type\n  forall {F : Type.{u1}} [_inst_1 : Field.{u1} F] {S\u2081 : Set.{u1} F} {S\u2082 : Set.{u1} F}, (IsSubfield.{u1} F _inst_1 S\u2081) -> (IsSubfield.{u1} F _inst_1 S\u2082) -> (IsSubfield.{u1} F _inst_1 (Inter.inter.{u1} (Set.{u1} F) (Set.instInterSet.{u1} F) S\u2081 S\u2082))\nCase conversion may be inaccurate. Consider using '#align is_subfield.inter IsSubfield.inter\u2093'. -/\ntheorem IsSubfield.inter {S\u2081 S\u2082 : Set F} (hS\u2081 : IsSubfield S\u2081) (hS\u2082 : IsSubfield S\u2082) :\n    IsSubfield (S\u2081 \u2229 S\u2082) :=\n  { IsSubring.inter hS\u2081.to_isSubring hS\u2082.to_isSubring with\n    inv_mem := fun x hx => \u27e8hS\u2081.inv_mem hx.1, hS\u2082.inv_mem hx.2\u27e9 }\n#align is_subfield.inter IsSubfield.inter\n\n#print IsSubfield.inter\u1d62 /-\ntheorem IsSubfield.inter\u1d62 {\u03b9 : Sort _} {S : \u03b9 \u2192 Set F} (h : \u2200 y : \u03b9, IsSubfield (S y)) :\n    IsSubfield (Set.inter\u1d62 S) :=\n  { IsSubring.inter\u1d62 fun y => (h y).to_isSubring with\n    inv_mem := fun x hx => Set.mem_inter\u1d62.2 fun y => (h y).inv_mem <| Set.mem_inter\u1d62.1 hx y }\n#align is_subfield.Inter IsSubfield.inter\u1d62\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(\u2200 x : K, \u00ac (T.rigid x \u2227 T.rigid (-x)) \u2192 x \u2208 T \u2228 -x \u2208 T) \u2227 \n((-1 : K) \u2208 T \u2228 \u2200 (x y : K), x \u2208 T \u2192 y \u2208 T \u2192 x + y \u2208 T)\n\ntheorem rigid_pair.preadditive_of_not_exceptional\n  {T H : mul_subgroup K}\n  (rp : rigid_pair T H)\n  (H : \u00ac T.exceptional) : \n  rp.preadditive :=\nbegin\n  suffices : (\u2203 (a : K) (ha1 : a \u2260 0) (ha2 : a \u2209 T), \u00ac T.rigid (-a)),\n  { obtain \u27e8a,ha1,ha2,hh\u27e9 := 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 \u2260 0, \n      { dsimp [mul_subgroup.rigid] at hx, push_neg at hx, \n        obtain \u27e8a,b,ha,hb,hx1,hx2,hx3\u27e9 := 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 \u2260 0, \n      { dsimp [mul_subgroup.rigid] at hx, push_neg at hx, \n        obtain \u27e8a,b,ha,hb,hx1,hx2,hx3\u27e9 := 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) \u2208 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  \u2200 (a b : K), a \u2208 rp.OO_m \u2192 b \u2208 rp.OO_m \u2192 (1 - a * b \u2209 T) \u2192\n  (-a)\u207b\u00b9 * (1 - a * b) \u2208 T :=\nbegin\n  intros a b ha hb hh,\n  have haz : (-a) \u2260 0,\n  { intro c, apply hh, rw neg_eq_zero at c, simp [c, T.one_mem] },\n  have haz' : a \u2260 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  \u2200 (a b : K), a \u2208 rp.OO_m \u2192 b \u2208 rp.OO_m \u2192 (1 - a * b \u2209 T) \u2192\n  a * b\u207b\u00b9 \u2208 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 \u2260 0,\n  { intro c, apply T.ne_zero_of_mem h2, simp [c] },\n  have : a \u2260 0, \n  { intro c, apply T.ne_zero_of_mem h1, simp [c] },\n  have : 1 - a * b \u2260 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 \u2264 H') : \n  (rp.of_le H' h).OO_m \u2264 rp.OO_m := \nbegin\n  rintros x \u27e8h1,h2\u27e9,\n  exact \u27e8\u03bb c, h1 (h c), h2\u27e9,\nend\n\ntheorem rigid_pair.exists_preadditive \n  {T H : mul_subgroup K}\n  (rp : rigid_pair T H) : \n  \u2203 (x : K) (hx : x \u2260 0) (hxH : x * x \u2208 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 \u27e8a,b,ha,hb,HH\u27e9 := HH,\n  have haz : a \u2260 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 _ \u2227 rp'.preadditive,\n  let t := (-a)\u207b\u00b9 * (1 - a * b),\n  have aux1 : t \u2208 T := rp.exists_preadditive_aux a b ha hb HH,\n  have haz' : (-a) \u2260 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 (\u03bb e, -e) at h1, rw neg_neg at h1, rw \u2190 h1, ring },\n  have h3 := rp.pos a ha.1 1 t T.one_mem aux1 haz,\n  rw \u2190 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 \u2260 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 \u2190 neg_neg a, apply rp.le_neg c, },\n    suffices : \u2200 z : K, z \u2208 rp'.OO_m \u2192 1 - a * z \u2208 T \u2227 1 - a\u207b\u00b9 * z \u2208 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)\u207b\u00b9 * (-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)\u207b\u00b9 * 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 \u2208 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 \u2208 H') (H'.inv_mem this),\n      field_simp, ring,\n      { suffices : a * b \u2208 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\u207b\u00b9)\u207b\u00b9 \u2209 rp'.OO_m, \n    { dsimp [rigid_pair.OO_m], push_neg, intro _, convert c, field_simp, ring },\n    rw \u2190 rp'.OO_m_mem_iff_inv_nmem at c',\n    have e1 := rp.exists_preadditive_aux (-a * z\u207b\u00b9) (-b * z) (rp.OO_m_mono _ c') _ _,\n    have e2 := rp.exists_preadditive_aux a b ha hb HH,\n    rw \u2190 inv_inv z, apply mul_subgroup.inv_mem,\n    apply rp'.mem_of_neg_mem, apply rp'.le,\n    have : 1 - -a * z\u207b\u00b9 * (-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), \u2190 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 \u2208 H')), \n        have : -b \u2260 0, by simpa,\n        field_simp, ring,\n        apply rp'.neg_mem_of_mem,\n        have : b * a\u207b\u00b9 \u2208 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 \u27e8haz, hzz\u27e9 },\n    { intro c, apply hz.1, \n      convert H'.mul_mem (H'.inv_mem c) (_ : (-a) \u2208 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": "import ..expressions.time_expr_current\n\nopen lang.time\n/-\nStress test of alternate API\n\nFirst Frames, then Spaces, \nDuration, Time, Transforms\n\nType error demonstrations on bottom\n-/\n\ndef \n\n--check frame API\ndef std_fr : time_frame_expr := [time_std_frame K] \ndef fr_var : time_frame_var := \u27e8\u27e8\"std\"\u27e9\u27e9 --hide with function?\ndef fr_var_expr := time_frame_expr.var fr_var\n#check fr_var_expr.value\nlemma defaultedfr : fr_var_expr.value = time_std_frame K := rfl\n\n--check space API\ndef std_sp : time_space_expr std_fr :=  [time_std_space K]\ndef std_var : time_space_expr std_fr := time_space_expr.var \u27e8\u27e8\"std\"\u27e9\u27e9\nlemma defaultsp : std_var.value = std_sp.value := rfl\n\n--out of sequence but required to test derived API\ndef launch_time : \n  time_expr std_sp\n  :=\n  [(mk_time std_sp.value 0)]\ndef one_second := \n  [(mk_duration std_sp.value 1)]\n\n--test derived API\n--This is not deeply embedded. Evaluates launch time and one second to build a new frame. \n--This is a trade-off caused because time frame expressions are defined prior to point and vector expressions,\n--in order to allow points and vectors to depend on space expressions rather than phys space literal values,\n--encapsulating phys inside of lang \ndef mission_frame : time_frame_expr  := \n    mk_time_frame_expr launch_time one_second\n\n--use this or literal constructor (this function uses a different constructor than [])\ndef mission_space :=\n  mk_time_space_expr mission_frame --(mk_space \u211a mission_frame.value)\n\n--move on to durations and times\ndef dur_zero : duration_expr std_sp := 0 --duration.zero\ndef dur_one : duration_expr std_sp := 1 --duration.one\ndef dur_lit : duration_expr std_sp := [one_second.value]\ndef dur_var : duration_expr std_sp := duration_expr.var \u27e8\u27e8\"dur\"\u27e9\u27e9 -- var constructor should have notation?\ndef dur_add  : duration_expr std_sp := one_second +\u1d65 one_second\ndef dur_neg  : duration_expr std_sp := -one_second\ndef dur_sub  : duration_expr std_sp := one_second -\u1d65 0 -\u1d65 one_second \ndef dur_time  : duration_expr std_sp := launch_time -\u1d65 launch_time\ndef dur_smul  : duration_expr std_sp := (3:\u211a/-again, \u211a is K, the configured scalar field-/)\u2022one_second\n\ndef time_lit : time_expr std_sp := [launch_time.value]\ndef time_var : time_expr std_sp := time_expr.var \u27e8\u27e8\"time\"\u27e9\u27e9\ndef time_add : time_expr std_sp := one_second +\u1d65 launch_time -- need to add reverse notation\n\n\n--Test Transforms next\ndef transform_lit : \n  transform_expr std_sp mission_space :=  [(std_sp.value.time_tr mission_space.value)]\ndef transform_var : transform_expr std_sp mission_space := transform_expr.var \u27e8\u27e8\"tr\"\u27e9\u27e9\n\n--belongs with time and duration tests, but...\n--also, these cannot be deeply embedded\n--required to evaluate the point or vector operand\n--needs notation?\ndef dur_apply : duration_expr mission_space := \n  duration_expr.apply_duration_lit transform_lit one_second.value\ndef time_apply : time_expr mission_space :=\n  time_expr.apply_time_lit transform_lit launch_time.value\n\n--used for compose\ndef mission_to_std : \n  transform_expr mission_space std_sp\n  := \n  [(mission_space.value.time_tr std_sp.value)]\ndef std_to_mission := transform_lit\n--compose result (trans used by mathlib)\n--compose not deeply embedded, same limitation as apply\ndef std_to_std : transform_expr std_sp std_sp := std_to_mission.trans mission_to_std\n\n--inverse\n--inverse not deeply embedded, same limitation as apply\ndef mission_to_std' : \n  transform_expr mission_space std_sp := std_to_mission\u207b\u00b9\n\n\n--a few type errors\n\n--adding wrong spaces/frames\ndef mission_dur : duration_expr mission_space := [(mk_duration mission_space.value 1)]\ndef wrong_spaces := mission_dur +\u1d65 dur_lit --dur_lit in standard space\n\n--bad apply\ndef bad_apply := duration_expr.apply_duration_lit mission_to_std dur_lit --dur_lit not in mission space\n\n--bad compose\ndef bad_compose := std_to_mission.trans std_to_mission \n\n--adding points\ndef point_add := launch_time +\u1d65 launch_time ", "meta": {"author": "kevinsullivan", "repo": "lang", "sha": "e9d869bff94fb13ad9262222a6f3c4aafba82d5e", "save_path": "github-repos/lean/kevinsullivan-lang", "path": "github-repos/lean/kevinsullivan-lang/lang-e9d869bff94fb13ad9262222a6f3c4aafba82d5e/demo/expressions_demo_current_alternate_all.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8128673133042216, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4999848125594002}}
{"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 \u2192\u2097\u1d62[R] F`) to be a linear isometric\nembedding of `E` into `F` and `linear_isometry_equiv` (notation: `E \u2243\u2097\u1d62[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' : \u2200 (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 \u2192 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) : \u21d1(to_linear_map f) = \u21d1f :=\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 : \u2200 (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 \u2022 x) = c \u2022 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 \u21d1f :=\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 \u21d1f :=\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 \u2194 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 \u2260 y) : coe_fn f x \u2260 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 \u21d1f :=\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 \u21d1f :=\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 \u21d1f :=\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 (\u21d1f '' 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 \u21d1f) = 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 (\u21d1f '' 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 \u21d1f) = 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) : \u21d1(to_continuous_linear_map f) = \u21d1f :=\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) {\u03b1 : Type u_4} [topological_space \u03b1] {g : \u03b1 \u2192 E} : continuous (\u21d1f \u2218 g) \u2194 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] : \u21d1id = \u21d1id :=\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) : \u21d1(comp g f) = \u21d1g \u2218 \u21d1f :=\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] : \u21d11 = \u21d1id :=\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) : \u21d1(f * g) = \u21d1f \u2218 \u21d1g :=\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' : \u2200 (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 \u2192 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 : \u2200 (x : E), norm (coe_fn e x) = norm x) : \u21d1(mk e he) = \u21d1e :=\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) : \u21d1(to_linear_equiv e) = \u21d1e :=\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 : \u2200 (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`\u2200 x, \u2225e x\u2225 \u2264 \u2225x\u2225` and `\u2200 y, \u2225e.symm y\u2225 \u2264 \u2225y\u2225`. -/\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\u2081 : \u2200 (x : E), norm (coe_fn e x) \u2264 norm x) (h\u2082 : \u2200 (y : F), norm (coe_fn (linear_equiv.symm e) y) \u2264 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 (\u2191(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 \u21d1e :=\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 \u2243\u1d62 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 \u21d1e :=\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] : \u21d1(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 \u2194 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) : \u21d1(linear_equiv.symm (to_linear_equiv e)) = \u21d1(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\u2081 : linear_isometry_equiv R E F) (e\u2082 : linear_isometry_equiv R F G) : \u21d1(trans e\u2081 e\u2082) = \u21d1e\u2082 \u2218 \u21d1e\u2081 :=\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\u2081 : linear_isometry_equiv R E F) (e\u2082 : linear_isometry_equiv R F G) : \u21d1(symm (trans e\u2081 e\u2082)) = \u21d1(symm e\u2081) \u2218 \u21d1(symm e\u2082) :=\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\u2081 e\u2082 : linear_isometry_equiv R E E) => trans e\u2082 e\u2081) sorry (refl R E) trans_refl refl_trans symm\n    (div_inv_monoid.div._default (fun (e\u2081 e\u2082 : linear_isometry_equiv R E E) => trans e\u2082 e\u2081) 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] : \u21d11 = 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) : \u21d1(e * e') = \u21d1e \u2218 \u21d1e' :=\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) : \u21d1(e\u207b\u00b9) = \u21d1(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 \u2022 x) = c \u2022 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 \u21d1e :=\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 \u21d1e :=\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 \u21d1e :=\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 \u2194 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 \u2260 y) : coe_fn e x \u2260 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 \u21d1e :=\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 \u21d1e :=\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 (\u21d1e '' 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 (\u21d1e '' 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* `\u03b8`, which is the specialization of evaluation-at-\u03be map `\u03d1` from `laurent_measures.theta`\n  at `\u03be=2\u207b\u00b9`.\n* `\u03d5` which corresponds to multiplying a Laurent series in `\u2112 S = (laurent_measures r S)`\n  for `r = 2^(1/p)` by `T\u207b\u00b9-2`.\n* `\u03c8` corresponds to dividing a Laurent series by `(T\u207b\u00b9-2)`. It is defined only on series\n  vanishing at `2\u207b\u00b9`, so that it again takes values in `\u2112 S`\n* The maps `\u0398`, `\u03a6` and `\u03a8` are the \"measurifications\" of `\u03b8`, `\u03d5` and `\u03c8`,\n  so they are morphisms in the right category (**[FAE]** Not here any more!)\n\nThe main results are\n* `injective_\u03d5` stating that `\u03d5` is injective;\n* `\u03b8_\u03d5_complex` stating that `\u03d5 \u2218 \u03b8 = 0`; and\n* `\u03b8_\u03d5_exact` stating that the kernel of `\u03b8` coincides with the image of `\u03d5`.\nTogether with `\u03d1_surjective` from `laurent_measures.theta` (specialized at `\u03be=2\u207b\u00b9`, so that `\u03d1` is\n`\u03b8`) 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 : \u211d\u22650}\n\nlocal notation `\u2112` := laurent_measures r\nvariables [fact (0 < r)]\nvariable {S : Fintype}\n\ndef \u03d5 : \u2112 S \u2192 \u2112 S :=\n\u03bb F, shift (1) F - 2 \u2022 F\n\nlemma \u03d5_apply (F : \u2112 S) (s : S) (n : \u2124) : \u03d5 F s n = F s (n+1) - 2 * F s n :=\nby simp only [\u03d5, sub_apply, nsmul_apply, shift_to_fun_to_fun, nsmul_eq_mul]; refl\n\nlemma \u03d5_natural (S T : Fintype) (f : S \u27f6 T) : --[fact (0 < p)] [fact ( p \u2264 1)] :\n  \u03d5 \u2218 laurent_measures.map_hom f = laurent_measures.map_hom f \u2218 \u03d5 :=\nbegin\n  ext F t n,\n  simp only [\u03d5, 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 @\u03d5\n\n-- lemma tsum_reindex (F : \u2112 S) (N : \u2124) (s : S) : \u2211' (l : \u2115), (F s (N + l) : \u211d) * (2 ^ l)\u207b\u00b9 =\n--  2 ^ N * \u2211' (m : {m : \u2124 // N \u2264 m}), (F s m : \u211d) * (2 ^ m.1)\u207b\u00b9 :=\n-- begin\n--   have h_shift := int_tsum_shift (\u03bb n, (F s n : \u211d) * (2 ^ (-n))) N,\n--   simp only at h_shift,\n--   simp_rw [subtype.val_eq_coe, \u2190 zpow_neg],\n--   rw [\u2190 h_shift, \u2190 _root_.tsum_mul_left, tsum_congr],\n--   intro n,\n--   rw [mul_comm (_ ^ N), mul_assoc, \u2190 (zpow_add\u2080 (@two_ne_zero \u211d _ _)), 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_\u03d5 (F : \u2112 S) (H : \u03d5 F = 0) : F = 0 :=\nbegin\n  dsimp only [\u03d5] at H, rw [sub_eq_zero] at H,\n  replace H : \u2200 n : \u2124, \u2200 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\u2080,\n    simp [\u2190 H (k + 1) s, add_sub_cancel, hk\u2080, mul_zero] },\n  { intros k h hk\u2080,\n    simpa only [hk\u2080, mul_eq_zero, bit0_eq_zero, one_ne_zero, false_or, zero_apply] using H k s }\nend\n\nlemma injective_\u03d5' : function.injective (\u03d5 : \u2112 S \u2192 \u2112 S) :=\nbegin\n  let PHI : comphaus_filtered_pseudo_normed_group_hom (\u2112 S) (\u2112 S) :=\n    shift (1) - 2 \u2022 comphaus_filtered_pseudo_normed_group_hom.id,\n  apply (injective_iff_map_eq_zero (PHI.to_add_monoid_hom)).mpr,\n  exact injective_\u03d5\nend\n\nend phi\n\nsection mem_exact\n\nparameter {p : \u211d\u22650}\n\n/-- `r`, or `r(p)`, is `2\u207b\u1d56`. -/\ndef r : \u211d\u22650 := 2\u207b\u00b9 ^ (p : \u211d)\n\nlemma r_pos : 0 < r :=\nsuffices 0 < (2 : \u211d\u22650)\u207b\u00b9 ^ (p : \u211d), by simpa [r],\nrpow_pos (nnreal.inv_pos.mpr zero_lt_two)\n\ninstance r_pos' : fact (0 < r) := \u27e8r_pos\u27e9\n\nlemma r_coe : (2\u207b\u00b9 : \u211d) ^ (p : \u211d) = r :=\nbegin\n  have : (2\u207b\u00b9 : \u211d) = ((2\u207b\u00b9 : \u211d\u22650) : \u211d),\n  simp only [one_div, nonneg.coe_inv, nnreal.coe_bit0, nonneg.coe_one],\n  rw [this, \u2190 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) := \u27e8r_lt_one\u27e9\n\nvariable {S : Fintype}\n\nlocal notation `\u2112` := laurent_measures r\nlocal notation `\u2133` := real_measures p\n\ntheorem nnreal.rpow_int_cast (x : nnreal) (n : \u2124) : x ^ (n : \u211d) = x ^ n :=\nbegin\n  apply subtype.ext,\n  simp,\nend\n\ndef \u03b8 : \u2112 S \u2192 \u2133 S := \u03d1 2\u207b\u00b9 r p S\n\nlemma \u03b8_natural [fact (0 < p)] [fact (p \u2264 1)] (S T : Fintype) (f : S \u27f6 T) (F : \u2112 S) (t : T) :\n  \u03b8 (map f F) t = real_measures.map f (\u03b8 F) t :=\nbegin\n  simp only [\u03b8, \u03d1, one_div, map_apply, int.cast_sum, inv_zpow', zpow_neg, real_measures.map_apply],\n  rw \u2190 tsum_sum,\n  { congr', ext n, exact sum_mul, },\n  intros,\n  rw mem_filter at H,\n  rcases H with \u27e8-, rfl\u27e9,\n  have := F.summable i,\n  refine summable.add_compl (_ : summable (_ \u2218 (coe : {n : \u2124 | 0 \u2264 n} \u2192 \u2124))) _,\n  { have moo := summable.comp_injective this\n      (subtype.coe_injective : function.injective (coe : {n : \u2124 | 0 \u2264 n} \u2192 \u2124)),\n    refine summable_of_norm_bounded _ (moo) _, clear moo this,\n    rintro \u27e8n, (hn : 0 \u2264 n)\u27e9,\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 : \u211d) ^ n)\u207b\u00b9 = ((2 ^ n)\u207b\u00b9 : nnreal)),\n    norm_cast,\n    rw [\u2190 nnreal.rpow_int_cast, \u2190 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 \u27e8d, hd\u27e9 := 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 \u27e8z, (hz : \u00ac (0 \u2264 z))\u27e9 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\u207b\u00b9 < r :=\ncalc (2\u207b\u00b9:\u211d\u22650)\n    = 2\u207b\u00b9 ^ (1:\u211d) : (rpow_one (2\u207b\u00b9:\u211d\u22650)).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\u207b\u00b9 : \u211d) < 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\u207b\u00b9 < 2 :=\nbegin\n  rw \u2190 inv_inv (2 : \u211d\u22650),\n  exact nnreal.inv_lt_inv (by norm_num) half_lt_r,\nend\n\nlemma laurent_measures.summable_half (F : \u2112 S) (s : S) :\n  summable (\u03bb n, ((F s n) : \u211d) * 2\u207b\u00b9 ^ n) :=\naux_thm69.summable_smaller_radius F.d (F.summable s) (\u03bb n hn, lt_d_eq_zero _ _ _ hn) half_lt_r\n\nlemma \u03b8_\u03d5_complex (F : \u2112 S) : (\u03b8 \u2218 \u03d5) F = 0 :=\nbegin\n  have t0 : (2 : \u211d)\u207b\u00b9 \u2260 0 := inv_ne_zero two_ne_zero,\n  funext s,\n  convert_to \u2211' (n : \u2124), ((F s (n + 1) - 2 * F s n) : \u211d) * 2\u207b\u00b9 ^ n = 0,\n  { apply tsum_congr,\n    intro b,\n    field_simp [\u03d5] },\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 (\u03bb i, (i.val : \u2124) - 1) _ _ _,\n    { rintros \u27e8x, _\u27e9 \u27e8y, _\u27e9 h, dsimp at *, linarith },\n    { rintros x hx,\n      refine \u27e8\u27e8x + 1, _\u27e9, _\u27e9,\n      { rw function.mem_support at \u22a2 hx,\n        convert hx using 1,\n        simp [zpow_add\u2080],\n        ring },\n      { simp } },\n    { rintro \u27e8i, hi\u27e9,\n      simp [zpow_sub\u2080],\n      ring } },\n  { rw \u2190 (equiv.add_group_add (-1 : \u2124)).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\u2080], ring },\n  { simp_rw [mul_assoc],\n    convert (F.summable_half s).mul_left 2 },\nend\n.\n\n/-!\n\n### Definition of \u03c8\n\nThis involves dividing by T\u207b\u00b9 - 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 \u211d\u22650-valued\nsum of sums\"\n\n-/\n\nlemma nnreal.summable_mul_left_iff {X : Type*} {f : X \u2192 \u211d\u22650} {a : \u211d\u22650} (ha : a \u2260 0) :\nsummable f \u2194 summable (\u03bb (x : X), a * f x) :=\nbegin\n  rw [\u2190 nnreal.summable_coe, \u2190 nnreal.summable_coe],\n  rw summable_mul_left_iff (by exact_mod_cast ha : (a : \u211d) \u2260 0),\n  apply summable_congr,\n  intro b,\n  norm_cast,\nend\n\nlemma psi_def_summable {S : Fintype} (n : \u2115)\n  (F : \u2112 S)\n  (s : S) :\n  summable\n    (\u03bb (k : \u2115),\n       r ^ (F.d + \u2191n) *\n         (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a)) :=\nbegin\n  have := F.summable_half s,\n  apply summable.mul_left,\n  have h : (2\u207b\u00b9 : \u211d\u22650) \u2260 0 := by norm_num,\n  rw nnreal.summable_mul_left_iff (show ((2\u207b\u00b9 : \u211d\u22650) ^ (F.d + n) \u2260 0), from zpow_ne_zero _ h),\n  simp only [\u2190 mul_assoc, \u2190 zpow_add\u2080 h],\n  have this2 := lt_d_eq_zero F s,\n  rw \u2190 summable_norm_iff at this,\n  simp_rw \u2190 _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 : \u2112 S)\n  (s : \u21a5S) :\n  \u2200 (k : \u2115),\n    summable\n      (\u03bb (n : \u2115),\n         r ^ (F.d + \u2191n) *\n           ((2\u207b\u00b9 : \u211d\u22650) ^ (k : \u2124) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a)) :=\nbegin\n  intro k,\n  have hhalf : (2\u207b\u00b9 : \u211d\u22650) \u2260 0, by norm_num,\n  have hhalf' : (2\u207b\u00b9 : \u211d\u22650) \u2260 0, by norm_num,\n  have hr : r \u2260 0 := r_pos.ne.symm,\n  rw nnreal.summable_mul_left_iff\n    (show (2\u207b\u00b9 : \u211d\u22650) ^ (-(k : \u2124)) * r ^ (k : \u2124) \u2260 0, from mul_ne_zero (zpow_ne_zero _ hhalf') (zpow_ne_zero _ hr)),\n  have : \u2200 x : \u2115, 2\u207b\u00b9 ^ -(k : \u2124) * r ^ (k : \u2124) * (r ^ (F.d + \u2191x) * (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191x + \u2191k)\u2225\u208a))\n    = r ^ (F.d + x + k) * \u2225F s (F.d + \u2191x + \u2191k)\u2225\u208a,\n  { intro x,\n    rw (show (2\u207b\u00b9 : \u211d\u22650) ^ -(k : \u2124) * r ^ (k : \u2124) * (r ^ (F.d + \u2191x) * (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191x + \u2191k)\u2225\u208a))\n      = (2\u207b\u00b9 : \u211d\u22650) ^ -(k : \u2124) * 2\u207b\u00b9 ^ (k : \u2124) * r ^ (k : \u2124) * r ^ (F.d + \u2191x) *  \u2225F s (F.d + \u2191x + \u2191k)\u2225\u208a, by ring),\n    simp only [zpow_add\u2080 hr, \u2190 zpow_add\u2080 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 : \u2112 S)\n  (s : \u21a5S) :\n  summable\n    (\u03bb (k : \u2115),\n       \u2211' (n : \u2115),\n         r ^ (F.d + \u2191n) *\n           (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a)) :=\nbegin\n  -- take 2\u207b\u00b9^k out the tsum,\n  -- put r^k into the tsum,\n  -- bounded by sum of GP,\n  have bdd : \u2200 k : \u2115, \u2211' (n : \u2115),\n         r ^ (F.d + \u2191n + k) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a \u2264\n           \u2211' (t : \u2124),\n         r ^ t * \u2225F s t\u2225\u208a,\n  { intro k,\n    simp_rw add_right_comm,\n    have hinj : function.injective (\u03bb (m : \u2115), 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 \u2190 @nnreal.summable_iff_on_nat_less_shift (\u03bb (z : \u2124), r ^ z * \u2225F s z\u2225\u208a) 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 : \u2200 k : \u2115, \u2211' (n : \u2115), r ^ (F.d + \u2191n) * (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a) =\n   (\u2211' (n : \u2115), r ^ (F.d + \u2191n + k) * (\u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a)) * (2\u207b\u00b9 * r\u207b\u00b9) ^ (k : \u2124),\n  { intro k,\n    rw \u2190 nnreal.tsum_mul_right,\n    apply tsum_congr,\n    intro n,\n    simp only [zpow_add\u2080 r_pos.ne.symm, zpow_coe_nat, one_div, inv_pow, div_zpow],\n    have foo : (2 * r) ^ k \u2260 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 (\u03bb k : \u2115, (\u2211' (t : \u2124), r ^ t * \u2225F s t\u2225\u208a) * (2\u207b\u00b9 * r\u207b\u00b9) ^ 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 : \u2112 S) (s : \u21a5S) : summable\n  (\u03bb (m : \u2115),\n     \u2225(2 : \u211d) ^ (F.d + \u2191m)\u2225\u208a *\n       ((\u2211' (k : \u2115), \u2225F s (F.d + \u2191m + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (F.d + \u2191m + \u2191k)) * r ^ (F.d + \u2191m))) :=\nbegin\n  -- tidy up\n  simp_rw [nnnorm_zpow, real.nnnorm_two],\n  have : \u2200 m : \u2115, (2 : \u211d\u22650) ^ (F.d + \u2191m) *\n  ((\u2211' (k : \u2115), \u2225F s (F.d + \u2191m + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (F.d + \u2191m + \u2191k)) * r ^ (F.d + \u2191m)) =\n  \u2211' (k : \u2115), (2 : \u211d\u22650) ^ (F.d + \u2191m) * \u2225F s (F.d + \u2191m + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (F.d + \u2191m + \u2191k) * r ^ (F.d + \u2191m),\n  { intro m,\n    rw [\u2190 nnreal.tsum_mul_right, \u2190 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\u207b\u00b9^x)\n  suffices : summable\n  (\u03bb (m : \u2115), \u2211' (k : \u2115),\n       \u2225F s (F.d + \u2191m + \u2191k)\u2225\u208a *\n       2\u207b\u00b9 ^ (k : \u2124) * r ^ (F.d + \u2191m)),\n  { refine (summable_congr _).2 this,\n    intro m,\n    apply tsum_congr,\n    intro b,\n    rw [inv_zpow , inv_zpow],\n    rw [\u2190 zpow_neg, \u2190zpow_neg],\n    have h2 : (2 : \u211d\u22650) \u2260 0 := two_ne_zero,\n    simp only [zpow_add\u2080, 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 : \u2112 S) (s : \u21a5S) : summable\n  (\u03bb (n : \u2124),\n     \u2225-(2 : \u211d) ^ (n - 1)\u2225\u208a *\n       ite (F.d \u2264 n) ((\u2211' (k : \u2115), \u2225F s (n + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (n + \u2191k)) * r ^ n) 0) :=\nbegin\n  -- get rid of factor of -2\u207b\u00b9\n  simp_rw [_root_.nnnorm_neg, zpow_sub\u2080 (two_ne_zero : (2 : \u211d) \u2260 0), nnnorm_div, zpow_one,\n    div_eq_mul_inv _ \u2225(2 : \u211d)\u2225\u208a, mul_comm _ \u2225(2 : \u211d)\u2225\u208a\u207b\u00b9, mul_assoc],\n  apply summable.mul_left,\n  have hinj : function.injective (\u03bb (m : \u2115), F.d + m),\n  { rintros a b (h2 : F.d + a = F.d + b),\n    simpa using h2 },\n  -- change outer sum to m : \u2115 with n : \u2124 = F.d + m\n  suffices : summable (\u03bb (m : \u2115),\n     \u2225(2 : \u211d) ^ (F.d + m)\u2225\u208a *\n       ((\u2211' (k : \u2115), \u2225F s (F.d + m + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (F.d + m + \u2191k)) * 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 : \u2112 S) (s : \u21a5S) : summable\n  (\u03bb (n : \u2124),\n     ite (F.d \u2264 n) \u2225-(2 : \u211d) ^ (n - 1) * \u2211' (k : \u2115), \u2191(F s (n + \u2191k)) * 2\u207b\u00b9 ^ (n + \u2191k) * r ^ n\u2225\u208a 0) :=\nbegin\n  simp_rw [nnnorm_mul],\n  -- next : put norm inside inner tsum (a one way implication)\n  suffices : summable\n  (\u03bb (n : \u2124), \u2225-(2 : \u211d) ^ (n - 1)\u2225\u208a *\n     ite (F.d \u2264 n)\n     ((\u2211' (k : \u2115), \u2225F s (n + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (n + \u2191k)) * 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 \u2190 summable_norm_iff at this,\n          simp_rw \u2190 _root_.coe_nnnorm at this,\n          rw nnreal.summable_coe at this,\n          have hinj : function.injective (\u03bb (b : \u2115), 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 [\u2190 zpow_neg] },\n        { rw \u2190 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 : \u2112 S) (s : \u21a5S) :\n  summable (\u03bb (n : \u2124), \u2225ite (F.d \u2264 n) (-(2 : \u211d) ^ (n - 1) *\n    \u2211' (k : \u2115), \u2191(F s (n + \u2191k)) * 2\u207b\u00b9 ^ (n + \u2191k)) 0\u2225\u208a * r ^ n) :=\nbegin\n  suffices :  summable (\u03bb (n : \u2124), ite (F.d \u2264 n) \u2225-(2 : \u211d) ^ (n - 1) *\n    \u2211' (k : \u2115), \u2191(F s (n + \u2191k)) * 2\u207b\u00b9 ^ (n + \u2191k) * r ^ n\u2225\u208a 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 [ \u2190 mul_assoc, nnnorm_mul _ ((r : \u211d) ^ n)],\n      simp },\n    { simp } },\n  exact psi_def_aux_2 _ _,\nend\n\ndef \u03c8 (F : \u2112 S) (hF : \u03b8 F = 0) : \u2112 S :=\n{ to_fun := \u03bb s n, if F.d \u2264 n then\n    \u2211 l in range (n - F.d).nat_abs.succ, F s (n - 1 - l) * (2 ^ l)\n    else 0,\n  summable' := \u03bb s, begin\n    -- make everything real\n    change summable (\u03bb (n : \u2124),\n     \u2225((ite (F.d \u2264 n)\n       (\u2211 (l : \u2115) in range (n - F.d).nat_abs.succ, F s (n - 1 - \u2191l) * 2 ^ l) 0 : \u2124) : \u211d)\u2225\u208a\n     * r ^ n),\n    push_cast,\n    -- hypothesis that infinite sum converges at r>2\u207b\u00b9\n    -- get hypothesis that infinite sum is 0 at 2\u207b\u00b9\n    simp only [\u03b8, \u03d1] at hF,\n    replace hF := congr_fun hF s, dsimp at hF,\n    -- change sum from \u2124 to \u2115\n    --rw nnreal.summable_iff_on_nat_less F.d, swap,\n    --{ intros n hn, simp [if_neg hn.not_le] },\n    have h1 : \u2200 (n : \u2124),\n      ite (F.d \u2264 n) (\u2211 (l : \u2115) in range (n - F.d).nat_abs.succ, (F s (n - 1 - \u2191l) : \u211d) * 2 ^ l) 0 =\n      ite (F.d \u2264 n) (-(2 : \u211d)^(n-1)*\u2211' (k : \u2115), F s (n + k) * 2\u207b\u00b9 ^ (n + k)) 0,\n    { intro n,\n      split_ifs with hn, swap, refl,\n      rw [\u2190 inv_mul_eq_iff_eq_mul\u2080, \u2190 neg_inv, neg_mul, mul_sum, neg_eq_iff_add_eq_zero, \u2190 hF],\n        swap, exact neg_ne_zero.2 (zpow_ne_zero _ two_ne_zero),\n      convert @tsum_add_tsum_compl \u211d \u2124 _ _ _ _ _ {x : \u2124 | x < n}\n        (summable.subtype (F.summable_half s) _) (summable.subtype (F.summable_half s) _) using 2,\n      { simp_rw [\u2190 inv_zpow, mul_comm ((2\u207b\u00b9 : \u211d)^(n-1)), mul_assoc],\n        simp_rw (show \u2200 (x : \u2115), (2 : \u211d)^x = 2\u207b\u00b9^(-(x : \u2124)), by {intros, simp}),\n        simp_rw [\u2190 zpow_add\u2080 (by norm_num : (2\u207b\u00b9 : \u211d) \u2260 0), add_comm, \u2190 sub_eq_add_neg],\n        rw \u2190 tsum_eq_sum,\n        convert @equiv.tsum_eq \u211d _ _ _ _ _\n          (\u27e8\u03bb m, \u27e8n - 1 - m, lt_of_le_of_lt (sub_le_self _ (int.coe_zero_le m)) (sub_one_lt n)\u27e9,\n           (\u03bb z, (n - 1 - z.1).nat_abs), \u03bb m, by simp, \u03bb \u27e8z, hz\u27e9, subtype.ext begin\n--             squeeze_simp,\n             change n - 1 - (n - 1 - z).nat_abs = z,\n             rw \u2190 int.eq_nat_abs_of_zero_le (sub_nonneg_of_le (int.le_sub_one_of_lt hz)),\n             ring, end\u27e9 : \u2115 \u2243 {z : \u2124 // 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, \u2190 int.coe_nat_lt, int.coe_nat_add,\n            \u2190 int.eq_nat_abs_of_zero_le]; linarith } },\n      { convert @equiv.tsum_eq \u211d _ _ _ _ _\n          (\u27e8\u03bb x, \u27e8n + x, (int.le.intro rfl).not_lt\u27e9, (\u03bb z, (z.1 - n).nat_abs),\n            \u03bb x, by simp, \u03bb \u27e8x, hx\u27e9, subtype.ext begin\n              change n + _ = x,\n              rw \u2190 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\u27e9 : \u2115 \u2243 {z : \u2124 // \u00ac z < n}) _,\n        ext, refl },\n    },\n    suffices : summable (\u03bb (n : \u2124),\n     \u2225ite (F.d \u2264 n) (-(2 : \u211d)^(n-1)*\u2211' (k : \u2115), \u2191(F s (n + k)) * 2\u207b\u00b9 ^ (n + k)) 0\u2225\u208a *\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 \u03b8_\u03d5_split_exact (F : \u2112 S) (hF : \u03b8 F = 0) : \u03d5 (\u03c8 F hF) = F :=\nbegin\n  ext s n,\n  simp only [\u03d5, \u03c8, 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 : \u2124) + 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 \u27e8m, hm\u27e9 := (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 \u03b8_\u03d5_exact (F : \u2112 S) (hF : \u03b8 F = 0) : \u2203 G, \u03d5 G = F :=\n\u27e8\u03c8 F hF, \u03b8_\u03d5_split_exact F hF\u27e9\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 \u00d7 -)` 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\u2082\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 \u00d7 -)` 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 \u2a2f 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 \u2a2f 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 \u22a4_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 \u2964 C :=\n(@closed.is_adj _ _ _ A _).right\n\n/-- The adjunction between A \u2a2f - and (-)^A. -/\ndef exp.adjunction : prod.functor.obj A \u22a3 exp A :=\nclosed.is_adj.adj\n\n/-- The evaluation natural transformation. -/\ndef ev : exp A \u22d9 prod.functor.obj A \u27f6 \ud835\udfed C :=\n(exp.adjunction A).counit\n\n/-- The coevaluation natural transformation. -/\ndef coev : \ud835\udfed C \u27f6 prod.functor.obj A \u22d9 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 \u27f6 Y) :\n  limits.prod.map (\ud835\udfd9 A) ((exp A).map f) \u226b (ev A).app Y = (ev A).app X \u226b f :=\n(ev A).naturality f\n\n@[simp, reassoc]\nlemma coev_naturality {X Y : C} (f : X \u27f6 Y) :\n  f \u226b (coev A).app Y = (coev A).app X \u226b (exp A).map (limits.prod.map (\ud835\udfd9 A) f) :=\n(coev A).naturality f\n\nnotation A ` \u27f9 `: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 (\ud835\udfd9 A) ((coev A).app B) \u226b (ev A).app (A \u2a2f B) = \ud835\udfd9 (A \u2a2f B) :=\nadjunction.left_triangle_components (exp.adjunction A)\n\n@[simp, reassoc] lemma coev_ev : (coev A).app (A\u27f9B) \u226b (exp A).map ((ev A).app B) = \ud835\udfd9 (A\u27f9B) :=\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 \u2a2f Y \u27f6 X) \u2192 (Y \u27f6 A \u27f9 X) :=\n(exp.adjunction A).hom_equiv _ _\n/-- Uncurrying in a cartesian closed category. -/\ndef uncurry : (Y \u27f6 A \u27f9 X) \u2192 (A \u2a2f Y \u27f6 X) :=\n((exp.adjunction A).hom_equiv _ _).symm\n\n@[simp] lemma hom_equiv_apply_eq (f : A \u2a2f Y \u27f6 X) :\n  (exp.adjunction A).hom_equiv _ _ f = curry f := rfl\n@[simp] lemma hom_equiv_symm_apply_eq (f : Y \u27f6 A \u27f9 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 \u27f6 X') (g : A \u2a2f X' \u27f6 Y) :\n  curry (limits.prod.map (\ud835\udfd9 _) f \u226b g) = f \u226b curry g :=\nadjunction.hom_equiv_naturality_left _ _ _\n\n@[reassoc]\nlemma curry_natural_right (f : A \u2a2f X \u27f6 Y) (g : Y \u27f6 Y') :\n  curry (f \u226b g) = curry f \u226b (exp _).map g :=\nadjunction.hom_equiv_naturality_right _ _ _\n\n@[reassoc]\nlemma uncurry_natural_right  (f : X \u27f6 A\u27f9Y) (g : Y \u27f6 Y') :\n  uncurry (f \u226b (exp _).map g) = uncurry f \u226b g :=\nadjunction.hom_equiv_naturality_right_symm _ _ _\n\n@[reassoc]\nlemma uncurry_natural_left  (f : X \u27f6 X') (g : X' \u27f6 A\u27f9Y) :\n  uncurry (f \u226b g) = limits.prod.map (\ud835\udfd9 _) f \u226b uncurry g :=\nadjunction.hom_equiv_naturality_left_symm _ _ _\n\n@[simp]\nlemma uncurry_curry (f : A \u2a2f X \u27f6 Y) : uncurry (curry f) = f :=\n(closed.is_adj.adj.hom_equiv _ _).left_inv f\n\n@[simp]\nlemma curry_uncurry (f : X \u27f6 A\u27f9Y) : curry (uncurry f) = f :=\n(closed.is_adj.adj.hom_equiv _ _).right_inv f\n\nlemma curry_eq_iff (f : A \u2a2f Y \u27f6 X) (g : Y \u27f6 A \u27f9 X) :\n  curry f = g \u2194 f = uncurry g :=\nadjunction.hom_equiv_apply_eq _ f g\n\nlemma eq_curry_iff (f : A \u2a2f Y \u27f6 X) (g : Y \u27f6 A \u27f9 X) :\n  g = curry f \u2194 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 \u27f6 A \u27f9 X) : uncurry g = limits.prod.map (\ud835\udfd9 A) g \u226b (ev A).app X :=\nadjunction.hom_equiv_counit _\n\nlemma curry_eq (g : A \u2a2f Y \u27f6 X) : curry g = (coev A).app Y \u226b (exp A).map g :=\nadjunction.hom_equiv_unit _\n\nlemma uncurry_id_eq_ev (A X : C) [exponentiable A] : uncurry (\ud835\udfd9 (A \u27f9 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 (\ud835\udfd9 _) = (coev A).app X :=\nby { rw [curry_eq, (exp A).map_id (A \u2a2f _)], apply comp_id }\n\nlemma curry_injective : function.injective (curry : (A \u2a2f Y \u27f6 X) \u2192 (Y \u27f6 A \u27f9 X)) :=\n(closed.is_adj.adj.hom_equiv _ _).injective\n\nlemma uncurry_injective : function.injective (uncurry : (Y \u27f6 A \u27f9 X) \u2192 (A \u2a2f Y \u27f6 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 \u2245 X`.\n\nThe typeclass argument is explicit: any instance can be used.\n-/\ndef exp_terminal_iso_self [exponentiable \u22a4_C] : (\u22a4_C \u27f9 X) \u2245 X :=\nyoneda.ext (\u22a4_ C \u27f9 X) X\n  (\u03bb Y f, (prod.left_unitor Y).inv \u226b uncurry f)\n  (\u03bb Y f, curry ((prod.left_unitor Y).hom \u226b f))\n  (\u03bb Z g, by rw [curry_eq_iff, iso.hom_inv_id_assoc] )\n  (\u03bb Z g, by simp)\n  (\u03bb 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 \u27f6 Y) : \u22a4_C \u27f6 (A \u27f9 Y) :=\ncurry (limits.prod.fst \u226b f)\n\nsection pre\n\nvariables {B}\n\n/-- Pre-compose an internal hom with an external hom. -/\ndef pre (f : B \u27f6 A) [exponentiable B] : exp A \u27f6 exp B :=\ntransfer_nat_trans_self (exp.adjunction _) (exp.adjunction _) (prod.functor.map f)\n\nlemma prod_map_pre_app_comp_ev (f : B \u27f6 A) [exponentiable B] (X : C) :\n  limits.prod.map (\ud835\udfd9 B) ((pre f).app X) \u226b (ev B).app X =\n    limits.prod.map f (\ud835\udfd9 (A \u27f9 X)) \u226b (ev A).app X :=\ntransfer_nat_trans_self_counit _ _ (prod.functor.map f) X\n\nlemma uncurry_pre (f : B \u27f6 A) [exponentiable B] (X : C) :\n  uncurry ((pre f).app X) = limits.prod.map f (\ud835\udfd9 _) \u226b (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 \u27f6 A) [exponentiable B] :\n  (coev A).app X \u226b (pre f).app (A \u2a2f X) = (coev B).app X \u226b (exp B).map (limits.prod.map f (\ud835\udfd9 _)) :=\nunit_transfer_nat_trans_self _ _ (prod.functor.map f) X\n\n@[simp]\nlemma pre_id (A : C) [exponentiable A] : pre (\ud835\udfd9 A) = \ud835\udfd9 _ :=\nby simp [pre]\n\n@[simp]\nlemma pre_map {A\u2081 A\u2082 A\u2083 : C} [exponentiable A\u2081] [exponentiable A\u2082] [exponentiable A\u2083]\n  (f : A\u2081 \u27f6 A\u2082) (g : A\u2082 \u27f6 A\u2083) :\n  pre (f \u226b g) = pre g \u226b 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\u1d52\u1d56 \u2964 C \u2964 C :=\n{ obj := \u03bb X, exp X.unop,\n  map := \u03bb X Y f, pre f.unop }\n\n/-- If an initial object `I` exists in a CCC, then `A \u2a2f I \u2245 I`. -/\n@[simps]\ndef zero_mul {I : C} (t : is_initial I) : A \u2a2f I \u2245 I :=\n{ hom := limits.prod.snd,\n  inv := t.to _,\n  hom_inv_id' :=\n  begin\n    have: (limits.prod.snd : A \u2a2f I \u27f6 I) = uncurry (t.to _),\n      rw \u2190 curry_eq_iff,\n      apply t.hom_ext,\n    rw [this, \u2190 uncurry_natural_right, \u2190 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 \u2a2f A \u2245 0`. -/\ndef mul_zero {I : C} (t : is_initial I) : I \u2a2f A \u2245 I :=\nlimits.prod.braiding _ _ \u226a\u226b zero_mul t\n\n/-- If an initial object `0` exists in a CCC then `0^B \u2245 1` for any `B`. -/\ndef pow_zero {I : C} (t : is_initial I) [cartesian_closed C] : I \u27f9 B \u2245 \u22a4_ C :=\n{ hom := default _,\n  inv := curry ((mul_zero t).hom \u226b t.to _),\n  hom_inv_id' :=\n  begin\n    rw [\u2190 curry_natural_left, curry_eq_iff, \u2190 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 \u2a2f X) \u2a3f (Z \u2a2f Y) \u2245 Z \u2a2f (X \u2a3f Y) :=\n{ hom := coprod.desc (limits.prod.map (\ud835\udfd9 _) coprod.inl) (limits.prod.map (\ud835\udfd9 _) 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, \u2190uncurry_natural_left, coprod.inl_desc, uncurry_curry],\n    rw [coprod.inr_desc_assoc, comp_id, \u2190uncurry_natural_left, coprod.inr_desc, uncurry_curry],\n  end,\n  inv_hom_id' :=\n  begin\n    rw [\u2190 uncurry_natural_right, \u2190eq_curry_iff],\n    apply coprod.hom_ext,\n    rw [coprod.inl_desc_assoc, \u2190curry_natural_right, coprod.inl_desc, \u2190curry_natural_left, comp_id],\n    rw [coprod.inr_desc_assoc, \u2190curry_natural_right, coprod.inr_desc, \u2190curry_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 \u27f6 I) : is_iso f :=\nbegin\n  haveI : mono (limits.prod.lift (\ud835\udfd9 A) f \u226b (zero_mul t).hom) := mono_comp _ _,\n  rw [zero_mul_hom, prod.lift_snd] at _inst,\n  haveI: split_epi f := \u27e8t.to _, t.hom_ext _ _\u27e9,\n  apply is_iso_of_mono_of_split_epi\nend\n\ninstance to_initial_is_iso [has_initial C] (f : A \u27f6 \u22a5_ 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\u27e8\u03bb 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\u27e9\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\u2082} [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 \u224c D) [h : cartesian_closed C] : cartesian_closed D :=\n{ closed := \u03bb 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 \u22d9 prod.functor.obj X \u22d9 e.inverse \u2245 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)) \u226a\u226b _,\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, \u2190 e.inverse.map_comp, \u2190 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 \u22d9 prod.functor.obj X \u22d9 e.inverse) :=\n          by exactI adjunction.left_adjoint_of_nat_iso this.symm,\n        have : is_left_adjoint (e.inverse \u22d9 e.functor \u22d9 prod.functor.obj X \u22d9 e.inverse) :=\n          by exactI adjunction.left_adjoint_of_comp e.inverse _,\n        have : (e.inverse \u22d9 e.functor \u22d9 prod.functor.obj X \u22d9 e.inverse) \u22d9 e.functor \u2245\n          prod.functor.obj X,\n        { apply iso_whisker_right e.counit_iso (prod.functor.obj X \u22d9 e.inverse \u22d9 e.functor) \u226a\u226b _,\n          change prod.functor.obj X \u22d9 e.inverse \u22d9 e.functor \u2245 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 `\u03b1` to be *minimal* if the\n`M`-orbit of every point `x : \u03b1` 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 : \u03b1` is dense. -/\nclass AddAction.IsMinimal (M \u03b1 : Type _) [AddMonoid M] [TopologicalSpace \u03b1] [AddAction M \u03b1] :\n    Prop where\n  dense_orbit : \u2200 x : \u03b1, 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 : \u03b1` is dense. -/\n@[to_additive]\nclass MulAction.IsMinimal (M \u03b1 : Type _) [Monoid M] [TopologicalSpace \u03b1] [MulAction M \u03b1] :\n    Prop where\n  dense_orbit : \u2200 x : \u03b1, Dense (MulAction.orbit M x)\n#align mul_action.is_minimal MulAction.IsMinimal\n\nopen MulAction Set\n\nvariable (M G : Type _) {\u03b1 : Type _} [Monoid M] [Group G] [TopologicalSpace \u03b1] [MulAction M \u03b1]\n  [MulAction G \u03b1]\n\n@[to_additive]\ntheorem MulAction.dense_orbit [IsMinimal M \u03b1] (x : \u03b1) : 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 \u03b1] (x : \u03b1) : DenseRange fun c : M \u21a6 c \u2022 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 \u03b1] :\n    IsMinimal M \u03b1 :=\n  \u27e8fun x \u21a6 (surjective_smul M x).denseRange\u27e9\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 \u03b1] (x : \u03b1) {U : Set \u03b1} (hUo : IsOpen U)\n    (hne : U.Nonempty) : \u2203 c : M, c \u2022 x \u2208 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\u1d62_preimage_smul [IsMinimal M \u03b1] {U : Set \u03b1} (hUo : IsOpen U)\n    (hne : U.Nonempty) : (\u22c3 c : M, (\u00b7 \u2022 \u00b7) c \u207b\u00b9' U) = univ :=\n  union\u1d62_eq_univ_iff.2 fun x \u21a6 hUo.exists_smul_mem M x hne\n#align is_open.Union_preimage_smul IsOpen.union\u1d62_preimage_smul\n#align is_open.Union_preimage_vadd IsOpen.union\u1d62_preimage_vadd\n\n@[to_additive]\ntheorem IsOpen.union\u1d62_smul [IsMinimal G \u03b1] {U : Set \u03b1} (hUo : IsOpen U) (hne : U.Nonempty) :\n    (\u22c3 g : G, g \u2022 U) = univ :=\n  union\u1d62_eq_univ_iff.2 fun x \u21a6\n    let \u27e8g, hg\u27e9 := hUo.exists_smul_mem G x hne\n    \u27e8g\u207b\u00b9, _, hg, inv_smul_smul _ _\u27e9\n#align is_open.Union_smul IsOpen.union\u1d62_smul\n#align is_open.Union_vadd IsOpen.union\u1d62_vadd\n\n@[to_additive]\ntheorem IsCompact.exists_finite_cover_smul [IsMinimal G \u03b1] [ContinuousConstSMul G \u03b1]\n    {K U : Set \u03b1} (hK : IsCompact K) (hUo : IsOpen U) (hne : U.Nonempty) :\n    \u2203 I : Finset G, K \u2286 \u22c3 g \u2208 I, g \u2022 U :=\n  (hK.elim_finite_subcover (fun g \u21a6 g \u2022 U) fun _ \u21a6 hUo.smul _) <| calc\n    K \u2286 univ := subset_univ K\n    _ = \u22c3 g : G, g \u2022 U := (hUo.union\u1d62_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 \u03b1] {s : Set \u03b1} (hne : s.Nonempty)\n    (hsmul : \u2200 c : M, c \u2022 s \u2286 s) : Dense s :=\n  let \u27e8x, hx\u27e9 := hne\n  (MulAction.dense_orbit M x).mono (range_subset_iff.2 fun c \u21a6 hsmul c \u27e8x, hx, rfl\u27e9)\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 \u03b1] {s : Set \u03b1} (hs : IsClosed s)\n    (hsmul : \u2200 c : M, c \u2022 s \u2286 s) : s = \u2205 \u2228 s = univ :=\n  s.eq_empty_or_nonempty.imp_right fun hne \u21a6\n    hs.closure_eq \u25b8 (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 \u03b1] :\n    IsMinimal M \u03b1 \u2194 \u2200 s : Set \u03b1, IsClosed s \u2192 (\u2200 c : M, c \u2022 s \u2286 s) \u2192 s = \u2205 \u2228 s = univ := by\n  constructor\n  \u00b7 intro _ _\n    exact eq_empty_or_univ_of_smul_invariant_closed M\n  refine' fun H \u21a6 \u27e8fun _ \u21a6 dense_iff_closure_eq.2 <| (H _ _ _).resolve_left _\u27e9\n  exacts[isClosed_closure, fun _ \u21a6 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u2243 m'` and `n \u2243 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') : Matrix m n A \u2243\u2097[R] Matrix m' n' A :=\n  { reindex e\u2098 e\u2099 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') (M : Matrix m n A) :\n    reindexLinearEquiv R A e\u2098 e\u2099 M = reindex e\u2098 e\u2099 M :=\n  rfl\n#align matrix.reindex_linear_equiv_apply Matrix.reindexLinearEquiv_apply\n\n@[simp]\ntheorem reindexLinearEquiv_symm (e\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') :\n    (reindexLinearEquiv R A e\u2098 e\u2099).symm = reindexLinearEquiv R A e\u2098.symm e\u2099.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\u2081 : m \u2243 m') (e\u2082 : n \u2243 n') (e\u2081' : m' \u2243 m'') (e\u2082' : n' \u2243 n'') :\n    (reindexLinearEquiv R A e\u2081 e\u2082).trans (reindexLinearEquiv R A e\u2081' e\u2082') =\n      (reindexLinearEquiv R A (e\u2081.trans e\u2081') (e\u2082.trans e\u2082') : _ \u2243\u2097[R] _) :=\n  by\n  ext\n  rfl\n#align matrix.reindex_linear_equiv_trans Matrix.reindexLinearEquiv_trans\n\ntheorem reindexLinearEquiv_comp (e\u2081 : m \u2243 m') (e\u2082 : n \u2243 n') (e\u2081' : m' \u2243 m'') (e\u2082' : n' \u2243 n'') :\n    reindexLinearEquiv R A e\u2081' e\u2082' \u2218 reindexLinearEquiv R A e\u2081 e\u2082 =\n      reindexLinearEquiv R A (e\u2081.trans e\u2081') (e\u2082.trans e\u2082') :=\n  by\n  rw [\u2190 reindex_linear_equiv_trans]\n  rfl\n#align matrix.reindex_linear_equiv_comp Matrix.reindexLinearEquiv_comp\n\ntheorem reindexLinearEquiv_comp_apply (e\u2081 : m \u2243 m') (e\u2082 : n \u2243 n') (e\u2081' : m' \u2243 m'') (e\u2082' : n' \u2243 n'')\n    (M : Matrix m n A) :\n    (reindexLinearEquiv R A e\u2081' e\u2082') (reindexLinearEquiv R A e\u2081 e\u2082 M) =\n      reindexLinearEquiv R A (e\u2081.trans e\u2081') (e\u2082.trans e\u2082') 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 \u2243 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') (e\u2092 : o \u2243 o')\n    (M : Matrix m n A) (N : Matrix n o A) :\n    reindexLinearEquiv R A e\u2098 e\u2099 M \u2b1d reindexLinearEquiv R A e\u2099 e\u2092 N =\n      reindexLinearEquiv R A e\u2098 e\u2092 (M \u2b1d 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\u2081 : o \u2243 n) (e\u2082 : o \u2243 n')\n    (M : Matrix m n A) :\n    M.mul (reindexLinearEquiv R A e\u2081 e\u2082 1) =\n      reindexLinearEquiv R A (Equiv.refl m) (e\u2081.symm.trans e\u2082) M :=\n  haveI := Fintype.ofEquiv _ e\u2081.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 \u2243 n) : Matrix m m R \u2243\u2090[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 \u2243 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 \u2243 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 \u2243 n) (M : Matrix m m R) (N : Matrix m m R) :\n    reindexAlgEquiv R e (M \u2b1d N) = reindexAlgEquiv R e M \u2b1d 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 \u2243 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 \u2243 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 \u2194 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 : \u2115} (h : n + succ k = m) : n < m :=\n  h \u25b8 nat.succ_le_succ (nat.le_add_right n k)\n\nend nat\n\nnamespace list\n\nsection\nparameter {\u03b1 : Type u}\nparameter (n : \u2115)\nparameter (f : fin n \u2192 \u03b1)\n\nprotected\ndef generate_core : \u03a0 (i j : \u2115), i + j = n  \u2192 list \u03b1\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 \u27e8i, qr\u27e9 :: generate_core (i+1) j rr\n\nprotected\ndef generate : list \u03b1 := generate_core 0 n (nat.zero_add n)\n\ntheorem length_generate_core (i j : \u2115)\n: \u03a0 (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\u2082\nparameter {\u03b1 : Type _}\nparameter {\u03b2 : Type _}\nparameter {C : Type _}\nparameter (f : C \u2192 \u03b1 \u2192 \u03b2 \u2192 C)\n\ndef foldl\u2082\n  : C \u2192 list \u03b1 \u2192 list \u03b2 \u2192 C\n| c [] _ := c\n| c _ [] := c\n| c (x::xr) (y::yr) := foldl\u2082 (f c x y) xr yr\n\nend foldl\u2082\n\nsection init\nparameter {\u03b1 : Type _}\n\nprotected\ntheorem length_init (l : list \u03b1) : 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 {\u03b1 : Type u} (n : \u2115) (f : fin n \u2192 \u03b1) : vector \u03b1 n :=\n  \u27e8 list.generate n f, list.length_generate n f\u27e9\n\nsection foldl\u2082\nparameter {\u03b1 : Type _}\nparameter {\u03b2 : Type _}\nparameter {C : Type _}\nparameter (f : C \u2192 \u03b1 \u2192 \u03b2 \u2192 C)\nparameter {n:\u2115}\n\ndef foldl\u2082 (c:C) (x : vector \u03b1 n) (y: vector \u03b2 n) : C :=\n  list.foldl\u2082 f c x.to_list y.to_list\n\nend foldl\u2082\n\ndef dotprod {\u03b1: Type u} [semiring \u03b1] {n:\u2115} : vector \u03b1 n \u2192 vector \u03b1 n \u2192 \u03b1 :=\n  foldl\u2082 (\u03bbc a b, c + a * b) 0\n\nnotation `\u2b1d` := dotprod\n\ndef last {\u03b1:Type u} {n:\u2115} (v : vector \u03b1 (n+1)) : \u03b1 :=\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 {\u03b1:Type u} {n:\u2115} (v : vector \u03b1 (n+1)) : vector \u03b1 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  \u27e8 v.to_list.init, pr\u27e9\n\ndef scale_mul {\u03b1:Type u} [has_mul \u03b1] {n:\u2115} (c:\u03b1) (v : vector \u03b1 n)\n: vector \u03b1 n :=\n  v.map (has_mul.mul c)\n\nend vector\n\n\n\nnamespace list\n\nprotected\ndef maximum {\u03b1:Type _} [decidable_linear_order \u03b1] : list \u03b1 \u2192 option \u03b1\n| [] := option.none\n| (h::r) := option.some (r.foldl max h)\n\nprotected\ndef minimum {\u03b1:Type _} [decidable_linear_order \u03b1] : list \u03b1 \u2192 option \u03b1\n| [] := option.none\n| (h::r) := option.some (r.foldl min h)\n\nend list\n\nnamespace rat\n\ndef to_string (q:\u211a) : 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 \u211a := \u27e8 to_string \u27e9\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 \u211a \u2192 option \u211a \u2192 Prop\n| none _ := true\n| (some l) (some u) := l \u2264 u\n| (some _) none := true\n\ntheorem bound_le_maximum_minimum (ll ul : list \u211a)\n(pr : \u2200 (l u : \u211a), l \u2208 ll \u2192 u \u2208 ul \u2192 l \u2264 u)\n: bound_le (list.maximum ll) (list.minimum ul) := sorry\n\ndef le_bound (ol: option \u211a) (u : \u211a) : Prop :=\n  match ol with\n  | option.none := true\n  | (option.some l) := l \u2264 u\n  end\n\ninstance le_bound.decidable (ol : option \u211a) (u:\u211a) : decidable (le_bound ol u) :=\n  begin cases ol; unfold le_bound; apply_instance end\n\ndef ge_bound (l:\u211a) (ou: option \u211a) : Prop :=\n  match ou with\n  | option.none := true\n  | (option.some u) := l \u2264 u\n  end\n\ninstance ge_bound.decidable (l:\u211a) (ou : option \u211a) : decidable (ge_bound l ou) :=\n  begin cases ou; unfold ge_bound; apply_instance end\n\n\ndef choose_bound : option \u211a \u2192 option \u211a \u2192 \u211a\n| (some l) _ := l\n| none none := 0\n| none (some u) := u\n\ntheorem le_bound_choose_bound (l u : option \u211a) : 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 \u211a} (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 (\u03b1:Type _) (n:\u2115) := vector \u03b1 n\n\nnamespace assignment\n\nsection\nparameter {\u03b1:Type _}\n\n/-- The empty assignment. -/\ndef empty : assignment \u03b1 0 := vector.nil\n\ndef zero_assignment_is_empty (a:assignment \u03b1 0) : a = empty :=\nbegin\n  simp [empty],\n  apply vector.eq_nil,\nend\n\ndef concat {n:\u2115} (xs : assignment \u03b1 n) (x : \u03b1) : assignment \u03b1 (n+1) :=\n  vector.cons x xs\n\ndef shrink {n:\u2115} (a:assignment \u03b1 n) (i : fin n) : assignment \u03b1 i.val :=\nbegin\nhave H1 : i.val \u2264 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:\u2115} (a:assignment \u03b1 n) (i : fin n) : \u03b1 :=\n--   sorry\n\n-- def init {n:\u2115} (a:assignment \u03b1 (n+1)) : assignment \u03b1 n :=\n--   sorry\n\n-- def last {n:\u2115} (a:assignment \u03b1 (n+1)) : \u03b1 :=\n--   sorry\n\n@[simp]\ntheorem init_concat {n:\u2115} (a:assignment \u03b1 n) (z:\u03b1) : vector.init (concat a z) = a := sorry\n\n@[simp]\ntheorem last_concat {n:\u2115} (a:assignment \u03b1 n) (z:\u03b1) : vector.last (concat a z) = z := sorry\n\nend\nend assignment\n\n-- denotes the inequality coef <= bound\ninductive linear_expr : \u2115 \u2192 Type\n| const : \u03a0 {n:\u2115}, \u211a \u2192 linear_expr n\n| add : \u03a0 {n:\u2115} (c:\u211a) (pr : c \u2260 0) (i : fin n), linear_expr i.val \u2192 linear_expr n\n\nlemma nat_ordering_char (x y : \u2115)\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 : \u2115}\n  (x y : fin n) : x < y \u2194 x.val < y.val\n:= begin\ninduction x; induction y; reflexivity\nend\n\ndef extend_le {m n : \u2115} (H : m \u2264 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 : \u2115} (x y : fin n) (H : x < y)\n  : fin y.val\n:= \u27e8 x.val, begin\nrw lt_char at H, assumption\nend \u27e9\n\ndef ordering_elim {n : \u2115}\n  (C : Sort _)\n  (x y : fin n)\n  (Hlt : x < y \u2192 C)\n  (Heq : x = y \u2192 C)\n  (Hgt : x > y \u2192 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 : \u211a) (xne0 : x \u2260 0) : \u2200 {n}, linear_expr n \u2192 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 : \u211a) : \u2200 {n}, linear_expr n \u2192 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 :\u2115} : linear_expr i \u2192 i \u2264 n \u2192 linear_expr n\n| (const c) is_le := const c\n| (add c pr j e) is_le := add c pr \u27e8j.val, lt_of_lt_of_le j.is_lt is_le\u27e9 e\n\ndef add_variable (x : \u211a) : \u2200 {n}, fin n \u2192 linear_expr n \u2192 linear_expr n\n| _ i (const c) := if xne0 : x \u2260 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 \u2260 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 \u2260 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 : \u2200 {n}, linear_expr n \u2192 linear_expr n \u2192 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 \u2192 \u211a\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 \u2192 string \u2192 string\n| s \"\" := s\n| s t := s ++ \" + \" ++ t\n\n\ndef to_string_core  : \u03a0 {n:\u2115}, linear_expr n \u2192 string \u2192 string\n| _ (const c) s :=\n   if s = \"\" then\n     to_string c\n  else if c = 0 \u2227 s \u2260 \"\" 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 ++\"\u00d7v\" ++ to_string i) s)\n\ndef to_string  {n:\u2115} (e:linear_expr n) : string := to_string_core e \"\"\n\ndef var {n:\u2115} (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:\u2115} : linear_expr (n+1) \u2192 \u211a\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:\u2115} : linear_expr (n+1) \u2192 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 \u27e8i.val, i_lt_n\u27e9 e\n  else\n    e.extend (nat.pred_le_pred i.is_lt)\n\nsection evaluate\nparameter {n:\u2115}\n\ndef evaluate_core : \u211a \u2192 \u03a0{n:\u2115}, linear_expr n \u2192 assignment \u211a n \u2192 \u211a\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 : \u03a0{n:\u2115}, linear_expr n \u2192 assignment \u211a n \u2192 \u211a := @evaluate_core 0\n\nend evaluate\n\nend linear_expr\n\n-----------------------------------------------------------------------\n-- linear_expr_list\n\ndef linear_expr_list (n:\u2115) := list (linear_expr n)\n\nnamespace linear_expr_list\n\ndef to_list {n:\u2115} : linear_expr_list n \u2192 list (linear_expr n) := id\n\ninstance (n:\u2115) : has_mem (linear_expr n) (linear_expr_list n) :=\n  begin unfold linear_expr_list, apply_instance end\n\nsection\nparameter {n:\u2115}\n\ndef evaluate (l : linear_expr_list n) (a : assignment \u211a n) : list \u211a :=\n  l.map (\u03bbe, e.evaluate a)\n\ntheorem evaluate_cons (e : linear_expr n) (l : linear_expr_list n)\n  (a : assignment \u211a 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 \u211a n} {q : \u211a}\n(pr : q \u2208 l.evaluate a)\n: \u2203(e:linear_expr n), e \u2208 l \u2227 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:\u2115) :=\n(lhs : linear_expr n)\n\nnamespace inequality\n\nsection entails\n\nparameter {n:\u2115}\n\ndef from_pair : linear_expr n \u2192 linear_expr n \u2192 inequality n := sorry\n\ndef satisfies (\u03b8:assignment \u211a n) (c:inequality n) : Prop := c.lhs.evaluate \u03b8 \u2264 0\n\ntheorem satisfies_from_pair (a:assignment \u211a n) (l u:linear_expr n)\n: satisfies a (from_pair l u) \u2194 l.evaluate a \u2264 u.evaluate a := sorry\n\ninstance (c:inequality n) (\u03b8:assignment \u211a n)\n: decidable (satisfies \u03b8 c) :=\n  begin unfold satisfies, apply_instance end\n\nend entails\n\nnotation `\u22a7` := satisfies\n\nend inequality\n\n/-- A collection on inequalities -/\ndef ineqs (n:\u2115) := list (inequality n)\n\nnamespace ineqs\n\ninstance (n:\u2115) : has_append (ineqs n) := begin unfold ineqs, apply_instance end\ninstance (n:\u2115) : has_mem (inequality n) (ineqs n) := begin unfold ineqs, apply_instance end\n\nsection satisfies\n\nparameter {n:\u2115}\nparameter (a:assignment \u211a n)\n\n-- Returns true if assignment satisfies bound.\ndef satisfies (eqs:ineqs n) : Prop :=\n   eqs.all (\u03bbb, 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) \u2194 inequality.satisfies a h \u2227 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 \u2227 satisfies y) := sorry\n\nend satisfies\n\ntheorem satisfies_list_implies_mem_satisfies {n:\u2115}\n{e : inequality n}\n{l : ineqs n}\n{a:assignment \u211a n}\n(pr : satisfies a l)\n(in_list : e \u2208 l)\n: inequality.satisfies a e := sorry\n\n\n/-- Denotes a solution to the equations. -/\ndef solution {n:\u2115} (eqs:ineqs n) := { a : assignment \u211a n // eqs.satisfies a }\n\n/-- A proof that the equations are unsatisfiable. -/\ndef unsat_proof {n:\u2115} (eqs:ineqs n) :=\n  \u2200(a:assignment \u211a n), \u00ac (satisfies a eqs)\n\nend ineqs\n\n-----------------------------------------------------------------------\n-- bound\n\ninductive bound (n:\u2115) : Type\n-- lower e denotes e <= x\n| lower : linear_expr n \u2192 bound\n-- upper e denotes x <= e\n| upper : linear_expr n \u2192 bound\n-- If variable had a zero in the expression.\n| independent  : inequality n \u2192 bound\n\nnamespace bound\n\n/-- Given an inequality infers the resulting bound on the last variable. -/\ndef from_ineq {n:\u2115} (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 \u27e8 r \u27e9\n\nsection\n\nparameter {n:\u2115}\n\n-- Returns true if assignment satisfies bound.\ndef satisfies (a:assignment \u211a (n+1)) : bound n \u2192 Prop\n| (lower e) := e.evaluate a.init \u2264 a.last\n| (upper e) := a.last \u2264 e.evaluate a.init\n| (independent le) := le.satisfies a.init\n\n@[simp]\ntheorem satisfies_from_ineq (a: assignment \u211a (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:\u2115) :=\n(lower : linear_expr_list n)\n(upper : linear_expr_list n)\n(independent : ineqs n)\n\nnamespace bound_list\n\ndef empty (n:\u2115) : bound_list n :=\n  { lower := [], upper := [], independent := []}\n\ndef lower_bound {n:\u2115} (b:bound_list n) (a:assignment \u211a n) : option \u211a :=\n  (b.lower.evaluate a).maximum\n\ndef upper_bound {n:\u2115} (b:bound_list n) (a:assignment \u211a n) : option \u211a :=\n  (b.upper.evaluate a).minimum\n\nsection satisfies\nparameter {n:\u2115}\nparameter (a:assignment \u211a (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   \u2227 ge_bound a.last (b.upper_bound a.init)\n   \u2227 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:\u2115) (a:assignment \u211a (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:\u2115}\n\ndef add_bound : bound n \u2192 bound_list n \u2192 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 \u211a (n+1)) (b:bound n) (l: bound_list n)\n: satisfies a (bound_list.add_bound b l) \u2194\n  (bound.satisfies a b \u2227 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 (\u03bbe, 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:\u2115}\n\ndef to_ineqs (b:bound_list n) : ineqs n :=\n  b.independent ++ (do l \u2190 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 \u2208 b.lower)\n(in_upper : u \u2208 b.upper)\n: (inequality.from_pair l u \u2208 to_ineqs b) := sorry\n\nend\n\ndef solution {n:\u2115} (eqs:bound_list n) := { a : assignment \u211a (n+1) // eqs.satisfies a }\n\n\ntheorem to_ineqs_preserve_sat {n:\u2115} {b: bound_list n} (a:assignment \u211a (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:\u2115} {b: bound_list n} (a:assignment \u211a 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:\u2115} {b: bound_list n} (a:assignment \u211a n) {z : \u211a}\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:\u2115} {l: ineqs (n+1)} (a:assignment \u211a (n+1))\n: bound_list.satisfies a (bound_list.from_ineqs l) \u2194 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:\u2115} {b : bound_list n}\n  : b.to_ineqs.solution \u2192 b.solution\n| \u27e8 a, pr \u27e9 :=\n  let z : \u211a := 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  \u27e8 (a.concat z : assignment \u211a (n+1)), qr \u27e9\n\ndef bound_list.solution.to_ineqs {n:\u2115} {l : ineqs (n+1)}\n  : (bound_list.from_ineqs l).solution \u2192 l.solution\n  | \u27e8 a, pr \u27e9 :=\n    let qr : l.satisfies a := iff.mp (from_ineqs_preserve_sat _) pr in\n    \u27e8 a, qr \u27e9\n\ninductive sat_result {n:\u2115} (eqs:ineqs n)\n| unsat : eqs.unsat_proof \u2192 sat_result\n| sat : eqs.solution \u2192 sat_result\n\ndef solve_inequalities : \u03a0 {n:\u2115} (eqs:ineqs n), sat_result eqs\n| 0 l :=\n  if pr : l.satisfies assignment.empty then\n    sat_result.sat \u27e8 assignment.empty, pr \u27e9\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 \u2192 string \u2295 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 \u2192 Type\n| foreign : \u03a0(tp:type), expr \u2192 lexpr tp\n| add : \u03a0{tp:type}, lexpr tp \u2192 lexpr tp \u2192 lexpr tp\n| zero : \u03a0(tp:type), lexpr tp\n| one : \u03a0(tp:type), lexpr tp\n| bit0 : \u03a0{tp:type}, lexpr tp \u2192 lexpr tp\n| bit1 : \u03a0{tp:type}, lexpr tp \u2192 lexpr tp\n\nprotected\nmeta def lexpr.resolve : \u03a0(tp:type), expr \u2192 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 : \u2200 {tp:type}, lexpr tp \u2192 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) := \u27e8@lexpr.to_string tp\u27e9\n\nend to_string\n\n\nend lexpr\n\nmeta inductive prop : Type\n| eq : \u03a0(tp:type), lexpr tp \u2192 lexpr tp \u2192 prop\n| ge : \u03a0(tp:type), lexpr tp \u2192 lexpr tp \u2192 prop\n| gt : \u03a0(tp:type), lexpr tp \u2192 lexpr tp \u2192 prop\n| le : \u03a0(tp:type), lexpr tp \u2192 lexpr tp \u2192 prop\n| lt : \u03a0(tp:type), lexpr tp \u2192 lexpr tp \u2192 prop\n\nset_option pp.all true\n\nmeta def prop.mk_bin (f : \u03a0(tp:type), lexpr tp \u2192 lexpr tp \u2192 prop)\n   (resolve_tp : string \u2295 type) (l r : expr) : string \u2295 prop := do\n   tp \u2190 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 \u2192 string \u2295 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 \u2192 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 := \u27e8 prop.to_string \u27e9\n\nend prop\n\n\nmeta def linear_solve : tactic unit := do\n  intros,\n  ctx \u2190 local_context,\n  ctx_types \u2190 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  _ \u2190 ctx_types.mmap pp,\n  t \u2190 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 : \u2115) : x = 0 \u2192 x = 1 \u2192 y = 2 \u2192 y = 3 \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 : Type*} [topological_space \u03b1]\n\nnamespace topological_space\nvariable (\u03b1)\n/-- The type of open subsets of a topological space. -/\ndef opens := {s : set \u03b1 // _root_.is_open s}\n\n/-- The type of closed subsets of a topological space. -/\ndef closeds := {s : set \u03b1 // 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 \u03b1 // s \u2260 \u2205 \u2227 compact s}\n\n\nsection nonempty_compacts\nopen topological_space set\nvariable {\u03b1}\n\ninstance nonempty_compacts.to_compact_space {p : nonempty_compacts \u03b1} : compact_space p.val :=\n\u27e8compact_iff_compact_univ.1 p.property.2\u27e9\n\ninstance nonempty_compacts.to_nonempty {p : nonempty_compacts \u03b1} : 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 \u03b1] (s : nonempty_compacts \u03b1) : closeds \u03b1 :=\n\u27e8s.val, closed_of_compact _ s.property.2\u27e9\n\nend nonempty_compacts\n\nvariable {\u03b1}\nnamespace opens\ninstance : has_coe (opens \u03b1) (set \u03b1) := { coe := subtype.val }\n\ninstance : has_subset (opens \u03b1) :=\n{ subset := \u03bb U V, U.val \u2286 V.val }\n\ninstance : has_mem \u03b1 (opens \u03b1) :=\n{ mem := \u03bb a U, a \u2208 U.val }\n\n\n@[extensionality] lemma ext {U V : opens \u03b1} (h : U.val = V.val) : U = V := subtype.ext.mpr h\n\ninstance : partial_order (opens \u03b1) := subtype.partial_order _\n\ndef interior (s : set \u03b1) : opens \u03b1 := \u27e8interior s, is_open_interior\u27e9\n\ndef gc : galois_connection (subtype.val : opens \u03b1 \u2192 set \u03b1) interior :=\n\u03bb U s, \u27e8\u03bb h, interior_maximal h U.property, \u03bb h, le_trans h interior_subset\u27e9\n\ndef gi : @galois_insertion (order_dual (set \u03b1)) (order_dual (opens \u03b1)) _ _ interior (subtype.val) :=\n{ choice := \u03bb s hs, \u27e8s, interior_eq_iff_open.mp $ le_antisymm interior_subset hs\u27e9,\n  gc := gc.dual,\n  le_l_u := \u03bb _, interior_subset,\n  choice_eq := \u03bb s hs, le_antisymm interior_subset hs }\n\n@[simp] lemma gi_choice_val {s : order_dual (set \u03b1)} {hs} : (gi.choice s hs).val = s := rfl\n\ninstance : complete_lattice (opens \u03b1) :=\ncomplete_lattice.copy\n(@order_dual.lattice.complete_lattice _\n  (@galois_insertion.lift_complete_lattice\n    (order_dual (set \u03b1)) (order_dual (opens \u03b1)) _ interior (subtype.val : opens \u03b1 \u2192 set \u03b1) _ gi))\n/- le  -/ (\u03bb U V, U.1 \u2286 V.1) rfl\n/- top -/ \u27e8set.univ, _root_.is_open_univ\u27e9 (subtype.ext.mpr interior_univ.symm)\n/- bot -/ \u27e8\u2205, is_open_empty\u27e9 rfl\n/- sup -/ (\u03bb U V, \u27e8U.1 \u222a V.1, _root_.is_open_union U.2 V.2\u27e9) rfl\n/- inf -/ (\u03bb U V, \u27e8U.1 \u2229 V.1, _root_.is_open_inter U.2 V.2\u27e9)\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 -/ (\u03bb Us, \u27e8\u22c3\u2080 (subtype.val '' Us), _root_.is_open_sUnion $ \u03bb U hU,\nby { rcases hU with \u27e8\u27e8V, hV\u27e9, h, h'\u27e9, dsimp at h', subst h', exact hV}\u27e9)\nbegin\n  funext,\n  apply subtype.ext.mpr,\n  simp [Sup_range],\n  refl,\nend\n/- Inf -/ _ rfl\n\ninstance : has_inter (opens \u03b1) := \u27e8\u03bb U V, U \u2293 V\u27e9\ninstance : has_union (opens \u03b1) := \u27e8\u03bb U V, U \u2294 V\u27e9\ninstance : has_emptyc (opens \u03b1) := \u27e8\u22a5\u27e9\n\n@[simp] lemma inter_eq (U V : opens \u03b1) : U \u2229 V = U \u2293 V := rfl\n@[simp] lemma union_eq (U V : opens \u03b1) : U \u222a V = U \u2294 V := rfl\n@[simp] lemma empty_eq : (\u2205 : opens \u03b1) = \u22a5 := rfl\n\n@[simp] lemma Sup_s {Us : set (opens \u03b1)} : (Sup Us).val = \u22c3\u2080 (subtype.val '' Us) :=\nbegin\n  rw [@galois_connection.l_Sup (opens \u03b1) (set \u03b1) _ _ (subtype.val : opens \u03b1 \u2192 set \u03b1) interior gc Us, set.sUnion_image],\n  congr\nend\n\ndef is_basis (B : set (opens \u03b1)) : Prop := is_topological_basis (subtype.val '' B)\n\nlemma is_basis_iff_nbhd {B : set (opens \u03b1)} :\n  is_basis B \u2194 \u2200 {U : opens \u03b1} {x}, x \u2208 U \u2192 \u2203 U' \u2208 B, x \u2208 U' \u2227 U' \u2286 U :=\nbegin\n  split; intro h,\n  { rintros \u27e8sU, hU\u27e9 x hx,\n    rcases (mem_nhds_of_is_topological_basis h).mp (mem_nhds_sets hU hx) with \u27e8sV, \u27e8\u27e8V, H\u2081, H\u2082\u27e9, hsV\u27e9\u27e9,\n    refine \u27e8V, H\u2081, _\u27e9,\n    cases V, dsimp at H\u2082, subst H\u2082, exact hsV },\n  { refine is_topological_basis_of_open_of_nhds _ _,\n    { rintros sU \u27e8U, \u27e8H\u2081, H\u2082\u27e9\u27e9, subst H\u2082, exact U.property },\n    { intros x sU hx hsU,\n      rcases @h (\u27e8sU, hsU\u27e9 : opens \u03b1) x hx with \u27e8V, hV, H\u27e9,\n      exact \u27e8V, \u27e8V, hV, rfl\u27e9, H\u27e9 } }\nend\n\nlemma is_basis_iff_cover {B : set (opens \u03b1)} :\n  is_basis B \u2194 \u2200 U : opens \u03b1, \u2203 Us \u2286 B, U = Sup Us :=\nbegin\n  split,\n  { intros hB U,\n    rcases sUnion_basis_of_is_open hB U.property with \u27e8sUs, H, hU\u27e9,\n    existsi {U : opens \u03b1 | U \u2208 B \u2227 U.val \u2208 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 \u27e8V, hV\u27e9,\n        rw \u2190 hV.right at hs,\n        refine \u27e8V, \u27e8\u27e8hV.left, hs\u27e9, hV.right\u27e9\u27e9 },\n      { rcases hs with \u27e8V, \u27e8\u27e8H\u2081, H\u2082\u27e9, H\u2083\u27e9\u27e9,\n        subst H\u2083, exact H\u2082 } } },\n  { intro h,\n    rw is_basis_iff_nbhd,\n    intros U x hx,\n    rcases h U with \u27e8Us, hUs, H\u27e9,\n    replace H := congr_arg subtype.val H,\n    rw Sup_s at H,\n    change x \u2208 U.val at hx,\n    rw H at hx,\n    rcases set.mem_sUnion.mp hx with \u27e8sV, \u27e8\u27e8V, H\u2081, H\u2082\u27e9, hsV\u27e9\u27e9,\n    refine \u27e8V,hUs H\u2081,_\u27e9,\n    cases V with V hV,\n    dsimp at H\u2082, subst H\u2082,\n    refine \u27e8hsV,_\u27e9,\n    change V \u2286 U.val, rw H,\n    exact set.subset_sUnion_of_mem \u27e8\u27e8V, _\u27e9, \u27e8H\u2081, rfl\u27e9\u27e9 }\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 \u00d7 \u2115) (fin 2 \u00d7 \u2115)) := \nbegin\n  rw is_empty_iff,\n  intro f,\n  induction f with fbij h\u2082 h\u2081,\n  simp at *,\n  have h\u2083 := h\u2081 (first_order.language.up\u2081),\n  specialize h\u2081 (first_order.language.up\u2082),\n\n  specialize h\u2083 ![(2, 1)],\n  specialize h\u2081 ![(2, 1)],\n  rw matrix.vec_single_eq_const at *,\n  simp at *,\n  rw \u2190 function.const_def at *,\n  rw \u2190 matrix.vec_single_eq_const at *,\n  rw \u2190 matrix.vec_single_eq_const at *,\n  generalize eq\u2081 : (fbij (2, 1)) = x,\n  rw eq\u2081 at *,\n  induction x,\n  induction x_fst,\n  cases x_fst_val,\n  rw first_order.language.Structure.rel_map_apply\u2081 at *,\n  rw first_order.language.Structure.rel_map_apply\u2081 at *,\n  rw first_order.language.up\u2081 at *,\n  rw first_order.language.up\u2082 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\u2081 at *,\n  rw first_order.language.Structure.rel_map_apply\u2081 at *,\n  rw first_order.language.up\u2081 at *,\n  rw first_order.language.up\u2082 at *,\n  simp at *,\n  injections_and_clear,\n  norm_num at *,\n  simp at *,\n  clear h\u2083 h\u2081 h\u2082,\n  rw nat.succ_lt_succ_iff at *,\n  rw nat.succ_lt_succ_iff at *,\n  linarith,\nend\n\nexample : \u00ac (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\u2135\u2080,\n  use ModelB,\n  split,\n  exact modelB\u2135\u2080,\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 : \u2115) (s : State) (N : \u2115) :=\n\u2200 (a : A pw) (d : D) (n : \u2115), ((init_game a d s).play n).s.board.A \u2208 bounded N\n\ndef A_trapped (pw : \u2115) (s : State) :=\n\u2203 (N : \u2115), A_trapped_in pw s N\n\ndef can_entrap_in {pw : \u2115} (a : A pw) (d : D) (N : \u2115) :=\n\u2203 (n : \u2115), A_trapped_in pw (simulate a d n).s N\n\ndef D_nice_cond (pw : \u2115) (s : State) (n : \u2115) : Prop :=\nA_trapped_in pw s n \u2227 \u2203 (md : Valid_D_move s.board) (p : Point),\nmd.m = some p \u2227 p \u2208 bounded n\n\ndef D.nice (d : D) (pw : \u2115) :=\n\u2200 (s : State) (hs : s.act) (N : \u2115),\nif D_nice_cond pw s N\nthen \u2203 (p : Point),\n  (d.f s hs).m = some p \u2227\n  p \u2208 bounded N\nelse \u2200 (p : Point) (b : Board),\n  (d.f s hs).m = some p \u2192\n  b \u2208 s.history \u2192\n  pw < dist p b.A\n\n-----\n\nlemma A_trapped_in_ge {pw n k : \u2115} {s : State}\n  (h\u2081 : A_trapped_in pw s k)\n  (h\u2082 : k \u2264 n) :\n  A_trapped_in pw s n :=\n\u03bb a d m, mem_bounded_ge (h\u2081 a d m) h\u2082\n\nlemma can_entrap_in_ge {pw n k : \u2115} {a : A pw} {d : D}\n  (h\u2081 : can_entrap_in a d k)\n  (h\u2082 : k \u2264 n) :\n  can_entrap_in a d n :=\n\u27e8_, A_trapped_in_ge h\u2081.some_spec h\u2082\u27e9\n\nlemma D_nice_cond_ge {pw n k : \u2115} {s : State}\n  (h\u2081 : D_nice_cond pw s k)\n  (h\u2082 : k \u2264 n) :\n  D_nice_cond pw s n :=\nbegin\n  obtain \u27e8md, p, h\u2083, h\u2084\u27e9 := h\u2081.2,\n  exact \u27e8A_trapped_in_ge h\u2081.1 h\u2082, _, _, h\u2083, mem_bounded_ge h\u2084 h\u2082\u27e9,\nend\n\nlemma mem_bounded_of_A_trapped_in {pw N : \u2115} {s : State}\n  (h : A_trapped_in pw s N) :\n  s.board.A \u2208 bounded N :=\nh default default 0\n\nlemma mem_bounded_apply_D_move_of_A_trapped_in {pw N : \u2115}\n  {s : State} {md : D_move}\n  (h : A_trapped_in pw s N) :\n  (apply_D_move s md).board.A \u2208 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 : \u2115}\n  {s s' : State} {ma : Valid_A_move pw s'.board} {md : Valid_D_move s.board}\n  (h\u2081 : A_trapped_in pw s N)\n  (h\u2082 : s' = apply_D_move s md.m) :\n  (apply_A_move s' ma.m).board.A \u2208 bounded N :=\nbegin\n  specialize h\u2081 ((default : A pw).set_move s' ma) ((default : D).set_move s md) 1,\n  rw play_1 at h\u2081,\n  rw Game.play_move at h\u2081,\n  split_ifs at h\u2081 with h\u2083,\n  {\n    rw play_A_move_at at h\u2081,\n    rw dif_pos at h\u2081, swap,\n    {\n      clear h\u2081,\n      use h\u2083,\n      subst s',\n      use ma.m,\n      revert h\u2083,\n      simp,\n      intro h\u2083,\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 : \u2115} {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\u2083 := 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\u2083 },\n    { rw [finset.mem_filter, set.mem_to_finset] at hp, exact hp.1 }},\nend\n\nlemma A_trapped_in_play_move {pw N : \u2115} {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 : \u2115}\n  {a : A pw} {d : D} {s\u2080 : State}\n  (h\u2080 : valid_state pw s\u2080)\n  (h\u2081 : d.nice pw)\n  (h\u2082 : A_trapped_in pw s\u2080 N) :\n  \u00ac((init_game a d s\u2080).play (bounded_area N)).act :=\nbegin\n  apply not_act_of_descend_play_move_valid\n    (\u03bb (s : State), squares_in_bounded_exc_A s.board N)\n    (\u03bb (s : State), A_trapped_in pw s N); try { dsimp },\n  sorry {\n    exact h\u2080,\n  },\n  sorry {\n    exact squares_in_bounded_exc_A_lt_bounded_area_of_A_trapped_in h\u2082,\n  },\n  sorry {\n    exact h\u2082,\n  },\n  sorry {\n    rintro s hv hs\u2081 h\u2083,\n    exact A_trapped_in_play_move h\u2083,\n  },\n  {\n    rintro s hv hs\u2081 h\u2083,\n    obtain \u27e8s', hs, hs', hvm, h\u2084, h\u2085\u27e9 := play_move_state_eq_of_act_play_move hs\u2081,\n    rw h\u2085, clear h\u2085,\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\u2081 : ma.m \u2208 bounded N,\n      {\n        sorry\n      },\n      have hma\u2082 : ma.m \u2208 s'.board.squares,\n      sorry,\n      have hma\u2083 : ma.m \u2260 s'.board.A,\n      sorry,\n      have h\u2085 : ma.m \u2208 t,\n      sorry {\n        rw [finset.mem_filter, set.mem_to_finset],\n        exact \u27e8hma\u2081, hma\u2082, hma\u2083\u27e9,\n      },\n      have h\u2086 : s'.board.A \u2209 t,\n      sorry {\n        rw finset.mem_filter,\n        simp,\n      },\n      convert finset_card_insert_erase_eq h\u2085 h\u2086,\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\u2087 : 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\u2087],\n        split; intro h\u2088,\n        sorry {\n          tauto,\n        },\n        {\n          change _ \u2260 _ at h\u2087,\n          cases h\u2088,\n          {\n            clear h\u2087,\n            subst h\u2088,\n            fsplit,\n            sorry {\n              subst s',\n              exact mem_bounded_apply_D_move_of_A_trapped_in h\u2083,\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 : \u2115} {a : A pw} {d : D}\n  (h\u2081 : d.nice pw)\n  (h\u2082 : can_entrap_in a d N) :\n  (init_game a d state\u2080).D_wins :=\nbegin\n  cases h\u2082 with n h\u2082, suffices h\u2083 : \u2203 (k : \u2115), \u00ac(simulate a d (n + k)).act,\n  { exact \u27e8_, h\u2083.some_spec\u27e9 },\n  simp_rw simulate_add,let g : Game pw := _,\n  change simulate a d n with g at h\u2082 \u22a2, 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\u2081 h\u2082,\nend\n\nlemma lem_2_3 {pw : \u2115}\n  (h : \u2203 (N : \u2115) (d : D), d.nice pw \u2227 \u2200 (a : A pw), can_entrap_in a d N) :\n  \u2203 (d : D), d.nice pw \u2227 \u2200 (a : A pw), (init_game a d state\u2080).D_wins :=\nbegin\n  rcases h with \u27e8N, d, h\u2081, h\u2082\u27e9, use [d, h\u2081], intro a,\n  specialize h\u2082 a, exact nice_D_wins_of_can_entrap_in h\u2081 h\u2082,\nend\n\nlemma lem_2_3' {pw : \u2115}\n  (h : \u2203 (a : A pw), \u2200 (d : D) (N : \u2115), d.nice pw \u2192\n  \u00acA_trapped_in_for a d (bounded N)) :\n  \u2203 (a : A pw), \u2200 (d : D), d.nice pw \u2192 (init_game a d state\u2080).A_wins :=\nbegin\n  cases h with a h, use a, rintro d h\u2081, specialize h d,\n  replace h : \u2200 (N : \u2115), \u00acA_trapped_in_for a d (bounded N),\n  { intro n, exact h n h\u2081 },\n  intro n, contrapose! h, use n * pw, intro k, by_cases h\u2082 : k \u2264 n,\n  { exact A_bounded_n_pw h\u2082 },\n  { change \u00ac(simulate a d n).act at h, have h\u2083 : \u00ac(simulate a d k).act,\n    { contrapose! h, push_neg at h\u2082, obtain \u27e8k, rfl\u27e9 := nat.exists_eq_add_of_lt h\u2082,\n      rw add_assoc at h, rw [simulate, play_add] at h, apply act_of_act_play h },\n    have h\u2084 : simulate a d k = simulate a d n,\n    { exact play_eq_of_not_act h\u2083 h },\n    rw h\u2084, 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 \u2192 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\u2081 ai\u2082 : M} (e\u2081 : a * ai\u2081 = 1) (e\u2082 : a * ai\u2082 = 1) : ai\u2081 = ai\u2082 :=\nby rw [\u2190 mul_one ai\u2081, \u2190 e\u2082, \u2190 mul_assoc, mul_comm ai\u2081, e\u2081, 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 \u25b8 J.zero,\n  add := H.symm \u25b8 J.add,\n  smul := H.symm \u25b8 J.smul }\n\ndef ker : ideal A :=\nideal.mk {x | f x = 0} (ideal.comap f \u22a5) $\nset.ext $ \u03bb x, (submodule.mem_bot B).symm--(submodule.mem_bot _).symm\n\ndef inverts_data (S : set A) (f : A \u2192 B) : Type* :=\n\u03a0 s : S, {si : B // (f s) * si = 1}\n\ndef inverts (S : set A) (f : A \u2192 B) : Prop := \n\u2200 s : S, \u2203 si : B, (f s) * si = 1\n\nlemma inverts_subsingleton (S : set A) (f : A \u2192 B) :\n  subsingleton (inverts_data S f) :=\n\u27e8\u03bb fi1 fi2, funext $ \u03bb s, subtype.eq $ comm_monoid.inv_unique (fi1 s).2 (fi2 s).2\u27e9\n\ndef inverts_of_data (h : inverts_data S f) : inverts S f :=\n\u03bb s, \u27e8(h s).1,(h s).2\u27e9\n\nnoncomputable def inverts_some (h : inverts S f) : inverts_data S f :=\n\u03bb s, classical.indefinite_description _ (h s)\n\ndef has_denom_data (S : set A) (f : A \u2192 B) :=\n\u03a0 b : B, {sa : S \u00d7 A // (f sa.1) * b = f sa.2 }\n\ndef has_denom (S : set A) (f : A \u2192 B) : Prop :=\n\u2200 b : B, \u2203 (sa : S \u00d7 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\u03bb b, subtype.exists_of_subtype (h b)\n\nnoncomputable def has_denom_some (h : has_denom S f) : has_denom_data S f := \n\u03bb b, classical.indefinite_description _ (h b)\n\ndef ann_aux (S : set A) [is_submonoid S] : Type* :=\n{ as : A \u00d7 S // as.1 * as.2 = 0 }\n\nnamespace ann_aux\n\ndef zero : ann_aux S := \u27e8(0, 1), mul_one _\u27e9\n\ndef add (as bt : ann_aux S) : ann_aux S :=\n\u27e8(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, \u2190 mul_assoc, as.2, zero_mul, zero_add, mul_left_comm, bt.2, mul_zero]\u27e9\n\ndef smul (a : A) (bt : ann_aux S) : ann_aux S :=\n\u27e8(a * bt.1.1, bt.1.2), show (a * bt.1.1) * bt.1.2 = 0, by rw [mul_assoc, bt.2, mul_zero]\u27e9\n\nend ann_aux\n\ndef submonoid_ann (S : set A) [is_submonoid S] : ideal A :=\n{ carrier := set.range (\u03bb as : ann_aux S, as.1.1),\n  zero := \u27e8ann_aux.zero S, rfl\u27e9,\n  add := \u03bb _ _ \u27e8as,has\u27e9 \u27e8bt,hbt\u27e9, \u27e8ann_aux.add S as bt, has \u25b8 hbt \u25b8 rfl\u27e9,\n  smul := \u03bb a _ \u27e8bt,h\u27e9, \u27e8ann_aux.smul S a bt, h \u25b8 rfl\u27e9 }\n\nlemma inverts_ker (hf : inverts S f) : submonoid_ann S \u2264 ker f :=\n\u03bb x \u27e8\u27e8\u27e8a,s\u27e9,asz\u27e9,rfl\u27e9, let \u27e8si,e1\u27e9 := hf s in show f x = 0,\nby rw [\u2190 mul_one (f x), \u2190 e1, \u2190 mul_assoc, \u2190 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 \u2264 submonoid_ann S)\n\ndef is_localization : Prop :=\n(inverts S f) \u2227 (has_denom S f) \u2227 (ker f = submonoid_ann S)\n\nlemma localization_epi (hf : is_localization S f)\n  (g\u2081 g\u2082 : B \u2192 C) [is_ring_hom g\u2081] [is_ring_hom g\u2082] \n  (e : g\u2081 \u2218 f = g\u2082 \u2218 f) : g\u2081 = g\u2082 := \nbegin\n  have e' : \u2200 x, g\u2081 (f x) = g\u2082 (f x) := \u03bb x, by convert congr_fun e x,\n  ext b,\n  rcases hf.2.1 b with \u27e8\u27e8s,a\u27e9,e1\u27e9,\n  rcases hf.1 s with \u27e8si,e2\u27e9,\n  have e4 : g\u2081 (f s) * (g\u2081 si) = 1,\n  { rw [\u2190 is_ring_hom.map_mul g\u2081, e2, is_ring_hom.map_one g\u2081] },\n  have e5 : g\u2081 (f s) * (g\u2082 si) = 1,\n  { rw [e', \u2190 is_ring_hom.map_mul g\u2082, e2, is_ring_hom.map_one g\u2082] },\n  rw [\u2190 mul_one b, \u2190 e2, mul_left_comm, \u2190 mul_assoc, e1],\n  rw [is_ring_hom.map_mul g\u2081, is_ring_hom.map_mul g\u2082, e', comm_monoid.inv_unique e4 e5]\nend\n\nsection localization_initial \nvariables (hf : is_localization_data S f) (g : A \u2192 C) [is_ring_hom g] (hg : inverts_data S g)\n\ndef is_localization_initial (hf : is_localization_data S f)\n  (g : A \u2192 C) [is_ring_hom g] (hg : inverts_data S g) : B \u2192 C :=\n\u03bb 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 \u2192 C) [is_ring_hom g] (hg : inverts_data S g)\n  {a\u2081 a\u2082 : A} (H : f a\u2081 = f a\u2082) : g a\u2081 = g a\u2082 :=\nbegin\n  rw [\u2190 sub_eq_zero, \u2190 is_ring_hom.map_sub f] at H,\n  rw [\u2190 sub_eq_zero, \u2190 is_ring_hom.map_sub g],\n  generalize_hyp : a\u2081 - a\u2082 = a at H \u22a2,\n  rcases hf.3 H with \u27e8\u27e8as,h1\u27e9,h2\u27e9,\n  rw [\u2190 h2],\n  cases hg as.2 with c h3,\n  rw [\u2190 mul_one (g as.1), \u2190 h3, \u2190 mul_assoc, \u2190 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 \u2194 z = w :=\n\u27e8\u03bb H, have _ := congr_arg (* y) H, by rwa [mul_assoc, h, mul_one, mul_assoc, h, mul_one] at this,\n\u03bb H, by rw H\u27e9\n\ninstance (hf : is_localization_data S f) (g : A \u2192 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 \u27e8\u27e8s,a\u27e9,h\u27e9,\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 \u2190 h, exact hc\n  end,\n  map_mul := \u03bb x y, begin\n    unfold is_localization_initial,\n    rcases hf.has_denom x with \u27e8\u27e8sx,ax\u27e9,h1\u27e9,\n    rcases hf.has_denom y with \u27e8\u27e8sy,ay\u27e9,h2\u27e9,\n    rcases hf.has_denom (x*y) with \u27e8\u27e8sxy,axy\u27e9,h3\u27e9,\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 [\u2190 useful2 h4, \u2190 useful2 h5, \u2190 useful2 h6],\n    have : g axy * sigxy * g \u2191sx * g \u2191sy * g \u2191sxy = g axy * g \u2191sx * g \u2191sy * (g \u2191sxy * 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 \u2191sx * g \u2191sy * g \u2191sxy = g ax * g ay * g \u2191sxy * (g \u2191sx * sigx) * (g \u2191sy * 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 \u2190 is_ring_hom.map_mul g }, apply useful S f hf g hg,\n    iterate 4 { rw is_ring_hom.map_mul f }, rw \u2190 h3,\n    have : f \u2191sxy * (f ax * sifx * (f ay * sify)) * f \u2191sx * f \u2191sy = f ax * f ay * f \u2191sxy * (f \u2191sx * sifx) * (f \u2191sy * sify),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h7, h8, mul_one, mul_one]\n  end,\n  map_add := \u03bb x y, begin\n    unfold is_localization_initial,\n    rcases hf.has_denom x with \u27e8\u27e8sx,ax\u27e9,h1\u27e9,\n    rcases hf.has_denom y with \u27e8\u27e8sy,ay\u27e9,h2\u27e9,\n    rcases hf.has_denom (x+y) with \u27e8\u27e8sxy,axy\u27e9,h3\u27e9,\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 [\u2190 useful2 h4, \u2190 useful2 h5, \u2190 useful2 h6],\n    have : g axy * sigxy * g \u2191sx * g \u2191sy * g \u2191sxy = g axy * g \u2191sx * g \u2191sy * (g \u2191sxy * 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 \u2191sx * g \u2191sy * g \u2191sxy =\n      g ax * g \u2191sy * g \u2191sxy * (g \u2191sx * sigx) + g ay * g \u2191sx * g \u2191sxy * (g \u2191sy * 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 \u2190 is_ring_hom.map_mul g }, rw \u2190 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 \u2190 h3,\n    have : f \u2191sxy * (f ax * sifx + f ay * sify) * f \u2191sx * f \u2191sy =\n      f ax * f \u2191sy * f \u2191sxy * (f \u2191sx * sifx) + f ay * f \u2191sx * f \u2191sxy * (f \u2191sy * 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 \u2192 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 \u27e8\u27e8s,x\u27e9,h1\u27e9,\n  cases hg s with si h2,\n  dsimp only [subtype.coe_mk] at *,\n  rw [\u2190 useful2 h2, mul_right_comm, mul_assoc, h2, mul_one, \u2190 is_ring_hom.map_mul g],\n  apply useful S f hf g hg,\n  rw [\u2190 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\u22121][b\u22121]A[a^{-1}][b^{-1}]A[a\u22121][b\u22121] with A[(ab)\u22121]A[(ab)^{-1}]A[(ab)\u22121]?\n2. If e2=ee^2=ee2=e, can we identify A[e\u22121]A[e^{-1}]A[e\u22121] with A/(1\u2212e)A/(1-e)A/(1\u2212e)?\n3. If we define Z(p)\\mathbb{Z}_{(p)}Z(p)\u200b as a subring of Q\\mathbb{Q}Q, can we produce the ring map Z(p)\u2192Z/p\\mathbb{Z}_{(p)}\\to\\mathbb{Z}/pZ(p)\u200b\u2192Z/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 \u2192 B} [is_ring_hom f] {a : A}\n{b : B} (hb : f a * b = 1) : localization_alt.inverts (powers a) f :=\nbegin\n rintro \u27e8z,n,h\u27e9,\n use b ^ n,\n show f z * b ^ n = 1,\n rw [\u2190h, is_semiring_hom.map_pow f, \u2190mul_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 \u27e8_, _, _\u27e9,\n  { rintros \u27e8_, n, rfl\u27e9, 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 \u27e8x\u27e9, 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 \u27e8\u27e8(x, \u27e8e, 1, pow_one e\u27e9), _\u27e9, rfl\u27e9,\n      cases hx with y hx, change x * e = 0, rw [\u2190 hx, mul_assoc, H2, mul_zero] },\n    { rcases hx with \u27e8\u27e8\u27e8x, \u27e8_, n, rfl\u27e9\u27e9, hx\u27e9, rfl\u27e9, 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 \u2203 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, \u2190 mul_assoc] at hx, cases ih _ hx with y hy,\n      use x + y, rw [add_mul, hy, \u2190 mul_add, sub_add_cancel, mul_one] } },\nend\n\ndef Z_loc_p {p : \u2115} (hp : nat.prime p) : Type := {q : \u211a // rat.denom q % p \u2260 0 }\n\nnamespace Z_loc_p\n\nprotected def zero {p : \u2115} (hp : nat.prime p) : Z_loc_p hp := \u27e8(0 : \u211a),begin\n  show 1 % p \u2260 0,\n  rw nat.mod_eq_of_lt, simp,\n  exact hp.1,\nend\u27e9\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\u2260 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 : \u2200 (\u03b1 : \u211d), const \u03b1 [] = \u03b1\nattribute [simp] const_scalar\n\naxiom const_mul {shape : S} : \u03a0 (\u03b1 \u03b2 : \u211d), const (\u03b1 * \u03b2) shape = const \u03b1 shape * const \u03b2 shape\naxiom const_neg {shape : S} : \u03a0 (\u03b1 : \u211d), const (- \u03b1) shape = - const \u03b1 shape\naxiom const_inv {shape : S} : \u03a0 (\u03b1 : \u211d), const \u03b1\u207b\u00b9 shape = (const \u03b1 shape)\u207b\u00b9\n\naxiom const_zero {shape : S} : const 0 shape = 0\naxiom const_one {shape : S} : const 1 shape = 1\naxiom const_bit0 {shape : S} : \u03a0 (\u03b1 : \u211d), const (bit0 \u03b1) shape = bit0 (const \u03b1 shape)\naxiom const_bit1 {shape : S} : \u03a0 (\u03b1 : \u211d), const (bit1 \u03b1) shape = bit1 (const \u03b1 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 (\u03b1 : \u211d) (shape : S) (x : T shape) : \u03b1 \u2b1d x = const \u03b1 shape * x\naxiom smul_neg (\u03b1 : \u211d) : \u2200 {shape : S} (x : T shape), \u03b1 \u2b1d (- x) = - (\u03b1 \u2b1d x)\naxiom smul_addr (\u03b1 : \u211d) : \u2200 (shape : S) (x y : T shape), \u03b1 \u2b1d (x + y) = \u03b1 \u2b1d x + \u03b1 \u2b1d y\naxiom smul_addl (\u03b1 \u03b2 : \u211d) : \u2200 (shape : S) (x : T shape), (\u03b1 + \u03b2) \u2b1d x = \u03b1 \u2b1d x + \u03b2 \u2b1d x\naxiom smul_group (\u03b1 \u03b2 : \u211d) : \u2200 (shape : S) (x : T shape), (\u03b1 * \u03b2) \u2b1d x = \u03b1 \u2b1d (\u03b2 \u2b1d x)\naxiom smul_flip (\u03b1 \u03b2 : \u211d) : \u2200 (shape : S) (x : T shape), \u03b1 \u2b1d (\u03b2 \u2b1d x) = \u03b2 \u2b1d (\u03b1 \u2b1d x)\naxiom one_smul : \u2200 (shape : S) (x : T shape), (1 : \u211d) \u2b1d x = x\n\naxiom smul_zero (\u03b1 : \u211d) : \u2200 (shape : S), \u03b1 \u2b1d (0 : T shape) = 0\naxiom zero_smul : \u2200 (shape : S) (x : T shape), (0 : \u211d) \u2b1d x = 0\naxiom smul_mul_scalar_right (\u03b1 : \u211d) : \u2200 (x y : \u211d), \u03b1 \u2b1d (x * y) = x \u2b1d (\u03b1 \u2b1d y)\naxiom smul_mul\u2081 (\u03b1 : \u211d) : \u2200 {shape : S} (x y : T shape), y * (\u03b1 \u2b1d x) = \u03b1 \u2b1d (x * y)\naxiom smul_mul\u2082 (\u03b1 : \u211d) : \u2200 {shape : S} (x y : T shape), (\u03b1 \u2b1d x) * y = \u03b1 \u2b1d (x * y)\naxiom smul_comm (\u03b1 \u03b2 : \u211d) : \u03b1 \u2b1d \u03b2 = \u03b2 \u2b1d \u03b1\naxiom smul_sum {shape : S} (\u03b1 : \u211d) (x : T shape) : \u03b1 \u2b1d sum x = sum (\u03b1 \u2b1d x)\naxiom smul_div {shape : S} (\u03b1 : \u211d) (x y : T shape) : \u03b1 \u2b1d (x / y) = (\u03b1 \u2b1d x) / y\naxiom smul_scale : \u2200 (\u03b1 : \u211d) (shape : S) (x : T shape), (\u03b1 \u2b1d 1) * x = \u03b1 \u2b1d x\naxiom smul_scalar : \u2200 (\u03b1 x : \u211d), (\u03b1 \u2b1d x) = \u03b1 * x\n\n-- sum\naxiom sum_empty_vec (x : T [0]) : sum x = 0\naxiom sum_mat_no_cols {nrows : \u2115} (x : T [nrows, 0]) : sum x = 0\naxiom sum_zero : \u03a0 {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} (\u03b1 : \u211d) (x : T shape) : sum (\u03b1 \u2b1d x) = \u03b1 * sum x\n\n-- Misc\naxiom sqrt_mul {shape : S} : \u2200 (x y : T shape), sqrt (x * y) = sqrt x * sqrt y\naxiom sqrt_square {shape : S} : \u2200 (x : T shape), sqrt (square x) = x\naxiom prod_mul {shape : S} : \u2200 (x y : T shape), prod (x * y) = prod x * prod y\naxiom mul_inv_pos {shape : S} : \u2200 {x y : T shape}, x > 0 \u2192 y > 0 \u2192 (x * y)\u207b\u00b9 = x\u207b\u00b9 * y\u207b\u00b9\naxiom inv_mul_cancel {shape : S} : \u2200 {x : T shape}, x > 0 \u2192 (x\u207b\u00b9 * x) = 1\naxiom mul_inv_cancel {shape : S} : \u2200 {x : T shape}, x > 0 \u2192 (x * x\u207b\u00b9) = 1\naxiom div_one {shape : S} : \u2200 {x : T shape}, x / 1 = x\naxiom log_one {shape : S} : log (1 : T shape) = (0 : T shape)\naxiom log_const {shape : S} (\u03b1 : \u211d) : log (const \u03b1 shape) = const (log \u03b1) shape\naxiom exp_inv {shape : S} (x : T shape) : (exp x)\u207b\u00b9 = exp (- x)\naxiom neg_div : \u2200 {shape : S} {x y : T shape}, -x / y = -(x / y)\naxiom log_prod : \u2200 {shape : S} {x : T shape}, x > 0 \u2192 log (prod x) = sum (log x)\naxiom log_mul : \u2200 {shape : S} {x y : T shape}, x > 0 \u2192 y > 0 \u2192 log (x * y) = log x + log y\naxiom log_exp : \u2200 {shape : S} {x : T shape}, log (exp x) = x\naxiom log_sqrt : \u2200 {shape : S} {x : T shape}, log (sqrt x) = 2\u207b\u00b9 * log x\naxiom log_inv : \u2200 {shape : S} {x : T shape}, log (x\u207b\u00b9) = - log x\n\n-- Signs\naxiom nz_of_pos {shape : S} : \u2200 {x : T shape}, x > 0 \u2192 x \u2260 0\naxiom nz_of_div {shape : S} : \u2200 {x y : T  shape}, x \u2260 0 \u2192 y \u2260 0 \u2192 x / y \u2260 0\naxiom nz_iff {shape : S} : \u2200 {x : T shape}, x \u2260 0 \u2194 x > 0 \u2228 x < 0\naxiom nneg_of_pos {shape : S} : \u2200 {x : T shape}, x > 0 \u2192 x \u2265 0\naxiom sqrt_pos {shape : S} : \u2200 {x : T shape}, x > 0 \u2192 sqrt x > 0\naxiom pos_of_sqrt_pos {shape : S} : \u2200 {x : T shape}, sqrt x > 0 \u2192 x > 0\naxiom square_nneg {shape : S} : \u2200 {x : T shape}, square x \u2265 0\naxiom square_pos_of_pos {shape : S} : \u2200 {x : T shape}, 0 < x \u2192 0 < square x\naxiom square_pos_of_neg {shape : S} : \u2200 {x : T shape}, x < 0 \u2192 0 < square x\naxiom exp_pos {shape : S} : \u2200 {x : T shape}, exp x > 0\naxiom sigmoid_pos {shape : S} : \u2200 {x : T shape}, sigmoid x > 0\naxiom sigmoid_lt1 {shape : S} : \u2200 {x : T shape}, sigmoid x < 1\naxiom lt1_alt {shape : S} : \u2200 {x : T shape}, x < 1 \u2192 0 < 1 - x\naxiom one_plus_pos {shape : S} : \u2200 {x : T shape}, x > 0 \u2192 1 + x > 0\naxiom one_plus_pos_iff {shape : S} : \u2200 {x : T shape}, 0 < 1 + x \u2194 (- 1 < x)\naxiom plus_one_pos {shape : S} : \u2200 {x : T shape}, x > 0 \u2192 x + 1 > 0\naxiom one_pos {shape : S} : (1 : T shape) > 0\naxiom neg_of_pos {shape : S} {x : T shape} : x > 0 \u2192 - x < 0\naxiom const_pos_of_pos {shape : S} {x : \u211d} : x > 0 \u2192 const x shape > 0\naxiom mul_pos_of_pos_pos {shape : S} {x y : T shape} : x > 0 \u2192 y > 0 \u2192 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 \u2192 x\u207b\u00b9 > 0\naxiom div_pos_pos {shape : S} {x y : T shape} : x > 0 \u2192 y > 0 \u2192 x / y > 0\naxiom add_pos_of_pos_pos {shape : S} {x y : T shape} : x > 0 \u2192 y > 0 \u2192 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} : \u2200 {x y : T shape}, y > 0 \u2192 (x / y) * y = x\naxiom div_div_eq_div_mul {shape : S} : \u2200 (x y z : T shape), (x / y) / z = x / (y * z)\naxiom div_mul_div {shape : S} : \u2200 (x y z w : T shape), (x / y) * (z / w) = (x * z) / (y * w)\naxiom mul_div_mul {shape : S} : \u2200 (x y z : T shape), x * (y / z) = (x / z) * y\naxiom mul_div_mul_alt {shape : S} : \u2200 (x y z : T shape), x * (y / z) = (x * y / z)\naxiom one_div_inv {shape : S} : \u2200 (x : T shape), 1 / x = x\u207b\u00b9\naxiom div_mul_inv {shape : S} : \u2200 (x y : T shape), x / y = x * y\u207b\u00b9\naxiom div_self {shape : S} : \u2200 {x : T shape}, x > 0 \u2192 x / x = 1\naxiom square_div {shape : S} : \u2200 {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\u207b\u00b9 :=\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\u207b\u00b9 : by rw one_div_inv\n\n-- integrable\naxiom is_integrable_const : \u03a0 {shape\u2081 shape\u2082 : S} (c : T shape\u2082), is_integrable (\u03bb (x : T shape\u2081), c)\n\nlemma is_integrable_zero {shape\u2081 shape\u2082 : S} : is_integrable (\u03bb (x : T shape\u2081), (0 : T shape\u2082)) := is_integrable_const (0 : T shape\u2082)\n\naxiom is_integrable_scale : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) (\u03b1 : \u211d),\n  is_integrable f \u2194 is_integrable (\u03bb x, \u03b1 \u2b1d f x)\n\naxiom is_integrable_neg : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082),\n  is_integrable f \u2194 is_integrable (\u03bb x, - f x)\n\naxiom is_integrable_div : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) (y : T shape\u2082) (Hy : y > 0),\n  is_integrable f \u2194 is_integrable (\u03bb x, (f x) / y)\n\naxiom is_integrable_add : \u03a0 {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082),\n  (is_integrable f \u2227 is_integrable g) \u2194 is_integrable (\u03bb x, f x + g x)\n\naxiom is_integrable_tmulT {ishape oshape fshape : S} (M : T (ishape ++ oshape)) (f : T fshape \u2192 T oshape) :\n  is_integrable f \u2194 is_integrable (\u03bb x, tmulT M (f x))\n\naxiom is_integrable_sum : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082),\n  (is_integrable f) \u2194 is_integrable (\u03bb x, sum (f x))\n\naxiom is_integrable_fscale : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 \u211d) (y : T shape\u2082),\n  is_integrable f \u2194 is_integrable (\u03bb x, f x \u2b1d y)\n\n-- (provable)\naxiom is_integrable_const_middle : \u03a0 {shape\u2081 shape\u2082 : S} (pdf : T shape\u2081 \u2192 \u211d) (c : T shape\u2082),\n  is_integrable (\u03bb (x : T shape\u2081), pdf x) \u2194 is_integrable (\u03bb (x : T shape\u2081), pdf x \u2b1d c)\n\naxiom is_integrable_add_middle : \u03a0 {shape\u2081 shape\u2082 : S} (pdf : T shape\u2081 \u2192 \u211d) (f g : T shape\u2081 \u2192 T shape\u2082),\n  (is_integrable (\u03bb (x : T shape\u2081), pdf x \u2b1d f x) \u2227 is_integrable (\u03bb (x : T shape\u2081), pdf x \u2b1d g x)) \u2194 is_integrable (\u03bb (x : T shape\u2081), pdf x \u2b1d (f x + g x))\n\n-- (provable)\naxiom is_integrable_tmulT_middle {ishape oshape fshape : S} (M : T (ishape ++ oshape)) (pdf : T fshape \u2192 \u211d) (f : T fshape \u2192 T oshape) :\n  is_integrable (\u03bb (x : T fshape), pdf x \u2b1d f x) \u2194 is_integrable (\u03bb (x : T fshape), pdf x \u2b1d tmulT M (f x))\n\n-- uniformly integrable\naxiom is_uniformly_integrable_around_binary : \u03a0 {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2081),\n  (is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f \u03b8\u2080 \u03b8 x) \u03b8 \u2227 is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f \u03b8 \u03b8\u2080 x) \u03b8) \u2194 is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f \u03b8\u2080 \u03b8\u2080 x) \u03b8\n\nlemma uint_left {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2081) :\n  is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f \u03b8\u2080 \u03b8\u2080 x) \u03b8 \u2192 is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f \u03b8\u2080 \u03b8 x) \u03b8 :=\nassume H_uint, (iff.mpr (is_uniformly_integrable_around_binary f \u03b8) H_uint)^.left\n\nlemma uint_right {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2081) :\n  is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f \u03b8\u2080 \u03b8\u2080 x) \u03b8 \u2192 is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f \u03b8 \u03b8\u2080 x) \u03b8 :=\nassume H_uint, (iff.mpr (is_uniformly_integrable_around_binary f \u03b8) H_uint)^.right\n\n-- (provable)\naxiom is_uniformly_integrable_around_binary_grad : \u03a0 {shape\u2081 shape\u2082 : S} (f\u2081 f\u2082 : T shape\u2081 \u2192 T shape\u2082 \u2192 \u211d) (\u03b8 : T shape\u2081),\n  (\u2200 x, is_cdifferentiable (\u03bb \u03b8\u2080, f\u2081 \u03b8\u2080 x) \u03b8) \u2192 (\u2200 x, is_cdifferentiable (\u03bb \u03b8\u2080, f\u2082 \u03b8\u2080 x) \u03b8) \u2192\n  (is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f\u2082 \u03b8\u2080 x \u2b1d \u2207 (\u03bb \u03b8\u2081, f\u2081 \u03b8\u2081 x) \u03b8\u2080) \u03b8 \u2227 is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f\u2081 \u03b8\u2080 x \u2b1d \u2207 (\u03bb \u03b8\u2081, f\u2082 \u03b8\u2081 x) \u03b8\u2080) \u03b8 \u2194\n   is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, \u2207 (\u03bb \u03b8\u2081, f\u2081 \u03b8\u2081 x \u2b1d f\u2082 \u03b8\u2081 x) \u03b8\u2080) \u03b8)\n\nlemma uint_grad_left {shape\u2081 shape\u2082 : S} (f\u2081 f\u2082 : T shape\u2081 \u2192 T shape\u2082 \u2192 \u211d) (\u03b8 : T shape\u2081) :\n  (\u2200 x, is_cdifferentiable (\u03bb \u03b8\u2080, f\u2081 \u03b8\u2080 x) \u03b8) \u2192 (\u2200 x, is_cdifferentiable (\u03bb \u03b8\u2080, f\u2082 \u03b8\u2080 x) \u03b8) \u2192\n   is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, \u2207 (\u03bb \u03b8\u2081, f\u2081 \u03b8\u2081 x \u2b1d f\u2082 \u03b8\u2081 x) \u03b8\u2080) \u03b8 \u2192 is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f\u2082 \u03b8\u2080 x \u2b1d \u2207 (\u03bb \u03b8\u2081, f\u2081 \u03b8\u2081 x) \u03b8\u2080) \u03b8 :=\nassume H_cdiff\u2081 H_cdiff\u2082 H_uint_grad, (iff.mpr (is_uniformly_integrable_around_binary_grad f\u2081 f\u2082 \u03b8 H_cdiff\u2081 H_cdiff\u2082) H_uint_grad)^.left\n\nlemma uint_grad_right {shape\u2081 shape\u2082 : S} (f\u2081 f\u2082 : T shape\u2081 \u2192 T shape\u2082 \u2192 \u211d) (\u03b8 : T shape\u2081) :\n  (\u2200 x, is_cdifferentiable (\u03bb \u03b8\u2080, f\u2081 \u03b8\u2080 x) \u03b8) \u2192 (\u2200 x, is_cdifferentiable (\u03bb \u03b8\u2080, f\u2082 \u03b8\u2080 x) \u03b8) \u2192\n   is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, \u2207 (\u03bb \u03b8\u2081, f\u2081 \u03b8\u2081 x \u2b1d f\u2082 \u03b8\u2081 x) \u03b8\u2080) \u03b8 \u2192 is_uniformly_integrable_around (\u03bb \u03b8\u2080 x, f\u2081 \u03b8\u2080 x \u2b1d \u2207 (\u03bb \u03b8\u2081, f\u2082 \u03b8\u2081 x) \u03b8\u2080) \u03b8 :=\nassume H_cdiff\u2081 H_cdiff\u2082 H_uint_grad, (iff.mpr (is_uniformly_integrable_around_binary_grad f\u2081 f\u2082 \u03b8 H_cdiff\u2081 H_cdiff\u2082) H_uint_grad)^.right\n\n-- integrals\naxiom integral_scale : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) (\u03b1 : \u211d),\n  \u222b (\u03bb x, \u03b1 \u2b1d f x) = \u03b1 \u2b1d \u222b (\u03bb x, f x)\n\naxiom integral_neg : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082),\n  \u222b (\u03bb x, - (f x)) = - \u222b (\u03bb x, f x)\n\naxiom integral_div : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) (y : T shape\u2082),\n  \u222b (\u03bb x, (f x) / y) = \u222b (\u03bb x, f x) / y\n\naxiom integral_add : \u03a0 {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082),\n  is_integrable f \u2192 is_integrable g \u2192 \u222b (\u03bb x, f x + g x) = \u222b (\u03bb x, f x) + \u222b (\u03bb x, g x)\n\naxiom integral_fscale : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 \u211d) (y : T shape\u2082),\n  \u222b (\u03bb x, f x \u2b1d y) = \u222b (\u03bb x, f x) \u2b1d y\n\naxiom integral_pos : \u2200 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082), (\u2200 x, f x > 0) \u2192 \u222b (\u03bb x, f x) > 0\naxiom integral_nneg : \u2200 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082), (\u2200 x, f x \u2265 0) \u2192 \u222b (\u03bb x, f x) \u2265 0\n\nlemma integral_congr {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082) (H_fg : \u2200 x, f x = g x) : \u222b f = \u222b g :=\n  show \u222b (\u03bb x, f x) = \u222b (\u03bb x, g x), by rw (funext H_fg)\n\naxiom integral_sum : \u03a0 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082), is_integrable f \u2192 \u222b (\u03bb x, sum (f x)) = sum (\u222b (\u03bb x, f x))\n\naxiom smul_tmulT {ishape oshape : S} (\u03b1 : \u211d) (M : T (ishape ++ oshape)) (y : T oshape) :\n  \u03b1 \u2b1d (tmulT M y) = tmulT M (\u03b1 \u2b1d y)\n\naxiom integral_tmulT {ishape oshape fshape : S} (M : T (ishape ++ oshape)) (f : T fshape \u2192 T oshape) :\n  \u222b (\u03bb x, tmulT M (f x)) = tmulT M (\u222b f)\n\naxiom integral_continuous : \u2200 {ishape tshape fshape : S} (f : T ishape \u2192 T tshape \u2192 T fshape) (\u03b8 : T tshape),\n  (\u2200 x, is_continuous (f x) \u03b8) \u2192 is_continuous (\u03bb \u03b8\u2080, \u222b (\u03bb x\u2080, f x\u2080 \u03b8\u2080)) \u03b8\n\n-- D\n\naxiom tmulT_scalar {shape : S} : \u2200 (x : T (shape ++ [])) (y : \u211d), tmulT x y = y \u2b1d (eq.rec_on (append_nil shape) x)\naxiom D_scalar {shape : S} (f : T shape \u2192 \u211d) (\u03b8 : T shape) : (eq.rec_on (append_nil shape) (D f \u03b8) : T shape) = \u2207 f \u03b8\n\n-- dintegral\n\nlemma dintegral_pos {oshape : S} : \u03a0 {shapes : list S} {f : dvec T shapes \u2192 T oshape}, (\u2200 x, f x > 0) \u2192 dintegral (\u03bb 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} (\u03b1 : \u211d) : \u03a0 {shapes : list S} (f : dvec T shapes \u2192 T shape),\n  dintegral (\u03bb (xs : dvec T shapes), \u03b1 \u2b1d f xs) = \u03b1 \u2b1d dintegral (\u03bb xs, f xs)\n| [] f := rfl\n\n| (ds::shapes) f :=\nbegin\ndunfold dintegral,\nsimp [\u03bb x, @dintegral_scale shapes (\u03bb v, f (x ::: v))],\nrw integral_scale,\nend\n\nlemma is_dintegrable_scale {oshape : S} : \u03a0 {shapes : list S} (f : dvec T shapes \u2192 T oshape) (\u03b1 : \u211d),\n  is_dintegrable f \u2194 is_dintegrable (\u03bb x, \u03b1 \u2b1d f x)\n| [] f \u03b1 := begin split, all_goals { intro, exact trivial } end\n| (shape::shapes) f \u03b1 :=\nbegin\ndunfold dintegral is_dintegrable,\nsplit,\n{ intro Hf, split,\n  { simp only [dintegral_scale], exact iff.mp (is_integrable_scale _ \u03b1) Hf^.left },\n  { intro x, exact iff.mp (is_dintegrable_scale _ _) (Hf^.right x) } },\n{ intro H\u03b1f, split,\n  { simp only [dintegral_scale] at H\u03b1f, exact iff.mpr (is_integrable_scale _ \u03b1) H\u03b1f^.left },\n  { intro x, exact iff.mpr (is_dintegrable_scale _ _) (H\u03b1f^.right x) } }\nend\n\nlemma dintegral_add {shape : S} : \u03a0 {shapes : list S} (f g : dvec T shapes \u2192 T shape),\n  is_dintegrable f \u2192 is_dintegrable g \u2192\n  dintegral (\u03bb (xs : dvec T shapes), f xs + g xs) = dintegral (\u03bb (xs : dvec T shapes), f xs) + dintegral (\u03bb (xs : dvec T shapes), g xs)\n| [] f g Hf Hg := rfl\n\n| (ds::shapes) f g Hf Hg :=\nbegin\ndunfold dintegral,\nsimp [\u03bb x, @dintegral_add shapes (\u03bb v, f (x ::: v)) (\u03bb v, g (x :::v)) (Hf^.right x) (Hg^.right x)],\nrw integral_add _ _ Hf^.left Hg^.left\nend\n\nlemma dintegral_div {shape : S} : \u03a0 {shapes : list S} (f : dvec T shapes \u2192 T shape) (y : T shape),\n  dintegral (\u03bb (xs : dvec T shapes), (f xs) / y) = dintegral (\u03bb (xs : dvec T shapes), f xs) / y\n| [] f y := rfl\n\n| (ds::shapes) f y :=\nbegin\ndunfold dintegral,\nsimp [\u03bb x, @dintegral_div shapes (\u03bb v, f (x ::: v)) y],\nrw integral_div\nend\n\nlemma dintegral_add_middle {shape : S} : \u03a0 {shapes : list S} (pdf : dvec T shapes \u2192 \u211d) (f g : dvec T shapes \u2192 T shape),\n  is_dintegrable (\u03bb xs, pdf xs \u2b1d f xs) \u2192 is_dintegrable (\u03bb xs, pdf xs \u2b1d g xs) \u2192\n  dintegral (\u03bb (xs : dvec T shapes), pdf xs \u2b1d (f xs + g xs)) = dintegral (\u03bb (xs : dvec T shapes), pdf xs \u2b1d f xs) + dintegral (\u03bb (xs : dvec T shapes), pdf xs \u2b1d 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 [\u03bb x, @dintegral_add_middle shapes (\u03bb v, pdf (x ::: v)) (\u03bb v, f (x ::: v)) (\u03bb 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} : \u03a0 {shapes : list S} (pdf : dvec T shapes \u2192 \u211d) (f : dvec T shapes \u2192 T shape),\n  dintegral (\u03bb (xs : dvec T shapes), pdf xs \u2b1d - (f xs)) = - dintegral (\u03bb (xs : dvec T shapes), pdf xs \u2b1d f xs)\n| [] pdf f := begin dunfold dintegral, apply smul_neg end\n\n| (ds::shapes) pdf f :=\nbegin\ndunfold dintegral,\nsimp [\u03bb x, @dintegral_neg_middle shapes (\u03bb v, pdf (x ::: v)) (\u03bb v, f (x ::: v))],\nrw integral_neg\nend\n\nlemma dintegral_mul (\u03b1 : \u211d) : \u03a0 {shapes : list S} (f : dvec T shapes \u2192 \u211d),\n  dintegral (\u03bb (xs : dvec T shapes), \u03b1 * f xs) = \u03b1 * dintegral (\u03bb xs, f xs) :=\nbegin\nintros shapes f,\nrw -(const_scalar \u03b1),\nsimp [\u03bb s x, eq.symm (smul.def \u03b1 s x)],\nsimp [\u03bb \u03b1 f, eq.symm (smul_scalar \u03b1 f)],\nexact (dintegral_scale \u03b1 f)\nend\n\nlemma dintegral_scale_middle  {shape : S} (\u03b1 : \u211d) : \u03a0 {shapes : list S} (f : dvec T shapes \u2192 \u211d) (g : dvec T shapes \u2192 T shape),\n  dintegral (\u03bb (xs : dvec T shapes), f xs \u2b1d (\u03b1 \u2b1d g xs)) = \u03b1 \u2b1d dintegral (\u03bb xs, f xs \u2b1d 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 [\u03bb x, @dintegral_scale_middle shapes (\u03bb v, f (x ::: v)) (\u03bb v, g (x ::: v))],\nrw integral_scale,\nend\n\nlemma dintegral_mul_middle (\u03b1 : \u211d) : \u03a0 {shapes : list S} (f : dvec T shapes \u2192 \u211d) (g : dvec T shapes \u2192 \u211d),\n  dintegral (\u03bb (xs : dvec T shapes), f xs \u2b1d (\u03b1 * g xs)) = \u03b1 * dintegral (\u03bb xs, f xs \u2b1d g xs) :=\nbegin\nintros shapes f g,\nrw -(const_scalar \u03b1),\nsimp [\u03bb s x, eq.symm (smul.def \u03b1 s x)],\nsimp [\u03bb xs, eq.symm (smul_scalar \u03b1 (g xs))],\nrw dintegral_scale_middle \u03b1 f g,\nsimp [smul_scalar]\nend\n\nlemma dintegral_tmulT  {shape\u2081 shape\u2082 : S} (M : T (shape\u2081 ++ shape\u2082)) : \u03a0 {shapes : list S} (f : dvec T shapes \u2192 T shape\u2082),\n  dintegral (\u03bb (xs : dvec T shapes), tmulT M (f xs)) = tmulT M (dintegral (\u03bb xs, f xs))\n| []           f := rfl\n\n| (ds::shapes) f :=\nbegin\ndunfold dintegral,\nsimp [\u03bb x, @dintegral_tmulT shapes (\u03bb v, f (x ::: v))],\nrw integral_tmulT\nend\n\nlemma dintegral_tmulT_middle {shape\u2081 shape\u2082 : S} (M : T (shape\u2081 ++ shape\u2082)) : \u03a0 {shapes : list S} (f : dvec T shapes \u2192 \u211d) (g : dvec T shapes \u2192 T shape\u2082),\n  dintegral (\u03bb (xs : dvec T shapes), f xs \u2b1d (tmulT M (g xs))) = tmulT M (dintegral (\u03bb xs, f xs \u2b1d g xs)) :=\nbegin\nintros shapes f g,\nsimp [smul_tmulT, dintegral_tmulT]\nend\n\nlemma dintegral_const_middle {yshape : S} :\n  \u2200 {shapes : list S} (pdf : dvec T shapes \u2192 \u211d) (H_pdf_pos : \u2200 x, pdf x > 0) (H_pdf_int1 : dintegral pdf = 1) (y : T yshape),\n    dintegral (\u03bb (xs : dvec T shapes), pdf xs \u2b1d 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 \u2192 dvec T shapes \u2192 \u211d := \u03bb x (xs : dvec T shapes), pdf (x ::: xs) / dintegral (\u03bb (xs : dvec T shapes), pdf (x ::: xs)) in\nhave H_dpos : \u2200 (x : T shape), dintegral (\u03bb (xs : dvec T shapes), pdf (x ::: xs)) > 0, from \u03bb x, dintegral_pos (\u03bb x, H_pdf_pos _),\nhave H_pdf'_pos : \u2200 (x : T shape) (xs : dvec T shapes), pdf' x xs > 0, from\n  assume (x : T shape) (xs : dvec T shapes),\n  have H\u2081 : pdf (x ::: xs) > 0, by apply H_pdf_pos,\n  T.div_pos_pos H\u2081 (H_dpos x),\n\nhave H_pdf'_int1 : \u2200 (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\u2081 : \u2200 (x : T shape), dintegral (\u03bb (v : dvec T shapes), pdf (x ::: v) \u2b1d y)\n                     = dintegral (\u03bb (v : dvec T shapes), (pdf' x v * dintegral (\u03bb (vs : dvec T shapes), pdf (x ::: vs))) \u2b1d 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\u2082 : \u2200 x, dintegral (\u03bb (v : dvec T shapes), (pdf' x v * dintegral (\u03bb (vs : dvec T shapes), pdf (x ::: vs))) \u2b1d y)\n                     = dintegral (\u03bb (vs : dvec T shapes), pdf (x ::: vs)) \u2b1d dintegral (\u03bb (v : dvec T shapes), pdf' x v \u2b1d y), from\n  assume (x : T shape),\n  begin dsimp, simp [smul_group, dintegral_scale] end,\nbegin\ndunfold dintegral,\nsimp [H_inner\u2081, H_inner\u2082, (\u03bb x, @dintegral_const_middle shapes (pdf' x) (H_pdf'_pos x) (H_pdf'_int1 x)), integral_fscale],\nchange dintegral (\u03bb (vs : dvec T (shape::shapes)), pdf vs) \u2b1d y = y,\nrw [H_pdf_int1, one_smul]\nend\n\n-- btw axioms\n\naxiom is_btw_id {shape : S} : is_btw_exp\u2082 (\u03bb (x : T shape), x)\naxiom is_btw_const {shape\u2081 shape\u2082 : S} (y : T shape\u2082) : is_btw_exp\u2082 (\u03bb (x : T shape\u2081), y)\naxiom is_btw_sigmoid {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 (\u03bb (x : T shape\u2081), sigmoid (f x))\naxiom is_btw_softplus {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 (\u03bb (x : T shape\u2081), softplus (f x))\naxiom is_btw_sum {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 (\u03bb (x : T shape\u2081), sum (f x))\naxiom is_btw_log_sigmoid {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) (y : T shape\u2082) : y > 0 \u2192 is_btw_exp\u2082 f \u2192 \n  is_btw_exp\u2082 (\u03bb (x : T shape\u2081), log (y + sigmoid (f x)))\naxiom is_btw_log_1msigmoid {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) (y : T shape\u2082) : y > 0 \u2192 is_btw_exp\u2082 f \u2192 \n  is_btw_exp\u2082 (\u03bb (x : T shape\u2081), log (y + (1 - sigmoid (f x))))\n\naxiom is_btw_gemm {shape : S} {m n p : \u2115} (f : T shape \u2192 T [m, n]) (g : T shape \u2192 T [n, p]) :\n  is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 g \u2192 is_btw_exp\u2082 (\u03bb x, gemm (f x) (g x))\n\naxiom is_btw_transpose {shape : S} {m n : \u2115} (f : T shape \u2192 T [m, n]) :\n  is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 (\u03bb x, transpose (f x))\n\naxiom is_btw_neg {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 (\u03bb x, - (f x))\naxiom is_btw_inv {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 (\u03bb x, (f x)\u207b\u00b9)\naxiom is_btw_add {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 g \u2192 is_btw_exp\u2082 (\u03bb x, f x + g x)\naxiom is_btw_mul {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 g \u2192 is_btw_exp\u2082 (\u03bb x, f x * g x)\naxiom is_btw_sub {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 g \u2192 is_btw_exp\u2082 (\u03bb x, f x - g x)\naxiom is_btw_div {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082) : is_btw_exp\u2082 f \u2192 is_btw_exp\u2082 g \u2192 is_btw_exp\u2082 (\u03bb x, f x / g x)\n\naxiom is_btw_exp {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) : is_sub_quadratic f \u2192 is_btw_exp\u2082 (\u03bb x, exp (f x))\n\n-- sub quadratic axioms\n\naxiom is_sub_quadratic_id {shape : S} : is_sub_quadratic (\u03bb (x : T shape), x)\naxiom is_sub_quadratic_const {shape\u2081 shape\u2082 : S} (y : T shape\u2082) : is_sub_quadratic (\u03bb (x : T shape\u2081), y)\n\naxiom is_sub_quadratic_gemm {shape : S} {m n p : \u2115} (f : T shape \u2192 T [m, n]) (g : T shape \u2192 T [n, p]) :\n  is_sub_quadratic f \u2192 is_sub_quadratic g \u2192 is_sub_quadratic (\u03bb x, gemm (f x) (g x))\n\naxiom is_sub_quadratic_transpose {shape : S} {m n : \u2115} (f : T shape \u2192 T [m, n]) :\n  is_sub_quadratic f \u2192 is_sub_quadratic (\u03bb x, transpose (f x))\n\naxiom is_sub_quadratic_softplus {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) : is_sub_quadratic f \u2192 is_sub_quadratic (\u03bb x, softplus (f x))\n\naxiom is_sub_quadratic_neg {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) : is_sub_quadratic f \u2192 is_sub_quadratic (\u03bb x, - (f x))\naxiom is_sub_quadratic_mul\u2081 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) (y : T shape\u2082) : is_sub_quadratic f \u2192 is_sub_quadratic (\u03bb x, y * f x)\naxiom is_sub_quadratic_mul\u2082 {shape\u2081 shape\u2082 : S} (f : T shape\u2081 \u2192 T shape\u2082) (y : T shape\u2082) : is_sub_quadratic f \u2192 is_sub_quadratic (\u03bb x, f x * y)\n\naxiom is_sub_quadratic_add {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082) : is_sub_quadratic f \u2192 is_sub_quadratic g \u2192 is_sub_quadratic (\u03bb x, f x + g x)\naxiom is_sub_quadratic_sub {shape\u2081 shape\u2082 : S} (f g : T shape\u2081 \u2192 T shape\u2082) : is_sub_quadratic f \u2192 is_sub_quadratic g \u2192 is_sub_quadratic (\u03bb x, f x - g x)\n\n-- is_bounded_btw_exp\u2082_around {shape\u2081 shape\u2082 shape\u2083 : S} (f : \u03a0 (x : T shape\u2081) (\u03b8 : T shape\u2082), T shape\u2083) (\u03b8 : T shape\u2082) : Prop\n\naxiom is_bbtw_of_btw {shape\u2081 shape\u2082 shape\u2083 : S} (f : \u03a0 (x : T shape\u2081), T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_btw_exp\u2082 f \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, f x) \u03b8\n\naxiom is_bbtw_id {shape\u2081 shape\u2082 : S} (\u03b8 : T shape\u2082) : is_bounded_btw_exp\u2082_around (\u03bb (x : T shape\u2081) (\u03b8\u2080 : T shape\u2082), \u03b8\u2080) \u03b8\n\naxiom is_bbtw_softplus {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, softplus (f x \u03b8\u2080)) \u03b8\n\naxiom is_bbtw_sum {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, sum (f x \u03b8\u2080)) \u03b8\n\naxiom is_bbtw_log_sigmoid {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (y : T shape\u2083) (\u03b8 : T shape\u2082) : y > 0 \u2192\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, log (y + sigmoid (f x \u03b8\u2080))) \u03b8\n\naxiom is_bbtw_log_1msigmoid {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (y : T shape\u2083) (\u03b8 : T shape\u2082) : y > 0 \u2192\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, log (y + (1 - sigmoid (f x \u03b8\u2080)))) \u03b8\n\naxiom is_bbtw_gemm {shape\u2081 shape\u2082 : S} {m n p : \u2115} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T [m, n]) (g : T shape\u2081 \u2192 T shape\u2082 \u2192 T [n, p]) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around g \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, gemm (f x \u03b8\u2080) (g x \u03b8\u2080)) \u03b8\n\naxiom is_bbtw_neg {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, - f x \u03b8\u2080) \u03b8\n\naxiom is_bbtw_inv {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, (f x \u03b8\u2080)\u207b\u00b9) \u03b8\n\naxiom is_bbtw_add {shape\u2081 shape\u2082 shape\u2083 : S} (f g : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around g \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, f x \u03b8\u2080 + g x \u03b8\u2080) \u03b8\n\naxiom is_bbtw_sub {shape\u2081 shape\u2082 shape\u2083 : S} (f g : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around g \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, f x \u03b8\u2080 - g x \u03b8\u2080) \u03b8\n\naxiom is_bbtw_mul {shape\u2081 shape\u2082 shape\u2083 : S} (f g : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around g \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, f x \u03b8\u2080 * g x \u03b8\u2080) \u03b8\n\naxiom is_bbtw_exp {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) :\n  is_sub_quadratic (\u03bb x, f x \u03b8) \u2192 (\u2200 x, is_sub_quadratic (f x)) \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, exp (f x \u03b8\u2080)) \u03b8\n\nlemma is_bbtw_bernoulli_neglogpdf {shape\u2081 shape\u2082 shape\u2083 : S} (f : T shape\u2081 \u2192 T shape\u2082 \u2192 T shape\u2083) (\u03b8 : T shape\u2082) (p : T shape\u2083) :\n  is_bounded_btw_exp\u2082_around f \u03b8 \u2192 is_bounded_btw_exp\u2082_around (\u03bb x \u03b8\u2080, bernoulli_neglogpdf (sigmoid (f x \u03b8\u2080)) p) \u03b8 :=\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 \u2192 T fshape) (\u03b1 \u03b2 : T shape) : \u222b (\u03bb x, f (\u03b1 * x + \u03b2)) = \u222b (\u03bb x, prod \u03b1\u207b\u00b9 \u2b1d 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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, `\u03b9`, `\u03ba`, `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 \u2243\u2097[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 {\u03b9 : Type _} [DecidableEq \u03b9] [Fintype \u03b9]\n\nvariable (e : Basis \u03b9 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 \u2192 R) \u2243\u2097[R] n \u2192 R) : m \u2243 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) : m \u2243 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 \u2b1d N) = det (N \u2b1d 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 \u2b1d M) = det (M \u2b1d 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) : det (M \u2b1d N) = det (N \u2b1d 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 [\u2190 det_submatrix_equiv_self e, \u2190 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 \u2b1d N \u2b1d M') = det N`.\n\nSee `matrix.det_conj` and `matrix.det_conj'` for the case when `M' = M\u207b\u00b9` 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) :\n    det (M \u2b1d N \u2b1d M') = det N := by\n  rw [\u2190 det_comm' hM'M hMM', \u2190 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 {\u03ba : Type _} [Fintype \u03ba]\n\n/-- The determinant of `linear_map.to_matrix` does not depend on the choice of basis. -/\ntheorem det_toMatrix_eq_det_toMatrix [DecidableEq \u03ba] (b : Basis \u03b9 A M) (c : Basis \u03ba A M)\n    (f : M \u2192\u2097[A] M) : det (LinearMap.toMatrix b b f) = det (LinearMap.toMatrix c c f) := by\n  rw [\u2190 linearMap_toMatrix_mul_basis_toMatrix c b c, \u2190 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 \u03b9 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 \u03b9 A M) \u2192 (M \u2192\u2097[A] M) \u2192* A :=\n  Trunc.lift\n    (fun b : Basis \u03b9 A M => detMonoidHom.comp (toMatrixAlgEquiv b : (M \u2192\u2097[A] M) \u2192* Matrix \u03b9 \u03b9 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 \u03b9 A M) (f : M \u2192\u2097[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' {\u03b9' : Type _} [Fintype \u03b9'] [DecidableEq \u03b9'] (tb : Trunc <| Basis \u03b9 A M)\n    (b' : Basis \u03b9' A M) (f : M \u2192\u2097[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 \u03b9 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 \u03b9 A M) (f g : M \u2192\u2097[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 \u2192\u2097[A] M) \u2192* A :=\n  if H : \u2203 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    \u21d1(LinearMap.det : (M \u2192\u2097[A] M) \u2192* A) =\n      if H : \u2203 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  \u00b7 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 \u2192\u2097[A] M) : f.det = Matrix.det (LinearMap.toMatrix b b f) :=\n  by\n  have : \u2203 s : Finset M, Nonempty (Basis s A M) := \u27e8s, \u27e8b\u27e9\u27e9\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 \u03b9 A M) (f : M \u2192\u2097[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' {\u03b9 : Type _} [Fintype \u03b9] [DecidableEq \u03b9] (f : (\u03b9 \u2192 A) \u2192\u2097[A] \u03b9 \u2192 A) :\n    det f.toMatrix' = f.det := by simp [\u2190 to_matrix_eq_to_matrix']\n#align linear_map.det_to_matrix' LinearMap.det_toMatrix'\n\n@[simp]\ntheorem det_toLin (b : Basis \u03b9 R M) (f : Matrix \u03b9 \u03b9 R) :\n    LinearMap.det (Matrix.toLin b b f) = f.det := by\n  rw [\u2190 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 \u03b9 \u03b9 R) : LinearMap.det f.toLin' = f.det := by\n  simp only [\u2190 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 \u2192 Prop} (f : M \u2192\u2097[A] M)\n    (hb : \u2200 (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  \u00b7 convert hb _ h.some_spec.some\n    apply det_aux_def'\n  \u00b7 exact h1\n#align linear_map.det_cases LinearMap.det_cases\n\n@[simp]\ntheorem det_comp (f g : M \u2192\u2097[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 \u2192\u2097[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 {\ud835\udd5c : Type _} [Field \ud835\udd5c] {M : Type _} [AddCommGroup M] [Module \ud835\udd5c M] (c : \ud835\udd5c)\n    (f : M \u2192\u2097[\ud835\udd5c] M) : LinearMap.det (c \u2022 f) = c ^ FiniteDimensional.finrank \ud835\udd5c M * LinearMap.det f :=\n  by\n  by_cases H : \u2203 s : Finset M, Nonempty (Basis s \ud835\udd5c M)\n  \u00b7 have : FiniteDimensional \ud835\udd5c M := by\n      rcases H with \u27e8s, \u27e8hs\u27e9\u27e9\n      exact FiniteDimensional.of_fintype_basis hs\n    simp only [\u2190 det_to_matrix (FiniteDimensional.finBasis \ud835\udd5c M), LinearEquiv.map_smul,\n      Fintype.card_fin, det_smul]\n  \u00b7\n    classical\n      have : FiniteDimensional.finrank \ud835\udd5c 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' {\u03b9 : Type _} [Finite \u03b9] [Nonempty \u03b9] (b : Basis \u03b9 A M) :\n    LinearMap.det (0 : M \u2192\u2097[A] M) = 0 :=\n  by\n  haveI := Classical.decEq \u03b9\n  cases nonempty_fintype \u03b9\n  rwa [\u2190 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 {\ud835\udd5c : Type _} [Field \ud835\udd5c] {M : Type _} [AddCommGroup M] [Module \ud835\udd5c M] :\n    LinearMap.det (0 : M \u2192\u2097[\ud835\udd5c] M) = (0 : \ud835\udd5c) ^ FiniteDimensional.finrank \ud835\udd5c M := by\n  simp only [\u2190 zero_smul \ud835\udd5c (1 : M \u2192\u2097[\ud835\udd5c] 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 \u2192\u2097[R] M) : (f : M \u2192\u2097[R] M).det = 1 :=\n  by\n  have b : Basis (Fin 0) R M := Basis.empty M\n  rw [\u2190 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 {\ud835\udd5c : Type _} [Field \ud835\udd5c] {M : Type _} [AddCommGroup M]\n    [Module \ud835\udd5c M] (h : FiniteDimensional.finrank \ud835\udd5c M = 0) (f : M \u2192\u2097[\ud835\udd5c] M) :\n    (f : M \u2192\u2097[\ud835\udd5c] M).det = 1 := by\n  classical\n    refine' @LinearMap.det_cases M _ \ud835\udd5c _ _ _ (fun t => t = 1) f _ rfl\n    intro s b\n    have : IsEmpty s := by\n      rw [\u2190 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 \u2192\u2097[A] M) (e : M \u2243\u2097[A] N) :\n    LinearMap.det ((e : M \u2192\u2097[A] N) \u2218\u2097 f \u2218\u2097 (e.symm : N \u2192\u2097[A] M)) = LinearMap.det f := by\n  classical\n    by_cases H : \u2203 s : Finset M, Nonempty (Basis s A M)\n    \u00b7 rcases H with \u27e8s, \u27e8b\u27e9\u27e9\n      rw [\u2190 det_to_matrix b f, \u2190 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, \u2190 Matrix.mul_assoc, Matrix.det_conj_of_mul_eq_one]\n      \u00b7\n        rw [\u2190 to_matrix_comp, LinearEquiv.comp_coe, e.symm_trans_self, LinearEquiv.refl_toLinearMap,\n          to_matrix_id]\n      \u00b7\n        rw [\u2190 to_matrix_comp, LinearEquiv.comp_coe, e.self_trans_symm, LinearEquiv.refl_toLinearMap,\n          to_matrix_id]\n    \u00b7 have H' : \u00ac\u2203 t : Finset N, Nonempty (Basis t A N) :=\n        by\n        contrapose! H\n        rcases H with \u27e8s, \u27e8b\u27e9\u27e9\n        exact \u27e8_, \u27e8(b.map e.symm).reindexFinsetRange\u27e9\u27e9\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 \u2192\u2097[A] M) (hf : IsUnit f) :\n    IsUnit f.det := by\n  obtain \u27e8g, hg\u27e9 : \u2203 g, f.comp g = 1 := hf.exists_right_inv\n  have : LinearMap.det f * LinearMap.det g = 1 := by\n    simp only [\u2190 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 {\ud835\udd5c : Type _} [Field \ud835\udd5c] [Module \ud835\udd5c M] (f : M \u2192\u2097[\ud835\udd5c] M)\n    (hf : f.det \u2260 1) : FiniteDimensional \ud835\udd5c M :=\n  by\n  by_cases H : \u2203 s : Finset M, Nonempty (Basis s \ud835\udd5c M)\n  \u00b7 rcases H with \u27e8s, \u27e8hs\u27e9\u27e9\n    exact FiniteDimensional.of_fintype_basis hs\n  \u00b7\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 {\ud835\udd5c : Type _} [Field \ud835\udd5c] [Module \ud835\udd5c M] {f : M \u2192\u2097[\ud835\udd5c] M}\n    (hf : f.det = 0) : f.range < \u22a4 :=\n  by\n  have : FiniteDimensional \ud835\udd5c 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, \u2190 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 {\ud835\udd5c : Type _} [Field \ud835\udd5c] [Module \ud835\udd5c M] {f : M \u2192\u2097[\ud835\udd5c] M}\n    (hf : f.det = 0) : \u22a5 < f.ker :=\n  by\n  have : FiniteDimensional \ud835\udd5c 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, \u2190 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\u02e3`. -/\nprotected def det : (M \u2243\u2097[R] M) \u2192* R\u02e3 :=\n  (Units.map (LinearMap.det : (M \u2192\u2097[R] M) \u2192* 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 \u2243\u2097[R] M) : \u2191f.det = LinearMap.det (f : M \u2192\u2097[R] M) :=\n  rfl\n#align linear_equiv.coe_det LinearEquiv.coe_det\n\n@[simp]\ntheorem coe_inv_det (f : M \u2243\u2097[R] M) : \u2191f.det\u207b\u00b9 = LinearMap.det (f.symm : M \u2192\u2097[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 \u2243\u2097[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 \u2243\u2097[R] M) : f.symm.det = f.det\u207b\u00b9 :=\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 \u2243\u2097[R] M) (e : M \u2243\u2097[R] M') : ((e.symm.trans f).trans e).det = f.det := by\n  rw [\u2190 Units.eq_iff, coe_det, coe_det, \u2190 comp_coe, \u2190 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 \u2243\u2097[A] M) :\n    (f : M \u2192\u2097[A] M).det * (f.symm : M \u2192\u2097[A] M).det = 1 := by simp [\u2190 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 \u2243\u2097[A] M) :\n    (f.symm : M \u2192\u2097[A] M).det * (f : M \u2192\u2097[A] M).det = 1 := by simp [\u2190 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 \u2243\u2097[R] M') (v : Basis \u03b9 R M) (v' : Basis \u03b9 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 \u2243\u2097[A] M) :\n    IsUnit (LinearMap.det (f : M \u2192\u2097[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 {\ud835\udd5c : Type _} [Field \ud835\udd5c] [Module \ud835\udd5c M] (f : M \u2243\u2097[\ud835\udd5c] M) :\n    (f.symm : M \u2192\u2097[\ud835\udd5c] M).det = (f : M \u2192\u2097[\ud835\udd5c] M).det\u207b\u00b9 := 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 \u2192\u2097[R] M'} {v : Basis \u03b9 R M} {v' : Basis \u03b9 R M'}\n    (h : IsUnit (LinearMap.toMatrix v v' f).det) : M \u2243\u2097[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)\u207b\u00b9\n  left_inv x :=\n    calc\n      toLin v' v (toMatrix v v' f)\u207b\u00b9 (f x) = toLin v v ((toMatrix v v' f)\u207b\u00b9 \u2b1d 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)\u207b\u00b9 x) =\n          toLin v' v' (toMatrix v v' f \u2b1d (toMatrix v v' f)\u207b\u00b9) 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 \u2192\u2097[R] M'} {v : Basis \u03b9 R M} {v' : Basis \u03b9 R M'}\n    (h : IsUnit (LinearMap.toMatrix v v' f).det) : (LinearEquiv.ofIsUnitDet h : M \u2192\u2097[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 {\ud835\udd5c : Type _} [Field \ud835\udd5c] {M : Type _} [AddCommGroup M] [Module \ud835\udd5c M]\n    [FiniteDimensional \ud835\udd5c M] (f : M \u2192\u2097[\ud835\udd5c] M) (hf : LinearMap.det f \u2260 0) : M \u2243\u2097[\ud835\udd5c] M :=\n  have :\n    IsUnit\n      (LinearMap.toMatrix (FiniteDimensional.finBasis \ud835\udd5c M) (FiniteDimensional.finBasis \ud835\udd5c 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 \u2243\u2097[R] M) (f f' : M \u2192\u2097[R] M)\n    (h : \u2200 x, f x = f' (e x)) : Associated f.det f'.det :=\n  by\n  suffices Associated (f' \u2218\u2097 \u2191e).det f'.det\n    by\n    convert this using 2\n    ext x\n    exact h x\n  rw [\u2190 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 \u2192\u2097[R] M) (e e' : M \u2243\u2097[R] N) : Associated (f \u2218\u2097 \u2191e).det (f \u2218\u2097 \u2191e').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 \u03b9\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 \u2039_\u203a\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 \u2039_\u203a\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 [\u2190 Function.update_eq_self i v, h, \u2190 det_transpose, e.to_matrix_update, \u2190\n      update_row_transpose, \u2190 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 : \u03b9 \u2192 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 \u03b9] : 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 \u2260 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 : \u03b9 \u2192 M} :\n    LinearIndependent R v \u2227 span R (Set.range v) = \u22a4 \u2194 IsUnit (e.det v) :=\n  by\n  constructor\n  \u00b7 rintro \u27e8hli, hspan\u27e9\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  \u00b7 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 : \u21d1v' = v := by\n      ext i\n      rw [v'_def, Basis.map_apply, LinearEquiv.ofIsUnitDet_apply, e.constr_basis]\n    rw [\u2190 this]\n    exact \u27e8v'.linear_independent, v'.span_eq\u27e9\n#align is_basis_iff_det is_basis_iff_det\n\ntheorem Basis.isUnit_det (e' : Basis \u03b9 R M) : IsUnit (e.det e') :=\n  (is_basis_iff_det e).mp \u27e8e'.LinearIndependent, e'.span_eq\u27e9\n#align basis.is_unit_det Basis.isUnit_det\n\n/-- Any alternating map to `R` where `\u03b9` 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 \u03b9) : f = f e \u2022 e.det :=\n  by\n  refine' Basis.ext_alternating e fun i h => _\n  let \u03c3 : Equiv.Perm \u03b9 := Equiv.ofBijective i (Finite.injective_iff_bijective.1 h)\n  change f (e \u2218 \u03c3) = (f e \u2022 e.det) (e \u2218 \u03c3)\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 {\u03b9 : Type _} [Finite \u03b9] (e : Basis \u03b9 R M)\n    (f : AlternatingMap R M R \u03b9) : f e = 0 \u2194 f = 0 :=\n  \u27e8fun h => by\n    cases nonempty_fintype \u03b9\n    letI := Classical.decEq \u03b9\n    simpa [h] using f.eq_smul_basis_det e, fun h => h.symm \u25b8 AlternatingMap.zero_apply _\u27e9\n#align alternating_map.map_basis_eq_zero_iff AlternatingMap.map_basis_eq_zero_iff\n\ntheorem AlternatingMap.map_basis_ne_zero_iff {\u03b9 : Type _} [Finite \u03b9] (e : Basis \u03b9 R M)\n    (f : AlternatingMap R M R \u03b9) : f e \u2260 0 \u2194 f \u2260 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 \u03b9 A M) (f : M \u2192\u2097[A] M) (v : \u03b9 \u2192 M) :\n    e.det (f \u2218 v) = f.det * e.det v := by\n  rw [Basis.det_apply, Basis.det_apply, \u2190 f.det_to_matrix e, \u2190 Matrix.det_mul,\n    e.to_matrix_eq_to_matrix_constr (f \u2218 v), e.to_matrix_eq_to_matrix_constr v, \u2190 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 \u03b9 A M) (b' : Basis \u03b9 A M') (f : M \u2192\u2097[A] M') :\n    b'.det (f \u2218 b) = LinearMap.det (f \u2218\u2097 (b'.Equiv b (Equiv.refl \u03b9) : M' \u2192\u2097[A] M)) :=\n  by\n  rw [Basis.det_apply, \u2190 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 {\u03b9' : Type _} [Fintype \u03b9'] [DecidableEq \u03b9'] (b : Basis \u03b9 R M) (v : \u03b9' \u2192 M)\n    (e : \u03b9 \u2243 \u03b9') : (b.reindex e).det v = b.det (v \u2218 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 {\u03b9' : Type _} [Fintype \u03b9'] [DecidableEq \u03b9'] (b : Basis \u03b9 R M)\n    (v : \u03b9 \u2192 M) (e : \u03b9' \u2243 \u03b9) : (b.reindex e.symm).det (v \u2218 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 \u03b9 R M) (f : M \u2243\u2097[R] M') (v : \u03b9 \u2192 M') :\n    (b.map f).det v = b.det (f.symm \u2218 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 \u03b9 R M) (f : M \u2243\u2097[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 \u03b9).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 : \u03b9 \u2192 M} (hli : LinearIndependent R v)\n    (hsp : \u22a4 \u2264 span R (range v)) (i : \u03b9) :\n    e.det v \u2022 (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  \u00b7 rw [Basis.mk_coord_apply_eq, mul_one, update_eq_self]\n    congr\n  \u00b7 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 : \u03b9 \u2192 R\u02e3`, 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 \u03b9 R M) (w : \u03b9 \u2192 R\u02e3) :\n    (e.units_smul w).det = (\u2191(\u220f i, w i)\u207b\u00b9 : R) \u2022 e.det :=\n  by\n  ext f\n  change\n    (Matrix.det fun i j => (e.units_smul w).repr (f j) i) =\n      (\u2191(\u220f i, w i)\u207b\u00b9 : R) \u2022 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 => (\u2191(w i)\u207b\u00b9 : R)) fun i j => e.repr (f j) i\n  simp [\u2190 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 : \u03b9 \u2192 R\u02e3) : e.det (e.units_smul w) = \u220f 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 : \u03b9 \u2192 R} (hw : \u2200 i, IsUnit (w i)) :\n    e.det (e.isUnitSmul hw) = \u220f 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 \u2192 Nat\n@[simp] axiom fEq (x : Nat) (h : x \u2260 0) : f x = x\n\nexample (x : Nat) (h : x \u2260 0) : f x = x + 0 := by\n  simp (discharger := trace_state; exact (fun h' => h') h)\n\nexample (x y : Nat) (h1 : x \u2260 0) (h2 : y \u2260 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 \u2260 0) (h2 : y \u2260 0) (h3 : x = y) : f x = f y + 0 := by\n  simp (discharger := assumption)\n  assumption\n\nexample (x y : Nat) (h1 : x \u2260 0) (h2 : y \u2260 0) (h3 : x = y) : f x = f y + 0 := by\n  simp (disch := assumption)\n  assumption\n\nexample (x y : Nat) (h1 : x \u2260 0) (h2 : y \u2260 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 : \u03b1} {l : List \u03b1} (h : a \u2208 l) : \u2203 s t : list \u03b1, l = s ++ a :: t :=\nby\n  induction l with b l ih, {cases h}, rcases h with rfl | h,\n  { exact \u27e8[], l, rfl\u27e9 },\n  { rcases ih h with \u27e8s, t, rfl\u27e9,\n    exact \u27e8b::s, t, rfl\u27e9 }\n\nend List\n\n/-\n\nTO BE PORTED\n\n\nuniverses u v w x\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b4 : Type x}\n\n\ninstance : is_left_id (list \u03b1) has_append.append [] :=\n\u27e8 nil_append \u27e9\n\ninstance : is_right_id (list \u03b1) has_append.append [] :=\n\u27e8 append_nil \u27e9\n\ninstance : is_associative (list \u03b1) has_append.append :=\n\u27e8 append_assoc \u27e9\n\ntheorem cons_ne_nil (a : \u03b1) (l : list \u03b1) : a::l \u2260 [].\n\ntheorem cons_ne_self (a : \u03b1) (l : list \u03b1) : a::l \u2260 l :=\nmt (congr_arg length) (nat.succ_ne_self _)\n\ntheorem head_eq_of_cons_eq {h\u2081 h\u2082 : \u03b1} {t\u2081 t\u2082 : list \u03b1} :\n      (h\u2081::t\u2081) = (h\u2082::t\u2082) \u2192 h\u2081 = h\u2082 :=\nassume Peq, list.no_confusion Peq (assume Pheq Pteq, Pheq)\n\ntheorem tail_eq_of_cons_eq {h\u2081 h\u2082 : \u03b1} {t\u2081 t\u2082 : list \u03b1} :\n      (h\u2081::t\u2081) = (h\u2082::t\u2082) \u2192 t\u2081 = t\u2082 :=\nassume Peq, list.no_confusion Peq (assume Pheq Pteq, Pteq)\n\n@[simp] theorem cons_injective {a : \u03b1} : injective (cons a) :=\nassume l\u2081 l\u2082, assume Pe, tail_eq_of_cons_eq Pe\n\ntheorem cons_inj (a : \u03b1) {l l' : list \u03b1} : a::l = a::l' \u2194 l = l' :=\ncons_injective.eq_iff\n\ntheorem exists_cons_of_ne_nil {l : list \u03b1} (h : l \u2260 nil) : \u2203 b L, l = b :: L :=\nby { induction l with c l',  contradiction,  use [c,l'], }\n\n/-! ### mem -/\n\ntheorem mem_singleton_self (a : \u03b1) : a \u2208 [a] := mem_cons_self _ _\n\ntheorem eq_of_mem_singleton {a b : \u03b1} : a \u2208 [b] \u2192 a = b :=\nassume : a \u2208 [b], or.elim (eq_or_mem_of_mem_cons this)\n  (assume : a = b, this)\n  (assume : a \u2208 [], absurd this (not_mem_nil a))\n\n@[simp] theorem mem_singleton {a b : \u03b1} : a \u2208 [b] \u2194 a = b :=\n\u27e8eq_of_mem_singleton, or.inl\u27e9\n\ntheorem mem_of_mem_cons_of_mem {a b : \u03b1} {l : list \u03b1} : a \u2208 b::l \u2192 b \u2208 l \u2192 a \u2208 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 \u2208 l, this)\n\ntheorem eq_or_ne_mem_of_mem {a b : \u03b1} {l : list \u03b1} (h : a \u2208 b :: l) : a = b \u2228 (a \u2260 b \u2227 a \u2208 l) :=\nclassical.by_cases or.inl $ assume : a \u2260 b, h.elim or.inl $ assume h, or.inr \u27e8this, h\u27e9\n\ntheorem not_mem_append {a : \u03b1} {s t : list \u03b1} (h\u2081 : a \u2209 s) (h\u2082 : a \u2209 t) : a \u2209 s ++ t :=\nmt mem_append.1 $ not_or_distrib.2 \u27e8h\u2081, h\u2082\u27e9\n\ntheorem ne_nil_of_mem {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) : l \u2260 [] :=\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 : \u03b1} {l : list \u03b1} (h\u2081 : a \u2260 y) (h\u2082 : a \u2208 y :: l) : a \u2208 l :=\nor.elim (eq_or_mem_of_mem_cons h\u2082) (\u03bbe, absurd e h\u2081) (\u03bbr, r)\n\ntheorem ne_of_not_mem_cons {a b : \u03b1} {l : list \u03b1} : a \u2209 b::l \u2192 a \u2260 b :=\nassume nin aeqb, absurd (or.inl aeqb) nin\n\ntheorem not_mem_of_not_mem_cons {a b : \u03b1} {l : list \u03b1} : a \u2209 b::l \u2192 a \u2209 l :=\nassume nin nainl, absurd (or.inr nainl) nin\n\ntheorem not_mem_cons_of_ne_of_not_mem {a y : \u03b1} {l : list \u03b1} : a \u2260 y \u2192 a \u2209 l \u2192 a \u2209 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 : \u03b1} {l : list \u03b1} : a \u2209 y::l \u2192 a \u2260 y \u2227 a \u2209 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 : \u03b1 \u2192 \u03b2) {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) : f a \u2208 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 : \u03b1 \u2192 \u03b2} {b : \u03b2} {l : list \u03b1} (h : b \u2208 map f l) :\n  \u2203 a, a \u2208 l \u2227 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 \u27e8c, mem_cons_self _ _, h.symm\u27e9},\n    {rcases ih h with \u27e8a, ha\u2081, ha\u2082\u27e9,\n      exact \u27e8a, mem_cons_of_mem _ ha\u2081, ha\u2082\u27e9 }}\nend\n\n@[simp] theorem mem_map {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {l : list \u03b1} : b \u2208 map f l \u2194 \u2203 a, a \u2208 l \u2227 f a = b :=\n\u27e8exists_of_mem_map, \u03bb \u27e8a, la, h\u27e9, by rw [\u2190 h]; exact mem_map_of_mem f la\u27e9\n\ntheorem mem_map_of_injective {f : \u03b1 \u2192 \u03b2} (H : injective f) {a : \u03b1} {l : list \u03b1} :\n  f a \u2208 map f l \u2194 a \u2208 l :=\n\u27e8\u03bb m, let \u27e8a', m', e\u27e9 := exists_of_mem_map m in H e \u25b8 m', mem_map_of_mem _\u27e9\n\nlemma forall_mem_map_iff {f : \u03b1 \u2192 \u03b2} {l : list \u03b1} {P : \u03b2 \u2192 Prop} :\n  (\u2200 i \u2208 l.map f, P i) \u2194 \u2200 j \u2208 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 \u27e8j, hj, ji\u27e9,\n    rw \u2190 ji,\n    exact H j hj }\nend\n\n@[simp] lemma map_eq_nil {f : \u03b1 \u2192 \u03b2} {l : list \u03b1} : list.map f l = [] \u2194 l = [] :=\n\u27e8by cases l; simp only [forall_prop_of_true, map, forall_prop_of_false, not_false_iff],\n  \u03bb h, h.symm \u25b8 rfl\u27e9\n\n@[simp] theorem mem_join {a : \u03b1} : \u2200 {L : list (list \u03b1)}, a \u2208 join L \u2194 \u2203 l, l \u2208 L \u2227 a \u2208 l\n| []       := \u27e8false.elim, \u03bb\u27e8_, h, _\u27e9, false.elim h\u27e9\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 : \u03b1} {L : list (list \u03b1)} : a \u2208 join L \u2192 \u2203 l, l \u2208 L \u2227 a \u2208 l :=\nmem_join.1\n\ntheorem mem_join_of_mem {a : \u03b1} {L : list (list \u03b1)} {l} (lL : l \u2208 L) (al : a \u2208 l) : a \u2208 join L :=\nmem_join.2 \u27e8l, lL, al\u27e9\n\n@[simp]\ntheorem mem_bind {b : \u03b2} {l : list \u03b1} {f : \u03b1 \u2192 list \u03b2} : b \u2208 list.bind l f \u2194 \u2203 a \u2208 l, b \u2208 f a :=\niff.trans mem_join\n  \u27e8\u03bb \u27e8l', h1, h2\u27e9, let \u27e8a, al, fa\u27e9 := exists_of_mem_map h1 in \u27e8a, al, fa.symm \u25b8 h2\u27e9,\n  \u03bb \u27e8a, al, bfa\u27e9, \u27e8f a, mem_map_of_mem _ al, bfa\u27e9\u27e9\n\ntheorem exists_of_mem_bind {b : \u03b2} {l : list \u03b1} {f : \u03b1 \u2192 list \u03b2} :\n  b \u2208 list.bind l f \u2192 \u2203 a \u2208 l, b \u2208 f a :=\nmem_bind.1\n\ntheorem mem_bind_of_mem {b : \u03b2} {l : list \u03b1} {f : \u03b1 \u2192 list \u03b2} {a} (al : a \u2208 l) (h : b \u2208 f a) :\n  b \u2208 list.bind l f :=\nmem_bind.2 \u27e8a, al, h\u27e9\n\nlemma bind_map {g : \u03b1 \u2192 list \u03b2} {f : \u03b2 \u2192 \u03b3} :\n  \u2200(l : list \u03b1), list.map f (l.bind g) = l.bind (\u03bba, (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 \u03b1} : length l = 0 \u2194 l = [] :=\n\u27e8eq_nil_of_length_eq_zero, \u03bb h, h.symm \u25b8 rfl\u27e9\n\n@[simp] lemma length_singleton (a : \u03b1) : length [a] = 1 := rfl\n\ntheorem length_pos_of_mem {a : \u03b1} : \u2200 {l : list \u03b1}, a \u2208 l \u2192 0 < length l\n| (b::l) _ := zero_lt_succ _\n\ntheorem exists_mem_of_length_pos : \u2200 {l : list \u03b1}, 0 < length l \u2192 \u2203 a, a \u2208 l\n| (b::l) _ := \u27e8b, mem_cons_self _ _\u27e9\n\ntheorem length_pos_iff_exists_mem {l : list \u03b1} : 0 < length l \u2194 \u2203 a, a \u2208 l :=\n\u27e8exists_mem_of_length_pos, \u03bb \u27e8a, h\u27e9, length_pos_of_mem h\u27e9\n\ntheorem ne_nil_of_length_pos {l : list \u03b1} : 0 < length l \u2192 l \u2260 [] :=\n\u03bb h1 h2, lt_irrefl 0 ((length_eq_zero.2 h2).subst h1)\n\ntheorem length_pos_of_ne_nil {l : list \u03b1} : l \u2260 [] \u2192 0 < length l :=\n\u03bb h, pos_iff_ne_zero.2 $ \u03bb h0, h $ length_eq_zero.1 h0\n\ntheorem length_pos_iff_ne_nil {l : list \u03b1} : 0 < length l \u2194 l \u2260 [] :=\n\u27e8ne_nil_of_length_pos, length_pos_of_ne_nil\u27e9\n\nlemma exists_mem_of_ne_nil (l : list \u03b1) (h : l \u2260 []) : \u2203 x, x \u2208 l :=\nexists_mem_of_length_pos (length_pos_of_ne_nil h)\n\ntheorem length_eq_one {l : list \u03b1} : length l = 1 \u2194 \u2203 a, l = [a] :=\n\u27e8match l with [a], _ := \u27e8a, rfl\u27e9 end, \u03bb \u27e8a, e\u27e9, e.symm \u25b8 rfl\u27e9\n\nlemma exists_of_length_succ {n} :\n  \u2200 l : list \u03b1, l.length = n + 1 \u2192 \u2203 h t, l = h :: t\n| [] H := absurd H.symm $ succ_ne_zero n\n| (h :: t) H := \u27e8h, t, rfl\u27e9\n\n@[simp] lemma length_injective_iff : injective (list.length : list \u03b1 \u2192 \u2115) \u2194 subsingleton \u03b1 :=\nbegin\n  split,\n  { intro h, refine \u27e8\u03bb x y, _\u27e9, suffices : [x] = [y], { simpa using this }, apply h, refl },\n  { intros h\u03b1 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 \u03b1] : injective (length : list \u03b1 \u2192 \u2115) :=\nlength_injective_iff.mpr $ by apply_instance\n\n/-! ### set-theoretic notation of lists -/\n\nlemma empty_eq : (\u2205 : list \u03b1) = [] := by refl\nlemma singleton_eq (x : \u03b1) : ({x} : list \u03b1) = [x] := rfl\nlemma insert_neg [decidable_eq \u03b1] {x : \u03b1} {l : list \u03b1} (h : x \u2209 l) :\n  has_insert.insert x l = x :: l :=\nif_neg h\nlemma insert_pos [decidable_eq \u03b1] {x : \u03b1} {l : list \u03b1} (h : x \u2208 l) :\n  has_insert.insert x l = l :=\nif_pos h\nlemma doubleton_eq [decidable_eq \u03b1] {x y : \u03b1} (h : x \u2260 y) : ({x, y} : list \u03b1) = [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 : \u03b1 \u2192 Prop) : \u2200 x \u2208 @nil \u03b1, p x.\n\ntheorem forall_mem_cons : \u2200 {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1},\n  (\u2200 x \u2208 a :: l, p x) \u2194 p a \u2227 \u2200 x \u2208 l, p x :=\nball_cons\n\ntheorem forall_mem_of_forall_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1}\n    (h : \u2200 x \u2208 a :: l, p x) :\n  \u2200 x \u2208 l, p x :=\n(forall_mem_cons.1 h).2\n\ntheorem forall_mem_singleton {p : \u03b1 \u2192 Prop} {a : \u03b1} : (\u2200 x \u2208 [a], p x) \u2194 p a :=\nby simp only [mem_singleton, forall_eq]\n\ntheorem forall_mem_append {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1} :\n  (\u2200 x \u2208 l\u2081 ++ l\u2082, p x) \u2194 (\u2200 x \u2208 l\u2081, p x) \u2227 (\u2200 x \u2208 l\u2082, p x) :=\nby simp only [mem_append, or_imp_distrib, forall_and_distrib]\n\ntheorem not_exists_mem_nil (p : \u03b1 \u2192 Prop) : \u00ac \u2203 x \u2208 @nil \u03b1, p x.\n\ntheorem exists_mem_cons_of {p : \u03b1 \u2192 Prop} {a : \u03b1} (l : list \u03b1) (h : p a) :\n  \u2203 x \u2208 a :: l, p x :=\nbex.intro a (mem_cons_self _ _) h\n\ntheorem exists_mem_cons_of_exists {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1} (h : \u2203 x \u2208 l, p x) :\n  \u2203 x \u2208 a :: l, p x :=\nbex.elim h (\u03bb x xl px, bex.intro x (mem_cons_of_mem _ xl) px)\n\ntheorem or_exists_of_exists_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1} (h : \u2203 x \u2208 a :: l, p x) :\n  p a \u2228 \u2203 x \u2208 l, p x :=\nbex.elim h (\u03bb x xal px,\n  or.elim (eq_or_mem_of_mem_cons xal)\n    (assume : x = a, begin rw \u2190this, left, exact px end)\n    (assume : x \u2208 l, or.inr (bex.intro x this px)))\n\ntheorem exists_mem_cons_iff (p : \u03b1 \u2192 Prop) (a : \u03b1) (l : list \u03b1) :\n  (\u2203 x \u2208 a :: l, p x) \u2194 p a \u2228 \u2203 x \u2208 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\u2081 l\u2082 : list \u03b1} : l\u2081 \u2286 l\u2082 \u2194 \u2200 \u2983a : \u03b1\u2984, a \u2208 l\u2081 \u2192 a \u2208 l\u2082 := iff.rfl\n\ntheorem subset_append_of_subset_left (l l\u2081 l\u2082 : list \u03b1) : l \u2286 l\u2081 \u2192 l \u2286 l\u2081++l\u2082 :=\n\u03bb s, subset.trans s $ subset_append_left _ _\n\ntheorem subset_append_of_subset_right (l l\u2081 l\u2082 : list \u03b1) : l \u2286 l\u2082 \u2192 l \u2286 l\u2081++l\u2082 :=\n\u03bb s, subset.trans s $ subset_append_right _ _\n\n@[simp] theorem cons_subset {a : \u03b1} {l m : list \u03b1} :\n  a::l \u2286 m \u2194 a \u2208 m \u2227 l \u2286 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 : \u03b1} {l m : list \u03b1}\n  (ainm : a \u2208 m) (lsubm : l \u2286 m) : a::l \u2286 m :=\ncons_subset.2 \u27e8ainm, lsubm\u27e9\n\ntheorem append_subset_of_subset_of_subset {l\u2081 l\u2082 l : list \u03b1} (l\u2081subl : l\u2081 \u2286 l) (l\u2082subl : l\u2082 \u2286 l) :\n  l\u2081 ++ l\u2082 \u2286 l :=\n\u03bb a h, (mem_append.1 h).elim (@l\u2081subl _) (@l\u2082subl _)\n\n@[simp] theorem append_subset_iff {l\u2081 l\u2082 l : list \u03b1} :\n  l\u2081 ++ l\u2082 \u2286 l \u2194 l\u2081 \u2286 l \u2227 l\u2082 \u2286 l :=\nbegin\n  split,\n  { intro h, simp only [subset_def] at *, split; intros; simp* },\n  { rintro \u27e8h1, h2\u27e9, apply append_subset_of_subset_of_subset h1 h2 }\nend\n\ntheorem eq_nil_of_subset_nil : \u2200 {l : list \u03b1}, l \u2286 [] \u2192 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 \u03b1} : l = [] \u2194 \u2200 a, a \u2209 l :=\nshow l = [] \u2194 l \u2286 [], from \u27e8\u03bb e, e \u25b8 subset.refl _, eq_nil_of_subset_nil\u27e9\n\ntheorem map_subset {l\u2081 l\u2082 : list \u03b1} (f : \u03b1 \u2192 \u03b2) (H : l\u2081 \u2286 l\u2082) : map f l\u2081 \u2286 map f l\u2082 :=\n\u03bb x, by simp only [mem_map, not_and, exists_imp_distrib, and_imp]; exact \u03bb a h e, \u27e8a, H h, e\u27e9\n\ntheorem map_subset_iff {l\u2081 l\u2082 : list \u03b1} (f : \u03b1 \u2192 \u03b2) (h : injective f) :\n  map f l\u2081 \u2286 map f l\u2082 \u2194 l\u2081 \u2286 l\u2082 :=\nbegin\n  refine \u27e8_, map_subset f\u27e9, intros h2 x hx,\n  rcases mem_map.1 (h2 (mem_map_of_mem f hx)) with \u27e8x', hx', hxx'\u27e9,\n  cases h hxx', exact hx'\nend\n\n/-! ### append -/\n\nlemma append_eq_has_append {L\u2081 L\u2082 : list \u03b1} : list.append L\u2081 L\u2082 = L\u2081 ++ L\u2082 := rfl\n\n@[simp] lemma singleton_append {x : \u03b1} {l : list \u03b1} : [x] ++ l = x :: l := rfl\n\ntheorem append_ne_nil_of_ne_nil_left (s t : list \u03b1) : s \u2260 [] \u2192 s ++ t \u2260 [] :=\nby induction s; intros; contradiction\n\ntheorem append_ne_nil_of_ne_nil_right (s t : list \u03b1) : t \u2260 [] \u2192 s ++ t \u2260 [] :=\nby induction s; intros; contradiction\n\n@[simp] lemma append_eq_nil {p q : list \u03b1} : (p ++ q) = [] \u2194 p = [] \u2227 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 \u03b1} : [] = a ++ b \u2194 a = [] \u2227 b = [] :=\nby rw [eq_comm, append_eq_nil]\n\nlemma append_eq_cons_iff {a b c : list \u03b1} {x : \u03b1} :\n  a ++ b = x :: c \u2194 (a = [] \u2227 b = x :: c) \u2228 (\u2203a', a = x :: a' \u2227 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 \u03b1} {x : \u03b1} :\n  (x :: c : list \u03b1) = a ++ b \u2194 (a = [] \u2227 b = x :: c) \u2228 (\u2203a', a = x :: a' \u2227 c = a' ++ b) :=\nby rw [eq_comm, append_eq_cons_iff]\n\nlemma append_eq_append_iff {a b c d : list \u03b1} :\n  a ++ b = c ++ d \u2194 (\u2203a', c = a ++ a' \u2227 b = a' ++ d) \u2228 (\u2203c', a = c ++ c' \u2227 d = c' ++ b) :=\nbegin\n  induction a generalizing c,\n  case nil { rw nil_append, split,\n    { rintro rfl, left, exact \u27e8_, rfl, rfl\u27e9 },\n    { rintro (\u27e8a', rfl, rfl\u27e9 | \u27e8a', H, rfl\u27e9), {refl}, {rw [\u2190 append_assoc, \u2190 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 : \u2200 (n : \u2115) (l : list \u03b1), 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 : \u2200 (n : \u2115) (l : list \u03b1), 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  \u2200 {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1}, s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082 \u2192 length s\u2081 = length s\u2082 \u2192 s\u2081 = s\u2082 \u2227 t\u2081 = t\u2082\n| []      []      t\u2081 t\u2082 h hl := \u27e8rfl, h\u27e9\n| (a::s\u2081) []      t\u2081 t\u2082 h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl\n| []      (b::s\u2082) t\u2081 t\u2082 h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl.symm\n| (a::s\u2081) (b::s\u2082) t\u2081 t\u2082 h hl := list.no_confusion h $ \u03bbab hap,\n  let \u27e8e1, e2\u27e9 := @append_inj s\u2081 s\u2082 t\u2081 t\u2082 hap (succ.inj hl) in\n  by rw [ab, e1, e2]; exact \u27e8rfl, rfl\u27e9\n\ntheorem append_inj_right {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082)\n  (hl : length s\u2081 = length s\u2082) : t\u2081 = t\u2082 :=\n(append_inj h hl).right\n\ntheorem append_inj_left {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082)\n  (hl : length s\u2081 = length s\u2082) : s\u2081 = s\u2082 :=\n(append_inj h hl).left\n\ntheorem append_inj' {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082) (hl : length t\u2081 = length t\u2082) :\n  s\u2081 = s\u2082 \u2227 t\u2081 = t\u2082 :=\nappend_inj h $ @nat.add_right_cancel _ (length t\u2081) _ $\nlet hap := congr_arg length h in by simp only [length_append] at hap; rwa [\u2190 hl] at hap\n\ntheorem append_inj_right' {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082)\n  (hl : length t\u2081 = length t\u2082) : t\u2081 = t\u2082 :=\n(append_inj' h hl).right\n\ntheorem append_inj_left' {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082)\n  (hl : length t\u2081 = length t\u2082) : s\u2081 = s\u2082 :=\n(append_inj' h hl).left\n\ntheorem append_left_cancel {s t\u2081 t\u2082 : list \u03b1} (h : s ++ t\u2081 = s ++ t\u2082) : t\u2081 = t\u2082 :=\nappend_inj_right h rfl\n\ntheorem append_right_cancel {s\u2081 s\u2082 t : list \u03b1} (h : s\u2081 ++ t = s\u2082 ++ t) : s\u2081 = s\u2082 :=\nappend_inj_left' h rfl\n\ntheorem append_right_injective (s : list \u03b1) : function.injective (\u03bb t, s ++ t) :=\n\u03bb t\u2081 t\u2082, append_left_cancel\n\ntheorem append_right_inj {t\u2081 t\u2082 : list \u03b1} (s) : s ++ t\u2081 = s ++ t\u2082 \u2194 t\u2081 = t\u2082 :=\n(append_right_injective s).eq_iff\n\ntheorem append_left_injective (t : list \u03b1) : function.injective (\u03bb s, s ++ t) :=\n\u03bb s\u2081 s\u2082, append_right_cancel\n\ntheorem append_left_inj {s\u2081 s\u2082 : list \u03b1} (t) : s\u2081 ++ t = s\u2082 ++ t \u2194 s\u2081 = s\u2082 :=\n(append_left_injective t).eq_iff\n\ntheorem map_eq_append_split {f : \u03b1 \u2192 \u03b2} {l : list \u03b1} {s\u2081 s\u2082 : list \u03b2}\n  (h : map f l = s\u2081 ++ s\u2082) : \u2203 l\u2081 l\u2082, l = l\u2081 ++ l\u2082 \u2227 map f l\u2081 = s\u2081 \u2227 map f l\u2082 = s\u2082 :=\nbegin\n  have := h, rw [\u2190 take_append_drop (length s\u2081) l] at this \u22a2,\n  rw map_append at this,\n  refine \u27e8_, _, rfl, append_inj this _\u27e9,\n  rw [length_map, length_take, min_eq_left],\n  rw [\u2190 length_map f l, h, length_append],\n  apply nat.le_add_right\nend\n\n/-! ### repeat -/\n\n@[simp] theorem repeat_succ (a : \u03b1) (n) : repeat a (n + 1) = a :: repeat a n := rfl\n\ntheorem mem_repeat {a b : \u03b1} : \u2200 {n}, b \u2208 repeat a n \u2194 n \u2260 0 \u2227 b = a\n| 0 := by simp\n| (n + 1) := by simp [mem_repeat]\n\ntheorem eq_of_mem_repeat {a b : \u03b1} {n} (h :  b \u2208 repeat a n) : b = a :=\n(mem_repeat.1 h).2\n\ntheorem eq_repeat_of_mem {a : \u03b1} : \u2200 {l : list \u03b1}, (\u2200 b \u2208 l, b = a) \u2192 l = repeat a l.length\n| []     H := rfl\n| (b::l) H := by cases forall_mem_cons.1 H with H\u2081 H\u2082;\n  unfold length repeat; congr; [exact H\u2081, exact eq_repeat_of_mem H\u2082]\n\ntheorem eq_repeat' {a : \u03b1} {l : list \u03b1} : l = repeat a l.length \u2194 \u2200 b \u2208 l, b = a :=\n\u27e8\u03bb h, h.symm \u25b8 \u03bb b, eq_of_mem_repeat, eq_repeat_of_mem\u27e9\n\ntheorem eq_repeat {a : \u03b1} {n} {l : list \u03b1} : l = repeat a n \u2194 length l = n \u2227 \u2200 b \u2208 l, b = a :=\n\u27e8\u03bb h, h.symm \u25b8 \u27e8length_repeat _ _, \u03bb b, eq_of_mem_repeat\u27e9,\n \u03bb \u27e8e, al\u27e9, e \u25b8 eq_repeat_of_mem al\u27e9\n\ntheorem repeat_add (a : \u03b1) (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 : \u03b1) (n) : repeat a n \u2286 [a] :=\n\u03bb b h, mem_singleton.2 (eq_of_mem_repeat h)\n\n@[simp] theorem map_const (l : list \u03b1) (b : \u03b2) : map (function.const \u03b1 b) l = repeat b l.length :=\nby induction l; [refl, simp only [*, map]]; split; refl\n\ntheorem eq_of_mem_map_const {b\u2081 b\u2082 : \u03b2} {l : list \u03b1} (h : b\u2081 \u2208 map (function.const \u03b1 b\u2082) l) :\n  b\u2081 = b\u2082 :=\nby rw map_const at h; exact eq_of_mem_repeat h\n\n@[simp] theorem map_repeat (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (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 : \u03b1) (n) : tail (repeat a n) = repeat a n.pred :=\nby cases n; refl\n\n@[simp] theorem join_repeat_nil (n : \u2115) : join (repeat [] n) = @nil \u03b1 :=\nby induction n; [refl, simp only [*, repeat, join, append_nil]]\n\nlemma repeat_left_injective {n : \u2115} (hn : n \u2260 0) :\n  function.injective (\u03bb a : \u03b1, repeat a n) :=\n\u03bb a b h, (eq_repeat.1 h).2 _ $ mem_repeat.2 \u27e8hn, rfl\u27e9\n\nlemma repeat_left_inj {a b : \u03b1} {n : \u2115} (hn : n \u2260 0) :\n  repeat a n = repeat b n \u2194 a = b :=\n(repeat_left_injective hn).eq_iff\n\n@[simp] lemma repeat_left_inj' {a b : \u03b1} :\n  \u2200 {n}, repeat a n = repeat b n \u2194 n = 0 \u2228 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 : \u03b1) : function.injective (repeat a) :=\nfunction.left_inverse.injective (length_repeat a)\n\n@[simp] lemma repeat_right_inj {a : \u03b1} {n m : \u2115} :\n  repeat a n = repeat a m \u2194 n = m :=\n(repeat_right_injective a).eq_iff\n\n/-! ### pure -/\n\n@[simp] theorem mem_pure {\u03b1} (x y : \u03b1) :\n  x \u2208 (pure y : list \u03b1) \u2194 x = y := by simp! [pure,list.ret]\n\n/-! ### bind -/\n\n@[simp] theorem bind_eq_bind {\u03b1 \u03b2} (f : \u03b1 \u2192 list \u03b2) (l : list \u03b1) :\n  l >>= f = l.bind f := rfl\n\n-- TODO: duplicate of a lemma in core\ntheorem bind_append (f : \u03b1 \u2192 list \u03b2) (l\u2081 l\u2082 : list \u03b1) :\n  (l\u2081 ++ l\u2082).bind f = l\u2081.bind f ++ l\u2082.bind f :=\nappend_bind _ _ _\n\n@[simp] theorem bind_singleton (f : \u03b1 \u2192 list \u03b2) (x : \u03b1) : [x].bind f = f x :=\nappend_nil (f x)\n\n/-! ### concat -/\n\ntheorem concat_nil (a : \u03b1) : concat [] a = [a] := rfl\n\ntheorem concat_cons (a b : \u03b1) (l : list \u03b1) : concat (a :: l) b = a :: concat l b := rfl\n\n@[simp] theorem concat_eq_append (a : \u03b1) (l : list \u03b1) : concat l a = l ++ [a] :=\nby induction l; simp only [*, concat]; split; refl\n\ntheorem init_eq_of_concat_eq {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} : concat l\u2081 a = concat l\u2082 a \u2192 l\u2081 = l\u2082 :=\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 : \u03b1} {l : list \u03b1} : concat l a = concat l b \u2192 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 : \u03b1) (l : list \u03b1) : concat l a \u2260 [] :=\nby simp\n\ntheorem concat_append (a : \u03b1) (l\u2081 l\u2082 : list \u03b1) : concat l\u2081 a ++ l\u2082 = l\u2081 ++ a :: l\u2082 :=\nby simp\n\ntheorem length_concat (a : \u03b1) (l : list \u03b1) : length (concat l a) = succ (length l) :=\nby simp only [concat_eq_append, length_append, length]\n\ntheorem append_concat (a : \u03b1) (l\u2081 l\u2082 : list \u03b1) : l\u2081 ++ concat l\u2082 a = concat (l\u2081 ++ l\u2082) a :=\nby simp\n\n/-! ### reverse -/\n\n@[simp] theorem reverse_nil : reverse (@nil \u03b1) = [] := rfl\n\nlocal attribute [simp] reverse_core\n\n@[simp] theorem reverse_cons (a : \u03b1) (l : list \u03b1) : reverse (a::l) = reverse l ++ [a] :=\nhave aux : \u2200 l\u2081 l\u2082, reverse_core l\u2081 l\u2082 ++ [a] = reverse_core l\u2081 (l\u2082 ++ [a]),\nby intro l\u2081; induction l\u2081; intros; [refl, simp only [*, reverse_core, cons_append]],\n(aux l nil).symm\n\ntheorem reverse_core_eq (l\u2081 l\u2082 : list \u03b1) : reverse_core l\u2081 l\u2082 = reverse l\u2081 ++ l\u2082 :=\nby induction l\u2081 generalizing l\u2082; [refl, simp only [*, reverse_core, reverse_cons, append_assoc]];\n  refl\n\ntheorem reverse_cons' (a : \u03b1) (l : list \u03b1) : reverse (a::l) = concat (reverse l) a :=\nby simp only [reverse_cons, concat_eq_append]\n\n@[simp] theorem reverse_singleton (a : \u03b1) : reverse [a] = [a] := rfl\n\n@[simp] theorem reverse_append (s t : list \u03b1) : 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 \u03b1) (a : \u03b1) : 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 \u03b1) : reverse (reverse l) = l :=\nby induction l; [refl, simp only [*, reverse_cons, reverse_append]]; refl\n\n@[simp] theorem reverse_involutive : involutive (@reverse \u03b1) :=\n\u03bb l, reverse_reverse l\n\n@[simp] theorem reverse_injective : injective (@reverse \u03b1) :=\nreverse_involutive.injective\n\n@[simp] theorem reverse_inj {l\u2081 l\u2082 : list \u03b1} : reverse l\u2081 = reverse l\u2082 \u2194 l\u2081 = l\u2082 :=\nreverse_injective.eq_iff\n\nlemma reverse_eq_iff {l l' : list \u03b1} :\n  l.reverse = l' \u2194 l = l'.reverse :=\nreverse_involutive.eq_iff\n\n@[simp] theorem reverse_eq_nil {l : list \u03b1} : reverse l = [] \u2194 l = [] :=\n@reverse_inj _ l []\n\ntheorem concat_eq_reverse_cons (a : \u03b1) (l : list \u03b1) : 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 \u03b1) : length (reverse l) = length l :=\nby induction l; [refl, simp only [*, reverse_cons, length_append, length]]\n\n@[simp] theorem map_reverse (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) : 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 : \u03b1 \u2192 \u03b2) (l\u2081 l\u2082 : list \u03b1) :\n  map f (reverse_core l\u2081 l\u2082) = reverse_core (map f l\u2081) (map f l\u2082) :=\nby simp only [reverse_core_eq, map_append, map_reverse]\n\n@[simp] theorem mem_reverse {a : \u03b1} {l : list \u03b1} : a \u2208 reverse l \u2194 a \u2208 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 : \u03b1) (n) : reverse (repeat a n) = repeat a n :=\neq_repeat.2 \u27e8by simp only [length_reverse, length_repeat],\n  \u03bb b h, eq_of_mem_repeat (mem_reverse.1 h)\u27e9\n\n/-! ### empty -/\n\nattribute [simp] list.empty\n\nlemma empty_iff_eq_nil {l : list \u03b1} : l.empty \u2194 l = [] :=\nlist.cases_on l (by simp) (by simp)\n\n/-! ### init -/\n\n@[simp] theorem length_init : \u2200 (l : list \u03b1), 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 : \u03b1} {l : list \u03b1} :\n  \u2200 (h\u2081 : a :: l \u2260 nil) (h\u2082 : l \u2260 nil), last (a :: l) h\u2081 = last l h\u2082 :=\nby {induction l; intros, contradiction, reflexivity}\n\n@[simp] theorem last_append {a : \u03b1} (l : list \u03b1) (h : l ++ [a] \u2260 []) : last (l ++ [a]) h = a :=\nby induction l;\n  [refl, simp only [cons_append, last_cons _ (\u03bb H, cons_ne_nil _ _ (append_eq_nil.1 H).2), *]]\n\ntheorem last_concat {a : \u03b1} (l : list \u03b1) (h : concat l a \u2260 []) : last (concat l a) h = a :=\nby simp only [concat_eq_append, last_append]\n\n@[simp] theorem last_singleton (a : \u03b1) (h : [a] \u2260 []) : last [a] h = a := rfl\n\n@[simp] theorem last_cons_cons (a\u2081 a\u2082 : \u03b1) (l : list \u03b1) (h : a\u2081::a\u2082::l \u2260 []) :\n  last (a\u2081::a\u2082::l) h = last (a\u2082::l) (cons_ne_nil a\u2082 l) := rfl\n\ntheorem init_append_last : \u2200 {l : list \u03b1} (h : l \u2260 []), 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\u2081 l\u2082 : list \u03b1} (h\u2081 : l\u2081 \u2260 []) (h\u2082 : l\u2082 \u2260 []) (h\u2083 : l\u2081 = l\u2082) :\n  last l\u2081 h\u2081 = last l\u2082 h\u2082 :=\nby subst l\u2081\n\ntheorem last_mem : \u2200 {l : list \u03b1} (h : l \u2260 []), last l h \u2208 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 : \u2115) :\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  \u2200 {l : list \u03b1}, (last' l).is_none \u2194 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 : \u2200 {l : list \u03b1}, l.last'.is_some \u2194 l \u2260 []\n| [] := by simp\n| [a] := by simp\n| (a::b::l) := by simp [@last'_is_some (b::l)]\n\ntheorem mem_last'_eq_last : \u2200 {l : list \u03b1} {x : \u03b1}, x \u2208 l.last' \u2192 \u2203 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 \u25b8 \u27e8cons_ne_nil a [], rfl\u27e9\n| (a::b::l) x hx :=\n  begin\n    rw last' at hx,\n    rcases mem_last'_eq_last hx with \u27e8h\u2081, h\u2082\u27e9,\n    use cons_ne_nil _ _,\n    rwa [last_cons]\n  end\n\ntheorem mem_of_mem_last' {l : list \u03b1} {a : \u03b1} (ha : a \u2208 l.last') : a \u2208 l :=\nlet \u27e8h\u2081, h\u2082\u27e9 := mem_last'_eq_last ha in h\u2082.symm \u25b8 last_mem _\n\ntheorem init_append_last' : \u2200 {l : list \u03b1} (a \u2208 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 \u03b1] : \u2200 l : list \u03b1, 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 : \u2200 (l\u2081 : list \u03b1) (a : \u03b1) (l\u2082 : list \u03b1),\n  last' (l\u2081 ++ a :: l\u2082) = last' (a :: l\u2082)\n| [] a l\u2082 := rfl\n| [b] a l\u2082 := rfl\n| (b::c::l\u2081) a l\u2082 := by rw [cons_append, cons_append, last', \u2190 cons_append, last'_append_cons]\n\ntheorem last'_append_of_ne_nil (l\u2081 : list \u03b1) : \u2200 {l\u2082 : list \u03b1} (hl\u2082 : l\u2082 \u2260 []),\n  last' (l\u2081 ++ l\u2082) = last' l\u2082\n| [] hl\u2082 := by contradiction\n| (b::l\u2082) _ := last'_append_cons l\u2081 b l\u2082\n\n/-! ### head(') and tail -/\n\ntheorem head_eq_head' [inhabited \u03b1] (l : list \u03b1) : head l = (head' l).iget :=\nby cases l; refl\n\ntheorem mem_of_mem_head' {x : \u03b1} : \u2200 {l : list \u03b1}, x \u2208 l.head' \u2192 x \u2208 l\n| [] h := (option.not_mem_none _ h).elim\n| (a::l) h := by { simp only [head', option.mem_def] at h, exact h \u25b8 or.inl rfl }\n\n@[simp] theorem head_cons [inhabited \u03b1] (a : \u03b1) (l : list \u03b1) : head (a::l) = a := rfl\n\n@[simp] theorem tail_nil : tail (@nil \u03b1) = [] := rfl\n\n@[simp] theorem tail_cons (a : \u03b1) (l : list \u03b1) : tail (a::l) = l := rfl\n\n@[simp] theorem head_append [inhabited \u03b1] (t : list \u03b1) {s : list \u03b1} (h : s \u2260 []) :\n  head (s ++ t) = head s :=\nby {induction s, contradiction, refl}\n\ntheorem tail_append_singleton_of_ne_nil {a : \u03b1} {l : list \u03b1} (h : l \u2260 nil) :\n  tail (l ++ [a]) = tail l ++ [a] :=\nby { induction l,  contradiction, rw [tail,cons_append,tail], }\n\ntheorem cons_head'_tail : \u2200 {l : list \u03b1} {a : \u03b1} (h : a \u2208 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 \u03b1] : \u2200 {l : list \u03b1} (h : l \u2260 []), head l \u2208 head' l\n| [] h := by contradiction\n| (a::l) h := rfl\n\ntheorem cons_head_tail [inhabited \u03b1] {l : list \u03b1} (h : l \u2260 []) : (head l)::(tail l) = l :=\ncons_head'_tail (head_mem_head' h)\n\nlemma head_mem_self [inhabited \u03b1] {l : list \u03b1} (h : l \u2260 nil) : l.head \u2208 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 : \u03b1 \u2192 \u03b2) (l) : head' (map f l) = (head' l).map f := by cases l; refl\n\nlemma tail_append_of_ne_nil (l l' : list \u03b1) (h : l \u2260 []) :\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 \u03b1 \u2192 Sort*}\n  (l : list \u03b1) (H0 : C [])\n  (H1 : \u2200 (l : list \u03b1) (a : \u03b1), C l \u2192 C (l ++ [a])) : C l :=\nbegin\n  rw \u2190 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 \u03b1 \u2192 Sort*}\n    (H0 : C []) (H1 : \u2200 (a : \u03b1), C [a])\n    (Hn : \u2200 (a : \u03b1) (l : list \u03b1) (b : \u03b1), C l \u2192 C (a :: (l ++ [b]))) : \u2200 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 \u2190init_append_last (cons_ne_nil b l),\n  have : C l', from bidirectional_rec l',\n  exact Hn a l' b' \u2039C l'\u203a\nend\nusing_well_founded { rel_tac := \u03bb _ _, `[exact \u27e8_, measure_wf list.length\u27e9] }\n\n/-- Like `bidirectional_rec`, but with the list parameter placed first. -/\n@[elab_as_eliminator] def bidirectional_rec_on {C : list \u03b1 \u2192 Sort*}\n    (l : list \u03b1) (H0 : C []) (H1 : \u2200 (a : \u03b1), C [a])\n    (Hn : \u2200 (a : \u03b1) (l : list \u03b1) (b : \u03b1), C l \u2192 C (a :: (l ++ [b]))) : C l :=\nbidirectional_rec H0 H1 Hn l\n\n/-! ### sublists -/\n\n@[simp] theorem nil_sublist : \u03a0 (l : list \u03b1), [] <+ l\n| []       := sublist.slnil\n| (a :: l) := sublist.cons _ _ a (nil_sublist l)\n\n@[refl, simp] theorem sublist.refl : \u03a0 (l : list \u03b1), l <+ l\n| []       := sublist.slnil\n| (a :: l) := sublist.cons2 _ _ a (sublist.refl l)\n\n@[trans] theorem sublist.trans {l\u2081 l\u2082 l\u2083 : list \u03b1} (h\u2081 : l\u2081 <+ l\u2082) (h\u2082 : l\u2082 <+ l\u2083) : l\u2081 <+ l\u2083 :=\nsublist.rec_on h\u2082 (\u03bb_ s, s)\n  (\u03bbl\u2082 l\u2083 a h\u2082 IH l\u2081 h\u2081, sublist.cons _ _ _ (IH l\u2081 h\u2081))\n  (\u03bbl\u2082 l\u2083 a h\u2082 IH l\u2081 h\u2081, @sublist.cases_on _ (\u03bbl\u2081 l\u2082', l\u2082' = a :: l\u2082 \u2192 l\u2081 <+ a :: l\u2083) _ _ h\u2081\n    (\u03bb_, nil_sublist _)\n    (\u03bbl\u2081 l\u2082' a' h\u2081' e, match a', l\u2082', e, h\u2081' with ._, ._, rfl, h\u2081 :=\n      sublist.cons _ _ _ (IH _ h\u2081) end)\n    (\u03bbl\u2081 l\u2082' a' h\u2081' e, match a', l\u2082', e, h\u2081' with ._, ._, rfl, h\u2081 :=\n      sublist.cons2 _ _ _ (IH _ h\u2081) end) rfl)\n  l\u2081 h\u2081\n\n@[simp] theorem sublist_cons (a : \u03b1) (l : list \u03b1) : l <+ a::l :=\nsublist.cons _ _ _ (sublist.refl l)\n\ntheorem sublist_of_cons_sublist {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} : a::l\u2081 <+ l\u2082 \u2192 l\u2081 <+ l\u2082 :=\nsublist.trans (sublist_cons a l\u2081)\n\ntheorem cons_sublist_cons {l\u2081 l\u2082 : list \u03b1} (a : \u03b1) (s : l\u2081 <+ l\u2082) : a::l\u2081 <+ a::l\u2082 :=\nsublist.cons2 _ _ _ s\n\n@[simp] theorem sublist_append_left : \u03a0 (l\u2081 l\u2082 : list \u03b1), l\u2081 <+ l\u2081++l\u2082\n| []      l\u2082 := nil_sublist _\n| (a::l\u2081) l\u2082 := cons_sublist_cons _ (sublist_append_left l\u2081 l\u2082)\n\n@[simp] theorem sublist_append_right : \u03a0 (l\u2081 l\u2082 : list \u03b1), l\u2082 <+ l\u2081++l\u2082\n| []      l\u2082 := sublist.refl _\n| (a::l\u2081) l\u2082 := sublist.cons _ _ _ (sublist_append_right l\u2081 l\u2082)\n\ntheorem sublist_cons_of_sublist (a : \u03b1) {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+ l\u2082 \u2192 l\u2081 <+ a::l\u2082 :=\nsublist.cons _ _ _\n\ntheorem sublist_append_of_sublist_left {l l\u2081 l\u2082 : list \u03b1} (s : l <+ l\u2081) : l <+ l\u2081++l\u2082 :=\ns.trans $ sublist_append_left _ _\n\ntheorem sublist_append_of_sublist_right {l l\u2081 l\u2082 : list \u03b1} (s : l <+ l\u2082) : l <+ l\u2081++l\u2082 :=\ns.trans $ sublist_append_right _ _\n\ntheorem sublist_of_cons_sublist_cons {l\u2081 l\u2082 : list \u03b1} : \u2200 {a : \u03b1}, a::l\u2081 <+ a::l\u2082 \u2192 l\u2081 <+ l\u2082\n| ._ (sublist.cons  ._ ._ a s) := sublist_of_cons_sublist s\n| ._ (sublist.cons2 ._ ._ a s) := s\n\ntheorem cons_sublist_cons_iff {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a::l\u2081 <+ a::l\u2082 \u2194 l\u2081 <+ l\u2082 :=\n\u27e8sublist_of_cons_sublist_cons, cons_sublist_cons _\u27e9\n\n@[simp] theorem append_sublist_append_left {l\u2081 l\u2082 : list \u03b1} : \u2200 l, l++l\u2081 <+ l++l\u2082 \u2194 l\u2081 <+ l\u2082\n| []     := iff.rfl\n| (a::l) := cons_sublist_cons_iff.trans (append_sublist_append_left l)\n\ntheorem sublist.append_right {l\u2081 l\u2082 : list \u03b1} (h : l\u2081 <+ l\u2082) (l) : l\u2081++l <+ l\u2082++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\u2081 l\u2082 : list \u03b1} {a : \u03b1} (h : l <+ l\u2081 ++ a::l\u2082) :\n  l <+ l\u2081 ++ l\u2082 \u2228 a \u2208 l :=\nbegin\n  induction l\u2081 with b l\u2081 IH generalizing l,\n  { cases h, { left, exact \u2039l <+ l\u2082\u203a }, { 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\u2081 l\u2082 : list \u03b1} (h : l\u2081 <+ l\u2082) : l\u2081.reverse <+ l\u2082.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\u2081 l\u2082 : list \u03b1} : l\u2081.reverse <+ l\u2082.reverse \u2194 l\u2081 <+ l\u2082 :=\n\u27e8\u03bb h, l\u2081.reverse_reverse \u25b8 l\u2082.reverse_reverse \u25b8 h.reverse, sublist.reverse\u27e9\n\n@[simp] theorem append_sublist_append_right {l\u2081 l\u2082 : list \u03b1} (l) : l\u2081++l <+ l\u2082++l \u2194 l\u2081 <+ l\u2082 :=\n\u27e8\u03bb h, by simpa only [reverse_append, append_sublist_append_left, reverse_sublist_iff]\n  using h.reverse,\n \u03bb h, h.append_right l\u27e9\n\ntheorem sublist.append {l\u2081 l\u2082 r\u2081 r\u2082 : list \u03b1}\n  (hl : l\u2081 <+ l\u2082) (hr : r\u2081 <+ r\u2082) : l\u2081 ++ r\u2081 <+ l\u2082 ++ r\u2082 :=\n(hl.append_right _).trans ((append_sublist_append_left _).2 hr)\n\ntheorem sublist.subset : \u03a0 {l\u2081 l\u2082 : list \u03b1}, l\u2081 <+ l\u2082 \u2192 l\u2081 \u2286 l\u2082\n| ._ ._ sublist.slnil             b h := h\n| ._ ._ (sublist.cons  l\u2081 l\u2082 a s) b h := mem_cons_of_mem _ (sublist.subset s h)\n| ._ ._ (sublist.cons2 l\u2081 l\u2082 a s) b h :=\n  match eq_or_mem_of_mem_cons h with\n  | or.inl h := h \u25b8 mem_cons_self _ _\n  | or.inr h := mem_cons_of_mem _ (sublist.subset s h)\n  end\n\ntheorem singleton_sublist {a : \u03b1} {l} : [a] <+ l \u2194 a \u2208 l :=\n\u27e8\u03bb h, h.subset (mem_singleton_self _), \u03bb h,\nlet \u27e8s, t, e\u27e9 := mem_split h in e.symm \u25b8\n  (cons_sublist_cons _ (nil_sublist _)).trans (sublist_append_right _ _)\u27e9\n\ntheorem eq_nil_of_sublist_nil {l : list \u03b1} (s : l <+ []) : l = [] :=\neq_nil_of_subset_nil $ s.subset\n\ntheorem repeat_sublist_repeat (a : \u03b1) {m n} : repeat a m <+ repeat a n \u2194 m \u2264 n :=\n\u27e8\u03bb h, by simpa only [length_repeat] using length_le_of_sublist h,\n \u03bb h, by induction h; [refl, simp only [*, repeat_succ, sublist.cons]] \u27e9\n\ntheorem eq_of_sublist_of_length_eq : \u2200 {l\u2081 l\u2082 : list \u03b1}, l\u2081 <+ l\u2082 \u2192 length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082\n| ._ ._ sublist.slnil             h := rfl\n| ._ ._ (sublist.cons  l\u2081 l\u2082 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\u2081 l\u2082 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\u2081 l\u2082 : list \u03b1} (s : l\u2081 <+ l\u2082) (h : length l\u2082 \u2264 length l\u2081) :\n  l\u2081 = l\u2082 :=\neq_of_sublist_of_length_eq s (le_antisymm (length_le_of_sublist s) h)\n\ntheorem sublist.antisymm {l\u2081 l\u2082 : list \u03b1} (s\u2081 : l\u2081 <+ l\u2082) (s\u2082 : l\u2082 <+ l\u2081) : l\u2081 = l\u2082 :=\neq_of_sublist_of_length_le s\u2081 (length_le_of_sublist s\u2082)\n\ninstance decidable_sublist [decidable_eq \u03b1] : \u2200 (l\u2081 l\u2082 : list \u03b1), decidable (l\u2081 <+ l\u2082)\n| []      l\u2082      := is_true $ nil_sublist _\n| (a::l\u2081) []      := is_false $ \u03bbh, list.no_confusion $ eq_nil_of_sublist_nil h\n| (a::l\u2081) (b::l\u2082) :=\n  if h : a = b then\n    decidable_of_decidable_of_iff (decidable_sublist l\u2081 l\u2082) $\n      by rw [\u2190 h]; exact \u27e8cons_sublist_cons _, sublist_of_cons_sublist_cons\u27e9\n  else decidable_of_decidable_of_iff (decidable_sublist (a::l\u2081) l\u2082)\n    \u27e8sublist_cons_of_sublist _, \u03bbs, match a, l\u2081, s, h with\n    | a, l\u2081, sublist.cons ._ ._ ._ s', h := s'\n    | ._, ._, sublist.cons2 t ._ ._ s', h := absurd rfl h\n    end\u27e9\n\n/-! ### index_of -/\n\nsection index_of\nvariable [decidable_eq \u03b1]\n\n@[simp] theorem index_of_nil (a : \u03b1) : index_of a [] = 0 := rfl\n\ntheorem index_of_cons (a b : \u03b1) (l : list \u03b1) :\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 : \u03b1} (l : list \u03b1) : a = b \u2192 index_of a (b::l) = 0 :=\nassume e, if_pos e\n\n@[simp] theorem index_of_cons_self (a : \u03b1) (l : list \u03b1) : index_of a (a::l) = 0 :=\nindex_of_cons_eq _ rfl\n\n@[simp, priority 990]\ntheorem index_of_cons_ne {a b : \u03b1} (l : list \u03b1) : a \u2260 b \u2192 index_of a (b::l) = succ (index_of a l) :=\nassume n, if_neg n\n\ntheorem index_of_eq_length {a : \u03b1} {l : list \u03b1} : index_of a l = length l \u2194 a \u2209 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 \u27e8\u27e9) (\u03bb H, H $ or.inl h) },\n  { simp only [h, false_or], rw \u2190 ih, exact succ_inj' }\nend\n\n@[simp, priority 980]\ntheorem index_of_of_not_mem {l : list \u03b1} {a : \u03b1} : a \u2209 l \u2192 index_of a l = length l :=\nindex_of_eq_length.2\n\ntheorem index_of_le_length {a : \u03b1} {l : list \u03b1} : index_of a l \u2264 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 \u03b1} : index_of a l < length l \u2194 a \u2208 l :=\n\u27e8\u03bbh, decidable.by_contradiction $ \u03bb al, ne_of_lt h $ index_of_eq_length.2 al,\n\u03bbal, lt_of_le_of_ne index_of_le_length $ \u03bb h, index_of_eq_length.1 h al\u27e9\n\nend index_of\n\n/-! ### nth element -/\n\ntheorem nth_le_of_mem : \u2200 {a} {l : list \u03b1}, a \u2208 l \u2192 \u2203 n h, nth_le l n h = a\n| a (_ :: l) (or.inl rfl) := \u27e80, succ_pos _, rfl\u27e9\n| a (b :: l) (or.inr m)   :=\n  let \u27e8n, h, e\u27e9 := nth_le_of_mem m in \u27e8n+1, succ_lt_succ h, e\u27e9\n\ntheorem nth_le_nth : \u2200 {l : list \u03b1} {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 : \u2200 {l : list \u03b1} {n}, length l \u2264 n \u2192 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 \u03b1} {n a} : nth l n = some a \u2194 \u2203 h, nth_le l n h = a :=\n\u27e8\u03bb e,\n  have h : n < length l, from lt_of_not_ge $ \u03bb hn,\n    by rw nth_len_le hn at e; contradiction,\n  \u27e8h, by rw nth_le_nth h at e;\n    injection e with e; apply nth_le_mem\u27e9,\n\u03bb \u27e8h, e\u27e9, e \u25b8 nth_le_nth _\u27e9\n\n@[simp]\ntheorem nth_eq_none_iff : \u2200 {l : list \u03b1} {n}, nth l n = none \u2194 length l \u2264 n :=\nbegin\n  intros, split,\n  { intro h, by_contradiction h',\n    have h\u2082 : \u2203 h, l.nth_le n h = l.nth_le n (lt_of_not_ge h') := \u27e8lt_of_not_ge h', rfl\u27e9,\n    rw [\u2190 nth_eq_some, h] at h\u2082, cases h\u2082 },\n  { solve_by_elim [nth_len_le] },\nend\n\ntheorem nth_of_mem {a} {l : list \u03b1} (h : a \u2208 l) : \u2203 n, nth l n = some a :=\nlet \u27e8n, h, e\u27e9 := nth_le_of_mem h in \u27e8n, by rw [nth_le_nth, e]\u27e9\n\ntheorem nth_le_mem : \u2200 (l : list \u03b1) n h, nth_le l n h \u2208 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 \u03b1} {n a} (e : nth l n = some a) : a \u2208 l :=\nlet \u27e8h, e\u27e9 := nth_eq_some.1 e in e \u25b8 nth_le_mem _ _ _\n\ntheorem mem_iff_nth_le {a} {l : list \u03b1} : a \u2208 l \u2194 \u2203 n h, nth_le l n h = a :=\n\u27e8nth_le_of_mem, \u03bb \u27e8n, h, e\u27e9, e \u25b8 nth_le_mem _ _ _\u27e9\n\ntheorem mem_iff_nth {a} {l : list \u03b1} : a \u2208 l \u2194 \u2203 n, nth l n = some a :=\nmem_iff_nth_le.trans $ exists_congr $ \u03bb n, nth_eq_some.symm\n\nlemma nth_zero (l : list \u03b1) : l.nth 0 = l.head' := by cases l; refl\n\nlemma nth_injective {\u03b1 : Type u} {xs : list \u03b1} {i j : \u2115}\n  (h\u2080 : i < xs.length)\n  (h\u2081 : nodup xs)\n  (h\u2082 : xs.nth i = xs.nth j) : i = j :=\nbegin\n  induction xs with x xs generalizing i j,\n  { cases h\u2080 },\n  { cases i; cases j,\n    case nat.zero nat.zero\n    { refl },\n    case nat.succ nat.succ\n    { congr, cases h\u2081,\n      apply xs_ih;\n      solve_by_elim [lt_of_succ_lt_succ] },\n    iterate 2\n    { dsimp at h\u2082,\n      cases h\u2081 with _ _ h h',\n      cases h x _ rfl,\n      rw mem_iff_nth,\n      exact \u27e8_, h\u2082.symm\u27e9 <|>\n        exact \u27e8_, h\u2082\u27e9 } },\nend\n\n@[simp] theorem nth_map (f : \u03b1 \u2192 \u03b2) : \u2200 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 : \u03b1 \u2192 \u03b2) {l n} (H1 H2) : nth_le (map f l) n H1 = f (nth_le l n H2) :=\noption.some.inj $ by rw [\u2190 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 : \u03b1 \u2192 \u03b2) {l n} (H) :\n  f (nth_le l n H) = nth_le (map f l) n ((length_map f l).symm \u25b8 H) :=\n(nth_le_map f _ _).symm\n\n@[simp] theorem nth_le_map' (f : \u03b1 \u2192 \u03b2) {l n} (H) :\n  nth_le (map f l) n H = f (nth_le l n (length_map f l \u25b8 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 \u03b1} (h : L = L') {i : \u2115} (hi : i < L.length) :\n  nth_le L i hi = nth_le L' i (h \u25b8 hi) :=\nby { congr, exact h}\n\n@[simp] lemma nth_le_singleton (a : \u03b1) {n : \u2115} (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 \u03b1] {L : list \u03b1} (h : 0 < L.length) :\n  L.nth_le 0 h = L.head :=\nby { cases L, cases h, simp, }\n\nlemma nth_le_append : \u2200 {l\u2081 l\u2082 : list \u03b1} {n : \u2115} (hn\u2081) (hn\u2082),\n  (l\u2081 ++ l\u2082).nth_le n hn\u2081 = l\u2081.nth_le n hn\u2082\n| []     _ n     hn\u2081 hn\u2082  := (not_lt_zero _ hn\u2082).elim\n| (a::l) _ 0     hn\u2081 hn\u2082 := rfl\n| (a::l) _ (n+1) hn\u2081 hn\u2082 := by simp only [nth_le, cons_append];\n                         exact nth_le_append _ _\n\nlemma nth_le_append_right_aux {l\u2081 l\u2082 : list \u03b1} {n : \u2115}\n  (h\u2081 : l\u2081.length \u2264 n) (h\u2082 : n < (l\u2081 ++ l\u2082).length) : n - l\u2081.length < l\u2082.length :=\nbegin\n  rw list.length_append at h\u2082,\n  convert (nat.sub_lt_sub_right_iff h\u2081).mpr h\u2082,\n  simp,\nend\n\nlemma nth_le_append_right : \u2200 {l\u2081 l\u2082 : list \u03b1} {n : \u2115} (h\u2081 : l\u2081.length \u2264 n) (h\u2082),\n  (l\u2081 ++ l\u2082).nth_le n h\u2082 = l\u2082.nth_le (n - l\u2081.length) (nth_le_append_right_aux h\u2081 h\u2082)\n| []       _ n     h\u2081 h\u2082 := rfl\n| (a :: l) _ (n+1) h\u2081 h\u2082 :=\n  begin\n    dsimp,\n    conv { to_rhs, congr, skip, rw [\u2190nat.sub_sub, nat.sub.right_comm, nat.add_sub_cancel], },\n    rw nth_le_append_right (nat.lt_succ_iff.mp h\u2081),\n  end\n\n@[simp] lemma nth_le_repeat (a : \u03b1) {n m : \u2115} (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\u2081 l\u2082 : list \u03b1} {n : \u2115} (hn : n < l\u2081.length) :\n  (l\u2081 ++ l\u2082).nth n = l\u2081.nth n :=\nhave hn' : n < (l\u2081 ++ l\u2082).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\u2081 l\u2082 : list \u03b1} {n : \u2115} (hn : l\u2081.length \u2264 n) :\n  (l\u2081 ++ l\u2082).nth n = l\u2082.nth (n - l\u2081.length) :=\nbegin\n  by_cases hl : n < (l\u2081 ++ l\u2082).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 : \u2200 (l : list \u03b1) (h : l \u2260 []),\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 : \u2200 (l : list \u03b1) (a : \u03b1), (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 : \u03b1) (xs : list \u03b1) (n : \u2115) (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 : \u2200 {l\u2081 l\u2082 : list \u03b1}, (\u2200n, nth l\u2081 n = nth l\u2082 n) \u2192 l\u2081 = l\u2082\n| []      []       h := rfl\n| (a::l\u2081) []       h := by have h0 := h 0; contradiction\n| []      (a'::l\u2082) h := by have h0 := h 0; contradiction\n| (a::l\u2081) (a'::l\u2082) h := by have h0 : some a = some a' := h 0; injection h0 with aa;\n    simp only [aa, ext (\u03bbn, h (n+1))]; split; refl\n\ntheorem ext_le {l\u2081 l\u2082 : list \u03b1} (hl : length l\u2081 = length l\u2082)\n  (h : \u2200n h\u2081 h\u2082, nth_le l\u2081 n h\u2081 = nth_le l\u2082 n h\u2082) : l\u2081 = l\u2082 :=\next $ \u03bbn, if h\u2081 : n < length l\u2081\n  then by rw [nth_le_nth, nth_le_nth, h n h\u2081 (by rwa [\u2190 hl])]\n  else let h\u2081 := le_of_not_gt h\u2081 in by { rw [nth_len_le h\u2081, nth_len_le], rwa [\u2190hl], }\n\n@[simp] theorem index_of_nth_le [decidable_eq \u03b1] {a : \u03b1} :\n  \u2200 {l : list \u03b1} 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 \u03b1] {a : \u03b1} {l : list \u03b1} (h : a \u2208 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  \u2200 (l r : list \u03b1) (i h1 h2), nth_le (reverse_core l r) (i + length l) h1 = nth_le r i h2\n| []       r i := \u03bbh1 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 \u03bbh1 h2, nth_le_reverse_aux1 l (a :: r) (i+1) h1 (succ_lt_succ h2)\n\nlemma index_of_inj [decidable_eq \u03b1] {l : list \u03b1} {x y : \u03b1}\n  (hx : x \u2208 l) (hy : y \u2208 l) : index_of x l = index_of y l \u2194 x = y :=\n\u27e8\u03bb 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  \u03bb h, by subst h\u27e9\n\ntheorem nth_le_reverse_aux2 : \u2200 (l r : list \u03b1) (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 [\u2190 heq] at aux,\n    apply aux\n  end\n\n@[simp] theorem nth_le_reverse (l : list \u03b1) (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 \u03b1) (n : \u2115) (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 \u03b1} (h : l.length = 1) :\n  l = [l.nth_le 0 (h.symm \u25b8 zero_lt_one)] :=\nbegin\n  refine ext_le (by convert h) (\u03bb n h\u2081 h\u2082, _),\n  simp only [nth_le_singleton],\n  congr,\n  exact eq_bot_iff.mpr (nat.lt_succ_iff.mp h\u2082)\nend\n\nlemma modify_nth_tail_modify_nth_tail {f g : list \u03b1 \u2192 list \u03b1} (m : \u2115) :\n  \u2200n (l:list \u03b1), (l.modify_nth_tail f n).modify_nth_tail g (m + n) =\n    l.modify_nth_tail (\u03bbl, (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 \u03b1 \u2192 list \u03b1} (m n : \u2115) (l : list \u03b1) (h : n \u2264 m) :\n  (l.modify_nth_tail f n).modify_nth_tail g m =\n    l.modify_nth_tail (\u03bbl, (f l).modify_nth_tail g (m - n)) n :=\nbegin\n  rcases le_iff_exists_add.1 h with \u27e8m, rfl\u27e9,\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 \u03b1 \u2192 list \u03b1} (n : \u2115) (l:list \u03b1) :\n  (l.modify_nth_tail f n).modify_nth_tail g n = l.modify_nth_tail (g \u2218 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  \u2200n (l:list \u03b1), 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 : \u2200 n (l : list \u03b1), 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 : \u03b1) : \u2200 n (l : list \u03b1),\n  update_nth l n a = modify_nth (\u03bb _, 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 : \u03b1 \u2192 \u03b1) : \u2200 n (l : list \u03b1),\n  modify_nth f n l = ((\u03bb 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 : \u03b1 \u2192 \u03b1) : \u2200 n (l : list \u03b1) m,\n  nth (modify_nth f n l) m = (\u03bb 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 \u03b1 \u2192 list \u03b1) (H : \u2200 l, length (f l) = length l) :\n  \u2200 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 : \u03b1 \u2192 \u03b1) :\n  \u2200 n l, length (modify_nth f n l) = length l :=\nmodify_nth_tail_length _ (\u03bb l, by cases l; refl)\n\n@[simp] theorem update_nth_length (l : list \u03b1) (n) (a : \u03b1) :\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 : \u03b1 \u2192 \u03b1) (n) (l : list \u03b1) :\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 : \u03b1 \u2192 \u03b1) {m n} (l : list \u03b1) (h : m \u2260 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 : \u03b1) (n) (l : list \u03b1) :\n  nth (update_nth l n a) n = (\u03bb _, a) <$> nth l n :=\nby simp only [update_nth_eq_modify_nth, nth_modify_nth_eq]\n\ntheorem nth_update_nth_of_lt (a : \u03b1) {n} {l : list \u03b1} (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 : \u03b1) {m n} (l : list \u03b1) (h : m \u2260 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 : \u2115) (a : \u03b1) : [].update_nth n a = [] := rfl\n\n@[simp] lemma update_nth_succ (x : \u03b1) (xs : list \u03b1) (n : \u2115) (a : \u03b1) :\n  (x :: xs).update_nth n.succ a = x :: xs.update_nth n a := rfl\n\nlemma update_nth_comm (a b : \u03b1) : \u03a0 {n m : \u2115} (l : list \u03b1) (h : n \u2260 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 (\u03bb h', h $ nat.succ_inj'.mpr h'), }\n\n@[simp] lemma nth_le_update_nth_eq (l : list \u03b1) (i : \u2115) (a : \u03b1)\n  (h : i < (l.update_nth i a).length) : (l.update_nth i a).nth_le i h = a :=\nby rw [\u2190 option.some_inj, \u2190 nth_le_nth, nth_update_nth_eq, nth_le_nth]; simp * at *\n\n@[simp] lemma nth_le_update_nth_of_ne {l : list \u03b1} {i j : \u2115} (h : i \u2260 j) (a : \u03b1)\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 [\u2190 option.some_inj, \u2190 list.nth_le_nth, list.nth_update_nth_ne _ _ h, list.nth_le_nth]\n\nlemma mem_or_eq_of_mem_update_nth : \u2200 {l : list \u03b1} {n : \u2115} {a b : \u03b1}\n  (h : a \u2208 l.update_nth n b), a \u2208 l \u2228 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 \u2218 mem_cons_of_mem _)\n| (c::l) (n+1) a b h := ((mem_cons_iff _ _ _).1 h).elim\n  (\u03bb h, h \u25b8 or.inl (mem_cons_self _ _))\n  (\u03bb h, (mem_or_eq_of_mem_update_nth h).elim\n    (or.inl \u2218 mem_cons_of_mem _) or.inr)\n\nsection insert_nth\nvariable {a : \u03b1}\n\n@[simp] lemma insert_nth_nil (a : \u03b1) : insert_nth 0 a [] = [a] := rfl\n\n@[simp] lemma insert_nth_succ_nil (n : \u2115) (a : \u03b1) : insert_nth (n + 1) a [] = [] := rfl\n\nlemma length_insert_nth : \u2200n as, n \u2264 length as \u2192 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:\u2115) (l : list \u03b1) : (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 : \u2200n m as, n < length as \u2192 n \u2264 m \u2192\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 : \u2200n m as, n < length as \u2192 m \u2264 n \u2192\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 : \u03b1) :\n  \u2200(i j : \u2115) (l : list \u03b1) (h : i \u2264 j) (hj : j \u2264 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\u2080 h\u2081,\n  by simp [insert_nth];\n    exact insert_nth_comm i j l (nat.le_of_succ_le_succ h\u2080) (nat.le_of_succ_le_succ h\u2081)\n\nlemma mem_insert_nth {a b : \u03b1} : \u2200 {n : \u2115} {l : list \u03b1} (hi : n \u2264 l.length),\n  a \u2208 l.insert_nth n b \u2194 a = b \u2228 a \u2208 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    \u2190 or.assoc, or_comm (a = a'), or.assoc]\nend\n\nend insert_nth\n\n/-! ### map -/\n\n@[simp] lemma map_nil (f : \u03b1 \u2192 \u03b2) : map f [] = [] := rfl\n\ntheorem map_eq_foldr (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) :\n  map f l = foldr (\u03bb a bs, f a :: bs) [] l :=\nby induction l; simp *\n\nlemma map_congr {f g : \u03b1 \u2192 \u03b2} : \u2200 {l : list \u03b1}, (\u2200 x \u2208 l, f x = g x) \u2192 map f l = map g l\n| []     _ := rfl\n| (a::l) h := let \u27e8h\u2081, h\u2082\u27e9 := forall_mem_cons.1 h in\n  by rw [map, map, h\u2081, map_congr h\u2082]\n\nlemma map_eq_map_iff {f g : \u03b1 \u2192 \u03b2} {l : list \u03b1} : map f l = map g l \u2194 (\u2200 x \u2208 l, f x = g x) :=\nbegin\n  refine \u27e8_, map_congr\u27e9, intros h x hx,\n  rw [mem_iff_nth_le] at hx, rcases hx with \u27e8n, hn, rfl\u27e9,\n  rw [nth_le_map_rev f, nth_le_map_rev g], congr, exact h\nend\n\ntheorem map_concat (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (l : list \u03b1) : 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 : \u03b1 \u2192 \u03b1} (h : \u2200 x, f x = x) (l : list \u03b1) : map f l = l :=\nby induction l; [refl, simp only [*, map]]; split; refl\n\ntheorem eq_nil_of_map_eq_nil {f : \u03b1 \u2192 \u03b2} {l : list \u03b1} (h : map f l = nil) : l = nil :=\neq_nil_of_length_eq_zero $ by rw [\u2190 length_map f l, h]; refl\n\n@[simp] theorem map_join (f : \u03b1 \u2192 \u03b2) (L : list (list \u03b1)) :\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 : \u03b1 \u2192 \u03b2) (l : list \u03b1) :\n  l.bind (list.ret \u2218 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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) : f <$> l = map f l := rfl\n\n@[simp] theorem map_tail (f : \u03b1 \u2192 \u03b2) (l) : map f (tail l) = tail (map f l) :=\nby cases l; refl\n\n@[simp] theorem map_injective_iff {f : \u03b1 \u2192 \u03b2} : injective (map f) \u2194 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 : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) (l : list \u03b1) :\n  map (h \u2218 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 : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) :\n  map g \u2218 map f = map (g \u2218 f) :=\nby { ext l, rw comp_map }\n\ntheorem map_filter_eq_foldr (f : \u03b1 \u2192 \u03b2) (p : \u03b1 \u2192 Prop) [decidable_pred p] (as : list \u03b1) :\n  map f (filter p as) = foldr (\u03bb 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 : \u03b1 \u2192 \u03b2) {l : list \u03b1} (hl : l \u2260 []) :\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\u2082 -/\n\ntheorem nil_map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l : list \u03b2) : map\u2082 f [] l = [] :=\nby cases l; refl\n\ntheorem map\u2082_nil (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l : list \u03b1) : map\u2082 f l [] = [] :=\nby cases l; refl\n\n@[simp] theorem map\u2082_flip (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :\n  \u2200 as bs, map\u2082 (flip f) bs as = map\u2082 f as bs\n| [] [] := rfl\n| [] (b :: bs) := rfl\n| (a :: as) [] := rfl\n| (a :: as) (b :: bs) := by { simp! [map\u2082_flip], refl }\n\n/-! ### take, drop -/\n@[simp] theorem take_zero (l : list \u03b1) : take 0 l = [] := rfl\n\n@[simp] theorem take_nil : \u2200 n, take n [] = ([] : list \u03b1)\n| 0     := rfl\n| (n+1) := rfl\n\ntheorem take_cons (n) (a : \u03b1) (l : list \u03b1) : take (succ n) (a::l) = a :: take n l := rfl\n\n@[simp] theorem take_length : \u2200 (l : list \u03b1), 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 : \u2200 {n} {l : list \u03b1}, length l \u2264 n \u2192 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 : \u2200 l\u2081 l\u2082 : list \u03b1, take (length l\u2081) (l\u2081 ++ l\u2082) = l\u2081\n| []      l\u2082 := rfl\n| (a::l\u2081) l\u2082 := congr_arg (cons a) (take_left l\u2081 l\u2082)\n\ntheorem take_left' {l\u2081 l\u2082 : list \u03b1} {n} (h : length l\u2081 = n) :\n  take n (l\u2081 ++ l\u2082) = l\u2081 :=\nby rw \u2190 h; apply take_left\n\ntheorem take_take : \u2200 (n m) (l : list \u03b1), 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 : \u03b1) : \u2200 (n m : \u2115), 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 {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) :\n  \u2200 (L : list \u03b1) (i : \u2115), (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 : \u2200 {l\u2081 l\u2082 : list \u03b1} {n : \u2115},\n  n \u2264 l\u2081.length \u2192 (l\u2081 ++ l\u2082).take n = l\u2081.take n\n| l\u2081      l\u2082 0     hn := by simp\n| []      l\u2082 (n+1) hn := absurd hn dec_trivial\n| (a::l\u2081) l\u2082 (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\u2081.length + i` elements in `l\u2081 ++ l\u2082` is the same as appending the first\n`i` elements of `l\u2082` to `l\u2081`. -/\nlemma take_append {l\u2081 l\u2082 : list \u03b1} (i : \u2115) :\n  take (l\u2081.length + i) (l\u2081 ++ l\u2082) = l\u2081 ++ (take i l\u2082) :=\nbegin\n  induction l\u2081, { simp },\n  have : length l\u2081_tl + 1 + i = (length l\u2081_tl + i).succ,\n    by { rw nat.succ_eq_add_one, exact succ_add _ _ },\n  simp only [cons_append, length, this, take_cons, l\u2081_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 \u03b1) {i j : \u2115} (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 \u03b1) {i j : \u2115} (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 \u03b1} {n m : \u2115} (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 \u03b1} {n : \u2115} :\n  (l.take (n + 1)).nth n = l.nth n :=\nnth_take (nat.lt_succ_self n)\n\nlemma take_succ {l : list \u03b1} {n : \u2115} :\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 \u03b1} {k : \u2115} :\n  l.take k = [] \u2194 l = [] \u2228 k = 0 :=\nby { cases l; cases k; simp [nat.succ_ne_zero] }\n\nlemma init_eq_take (l : list \u03b1) : 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 : \u2115} {l : list \u03b1} (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 \u03b1} {k : \u2115} (h : l.length \u2264 k) :\n  l.drop k = [] :=\nby simpa [\u2190length_eq_zero] using nat.sub_eq_zero_of_le h\n\nlemma drop_eq_nil_iff_le {l : list \u03b1} {k : \u2115} :\n  l.drop k = [] \u2194 l.length \u2264 k :=\nbegin\n  refine \u27e8\u03bb h, _, drop_eq_nil_of_le\u27e9,\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 \u03b1) (n : \u2115) : (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 \u03b1} {n : \u2115} (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 : \u2200 n, drop n [] = ([] : list \u03b1) :=\n\u03bb _, drop_eq_nil_of_le (nat.zero_le _)\n\nlemma mem_of_mem_drop {\u03b1} {n : \u2115} {l : list \u03b1} {x : \u03b1}\n  (h : x \u2208 l.drop n) :\n  x \u2208 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 \u22a2,\n    { exact h },\n    right, apply l_ih h },\nend\n\n@[simp] theorem drop_one : \u2200 l : list \u03b1, drop 1 l = tail l\n| []       := rfl\n| (a :: l) := rfl\n\ntheorem drop_add : \u2200 m n (l : list \u03b1), 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 : \u2200 l\u2081 l\u2082 : list \u03b1, drop (length l\u2081) (l\u2081 ++ l\u2082) = l\u2082\n| []      l\u2082 := rfl\n| (a::l\u2081) l\u2082 := drop_left l\u2081 l\u2082\n\ntheorem drop_left' {l\u2081 l\u2082 : list \u03b1} {n} (h : length l\u2081 = n) :\n  drop n (l\u2081 ++ l\u2082) = l\u2082 :=\nby rw \u2190 h; apply drop_left\n\ntheorem drop_eq_nth_le_cons : \u2200 {n} {l : list \u03b1} 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 \u03b1) : 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 : \u2200 {l\u2081 l\u2082 : list \u03b1} {n : \u2115}, n \u2264 l\u2081.length \u2192\n  (l\u2081 ++ l\u2082).drop n = l\u2081.drop n ++ l\u2082\n| l\u2081      l\u2082 0     hn := by simp\n| []      l\u2082 (n+1) hn := absurd hn dec_trivial\n| (a::l\u2081) l\u2082 (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\u2081.length + i` in `l\u2081 + l\u2082` is the same as dropping the elements\nup to `i` in `l\u2082`. -/\nlemma drop_append {l\u2081 l\u2082 : list \u03b1} (i : \u2115) :\n  drop (l\u2081.length + i) (l\u2081 ++ l\u2082) = drop i l\u2082 :=\nbegin\n  induction l\u2081, { simp },\n  have : length l\u2081_tl + 1 + i = (length l\u2081_tl + i).succ,\n    by { rw nat.succ_eq_add_one, exact succ_add _ _ },\n  simp only [cons_append, length, this, drop, l\u2081_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 \u03b1) {i j : \u2115} (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 \u03b1) {i j : \u2115} (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) \u25b8 h)) :=\nby rw nth_le_drop\n\nlemma nth_drop (L : list \u03b1) (i j : \u2115) :\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 \u03bb \u27e8h, ha\u27e9, \u27e8by simpa [nat.lt_sub_left_iff_add_lt] using h, ha\u27e9\nend\n\n@[simp] theorem drop_drop (n : \u2115) : \u2200 (m) (l : list \u03b1), 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 : \u2200 (m : \u2115) (n : \u2115) (l : list \u03b1),\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 {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) :\n  \u2200 (L : list \u03b1) (i : \u2115), (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 \u03b1 \u2192 list \u03b1) (H : f [] = []) :\n  \u2200 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 : \u03b1 \u2192 \u03b1) :\n  \u2200 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 : \u03b1 \u2192 \u03b1) {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 : \u03b1) {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 {\u03b1} {xs : list \u03b1} (n : \u2115)\n  (h : n \u2264 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 \u03b1) (n : \u2115) (a : \u03b1) : l.update_nth n a = [] \u2194 l = [] :=\nby cases l; cases n; simp only [update_nth]\n\nsection take'\nvariable [inhabited \u03b1]\n\n@[simp] theorem take'_length : \u2200 n l, length (@take' \u03b1 _ n l) = n\n| 0     l := rfl\n| (n+1) l := congr_arg succ (take'_length _ _)\n\n@[simp] theorem take'_nil : \u2200 n, take' n (@nil \u03b1) = repeat (default _) n\n| 0     := rfl\n| (n+1) := congr_arg (cons _) (take'_nil _)\n\ntheorem take'_eq_take : \u2200 {n} {l : list \u03b1},\n  n \u2264 length l \u2192 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\u2081 l\u2082 : list \u03b1) : take' (length l\u2081) (l\u2081 ++ l\u2082) = l\u2081 :=\n(take'_eq_take (by simp only [length_append, nat.le_add_right])).trans (take_left _ _)\n\ntheorem take'_left' {l\u2081 l\u2082 : list \u03b1} {n} (h : length l\u2081 = n) :\n  take' n (l\u2081 ++ l\u2082) = l\u2081 :=\nby rw \u2190 h; apply take'_left\n\nend take'\n\n/-! ### foldl, foldr -/\n\nlemma foldl_ext (f g : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1)\n  {l : list \u03b2} (H : \u2200 a : \u03b1, \u2200 b \u2208 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 (\u03bb a b bin, H a b $ mem_cons_of_mem _ bin), H a hd (mem_cons_self _ _)]\nend\n\nlemma foldr_ext (f g : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2)\n  {l : list \u03b1} (H : \u2200 a \u2208 l, \u2200 b : \u03b2, 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) : foldl f a [] = a := rfl\n\n@[simp] theorem foldl_cons (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (b : \u03b2) (l : list \u03b2) :\n  foldl f a (b::l) = foldl f (f a b) l := rfl\n\n@[simp] theorem foldr_nil (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) : foldr f b [] = b := rfl\n\n@[simp] theorem foldr_cons (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (a : \u03b1) (l : list \u03b1) :\n  foldr f b (a::l) = f a (foldr f b l) := rfl\n\n@[simp] theorem foldl_append (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) :\n  \u2200 (a : \u03b1) (l\u2081 l\u2082 : list \u03b2), foldl f a (l\u2081++l\u2082) = foldl f (foldl f a l\u2081) l\u2082\n| a []      l\u2082 := rfl\n| a (b::l\u2081) l\u2082 := by simp only [cons_append, foldl_cons, foldl_append (f a b) l\u2081 l\u2082]\n\n@[simp] theorem foldr_append (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) :\n  \u2200 (b : \u03b2) (l\u2081 l\u2082 : list \u03b1), foldr f b (l\u2081++l\u2082) = foldr f (foldr f b l\u2082) l\u2081\n| b []      l\u2082 := rfl\n| b (a::l\u2081) l\u2082 := by simp only [cons_append, foldr_cons, foldr_append b l\u2081 l\u2082]\n\n@[simp] theorem foldl_join (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) :\n  \u2200 (a : \u03b1) (L : list (list \u03b2)), 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) :\n  \u2200 (b : \u03b2) (L : list (list \u03b1)), foldr f b (join L) = foldr (\u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (l : list \u03b2) :\n  foldl f a (reverse l) = foldr (\u03bbx 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (a : \u03b2) (l : list \u03b1) :\n  foldr f a (reverse l) = foldl (\u03bbx y, f y x) a l :=\nlet t := foldl_reverse (\u03bbx y, f y x) a (reverse l) in\nby rw reverse_reverse l at t; rwa t\n\n@[simp] theorem foldr_eta : \u2200 (l : list \u03b1), 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 \u03b1} : reverse (foldl (\u03bb t h, h :: t) [] l) = l :=\nby rw \u2190foldr_reverse; simp\n\n@[simp] theorem foldl_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b3 \u2192 \u03b1) (a : \u03b1) (l : list \u03b2) :\n  foldl f a (map g l) = foldl (\u03bbx 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 : \u03b2 \u2192 \u03b3) (f : \u03b3 \u2192 \u03b1 \u2192 \u03b1) (a : \u03b1) (l : list \u03b2) :\n  foldr f a (map g l) = foldr (f \u2218 g) a l :=\nby revert a; induction l; intros; [refl, simp only [*, map, foldr]]\n\ntheorem foldl_map' {\u03b1 \u03b2: Type u} (g : \u03b1 \u2192 \u03b2) (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (f' : \u03b2 \u2192 \u03b2 \u2192 \u03b2)\n  (a : \u03b1) (l : list \u03b1) (h : \u2200 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' {\u03b1 \u03b2: Type u} (g : \u03b1 \u2192 \u03b2) (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (f' : \u03b2 \u2192 \u03b2 \u2192 \u03b2)\n  (a : \u03b1) (l : list \u03b1) (h : \u2200 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 \u03b3) (f : \u03b1 \u2192 \u03b2) (op : \u03b1 \u2192 \u03b3 \u2192 \u03b1) (op' : \u03b2 \u2192 \u03b3 \u2192 \u03b2) (a : \u03b1)\n  (h : \u2200a 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 \u03b3) (f : \u03b1 \u2192 \u03b2) (op : \u03b3 \u2192 \u03b1 \u2192 \u03b1) (op' : \u03b3 \u2192 \u03b2 \u2192 \u03b2) (a : \u03b1)\n  (h : \u2200x 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 {\u03b1 : Type*} {l : list (\u03b1 \u2192 \u03b1)} {f : \u03b1 \u2192 \u03b1}\n  (hl : \u2200 f \u2208 l, function.injective f) (hf : function.injective f):\n  function.injective (@list.foldl (\u03b1 \u2192 \u03b1) (\u03b1 \u2192 \u03b1) function.comp f l) :=\nbegin\n  induction l generalizing f,\n  { exact hf },\n  { apply l_ih (\u03bb _ 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 : \u03b2` and for all incremental `op : \u03b1 \u2192 \u03b2 \u2192 \u03b2`\nperformed on the elements `(a : \u03b1) \u2208 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 : \u03b2 \u2192 Sort*} (l : list \u03b1) (op : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (hb : C b)\n  (hl : \u2200 (b : \u03b2) (hb : C b) (a : \u03b1) (ha : a \u2208 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 : \u03b2` and for all incremental `op : \u03b2 \u2192 \u03b1 \u2192 \u03b2`\nperformed on the elements `(a : \u03b1) \u2208 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 : \u03b2 \u2192 Sort*} (l : list \u03b1) (op : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (b : \u03b2) (hb : C b)\n  (hl : \u2200 (b : \u03b2) (hb : C b) (a : \u03b1) (ha : a \u2208 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 : \u03b2 \u2192 Sort*} (op : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b) (hb : C b) (hl) :\n  foldr_rec_on [] op b hb hl = hb := rfl\n\n@[simp] lemma foldr_rec_on_cons {C : \u03b2 \u2192 Sort*} (x : \u03b1) (l : list \u03b1)\n  (op : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b) (hb : C b)\n  (hl : \u2200 (b : \u03b2) (hb : C b) (a : \u03b1) (ha : a \u2208 (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    (\u03bb 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 : \u03b2 \u2192 Sort*} (op : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (b) (hb : C b) (hl) :\n  foldl_rec_on [] op b hb hl = hb := rfl\n\n/- scanl -/\n\nsection scanl\n\nvariables {f : \u03b2 \u2192 \u03b1 \u2192 \u03b2} {b : \u03b2} {a : \u03b1} {l : list \u03b1}\n\nlemma length_scanl :\n  \u2200 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 : \u03b2) : 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 : \u2115} :\n  (scanl f b l).nth (i + 1) = ((scanl f b l).nth i).bind (\u03bb x, (l.nth i).map (\u03bb 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 : \u2115} {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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) : scanr f b [] = [b] := rfl\n\n@[simp] theorem scanr_aux_cons (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) : \u2200 (a : \u03b1) (l : list \u03b1),\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (a : \u03b1) (l : list \u03b1) :\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 : \u03b1 \u2192 \u03b1 \u2192 \u03b1} (hcomm : commutative f) (hassoc : associative f)\n\ninclude hassoc\ntheorem foldl1_eq_foldr1 : \u2200 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 : \u2200 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 [\u2190 foldl_eq_of_comm_of_assoc, right_comm _ hcomm hassoc]; refl\n\ntheorem foldl_eq_foldr : \u2200 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b1}\nvariables hf : \u2200 a b c, f (f a b) c = f (f a c) b\ninclude hf\n\ntheorem foldl_eq_of_comm' : \u2200 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,\u2190 foldl_eq_of_comm',foldl,hf]\n\ntheorem foldl_eq_foldr' : \u2200 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2}\nvariables hf : \u2200 a b c, f a (f b c) = f b (f a c)\ninclude hf\n\ntheorem foldr_eq_of_comm' : \u2200 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,\u2190 foldr_eq_of_comm']; refl\n\nend foldl_eq_foldlr'\n\nsection\nvariables {op : \u03b1 \u2192 \u03b1 \u2192 \u03b1} [ha : is_associative \u03b1 op] [hc : is_commutative \u03b1 op]\nlocal notation a * b := op a b\nlocal notation l <*> a := foldl op a l\n\ninclude ha\n\nlemma foldl_assoc : \u2200 {l : list \u03b1} {a\u2081 a\u2082}, l <*> (a\u2081 * a\u2082) = a\u2081 * (l <*> a\u2082)\n| [] a\u2081 a\u2082 := rfl\n| (a :: l) a\u2081 a\u2082 :=\n  calc a::l <*> (a\u2081 * a\u2082) = l <*> (a\u2081 * (a\u2082 * a)) : by simp only [foldl_cons, ha.assoc]\n    ... = a\u2081 * (a::l <*> a\u2082) : by rw [foldl_assoc, foldl_cons]\n\nlemma foldl_op_eq_op_foldr_assoc : \u2200{l : list \u03b1} {a\u2081 a\u2082}, (l <*> a\u2081) * a\u2082 = a\u2081 * l.foldr (*) a\u2082\n| [] a\u2081 a\u2082 := rfl\n| (a :: l) a\u2081 a\u2082 := 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 \u03b1} {a\u2081 a\u2082} : (a\u2081 :: l) <*> a\u2082 = a\u2081 * (l <*> a\u2082) :=\nby rw [foldl_cons, hc.comm, foldl_assoc]\n\nend\n\n/-! ### mfoldl, mfoldr, mmap -/\n\nsection mfoldl_mfoldr\nvariables {m : Type v \u2192 Type w} [monad m]\n\n@[simp] theorem mfoldl_nil (f : \u03b2 \u2192 \u03b1 \u2192 m \u03b2) {b} : mfoldl f b [] = pure b := rfl\n\n@[simp] theorem mfoldr_nil (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) {b} : mfoldr f b [] = pure b := rfl\n\n@[simp] theorem mfoldl_cons {f : \u03b2 \u2192 \u03b1 \u2192 m \u03b2} {b a l} :\n  mfoldl f b (a :: l) = f b a >>= \u03bb b', mfoldl f b' l := rfl\n\n@[simp] theorem mfoldr_cons {f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2} {b a l} :\n  mfoldr f b (a :: l) = mfoldr f b l >>= f a := rfl\n\ntheorem mfoldr_eq_foldr (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) (b l) :\n  mfoldr f b l = foldr (\u03bb 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 : \u03b2 \u2192 \u03b1 \u2192 m \u03b2) (b l) :\n  mfoldl f b l = foldl (\u03bb mb a, mb >>= \u03bb b, f b a) (pure b) l :=\nbegin\n  suffices h : \u2200 (mb : m \u03b2),\n    (mb >>= \u03bb b, mfoldl f b l) = foldl (\u03bb mb a, mb >>= \u03bb b, f b a) mb l,\n  by simp [\u2190h (pure b)],\n  induction l; intro,\n  { simp },\n  { simp only [mfoldl, foldl, \u2190l_ih] with monad_norm }\nend\n\n@[simp] theorem mfoldl_append {f : \u03b2 \u2192 \u03b1 \u2192 m \u03b2} : \u2200 {b l\u2081 l\u2082},\n  mfoldl f b (l\u2081 ++ l\u2082) = mfoldl f b l\u2081 >>= \u03bb x, mfoldl f x l\u2082\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 : \u03b1 \u2192 \u03b2 \u2192 m \u03b2} : \u2200 {b l\u2081 l\u2082},\n  mfoldr f b (l\u2081 ++ l\u2082) = mfoldr f b l\u2082 >>= \u03bb x, mfoldr f x l\u2081\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 \u03b1] {l l\u2081 l\u2082 : list \u03b1} {a : \u03b1}\n\n@[simp, to_additive]\ntheorem prod_nil : ([] : list \u03b1).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\u2081 ++ l\u2082).prod = l\u2081.prod * l\u2082.prod :=\ncalc (l\u2081 ++ l\u2082).prod = foldl (*) (foldl (*) 1 l\u2081 * 1) l\u2082 : by simp [list.prod]\n  ... = l\u2081.prod * l\u2082.prod : foldl_assoc\n\n@[simp, to_additive]\ntheorem prod_join {l : list (list \u03b1)} : 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\u2080 : Type*} [monoid_with_zero M\u2080] {L : list M\u2080} (h : (0 : M\u2080) \u2208 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 \u2208 L`. See also\n`list.prod_eq_zero` for an implication that needs weaker typeclass assumptions. -/\n@[simp] theorem prod_eq_zero_iff {M\u2080 : Type*} [monoid_with_zero M\u2080] [nontrivial M\u2080]\n  [no_zero_divisors M\u2080] {L : list M\u2080} :\n  L.prod = 0 \u2194 (0 : M\u2080) \u2208 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\u2080 : Type*} [monoid_with_zero M\u2080] [nontrivial M\u2080] [no_zero_divisors M\u2080]\n  {L : list M\u2080} (hL : (0 : M\u2080) \u2209 L) : L.prod \u2260 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 $ \u03bb a l ihl, by rw [prod_cons, foldr_cons, ihl]\n\n@[to_additive]\ntheorem prod_hom_rel {\u03b1 \u03b2 \u03b3 : Type*} [monoid \u03b2] [monoid \u03b3] (l : list \u03b1) {r : \u03b2 \u2192 \u03b3 \u2192 Prop}\n  {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} (h\u2081 : r 1 1) (h\u2082 : \u2200\u2983a b c\u2984, r b c \u2192 r (f a * b) (g a * c)) :\n  r (l.map f).prod (l.map g).prod :=\nlist.rec_on l h\u2081 (\u03bb a l hl, by simp only [map_cons, prod_cons, h\u2082 hl])\n\n@[to_additive]\ntheorem prod_hom [monoid \u03b2] (l : list \u03b1) (f : \u03b1 \u2192* \u03b2) :\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 \u03b2] : \u03a0 {L : list \u03b2} (u : \u2200 m \u2208 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 (\u03bb 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  \u2200 (L : list \u03b1) (i : \u2115), (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  \u2200 (L : list \u03b1) (i : \u2115) (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 \u03b1) (h : L.prod \u2260 1) : 0 < L.length :=\nby { cases L, { simp at h, cases h, }, { simp, }, }\n\nlemma prod_update_nth : \u2200 (L : list \u03b1) (n : \u2115) (a : \u03b1),\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 \u03b1]\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 : \u2200 (L : list \u03b1), L.prod\u207b\u00b9 = (L.map (\u03bb x, x\u207b\u00b9)).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 : \u2200 (L : list \u03b1), L.reverse.prod = (L.map (\u03bb x, x\u207b\u00b9)).prod\u207b\u00b9 :=\nby simp [prod_inv_reverse]\n\nend group\n\nsection comm_group\nvariables [comm_group \u03b1]\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 : \u2200 (L : list \u03b1), L.prod\u207b\u00b9 = (L.map (\u03bb x, x\u207b\u00b9)).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 \u03b1] :\n  \u2200 (L : list \u03b1) (i : \u2115), (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 \u03b1] :\n  \u2200 (L : list \u03b1) (i : \u2115) (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 \u03b1] {L L' : list \u03b1} (h : L.length = L'.length)\n  (h' : \u2200 i \u2264 L.length, (L.take i).sum = (L'.take i).sum) : L = L' :=\nbegin\n  apply ext_le h (\u03bb i h\u2081 h\u2082, _),\n  have : (L.take (i + 1)).sum = (L'.take (i + 1)).sum := h' _ (nat.succ_le_of_lt h\u2081),\n  rw [sum_take_succ L i h\u2081, sum_take_succ L' i h\u2082, h' i (le_of_lt h\u2081)] at this,\n  exact add_left_cancel this\nend\n\nlemma monotone_sum_take [canonically_ordered_add_monoid \u03b1] (L : list \u03b1) :\n  monotone (\u03bb i, (L.take i).sum) :=\nbegin\n  apply monotone_of_monotone_nat (\u03bb 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 \u03b1] {l : list \u03b1} (hl\u2081 : \u2200 x \u2208 l, (1 : \u03b1) \u2264 x) :\n  1 \u2264 l.prod :=\nbegin\n  induction l with hd tl ih,\n  { simp },\n  rw prod_cons,\n  exact one_le_mul (hl\u2081 hd (mem_cons_self hd tl)) (ih (\u03bb x h, hl\u2081 x (mem_cons_of_mem hd h))),\nend\n\n@[to_additive]\nlemma single_le_prod [ordered_comm_monoid \u03b1] {l : list \u03b1} (hl\u2081 : \u2200 x \u2208 l, (1 : \u03b1) \u2264 x) :\n  \u2200 x \u2208 l, x \u2264 l.prod :=\nbegin\n  induction l,\n  { simp },\n  simp_rw [prod_cons, forall_mem_cons] at \u22a2 hl\u2081,\n  split,\n  { exact le_mul_of_one_le_right' (one_le_prod_of_one_le hl\u2081.2) },\n  { exact \u03bb x H, le_mul_of_one_le_of_le hl\u2081.1 (l_ih hl\u2081.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 \u03b1]\n  {l : list \u03b1} (hl\u2081 : \u2200 x \u2208 l, (1 : \u03b1) \u2264 x) (hl\u2082 : l.prod = 1) :\n  \u2200 x \u2208 l, x = (1 : \u03b1) :=\n\u03bb x hx, le_antisymm (hl\u2082 \u25b8 single_le_prod hl\u2081 _ hx) (hl\u2081 x hx)\n\nlemma sum_eq_zero_iff [canonically_ordered_add_monoid \u03b1] (l : list \u03b1) :\n  l.sum = 0 \u2194 \u2200 x \u2208 l, x = (0 : \u03b1) :=\n\u27e8all_zero_of_le_zero_le_of_sum_eq_zero (\u03bb _ _, 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 \u27e8h.1, l_ih h.2\u27e9 },\nend\u27e9\n\n/-- A list with sum not zero must have positive length. -/\nlemma length_pos_of_sum_ne_zero [add_monoid \u03b1] (L : list \u03b1) (h : L.sum \u2260 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 \u2115) (h : \u2200 i \u2208 L, 1 \u2264 i) : L.length \u2264 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 (\u03bb 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 \u03b1] (L : list \u03b1) (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 \u03b1] [comm_monoid \u03b1] {a} :\n  \u03a0 {l : list \u03b1}, a \u2208 l \u2192 a * (l.erase a).prod = l.prod\n| (b::l) h :=\n  begin\n    rcases eq_or_ne_mem_of_mem h with rfl | \u27e8ne, h\u27e9,\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 \u03b1] {a} {l : list \u03b1} (ha : a \u2208 l) : a \u2223 l.prod :=\nlet \u27e8s, t, h\u27e9 := 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 : \u2115) : 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 \u03b1] {a} {l : list \u03b1} (h : \u2200 x \u2208 l, a \u2223 x) : a \u2223 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 (\u03bb x hx, h x (mem_cons_of_mem _ hx))) }\nend\n\n@[simp] theorem length_join (L : list (list \u03b1)) : 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 \u03b1) (f : \u03b1 \u2192 list \u03b2) :\n  length (list.bind l f) = sum (map (length \u2218 f) l) :=\nby rw [list.bind, length_join, map_map]\n\nlemma exists_lt_of_sum_lt [linear_ordered_cancel_add_comm_monoid \u03b2] {l : list \u03b1}\n  (f g : \u03b1 \u2192 \u03b2) (h : (l.map f).sum < (l.map g).sum) : \u2203 x \u2208 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 \u27e8x, mem_cons_self _ _, h'\u27e9,\n    rcases l_ih _ with \u27e8y, h1y, h2y\u27e9, refine \u27e8y, mem_cons_of_mem x h1y, h2y\u27e9, 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 \u03b2] {l : list \u03b1}\n  (hl : l \u2260 []) (f g : \u03b1 \u2192 \u03b2) (h : (l.map f).sum \u2264 (l.map g).sum) : \u2203 x \u2208 l, f x \u2264 g x :=\nbegin\n  cases l with x l,\n  { contradiction },\n  { by_cases h' : f x \u2264 g x, exact \u27e8x, mem_cons_self _ _, h'\u27e9,\n    rcases exists_lt_of_sum_lt f g _ with \u27e8y, h1y, h2y\u27e9,\n    exact \u27e8y, mem_cons_of_mem x h1y, le_of_lt h2y\u27e9, 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 \u2115`.\n-- These are hard to generalize well, as they rely on the fact that `default \u2115 = 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 `\u2115`.\n@[to_additive]\nlemma head_mul_tail_prod' [monoid \u03b1] (L : list \u03b1) :\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 \u2115) : L.head + L.tail.sum = L.sum :=\nby { cases L, { simp, refl, }, { simp, }, }\n\nlemma head_le_sum (L : list \u2115) : L.head \u2264 L.sum :=\nnat.le.intro (head_add_tail_sum L)\n\nlemma tail_sum (L : list \u2115) : L.tail.sum = L.sum - L.head :=\nby rw [\u2190 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\u207b\u00b9 * 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 : \u2200 {L : list (list \u03b1)}, join L = [] \u2194 \u2200 l \u2208 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\u2081 L\u2082 : list (list \u03b1)) : join (L\u2081 ++ L\u2082) = join L\u2081 ++ join L\u2082 :=\nby induction L\u2081; [refl, simp only [*, join, cons_append, append_assoc]]\n\n@[simp] theorem join_filter_empty_eq_ff [decidable_pred (\u03bb l : list \u03b1, l.empty = ff)] :\n  \u2200 {L : list (list \u03b1)}, join (L.filter (\u03bb 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 (\u03bb l : list \u03b1, l \u2260 [])] {L : list (list \u03b1)} :\n  join (L.filter (\u03bb l, l \u2260 [])) = L.join :=\nby simp [join_filter_empty_eq_ff, \u2190 empty_iff_eq_nil]\n\nlemma join_join (l : list (list (list \u03b1))) : 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 \u03b1)) (i : \u2115) :\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 \u03b1)) (i : \u2115) :\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 \u03b1) {i : \u2115} (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 `\u2264 i`. -/\nlemma drop_take_succ_join_eq_nth_le (L : list (list \u03b1)) {i : \u2115} (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 \u03b1)) {i j : \u2115}\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 \u03b1)) {i j : \u2115}\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 \u03b1)) {i j : \u2115}\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 \u03b1)) :\n  L = L' \u2194 L.join = L'.join \u2227 map length L = map length L' :=\nbegin\n  refine \u27e8\u03bb H, by simp [H], _\u27e9,\n  rintros \u27e8join_eq, length_eq\u27e9,\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\u2081 h\u2082,\n    rw [\u2190 drop_take_succ_join_eq_nth_le, \u2190 drop_take_succ_join_eq_nth_le, join_eq, length_eq] }\nend\n\n/-! ### lexicographic ordering -/\n\n/-- Given a strict order `<` on `\u03b1`, the lexicographic strict order on `list \u03b1`, 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) : list \u03b1 \u2192 list \u03b1 \u2192 Prop\n| nil {a l} : lex [] (a :: l)\n| cons {a l\u2081 l\u2082} (h : lex l\u2081 l\u2082) : lex (a :: l\u2081) (a :: l\u2082)\n| rel {a\u2081 l\u2081 a\u2082 l\u2082} (h : r a\u2081 a\u2082) : lex (a\u2081 :: l\u2081) (a\u2082 :: l\u2082)\n\nnamespace lex\ntheorem cons_iff {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_irrefl \u03b1 r] {a l\u2081 l\u2082} :\n  lex r (a :: l\u2081) (a :: l\u2082) \u2194 lex r l\u2081 l\u2082 :=\n\u27e8\u03bb h, by cases h with _ _ _ _ _ h _ _ _ _ h;\n  [exact h, exact (irrefl_of r a h).elim], lex.cons\u27e9\n\n@[simp] theorem not_nil_right (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (l : list \u03b1) : \u00ac lex r l [].\n\ninstance is_order_connected (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [is_order_connected \u03b1 r] [is_trichotomous \u03b1 r] :\n  is_order_connected (list \u03b1) (lex r) :=\n\u27e8\u03bb l\u2081, match l\u2081 with\n| _,     [],    c::l\u2083, nil    := or.inr nil\n| _,     [],    c::l\u2083, rel _ := or.inr nil\n| _,     [],    c::l\u2083, cons _ := or.inr nil\n| _,     b::l\u2082, c::l\u2083, nil := or.inl nil\n| a::l\u2081, b::l\u2082, c::l\u2083, rel h :=\n  (is_order_connected.conn _ b _ h).imp rel rel\n| a::l\u2081, b::l\u2082, _::l\u2083, cons h := begin\n    rcases trichotomous_of r a b with ab | rfl | ab,\n    { exact or.inl (rel ab) },\n    { exact (_match _ l\u2082 _ h).imp cons cons },\n    { exact or.inr (rel ab) }\n  end\nend\u27e9\n\ninstance is_trichotomous (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [is_trichotomous \u03b1 r] :\n  is_trichotomous (list \u03b1) (lex r) :=\n\u27e8\u03bb l\u2081, match l\u2081 with\n| [], [] := or.inr (or.inl rfl)\n| [], b::l\u2082 := or.inl nil\n| a::l\u2081, [] := or.inr (or.inr nil)\n| a::l\u2081, b::l\u2082 := begin\n    rcases trichotomous_of r a b with ab | rfl | ab,\n    { exact or.inl (rel ab) },\n    { exact (_match l\u2081 l\u2082).imp cons\n      (or.imp (congr_arg _) cons) },\n    { exact or.inr (or.inr (rel ab)) }\n  end\nend\u27e9\n\ninstance is_asymm (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [is_asymm \u03b1 r] : is_asymm (list \u03b1) (lex r) :=\n\u27e8\u03bb l\u2081, match l\u2081 with\n| a::l\u2081, b::l\u2082, lex.rel h\u2081, lex.rel h\u2082 := asymm h\u2081 h\u2082\n| a::l\u2081, b::l\u2082, lex.rel h\u2081, lex.cons h\u2082 := asymm h\u2081 h\u2081\n| a::l\u2081, b::l\u2082, lex.cons h\u2081, lex.rel h\u2082 := asymm h\u2082 h\u2082\n| a::l\u2081, b::l\u2082, lex.cons h\u2081, lex.cons h\u2082 :=\n  by exact _match _ _ h\u2081 h\u2082\nend\u27e9\n\ninstance is_strict_total_order (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [is_strict_total_order' \u03b1 r] : is_strict_total_order' (list \u03b1) (lex r) :=\n{..is_strict_weak_order_of_is_order_connected}\n\ninstance decidable_rel [decidable_eq \u03b1] (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [decidable_rel r] : decidable_rel (lex r)\n| l\u2081 [] := is_false $ \u03bb h, by cases h\n| [] (b::l\u2082) := is_true lex.nil\n| (a::l\u2081) (b::l\u2082) := begin\n  haveI := decidable_rel l\u2081 l\u2082,\n  refine decidable_of_iff (r a b \u2228 a = b \u2227 lex r l\u2081 l\u2082) \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { rcases h with h | \u27e8rfl, h\u27e9,\n    { exact lex.rel h },\n    { exact lex.cons h } },\n  { rcases h with _|\u27e8_,_,_,h\u27e9|\u27e8_,_,_,_,h\u27e9,\n    { exact or.inr \u27e8rfl, h\u27e9 },\n    { exact or.inl h } }\nend\n\ntheorem append_right (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :\n  \u2200 {s\u2081 s\u2082} t, lex r s\u2081 s\u2082 \u2192 lex r s\u2081 (s\u2082 ++ t)\n| _ _ t nil      := nil\n| _ _ t (cons h) := cons (append_right _ h)\n| _ _ t (rel r)  := rel r\n\ntheorem append_left (R : \u03b1 \u2192 \u03b1 \u2192 Prop) {t\u2081 t\u2082} (h : lex R t\u2081 t\u2082) :\n  \u2200 s, lex R (s ++ t\u2081) (s ++ t\u2082)\n| []      := h\n| (a::l) := cons (append_left l)\n\ntheorem imp {r s : \u03b1 \u2192 \u03b1 \u2192 Prop} (H : \u2200 a b, r a b \u2192 s a b) :\n  \u2200 l\u2081 l\u2082, lex r l\u2081 l\u2082 \u2192 lex s l\u2081 l\u2082\n| _ _ nil      := nil\n| _ _ (cons h) := cons (imp _ _ h)\n| _ _ (rel r)  := rel (H _ _ r)\n\ntheorem to_ne : \u2200 {l\u2081 l\u2082 : list \u03b1}, lex (\u2260) l\u2081 l\u2082 \u2192 l\u2081 \u2260 l\u2082\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\u2081 l\u2082 : list \u03b1} (H : length l\u2081 \u2264 length l\u2082) :\n  lex (\u2260) l\u2081 l\u2082 \u2194 l\u2081 \u2260 l\u2082 :=\n\u27e8to_ne, \u03bb h, begin\n  induction l\u2081 with a l\u2081 IH generalizing l\u2082; cases l\u2082 with b l\u2082,\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\u27e9\n\nend lex\n\n--Note: this overrides an instance in core lean\ninstance has_lt' [has_lt \u03b1] : has_lt (list \u03b1) := \u27e8lex (<)\u27e9\n\ntheorem nil_lt_cons [has_lt \u03b1] (a : \u03b1) (l : list \u03b1) : [] < a :: l :=\nlex.nil\n\ninstance [linear_order \u03b1] : linear_order (list \u03b1) :=\nlinear_order_of_STO' (lex (<))\n\n--Note: this overrides an instance in core lean\ninstance has_le' [linear_order \u03b1] : has_le (list \u03b1) :=\npreorder.to_has_le _\n\n/-! ### all & any -/\n\n@[simp] theorem all_nil (p : \u03b1 \u2192 bool) : all [] p = tt := rfl\n\n@[simp] theorem all_cons (p : \u03b1 \u2192 bool) (a : \u03b1) (l : list \u03b1) :\n  all (a::l) p = (p a && all l p) := rfl\n\ntheorem all_iff_forall {p : \u03b1 \u2192 bool} {l : list \u03b1} : all l p \u2194 \u2200 a \u2208 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 : \u03b1 \u2192 Prop} [decidable_pred p]\n  {l : list \u03b1} : all l (\u03bb a, p a) \u2194 \u2200 a \u2208 l, p a :=\nby simp only [all_iff_forall, bool.of_to_bool_iff]\n\n@[simp] theorem any_nil (p : \u03b1 \u2192 bool) : any [] p = ff := rfl\n\n@[simp] theorem any_cons (p : \u03b1 \u2192 bool) (a : \u03b1) (l : list \u03b1) :\n  any (a::l) p = (p a || any l p) := rfl\n\ntheorem any_iff_exists {p : \u03b1 \u2192 bool} {l : list \u03b1} : any l p \u2194 \u2203 a \u2208 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 : \u03b1 \u2192 Prop} [decidable_pred p]\n  {l : list \u03b1} : any l (\u03bb a, p a) \u2194 \u2203 a \u2208 l, p a :=\nby simp [any_iff_exists]\n\ntheorem any_of_mem {p : \u03b1 \u2192 bool} {a : \u03b1} {l : list \u03b1} (h\u2081 : a \u2208 l) (h\u2082 : p a) : any l p :=\nany_iff_exists.2 \u27e8_, h\u2081, h\u2082\u27e9\n\n@[priority 500] instance decidable_forall_mem {p : \u03b1 \u2192 Prop} [decidable_pred p] (l : list \u03b1) :\n  decidable (\u2200 x \u2208 l, p x) :=\ndecidable_of_iff _ all_iff_forall_prop\n\ninstance decidable_exists_mem {p : \u03b1 \u2192 Prop} [decidable_pred p] (l : list \u03b1) :\n  decidable (\u2203 x \u2208 l, p x) :=\ndecidable_of_iff _ any_iff_exists_prop\n\n/-! ### map for partial functions -/\n\n/-- Partial map. If `f : \u03a0 a, p a \u2192 \u03b2` is a partial function defined on\n  `a : \u03b1` 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 : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) : \u03a0 l : list \u03b1, (\u2200 a \u2208 l, p a) \u2192 list \u03b2\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 \u2208 l}`. -/\ndef attach (l : list \u03b1) : list {x // x \u2208 l} := pmap subtype.mk l (\u03bb a, id)\n\ntheorem sizeof_lt_sizeof_of_mem [has_sizeof \u03b1] {x : \u03b1} {l : list \u03b1} (hx : x \u2208 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 : \u03b1 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) (H) :\n  @pmap _ _ p (\u03bb a _, f a) l H = map f l :=\nby induction l; [refl, simp only [*, pmap, map]]; split; refl\n\ntheorem pmap_congr {p q : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2} {g : \u03a0 a, q a \u2192 \u03b2}\n  (l : list \u03b1) {H\u2081 H\u2082} (h : \u2200 a h\u2081 h\u2082, f a h\u2081 = g a h\u2082) :\n  pmap f l H\u2081 = pmap g l H\u2082 :=\nby induction l with _ _ ih; [refl, rw [pmap, pmap, h, ih]]\n\ntheorem map_pmap {p : \u03b1 \u2192 Prop} (g : \u03b2 \u2192 \u03b3) (f : \u03a0 a, p a \u2192 \u03b2)\n  (l H) : map g (pmap f l H) = pmap (\u03bb a h, g (f a h)) l H :=\nby induction l; [refl, simp only [*, pmap, map]]; split; refl\n\ntheorem pmap_map {p : \u03b2 \u2192 Prop} (g : \u2200 b, p b \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2)\n  (l H) : pmap g (map f l) H = pmap (\u03bb a h, g (f a) h) l (\u03bb 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 : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2)\n  (l H) : pmap f l H = l.attach.map (\u03bb x, f x.1 (H _ x.2)) :=\nby rw [attach, map_pmap]; exact pmap_congr l (\u03bb a h\u2081 h\u2082, rfl)\n\ntheorem attach_map_val (l : list \u03b1) : 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 \u03b1) : \u2200 x, x \u2208 l.attach | \u27e8a, h\u27e9 :=\nby have := mem_map.1 (by rw [attach_map_val]; exact h);\n   { rcases this with \u27e8\u27e8_, _\u27e9, m, rfl\u27e9, exact m }\n\n@[simp] theorem mem_pmap {p : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2}\n  {l H b} : b \u2208 pmap f l H \u2194 \u2203 a (h : a \u2208 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 : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2}\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 \u03b1) : L.attach.length = L.length := length_pmap\n\n@[simp] lemma pmap_eq_nil {p : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2}\n  {l H} : pmap f l H = [] \u2194 l = [] :=\nby rw [\u2190 length_eq_zero, length_pmap, length_eq_zero]\n\n@[simp] lemma attach_eq_nil (l : list \u03b1) : l.attach = [] \u2194 l = [] := pmap_eq_nil\n\nlemma last_pmap {\u03b1 \u03b2 : Type*} (p : \u03b1 \u2192 Prop) (f : \u03a0 a, p a \u2192 \u03b2)\n  (l : list \u03b1) (hl\u2081 : \u2200 a \u2208 l, p a) (hl\u2082 : l \u2260 []) :\n  (l.pmap f hl\u2081).last (mt list.pmap_eq_nil.1 hl\u2082) = f (l.last hl\u2082) (hl\u2081 _ (list.last_mem hl\u2082)) :=\nbegin\n  induction l with l_hd l_tl l_ih,\n  { apply (hl\u2082 rfl).elim },\n  { cases l_tl,\n    { simp },\n    { apply l_ih } }\nend\n\nlemma nth_pmap {p : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) {l : list \u03b1} (h : \u2200 a \u2208 l, p a) (n : \u2115) :\n  nth (pmap f l h) n = option.pmap f (nth l n) (\u03bb 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 : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) {l : list \u03b1} (h : \u2200 a \u2208 l, p a) {n : \u2115}\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 \u25b8 hn))\n    (h _ (nth_le_mem l n (@length_pmap _ _ p f l h \u25b8 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 : \u03b1 \u2192 Prop} [decidable_pred p] {l : list \u03b1} {a : \u03b1}\n\n@[simp] theorem find_nil (p : \u03b1 \u2192 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 : \u00ac p a) : find p (a::l) = find p l :=\nif_neg h\n\n@[simp] theorem find_eq_none : find p l = none \u2194 \u2200 x \u2208 l, \u00ac 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 \u2208 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 : \u03b1 \u2192 option \u03b1)\n\n@[simp] theorem lookmap_nil : [].lookmap f = [] := rfl\n\n@[simp] theorem lookmap_cons_none {a : \u03b1} (l : list \u03b1) (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 : \u03b1} (l : list \u03b1) (h : f a = some b) :\n  (a :: l).lookmap f = b :: l :=\nby simp [lookmap, h]\n\ntheorem lookmap_some : \u2200 l : list \u03b1, l.lookmap some = l\n| []     := rfl\n| (a::l) := rfl\n\ntheorem lookmap_none : \u2200 l : list \u03b1, l.lookmap (\u03bb _, none) = l\n| []     := rfl\n| (a::l) := congr_arg (cons a) (lookmap_none l)\n\ntheorem lookmap_congr {f g : \u03b1 \u2192 option \u03b1} :\n  \u2200 {l : list \u03b1}, (\u2200 a \u2208 l, f a = g a) \u2192 l.lookmap f = l.lookmap g\n| []     H := rfl\n| (a::l) H := begin\n  cases forall_mem_cons.1 H with H\u2081 H\u2082,\n  cases h : g a with b,\n  { simp [h, H\u2081.trans h, lookmap_congr H\u2082] },\n  { simp [lookmap_cons_some _ _ h, lookmap_cons_some _ _ (H\u2081.trans h)] }\nend\n\ntheorem lookmap_of_forall_not {l : list \u03b1} (H : \u2200 a \u2208 l, f a = none) : l.lookmap f = l :=\n(lookmap_congr H).trans (lookmap_none l)\n\ntheorem lookmap_map_eq (g : \u03b1 \u2192 \u03b2) (h : \u2200 a (b \u2208 f a), g a = g b) :\n  \u2200 l : list \u03b1, 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 : \u2200 a (b \u2208 f a), a = b) (l : list \u03b1) : l.lookmap f = l :=\nby rw [\u2190 map_id (l.lookmap f), lookmap_map_eq, map_id]; exact h\n\ntheorem length_lookmap (l : list \u03b1) : length (l.lookmap f) = length l :=\nby rw [\u2190 length_map, lookmap_map_eq _ (\u03bb _, ()), length_map]; simp\n\nend lookmap\n\n/-! ### filter_map -/\n\n@[simp] theorem filter_map_nil (f : \u03b1 \u2192 option \u03b2) : filter_map f [] = [] := rfl\n\n@[simp] theorem filter_map_cons_none {f : \u03b1 \u2192 option \u03b2} (a : \u03b1) (l : list \u03b1) (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 : \u03b1 \u2192 option \u03b2)\n  (a : \u03b1) (l : list \u03b1) {b : \u03b2} (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 {\u03b1 \u03b2 : Type*} (l l' : list \u03b1) (f : \u03b1 \u2192 option \u03b2) :\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 : \u03b1 \u2192 \u03b2) : filter_map (some \u2218 f) = map f :=\nbegin\n  funext l,\n  induction l with a l IH, {refl},\n  simp only [filter_map_cons_some (some \u2218 f) _ _ rfl, IH, map_cons], split; refl\nend\n\ntheorem filter_map_eq_filter (p : \u03b1 \u2192 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 : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 option \u03b3) (l : list \u03b1) :\n  filter_map g (filter_map f l) = filter_map (\u03bb 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 : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 \u03b3) (l : list \u03b1) :\n  map g (filter_map f l) = filter_map (\u03bb x, (f x).map g) l :=\nby rw [\u2190 filter_map_eq_map, filter_map_filter_map]; refl\n\ntheorem filter_map_map (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 option \u03b3) (l : list \u03b1) :\n  filter_map g (map f l) = filter_map (g \u2218 f) l :=\nby rw [\u2190 filter_map_eq_map, filter_map_filter_map]; refl\n\ntheorem filter_filter_map (f : \u03b1 \u2192 option \u03b2) (p : \u03b2 \u2192 Prop) [decidable_pred p] (l : list \u03b1) :\n  filter p (filter_map f l) = filter_map (\u03bb x, (f x).filter p) l :=\nby rw [\u2190 filter_map_eq_filter, filter_map_filter_map]; refl\n\ntheorem filter_map_filter (p : \u03b1 \u2192 Prop) [decidable_pred p] (f : \u03b1 \u2192 option \u03b2) (l : list \u03b1) :\n  filter_map f (filter p l) = filter_map (\u03bb x, if p x then f x else none) l :=\nbegin\n  rw [\u2190 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 \u03b1) : filter_map some l = l :=\nby rw filter_map_eq_map; apply map_id\n\n@[simp] theorem mem_filter_map (f : \u03b1 \u2192 option \u03b2) (l : list \u03b1) {b : \u03b2} :\n  b \u2208 filter_map f l \u2194 \u2203 a, a \u2208 l \u2227 f a = some b :=\nbegin\n  induction l with a l IH,\n  { split, { intro H, cases H }, { rintro \u27e8_, H, _\u27e9, cases H } },\n  cases h : f a with b',\n  { have : f a \u2260 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 \u2194 b = b',\n    { split; intro t, {rw t at h; injection h}, {exact t.symm \u25b8 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 : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 \u03b1)\n  (H : \u2200 x : \u03b1, (f x).map g = some x) (l : list \u03b1) :\n  map g (filter_map f l) = l :=\nby simp only [map_filter_map, H, filter_map_some]\n\ntheorem sublist.filter_map (f : \u03b1 \u2192 option \u03b2) {l\u2081 l\u2082 : list \u03b1}\n  (s : l\u2081 <+ l\u2082) : filter_map f l\u2081 <+ filter_map f l\u2082 :=\nby induction s with l\u2081 l\u2082 a s IH l\u2081 l\u2082 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 : \u03b1 \u2192 \u03b2) {l\u2081 l\u2082 : list \u03b1}\n  (s : l\u2081 <+ l\u2082) : map f l\u2081 <+ map f l\u2082 :=\nfilter_map_eq_map f \u25b8 s.filter_map _\n\n/-! ### reduce_option -/\n\n@[simp] lemma reduce_option_cons_of_some (x : \u03b1) (l : list (option \u03b1)) :\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 \u03b1)) :\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 \u03b1 [] = [] := rfl\n\n@[simp] lemma reduce_option_map {l : list (option \u03b1)} {f : \u03b1 \u2192 \u03b2} :\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 \u03b1)) :\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 \u03b1)) :\n  l.reduce_option.length \u2264 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 \u03b1)} :\n  l.reduce_option.length = l.length \u2194 \u2200 x \u2208 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 \u03b1)} :\n  l.reduce_option.length < l.length \u2194 none \u2208 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 \u03b1) :\n  [x].reduce_option = x.to_list :=\nby cases x; refl\n\nlemma reduce_option_concat (l : list (option \u03b1)) (x : option \u03b1) :\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 \u03b1)) (x : \u03b1) :\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 \u03b1)} {x : \u03b1} :\n  x \u2208 l.reduce_option \u2194 (some x) \u2208 l :=\nby simp only [reduce_option, id.def, mem_filter_map, exists_eq_right]\n\n\nlemma reduce_option_nth_iff {l : list (option \u03b1)} {x : \u03b1} :\n  (\u2203 i, l.nth i = some (some x)) \u2194 \u2203 i, l.reduce_option.nth i = some x :=\nby rw [\u2190mem_iff_nth, \u2190mem_iff_nth, reduce_option_mem_iff]\n\n/-! ### filter -/\n\nsection filter\nvariables {p : \u03b1 \u2192 Prop} [decidable_pred p]\n\ntheorem filter_eq_foldr (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : list \u03b1) :\n  filter p l = foldr (\u03bb a out, if p a then a :: out else out) [] l :=\nby induction l; simp [*, filter]\n\nlemma filter_congr {p q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q]\n  : \u2200 {l : list \u03b1}, (\u2200 x \u2208 l, p x \u2194 q x) \u2192 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 \u03b1) : filter p l \u2286 l :=\n(filter_sublist l).subset\n\ntheorem of_mem_filter {a : \u03b1} : \u2200 {l}, a \u2208 filter p l \u2192 p a\n| (b::l) ain :=\n  if pb : p b then\n    have a \u2208 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 [\u2190 this] at pb, exact pb end)\n      (assume : a \u2208 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 : \u03b1} {l} (h : a \u2208 filter p l) : a \u2208 l :=\nfilter_subset l h\n\ntheorem mem_filter_of_mem {a : \u03b1} : \u2200 {l}, a \u2208 l \u2192 p a \u2192 a \u2208 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 : \u03b1} {l} : a \u2208 filter p l \u2194 a \u2208 l \u2227 p a :=\n\u27e8\u03bb h, \u27e8mem_of_mem_filter h, of_mem_filter h\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, mem_filter_of_mem h\u2081 h\u2082\u27e9\n\ntheorem filter_eq_self {l} : filter p l = l \u2194 \u2200 a \u2208 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 = [] \u2194 \u2200 a \u2208 l, \u00acp a :=\nby simp only [eq_nil_iff_forall_not_mem, mem_filter, not_and]\n\nvariable (p)\ntheorem filter_sublist_filter {l\u2081 l\u2082} (s : l\u2081 <+ l\u2082) : filter p l\u2081 <+ filter p l\u2082 :=\nfilter_map_eq_filter p \u25b8 s.filter_map _\n\ntheorem map_filter (f : \u03b2 \u2192 \u03b1) (l : list \u03b2) :\n  filter p (map f l) = map f (filter (p \u2218 f) l) :=\nby rw [\u2190 filter_map_eq_map, filter_filter_map, filter_map_filter]; refl\n\n@[simp] theorem filter_filter (q) [decidable_pred q] : \u2200 l,\n  filter p (filter q l) = filter (\u03bb a, p a \u2227 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 (\u03bb a : \u03b1, true)} (l : list \u03b1) :\n  @filter \u03b1 (\u03bb _, true) h l = l :=\nby convert filter_eq_self.2 (\u03bb _ _, trivial)\n\n@[simp] lemma filter_false {h : decidable_pred (\u03bb a : \u03b1, false)} (l : list \u03b1) :\n  @filter \u03b1 (\u03bb _, false) h l = [] :=\nby convert filter_eq_nil.2 (\u03bb _ _, id)\n\n@[simp] theorem span_eq_take_drop : \u2200 (l : list \u03b1), 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 : \u2200 (l : list \u03b1), 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 : \u03b1} (l) (pa : p a) : countp p (a::l) = countp p l + 1 :=\nif_pos pa\n\n@[simp] theorem countp_cons_of_neg {a : \u03b1} (l) (pa : \u00ac 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\u2081 l\u2082) : countp p (l\u2081 ++ l\u2082) = countp p l\u2081 + countp p l\u2082 :=\nby simp only [countp_eq_length_filter, filter_append, length_append]\n\ntheorem countp_pos {l} : 0 < countp p l \u2194 \u2203 a \u2208 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\u2081 l\u2082} (s : l\u2081 <+ l\u2082) : countp p l\u2081 \u2264 countp p l\u2082 :=\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 \u03b1) :\n  countp p (filter q l) = countp (\u03bb a, p a \u2227 q a) l :=\nby simp only [countp_eq_length_filter, filter_filter]\n\nend filter\n\n/-! ### count -/\n\nsection count\nvariable [decidable_eq \u03b1]\n\n@[simp] theorem count_nil (a : \u03b1) : count a [] = 0 := rfl\n\ntheorem count_cons (a b : \u03b1) (l : list \u03b1) :\n  count a (b :: l) = if a = b then succ (count a l) else count a l := rfl\n\ntheorem count_cons' (a b : \u03b1) (l : list \u03b1) :\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 : \u03b1) (l : list \u03b1) : count a (a::l) = succ (count a l) :=\nif_pos rfl\n\n@[simp, priority 990]\ntheorem count_cons_of_ne {a b : \u03b1} (h : a \u2260 b) (l : list \u03b1) : count a (b::l) = count a l :=\nif_neg h\n\ntheorem count_tail : \u03a0 (l : list \u03b1) (a : \u03b1) (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 : \u03b1) {l\u2081 l\u2082} : l\u2081 <+ l\u2082 \u2192 count a l\u2081 \u2264 count a l\u2082 :=\ncountp_le_of_sublist _\n\ntheorem count_le_count_cons (a b : \u03b1) (l : list \u03b1) : count a l \u2264 count a (b :: l) :=\ncount_le_of_sublist _ (sublist_cons _ _)\n\ntheorem count_singleton (a : \u03b1) : count a [a] = 1 := if_pos rfl\n\n@[simp] theorem count_append (a : \u03b1) : \u2200 l\u2081 l\u2082, count a (l\u2081 ++ l\u2082) = count a l\u2081 + count a l\u2082 :=\ncountp_append _\n\ntheorem count_concat (a : \u03b1) (l : list \u03b1) : count a (concat l a) = succ (count a l) :=\nby simp [-add_comm]\n\ntheorem count_pos {a : \u03b1} {l : list \u03b1} : 0 < count a l \u2194 a \u2208 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 : \u03b1} {l : list \u03b1} (h : a \u2209 l) : count a l = 0 :=\ndecidable.by_contradiction $ \u03bb h', h $ count_pos.1 (nat.pos_of_ne_zero h')\n\ntheorem not_mem_of_count_eq_zero {a : \u03b1} {l : list \u03b1} (h : count a l = 0) : a \u2209 l :=\n\u03bb h', ne_of_gt (count_pos.2 h') h\n\n@[simp] theorem count_repeat (a : \u03b1) (n : \u2115) : count a (repeat a n) = n :=\nby rw [count, countp_eq_length_filter, filter_eq_self.2, length_repeat];\n   exact \u03bb b m, (eq_of_mem_repeat m).symm\n\ntheorem le_count_iff_repeat_sublist {a : \u03b1} {l : list \u03b1} {n : \u2115} :\n  n \u2264 count a l \u2194 repeat a n <+ l :=\n\u27e8\u03bb h, ((repeat_sublist_repeat a).2 h).trans $\n  have filter (eq a) l = repeat a (count a l), from eq_repeat.2\n    \u27e8by simp only [count, countp_eq_length_filter], \u03bb b m, (of_mem_filter m).symm\u27e9,\n  by rw \u2190 this; apply filter_sublist,\n \u03bb h, by simpa only [count_repeat] using count_le_of_sublist a h\u27e9\n\ntheorem repeat_count_eq_of_count_eq_length  {a : \u03b1} {l : list \u03b1} (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 \u03b1} (h : p a) : count a (filter p l) = count a l :=\nby simp only [count, countp_filter]; congr; exact\nset.ext (\u03bb b, and_iff_left_of_imp (\u03bb e, e \u25b8 h))\n\nend count\n\n/-! ### prefix, suffix, infix -/\n\n@[simp] theorem prefix_append (l\u2081 l\u2082 : list \u03b1) : l\u2081 <+: l\u2081 ++ l\u2082 := \u27e8l\u2082, rfl\u27e9\n\n@[simp] theorem suffix_append (l\u2081 l\u2082 : list \u03b1) : l\u2082 <:+ l\u2081 ++ l\u2082 := \u27e8l\u2081, rfl\u27e9\n\ntheorem infix_append (l\u2081 l\u2082 l\u2083 : list \u03b1) : l\u2082 <:+: l\u2081 ++ l\u2082 ++ l\u2083 := \u27e8l\u2081, l\u2083, rfl\u27e9\n\n@[simp] theorem infix_append' (l\u2081 l\u2082 l\u2083 : list \u03b1) : l\u2082 <:+: l\u2081 ++ (l\u2082 ++ l\u2083) :=\nby rw \u2190 list.append_assoc; apply infix_append\n\ntheorem nil_prefix (l : list \u03b1) : [] <+: l := \u27e8l, rfl\u27e9\n\ntheorem nil_suffix (l : list \u03b1) : [] <:+ l := \u27e8l, append_nil _\u27e9\n\n@[refl] theorem prefix_refl (l : list \u03b1) : l <+: l := \u27e8[], append_nil _\u27e9\n\n@[refl] theorem suffix_refl (l : list \u03b1) : l <:+ l := \u27e8[], rfl\u27e9\n\n@[simp] theorem suffix_cons (a : \u03b1) : \u2200 l, l <:+ a :: l := suffix_append [a]\n\ntheorem prefix_concat (a : \u03b1) (l) : l <+: concat l a := by simp\n\ntheorem infix_of_prefix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+: l\u2082 \u2192 l\u2081 <:+: l\u2082 :=\n\u03bb\u27e8t, h\u27e9, \u27e8[], t, h\u27e9\n\ntheorem infix_of_suffix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+ l\u2082 \u2192 l\u2081 <:+: l\u2082 :=\n\u03bb\u27e8t, h\u27e9, \u27e8t, [], by simp only [h, append_nil]\u27e9\n\n@[refl] theorem infix_refl (l : list \u03b1) : l <:+: l := infix_of_prefix $ prefix_refl l\n\ntheorem nil_infix (l : list \u03b1) : [] <:+: l := infix_of_prefix $ nil_prefix l\n\ntheorem infix_cons {L\u2081 L\u2082 : list \u03b1} {x : \u03b1} : L\u2081 <:+: L\u2082 \u2192 L\u2081 <:+: x :: L\u2082 :=\n\u03bb\u27e8LP, LS, H\u27e9, \u27e8x :: LP, LS, H \u25b8 rfl\u27e9\n\n@[trans] theorem is_prefix.trans : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1}, l\u2081 <+: l\u2082 \u2192 l\u2082 <+: l\u2083 \u2192 l\u2081 <+: l\u2083\n| l ._ ._ \u27e8r\u2081, rfl\u27e9 \u27e8r\u2082, rfl\u27e9 := \u27e8r\u2081 ++ r\u2082, (append_assoc _ _ _).symm\u27e9\n\n@[trans] theorem is_suffix.trans : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1}, l\u2081 <:+ l\u2082 \u2192 l\u2082 <:+ l\u2083 \u2192 l\u2081 <:+ l\u2083\n| l ._ ._ \u27e8l\u2081, rfl\u27e9 \u27e8l\u2082, rfl\u27e9 := \u27e8l\u2082 ++ l\u2081, append_assoc _ _ _\u27e9\n\n@[trans] theorem is_infix.trans : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1}, l\u2081 <:+: l\u2082 \u2192 l\u2082 <:+: l\u2083 \u2192 l\u2081 <:+: l\u2083\n| l ._ ._ \u27e8l\u2081, r\u2081, rfl\u27e9 \u27e8l\u2082, r\u2082, rfl\u27e9 := \u27e8l\u2082 ++ l\u2081, r\u2081 ++ r\u2082, by simp only [append_assoc]\u27e9\n\ntheorem sublist_of_infix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+: l\u2082 \u2192 l\u2081 <+ l\u2082 :=\n\u03bb\u27e8s, t, h\u27e9, by rw [\u2190 h]; exact (sublist_append_right _ _).trans (sublist_append_left _ _)\n\ntheorem sublist_of_prefix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+: l\u2082 \u2192 l\u2081 <+ l\u2082 :=\nsublist_of_infix \u2218 infix_of_prefix\n\ntheorem sublist_of_suffix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+ l\u2082 \u2192 l\u2081 <+ l\u2082 :=\nsublist_of_infix \u2218 infix_of_suffix\n\ntheorem reverse_suffix {l\u2081 l\u2082 : list \u03b1} : reverse l\u2081 <:+ reverse l\u2082 \u2194 l\u2081 <+: l\u2082 :=\n\u27e8\u03bb \u27e8r, e\u27e9, \u27e8reverse r,\n  by rw [\u2190 reverse_reverse l\u2081, \u2190 reverse_append, e, reverse_reverse]\u27e9,\n \u03bb \u27e8r, e\u27e9, \u27e8reverse r, by rw [\u2190 reverse_append, e]\u27e9\u27e9\n\ntheorem reverse_prefix {l\u2081 l\u2082 : list \u03b1} : reverse l\u2081 <+: reverse l\u2082 \u2194 l\u2081 <:+ l\u2082 :=\nby rw \u2190 reverse_suffix; simp only [reverse_reverse]\n\ntheorem length_le_of_infix {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <:+: l\u2082) : length l\u2081 \u2264 length l\u2082 :=\nlength_le_of_sublist $ sublist_of_infix s\n\ntheorem eq_nil_of_infix_nil {l : list \u03b1} (s : l <:+: []) : l = [] :=\neq_nil_of_sublist_nil $ sublist_of_infix s\n\n@[simp] theorem eq_nil_iff_infix_nil {l : list \u03b1} : l <:+: [] \u2194 l = [] :=\n\u27e8eq_nil_of_infix_nil, \u03bb h, h \u25b8 infix_refl _\u27e9\n\ntheorem eq_nil_of_prefix_nil {l : list \u03b1} (s : l <+: []) : l = [] :=\neq_nil_of_infix_nil $ infix_of_prefix s\n\n@[simp] theorem eq_nil_iff_prefix_nil {l : list \u03b1} : l <+: [] \u2194 l = [] :=\n\u27e8eq_nil_of_prefix_nil, \u03bb h, h \u25b8 prefix_refl _\u27e9\n\ntheorem eq_nil_of_suffix_nil {l : list \u03b1} (s : l <:+ []) : l = [] :=\neq_nil_of_infix_nil $ infix_of_suffix s\n\n@[simp] theorem eq_nil_iff_suffix_nil {l : list \u03b1} : l <:+ [] \u2194 l = [] :=\n\u27e8eq_nil_of_suffix_nil, \u03bb h, h \u25b8 suffix_refl _\u27e9\n\ntheorem infix_iff_prefix_suffix (l\u2081 l\u2082 : list \u03b1) : l\u2081 <:+: l\u2082 \u2194 \u2203 t, l\u2081 <+: t \u2227 t <:+ l\u2082 :=\n\u27e8\u03bb\u27e8s, t, e\u27e9, \u27e8l\u2081 ++ t, \u27e8_, rfl\u27e9, by rw [\u2190 e, append_assoc]; exact \u27e8_, rfl\u27e9\u27e9,\n\u03bb\u27e8._, \u27e8t, rfl\u27e9, \u27e8s, e\u27e9\u27e9, \u27e8s, t, by rw append_assoc; exact e\u27e9\u27e9\n\ntheorem eq_of_infix_of_length_eq {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <:+: l\u2082) :\n  length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082 :=\neq_of_sublist_of_length_eq $ sublist_of_infix s\n\ntheorem eq_of_prefix_of_length_eq {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <+: l\u2082) :\n  length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082 :=\neq_of_sublist_of_length_eq $ sublist_of_prefix s\n\ntheorem eq_of_suffix_of_length_eq {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <:+ l\u2082) :\n  length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082 :=\neq_of_sublist_of_length_eq $ sublist_of_suffix s\n\ntheorem prefix_of_prefix_length_le : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1},\n l\u2081 <+: l\u2083 \u2192 l\u2082 <+: l\u2083 \u2192 length l\u2081 \u2264 length l\u2082 \u2192 l\u2081 <+: l\u2082\n| []      l\u2082 l\u2083 h\u2081 h\u2082 _ := nil_prefix _\n| (a::l\u2081) (b::l\u2082) _ \u27e8r\u2081, rfl\u27e9 \u27e8r\u2082, e\u27e9 ll := begin\n  injection e with _ e', subst b,\n  rcases prefix_of_prefix_length_le \u27e8_, rfl\u27e9 \u27e8_, e'\u27e9\n    (le_of_succ_le_succ ll) with \u27e8r\u2083, rfl\u27e9,\n  exact \u27e8r\u2083, rfl\u27e9\nend\n\ntheorem prefix_or_prefix_of_prefix {l\u2081 l\u2082 l\u2083 : list \u03b1}\n (h\u2081 : l\u2081 <+: l\u2083) (h\u2082 : l\u2082 <+: l\u2083) : l\u2081 <+: l\u2082 \u2228 l\u2082 <+: l\u2081 :=\n(le_total (length l\u2081) (length l\u2082)).imp\n  (prefix_of_prefix_length_le h\u2081 h\u2082)\n  (prefix_of_prefix_length_le h\u2082 h\u2081)\n\ntheorem suffix_of_suffix_length_le {l\u2081 l\u2082 l\u2083 : list \u03b1}\n (h\u2081 : l\u2081 <:+ l\u2083) (h\u2082 : l\u2082 <:+ l\u2083) (ll : length l\u2081 \u2264 length l\u2082) : l\u2081 <:+ l\u2082 :=\nreverse_prefix.1 $ prefix_of_prefix_length_le\n  (reverse_prefix.2 h\u2081) (reverse_prefix.2 h\u2082) (by simp [ll])\n\ntheorem suffix_or_suffix_of_suffix {l\u2081 l\u2082 l\u2083 : list \u03b1}\n (h\u2081 : l\u2081 <:+ l\u2083) (h\u2082 : l\u2082 <:+ l\u2083) : l\u2081 <:+ l\u2082 \u2228 l\u2082 <:+ l\u2081 :=\n(prefix_or_prefix_of_prefix (reverse_prefix.2 h\u2081) (reverse_prefix.2 h\u2082)).imp\n  reverse_prefix.1 reverse_prefix.1\n\ntheorem suffix_cons_iff {x : \u03b1} {l\u2081 l\u2082 : list \u03b1} :\n  l\u2081 <:+ x :: l\u2082 \u2194 l\u2081 = x :: l\u2082 \u2228 l\u2081 <:+ l\u2082 :=\nbegin\n  split,\n  { rintro \u27e8\u27e8hd, tl\u27e9, hl\u2083\u27e9,\n    { exact or.inl hl\u2083 },\n    { simp only [cons_append] at hl\u2083,\n      exact or.inr \u27e8_, hl\u2083.2\u27e9 } },\n  { rintro (rfl | hl\u2081),\n    { exact (x :: l\u2082).suffix_refl },\n    { exact hl\u2081.trans (l\u2082.suffix_cons _) } }\nend\n\ntheorem infix_of_mem_join : \u2200 {L : list (list \u03b1)} {l}, l \u2208 L \u2192 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\u2081 l\u2082 : list \u03b1} (l) : l ++ l\u2081 <+: l ++ l\u2082 \u2194 l\u2081 <+: l\u2082 :=\nexists_congr $ \u03bb r, by rw [append_assoc, append_right_inj]\n\ntheorem prefix_cons_inj {l\u2081 l\u2082 : list \u03b1} (a) : a :: l\u2081 <+: a :: l\u2082 \u2194 l\u2081 <+: l\u2082 :=\nprefix_append_right_inj [a]\n\ntheorem take_prefix (n) (l : list \u03b1) : take n l <+: l := \u27e8_, take_append_drop _ _\u27e9\n\ntheorem drop_suffix (n) (l : list \u03b1) : drop n l <:+ l := \u27e8_, take_append_drop _ _\u27e9\n\ntheorem tail_suffix (l : list \u03b1) : tail l <:+ l := by rw \u2190 drop_one; apply drop_suffix\n\nlemma tail_sublist (l : list \u03b1) : l.tail <+ l := sublist_of_suffix (tail_suffix l)\n\ntheorem tail_subset (l : list \u03b1) : tail l \u2286 l := (tail_sublist l).subset\n\ntheorem prefix_iff_eq_append {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+: l\u2082 \u2194 l\u2081 ++ drop (length l\u2081) l\u2082 = l\u2082 :=\n\u27e8by rintros \u27e8r, rfl\u27e9; rw drop_left, \u03bb e, \u27e8_, e\u27e9\u27e9\n\ntheorem suffix_iff_eq_append {l\u2081 l\u2082 : list \u03b1} :\n  l\u2081 <:+ l\u2082 \u2194 take (length l\u2082 - length l\u2081) l\u2082 ++ l\u2081 = l\u2082 :=\n\u27e8by rintros \u27e8r, rfl\u27e9; simp only [length_append, nat.add_sub_cancel, take_left], \u03bb e, \u27e8_, e\u27e9\u27e9\n\ntheorem prefix_iff_eq_take {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+: l\u2082 \u2194 l\u2081 = take (length l\u2081) l\u2082 :=\n\u27e8\u03bb h, append_right_cancel $\n  (prefix_iff_eq_append.1 h).trans (take_append_drop _ _).symm,\n \u03bb e, e.symm \u25b8 take_prefix _ _\u27e9\n\ntheorem suffix_iff_eq_drop {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+ l\u2082 \u2194 l\u2081 = drop (length l\u2082 - length l\u2081) l\u2082 :=\n\u27e8\u03bb h, append_left_cancel $\n  (suffix_iff_eq_append.1 h).trans (take_append_drop _ _).symm,\n \u03bb e, e.symm \u25b8 drop_suffix _ _\u27e9\n\ninstance decidable_prefix [decidable_eq \u03b1] : \u2200 (l\u2081 l\u2082 : list \u03b1), decidable (l\u2081 <+: l\u2082)\n| []      l\u2082 := is_true \u27e8l\u2082, rfl\u27e9\n| (a::l\u2081) [] := is_false $ \u03bb \u27e8t, te\u27e9, list.no_confusion te\n| (a::l\u2081) (b::l\u2082) :=\n  if h : a = b then\n    @decidable_of_iff _ _ (by rw [\u2190 h, prefix_cons_inj])\n      (decidable_prefix l\u2081 l\u2082)\n  else\n    is_false $ \u03bb \u27e8t, te\u27e9, h $ by injection te\n\n-- Alternatively, use mem_tails\ninstance decidable_suffix [decidable_eq \u03b1] : \u2200 (l\u2081 l\u2082 : list \u03b1), decidable (l\u2081 <:+ l\u2082)\n| []      l\u2082 := is_true \u27e8l\u2082, append_nil _\u27e9\n| (a::l\u2081) [] := is_false $ mt (length_le_of_sublist \u2218 sublist_of_suffix) dec_trivial\n| l\u2081      l\u2082 := let len1 := length l\u2081, len2 := length l\u2082 in\n  if hl : len1 \u2264 len2 then\n    decidable_of_iff' (l\u2081 = drop (len2-len1) l\u2082) suffix_iff_eq_drop\n  else is_false $ \u03bb h, hl $ length_le_of_sublist $ sublist_of_suffix h\n\nlemma prefix_take_le_iff {L : list (list (option \u03b1))} {m n : \u2115} (hm : m < L.length) :\n  (take m L) <+: (take n L) \u2194 m \u2264 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 \u27e8nat.succ_le_succ, nat.le_of_succ_le_succ\u27e9 } } },\nend\n\nlemma cons_prefix_iff {l l' : list \u03b1} {x y : \u03b1} :\n  x :: l <+: y :: l' \u2194 x = y \u2227 l <+: l' :=\nbegin\n  split,\n  { rintro \u27e8L, hL\u27e9,\n    simp only [cons_append] at hL,\n    exact \u27e8hL.left, \u27e8L, hL.right\u27e9\u27e9 },\n  { rintro \u27e8rfl, h\u27e9,\n    rwa [prefix_cons_inj] },\nend\n\nlemma map_prefix {l l' : list \u03b1} (f : \u03b1 \u2192 \u03b2) (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 \u03b1} (h : l <+: l') (f : \u03b1 \u2192 option \u03b2) :\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 [\u2190@singleton_append _ hd _, \u2190@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 \u03b1)} (h : l <+: l') :\n  l.reduce_option <+: l'.reduce_option :=\nh.filter_map id\n\n@[simp] theorem mem_inits : \u2200 (s t : list \u03b1), s \u2208 inits t \u2194 s <+: t\n| s []     := suffices s = nil \u2194 s <+: nil, by simpa only [inits, mem_singleton],\n  \u27e8\u03bbh, h.symm \u25b8 prefix_refl [], eq_nil_of_prefix_nil\u27e9\n| s (a::t) :=\n  suffices (s = nil \u2228 \u2203 l \u2208 inits t, a :: l = s) \u2194 s <+: a :: t, by simpa,\n  \u27e8\u03bbo, match s, o with\n  | ._, or.inl rfl := \u27e8_, rfl\u27e9\n  | s, or.inr \u27e8r, hr, hs\u27e9 := let \u27e8s, ht\u27e9 := (mem_inits _ _).1 hr in\n    by rw [\u2190 hs, \u2190 ht]; exact \u27e8s, rfl\u27e9\n  end, \u03bbmi, match s, mi with\n  | [], \u27e8._, rfl\u27e9 := or.inl rfl\n  | (b::s), \u27e8r, hr\u27e9 := list.no_confusion hr $ \u03bbba (st : s++r = t), or.inr $\n    by rw ba; exact \u27e8_, (mem_inits _ _).2 \u27e8_, st\u27e9, rfl\u27e9\n  end\u27e9\n\n@[simp] theorem mem_tails : \u2200 (s t : list \u03b1), s \u2208 tails t \u2194 s <:+ t\n| s []     := by simp only [tails, mem_singleton];\n  exact \u27e8\u03bbh, by rw h; exact suffix_refl [], eq_nil_of_suffix_nil\u27e9\n| s (a::t) := by simp only [tails, mem_cons_iff, mem_tails s t];\n  exact show s = a :: t \u2228 s <:+ t \u2194 s <:+ a :: t, from\n  \u27e8\u03bbo, match s, t, o with\n  | ._, t, or.inl rfl := suffix_refl _\n  | s, ._, or.inr \u27e8l, rfl\u27e9 := \u27e8a::l, rfl\u27e9\n  end, \u03bbe, match s, t, e with\n  | ._, t, \u27e8[], rfl\u27e9 := or.inl rfl\n  | s, t, \u27e8b::l, he\u27e9 := list.no_confusion he (\u03bbab lt, or.inr \u27e8l, lt\u27e9)\n  end\u27e9\n\nlemma inits_cons (a : \u03b1) (l : list \u03b1) : inits (a :: l) = [] :: l.inits.map (\u03bb t, a :: t) :=\nby simp\n\nlemma tails_cons (a : \u03b1) (l : list \u03b1) : tails (a :: l) = (a :: l) :: l.tails :=\nby simp\n\n@[simp]\nlemma inits_append : \u2200 (s t : list \u03b1), inits (s ++ t) = s.inits ++ t.inits.tail.map (\u03bb 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 : \u2200 (s t : list \u03b1), tails (s ++ t) = s.tails.map (\u03bb 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  \u2200 (l : list \u03b1), 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  \u2200 (l : list \u03b1), 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 \u03b1) : 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 \u03b1) : 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 \u03b1) : 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 \u03b1) : 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 \u03b1] : \u2200 (l\u2081 l\u2082 : list \u03b1), decidable (l\u2081 <:+: l\u2082)\n| []      l\u2082 := is_true \u27e8[], l\u2082, rfl\u27e9\n| (a::l\u2081) [] := is_false $ \u03bb\u27e8s, t, te\u27e9, absurd te $ append_ne_nil_of_ne_nil_left _ _ $\n                append_ne_nil_of_ne_nil_right _ _ $ \u03bbh, list.no_confusion h\n| l\u2081      l\u2082 := decidable_of_decidable_of_iff (list.decidable_bex (\u03bbt, l\u2081 <+: t) (tails l\u2082)) $\n  by refine (exists_congr (\u03bbt, _)).trans (infix_iff_prefix_suffix _ _).symm;\n     exact \u27e8\u03bb\u27e8h1, h2\u27e9, \u27e8h2, (mem_tails _ _).1 h1\u27e9, \u03bb\u27e8h2, h1\u27e9, \u27e8(mem_tails _ _).2 h1, h2\u27e9\u27e9\n\n/-! ### sublists -/\n\n@[simp] theorem sublists'_nil : sublists' (@nil \u03b1) = [[]] := rfl\n\n@[simp, priority 1100] theorem sublists'_singleton (a : \u03b1) : sublists' [a] = [[], [a]] := rfl\n\ntheorem map_sublists'_aux (g : list \u03b2 \u2192 list \u03b3) (l : list \u03b1) (f r) :\n  map g (sublists'_aux l f r) = sublists'_aux l (g \u2218 f) (map g r) :=\nby induction l generalizing f r; [refl, simp only [*, sublists'_aux]]\n\ntheorem sublists'_aux_append (r' : list (list \u03b2)) (l : list \u03b1) (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 \u03b1 \u03b2 l f r = map f (sublists' l) ++ r :=\nby rw [sublists', map_sublists'_aux, \u2190 sublists'_aux_append]; refl\n\n@[simp] theorem sublists'_cons (a : \u03b1) (l : list \u03b1) :\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 \u03b1} : s \u2208 sublists' t \u2194 s <+ t :=\nbegin\n  induction t with a t IH generalizing s,\n  { simp only [sublists'_nil, mem_singleton],\n    exact \u27e8\u03bb h, by rw h, eq_nil_of_sublist_nil\u27e9 },\n  simp only [sublists'_cons, mem_append, IH, mem_map],\n  split; intro h, rcases h with h | \u27e8s, h, rfl\u27e9,\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 \u27e8s, h, rfl\u27e9 } }\nend\n\n@[simp] theorem length_sublists' : \u2200 l : list \u03b1, 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 \u03b1) = [[]] := rfl\n\n@[simp] theorem sublists_singleton (a : \u03b1) : sublists [a] = [[], [a]] := rfl\n\ntheorem sublists_aux\u2081_eq_sublists_aux : \u2200 l (f : list \u03b1 \u2192 list \u03b2),\n  sublists_aux\u2081 l f = sublists_aux l (\u03bb ys r, f ys ++ r)\n| []     f := rfl\n| (a::l) f := by rw [sublists_aux\u2081, sublists_aux]; simp only [*, append_assoc]\n\ntheorem sublists_aux_cons_eq_sublists_aux\u2081 (l : list \u03b1) :\n  sublists_aux l cons = sublists_aux\u2081 l (\u03bb x, [x]) :=\nby rw [sublists_aux\u2081_eq_sublists_aux]; refl\n\ntheorem sublists_aux_eq_foldr.aux {a : \u03b1} {l : list \u03b1}\n  (IH\u2081 : \u2200 (f : list \u03b1 \u2192 list \u03b2 \u2192 list \u03b2), sublists_aux l f = foldr f [] (sublists_aux l cons))\n  (IH\u2082 : \u2200 (f : list \u03b1 \u2192 list (list \u03b1) \u2192 list (list \u03b1)),\n      sublists_aux l f = foldr f [] (sublists_aux l cons))\n  (f : list \u03b1 \u2192 list \u03b2 \u2192 list \u03b2) : sublists_aux (a::l) f = foldr f [] (sublists_aux (a::l) cons) :=\nbegin\n  simp only [sublists_aux, foldr_cons], rw [IH\u2082, IH\u2081], 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 \u03b1) : \u2200 (f : list \u03b1 \u2192 list \u03b2 \u2192 list \u03b2),\n  sublists_aux l f = foldr f [] (sublists_aux l cons) :=\nsuffices _ \u2227 \u2200 f : list \u03b1 \u2192 list (list \u03b1) \u2192 list (list \u03b1),\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 \u27e8sublists_aux_eq_foldr.aux IH.1 IH.2,\n         sublists_aux_eq_foldr.aux IH.2 IH.2\u27e9\nend\n\ntheorem sublists_aux_cons_cons (l : list \u03b1) (a : \u03b1) :\n  sublists_aux (a::l) cons = [a] :: foldr (\u03bbys r, ys :: (a :: ys) :: r) [] (sublists_aux l cons) :=\nby rw [\u2190 sublists_aux_eq_foldr]; refl\n\ntheorem sublists_aux\u2081_append : \u2200 (l\u2081 l\u2082 : list \u03b1) (f : list \u03b1 \u2192 list \u03b2),\n  sublists_aux\u2081 (l\u2081 ++ l\u2082) f = sublists_aux\u2081 l\u2081 f ++\n    sublists_aux\u2081 l\u2082 (\u03bb x, f x ++ sublists_aux\u2081 l\u2081 (f \u2218 (++ x)))\n| []      l\u2082 f := by simp only [sublists_aux\u2081, nil_append, append_nil]\n| (a::l\u2081) l\u2082 f := by simp only [sublists_aux\u2081, cons_append, sublists_aux\u2081_append l\u2081, append_assoc];\n  refl\n\ntheorem sublists_aux\u2081_concat (l : list \u03b1) (a : \u03b1) (f : list \u03b1 \u2192 list \u03b2) :\n  sublists_aux\u2081 (l ++ [a]) f = sublists_aux\u2081 l f ++\n    f [a] ++ sublists_aux\u2081 l (\u03bb x, f (x ++ [a])) :=\nby simp only [sublists_aux\u2081_append, sublists_aux\u2081, append_assoc, append_nil]\n\ntheorem sublists_aux\u2081_bind : \u2200 (l : list \u03b1)\n  (f : list \u03b1 \u2192 list \u03b2) (g : \u03b2 \u2192 list \u03b3),\n  (sublists_aux\u2081 l f).bind g = sublists_aux\u2081 l (\u03bb x, (f x).bind g)\n| []     f g := rfl\n| (a::l) f g := by simp only [sublists_aux\u2081, bind_append, sublists_aux\u2081_bind l]\n\ntheorem sublists_aux_cons_append (l\u2081 l\u2082 : list \u03b1) :\n  sublists_aux (l\u2081 ++ l\u2082) cons = sublists_aux l\u2081 cons ++\n    (do x \u2190 sublists_aux l\u2082 cons, (++ x) <$> sublists l\u2081) :=\nbegin\n  simp only [sublists, sublists_aux_cons_eq_sublists_aux\u2081, sublists_aux\u2081_append, bind_eq_bind,\n    sublists_aux\u2081_bind],\n  congr, funext x, apply congr_arg _,\n  rw [\u2190 bind_ret_eq_map, sublists_aux\u2081_bind], exact (append_nil _).symm\nend\n\ntheorem sublists_append (l\u2081 l\u2082 : list \u03b1) :\n  sublists (l\u2081 ++ l\u2082) = (do x \u2190 sublists l\u2082, (++ x) <$> sublists l\u2081) :=\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' (\u03bb _, rfl)]; split; refl\n\n@[simp] theorem sublists_concat (l : list \u03b1) (a : \u03b1) :\n  sublists (l ++ [a]) = sublists l ++ map (\u03bb 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 \u03b1) : 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, (\u2218)]]\n\ntheorem sublists_eq_sublists' (l : list \u03b1) : sublists l = map reverse (sublists' (reverse l)) :=\nby rw [\u2190 sublists_reverse, reverse_reverse]\n\ntheorem sublists'_reverse (l : list \u03b1) : 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 \u03b1) : sublists' l = map reverse (sublists (reverse l)) :=\nby rw [\u2190 sublists'_reverse, reverse_reverse]\n\ntheorem sublists_aux_ne_nil : \u2200 (l : list \u03b1), [] \u2209 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 \u27e8ne_of_not_mem_cons this, ih (not_mem_of_not_mem_cons this)\u27e9\nend\n\n@[simp] theorem mem_sublists {s t : list \u03b1} : s \u2208 sublists t \u2194 s <+ t :=\nby rw [\u2190 reverse_sublist_iff, \u2190 mem_sublists',\n       sublists'_reverse, mem_map_of_injective reverse_injective]\n\n@[simp] theorem length_sublists (l : list \u03b1) : 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 \u03b1) : map list.ret l <+ sublists l :=\nreverse_rec_on l (nil_sublist _) $\n\u03bb 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 \u27e8[], mem_sublists.2 (nil_sublist _), by refl\u27e9).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 {\u03b1 \u03b2 : Type*} : \u2115 \u2192 list \u03b1 \u2192 (list \u03b1 \u2192 \u03b2) \u2192 list \u03b2 \u2192 list \u03b2\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 \u2218 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 {\u03b1 : Type*} (n : \u2115) (l : list \u03b1) : list (list \u03b1) :=\nsublists_len_aux n l id []\n\nlemma sublists_len_aux_append {\u03b1 \u03b2 \u03b3 : Type*} :\n  \u2200 (n : \u2115) (l : list \u03b1) (f : list \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (r : list \u03b2) (s : list \u03b3),\n  sublists_len_aux n l (g \u2218 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 \u2218 f) \u2218 list.cons a) = (g \u2218 f \u2218 list.cons a), by refl,\n    sublists_len_aux_append, sublists_len_aux_append]\nend\n\nlemma sublists_len_aux_eq {\u03b1 \u03b2 : Type*} (l : list \u03b1) (n) (f : list \u03b1 \u2192 \u03b2) (r) :\n  sublists_len_aux n l f r = (sublists_len n l).map f ++ r :=\nby rw [sublists_len, \u2190 sublists_len_aux_append]; refl\n\nlemma sublists_len_aux_zero {\u03b1 : Type*} (l : list \u03b1) (f : list \u03b1 \u2192 \u03b2) (r) :\n  sublists_len_aux 0 l f r = f [] :: r := by cases l; refl\n\n@[simp] lemma sublists_len_zero {\u03b1 : Type*} (l : list \u03b1) :\n  sublists_len 0 l = [[]] := sublists_len_aux_zero _ _ _\n\n@[simp] lemma sublists_len_succ_nil {\u03b1 : Type*} (n) :\n  sublists_len (n+1) (@nil \u03b1) = [] := rfl\n\n@[simp] lemma sublists_len_succ_cons {\u03b1 : Type*} (n) (a : \u03b1) (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 {\u03b1 : Type*} : \u2200 n (l : list \u03b1),\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' {\u03b1 : Type*} : \u2200 n (l : list \u03b1),\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  {\u03b1 : Type*} (n) {l\u2081 l\u2082 : list \u03b1} (h : l\u2081 <+ l\u2082) : sublists_len n l\u2081 <+ sublists_len n l\u2082 :=\nbegin\n  induction n with n IHn generalizing l\u2081 l\u2082, {simp},\n  induction h with l\u2081 l\u2082 a s IH l\u2081 l\u2082 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 {\u03b1 : Type*} : \u2200 {n} {l l' : list \u03b1},\n  l' \u2208 sublists_len n l \u2192 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 | \u27e8l', h, rfl\u27e9,\n  { exact length_of_sublists_len h },\n  { exact congr_arg (+1) (length_of_sublists_len h) },\nend\n\nlemma mem_sublists_len_self {\u03b1 : Type*} {l l' : list \u03b1}\n  (h : l' <+ l) : l' \u2208 sublists_len (length l') l :=\nbegin\n  induction h with l\u2081 l\u2082 a s IH l\u2081 l\u2082 a s IH,\n  { exact or.inl rfl },\n  { cases l\u2081 with b l\u2081,\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 \u27e8_, IH, rfl\u27e9) }\nend\n\n@[simp] lemma mem_sublists_len {\u03b1 : Type*} {n} {l l' : list \u03b1} :\n  l' \u2208 sublists_len n l \u2194 l' <+ l \u2227 length l' = n :=\n\u27e8\u03bb h, \u27e8mem_sublists'.1\n    ((sublists_len_sublist_sublists' _ _).subset h),\n  length_of_sublists_len h\u27e9,\n\u03bb \u27e8h\u2081, h\u2082\u27e9, h\u2082 \u25b8 mem_sublists_len_self h\u2081\u27e9\n\n/-! ### permutations -/\n\nsection permutations\n\n@[simp] theorem permutations_aux_nil (is : list \u03b1) : permutations_aux [] is = [] :=\nby rw [permutations_aux, permutations_aux.rec]\n\n@[simp] theorem permutations_aux_cons (t : \u03b1) (ts is : list \u03b1) :\n  permutations_aux (t :: ts) is = foldr (\u03bby 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 \u03b1]\n\n@[simp] theorem insert_nil (a : \u03b1) : insert a nil = [a] := rfl\n\ntheorem insert.def (a : \u03b1) (l : list \u03b1) : insert a l = if a \u2208 l then l else a :: l := rfl\n\n@[simp, priority 980]\ntheorem insert_of_mem {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) : insert a l = l :=\nby simp only [insert.def, if_pos h]\n\n@[simp, priority 970]\ntheorem insert_of_not_mem {a : \u03b1} {l : list \u03b1} (h : a \u2209 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 : \u03b1} {l : list \u03b1} : a \u2208 insert b l \u2194 a = b \u2228 a \u2208 l :=\nbegin\n  by_cases h' : b \u2208 l,\n  { simp only [insert_of_mem h'],\n    apply (or_iff_right_of_imp _).symm,\n    exact \u03bb e, e.symm \u25b8 h' },\n  simp only [insert_of_not_mem h', mem_cons_iff]\nend\n\n@[simp] theorem suffix_insert (a : \u03b1) (l : list \u03b1) : l <:+ insert a l :=\nby by_cases a \u2208 l; [simp only [insert_of_mem h], simp only [insert_of_not_mem h, suffix_cons]]\n\n@[simp] theorem mem_insert_self (a : \u03b1) (l : list \u03b1) : a \u2208 insert a l :=\nmem_insert_iff.2 (or.inl rfl)\n\ntheorem mem_insert_of_mem {a b : \u03b1} {l : list \u03b1} (h : a \u2208 l) : a \u2208 insert b l :=\nmem_insert_iff.2 (or.inr h)\n\ntheorem eq_or_mem_of_mem_insert {a b : \u03b1} {l : list \u03b1} (h : a \u2208 insert b l) : a = b \u2228 a \u2208 l :=\nmem_insert_iff.1 h\n\n@[simp] theorem length_insert_of_mem {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) :\n  length (insert a l) = length l :=\nby rw insert_of_mem h\n\n@[simp] theorem length_insert_of_not_mem {a : \u03b1} {l : list \u03b1} (h : a \u2209 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 : \u03b1 \u2192 Prop} [decidable_pred p]\n\n@[simp] theorem erasep_nil : [].erasep p = [] := rfl\n\ntheorem erasep_cons (a : \u03b1) (l : list \u03b1) :\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 : \u03b1} {l : list \u03b1} (h : p a) : (a :: l).erasep p = l :=\nby simp [erasep_cons, h]\n\n@[simp] theorem erasep_cons_of_neg {a : \u03b1} {l : list \u03b1} (h : \u00ac p a) :\n  (a::l).erasep p = a :: l.erasep p :=\nby simp [erasep_cons, h]\n\ntheorem erasep_of_forall_not {l : list \u03b1}\n  (h : \u2200 a \u2208 l, \u00ac 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 \u03b1} {a} (al : a \u2208 l) (pa : p a) :\n  \u2203 a l\u2081 l\u2082, (\u2200 b \u2208 l\u2081, \u00ac p b) \u2227 p a \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.erasep p = l\u2081 ++ l\u2082 :=\nbegin\n  induction l with b l IH, {cases al},\n  by_cases pb : p b,\n  { exact \u27e8b, [], l, forall_mem_nil _, pb, by simp [pb]\u27e9 },\n  { rcases al with rfl | al, {exact pb.elim pa},\n    rcases IH al with \u27e8c, l\u2081, l\u2082, h\u2081, h\u2082, h\u2083, h\u2084\u27e9,\n    exact \u27e8c, b::l\u2081, l\u2082, forall_mem_cons.2 \u27e8pb, h\u2081\u27e9,\n      h\u2082, by rw h\u2083; refl, by simp [pb, h\u2084]\u27e9 }\nend\n\ntheorem exists_or_eq_self_of_erasep (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : list \u03b1) :\n  l.erasep p = l \u2228 \u2203 a l\u2081 l\u2082, (\u2200 b \u2208 l\u2081, \u00ac p b) \u2227 p a \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.erasep p = l\u2081 ++ l\u2082 :=\nbegin\n  by_cases h : \u2203 a \u2208 l, p a,\n  { rcases h with \u27e8a, ha, pa\u27e9,\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 \u03b1} {a} (al : a \u2208 l) (pa : p a) :\n length (l.erasep p) = pred (length l) :=\nby rcases exists_of_erasep al pa with \u27e8_, l\u2081, l\u2082, _, _, e\u2081, e\u2082\u27e9;\n   rw e\u2082; simp [-add_comm, e\u2081]; refl\n\ntheorem erasep_append_left {a : \u03b1} (pa : p a) :\n  \u2200 {l\u2081 : list \u03b1} (l\u2082), a \u2208 l\u2081 \u2192 (l\u2081++l\u2082).erasep p = l\u2081.erasep p ++ l\u2082\n| (x::xs) l\u2082 h := begin\n  by_cases h' : p x; simp [h'],\n  rw erasep_append_left l\u2082 (mem_of_ne_of_mem (mt _ h') h),\n  rintro rfl, exact pa\nend\n\ntheorem erasep_append_right :\n  \u2200 {l\u2081 : list \u03b1} (l\u2082), (\u2200 b \u2208 l\u2081, \u00ac p b) \u2192 (l\u2081++l\u2082).erasep p = l\u2081 ++ l\u2082.erasep p\n| []      l\u2082 h := rfl\n| (x::xs) l\u2082 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 \u03b1) : l.erasep p <+ l :=\nby rcases exists_or_eq_self_of_erasep p l with h | \u27e8c, l\u2081, l\u2082, h\u2081, h\u2082, h\u2083, h\u2084\u27e9;\n   [rw h, {rw [h\u2084, h\u2083], simp}]\n\ntheorem erasep_subset (l : list \u03b1) : l.erasep p \u2286 l :=\n(erasep_sublist l).subset\n\ntheorem sublist.erasep {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <+ l\u2082) : l\u2081.erasep p <+ l\u2082.erasep p :=\nbegin\n  induction s,\n  case list.sublist.slnil { refl },\n  case list.sublist.cons : l\u2081 l\u2082 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\u2081 l\u2082 a s IH {\n    by_cases h : p a; simp [h],\n    exacts [s, IH.cons2 _ _ _] }\nend\n\ntheorem mem_of_mem_erasep {a : \u03b1} {l : list \u03b1} : a \u2208 l.erasep p \u2192 a \u2208 l :=\n@erasep_subset _ _ _ _ _\n\n@[simp] theorem mem_erasep_of_neg {a : \u03b1} {l : list \u03b1} (pa : \u00ac p a) : a \u2208 l.erasep p \u2194 a \u2208 l :=\n\u27e8mem_of_mem_erasep, \u03bb al, begin\n  rcases exists_or_eq_self_of_erasep p l with h | \u27e8c, l\u2081, l\u2082, h\u2081, h\u2082, h\u2083, h\u2084\u27e9,\n  { rwa h },\n  { rw h\u2084, rw h\u2083 at al,\n    have : a \u2260 c, {rintro rfl, exact pa.elim h\u2082},\n    simpa [this] using al }\nend\u27e9\n\ntheorem erasep_map (f : \u03b2 \u2192 \u03b1) :\n  \u2200 (l : list \u03b2), (map f l).erasep p = map f (l.erasep (p \u2218 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  \u2200 l : list \u03b1, 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 \u03b1]\n\n@[simp] theorem erase_nil (a : \u03b1) : [].erase a = [] := rfl\n\ntheorem erase_cons (a b : \u03b1) (l : list \u03b1) :\n  (b :: l).erase a = if b = a then l else b :: l.erase a := rfl\n\n@[simp] theorem erase_cons_head (a : \u03b1) (l : list \u03b1) : (a :: l).erase a = l :=\nby simp only [erase_cons, if_pos rfl]\n\n@[simp] theorem erase_cons_tail {a b : \u03b1} (l : list \u03b1) (h : b \u2260 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 : \u03b1) (l : list \u03b1) : 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 : \u03b1} {l : list \u03b1} (h : a \u2209 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 : \u03b1} {l : list \u03b1} (h : a \u2208 l) :\n  \u2203 l\u2081 l\u2082, a \u2209 l\u2081 \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.erase a = l\u2081 ++ l\u2082 :=\nby rcases exists_of_erasep h rfl with \u27e8_, l\u2081, l\u2082, h\u2081, rfl, h\u2082, h\u2083\u27e9;\n   rw erase_eq_erasep; exact \u27e8l\u2081, l\u2082, \u03bb h, h\u2081 _ h rfl, h\u2082, h\u2083\u27e9\n\n@[simp] theorem length_erase_of_mem {a : \u03b1} {l : list \u03b1} (h : a \u2208 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 : \u03b1} {l\u2081 : list \u03b1} (l\u2082) (h : a \u2208 l\u2081) :\n  (l\u2081++l\u2082).erase a = l\u2081.erase a ++ l\u2082 :=\nby simp [erase_eq_erasep]; exact erasep_append_left (by refl) l\u2082 h\n\ntheorem erase_append_right {a : \u03b1} {l\u2081 : list \u03b1} (l\u2082) (h : a \u2209 l\u2081) :\n  (l\u2081++l\u2082).erase a = l\u2081 ++ l\u2082.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 : \u03b1) (l : list \u03b1) : l.erase a <+ l :=\nby rw erase_eq_erasep; apply erasep_sublist\n\ntheorem erase_subset (a : \u03b1) (l : list \u03b1) : l.erase a \u2286 l :=\n(erase_sublist a l).subset\n\ntheorem sublist.erase (a : \u03b1) {l\u2081 l\u2082 : list \u03b1} (h : l\u2081 <+ l\u2082) : l\u2081.erase a <+ l\u2082.erase a :=\nby simp [erase_eq_erasep]; exact sublist.erasep h\n\ntheorem mem_of_mem_erase {a b : \u03b1} {l : list \u03b1} : a \u2208 l.erase b \u2192 a \u2208 l :=\n@erase_subset _ _ _ _ _\n\n@[simp] theorem mem_erase_of_ne {a b : \u03b1} {l : list \u03b1} (ab : a \u2260 b) : a \u2208 l.erase b \u2194 a \u2208 l :=\nby rw erase_eq_erasep; exact mem_erasep_of_neg ab.symm\n\ntheorem erase_comm (a b : \u03b1) (l : list \u03b1) : (l.erase a).erase b = (l.erase b).erase a :=\nif ab : a = b then by rw ab else\nif ha : a \u2208 l then\nif hb : b \u2208 l then match l, l.erase a, exists_erase_eq ha, hb with\n| ._, ._, \u27e8l\u2081, l\u2082, ha', rfl, rfl\u27e9, hb :=\n  if h\u2081 : b \u2208 l\u2081 then\n    by rw [erase_append_left _ h\u2081, erase_append_left _ h\u2081,\n           erase_append_right _ (mt mem_of_mem_erase ha'), erase_cons_head]\n  else\n    by rw [erase_append_right _ h\u2081, erase_append_right _ h\u2081, 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 \u03b2] {f : \u03b1 \u2192 \u03b2} (finj : injective f) {a : \u03b1}\n  (l : list \u03b1) : 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 \u03b2] {f : \u03b1 \u2192 \u03b2} (finj : injective f) {l\u2081 l\u2082 : list \u03b1} :\n  map f (foldl list.erase l\u2081 l\u2082) = foldl (\u03bb l a, l.erase (f a)) (map f l\u2081) l\u2082 :=\nby induction l\u2082 generalizing l\u2081; [refl,\nsimp only [foldl_cons, map_erase finj, *]]\n\n@[simp] theorem count_erase_self (a : \u03b1) :\n  \u2200 (s : list \u03b1), 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 (\u03bb x : a = h, p x.symm), count_erase_self],\n    simp, }\nend\n\n@[simp] theorem count_erase_of_ne {a b : \u03b1} (ab : a \u2260 b) :\n  \u2200 (s : list \u03b1), 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 \u03b1]\n\n@[simp] theorem diff_nil (l : list \u03b1) : l.diff [] = l := rfl\n\n@[simp] theorem diff_cons (l\u2081 l\u2082 : list \u03b1) (a : \u03b1) : l\u2081.diff (a::l\u2082) = (l\u2081.erase a).diff l\u2082 :=\nif h : a \u2208 l\u2081 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\u2081 l\u2082 : list \u03b1) (a : \u03b1) : l\u2081.diff (a::l\u2082) = (l\u2081.diff l\u2082).erase a :=\nbegin\n  induction l\u2082 with b l\u2082 ih generalizing l\u2081 a,\n  { simp_rw [diff_cons, diff_nil] },\n  { rw [diff_cons, diff_cons, erase_comm, \u2190 diff_cons, ih, \u2190 diff_cons] }\nend\n\nlemma diff_erase (l\u2081 l\u2082 : list \u03b1) (a : \u03b1) : (l\u2081.diff l\u2082).erase a = (l\u2081.erase a).diff l\u2082 :=\nby rw [\u2190 diff_cons_right, diff_cons]\n\n@[simp] theorem nil_diff (l : list \u03b1) : [].diff l = [] :=\nby induction l; [refl, simp only [*, diff_cons, erase_of_not_mem (not_mem_nil _)]]\n\ntheorem diff_eq_foldl : \u2200 (l\u2081 l\u2082 : list \u03b1), l\u2081.diff l\u2082 = foldl list.erase l\u2081 l\u2082\n| l\u2081 []      := rfl\n| l\u2081 (a::l\u2082) := (diff_cons l\u2081 l\u2082 a).trans (diff_eq_foldl _ _)\n\n@[simp] theorem diff_append (l\u2081 l\u2082 l\u2083 : list \u03b1) : l\u2081.diff (l\u2082 ++ l\u2083) = (l\u2081.diff l\u2082).diff l\u2083 :=\nby simp only [diff_eq_foldl, foldl_append]\n\n@[simp] theorem map_diff [decidable_eq \u03b2] {f : \u03b1 \u2192 \u03b2} (finj : injective f) {l\u2081 l\u2082 : list \u03b1} :\n  map f (l\u2081.diff l\u2082) = (map f l\u2081).diff (map f l\u2082) :=\nby simp only [diff_eq_foldl, foldl_map, map_foldl_erase finj]\n\ntheorem diff_sublist : \u2200 l\u2081 l\u2082 : list \u03b1, l\u2081.diff l\u2082 <+ l\u2081\n| l\u2081 []      := sublist.refl _\n| l\u2081 (a::l\u2082) := calc l\u2081.diff (a :: l\u2082) = (l\u2081.erase a).diff l\u2082 : diff_cons _ _ _\n  ... <+ l\u2081.erase a : diff_sublist _ _\n  ... <+ l\u2081 : list.erase_sublist _ _\n\ntheorem diff_subset (l\u2081 l\u2082 : list \u03b1) : l\u2081.diff l\u2082 \u2286 l\u2081 :=\n(diff_sublist _ _).subset\n\ntheorem mem_diff_of_mem {a : \u03b1} : \u2200 {l\u2081 l\u2082 : list \u03b1}, a \u2208 l\u2081 \u2192 a \u2209 l\u2082 \u2192 a \u2208 l\u2081.diff l\u2082\n| l\u2081 []      h\u2081 h\u2082 := h\u2081\n| l\u2081 (b::l\u2082) h\u2081 h\u2082 := by rw diff_cons; exact\n  mem_diff_of_mem ((mem_erase_of_ne (ne_of_not_mem_cons h\u2082)).2 h\u2081) (not_mem_of_not_mem_cons h\u2082)\n\ntheorem sublist.diff_right : \u2200 {l\u2081 l\u2082 l\u2083: list \u03b1}, l\u2081 <+ l\u2082 \u2192 l\u2081.diff l\u2083 <+ l\u2082.diff l\u2083\n| l\u2081 l\u2082 [] h      := h\n| l\u2081 l\u2082 (a::l\u2083) h := by simp only\n  [diff_cons, (h.erase _).diff_right]\n\ntheorem erase_diff_erase_sublist_of_sublist {a : \u03b1} : \u2200 {l\u2081 l\u2082 : list \u03b1},\n  l\u2081 <+ l\u2082 \u2192 (l\u2082.erase a).diff (l\u2081.erase a) <+ l\u2082.diff l\u2081\n| []      l\u2082 h := erase_sublist _ _\n| (b::l\u2081) l\u2082 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\u2082]\n                  using erase_diff_erase_sublist_of_sublist (h.erase b)\n\nend diff\n\n/-! ### enum -/\n\ntheorem length_enum_from : \u2200 n (l : list \u03b1), 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 : \u2200 (l : list \u03b1), length (enum l) = length l := length_enum_from _\n\n@[simp] theorem enum_from_nth : \u2200 n (l : list \u03b1) m,\n  nth (enum_from n l) m = (\u03bb 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 : \u2200 (l : list \u03b1) n,\n  nth (enum l) n = (\u03bb 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 : \u2200 n (l : list \u03b1),\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 : \u2200 (l : list \u03b1),\n  map prod.snd (enum l) = l := enum_from_map_snd _\n\ntheorem mem_enum_from {x : \u03b1} {i : \u2115} :\n   \u2200 {j : \u2115} (xs : list \u03b1), (i, x) \u2208 xs.enum_from j \u2192 j \u2264 i \u2227 i < j + xs.length \u2227 x \u2208 xs\n| j [] := by simp [enum_from]\n| j (y :: ys) :=\nsuffices i = j \u2227 x = y \u2228 (i, x) \u2208 enum_from (j + 1) ys \u2192\n    j \u2264 i \u2227 i < j + (length ys + 1) \u2227 (x = y \u2228 x \u2208 ys),\n  by simpa [enum_from, mem_enum_from ys],\nbegin\n  rintro (h|h),\n  { refine \u27e8le_of_eq h.1.symm,h.1 \u25b8 _,or.inl h.2\u27e9,\n    apply nat.lt_add_of_pos_right; simp },\n  { obtain \u27e8hji, hijlen, hmem\u27e9 := mem_enum_from _ h,\n    refine \u27e8_, _, _\u27e9,\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 \u03b2) : product (@nil \u03b1) l = [] := rfl\n\n@[simp] theorem product_cons (a : \u03b1) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2)\n        : product (a::l\u2081) l\u2082 = map (\u03bb b, (a, b)) l\u2082 ++ product l\u2081 l\u2082 := rfl\n\n@[simp] theorem product_nil : \u2200 (l : list \u03b1), product l (@nil \u03b2) = []\n| []     := rfl\n| (a::l) := by rw [product_cons, product_nil]; refl\n\n@[simp] theorem mem_product {l\u2081 : list \u03b1} {l\u2082 : list \u03b2} {a : \u03b1} {b : \u03b2} :\n  (a, b) \u2208 product l\u2081 l\u2082 \u2194 a \u2208 l\u2081 \u2227 b \u2208 l\u2082 :=\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\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n  length (product l\u2081 l\u2082) = length l\u2081 * length l\u2082 :=\nby induction l\u2081 with x l\u2081 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 {\u03c3 : \u03b1 \u2192 Type*}\n\n@[simp] theorem nil_sigma (l : \u03a0 a, list (\u03c3 a)) : (@nil \u03b1).sigma l = [] := rfl\n\n@[simp] theorem sigma_cons (a : \u03b1) (l\u2081 : list \u03b1) (l\u2082 : \u03a0 a, list (\u03c3 a))\n        : (a::l\u2081).sigma l\u2082 = map (sigma.mk a) (l\u2082 a) ++ l\u2081.sigma l\u2082 := rfl\n\n@[simp] theorem sigma_nil : \u2200 (l : list \u03b1), l.sigma (\u03bb a, @nil (\u03c3 a)) = []\n| []     := rfl\n| (a::l) := by rw [sigma_cons, sigma_nil]; refl\n\n@[simp] theorem mem_sigma {l\u2081 : list \u03b1} {l\u2082 : \u03a0 a, list (\u03c3 a)} {a : \u03b1} {b : \u03c3 a} :\n  sigma.mk a b \u2208 l\u2081.sigma l\u2082 \u2194 a \u2208 l\u2081 \u2227 b \u2208 l\u2082 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\u2081 : list \u03b1) (l\u2082 : \u03a0 a, list (\u03c3 a)) :\n  length (l\u2081.sigma l\u2082) = (l\u2081.map (\u03bb a, length (l\u2082 a))).sum :=\nby induction l\u2081 with x l\u2081 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\u2081 l\u2082 : list \u03b1} (d : disjoint l\u2081 l\u2082) : disjoint l\u2082 l\u2081\n| a i\u2082 i\u2081 := d i\u2081 i\u2082\n\ntheorem disjoint_comm {l\u2081 l\u2082 : list \u03b1} : disjoint l\u2081 l\u2082 \u2194 disjoint l\u2082 l\u2081 :=\n\u27e8disjoint.symm, disjoint.symm\u27e9\n\ntheorem disjoint_left {l\u2081 l\u2082 : list \u03b1} : disjoint l\u2081 l\u2082 \u2194 \u2200 {a}, a \u2208 l\u2081 \u2192 a \u2209 l\u2082 := iff.rfl\n\ntheorem disjoint_right {l\u2081 l\u2082 : list \u03b1} : disjoint l\u2081 l\u2082 \u2194 \u2200 {a}, a \u2208 l\u2082 \u2192 a \u2209 l\u2081 :=\ndisjoint_comm\n\ntheorem disjoint_iff_ne {l\u2081 l\u2082 : list \u03b1} : disjoint l\u2081 l\u2082 \u2194 \u2200 a \u2208 l\u2081, \u2200 b \u2208 l\u2082, a \u2260 b :=\nby simp only [disjoint_left, imp_not_comm, forall_eq']\n\ntheorem disjoint_of_subset_left {l\u2081 l\u2082 l : list \u03b1} (ss : l\u2081 \u2286 l) (d : disjoint l l\u2082) :\n  disjoint l\u2081 l\u2082\n| x m\u2081 := d (ss m\u2081)\n\ntheorem disjoint_of_subset_right {l\u2081 l\u2082 l : list \u03b1} (ss : l\u2082 \u2286 l) (d : disjoint l\u2081 l) :\n  disjoint l\u2081 l\u2082\n| x m m\u2081 := d m (ss m\u2081)\n\ntheorem disjoint_of_disjoint_cons_left {a : \u03b1} {l\u2081 l\u2082} : disjoint (a::l\u2081) l\u2082 \u2192 disjoint l\u2081 l\u2082 :=\ndisjoint_of_subset_left (list.subset_cons _ _)\n\ntheorem disjoint_of_disjoint_cons_right {a : \u03b1} {l\u2081 l\u2082} : disjoint l\u2081 (a::l\u2082) \u2192 disjoint l\u2081 l\u2082 :=\ndisjoint_of_subset_right (list.subset_cons _ _)\n\n@[simp] theorem disjoint_nil_left (l : list \u03b1) : disjoint [] l\n| a := (not_mem_nil a).elim\n\n@[simp] theorem disjoint_nil_right (l : list \u03b1) : disjoint l [] :=\nby rw disjoint_comm; exact disjoint_nil_left _\n\n@[simp, priority 1100] theorem singleton_disjoint {l : list \u03b1} {a : \u03b1} : disjoint [a] l \u2194 a \u2209 l :=\nby simp only [disjoint, mem_singleton, forall_eq]; refl\n\n@[simp, priority 1100] theorem disjoint_singleton {l : list \u03b1} {a : \u03b1} : disjoint l [a] \u2194 a \u2209 l :=\nby rw disjoint_comm; simp only [singleton_disjoint]\n\n@[simp] theorem disjoint_append_left {l\u2081 l\u2082 l : list \u03b1} :\n  disjoint (l\u2081++l\u2082) l \u2194 disjoint l\u2081 l \u2227 disjoint l\u2082 l :=\nby simp only [disjoint, mem_append, or_imp_distrib, forall_and_distrib]\n\n@[simp] theorem disjoint_append_right {l\u2081 l\u2082 l : list \u03b1} :\n  disjoint l (l\u2081++l\u2082) \u2194 disjoint l l\u2081 \u2227 disjoint l l\u2082 :=\ndisjoint_comm.trans $ by simp only [disjoint_comm, disjoint_append_left]\n\n@[simp] theorem disjoint_cons_left {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} :\n  disjoint (a::l\u2081) l\u2082 \u2194 a \u2209 l\u2082 \u2227 disjoint l\u2081 l\u2082 :=\n(@disjoint_append_left _ [a] l\u2081 l\u2082).trans $ by simp only [singleton_disjoint]\n\n@[simp] theorem disjoint_cons_right {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} :\n  disjoint l\u2081 (a::l\u2082) \u2194 a \u2209 l\u2081 \u2227 disjoint l\u2081 l\u2082 :=\ndisjoint_comm.trans $ by simp only [disjoint_comm, disjoint_cons_left]\n\ntheorem disjoint_of_disjoint_append_left_left {l\u2081 l\u2082 l : list \u03b1} (d : disjoint (l\u2081++l\u2082) l) :\n  disjoint l\u2081 l :=\n(disjoint_append_left.1 d).1\n\ntheorem disjoint_of_disjoint_append_left_right {l\u2081 l\u2082 l : list \u03b1} (d : disjoint (l\u2081++l\u2082) l) :\n  disjoint l\u2082 l :=\n(disjoint_append_left.1 d).2\n\ntheorem disjoint_of_disjoint_append_right_left {l\u2081 l\u2082 l : list \u03b1} (d : disjoint l (l\u2081++l\u2082)) :\n  disjoint l l\u2081 :=\n(disjoint_append_right.1 d).1\n\ntheorem disjoint_of_disjoint_append_right_right {l\u2081 l\u2082 l : list \u03b1} (d : disjoint l (l\u2081++l\u2082)) :\n  disjoint l l\u2082 :=\n(disjoint_append_right.1 d).2\n\ntheorem disjoint_take_drop {l : list \u03b1} {m n : \u2115} (hl : l.nodup) (h : m \u2264 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\u2080 h\u2081, split,\n    { intro h, exact h\u2080 _ (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 \u03b1]\n\n@[simp] theorem nil_union (l : list \u03b1) : [] \u222a l = l := rfl\n\n@[simp] theorem cons_union (l\u2081 l\u2082 : list \u03b1) (a : \u03b1) : a :: l\u2081 \u222a l\u2082 = insert a (l\u2081 \u222a l\u2082) := rfl\n\n@[simp] theorem mem_union {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a \u2208 l\u2081 \u222a l\u2082 \u2194 a \u2208 l\u2081 \u2228 a \u2208 l\u2082 :=\nby induction l\u2081; 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 : \u03b1} {l\u2081 : list \u03b1} (h : a \u2208 l\u2081) (l\u2082 : list \u03b1) : a \u2208 l\u2081 \u222a l\u2082 :=\nmem_union.2 (or.inl h)\n\ntheorem mem_union_right {a : \u03b1} (l\u2081 : list \u03b1) {l\u2082 : list \u03b1} (h : a \u2208 l\u2082) : a \u2208 l\u2081 \u222a l\u2082 :=\nmem_union.2 (or.inr h)\n\ntheorem sublist_suffix_of_union : \u2200 l\u2081 l\u2082 : list \u03b1, \u2203 t, t <+ l\u2081 \u2227 t ++ l\u2082 = l\u2081 \u222a l\u2082\n| [] l\u2082 := \u27e8[], by refl, rfl\u27e9\n| (a::l\u2081) l\u2082 := let \u27e8t, s, e\u27e9 := sublist_suffix_of_union l\u2081 l\u2082 in\n  if h : a \u2208 l\u2081 \u222a l\u2082\n  then \u27e8t, sublist_cons_of_sublist _ s, by simp only [e, cons_union, insert_of_mem h]\u27e9\n  else \u27e8a::t, cons_sublist_cons _ s, by simp only [cons_append, cons_union, e, insert_of_not_mem h];\n    split; refl\u27e9\n\ntheorem suffix_union_right (l\u2081 l\u2082 : list \u03b1) : l\u2082 <:+ l\u2081 \u222a l\u2082 :=\n(sublist_suffix_of_union l\u2081 l\u2082).imp (\u03bb a, and.right)\n\ntheorem union_sublist_append (l\u2081 l\u2082 : list \u03b1) : l\u2081 \u222a l\u2082 <+ l\u2081 ++ l\u2082 :=\nlet \u27e8t, s, e\u27e9 := sublist_suffix_of_union l\u2081 l\u2082 in\ne \u25b8 (append_sublist_append_right _).2 s\n\ntheorem forall_mem_union {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1} :\n  (\u2200 x \u2208 l\u2081 \u222a l\u2082, p x) \u2194 (\u2200 x \u2208 l\u2081, p x) \u2227 (\u2200 x \u2208 l\u2082, p x) :=\nby simp only [mem_union, or_imp_distrib, forall_and_distrib]\n\ntheorem forall_mem_of_forall_mem_union_left {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1}\n   (h : \u2200 x \u2208 l\u2081 \u222a l\u2082, p x) : \u2200 x \u2208 l\u2081, p x :=\n(forall_mem_union.1 h).1\n\ntheorem forall_mem_of_forall_mem_union_right {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1}\n   (h : \u2200 x \u2208 l\u2081 \u222a l\u2082, p x) : \u2200 x \u2208 l\u2082, p x :=\n(forall_mem_union.1 h).2\n\nend union\n\n/-! ### inter -/\nsection inter\nvariable [decidable_eq \u03b1]\n\n@[simp] theorem inter_nil (l : list \u03b1) : [] \u2229 l = [] := rfl\n\n@[simp] theorem inter_cons_of_mem {a : \u03b1} (l\u2081 : list \u03b1) {l\u2082 : list \u03b1} (h : a \u2208 l\u2082) :\n  (a::l\u2081) \u2229 l\u2082 = a :: (l\u2081 \u2229 l\u2082) :=\nif_pos h\n\n@[simp] theorem inter_cons_of_not_mem {a : \u03b1} (l\u2081 : list \u03b1) {l\u2082 : list \u03b1} (h : a \u2209 l\u2082) :\n  (a::l\u2081) \u2229 l\u2082 = l\u2081 \u2229 l\u2082 :=\nif_neg h\n\ntheorem mem_of_mem_inter_left {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a \u2208 l\u2081 \u2229 l\u2082 \u2192 a \u2208 l\u2081 :=\nmem_of_mem_filter\n\ntheorem mem_of_mem_inter_right {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a \u2208 l\u2081 \u2229 l\u2082 \u2192 a \u2208 l\u2082 :=\nof_mem_filter\n\ntheorem mem_inter_of_mem_of_mem {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a \u2208 l\u2081 \u2192 a \u2208 l\u2082 \u2192 a \u2208 l\u2081 \u2229 l\u2082 :=\nmem_filter_of_mem\n\n@[simp] theorem mem_inter {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} : a \u2208 l\u2081 \u2229 l\u2082 \u2194 a \u2208 l\u2081 \u2227 a \u2208 l\u2082 :=\nmem_filter\n\ntheorem inter_subset_left (l\u2081 l\u2082 : list \u03b1) : l\u2081 \u2229 l\u2082 \u2286 l\u2081 :=\nfilter_subset _\n\ntheorem inter_subset_right (l\u2081 l\u2082 : list \u03b1) : l\u2081 \u2229 l\u2082 \u2286 l\u2082 :=\n\u03bb a, mem_of_mem_inter_right\n\ntheorem subset_inter {l l\u2081 l\u2082 : list \u03b1} (h\u2081 : l \u2286 l\u2081) (h\u2082 : l \u2286 l\u2082) : l \u2286 l\u2081 \u2229 l\u2082 :=\n\u03bb a h, mem_inter.2 \u27e8h\u2081 h, h\u2082 h\u27e9\n\ntheorem inter_eq_nil_iff_disjoint {l\u2081 l\u2082 : list \u03b1} : l\u2081 \u2229 l\u2082 = [] \u2194 disjoint l\u2081 l\u2082 :=\nby simp only [eq_nil_iff_forall_not_mem, mem_inter, not_and]; refl\n\ntheorem forall_mem_inter_of_forall_left {p : \u03b1 \u2192 Prop} {l\u2081 : list \u03b1} (h : \u2200 x \u2208 l\u2081, p x)\n     (l\u2082 : list \u03b1) :\n  \u2200 x, x \u2208 l\u2081 \u2229 l\u2082 \u2192 p x :=\nball.imp_left (\u03bb x, mem_of_mem_inter_left) h\n\ntheorem forall_mem_inter_of_forall_right {p : \u03b1 \u2192 Prop} (l\u2081 : list \u03b1) {l\u2082 : list \u03b1}\n    (h : \u2200 x \u2208 l\u2082, p x) :\n  \u2200 x, x \u2208 l\u2081 \u2229 l\u2082 \u2192 p x :=\nball.imp_left (\u03bb x, mem_of_mem_inter_right) h\n\n@[simp] lemma inter_reverse {xs ys : list \u03b1} :\n  xs.inter ys.reverse = xs.inter ys :=\nby simp only [list.inter, mem_reverse]; congr\n\nend inter\n\nsection choose\nvariables (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : list \u03b1)\n\nlemma choose_spec (hp : \u2203 a, a \u2208 l \u2227 p a) : choose p l hp \u2208 l \u2227 p (choose p l hp) :=\n(choose_x p l hp).property\n\nlemma choose_mem (hp : \u2203 a, a \u2208 l \u2227 p a) : choose p l hp \u2208 l := (choose_spec _ _ _).1\n\nlemma choose_property (hp : \u2203 a, a \u2208 l \u2227 p a) : p (choose p l hp) := (choose_spec _ _ _).2\n\nend choose\n\n/-! ### map\u2082_left' -/\n\nsection map\u2082_left'\n\n-- The definitional equalities for `map\u2082_left'` can already be used by the\n-- simplifie because `map\u2082_left'` is marked `@[simp]`.\n\n@[simp] theorem map\u2082_left'_nil_right (f : \u03b1 \u2192 option \u03b2 \u2192 \u03b3) (as) :\n  map\u2082_left' f as [] = (as.map (\u03bb a, f a none), []) :=\nby cases as; refl\n\nend map\u2082_left'\n\n/-! ### map\u2082_right' -/\n\nsection map\u2082_right'\n\nvariables (f : option \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (as : list \u03b1) (b : \u03b2) (bs : list \u03b2)\n\n@[simp] theorem map\u2082_right'_nil_left :\n  map\u2082_right' f [] bs = (bs.map (f none), []) :=\nby cases bs; refl\n\n@[simp] theorem map\u2082_right'_nil_right  :\n  map\u2082_right' f as [] = ([], as) :=\nrfl\n\n@[simp] theorem map\u2082_right'_nil_cons :\n  map\u2082_right' f [] (b :: bs) = (f none b :: bs.map (f none), []) :=\nrfl\n\n@[simp] theorem map\u2082_right'_cons_cons :\n  map\u2082_right' f (a :: as) (b :: bs) =\n    let rec := map\u2082_right' f as bs in\n    (f (some a) b :: rec.fst, rec.snd) :=\nrfl\n\nend map\u2082_right'\n\n/-! ### zip_left' -/\n\nsection zip_left'\n\nvariables (a : \u03b1) (as : list \u03b1) (b : \u03b2) (bs : list \u03b2)\n\n@[simp] theorem zip_left'_nil_right :\n  zip_left' as ([] : list \u03b2) = (as.map (\u03bb a, (a, none)), []) :=\nby cases as; refl\n\n@[simp] theorem zip_left'_nil_left :\n  zip_left' ([] : list \u03b1) bs = ([], bs) :=\nrfl\n\n@[simp] theorem zip_left'_cons_nil :\n  zip_left' (a :: as) ([] : list \u03b2) = ((a, none) :: as.map (\u03bb 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 : \u03b1) (as : list \u03b1) (b : \u03b2) (bs : list \u03b2)\n\n@[simp] theorem zip_right'_nil_left :\n  zip_right' ([] : list \u03b1) bs = (bs.map (\u03bb b, (none, b)), []) :=\nby cases bs; refl\n\n@[simp] theorem zip_right'_nil_right :\n  zip_right' as ([] : list \u03b2) = ([], as) :=\nrfl\n\n@[simp] theorem zip_right'_nil_cons :\n  zip_right' ([] : list \u03b1) (b :: bs) = ((none, b) :: bs.map (\u03bb 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\u2082_left -/\n\nsection map\u2082_left\n\nvariables (f : \u03b1 \u2192 option \u03b2 \u2192 \u03b3) (as : list \u03b1)\n\n-- The definitional equalities for `map\u2082_left` can already be used by the\n-- simplifier because `map\u2082_left` is marked `@[simp]`.\n\n@[simp] theorem map\u2082_left_nil_right :\n  map\u2082_left f as [] = as.map (\u03bb a, f a none) :=\nby cases as; refl\n\ntheorem map\u2082_left_eq_map\u2082_left' : \u2200 as bs,\n  map\u2082_left f as bs = (map\u2082_left' f as bs).fst\n| [] bs := by simp!\n| (a :: as) [] := by simp!\n| (a :: as) (b :: bs) := by simp! [*]\n\ntheorem map\u2082_left_eq_map\u2082 : \u2200 as bs,\n  length as \u2264 length bs \u2192\n  map\u2082_left f as bs = map\u2082 (\u03bb 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\u2082_left\n\n/-! ### map\u2082_right -/\n\nsection map\u2082_right\n\nvariables (f : option \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (as : list \u03b1) (b : \u03b2) (bs : list \u03b2)\n\n@[simp] theorem map\u2082_right_nil_left :\n  map\u2082_right f [] bs = bs.map (f none) :=\nby cases bs; refl\n\n@[simp] theorem map\u2082_right_nil_right :\n  map\u2082_right f as [] = [] :=\nrfl\n\n@[simp] theorem map\u2082_right_nil_cons :\n  map\u2082_right f [] (b :: bs) = f none b :: bs.map (f none) :=\nrfl\n\n@[simp] theorem map\u2082_right_cons_cons :\n  map\u2082_right f (a :: as) (b :: bs) = f (some a) b :: map\u2082_right f as bs :=\nrfl\n\ntheorem map\u2082_right_eq_map\u2082_right' :\n  map\u2082_right f as bs = (map\u2082_right' f as bs).fst :=\nby simp only [map\u2082_right, map\u2082_right', map\u2082_left_eq_map\u2082_left']\n\ntheorem map\u2082_right_eq_map\u2082 (h : length bs \u2264 length as) :\n  map\u2082_right f as bs = map\u2082 (\u03bb a b, f (some a) b) as bs :=\nbegin\n  have : (\u03bb a b, flip f a (some b)) = (flip (\u03bb a b, f (some a) b)) := rfl,\n  simp only [map\u2082_right, map\u2082_left_eq_map\u2082, map\u2082_flip, *]\nend\n\nend map\u2082_right\n\n/-! ### zip_left -/\n\nsection zip_left\n\nvariables (a : \u03b1) (as : list \u03b1) (b : \u03b2) (bs : list \u03b2)\n\n@[simp] theorem zip_left_nil_right :\n  zip_left as ([] : list \u03b2) = as.map (\u03bb a, (a, none)) :=\nby cases as; refl\n\n@[simp] theorem zip_left_nil_left :\n  zip_left ([] : list \u03b1) bs = [] :=\nrfl\n\n@[simp] theorem zip_left_cons_nil :\n  zip_left (a :: as) ([] : list \u03b2) = (a, none) :: as.map (\u03bb 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\u2082_left_eq_map\u2082_left']\n\nend zip_left\n\n/-! ### zip_right -/\n\nsection zip_right\n\nvariables (a : \u03b1) (as : list \u03b1) (b : \u03b2) (bs : list \u03b2)\n\n@[simp] theorem zip_right_nil_left :\n  zip_right ([] : list \u03b1) bs = bs.map (\u03bb b, (none, b)) :=\nby cases bs; refl\n\n@[simp] theorem zip_right_nil_right :\n  zip_right as ([] : list \u03b2) = [] :=\nrfl\n\n@[simp] theorem zip_right_nil_cons :\n  zip_right ([] : list \u03b1) (b :: bs) = (none, b) :: bs.map (\u03bb 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\u2082_right_eq_map\u2082_right']\n\nend zip_right\n\n/-! ### Miscellaneous lemmas -/\n\ntheorem ilast'_mem : \u2200 a l, @ilast' \u03b1 a l \u2208 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 \u03b1) (i) (H : i < L.attach.length) :\n  (L.attach.nth_le i H).1 = L.nth_le i (length_attach L \u25b8 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 {\u03b1 \u03b2 : Type*} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2) (l : list \u03b1) :\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 {\u03b1 \u03b2 \u03b3 : Type*} [monoid \u03b2] [monoid \u03b3] (L : list \u03b1) (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192* \u03b3) :\n  (L.map (g \u2218 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 {\u03b1 : Type*} [semiring \u03b1] {\u03b2 : Type*} (L : list \u03b2)\n  (f : \u03b2 \u2192 \u03b1) (r : \u03b1) :\n  (L.map (\u03bb 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 {\u03b1 : Type*} [semiring \u03b1] {\u03b2 : Type*} (L : list \u03b2)\n  (f : \u03b2 \u2192 \u03b1) (r : \u03b1) :\n  (L.map (\u03bb 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 {\u03b1 : Type u} {\u03b2 : Type v} (x : \u03b1) (y : \u03b2) (xs : list (\u03b1 \u00d7 \u03b2)) :\n  (y, x) \u2208 map prod.swap xs \u2194 (x, y) \u2208 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 {\u03b1} (xs : list \u03b1) (n m : \u2115) :\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 {\u03b1} [has_sizeof \u03b1] (i j : \u2115) (hj : 0 < j) (xs : list \u03b1) (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 \u2192+* 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 \u2192+* A) (x : A) :=\n  \u2203 (p : polynomial R), polynomial.monic p \u2227 polynomial.eval\u2082 f x p = 0\n\n/-- A ring homomorphism `f : R \u2192+* 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 \u2192+* A) :=\n  \u2200 (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 \u2192+* 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 \u21a5\u2191S) (x : A) (hx : x \u2208 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 (\u21a5T) 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 \u21d1(algebra_map A B)) : is_integral R (coe_fn (algebra_map A B) x) \u2194 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 \u2194 \u2203 (s : set R), set.finite s \u2227 is_integral (\u21a5(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 \u2191(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 : \u2200 (x : A), x \u2208 s \u2192 is_integral R x) : submodule.fg \u2191(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 \u2191S) (x : A) (hx : x \u2208 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 \u2192+* 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 \u2208 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 \u2208 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 \u2192+* S) : ring_hom.is_integral_elem f 0 :=\n  ring_hom.map_zero f \u25b8 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 \u2192+* S) : ring_hom.is_integral_elem f 1 :=\n  ring_hom.map_one f \u25b8 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 \u2192+* 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 \u2192+* 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 \u2192+* 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 \u2192+* 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 \u2208 integral_closure R A \u2194 \u2203 (M : subalgebra R A), submodule.fg \u2191M \u2227 r \u2208 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) \u2191f = 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 : \u21a5(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 \u2192+* 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 : \u2200 (x : A), x \u2208 G \u2192 is_integral R x) (x : A) (H : x \u2208 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 \u2192+* S} (G : set S) (hG : \u2200 (x : S), x \u2208 G \u2192 ring_hom.is_integral_elem f x) (x : S) (H : x \u2208 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 (\u21a5(algebra.adjoin R \u2191(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 \u2192+* S) (g : S \u2192+* 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 \u2192+* S) (hf : function.surjective \u21d1f) : ring_hom.is_integral f :=\n  fun (x : S) => Exists.rec_on (hf x) fun (y : R) (hy : coe_fn f y = x) => hy \u25b8 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 \u21d1(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 \u2192 A \u2192 B` is an algebra tower with `A \u2192 B` injective,\nthen if the entire tower is an integral extension so is `R \u2192 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 \u21d1(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 \u2192+* S) (g : S \u2192+* T) (hg : function.injective \u21d1g) (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 \u2192+* S) (g : S \u2192+* 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 \u2192+* S) (g : S \u2192+* 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 \u2192 A \u2192 B` is an algebra tower,\nthen if the entire tower is an integral extension so is `A \u2192 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 \u2192+* 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 \u2192+* S) {I : ideal S} : ring_hom.is_integral (ideal.quotient_map I f le_rfl) \u2194 ring_hom.is_integral (ring_hom.comp (ideal.quotient.mk I) f) := sorry\n\n/-- If the integral extension `R \u2192 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 \u21d1(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 (\u21a5\u2191(integral_closure R A)) A = \u22a5 := 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 \u21a5(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\u00f6lzl, Patrick Massot, S\u00e9bastien Gou\u00ebzel, 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 `\u2243\u1d64`.\n\n# Main definitions\n\n* `uniform_equiv \u03b1 \u03b2`: The type of uniform isomorphisms from `\u03b1` to `\u03b2`.\n  This type can be denoted using the following notation: `\u03b1 \u2243\u1d64 \u03b2`.\n\n-/\n\nopen set filter\nopen_locale\n\nuniverses u v\nvariables {\u03b1 : Type u} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\n\n/-- Uniform isomorphism between `\u03b1` and `\u03b2` -/\n@[nolint has_nonempty_instance] -- not all spaces are homeomorphic to each other\nstructure uniform_equiv (\u03b1 : Type*) (\u03b2 : Type*) [uniform_space \u03b1] [uniform_space \u03b2]\n  extends \u03b1 \u2243 \u03b2 :=\n(uniform_continuous_to_fun  : uniform_continuous to_fun)\n(uniform_continuous_inv_fun : uniform_continuous inv_fun)\n\ninfix ` \u2243\u1d64 `:25 := uniform_equiv\n\nnamespace uniform_equiv\nvariables [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] [uniform_space \u03b4]\n\ninstance : has_coe_to_fun (\u03b1 \u2243\u1d64 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := \u27e8\u03bbe, e.to_equiv\u27e9\n\n@[simp] lemma uniform_equiv_mk_coe (a : equiv \u03b1 \u03b2) (b c) :\n  ((uniform_equiv.mk a b c) : \u03b1 \u2192 \u03b2) = a :=\nrfl\n\n/-- Inverse of a uniform isomorphism. -/\nprotected def symm (h : \u03b1 \u2243\u1d64 \u03b2) : \u03b2 \u2243\u1d64 \u03b1 :=\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 : \u03b1 \u2243\u1d64 \u03b2) : \u03b1 \u2192 \u03b2 := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : \u03b1 \u2243\u1d64 \u03b2) : \u03b2 \u2192 \u03b1 := h.symm\n\ninitialize_simps_projections uniform_equiv\n  (to_equiv_to_fun \u2192 apply, to_equiv_inv_fun \u2192 symm_apply, -to_equiv)\n\n@[simp] lemma coe_to_equiv (h : \u03b1 \u2243\u1d64 \u03b2) : \u21d1h.to_equiv = h := rfl\n@[simp] lemma coe_symm_to_equiv (h : \u03b1 \u2243\u1d64 \u03b2) : \u21d1h.to_equiv.symm = h.symm := rfl\n\nlemma to_equiv_injective : function.injective (to_equiv : \u03b1 \u2243\u1d64 \u03b2 \u2192 \u03b1 \u2243 \u03b2)\n| \u27e8e, h\u2081, h\u2082\u27e9 \u27e8e', h\u2081', h\u2082'\u27e9 rfl := rfl\n\n@[ext] lemma ext {h h' : \u03b1 \u2243\u1d64 \u03b2} (H : \u2200 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 (\u03b1 : Type*) [uniform_space \u03b1] : \u03b1 \u2243\u1d64 \u03b1 :=\n{ uniform_continuous_to_fun := uniform_continuous_id,\n  uniform_continuous_inv_fun := uniform_continuous_id,\n  to_equiv := equiv.refl \u03b1 }\n\n/-- Composition of two uniform isomorphisms. -/\nprotected def trans (h\u2081 : \u03b1 \u2243\u1d64 \u03b2) (h\u2082 : \u03b2 \u2243\u1d64 \u03b3) : \u03b1 \u2243\u1d64 \u03b3 :=\n{ uniform_continuous_to_fun  := h\u2082.uniform_continuous_to_fun.comp h\u2081.uniform_continuous_to_fun,\n  uniform_continuous_inv_fun := h\u2081.uniform_continuous_inv_fun.comp h\u2082.uniform_continuous_inv_fun,\n  to_equiv := equiv.trans h\u2081.to_equiv h\u2082.to_equiv }\n\n@[simp] lemma trans_apply (h\u2081 : \u03b1 \u2243\u1d64 \u03b2) (h\u2082 : \u03b2 \u2243\u1d64 \u03b3) (a : \u03b1) : h\u2081.trans h\u2082 a = h\u2082 (h\u2081 a) := rfl\n\n@[simp] lemma uniform_equiv_mk_coe_symm (a : equiv \u03b1 \u03b2) (b c) :\n  ((uniform_equiv.mk a b c).symm : \u03b2 \u2192 \u03b1) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (uniform_equiv.refl \u03b1).symm = uniform_equiv.refl \u03b1 := rfl\n\nprotected lemma uniform_continuous (h : \u03b1 \u2243\u1d64 \u03b2) : uniform_continuous h :=\nh.uniform_continuous_to_fun\n\n@[continuity]\nprotected lemma continuous (h : \u03b1 \u2243\u1d64 \u03b2) : continuous h :=\nh.uniform_continuous.continuous\n\nprotected lemma uniform_continuous_symm (h : \u03b1 \u2243\u1d64 \u03b2) : 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 : \u03b1 \u2243\u1d64 \u03b2) : continuous (h.symm) :=\nh.uniform_continuous_symm.continuous\n\n/-- A uniform isomorphism as a homeomorphism. -/\n@[simps]\nprotected def to_homeomorph (e : \u03b1 \u2243\u1d64 \u03b2) : \u03b1 \u2243\u209c \u03b2 :=\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 : \u03b1 \u2243\u1d64 \u03b2) (x : \u03b2) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : \u03b1 \u2243\u1d64 \u03b2) (x : \u03b1) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\nprotected lemma bijective (h : \u03b1 \u2243\u1d64 \u03b2) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : \u03b1 \u2243\u1d64 \u03b2) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : \u03b1 \u2243\u1d64 \u03b2) : 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 : \u03b1 \u2243\u1d64 \u03b2) (g : \u03b2 \u2192 \u03b1) (hg : function.right_inverse g f) : \u03b1 \u2243\u1d64 \u03b2 :=\nhave g = f.symm, from funext (\u03bb 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 : \u03b1 \u2243\u1d64 \u03b2) : \u21d1h.symm \u2218 \u21d1h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : \u03b1 \u2243\u1d64 \u03b2) : \u21d1h \u2218 \u21d1h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : \u03b1 \u2243\u1d64 \u03b2) : range h = univ :=\nh.surjective.range_eq\n\n\n\nlemma preimage_symm (h : \u03b1 \u2243\u1d64 \u03b2) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : \u03b1 \u2243\u1d64 \u03b2) (s : set \u03b2) : h '' (h \u207b\u00b9' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : \u03b1 \u2243\u1d64 \u03b2) (s : set \u03b1) : h \u207b\u00b9' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma uniform_inducing (h : \u03b1 \u2243\u1d64 \u03b2) : 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 : \u03b1 \u2243\u1d64 \u03b2) : uniform_space.comap h \u2039_\u203a = \u2039_\u203a :=\nby ext : 1; exact h.uniform_inducing.comap_uniformity\n\nprotected lemma uniform_embedding (h : \u03b1 \u2243\u1d64 \u03b2) : uniform_embedding h :=\n\u27e8h.uniform_inducing, h.injective\u27e9\n\n/-- Uniform equiv given a uniform embedding. -/\nnoncomputable def of_uniform_embedding (f : \u03b1 \u2192 \u03b2) (hf : uniform_embedding f) :\n  \u03b1 \u2243\u1d64 (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 \u03b1} (h : s = t) : s \u2243\u1d64 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\u2081 : \u03b1 \u2243\u1d64 \u03b2) (h\u2082 : \u03b3 \u2243\u1d64 \u03b4) : \u03b1 \u00d7 \u03b3 \u2243\u1d64 \u03b2 \u00d7 \u03b4 :=\n{ uniform_continuous_to_fun  := (h\u2081.uniform_continuous.comp uniform_continuous_fst).prod_mk\n    (h\u2082.uniform_continuous.comp uniform_continuous_snd),\n  uniform_continuous_inv_fun := (h\u2081.symm.uniform_continuous.comp uniform_continuous_fst).prod_mk\n    (h\u2082.symm.uniform_continuous.comp uniform_continuous_snd),\n  to_equiv := h\u2081.to_equiv.prod_congr h\u2082.to_equiv }\n\n@[simp] lemma prod_congr_symm (h\u2081 : \u03b1 \u2243\u1d64 \u03b2) (h\u2082 : \u03b3 \u2243\u1d64 \u03b4) :\n  (h\u2081.prod_congr h\u2082).symm = h\u2081.symm.prod_congr h\u2082.symm := rfl\n\n@[simp] lemma coe_prod_congr (h\u2081 : \u03b1 \u2243\u1d64 \u03b2) (h\u2082 : \u03b3 \u2243\u1d64 \u03b4) :\n  \u21d1(h\u2081.prod_congr h\u2082) = prod.map h\u2081 h\u2082 := rfl\n\nsection\nvariables (\u03b1 \u03b2 \u03b3)\n\n/-- `\u03b1 \u00d7 \u03b2` is uniformly isomorphic to `\u03b2 \u00d7 \u03b1`. -/\ndef prod_comm : \u03b1 \u00d7 \u03b2 \u2243\u1d64 \u03b2 \u00d7 \u03b1 :=\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 \u03b1 \u03b2 }\n\n@[simp] lemma prod_comm_symm : (prod_comm \u03b1 \u03b2).symm = prod_comm \u03b2 \u03b1 := rfl\n@[simp] lemma coe_prod_comm : \u21d1(prod_comm \u03b1 \u03b2) = prod.swap := rfl\n\n/-- `(\u03b1 \u00d7 \u03b2) \u00d7 \u03b3` is uniformly isomorphic to `\u03b1 \u00d7 (\u03b2 \u00d7 \u03b3)`. -/\ndef prod_assoc : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243\u1d64 \u03b1 \u00d7 (\u03b2 \u00d7 \u03b3) :=\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 \u03b1 \u03b2 \u03b3 }\n\n/-- `\u03b1 \u00d7 {*}` is uniformly isomorphic to `\u03b1`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : \u03b1 \u00d7 punit \u2243\u1d64 \u03b1 :=\n{ to_equiv := equiv.prod_punit \u03b1,\n  uniform_continuous_to_fun := uniform_continuous_fst,\n  uniform_continuous_inv_fun := uniform_continuous_id.prod_mk uniform_continuous_const }\n\n/-- `{*} \u00d7 \u03b1` is uniformly isomorphic to `\u03b1`. -/\ndef punit_prod : punit \u00d7 \u03b1 \u2243\u1d64 \u03b1 :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : \u21d1(punit_prod \u03b1) = prod.snd := rfl\n\n/-- Uniform equivalence between `ulift \u03b1` and `\u03b1`. -/\ndef ulift : ulift.{v u} \u03b1 \u2243\u1d64 \u03b1 :=\n{ uniform_continuous_to_fun := uniform_continuous_comap,\n  uniform_continuous_inv_fun := begin\n    have hf : uniform_inducing (@equiv.ulift.{v u} \u03b1).to_fun, from \u27e8rfl\u27e9,\n    simp_rw [hf.uniform_continuous_iff],\n    exact uniform_continuous_id,\n  end,\n  .. equiv.ulift }\n\nend\n\n/-- If `\u03b9` has a unique element, then `\u03b9 \u2192 \u03b1` is homeomorphic to `\u03b1`. -/\n@[simps { fully_applied := ff }]\ndef fun_unique (\u03b9 \u03b1 : Type*) [unique \u03b9] [uniform_space \u03b1] : (\u03b9 \u2192 \u03b1) \u2243\u1d64 \u03b1 :=\n{ to_equiv := equiv.fun_unique \u03b9 \u03b1,\n  uniform_continuous_to_fun := Pi.uniform_continuous_proj _ _,\n  uniform_continuous_inv_fun := uniform_continuous_pi.mpr (\u03bb _, uniform_continuous_id) }\n\n/-- Uniform isomorphism between dependent functions `\u03a0 i : fin 2, \u03b1 i` and `\u03b1 0 \u00d7 \u03b1 1`. -/\n@[simps { fully_applied := ff }]\ndef pi_fin_two (\u03b1 : fin 2 \u2192 Type u) [\u03a0 i, uniform_space (\u03b1 i)] : (\u03a0 i, \u03b1 i) \u2243\u1d64 \u03b1 0 \u00d7 \u03b1 1 :=\n{ to_equiv := pi_fin_two_equiv \u03b1,\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 \u27e8uniform_continuous_fst, uniform_continuous_snd\u27e9 }\n\n/-- Uniform isomorphism between `\u03b1\u00b2 = fin 2 \u2192 \u03b1` and `\u03b1 \u00d7 \u03b1`. -/\n@[simps { fully_applied := ff }] def fin_two_arrow : (fin 2 \u2192 \u03b1) \u2243\u1d64 \u03b1 \u00d7 \u03b1 :=\n{ to_equiv := fin_two_arrow_equiv \u03b1, .. pi_fin_two (\u03bb _, \u03b1) }\n\n/--\nA subset of a uniform space is uniformly isomorphic to its image under a uniform isomorphism.\n-/\ndef image (e : \u03b1 \u2243\u1d64 \u03b2) (s : set \u03b1) : s \u2243\u1d64 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 \u03b1] [uniform_space \u03b2]\n  (f : \u03b1 \u2243 \u03b2) (hf : uniform_inducing f) :\n  \u03b1 \u2243\u1d64 \u03b2 :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 `\u03b1 \u00d7 \u03b2` but where the type of the second component\ndepends on the first component. This can be seen as a generalization of the sum type `\u03b1 \u2295 \u03b2`:\n* `\u03b1 \u2295 \u03b2` is made of stuff which is either of type `\u03b1` or `\u03b2`.\n* Given `\u03b1 : \u03b9 \u2192 Type*`, `sigma \u03b1` is made of stuff which is of type `\u03b1 i` for some `i : \u03b9`. One\n  effectively recovers a type isomorphic to `\u03b1 \u2295 \u03b2` by taking a `\u03b9` with exactly two elements. See\n  `equiv.sum_equiv_sigma_bool`.\n\n`\u03a3 x, A x` is notation for `sigma A` (note the difference with the big operator `\u2211`).\n`\u03a3 x y z ..., A x y z ...` is notation for `\u03a3 x, \u03a3 y, \u03a3 z, ..., A x y z ...`. Here we have\n`\u03b1 : Type*`, `\u03b2 : \u03b1 \u2192 Type*`, `\u03b3 : \u03a0 a : \u03b1, \u03b2 a \u2192 Type*`, ...,\n`A : \u03a0 (a : \u03b1) (b : \u03b2 a) (c : \u03b3 a b) ..., Type*`  with `x : \u03b1` `y : \u03b2 x`, `z : \u03b3 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 {\u03b1 \u03b1\u2081 \u03b1\u2082 : Type*} {\u03b2 : \u03b1 \u2192 Type*} {\u03b2\u2081 : \u03b1\u2081 \u2192 Type*} {\u03b2\u2082 : \u03b1\u2082 \u2192 Type*}\n\nnamespace sigma\n\ninstance [inhabited \u03b1] [inhabited (\u03b2 default)] : inhabited (sigma \u03b2) :=\n\u27e8\u27e8default, default\u27e9\u27e9\n\ninstance [h\u2081 : decidable_eq \u03b1] [h\u2082 : \u2200a, decidable_eq (\u03b2 a)] : decidable_eq (sigma \u03b2)\n| \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 := match a\u2081, b\u2081, a\u2082, b\u2082, h\u2081 a\u2081 a\u2082 with\n  | _, b\u2081, _, b\u2082, is_true (eq.refl a) :=\n    match b\u2081, b\u2082, h\u2082 a b\u2081 b\u2082 with\n    | _, _, is_true (eq.refl b) := is_true rfl\n    | b\u2081, b\u2082, is_false n := is_false (assume h, sigma.no_confusion h (\u03bbe\u2081 e\u2082, n $ eq_of_heq e\u2082))\n    end\n  | a\u2081, _, a\u2082, _, is_false n := is_false (assume h, sigma.no_confusion h (\u03bbe\u2081 e\u2082, n e\u2081))\n  end\n\n@[simp, nolint simp_nf] -- sometimes the built-in injectivity support does not work\ntheorem mk.inj_iff {a\u2081 a\u2082 : \u03b1} {b\u2081 : \u03b2 a\u2081} {b\u2082 : \u03b2 a\u2082} :\n  sigma.mk a\u2081 b\u2081 = \u27e8a\u2082, b\u2082\u27e9 \u2194 (a\u2081 = a\u2082 \u2227 b\u2081 == b\u2082) :=\nby simp\n\n@[simp] theorem eta : \u2200 x : \u03a3 a, \u03b2 a, sigma.mk x.1 x.2 = x\n| \u27e8i, x\u27e9 := rfl\n\n@[ext]\nlemma ext {x\u2080 x\u2081 : sigma \u03b2} (h\u2080 : x\u2080.1 = x\u2081.1) (h\u2081 : x\u2080.2 == x\u2081.2) : x\u2080 = x\u2081 :=\nby { cases x\u2080, cases x\u2081, cases h\u2080, cases h\u2081, refl }\n\nlemma ext_iff {x\u2080 x\u2081 : sigma \u03b2} : x\u2080 = x\u2081 \u2194 x\u2080.1 = x\u2081.1 \u2227 x\u2080.2 == x\u2081.2 :=\nby { cases x\u2080, cases x\u2081, 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 {\u03b2 : Type*} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  \u2200 {x\u2080 x\u2081 : \u03a3 a, subtype (p a)}, x\u2080.fst = x\u2081.fst \u2192 (x\u2080.snd : \u03b2) = x\u2081.snd \u2192 x\u2080 = x\u2081\n| \u27e8a\u2080, b\u2080, hb\u2080\u27e9 \u27e8a\u2081, b\u2081, hb\u2081\u27e9 rfl rfl := rfl\n\nlemma subtype_ext_iff {\u03b2 : Type*} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} {x\u2080 x\u2081 : \u03a3 a, subtype (p a)} :\n  x\u2080 = x\u2081 \u2194 x\u2080.fst = x\u2081.fst \u2227 (x\u2080.snd : \u03b2) = x\u2081.snd :=\n\u27e8\u03bb h, h \u25b8 \u27e8rfl, rfl\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, subtype_ext h\u2081 h\u2082\u27e9\n\n@[simp] theorem \u00abforall\u00bb {p : (\u03a3 a, \u03b2 a) \u2192 Prop} :\n  (\u2200 x, p x) \u2194 (\u2200 a b, p \u27e8a, b\u27e9) :=\n\u27e8assume h a b, h \u27e8a, b\u27e9, assume h \u27e8a, b\u27e9, h a b\u27e9\n\n@[simp] theorem \u00abexists\u00bb {p : (\u03a3 a, \u03b2 a) \u2192 Prop} :\n  (\u2203 x, p x) \u2194 (\u2203 a b, p \u27e8a, b\u27e9) :=\n\u27e8assume \u27e8\u27e8a, b\u27e9, h\u27e9, \u27e8a, b, h\u27e9, assume \u27e8a, b, h\u27e9, \u27e8\u27e8a, b\u27e9, h\u27e9\u27e9\n\n/-- Map the left and right components of a sigma -/\ndef map (f\u2081 : \u03b1\u2081 \u2192 \u03b1\u2082) (f\u2082 : \u03a0a, \u03b2\u2081 a \u2192 \u03b2\u2082 (f\u2081 a)) (x : sigma \u03b2\u2081) : sigma \u03b2\u2082 :=\n\u27e8f\u2081 x.1, f\u2082 x.1 x.2\u27e9\n\nend sigma\n\nlemma sigma_mk_injective {i : \u03b1} : function.injective (@sigma.mk \u03b1 \u03b2 i)\n| _ _ rfl := rfl\n\nlemma function.injective.sigma_map {f\u2081 : \u03b1\u2081 \u2192 \u03b1\u2082} {f\u2082 : \u03a0a, \u03b2\u2081 a \u2192 \u03b2\u2082 (f\u2081 a)}\n  (h\u2081 : function.injective f\u2081) (h\u2082 : \u2200 a, function.injective (f\u2082 a)) :\n  function.injective (sigma.map f\u2081 f\u2082)\n| \u27e8i, x\u27e9 \u27e8j, y\u27e9 h :=\nbegin\n  obtain rfl : i = j, from h\u2081 (sigma.mk.inj_iff.mp h).1,\n  obtain rfl : x = y, from h\u2082 i (eq_of_heq (sigma.mk.inj_iff.mp h).2),\n  refl\nend\n\nlemma function.surjective.sigma_map {f\u2081 : \u03b1\u2081 \u2192 \u03b1\u2082} {f\u2082 : \u03a0a, \u03b2\u2081 a \u2192 \u03b2\u2082 (f\u2081 a)}\n  (h\u2081 : function.surjective f\u2081) (h\u2082 : \u2200 a, function.surjective (f\u2082 a)) :\n  function.surjective (sigma.map f\u2081 f\u2082) :=\nbegin\n  intros y,\n  cases y with j y,\n  cases h\u2081 j with i hi,\n  subst j,\n  cases h\u2082 i y with x hx,\n  subst y,\n  exact \u27e8\u27e8i, x\u27e9, rfl\u27e9\nend\n\n/-- Interpret a function on `\u03a3 x : \u03b1, \u03b2 x` as a dependent function with two arguments.\n\nThis also exists as an `equiv` as `equiv.Pi_curry \u03b3`. -/\ndef sigma.curry {\u03b3 : \u03a0 a, \u03b2 a \u2192 Type*} (f : \u03a0 x : sigma \u03b2, \u03b3 x.1 x.2) (x : \u03b1) (y : \u03b2 x) : \u03b3 x y :=\nf \u27e8x,y\u27e9\n\n/-- Interpret a dependent function with two arguments as a function on `\u03a3 x : \u03b1, \u03b2 x`.\n\nThis also exists as an `equiv` as `(equiv.Pi_curry \u03b3).symm`. -/\ndef sigma.uncurry {\u03b3 : \u03a0 a, \u03b2 a \u2192 Type*} (f : \u03a0 x (y : \u03b2 x), \u03b3 x y) (x : sigma \u03b2) : \u03b3 x.1 x.2 :=\nf x.1 x.2\n\n@[simp]\nlemma sigma.uncurry_curry {\u03b3 : \u03a0 a, \u03b2 a \u2192 Type*} (f : \u03a0 x : sigma \u03b2, \u03b3 x.1 x.2) :\n  sigma.uncurry (sigma.curry f) = f :=\nfunext $ \u03bb \u27e8i, j\u27e9, rfl\n\n@[simp]\nlemma sigma.curry_uncurry {\u03b3 : \u03a0 a, \u03b2 a \u2192 Type*} (f : \u03a0 x (y : \u03b2 x), \u03b3 x y) :\n  sigma.curry (sigma.uncurry f) = f :=\nrfl\n\n/-- Convert a product type to a \u03a3-type. -/\n@[simp]\ndef prod.to_sigma {\u03b1 \u03b2} : \u03b1 \u00d7 \u03b2 \u2192 \u03a3 _ : \u03b1, \u03b2\n| \u27e8x,y\u27e9 := \u27e8x,y\u27e9\n\n@[simp]\nlemma prod.fst_to_sigma {\u03b1 \u03b2} (x : \u03b1 \u00d7 \u03b2) : (prod.to_sigma x).fst = x.fst :=\nby cases x; refl\n\n@[simp]\nlemma prod.snd_to_sigma {\u03b1 \u03b2} (x : \u03b1 \u00d7 \u03b2) : (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  {\u03b1 : Type u} (\u03b2 : \u03b1 \u2192 Type v)\n  [reflected _ \u03b1] [reflected _ \u03b2] [h\u03b1 : has_reflect \u03b1] [h\u03b2 : \u03a0 i, has_reflect (\u03b2 i)] :\n  has_reflect (\u03a3 a, \u03b2 a) :=\n\u03bb \u27e8a, b\u27e9, (by reflect_name : reflected _ @sigma.mk.{u v}).subst\u2084 `(\u03b1) `(\u03b2) `(a) `(b)\n\nend sigma\n\nsection psigma\nvariables {\u03b1 : Sort*} {\u03b2 : \u03b1 \u2192 Sort*}\n\nnamespace psigma\n\n/-- Nondependent eliminator for `psigma`. -/\ndef elim {\u03b3} (f : \u2200 a, \u03b2 a \u2192 \u03b3) (a : psigma \u03b2) : \u03b3 :=\npsigma.cases_on a f\n\n@[simp] theorem elim_val {\u03b3} (f : \u2200 a, \u03b2 a \u2192 \u03b3) (a b) : psigma.elim f \u27e8a, b\u27e9 = f a b := rfl\n\ninstance [inhabited \u03b1] [inhabited (\u03b2 default)] : inhabited (psigma \u03b2) :=\n\u27e8\u27e8default, default\u27e9\u27e9\n\ninstance [h\u2081 : decidable_eq \u03b1] [h\u2082 : \u2200a, decidable_eq (\u03b2 a)] : decidable_eq (psigma \u03b2)\n| \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 := match a\u2081, b\u2081, a\u2082, b\u2082, h\u2081 a\u2081 a\u2082 with\n  | _, b\u2081, _, b\u2082, is_true (eq.refl a) :=\n    match b\u2081, b\u2082, h\u2082 a b\u2081 b\u2082 with\n    | _, _, is_true (eq.refl b) := is_true rfl\n    | b\u2081, b\u2082, is_false n := is_false (assume h, psigma.no_confusion h (\u03bbe\u2081 e\u2082, n $ eq_of_heq e\u2082))\n    end\n  | a\u2081, _, a\u2082, _, is_false n := is_false (assume h, psigma.no_confusion h (\u03bbe\u2081 e\u2082, n e\u2081))\n  end\n\ntheorem mk.inj_iff {a\u2081 a\u2082 : \u03b1} {b\u2081 : \u03b2 a\u2081} {b\u2082 : \u03b2 a\u2082} :\n  @psigma.mk \u03b1 \u03b2 a\u2081 b\u2081 = @psigma.mk \u03b1 \u03b2 a\u2082 b\u2082 \u2194 (a\u2081 = a\u2082 \u2227 b\u2081 == b\u2082) :=\niff.intro psigma.mk.inj $\n  assume \u27e8h\u2081, h\u2082\u27e9, match a\u2081, a\u2082, b\u2081, b\u2082, h\u2081, h\u2082 with _, _, _, _, eq.refl a, heq.refl b := rfl end\n\n@[ext]\nlemma ext {x\u2080 x\u2081 : psigma \u03b2} (h\u2080 : x\u2080.1 = x\u2081.1) (h\u2081 : x\u2080.2 == x\u2081.2) : x\u2080 = x\u2081 :=\nby { cases x\u2080, cases x\u2081, cases h\u2080, cases h\u2081, refl }\n\nlemma ext_iff {x\u2080 x\u2081 : psigma \u03b2} : x\u2080 = x\u2081 \u2194 x\u2080.1 = x\u2081.1 \u2227 x\u2080.2 == x\u2081.2 :=\nby { cases x\u2080, cases x\u2081, exact psigma.mk.inj_iff }\n\n@[simp] theorem \u00abforall\u00bb {p : (\u03a3' a, \u03b2 a) \u2192 Prop} :\n  (\u2200 x, p x) \u2194 (\u2200 a b, p \u27e8a, b\u27e9) :=\n\u27e8assume h a b, h \u27e8a, b\u27e9, assume h \u27e8a, b\u27e9, h a b\u27e9\n\n@[simp] theorem \u00abexists\u00bb {p : (\u03a3' a, \u03b2 a) \u2192 Prop} :\n  (\u2203 x, p x) \u2194 (\u2203 a b, p \u27e8a, b\u27e9) :=\n\u27e8assume \u27e8\u27e8a, b\u27e9, h\u27e9, \u27e8a, b, h\u27e9, assume \u27e8a, b, h\u27e9, \u27e8\u27e8a, b\u27e9, h\u27e9\u27e9\n\n/-- A specialized ext lemma for equality of psigma types over an indexed subtype. -/\n@[ext]\nlemma subtype_ext {\u03b2 : Sort*} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  \u2200 {x\u2080 x\u2081 : \u03a3' a, subtype (p a)}, x\u2080.fst = x\u2081.fst \u2192 (x\u2080.snd : \u03b2) = x\u2081.snd \u2192 x\u2080 = x\u2081\n| \u27e8a\u2080, b\u2080, hb\u2080\u27e9 \u27e8a\u2081, b\u2081, hb\u2081\u27e9 rfl rfl := rfl\n\nlemma subtype_ext_iff {\u03b2 : Sort*} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} {x\u2080 x\u2081 : \u03a3' a, subtype (p a)} :\n  x\u2080 = x\u2081 \u2194 x\u2080.fst = x\u2081.fst \u2227 (x\u2080.snd : \u03b2) = x\u2081.snd :=\n\u27e8\u03bb h, h \u25b8 \u27e8rfl, rfl\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, subtype_ext h\u2081 h\u2082\u27e9\n\nvariables {\u03b1\u2081 : Sort*} {\u03b1\u2082 : Sort*} {\u03b2\u2081 : \u03b1\u2081 \u2192 Sort*} {\u03b2\u2082 : \u03b1\u2082 \u2192 Sort*}\n\n/-- Map the left and right components of a sigma -/\ndef map (f\u2081 : \u03b1\u2081 \u2192 \u03b1\u2082) (f\u2082 : \u03a0a, \u03b2\u2081 a \u2192 \u03b2\u2082 (f\u2081 a)) : psigma \u03b2\u2081 \u2192 psigma \u03b2\u2082\n| \u27e8a, b\u27e9 := \u27e8f\u2081 a, f\u2082 a b\u27e9\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} [\ud835\udc9e : category.{u v} C]\ninclude \ud835\udc9e\nvariables {X Y : C}\n\nstructure Equalizer (f g : X \u27f6 Y) :=\n(equalizer     : C)\n(inclusion     : equalizer \u27f6 X)\n(map           : \u2200 {Z : C} (k : Z \u27f6 X) (w : k \u226b f = k \u226b g), Z \u27f6 equalizer)\n(witness       : inclusion \u226b f = inclusion \u226b g . obviously)\n(factorisation : \u2200 {Z : C} (k : Z \u27f6 X) (w : k \u226b f = k \u226b g), (map k w) \u226b inclusion = k . obviously)\n(uniqueness    : \u2200 {Z : C} (a b : Z \u27f6 equalizer) (witness : a \u226b inclusion = b \u226b 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 \u27f6 X)\n(right_projection    : product \u27f6 Y)\n(map                 : \u2200 {Z : C} (f : Z \u27f6 X) (g : Z \u27f6 Y), Z \u27f6 product)\n(left_factorisation  : \u2200 {Z : C} (f : Z \u27f6 X) (g : Z \u27f6 Y), (map f g) \u226b left_projection  = f . obviously) \n(right_factorisation : \u2200 {Z : C} (f : Z \u27f6 X) (g : Z \u27f6 Y), (map f g) \u226b right_projection = g . obviously) \n(uniqueness          : \u2200 {Z : C} (f g : Z \u27f6 product)\n                          (left_witness  : f \u226b left_projection  = g \u226b left_projection )\n                          (right_witness : f \u226b right_projection = g \u226b 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 \u2192 C) :=\n(product       : C)\n(projection    : \u03a0 i : I, product \u27f6 (F i))\n(map           : \u2200 {Z : C} (f : \u03a0 i : I, Z \u27f6 (F i)), Z \u27f6 product)\n(factorisation : \u2200 {Z : C} (f : \u03a0 i : I, Z \u27f6 (F i)) (i : I), (map f) \u226b (projection i) = f i . obviously)\n(uniqueness    : \u2200 {Z : C} (f g : Z \u27f6 product) (witness : \u2200 i : I, f \u226b (projection i) = g \u226b (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 \u27f6 Y) :=\n(coequalizer   : C)\n(projection    : Y \u27f6 coequalizer)\n(map           : \u2200 {Z : C} (k : Y \u27f6 Z) (w : f \u226b k = g \u226b k), coequalizer \u27f6 Z)\n(witness       : f \u226b projection = g \u226b projection . obviously)\n(factorisation : \u2200 {Z : C} (k : Y \u27f6 Z) (w : f \u226b k = g \u226b k), projection \u226b (map k w) = k . obviously)\n(uniqueness    : \u2200 {Z : C} (a b : coequalizer \u27f6 Z) (witness : projection \u226b a = projection \u226b 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 \u27f6 coproduct)\n(right_inclusion     : Y \u27f6 coproduct)\n(map                 : \u2200 {Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z), coproduct \u27f6 Z)\n(left_factorisation  : \u2200 {Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z), left_inclusion \u226b (map f g)  = f . obviously) \n(right_factorisation : \u2200 {Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z), right_inclusion \u226b (map f g) = g . obviously) \n(uniqueness          : \u2200 {Z : C} (f g : coproduct \u27f6 Z)\n                          (left_witness  : left_inclusion \u226b f = left_inclusion \u226b g)\n                          (right_witness : right_inclusion \u226b f = right_inclusion \u226b 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 \u2192 C) :=\n(coproduct     : C)\n(inclusion     : \u03a0 i : I, (X i) \u27f6 coproduct)\n(map           : \u2200 {Z : C} (f : \u03a0 i : I, (X i) \u27f6 Z), coproduct \u27f6 Z)\n(factorisation : \u2200 {Z : C} (f : \u03a0 i : I, (X i) \u27f6 Z) (i : I), (inclusion i) \u226b (map f) = f i . obviously)\n(uniqueness    : \u2200 {Z : C} (f g : coproduct \u27f6 Z) (witness : \u2200 i : I, (inclusion i) \u226b f = (inclusion i) \u226b 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 \u27f6 Z) (g : Y \u27f6 Z) :=\n(pullback : C)\n(h : pullback \u27f6 X)\n(k : pullback \u27f6 Y)\n(commutativity : h \u226b f = k \u226b g)\n(map : \u2200 {P} {h' : P \u27f6 X} {k' : P \u27f6 Y} (w : h' \u226b f = k' \u226b g), P \u27f6 pullback)\n(factorisation : \u2200 {P} {h' : P \u27f6 X} {k' : P \u27f6 Y} (w : h' \u226b f = k' \u226b g), (map w \u226b h) = h' \u2227 (map w \u226b k) = k')\n(uniqueness : \u2200 {P} {h' : P \u27f6 X} {k' : P \u27f6 Y} (w : h' \u226b f = k' \u226b g) (m n : P \u27f6 pullback) (w' : (m \u226b h) = h' \u2227 (m \u226b k) = k' \u2227 (n \u226b h) = h' \u2227 (n \u226b 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 \u2192 F` that is complex differentiable on a set `s`, is continuous on its\nclosure, and `\u2016f x\u2016` 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 `\u2016f x\u2016 = \u2016f c\u2016` 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) \u2286 s`, then\n  `\u2016f w\u2016 = \u2016f c\u2016`;\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 `\u2016f x\u2016` has a maximum on `U` at `c \u2208 U`, then `\u2016f x\u2016 = \u2016f c\u2016`\n  for all `x \u2208 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 \u2208 s`, then `\u2016f x\u2016 = \u2016f c\u2016` for all `x \u2208 closure s`;\n\n- `complex.norm_eventually_eq_of_is_local_max`: if `f` is complex differentiable in a neighborhood\n  of `c` and `\u2016f x\u2016` has a local maximum at `c`, then `\u2016f x\u2016` 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 `\u2016f w\u2016 = \u2016f c\u2016`, 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 \u2192 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 \u2208 frontier s` such that `\u03bb z, \u2016f z\u2016` takes it\n  maximum value on `closure s` at `z`.\n\n- `complex.norm_le_of_forall_mem_frontier_norm_le`: if `\u2016f z\u2016 \u2264 C` for all `z \u2208 frontier s`, then\n  `\u2016f z\u2016 \u2264 C` for all `z \u2208 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 \u2102 E] {F : Type v} [NormedAddCommGroup F]\n  [NormedSpace \u2102 F]\n\n-- mathport name: \u00abexpr \u0302\u00bb\nlocal postfix:100 \"\u0302\" => 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 : \u2102 \u2192 F`\nwith an additional assumption that `F` is a complete space, then drop unneeded assumptions one by\none.\n\nThe lemmas with names `*_aux\u2099` are considered to be private and should not be used outside of this\nfile.\n-/\n\n\ntheorem norm_max_aux\u2081 [CompleteSpace F] {f : \u2102 \u2192 F} {z w : \u2102}\n    (hd : DiffContOnCl \u2102 f (ball z (dist w z)))\n    (hz : IsMaxOn (norm \u2218 f) (closedBall z (dist w z)) z) : \u2016f w\u2016 = \u2016f z\u2016 :=\n  by\n  -- Consider a circle of radius `r = dist w z`.\n  set r : \u211d := dist w z\n  have hw : w \u2208 closed_ball z r := mem_closed_ball.2 le_rfl\n  -- Assume the converse. Since `\u2016f w\u2016 \u2264 \u2016f z\u2016`, we have `\u2016f w\u2016 < \u2016f z\u2016`.\n  refine' (isMaxOn_iff.1 hz _ hw).antisymm (not_lt.1 _)\n  rintro hw_lt : \u2016f w\u2016 < \u2016f z\u2016\n  have hr : 0 < r := dist_pos.2 (ne_of_apply_ne (norm \u2218 f) hw_lt.ne)\n  -- Due to Cauchy integral formula, it suffices to prove the following inequality.\n  suffices \u2016\u222e \u03b6 in C(z, r), (\u03b6 - z)\u207b\u00b9 \u2022 f \u03b6\u2016 < 2 * \u03c0 * \u2016f z\u2016\n    by\n    refine' this.ne _\n    have A : (\u222e \u03b6 in C(z, r), (\u03b6 - z)\u207b\u00b9 \u2022 f \u03b6) = (2 * \u03c0 * I : \u2102) \u2022 f z :=\n      hd.circle_integral_sub_inv_smul (mem_ball_self hr)\n    simp [A, norm_smul, real.pi_pos.le]\n  suffices \u2016\u222e \u03b6 in C(z, r), (\u03b6 - z)\u207b\u00b9 \u2022 f \u03b6\u2016 < 2 * \u03c0 * r * (\u2016f z\u2016 / r) by\n    rwa [mul_assoc, mul_div_cancel' _ hr.ne'] at this\n  /- This inequality is true because `\u2016(\u03b6 - z)\u207b\u00b9 \u2022 f \u03b6\u2016 \u2264 \u2016f z\u2016 / r` for all `\u03b6` on the circle and\n    this inequality is strict at `\u03b6 = w`. -/\n  have hsub : sphere z r \u2286 closed_ball z r := sphere_subset_closed_ball\n  refine' circleIntegral.norm_integral_lt_of_norm_le_const_of_lt hr _ _ \u27e8w, rfl, _\u27e9\n  show ContinuousOn (fun \u03b6 : \u2102 => (\u03b6 - z)\u207b\u00b9 \u2022 f \u03b6) (sphere z r)\n  \u00b7 refine'\n      ((continuous_on_id.sub continuousOn_const).inv\u2080 _).smul (hd.continuous_on_ball.mono hsub)\n    exact fun \u03b6 h\u03b6 => sub_ne_zero.2 (ne_of_mem_sphere h\u03b6 hr.ne')\n  show \u2200 \u03b6 \u2208 sphere z r, \u2016(\u03b6 - z)\u207b\u00b9 \u2022 f \u03b6\u2016 \u2264 \u2016f z\u2016 / r\n  \u00b7 rintro \u03b6 (h\u03b6 : abs (\u03b6 - z) = r)\n    rw [le_div_iff hr, norm_smul, norm_inv, norm_eq_abs, h\u03b6, mul_comm, mul_inv_cancel_left\u2080 hr.ne']\n    exact hz (hsub h\u03b6)\n  show \u2016(w - z)\u207b\u00b9 \u2022 f w\u2016 < \u2016f z\u2016 / r\n  \u00b7 rw [norm_smul, norm_inv, norm_eq_abs, \u2190 div_eq_inv_mul]\n    exact (div_lt_div_right hr).2 hw_lt\n#align complex.norm_max_aux\u2081 Complex.norm_max_aux\u2081\n\n/-!\nNow we drop the assumption `complete_space F` by embedding `F` into its completion.\n-/\n\n\ntheorem norm_max_aux\u2082 {f : \u2102 \u2192 F} {z w : \u2102} (hd : DiffContOnCl \u2102 f (ball z (dist w z)))\n    (hz : IsMaxOn (norm \u2218 f) (closedBall z (dist w z)) z) : \u2016f w\u2016 = \u2016f z\u2016 :=\n  by\n  set e : F \u2192L[\u2102] F\u0302 := UniformSpace.Completion.toComplL\n  have he : \u2200 x, \u2016e x\u2016 = \u2016x\u2016 := UniformSpace.Completion.norm_coe\n  replace hz : IsMaxOn (norm \u2218 e \u2218 f) (closed_ball z (dist w z)) z\n  \u00b7 simpa only [IsMaxOn, (\u00b7 \u2218 \u00b7), he] using hz\n  simpa only [he] using norm_max_aux\u2081 (e.differentiable.comp_diff_cont_on_cl hd) hz\n#align complex.norm_max_aux\u2082 Complex.norm_max_aux\u2082\n\n/-!\nThen we replace the assumption `is_max_on (norm \u2218 f) (closed_ball z r) z` with a seemingly weaker\nassumption `is_max_on (norm \u2218 f) (ball z r) z`.\n-/\n\n\ntheorem norm_max_aux\u2083 {f : \u2102 \u2192 F} {z w : \u2102} {r : \u211d} (hr : dist w z = r)\n    (hd : DiffContOnCl \u2102 f (ball z r)) (hz : IsMaxOn (norm \u2218 f) (ball z r) z) : \u2016f w\u2016 = \u2016f z\u2016 :=\n  by\n  subst r\n  rcases eq_or_ne w z with (rfl | hne); \u00b7 rfl\n  rw [\u2190 dist_ne_zero] at hne\n  exact norm_max_aux\u2082 hd (closure_ball z hne \u25b8 hz.closure hd.continuous_on.norm)\n#align complex.norm_max_aux\u2083 Complex.norm_max_aux\u2083\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** `\u2016f x\u2016` is locally constant.\n-/\n\n\n/-!\nFinally, we generalize the theorem from a disk in `\u2102` to a closed ball in any normed space.\n-/\n\n\n/-- **Maximum modulus principle** on a closed ball: if `f : E \u2192 F` is continuous on a closed ball,\nis complex differentiable on the corresponding open ball, and the norm `\u2016f w\u2016` takes its maximum\nvalue on the open ball at its center, then the norm `\u2016f w\u2016` is constant on the closed ball.  -/\ntheorem norm_eqOn_closedBall_of_isMaxOn {f : E \u2192 F} {z : E} {r : \u211d}\n    (hd : DiffContOnCl \u2102 f (ball z r)) (hz : IsMaxOn (norm \u2218 f) (ball z r) z) :\n    EqOn (norm \u2218 f) (const E \u2016f z\u2016) (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  \u00b7 rfl\n  set e : \u2102 \u2192 E := line_map z w\n  have hde : Differentiable \u2102 e := (differentiable_id.smul_const (w - z)).AddConst z\n  suffices \u2016(f \u2218 e) (1 : \u2102)\u2016 = \u2016(f \u2218 e) (0 : \u2102)\u2016 by simpa [e]\n  have hr : dist (1 : \u2102) 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\u2083 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 \u2192 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 `\u2016f w\u2016 = \u2016f z\u2016`. -/\ntheorem norm_eq_norm_of_isMaxOn_of_ball_subset {f : E \u2192 F} {s : Set E} {z w : E}\n    (hd : DiffContOnCl \u2102 f s) (hz : IsMaxOn (norm \u2218 f) s z) (hsub : ball z (dist w z) \u2286 s) :\n    \u2016f w\u2016 = \u2016f z\u2016 :=\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 \u2192 F` is complex differentiable in a neighborhood of `c`\nand the norm `\u2016f z\u2016` has a local maximum at `c`, then `\u2016f z\u2016` is locally constant in a neighborhood\nof `c`. -/\ntheorem norm_eventually_eq_of_isLocalMax {f : E \u2192 F} {c : E}\n    (hd : \u2200\u1da0 z in \ud835\udcdd c, DifferentiableAt \u2102 f z) (hc : IsLocalMax (norm \u2218 f) c) :\n    \u2200\u1da0 y in \ud835\udcdd c, \u2016f y\u2016 = \u2016f c\u2016 :=\n  by\n  rcases nhds_basis_closed_ball.eventually_iff.1 (hd.and hc) with \u27e8r, hr\u2080, hr\u27e9\n  exact\n    nhds_basis_closed_ball.eventually_iff.2\n      \u27e8r, hr\u2080,\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\u27e9\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 \u2192 F} {s : Set E}\n    (hd : DifferentiableOn \u2102 f s) : IsOpen { z | s \u2208 \ud835\udcdd z \u2227 IsMaxOn (norm \u2218 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 : \u2200\u1da0 w in \ud835\udcdd z, DifferentiableAt \u2102 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 \u2192 F` be a function that is complex differentiable on `U`. Suppose\nthat `\u2016f x\u2016` takes its maximum value on `U` at `c \u2208 U`. Then `\u2016f x\u2016 = \u2016f c\u2016` for all `x \u2208 U`. -/\ntheorem norm_eqOn_of_isPreconnected_of_isMaxOn {f : E \u2192 F} {U : Set E} {c : E}\n    (hc : IsPreconnected U) (ho : IsOpen U) (hd : DifferentiableOn \u2102 f U) (hcU : c \u2208 U)\n    (hm : IsMaxOn (norm \u2218 f) U c) : EqOn (norm \u2218 f) (const E \u2016f c\u2016) U :=\n  by\n  set V := U \u2229 { z | IsMaxOn (norm \u2218 f) U z }\n  have hV : \u2200 x \u2208 V, \u2016f x\u2016 = \u2016f c\u2016 := fun x hx => le_antisymm (hm hx.1) (hx.2 hcU)\n  suffices : U \u2286 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 \u2229 V).Nonempty := \u27e8c, hcU, hcU, hm\u27e9\n  set W := U \u2229 { z | \u2016f z\u2016 \u2260 \u2016f c\u2016 }\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 \u2286 V \u222a W := fun x hx =>\n    (eq_or_ne \u2016f x\u2016 \u2016f c\u2016).imp (fun h => \u27e8hx, fun y hy => (hm hy).out.trans_eq h.symm\u27e9)\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 \u2192 F` be a function that is complex differentiable on `U` and is\ncontinuous on its closure. Suppose that `\u2016f x\u2016` takes its maximum value on `U` at `c \u2208 U`. Then\n`\u2016f x\u2016 = \u2016f c\u2016` for all `x \u2208 closure U`. -/\ntheorem norm_eqOn_closure_of_isPreconnected_of_isMaxOn {f : E \u2192 F} {U : Set E} {c : E}\n    (hc : IsPreconnected U) (ho : IsOpen U) (hd : DiffContOnCl \u2102 f U) (hcU : c \u2208 U)\n    (hm : IsMaxOn (norm \u2218 f) U c) : EqOn (norm \u2218 f) (const E \u2016f c\u2016) (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 `\u2016f w\u2016 = \u2016f z\u2016`.\n\nInstead of repeating the proof starting with lemmas about integrals, we apply a corresponding lemma\nabove twice: for `f` and for `\u03bb x, f x + f c`.  Then we have `\u2016f w\u2016 = \u2016f z\u2016` and\n`\u2016f w + f z\u2016 = \u2016f z + f z\u2016`, thus `\u2016f w + f z\u2016 = \u2016f w\u2016 + \u2016f z\u2016`. This is only possible if\n`f w = f z`, see `eq_of_norm_eq_of_norm_add_eq`.\n-/\n\n\nvariable [StrictConvexSpace \u211d 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 \u2192 F` be a function that is complex differentiable on `U`. Suppose\nthat `\u2016f x\u2016` takes its maximum value on `U` at `c \u2208 U`. Then `f x = f c` for all `x \u2208 U`.\n\nTODO: change assumption from `is_max_on` to `is_local_max`. -/\ntheorem eqOn_of_isPreconnected_of_isMaxOn_norm {f : E \u2192 F} {U : Set E} {c : E}\n    (hc : IsPreconnected U) (ho : IsOpen U) (hd : DifferentiableOn \u2102 f U) (hcU : c \u2208 U)\n    (hm : IsMaxOn (norm \u2218 f) U c) : EqOn f (const E (f c)) U := fun x hx =>\n  have H\u2081 : \u2016f x\u2016 = \u2016f c\u2016 := norm_eqOn_of_isPreconnected_of_isMaxOn hc ho hd hcU hm hx\n  have H\u2082 : \u2016f x + f c\u2016 = \u2016f c + f c\u2016 :=\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\u2081 <| by simp only [H\u2082, same_ray.rfl.norm_add, H\u2081]\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 \u2192 F` be a function that is complex differentiable on `U` and is\ncontinuous on its closure. Suppose that `\u2016f x\u2016` takes its maximum value on `U` at `c \u2208 U`. Then\n`f x = f c` for all `x \u2208 closure U`. -/\ntheorem eqOn_closure_of_isPreconnected_of_isMaxOn_norm {f : E \u2192 F} {U : Set E} {c : E}\n    (hc : IsPreconnected U) (ho : IsOpen U) (hd : DiffContOnCl \u2102 f U) (hcU : c \u2208 U)\n    (hm : IsMaxOn (norm \u2218 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 \u2192 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 \u2192 F} {s : Set E} {z w : E} (hd : DiffContOnCl \u2102 f s)\n    (hz : IsMaxOn (norm \u2218 f) s z) (hsub : ball z (dist w z) \u2286 s) : f w = f z :=\n  have H\u2081 : \u2016f w\u2016 = \u2016f z\u2016 := norm_eq_norm_of_isMaxOn_of_ball_subset hd hz hsub\n  have H\u2082 : \u2016f w + f z\u2016 = \u2016f z + f z\u2016 :=\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\u2081 <| by simp only [H\u2082, same_ray.rfl.norm_add, H\u2081]\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 \u2192 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 `\u2016f w\u2016` 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 \u2192 F} {z : E} {r : \u211d}\n    (hd : DiffContOnCl \u2102 f (ball z r)) (hz : IsMaxOn (norm \u2218 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 \u2192 F` is complex differentiable in a neighborhood of `c`\nand the norm `\u2016f z\u2016` has a local maximum at `c`, then `f` is locally constant in a neighborhood\nof `c`. -/\ntheorem eventually_eq_of_isLocalMax_norm {f : E \u2192 F} {c : E}\n    (hd : \u2200\u1da0 z in \ud835\udcdd c, DifferentiableAt \u2102 f z) (hc : IsLocalMax (norm \u2218 f) c) :\n    \u2200\u1da0 y in \ud835\udcdd c, f y = f c :=\n  by\n  rcases nhds_basis_closed_ball.eventually_iff.1 (hd.and hc) with \u27e8r, hr\u2080, hr\u27e9\n  exact\n    nhds_basis_closed_ball.eventually_iff.2\n      \u27e8r, hr\u2080,\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\u27e9\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 \u2192 \u2102} {c : E}\n    (hf : \u2200\u1da0 z in \ud835\udcdd c, DifferentiableAt \u2102 f z) (hc : IsLocalMin (norm \u2218 f) c) :\n    (\u2200\u1da0 z in \ud835\udcdd c, f z = f c) \u2228 f c = 0 :=\n  by\n  refine' or_iff_not_imp_right.mpr fun h => _\n  have h1 : \u2200\u1da0 z in \ud835\udcdd c, f z \u2260 0 := hf.self_of_nhds.continuous_at.eventually_ne h\n  have h2 : IsLocalMax (norm \u2218 f)\u207b\u00b9 c := hc.inv (h1.mono fun z => norm_pos_iff.mpr)\n  have h3 : IsLocalMax (norm \u2218 f\u207b\u00b9) c := by refine' h2.congr (eventually_of_forall _) <;> simp\n  have h4 : \u2200\u1da0 z in \ud835\udcdd c, DifferentiableAt \u2102 f\u207b\u00b9 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 \u2192 F` is complex differentiable on a nonempty bounded\nset `U` and is continuous on its closure, then there exists a point `z \u2208 frontier U` such that\n`\u03bb z, \u2016f z\u2016` takes it maximum value on `closure U` at `z`. -/\ntheorem exists_mem_frontier_isMaxOn_norm [FiniteDimensional \u2102 E] {f : E \u2192 F} {U : Set E}\n    (hb : Bounded U) (hne : U.Nonempty) (hd : DiffContOnCl \u2102 f U) :\n    \u2203 z \u2208 frontier U, IsMaxOn (norm \u2218 f) (closure U) z :=\n  by\n  have hc : IsCompact (closure U) := hb.is_compact_closure\n  obtain \u27e8w, hwU, hle\u27e9 : \u2203 w \u2208 closure U, IsMaxOn (norm \u2218 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  \u00b7 exact \u27e8w, hwU, hle\u27e9\n  have : interior U \u2260 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 \u27e8z, hzU, hzw\u27e9\n  refine' \u27e8z, frontier_interior_subset hzU, fun x hx => (mem_set_of_eq.mp <| hle hx).trans_eq _\u27e9\n  refine' (norm_eq_norm_of_is_max_on_of_ball_subset hd (hle.on_subset subset_closure) _).symm\n  rw [dist_comm, \u2190 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 \u2192 F` is complex differentiable on a bounded set `U` and\n`\u2016f z\u2016 \u2264 C` for any `z \u2208 frontier U`, then the same is true for any `z \u2208 closure U`. -/\ntheorem norm_le_of_forall_mem_frontier_norm_le {f : E \u2192 F} {U : Set E} (hU : Bounded U)\n    (hd : DiffContOnCl \u2102 f U) {C : \u211d} (hC : \u2200 z \u2208 frontier U, \u2016f z\u2016 \u2264 C) {z : E}\n    (hz : z \u2208 closure U) : \u2016f z\u2016 \u2264 C :=\n  by\n  rw [closure_eq_self_union_frontier, union_comm, mem_union] at hz\n  cases hz\n  \u00b7 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 \u27e8w, hne\u27e9\n  set e : \u2102 \u2192 E := line_map z w\n  have hde : Differentiable \u2102 e := (differentiable_id.smul_const (w - z)).AddConst z\n  have hL : AntilipschitzWith (nndist z w)\u207b\u00b9 e := antilipschitzWith_lineMap hne.symm\n  replace hd : DiffContOnCl \u2102 (f \u2218 e) (e \u207b\u00b9' U)\n  exact hd.comp hde.diff_cont_on_cl (maps_to_preimage _ _)\n  have h\u2080 : (0 : \u2102) \u2208 e \u207b\u00b9' U := by simpa only [e, mem_preimage, line_map_apply_zero]\n  rcases exists_mem_frontier_is_max_on_norm (hL.bounded_preimage hU) \u27e80, h\u2080\u27e9 hd with \u27e8\u03b6, h\u03b6U, h\u03b6\u27e9\n  calc\n    \u2016f z\u2016 = \u2016f (e 0)\u2016 := by simp only [e, line_map_apply_zero]\n    _ \u2264 \u2016f (e \u03b6)\u2016 := (h\u03b6 (subset_closure h\u2080))\n    _ \u2264 C := hC _ (hde.continuous.frontier_preimage_subset _ h\u03b6U)\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 \u2192 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 \u2192 F} {U : Set E} (hU : Bounded U)\n    (hf : DiffContOnCl \u2102 f U) (hg : DiffContOnCl \u2102 g U) (hfg : EqOn f g (frontier U)) :\n    EqOn f g (closure U) :=\n  by\n  suffices H : \u2200 z \u2208 closure U, \u2016(f - g) z\u2016 \u2264 0; \u00b7 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 \u2192 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 \u2192 F} {U : Set E} (hU : Bounded U) (hf : DiffContOnCl \u2102 f U)\n    (hg : DiffContOnCl \u2102 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : \u03b1 :=\n  fold lcm 1 f s\n\ntheorem lcm_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} : lcm s f = multiset.lcm (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem lcm_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {f : \u03b2 \u2192 \u03b1} : lcm \u2205 f = 1 :=\n  fold_empty\n\n@[simp] theorem lcm_dvd_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} : lcm s f \u2223 a \u2194 \u2200 (b : \u03b2), b \u2208 s \u2192 f b \u2223 a := sorry\n\ntheorem lcm_dvd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} : (\u2200 (b : \u03b2), b \u2208 s \u2192 f b \u2223 a) \u2192 lcm s f \u2223 a :=\n  iff.mpr lcm_dvd_iff\n\ntheorem dvd_lcm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {b : \u03b2} (hb : b \u2208 s) : f b \u2223 lcm s f :=\n  iff.mp lcm_dvd_iff (dvd_refl (lcm s f)) b hb\n\n@[simp] theorem lcm_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [DecidableEq \u03b2] {b : \u03b2} : lcm (insert b s) f = lcm (f b) (lcm s f) := sorry\n\n@[simp] theorem lcm_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} : lcm (singleton b) f = coe_fn normalize (f b) :=\n  multiset.lcm_singleton\n\n@[simp] theorem normalize_lcm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} : coe_fn normalize (lcm s f) = lcm s f := sorry\n\ntheorem lcm_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [DecidableEq \u03b2] : lcm (s\u2081 \u222a s\u2082) f = lcm (lcm s\u2081 f) (lcm s\u2082 f) := sorry\n\ntheorem lcm_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (hs : s\u2081 = s\u2082) (hfg : \u2200 (a : \u03b2), a \u2208 s\u2082 \u2192 f a = g a) : lcm s\u2081 f = lcm s\u2082 g :=\n  Eq._oldrec (fun (hfg : \u2200 (a : \u03b2), a \u2208 s\u2081 \u2192 f a = g a) => fold_congr hfg) hs hfg\n\ntheorem lcm_mono_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (h : \u2200 (b : \u03b2), b \u2208 s \u2192 f b \u2223 g b) : lcm s f \u2223 lcm s g :=\n  lcm_dvd fun (b : \u03b2) (hb : b \u2208 s) => dvd_trans (h b hb) (dvd_lcm hb)\n\ntheorem lcm_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} (h : s\u2081 \u2286 s\u2082) : lcm s\u2081 f \u2223 lcm s\u2082 f :=\n  lcm_dvd fun (b : \u03b2) (hb : b \u2208 s\u2081) => dvd_lcm (h hb)\n\n/-! ### gcd -/\n\n/-- Greatest common divisor of a finite set -/\ndef gcd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : \u03b1 :=\n  fold gcd 0 f s\n\ntheorem gcd_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} : gcd s f = multiset.gcd (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem gcd_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {f : \u03b2 \u2192 \u03b1} : gcd \u2205 f = 0 :=\n  fold_empty\n\ntheorem dvd_gcd_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} : a \u2223 gcd s f \u2194 \u2200 (b : \u03b2), b \u2208 s \u2192 a \u2223 f b := sorry\n\ntheorem gcd_dvd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {b : \u03b2} (hb : b \u2208 s) : gcd s f \u2223 f b :=\n  iff.mp dvd_gcd_iff (dvd_refl (gcd s f)) b hb\n\ntheorem dvd_gcd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} : (\u2200 (b : \u03b2), b \u2208 s \u2192 a \u2223 f b) \u2192 a \u2223 gcd s f :=\n  iff.mpr dvd_gcd_iff\n\n@[simp] theorem gcd_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [DecidableEq \u03b2] {b : \u03b2} : gcd (insert b s) f = gcd (f b) (gcd s f) := sorry\n\n@[simp] theorem gcd_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} : gcd (singleton b) f = coe_fn normalize (f b) :=\n  multiset.gcd_singleton\n\n@[simp] theorem normalize_gcd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} : coe_fn normalize (gcd s f) = gcd s f := sorry\n\ntheorem gcd_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [DecidableEq \u03b2] : gcd (s\u2081 \u222a s\u2082) f = gcd (gcd s\u2081 f) (gcd s\u2082 f) := sorry\n\ntheorem gcd_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (hs : s\u2081 = s\u2082) (hfg : \u2200 (a : \u03b2), a \u2208 s\u2082 \u2192 f a = g a) : gcd s\u2081 f = gcd s\u2082 g :=\n  Eq._oldrec (fun (hfg : \u2200 (a : \u03b2), a \u2208 s\u2081 \u2192 f a = g a) => fold_congr hfg) hs hfg\n\ntheorem gcd_mono_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (h : \u2200 (b : \u03b2), b \u2208 s \u2192 f b \u2223 g b) : gcd s f \u2223 gcd s g :=\n  dvd_gcd fun (b : \u03b2) (hb : b \u2208 s) => dvd_trans (gcd_dvd hb) (h b hb)\n\ntheorem gcd_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} (h : s\u2081 \u2286 s\u2082) : gcd s\u2082 f \u2223 gcd s\u2081 f :=\n  dvd_gcd fun (b : \u03b2) (hb : b \u2208 s\u2081) => gcd_dvd (h hb)\n\ntheorem gcd_eq_zero_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} : gcd s f = 0 \u2194 \u2200 (x : \u03b2), x \u2208 s \u2192 f x = 0 := sorry\n\ntheorem gcd_eq_gcd_filter_ne_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [decidable_pred fun (x : \u03b2) => f x = 0] : gcd s f = gcd (filter (fun (x : \u03b2) => f x \u2260 0) s) f := sorry\n\ntheorem gcd_mul_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} : (gcd s fun (x : \u03b2) => a * f x) = coe_fn normalize a * gcd s f := sorry\n\ntheorem gcd_mul_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} : (gcd s fun (x : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b2] [integral_domain \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : \u2200 (x : \u03b2), x \u2208 s \u2192 a \u2223 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\u2081 v\u2081 u\u2082 v\u2082 \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\u2081) := C\n\nprotected instance core_category {C : Type u\u2081} [category C] : groupoid (core C) :=\n  groupoid.mk fun (X Y : core C) (f : X \u27f6 Y) => iso.symm f\n\nnamespace core\n\n\n@[simp] theorem id_hom {C : Type u\u2081} [category C] (X : core C) : iso.hom \ud835\udfd9 = \ud835\udfd9 := rfl\n\n@[simp] theorem comp_hom {C : Type u\u2081} [category C] {X : core C} {Y : core C} {Z : core C}\n    (f : X \u27f6 Y) (g : Y \u27f6 Z) : iso.hom (f \u226b g) = iso.hom f \u226b iso.hom g :=\n  rfl\n\n/-- The core of a category is naturally included in the category. -/\ndef inclusion {C : Type u\u2081} [category C] : core C \u2964 C :=\n  functor.mk id fun (X Y : core C) (f : X \u27f6 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\u2081} [category C] {G : Type u\u2082} [groupoid G] (F : G \u2964 C) :\n    G \u2964 core C :=\n  functor.mk (fun (X : G) => functor.obj F X)\n    fun (X Y : G) (f : X \u27f6 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 \u2964 C`.\n-/\nend core\n\n\ndef core.forget_functor_to_core {C : Type u\u2081} [category C] {G : Type u\u2082} [groupoid G] :\n    (G \u2964 core C) \u2964 G \u2964 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\u2081) \u2964 core (Type u\u2082)`.\n-/\ndef of_equiv_functor (m : Type u\u2081 \u2192 Type u\u2082) [equiv_functor m] : core (Type u\u2081) \u2964 core (Type u\u2082) :=\n  functor.mk m\n    fun (\u03b1 \u03b2 : core (Type u\u2081)) (f : \u03b1 \u27f6 \u03b2) =>\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 (\u03c3 : variable_ \u2192 variable_) : finset variable_ \u2192 formula \u2192 formula\n| _ true_ := true_\n| binders (pred_ name args) :=\n    pred_\n    name\n    (args.map (fun (x : variable_), if x \u2208 binders then x else \u03c3 x))\n| binders (eq_ x y) :=\n    eq_\n    (if x \u2208 binders then x else \u03c3 x)\n    (if y \u2208 binders then y else \u03c3 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 \u222a {x}) P)\n\n\ndef simult_replace_free (\u03c3 : variable_ \u2192 variable_) (P : formula) : formula := simult_replace_free_aux \u03c3 \u2205 P\n\n\n/--\n  Specialized version of function.update.\n-/\ndef function.update_ite\n  {\u03b1 \u03b2 : Type}\n  [decidable_eq \u03b1]\n  (f : \u03b1 \u2192 \u03b2)\n  (a' : \u03b1) (b : \u03b2) (a : \u03b1) :=\n  if a = a' then b else f a\n\n/--\n  fast_simult_replace_free \u03c3 P := The simultaneous replacement of each free occurence of any variable v in the formula P by \u03c3 v.\n-/\ndef fast_simult_replace_free : (variable_ \u2192 variable_) \u2192 formula \u2192 formula\n| _ true_ := true_\n| \u03c3 (pred_ name args) := pred_ name (args.map \u03c3)\n| \u03c3 (eq_ x y) := eq_ (\u03c3 x) (\u03c3 y)\n| \u03c3 (not_ P) := not_ (fast_simult_replace_free \u03c3 P)\n| \u03c3 (imp_ P Q) := imp_ (fast_simult_replace_free \u03c3 P) (fast_simult_replace_free \u03c3 Q)\n| \u03c3 (forall_ x P) := forall_ x (fast_simult_replace_free (function.update_ite \u03c3 x x) P)\n\n\n@[simp]\nlemma function.update_ite_idem\n  {\u03b1 \u03b2 : Type}\n  [decidable_eq \u03b1]\n  (f : \u03b1 \u2192 \u03b2)\n  (a : \u03b1)\n  (x y : \u03b2)  :\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  {\u03b1 : Type}\n  [decidable_eq \u03b1]\n  (x : \u03b1) :\n  function.update_ite (id : \u03b1 \u2192 \u03b1) 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_ \u2192 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  (\u03c3 \u03c3' : variable_ \u2192 variable_)\n  (binders : finset variable_)\n  (h1 : \u2200 (v : variable_), v \u2209 binders \u2192 \u03c3 v = \u03c3' v) :\n  simult_replace_free_aux \u03c3 binders P =\n    simult_replace_free_aux \u03c3' 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_\u1fb0 P_\u1fb0_1 binders h1\n  { admit },\n  case formula.not_ : P_\u1fb0 P_ih binders h1\n  { admit },\n  case formula.imp_ : P_\u1fb0 P_\u1fb0_1 P_ih_\u1fb0 P_ih_\u1fb0_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  (\u03c3 : variable_ \u2192 variable_)\n  (binders : finset variable_)\n  (h1 : \u2200 (v : variable_), v \u2208 binders \u2192 v = \u03c3 v) :\n  simult_replace_free_aux \u03c3 binders P =\n    fast_simult_replace_free \u03c3 P :=\nbegin\n  induction P generalizing binders \u03c3,\n  case formula.true_ : binders h1\n  { admit },\n  case formula.pred_ : name args binders \u03c3 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_\u1fb0 P_\u1fb0_1 binders \u03c3 h1\n  { admit },\n  case formula.not_ : P_\u1fb0 P_ih binders \u03c3 h1\n  { admit },\n  case formula.imp_ : P_\u1fb0 P_\u1fb0_1 P_ih_\u1fb0 P_ih_\u1fb0_1 binders \u03c3 h1\n  { admit },\n  case formula.forall_ : x P P_ih binders \u03c3 h1\n  {\n    unfold fast_simult_replace_free,\n    unfold simult_replace_free_aux,\n    congr,\n\n    rewrite huh P \u03c3 (function.update_ite \u03c3 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 \u211d E]\n          {F : Type*} [normed_add_comm_group F]\n          {g b : E \u2192 F} {\u03a9 : set (E \u00d7 F)} {U K C : set E}\nvariables [normed_space \u211d F] [finite_dimensional \u211d F]\n\nlemma exist_loops_aux1\n  (hK : is_compact K)\n  (h\u03a9_op : is_open \u03a9)\n  (hb : \ud835\udc9e \u221e b)\n  (hgK : \u2200\u1da0 x near K, g x = b x)\n  (hconv : \u2200 x, g x \u2208 hull (connected_component_in (prod.mk x \u207b\u00b9' \u03a9) $ b x)) :\n  \u2203 (\u03b3 : E \u2192 \u211d \u2192 loop F) (V \u2208 \ud835\udcdd\u02e2 K) (\u03b5 > 0), surrounding_family_in g b \u03b3 V \u03a9 \u2227\n  (\u2200 (x \u2208 V), ball (x, b x) (\u03b5 + \u03b5) \u2286 \u03a9) \u2227\n  \u2200 (x \u2208 V) t s, dist (\u03b3 x t s) (b x) < \u03b5 :=\nbegin\n  have b_in : \u2200 x, (x, b x) \u2208 \u03a9 :=\n    \u03bb x, (connected_component_in_nonempty_iff.mp (convex_hull_nonempty_iff.mp \u27e8g x, hconv x\u27e9) : _),\n  have h2\u03a9 : is_open (\u03a9 \u2229 fst \u207b\u00b9' univ), { rwa [preimage_univ, inter_univ] },\n\n  -- we could probably get away with something simpler to get \u03b3\u2080.\n  obtain \u27e8\u03b3\u2080, h\u03b3\u2080_cont, h\u03b3\u2080, h2\u03b3\u2080, h3\u03b3\u2080, -, h\u03b3\u2080_surr\u27e9 := -- \u03b3\u2080 is \u03b3* 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 \u27e8\u03b5\u2080, h\u03b5\u2080, V, hV, h\u03b5\u03a9\u27e9 :=\n    hK.exists_thickening_image h\u03a9_op (continuous_id.prod_mk hb.continuous) (\u03bb x _, b_in x),\n  let range_\u03b3\u2080 := (\u03bb i : \u211d \u00d7 \u211d, \u2016\u03b3\u2080 i.1 i.2\u2016) '' (I \u00d7\u02e2 I),\n  have h4\u03b3\u2080 : bdd_above range_\u03b3\u2080 :=\n  (is_compact_Icc.prod is_compact_Icc).bdd_above_image (h\u03b3\u2080_cont.norm.continuous_on),\n  have h0 : 0 < 1 + Sup range_\u03b3\u2080 := add_pos_of_pos_of_nonneg zero_lt_one (le_cSup_of_le h4\u03b3\u2080\n    (mem_image_of_mem _ $ mk_mem_prod unit_interval.zero_mem unit_interval.zero_mem) $\n    norm_nonneg _),\n  generalize' h0\u03b5\u2081 : \u03b5\u2080 / 2 = \u03b5\u2081,\n  have h\u03b5\u2081 : 0 < \u03b5\u2081 := h0\u03b5\u2081 \u25b8 div_pos h\u03b5\u2080 two_pos,\n  let \u03b5 := \u03b5\u2081 / (1 + Sup range_\u03b3\u2080),\n  have h\u03b5 : 0 < \u03b5 := div_pos h\u03b5\u2081 h0,\n  have h2\u03b5 : \u2200 t s : \u211d, \u2016\u03b5 \u2022 \u03b3\u2080 t s\u2016 < \u03b5\u2081,\n  { intros t s, simp [norm_smul, mul_comm_div, real.norm_eq_abs, abs_eq_self.mpr, h\u03b5.le],\n    refine lt_of_lt_of_le _ (mul_one _).le,\n    rw [mul_lt_mul_left h\u03b5\u2081, 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\u03b3\u2080 _),\n    rw [\u2190 loop.fract_eq, \u2190 h3\u03b3\u2080],\n    refine mem_image_of_mem _ (mk_mem_prod proj_I_mem_Icc $ unit_interval.fract_mem _) },\n  let \u03b3\u2081 : E \u2192 \u211d \u2192 loop F := \u03bb x t, (\u03b3\u2080 t).transform (\u03bb y, b x + \u03b5 \u2022 y), -- `\u03b3\u2081 x` is `\u03b3\u2093` in notes\n  refine \u27e8\u03b3\u2081, _\u27e9,\n  have hbV : \u2200\u1da0 x near K, x \u2208 V := hV,\n  have h1 : \u2200 (x \u2208 V) (t s : \u211d), ball (x, b x) (\u03b5\u2081 + \u03b5\u2081) \u2286 \u03a9,\n  { intros x hx t s,\n    simp [\u2190 h0\u03b5\u2081],\n    refine (ball_subset_thickening (mem_image_of_mem _ hx) _).trans h\u03b5\u03a9 },\n  refine \u27e8_, hgK.and hbV, \u03b5\u2081, h\u03b5\u2081, \u27e8\u27e8by simp [\u03b3\u2081, h\u03b3\u2080], by simp [\u03b3\u2081, h2\u03b3\u2080], _, _, _\u27e9, _\u27e9, _, _\u27e9,\n  { intros x t s, simp [\u03b3\u2081, h3\u03b3\u2080] },\n  { rintro x \u27e8hx, -\u27e9, simp_rw [hx, \u03b3\u2081],\n    exact (h\u03b3\u2080_surr.smul0 h\u03b5.ne').vadd0 },\n  { refine hb.continuous.fst'.add (continuous_const.smul $ h\u03b3\u2080_cont.snd') },\n  { rintro x \u27e8-, hx\u27e9 t ht s hs,\n    have : \u2016\u03b5 \u2022 \u03b3\u2080 t s\u2016 < \u03b5\u2080 := (h2\u03b5 t s).trans (h0\u03b5\u2081 \u25b8 half_lt_self h\u03b5\u2080),\n    refine h1 x hx t s (by simp [\u2190 h0\u03b5\u2081, this]) },\n  { intros x hx,\n    rw [\u2190 h0\u03b5\u2081, add_halves'],\n    refine (ball_subset_thickening (mem_image_of_mem _ hx.2) _).trans h\u03b5\u03a9 },\n  { rintro x \u27e8-, hx\u27e9 t s, simp [h2\u03b5] }\nend\n\n/- Some remarks about `exist_loops_aux2`:\n  `\u03b4`: loop after smoothing\n  `\u03b3`: loop before smoothing (defined on all of `E`)\n  Requirements:\n  (0) `\u03b4 x t` is a loop\n  (1) `\u03b4` lands in `\u03a9`\n  (2) `\u03b4` has the correct values: for `s = 0` and `t = 0` it should be `b`\n  (3) `\u03b4` should be constant on `t \u2264 0` and for `t \u2265 1`.\n  (4) `\u03b4 x 1` surrounds `g x`.\n  (5) Near `K`, the line connecting `b` and `\u03b4` lies in `\u03a9`\n\n  Strategy:\n  (a) We need `\u03b5\u2081` satisfying the following conditions:\n  (a1) We need to ensure that an `\u03b5\u2081 x`-ball around `(x, \u03b4 x s t)` lies in `\u03a9` for some\n    continuous `\u03b5\u2081`.\n  (a4) Furthermore, `\u03b5\u2081` should be small enough so that any function with that\n    distance from `\u03b3` still surrounds `g`, using `surrounding_family.surrounds_of_close`.\n  (a5): `\u03b5\u2081 x < \u03b5\u2080` (obtained from `exist_loops_aux1`)\n  (b) Replace `\u03b3 x t s` by `\u03b3 x (linear_reparam t) (linear_reparam s)`.\n  (e) Let `\u03b4' x` be a family of loops that is at most `\u03b5\u2081` away from `\u03b3` using\n    `exists_smooth_and_eq_on`. Since `\u03b3` is smooth near `s \u2208 \u2124` and `t \u2264 0` we can also\n    ensure that `\u03b4' = \u03b3` for those values (*).\n    Now let `\u03b4 x t s = \u03b4' x (smooth_transition t) (fract s)`\n    We immediately get (0) and (3). We get (2) by (*).\n    This is still smooth, since `\u03b4'` is doesn't depend on `s` near `s \u2208 \u2124`.\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 `\u03b3` 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 `\u03b3` is not constant in the `x`-direction.\n\n  -/\n\nlemma exist_loops_aux2 [finite_dimensional \u211d E]\n  (hK : is_compact K)\n  (h\u03a9_op : is_open \u03a9)\n  (hg : \ud835\udc9e \u221e g) (hb : \ud835\udc9e \u221e b)\n  (hgK : \u2200\u1da0 x near K, g x = b x)\n  (hconv : \u2200 x, g x \u2208 hull (connected_component_in (prod.mk x \u207b\u00b9' \u03a9) $ b x)) :\n  \u2203 (\u03b3 : E \u2192 \u211d \u2192 loop F), surrounding_family_in g b \u03b3 univ \u03a9 \u2227 \ud835\udc9e \u221e \u21bf\u03b3 \u2227\n  \u2200\u1da0 x near K, \u2200 t s, closed_ball (x, b x) (dist (\u03b3 x t s) (b x)) \u2286 \u03a9 :=\nbegin\n  obtain \u27e8\u03b3\u2081, V, hV, \u03b5\u2080, h\u03b5\u2080, h\u03b3\u2081, h\u03a9, h2\u03b3\u2081\u27e9 := exist_loops_aux1 hK h\u03a9_op hb hgK hconv,\n  obtain \u27e8\u03b3\u2082, h\u03b3\u2082, h\u03b3\u2082\u2081\u27e9 :=\n    exists_surrounding_loops hK.is_closed h\u03a9_op\n    (\u03bb x, hg.continuous.continuous_at) hb.continuous (\u03bb x, hconv x) \u27e8V, hV, h\u03b3\u2081\u27e9,\n  let \u03b3\u2083 : E \u2192 \u211d \u2192 loop F := \u03bb x t, (\u03b3\u2082 x (linear_reparam t)).reparam linear_reparam,\n  have h\u03b3\u2083 : surrounding_family_in g b \u03b3\u2083 univ \u03a9 := h\u03b3\u2082.reparam,\n  obtain \u27e8\u03b5\u2081, h\u03b5\u2081, hc\u03b5\u2081, h\u03b3\u03b5\u2081\u27e9 := h\u03b3\u2083.to_sf.surrounds_of_close_univ hg.continuous,\n  classical,\n  let f : E \u2192 \u211d \u00d7 \u211d \u2192 \u211d := \u03bb x y, if \u03a9\u1d9c.nonempty then inf_dist (x, \u03b3\u2083 x y.1 y.2) \u03a9\u1d9c else 1,\n  have hI : is_compact (I \u00d7\u02e2 I) := is_compact_Icc.prod is_compact_Icc,\n  have h1f : continuous \u21bff :=\n    (continuous_fst.prod_mk h\u03b3\u2083.cont).inf_dist.if_const _ continuous_const,\n  have h2f : \u2200 x : E, continuous (f x) :=\n    \u03bb x, h1f.comp\u2082 continuous_const continuous_id,\n  have h3f : \u2200 {x y}, 0 < f x y,\n  { intros x y, by_cases h\u03a9 : \u03a9\u1d9c.nonempty,\n    { simp_rw [f, if_pos h\u03a9, \u2190 h\u03a9_op.is_closed_compl.not_mem_iff_inf_dist_pos h\u03a9, not_mem_compl_iff,\n      h\u03b3\u2083.val_in (mem_univ _)] },\n    { simp_rw [f, if_neg h\u03a9, zero_lt_one] }},\n  let \u03b5\u2082 : E \u2192 \u211d := \u03bb x, min (min \u03b5\u2080 (\u03b5\u2081 x)) (Inf (f x '' (I \u00d7\u02e2 I))),\n  have hc\u03b5\u2082 : continuous \u03b5\u2082 :=\n    (continuous_const.min hc\u03b5\u2081).min (hI.continuous_Inf h1f),\n  have h\u03b5\u2082 : \u2200 {x}, 0 < \u03b5\u2082 x := \u03bb x, lt_min (lt_min h\u03b5\u2080 (h\u03b5\u2081 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 $ \u03bb x hx, h3f),\n  let \u03b3\u2084 := \u21bf\u03b3\u2083,\n  have h0\u03b3\u2084 : \u2200 x t s, \u03b3\u2084 (x, t, s) = \u03b3\u2083 x t s := \u03bb x t s, rfl,\n  have h\u03b3\u2084 : continuous \u03b3\u2084 := h\u03b3\u2083.cont,\n  let C\u2081 : set \u211d := Iic (5\u207b\u00b9  : \u211d) \u222a Ici (4 / 5),\n  have h0C\u2081 : (0 : \u211d) \u2208 C\u2081 := or.inl (by { rw [mem_Iic], norm_num1 }),\n  have h1C\u2081 : (1 : \u211d) \u2208 C\u2081 := or.inr (by { rw [mem_Ici], norm_num1 }),\n  have h2C\u2081 : \u2200 (s : \u211d) (hs : fract s = 0), fract \u207b\u00b9' C\u2081 \u2208 \ud835\udcdd s,\n  { intros s hs,\n    refine fract_preimage_mem_nhds _ (\u03bb _, _),\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 \u00d7 \u211d \u00d7 \u211d) := (\u03bb x, x.2.1) \u207b\u00b9' Iic (5\u207b\u00b9 : \u211d) \u222a (\u03bb x, fract x.2.2) \u207b\u00b9' C\u2081,\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 \u03bb x, or.inl (show (0 : \u211d) \u2264 5\u207b\u00b9, by norm_num) },\n  let U\u2081 : set \u211d := Iio (4\u207b\u00b9 : \u211d) \u222a Ioi (3 / 4),\n  let U : set (E \u00d7 \u211d \u00d7 \u211d) := (\u03bb x, x.2.1) \u207b\u00b9' Iio (4\u207b\u00b9 : \u211d) \u222a (\u03bb x, fract x.2.2) \u207b\u00b9' U\u2081,\n  have hUC : U \u2208 \ud835\udcdd\u02e2 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 \u03bb x, or.inr (show (3/4 : \u211d) < 1, by norm_num) },\n    exact hU.mem_nhds_set.mpr (union_subset_union (\u03bb x hx, lt_of_le_of_lt hx (by norm_num)) $\n      union_subset_union (\u03bb x hx, lt_of_le_of_lt hx (by norm_num))\n      (\u03bb x hx, lt_of_lt_of_le (by norm_num) hx)) },\n  have h2\u03b3\u2084 : eq_on \u03b3\u2084 (\u03bb x, b x.1) U,\n  { rintro \u27e8x, t, s\u27e9 hxts,\n    simp_rw [h0\u03b3\u2084, \u03b3\u2083, loop.reparam_apply],\n    cases hxts with ht hs,\n    { refine h\u03b3\u2082.to_sf.t_le_zero_eq_b x (linear_reparam s) (linear_reparam_nonpos (le_of_lt ht)) },\n    { rw [\u2190 loop.fract_eq, fract_linear_reparam_eq_zero, h\u03b3\u2082.base],\n      exact or.imp le_of_lt le_of_lt hs } },\n  have h3\u03b3\u2084 : smooth_on \u03b3\u2084 U := hb.fst'.cont_diff_on.congr h2\u03b3\u2084,\n  obtain \u27e8\u03b3\u2085, h\u03b3\u2085, h\u03b3\u2085\u2084, h\u03b3\u2085C\u27e9 :=\n    exists_smooth_and_eq_on h\u03b3\u2084 hc\u03b5\u2082.fst' (\u03bb x, h\u03b5\u2082) hC \u27e8U, hUC, h3\u03b3\u2084\u27e9,\n  let \u03b3 : E \u2192 \u211d \u2192 loop F := \u03bb x t, \u27e8\u03bb s, \u03b3\u2085 (x, smooth_transition t, fract s),\n    \u03bb s, by rw [fract_add_one s]\u27e9,\n  have h\u03b3 : \ud835\udc9e \u221e \u21bf\u03b3,\n  { rw [cont_diff_iff_cont_diff_at],\n    rintro \u27e8x, t, s\u27e9, by_cases hs : fract s = 0,\n    { have : (\u03bb x, \u03b3 x.1 x.2.1 x.2.2) =\u1da0[\ud835\udcdd (x, t, s)] \u03bb x, b x.1,\n      { have : (\u03bb x : E \u00d7 \u211d \u00d7 \u211d, (x.1, smooth_transition x.2.1, fract x.2.2)) \u207b\u00b9' C \u2208 \ud835\udcdd (x, t, s),\n        { simp_rw [C, @preimage_union _ _ _ (_ \u207b\u00b9' _), preimage_preimage, fract_fract],\n          refine mem_of_superset _ (subset_union_right _ _),\n          refine continuous_at_id.snd'.snd'.preimage_mem_nhds (h2C\u2081 s hs) },\n        refine eventually_of_mem this _,\n        intros x hx,\n        simp_rw [\u03b3, loop.coe_mk],\n        refine (h\u03b3\u2085C hx).trans\n          (h2\u03b3\u2084 $ (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\u03b3\u2085.comp\u2083 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 \u21bf\u03b3\u2085) } },\n  refine \u27e8\u03b3, \u27e8\u27e8_, _, _, _, h\u03b3.continuous\u27e9, _\u27e9, h\u03b3, _\u27e9,\n  { intros x t, simp_rw [\u03b3, loop.coe_mk, fract_zero], rw [h\u03b3\u2085C], exact h\u03b3\u2083.base x _,\n    exact or.inr (by { rw [mem_preimage, fract_zero], exact h0C\u2081 }) },\n  { intros x s, simp_rw [\u03b3, loop.coe_mk, smooth_transition.zero_of_nonpos le_rfl], rw [h\u03b3\u2085C],\n    exact h\u03b3\u2083.t\u2080 x (fract s),\n    exact or.inl (show (0 : \u211d) \u2264 5\u207b\u00b9, by norm_num) },\n  { intros x t s, simp_rw [\u03b3, loop.coe_mk, smooth_transition_proj_I] },\n  { rintro x -, apply h\u03b3\u03b5\u2081, intro s,\n    simp_rw [\u2190 (\u03b3\u2083 x 1).fract_eq s, \u03b3, loop.coe_mk, smooth_transition.one_of_one_le le_rfl],\n    exact (h\u03b3\u2085\u2084 (x, 1, fract s)).trans_le ((min_le_left _ _).trans $ min_le_right _ _) },\n  { rintro x - t - s -, rw [\u2190 not_mem_compl_iff],\n    by_cases h\u03a9 : \u03a9\u1d9c.nonempty, swap,\n    { rw [not_nonempty_iff_eq_empty] at h\u03a9, rw [h\u03a9], apply not_mem_empty },\n    refine not_mem_of_dist_lt_inf_dist _,\n    exact (x, \u03b3\u2083 x (smooth_transition t) (fract s)),\n    rw [dist_comm, dist_prod_same_left],\n    refine (h\u03b3\u2085\u2084 (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 [\u2190 h\u03b3\u2083.proj_I],\n    simp_rw [f, if_pos h\u03a9],\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\u03b3\u2082\u2081) (\u03bb x hx t s, _),\n    refine (closed_ball_subset_ball _).trans (h\u03a9 x hx.1),\n    refine (dist_triangle _ _ _).trans_lt (add_lt_add_of_le_of_lt\n      ((h\u03b3\u2085\u2084 (x, _, fract s)).le.trans $ (min_le_left _ _).trans $ min_le_left _ _) _),\n    simp_rw [\u03b3\u2084, has_uncurry.uncurry, \u03b3\u2083, loop.reparam_apply, show \u03b3\u2082 x = \u03b3\u2081 x, from hx.2],\n    exact h2\u03b3\u2081 x hx.1 _ _ }\nend\n\nvariables (g b \u03a9 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 `\u03a9` 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 (\u03b3 : \u211d \u2192 E \u2192 loop F) : Prop :=\n(t_le_zero : \u2200 x, \u2200 t \u2264 0, \u03b3 t x = \u03b3 0 x)\n(t_ge_one : \u2200 x, \u2200 t \u2265 1, \u03b3 t x = \u03b3 1 x)\n(t_zero : \u2200 x s, \u03b3 0 x s = b x)\n(s_zero : \u2200 x t, \u03b3 t x 0 = b x)\n(avg : \u2200 x, (\u03b3 1 x).average = g x)\n(mem_\u03a9 : \u2200 x t s, (x, \u03b3 t x s) \u2208 \u03a9)\n(smooth : \ud835\udc9e \u221e \u21bf\u03b3)\n(rel_K : \u2200\u1da0 x in \ud835\udcdd\u02e2 K, \u2200 t s, \u03b3 t x s = b x)\n\nvariables {g b \u03a9 U K}\n\n\ntheorem exist_loops [finite_dimensional \u211d E]\n  (hK : is_compact K)\n  (h\u03a9_op : is_open \u03a9)\n  (hg : \ud835\udc9e \u221e g) (hb : \ud835\udc9e \u221e b)\n  (hgK : \u2200\u1da0 x near K, g x = b x)\n  (hconv : \u2200 x, g x \u2208 hull (connected_component_in (prod.mk x \u207b\u00b9' \u03a9) $ b x)) :\n  \u2203 \u03b3 : \u211d \u2192 E \u2192 loop F, nice_loop g b \u03a9 K \u03b3 :=\nbegin\n  obtain \u27e8\u03b3\u2081, h\u03b3\u2081, hs\u03b3\u2081, h2\u03b3\u2081\u27e9 := exist_loops_aux2 hK h\u03a9_op hg hb hgK hconv,\n  let \u03b3\u2082 : smooth_surrounding_family g :=\n    \u27e8hg, \u03bb x, \u03b3\u2081 x 1, hs\u03b3\u2081.comp\u2083 cont_diff_fst cont_diff_const cont_diff_snd,\n      \u03bb x, h\u03b3\u2081.surrounds x (mem_univ _)\u27e9,\n  classical,\n  let \u03b3\u2083 : \u211d \u2192 E \u2192 loop F :=\n  \u03bb t x, (\u03b3\u2081 x t).reparam $ (\u03b3\u2082.reparametrize x).equivariant_map,\n  have h\u03b3\u2083 : \ud835\udc9e \u221e \u21bf\u03b3\u2083 :=\n    hs\u03b3\u2081.comp\u2083 cont_diff_snd.fst cont_diff_fst (\u03b3\u2082.reparametrize_smooth.snd'),\n  obtain \u27e8\u03c7, h\u03c7, h1\u03c7, h0\u03c7, h2\u03c7\u27e9 := exists_cont_diff_one_nhds_of_interior hK.is_closed\n    (subset_interior_iff_mem_nhds_set.mpr $ hgK.and h2\u03b3\u2081),\n  simp_rw [\u2190 or_iff_not_imp_left] at h0\u03c7,\n  let \u03b3 : \u211d \u2192 E \u2192 loop F :=\n  \u03bb t x, \u03c7 x \u2022 loop.const (b x) + (1 - \u03c7 x) \u2022 \u03b3\u2083 t x,\n  have h1\u03b3 : \u2200 x, \u2200 t \u2264 0, \u03b3 t x = \u03b3 0 x,\n  { intros x t ht, ext s, simp [h\u03b3\u2081.to_sf.t_le_zero _ _ ht] },\n  have h2\u03b3 : \u2200 x, \u2200 t \u2265 1, \u03b3 t x = \u03b3 1 x,\n  { intros x t ht, ext s, simp [h\u03b3\u2081.to_sf.t_ge_one _ _ ht] },\n  refine \u27e8\u03b3, h1\u03b3, h2\u03b3, _, _, _, _, _, _\u27e9,\n  { intros x t, simp [h\u03b3\u2081.t\u2080] },\n  { intros x t, simp [h\u03b3\u2081.base] },\n  { intros x,\n    have h1 : interval_integrable (\u03c7 x \u2022 loop.const (b x) : loop F) volume 0 1,\n    { show interval_integrable (\u03bb t, \u03c7 x \u2022 b x) volume (0 : \u211d) (1 : \u211d),\n      exact interval_integrable_const, },\n    have h2 : interval_integrable ((1 - \u03c7 x) \u2022 \u03b3\u2083 1 x : loop F) volume 0 1 :=\n    ((h\u03b3\u2083.comp\u2083 cont_diff_const cont_diff_const cont_diff_id)\n      .continuous.interval_integrable _ _).smul _,\n    have h3 : (\u03b3\u2083 1 x).average = g x := \u03b3\u2082.reparametrize_average x,\n    simp [h1, h2, h3],\n    rcases h0\u03c7 x with \u27e8hx,-\u27e9|hx,\n    { rw [hx, smul_add_one_sub_smul] },\n    { simp [hx] } },\n  { intros x t s,\n    have : \u2200 (P : F \u2192 Prop) t, (\u2200 t \u2208 I, P (\u03b3 t x s)) \u2192 P (\u03b3 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 \u27e8h1t, h2t\u27e9},\n      { rw [h2\u03b3 x t h2t], exact hP 1 \u27e8zero_le_one, le_rfl\u27e9 },\n      { rw [h1\u03b3 x t h1t], exact hP 0 \u27e8le_rfl, zero_le_one\u27e9 } },\n    refine this (\u03bb y, (x, y) \u2208 \u03a9) t (\u03bb t ht, _),\n    rcases h0\u03c7 x with \u27e8hx, h2x\u27e9|hx,\n    { refine h2x t (\u03b3\u2082.reparametrize x s) _, simp [\u03b3, dist_smul_add_one_sub_smul_le (h2\u03c7 x)] },\n    { simp [hx], apply h\u03b3\u2081.val_in (mem_univ _) } },\n  { exact (h\u03c7.fst'.snd'.smul hb.fst'.snd').add ((cont_diff_const.sub h\u03c7.fst'.snd').smul h\u03b3\u2083) },\n  { exact h1\u03c7.mono (\u03bb x (hx : \u03c7 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 (\u03b1 : Type*) :=\n  (carrier  : Type)\n  (rows     : \u03b1 \u2192 \u2115)\n  (cols     : \u03b1 \u2192 \u2115)\n  (nonempty : \u03a0g, rows g * cols g > 0)\n  (data     : \u03a0g, fin (rows g) \u2192 fin (cols g) \u2192 carrier)\n\nclass grid (\u03b1 : Type*) extends relative_grid \u03b1 :=\n  (bl : \u03b1 \u2192 point)\n\nsection grid_defs\n\nvariables {\u03b1 : Type*} [grid \u03b1] (g : \u03b1)\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 : \u2115) : point :=\n  \u27e8bl.x + c, bl.y + r\u27e9\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 := \u27e8(bl g).x, (bl g).y + rows g\u27e9\n\ndef br : point := \u27e8(bl g).x + cols g, (bl g).y\u27e9\n\nlemma expand_gbl : gbl g = bl g := by simp\n\nlemma expand_gtr : gtr g = \u27e8(bl g).x + cols g, (bl g).y + rows g\u27e9 :=\n  by simp [gtr, tr]\n\nlemma blx_eq_tlx {g : \u03b1} : (bl g).x = (tl g).x := by simp [bl, tl]\n\nlemma brx_eq_trx {g : \u03b1} : (br g).x = (gtr g).x := by simp [br, expand_gtr]\n\nlemma bly_eq_bry {g : \u03b1} : (bl g).y = (br g).y := by simp [br]\n\nlemma tly_eq_try {g : \u03b1} : (tl g).y = (gtr g).y := by simp [expand_gtr, tl]\n\nstructure bounding_box := (p\u2081 : point) (p\u2082 : point) (h : p\u2081 \u2197 p\u2082)\n\ndef bbox_str : bounding_box \u2192 string\n  | \u27e8p\u2081, p\u2082, _\u27e9 := \"<(\" ++ to_string p\u2081 ++ \", \" ++ to_string p\u2082 ++ \")>\"\n\ninstance : has_to_string bounding_box := \u27e8bbox_str\u27e9\n\ninstance : has_repr bounding_box := \u27e8bbox_str\u27e9\n\ndef bb_eq (bb\u2081 bb\u2082 : bounding_box) := bb\u2081.p\u2081 = bb\u2082.p\u2082 \u2227 bb\u2081.p\u2082 = bb\u2082.p\u2082\n\ninstance dec_eq_bb {bb\u2081 bb\u2082} : decidable (bb_eq bb\u2081 bb\u2082) :=\n  by simp [bb_eq]; apply_instance\n\ninstance : decidable_eq bounding_box :=\n  \u03bbbb\u2081 bb\u2082, begin\n              cases bb\u2081, cases bb\u2082,\n              simp, apply_instance\n            end\n\ndef points_of_box (bb : bounding_box) : point \u00d7 point := \u27e8bb.p\u2081, bb.p\u2082\u27e9\n\ndef rows_of_box (bb : bounding_box) : \u2115 :=\n  |bb.p\u2082.y - bb.p\u2081.y|\n \ndef cols_of_box (bb : bounding_box) : \u2115 :=\n  |bb.p\u2082.x - bb.p\u2081.x|\n\ndef bb_size (bb : bounding_box) := rows_of_box bb * cols_of_box bb\n\nprivate def data_option (g : \u03b1) (x y : \u2115) :=\n  if h : y < cols g\n  then if h\u2081 : x < rows g\n       then some $ data g \u27e8x, h\u2081\u27e9 \u27e8y, h\u27e9\n       else none\n  else none\n\nend grid_defs\n\nsection grid_lemmas\n\nopen grid relative_grid function\n\nvariables {\u03b1 : Type*} [grid \u03b1] {g : \u03b1}\n\nprivate theorem data_data_option {x y : \u2115}\n  (h\u2081 : y < rows g) (h\u2082 : x < cols g) :\n  some (data g \u27e8y, h\u2081\u27e9 \u27e8x, h\u2082\u27e9) = 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 \u27e8\u27e8_, y\u2081\u27e9, \u27e8_, y\u2082\u27e9, h\u27e9 := bb in\nbegin\n  simp only [rows_of_box, gt_from_lt], simp [grid_bounded_iff] at h,\n  rw [\u2190 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 \u27e8\u27e8x\u2081, _\u27e9, \u27e8x\u2082, _\u27e9, h\u27e9 := bb in\nbegin\n  simp only [cols_of_box, gt_from_lt], simp [grid_bounded_iff] at h,\n  rw [\u2190 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 : \u2124) < \u2191(rows g) := by simp [rows_pos]\n\nlemma coe_cols_pos {g : \u03b1} : (0 : \u2124) < \u2191(cols g) := by simp [cols_pos]\n\nlemma idx_div_cols_bounded {n} (h : n < size g) :\n  (bl g).y + \u2191n / \u2191(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 : \u2115} :\n  (bl g).x + \u2191n % \u2191(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 \u2197 gtr g :=\nlet \u27e8h\u2081, h\u2082\u27e9 := gt_and_gt_of_mul_gt (nonempty g) in\n  grid_bounded_iff.2 \u27e8\n    by simpa [expand_gtr],\n    by simpa [expand_gtr]\n  \u27e9\n\nstructure relative_point (g : \u03b1) :=\n  (x : fin (rows g))\n  (y : fin (cols g))\n\ndef relative_point_str (g : \u03b1) : relative_point g \u2192 string\n  | \u27e8x, y\u27e9 := \"[\" ++ to_string x ++ \", \" ++ to_string y ++ \"]\"\n\ninstance : has_to_string (relative_point g) :=\n  \u27e8relative_point_str g\u27e9\n\ninstance : has_repr (relative_point g) :=\n  \u27e8relative_point_str g\u27e9\n\nstructure grid_point (g : \u03b1) :=\n  (y : bounded (bl g).y (gtr g).y)\n  (x : bounded (bl g).x (gtr g).x)\n\ndef grid_point_str (g : \u03b1) : grid_point g \u2192 string\n  | \u27e8x, y\u27e9 := \"[\" ++ to_string x ++ \", \" ++ to_string y ++ \"] - \"\n              ++ to_string (bl g)\n\ninstance : has_to_string (grid_point g) := \u27e8grid_point_str g\u27e9\n\ninstance : has_repr (grid_point g) := \u27e8grid_point_str g\u27e9\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 \u25b8 expand_gbl g \u25b8 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  \u2191(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 : \u03b1} (p : grid_point g) : relative_point g :=\n    \u27e8\n      \u27e8|p.y.1 - (bl g).y|,  \n       begin\n         rcases p with \u27e8\u27e8x, \u27e8xl, xu\u27e9\u27e9, \u27e8y, \u27e8yl, yu\u27e9\u27e9\u27e9, simp,\n         have eq\u2081 : x + -(bl g).y \u2265 0, by linarith,\n         have eq\u2082 : (gtr g).y - (bl g).y \u2265 0, by simp [expand_gtr]; linarith,\n         rw [\n           \u2190 int.coe_nat_lt_coe_nat_iff, rows_eq_try_sub_bly,\n           int.nat_abs_of_nonneg eq\u2081, int.nat_abs_of_nonneg eq\u2082\n         ],\n         linarith\n       end\n      \u27e9,\n      \u27e8|p.x.1 - (bl g).x|,\n       have h : p.x.1 - (tl g).x \u2265 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 \u25b8\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      \u27e9\n    \u27e9\n\ndef gpoint_of_relpoint {g : \u03b1} (p : relative_point g) : grid_point g :=\n  \u27e8\n    \u27e8(bl g).y + p.x.1,\n      \u27e8\n        by simp [tl, expand_gtr],\n        by rcases p with \u27e8\u27e8_, h\u27e9, _\u27e9; simp only [tl, expand_gtr, h]; linarith\n      \u27e9\n    \u27e9,\n    \u27e8(bl g).x + p.y.1,\n      \u27e8\n        by simp [tl],\n        by rcases p with \u27e8\u27e8_, _\u27e9, \u27e8_, h\u27e9\u27e9; simp only [tl, expand_gtr, h]; linarith\n      \u27e9\n    \u27e9\n  \u27e9\n\nlemma relpoint_gpoint_id {g : \u03b1} {p : grid_point g} :\n  gpoint_of_relpoint (relpoint_of_gpoint p) = p :=\nbegin\n  rcases p with \u27e8\u27e8x, \u27e8hx\u2081, _\u27e9\u27e9, \u27e8y, \u27e8hy\u2081, _\u27e9\u27e9\u27e9,\n  simp [relpoint_of_gpoint, gpoint_of_relpoint, -sub_eq_add_neg],\n  have : x - (bl g).y \u2265 0, by linarith,\n  have : y - (bl g).x \u2265 0, by linarith,\n  split; rw int.nat_abs_of_nonneg; try { simp }; assumption\nend\n\nlemma gpoint_relpoint_id {g : \u03b1} {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 : \u03b1} (rp : relative_point g) := (rp.x, rp.y)\n\ndef prod_of_grid_point {g : \u03b1} (ap : grid_point g) := (ap.x, ap.y)\n\ndef grid_point_of_prod {g : \u03b1}\n  (p : bounded (bl g).x (gtr g).x \u00d7\n       bounded (bl g).y (gtr g).y) : grid_point g :=\n  \u27e8p.snd, p.fst\u27e9\n\ndef grid_point_of_prod' {g : \u03b1}\n  (p : bounded (bl g).y (gtr g).y \u00d7\n       bounded (bl g).x (gtr g).x) : grid_point g :=\n  \u27e8p.fst, p.snd\u27e9\n\ndef abs_data (g : \u03b1) (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 : \u2124}\n  (h : a < b) (x : bounded 0 ( |b - a| )) :\n  a \u2264 a + \u2191x \u2227 a + \u2191x < b :=\nhave xpos : \u2191x \u2265 0, from positive_bounded _,\nhave xmax : \u2191x < |b - a|, from bounded_lt _,\n  \u27e8\n    by apply le_add_of_nonneg_right; unfold coe,\n    begin\n      unfold_coes at *,\n      rw add_comm,\n      rw [\u2190 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          \u2190 sub_eq_add_neg, \u2190 add_le_add_iff_right a,\n          zero_add, sub_add_cancel\n        ],\n        exact int.le_of_lt h,\n      }\n    end\n  \u27e9\n\nend grid_lemmas\n\nend grids\n\nsection grid_impls\n\nstructure vec_grid (\u03b1 : Type) :=\n  (r : \u2115)\n  (c : \u2115)\n  (h : r * c > 0)\n  (data : vector \u03b1 (r * c))\n\nstructure vec_grid\u2080 (\u03b1 : Type) extends vec_grid \u03b1 :=\n  (o : point)\n\nstructure fgrid\u2080 (\u03b1 : Type) :=\n  (r : \u2115)\n  (c : \u2115)\n  (h : r * c > 0)\n  (o : point)\n  (data : bounded o.y (o.y + r) \u2192 bounded o.x (o.x + c) \u2192 \u03b1)\n\nend grid_impls\n\nsection grid_instances\n\nopen relative_grid grid\n\nlemma data_not_empty {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} : \u00acempty_list g.data.to_list :=\nassume contra,\nbegin\n  simp [empty_list] at contra,\n  have contra\u2081 := contra.symm,\n  rw [list_empty_iff_len, vector.to_list_length] at contra\u2081,\n  rcases g with \u27e8\u27e8_, _, h,_\u27e9, _\u27e9,\n  linarith\nend\n\nlemma linearize_array {x y r c : \u2115}\n  (xb : x < c) (yb : y < r) : y * c + x < r * c :=\nhave h\u2081 : y * c < r * c, by apply mul_lt_mul yb; omega,\nhave h\u2082 : \u2203n, nat.succ y + n = r, from nat_le_dest yb,\nlet \u27e8n, h\u2082\u27e9 := h\u2082 in\n  by rw [\u2190 h\u2082, right_distrib, nat.succ_mul, add_assoc]; linarith\n\ndef rel_point_to_fin {\u03b1 : Type} [grid \u03b1] {g : \u03b1}\n  (p : relative_point g) : fin (size g) :=\n  \u27e8p.x * cols g + p.y, linearize_array p.y.2 p.x.2\u27e9\n\ndef grid_point_to_fin {\u03b1 : Type} [grid \u03b1] {g : \u03b1}\n  (p : grid_point g) : fin (size g) := rel_point_to_fin (relpoint_of_gpoint p)\n\nlemma expand_grid_point_to_fin {\u03b1 : Type} [grid \u03b1] {g : \u03b1}\n  (p : grid_point g) : grid_point_to_fin p =\n  \u27e8|p.y.1 - (bl g).y| * cols g + |p.x.1 - (bl g).x|,\n  linearize_array\n    begin\n      rcases p with \u27e8_, \u27e8y, \u27e8_, yu\u27e9\u27e9\u27e9,\n      simp only [tl], rw \u2190 int.coe_nat_lt_coe_nat_iff,\n      have : y - (grid.bl g).x \u2265 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 \u27e8\u27e8x, \u27e8xl, xu\u27e9\u27e9, _\u27e9,\n      simp only [tl], rw \u2190 int.coe_nat_lt_coe_nat_iff,\n      have : x - (bl g).y \u2265 0, by linarith,\n      rw [int.nat_abs_of_nonneg this, rows_eq_try_sub_bly'],\n      linarith\n    end\u27e9 :=\n  by simp [grid_point_to_fin, relpoint_of_gpoint, rel_point_to_fin]; unfold_coes\n\ninstance rg_vec_grid {\u03b1 : Type} :\n  relative_grid (vec_grid \u03b1) := {\n    carrier  := \u03b1,\n    rows     := \u03bbg, g.r,\n    cols     := \u03bbg, g.c,\n    nonempty := \u03bbg, g.h,\n    data     :=\n    \u03bbg y x,\n      g.data.nth \u27e8\n        y.1 * g.c + x.1,\n        linearize_array x.2 y.2\n      \u27e9    \n}\n\ninstance rg_vec_grid\u2080 {\u03b1 : Type} :\n  relative_grid (vec_grid\u2080 \u03b1) := {\n    carrier  := \u03b1,\n    rows     := \u03bbg, g.r,\n    cols     := \u03bbg, g.c,\n    nonempty := \u03bbg, g.h,\n    data     :=\n    \u03bbg y x,\n      g.data.nth \u27e8\n        y.1 * g.c + x.1,\n        linearize_array x.2 y.2\n      \u27e9   \n}\n\nprivate lemma absolute_bounds {o : \u2124} {r : \u2115}\n                              (x : fin r) : o + \u2191x < o + \u2191r :=\n  by simp; cases x; unfold_coes; simpa\n\ninstance rg_fgrid\u2080 {\u03b1 : Type} :\n  relative_grid (fgrid\u2080 \u03b1) := {\n    carrier  := \u03b1,\n    rows     := \u03bbg, g.r,\n    cols     := \u03bbg, g.c,\n    nonempty := \u03bbg, g.h,\n    data     := \u03bbg y x,\n      g.data \u27e8g.o.y + y, \u27e8by simp, absolute_bounds _\u27e9\u27e9\n             \u27e8g.o.x + x, \u27e8by simp, absolute_bounds _\u27e9\u27e9\n}\n\ninstance ag_vec_agrid\u2080 {\u03b1 : Type} :\n  grid (vec_grid\u2080 \u03b1) := {\n    bl := \u03bbg, g.o\n  }\n\ninstance ag_fgrid\u2080 {\u03b1 : Type} :\n  grid (fgrid\u2080 \u03b1) := {\n    bl := \u03bbg, g.o\n  }\n\ndef point_of_grid_point {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} : grid_point g \u2192 point\n  | \u27e8b\u2081, b\u2082\u27e9 := \u27e8b\u2082, b\u2081\u27e9\n\ninstance point_grid_point_coe {\u03b1 : Type*} [grid \u03b1] (g : \u03b1) :\n  has_coe (grid_point g) point := \u27e8point_of_grid_point\u27e9\n\nend grid_instances\n\nsection finite_grid\n\nopen list int function\n\nsection spec\n\nopen grid relative_grid\n\nvariables {\u03b1 : Type} {ag : vec_grid\u2080 \u03b1} {fg : fgrid\u2080 \u03b1}\n\nlemma coe_rows_pos_a : \u2191ag.r > (0 : \u2124) :=\n  by change ag.r with (rows ag); simp [gt_from_lt, rows_pos]\n\nlemma coe_rows_pos_f : \u2191fg.r > (0 : \u2124) :=\n  by change fg.r with (rows fg); simp [gt_from_lt, rows_pos]\n\nlemma coe_cols_pos_a : \u2191ag.c > (0 : \u2124) :=\n  by change ag.c with (cols ag); simp [gt_from_lt, cols_pos]\n\nlemma coe_cols_pos_f : \u2191fg.c > (0 : \u2124) :=\n  by change fg.c with (cols fg); simp [gt_from_lt, cols_pos]\n\nend spec\n\nvariables {\u03b1 : Type*} [grid \u03b1] (g : \u03b1)\n\ndef grp (a b row : \u2124) : 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  \u27e8a, r\u27e9 :: grp (a + 1) b r :=\nbegin\n  conv_lhs { simp only [grp] },\n  rw range_pure_next h,\n  have : |b - a| \u2265 1, from nat_abs_ge_one_of_lt h,\n  rw repeat_more this, simp [-sub_eq_add_neg],\n  exact \u27e8\n    by simp [uncurry],\n    by simp [grp, -sub_eq_add_neg, abs_minus_plus h]\n  \u27e9\nend\n\nprivate lemma expand_grp_g {g : \u03b1} :\n  grp (gbl g).x (gtr g).x (gtr g).y =\n  \u27e8(gbl g).x, (gtr g).y\u27e9 ::\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\u2081 : 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 \u2190 cols_eq_trx_sub_blx,\n      exact abs_cols_pos\n    },\n  simp only [map, h\u2081, zip_cons_cons],\n  exact \u27e8\n    by simp [uncurry],\n    by rw abs_minus_plus;\n       exact (grid_bounded_iff.1 grid_is_bounding_box).1\n  \u27e9\nend\n\nprivate lemma grp_empty_iff {a b r} :\n  empty_list (grp a b r) \u2194 b \u2264 a :=\n  \u27e8\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  \u27e9\n\nlemma grp_empty_iff' {a b r} : grp a b r = [] \u2194 (b \u2264 a) :=\nbegin\n  split; intros h,\n    {rw \u2190 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\u2081 : p \u2208 grp a b r) :\n  p.y = r :=\nbegin\n  cases p with px py, simp only [point.y] at *,\n  revert h\u2081,\n  induction eq : grp a b r with hd tl generalizing a; intros,\n    {cases h\u2081},\n    {\n      by_cases h : a < b,\n        {\n          rw expand_grp h at eq, injection eq with eq\u2081 eq\u2082,\n          rw mem_cons_iff at h\u2081, cases h\u2081 with h\u2081 h\u2081,\n            {cc},\n            {\n              by_cases h\u2082 : a + 1 < b,\n                {exact ih eq\u2082 h\u2081,},\n                {\n                  rw not_lt at h\u2082, \n                  rw grp_empty_iff'.2 h\u2082 at eq\u2082, subst eq\u2082,\n                  cases h\u2081\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\u2080 : a < b) :\n  c \u2208 grp a b r \u2194 is_bounded a b c.x \u2227 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 \u27e8a\u2081, b\u2082, \u27e8h\u2081, h\u2082\u27e9\u27e9,\n      have : a\u2081 \u2208 range_pure a b, from pair_in_zip_l h\u2081,\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 \u27e8\u27e8h, h\u2081\u27e9, h\u2082\u27e9, simp [grp, -sub_eq_add_neg, uncurry],\n      use x, use y, split,\n        {\n          apply in_zip_of_and, intros, subst h\u2082, \n          exact eq_of_mem_repeat H,\n          rw in_range_pure_iff, unfold is_bounded, exact \u27e8h, h\u2081\u27e9,\n          rw length_repeat, rw range_length_pure (int.le_of_lt h\u2080)\n        },\n        {simp}\n    }\nend\n\nlemma notin_grp_of_lt {p : point} {a b r : \u2124} (h : p.x < a) :\n  p \u2209 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\u2081 : a < b,\n        {\n          rw expand_grp h\u2081 at eq, injection eq with eq\u2081 eq\u2082, clear eq,\n          intros contra, cases contra,\n            {subst eq\u2081, subst eq\u2082, cases contra, linarith},\n            {\n              by_cases h\u2082 : a + 1 < b,\n                {\n                  specialize @ih (a + 1) (by linarith) eq\u2082,\n                  contradiction\n                },\n                {\n                  rw not_lt at h\u2082, rw grp_empty_iff'.2 h\u2082 at eq\u2082,\n                  subst eq\u2082, cases contra\n                }\n            }\n        },\n        {rw not_lt at h\u2081, rw grp_empty_iff'.2 h\u2081 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\u2081 eq\u2082,\n          rw nodup_cons, split,\n            {\n              rw [\u2190 eq\u2082, \u2190 eq\u2081],\n              apply notin_grp_of_lt,\n              simp only [point.x], linarith\n            },\n            {exact ih eq\u2082}\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 : \u2124} :\n  \u2200{c : point}, c \u2208 grp a b row \u2192\n    is_bounded a b c.x \u2227 is_bounded row (row + 1) c.y :=\nassume c h,\nbegin\n  simp [grp] at h,\n  rcases h with \u27e8a\u2081, \u27e8b\u2081, \u27e8h\u2082, h\u2083\u27e9\u27e9\u27e9,\n  have h\u2084 : a\u2081 \u2208 range_pure a b, from pair_in_zip_l h\u2082,\n  have h\u2085 : b\u2081 \u2208 repeat row ( |b + -a| ), from pair_in_zip_r h\u2082,\n  rw \u2190 h\u2083,\n  split; split,\n    {exact (range_pure_bounded h\u2084).1},\n    {exact (range_pure_bounded h\u2084).2},\n    {simp [repeat_bounded h\u2085, uncurry]},\n    {rw (repeat_bounded h\u2085), exact lt_add_succ _ _}\nend\n\nlemma length_grp {a b : \u2124} (h : a < b) {x : \u2124} :\n  length (grp a b x) = |b - a| :=\nhave h\u2081 : 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\u2081]\n\nlemma injective_grp {a b} (h : a < b) : injective (grp a b) :=\nbegin\n  intros a\u2081 a\u2082,\n  induction eq : grp a b a\u2081 with hd tl ih generalizing a; intros h\u2081,\n    {rw expand_grp h at eq, cases eq},\n    {\n      rw expand_grp h at eq h\u2081,\n      injection eq with eq\u2081 eq\u2082, injection h\u2081 with h\u2082 h\u2083,\n      by_cases alt : a + 1 < b,\n        {exact ih alt eq\u2082 h\u2083},\n        {cc}\n    }\nend\n\nlemma disjoint_grp_neq_row {a b r\u2081 r\u2082} (h\u2080 : r\u2081 \u2260 r\u2082) :\n  disjoint (grp a b r\u2081) (grp a b r\u2082) :=\nbegin\n  by_cases h : a < b,\n    {\n      induction eq : grp a b r\u2081 with hd tl ih generalizing a,\n        {rw expand_grp h at eq, cases eq},\n        {\n          cases eq\u2081 : grp a b r\u2082 with hd\u2081 tl\u2081,\n            {rw expand_grp h at eq\u2081, cases eq\u2081},\n            {\n              rw expand_grp h at eq\u2081, rw expand_grp h at eq,\n              injection eq\u2081 with eq\u2082 eq\u2083,\n              injection eq with eq\u2084 eq\u2085,\n              clear eq eq\u2081,\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 \u2190 eq\u2085 at contra,\n                      have : hd\u2081.y = r\u2081, from in_grp_second contra,\n                      clear contra, subst this, subst eq\u2084, subst eq\u2085, subst eq\u2082,\n                      cc\n                    }\n                },\n                {\n                  split,\n                    {\n                      intros contra, rw \u2190 eq\u2083 at contra,\n                      have : hd.y = r\u2082, from in_grp_second contra,\n                      clear contra, subst this, subst eq\u2084, subst eq\u2085, subst eq\u2082,\n                      cc \n                    },\n                    {\n                      rw \u2190 eq\u2083,\n                      by_cases h\u2081 : a + 1 < b,\n                        {\n                          exact ih h\u2081 eq\u2085\n                        },\n                        {\n                          rw not_lt at h\u2081,\n                          rw [grp_empty_iff'.2 h\u2081, 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\u2081 p\u2082 : point) : list point :=\n  join (map (grp p\u2081.x p\u2082.x) (range_pure p\u2081.y p\u2082.y))\n\nlemma gip_no_dup {p\u2081 p\u2082} : nodup (gip p\u2081 p\u2082) :=\nbegin\n  cases p\u2081 with p\u2081x p\u2081y,\n  cases p\u2082 with p\u2082x p\u2082y,\n  simp only [gip, nodup_join],\n  split,\n    {\n      intros l hl, \n      by_cases h : p\u2081x < p\u2082x,\n        {\n          have : nodup (map (grp p\u2081x p\u2082x) (range_pure p\u2081y p\u2082y)),\n            from nodup_map (injective_grp h) (nodup_range_pure),\n          induction l with hd tl ih generalizing p\u2081x,\n            {exact nodup_nil},\n            {\n              simp only [map, mem_map] at hl,\n              rcases hl with \u27e8l, \u27e8c\u2081, c\u2082\u27e9\u27e9, rw \u2190 c\u2082,\n              exact nodup_grp\n            }\n        },\n        {\n          rw not_lt at h, simp only [map, mem_map] at hl,\n          rcases hl with \u27e8l', \u27e8c\u2081, c\u2082\u27e9\u27e9,\n          rw grp_empty_iff'.2 h at c\u2082,\n          simp [c\u2082.symm, nodup_nil]\n        }\n    },\n    {\n      induction eq : range_pure p\u2081y p\u2082y with hd tl ih generalizing p\u2081y,\n        {simp, constructor},\n        {\n          by_cases h : p\u2081y < p\u2082y,\n            {\n              rw range_pure_next h at eq, injection eq with eq\u2081 eq\u2082,\n              specialize @ih (p\u2081y + 1) eq\u2082,\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\u2081 h\u2082, subst h\u2082,\n              have : x \u2260 hd,\n                {\n                  intros contra, subst contra, subst eq\u2081,\n                  rw \u2190 eq\u2082 at h\u2081,\n                  have : p\u2081y \u2209 range_pure (p\u2081y + 1) p\u2082y,\n                    from @notin_range_pure_of_lt (p\u2081y + 1) p\u2082y p\u2081y (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\u2081 p\u2082} (h : p\u2081 \u2197 p\u2082) :\n  gip p\u2081 p\u2082 = \u27e8p\u2081.x, p\u2081.y\u27e9 :: grp (p\u2081.x + 1) p\u2082.x p\u2081.y\n           ++ gip \u27e8p\u2081.x, p\u2081.y + 1\u27e9 p\u2082 :=\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\u2081 p\u2082} (h : p\u2081 \u2197 p\u2082) :\n  gip p\u2081 p\u2082 =\n  grp p\u2081.x p\u2082.x p\u2081.y ++ gip \u27e8p\u2081.x, p\u2081.y + 1\u27e9 p\u2082 :=\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 \u27e8(gbl g).x, (gbl g).y + 1\u27e9 \u27e8(gtr g).x, ((gtr g).y)\u27e9 :=\nbegin\n  generalize h : gip \u27e8(gbl g).x, (gbl g).y\u27e9 \u27e8(gtr g).x, ((gtr g).y + 1)\u27e9 = 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 \u2227\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\u2081.y bb.p\u2082.y xy.y \u2227 is_bounded bb.p\u2081.x bb.p\u2082.x xy.x\n\nattribute [reducible]\ninstance has_mem_grid : has_mem point \u03b1 := \u27e8flip is_in_grid'\u27e9\n\nattribute [reducible]\ninstance has_mem_bb : has_mem point bounding_box := \u27e8flip is_in_grid\u27e9\n\nlemma gip_in_grid {p\u2081 p\u2082 : point} {h : p\u2081 \u2197 p\u2082} :\n  \u2200{a}, a \u2208 gip p\u2081 p\u2082 \u2192 a \u2208 (\u27e8p\u2081, p\u2082, h\u27e9 : bounding_box) :=\nassume a h,\nbegin\n  simp [gip] at h,\n  cases a with al ar,\n  rcases h with \u27e8l, \u27e8\u27e8a\u2081, \u27e8h\u2082, h\u2083\u27e9\u27e9, h\u2081\u27e9\u27e9,\n  have h\u2084 := range_pure_bounded h\u2082, rw \u2190 h\u2083 at h\u2081,\n  have h\u2085 := grp_bounds h\u2081,\n  split; split,\n    {\n      simp [bounding_box.p\u2081],\n      rcases h\u2085 with \u27e8\u27e8h\u2085l\u2081, h\u2085l\u2082\u27e9, \u27e8h\u2085r\u2081, h\u2085r\u2082\u27e9\u27e9,\n      cases h\u2084, transitivity a\u2081; assumption\n    },\n    {exact lt_of_le_of_lt (le_of_lt_add_one h\u2085.2.2) h\u2084.2},\n    {exact h\u2085.1.1},\n    {exact h\u2085.1.2}\nend\n\ndef grid_bounds : bounding_box :=\n  \u27e8gbl g, gtr g, grid_is_bounding_box\u27e9\n\nlemma grid_bounds_p\u2081 : (grid_bounds g).p\u2081 = gbl g := rfl\n\nlemma grid_bounds_p\u2082 : (grid_bounds g).p\u2082 = gtr g := rfl\n\nlemma gip_g_in_grid {g : \u03b1} :\n  \u2200{a}, a \u2208 gip_g g \u2192 a \u2208 (grid_bounds g) :=\n  assume a h, gip_in_grid h\n\ndef make_bounded_idx {g : \u03b1} {p : point} (h : p \u2208 (grid_bounds g)) :\n  bounded (bl g).x (gtr g).x \u00d7\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 : \u2200p, p \u2208 is \u2192 p \u2208 (grid_bounds g)) :\n  list (\n    bounded (bl g).x (gtr g).x \u00d7\n    bounded (gbl g).y (gtr g).y\n  ) := map (\u03bbp : {x // x \u2208 is},\n           (\u27e8p.1.1, (h p.1 p.2).2\u27e9,\n            \u27e8p.1.2, (h p.1 p.2).1\u27e9)) (attach is)\n\nlemma is_bounded_y_of_grid_bounds {g : \u03b1} {p} (h : p \u2208 (grid_bounds g)) :\n  is_bounded (bl g).y (gtr g).y p.y :=\n  by simp [grid_bounds, (\u2208), flip, is_in_grid] at h; exact h.1\n\nlemma is_bounded_x_of_grid_bounds {g : \u03b1} {p} (h : p \u2208 (grid_bounds g)) :\n  is_bounded (bl g).x (gtr g).x p.x :=\n  by simp [grid_bounds, (\u2208), 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 \u2208 g) :=\n   by simp [(\u2208), is_in_grid', flip]; apply_instance\n\ninstance decidable_is_in_grid_op (bb : bounding_box) {xy : point}\n   : decidable (xy \u2208 bb) :=\n   by simp [is_in_grid, (\u2208), flip]; apply_instance\n\ndef inject_into_bounded (p : {x // x \u2208 gip_g g}) :\n  bounded (bl g).x (gtr g).x \u00d7\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 \u2208 grp a b r}) :\n  bounded a b \u00d7 bounded r (r + 1) :=\n  \u27e8\u27e8p.1.1, (grp_bounds p.2).1\u27e9, \u27e8p.1.2, (grp_bounds p.2).2\u27e9\u27e9\n\nprivate lemma blgx_trgx_of_mem {g : \u03b1} {x} {y} (h : point.mk x y \u2208 g) :\n  (bl g).x < (gtr g).x :=\n  by simp only [(\u2208), 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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {p}\n  (h : p \u2208 g) : p \u2208 gip_g g :=\nbegin  \n  cases p with x y,\n  simp [-gtr, gip_g, gip],\n  have h\u2082 : y \u2208 range_pure (gbl g).y (gtr g).y,\n    by simp [(\u2208), flip, is_in_grid'] at h; exact in_range_iff.2 h.1,\n  split, {\n    split,\n      {use y, exact \u27e8h\u2082, by simp [grp]\u27e9},\n      {\n        generalize h\u2082 : range_pure ((bl g).x) ((gtr g).x) = l\u2081,\n        generalize h\u2083 : repeat y ( |(gtr g).x - (bl g).x| ) = l\u2082,\n        rw point_in_zip_prod_iff,\n        apply point_in_zip_repeat_right _ h\u2083 _,\n          {\n            simp [\n              h\u2082.symm, h\u2083.symm, range_length_pure, length_repeat,\n              int.le_of_lt (blgx_trgx_of_mem h)\n            ]\n          },\n          {\n            rw [\u2190 h\u2082, in_range_iff],\n            simp only [(\u2208), flip, is_in_grid'] at h,\n            exact h.2\n          }\n      }\n    }\nend\n\ntheorem in_grid_iff_in_gip_g {p} {g : \u03b1} : p \u2208 g \u2194 p \u2208 gip_g g :=\n  \u27e8\n    in_gip_g_of_in_g,\n    \u03bbh, by apply gip_in_grid h; exact grid_is_bounding_box\n  \u27e9\n \nlemma in_grid_iff_in_grid_bounds {p} {g : \u03b1} : p \u2208 grid_bounds g \u2194 p \u2208 g :=\n  by split; intros h;\n       simp [(\u2208), flip, is_in_grid, grid_bounds, is_in_grid'] at *;\n         exact h\n\nlemma is_bounded_rows_of_in_gip_g {p} {g : \u03b1} (h : p \u2208 gip_g g) :\n  is_bounded (gbl g).y ((gbl g).y + \u2191(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 : \u03b1} (h : p \u2208 gip_g g) :\n  is_bounded (gbl g).x ((gbl g).x + \u2191(cols g)) p.x :=\n  (in_grid_iff_in_gip_g.2 h).2\n\ndef grid_point_of_mem {p} (h : p \u2208 g) : grid_point g :=\n  \u27e8make_bounded h.1, make_bounded h.2\u27e9\n\ndef generate :=\n  map (abs_data g \u2218 grid_point_of_prod \u2218 inject_into_bounded g)\n      (attach $ gip_g g)\n\nnotation `\u2118` g:max := generate g\n\nsection grid_instances\n\ninstance vec_grid_functor : functor vec_grid := {\n  map := \u03bb\u03b1 \u03b2 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 := \u03bb\u03b1 \u27e8r, c, h, d\u27e9, by unfold functor.map; simp,\n  comp_map := \u03bb\u03b1 \u03b2 \u03b3 f h \u27e8r, c, h, d\u27e9, by simp [(<$>)]\n}\n\ninstance vec_grid\u2080_functor : functor vec_grid\u2080 := {\n  map := \u03bb\u03b1 \u03b2 f g, {g with data := vector.map f g.data}\n}\n\ninstance vec_grid\u2080_functor_law : is_lawful_functor vec_grid\u2080 := {\n  id_map := \u03bb\u03b1 \u27e8\u27e8r, c, h, d\u27e9, o\u27e9, by simp [(<$>)],\n  comp_map := \u03bb\u03b1 \u03b2 \u03b3 f h \u27e8\u27e8r, c, h, d\u27e9, o\u27e9, by simp [(<$>)]\n}\n\ninstance fgrid\u2080_functor : functor fgrid\u2080 := {\n  map := \u03bb\u03b1 \u03b2 f g, {g with data := \u03bbx y, f (g.data x y)}\n}\n\ninstance fgrid\u2080_functor_law : is_lawful_functor fgrid\u2080 := {\n  id_map := \u03bb\u03b1 \u27e8r, c, h, d, o\u27e9, by simp [(<$>)],\n  comp_map := \u03bb\u03b1 \u03b2 \u03b3 f h \u27e8r, c, h, d, o\u27e9, by simp [(<$>)]\n}\n\nend grid_instances\n\nattribute [simp]\nlemma vec_grid_fmap_r {\u03b1 \u03b2 : Type} {g : vec_grid \u03b1} {f : \u03b1 \u2192 \u03b2} : (f <$> g).r = g.r :=\n  by simp [(<$>)]\n\nattribute [simp]\nlemma vec_grid_fmap_c {\u03b1 \u03b2 : Type} {g : vec_grid \u03b1} {f : \u03b1 \u2192 \u03b2} : (f <$> g).c = g.c :=\n  by simp [(<$>)]\n\nattribute [simp]\nlemma vec_grid\u2080_fmap_r {\u03b1 \u03b2 : Type} {g : vec_grid\u2080 \u03b1} {f : \u03b1 \u2192 \u03b2} : (f <$> g).r = g.r\n  := by simp [(<$>)]\n\nattribute [simp]\nlemma vec_grid\u2080_fmap_c {\u03b1 \u03b2 : Type} {g : vec_grid\u2080 \u03b1} {f : \u03b1 \u2192 \u03b2} : (f <$> g).c = g.c\n  := by simp [(<$>)]\n\nattribute [simp]\nlemma fgrid\u2080_fmap_r {\u03b1 \u03b2 : Type} {g : fgrid\u2080 \u03b1} {f : \u03b1 \u2192 \u03b2} : (f <$> g).r = g.r\n  := by simp [(<$>)]\n\nattribute [simp]\nlemma fgrid\u2080_fmap_c {\u03b1 \u03b2 : Type} {g : fgrid\u2080 \u03b1} {f : \u03b1 \u2192 \u03b2} : (f <$> g).c = g.c\n  := by simp [(<$>)]\n\ndef point_of_bounded_prod {a b c d : \u2124} : bounded a b \u00d7 bounded c d \u2192 point\n  | \u27e8\u27e8a, _\u27e9, \u27e8c, _\u27e9\u27e9 := \u27e8a, c\u27e9\n\nlemma gip_g_nonempty : \u00acempty_list (gip_g g) :=\nassume contra,\nbegin\n  simp [gip_g, gip] at contra,\n  have c\u2081 : \u00acempty_list (\n    range_pure (bl g).y (gtr g).y\n  ),\n    {\n      simp only [empty_list], intros c\u2082, symmetry' at c\u2082,\n      rw range_pure_empty_iff at c\u2082,\n      have c\u2083 := @grid_is_bounding_box _ _ g, rw grid_bounded_iff at c\u2083,\n      exact absurd (lt_of_le_of_lt c\u2082 c\u2083.2) (lt_irrefl _)\n    },\n  have c\u2082 := @not_map_empty_of_not_empty _ _ _\n    (grp (bl g).x (tr (bl g) (rows g) (cols g)).x) c\u2081,\n  have c\u2083 := not_join_empty_of_not_empty contra,\n  cases c\u2083,\n    {contradiction},\n    {\n      revert c\u2083 contra c\u2082 c\u2081,\n      generalize c\u2086 : bl g = bl,\n      generalize c\u2085 : tr bl (rows g) (cols g) = tr',\n      generalize c\u2084 :\n        map (grp bl.x tr'.x) (range_pure bl.y (gtr g).y) = l,\n      let h\u2083 := @grid_is_bounding_box _ _ g, rw grid_bounded_iff at h\u2083,\n      simp [gtr, c\u2086, c\u2085] at h\u2083,\n      intros,\n      have c\u2085 : \u2203z \u2208 l, \u00acempty_list z,\n        {\n          let h := grp bl.x tr'.x bl.y,\n          have h\u2081 : h = grp bl.x tr'.x bl.y, by cc,\n          use h, split,\n            {\n              rw h\u2081, revert c\u2084,\n              generalize h\u2082 : range_pure bl.y tr'.y = l\u2081, intros,\n              cases l\u2081 with w ws,\n                {\n                  rw range_pure_empty_iff at h\u2082,\n                  exact absurd (lt_of_le_of_lt h\u2082 h\u2083.2) (lt_irrefl _)\n                },\n                {\n                  have h\u2084 : w = bl.y,\n                    by unfold1 range_pure at h\u2082; rw if_pos h\u2083.2 at h\u2082;\n                       injection h\u2082 with h\u2083 _; rw h\u2083,\n                  have : bl.y < (gtr g).y, by subst c\u2085; simp [gtr, c\u2086]; exact h\u2083.2,\n                  simp [c\u2084.symm, range_pure_next this]\n                },\n            },\n            {\n              unfold1 grp at h\u2081,\n              have h\u2082 : tr'.x > bl.x, from h\u2083.1,\n              have h\u2084 : range_pure (bl.x) (tr'.x) =\n                        bl.x :: range_pure (bl.x + 1) (tr'.x),\n                from range_pure_next h\u2082,\n              rw h\u2084 at h\u2081,\n              have : |tr'.x - bl.x| \u2265 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\u2085 : 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\u2085, zip_cons_cons, map_cons] at h\u2081, rw h\u2081,\n              apply not_empty_cons\n            }\n        },\n      rcases c\u2085 with \u27e8c\u2085l, \u27e8c\u2085\u2081, c\u2085\u2082\u27e9\u27e9, rw [\u2190 c\u2084, \u2190 c\u2085] at c\u2085\u2081,\n      simp only [gtr] at c\u2083, subst c\u2086,\n      exact absurd (c\u2083 c\u2085l c\u2085\u2081) c\u2085\u2082\n    }\nend\n\nlemma length_gip {p\u2081 p\u2082 : point} (h : p\u2081 \u2197 p\u2082) :\n  length (gip p\u2081 p\u2082) = |p\u2082.y - p\u2081.y| * |p\u2082.x - p\u2081.x| :=\nbegin\n  rw [\u2190 int.coe_nat_eq_coe_nat_iff, \u2190 nat_abs_mul],\n  rw grid_bounded_iff at h,\n  have h\u2081 : (p\u2082.y - p\u2081.y) * (p\u2082.x - p\u2081.x) > 0,\n    {cases p\u2081, cases p\u2082, apply mul_pos; omega},\n  simp [\n    -sub_eq_add_neg, gip, length_join, (\u2218), length_grp h.1,\n    range_length_pure (int.le_of_lt h.2),\n    nat_abs_of_nonneg (int.le_of_lt h\u2081)\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 {\u03b1 : Type*} [grid \u03b1] (g : \u03b1) :\n  length (\u2118 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 (\u2118 g) = size g := by simp [size, length_generate]\n\nlemma map_generate_map_v\u2080 {\u03b1 \u03b2 : Type} {g : vec_grid\u2080 \u03b1} {f : \u03b1 \u2192 \u03b2} :\n  f <$> (\u2118 g) = \u2118 (f <$> g) :=\n  by simpa [(<$>), generate, abs_data, data, vector.nth_map, (\u2218)]\n\nlemma map_generate_map_f\u2080 {\u03b1 \u03b2 : Type} (g : fgrid\u2080 \u03b1) {f : \u03b1 \u2192 \u03b2} :\n  f <$> (\u2118 g) = \u2118 (f <$> g) :=\n  by simpa [(<$>), generate, abs_data, data]\n\nlemma dec_grid_len_eq_indices_len :\n  length (\u2118 g) = length (gip_g g) :=\n  by simp [length_generate, length_gip_g]\n\ndef vec_grid\u2080_of_fgrid\u2080 {\u03b1 : Type} (g : fgrid\u2080 \u03b1) : vec_grid\u2080 \u03b1 :=\n  {g with data := \u27e8\u2118 g, length_generate_eq_size _\u27e9}\n\ndef fgrid\u2080_of_vec_grid\u2080 {\u03b1 : Type} (g : vec_grid\u2080 \u03b1) : fgrid\u2080 \u03b1 :=\n  {g with data := \u03bbx y, abs_data g \u27e8x, y\u27e9}\n\ninstance f\u2080_v\u2080_coe {\u03b1 : Type} : has_coe (fgrid\u2080 \u03b1) (vec_grid\u2080 \u03b1) := \u27e8vec_grid\u2080_of_fgrid\u2080\u27e9\ninstance v\u2080_f\u2080_coe {\u03b1 : Type} : has_coe (vec_grid\u2080 \u03b1) (fgrid\u2080 \u03b1) := \u27e8fgrid\u2080_of_vec_grid\u2080\u27e9\n\nattribute [simp]\nlemma vec_grid\u2080_of_fgrid\u2080_r {\u03b1 : Type} {g : fgrid\u2080 \u03b1} :\n  (vec_grid\u2080_of_fgrid\u2080 g).r = g.r := by simp [vec_grid\u2080_of_fgrid\u2080]\n\nattribute [simp]\nlemma vec_grid\u2080_of_fgrid\u2080_c {\u03b1 : Type} {g : fgrid\u2080 \u03b1} :\n  (vec_grid\u2080_of_fgrid\u2080 g).c = g.c := by simp [vec_grid\u2080_of_fgrid\u2080]\n\nattribute [simp]\nlemma vec_grid\u2080_of_fgrid\u2080_o {\u03b1 : Type} {g : fgrid\u2080 \u03b1} :\n  (vec_grid\u2080_of_fgrid\u2080 g).o = g.o := by simp [vec_grid\u2080_of_fgrid\u2080]\n\nattribute [simp]\nlemma fgrid\u2080_of_vec_grid\u2080_r {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} :\n  (fgrid\u2080_of_vec_grid\u2080 g).r = g.r := by simp [fgrid\u2080_of_vec_grid\u2080]\n\nattribute [simp]\nlemma fgrid\u2080_of_vec_grid\u2080_c {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} :\n  (fgrid\u2080_of_vec_grid\u2080 g).c = g.c := by simp [fgrid\u2080_of_vec_grid\u2080]\n\nattribute [simp]\nlemma fgrid\u2080_of_vec_grid\u2080_o {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} :\n  (fgrid\u2080_of_vec_grid\u2080 g).o = g.o := by simp [fgrid\u2080_of_vec_grid\u2080]\n\nattribute [simp]\nlemma vec_grid\u2080_of_fgrid\u2080_gtr {\u03b1 : Type} {g : fgrid\u2080 \u03b1} :\n  gtr (vec_grid\u2080_of_fgrid\u2080 g) = gtr g :=\n    by simp [expand_gtr, bl, cols, rows, vec_grid\u2080_of_fgrid\u2080]\n\nattribute [simp]\nlemma fgrid\u2080_of_vec_grid\u2080_gtr {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} :\n  gtr (fgrid\u2080_of_vec_grid\u2080 g) = gtr g :=\n    by simp [expand_gtr, bl, cols, rows, fgrid\u2080_of_vec_grid\u2080]\n\nprivate theorem nth_le_grp {n} {a b r : \u2124} (h : a < b) (H) :\n  nth_le (grp a b r) n H = \u27e8a + n, r\u27e9 :=\nbegin\n  rw \u2190 option.some_inj, rw \u2190 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 \u2260 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\u2081,\n          replace h\u2081 := le_of_not_lt h\u2081,\n          rw le_iff_eq_or_lt at h\u2081, cases h\u2081; 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\u2081 : b - (a + 1) \u2265 0, by linarith,\n          have eq\u2082 : b - a \u2265 0, by linarith,\n          rw [\u2190 int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg eq\u2081],\n          rw [\u2190 int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg eq\u2082] 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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} : bl g \u2208 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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} : bl g \u2208 gip_g g :=\n  in_grid_iff_in_gip_g.1 bl_g_in_g\n\ntheorem nth_grp {n} {a b r : \u2124} (h : a < b) (H : n < length (grp a b r)) :\n  nth (grp a b r) n = some \u27e8a + n, r\u27e9 :=\n  by rw nth_le_nth H; exact congr_arg _ (nth_le_grp h _)\n\ntheorem nth_le_gip {n} {p\u2081 p\u2082 : point} (h : p\u2081 \u2197 p\u2082) (H) :\n  nth_le (gip p\u2081 p\u2082) n H =\n  \u27e8p\u2081.x + n % |p\u2082.x - p\u2081.x|, p\u2081.y + n / |p\u2082.x - p\u2081.x|\u27e9 :=\nbegin\n  cases p\u2081 with x\u2081 y\u2081, cases p\u2082 with x\u2082 y\u2082,\n  have x\u2081x\u2082 : x\u2081 < x\u2082, from (grid_bounded_iff.1 h).1,\n  have y\u2081y\u2082 : y\u2081 < y\u2082, from (grid_bounded_iff.1 h).2,\n  rw [\u2190 option.some_inj, \u2190 nth_le_nth H], rw length_gip h at H,\n  repeat { rw nat_abs_of_nonneg (nonneg_of_lt x\u2081x\u2082) },\n  simp [-sub_eq_add_neg] at *,\n  have : y\u2082 = y\u2081 + (y\u2082 - y\u2081), by linarith,\n  rw this, clear this,\n  have : y\u2082 - y\u2081 = \u2191|y\u2082 - y\u2081|,\n    by rw nat_abs_of_nonneg; exact nonneg_of_lt y\u2081y\u2082,\n  rw this, clear this,\n  generalize hrows : |y\u2082 - y\u2081| = rows, rw hrows at H,\n  induction rows with rows ih generalizing y\u2081 y\u2082 n,\n    {exfalso, simp at H, cases H},\n    {\n      rw expand_row_gip _,\n        {\n          by_cases h\u2081 : n < |x\u2082 - x\u2081|,\n            {\n              simp [-sub_eq_add_neg], rw [nth_split, nth_grp];\n              try {simpa [length_grp x\u2081x\u2082]},\n              congr' 2;\n              rw [\n                \u2190 int.coe_nat_lt_coe_nat_iff,\n                nat_abs_of_nonneg (nonneg_of_lt x\u2081x\u2082)\n              ] at h\u2081,\n              rw mod_eq_of_lt (coe_zero_le _) h\u2081,\n              rw div_eq_zero_of_lt (coe_zero_le _) h\u2081,\n              simp\n            },\n            {\n              generalize hcols : x\u2082 - x\u2081 = cols,\n              have rowsnezero : rows \u2260 0, assume contra,\n                by simp [contra, -sub_eq_add_neg] at H; contradiction,\n              have colsnezero : cols \u2260 0, by linarith,\n              have x\u2082x\u2081n : |x\u2082 - x\u2081| \u2264 n, from not_lt.1 h\u2081,\n              have lenok : \u00acn < length (grp x\u2081 x\u2082 y\u2081),\n                by simpa [length_grp x\u2081x\u2082, -sub_eq_add_neg],\n              simp [-sub_eq_add_neg], rw nth_split_second lenok,\n              by_cases h\u2082 : y\u2081 + 1 < y\u2082,\n                {\n                  have h\u2083 : {x := x\u2081, y := y\u2081 + 1}\u2197{x := x\u2082, y := y\u2082},\n                    from \u27e8x\u2081x\u2082, h\u2082\u27e9,\n                  have lenok :\n                    n - length (grp x\u2081 x\u2082 y\u2081) < rows * |x\u2082 - x\u2081|,\n                    {\n                      rw nat.succ_mul at H,\n                      rw [\n                        length_grp x\u2081x\u2082, \u2190 int.coe_nat_lt_coe_nat_iff,\n                        int.coe_nat_sub x\u2082x\u2081n, int.coe_nat_mul,\n                        sub_lt_iff_lt_add, \u2190 int.coe_nat_mul, \u2190 int.coe_nat_add\n                      ],\n                      rwa int.coe_nat_lt_coe_nat_iff\n                    },\n                  have rowsok : |y\u2082 - (y\u2081 + 1)| = rows,\n                    by rw [\u2190 abs_minus_plus y\u2081y\u2082, hrows, nat.succ_sub_one],\n                  rw [\n                    \u2190 add_assoc,\n                    @ih (y\u2081 + 1) y\u2082 (n - length (grp x\u2081 x\u2082 y\u2081)) h\u2083 h\u2082 rowsok lenok,\n                    length_grp x\u2081x\u2082\n                  ],\n                  simp [-sub_eq_add_neg],\n                  exact \u27e8\n                    begin\n                      rw [\n                        int.coe_nat_sub x\u2082x\u2081n, nat_abs_of_nonneg, \u2190 hcols,\n                        mod_eq_mod_iff_mod_sub_eq_zero, mod_eq_zero_of_dvd\n                      ],\n                      simp, rw \u2190 dvd_neg, simp,\n                      exact nonneg_of_lt x\u2081x\u2082\n                    end,\n                    begin\n                      rw [\n                        int.coe_nat_sub x\u2082x\u2081n,\n                        nat_abs_of_nonneg (nonneg_of_lt x\u2081x\u2082), hcols\n                      ],\n                      simp,\n                      have : -cols = cols * (-1 : \u2124), by simp, rw this,\n                      rw int.add_mul_div_left _ _ colsnezero,\n                      simp\n                    end\n                  \u27e9\n                },\n                {\n                  have h\u2083 : y\u2081 + 1 = y\u2082, by linarith,\n                  have h\u2084 : |y\u2082 - y\u2081| = 1, by simp [h\u2083.symm, add_sub_cancel'],\n                  rw h\u2084 at hrows, injection hrows with contra, cc\n                }\n            }\n      },\n      {\n        exact \u27e8\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              (\u03bb_, lt_trans zero_lt_one (lt_add_succ _ _)),\n          end\n        \u27e9\n      }\n    }\nend\n\ntheorem nth_le_gip_g {n} (H) :\n  nth_le (gip_g g) n H = \u27e8(bl g).x + n % cols g, (bl g).y + n / cols g\u27e9 :=\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\u2081 p\u2082 : point} (h : p\u2081 \u2197 p\u2082) (H : n < length (gip p\u2081 p\u2082)) :\n  nth (gip p\u2081 p\u2082) n =\n  some \u27e8p\u2081.x + n % |p\u2082.x - p\u2081.x|, p\u2081.y + n / |p\u2082.x - p\u2081.x|\u27e9 :=\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 \u27e8(bl g).x + n % cols g, (bl g).y + n / cols g\u27e9 :=\n  by simp [nth_le_nth H, nth_le_gip_g]\n\ntheorem nth_generate {n} (H) :\n  nth_le (\u2118 g) n H =\n  abs_data g \u27e8\n    \u27e8(bl g).y + n / cols g, \u27e8\n      by simp,\n      idx_div_cols_bounded (by rwa length_generate_eq_size at H)\n    \u27e9\u27e9,\n    \u27e8(bl g).x + n % cols g, \u27e8\n      by simp,\n      idx_mod_cols_bounded\u27e9\n  \u27e9\u27e9 :=\nbegin\n  rw length_generate at H,\n  rw [\u2190 option.some_inj, \u2190 nth_le_nth],\n  simp only [\n    abs_data, (\u2218), 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 \u27e8(bl g).x, (bl g).y + 1\u27e9 (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 \u2118 g) :\n  nth (\u2118 g) n =\n  some (abs_data g \u27e8\n    \u27e8(bl g).y + n / cols g, \u27e8\n      by simp,\n      idx_div_cols_bounded (by rwa length_generate_eq_size at h)\n    \u27e9\u27e9,\n    \u27e8(bl g).x + n % cols g, \u27e8\n      by simp,\n      idx_mod_cols_bounded\u27e9\n  \u27e9\u27e9) := by simp [nth_le_nth h, congr_arg, nth_generate]\n\nlemma abs_data_eq_nth_v\u2080 {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} {p} :\n  abs_data g p = vector.nth g.data (grid_point_to_fin p) :=\n  by simpa [\n       abs_data, (\u2218), 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\u2080' {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} {p} :\n  abs_data g p =\n  vector.nth g.data \u27e8|p.y.1 - g.o.y| * g.c + |p.x.1 - g.o.x|,\n  begin\n    rcases p with \u27e8\u27e8x, \u27e8xl, xu\u27e9\u27e9, \u27e8y, \u27e8yl, yu\u27e9\u27e9\u27e9,\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\u2081 : |y - g.o.x| < g.c,\n      {\n        have : y - (g.o).x \u2265 0, by linarith,\n        rw [\u2190 int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg this],\n        linarith\n      },\n    have eq\u2082 : |x - g.o.y| < g.r,\n      {\n        have : x - g.o.y \u2265 0, by linarith,\n        rw [\u2190 int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg this],\n        linarith\n      },\n    exact linearize_array eq\u2081 eq\u2082\n  end\u27e9 :=\n  by simp [\n       abs_data, (\u2218), 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\u2080 {\u03b1 : Type} {g : fgrid\u2080 \u03b1} {p} :\n  abs_data g p = g.data p.y p.x :=\nbegin\n  rcases p with \u27e8\u27e8x, \u27e8xl, xu\u27e9\u27e9, \u27e8y, \u27e8yl, yu\u27e9\u27e9\u27e9,\n  simp only [\n    abs_data, (\u2218), relpoint_of_gpoint, prod_of_rel_point, data\n  ],\n  unfold_coes, simp only [fin.val, of_nat_eq_coe],\n  have h\u2081 : x - (bl g).y \u2265 0, by linarith,\n  have h\u2082 : y - (bl g).x \u2265 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\u2080 {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} {n} (H) :\n  some (nth_le (\u2118 g) n H) =\n  nth g.data.to_list ( |\u2191n % \u2191g.c| + |\u2191n / \u2191g.c| * g.c ) :=\nbegin\n  rcases g with \u27e8\u27e8r, c, h, \u27e8d, hd\u27e9\u27e9, o\u27e9,\n  rw [nth_le_nth, nth_generate],\n  simp [abs_data_eq_nth_v\u2080', 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\u2080 {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} {n} (H : n < length \u2118 g):\n  nth (\u2118 g) n =\n  nth g.data.to_list ( |\u2191n % \u2191g.c| + |\u2191n / \u2191g.c| * g.c) :=\n  by simp [nth_le_nth, some_nth_le_generate_v\u2080, H]\n\nprivate lemma goy_add_n_div_c_lt_goy_add_r {\u03b1 : Type} {g : fgrid\u2080 \u03b1} {n : \u2115}\n  (h : n < length \u2118 g) : g.o.y + \u2191n / \u2191g.c < g.o.y + \u2191g.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\u2080 {\u03b1 : Type} {g : fgrid\u2080 \u03b1} {n} (H) :\n  some (nth_le (\u2118 g) n H) =\n  g.data\n    \u27e8g.o.y + \u2191n / \u2191g.c, \u27e8by simp, goy_add_n_div_c_lt_goy_add_r H\u27e9\u27e9\n    \u27e8g.o.x + \u2191n % \u2191g.c, \u27e8by simp, by simp; exact mod_lt_of_pos _ coe_cols_pos_f\u27e9\u27e9\n  := by simpa [nth_generate, abs_data_eq_nth_f\u2080, expand_gtr]\n\nlemma nth_generate_f\u2080 {\u03b1 : Type} {g : fgrid\u2080 \u03b1} {n} (H : n < length \u2118 g) :\n  nth (\u2118 g) n =\n  g.data\n    \u27e8g.o.y + \u2191n / \u2191g.c, \u27e8by simp, goy_add_n_div_c_lt_goy_add_r H\u27e9\u27e9\n    \u27e8g.o.x + \u2191n % \u2191g.c, \u27e8by simp, by simp; exact mod_lt_of_pos _ coe_cols_pos_f\u27e9\u27e9\n  := by simp [nth_le_nth H, some_nth_le_generate_f\u2080]\n\nlemma nth_le_generate_f\u2080 {\u03b1 : Type} {g : fgrid\u2080 \u03b1} {n} (H) :\n  nth_le (\u2118 g) n H =\n  g.data\n    \u27e8g.o.y + \u2191n / \u2191g.c, \u27e8by simp, goy_add_n_div_c_lt_goy_add_r H\u27e9\u27e9\n    \u27e8g.o.x + \u2191n % \u2191g.c, \u27e8by simp, by simp; exact mod_lt_of_pos _ coe_cols_pos_f\u27e9\u27e9\n  := by simpa [nth_generate, abs_data_eq_nth_f\u2080, expand_gtr]\n\nlemma generate_eq_data {\u03b1 : Type} (g : vec_grid\u2080 \u03b1) :\n  \u2118 g = g.data.to_list :=\nbegin\n  have h\u2081 : length (\u2118 g) = rows g * cols g,\n    from length_generate _,\n  have h\u2082 : length (g.data.to_list) = rows g * cols g,\n    by simp [rows, cols],\n  apply ext_le (eq.trans h\u2081 h\u2082.symm) (\u03bbi hi\u2081 hi\u2082, _),\n  rw h\u2081 at hi\u2081, rw h\u2082 at hi\u2082,\n  have : hi\u2081 = hi\u2082, from rfl, subst this, dedup,\n  rw \u2190 option.some_inj, repeat { rw \u2190 nth_le_nth },\n  rename hi\u2081_1 hi,\n  rcases g with \u27e8\u27e8r, c, h, \u27e8data, hd\u27e9\u27e9, o\u27e9,\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\u2080],\n  rw nth_le_nth hi\u2082, simp,\n  have : |\u2191i % \u2191c| + |\u2191i / \u2191c| * c = i, from mod_add_div_coe,\n  repeat { rw \u2190 nth_le_nth }, simp [this]\nend\n\nprivate theorem generate_inj_v\u2080_v\u2080 {\u03b1 : Type} {g\u2081 g\u2082 : vec_grid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o)\n  (h : \u2118 g\u2081 = \u2118 g\u2082) : g\u2081 = g\u2082 :=\nbegin\n  repeat { rw generate_eq_data at h },\n  rcases g\u2081 with \u27e8\u27e8g\u2081r, g\u2081c, g\u2081h, g\u2081d\u27e9, g\u2081o\u27e9,\n  rcases g\u2082 with \u27e8\u27e8g\u2082r, g\u2082c, g\u2082h, g\u2082d\u27e9, g\u2082o\u27e9,\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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {i} {hi} :\n  (nth_le (attach (gip_g g)) i hi).val \u2208 gip_g g :=\nbegin\n  rw [nth_le_attach, \u2190 in_grid_iff_in_gip_g, nth_le_gip_g],\n  simp only [(\u2208), flip, is_in_grid', is_bounded],\n  split; split,\n    {\n      have : \u2191i / \u2191(cols g) \u2265 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 : \u2191i % \u2191(cols g) \u2265 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\u2080_v\u2080 {\u03b1 : Type} {g\u2081 g\u2082 : vec_grid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o) : g\u2081 = g\u2082 \u2194 \u2118 g\u2081 = \u2118 g\u2082 :=\n  \u27e8\u03bbh, h \u25b8 rfl, generate_inj_v\u2080_v\u2080 hrows hcols horig\u27e9\n\nlemma i_bounded {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {p} (h : p \u2208 g) :\n  is_bounded 0 (size g) ( |p.y - (bl g).y| * cols g + |p.x - (bl g).x| ) :=\nbegin\n  have h\u2081 : |p.x - (bl g).x| \u2265 0, by simp,\n  have h\u2082 : |p.y - (bl g).y| \u2265 0, by simp,\n  unfold is_bounded, split,\n    {linarith},\n    {\n      simp [(\u2208), flip, is_in_grid'] at h,\n      rcases h with \u27e8\u27e8h\u2083, h\u2084\u27e9, \u27e8h\u2085, h\u2086\u27e9\u27e9,\n      have eq\u2081 : |p.x - (bl g).x| < cols g,\n        {\n          rw \u2190 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\u2082 : |p.y - (bl g).y| < rows g,\n        {\n          rw \u2190 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\u2081 eq\u2082\n    }\nend\n\nprivate theorem generate_inj_f\u2080_f\u2080 {\u03b1 : Type} {g\u2081 g\u2082 : fgrid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o)\n  (h : \u2118 g\u2081 = \u2118 g\u2082) : g\u2081 = g\u2082 :=\nbegin\n  have hl\u2081 : length (\u2118 g\u2081) = g\u2081.r * g\u2081.c,\n    from length_generate _,\n  have hl\u2082 : length (\u2118 g\u2082) = g\u2082.r * g\u2082.c,\n    from length_generate _,\n  cases g\u2081 with g\u2081r g\u2081c g\u2081h g\u2081o g\u2081d,\n  cases g\u2082 with g\u2082r g\u2082c g\u2082h g\u2082o g\u2082d,\n  dsimp at hrows hcols horig hl\u2081 hl\u2082,\n  subst hrows, subst hcols, subst horig,\n  congr, ext x y,\n  rcases x with \u27e8x, \u27e8xl, xu\u27e9\u27e9, rcases y with \u27e8y, \u27e8yl, yu\u27e9\u27e9,\n  have rowsnezero : g\u2081r \u2260 0, assume contra,\n    by simp [contra] at g\u2081h; exact absurd g\u2081h (lt_irrefl _),\n  have colsnezero : g\u2081c \u2260 0, assume contra,\n    by simp [contra] at g\u2082h; exact absurd g\u2082h (lt_irrefl _),\n  let i := |x - g\u2081o.y| * g\u2081c + |y - g\u2081o.x|,\n  have hi : i = |x - g\u2081o.y| * g\u2081c + |y - g\u2081o.x|, refl,\n  have r_nonneg : x - g\u2081o.y \u2265 0,\n    by simp only [ge_from_le, le_sub_iff_add_le, zero_add]; exact xl,\n  have c_nonneg : y - g\u2081o.x \u2265 0,\n    by simp only [ge_from_le, le_sub_iff_add_le, zero_add]; exact yl,\n  have i_nonneg : 0 \u2264 i, by linarith,\n  have i_bounded : i < g\u2081r * g\u2081c,\n    {\n      have yb : y - g\u2081o.x < \u2191g\u2081c, from sub_lt_iff_lt_add'.2 yu,\n      have xb : x - g\u2081o.y < \u2191g\u2081r, from sub_lt_iff_lt_add'.2 xu,\n      rw hi,\n      apply linearize_array;\n        try { rw \u2190 int.coe_nat_lt_coe_nat_iff };\n        rw nat_abs_of_nonneg; try { assumption }\n    },\n  have h\u2081 : \u2200hh,\n    list.nth_le (\u2118 (\n      {r := g\u2081r, c := g\u2081c, h := g\u2081h, o := g\u2081o, data := g\u2081d} : fgrid\u2080 \u03b1\n    )) i hh =\n    list.nth_le (\u2118 (\n      {r := g\u2081r, c := g\u2081c, h := g\u2082h, o := g\u2081o, data := g\u2082d} : fgrid\u2080 \u03b1\n    )) i (hl\u2082.symm \u25b8 i_bounded), { rw h, intro, refl },\n  specialize h\u2081 (hl\u2081.symm \u25b8 i_bounded),\n  simp [-sub_eq_add_neg, nth_le_generate_f\u2080] at h\u2081,\n  have : g\u2081o.y + (\u2191|y - g\u2081o.x| + \u2191|x - g\u2081o.y| * \u2191g\u2081c) / \u2191g\u2081c = x,\n    {\n      repeat { rw nat_abs_of_nonneg; try { assumption } },\n      rw @int.add_mul_div_right _ _ \u2191g\u2081c (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\u2081,\n  have : g\u2081o.x + \u2191|y - g\u2081o.x| % \u2191g\u2081c = 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\u2081,\n  exact h\u2081\nend\n\ntheorem grid_eq_iff_f\u2080_f\u2080 {\u03b1 : Type} {g\u2081 g\u2082 : fgrid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o) : g\u2081 = g\u2082 \u2194 \u2118 g\u2081 = \u2118 g\u2082 :=\n  \u27e8\u03bbh, h \u25b8 rfl, generate_inj_f\u2080_f\u2080 hrows hcols horig\u27e9\n\ndef row (n : fin (rows g)) :\n  (fin (cols g)) \u2192 carrier \u03b1 :=\n  data g n\n\ndef col (n : fin (cols g)) :\n  (fin (rows g)) \u2192 carrier \u03b1 :=\n  flip (data g) n\n\ndef top :=\n  row g \u27e8\n    0,\n    and.elim_left (gt_and_gt_of_mul_gt (nonempty g))\n  \u27e9\n\ndef bot :=\n  row g \u27e8nat.pred (rows g),\n         nat.pred_lt (ne_of_gt (gt_and_gt_of_mul_gt (nonempty g)).1)\n        \u27e9\n\ndef left :=\n  have h : cols g > 0,\n    from (gt_and_gt_of_mul_gt (nonempty g)).2,\n  col g \u27e80, h\u27e9\n\ndef right :=\n  have h : cols g > 0,\n    from (gt_and_gt_of_mul_gt (nonempty g)).2,\n  col g \u27e8nat.pred (cols g), nat.pred_lt (ne_of_gt h)\u27e9\n\ndef overlaid_by (bb\u2081 bb\u2082 : bounding_box) :=\n  (bb\u2082.p\u2081.x \u2264 bb\u2081.p\u2081.x \u2227 bb\u2081.p\u2082.x \u2264 bb\u2082.p\u2082.x) \u2227\n  (bb\u2081.p\u2082.y \u2264 bb\u2082.p\u2082.y \u2227 bb\u2082.p\u2081.y \u2264 bb\u2081.p\u2081.y)\n\ndef in_grid_bounded (p : point)\n  (h : is_in_grid' g p) :=\n  let \u27e8left, right\u27e9 :=\n    h in (make_bounded left, make_bounded right)\n\ninstance overlaid_decidable (p\u2081 p\u2082 : bounding_box) :\n  decidable (overlaid_by p\u2081 p\u2082) := 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\u2081 bb\u2082 bb\u2083 : bounding_box}\n  (h : overlaid_by bb\u2081 bb\u2082) (h\u2081 : overlaid_by bb\u2082 bb\u2083) : overlaid_by bb\u2081 bb\u2083 :=\n  by simp [overlaid_by] at *; repeat {split}; transitivity; finish\n\nlemma overlaid_by_antisymm {bb\u2081 bb\u2082 : bounding_box}\n  (h : overlaid_by bb\u2081 bb\u2082) (h\u2081 : overlaid_by bb\u2082 bb\u2081) : bb\u2081 = bb\u2082 :=\nbegin\n  simp [overlaid_by] at *,\n  rcases bb\u2081 with \u27e8\u27e8_, _\u27e9, \u27e8_, _\u27e9\u27e9, rcases bb\u2082 with \u27e8\u27e8_, _\u27e9, \u27e8_, _\u27e9\u27e9,\n  safe\nend\n\nlemma overlaid_by_size_le {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb : bounding_box}\n  (h : overlaid_by bb (grid_bounds g)) :\n  bb_size bb \u2264 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 \u27e8\u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2083, h\u2084\u27e9\u27e9,\n  rw \u2190 int.coe_nat_le_coe_nat_iff,\n  repeat { rw int.coe_nat_mul },\n  cases bb with p\u2081 p\u2082 hbb, simp [-sub_eq_add_neg] at *,\n  rw grid_bounded_iff at hbb, cases hbb with h\u2085 h\u2086,\n  repeat { rw nat_abs_of_nonneg; try { linarith } },\n  apply mul_le_mul; linarith\nend\n\nlemma is_in_larger {bb\u2081 bb\u2082 : bounding_box} {xy : point}\n  (h : xy \u2208 bb\u2081) (h\u2081 : overlaid_by bb\u2081 bb\u2082) : xy \u2208 bb\u2082 :=\n  \u27e8\u27e8le_trans h\u2081.2.2 h.1.1, lt_of_lt_of_le h.1.2 h\u2081.2.1\u27e9,\n   \u27e8le_trans h\u2081.1.1 h.2.1, lt_of_lt_of_le h.2.2 h\u2081.1.2\u27e9\u27e9\n\nprivate def bounded_prod_of_point {p : point} {g : \u03b1} (h : p \u2208 g) :\n  bounded (bl g).x (gtr g).x \u00d7\n  bounded (bl g).y (gtr g).y := \u27e8make_bounded h.2, make_bounded h.1\u27e9\n\nopen bounding_box\n\ndef subgrid (bb : bounding_box) (h : overlaid_by bb (grid_bounds g)) :\n            fgrid\u2080 (carrier \u03b1) :=\n  \u27e8rows_of_box bb, cols_of_box bb,\n   mul_pos rows_of_box_pos cols_of_box_pos, bb.p\u2081,\n   \u03bbx y, abs_data g \u27e8\u27e8x.1,\n    begin\n      unfold overlaid_by at h, cases x with x hx, simp,\n      rw grid_bounds_p\u2081 at h, rw grid_bounds_p\u2082 at h,\n      exact \u27e8\n        le_trans h.2.2 hx.1,\n        begin\n          have : bb.p\u2081.y + \u2191(rows_of_box bb) = bb.p\u2082.y,\n            begin\n              have : (bb.p\u2082).y - (bb.p\u2081).y \u2265 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      \u27e9\n    end\u27e9, \u27e8y.1,\n    begin\n      unfold overlaid_by at h, cases y with y hy, simp,\n      rw grid_bounds_p\u2081 at h, rw grid_bounds_p\u2082 at h,\n      have : (bb.p\u2081).x + \u2191(cols_of_box bb) = bb.p\u2082.x,\n        by simp [\n             -sub_eq_add_neg, bounding_box.p\u2081, bounding_box.p\u2082, 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 \u27e8le_trans h.1.1 hy.1, lt_of_lt_of_le hy.2 h.1.2\u27e9\n    end\u27e9\u27e9\u27e9\n\ntheorem length_subgrid {bb} {H} : length \u2118(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  \u2118 (subgrid g (grid_bounds g) (overlaid_by_refl _)) = @generate _ _ g :=\nbegin\n  have lenok : length \u2118(subgrid g (grid_bounds g) (overlaid_by_refl _)) = length \u2118 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\u2081 : rows_of_box (grid_bounds g) = rows g,\n    by simp [grid_bounds, rows_of_box, rows_eq_try_sub_bly],\n  have eq\u2082 : cols_of_box (grid_bounds g) = cols g,\n    by simp [grid_bounds, cols_of_box, cols_eq_trx_sub_blx],\n  have eq\u2083 : (grid_bounds g).p\u2081 = 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\u2080, bl, eq\u2083, cols, eq\u2081, eq\u2082]\nend\n\nlemma overlaid_by_subgrid_grid {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {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 \u27e8p\u2081, p\u2082, hbb\u27e9,\n  rw grid_bounded_iff at hbb,\n  cases hbb with hbb\u2081 hbb\u2082,\n  rcases H with \u27e8\u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2083, h\u2084\u27e9\u27e9,\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\u2082.x - p\u2081.x \u2265 0, by linarith,\n      rw nat_abs_of_nonneg this,\n      linarith\n    },\n    {\n      have : p\u2082.y - p\u2081.y \u2265 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\u2081 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb} {H} :\n  bl (subgrid g bb H) = bb.p\u2081 := by simp [subgrid, bl]\n\nlemma tr_subgrid_g_bb_eq_bb_p\u2082 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb} {H} :\n  gtr (subgrid g bb H) = bb.p\u2082 :=\nbegin\n  simp [expand_gtr, subgrid, bl, rows, cols],\n  have eq\u2081 : cols_of_box bb > 0, from cols_of_box_pos,\n  have eq\u2082 : rows_of_box bb > 0, from rows_of_box_pos,\n  rcases bb with \u27e8\u27e8p\u2081x, p\u2081y\u27e9, \u27e8p\u2082x, p\u2082y\u27e9, h\u27e9, 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\u2081,\n  simp [-sub_eq_add_neg, rows_of_box] at eq\u2082,\n  simp at h, cases h with hl hr,\n  rw \u2190 int.coe_nat_lt_coe_nat_iff at eq\u2081 eq\u2082,\n  rw nat_abs_of_nonneg at eq\u2081 eq\u2082,\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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb} {H} :\n  grid_bounds (subgrid g bb H) = bb :=\n  by simp [grid_bounds, bl_subgrid_g_bb_eq_bb_p\u2081, tr_subgrid_g_bb_eq_bb_p\u2082];\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\u2082, bl_subgrid_g_bb_eq_bb_p\u2081\n     ]\n\nlemma overlaid_by_subgrid_bb {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb} {H} {p} :\n  p \u2208 grid_bounds (subgrid g bb H) \u2194 p \u2208 bb :=\nbegin\n  split; intros h,\n    {\n      simp [grid_bounds, flip, is_in_grid] at h,\n      simp [(\u2208), flip, is_in_grid],\n      rw [bl_subgrid_g_bb_eq_bb_p\u2081, tr_subgrid_g_bb_eq_bb_p\u2082] at h,\n      exact h\n    },\n    {\n      simp [grid_bounds, flip, is_in_grid],\n      simp [(\u2208), flip, is_in_grid] at h,\n      rw [bl_subgrid_g_bb_eq_bb_p\u2081, tr_subgrid_g_bb_eq_bb_p\u2082],\n      exact h\n    }\nend\n\ndef inject_filter_bounded {bb : bounding_box}\n  (e : {x // x \u2208 filter (\u03bb (p : point), p \u2209 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 \u03b1) :=\n  map (abs_data g \u2218 inject_filter_bounded _)\n      (attach $ filter (\u03bbp, p \u2209 bb) (gip_g g))\n\nlemma countp_grp_x {p\u2081x p\u2082x a b row} :\n  countp (\u03bb (p : point), p.x < p\u2081x \u2228 p\u2082x \u2264 p.x) (grp a b row) =\n  countp (\u03bb x, x < p\u2081x \u2228 p\u2082x \u2264 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\u2081 eq\u2082, subst eq\u2081,\n      specialize @ih (a + 1) eq\u2082,\n      rw expand_grp this, simp [countp],\n      by_cases eq\u2081 : a < p\u2081x \u2228 p\u2082x \u2264 a; simp [eq\u2081, ih]\n    }\nend\n\nlemma countp_grp_single_row_l {\u03b1 : Type} {l : list \u03b1}\n  {P\u2081 P\u2082 : \u03b1 \u2192 Prop} [decidable_pred P\u2081] [decidable_pred P\u2082]\n  (h : \u2200x \u2208 l, \u00acP\u2082 x) :\n  countp P\u2081 l = countp (\u03bb x, P\u2081 x \u2228 P\u2082 x) l :=\nbegin\n  induction l with hd tl ih,\n    {simp},\n    {\n      simp [countp],\n      by_cases eq : (P\u2081 hd); simp [eq],\n        {exact ih (\u03bb_ h\u2080, h _ (mem_cons_of_mem _ h\u2080))},\n        {\n          rw if_neg (h _ _),\n          exact ih (\u03bb_ h\u2080, h _ (mem_cons_of_mem _ h\u2080)),\n          exact mem_cons_self _ _\n        }\n    }\nend\n\nlemma countp_grp_single_row_r {\u03b1 : Type} {l : list \u03b1}\n  {P\u2081 P\u2082 : \u03b1 \u2192 Prop} [decidable_pred P\u2081] [decidable_pred P\u2082]\n  (h : \u2200x \u2208 l, \u00acP\u2082 x) :\n  countp P\u2081 l = countp (\u03bb x, P\u2082 x \u2228 P\u2081 x) l :=\nbegin\n  induction l with hd tl ih,\n    {simp},\n    {\n      simp [countp],\n      by_cases eq : (P\u2081 hd); simp [eq],\n        {exact ih (\u03bb_ h\u2080, h _ (mem_cons_of_mem _ h\u2080))},\n        {\n          rw if_neg (h _ _),\n          exact ih (\u03bb_ h\u2080, h _ (mem_cons_of_mem _ h\u2080)),\n          exact mem_cons_self _ _\n        }\n    }\nend\n\nlemma countp_grp_row {p\u2081x p\u2081y p\u2082x p\u2082y : \u2124} {blx bly trx : \u2124} \n(h\u2080 : p\u2081y < p\u2082y) (hl : bly \u2264 p\u2081y) :\ncountp (\u03bb (p : point), (p.y < p\u2081y \u2228 p\u2082y \u2264 p.y) \u2228 p.x < p\u2081x \u2228 p\u2082x \u2264 p.x) (grp blx trx bly) =\nite (p\u2081y = bly) (countp (\u03bb (p : point), p.x < p\u2081x \u2228 p\u2082x \u2264 p.x) (grp blx trx bly))\n                (length (grp blx trx bly)) :=\nbegin\n  by_cases h\u2081 : p\u2081y = bly,\n    {\n      have : \u2200p : point, p \u2208 grp blx trx bly \u2192 p.y = bly, from \u03bbp, in_grp_second,\n      rw if_pos h\u2081,\n      rw \u2190 countp_grp_single_row_r,\n      intros p h\u2082, rw not_or_distrib, subst h\u2081,\n      by_cases h : blx < trx,\n        {\n          rw expand_grp h at this,\n          have eq : p.y = p\u2081y, from in_grp_second h\u2082, subst eq,\n          split; linarith\n        },\n        {\n          rw not_lt at h, rw grp_empty_iff'.2 h at h\u2082, cases h\u2082\n        }\n    },\n    {\n      rw if_neg h\u2081,\n      have eq : \u2200p : point, p \u2208 grp blx trx bly \u2192 p.y = bly,\n        from \u03bbp, in_grp_second,\n      have eq\u2081 : bly < p\u2081y,\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\u2082 : 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\u2082 at iheq, injection iheq with i\u2081 i\u2082,\n          simp [countp], subst i\u2081, simp only [point.x, point.y] at *,\n          by_cases h\u2083 : (bly < p\u2081y \u2228 p\u2082y \u2264 bly) \u2228 blx < p\u2081x \u2228 p\u2082x \u2264 blx; simp [h\u2083],\n            {\n              simp [nat.succ_eq_add_one],\n              rw expand_grp eq\u2082 at eq,\n              rw @ih (blx + 1) (\u03bb_ hk, eq _ (mem_cons_of_mem _ hk)) i\u2082\n            },\n            {\n              repeat { rw not_or_distrib at h\u2083 },\n              rcases h\u2083 with \u27e8\u27e8a\u2081, a\u2082\u27e9, a\u2083, a\u2084\u27e9,\n              linarith\n            }\n        }\n    }\nend\n\nlemma in_join_grp_range_iff {blx trx bly try} {p : point}\n  (h\u2080 : blx < trx) :\n  p \u2208 join (map (grp blx trx) (range_pure bly try)) \u2194\n  is_bounded blx trx p.x \u2227 is_bounded bly try p.y :=\nbegin\n  split; intros h,\n    {\n      simp at h, rcases h with \u27e8l, \u27e8\u27e8a, \u27e8h\u2081, h\u2082\u27e9\u27e9, h\u2083\u27e9\u27e9,\n      rw in_range_pure_iff at h\u2081, rw [\u2190 h\u2082, in_grp_iff h\u2080] at h\u2083,\n      cases h\u2083 with h\u2083 h\u2084, rw \u2190 h\u2084 at h\u2081,\n      exact \u27e8h\u2083, h\u2081\u27e9\n    },\n    {\n      cases h with h h\u2081, simp,\n      use (grp blx trx p.y), use p.y,\n      split, {exact in_range_pure_iff.2 h\u2081}, {refl},\n      rw in_grp_iff h\u2080,\n      split, {exact h}, {refl}\n    }\nend\n\nprivate lemma filter_any_ {l\u2081 l\u2082 : list \u2124} {p\u2081x p\u2082x} (h : length l\u2081 = length l\u2082) :\n  length (filter (\u03bb (x : point), x.x < p\u2081x \u2228 p\u2082x \u2264 x.x)\n                 (map (uncurry point.mk) (zip l\u2081 l\u2082))) =\n  length (filter (\u03bb (x : \u2124), x < p\u2081x \u2228 p\u2082x \u2264 x) l\u2081) :=\nbegin\n  induction l\u2081 with hd tl ih generalizing l\u2082,\n    {simp},\n    {\n      cases l\u2082 with hd\u2082 tl\u2082,\n        {simp at h, contradiction},\n        {\n          simp [uncurry] at *, \n          by_cases eq : hd < p\u2081x \u2228 p\u2082x \u2264 hd; simp [eq]; exact ih h\n        }\n    }\nend\n\nlemma countp_grp {p\u2081x p\u2082x a b r : \u2124}\n  (h : p\u2081x < p\u2082x) (h\u2081 : a \u2264 p\u2081x) (h\u2082 : p\u2082x \u2264 b):\n  countp (\u03bb (x : point), x.x < p\u2081x \u2228 p\u2082x \u2264 x.x) (grp a b r) =\n  nat_abs (p\u2081x - a) + nat_abs (b - p\u2082x) :=\nbegin\n  unfold grp, rw countp_eq_length_filter, rw filter_any_,\n  rw \u2190 countp_eq_length_filter, rw countp_range_pure h h\u2081 h\u2082,\n  rw range_length_pure, rw length_repeat, linarith\nend\n\nlemma map_length_grp_range {a b c d : \u2124} (h : c \u2264 d) (h\u2081 : 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\u2081,\n          simp only [map, join, length_append], rw length_grp h\u2081,\n          by_cases eq\u2082 : c + 1 < d,\n            {\n              rw @ih (c + 1) eq\u2081 eq\u2082, rw \u2190 abs_minus_plus h,\n              rw \u2190 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 \u2190 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\u2082,\n              have : c + 1 = d, by linarith, subst this,\n              rw range_pure_same_empty at eq\u2081, subst eq\u2081,\n              simp\n            }\n        }\n    }\nend\n\nlemma count_outside_join_map {a b c d p\u2081x p\u2082x}\n  (h : c < d) (h\u2081 : p\u2081x < p\u2082x) (h\u2082 : a \u2264 p\u2081x) (h\u2083 : p\u2082x \u2264 b) :\n  countp (\u03bb (p : point), p.x < p\u2081x \u2228 p\u2082x \u2264 p.x) (join (map (grp a b) (range_pure c d))) =\n  |p\u2081x - a| * |d - c| + |b - p\u2082x| * |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\u2081 : c + 1 < d,\n        {\n          rw range_pure_next h at eq, injection eq with eq eq\u2082,\n          simp [-sub_eq_add_neg], rw countp_grp; try { linarith },\n          rw @ih (c + 1) eq\u2081 eq\u2082, repeat { rw \u2190 abs_minus_plus h },\n          rw \u2190 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 \u2190 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\u2081, rw range_pure_next h at eq,\n          have : d = c + 1, by linarith, subst this,\n          injection eq with eq eq\u2082, rw range_pure_same_empty at eq\u2082,\n          subst eq\u2082, 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\u2081x p\u2081y p\u2082x p\u2082y}\n  (h\u2080 : p\u2081x < p\u2082x) (h\u2081 : p\u2081y < p\u2082y) (h\u2082 : blx \u2264 p\u2081x) (h\u2083 : p\u2082x \u2264 trx)\n  (h\u2084 : bly \u2264 p\u2081y) (h\u2085 : p\u2082y \u2264 try) :\n  |p\u2082y - p\u2081y| * |p\u2082x - p\u2081x| \u2264 |try - bly| * |trx - blx| :=\nbegin\n  rw \u2190 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\u2081x p\u2081y p\u2082x p\u2082y : \u2124} {blx bly : \u2124} {c r : \u2115}\n  (cpos : c > 0) (rpos : r > 0)\n  (h\u2083 : blx \u2264 p\u2081x) (h\u2084 : p\u2082x \u2264 blx + c) (h\u2085 : bly \u2264 p\u2081y) (h\u2086 : p\u2082y \u2264 bly + r)\n  (h\u2087 : p\u2081x < p\u2082x) (h\u2088 : p\u2081y < p\u2082y)\n  :\n  countp (\u03bb (p : point), ((p.y < p\u2081y \u2228 p\u2082y \u2264 p.y) \u2228 p.x < p\u2081x \u2228 p\u2082x \u2264 p.x))\n      (join (map (grp blx (blx + \u2191c)) (range_pure (bly) (bly + \u2191r)))) =\n    r * c - |p\u2082y - p\u2081y| * |p\u2082x - p\u2081x| :=\nbegin\n  generalize eq\u2081 : blx + \u2191c = trx,\n  generalize eq\u2082 : bly + \u2191r = try,\n  have eq\u2083 : \u2191c = trx - blx, by linarith,\n  have eq\u2084 : \u2191r = try - bly, by linarith,\n  rw \u2190 @nat_abs_of_nonneg (trx - blx) at eq\u2083; try { linarith },\n  rw \u2190 @nat_abs_of_nonneg (try - bly) at eq\u2084; try { linarith },\n  simp [-sub_eq_add_neg] at eq\u2083 eq\u2084,\n  rw [eq\u2083, eq\u2084],\n  generalize eq : range_pure bly try = l,\n  have : \u2203l\u2081 l\u2082, l = l\u2081 ++ l\u2082 \u2227\n                     l\u2081 = range_pure bly p\u2081y \u2227\n                     l\u2082 = range_pure p\u2081y try,\n    from @range_pure_app bly try _ (by linarith) eq.symm _ h\u2085 (by linarith),\n  rcases this with \u27e8l\u2081, \u27e8l\u2082, eq\u2082, eq\u2083, eq\u2084\u27e9\u27e9,\n  have : \u2203 (l\u2083 l\u2084 : list \u2124),\n            l\u2082 = l\u2083 ++ l\u2084 \u2227 l\u2083 = range_pure p\u2081y p\u2082y \u2227 l\u2084 = range_pure p\u2082y try,\n    from @range_pure_app p\u2081y try _ (by linarith) eq\u2084 _ (int.le_of_lt h\u2088) (by linarith),\n  rcases this with \u27e8l\u2083, \u27e8l\u2084, eq\u2085, eq\u2086, eq\u2087\u27e9\u27e9,\n  have eq\u2088 : l = l\u2081 ++ l\u2083 ++ l\u2084, by rw [eq\u2082, eq\u2085, append_assoc], rw eq\u2088,\n  simp [-sub_eq_add_neg], rw [eq\u2083, eq\u2086, eq\u2087],\n  rw countp_eq_length_filter,\n  rw @filter_congr _ _ (\u03bb_, true),\n  swap 2,\n    {\n      intros, split; intros h\u2083,\n        {trivial},\n        {\n          rw in_join_grp_range_iff at H,\n          unfold is_bounded at H,\n          rcases H with \u27e8_, \u27e8_, c\u27e9\u27e9,\n          left, left, exact c, linarith\n        }\n    }, rw filter_true,\n  rw countp_eq_length_filter,\n  rw @filter_congr _ _ (\u03bbp : point, p.x < p\u2081x \u2228 p\u2082x \u2264 p.x),\n  swap 2,\n    {\n      intros, split; intros h\u2083,\n      {\n        rw in_join_grp_range_iff at H,\n        unfold is_bounded at H,\n        rcases H with \u27e8\u27e8c\u2081, c\u2082\u27e9, \u27e8c\u2083, c\u2084\u27e9\u27e9,\n        cases h\u2083 with h\u2083 h\u2083; cases h\u2083 with h\u2083 h\u2083,\n          {linarith},\n          {linarith},\n          {left, exact h\u2083},\n          {right, exact h\u2083},\n          {linarith}\n      },\n      {right, exact h\u2083}\n    },\n  rw \u2190 countp_eq_length_filter,\n  generalize c\u2081 :\n    countp (\u03bb (p : point), p.x < p\u2081x \u2228 p\u2082x \u2264 p.x)\n             (join (map (grp blx trx) (range_pure p\u2081y p\u2082y))) =\n    n\u2081,\n  rw countp_eq_length_filter,\n   rw @filter_congr _ _ (\u03bb_, true),\n  swap 2,\n    {\n      intros, split; intros h\u2083,\n        {trivial},\n        {\n          rw in_join_grp_range_iff at H,\n          unfold is_bounded at H,\n          rcases H with \u27e8_, \u27e8c, _\u27e9\u27e9,\n          left, right, exact c, linarith\n        }\n    }, rw filter_true, repeat { rw map_length_grp_range }; try { linarith },\n  rw \u2190 c\u2081, rw count_outside_join_map; try { linarith },\n  rw \u2190 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 {\u03b1 : Type*} [\u03c6 : grid \u03b1] {g : \u03b1} {bb} {H} :\n  countp (\u03bb (p : point), \u00acis_in_grid bb p) (gip_g g) =\n  size g - size (subgrid g bb H) :=\nbegin\n  rcases bb with \u27e8\u27e8p\u2081x, p\u2081y\u27e9, \u27e8p\u2082x, p\u2082y\u27e9, p\u2083\u27e9,\n  simp [grid_bounded_iff] at p\u2083,\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 \u2190 @count_notin_ p\u2081x p\u2081y p\u2082x p\u2082y (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\u2083.1 p\u2083.2,\n  finish\nend\n\nlemma length_subgrid' {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {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 \u2190 countp_eq_length_filter,\n  exact count_notin\nend\n\n-- lemma gip_g_subgrid'_eq_gip_g {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb} {H} :\n--   gip_g (subgrid' g bb H) = gip_g g := by unfold gip_g; congr\n\n-- lemma grid_bounds_subgrid'_grid {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {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' {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {p} :\n  p \u2208 g \u2194 p \u2208 grid_bounds g :=\nbegin\n  split; intros h,\n    {\n      simp [grid_bounds, flip, is_in_grid],\n      simp [(\u2208), flip, is_in_grid'] at h,\n      exact h\n    },\n    {\n      simp [(\u2208), 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 \u2208 gip_g (subgrid g bb H)) :\n  p \u2208 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 [\u2190 in_grid_iff_in_gip_g, \u2190 in_grid_iff_in_grid_bounds] at h,\n  exact is_in_larger h overlaid\nend\n\nprivate def modify_vec\n  {\u03b1 : Type} {m} (v : vector \u03b1 m) (n : \u2115) (x : \u03b1) : vector \u03b1 m :=\n  \u27e8update_nth v.to_list n x,\n   by simp [update_nth_pres_len, *]\u27e9\n\ndef modify_at {\u03b1 : Type} (p : point) (x : \u03b1) (g : vec_grid\u2080 \u03b1) : vec_grid\u2080 \u03b1 :=\n  if h : p \u2208 g\n  then let \u27e8r, c\u27e9 :=\n         relpoint_of_gpoint $\n           @grid_point.mk _ _ g\n           \u27e8p.y, by simp only [(\u2208)] at h; exact h.left\u27e9\n           \u27e8p.x, by simp only [(\u2208)] at h; exact h.right\u27e9 in\n    \u27e8\u27e8g.r, g.c, g.h, modify_vec g.data (r * g.c + c) x\u27e9, g.o\u27e9\n  else g\n\ndef modify_many {\u03b1 : Type} (l : list (point \u00d7 \u03b1)) (g : vec_grid\u2080 \u03b1) : vec_grid\u2080 \u03b1 :=\n  foldr (uncurry modify_at) g l\n\ndef count_grid {\u03b1 : Type} [grid \u03b1] [decidable_eq (carrier \u03b1)]\n  (g : \u03b1) (x : carrier \u03b1) := list.count x (\u2118 g)\n\nlemma gen_aof_eq_gen {\u03b1 : Type} {g : fgrid\u2080 \u03b1} :\n  \u2118 (vec_grid\u2080_of_fgrid\u2080 g) = @generate _ ag_fgrid\u2080 g :=\n  by simp [vec_grid\u2080_of_fgrid\u2080, generate_eq_data]\n\nprivate theorem generate_inj_a_f {\u03b1 : Type} {g\u2081 : vec_grid\u2080 \u03b1} {g\u2082 : fgrid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o)\n  (h : \u2118 g\u2081 = @generate (fgrid\u2080 \u03b1) _ g\u2082) : g\u2081 = g\u2082 :=\nbegin\n  have hl\u2081 : length (\u2118 g\u2081) = g\u2081.r * g\u2081.c, from length_generate _,\n  have hl\u2082 : length (\u2118 g\u2082) = g\u2082.r * g\u2082.c, from length_generate _,\n  rcases g\u2081 with \u27e8\u27e8g\u2081r, g\u2081c, g\u2081h, \u27e8g\u2081dv, g\u2081dh\u27e9\u27e9, g\u2081o\u27e9,\n  cases g\u2082 with g\u2082r g\u2082c g\u2082h g\u2082o g\u2082d,\n  dsimp at hrows hcols horig hl\u2081 hl\u2082,\n  subst hrows, subst hcols, subst horig,\n  unfold_coes,\n  simp [vec_grid\u2080_of_fgrid\u2080, h.symm, generate_eq_data]\nend\n\nlemma gen_foa_eq_gen {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} :\n  \u2118 (fgrid\u2080_of_vec_grid\u2080 g) = @generate (vec_grid\u2080 \u03b1) _ g :=\nbegin\n  have hl\u2081 : length (\u2118 g) = rows g * cols g,\n    from length_generate _,\n  have hl\u2082 : length (\u2118 (fgrid\u2080_of_vec_grid\u2080 g)) = rows g * cols g,\n    from length_generate _,\n  simp [fgrid\u2080_of_vec_grid\u2080] at *,\n  apply list.ext_le (hl\u2082.trans hl\u2081.symm) (\u03bbi hi\u2081 hi\u2082, _),\n  simp [\n    nth_le_generate_f\u2080, nth_generate, abs_data_eq_nth_v\u2080', abs_data_eq_nth_f\u2080,\n    tl, bl, rows, cols, expand_gtr\n  ]\nend\n\nprivate theorem generate_inj_f\u2080_v\u2080 {\u03b1 : Type} {g\u2081 : fgrid\u2080 \u03b1} {g\u2082 : vec_grid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o)\n  (h : \u2118 g\u2081 = @generate (fgrid\u2080 \u03b1) _ g\u2082) : g\u2081 = g\u2082 :=\n  generate_inj_f\u2080_f\u2080 hrows hcols horig h\n\ntheorem grid_eq_iff_v\u2080_f\u2080\n  {\u03b1 : Type} {g\u2081 : vec_grid\u2080 \u03b1} {g\u2082 : fgrid\u2080 \u03b1}\n  (h\u2081 : g\u2081.r = g\u2082.r)\n  (h\u2082 : g\u2081.c = g\u2082.c)\n  (h\u2083 : g\u2081.o = g\u2082.o) :\n  g\u2081 = g\u2082 \u2194 \u2118 g\u2081 = \u2118 g\u2082 :=\n  \u27e8\u03bbh, h \u25b8 rfl, \u03bbh, generate_inj_a_f h\u2081 h\u2082 h\u2083 $ by rwa gen_aof_eq_gen.symm\u27e9\n\ntheorem grid_eq_iff_f\u2080_v\u2080\n  {\u03b1 : Type} {g\u2081 : fgrid\u2080 \u03b1} {g\u2082 : vec_grid\u2080 \u03b1}\n  (h\u2081 : g\u2081.r = g\u2082.r)\n  (h\u2082 : g\u2081.c = g\u2082.c)\n  (h\u2083 : g\u2081.o = g\u2082.o) :\n  g\u2081 = g\u2082 \u2194 \u2118 g\u2081 = \u2118 g\u2082 :=\n    \u27e8\u03bbh, h \u25b8 rfl, \u03bbh, generate_inj_f\u2080_v\u2080 h\u2081 h\u2082 h\u2083 h\u27e9\n\n@[ext]\ntheorem grid_eq_ext_v\u2080_v\u2080 {\u03b1 : Type} {g\u2081 g\u2082 : vec_grid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o) : \u2118 g\u2081 = \u2118 g\u2082 \u2192 g\u2081 = g\u2082 :=\n  (grid_eq_iff_v\u2080_v\u2080 hrows hcols horig).2\n\n@[ext]\ntheorem grid_eq_ext_f\u2080_f\u2080 {\u03b1 : Type} {g\u2081 g\u2082 : fgrid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o) : \u2118 g\u2081 = \u2118 g\u2082 \u2192 g\u2081 = g\u2082 :=\n  (grid_eq_iff_f\u2080_f\u2080 hrows hcols horig).2\n\n@[ext]\ntheorem grid_eq_ext_v\u2080_f\u2080 {\u03b1 : Type} {g\u2081 : vec_grid\u2080 \u03b1} {g\u2082 : fgrid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o) : \u2118 g\u2081 = \u2118 g\u2082 \u2192 g\u2081 = g\u2082 :=\n  (grid_eq_iff_v\u2080_f\u2080 hrows hcols horig).2\n\n@[ext]\ntheorem grid_eq_ext_f\u2080_v\u2080 {\u03b1 : Type} {g\u2081 : fgrid\u2080 \u03b1} {g\u2082 : vec_grid\u2080 \u03b1}\n  (hrows : g\u2081.r = g\u2082.r)\n  (hcols : g\u2081.c = g\u2082.c)\n  (horig : g\u2081.o = g\u2082.o) : \u2118 g\u2081 = \u2118 g\u2082 \u2192 g\u2081 = g\u2082 :=\n  (grid_eq_iff_f\u2080_v\u2080 hrows hcols horig).2\n\nlemma nth_vecgrid_of_fgrid {\u03b1 : Type} {g : fgrid\u2080 \u03b1} {n} :\n  list.nth (vec_grid\u2080_of_fgrid\u2080 g).data.val n = list.nth (\u2118 g) n :=\n  by delta vec_grid\u2080_of_fgrid\u2080; simp\n\ninstance decidable_eq_v\u2080_v\u2080 {\u03b1 : Type} [decidable_eq \u03b1]\n  : decidable_eq (vec_grid\u2080 \u03b1) :=\n  \u03bbg\u2081 g\u2082, if h : g\u2081.r = g\u2082.r \u2227 g\u2081.c = g\u2082.c \u2227 g\u2081.o = g\u2082.o then\n            by simp [grid_eq_iff_v\u2080_v\u2080, *]; apply_instance\n          else is_false $ by finish\n\ninstance decidable_eq_f\u2080_f\u2080 {\u03b1 : Type} [decidable_eq \u03b1]\n  : decidable_eq (fgrid\u2080 \u03b1) :=\n  \u03bbg\u2081 g\u2082, if h : g\u2081.r = g\u2082.r \u2227 g\u2081.c = g\u2082.c \u2227 g\u2081.o = g\u2082.o then\n            by simp [grid_eq_iff_f\u2080_f\u2080, *]; apply_instance\n          else is_false $ by finish\n\ninstance decidable_eq_v\u2080_f\u2080 {\u03b1 : Type} [decidable_eq \u03b1]\n  {g\u2081 : vec_grid\u2080 \u03b1} {g\u2082 : fgrid\u2080 \u03b1} : decidable (g\u2081 = g\u2082) :=\n  if h : g\u2081.r = g\u2082.r \u2227 g\u2081.c = g\u2082.c \u2227 g\u2081.o = g\u2082.o then\n    by simp [grid_eq_iff_v\u2080_f\u2080, *]; apply_instance    \n  else is_false $ by finish\n\ninstance decidable_eq_f\u2080_v\u2080 {\u03b1 : Type} [decidable_eq \u03b1]\n  {g\u2081 : fgrid\u2080 \u03b1} {g\u2082 : vec_grid\u2080 \u03b1} : decidable (g\u2081 = g\u2082) :=\n  if h : g\u2081.r = g\u2082.r \u2227 g\u2081.c = g\u2082.c \u2227 g\u2081.o = g\u2082.o then\n    by simp [grid_eq_iff_f\u2080_v\u2080, *]; apply_instance\n  else is_false $ by finish\n\nlemma subgrid_self {\u03b1 : Type} {g : vec_grid\u2080 \u03b1} {bb : bounding_box}\n  (h : bb = {bounding_box. p\u2081 := bl g, p\u2082 := 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 \u27e8\u27e8r, c, h, \u27e8d, hd\u27e9\u27e9, o\u27e9,\n  simp [h, subgrid], unfold_coes,\n  rw grid_eq_iff_f\u2080_f\u2080;\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\u2080,\n      simp only [\n        nth_generate, abs_data, data, expand_gtr, bl, (\u2218),\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\u2080_f\u2080 {\u03b1 : Type} {g\u2081 : vec_grid\u2080 \u03b1} {g\u2082 : fgrid\u2080 \u03b1} {p}\n                     (h\u2081 : g\u2081.r = g\u2082.r)\n                     (h\u2082 : g\u2081.c = g\u2082.c)\n                     (h\u2083 : g\u2081.o = g\u2082.o) : p \u2208 g\u2081 \u2194 p \u2208 g\u2082 :=\nbegin\n  rcases g\u2081 with \u27e8\u27e8r\u2081, c\u2081, gh\u2081, d\u2081\u27e9, o\u2081\u27e9,\n  rcases g\u2082 with \u27e8r\u2082, c\u2082, gh\u2082, o\u2082, d\u2082\u27e9,\n  simp [flip, is_in_grid'] at *,\n  split; intros; unfold_projs at *;  \n  subst h\u2081; subst h\u2082; subst h\u2083; 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 {\u03b1 : Type} {l\u2081 l\u2082 l\u2083 : list \u03b1} {r : \u2124} :\n  repeat r (length (l\u2081 ++ l\u2082 ++ l\u2083)) = \n  repeat r (length l\u2081) ++ repeat r (length l\u2082) ++ repeat r (length l\u2083) :=\n  by simp [repeat_add]\n\nprivate lemma expand_map_zip_repeat {l\u2081 l\u2082 l\u2083} {r : \u2124} :\n  map (uncurry point.mk) (zip (l\u2081 ++ l\u2082 ++ l\u2083) (repeat r (length (l\u2081 ++ l\u2082 ++ l\u2083)))) =\n  map (uncurry point.mk) (zip l\u2081 (repeat r (length l\u2081))) ++\n  map (uncurry point.mk) (zip l\u2082 (repeat r (length l\u2082))) ++\n  map (uncurry point.mk) (zip l\u2083 (repeat r (length l\u2083))) :=\nbegin\n  repeat { rw \u2190 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\u2081x p\u2082x gbl gtr r}\n  (h : p\u2081x < p\u2082x) (h\u2081 : gbl \u2264 p\u2081x) (h\u2082 : p\u2082x \u2264 gtr) :\n  filter (\u03bb (p : point), p\u2081x \u2264 p.x \u2227 p.x < p\u2082x) (grp gbl gtr r) =\n  grp p\u2081x p\u2082x r :=\nbegin\n  unfold grp,\n  generalize eq : range_pure gbl gtr = l,\n  have : \u2203l\u2081 l\u2082, l = l\u2081 ++ l\u2082 \u2227\n                 l\u2081 = range_pure gbl p\u2081x \u2227\n                 l\u2082 = range_pure p\u2081x gtr,\n  from @range_pure_app gbl gtr _ (by linarith) eq.symm _ h\u2081 (by linarith),\n  rcases this with \u27e8l\u2081, \u27e8l\u2082, eq\u2081, eq\u2082, eq\u2083\u27e9\u27e9,\n  have : \u2203l\u2083 l\u2084, l\u2082 = l\u2083 ++ l\u2084 \u2227\n                 l\u2083 = range_pure p\u2081x p\u2082x \u2227\n                 l\u2084 = range_pure p\u2082x gtr,\n  from @range_pure_app p\u2081x gtr _ (by linarith) eq\u2083 _ (int.le_of_lt h) h\u2082,\n  rcases this with \u27e8l\u2083, \u27e8l\u2084, eq\u2084, eq\u2085, eq\u2086\u27e9\u27e9,\n  rw [eq\u2081, eq\u2084], rw \u2190 eq\u2085, rw \u2190 append_assoc,\n  have : length (l\u2081 ++ l\u2083 ++ l\u2084) = |gtr - gbl|,\n    {\n      have : l = l\u2081 ++ l\u2083 ++ l\u2084,\n        by simp [append_assoc, *], rw \u2190 this,\n      rw \u2190 eq, apply range_length_pure, linarith\n    }, rw \u2190 this,\n  rw expand_map_zip_repeat, simp, rw eq\u2082,\n  rw @filter_congr _ _ (\u03bb_, false), swap 2,\n    {\n      intros, split; intros H\u2081, cases x with x y,\n      have eq\u2087 :\n        x \u2208 range_pure gbl p\u2081x \u2227\n        y \u2208 repeat r (length (range_pure gbl p\u2081x)),\n      from in_zip_of H,\n      cases eq\u2087 with eq\u2087 eq\u2088,\n      simp at H\u2081,\n      rw in_range_pure_iff at eq\u2087,\n      have : y = r, from eq_of_mem_repeat eq\u2088,\n      subst this,\n      unfold is_bounded at eq\u2087,\n      cases H\u2081, cases eq\u2087, linarith,\n      contradiction\n    },\n  rw [filter_false, nil_append], rw eq\u2085,\n  rw @filter_congr _ _ (\u03bb_, true), swap 2,\n    {\n      intros, split; intros H\u2081,\n      trivial,\n      cases x with x y,\n      have eq\u2087 :\n        x \u2208 range_pure p\u2081x p\u2082x \u2227\n        y \u2208 repeat r (length (range_pure p\u2081x p\u2082x)),\n      from in_zip_of H,\n      cases eq\u2087 with eq\u2087 eq\u2088,\n      rw in_range_pure_iff at eq\u2087,\n      have : y = r, from eq_of_mem_repeat eq\u2088,\n      subst this,\n      exact eq\u2087\n    }, rw filter_true, rw eq\u2086,\n  rw @filter_congr _ _ (\u03bb_, false), swap 2,\n    {\n      intros, split; intros H\u2081, cases x with x y,\n      have eq\u2087 :\n        x \u2208 range_pure p\u2082x gtr \u2227\n        y \u2208 repeat r (length (range_pure p\u2082x gtr)),\n      from in_zip_of H,\n      cases eq\u2087 with eq\u2087 eq\u2088,\n      simp at H\u2081,\n      rw in_range_pure_iff at eq\u2087,\n      have : y = r, from eq_of_mem_repeat eq\u2088,\n      subst this,\n      unfold is_bounded at eq\u2087,\n      cases H\u2081, cases eq\u2087, 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\u2081x p\u2082x gbl gtr} {l}\n  (h : p\u2081x < p\u2082x) (h\u2081 : gbl \u2264 p\u2081x) (h\u2082 : p\u2082x \u2264 gtr) :\n  filter (\u03bb (p : point), p\u2081x \u2264 p.x \u2227 p.x < p\u2082x)\n    (join (map (grp gbl gtr) l)) = join (map (grp p\u2081x p\u2082x) 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 {\u03b1 : Type*} [grid \u03b1]\n  {g : \u03b1} {bb} {H} :\n  filter (\u03bb (p : point), p \u2208 bb) (gip_g g) =\n  gip_g (subgrid g bb H) :=\nbegin\n  rcases bb with \u27e8p\u2081, p\u2082, hbb\u27e9, rw grid_bounded_iff at hbb,\n  cases hbb with hbb\u2081 hbb\u2082,\n  unfold gip_g gip,\n  rw bl_subgrid_g_bb_eq_bb_p\u2081,\n  rw tr_subgrid_g_bb_eq_bb_p\u2082, simp at *,\n  generalize eq : range_pure p\u2081.y p\u2082.y = l,\n  generalize eq\u2081 : range_pure (bl g).y (gtr g).y = l\u2081,\n  unfold overlaid_by at H,\n  rcases H with \u27e8\u27e8c\u2081, c\u2082\u27e9, c\u2083, c\u2084\u27e9, simp [grid_bounds] at *,\n  have : \u2203l\u2082 l\u2083, l\u2081 = l\u2082 ++ l\u2083 \u2227\n                     l\u2082 = range_pure (bl g).y p\u2081.y \u2227\n                     l\u2083 = range_pure p\u2081.y (gtr g).y,\n  from @range_pure_app (bl g).y (gtr g).y _ blgy_lt_trgy eq\u2081.symm _ c\u2084 (by linarith),\n  rcases this with \u27e8l\u2082, \u27e8l\u2083, eq\u2082, eq\u2083, eq\u2084\u27e9\u27e9,\n  have : \u2203l\u2084 l\u2085, l\u2083 = l\u2084 ++ l\u2085 \u2227\n                 l\u2084 = range_pure p\u2081.y p\u2082.y \u2227\n                 l\u2085 = range_pure p\u2082.y (gtr g).y,\n  from @range_pure_app p\u2081.y (gtr g).y _ (lt_of_lt_of_le hbb\u2082 c\u2083) eq\u2084 _ (int.le_of_lt hbb\u2082) (by linarith),\n  rcases this with \u27e8l\u2084, \u27e8l\u2085, eq\u2085, eq\u2086, eq\u2087\u27e9\u27e9,\n  rw eq\u2082, rw eq\u2085,\n  have eq\u2088 : l\u2084 = l, by cc, subst eq\u2088,\n  simp only [flip, is_in_grid, is_bounded],\n  simp, rw eq\u2083, rw eq\u2086, rw eq\u2087,\n  rw @filter_congr _ _ (\u03bb_, false), swap 2,\n  intros, split; intros H\u2081,\n    {\n      rw in_join_grp_range_iff at H, unfold is_bounded at H,\n      have contra\u2081 : p\u2081.y \u2264 x.y, from H\u2081.1.1,\n      have contra\u2082 : x.y < p\u2081.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 (\u03bb (p : point), (p\u2081.y \u2264 p.y \u2227 p.y < p\u2082.y) \u2227 p\u2081.x \u2264 p.x \u2227 p.x < p\u2082.x)\n           (join (map (grp ((bl g).x) ((gtr g).x)) (range_pure (p\u2081.y) (p\u2082.y)))) = prot\u2081,\n  rw @filter_congr _ _ (\u03bb_, false), swap 2,\n  intros, split; intros H\u2081,\n    {\n      rw in_join_grp_range_iff at H, unfold is_bounded at H,\n      have contra\u2081 : x.y < p\u2082.y, from H\u2081.1.2,\n      have contra\u2082 : p\u2082.y \u2264 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 \u2190 protect,\n  rw @filter_congr _ _ (\u03bb (p : point), p\u2081.x \u2264 p.x \u2227 p.x < p\u2082.x),\n  swap 2,\n    {\n      intros, split; intros H\u2081,\n      exact H\u2081.right,\n      rw in_join_grp_range_iff at H, unfold is_bounded at H,\n      exact \u27e8H.2, H\u2081\u27e9,\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 (\u03bb (p : point), p \u2208 bb) (gip_g g)) n H =\n    {x := bb.p\u2081.x + \u2191n % \u2191(cols_of_box bb),\n     y := bb.p\u2081.y + \u2191n / \u2191(cols_of_box bb)} :=\nbegin\n  rw \u2190 option.some_inj, rw \u2190 nth_le_nth,\n  rw @filter_generate_subgrid _ _ _ _ h, rw nth_gip_g,\n  rw bl_subgrid_g_bb_eq_bb_p\u2081,\n  refl, rw @filter_generate_subgrid _ _ _ _ h at H,\n  exact H\nend\n\nlemma rows_of_overlaid_le {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb}\n  (H : overlaid_by bb (grid_bounds g)) : rows_of_box bb \u2264 rows g :=\nbegin\n  unfold rows_of_box, unfold overlaid_by grid_bounds at H, simp at H,\n  rcases H with \u27e8\u27e8h\u2081, h\u2082\u27e9, h\u2083, h\u2084\u27e9,\n  rw rows_eq_try_sub_bly,\n  rw \u2190 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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb}\n  (H : overlaid_by bb (grid_bounds g)) : cols_of_box bb \u2264 cols g :=\nbegin\n  unfold cols_of_box, unfold overlaid_by grid_bounds at H, simp at H,\n  rcases H with \u27e8\u27e8h\u2081, h\u2082\u27e9, h\u2083, h\u2084\u27e9,\n  rw cols_eq_trx_sub_blx,\n  rw \u2190 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 {\u03b1 : Type*} [grid \u03b1] {g : \u03b1} {bb} {H} :\n  size (subgrid g bb H) \u2264 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 {\u03b1 : Type} {l\u2081 l\u2082 : list \u03b1}\n  (h : l\u2081 = l\u2082) {P\u2081 : {x : \u03b1 | x \u2208 l\u2081} \u2192 Prop} {P\u2082 : {x : \u03b1 | x \u2208 l\u2082} \u2192 Prop}\n  [decidable_pred P\u2081] [decidable_pred P\u2082]\n  (h\u2081 : \u2200x : \u03b1, x \u2208 l\u2081 \u2192 (P\u2081 \u27e8x, by simp [a]\u27e9 \u2194 P\u2082 \u27e8x, begin simp, rw \u2190 h, exact a end\u27e9)) :\n  length (filter P\u2081 (attach l\u2081)) = length (filter P\u2082 (attach l\u2082)) :=\nbegin\n  resetI, subst h,\n  have : P\u2081 = P\u2082,\n    {\n      apply funext,\n      intros, cases x with x hx, simp at hx,\n      simp,\n      split; intros h,\n        {\n          specialize h\u2081 x hx, \n          rw \u2190 h\u2081,\n          exact h\n        },\n        {\n          specialize h\u2081 x hx, \n          rw h\u2081,\n          exact h\n        }\n    },\n  subst this,\n  finish\nend\n\nprivate lemma filter_congr_heq' {\u03b1 : Type} {l\u2081 l\u2082 : list \u03b1}\n  (h : l\u2081 = l\u2082) {P\u2081 : {x : \u03b1 // x \u2208 l\u2081} \u2192 Prop} {P\u2082 : {x : \u03b1 // x \u2208 l\u2082} \u2192 Prop}\n  [decidable_pred P\u2081] [decidable_pred P\u2082]\n  (h\u2081 : \u2200x : \u03b1, x \u2208 l\u2081 \u2192 (P\u2081 \u27e8x, by simp [a]\u27e9 \u2194 P\u2082 \u27e8x, begin rw \u2190 h, exact a end\u27e9)) :\n  length (filter P\u2081 (pmap subtype.mk l\u2081 (\u03bb_, id))) = length (filter P\u2082 (pmap subtype.mk l\u2082 (\u03bb_, id))) :=\n  filter_congr_heq h h\u2081 \n\nlemma count_subgrid_in_bb {\u03b1 : Type*} [grid \u03b1] [decidable_eq (carrier \u03b1)]\n  (g : \u03b1) {bb} {H\u2081} {elem : carrier \u03b1} :\n  count elem (@generate _ _  (subgrid g bb H\u2081)) =\n  countp\n    (\u03bb (x : {x // x \u2208 filter (\u03bb (p : point), p \u2208 bb) (gip_g g)}),\n        elem = abs_data g {\n  x := \u27e8(x.val).x,\n  begin\n    rcases x with \u27e8\u27e8x, y\u27e9, hx\u27e9, simp, rw mem_filter at hx,\n    cases hx with hx\u2081 hx\u2082,\n    rw \u2190 in_grid_iff_in_gip_g at hx\u2081,\n    exact hx\u2081.2\n  end\u27e9,\n  y := \u27e8(x.val).y,\n  begin\n    rcases x with \u27e8\u27e8x, y\u27e9, hx\u27e9, simp, rw mem_filter at hx,\n    cases hx with hx\u2081 hx\u2082,\n    rw \u2190 in_grid_iff_in_gip_g at hx\u2081,\n    exact hx\u2081.1\n  end\u27e9})\n    (attach (filter (\u03bb (p : point), p \u2208 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    (\u2218), inject_into_bounded, grid_point_of_prod, make_bounded,\n    make_bounded_idx\n  ],\n  let eq := @filter_generate_subgrid _ _ g bb H\u2081, symmetry' at eq,\n  apply filter_congr_heq eq,\n  rintros \u27e8x, y\u27e9 p,\n  split; intros h; simp [h];  \n  rw abs_data_eq_nth_f\u2080;\n  delta subgrid; simp; refl\nend\n\nlemma filter_partition_dependent'\n  {\u03b1 : Type} [decidable_eq \u03b1] {l : list \u03b1}\n  {Q : \u03b1 \u2192 Prop} {R : \u03b1 \u2192 Prop}\n  [decidable_pred Q] [decidable_pred R]\n  {\u03b2} {P : \u03b2 \u2192 Prop} [decidable_pred P]\n  (h : \u2200x, \u00acQ x \u2194 R x)\n  (p : \u03b1 \u2192 Prop) (f : \u2200 a, p a \u2192 \u03b2)\n  {\u03b2\u2081} (i\u2081 : \u03b2\u2081 \u2192 \u03b2) (p\u2081 : \u03b1 \u2192 Prop) (f\u2081 : \u2200 a, p\u2081 a \u2192 \u03b2\u2081)\n  {\u03b2\u2082} (i\u2082 : \u03b2\u2082 \u2192 \u03b2) (p\u2082 : \u03b1 \u2192 Prop) (f\u2082 : \u2200 a, p\u2082 a \u2192 \u03b2\u2082) :\n  \u2200 (H : \u2200 (a : \u03b1), a \u2208 l \u2192 p a)\n    (H\u2081 : \u2200 (a : \u03b1), a \u2208 filter Q l \u2192 p\u2081 a)\n    (H\u2082 : \u2200 (a : \u03b1), a \u2208 filter R l \u2192 p\u2082 a)\n    (heq : \u2200x (H\u2083 : x \u2208 l) (H\u2084 : Q x), P (f x (H x H\u2083)) \u2192 P (i\u2081 (f\u2081 x (H\u2081 x (by simp [H\u2083, H\u2084])))))\n    (heq\u2081 : \u2200x (H\u2083 : x \u2208 l) (H\u2084 : R x), P (f x (H x H\u2083)) \u2192 P (i\u2082 (f\u2082 x (H\u2082 x (by simp [H\u2083, H\u2084])))))\n    (heq\u2082 : \u2200x (H\u2083 : x \u2208 l) (H\u2084 : Q x), \u00acP (f x (H x H\u2083)) \u2192 \u00acP (i\u2081 (f\u2081 x (H\u2081 x (by simp [H\u2083, H\u2084])))))\n    (heq\u2083 : \u2200x (H\u2083 : x \u2208 l) (H\u2084 : R x), \u00acP (f x (H x H\u2083)) \u2192 \u00acP (i\u2082 (f\u2082 x (H\u2082 x (by simp [H\u2083, H\u2084]))))),\n  length (filter P (pmap f l H)) =\n  length (filter (\u03bb x, P (i\u2081 x)) (pmap f\u2081 (filter Q l) H\u2081)) +\n  length (filter (\u03bb x, P (i\u2082 x)) (pmap f\u2082 (filter R l) H\u2082)) :=\nbegin\n  induction l with hd tl ih; intros,\n    {simp},\n    {\n      by_cases h\u2081 : P (f hd (H _ (mem_cons_self _ _))),\n        {\n          unfold pmap,\n          rw filter_cons_of_pos _ h\u2081,\n          rw length_cons,\n          by_cases h\u2082 : Q hd,\n            {\n              simp [filter_cons_of_pos _ h\u2082, -add_comm],\n              have : \u00acR hd, by finish,\n              simp [filter_cons_of_neg _ this, -add_comm],\n              have h\u2083 : P (i\u2081 (f\u2081 hd (H\u2081 _ (by simp [h\u2082])))),\n                {\n                  apply heq, exact h\u2082, exact h\u2081\n                },\n              simp [h\u2083], rw add_comm,\n              apply ih,\n              intros, apply heq, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2081, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2082, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2083, exact H\u2084, exact a, right, exact H\u2083\n            },\n            {\n              simp [filter_cons_of_neg _ h\u2082, -add_comm],\n              have : R hd, by finish,\n              simp [filter_cons_of_pos _ this, -add_comm],\n              have h\u2083 : P (i\u2082 (f\u2082 hd (H\u2082 _ (by simp [this])))),\n                {\n                  apply heq\u2081, exact this, exact h\u2081\n                },\n              simp [h\u2083],\n              apply ih,\n              intros, apply heq, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2081, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2082, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2083, exact H\u2084, exact a, right, exact H\u2083\n            }\n        },\n        {\n          unfold pmap,\n          rw filter_cons_of_neg _ h\u2081,\n          by_cases h\u2082 : Q hd,\n            {\n              simp [filter_cons_of_pos _ h\u2082, -add_comm],\n              have : \u00acR hd, by finish,\n              simp [filter_cons_of_neg _ this, -add_comm],\n              have h\u2083 : \u00acP (i\u2081 (f\u2081 hd (H\u2081 _ (by simp [h\u2082])))),\n                {\n                  apply heq\u2082, exact h\u2082, exact h\u2081\n                },\n              simp [h\u2083], rw add_comm,\n              apply ih,\n              intros, apply heq, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2081, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2082, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2083, exact H\u2084, exact a, right, exact H\u2083\n            },\n            {\n              simp [filter_cons_of_neg _ h\u2082, -add_comm],\n              have : R hd, by finish,\n              simp [filter_cons_of_pos _ this, -add_comm],\n              have h\u2083 : \u00acP (i\u2082 (f\u2082 hd (H\u2082 _ (by simp [this])))),\n                {\n                  apply heq\u2083, exact this, exact h\u2081\n                },\n              simp [h\u2083],\n              apply ih,\n              intros, apply heq, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2081, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2082, exact H\u2084, exact a, right, exact H\u2083,\n              intros, apply heq\u2083, exact H\u2084, exact a, right, exact H\u2083\n            }\n        }\n    }\nend\n\nprivate lemma count_partition_over_filter\n  {\u03b1 : Type} {l : list \u03b1} [decidable_eq \u03b1]\n  {P : \u03b1 \u2192 Prop} [decidable_pred P]\n  {P\u2083 : \u03b1 \u2192 Prop} [decidable_pred P\u2083]\n  {P\u2085 : {x // x \u2208 l} \u2192 Prop} [decidable_pred P\u2085]\n  (h : \u2200x, \u00acP x \u2194 P\u2083 x) :\n  length (filter (\u03bb (x : {x // x \u2208 l}), P\u2085 x) (attach l)) =\n  length (filter (\u03bb (x : {x // x \u2208 filter P l}), P\u2085 \u27e8x.1, in_l_of_in_filter x.2\u27e9) (attach (filter P l))) +\n  length (filter (\u03bb (x : {x // x \u2208 filter P\u2083 l}), P\u2085 \u27e8x.1, in_l_of_in_filter x.2\u27e9) (attach (filter P\u2083 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 {\u03b1 : Type*} [grid \u03b1] [decidable_eq (carrier \u03b1)] (g : \u03b1) (bb) (H\u2081)\n  {elem : carrier \u03b1} :\n  count elem (\u2118 g) =\n  count elem (@generate _ _ (subgrid g bb H\u2081)) +\n  count elem (subgrid' g bb H\u2081) :=\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 [(\u2218)],\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 : \u2115 \u2192 \u2115 \u2192 list string \u2192 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 {\u03b1 : Type*} [grid \u03b1]\n  [has_to_string (carrier \u03b1)] (g : \u03b1) : string :=\n  let points := list.map to_string $ \u2118 g in\n    \" \" ++ (list.foldr append \"\" $\n                       list.intersperse \" \" $\n                       split_rows_cols (cols g)\n                                       (rows g) points)\n\ninstance grid_repr {\u03b1 : Type*} [grid \u03b1]\n  [has_to_string (carrier \u03b1)] : has_repr \u03b1 := \u27e8grid_str\u27e9\n\ninstance grid_to_string {\u03b1 : Type*} [grid \u03b1]\n  [has_to_string (carrier \u03b1)] : has_to_string \u03b1 := \u27e8grid_str\u27e9\n\n-- def test_grid : vec_grid\u2080 \u2115 :=\n--   vec_grid\u2080.mk \u27e84, 5, dec_trivial,\n--     \u27e8[1, 2, 3, 4, 5,\n--       1, 2, 3, 4, 5,\n--       1, 2, 3, 4, 5,\n--       1, 2, 3, 4, 5], rfl\u27e9\u27e9 \u27e80, 0\u27e9\n-- def testbb : bounding_box := \u27e8\u27e80, 0\u27e9, \u27e82, 3\u27e9, sorry\u27e9\n-- #eval list.filter (\u03bbx, x \u2208 testbb) (gip_g test_grid)\n-- #eval gip_g (subgrid test_grid testbb sorry)\n-- #eval list.count 4 (\u2118 test_grid)\n-- #eval list.count 4 (\u2118 (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 \u27e8\u27e81, 1\u27e9, \u27e84, 3\u27e9, sorry\u27e9 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 \u2192 Prop) (h : \u2200 n, p (n+1) = p n) : (p m \u2194 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 {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [mul_action \u03b1 \u03b2] (u : units \u03b1) (x : \u03b2) : \u2191(u\u207b\u00b9) \u2022 \u2191u \u2022 x = x :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2191(u\u207b\u00b9) \u2022 \u2191u \u2022 x = x)) (smul_smul (\u2191(u\u207b\u00b9)) (\u2191u) x)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((\u2191(u\u207b\u00b9) * \u2191u) \u2022 x = x)) (units.inv_mul u)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (1 \u2022 x = x)) (one_smul \u03b1 x))) (Eq.refl x)))\n\n@[simp] theorem units.smul_inv_smul {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [mul_action \u03b1 \u03b2] (u : units \u03b1) (x : \u03b2) : \u2191u \u2022 \u2191(u\u207b\u00b9) \u2022 x = x :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2191u \u2022 \u2191(u\u207b\u00b9) \u2022 x = x)) (smul_smul (\u2191u) (\u2191(u\u207b\u00b9)) x)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((\u2191u * \u2191(u\u207b\u00b9)) \u2022 x = x)) (units.mul_inv u)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (1 \u2022 x = x)) (one_smul \u03b1 x))) (Eq.refl x)))\n\n/-- If a monoid `\u03b1` acts on `\u03b2`, then each `u : units \u03b1` defines a permutation of `\u03b2`. -/\ndef units.smul_perm_hom {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [mul_action \u03b1 \u03b2] : units \u03b1 \u2192* equiv.perm \u03b2 :=\n  monoid_hom.mk\n    (fun (u : units \u03b1) =>\n      equiv.mk (fun (x : \u03b2) => \u2191u \u2022 x) (fun (x : \u03b2) => \u2191(u\u207b\u00b9) \u2022 x) (units.inv_smul_smul u) (units.smul_inv_smul u))\n    sorry sorry\n\n@[simp] theorem units.smul_left_cancel {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [mul_action \u03b1 \u03b2] (u : units \u03b1) {x : \u03b2} {y : \u03b2} : \u2191u \u2022 x = \u2191u \u2022 y \u2194 x = y :=\n  equiv.apply_eq_iff_eq (coe_fn units.smul_perm_hom u)\n\ntheorem units.smul_eq_iff_eq_inv_smul {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [mul_action \u03b1 \u03b2] (u : units \u03b1) {x : \u03b2} {y : \u03b2} : \u2191u \u2022 x = y \u2194 x = \u2191(u\u207b\u00b9) \u2022 y :=\n  equiv.apply_eq_iff_eq_symm_apply (coe_fn units.smul_perm_hom u)\n\ntheorem is_unit.smul_left_cancel {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [mul_action \u03b1 \u03b2] {a : \u03b1} (ha : is_unit a) {x : \u03b2} {y : \u03b2} : a \u2022 x = a \u2022 y \u2194 x = y := sorry\n\n@[simp] theorem inv_smul_smul' {\u03b1 : Type u} {\u03b2 : Type v} [group_with_zero \u03b1] [mul_action \u03b1 \u03b2] {c : \u03b1} (hc : c \u2260 0) (x : \u03b2) : c\u207b\u00b9 \u2022 c \u2022 x = x :=\n  units.inv_smul_smul (units.mk0 c hc) x\n\n@[simp] theorem smul_inv_smul' {\u03b1 : Type u} {\u03b2 : Type v} [group_with_zero \u03b1] [mul_action \u03b1 \u03b2] {c : \u03b1} (hc : c \u2260 0) (x : \u03b2) : c \u2022 c\u207b\u00b9 \u2022 x = x :=\n  units.smul_inv_smul (units.mk0 c hc) x\n\ntheorem inv_smul_eq_iff' {\u03b1 : Type u} {\u03b2 : Type v} [group_with_zero \u03b1] [mul_action \u03b1 \u03b2] {a : \u03b1} (ha : a \u2260 0) {x : \u03b2} {y : \u03b2} : a\u207b\u00b9 \u2022 x = y \u2194 x = a \u2022 y := sorry\n\ntheorem eq_inv_smul_iff' {\u03b1 : Type u} {\u03b2 : Type v} [group_with_zero \u03b1] [mul_action \u03b1 \u03b2] {a : \u03b1} (ha : a \u2260 0) {x : \u03b2} {y : \u03b2} : x = a\u207b\u00b9 \u2022 y \u2194 a \u2022 x = y := sorry\n\n@[simp] theorem inv_smul_smul {\u03b1 : Type u} {\u03b2 : Type v} [group \u03b1] [mul_action \u03b1 \u03b2] (c : \u03b1) (x : \u03b2) : c\u207b\u00b9 \u2022 c \u2022 x = x :=\n  units.inv_smul_smul (coe_fn to_units c) x\n\n@[simp] theorem smul_inv_smul {\u03b1 : Type u} {\u03b2 : Type v} [group \u03b1] [mul_action \u03b1 \u03b2] (c : \u03b1) (x : \u03b2) : c \u2022 c\u207b\u00b9 \u2022 x = x :=\n  units.smul_inv_smul (coe_fn to_units c) x\n\ntheorem inv_smul_eq_iff {\u03b1 : Type u} {\u03b2 : Type v} [group \u03b1] [mul_action \u03b1 \u03b2] {a : \u03b1} {x : \u03b2} {y : \u03b2} : a\u207b\u00b9 \u2022 x = y \u2194 x = a \u2022 y := sorry\n\ntheorem eq_inv_smul_iff {\u03b1 : Type u} {\u03b2 : Type v} [group \u03b1] [mul_action \u03b1 \u03b2] {a : \u03b1} {x : \u03b2} {y : \u03b2} : x = a\u207b\u00b9 \u2022 y \u2194 a \u2022 x = y := sorry\n\n/-- Given an action of a group `\u03b1` on a set `\u03b2`, each `g : \u03b1` defines a permutation of `\u03b2`. -/\ndef mul_action.to_perm (\u03b1 : Type u) (\u03b2 : Type v) [group \u03b1] [mul_action \u03b1 \u03b2] : \u03b1 \u2192* equiv.perm \u03b2 :=\n  monoid_hom.comp units.smul_perm_hom (mul_equiv.to_monoid_hom to_units)\n\nprotected theorem mul_action.bijective {\u03b1 : Type u} {\u03b2 : Type v} [group \u03b1] [mul_action \u03b1 \u03b2] (g : \u03b1) : function.bijective fun (b : \u03b2) => g \u2022 b :=\n  equiv.bijective (coe_fn (mul_action.to_perm \u03b1 \u03b2) g)\n\ntheorem units.smul_eq_zero {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [add_monoid \u03b2] [distrib_mul_action \u03b1 \u03b2] (u : units \u03b1) {x : \u03b2} : \u2191u \u2022 x = 0 \u2194 x = 0 := sorry\n\ntheorem units.smul_ne_zero {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [add_monoid \u03b2] [distrib_mul_action \u03b1 \u03b2] (u : units \u03b1) {x : \u03b2} : \u2191u \u2022 x \u2260 0 \u2194 x \u2260 0 :=\n  not_congr (units.smul_eq_zero u)\n\n@[simp] theorem is_unit.smul_eq_zero {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [add_monoid \u03b2] [distrib_mul_action \u03b1 \u03b2] {u : \u03b1} (hu : is_unit u) {x : \u03b2} : u \u2022 x = 0 \u2194 x = 0 :=\n  exists.elim hu fun (u_1 : units \u03b1) (hu : \u2191u_1 = u) => hu \u25b8 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 \u2964 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 \u22d9 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\u2081 u\u2082\n\nvariables {C : Type u\u2081} [category.{v} C] [has_limits C]\nvariables {D : Type u\u2082} [category.{v} D] [has_limits D]\nvariables (G : C \u2964 D) [preserves_limits G]\nvariables {X : Top.{v}} (F : presheaf C X)\nvariables {\u03b9 : Type v} (U : \u03b9 \u2192 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 \u22d9 G`.\n-/\ndef diagram_comp_preserves_limits :\n  diagram F U \u22d9 G \u2245 diagram (F \u22d9 G) U :=\nbegin\n  fapply nat_iso.of_components,\n  rintro \u27e8j\u27e9,\n  exact (preserves_product.iso _ _),\n  exact (preserves_product.iso _ _),\n  rintros \u27e8\u27e9 \u27e8\u27e9 \u27e8\u27e9,\n  { ext, simp, dsimp, simp, }, -- non-terminal `simp`, but `squeeze_simp` fails\n  { ext,\n    simp only [limit.lift_\u03c0, functor.comp_map, map_lift_pi_comparison, fan.mk_\u03c0_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_\u03c0, functor.comp_map, parallel_pair_map_right, fan.mk_\u03c0_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 \u22d9 G`,\npostcomposed with the inverse of the natural isomorphism `diagram_comp_preserves_limits`.\n-/\ndef map_cone_fork : G.map_cone (fork F U) \u2245\n  (cones.postcompose (diagram_comp_preserves_limits G F U).inv).obj (fork (F \u22d9 G) U) :=\ncones.ext (iso.refl _) (\u03bb 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_\u03c0, fan.mk_\u03c0_app, \u2190G.map_comp, limit.lift_\u03c0_assoc, fan.mk_\u03c0_app] }\nend)\n\nend sheaf_condition\n\nuniverses v u\u2081 u\u2082\n\nopen sheaf_condition sheaf_condition_equalizer_products\n\nvariables {C : Type u\u2081} [category.{v} C] {D : Type u\u2082} [category.{v} D]\nvariables (G : C \u2964 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 \u2964 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 \u22d9 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 \u2964 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 \u2243 sheaf_condition (F \u22d9 G) :=\nbegin\n  apply equiv_of_subsingleton_of_subsingleton,\n  { intros S \u03b9 U,\n    -- We have that the sheaf condition fork for `F` is a limit fork,\n    have t\u2081 := S U,\n    -- and since `G` preserves limits, the image under `G` of this fork is a limit fork too.\n    have t\u2082 := @preserves_limit.preserves _ _ _ _ _ _ _ G _ _ t\u2081,\n    -- As we established above, that image is just the sheaf condition fork\n    -- for `F \u22d9 G` postcomposed with some natural isomorphism,\n    have t\u2083 := is_limit.of_iso_limit t\u2082 (map_cone_fork G F U),\n    -- and as postcomposing by a natural isomorphism preserves limit cones,\n    have t\u2084 := is_limit.postcompose_inv_equiv _ _ t\u2083,\n    -- we have our desired conclusion.\n    exact t\u2084, },\n  { intros S \u03b9 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 \u27e8_|_\u27e9; { 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 \u22d9 G` to the\n      -- image under `G` of the equalizer cone for the sheaf condition diagram.\n      let c := fork (F \u22d9 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 \u27f6 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.\u03b9,\n        ext1 j,\n        dsimp,\n        simp only [category.assoc, \u2190functor.map_comp_assoc, equalizer.lift_\u03b9,\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 \u22d9 (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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u211a`, is the type of rational numbers. It is defined\n  as the set of pairs \u27e8n, d\u27e9 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 : \u2124)\n(denom : \u2115)\n(pos : denom > 0)\n(cop : num.nat_abs.coprime denom)\nnotation `\u211a` := rat\n\nnamespace rat\n\nprotected def repr : \u211a \u2192 string\n| \u27e8n, d, _, _\u27e9 := if d = 1 then _root_.repr n else\n  _root_.repr n ++ \"/\" ++ _root_.repr d\n\ninstance : has_repr \u211a := \u27e8rat.repr\u27e9\ninstance : has_to_string \u211a := \u27e8rat.repr\u27e9\nmeta instance : has_to_format \u211a := \u27e8coe \u2218 rat.repr\u27e9\n\ninstance : encodable \u211a := encodable.of_equiv (\u03a3 n : \u2124, {d : \u2115 // d > 0 \u2227 n.nat_abs.coprime d})\n  \u27e8\u03bb \u27e8a, b, c, d\u27e9, \u27e8a, b, c, d\u27e9, \u03bb\u27e8a, b, c, d\u27e9, \u27e8a, b, c, d\u27e9,\n   \u03bb \u27e8a, b, c, d\u27e9, rfl, \u03bb\u27e8a, b, c, d\u27e9, rfl\u27e9\n\n/-- Embed an integer as a rational number -/\ndef of_int (n : \u2124) : \u211a :=\n\u27e8n, 1, nat.one_pos, nat.coprime_one_right _\u27e9\n\ninstance : has_zero \u211a := \u27e8of_int 0\u27e9\ninstance : has_one \u211a := \u27e8of_int 1\u27e9\ninstance : inhabited \u211a := \u27e80\u27e9\n\n/-- Form the quotient `n / d` where `n:\u2124` and `d:\u2115+` (not necessarily coprime) -/\ndef mk_pnat (n : \u2124) : \u2115+ \u2192 \u211a | \u27e8d, dpos\u27e9 :=\nlet n' := n.nat_abs, g := n'.gcd d in\n\u27e8n / 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 / \u2191g) = 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\u27e9\n\n/-- Form the quotient `n / d` where `n:\u2124` and `d:\u2115`. In the case `d = 0`, we\n  define `n / 0 = 0` by convention. -/\ndef mk_nat (n : \u2124) (d : \u2115) : \u211a :=\nif d0 : d = 0 then 0 else mk_pnat n \u27e8d, nat.pos_of_ne_zero d0\u27e9\n\n/-- Form the quotient `n / d` where `n d : \u2124`. -/\ndef mk : \u2124 \u2192 \u2124 \u2192 \u211a\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 \u27e8d, h\u27e9 = 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 : \u2124) \u2223 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 : \u2124} (b0 : b \u2260 0) : a /. b = 0 \u2194 a = 0 :=\nbegin\n  constructor; intro h; [skip, {subst a, simp}],\n  have : \u2200 {a b}, mk_pnat a b = 0 \u2192 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 : \u2200 {a b c d : \u2124} (hb : b \u2260 0) (hd : d \u2260 0),\n  a /. b = c /. d \u2194 a * d = c * b :=\nsuffices \u2200 a b c d hb hd, mk_pnat a \u27e8b, hb\u27e9 = mk_pnat c \u27e8d, hd\u27e9 \u2194 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 * \u2191(d.succ) = -c * \u2191b \u2194 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 * \u2191d = c * b.succ \u2194 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 \u2194 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 \u2190 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 := \u03bb {a b}, nat.gcd_dvd_right (int.nat_abs a) b,\n      have := nat.eq_mul_of_div_eq_right dv hb,\n      rw \u2190 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 : \u2124) \u2260 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 : \u2200 a c, a * d = c * b \u2192\n      a / a.gcd b = c / c.gcd d \u2227 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\u2081 h\u2082,\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 \u2190 int.sign_mul_nat_abs a },\n      conv in c { rw \u2190 int.sign_mul_nat_abs c },\n      rw [int.mul_div_assoc, int.mul_div_assoc],\n      exact \u27e8congr (congr_arg (*) hs) (congr_arg coe h\u2081), h\u2082\u27e9,\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 \u27e8_, bd\u27e9,\n      apply nat.eq_of_mul_eq_mul_left hb,\n      rw [\u2190 nat.mul_div_assoc _ (nat.gcd_dvd_left _ _), mul_comm,\n          nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), bd,\n          \u2190 nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), h, mul_comm,\n          nat.mul_div_assoc _ (nat.gcd_dvd_left _ _)] },\n    suffices : \u2200 {a c : \u2115} (b>0) (d>0),\n      a * d = c * b \u2192 b / a.gcd b \u2264 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 \u27e8c / c.gcd d, _\u27e9,\n    rw [\u2190 nat.mul_div_assoc _ (nat.gcd_dvd_left _ _),\n        \u2190 nat.mul_div_assoc _ (nat.gcd_dvd_right _ _)],\n    apply congr_arg (/ c.gcd d),\n    rw [mul_comm, \u2190 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 : \u2124} (c0 : c \u2260 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 : \u2200 a : \u211a, a = a.num /. a.denom\n| \u27e8n, d, h, (c:_=1)\u27e9 := 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) : (\u27e8n, d, h, c\u27e9 : \u211a) = n /. d := num_denom _\n\n@[elab_as_eliminator] theorem {u} num_denom_cases_on {C : \u211a \u2192 Sort u}\n   : \u2200 (a : \u211a) (H : \u2200 n d, d > 0 \u2192 (int.nat_abs n).coprime d \u2192 C (n /. d)), C a\n| \u27e8n, d, h, c\u27e9 H := by rw num_denom'; exact H n d h c\n\n@[elab_as_eliminator] theorem {u} num_denom_cases_on' {C : \u211a \u2192 Sort u}\n   (a : \u211a) (H : \u2200 (n:\u2124) (d:\u2115), d \u2260 0 \u2192 C (n /. d)) : C a :=\nnum_denom_cases_on a $ \u03bb n d h c,\nH n d $ ne_of_gt h\n\ntheorem num_dvd (a) {b : \u2124} (b0 : b \u2260 0) : (a /. b).num \u2223 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 : \u2124) : ((a /. b).denom : \u2124) \u2223 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 [\u2190 int.nat_abs_mul, \u2190 int.coe_nat_dvd, int.dvd_nat_abs, \u2190 e], simp\nend\n\nprotected def add : \u211a \u2192 \u211a \u2192 \u211a\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := mk_pnat (n\u2081 * d\u2082 + n\u2082 * d\u2081) \u27e8d\u2081 * d\u2082, mul_pos h\u2081 h\u2082\u27e9\n\ninstance : has_add \u211a := \u27e8rat.add\u27e9\n\ntheorem lift_binop_eq (f : \u211a \u2192 \u211a \u2192 \u211a) (f\u2081 : \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124) (f\u2082 : \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124)\n  (fv : \u2200 {n\u2081 d\u2081 h\u2081 c\u2081 n\u2082 d\u2082 h\u2082 c\u2082},\n    f \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 = f\u2081 n\u2081 d\u2081 n\u2082 d\u2082 /. f\u2082 n\u2081 d\u2081 n\u2082 d\u2082)\n  (f0 : \u2200 {n\u2081 d\u2081 n\u2082 d\u2082} (d\u20810 : d\u2081 \u2260 0) (d\u20820 : d\u2082 \u2260 0), f\u2082 n\u2081 d\u2081 n\u2082 d\u2082 \u2260 0)\n  (a b c d : \u2124) (b0 : b \u2260 0) (d0 : d \u2260 0)\n  (H : \u2200 {n\u2081 d\u2081 n\u2082 d\u2082} (h\u2081 : a * d\u2081 = n\u2081 * b) (h\u2082 : c * d\u2082 = n\u2082 * d),\n       f\u2081 n\u2081 d\u2081 n\u2082 d\u2082 * f\u2082 a b c d = f\u2081 a b c d * f\u2082 n\u2081 d\u2081 n\u2082 d\u2082) :\n  f (a /. b) (c /. d) = f\u2081 a b c d /. f\u2082 a b c d :=\nbegin\n  generalize ha : a /. b = x, cases x with n\u2081 d\u2081 h\u2081 c\u2081, rw num_denom' at ha,\n  generalize hc : c /. d = x, cases x with n\u2082 d\u2082 h\u2082 c\u2082, rw num_denom' at hc,\n  rw fv,\n  have d\u20810 := ne_of_gt (int.coe_nat_lt.2 h\u2081),\n  have d\u20820 := ne_of_gt (int.coe_nat_lt.2 h\u2082),\n  exact (mk_eq (f0 d\u20810 d\u20820) (f0 b0 d0)).2 (H ((mk_eq b0 d\u20810).1 ha) ((mk_eq d0 d\u20820).1 hc))\nend\n\n@[simp] theorem add_def {a b c d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 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\u20810 d\u20820 },\n  calc (n\u2081 * d\u2082 + n\u2082 * d\u2081) * (b * d) =\n          (n\u2081 * b) * d\u2082 * d + (n\u2082 * d) * (d\u2081 * b) : by simp [mul_add, mul_comm, mul_left_comm]\n    ... = (a * d\u2081) * d\u2082 * d + (c * d\u2082) * (d\u2081 * b) : by rw [h\u2081, h\u2082]\n    ... = (a * d + c * b) * (d\u2081 * d\u2082)             : by simp [mul_add, mul_comm, mul_left_comm]\nend\n\nprotected def neg : \u211a \u2192 \u211a\n| \u27e8n, d, h, c\u27e9 := \u27e8-n, d, h, by simp [c]\u27e9\n\ninstance : has_neg \u211a := \u27e8rat.neg\u27e9\n\n@[simp] theorem neg_def {a b : \u2124} : -(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\u2081 d\u2081 h\u2081 c\u2081, rw num_denom' at ha,\n  show rat.mk' _ _ _ _ = _, rw num_denom',\n  have d0 := ne_of_gt (int.coe_nat_lt.2 h\u2081),\n  apply (mk_eq d0 b0).2, have h\u2081 := (mk_eq b0 d0).1 ha,\n  simp only [neg_mul_eq_neg_mul_symm, congr_arg has_neg.neg h\u2081]\nend\n\nprotected def mul : \u211a \u2192 \u211a \u2192 \u211a\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := mk_pnat (n\u2081 * n\u2082) \u27e8d\u2081 * d\u2082, mul_pos h\u2081 h\u2082\u27e9\n\ninstance : has_mul \u211a := \u27e8rat.mul\u27e9\n\n@[simp] theorem mul_def {a b c d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 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\u20810 d\u20820 },\n  cc\nend\n\nprotected def inv : \u211a \u2192 \u211a\n| \u27e8(n+1:\u2115), d, h, c\u27e9 := \u27e8d, n+1, n.succ_pos, c.symm\u27e9\n| \u27e80, d, h, c\u27e9 := 0\n| \u27e8-[1+ n], d, h, c\u27e9 := \u27e8-d, n+1, n.succ_pos, nat.coprime.symm $ by simp; exact c\u27e9\n\ninstance : has_inv \u211a := \u27e8rat.inv\u27e9\n\n@[simp] theorem inv_def {a b : \u2124} : (a /. b)\u207b\u00b9 = 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 \u27e8n, d, h, c\u27e9 = d /. n) _,\n  { cases n with n; [cases n with n, skip],\n    { refl },\n    { change int.of_nat n.succ with (n+1:\u2115),\n      unfold rat.inv, rw num_denom' },\n    { unfold rat.inv, rw num_denom', refl } },\n  have n0 : n \u2260 0,\n  { refine mt (\u03bb (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 : \u211a)\n\nprotected theorem add_zero : a + 0 = a :=\nnum_denom_cases_on' a $ \u03bb n d h,\nby rw [\u2190 zero_mk d]; simp [h, -zero_mk]\n\nprotected theorem zero_add : 0 + a = a :=\nnum_denom_cases_on' a $ \u03bb n d h,\nby rw [\u2190 zero_mk d]; simp [h, -zero_mk]\n\nprotected theorem add_comm : a + b = b + a :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nby simp [h\u2081, h\u2082, mul_comm]\n\nprotected theorem add_assoc : a + b + c = a + (b + c) :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nnum_denom_cases_on' c $ \u03bb n\u2083 d\u2083 h\u2083,\nby simp [h\u2081, h\u2082, h\u2083, 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 $ \u03bb n d h,\nby simp [h]\n\nprotected theorem mul_one : a * 1 = a :=\nnum_denom_cases_on' a $ \u03bb n d h,\nby change (1:\u211a) with 1 /. 1; simp [h]\n\nprotected theorem one_mul : 1 * a = a :=\nnum_denom_cases_on' a $ \u03bb n d h,\nby change (1:\u211a) with 1 /. 1; simp [h]\n\nprotected theorem mul_comm : a * b = b * a :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nby simp [h\u2081, h\u2082, mul_comm]\n\nprotected theorem mul_assoc : a * b * c = a * (b * c) :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nnum_denom_cases_on' c $ \u03bb n\u2083 d\u2083 h\u2083,\nby simp [h\u2081, h\u2082, h\u2083, 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 $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nnum_denom_cases_on' c $ \u03bb n\u2083 d\u2083 h\u2083,\nby simp [h\u2081, h\u2082, h\u2083, mul_ne_zero];\n   refine (div_mk_div_cancel_left (int.coe_nat_ne_zero.2 h\u2083)).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 \u2260 (1:\u211a) :=\nmt (\u03bb (h : 0 = 1 /. 1), (mk_eq_zero one_ne_zero).1 h.symm) one_ne_zero\n\nprotected theorem mul_inv_cancel : a \u2260 0 \u2192 a * a\u207b\u00b9 = 1 :=\nnum_denom_cases_on' a $ \u03bb n d h a0,\nhave n0 : n \u2260 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 \u2260 0) : a\u207b\u00b9 * a = 1 :=\neq.trans (rat.mul_comm _ _) (rat.mul_inv_cancel _ h)\n\ninstance : decidable_eq \u211a := by tactic.mk_dec_eq_instance\n\ninstance : discrete_field \u211a :=\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 \u211a              := by apply_instance\ninstance : division_ring \u211a      := by apply_instance\ninstance : integral_domain \u211a    := by apply_instance\n-- TODO(Mario): this instance slows down data.real.basic\n--instance : domain \u211a           := by apply_instance\ninstance : nonzero_comm_ring \u211a  := by apply_instance\ninstance : comm_ring \u211a          := by apply_instance\n--instance : ring \u211a             := by apply_instance\ninstance : comm_semiring \u211a      := by apply_instance\ninstance : semiring \u211a           := by apply_instance\ninstance : add_comm_group \u211a     := by apply_instance\ninstance : add_group \u211a          := by apply_instance\ninstance : add_comm_monoid \u211a    := by apply_instance\ninstance : add_monoid \u211a         := by apply_instance\ninstance : add_left_cancel_semigroup \u211a := by apply_instance\ninstance : add_right_cancel_semigroup \u211a := by apply_instance\ninstance : add_comm_semigroup \u211a := by apply_instance\ninstance : add_semigroup \u211a      := by apply_instance\ninstance : comm_monoid \u211a        := by apply_instance\ninstance : monoid \u211a             := by apply_instance\ninstance : comm_semigroup \u211a     := by apply_instance\ninstance : semigroup \u211a          := by apply_instance\n\ntheorem sub_def {a b c d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 0) :\n  a /. b - c /. d = (a * d - c * b) /. (b * d) :=\nby simp [b0, d0]\n\nprotected def nonneg : \u211a \u2192 Prop\n| \u27e8n, d, h, c\u27e9 := n \u2265 0\n\n@[simp] theorem mk_nonneg (a : \u2124) {b : \u2124} (h : b > 0) : (a /. b).nonneg \u2194 a \u2265 0 :=\nbegin\n  generalize ha : a /. b = x, cases x with n\u2081 d\u2081 h\u2081 c\u2081, rw num_denom' at ha,\n  simp [rat.nonneg],\n  have d0 := int.coe_nat_lt.2 h\u2081,\n  have := (mk_eq (ne_of_gt h) (ne_of_gt d0)).1 ha,\n  constructor; intro h\u2082,\n  { apply nonneg_of_mul_nonneg_right _ d0,\n    rw this, exact mul_nonneg h\u2082 (le_of_lt h) },\n  { apply nonneg_of_mul_nonneg_right _ h,\n    rw \u2190 this, exact mul_nonneg h\u2082 (int.coe_zero_le _) },\nend\n\nprotected def nonneg_add {a b} : rat.nonneg a \u2192 rat.nonneg b \u2192 rat.nonneg (a + b) :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nbegin\n  have d\u20810 : (d\u2081:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h\u2081),\n  have d\u20820 : (d\u2082:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h\u2082),\n  simp [d\u20810, d\u20820, h\u2081, h\u2082, mul_pos d\u20810 d\u20820],\n  intros n\u20810 n\u20820,\n  apply add_nonneg; apply mul_nonneg; {assumption <|> apply int.coe_zero_le}\nend\n\nprotected def nonneg_mul {a b} : rat.nonneg a \u2192 rat.nonneg b \u2192 rat.nonneg (a * b) :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nbegin\n  have d\u20810 : (d\u2081:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h\u2081),\n  have d\u20820 : (d\u2082:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h\u2082),\n  simp [d\u20810, d\u20820, h\u2081, h\u2082, mul_pos d\u20810 d\u20820],\n  exact mul_nonneg\nend\n\nprotected def nonneg_antisymm {a} : rat.nonneg a \u2192 rat.nonneg (-a) \u2192 a = 0 :=\nnum_denom_cases_on' a $ \u03bb n d h,\nbegin\n  have d0 : (d:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h),\n  simp [d0, h],\n  exact \u03bb h\u2081 h\u2082, le_antisymm (nonpos_of_neg_nonneg h\u2082) h\u2081\nend\n\nprotected def nonneg_total : rat.nonneg a \u2228 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 : \u211a) := rat.nonneg (b - a)\n\ninstance : has_le \u211a := \u27e8rat.le\u27e9\n\ninstance decidable_le : decidable_rel ((\u2264) : \u211a \u2192 \u211a \u2192 Prop)\n| a b := show decidable (rat.nonneg (b - a)), by apply_instance\n\nprotected theorem le_def {a b c d : \u2124} (b0 : b > 0) (d0 : d > 0) :\n  a /. b \u2264 c /. d \u2194 a * d \u2264 c * b :=\nshow rat.nonneg _ \u2194 _,\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 \u2264 a :=\nshow rat.nonneg (a - a), by rw sub_self; exact le_refl (0 : \u2124)\n\nprotected theorem le_total : a \u2264 b \u2228 b \u2264 a :=\nby have := rat.nonneg_total (b - a); rwa neg_sub at this\n\nprotected theorem le_antisymm {a b : \u211a} (hab : a \u2264 b) (hba : b \u2264 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 : \u211a} (hab : a \u2264 b) (hbc : b \u2264 c) : a \u2264 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 \u211a :=\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 \u211a                  := by apply_instance\ninstance : lattice.distrib_lattice \u211a := by apply_instance\ninstance : lattice.lattice \u211a         := by apply_instance\ninstance : lattice.semilattice_inf \u211a := by apply_instance\ninstance : lattice.semilattice_sup \u211a := by apply_instance\ninstance : lattice.has_inf \u211a         := by apply_instance\ninstance : lattice.has_sup \u211a         := by apply_instance\ninstance : linear_order \u211a            := by apply_instance\ninstance : partial_order \u211a           := by apply_instance\ninstance : preorder \u211a                := by apply_instance\n\ntheorem nonneg_iff_zero_le {a} : rat.nonneg a \u2194 0 \u2264 a :=\nshow rat.nonneg a \u2194 rat.nonneg (a - 0), by simp\n\ntheorem num_nonneg_iff_zero_le : \u2200 {a : \u211a}, 0 \u2264 a.num \u2194 0 \u2264 a\n| \u27e8n, d, h, c\u27e9 := @nonneg_iff_zero_le \u27e8n, d, h, c\u27e9\n\ntheorem mk_le {a b c d : \u2124} (h\u2081 : b > 0) (h\u2082 : d > 0) :\n  a /. b \u2264 c /. d \u2194 a * d \u2264 c * b :=\nby conv in (_ \u2264 _) {\n  simp only [(\u2264), rat.le],\n  rw [sub_def (ne_of_gt h\u2082) (ne_of_gt h\u2081),\n      mk_nonneg _ (mul_pos h\u2082 h\u2081), ge, sub_nonneg] }\n\nprotected theorem add_le_add_left {a b c : \u211a} : c + a \u2264 c + b \u2194 a \u2264 b :=\nby unfold has_le.le rat.le; rw add_sub_add_left_eq_sub\n\nprotected theorem mul_nonneg {a b : \u211a} (ha : 0 \u2264 a) (hb : 0 \u2264 b) : 0 \u2264 a * b :=\nby rw \u2190 nonneg_iff_zero_le at ha hb \u22a2; exact rat.nonneg_mul ha hb\n\ninstance : discrete_linear_ordered_field \u211a :=\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 $ \u03bb 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 \u211a                := by apply_instance\ninstance : decidable_linear_ordered_comm_ring \u211a  := by apply_instance\ninstance : linear_ordered_comm_ring \u211a            := by apply_instance\ninstance : linear_ordered_ring \u211a                 := by apply_instance\ninstance : ordered_ring \u211a                        := by apply_instance\ninstance : decidable_linear_ordered_semiring \u211a   := by apply_instance\ninstance : linear_ordered_semiring \u211a             := by apply_instance\ninstance : ordered_semiring \u211a                    := by apply_instance\ninstance : decidable_linear_ordered_comm_group \u211a := by apply_instance\ninstance : ordered_comm_group \u211a                  := by apply_instance\ninstance : ordered_cancel_comm_monoid \u211a          := by apply_instance\ninstance : ordered_comm_monoid \u211a                 := by apply_instance\n\ntheorem num_pos_iff_pos {a : \u211a} : 0 < a.num \u2194 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 : \u2124) : of_int z = z /. 1 := num_denom' _ _ _ _\n\ntheorem coe_int_eq_mk : \u2200 z : \u2124, \u2191z = z /. 1\n| (n : \u2115) := show (n:\u211a) = n /. 1,\n  by induction n with n IH n; simp [*, show (1:\u211a) = 1 /. 1, from rfl]\n| -[1+ n] := show (-(n + 1) : \u211a) = -[1+ n] /. 1, begin\n  induction n with n IH, {refl},\n  show -(n + 1 + 1 : \u211a) = -[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 : \u2124) : \u2191z = of_int z :=\n(coe_int_eq_mk z).trans (of_int_eq_mk z).symm\n\ntheorem mk_eq_div (n d : \u2124) : n /. d = (n / d : \u211a) :=\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 \u2264 q` -/\ndef floor : \u211a \u2192 \u2124\n| \u27e8n, d, h, c\u27e9 := n / d\n\ntheorem le_floor {z : \u2124} : \u2200 {r : \u211a}, z \u2264 floor r \u2194 (z : \u211a) \u2264 r\n| \u27e8n, d, h, c\u27e9 := 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 : \u211a} {z : \u2124} : floor r < z \u2194 r < z :=\nle_iff_le_iff_lt_iff_lt.1 le_floor\n\ntheorem floor_le (r : \u211a) : (floor r : \u211a) \u2264 r :=\nle_floor.1 (le_refl _)\n\ntheorem lt_succ_floor (r : \u211a) : r < (floor r).succ :=\nfloor_lt.1 $ int.lt_succ_self _\n\n@[simp] theorem floor_coe (z : \u2124) : floor z = z :=\neq_of_forall_le_iff $ \u03bb a, by rw [le_floor, int.cast_le]\n\ntheorem floor_mono {a b : \u211a} (h : a \u2264 b) : floor a \u2264 floor b :=\nle_floor.2 (le_trans (floor_le _) h)\n\n@[simp] theorem floor_add_int (r : \u211a) (z : \u2124) : floor (r + z) = floor r + z :=\neq_of_forall_le_iff $ \u03bb a, by rw [le_floor,\n  \u2190 sub_le_iff_le_add, \u2190 sub_le_iff_le_add, le_floor, int.cast_sub]\n\ntheorem floor_sub_int (r : \u211a) (z : \u2124) : 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 \u2264 z` -/\ndef ceil (r : \u211a) : \u2124 :=\n-(floor (-r))\n\ntheorem ceil_le {z : \u2124} {r : \u211a} : ceil r \u2264 z \u2194 r \u2264 z :=\nby rw [ceil, neg_le, le_floor, int.cast_neg, neg_le_neg_iff]\n\ntheorem le_ceil (r : \u211a) : r \u2264 ceil r :=\nceil_le.1 (le_refl _)\n\n@[simp] theorem ceil_coe (z : \u2124) : ceil z = z :=\nby rw [ceil, \u2190 int.cast_neg, floor_coe, neg_neg]\n\ntheorem ceil_mono {a b : \u211a} (h : a \u2264 b) : ceil a \u2264 ceil b :=\nceil_le.2 (le_trans h (le_ceil _))\n\n@[simp] theorem ceil_add_int (r : \u211a) (z : \u2124) : 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 : \u211a) (z : \u2124) : 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 {\u03b1 : Type*}\n\nsection\nvariables [division_ring \u03b1]\n\n/-- Construct the canonical injection from `\u211a` 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 : \u211a \u2192 \u03b1\n| \u27e8n, d, h, c\u27e9 := n / d\n\n@[priority 0] instance cast_coe : has_coe \u211a \u03b1 := \u27e8rat.cast\u27e9\n\n@[simp] theorem cast_of_int (n : \u2124) : (of_int n : \u03b1) = n :=\nshow (n / (1:\u2115) : \u03b1) = n, by rw [nat.cast_one, div_one]\n\n@[simp] theorem cast_coe_int (n : \u2124) : ((n : \u211a) : \u03b1) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp] theorem coe_int_num (n : \u2124) : (n : \u211a).num = n :=\nby rw coe_int_eq_of_int; refl\n\n@[simp] theorem coe_int_denom (n : \u2124) : (n : \u211a).denom = 1 :=\nby rw coe_int_eq_of_int; refl\n\n@[simp] theorem coe_nat_num (n : \u2115) : (n : \u211a).num = n :=\nby rw [\u2190 int.cast_coe_nat, coe_int_num]\n\n@[simp] theorem coe_nat_denom (n : \u2115) : (n : \u211a).denom = 1 :=\nby rw [\u2190 int.cast_coe_nat, coe_int_denom]\n\n@[simp] theorem cast_coe_nat (n : \u2115) : ((n : \u211a) : \u03b1) = n := cast_coe_int n\n\n@[simp] theorem cast_zero : ((0 : \u211a) : \u03b1) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp] theorem cast_one : ((1 : \u211a) : \u03b1) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem mul_cast_comm (a : \u03b1) :\n  \u2200 (n : \u211a), (n.denom : \u03b1) \u2260 0 \u2192 a * n = n * a\n| \u27e8n, d, h, c\u27e9 h\u2082 := show a * (n * d\u207b\u00b9) = n * d\u207b\u00b9 * a,\n  by rw [\u2190 mul_assoc, int.mul_cast_comm, mul_assoc, mul_assoc,\n         \u2190 show (d:\u03b1)\u207b\u00b9 * a = a * d\u207b\u00b9, from\n           division_ring.inv_comm_of_comm h\u2082 (int.mul_cast_comm a d).symm]\n\ntheorem cast_mk_of_ne_zero (a b : \u2124)\n  (b0 : (b:\u03b1) \u2260 0) : (a /. b : \u03b1) = a / b :=\nbegin\n  have b0' : b \u2260 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:\u03b1) \u2260 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:\u2124) \u2223 b, by rwa e at dd) with k ke,\n    have : (b:\u03b1) = (d:\u03b1) * (k:\u03b1), {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 : \u2124 \u2192 \u03b1) ((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\u207b\u00b9 : \u03b1) = n / d,\n  rw [eq_div_iff_mul_eq _ _ d0, mul_assoc, nat.mul_cast_comm,\n      \u2190 mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\ntheorem cast_add_of_ne_zero : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m + n : \u211a) : \u03b1) = m + n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', add_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * (d\u2082 * (d\u2082\u207b\u00b9 * d\u2081\u207b\u00b9)) +\n    n\u2082 * (d\u2081 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9 : \u03b1) = n\u2081 * d\u2081\u207b\u00b9 + n\u2082 * d\u2082\u207b\u00b9,\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\u20810, d\u20820, division_ring.mul_ne_zero d\u20810 d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820, division_ring.mul_ne_zero d\u20810 d\u20820]} },\n  rw [\u2190 mul_assoc (d\u2082:\u03b1), mul_inv_cancel d\u20820, one_mul,\n      \u2190 nat.mul_cast_comm], simp [d\u20810, mul_assoc]\nend\n\n@[simp] theorem cast_neg : \u2200 n, ((-n : \u211a) : \u03b1) = -n\n| \u27e8n, d, h, c\u27e9 := show (\u2191-n * d\u207b\u00b9 : \u03b1) = -(n * d\u207b\u00b9),\n  by rw [int.cast_neg, neg_mul_eq_neg_mul]\n\ntheorem cast_sub_of_ne_zero {m n : \u211a}\n  (m0 : (m.denom : \u03b1) \u2260 0) (n0 : (n.denom : \u03b1) \u2260 0) : ((m - n : \u211a) : \u03b1) = m - n :=\nhave ((-n).denom : \u03b1) \u2260 0, by cases n; exact n0,\nby simp [m0, this, cast_add_of_ne_zero]\n\ntheorem cast_mul_of_ne_zero : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m * n : \u211a) : \u03b1) = m * n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', mul_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * ((n\u2082 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9) : \u03b1) = n\u2081 * (d\u2081\u207b\u00b9 * (n\u2082 * d\u2082\u207b\u00b9)),\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\u20810, d\u20820, division_ring.mul_ne_zero d\u20810 d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820, division_ring.mul_ne_zero d\u20810 d\u20820]} },\n  rw [division_ring.inv_comm_of_comm d\u20810 (nat.mul_cast_comm _ _).symm]\nend\n\ntheorem cast_inv_of_ne_zero : \u2200 {n : \u211a},\n  (n.num : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9\n| \u27e8n, d, h, c\u27e9 := \u03bb (n0 : (n:\u03b1) \u2260 0) (d0 : (d:\u03b1) \u2260 0), begin\n  have n0' : (n:\u2124) \u2260 0 := \u03bb e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb 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 : \u211a} (md : (m.denom : \u03b1) \u2260 0)\n  (nn : (n.num : \u03b1) \u2260 0) (nd : (n.denom : \u03b1) \u2260 0) : ((m / n : \u211a) : \u03b1) = m / n :=\nhave (n\u207b\u00b9.denom : \u2124) \u2223 n.num,\nby conv in n\u207b\u00b9.denom { rw [num_denom n, inv_def] };\n   apply denom_dvd,\nhave (n\u207b\u00b9.denom : \u03b1) = 0 \u2192 (n.num : \u03b1) = 0, from\n\u03bb h, let \u27e8k, e\u27e9 := this in\n  by have := congr_arg (coe : \u2124 \u2192 \u03b1) 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 \u03b1] : \u2200 {m n : \u211a}, (m : \u03b1) = n \u2194 m = n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := begin\n  refine \u27e8\u03bb h, _, congr_arg _\u27e9,\n  have d\u20810 : d\u2081 \u2260 0 := ne_of_gt h\u2081,\n  have d\u20820 : d\u2082 \u2260 0 := ne_of_gt h\u2082,\n  have d\u2081a : (d\u2081:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20810,\n  have d\u2082a : (d\u2082:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20820,\n  rw [num_denom', num_denom'] at h \u22a2,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d\u20810, d\u20820] at h \u22a2,\n  rwa [eq_div_iff_mul_eq _ _ d\u2082a, division_def, mul_assoc,\n    division_ring.inv_comm_of_comm d\u2081a (nat.mul_cast_comm _ _),\n    \u2190 mul_assoc, \u2190 division_def, eq_comm, eq_div_iff_mul_eq _ _ d\u2081a, eq_comm,\n    \u2190 int.cast_coe_nat, \u2190 int.cast_mul, \u2190 int.cast_coe_nat, \u2190 int.cast_mul,\n    int.cast_inj, \u2190 mk_eq (int.coe_nat_ne_zero.2 d\u20810) (int.coe_nat_ne_zero.2 d\u20820)] at h\nend\n\ntheorem cast_injective [char_zero \u03b1] : function.injective (coe : \u211a \u2192 \u03b1)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) = 0 \u2194 n = 0 :=\nby rw [\u2190 cast_zero, cast_inj]\n\n@[simp] theorem cast_ne_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) \u2260 0 \u2194 n \u2260 0 :=\nnot_congr cast_eq_zero\n\ntheorem eq_cast_of_ne_zero (f : \u211a \u2192 \u03b1) (H1 : f 1 = 1)\n  (Hadd : \u2200 x y, f (x + y) = f x + f y)\n  (Hmul : \u2200 x y, f (x * y) = f x * f y) :\n  \u2200 n : \u211a, (n.denom : \u03b1) \u2260 0 \u2192 f n = n\n| \u27e8n, d, h, c\u27e9 := \u03bb (h\u2082 : ((d:\u2124):\u03b1) \u2260 0), show _ = (n / (d:\u2124) : \u03b1), begin\n  rw [num_denom', mk_eq_div, eq_div_iff_mul_eq _ _ h\u2082],\n  have : \u2200 n : \u2124, f n = n, { apply int.eq_cast; simp [H1, Hadd] },\n  rw [\u2190 this, \u2190 this, \u2190 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 \u03b1] (f : \u211a \u2192 \u03b1) (H1 : f 1 = 1)\n  (Hadd : \u2200 x y, f (x + y) = f x + f y)\n  (Hmul : \u2200 x y, f (x * y) = f x * f y) (n : \u211a) : 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 \u03b1] [char_zero \u03b1] (a b : \u2124) : ((a /. b) : \u03b1) = 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 \u03b1] [char_zero \u03b1] (m n) : ((m + n : \u211a) : \u03b1) = 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 \u03b1] [char_zero \u03b1] (m n) : ((m - n : \u211a) : \u03b1) = 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 \u03b1] [char_zero \u03b1] (m n) : ((m * n : \u211a) : \u03b1) = 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 \u03b1] [char_zero \u03b1] (n) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\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 \u03b1] [char_zero \u03b1] (m n) : ((m / n : \u211a) : \u03b1) = m / n :=\nby rw [division_def, cast_mul, cast_inv, division_def]\n\n@[simp] theorem cast_bit0 [division_ring \u03b1] [char_zero \u03b1] (n : \u211a) : ((bit0 n : \u211a) : \u03b1) = bit0 n := cast_add _ _\n\n@[simp] theorem cast_bit1 [division_ring \u03b1] [char_zero \u03b1] (n : \u211a) : ((bit1 n : \u211a) : \u03b1) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\n@[simp] theorem cast_nonneg [linear_ordered_field \u03b1] : \u2200 {n : \u211a}, 0 \u2264 (n : \u03b1) \u2194 0 \u2264 n\n| \u27e8n, d, h, c\u27e9 := show 0 \u2264 (n * d\u207b\u00b9 : \u03b1) \u2194 0 \u2264 (\u27e8n, d, h, c\u27e9 : \u211a),\n  by rw [num_denom', \u2190 nonneg_iff_zero_le, mk_nonneg _ (int.coe_nat_pos.2 h),\n    mul_nonneg_iff_right_nonneg_of_pos (@inv_pos \u03b1 _ _ (nat.cast_pos.2 h)),\n    int.cast_nonneg]\n\n@[simp] theorem cast_le [linear_ordered_field \u03b1] {m n : \u211a} : (m : \u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw [\u2190 sub_nonneg, \u2190 cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp] theorem cast_lt [linear_ordered_field \u03b1] {m n : \u211a} : (m : \u03b1) < n \u2194 m < n :=\nby simpa [-cast_le] using not_congr (@cast_le \u03b1 _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) \u2264 0 \u2194 n \u2264 0 :=\nby rw [\u2190 cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field \u03b1] {n : \u211a} : (0 : \u03b1) < n \u2194 0 < n :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) < 0 \u2194 n < 0 :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp] theorem cast_id : \u2200 n : \u211a, \u2191n = n\n| \u27e8n, d, h, c\u27e9 := show (n / (d : \u2124) : \u211a) = _, by rw [num_denom', mk_eq_div]\n\n@[simp] theorem cast_min [discrete_linear_ordered_field \u03b1] {a b : \u211a} : (\u2191(min a b) : \u03b1) = min a b :=\nby by_cases a \u2264 b; simp [h, min]\n\n@[simp] theorem cast_max [discrete_linear_ordered_field \u03b1] {a b : \u211a} : (\u2191(max a b) : \u03b1) = max a b :=\nby by_cases a \u2264 b; simp [h, max]\n\n@[simp] theorem cast_abs [discrete_linear_ordered_field \u03b1] {q : \u211a} : ((abs q : \u211a) : \u03b1) = 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 \u2264 n`.\n  It is the same as `ceil q` when `q \u2265 0`, otherwise it is `0`. -/\ndef nat_ceil (q : \u211a) : \u2115 := int.to_nat (ceil q)\n\ntheorem nat_ceil_le {q : \u211a} {n : \u2115} : nat_ceil q \u2264 n \u2194 q \u2264 n :=\nby rw [nat_ceil, int.to_nat_le, ceil_le]; refl\n\ntheorem lt_nat_ceil {q : \u211a} {n : \u2115} : n < nat_ceil q \u2194 (n : \u211a) < q :=\nnot_iff_not.1 $ by rw [not_lt, not_lt, nat_ceil_le]\n\ntheorem le_nat_ceil (q : \u211a) : q \u2264 nat_ceil q :=\nnat_ceil_le.1 (le_refl _)\n\ntheorem nat_ceil_mono {q\u2081 q\u2082 : \u211a} (h : q\u2081 \u2264 q\u2082) : nat_ceil q\u2081 \u2264 nat_ceil q\u2082 :=\nnat_ceil_le.2 (le_trans h (le_nat_ceil _))\n\n@[simp] theorem nat_ceil_coe (n : \u2115) : nat_ceil n = n :=\nshow (ceil (n:\u2124)).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 : \u211a} (hq : 0 \u2264 q) (n : \u2115) : nat_ceil (q + n) = nat_ceil q + n :=\nshow int.to_nat (ceil (q + (n:\u2124))) = 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| _, \u27e8m, rfl\u27e9 := rfl\nend\n\ntheorem nat_ceil_lt_add_one {q : \u211a} (hq : q \u2265 0) : \u2191(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 : \u2200 q : \u211a, (-q).denom = q.denom\n| \u27e8_, d, _, _\u27e9 := rfl\n\n@[simp] lemma num_neg_eq_neg_num : \u2200 q : \u211a, (-q).num = -(q.num)\n| \u27e8n, _, _, _\u27e9 := rfl\n\n@[simp] lemma num_zero : rat.num 0 = 0 := rfl\n\nlemma zero_of_num_zero {q : \u211a} (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 : \u211a} (h : q \u2260 0) : q.num \u2260 0 :=\nassume : q.num = 0,\nh $ zero_of_num_zero this\n\nlemma denom_ne_zero (q : \u211a) : q.denom \u2260 0 :=\nne_of_gt q.pos\n\nlemma mk_num_ne_zero_of_ne_zero {q : \u211a} {n d : \u2124} (hq : q \u2260 0) (hqnd : q = n /. d) : n \u2260 0 :=\nassume : n = 0,\nhq $ by simpa [this] using hqnd\n\nlemma mk_denom_ne_zero_of_ne_zero {q : \u211a} {n d : \u2124} (hq : q \u2260 0) (hqnd : q = n /. d) : d \u2260 0 :=\nassume : d = 0,\nhq $ by simpa [this] using hqnd\n\nlemma mk_ne_zero_of_ne_zero {n d : \u2124} (h : n \u2260 0) (hd : d \u2260 0) : n /. d \u2260 0 :=\nassume : n /. d = 0,\nh $ (mk_eq_zero hd).1 this\n\nlemma mul_num_denom (q r : \u211a) : q * r = (q.num * r.num) /. \u2191(q.denom * r.denom) :=\nhave hq' : (\u2191q.denom : \u2124) \u2260 0, by have := denom_ne_zero q; simpa,\nhave hr' : (\u2191r.denom : \u2124) \u2260 0, by have := denom_ne_zero r; simpa,\nsuffices (q.num /. \u2191q.denom) * (r.num /. \u2191r.denom) = (q.num * r.num) /. \u2191(q.denom * r.denom),\n  by rwa [\u2190num_denom q, \u2190num_denom r] at this,\nby simp [mul_def hq' hr']\n\nlemma num_denom_mk {q : \u211a} {n d : \u2124} (hn : n \u2260 0) (hd : d \u2260 0) (qdf : q = n /. d) :\n      \u2203 c : \u2124, n = c * q.num \u2227 d = c * q.denom :=\nhave hq : q \u2260 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 [\u2190rat.num_denom q],\nhave q.num * d = n * \u2191(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 \u2223 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 \u03b1` is classically a nonempty `set \u03b1`,\n  and in the VM is represented by an element of `\u03b1`; 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 (\u03b1 : Type*) := mk' ::\n(s : set \u03b1)\n(val : trunc \u21a5s)\n\nnamespace semiquot\nvariables {\u03b1 : Type*} {\u03b2 : Type*}\n\ninstance : has_mem \u03b1 (semiquot \u03b1) := \u27e8\u03bb a q, a \u2208 q.s\u27e9\n\n/-- Construct a `semiquot \u03b1` from `h : a \u2208 s` where `s : set \u03b1`. -/\ndef mk {a : \u03b1} {s : set \u03b1} (h : a \u2208 s) : semiquot \u03b1 :=\n\u27e8s, trunc.mk \u27e8a, h\u27e9\u27e9\n\ntheorem ext_s {q\u2081 q\u2082 : semiquot \u03b1} : q\u2081 = q\u2082 \u2194 q\u2081.s = q\u2082.s :=\nbegin\n  refine \u27e8congr_arg _, \u03bb h, _\u27e9,\n  cases q\u2081,\n  cases q\u2082,\n  cc,\nend\n\ntheorem ext {q\u2081 q\u2082 : semiquot \u03b1} : q\u2081 = q\u2082 \u2194 \u2200 a, a \u2208 q\u2081 \u2194 a \u2208 q\u2082 :=\next_s.trans set.ext_iff\n\ntheorem exists_mem (q : semiquot \u03b1) : \u2203 a, a \u2208 q :=\nlet \u27e8\u27e8a, h\u27e9, h\u2082\u27e9 := q.2.exists_rep in \u27e8a, h\u27e9\n\ntheorem eq_mk_of_mem {q : semiquot \u03b1} {a : \u03b1} (h : a \u2208 q) :\n  q = @mk _ a q.1 h := ext_s.2 rfl\n\ntheorem nonempty (q : semiquot \u03b1) : q.s.nonempty := q.exists_mem\n\n/-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/\nprotected def pure (a : \u03b1) : semiquot \u03b1 := mk (set.mem_singleton a)\n\n@[simp] theorem mem_pure' {a b : \u03b1} : a \u2208 semiquot.pure b \u2194 a = b :=\nset.mem_singleton_iff\n\n/-- Replace `s` in a `semiquot` with a superset. -/\ndef blur' (q : semiquot \u03b1) {s : set \u03b1} (h : q.s \u2286 s) : semiquot \u03b1 :=\n\u27e8s, trunc.lift (\u03bb a : q.s, trunc.mk \u27e8a.1, h a.2\u27e9)\n  (\u03bb _ _, trunc.eq _ _) q.2\u27e9\n\n/-- Replace `s` in a `q : semiquot \u03b1` with a union `s \u222a q.s` -/\ndef blur (s : set \u03b1) (q : semiquot \u03b1) : semiquot \u03b1 :=\nblur' q (set.subset_union_right s q.s)\n\ntheorem blur_eq_blur' (q : semiquot \u03b1) (s : set \u03b1) (h : q.s \u2286 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 \u03b1) {s : set \u03b1} (h : q.s \u2286 s)\n  {a : \u03b1} : a \u2208 blur' q h \u2194 a \u2208 s := iff.rfl\n\n/-- Convert a `trunc \u03b1` to a `semiquot \u03b1`. -/\ndef of_trunc (q : trunc \u03b1) : semiquot \u03b1 :=\n\u27e8set.univ, q.map (\u03bb a, \u27e8a, trivial\u27e9)\u27e9\n\n/-- Convert a `semiquot \u03b1` to a `trunc \u03b1`. -/\ndef to_trunc (q : semiquot \u03b1) : trunc \u03b1 :=\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 \u03b1) (f : \u03b1 \u2192 \u03b2) (h : \u2200 a b \u2208 q, f a = f b) : \u03b2 :=\ntrunc.lift_on q.2 (\u03bb x, f x.1) (\u03bb x y, h _ x.2 _ y.2)\n\ntheorem lift_on_of_mem (q : semiquot \u03b1)\n  (f : \u03b1 \u2192 \u03b2) (h : \u2200 a b \u2208 q, f a = f b)\n  (a : \u03b1) (aq : a \u2208 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 \u03b1`. -/\ndef map (f : \u03b1 \u2192 \u03b2) (q : semiquot \u03b1) : semiquot \u03b2 :=\n\u27e8f '' q.1, q.2.map (\u03bb x, \u27e8f x.1, set.mem_image_of_mem _ x.2\u27e9)\u27e9\n\n@[simp] theorem mem_map (f : \u03b1 \u2192 \u03b2) (q : semiquot \u03b1) (b : \u03b2) :\n  b \u2208 map f q \u2194 \u2203 a, a \u2208 q \u2227 f a = b := set.mem_image _ _ _\n\n/-- Apply a function returning a `semiquot` to a `semiquot`. -/\ndef bind (q : semiquot \u03b1) (f : \u03b1 \u2192 semiquot \u03b2) : semiquot \u03b2 :=\n\u27e8\u22c3 a \u2208 q.1, (f a).1,\n q.2.bind (\u03bb a, (f a.1).2.map (\u03bb b, \u27e8b.1, set.mem_bUnion a.2 b.2\u27e9))\u27e9\n\n@[simp] theorem mem_bind (q : semiquot \u03b1) (f : \u03b1 \u2192 semiquot \u03b2) (b : \u03b2) :\n  b \u2208 bind q f \u2194 \u2203 a \u2208 q, b \u2208 f a := set.mem_Union\u2082\n\ninstance : monad semiquot :=\n{ pure := @semiquot.pure,\n  map := @semiquot.map,\n  bind := @semiquot.bind }\n\n@[simp] lemma map_def {\u03b2} : ((<$>) : (\u03b1 \u2192 \u03b2) \u2192 semiquot \u03b1 \u2192 semiquot \u03b2) = map := rfl\n@[simp] lemma bind_def {\u03b2} : ((>>=) : semiquot \u03b1 \u2192 (\u03b1 \u2192 semiquot \u03b2) \u2192 semiquot \u03b2) = bind := rfl\n\n@[simp] \n\ntheorem mem_pure_self (a : \u03b1) : a \u2208 (pure a : semiquot \u03b1) :=\nset.mem_singleton a\n\n@[simp] theorem pure_inj {a b : \u03b1} : (pure a : semiquot \u03b1) = pure b \u2194 a = b :=\next_s.trans set.singleton_eq_singleton_iff\n\ninstance : is_lawful_monad semiquot :=\n{ pure_bind  := \u03bb \u03b1 \u03b2 x f, ext.2 $ by simp,\n  bind_assoc := \u03bb \u03b1 \u03b2 \u03b3 s f g, ext.2 $ by simp; exact\n    \u03bb c, \u27e8\u03bb \u27e8b, \u27e8a, as, bf\u27e9, cg\u27e9, \u27e8a, as, b, bf, cg\u27e9,\n          \u03bb \u27e8a, as, b, bf, cg\u27e9, \u27e8b, \u27e8a, as, bf\u27e9, cg\u27e9\u27e9,\n  id_map     := \u03bb \u03b1 q, ext.2 $ by simp,\n  bind_pure_comp_eq_map := \u03bb \u03b1 \u03b2 f s, ext.2 $ by simp [eq_comm] }\n\ninstance : has_le (semiquot \u03b1) := \u27e8\u03bb s t, s.s \u2286 t.s\u27e9\n\ninstance : partial_order (semiquot \u03b1) :=\n{ le := \u03bb s t, \u2200 \u2983x\u2984, x \u2208 s \u2192 x \u2208 t,\n  le_refl := \u03bb s, set.subset.refl _,\n  le_trans := \u03bb s t u, set.subset.trans,\n  le_antisymm := \u03bb s t h\u2081 h\u2082, ext_s.2 (set.subset.antisymm h\u2081 h\u2082) }\n\ninstance : semilattice_sup (semiquot \u03b1) :=\n{ sup := \u03bb s, blur s.s,\n  le_sup_left := \u03bb s t, set.subset_union_left _ _,\n  le_sup_right := \u03bb s t, set.subset_union_right _ _,\n  sup_le := \u03bb s t u, set.union_subset,\n  ..semiquot.partial_order }\n\n@[simp] theorem pure_le {a : \u03b1} {s : semiquot \u03b1} : pure a \u2264 s \u2194 a \u2208 s :=\nset.singleton_subset_iff\n\n/-- Assert that a `semiquot` contains only one possible value. -/\ndef is_pure (q : semiquot \u03b1) : Prop := \u2200 a b \u2208 q, a = b\n\n/-- Extract the value from a `is_pure` semiquotient. -/\ndef get (q : semiquot \u03b1) (h : q.is_pure) : \u03b1 := lift_on q id h\n\ntheorem get_mem {q : semiquot \u03b1} (p) : get q p \u2208 q :=\nlet \u27e8a, h\u27e9 := exists_mem q in\nby unfold get; rw lift_on_of_mem q _ _ a h; exact h\n\ntheorem eq_pure {q : semiquot \u03b1} (p) : q = pure (get q p) :=\next.2 $ \u03bb a, by simp; exact\n\u27e8\u03bb h, p _ h _ (get_mem _), \u03bb e, e.symm \u25b8 get_mem _\u27e9\n\n@[simp] theorem pure_is_pure (a : \u03b1) : is_pure (pure a)\n| b ab c ac := by { rw [mem_pure] at ab ac, cc }\n\ntheorem is_pure_iff {s : semiquot \u03b1} : is_pure s \u2194 \u2203 a, s = pure a :=\n\u27e8\u03bb h, \u27e8_, eq_pure h\u27e9, \u03bb \u27e8a, e\u27e9, e.symm \u25b8 pure_is_pure _\u27e9\n\ntheorem is_pure.mono {s t : semiquot \u03b1}\n  (st : s \u2264 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 \u03b1} (h : is_pure t) : s \u2264 t \u2194 s = t :=\n\u27e8\u03bb 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\u27e9\n\ntheorem is_pure_of_subsingleton [subsingleton \u03b1] (q : semiquot \u03b1) : is_pure q\n| a b aq bq := subsingleton.elim _ _\n\n/-- `univ : semiquot \u03b1` represents an unspecified element of `univ : set \u03b1`. -/\ndef univ [inhabited \u03b1] : semiquot \u03b1 :=\nmk $ set.mem_univ default\n\ninstance [inhabited \u03b1] : inhabited (semiquot \u03b1) := \u27e8univ\u27e9\n\n@[simp] theorem mem_univ [inhabited \u03b1] : \u2200 a, a \u2208 @univ \u03b1 _ :=\n@set.mem_univ \u03b1\n\n@[congr] theorem univ_unique (I J : inhabited \u03b1) : @univ _ I = @univ _ J :=\next.2 $ by simp\n\n@[simp] theorem is_pure_univ [inhabited \u03b1] : @is_pure \u03b1 univ \u2194 subsingleton \u03b1 :=\n\u27e8\u03bb h, \u27e8\u03bb a b, h a trivial b trivial\u27e9, \u03bb \u27e8h\u27e9 a _ b _, h a b\u27e9\n\ninstance [inhabited \u03b1] : order_top (semiquot \u03b1) :=\n{ top := univ,\n  le_top := \u03bb 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 \u2133`: A typeclass to provide a constructive decomposition from\n  an additive monoid `M` into a family of additive submonoids `\u2133`\n* `direct_sum.decompose \u2133`: 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 {\u03b9 R M \u03c3 : Type _}\n\nopen DirectSum BigOperators\n\nnamespace DirectSum\n\nsection AddCommMonoid\n\nvariable [DecidableEq \u03b9] [AddCommMonoid M]\n\nvariable [SetLike \u03c3 M] [AddSubmonoidClass \u03c3 M] (\u2133 : \u03b9 \u2192 \u03c3)\n\n/-- A decomposition is an equivalence between an additive monoid `M` and a direct sum of additive\nsubmonoids `\u2133 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 \u2192 \u2a01 i, \u2133 i\n  left_inv : Function.LeftInverse (DirectSum.coeAddMonoidHom \u2133) decompose'\n  right_inv : Function.RightInverse (DirectSum.coeAddMonoidHom \u2133) 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 \u2133) :=\n  \u27e8fun 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\u27e9\n\nvariable [Decomposition \u2133]\n\nprotected theorem Decomposition.isInternal : DirectSum.IsInternal \u2133 :=\n  \u27e8Decomposition.right_inv.Injective, Decomposition.left_inv.Surjective\u27e9\n#align direct_sum.decomposition.is_internal DirectSum.Decomposition.isInternal\n\n/-- If `M` is graded by `\u03b9` with degree `i` component `\u2133 i`, then it is isomorphic as\nto a direct sum of components. This is the canonical spelling of the `decompose'` field. -/\ndef decompose : M \u2243 \u2a01 i, \u2133 i where\n  toFun := Decomposition.decompose'\n  invFun := DirectSum.coeAddMonoidHom \u2133\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 \u2192 Prop} (h_zero : p 0)\n    (h_homogeneous : \u2200 {i} (m : \u2133 i), p (m : M)) (h_add : \u2200 m m' : M, p m \u2192 p m' \u2192 p (m + m')) :\n    \u2200 m, p m :=\n  by\n  let \u2133' : \u03b9 \u2192 AddSubmonoid M := fun i =>\n    (\u27e8\u2133 i, fun _ _ => AddMemClass.add_mem, ZeroMemClass.zero_mem _\u27e9 : AddSubmonoid M)\n  haveI t : DirectSum.Decomposition \u2133' :=\n    { decompose' := DirectSum.decompose \u2133\n      left_inv := fun _ => (decompose \u2133).left_inv _\n      right_inv := fun _ => (decompose \u2133).right_inv _ }\n  have mem : \u2200 m, m \u2208 sup\u1d62 \u2133' := fun m =>\n    (DirectSum.IsInternal.addSubmonoid_sup\u1d62_eq_top \u2133' (decomposition.is_internal \u2133')).symm \u25b8 trivial\n  exact fun m =>\n    AddSubmonoid.sup\u1d62_induction \u2133' (mem m) (fun i m h => h_homogeneous \u27e8m, h\u27e9) h_zero h_add\n#align direct_sum.decomposition.induction_on DirectSum.Decomposition.inductionOn\n\n@[simp]\ntheorem Decomposition.decompose'_eq : Decomposition.decompose' = decompose \u2133 :=\n  rfl\n#align direct_sum.decomposition.decompose'_eq DirectSum.Decomposition.decompose'_eq\n\n@[simp]\ntheorem decompose_symm_of {i : \u03b9} (x : \u2133 i) : (decompose \u2133).symm (DirectSum.of _ i x) = x :=\n  DirectSum.coeAddMonoidHom_of \u2133 _ _\n#align direct_sum.decompose_symm_of DirectSum.decompose_symm_of\n\n@[simp]\ntheorem decompose_coe {i : \u03b9} (x : \u2133 i) : decompose \u2133 (x : M) = DirectSum.of _ i x := by\n  rw [\u2190 decompose_symm_of, Equiv.apply_symm_apply]\n#align direct_sum.decompose_coe DirectSum.decompose_coe\n\ntheorem decompose_of_mem {x : M} {i : \u03b9} (hx : x \u2208 \u2133 i) :\n    decompose \u2133 x = DirectSum.of (fun i => \u2133 i) i \u27e8x, hx\u27e9 :=\n  decompose_coe _ \u27e8x, hx\u27e9\n#align direct_sum.decompose_of_mem DirectSum.decompose_of_mem\n\ntheorem decompose_of_mem_same {x : M} {i : \u03b9} (hx : x \u2208 \u2133 i) : (decompose \u2133 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 : \u03b9} (hx : x \u2208 \u2133 i) (hij : i \u2260 j) :\n    (decompose \u2133 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 `\u03b9` with degree `i` component `\u2133 i`, then it is isomorphic as\nan additive monoid to a direct sum of components. -/\n@[simps (config := { fullyApplied := false })]\ndef decomposeAddEquiv : M \u2243+ \u2a01 i, \u2133 i :=\n  AddEquiv.symm { (decompose \u2133).symm with map_add' := map_add (DirectSum.coeAddMonoidHom \u2133) }\n#align direct_sum.decompose_add_equiv DirectSum.decomposeAddEquiv\n\n@[simp]\ntheorem decompose_zero : decompose \u2133 (0 : M) = 0 :=\n  map_zero (decomposeAddEquiv \u2133)\n#align direct_sum.decompose_zero DirectSum.decompose_zero\n\n@[simp]\ntheorem decompose_symm_zero : (decompose \u2133).symm 0 = (0 : M) :=\n  map_zero (decomposeAddEquiv \u2133).symm\n#align direct_sum.decompose_symm_zero DirectSum.decompose_symm_zero\n\n@[simp]\ntheorem decompose_add (x y : M) : decompose \u2133 (x + y) = decompose \u2133 x + decompose \u2133 y :=\n  map_add (decomposeAddEquiv \u2133) x y\n#align direct_sum.decompose_add DirectSum.decompose_add\n\n@[simp]\ntheorem decompose_symm_add (x y : \u2a01 i, \u2133 i) :\n    (decompose \u2133).symm (x + y) = (decompose \u2133).symm x + (decompose \u2133).symm y :=\n  map_add (decomposeAddEquiv \u2133).symm x y\n#align direct_sum.decompose_symm_add DirectSum.decompose_symm_add\n\n@[simp]\ntheorem decompose_sum {\u03b9'} (s : Finset \u03b9') (f : \u03b9' \u2192 M) :\n    decompose \u2133 (\u2211 i in s, f i) = \u2211 i in s, decompose \u2133 (f i) :=\n  map_sum (decomposeAddEquiv \u2133) f s\n#align direct_sum.decompose_sum DirectSum.decompose_sum\n\n@[simp]\ntheorem decompose_symm_sum {\u03b9'} (s : Finset \u03b9') (f : \u03b9' \u2192 \u2a01 i, \u2133 i) :\n    (decompose \u2133).symm (\u2211 i in s, f i) = \u2211 i in s, (decompose \u2133).symm (f i) :=\n  map_sum (decomposeAddEquiv \u2133).symm f s\n#align direct_sum.decompose_symm_sum DirectSum.decompose_symm_sum\n\ntheorem sum_support_decompose [\u2200 (i) (x : \u2133 i), Decidable (x \u2260 0)] (r : M) :\n    (\u2211 i in (decompose \u2133 r).support, (decompose \u2133 r i : M)) = r :=\n  by\n  conv_rhs =>\n    rw [\u2190 (decompose \u2133).symm_apply_apply r, \u2190 sum_support_of (fun i => \u2133 i) (decompose \u2133 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 (\u2a01 i, \u2133 i) (decompose \u2133 (-x)) (-decompose \u2133 x)`\ninstead of `decompose \u2133 (-x) = -decompose \u2133 x`, which forces the typeclasses needed by `\u2a01 i, \u2133 i` to\nbe found by unification rather than synthesis, then everything works fine without this instance. -/\ninstance addCommGroupSetLike [AddCommGroup M] [SetLike \u03c3 M] [AddSubgroupClass \u03c3 M] (\u2133 : \u03b9 \u2192 \u03c3) :\n    AddCommGroup (\u2a01 i, \u2133 i) := by infer_instance\n#align direct_sum.add_comm_group_set_like DirectSum.addCommGroupSetLike\n\nsection AddCommGroup\n\nvariable [DecidableEq \u03b9] [AddCommGroup M]\n\nvariable [SetLike \u03c3 M] [AddSubgroupClass \u03c3 M] (\u2133 : \u03b9 \u2192 \u03c3)\n\nvariable [Decomposition \u2133]\n\ninclude M\n\n@[simp]\ntheorem decompose_neg (x : M) : decompose \u2133 (-x) = -decompose \u2133 x :=\n  map_neg (decomposeAddEquiv \u2133) x\n#align direct_sum.decompose_neg DirectSum.decompose_neg\n\n@[simp]\ntheorem decompose_symm_neg (x : \u2a01 i, \u2133 i) : (decompose \u2133).symm (-x) = -(decompose \u2133).symm x :=\n  map_neg (decomposeAddEquiv \u2133).symm x\n#align direct_sum.decompose_symm_neg DirectSum.decompose_symm_neg\n\n@[simp]\ntheorem decompose_sub (x y : M) : decompose \u2133 (x - y) = decompose \u2133 x - decompose \u2133 y :=\n  map_sub (decomposeAddEquiv \u2133) x y\n#align direct_sum.decompose_sub DirectSum.decompose_sub\n\n@[simp]\ntheorem decompose_symm_sub (x y : \u2a01 i, \u2133 i) :\n    (decompose \u2133).symm (x - y) = (decompose \u2133).symm x - (decompose \u2133).symm y :=\n  map_sub (decomposeAddEquiv \u2133).symm x y\n#align direct_sum.decompose_symm_sub DirectSum.decompose_symm_sub\n\nend AddCommGroup\n\nsection Module\n\nvariable [DecidableEq \u03b9] [Semiring R] [AddCommMonoid M] [Module R M]\n\nvariable (\u2133 : \u03b9 \u2192 Submodule R M)\n\nvariable [Decomposition \u2133]\n\ninclude M\n\n/-- If `M` is graded by `\u03b9` with degree `i` component `\u2133 i`, then it is isomorphic as\na module to a direct sum of components. -/\n@[simps (config := { fullyApplied := false })]\ndef decomposeLinearEquiv : M \u2243\u2097[R] \u2a01 i, \u2133 i :=\n  LinearEquiv.symm\n    { (decomposeAddEquiv \u2133).symm with map_smul' := map_smul (DirectSum.coeLinearMap \u2133) }\n#align direct_sum.decompose_linear_equiv DirectSum.decomposeLinearEquiv\n\n@[simp]\ntheorem decompose_smul (r : R) (x : M) : decompose \u2133 (r \u2022 x) = r \u2022 decompose \u2133 x :=\n  map_smul (decomposeLinearEquiv \u2133) 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 \u2192 Data)\n(combine_data : Data -> Data \u2192 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 : \u2115) :=\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 : \u2115) :=\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:\u2115} (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 : \u2115)\n: path.leaf \u2218 @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 : \u2115}\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 : \u2115) (l : Link)\n: path.leaf \u2218 @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     : \u03a0 (n : \u2115) (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 : \u2115 \u2192 Leaf \u2192 list Leaf \u2192 Prop}\n  (n : \u2115) (e : Leaf) (l : list Leaf)\n  (base : \u2200 (e:Leaf) (l:list Leaf), P 0 e l)\n  (ind1 : \u2200 (n:\u2115) (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 : \u2200 (n:\u2115) (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 :\u2115) (e : Leaf) (l : list Leaf)\n\ntheorem merkle_core_paths_ne : (merkle_core n e l).paths \u2260 [] :=\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:\u2115) (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:\u2115) (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     : \u03a0 (n : \u2115) (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 : \u2115) (l : list Leaf)\n\ntheorem merkle_paths_ne (pr : l \u2260 []) : (merkle n l).paths \u2260 [] :=\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:\u2115) (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:\u2115} {l : list Leaf}\n   {idx : \u2115}\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 \u2192 set atom\n\nstructure sig_bounds :=\n(lower : sig_bound)\n(upper : sig_bound)\n\ndef rel_bound := relation \u2192 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 \u2192 inst \u2192 inst\n| sig_in_atoms : sig \u2192 set atom \u2192 inst\n| atoms_in_sig : set atom \u2192 sig \u2192 inst\n| rel_in_atoms : relation \u2192 set (list atom) \u2192 inst\n| atoms_in_rel : set (list atom) \u2192 relation \u2192 inst\n\ndef refine_bounds [decidable_eq sig] [decidable_eq relation] : inst \u2192 all_bounds \u2192 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      \u03bb(s : sig),\n        if s = s1 then\n          atoms \u2229 (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      \u03bb(s : sig),\n        if s = s1 then\n          atoms \u222a (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      \u03bb(r : relation),\n        if r = r1 then\n          atoms \u2229 (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      \u03bb(r : relation),\n        if r = r1 then\n          atoms \u222a (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 \u2286 upper) \u2194\n    ((refine_bounds (inst.and (inst.sig_in_atoms s1 upper) (inst.atoms_in_sig lower s1))\n                       (all_bounds.mk (sig_bounds.mk (\u03bbx, \u2205) (\u03bbx, set.univ))\n                                      (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, set.univ)))).sigs.lower s1)\n        \u2286\n       ((refine_bounds (inst.and (inst.sig_in_atoms s1 upper) (inst.atoms_in_sig lower s1))\n                       (all_bounds.mk (sig_bounds.mk (\u03bbx, \u2205) (\u03bbx, set.univ))\n                                      (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, 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 (\u03bbx, \u2205) (\u03bbx, set.univ))\n                                      (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, set.univ)))).sigs.lower s1 :=\n      begin\n         calc lower\n             = (\u03bb(s : sig), if s = s1 then (lower \u222a \u2205) else \u2205) s1 :\n          by simp\n        ... = (sig_bounds.mk (\u03bb(s : sig), if s = s1 then (lower \u222a \u2205) else \u2205)\n                             (\u03bb(s : sig), if s = s1 then (upper \u2229 set.univ) else set.univ)).lower s1 :\n          by simp\n         ... = (all_bounds.mk (sig_bounds.mk (\u03bb(s : sig), if s = s1 then (lower \u222a \u2205) else \u2205)\n                                             (\u03bb(s : sig), if s = s1 then (upper \u2229 set.univ) else set.univ))\n                              (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, 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 (\u03bbx, \u2205) (\u03bbx, set.univ))\n                                      (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, 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 (\u03bbx, \u2205) (\u03bbx, set.univ))\n                                      (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, set.univ)))).sigs.upper s1 :=\n      begin\n         calc upper\n             = (\u03bb(s : sig), if s = s1 then (upper \u2229 set.univ) else set.univ) s1 :\n          by simp\n        ... = (sig_bounds.mk (\u03bb(s : sig), if s = s1 then (lower \u222a \u2205) else \u2205)\n                             (\u03bb(s : sig), if s = s1 then (upper \u2229 set.univ) else set.univ)).upper s1 :\n          by simp\n         ... = (all_bounds.mk (sig_bounds.mk (\u03bb(s : sig), if s = s1 then (lower \u222a \u2205) else \u2205)\n                                             (\u03bb(s : sig), if s = s1 then (upper \u2229 set.univ) else set.univ))\n                              (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, 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 (\u03bbx, \u2205) (\u03bbx, set.univ))\n                                      (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, 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 \u2208 lower :=\n      by cc,\n    apply hlsubu,\n    exact hboundeltlower, },\n  { rw \u2190hupper,\n    rw \u2190hlower,\n    intro hlu,\n    exact hlu, },\nend\n\ndef new_bounds : all_bounds :=\n(all_bounds.mk (sig_bounds.mk (\u03bbx, \u2205) (\u03bbx, set.univ))\n               (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, 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 (\u03bbx, \u2205) (\u03bb(s : sig), if s = x then set.univ \u2229 x_1 else set.univ))\n                                          (rel_bounds.mk (\u03bbx, \u2205) (\u03bbx, 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 = \u27e8a.val - b.val\u27e9 := rfl\n\n      lemma mul_def (a b : $typeName) : a * b = \u27e8a.val * b.val\u27e9 := rfl\n\n      lemma mod_def (a b : $typeName) : a % b = \u27e8a.val % b.val\u27e9 := rfl\n\n      lemma add_def (a b : $typeName) : a + b = \u27e8a.val + b.val\u27e9 := rfl\n\n      lemma eq_of_val_eq : \u2200 {a b : $typeName}, a.val = b.val -> a = b\n      | \u27e8f1\u27e9, \u27e8f2\u27e9, h => congrArg mk h\n\n      lemma val_eq_of_eq : \u2200 {a b : $typeName}, a = b -> a.val = b.val\n      | \u27e8f1\u27e9, \u27e8f2\u27e9, h => congrArg val h\n\n      @[simp] lemma mk_val_eq : \u2200 (a : $typeName), mk a.val = a\n      | \u27e8a, _\u27e9 => rfl\n\n      lemma zero_def : (0 : $typeName) = \u27e80\u27e9 := rfl\n\n      lemma neg_def (a : $typeName) : -a = \u27e8-a.val\u27e9 := rfl\n\n      lemma one_def : (1 : $typeName) = \u27e81\u27e9 := 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 := \u27e8AddMonoid.nsmul n a.val\u27e9\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 := \u27e8n\u27e9\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 := \u27e8n\u27e9\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 \u2265 65 && c \u2264 90\n\n/-- Is this a lowercase ASCII letter? -/\ndef isLower (c : UInt8) : Bool :=\n  c \u2265 97 && c \u2264 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 \u2265 48 && c \u2264 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 := \u27e8n.toUInt32, toChar_aux n.1 n.1.2\u27e9\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 (\u03c4\u209b.w (t+1)) = this value, then \u03c4\u209b.upper = \u03c4\u2081.upper\ndef track (\u03c4\u2081 \u03c4\u2082 : Trace) (wst_cur : \u211a) (t : \u2115) : \u211a :=\n  let wst := \u03c4\u2081.wst (t+1) - (\u03c4\u2081.C - \u03c4\u2082.C) * \u2191t 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 \u03c4\u209b.w\ndef wst_compose (\u03c4\u2081 \u03c4\u2082 : Trace) : \u2115 \u2192 (\u211a \u00d7 WstState)\n  | 0 := (0, WstState.Tracking)\n  | (nat.succ t) :=\n    let \u27e8wst, s\u27e9 := (wst_compose t) in\n    match s with\n    | WstState.Tracking :=\n      if \u03c4\u2081.lower (1 + t) \u2265 \u03c4\u2082.upper 1 + t\n      then (wst, WstState.NoWst)\n      else (track \u03c4\u2081 \u03c4\u2082 wst t, WstState.Tracking)\n    | WstState.NoWst :=\n      if \u03c4\u2082.C * \u2191t - wst + \u03c4\u2082.C \u2265 \u03c4\u2081.upper (1 + t)\n      then (track \u03c4\u2081 \u03c4\u2082 wst t, WstState.Tracking)\n      else (wst, WstState.NoWst)\n    end\n\nset_option trace.check true\ntheorem trace_composes_\u03c4\u2081_ge_\u03c4\u2082 :\n    \u2200(\u03c4\u2081 \u03c4\u2082 : Trace),\n        \u03c4\u2081.C \u2265 \u03c4\u2082.C \u2227\n        \u03c4\u2081.out = \u03c4\u2082.inp \u2227\n        (\u2200t, \u03c4\u2081.los t = 0 \u2227 \u03c4\u2082.los t = 0)\n    \u2192 \u2203(\u03c4\u209b : Trace),\n        \u03c4\u209b.C = \u03c4\u2081.C \u2227\n        \u03c4\u209b.D = \u03c4\u2081.D + \u03c4\u2082.D \u2227\n        \u03c4\u209b.inp = \u03c4\u2081.inp \u2227\n        \u03c4\u209b.out = \u03c4\u2082.out \u2227\n        \u2200 t, \u03c4\u209b.los t = \u03c4\u2081.los t + \u03c4\u2082.los t :=\nbegin\n  intros \u03c4\u2081 \u03c4\u2082 h, cases h with hc h, cases h with h\u2081\u2082 h_los,\n\n  -- We will set \u03c4\u209b.wst to wst_compose\n  -- generalize h : w = \u03bb t, (waste_compose \u03c4\u2081 \u03c4\u2082 t),\n  -- have h : \u2115 \u2192 (\u211a \u00d7 WstState) := (\u03bb t, (wst_compose \u03c4\u2081 \u03c4\u2082 t)),\n  generalize h_wst\u209b : (wst_compose \u03c4\u2081 \u03c4\u2082) = wst\u209b,\n\n  -- Whenever waste happens, it is allowed\n  have h_cond_waste : \u2200t, (wst\u209b (1 + t)).1 > (wst\u209b t).1 \u2192\n    \u03c4\u2081.inp (1 + t) \u2264 \u03c4\u2082.C * (1 + t) - (wst\u209b (1 + t)).1 :=\n  begin\n    intros t h_inc,\n    induction t,\n    {\n      simp, rw <- h_wst\u209b, unfold wst_compose,\n      by_cases h_cond : ((Trace.lower \u03c4\u2081 (1 + 0) \u2265 Trace.upper \u03c4\u2082 1 + \u21910)) = 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\u209b 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  \u03a0 (m : env) (nodes : list node) (tgt : reference),\n  well_formed_at costs nodes m tgt \u2192\n  grads_exist_at nodes m tgt \u2192\n  pdfs_exist_at nodes m \u2192\n  is_gdifferentiable (\u03bb m, \u27e6sum_costs m costs\u27e7) tgt m nodes dvec.head \u2192\n  can_differentiate_under_integrals costs nodes m tgt \u2192\n\n  is_gintegrable (\u03bb m, \u27e6compute_grad_slow costs nodes m tgt\u27e7) m nodes dvec.head \u2192 is_nabla_gintegrable (\u03bb m, \u27e6sum_costs m costs\u27e7) 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 (\u27e8ref, parents, operator.det op\u27e9 :: 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 \u2209 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 \u2227 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 := \u27e8in_riota_lt H_idx_in_riota, H_tgt_eq_dnth_idx\u27e9,\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 \u2208 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 (\u03bb m, \u27e6compute_grad_slow costs nodes m ref\u27e7) next_inputs nodes dvec.head,\nbegin\nassertv H_op_called : is_gintegrable (\u03bb m, \u27e6det.op.pb op (env.get_ks parents m) (env.get ref m) (compute_grad_slow costs nodes m ref) idx (tgt.snd)\u27e7)\n                                    next_inputs nodes dvec.head :=\n  is_gintegrable_of_sumr_map (\u03bb 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 (\u03bb m, \u27e6det.op.pb op (env.get_ks parents next_inputs) x (compute_grad_slow costs nodes m ref) idx (tgt.snd)\u27e7)\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 [\u03bb (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 (\u27e8ref, parents, operator.rand op\u27e9 :: nodes) tgt H_wf H_gs_exist H_pdfs_exist H_gdiff H_diff_under_int H_gint :=\nlet \u03b8 := env.get tgt inputs in\nlet next_inputs := \u03bb (y : T ref.2), env.insert ref y inputs in\nhave H_ref_in_refs : ref \u2208 ref :: map node.ref nodes, from mem_of_cons_same,\nhave H_ref_notin_parents : ref \u2209 parents, from ref_notin_parents H_wf^.ps_in_env H_wf^.uids,\nhave H_tgt_neq_ref : tgt \u2260 ref, from ref_ne_tgt H_wf^.m_contains_tgt H_wf^.uids,\n\nhave H_wfs : \u2200 y, well_formed_at costs nodes (next_inputs y) tgt \u2227 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 : \u2200 x,\nE (graph.to_dist (\u03bb (m : env), \u27e6compute_grad_slow costs nodes m tgt\u27e7)\n                 (env.insert ref x inputs) nodes)\n  dvec.head\n=\n\u2207 (\u03bb (\u03b8\u2080 : T (tgt.snd)),\n     E (graph.to_dist (\u03bb (m : env), \u27e6sum_costs m costs\u27e7)\n                      (env.insert ref x (env.insert tgt \u03b8\u2080 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 [(\u03bb (\u03b8\u2080 : T tgt.2), env.insert_insert_flip \u03b8\u2080 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 [\u03bb 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 : \u2200 y,\nmap\n            (\u03bb (idx : \u2115),\n               E\n                 (graph.to_dist\n                    (\u03bb (m : env), \u27e6sum_costs m costs\u27e7)\n                    (env.insert ref y inputs)\n                    nodes)\n                 dvec.head \u2b1d \u2207\n                 (\u03bb (\u03b8\u2080 : T (tgt.snd)), T.log (rand.op.pdf op (dvec.update_at \u03b8\u2080 (env.get_ks parents inputs) idx) y))\n                 (env.get tgt inputs))\n            (filter (\u03bb (idx : \u2115), tgt = dnth parents idx) (riota (length parents)))\n=\nmap\n    (\u03bb (idx : \u2115),\n       E\n         (graph.to_dist\n            (\u03bb (m : env),\n               \u27e6sum_downstream_costs nodes costs ref m \u2b1d rand.op.glogpdf op (env.get_ks parents m) (env.get ref m)\n                    idx\n                    (tgt.snd)\u27e7)\n            (env.insert ref y inputs)\n            nodes)\n         dvec.head)\n    (filter (\u03bb (idx : \u2115), 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 : \u2200 y,\nsumr\n         (map\n            (\u03bb (idx : \u2115),\n               E\n                 (graph.to_dist\n                    (\u03bb (m : env),\n                       \u27e6sum_downstream_costs nodes costs ref m \u2b1d rand.op.glogpdf op (env.get_ks parents m) (env.get ref m) idx (tgt.snd)\u27e7)\n                    (env.insert ref y inputs)\n                    nodes)\n                 dvec.head)\n            (filter (\u03bb (idx : \u2115), tgt = dnth parents idx) (riota (length parents))))\n=\nE (graph.to_dist (\u03bb (m : env),\n                    \u27e6sumr (map (\u03bb (idx : \u2115), sum_downstream_costs nodes costs ref m \u2b1d rand.op.glogpdf op (env.get_ks parents m) (env.get ref m) idx (tgt.snd))\n                               (filter (\u03bb (idx : \u2115), tgt = dnth parents idx) (riota (length parents))))\u27e7)\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\u00e9my Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: R\u00e9my 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 `\ud835\udd5c` (`\u211d` or `\u2102`), then `Lp E 2 \u03bc` (defined in `lp_space.lean`)\nis also an inner product space, with inner product defined as `inner f g = \u222b a, \u27eaf a, g a\u27eb \u2202\u03bc`.\n\n### Main results\n\n* `mem_L1_inner` : for `f` and `g` in `Lp E 2 \u03bc`, the pointwise inner product `\u03bb x, \u27eaf x, g x\u27eb`\n  belongs to `Lp \ud835\udd5c 1 \u03bc`.\n* `integrable_inner` : for `f` and `g` in `Lp E 2 \u03bc`, the pointwise inner product `\u03bb x, \u27eaf x, g x\u27eb`\n  is integrable.\n* `L2.inner_product_space` : `Lp E 2 \u03bc` 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 {\u03b1 F : Type*} {m : measurable_space \u03b1} {\u03bc : measure \u03b1} [normed_group F]\n\nlemma mem_\u2112p.integrable_sq {f : \u03b1 \u2192 \u211d} (h : mem_\u2112p f 2 \u03bc) :\n  integrable (\u03bb x, (f x)^2) \u03bc :=\nby simpa [\u2190 mem_\u2112p_one_iff_integrable]\n  using h.norm_rpow ennreal.two_ne_zero ennreal.two_ne_top\n\nlemma mem_\u2112p_two_iff_integrable_sq_norm {f : \u03b1 \u2192 F} (hf : ae_strongly_measurable f \u03bc) :\n  mem_\u2112p f 2 \u03bc \u2194 integrable (\u03bb x, \u2225f x\u2225^2) \u03bc :=\nbegin\n  rw \u2190 mem_\u2112p_one_iff_integrable,\n  convert (mem_\u2112p_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_\u2112p_two_iff_integrable_sq {f : \u03b1 \u2192 \u211d} (hf : ae_strongly_measurable f \u03bc) :\n  mem_\u2112p f 2 \u03bc \u2194 integrable (\u03bb x, (f x)^2) \u03bc :=\nbegin\n  convert mem_\u2112p_two_iff_integrable_sq_norm hf,\n  ext x,\n  simp,\nend\n\nend\n\nnamespace L2\n\nvariables {\u03b1 E F \ud835\udd5c : Type*} [is_R_or_C \ud835\udd5c] [measurable_space \u03b1] {\u03bc : measure \u03b1}\n  [inner_product_space \ud835\udd5c E] [normed_group F]\n\n\nlocal notation `\u27ea`x`, `y`\u27eb` := @inner \ud835\udd5c _ _ x y\n\nlemma snorm_rpow_two_norm_lt_top (f : Lp F 2 \u03bc) : snorm (\u03bb x, \u2225f x\u2225 ^ (2 : \u211d)) 1 \u03bc < \u221e :=\nbegin\n  have h_two : ennreal.of_real (2 : \u211d) = 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 : \u03b1 \u2192\u2082[\u03bc] E) : snorm (\u03bb (x : \u03b1), \u27eaf x, g x\u27eb) 1 \u03bc < \u221e :=\nbegin\n  have h : \u2200 x, is_R_or_C.abs \u27eaf x, g x\u27eb \u2264 \u2225f x\u2225 * \u2225g x\u2225, from \u03bb x, abs_inner_le_norm _ _,\n  have h' : \u2200 x, is_R_or_C.abs \u27eaf x, g x\u27eb \u2264 is_R_or_C.abs (\u2225f x\u2225^2 + \u2225g x\u2225^2),\n  { refine \u03bb 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 \u211d _ _)).mpr ((le_of_eq _).trans (two_mul_le_add_sq _ _)),\n    ring, },\n  simp_rw [\u2190 is_R_or_C.norm_eq_abs, \u2190 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 \u27e8snorm_rpow_two_norm_lt_top f, snorm_rpow_two_norm_lt_top g\u27e9,\nend\n\nsection inner_product_space\nopen_locale complex_conjugate\n\ninclude \ud835\udd5c\n\ninstance : has_inner \ud835\udd5c (\u03b1 \u2192\u2082[\u03bc] E) := \u27e8\u03bb f g, \u222b a, \u27eaf a, g a\u27eb \u2202\u03bc\u27e9\n\nlemma inner_def (f g : \u03b1 \u2192\u2082[\u03bc] E) : \u27eaf, g\u27eb = \u222b a : \u03b1, \u27eaf a, g a\u27eb \u2202\u03bc := rfl\n\nlemma integral_inner_eq_sq_snorm (f : \u03b1 \u2192\u2082[\u03bc] E) :\n  \u222b a, \u27eaf a, f a\u27eb \u2202\u03bc = ennreal.to_real \u222b\u207b a, (\u2225f a\u2225\u208a : \u211d\u22650\u221e) ^ (2:\u211d) \u2202\u03bc :=\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 (\u03bb 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 : \u211d) = ((2 : \u2115) : \u211d), by simp,\n  rw [\u2190 real.rpow_nat_cast _ 2, \u2190 h_two,\n    \u2190 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 : \u03b1 \u2192\u2082[\u03bc] E) : \u2225f\u2225 ^ 2 = is_R_or_C.re \u27eaf, f\u27eb :=\nbegin\n  have h_two : (2 : \u211d\u22650\u221e).to_real = 2 := by simp,\n  rw [inner_def, integral_inner_eq_sq_snorm, norm_def, \u2190 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 [\u2190ennreal.rpow_nat_cast, snorm_eq_snorm' ennreal.two_ne_zero ennreal.two_ne_top, snorm',\n      \u2190 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 [\u2190 h_two, \u2190 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 : \u03b1 \u2192\u2082[\u03bc] E) :\n  ae_eq_fun.mk (\u03bb x, \u27eaf x, g x\u27eb)\n    ((Lp.ae_strongly_measurable f).inner (Lp.ae_strongly_measurable g)) \u2208 Lp \ud835\udd5c 1 \u03bc :=\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 : \u03b1 \u2192\u2082[\u03bc] E) : integrable (\u03bb x : \u03b1, \u27eaf x, g x\u27eb) \u03bc :=\n(integrable_congr (ae_eq_fun.coe_fn_mk (\u03bb x, \u27eaf x, g x\u27eb)\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 : \u03b1 \u2192\u2082[\u03bc] E) : \u27eaf + f', g\u27eb = inner f g + inner f' g :=\nbegin\n  simp_rw [inner_def, \u2190 integral_add (integrable_inner f g) (integrable_inner f' g),\n    \u2190inner_add_left],\n  refine integral_congr_ae ((coe_fn_add f f').mono (\u03bb x hx, _)),\n  congr,\n  rwa pi.add_apply at hx,\nend\n\nprivate lemma smul_left' (f g : \u03b1 \u2192\u2082[\u03bc] E) (r : \ud835\udd5c) :\n  \u27ear \u2022 f, g\u27eb = conj r * inner f g :=\nbegin\n  rw [inner_def, inner_def, \u2190 smul_eq_mul, \u2190 integral_smul],\n  refine integral_congr_ae ((coe_fn_smul r f).mono (\u03bb x hx, _)),\n  rw [smul_eq_mul, \u2190 inner_smul_left],\n  congr,\n  rwa pi.smul_apply at hx,\nend\n\ninstance inner_product_space : inner_product_space \ud835\udd5c (\u03b1 \u2192\u2082[\u03bc] E) :=\n{ norm_sq_eq_inner := norm_sq_eq_inner',\n  conj_sym := \u03bb _ _, by simp_rw [inner_def, \u2190 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 (\ud835\udd5c) {s : set \u03b1}\n\n/-- The inner product in `L2` of the indicator of a set `indicator_const_Lp 2 hs h\u03bcs c` and `f` is\nequal to the integral of the inner product over `s`: `\u222b x in s, \u27eac, f x\u27eb \u2202\u03bc`. -/\nlemma inner_indicator_const_Lp_eq_set_integral_inner (f : Lp E 2 \u03bc) (hs : measurable_set s) (c : E)\n  (h\u03bcs : \u03bc s \u2260 \u221e) :\n  (\u27eaindicator_const_Lp 2 hs h\u03bcs c, f\u27eb : \ud835\udd5c) = \u222b x in s, \u27eac, f x\u27eb \u2202\u03bc :=\nbegin\n  rw [inner_def, \u2190 integral_add_compl hs (L2.integrable_inner _ f)],\n  have h_left : \u222b x in s, \u27ea(indicator_const_Lp 2 hs h\u03bcs c) x, f x\u27eb \u2202\u03bc = \u222b x in s, \u27eac, f x\u27eb \u2202\u03bc,\n  { suffices h_ae_eq : \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 \u27eaindicator_const_Lp 2 hs h\u03bcs c x, f x\u27eb = \u27eac, f x\u27eb,\n      from set_integral_congr_ae hs h_ae_eq,\n    have h_indicator : \u2200\u1d50 (x : \u03b1) \u2202\u03bc, x \u2208 s \u2192 (indicator_const_Lp 2 hs h\u03bcs c x) = c,\n      from indicator_const_Lp_coe_fn_mem,\n    refine h_indicator.mono (\u03bb x hx hxs, _),\n    congr,\n    exact hx hxs, },\n  have h_right : \u222b x in s\u1d9c, \u27ea(indicator_const_Lp 2 hs h\u03bcs c) x, f x\u27eb \u2202\u03bc = 0,\n  { suffices h_ae_eq : \u2200\u1d50 x \u2202\u03bc, x \u2209 s \u2192 \u27eaindicator_const_Lp 2 hs h\u03bcs c x, f x\u27eb = 0,\n    { simp_rw \u2190 set.mem_compl_iff at h_ae_eq,\n      suffices h_int_zero : \u222b x in s\u1d9c, inner (indicator_const_Lp 2 hs h\u03bcs c x) (f x) \u2202\u03bc\n        = \u222b x in s\u1d9c, (0 : \ud835\udd5c) \u2202\u03bc,\n      { rw h_int_zero,\n        simp, },\n      exact set_integral_congr_ae hs.compl h_ae_eq, },\n    have h_indicator : \u2200\u1d50 (x : \u03b1) \u2202\u03bc, x \u2209 s \u2192 (indicator_const_Lp 2 hs h\u03bcs c x) = 0,\n      from indicator_const_Lp_coe_fn_nmem,\n    refine h_indicator.mono (\u03bb 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\u03bcs 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 \u211d E]\n  (hs : measurable_set s) (h\u03bcs : \u03bc s \u2260 \u221e) (c : E) (f : Lp E 2 \u03bc) :\n  (\u27eaindicator_const_Lp 2 hs h\u03bcs c, f\u27eb : \ud835\udd5c) = \u27eac, \u222b x in s, f x \u2202\u03bc\u27eb :=\nby rw [\u2190 integral_inner (integrable_on_Lp_of_measure_ne_top f fact_one_le_two_ennreal.elim h\u03bcs),\n    L2.inner_indicator_const_Lp_eq_set_integral_inner]\n\nvariables {\ud835\udd5c}\n\n/-- The inner product in `L2` of the indicator of a set `indicator_const_Lp 2 hs h\u03bcs (1 : \ud835\udd5c)` 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\u03bcs : \u03bc s \u2260 \u221e) (f : Lp \ud835\udd5c 2 \u03bc) :\n  \u27eaindicator_const_Lp 2 hs h\u03bcs (1 : \ud835\udd5c), f\u27eb = \u222b x in s, f x \u2202\u03bc :=\nby { rw L2.inner_indicator_const_Lp_eq_inner_set_integral \ud835\udd5c hs h\u03bcs (1 : \ud835\udd5c) f, simp, }\n\nend indicator_const_Lp\n\nend L2\n\nsection inner_continuous\n\nvariables {\u03b1 : Type*} [topological_space \u03b1] [measure_space \u03b1] [borel_space \u03b1] {\ud835\udd5c : Type*}\n  [is_R_or_C \ud835\udd5c]\nvariables (\u03bc : measure \u03b1) [is_finite_measure \u03bc]\n\nopen_locale bounded_continuous_function complex_conjugate\n\nlocal notation `\u27ea`x`, `y`\u27eb` := @inner \ud835\udd5c (\u03b1 \u2192\u2082[\u03bc] \ud835\udd5c) _ x y\n\n/-- For bounded continuous functions `f`, `g` on a finite-measure topological space `\u03b1`, the L^2\ninner product is the integral of their pointwise inner product. -/\nlemma bounded_continuous_function.inner_to_Lp (f g : \u03b1 \u2192\u1d47 \ud835\udd5c) :\n  \u27eabounded_continuous_function.to_Lp 2 \u03bc \ud835\udd5c f, bounded_continuous_function.to_Lp 2 \u03bc \ud835\udd5c g\u27eb\n  = \u222b x, conj (f x) * g x \u2202\u03bc :=\nbegin\n  apply integral_congr_ae,\n  have hf_ae := f.coe_fn_to_Lp \u03bc,\n  have hg_ae := g.coe_fn_to_Lp \u03bc,\n  filter_upwards [hf_ae, hg_ae] with _ hf hg,\n  rw [hf, hg],\n  simp\nend\n\nvariables [compact_space \u03b1]\n\n/-- For continuous functions `f`, `g` on a compact, finite-measure topological space `\u03b1`, the L^2\ninner product is the integral of their pointwise inner product. -/\nlemma continuous_map.inner_to_Lp (f g : C(\u03b1, \ud835\udd5c)) :\n  \u27eacontinuous_map.to_Lp 2 \u03bc \ud835\udd5c f, continuous_map.to_Lp 2 \u03bc \ud835\udd5c g\u27eb\n  = \u222b x, conj (f x) * g x \u2202\u03bc :=\nbegin\n  apply integral_congr_ae,\n  have hf_ae := f.coe_fn_to_Lp \u03bc,\n  have hg_ae := g.coe_fn_to_Lp \u03bc,\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 \u03b1 \u03c3` is a realization of a topology (basis) on `\u03b1`,\n  represented by a type `\u03c3` together with operations for the top element and\n  the intersection operation. -/\nstructure ctop (\u03b1 \u03c3 : Type*) :=\n(f : \u03c3 \u2192 set \u03b1)\n(top : \u03b1 \u2192 \u03c3)\n(top_mem : \u2200 x : \u03b1, x \u2208 f (top x))\n(inter : \u03a0 a b (x : \u03b1), x \u2208 f a \u2229 f b \u2192 \u03c3)\n(inter_mem : \u2200 a b x h, x \u2208 f (inter a b x h))\n(inter_sub : \u2200 a b x h, f (inter a b x h) \u2286 f a \u2229 f b)\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03c3 : Type*} {\u03c4 : Type*}\n\nnamespace ctop\nsection\nvariables (F : ctop \u03b1 \u03c3)\n\ninstance : has_coe_to_fun (ctop \u03b1 \u03c3) := \u27e8_, ctop.f\u27e9\n\n@[simp] theorem coe_mk (f T h\u2081 I h\u2082 h\u2083 a) : (@ctop.mk \u03b1 \u03c3 f T h\u2081 I h\u2082 h\u2083) a = f a := rfl\n\n/-- Map a ctop to an equivalent representation type. -/\ndef of_equiv (E : \u03c3 \u2243 \u03c4) : ctop \u03b1 \u03c3 \u2192 ctop \u03b1 \u03c4\n| \u27e8f, T, h\u2081, I, h\u2082, h\u2083\u27e9 :=\n  { f         := \u03bb a, f (E.symm a),\n    top       := \u03bb x, E (T x),\n    top_mem   := \u03bb x, by simpa using h\u2081 x,\n    inter     := \u03bb a b x h, E (I (E.symm a) (E.symm b) x h),\n    inter_mem := \u03bb a b x h, by simpa using h\u2082 (E.symm a) (E.symm b) x h,\n    inter_sub := \u03bb a b x h, by simpa using h\u2083 (E.symm a) (E.symm b) x h }\n\n@[simp] theorem of_equiv_val (E : \u03c3 \u2243 \u03c4) (F : ctop \u03b1 \u03c3) (a : \u03c4) :\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 \u03b1 \u03c3) : topological_space \u03b1 :=\ntopological_space.generate_from (set.range F.f)\n\ntheorem to_topsp_is_topological_basis (F : ctop \u03b1 \u03c3) :\n  @topological_space.is_topological_basis _ F.to_topsp (set.range F.f) :=\nby letI := F.to_topsp; exact\n\u27e8\u03bb u \u27e8a, e\u2081\u27e9 v \u27e8b, e\u2082\u27e9, e\u2081 \u25b8 e\u2082 \u25b8\n   \u03bb x h, \u27e8_, \u27e8_, rfl\u27e9, F.inter_mem a b x h, F.inter_sub a b x h\u27e9,\neq_univ_iff_forall.2 $ \u03bb x, \u27e8_, \u27e8_, rfl\u27e9, F.top_mem x\u27e9, rfl\u27e9\n\n@[simp] theorem mem_nhds_to_topsp (F : ctop \u03b1 \u03c3) {s : set \u03b1} {a : \u03b1} :\n  s \u2208 @nhds _ F.to_topsp a \u2194 \u2203 b, a \u2208 F b \u2227 F b \u2286 s :=\n(@topological_space.is_topological_basis.mem_nhds_iff\n  _ F.to_topsp _ _ _ F.to_topsp_is_topological_basis).trans $\n\u27e8\u03bb \u27e8_, \u27e8x, rfl\u27e9, h\u27e9, \u27e8x, h\u27e9, \u03bb \u27e8x, h\u27e9, \u27e8_, \u27e8x, rfl\u27e9, h\u27e9\u27e9\n\nend ctop\n\n/-- A `ctop` realizer for the topological space `T` is a `ctop`\n  which generates `T`. -/\nstructure ctop.realizer (\u03b1) [T : topological_space \u03b1] :=\n(\u03c3 : Type*)\n(F : ctop \u03b1 \u03c3)\n(eq : F.to_topsp = T)\nopen ctop\n\nprotected def ctop.to_realizer (F : ctop \u03b1 \u03c3) : @ctop.realizer _ F.to_topsp :=\n@ctop.realizer.mk _ F.to_topsp \u03c3 F rfl\n\nnamespace ctop.realizer\n\nprotected theorem is_basis [T : topological_space \u03b1] (F : realizer \u03b1) :\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 \u03b1] (F : realizer \u03b1) {s : set \u03b1} {a : \u03b1} :\n  s \u2208 \ud835\udcdd a \u2194 \u2203 b, a \u2208 F.F b \u2227 F.F b \u2286 s :=\nby have := mem_nhds_to_topsp F.F; rwa F.eq at this\n\ntheorem is_open_iff [topological_space \u03b1] (F : realizer \u03b1) {s : set \u03b1} :\n  is_open s \u2194 \u2200 a \u2208 s, \u2203 b, a \u2208 F.F b \u2227 F.F b \u2286 s :=\nis_open_iff_mem_nhds.trans $ ball_congr $ \u03bb a h, F.mem_nhds\n\ntheorem is_closed_iff [topological_space \u03b1] (F : realizer \u03b1) {s : set \u03b1} :\n  is_closed s \u2194 \u2200 a, (\u2200 b, a \u2208 F.F b \u2192 \u2203 z, z \u2208 F.F b \u2229 s) \u2192 a \u2208 s :=\nis_open_compl_iff.symm.trans $ F.is_open_iff.trans $ forall_congr $ \u03bb a,\nshow (a \u2209 s \u2192 (\u2203 (b : F.\u03c3), a \u2208 F.F b \u2227 \u2200 z \u2208 F.F b, z \u2209 s)) \u2194 _,\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 \u03b1] (F : realizer \u03b1) {s : set \u03b1} {a : \u03b1} :\n  a \u2208 interior s \u2194 \u2203 b, a \u2208 F.F b \u2227 F.F b \u2286 s :=\nmem_interior_iff_mem_nhds.trans F.mem_nhds\n\nprotected theorem is_open [topological_space \u03b1] (F : realizer \u03b1) (s : F.\u03c3) : is_open (F.F s) :=\nis_open_iff_nhds.2 $ \u03bb a m, by simpa using F.mem_nhds.2 \u27e8s, m, subset.refl _\u27e9\n\n\n\ntheorem ext [T : topological_space \u03b1] {\u03c3 : Type*} {F : ctop \u03b1 \u03c3}\n  (H\u2081 : \u2200 a, is_open (F a))\n  (H\u2082 : \u2200 a s, s \u2208 \ud835\udcdd a \u2192 \u2203 b, a \u2208 F b \u2227 F b \u2286 s) :\n  F.to_topsp = T :=\next' $ \u03bb a s, \u27e8H\u2082 a s, \u03bb \u27e8b, h\u2081, h\u2082\u27e9, mem_nhds_sets_iff.2 \u27e8_, h\u2082, H\u2081 _, h\u2081\u27e9\u27e9\n\nvariable [topological_space \u03b1]\n\nprotected def id : realizer \u03b1 := \u27e8{x:set \u03b1 // is_open x},\n{ f            := subtype.val,\n  top          := \u03bb _, \u27e8univ, is_open_univ\u27e9,\n  top_mem      := mem_univ,\n  inter        := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a h\u2083, \u27e8_, is_open_inter h\u2081 h\u2082\u27e9,\n  inter_mem    := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a, id,\n  inter_sub    := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a h\u2083, subset.refl _ },\next subtype.property $ \u03bb x s h,\n  let \u27e8t, h, o, m\u27e9 := mem_nhds_sets_iff.1 h in \u27e8\u27e8t, o\u27e9, m, h\u27e9\u27e9\n\ndef of_equiv (F : realizer \u03b1) (E : F.\u03c3 \u2243 \u03c4) : realizer \u03b1 :=\n\u27e8\u03c4, F.F.of_equiv E, ext' (\u03bb a s, F.mem_nhds.trans $\n \u27e8\u03bb \u27e8s, h\u27e9, \u27e8E s, by simpa using h\u27e9, \u03bb \u27e8t, h\u27e9, \u27e8E.symm t, by simpa using h\u27e9\u27e9)\u27e9\n\n@[simp] theorem of_equiv_\u03c3 (F : realizer \u03b1) (E : F.\u03c3 \u2243 \u03c4) : (F.of_equiv E).\u03c3 = \u03c4 := rfl\n@[simp] theorem of_equiv_F (F : realizer \u03b1) (E : F.\u03c3 \u2243 \u03c4) (s : \u03c4) :\n  (F.of_equiv E).F s = F.F (E.symm s) := by delta of_equiv; simp\n\nprotected def nhds (F : realizer \u03b1) (a : \u03b1) : (\ud835\udcdd a).realizer :=\n\u27e8{s : F.\u03c3 // a \u2208 F.F s},\n{ f            := \u03bb s, F.F s.1,\n  pt           := \u27e8_, F.F.top_mem a\u27e9,\n  inf          := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9, \u27e8_, F.F.inter_mem x y a \u27e8h\u2081, h\u2082\u27e9\u27e9,\n  inf_le_left  := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 z h, (F.F.inter_sub x y a \u27e8h\u2081, h\u2082\u27e9 h).1,\n  inf_le_right := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 z h, (F.F.inter_sub x y a \u27e8h\u2081, h\u2082\u27e9 h).2 },\nfilter_eq $ set.ext $ \u03bb x,\n\u27e8\u03bb \u27e8\u27e8s, as\u27e9, h\u27e9, mem_nhds_sets_iff.2 \u27e8_, h, F.is_open _, as\u27e9,\n \u03bb h, let \u27e8s, h, as\u27e9 := F.mem_nhds.1 h in \u27e8\u27e8s, h\u27e9, as\u27e9\u27e9\u27e9\n\n@[simp] theorem nhds_\u03c3 (m : \u03b1 \u2192 \u03b2) (F : realizer \u03b1) (a : \u03b1) :\n  (F.nhds a).\u03c3 = {s : F.\u03c3 // a \u2208 F.F s} := rfl\n@[simp] theorem nhds_F (m : \u03b1 \u2192 \u03b2) (F : realizer \u03b1) (a : \u03b1) (s) :\n  (F.nhds a).F s = F.F s.1 := rfl\n\ntheorem tendsto_nhds_iff {m : \u03b2 \u2192 \u03b1} {f : filter \u03b2} (F : f.realizer) (R : realizer \u03b1) {a : \u03b1} :\n  tendsto m f (\ud835\udcdd a) \u2194 \u2200 t, a \u2208 R.F t \u2192 \u2203 s, \u2200 x \u2208 F.F s, m x \u2208 R.F t :=\n(F.tendsto_iff _ (R.nhds a)).trans subtype.forall\n\nend ctop.realizer\n\nstructure locally_finite.realizer [topological_space \u03b1] (F : realizer \u03b1) (f : \u03b2 \u2192 set \u03b1) :=\n(bas : \u2200 a, {s // a \u2208 F.F s})\n(sets : \u2200 x:\u03b1, fintype {i | (f i \u2229 F.F (bas x)).nonempty})\n\ntheorem locally_finite.realizer.to_locally_finite [topological_space \u03b1]\n  {F : realizer \u03b1} {f : \u03b2 \u2192 set \u03b1} (R : locally_finite.realizer F f) :\n  locally_finite f :=\n\u03bb a, \u27e8_, F.mem_nhds.2\n  \u27e8(R.bas a).1, (R.bas a).2, subset.refl _\u27e9, \u27e8R.sets a\u27e9\u27e9\n\ntheorem locally_finite_iff_exists_realizer [topological_space \u03b1]\n  (F : realizer \u03b1) {f : \u03b2 \u2192 set \u03b1} : locally_finite f \u2194 nonempty (locally_finite.realizer F f) :=\n\u27e8\u03bb h, let \u27e8g, h\u2081\u27e9 := classical.axiom_of_choice h,\n    \u27e8g\u2082, h\u2082\u27e9 := classical.axiom_of_choice (\u03bb x,\n       show \u2203 (b : F.\u03c3), x \u2208 (F.F) b \u2227 (F.F) b \u2286 g x, from\n       let \u27e8h, h'\u27e9 := h\u2081 x in F.mem_nhds.1 h) in\n  \u27e8\u27e8\u03bb x, \u27e8g\u2082 x, (h\u2082 x).1\u27e9, \u03bb x, finite.fintype $\n    let \u27e8h, h'\u27e9 := h\u2081 x in h'.subset $ \u03bb i hi,\n    hi.mono (inter_subset_inter_right _ (h\u2082 x).2)\u27e9\u27e9,\n \u03bb \u27e8R\u27e9, R.to_locally_finite\u27e9\n\ndef compact.realizer [topological_space \u03b1] (R : realizer \u03b1) (s : set \u03b1) :=\n\u2200 {f : filter \u03b1} (F : f.realizer) (x : F.\u03c3), f \u2260 \u22a5 \u2192\n  F.F x \u2286 s \u2192 {a // a\u2208s \u2227 \ud835\udcdd a \u2293 f \u2260 \u22a5}\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) \u2192 Foo a \u2192 Foo b := @Foo.mk\n\n#print Foo\n\nnamespace Ex2\n\ndef natToType : Nat \u2192 Type\n| 0 => Unit\n| _ => Bool\n\ninductive Foo : Nat \u2192 Char \u2192 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 (\u03b1 : Type) where\n  decEq : DecidableEq \u03b1\n\ninstance instDecidableEq {\u03b1} [Foo \u03b1] : DecidableEq \u03b1 := Foo.decEq\ninstance instFooNat : Foo Nat := \u27e8by infer_instance\u27e9\n\ndef kron (i j : \u03b1) [DecidableEq \u03b1] : Nat := if (i=j) then 1 else 0\n\ntheorem kron_right_mul (\u03b1 : Type) [foo : Foo \u03b1]  (i j : \u03b1) (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 \u2220DAB = \u2220ABC < 90\u00b0.\nThe line through D and the midpoint of BC intersects line AB\nin point E. Prove that \u2220BEC = \u2220DAC. (Note: The problem is valid\nwithout the assumption \u2220ABC < 90\u00b0.)\n\n-/\n\nopen_locale euclidean_geometry\n\ntheorem bulgaria1998_q2\n    (A B C D E M: euclidean_space \u211d (fin 2))\n    (H1 : dist D A = dist D C)\n    (H2 : \u2220 D A B = \u2220 A B C)\n    (H3 : M = midpoint \u211d B C) :\n    \u2220 B E C = \u2220 D A C :=\nbegin\n  let x := \u2220 D A C,\n  have : \u2220 D A C = \u2220 D C A := euclidean_geometry.angle_eq_angle_of_dist_eq H1,\n  let y := \u2220 C A B,\n  have : \u2220 A B C = x + y,\n  {\n    rw \u2190 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\u2019s 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 : \u2115}\n\n/-- u_stmt and u_wit are fin-indexed collections of polynomials from the square span program -/\nparameter {u_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {u_wit : fin n_wit \u2192 (polynomial F) }\nparameter {v_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {v_wit : fin n_wit \u2192 (polynomial F) }\nparameter {w_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {w_wit : fin n_wit \u2192 (polynomial F) }\n\n\n/-- The roots of the polynomial t -/\nparameter {r : fin n_wit \u2192 F} \n/-- t is the polynomial divisibility by which is used to verify satisfaction of the SSP -/\ndef t : polynomial F := \u220f 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 \u2192 F ) (a_wit : fin n_wit \u2192 F) := \n((\u2211 i in (finset.univ : finset (fin n_stmt)), a_stmt i \u2022 u_stmt i\n  + (\u2211 i in (finset.univ : finset (fin n_wit)), a_wit i \u2022 u_wit i))\n  * \n(\u2211 i in (finset.univ : finset (fin n_stmt)), a_stmt i \u2022 v_stmt i\n  + (\u2211 i in (finset.univ : finset (fin n_wit)), a_wit i \u2022 v_wit i))\n  -\n(\u2211 i in (finset.univ : finset (fin n_stmt)), a_stmt i \u2022 w_stmt i\n  + (\u2211 i in (finset.univ : finset (fin n_wit)), a_wit i \u2022 w_wit i)))\n   %\u2098 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_\u03b1  (f : groth16.vars \u2192 F) : polynomial F := polynomial.C (f vars.\u03b1)\n@[crs]\ndef crs_\u03b2 (f : groth16.vars \u2192 F) : polynomial F := polynomial.C (f vars.\u03b2)\n@[crs]\ndef crs_\u03b3 (f : groth16.vars \u2192 F) : polynomial F := polynomial.C (f vars.\u03b3)\n@[crs]\ndef crs_\u03b4 (f : groth16.vars \u2192 F) : polynomial F := polynomial.C (f vars.\u03b4)\n@[crs]\ndef crs_powers_of_x (i : fin n_var) (f : groth16.vars \u2192 F) : polynomial F := ((polynomial.X)^(i : \u2115))\n@[crs]\ndef crs_l (i : fin n_stmt) (f : groth16.vars \u2192 F) : polynomial F := \npolynomial.C (1 / f vars.\u03b3) * (polynomial.C (f vars.\u03b2 / f vars.\u03b3) * u_stmt i\n+\npolynomial.C  (f vars.\u03b1 / f vars.\u03b3) * v_stmt i\n+\n(w_stmt i)) \n@[crs]\ndef crs_m (i : fin n_wit) (f : groth16.vars \u2192 F) : polynomial F := \npolynomial.C (1 / f vars.\u03b4) * (polynomial.C  (f vars.\u03b2 / f vars.\u03b4) * (u_wit i)\n+\npolynomial.C  (f vars.\u03b1 / f vars.\u03b4) * (v_wit i)\n+\n(w_wit i)) \n@[crs]\ndef crs_n (i : fin (n_var - 1)) (f : groth16.vars \u2192 F) : polynomial F := \n(polynomial.X)^(i : \u2115) * t * polynomial.C (1 / f vars.\u03b4)\n\n/-- The coefficients of the CRS elements in the algebraic adversary's representation -/\nparameters {A_\u03b1 A_\u03b2 A_\u03b3 A_\u03b4 B_\u03b1 B_\u03b2 B_\u03b3 B_\u03b4 C_\u03b1 C_\u03b2 C_\u03b3 C_\u03b4  : F}\nparameters {A_x B_x C_x : fin n_var \u2192 F}\nparameters {A_l B_l C_l : fin n_stmt \u2192 F}\nparameters {A_m B_m C_m : fin n_wit \u2192 F}\nparameters {A_h B_h C_h : fin (n_var-1) \u2192 F}\n\n\n/-- Polynomial forms of the adversary's proof representation -/\ndef A (f : groth16.vars \u2192 F) : polynomial F := \n  polynomial.C A_\u03b1 * (crs_\u03b1 f)\n  +\n  polynomial.C A_\u03b2 * (crs_\u03b2 f)\n  +\n  polynomial.C A_\u03b4 * crs_\u03b4 f\n  +\n  \u2211 i in ((finset.univ : finset (fin n_var))), polynomial.C (A_x i) * (crs_powers_of_x i f)\n  +\n  \u2211 i in (finset.univ : finset (fin n_stmt)), polynomial.C (A_l i) * (crs_l i f)\n  +\n  \u2211 i in (finset.univ : finset (fin n_wit)), polynomial.C (A_m i) * (crs_m i f)\n  +\n  \u2211 i in (finset.univ : finset (fin (n_var-1))), polynomial.C (A_h i) * (crs_n i f)\n\ndef B (f : groth16.vars \u2192 F) : polynomial F  := \n  polynomial.C B_\u03b2 * crs_\u03b2 f\n  + \n  polynomial.C B_\u03b3 * crs_\u03b3 f\n  +\n  polynomial.C B_\u03b4 * crs_\u03b4 f\n  +\n  \u2211 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 \u2192 F) : polynomial F  := \n  polynomial.C C_\u03b1 * crs_\u03b1 f\n  +\n  polynomial.C C_\u03b2 * crs_\u03b2 f\n  +\n  polynomial.C C_\u03b4 * crs_\u03b4 f\n  +\n  \u2211 i in ((finset.univ : finset (fin n_var))), polynomial.C (C_x i) * (crs_powers_of_x i f)\n  +\n  \u2211 i in (finset.univ : finset (fin n_stmt)), polynomial.C (C_l i) * (crs_l i f)\n  +\n  \u2211 i in (finset.univ : finset (fin n_wit)), polynomial.C (C_m i) * (crs_m i f)\n  +\n  \u2211 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 \u03b3 * \u03b4. \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'_\u03b1  : groth16polynomial := X vars.\u03b1 * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_\u03b2 : groth16polynomial := X vars.\u03b2 * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_\u03b3 : groth16polynomial := X vars.\u03b3 * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_\u03b4 : groth16polynomial := X vars.\u03b4 * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_powers_of_x (i : fin n_var) : (groth16polynomial) := mv_polynomial.C (polynomial.X ^ (i : \u2115)) * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_l (i : fin n_stmt) : (groth16polynomial) := \n(X vars.\u03b2 * X vars.\u03b4) * mv_polynomial.C (u_stmt i)\n+\n(X vars.\u03b1 * X vars.\u03b4) * mv_polynomial.C (v_stmt i)\n+\nX vars.\u03b4 * mv_polynomial.C (w_stmt i)\n@[crs]\ndef crs'_m (i : fin n_wit) : (groth16polynomial) := \n(X vars.\u03b2 * X vars.\u03b3) * mv_polynomial.C (u_wit i)\n+\n(X vars.\u03b1 * X vars.\u03b3) * mv_polynomial.C (v_wit i)\n+\nX vars.\u03b3 * mv_polynomial.C (w_wit i)\n@[crs]\ndef crs'_t (i : fin (n_var - 1)) : (groth16polynomial) := \nX vars.\u03b3 * mv_polynomial.C ((polynomial.X)^(i : \u2115) * t)\n\n\n/-- Polynomial form of A in the adversary's proof representation -/\ndef A'  : groth16polynomial := \n  crs'_\u03b1 * mv_polynomial.C (polynomial.C (A_\u03b1))\n  +\n  crs'_\u03b2 * mv_polynomial.C (polynomial.C (A_\u03b2))\n  + \n  crs'_\u03b4 * mv_polynomial.C (polynomial.C (A_\u03b4))\n  +\n  X vars.\u03b3 * X vars.\u03b4 * mv_polynomial.C \u2211 i in ((finset.univ : finset (fin n_var))), (polynomial.C (A_x i) * polynomial.X ^ (i : \u2115))\n  +\n  \u2211 i in (finset.univ : finset (fin n_stmt)), (crs'_l i) * mv_polynomial.C (polynomial.C (A_l i))\n  +\n  \u2211 i in (finset.univ : finset (fin n_wit)), (crs'_m i) * mv_polynomial.C (polynomial.C (A_m i))\n  +\n  \u2211 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'_\u03b2 * mv_polynomial.C (polynomial.C (B_\u03b2))\n  + \n  crs'_\u03b3 * mv_polynomial.C (polynomial.C (B_\u03b3))\n  +\n  crs'_\u03b4 * mv_polynomial.C (polynomial.C (B_\u03b4))\n  +\n  X vars.\u03b3 * X vars.\u03b4 * mv_polynomial.C \u2211 i in ((finset.univ : finset (fin n_var))), (polynomial.C (B_x i) * polynomial.X ^ (i : \u2115))\n\n/-- Polynomial form of C in the adversary's proof representation -/\ndef C'  : groth16polynomial := \n  crs'_\u03b1 * mv_polynomial.C (polynomial.C (C_\u03b1))\n  +\n  crs'_\u03b2 * mv_polynomial.C (polynomial.C (C_\u03b2))\n  + \n  crs'_\u03b4 * mv_polynomial.C (polynomial.C (C_\u03b4))\n  +\n  X vars.\u03b3 * X vars.\u03b4 * mv_polynomial.C \u2211 i in ((finset.univ : finset (fin n_var))), (polynomial.C (C_x i) * polynomial.X ^ (i : \u2115))\n  +\n  \u2211 i in (finset.univ : finset (fin n_stmt)), (crs'_l i) * mv_polynomial.C (polynomial.C (C_l i))\n  +\n  \u2211 i in (finset.univ : finset (fin n_wit)), (crs'_m i) * mv_polynomial.C (polynomial.C (C_m i))\n  +\n  \u2211 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 \u2192 F ) : Prop := A * B = crs_\u03b1 * crs_\u03b2 + (\u2211 i in (finset.univ : finset (fin n_stmt)), a_stmt i \u2022 crs_l i ) * crs_\u03b3 + C * crs_\u03b4\n\ndef verified' (a_stmt : fin n_stmt \u2192 F ) : Prop := A' * B' = crs'_\u03b1 * crs'_\u03b2 + (\u2211 i in (finset.univ : finset (fin n_stmt)), mv_polynomial.C (polynomial.C (a_stmt i)) * crs'_l i ) * crs'_\u03b3 + C' * crs'_\u03b4\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 \u2192 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_\u03b1_mul (p : polynomial F) : p * polynomial.C A_\u03b1  = polynomial.C A_\u03b1 * p := by ring\n\nlemma B_\u03b2_mul (p : polynomial F) : p * polynomial.C B_\u03b2  = polynomial.C B_\u03b2 * 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 \u2194 a = 1 :=\ncalc polynomial.C a = 1 \u2194 polynomial.C a = polynomial.C 1 : by rw polynomial.C_1\n         ... \u2194 a = 1 : polynomial.C_inj\n\n\nlemma simplifier1 (x : fin n_stmt) (a_stmt : fin n_stmt \u2192 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 \u2192 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) %\u2098 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 \u2192 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    (\u2211 (i : fin n_stmt) in finset.univ, u_stmt i * polynomial.C (a_stmt i) + \u2211 (i : fin n_wit) in finset.univ, u_wit i * polynomial.C (C_m i)) \n    * \n    (\u2211 (i : fin n_stmt) in finset.univ, v_stmt i * polynomial.C (a_stmt i) + \u2211 (i : fin n_wit) in finset.univ, v_wit i * polynomial.C (C_m i)) \n    = \n    (\u2211 (i : fin n_stmt) in finset.univ, w_stmt i * polynomial.C (a_stmt i) + \u2211 (i : fin n_wit) in finset.univ, w_wit i * polynomial.C (C_m i)) \n    +\n    \u2211 (x : fin (n_var - 1)) in finset.univ, polynomial.X ^ (x : \u2115) * t * polynomial.C (C_h x),\n  {\n    rw <-sub_eq_iff_eq_add' at this,\n    have h := congr_arg (%\u2098 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.\u03b1 0 + single vars.\u03b2 0 + single vars.\u03b3 1 + single vars.\u03b4 2)) eqn',\n  have h0021 := congr_arg (coeff (single vars.\u03b1 0 + single vars.\u03b2 0 + single vars.\u03b3 2 + single vars.\u03b4 1)) eqn',\n  have h0022 := congr_arg (coeff (single vars.\u03b1 0 + single vars.\u03b2 0 + single vars.\u03b3 2 + single vars.\u03b4 2)) eqn',\n  have h0112 := congr_arg (coeff (single vars.\u03b1 0 + single vars.\u03b2 1 + single vars.\u03b3 1 + single vars.\u03b4 2)) eqn',\n  have h0121 := congr_arg (coeff (single vars.\u03b1 0 + single vars.\u03b2 1 + single vars.\u03b3 2 + single vars.\u03b4 1)) eqn',\n  have h0122 := congr_arg (coeff (single vars.\u03b1 0 + single vars.\u03b2 1 + single vars.\u03b3 2 + single vars.\u03b4 2)) eqn',\n  have h0212 := congr_arg (coeff (single vars.\u03b1 0 + single vars.\u03b2 2 + single vars.\u03b3 1 + single vars.\u03b4 2)) eqn',\n  have h0221 := congr_arg (coeff (single vars.\u03b1 0 + single vars.\u03b2 2 + single vars.\u03b3 2 + single vars.\u03b4 1)) eqn',\n  have h0222 := congr_arg (coeff (single vars.\u03b1 0 + single vars.\u03b2 2 + single vars.\u03b3 2 + single vars.\u03b4 2)) eqn',\n  have h1022 := congr_arg (coeff (single vars.\u03b1 1 + single vars.\u03b2 0 + single vars.\u03b3 2 + single vars.\u03b4 2)) eqn',\n  -- have h1023 := congr_arg (coeff (single vars.\u03b1 1 + single vars.\u03b2 0 + single vars.\u03b3 2 + single vars.\u03b4 3)) eqn', -- not needed\n  have h1112 := congr_arg (coeff (single vars.\u03b1 1 + single vars.\u03b2 1 + single vars.\u03b3 1 + single vars.\u03b4 2)) eqn',\n  have h1121 := congr_arg (coeff (single vars.\u03b1 1 + single vars.\u03b2 1 + single vars.\u03b3 2 + single vars.\u03b4 1)) eqn',\n  have h1122 := congr_arg (coeff (single vars.\u03b1 1 + single vars.\u03b2 1 + single vars.\u03b3 2 + single vars.\u03b4 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_\u03b2_mul],\n    simp only [<-mul_assoc],\n    simp only [A_\u03b1_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 : \u2115)\n  (h : a + b \u2265 c)\n  (h\u2080 : a \u2223 c)\n  (h' : a + c + 17 \u2265 d)\n  (sol : a * c \u2264 b + d * c) :\n  a * c \u2264 b + d * c :=\nbegin\n  to_int,\n    -- a : \u2124,\n    -- a_nneg : a \u2265 0,\n    -- b : \u2124,\n    -- b_nneg : b \u2265 0,\n    -- c : \u2124,\n    -- c_nneg : c \u2265 0,\n    -- d : \u2124,\n    -- d_nneg : d \u2265 0,\n    -- h : a + b \u2265 c,\n    -- h\u2080 : a \u2223 c,\n    -- h' : a + c + 17 \u2265 d\n    -- \u22a2 a * c \u2264 b + d * c\n  guard_hyp a := \u2124,\n  guard_hyp b := \u2124,\n  guard_hyp c := \u2124,\n  guard_hyp d := \u2124,\n  guard_hyp h := a + b \u2265 c,\n  guard_target a * c \u2264 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 \u2192+* S)\nvariable (f : R \u27f6 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 := \u03bb s n, @has_scalar.smul S N _ s n }.\n\n@[simp] lemma smul_def' (r : R) (n : f ^* N) : r \u2022 n = f r \u2022 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 \u2022 n := rfl\n\ndef compatible_smul (N\u2081 N\u2082 : Module S) :\n  let m1 := is_module f N\u2081,\n      m2 := is_module f N\u2082,\n      m3 := is_module f \u27e8S\u27e9 in\n  begin\n    resetI,\n    exact linear_map.compatible_smul N\u2081 N\u2082 R S\n  end :=\nlet m1 := is_module f N\u2081,\n    m2 := is_module f N\u2082,\n    m3 := is_module f \u27e8S\u27e9 in\nbegin\n  resetI,\n  fconstructor,\n  intros g r n,\n  calc  g (r \u2022 n)\n      = g (f r \u2022 n) : by congr' 1\n    ... = f r \u2022 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 \u2964 Module R :=\n{ obj := \u03bb N, f ^* N,\n  map := \u03bb N\u2081 N\u2082 l,\n  let m1 := is_module f N\u2081,\n      m2 := is_module f N\u2082,\n      m3 := is_module f \u27e8S\u27e9,\n      m4 := compatible_smul f N\u2081 N\u2082 in\n  begin\n    dsimp only at m4,\n    resetI,\n    exact linear_map.restrict_scalars R l,\n  end }.\n\nlocalized \"notation f `\u2964^*` 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 \u27f6 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 \u27e8S\u27e9 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 `\u2297[` R `,` f `]` S := @tensor_product R _ M S _ _ _\n  (restriction_of_scalars.is_module f \u27e8S\u27e9)\" in change_of_rings\nlocalized \"notation m `\u2297\u209c[` R `,` f `]` s := @tensor_product.tmul R _ _ _ _ _ _\n  (restriction_of_scalars.is_module f \u27e8_\u27e9) m s\" in change_of_rings\n\ndef smul_by (s : S) : (M \u2297[R, f] S) \u27f6 (M \u2297[R, f] S) :=\nlet m : module R S := restriction_of_scalars.is_module f \u27e8S\u27e9 in\nbegin\n  resetI,\n  refine tensor_product.lift _,\n  refine \u27e8_, _, _\u27e9,\n  { -- we define `m \u21a6 (s' \u21a6 m \u2297 (s * s'))`\n    refine \u03bb m, \u27e8\u03bb s', m \u2297\u209c[R, f] (s * s'), _, _\u27e9,\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 \u27e8S\u27e9, smul_eq_mul, \u2190 mul_assoc, mul_comm s,\n        mul_assoc, restriction_of_scalars.smul_def f \u27e8S\u27e9, 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 \u2297\u209c[R, f] s')) =\n  m \u2297\u209c[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 = \ud835\udfd9 _ :=\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 \u22a2,\n    conv_rhs { rw [\u2190 ih1, \u2190 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' \u226b 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 \u2200 (a b c d : M \u2297[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 \u2297[R] S` can be given an `S`-module structure.\nThe scalar multiplication is defined by `s \u2022 (m \u2297 s') := m \u2297 (s * s')`\n-/\n@[reducible] def has_scalar_S_M_tensor_S : _root_.has_scalar S (M \u2297[R, f] S) :=\n{ smul := \u03bb 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 \u2022 (m \u2297\u209c[R, f] s')) =\n  m \u2297\u209c[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 \u2022 (0 : M \u2297[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 \u2297[R, f] S) :=\n{ one_smul := \u03bb x, begin\n    change smul_by _ _ _ _ = _,\n    rw smul_by.one f M,\n    refl,\n  end,\n  mul_smul := \u03bb 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 \u2297[R, f] S) :=\n{ smul_zero := \u03bb s, by { change smul_by f M s 0 = 0, apply smul_by.apply_zero, },\n  smul_add := \u03bb 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 \u2297[R, f] S) :=\n{ add_smul := \u03bb s s' x, begin\n    change smul_by _ _ _ _ = smul_by _ _ _ _ + smul_by _ _ _ _,\n    rw smul_by.add,\n    refl,\n  end,\n  zero_smul := \u03bb 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 \u2297[R, f] S) :=\ninfer_instance\n\n-- def compatible_smul (M1 M2 : Module R) :\n--   linear_map.compatible_smul (M1 \u2297[R, f] S) (M2 \u2297[R, f] S) S R :=\n-- let im1 : module R S := restriction_of_scalars.is_module f \u27e8S\u27e9,\n--     im2 : module S (M1 \u2297[R, f] S) := is_module f M1,\n--     im3 : module S (M2 \u2297[R, f] S) := is_module f M2 in\n-- \u27e8\u03bb 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 \u2297\u209c[R, f] s') using tensor_product.induction_on,\n--     rw \u2190 lift.equiv_symm_apply R M1 S (M2 \u2297[R, f] S) g m1 (s * s'),\n--     rw \u2190 lift.equiv_symm_apply R M1 S (M2 \u2297[R, f] S) g m1 s',\n--     -- dsimp only,\n--     -- squeeze_dsimp,\n--     -- type_check (tensor_product.lift.equiv R M1 S (M2 \u2297[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\u27e9\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 \u2297[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 \u2297 S` and\n`l : M1 \u27f6 M2` is sent to `m \u2297 s \u21a6 l m \u2297 s`\n-/\ndef map {M1 M2 : Module R} (l : M1 \u27f6 M2) : (f _* M1) \u27f6 (f _* M2) :=\nlet im1 : _root_.module R S := restriction_of_scalars.is_module f \u27e8S\u27e9,\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 := \u03bb m1, _, map_add' := _, map_smul' := _ },\n      map_add' := _,\n      map_smul' := _ },\n  { -- `S \u27f6 f _* M2` given by `s \u21a6 l m \u2297 s`\n    refine { to_fun := \u03bb s, (l m1) \u2297\u209c[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 \u27e8S\u27e9 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 \u2964 Module.{u} S :=\n{ obj := \u03bb M, f _* M,\n  map := \u03bb M1 M2 l, map f l,\n  map_id' := \u03bb 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 \u22a2,\n      rw [map_add, ihx, ihy], }\n  end,\n  map_comp' := \u03bb 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 `\u2964_*` 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 \u27f6 S) (X : Module.{u} R) (Y : Module.{u} S)\n\ndef backward (g : X \u27f6 (f \u2964^* Y)) :\n  (f \u2964_* X) \u27f6 Y :=\n{ to_fun := \u03bb z,\n  let m1 := restriction_of_scalars.is_module f \u27e8S\u27e9,\n      m2 : module R Y := restriction_of_scalars.is_module f Y,\n      m3 : module S (f \u2964^* Y) := Y.is_module in\n  begin\n    resetI,\n    refine tensor_product.lift\n      { to_fun := \u03bb x,\n          { to_fun := \u03bb s, _,\n            map_add' := _,\n            map_smul' := _, },\n        map_add' := _,\n        map_smul' := _ } z,\n    { -- `x \u2297 s \u21a6 s \u2022 g x` in Y\n      exact s \u2022 (g x : Y) },\n    { intros, rw add_smul, },\n    { intros r s,\n      rw [ring_hom.id_apply],\n      calc  (r \u2022 s) \u2022 g x\n          = (f r * s) \u2022 g x : rfl\n      ... = f r \u2022 s \u2022 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 [\u2190 mul_smul, mul_comm, mul_smul],\n      refl, },\n  end,\n  map_add' := \u03bb z1 z2, by simp only [map_add],\n  map_smul' := \u03bb 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 \u2964_* X) \u27f6 Y) :\n  X \u27f6 (f \u2964^* Y) :=\nlet m1 : module R S := restriction_of_scalars.is_module f \u27e8S\u27e9,\n    m2 : module R Y := restriction_of_scalars.is_module f Y in\n{ to_fun := \u03bb x, g (x \u2297\u209c[R, f] 1),\n  map_add' := \u03bb x x', by rw [tensor_product.add_tmul, map_add],\n  map_smul' := \u03bb r x, begin\n    resetI,\n    rw [ring_hom.id_apply],\n    calc  g ((r \u2022 x) \u2297\u209c[R, f] (1 : S))\n        = g (x \u2297\u209c[R, f] (r \u2022 1)) : by rw smul_tmul\n    ... = g (x \u2297\u209c[R, f] (f r \u2022 1)) : by rw restriction_of_scalars.smul_def f \u27e8S\u27e9\n    ... = g (f r \u2022 (x \u2297\u209c[R, f] 1)) : by congr' 1\n    ... = f r \u2022 g (x \u2297\u209c[R, f] 1) : by rw linear_map.map_smul\n    ... = r \u2022 g (x \u2297\u209c[R, f] 1) : rfl,\n  end }.\n\ndef equiv :\n  ((extension_of_scalars.functor f).obj X \u27f6 Y) \u2243 (X \u27f6 (restriction_of_scalars.functor f).obj Y) :=\n{ to_fun := forward f X Y,\n  inv_fun := backward f X Y,\n  left_inv := \u03bb 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 \u2022 g _ = _,\n      rw [\u2190 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 := \u03bb 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 \u27f6 ((extension_of_scalars.functor f \u22d9 restriction_of_scalars.functor f).obj X) :=\nlet m1 : module R S := restriction_of_scalars.is_module f \u27e8S\u27e9 in\n{ to_fun := \u03bb x, x \u2297\u209c[R, f] 1,\n  map_add' := \u03bb x x', by { rw tensor_product.add_tmul, },\n  map_smul' := \u03bb r x, begin\n    resetI,\n    erw [smul_tmul, extension_of_scalars.smul_pure_tensor],\n    congr,\n  end }.\n\ndef unit : \ud835\udfed (Module \u21a5R) \u27f6 extension_of_scalars.functor f \u22d9 restriction_of_scalars.functor f :=\n{ app := unit.map f,\n  naturality' := \u03bb 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 \u22d9 extension_of_scalars.functor f).obj Y \u27f6 Y :=\nlet m1 : module R S := restriction_of_scalars.is_module f \u27e8S\u27e9,\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 := \u03bb y,\n            { to_fun := \u03bb s, _,\n              map_add' := _,\n              map_smul' := _ },\n          map_add' := _,\n          map_smul' := _ },\n      { exact s \u2022 (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 \u27e8S\u27e9 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 [\u2190 mul_smul, mul_comm, mul_smul],\n        refl, },\n    end,\n  map_add' := \u03bb z1 z2, by simp only [map_add],\n  map_smul' := \u03bb 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 \u22d9 extension_of_scalars.functor f) \u27f6 (\ud835\udfed _) :=\n{ app := counit.map f,\n  naturality' := \u03bb 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\u209b\u2097, 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' := \u03bb 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' := \u03bb 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 `\u00abbrack\u00bb`\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 : \u00abarith\u00bb  -- 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 \"}\" : \u00abarith\u00bb -- 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 (\u03b1 : Type u) : Type u := Quotient (Perm.PermSetoid \u03b1)\n\ndef List.to_UnorderedList (l : List \u03b1) : M4R.UnorderedList \u03b1 := Quotient.mk l\n\nnamespace M4R\n  namespace UnorderedList\n    instance UnorderedListCoe : Coe (List \u03b1) (UnorderedList \u03b1) where coe := List.to_UnorderedList\n\n    @[simp] theorem list_to_eq (l : List \u03b1) : l.to_UnorderedList = (\u2191l : UnorderedList \u03b1) := rfl\n    @[simp] theorem list_coe_eq (l : List \u03b1) : Quotient.mk l = (\u2191l : UnorderedList \u03b1) := rfl\n    @[simp] theorem list_coe_eq' (l : List \u03b1) : Quot.mk Perm l = (\u2191l : UnorderedList \u03b1) := rfl\n\n    @[simp] theorem list_perm_eq {l\u2081 l\u2082 : List \u03b1} (h : l\u2081 ~ l\u2082) : (\u2191l\u2081 : UnorderedList \u03b1) = \u2191l\u2082 :=\n      Quot.sound h\n\n    protected def mem (a : \u03b1) (s : UnorderedList \u03b1) : Prop :=\n      Quot.liftOn s (fun l => a \u2208 l) (fun l\u2081 l\u2082 (p : l\u2081 ~ l\u2082) => propext (p.mem_iff _))\n    instance UnorderedListMem : Mem \u03b1 (UnorderedList \u03b1) where mem := UnorderedList.mem\n\n    protected def toSet (l : UnorderedList \u03b1) : Set \u03b1 := Set.toSet l\n    protected def ext_toSet {l : UnorderedList \u03b1} {x : \u03b1} : x \u2208 l \u2194 x \u2208 l.toSet := \u27e8id, id\u27e9\n\n    def nodup (s : UnorderedList \u03b1) : Prop :=\n      Quot.liftOn s List.nodup (fun l\u2081 l\u2082 p => propext p.nodupIff)\n\n    protected def sizeOf [SizeOf \u03b1] (s : UnorderedList \u03b1) : Nat :=\n      Quot.liftOn s sizeOf (fun _ _ => Perm.sizeOf_Eq_sizeOf)\n    instance UnorderedListSizeOf : SizeOf (UnorderedList \u03b1) where sizeOf := UnorderedList.sizeOf\n\n    def length (s : UnorderedList \u03b1) : Nat :=\n      Quot.liftOn s List.length (fun _ _ => Perm.length_eq)\n\n    protected def cons (a : \u03b1) (s : UnorderedList \u03b1) : UnorderedList \u03b1 :=\n      Quot.liftOn s (fun l => List.to_UnorderedList (a::l)) (fun _ _ p => Quot.sound (p.cons a))\n    @[simp] theorem cons_eq (a : \u03b1) (l : List \u03b1) : \u2191(a::l) = (\u2191l : UnorderedList \u03b1).cons a := rfl\n\n    @[simp] theorem nodup_cons {a : \u03b1} {s : UnorderedList \u03b1} : nodup (s.cons a) \u2194 a \u2209 s \u2227 nodup s :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => nodup (l.cons a) \u2194 a \u2209 l \u2227 nodup l) s\n        fun l => List.nodup_cons\n\n    protected def Empty {\u03b1 : Type _} : UnorderedList \u03b1 := List.to_UnorderedList []\n    instance EmptyUnorderedListEmptyCollection : EmptyCollection (UnorderedList \u03b1) where\n      emptyCollection := UnorderedList.Empty\n    instance UnorderedListZero : Zero (UnorderedList \u03b1) where zero := UnorderedList.Empty\n    @[simp] theorem empty_eq : (\u2191([] : List \u03b1) : UnorderedList \u03b1) = 0 := rfl\n    theorem mem_empty {a : \u03b1} : a \u2208 (0 : UnorderedList \u03b1) \u2194 False := Iff.rfl\n    theorem nodup_zero (\u03b1 : Type _) : (0 : UnorderedList \u03b1).nodup := List.nodup_nil\n\n    protected def singleton (a : \u03b1) : UnorderedList \u03b1 := \u2191[a]\n    @[simp] theorem singleton_eq (a : \u03b1) : List.to_UnorderedList [a] = UnorderedList.singleton a := rfl\n    theorem singleton_eq_cons (a : \u03b1) : UnorderedList.singleton a = UnorderedList.cons a 0 := rfl\n\n    protected theorem induction {p : UnorderedList \u03b1 \u2192 Prop} (h\u2081 : p 0)\n      (h\u2082 : \u2200 \u2983a : \u03b1\u2984 {s : UnorderedList \u03b1}, p s \u2192 p (s.cons a)) (s : UnorderedList \u03b1) : p s :=\n        @Quotient.inductionOn _ _ p s (fun l => by induction l with\n          | nil => exact h\u2081\n          | cons _ _ ih => exact h\u2082 ih)\n\n    protected theorem induction_on (p : UnorderedList \u03b1 \u2192 Prop) (s : UnorderedList \u03b1)\n      (h\u2081 : p 0) (h\u2082 : \u2200 \u2983a : \u03b1\u2984 {s : UnorderedList \u03b1}, p s \u2192 p (s.cons a)) : p s :=\n        UnorderedList.induction h\u2081 h\u2082 s\n\n    def disjoint (s t : UnorderedList \u03b1) : Prop := \u2200 x, x \u2208 s \u2192 x \u2209 t\n\n    theorem disjoint.symm {s t : UnorderedList \u03b1} : disjoint s t \u2194 disjoint t s :=\n      have : \u2200 s t : UnorderedList \u03b1, disjoint s t \u2192 disjoint t s :=\n        fun s t h x ht hs => h x hs ht\n      \u27e8this s t, this t s\u27e9\n\n    @[simp] theorem mem_cons {a b : \u03b1} {s : UnorderedList \u03b1} : a \u2208 s.cons b \u2194 a = b \u2228 a \u2208 s :=\n      @Quotient.ind _ _ (fun (l : UnorderedList \u03b1) => a \u2208 l.cons b \u2194 a = b \u2228 a \u2208 l)\n        (fun _ => Iff.rfl) s\n\n    theorem mem_cons_of_mem {a b : \u03b1} {s : UnorderedList \u03b1} (h : a \u2208 s) : a \u2208 s.cons b :=\n      mem_cons.mpr (Or.inr h)\n\n    @[simp] theorem mem_cons_self (a : \u03b1) (s : UnorderedList \u03b1) : a \u2208 s.cons a :=\n      mem_cons.mpr (Or.inl rfl)\n\n    theorem eq_nil_of_length_eq_zero {s : UnorderedList \u03b1} : s.length = 0 \u2192 s = 0 :=\n      @Quotient.ind _ _ (fun (l : UnorderedList \u03b1) => l.length = 0 \u2192 l = 0)\n        (fun _ h => congrArg _ (List.eq_nil_of_length_eq_zero h)) s\n\n    @[simp] theorem zero_subset {s : UnorderedList \u03b1} : 0 \u2286 s := by\n      intro _ _; contradiction\n\n    @[simp] theorem subset_zero {s : UnorderedList \u03b1} : s \u2286 0 \u2192 s = 0 :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => l \u2286 0 \u2192 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 \u2191l); contradiction)\n\n    protected def append (s t : UnorderedList \u03b1) : UnorderedList \u03b1 :=\n      Quotient.liftOn\u2082 s t (fun l\u2081 l\u2082 => (l\u2081 ++ l\u2082 : List \u03b1).to_UnorderedList)\n        fun v\u2081 v\u2082 w\u2081 w\u2082 p\u2081 p\u2082 => Quot.sound (p\u2081.append p\u2082)\n\n    namespace append\n      instance UnorderedListAdd : Add (UnorderedList \u03b1) where add := UnorderedList.append\n\n      theorem comm (s t : UnorderedList \u03b1) : s + t = t + s :=\n        @Quotient.inductionOn\u2082 _ _ _ _ (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2081 + l\u2082 = l\u2082 + l\u2081) s t\n          fun _ _ => Quot.sound Perm.append_comm\n\n      @[simp] theorem add_zero (s : UnorderedList \u03b1) : s + 0 = s :=\n        @Quotient.inductionOn _ _ (fun (a : UnorderedList \u03b1) => 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 \u03b1) : 0 + s = s := by\n        rw [comm, add_zero]\n\n      theorem cons (a : \u03b1) (s : UnorderedList \u03b1) : s.cons a = [a] + s := rfl\n      theorem cons' (a : \u03b1) (s : UnorderedList \u03b1) : s.cons a = s + [a] := by rw [comm, cons]\n\n      theorem assoc (s t u : UnorderedList \u03b1) : s + t + u = s + (t + u) :=\n        @Quotient.inductionOn\u2083 _ _ _ _ _ _\n          (fun (a b c : UnorderedList \u03b1) => 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 : \u03b1) (s t : UnorderedList \u03b1) : s + (t.cons a) = (s + t).cons a := by\n        simp only [cons]; rw [\u2190assoc, comm s, assoc]\n      theorem cons_over_left (a : \u03b1) (s t : UnorderedList \u03b1) : (s.cons a) + t = (s + t).cons a := by\n        simp only [cons]; rw [\u2190assoc, comm _ s, assoc]\n\n      @[simp] theorem mem_add {a : \u03b1} {s t : UnorderedList \u03b1} : a \u2208 s + t \u2194 a \u2208 s \u2228 a \u2208 t :=\n        @Quotient.inductionOn\u2082 _ _ _ _ (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => a \u2208 l\u2081 + l\u2082 \u2194 a \u2208 l\u2081 \u2228 a \u2208 l\u2082)\n          s t fun l\u2081 l\u2082 => List.mem_append\n\n      theorem nodup_add {s t : UnorderedList \u03b1} : (s + t).nodup \u2194 s.nodup \u2227 t.nodup \u2227 disjoint s t :=\n        @Quotient.inductionOn\u2082 _ _ _ _ (fun (s t : UnorderedList \u03b1) => (s + t).nodup \u2194 s.nodup \u2227 t.nodup \u2227 disjoint s t)\n          s t fun l\u2081 l\u2082 => List.nodup_append\n\n    end append\n\n    namespace length\n      @[simp] theorem coe_length (l : List \u03b1) : length (l : UnorderedList \u03b1) = l.length := rfl\n\n      @[simp] theorem zero : @length \u03b1 0 = 0 := rfl\n\n      @[simp] theorem add (s t : UnorderedList \u03b1) : length (s + t) = length s + length t :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => length (l\u2081 + l\u2082) = length l\u2081 + length l\u2082) s t\n            List.length_append\n\n      @[simp] theorem cons (a : \u03b1) (s : UnorderedList \u03b1) : length (s.cons a) = length s + 1 :=\n        @Quotient.inductionOn _ _\n          (fun (l : UnorderedList \u03b1) => length (l.cons a) = length l + 1) s fun l => rfl\n\n      @[simp] theorem singleton (a : \u03b1) : length (UnorderedList.singleton a) = 1 := by\n        simp only [singleton_eq_cons, zero, cons]\n\n      theorem eq_one {s : UnorderedList \u03b1} : length s = 1 \u2194 \u2203 a, s = UnorderedList.singleton a :=\n        \u27e8@Quotient.inductionOn _ _\n          (fun (l : UnorderedList \u03b1) => length l = 1 \u2192 \u2203 a, l = UnorderedList.singleton a) s\n          (fun l h => (List.length_eq_one.mp h).imp fun _ => congrArg List.to_UnorderedList),\n        fun \u27e8a, e\u27e9 => e.symm \u25b8 rfl\u27e9\n\n      theorem pos_iff_exists_mem {s : UnorderedList \u03b1} : 0 < length s \u2194 \u2203 a, a \u2208 s :=\n        @Quotient.inductionOn _ _\n          (fun (l : UnorderedList \u03b1) => 0 < length l \u2194 \u2203 a, a \u2208 l) s\n          (fun l => List.length_pos_iff_exists_mem)\n\n    end length\n\n    protected theorem in_singleton {a a' : \u03b1} : a' \u2208 UnorderedList.singleton a \u2192 a' = a :=\n      List.in_singleton\n\n    protected theorem self_singleton (a : \u03b1) : a \u2208 UnorderedList.singleton a :=\n      List.self_singleton a\n\n    protected theorem in_double (a b : \u03b1) : \u2200 x \u2208 ([a, b] : UnorderedList \u03b1), x = a \u2228 x = b :=\n      List.in_double a b\n\n    @[simp] protected theorem cons' (a : \u03b1) (l : List \u03b1) : Quotient.mk (a :: l) = (\u2191l : UnorderedList \u03b1).cons a := rfl\n\n    protected def map (f : \u03b1 \u2192 \u03b2) (s : UnorderedList \u03b1) : UnorderedList \u03b2 :=\n      Quot.liftOn s (fun l : List \u03b1 => \u2191(l.map f))\n        (fun l\u2081 l\u2082 p => Quot.sound (p.map f))\n\n    @[simp] theorem map_nil (f : \u03b1 \u2192 \u03b2) : UnorderedList.map f 0 = 0 := rfl\n\n    namespace map\n\n      @[simp] theorem cons (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (s : UnorderedList \u03b1) : (s.cons a).map f = (s.map f).cons (f a) :=\n        @Quotient.ind _ _ (fun (l : UnorderedList \u03b1) => (l.cons a).map f = (l.map f).cons (f a)) (fun _ => rfl) s\n\n      @[simp] theorem singleton (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : (UnorderedList.singleton a).map f = UnorderedList.singleton (f a) := rfl\n\n      @[simp] theorem add (f : \u03b1 \u2192 \u03b2) (l\u2081 l\u2082 : UnorderedList \u03b1) : (l\u2081 + l\u2082).map f = (l\u2081.map f) + (l\u2082.map f) :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (s t : UnorderedList \u03b1) => (s + t).map f = (s.map f) + (t.map f)) l\u2081 l\u2082\n          (fun s t => congrArg List.to_UnorderedList (List.map_append f s t))\n\n      @[simp] theorem mem_map {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : UnorderedList \u03b1} : b \u2208 s.map f \u2194 \u2203 a, a \u2208 s \u2227 f a = b :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          b \u2208 l.map f \u2194 \u2203 a, a \u2208 l \u2227 f a = b) s (fun _ => List.mem_map)\n\n      theorem congr {f g : \u03b1 \u2192 \u03b2} {s t : UnorderedList \u03b1} (h\u2081 : s = t) (h\u2082 : \u2200 x \u2208 t, f x = g x) :\n        s.map f = t.map g := h\u2081 \u25b8 @Quotient.inductionOn _ _\n            (fun (l : UnorderedList \u03b1) => (\u2200 x \u2208 l, f x = g x) \u2192 l.map f = l.map g) t\n            (fun l hl => congrArg List.to_UnorderedList (List.map_congr rfl hl)) h\u2082\n\n      theorem map_comp (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (s : UnorderedList \u03b1) : (s.map f).map g = s.map (g \u2218 f) :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => (l.map f).map g = l.map (g \u2218 f)) s\n          (fun l => congrArg List.to_UnorderedList (l.map_comp f g))\n\n      theorem map_id (s : UnorderedList \u03b1) : s.map id = s :=\n        @Quotient.ind _ _ (fun (l : UnorderedList \u03b1) => l.map id = l) (fun l =>\n          congrArg List.to_UnorderedList (List.map_id l)) s\n\n      @[simp] theorem length_map (f : \u03b1 \u2192 \u03b2) (s : UnorderedList \u03b1) : (s.map f).length = s.length :=\n        @Quotient.ind _ _ (fun (l : UnorderedList \u03b1) => (l.map f).length = l.length) (List.length_map f) s\n    end map\n\n    theorem nodup_map_on {f : \u03b1 \u2192 \u03b2} {s : UnorderedList \u03b1} (H : \u2200 x \u2208 s, \u2200 y \u2208 s, f x = f y \u2192 x = y) :\n      nodup s \u2192 nodup (s.map f) :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          (\u2200 (x : \u03b1), x \u2208 l \u2192 \u2200 (y : \u03b1), y \u2208 l \u2192 f x = f y \u2192 x = y) \u2192 nodup l \u2192 nodup (l.map f))\n            s (fun _ => List.nodup_map_on) H\n\n    theorem nodup_map {f : \u03b1 \u2192 \u03b2} {s : UnorderedList \u03b1} (hf : Function.injective f) :\n      nodup s \u2192 nodup (s.map f) :=\n        nodup_map_on (fun x _ y _ h => hf h)\n\n    theorem nodup_ext {s t : UnorderedList \u03b1} : nodup s \u2192 nodup t \u2192 (s = t \u2194 \u2200 a, a \u2208 s \u2194 a \u2208 t) :=\n      @Quotient.inductionOn\u2082 _ _ _ _\n        (fun (s' t' : UnorderedList \u03b1) => nodup s' \u2192 nodup t' \u2192 (s' = t' \u2194 \u2200 a, a \u2208 s' \u2194 a \u2208 t')) s t\n        (fun l\u2081 l\u2082 h\u2081 h\u2082 => Quotient.eq.trans (Perm.ext h\u2081 h\u2082))\n\n    inductive rel {\u03b1 : Type _} {\u03b2 : Type _} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) : UnorderedList \u03b1 \u2192 UnorderedList \u03b2 \u2192 Prop\n    | zero : rel r 0 0\n    | cons {a b as bs} : r a b \u2192 rel r as bs \u2192 rel r (as.cons a) (bs.cons b)\n\n    def pmap {p : \u03b1 \u2192 Prop} (f : \u2200 a, p a \u2192 \u03b2) (s : UnorderedList \u03b1) : (\u2200 a \u2208 s, p a) \u2192 UnorderedList \u03b2 :=\n      @Quotient.recOn _ _ (fun (l : UnorderedList \u03b1) => (\u2200 a \u2208 l, p a) \u2192 UnorderedList \u03b2) s\n        (fun l H => \u2191(l.pmap f H)) (fun l\u2081 l\u2082 pp => by\n          apply funext; intro h\u2082; have h\u2081 : \u2200 a, a \u2208 \u2191l\u2081 \u2192 p a := fun a h => h\u2082 a (pp.subset h)\n          have : \u2200 (s\u2082 e H), @Eq.rec (UnorderedList \u03b1) l\u2081\n            (fun l _ => (\u2200 a \u2208 l, p a) \u2192 UnorderedList \u03b2) (fun _ => \u2191(l\u2081.pmap f h\u2081))\n            s\u2082 e H = \u2191(l\u2081.pmap f h\u2081) := by\n              intro _ e _; subst e; rfl\n          have t\u2081 := this \u2191l\u2082 (Quot.sound pp) h\u2082\n          have t\u2082 := Quot.sound (@Perm.pmap _ _ _ f _ _ pp h\u2081 h\u2082)\n          exact t\u2081.trans t\u2082)\n\n    theorem nodup_pmap {p : \u03b1 \u2192 Prop} {f : \u2200 a, p a \u2192 \u03b2} {s : UnorderedList \u03b1} {H : \u2200 a \u2208 s, p a}\n    (hf : \u2200 a ha b hb, f a ha = f b hb \u2192 a = b) : nodup s \u2192 nodup (pmap f s H) :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n        (h : \u2200 a \u2208 l, p a) \u2192 nodup l \u2192 nodup (pmap f l h)) s (fun l hl => List.nodup_pmap hf) H\n\n    @[simp] theorem mem_pmap {p : \u03b1 \u2192 Prop} {f : \u2200 a, p a \u2192 \u03b2}\n      {s : UnorderedList \u03b1} {H : \u2200 a \u2208 s, p a} {b : \u03b2} : b \u2208 pmap f s H \u2194 \u2203 (a : \u03b1) (h : a \u2208 s), f a (H a h) = b :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          (H' : \u2200 a \u2208 l, p a) \u2192 b \u2208 pmap f l H' \u2194 \u2203 (a : \u03b1) (h : a \u2208 l), f a (H' a h) = b) s\n          (fun l h => List.mem_pmap) H\n\n    theorem pmap_empty {p : \u03b1 \u2192 Prop} (f : \u2200 a, p a \u2192 \u03b2) : pmap f 0 (fun _ _ => by contradiction) = 0 := rfl\n\n    theorem pmap_length {p : \u03b1 \u2192 Prop} (f : \u2200 a, p a \u2192 \u03b2) {s : UnorderedList \u03b1} (H : \u2200 a \u2208 s, p a) : (s.pmap f H).length = s.length :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => (H : \u2200 a \u2208 l, p a) \u2192 (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 : \u03b1 \u2192 Prop) (s : UnorderedList \u03b1) : UnorderedList \u03b1 :=\n        Quot.liftOn s (fun l => (l.filter' p : UnorderedList \u03b1))\n          (fun l\u2081 l\u2082 h => Quot.sound (h.filter' p))\n\n      @[simp] theorem filter_add (s t : UnorderedList \u03b1) : filter p (s + t) = filter p s + filter p t :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => filter p (l\u2081 + l\u2082) = filter p l\u2081 + filter p l\u2082) s t\n          (fun l\u2081 l\u2082 => congrArg List.to_UnorderedList (List.filter'_append _ _))\n\n      theorem nodup_filter (p : \u03b1 \u2192 Prop) {l : UnorderedList \u03b1} : nodup l \u2192 nodup (filter p l) :=\n        @Quotient.inductionOn _ _ (fun (s : UnorderedList \u03b1) =>\n          nodup s \u2192 nodup (filter p s)) l fun l => List.nodup_filter' p\n\n      @[simp] theorem filter_cons_of_pos {a : \u03b1} (s : UnorderedList \u03b1) :\n        p a \u2192 filter p (s.cons a) = (filter p s).cons a :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n            p a \u2192 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 : \u03b1} (s : UnorderedList \u03b1) :\n        \u00ac p a \u2192 filter p (s.cons a) = filter p s :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n            \u00ac p a \u2192 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 : \u03b1} {s : UnorderedList \u03b1} : a \u2208 filter p s \u2194 a \u2208 s \u2227 p a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          a \u2208 filter p l \u2194 a \u2208 l \u2227 p a) s fun l => List.mem_filter'\n\n      theorem of_mem_filter {a : \u03b1} {s : UnorderedList \u03b1} (h : a \u2208 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 : \u03b1) (s : UnorderedList \u03b1) : UnorderedList \u03b1 :=\n        Quot.liftOn s (fun l => (l.insert a : UnorderedList \u03b1))\n          (fun s t p => Quot.sound (p.insert a))\n\n      @[simp] theorem coe_ndinsert (a : \u03b1) (l : List \u03b1) : ndinsert a l = (l.insert a : List \u03b1) := rfl\n\n      @[simp] theorem ndinsert_of_mem {a : \u03b1} {s : UnorderedList \u03b1} : a \u2208 s \u2192 ndinsert a s = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => a \u2208 l \u2192 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 : \u03b1} {s : UnorderedList \u03b1} : a \u2209 s \u2192 ndinsert a s = s.cons a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          a \u2209 l \u2192 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 : \u03b1) : ndinsert a 0 = UnorderedList.singleton a :=\n        ndinsert_of_not_mem (fun _ => by contradiction)\n\n      @[simp] theorem mem_ndinsert {a b : \u03b1} {s : UnorderedList \u03b1} : a \u2208 ndinsert b s \u2194 a = b \u2228 a \u2208 s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          a \u2208 ndinsert b l \u2194 a = b \u2228 a \u2208 l) s fun l => List.mem_insert_iff\n\n      @[simp] theorem mem_ndinsert_self (a : \u03b1) (s : UnorderedList \u03b1) : a \u2208 ndinsert a s :=\n        mem_ndinsert.mpr (Or.inl rfl)\n\n      theorem mem_ndinsert_of_mem {a b : \u03b1} {s : UnorderedList \u03b1} (h : a \u2208 s) : a \u2208 ndinsert b s :=\n        mem_ndinsert.mpr (Or.inr h)\n\n      theorem nodup_ndinsert (a : \u03b1) {s : UnorderedList \u03b1} : nodup s \u2192 nodup (ndinsert a s) :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => nodup l \u2192 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 \u03b1) : UnorderedList \u03b1 :=\n        @Quotient.liftOn\u2082 _ _ _ _ _ s t (fun l\u2081 l\u2082 => \u2191(l\u2081 \u222a l\u2082)) (fun _ _ _ _ p\u2081 p\u2082 => Quot.sound (p\u2081.union p\u2082))\n\n      @[simp] theorem coe_ndunion (l\u2081 l\u2082 : List \u03b1) : @ndunion \u03b1 l\u2081 l\u2082 = (l\u2081 \u222a l\u2082 : List \u03b1) := rfl\n\n      @[simp] theorem zero_ndunion (s : UnorderedList \u03b1) : ndunion 0 s = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => ndunion 0 l = l) s\n          fun _ => rfl\n\n      @[simp] theorem cons_ndunion (s t : UnorderedList \u03b1) (a : \u03b1) :\n        ndunion (s.cons a) t = ndinsert a (ndunion s t) :=\n          @Quotient.inductionOn\u2082 _ _ _ _ (fun (l\u2081 l\u2082 : UnorderedList \u03b1) =>\n            ndunion (l\u2081.cons a) l\u2082 = ndinsert a (ndunion l\u2081 l\u2082)) s t fun _ _ => rfl\n\n      @[simp] theorem mem_ndunion {s t : UnorderedList \u03b1} {a : \u03b1} : a \u2208 ndunion s t \u2194 a \u2208 s \u2228 a \u2208 t :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => a \u2208 ndunion l\u2081 l\u2082 \u2194 a \u2208 l\u2081 \u2228 a \u2208 l\u2082) s t\n          (fun l\u2081 l\u2082 => List.mem_union)\n\n      theorem nodup_ndunion (s : UnorderedList \u03b1) {t : UnorderedList \u03b1} : nodup t \u2192 nodup (ndunion s t) :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => nodup l\u2082 \u2192 nodup (ndunion l\u2081 l\u2082)) s t\n          (fun l\u2081 l\u2082 => List.nodup_union l\u2081)\n\n    end ndunion\n\n    section ndinter\n\n      noncomputable def ndinter (s t : UnorderedList \u03b1) : UnorderedList \u03b1 := s.filter (\u00b7 \u2208 t)\n\n      @[simp] theorem zero_ndinter (s : UnorderedList \u03b1) : ndinter 0 s = 0 := rfl\n\n      @[simp] theorem cons_ndinter_of_mem {a : \u03b1} (s : UnorderedList \u03b1) {t : UnorderedList \u03b1} (h : a \u2208 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 : \u03b1} (s : UnorderedList \u03b1) {t : UnorderedList \u03b1} (h : a \u2209 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 \u03b1} {a : \u03b1} : a \u2208 ndinter s t \u2194 a \u2208 s \u2227 a \u2208 t :=\n        mem_filter\n\n      @[simp] theorem nodup_ndinter {s : UnorderedList \u03b1} (t : UnorderedList \u03b1) : nodup s \u2192 nodup (ndinter s t) :=\n        nodup_filter _\n\n    end ndinter\n\n    protected def le (s t : UnorderedList \u03b1) : Prop :=\n        Quotient.liftOn\u2082 s t (\u00b7 <+~ \u00b7) (fun _ _ _ _ p\u2081 p\u2082 =>\n          propext (p\u2082.subperm_left.trans p\u2081.subperm_right))\n\n    namespace le\n      instance UnorderedListle : LE (UnorderedList \u03b1) where le := UnorderedList.le\n\n      protected theorem refl (a : UnorderedList \u03b1) : a \u2264 a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => l \u2264 l) a\n          Perm.Subperm.refl\n\n      protected theorem trans {a b c : UnorderedList \u03b1} : a \u2264 b \u2192 b \u2264 c \u2192 a \u2264 c :=\n        @Quotient.inductionOn\u2083 _ _ _ _ _ _\n          (fun (l\u2081 l\u2082 l\u2083 : UnorderedList \u03b1) => l\u2081 \u2264 l\u2082 \u2192 l\u2082 \u2264 l\u2083 \u2192 l\u2081 \u2264 l\u2083) a b c\n          (fun l\u2081 l\u2082 l\u2083 => Perm.Subperm.trans)\n\n      protected theorem antisymm {a b : UnorderedList \u03b1} : a \u2264 b \u2192 b \u2264 a \u2192 a = b :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2081 \u2264 l\u2082 \u2192 l\u2082 \u2264 l\u2081 \u2192 l\u2081 = l\u2082) a b\n          (fun l\u2081 l\u2082 h\u2081 h\u2082 => Quot.sound (Perm.Subperm.antisymm h\u2081 h\u2082))\n\n      protected theorem of_eq {a b : UnorderedList \u03b1} (h : a = b) : a \u2264 b := by rw [h]; exact le.refl _\n\n      @[simp] theorem subperm {l\u2081 l\u2082 : List \u03b1} : (l\u2081 : UnorderedList \u03b1) \u2264 l\u2082 \u2194 l\u2081 <+~ l\u2082 := Iff.rfl\n\n      variable {s t : UnorderedList \u03b1} {a : \u03b1}\n\n      theorem subset_of_le : s \u2264 t \u2192 s \u2286 t :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2081 \u2264 l\u2082 \u2192 l\u2081 \u2286 l\u2082) s t\n          (fun l\u2081 l\u2082 h => Perm.Subperm.subset (le.subperm.mp h))\n\n      theorem mem_of_le (h : s \u2264 t) : a \u2208 s \u2192 a \u2208 t :=\n        have := subset_of_le h\n        @this a\n\n      theorem not_mem_mono (h : s \u2286 t) : a \u2209 t \u2192 a \u2209 s := mt (@h _)\n\n      theorem zero_le (s : UnorderedList \u03b1) : 0 \u2264 s :=\n        Quot.inductionOn s fun l => (List.Sublist.nil_sublist l).subperm\n\n      theorem le_zero : s \u2264 0 \u2194 s = 0 := \u27e8fun h => le.antisymm h (zero_le _), le.of_eq\u27e9\n\n      theorem le_iff_subset {s t : UnorderedList \u03b1} : nodup s \u2192 (s \u2264 t \u2194 s \u2286 t) :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => nodup l\u2081 \u2192 (l\u2081 \u2264 l\u2082 \u2194 l\u2081 \u2286 l\u2082)) s t\n          fun l\u2081 l\u2082 d => \u27e8subset_of_le, Perm.Subperm.subperm_of_subset_nodup d\u27e9\n\n      theorem le_induction_on {C : UnorderedList \u03b1 \u2192 UnorderedList \u03b1 \u2192 Prop}\n        (h : s \u2264 t) (H : \u2200 {l\u2081 l\u2082 : List \u03b1}, l\u2081 <+ l\u2082 \u2192 C l\u2081 l\u2082) : C s t :=\n          @Quotient.inductionOn\u2082 _ _ _ _\n            (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2081 \u2264 l\u2082 \u2192 C l\u2081 l\u2082) s t\n            (fun l\u2081 l\u2082 \u27e8l, p, s'\u27e9 => by simp; rw [\u2190list_perm_eq p]; exact H s') h\n\n      theorem nodup_of_le (h : s \u2264 t) : nodup t \u2192 nodup s :=\n        @le_induction_on \u03b1 s t (fun a b => nodup b \u2192 nodup a)\n          h List.nodup_of_sublist\n\n      theorem cons_self (s : UnorderedList \u03b1) (a : \u03b1) : s \u2264 s.cons a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => l \u2264 l.cons a)\n          s fun l => (List.Sublist.sublist_cons a l).subperm\n\n      theorem cons_of_le {s t : UnorderedList \u03b1} (a : \u03b1) (h : s \u2264 t) : s \u2264 t.cons a :=\n        le.trans h (cons_self t a)\n\n      theorem cons_le_cons_iff (a : \u03b1) {s t : UnorderedList \u03b1} : s.cons a \u2264 t.cons a \u2194 s \u2264 t :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2081.cons a \u2264 l\u2082.cons a \u2194 l\u2081 \u2264 l\u2082) s t\n          fun l\u2081 l\u2082 => Perm.Subperm.subperm_cons a\n\n      theorem cons_le_cons (a : \u03b1) : s \u2264 t \u2192 s.cons a \u2264 t.cons a := (cons_le_cons_iff a).mpr\n\n      theorem le_cons_of_not_mem (m : a \u2209 s) : s \u2264 t.cons a \u2194 s \u2264 t :=\n        \u27e8have : \u2200 {t' : UnorderedList \u03b1} (h\u2081 : s \u2264 t') (h\u2082 : a \u2208 t'), s.cons a \u2264 t' := by\n          intro t' h; revert m\n          exact @le_induction_on \u03b1 s t' (fun l\u2081 l\u2082 => a \u2209 l\u2081 \u2192 a \u2208 l\u2082 \u2192 l\u2081.cons a \u2264 l\u2082) h (by\n            intro l\u2081 l\u2082 s m\u2081 m\u2082; let \u27e8r\u2081, r\u2082, h'\u27e9 := List.mem_split m\u2082; rw [h'] at s \u22a2\n            exact (Perm.middle a r\u2081 r\u2082).subperm_left.mpr ((Perm.Subperm.subperm_cons a).mpr ((List.Sublist.sublist_or_mem_of_sublist s).resolve_right m\u2081).subperm))\n        fun h => (cons_le_cons_iff a).mp (this h (mem_cons_self _ _)),\n        cons_of_le a\u27e9\n\n      theorem add_right (s t : UnorderedList \u03b1) : s \u2264 s + t :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          s \u2264 s + l) t (fun l => by\n            induction l with\n            | nil => exact (by simp; exact le.refl _ : s \u2264 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 \u03b1) : s \u2264 t + s := by\n        rw [append.comm]; exact add_right s t\n\n      theorem le_iff_exists_add {s t : UnorderedList \u03b1} : s \u2264 t \u2194 \u2203 u, t = s + u :=\n        \u27e8fun h => @le_induction_on \u03b1 s t (fun l\u2081 l\u2082 => \u2203 u, l\u2082 = l\u2081 + u) h (fun s =>\n          let \u27e8l, p\u27e9 := s.exists_perm_append\n          \u27e8l, Quot.sound p\u27e9),\n        fun \u27e8u, e\u27e9 => e.symm \u25b8 add_right s u\u27e9\n\n      theorem add_le_add_left (s : UnorderedList \u03b1) {t u : UnorderedList \u03b1} : s + t \u2264 s + u \u2194 t \u2264 u :=\n        @Quotient.inductionOn\u2083 _ _ _ _ _ _\n          (fun (l\u2081 l\u2082 l\u2083 : UnorderedList \u03b1) => l\u2081 + l\u2082 \u2264 l\u2081 + l\u2083 \u2194 l\u2082 \u2264 l\u2083) s t u\n          fun l\u2081 l\u2082 l\u2083 => Perm.Subperm.subperm_append_left l\u2081\n\n      theorem add_le_add_right {s t : UnorderedList \u03b1} (u : UnorderedList \u03b1): s + u \u2264 t + u \u2194 s \u2264 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 \u03b1} : s + t \u2264 s + u \u2192 t \u2264 u :=\n        (add_le_add_left s).mp\n\n      @[simp] theorem filter_le (p : \u03b1 \u2192 Prop) (s : UnorderedList \u03b1) : filter p s \u2264 s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          filter p l \u2264 l) s fun l => (List.filter'_sublist _).subperm\n\n      theorem not_cons_self (s : UnorderedList \u03b1) (a : \u03b1) : \u00ac (s.cons a \u2264 s) :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => \u00ac (l.cons a \u2264 l)) s\n          (fun l => Perm.Subperm.not_cons_self l a)\n\n      theorem ne_iff_cons {s t : UnorderedList \u03b1} (h : s \u2264 t) : s \u2260 t \u2194 \u2203 a, s.cons a \u2264 t :=\n        \u27e8@Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2081 \u2264 l\u2082 \u2192 l\u2081 \u2260 l\u2082 \u2192 \u2203 a, l\u2081.cons a \u2264 l\u2082) s t\n          (fun l\u2081 l\u2082 h' he =>\n            have p' : \u00ac l\u2081 ~ l\u2082 := by intro p; exact he (Quot.sound p)\n            Perm.Subperm.exists_of_subperm_ne h' p') h,\n        fun \u27e8a, ha\u27e9 he => by rw [he] at ha; exact absurd ha (not_cons_self t a)\u27e9\n\n    end le\n\n    theorem length.le_of_le {s t : UnorderedList \u03b1} (h : s \u2264 t) : length s \u2264 length t :=\n      @le.le_induction_on \u03b1 s t (fun l\u2081 l\u2082 => length l\u2081 \u2264 length l\u2082) h\n        List.Sublist.length_le_of_sublist\n\n    open Classical\n\n    protected noncomputable def erase (s : UnorderedList \u03b1) (a : \u03b1) : UnorderedList \u03b1 :=\n        Quotient.liftOn s (fun l => (l.erase a : UnorderedList \u03b1))\n          fun l\u2081 l\u2082 p => list_perm_eq (p.erase a)\n\n    namespace erase\n      @[simp] theorem coe_erase (l : List \u03b1) (a : \u03b1) :\n        (l : UnorderedList \u03b1).erase a = l.erase a := rfl\n\n      @[simp] theorem erase_zero (a : \u03b1) : (0 : UnorderedList \u03b1).erase a = 0 := rfl\n\n      @[simp] theorem erase_cons_head (a : \u03b1) (s : UnorderedList \u03b1) : (s.cons a).erase a = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => (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 : \u03b1} (s : UnorderedList \u03b1) (h : b \u2260 a) :\n        (s.cons b).erase a = (s.erase a).cons b :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => (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 : \u03b1} {s : UnorderedList \u03b1} : a \u2209 s \u2192 s.erase a = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          a \u2209 l \u2192 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 \u03b1} {a : \u03b1} : a \u2208 s \u2192 (s.erase a).cons a = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          a \u2208 l \u2192 (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 \u03b1) (a : \u03b1) : s \u2264 (s.erase a).cons a :=\n        if h : a \u2208 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 : \u03b1) (s : UnorderedList \u03b1) : s.erase a \u2264 s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          l.erase a \u2264 l) s fun l => (List.erase_sublist a l).subperm\n\n      theorem erase_le_iff_le_cons {s t : UnorderedList \u03b1} {a : \u03b1} : s.erase a \u2264 t \u2194 s \u2264 t.cons a :=\n        \u27e8fun h => le.trans (erase.le_cons_erase _ _) (le.cons_le_cons _ h),\n        fun h => if m : a \u2208 s then by\n          rw [\u2190cons_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)\u27e9\n\n      theorem erase_le_erase {s t : UnorderedList \u03b1} (a : \u03b1) (h : s \u2264 t) : s.erase a \u2264 t.erase a :=\n        @le.le_induction_on \u03b1 s t (fun l\u2081 l\u2082 => l\u2081.erase a \u2264 l\u2082.erase a) h\n          fun h' => (h'.erase _).subperm\n\n      theorem nodup_erase_eq_filter (a : \u03b1) {s : UnorderedList \u03b1} : nodup s \u2192 s.erase a = filter (\u00b7 \u2260 a) s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          nodup l \u2192 l.erase a = filter (\u00b7 \u2260 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 : \u03b1) {l : UnorderedList \u03b1} : nodup l \u2192 nodup (l.erase a) :=\n        le.nodup_of_le (erase_le _ _)\n\n      theorem mem_erase_iff_of_nodup {a b : \u03b1} {l : UnorderedList \u03b1} (d : nodup l) :\n        a \u2208 l.erase b \u2194 a \u2260 b \u2227 a \u2208 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 : \u03b1} {l : UnorderedList \u03b1} (h : nodup l) : a \u2209 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 \u03b1) : UnorderedList \u03b1 :=\n      Quotient.liftOn\u2082 s t (fun l\u2081 l\u2082 => (l\u2081.diff l\u2082 : UnorderedList \u03b1))\n        (fun _ _ _ _ p\u2081 p\u2082 => Quot.sound (p\u2081.diff p\u2082))\n\n    namespace sub\n\n      noncomputable instance : Sub (UnorderedList \u03b1) where sub := UnorderedList.sub\n\n      @[simp] protected theorem sub_zero (s : UnorderedList \u03b1) : s - 0 = s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => l - 0 = l) s fun l => rfl\n\n      @[simp] theorem sub_cons (a : \u03b1) (s t : UnorderedList \u03b1) : s - t.cons a = s.erase a - t :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2081 - l\u2082.cons a = l\u2081.erase a - l\u2082) s t\n          fun l\u2081 l\u2082 => congrArg List.to_UnorderedList (List.diff_cons _ _ _)\n\n      theorem sub_le_iff_le_add_right {s t : UnorderedList \u03b1} : s - t \u2264 u \u2194 s \u2264 u + t := by\n        revert s\n        exact @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          \u2200 s, s - l \u2264 u \u2194 s \u2264 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 \u2264 u \u2194 s \u2264 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 \u03b1} : s - t \u2264 u \u2194 s \u2264 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 \u03b1) : s \u2264 (s - t) + t :=\n        sub_le_iff_le_add_right.mp (le.refl _)\n\n      theorem le_add_sub (s t : UnorderedList \u03b1) : s \u2264 t + (s - t) :=\n        sub_le_iff_le_add_left.mp (le.refl _)\n\n      theorem add_sub_le_left {s t : UnorderedList \u03b1}: s + t - s \u2264 t :=\n        sub_le_iff_le_add_left.mpr (le.refl _)\n\n      theorem sub_le_sub_right {s t : UnorderedList \u03b1} (h : s \u2264 t) (u : UnorderedList \u03b1) : s - u \u2264 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 \u03b1) : s - t \u2264 s :=\n      sub.sub_le_iff_le_add_left.mpr (le.add_left s t)\n\n    theorem filter_eq_self {s : UnorderedList \u03b1} : filter p s = s \u2194 \u2200 a \u2208 s, p a :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          filter p l = l \u2194 \u2200 a \u2208 l, p a) s fun l => Iff.trans \u27e8fun h =>\n            List.Sublist.eq_of_sublist_of_length_eq (List.filter'_sublist _) (@congrArg _ _ _ _ length h),\n            congrArg List.to_UnorderedList\u27e9 List.filter'_eq_self\n\n    theorem filter_le_filter (p : \u03b1 \u2192 Prop) {s t : UnorderedList \u03b1} (h : s \u2264 t) : filter p s \u2264 filter p t :=\n      @le.le_induction_on \u03b1 s t (fun l\u2081 l\u2082 => filter p l\u2081 \u2264 filter p l\u2082) h\n        (fun h => (h.filter' p).subperm)\n\n    theorem le.le_filter {s t : UnorderedList \u03b1} : s \u2264 filter p t \u2194 s \u2264 t \u2227 \u2200 a \u2208 s, p a :=\n      \u27e8fun h => \u27e8le.trans h (filter_le _ _), fun a m => of_mem_filter (mem_of_le h m)\u27e9,\n        fun \u27e8h, al\u27e9 => filter_eq_self.mpr al \u25b8 filter_le_filter p h\u27e9\n\n    noncomputable def countp (p : \u03b1 \u2192 Prop) (s : UnorderedList \u03b1) : Nat :=\n      Quot.liftOn s (List.countp p) (fun l\u2081 l\u2082 h => Perm.countp_eq p h)\n\n    namespace countp\n      variable (p : \u03b1 \u2192 Prop)\n\n      @[simp] theorem coe_countp (l : List \u03b1) : 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 : \u03b1} (s : UnorderedList \u03b1) :\n        p a \u2192 countp p (s.cons a) = countp p s + 1 :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n            p a \u2192 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 : \u03b1} (s : UnorderedList \u03b1) :\n        \u00ac p a \u2192 countp p (s.cons a) = countp p s :=\n          @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n            \u00ac p a \u2192 countp p (l.cons a) = countp p l) s (List.countp_cons_of_neg p)\n\n      theorem cons (b : \u03b1) (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 \u03b1) : countp p s = length (filter p s) :=\n        @Quotient.inductionOn _ _\n          (fun (l : UnorderedList \u03b1) => countp p l = length (filter p l)) s\n            fun l => List.countp_eq_length_filter' _ _\n\n      @[simp] theorem add (s t : UnorderedList \u03b1) : countp p (s + t) = countp p s + countp p t := by\n        simp [countp_eq_length_filter]\n\n      theorem pos {s : UnorderedList \u03b1} : 0 < countp p s \u2194 \u2203 a \u2208 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 : \u03b1) : UnorderedList \u03b1 \u2192 Nat := countp (Eq a)\n\n    namespace count\n\n      @[simp] theorem zero (a : \u03b1) : count a 0 = 0 := rfl\n\n      @[simp] theorem cons_self (a : \u03b1) (s : UnorderedList \u03b1) : count a (s.cons a) = (count a s).succ :=\n        countp.cons_of_pos _ rfl\n\n      @[simp] theorem cons_of_ne {a b : \u03b1} (h : a \u2260 b) (s : UnorderedList \u03b1) :\n        count a (s.cons b) = count a s :=\n          countp.cons_of_neg _ h\n\n      theorem cons (a b : \u03b1) (s : UnorderedList \u03b1) :\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 : \u03b1) : count a (UnorderedList.singleton a) = 1 := by\n        simp only [cons_self, singleton_eq_cons, zero]\n\n      theorem singleton (a b : \u03b1) : 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 : \u03b1) : \u2200 s t, count a (s + t) = count a s + count a t :=\n          countp.add _\n\n      theorem pos {a : \u03b1} {s : UnorderedList \u03b1} : 0 < count a s \u2194 a \u2208 s := by\n        simp [count, countp.pos]\n        exact \u27e8fun \u27e8x, xs, ax\u27e9 => by rw [ax]; exact xs, fun as => \u27e8a, as, rfl\u27e9\u27e9\n\n      @[simp] theorem eq_zero {a : \u03b1} {s : UnorderedList \u03b1} : count a s = 0 \u2194 a \u2209 s :=\n        iff_not_comm.mp (pos.symm.trans Nat.pos_iff_ne_zero)\n\n      @[simp] theorem erase_self (a : \u03b1) (s : UnorderedList \u03b1) :\n        count a (s.erase a) = Nat.pred (count a s) := by\n          byCases h : a \u2208 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 : \u03b1} (ab : a \u2260 b) (s : UnorderedList \u03b1) :\n        count a (s.erase b) = count a s := by\n          byCases h : b \u2208 s\n          rw [\u2190count.cons_of_ne ab, erase.cons_erase h]\n          rw [erase.erase_of_not_mem h]\n\n      @[simp] theorem sub (a : \u03b1) (s t : UnorderedList \u03b1) : count a (s - t) = count a s - count a t := by\n        revert s; exact @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          \u2200 (s : UnorderedList \u03b1), 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 \u22a2; 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 \u03b1} : nodup s \u2194 \u2200 a, count a s \u2264 1 :=\n      @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n        nodup l \u2194 \u2200 a, count a l \u2264 1) s fun l => List.nodup_iff_count_le_one\n\n    theorem sub.mem_sub_of_nodup {a : \u03b1} {s t : UnorderedList \u03b1} (d : nodup s) :\n      a \u2208 s - t \u2194 a \u2208 s \u2227 a \u2209 t :=\n        \u27e8fun h => \u27e8le.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\u27e9,\n        fun \u27e8h\u2081, h\u2082\u27e9 => Or.resolve_right (append.mem_add.mp (le.mem_of_le (sub.le_sub_add  s t) h\u2081)) h\u2082\u27e9\n\n    @[simp] theorem le.add_sub_cancel_of_le {s t : UnorderedList \u03b1} (h : s \u2264 t) : s + (t - s) = t :=\n      le.antisymm (by\n          let \u27e8c, e\u27e9 := le_iff_exists_add.mp h\n          rw [e] at h \u22a2\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 \u03b1} (h : s \u2264 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 : \u03b1) (s : UnorderedList \u03b1) : s \u2264 ndinsert a s :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          l \u2264 ndinsert a l) s fun l => (List.Sublist.insert _ _).subperm\n\n      theorem ndinsert_le {a : \u03b1} {s t : UnorderedList \u03b1} : ndinsert a s \u2264 t \u2194 s \u2264 t \u2227 a \u2208 t :=\n        \u27e8fun h => \u27e8le.trans (le_ndinsert_self _ _) h, le.mem_of_le h (mem_ndinsert_self _ _)\u27e9,\n        fun \u27e8l, m\u27e9 => if h : a \u2208 s then by\n          simp [h, l]\n        else by\n          rw [ndinsert_of_not_mem h, \u2190 erase.cons_erase m, le.cons_le_cons_iff,\n            \u2190le.le_cons_of_not_mem h, erase.cons_erase m]; exact l\u27e9\n\n    end ndinsert\n\n    section ndunion\n\n      theorem ndunion_le {s t u : UnorderedList \u03b1} : ndunion s t \u2264 u \u2194 s \u2286 u \u2227 t \u2264 u :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) =>\n          ndunion l t \u2264 u \u2194 l \u2286 u \u2227 t \u2264 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 \u27e8fun \u27e8\u27e8h\u2081, h\u2082\u27e9, h\u2083\u27e9 => \u27e8fun x hx => Or.elim (mem_cons.mp hx)\n                  (fun h => by rw [h]; exact h\u2083) (fun h => h\u2081 h), h\u2082\u27e9,\n                fun \u27e8h\u2081, h\u2082\u27e9 => \u27e8\u27e8fun x hx => h\u2081 (mem_cons_of_mem hx), h\u2082\u27e9,\n                  h\u2081 (mem_cons_self a \u2191l)\u27e9\u27e9)\n\n      theorem le_ndunion_right (s t : UnorderedList \u03b1) : t \u2264 ndunion s t :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2082 \u2264 ndunion l\u2081 l\u2082) s t\n          fun l\u2081 l\u2082 => Perm.Subperm.union_left l\u2082 l\u2081\n\n      theorem subset_ndunion_right (s t : UnorderedList \u03b1) : t \u2286 ndunion s t :=\n        le.subset_of_le (le_ndunion_right s t)\n\n      theorem subset_ndunion_left (s t : UnorderedList \u03b1) : s \u2286 ndunion s t :=\n        fun a h => mem_ndunion.mpr (Or.inl h)\n\n      theorem le_ndunion_left {s} (t : UnorderedList \u03b1) (d : nodup s) : s \u2264 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 \u03b1) : UnorderedList \u03b1 := s - t + t\n\n      noncomputable instance : Union (UnorderedList \u03b1) where union := UnorderedList.union\n\n      theorem le_union_left (s t : UnorderedList \u03b1) : s \u2264 s \u222a t := sub.le_sub_add s t\n\n      theorem le_union_right (s t : UnorderedList \u03b1) : t \u2264 s \u222a t := le.add_left t (s - t)\n\n      theorem eq_union_left {s t : UnorderedList \u03b1} : t \u2264 s \u2192 s \u222a t = s := le.sub_add_cancel_of_le\n\n      theorem union_le_union_right {s t : UnorderedList \u03b1} (h : s \u2264 t) (u : UnorderedList \u03b1) : s \u222a u \u2264 t \u222a 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 \u03b1} (h\u2081 : s \u2264 u) (h\u2082 : t \u2264 u) : s \u222a t \u2264 u := by\n        rw [\u2190eq_union_left h\u2082]; exact union_le_union_right h\u2081 t\n\n      theorem ndunion_le_union (s t : UnorderedList \u03b1) : ndunion s t \u2264 s \u222a t :=\n        ndunion_le.mpr \u27e8le.subset_of_le (le_union_left _ _), le_union_right _ _\u27e9\n\n      @[simp] theorem ndunion_eq_union {s t : UnorderedList \u03b1} (d : nodup s) : ndunion s t = s \u222a 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 \u03b1} : s \u2264 ndinter t u \u2194 s \u2264 t \u2227 s \u2286 u := by\n        simp [ndinter, le.le_filter]; exact Iff.rfl\n\n      theorem ndinter_le_left (s t : UnorderedList \u03b1) : ndinter s t \u2264 s :=\n        (le_ndinter.mp (le.refl _)).left\n\n      theorem ndinter_subset_left (s t : UnorderedList \u03b1) : ndinter s t \u2286 s :=\n        le.subset_of_le (ndinter_le_left s t)\n\n      theorem ndinter_subset_right (s t : UnorderedList \u03b1) : ndinter s t \u2286 t :=\n        (le_ndinter.mp (le.refl _)).right\n\n      theorem ndinter_le_right {s} (t : UnorderedList \u03b1) (d : nodup s) : ndinter s t \u2264 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 \u03b1) : UnorderedList \u03b1 :=\n        Quotient.liftOn\u2082 s t (fun l\u2081 l\u2082 => (l\u2081.bag_inter l\u2082 : UnorderedList \u03b1)) fun _ _ _ _ p\u2081 p\u2082 =>\n          Quot.sound (p\u2081.bag_inter p\u2082)\n\n      noncomputable instance UnorderedListIntersection : Intersection (UnorderedList \u03b1) where intersection := inter\n\n      @[simp] theorem inter_zero (s : UnorderedList \u03b1) : s \u2229 0 = 0 :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => l \u2229 0 = 0) s\n          fun l => congrArg List.to_UnorderedList l.bag_inter_nil\n\n      @[simp] theorem zero_inter (s : UnorderedList \u03b1) : 0 \u2229 s = 0 :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => 0 \u2229 l = 0) s\n          fun l => congrArg List.to_UnorderedList l.nil_bag_inter\n\n      @[simp] theorem cons_inter_of_pos {a : \u03b1} (s : UnorderedList \u03b1) {t : UnorderedList \u03b1} :\n        a \u2208 t \u2192 (s.cons a) \u2229 t = (s \u2229 t.erase a).cons a :=\n          @Quotient.inductionOn\u2082 _ _ _ _\n            (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => a \u2208 l\u2082 \u2192 (l\u2081.cons a) \u2229 l\u2082 = (l\u2081 \u2229 l\u2082.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 \u03b1) {t} :\n        a \u2209 t \u2192 (s.cons a) \u2229 t = s \u2229 t :=\n          @Quotient.inductionOn\u2082 _ _ _ _\n            (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => a \u2209 l\u2082 \u2192 (l\u2081.cons a) \u2229 l\u2082 = l\u2081 \u2229 l\u2082) 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 \u03b1) : s \u2229 t \u2264 s :=\n        @Quotient.inductionOn\u2082 _ _ _ _\n          (fun (l\u2081 l\u2082 : UnorderedList \u03b1) => l\u2081 \u2229 l\u2082 \u2264 l\u2081) s t fun _ _ =>\n            (List.bag_inter_sublist_left _ _).subperm\n\n      theorem inter_le_right (s : UnorderedList \u03b1) : \u2200 t, s \u2229 t \u2264 t :=\n        @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1) => \u2200 t, l \u2229 t \u2264 t) s\n          (fun l => by\n            induction l with\n            | nil => exact fun t => (zero_inter t).symm \u25b8 le.zero_le _\n            | cons a s ih =>\n              intro t; byCases h : a \u2208 t\n              { have := le.cons_le_cons a (ih (t.erase a));\n                rw [erase.cons_erase h, \u2190cons_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 \u03b1} (h\u2081 : s \u2264 t) (h\u2082 : s \u2264 u) : s \u2264 t \u2229 u := by\n        revert s u; exact @Quotient.inductionOn _ _ (fun (l : UnorderedList \u03b1)\n          => \u2200 {u s : UnorderedList \u03b1}, s \u2264 l \u2192 s \u2264 u \u2192 s \u2264 l \u2229 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\u2081 h\u2082\n              byCases h : a \u2208 u\n              { rw [list_coe_eq, cons_eq, cons_inter_of_pos _ h, \u2190erase.erase_le_iff_le_cons]\n                exact ih (erase.erase_le_iff_le_cons.mpr h\u2081) (erase.erase_le_erase _ h\u2082) }\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\u2082) h)).mp h\u2081) h\u2082 })\n\n      @[simp] theorem mem_inter {s t : UnorderedList \u03b1} : a \u2208 s \u2229 t \u2194 a \u2208 s \u2227 a \u2208 t :=\n        \u27e8fun h => \u27e8le.mem_of_le (inter_le_left _ _) h, le.mem_of_le (inter_le_right _ _) h\u27e9,\n        fun \u27e8h\u2081, h\u2082\u27e9 => by rw [\u2190 erase.cons_erase h\u2081, cons_inter_of_pos _ h\u2082]; exact mem_cons_self a _\u27e9\n\n      theorem inter_le_ndinter (s t : UnorderedList \u03b1) : s \u2229 t \u2264 ndinter s t :=\n        le_ndinter.mpr \u27e8inter_le_left _ _, le.subset_of_le (inter_le_right _ _)\u27e9\n\n      @[simp] theorem ndinter_eq_inter {s t : UnorderedList \u03b1} (d : nodup s) : ndinter s t = s \u2229 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 \u03b1) : 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 [\u2190append.assoc]; exact sub.le_add_sub s _)\n\n      theorem le_add_sub' (s t : UnorderedList \u03b1) : s \u2264 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 \u03b1) : s \u2264 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 \u03b1} (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 \u03b1) : 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 \u03b1) : (s \u222a t) + u = (s + u) \u222a (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 \u03b1) : (s \u2229 t) + u = (s + u) \u2229 (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 \u27e8a, ha\u27e9 := (le.ne_iff_cons this).mp h\n      rw [\u2190 append.cons_over_left] at ha\n      have : (s \u2229 t).cons a = s \u2229 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 \u2229 t)))\n      apply Nat.succ_ne_self (length (s \u2229 t))\n      rw [\u2190Nat.add_one, \u2190length.cons a (s \u2229 t)]\n      exact congrArg length this\n\n    theorem add_inter_distrib (s t u : UnorderedList \u03b1) : s + (t \u2229 u) = (s + t) \u2229 (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 \u03b1) : s \u222a t + s \u2229 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 \u03b1) : UnorderedList \u03b1 :=\n      Quotient.liftOn s (fun l => (l.dedup : UnorderedList \u03b1))\n        fun _ _ p => Quot.sound p.dedup\n\n    @[simp] theorem dedup_zero : dedup (0 : UnorderedList \u03b1) = 0 := rfl\n\n    @[simp] theorem mem_dedup {a : \u03b1} {l : UnorderedList \u03b1} : a \u2208 l.dedup \u2194 a \u2208 l :=\n      @Quotient.inductionOn _ _ (fun s : UnorderedList \u03b1 => a \u2208 s.dedup \u2194 a \u2208 s) l fun _ => List.mem_dedup\n\n    theorem nodup_dedup (l : UnorderedList \u03b1) : l.dedup.nodup :=\n      @Quotient.inductionOn _ _ (fun s : UnorderedList \u03b1 => s.dedup.nodup) l List.nodup_dedup\n\n    theorem dedup_le (l : UnorderedList \u03b1) : l.dedup \u2264 l :=\n      @Quotient.ind _ _ (fun s : UnorderedList \u03b1 => s.dedup \u2264 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* `\u03b1 \u27f9 \u03b2`    - n-tuples of maps\n* `f \u229a g`     - composition\n\nAlso, support functions for operating with n-tuples of types, such as:\n\n* `append1 \u03b1 \u03b2`    - append type `\u03b2` to n-tuple `\u03b1` to obtain an (n+1)-tuple\n* `drop \u03b1`         - drops the last element of an (n+1)-tuple\n* `last \u03b1`         - 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 \u03b1.drop \u03b1.last` is propositionally equal to `\u03b1` 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 : \u2115) :=\n  Fin2 n \u2192 Type _\n#align typevec TypeVec\n-/\n\ninstance {n} : Inhabited (TypeVec.{u} n) :=\n  \u27e8fun _ => PUnit\u27e9\n\nnamespace TypeVec\n\nvariable {n : \u2115}\n\n#print TypeVec.Arrow /-\n/-- arrow in the category of `typevec` -/\ndef Arrow (\u03b1 \u03b2 : TypeVec n) :=\n  \u2200 i : Fin2 n, \u03b1 i \u2192 \u03b2 i\n#align typevec.arrow TypeVec.Arrow\n-/\n\n-- mathport name: typevec.arrow\nscoped[MvFunctor] infixl:40 \" \u27f9 \" => TypeVec.Arrow\n\n#print TypeVec.Arrow.inhabited /-\ninstance Arrow.inhabited (\u03b1 \u03b2 : TypeVec n) [\u2200 i, Inhabited (\u03b2 i)] : Inhabited (\u03b1 \u27f9 \u03b2) :=\n  \u27e8fun _ _ => default\u27e9\n#align typevec.arrow.inhabited TypeVec.Arrow.inhabited\n-/\n\n#print TypeVec.id /-\n/-- identity of arrow composition -/\ndef id {\u03b1 : TypeVec n} : \u03b1 \u27f9 \u03b1 := 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 {\u03b1 \u03b2 \u03b3 : TypeVec n} (g : \u03b2 \u27f9 \u03b3) (f : \u03b1 \u27f9 \u03b2) : \u03b1 \u27f9 \u03b3 := 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 \" \u229a \" => TypeVec.comp\n\n/- warning: typevec.id_comp -> TypeVec.id_comp is a dubious translation:\nlean 3 declaration is\n  forall {n : Nat} {\u03b1 : TypeVec.{u1} n} {\u03b2 : TypeVec.{u2} n} (f : TypeVec.Arrow.{u1, u2} n \u03b1 \u03b2), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n \u03b1 \u03b2) (TypeVec.comp.{u1, u2, u2} n \u03b1 \u03b2 \u03b2 (TypeVec.id.{u2} n \u03b2) f) f\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} n} {\u03b2 : TypeVec.{u1} n} (f : TypeVec.Arrow.{u2, u1} n \u03b1 \u03b2), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n \u03b1 \u03b2) (TypeVec.comp.{u2, u1, u1} n \u03b1 \u03b2 \u03b2 (TypeVec.id.{u1} n \u03b2) f) f\nCase conversion may be inaccurate. Consider using '#align typevec.id_comp TypeVec.id_comp\u2093'. -/\n-- type as \\oo\n@[simp]\ntheorem id_comp {\u03b1 \u03b2 : TypeVec n} (f : \u03b1 \u27f9 \u03b2) : id \u229a 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} {\u03b1 : TypeVec.{u1} n} {\u03b2 : TypeVec.{u2} n} (f : TypeVec.Arrow.{u1, u2} n \u03b1 \u03b2), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n \u03b1 \u03b2) (TypeVec.comp.{u1, u1, u2} n \u03b1 \u03b1 \u03b2 f (TypeVec.id.{u1} n \u03b1)) f\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} n} {\u03b2 : TypeVec.{u1} n} (f : TypeVec.Arrow.{u2, u1} n \u03b1 \u03b2), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n \u03b1 \u03b2) (TypeVec.comp.{u2, u2, u1} n \u03b1 \u03b1 \u03b2 f (TypeVec.id.{u2} n \u03b1)) f\nCase conversion may be inaccurate. Consider using '#align typevec.comp_id TypeVec.comp_id\u2093'. -/\n@[simp]\ntheorem comp_id {\u03b1 \u03b2 : TypeVec n} (f : \u03b1 \u27f9 \u03b2) : f \u229a 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} {\u03b1 : TypeVec.{u1} n} {\u03b2 : TypeVec.{u2} n} {\u03b3 : TypeVec.{u3} n} {\u03b4 : TypeVec.{u4} n} (h : TypeVec.Arrow.{u3, u4} n \u03b3 \u03b4) (g : TypeVec.Arrow.{u2, u3} n \u03b2 \u03b3) (f : TypeVec.Arrow.{u1, u2} n \u03b1 \u03b2), Eq.{max 1 (succ u1) (succ u4)} (TypeVec.Arrow.{u1, u4} n \u03b1 \u03b4) (TypeVec.comp.{u1, u2, u4} n \u03b1 \u03b2 \u03b4 (TypeVec.comp.{u2, u3, u4} n \u03b2 \u03b3 \u03b4 h g) f) (TypeVec.comp.{u1, u3, u4} n \u03b1 \u03b3 \u03b4 h (TypeVec.comp.{u1, u2, u3} n \u03b1 \u03b2 \u03b3 g f))\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u4} n} {\u03b2 : TypeVec.{u3} n} {\u03b3 : TypeVec.{u2} n} {\u03b4 : TypeVec.{u1} n} (h : TypeVec.Arrow.{u2, u1} n \u03b3 \u03b4) (g : TypeVec.Arrow.{u3, u2} n \u03b2 \u03b3) (f : TypeVec.Arrow.{u4, u3} n \u03b1 \u03b2), Eq.{max (succ u4) (succ u1)} (TypeVec.Arrow.{u4, u1} n \u03b1 \u03b4) (TypeVec.comp.{u4, u3, u1} n \u03b1 \u03b2 \u03b4 (TypeVec.comp.{u3, u2, u1} n \u03b2 \u03b3 \u03b4 h g) f) (TypeVec.comp.{u4, u2, u1} n \u03b1 \u03b3 \u03b4 h (TypeVec.comp.{u4, u3, u2} n \u03b1 \u03b2 \u03b3 g f))\nCase conversion may be inaccurate. Consider using '#align typevec.comp_assoc TypeVec.comp_assoc\u2093'. -/\ntheorem comp_assoc {\u03b1 \u03b2 \u03b3 \u03b4 : TypeVec n} (h : \u03b3 \u27f9 \u03b4) (g : \u03b2 \u27f9 \u03b3) (f : \u03b1 \u27f9 \u03b2) :\n    (h \u229a g) \u229a f = h \u229a g \u229a 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 (\u03b1 : TypeVec n) (\u03b2 : Type _) : TypeVec (n + 1)\n  | Fin2.fs i => \u03b1 i\n  | Fin2.fz => \u03b2\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 (\u03b1 : TypeVec.{u} (n + 1)) : TypeVec n := fun i => \u03b1 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 (\u03b1 : TypeVec.{u} (n + 1)) : Type _ :=\n  \u03b1 Fin2.fz\n#align typevec.last TypeVec.last\n-/\n\n#print TypeVec.last.inhabited /-\ninstance last.inhabited (\u03b1 : TypeVec (n + 1)) [Inhabited (\u03b1 Fin2.fz)] : Inhabited (last \u03b1) :=\n  \u27e8show \u03b1 Fin2.fz from default\u27e9\n#align typevec.last.inhabited TypeVec.last.inhabited\n-/\n\n#print TypeVec.drop_append1 /-\ntheorem drop_append1 {\u03b1 : TypeVec n} {\u03b2 : Type _} {i : Fin2 n} : drop (append1 \u03b1 \u03b2) i = \u03b1 i :=\n  rfl\n#align typevec.drop_append1 TypeVec.drop_append1\n-/\n\n#print TypeVec.drop_append1' /-\ntheorem drop_append1' {\u03b1 : TypeVec n} {\u03b2 : Type _} : drop (append1 \u03b1 \u03b2) = \u03b1 := by\n  ext <;> apply drop_append1\n#align typevec.drop_append1' TypeVec.drop_append1'\n-/\n\n#print TypeVec.last_append1 /-\ntheorem last_append1 {\u03b1 : TypeVec n} {\u03b2 : Type _} : last (append1 \u03b1 \u03b2) = \u03b2 :=\n  rfl\n#align typevec.last_append1 TypeVec.last_append1\n-/\n\n#print TypeVec.append1_drop_last /-\n@[simp]\ntheorem append1_drop_last (\u03b1 : TypeVec (n + 1)) : append1 (drop \u03b1) (last \u03b1) = \u03b1 :=\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) \u2192 Sort u} (H : \u2200 \u03b1 \u03b2, C (append1 \u03b1 \u03b2)) (\u03b3) : C \u03b3 := by\n  rw [\u2190 @append1_drop_last _ \u03b3] <;> 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 (\u03b1 : TypeVec.{u2} n) (\u03b2 : Type.{u2}), C (TypeVec.append1.{u2} n \u03b1 \u03b2)) (\u03b1 : TypeVec.{u2} n) (\u03b2 : Type.{u2}), Eq.{u1} (C (TypeVec.append1.{u2} n \u03b1 \u03b2)) (TypeVec.append1Cases.{u1, u2} n C H (TypeVec.append1.{u2} n \u03b1 \u03b2)) (H \u03b1 \u03b2)\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 (\u03b1 : TypeVec.{u1} n) (\u03b2 : Type.{u1}), C (TypeVec.append1.{u1} n \u03b1 \u03b2)) (\u03b1 : TypeVec.{u1} n) (\u03b2 : Type.{u1}), Eq.{u2} (C (TypeVec.append1.{u1} n \u03b1 \u03b2)) (TypeVec.append1Cases.{u2, u1} n C H (TypeVec.append1.{u1} n \u03b1 \u03b2)) (H \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align typevec.append1_cases_append1 TypeVec.append1_cases_append1\u2093'. -/\n@[simp]\ntheorem append1_cases_append1 {C : TypeVec (n + 1) \u2192 Sort u} (H : \u2200 \u03b1 \u03b2, C (append1 \u03b1 \u03b2)) (\u03b1 \u03b2) :\n    @append1Cases _ C H (append1 \u03b1 \u03b2) = H \u03b1 \u03b2 :=\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 {\u03b1 \u03b1' : TypeVec (n + 1)} (f : drop \u03b1 \u27f9 drop \u03b1') (g : last \u03b1 \u2192 last \u03b1') : \u03b1 \u27f9 \u03b1'\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 {\u03b1 \u03b1' : TypeVec n} {\u03b2 \u03b2' : Type _} (f : \u03b1 \u27f9 \u03b1') (g : \u03b2 \u2192 \u03b2') :\n    append1 \u03b1 \u03b2 \u27f9 append1 \u03b1' \u03b2' :=\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 {\u03b1 \u03b2 : TypeVec (n + 1)} (f : \u03b1 \u27f9 \u03b2) : drop \u03b1 \u27f9 drop \u03b2 := 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 {\u03b1 \u03b2 : TypeVec (n + 1)} (f : \u03b1 \u27f9 \u03b2) : last \u03b1 \u2192 last \u03b2 :=\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 {\u03b1 : TypeVec 0} {\u03b2 : TypeVec 0} : \u03b1 \u27f9 \u03b2 := 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} {\u03b1 : 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))))} {\u03b2 : 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)))) \u03b1 \u03b2} {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)))) \u03b1 \u03b2}, (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n \u03b1) (TypeVec.drop.{u2} n \u03b2)) (TypeVec.dropFun.{u1, u2} n \u03b1 \u03b2 f) (TypeVec.dropFun.{u1, u2} n \u03b1 \u03b2 g)) -> (Eq.{max (succ u1) (succ u2)} ((TypeVec.last.{u1} n \u03b1) -> (TypeVec.last.{u2} n \u03b2)) (TypeVec.lastFun.{u1, u2} n \u03b1 \u03b2 f) (TypeVec.lastFun.{u1, u2} n \u03b1 \u03b2 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)))) \u03b1 \u03b2) f g)\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b2 : 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))) \u03b1 \u03b2} {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))) \u03b1 \u03b2}, (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n \u03b1) (TypeVec.drop.{u1} n \u03b2)) (TypeVec.dropFun.{u2, u1} n \u03b1 \u03b2 f) (TypeVec.dropFun.{u2, u1} n \u03b1 \u03b2 g)) -> (Eq.{max (succ u2) (succ u1)} ((TypeVec.last.{u2} n \u03b1) -> (TypeVec.last.{u1} n \u03b2)) (TypeVec.lastFun.{u2, u1} n \u03b1 \u03b2 f) (TypeVec.lastFun.{u2, u1} n \u03b1 \u03b2 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))) \u03b1 \u03b2) f g)\nCase conversion may be inaccurate. Consider using '#align typevec.eq_of_drop_last_eq TypeVec.eq_of_drop_last_eq\u2093'. -/\ntheorem eq_of_drop_last_eq {\u03b1 \u03b2 : TypeVec (n + 1)} {f g : \u03b1 \u27f9 \u03b2} (h\u2080 : dropFun f = dropFun g)\n    (h\u2081 : lastFun f = lastFun g) : f = g := by\n  replace h\u2080 := congr_fun h\u2080 <;> ext1 \u27e8\u27e9 <;> 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} {\u03b1 : 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))))} {\u03b1' : 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 \u03b1) (TypeVec.drop.{u2} n \u03b1')) (g : (TypeVec.last.{u1} n \u03b1) -> (TypeVec.last.{u2} n \u03b1')), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n \u03b1) (TypeVec.drop.{u2} n \u03b1')) (TypeVec.dropFun.{u1, u2} n \u03b1 \u03b1' (TypeVec.splitFun.{u1, u2} n \u03b1 \u03b1' f g)) f\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1' : 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 \u03b1) (TypeVec.drop.{u1} n \u03b1')) (g : (TypeVec.last.{u2} n \u03b1) -> (TypeVec.last.{u1} n \u03b1')), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n \u03b1) (TypeVec.drop.{u1} n \u03b1')) (TypeVec.dropFun.{u2, u1} n \u03b1 \u03b1' (TypeVec.splitFun.{u2, u1} n \u03b1 \u03b1' f g)) f\nCase conversion may be inaccurate. Consider using '#align typevec.drop_fun_split_fun TypeVec.dropFun_splitFun\u2093'. -/\n@[simp]\ntheorem dropFun_splitFun {\u03b1 \u03b1' : TypeVec (n + 1)} (f : drop \u03b1 \u27f9 drop \u03b1') (g : last \u03b1 \u2192 last \u03b1') :\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 {\u03b1 \u03b2 : TypeVec n} (h : \u03b1 = \u03b2) : \u03b1 \u27f9 \u03b2\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 {\u03b1 \u03b2 : TypeVec n} (h : \u03b1 = \u03b2) : \u03b2 \u27f9 \u03b1\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 {\u03b1 : TypeVec (n + 1)} : \u03b1 \u27f9 (drop \u03b1 ::: last \u03b1) :=\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 {\u03b1 : TypeVec (n + 1)} : (drop \u03b1 ::: last \u03b1) \u27f9 \u03b1 :=\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} {\u03b1 : 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))))} {\u03b1' : 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 \u03b1) (TypeVec.drop.{u2} n \u03b1')) (g : (TypeVec.last.{u1} n \u03b1) -> (TypeVec.last.{u2} n \u03b1')), Eq.{max (succ u1) (succ u2)} ((TypeVec.last.{u1} n \u03b1) -> (TypeVec.last.{u2} n \u03b1')) (TypeVec.lastFun.{u1, u2} n \u03b1 \u03b1' (TypeVec.splitFun.{u1, u2} n \u03b1 \u03b1' f g)) g\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1' : 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 \u03b1) (TypeVec.drop.{u1} n \u03b1')) (g : (TypeVec.last.{u2} n \u03b1) -> (TypeVec.last.{u1} n \u03b1')), Eq.{max (succ u2) (succ u1)} ((TypeVec.last.{u2} n \u03b1) -> (TypeVec.last.{u1} n \u03b1')) (TypeVec.lastFun.{u2, u1} n \u03b1 \u03b1' (TypeVec.splitFun.{u2, u1} n \u03b1 \u03b1' f g)) g\nCase conversion may be inaccurate. Consider using '#align typevec.last_fun_split_fun TypeVec.lastFun_splitFun\u2093'. -/\n@[simp]\ntheorem lastFun_splitFun {\u03b1 \u03b1' : TypeVec (n + 1)} (f : drop \u03b1 \u27f9 drop \u03b1') (g : last \u03b1 \u2192 last \u03b1') :\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} {\u03b1 : TypeVec.{u1} n} {\u03b1' : TypeVec.{u2} n} {\u03b2 : Type.{u1}} {\u03b2' : Type.{u2}} (f : TypeVec.Arrow.{u1, u2} n \u03b1 \u03b1') (g : \u03b2 -> \u03b2'), Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n \u03b1 \u03b2)) (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n \u03b1' \u03b2'))) (TypeVec.dropFun.{u1, u2} n (TypeVec.append1.{u1} n \u03b1 \u03b2) (TypeVec.append1.{u2} n \u03b1' \u03b2') (TypeVec.appendFun.{u1, u2} n \u03b1 \u03b1' \u03b2 \u03b2' f g)) f\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} n} {\u03b1' : TypeVec.{u1} n} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u1}} (f : TypeVec.Arrow.{u2, u1} n \u03b1 \u03b1') (g : \u03b2 -> \u03b2'), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n \u03b1 \u03b2)) (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n \u03b1' \u03b2'))) (TypeVec.dropFun.{u2, u1} n (TypeVec.append1.{u2} n \u03b1 \u03b2) (TypeVec.append1.{u1} n \u03b1' \u03b2') (TypeVec.appendFun.{u2, u1} n \u03b1 \u03b1' \u03b2 \u03b2' f g)) f\nCase conversion may be inaccurate. Consider using '#align typevec.drop_fun_append_fun TypeVec.dropFun_appendFun\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem dropFun_appendFun {\u03b1 \u03b1' : TypeVec n} {\u03b2 \u03b2' : Type _} (f : \u03b1 \u27f9 \u03b1') (g : \u03b2 \u2192 \u03b2') :\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} {\u03b1 : TypeVec.{u1} n} {\u03b1' : TypeVec.{u2} n} {\u03b2 : Type.{u1}} {\u03b2' : Type.{u2}} (f : TypeVec.Arrow.{u1, u2} n \u03b1 \u03b1') (g : \u03b2 -> \u03b2'), Eq.{max (succ u1) (succ u2)} ((TypeVec.last.{u1} n (TypeVec.append1.{u1} n \u03b1 \u03b2)) -> (TypeVec.last.{u2} n (TypeVec.append1.{u2} n \u03b1' \u03b2'))) (TypeVec.lastFun.{u1, u2} n (TypeVec.append1.{u1} n \u03b1 \u03b2) (TypeVec.append1.{u2} n \u03b1' \u03b2') (TypeVec.appendFun.{u1, u2} n \u03b1 \u03b1' \u03b2 \u03b2' f g)) g\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} n} {\u03b1' : TypeVec.{u1} n} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u1}} (f : TypeVec.Arrow.{u2, u1} n \u03b1 \u03b1') (g : \u03b2 -> \u03b2'), Eq.{max (succ u2) (succ u1)} ((TypeVec.last.{u2} n (TypeVec.append1.{u2} n \u03b1 \u03b2)) -> (TypeVec.last.{u1} n (TypeVec.append1.{u1} n \u03b1' \u03b2'))) (TypeVec.lastFun.{u2, u1} n (TypeVec.append1.{u2} n \u03b1 \u03b2) (TypeVec.append1.{u1} n \u03b1' \u03b2') (TypeVec.appendFun.{u2, u1} n \u03b1 \u03b1' \u03b2 \u03b2' f g)) g\nCase conversion may be inaccurate. Consider using '#align typevec.last_fun_append_fun TypeVec.lastFun_appendFun\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem lastFun_appendFun {\u03b1 \u03b1' : TypeVec n} {\u03b2 \u03b2' : Type _} (f : \u03b1 \u27f9 \u03b1') (g : \u03b2 \u2192 \u03b2') :\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} {\u03b1 : 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))))} {\u03b1' : 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)))) \u03b1 \u03b1'), 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)))) \u03b1 \u03b1') (TypeVec.splitFun.{u1, u2} n \u03b1 \u03b1' (TypeVec.dropFun.{u1, u2} n \u03b1 \u03b1' f) (TypeVec.lastFun.{u1, u2} n \u03b1 \u03b1' f)) f\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1' : 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))) \u03b1 \u03b1'), 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))) \u03b1 \u03b1') (TypeVec.splitFun.{u2, u1} n \u03b1 \u03b1' (TypeVec.dropFun.{u2, u1} n \u03b1 \u03b1' f) (TypeVec.lastFun.{u2, u1} n \u03b1 \u03b1' f)) f\nCase conversion may be inaccurate. Consider using '#align typevec.split_drop_fun_last_fun TypeVec.split_dropFun_lastFun\u2093'. -/\ntheorem split_dropFun_lastFun {\u03b1 \u03b1' : TypeVec (n + 1)} (f : \u03b1 \u27f9 \u03b1') :\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} {\u03b1 : 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))))} {\u03b1' : 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 \u03b1) (TypeVec.drop.{u2} n \u03b1')} {f' : TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n \u03b1) (TypeVec.drop.{u2} n \u03b1')} {g : (TypeVec.last.{u1} n \u03b1) -> (TypeVec.last.{u2} n \u03b1')} {g' : (TypeVec.last.{u1} n \u03b1) -> (TypeVec.last.{u2} n \u03b1')}, (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)))) \u03b1 \u03b1') (TypeVec.splitFun.{u1, u2} n \u03b1 \u03b1' f g) (TypeVec.splitFun.{u1, u2} n \u03b1 \u03b1' f' g')) -> (And (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n \u03b1) (TypeVec.drop.{u2} n \u03b1')) f f') (Eq.{max (succ u1) (succ u2)} ((TypeVec.last.{u1} n \u03b1) -> (TypeVec.last.{u2} n \u03b1')) g g'))\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1' : 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 \u03b1) (TypeVec.drop.{u1} n \u03b1')} {f' : TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n \u03b1) (TypeVec.drop.{u1} n \u03b1')} {g : (TypeVec.last.{u2} n \u03b1) -> (TypeVec.last.{u1} n \u03b1')} {g' : (TypeVec.last.{u2} n \u03b1) -> (TypeVec.last.{u1} n \u03b1')}, (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))) \u03b1 \u03b1') (TypeVec.splitFun.{u2, u1} n \u03b1 \u03b1' f g) (TypeVec.splitFun.{u2, u1} n \u03b1 \u03b1' f' g')) -> (And (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n \u03b1) (TypeVec.drop.{u1} n \u03b1')) f f') (Eq.{max (succ u2) (succ u1)} ((TypeVec.last.{u2} n \u03b1) -> (TypeVec.last.{u1} n \u03b1')) g g'))\nCase conversion may be inaccurate. Consider using '#align typevec.split_fun_inj TypeVec.splitFun_inj\u2093'. -/\ntheorem splitFun_inj {\u03b1 \u03b1' : TypeVec (n + 1)} {f f' : drop \u03b1 \u27f9 drop \u03b1'} {g g' : last \u03b1 \u2192 last \u03b1'}\n    (H : splitFun f g = splitFun f' g') : f = f' \u2227 g = g' := by\n  rw [\u2190 drop_fun_split_fun f g, H, \u2190 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} {\u03b1 : TypeVec.{u1} n} {\u03b1' : TypeVec.{u2} n} {\u03b2 : Type.{u1}} {\u03b2' : Type.{u2}} {f : TypeVec.Arrow.{u1, u2} n \u03b1 \u03b1'} {f' : TypeVec.Arrow.{u1, u2} n \u03b1 \u03b1'} {g : \u03b2 -> \u03b2'} {g' : \u03b2 -> \u03b2'}, (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 \u03b1 \u03b2) (TypeVec.append1.{u2} n \u03b1' \u03b2')) (TypeVec.appendFun.{u1, u2} n \u03b1 \u03b1' \u03b2 \u03b2' f g) (TypeVec.appendFun.{u1, u2} n \u03b1 \u03b1' \u03b2 \u03b2' f' g')) -> (And (Eq.{max 1 (succ u1) (succ u2)} (TypeVec.Arrow.{u1, u2} n \u03b1 \u03b1') f f') (Eq.{max (succ u1) (succ u2)} (\u03b2 -> \u03b2') g g'))\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} n} {\u03b1' : TypeVec.{u1} n} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u1}} {f : TypeVec.Arrow.{u2, u1} n \u03b1 \u03b1'} {f' : TypeVec.Arrow.{u2, u1} n \u03b1 \u03b1'} {g : \u03b2 -> \u03b2'} {g' : \u03b2 -> \u03b2'}, (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 \u03b1 \u03b2) (TypeVec.append1.{u1} n \u03b1' \u03b2')) (TypeVec.appendFun.{u2, u1} n \u03b1 \u03b1' \u03b2 \u03b2' f g) (TypeVec.appendFun.{u2, u1} n \u03b1 \u03b1' \u03b2 \u03b2' f' g')) -> (And (Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n \u03b1 \u03b1') f f') (Eq.{max (succ u2) (succ u1)} (\u03b2 -> \u03b2') g g'))\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_inj TypeVec.appendFun_inj\u2093'. -/\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 {\u03b1 \u03b1' : TypeVec n} {\u03b2 \u03b2' : Type _} {f f' : \u03b1 \u27f9 \u03b1'} {g g' : \u03b2 \u2192 \u03b2'} :\n    (f ::: g) = (f' ::: g') \u2192 f = f' \u2227 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} {\u03b1\u2080 : 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))))} {\u03b1\u2081 : 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))))} {\u03b1\u2082 : 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\u2080 : TypeVec.Arrow.{u1, u2} n (TypeVec.drop.{u1} n \u03b1\u2080) (TypeVec.drop.{u2} n \u03b1\u2081)) (f\u2081 : TypeVec.Arrow.{u2, u3} n (TypeVec.drop.{u2} n \u03b1\u2081) (TypeVec.drop.{u3} n \u03b1\u2082)) (g\u2080 : (TypeVec.last.{u1} n \u03b1\u2080) -> (TypeVec.last.{u2} n \u03b1\u2081)) (g\u2081 : (TypeVec.last.{u2} n \u03b1\u2081) -> (TypeVec.last.{u3} n \u03b1\u2082)), 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)))) \u03b1\u2080 \u03b1\u2082) (TypeVec.splitFun.{u1, u3} n \u03b1\u2080 \u03b1\u2082 (TypeVec.comp.{u1, u2, u3} n (TypeVec.drop.{u1} n \u03b1\u2080) (TypeVec.drop.{u2} n \u03b1\u2081) (TypeVec.drop.{u3} n \u03b1\u2082) f\u2081 f\u2080) (Function.comp.{succ u1, succ u2, succ u3} (TypeVec.last.{u1} n \u03b1\u2080) (TypeVec.last.{u2} n \u03b1\u2081) (TypeVec.last.{u3} n \u03b1\u2082) g\u2081 g\u2080)) (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)))) \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 (TypeVec.splitFun.{u2, u3} n \u03b1\u2081 \u03b1\u2082 f\u2081 g\u2081) (TypeVec.splitFun.{u1, u2} n \u03b1\u2080 \u03b1\u2081 f\u2080 g\u2080))\nbut is expected to have type\n  forall {n : Nat} {\u03b1\u2080 : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1\u2081 : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1\u2082 : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f\u2080 : TypeVec.Arrow.{u3, u2} n (TypeVec.drop.{u3} n \u03b1\u2080) (TypeVec.drop.{u2} n \u03b1\u2081)) (f\u2081 : TypeVec.Arrow.{u2, u1} n (TypeVec.drop.{u2} n \u03b1\u2081) (TypeVec.drop.{u1} n \u03b1\u2082)) (g\u2080 : (TypeVec.last.{u3} n \u03b1\u2080) -> (TypeVec.last.{u2} n \u03b1\u2081)) (g\u2081 : (TypeVec.last.{u2} n \u03b1\u2081) -> (TypeVec.last.{u1} n \u03b1\u2082)), 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))) \u03b1\u2080 \u03b1\u2082) (TypeVec.splitFun.{u3, u1} n \u03b1\u2080 \u03b1\u2082 (TypeVec.comp.{u3, u2, u1} n (TypeVec.drop.{u3} n \u03b1\u2080) (TypeVec.drop.{u2} n \u03b1\u2081) (TypeVec.drop.{u1} n \u03b1\u2082) f\u2081 f\u2080) (Function.comp.{succ u3, succ u2, succ u1} (TypeVec.last.{u3} n \u03b1\u2080) (TypeVec.last.{u2} n \u03b1\u2081) (TypeVec.last.{u1} n \u03b1\u2082) g\u2081 g\u2080)) (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))) \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 (TypeVec.splitFun.{u2, u1} n \u03b1\u2081 \u03b1\u2082 f\u2081 g\u2081) (TypeVec.splitFun.{u3, u2} n \u03b1\u2080 \u03b1\u2081 f\u2080 g\u2080))\nCase conversion may be inaccurate. Consider using '#align typevec.split_fun_comp TypeVec.splitFun_comp\u2093'. -/\ntheorem splitFun_comp {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 : TypeVec (n + 1)} (f\u2080 : drop \u03b1\u2080 \u27f9 drop \u03b1\u2081) (f\u2081 : drop \u03b1\u2081 \u27f9 drop \u03b1\u2082)\n    (g\u2080 : last \u03b1\u2080 \u2192 last \u03b1\u2081) (g\u2081 : last \u03b1\u2081 \u2192 last \u03b1\u2082) :\n    splitFun (f\u2081 \u229a f\u2080) (g\u2081 \u2218 g\u2080) = splitFun f\u2081 g\u2081 \u229a splitFun f\u2080 g\u2080 :=\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} {\u03b1 : TypeVec.{u1} n} {\u03b3 : TypeVec.{u2} n} {\u03b2 : Type.{u1}} {\u03b4 : Type.{u2}} {\u03b5 : 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\u2080 : TypeVec.Arrow.{u3, u1} n (TypeVec.drop.{u3} n \u03b5) \u03b1) (f\u2081 : TypeVec.Arrow.{u1, u2} n \u03b1 \u03b3) (g\u2080 : (TypeVec.last.{u3} n \u03b5) -> \u03b2) (g\u2081 : \u03b2 -> \u03b4), 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)))) \u03b5 (TypeVec.append1.{u2} n \u03b3 \u03b4)) (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)))) \u03b5 (TypeVec.append1.{u1} n \u03b1 \u03b2) (TypeVec.append1.{u2} n \u03b3 \u03b4) (TypeVec.appendFun.{u1, u2} n \u03b1 \u03b3 \u03b2 \u03b4 f\u2081 g\u2081) (TypeVec.splitFun.{u3, u1} n \u03b5 (TypeVec.append1.{u1} n \u03b1 \u03b2) f\u2080 g\u2080)) (TypeVec.splitFun.{u3, u2} n \u03b5 (TypeVec.append1.{u2} n \u03b3 \u03b4) (TypeVec.comp.{u3, u1, u2} n (TypeVec.drop.{u3} n \u03b5) \u03b1 (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n \u03b3 \u03b4)) f\u2081 f\u2080) (Function.comp.{succ u3, succ u1, succ u2} (TypeVec.last.{u3} n \u03b5) \u03b2 (TypeVec.last.{u2} n (TypeVec.append1.{u2} n \u03b3 \u03b4)) g\u2081 g\u2080))\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u3} n} {\u03b3 : TypeVec.{u2} n} {\u03b2 : Type.{u3}} {\u03b4 : Type.{u2}} {\u03b5 : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f\u2080 : TypeVec.Arrow.{u1, u3} n (TypeVec.drop.{u1} n \u03b5) \u03b1) (f\u2081 : TypeVec.Arrow.{u3, u2} n \u03b1 \u03b3) (g\u2080 : (TypeVec.last.{u1} n \u03b5) -> \u03b2) (g\u2081 : \u03b2 -> \u03b4), 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))) \u03b5 (TypeVec.append1.{u2} n \u03b3 \u03b4)) (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))) \u03b5 (TypeVec.append1.{u3} n \u03b1 \u03b2) (TypeVec.append1.{u2} n \u03b3 \u03b4) (TypeVec.appendFun.{u3, u2} n \u03b1 \u03b3 \u03b2 \u03b4 f\u2081 g\u2081) (TypeVec.splitFun.{u1, u3} n \u03b5 (TypeVec.append1.{u3} n \u03b1 \u03b2) f\u2080 g\u2080)) (TypeVec.splitFun.{u1, u2} n \u03b5 (TypeVec.append1.{u2} n \u03b3 \u03b4) (TypeVec.comp.{u1, u3, u2} n (TypeVec.drop.{u1} n \u03b5) \u03b1 (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n \u03b3 \u03b4)) f\u2081 f\u2080) (Function.comp.{succ u1, succ u3, succ u2} (TypeVec.last.{u1} n \u03b5) \u03b2 (TypeVec.last.{u2} n (TypeVec.append1.{u2} n \u03b3 \u03b4)) g\u2081 g\u2080))\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_comp_split_fun TypeVec.appendFun_comp_splitFun\u2093'. -/\ntheorem appendFun_comp_splitFun {\u03b1 \u03b3 : TypeVec n} {\u03b2 \u03b4 : Type _} {\u03b5 : TypeVec (n + 1)}\n    (f\u2080 : drop \u03b5 \u27f9 \u03b1) (f\u2081 : \u03b1 \u27f9 \u03b3) (g\u2080 : last \u03b5 \u2192 \u03b2) (g\u2081 : \u03b2 \u2192 \u03b4) :\n    appendFun f\u2081 g\u2081 \u229a splitFun f\u2080 g\u2080 = splitFun (f\u2081 \u229a f\u2080) (g\u2081 \u2218 g\u2080) :=\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} {\u03b1\u2080 : TypeVec.{u1} n} {\u03b1\u2081 : TypeVec.{u2} n} {\u03b1\u2082 : TypeVec.{u3} n} {\u03b2\u2080 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u3}} (f\u2080 : TypeVec.Arrow.{u1, u2} n \u03b1\u2080 \u03b1\u2081) (f\u2081 : TypeVec.Arrow.{u2, u3} n \u03b1\u2081 \u03b1\u2082) (g\u2080 : \u03b2\u2080 -> \u03b2\u2081) (g\u2081 : \u03b2\u2081 -> \u03b2\u2082), 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 \u03b1\u2080 \u03b2\u2080) (TypeVec.append1.{u3} n \u03b1\u2082 \u03b2\u2082)) (TypeVec.appendFun.{u1, u3} n \u03b1\u2080 \u03b1\u2082 \u03b2\u2080 \u03b2\u2082 (TypeVec.comp.{u1, u2, u3} n \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 f\u2081 f\u2080) (Function.comp.{succ u1, succ u2, succ u3} \u03b2\u2080 \u03b2\u2081 \u03b2\u2082 g\u2081 g\u2080)) (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 \u03b1\u2080 \u03b2\u2080) (TypeVec.append1.{u2} n \u03b1\u2081 \u03b2\u2081) (TypeVec.append1.{u3} n \u03b1\u2082 \u03b2\u2082) (TypeVec.appendFun.{u2, u3} n \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 f\u2081 g\u2081) (TypeVec.appendFun.{u1, u2} n \u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081 f\u2080 g\u2080))\nbut is expected to have type\n  forall {n : Nat} {\u03b1\u2080 : TypeVec.{u3} n} {\u03b1\u2081 : TypeVec.{u2} n} {\u03b1\u2082 : TypeVec.{u1} n} {\u03b2\u2080 : Type.{u3}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u1}} (f\u2080 : TypeVec.Arrow.{u3, u2} n \u03b1\u2080 \u03b1\u2081) (f\u2081 : TypeVec.Arrow.{u2, u1} n \u03b1\u2081 \u03b1\u2082) (g\u2080 : \u03b2\u2080 -> \u03b2\u2081) (g\u2081 : \u03b2\u2081 -> \u03b2\u2082), 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 \u03b1\u2080 \u03b2\u2080) (TypeVec.append1.{u1} n \u03b1\u2082 \u03b2\u2082)) (TypeVec.appendFun.{u3, u1} n \u03b1\u2080 \u03b1\u2082 \u03b2\u2080 \u03b2\u2082 (TypeVec.comp.{u3, u2, u1} n \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 f\u2081 f\u2080) (Function.comp.{succ u3, succ u2, succ u1} \u03b2\u2080 \u03b2\u2081 \u03b2\u2082 g\u2081 g\u2080)) (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 \u03b1\u2080 \u03b2\u2080) (TypeVec.append1.{u2} n \u03b1\u2081 \u03b2\u2081) (TypeVec.append1.{u1} n \u03b1\u2082 \u03b2\u2082) (TypeVec.appendFun.{u2, u1} n \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 f\u2081 g\u2081) (TypeVec.appendFun.{u3, u2} n \u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081 f\u2080 g\u2080))\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_comp TypeVec.appendFun_comp\u2093'. -/\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 {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 : TypeVec n} {\u03b2\u2080 \u03b2\u2081 \u03b2\u2082 : Type _} (f\u2080 : \u03b1\u2080 \u27f9 \u03b1\u2081) (f\u2081 : \u03b1\u2081 \u27f9 \u03b1\u2082)\n    (g\u2080 : \u03b2\u2080 \u2192 \u03b2\u2081) (g\u2081 : \u03b2\u2081 \u2192 \u03b2\u2082) : (f\u2081 \u229a f\u2080 ::: g\u2081 \u2218 g\u2080) = (f\u2081 ::: g\u2081) \u229a (f\u2080 ::: g\u2080) :=\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} {\u03b1\u2080 : TypeVec.{u1} n} {\u03b1\u2081 : TypeVec.{u2} n} {\u03b1\u2082 : TypeVec.{u3} n} {\u03b2\u2080 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u3}} (f\u2080 : TypeVec.Arrow.{u1, u2} n \u03b1\u2080 \u03b1\u2081) (f\u2081 : TypeVec.Arrow.{u2, u3} n \u03b1\u2081 \u03b1\u2082) (g\u2080 : \u03b2\u2080 -> \u03b2\u2081) (g\u2081 : \u03b2\u2081 -> \u03b2\u2082), 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 \u03b1\u2080 \u03b2\u2080) (TypeVec.append1.{u3} n \u03b1\u2082 \u03b2\u2082)) (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 \u03b1\u2080 \u03b2\u2080) (TypeVec.append1.{u2} n \u03b1\u2081 \u03b2\u2081) (TypeVec.append1.{u3} n \u03b1\u2082 \u03b2\u2082) (TypeVec.appendFun.{u2, u3} n \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 f\u2081 g\u2081) (TypeVec.appendFun.{u1, u2} n \u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081 f\u2080 g\u2080)) (TypeVec.appendFun.{u1, u3} n \u03b1\u2080 \u03b1\u2082 \u03b2\u2080 \u03b2\u2082 (TypeVec.comp.{u1, u2, u3} n \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 f\u2081 f\u2080) (Function.comp.{succ u1, succ u2, succ u3} \u03b2\u2080 \u03b2\u2081 \u03b2\u2082 g\u2081 g\u2080))\nbut is expected to have type\n  forall {n : Nat} {\u03b1\u2080 : TypeVec.{u3} n} {\u03b1\u2081 : TypeVec.{u2} n} {\u03b1\u2082 : TypeVec.{u1} n} {\u03b2\u2080 : Type.{u3}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u1}} (f\u2080 : TypeVec.Arrow.{u3, u2} n \u03b1\u2080 \u03b1\u2081) (f\u2081 : TypeVec.Arrow.{u2, u1} n \u03b1\u2081 \u03b1\u2082) (g\u2080 : \u03b2\u2080 -> \u03b2\u2081) (g\u2081 : \u03b2\u2081 -> \u03b2\u2082), 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 \u03b1\u2080 \u03b2\u2080) (TypeVec.append1.{u1} n \u03b1\u2082 \u03b2\u2082)) (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 \u03b1\u2080 \u03b2\u2080) (TypeVec.append1.{u2} n \u03b1\u2081 \u03b2\u2081) (TypeVec.append1.{u1} n \u03b1\u2082 \u03b2\u2082) (TypeVec.appendFun.{u2, u1} n \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 f\u2081 g\u2081) (TypeVec.appendFun.{u3, u2} n \u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081 f\u2080 g\u2080)) (TypeVec.appendFun.{u3, u1} n \u03b1\u2080 \u03b1\u2082 \u03b2\u2080 \u03b2\u2082 (TypeVec.comp.{u3, u2, u1} n \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 f\u2081 f\u2080) (Function.comp.{succ u3, succ u2, succ u1} \u03b2\u2080 \u03b2\u2081 \u03b2\u2082 g\u2081 g\u2080))\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_comp' TypeVec.appendFun_comp'\u2093'. -/\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' {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 : TypeVec n} {\u03b2\u2080 \u03b2\u2081 \u03b2\u2082 : Type _} (f\u2080 : \u03b1\u2080 \u27f9 \u03b1\u2081) (f\u2081 : \u03b1\u2081 \u27f9 \u03b1\u2082)\n    (g\u2080 : \u03b2\u2080 \u2192 \u03b2\u2081) (g\u2081 : \u03b2\u2081 \u2192 \u03b2\u2082) : (f\u2081 ::: g\u2081) \u229a (f\u2080 ::: g\u2080) = (f\u2081 \u229a f\u2080 ::: g\u2081 \u2218 g\u2080) :=\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 {\u03b1\u2080 : TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))} (f\u2080 : TypeVec.Arrow.{u1, u2} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) \u03b1\u2080 (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : 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))) \u03b1\u2080 (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : 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))) \u03b1\u2080 (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : 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 (\u1fb0 : 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 (\u1fb0 : 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 (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2}))) f\u2080) f\u2080\nbut is expected to have type\n  forall {\u03b1\u2080 : TypeVec.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))} (f\u2080 : TypeVec.Arrow.{u2, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) \u03b1\u2080 (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : 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)) \u03b1\u2080 (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1}))) (TypeVec.comp.{u2, u1, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) \u03b1\u2080 (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1})) (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1})) (TypeVec.nilFun.{u1, u1} (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1})) (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u1}))) f\u2080) f\u2080\nCase conversion may be inaccurate. Consider using '#align typevec.nil_fun_comp TypeVec.nilFun_comp\u2093'. -/\ntheorem nilFun_comp {\u03b1\u2080 : TypeVec 0} (f\u2080 : \u03b1\u2080 \u27f9 Fin2.elim0) : nilFun \u229a f\u2080 = f\u2080 :=\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 {\u03b1 : TypeVec n} {\u03b2\u2080 \u03b2\u2081 \u03b2\u2082 : Type _} (g\u2080 : \u03b2\u2080 \u2192 \u03b2\u2081) (g\u2081 : \u03b2\u2081 \u2192 \u03b2\u2082) :\n    (@id _ \u03b1 ::: g\u2081 \u2218 g\u2080) = (id ::: g\u2081) \u229a (id ::: g\u2080) :=\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} {\u03b1\u2080 : 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))))} {\u03b1\u2081 : 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))))} {\u03b1\u2082 : 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\u2080 : 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)))) \u03b1\u2080 \u03b1\u2081) (f\u2081 : 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)))) \u03b1\u2081 \u03b1\u2082), Eq.{max 1 (succ u1) (succ u3)} (TypeVec.Arrow.{u1, u3} n (TypeVec.drop.{u1} n \u03b1\u2080) (TypeVec.drop.{u3} n \u03b1\u2082)) (TypeVec.dropFun.{u1, u3} n \u03b1\u2080 \u03b1\u2082 (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)))) \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 f\u2081 f\u2080)) (TypeVec.comp.{u1, u2, u3} n (TypeVec.drop.{u1} n \u03b1\u2080) (TypeVec.drop.{u2} n \u03b1\u2081) (TypeVec.drop.{u3} n \u03b1\u2082) (TypeVec.dropFun.{u2, u3} n \u03b1\u2081 \u03b1\u2082 f\u2081) (TypeVec.dropFun.{u1, u2} n \u03b1\u2080 \u03b1\u2081 f\u2080))\nbut is expected to have type\n  forall {n : Nat} {\u03b1\u2080 : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1\u2081 : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1\u2082 : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f\u2080 : TypeVec.Arrow.{u3, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) \u03b1\u2080 \u03b1\u2081) (f\u2081 : TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) \u03b1\u2081 \u03b1\u2082), Eq.{max (succ u3) (succ u1)} (TypeVec.Arrow.{u3, u1} n (TypeVec.drop.{u3} n \u03b1\u2080) (TypeVec.drop.{u1} n \u03b1\u2082)) (TypeVec.dropFun.{u3, u1} n \u03b1\u2080 \u03b1\u2082 (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))) \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 f\u2081 f\u2080)) (TypeVec.comp.{u3, u2, u1} n (TypeVec.drop.{u3} n \u03b1\u2080) (TypeVec.drop.{u2} n \u03b1\u2081) (TypeVec.drop.{u1} n \u03b1\u2082) (TypeVec.dropFun.{u2, u1} n \u03b1\u2081 \u03b1\u2082 f\u2081) (TypeVec.dropFun.{u3, u2} n \u03b1\u2080 \u03b1\u2081 f\u2080))\nCase conversion may be inaccurate. Consider using '#align typevec.drop_fun_comp TypeVec.dropFun_comp\u2093'. -/\n@[simp]\ntheorem dropFun_comp {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 : TypeVec (n + 1)} (f\u2080 : \u03b1\u2080 \u27f9 \u03b1\u2081) (f\u2081 : \u03b1\u2081 \u27f9 \u03b1\u2082) :\n    dropFun (f\u2081 \u229a f\u2080) = dropFun f\u2081 \u229a dropFun f\u2080 :=\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} {\u03b1\u2080 : 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))))} {\u03b1\u2081 : 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))))} {\u03b1\u2082 : 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\u2080 : 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)))) \u03b1\u2080 \u03b1\u2081) (f\u2081 : 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)))) \u03b1\u2081 \u03b1\u2082), Eq.{max (succ u1) (succ u3)} ((TypeVec.last.{u1} n \u03b1\u2080) -> (TypeVec.last.{u3} n \u03b1\u2082)) (TypeVec.lastFun.{u1, u3} n \u03b1\u2080 \u03b1\u2082 (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)))) \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 f\u2081 f\u2080)) (Function.comp.{succ u1, succ u2, succ u3} (TypeVec.last.{u1} n \u03b1\u2080) (TypeVec.last.{u2} n \u03b1\u2081) (TypeVec.last.{u3} n \u03b1\u2082) (TypeVec.lastFun.{u2, u3} n \u03b1\u2081 \u03b1\u2082 f\u2081) (TypeVec.lastFun.{u1, u2} n \u03b1\u2080 \u03b1\u2081 f\u2080))\nbut is expected to have type\n  forall {n : Nat} {\u03b1\u2080 : TypeVec.{u3} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1\u2081 : TypeVec.{u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} {\u03b1\u2082 : TypeVec.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)))} (f\u2080 : TypeVec.Arrow.{u3, u2} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) \u03b1\u2080 \u03b1\u2081) (f\u2081 : TypeVec.Arrow.{u2, u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) \u03b1\u2081 \u03b1\u2082), Eq.{max (succ u3) (succ u1)} ((TypeVec.last.{u3} n \u03b1\u2080) -> (TypeVec.last.{u1} n \u03b1\u2082)) (TypeVec.lastFun.{u3, u1} n \u03b1\u2080 \u03b1\u2082 (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))) \u03b1\u2080 \u03b1\u2081 \u03b1\u2082 f\u2081 f\u2080)) (Function.comp.{succ u3, succ u2, succ u1} (TypeVec.last.{u3} n \u03b1\u2080) (TypeVec.last.{u2} n \u03b1\u2081) (TypeVec.last.{u1} n \u03b1\u2082) (TypeVec.lastFun.{u2, u1} n \u03b1\u2081 \u03b1\u2082 f\u2081) (TypeVec.lastFun.{u3, u2} n \u03b1\u2080 \u03b1\u2081 f\u2080))\nCase conversion may be inaccurate. Consider using '#align typevec.last_fun_comp TypeVec.lastFun_comp\u2093'. -/\n@[simp]\ntheorem lastFun_comp {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 : TypeVec (n + 1)} (f\u2080 : \u03b1\u2080 \u27f9 \u03b1\u2081) (f\u2081 : \u03b1\u2081 \u27f9 \u03b1\u2082) :\n    lastFun (f\u2081 \u229a f\u2080) = lastFun f\u2081 \u2218 lastFun f\u2080 :=\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} {\u03b1 : TypeVec.{u1} n} {\u03b1' : TypeVec.{u2} n} {\u03b2 : Type.{u1}} {\u03b2' : 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 \u03b1 \u03b2) (TypeVec.append1.{u2} n \u03b1' \u03b2')), 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 \u03b1 \u03b2)) (TypeVec.last.{u1} n (TypeVec.append1.{u1} n \u03b1 \u03b2))) (TypeVec.append1.{u2} n (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n \u03b1' \u03b2')) (TypeVec.last.{u2} n (TypeVec.append1.{u2} n \u03b1' \u03b2')))) (TypeVec.appendFun.{u1, u2} n (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n \u03b1 \u03b2)) (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n \u03b1' \u03b2')) (TypeVec.last.{u1} n (TypeVec.append1.{u1} n \u03b1 \u03b2)) (TypeVec.last.{u2} n (TypeVec.append1.{u2} n \u03b1' \u03b2')) (TypeVec.dropFun.{u1, u2} n (TypeVec.append1.{u1} n \u03b1 \u03b2) (TypeVec.append1.{u2} n \u03b1' \u03b2') f) (TypeVec.lastFun.{u1, u2} n (TypeVec.append1.{u1} n \u03b1 \u03b2) (TypeVec.append1.{u2} n \u03b1' \u03b2') f)) f\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} n} {\u03b1' : TypeVec.{u1} n} {\u03b2 : Type.{u2}} {\u03b2' : 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 \u03b1 \u03b2) (TypeVec.append1.{u1} n \u03b1' \u03b2')), 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 \u03b1 \u03b2)) (TypeVec.last.{u2} n (TypeVec.append1.{u2} n \u03b1 \u03b2))) (TypeVec.append1.{u1} n (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n \u03b1' \u03b2')) (TypeVec.last.{u1} n (TypeVec.append1.{u1} n \u03b1' \u03b2')))) (TypeVec.appendFun.{u2, u1} n (TypeVec.drop.{u2} n (TypeVec.append1.{u2} n \u03b1 \u03b2)) (TypeVec.drop.{u1} n (TypeVec.append1.{u1} n \u03b1' \u03b2')) (TypeVec.last.{u2} n (TypeVec.append1.{u2} n \u03b1 \u03b2)) (TypeVec.last.{u1} n (TypeVec.append1.{u1} n \u03b1' \u03b2')) (TypeVec.dropFun.{u2, u1} n (TypeVec.append1.{u2} n \u03b1 \u03b2) (TypeVec.append1.{u1} n \u03b1' \u03b2') f) (TypeVec.lastFun.{u2, u1} n (TypeVec.append1.{u2} n \u03b1 \u03b2) (TypeVec.append1.{u1} n \u03b1' \u03b2') f)) f\nCase conversion may be inaccurate. Consider using '#align typevec.append_fun_aux TypeVec.appendFun_aux\u2093'. -/\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 {\u03b1 \u03b1' : TypeVec n} {\u03b2 \u03b2' : Type _} (f : (\u03b1 ::: \u03b2) \u27f9 (\u03b1' ::: \u03b2')) :\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 {\u03b1 : TypeVec n} {\u03b2 : Type _} : (@TypeVec.id n \u03b1 ::: @id \u03b2) = 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  \u27e8fun a b => funext fun a => Fin2.elim0 a\u27e9\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: \u00abexpr\u266f \u00bb\nlocal prefix:0 \"\u266f\" => cast (by try simp <;> congr 1 <;> try simp)\n\n#print TypeVec.casesNil /-\n/-- cases distinction for 0-length type vector -/\nprotected def casesNil {\u03b2 : TypeVec 0 \u2192 Sort _} (f : \u03b2 Fin2.elim0) : \u2200 v, \u03b2 v := fun v => \u266ff\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 : \u2115) {\u03b2 : TypeVec (n + 1) \u2192 Sort _}\n    (f : \u2200 (t) (v : TypeVec n), \u03b2 (v ::: t)) : \u2200 v, \u03b2 v := fun v : TypeVec (n + 1) =>\n  \u266ff 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 {\u03b2 : (TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> Sort.{u2}} (f : \u03b2 (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1}))), Eq.{u2} (\u03b2 (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u1}))) (TypeVec.casesNil.{u1, u2} \u03b2 f (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : 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 {\u03b2 : (TypeVec.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> Sort.{u1}} (f : \u03b2 (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2}))), Eq.{u1} (\u03b2 (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2}))) (TypeVec.casesNil.{u2, u1} \u03b2 f (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : 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\u2093'. -/\nprotected theorem casesNil_append1 {\u03b2 : TypeVec 0 \u2192 Sort _} (f : \u03b2 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) {\u03b2 : (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), \u03b2 (TypeVec.append1.{u1} n v t)) (v : TypeVec.{u1} n) (\u03b1 : Type.{u1}), Eq.{u2} (\u03b2 (TypeVec.append1.{u1} n v \u03b1)) (TypeVec.casesCons.{u1, u2} n \u03b2 f (TypeVec.append1.{u1} n v \u03b1)) (f \u03b1 v)\nbut is expected to have type\n  forall (n : Nat) {\u03b2 : (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), \u03b2 (TypeVec.append1.{u2} n v t)) (v : TypeVec.{u2} n) (\u03b1 : Type.{u2}), Eq.{u1} (\u03b2 (TypeVec.append1.{u2} n v \u03b1)) (TypeVec.casesCons.{u2, u1} n \u03b2 f (TypeVec.append1.{u2} n v \u03b1)) (f \u03b1 v)\nCase conversion may be inaccurate. Consider using '#align typevec.cases_cons_append1 TypeVec.casesCons_append1\u2093'. -/\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 : \u2115) {\u03b2 : TypeVec (n + 1) \u2192 Sort _}\n    (f : \u2200 (t) (v : TypeVec n), \u03b2 (v ::: t)) (v : TypeVec n) (\u03b1) :\n    TypeVec.casesCons n f (v ::: \u03b1) = f \u03b1 v :=\n  rfl\n#align typevec.cases_cons_append1 TypeVec.casesCons_append1\n\n#print TypeVec.typevecCasesNil\u2083 /-\n/-- cases distinction for an arrow in the category of 0-length type vectors -/\ndef typevecCasesNil\u2083 {\u03b2 : \u2200 v v' : TypeVec 0, v \u27f9 v' \u2192 Sort _}\n    (f : \u03b2 Fin2.elim0 Fin2.elim0 nilFun) : \u2200 v v' fs, \u03b2 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\u2083 TypeVec.typevecCasesNil\u2083\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\u2083 /-\n/-- cases distinction for an arrow in the category of (n+1)-length type vectors -/\ndef typevecCasesCons\u2083 (n : \u2115) {\u03b2 : \u2200 v v' : TypeVec (n + 1), v \u27f9 v' \u2192 Sort _}\n    (F :\n      \u2200 (t t') (f : t \u2192 t') (v v' : TypeVec n) (fs : v \u27f9 v'), \u03b2 (v ::: t) (v' ::: t') (fs ::: f)) :\n    \u2200 v v' fs, \u03b2 v v' fs := by\n  intro v v'\n  rw [\u2190 append1_drop_last v, \u2190 append1_drop_last v']\n  intro fs\n  rw [\u2190 split_drop_fun_last_fun fs]\n  apply F\n#align typevec.typevec_cases_cons\u2083 TypeVec.typevecCasesCons\u2083\n-/\n\n#print TypeVec.typevecCasesNil\u2082 /-\n/-- specialized cases distinction for an arrow in the category of 0-length type vectors -/\ndef typevecCasesNil\u2082 {\u03b2 : Fin2.elim0 \u27f9 Fin2.elim0 \u2192 Sort _} (f : \u03b2 nilFun) : \u2200 f, \u03b2 f :=\n  by\n  intro g; have : g = nil_fun; ext \u27e8\u27e9\n  rw [this]; exact f\n#align typevec.typevec_cases_nil\u2082 TypeVec.typevecCasesNil\u2082\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\u2082 /-\n/-- specialized cases distinction for an arrow in the category of (n+1)-length type vectors -/\ndef typevecCasesCons\u2082 (n : \u2115) (t t' : Type _) (v v' : TypeVec n)\n    {\u03b2 : (v ::: t) \u27f9 (v' ::: t') \u2192 Sort _} (F : \u2200 (f : t \u2192 t') (fs : v \u27f9 v'), \u03b2 (fs ::: f)) :\n    \u2200 fs, \u03b2 fs := by\n  intro fs\n  rw [\u2190 split_drop_fun_last_fun fs]\n  apply F\n#align typevec.typevec_cases_cons\u2082 TypeVec.typevecCasesCons\u2082\n-/\n\n/- warning: typevec.typevec_cases_nil\u2082_append_fun -> TypeVec.typevecCasesNil\u2082_appendFun is a dubious translation:\nlean 3 declaration is\n  forall {\u03b2 : (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 (\u1fb0 : 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 (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2}))) -> Sort.{u3}} (f : \u03b2 (TypeVec.nilFun.{u1, u2} (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : 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 (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2})))), Eq.{u3} (\u03b2 (TypeVec.nilFun.{u1, u2} (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : 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 (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) => Type.{u2})))) (TypeVec.typevecCasesNil\u2082.{u1, u2, u3} \u03b2 f (TypeVec.nilFun.{u1, u2} (Fin2.elim0.{succ (succ u1)} (fun (\u1fb0 : 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 (\u1fb0 : 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 {\u03b2 : (TypeVec.Arrow.{u3, u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) (Fin2.elim0.{succ (succ u3)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u3})) (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2}))) -> Sort.{u1}} (f : \u03b2 (TypeVec.nilFun.{u3, u2} (Fin2.elim0.{succ (succ u3)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u3})) (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2})))), Eq.{u1} (\u03b2 (TypeVec.nilFun.{u3, u2} (Fin2.elim0.{succ (succ u3)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u3})) (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2})))) (TypeVec.typevecCasesNil\u2082.{u3, u2, u1} \u03b2 f (TypeVec.nilFun.{u3, u2} (Fin2.elim0.{succ (succ u3)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u3})) (Fin2.elim0.{succ (succ u2)} (fun (\u1fb0 : Fin2 (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) => Type.{u2})))) f\nCase conversion may be inaccurate. Consider using '#align typevec.typevec_cases_nil\u2082_append_fun TypeVec.typevecCasesNil\u2082_appendFun\u2093'. -/\ntheorem typevecCasesNil\u2082_appendFun {\u03b2 : Fin2.elim0 \u27f9 Fin2.elim0 \u2192 Sort _} (f : \u03b2 nilFun) :\n    typevecCasesNil\u2082 f nilFun = f :=\n  rfl\n#align typevec.typevec_cases_nil\u2082_append_fun TypeVec.typevecCasesNil\u2082_appendFun\n\n/- warning: typevec.typevec_cases_cons\u2082_append_fun -> TypeVec.typevecCasesCons\u2082_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) {\u03b2 : (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'), \u03b2 (TypeVec.appendFun.{u1, u2} n v v' t t' fs f)) (f : t -> t') (fs : TypeVec.Arrow.{u1, u2} n v v'), Eq.{u3} (\u03b2 (TypeVec.appendFun.{u1, u2} n v v' t t' fs f)) (TypeVec.typevecCasesCons\u2082.{u1, u2, u3} n t t' v v' \u03b2 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) {\u03b2 : (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'), \u03b2 (TypeVec.appendFun.{u3, u2} n v v' t t' fs f)) (f : t -> t') (fs : TypeVec.Arrow.{u3, u2} n v v'), Eq.{u1} (\u03b2 (TypeVec.appendFun.{u3, u2} n v v' t t' fs f)) (TypeVec.typevecCasesCons\u2082.{u3, u2, u1} n t t' v v' \u03b2 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\u2082_append_fun TypeVec.typevecCasesCons\u2082_appendFun\u2093'. -/\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\u2082_appendFun (n : \u2115) (t t' : Type _) (v v' : TypeVec n)\n    {\u03b2 : (v ::: t) \u27f9 (v' ::: t') \u2192 Sort _} (F : \u2200 (f : t \u2192 t') (fs : v \u27f9 v'), \u03b2 (fs ::: f)) (f fs) :\n    typevecCasesCons\u2082 n t t' v v' F (fs ::: f) = F f fs :=\n  rfl\n#align typevec.typevec_cases_cons\u2082_append_fun TypeVec.typevecCasesCons\u2082_appendFun\n\n#print TypeVec.PredLast /-\n-- for lifting predicates and relations\n/-- `pred_last \u03b1 p x` predicates `p` of the last element of `x : \u03b1.append1 \u03b2`. -/\ndef PredLast (\u03b1 : TypeVec n) {\u03b2 : Type _} (p : \u03b2 \u2192 Prop) : \u2200 \u2983i\u2984, (\u03b1.append1 \u03b2) i \u2192 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 \u03b1 r x y` says that `p` the last elements of `x y : \u03b1.append1 \u03b2` are related by `r` and\nall the other elements are equal. -/\ndef RelLast (\u03b1 : TypeVec n) {\u03b2 \u03b3 : Type _} (r : \u03b2 \u2192 \u03b3 \u2192 Prop) :\n    \u2200 \u2983i\u2984, (\u03b1.append1 \u03b2) i \u2192 (\u03b1.append1 \u03b3) i \u2192 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 : \u2200 (n : \u2115) (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 \u03b1 \u03b2` is the pointwise product of the components of `\u03b1` and `\u03b2` -/\ndef prod : \u2200 {n} (\u03b1 \u03b2 : TypeVec.{u} n), TypeVec n\n  | 0, \u03b1, \u03b2 => Fin2.elim0\n  | n + 1, \u03b1, \u03b2 => Prod (drop \u03b1) (drop \u03b2) ::: last \u03b1 \u00d7 last \u03b2\n#align typevec.prod TypeVec.prod\n-/\n\n-- mathport name: typevec.prod\nscoped[MvFunctor] infixl:45 \" \u2297 \" => TypeVec.prod\n\n#print TypeVec.const /-\n/-- `const x \u03b1` is an arrow that ignores its source and constructs a `typevec` that\ncontains nothing but `x` -/\nprotected def const {\u03b2} (x : \u03b2) : \u2200 {n} (\u03b1 : TypeVec n), \u03b1 \u27f9 repeat _ \u03b2\n  | succ n, \u03b1, Fin2.fs i => const (drop \u03b1) _\n  | succ n, \u03b1, 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 : \u2200 {n} (\u03b1 : TypeVec n), \u03b1 \u2297 \u03b1 \u27f9 repeat _ Prop\n  | 0, \u03b1 => nilFun\n  | succ n, \u03b1 => repeat_eq (drop \u03b1) ::: 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 {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} (x : \u03b3) {n : Nat} (\u03b1 : 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 \u03b1 \u03b2) (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)))) \u03b3)) (TypeVec.const.{u2, u1} \u03b3 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 \u03b1 \u03b2)) (TypeVec.appendFun.{u1, u2} n \u03b1 (TypeVec.repeat.{u2} (Nat.add n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) \u03b3) \u03b2 \u03b3 (TypeVec.const.{u2, u1} \u03b3 x n \u03b1) (fun (_x : \u03b2) => x))\nbut is expected to have type\n  forall {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (x : \u03b3) {n : Nat} (\u03b1 : 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 \u03b1 \u03b2) (TypeVec.repeat.{u1} (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) n (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) \u03b3)) (TypeVec.const.{u1, u2} \u03b3 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 \u03b1 \u03b2)) (TypeVec.appendFun.{u2, u1} n \u03b1 (TypeVec.repeat.{u1} n \u03b3) \u03b2 \u03b3 (TypeVec.const.{u1, u2} \u03b3 x n \u03b1) (fun (_x : \u03b2) => x))\nCase conversion may be inaccurate. Consider using '#align typevec.const_append1 TypeVec.const_append1\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem const_append1 {\u03b2 \u03b3} (x : \u03b3) {n} (\u03b1 : TypeVec n) :\n    TypeVec.const x (\u03b1 ::: \u03b2) = appendFun (TypeVec.const x \u03b1) 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 {\u03b1 : TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))} {\u03b2 : 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))) \u03b1 \u03b2), 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))) \u03b1 \u03b2) f (TypeVec.nilFun.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : TypeVec.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))} {\u03b2 : TypeVec.{u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))} (f : TypeVec.Arrow.{u2, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) \u03b1 \u03b2), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) \u03b1 \u03b2) f (TypeVec.nilFun.{u2, u1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align typevec.eq_nil_fun TypeVec.eq_nilFun\u2093'. -/\ntheorem eq_nilFun {\u03b1 \u03b2 : TypeVec 0} (f : \u03b1 \u27f9 \u03b2) : 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 {\u03b1 : TypeVec 0} : @id _ \u03b1 = 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 {\u03b2 : Type.{u1}} (x : \u03b2) (\u03b1 : 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))) \u03b1 (TypeVec.repeat.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) \u03b2)) (TypeVec.const.{u1, u2} \u03b2 x (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) \u03b1) (TypeVec.nilFun.{u2, u1} \u03b1 (TypeVec.repeat.{u1} (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) \u03b2))\nbut is expected to have type\n  forall {\u03b2 : Type.{u2}} (x : \u03b2) (\u03b1 : 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)) \u03b1 (TypeVec.repeat.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) \u03b2)) (TypeVec.const.{u2, u1} \u03b2 x (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) \u03b1) (TypeVec.nilFun.{u1, u2} \u03b1 (TypeVec.repeat.{u2} (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) \u03b2))\nCase conversion may be inaccurate. Consider using '#align typevec.const_nil TypeVec.const_nil\u2093'. -/\ntheorem const_nil {\u03b2} (x : \u03b2) (\u03b1 : TypeVec 0) : TypeVec.const x \u03b1 = 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 {\u03b2} {n} (\u03b1 : TypeVec n) :\n    repeatEq (\u03b1 ::: \u03b2) = splitFun (repeatEq \u03b1) (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 (\u03b1 : TypeVec 0) : repeatEq \u03b1 = 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' (\u03b1 : TypeVec n) {\u03b2 : Type _} (p : \u03b2 \u2192 Prop) : (\u03b1 ::: \u03b2) \u27f9 repeat (n + 1) Prop :=\n  splitFun (TypeVec.const True \u03b1) 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' (\u03b1 : TypeVec n) {\u03b2 : Type _} (p : \u03b2 \u2192 \u03b2 \u2192 Prop) :\n    (\u03b1 ::: \u03b2) \u2297 (\u03b1 ::: \u03b2) \u27f9 repeat (n + 1) Prop :=\n  splitFun (repeatEq \u03b1) (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) \u2192 Type u`, `curry F : Type u \u2192 typevec.{u} \u2192 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) \u2192 Type _) (\u03b1 : Type u) (\u03b2 : TypeVec.{u} n) : Type _ :=\n  F (\u03b2 ::: \u03b1)\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) \u2192 Type _) (\u03b1 : Type u) (\u03b2 : TypeVec.{u} n)\n    [I : Inhabited (F <| (\u03b2 ::: \u03b1))] : Inhabited (Curry F \u03b1 \u03b2) :=\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 (\u03b1 : Type _) : \u2200 {n}, drop (repeat (succ n) \u03b1) \u27f9 repeat n \u03b1\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 {\u03b1 : Sort _} : \u2200 {n i}, repeat n \u03b1 i \u2192 \u03b1\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 {\u03b1 : TypeVec n} {i x p} : ofRepeat (TypeVec.const p \u03b1 i x) \u2194 p := by\n  induction i <;> [rfl, erw [TypeVec.const, @i_ih (drop \u03b1) x]]\n#align typevec.const_iff_true TypeVec.const_iff_true\n-/\n\n-- variables  {F : typevec.{u} n \u2192 Type*} [mvfunctor F]\nvariable {\u03b1 \u03b2 \u03b3 : TypeVec.{u} n}\n\nvariable (p : \u03b1 \u27f9 repeat n Prop) (r : \u03b1 \u2297 \u03b1 \u27f9 repeat n Prop)\n\n#print TypeVec.prod.fst /-\n/-- left projection of a `prod` vector -/\ndef prod.fst : \u2200 {n} {\u03b1 \u03b2 : TypeVec.{u} n}, \u03b1 \u2297 \u03b2 \u27f9 \u03b1\n  | succ n, \u03b1, \u03b2, Fin2.fs i => @Prod.fst _ (drop \u03b1) (drop \u03b2) i\n  | succ n, \u03b1, \u03b2, 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 : \u2200 {n} {\u03b1 \u03b2 : TypeVec.{u} n}, \u03b1 \u2297 \u03b2 \u27f9 \u03b2\n  | succ n, \u03b1, \u03b2, Fin2.fs i => @Prod.snd _ (drop \u03b1) (drop \u03b2) i\n  | succ n, \u03b1, \u03b2, 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 : \u2200 {n} {\u03b1 : TypeVec.{u} n}, \u03b1 \u27f9 \u03b1 \u2297 \u03b1\n  | succ n, \u03b1, Fin2.fs i, x => @prod.diag _ (drop \u03b1) _ x\n  | succ n, \u03b1, 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 : \u2200 {n} {\u03b1 \u03b2 : TypeVec.{u} n} (i : Fin2 n), \u03b1 i \u2192 \u03b2 i \u2192 (\u03b1 \u2297 \u03b2) i\n  | succ n, \u03b1, \u03b2, Fin2.fs i => Prod.mk i\n  | succ n, \u03b1, \u03b2, 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 {\u03b1 \u03b2 : TypeVec n} (i : Fin2 n) (a : \u03b1 i) (b : \u03b2 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 {\u03b1 \u03b2 : TypeVec n} (i : Fin2 n) (a : \u03b1 i) (b : \u03b2 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 : \u2200 {n} {\u03b1 \u03b1' \u03b2 \u03b2' : TypeVec.{u} n}, \u03b1 \u27f9 \u03b2 \u2192 \u03b1' \u27f9 \u03b2' \u2192 \u03b1 \u2297 \u03b1' \u27f9 \u03b2 \u2297 \u03b2'\n  | succ n, \u03b1, \u03b1', \u03b2, \u03b2', x, y, Fin2.fs i, a =>\n    @Prod.map _ (drop \u03b1) (drop \u03b1') (drop \u03b2) (drop \u03b2') (dropFun x) (dropFun y) _ a\n  | succ n, \u03b1, \u03b1', \u03b2, \u03b2', 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 \" \u2297' \" => TypeVec.prod.map\n\n#print TypeVec.fst_prod_mk /-\ntheorem fst_prod_mk {\u03b1 \u03b1' \u03b2 \u03b2' : TypeVec n} (f : \u03b1 \u27f9 \u03b2) (g : \u03b1' \u27f9 \u03b2') :\n    TypeVec.prod.fst \u229a (f \u2297' g) = f \u229a 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 {\u03b1 \u03b1' \u03b2 \u03b2' : TypeVec n} (f : \u03b1 \u27f9 \u03b2) (g : \u03b1' \u27f9 \u03b2') :\n    TypeVec.prod.snd \u229a (f \u2297' g) = g \u229a 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 {\u03b1 : TypeVec n} : TypeVec.prod.fst \u229a (prod.diag : \u03b1 \u27f9 _) = 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 {\u03b1 : TypeVec n} : TypeVec.prod.snd \u229a (prod.diag : \u03b1 \u27f9 _) = 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 {\u03b1 : TypeVec n} {i x y} : ofRepeat (repeatEq \u03b1 i (prod.mk _ x y)) \u2194 x = y :=\n  by induction i <;> [rfl, erw [repeat_eq, @i_ih (drop \u03b1) 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 `\u03b1`, `subtype_ p` is the type of vectors\nthat contain an `\u03b1` that satisfies `p` -/\ndef Subtype_ : \u2200 {n} {\u03b1 : TypeVec.{u} n} (p : \u03b1 \u27f9 repeat n Prop), TypeVec n\n  | _, \u03b1, p, Fin2.fz => Subtype fun x => p Fin2.fz x\n  | _, \u03b1, 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 : \u2200 {n} {\u03b1 : TypeVec.{u} n} (p : \u03b1 \u27f9 repeat n Prop), Subtype_ p \u27f9 \u03b1\n  | succ n, \u03b1, p, Fin2.fs i => @subtype_val n _ _ i\n  | succ n, \u03b1, 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    \u2200 {n} {\u03b1 : TypeVec.{u} n} (p : \u03b1 \u27f9 repeat n Prop),\n      (fun i : Fin2 n => { x // ofRepeat <| p i x }) \u27f9 Subtype_ p\n  | succ n, \u03b1, p, Fin2.fs i, x => to_subtype (dropFun p) i x\n  | succ n, \u03b1, 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    \u2200 {n} {\u03b1 : TypeVec.{u} n} (p : \u03b1 \u27f9 repeat n Prop),\n      Subtype_ p \u27f9 fun i : Fin2 n => { x // ofRepeat <| p i x }\n  | succ n, \u03b1, p, Fin2.fs i, x => of_subtype _ i x\n  | succ n, \u03b1, 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    \u2200 {n} {\u03b1 : TypeVec.{u} n} (p : \u03b1 \u2297 \u03b1 \u27f9 repeat n Prop),\n      (fun i : Fin2 n => { x : \u03b1 i \u00d7 \u03b1 i // ofRepeat <| p i (prod.mk _ x.1 x.2) }) \u27f9 Subtype_ p\n  | succ n, \u03b1, p, Fin2.fs i, x => to_subtype' (dropFun p) i x\n  | succ n, \u03b1, p, Fin2.fz, x => \u27e8x.val, cast (by congr <;> simp [Prod.mk]) x.property\u27e9\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    \u2200 {n} {\u03b1 : TypeVec.{u} n} (p : \u03b1 \u2297 \u03b1 \u27f9 repeat n Prop),\n      Subtype_ p \u27f9 fun i : Fin2 n => { x : \u03b1 i \u00d7 \u03b1 i // ofRepeat <| p i (prod.mk _ x.1 x.2) }\n  | _, \u03b1, p, Fin2.fs i, x => of_subtype' _ i x\n  | _, \u03b1, p, Fin2.fz, x => \u27e8x.val, cast (by congr <;> simp [Prod.mk]) x.property\u27e9\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 : \u2200 {n} {\u03b1 : TypeVec.{u} n}, \u03b1 \u27f9 Subtype_ (repeatEq \u03b1)\n  | succ n, \u03b1, Fin2.fs i, x => @diag_sub _ (drop \u03b1) _ x\n  | succ n, \u03b1, Fin2.fz, x => \u27e8(x, x), rfl\u27e9\n#align typevec.diag_sub TypeVec.diagSub\n-/\n\n#print TypeVec.subtypeVal_nil /-\ntheorem subtypeVal_nil {\u03b1 : TypeVec.{u} 0} (ps : \u03b1 \u27f9 repeat 0 Prop) :\n    TypeVec.subtypeVal ps = nilFun :=\n  funext <| by rintro \u27e8\u27e9 <;> rfl\n#align typevec.subtype_val_nil TypeVec.subtypeVal_nil\n-/\n\n#print TypeVec.diag_sub_val /-\ntheorem diag_sub_val {n} {\u03b1 : TypeVec.{u} n} : subtypeVal (repeatEq \u03b1) \u229a 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 : \u2200 {n} {\u03b1 \u03b2 : TypeVec.{u} n}, (id \u2297' id) = (id : \u03b1 \u2297 \u03b2 \u27f9 _) :=\n  by\n  intros ; ext (i a); induction i\n  \u00b7 cases a\n    rfl\n  \u00b7 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} {\u03b1 \u03b1' \u03b2 \u03b2' : TypeVec.{u} n} {\u03c6 \u03c6' \u03c8 \u03c8' : Type u} {f\u2080 : \u03b1 \u27f9 \u03b1'}\n    {g\u2080 : \u03b2 \u27f9 \u03b2'} {f\u2081 : \u03c6 \u2192 \u03c6'} {g\u2081 : \u03c8 \u2192 \u03c8'} :\n    (f\u2080 \u2297' g\u2080 ::: Prod.map f\u2081 g\u2081) = ((f\u2080 ::: f\u2081) \u2297' (g\u2080 ::: g\u2081)) := 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 {\u03b1} : dropFun (@prod.diag (n + 1) \u03b1) = 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 {\u03b1} (p : \u03b1 \u27f9 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 {\u03b1} (p : \u03b1 \u27f9 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 {\u03b1} (p : \u03b1 \u27f9 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 {\u03b1} (p : \u03b1 \u27f9 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 {\u03b1} (p : \u03b1 \u27f9 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 {\u03b1} (p : \u03b1 \u27f9 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' {\u03b1 : TypeVec n} {\u03b2} (R : \u03b2 \u2192 \u03b2 \u2192 Prop) :\n    dropFun (RelLast' \u03b1 R) = repeatEq \u03b1 :=\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 {\u03b1 \u03b1' \u03b2 \u03b2' : TypeVec (n + 1)} (f : \u03b1 \u27f9 \u03b2) (f' : \u03b1' \u27f9 \u03b2') :\n    dropFun (f \u2297' f') = (dropFun f \u2297' 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 {\u03b1 \u03b1' \u03b2 \u03b2' : TypeVec (n + 1)} (f : \u03b1 \u27f9 \u03b2) (f' : \u03b1' \u27f9 \u03b2') :\n    lastFun (f \u2297' 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 {\u03b1 : TypeVec (n + 1)} :\n    dropFun (@fromAppend1DropLast _ \u03b1) = 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 {\u03b1 : TypeVec (n + 1)} :\n    lastFun (@fromAppend1DropLast _ \u03b1) = 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 {\u03b1 : TypeVec (n + 1)} : dropFun (@TypeVec.id _ \u03b1) = 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 {\u03b1 \u03b2 : TypeVec n} : (@TypeVec.id _ \u03b1 \u2297' @TypeVec.id _ \u03b2) = 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 {\u03b1 : TypeVec n} : subtypeVal (repeatEq \u03b1) \u229a 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 {\u03b1 : TypeVec n} (p : \u03b1 \u27f9 repeat n Prop) :\n    toSubtype p \u229a 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 {\u03b1 : TypeVec n} (p : \u03b1 \u27f9 repeat n Prop) :\n    subtypeVal p \u229a 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} {\u03b1 : TypeVec.{u1} n} {\u03b2 : TypeVec.{u2} n} (p : TypeVec.Arrow.{u1, 0} n \u03b1 (TypeVec.repeat.{0} n Prop)) (f : TypeVec.Arrow.{u2, u1} n \u03b2 (TypeVec.Subtype_.{u1} n \u03b1 p)), Eq.{max 1 (succ u2) (succ u1)} (TypeVec.Arrow.{u2, u1} n \u03b2 (TypeVec.Subtype_.{u1} n \u03b1 p)) (TypeVec.comp.{u2, u1, u1} n \u03b2 (fun (i : Fin2 n) => Subtype.{succ u1} (\u03b1 i) (fun (x : \u03b1 i) => TypeVec.ofRepeat.{0} Prop n i (p i x))) (TypeVec.Subtype_.{u1} n \u03b1 p) (TypeVec.toSubtype.{u1} n \u03b1 p) (TypeVec.comp.{u2, u1, u1} n \u03b2 (TypeVec.Subtype_.{u1} n (fun (i : Fin2 n) => \u03b1 i) (fun (i : Fin2 n) (x : \u03b1 i) => p i x)) (fun (i : Fin2 n) => Subtype.{succ u1} (\u03b1 i) (fun (x : \u03b1 i) => TypeVec.ofRepeat.{0} Prop n i (p i x))) (TypeVec.ofSubtype.{u1} n (fun (i : Fin2 n) => \u03b1 i) (fun (i : Fin2 n) (x : \u03b1 i) => p i x)) f)) f\nbut is expected to have type\n  forall {n : Nat} {\u03b1 : TypeVec.{u2} n} {\u03b2 : TypeVec.{u1} n} (p : TypeVec.Arrow.{u2, 0} n \u03b1 (TypeVec.repeat.{0} n Prop)) (f : TypeVec.Arrow.{u1, u2} n \u03b2 (TypeVec.Subtype_.{u2} n \u03b1 p)), Eq.{max (succ u2) (succ u1)} (TypeVec.Arrow.{u1, u2} n \u03b2 (TypeVec.Subtype_.{u2} n \u03b1 p)) (TypeVec.comp.{u1, u2, u2} n \u03b2 (fun (i : Fin2 n) => Subtype.{succ u2} (\u03b1 i) (fun (x : \u03b1 i) => TypeVec.ofRepeat.{0} Prop n i (p i x))) (TypeVec.Subtype_.{u2} n \u03b1 p) (TypeVec.toSubtype.{u2} n \u03b1 p) (TypeVec.comp.{u1, u2, u2} n \u03b2 (TypeVec.Subtype_.{u2} n (fun (i : Fin2 n) => \u03b1 i) (fun (i : Fin2 n) (x : \u03b1 i) => p i x)) (fun (i : Fin2 n) => Subtype.{succ u2} (\u03b1 i) (fun (x : \u03b1 i) => TypeVec.ofRepeat.{0} Prop n i (p i x))) (TypeVec.ofSubtype.{u2} n (fun (i : Fin2 n) => \u03b1 i) (fun (i : Fin2 n) (x : \u03b1 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\u2093'. -/\n@[simp]\ntheorem toSubtype_of_subtype_assoc {\u03b1 \u03b2 : TypeVec n} (p : \u03b1 \u27f9 repeat n Prop) (f : \u03b2 \u27f9 Subtype_ p) :\n    @toSubtype n _ p \u229a ofSubtype _ \u229a f = f := by rw [\u2190 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' {\u03b1 : TypeVec n} (r : \u03b1 \u2297 \u03b1 \u27f9 repeat n Prop) :\n    toSubtype' r \u229a 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' {\u03b1 : TypeVec n} (r : \u03b1 \u2297 \u03b1 \u27f9 repeat n Prop) :\n    subtypeVal r \u229a 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\u2081 P\u2081 V\u2082 P\u2082 : Type _} [Ring k] [AddCommGroup V\u2081] [AddCommGroup V\u2082] [Module k V\u2081]\n  [Module k V\u2082] [AddTorsor V\u2081 P\u2081] [AddTorsor V\u2082 P\u2082]\n\n-- not an instance because it loops with `Nonempty`\ntheorem AffineSubspace.nonempty_map {E : AffineSubspace k P\u2081} [Ene : Nonempty E] {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} :\n    Nonempty (E.map \u03c6) := by\n  obtain \u27e8x, hx\u27e9 := id Ene\n  refine' \u27e8\u27e8\u03c6 x, AffineSubspace.mem_map.mpr \u27e8x, hx, rfl\u27e9\u27e9\u27e9\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 (\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082) {E : AffineSubspace k P\u2081} {F : AffineSubspace k P\u2082}\n    [Nonempty E] [Nonempty F] (hEF : E.map \u03c6 \u2264 F) : E \u2192\u1d43[k] F := by\n  refine' \u27e8_, _, _\u27e9\n  \u00b7 exact fun x => \u27e8\u03c6 x, hEF <| AffineSubspace.mem_map.mpr \u27e8x, x.property, rfl\u27e9\u27e9\n  \u00b7 refine' \u03c6.linear.restrict (_ : E.direction \u2264 F.direction.comap \u03c6.linear)\n    rw [\u2190 Submodule.map_le_iff_le_comap, \u2190 AffineSubspace.map_direction]\n    exact AffineSubspace.direction_le hEF\n  \u00b7 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 (\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082) {E : AffineSubspace k P\u2081}\n    {F : AffineSubspace k P\u2082} [Nonempty E] [Nonempty F] (hEF : E.map \u03c6 \u2264 F) (x : E) :\n    \u2191(\u03c6.restrict hEF x) = \u03c6 x :=\n  rfl\n#align affine_map.restrict.coe_apply AffineMap.restrict.coe_apply\n\ntheorem AffineMap.restrict.linear_aux {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} {E : AffineSubspace k P\u2081}\n    {F : AffineSubspace k P\u2082} (hEF : E.map \u03c6 \u2264 F) : E.direction \u2264 F.direction.comap \u03c6.linear := by\n  rw [\u2190 Submodule.map_le_iff_le_comap, \u2190 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 (\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082) {E : AffineSubspace k P\u2081}\n    {F : AffineSubspace k P\u2082} [Nonempty E] [Nonempty F] (hEF : E.map \u03c6 \u2264 F) :\n    (\u03c6.restrict hEF).linear = \u03c6.linear.restrict (AffineMap.restrict.linear_aux hEF) :=\n  rfl\n#align affine_map.restrict.linear AffineMap.restrict.linear\n\ntheorem AffineMap.restrict.injective {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} (h\u03c6 : Function.Injective \u03c6)\n    {E : AffineSubspace k P\u2081} {F : AffineSubspace k P\u2082} [Nonempty E] [Nonempty F]\n    (hEF : E.map \u03c6 \u2264 F) : Function.Injective (AffineMap.restrict \u03c6 hEF) := by\n  intro x y h\n  simp only [Subtype.ext_iff, Subtype.coe_mk, AffineMap.restrict.coe_apply] at h\u22a2\n  exact h\u03c6 h\n#align affine_map.restrict.injective AffineMap.restrict.injective\n\ntheorem AffineMap.restrict.surjective (\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082) {E : AffineSubspace k P\u2081}\n    {F : AffineSubspace k P\u2082} [Nonempty E] [Nonempty F] (h : E.map \u03c6 = F) :\n    Function.Surjective (AffineMap.restrict \u03c6 (le_of_eq h)) := by\n  rintro \u27e8x, hx : x \u2208 F\u27e9\n  rw [\u2190 h, AffineSubspace.mem_map] at hx\n  obtain \u27e8y, hy, rfl\u27e9 := hx\n  exact \u27e8\u27e8y, hy\u27e9, rfl\u27e9\n#align affine_map.restrict.surjective AffineMap.restrict.surjective\n\ntheorem AffineMap.restrict.bijective {E : AffineSubspace k P\u2081} [Nonempty E] {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082}\n    (h\u03c6 : Function.Injective \u03c6) : Function.Bijective (\u03c6.restrict (le_refl (E.map \u03c6))) :=\n  \u27e8AffineMap.restrict.injective h\u03c6 _, AffineMap.restrict.surjective _ rfl\u27e9\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 \u27f6[C] -` -/\n@[simps] def closed_ihom (F : D \u2964 C) : (D \u2964 C) \u2964 (D \u2964 C) :=\n((whiskering_right\u2082 D C\u1d52\u1d56 C C).obj internal_hom).obj (groupoid.inv_functor D \u22d9 F.op)\n\n/-- Auxiliary definition for `category_theory.monoidal_closed.functor_closed`.\nThe unit for the adjunction `(tensor_left F) \u22a3 (ihom F)`. -/\n@[simps]\ndef closed_unit (F : D \u2964 C) : \ud835\udfed (D \u2964 C) \u27f6 (tensor_left F) \u22d9 (closed_ihom F) :=\n{ app := \u03bb G,\n  { app := \u03bb 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, \u2190functor.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) \u22a3 (ihom F)`. -/\n@[simps]\ndef closed_counit (F : D \u2964 C) : (closed_ihom F) \u22d9 (tensor_left F) \u27f6 \ud835\udfed (D \u2964 C) :=\n{ app := \u03bb G,\n  { app := \u03bb 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 [\u2190tensor_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 \u2964 C` is\nclosed in the functor category `F : D \u2964 C` with the pointwise monoidal structure. -/\n@[simps] instance closed (F : D \u2964 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 \u2964 C`,\nwith the pointwise monoidal structure, is monoidal closed. -/\n@[simps] instance monoidal_closed : monoidal_closed (D \u2964 C) :=\n{ closed' := by apply_instance }\n\nlemma ihom_map (F : D \u2964 C) {G H : D \u2964 C} (f : G \u27f6 H) :\n  (ihom F).map f = (closed_ihom F).map f := rfl\n\nlemma ihom_ev_app (F G : D \u2964 C) :\n  (ihom.ev F).app G = (closed_counit F).app G := rfl\n\nlemma ihom_coev_app (F G : D \u2964 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 {\u03b1 \u03b2 : Type u}\n\ndef vanishing (\u03b8 : Subst \u03b1 \u03b2) :=\n  \u2200 {x}, (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03b8 \u2260 Term.Var x \u2192\n    \u2200 y, \u00ac (x \u2208 (\ud835\udcb1 ((Term.Var y : Term \u03b1 \u03b2) \u2022 \u03b8) : Fintype \u03b2))\n\ntheorem vanishing_on_term {\u03b8 : Subst \u03b1 \u03b2} (h\u2081 : vanishing \u03b8)\n  {x : \u03b2} (h\u2082 : (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03b8 \u2260 Term.Var x)\n  (u : Term \u03b1 \u03b2) : \u00ac x \u2208 (\ud835\udcb1 (u \u2022 \u03b8) : Fintype \u03b2) := by\n  induction u with\n  | Cst c => match \u03b8 with\n    | \u27e8 \u03b8, h \u27e9 => intro h; cases h <;> trivial\n  | Var y => exact h\u2081 h\u2082 _\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 {\u03b8 : Subst \u03b1 \u03b2} (h\u2081 : vanishing \u03b8)\n  {x : \u03b2} (h\u2082 : (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03b8 \u2260 Term.Var x) :\n  \u00ac x \u2208 (\ud835\udcb1 \u03b8 : Fintype \u03b2) := by\n  suffices h : \ud835\udcb1 \u03b8 \u2286 \ud835\udcb1 \u03b8 \\ (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\u2081 h\u2082\n\ntheorem vanishing_respects_vehicle {\u03b8 : Subst \u03b1 \u03b2} (h\u2081 : vanishing \u03b8) {x : \u03b2}\n  (h\u2082 : \u00ac x \u2208 (\ud835\udcb1 \u03b8 : Fintype \u03b2)) {u : Term \u03b1 \u03b2} (h\u2083 : \u00ac x \u2208 (\ud835\udcb1 u : Fintype \u03b2)) :\n  \u00ac x \u2208 (\ud835\udcb1 (u \u2022 \u03b8) : Fintype \u03b2) := 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\u2082 h\n  | Or.inr h => h\u2083 h\n\ntheorem cons_vanishing {\u03b8 \u03c6 : Subst \u03b1 \u03b2} {l\u2081 r\u2081 l\u2082 r\u2082 : Term \u03b1 \u03b2}\n  (h\u2081 : (\ud835\udcb1 \u03b8 : Fintype \u03b2) \u2286 \ud835\udcb1 l\u2081 \u222a \ud835\udcb1 l\u2082)\n  (h\u2082 : (\ud835\udcb1 \u03c6 : Fintype \u03b2) \u2286 \ud835\udcb1 (r\u2081 \u2022 \u03b8) \u222a \ud835\udcb1 (r\u2082 \u2022 \u03b8))\n  (h\u2083 : vanishing \u03b8) (h\u2084 : vanishing \u03c6) : vanishing (\u03b8 * \u03c6) := by\n  intro x hx y\n  by_cases h\u03b8 : (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03b8 = Term.Var x\n  focus\n    let p := show (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03c6 \u2260 Term.Var x by\n      intro h\u03c6\n      apply hx\n      rw [\u2190 RAction.smul_mul, h\u03b8, h\u03c6]\n    rw [\u2190 RAction.smul_mul]\n    apply vanishing_on_term h\u2084 p\n  focus\n    let p := show \u00ac x \u2208 (\ud835\udcb1 \u03c6 : Fintype \u03b2) by\n      apply Fintype.not_mem_of_superset_not_mem h\u2082\n      intro h\n      rw [Fintype.mem_union_iff] at h\n      exact match h with\n      | Or.inl h => (vanishing_on_term h\u2083 h\u03b8 r\u2081) h\n      | Or.inr h => (vanishing_on_term h\u2083 h\u03b8 r\u2082) h\n    rw [\u2190 RAction.smul_mul]\n    exact vanishing_respects_vehicle h\u2084 p (h\u2083 h\u03b8 _)\n\ntheorem elementary_vanishing {x : \u03b2} {u : Term \u03b1 \u03b2} {h\u2081 : Term.Var x \u2260 u}\n  (h\u2082 : \u00ac x \u2208 (\ud835\udcb1 u : Fintype \u03b2)) :\n  vanishing (Subst.elementary h\u2081 : Subst \u03b1 \u03b2) := 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\u2081] at h'\n    exact h\u2082 h'\n  focus\n    rw [Subst.elementary_spec\u2082 _ 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\u00f6lzl, 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\u27e8\u03bb M N [semiring M] [semiring N], by exactI @ring_hom.to_fun M N _ _,\n \u03bb M [semiring M], by exactI @ring_hom.id M _,\n \u03bb M N P [semiring M] [semiring N] [semiring P], by exactI @ring_hom.comp M N P _ _ _,\n \u03bb M N [semiring M] [semiring N], by exactI @ring_hom.coe_inj M N _ _\u27e9\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 \u2192+* S) : of R \u27f6 of S := f\n\n@[simp] lemma of_hom_apply {R S : Type u} [semiring R] [semiring S] (f : R \u2192+* S) (x : R) :\n  of_hom f x = f x := rfl\n\ninstance : inhabited SemiRing := \u27e8of punit\u27e9\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\u2082 SemiRing Mon :=\nbundled_hom.mk_has_forget\u2082\n  (\u03bb R hR, @monoid_with_zero.to_monoid R (@semiring.to_monoid_with_zero R hR))\n  (\u03bb R\u2081 R\u2082, ring_hom.to_monoid_hom) (\u03bb _ _ _, rfl)\n\ninstance has_forget_to_AddCommMon : has_forget\u2082 SemiRing AddCommMon :=\n-- can't use bundled_hom.mk_has_forget\u2082, since AddCommMon is an induced category\n{ forget\u2082 :=\n  { obj := \u03bb R, AddCommMon.of R,\n    map := \u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\n\nattribute [derive [(\u03bb 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 \u2192+* S) : of R \u27f6 of S := f\n\n@[simp] lemma of_hom_apply {R S : Type u} [ring R] [ring S] (f : R \u2192+* S) (x : R) :\n  of_hom f x = f x := rfl\n\ninstance : inhabited Ring := \u27e8of punit\u27e9\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\u2082 Ring SemiRing := bundled_hom.forget\u2082 _ _\ninstance has_forget_to_AddCommGroup : has_forget\u2082 Ring AddCommGroup :=\n-- can't use bundled_hom.mk_has_forget\u2082, since AddCommGroup is an induced category\n{ forget\u2082 :=\n  { obj := \u03bb R, AddCommGroup.of R,\n    map := \u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\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 \u2192+* S) : of R \u27f6 of S := f\n\n@[simp]\nlemma of_hom_apply {R S : Type u} [comm_semiring R] [comm_semiring S] (f : R \u2192+* S) (x : R) :\n  of_hom f x = f x := rfl\n\ninstance : inhabited CommSemiRing := \u27e8of punit\u27e9\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\u2082 CommSemiRing SemiRing := bundled_hom.forget\u2082 _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommMon : has_forget\u2082 CommSemiRing CommMon :=\nhas_forget\u2082.mk'\n  (\u03bb R : CommSemiRing, CommMon.of R) (\u03bb R, rfl)\n  (\u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\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 \u2192+* S) : of R \u27f6 of S := f\n\n@[simp] lemma of_hom_apply {R S : Type u} [comm_ring R] [comm_ring S] (f : R \u2192+* S) (x : R) :\n  of_hom f x = f x := rfl\n\ninstance : inhabited CommRing := \u27e8of punit\u27e9\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\u2082 CommRing Ring := bundled_hom.forget\u2082 _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommSemiRing : has_forget\u2082 CommRing CommSemiRing :=\nhas_forget\u2082.mk' (\u03bb R : CommRing, CommSemiRing.of R) (\u03bb R, rfl) (\u03bb R\u2081 R\u2082 f, f) (by tidy)\n\ninstance : full (forget\u2082 CommRing CommSemiRing) :=\n{ preimage := \u03bb 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 \u27f6 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 \u2243+* Y) : Ring.of X \u2245 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 \u2243+* Y) :\n  CommRing.of X \u2245 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 \u2245 Y) : X \u2243+* 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 \u2245 Y) : X \u2243+* 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 \u2245 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 \u2245 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 \u2243+* Y) \u2245 (Ring.of X \u2245 Ring.of Y) :=\n{ hom := \u03bb e, e.to_Ring_iso,\n  inv := \u03bb 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 \u2243+* Y) \u2245 (CommRing.of X \u2245 CommRing.of Y) :=\n{ hom := \u03bb e, e.to_CommRing_iso,\n  inv := \u03bb i, i.CommRing_iso_to_ring_equiv, }\n\ninstance Ring.forget_reflects_isos : reflects_isomorphisms (forget Ring.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Ring).map f),\n    let e : X \u2243+* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Ring_iso).1\u27e9,\n  end }\n\ninstance CommRing.forget_reflects_isos : reflects_isomorphisms (forget CommRing.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommRing).map f),\n    let e : X \u2243+* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommRing_iso).1\u27e9,\n  end }\n\n-- It would be nice if we could have the following,\n-- but it requires making `reflects_isomorphisms_forget\u2082` an instance,\n-- which can cause typeclass loops:\n\nlocal attribute [priority 50,instance] reflects_isomorphisms_forget\u2082\nexample : reflects_isomorphisms (forget\u2082 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 (\u03b1\u2081 : Type _) (\u03b1\u2082 : Type _) [Monoid \u03b1\u2081] [Monoid \u03b1\u2082] : Monoid (\u03b1\u2081 \u00d7 \u03b1\u2082) where\n      zero      := (0, 0)\n      add       := fun (x\u2081, x\u2082) (y\u2081, y\u2082) => (x\u2081 + y\u2081, x\u2082 + y\u2082)\n      add_zero  := fun (a\u2081, a\u2082) => by simp only [HAdd.hAdd, Add.add, Prod.mk.injEq]; exact \u27e8add_zero a\u2081, add_zero a\u2082\u27e9\n      zero_add  := fun (a\u2081, a\u2082) => by simp only [HAdd.hAdd, Add.add, Prod.mk.injEq]; exact \u27e8zero_add a\u2081, zero_add a\u2082\u27e9\n      add_assoc := fun (a\u2081, a\u2082) (b\u2081, b\u2082) (c\u2081, c\u2082) => by\n        simp only [HAdd.hAdd, Add.add, Prod.mk.injEq]\n        exact \u27e8add_assoc a\u2081 b\u2081 c\u2081, add_assoc a\u2082 b\u2082 c\u2082\u27e9\n\n    theorem product_zero (\u03b1\u2081 : Type _) (\u03b1\u2082 : Type _) [Monoid \u03b1\u2081] [Monoid \u03b1\u2082] : (0 : \u03b1\u2081 \u00d7 \u03b1\u2082) = (0, 0) := rfl\n    theorem product_add {\u03b1\u2081 : Type _} {\u03b1\u2082 : Type _} [Monoid \u03b1\u2081] [Monoid \u03b1\u2082] : \u2200 x y : \u03b1\u2081 \u00d7 \u03b1\u2082, x + y = (x.fst + y.fst, x.snd + y.snd) :=\n      fun (x\u2081, x\u2082) (y\u2081, y\u2082) => rfl\n\n    protected instance multi_product.Zero {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, Zero (f\u03b9 i)] : Zero (MultiProd f\u03b9) where\n      zero := fun _ => 0\n    protected theorem multi_product.Zero_def {\u03b9 : Type _} {f\u03b9 : \u03b9 \u2192 Type _} [\u2200 i, Zero (f\u03b9 i)] : \u2200 i, (0 : MultiProd f\u03b9) i = 0 :=\n      fun _ => rfl\n\n    protected instance multi_product.Add {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, Add (f\u03b9 i)] : Add (MultiProd f\u03b9) where\n      add := fun a b i => a i + b i\n    protected theorem multi_product.Add_def {\u03b9 : Type _} {f\u03b9 : \u03b9 \u2192 Type _} [\u2200 i, Add (f\u03b9 i)] (a b : MultiProd f\u03b9) :\n      \u2200 i, (a + b) i = a i + b i := fun _ => rfl\n\n    protected instance multi_product {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, Monoid (f\u03b9 i)] : Monoid (MultiProd f\u03b9) 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 (\u03b1\u2081 : Type _) (\u03b1\u2082 : Type _) [CommMonoid \u03b1\u2081] [CommMonoid \u03b1\u2082] : CommMonoid (\u03b1\u2081 \u00d7 \u03b1\u2082) where\n      add_comm := fun (a\u2081, a\u2082) (b\u2081, b\u2082) => by simp [HAdd.hAdd, Add.add]; exact \u27e8add_comm a\u2081 b\u2081, add_comm a\u2082 b\u2082\u27e9\n\n    protected instance multi_product {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, CommMonoid (f\u03b9 i)] : CommMonoid (MultiProd f\u03b9) where\n      add_comm := fun a b => funext fun i => CommMonoid.add_comm (a i) (b i)\n\n    theorem add_right_comm [CommMonoid \u03b1] (a b c : \u03b1) : a + b + c = a + c + b := by\n      rw [Monoid.add_assoc, add_comm b, \u2190Monoid.add_assoc]\n    theorem add_left_comm [CommMonoid \u03b1] (a b c : \u03b1) : a + (b + c) = b + (a + c) := by\n      rw [\u2190Monoid.add_assoc, add_comm a, Monoid.add_assoc]\n\n    protected class constructor_cm (\u03b1 : Type _) extends Zero \u03b1, Add \u03b1 where\n      add_zero  : \u2200 a : \u03b1, a + 0 = a\n      add_assoc : \u2200 a b c : \u03b1, (a + b) + c = a + (b + c)\n      add_comm  : \u2200 a b : \u03b1, a + b = b + a\n\n    protected def construct {\u03b1 : Type _} (c : CommMonoid.constructor_cm \u03b1) : CommMonoid \u03b1 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 (\u03b1 : Type _) [CommMonoid \u03b1] : CommMonoid.constructor_cm \u03b1 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 (\u03b1 : Type _) : CommMonoid (UnorderedList \u03b1) := 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 \u00d7 \u2115) := \nfirst_order.language.Structure.mk\u2082 empty.elim empty.elim empty.elim \n(\u03bb (b : bool), bool.rec {x : fin 3 \u00d7 \u2115 | x.fst = 0} {x : fin 3 \u00d7 \u2115 | x.fst = 1} b) empty.elim\n\ninstance modelB : (first_order.language.unary_preds).Structure (fin 2 \u00d7 \u2115) := \nfirst_order.language.Structure.mk\u2082 empty.elim empty.elim empty.elim \n(\u03bb (b : bool), bool.rec {x : fin 2 \u00d7 \u2115 | x.fst = 0} {x : fin 2 \u00d7 \u2115 | x.fst = 1} b) empty.elim\n\nlemma modelA\u2081up\u2081 : (fin 3 \u00d7 \u2115) \u22a8 (set.range (first_order.language.sentence.unary_card_ge first_order.language.up\u2081)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up\u2081,\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\u2081up\u2081 : (fin 2 \u00d7 \u2115) \u22a8 (set.range (first_order.language.sentence.unary_card_ge first_order.language.up\u2081)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up\u2081,\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\u2082up\u2081 : (fin 3 \u00d7 \u2115) \u22a8 (set.range (first_order.language.sentence.not_unary_card_ge first_order.language.up\u2081)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up\u2081,\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\u2082up\u2081 : (fin 2 \u00d7 \u2115) \u22a8 (set.range (first_order.language.sentence.not_unary_card_ge first_order.language.up\u2081)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up\u2081,\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\u2083 : (fin 3 \u00d7 \u2115) \u22a8 (first_order.language.sentence.unary_disjoint) :=\nbegin\n  simp,\n  rw first_order.language.up\u2081,\n  rw first_order.language.up\u2082,\n  simp,\n  rw disjoint_iff,\n  simp,\n  rw set.eq_empty_iff_forall_not_mem,\n  simp,\nend\n\nlemma modelB\u2083 : (fin 2 \u00d7 \u2115) \u22a8 (first_order.language.sentence.unary_disjoint) :=\nbegin\n  simp,\n  rw first_order.language.up\u2081,\n  rw first_order.language.up\u2082,\n  simp,\n  rw disjoint_iff,\n  simp,\n  rw set.eq_empty_iff_forall_not_mem,\n  simp,\nend\n\nlemma modelA\u2081up\u2082 : (fin 3 \u00d7 \u2115) \u22a8 (set.range (first_order.language.sentence.unary_card_ge first_order.language.up\u2082)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up\u2082,\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\u2081up\u2082 : (fin 2 \u00d7 \u2115) \u22a8 (set.range (first_order.language.sentence.unary_card_ge first_order.language.up\u2082)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up\u2082,\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\u2082up\u2082 : (fin 3 \u00d7 \u2115) \u22a8 (set.range (first_order.language.sentence.not_unary_card_ge first_order.language.up\u2082)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up\u2082,\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\u2082up\u2082 : (fin 2 \u00d7 \u2115) \u22a8 (set.range (first_order.language.sentence.not_unary_card_ge first_order.language.up\u2082)) :=\nbegin\n  simp,\n  refine set.infinite_coe_iff.mpr _,\n  rw first_order.language.up\u2082,\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 \u00d7 \u2115) \u22a8 (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\u2081up\u2081,\n  exact modelA\u2081up\u2082,\n  exact modelA\u2082up\u2081,\n  exact modelA\u2082up\u2082,\n  rw first_order.language.Theory.model_singleton_iff,\n  exact modelA\u2083,\nend\n\n\ninstance modelBT : (fin 2 \u00d7 \u2115) \u22a8 (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\u2081up\u2081,\n  exact modelB\u2081up\u2082,\n  exact modelB\u2082up\u2081,\n  exact modelB\u2082up\u2082,\n  rw first_order.language.Theory.model_singleton_iff,\n  exact modelB\u2083,\nend\n\nlemma modelA\u2135\u2080 : cardinal.mk (fin 3 \u00d7 \u2115) = cardinal.aleph_0 := \nbegin\n  rw \u2190 cardinal.denumerable_iff,\n  fconstructor,\n  exact denumerable.of_encodable_of_infinite (fin 3 \u00d7 \u2115),\nend\n\nlemma modelB\u2135\u2080 : cardinal.mk (fin 2 \u00d7 \u2115) = cardinal.aleph_0 := \nbegin\n  rw \u2190 cardinal.denumerable_iff,\n  fconstructor,\n  exact denumerable.of_encodable_of_infinite (fin 2 \u00d7 \u2115),\nend\n\ndef ModelA : first_order.language.Theory.Model (first_order.language.Theory.disjoint_unary_preds) := \n{ carrier := fin 3 \u00d7 \u2115 }\n\ndef ModelB : first_order.language.Theory.Model (first_order.language.Theory.disjoint_unary_preds) := \n{ carrier := fin 2 \u00d7 \u2115 }", "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 {\u03b9 : Type*} (A : \u03b9 \u2192 Type*) (M : \u03b9 \u2192 Type*)\n\n/-- A graded version of `has_smul`. Scalar multiplication combines grades additively, i.e.\nif `a \u2208 A i` and `m \u2208 M j`, then `a \u2022 b` must be in `M (i + j)`-/\nclass ghas_smul [has_add \u03b9] :=\n(smul {i j} : A i \u2192 M j \u2192 M (i + j))\n\ninstance ghas_mul.to_ghas_mul [has_add \u03b9] [ghas_mul A] : ghas_smul A A :=\n{ smul := \u03bb _ _, ghas_mul.mul }\n\ninstance [has_add \u03b9] [ghas_smul A M] : has_smul (graded_monoid A) (graded_monoid M) :=\n\u27e8\u03bb (x : graded_monoid A) (y : graded_monoid M), \u27e8_, ghas_smul.smul x.snd y.snd\u27e9\u27e9\n\n/-- A graded version of `mul_action`. -/\nclass gmul_action [add_monoid \u03b9] [graded_monoid.gmonoid A] extends ghas_smul A M :=\n(one_smul (b : graded_monoid M) : (1 : graded_monoid A) \u2022 b = b)\n(mul_smul (a a' : graded_monoid A) (b : graded_monoid M) : (a * a') \u2022 b = a \u2022 a' \u2022 b)\n\ninstance gmonoid.to_gmul_action [add_monoid \u03b9] [gmonoid A] :\n  gmul_action A A :=\n{ one_smul := \u03bb x, graded_monoid.gmonoid.one_mul x,\n  mul_smul := graded_monoid.gmonoid.mul_assoc }\n\ninstance [add_monoid \u03b9] [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 {\u03b9 S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add \u03b9] (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) : Prop :=\n(smul_mem : \u2200 \u2983i j : \u03b9\u2984 {ai bj}, ai \u2208 A i \u2192 bj \u2208 B j \u2192 ai \u2022 bj \u2208 B (i + j))\n\nlemma set_like.smul_mem_graded {\u03b9 S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add \u03b9] (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) [set_like.has_graded_smul A B]\n  \u2983i j\u2984 {gi gj} (hi : gi \u2208 A i) (hj : gj \u2208 B j) :\n  gi \u2022 gj \u2208 B (i + j) :=\nset_like.has_graded_smul.smul_mem hi hj\n\ninstance set_like.ghas_smul {\u03b9 S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add \u03b9] (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) [set_like.has_graded_smul A B] :\n  graded_monoid.ghas_smul (\u03bb i, A i) (\u03bb i, B i) :=\n{ smul := \u03bb i j a b, \u27e8(a : R) \u2022 b, set_like.has_graded_smul.smul_mem a.2 b.2\u27e9 }\n\n@[simp] lemma set_like.coe_ghas_smul {\u03b9 S R N M : Type*} [set_like S R] [set_like N M]\n  [has_smul R M] [has_add \u03b9] (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) [set_like.has_graded_smul A B]\n  {i j : \u03b9} (x : A i) (y : B j) :\n  (@graded_monoid.ghas_smul.smul \u03b9 (\u03bb i, A i) (\u03bb i, B i) _ _ i j x y : M) = ((x : R) \u2022 y) :=\nrfl\n\ninstance set_like.has_graded_mul.to_has_graded_smul\n  {\u03b9 S R : Type*} [set_like S R] [monoid R] [add_monoid \u03b9] (A : \u03b9 \u2192 S) [set_like.has_graded_mul A] :\n  set_like.has_graded_smul A A :=\n{ smul_mem := \u03bb 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 {\u03b9 : Type*} [add_monoid \u03b9] (A : \u03b9 \u2192 Type*) (M : \u03b9 \u2192 Type*)\n\n/-- A graded version of `distrib_mul_action`. -/\nclass gdistrib_mul_action [graded_monoid.gmonoid A] [\u03a0 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] [\u03a0 i, add_comm_monoid $ M i] [\u03a0 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 {\u03b9 : Type*} [add_monoid \u03b9] (A : \u03b9 \u2192 Type*) (M : \u03b9 \u2192 Type*)\nvariables [\u03a0 (i : \u03b9), add_comm_monoid (A i)] [\u03a0 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 \u2192+ M j \u2192+ M (i + j) :=\n{ to_fun := \u03bb a,\n  { to_fun := \u03bb 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 $ \u03bb a, gmodule.zero_smul a,\n  map_add' := \u03bb a\u2081 a\u2082, add_monoid_hom.ext $ \u03bb 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 \u03b9] [graded_monoid.gmonoid A] [gmodule A M] :\n  (\u2a01 i, A i) \u2192+ (\u2a01 i, M i) \u2192+ \u2a01 i, M i :=\ndirect_sum.to_add_monoid $ \u03bb i,\n  add_monoid_hom.flip $ direct_sum.to_add_monoid $ \u03bb j, add_monoid_hom.flip $\n    (direct_sum.of M _).comp_hom.comp $ gsmul_hom A M\n\nsection\n\nvariables [decidable_eq \u03b9] [graded_monoid.gmonoid A] [gmodule A M]\ninstance : has_smul (\u2a01 i, A i) (\u2a01 i, M i) :=\n{ smul := \u03bb x y, gmodule.smul_add_monoid_hom A M x y }\n\n@[simp] lemma gmodule.smul_def\n  (x : \u2a01 i, A i) (y : \u2a01 i, M i) : x \u2022 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 \u2022 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 \u03b9] [direct_sum.gsemiring A] [gmodule A M] (x : \u2a01 i, M i) :\n  (1 : \u2a01 i, A i) \u2022 x = x :=\nsuffices gmodule.smul_add_monoid_hom A M 1 = add_monoid_hom.id (\u2a01 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 \u03b9] [direct_sum.gsemiring A] [gmodule A M]\n  (a b : \u2a01 i, A i) (c : \u2a01 i, M i) : (a * b) \u2022 c = a \u2022 (b \u2022 c) :=\nsuffices (gmodule.smul_add_monoid_hom A M).comp_hom.comp (direct_sum.mul_hom A) -- `\u03bb a b c, (a * b) \u2022 c` as a bundled hom\n       = (add_monoid_hom.comp_hom add_monoid_hom.flip_hom $                     -- `\u03bb a b c, a \u2022 (b \u2022 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 \u03b9] [direct_sum.gsemiring A] [gmodule A M] :\n  module (\u2a01 i, A i) (\u2a01 i, M i) :=\n{ smul := (\u2022),\n  one_smul := one_smul _ _,\n  mul_smul := mul_smul _ _,\n  smul_add := \u03bb r, (gmodule.smul_add_monoid_hom A M r).map_add,\n  smul_zero := \u03bb r, (gmodule.smul_add_monoid_hom A M r).map_zero,\n  add_smul := \u03bb r s x, by simp only [gmodule.smul_def, map_add, add_monoid_hom.add_apply],\n  zero_smul := \u03bb 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 {\u03b9 R A M \u03c3 \u03c3' : Type*}\nvariables [add_monoid \u03b9] [comm_semiring R] [semiring A] [algebra R A]\nvariables (\ud835\udcd0 : \u03b9 \u2192 \u03c3') [set_like \u03c3' A]\nvariables (\ud835\udcdc : \u03b9 \u2192 \u03c3)\n\nopen_locale direct_sum\n\nnamespace graded_module\n\ninclude \u03c3' A \u03c3 M\n\ninstance gdistrib_mul_action [add_monoid M] [distrib_mul_action A M]\n  [set_like \u03c3 M] [add_submonoid_class \u03c3 M] [set_like.graded_monoid \ud835\udcd0]\n  [set_like.has_graded_smul \ud835\udcd0 \ud835\udcdc] :\n  gdistrib_mul_action (\u03bb i, \ud835\udcd0 i) (\u03bb i, \ud835\udcdc i) :=\n{ smul := \u03bb i j x y, \u27e8(x : A) \u2022 (y : M), set_like.has_graded_smul.smul_mem x.2 y.2\u27e9,\n  one_smul := \u03bb \u27e8i, m\u27e9, sigma.subtype_ext (zero_add _) (one_smul _ _),\n  mul_smul := \u03bb \u27e8i, a\u27e9 \u27e8j, a'\u27e9 \u27e8k, b\u27e9, sigma.subtype_ext (add_assoc _ _ _) (mul_smul _ _ _),\n  smul_add := \u03bb i j a b c, subtype.ext $ smul_add _ _ _,\n  smul_zero := \u03bb i j a, subtype.ext $ smul_zero _ }\n\nvariables [add_comm_monoid M] [module A M] [set_like \u03c3 M] [add_submonoid_class \u03c3' A]\n  [add_submonoid_class \u03c3 M] [set_like.graded_monoid \ud835\udcd0] [set_like.has_graded_smul \ud835\udcd0 \ud835\udcdc]\n\n-- [set_like.graded_monoid \ud835\udcd0] [set_like.has_graded_smul \ud835\udcd0 \ud835\udcdc] is the internal version of graded module\n-- the internal version can be translated into the external version `gmodule`.\ninstance gmodule : gmodule (\u03bb i, \ud835\udcd0 i) (\u03bb i, \ud835\udcdc i) :=\n{ smul := \u03bb i j x y, \u27e8(x : A) \u2022 (y : M), set_like.has_graded_smul.smul_mem x.2 y.2\u27e9,\n  add_smul := \u03bb i j a a' b, subtype.ext $ add_smul _ _ _,\n  zero_smul := \u03bb i j b, subtype.ext $ zero_smul _ _,\n  ..graded_module.gdistrib_mul_action \ud835\udcd0 \ud835\udcdc}\n\n/--\nThe smul multiplication of `A` on `\u2a01 i, \ud835\udcdc i` from `(\u2a01 i, \ud835\udcd0 i) \u2192+ (\u2a01 i, \ud835\udcdc i) \u2192+ \u2a01 i, \ud835\udcdc i`\nturns `\u2a01 i, \ud835\udcdc i` into an `A`-module\n-/\ndef is_module [decidable_eq \u03b9] [graded_ring \ud835\udcd0] :\n  module A (\u2a01 i, \ud835\udcdc i) :=\n{ smul := \u03bb a b, direct_sum.decompose \ud835\udcd0 a \u2022 b,\n  ..module.comp_hom _ $\n    (direct_sum.decompose_ring_equiv \ud835\udcd0 : A \u2243+* \u2a01 i, \ud835\udcd0 i).to_ring_hom }\n\nlocal attribute [instance] graded_module.is_module\n\n/--\n`\u2a01 i, \ud835\udcdc 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 \u03b9] [graded_ring \ud835\udcd0] \n  [direct_sum.decomposition \ud835\udcdc] :\n  M \u2243\u2097[A] \u2a01 i, \ud835\udcdc i :=\n{ to_fun := direct_sum.decompose_add_equiv \ud835\udcdc,\n  map_smul' := \u03bb x y, begin\n    classical,\n    rw [\u2190 direct_sum.sum_support_decompose \ud835\udcd0 x, map_sum, finset.sum_smul, map_sum,\n      finset.sum_smul, finset.sum_congr rfl (\u03bb i hi, _)],\n    rw [ring_hom.id_apply, \u2190 direct_sum.sum_support_decompose \ud835\udcdc y, map_sum, finset.smul_sum,\n      map_sum, finset.smul_sum, finset.sum_congr rfl (\u03bb 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 \ud835\udcdc _,\n    refl,\n  end,\n  .. (direct_sum.decompose_add_equiv \ud835\udcdc) }\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    | \u03b5 (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 \u2192 Prop where\n    | skip : SkipPreAST (.skip s e G)\n\n  inductive PreAST.StarPreAST : PreAST n b \u2192 Prop where\n    | star : StarPreAST (.star s e T0 TS)\n\n  inductive PreAST.IsValid : PreAST n b \u2192 Prop where\n    | skip : IsValid (.skip s e G)\n    | \u03b5 : IsValid (.\u03b5 s e)\n    | any : IsValid (.any s e x)\n    | terminal : IsValid (.terminal s e a x)\n    | nonTerminal : IsValid sub_T \u2192 \u00acSkipPreAST sub_T \u2192 IsValid (.nonTerminal s e A sub_T)\n    | seq : IsValid T1 \u2192 IsValid T2 \u2192 \u00acSkipPreAST T1 \u2192 IsValid (.seq s e T1 T2)\n    | prior : IsValid T1 \u2192 IsValid T2 \u2192 \u00acSkipPreAST T1 \u2192 IsValid (.prior s e T1 T2)\n    | star : IsValid T0 \u2192 IsValid TS \u2192 \u00acSkipPreAST T0 \u2192 (SkipPreAST TS \u2228 StarPreAST TS) \u2192 IsValid (.star s e T0 TS)\n    | notP : IsValid sub_T \u2192 \u00acSkipPreAST sub_T \u2192 IsValid (.notP s e sub_T)\n\n  def PreAST.size (T : PreAST n b) : Nat :=\n    match T with\n    | .skip _ _ _ => 0\n    | .\u03b5 _ _ => 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    | .\u03b5 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    | .\u03b5 _ 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 \u2192 Prop where\n    | \u03b5 : s = e \u2192 SuccessAST (.\u03b5 s e)\n    | any : s.inbound_succ h = e \u2192 SuccessAST (.any s e x)\n    | terminal : s.inbound_succ h = e \u2192 a = x \u2192 SuccessAST (.terminal s e a x)\n    | nonTerminal : SuccessAST T \u2192 SuccessAST (.nonTerminal s e A T)\n    | seq : SuccessAST T1 \u2192 SuccessAST T2 \u2192 SuccessAST (.seq s e T1 T2)\n    | prior_S : SuccessAST T1 \u2192 SuccessAST (.prior s e T1 T2)\n    | prior_FS : FailureAST T1 \u2192 SuccessAST T2 \u2192 SuccessAST (.prior s e T1 T2)\n    | star_F : FailureAST T0 \u2192 SuccessAST (.star s e T0 TS)\n    | star_SS : SuccessAST T0 \u2192 SuccessAST TS \u2192 SuccessAST (.star s e T0 TS)\n    | notP : FailureAST T \u2192 SuccessAST (.notP s e T)\n\n  inductive PreAST.FailureAST : PreAST n b \u2192 Prop where\n    | any : s = e \u2192 Fin.IsMax e \u2192 FailureAST (.any s e x)\n    | terminal_mismatch : s.inbound_succ h = e \u2192 a \u2260 x \u2192 FailureAST (.terminal s e a x)\n    | terminal_empty : s = e \u2192 Fin.IsMax e \u2192 FailureAST (.terminal s e a x)\n    | nonTerminal : FailureAST T \u2192 FailureAST (.nonTerminal s e A T)\n    | seq_F : FailureAST T1 \u2192 FailureAST (.seq s e T1 T2)\n    | seq_SF : SuccessAST T1 \u2192 FailureAST T2 \u2192 FailureAST (.seq s e T1 T2)\n    | prior : FailureAST T1 \u2192 FailureAST T2 \u2192 FailureAST (.prior s e T1 T2)\n    | notP : SuccessAST T \u2192 FailureAST (.notP s e T)\n\n  end\n\n  theorem PreAST.SuccessAST.ne_failure : \u2200 {T : PreAST n b}, PreAST.IsValid T \u2192 SuccessAST T \u2192 \u00acFailureAST T := by\n    intro T valid_T hs hf;\n    match T with\n      | .skip _ _ _ => cases hs;\n      | .\u03b5 _ _ => 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 : \u2200 {T : PreAST n b}, PreAST.IsValid T \u2192 FailureAST T \u2192 \u00acSuccessAST 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 : \u2200 {T : PreAST n b}, StarPreAST T \u2192 \u00acFailureAST 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 \u2228 FailureAST T\n\n  inductive PreAST.IsWellformed : PreAST n b \u2192 Prop where\n    | \u03b5 :           IsMeaningful (.\u03b5 (n := n) (b := b) s e)\n                    \u2192 IsWellformed (.\u03b5 (n := n) (b := b) s e)\n    | any :         IsMeaningful (.any (n := n) (b := b) s e x)\n                    \u2192 IsWellformed (.any (n := n) (b := b) s e x)\n    | terminal :    IsMeaningful (.terminal (n := n) (b := b) s e a x)\n                    \u2192 IsWellformed (.terminal (n := n) (b := b) s e a x)\n    | nonTerminal : \u2200 {sub_T : PreAST n b},\n                    s = sub_T.start \u2192 e = sub_T.end \n                    \u2192 IsWellformed sub_T \n                    \u2192 IsWellformed (.nonTerminal s e A sub_T)\n    | seq_F :       \u2200 {T1 T2 : PreAST n b},\n                    s = T1.start \u2192 T1.end = T2.start \u2192 e = T2.end \u2192 T2.start = T2.end\n                    \u2192 IsWellformed T1 \u2192 FailureAST T1 \u2192 SkipPreAST T2\n                    \u2192 IsWellformed (.seq s e T1 T2)\n    | seq_S :       \u2200 {T1 T2 : PreAST n b},\n                    s = T1.start \u2192 T1.end = T2.start \u2192 e = T2.end \n                    \u2192 IsWellformed T1 \u2192 SuccessAST T1 \u2192 IsWellformed T2\n                    \u2192 IsWellformed (.seq s e T1 T2)\n    | prior_S :     \u2200 {T1 T2 : PreAST n b},\n                    s = T1.start \u2192 s = T2.start \u2192 s = T2.end \u2192 e = T1.end \n                    \u2192 IsWellformed T1 \u2192 SuccessAST T1 \u2192 SkipPreAST T2\n                    \u2192 IsWellformed (.prior s e T1 T2)\n    | prior_F :     \u2200 {T1 T2 : PreAST n b},\n                    s = T1.start \u2192 s = T2.start \u2192 e = T2.end \n                    \u2192 IsWellformed T1 \u2192 FailureAST T1 \u2192 IsWellformed T2\n                    \u2192 IsWellformed (.prior s e T1 T2)\n    | star_S :      \u2200 {T0 TS : PreAST n b},\n                    s = T0.start \u2192 T0.end = TS.start \u2192 e = TS.end\n                    \u2192 IsWellformed T0 \u2192 SuccessAST T0 \u2192 IsWellformed TS\n                    \u2192 IsWellformed (.star s e T0 TS)\n    | star_F :      \u2200 {T0 TS : PreAST n b},\n                    s = T0.start \u2192 T0.end = TS.start \u2192 TS.start = TS.end \u2192 s = e\n                    \u2192 IsWellformed T0 \u2192 FailureAST T0 \u2192 SkipPreAST TS\n                    \u2192 IsWellformed (.star s e T0 TS)\n    | notP :        \u2200 {sub_T : PreAST n b},\n                    s = e \u2192 s = sub_T.start\n                    \u2192 IsWellformed sub_T \n                    \u2192 IsWellformed (.notP s e sub_T)\n\n  theorem PreAST.skip_is_not_wellformed : \u2200 {T : PreAST n b}, SkipPreAST T \u2192 \u00acIsWellformed T := by\n    intro T hskip hwf;\n    cases hskip; cases hwf;\n\n  theorem PreAST.valid_and_wellformed_implies_meaningful : \u2200 {T : PreAST n b}, IsValid T \u2192 IsWellformed T \u2192 IsMeaningful T := by\n    intro T h_valid hwf;\n    match hwf with\n    | .\u03b5 _ => 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 : \u2200 {T : PreAST n b}, IsValid T \u2192 IsWellformed T \u2192 T.start \u2264 T.end := by\n    intro T h_valid hwf;\n    match hwf with\n    | .\u03b5 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, \u2190hs2e2, \u2190he1s2]\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 \u2264 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  \u2200 x y, x * y \u2208 S \u2192 \u2203 z \u2208 S, Associated x z \u2227 \u2203 z \u2208 S, Associated y z\n\nsection Basic\n\ntheorem absorbing_def {S : Submonoid M} :\n    Absorbing S \u2194 \u2200 x y, x * y \u2208 S \u2192 \u2203 z \u2208 S, Associated x z \u2227 \u2203 z \u2208 S, Associated y z :=\n  Iff.rfl\n\nvariable (M)\n\nvariable (N)\n\ntheorem top_absorbing : (\u22a4 : Submonoid M).Absorbing := fun x y _ =>\n  \u27e8x, Submonoid.mem_top _, Associated.refl _, y, Submonoid.mem_top _, Associated.refl _\u27e9\n\ntheorem bot_absorbing : (\u22a5 : Submonoid M).Absorbing := fun x y hxy =>\n  \u27e81, (\u22a5 : Submonoid M).one_mem, associated_one_of_mul_eq_one _ (Submonoid.mem_bot.1 hxy), 1,\n    (\u22a5 : Submonoid M).one_mem,\n    associated_one_of_mul_eq_one _ (Submonoid.mem_bot.1 (by rwa [mul_comm] at hxy))\u27e9\n\ntheorem IsUnit.submonoid_absorbing : (IsUnit.submonoid M).Absorbing := fun x y hxy =>\n  \u27e8x, isUnit_of_mul_isUnit_left hxy, Associated.refl _, y, isUnit_of_mul_isUnit_right hxy,\n    Associated.refl _\u27e9\n\ntheorem Associated.prod (x z : M \u00d7 N) : Associated x z \u2194 Associated x.1 z.1 \u2227 Associated x.2 z.2 :=\n  by\n  refine'\n    \u27e8_, fun \u27e8\u27e8u\u2081, hu\u2081\u27e9, \u27e8u\u2082, hu\u2082\u27e9\u27e9 =>\n      \u27e8MulEquiv.prodUnits.invFun (u\u2081, u\u2082), Prod.eq_iff_fst_eq_snd_eq.2 \u27e8hu\u2081, hu\u2082\u27e9\u27e9\u27e9\n  rintro \u27e8u, hu\u27e9\n  cases' u.isUnit.exists_right_inv with b hb\n  rw [Prod.mul_def, Prod.mk_eq_one] at hb\n  rw [\u2190 hu, Prod.fst_mul, Prod.snd_mul]\n  refine'\n    \u27e8(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 _)\u27e9\n\ntheorem Submonoid.prod_absorbing (s : Submonoid M) (t : Submonoid N) :\n    (s.prod t).Absorbing \u2194 Absorbing s \u2227 Absorbing t :=\n  by\n  refine' \u27e8fun h => \u27e8fun x y hxy => _, fun x y hxy => _\u27e9, _\u27e9\n  \u00b7 specialize h (x, 1) (y, 1)\n    rw [Prod.mk_one_mul_mk_one] at h\n    rcases h (Submonoid.mem_prod.2 \u27e8hxy, t.one_mem\u27e9) with \u27e8a, ha, ha\u2082, \u27e8b, hb, hb\u2082\u27e9\u27e9\n    exact\n      \u27e8a.1, (Submonoid.mem_prod.1 ha).1, ((Associated.prod _ _ _ _).1 ha\u2082).1, b.1,\n        (Submonoid.mem_prod.1 hb).1, ((Associated.prod _ _ _ _).1 hb\u2082).1\u27e9\n  \u00b7 specialize h (1, x) (1, y)\n    rw [Prod.one_mk_mul_one_mk] at h\n    rcases h (Submonoid.mem_prod.2 \u27e8s.one_mem, hxy\u27e9) with \u27e8a, ha, ha\u2082, \u27e8b, hb, hb\u2082\u27e9\u27e9\n    exact\n      \u27e8a.2, (Submonoid.mem_prod.1 ha).2, ((Associated.prod _ _ _ _).1 ha\u2082).2, b.2,\n        (Submonoid.mem_prod.1 hb).2, ((Associated.prod _ _ _ _).1 hb\u2082).2\u27e9\n  \u00b7 rintro \u27e8hs, ht\u27e9 x y hxy\n    rcases hs x.1 y.1 hxy.1 with \u27e8z, hz, hz\u2082, \u27e8z', hz', hz'\u2082\u27e9\u27e9\n    rcases ht x.2 y.2 hxy.2 with \u27e8w, hw, hw\u2082, \u27e8w', hw', hw'\u2082\u27e9\u27e9\n    exact\n      \u27e8(z, w), Submonoid.mem_prod.2 \u27e8hz, hw\u27e9, (Associated.prod _ _ _ _).2 \u27e8hz\u2082, hw\u2082\u27e9, (z', w'),\n        Submonoid.mem_prod.2 \u27e8hz', hw'\u27e9, (Associated.prod _ _ _ _).2 \u27e8hz'\u2082, hw'\u2082\u27e9\u27e9\n\nend Basic\n\nsection CommMonoid\n\ntheorem absorbing_iff_of_comm {S : Submonoid M} :\n    Absorbing S \u2194 \u2200 x y, x * y \u2208 S \u2192 \u2203 z \u2208 S, Associated x z :=\n  by\n  refine' \u27e8fun hS x y hxy => _, fun h x y hxy => _\u27e9\n  \u00b7 rcases hS x y hxy with \u27e8z, hz, hz\u2082, _\u27e9\n    exact \u27e8z, hz, hz\u2082\u27e9\n  \u00b7 obtain \u27e8z, hz, hz\u2082\u27e9 := h x y hxy\n    refine' \u27e8z, hz, hz\u2082, _\u27e9\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 \u2208 F[x\u2080,\u2026,x\u2099]. Suppose that for 0 \u2264 i \u2264 n,\n  the degree of f in x\u1d62 is at most t\u1d62. Let S\u2080,\u2026,S\u2099 \u2286 F be subsets such that t\u1d62 < |S\u1d62|.\n  Suppose that f(s\u2080,\u2026,s\u2099) = 0 for each (s\u2080,\u2026,s\u2099) \u2208 S\u2080 \u00d7 \u2026 \u00d7 S\u2099. 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 : \u2115 } {R : Type*} [comm_ring R] [is_domain R]\n  (f : mv_polynomial (fin n) R)\n  (S : fin n \u2192 finset R)\n  (hS : \u2200 i : fin n, degree_of i f < (S i).card) \n  (hz : \u2200 s : fin n \u2192 R, (\u2200 i : fin n, s i \u2208 S i ) \u2192 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 \u2191(fin_succ_equiv R n)).1 \u2218 polynomial.ext_iff.2,\n  intro i,\n  rw \u2190 polynomial.coeff_zero i,\n  apply hn (polynomial.coeff ((fin_succ_equiv R n) f) i),\n  exact \u03bb j, lt_of_le_of_lt (degree_of_coeff_fin_succ_equiv f j i) (hS j.succ),\n  intros s hs,\n  rw [ \u2190 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 \u2286 (polynomial.map (eval (\u03bb (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 \u2190 nat_degree_fin_succ_equiv f,\n    exact polynomial.nat_degree_le_nat_degree (polynomial.degree_mono (polynomial.support_map_subset _ _)),},\n  suffices h0 : \u2200 s' : fin n \u2192 R, (\u2200 i : fin n, s' i \u2208 S i.succ) \u2192 \u2200 y : R, y \u2208 S 0 \u2192  \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 [\u2190 eval_eq_eval_mv_eval', hz],\n  intro i,\n  by_cases c : i \u2260 0,\n  { rw [ \u2190fin.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 \u03c3 : Type*} [comm_ring R] [is_domain R] [fintype \u03c3] (f : mv_polynomial \u03c3 R)\n  (S : \u03c3 \u2192 finset R) (hS : \u2200 i : \u03c3, degree_of i f < (S i).card) \n  (hz : \u2200 s : \u03c3 \u2192 R, (\u2200 i : \u03c3, s i \u2208 S i ) \u2192 eval s f = 0) : f = 0 :=\nbegin\n  rcases exists_fin_rename f with \u27e8n, \u27e8\u03c8,\u27e8h\u03c8,\u27e8g,hg\u27e9\u27e9\u27e9\u27e9,\n  rw hg,\n  rw hg at hS,\n  rw hg at hz,\n  clear hg f,\n  have h_S_nonempty : \u2200 i, \u2203 x, x \u2208 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 : \u2203 s0 : \u03c3 \u2192 R, (\u2200 i : \u03c3, s0 i \u2208 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' : \u2200 i : (fin n), degree_of i g < ((S \u2218 \u03c8) i).card,\n    { intro i,\n      convert hS (\u03c8 i),\n      rw degree_of_rename_of_injective h\u03c8 i },\n    suffices hz' : \u2200 s : (fin n) \u2192 R, (\u2200 i : fin n, s i \u2208 (S \u2218 \u03c8) i ) \u2192 eval s g = 0,\n      by simp [lemma_2_1_fin_n g (S \u2218 \u03c8 ) hS' hz'],\n    intros s' h,\n    let \u03c6 := @function.inv_fun (fin n) \u03c3 c \u03c8,\n    have \u03c6_left_inv := @function.left_inverse_inv_fun (fin n) \u03c3 c \u03c8 h\u03c8,\n    let s : \u03c3 \u2192 R := \u03bb i, if h : \u2203 j : fin n, \u03c8 j = i then (s' \u2218 \u03c6) i else s0 i,\n    have hs' : s' = s \u2218 \u03c8,\n    { ext,\n      have hx  : \u2203 j, \u03c8 j = \u03c8 x := \u27e8x, by refl\u27e9,\n      simp only [function.comp_app, s, hx, dif_pos, \u03c6, \u03c6_left_inv x], },\n    suffices hs : \u2200 (i : \u03c3), s i \u2208 S i,\n    { rw hs',\n      convert hz s hs, \n      simp only [eval, eval\u2082_hom_rename] },\n    intro i,\n    by_cases ch : \u2203 (j : fin n), \u03c8 j = i,\n    { simp only [s, dite_eq_ite, function.comp_app, if_pos, ch, \u03c6 ],\n      cases ch with j hj,\n      simpa [\u2190 hj, \u03c6_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 [\u2190ha, rename_C] at hz,\n    have t := hz s0 hs0,\n    rw [eval_C] at t,\n    simp [\u2190ha, 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\u00f6lich, *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 \u2194 finite_dimensional Fqt F :=\nbegin\n  let e := is_localization.alg_equiv (non_zero_divisors (polynomial Fq)) (ratfunc Fq) Fqt,\n  have : \u2200 c (x : F), e c \u2022 x = c \u2022 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, \u2190 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 `\u2124_[p]`\n\nWe construct a ring isomorphism between `witt_vector p (zmod p)` and `\u2124_[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 `\ud835\udd4e (zmod p) \u2192 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) (R : Type u_1)\n    [comm_ring R] [char_p R p] (i : \u2115) (hin : i \u2264 n) (hpi : \u2191p ^ i = 0) : i = n :=\n  sorry\n\ntheorem card_zmod (p : \u2115) [hp : fact (nat.prime p)] (n : \u2115) :\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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) :\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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) :\n    zmod (p ^ n) \u2243+* 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {m : \u2115} (hm : n \u2264 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {m : \u2115} (hm : n \u2264 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {m : \u2115} (hm : n \u2264 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {m : \u2115} (hm : n \u2264 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 : \u2115) [hp : fact (nat.prime p)] (k : \u2115) :\n    witt_vector p (zmod p) \u2192+* 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 : \u2115) [hp : fact (nat.prime p)] (m : \u2115) (n : \u2115) (h : m \u2264 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 : \ud835\udd4e (zmod p) \u2192+* zmod (p ^ k)` to a ring hom to `\u2124_[p]`\nusing `padic_int.lift`, the universal property of `\u2124_[p]`.\n-/\ndef to_padic_int (p : \u2115) [hp : fact (nat.prime p)] : witt_vector p (zmod p) \u2192+* padic_int p :=\n  padic_int.lift (to_zmod_pow_compat p)\n\ntheorem zmod_equiv_trunc_compat (p : \u2115) [hp : fact (nat.prime p)] (k\u2081 : \u2115) (k\u2082 : \u2115) (hk : k\u2081 \u2264 k\u2082) :\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\u2082))\n            (padic_int.to_zmod_pow k\u2082)) =\n        ring_hom.comp (ring_equiv.to_ring_hom (truncated_witt_vector.zmod_equiv_trunc p k\u2081))\n          (padic_int.to_zmod_pow k\u2081) :=\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 `\u2124_[p] \u2192+* \ud835\udd4e (zmod p)`.\n-/\ndef from_padic_int (p : \u2115) [hp : fact (nat.prime p)] : padic_int p \u2192+* witt_vector p (zmod p) :=\n  lift\n    (fun (k : \u2115) =>\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 : \u2115) [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 : \u2115) [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 : \u2115) [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 : \u2115) [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 : \u2115) [hp : fact (nat.prime p)] : witt_vector p (zmod p) \u2243+* padic_int p :=\n  ring_equiv.mk (\u21d1(to_padic_int p)) (\u21d1(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\u1d52\u1d56`\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\u1d52\u1d56) :=\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\u1d52\u1d56) :=\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] : \u21d1(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] : \u21d1(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] : \u21d1(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    \u21d1(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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 `\u03b1`, to its elements that satisfy some\npredicate, say `p : \u03b1 \u2192 Prop`. Specifically, it is the type of pairs `\u27e8val, property\u27e9` where\n`val : \u03b1` and `property : p val`. It is denoted `subtype p` and notation `{val : \u03b1 // p val}` is\navailable.\n\nA subtype has a natural coercion to the parent type, by coercing `\u27e8val, property\u27e9` to `val`. As\nsuch, subtypes can be thought of as bundled sets, the difference being that elements of a set are\nstill of type `\u03b1` while elements of a subtype aren't.\n-/\n\nopen function\n\nnamespace subtype\nvariables {\u03b1 \u03b2 \u03b3 : Sort*} {p q : \u03b1 \u2192 Prop}\n\n/-- See Note [custom simps projection] -/\ndef simps.coe (x : subtype p) : \u03b1 := x\n\ninitialize_simps_projections subtype (val \u2192 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 = \u2191x := rfl\n\n@[simp] protected theorem \u00abforall\u00bb {q : {a // p a} \u2192 Prop} :\n  (\u2200 x, q x) \u2194 (\u2200 a b, q \u27e8a, b\u27e9) :=\n\u27e8assume h a b, h \u27e8a, b\u27e9, assume h \u27e8a, b\u27e9, h a b\u27e9\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 : \u2200 x, p x \u2192 Prop} :\n  (\u2200 x h, q x h) \u2194 (\u2200 x : {a // p a}, q x x.2) :=\n(@subtype.forall _ _ (\u03bb x, q x.1 x.2)).symm\n\n@[simp] protected theorem \u00abexists\u00bb {q : {a // p a} \u2192 Prop} :\n  (\u2203 x, q x) \u2194 (\u2203 a b, q \u27e8a, b\u27e9) :=\n\u27e8assume \u27e8\u27e8a, b\u27e9, h\u27e9, \u27e8a, b, h\u27e9, assume \u27e8a, b, h\u27e9, \u27e8\u27e8a, b\u27e9, h\u27e9\u27e9\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 : \u2200x, p x \u2192 Prop} :\n  (\u2203 x h, q x h) \u2194 (\u2203 x : {a // p a}, q x x.2) :=\n(@subtype.exists _ _ (\u03bb x, q x.1 x.2)).symm\n\n@[ext] protected lemma ext : \u2200 {a1 a2 : {x // p x}}, (a1 : \u03b1) = (a2 : \u03b1) \u2192 a1 = a2\n| \u27e8x, h1\u27e9 \u27e8.(x), h2\u27e9 rfl := rfl\n\nlemma ext_iff {a1 a2 : {x // p x}} : a1 = a2 \u2194 (a1 : \u03b1) = (a2 : \u03b1) :=\n\u27e8congr_arg _, subtype.ext\u27e9\n\nlemma heq_iff_coe_eq (h : \u2200 x, p x \u2194 q x) {a1 : {x // p x}} {a2 : {x // q x}} :\n  a1 == a2 \u2194 (a1 : \u03b1) = (a2 : \u03b1) :=\neq.rec (\u03bb a2', heq_iff_eq.trans ext_iff) (funext $ \u03bb x, propext (h x)) a2\n\nlemma heq_iff_coe_heq {\u03b1 \u03b2 : Sort*} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {a : {x // p x}}\n  {b : {y // q y}} (h : \u03b1 = \u03b2) (h' : p == q) :\n  a == b \u2194 (a : \u03b1) == (b : \u03b2) :=\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 \u2192 a1 = a2 :=\nsubtype.ext\n\nlemma ext_iff_val {a1 a2 : {x // p x}} : a1 = a2 \u2194 a1.1 = a2.1 :=\next_iff\n\n@[simp] theorem coe_eta (a : {a // p a}) (h : p a) : mk \u2191a h = a := subtype.ext rfl\n\n@[simp] theorem coe_mk (a h) : (@mk \u03b1 p a h : \u03b1) = a := rfl\n\n@[simp, nolint simp_nf] -- built-in reduction doesn't always work\ntheorem mk_eq_mk {a h a' h'} : @mk \u03b1 p a h = @mk \u03b1 p a' h' \u2194 a = a' :=\next_iff\n\ntheorem coe_eq_iff {a : {a // p a}} {b : \u03b1} : \u2191a = b \u2194 \u2203 h, a = \u27e8b, h\u27e9 :=\n\u27e8\u03bb h, h \u25b8 \u27e8a.2, (coe_eta _ _).symm\u27e9, \u03bb \u27e8hb, ha\u27e9, ha.symm \u25b8 rfl\u27e9\n\ntheorem coe_injective : injective (coe : subtype p \u2192 \u03b1) :=\n\u03bb a b, subtype.ext\n\ntheorem val_injective : injective (@val _ p) :=\ncoe_injective\n\n/-- Restrict a (dependent) function to a subtype -/\ndef restrict {\u03b1} {\u03b2 : \u03b1 \u2192 Type*} (f : \u03a0 x, \u03b2 x) (p : \u03b1 \u2192 Prop) (x : subtype p) : \u03b2 x.1 :=\nf x\n\nlemma restrict_apply {\u03b1} {\u03b2 : \u03b1 \u2192 Type*} (f : \u03a0 x, \u03b2 x) (p : \u03b1 \u2192 Prop) (x : subtype p) :\n  restrict f p x = f x.1 :=\nby refl\n\nlemma restrict_def {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (p : \u03b1 \u2192 Prop) : restrict f p = f \u2218 coe :=\nby refl\n\nlemma restrict_injective {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} (p : \u03b1 \u2192 Prop) (h : injective f) :\n  injective (restrict f p) :=\nh.comp coe_injective\n\nlemma surjective_restrict {\u03b1} {\u03b2 : \u03b1 \u2192 Type*} [ne : \u03a0 a, nonempty (\u03b2 a)] (p : \u03b1 \u2192 Prop) :\n  surjective (\u03bb f : \u03a0 x, \u03b2 x, restrict f p) :=\nbegin\n  letI := classical.dec_pred p,\n  refine \u03bb f, \u27e8\u03bb x, if h : p x then f \u27e8x, h\u27e9 else nonempty.some (ne x), funext $ _\u27e9,\n  rintro \u27e8x, hx\u27e9,\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) {p : \u03b2 \u2192 Prop} (h : \u2200 a, p (f a)) : \u03b1 \u2192 subtype p :=\n\u03bb a, \u27e8f a, h a\u27e9\n\ntheorem coind_injective {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} (h : \u2200 a, p (f a))\n  (hf : injective f) : injective (coind f h) :=\n\u03bb x y hxy, hf $ by apply congr_arg subtype.val hxy\n\ntheorem coind_surjective {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} (h : \u2200 a, p (f a))\n  (hf : surjective f) : surjective (coind f h) :=\n\u03bb x, let \u27e8a, ha\u27e9 := hf x in \u27e8a, coe_injective ha\u27e9\n\ntheorem coind_bijective {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} (h : \u2200 a, p (f a))\n  (hf : bijective f) : bijective (coind f h) :=\n\u27e8coind_injective h hf.1, coind_surjective h hf.2\u27e9\n\n/-- Restriction of a function to a function on subtypes. -/\n@[simps] def map {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2) (h : \u2200 a, p a \u2192 q (f a)) :\n  subtype p \u2192 subtype q :=\n\u03bb x, \u27e8f x, h x x.prop\u27e9\n\ntheorem map_comp {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} {x : subtype p}\n  (f : \u03b1 \u2192 \u03b2) (h : \u2200 a, p a \u2192 q (f a)) (g : \u03b2 \u2192 \u03b3) (l : \u2200 a, q a \u2192 r (g a)) :\n  map g l (map f h x) = map (g \u2218 f) (assume a ha, l (f a) $ h a ha) x :=\nrfl\n\ntheorem map_id {p : \u03b1 \u2192 Prop} {h : \u2200 a, p a \u2192 p (id a)} : map (@id \u03b1) h = id :=\nfunext $ assume \u27e8v, h\u27e9, rfl\n\nlemma map_injective {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} (h : \u2200 a, p a \u2192 q (f a))\n  (hf : injective f) : injective (map f h) :=\ncoind_injective _ $ hf.comp coe_injective\n\nlemma map_involutive {p : \u03b1 \u2192 Prop} {f : \u03b1 \u2192 \u03b1} (h : \u2200 a, p a \u2192 p (f a))\n  (hf : involutive f) : involutive (map f h) :=\n\u03bb x, subtype.ext (hf x)\n\ninstance [has_equiv \u03b1] (p : \u03b1 \u2192 Prop) : has_equiv (subtype p) :=\n\u27e8\u03bb s t, (s : \u03b1) \u2248 (t : \u03b1)\u27e9\n\ntheorem equiv_iff [has_equiv \u03b1] {p : \u03b1 \u2192 Prop} {s t : subtype p} :\n  s \u2248 t \u2194 (s : \u03b1) \u2248 (t : \u03b1) :=\niff.rfl\n\nvariables [setoid \u03b1]\n\nprotected theorem refl (s : subtype p) : s \u2248 s :=\nsetoid.refl \u2191s\n\nprotected theorem symm {s t : subtype p} (h : s \u2248 t) : t \u2248 s :=\nsetoid.symm h\n\nprotected theorem trans {s t u : subtype p} (h\u2081 : s \u2248 t) (h\u2082 : t \u2248 u) : s \u2248 u :=\nsetoid.trans h\u2081 h\u2082\n\ntheorem equivalence (p : \u03b1 \u2192 Prop) : equivalence (@has_equiv.equiv (subtype p) _) :=\nmk_equivalence _ subtype.refl (@subtype.symm _ p _) (@subtype.trans _ p _)\n\ninstance (p : \u03b1 \u2192 Prop) : setoid (subtype p) :=\nsetoid.mk (\u2248) (equivalence p)\n\nend subtype\n\nnamespace subtype\n/-! Some facts about sets, which require that `\u03b1` is a type. -/\nvariables {\u03b1 \u03b2 \u03b3 : Type*} {p : \u03b1 \u2192 Prop}\n\n@[simp] lemma coe_prop {S : set \u03b1} (a : {a // a \u2208 S}) : \u2191a \u2208 S := a.prop\n\nlemma val_prop {S : set \u03b1} (a : {a // a \u2208 S}) : a.val \u2208 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 \u2964 Ab.{u})\n  (h_tf : \u2200 j, no_zero_smul_divisors \u2124 (J.obj j))\n  : no_zero_smul_divisors \u2124 (limit J).\u03b1 :=\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 \u03c6 := \u03bb x : (limit J), \u03bb j, (L.cone.\u03c0.app j) x,\n  have h1: \u03c6 0 = 0,\n  { ext j,\n    exact (L.cone.\u03c0.app j).2 },\n  have h2: \u03c6 (c \u2022 x) = c \u2022 \u03c6 x,\n  { ext j,\n    exact map_zsmul (L.cone.\u03c0.app j) _ _ },\n  apply_fun \u03c6 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} \u2115) \u2964 AddCommGroup.{u})\n  (h_tf : \u2200 j, no_zero_smul_divisors \u2124 (J.obj j))\n  : no_zero_smul_divisors \u2124 (limit J).\u03b1 := limit_torsion_free_to_Ab J h_tf\n\nopen CompHausFiltPseuNormGrp\u2081 category_theory\n\ninstance : concrete_category.{u} PseuNormGrp\u2081.{u} :=\n{ forget :=\n  { obj := \u03bb M, M,\n    map := \u03bb M N f, f,\n    map_id' := \u03bb M, rfl,\n    map_comp' := \u03bb _ _ _ f g, rfl },\n  forget_faithful := { map_injective' := \u03bb M N f g h, by { ext, dsimp at h, rw h, } } }\n\nlemma PNG\u2081.iso_injective {X Y : PseuNormGrp\u2081.{u}} (f : X \u2245 Y) :\n  function.injective f.hom :=\nbegin\n  intros x y h,\n  apply_fun f.inv at h,\n  simp only [\u2190 category_theory.comp_apply, f.hom_inv_id] at h,\n  exact h,\nend\n\nlemma PNG\u2081.map_zsmul {X Y : PseuNormGrp\u2081} (f : X \u27f6 Y) (n : \u2124) (x : X) :\n  f (n \u2022 x) = n \u2022 f x :=\nf.to_add_monoid_hom.map_zsmul _ _\n\nnamespace Profinite\n\nlemma extend_torsion_free (A : Fintype.{u} \u2964 CompHausFiltPseuNormGrp\u2081)\n  (hA : \u2200 X, no_zero_smul_divisors \u2124 (A.obj X)) (S : Profinite) :\n  no_zero_smul_divisors \u2124 ((Profinite.extend A).obj S) :=\nbegin\n  let T := Ab.explicit_limit_cone.{u u}\n    ((S.fintype_diagram \u22d9 A \u22d9 to_PNG\u2081) \u22d9 PseuNormGrp\u2081.to_Ab),\n  set T' := limit.cone.{u u} ((S.fintype_diagram \u22d9 A \u22d9 to_PNG\u2081) \u22d9 PseuNormGrp\u2081.to_Ab) with hT',\n  let hT : is_limit T := Ab.explicit_limit_cone_is_limit _,\n  let E := PseuNormGrp\u2081.bounded_cone.{u} \u27e8T,hT\u27e9,\n  let hE : is_limit E := PseuNormGrp\u2081.bounded_cone_is_limit _,\n  suffices claim : no_zero_smul_divisors \u2124 E.X,\n  { resetI,\n    let iso : to_PNG\u2081.obj ((extend (A)).obj S) \u2245 E.X :=\n      (is_limit_of_preserves to_PNG\u2081\n      (limit.is_limit _)).cone_point_unique_up_to_iso hE,\n    apply function.injective.no_zero_smul_divisors iso.hom (PNG\u2081.iso_injective _),\n    any_goals { apply_instance },\n    { apply strict_pseudo_normed_group_hom.map_zero },\n    { intros, rw PNG\u2081.map_zsmul } },\n  let \u03b9 : E.X \u2192+ T.X := add_subgroup.subtype _,\n  apply function.injective.no_zero_smul_divisors \u03b9 (subtype.val_injective.{u+1}) \u03b9.map_zero,\n  any_goals { apply_instance },\n  { intros c x, apply \u03b9.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 \u03c6 := (@iso.AddCommGroup_iso_to_add_equiv.{u} T.X T'.X iso_pts),\n  apply function.injective.no_zero_smul_divisors \u03c6 \u03c6.injective \u03c6.map_zero,\n  { intros c x,\n    exact map_zsmul \u03c6 _ _ },\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 (\u03b1 : Type u) : Language :=\n\u27e8\u03bbn, nat.rec \u03b1 (\u03bbn ih, pempty) n, \u03bbn, pempty\u27e9\n\nprotected def sum (L L' : Language) : Language :=\n\u27e8\u03bbn, L.functions n \u2295 L'.functions n, \u03bb n, L.relations n \u2295 L'.relations n\u27e9\n\ndef symbols (L : Language) := (\u03a3l, L.functions l) \u2295 (\u03a3l, L.relations l)\nend Language\n\nsection\nvariable {L : Language}\n\n\n@[simp] def symbols_in_term : \u2200{l}, preterm L l \u2192 set L.symbols\n| _ &k          := \u2205\n| l (func f)    := {sum.inl \u27e8l,f\u27e9}\n| _ (app t\u2081 t\u2082) := symbols_in_term t\u2081 \u222a symbols_in_term t\u2082\n\n@[simp] def symbols_in_formula : \u2200{l}, preformula L l \u2192 set L.symbols\n| _ falsum       := \u2205\n| _ (t\u2081 \u2243 t\u2082)    := symbols_in_term t\u2081 \u222a symbols_in_term t\u2082\n| l (rel R)      := {sum.inr \u27e8l, R\u27e9}\n| _ (apprel f t) := symbols_in_formula f \u222a symbols_in_term t\n| _ (f\u2081 \u27f9 f\u2082)   := symbols_in_formula f\u2081 \u222a symbols_in_formula f\u2082\n| _ (\u2200' f)       := symbols_in_formula f\n\n@[simp] lemma symbols_in_term_lift_at (n m) : \u2200{l} (t : preterm L l),\n  symbols_in_term (t \u2191' n # m) = symbols_in_term t\n| _ &k          := by by_cases h : m \u2264 k; simp [h]\n| l (func f)    := by refl\n| _ (app t\u2081 t\u2082) := by simp*\n\n@[simp] lemma symbols_in_term_lift (n) {l} (t : preterm L l) :\n  symbols_in_term (t \u2191 n) = symbols_in_term t :=\nsymbols_in_term_lift_at n 0 t\n\nlemma symbols_in_term_subst (s : term L) (n) : \u2200{l} (t : preterm L l),\n  symbols_in_term (t[s // n]) \u2286 symbols_in_term t \u222a 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\u2081 t\u2082) :=\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 : \u2200{l} (f : preformula L l) (s : term L) (n),\n  symbols_in_formula (f[s // n]) \u2286 symbols_in_formula f \u222a symbols_in_term s\n| _ falsum       s n := empty_subset _\n| _ (t\u2081 \u2243 t\u2082)    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\u2081 \u27f9 f\u2082)   s n :=\n  by { simp; split; refine subset.trans (symbols_in_formula_subst _ _ _) _;\n       simp [subset_union2_left, subset_union2_middle] }\n| _ (\u2200' f)       s n := symbols_in_formula_subst f _ _\n\nend\n\n-- def symbols_in_prf : \u2200{\u0393 : set $ formula L} {f : formula L} (P : \u0393 \u22a2 f), set L.symbols\n-- | \u0393 f (axm h)              := symbols_in_formula f\n-- | \u0393 (f\u2081 \u27f9 f\u2082) (impI P)    := symbols_in_prf P \u222a symbols_in_formula f\u2081\n-- | \u0393 f\u2082 (impE f\u2081 P\u2081 P\u2082)     := symbols_in_prf P\u2081 \u222a symbols_in_prf P\u2082\n-- | \u0393 f (falsumE P)          := symbols_in_prf P \u222a symbols_in_formula f\n-- | \u0393 (\u2200' f) (allI P)        := symbols_in_prf P\n-- | \u0393 _ (allE\u2082 f t P)        := symbols_in_prf P \u222a symbols_in_term t\n-- | \u0393 (_ \u2243 t) (ref _ _)     := symbols_in_term t\n-- | \u0393 _ (subst\u2082 s t f P\u2081 P\u2082) := symbols_in_prf P\u2081 \u222a symbols_in_prf P\u2082\n\n-- def interpolation : \u2200{\u0393 : set $ formula L} {f : formula L} (P : \u0393 \u22a2 f),\n--   \u03a3' (f' : formula L) (P\u2081 : \u0393 \u22a2 f') (P\u2082 : {f'} \u22a2 f),\n--     symbols_in_prf P\u2081 \u2286 \u22c3\u2080 (symbols_in_formula '' \u0393) \u2227\n--     symbols_in_prf P\u2082 \u2286 symbols_in_formula f \u2227\n--     symbols_in_formula f' \u2286 \u22c3\u2080 (symbols_in_formula '' \u0393) \u2229 symbols_in_formula f :=\n-- sorry -- probably the last property follows automatically\n\n\n\n\nstructure Lhom (L L' : Language) :=\n(on_function : \u2200{n}, L.functions n \u2192 L'.functions n)\n(on_relation : \u2200{n}, L.relations n \u2192 L'.relations n)\n\ninfix ` \u2192\u1d38 `:10 := Lhom -- \\^L\n\nnamespace Lhom\n/- -/\nvariables {L : Language.{u}} {L' : Language.{u}} (\u03d5 : L \u2192\u1d38 L')\n\nprotected def id (L : Language) : L \u2192\u1d38 L :=\n\u27e8\u03bbn, id, \u03bb n, id\u27e9\n\nprotected def sum_inl {L L' : Language} : L \u2192\u1d38 L.sum L' :=\n\u27e8\u03bbn, sum.inl, \u03bb n, sum.inl\u27e9\n\nprotected def sum_inr {L L' : Language} : L' \u2192\u1d38 L.sum L' :=\n\u27e8\u03bbn, sum.inr, \u03bb n, sum.inr\u27e9\n\n@[reducible]def comp {L1} {L2} {L3} (g : L2 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2) : L1 \u2192\u1d38 L3 :=\nbegin\n--  rcases g with \u27e8g1, g2\u27e9, rcases f with \u27e8f1,f2\u27e9,\n--  exact \u27e8\u03bbn, g1 \u2218 f1, \u03bbn, g2 \u2218 f2\u27e9\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) \u2218 (@f1 n),\n  let g2 := g.on_relation, let f2 := f.on_relation,\n    exact (@g2 n) \u2218 (@f2 n)\nend\n\nlemma Lhom_funext {L1} {L2} {F G : L1 \u2192\u1d38 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 ` \u2218 `:60 := Lhom.comp\n\n@[simp]lemma id_is_left_identity {L1 L2} {F : L1 \u2192\u1d38 L2} : (Lhom.id L2) \u2218 F = F := by {cases F, refl}\n\n@[simp]lemma id_is_right_identity {L1 L2} {F : L1 \u2192\u1d38 L2} : F \u2218 (Lhom.id L1) = F := by {cases F, refl}\n\nstructure is_injective : Prop :=\n(on_function {n} : injective (on_function \u03d5 : L.functions n \u2192 L'.functions n))\n(on_relation {n} : injective (on_relation \u03d5 : L.relations n \u2192 L'.relations n))\n\nclass has_decidable_range : Type u :=\n(on_function {n} : decidable_pred (range (on_function \u03d5 : L.functions n \u2192 L'.functions n)))\n(on_relation {n} : decidable_pred (range (on_relation \u03d5 : L.relations n \u2192 L'.relations n)))\n\nattribute [instance] has_decidable_range.on_function has_decidable_range.on_relation\n\n@[simp] def on_symbol : L.symbols \u2192 L'.symbols\n| (sum.inl \u27e8l, f\u27e9) := sum.inl \u27e8l, \u03d5.on_function f\u27e9\n| (sum.inr \u27e8l, R\u27e9) := sum.inr \u27e8l, \u03d5.on_relation R\u27e9\n\n@[simp] def on_term : \u2200{l}, preterm L l \u2192 preterm L' l\n| _ &k          := &k\n| _ (func f)    := func $ \u03d5.on_function f\n| _ (app t\u2081 t\u2082) := app (on_term t\u2081) (on_term t\u2082)\n\n@[simp] lemma on_term_lift_at : \u2200{l} (t : preterm L l) (n m : \u2115),\n  \u03d5.on_term (t \u2191' n # m) = \u03d5.on_term t \u2191' n # m\n| _ &k          n m := by simp\n| _ (func f)    n m := by refl\n| _ (app t\u2081 t\u2082) n m := by simp*\n\n@[simp] lemma on_term_lift {l} (n : \u2115) (t : preterm L l) : \u03d5.on_term (t \u2191 n) = \u03d5.on_term t \u2191 n :=\n\u03d5.on_term_lift_at t n 0\n\n@[simp] lemma on_term_subst : \u2200{l} (t : preterm L l) (s : term L) (n : \u2115),\n  \u03d5.on_term (t[s // n]) = \u03d5.on_term t[\u03d5.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\u2081 t\u2082) s n := by simp*\n\n@[simp] def on_term_apps : \u2200{l} (t : preterm L l) (ts : dvector (term L) l),\n  \u03d5.on_term (apps t ts) = apps (\u03d5.on_term t) (ts.map \u03d5.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 \u2209 range (\u03d5.on_symbol)) :\n  \u2200{l} (t : preterm L l), s \u2209 symbols_in_term (\u03d5.on_term t)\n| _ &k          h' := not_mem_empty _ h'\n| l (func f)    h' := h \u27e8sum.inl \u27e8l, f\u27e9, (eq_of_mem_singleton h').symm\u27e9\n| _ (app t\u2081 t\u2082) h' :=\n  or.elim h' (not_mem_symbols_in_term_on_term t\u2081) (not_mem_symbols_in_term_on_term t\u2082)\n\n@[simp] def on_formula : \u2200{l}, preformula L l \u2192 preformula L' l\n| _ falsum       := falsum\n| _ (t\u2081 \u2243 t\u2082)    := \u03d5.on_term t\u2081 \u2243 \u03d5.on_term t\u2082\n| _ (rel R)      := rel $ \u03d5.on_relation R\n| _ (apprel f t) := apprel (on_formula f) $ \u03d5.on_term t\n| _ (f\u2081 \u27f9 f\u2082)   := on_formula f\u2081 \u27f9 on_formula f\u2082\n| _ (\u2200' f)       := \u2200' on_formula f\n\n@[simp] lemma on_formula_lift_at : \u2200{l} (n m : \u2115) (f : preformula L l),\n  \u03d5.on_formula (f \u2191' n # m) = \u03d5.on_formula f \u2191' n # m\n| _ n m falsum       := by refl\n| _ n m (t\u2081 \u2243 t\u2082)    := by simp\n| _ n m (rel R)      := by refl\n| _ n m (apprel f t) := by simp*\n| _ n m (f\u2081 \u27f9 f\u2082)   := by simp*\n| _ n m (\u2200' f)       := by simp*\n\n@[simp] lemma on_formula_lift {l} (n : \u2115) (f : preformula L l) :\n  \u03d5.on_formula (f \u2191 n) = \u03d5.on_formula f \u2191 n :=\n\u03d5.on_formula_lift_at n 0 f\n\n@[simp] lemma on_formula_subst : \u2200{l} (f : preformula L l) (s : term L) (n : \u2115),\n  \u03d5.on_formula (f[s // n]) = (\u03d5.on_formula f)[\u03d5.on_term s // n]\n| _ falsum       s n := by refl\n| _ (t\u2081 \u2243 t\u2082)    s n := by simp\n| _ (rel R)      s n := by refl\n| _ (apprel f t) s n := by simp*\n| _ (f\u2081 \u27f9 f\u2082)   s n := by simp*\n| _ (\u2200' f)       s n := by simp*\n\n@[simp] def on_formula_apps_rel : \u2200{l} (f : preformula L l) (ts : dvector (term L) l),\n  \u03d5.on_formula (apps_rel f ts) = apps_rel (\u03d5.on_formula f) (ts.map \u03d5.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 \u2209 range (\u03d5.on_symbol)) :\n  \u2200{l} (f : preformula L l), s \u2209 symbols_in_formula (\u03d5.on_formula f)\n| _ falsum       h' := not_mem_empty _ h'\n| _ (t\u2081 \u2243 t\u2082)    h' := by cases h'; apply not_mem_symbols_in_term_on_term \u03d5 h _ h'\n| l (rel R)      h' := h \u27e8sum.inr \u27e8l, R\u27e9, (eq_of_mem_singleton h').symm\u27e9\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 \u03d5 h _ h' }\n| _ (f\u2081 \u27f9 f\u2082)   h' := by cases h'; apply not_mem_symbols_in_formula_on_formula _ h'\n| _ (\u2200' 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' \u2209 range (@on_function _ _ \u03d5 l')) {l} (f : preformula L l) :\n  (sum.inl \u27e8l', f'\u27e9 : L'.symbols) \u2209 symbols_in_formula (\u03d5.on_formula f) :=\nbegin\n  apply not_mem_symbols_in_formula_on_formula,\n  intro h', apply h,\n  rcases h' with \u27e8\u27e8n, f\u27e9 | \u27e8n, R\u27e9, hf\u2082\u27e9; dsimp at hf\u2082; cases hf\u2082 with hf\u2082',\n  apply mem_range_self\nend\n\n@[simp] def on_bounded_term {n} : \u2200{l} (t : bounded_preterm L n l), bounded_preterm L' n l\n| _ &k           := &k\n| _ (bd_func f)  := bd_func $ \u03d5.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} : \u2200{l} (t : bounded_preterm L n l),\n  (\u03d5.on_bounded_term t).fst = \u03d5.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 : \u2200{n l} (f : bounded_preformula L n l), bounded_preformula L' n l\n| _ _ bd_falsum       := \u22a5\n| _ _ (t\u2081 \u2243 t\u2082)       := \u03d5.on_bounded_term t\u2081 \u2243 \u03d5.on_bounded_term t\u2082\n| _ _ (bd_rel R)      := bd_rel $ \u03d5.on_relation R\n| _ _ (bd_apprel f t) := bd_apprel (on_bounded_formula f) $ \u03d5.on_bounded_term t\n| _ _ (f\u2081 \u27f9 f\u2082)      := on_bounded_formula f\u2081 \u27f9 on_bounded_formula f\u2082\n| _ _ (\u2200' f)          := \u2200' on_bounded_formula f\n\n@[simp] def on_bounded_formula_fst : \u2200{n l} (f : bounded_preformula L n l),\n  (\u03d5.on_bounded_formula f).fst = \u03d5.on_formula f.fst\n| _ _ bd_falsum       := by refl\n| _ _ (t\u2081 \u2243 t\u2082)       := by simp\n| _ _ (bd_rel R)      := by refl\n| _ _ (bd_apprel f t) := by simp*\n| _ _ (f\u2081 \u27f9 f\u2082)      := by simp*\n| _ _ (\u2200' 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 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2):\n      (g \u2218 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 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2) (n):\n      @on_function L1 L3 (g \u2218 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 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2) :\n      (g \u2218 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 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2) (n):\n      @on_relation L1 L3 (g \u2218 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 : \u2115} (g : L2 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2) :\n@on_term L1 L3 (g \u2218 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 : \u2115}(g : L2 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2) :\n@on_formula L1 L3 (g \u2218 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 : \u2115}(g : L2 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2) :\n@on_bounded_term L1 L3 (g \u2218 f) n l = function.comp (@on_bounded_term L2 L3 g n l) (@on_bounded_term L1 L2 f n l) :=\nfunext $ \u03bb _, by tidy\n\n@[simp]lemma comp_on_bounded_formula {L1} {L2} {L3} {n l : \u2115}(g : L2 \u2192\u1d38 L3) (f : L1 \u2192\u1d38 L2) :\n@on_bounded_formula L1 L3 (g \u2218 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} : \u03a0l, \u03a0 f, (@on_term L L (Lhom.id L) l) f = f\n| _ &k          := by refl\n| _ (func f)    := by refl\n| l (app t\u2081 t\u2082) := by simp[id_term (l+1) t\u2081, id_term 0 t\u2082]\n\nlemma id_formula {L} : \u03a0 l, \u03a0 f, (@on_formula L L (Lhom.id L) l) f = f\n| _   falsum        := by refl\n| _ (t\u2081 \u2243 t\u2082)         := 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\u2081 \u27f9 f\u2082)    := by {dsimp, rw[id_formula _ f\u2081, id_formula _ f\u2082]}\n| _ (\u2200' f)        := by {dsimp, rw[id_formula _ f]}\n\nlemma id_bounded_term {L} (n) : \u03a0l, \u03a0 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\u2081 t\u2082) := by simp[id_bounded_term (l+1) t\u2081, id_bounded_term 0 t\u2082]\n\nlemma id_bounded_formula {L} : \u03a0 n l, \u03a0 f, (@on_bounded_formula L L (Lhom.id L) n l) f = f\n| _ _   bd_falsum        := by refl\n| _ _ (t\u2081 \u2243 t\u2082)         := 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\u2081 \u27f9 f\u2082)    := by {dsimp, rw[id_bounded_formula _ _ f\u2081, id_bounded_formula _ _ f\u2082]}\n| _ _ (\u2200' f)        := by {dsimp, rw[id_bounded_formula _ _ f]}\n\n@[simp] def on_closed_term (t : closed_term L) : closed_term L' := \u03d5.on_bounded_term t\n@[simp] def on_sentence (f : sentence L) : sentence L' := \u03d5.on_bounded_formula f\ndef on_sentence_fst (f : sentence L) : (\u03d5.on_sentence f).fst = \u03d5.on_formula f.fst :=\n\u03d5.on_bounded_formula_fst f\n\ndef on_prf {\u0393 : set $ formula L} {f : formula L} (h : \u0393 \u22a2 f) : \u03d5.on_formula '' \u0393 \u22a2 \u03d5.on_formula f :=\nbegin\n  induction h,\n  { apply axm, exact mem_image_of_mem _ h_h, },\n  { apply impI, rw [\u2190image_insert_eq], exact h_ih },\n  { exact impE _ h_ih_h\u2081 h_ih_h\u2082, },\n  { apply falsumE, rw [image_insert_eq] at h_ih, exact h_ih },\n  { apply allI, rw [image_image] at h_ih \u22a2, simp [image_congr' (on_formula_lift \u03d5 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\u2082, apply subst _ h_ih_h\u2081 h_ih_h\u2082, simp }\nend\n\ndef on_sprf {\u0393 : set $ sentence L} {f : sentence L} (h : \u0393 \u22a2 f) :\n  \u03d5.on_sentence '' \u0393 \u22a2 \u03d5.on_sentence f :=\nby have := \u03d5.on_prf h; simp only [sprf, Theory.fst, image_image, function.comp,\n  on_bounded_formula_fst, on_sentence] at this \u22a2; exact this\n\n\n/- replace all symbols not in the image of \u03d5 by a new variable -/\nnoncomputable def reflect_term [has_decidable_range \u03d5] (t : term L') (m : \u2115) : term L :=\nterm.elim (\u03bbk, &k \u2191' 1 # m)\n     (\u03bbl f' ts' ts, if hf' : f' \u2208 range (@on_function _ _ \u03d5 l)\n       then apps (func (classical.some hf')) ts else &m) t\n\nvariable {\u03d5}\nlemma reflect_term_apps_pos [has_decidable_range \u03d5] {l} {f : L'.functions l}\n  (hf : f \u2208 range (@on_function _ _ \u03d5 l)) (ts : dvector (term L') l) (m : \u2115) :\n  \u03d5.reflect_term (apps (func f) ts) m =\n  apps (func (classical.some hf)) (ts.map (\u03bbt, \u03d5.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 \u03d5] {l} {f : L'.functions l}\n  (hf : f \u2209 range (@on_function _ _ \u03d5 l)) (ts : dvector (term L') l) (m : \u2115) :\n  \u03d5.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 \u03d5] {c : L'.constants}\n  (hf : c \u2208 range (@on_function _ _ \u03d5 0)) (m : \u2115) :\n  \u03d5.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 \u03d5] {c : L'.constants}\n  (hf : c \u2209 range (@on_function _ _ \u03d5 0)) (m : \u2115) :\n  \u03d5.reflect_term (func c) m = &m :=\nby apply reflect_term_apps_neg hf ([]) m\n\n@[simp] lemma reflect_term_var [has_decidable_range \u03d5] (k : \u2115) (m : \u2115) :\n  \u03d5.reflect_term &k m = &k \u2191' 1 # m := by refl\n\n@[simp] lemma reflect_term_on_term [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) (t : term L)\n  (m : \u2115) : \u03d5.reflect_term (\u03d5.on_term t) m = t \u2191' 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 (\u03bby hy, h\u03d5.on_function hy), dvector.map_congr_pmem ih_ts] }\nend\n\nlemma reflect_term_lift_at [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) {n m m' : \u2115} (h : m \u2264 m')\n  (t : term L') : \u03d5.reflect_term (t \u2191' n # m) (m'+n) = \u03d5.reflect_term t m' \u2191' 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 \u2208 range (@on_function _ _ \u03d5 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 \u03d5] (h\u03d5 : is_injective \u03d5) {n m : \u2115}\n  (t : term L') : \u03d5.reflect_term (t \u2191 n) (m+n) = \u03d5.reflect_term t m \u2191 n :=\nreflect_term_lift_at h\u03d5 m.zero_le t\n\nlemma reflect_term_subst [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) (n m : \u2115)\n  (s t : term L') :\n  \u03d5.reflect_term (t[s // n]) (m+n) = (\u03d5.reflect_term t (m+n+1))[\u03d5.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\u2082 : \u00ac(m + n \u2264 k), from \u03bbh', not_le_of_gt h (le_trans (le_add_left n m) h'),\n      have h\u2083 : \u00ac(m + n + 1 \u2264 k), from \u03bbh', h\u2082 $ le_trans (le_succ _) h',\n      simp [h, h\u2082, h\u2083, -add_comm, -add_assoc] },\n    { have h\u2082 : \u00ac(m + n + 1 \u2264 n), from not_le_of_gt (lt_of_le_of_lt (le_add_left n m) (lt.base _)) ,\n      simp [h, h\u2082, reflect_term_lift h\u03d5, -add_comm, -add_assoc] },\n    { have hk := one_le_of_lt h,\n      have h\u2084 : n < k + 1, from lt.trans h (lt.base k),\n      by_cases h\u2082' : m + n + 1 \u2264 k,\n      { have h\u2082 : m + n + 1 \u2264 k, from h\u2082',\n        have h\u2083 : m + n \u2264 k - 1, from (nat.le_sub_right_iff_add_le hk).mpr h\u2082,\n        simp [h, h\u2082, h\u2083, h\u2084, -add_comm, -add_assoc],\n        rw [sub_add_eq_max, max_eq_left hk] },\n      { have h\u2082 : \u00ac(m + n + 1 \u2264 k), from h\u2082',\n        have h\u2083 : \u00ac(m + n \u2264 k - 1), from \u03bbh', h\u2082 $ (nat.le_sub_right_iff_add_le hk).mp h',\n        simp [h, h\u2082, h\u2083, -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 \u2208 range (@on_function _ _ \u03d5 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 (\u03d5)\n\nnoncomputable def reflect_formula [has_decidable_range \u03d5] (f : formula L') :\n  \u2200(m : \u2115), formula L :=\nformula.rec (\u03bbm, \u22a5) (\u03bbt\u2081 t\u2082 m, \u03d5.reflect_term t\u2081 m \u2243 \u03d5.reflect_term t\u2082 m)\n  (\u03bbl R' xs' m, if hR' : R' \u2208 range (@on_relation _ _ \u03d5 l)\n       then apps_rel (rel (classical.some hR')) (xs'.map $ \u03bbt, \u03d5.reflect_term t m) else \u22a5)\n   (\u03bbf\u2081' f\u2082' f\u2081 f\u2082 m, f\u2081 m \u27f9 f\u2082 m) (\u03bbf' f m, \u2200' f (m+1)) f\n\nvariable {\u03d5}\nlemma reflect_formula_apps_rel_pos [has_decidable_range \u03d5] {l} {R : L'.relations l}\n  (hR : R \u2208 range (@on_relation _ _ \u03d5 l)) (ts : dvector (term L') l) (m : \u2115) :\n  \u03d5.reflect_formula (apps_rel (rel R) ts) m =\n  apps_rel (rel (classical.some hR)) (ts.map (\u03bbt, \u03d5.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 \u03d5] {l} {R : L'.relations l}\n  (hR : R \u2209 range (@on_relation _ _ \u03d5 l)) (ts : dvector (term L') l) (m : \u2115) :\n  \u03d5.reflect_formula (apps_rel (rel R) ts) m = \u22a5 :=\nby simp [reflect_formula, formula.rec_apps_rel, dif_neg hR]\n\n@[simp] lemma reflect_formula_equal [has_decidable_range \u03d5] (t\u2081 t\u2082 : term L') (m : \u2115) :\n  \u03d5.reflect_formula (t\u2081 \u2243 t\u2082) m = \u03d5.reflect_term t\u2081 m \u2243 \u03d5.reflect_term t\u2082 m := by refl\n@[simp] lemma reflect_formula_imp [has_decidable_range \u03d5] (f\u2081 f\u2082 : formula L') (m : \u2115) :\n  \u03d5.reflect_formula (f\u2081 \u27f9 f\u2082) m = \u03d5.reflect_formula f\u2081 m \u27f9 \u03d5.reflect_formula f\u2082 m := by refl\n@[simp] lemma reflect_formula_all [has_decidable_range \u03d5] (f : formula L') (m : \u2115) :\n  \u03d5.reflect_formula (\u2200' f) m = \u2200' (\u03d5.reflect_formula f (m+1)) := by refl\n\n@[simp] lemma reflect_formula_on_formula [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) (m : \u2115)\n  (f : formula L) : \u03d5.reflect_formula (\u03d5.on_formula f) m = f \u2191' 1 # m :=\nbegin\n  revert m, refine formula.rec _ _ _ _ _ f; clear f; intros,\n  { refl },\n  { simp [h\u03d5] },\n  { simp [reflect_formula_apps_rel_pos (mem_range_self R), h\u03d5],\n    rw [classical.some_eq R (\u03bby hy, h\u03d5.on_relation hy)] },\n  { simp* },\n  { simp* }\nend\n\nlemma reflect_formula_lift_at [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) {n m m' : \u2115}\n  (h : m \u2264 m') (f : formula L') :\n  \u03d5.reflect_formula (f \u2191' n # m) (m'+n) = \u03d5.reflect_formula f m' \u2191' n # m :=\nbegin\n  revert m m', refine formula.rec _ _ _ _ _ f; clear f; intros,\n  { refl },\n  { simp [reflect_term_lift_at h\u03d5 h, -add_comm] },\n  { by_cases h' : R \u2208 range (@on_relation _ _ \u03d5 l); simp [reflect_formula_apps_rel_pos,\n      reflect_formula_apps_rel_neg, h', h, ts.map_congr (reflect_term_lift_at h\u03d5 h), -add_comm] },\n  { simp [ih\u2081 h, ih\u2082 h, -add_comm] },\n  { simp [-add_comm, -add_assoc], rw [\u2190ih], simp, exact add_le_add_right h 1 },\nend\n\nlemma reflect_formula_lift [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) (n m : \u2115)\n  (f : formula L') : \u03d5.reflect_formula (f \u2191 n) (m+n) = \u03d5.reflect_formula f m \u2191 n :=\nreflect_formula_lift_at h\u03d5 m.zero_le f\n\nlemma reflect_formula_lift1 [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) (m : \u2115)\n  (f : formula L') : \u03d5.reflect_formula (f \u2191 1) (m+1) = \u03d5.reflect_formula f m \u2191 1 :=\nreflect_formula_lift h\u03d5 1 m f\n\nlemma reflect_formula_subst [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) (f : formula L')\n  (n m : \u2115) (s : term L') :\n  \u03d5.reflect_formula (f[s // n]) (m+n) = (\u03d5.reflect_formula f (m+n+1))[\u03d5.reflect_term s m // n] :=\nbegin\n  revert n, refine formula.rec _ _ _ _ _ f; clear f; intros,\n  { refl },\n  { simp [reflect_term_subst h\u03d5, -add_comm] },\n  { by_cases h' : R \u2208 range (@on_relation _ _ \u03d5 l); simp [reflect_formula_apps_rel_pos,\n      reflect_formula_apps_rel_neg, h', ts.map_congr (reflect_term_subst h\u03d5 n m s), -add_comm] },\n  { simp [ih\u2081, ih\u2082, -add_comm] },\n  { simp [-add_comm, ih] },\nend\n\n@[simp] lemma reflect_formula_subst0 [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) (m : \u2115)\n  (f : formula L') (s : term L') :\n  \u03d5.reflect_formula (f[s // 0]) m = (\u03d5.reflect_formula f (m+1))[\u03d5.reflect_term s m // 0] :=\nreflect_formula_subst h\u03d5 f 0 m s\n\nnoncomputable def reflect_prf_gen [has_decidable_range \u03d5] (h\u03d5 : is_injective \u03d5) {\u0393}\n  {f : formula L'} (m) (H : \u0393 \u22a2 f) : (\u03bbf, \u03d5.reflect_formula f m) '' \u0393 \u22a2 \u03d5.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\u2081, apply H_ih_h\u2082 },\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\u03d5 m) },\n  { apply allE, have h := @H_ih m, simp at h, exact h, symmetry,\n    apply reflect_formula_subst0 h\u03d5 },\n  { apply ref },\n  { apply subst, have h := @H_ih_h\u2081 m, simp at h, exact h,\n    have h := @H_ih_h\u2082 m, simp [h\u03d5] at h, exact h, simp [h\u03d5] },\nend\n\nsection\n\n/- maybe generalize to filter_symbol? -/\n@[reducible] def filter_symbols (p : L.symbols \u2192 Prop) : Language :=\n\u27e8\u03bbl, subtype (\u03bbf, p (sum.inl \u27e8l, f\u27e9)), \u03bbl, subtype (\u03bbR, p (sum.inr \u27e8l, R\u27e9))\u27e9\n\ndef filter_symbols_Lhom (p : L.symbols \u2192 Prop) : filter_symbols p \u2192\u1d38 L :=\n\u27e8\u03bbl, subtype.val, \u03bbl, subtype.val\u27e9\n\ndef is_injective_filter_symbols_Lhom (p : L.symbols \u2192 Prop) :\n  is_injective (filter_symbols_Lhom p) :=\n\u27e8\u03bbl, subtype.val_injective, \u03bbl, subtype.val_injective\u27e9\n\nlemma find_term_filter_symbols (p : L.symbols \u2192 Prop) :\n  \u2200{l} (t : preterm L l) (h : symbols_in_term t \u2286 { s | p s }),\n  { t' : preterm (filter_symbols p) l // (filter_symbols_Lhom p).on_term t' = t }\n| _ &k          h := \u27e8&k, rfl\u27e9\n| _ (func f)    h := \u27e8func \u27e8f, h $ mem_singleton _\u27e9, rfl\u27e9\n| _ (app t\u2081 t\u2082) h :=\n  begin\n    let ih\u2081 := find_term_filter_symbols t\u2081 (subset.trans (subset_union_left _ _) h),\n    let ih\u2082 := find_term_filter_symbols t\u2082 (subset.trans (subset_union_right _ _) h),\n    refine \u27e8app ih\u2081.1 ih\u2082.1, _\u27e9, dsimp, rw [ih\u2081.2, ih\u2082.2]\n  end\n\nlemma find_formula_filter_symbols (p : L.symbols \u2192 Prop) :\n  \u2200{l} (f : preformula L l) (h : symbols_in_formula f \u2286 { s | p s }),\n  { f' : preformula (filter_symbols p) l // (filter_symbols_Lhom p).on_formula f' = f }\n| _ falsum       h := \u27e8\u22a5, rfl\u27e9\n| _ (t\u2081 \u2243 t\u2082)    h :=\n  begin\n    let ih\u2081 := find_term_filter_symbols p t\u2081 (subset.trans (subset_union_left _ _) h),\n    let ih\u2082 := find_term_filter_symbols p t\u2082 (subset.trans (subset_union_right _ _) h),\n    refine \u27e8ih\u2081.1 \u2243 ih\u2082.1, _\u27e9, dsimp, rw [ih\u2081.2, ih\u2082.2]\n  end\n| _ (rel R)      h := \u27e8rel \u27e8R, h $ mem_singleton _\u27e9, rfl\u27e9\n| _ (apprel f t) h :=\n  begin\n    let ih\u2081 := find_formula_filter_symbols f (subset.trans (subset_union_left _ _) h),\n    let ih\u2082 := find_term_filter_symbols p t (subset.trans (subset_union_right _ _) h),\n    refine \u27e8apprel ih\u2081.1 ih\u2082.1, _\u27e9, dsimp, rw [ih\u2081.2, ih\u2082.2]\n  end\n| _ (f\u2081 \u27f9 f\u2082)   h :=\n  begin\n    let ih\u2081 := find_formula_filter_symbols f\u2081 (subset.trans (subset_union_left _ _) h),\n    let ih\u2082 := find_formula_filter_symbols f\u2082 (subset.trans (subset_union_right _ _) h),\n    refine \u27e8ih\u2081.1 \u27f9 ih\u2082.1, _\u27e9, dsimp, rw [ih\u2081.2, ih\u2082.2]\n  end\n| _ (\u2200' f)       h :=\n  begin\n    let ih := find_formula_filter_symbols f h,\n    refine \u27e8\u2200' ih.1, _\u27e9, dsimp, rw [ih.2]\n  end\n\nend\n\nnoncomputable def generalize_constant {\u0393} (c : L.constants)\n  (h\u0393 : (sum.inl \u27e80, c\u27e9 : L.symbols) \u2209 \u22c3\u2080 (symbols_in_formula '' \u0393))\n  {f : formula L} (hf : (sum.inl \u27e80, c\u27e9 : L.symbols) \u2209 symbols_in_formula f)\n  (H : \u0393 \u22a2 f[func c // 0]) : \u0393 \u22a2 \u2200' f :=\nbegin\n  apply allI,\n  let p : L.symbols \u2192 Prop := (\u2260 sum.inl \u27e80, c\u27e9),\n  let \u03d5 := filter_symbols_Lhom p,\n  have h\u03d5 : is_injective \u03d5 := is_injective_filter_symbols_Lhom p,\n  have hc : c \u2209 range (on_function \u03d5),\n  { intro hc, rw [mem_range] at hc, rcases hc with \u27e8c', hc'\u27e9,\n    apply c'.2, rw [\u2190hc'], refl },\n  have hf' : symbols_in_formula f \u2286 {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 \u27e8f, rfl\u27e9,\n  have : {\u0393' // Lhom.on_formula \u03d5 '' \u0393' = \u0393 } ,\n  { refine \u27e8Lhom.on_formula \u03d5 \u207b\u00b9' \u0393, _\u27e9,\n    apply image_preimage_eq_of_subset, intros f' hf',\n    have : symbols_in_formula f' \u2286 {s : Language.symbols L | p s},\n    { intros s hs hps, subst hps, exact h\u0393 \u27e8_, mem_image_of_mem _ hf', hs\u27e9 },\n    rcases find_formula_filter_symbols p f' this with \u27e8f, rfl\u27e9,\n    apply mem_range_self },\n  rcases this with \u27e8\u0393, rfl\u27e9,\n  rw [image_image, \u2190image_congr' (\u03d5.on_formula_lift 1),\n    \u2190image_image \u03d5.on_formula],\n  apply \u03d5.on_prf,\n  haveI : has_decidable_range (filter_symbols_Lhom p) :=\n    \u27e8\u03bbn f, classical.prop_decidable _, \u03bbn R, classical.prop_decidable _\u27e9,\n  have := reflect_prf_gen h\u03d5 0 H,\n  rwa [reflect_formula_subst0 h\u03d5, reflect_term_const_neg hc, image_image,\n    image_congr' (reflect_formula_on_formula h\u03d5 0),\n    reflect_formula_on_formula h\u03d5, lift_subst_formula_cancel] at this\nend\n\nnoncomputable def sgeneralize_constant {T : Theory L} (c : L.constants)\n  (h\u0393 : (sum.inl \u27e80, c\u27e9 : L.symbols) \u2209 \u22c3\u2080 (symbols_in_formula '' T.fst))\n  {f : bounded_formula L 1} (hf : (sum.inl \u27e80, c\u27e9 : L.symbols) \u2209 symbols_in_formula f.fst)\n  (H : T \u22a2 f[bd_func c /0]) : T \u22a2 \u2200' f :=\nby { simp [sprf] at H, exact generalize_constant c h\u0393 hf H }\n\n\nnoncomputable def reflect_prf {\u0393 : set $ formula L} {f : formula L} (h\u03d5 : \u03d5.is_injective)\n  (h : \u03d5.on_formula '' \u0393 \u22a2 \u03d5.on_formula f) : \u0393 \u22a2 f :=\nbegin\n  haveI : has_decidable_range \u03d5 :=\n    \u27e8\u03bbl f, classical.prop_decidable _, \u03bbl R, classical.prop_decidable _\u27e9,\n  apply reflect_prf_lift1,\n  have := reflect_prf_gen h\u03d5 0 h, simp [image_image, h\u03d5] at this, exact this\nend\n\nnoncomputable def reflect_sprf {\u0393 : set $ sentence L} {f : sentence L} (h\u03d5 : \u03d5.is_injective)\n  (h : \u03d5.on_sentence '' \u0393 \u22a2 \u03d5.on_sentence f) : \u0393 \u22a2 f :=\nby { apply reflect_prf h\u03d5, simp only [sprf, Theory.fst, image_image, function.comp,\n     on_bounded_formula_fst, on_sentence] at h \u22a2, exact h }\n\nlemma on_term_inj (h : \u03d5.is_injective) {l} : injective (\u03d5.on_term : preterm L l \u2192 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 : \u03d5.is_injective) {l} :\n  injective (\u03d5.on_formula : preformula L l \u2192 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\u2081 hxy', x_ih_f\u2082 hxy''] },\n  { rw [x_ih hxy'] }\nend\n\nlemma on_bounded_term_inj (h : \u03d5.is_injective) {n} {l} : injective (\u03d5.on_bounded_term : bounded_preterm L n l \u2192 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 : \u03d5.is_injective) {n l}:\n  injective (\u03d5.on_bounded_formula : bounded_preformula L n l \u2192 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\u2081 hxy', x_ih_f\u2082 hxy''] },\n  { rw [x_ih hxy'] }\nend\n\nvariable (\u03d5)\n\n/-- Given L \u2192 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\u27e8 S.carrier, \u03bbn f, S.fun_map $ \u03d5.on_function f, \u03bbn R, S.rel_map $ \u03d5.on_relation R\u27e9\n\nnotation S`[[`:95 \u03d5`]]`:90 := reduct \u03d5 S\n\nvariable {\u03d5}\n\n@[simp] def reduct_coe (S : Structure L') : \u21a5(reduct \u03d5 S) = S :=\nby refl\n\ndef reduct_id {S : Structure L'} : S \u2192 S[[\u03d5]] := id\n\n@[simp] lemma reduct_term_eq {S : Structure L'} (h\u03d5 : \u03d5.is_injective) {n} :\n  \u03a0(xs : dvector S n) {l} (t : bounded_preterm L n l) (xs' : dvector S l), realize_bounded_term xs (on_bounded_term \u03d5 t) xs' = @realize_bounded_term L (reduct \u03d5 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\u03d5 : \u03d5.is_injective) : \u03a0{n l} (xs : dvector S n) (xs' : dvector S l) (f : bounded_preformula L n l),\n  realize_bounded_formula xs (on_bounded_formula \u03d5 f) xs' \u2194 @realize_bounded_formula L (reduct \u03d5 S) n l xs f xs'\n| _ _ xs xs' (bd_falsum)      := by refl\n| _ _ xs xs' (bd_equal t\u2081 t\u2082) := by simp [h\u03d5]\n| _ _ xs xs' (bd_rel R)       := by refl\n| _ _ xs xs' (bd_apprel f t)  := by simp*\n| _ _ xs xs' (f\u2081 \u27f9 f\u2082)       := by simp*\n| _ _ xs xs' (\u2200' f)           := by apply forall_congr; intro x;simp*\n\nlemma reduct_ssatisfied {S : Structure L'} {f : sentence L} (h\u03d5 : \u03d5.is_injective)\n (h : S \u22a8 \u03d5.on_sentence f) : \u03d5.reduct S \u22a8 f :=\n(reduct_bounded_formula_iff h\u03d5 ([]) ([]) f).mp h\n\nlemma reduct_ssatisfied' {S : Structure L'} {f : sentence L} (h\u03d5 : \u03d5.is_injective)\n (h : S \u22a8 \u03d5.on_bounded_formula f) : \u03d5.reduct S \u22a8 f :=\n(reduct_bounded_formula_iff h\u03d5 ([]) ([]) f).mp h\n\ndef reduct_all_ssatisfied {S : Structure L'} {T : Theory L} (h\u03d5 : \u03d5.is_injective)\n  (h : S \u22a8 \u03d5.on_sentence '' T) : S[[\u03d5]] \u22a8 T :=\n\u03bbf hf, reduct_ssatisfied h\u03d5 $ h $ mem_image_of_mem _ hf\n\nlemma reduct_nonempty_of_nonempty {S : Structure L'} (H : nonempty S) : nonempty (reduct \u03d5 S) :=\nby {apply nonempty.map, repeat{assumption}, exact reduct_id}\n\nvariable (\u03d5)\n@[reducible]def Theory_induced (T : Theory L) : Theory L' := \u03d5.on_sentence '' T\n\nvariable {\u03d5}\nlemma is_consistent_Theory_induced (h\u03d5 : \u03d5.is_injective) {T : Theory L} (hT : is_consistent T) :\n  is_consistent (\u03d5.Theory_induced T) :=\n\u03bbH, hT $ H.map $ \u03bbh, reflect_sprf h\u03d5 (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\u03d5 : \u03d5.is_injective)\n  (h : bounded_formula L 1 \u2192 bounded_formula L 1)\n  (hT' : \u2200(f : bounded_formula L 1), T \u22a2 \u2203' (h f))\n  (g : bounded_formula L 1 \u2192 L'.constants) (hg : injective g)\n  (hg' : \u2200x, g x \u2209 range (@on_function L L' \u03d5 0)) :\n  is_consistent (\u03d5.Theory_induced T \u222a\n  (\u03bbf, (\u03d5.on_bounded_formula (h f))[bd_const (g f)/0]) '' set.univ) :=\nbegin\n  haveI : decidable_eq (bounded_formula L 1) := \u03bbx y, classical.prop_decidable _,\n  haveI : decidable_eq (sentence L') := \u03bbx y, classical.prop_decidable _,\n  have lem : \u2200(s\u2080 : finset (bounded_formula L 1)),\n    is_consistent (\u03d5.Theory_induced T \u222a\n      (\u03bbf, (\u03d5.on_bounded_formula (h f))[bd_const (g f)/0]) '' \u2191s\u2080),\n  { refine finset.induction _ _,\n    { simp, exact is_consistent_Theory_induced h\u03d5 hT },\n    { intros \u03c8 s h\u03c8 ih hs, refine sprovable.elim _ hs, clear hs, intro hs, apply ih, constructor,\n      simp [image_insert_eq] at hs,\n      have : _ \u22a2 (\u03d5.on_bounded_formula $ \u223c(h \u03c8))[bd_const (g \u03c8)/0] := simpI hs,\n      have := sgeneralize_constant (g \u03c8) _ _ this,\n      { refine simpE _ _ this, apply sweakening (subset_union_left _ _) (\u03d5.on_sprf $ hT' \u03c8) },\n      { intro h', rcases h' with \u27e8s', \u27e8\u03c8', \u27e8\u03c8', \u27e8\u03c8', h\u03c8\u2082, rfl\u27e9 | \u27e8\u03c8', h\u03c8\u2082, rfl\u27e9, rfl\u27e9, rfl\u27e9, h\u03c8\u2083\u27e9,\n        { rw [\u03d5.on_sentence_fst] at h\u03c8\u2083,\n          exact \u03d5.not_mem_function_in_formula_on_formula (hg' _) _ h\u03c8\u2083 },\n        { simp at h\u03c8\u2083,\n          cases symbols_in_formula_subst _ _ _ h\u03c8\u2083 with h\u03c8\u2084 h\u03c8\u2084,\n          { exact \u03d5.not_mem_function_in_formula_on_formula (hg' _) _ h\u03c8\u2084 },\n          { injection eq_of_mem_singleton h\u03c8\u2084 with h\u03c8\u2085, injection h\u03c8\u2085 with x h\u03c8\u2086,\n            cases hg (eq_of_heq h\u03c8\u2086), exact h\u03c8 h\u03c8\u2082 }}},\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 \u27e8T\u2080, h\u2080, hT\u27e9,\n  have : decidable_pred (\u2208 \u03d5.Theory_induced T) := \u03bbx, classical.prop_decidable _,\n  rcases finset.subset_union_elim hT with \u27e8t\u2080, s\u2080, rfl, ht\u2080, hs\u2080\u27e9,\n  have hs\u2080' := subset.trans hs\u2080 (diff_subset _ _),\n  rcases finset.subset_image_iff.mp hs\u2080' with \u27e8s\u2080, hs\u2080x, rfl\u27e9,\n  apply lem s\u2080, refine h\u2080.map _, apply sweakening,\n  simp, refine subset.trans ht\u2080 _, 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 \u27e8L, language_id_morphism L\u27e9 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\u00e9bastien Gou\u00ebzel\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 \u2192 F`\nhas an invertible strict derivative `f'` at `a`, then it is locally invertible,\nand the inverse function has derivative `f' \u207b\u00b9`.\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 \u2243L[\ud835\udd5c] 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'\u207b\u00b9`.\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`\u211d` or `\u2102` and implemented here assuming `is_R_or_C \ud835\udd42`.\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 `\u2225f'\u207b\u00b9\u2225`;\n* by `g` we denote the auxiliary contracting map `x \u21a6 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\nvariables {E : Type*} [normed_group E] [normed_space \ud835\udd5c E]\nvariables {F : Type*} [normed_group F] [normed_space \ud835\udd5c F]\nvariables {G : Type*} [normed_group G] [normed_space \ud835\udd5c G]\nvariables {G' : Type*} [normed_group G'] [normed_space \ud835\udd5c G']\nvariables {\u03b5 : \u211d}\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 `\u2225f x - f y - f' (x - y)\u2225 \u2264 c * \u2225x - y\u2225` on an open set\n`s`, where `f' : E \u2192L[\ud835\udd5c] 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 \u2208 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 \u00d7 F \u2192 G` with estimates on `f x y\u2081 - f x y\u2082` but not on `f x\u2081 y - f x\u2082 y`.\n-/\n\n/-- We say that `f` approximates a continuous linear map `f'` on `s` with constant `c`,\nif `\u2225f x - f y - f' (x - y)\u2225 \u2264 c * \u2225x - y\u2225` whenever `x, y \u2208 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 \u2192 F) (f' : E \u2192L[\ud835\udd5c] F) (s : set E) (c : \u211d\u22650) : Prop :=\n\u2200 (x \u2208 s) (y \u2208 s), \u2225f x - f y - f' (x - y)\u2225 \u2264 c * \u2225x - y\u2225\n\nnamespace approximates_linear_on\n\nvariables [cs : complete_space E] {f : E \u2192 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 \u2192L[\ud835\udd5c] F} {s t : set E} {c c' : \u211d\u22650}\n\ntheorem mono_num (hc : c \u2264 c') (hf : approximates_linear_on f f' s c) :\n  approximates_linear_on f f' s c' :=\n\u03bb 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 \u2286 t) (hf : approximates_linear_on f f' t c) :\n  approximates_linear_on f f' s c :=\n\u03bb 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 (\u03bb x : s, f x - f' x) :=\nbegin\n  refine lipschitz_with.of_dist_le_mul (\u03bb 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 : \u211d\u22650} {f' : E \u2192L[\ud835\udd5c] 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  {\u03b5 : \u211d} {b : E} (\u03b50 : 0 \u2264 \u03b5) (h\u03b5 : closed_ball b \u03b5 \u2286 s) :\n  surj_on f (closed_ball b \u03b5) (closed_ball (f b) (((f'symm.nnnorm : \u211d)\u207b\u00b9 - c) * \u03b5)) :=\nbegin\n  assume y hy,\n  cases le_or_lt (f'symm.nnnorm : \u211d) \u207b\u00b9 c with hc hc,\n  { refine \u27e8b, by simp [\u03b50], _\u27e9,\n    have : dist y (f b) \u2264 0 :=\n      (mem_closed_ball.1 hy).trans (mul_nonpos_of_nonpos_of_nonneg (by linarith) \u03b50),\n    simp only [dist_le_zero] at this,\n    rw this },\n  have If' : (0 : \u211d) < f'symm.nnnorm,\n    by { rw [\u2190 inv_pos], exact (nnreal.coe_nonneg _).trans_lt hc },\n  have Icf' : (c : \u211d) * f'symm.nnnorm < 1, by rwa [inv_eq_one_div, lt_div_iff If'] at hc,\n  have Jf' : (f'symm.nnnorm : \u211d) \u2260 0 := ne_of_gt If',\n  have Jcf' : (1 : \u211d) - c * f'symm.nnnorm \u2260 0, by { apply ne_of_gt, linarith },\n  /- We have to show that `y` can be written as `f x` for some `x \u2208 closed_ball b \u03b5`.\n  The idea of the proof is to apply the Banach contraction principle to the map\n  `g : x \u21a6 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\u2099 = g\u207f 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 := \u03bb x, x + f'symm (y - f x) with hg,\n  set u := \u03bb (n : \u2115), g ^[n] b with hu,\n  have usucc : \u2200 n, u (n + 1) = g (u n), by simp [hu, \u2190 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 : \u2200 z, dist (g z) z \u2264 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 : \u2200 z \u2208 closed_ball b \u03b5, g z \u2208 closed_ball b \u03b5 \u2192\n    dist (f (g z)) y \u2264 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 = \u2225f (z + v) - y\u2225 : by rw [dist_eq_norm]\n    ... = \u2225f (z + v) - f  z - f' v + f' v - (y - f z)\u2225 : by { congr' 1, abel }\n    ... = \u2225f (z + v) - f z - f' ((z + v) - z)\u2225 :\n      by simp only [continuous_linear_map.nonlinear_right_inverse.right_inv,\n                    add_sub_cancel', sub_add_cancel]\n    ... \u2264 c * \u2225(z + v) - z\u2225 : hf _ (h\u03b5 hgz) _ (h\u03b5 hz)\n    ... \u2264 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 : \u2200 (n : \u2115) (w : E),\n    dist w b \u2264 f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y\n    \u2192 w \u2208 closed_ball b \u03b5,\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 : \u211d) * (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      ... \u2264 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    ... \u2264 f'symm.nnnorm * (((f'symm.nnnorm : \u211d)\u207b\u00b9 - c) * \u03b5) :\n      by { rw [mul_one],\n           exact mul_le_mul_of_nonneg_left (mem_closed_ball'.1 hy) (nnreal.coe_nonneg _) }\n    ... = \u03b5 * (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 : \u2200 (n : \u2115), dist (f (u n)) y \u2264 (c * f'symm.nnnorm)^n * dist (f b) y\n    \u2227 dist (u n) b \u2264 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 \u2264\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 \u2264 dist (g (u n)) (u n) + dist (u n) b : dist_triangle _ _ _\n      ... \u2264 f'symm.nnnorm * dist (f (u n)) y + dist (u n) b : add_le_add (A _) (le_refl _)\n      ... \u2264 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 \u27e8_, Ign\u27e9,\n    calc dist (f (g (u n))) y \u2264 c * f'symm.nnnorm * dist (f (u n)) y :\n      B _ (C n _ IH.2) (C n.succ _ Ign)\n    ... \u2264 (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\u2099` is a Cauchy sequence, therefore converging.\n  have : cauchy_seq u,\n  { have : \u2200 (n : \u2115), dist (u n) (u (n+1)) \u2264 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      ... \u2264 f'symm.nnnorm * dist (f (u n)) y : A _\n      ... \u2264 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 \u27e8x, hx\u27e9 : \u2203 x, tendsto u at_top (\ud835\udcdd x) := cauchy_seq_tendsto_of_complete this,\n  -- As all the `u\u2099` belong to the ball `closed_ball b \u03b5`, so does their limit `x`.\n  have xmem : x \u2208 closed_ball b \u03b5 :=\n    is_closed_ball.mem_of_tendsto hx (eventually_of_forall (\u03bb n, C n _ (D n).2)),\n  refine \u27e8x, xmem, _\u27e9,\n  -- It remains to check that `f x = y`. This follows from continuity of `f` on `closed_ball b \u03b5`\n  -- and from the fact that `f u\u2099` is converging to `y` by construction.\n  have hx' : tendsto u at_top (\ud835\udcdd[closed_ball b \u03b5] x),\n  { simp only [nhds_within, tendsto_inf, hx, true_and, ge_iff_le, tendsto_principal],\n    exact eventually_of_forall (\u03bb n, C n _ (D n).2) },\n  have T1 : tendsto (\u03bb n, f (u n)) at_top (\ud835\udcdd (f x)) :=\n    (hf.continuous_on.mono h\u03b5 x xmem).tendsto.comp hx',\n  have T2 : tendsto (\u03bb n, f (u n)) at_top (\ud835\udcdd y),\n  { rw tendsto_iff_dist_tendsto_zero,\n    refine squeeze_zero (\u03bb n, dist_nonneg) (\u03bb 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 \u2228 c < f'symm.nnnorm\u207b\u00b9) : 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 \u22a2,\n  intros x hx,\n  rcases hs x hx with \u27e8\u03b5, \u03b50, h\u03b5\u27e9,\n  refine \u27e8(f'symm.nnnorm\u207b\u00b9 - c) * \u03b5, mul_pos (sub_pos.2 hc) \u03b50, _\u27e9,\n  exact (hf.surj_on_closed_ball_of_nonlinear_right_inverse f'symm (le_of_lt \u03b50) h\u03b5).mono\n    h\u03b5 (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 \u2208 \ud835\udcdd x) (hc : subsingleton F \u2228 c < f'symm.nnnorm\u207b\u00b9) :\n  f '' s \u2208 \ud835\udcdd (f x) :=\nbegin\n  obtain \u27e8t, hts, ht, xt\u27e9 : \u2203 t \u2286 s, is_open t \u2227 x \u2208 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 \u2208 \ud835\udcdd x) (hc : subsingleton F \u2228 c < f'symm.nnnorm\u207b\u00b9) :\n  map f (\ud835\udcdd x) = \ud835\udcdd (f x) :=\nbegin\n  refine le_antisymm ((hf.continuous_on x (mem_of_mem_nhds hs)).continuous_at hs)\n    (le_map (\u03bb t ht, _)),\n  have : f '' (s \u2229 t) \u2208 \ud835\udcdd (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 \u2243L[\ud835\udd5c] F`.\n\nWe also assume that either `E = {0}`, or `c < \u2225f'\u207b\u00b9\u2225\u207b\u00b9`. We use `N` as an abbreviation for `\u2225f'\u207b\u00b9\u2225`.\n-/\n\nvariables {f' : E \u2243L[\ud835\udd5c] F} {s : set E} {c : \u211d\u22650}\n\nlocal notation `N` := nnnorm (f'.symm : F \u2192L[\ud835\udd5c] E)\n\nprotected lemma antilipschitz (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\n  antilipschitz_with (N\u207b\u00b9 - c)\u207b\u00b9 (s.restrict f) :=\nbegin\n  cases hc with hE hc,\n  { haveI : subsingleton s := \u27e8\u03bb x y, subtype.eq $ @subsingleton.elim _ hE _ _\u27e9,\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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\n  injective (s.restrict f) :=\n(hf.antilipschitz hc).injective\n\nprotected lemma inj_on (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) : 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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\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 (\u03bb 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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs : E \u2192 F) = f := rfl\n\n@[simp] lemma to_local_homeomorph_source (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (hs : is_open s) {b : E} (\u03b50 : 0 \u2264 \u03b5) (h\u03b5 : closed_ball b \u03b5 \u2286 s) :\n  closed_ball (f b) ((N\u207b\u00b9 - c) * \u03b5) \u2286 (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  \u03b50 h\u03b5).mono h\u03b5 (subset.refl _)\n\nend approximates_linear_on\n\n/-!\n### Inverse function theorem\n\nNow we prove the inverse function theorem. Let `f : E \u2192 F` be a map defined on a complete vector\nspace `E`. Assume that `f` has an invertible derivative `f' : E \u2243L[\ud835\udd5c] 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 \u2192 F} {f' : E \u2192L[\ud835\udd5c] F} {a : E}\n  (hf : has_strict_fderiv_at f f' a) {c : \u211d\u22650} (hc : subsingleton E \u2228 0 < c) :\n  \u2203 s \u2208 \ud835\udcdd a, approximates_linear_on f f' s c :=\nbegin\n  cases hc with hE hc,\n  { refine \u27e8univ, is_open.mem_nhds is_open_univ trivial, \u03bb x hx y hy, _\u27e9,\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 \u27e8s, has, hs\u27e9,\n  exact \u27e8s, has, \u03bb x hx y hy, hs (mk_mem_prod hx hy)\u27e9\nend\n\nlemma map_nhds_eq_of_surj [complete_space E] [complete_space F]\n  {f : E \u2192 F} {f' : E \u2192L[\ud835\udd5c] F} {a : E}\n  (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) (h : f'.range = \u22a4) :\n  map f (\ud835\udcdd a) = \ud835\udcdd (f a) :=\nbegin\n  let f'symm := f'.nonlinear_right_inverse_of_surjective h,\n  set c : \u211d\u22650 := f'symm.nnnorm\u207b\u00b9 / 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 \u27e8s, s_nhds, hs\u27e9 : \u2203 s \u2208 \ud835\udcdd 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 \u2192 F} {f' : E \u2243L[\ud835\udd5c] F} {a : E}\n\nlemma approximates_deriv_on_open_nhds (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) :\n  \u2203 (s : set E) (hs : a \u2208 s \u2227 is_open s),\n    approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s ((nnnorm (f'.symm : F \u2192L[\ud835\udd5c] E))\u207b\u00b9 / 2) :=\nbegin\n  refine ((nhds_basis_opens a).exists_iff _).1 _,\n  exact (\u03bb s t, approximates_linear_on.mono_set),\n  exact (hf.approximates_deriv_on_nhds $ f'.subsingleton_or_nnnorm_symm_pos.imp id $\n    \u03bb 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 \u2208 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 \u2192L[\ud835\udd5c] 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 $ \u03bb 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 \u2192L[\ud835\udd5c] F) a) :\n  (hf.to_local_homeomorph f : E \u2192 F) = f := rfl\n\nlemma mem_to_local_homeomorph_source (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) :\n  a \u2208 (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 \u2192L[\ud835\udd5c] F) a) :\n  f a \u2208 (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 \u2192L[\ud835\udd5c] F) a) :\n  map f (\ud835\udcdd a) = \ud835\udcdd (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 \u2192L[\ud835\udd5c] F) a) : F \u2192 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 \u2192L[\ud835\udd5c] 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 \u2192L[\ud835\udd5c] F) a) :\n  \u2200\u1da0 x in \ud835\udcdd 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 \u2192L[\ud835\udd5c] F) a) :\n  \u2200\u1da0 y in \ud835\udcdd (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 \u2192L[\ud835\udd5c] 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 \u2192L[\ud835\udd5c] F) a) :\n  tendsto (hf.local_inverse f f' a) (\ud835\udcdd $ f a) (\ud835\udcdd 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 \u2192L[\ud835\udd5c] F) a) {g : F \u2192 E}\n  (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  \u2200\u1da0 y in \ud835\udcdd (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 \u2192L[\ud835\udd5c] F) a) :\n  has_strict_fderiv_at (hf.local_inverse f f' a) (f'.symm : F \u2192L[\ud835\udd5c] E) (f a) :=\n(hf.to_local_homeomorph f).has_strict_fderiv_at_symm hf.image_mem_to_local_homeomorph_target $\n  by simpa [\u2190 local_inverse_def] using hf\n\n/-- If `f : E \u2192 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 \u2192L[\ud835\udd5c] F) a) {g : F \u2192 E}\n  (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  has_strict_fderiv_at g (f'.symm : F \u2192L[\ud835\udd5c] E) (f a) :=\nhf.to_local_inverse.congr_of_eventually_eq $ (hf.local_inverse_unique hg).mono $ \u03bb _, 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 \u2192 F} {f' : E \u2192 E \u2243L[\ud835\udd5c] F}\n  (hf : \u2200 x, has_strict_fderiv_at f (f' x : E \u2192L[\ud835\udd5c] F) x) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ \u03bb 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 : \ud835\udd5c \u2192 \ud835\udd5c`.\nWe use `continuous_linear_equiv.units_equiv_aut` to translate `has_strict_deriv_at f f' a` and\n`f' \u2260 0` into `has_strict_fderiv_at f (_ : \ud835\udd5c \u2243L[\ud835\udd5c] \ud835\udd5c) a`.\n-/\n\nnamespace has_strict_deriv_at\n\nvariables [cs : complete_space \ud835\udd5c] {f : \ud835\udd5c \u2192 \ud835\udd5c} {f' a : \ud835\udd5c} (hf : has_strict_deriv_at f f' a)\n  (hf' : f' \u2260 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 : \ud835\udd5c \u2192 \ud835\udd5c :=\n(hf.has_strict_fderiv_at_equiv hf').local_inverse _ _ _\n\nvariables {f f' a}\n\nlemma map_nhds_eq : map f (\ud835\udcdd a) = \ud835\udcdd (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'\u207b\u00b9 (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_inverse\n\ntheorem to_local_left_inverse {g : \ud835\udd5c \u2192 \ud835\udd5c} (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  has_strict_deriv_at g f'\u207b\u00b9 (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 \ud835\udd5c] {f f' : \ud835\udd5c \u2192 \ud835\udd5c}\n  (hf : \u2200 x, has_strict_deriv_at f (f' x) x) (h0 : \u2200 x, f' x \u2260 0) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ \u03bb 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 {\ud835\udd42 : Type*} [is_R_or_C \ud835\udd42]\nvariables {E' : Type*} [normed_group E'] [normed_space \ud835\udd42 E']\nvariables {F' : Type*} [normed_group F'] [normed_space \ud835\udd42 F']\nvariables [complete_space E'] (f : E' \u2192 F') {f' : E' \u2243L[\ud835\udd42] F'} {a : E'}\n\n/-- Given a `times_cont_diff` function over `\ud835\udd42` (which is `\u211d` or `\u2102`) with an invertible\nderivative at `a`, returns a `local_homeomorph` with `to_fun = f` and `a \u2208 source`. -/\ndef to_local_homeomorph\n  {n : with_top \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 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 \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  (hf.to_local_homeomorph f hf' hn : E' \u2192 F') = f := rfl\n\nlemma mem_to_local_homeomorph_source\n  {n : with_top \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  a \u2208 (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 \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  f a \u2208 (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 `\ud835\udd42` (which is `\u211d` or `\u2102`) with an invertible derivative\nat `a`, returns a function that is locally inverse to `f`. -/\ndef local_inverse\n  {n : with_top \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  F' \u2192 E' :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse f f' a\n\nlemma local_inverse_apply_image\n  {n : with_top \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 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 `\ud835\udd42` (which is `\u211d` or `\u2102`) 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 \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  times_cont_diff_at \ud835\udd42 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 \ud835\udd40\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 \ud835\udd38\u207f (where n can even be infinite).\nA _regular function_ on V is a function V \u2192 k which is induced\nby some polynomial F \u2208 k[X\u2081, X\u2082, \u2026, X\u2099]. 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 `\ud835\udd38\u207f` := n \u2192 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 \u2286 \ud835\udd38\u207f 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 \ud835\udd38\u207f) \u2192 k) : Prop :=\n  \u2203 F : k[n], \u2200 (x : \ud835\udd38\u207f) (hx : x \u2208 V), F.eval x = f \u27e8x, hx\u27e9\n\ndef is_regular (f : (V : subset_of \ud835\udd38\u207f) \u2192 k) : Prop :=\n  \u2203 F : k[n], \u2200 (x : (V : subset_of \ud835\udd38\u207f)), F.eval x = f x\n\n/-- A \"regular function\" is a pair: a function V \u2192 k, and a proof that\nit comes from a polynomial -/\nstructure regular_fun (V : affine_algebraic_set k n) :=\n(to_fun : {x : \ud835\udd38\u207f // x \u2208 (V : subset_of \ud835\udd38\u207f)} \u2192 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\u27e8_, regular_fun.to_fun\u27e9\n\nvariable {V}\n\n/-- A regular function is induced from a polynomial -/\nlemma is_regular (f : k[V]): \u2203 F : k[n],\n   \u2200 (x : (V : subset_of \ud835\udd38\u207f)), 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 := \u03bb x, F.eval x, -- i.e. F(x)\n  is_regular' := \u27e8F, \u03bb x, rfl\u27e9 }\n\nvariable {V}\n\ndef mk'.some_spec (F : k[n]) (x : (V : subset_of \ud835\udd38\u207f)) :\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 \u2192 k are equal -/\n@[ext] lemma ext (f g : k[V]) : (f : (V : set \ud835\udd38\u207f) \u2192 k) = g \u2192 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 \u2194 (f : (V : set \ud835\udd38\u207f) \u2192 k) = g :=\n\u27e8\u03bb h, h \u25b8 rfl, ext f g\u27e9\n\n-- We prove the regular functions are naturally a ring.\n\ndef zero : k[V] :=\n{ to_fun := \u03bb x, 0,\n  is_regular' := begin\n    -- the function V \u2192 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]) := \u27e8zero\u27e9\n\ndef one : k[V] :=\n{ to_fun := \u03bb x, 1,\n  is_regular' := begin\n    -- the function V \u2192 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]) := \u27e8one\u27e9\n\ndef add (f g : k[V]) : k[V] :=\n{ to_fun := \u03bb 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]) := \u27e8add\u27e9\n\ndef neg (f : k[V]) : k[V] :=\n{ to_fun := \u03bb 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]) := \u27e8neg\u27e9\n\ndef mul (f g : k[V]) : k[V] :=\n{ to_fun := \u03bb 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]) := \u27e8mul\u27e9\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\u2081, X\u2082, \u2026, X\u2099] to k[V] -/\nnoncomputable def mv_polynomial.to_regular_fun : mv_polynomial n k \u2192+* k[V] :=\n{ to_fun := \u03bb F,\n  { to_fun := \u03bb x, F.eval x.1,\n    is_regular' := \u27e8F, \u03bb x, rfl\u27e9\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 := \u03bb t f,\n  { to_fun := \u03bb 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 (\u03bb 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 := (\u03bb 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 \u2192+* k[V]) : mv_polynomial n k \u2192 k[V]) :=\nbegin\n  intro f,\n  cases f.is_regular with F hF,\n  use F,\n  ext x,\n  rw \u2190hF 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 \u2192+* k[V]) : mv_polynomial n k \u2192 k[V]) F = 0\n  \u2194 F \u2208 \ud835\udd40 V :=\nbegin\n  rw mem_\ud835\udd40_iff,\n  rw regular_fun.ext_iff,\n  rw funext_iff,\n  split, -- sigh\n  { intros f x hx, exact f \u27e8x, hx\u27e9},\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] \u2192\u2090[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 : \u2200 {X : Type u_2} {R : Type u_1} [_inst_1 : comm_semiring R] (x : X \u2192 R), eval x 1 = 1\nmv_polynomial.eval_zero : \u2200 {\u03b1 : Type ?} {n : Type ?} [_inst_1 : comm_semiring \u03b1] {f : n \u2192 \u03b1}, 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 = \u22a4`) 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 \u2192 submonoid M` and coercion `coe : submonoid M \u2192 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 \u2192 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 : \u2115 \u2192 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 `\u2264` rather than `\u2286`, although `\u2208` 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 \u2264 M`, such that `1 \u2208 s` for all `s`. -/\nclass OneMemClass (S M : Type _) [One M] [SetLike S M] : Prop where\n  one_mem : \u2200 s : S, (1 : M) \u2208 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 \u2264 M`, such that `0 \u2208 s` for all `s`. -/\nclass ZeroMemClass (S M : Type _) [Zero M] [SetLike S M] : Prop where\n  zero_mem : \u2200 s : S, (0 : M) \u2208 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) \u2208 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 \u2264 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) \u2208 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 \u2264 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\u2093'. -/\n@[to_additive]\ntheorem pow_mem {M} [Monoid M] {A : Type _} [SetLike A M] [SubmonoidClass A M] {S : A} {x : M}\n    (hx : x \u2208 S) : \u2200 n : \u2115, x ^ n \u2208 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 \u2192 coe)\n\ninitialize_simps_projections AddSubmonoid (carrier \u2192 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\u2093'. -/\n@[simp, to_additive]\ntheorem mem_carrier {s : Submonoid M} {x : M} : x \u2208 s.carrier \u2194 x \u2208 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\u2093'. -/\n@[simp, to_additive]\ntheorem mem_mk {s : Set M} {x : M} (h_one) (h_mul) : x \u2208 mk s h_one h_mul \u2194 x \u2208 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\u2093.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\u2093'. -/\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\u2093'. -/\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 \u2264 mk t h_one' h_mul' \u2194 s \u2286 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\u2093'. -/\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 : \u2200 x, x \u2208 S \u2194 x \u2208 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\u2093.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\u2093'. -/\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 \u25b8 S.one_mem'\n  mul_mem' _ _ := hs.symm \u25b8 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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093'. -/\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\u2093'. -/\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) \u2208 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\u2093'. -/\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 \u2208 S \u2192 y \u2208 S \u2192 x * y \u2208 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  \u27e8{  carrier := Set.univ\n      one_mem' := Set.mem_univ 1\n      mul_mem' := fun _ _ _ _ => Set.mem_univ _ }\u27e9\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  \u27e8{  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] }\u27e9\n\n@[to_additive]\ninstance : Inhabited (Submonoid M) :=\n  \u27e8\u22a5\u27e9\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\u2093'. -/\n@[simp, to_additive]\ntheorem mem_bot {x : M} : x \u2208 (\u22a5 : Submonoid M) \u2194 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\u2093'. -/\n@[simp, to_additive]\ntheorem mem_top (x : M) : x \u2208 (\u22a4 : 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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem coe_top : ((\u22a4 : 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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem coe_bot : ((\u22a5 : 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  \u27e8fun S\u2081 S\u2082 =>\n    { carrier := S\u2081 \u2229 S\u2082\n      one_mem' := \u27e8S\u2081.one_mem, S\u2082.one_mem\u27e9\n      mul_mem' := fun _ _ \u27e8hx, hx'\u27e9 \u27e8hy, hy'\u27e9 => \u27e8S\u2081.mul_mem hx hy, S\u2082.mul_mem hx' hy'\u27e9 }\u27e9\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem coe_inf (p p' : Submonoid M) : ((p \u2293 p' : Submonoid M) : Set M) = p \u2229 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\u2093'. -/\n@[simp, to_additive]\ntheorem mem_inf {p p' : Submonoid M} {x : M} : x \u2208 p \u2293 p' \u2194 x \u2208 p \u2227 x \u2208 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  \u27e8fun s =>\n    { carrier := \u22c2 t \u2208 s, \u2191t\n      one_mem' := Set.mem_binter\u1d62 fun i h => i.one_mem\n      mul_mem' := fun x y hx hy =>\n        Set.mem_binter\u1d62 fun i h =>\n          i.mul_mem (by apply Set.mem_inter\u1d62\u2082.1 hx i h) (by apply Set.mem_inter\u1d62\u2082.1 hy i h) }\u27e9\n\n/- warning: submonoid.coe_Inf -> Submonoid.coe_inf\u209b 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\u2093.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\u209b.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) S)) (Set.inter\u1d62.{u1, succ u1} M (Submonoid.{u1} M _inst_1) (fun (s : Submonoid.{u1} M _inst_1) => Set.inter\u1d62.{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\u2093.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\u209b.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSetSubmonoid.{u1} M _inst_1) S)) (Set.inter\u1d62.{u1, succ u1} M (Submonoid.{u1} M _inst_1) (fun (s : Submonoid.{u1} M _inst_1) => Set.inter\u1d62.{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\u209b\u2093'. -/\n@[simp, norm_cast, to_additive]\ntheorem coe_inf\u209b (S : Set (Submonoid M)) : ((inf\u209b S : Submonoid M) : Set M) = \u22c2 s \u2208 S, \u2191s :=\n  rfl\n#align submonoid.coe_Inf Submonoid.coe_inf\u209b\n#align add_submonoid.coe_Inf AddSubmonoid.coe_inf\u209b\n\n/- warning: submonoid.mem_Inf -> Submonoid.mem_inf\u209b 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\u209b.{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\u209b.{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\u209b\u2093'. -/\n@[to_additive]\ntheorem mem_inf\u209b {S : Set (Submonoid M)} {x : M} : x \u2208 inf\u209b S \u2194 \u2200 p \u2208 S, x \u2208 p :=\n  Set.mem_inter\u1d62\u2082\n#align submonoid.mem_Inf Submonoid.mem_inf\u209b\n#align add_submonoid.mem_Inf AddSubmonoid.mem_inf\u209b\n\n/- warning: submonoid.mem_infi -> Submonoid.mem_inf\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {\u03b9 : Sort.{u2}} {S : \u03b9 -> (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\u1d62.{u1, u2} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) \u03b9 (fun (i : \u03b9) => S i))) (forall (i : \u03b9), 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] {\u03b9 : Sort.{u2}} {S : \u03b9 -> (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\u1d62.{u1, u2} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSetSubmonoid.{u1} M _inst_1) \u03b9 (fun (i : \u03b9) => S i))) (forall (i : \u03b9), 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\u1d62\u2093'. -/\n@[to_additive]\ntheorem mem_inf\u1d62 {\u03b9 : Sort _} {S : \u03b9 \u2192 Submonoid M} {x : M} : (x \u2208 \u2a05 i, S i) \u2194 \u2200 i, x \u2208 S i := by\n  simp only [inf\u1d62, mem_Inf, Set.forall_range_iff]\n#align submonoid.mem_infi Submonoid.mem_inf\u1d62\n#align add_submonoid.mem_infi AddSubmonoid.mem_inf\u1d62\n\n/- warning: submonoid.coe_infi -> Submonoid.coe_inf\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {\u03b9 : Sort.{u2}} {S : \u03b9 -> (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\u2093.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\u1d62.{u1, u2} (Submonoid.{u1} M _inst_1) (Submonoid.hasInf.{u1} M _inst_1) \u03b9 (fun (i : \u03b9) => S i))) (Set.inter\u1d62.{u1, u2} M \u03b9 (fun (i : \u03b9) => (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\u2093.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] {\u03b9 : Sort.{u2}} {S : \u03b9 -> (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\u1d62.{u1, u2} (Submonoid.{u1} M _inst_1) (Submonoid.instInfSetSubmonoid.{u1} M _inst_1) \u03b9 (fun (i : \u03b9) => S i))) (Set.inter\u1d62.{u1, u2} M \u03b9 (fun (i : \u03b9) => 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\u1d62\u2093'. -/\n@[simp, norm_cast, to_additive]\ntheorem coe_inf\u1d62 {\u03b9 : Sort _} {S : \u03b9 \u2192 Submonoid M} : (\u2191(\u2a05 i, S i) : Set M) = \u22c2 i, S i := by\n  simp only [inf\u1d62, coe_Inf, Set.binter\u1d62_range]\n#align submonoid.coe_infi Submonoid.coe_inf\u1d62\n#align add_submonoid.coe_infi AddSubmonoid.coe_inf\u1d62\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) \u2264 T \u2194 S \u2264 T from SetLike.coe_subset_coe)\n        isGLB_binf\u1d62 with\n    le := (\u00b7 \u2264 \u00b7)\n    lt := (\u00b7 < \u00b7)\n    bot := \u22a5\n    bot_le := fun S x hx => (mem_bot.1 hx).symm \u25b8 S.one_mem\n    top := \u22a4\n    le_top := fun S x hx => mem_top x\n    inf := (\u00b7 \u2293 \u00b7)\n    inf\u209b := InfSet.inf\u209b\n    le_inf := fun a b c ha hb x hx => \u27e8ha hx, hb hx\u27e9\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) \u2194 Subsingleton M :=\n  \u27e8fun h =>\n    \u27e8fun x y =>\n      have : \u2200 i : M, i = 1 := fun i =>\n        mem_bot.mp <| Subsingleton.elim (\u22a4 : Submonoid M) \u22a5 \u25b8 mem_top i\n      (this x).trans (this y).symm\u27e9,\n    fun h =>\n    \u27e8fun x y => Submonoid.ext fun i => Subsingleton.elim 1 i \u25b8 by simp [Submonoid.one_mem]\u27e9\u27e9\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) \u2194 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  \u27e8\u27e8\u22a5\u27e9, fun a => @Subsingleton.elim _ (subsingleton_iff.mpr \u2039_\u203a) a _\u27e9\n\n@[to_additive]\ninstance [Nontrivial M] : Nontrivial (Submonoid M) :=\n  nontrivial_iff.mpr \u2039_\u203a\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\u209b { S | s \u2286 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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem mem_closure {x : M} : x \u2208 closure s \u2194 \u2200 S : Submonoid M, s \u2286 S \u2192 x \u2208 S :=\n  mem_inf\u209b\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\u2093.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\u2093'. -/\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 \u2286 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\u2093'. -/\n@[to_additive]\ntheorem not_mem_of_not_mem_closure {P : M} (hP : P \u2209 closure s) : P \u2209 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\u2093.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\u2093'. -/\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 \u2264 S \u2194 s \u2286 S :=\n  \u27e8Subset.trans subset_closure, fun h => inf\u209b_le h\u27e9\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\u2093'. -/\n/-- Submonoid closure of a set is monotone in its argument: if `s \u2286 t`,\nthen `closure s \u2264 closure t`. -/\n@[to_additive\n      \"Additive submonoid closure of a set is monotone in its argument: if `s \u2286 t`,\\nthen `closure s \u2264 closure t`\"]\ntheorem closure_mono \u2983s t : Set M\u2984 (h : s \u2286 t) : closure s \u2264 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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem closure_eq_of_le (h\u2081 : s \u2286 S) (h\u2082 : S \u2264 closure s) : closure s = S :=\n  le_antisymm (closure_le.2 h\u2081) h\u2082\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\u2093'. -/\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 \u2192 Prop} {x} (h : x \u2208 closure s) (Hs : \u2200 x \u2208 s, p x) (H1 : p 1)\n    (Hmul : \u2200 x y, p x \u2192 p y \u2192 p (x * y)) : p x :=\n  (@closure_le _ _ _ \u27e8p, Hmul, H1\u27e9).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'\u2093'. -/\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 : \u2200 x, x \u2208 closure s \u2192 Prop}\n    (Hs : \u2200 (x) (h : x \u2208 s), p x (subset_closure h)) (H1 : p 1 (one_mem _))\n    (Hmul : \u2200 x hx y hy, p x hx \u2192 p y hy \u2192 p (x * y) (mul_mem hx hy)) {x} (hx : x \u2208 closure s) :\n    p x hx := by\n  refine' Exists.elim _ fun (hx : x \u2208 closure s) (hc : p x hx) => hc\n  exact\n    closure_induction hx (fun x hx => \u27e8_, Hs x hx\u27e9) \u27e8_, H1\u27e9 fun x y \u27e8hx', hx\u27e9 \u27e8hy', hy\u27e9 =>\n      \u27e8_, Hmul _ _ _ _ hx hy\u27e9\n#align submonoid.closure_induction' Submonoid.closure_induction'\n#align add_submonoid.closure_induction' AddSubmonoid.closure_induction'\n\n/- warning: submonoid.closure_induction\u2082 -> Submonoid.closure_induction\u2082 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\u2082 Submonoid.closure_induction\u2082\u2093'. -/\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\u2082 {p : M \u2192 M \u2192 Prop} {x} {y : M} (hx : x \u2208 closure s) (hy : y \u2208 closure s)\n    (Hs : \u2200 x \u2208 s, \u2200 y \u2208 s, p x y) (H1_left : \u2200 x, p 1 x) (H1_right : \u2200 x, p x 1)\n    (Hmul_left : \u2200 x y z, p x z \u2192 p y z \u2192 p (x * y) z)\n    (Hmul_right : \u2200 x y z, p z x \u2192 p z y \u2192 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\u2081 h\u2082 => Hmul_right z _ _ h\u2081 h\u2082)\n    (H1_left y) fun x z h\u2081 h\u2082 => Hmul_left _ _ _ h\u2081 h\u2082\n#align submonoid.closure_induction\u2082 Submonoid.closure_induction\u2082\n#align add_submonoid.closure_induction\u2082 AddSubmonoid.closure_induction\u2082\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\u2093'. -/\n/-- If `s` is a dense set in a monoid `M`, `submonoid.closure s = \u22a4`, then in order to prove that\nsome predicate `p` holds for all `x : M` it suffices to verify `p x` for `x \u2208 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 = \u22a4`, then in order to prove that some predicate `p` holds for all `x : M`\\nit suffices to verify `p x` for `x \u2208 s`, verify `p 0`, and verify that `p x` and `p y` imply\\n`p (x + y)`.\"]\ntheorem dense_induction {p : M \u2192 Prop} (x : M) {s : Set M} (hs : closure s = \u22a4) (Hs : \u2200 x \u2208 s, p x)\n    (H1 : p 1) (Hmul : \u2200 x y, p x \u2192 p y \u2192 p (x * y)) : p x :=\n  by\n  have : \u2200 x \u2208 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\u2093.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\u2093'. -/\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\u2093.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\u2093'. -/\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\u2093'. -/\n@[simp, to_additive]\ntheorem closure_empty : closure (\u2205 : Set M) = \u22a5 :=\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\u2093'. -/\n@[simp, to_additive]\ntheorem closure_univ : closure (univ : Set M) = \u22a4 :=\n  @coe_top M _ \u25b8 closure_eq \u22a4\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\u2093'. -/\n@[to_additive]\ntheorem closure_union (s t : Set M) : closure (s \u222a t) = closure s \u2294 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\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {\u03b9 : Sort.{u2}} (s : \u03b9 -> (Set.{u1} M)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (Set.union\u1d62.{u1, u2} M \u03b9 (fun (i : \u03b9) => s i))) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => Submonoid.closure.{u1} M _inst_1 (s i)))\nbut is expected to have type\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {\u03b9 : Sort.{u2}} (s : \u03b9 -> (Set.{u1} M)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (Submonoid.closure.{u1} M _inst_1 (Set.union\u1d62.{u1, u2} M \u03b9 (fun (i : \u03b9) => s i))) (sup\u1d62.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteLattice.toSupSet.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1)) \u03b9 (fun (i : \u03b9) => Submonoid.closure.{u1} M _inst_1 (s i)))\nCase conversion may be inaccurate. Consider using '#align submonoid.closure_Union Submonoid.closure_union\u1d62\u2093'. -/\n@[to_additive]\ntheorem closure_union\u1d62 {\u03b9} (s : \u03b9 \u2192 Set M) : closure (\u22c3 i, s i) = \u2a06 i, closure (s i) :=\n  (Submonoid.gi M).gc.l_sup\u1d62\n#align submonoid.closure_Union Submonoid.closure_union\u1d62\n#align add_submonoid.closure_Union AddSubmonoid.closure_union\u1d62\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\u2093'. -/\n@[simp, to_additive]\ntheorem closure_singleton_le_iff_mem (m : M) (p : Submonoid M) : closure {m} \u2264 p \u2194 m \u2208 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\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {\u03b9 : Sort.{u2}} (p : \u03b9 -> (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\u1d62.{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))) \u03b9 (fun (i : \u03b9) => p i))) (forall (N : Submonoid.{u1} M _inst_1), (forall (i : \u03b9), 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] {\u03b9 : Sort.{u2}} (p : \u03b9 -> (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\u1d62.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteLattice.toSupSet.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1)) \u03b9 (fun (i : \u03b9) => p i))) (forall (N : Submonoid.{u1} M _inst_1), (forall (i : \u03b9), 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\u1d62\u2093'. -/\n@[to_additive]\ntheorem mem_sup\u1d62 {\u03b9 : Sort _} (p : \u03b9 \u2192 Submonoid M) {m : M} :\n    (m \u2208 \u2a06 i, p i) \u2194 \u2200 N, (\u2200 i, p i \u2264 N) \u2192 m \u2208 N :=\n  by\n  rw [\u2190 closure_singleton_le_iff_mem, le_sup\u1d62_iff]\n  simp only [closure_singleton_le_iff_mem]\n#align submonoid.mem_supr Submonoid.mem_sup\u1d62\n#align add_submonoid.mem_supr AddSubmonoid.mem_sup\u1d62\n\n/- warning: submonoid.supr_eq_closure -> Submonoid.sup\u1d62_eq_closure is a dubious translation:\nlean 3 declaration is\n  forall {M : Type.{u1}} [_inst_1 : MulOneClass.{u1} M] {\u03b9 : Sort.{u2}} (p : \u03b9 -> (Submonoid.{u1} M _inst_1)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => p i)) (Submonoid.closure.{u1} M _inst_1 (Set.union\u1d62.{u1, u2} M \u03b9 (fun (i : \u03b9) => (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\u2093.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] {\u03b9 : Sort.{u2}} (p : \u03b9 -> (Submonoid.{u1} M _inst_1)), Eq.{succ u1} (Submonoid.{u1} M _inst_1) (sup\u1d62.{u1, u2} (Submonoid.{u1} M _inst_1) (CompleteLattice.toSupSet.{u1} (Submonoid.{u1} M _inst_1) (Submonoid.instCompleteLatticeSubmonoid.{u1} M _inst_1)) \u03b9 (fun (i : \u03b9) => p i)) (Submonoid.closure.{u1} M _inst_1 (Set.union\u1d62.{u1, u2} M \u03b9 (fun (i : \u03b9) => 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\u1d62_eq_closure\u2093'. -/\n@[to_additive]\ntheorem sup\u1d62_eq_closure {\u03b9 : Sort _} (p : \u03b9 \u2192 Submonoid M) :\n    (\u2a06 i, p i) = Submonoid.closure (\u22c3 i, (p i : Set M)) := by\n  simp_rw [Submonoid.closure_union\u1d62, Submonoid.closure_eq]\n#align submonoid.supr_eq_closure Submonoid.sup\u1d62_eq_closure\n#align add_submonoid.supr_eq_closure AddSubmonoid.sup\u1d62_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\u2081 : Submonoid.{u1} M _inst_1} {p\u2082 : 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\u2081 p\u2082) (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\u2081) -> (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\u2082) -> (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\u2081 : Submonoid.{u1} M _inst_1} {p\u2082 : 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\u2081 p\u2082) (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\u2081) -> (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\u2082) -> (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\u2093'. -/\n@[to_additive]\ntheorem disjoint_def {p\u2081 p\u2082 : Submonoid M} : Disjoint p\u2081 p\u2082 \u2194 \u2200 {x : M}, x \u2208 p\u2081 \u2192 x \u2208 p\u2082 \u2192 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\u2081 : Submonoid.{u1} M _inst_1} {p\u2082 : 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\u2081 p\u2082) (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\u2081) -> (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\u2082) -> (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\u2081 : Submonoid.{u1} M _inst_1} {p\u2082 : 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\u2081 p\u2082) (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\u2081) -> (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\u2082) -> (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'\u2093'. -/\n@[to_additive]\ntheorem disjoint_def' {p\u2081 p\u2082 : Submonoid M} :\n    Disjoint p\u2081 p\u2082 \u2194 \u2200 {x y : M}, x \u2208 p\u2081 \u2192 y \u2208 p\u2082 \u2192 x = y \u2192 x = 1 :=\n  disjoint_def.trans \u27e8fun h x y hx hy hxy => h hx <| hxy.symm \u25b8 hy, fun h x hx hx' => h hx hx' rfl\u27e9\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 \u2192* 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\u2093'. -/\n@[simp, to_additive]\ntheorem eqLocusM_same (f : M \u2192* N) : f.eqLocus f = \u22a4 :=\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\u2093.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\u2093'. -/\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 \u2192* N} {s : Set M} (h : Set.EqOn f g s) : Set.EqOn f g (closure s) :=\n  show closure s \u2264 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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem eq_of_eqOn_topM {f g : M \u2192* N} (h : Set.EqOn f g (\u22a4 : 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\u2093'. -/\n@[to_additive]\ntheorem eq_of_eqOn_denseM {s : Set M} (hs : closure s = \u22a4) {f g : M \u2192* N} (h : s.EqOn f g) :\n    f = g :=\n  eq_of_eqOn_topM <| hs \u25b8 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\u2093'. -/\n@[to_additive]\ntheorem IsUnit.mem_submonoid_iff {M : Type _} [Monoid M] (a : M) :\n    a \u2208 IsUnit.submonoid M \u2194 IsUnit a :=\n  by\n  change a \u2208 setOf IsUnit \u2194 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\u2093'. -/\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 \u2208 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 \u2208 s`. -/\"]\ndef ofClosureMEqTopLeft {M N} [Monoid M] [Monoid N] {s : Set M} (f : M \u2192 N) (hs : closure s = \u22a4)\n    (h1 : f 1 = 1) (hmul : \u2200 x \u2208 s, \u2200 (y), f (x * y) = f x * f y) : M \u2192* 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 (\u1fb0 : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) \u1fb0) (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\u2093'. -/\n@[simp, norm_cast, to_additive]\ntheorem coe_ofClosureMEqTopLeft (f : M \u2192 N) (hs : closure s = \u22a4) (h1 hmul) :\n    \u21d1(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\u2093'. -/\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 \u2208 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 \u2208 s`. -/\"]\ndef ofClosureMEqTopRight {M N} [Monoid M] [Monoid N] {s : Set M} (f : M \u2192 N) (hs : closure s = \u22a4)\n    (h1 : f 1 = 1) (hmul : \u2200 (x), \u2200 y \u2208 s, f (x * y) = f x * f y) : M \u2192* 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\u2081 y\u2082 h\u2081 h\u2082 x => by simp only [\u2190 mul_assoc, h\u2081, h\u2082]) 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 (\u1fb0 : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) \u1fb0) (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\u2093'. -/\n@[simp, norm_cast, to_additive]\ntheorem coe_ofClosureMEqTopRight (f : M \u2192 N) (hs : closure s = \u22a4) (h1 hmul) :\n    \u21d1(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 {\u03b1 : Type _} [DecidableEq \u03b1]\n\n/-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/\ndef nextOr : \u2200 (_ : List \u03b1) (_ _ : \u03b1), \u03b1\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 : \u03b1) : nextOr [] x d = d :=\n  rfl\n#align list.next_or_nil List.nextOr_nil\n\n@[simp]\ntheorem nextOr_singleton (x y d : \u03b1) : 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 \u03b1) (x y d : \u03b1) : 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 \u03b1) (y x d : \u03b1) (h : x \u2260 y) :\n    nextOr (y :: xs) x d = nextOr xs x d := by\n  cases' xs with z zs\n  \u00b7 rfl\n  \u00b7 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 \u03b1) (x d d' : \u03b1) (x_mem : x \u2208 xs)\n    (x_ne : x \u2260 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  \u00b7 cases x_mem\n  cases' ys with z zs\n  \u00b7 simp at x_mem x_ne\n    contradiction\n  by_cases h : x = y\n  \u00b7 rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons]\n  \u00b7 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 \u03b1} {x d : \u03b1} (h : nextOr xs x d \u2260 d) : x \u2208 xs :=\n  by\n  induction' xs with y ys IH\n  \u00b7 simp at h\n  cases' ys with z zs\n  \u00b7 simp at h\n  \u00b7 by_cases hx : x = y\n    \u00b7 simp [hx]\n    \u00b7 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 \u03b1} {x : \u03b1} (d : \u03b1) (h : x \u2209 xs) : nextOr (xs ++ [x]) x d = d :=\n  by\n  induction' xs with z zs IH\n  \u00b7 simp\n  \u00b7 obtain \u27e8hz, hzs\u27e9 := 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 \u03b1} {x d : \u03b1} (hd : d \u2208 xs) : nextOr xs x d \u2208 xs := by\n  revert hd\n  suffices \u2200 (xs' : List \u03b1) (_ : \u2200 x \u2208 xs, x \u2208 xs') (_ : d \u2208 xs'), nextOr xs x d \u2208 xs' by\n    exact this xs fun _ => id\n  intro xs' hxs' hd\n  induction' xs with y ys ih\n  \u00b7 exact hd\n  cases' ys with z zs\n  \u00b7 exact hd\n  rw [nextOr]\n  split_ifs with h\n  \u00b7 exact hxs' _ (mem_cons_of_mem _ (mem_cons_self _ _))\n  \u00b7 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 : \u03b1` of `l : list \u03b1` such that `x \u2208 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 \u03b1) (x : \u03b1) (h : x \u2208 l) : \u03b1 :=\n  nextOr l x (l.get \u27e80, length_pos_of_mem h\u27e9)\n#align list.next List.next\n\n/-- Given an element `x : \u03b1` of `l : list \u03b1` such that `x \u2208 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 : \u2200 (l : List \u03b1) (x : \u03b1) (_h : x \u2208 l), \u03b1\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 \u03b1) (x : \u03b1)\n\n@[simp]\ntheorem next_singleton (x y : \u03b1) (h : x \u2208 [y]) : next [y] x h = y :=\n  rfl\n#align list.next_singleton List.next_singleton\n\n@[simp]\ntheorem prev_singleton (x y : \u03b1) (h : x \u2208 [y]) : prev [y] x h = y :=\n  rfl\n#align list.prev_singleton List.prev_singleton\n\ntheorem next_cons_cons_eq' (y z : \u03b1) (h : x \u2208 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 : \u03b1) (h : x \u2208 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 \u2208 l) (y : \u03b1) (h : x \u2208 y :: l) (hy : x \u2260 y)\n    (hx : x \u2260 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  \u00b7 rwa [getLast_cons] at hx\n    exact ne_nil_of_mem (by assumption)\n  \u00b7 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 : \u03b1) (hy : x \u2260 y) (hx : x \u2209 l)\n    (h : x \u2208 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  \u00b7 rfl\n  \u00b7 simp [hy, hx]\n#align list.next_cons_concat List.next_cons_concat\n\ntheorem next_getLast_cons (h : x \u2208 l) (y : \u03b1) (h : x \u2208 y :: l) (hy : x \u2260 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, \u2190 dropLast_append_getLast (cons_ne_nil y l), hx, nextOr_concat]\n  subst hx\n  intro H\n  obtain \u27e8\u27e8_ | k, hk\u27e9, hk'\u27e9 := get_of_mem H\n  \u00b7 rw [\u2190 Option.some_inj] at hk'\n    rw [\u2190 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  \u00b7 simp at hk\n  \u00b7 rw [nodup_iff_injective_get] at hl\n    rw [length, Nat.succ_inj']\n    refine' Fin.veq_of_eq (@hl \u27e8k, Nat.lt_of_succ_lt <| by simpa using hk\u27e9 \u27e8tl.length, by simp\u27e9 _)\n    rw [\u2190 Option.some_inj] at hk'\n    rw [\u2190 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 : \u03b1) (hxy : x \u2208 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 \u2208 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 : \u03b1) (h : x \u2208 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 : \u03b1) (h : x \u2208 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 : \u03b1) (h : x \u2208 y :: z :: l) (hy : x \u2260 y) (hz : x = z) :\n    prev (y :: z :: l) x h = y := by\n  cases l\n  \u00b7 simp [prev, hy, hz]\n  \u00b7 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 : \u03b1) (h : x \u2208 y :: x :: l) (hy : x \u2260 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 : \u03b1) (h : x \u2208 y :: z :: l) (hy : x \u2260 y) (hz : x \u2260 z) :\n    prev (y :: z :: l) x h = prev (z :: l) x (by simpa [hy] using h) := by\n  cases l\n  \u00b7 simp [hy, hz] at h\n  \u00b7 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 \u2208 l) : l.next x h \u2208 l :=\n  nextOr_mem (get_mem _ _ _)\n#align list.next_mem List.next_mem\n\ntheorem prev_mem (h : x \u2208 l) : l.prev x h \u2208 l := by\n  cases' l with hd tl\n  \u00b7 simp at h\n  induction' tl with hd' tl hl generalizing hd\n  \u00b7 simp\n  \u00b7 by_cases hx : x = hd\n    \u00b7 simp only [hx, prev_cons_cons_eq]\n      exact mem_cons_of_mem _ (getLast_mem _)\n    \u00b7 rw [prev, dif_neg hx]\n      split_ifs with hm\n      \u00b7 exact mem_cons_self _ _\n      \u00b7 exact mem_cons_of_mem _ (hl _ _)\n#align list.prev_mem List.prev_mem\n\n--Porting note: new theorem\ntheorem next_get : \u2200 (l : List \u03b1) (_h : Nodup l) (i : Fin l.length),\n    next l (l.get i) (get_mem _ _ _) = l.get \u27e8(i + 1) % l.length,\n      Nat.mod_lt _ (i.1.zero_le.trans_lt i.2)\u27e9\n  | [], _, i => by simpa using i.2\n  | [_], _, _ => by simp\n  | x::y::l, _h, \u27e80, h0\u27e9 => by\n    have h\u2081 : get (x :: y :: l) { val := 0, isLt := h0 } = x := by simp\n    rw [next_cons_cons_eq' _ _ _ _ _ h\u2081]\n    simp\n  | x::y::l, hn, \u27e8i+1, hi\u27e9 => by\n    have hx' : (x :: y :: l).get \u27e8i+1, hi\u27e9 \u2260 x := by\n      intro H\n      suffices (i + 1 : \u2115) = 0 by simpa\n      rw [nodup_iff_injective_get] at hn\n      refine' Fin.veq_of_eq (@hn \u27e8i + 1, hi\u27e9 \u27e80, by simp\u27e9 _)\n      simpa using H\n    have hi' : i \u2264 l.length := Nat.le_of_lt_succ (Nat.succ_lt_succ_iff.1 hi)\n    rcases hi'.eq_or_lt with (hi' | hi')\n    \u00b7 subst hi'\n      rw [next_getLast_cons]\n      \u00b7 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), \u2190 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 \u03b1) (h : Nodup l) (n : \u2115) (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 \u27e8n, hn\u27e9\n#align list.next_nth_le List.next_nthLe\n\nset_option linter.deprecated false in\ntheorem prev_nthLe (l : List \u03b1) (h : Nodup l) (n : \u2115) (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  \u00b7 simp at hn\n  induction' l with y l hl generalizing n x\n  \u00b7 simp\n  \u00b7 rcases n with (_ | _ | n)\n    \u00b7 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    \u00b7 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    \u00b7 rw [prev_ne_cons_cons]\n      \u00b7 convert hl n.succ y h.of_cons (Nat.le_of_succ_le_succ hn) using 1\n        have : \u2200 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, \u2190 Nat.add_succ, Nat.add_mod_right, Nat.succ_add, \u2190 Nat.add_succ _ k,\n          Nat.add_mod_right, Nat.mod_eq_of_lt, Nat.mod_eq_of_lt]\n        \u00b7 exact Nat.lt_succ_of_lt hn\n        \u00b7 exact Nat.succ_lt_succ (Nat.lt_succ_of_lt hn)\n      \u00b7 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      \u00b7 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  \u00b7 simp\n  \u00b7 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  \u00b7 simp\n  \u00b7 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 \u03b1) (h : Nodup l) (x : \u03b1) (hx : x \u2208 l) :\n    prev l (next l x hx) (next_mem _ _ _) = x :=\n  by\n  obtain \u27e8n, hn, rfl\u27e9 := nthLe_of_mem hx\n  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]\n  cases' l with hd tl\n  \u00b7 simp at hx\n  \u00b7 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 \u03b1) (h : Nodup l) (x : \u03b1) (hx : x \u2208 l) :\n    next l (prev l x hx) (prev_mem _ _ _) = x :=\n  by\n  obtain \u27e8n, hn, rfl\u27e9 := nthLe_of_mem hx\n  simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]\n  cases' l with hd tl\n  \u00b7 simp at hx\n  \u00b7 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 \u03b1) (h : Nodup l) (x : \u03b1) (hx : x \u2208 l) :\n    prev l.reverse x (mem_reverse'.mpr hx) = next l x hx :=\n  by\n  obtain \u27e8k, hk, rfl\u27e9 := 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 [\u2190 nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]\n  simp_rw [\u2190 nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]\n  rw [\u2190 nthLe_pmap l.reverse.prev fun _ h => h]\n  \u00b7 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 [\u2190 nthLe_reverse]\n    \u00b7 simp [tsub_tsub_cancel_of_le (Nat.le_pred_of_lt hk)]\n    \u00b7 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 \u03b1) (h : Nodup l) (x : \u03b1) (hx : x \u2208 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 \u03b1} (h : l ~r l') (hn : Nodup l) {x : \u03b1} (hx : x \u2208 l) :\n    l.next x hx = l'.next x (h.mem_iff.mp hx) :=\n  by\n  obtain \u27e8k, hk, rfl\u27e9 := nthLe_of_mem hx\n  obtain \u27e8n, rfl\u27e9 := id h\n  rw [next_nthLe _ hn]\n  simp_rw [\u2190 nthLe_rotate' _ n k]\n  rw [next_nthLe _ (h.nodup_iff.mp hn), \u2190 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 \u03b1} (h : l ~r l') (hn : Nodup l) {x : \u03b1} (hx : x \u2208 l) :\n    l.prev x hx = l'.prev x (h.mem_iff.mp hx) :=\n  by\n  rw [\u2190 next_reverse_eq_prev _ hn, \u2190 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 \u03b1` is the quotient of `List \u03b1` by cyclic permutation.\nDuplicates are allowed.\n-/\ndef Cycle (\u03b1 : Type _) : Type _ :=\n  Quotient (IsRotated.setoid \u03b1)\n#align cycle Cycle\n\nnamespace Cycle\n\nvariable {\u03b1 : Type _}\n\n--Porting note: new definition\n/-- The coercion from `List \u03b1` to `Cycle \u03b1` -/\n@[coe] def ofList : List \u03b1 \u2192 Cycle \u03b1 :=\n  Quot.mk _\n\ninstance : Coe (List \u03b1) (Cycle \u03b1) :=\n  \u27e8ofList\u27e9\n\n@[simp]\ntheorem coe_eq_coe {l\u2081 l\u2082 : List \u03b1} : (l\u2081 : Cycle \u03b1) = (l\u2082 : Cycle \u03b1) \u2194 l\u2081 ~r l\u2082 :=\n  @Quotient.eq _ (IsRotated.setoid _) _ _\n#align cycle.coe_eq_coe Cycle.coe_eq_coe\n\n@[simp]\ntheorem mk_eq_coe (l : List \u03b1) : Quot.mk _ l = (l : Cycle \u03b1) :=\n  rfl\n#align cycle.mk_eq_coe Cycle.mk_eq_coe\n\n@[simp]\ntheorem mk''_eq_coe (l : List \u03b1) : Quotient.mk'' l = (l : Cycle \u03b1) :=\n  rfl\n#align cycle.mk'_eq_coe Cycle.mk''_eq_coe\n\ntheorem coe_cons_eq_coe_append (l : List \u03b1) (a : \u03b1) :\n    (\u2191(a :: l) : Cycle \u03b1) = (\u2191(l ++ [a]) : Cycle \u03b1) :=\n  Quot.sound \u27e81, by rw [rotate_cons_succ, rotate_zero]\u27e9\n#align cycle.coe_cons_eq_coe_append Cycle.coe_cons_eq_coe_append\n\n/-- The unique empty cycle. -/\ndef nil : Cycle \u03b1 :=\n  ([] : List \u03b1)\n#align cycle.nil Cycle.nil\n\n@[simp]\ntheorem coe_nil : \u2191([] : List \u03b1) = @nil \u03b1 :=\n  rfl\n#align cycle.coe_nil Cycle.coe_nil\n\n@[simp]\ntheorem coe_eq_nil (l : List \u03b1) : (l : Cycle \u03b1) = nil \u2194 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 \u03b1)`. -/\ninstance : EmptyCollection (Cycle \u03b1) :=\n  \u27e8nil\u27e9\n\n@[simp]\ntheorem empty_eq : \u2205 = @nil \u03b1 :=\n  rfl\n#align cycle.empty_eq Cycle.empty_eq\n\ninstance : Inhabited (Cycle \u03b1) :=\n  \u27e8nil\u27e9\n\n/-- An induction principle for `Cycle`. Use as `induction s using Cycle.induction_on`. -/\n@[elab_as_elim]\ntheorem induction_on {C : Cycle \u03b1 \u2192 Prop} (s : Cycle \u03b1) (H0 : C nil)\n    (HI : \u2200 (a) (l : List \u03b1), C \u2191l \u2192 C \u2191(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 : \u03b1`, `s : Cycle \u03b1`, `x \u2208 s` indicates that `x` occurs at least once in `s`. -/\ndef Mem (a : \u03b1) (s : Cycle \u03b1) : Prop :=\n  Quot.liftOn s (fun l => a \u2208 l) fun _ _ e => propext <| e.mem_iff\n#align cycle.mem Cycle.Mem\n\ninstance : Membership \u03b1 (Cycle \u03b1) :=\n  \u27e8Mem\u27e9\n\n@[simp]\ntheorem mem_coe_iff {a : \u03b1} {l : List \u03b1} : a \u2208 (\u2191l : Cycle \u03b1) \u2194 a \u2208 l :=\n  Iff.rfl\n#align cycle.mem_coe_iff Cycle.mem_coe_iff\n\n@[simp]\ntheorem not_mem_nil : \u2200 a, a \u2209 @nil \u03b1 :=\n  List.not_mem_nil\n#align cycle.not_mem_nil Cycle.not_mem_nil\n\ninstance [DecidableEq \u03b1] : DecidableEq (Cycle \u03b1) := fun s\u2081 s\u2082 =>\n  Quotient.recOnSubsingleton\u2082' s\u2081 s\u2082 fun _ _ => decidable_of_iff' _ Quotient.eq''\n\ninstance [DecidableEq \u03b1] (x : \u03b1) (s : Cycle \u03b1) : Decidable (x \u2208 s) :=\n  Quotient.recOnSubsingleton' s fun l => show Decidable (x \u2208 l) from inferInstance\n\n/-- Reverse a `s : Cycle \u03b1` by reversing the underlying `List`. -/\nnonrec def reverse (s : Cycle \u03b1) : Cycle \u03b1 :=\n  Quot.map reverse (fun _ _ => IsRotated.reverse) s\n#align cycle.reverse Cycle.reverse\n\n@[simp]\ntheorem reverse_coe (l : List \u03b1) : (l : Cycle \u03b1).reverse = l.reverse :=\n  rfl\n#align cycle.reverse_coe Cycle.reverse_coe\n\n@[simp]\ntheorem mem_reverse_iff {a : \u03b1} {s : Cycle \u03b1} : a \u2208 s.reverse \u2194 a \u2208 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 \u03b1) : 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 \u03b1 :=\n  rfl\n#align cycle.reverse_nil Cycle.reverse_nil\n\n/-- The length of the `s : Cycle \u03b1`, which is the number of elements, counting duplicates. -/\ndef length (s : Cycle \u03b1) : \u2115 :=\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 \u03b1) : length (l : Cycle \u03b1) = l.length :=\n  rfl\n#align cycle.length_coe Cycle.length_coe\n\n@[simp]\ntheorem length_nil : length (@nil \u03b1) = 0 :=\n  rfl\n#align cycle.length_nil Cycle.length_nil\n\n@[simp]\ntheorem length_reverse (s : Cycle \u03b1) : 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 \u03b1` that is at most one element. -/\ndef Subsingleton (s : Cycle \u03b1) : Prop :=\n  s.length \u2264 1\n#align cycle.subsingleton Cycle.Subsingleton\n\ntheorem subsingleton_nil : Subsingleton (@nil \u03b1) :=\n  zero_le_one\n#align cycle.subsingleton_nil Cycle.subsingleton_nil\n\ntheorem length_subsingleton_iff {s : Cycle \u03b1} : Subsingleton s \u2194 length s \u2264 1 :=\n  Iff.rfl\n#align cycle.length_subsingleton_iff Cycle.length_subsingleton_iff\n\n@[simp]\ntheorem subsingleton_reverse_iff {s : Cycle \u03b1} : s.reverse.Subsingleton \u2194 s.Subsingleton := by\n  simp [length_subsingleton_iff]\n#align cycle.subsingleton_reverse_iff Cycle.subsingleton_reverse_iff\n\ntheorem Subsingleton.congr {s : Cycle \u03b1} (h : Subsingleton s) :\n    \u2200 \u2983x\u2984 (_hx : x \u2208 s) \u2983y\u2984 (_hy : y \u2208 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 | \u27e8z, rfl\u27e9) <;> simp\n#align cycle.subsingleton.congr Cycle.Subsingleton.congr\n\n/-- A `s : Cycle \u03b1` that is made up of at least two unique elements. -/\ndef Nontrivial (s : Cycle \u03b1) : Prop :=\n  \u2203 (x y : \u03b1)(_h : x \u2260 y), x \u2208 s \u2227 y \u2208 s\n#align cycle.nontrivial Cycle.Nontrivial\n\n@[simp]\ntheorem nontrivial_coe_nodup_iff {l : List \u03b1} (hl : l.Nodup) :\n    Nontrivial (l : Cycle \u03b1) \u2194 2 \u2264 l.length :=\n  by\n  rw [Nontrivial]\n  rcases l with (_ | \u27e8hd, _ | \u27e8hd', tl\u27e9\u27e9)\n  \u00b7 simp\n  \u00b7 simp\n  \u00b7 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' \u27e8hd, hd', _, by simp\u27e9\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 \u03b1} : s.reverse.Nontrivial \u2194 s.Nontrivial := by\n  simp [Nontrivial]\n#align cycle.nontrivial_reverse_iff Cycle.nontrivial_reverse_iff\n\ntheorem length_nontrivial {s : Cycle \u03b1} (h : Nontrivial s) : 2 \u2264 length s := by\n  obtain \u27e8x, y, hxy, hx, hy\u27e9 := h\n  induction' s using Quot.inductionOn with l\n  rcases l with (_ | \u27e8hd, _ | \u27e8hd', tl\u27e9\u27e9)\n  \u00b7 simp at hx\n  \u00b7 simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy\n    simp [hx, hy] at hxy\n  \u00b7 simp [Nat.succ_le_succ_iff]\n#align cycle.length_nontrivial Cycle.length_nontrivial\n\n/-- The `s : Cycle \u03b1` contains no duplicates. -/\nnonrec def Nodup (s : Cycle \u03b1) : Prop :=\n  Quot.liftOn s Nodup fun _l\u2081 _l\u2082 e => propext <| e.nodup_iff\n#align cycle.nodup Cycle.Nodup\n\n@[simp]\nnonrec theorem nodup_nil : Nodup (@nil \u03b1) :=\n  nodup_nil\n#align cycle.nodup_nil Cycle.nodup_nil\n\n@[simp]\ntheorem nodup_coe_iff {l : List \u03b1} : Nodup (l : Cycle \u03b1) \u2194 l.Nodup :=\n  Iff.rfl\n#align cycle.nodup_coe_iff Cycle.nodup_coe_iff\n\n@[simp]\ntheorem nodup_reverse_iff {s : Cycle \u03b1} : s.reverse.Nodup \u2194 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 \u03b1} (h : Subsingleton s) : Nodup s :=\n  by\n  induction' s using Quot.inductionOn with l\n  cases' l with hd tl\n  \u00b7 simp\n  \u00b7 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 \u03b1} (h : Nodup s) : Nontrivial s \u2194 \u00acSubsingleton 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 \u03b1` as a `Multiset \u03b1`.\n-/\ndef toMultiset (s : Cycle \u03b1) : Multiset \u03b1 :=\n  Quotient.liftOn' s (\u2191) fun _ _  h => Multiset.coe_eq_coe.mpr h.perm\n#align cycle.to_multiset Cycle.toMultiset\n\n@[simp]\ntheorem coe_toMultiset (l : List \u03b1) : (l : Cycle \u03b1).toMultiset = l :=\n  rfl\n#align cycle.coe_to_multiset Cycle.coe_toMultiset\n\n@[simp]\ntheorem nil_toMultiset : nil.toMultiset = (0 : Multiset \u03b1) :=\n  rfl\n#align cycle.nil_to_multiset Cycle.nil_toMultiset\n\n@[simp]\ntheorem card_toMultiset (s : Cycle \u03b1) : 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 \u03b1} : s.toMultiset = 0 \u2194 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 {\u03b2 : Type _} (f : \u03b1 \u2192 \u03b2) : Cycle \u03b1 \u2192 Cycle \u03b2 :=\n  Quotient.map' (List.map f) fun _ _ h => h.map _\n#align cycle.map Cycle.map\n\n@[simp]\ntheorem map_nil {\u03b2 : Type _} (f : \u03b1 \u2192 \u03b2) : map f nil = nil :=\n  rfl\n#align cycle.map_nil Cycle.map_nil\n\n@[simp]\ntheorem map_coe {\u03b2 : Type _} (f : \u03b1 \u2192 \u03b2) (l : List \u03b1) : map f \u2191l = List.map f l :=\n  rfl\n#align cycle.map_coe Cycle.map_coe\n\n@[simp]\ntheorem map_eq_nil {\u03b2 : Type _} (f : \u03b1 \u2192 \u03b2) (s : Cycle \u03b1) : map f s = nil \u2194 s = nil :=\n  Quotient.inductionOn' s (by simp)\n#align cycle.map_eq_nil Cycle.map_eq_nil\n\n@[simp]\ntheorem mem_map {\u03b2 : Type _} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : Cycle \u03b1} :\n    b \u2208 s.map f \u2194 \u2203 a, a \u2208 s \u2227 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 \u03b1) : Multiset (List \u03b1) :=\n  Quotient.liftOn' s (fun l => (l.cyclicPermutations : Multiset (List \u03b1))) fun l\u2081 l\u2082 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 \u03b1} {l : List \u03b1} : l \u2208 s.lists \u2194 (l : Cycle \u03b1) = 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 \u03b1) = [([] : List \u03b1)] := by\n  rw [nil, lists_coe, cyclicPermutations_nil]\n#align cycle.lists_nil Cycle.lists_nil\n\nsection Decidable\n\nvariable [DecidableEq \u03b1]\n\n/-- Auxiliary decidability algorithm for lists that contain at least two unique elements.\n-/\ndef decidableNontrivialCoe : \u2200 l : List \u03b1, Decidable (Nontrivial (l : Cycle \u03b1))\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 \u03b1)) (by simp [h, Nontrivial])\n        (decidableNontrivialCoe (x :: l))\n    else isTrue \u27e8x, y, h, by simp, by simp\u27e9\n#align cycle.decidable_nontrivial_coe Cycle.decidableNontrivialCoe\n\ninstance {s : Cycle \u03b1} : Decidable (Nontrivial s) :=\n  Quot.recOnSubsingleton' s decidableNontrivialCoe\n\ninstance {s : Cycle \u03b1} : Decidable (Nodup s) :=\n  Quot.recOnSubsingleton' s List.nodupDecidable\n\ninstance fintypeNodupCycle [Fintype \u03b1] : Fintype { s : Cycle \u03b1 // s.Nodup } :=\n  Fintype.ofSurjective (fun l : { l : List \u03b1 // l.Nodup } => \u27e8l.val, by simpa using l.prop\u27e9)\n    fun \u27e8s, hs\u27e9 => by\n    induction' s using Quotient.inductionOn' with s hs\n    exact \u27e8\u27e8s, hs\u27e9, by simp\u27e9\n#align cycle.fintype_nodup_cycle Cycle.fintypeNodupCycle\n\ninstance fintypeNodupNontrivialCycle [Fintype \u03b1] :\n    Fintype { s : Cycle \u03b1 // s.Nodup \u2227 s.Nontrivial } :=\n  Fintype.subtype\n    (((Finset.univ : Finset { s : Cycle \u03b1 // 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 \u03b1` as a `Finset \u03b1`. -/\ndef toFinset (s : Cycle \u03b1) : Finset \u03b1 :=\n  s.toMultiset.toFinset\n#align cycle.to_finset Cycle.toFinset\n\n@[simp]\ntheorem toFinset_toMultiset (s : Cycle \u03b1) : 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 \u03b1) : (l : Cycle \u03b1).toFinset = l.toFinset :=\n  rfl\n#align cycle.coe_to_finset Cycle.coe_toFinset\n\n@[simp]\ntheorem nil_toFinset : (@nil \u03b1).toFinset = \u2205 :=\n  rfl\n#align cycle.nil_to_finset Cycle.nil_toFinset\n\n@[simp]\ntheorem toFinset_eq_nil {s : Cycle \u03b1} : s.toFinset = \u2205 \u2194 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 \u03b1` such that `Nodup s`, retrieve the next element after `x \u2208 s`. -/\nnonrec def next : \u2200 (s : Cycle \u03b1) (_hs : Nodup s) (x : \u03b1) (_hx : x \u2208 s), \u03b1 := fun s =>\n  Quot.hrecOn (motive := fun (s : Cycle \u03b1) => \u2200 (_hs : Cycle.Nodup s) (x : \u03b1) (_hx : x \u2208 s), \u03b1) s\n  (fun l _hn x hx => next l x hx) fun l\u2081 l\u2082 h =>\n    Function.hfunext (propext h.nodup_iff) fun h\u2081 h\u2082 _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\u2081 _)\n#align cycle.next Cycle.next\n\n/-- Given a `s : Cycle \u03b1` such that `Nodup s`, retrieve the previous element before `x \u2208 s`. -/\nnonrec def prev : \u2200 (s : Cycle \u03b1) (_hs : Nodup s) (x : \u03b1) (_hx : x \u2208 s), \u03b1 := fun s =>\n  Quot.hrecOn (motive := fun (s : Cycle \u03b1) => \u2200 (_hs : Cycle.Nodup s) (x : \u03b1) (_hx : x \u2208 s), \u03b1) s\n  (fun l _hn x hx => prev l x hx) fun l\u2081 l\u2082 h =>\n    Function.hfunext (propext h.nodup_iff) fun h\u2081 h\u2082 _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\u2081 _)\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 \u03b1) : \u2200 (hs : Nodup s) (x : \u03b1) (hx : x \u2208 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 \u03b1) (hs : Nodup s.reverse) (x : \u03b1)\n    (hx : x \u2208 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 \u03b1) (hs : Nodup s) (x : \u03b1) (hx : x \u2208 s) :\n    s.reverse.next (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.prev hs x hx := by\n  simp [\u2190 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 \u03b1) (hs : Nodup s.reverse) (x : \u03b1) (hx : x \u2208 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 [\u2190 prev_reverse_eq_next]\n\n@[simp]\nnonrec theorem next_mem (s : Cycle \u03b1) (hs : Nodup s) (x : \u03b1) (hx : x \u2208 s) : s.next hs x hx \u2208 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 \u03b1) (hs : Nodup s) (x : \u03b1) (hx : x \u2208 s) : s.prev hs x hx \u2208 s :=\n  by\n  rw [\u2190 next_reverse_eq_prev, \u2190 mem_reverse_iff]\n  apply next_mem\n#align cycle.prev_mem Cycle.prev_mem\n\n@[simp]\nnonrec theorem prev_next (s : Cycle \u03b1) : \u2200 (hs : Nodup s) (x : \u03b1) (hx : x \u2208 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 \u03b1) : \u2200 (hs : Nodup s) (x : \u03b1) (hx : x \u2208 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 \u03b1] : Repr (Cycle \u03b1) :=\n  \u27e8fun s _ => \"c[\" ++ Std.Format.joinSep (s.map repr).lists.unquot.head! \", \" ++ \"]\"\u27e9\n\n/-- `chain R s` means that `R` holds between adjacent elements of `s`.\n\n`chain R ([a, b, c] : Cycle \u03b1) \u2194 R a b \u2227 R b c \u2227 R c a` -/\nnonrec def Chain (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (c : Cycle \u03b1) : 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      \u00b7 rfl\n      \u00b7 have := isRotated_nil_iff'.1 hab\n        contradiction\n      \u00b7 have := isRotated_nil_iff.1 hab\n        contradiction\n      \u00b7 dsimp only\n        cases' hab with n hn\n        induction' n with d hd generalizing a b l m\n        \u00b7 simp only [Nat.zero_eq, rotate_zero, cons.injEq] at hn\n          rw [hn.1, hn.2]\n        \u00b7 cases' l with c s\n          \u00b7 simp only [rotate_cons_succ, nil_append, rotate_singleton, cons.injEq] at hn\n            rw [hn.1, hn.2]\n          \u00b7 rw [Nat.succ_eq_one_add, \u2190 rotate_rotate, rotate_cons_succ, rotate_zero,\n              cons_append] at hn\n            rw [\u2190 hd c _ _ _ hn]\n            simp [and_comm]\n#align cycle.chain Cycle.Chain\n\n@[simp]\ntheorem Chain.nil (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Cycle.Chain r (@nil \u03b1) := by trivial\n#align cycle.chain.nil Cycle.Chain.nil\n\n@[simp]\ntheorem chain_coe_cons (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) (l : List \u03b1) :\n    Chain r (a :: l) \u2194 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : Chain r [a] \u2194 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) {l : List \u03b1} :\n    \u2200 hl : l \u2260 [], Chain r l \u2194 List.Chain r (getLast l hl) l :=\n  l.reverseRecOn (fun hm => hm.irrefl.elim) (by\n    intro m a _H _\n    rw [\u2190 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 {\u03b2 : Type _} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (f : \u03b2 \u2192 \u03b1) {s : Cycle \u03b2} :\n    Chain r (s.map f) \u2194 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, \u2190 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 [\u2190 concat_eq_append, \u2190 List.map_concat, List.chain_map f]\n    simp\n#align cycle.chain_map Cycle.chain_map\n\nnonrec theorem chain_range_succ (r : \u2115 \u2192 \u2115 \u2192 Prop) (n : \u2115) :\n    Chain r (List.range n.succ) \u2194 r n 0 \u2227 \u2200 m < n, r m m.succ := by\n  rw [range_succ, \u2190 coe_cons_eq_coe_append, chain_coe_cons, \u2190 range_succ, chain_range_succ]\n#align cycle.chain_range_succ Cycle.chain_range_succ\n\nvariable {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : Cycle \u03b1}\n\ntheorem chain_of_pairwise : (\u2200 a \u2208 s, \u2200 b \u2208 s, r a b) \u2192 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 \u2208 (a :: l : Cycle \u03b1) := by simp\n  have Hl : \u2200 {b} (_hb : b \u2208 l), b \u2208 (a :: l : Cycle \u03b1) := @fun b hb => by simp [hb]\n  rw [Cycle.chain_coe_cons]\n  apply Pairwise.chain\n  rw [pairwise_cons]\n  refine'\n    \u27e8fun b hb => _,\n      pairwise_append.2\n        \u27e8pairwise_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 => _\u27e9\u27e9\n  \u00b7 rw [mem_append] at hb\n    cases' hb with hb hb\n    \u00b7 exact hs a Ha b (Hl hb)\n    \u00b7 rw [mem_singleton] at hb\n      rw [hb]\n      exact hs a Ha a Ha\n  \u00b7 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 \u03b1 r] : Chain r s \u2194 \u2200 a \u2208 s, \u2200 b \u2208 s, r a b :=\n  \u27e8by\n    induction' s using Cycle.induction_on with a l _\n    \u00b7 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    \u00b7 exact hs.1 c (Or.inr rfl)\n    \u00b7 exact hs.1 c (Or.inl hc)\n    \u00b7 exact hs.2.2 b hb\n    \u00b7 exact _root_.trans (hs.2.2 b hb) (hs.1 c (Or.inl hc)), Cycle.chain_of_pairwise\u27e9\n#align cycle.chain_iff_pairwise Cycle.chain_iff_pairwise\n\ntheorem forall_eq_of_chain [IsTrans \u03b1 r] [IsAntisymm \u03b1 r] (hs : Chain r s) {a b : \u03b1} (ha : a \u2208 s)\n    (hb : b \u2208 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 (\u03b1 : Type u) where\n    add : \u03b1 \u2192 \u03b1 \u2192 \u03b1 \n\n  def double (s : Add1 \u03b1) (x : \u03b1) :=\n    s.add x x\n\n  #eval double {add := Nat.add} 10 -- 20\n\n  class Add (\u03b1 : Type u) where\n    add : \u03b1 \u2192 \u03b1 \u2192 \u03b1 \n\n  instance : Add Nat where\n    add := Nat.add\n\n  instance [Add \u03b1] : Add (Array \u03b1) 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 (\u03b1 : Type u) where \n      default : \u03b1 \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 \u03b1] [Inhabited \u03b2] : Inhabited (\u03b1 \u00d7 \u03b2) where \n    default := (default, default)\n\n  #eval (default : Nat \u00d7 Bool) -- (0, false)\n\n  instance [Inhabited \u03b2] : Inhabited (\u03b1 \u2192 \u03b2) where \n    default := fun _ => default \n\n  instance [Inhabited \u03b1] : Inhabited (List \u03b1) where \n    default := [default]\n\n  #eval (default : List Nat) -- [0]\n\n  instance [Inhabited \u03b1] : Inhabited (Sum \u03b1 \u03b2) 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 \u2260 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 (\u03b1 : Type u) where \n    unit : \u03b1 \n    op : \u03b1 \u2192 \u03b1 \u2192 \u03b1 \n\n  instance [s : Monoid \u03b1] : OfNat \u03b1 (nat_lit 1) where \n    ofNat := s.unit\n\n  def getUnit [Monoid \u03b1] : \u03b1 :=\n    1 \n\nend num \n\n\n/- Output Parameters -/\n\nnamespace op  \n\n  class HMul (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where \n    hMul : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \n\n  export HMul (hMul)\n\n  instance : HMul Nat Nat Nat where \n    hMul := Nat.mul\n\n  instance [HMul \u03b1 \u03b2 \u03b3]: HMul \u03b1 (Array \u03b2) (Array \u03b3) 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 (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where \n    hMul : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \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 \u2192 List Int \n\n  class Mul (\u03b1 : Type u) where \n    mul : \u03b1 \u2192 \u03b1 \u2192 \u03b1 \n\n  @[defaultInstance 10]\n  instance [Mul \u03b1] : HMul \u03b1 \u03b1 \u03b1  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 : \u00ac p) : Decidable p\n  | isTrue (h : p) : Decidable p \n\n  def ite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t e : \u03b1) : \u03b1 :=\n    match h with \n    | Decidable.isTrue _  => t\n    | Decidable.isFalse _ => e \n\n  def dite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t : c \u2192 \u03b1) (e : \u00ac c \u2192 \u03b1) : \u03b1 :=\n    match h with \n    | Decidable.isTrue c => t c\n    | Decidable.isFalse nc => e nc \n\n  example : \u00ac (True \u2227 False) := by decide \n\nend dp \n\n/- Managing Type Class Inference -/\n\nnamespace mtci \n\n  def foo : Inhabited (Nat \u2192 Nat) := inferInstance\n\n  def Set (\u03b1 : Type u) := \u03b1 \u2192 Prop \n\n  example : Inhabited (Set \u03b1) := \n    inferInstanceAs (Inhabited (\u03b1 \u2192 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 (\u03b1 : Type u) := \u03b1 \u2192 Prop \n  def Set.empty {\u03b1 : Type u} : Set \u03b1 := fun _ => False \n  def Set.mem (a : \u03b1) (s : Set \u03b1) : Prop := s a \n  def Set.singleton (a : \u03b1) : Set \u03b1 := fun x => x = a \n  def Set.union (a b : Set \u03b1) : Set \u03b1 := fun x => a x \u2228 b x \n  notation \"{\" a \"}\" => Set.singleton a \n  infix:55 \" \u222a \" => Set.union\n\n\n  def List.toSet : List \u03b1 \u2192 Set \u03b1\n    | []    => Set.empty\n    | a::as => {a} \u222a toSet as \n\n  instance : Coe (List \u03b1) (Set \u03b1) where \n    coe as := List.toSet as \n\n  /-\n  {1} \u222a List.toSet [1, 2] : Set Nat\n  -/\n  #check {1} \u222a \u2191[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 \u2192 carrier \u2192 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 \u2192 S2 \n    resp_mul : \u2200 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 \u2192 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 : \u2115) : \u2124 \u2192 \u2115 \u00d7 \u2115\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 : \u2115)\n  precPos : 0 < prec\n  precMax : prec \u2264 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 : \u2124 :=\n  1 - C.emax\n#align fp.emin FP.emin\n\n@[nolint docBlame]\ndef ValidFinite (e : \u2124) (m : \u2115) : Prop :=\n  emin \u2264 e + prec - 1 \u2227 e + prec - 1 \u2264 emax \u2227 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 \u2192 Float\n  | nan : Float\n  | finite : Bool \u2192 \u2200 e m, ValidFinite e m \u2192 Float\n#align fp.float FP.Float\n\n@[nolint docBlame]\ndef Float.isFinite : Float \u2192 Bool\n  | Float.finite _ _ _ _ => true\n  | _ => false\n#align fp.float.is_finite FP.Float.isFinite\n\n@[nolint docBlame]\ndef toRat : \u2200 f : Float, f.isFinite \u2192 \u211a\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  \u27e8by\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 \u2264 2 * emax by\n      rw [\u2190 Int.ofNat_le] at this\n      rw [\u2190 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])\u27e9\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  \u27e8Float.zero true\u27e9\n\n@[nolint docBlame]\nprotected def Float.sign' : Float \u2192 Semiquot Bool\n  | Float.inf s => pure s\n  | Float.nan => \u22a4\n  | Float.finite s _ _ _ => pure s\n#align fp.float.sign' FP.Float.sign'\n\n@[nolint docBlame]\nprotected def Float.sign : Float \u2192 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 \u2192 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 \u2192 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 : \u2115) : \u2124 \u2192 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\u2093 -- 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 : \u2115+) (d : \u2115+) : Float \u00d7 Bool := by\n  let e\u2081 : \u2124 := n.1.size - d.1.size - prec\n  cases' h\u2081 : Int.shift2 d.1 n.1 (e\u2081 + prec) with d\u2081 n\u2081\n  let e\u2082 := if n\u2081 < d\u2081 then e\u2081 - 1 else e\u2081\n  let e\u2083 := max e\u2082 emin\n  cases' h\u2082 : Int.shift2 d.1 n.1 (e\u2083 + prec) with d\u2082 n\u2082\n  let r := mkRat n\u2082 d\u2082\n  let m := r.floor\n  refine' (Float.finite Bool.false e\u2083 (Int.toNat m) _, r.den = 1)\n  \u00b7 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 \u2192 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 \u2192 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 : \u211a \u2192 Float\n  | \u27e80, _, _, _\u27e9 => Float.zero false\n  | \u27e8Nat.succ n, d, h, _\u27e9 =>\n    let (f, exact) := ofPosRatDn n.succPNat \u27e8d, Nat.pos_of_ne_zero h\u27e9\n    if exact then f else nextUp f\n  | \u27e8Int.negSucc n, d, h, _\u27e9 => Float.neg (ofPosRatDn n.succPNat \u27e8d, Nat.pos_of_ne_zero h\u27e9).1\n#align fp.of_rat_up FP.ofRatUp\n\n@[nolint docBlame]\nunsafe def ofRatDn (r : \u211a) : Float :=\n  Float.neg <| ofRatUp (-r)\n#align fp.of_rat_dn FP.ofRatDn\n\n@[nolint docBlame]\nunsafe def ofRat : RMode \u2192 \u211a \u2192 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 \u2223 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  \u27e8Float.neg\u27e9\n\n@[nolint docBlame]\nunsafe def add (mode : RMode) : Float \u2192 Float \u2192 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\u2081, _ => inf s\u2081\n  | _, inf s\u2082 => inf s\u2082\n  | finite s\u2081 e\u2081 m\u2081 v\u2081, finite s\u2082 e\u2082 m\u2082 v\u2082 =>\n    let f\u2081 := finite s\u2081 e\u2081 m\u2081 v\u2081\n    let f\u2082 := finite s\u2082 e\u2082 m\u2082 v\u2082\n    ofRat mode (toRat f\u2081 rfl + toRat f\u2082 rfl)\n#align fp.float.add FP.Float.add\n\nunsafe instance : Add Float :=\n  \u27e8Float.add RMode.NE\u27e9\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  \u27e8Float.sub RMode.NE\u27e9\n\n@[nolint docBlame]\nunsafe def mul (mode : RMode) : Float \u2192 Float \u2192 Float\n  | nan, _ => nan\n  | _, nan => nan\n  | inf s\u2081, f\u2082 => if f\u2082.isZero then nan else inf (xor s\u2081 f\u2082.sign)\n  | f\u2081, inf s\u2082 => if f\u2081.isZero then nan else inf (xor f\u2081.sign s\u2082)\n  | finite s\u2081 e\u2081 m\u2081 v\u2081, finite s\u2082 e\u2082 m\u2082 v\u2082 =>\n    let f\u2081 := finite s\u2081 e\u2081 m\u2081 v\u2081\n    let f\u2082 := finite s\u2082 e\u2082 m\u2082 v\u2082\n    ofRat mode (toRat f\u2081 rfl * toRat f\u2082 rfl)\n#align fp.float.mul FP.Float.mul\n\n@[nolint docBlame]\nunsafe def div (mode : RMode) : Float \u2192 Float \u2192 Float\n  | nan, _ => nan\n  | _, nan => nan\n  | inf _, inf _ => nan\n  | inf s\u2081, f\u2082 => inf (xor s\u2081 f\u2082.sign)\n  | f\u2081, inf s\u2082 => zero (xor f\u2081.sign s\u2082)\n  | finite s\u2081 e\u2081 m\u2081 v\u2081, finite s\u2082 e\u2082 m\u2082 v\u2082 =>\n    let f\u2081 := finite s\u2081 e\u2081 m\u2081 v\u2081\n    let f\u2082 := finite s\u2082 e\u2082 m\u2082 v\u2082\n    if f\u2082.isZero then inf (xor s\u2081 s\u2082) else ofRat mode (toRat f\u2081 rfl / toRat f\u2082 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 (\u03b1 : Type u) := \u03b1 \u2192 Prop\n\ndef setOf {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) : Set \u03b1 :=\np\n\nnamespace Set\n\nprotected def mem (a : \u03b1) (s : Set \u03b1) :=\ns a\n\ninstance : Membership \u03b1 (Set \u03b1) :=\n\u27e8Set.mem\u27e9\n\ntheorem ext {a b : Set \u03b1} (h : \u2200 (x : \u03b1), x \u2208 a \u2194 x \u2208 b) : a = b :=\nfunext (fun x => propext (h x))\n\nprotected def subset (s\u2081 s\u2082 : Set \u03b1) :=\n\u2200 {a}, a \u2208 s\u2081 \u2192 a \u2208 s\u2082\n\nclass Subset (\u03b1 : Type u) where\n  /-- Subset relation: `a \u2286 b`  -/\n  subset : \u03b1 \u2192 \u03b1 \u2192 Prop\n\n/-- Subset relation: `a \u2286 b`  -/\ninfix:50 \" \u2286 \" => Subset.subset\n\ninstance : Subset (Set \u03b1) :=\n\u27e8Set.subset\u27e9\n\ninstance : EmptyCollection (Set \u03b1) :=\n\u27e8\u03bb _ => False\u27e9\n\nexample (U : Type) (A B : Set U) : A \u2286 B \u2192 A = A :=\n  fun h =>\n  match @h with | (h : A \u2286 B) => sorry\n\nexample (U : Type) (A B : Set U) : A \u2286 B \u2192 A = A := by\n  intro (h : A \u2286 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 \u2194 A := by rfl\n\ntheorem s (A B : Prop) (h : A \u2194 B) : B \u2194 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\u00f6lzl, 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 \u2022 x : M` is defined, and\n  the operation `\u2022` 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\u2082`, `M \u2192\u2097[R] M\u2082` : 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 \u2022 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 : \u2200 (r s : R) (x : M), (r + s) \u2022 x = r \u2022 x + s \u2022 x\n  zero_smul : \u2200 (x : M), 0 \u2022 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) \u2022 x = r \u2022 x + s \u2022 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 \u2022 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 \u2022 x = x + x :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (bit0 1 \u2022 x = x + x)) (bit0.equations._eqn_1 1)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((1 + 1) \u2022 x = x + x)) (add_smul 1 1 x)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (1 \u2022 x + 1 \u2022 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 \u2022 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\u2082 : Type x} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid M\u2082] [has_scalar R M\u2082] (f : M\u2082 \u2192+ M)\n    (hf : function.injective \u21d1f) (smul : \u2200 (c : R) (x : M\u2082), coe_fn f (c \u2022 x) = c \u2022 coe_fn f x) :\n    semimodule R M\u2082 :=\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\u2082 : Type x} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid M\u2082] [has_scalar R M\u2082] (f : M \u2192+ M\u2082)\n    (hf : function.surjective \u21d1f) (smul : \u2200 (c : R) (x : M), coe_fn f (c \u2022 x) = c \u2022 coe_fn f x) :\n    semimodule R M\u2082 :=\n  semimodule.mk sorry sorry\n\n/-- `(\u2022)` 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 \u2192+ M \u2192+ 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 \u2022 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 \u2022 x = 0)) (Eq.symm zero_eq_one)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (0 \u2022 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 \u2022 x = list.sum (list.map (fun (r : R) => r \u2022 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 \u2022 x = multiset.sum (multiset.map (fun (r : R) => r \u2022 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} {\u03b9 : Type z} [semiring R] [add_comm_monoid M]\n    [semimodule R M] {f : \u03b9 \u2192 R} {s : finset \u03b9} {x : M} :\n    (finset.sum s fun (i : \u03b9) => f i) \u2022 x = finset.sum s fun (i : \u03b9) => f i \u2022 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 \u2022 a)\n    (add_group.sub._default add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry\n      fun (a : M) => -1 \u2022 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 : \u2200 (r : R) (x y : M), r \u2022 (x + y) = r \u2022 x + r \u2022 y\n  add_smul : \u2200 (r s : R) (x : M), (r + s) \u2022 x = r \u2022 x + s \u2022 x\n  mul_smul : \u2200 (r s : R) (x : M), (r * s) \u2022 x = r \u2022 s \u2022 x\n  one_smul : \u2200 (x : M), 1 \u2022 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 `\u2124^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 \u2115 M` and `module \u2124 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 : \u2200 (r : R) (m : M), r \u2022 m = r \u2022 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 \u2022 x = -(r \u2022 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 \u2022 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) \u2022 y = r \u2022 y - s \u2022 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 \u2022 x = 0 \u2194 c = 0 \u2228 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 \u2022 a' = a * a' := rfl\n\n/-- A ring homomorphism `f : R \u2192+* M` defines a module structure by `r \u2022 x = f r * x`. -/\ndef ring_hom.to_semimodule {R : Type u} {S : Type v} [semiring R] [semiring S] (f : R \u2192+* 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 `\u211d^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 \u2115-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 \u2022 x` when `n : \u2115`.\n\ninstance add_comm_monoid.nat_semimodule {M : Type w} [add_comm_monoid M] : semimodule \u2115 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 : \u2115) (x : M) : n \u2022\u2115 x = n \u2022 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 : \u2115) (b : M) : n \u2022\u2115 b = \u2191n \u2022 b :=\n  sorry\n\n/-- `nsmul` is equal to any `\u2115`-semimodule structure. -/\ntheorem nsmul_eq_smul {M : Type w} [add_comm_monoid M] [semimodule \u2115 M] (n : \u2115) (b : M) :\n    n \u2022\u2115 b = n \u2022 b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022\u2115 b = n \u2022 b)) (nsmul_eq_smul_cast \u2115 n b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n \u2022 b = n \u2022 b)) (nat.cast_id n))) (Eq.refl (n \u2022 b)))\n\n/-- All `\u2115`-semimodule structures are equal. -/\nprotected instance add_comm_monoid.nat_semimodule.subsingleton {M : Type w} [add_comm_monoid M] :\n    subsingleton (semimodule \u2115 M) :=\n  subsingleton.intro\n    fun (P Q : semimodule \u2115 M) =>\n      semimodule_ext P Q\n        fun (n : \u2115) (m : M) =>\n          eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022 m = n \u2022 m)) (Eq.symm (nsmul_eq_smul n m))))\n            (eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022\u2115 m = n \u2022 m)) (Eq.symm (nsmul_eq_smul n m))))\n              (Eq.refl (n \u2022\u2115 m)))\n\n/-- Note this does not depend on the `nat_semimodule` definition above, to avoid issues when\ndiamonds occur in finding `semimodule \u2115 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 \u2115 R] [semimodule \u2115 M] :\n    is_scalar_tower \u2115 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 \u2115 M] : smul_comm_class \u2115 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 \u2115 M] : smul_comm_class R \u2115 M :=\n  smul_comm_class.symm \u2115 R M\n\n/-- The natural \u2124-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 \u2022 x` when `n : \u2124`.\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 \u2124 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 : \u2124) (x : M) : n \u2022\u2124 x = n \u2022 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 : \u2124) (b : M) : n \u2022\u2124 b = \u2191n \u2022 b :=\n  sorry\n\n/-- `gsmul` is equal to any `\u2124`-module structure. -/\ntheorem gsmul_eq_smul {M : Type w} [add_comm_group M] [semimodule \u2124 M] (n : \u2124) (b : M) :\n    n \u2022\u2124 b = n \u2022 b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022\u2124 b = n \u2022 b)) (gsmul_eq_smul_cast \u2124 n b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n \u2022 b = n \u2022 b)) (int.cast_id n))) (Eq.refl (n \u2022 b)))\n\n/-- All `\u2124`-module structures are equal. -/\nprotected instance add_comm_group.int_module.subsingleton {M : Type w} [add_comm_group M] :\n    subsingleton (semimodule \u2124 M) :=\n  subsingleton.intro\n    fun (P Q : semimodule \u2124 M) =>\n      semimodule_ext P Q\n        fun (n : \u2124) (m : M) =>\n          eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022 m = n \u2022 m)) (Eq.symm (gsmul_eq_smul n m))))\n            (eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022\u2124 m = n \u2022 m)) (Eq.symm (gsmul_eq_smul n m))))\n              (Eq.refl (n \u2022\u2124 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 \u2124 R] [semimodule \u2124 M] : is_scalar_tower \u2124 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 \u2124 M] : smul_comm_class \u2124 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 \u2124 M] : smul_comm_class S \u2124 M :=\n  smul_comm_class.symm \u2124 S M\n\nnamespace add_monoid_hom\n\n\n-- We prove this without using the `add_comm_group.int_module` instance, so the `\u2022`s here\n\n-- come from whatever the local `module \u2124` structure actually is.\n\ntheorem map_int_module_smul {M : Type w} {M\u2082 : Type x} [add_comm_group M] [add_comm_group M\u2082]\n    [module \u2124 M] [module \u2124 M\u2082] (f : M \u2192+ M\u2082) (x : \u2124) (a : M) : coe_fn f (x \u2022 a) = x \u2022 coe_fn f a :=\n  sorry\n\ntheorem map_int_cast_smul {R : Type u} {M : Type w} {M\u2082 : Type x} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [module R M] [module R M\u2082] (f : M \u2192+ M\u2082) (x : \u2124) (a : M) :\n    coe_fn f (\u2191x \u2022 a) = \u2191x \u2022 coe_fn f a :=\n  sorry\n\ntheorem map_nat_cast_smul {R : Type u} {M : Type w} {M\u2082 : Type x} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : M \u2192+ M\u2082) (x : \u2115) (a : M) :\n    coe_fn f (\u2191x \u2022 a) = \u2191x \u2022 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 \u2192+ F)\n    (c : \u211a) (x : E) : coe_fn f (\u2191c \u2022 x) = \u2191c \u2022 coe_fn f x :=\n  sorry\n\ntheorem map_rat_module_smul {E : Type u_1} [add_comm_group E] [vector_space \u211a E] {F : Type u_2}\n    [add_comm_group F] [module \u211a F] (f : E \u2192+ F) (c : \u211a) (x : E) :\n    coe_fn f (c \u2022 x) = c \u2022 coe_fn f x :=\n  rat.cast_id c \u25b8 map_rat_cast_smul f c x\n\n@[simp] theorem nat_smul_apply {M : Type w} {M\u2082 : Type x} [add_monoid M] [add_comm_monoid M\u2082]\n    [semimodule \u2115 (M \u2192+ M\u2082)] [semimodule \u2115 M\u2082] (n : \u2115) (f : M \u2192+ M\u2082) (a : M) :\n    coe_fn (n \u2022 f) a = n \u2022 coe_fn f a :=\n  sorry\n\n@[simp] theorem int_smul_apply {M : Type w} {M\u2082 : Type x} [add_monoid M] [add_comm_group M\u2082]\n    [module \u2124 (M \u2192+ M\u2082)] [module \u2124 M\u2082] (n : \u2124) (f : M \u2192+ M\u2082) (a : M) :\n    coe_fn (n \u2022 f) a = n \u2022 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 \u2115 M] [char_zero R] {v : M} {n : \u2115} : n \u2022 v = 0 \u2194 n = 0 \u2228 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 \u2115 M] [char_zero R] {v : M} (hv : bit0 1 \u2022 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 \u2260 0) :\n    v \u2260 -v :=\n  fun (h : v = -v) =>\n    (fun (this : semimodule \u2115 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 {\u03b1 \u03b2 \u03b3 : Type} [tencodable \u03b1] [tencodable \u03b2] [tencodable \u03b3]\nopen_locale complexity_class\n\n@[simp] def zip {\u03b1 \u03b2 : Type*} : list \u03b1 \u2192 list \u03b2 \u2192 list (\u03b1 \u00d7 \u03b2)\n| (x :: xs) (y :: ys) := (x, y) :: zip xs ys\n| _ _ := []\n\ntheorem zip_eq_stack_rec (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n  zip l\u2081 l\u2082 = l\u2081.stack_rec (\u03bb l\u2082' : list \u03b2, []) (\u03bb x xs l\u2082', l\u2082'.tail)\n    (\u03bb ih x xs l\u2082', @list.cases_on _ (\u03bb _, list (\u03b1 \u00d7 \u03b2)) l\u2082' [] (\u03bb y ys, (x, y) :: ih)) l\u2082 :=\nby induction l\u2081 generalizing l\u2082; cases l\u2082; simp [*]\n\nexample : (@zip \u03b1 \u03b2) \u2208\u2091 PTIME :=\nbegin\n  complexity using \u03bb l\u2081 l\u2082, l\u2081.stack_rec (\u03bb l\u2082' : list \u03b2, []) (\u03bb x xs l\u2082', l\u2082'.tail)\n    (\u03bb ih x xs l\u2082', @list.cases_on _ (\u03bb _, list (\u03b1 \u00d7 \u03b2)) l\u2082' [] (\u03bb y ys, (x, y) :: ih)) l\u2082,\n  induction l\u2081 generalizing l\u2082; cases l\u2082; 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 \u2192 C \u2192 C`\n* `tensor_hom : (X\u2081 \u27f6 Y\u2081) \u2192 (X\u2082 \u27f6 Y\u2082) \u2192 ((X\u2081 \u2297 X\u2082) \u27f6 (Y\u2081 \u2297 Y\u2082))`\nand allow use of the overloaded notation `\u2297` for both.\nThe unitors and associator are provided componentwise.\n\nThe tensor product can be expressed as a functor via `tensor : C \u00d7 C \u2964 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. `(\u03bb_ (\ud835\udfd9_ C)).hom = (\u03c1_ (\ud835\udfd9_ 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(\u03bb_ (X \u2297 Y)).hom = (\u03b1_ (\ud835\udfd9_ C) X Y).inv \u226b (\u03bb_ X).hom \u2297 (\ud835\udfd9 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 \u2297 Y` and of morphisms `f \u2297 g`.\nTensor product does not need to be strictly associative on objects, but there is a\nspecified associator, `\u03b1_ X Y Z : (X \u2297 Y) \u2297 Z \u2245 X \u2297 (Y \u2297 Z)`. There is a tensor unit `\ud835\udfd9_ C`,\nwith specified left and right unitor isomorphisms `\u03bb_ X : \ud835\udfd9_ C \u2297 X \u2245 X` and `\u03c1_ X : X \u2297 \ud835\udfd9_ C \u2245 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) [\ud835\udc9e : category C] \nwhere\n  tensor_obj : C \u2192 C \u2192 C\n  tensor_hom : {X\u2081 Y\u2081 X\u2082 Y\u2082 : C} \u2192 (X\u2081 \u27f6 Y\u2081) \u2192 (X\u2082 \u27f6 Y\u2082) \u2192 (tensor_obj X\u2081 X\u2082 \u27f6 tensor_obj Y\u2081 Y\u2082)\n  tensor_id' : autoParam (C \u2192 C \u2192 tensor_hom \ud835\udfd9 \ud835\udfd9 = \ud835\udfd9)\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  (\u2200 {X\u2081 Y\u2081 Z\u2081 X\u2082 Y\u2082 Z\u2082 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (g\u2081 : Y\u2081 \u27f6 Z\u2081) (g\u2082 : Y\u2082 \u27f6 Z\u2082),\n    tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082) = tensor_hom f\u2081 f\u2082 \u226b tensor_hom g\u2081 g\u2082)\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) \u2192 tensor_obj (tensor_obj X Y) Z \u2245 tensor_obj X (tensor_obj Y Z)\n  associator_naturality' : autoParam\n  (\u2200 {X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083),\n    tensor_hom (tensor_hom f\u2081 f\u2082) f\u2083 \u226b iso.hom (associator Y\u2081 Y\u2082 Y\u2083) =\n      iso.hom (associator X\u2081 X\u2082 X\u2083) \u226b tensor_hom f\u2081 (tensor_hom f\u2082 f\u2083))\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) \u2192 tensor_obj tensor_unit X \u2245 X\n  left_unitor_naturality' : autoParam (\u2200 {X Y : C} (f : X \u27f6 Y), tensor_hom \ud835\udfd9 f \u226b iso.hom (left_unitor Y) = iso.hom (left_unitor X) \u226b 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) \u2192 tensor_obj X tensor_unit \u2245 X\n  right_unitor_naturality' : autoParam (\u2200 {X Y : C} (f : X \u27f6 Y), tensor_hom f \ud835\udfd9 \u226b iso.hom (right_unitor Y) = iso.hom (right_unitor X) \u226b 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  (\u2200 (W X Y Z : C),\n    tensor_hom (iso.hom (associator W X Y)) \ud835\udfd9 \u226b\n        iso.hom (associator W (tensor_obj X Y) Z) \u226b tensor_hom \ud835\udfd9 (iso.hom (associator X Y Z)) =\n      iso.hom (associator (tensor_obj W X) Y Z) \u226b 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  (\u2200 (X Y : C),\n    iso.hom (associator X tensor_unit Y) \u226b tensor_hom \ud835\udfd9 (iso.hom (left_unitor Y)) =\n      tensor_hom (iso.hom (right_unitor X)) \ud835\udfd9)\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} [\ud835\udc9e : category C] [c : monoidal_category C] (X\u2081 : C) (X\u2082 : C) : monoidal_category.tensor_hom \ud835\udfd9 \ud835\udfd9 = \ud835\udfd9 := sorry\n\n@[simp] theorem monoidal_category.tensor_comp {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] {X\u2081 : C} {Y\u2081 : C} {Z\u2081 : C} {X\u2082 : C} {Y\u2082 : C} {Z\u2082 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (g\u2081 : Y\u2081 \u27f6 Z\u2081) (g\u2082 : Y\u2082 \u27f6 Z\u2082) : monoidal_category.tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082) =\n  monoidal_category.tensor_hom f\u2081 f\u2082 \u226b monoidal_category.tensor_hom g\u2081 g\u2082 := sorry\n\ntheorem monoidal_category.tensor_comp_assoc {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] {X\u2081 : C} {Y\u2081 : C} {Z\u2081 : C} {X\u2082 : C} {Y\u2082 : C} {Z\u2082 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (g\u2081 : Y\u2081 \u27f6 Z\u2081) (g\u2082 : Y\u2082 \u27f6 Z\u2082) {X' : C} (f' : monoidal_category.tensor_obj Z\u2081 Z\u2082 \u27f6 X') : monoidal_category.tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082) \u226b f' =\n  monoidal_category.tensor_hom f\u2081 f\u2082 \u226b monoidal_category.tensor_hom g\u2081 g\u2082 \u226b f' := sorry\n\ntheorem monoidal_category.associator_naturality {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] {X\u2081 : C} {X\u2082 : C} {X\u2083 : C} {Y\u2081 : C} {Y\u2082 : C} {Y\u2083 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083) : monoidal_category.tensor_hom (monoidal_category.tensor_hom f\u2081 f\u2082) f\u2083 \u226b iso.hom (monoidal_category.associator Y\u2081 Y\u2082 Y\u2083) =\n  iso.hom (monoidal_category.associator X\u2081 X\u2082 X\u2083) \u226b monoidal_category.tensor_hom f\u2081 (monoidal_category.tensor_hom f\u2082 f\u2083) := sorry\n\ntheorem monoidal_category.associator_naturality_assoc {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] {X\u2081 : C} {X\u2082 : C} {X\u2083 : C} {Y\u2081 : C} {Y\u2082 : C} {Y\u2083 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083) {X' : C} (f' : monoidal_category.tensor_obj Y\u2081 (monoidal_category.tensor_obj Y\u2082 Y\u2083) \u27f6 X') : monoidal_category.tensor_hom (monoidal_category.tensor_hom f\u2081 f\u2082) f\u2083 \u226b\n    iso.hom (monoidal_category.associator Y\u2081 Y\u2082 Y\u2083) \u226b f' =\n  iso.hom (monoidal_category.associator X\u2081 X\u2082 X\u2083) \u226b\n    monoidal_category.tensor_hom f\u2081 (monoidal_category.tensor_hom f\u2082 f\u2083) \u226b f' := sorry\n\ntheorem monoidal_category.left_unitor_naturality {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] {X : C} {Y : C} (f : X \u27f6 Y) : monoidal_category.tensor_hom \ud835\udfd9 f \u226b iso.hom (monoidal_category.left_unitor Y) =\n  iso.hom (monoidal_category.left_unitor X) \u226b f := sorry\n\ntheorem monoidal_category.left_unitor_naturality_assoc {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] {X : C} {Y : C} (f : X \u27f6 Y) {X' : C} (f' : Y \u27f6 X') : monoidal_category.tensor_hom \ud835\udfd9 f \u226b iso.hom (monoidal_category.left_unitor Y) \u226b f' =\n  iso.hom (monoidal_category.left_unitor X) \u226b f \u226b f' := sorry\n\ntheorem monoidal_category.right_unitor_naturality {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] {X : C} {Y : C} (f : X \u27f6 Y) : monoidal_category.tensor_hom f \ud835\udfd9 \u226b iso.hom (monoidal_category.right_unitor Y) =\n  iso.hom (monoidal_category.right_unitor X) \u226b f := sorry\n\ntheorem monoidal_category.right_unitor_naturality_assoc {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] {X : C} {Y : C} (f : X \u27f6 Y) {X' : C} (f' : Y \u27f6 X') : monoidal_category.tensor_hom f \ud835\udfd9 \u226b iso.hom (monoidal_category.right_unitor Y) \u226b f' =\n  iso.hom (monoidal_category.right_unitor X) \u226b f \u226b f' := sorry\n\ntheorem monoidal_category.pentagon {C : Type u} [\ud835\udc9e : 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)) \ud835\udfd9 \u226b\n    iso.hom (monoidal_category.associator W (monoidal_category.tensor_obj X Y) Z) \u226b\n      monoidal_category.tensor_hom \ud835\udfd9 (iso.hom (monoidal_category.associator X Y Z)) =\n  iso.hom (monoidal_category.associator (monoidal_category.tensor_obj W X) Y Z) \u226b\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} [\ud835\udc9e : category C] [c : monoidal_category C] (X : C) (Y : C) : iso.hom (monoidal_category.associator X (monoidal_category.tensor_unit C) Y) \u226b\n    monoidal_category.tensor_hom \ud835\udfd9 (iso.hom (monoidal_category.left_unitor Y)) =\n  monoidal_category.tensor_hom (iso.hom (monoidal_category.right_unitor X)) \ud835\udfd9 := sorry\n\n@[simp] theorem monoidal_category.triangle_assoc {C : Type u} [\ud835\udc9e : category C] [c : monoidal_category C] (X : C) (Y : C) {X' : C} (f' : monoidal_category.tensor_obj X Y \u27f6 X') : iso.hom (monoidal_category.associator X (monoidal_category.tensor_unit C) Y) \u226b\n    monoidal_category.tensor_hom \ud835\udfd9 (iso.hom (monoidal_category.left_unitor Y)) \u226b f' =\n  monoidal_category.tensor_hom (iso.hom (monoidal_category.right_unitor X)) \ud835\udfd9 \u226b f' := sorry\n\ninfixr:70 \" \u2297 \" => Mathlib.category_theory.monoidal_category.tensor_obj\n\ninfixr:70 \" \u2297 \" => Mathlib.category_theory.monoidal_category.tensor_hom\n\nnotation:1024 \"\ud835\udfd9_\" => Mathlib.category_theory.monoidal_category.tensor_unit\n\nnotation:1024 \"\u03b1_\" => Mathlib.category_theory.monoidal_category.associator\n\nnotation:1024 \"\u03bb_\" => Mathlib.category_theory.monoidal_category.left_unitor\n\nnotation:1024 \"\u03c1_\" => 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 \u2245 Y) (g : X' \u2245 Y') : X \u2297 X' \u2245 Y \u2297 Y' :=\n  iso.mk (iso.hom f \u2297 iso.hom g) (iso.inv f \u2297 iso.inv g)\n\ninfixr:70 \" \u2297 \" => 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 \u27f6 X) [is_iso f] (g : Y \u27f6 Z) [is_iso g] : is_iso (f \u2297 g) :=\n  is_iso.mk (iso.inv (as_iso f \u2297 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 \u27f6 X) [is_iso f] (g : Y \u27f6 Z) [is_iso g] : inv (f \u2297 g) = inv f \u2297 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 \u27f6 X) (g : X \u27f6 Y) : f \u226b g \u2297 \ud835\udfd9 = (f \u2297 \ud835\udfd9) \u226b (g \u2297 \ud835\udfd9) := 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 \u27f6 X) (g : X \u27f6 Y) : \ud835\udfd9 \u2297 f \u226b g = (\ud835\udfd9 \u2297 f) \u226b (\ud835\udfd9 \u2297 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 \u27f6 X) (g : Y \u27f6 Z) : (\ud835\udfd9 \u2297 f) \u226b (g \u2297 \ud835\udfd9) = g \u2297 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 \u27f6 X) (g : Y \u27f6 Z) {X' : C} (f' : Z \u2297 X \u27f6 X') : (g \u2297 \ud835\udfd9) \u226b (\ud835\udfd9 \u2297 f) \u226b f' = (g \u2297 f) \u226b f' := sorry\n\ntheorem left_unitor_inv_naturality {C : Type u} [category C] [monoidal_category C] {X : C} {X' : C} (f : X \u27f6 X') : f \u226b iso.inv \u03bb_ = iso.inv \u03bb_ \u226b (\ud835\udfd9 \u2297 f) := sorry\n\ntheorem right_unitor_inv_naturality {C : Type u} [category C] [monoidal_category C] {X : C} {X' : C} (f : X \u27f6 X') : f \u226b iso.inv \u03c1_ = iso.inv \u03c1_ \u226b (f \u2297 \ud835\udfd9) := sorry\n\n@[simp] theorem right_unitor_conjugation {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} (f : X \u27f6 Y) : iso.inv \u03c1_ \u226b (f \u2297 \ud835\udfd9) \u226b iso.hom \u03c1_ = f := sorry\n\n@[simp] theorem left_unitor_conjugation {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} (f : X \u27f6 Y) : iso.inv \u03bb_ \u226b (\ud835\udfd9 \u2297 f) \u226b iso.hom \u03bb_ = f := sorry\n\n@[simp] theorem tensor_left_iff {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} (f : X \u27f6 Y) (g : X \u27f6 Y) : \ud835\udfd9 \u2297 f = \ud835\udfd9 \u2297 g \u2194 f = g := sorry\n\n@[simp] theorem tensor_right_iff {C : Type u} [category C] [monoidal_category C] {X : C} {Y : C} (f : X \u27f6 Y) (g : X \u27f6 Y) : f \u2297 \ud835\udfd9 = g \u2297 \ud835\udfd9 \u2194 f = g := sorry\n\n-- We now prove:\n\n--   ((\u03b1_ (\ud835\udfd9_ C) X Y).hom) \u226b\n\n--     ((\u03bb_ (X \u2297 Y)).hom)\n\n--   = ((\u03bb_ X).hom \u2297 (\ud835\udfd9 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 \u03b1_ \u2297 \ud835\udfd9) \u226b iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 iso.hom \u03b1_) \u226b (\ud835\udfd9 \u2297 iso.hom \u03bb_) = ((iso.hom \u03c1_ \u2297 \ud835\udfd9) \u2297 \ud835\udfd9) \u226b iso.hom \u03b1_ := sorry\n\ntheorem left_unitor_product_aux_triangle {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.hom \u03b1_ \u2297 \ud835\udfd9) \u226b ((\ud835\udfd9 \u2297 iso.hom \u03bb_) \u2297 \ud835\udfd9) = (iso.hom \u03c1_ \u2297 \ud835\udfd9) \u2297 \ud835\udfd9 := sorry\n\ntheorem left_unitor_product_aux_square {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 iso.hom \u03bb_ \u2297 \ud835\udfd9) = ((\ud835\udfd9 \u2297 iso.hom \u03bb_) \u2297 \ud835\udfd9) \u226b iso.hom \u03b1_ := sorry\n\ntheorem left_unitor_product_aux {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (\ud835\udfd9 \u2297 iso.hom \u03b1_) \u226b (\ud835\udfd9 \u2297 iso.hom \u03bb_) = \ud835\udfd9 \u2297 iso.hom \u03bb_ \u2297 \ud835\udfd9 := sorry\n\ntheorem right_unitor_product_aux_perimeter {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.hom \u03b1_ \u2297 \ud835\udfd9) \u226b iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 iso.hom \u03b1_) \u226b (\ud835\udfd9 \u2297 \ud835\udfd9 \u2297 iso.hom \u03bb_) = (iso.hom \u03c1_ \u2297 \ud835\udfd9) \u226b iso.hom \u03b1_ := sorry\n\ntheorem right_unitor_product_aux_triangle {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (\ud835\udfd9 \u2297 iso.hom \u03b1_) \u226b (\ud835\udfd9 \u2297 \ud835\udfd9 \u2297 iso.hom \u03bb_) = \ud835\udfd9 \u2297 iso.hom \u03c1_ \u2297 \ud835\udfd9 := sorry\n\ntheorem right_unitor_product_aux_square {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 iso.hom \u03c1_ \u2297 \ud835\udfd9) = ((\ud835\udfd9 \u2297 iso.hom \u03c1_) \u2297 \ud835\udfd9) \u226b iso.hom \u03b1_ := sorry\n\ntheorem right_unitor_product_aux {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.hom \u03b1_ \u2297 \ud835\udfd9) \u226b ((\ud835\udfd9 \u2297 iso.hom \u03c1_) \u2297 \ud835\udfd9) = iso.hom \u03c1_ \u2297 \ud835\udfd9 := 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 \u03b1_ \u226b iso.hom \u03bb_ = iso.hom \u03bb_ \u2297 \ud835\udfd9 := sorry\n\n@[simp] theorem left_unitor_tensor {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom \u03bb_ = iso.inv \u03b1_ \u226b (iso.hom \u03bb_ \u2297 \ud835\udfd9) := sorry\n\ntheorem left_unitor_tensor_inv' {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.inv \u03bb_ \u226b iso.inv \u03b1_ = iso.inv \u03bb_ \u2297 \ud835\udfd9 := sorry\n\n@[simp] theorem left_unitor_tensor_inv {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.inv \u03bb_ = (iso.inv \u03bb_ \u2297 \ud835\udfd9) \u226b iso.hom \u03b1_ := sorry\n\n@[simp] theorem right_unitor_tensor {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom \u03c1_ = iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 iso.hom \u03c1_) := sorry\n\n@[simp] theorem right_unitor_tensor_inv {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.inv \u03c1_ = (\ud835\udfd9 \u2297 iso.inv \u03c1_) \u226b iso.inv \u03b1_ := 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 \u27f6 X') (g : Y \u27f6 Y') (h : Z \u27f6 Z') : (f \u2297 g \u2297 h) \u226b iso.inv \u03b1_ = iso.inv \u03b1_ \u226b ((f \u2297 g) \u2297 h) := sorry\n\ntheorem pentagon_inv {C : Type u} [category C] [monoidal_category C] (W : C) (X : C) (Y : C) (Z : C) : (\ud835\udfd9 \u2297 iso.inv \u03b1_) \u226b iso.inv \u03b1_ \u226b (iso.inv \u03b1_ \u2297 \ud835\udfd9) = iso.inv \u03b1_ \u226b iso.inv \u03b1_ := sorry\n\ntheorem triangle_assoc_comp_left {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 iso.hom \u03bb_) = iso.hom \u03c1_ \u2297 \ud835\udfd9 :=\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 \u03b1_ \u226b (iso.hom \u03c1_ \u2297 \ud835\udfd9) = \ud835\udfd9 \u2297 iso.hom \u03bb_ := sorry\n\n@[simp] theorem triangle_assoc_comp_right_inv {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (iso.inv \u03c1_ \u2297 \ud835\udfd9) \u226b iso.hom \u03b1_ = \ud835\udfd9 \u2297 iso.inv \u03bb_ := sorry\n\n@[simp] theorem triangle_assoc_comp_left_inv {C : Type u} [category C] [monoidal_category C] (X : C) (Y : C) : (\ud835\udfd9 \u2297 iso.inv \u03bb_) \u226b iso.inv \u03b1_ = iso.inv \u03c1_ \u2297 \ud835\udfd9 := sorry\n\n/-- The tensor product expressed as a functor. -/\ndef tensor (C : Type u) [category C] [monoidal_category C] : C \u00d7 C \u2964 C :=\n  functor.mk (fun (X : C \u00d7 C) => prod.fst X \u2297 prod.snd X) fun {X Y : C \u00d7 C} (f : X \u27f6 Y) => prod.fst f \u2297 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 \u00d7 C \u00d7 C \u2964 C :=\n  functor.mk (fun (X : C \u00d7 C \u00d7 C) => (prod.fst X \u2297 prod.fst (prod.snd X)) \u2297 prod.snd (prod.snd X))\n    fun {X Y : C \u00d7 C \u00d7 C} (f : X \u27f6 Y) => (prod.fst f \u2297 prod.fst (prod.snd f)) \u2297 prod.snd (prod.snd f)\n\n@[simp] theorem left_assoc_tensor_obj (C : Type u) [category C] [monoidal_category C] (X : C \u00d7 C \u00d7 C) : functor.obj (left_assoc_tensor C) X = (prod.fst X \u2297 prod.fst (prod.snd X)) \u2297 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 \u00d7 C \u00d7 C} {Y : C \u00d7 C \u00d7 C} (f : X \u27f6 Y) : functor.map (left_assoc_tensor C) f = (prod.fst f \u2297 prod.fst (prod.snd f)) \u2297 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 \u00d7 C \u00d7 C \u2964 C :=\n  functor.mk (fun (X : C \u00d7 C \u00d7 C) => prod.fst X \u2297 prod.fst (prod.snd X) \u2297 prod.snd (prod.snd X))\n    fun {X Y : C \u00d7 C \u00d7 C} (f : X \u27f6 Y) => prod.fst f \u2297 prod.fst (prod.snd f) \u2297 prod.snd (prod.snd f)\n\n@[simp] theorem right_assoc_tensor_obj (C : Type u) [category C] [monoidal_category C] (X : C \u00d7 C \u00d7 C) : functor.obj (right_assoc_tensor C) X = prod.fst X \u2297 prod.fst (prod.snd X) \u2297 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 \u00d7 C \u00d7 C} {Y : C \u00d7 C \u00d7 C} (f : X \u27f6 Y) : functor.map (right_assoc_tensor C) f = prod.fst f \u2297 prod.fst (prod.snd f) \u2297 prod.snd (prod.snd f) :=\n  rfl\n\n/-- The functor `\u03bb X, \ud835\udfd9_ C \u2297 X`. -/\ndef tensor_unit_left (C : Type u) [category C] [monoidal_category C] : C \u2964 C :=\n  functor.mk (fun (X : C) => \ud835\udfd9_ \u2297 X) fun {X Y : C} (f : X \u27f6 Y) => \ud835\udfd9 \u2297 f\n\n/-- The functor `\u03bb X, X \u2297 \ud835\udfd9_ C`. -/\ndef tensor_unit_right (C : Type u) [category C] [monoidal_category C] : C \u2964 C :=\n  functor.mk (fun (X : C) => X \u2297 \ud835\udfd9_) fun {X Y : C} (f : X \u27f6 Y) => f \u2297 \ud835\udfd9\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 \u00d7 C \u00d7 C) : nat_trans.app (iso.hom (associator_nat_iso C)) X = iso.hom \u03b1_ :=\n  Eq.refl (iso.hom \u03b1_)\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 \u03bb_ :=\n  Eq.refl (iso.inv \u03bb_)\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 \u03c1_ :=\n  Eq.refl (iso.inv \u03c1_)\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 \u27f6 Y') : functor.map (tensor_left X) f = \ud835\udfd9 \u2297 f :=\n  Eq.refl (functor.map (tensor_left X) f)\n\n/--\nTensoring on the left with `X \u2297 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 \u2297 Y) \u2245 tensor_left Y \u22d9 tensor_left X :=\n  nat_iso.of_components \u03b1_ 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 \u03b1_ :=\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 \u03b1_ :=\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 \u2297 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 \u2964 C \u2964 C :=\n  functor.mk tensor_right fun (X Y : C) (f : X \u27f6 Y) => nat_trans.mk fun (Z : C) => \ud835\udfd9 \u2297 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 \u2297 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 \u2297 Y) \u2245 tensor_right X \u22d9 tensor_right Y :=\n  nat_iso.of_components (fun (Z : C) => iso.symm \u03b1_) 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 \u03b1_ :=\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 \u03b1_ :=\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 algebra.module.linear_map\nimport data.real.basic\n\ndef f (x y : \u211d) : prod \u211d \u211d := (x+y, x-y)\ntheorem cpge_applin_2 [module \u211d (prod \u211d \u211d )] [E : set (prod \u211d \u211d)]: \n\u2203 g : (linear_equiv  \u211d (prod \u211d \u211d) (prod \u211d \u211d)), \n\u2200 x y : \u211d , (f x y) = (g (x, y)) := 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/applications_lineaires/cpge_applin_2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9059898254600903, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4988446709983126}}
{"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 : \u2115) : 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 : \u2115) : 2 * (root * p ^ q) * (p ^ 1 * a) = p ^ q  * p ^ 1  * (2 * a * root) := by ring\n\nlemma factorize3 (root p : R) (q : \u2115) : 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 : \u2115) : 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\u2082 u\u2082\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 \u03c7 to classify the mono f. -/\nabbreviation classifying {\u03a9 \u03a9\u2080 U X : C} (truth : \u03a9\u2080 \u27f6 \u03a9) (f : U \u27f6 X) (\u03c7 : X \u27f6 \u03a9) := has_pullback_top f \u03c7 truth\n\ninstance subsingleton_classifying {\u03a9 \u03a9\u2080 U X : C} (truth : \u03a9\u2080 \u27f6 \u03a9) [mono truth] (f : U \u27f6 X) (\u03c7 : X \u27f6 \u03a9) :\n  subsingleton (classifying truth f \u03c7) :=\n\u27e8by { intros P Q, cases P, cases Q, congr, rw [\u2190 cancel_mono truth, P_comm, Q_comm] }\u27e9\n\n/--\n`is_subobject_classifier truth` holds if the morphism `truth : \u03a9\u2080 \u27f6 \u03a9` is a subobject classifier,\ni.e. that for any monomorphism `U \u27f6 X`, there is a unique morphism `X \u27f6 \u03a9` forming a pullback\nsquare.\nNote we do not require `truth` to be a monomorphism here, nor that `\u03a9\u2080` is terminal.\n-/\nstructure is_subobject_classifier {\u03a9 \u03a9\u2080 : C} (truth : \u03a9\u2080 \u27f6 \u03a9) :=\n(classifier_of : \u2200 {U X} (f : U \u27f6 X) [mono.{v} f], X \u27f6 \u03a9)\n(classifies' : \u2200 {U X} (f : U \u27f6 X) [mono f], classifying truth f (classifier_of f))\n(uniquely' : \u2200 {U X} (f : U \u27f6 X) [mono f] (\u03c7\u2081 : X \u27f6 \u03a9), classifying truth f \u03c7\u2081 \u2192 classifier_of f = \u03c7\u2081)\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 `\u03a9\u2080` to be terminal, nor do we assume the existence of any limits.\n-/\nclass has_subobject_classifier :=\n(\u03a9 \u03a9\u2080 : C)\n(truth : \u03a9\u2080 \u27f6 \u03a9)\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 \u03a9 : C := has_subobject_classifier.\u03a9.{v}\n/-- Convenience notation for the classifier source given the typeclass `has_subobject_classifier`. -/\ndef \u03a9\u2080 : C := has_subobject_classifier.\u03a9\u2080.{v}\n/-- Convenience notation for the classifier given the typeclass `has_subobject_classifier`. -/\ndef truth : \u03a9\u2080 C \u27f6 \u03a9 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 \u27f6 X) [mono f] : X \u27f6 \u03a9 C :=\n(subobj_classifier_is_subobj_classifier C).classifier_of f\ndef classifies {U X : C} (f : U \u27f6 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 \u27f6 X) [mono f] (\u03c7\u2081 : X \u27f6 \u03a9 C) (h\u03c7 : classifying (truth C) f \u03c7\u2081) : classifier_of f = \u03c7\u2081 :=\n(subobj_classifier_is_subobj_classifier C).uniquely' f \u03c7\u2081 h\u03c7\n\nend classifier\n\nopen classifier\n\n-- Usually we would assume C has finite limits, and \u03a9\u2080 C might not be equal to it.\ninstance unique_to_\u03a9\u2080 (P : C) : unique (P \u27f6 \u03a9\u2080 C) :=\n{ default := (classifies (\ud835\udfd9 _)).top,\n  uniq := \u03bb a,\n  begin\n    rw [\u2190 cancel_mono (truth C), (classifies (\ud835\udfd9 _)).comm, id_comp, uniquely],\n    apply left_iso_has_pullback_top a (\ud835\udfd9 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 \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} (h : factors_through f g) [mono g] : {k // k \u226b g = f} :=\nbegin\n  haveI := mono_is_regular g,\n  refine regular_mono.lift' _ _ _,\n  casesI h,\n  have : h.left \u226b g = f := over.w h,\n  rw [\u2190 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 \u27f6 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\u2082) [category.{v\u2082} D] (F : C \u2964 D) [faithful F] : reflects_isomorphisms F :=\n\u27e8\u03bb 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\u27e9\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 \u2964 D`, a `T`-structured arrow with source `S : D`\nis just a morphism `S \u27f6 T.obj Y`, for some `Y : C`.\n\nThese form a category with morphisms `g : Y \u27f6 Y'` making the obvious diagram commute.\n\nWe prove that `\ud835\udfd9 (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\u2081 v\u2082 v\u2083 v\u2084 u\u2081 u\u2082 u\u2083 u\u2084\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} D]\n\n#print CategoryTheory.StructuredArrow /-\n/-- The category of `T`-structured arrows with domain `S : D` (here `T : C \u2964 D`),\nhas as its objects `D`-morphisms of the form `S \u27f6 T Y`, for some `Y : C`,\nand morphisms `C`-morphisms `Y \u27f6 Y'` making the obvious triangle commute.\n-/\n@[nolint has_nonempty_instance]\ndef StructuredArrow (S : D) (T : C \u2964 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 \u2964 D) : StructuredArrow S T \u2964 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 \u2964 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\u2093'. -/\n/-- Construct a structured arrow from a morphism. -/\ndef mk (f : S \u27f6 T.obj Y) : StructuredArrow S T :=\n  \u27e8\u27e8\u27e8\u27e9\u27e9, Y, f\u27e9\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\u2093'. -/\n@[simp]\ntheorem mk_left (f : S \u27f6 T.obj Y) : (mk f).left = \u27e8\u27e8\u27e9\u27e9 :=\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\u2093'. -/\n@[simp]\ntheorem mk_right (f : S \u27f6 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\u2093'. -/\n@[simp]\ntheorem mk_hom_eq_self (f : S \u27f6 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\u2093'. -/\n@[simp, reassoc.1]\ntheorem w {A B : StructuredArrow S T} (f : A \u27f6 B) : A.Hom \u226b 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\u2093'. -/\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 \u27f6 f'.right) (w : f.Hom \u226b T.map g = f'.Hom) :\n    f \u27f6 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'\u2093'. -/\n/-- Given a structured arrow `X \u27f6 F(U)`, and an arrow `U \u27f6 Y`, we can construct a morphism of\nstructured arrow given by `(X \u27f6 F(U)) \u27f6 (X \u27f6 F(U) \u27f6 F(Y))`.\n-/\ndef homMk' {F : C \u2964 D} {X : D} {Y : C} (U : StructuredArrow X F) (f : U.right \u27f6 Y) :\n    U \u27f6 mk (U.Hom \u226b 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\u2093'. -/\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 \u2245 f'.right) (w : f.Hom \u226b T.map g.Hom = f'.Hom) :\n    f \u2245 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 \u27f6 B) : f.right = g.right \u2192 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 \u27f6 B) : f = g \u2194 f.right = g.right :=\n  \u27e8fun h => h \u25b8 rfl, ext f g\u27e9\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 \u27f6 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 \u27f6 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\u2093'. -/\ninstance mono_homMk {A B : StructuredArrow S T} (f : A.right \u27f6 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\u2093'. -/\ninstance epi_homMk {A B : StructuredArrow S T} (f : A.right \u27f6 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 \u2245 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 \u27f6 S'`\ncontravariantly induces a functor between structured arrows,\n`structured_arrow S' T \u2964 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 \u27f6 S') : StructuredArrow S' T \u2964 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\u2093'. -/\n@[simp]\ntheorem map_mk {f : S' \u27f6 T.obj Y} (g : S \u27f6 S') : (map g).obj (mk f) = mk (g \u226b 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\u2093'. -/\n@[simp]\ntheorem map_id {f : StructuredArrow S T} : (map (\ud835\udfd9 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\u2093'. -/\n@[simp]\ntheorem map_comp {f : S \u27f6 S'} {f' : S' \u27f6 S''} {h : StructuredArrow S'' T} :\n    (map (f \u226b 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    \u27e8\u27e8structured_arrow.hom_mk (inv ((proj S T).map f)) (by simp), by tidy\u27e9\u27e9\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\u2093'. -/\n/-- The identity structured arrow is initial. -/\ndef mkIdInitial [Full T] [Faithful T] : IsInitial (mk (\ud835\udfd9 (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, \u2190 w m] using (category.id_comp _).symm\n#align category_theory.structured_arrow.mk_id_initial CategoryTheory.StructuredArrow.mkIdInitial\n\nvariable {A : Type u\u2083} [Category.{v\u2083} A] {B : Type u\u2084} [Category.{v\u2084} B]\n\n#print CategoryTheory.StructuredArrow.pre /-\n/-- The functor `(S, F \u22d9 G) \u2964 (S, G)`. -/\n@[simps]\ndef pre (S : D) (F : B \u2964 C) (G : C \u2964 D) : StructuredArrow S (F \u22d9 G) \u2964 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\u2093'. -/\n/-- The functor `(S, F) \u2964 (G(S), F \u22d9 G)`. -/\n@[simps]\ndef post (S : C) (F : B \u2964 C) (G : C \u2964 D) : StructuredArrow S F \u2964 StructuredArrow (G.obj S) (F \u22d9 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, \u2190 G.map_comp, \u2190 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} {\ud835\udca2 : Set.{u3} C} [_inst_5 : Small.{u1, u3} (coeSort.{succ u3, succ (succ u3)} (Set.{u3} C) Type.{u3} (Set.hasCoeToSort.{u3} C) \ud835\udca2)] [_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)) \ud835\udca2))\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} {\ud835\udca2 : Set.{u3} C} [_inst_5 : Small.{u1, u3} (Set.Elem.{u3} C \ud835\udca2)] [_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))) \ud835\udca2))\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\u2093'. -/\ninstance small_proj_preimage_of_locallySmall {\ud835\udca2 : Set C} [Small.{v\u2081} \ud835\udca2] [LocallySmall.{v\u2081} D] :\n    Small.{v\u2081} ((proj S T).obj \u207b\u00b9' \ud835\udca2) :=\n  by\n  suffices (proj S T).obj \u207b\u00b9' \ud835\udca2 = Set.range fun f : \u03a3G : \ud835\udca2, S \u27f6 T.obj G => mk f.2\n    by\n    rw [this]\n    infer_instance\n  exact Set.ext fun X => \u27e8fun h => \u27e8\u27e8\u27e8_, h\u27e9, X.Hom\u27e9, (eq_mk _).symm\u27e9, by tidy\u27e9\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 \u2964 D`),\nhas as its objects `D`-morphisms of the form `S Y \u27f6 T`, for some `Y : C`,\nand morphisms `C`-morphisms `Y \u27f6 Y'` making the obvious triangle commute.\n-/\n@[nolint has_nonempty_instance]\ndef CostructuredArrow (S : C \u2964 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 \u2964 D) (T : D) : CostructuredArrow S T \u2964 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 \u2964 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\u2093'. -/\n/-- Construct a costructured arrow from a morphism. -/\ndef mk (f : S.obj Y \u27f6 T) : CostructuredArrow S T :=\n  \u27e8Y, \u27e8\u27e8\u27e9\u27e9, f\u27e9\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\u2093'. -/\n@[simp]\ntheorem mk_left (f : S.obj Y \u27f6 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\u2093'. -/\n@[simp]\ntheorem mk_right (f : S.obj Y \u27f6 T) : (mk f).right = \u27e8\u27e8\u27e9\u27e9 :=\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\u2093'. -/\n@[simp]\ntheorem mk_hom_eq_self (f : S.obj Y \u27f6 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\u2093'. -/\n@[simp, reassoc.1]\ntheorem w {A B : CostructuredArrow S T} (f : A \u27f6 B) : S.map f.left \u226b 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\u2093'. -/\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 \u27f6 f'.left) (w : S.map g \u226b f'.Hom = f.Hom) :\n    f \u27f6 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\u2093'. -/\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 \u2245 f'.left) (w : S.map g.Hom \u226b f'.Hom = f.Hom) :\n    f \u2245 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 \u27f6 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 \u27f6 B) : f = g \u2194 f.left = g.left :=\n  \u27e8fun h => h \u25b8 rfl, ext f g\u27e9\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 \u27f6 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 \u27f6 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\u2093'. -/\ninstance mono_homMk {A B : CostructuredArrow S T} (f : A.left \u27f6 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\u2093'. -/\ninstance epi_homMk {A B : CostructuredArrow S T} (f : A.left \u27f6 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 \u2245 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 \u27f6 T'`\ncovariantly induces a functor between costructured arrows,\n`costructured_arrow S T \u2964 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 \u27f6 T') : CostructuredArrow S T \u2964 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\u2093'. -/\n@[simp]\ntheorem map_mk {f : S.obj Y \u27f6 T} (g : T \u27f6 T') : (map g).obj (mk f) = mk (f \u226b 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\u2093'. -/\n@[simp]\ntheorem map_id {f : CostructuredArrow S T} : (map (\ud835\udfd9 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\u2093'. -/\n@[simp]\ntheorem map_comp {f : T \u27f6 T'} {f' : T' \u27f6 T''} {h : CostructuredArrow S T} :\n    (map (f \u226b 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    \u27e8\u27e8costructured_arrow.hom_mk (inv ((proj S T).map f)) (by simp), by tidy\u27e9\u27e9\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\u2093'. -/\n/-- The identity costructured arrow is terminal. -/\ndef mkIdTerminal [Full S] [Faithful S] : IsTerminal (mk (\ud835\udfd9 (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, \u2190 w m] using (category.comp_id _).symm\n#align category_theory.costructured_arrow.mk_id_terminal CategoryTheory.CostructuredArrow.mkIdTerminal\n\nvariable {A : Type u\u2083} [Category.{v\u2083} A] {B : Type u\u2084} [Category.{v\u2084} B]\n\n#print CategoryTheory.CostructuredArrow.pre /-\n/-- The functor `(F \u22d9 G, S) \u2964 (G, S)`. -/\n@[simps]\ndef pre (F : B \u2964 C) (G : C \u2964 D) (S : D) : CostructuredArrow (F \u22d9 G) S \u2964 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\u2093'. -/\n/-- The functor `(F, S) \u2964 (F \u22d9 G, G(S))`. -/\n@[simps]\ndef post (F : B \u2964 C) (G : C \u2964 D) (S : C) :\n    CostructuredArrow F S \u2964 CostructuredArrow (F \u22d9 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, \u2190 G.map_comp, \u2190 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} {\ud835\udca2 : Set.{u3} C} [_inst_5 : Small.{u1, u3} (coeSort.{succ u3, succ (succ u3)} (Set.{u3} C) Type.{u3} (Set.hasCoeToSort.{u3} C) \ud835\udca2)] [_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)) \ud835\udca2))\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} {\ud835\udca2 : Set.{u3} C} [_inst_5 : Small.{u1, u3} (Set.Elem.{u3} C \ud835\udca2)] [_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))) \ud835\udca2))\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\u2093'. -/\ninstance small_proj_preimage_of_locallySmall {\ud835\udca2 : Set C} [Small.{v\u2081} \ud835\udca2] [LocallySmall.{v\u2081} D] :\n    Small.{v\u2081} ((proj S T).obj \u207b\u00b9' \ud835\udca2) :=\n  by\n  suffices (proj S T).obj \u207b\u00b9' \ud835\udca2 = Set.range fun f : \u03a3G : \ud835\udca2, S.obj G \u27f6 T => mk f.2\n    by\n    rw [this]\n    infer_instance\n  exact Set.ext fun X => \u27e8fun h => \u27e8\u27e8\u27e8_, h\u27e9, X.Hom\u27e9, (eq_mk _).symm\u27e9, by tidy\u27e9\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 \u2964 D` and an object `d : D`, we obtain a contravariant functor from the\ncategory of structured arrows `d \u27f6 F.obj c` to the category of costructured arrows\n`F.op.obj c \u27f6 (op d)`.\n-/\n@[simps]\ndef toCostructuredArrow (F : C \u2964 D) (d : D) :\n    (StructuredArrow d F)\u1d52\u1d56 \u2964 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 [\u2190 op_comp, \u2190 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 \u2964 D` and an object `d : D`, we obtain a contravariant functor from the\ncategory of structured arrows `op d \u27f6 F.op.obj c` to the category of costructured arrows\n`F.obj c \u27f6 d`.\n-/\n@[simps]\ndef toCostructuredArrow' (F : C \u2964 D) (d : D) :\n    (StructuredArrow (op d) F.op)\u1d52\u1d56 \u2964 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 [\u2190 Quiver.Hom.unop_op (F.map (Quiver.Hom.unop f.unop.right)), \u2190 unop_comp, \u2190 F.op_map, \u2190\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 \u2964 D` and an object `d : D`, we obtain a contravariant functor from the\ncategory of costructured arrows `F.obj c \u27f6 d` to the category of structured arrows\n`op d \u27f6 F.op.obj c`.\n-/\n@[simps]\ndef toStructuredArrow (F : C \u2964 D) (d : D) : (CostructuredArrow F d)\u1d52\u1d56 \u2964 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 [\u2190 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 \u2964 D` and an object `d : D`, we obtain a contravariant functor from the\ncategory of costructured arrows `F.op.obj c \u27f6 op d` to the category of structured arrows\n`d \u27f6 F.obj c`.\n-/\n@[simps]\ndef toStructuredArrow' (F : C \u2964 D) (d : D) : (CostructuredArrow F.op (op d))\u1d52\u1d56 \u2964 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 [\u2190 Quiver.Hom.unop_op (F.map f.unop.left.unop), \u2190 unop_comp, \u2190 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\u2093'. -/\n/-- For a functor `F : C \u2964 D` and an object `d : D`, the category of structured arrows `d \u27f6 F.obj c`\nis contravariantly equivalent to the category of costructured arrows `F.op.obj c \u27f6 op d`.\n-/\ndef structuredArrowOpEquivalence (F : C \u2964 D) (d : D) :\n    (StructuredArrow d F)\u1d52\u1d56 \u224c 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\u2093'. -/\n/-- For a functor `F : C \u2964 D` and an object `d : D`, the category of costructured arrows\n`F.obj c \u27f6 d` is contravariantly equivalent to the category of structured arrows\n`op d \u27f6 F.op.obj c`.\n-/\ndef costructuredArrowOpEquivalence (F : C \u2964 D) (d : D) :\n    (CostructuredArrow F d)\u1d52\u1d56 \u224c 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 \u22a2}\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 \u22a2} \"'[e, f, g]' are unused variables\",\n  success_if_fail_with_msg {move_add at \u22a2 h} \"Goal did not change\\n'[h]' did not change\",\n  move_add \u2190 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 \u22a2}\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 \u22a2} \"'[e, f, g]' are unused variables\",\n  success_if_fail_with_msg {move_mul at \u22a2 h} \"Goal did not change\\n'[h]' did not change\",\n  success_if_fail_with_msg {move_mul at \u22a2} \"Goal did not change\",\n  move_mul \u2190 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 [\u2190 a, c],\n  simp only,\nend\n\nexample (n : \u2115) : list.of_fn (\u03bb i : fin (n + 3), (i : \u2115)) = list.of_fn (\u03bb i : fin (3 + n), i) :=\nbegin\n  move_add [\u2190n],\nend\n\nexample (a b : \u2115) : a + max a b = max b a + a :=\nbegin\n  move_oper [max] \u2190 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  \u2200 x : R, \u2203 y : R, a * x * b * y = x * y * b * a :=\nby { move_mul [a, b], exact \u03bb x, \u27e8x, rfl\u27e9 }\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 \u2192 d + c + a = c + a) : a + d + b = b + a \u2192 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 \u2260 c + a :=\nbegin\n  move_add [\u2190 a],\n  split_ifs; exact h,\nend\n\nexample (r : R \u2192 R \u2192 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 [\u2190 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, \u2190 _ * 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 \u2192 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 : \u2200 i, add_comm_semigroup (fin i \u2192 \u2115) := \u03bb i, by apply_instance,\n  letI ia : \u2200 i, has_add (fin i \u2192 \u2115) := \u03bb 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 : \u2200 (a b : fin _ \u2192 \u2115), @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\u00f6lzl, 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 `\u03b1 \u00d7 \u03b2`. 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 \u03b1`, `t : finset \u03b2` into their product in `finset (\u03b1 \u00d7 \u03b2)`.\n* `finset.diag`: For `s : finset \u03b1`, `s.diag` is the `finset (\u03b1 \u00d7 \u03b1)` of pairs `(a, a)` with\n  `a \u2208 s`.\n* `finset.off_diag`: For `s : finset \u03b1`, `s.off_diag` is the `finset (\u03b1 \u00d7 \u03b1)` of pairs `(a, b)` with\n  `a, b \u2208 s` and `a \u2260 b`.\n-/\n\n\nopen Multiset\n\nvariable {\u03b1 \u03b2 \u03b3 : Type _}\n\nnamespace Finset\n\n/-! ### prod -/\n\n\nsection Prod\n\nvariable {s s' : Finset \u03b1} {t t' : Finset \u03b2} {a : \u03b1} {b : \u03b2}\n\n#print Finset.product /-\n/-- `product s t` is the set of pairs `(a, b)` such that `a \u2208 s` and `b \u2208 t`. -/\nprotected def product (s : Finset \u03b1) (t : Finset \u03b2) : Finset (\u03b1 \u00d7 \u03b2) :=\n  \u27e8_, s.Nodup.product t.Nodup\u27e9\n#align finset.product Finset.product\n-/\n\n-- mathport name: finset.product\ninfixr:82\n  \" \u00d7\u02e2 \" =>-- 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, Eq.{succ (max u1 u2)} (Multiset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.val.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) (Multiset.product.{u1, u2} \u03b1 \u03b2 (Finset.val.{u1} \u03b1 s) (Finset.val.{u2} \u03b2 t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, Eq.{max (succ u2) (succ u1)} (Multiset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.val.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) (Multiset.product.{u2, u1} \u03b1 \u03b2 (Finset.val.{u2} \u03b1 s) (Finset.val.{u1} \u03b2 t))\nCase conversion may be inaccurate. Consider using '#align finset.product_val Finset.product_val\u2093'. -/\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 \u00d7\u02e2 t).1 = s.1 \u00d7\u02e2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {p : Prod.{u1, u2} \u03b1 \u03b2}, Iff (Membership.Mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasMem.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) p (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) (And (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) (Prod.fst.{u1, u2} \u03b1 \u03b2 p) s) (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) (Prod.snd.{u1, u2} \u03b1 \u03b2 p) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {p : Prod.{u2, u1} \u03b1 \u03b2}, Iff (Membership.mem.{max u2 u1, max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instMembershipFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) p (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) (And (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) (Prod.fst.{u2, u1} \u03b1 \u03b2 p) s) (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) (Prod.snd.{u2, u1} \u03b1 \u03b2 p) t))\nCase conversion may be inaccurate. Consider using '#align finset.mem_product Finset.mem_product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem mem_product {p : \u03b1 \u00d7 \u03b2} : p \u2208 s \u00d7\u02e2 t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {a : \u03b1} {b : \u03b2}, (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) -> (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) b t) -> (Membership.Mem.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasMem.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.mk.{u1, u2} \u03b1 \u03b2 a b) (Finset.product.{u1, u2} \u03b1 \u03b2 s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {a : \u03b1} {b : \u03b2}, (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) a s) -> (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) b t) -> (Membership.mem.{max u1 u2, max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instMembershipFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Prod.mk.{u2, u1} \u03b1 \u03b2 a b) (Finset.product.{u2, u1} \u03b1 \u03b2 s t))\nCase conversion may be inaccurate. Consider using '#align finset.mk_mem_product Finset.mk_mem_product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem mk_mem_product (ha : a \u2208 s) (hb : b \u2208 t) : (a, b) \u2208 s \u00d7\u02e2 t :=\n  mem_product.2 \u27e8ha, hb\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ (max u1 u2)} (Set.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) ((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} \u03b1 \u03b2)) (Set.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (HasLiftT.mk.{succ (max u1 u2), succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Set.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (CoeTC\u2093.coe.{succ (max u1 u2), succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Set.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.Set.hasCoeT.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)))) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) (Set.prod.{u1, u2} \u03b1 \u03b2 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (Finset.Set.hasCoeT.{u1} \u03b1))) s) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (Finset.Set.hasCoeT.{u2} \u03b2))) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (s : Finset.{u2} \u03b1) (t : Finset.{u1} \u03b2), Eq.{max (succ u2) (succ u1)} (Set.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.toSet.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) (Set.prod.{u2, u1} \u03b1 \u03b2 (Finset.toSet.{u2} \u03b1 s) (Finset.toSet.{u1} \u03b2 t))\nCase conversion may be inaccurate. Consider using '#align finset.coe_product Finset.coe_product\u2093'. -/\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 \u03b1) (t : Finset \u03b2) : (\u2191(s \u00d7\u02e2 t) : Set (\u03b1 \u00d7 \u03b2)) = s \u00d7\u02e2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} [_inst_1 : DecidableEq.{succ u1} \u03b1], HasSubset.Subset.{u1} (Finset.{u1} \u03b1) (Finset.hasSubset.{u1} \u03b1) (Finset.image.{max u1 u2, u1} (Prod.{u1, u2} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Prod.fst.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} [_inst_1 : DecidableEq.{succ u2} \u03b1], HasSubset.Subset.{u2} (Finset.{u2} \u03b1) (Finset.instHasSubsetFinset.{u2} \u03b1) (Finset.image.{max u1 u2, u2} (Prod.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Prod.fst.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) s\nCase conversion may be inaccurate. Consider using '#align finset.subset_product_image_fst Finset.subset_product_image_fst\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem subset_product_image_fst [DecidableEq \u03b1] : (s \u00d7\u02e2 t).image Prod.fst \u2286 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 \u03b2] : (s \u00d7\u02e2 t).image Prod.snd \u2286 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} [_inst_1 : DecidableEq.{succ u1} \u03b1], (Finset.Nonempty.{u2} \u03b2 t) -> (Eq.{succ u1} (Finset.{u1} \u03b1) (Finset.image.{max u1 u2, u1} (Prod.{u1, u2} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Prod.fst.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} [_inst_1 : DecidableEq.{succ u2} \u03b1], (Finset.Nonempty.{u1} \u03b2 t) -> (Eq.{succ u2} (Finset.{u2} \u03b1) (Finset.image.{max u1 u2, u2} (Prod.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Prod.fst.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) s)\nCase conversion may be inaccurate. Consider using '#align finset.product_image_fst Finset.product_image_fst\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_image_fst [DecidableEq \u03b1] (ht : t.Nonempty) : (s \u00d7\u02e2 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 \u03b2] (ht : s.Nonempty) : (s \u00d7\u02e2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] {s : Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)}, HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasSubset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) s (Finset.product.{u1, u2} \u03b1 \u03b2 (Finset.image.{max u1 u2, u1} (Prod.{u1, u2} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Prod.fst.{u1, u2} \u03b1 \u03b2) s) (Finset.image.{max u1 u2, u2} (Prod.{u1, u2} \u03b1 \u03b2) \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (Prod.snd.{u1, u2} \u03b1 \u03b2) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] {s : Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)}, HasSubset.Subset.{max u2 u1} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instHasSubsetFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) s (Finset.product.{u2, u1} \u03b1 \u03b2 (Finset.image.{max u1 u2, u2} (Prod.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Prod.fst.{u2, u1} \u03b1 \u03b2) s) (Finset.image.{max u1 u2, u1} (Prod.{u2, u1} \u03b1 \u03b2) \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (Prod.snd.{u2, u1} \u03b1 \u03b2) s))\nCase conversion may be inaccurate. Consider using '#align finset.subset_product Finset.subset_product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem subset_product [DecidableEq \u03b1] [DecidableEq \u03b2] {s : Finset (\u03b1 \u00d7 \u03b2)} :\n    s \u2286 s.image Prod.fst \u00d7\u02e2 s.image Prod.snd := fun p hp =>\n  mem_product.2 \u27e8mem_image_of_mem _ hp, mem_image_of_mem _ hp\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b1) (Finset.hasSubset.{u1} \u03b1) s s') -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b2) (Finset.hasSubset.{u2} \u03b2) t t') -> (HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasSubset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {s' : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {t' : Finset.{u1} \u03b2}, (HasSubset.Subset.{u2} (Finset.{u2} \u03b1) (Finset.instHasSubsetFinset.{u2} \u03b1) s s') -> (HasSubset.Subset.{u1} (Finset.{u1} \u03b2) (Finset.instHasSubsetFinset.{u1} \u03b2) t t') -> (HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instHasSubsetFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s' t'))\nCase conversion may be inaccurate. Consider using '#align finset.product_subset_product Finset.product_subset_product\u2093'. -/\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 \u2286 s') (ht : t \u2286 t') : s \u00d7\u02e2 t \u2286 s' \u00d7\u02e2 t' := fun \u27e8x, y\u27e9 h =>\n  mem_product.2 \u27e8hs (mem_product.1 h).1, ht (mem_product.1 h).2\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b1) (Finset.hasSubset.{u1} \u03b1) s s') -> (HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasSubset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {s' : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (HasSubset.Subset.{u2} (Finset.{u2} \u03b1) (Finset.instHasSubsetFinset.{u2} \u03b1) s s') -> (HasSubset.Subset.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instHasSubsetFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s' t))\nCase conversion may be inaccurate. Consider using '#align finset.product_subset_product_left Finset.product_subset_product_left\u2093'. -/\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 \u2286 s') : s \u00d7\u02e2 t \u2286 s' \u00d7\u02e2 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 \u2286 t') : s \u00d7\u02e2 t \u2286 s \u00d7\u02e2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.map.{max u2 u1, max u1 u2} (Prod.{u2, u1} \u03b2 \u03b1) (Prod.{u1, u2} \u03b1 \u03b2) (Function.Embedding.mk.{succ (max u2 u1), succ (max u1 u2)} (Prod.{u2, u1} \u03b2 \u03b1) (Prod.{u1, u2} \u03b1 \u03b2) (Prod.swap.{u2, u1} \u03b2 \u03b1) (Prod.swap_injective.{u2, u1} \u03b2 \u03b1)) (Finset.product.{u2, u1} \u03b2 \u03b1 t s)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (s : Finset.{u2} \u03b1) (t : Finset.{u1} \u03b2), Eq.{max (succ u2) (succ u1)} (Finset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.map.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b2 \u03b1) (Prod.{u2, u1} \u03b1 \u03b2) (Function.Embedding.mk.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u1, u2} \u03b2 \u03b1) (Prod.{u2, u1} \u03b1 \u03b2) (Prod.swap.{u1, u2} \u03b2 \u03b1) (Prod.swap_injective.{u2, u1} \u03b2 \u03b1)) (Finset.product.{u1, u2} \u03b2 \u03b1 t s)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)\nCase conversion may be inaccurate. Consider using '#align finset.map_swap_product Finset.map_swap_product\u2093'. -/\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 \u03b1) (t : Finset \u03b2) :\n    (t \u00d7\u02e2 s).map \u27e8Prod.swap, Prod.swap_injective\u27e9 = s \u00d7\u02e2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.image.{max u2 u1, max u1 u2} (Prod.{u2, u1} \u03b2 \u03b1) (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b) (Prod.swap.{u2, u1} \u03b2 \u03b1) (Finset.product.{u2, u1} \u03b2 \u03b1 t s)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{max (succ u2) (succ u1)} (Prod.{u1, u2} \u03b1 \u03b2)] (_inst_2 : Finset.{u1} \u03b1) (s : Finset.{u2} \u03b2), Eq.{max (succ u1) (succ u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.image.{max u1 u2, max u1 u2} (Prod.{u2, u1} \u03b2 \u03b1) (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => _inst_1 a b) (Prod.swap.{u2, u1} \u03b2 \u03b1) (Finset.product.{u2, u1} \u03b2 \u03b1 s _inst_2)) (Finset.product.{u1, u2} \u03b1 \u03b2 _inst_2 s)\nCase conversion may be inaccurate. Consider using '#align finset.image_swap_product Finset.image_swap_product\u2093'. -/\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 \u03b1] [DecidableEq \u03b2] (s : Finset \u03b1) (t : Finset \u03b2) :\n    (t \u00d7\u02e2 s).image Prod.swap = s \u00d7\u02e2 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\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.bunion\u1d62.{u1, max u1 u2} \u03b1 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b) s (fun (a : \u03b1) => Finset.image.{u2, max u1 u2} \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b) (fun (b : \u03b2) => Prod.mk.{u1, u2} \u03b1 \u03b2 a b) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{max (succ u2) (succ u1)} (Prod.{u1, u2} \u03b1 \u03b2)] (_inst_2 : Finset.{u1} \u03b1) (s : Finset.{u2} \u03b2), Eq.{max (succ u1) (succ u2)} (Finset.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 _inst_2 s) (Finset.bunion\u1d62.{u1, max u2 u1} \u03b1 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => Finset.image.{u2, max u2 u1} \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => _inst_1 a b) (fun (b : \u03b2) => Prod.mk.{u1, u2} \u03b1 \u03b2 a b) s))\nCase conversion may be inaccurate. Consider using '#align finset.product_eq_bUnion Finset.product_eq_bunion\u1d62\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_eq_bunion\u1d62 [DecidableEq \u03b1] [DecidableEq \u03b2] (s : Finset \u03b1) (t : Finset \u03b2) :\n    s \u00d7\u02e2 t = s.bunion\u1d62 fun a => t.image fun b => (a, b) :=\n  ext fun \u27e8x, y\u27e9 => 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\u1d62\n\n/- warning: finset.product_eq_bUnion_right -> Finset.product_eq_bunion\u1d62_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.bunion\u1d62.{u2, max u1 u2} \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b) t (fun (b : \u03b2) => Finset.image.{u1, max u1 u2} \u03b1 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b) (fun (a : \u03b1) => Prod.mk.{u1, u2} \u03b1 \u03b2 a b) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{max (succ u2) (succ u1)} (Prod.{u1, u2} \u03b1 \u03b2)] (_inst_2 : Finset.{u1} \u03b1) (s : Finset.{u2} \u03b2), Eq.{max (succ u1) (succ u2)} (Finset.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 _inst_2 s) (Finset.bunion\u1d62.{u2, max u2 u1} \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => _inst_1 a b) s (fun (b : \u03b2) => Finset.image.{u1, max u2 u1} \u03b1 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => _inst_1 a b) (fun (a : \u03b1) => Prod.mk.{u1, u2} \u03b1 \u03b2 a b) _inst_2))\nCase conversion may be inaccurate. Consider using '#align finset.product_eq_bUnion_right Finset.product_eq_bunion\u1d62_right\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_eq_bunion\u1d62_right [DecidableEq \u03b1] [DecidableEq \u03b2] (s : Finset \u03b1) (t : Finset \u03b2) :\n    s \u00d7\u02e2 t = t.bunion\u1d62 fun b => s.image fun a => (a, b) :=\n  ext fun \u27e8x, y\u27e9 => 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\u1d62_right\n\n/- warning: finset.product_bUnion -> Finset.product_bunion\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : DecidableEq.{succ u3} \u03b3] (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2) (f : (Prod.{u1, u2} \u03b1 \u03b2) -> (Finset.{u3} \u03b3)), Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.bunion\u1d62.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) f) (Finset.bunion\u1d62.{u1, u3} \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) s (fun (a : \u03b1) => Finset.bunion\u1d62.{u2, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) t (fun (b : \u03b2) => f (Prod.mk.{u1, u2} \u03b1 \u03b2 a b))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_1 : DecidableEq.{succ u3} \u03b3] (s : Finset.{u2} \u03b1) (t : Finset.{u1} \u03b2) (f : (Prod.{u2, u1} \u03b1 \u03b2) -> (Finset.{u3} \u03b3)), Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.bunion\u1d62.{max u2 u1, u3} (Prod.{u2, u1} \u03b1 \u03b2) \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) f) (Finset.bunion\u1d62.{u2, u3} \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) s (fun (a : \u03b1) => Finset.bunion\u1d62.{u1, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) t (fun (b : \u03b2) => f (Prod.mk.{u2, u1} \u03b1 \u03b2 a b))))\nCase conversion may be inaccurate. Consider using '#align finset.product_bUnion Finset.product_bunion\u1d62\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- See also `finset.sup_product_left`. -/\n@[simp]\ntheorem product_bunion\u1d62 [DecidableEq \u03b3] (s : Finset \u03b1) (t : Finset \u03b2) (f : \u03b1 \u00d7 \u03b2 \u2192 Finset \u03b3) :\n    (s \u00d7\u02e2 t).bunion\u1d62 f = s.bunion\u1d62 fun a => t.bunion\u1d62 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\u1d62\n\n/- warning: finset.card_product -> Finset.card_product is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{1} Nat (Finset.card.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} \u03b1 s) (Finset.card.{u2} \u03b2 t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (s : Finset.{u2} \u03b1) (t : Finset.{u1} \u03b2), Eq.{1} Nat (Finset.card.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u2} \u03b1 s) (Finset.card.{u1} \u03b2 t))\nCase conversion may be inaccurate. Consider using '#align finset.card_product Finset.card_product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem card_product (s : Finset \u03b1) (t : Finset \u03b2) : card (s \u00d7\u02e2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} (p : \u03b1 -> Prop) (q : \u03b2 -> Prop) [_inst_1 : DecidablePred.{succ u1} \u03b1 p] [_inst_2 : DecidablePred.{succ u2} \u03b2 q], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.filter.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (fun (x : Prod.{u1, u2} \u03b1 \u03b2) => And (p (Prod.fst.{u1, u2} \u03b1 \u03b2 x)) (q (Prod.snd.{u1, u2} \u03b1 \u03b2 x))) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) => And.decidable (p (Prod.fst.{u1, u2} \u03b1 \u03b2 a)) (q (Prod.snd.{u1, u2} \u03b1 \u03b2 a)) (_inst_1 (Prod.fst.{u1, u2} \u03b1 \u03b2 a)) (_inst_2 (Prod.snd.{u1, u2} \u03b1 \u03b2 a))) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) (Finset.product.{u1, u2} \u03b1 \u03b2 (Finset.filter.{u1} \u03b1 p (fun (a : \u03b1) => _inst_1 a) s) (Finset.filter.{u2} \u03b2 q (fun (a : \u03b2) => _inst_2 a) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} (p : \u03b1 -> Prop) (q : \u03b2 -> Prop) [_inst_1 : DecidablePred.{succ u2} \u03b1 p] [_inst_2 : DecidablePred.{succ u1} \u03b2 q], Eq.{max (succ u2) (succ u1)} (Finset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.filter.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (fun (x : Prod.{u2, u1} \u03b1 \u03b2) => And (p (Prod.fst.{u2, u1} \u03b1 \u03b2 x)) (q (Prod.snd.{u2, u1} \u03b1 \u03b2 x))) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) => instDecidableAnd (p (Prod.fst.{u2, u1} \u03b1 \u03b2 a)) (q (Prod.snd.{u2, u1} \u03b1 \u03b2 a)) (_inst_1 (Prod.fst.{u2, u1} \u03b1 \u03b2 a)) (_inst_2 (Prod.snd.{u2, u1} \u03b1 \u03b2 a))) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) (Finset.product.{u2, u1} \u03b1 \u03b2 (Finset.filter.{u2} \u03b1 p (fun (a : \u03b1) => _inst_1 a) s) (Finset.filter.{u1} \u03b2 q (fun (a : \u03b2) => _inst_2 a) t))\nCase conversion may be inaccurate. Consider using '#align finset.filter_product Finset.filter_product\u2093'. -/\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 : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) [DecidablePred p] [DecidablePred q] :\n    ((s \u00d7\u02e2 t).filter\u2093 fun x : \u03b1 \u00d7 \u03b2 => p x.1 \u2227 q x.2) = s.filter\u2093 p \u00d7\u02e2 t.filter\u2093 q :=\n  by\n  ext \u27e8a, b\u27e9\n  simp only [mem_filter, mem_product]\n  exact and_and_and_comm (a \u2208 s) (b \u2208 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} (p : \u03b1 -> Prop) [_inst_1 : DecidablePred.{succ u1} \u03b1 p], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.filter.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (fun (x : Prod.{u1, u2} \u03b1 \u03b2) => p (Prod.fst.{u1, u2} \u03b1 \u03b2 x)) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) => _inst_1 (Prod.fst.{u1, u2} \u03b1 \u03b2 a)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) (Finset.product.{u1, u2} \u03b1 \u03b2 (Finset.filter.{u1} \u03b1 p (fun (a : \u03b1) => _inst_1 a) s) t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} (p : \u03b1 -> Prop) [_inst_1 : DecidablePred.{succ u2} \u03b1 p], Eq.{max (succ u2) (succ u1)} (Finset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.filter.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (fun (x : Prod.{u2, u1} \u03b1 \u03b2) => p (Prod.fst.{u2, u1} \u03b1 \u03b2 x)) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) => _inst_1 (Prod.fst.{u2, u1} \u03b1 \u03b2 a)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) (Finset.product.{u2, u1} \u03b1 \u03b2 (Finset.filter.{u2} \u03b1 p (fun (a : \u03b1) => _inst_1 a) s) t)\nCase conversion may be inaccurate. Consider using '#align finset.filter_product_left Finset.filter_product_left\u2093'. -/\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 : \u03b1 \u2192 Prop) [DecidablePred p] :\n    ((s \u00d7\u02e2 t).filter\u2093 fun x : \u03b1 \u00d7 \u03b2 => p x.1) = s.filter\u2093 p \u00d7\u02e2 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 : \u03b2 \u2192 Prop) [DecidablePred q] :\n    ((s \u00d7\u02e2 t).filter\u2093 fun x : \u03b1 \u00d7 \u03b2 => q x.2) = s \u00d7\u02e2 t.filter\u2093 q := by\n  simpa using filter_product (fun _ : \u03b1 => 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2) (p : \u03b1 -> Prop) (q : \u03b2 -> Prop) [_inst_1 : DecidablePred.{succ u1} \u03b1 p] [_inst_2 : DecidablePred.{succ u2} \u03b2 q], Eq.{1} Nat (Finset.card.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.filter.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (fun (x : Prod.{u1, u2} \u03b1 \u03b2) => Iff (p (Prod.fst.{u1, u2} \u03b1 \u03b2 x)) (q (Prod.snd.{u1, u2} \u03b1 \u03b2 x))) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) => Iff.decidable (p (Prod.fst.{u1, u2} \u03b1 \u03b2 a)) (q (Prod.snd.{u1, u2} \u03b1 \u03b2 a)) (_inst_1 (Prod.fst.{u1, u2} \u03b1 \u03b2 a)) (_inst_2 (Prod.snd.{u1, u2} \u03b1 \u03b2 a))) (Finset.product.{u1, u2} \u03b1 \u03b2 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} \u03b1 (Finset.filter.{u1} \u03b1 p (fun (a : \u03b1) => _inst_1 a) s)) (Finset.card.{u2} \u03b2 (Finset.filter.{u2} \u03b2 q (fun (a : \u03b2) => _inst_2 a) t))) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} \u03b1 (Finset.filter.{u1} \u03b1 (Function.comp.{succ u1, 1, 1} \u03b1 Prop Prop Not p) (fun (a : \u03b1) => Not.decidable (p a) (_inst_1 a)) s)) (Finset.card.{u2} \u03b2 (Finset.filter.{u2} \u03b2 (Function.comp.{succ u2, 1, 1} \u03b2 Prop Prop Not q) (fun (a : \u03b2) => Not.decidable (q a) (_inst_2 a)) t))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (s : Finset.{u2} \u03b1) (t : Finset.{u1} \u03b2) (p : \u03b1 -> Prop) (q : \u03b2 -> Prop) [_inst_1 : DecidablePred.{succ u2} \u03b1 p] [_inst_2 : DecidablePred.{succ u1} \u03b2 q], Eq.{1} Nat (Finset.card.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.filter.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (fun (x : Prod.{u2, u1} \u03b1 \u03b2) => Eq.{1} Prop (p (Prod.fst.{u2, u1} \u03b1 \u03b2 x)) (q (Prod.snd.{u2, u1} \u03b1 \u03b2 x))) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) => instDecidableEqProp (p (Prod.fst.{u2, u1} \u03b1 \u03b2 a)) (q (Prod.snd.{u2, u1} \u03b1 \u03b2 a)) (instDecidableIff (p (Prod.fst.{u2, u1} \u03b1 \u03b2 a)) (q (Prod.snd.{u2, u1} \u03b1 \u03b2 a)) (_inst_1 (Prod.fst.{u2, u1} \u03b1 \u03b2 a)) (_inst_2 (Prod.snd.{u2, u1} \u03b1 \u03b2 a)))) (Finset.product.{u2, u1} \u03b1 \u03b2 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} \u03b1 (Finset.filter.{u2} \u03b1 p (fun (a : \u03b1) => _inst_1 a) s)) (Finset.card.{u1} \u03b2 (Finset.filter.{u1} \u03b2 q (fun (a : \u03b2) => _inst_2 a) t))) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u2} \u03b1 (Finset.filter.{u2} \u03b1 (fun (x._@.Mathlib.Data.Finset.Prod._hyg.1940 : \u03b1) => Not (p x._@.Mathlib.Data.Finset.Prod._hyg.1940)) (fun (a : \u03b1) => instDecidableNot (p a) (_inst_1 a)) s)) (Finset.card.{u1} \u03b2 (Finset.filter.{u1} \u03b2 (fun (x._@.Mathlib.Data.Finset.Prod._hyg.1956 : \u03b2) => Not (q x._@.Mathlib.Data.Finset.Prod._hyg.1956)) (fun (a : \u03b2) => instDecidableNot (q a) (_inst_2 a)) t))))\nCase conversion may be inaccurate. Consider using '#align finset.filter_product_card Finset.filter_product_card\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem filter_product_card (s : Finset \u03b1) (t : Finset \u03b2) (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop)\n    [DecidablePred p] [DecidablePred q] :\n    ((s \u00d7\u02e2 t).filter\u2093 fun x : \u03b1 \u00d7 \u03b2 => p x.1 \u2194 q x.2).card =\n      (s.filter\u2093 p).card * (t.filter\u2093 q).card +\n        (s.filter\u2093 (Not \u2218 p)).card * (t.filter\u2093 (Not \u2218 q)).card :=\n  by\n  classical\n    rw [\u2190 card_product, \u2190 card_product, \u2190 filter_product, \u2190 filter_product, \u2190 card_union_eq]\n    \u00b7 apply congr_arg\n      ext \u27e8a, b\u27e9\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        \u00b7 try simp at h_1\n          simp [h_1]\n    \u00b7 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 \u03b2) : (\u2205 : Finset \u03b1) \u00d7\u02e2 t = \u2205 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (s : Finset.{u1} \u03b1), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b2) (Finset.hasEmptyc.{u2} \u03b2))) (EmptyCollection.emptyCollection.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasEmptyc.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (s : Finset.{u2} \u03b1), Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 s (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b2) (Finset.instEmptyCollectionFinset.{u1} \u03b2))) (EmptyCollection.emptyCollection.{max u2 u1} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instEmptyCollectionFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)))\nCase conversion may be inaccurate. Consider using '#align finset.product_empty Finset.product_empty\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_empty (s : Finset \u03b1) : s \u00d7\u02e2 (\u2205 : Finset \u03b2) = \u2205 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (Finset.Nonempty.{u1} \u03b1 s) -> (Finset.Nonempty.{u2} \u03b2 t) -> (Finset.Nonempty.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (Finset.Nonempty.{u2} \u03b1 s) -> (Finset.Nonempty.{u1} \u03b2 t) -> (Finset.Nonempty.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t))\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.product Finset.Nonempty.product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Nonempty.product (hs : s.Nonempty) (ht : t.Nonempty) : (s \u00d7\u02e2 t).Nonempty :=\n  let \u27e8x, hx\u27e9 := hs\n  let \u27e8y, hy\u27e9 := ht\n  \u27e8(x, y), mem_product.2 \u27e8hx, hy\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (Finset.Nonempty.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) -> (Finset.Nonempty.{u1} \u03b1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (Finset.Nonempty.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) -> (Finset.Nonempty.{u2} \u03b1 s)\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.fst Finset.Nonempty.fst\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Nonempty.fst (h : (s \u00d7\u02e2 t).Nonempty) : s.Nonempty :=\n  let \u27e8xy, hxy\u27e9 := h\n  \u27e8xy.1, (mem_product.1 hxy).1\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (Finset.Nonempty.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) -> (Finset.Nonempty.{u2} \u03b2 t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (Finset.Nonempty.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) -> (Finset.Nonempty.{u1} \u03b2 t)\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.snd Finset.Nonempty.snd\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem Nonempty.snd (h : (s \u00d7\u02e2 t).Nonempty) : t.Nonempty :=\n  let \u27e8xy, hxy\u27e9 := h\n  \u27e8xy.2, (mem_product.1 hxy).2\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, Iff (Finset.Nonempty.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) (And (Finset.Nonempty.{u1} \u03b1 s) (Finset.Nonempty.{u2} \u03b2 t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, Iff (Finset.Nonempty.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)) (And (Finset.Nonempty.{u2} \u03b1 s) (Finset.Nonempty.{u1} \u03b2 t))\nCase conversion may be inaccurate. Consider using '#align finset.nonempty_product Finset.nonempty_product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem nonempty_product : (s \u00d7\u02e2 t).Nonempty \u2194 s.Nonempty \u2227 t.Nonempty :=\n  \u27e8fun h => \u27e8h.fst, h.snd\u27e9, fun h => h.1.product h.2\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, Iff (Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (EmptyCollection.emptyCollection.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasEmptyc.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)))) (Or (Eq.{succ u1} (Finset.{u1} \u03b1) s (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b1) (Finset.hasEmptyc.{u1} \u03b1))) (Eq.{succ u2} (Finset.{u2} \u03b2) t (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b2) (Finset.hasEmptyc.{u2} \u03b2))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, Iff (Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (EmptyCollection.emptyCollection.{max u2 u1} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instEmptyCollectionFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)))) (Or (Eq.{succ u2} (Finset.{u2} \u03b1) s (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b1) (Finset.instEmptyCollectionFinset.{u2} \u03b1))) (Eq.{succ u1} (Finset.{u1} \u03b2) t (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b2) (Finset.instEmptyCollectionFinset.{u1} \u03b2))))\nCase conversion may be inaccurate. Consider using '#align finset.product_eq_empty Finset.product_eq_empty\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem product_eq_empty {s : Finset \u03b1} {t : Finset \u03b2} : s \u00d7\u02e2 t = \u2205 \u2194 s = \u2205 \u2228 t = \u2205 := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {t : Finset.{u2} \u03b2} {a : \u03b1}, Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) t) (Finset.map.{u2, max u1 u2} \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) (Function.Embedding.mk.{succ u2, succ (max u1 u2)} \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) (Prod.mk.{u1, u2} \u03b1 \u03b2 a) (Prod.mk.inj_left.{u1, u2} \u03b1 \u03b2 a)) t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {t : Finset.{u1} \u03b2} {a : \u03b1}, Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 (Singleton.singleton.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instSingletonFinset.{u2} \u03b1) a) t) (Finset.map.{u1, max u1 u2} \u03b2 (Prod.{u2, u1} \u03b1 \u03b2) (Function.Embedding.mk.{succ u1, succ (max u1 u2)} \u03b2 (Prod.{u2, u1} \u03b1 \u03b2) (Prod.mk.{u2, u1} \u03b1 \u03b2 a) (Prod.mk.inj_left.{u1, u2} \u03b1 \u03b2 a)) t)\nCase conversion may be inaccurate. Consider using '#align finset.singleton_product Finset.singleton_product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem singleton_product {a : \u03b1} : ({a} : Finset \u03b1) \u00d7\u02e2 t = t.map \u27e8Prod.mk a, Prod.mk.inj_left _\u27e9 :=\n  by\n  ext \u27e8x, y\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {b : \u03b2}, Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s (Singleton.singleton.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasSingleton.{u2} \u03b2) b)) (Finset.map.{u1, max u1 u2} \u03b1 (Prod.{u1, u2} \u03b1 \u03b2) (Function.Embedding.mk.{succ u1, succ (max u1 u2)} \u03b1 (Prod.{u1, u2} \u03b1 \u03b2) (fun (i : \u03b1) => Prod.mk.{u1, u2} \u03b1 \u03b2 i b) (Prod.mk.inj_right.{u1, u2} \u03b1 \u03b2 b)) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {b : \u03b2}, Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 s (Singleton.singleton.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instSingletonFinset.{u1} \u03b2) b)) (Finset.map.{u2, max u1 u2} \u03b1 (Prod.{u2, u1} \u03b1 \u03b2) (Function.Embedding.mk.{succ u2, succ (max u1 u2)} \u03b1 (Prod.{u2, u1} \u03b1 \u03b2) (fun (i : \u03b1) => Prod.mk.{u2, u1} \u03b1 \u03b2 i b) (Prod.mk.inj_right.{u1, u2} \u03b1 \u03b2 b)) s)\nCase conversion may be inaccurate. Consider using '#align finset.product_singleton Finset.product_singleton\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem product_singleton {b : \u03b2} : s \u00d7\u02e2 {b} = s.map \u27e8fun i => (i, b), Prod.mk.inj_right _\u27e9 :=\n  by\n  ext \u27e8x, y\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {a : \u03b1} {b : \u03b2}, Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) (Singleton.singleton.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasSingleton.{u2} \u03b2) b)) (Singleton.singleton.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasSingleton.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.mk.{u1, u2} \u03b1 \u03b2 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {a : \u03b1} {b : \u03b2}, Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 (Singleton.singleton.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instSingletonFinset.{u2} \u03b1) a) (Singleton.singleton.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instSingletonFinset.{u1} \u03b2) b)) (Singleton.singleton.{max u1 u2, max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instSingletonFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Prod.mk.{u2, u1} \u03b1 \u03b2 a b))\nCase conversion may be inaccurate. Consider using '#align finset.singleton_product_singleton Finset.singleton_product_singleton\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem singleton_product_singleton {a : \u03b1} {b : \u03b2} :\n    ({a} : Finset \u03b1) \u00d7\u02e2 ({b} : Finset \u03b2) = {(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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s s') t) (Union.union.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasUnion.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {s' : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 (Union.union.{u2} (Finset.{u2} \u03b1) (Finset.instUnionFinset.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s s') t) (Union.union.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instUnionFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) (b : Prod.{u2, u1} \u03b1 \u03b2) => instDecidableEqProd.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s' t))\nCase conversion may be inaccurate. Consider using '#align finset.union_product Finset.union_product\u2093'. -/\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 \u03b1] [DecidableEq \u03b2] : (s \u222a s') \u00d7\u02e2 t = s \u00d7\u02e2 t \u222a s' \u00d7\u02e2 t :=\n  by\n  ext \u27e8x, y\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s (Union.union.{u2} (Finset.{u2} \u03b2) (Finset.hasUnion.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b)) t t')) (Union.union.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasUnion.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {t' : Finset.{u1} \u03b2} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 s (Union.union.{u1} (Finset.{u1} \u03b2) (Finset.instUnionFinset.{u1} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b)) t t')) (Union.union.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instUnionFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) (b : Prod.{u2, u1} \u03b1 \u03b2) => instDecidableEqProd.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s t'))\nCase conversion may be inaccurate. Consider using '#align finset.product_union Finset.product_union\u2093'. -/\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 \u03b1] [DecidableEq \u03b2] : s \u00d7\u02e2 (t \u222a t') = s \u00d7\u02e2 t \u222a s \u00d7\u02e2 t' :=\n  by\n  ext \u27e8x, y\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s s') t) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasInter.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {s' : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 (Inter.inter.{u2} (Finset.{u2} \u03b1) (Finset.instInterFinset.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s s') t) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instInterFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) (b : Prod.{u2, u1} \u03b1 \u03b2) => instDecidableEqProd.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s' t))\nCase conversion may be inaccurate. Consider using '#align finset.inter_product Finset.inter_product\u2093'. -/\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 \u03b1] [DecidableEq \u03b2] : (s \u2229 s') \u00d7\u02e2 t = s \u00d7\u02e2 t \u2229 s' \u00d7\u02e2 t :=\n  by\n  ext \u27e8x, y\u27e9\n  simp only [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s (Inter.inter.{u2} (Finset.{u2} \u03b2) (Finset.hasInter.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b)) t t')) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasInter.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {t' : Finset.{u1} \u03b2} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 s (Inter.inter.{u1} (Finset.{u1} \u03b2) (Finset.instInterFinset.{u1} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b)) t t')) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instInterFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) (b : Prod.{u2, u1} \u03b1 \u03b2) => instDecidableEqProd.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s t'))\nCase conversion may be inaccurate. Consider using '#align finset.product_inter Finset.product_inter\u2093'. -/\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 \u03b1] [DecidableEq \u03b2] : s \u00d7\u02e2 (t \u2229 t') = s \u00d7\u02e2 t \u2229 s \u00d7\u02e2 t' :=\n  by\n  ext \u27e8x, y\u27e9\n  simp only [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2], Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.hasInter.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t')) (Finset.product.{u1, u2} \u03b1 \u03b2 (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s s') (Inter.inter.{u2} (Finset.{u2} \u03b2) (Finset.hasInter.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b)) t t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {s' : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {t' : Finset.{u1} \u03b2} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2], Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Inter.inter.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instInterFinset.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) (b : Prod.{u2, u1} \u03b1 \u03b2) => instDecidableEqProd.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s' t')) (Finset.product.{u2, u1} \u03b1 \u03b2 (Inter.inter.{u2} (Finset.{u2} \u03b1) (Finset.instInterFinset.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s s') (Inter.inter.{u1} (Finset.{u1} \u03b2) (Finset.instInterFinset.{u1} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b)) t t'))\nCase conversion may be inaccurate. Consider using '#align finset.product_inter_product Finset.product_inter_product\u2093'. -/\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 \u03b1] [DecidableEq \u03b2] :\n    s \u00d7\u02e2 t \u2229 s' \u00d7\u02e2 t' = (s \u2229 s') \u00d7\u02e2 (t \u2229 t') :=\n  by\n  ext \u27e8x, y\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2}, Iff (Disjoint.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.orderBot.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t')) (Or (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.orderBot.{u1} \u03b1) s s') (Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.orderBot.{u2} \u03b2) t t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2}, Iff (Disjoint.{max u2 u1} (Finset.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t')) (Or (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1) s s') (Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} \u03b2) t t'))\nCase conversion may be inaccurate. Consider using '#align finset.disjoint_product Finset.disjoint_product\u2093'. -/\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 \u00d7\u02e2 t) (s' \u00d7\u02e2 t') \u2194 Disjoint s s' \u2228 Disjoint t t' := by\n  simp_rw [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} (hs : Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.orderBot.{u1} \u03b1) s s'), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 (Finset.disjUnion.{u1} \u03b1 s s' hs) t) (Finset.disjUnion.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t) (Iff.mpr (Disjoint.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.orderBot.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s' t)) (Or (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.orderBot.{u1} \u03b1) s s') (Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.orderBot.{u2} \u03b2) t t)) (Finset.disjoint_product.{u1, u2} \u03b1 \u03b2 s s' t t) (Or.inl (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.orderBot.{u1} \u03b1) s s') (Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.orderBot.{u2} \u03b2) t t) hs)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {s' : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} (hs : Disjoint.{u2} (Finset.{u2} \u03b1) (Finset.partialOrder.{u2} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} \u03b1) s s'), Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 (Finset.disjUnion.{u2} \u03b1 s s' hs) t) (Finset.disjUnion.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s' t) (Iff.mpr (Disjoint.{max u1 u2} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.partialOrder.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.product.{u2, u1} \u03b1 \u03b2 s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s' t)) (Or (Disjoint.{u2} (Finset.{u2} \u03b1) (Finset.partialOrder.{u2} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} \u03b1) s s') (Disjoint.{u1} (Finset.{u1} \u03b2) (Finset.partialOrder.{u1} \u03b2) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b2) t t)) (Finset.disjoint_product.{u2, u1} \u03b1 \u03b2 s s' t t) (Or.inl (Disjoint.{u2} (Finset.{u2} \u03b1) (Finset.partialOrder.{u2} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} \u03b1) s s') (Disjoint.{u1} (Finset.{u1} \u03b2) (Finset.partialOrder.{u1} \u03b2) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b2) t t) hs)))\nCase conversion may be inaccurate. Consider using '#align finset.disj_union_product Finset.disjUnion_product\u2093'. -/\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 \u00d7\u02e2 t = (s \u00d7\u02e2 t).disjUnion (s' \u00d7\u02e2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2} (ht : Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.orderBot.{u2} \u03b2) t t'), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s (Finset.disjUnion.{u2} \u03b2 t t' ht)) (Finset.disjUnion.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s t') (Iff.mpr (Disjoint.{max u1 u2} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.orderBot.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s t')) (Or (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.orderBot.{u1} \u03b1) s s) (Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.orderBot.{u2} \u03b2) t t')) (Finset.disjoint_product.{u1, u2} \u03b1 \u03b2 s s t t') (Or.inr (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.orderBot.{u1} \u03b1) s s) (Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.orderBot.{u2} \u03b2) t t') ht)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2} (ht : Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} \u03b2) t t'), Eq.{max (succ u1) (succ u2)} (Finset.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s (Finset.disjUnion.{u2} \u03b2 t t' ht)) (Finset.disjUnion.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s t') (Iff.mpr (Disjoint.{max u2 u1} (Finset.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.partialOrder.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.product.{u1, u2} \u03b1 \u03b2 s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s t')) (Or (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1) s s) (Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} \u03b2) t t')) (Finset.disjoint_product.{u1, u2} \u03b1 \u03b2 s s t t') (Or.inr (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1) s s) (Disjoint.{u2} (Finset.{u2} \u03b2) (Finset.partialOrder.{u2} \u03b2) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} \u03b2) t t') ht)))\nCase conversion may be inaccurate. Consider using '#align finset.product_disj_union Finset.product_disjUnion\u2093'. -/\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 \u00d7\u02e2 t.disjUnion t' ht = (s \u00d7\u02e2 t).disjUnion (s \u00d7\u02e2 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 \u03b1] (s t : Finset \u03b1)\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 \u2208 s`. -/\ndef diag :=\n  (s \u00d7\u02e2 s).filter\u2093 fun a : \u03b1 \u00d7 \u03b1 => 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 \u2260 b`\nfor `a, b \u2208 s`. -/\ndef offDiag :=\n  (s \u00d7\u02e2 s).filter\u2093 fun a : \u03b1 \u00d7 \u03b1 => a.fst \u2260 a.snd\n#align finset.off_diag Finset.offDiag\n-/\n\nvariable {s} {x : \u03b1 \u00d7 \u03b1}\n\n#print Finset.mem_diag /-\n@[simp]\ntheorem mem_diag : x \u2208 s.diag \u2194 x.1 \u2208 s \u2227 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 [\u2190 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 \u2208 s.offDiag \u2194 x.1 \u2208 s \u2227 x.2 \u2208 s \u2227 x.1 \u2260 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 (\u03b1 \u00d7 \u03b1)) = (s : Set \u03b1).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 \u27e8a\u2081, a\u2082\u27e9\n  rw [mem_diag]\n  constructor <;> intro h <;> rw [Finset.mem_image] at *\n  \u00b7 use a\u2081, h.1, prod.mk.inj_iff.mpr \u27e8rfl, h.2\u27e9\n  \u00b7 rcases h with \u27e8a, h1, h2\u27e9\n    have h := Prod.mk.inj h2\n    rw [\u2190 h.1, \u2190 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 [\u2190 s.diag_card]\n    simp only [diag_card] at *\n    rw [tsub_eq_of_eq_add_rev]\n    rw [this]\n  rw [\u2190 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 \u03b1 \u2192 Finset (\u03b1 \u00d7 \u03b1)) := 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 \u03b1 \u2192 Finset (\u03b1 \u00d7 \u03b1)) := 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 : (\u2205 : Finset \u03b1).diag = \u2205 :=\n  rfl\n#align finset.diag_empty Finset.diag_empty\n-/\n\n#print Finset.offDiag_empty /-\n@[simp]\ntheorem offDiag_empty : (\u2205 : Finset \u03b1).offDiag = \u2205 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasUnion.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)) (Finset.product.{u1, u1} \u03b1 \u03b1 s s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)) (Finset.product.{u1, u1} \u03b1 \u03b1 s s)\nCase conversion may be inaccurate. Consider using '#align finset.diag_union_off_diag Finset.diag_union_offDiag\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem diag_union_offDiag : s.diag \u222a s.offDiag = s \u00d7\u02e2 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Disjoint.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.orderBot.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Disjoint.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)\nCase conversion may be inaccurate. Consider using '#align finset.disjoint_diag_off_diag Finset.disjoint_diag_offDiag\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (SDiff.sdiff.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasSdiff.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.product.{u1, u1} \u03b1 \u03b1 s s) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (SDiff.sdiff.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instSDiffFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.product.{u1, u1} \u03b1 \u03b1 s s) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)\nCase conversion may be inaccurate. Consider using '#align finset.product_sdiff_diag Finset.product_sdiff_diag\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_sdiff_diag : s \u00d7\u02e2 s \\ s.diag = s.offDiag := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (SDiff.sdiff.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasSdiff.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.product.{u1, u1} \u03b1 \u03b1 s s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (SDiff.sdiff.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instSDiffFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.product.{u1, u1} \u03b1 \u03b1 s s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)\nCase conversion may be inaccurate. Consider using '#align finset.product_sdiff_off_diag Finset.product_sdiff_offDiag\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem product_sdiff_offDiag : s \u00d7\u02e2 s \\ s.offDiag = s.diag := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1) (t : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s t)) (Inter.inter.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasInter.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1) (t : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.instInterFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s t)) (Inter.inter.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instInterFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t))\nCase conversion may be inaccurate. Consider using '#align finset.diag_inter Finset.diag_inter\u2093'. -/\ntheorem diag_inter : (s \u2229 t).diag = s.diag \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1) (t : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s t)) (Inter.inter.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasInter.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1) (t : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.instInterFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s t)) (Inter.inter.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instInterFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t))\nCase conversion may be inaccurate. Consider using '#align finset.off_diag_inter Finset.offDiag_inter\u2093'. -/\ntheorem offDiag_inter : (s \u2229 t).offDiag = s.offDiag \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1) (t : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s t)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasUnion.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1) (t : Finset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.instUnionFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s t)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t))\nCase conversion may be inaccurate. Consider using '#align finset.diag_union Finset.diag_union\u2093'. -/\ntheorem diag_union : (s \u222a t).diag = s.diag \u222a t.diag :=\n  by\n  ext \u27e8i, j\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u1} \u03b1} {t : Finset.{u1} \u03b1}, (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.orderBot.{u1} \u03b1) s t) -> (Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s t)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasUnion.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasUnion.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasUnion.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t)) (Finset.product.{u1, u1} \u03b1 \u03b1 s t)) (Finset.product.{u1, u1} \u03b1 \u03b1 t s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u1} \u03b1} {t : Finset.{u1} \u03b1}, (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1) s t) -> (Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.instUnionFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) s t)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t)) (Finset.product.{u1, u1} \u03b1 \u03b1 s t)) (Finset.product.{u1, u1} \u03b1 \u03b1 t s)))\nCase conversion may be inaccurate. Consider using '#align finset.off_diag_union Finset.offDiag_union\u2093'. -/\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 \u222a t).offDiag = s.offDiag \u222a t.offDiag \u222a s \u00d7\u02e2 t \u222a t \u00d7\u02e2 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 : \u03b1)\n\n#print Finset.offDiag_singleton /-\n@[simp]\ntheorem offDiag_singleton : ({a} : Finset \u03b1).offDiag = \u2205 := by simp [\u2190 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 \u03b1).diag = {(a, a)} := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u1} \u03b1} (a : \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Insert.insert.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasInsert.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) a s)) (Insert.insert.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasInsert.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a a) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u1} \u03b1} (a : \u03b1), Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Insert.insert.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instInsertFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) a s)) (Insert.insert.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instInsertFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a a) (Finset.diag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s))\nCase conversion may be inaccurate. Consider using '#align finset.diag_insert Finset.diag_insert\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u1} \u03b1} (a : \u03b1), (Not (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s)) -> (Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Insert.insert.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasInsert.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) a s)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasUnion.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.hasUnion.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => Prod.decidableEq.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.product.{u1, u1} \u03b1 \u03b1 (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) s)) (Finset.product.{u1, u1} \u03b1 \u03b1 s (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u1} \u03b1} (a : \u03b1), (Not (Membership.mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instMembershipFinset.{u1} \u03b1) a s)) -> (Eq.{succ u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Insert.insert.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instInsertFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) a s)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Union.union.{u1} (Finset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Finset.instUnionFinset.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (a : Prod.{u1, u1} \u03b1 \u03b1) (b : Prod.{u1, u1} \u03b1 \u03b1) => instDecidableEqProd.{u1, u1} \u03b1 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) (Finset.offDiag.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) (Finset.product.{u1, u1} \u03b1 \u03b1 (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instSingletonFinset.{u1} \u03b1) a) s)) (Finset.product.{u1, u1} \u03b1 \u03b1 s (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instSingletonFinset.{u1} \u03b1) a))))\nCase conversion may be inaccurate. Consider using '#align finset.off_diag_insert Finset.offDiag_insert\u2093'. -/\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 \u2209 s) : (insert a s).offDiag = s.offDiag \u222a {a} \u00d7\u02e2 s \u222a s \u00d7\u02e2 {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 \u2192 Set \u2192 Prop} {x y a b : Set} :\na.pair b \u2208 pair_sep p x y \u2194 a \u2208 x \u2227 b \u2208 y \u2227 p a b :=\nbegin\n  simp only [mem_pair_sep], split,\n  { rintro \u27e8a', ha, b', hb, he, hp\u27e9,\n    have hpe : a = a' \u2227 b = b' := pair_inj he,\n    simp only [hpe.left, hpe.right],\n    exact \u27e8ha, hb, hp\u27e9, },\n  { rintro \u27e8ha, hb, hp\u27e9,\n    exact \u27e8a, ha, b, hb, rfl, hp\u27e9, },\nend\n\nlemma pair_mem_pair_sep' {p : Set \u2192 Set \u2192 Prop} {x y a : Set} (a' : a \u2208 x) {b : Set} (b' : b \u2208 y) :\n  a.pair b \u2208 pair_sep p x y \u2194 p a b :=\nbegin\n  simp only [pair_mem_pair_sep], split,\n    rintro \u27e8-, -, pab\u27e9, exact pab,\n  intro pab, exact \u27e8a', b', pab\u27e9,\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 \u00d7 y that satisfies p\n-- Corralary 3C is basically mem_pair_sep\n-- We also have prod and mem_prod\ntheorem ch3_p4 : \u00ac \u2203 S : Set, \u2200 x y : Set, x.pair y \u2208 S :=\nbegin\n  rintro \u27e8S, h\u27e9,\n  apply univ_not_set,\n  refine \u27e8S.Union.Union, _\u27e9,\n  intro x,\n  specialize h x x,\n  rw mem_Union,\n  refine \u27e8{x}, _, _\u27e9,\n  rw mem_Union,\n  refine \u27e8x.pair x, h, _\u27e9,\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 := \u2203 (y z : Set), x = y.pair z\ndef is_rel (R : Set) : Prop := \u2200 x : Set, x \u2208 R \u2192 x.is_pair\ndef dom (R : Set) : Set := {x \u2208 R.Union.Union | \u2203 y, x.pair y \u2208 R}\ndef ran (R : Set) : Set := {x \u2208 R.Union.Union | \u2203 t : Set, t.pair x \u2208 R}\ndef fld (R : Set) : Set := R.dom \u222a R.ran\n\nlemma empty_is_rel : (\u2205 : 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 \u27e8_, _, hz\u27e9,\nend\n\nlemma inter_rel_is_rel {R : Set} (hR : R.is_rel) {S : Set} : (R \u2229 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 \u222a 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 : \u2200 \u2983x : Set\u2984, x \u2208 S \u2192 x.is_rel) : S.Union.is_rel :=\nbegin\n  intros z hz, rw mem_Union at hz, rcases hz with \u27e8x, hx, hz\u27e9, exact h hx _ hz,\nend\n\nlemma rel_eq {R : Set} (hR : R.is_rel) {S : Set} (hS : S.is_rel) (h : \u2200 \u2983x y : Set\u2984, x.pair y \u2208 R \u2194 x.pair y \u2208 S) : R = S :=\nbegin\n  apply ext, intro z, split,\n  { intro hz,\n    have hxy := hR _ hz, rcases hxy with \u27e8x, y, hxy\u27e9,\n    rw hxy at hz, rw hxy, rw \u2190h, exact hz, },\n  { intro hz,\n    have hxy := hS _ hz, rcases hxy with \u27e8x, y, hxy\u27e9,\n    rw hxy at hz, rw hxy, rw h, exact hz, },\nend\n\nlemma rel_eq_empty {R : Set} (hR : R.is_rel) : R = \u2205 \u2194 \u2200 \u2983x y : Set\u2984, x.pair y \u2209 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 \u2208 A.prod B) : p.is_pair :=\nbegin\n  simp only [mem_prod, exists_prop] at h, rcases h with \u27e8a, ha, b, hb, he\u27e9,\n  exact \u27e8_, _, he\u27e9,\nend\n\nlemma pair_sep_is_rel {p : Set \u2192 Set \u2192 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 \u27e8a, ha, b, hb, he, hp\u27e9,\n  exact \u27e8a, b, he\u27e9,\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 \u2286 Y) : X.is_rel :=\n\u03bb 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 : \u2200 \u2983x y : Set\u2984, x.pair y \u2208 R \u2192 x.pair y \u2208 S) : R \u2286 S :=\nbegin\n  intros z hz, specialize hR z hz, rcases hR with \u27e8x, y, he\u27e9, subst he, exact hext hz,\nend\n\ntheorem rel_ext {R : Set} (hR : R.is_rel) {S : Set} (hS : S.is_rel) (hext : \u2200 \u2983x y : Set\u2984, x.pair y \u2208 R \u2194 x.pair y \u2208 S) : R = S :=\nbegin\n  rw eq_iff_subset_and_subset, refine \u27e8rel_sub hR _, rel_sub hS _\u27e9,\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 \u2286 A.prod B) {S : Set} (SAB : S \u2286 A.prod B)\n  (hext : \u2200 \u2983x : Set\u2984, x \u2208 A \u2192 \u2200 \u2983y : Set\u2984, y \u2208 B \u2192 (x.pair y \u2208 R \u2194 x.pair y \u2208 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 \u2190hext 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 \u222a B).prod C = (A.prod C) \u222a (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 \u222a C) = (A.prod B) \u222a (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 \u2229 C) = A.prod B \u2229 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 \u2190and_assoc,\n  rw and_self, simp only [\u2190and_assoc], nth_rewrite 1 and_comm,\nend\n\nlemma pair_sep_sub_prod {p : Set \u2192 Set \u2192 Prop} {x y : Set} : pair_sep p x y \u2286 x.prod y :=\nbegin\n  intro p, simp only [mem_pair_sep, mem_prod, exists_prop], rintro \u27e8a, ha, b, hb, he, hp\u27e9,\n  exact \u27e8_, ha, _, hb, he\u27e9,\nend\n\nlemma L3D_bulk {x y A : Set} (h : x.pair y \u2208 A) : {x, y} \u2208 A.Union :=\nbegin\n  rw mem_Union,\n  refine \u27e8_, h, _\u27e9,\n  simp only [pair, mem_pair], right, refl,\nend\n\nlemma L3D_left {x y A : Set} (h : x.pair y \u2208 A) : x \u2208 A.Union.Union :=\nbegin\n  rw mem_Union,\n  refine \u27e8_, L3D_bulk h, _\u27e9,\n  simp only [mem_pair], left, refl,\nend\n\nlemma L3D_right {x y A : Set} (h : x.pair y \u2208 A) : y \u2208 A.Union.Union :=\nbegin\n  rw mem_Union,\n  refine \u27e8_, L3D_bulk h, _\u27e9,\n  simp only [mem_pair], right, refl,\nend\n\n@[simp]\nlemma mem_dom {R : Set} (x : Set) : x \u2208 R.dom \u2194 \u2203 y, x.pair y \u2208 R :=\nbegin\n  simp only [dom, mem_sep],\n  apply and_iff_right_of_left_if_right,\n  rintro \u27e8y, h\u27e9,\n  exact L3D_left h,\nend\n@[simp]\nlemma mem_ran {R : Set} (x : Set) : x \u2208 R.ran \u2194 \u2203 t : Set, t.pair x \u2208 R :=\nbegin\n  simp only [ran, mem_sep],\n  apply and_iff_right_of_left_if_right,\n  rintro \u27e8t, h\u27e9,\n  exact L3D_right h,\nend\n\nlemma ran_empty_eq_empty : ran \u2205 = \u2205 :=\nbegin\n  rw eq_empty, intros y hy, rw mem_ran at hy, rcases hy with \u27e8x, hxy\u27e9, exact mem_empty _ hxy,\nend\n\nlemma dom_empty_eq_empty : dom \u2205 = \u2205 :=\nbegin\n  rw eq_empty, intros x hx, rw mem_dom at hx, rcases hx with \u27e8y, hxy\u27e9, exact mem_empty _ hxy,\nend\n\nlemma ran_ne_of_ne {C A B : Set} (CAB : C \u2286 A.prod B) (Cne : C \u2260 \u2205) : C.ran \u2260 \u2205 :=\nbegin\n  intro Ce, apply Cne, rw eq_empty,\n  intros z zC, specialize CAB zC, rw mem_prod at CAB, rcases CAB with \u27e8a, aC, b, bB, zab\u27e9, subst zab,\n  apply mem_empty b, rw [\u2190Ce, mem_ran], exact \u27e8_, zC\u27e9,\nend\n\nlemma pair_sep_dom_sub {p : Set \u2192 Set \u2192 Prop} {x y : Set} : (pair_sep p x y).dom \u2286 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 \u27e8y, hy\u27e9, exact (pair_inj hy).left, },\n  { rintro hx, rw hx, exact \u27e8_, rfl\u27e9, },\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 \u27e8y, hy\u27e9, exact (pair_inj hy).right, },\n  { rintro hx, rw hx, exact \u27e8_, rfl\u27e9, },\nend\n\n-- chapter 3 problem 6\nlemma rel_sub_dom_ran {R : Set} : R.is_rel \u2194 R \u2286 R.dom.prod R.ran :=\nbegin\n  split,\n    intros hR z hz, rw mem_prod, specialize hR _ hz, rcases hR with \u27e8x, y, hxy\u27e9, rw hxy at hz,\n    simp only [exists_prop, mem_dom, mem_ran], exact \u27e8_, \u27e8_, hz\u27e9, _, \u27e8_, hz\u27e9, hxy\u27e9,\n  intros hR z hz, specialize hR hz, simp only [mem_prod, exists_prop] at hR, rcases hR with \u27e8x, hx, y, hy, he\u27e9,\n  exact \u27e8_, _, he\u27e9,\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 \u27e8x, y, hp\u27e9, 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 \u27e8_, _, rfl\u27e9,\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 \u27e8_, _, rfl\u27e9,\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 \u27e8a, b, pab\u27e9, rcases hq with \u27e8c, d, qcd\u27e9, 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 \u2260 y.pair z) : x \u2260 y :=\nbegin\n  intro xy, subst xy, exact h rfl,\nend\n\nlemma fst_snd_mem_dom_ran {p A B : Set} (hp : p \u2208 A.prod B) : p.fst \u2208 A \u2227 p.snd \u2208 B :=\nbegin\n  simp only [mem_prod, exists_prop] at hp,\n  rcases hp with \u27e8a, ha, b, hb, he\u27e9,\n  have he' : a.pair b = p.fst.pair p.snd, rw \u2190he, exact fst_snd_spec \u27e8_, _, he\u27e9,\n  rw [\u2190(pair_inj he').left, \u2190(pair_inj he').right], finish,\nend\n\nlemma ran_subset_of_subset {H F : Set} (h : H \u2286 F) : H.ran \u2286 F.ran :=\nbegin\n  intro z, simp only [mem_ran],\n  rintro \u27e8x, hx\u27e9,\n  exact \u27e8x, h hx\u27e9,\nend\n\nlemma ran_prod {A B : Set} : (A.prod B).ran \u2286 B :=\nbegin\n  intro b, simp only [mem_ran, pair_mem_prod], rintro \u27e8-, -, xB\u27e9, exact xB,\nend\n\nlemma ran_sub_of_sub_prod {C A B : Set} (CAB : C \u2286 A.prod B) : C.ran \u2286 B :=\nsubset_trans (ran_subset_of_subset CAB) ran_prod\n\nlemma ran_Union_eq_Union_ran {C A : Set} (hA : \u2200 \u2983y\u2984, y \u2208 A \u2194 \u2203 f : Set, y \u2208 f.ran \u2227 f \u2208 C) : A = C.Union.ran :=\nbegin\n  apply ext,\n  simp only [hA, mem_ran], intro y, split,\n    rintro \u27e8f, \u27e8x, hxy\u27e9, hf\u27e9, use x, rw mem_Union, exact \u27e8_, hf, hxy\u27e9,\n  rintro \u27e8x, hxy\u27e9, rw mem_Union at hxy, rcases hxy with \u27e8f, hf, hxy\u27e9, exact \u27e8_, \u27e8_, hxy\u27e9, hf\u27e9,\nend\n\nlemma dom_Union_eq_Union_dom {C A : Set} (hA : \u2200 \u2983x\u2984, x \u2208 A \u2194 \u2203 f : Set, x \u2208 f.dom \u2227 f \u2208 C) : A = C.Union.dom :=\nbegin\n  apply ext,\n  simp only [hA, mem_dom], intro x, split,\n    rintro \u27e8f, \u27e8y, hxy\u27e9, hf\u27e9, use y, rw mem_Union, exact \u27e8_, hf, hxy\u27e9,\n  rintro \u27e8y, hxy\u27e9, rw mem_Union at hxy, rcases hxy with \u27e8f, hf, hxy\u27e9, exact \u27e8_, \u27e8_, hxy\u27e9, hf\u27e9,\nend\n\ndef pow : Set \u2192 \u2115 \u2192 Set\n| S 0 := {\u2205}\n| S 1 := S\n| S (n + 1) := (S.pow n).prod S\ndef is_n_ary (S : Set) (n : \u2115) : Prop := S \u2286 S.pow n\ndef is_function (F : Set) : Prop := F.is_rel \u2227 \u2200 x : Set, x \u2208 F.dom \u2192 \u2203! y, x.pair y \u2208 F\n\ndef fun_value (F x : Set) : Set := {y \u2208 F.Union.Union | x.pair y \u2208 F}.Union\n\nlemma is_function_iff {F : Set} : F.is_function \u2194 F.is_rel \u2227 \u2200 x y y' : Set, x.pair y \u2208 F \u2192 x.pair y' \u2208 F \u2192 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 \u27e8_, hy\u27e9 (h x), },\nend\n\n@[simp]\nlemma mem_fun_value {F x z : Set} : z \u2208 F.fun_value x \u2194 \u2203 y : Set, x.pair y \u2208 F \u2227 z \u2208 y :=\nbegin\n  simp only [fun_value, mem_Union], split,\n  { rintro \u27e8y, h\u2081, h\u2082\u27e9,\n    simp only [mem_sep] at h\u2081,\n    exact \u27e8_, h\u2081.right, h\u2082\u27e9, },\n  { rintro \u27e8y, h\u2081, h\u2082\u27e9,\n    refine \u27e8_, _, h\u2082\u27e9,\n    simp only [mem_sep],\n    exact \u27e8L3D_right h\u2081, h\u2081\u27e9, },\nend\n\nlemma fun_lemma {F x y z : Set} (hf : F.is_function) (hy : x.pair y \u2208 F) (hz : x.pair z \u2208 F) : y = z :=\nbegin\n  have hd : x \u2208 F.dom, simp only [mem_dom], exact \u27e8_, hy\u27e9,\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 \u2208 F) : y = F.fun_value x :=\nbegin\n  apply ext, intro z, simp only [mem_fun_value], split,\n  { intro hm, exact \u27e8_, hp, hm\u27e9, },\n  { rintro \u27e8w, hw, hm\u27e9,\n    rw fun_lemma hf hp hw,\n    assumption, },\nend\n\nlemma fun_value_def' {F x : Set} (hf : F.is_function) (hd : x \u2208 F.dom) : x.pair (F.fun_value x) \u2208 F :=\nbegin\n  simp only [mem_dom] at hd,\n  rcases hd with \u27e8y, hy\u27e9,\n  rw \u2190fun_value_def hf hy,\n  exact hy,\nend\n\nlemma fun_value_def'' {F x : Set} (hf : F.is_function) (hd : x \u2208 F.dom) : (F.fun_value x) \u2208 F.ran :=\nbegin\n  simp only [mem_ran],\n  exact \u27e8x, fun_value_def' hf hd\u27e9,\nend\n\nlemma fun_value_def''' {F x y : Set} (hf : F.is_function) (hd : x \u2208 F.dom) (hy : y = F.fun_value x) : x.pair y \u2208 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 \u2208 F.ran) : \u2203 x \u2208 F.dom, y = F.fun_value x :=\nbegin\n  rw mem_ran at hy, rcases hy with \u27e8x, hy\u27e9, refine \u27e8x, _, _\u27e9,\n  { rw mem_dom, exact \u27e8_, hy\u27e9, },\n  { exact fun_value_def hf hy, },\nend\n\nlemma mem_ran_iff {F : Set} (hf : F.is_function) {y : Set} : y \u2208 F.ran \u2194 \u2203 x : Set, x \u2208 F.dom \u2227 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 \u27e8x, hx, he\u27e9, rw he, exact fun_value_def'' hf hx, },\nend\n\nlemma of_ran {f : Set} (ffun : f.is_function) {p : Set \u2192 Prop} (h : \u2200 {x : Set}, x \u2208 f.dom \u2192 p (f.fun_value x)) :\n  \u2200 \u2983y : Set\u2984, y \u2208 f.ran \u2192 p y :=\nbegin\n  intro y, rw mem_ran_iff ffun, rintro \u27e8x, xf, e\u27e9, subst e, exact h xf,\nend\n\nlemma dom_ran_eq_empty_iff {R : Set} : R.dom = \u2205 \u2194 R.ran = \u2205 :=\nbegin\n  split,\n    intro de, rw eq_empty, intros y yr, rw mem_ran at yr, rcases yr with \u27e8x, xyR\u27e9,\n    apply mem_empty x, rw \u2190de, rw mem_dom, exact \u27e8_, xyR\u27e9,\n  intro re, rw eq_empty, intros x xd, rw mem_dom at xd, rcases xd with \u27e8y, xyR\u27e9,\n    apply mem_empty y, rw \u2190re, rw mem_ran, exact \u27e8_, xyR\u27e9,\nend\n\nlemma ran_sub {F : Set} (hf : F.is_function) {A : Set} (h : \u2200 x : Set, x \u2208 F.dom \u2192 F.fun_value x \u2208 A) : F.ran \u2286 A :=\nbegin\n  intro y, rw mem_ran_iff hf, rintro \u27e8x, xdom, Fx\u27e9, subst Fx, exact h _ xdom,\nend\n\ndef into_fun (F A B : Set) : Prop := F.is_function \u2227 F.dom = A \u2227 F.ran \u2286 B\n\nlemma fun_def_equiv {F A B : Set} : F.into_fun A B \u2194 A.is_func B F :=\nbegin\n  split,\n  { rintro \u27e8\u27e8hf, hu\u27e9, hd, hr\u27e9, refine \u27e8\u03bb p hp, _, \u03bb x hx, _\u27e9,\n    { simp only [mem_prod], specialize hf p hp, rcases hf with \u27e8x, y, he\u27e9,\n      have hx : x \u2208 A, rw [\u2190hd, mem_dom], use y, rw \u2190he, assumption,\n      have hy : y \u2208 B, apply hr, rw mem_ran, use x, rw \u2190he, assumption,\n      exact \u27e8_, hx, _, hy, he\u27e9, },\n    { rw [\u2190hd, mem_dom] at hx, apply exists_unique_of_exists_of_unique hx (\u03bb y\u2081 y\u2082 hy\u2081 hy\u2082, _),\n      refine unique_of_exists_unique (hu x _) hy\u2081 hy\u2082,\n      { rw mem_dom, assumption, }, }, },\n  { rintro \u27e8hsp, hu\u27e9, refine \u27e8\u27e8\u03bb p hp, _, \u03bb x hx, _\u27e9, _, _\u27e9,\n    { specialize hsp hp, rw mem_prod at hsp, rcases hsp with \u27e8x, hx, y, hp, he\u27e9, exact \u27e8_, _, he\u27e9, },\n    { apply hu, rw mem_dom at hx, rcases hx with \u27e8y, hp\u27e9, specialize hsp hp,\n      rw mem_prod at hsp, rcases hsp with \u27e8a, ha, b, hb, he\u27e9, rw (pair_inj he).left, assumption, },\n    { apply ext, simp only [mem_dom], intro x, split,\n      { rintro \u27e8y, hp\u27e9, specialize hsp hp, rw mem_prod at hsp,\n        rcases hsp with \u27e8a, ha, b, hb, he\u27e9, 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 \u27e8x, hp\u27e9, specialize hsp hp,\n      rw mem_prod at hsp, rcases hsp with \u27e8a, ha, b, hb, he\u27e9, 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 \u2286 B := hf.right.right\n\ndef onto_fun (F A B : Set) : Prop := F.is_function \u2227 F.dom = A \u2227 F.ran = B\ndef one_to_one (F : Set) : Prop := \u2200 y : Set, y \u2208 F.ran \u2192 \u2203! x : Set, x.pair y \u2208 F -- also called single-rooted\ndef inv (F : Set) : Set := pair_sep (\u03bb a b, b.pair a \u2208 F) F.ran F.dom\n\nlemma inv_sub_prod {R A B : Set} (RAB : R \u2286 A.prod B) : R.inv \u2286 B.prod A :=\nbegin\n  intros z zR, simp only [inv, mem_pair_sep] at zR, rcases zR with \u27e8a, -, b, -, zab, baR\u27e9, subst zab,\n  specialize RAB baR, rw mem_prod at RAB, rcases RAB with \u27e8c, cA, d, dB, bacd\u27e9,\n  obtain \u27e8bc, ad\u27e9 := 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 : \u2200 {m : Set}, m \u2208 F.dom \u2192 \u2200 {n : Set}, n \u2208 F.dom \u2192 m \u2260 n \u2192 F.fun_value m \u2260 F.fun_value n) : F.one_to_one :=\nbegin\n  intros y hy, rw mem_ran at hy, rcases hy with \u27e8x, hx\u27e9, refine \u27e8_, hx, _\u27e9,\n  intros x' hx', apply classical.by_contradiction, intros hne, refine @h x _ x' _ _ _,\n  { rw mem_dom, exact \u27e8_, hx\u27e9, },\n  { rw mem_dom, exact \u27e8_, hx'\u27e9, },\n  { intro he, apply hne, symmetry, assumption, },\n  { rw \u2190fun_value_def hf hx, rw \u2190fun_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 \u2208 F.dom) (hx' : x' \u2208 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 \u2208 F.dom) (hx' : x' \u2208 F.dom) : x = x' \u2194 F.fun_value x = F.fun_value x' :=\n\u27e8\u03bb xx, xx \u25b8 rfl, \u03bb fxx, from_one_to_one hf hoto hx hx' fxx\u27e9\n\nlemma one_to_one_iff {R : Set} : R.one_to_one \u2194 \u2200 {y x x' : Set}, x.pair y \u2208 R \u2192 x'.pair y \u2208 R \u2192 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 _ \u27e8_, hxy\u27e9) 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\u27e8is_function_of_into hf, dom_eq_of_into hf, he\u27e9\n\nlemma onto_ran_of_into {F A B : Set} (hf : F.into_fun A B) : F.onto_fun A F.ran := \u27e8hf.left, hf.right.left, rfl\u27e9\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 \u27e8hf, hd, hr\u27e9, refine \u27e8hf, hd, _\u27e9, rw hr, exact subset_self,\nend\n\nlemma into_of_into_ran_sub {F A B C : Set} (h : B \u2286 C) (hf : F.into_fun A B) : F.into_fun A C :=\n\u27e8hf.left, hf.right.left, subset_trans hf.right.right h\u27e9\n\nlemma into_of_onto_ran_sub {F A B C : Set} (h : B \u2286 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 \u2190hab' 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 \u2209 F.dom) : (F \u222a {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 \u27e8_, hb\u27e9,\n    exfalso, apply hx, rw mem_dom, rw (pair_inj hb).left at hb', exact \u27e8_, hb'\u27e9,\n  rw \u2190hb' 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 \u2209 F.ran) : (F \u222a {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 \u27e8_, hab\u27e9,\n    exfalso, apply hy, rw mem_ran, rw (pair_inj hab).right at hab', exact \u27e8_, hab'\u27e9,\n  rw [(pair_inj hab).left, (pair_inj hab').left],\nend\n\n@[simp]\nlemma mem_inv {F p : Set} : p \u2208 F.inv \u2194 \u2203 (a b : Set), p = a.pair b \u2227 b.pair a \u2208 F :=\nbegin\n  simp only [inv, mem_pair_sep], split,\n  { rintro \u27e8a, ha, b, hb, he, hm\u27e9,\n    exact \u27e8_, _, he, hm\u27e9, },\n  { rintro \u27e8a, b, he, hm\u27e9,\n    refine \u27e8_, _, _, _, he, hm\u27e9,\n    rw mem_ran, exact \u27e8_, hm\u27e9,\n    rw mem_dom, exact \u27e8_, hm\u27e9, },\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 \u2208 F.inv \u2194 b.pair a \u2208 F :=\nbegin\n  simp only [mem_inv], split,\n  { rintro \u27e8x, y, he, hm\u27e9,\n    suffices hinj : a = x \u2227 b = y,\n      rw hinj.left, rw hinj.right, assumption,\n    exact pair_inj he, },\n  { intro h, exact \u27e8a, b, rfl, h\u27e9, },\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 (\u03bb a b, \u2203 t : Set, a.pair t \u2208 G \u2227 t.pair b \u2208 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 \u2208 F.comp G \u2194 \u2203 (a b c : Set), p = a.pair c \u2227 a.pair b \u2208 G \u2227 b.pair c \u2208 F :=\nbegin\n  simp only [comp, mem_pair_sep], split,\n  { rintro \u27e8a, ha, b, hb, he, t, hm1, hm2\u27e9,\n    exact \u27e8a, t, b, he, hm1, hm2\u27e9, },\n  { rintro \u27e8a, b, c, he, hm1, hm2\u27e9,\n    refine \u27e8a, _, c, _, he, _, hm1, hm2\u27e9,\n      rw mem_dom, exact \u27e8_, hm1\u27e9,\n      rw mem_ran, exact \u27e8_, hm2\u27e9, },\nend\n\n@[simp]\nlemma pair_mem_comp {F G a c : Set} : a.pair c \u2208 F.comp G \u2194 \u2203 b : Set, a.pair b \u2208 G \u2227 b.pair c \u2208 F :=\nbegin\n  simp only [mem_comp], split,\n  { rintro \u27e8a', b, c', he, hg, hf\u27e9,\n    have hinj : a = a' \u2227 c = c' := pair_inj he,\n    rw hinj.left, rw hinj.right,\n    exact \u27e8_, hg, hf\u27e9, },\n  { rintro \u27e8b, hg, hf\u27e9,\n    exact \u27e8_, _, _, rfl, hg, hf\u27e9, },\nend\n\ndef restrict (F A : Set) : Set := pair_sep (\u03bb a b, a.pair b \u2208 F \u2227 a \u2208 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 \u2208 F.restrict A \u2194 \u2203 (a b : Set), p = a.pair b \u2227 a.pair b \u2208 F \u2227 a \u2208 A :=\nbegin\n  simp only [restrict, mem_pair_sep], split; intro h,\n    rcases h with \u27e8a, H\u2081, b, H\u2082, h\u2081, h\u2082, h\u2083\u27e9, exact \u27e8_, _, h\u2081, h\u2082, h\u2083\u27e9,\n  rcases h with \u27e8a, b, h\u2081, h\u2082, h\u2083\u27e9,\n  refine \u27e8a, _, b, _, _\u27e9,\n  simp only [mem_dom], exact \u27e8_, h\u2082\u27e9,\n  simp only [mem_ran], exact \u27e8_, h\u2082\u27e9,\n  exact \u27e8h\u2081, h\u2082, h\u2083\u27e9,\nend\n\n@[simp]\nlemma pair_mem_restrict {F A x y : Set} : x.pair y \u2208 F.restrict A \u2194 x.pair y \u2208 F \u2227 x \u2208 A :=\nbegin\n  simp, split,\n  { rintro \u27e8a, b, he, hp, hm\u27e9, rw he, rw (pair_inj he).left, finish, },\n  { rintro \u27e8hp, hm\u27e9, exact \u27e8_, _, rfl, hp, hm\u27e9, },\nend\n\nlemma restrict_empty {F : Set} : F.restrict \u2205 = \u2205 :=\nbegin\n  simp only [rel_eq_empty restrict_is_rel, pair_mem_restrict], rintros x y \u27e8-, h\u27e9,\n  exact mem_empty _ h,\nend\n\nlemma restrict_combine {F : Set} (hf : F.is_rel) {A B : Set} (hd : A \u222a B = F.dom) : F.restrict A \u222a F.restrict B = F :=\nbegin\n  apply ext, simp only [mem_union, mem_restrict], intro p, split,\n  { rintro (\u27e8a, b, he, hp, hm\u27e9|\u27e8a, b, he, hp, hm\u27e9),\n    { rw he, exact hp, },\n    { rw he, exact hp, }, },\n  { intro hp, have h := hf _ hp, rcases h with \u27e8x, y, h\u27e9,\n    have hx : x \u2208 F.dom, rw mem_dom, finish,\n    rw \u2190hd 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 \u2208 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 \u27e8x', y, he, hp, hm\u27e9, rw he, congr,\n    { exact hm, },\n    { rw \u2190hm, exact fun_value_def hf hp, }, },\n  { rintro he, refine \u27e8_, _, he, _, rfl\u27e9, 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 \u27e8x, y, he, hp, hx\u27e9, exact \u27e8_, _, he\u27e9, },\n  { simp only [pair_mem_restrict], rintros x y y' \u27e8hp, hx\u27e9 \u27e8hp', -\u27e9,\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 \u2286 F.dom) {x : Set} (hx : x \u2208 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 \u27e8fun_value_def' hf (hA hx), hx\u27e9,\nend\n\nlemma restrict_dom {F A : Set} (hA : A \u2286 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 \u2190mem_dom, exact hA hxA,\nend\n\nlemma restrict_dom_inter {F A : Set} : (F.restrict A).dom = F.dom \u2229 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 \u2208 F.dom) {A : Set} (hxA : x \u2208 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 \u27e8fun_value_def' hf hx, hxA\u27e9,\nend\n\nlemma restrict_subset {F A : Set} : F.restrict A \u2286 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 \u2286 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 \u2208 F.img A \u2194 \u2203 x : Set, x \u2208 A \u2227 x.pair y \u2208 F :=\nbegin\n  simp only [img, mem_ran, mem_restrict], split,\n    rintro \u27e8t, a, b, h\u2081, h\u2082, h\u2083\u27e9,\n    have h\u2084 : y = b := (pair_inj h\u2081).right,\n    subst h\u2084,\n    exact \u27e8_, h\u2083, h\u2082\u27e9,\n  rintro \u27e8x, h\u2081, h\u2082\u27e9,\n  exact \u27e8x, x, y, rfl, h\u2082, h\u2081\u27e9,\nend\n\nlemma mem_img' {F A y : Set} (h : F.is_function) (h' : A \u2286 F.dom) : y \u2208 F.img A \u2194 \u2203 x : Set, x \u2208 A \u2227 y = F.fun_value x :=\nbegin\n  simp only [mem_img],\n  split,\n    rintro \u27e8x, h\u2081, h\u2082\u27e9,\n    refine \u27e8_, h\u2081, fun_value_def h h\u2082\u27e9,\n  rintros \u27e8x, h\u2081, h\u2082\u27e9,\n  rw h\u2082,\n  refine \u27e8_, h\u2081, _\u27e9,\n  apply fun_value_def', exact h,\n  exact h' h\u2081,\nend\n\nlemma fun_value_mem_img {F : Set} (hf : F.is_function) {A : Set} (hd : A \u2286 F.dom) {x : Set} (h : x \u2208 A) : F.fun_value x \u2208 F.img A :=\nbegin\n  rw mem_img' hf hd, exact \u27e8_, h, rfl\u27e9,\nend\n\nlemma img_subset_ran {F A : Set} : F.img A \u2286 F.ran :=\nbegin\n  intro y, simp only [mem_img, mem_ran, and_imp, exists_imp_distrib],\n  intros x hxA hxyF, exact \u27e8_, hxyF\u27e9,\nend\n\nlemma img_singleton_eq {F : Set} (hF : F.is_function) {x : Set} (hx : x \u2208 F.dom) : F.img {x} = {F.fun_value x} :=\nbegin\n  have h : {x} \u2286 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 \u27e8x', hx', hz\u27e9, subst hx', exact hz,\n  intro hz, exact \u27e8_, rfl, hz\u27e9,\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 \u2286 f.dom) {g : Set} (hg : g.is_function) (Ag : A \u2286 g.dom)\n  (h : \u2200 {a : Set}, a \u2208 A \u2192 f.fun_value a = g.fun_value a) : f.img A = g.img A :=\next (\u03bb y, calc\n  y \u2208 f.img A \u2194 \u2203 x : Set, x \u2208 A \u2227 y = f.fun_value x : by rw mem_img' hf Af\n  ... \u2194 \u2203 x : Set, x \u2208 A \u2227 y = g.fun_value x : exists_congr (\u03bb x, and_congr_right (\u03bb xA, eq.congr_right (h xA)))\n  ... \u2194 y \u2208 g.img A : by rw mem_img' hg Ag)\n\nlemma restrict_into_fun {F D\u2081 D\u2082 R : Set} (hF : F.into_fun D\u2081 R) (h : D\u2082 \u2286 D\u2081) : (F.restrict D\u2082).into_fun D\u2082 R :=\nbegin\n  refine \u27e8restrict_is_function hF.left, _, _\u27e9,\n  { rw \u2190hF.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 \u2286 F.dom) (hAne : A \u2260 F.dom) : F.img A \u2260 F.ran :=\nbegin\n  intro he, apply hAne, rw eq_iff_subset_and_subset, refine \u27e8hAsub, _\u27e9, intros x hx,\n  rw mem_dom at hx, rcases hx with \u27e8y, hx\u27e9,\n  have hy : y \u2208 F.ran, rw mem_ran, exact \u27e8_, hx\u27e9,\n  rw [\u2190he, mem_img] at hy, rcases hy with \u27e8x', hx', hy\u27e9,\n  have hxx' : x = x', apply unique_of_exists_unique,\n    { refine hF' y _, rw mem_ran, exact \u27e8_, hx\u27e9, },\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 : \u2200 x y : Set, x \u2208 F.dom \u2192 y \u2208 F.dom \u2192 F.fun_value x = F.fun_value y \u2192 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 \u27e8_, hx\u27e9,\n  rw mem_dom, exact \u27e8_, hx'\u27e9,\n  rw \u2190fun_value_def hf hx,\n  rw \u2190fun_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 \u27e8a, b, he, hm\u27e9, rw he, assumption, },\n  { intro hm,\n    specialize h _ hm,\n    rcases h with \u27e8a, b, he\u27e9,\n    rw he at hm,\n    exact \u27e8_, _, he, hm\u27e9, },\nend\n\ntheorem T3F_a {F : Set} : F.inv.is_function \u2194 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 \u2194 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) : \u2200 x \u2208 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) \u2208 F := fun_value_def' hf hm,\n  have hpinv : (F.fun_value x).pair x \u2208 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) : \u2200 y \u2208 F.ran, F.fun_value (F.inv.fun_value y) = y :=\nbegin\n  intros y hm,\n  rw \u2190T3E_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 \u27e8a, b, c, he, hmg, hmf\u27e9,\n    exact \u27e8_, _, he\u27e9,\n  intros p hp,\n  rw mem_dom at hp,\n  rcases hp with \u27e8y, hp\u27e9,\n  refine \u27e8_, hp, _\u27e9,\n  intros w hw,\n  simp only [pair_mem_comp] at hp,\n  simp only [pair_mem_comp] at hw,\n  rcases hp with \u27e8u, hu\u27e9,\n  rcases hw with \u27e8v, hv\u27e9,\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 \u2208 G.dom | G.fun_value x \u2208 F.dom} :=\nbegin\n  apply ext, intro x, simp only [mem_sep, mem_dom, pair_mem_comp],\n  split,\n  { rintro \u27e8y, t, hx, ht\u27e9,\n    refine \u27e8\u27e8t, hx\u27e9, y, _\u27e9,\n    rw \u2190fun_value_def hg hx,\n    exact ht, },\n  { rintro \u27e8\u27e8t, ht\u27e9, y, hy\u27e9,\n    refine \u27e8y, _, ht, _\u27e9,\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 \u2208 (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 \u27e8\u27e8t, ht\u27e9, y, hy\u27e9,\n  symmetry,\n  apply fun_value_def (T3H_a hf hg),\n  simp only [pair_mem_comp],\n  refine \u27e8_, ht, _\u27e9,\n  rw \u2190fun_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 \u27e8a, b, he, b', t, a', hpe, hg, hf\u27e9,\n    have hinj : b = b' \u2227 a = a' := pair_inj hpe,\n    refine \u27e8a, t, b, he, _, _\u27e9,\n      rw hinj.right,\n      assumption,\n    rw hinj.left,\n    assumption, },\n  { rintro \u27e8a, t, b, he, hf, hg\u27e9,\n    exact \u27e8a, b, he, b, t, a, rfl, hg, hf\u27e9, },\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 \u27e8Foto, rfl, Fonto.right.left\u27e9,\nend\n\nlemma dom_comp_sub {F G : Set} : (F.comp G).dom \u2286 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 \u2286 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 \u27e8y, hy\u27e9,\n    have hd : y \u2208 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 \u2286 F.ran :=\nbegin\n  rw [\u2190T3E_a, T3I, \u2190T3E_a], exact dom_comp_sub,\nend\n\nlemma ran_comp {F G : Set} (h : F.dom \u2286 G.ran) : (F.comp G).ran = F.ran :=\nbegin\n  rw [\u2190T3E_a, \u2190T3E_b] at h, rw [\u2190T3E_a, T3I, \u2190T3E_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 \u27e8z, x, hzx, hxy\u27e9, refine \u27e8\u27e8_, hxy\u27e9, _\u27e9, rintro \u27e8x', \u27e8\u27e8y', hxy'\u27e9, he\u27e9, hx'y\u27e9,\n    apply he, rw one_to_one_iff at hf, specialize hf hxy hx'y, rw \u2190hf, exact \u27e8_, hzx\u27e9,\n  rintro\u27e8\u27e8z, hzy\u27e9, hne\u27e9, apply classical.by_contradiction, intro hne', apply hne,\n  refine \u27e8_, \u27e8\u27e8_, hzy\u27e9, _\u27e9, hzy\u27e9, rintro \u27e8x', hx'z\u27e9, apply hne', exact \u27e8_, _, hx'z, hzy\u27e9,\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 \u27e8T3H_a hg.left hf.left, _, _\u27e9,\n  { have h : f.ran \u2286 g.dom, rw hg.right.left, exact hf.right.right,\n    rw \u2190hf.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 \u27e8T3F_a.mpr foto, _, _\u27e9,\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 : \u2200 x \u2208 F.dom, F.fun_value x = G.fun_value x) : F = G :=\nbegin\n  have h : \u2200 F G : Set, F.is_function \u2192 G.is_function \u2192 F.dom = G.dom \u2192 (\u2200 x \u2208 F.dom, F.fun_value x = G.fun_value x) \u2192 \u2200 z : Set, z \u2208 F \u2192 z \u2208 G,\n    intros F G hf hg hd ha z hm,\n    have hp : z.is_pair := hf.left _ hm,\n    rcases hp with \u27e8x, y, hp\u27e9, subst hp,\n    have hxd : x \u2208 F.dom, simp only [mem_dom], exact \u27e8_, hm\u27e9,\n    specialize ha _ hxd,\n    rw \u2190fun_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 \u2190hd, 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 \u222a 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 (\u03bb a b, a = b) A A\n\nlemma id_is_function {A : Set} : A.id.is_function :=\nbegin\n  refine \u27e8pair_sep_is_rel, _\u27e9,\n  simp only [mem_dom, pair_mem_pair_sep, id],\n  rintros x \u27e8y, hx\u27e9,\n  refine \u27e8y, hx, _\u27e9,\n  intros y' hy,\n  rw \u2190hx.right.right,\n  rw \u2190hy.right.right,\nend\n\nlemma id_onto {A : Set} : A.id.onto_fun A A :=\nbegin\n  simp only [onto_fun],\n  refine \u27e8id_is_function, _, _\u27e9,\n    apply ext, simp only [mem_dom, id, pair_mem_pair_sep],\n    intro z, split,\n    { rintro \u27e8y, h, _\u27e9, exact h, },\n    { intro h, exact \u27e8_, h, h, rfl\u27e9, },\n  apply ext, simp only [mem_ran, id, pair_mem_pair_sep],\n  intro z, split,\n  { rintro \u27e8x, _, h, _\u27e9, exact h, },\n  { intro h, exact \u27e8_, h, h, rfl\u27e9, },\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 \u2208 A) : A.id.fun_value x = x :=\nbegin\n  have h : x.pair x \u2208 A.id,\n    simp only [id, pair_mem_pair_sep],\n    exact \u27e8hx, hx, rfl\u27e9,\n  rw \u2190fun_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 \u2190id_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 \u2286 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 \u2286 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 \u2286 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 \u2208 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 \u27e8x, y, x', he, hxy, hxy'\u27e9, refine \u27e8_, \u27e8_, hxy\u27e9, _, \u27e8_, hxy'\u27e9, he, _\u27e9,\n    refine unique_of_exists_unique _ hxy hxy', apply hf', rw mem_ran, exact \u27e8_, hxy\u27e9, },\n  { rintro \u27e8x, \u27e8y, hxy\u27e9, x', \u27e8y', hxy'\u27e9, he, hxx'\u27e9, 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 \u27e8_, hxy\u27e9,\n    rw hyy' at hxy, exact \u27e8_, _, _, he, hxy, hxy\u27e9, },\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 \u2190T3F_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 \u2229 G.dom = \u2205) : (F \u222a G).onto_fun (F.dom \u222a G.dom) (F.ran \u222a G.ran) :=\nbegin\n  have hd : (F \u222a G).dom = F.dom \u222a G.dom,\n    apply ext, simp only [mem_dom, mem_union],\n    intro z,\n    exact exists_or_distrib,\n  split,\n  { refine \u27e8union_of_rel_is_rel hf.left hg.left, _\u27e9,\n    simp only [hd, mem_union, mem_dom],\n    rintros x (\u27e8y, hmf\u27e9 | \u27e8y, hmg\u27e9),\n    { refine \u27e8y, or.inl hmf, _\u27e9,\n      rintros z (hz | hz),\n      exact fun_lemma hf hz hmf,\n      exfalso,\n      apply mem_empty x,\n      simp only [\u2190hdisj, mem_inter, mem_dom],\n      exact \u27e8\u27e8_, hmf\u27e9, _, hz\u27e9, },\n    { refine \u27e8y, or.inr hmg, _\u27e9,\n      rintros z (hz | hz),\n      exfalso,\n      apply mem_empty x,\n      simp only [\u2190hdisj, mem_inter, mem_dom],\n      exact \u27e8\u27e8_, hz\u27e9, _, hmg\u27e9,\n      exact fun_lemma hg hz hmg, }, },\n  refine \u27e8hd, _\u27e9,\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 \u222a G).dom = F.dom \u222a 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\u2081 D\u2082 R : Set} (hF : F.into_fun D\u2081 R) (hG : G.into_fun D\u2082 R) (hdisj : D\u2081 \u2229 D\u2082 = \u2205) : (F \u222a G).into_fun (D\u2081 \u222a D\u2082) R :=\nbegin\n  have onto : (F \u222a G).onto_fun (F.dom \u222a G.dom) (F.ran \u222a G.ran), apply union_fun hF.left hG.left, rw [hF.right.left, hG.right.left], exact hdisj,\n  rw [\u2190hF.right.left, \u2190hG.right.left], refine \u27e8onto.left, onto.right.left, _\u27e9,\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 \u222a G).ran = F.ran \u222a 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\u2081 D\u2082 R\u2081 R\u2082 : Set} (Fonto : F.onto_fun D\u2081 R\u2081) (Gonto : G.onto_fun D\u2082 R\u2082) (disj : D\u2081 \u2229 D\u2082 = \u2205)\n  {x : Set} (xD : x \u2208 D\u2081) : (F \u222a 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\u2081 D\u2082 R\u2081 R\u2082 : Set} (Fonto : F.onto_fun D\u2081 R\u2081) (Gonto : G.onto_fun D\u2082 R\u2082) (disj : D\u2081 \u2229 D\u2082 = \u2205)\n  {x : Set} (xD : x \u2208 D\u2082) : (F \u222a 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 \u27e8x, hx\u27e9, exact (pair_inj hx).right, },\n  { intro hy, rw hy, exact \u27e8_, rfl\u27e9, },\nend\n\nlemma union_one_to_one {f : Set} (hf : f.one_to_one) {g : Set} (hg : g.one_to_one) (hfg : f.ran \u2229 g.ran = \u2205) : (f \u222a g).one_to_one :=\nbegin\n  intros y hy, simp only [mem_ran, mem_union] at hy, simp only [mem_union], rcases hy with \u27e8x, hx|hx\u27e9,\n  { refine \u27e8_, or.inl hx, _\u27e9,\n    have hyfr : y \u2208 f.ran, rw mem_ran, exact \u27e8_, hx\u27e9,\n    rintros x' (hx'|hx'),\n    { apply unique_of_exists_unique (hf _ hyfr) hx' hx, },\n    { have hygr : y \u2208 g.ran, rw mem_ran, exact \u27e8_, hx'\u27e9,\n      exfalso, apply mem_empty y, rw [\u2190hfg, mem_inter], exact \u27e8hyfr, hygr\u27e9, }, },\n  { refine \u27e8_, or.inr hx, _\u27e9,\n    have hygr : y \u2208 g.ran, rw mem_ran, exact \u27e8_, hx\u27e9,\n    rintros x' (hx'|hx'),\n    { have hyfr : y \u2208 f.ran, rw mem_ran, exact \u27e8_, hx'\u27e9,\n      exfalso, apply mem_empty y, rw [\u2190hfg, mem_inter], exact \u27e8hyfr, hygr\u27e9, },\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 \u2229 G.dom = \u2205) : (F \u222a 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 \u27e8(hxy|hxy), hd\u27e9,\n      exact hxy,\n    exfalso, apply mem_empty x, rw \u2190hdisj, rw mem_inter, refine \u27e8hd, _\u27e9, rw mem_dom, exact \u27e8_, hxy\u27e9, },\n  { intro hxy, rw mem_dom, refine \u27e8or.inl hxy, _, hxy\u27e9, },\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 \u27e8_, rfl, _\u27e9, intros x' hx', exact (pair_inj hx').left,\nend\n\nlemma single_pair_into {x y R : Set} (hy : y \u2208 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 \u27e8rfl, hy\u27e9,\n  simp only [mem_singleton], intros z he, rw he, exact \u27e8_, rfl, \u03bb y' he', (pair_inj he').right\u27e9,\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 \u27e8prod_is_rel, _\u27e9,\n  simp only [mem_dom, mem_singleton, pair_mem_prod],\n  rintros z \u27e8y, hy\u27e9,\n  refine \u27e8y, hy, _\u27e9,\n  intros y' hy',\n  rw hy'.right, symmetry, exact hy.right,\nend\n\nlemma empty_fun : is_function \u2205 :=\nbegin\n  rw is_function_iff, refine \u27e8empty_is_rel, \u03bb x y y' hxy hxy', _\u27e9,\n  exfalso, exact mem_empty _ hxy,\nend\n\nlemma empty_onto : onto_fun \u2205 \u2205 \u2205 :=\n\u27e8empty_fun, dom_empty_eq_empty, ran_empty_eq_empty\u27e9\n\nlemma empty_oto : one_to_one \u2205 :=\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 : \u2203 x : Set, x \u2208 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 \u2286 B :=\nbegin\n  intros z hz,\n  simp only [mem_ran, pair_mem_prod] at hz,\n  rcases hz with \u27e8t, hA, hB\u27e9, exact hB,\nend\n\nlemma one_to_one_of_has_left_inv {F A B : Set} (hf : F.into_fun A B) (he : \u2203 G : Set, G.into_fun B A \u2227 G.comp F = A.id) : F.one_to_one :=\nbegin\n  rcases he with \u27e8G, hif, hcid\u27e9,\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 \u2190id_value hxd, rw \u2190id_value hyd, rw \u2190hcid,\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 : \u2203 x, x \u2208 A) : (\u2203 G : Set, G.into_fun B A \u2227 G.comp F = A.id) \u2194 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 \u27e8x, hxm\u27e9,\n    intro hoto,\n    let F' := F.inv,\n    let E := (B \\ F.ran).prod {x},\n    let G := F' \u222a E,\n    have honto : G.onto_fun (F'.dom \u222a E.dom) (F'.ran \u222a 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 \u27e8\u27e8y, hy\u27e9, y', \u27e8_, him\u27e9, _\u27e9,\n        exact him \u27e8_, hy\u27e9, },\n    refine \u27e8_, \u27e8honto.left, _, _\u27e9, _\u27e9,\n    { rw honto.right.left,\n      simp only [T3E_a, dom_prod_nonempty \u27e8x, mem_singleton.mpr rfl\u27e9],\n      apply ext, intro z,\n      have hz : z \u2208 F.ran \u2192 z \u2208 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 \u2190hf.right.left, assumption, },\n      { have hz' : z \u2208 {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 \u27e8hmz, _\u27e9, assumption, },\n      { intro hmz, refine \u27e8hmz, _\u27e9,\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 \u2208 (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 : \u2205 \u2209 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 \u27e8y, hy\u27e9,\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 \u27e8\u27e8_, _\u27e9, _, _\u27e9,\n  { intros z hz,\n    have hp := choice.left hz,\n    simp only [mem_prod] at hp,\n    rcases hp with \u27e8a, H, b, H, he\u27e9,\n    exact \u27e8a, b, he\u27e9, },\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 \u2208 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 : \u2205 \u2209 x) (y : Set) (hy : y \u2208 x) : x.choice.fun_value y \u2208 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 \u27e8a, ha, hp\u27e9,\n      simp only [Class.mem_hom_right] at hp,\n      apply fun_value_def, exact hf.left, rw \u2190(Class.of_Set.inj ha), assumption, },\n    { intro hv, refine \u27e8y, rfl, _\u27e9,\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\u2082 : (x.choice.fun_value y : Class.{u}) \u2208 (y : Class.{u}),\n    simp only [Class.mem_hom_left, Class.mem_hom_right] at h\u2082, assumption,\n  rw \u2190h, exact choice_mem x hx y hy,\nend\n\nlemma pair_sep_eq_is_fun {A B : Set} {f : Set \u2192 Set} : (pair_sep (\u03bb 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 \u2192 Set} (h : \u2200 a \u2208 A, f a \u2208 B) : (pair_sep (\u03bb 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 \u2192 Set} (h : \u2200 b \u2208 B, \u2203 a, a \u2208 A \u2227 b = f a)\n: (pair_sep (\u03bb 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 \u27e8t, _, hb, _\u27e9, assumption, },\n  { intro hb, specialize h _ hb, finish, },\nend\n\nlemma pair_sep_eq_ran_sub {A B : Set} {p : Set \u2192 Set \u2192 Prop} : (pair_sep p A B).ran \u2286 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 \u2192 Set} (hf : \u2200 \u2983a\u2081 : Set\u2984, a\u2081 \u2208 A \u2192 \u2200 \u2983a\u2082 : Set\u2984, a\u2082 \u2208 A \u2192 f a\u2081 = f a\u2082 \u2192 a\u2081 = a\u2082) : (pair_sep (\u03bb 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 \u27e8a, ha, hb, he\u27e9,\n  simp only [pair_mem_pair_sep], refine \u27e8_, \u27e8ha, hb, he\u27e9, \u03bb a' ha', _\u27e9, rcases ha' with \u27e8ha', -, he'\u27e9,\n  rw he' at he, exact hf ha' ha he,\nend\n\ndef pair_sep_eq (A B : Set) (f : Set \u2192 Set) : Set := pair_sep (\u03bb a b, b = f a) A B\n\n@[simp]\nlemma pair_mem_pair_sep_eq {A B : Set} {f : Set \u2192 Set} {a b : Set} : a.pair b \u2208 pair_sep_eq A B f \u2194 a \u2208 A \u2227 b \u2208 B \u2227 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 \u2192 Set} {a : Set} (ha : a \u2208 (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 \u27e8b, ha, hb, he\u27e9, rw he at hb,\n  exact \u27e8ha, hb, rfl\u27e9,\nend\n\nlemma pair_sep_eq_into {A B : Set} {f : Set \u2192 Set} (h : \u2200 a \u2208 A, f a \u2208 B) : (pair_sep_eq A B f).into_fun A B :=\n\u27e8pair_sep_eq_is_fun, pair_sep_eq_dom_eq h, pair_sep_eq_ran_sub\u27e9\n\n-- These are all stated and proved equivalent in chapter 6, but some are stated earlier.\n\ndef Axiom_of_choice_I : Prop := \u2200 {R : Set}, R.is_rel \u2192 \u2203 F : Set, F.is_function \u2227 F \u2286 R \u2227 F.dom = R.dom\ndef Axiom_of_choice_II : Prop := \u2200 {I H : Set}, (H.is_function \u2227 H.dom = I \u2227 (\u2200 i : Set, i \u2208 I \u2192 H.fun_value i \u2260 \u2205))\n\u2192 \u2203 f : Set, f.is_function \u2227 f.dom = I \u2227 \u2200 i : Set, i \u2208 I \u2192 f.fun_value i \u2208 H.fun_value i\ndef Axiom_of_choice_III : Prop := \u2200 {A : Set}, \u2203 F : Set, F.is_function \u2227 F.dom = {x \u2208 A.powerset | x \u2260 \u2205}\n\u2227 \u2200 B : Set, B \u2208 F.dom \u2192 F.fun_value B \u2208 B\ndef Axiom_of_choice_IV : Prop := \u2200 {\ud835\udcd0 : Set}, (\u2200 a \u2208 \ud835\udcd0, a \u2260 \u2205 \u2227 \u2200 b \u2208 \ud835\udcd0, b \u2260 a \u2192 a \u2229 b = \u2205)\n\u2192 \u2203 C : Set, \u2200 B \u2208 \ud835\udcd0, \u2203 x : Set, C \u2229 B = {x}\n\ntheorem ax_ch_3 : Axiom_of_choice_III :=\nbegin\n  intro A,\n  let A' := {x \u2208 A.powerset | x \u2260 \u2205},\n  have hne : \u2205 \u2209 A', intro h, simp at h, assumption,\n  have hf := choice_is_fun _ hne,\n  refine \u27e8A'.choice, hf.left, _, (\u03bb B hB, _)\u27e9,\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 \u2192 2,\n  { dsimp only [Axiom_of_choice_I, Axiom_of_choice_II], rintros ax1 I H \u27e8Hfun, Hdom, Hne\u27e9,\n    let R : Set := pair_sep (\u03bb i y, y \u2208 H.fun_value i) I H.ran.Union,\n    specialize @ax1 R pair_sep_is_rel, rcases ax1 with \u27e8F, Ffun, FR, Fdom\u27e9,\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 \u27e8y, hy\u27e9, simp only [mem_Union, exists_prop],\n      refine \u27e8_, hi, \u27e8_, _, hy\u27e9, hy\u27e9, apply fun_value_def'' Hfun, rw Hdom, exact hi,\n    rw Rdom at Fdom, refine \u27e8_, Ffun, Fdom, _\u27e9, intros i hi,\n    have hiy : i.pair (F.fun_value i) \u2208 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 \u2192 4,\n  { dsimp only [Axiom_of_choice_II, Axiom_of_choice_IV], rintros ax2 A hA,\n    let H := A.id,\n    have Hh : \u2200 i : Set, i \u2208 H.dom \u2192 H.fun_value i \u2260 \u2205, rw id_into.right.left,\n      intros i hi, rw id_value hi, specialize hA _ hi, exact hA.left,\n    specialize ax2 \u27e8id_is_function, rfl, Hh\u27e9, rcases ax2 with \u27e8f, ffun, fdom, hf\u27e9, 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 \u27e8\u27e8X, hXC\u27e9, hCB\u27e9, have hXA : X \u2208 f.dom, rw mem_dom, exact \u27e8_, hXC\u27e9, 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 [\u2190(hA _ hBA).right _ hXA hXB, mem_inter], split,\n        rw \u2190hCfX, 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 \u2192 3,\n  { dsimp only [Axiom_of_choice_IV, Axiom_of_choice_III], rintro ax4 A,\n    let \ud835\udcd0 := {x \u2208 (A.powerset.Union \u222a A.powerset).powerset.powerset.powerset | \u2203 B, B \u2286 A \u2227 B \u2260 \u2205 \u2227 x = prod {B} B},\n    have h\ud835\udcd0 : \u2200 x, x \u2208 \ud835\udcd0 \u2194 \u2203 B, B \u2286 A \u2227 B \u2260 \u2205 \u2227 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 \u27e8B', hBB', b, hb, hbp\u27e9, 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 \u27e8_, hBA, hb\u27e9,\n    have h\ud835\udcd0' : \u2200 a \u2208 \ud835\udcd0, a \u2260 \u2205 \u2227 \u2200 b \u2208 \ud835\udcd0, b \u2260 a \u2192 a \u2229 b = \u2205, intros a ha,\n      rw h\ud835\udcd0 _ at ha, rcases ha with \u27e8B, -, hBne, he\u27e9, split,\n        apply ne_empty_of_inhabited, rw he,\n        replace hBne := inhabited_of_ne_empty hBne, rcases hBne with \u27e8b, hb\u27e9, use B.pair b,\n        rw [pair_mem_prod, mem_singleton], exact \u27e8rfl, hb\u27e9,\n      intros b hb hba, rw eq_empty, intros z hz,\n      rw h\ud835\udcd0 _ at hb, rcases hb with \u27e8B', -, hBne', he'\u27e9, 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 \u27e8\u27e8x, hx, y, hy, hxy\u27e9, x', hx', y', hy', hxy'\u27e9, rw [\u2190hx, \u2190hx'], rw hxy at hxy',\n        exact (pair_inj hxy').left,\n      rw hBB',\n    specialize ax4 h\ud835\udcd0', rcases ax4 with \u27e8C, hC\u27e9,\n    let F := C \u2229 \ud835\udcd0.Union, use F,\n    have hFinto : F.into_fun {x \u2208 A.powerset | x \u2260 \u2205} F.ran, rw fun_def_equiv,\n      have Fsubprod : F \u2286 {x \u2208 A.powerset | x \u2260 \u2205}.prod F.ran,\n        intros z hz, simp only [mem_inter, mem_Union, exists_prop] at hz,\n        rcases hz with \u27e8hzC, X, hX\ud835\udcd0, hzX\u27e9, simp only [mem_prod, exists_prop, mem_ran, mem_sep, mem_inter, mem_powerset],\n        rw h\ud835\udcd0 _ at hX\ud835\udcd0, rcases hX\ud835\udcd0 with \u27e8B, hBA, hBne, hX\u27e9, refine \u27e8_, \u27e8hBA, hBne\u27e9, _\u27e9, rw hX at hzX,\n        simp only [mem_prod, exists_prop, mem_singleton] at hzX, rcases hzX with \u27e8B', hB', b, hb, he\u27e9,\n        rw he at hzC, rw \u2190hB', refine \u27e8_, \u27e8_, hzC, _\u27e9, he\u27e9, simp only [mem_Union, exists_prop, h\ud835\udcd0 _],\n        refine \u27e8_, \u27e8_, hBA, hBne, rfl\u27e9, _\u27e9, simp only [pair_mem_prod, mem_singleton], exact \u27e8hB', hb\u27e9,\n      refine \u27e8Fsubprod, _\u27e9,\n      intros B hB, simp only [mem_sep, exists_prop, mem_powerset] at hB, simp only [mem_inter, mem_Union],\n      have hB\ud835\udcd0 : prod {B} B \u2208 \ud835\udcd0, rw h\ud835\udcd0 _, exact \u27e8_, hB.left, hB.right, rfl\u27e9,\n      have he : \u2203 x, C \u2229 prod {B} B = {x}, apply hC _ hB\ud835\udcd0,\n      replace he : \u2203! x, x \u2208 C \u2229 prod {B} B, rcases he with \u27e8x, he\u27e9, rw \u2190ext_iff at he, simp only [mem_singleton] at he,\n        refine \u27e8x, (he x).mpr rfl, \u03bb x' hx, _\u27e9, apply (he x').mp, exact hx,\n      simp only [mem_inter, mem_prod, exists_prop, mem_singleton] at he,\n      rcases he with \u27e8x, \u27e8hxC, B', hBB', b, hb, he\u27e9, ha\u27e9, rw [he, hBB'] at hxC, refine \u27e8_, \u27e8hxC, _, hB\ud835\udcd0, _\u27e9, \u03bb b' hb', _\u27e9,\n        rw [pair_mem_prod, mem_singleton], exact \u27e8rfl, hb\u27e9,\n      rcases hb' with \u27e8hxC', X, hX\ud835\udcd0, he'\u27e9, rw h\ud835\udcd0 X at hX\ud835\udcd0, rcases hX\ud835\udcd0 with \u27e8B'', hBA'', hBne'', hB''\u27e9,\n      refine (@pair_inj B _ B _ _).right, rw [he, hBB'] at ha, apply ha _, refine \u27e8hxC', _, rfl, b', _, rfl\u27e9,\n      rw [hB'', pair_mem_prod, mem_singleton] at he', rw he'.left, exact he'.right,\n    refine \u27e8hFinto.left, hFinto.right.left, \u03bb B hB, _\u27e9,\n    rw mem_dom at hB, rcases hB with \u27e8b, hb\u27e9,\n    have hb' : \u2203 X, X \u2208 \ud835\udcd0 \u2227 B.pair b \u2208 X, simp only [mem_inter, mem_Union, exists_prop] at hb, exact hb.right,\n    rcases hb' with \u27e8X, hX\ud835\udcd0, hBX\u27e9, rw h\ud835\udcd0 _ at hX\ud835\udcd0, rcases hX\ud835\udcd0 with \u27e8B', hBA', hB', he\u27e9,\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 \u2192 1,\n  { dsimp only [Axiom_of_choice_III, Axiom_of_choice_I], intros ax3 R hR, specialize @ax3 R.ran,\n    rcases ax3 with \u27e8G, Gfun, GsubR, hG\u27e9,\n    let F := pair_sep_eq R.dom G.ran (\u03bb x, G.fun_value {y \u2208 R.ran | x.pair y \u2208 R}),\n    have Ffun : F.is_function := pair_sep_eq_is_fun,\n    have BGdom : \u2200 {a : Set}, a \u2208 R.dom \u2192 {y \u2208 R.ran | a.pair y \u2208 R} \u2208 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 \u27e8b, hab\u27e9, exact \u27e8b, \u27e8a, hab\u27e9, hab\u27e9,\n    refine \u27e8_, Ffun, _, _\u27e9,\n      intros z hz, simp only [F, pair_sep_eq, mem_pair_sep, exists_prop] at hz,\n      rcases hz with \u27e8a, ha, b, hb, he, he'\u27e9, 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) : (\u2203 H : Set, H.into_fun B A \u2227 F.comp H = B.id) \u2194 F.onto_fun A B :=\nbegin\n  rcases hf with \u27e8hf, hd, hr\u27e9,\n  split,\n  { rintro \u27e8H, \u27e8hhf, hhd, hhr\u27e9, heq\u27e9,\n    refine \u27e8hf, hd, _\u27e9,\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 \u2190T3H_c hf hhf, rw heq, symmetry, exact id_value hz,\n      rw heq, rw id_onto.right.left, assumption, }, },\n  { rintro \u27e8-, -, hre\u27e9,\n    rcases @ax_ch_1 F.inv inv_rel with \u27e8H, hhf, hhs, hhd\u27e9,\n    existsi H, split, refine \u27e8hhf, _, _\u27e9,\n      simp only [hhd, T3E_a, hre],\n      rw \u2190hd, rw \u2190T3E_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 [\u2190T3E_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 \u2190pair_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 \ud835\udcd0 : Set) : Set := {B \u2208 F.ran.powerset | \u2203 A \u2208 \ud835\udcd0, B = F.img A}\n\n@[simp]\nlemma mem_img_fun_img {F \ud835\udcd0 B : Set} : B \u2208 F.img_fun_img \ud835\udcd0 \u2194 \u2203 A \u2208 \ud835\udcd0, 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 \ud835\udcd0 : Set} : F.img \ud835\udcd0.Union = (F.img_fun_img \ud835\udcd0).Union :=\nbegin\n  apply ext, intro y, simp only [exists_prop, mem_img_fun_img, mem_img, mem_Union], split,\n  { rintro \u27e8x, \u27e8A, hA, hx\u27e9, hp\u27e9, refine \u27e8F.img A, \u27e8A, hA, rfl\u27e9, _\u27e9,\n    simp only [mem_img], exact \u27e8_, hx, hp\u27e9, },\n  { rintro \u27e8B, \u27e8A, hA, hB\u27e9, hy\u27e9, rw [hB, mem_img] at hy, rcases hy with \u27e8x, hx, hp\u27e9,\n    exact \u27e8_, \u27e8_, hA, hx\u27e9, hp\u27e9, },\nend\n\ntheorem T3K_b {F \ud835\udcd0 : Set} : F.img \ud835\udcd0.Inter \u2286 (F.img_fun_img \ud835\udcd0).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 \u27e8\u27e8F.img A, _, hA, rfl\u27e9, (\u03bb B X hX hB, _)\u27e9, rw [hB, mem_img],\n  exact \u27e8_, ha _ hX, hp\u27e9,\nend\n\ntheorem T3K_b_eq {F \ud835\udcd0 : Set} (hf : F.one_to_one) : F.img \ud835\udcd0.Inter = (F.img_fun_img \ud835\udcd0).Inter :=\nbegin\n  rw eq_iff_subset_and_subset, refine \u27e8T3K_b, _\u27e9, 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 \u2208 F.img A, exact ha _ _ hA rfl, rw mem_img at hy, rcases hy with \u27e8x, hx, hp\u27e9,\n  refine \u27e8_, \u27e8\u27e8_, hA\u27e9, (\u03bb X hX, _)\u27e9, hp\u27e9,\n  have hy : y \u2208 F.img X, exact ha _ _ hX rfl, rw mem_img at hy, rcases hy with \u27e8x', hx', hp'\u27e9,\n  have he : x = x', refine unique_of_exists_unique (hf y _) hp hp', rw mem_ran, exact \u27e8_, hp\u27e9,\n  rw he, assumption,\nend\n\ntheorem T3K_c {F A B : Set} : F.img A \\ F.img B \u2286 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 \u27e8_, \u27e8hx, (\u03bb h, ha _ h hp)\u27e9, hp\u27e9,\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 \u27e8T3K_c, _\u27e9, 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 \u27e8\u27e8_, hA, hp\u27e9, (\u03bb x' hB' hp', _)\u27e9, apply hB,\n  have he : x = x', refine unique_of_exists_unique (hf y _) hp hp', rw mem_ran, exact \u27e8_, hp\u27e9,\n  rw he, assumption,\nend\n\ndef into_funs (X Y : Set) : Set := {f \u2208 (X.prod Y).powerset | f.into_fun X Y}\n\n@[simp]\nlemma mem_into_funs {X Y f : Set} : f \u2208 X.into_funs Y \u2194 f.into_fun X Y :=\nbegin\n  simp only [into_funs, mem_powerset, and_iff_right_iff_imp, mem_sep], rintros \u27e8hf, hd, hr\u27e9 p hp,\n  have hp' : \u2203 x y : Set, p = x.pair y, from hf.left _ hp,\n  rcases hp' with \u27e8x, y, hp'\u27e9,\n  simp *,\n  have hd' : x \u2208 f.dom, rw hp' at hp, simp, exact \u27e8_, hp\u27e9,\n  have hr' : y \u2208 f.ran, rw hp' at hp, simp, exact \u27e8_, hp\u27e9,\n  rw hd at hd', refine \u27e8hd', hr hr'\u27e9,\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 \u2205 = \u2205 :=\nbegin\n  rw eq_empty, intros f hf, rw mem_into_funs at hf, rcases h with \u27e8x, hx\u27e9, rcases hf with \u27e8hf, hd, hr\u27e9,\n  rw \u2190hd at hx, rw mem_dom at hx, rcases hx with \u27e8y, hy\u27e9, apply (mem_empty y), apply hr, rw mem_ran,\n  exact \u27e8_, hy\u27e9,\nend\n\ntheorem ex2 {A : Set} : (\u2205 : Set).into_funs A = {\u2205} :=\nbegin\n  apply ext, simp only [mem_singleton, mem_into_funs], intro f, split,\n  { rintro \u27e8\u27e8hre, hf\u27e9, hd, hr\u27e9, rw eq_empty, intros p hp,\n    have hx := hre _ hp,\n    rcases hx with \u27e8x, y, hx\u27e9, rw hx at hp, apply mem_empty x, rw \u2190hd, rw mem_dom, exact \u27e8_, hp\u27e9, },\n  { have hd : (\u2205 : Set).dom = \u2205, rw eq_empty, intros x hx, rw mem_dom at hx, rcases hx with \u27e8y, hy\u27e9,\n      exact mem_empty _ hy,\n    intro he, rw he, refine \u27e8\u27e8(\u03bb p hp, _), (\u03bb x hx, _)\u27e9, _, _\u27e9,\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 \u27e8y, hy\u27e9,\n        exfalso, exact mem_empty _ hy, }, },\nend\n\ntheorem p16 : \u00ac \u2203 X : Set, \u2200 f : Set, f \u2208 X \u2194 f.is_function :=\nbegin\n  rintro \u27e8X, hX\u27e9, apply univ_not_set, refine \u27e8X.Union.Union.Union, (\u03bb x, _)\u27e9,\n  simp only [exists_prop, mem_Union], refine \u27e8{x}, \u27e8x.pair x, \u27e8{x.pair x}, _, _\u27e9, _\u27e9, _\u27e9,\n  { rw hX, refine \u27e8(\u03bb p hp, _), (\u03bb t ht, \u27e8x, _, _\u27e9)\u27e9,\n    { rw mem_singleton at hp, rw hp, exact \u27e8_, _, rfl\u27e9, },\n    { change t.pair x \u2208 {x.pair x}, rw mem_singleton, rw mem_dom at ht, rcases ht with \u27e8y, hy\u27e9,\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 \u27e8z, hxz, hzy\u27e9, rcases hx' with \u27e8z', hxz', hzy'\u27e9,\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 \u27e8a, b, d, hz, hT, c, hS, hR\u27e9, exact \u27e8a, c, d, hz, \u27e8b, hT, hS\u27e9, hR\u27e9, },\n  { rintro \u27e8a, c, d, hz, \u27e8b, hT, hS\u27e9, hR\u27e9, exact \u27e8a, b, d, hz, hT, c, hS, hR\u27e9, },\nend\n\nsection p30\nparameters {A F : Set.{u}}\n\ndef B : Set := {X \u2208 A.powerset | F.fun_value X \u2286 X}.Inter\ndef C : Set := {X \u2208 A.powerset | X \u2286 F.fun_value X}.Union\n\nlemma F_sub_of_self (hf : F.into_fun A.powerset A.powerset) {X : Set} (h : X \u2208 A.powerset) : F.fun_value X \u2208 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 \u2208 A.powerset :=\nbegin\n  rw mem_powerset, intro z, simp only [C, mem_Union, exists_prop, mem_sep, mem_powerset],\n  rintro \u27e8X, \u27e8hX, -\u27e9, hz\u27e9, exact hX hz,\nend\n\nlemma B_subset_A (hf : F.into_fun A.powerset A.powerset) : B \u2208 A.powerset :=\nbegin\n  rw mem_powerset, intro z, simp only [B, mem_Inter, mem_sep],\n  rintro \u27e8hin, ha\u27e9, apply ha, refine \u27e8mem_powerset_self, _\u27e9, rw \u2190mem_powerset, apply F_sub_of_self hf,\n  exact mem_powerset_self,\nend\n\nlemma subset_C {X : Set} (hA : X \u2208 A.powerset) (hX : X \u2286 F.fun_value X) : X \u2286 C :=\nbegin\n  rw C, apply subset_Union, rw [mem_sep, mem_powerset], finish,\nend\n\nlemma B_subset {X : Set} (hA : X \u2208 A.powerset) (hX : F.fun_value X \u2286 X) : B \u2286 X :=\nbegin\n  rw B, apply subset_Inter, rw [mem_sep, mem_powerset], finish,\nend\n\ntheorem p30_b {X : Set}\n(hA : X \u2286 A)\n(hX : F.fun_value X = X)\n: B \u2286 X \u2227 X \u2286 C :=\nbegin\n  rw eq_iff_subset_and_subset at hX, refine \u27e8(\u03bb x hx, _), (\u03bb x hx, _)\u27e9,\n  { rw B at hx, simp only [mem_Inter, mem_sep, mem_powerset] at hx,\n    apply hx.right, exact \u27e8hA, hX.left\u27e9, },\n  { rw C, simp only [mem_Union, mem_sep, mem_powerset, exists_prop],\n    exact \u27e8_, \u27e8hA, hX.right\u27e9, hx\u27e9, },\nend\n\ntheorem p30_a {hf : F.into_fun A.powerset A.powerset}\n{hmon : \u2200 {X Y : Set}, X \u2286 Y \u2192 Y \u2208 A.powerset \u2192 F.fun_value X \u2286 F.fun_value Y}\n: F.fun_value B = B \u2227 F.fun_value C = C :=\nbegin\n  have hC : C \u2286 F.fun_value C, intros z hz,\n    simp only [C, mem_Union, exists_prop, mem_sep] at hz,\n    rcases hz with \u27e8X, \u27e8hA, hX\u27e9, hz\u27e9, exact hmon (subset_C hA hX) C_subset_A (hX hz),\n  have hB : F.fun_value B \u2286 B, intros z hz,\n    simp only [B, mem_Inter, mem_sep], refine \u27e8\u27e8A, _\u27e9, (\u03bb X \u27e8hA, hX\u27e9, hX (hmon (B_subset hA hX) hA hz))\u27e9,\n    simp only [mem_sep], rw \u2190mem_powerset, refine \u27e8mem_powerset_self, _\u27e9,\n    apply F_sub_of_self hf, exact mem_powerset_self,\n  simp only [eq_iff_subset_and_subset], refine \u27e8\u27e8hB, _\u27e9, _, hC\u27e9,\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 \u2208 I.into_funs (H.img I).Union | f.is_function \u2227 f.dom = I \u2227 \u2200 i : Set, i \u2208 I \u2192 f.fun_value i \u2208 H.fun_value i}\n\n@[simp]\nlemma mem_inf_prod {H I f : Set} (hF : H.is_function) (hD : I \u2286 H.dom)\n: f \u2208 H.inf_prod I \u2194 f.is_function \u2227 f.dom = I \u2227 \u2200 i : Set, i \u2208 I \u2192 f.fun_value i \u2208 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 \u27e8hf, hd, (\u03bb y hy, _)\u27e9, simp only [mem_Union, exists_prop, mem_img_fun_img],\n  rw mem_ran at hy, rcases hy with \u27e8x, hy\u27e9,\n  have hxi : x \u2208 I, rw [\u2190hd, mem_dom], exact \u27e8_, hy\u27e9,\n  have hY := ha _ hxi, rcases hY with \u27e8Y, hH, hY\u27e9,\n  refine \u27e8Y, _, _\u27e9,\n  { simp only [mem_img], refine \u27e8x, hxi, hH\u27e9, },\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 : \u2200 i : Set, i \u2208 I \u2192 H.fun_value i \u2260 \u2205)\n: (H.inf_prod I ).inhab :=\nbegin\n  have hD' : I \u2286 H.dom, rw hD, exact subset_self,\n  simp only [inhab, mem_inf_prod hF hD'], exact @ax_ch_2 _ _ \u27e8hF, hD, hA\u27e9,\nend\n\ndef symmetric (R : Set) : Prop := \u2200 \u2983x y : Set\u2984, x.pair y \u2208 R \u2192 y.pair x \u2208 R\ndef transitive (R : Set) : Prop := \u2200 \u2983x y z : Set\u2984, x.pair y \u2208 R \u2192 y.pair z \u2208 R \u2192 x.pair z \u2208 R\n\nstructure equiv_rel (R A : Set) : Prop :=\n(rel : R \u2286 A.prod A)\n(refl : \u2200 \u2983x : Set\u2984, x \u2208 A \u2192 x.pair x \u2208 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 \u27e8(\u03bb p hp, _), _, hs, ht\u27e9,\n  { have h : \u2203 x y : Set, p = x.pair y := hr _ hp, rcases h with \u27e8x, y, h\u27e9, rw h at hp,\n    simp only [mem_prod, exists_prop, fld, mem_union, mem_dom, mem_ran],\n    exact \u27e8_, or.inl \u27e8_, hp\u27e9, _, or.inr \u27e8_, hp\u27e9, h\u27e9, },\n  have h : \u2200 {x y : Set}, x.pair y \u2208 R \u2192 x.pair x \u2208 R,\n    intros x y h, exact ht h (hs h),\n  simp only [fld, mem_union, mem_dom, mem_ran], rintros x (\u27e8y, hp\u27e9|\u27e8y, hp\u27e9),\n  { exact h hp, },\n  { exact h (hs hp), },\nend\n\ndef eq_class (R x : Set) : Set := {t \u2208 R.ran | x.pair t \u2208 R}\n\n@[simp]\nlemma mem_eq_class {R x t : Set} : t \u2208 R.eq_class x \u2194 x.pair t \u2208 R :=\nbegin\n  simp only [eq_class, and_iff_right_iff_imp, mem_ran, mem_sep],\n  intro h, exact \u27e8_, h\u27e9,\nend\n\nlemma mem_eq_class_of_self {R A x : Set} (hr : R.equiv_rel A) (hx : x \u2208 A) : x \u2208 R.eq_class x :=\nbegin\n  rw mem_eq_class, exact hr.refl hx,\nend\n\ndef eq_classes (R A : Set) : Set := {X \u2208 R.ran.powerset | \u2203 x : Set, X = R.eq_class x \u2227 x \u2208 A}\n\n@[simp]\nlemma mem_eq_classes {R A X : Set} : X \u2208 R.eq_classes A \u2194 \u2203 x : Set, X = R.eq_class x \u2227 x \u2208 A :=\nbegin\n  simp only [eq_classes, mem_powerset, and_iff_right_iff_imp, exists_imp_distrib, mem_sep],\n  rintros x \u27e8hX, hx\u27e9, 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 \u2208 A) (hy : y \u2208 A)\n: R.eq_class x = R.eq_class y \u2194 x.pair y \u2208 R :=\nbegin\n  refine \u27e8(\u03bb h, _), (\u03bb h, _)\u27e9,\n  { rw [\u2190mem_eq_class, h, mem_eq_class], exact hr.refl hy, },\n  { apply ext, intro t, simp only [mem_eq_class], split,\n    { exact (\u03bb ht, hr.trans (hr.symm h) ht), },\n    { exact (\u03bb ht, hr.trans h ht), }, },\nend\n\nstructure partition (P A : Set) : Prop :=\n(subs : \u2200 \u2983x : Set\u2984, x \u2208 P \u2192 x \u2286 A)\n(nonem : \u2200 \u2983x : Set\u2984, x \u2208 P \u2192 x \u2260 \u2205)\n(disj : \u2200 \u2983x y : Set\u2984, x \u2208 P \u2192 y \u2208 P \u2192 x \u2260 y \u2192 (x \u2229 y) = \u2205)\n(exhaust : \u2200 \u2983x : Set\u2984, x \u2208 A \u2192 \u2203 X : Set, X \u2208 P \u2227 x \u2208 X)\n\ntheorem T3P {R A : Set} (hr : R.equiv_rel A) : (R.eq_classes A).partition A :=\nbegin\n  refine \u27e8_, _, _, _\u27e9,\n  { simp only [mem_eq_classes], rintros X \u27e8x, hX\u27e9 t ht, simp only [hX, mem_eq_class] at ht,\n    replace ht : x.pair t \u2208 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 \u27e8x, hX, hx\u27e9, 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 \u27e8x, hX, hx\u27e9 \u27e8y, hY, hy\u27e9 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 \u27e8_, \u27e8_, rfl, hx\u27e9, mem_eq_class_of_self hr hx\u27e9, },\nend\n\n-- I'm not writing any lemmas for this unless we use it\ndef natural_map (R A : Set) : Set := pair_sep (\u03bb 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 \u2286 A.prod A)\n(trans : R.transitive)\n(irrefl : \u2200 \u2983x : Set\u2984, x.pair x \u2209 R)\n(conn : \u2200 \u2983x y : Set\u2984, x \u2208 A \u2192 y \u2208 A \u2192 x \u2260 y \u2192 x.pair y \u2208 R \u2228 y.pair x \u2208 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 \u22a2, 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 \u2229 D = \u2205) : A.prod C \u2229 B.prod D = \u2205 :=\nbegin\n  rw eq_empty, intros z hz, simp only [mem_inter, mem_prod, exists_prop] at hz,\n  rcases hz with \u27e8\u27e8a, ha, b, hb, he\u27e9, a', ha', b', hb', he'\u27e9,\n  rw he' at he, rw (pair_inj he).right at hb',\n  have hb'' : b \u2208 C \u2229 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 \u2260 B) : {A} \u2229 {B} = (\u2205 : Set) :=\nbegin\n  rw eq_empty, intros z hz, simp only [mem_inter, mem_singleton] at hz, apply hne, rw \u2190hz.left, rw \u2190hz.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 : \u2200 a b : H, a * b = b * a) : subgroup.center H = \u22a4 :=\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 = \u22a4 :=\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 = \u22a4)) : (\u2200 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 : \u2115) [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 \u2192 \u2203 q : \u2115 , 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 \u29f8 subgroup.center G) :=\ninfer_instance\n\n\nlemma center_index_not_prime : \u00ac nat.prime (fintype.card (G \u29f8 subgroup.center G)) :=\nbegin\n  intro h1,\n  haveI : fact(nat.prime (card (G \u29f8 subgroup.center G))) := \u27e8h1\u27e9,\n  haveI := is_cyclic_of_prime_card (rfl : card (G \u29f8 subgroup.center G) = _),\n  have h2 := commutative_of_cyclic_center_quotient (quotient_group.mk' (subgroup.center G)) (by simp),\n  have h4 : card (G \u29f8 subgroup.center G) = 1,\n  {\n    simp_rw [group.center_eq_top_of_comm h2, \u2190 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 : \u00ac nat.prime (fintype.card (G \u29f8 subgroup.center G)) :=\nbegin\n  intro h1,\n  haveI : fact(nat.prime (card (G \u29f8 subgroup.center G))) := \u27e8h1\u27e9,\n  haveI := is_cyclic_of_prime_card (rfl : card (G \u29f8 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 = \u22a4,\n  {\n    exact comm_group.center_eq_top,  -- not working\n  },\n  have h4 : card (G \u29f8 subgroup.center G) = 1,\n  {\n    simp_rw [h3, \u2190 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] : (\u2200 x1 x2 : G, x1 * x2 = x2 * x1) :=\nbegin\n  apply group.of_comm_center_eq_top,\n  have h1 : (card (subgroup.center G) \u2223 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 \u27e8k, hk1, hk2\u27e9,\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 : \u2115) : a + b + c = a + c + b :=\nbegin\n  rw [add_assoc, add_comm b, \u2190add_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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u2264 b` implies the existence of\n  `a'` such that `a \u2264 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 \u03b1 \u03b2 \u03b3 \u03b4 : Type*}\n\n/-- The type of pseudo-epimorphisms, aka p-morphisms, aka bounded maps, from `\u03b1` to `\u03b2`. -/\nstructure pseudo_epimorphism (\u03b1 \u03b2 : Type*) [preorder \u03b1] [preorder \u03b2] extends \u03b1 \u2192o \u03b2 :=\n(exists_map_eq_of_map_le' \u2983a : \u03b1\u2984 \u2983b : \u03b2\u2984 : to_fun a \u2264 b \u2192 \u2203 c, a \u2264 c \u2227 to_fun c = b)\n\n/-- The type of Esakia morphisms, aka continuous pseudo-epimorphisms, from `\u03b1` to `\u03b2`. -/\nstructure esakia_hom (\u03b1 \u03b2 : Type*) [topological_space \u03b1] [preorder \u03b1] [topological_space \u03b2]\n  [preorder \u03b2] extends \u03b1 \u2192Co \u03b2 :=\n(exists_map_eq_of_map_le' \u2983a : \u03b1\u2984 \u2983b : \u03b2\u2984 : to_fun a \u2264 b \u2192 \u2203 c, a \u2264 c \u2227 to_fun c = b)\n\n/-- `pseudo_epimorphism_class F \u03b1 \u03b2` states that `F` is a type of `\u2294`-preserving morphisms.\n\nYou should extend this class when you extend `pseudo_epimorphism`. -/\nclass pseudo_epimorphism_class (F : Type*) (\u03b1 \u03b2 : out_param $ Type*) [preorder \u03b1] [preorder \u03b2]\n  extends rel_hom_class F ((\u2264) : \u03b1 \u2192 \u03b1 \u2192 Prop) ((\u2264) : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n(exists_map_eq_of_map_le (f : F) \u2983a : \u03b1\u2984 \u2983b : \u03b2\u2984 : f a \u2264 b \u2192 \u2203 c, a \u2264 c \u2227 f c = b)\n\n/-- `esakia_hom_class F \u03b1 \u03b2` 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*) (\u03b1 \u03b2 : out_param $ Type*) [topological_space \u03b1] [preorder \u03b1]\n  [topological_space \u03b2] [preorder \u03b2]\n  extends continuous_order_hom_class F \u03b1 \u03b2 :=\n(exists_map_eq_of_map_le (f : F) \u2983a : \u03b1\u2984 \u2983b : \u03b2\u2984 : f a \u2264 b \u2192 \u2203 c, a \u2264 c \u2227 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 \u03b1] [order_top \u03b1] [preorder \u03b2]\n  [order_top \u03b2] [pseudo_epimorphism_class F \u03b1 \u03b2] : top_hom_class F \u03b1 \u03b2 :=\n\u27e8\u03bb f, let \u27e8b, h\u27e9 := exists_map_eq_of_map_le f (@le_top _ _ _ $ f \u22a4) in\n  by rw [\u2190top_le_iff.1 h.1, h.2]\u27e9\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_pseudo_epimorphism_class [preorder \u03b1] [preorder \u03b2]\n  [order_iso_class F \u03b1 \u03b2] : pseudo_epimorphism_class F \u03b1 \u03b2 :=\n\u27e8\u03bb f a b h, \u27e8equiv_like.inv f b, (le_map_inv_iff f).2 h, equiv_like.right_inv _ _\u27e9\u27e9\n\n@[priority 100] -- See note [lower instance priority]\ninstance esakia_hom_class.to_pseudo_epimorphism_class [topological_space \u03b1] [preorder \u03b1]\n  [topological_space \u03b2] [preorder \u03b2] [esakia_hom_class F \u03b1 \u03b2] : pseudo_epimorphism_class F \u03b1 \u03b2 :=\n{ .. \u2039esakia_hom_class F \u03b1 \u03b2\u203a }\n\ninstance [preorder \u03b1] [preorder \u03b2] [pseudo_epimorphism_class F \u03b1 \u03b2] :\n  has_coe_t F (pseudo_epimorphism \u03b1 \u03b2) :=\n\u27e8\u03bb f, \u27e8f, exists_map_eq_of_map_le f\u27e9\u27e9\n\ninstance [topological_space \u03b1] [preorder \u03b1] [topological_space \u03b2] [preorder \u03b2]\n  [esakia_hom_class F \u03b1 \u03b2] : has_coe_t F (esakia_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f, \u27e8f, exists_map_eq_of_map_le f\u27e9\u27e9\n\n/-! ### Pseudo-epimorphisms -/\n\nnamespace pseudo_epimorphism\nvariables [preorder \u03b1] [preorder \u03b2] [preorder \u03b3] [preorder \u03b4]\n\ninstance : pseudo_epimorphism_class (pseudo_epimorphism \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := \u03bb f, f.to_fun,\n  coe_injective' := \u03bb f g h, by { obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := f, obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := g, congr' },\n  map_rel := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : pseudo_epimorphism \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n@[ext] lemma ext {f g : pseudo_epimorphism \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) :\n  pseudo_epimorphism \u03b1 \u03b2 :=\n\u27e8f.to_order_hom.copy f' h, by simpa only [h.symm, to_fun_eq_coe] using f.exists_map_eq_of_map_le'\u27e9\n\nvariables (\u03b1)\n\n/-- `id` as a `pseudo_epimorphism`. -/\nprotected def id : pseudo_epimorphism \u03b1 \u03b1 := \u27e8order_hom.id, \u03bb a b h, \u27e8b, h, rfl\u27e9\u27e9\n\ninstance : inhabited (pseudo_epimorphism \u03b1 \u03b1) := \u27e8pseudo_epimorphism.id \u03b1\u27e9\n\n@[simp] lemma coe_id : \u21d1(pseudo_epimorphism.id \u03b1) = id := rfl\n@[simp] lemma coe_id_order_hom : (pseudo_epimorphism.id \u03b1 : \u03b1 \u2192o \u03b1) = order_hom.id := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : pseudo_epimorphism.id \u03b1 a = a := rfl\n\n/-- Composition of `pseudo_epimorphism`s as a `pseudo_epimorphism`. -/\ndef comp (g : pseudo_epimorphism \u03b2 \u03b3) (f : pseudo_epimorphism \u03b1 \u03b2) : pseudo_epimorphism \u03b1 \u03b3 :=\n\u27e8g.to_order_hom.comp f.to_order_hom, \u03bb a b h\u2080, begin\n  obtain \u27e8b, h\u2081, rfl\u27e9 := g.exists_map_eq_of_map_le' h\u2080,\n  obtain \u27e8b, h\u2082, rfl\u27e9 := f.exists_map_eq_of_map_le' h\u2081,\n  exact \u27e8b, h\u2082, rfl\u27e9,\nend\u27e9\n\n@[simp] lemma coe_comp (g : pseudo_epimorphism \u03b2 \u03b3) (f : pseudo_epimorphism \u03b1 \u03b2) :\n  (g.comp f : \u03b1 \u2192 \u03b3) = g \u2218 f := rfl\n@[simp] lemma coe_comp_order_hom (g : pseudo_epimorphism \u03b2 \u03b3) (f : pseudo_epimorphism \u03b1 \u03b2) :\n  (g.comp f : \u03b1 \u2192o \u03b3) = (g : \u03b2 \u2192o \u03b3).comp f := rfl\n@[simp] lemma comp_apply (g : pseudo_epimorphism \u03b2 \u03b3) (f : pseudo_epimorphism \u03b1 \u03b2) (a : \u03b1) :\n  (g.comp f) a = g (f a) := rfl\n@[simp] lemma comp_assoc (h : pseudo_epimorphism \u03b3 \u03b4) (g : pseudo_epimorphism \u03b2 \u03b3)\n  (f : pseudo_epimorphism \u03b1 \u03b2) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[simp] \n\nlemma cancel_right {g\u2081 g\u2082 : pseudo_epimorphism \u03b2 \u03b3} {f : pseudo_epimorphism \u03b1 \u03b2}\n  (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : pseudo_epimorphism \u03b2 \u03b3} {f\u2081 f\u2082 : pseudo_epimorphism \u03b1 \u03b2} (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, ext $ \u03bb a, hg $ by rw [\u2190comp_apply, h, comp_apply], congr_arg _\u27e9\n\nend pseudo_epimorphism\n\n/-! ### Esakia morphisms -/\n\nnamespace esakia_hom\nvariables [topological_space \u03b1] [preorder \u03b1] [topological_space \u03b2] [preorder \u03b2]\n  [topological_space \u03b3] [preorder \u03b3] [topological_space \u03b4] [preorder \u03b4]\n\n/-- Reinterpret an `esakia_hom` as a `pseudo_epimorphism`. -/\ndef to_pseudo_epimorphism (f : esakia_hom \u03b1 \u03b2) : pseudo_epimorphism \u03b1 \u03b2 := { ..f }\n\ninstance : esakia_hom_class (esakia_hom \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := \u03bb f, f.to_fun,\n  coe_injective' := \u03bb f g h,\n    by { obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := f, obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := g, congr' },\n  map_rel := \u03bb f, f.monotone',\n  map_continuous := \u03bb f, f.continuous_to_fun,\n  exists_map_eq_of_map_le := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : esakia_hom \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n@[ext] lemma ext {f g : esakia_hom \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : esakia_hom \u03b1 \u03b2 :=\n\u27e8f.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'\u27e9\n\nvariables (\u03b1)\n\n/-- `id` as an `esakia_hom`. -/\nprotected def id : esakia_hom \u03b1 \u03b1 := \u27e8continuous_order_hom.id \u03b1, \u03bb a b h, \u27e8b, h, rfl\u27e9\u27e9\n\ninstance : inhabited (esakia_hom \u03b1 \u03b1) := \u27e8esakia_hom.id \u03b1\u27e9\n\n@[simp] lemma coe_id : \u21d1(esakia_hom.id \u03b1) = id := rfl\n@[simp] lemma coe_id_continuous_order_hom :\n  (esakia_hom.id \u03b1 : \u03b1 \u2192Co \u03b1) = continuous_order_hom.id \u03b1 := rfl\n@[simp] lemma coe_id_pseudo_epimorphism :\n  (esakia_hom.id \u03b1 : pseudo_epimorphism \u03b1 \u03b1) = pseudo_epimorphism.id \u03b1  := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : esakia_hom.id \u03b1 a = a := rfl\n\n/-- Composition of `esakia_hom`s as an `esakia_hom`. -/\ndef comp (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) : esakia_hom \u03b1 \u03b3 :=\n\u27e8g.to_continuous_order_hom.comp f.to_continuous_order_hom, \u03bb a b h\u2080, begin\n  obtain \u27e8b, h\u2081, rfl\u27e9 := g.exists_map_eq_of_map_le' h\u2080,\n  obtain \u27e8b, h\u2082, rfl\u27e9 := f.exists_map_eq_of_map_le' h\u2081,\n  exact \u27e8b, h\u2082, rfl\u27e9,\nend\u27e9\n\n@[simp] lemma coe_comp (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) : (g.comp f : \u03b1 \u2192 \u03b3) = g \u2218 f := rfl\n@[simp] lemma comp_apply (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) (a : \u03b1) :\n  (g.comp f) a = g (f a) := rfl\n@[simp] lemma coe_comp_continuous_order_hom (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) :\n  (g.comp f : \u03b1 \u2192Co \u03b3) = (g : \u03b2 \u2192Co \u03b3).comp f := rfl\n@[simp] lemma coe_comp_pseudo_epimorphism (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) :\n  (g.comp f : pseudo_epimorphism \u03b1 \u03b3) = (g : pseudo_epimorphism \u03b2 \u03b3).comp f := rfl\n@[simp] lemma comp_assoc (h : esakia_hom \u03b3 \u03b4) (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[simp] lemma comp_id (f : esakia_hom \u03b1 \u03b2) : f.comp (esakia_hom.id \u03b1) = f := ext $ \u03bb a, rfl\n@[simp] lemma id_comp (f : esakia_hom \u03b1 \u03b2) : (esakia_hom.id \u03b2).comp f = f := ext $ \u03bb a, rfl\n\nlemma cancel_right {g\u2081 g\u2082 : esakia_hom \u03b2 \u03b3} {f : esakia_hom \u03b1 \u03b2} (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : esakia_hom \u03b2 \u03b3} {f\u2081 f\u2082 : esakia_hom \u03b1 \u03b2} (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, ext $ \u03bb a, hg $ by rw [\u2190comp_apply, h, comp_apply], congr_arg _\u27e9\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} \u2192 Loop v \u2192 Sort _\n  inv : {v w : V} \u2192 (e : v \u27f6 w) \u2192 relator (.cons (op e) $ .cons e .nil) -- the trivial relations are satisfied\n  flip :  {v : V} \u2192 {l : Loop v} \u2192 relator l \u2192 relator l.inv\n  flip_inv : {v : V} \u2192 {l : Loop v} \u2192 (r : relator l) \u2192 (Eq.subst l.inverse_inv $ flip (flip r)) = r\n\ninductive NullHomotopy {V : Sort _} [CombinatorialTwoComplex V] : {v : V} \u2192 (\u2113 : Loop v) \u2192 Sort _\n  | nil : {v : V} \u2192  NullHomotopy (.nil v)\n  | relator : {v : V} \u2192 {l : Loop v} \u2192 CombinatorialTwoComplex.relator l \u2192 NullHomotopy l\n  | concat : {v : V} \u2192 {l l' : Loop v} \u2192 NullHomotopy l \u2192 NullHomotopy l' \u2192 NullHomotopy (.append l l')\n  | delete : {v : V} \u2192 {l l' : Loop v} \u2192 NullHomotopy l \u2192 NullHomotopy (.append l l') \u2192 NullHomotopy l'\n  | rotate : {v : V} \u2192 {l : Loop v} \u2192 NullHomotopy l \u2192 NullHomotopy l.rotate\n  | rotate' : {v : V} \u2192 {l : Loop v} \u2192 NullHomotopy l \u2192 NullHomotopy l.rotate'\n\ninductive Path.Homotopy {V : Sort _} [CombinatorialTwoComplex V] : {v w : V} \u2192 (p q : Path v w) \u2192 Prop\n  | rel : {v w : V} \u2192 {p q : Path v w} \u2192 NullHomotopy (.append p q.inverse) \u2192 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} \u2192 (h : u = v) \u2192 (l : Loop u) \u2192 (l' : Loop v) \u2192 (l = (congrArg Loop h) \u25b8 l') \u2192 NullHomotopy l \u2192 NullHomotopy l'\n  | _, _, rfl, _, _, rfl => id\n\ndef swap {u v : V} : {p : Path u v} \u2192 {q : Path v u} \u2192 NullHomotopy (.append p q) \u2192 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)) \u2192 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) \u2192 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) \u2192 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 [\u2190 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    \u00b7 apply NullHomotopy.relator\n      apply CombinatorialTwoComplex.inv\n    \u00b7 apply trivial\n\ndef inv {v : V} {l : Loop v} : NullHomotopy l \u2192 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      \u00b7 exact inv r'\n      \u00b7 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      \u00b7 apply Loop.rotate'_inv\n      \u00b7 exact rotate' <| inv r\n  | .rotate' r => by\n      apply subst (Loop.next_inv _ _)\n      \u00b7 apply Loop.rotate_inv\n      \u00b7 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) \u2192 Path.Homotopy p p := (.rel $ NullHomotopy.trivial \u00b7)\n\ntheorem symm : Path.Homotopy p q \u2192 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 \u2192 Path.Homotopy q r \u2192 Path.Homotopy p r\n  |.rel h, .rel h' => by\n    let H := NullHomotopy.concat h h'\n    rw [Path.append_assoc p _ _, \u2190 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 \u2192 Path.Homotopy r s \u2192 \n  Path.Homotopy (.append p r) (.append q s)\n  | .rel a, .rel b  => .rel $ by\n    rw [inverse_append, append_assoc, \u2190 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 \u2192 \n  Path.Homotopy p.inverse q.inverse\n  | .rel r =>.rel $ by\n    rw [\u2190 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 : \u2115 ) ( b : \u2115 )\n\n@[reducible] def f ( x : X ) : X := \u27e8 x^.b + 1, x^.a \u27e9\n\nlemma t (x : \u2115 \u00d7 \u2115) : (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 := \u2203 x, e.isLE x\n\nnamespace Finite\nvariable (e : ENat)\n\nprivate def rel (x y : Nat) : Prop := x = y + 1 \u2227 \u00ace.isLE y\n\nprivate def wf (isFinite : Finite e) : WellFounded (Finite.rel e) := by\n  constr\n  intro x\n  match isFinite with\n  | \u27e8n,hn\u27e9 =>\n    apply Acc.intro\n    intro x' \u27e8h', hx\u27e9\n    cases h'\n    have : x + 1 \u2264 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    | \u27e8y, hxy\u27e9 =>\n      clear this\n      induction y generalizing x with\n      | zero =>\n        rw [hxy]\n        apply Acc.intro\n        intro | _, \u27e8rfl, _\u27e9 => contradiction\n      | succ y H =>\n        apply Acc.intro\n        intro\n        | _, \u27e8rfl, h\u27e9 =>\n          apply H\n          \u00b7 exact h\n          \u00b7 rw [\u2190hxy]\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' \u27e8Finite.rel e, Finite.wf e isFinite\u27e9\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  \u00b7 assumption\n  \u00b7 apply isLE_toNatAux\ntermination_by' \u27e8Finite.rel e, Finite.wf e isFinite\u27e9\ndecreasing_by trivial\n\nprivate theorem toNatAux_le {e : ENat} {y : Nat} (hy : e.isLE y) {x} (hle : x \u2264 y) : toNatAux \u27e8y,hy\u27e9 x \u2264 y := by\n  rw [toNatAux_eq]\n  split\n  \u00b7 assumption\n  \u00b7 apply toNatAux_le hy\n    apply Nat.succ_le_of_lt\n    apply Nat.lt_of_le_of_ne\n    \u00b7 exact hle\n    \u00b7 intro heq\n      cases heq\n      contradiction\ntermination_by' invImage PSigma.fst \u27e8Finite.rel e, Finite.wf e \u27e8y,hy\u27e9\u27e9\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 \u27e8x,h\u27e9 \u2264 x := by\n  apply toNatAux_le\n  \u00b7 exact h\n  \u00b7 exact Nat.zero_le x\n\ntheorem isLE_iff_toNat_le (e : ENat) (isFinite : Finite e) (x : Nat) : e.isLE x \u2194 e.toNat isFinite \u2264 x := by\n  constr\n  \u00b7 intro h\n    apply toNat_le_of_isLE\n    exact h\n  \u00b7 intro h\n    apply mono _ h\n    apply isLE_toNat\n\n@[simp] theorem toNat_ofNat (x : Nat) : toNat (ENat.ofNat x) \u27e8x, ofNat_isLE_self x\u27e9 = x := by\n  antisymmetry using (.\u2264.:Nat\u2192Nat\u2192Prop)\n  \u00b7 rw [\u2190isLE_iff_toNat_le]\n    exact ofNat_isLE_self x\n  \u00b7 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 : _ \u2264 x)\n      rw [\u2190isLE_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, \u2190isLE_iff_toNat_le, hx]\n  | false =>\n    rw [\u2190Bool.not_eq_true] at hx \u22a2\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 : \u2115} (xs : dvector (struc_to_ring_struc.Structure A) c)\n\n@[simp] lemma list_sumr :\n  \u03a0 {l : list (bounded_ring_term c)},\n  realize_bounded_term xs (list.sumr l) dvector.nil\n  =\n  list.sumr (list.map (\u03bb 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\u27e8 \u03bb t, realize_bounded_term xs t dvector.nil ,\n  models_ring_theory_to_comm_ring.realize_zero ,\n  \u03bb t s, models_ring_theory_to_comm_ring.realize_add \u27e9\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 \u2190 list.add_zero_hom_sumr (add_zero_hom xs) ts,\n  refl,\nend\n\nlemma nat_non_comm_prod :\n  \u03a0 (n : \u2115) (ts : fin n \u2192 bounded_ring_term c),\n  realize_bounded_term xs (nat.non_comm_prod _ ts) dvector.nil\n  =\n  nat.non_comm_prod n (\u03bb 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) : \u03a0 (n : \u2115),\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 : \u2124 \u2192 eexpr\n| str : string \u2192 eexpr\n| var : \u2115 \u2192 eexpr\n| plus : eexpr \u2192 eexpr \u2192 eexpr\n| cat : eexpr \u2192 eexpr \u2192 eexpr\n| len : eexpr \u2192 eexpr\n| lett : eexpr \u2192 eexpr \u2192 eexpr\n\ninductive typ : Type\n| num : typ\n| str : typ\n\ndef env : Type := list typ\n\ndef lookup (n : \u2115 ) (\u03c4 : typ) (\u0393 : env) : Prop :=\n  list.nth \u0393 n = some \u03c4\n\nlemma lookup_lt (n : \u2115 ) (\u03c4 : typ) (\u0393 : env) (h : lookup n \u03c4 \u0393 ) :\n  n < list.length \u0393 :=\nbegin\n  induction' \u0393 ,\n  simp [lookup] at h,\n  contradiction,\n  cases' n,\n  simp,\n  simp,\n  have : n < \u0393.length, {\n    apply ih n \u03c4,\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 \u2192 eexpr \u2192 typ \u2192 Prop\n| refl (n : \u2115 ) (\u03c4 : typ) (\u0393 : env) :\n      lookup n \u03c4 \u0393 \u2192\n      has_type \u0393 (eexpr.var n) \u03c4\n| strlit (s : string) (\u0393 : env) :\n      has_type \u0393 (eexpr.str s) typ.str\n| numlit (n : \u2124) (\u0393 : env) :\n      has_type \u0393 (eexpr.int n) typ.num\n| plus (e1 e2 : eexpr) (\u0393 : env) :\n      has_type \u0393 e1 typ.num \u2192\n      has_type \u0393 e2 typ.num \u2192\n      has_type \u0393 (eexpr.plus e1 e2) typ.num\n| cat (e1 e2 : eexpr) (\u0393 : env) :\n      has_type \u0393 e1 typ.str \u2192\n      has_type \u0393 e2 typ.str \u2192\n      has_type \u0393 (eexpr.cat e1 e2) typ.str\n| len (e1 : eexpr) (\u0393 : env) :\n      has_type \u0393 e1 typ.str \u2192\n      has_type \u0393 (eexpr.len e1) typ.num\n| lett (e1 e2 : eexpr) (\u03c41 \u03c42: typ) (\u0393 : env): \n      has_type \u0393 e1 \u03c41 \u2192\n      has_type (\u03c41 :: \u0393) e2 \u03c42 \u2192\n      has_type \u0393 (eexpr.lett e1 e2) \u03c42\n\n-- \u2205 \u22a2 let 1+1 in x0 : int\n-- [int] \u22a2 x0 : int\n\n-- \u2205 \u22a2 let 1+1 in let \"foo\" in len(x0) + x1 : int\n-- [int] \u22a2 let \"foo\" in len(x0) + x1 : int\n-- [str, int] \u22a2 len(x0) + x1 : int\n\n-- Unicity: term can only have one type\nlemma unicity (\u0393 : env) (e : eexpr) (\u03c41 : typ) (h1 : has_type \u0393 e \u03c41) :\n  \u2200 \u03c42, (has_type \u0393 e \u03c42) \u2192 \u03c41 = \u03c42 :=\nbegin\n  induction' h1,\n  all_goals {\n    try {\n      intros \u03c42 h2,\n      cases h2,\n      refl,\n    }\n  },\n  case refl : v \u03c4 \u0393 h {\n    intros \u03c42 hh,\n    cases' hh,\n    simp [lookup] at *,\n    apply option.some.inj,\n    rw \u2190 h,\n    rw \u2190 h_1,\n  },\n  case has_type.lett {\n    intros \u03c42 h2,\n    cases' h2,\n    have : \u03c41 = \u03c41_2,\n    {\n      apply ih_h1,\n      assumption,\n    },\n    rw \u2190 this at *,\n    apply ih_h1_1,\n    assumption,\n  }\nend\n\nlemma env_append (\u0393 : env) (stuff : list typ) (n : \u2115 ) (\u03c4 : typ) :\n  lookup n \u03c4 \u0393 \u2192 lookup n \u03c4 (list.append \u0393 stuff) :=\nbegin\n  induction' \u0393 ,\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 (\u0393 : env) (stuff : list typ) (e : eexpr) (\u03c4 : typ) :\n  has_type \u0393 e \u03c4 \u2192 has_type (list.append \u0393 stuff) e \u03c4 :=\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 _ _ \u03c41 \u03c4,\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 (\u0393 : env) (e1 e2 : eexpr) (\u03c4 : typ) (h : has_type \u0393 (eexpr.plus e1 e2) \u03c4):\n  \u03c4 = typ.num \u2227 (has_type \u0393 e1 typ.num) \u2227 (has_type \u0393 e2 typ.num) :=\nbegin\n  cases' h,\n  split,\n  refl,\n  split,\n  assumption',\nend\n\ndef incr : \u2115 \u2192 eexpr \u2192 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 : \u2115 \u2192 eexpr \u2192 eexpr \u2192 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) (\u03c4 : typ) (\u0393 : env) (ht : has_type \u0393  e \u03c4) (n : \u2115 ) (hn : n >= list.length \u0393 ):\n  incr n e = e :=\nbegin\n  induction' ht,\n  case refl {\n    dsimp [incr],\n    simp [hn],\n    have : n_1 < list.length \u0393, 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 {\u03b1 : Type}\n\n@[simp] def insert_nth : \u2200 (l : list \u03b1) (n : \u2115) (h : n \u2264 l.length), \u03b1 \u2192 list \u03b1\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 \u03b1) (h : 0 \u2264 l.length) (x : \u03b1):\n  insert_nth l 0 h x = x :: l :=\nbegin\n  induction' l,\n  simp,\n  simp,\nend\n\nlemma map_insert (l : list \u03b1) (x : \u03b1) (n n1 : \u2115) (hn : n \u2264 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 \u2264 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) (\u03c4 \u03c4' : typ) (\u0393 : env)\n  (ht : has_type \u0393 e \u03c4) (n : \u2115 ) (hn : n \u2264 list.length \u0393 ) :\n  has_type (insert_nth \u0393 n hn \u03c4') (incr n e) \u03c4 :=\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 _ _ \u03c41,\n    apply ih_ht,\n    specialize ih_ht_1 \u03c4' 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) (\u0393 : env) (\u03c4 \u03c4' : typ)\n  (n : \u2115 ) (te : has_type \u0393 e \u03c4)\n  (hn : lookup n \u03c4 \u0393 )\n  (te' : has_type \u0393 e' \u03c4')\n  : has_type \u0393 (subst n e e') \u03c4'\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 \u2190 hh at *,\n    simp,\n    have : \u03c4' = \u03c4,\n    {\n      simp [lookup] at *,\n      apply option.some.inj,\n      rw \u2190 hn,\n      rw \u2190 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 _ _ \u03c41 \u03c4',\n    {\n      apply ih_te',\n      exact te,\n      exact hn,\n    },\n    {\n      apply ih_te'_1 (incr 0 e) \u03c4 n.succ,\n      rw \u2190 blah _ (nat.zero_le \u0393.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 {\u03b1 : Type}\n\nclass is_symb (\u03b1 : Type) extends prop.is_symb \u03b1 :=\n(fa : \u03b1) (ex : \u03b1)\n\ninductive symb : Type \n| fn : string \u2192 symb \n| prd : string \u2192 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 \u03b1] (p : exp \u03b1) := exp.app (exp.cst (is_symb.fa \u03b1)) (exp.lam p)\nnotation  `\u2200'` p := fa p\n\ndef ex [is_symb \u03b1] (p : exp \u03b1) := exp.app (exp.cst (is_symb.ex \u03b1)) (exp.lam p)\nnotation  `\u2203'` 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 \u03b1] : list (seq \u03b1) \u2192 seq \u03b1 \u2192 Prop\n| prop : \u2200 S s, prop.inf S s \u2192 inf S s\n| fal : \u2200 t \u0393 \u0394 p, inf [(inst t p)::\u0393 ==> \u0394] ((\u2200' p)::\u0393 ==> \u0394)\n| far : \u2200 k \u0393 \u0394 p, k \u2209 fvrs_list \u0393 \u2192 k \u2209 fvrs_list \u0394   \n  \u2192 inf [\u0393 ==> (inst (exp.fvr \u03b1 k) p)::\u0394] (\u0393 ==> (\u2200' p)::\u0394)\n| exl : \u2200 k \u0393 \u0394 p, k \u2209 fvrs_list \u0393 \u2192 k \u2209 fvrs_list \u0394   \n  \u2192 inf [(inst (exp.fvr \u03b1 k) p)::\u0393 ==> \u0394] ((\u2203' p)::\u0393 ==> \u0394) \n| exr : \u2200 t \u0393 \u0394 p, inf [\u0393 ==> (inst t p)::\u0394] (\u0393 ==> (\u2203' p)::\u0394)\n\ninductive thm [is_symb \u03b1] : (seq \u03b1) \u2192 Prop  \n| inf : \u2200 {s S}, inf S s \u2192 (\u2200 s' \u2208 S, thm s') \u2192 thm s \n\n\n\n/- Derived rules -/\n\nopen list\n\nlemma thm.id [is_symb \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p, thm (p::\u0393 ==> p::\u0394) :=\nbegin\n  intros \u0393 \u0394 p, apply thm.inf, apply inf.prop,\n  apply prop.inf.id, apply forall_mem_nil \nend\n \nlemma thm.truer [is_symb \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)), thm (\u0393 ==> \u22a4'::\u0394) :=\nbegin\n  intros \u0393 \u0394, apply thm.inf, apply inf.prop,\n  apply prop.inf.truer, apply forall_mem_nil\nend\n\nlemma thm.falsel [is_symb \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)), thm (\u22a5'::\u0393 ==> \u0394) :=\nbegin\n  intros \u0393 \u0394, apply thm.inf, apply inf.prop,\n  apply prop.inf.falsel, apply forall_mem_nil\nend\n\nlemma thm.andl [is_symb \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p q,\n  thm ((p \u2227' q)::\u0393 ==> \u0394) \u2192 thm (p::q::\u0393 ==> \u0394) :=\nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p q, \n  thm (\u0393 ==> p::\u0394) \u2192 thm (\u0393 ==> q::\u0394) \n  \u2192 thm (\u0393 ==> (p \u2227' q)::\u0394) :=\nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p q,\n  thm (p::\u0393 ==> \u0394) \u2192 thm (q::\u0393 ==> \u0394)\n  \u2192 thm ((p \u2228' q)::\u0393 ==> \u0394) :=\nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p q, \n  thm (\u0393 ==> p::q::\u0394) \u2192 thm (\u0393 ==> (p \u2228' q)::\u0394) := \nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p q, \n  thm (\u0393 ==> p::\u0394) \u2192 thm (q::\u0393 ==> \u0394) \n  \u2192 thm ((p \u2192' q)::\u0393 ==> \u0394) :=\nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p q, \n  thm (p::\u0393 ==> q::\u0394) \u2192 thm (\u0393 ==> (p \u2192' q)::\u0394) :=\nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p, \n  thm (\u0393 ==> \u0394) \u2192 thm (p::\u0393 ==> \u0394) :=  \nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p, \n  thm (\u0393 ==> \u0394) \u2192 thm (\u0393 ==> p::\u0394) :=\nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p, \n  thm (p::p::\u0393 ==> \u0394) \u2192 thm (p::\u0393 ==> \u0394) := \nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 (\u0393 \u0394 : list (exp \u03b1)) p, \n  thm (\u0393 ==> p::p::\u0394) \u2192 thm (\u0393 ==> p::\u0394) := \nbegin\n  intros \u0393 \u0394 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 \u03b1] : \n  \u2200 n (\u0393 \u0394 : list (exp \u03b1)), thm (rotate n \u0393 ==> \u0394) \u2192 thm (\u0393 ==> \u0394) :=\nbegin\n  intros n \u0393 \u0394 h, apply thm.inf, apply inf.prop,\n  apply prop.inf.pl (rotate n \u0393), \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 \u03b1] : \n  \u2200 n (\u0393 \u0394 : list (exp \u03b1)), thm (\u0393 ==> rotate n \u0394) \u2192 thm (\u0393 ==> \u0394) :=\nbegin\n  intros n \u0393 \u0394 h, apply thm.inf, apply inf.prop,\n  apply prop.inf.pr _ (rotate n \u0394), \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 \u03b1] : \n  \u2200 t (\u0393 \u0394 : list (exp \u03b1)) p, \n  thm ((inst t p)::\u0393 ==> \u0394) \u2192 thm ((\u2200' p)::\u0393 ==> \u0394) :=\nbegin\n  intros t \u0393 \u0394 p h, apply thm.inf, apply inf.fal t, \n  rewrite list.forall_mem_singleton, apply h\nend\n\nlemma thm.far [is_symb \u03b1] : \n  \u2200 k (\u0393 \u0394 : list (exp \u03b1)) p, \n  k \u2209 fvrs_list \u0393 \u2192 k \u2209 fvrs_list \u0394   \n  \u2192 thm (\u0393 ==> (inst (exp.fvr \u03b1 k) p)::\u0394) \u2192 thm (\u0393 ==> (\u2200' p)::\u0394) :=\nbegin\n  intros k \u0393 \u0394 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 \u03b1] : \n  \u2200 k (\u0393 \u0394 : list (exp \u03b1)) p, \n  k \u2209 fvrs_list \u0393 \u2192 k \u2209 fvrs_list \u0394   \n  \u2192 thm ((inst (exp.fvr \u03b1 k) p)::\u0393 ==> \u0394) \u2192 thm ((\u2203' p)::\u0393 ==> \u0394) :=\nbegin\n  intros k \u0393 \u0394 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 \u03b1] : \n  \u2200 t (\u0393 \u0394 : list (exp \u03b1)) p, \n  thm (\u0393 ==> (inst t p)::\u0394) \u2192 thm (\u0393 ==> (\u2203' p)::\u0394) :=\nbegin\n  intros t \u0393 \u0394 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) \u00d7 list (exp symb)) :=\ndo `(thm (%%\u0393e ==> %%\u0394e)) \u2190 tactic.target,\n    \u0393 \u2190 eval_expr (list (exp symb)) \u0393e, \n    \u0394 \u2190 eval_expr (list (exp symb)) \u0394e, \n    return (\u0393,\u0394)\n\ndef fml2str : exp symb \u2192 string \n| (exp.app (exp.app e p) q) := \n  if e = exp.cst (prop.is_symb.and symb)\n  then \"(\" ++ fml2str p ++ \" \u2227 \" ++ fml2str q ++ \")\" else \n  if e = exp.cst (prop.is_symb.or symb)\n  then \"(\" ++ fml2str p ++ \" \u2228 \" ++ fml2str q ++ \")\" else \n  if e = exp.cst (prop.is_symb.imp symb)\n  then \"(\" ++ fml2str p ++ \" \u2192 \" ++ 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 \"\u22a4\" else\n  if s = prop.is_symb.false symb\n  then \"\u22a5\" else\n  match s with \n  | (symb.fa) := \"\u2200\"\n  | (symb.ex) := \"\u2203\"\n  | (symb.not) := \"\u00ac\"\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 (\u0393,\u0394) \u2190 getsqt, trace (sqt2str fml2str \u0393 \u0394)) <|> trace \"No Goals\"\n\n\n/- Examples -/\n\nexample : thm ([] ==> [\u2200' (pred \"P\" [# 0]) \u2192' \u2203' (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 ([\u2203' (pred \"P\" [# 0] \u2228' pred \"Q\" [# 0])] ==> [\u2203' (pred \"P\" [# 0]) \u2228' \u2203' (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 ([\u2200' (pred \"P\" [# 0]), \u2200' ((pred \"P\" [# 0]) \u2192' (pred \"Q\" [# 0]))] ==> [\u2200' (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 ([\u2200' (pred \"P\" [# 0]), (pred \"P\" [& 0]) \u2192' ((pred \"P\" [& 1]) \u2192' (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 : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R) : witt_vector p R :=\n  mk p fun (n : \u2115) => ite (n = 0) 0 (coeff x (n - 1))\n\ntheorem verschiebung_fun_coeff {p : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : \u2115) : coeff (verschiebung_fun x) n = ite (n = 0) 0 (coeff x (n - 1)) := sorry\n\ntheorem verschiebung_fun_coeff_zero {p : \u2115} {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 : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : \u2115) : coeff (verschiebung_fun x) (Nat.succ n) = coeff x n :=\n  rfl\n\ntheorem ghost_component_zero_verschiebung_fun {p : \u2115} {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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : \u2115) : coe_fn (ghost_component (n + 1)) (verschiebung_fun x) = \u2191p * 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 : \u2115) : mv_polynomial \u2115 \u2124 :=\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 : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : \u2115) : 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 : \u2115) : 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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] : witt_vector p R \u2192+ 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 : \u2115} [hp : fact (nat.prime p)] : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => \u21d1verschiebung :=\n  verschiebung_fun_is_poly p\n\n/-- verschiebung is a natural transformation -/\n@[simp] theorem map_verschiebung {p : \u2115} {R : Type u_1} {S : Type u_2} [hp : fact (nat.prime p)] [comm_ring R] [comm_ring S] (f : R \u2192+* 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 : \u2115} {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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : \u2115) : coe_fn (ghost_component (n + 1)) (coe_fn verschiebung x) = \u2191p * coe_fn (ghost_component n) x :=\n  ghost_component_verschiebung_fun x n\n\n@[simp] theorem verschiebung_coeff_zero {p : \u2115} {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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : \u2115) : coeff (coe_fn verschiebung x) (n + 1) = coeff x n :=\n  rfl\n\n@[simp] theorem verschiebung_coeff_succ {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : \u2115) : coeff (coe_fn verschiebung x) (Nat.succ n) = coeff x n :=\n  rfl\n\ntheorem aeval_verschiebung_poly {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : \u2115) : 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\u2081_verschiebung_poly_witt_polynomial {p : \u2115} [hp : fact (nat.prime p)] (n : \u2115) : coe_fn (mv_polynomial.bind\u2081 verschiebung_poly) (witt_polynomial p \u2124 n) =\n  ite (n = 0) 0 (\u2191p * witt_polynomial p \u2124 (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\u2081 u\u2082 u\u2083\n\nvariable {J : Type w} [Category.{w'} J]\n\nvariable {A : Type u\u2081} [Category.{v} A]\n\nvariable {B : Type u\u2082} [Category.{v} B]\n\nvariable {T : Type u\u2083} [Category.{v} T]\n\nnamespace Comma\n\nvariable {L : A \u2964 T} {R : B \u2964 T}\n\nvariable (F : J \u2964 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\u2081 : Cone (F \u22d9 fst L R)) : Cone ((F \u22d9 snd L R) \u22d9 R) :=\n  (Cones.postcompose (whiskerLeft F (Comma.natTrans L R) : _)).obj (L.mapCone c\u2081)\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 \u22d9 fst L R : J \u2964 L` and a\nlimit cone for `F \u22d9 snd L R : J \u2964 R` we can build a cone for `F` which will turn out to be a limit\ncone.\n-/\n@[simps]\ndef coneOfPreserves [PreservesLimit (F \u22d9 snd L R) R] (c\u2081 : Cone (F \u22d9 fst L R))\n    {c\u2082 : Cone (F \u22d9 snd L R)} (t\u2082 : IsLimit c\u2082) : Cone F\n    where\n  pt :=\n    { left := c\u2081.pt\n      right := c\u2082.pt\n      Hom := (isLimitOfPreserves R t\u2082).lift (limitAuxiliaryCone _ c\u2081) }\n  \u03c0 :=\n    { app := fun j =>\n        { left := c\u2081.\u03c0.app j\n          right := c\u2082.\u03c0.app j\n          w' := ((isLimitOfPreserves R t\u2082).fac (limitAuxiliaryCone F c\u2081) j).symm }\n      naturality' := fun j\u2081 j\u2082 t => by ext <;> dsimp <;> simp [\u2190 c\u2081.w t, \u2190 c\u2082.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 \u22d9 snd L R) R] {c\u2081 : Cone (F \u22d9 fst L R)}\n    (t\u2081 : IsLimit c\u2081) {c\u2082 : Cone (F \u22d9 snd L R)} (t\u2082 : IsLimit c\u2082) :\n    IsLimit (coneOfPreserves F c\u2081 t\u2082)\n    where\n  lift s :=\n    { left := t\u2081.lift ((fst L R).mapCone s)\n      right := t\u2082.lift ((snd L R).mapCone s)\n      w' :=\n        (isLimitOfPreserves R t\u2082).hom_ext fun j =>\n          by\n          rw [cone_of_preserves_X_hom, assoc, assoc, (is_limit_of_preserves R t\u2082).fac,\n            limit_auxiliary_cone_\u03c0_app, \u2190 L.map_comp_assoc, t\u2081.fac, R.map_cone_\u03c0_app, \u2190 R.map_comp,\n            t\u2082.fac]\n          exact (s.\u03c0.app j).w }\n  uniq s m w :=\n    CommaMorphism.ext _ _ (t\u2081.uniq ((fst L R).mapCone s) _ fun j => by simp [\u2190 w])\n      (t\u2082.uniq ((snd L R).mapCone s) _ fun j => by simp [\u2190 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\u2082 : Cocone (F \u22d9 snd L R)) : Cocone ((F \u22d9 fst L R) \u22d9 L) :=\n  (Cocones.precompose (whiskerLeft F (Comma.natTrans L R) : _)).obj (R.mapCocone c\u2082)\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 \u22d9 fst L R : J \u2964 L` and\na cocone for `F \u22d9 snd L R : J \u2964 R` we can build a cocone for `F` which will turn out to be a\ncolimit cocone.\n-/\n@[simps]\ndef coconeOfPreserves [PreservesColimit (F \u22d9 fst L R) L] {c\u2081 : Cocone (F \u22d9 fst L R)}\n    (t\u2081 : IsColimit c\u2081) (c\u2082 : Cocone (F \u22d9 snd L R)) : Cocone F\n    where\n  pt :=\n    { left := c\u2081.pt\n      right := c\u2082.pt\n      Hom := (isColimitOfPreserves L t\u2081).desc (colimitAuxiliaryCocone _ c\u2082) }\n  \u03b9 :=\n    { app := fun j =>\n        { left := c\u2081.\u03b9.app j\n          right := c\u2082.\u03b9.app j\n          w' := (isColimitOfPreserves L t\u2081).fac (colimitAuxiliaryCocone _ c\u2082) j }\n      naturality' := fun j\u2081 j\u2082 t => by ext <;> dsimp <;> simp [\u2190 c\u2081.w t, \u2190 c\u2082.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 \u22d9 fst L R) L] {c\u2081 : Cocone (F \u22d9 fst L R)}\n    (t\u2081 : IsColimit c\u2081) {c\u2082 : Cocone (F \u22d9 snd L R)} (t\u2082 : IsColimit c\u2082) :\n    IsColimit (coconeOfPreserves F t\u2081 c\u2082)\n    where\n  desc s :=\n    { left := t\u2081.desc ((fst L R).mapCocone s)\n      right := t\u2082.desc ((snd L R).mapCocone s)\n      w' :=\n        (isColimitOfPreserves L t\u2081).hom_ext fun j =>\n          by\n          rw [cocone_of_preserves_X_hom, (is_colimit_of_preserves L t\u2081).fac_assoc,\n            colimit_auxiliary_cocone_\u03b9_app, assoc, \u2190 R.map_comp, t\u2082.fac, L.map_cocone_\u03b9_app, \u2190\n            L.map_comp_assoc, t\u2081.fac]\n          exact (s.\u03b9.app j).w }\n  uniq s m w :=\n    CommaMorphism.ext _ _ (t\u2081.uniq ((fst L R).mapCocone s) _ (by simp [\u2190 w]))\n      (t\u2082.uniq ((snd L R).mapCocone s) _ (by simp [\u2190 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 \u2964 Comma L R) [HasLimit (F \u22d9 fst L R)] [HasLimit (F \u22d9 snd L R)]\n    [PreservesLimit (F \u22d9 snd L R) R] : HasLimit F :=\n  HasLimit.mk \u27e8_, coneOfPreservesIsLimit _ (limit.isLimit _) (limit.isLimit _)\u27e9\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  \u27e8inferInstance\u27e9\n#align category_theory.comma.has_limits CategoryTheory.Comma.hasLimits\n-/\n\n#print CategoryTheory.Comma.hasColimit /-\ninstance hasColimit (F : J \u2964 Comma L R) [HasColimit (F \u22d9 fst L R)] [HasColimit (F \u22d9 snd L R)]\n    [PreservesColimit (F \u22d9 fst L R) L] : HasColimit F :=\n  HasColimit.mk \u27e8_, coconeOfPreservesIsColimit _ (colimit.isColimit _) (colimit.isColimit _)\u27e9\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  \u27e8inferInstance\u27e9\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 \u2964 Arrow T) [i\u2081 : HasLimit (F \u22d9 leftFunc)] [i\u2082 : HasLimit (F \u22d9 rightFunc)] :\n    HasLimit F :=\n  @Comma.hasLimit _ _ _ _ _ i\u2081 i\u2082 _\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  \u27e8inferInstance\u27e9\n#align category_theory.arrow.has_limits CategoryTheory.Arrow.hasLimits\n-/\n\n#print CategoryTheory.Arrow.hasColimit /-\ninstance hasColimit (F : J \u2964 Arrow T) [i\u2081 : HasColimit (F \u22d9 leftFunc)]\n    [i\u2082 : HasColimit (F \u22d9 rightFunc)] : HasColimit F :=\n  @Comma.hasColimit _ _ _ _ _ i\u2081 i\u2082 _\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  \u27e8inferInstance\u27e9\n#align category_theory.arrow.has_colimits CategoryTheory.Arrow.hasColimits\n-/\n\nend Arrow\n\nnamespace StructuredArrow\n\nvariable {X : T} {G : A \u2964 T} (F : J \u2964 StructuredArrow X G)\n\n#print CategoryTheory.StructuredArrow.hasLimit /-\ninstance hasLimit [i\u2081 : HasLimit (F \u22d9 proj X G)] [i\u2082 : PreservesLimit (F \u22d9 proj X G) G] :\n    HasLimit F :=\n  @Comma.hasLimit _ _ _ _ _ _ i\u2081 i\u2082\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  \u27e8inferInstance\u27e9\n#align category_theory.structured_arrow.has_limits CategoryTheory.StructuredArrow.hasLimits\n-/\n\n#print CategoryTheory.StructuredArrow.createsLimit /-\nnoncomputable instance createsLimit [i : PreservesLimit (F \u22d9 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  \u27e8\u27e9\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 \u27f6 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 \u27f6 Z) : Mono f \u2194 Mono f.right :=\n  \u27e8fun h => inferInstance, fun h => mono_of_mono_right f\u27e9\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 \u2964 T} {X : T} (F : J \u2964 CostructuredArrow G X)\n\n#print CategoryTheory.CostructuredArrow.hasColimit /-\ninstance hasColimit [i\u2081 : HasColimit (F \u22d9 proj G X)] [i\u2082 : PreservesColimit (F \u22d9 proj G X) G] :\n    HasColimit F :=\n  @Comma.hasColimit _ _ _ _ _ i\u2081 _ i\u2082\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  \u27e8inferInstance\u27e9\n#align category_theory.costructured_arrow.has_colimits CategoryTheory.CostructuredArrow.hasColimits\n-/\n\n#print CategoryTheory.CostructuredArrow.createsColimit /-\nnoncomputable instance createsColimit [i : PreservesColimit (F \u22d9 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  \u27e8\u27e9\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 \u27f6 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 \u27f6 Z) : Epi f \u2194 Epi f.left :=\n  \u27e8fun h => inferInstance, fun h => epi_of_epi_left f\u27e9\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 \u2964 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 := \u27e8{to_Top := { \u03b1 := pempty }}\u27e9\n\ninstance : has_coe_to_sort CompHaus Type* := \u27e8\u03bb X, X.to_Top\u27e9\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 := \u2039_\u203a,\n  is_hausdorff := \u2039_\u203a }\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 \u27f6 Y) : is_closed_map f :=\n\u03bb 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 \u27f6 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 \u2190 E.image_eq_preimage,\n    exact is_closed_map f S hS },\n  refine \u27e8\u27e8\u27e8E.symm, hE\u27e9, _, _\u27e9\u27e9,\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 \u27f6 Y) (bij : function.bijective f) : X \u2245 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} \u2964 Top.{u} := induced_functor _\n\ninstance CompHaus.forget_reflects_isomorphisms : reflects_isomorphisms (forget CompHaus.{u}) :=\n\u27e8by introsI A B f hf; exact CompHaus.is_iso_of_bijective _ ((is_iso_iff_bijective f).mp hf)\u27e9\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 \u27f6 Y) \u2243 (X \u27f6 CompHaus_to_Top.obj Y) :=\n{ to_fun := \u03bb f,\n  { to_fun := f \u2218 stone_cech_unit,\n    continuous_to_fun := f.2.comp (@continuous_stone_cech_unit X _) },\n  inv_fun := \u03bb 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 \u27e8f : stone_cech X \u27f6 Y, hf : continuous f\u27e9,\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 _ \u27e8y, rfl\u27e9,\n    apply congr_fun (stone_cech_extend_extends (hf.comp _)) y,\n  end,\n  right_inv :=\n  begin\n    rintro \u27e8f : (X : Type*) \u27f6 Y, hf : continuous f\u27e9,\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} \u2964 CompHaus.{u} :=\nadjunction.left_adjoint_of_equiv stone_cech_equivalence.{u} (\u03bb _ _ _ _ _, rfl)\n\nlemma Top_to_CompHaus_obj (X : Top) : \u21a5(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 := \u27e8Top_to_CompHaus, adjunction.adjunction_of_equiv_left _ _\u27e9 }\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 \u2964 CompHaus`, defined in terms of\n`Top.limit_cone`. -/\ndef limit_cone {J : Type u} [small_category J] (F : J \u2964 CompHaus.{u}) :\n  limits.cone F :=\n{ X :=\n  { to_Top := (Top.limit_cone (F \u22d9 CompHaus_to_Top)).X,\n    is_compact := begin\n      show compact_space \u21a5{u : \u03a0 j, (F.obj j) | \u2200 {i j : J} (f : i \u27f6 j), (F.map f) (u i) = u j},\n      rw \u2190 is_compact_iff_compact_space,\n      apply is_closed.is_compact,\n      have : {u : \u03a0 j, F.obj j | \u2200 {i j : J} (f : i \u27f6 j), F.map f (u i) = u j} =\n        \u22c2 (i j : J) (f : i \u27f6 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 \u21a5{u : \u03a0 j, (F.obj j) | \u2200 {i j : J} (f : i \u27f6 j), (F.map f) (u i) = u j},\n      from infer_instance },\n  \u03c0 :=\n  { app := \u03bb j, (Top.limit_cone (F \u22d9 CompHaus_to_Top)).\u03c0.app j,\n    naturality' := by { intros _ _ _, ext \u27e8x, hx\u27e9,\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 \u2964 CompHaus.{u}) :\n  limits.is_limit (limit_cone F) :=\n{ lift := \u03bb S,\n    (Top.limit_cone_is_limit (F \u22d9 CompHaus_to_Top)).lift (CompHaus_to_Top.map_cone S),\n  uniq' := \u03bb 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 \u27f6 Y) : epi f \u2194 function.surjective f :=\nbegin\n  split,\n  { contrapose!,\n    rintros \u27e8y, hy\u27e9 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 \u27e8y', hy'\u27e9, exact hy y' hy' },\n    haveI : normal_space \u21a5(Y.to_Top) := normal_of_compact_t2,\n    obtain \u27e8\u03c6, h\u03c60, h\u03c61, h\u03c601\u27e9 := exists_continuous_zero_one_of_closed hC hD hCD,\n    haveI : compact_space (ulift.{u} $ set.Icc (0:\u211d) 1) := homeomorph.ulift.symm.compact_space,\n    haveI : t2_space (ulift.{u} $ set.Icc (0:\u211d) 1) := homeomorph.ulift.symm.t2_space,\n    let Z := of (ulift.{u} $ set.Icc (0:\u211d) 1),\n    let g : Y \u27f6 Z := \u27e8\u03bb y', \u27e8\u27e8\u03c6 y', h\u03c601 y'\u27e9\u27e9,\n      continuous_ulift_up.comp (continuous_subtype_mk (\u03bb y', h\u03c601 y') \u03c6.continuous)\u27e9,\n    let h : Y \u27f6 Z := \u27e8\u03bb _, \u27e8\u27e80, set.left_mem_Icc.mpr zero_le_one\u27e9\u27e9, continuous_const\u27e9,\n    have H : h = g,\n    { rw \u2190 cancel_epi f,\n      ext x, dsimp,\n      simp only [comp_apply, continuous_map.coe_mk, subtype.coe_mk, h\u03c60 (set.mem_range_self x),\n        pi.zero_apply], },\n    apply_fun (\u03bb e, (e y).down) at H,\n    dsimp at H,\n    simp only [subtype.mk_eq_mk, h\u03c61 (set.mem_singleton y), pi.one_apply] at H,\n    exact zero_ne_one H, },\n  { rw \u2190 category_theory.epi_iff_surjective,\n    apply faithful_reflects_epi (forget CompHaus) },\nend\n\nlemma mono_iff_injective {X Y : CompHaus.{u}} (f : X \u27f6 Y) : mono f \u2194 function.injective f :=\nbegin\n  split,\n  { introsI hf x\u2081 x\u2082 h,\n    let g\u2081 : of punit \u27f6 X := \u27e8\u03bb _, x\u2081, continuous_of_discrete_topology\u27e9,\n    let g\u2082 : of punit \u27f6 X := \u27e8\u03bb _, x\u2082, continuous_of_discrete_topology\u27e9,\n    have : g\u2081 \u226b f = g\u2082 \u226b f, by { ext, exact h },\n    rw cancel_mono at this,\n    apply_fun (\u03bb e, e punit.star) at this,\n    exact this },\n  { rw \u2190 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 (\u2115 \u00d7 \u2115) sorted in lex order), we create two semistandard\nYoung tableaux (ssyt) of the same shape (\u03bd : 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 : \u03a0 (w : list (lex (\u2115 \u00d7 \u2115))), w.sorted (\u2264) \u2192\n          \u03a3 (\u03bc : young_diagram), ssyt \u03bc \u00d7 ssyt \u03bc\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 \u2115 \u2115).le\n\nlemma rsk_mono_iff {x y : lex (\u2115 \u00d7 \u2115)} {w : list (lex (\u2115 \u00d7 \u2115))} : \n  (x :: y :: w).sorted (\u2264) \u2194 \n  (x.1 < y.1 \u2228 x.1 = y.1 \u2227 x.2 \u2264 y.2) \u2227 (y :: w).sorted (\u2264) :=\nbegin\n  repeat {rw list.sorted_cons at *},\n  split; intro h,\n  { exact \u27e8(prod.lex_def _ _).mp (h.1 y (or.inl rfl)), h.2\u27e9 },\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 (\u2115 \u00d7 \u2115))) (val : \u2115) : \u2115 := \nlist.count val $ w.map prod.fst\n\ndef wtB (w : list (lex (\u2115 \u00d7 \u2115))) (val : \u2115) : \u2115 := \nlist.count val $ w.map prod.snd\n\nlemma wtR_cons (x : lex (\u2115 \u00d7 \u2115)) (w : list (lex (\u2115 \u00d7 \u2115))) (val : \u2115) :\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 (\u2115 \u00d7 \u2115)) (w : list (lex (\u2115 \u00d7 \u2115))) (val : \u2115) :\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  {\u03bc : young_diagram} {R B : ssyt \u03bc} (rcert : ssyt.rec_cert R B) :\n  \u03a3 (\u03bd : young_diagram), ssyt \u03bd \u00d7 ssyt \u03bd :=\n\u27e8_, \u27e8rcert.rec_step, (B.row_bump rcert.bumpval).2\u27e9\u27e9\n\ndef ssyt.rec_cert.rsk_inductive :\n  \u03a0 {\u03bc : young_diagram} {R B : ssyt \u03bc} (rcert : ssyt.rec_cert R B)\n  (w : list (lex (\u2115 \u00d7 \u2115)))\n  (hw : ((rcert.recval, rcert.bumpval) :: w).sorted rsk_le),\n\u03a3 {\u03bd : young_diagram}, ssyt \u03bd \u00d7 ssyt \u03bd\n| \u03bc R B rcert [] _ := \n  \u27e8_, \u27e8rcert.rsk_step.2.1, rcert.rsk_step.2.2\u27e9\u27e9\n| \u03bc 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  \u03a0 {\u03bc : young_diagram} {R B : ssyt \u03bc} (rcert : ssyt.rec_cert R B)\n  (w : list (lex (\u2115 \u00d7 \u2115)))\n  (hw : ((rcert.recval, rcert.bumpval) :: w).sorted rsk_le),\n  (rcert.rsk_inductive w hw).1.size =\n  \u03bc.size + 1 + w.length\n| \u03bc R B rcert [] _ := by apply B.row_bump_size\n| \u03bc 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  \u03a0 {\u03bc : young_diagram} {R B : ssyt \u03bc} (rcert : ssyt.rec_cert R B)\n  (w : list (lex (\u2115 \u00d7 \u2115)))\n  (hw : ((rcert.recval, rcert.bumpval) :: w).sorted rsk_le)\n  (val : \u2115),\n  (rcert.rsk_inductive w hw).2.1.wt val =\n  R.wt val + (ite (val = rcert.recval) 1 0) + wtR w val\n| \u03bc 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| \u03bc R B rcert ((recval', bumpval') :: xs) hw val := begin\n  rw [\u2190 rcert.rec_wt val, wtR_cons, \u2190 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  \u03a0 {\u03bc : young_diagram} {R B : ssyt \u03bc} (rcert : ssyt.rec_cert R B)\n  (w : list (lex (\u2115 \u00d7 \u2115)))\n  (hw : ((rcert.recval, rcert.bumpval) :: w).sorted rsk_le)\n  (val : \u2115),\n  (rcert.rsk_inductive w hw).2.2.wt val =\n  B.wt val + (ite (val = rcert.bumpval) 1 0) + wtB w val\n| \u03bc 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| \u03bc R B rcert ((recval', bumpval') :: xs) hw val := begin\n  rw [\u2190 B.row_bump_wt _ val, wtB_cons, \u2190 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 : \u2115) : ssyt.rec_cert T_empty T_empty :=\n{ recval := recval, bumpval := bumpval,\n  rec_le := \u03bb _ _, nat.zero_le _,\n  rec_eq_left := \u03bb _ _ cell _, false.rec _ cell }\n\ndef rsk :\n  \u03a0 (w : list (lex (\u2115 \u00d7 \u2115))), w.sorted (\u2264) \u2192\n  \u03a3 (\u03bc : young_diagram), ssyt \u03bc \u00d7 ssyt \u03bc\n| [] _ := \u27e8\u2205, \u2205, \u2205\u27e9\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  \u03a0 (w : list (lex (\u2115 \u00d7 \u2115))) (hw : w.sorted (\u2264)),\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      \u03bc_empty_size, zero_add, add_comm], refl,\n}\n\nlemma rsk_wtR :\n  \u03a0 (w : list (lex (\u2115 \u00d7 \u2115))) (hw : w.sorted (\u2264)) (val : \u2115),\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  \u03a0 (w : list (lex (\u2115 \u00d7 \u2115))) (hw : w.sorted (\u2264)) (val : \u2115),\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 (\u2115 \u00d7 \u2115)) :=\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_\u03bc : young_diagram := (rsk rsk.ex0 rsk.ex0_sorted).1\ndef rsk.ex0_R : ssyt rsk.ex0_\u03bc := (rsk rsk.ex0 rsk.ex0_sorted).2.1\ndef rsk.ex0_B : ssyt rsk.ex0_\u03bc := (rsk rsk.ex0 rsk.ex0_sorted).2.2\n\n#eval rsk.ex0_\u03bc\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 \u2964 C) (hF : is_zero F) (c : cone F) (hc : is_zero c.X) : is_limit c :=\n{ lift := \u03bb s, 0,\n  fac' := \u03bb s j, (F.is_zero_iff.1 hF j).eq_of_tgt _ _,\n  uniq' := \u03bb 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 \u2964 D) (hG : is_zero G) :\n  preserves_limits_of_shape J G :=\n\u27e8\u03bb F, \u27e8\u03bb 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 \u03bb X, hG _, },\n  { exact hG c.X, },\nend\u27e9\u27e9\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 \u2964 C) (hF : is_zero F) (c : cocone F) (hc : is_zero c.X) : is_colimit c :=\n{ desc := \u03bb s, 0,\n  fac' := \u03bb s j, (F.is_zero_iff.1 hF j).eq_of_src _ _,\n  uniq' := \u03bb 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 \u2964 D) (hG : is_zero G):\n  preserves_colimits_of_shape J G :=\n\u27e8\u03bb F, \u27e8\u03bb 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 \u03bb X, hG _, },\n  { exact hG c.X, },\nend\u27e9\u27e9\n\nend category_theory.limits\n\nopen category_theory category_theory.limits\n  category_theory.category\n\nnamespace homological_complex\n\nvariables (C : Type*) {\u03b9 J : Type*} [category C] [category J] [has_zero_morphisms C]\n  (c : complex_shape \u03b9) (F : J \u2964 homological_complex C c)\n\ndef single_nat_iso_self [has_zero_object C] [decidable_eq \u03b9] (i : \u03b9) :\n  single C c i \u22d9 eval C c i \u2245 \ud835\udfed C :=\nnat_iso.of_components (\u03bb 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 \u03b9] (i j : \u03b9) (h : i \u2260 j) :\n  is_zero (single C c i \u22d9 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 [\u2200 (n : \u03b9), has_limit (F \u22d9 homological_complex.eval C c n)]\n\n@[protected, simps]\ndef cone_of_limit_eval : cone F :=\n{ X :=\n  { X := \u03bb n, limit (F \u22d9 homological_complex.eval C c n),\n    d := \u03bb n m, lim_map { app := \u03bb j, (F.obj j).d n m, },\n    shape' := \u03bb n m h, begin\n      ext j,\n      simp only [lim_map_\u03c0, zero_comp, (F.obj j).shape _ _ h, comp_zero],\n    end, },\n  \u03c0 :=\n  { app := \u03bb j,\n    { f := \u03bb n, limit.\u03c0 _ j, },\n    naturality' := \u03bb i j \u03c6, 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 := \u03bb s,\n  { f := \u03bb n, limit.lift _ ((eval C c n).map_cone s), },\n  uniq' := \u03bb s m hm, begin\n    ext n j,\n    simp only [limit.lift_\u03c0, functor.map_cone_\u03c0_app, eval_map,\n      \u2190 hm, comp_f, cone_of_limit_eval_\u03c0_app_f],\n  end, }\n\ninstance : has_limit F := \u27e8\u27e8\u27e8 _, is_limit_cone F\u27e9\u27e9\u27e9\n\ninstance (n : \u03b9) : 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 [\u2200 (n : \u03b9), has_colimit (F \u22d9 homological_complex.eval C c n)]\n\n@[simps]\ndef cocone_of_colimit_eval : cocone F :=\n{ X :=\n  { X := \u03bb n, colimit (F \u22d9 homological_complex.eval C c n),\n    d:= \u03bb n m, colim_map { app := \u03bb j, (F.obj j).d n m, },\n    shape' := \u03bb n m h, begin\n      ext j,\n      simp only [\u03b9_colim_map, comp_zero, (F.obj j).shape _ _ h, zero_comp],\n    end, },\n  \u03b9 :=\n  { app := \u03bb j,\n    { f := \u03bb n, colimit.\u03b9 (F \u22d9 eval C c n) j, },\n    naturality' := \u03bb i j \u03c6, begin\n      ext n,\n      dsimp,\n      rw [comp_id],\n      exact colimit.w (F \u22d9 eval C c n) \u03c6,\n    end, }, }\n\nlemma is_colimit_cocone : is_colimit (cocone_of_colimit_eval F) :=\n{ desc := \u03bb s,\n  { f := \u03bb n, colimit.desc _ ((eval C c n).map_cocone s), },\n  uniq' := \u03bb s m hm, begin\n    ext n j,\n    simp only [\u2190hm, functor.map_cocone_\u03b9_app, eval_map, colimit.\u03b9_desc, comp_f,\n      cocone_of_colimit_eval_\u03b9_app_f],\n  end, }\n\ninstance : has_colimit F := \u27e8\u27e8\u27e8 _, is_colimit_cocone F\u27e9\u27e9\u27e9\n\ninstance (n : \u03b9) : 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\u27e8\u03bb F, infer_instance\u27e9\n\ninstance [has_colimits_of_shape J C] :\n  has_colimits_of_shape J (homological_complex C c) :=\n\u27e8\u03bb F, infer_instance\u27e9\n\ninstance [has_limits_of_shape J C] (n : \u03b9) :\n  preserves_limits_of_shape J (homological_complex.eval C c n) :=\n\u27e8\u03bb F, infer_instance\u27e9\n\ninstance [has_colimits_of_shape J C] (n : \u03b9) :\n  preserves_colimits_of_shape J (homological_complex.eval C c n) :=\n\u27e8\u03bb F, infer_instance\u27e9\n\ninstance [has_finite_limits C] :\n  has_finite_limits (homological_complex C c) :=\n\u27e8\u03bb J, begin\n  introI,\n  introI,\n  apply_instance,\nend\u27e9\n\ninstance [has_finite_colimits C] :\n  has_finite_colimits (homological_complex C c) :=\n\u27e8\u03bb J, begin\n  introI,\n  introI,\n  apply_instance,\nend\u27e9\n\ninstance [has_finite_limits C] (n : \u03b9) :\n  preserves_finite_limits (homological_complex.eval C c n) :=\n\u27e8\u03bb J, begin\n  introI,\n  introI,\n  apply_instance,\nend\u27e9\n\ninstance [has_finite_colimits C] (n : \u03b9) :\n  preserves_finite_colimits (homological_complex.eval C c n) :=\n\u27e8\u03bb J, begin\n  introI,\n  introI,\n  apply_instance,\nend\u27e9\n\ninstance [has_finite_products C] :\n  has_finite_products (homological_complex C c) :=\n\u27e8\u03bb n, infer_instance\u27e9\n\ninstance [has_finite_coproducts C] :\n  has_finite_coproducts (homological_complex C c) :=\n\u27e8\u03bb n, infer_instance\u27e9\n\nvariable {F}\n\ndef is_limit_of_eval (s : limits.cone F) [has_limits_of_shape J C]\n  (hs : \u2200 (i : \u03b9), is_limit ((eval C c i).map_cone s)) : is_limit s :=\n{ lift := \u03bb t,\n  { f := \u03bb i, (hs i).lift ((eval C c i).map_cone t),\n    comm' := \u03bb i i' hii', is_limit.hom_ext (hs i') (begin\n      intro j,\n      have eq := \u03bb i, (hs i).fac ((eval C c i).map_cone t),\n      simp only [functor.map_cone_\u03c0_app, eval_map] at eq,\n      simp only [functor.map_cone_\u03c0_app, eval_map, assoc],\n      rw [eq i', \u2190 hom.comm, reassoc_of (eq i), hom.comm],\n    end), },\n  fac' := \u03bb t j, begin\n    ext i,\n    simp only [comp_f],\n    apply (hs i).fac,\n  end,\n  uniq' := \u03bb t m hm, begin\n    ext i,\n    exact (hs i).uniq ((eval C c i).map_cone t) (m.f i)\n      (\u03bb 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 \u2964 homological_complex C c) [has_limits_of_shape J C]\n  (hG : \u03a0 (i : \u03b9), preserves_limits_of_shape J (G \u22d9 eval C c i)) :\n  preserves_limits_of_shape J G :=\n\u27e8\u03bb F, \u27e8\u03bb s hs, is_limit_of_eval _ (\u03bb i, begin\n  let hs' := is_limit_of_preserves (G \u22d9 eval C c i) hs,\n  exact hs',\nend)\u27e9\u27e9\n\ndef is_colimit_of_eval (s : limits.cocone F) [has_colimits_of_shape J C]\n  (hs : \u2200 (i : \u03b9), is_colimit ((eval C c i).map_cocone s)) : is_colimit s :=\n{ desc := \u03bb t,\n  { f := \u03bb i, (hs i).desc ((eval C c i).map_cocone t),\n    comm' := \u03bb i i' hii', is_colimit.hom_ext (hs i) begin\n      intro j,\n      have eq := \u03bb i, (hs i).fac ((eval C c i).map_cocone t),\n      simp only [functor.map_cocone_\u03b9_app, eval_map] at eq,\n      simp only [functor.map_cocone_\u03b9_app, eval_map, hom.comm_assoc],\n      rw [eq i', reassoc_of (eq i), hom.comm],\n    end, },\n  fac' := \u03bb t j, begin\n    ext i,\n    simp only [comp_f],\n    apply (hs i).fac,\n  end,\n  uniq' := \u03bb t m hm, begin\n    ext i,\n    exact (hs i).uniq ((eval C c i).map_cocone t) (m.f i)\n      (\u03bb 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 \u2964 homological_complex C c) [has_colimits_of_shape J C]\n  (hG : \u03a0 (i : \u03b9), preserves_colimits_of_shape J (G \u22d9 eval C c i)) :\n  preserves_colimits_of_shape J G :=\n\u27e8\u03bb F, \u27e8\u03bb s hs, is_colimit_of_eval _ (\u03bb i, begin\n  let hs' := is_colimit_of_preserves (G \u22d9 eval C c i) hs,\n  exact hs',\nend)\u27e9\u27e9\n\n\nvariables [has_zero_object C] [decidable_eq \u03b9]\n\ninstance [has_zero_object C] [has_limits_of_shape J C] (i : \u03b9) :\n  preserves_limits_of_shape J (single C c i) :=\npreserves_limits_of_shape_of_eval _ (\u03bb 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 : \u03b9) :\n  preserves_colimits_of_shape J (single C c i) :=\npreserves_colimits_of_shape_of_eval _ (\u03bb 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 : \u03b9) : preserves_finite_limits (single C c i) :=\n\u27e8\u03bb J, by { introI, introI, apply_instance, }\u27e9\n\ninstance [has_finite_colimits C] (i : \u03b9) : preserves_finite_colimits (single C c i) :=\n\u27e8\u03bb J, by { introI, introI, apply_instance, }\u27e9\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": "variables {A: Type*} {B : Type*} {C : Type*} {D : Type*} {h : A \u2192 B} {g : B \u2192 C} {f : C \u2192 D}\n\ntheorem Q1007 : (f \u2218 g) \u2218 h = f \u2218 (g \u2218 h) := sorry", "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/PB1008/Q1008.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8152324803738429, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4984184425444454}}
{"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 \u03b1)` quasiquotes a tree `(t: tree expr)` of quoted\nvalues of type `\u03b1` at level `u` into an `expr` which reifies to a `tree \u03b1`\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 {\u03b1 : Type u_1} [HasZero \u03b1] (t : tree \u03b1) (n : pos_num) : \u03b1 :=\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 \u2192 csring_expr\n| const : num \u2192 csring_expr\n| add : csring_expr \u2192 csring_expr \u2192 csring_expr\n| mul : csring_expr \u2192 csring_expr \u2192 csring_expr\n| pow : csring_expr \u2192 num \u2192 csring_expr\n\na local variable in the context. n indexes into a storage\nof such atoms - a `tree \u03b1`. -/\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 `\u03b1`, retrieving opaque elements\n(atoms) from the tree `t`. -/\ndef eval {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) : csring_expr \u2192 \u03b1 :=\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 \u2192 horner_expr\n| horner : horner_expr \u2192 pos_num \u2192 num \u2192 horner_expr \u2192 horner_expr\n\nconstructor in `csring_expr`. This one, however, can be negative. -/\n\n/- (horner a x n b) is a*x\u207f + 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 \u2192 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 \u2192 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\u2081 : horner_expr) (A\u2081 : horner_expr \u2192 horner_expr) (x\u2081 : pos_num) : horner_expr \u2192 num \u2192 horner_expr \u2192 (horner_expr \u2192 horner_expr) \u2192 horner_expr :=\n  sorry\n\ndef add : horner_expr \u2192 horner_expr \u2192 horner_expr :=\n  sorry\n\n/-begin\n  induction e\u2081 with n\u2081 a\u2081 x\u2081 n\u2081 b\u2081 A\u2081 B\u2081 generalizing e\u2082,\n  { exact add_const n\u2081 e\u2082 },\n  exact match e\u2082 with e\u2082 := begin\n    induction e\u2082 with n\u2082 a\u2082 x\u2082 n\u2082 b\u2082 A\u2082 B\u2082 generalizing n\u2081 b\u2081;\n    let e\u2081 := horner a\u2081 x\u2081 n\u2081 b\u2081,\n    { exact add_const n\u2082 e\u2081 },\n    let e\u2082 := horner a\u2082 x\u2082 n\u2082 b\u2082,\n    exact match pos_num.cmp x\u2081 x\u2082 with\n    | ordering.lt := horner a\u2081 x\u2081 n\u2081 (B\u2081 e\u2082)\n    | ordering.gt := horner a\u2082 x\u2082 n\u2082 (B\u2082 n\u2081 b\u2081)\n    | ordering.eq :=\n      match num.sub' n\u2081 n\u2082 with\n      | znum.zero := horner' (A\u2081 a\u2082) x\u2081 n\u2081 (B\u2081 b\u2082)\n      | (znum.pos k) := horner (A\u2082 k 0) x\u2081 n\u2082 (B\u2081 b\u2082)\n      | (znum.neg k) := horner (A\u2081 (horner a\u2082 x\u2081 k 0)) x\u2081 n\u2081 (B\u2081 b\u2082)\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\u2081 : horner_expr) (x\u2081 : pos_num) (n\u2081 : num) (b\u2081 : horner_expr) (A\u2081 : horner_expr \u2192 horner_expr) (B\u2081 : horner_expr \u2192 horner_expr) : horner_expr \u2192 horner_expr :=\n  sorry\n\ndef mul : horner_expr \u2192 horner_expr \u2192 horner_expr :=\n  sorry\n\n/-begin\n  induction e\u2081 with n\u2081 a\u2081 x\u2081 n\u2081 b\u2081 A\u2081 B\u2081 generalizing e\u2082,\n  { exact mul_const n\u2081 e\u2082 },\n  induction e\u2082 with n\u2082 a\u2082 x\u2082 n\u2082 b\u2082 A\u2082 B\u2082;\n  let e\u2081 := horner a\u2081 x\u2081 n\u2081 b\u2081,\n  { exact mul_const n\u2082 e\u2081 },\n  let e\u2082 := horner a\u2082 x\u2082 n\u2082 b\u2082,\n  cases pos_num.cmp x\u2081 x\u2082,\n  { exact horner (A\u2081 e\u2082) x\u2081 n\u2081 (B\u2081 e\u2082) },\n  { let haa := horner' A\u2082 x\u2081 n\u2082 0,\n    exact if b\u2082 = 0 then haa else\n      haa.add (horner (A\u2081 b\u2082) x\u2081 n\u2081 (B\u2081 b\u2082)) },\n  { exact horner A\u2082 x\u2082 n\u2082 B\u2082 }\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 \u2192 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 \u2192 horner_expr :=\n  sorry\n\n/-- Evaluates a reflected `horner_expr` - see `csring_expr.eval`. -/\ndef cseval {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) : horner_expr \u2192 \u03b1 :=\n  sorry\n\ntheorem cseval_atom {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) (n : pos_num) : is_cs (atom n) \u2227 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) (k : num) {e : horner_expr} (cs : is_cs e) : is_cs (add_const (num.to_znum k) e) \u2227 cseval t (add_const (num.to_znum k) e) = \u2191k + cseval t e := sorry\n\ntheorem cseval_horner' {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) (a : horner_expr) (x : pos_num) (n : num) (b : horner_expr) (h\u2081 : is_cs a) (h\u2082 : is_cs b) : is_cs (horner' a x n b) \u2227 cseval t (horner' a x n b) = ring.horner (cseval t a) (tree.get_or_zero t x) (\u2191n) (cseval t b) := sorry\n\ntheorem cseval_add {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) {e\u2081 : horner_expr} {e\u2082 : horner_expr} (cs\u2081 : is_cs e\u2081) (cs\u2082 : is_cs e\u2082) : is_cs (add e\u2081 e\u2082) \u2227 cseval t (add e\u2081 e\u2082) = cseval t e\u2081 + cseval t e\u2082 := sorry\n\ntheorem cseval_mul_const {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) (k : num) {e : horner_expr} (cs : is_cs e) : is_cs (mul_const (num.to_znum k) e) \u2227 cseval t (mul_const (num.to_znum k) e) = cseval t e * \u2191k := sorry\n\ntheorem cseval_mul {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) {e\u2081 : horner_expr} {e\u2082 : horner_expr} (cs\u2081 : is_cs e\u2081) (cs\u2082 : is_cs e\u2082) : is_cs (mul e\u2081 e\u2082) \u2227 cseval t (mul e\u2081 e\u2082) = cseval t e\u2081 * cseval t e\u2082 := sorry\n\ntheorem cseval_pow {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) {x : horner_expr} (cs : is_cs x) (n : num) : is_cs (pow x n) \u2227 cseval t (pow x n) = cseval t x ^ \u2191n := 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) (r : csring_expr) : is_cs (of_csexpr r) \u2227 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\u2081` and `r\u2082` 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (t : tree \u03b1) (r\u2081 : csring_expr) (r\u2082 : csring_expr) (H : horner_expr.of_csexpr r\u2081 = horner_expr.of_csexpr r\u2082) : csring_expr.eval t r\u2081 = csring_expr.eval t r\u2082 := 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\u2081 - %%e\u2082) :=\n  let (r\u2081, l\u2081) := reflect_expr e\u2081, (r\u2082, l\u2082) := reflect_expr e\u2082 in\n  (r\u2081.add r\u2082.neg, l\u2081 ++ l\u2082)\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\u2081 / %%e\u2082) :=\n  let (r\u2081, l\u2081) := reflect_expr e\u2081, (r\u2082, l\u2082) := reflect_expr e\u2082 in\n  (r\u2081.mul r\u2082.inv, l\u2081 ++ l\u2082)-/\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}} [\u2200 k : \u2115, Encodable (L.func k)]\n  [\u2200 k, Encodable (L.rel k)] {\u03bc : Type v} [Encodable \u03bc]\n\nnamespace SubFormula\nopen Encodable\n\ndef toNat : {n : \u2115} \u2192 SubFormula L \u03bc n \u2192 \u2115\n  | _, \u22a4                 => 0\n  | _, \u22a5                 => 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 \u22cf q             => (Nat.bit true  $ Nat.bit false $ Nat.bit false $ Nat.mkpair p.toNat q.toNat) + 2\n  | _, p \u22ce q             => (Nat.bit true  $ Nat.bit false $ Nat.bit true  $ Nat.mkpair p.toNat q.toNat) + 2\n  | _, \u2200' p              => (Nat.bit true  $ Nat.bit true  $ Nat.bit false p.toNat) + 2\n  | _, \u2203' p              => (Nat.bit true  $ Nat.bit true  $ Nat.bit true  p.toNat) + 2\n\ndef ofNat : (n : \u2115) \u2192 \u2115 \u2192 Option (SubFormula L \u03bc n)\n  | n, 0     => some \u22a4\n  | n, 1     => some \u22a5\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\u2082 (L.rel k) x.unpair.2.unpair.1\n      let v' := decode\u2082 (Fin k \u2192 SubTerm L \u03bc 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 \u2264 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 \u22cf q\n        | true  => p'.bind fun p => q'.map fun q => p \u22ce q\n      | true  =>\n        let p' := ofNat (n + 1) x\n        match e.div2.div2.bodd with\n        | false => p'.bind fun p => \u2200' p\n        | true  => p'.bind fun p => \u2203' p\n  termination_by ofNat n e => e\n\nlemma ofNat_toNat : \u2200 {n} (p : SubFormula L \u03bc n), ofNat n p.toNat = some p\n  | _, \u22a4 => by simp[toNat, ofNat]\n  | _, \u22a5 => 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 \u22cf 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 \u22ce 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, \u2200' 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, \u2203' 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 \u03bc 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 : \u2115}\n  (F : typevec.{u} n \u2192 Type*) [mvfunctor F] [q : mvqpf F]\n  (G : fin' n \u2192 typevec.{u} m \u2192 Type u) [\u2200 i, mvfunctor $ G i] [q' : \u2200 i, mvqpf $ G i]\n\ndef comp (v : typevec.{u} m) : Type* :=\nF $ \u03bb i : fin' n, G i v\n\nnamespace comp\nopen mvfunctor mvpfunctor\nvariables {F G} {\u03b1 \u03b2 : typevec.{u} m} (f : \u03b1 \u27f9 \u03b2)\n\nprotected def mk (x : F $ \u03bb i, G i \u03b1) : (comp F G) \u03b1 := x\n\nprotected def get (x : (comp F G) \u03b1) : F $ \u03bb i, G i \u03b1 := x\n\n@[simp] protected lemma mk_get (x : (comp F G) \u03b1) : comp.mk (comp.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : F $ \u03bb i, G i \u03b1) : comp.get (comp.mk x) = x := rfl\n\nprotected def map' : (\u03bb (i : fin' n), G i \u03b1) \u27f9 \u03bb (i : fin' n), G i \u03b2 :=\n\u03bb i, map f\n\nprotected def map : (comp F G) \u03b1 \u2192 (comp F G) \u03b2 :=\n(map (\u03bb i, map f) : F (\u03bb i, G i \u03b1) \u2192 F (\u03bb i, G i \u03b2))\n\ninstance : mvfunctor (comp F G) :=\n{ map := \u03bb \u03b1 \u03b2, comp.map }\n\nlemma map_mk (x : F $ \u03bb i, G i \u03b1) :\n  f <$$> comp.mk x = comp.mk ((\u03bb i (x : G i \u03b1), f <$$> x) <$$> x) := rfl\n\nlemma get_map (x : comp F G \u03b1) :\n  comp.get (f <$$> x) = (\u03bb i (x : G i \u03b1), f <$$> x) <$$> comp.get x := rfl\n\ninclude q q'\n\ninstance : mvqpf (comp F G) :=\n{ P         := mvpfunctor.comp (P F) (\u03bb i, P $ G i),\n  abs       := \u03bb \u03b1, comp.mk \u2218 map (\u03bb i, abs) \u2218 abs \u2218 mvpfunctor.comp.get,\n  repr'     := \u03bb \u03b1,  mvpfunctor.comp.mk \u2218 repr \u2218\n                 map (\u03bb i, (repr : G i \u03b1 \u2192 (\u03bb (i : fin' n), apply (P (G i)) \u03b1) i)) \u2218 comp.get,\n  abs_repr' := by { intros, simp [(\u2218), mvfunctor.map_map, (\u229a), abs_repr] },\n  abs_map   := by { intros, simp [(\u2218)], rw [\u2190 abs_map],\n                    simp [id_map, (\u229a), 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\u00e9d\u00e9ric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Fr\u00e9d\u00e9ric 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 : \u03b9 \u2192 Type*` of semimodules over commutative\nsemirings. We denote this space by `\u2a02[R] i, s i` and define it as `free_add_monoid (R \u00d7 \u03a0 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 : \u03b9 \u2192 Type*` is the tensor product\n  of all the `s i`'s. This is denoted by `\u2a02[R] i, s i`.\n* `tprod R f` with `f : \u03a0 i, s i` is the tensor product of the vectors `f i` over all `i : \u03b9`.\n  This is bundled as a multilinear map from `\u03a0 i, s i` to `\u2a02[R] i, s i`.\n* `lift_add_hom` constructs an `add_monoid_hom` from `(\u2a02[R] i, s i)` to some space `F` from a\n  function `\u03c6 : (R \u00d7 \u03a0 i, s i) \u2192 F` with the appropriate properties.\n* `lift \u03c6` with `\u03c6 : multilinear_map R s E` is the corresponding linear map\n  `(\u2a02[R] i, s i) \u2192\u2097[R] E`. This is bundled as a linear equivalence.\n\n## Notations\n\n* `\u2a02[R] i, s i` is defined as localized notation in locale `tensor_product`\n* `\u2a02\u209c[R] i, f i` with `f : \u03a0 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 \u00d7 \u03a0 i, s i)` with the `R` representing a \"hidden\" tensor\n  factor, rather than `free_add_monoid (\u03a0 i, s i)` to ensure that, if `\u03b9` is an empty type,\n  the space is isomorphic to the base ring `R`.\n* We have not restricted the index type `\u03b9` to be a `fintype`, as nothing we do here strictly\n  requires it. However, problems may arise in the case where `\u03b9` 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 `\u03b9` 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 \u00d7 \u03a0 i, s i)` that generates a congruence whose quotient is\nthe tensor product. -/\ninductive eqv {\u03b9 : Type u_1} [DecidableEq \u03b9] (R : Type u_2) [comm_semiring R] (s : \u03b9 \u2192 Type u_4)\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :\n    free_add_monoid (R \u00d7 ((i : \u03b9) \u2192 s i)) \u2192 free_add_monoid (R \u00d7 ((i : \u03b9) \u2192 s i)) \u2192 Prop\n    where\n| of_zero : \u2200 (r : R) (f : (i : \u03b9) \u2192 s i) (i : \u03b9), f i = 0 \u2192 eqv R s (free_add_monoid.of (r, f)) 0\n| of_zero_scalar : \u2200 (f : (i : \u03b9) \u2192 s i), eqv R s (free_add_monoid.of (0, f)) 0\n| of_add :\n    \u2200 (r : R) (f : (i : \u03b9) \u2192 s i) (i : \u03b9) (m\u2081 m\u2082 : s i),\n      eqv R s\n        (free_add_monoid.of (r, function.update f i m\u2081) +\n          free_add_monoid.of (r, function.update f i m\u2082))\n        (free_add_monoid.of (r, function.update f i (m\u2081 + m\u2082)))\n| of_add_scalar :\n    \u2200 (r r' : R) (f : (i : \u03b9) \u2192 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    \u2200 (r : R) (f : (i : \u03b9) \u2192 s i) (i : \u03b9) (r' : R),\n      eqv R s (free_add_monoid.of (r, function.update f i (r' \u2022 f i)))\n        (free_add_monoid.of (r' * r, f))\n| add_comm : \u2200 (x y : free_add_monoid (R \u00d7 ((i : \u03b9) \u2192 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 : \u03b9 \u2192 Type*` is the tensor\n  product of all the `s i`'s. This is denoted by `\u2a02[R] i, s i`. -/\ndef pi_tensor_product {\u03b9 : Type u_1} [DecidableEq \u03b9] (R : Type u_2) [comm_semiring R]\n    (s : \u03b9 \u2192 Type u_4) [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :=\n  add_con.quotient (add_con_gen sorry)\n\n/- This enables the notation `\u2a02[R] i : \u03b9, s i` for the pi tensor product, given `s : \u03b9 \u2192 Type*`. -/\n\nnamespace pi_tensor_product\n\n\nprotected instance add_comm_monoid {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    (s : \u03b9 \u2192 Type u_4) [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :\n    add_comm_monoid (pi_tensor_product R fun (i : \u03b9) => s i) :=\n  add_comm_monoid.mk add_monoid.add sorry add_monoid.zero sorry sorry sorry\n\nprotected instance inhabited {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    (s : \u03b9 \u2192 Type u_4) [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :\n    Inhabited (pi_tensor_product R fun (i : \u03b9) => s i) :=\n  { default := 0 }\n\n/-- `tprod_coeff R r f` with `r : R` and `f : \u03a0 i, s i` is the tensor product of the vectors `f i`\nover all `i : \u03b9`, 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 {\u03b9 : Type u_1} [DecidableEq \u03b9] (R : Type u_2) [comm_semiring R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] (r : R) (f : (i : \u03b9) \u2192 s i) :\n    pi_tensor_product R fun (i : \u03b9) => s i :=\n  coe_fn (add_con.mk' (add_con_gen (eqv R fun (i : \u03b9) => s i))) (free_add_monoid.of (r, f))\n\ntheorem zero_tprod_coeff {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    (f : (i : \u03b9) \u2192 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' {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] (z : R)\n    (f : (i : \u03b9) \u2192 s i) (i : \u03b9) (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 {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] (z : R)\n    (f : (i : \u03b9) \u2192 s i) (i : \u03b9) (m\u2081 : s i) (m\u2082 : s i) :\n    tprod_coeff R z (function.update f i m\u2081) + tprod_coeff R z (function.update f i m\u2082) =\n        tprod_coeff R z (function.update f i (m\u2081 + m\u2082)) :=\n  quotient.sound'\n    (add_con_gen.rel.of\n      (free_add_monoid.of (z, function.update f i m\u2081) +\n        free_add_monoid.of (z, function.update f i m\u2082))\n      (free_add_monoid.of (z, function.update f i (m\u2081 + m\u2082))) (eqv.of_add z f i m\u2081 m\u2082))\n\ntheorem add_tprod_coeff' {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] (z\u2081 : R)\n    (z\u2082 : R) (f : (i : \u03b9) \u2192 s i) :\n    tprod_coeff R z\u2081 f + tprod_coeff R z\u2082 f = tprod_coeff R (z\u2081 + z\u2082) f :=\n  quotient.sound'\n    (add_con_gen.rel.of (free_add_monoid.of (z\u2081, f) + free_add_monoid.of (z\u2082, f))\n      (free_add_monoid.of (z\u2081 + z\u2082, f)) (eqv.of_add_scalar z\u2081 z\u2082 f))\n\ntheorem smul_tprod_coeff_aux {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] (z : R)\n    (f : (i : \u03b9) \u2192 s i) (i : \u03b9) (r : R) :\n    tprod_coeff R z (function.update f i (r \u2022 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 \u2022 f i)))\n      (free_add_monoid.of (r * z, f)) (eqv.of_smul z f i r))\n\ntheorem smul_tprod_coeff {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] (z : R) (f : (i : \u03b9) \u2192 s i)\n    (i : \u03b9) (r : R') [semimodule R' (s i)] [is_scalar_tower R' R (s i)] :\n    tprod_coeff R z (function.update f i (r \u2022 f i)) = tprod_coeff R (r \u2022 z) f :=\n  sorry\n\n/-- Construct an `add_monoid_hom` from `(\u2a02[R] i, s i)` to some space `F` from a function\n`\u03c6 : (R \u00d7 \u03a0 i, s i) \u2192 F` with the appropriate properties. -/\ndef lift_add_hom {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] {F : Type u_6}\n    [add_comm_monoid F] (\u03c6 : R \u00d7 ((i : \u03b9) \u2192 s i) \u2192 F)\n    (C0 : \u2200 (r : R) (f : (i : \u03b9) \u2192 s i) (i : \u03b9), f i = 0 \u2192 \u03c6 (r, f) = 0)\n    (C0' : \u2200 (f : (i : \u03b9) \u2192 s i), \u03c6 (0, f) = 0)\n    (C_add :\n      \u2200 (r : R) (f : (i : \u03b9) \u2192 s i) (i : \u03b9) (m\u2081 m\u2082 : s i),\n        \u03c6 (r, function.update f i m\u2081) + \u03c6 (r, function.update f i m\u2082) =\n          \u03c6 (r, function.update f i (m\u2081 + m\u2082)))\n    (C_add_scalar : \u2200 (r r' : R) (f : (i : \u03b9) \u2192 s i), \u03c6 (r, f) + \u03c6 (r', f) = \u03c6 (r + r', f))\n    (C_smul :\n      \u2200 (r : R) (f : (i : \u03b9) \u2192 s i) (i : \u03b9) (r' : R),\n        \u03c6 (r, function.update f i (r' \u2022 f i)) = \u03c6 (r' * r, f)) :\n    (pi_tensor_product R fun (i : \u03b9) => s i) \u2192+ F :=\n  add_con.lift (add_con_gen (eqv R s)) (coe_fn free_add_monoid.lift \u03c6) 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' {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :\n    has_scalar R' (pi_tensor_product R fun (i : \u03b9) => s i) :=\n  has_scalar.mk\n    fun (r : R') =>\n      \u21d1(lift_add_hom (fun (f : R \u00d7 ((i : \u03b9) \u2192 s i)) => tprod_coeff R (r \u2022 prod.fst f) (prod.snd f))\n          sorry sorry sorry sorry sorry)\n\nprotected instance has_scalar {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :\n    has_scalar R (pi_tensor_product R fun (i : \u03b9) => s i) :=\n  pi_tensor_product.has_scalar'\n\ntheorem smul_tprod_coeff' {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] (r : R') (z : R)\n    (f : (i : \u03b9) \u2192 s i) : r \u2022 tprod_coeff R z f = tprod_coeff R (r \u2022 z) f :=\n  rfl\n\nprotected theorem smul_add {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] (r : R')\n    (x : pi_tensor_product R fun (i : \u03b9) => s i) (y : pi_tensor_product R fun (i : \u03b9) => s i) :\n    r \u2022 (x + y) = r \u2022 x + r \u2022 y :=\n  sorry\n\nprotected theorem induction_on' {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    {C : (pi_tensor_product R fun (i : \u03b9) => s i) \u2192 Prop}\n    (z : pi_tensor_product R fun (i : \u03b9) => s i)\n    (C1 : \u2200 {r : R} {f : (i : \u03b9) \u2192 s i}, C (tprod_coeff R r f))\n    (Cp : \u2200 {x y : pi_tensor_product R fun (i : \u03b9) => s i}, C x \u2192 C y \u2192 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' {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :\n    semimodule R' (pi_tensor_product R fun (i : \u03b9) => s i) :=\n  semimodule.mk sorry sorry\n\nprotected instance semimodule {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {R' : Type u_3} [comm_semiring R'] [algebra R' R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :\n    semimodule R' (pi_tensor_product R fun (i : \u03b9) => s i) :=\n  pi_tensor_product.semimodule'\n\n/-- The canonical `multilinear_map R s (\u2a02[R] i, s i)`. -/\ndef tprod {\u03b9 : Type u_1} [DecidableEq \u03b9] (R : Type u_2) [comm_semiring R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] :\n    multilinear_map R s (pi_tensor_product R fun (i : \u03b9) => s i) :=\n  multilinear_map.mk (tprod_coeff R 1) sorry sorry\n\n@[simp] theorem tprod_coeff_eq_smul_tprod {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2}\n    [comm_semiring R] {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)]\n    [(i : \u03b9) \u2192 semimodule R (s i)] (z : R) (f : (i : \u03b9) \u2192 s i) :\n    tprod_coeff R z f = z \u2022 coe_fn (tprod R) f :=\n  sorry\n\nprotected theorem induction_on {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    {C : (pi_tensor_product R fun (i : \u03b9) => s i) \u2192 Prop}\n    (z : pi_tensor_product R fun (i : \u03b9) => s i)\n    (C1 : \u2200 {r : R} {f : (i : \u03b9) \u2192 s i}, C (r \u2022 coe_fn (tprod R) f))\n    (Cp : \u2200 {x y : pi_tensor_product R fun (i : \u03b9) => s i}, C x \u2192 C y \u2192 C (x + y)) : C z :=\n  sorry\n\ntheorem ext {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] {E : Type u_5}\n    [add_comm_monoid E] [semimodule R E]\n    {\u03c6\u2081 : linear_map R (pi_tensor_product R fun (i : \u03b9) => s i) E}\n    {\u03c6\u2082 : linear_map R (pi_tensor_product R fun (i : \u03b9) => s i) E}\n    (H :\n      linear_map.comp_multilinear_map \u03c6\u2081 (tprod R) = linear_map.comp_multilinear_map \u03c6\u2082 (tprod R)) :\n    \u03c6\u2081 = \u03c6\u2082 :=\n  sorry\n\n/-- Auxiliary function to constructing a linear map `(\u2a02[R] i, s i) \u2192 E` given a\n`multilinear map R s E` with the property that its composition with the canonical\n`multilinear_map R s (\u2a02[R] i, s i)` is the given multilinear map. -/\ndef lift_aux {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)] {E : Type u_5}\n    [add_comm_monoid E] [semimodule R E] (\u03c6 : multilinear_map R s E) :\n    (pi_tensor_product R fun (i : \u03b9) => s i) \u2192+ E :=\n  lift_add_hom (fun (p : R \u00d7 ((i : \u03b9) \u2192 s i)) => prod.fst p \u2022 coe_fn \u03c6 (prod.snd p)) sorry sorry\n    sorry sorry sorry\n\ntheorem lift_aux_tprod {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] (\u03c6 : multilinear_map R s E)\n    (f : (i : \u03b9) \u2192 s i) : coe_fn (lift_aux \u03c6) (coe_fn (tprod R) f) = coe_fn \u03c6 f :=\n  sorry\n\ntheorem lift_aux_tprod_coeff {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] (\u03c6 : multilinear_map R s E) (z : R)\n    (f : (i : \u03b9) \u2192 s i) : coe_fn (lift_aux \u03c6) (tprod_coeff R z f) = z \u2022 coe_fn \u03c6 f :=\n  sorry\n\ntheorem lift_aux.smul {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] {\u03c6 : multilinear_map R s E} (r : R)\n    (x : pi_tensor_product R fun (i : \u03b9) => s i) :\n    coe_fn (lift_aux \u03c6) (r \u2022 x) = r \u2022 coe_fn (lift_aux \u03c6) x :=\n  sorry\n\n/-- Constructing a linear map `(\u2a02[R] i, s i) \u2192 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 `\u03c6`. -/\ndef lift {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R] {s : \u03b9 \u2192 Type u_4}\n    [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 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 : \u03b9) => s i) E) :=\n  linear_equiv.mk\n    (fun (\u03c6 : multilinear_map R s E) =>\n      linear_map.mk (add_monoid_hom.to_fun (lift_aux \u03c6)) sorry sorry)\n    sorry sorry\n    (fun (\u03c6' : linear_map R (pi_tensor_product R fun (i : \u03b9) => s i) E) =>\n      linear_map.comp_multilinear_map \u03c6' (tprod R))\n    sorry sorry\n\n@[simp] theorem lift.tprod {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] {\u03c6 : multilinear_map R s E}\n    (f : (i : \u03b9) \u2192 s i) : coe_fn (coe_fn lift \u03c6) (coe_fn (tprod R) f) = coe_fn \u03c6 f :=\n  lift_aux_tprod \u03c6 f\n\ntheorem lift.unique' {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] {\u03c6 : multilinear_map R s E}\n    {\u03c6' : linear_map R (pi_tensor_product R fun (i : \u03b9) => s i) E}\n    (H : linear_map.comp_multilinear_map \u03c6' (tprod R) = \u03c6) : \u03c6' = coe_fn lift \u03c6 :=\n  ext (Eq.symm H \u25b8 Eq.symm (linear_equiv.symm_apply_apply lift \u03c6))\n\ntheorem lift.unique {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 semimodule R (s i)]\n    {E : Type u_5} [add_comm_monoid E] [semimodule R E] {\u03c6 : multilinear_map R s E}\n    {\u03c6' : linear_map R (pi_tensor_product R fun (i : \u03b9) => s i) E}\n    (H : \u2200 (f : (i : \u03b9) \u2192 s i), coe_fn \u03c6' (coe_fn (tprod R) f) = coe_fn \u03c6 f) : \u03c6' = coe_fn lift \u03c6 :=\n  lift.unique' (multilinear_map.ext H)\n\ntheorem lift_tprod {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_semiring R]\n    {s : \u03b9 \u2192 Type u_4} [(i : \u03b9) \u2192 add_comm_monoid (s i)] [(i : \u03b9) \u2192 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 `\u03b9` is empty. -/\n\nprotected instance add_comm_group {\u03b9 : Type u_1} [DecidableEq \u03b9] {R : Type u_2} [comm_ring R]\n    {s : \u03b9 \u2192 Type u_3} [(i : \u03b9) \u2192 add_comm_group (s i)] [(i : \u03b9) \u2192 module R (s i)] :\n    add_comm_group (pi_tensor_product R fun (i : \u03b9) => 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 {\u03b1 \u03b2 : Type}\n\nopen list atom tactic\n\ndef formula.atoms : formula \u2192 list atom\n| \u22a4' := []\n| \u22a5' := []\n| (A' a) := [a]\n| (\u00ac' p) := p.atoms\n| (p \u2228' q) := p.atoms ++ q.atoms\n| (p \u2227' q) := p.atoms ++ q.atoms\n| (\u2203' p) := p.atoms\n\ndef head_coeff : atom \u2192 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 \u2260 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 \u2192 atom \u2192 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 \u2192 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]) \u2227' (p.map (atom.unify (coeffs_lcm p)))\n\ndef inf_minus : formula \u2192 formula\n| \u22a4' := \u22a4'\n| \u22a5' := \u22a5'\n| (A' (atom.le i (k::ks))) :=\n  if k < 0\n  then \u22a4'\n  else if k > 0\n       then \u22a5'\n       else A' (atom.le i (0::ks))\n| (A' a) := A' a\n| (p \u2227' q) := and_o (inf_minus p) (inf_minus q)\n| (p \u2228' q) := or_o (inf_minus p) (inf_minus q)\n| (\u00ac' p) := \u00ac' p\n| (\u2203' p) := \u2203' p\n\nlemma inf_minus_le_eq_of_lt {i k ks} :\n  k < 0 \u2192 inf_minus (A' (atom.le i (k::ks))) = \u22a4' :=\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 \u2192 inf_minus (A' (atom.le i (k::ks))) = \u22a5' :=\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 \u22a4'\n  else if k > 0\n       then \u22a5'\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 \u2192 option (znum \u00d7 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 \u2192 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  \u2200 {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 \u2264 z \u2192 z < y \u2192 z \u2208 znum.range y :=\nbegin\n  intros hz hzy, have hy : 0 \u2264 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 \u2264 z \u2192 z < (abs y) \u2192 z \u2208 znum.range y :=\nbegin\n  by_cases hy : (0 \u2264 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 \u2264 y \u2192 (x \u2208 znum.range y \u2194 (0 \u2264 x \u2227 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)) (\u03bb n, subst n [] (inf_minus p))\n\ndef sqe_bnd  (p : formula) : formula :=\n  disj_map (bnd_points p)\n   (\u03bb iks, disj_map (znum.range (divisors_lcm p))\n     (\u03bb 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E]\n{F : Type*} [normed_group F] [normed_space \ud835\udd5c F]\n{G : Type*} [normed_group G] [normed_space \ud835\udd5c 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 \u2192L[\ud835\udd5c] F` at `x : E`:\n`f y = f x + f (y - x)`. -/\n@[simp] def fpower_series (f : E \u2192L[\ud835\udd5c] F) (x : E) : formal_multilinear_series \ud835\udd5c E F\n| 0 := continuous_multilinear_map.curry0 \ud835\udd5c _ (f x)\n| 1 := (continuous_multilinear_curry_fin1 \ud835\udd5c E F).symm f\n| _ := 0\n\n@[simp] lemma fpower_series_apply_add_two (f : E \u2192L[\ud835\udd5c] F) (x : E) (n : \u2115) :\n  f.fpower_series x (n + 2) = 0 := rfl\n\n@[simp] lemma fpower_series_radius (f : E \u2192L[\ud835\udd5c] F) (x : E) : (f.fpower_series x).radius = \u221e :=\n(f.fpower_series x).radius_eq_top_of_forall_image_add_eq_zero 2 $ \u03bb n, rfl\n\nprotected theorem has_fpower_series_on_ball (f : E \u2192L[\ud835\udd5c] F) (x : E) :\n  has_fpower_series_on_ball f (f.fpower_series x) x \u221e :=\n{ r_le := by simp,\n  r_pos := ennreal.coe_lt_top,\n  has_sum := \u03bb y _, (has_sum_nat_add_iff' 2).1 $\n    by simp [finset.sum_range_succ, \u2190 sub_sub, has_sum_zero] }\n\nprotected theorem has_fpower_series_at (f : E \u2192L[\ud835\udd5c] F) (x : E) :\n  has_fpower_series_at f (f.fpower_series x) x :=\n\u27e8\u221e, f.has_fpower_series_on_ball x\u27e9\n\nprotected theorem analytic_at (f : E \u2192L[\ud835\udd5c] F) (x : E) : analytic_at \ud835\udd5c f x :=\n(f.has_fpower_series_at x).analytic_at\n\n/-- Reinterpret a bilinear map `f : E \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G` as a multilinear map\n`(E \u00d7 F) [\u00d72]\u2192L[\ud835\udd5c] 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 \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G) : (E \u00d7 F) [\u00d72]\u2192L[\ud835\udd5c] G :=\n@continuous_linear_map.uncurry_left \ud835\udd5c 1 (\u03bb _, E \u00d7 F) G _ _ _ _ _ $\n  (\u2191(continuous_multilinear_curry_fin1 \ud835\udd5c (E \u00d7 F) G).symm : (E \u00d7 F \u2192L[\ud835\udd5c] G) \u2192L[\ud835\udd5c] _).comp $\n    f.bilinear_comp (fst _ _ _) (snd _ _ _)\n\n@[simp] lemma uncurry_bilinear_apply (f : E \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G) (m : fin 2 \u2192 E \u00d7 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 \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G`. -/\n@[simp] def fpower_series_bilinear (f : E \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G) (x : E \u00d7 F) :\n  formal_multilinear_series \ud835\udd5c (E \u00d7 F) G\n| 0 := continuous_multilinear_map.curry0 \ud835\udd5c _ (f x.1 x.2)\n| 1 := (continuous_multilinear_curry_fin1 \ud835\udd5c (E \u00d7 F) G).symm (f.deriv\u2082 x)\n| 2 := f.uncurry_bilinear\n| _ := 0\n\n@[simp] lemma fpower_series_bilinear_radius (f : E \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G) (x : E \u00d7 F) :\n  (f.fpower_series_bilinear x).radius = \u221e :=\n(f.fpower_series_bilinear x).radius_eq_top_of_forall_image_add_eq_zero 3 $ \u03bb n, rfl\n\nprotected \n\nprotected theorem has_fpower_series_at_bilinear (f : E \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G) (x : E \u00d7 F) :\n  has_fpower_series_at (\u03bb x : E \u00d7 F, f x.1 x.2) (f.fpower_series_bilinear x) x :=\n\u27e8\u221e, f.has_fpower_series_on_ball_bilinear x\u27e9\n\nprotected theorem analytic_at_bilinear (f : E \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G) (x : E \u00d7 F) :\n  analytic_at \ud835\udd5c (\u03bb x : E \u00d7 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 \u27f6 M') (g : M' \u27f6 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'' : \u211d\u22650}\n  [hk : fact (1 \u2264 k)] [hk' : fact (1 \u2264 k')] [hk'' : fact (1 \u2264 k'')]\n  {m : \u2115} {c\u2080 : \u211d\u22650}\n  (hM : M.is_weak_bounded_exact k K (m+1) c\u2080)\n  (hM' : M'.is_weak_bounded_exact k' K' (m+1) c\u2080)\n  (hM'_adm : M'.admissible)\n  (hf : \u2200 c i, (f.apply : M c i \u27f6 M' c i).norm_noninc)\n  (Hf : \u2200 (c : \u211d\u22650) [fact (c\u2080 \u2264 c)] (i : \u2115) (hi : i \u2264 m+1+1) (x : M (k'' * c) i),\n    \u2225(res x : M c i)\u2225 \u2264 K'' * \u2225f x\u2225)\n  (hg : \u2200 c i, (g.apply : M' c i \u27f6 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\u2080 :=\nbegin\n  introsI c hc i hi,\n  let c\u2081 := k'' * (k * (k' * c)),\n  suffices : \u2200 n : N c\u2081 i, \u2200 \u03b5 > 0,\n    \u2203 i\u2080 (hi\u2080 : i\u2080 = i - 1) (y : N c i\u2080),\n      \u2225res n - N.d _ _ y\u2225 \u2264 K' * (K * K'' + 1) * \u2225N.d i (i+1) n\u2225 + \u03b5,\n  { dsimp [c\u2081] at this,\n    intros n\u2081 \u03b5 h\u03b5,\n    haveI hc : fact (k'' * k * k' * c = c\u2081) :=\n      { out := (mul_assoc _ _ _).trans ((mul_assoc _ _ _).trans rfl) },\n    rcases this (res n\u2081) \u03b5 h\u03b5 with \u27e8i\u2080, hi\u2080, y, hy\u27e9,\n    rw [res_res, d_res] at hy,\n    refine \u27e8i\u2080, _, hi\u2080, rfl, _\u27e9,\n    refine \u27e8y, hy.trans (add_le_add_right (mul_le_mul_of_nonneg_left _ _) \u03b5)\u27e9,\n    { apply (admissible_of_quotient hgquot hM'_adm).res_norm_noninc },\n    { exact (nnreal.zero_le_coe : 0 \u2264 K' * (K * K'' + 1)) } },\n  intros n \u03b5 h\u03b5,\n  let \u03b5\u2081 := \u03b5/(K' * (K * K'' + 2) + 1),\n\n  have h\u03b5\u2081 : 0 < \u03b5\u2081 :=\n    div_pos h\u03b5 (lt_of_lt_of_le zero_lt_one (nnreal.one_le_add'.out : 1 \u2264 K' * (K * K'' + 2) + 1)),\n\n  obtain \u27e8m' : M' c\u2081 i, rfl : g m' = n\u27e9 := (hgquot _ _).surjective _,\n  let m\u2081' := M'.d i (i+1) m',\n  have hm\u2081' : g m\u2081' = N.d i (i+1) (g m') := (d_apply _ _ g m').symm,\n  obtain \u27e8m\u2081'' : M' c\u2081 (i+1),\n          hgm\u2081'' : g m\u2081'' = N.d i (i+1) (g m'),\n          hnorm_m\u2081'' : \u2225m\u2081''\u2225 < \u2225N.d i (i+1) (g m')\u2225 + \u03b5\u2081\u27e9 :=\n    (hgquot _ _).norm_lift h\u03b5\u2081 (N.d i (i+1) (g m')),\n  obtain \u27e8m\u2081, hm\u2081\u27e9 : \u2203 m\u2081 : M c\u2081 (i+1), f m\u2081 + m\u2081'' = m\u2081',\n  { have hrange : m\u2081' - m\u2081'' \u2208 f.apply.range,\n    { rw [\u2190 hg _ _, mem_ker  _ _, _root_.map_sub],\n      change g m\u2081' - g m\u2081'' = 0,\n      rw [hm\u2081', hgm\u2081'', sub_self] },\n    obtain \u27e8m\u2081, hm\u2081 : f m\u2081 = m\u2081' - m\u2081''\u27e9 := (mem_range _ _).1 hrange,\n    exact \u27e8m\u2081, by rw [hm\u2081, sub_add_cancel]\u27e9 },\n\n  have him : i+2 \u2264 m+2 := add_le_add_right hi _,\n  have hm\u2082 : f (M.d (i+1) (i+2) m\u2081) = -M'.d (i+1) (i+2) m\u2081'',\n  { rw [\u2190 d_apply, eq_sub_of_add_eq hm\u2081, _root_.map_sub, \u2190 category_theory.comp_apply,\n       d_comp_d, coe_zero, \u2190 neg_inj, pi.zero_apply, zero_sub], },\n  have hle : \u2225res (M.d (i+1) (i+2) m\u2081)\u2225 \u2264 K'' * \u2225m\u2081''\u2225,\n  { calc \u2225res (M.d (i+1) (i+2) m\u2081)\u2225\n        \u2264 K'' * \u2225f (M.d (i+1) (i+2) m\u2081)\u2225 : Hf _ _ him _\n    ... = K'' * \u2225M'.d (i+1) (i+2) m\u2081''\u2225 : by rw [hm\u2082, norm_neg]\n    ... \u2264 K'' * \u2225m\u2081''\u2225 : (mul_le_mul_of_nonneg_left\n                           (hM'_adm.d_norm_noninc _ _ _ _ m\u2081'') $ nnreal.coe_nonneg K'') },\n  obtain \u27e8i', j, hi', rfl, m\u2080, hm\u2080\u27e9 :=\n    hM _ \u27e8hc.out.trans $ le_mul_of_one_le_left' hk'.out\u27e9 _ (nat.succ_le_succ hi) (res m\u2081) \u03b5\u2081 h\u03b5\u2081,\n  rw [\u2190 nat.pred_eq_sub_one, i.pred_succ] at hi', subst i',\n  replace hm\u2080 : \u2225res m\u2081 - M.d i (i+1) m\u2080\u2225 \u2264 K * K'' * \u2225N.d i (i+1) (g m')\u2225 + K*K''*\u03b5\u2081 + \u03b5\u2081,\n  { calc \u2225res m\u2081 - M.d i (i+1) m\u2080\u2225  = \u2225res (res m\u2081) - M.d i (i+1) m\u2080\u2225 : by rw res_res\n    ... \u2264 K * \u2225M.d (i+1) (i+2) (res m\u2081)\u2225 + \u03b5\u2081 : hm\u2080\n    ... = K * \u2225res (M.d (i+1) (i+2) m\u2081)\u2225 + \u03b5\u2081 : by rw d_res\n    ... \u2264 K*(K'' * \u2225m\u2081''\u2225) + \u03b5\u2081 : add_le_add_right (mul_le_mul_of_nonneg_left hle nnreal.zero_le_coe) _\n    ... \u2264 K*(K'' * (\u2225N.d i (i+1) (g m')\u2225 + \u03b5\u2081)) + \u03b5\u2081 :  add_le_add_right (mul_le_mul_of_nonneg_left\n                                        (mul_le_mul_of_nonneg_left hnorm_m\u2081''.le nnreal.zero_le_coe)\n                                         nnreal.zero_le_coe) \u03b5\u2081\n    ... = K * K'' * \u2225N.d i (i+1) (g m')\u2225 + K*K''*\u03b5\u2081 + \u03b5\u2081 : by ring },\n\n  let mnew\u2081' := M'.d i (i+1) (res m' - f m\u2080),\n  have hmnew' : mnew\u2081' = res m\u2081'' + f (res m\u2081 - M.d i (i+1) m\u2080),\n  { calc mnew\u2081'\n        = M'.d i (i+1) (res m' - f m\u2080) : rfl\n    ... = res (M'.d i (i+1) m') - (f (M.d i (i+1) m\u2080)) : by rw [_root_.map_sub, d_res _, d_apply]\n    ... = res (M'.d i (i+1) m') - (f (res m\u2081)) + (f (res m\u2081) - f (M.d i (i+1) m\u2080)) : by abel\n    ... = res m\u2081'' + f ((res m\u2081) - (M.d i (i+1) m\u2080)) : by\n                        { rw [\u2190 system_of_complexes.map_sub, \u2190 res_apply,\n                              \u2190 _root_.map_sub, \u2190 sub_eq_of_eq_add' hm\u2081.symm] } },\n  have hnormle : \u2225mnew\u2081'\u2225 \u2264 (K*K'' + 1)*\u2225N.d i (i+1) (g m')\u2225 + (K*K'' + 2) * \u03b5\u2081,\n  { calc \u2225mnew\u2081'\u2225\n        = \u2225res m\u2081'' + f (res m\u2081 - M.d i (i+1) m\u2080)\u2225 : by rw [hmnew']\n    ... \u2264 \u2225res m\u2081''\u2225 + \u2225f (res m\u2081 - M.d i (i+1) m\u2080)\u2225 : norm_add_le _ _\n    ... \u2264 \u2225m\u2081''\u2225 + \u2225f (res m\u2081 - M.d i (i+1) m\u2080)\u2225 : add_le_add_right\n                                      (hM'_adm.res_norm_noninc _ _ _ _ m\u2081'') _\n    ... \u2264 \u2225m\u2081''\u2225 + \u2225res m\u2081 - M.d i (i+1) m\u2080\u2225 : add_le_add_left (hf _ _ _) _\n    ... \u2264 \u2225N.d i (i+1) (g m')\u2225 + \u03b5\u2081 + \u2225res m\u2081 - M.d i (i+1) m\u2080\u2225 : add_le_add_right (le_of_lt hnorm_m\u2081'')  _\n    ... \u2264 \u2225N.d i (i+1) (g m')\u2225 + \u03b5\u2081 + (K * K'' * \u2225N.d i (i+1) (g m')\u2225 + K * K'' * \u03b5\u2081 + \u03b5\u2081) : add_le_add_left hm\u2080 _\n    ... = (K*K'' + 1)*\u2225d _ _ (i+1) (g m')\u2225 + (K*K'' + 2) * \u03b5\u2081 : by ring },\n  obtain \u27e8i\u2080, _, hi\u2080, rfl, mnew\u2080, hmnew\u2080\u27e9 := hM' _ hc _ (hi.trans m.le_succ) (res m' - f m\u2080) _ h\u03b5\u2081,\n  replace hmnew\u2080 : \u2225res (res m' - f m\u2080) - d _ _ _ mnew\u2080\u2225 \u2264\n    K' * ((K * K'' + 1) * \u2225N.d i (i+1) (g m')\u2225 + (K * K'' + 2) * \u03b5\u2081) + \u03b5\u2081 :=\n    hmnew\u2080.trans (add_le_add_right (mul_le_mul_of_nonneg_left hnormle nnreal.zero_le_coe) \u03b5\u2081),\n  let nnew\u2080 : \u21a5(N c i\u2080) := g mnew\u2080,\n  have hmnewlift : g (res (res m' - f m\u2080) - M'.d i\u2080 i mnew\u2080) = res (g m') - N.d i\u2080 i nnew\u2080,\n  { suffices h : g (res m' - f m\u2080) = res (g m'),\n    { rw [system_of_complexes.map_sub, \u2190 res_apply, \u2190 d_apply, h, res_res] },\n    rw system_of_complexes.map_sub,\n    have hker : f m\u2080 \u2208 g.apply.ker,\n    { rw [hg _ _, mem_range _ _],\n      exact \u27e8m\u2080, rfl\u27e9 },\n    replace hker : g (f m\u2080) = 0, { rwa mem_ker at hker },\n    rw [hker, sub_zero, \u2190 res_apply] },\n  refine \u27e8i\u2080, hi\u2080, nnew\u2080, _\u27e9,\n  rw \u2190 hmnewlift,\n  refine ((hgquot _ _).norm_le _).trans (hmnew\u2080.trans (le_of_eq _)),\n  have h\u03b5\u2081_\u03b5 : (K' * (K * K'' + 2) + 1 : \u211d)*\u03b5\u2081 = \u03b5 := mul_div_cancel' _\n    (by { refine (lt_of_lt_of_le zero_lt_one _).ne',\n          exact (nnreal.one_le_add'.out : 1 \u2264 K' * (K * K'' + 2) + 1) }),\n  rw \u2190 h\u03b5\u2081_\u03b5,\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 \u2192 ^symbol \u2192 state \u2192 ^symbol \u2192 direction \u2192 bool\n\ndef turing_machine (state symbol : Type) [decidable_eq state] [decidable_eq symbol] :=\nstate \u2192 ^symbol \u2192 ^(state \u00d7 ^symbol \u00d7 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\u03bb 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\u27e8to_nondet\u27e9\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) \u2192 ^A \u00d7 list (^A)\n| []       := (none, [])\n| (a :: s) := (a, s)\n\ndef cons' : ^A \u2192 list (^A) \u2192 list (^A)\n| none [] := []\n| v    s  := v::s\n\ndef apply_step\n  (l r : list (^A)) (c : S) (v : ^A) : direction \u2192 TM_config S A\n| direction.left  := let \u27e8a, l'\u27e9 := uncons l in \u27e8c, a, l', cons' v r\u27e9\n| direction.right := let \u27e8a, r'\u27e9 := uncons r in \u27e8c, a, cons' v l, r'\u27e9\n\ninductive step (TM : nondet_turing_machine S A) :\n  TM_config S A \u2192 TM_config S A \u2192 Prop\n| mk {c h l r c' v d} :\n  TM c h c' v d \u2192 step \u27e8c, h, l, r\u27e9 (apply_step l r c' v d)\n\ndef halts (TM) (s : TM_config S A) : Prop := \u2200 s', \u00ac step TM s s'\n\ninductive computes (TM) (res : TM_config S A) : nat \u2192 TM_config S A \u2192 Prop\n| done : halts TM res \u2192 computes 0 res\n| step {s s' n} : step TM s s' \u2192 computes n s' \u2192 computes (n+1) s\n\ndef next (TM : turing_machine S A) : TM_config S A \u2192 option (TM_config S A)\n| \u27e8c, h, l, r\u27e9 := 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' \u2194 @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 \u27e8to_bool_true e\u27e9 } },\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 \u2194 @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 \u2192 tape_alpha\n| delim {} : tape_alpha\n| work {} : fin n \u2192 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) := \u27e8to_nondet\u27e9\n\ndef encode {n} : list (list bool) \u2192 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 \u2192 list bool) \u2192 list bool)\n  (tm : (fin m \u2192 list bool) \u2192 nat) : Prop :=\n\u2200 i : fin m \u2192 list bool,\n\u2203 (n \u2264 tm i) e,\n  computes TM\n    \u27e8e, none, [], encode [f i]\u27e9 n\n    \u27e80, none, [], encode (array.to_list \u27e8i\u27e9)\u27e9\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 \u2227 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 \u2260 2)\n: \u2203 (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 \u27e8 1, 0, -E.a1/2, -E.a3/2, by simp \u27e9,\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 \u2227 E.a2 = 0 \u2227 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 \u27e8 h.1, h.2.2 \u27e9\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 \u27e8 h.1, h.2.2 \u27e9\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 \u2260 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 \u2260 2) (hchar3 : ring_char K \u2260 3)\n: \u2203 (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 \u27e8 C, h1 \u27e9,\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 := \u27e8 1, -E'.a2/3, 0, 0, by simp \u27e9,\n  use C'.composite C,\n  rw [linear_change_of_variable.change_curve.comp, \u2190 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 \u2227 E.a3 = 0 \u2227 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' \u2192 E.j \u2260 0) \u2227 \u2203 (C : linear_change_of_variable K), (C.change_curve E).is_model_of_char_3_j_non_zero)\n\u2228 (E.j = 0 \u2227 \u2203 (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 \u2260 2 := by {\n    rw hchar3, norm_num,\n  },\n  rcases E.have_model_of_char_neq_2 hchar2 with \u27e8 C, h1 \u27e9,\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' \u2194 E'.non_singular' := C.preserve_non_singular' E,\n  rw [\u2190 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 \u27e8 h1.1, ha2, h1.2 \u27e9,\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 := \u27e8 1, E'.a4/E'.a2, 0, 0, by simp \u27e9,\n  use C'.composite C,\n  rw [linear_change_of_variable.change_curve.comp, \u2190 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 \u2227 E.a3 = 0 \u2227 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 \u2227 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' \u2192 E.j \u2260 0) \u2227 \u2203 (C : linear_change_of_variable K), (C.change_curve E).is_model_of_char_2_j_non_zero)\n\u2228 (E.j = 0 \u2227 \u2203 (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 \u27e8 1, E.a2, 0, 0, by simp \u27e9,\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 \u27e8 E.a1, E.a3/E.a1, 0, (E.a1^2*E.a4+E.a3^2)/E.a1^3, ha1 \u27e9,\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 {\u03c3 : nat}\n\n/- maximal set of a context -/\n\nnamespace ctx\ndef is_max (\u0393 : ctx \u03c3) := is_consist \u0393 \u2227 \u2200 p, p \u2208 \u0393 \u2228 (~p) \u2208 \u0393\n\ndef insert_form (\u0393 : ctx \u03c3) (p : form \u03c3) : ctx \u03c3 :=\nif is_consist (\u0393 \u2e34 p) then \u0393 \u2e34 p else \u0393 \u2e34 ~p\n\ndef insert_code (\u0393 : ctx \u03c3) (n : nat) : ctx \u03c3 :=\nmatch encodable.decode (form \u03c3) n with\n| none := \u0393\n| some p := insert_form \u0393 p\nend\n\n@[simp]\ndef maxn (\u0393 : ctx \u03c3) : nat \u2192 ctx \u03c3\n| 0     := \u0393\n| (n+1) := insert_code (maxn n) n\n\n@[simp]\ndef max (\u0393 : ctx \u03c3) : ctx \u03c3 := \n\u22c3 n, maxn \u0393 n\n\n/- maximal extensions are extensions -/\n\nlemma subset_insert_code {\u0393 : ctx \u03c3} (n) :\n  \u0393 \u2286 insert_code \u0393 n :=\nbegin\n  intros v hv,\n  unfold insert_code,\n  cases (encodable.decode (form \u03c3) _); unfold insert_code insert_form,\n  { assumption },\n  { split_ifs; exact set.mem_insert_of_mem _ hv },\nend\n\nlemma subset_maxn {\u0393 : ctx \u03c3} :\n  \u2200 n, \u0393 \u2286 maxn \u0393 n\n| 0        := by refl\n| (succ n) := subset.trans (subset_maxn n) (subset_insert_code _)\n\nlemma maxn_subset_max {\u0393 : ctx \u03c3} (n) :\n  maxn \u0393 n \u2286 max \u0393 :=\nsubset_Union _ _\n\nlemma subset_max_self {\u0393 : ctx \u03c3} :\n  \u0393 \u2286 max \u0393 :=\nmaxn_subset_max 0\n\nlemma maxn_subset_succ {\u0393 : ctx \u03c3} {n : nat} :\n  maxn \u0393 n \u2286 maxn \u0393 (n+1) :=\nsubset_insert_code _\n\nlemma maxn_mono {\u0393 : ctx \u03c3} {m n : nat} (h : n \u2264 m) :\n  maxn \u0393 n \u2286 maxn \u0393 m :=\nby induction h; [refl, exact subset.trans h_ih (subset_insert_code _)]\n\n/- maximal extensions are maximal -/\n\nlemma insert_form_self {\u0393 : ctx \u03c3} {p : form \u03c3} :\n  p \u2208 insert_form \u0393 p \u2228 (~p) \u2208 insert_form \u0393 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 {\u0393 : ctx \u03c3} (p : form \u03c3) :\n  p \u2208 insert_code \u0393 (encodable.encode p) \u2228 (~p) \u2208 insert_code \u0393 (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 {\u0393 : ctx \u03c3} (p : form \u03c3) :\n  p \u2208 max \u0393 \u2228 (~p) \u2208 max \u0393 :=\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 {\u0393 : ctx \u03c3} {p : form \u03c3}\n  (H : is_consist \u0393) : is_consist (insert_form \u0393 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 {\u0393 : ctx \u03c3} (n)\n  (H : is_consist \u0393) : is_consist (insert_code \u0393 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 {\u0393 : ctx \u03c3} : \n  \u2200 n, is_consist \u0393 \u2192 is_consist (maxn \u0393 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 {\u0393 : ctx \u03c3} {p : form \u03c3} :\n  (p \u2208 max \u0393) \u2192 \u2203 n, p \u2208 maxn \u0393 n :=\nmem_Union.1\n\nlemma ext_ctx_lvl {\u0393 : ctx \u03c3} {p : form \u03c3} :\n  (max \u0393 \u22a2\u209b\u2085 p) \u2192 \u2203 n, maxn \u0393 n \u22a2\u209b\u2085 p :=\nbegin\n  generalize eq : max \u0393 = \u0393',\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 \u2264 n1)),\n            have hh: n1 \u2264 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 {\u0393 : ctx \u03c3} :\n  is_consist \u0393 \u2192 is_consist (max \u0393) :=\n\u03bb hc nc, let \u27e8n, ht\u27e9 := ext_ctx_lvl nc in is_consist_maxn _ hc ht\n\n/- maximal consistent sets are closed under derivability -/\n\nlemma max_of_max {\u0393 : ctx \u03c3} {p : form \u03c3} (h : is_consist \u0393) : is_max (max \u0393) :=\n\u27e8 is_consist_max h , mem_or_mem_max\u27e9 \n\nlemma mem_max_of_prf {\u0393 : ctx \u03c3} {p : form \u03c3} (h\u2081 : is_max \u0393)\n  (h\u2082 : \u0393 \u22a2\u209b\u2085 p) : p \u2208 \u0393 :=\n(h\u2081.2 p).resolve_right $ \u03bb hn,\nh\u2081.1 (prf.mp (prf.ax hn) h\u2082)\n\nend ctx\n\n/- the canonical model construction -/\n\n-- domain\n\nnamespace canonical\ndef domain (\u03c3 : nat) : set (wrld \u03c3) := {w | ctx.is_max w}\n\nlemma mem_domain_max {w : wrld \u03c3} :\n  w \u2208 domain \u03c3 \u2192 \u2200 p, (p \u2208 w) \u2228 ((~p) \u2208 w) :=\nand.right\n\nlemma mem_domain_consist {w : wrld \u03c3} :\n  w \u2208 domain \u03c3 \u2192 is_consist w :=\nand.left\n\nlemma mem_domain {w : wrld \u03c3}\n  (h : is_consist w) : ctx.max w \u2208 domain \u03c3 :=\n\u27e8ctx.is_consist_max h, ctx.mem_or_mem_max\u27e9\n\nlemma mem_domain_of_prf {p : form \u03c3} (w \u2208 domain \u03c3)\n  (h : w \u22a2\u209b\u2085 p) : p \u2208 w :=\n(mem_domain_max H p).resolve_right $\n\u03bb hn, (mem_domain_consist H) (prf.mp (prf.ax hn) h)\n\n-- accessibility\n\ndef unbox (w : wrld \u03c3) : wrld \u03c3 := {p | (\u25fbp) \u2208 w}\n\nnoncomputable def access : wrld \u03c3 \u2192 wrld \u03c3 \u2192 bool :=\nassume w v, if (unbox w \u2286 v) then tt else ff\n\nlemma subset_unbox_iff_access {w v : wrld \u03c3} : access w v = tt \u2194 unbox w \u2286 v :=\nby unfold access; simp \n\nlemma mem_unbox_iff_mem_box {p : form \u03c3} {w : wrld \u03c3} :\n  p \u2208 unbox w \u2194 (\u25fbp) \u2208 w :=\n\u27e8 id, id \u27e9 \n\nlemma not_mem_unbox_of_mem_not_box {p : form \u03c3} {w : wrld \u03c3} (hc : w \u2208 domain \u03c3) :\n  (~\u25fbp) \u2208 w \u2192 p \u2209 unbox w :=\n\u03bb 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 \u03c3} {w : wrld \u03c3} (H : w \u2208 domain \u03c3) :\n  (unbox w \u22a2\u209b\u2085 p) \u2192 (\u25fbp) \u2208 w :=\nbegin\n  generalize eq : unbox w = \u0393',\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 \u03c3} {w : wrld \u03c3} (hw : w \u2208 domain \u03c3) :\n  (~\u25fbp) \u2208 w \u2192 (unbox w \u22ac\u209b\u2085 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 \u03c3} {w : wrld \u03c3} (hw : w \u2208 domain \u03c3) :\n  (~\u25fbp) \u2208 w \u2192 is_consist (unbox w \u2e34 (~p)) :=\n\u03bb hn, consist_not_of_not_prf (not_unbox_prf_of_not_box_mem hw hn)\n\n-- valuation\n\nnoncomputable def val : fin \u03c3 \u2192 wrld \u03c3 \u2192 bool :=\nassume p w, if w \u2208 domain \u03c3 \u2227 (#p) \u2208 w then tt else ff\n\n-- reflexivity\n\nlemma access.refl :\n  \u2200 w \u2208 domain \u03c3, 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 : \u2200 w \u2208 domain \u03c3, \u2200 v \u2208 domain \u03c3, access w v = tt \u2192 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\u2081 : \u2200 p, p \u2209 v \u2192 p \u2209 unbox w, from \n      (\u03bb p, (@not_imp_not _ _ (prop_decidable _)).2 (@sw _ ) ),\n      have h\u2082 : (\u25fb~\u25fbp) \u2209 w, from \n      begin\n        apply h\u2081,\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 (\u25fb~\u25fbp),\n      { contradiction },\n      { apply prf.ax, assumption } }\nend\n\n-- transitivity\n\nlemma access.trans : \u2200 w \u2208 domain \u03c3, \u2200 v \u2208 domain \u03c3, \u2200 u \u2208 domain \u03c3,\n  access w v = tt \u2192 access v u = tt \u2192 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 \u03c3 :=\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 \u03c3} : \n  \u2200 (w \u2208 domain \u03c3), (w \u22a9\u2983model\u2984 p) = tt \u2194 p \u2208 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\u2081 h\u2082,\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\u2082)) } },\n      { cases mem_domain_max wm q with h\u2081 h\u2082,\n        { refine ctx.mem_max_of_prf wm _,\n          exact prf.mp prf.pl1 (prf.ax h\u2081) },\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\u2081 hp\u2082,\n          { exfalso, apply ff_eq_tt_eq_false,\n            transitivity, \n            { exact h.symm },\n            { exact (hp _ wm).2 hp\u2081} },\n          { apply prf.ax hp\u2082 } } } },\n      { intro h,\n        cases mem_domain_max wm q with h\u2081 h\u2082,\n        { left, exact (hq _ wm).2 h\u2081 },\n        { cases mem_domain_max wm p with hp\u2081 hp\u2082,\n          { exfalso, apply mem_domain_consist wm,\n            exact prf.mp (prf.ax h\u2082) (prf.mp (prf.ax h) (prf.ax hp\u2081)) },\n          { right, apply eq_ff_of_not_eq_tt,\n            intro ptt, apply mem_domain_consist wm,\n            exact prf.mp (prf.ax hp\u2082) (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 (\u25fbp) with h\u2081 h\u2082,\n      { exact h\u2081 },\n        exfalso, apply ctx.is_consist_max (consist_unbox_of_not_box_mem wm h\u2082),\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\u2082))).1,\n          apply h, apply mem_domain (consist_unbox_of_not_box_mem wm h\u2082), 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 (\u0393 : ctx \u03c3) (wm : \u0393 \u2208 domain \u03c3) : \n  (\u0393 \u22a9\u2983model\u2984 \u0393) = tt :=\nmem_tt_to_ctx_tt \u0393 (\u03bb p pm, (form_tt_iff_mem_wrld _ wm).2 pm)\n\n/- the completeness lemma -/\n\ntheorem completeness {\u0393 : ctx \u03c3} {p : form \u03c3} : \n  (\u0393 \u22a8\u209b\u2085 p) \u2192 (\u0393 \u22a2\u209b\u2085 p) :=\nbegin\n  apply (@not_imp_not (\u0393 \u22a2\u209b\u2085 p) (\u0393 \u22a8\u209b\u2085 p) (prop_decidable _)).1,\n  intros nhp hp, cases hp,\n  have c : is_consist (\u0393 \u2e34 ~p) := consist_not_of_not_prf nhp,\n  apply absurd,\n  fapply hp,\n    { exact model },\n    { exact ctx.max (\u0393 \u2e34 ~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 (\u0393 \u2e34 ~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 (\u0393 \u2e34 ~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 \u2192 bool2 \u2192 bool2\n| ff2 P := ff2\n| tt2 P := P\n\ndefinition or2 : bool2 \u2192 bool2 \u2192 bool2\n| tt2 P := tt2\n| ff2 P := P\n\ndefinition not2 : bool2 \u2192 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 \u2192 bool\n| ff2 := tt\n| tt2 := ff\n\nend bool2\n\nopen bool2\n\ndefinition bool.to2 : bool \u2192 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 \u2243 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 \u2192 bool \u2192 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 \u2228 b = tt := bool.dichotomy b\n\n-- I can'y do this -- ask Chris?\nexample : \u2200 f : bool \u2192 bool \u2192 bool, \n  (\u2200 x y : bool, f x y = f y x) \u2192 \n  (f = bor \u2228 f = band \u2228 f = bxor \u2228 f = \u03bb x y, bnot (band x y) \n  \u2228 f = \u03bb x y, bnot (bor x y) \u2228 f = \u03bb x y, bnot (bxor x y) \u2228 f = \u03bb x y, tt \u2228 f = \u03bb 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 (\u03a9 : Type) (X Y : set \u03a9)\n\nexample : \u00ac (\u2203 a, X a) \u2194 \u2200 b, \u00ac (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 : \u00ac (\u2200 a, X a) \u2194 \u2203 b, \u00ac (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 : \u00ac (\u2203 a, X a) \u2194 \u2200 b, \u00ac (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": "import Days\nimport Days.Common\nimport Std\nimport Lean.Data.Parsec\n\nnamespace Days.Day04\nopen Days\nopen Common\nopen Std (RBSet)\n\n/--\n\nSpace needs to be cleared before the last supplies can be unloaded from the ships, and so several Elves have been assigned the job of cleaning up sections of the camp. Every section has a unique ID number, and each Elf is assigned a range of section IDs.\n\nHowever, as some of the Elves compare their section assignments with each other, they've noticed that many of the assignments overlap. To try to quickly find overlaps and reduce duplicated effort, the Elves pair up and make a big list of the section assignments for each pair (your puzzle input).\n\nFor example, consider the following list of section assignment pairs:\n\n2-4,6-8\n2-3,4-5\n5-7,7-9\n2-8,3-7\n6-6,4-6\n2-6,4-8\nFor the first few pairs, this list means:\n\nWithin the first pair of Elves, the first Elf was assigned sections 2-4 (sections 2, 3, and 4), while the second Elf was assigned sections 6-8 (sections 6, 7, 8).\nThe Elves in the second pair were each assigned two sections.\nThe Elves in the third pair were each assigned three sections: one got sections 5, 6, and 7, while the other also got 7, plus 8 and 9.\nThis example list uses single-digit section IDs to make it easier to draw; your actual list might contain larger numbers. Visually, these pairs of section assignments look like this:\n\n.234.....  2-4\n.....678.  6-8\n\n.23......  2-3\n...45....  4-5\n\n....567..  5-7\n......789  7-9\n\n.2345678.  2-8\n..34567..  3-7\n\n.....6...  6-6\n...456...  4-6\n\n.23456...  2-6\n...45678.  4-8\nSome of the pairs have noticed that one of their assignments fully contains the other. For example, 2-8 fully contains 3-7, and 6-6 is fully contained by 4-6. In pairs where one assignment fully contains the other, one Elf in the pair would be exclusively cleaning sections their partner will already be cleaning, so these seem like the most in need of reconsideration. In this example, there are 2 such pairs.\n\nIn how many assignment pairs does one range fully contain the other?\n-/\nstructure ElfSection where\n  start: Nat\n  stop: Nat\n\ndef ElfSection.contains (self: ElfSection) (other: Nat) : Bool :=\n  if self.start \u2264 other \u2227 self.stop \u2265 other\n  then true\n  else false\n\ndef ElfSection.fullyContains (self other: ElfSection) : Bool :=\n  if self.contains other.start \u2227 self.contains other.stop \n  then true\n  else false\n\ndef ElfSection.eitherFullyOverlaps (self other: ElfSection) : Bool :=\n  self.fullyContains other \u2228 other.fullyContains self\n\ndef allElfPairs (input: Input) : List $ ElfSection \u00d7 ElfSection := \n  input.lines\n  |>.map (\u03bb line => \n    match line.splitOn \",\" with \n    | [fst, snd] => \n      let parsePair (sec: Input) : Option ElfSection := \n        match sec.text.splitOn \"-\" |>.map String.toNat! with\n        | [start, stop] => some \u27e8 start, stop \u27e9\n        | _ => none\n\n      do \n      let fst \u2190 parsePair fst\n      let snd \u2190 parsePair snd\n      return (fst, snd)\n    | _ => none\n  )\n  |>.filterMap id\n\ndef part\u2081 (input: Input) : Nat := \n  totalOverlaps\n  where\n    fullyOverlaps := Function.uncurry (ElfSection.eitherFullyOverlaps \u00b7 \u00b7)\n    totalOverlaps := \n      allElfPairs input\n      |>.filter fullyOverlaps\n      |>.length\n\n/--\nIt seems like there is still quite a bit of duplicate work planned. Instead, the Elves would like to know the number of pairs that overlap at all.\n\nIn the above example, the first two pairs (2-4,6-8 and 2-3,4-5) don't overlap, while the remaining four pairs (5-7,7-9, 2-8,3-7, 6-6,4-6, and 2-6,4-8) do overlap:\n\n5-7,7-9 overlaps in a single section, 7.\n2-8,3-7 overlaps all of the sections 3 through 7.\n6-6,4-6 overlaps in a single section, 6.\n2-6,4-8 overlaps in sections 4, 5, and 6.\nSo, in this example, the number of overlapping assignment pairs is 4.\n\nIn how many assignment pairs do the ranges overlap?\n-/\ndef ElfSection.anyOverlap (self other: ElfSection) : Bool :=\n  if self.contains other.start \u2228 self.contains other.stop\n  then true\n  else false\n\ndef ElfSection.eitherOverlaps (self other: ElfSection) : Bool :=\n  self.anyOverlap other \u2228 other.anyOverlap self \n\ndef part\u2082 (input: Input) : Nat :=\n   totalOverlaps\n  where\n    anyOverlaps := Function.uncurry (ElfSection.eitherOverlaps \u00b7 \u00b7)\n    totalOverlaps := \n      allElfPairs input\n      |>.filter anyOverlaps\n      |>.length\n\ndef solution : Problem Nat := \u27e8 4, part\u2081, part\u2082 \u27e9 \n\ndef sample := \"2-4,6-8\n2-3,4-5\n5-7,7-9\n2-8,3-7\n6-6,4-6\n2-6,4-8\"\n\n#eval testPart\u2081 solution sample (expect:=2)\n#eval testPart\u2082 solution sample (expect:=4)\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/Day04.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7371581626286834, "lm_q2_score": 0.6757646010190476, "lm_q1q2_score": 0.4981453916567064}}
{"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 \u2192+* 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 \u2192+* 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 \u2192+* A) (x : A) :=\n\u2203 p : R[X], monic p \u2227 eval\u2082 f x p = 0\n\n/-- A ring homomorphism `f : R \u2192+* 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 \u2192+* A) :=\n\u2200 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\u27e8X - C x, monic_X_sub_C _, by simp\u27e9\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] \u2192\u2097[R] A) := (aeval x).to_linear_map,\n  let D : \u2115 \u2192 submodule R A := \u03bb n, (degree_le R n).map leval,\n  let M := well_founded.min (is_noetherian_iff_well_founded.1 H)\n    (set.range D) \u27e8_, \u27e80, rfl\u27e9\u27e9,\n  have HM : M \u2208 set.range D := well_founded.min_mem _ _ _,\n  cases HM with N HN,\n  have HM : \u00acM < D (N+1) := well_founded.not_lt_min\n    (is_noetherian_iff_well_founded.1 H) (set.range D) _ \u27e8N+1, rfl\u27e9,\n  rw \u2190 HN at HM,\n  have HN2 : D (N+1) \u2264 D N := classical.by_contradiction (\u03bb 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)) \u2208 D N,\n  { exact HN2 (mem_map_of_mem (mem_degree_le.2 (degree_X_pow_le _))) },\n  rcases HN3 with \u27e8p, hdp, hpe\u27e9,\n  refine \u27e8X^(N+1) - p, monic_X_pow_sub (mem_degree_le.1 hdp), _\u27e9,\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 \u2208 S) :\n  is_integral R x :=\nbegin\n  suffices : is_integral R (show S, from \u27e8x, hx\u27e9),\n  { rcases this with \u27e8p, hpm, hpx\u27e9,\n    replace hpx := congr_arg S.val hpx,\n    refine \u27e8p, hpm, eq.trans _ hpx\u27e9,\n    simp only [aeval_def, eval\u2082, sum_def],\n    rw S.val.map_sum,\n    refine finset.sum_congr rfl (\u03bb 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 \u27e8x, hx\u27e9\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 \u2192+* 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 \u27e8P, hP\u27e9 := hb,\n  refine \u27e8P, hP.1, _\u27e9,\n  rw [\u2190 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] (\u03c6 : R \u2192+* T) (\u03c8 : S \u2192+* U)\n  (h : (algebra_map T U).comp \u03c6 = \u03c8.comp (algebra_map R S)) {a : S} (ha : is_integral R a) :\n  is_integral T (\u03c8 a) :=\nbegin\n  rw [is_integral, ring_hom.is_integral_elem] at \u22a2 ha,\n  obtain \u27e8p, hp\u27e9 := ha,\n  refine \u27e8p.map \u03c6, hp.left.map _, _\u27e9,\n  rw [\u2190 eval_map, map_map, h, \u2190 map_map, eval_map, eval\u2082_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 \u2192\u2090[R] B) (hf : function.injective f) {x : A} : is_integral R (f x) \u2194 is_integral R x :=\nbegin\n  refine \u27e8_, map_is_integral f\u27e9,\n  rintros \u27e8p, hp, hx\u27e9,\n  use [p, hp],\n  rwa [\u2190 f.comp_algebra_map, \u2190 alg_hom.coe_to_ring_hom, \u2190 polynomial.hom_eval\u2082,\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 \u2243\u2090[R] B) {x : A} : is_integral R (f x) \u2194 is_integral R x :=\n\u27e8\u03bb h, by simpa using map_is_integral f.symm.to_alg_hom h, map_is_integral f.to_alg_hom\u27e9\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 \u27e8p, hp, hpx\u27e9 := hx in\n\u27e8p.map $ algebra_map R A, hp.map _,\n  by rw [\u2190 aeval_def, aeval_map_algebra_map, aeval_def, hpx]\u27e9\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 \u2124 b) :\n  is_integral \u2124 (f b) :=\nmap_is_integral (f : B \u2192+* 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 \u27e8f, hf, hx\u27e9,\n  use [f, hf],\n  rw [is_scalar_tower.algebra_map_eq R A B, \u2190 hom_eval\u2082, 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) \u2194 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 \u2194 \u2203 s : set R, s.finite \u2227 is_integral (subring.closure s) r :=\nbegin\n  split; intro hr,\n  { rcases hr with \u27e8p, hmp, hpr\u27e9,\n    refine \u27e8_, finset.finite_to_set _, p.restriction, monic_restriction.2 hmp, _\u27e9,\n    rw [\u2190 aeval_def, \u2190 aeval_map_algebra_map R r p.restriction,\n      map_restriction, aeval_def, hpr], },\n  rcases hr with \u27e8s, hs, hsr\u27e9,\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 \u27e8f, hfm, hfx\u27e9,\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 \u27e8k, hk, rfl\u27e9, clear hk,\n    exact (algebra.adjoin R {x}).pow_mem (algebra.subset_adjoin (set.mem_singleton _)) k },\n  intros r hr, change r \u2208 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 \u27e8p, rfl\u27e9,\n  rw \u2190 mod_by_monic_add_div p hfm,\n  rw \u2190 aeval_def at hfx,\n  rw [alg_hom.map_add, alg_hom.map_mul, hfx, zero_mul, add_zero],\n  have : degree (p %\u2098 f) \u2264 degree f := degree_mod_by_monic_le p hfm,\n  generalize_hyp : p %\u2098 f = q at this \u22a2,\n  rw [\u2190 sum_C_mul_X_pow_eq q, aeval_def, eval\u2082_sum, sum_def],\n  refine sum_mem (\u03bb k hkq, _),\n  rw [eval\u2082_mul, eval\u2082_C, eval\u2082_pow, eval\u2082_X, \u2190 algebra.smul_def],\n  refine smul_mem _ _ (subset_span _),\n  rw finset.mem_coe, refine finset.mem_image.2 \u27e8_, _, rfl\u27e9,\n  rw [finset.mem_range, nat.lt_succ_iff], refine le_of_not_lt (\u03bb 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 : \u2200 x \u2208 s, is_integral R x) : (algebra.adjoin R s).to_submodule.fg :=\nset.finite.induction_on hfs (\u03bb _, \u27e8{1}, submodule.ext $ \u03bb x,\n  by { erw [algebra.adjoin_empty, finset.coe_singleton, \u2190 one_eq_span, one_eq_range,\n            linear_map.mem_range, algebra.mem_bot], refl }\u27e9)\n(\u03bb a s has hs ih his, by rw [\u2190 set.union_singleton, algebra.adjoin_union_coe_submodule]; exact\n  fg.mul (ih $ \u03bb 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 : \u2200 x \u2208 s, is_integral R x) :\n  is_noetherian R (algebra.adjoin R (\u2191s : 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 \u2208 S) : is_integral R x :=\nbegin\n  -- say `x \u2208 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 `\u2211 r\u1d62 y\u1d62` for `y\u1d62 \u2208 Y`.\n  obtain \u27e8lx, hlx1, hlx2\u27e9 :\n    \u2203 (l : A \u2192\u2080 R) (H : l \u2208 finsupp.supported R R \u2191y), (finsupp.total A A R id) l = x,\n  { rwa [\u2190(@finsupp.mem_span_image_iff_total A A R _ _ _ id \u2191y x), set.image_id \u2191y, hy] },\n  -- Note that `y \u2286 S`.\n  have hyS : \u2200 {p}, p \u2208 y \u2192 p \u2208 S := \u03bb p hp, show p \u2208 S.to_submodule,\n    by { rw \u2190 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 : \u2200 (jk : (\u2191(y \u00d7\u02e2 y) : set (A \u00d7 A))), jk.1.1 * jk.1.2 \u2208 S.to_submodule :=\n    \u03bb jk, S.mul_mem (hyS (finset.mem_product.1 jk.2).1) (hyS (finset.mem_product.1 jk.2).2),\n  rw [\u2190 hy, \u2190 set.image_id \u2191y] at this, simp only [finsupp.mem_span_image_iff_total] at this,\n  -- Say `y\u1d62y\u2c7c = \u2211r\u1d62\u2c7c\u2096 y\u2096`\n  choose ly hly1 hly2,\n  -- Now let `S\u2080` be the subring of `R` generated by the `r\u1d62` and the `r\u1d62\u2c7c\u2096`.\n  let S\u2080 : subring R :=\n    subring.closure \u2191(lx.frange \u222a finset.bUnion finset.univ (finsupp.frange \u2218 ly)),\n  -- It suffices to prove that `x` is integral over `S\u2080`.\n  refine is_integral_of_subring S\u2080 _,\n  letI : comm_ring S\u2080 := subring_class.to_comm_ring S\u2080,\n  letI : algebra S\u2080 A := algebra.of_subring S\u2080,\n  -- Claim: the `S\u2080`-module span (in `A`) of the set `y \u222a {1}` is closed under\n  -- multiplication (indeed, this is the motivation for the definition of `S\u2080`).\n  have :\n    span S\u2080 (insert 1 \u2191y : set A) * span S\u2080 (insert 1 \u2191y : set A) \u2264 span S\u2080 (insert 1 \u2191y : set A),\n  { rw span_mul_span, refine span_le.2 (\u03bb z hz, _),\n    rcases set.mem_mul.1 hz with \u27e8p, q, rfl | hp, hq, rfl\u27e9,\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 \u2190 hly2 \u27e8(p, q), finset.mem_product.2 \u27e8hp, hq\u27e9\u27e9,\n    rw [finsupp.total_apply, finsupp.sum],\n    refine (span S\u2080 (insert 1 \u2191y : set A)).sum_mem (\u03bb t ht, _),\n    have : ly \u27e8(p, q), finset.mem_product.2 \u27e8hp, hq\u27e9\u27e9 t \u2208 S\u2080 :=\n    subring.subset_closure (finset.mem_union_right _ $ finset.mem_bUnion.2\n      \u27e8\u27e8(p, q), finset.mem_product.2 \u27e8hp, hq\u27e9\u27e9, finset.mem_univ _,\n        finsupp.mem_frange.2 \u27e8finsupp.mem_support_iff.1 ht, _, rfl\u27e9\u27e9),\n    change (\u27e8_, this\u27e9 : S\u2080) \u2022 t \u2208 _, exact smul_mem _ _ (subset_span $ or.inr $ hly1 _ ht) },\n  -- Hence this span is a subring. Call this subring `S\u2081`.\n  let S\u2081 : subring A :=\n  { carrier := span S\u2080 (insert 1 \u2191y : set A),\n    one_mem' := subset_span $ or.inl rfl,\n    mul_mem' := \u03bb p q hp hq, this $ mul_mem_mul hp hq,\n    zero_mem' := (span S\u2080 (insert 1 \u2191y : set A)).zero_mem,\n    add_mem' := \u03bb _ _, (span S\u2080 (insert 1 \u2191y : set A)).add_mem,\n    neg_mem' := \u03bb _, (span S\u2080 (insert 1 \u2191y : set A)).neg_mem },\n  have : S\u2081 = subalgebra.to_subring (algebra.adjoin S\u2080 (\u2191y : set A)),\n  { ext z,\n    suffices : z \u2208 span \u21a5S\u2080 (insert 1 \u2191y : set A) \u2194\n      z \u2208 (algebra.adjoin \u21a5S\u2080 (y : set A)).to_submodule,\n    { simpa },\n    split; intro hz,\n    { exact (span_le.2\n        (set.insert_subset.2 \u27e8(algebra.adjoin S\u2080 \u2191y).one_mem, algebra.subset_adjoin\u27e9)) hz },\n    { rw [subalgebra.mem_to_submodule, algebra.mem_adjoin_iff] at hz,\n      suffices : subring.closure (set.range \u21d1(algebra_map \u21a5S\u2080 A) \u222a \u2191y) \u2264 S\u2081,\n      { exact this hz },\n      refine subring.closure_le.2 (set.union_subset _ (\u03bb 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 : \u2200 z, z \u2208 S\u2081 \u2194 z \u2208 algebra.adjoin \u21a5S\u2080 (y : set A),\n    simp [this],\n  haveI : is_noetherian_ring \u21a5S\u2080 := is_noetherian_subring_closure _ (finset.finite_to_set _),\n  refine is_integral_of_submodule_noetherian (algebra.adjoin S\u2080 \u2191y)\n    (is_noetherian_of_fg_of_noetherian _ \u27e8insert 1 y,\n      by { rw [finset.coe_insert], ext z, simp [S\u2081], convert foo z}\u27e9) _ _,\n  rw [\u2190 hlx2, finsupp.total_apply, finsupp.sum], refine subalgebra.sum_mem _ (\u03bb r hr, _),\n  have : lx r \u2208 S\u2080 :=\n    subring.subset_closure (finset.mem_union_left _ (finset.mem_image_of_mem _ hr)),\n  change (\u27e8_, this\u27e9 : S\u2080) \u2022 r \u2208 _,\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 \u2022 m \u2260 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 \u2260 \u22a5) (hN' : N.fg) (x : A)\n    (hx : \u2200 n \u2208 N, x \u2022 n \u2208 N) : is_integral R x :=\nbegin\n  let A' : subalgebra R A :=\n  { carrier := { x | \u2200 n \u2208 N, x \u2022 n \u2208 N },\n    mul_mem' := \u03bb a b ha hb n hn, smul_smul a b n \u25b8 ha _ (hb _ hn),\n    one_mem' := \u03bb n hn, (one_smul A n).symm \u25b8 hn,\n    add_mem' := \u03bb a b ha hb n hn, (add_smul a b n).symm \u25b8 N.add_mem (ha _ hn) (hb _ hn),\n    zero_mem' := \u03bb n hn, (zero_smul A n).symm \u25b8 N.zero_mem,\n    algebra_map_mem' := \u03bb r n hn, (algebra_map_smul A r n).symm \u25b8 N.smul_mem r hn },\n  let f : A' \u2192\u2090[R] module.End R N := alg_hom.of_linear_map\n    { to_fun := \u03bb x, (distrib_mul_action.to_linear_map R M x).restrict x.prop,\n      map_add' := \u03bb x y, linear_map.ext $ \u03bb n, subtype.ext $ add_smul x y n,\n      map_smul' := \u03bb r s, linear_map.ext $ \u03bb n, subtype.ext $ smul_assoc r s n }\n      (linear_map.ext $ \u03bb n, subtype.ext $ one_smul _ _)\n      (\u03bb x y, linear_map.ext $ \u03bb n, subtype.ext $ mul_smul x y n),\n  obtain \u27e8a, ha\u2081, ha\u2082\u27e9 : \u2203 a \u2208 N, a \u2260 (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 [\u2190 linear_map.ker_eq_bot, eq_bot_iff],\n    intros s hs,\n    have : s.1 \u2022 a = 0 := congr_arg subtype.val (linear_map.congr_fun hs \u27e8a, ha\u2081\u27e9),\n    exact subtype.ext ((eq_zero_or_eq_zero_of_smul_eq_zero this).resolve_right ha\u2082) },\n  show is_integral R (A'.val \u27e8x, hx\u27e9),\n  rw [is_integral_alg_hom_iff A'.val subtype.val_injective,\n    \u2190 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 \u03bb x, is_integral_of_mem_of_fg \u22a4 h.1 _ trivial }\n\nalias ring_hom.finite.to_is_integral \u2190 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 \u27e8s, hs\u27e9 := h' },\n  constructor,\n  change (\u22a4 : subalgebra R S).to_submodule.fg,\n  rw \u2190 hs,\n  exact fg_adjoin_of_finite (set.to_finite _) (\u03bb x _, h x)\nend\n\nalias ring_hom.is_integral.to_finite \u2190 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 \u2194 f.is_integral \u2227 f.finite_type :=\n\u27e8\u03bb h, \u27e8h.to_is_integral, h.to_finite_type\u27e9, \u03bb \u27e8h, h'\u27e9, h.to_finite h'\u27e9\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 \u2194 algebra.is_integral R A \u2227 algebra.finite_type R A :=\n\u27e8\u03bb h, by exactI \u27e8algebra.is_integral.of_finite, infer_instance\u27e9, \u03bb \u27e8h, h'\u27e9, by exactI h.finite\u27e9\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 \u2208 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 [\u2190 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 \u2208 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 \u25b8 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 \u25b8 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 \u2022 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 : \u2115} (hn : 0 < n) (hx : is_integral R $ x ^ n) :\n  is_integral R x :=\nbegin\n  rcases hx with \u27e8p, \u27e8hmonic, heval\u27e9\u27e9,\n  exact \u27e8expand R n p, monic.expand hn hmonic,\n         by rwa [eval\u2082_eq_eval_map, map_expand, expand_eval, \u2190 eval\u2082_eq_eval_map]\u27e9\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' := \u03bb _ _, is_integral_add,\n  mul_mem' := \u03bb _ _, is_integral_mul,\n  algebra_map_mem' := \u03bb x, is_integral_algebra_map }\n\ntheorem mem_integral_closure_iff_mem_fg {r : A} :\n  r \u2208 integral_closure R A \u2194 \u2203 M : subalgebra R A, M.to_submodule.fg \u2227 r \u2208 M :=\n\u27e8\u03bb hr, \u27e8algebra.adjoin R {r}, fg_adjoin_singleton_of_integral _ hr, algebra.subset_adjoin rfl\u27e9,\n\u03bb \u27e8M, Hf, hrM\u27e9, is_integral_of_mem_of_fg M Hf _ hrM\u27e9\n\nvariables {R} {A}\n\nlemma adjoin_le_integral_closure {x : A} (hx : is_integral R x) :\n  algebra.adjoin R {x} \u2264 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 \u2264 integral_closure R A \u2194 algebra.is_integral R S :=\nset_like.forall.symm.trans (forall_congr (\u03bb x, show is_integral R (algebra_map S A x)\n  \u2194 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 \u21a5(S \u2294 T) \u2194 algebra.is_integral R S \u2227 algebra.is_integral R T :=\nby simp only [\u2190le_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 \u2243\u2090[R] B) :\n  (integral_closure R A).map (f : A \u2192\u2090[R] B) = integral_closure R B :=\nbegin\n  ext y,\n  rw subalgebra.mem_map,\n  split,\n  { rintros \u27e8x, hx, rfl\u27e9,\n    exact map_is_integral f hx },\n  { intro hy,\n    use [f.symm y, map_is_integral (f.symm : B \u2192\u2090[R] A) hy],\n    simp }\nend\n\nlemma integral_closure.is_integral (x : integral_closure R A) : is_integral R x :=\nlet \u27e8p, hpm, hpx\u27e9 := x.2 in \u27e8p, hpm, subtype.eq $\nby rwa [\u2190 aeval_def, subtype.val_eq_coe, \u2190 subalgebra.val_apply, aeval_alg_hom_apply] at hpx\u27e9\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 \u27e8p, \u27e8p_monic, hp\u27e9\u27e9 := hx,\n  refine \u27e8scale_roots p r, \u27e8(monic_scale_roots_iff r).2 p_monic, _\u27e9\u27e9,\n  convert scale_roots_eval\u2082_eq_zero f hp,\n  rw [mul_comm x y, \u2190 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 : \u2200 x \u2208 G, is_integral R x) :\n  \u2200 x \u2208 (subring.closure G), is_integral R x :=\n\u03bb x hx, subring.closure_induction hx hG is_integral_zero is_integral_one\n  (\u03bb _ _, is_integral_add) (\u03bb _, is_integral_neg) (\u03bb _ _, is_integral_mul)\n\nlemma is_integral_of_mem_closure'' {S : Type*} [comm_ring S] {f : R \u2192+* S} (G : set S)\n  (hG : \u2200 x \u2208 G, f.is_integral_elem x) : \u2200 x \u2208 (subring.closure G), f.is_integral_elem x :=\n\u03bb 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 : \u2115) : 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 : \u2115) : is_integral R (n \u2022 x) :=\n(integral_closure R A).nsmul_mem h n\n\nlemma is_integral.zsmul {x : A} (h : is_integral R x) (n : \u2124) : is_integral R (n \u2022 x) :=\n(integral_closure R A).zsmul_mem h n\n\nlemma is_integral.multiset_prod {s : multiset A} (h : \u2200 x \u2208 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 : \u2200 x \u2208 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 {\u03b1 : Type*} {s : finset \u03b1} (f : \u03b1 \u2192 A) (h : \u2200 x \u2208 s, is_integral R (f x)) :\n  is_integral R (\u220f x in s, f x) :=\n(integral_closure R A).prod_mem h\n\nlemma is_integral.sum {\u03b1 : Type*} {s : finset \u03b1} (f : \u03b1 \u2192 A) (h : \u2200 x \u2208 s, is_integral R (f x)) :\n  is_integral R (\u2211 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 : \u2200 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 _ (\u03bb \u03c3 h\u03c3, is_integral.zsmul (is_integral.prod _ (\u03bb i hi, h _ _)) _)\nend\n\n@[simp] lemma is_integral.pow_iff {x : A} {n : \u2115} (hn : 0 < n) :\n  is_integral R (x ^ n) \u2194 is_integral R x :=\n\u27e8is_integral_of_pow hn, \u03bb hx, is_integral.pow hx n\u27e9\n\nopen_locale tensor_product\n\nlemma is_integral.tmul (x : A) {y : B} (h : is_integral R y) : is_integral A (x \u2297\u209c[R] y) :=\nbegin\n  obtain \u27e8p, hp, hp'\u27e9 := h,\n  refine \u27e8(p.map (algebra_map R A)).scale_roots x, _, _\u27e9,\n  { rw polynomial.monic_scale_roots_iff, exact hp.map _ },\n  convert @polynomial.scale_roots_eval\u2082_mul (A \u2297[R] B) A _ _ _\n    algebra.tensor_product.include_left.to_ring_hom (1 \u2297\u209c 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\u2082_map, algebra.tensor_product.include_left_comp_algebra_map,\n    \u2190 polynomial.eval\u2082_map],\n  convert polynomial.eval\u2082_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\u2211 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 : \u2115) (hp : 1 \u2264 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\u2081 h\u2082,\n  { simp [h\u2081], },\n  { rw [h\u2082, leading_coeff, \u2190 pow_succ, tsub_add_cancel_of_le hp], },\n  { rw [mul_assoc, \u2190 pow_add, tsub_add_cancel_of_le],\n    apply nat.le_pred_of_lt,\n    rw lt_iff_le_and_ne,\n    exact \u27e8le_nat_degree_of_ne_zero h\u2081, h\u2082\u27e9, },\nend\n\nlemma leading_coeff_smul_normalize_scale_roots (p : R[X]) :\n  p.leading_coeff \u2022 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\u2081 h\u2082,\n  { simp [*] },\n  { simp [*] },\n  { rw [algebra.id.smul_eq_mul, mul_comm, mul_assoc, \u2190 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\u2081) h\u2082) },\nend\n\nlemma normalize_scale_roots_support :\n  (normalize_scale_roots p).support \u2264 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\u2081 h\u2082,\n  exact (h\u2082 h\u2081).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 [\u2190 degree_scale_roots, \u2190 leading_coeff_smul_normalize_scale_roots],\n    exact degree_smul_le _ _ }\nend\n\nlemma normalize_scale_roots_eval\u2082_leading_coeff_mul (h : 1 \u2264 p.nat_degree) (f : R \u2192+* S) (x : S) :\n  (normalize_scale_roots p).eval\u2082 f (f p.leading_coeff * x) =\n    f p.leading_coeff ^ (p.nat_degree - 1) * (p.eval\u2082 f x) :=\nbegin\n  rw [eval\u2082_eq_sum_range, eval\u2082_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, \u2190 mul_assoc, \u2190 f.map_pow, \u2190 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 \u2260 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 \u2192 (0 : R) = 1,\n  { simpa [normalize_scale_roots, coeff_monomial] },\n  exact \u03bb h', (h h').rec _,\nend\n\n/-- Given a `p : R[X]` and a `x : S` such that `p.eval\u2082 f x = 0`,\n`f p.leading_coeff * x` is integral. -/\nlemma ring_hom.is_integral_elem_leading_coeff_mul (h : p.eval\u2082 f x = 0) :\n  f.is_integral_elem (f p.leading_coeff * x) :=\nbegin\n  by_cases h' : 1 \u2264 p.nat_degree,\n  { use normalize_scale_roots p,\n    have : p \u2260 0 := \u03bb 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\u2082_leading_coeff_mul p h' f x, h, mul_zero] },\n  { by_cases hp : p.map f = 0,\n    { apply_fun (\u03bb 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\u2082_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 \u2022 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 \u2022 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 : \u2200 {x : B}, is_integral R x \u2194 \u2203 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\u27e8subtype.coe_injective, \u03bb x, \u27e8\u03bb h, \u27e8\u27e8x, h\u27e9, rfl\u27e9, by { rintro \u27e8\u27e8_, h\u27e9, rfl\u27e9, exact h }\u27e9\u27e9\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 \u27e8x, rfl\u27e9\n\ntheorem is_integral_algebra [algebra R A] [is_scalar_tower R A B] :\n  algebra.is_integral R A :=\n\u03bb 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 _) (\u03bb _ _, _),\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', \u2190 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 \u2192\u2090[R] A :=\n{ to_fun := \u03bb 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' := \u03bb x y, by simp_rw [\u2190 mk'_add, ring_hom.map_add],\n  map_mul' := \u03bb x y, by simp_rw [\u2190 mk'_mul, ring_hom.map_mul],\n  commutes' := \u03bb x, by simp_rw [\u2190 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 \u2243\u2090[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 \u2192+* S) (g : S \u2192+* 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 (\u2191(p.map $ algebra_map A B).frange : set B)) x :=\nbegin\n  generalize hS : (\u2191(p.map $ algebra_map A B).frange : set B) = S,\n  have coeffs_mem : \u2200 i, (p.map $ algebra_map A B).coeff i \u2208 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 \u2190 hS,\n    exact subset_adjoin (coeff_mem_frange _ _ hi) },\n  obtain \u27e8q, hq\u27e9 : \u2203 q : (adjoin R S)[X], q.map (algebra_map (adjoin R S) B) =\n      (p.map $ algebra_map A B),\n  { rw \u2190 set.mem_range, exact (polynomial.mem_map_range _).2 (\u03bb i, \u27e8\u27e8_, coeffs_mem i\u27e9, rfl\u27e9) },\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 \u27e8p, pmonic, hp\u27e9,\n  let S : set B := \u2191(p.map $ algebra_map A B).frange,\n  refine is_integral_of_mem_of_fg (adjoin R (S \u222a {x})) _ _ (subset_adjoin $ or.inr rfl),\n  refine fg_trans (fg_adjoin_of_finite (finset.finite_to_set _) (\u03bb x hx, _)) _,\n  { rw [finset.mem_coe, frange, finset.mem_image] at hx,\n    rcases hx with \u27e8i, _, rfl\u27e9,\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\u03bb 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\u03bb x, (hf x).rec_on (\u03bb y hy, (hy \u25b8 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 \u2192 A \u2192 B` is an algebra tower with `A \u2192 B` injective,\nthen if the entire tower is an integral extension so is `R \u2192 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 \u27e8p, \u27e8hp, hp'\u27e9\u27e9,\n  refine \u27e8p, \u27e8hp, _\u27e9\u27e9,\n  rw [is_scalar_tower.algebra_map_eq R A B, \u2190 eval\u2082_map,\n      eval\u2082_hom, \u2190 ring_hom.map_zero (algebra_map A B)] at hp',\n  rw [eval\u2082_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\u03bb 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 \u27e8p, \u27e8hp, hp'\u27e9\u27e9 := h in \u27e8p.map f, hp.map f, by rwa \u2190 eval\u2082_map at hp'\u27e9\n\nlemma ring_hom.is_integral_tower_top_of_is_integral (h : (g.comp f).is_integral) : g.is_integral :=\n\u03bb x, ring_hom.is_integral_elem_of_is_integral_elem_comp f g (h x)\n\n/-- If `R \u2192 A \u2192 B` is an algebra tower,\nthen if the entire tower is an integral extension so is `A \u2192 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 \u27e8p, \u27e8hp, hp'\u27e9\u27e9,\n  refine \u27e8p.map (algebra_map R A), \u27e8hp.map (algebra_map R A), _\u27e9\u27e9,\n  rw [is_scalar_tower.algebra_map_eq R A B, \u2190 eval\u2082_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 \u27e8x\u27e9,\n  obtain \u27e8p, \u27e8p_monic, hpx\u27e9\u27e9 := hf x,\n  refine \u27e8p.map (ideal.quotient.mk _), \u27e8p_monic.map _, _\u27e9\u27e9,\n  simpa only [hom_eval\u2082, eval\u2082_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 \u29f8 I.comap (algebra_map R A)) (A \u29f8 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 \u2194\n    ((ideal.quotient.mk I).comp f : R \u2192+* S \u29f8 I).is_integral :=\nbegin\n  let g := ideal.quotient.mk (I.comap f),\n  have := ideal.quotient_map_comp_mk le_rfl,\n  refine \u27e8\u03bb h, _, \u03bb h, ring_hom.is_integral_tower_top_of_is_integral g _ (this \u25b8 h)\u27e9,\n  refine this \u25b8 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 \u2192 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 \u27e8\u27e80, 1, zero_ne_one\u27e9, mul_comm, \u03bb a ha, _\u27e9,\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 \u27e8a_inv, ha_inv\u27e9 := hS.mul_inv_cancel (\u03bb 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 \u27e8p, p_monic, hp\u27e9 := H a_inv,\n  use -\u2211 (i : \u2115) 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 : \u2211 (i : \u2115) 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 \u2260 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\u2082_eq_sum_range] at hp,\n    rw [ring_hom.map_sum, finset.sum_mul],\n    refine (finset.sum_congr rfl (\u03bb 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 [\u2190 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, \u2190 mul_assoc, \u2190 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 (\u03bb i hi, _),\n  have : 1 \u2264 p.nat_degree - i := le_tsub_of_add_le_left (finset.mem_range.mp hi),\n  rw [mul_assoc, \u2190 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 \u27e8\u27e80, 1, zero_ne_one\u27e9, mul_comm, \u03bb x hx, _\u27e9,\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 \u27e8y, hy\u27e9 := linear_map.surjective_of_injective (@linear_map.mul_left_injective R A _ _ _ _\n    \u27e8x, subset_adjoin (set.mem_singleton x)\u27e9 (\u03bb h, hx (subtype.ext_iff.mp h))) 1,\n  exact \u27e8y, subtype.ext_iff.mp hy\u27e9,\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 \u2194 is_field S :=\n\u27e8is_field_of_is_integral_of_is_field' H, is_field_of_is_integral_of_is_field H hRS\u27e9\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 = \u22a5 :=\neq_bot_iff.2 $ \u03bb x hx, algebra.mem_bot.2\n\u27e8\u27e8x, @is_integral_trans _ _ _ _ _ _ _ _ (integral_closure R A).algebra\n     _ integral_closure.is_integral x hx\u27e9, rfl\u27e9\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 \u2208 (f.map $ algebra_map R S).roots) : a \u2208 integral_closure R S :=\n\u27e8f, hf, (eval\u2082_eq_eval_map _).trans $ (mem_roots $ (hf.map _).ne_zero).1 ha\u27e9\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 \u2964 Module R`. We show that the colimit of `F \u22d9 forget\u2082 (Module R) AddCommGroup`\n(in `AddCommGroup`) carries the structure of an `R`-module, thereby showing that the forgetful\nfunctor `forget\u2082 (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 \u2192 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 \u2964 ModuleCat.{max v u} R)\n\n/-- The colimit of `F \u22d9 forget\u2082 (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 \u22d9 forget\u2082 (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 : (\u03a3j, F.obj j) \u2192 M :=\n  Quot.mk (Types.Quot.Rel (F \u22d9 forget (ModuleCat R)))\n#align Module.filtered_colimits.M.mk ModuleCat.FilteredColimits.m.mk\n\ntheorem m.mk_eq (x y : \u03a3j, F.obj j)\n    (h : \u2203 (k : J)(f : x.1 \u27f6 k)(g : y.1 \u27f6 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 \u22d9 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 : \u03a3j, F.obj j) : M :=\n  M.mk \u27e8x.1, r \u2022 x.2\u27e9\n#align Module.filtered_colimits.colimit_smul_aux ModuleCat.FilteredColimits.colimitSmulAux\n\ntheorem colimitSmulAux_eq_of_rel (r : R) (x y : \u03a3j, F.obj j)\n    (h : Types.FilteredColimit.Rel (F \u22d9 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 \u27e8k, f, g, hfg\u27e9 := 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 : \u03a3j, F.obj j) : r \u2022 M.mk x = M.mk \u27e8x.1, r \u2022 x.2\u27e9 :=\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 \u27e8j, x\u27e9, 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) \u27e8j, x\u27e9, colimit_smul_mk_eq F s \u27e8j, x\u27e9,\n      colimit_smul_mk_eq F r \u27e8j, _\u27e9, mul_smul]\n  smul_add r x y := by\n    apply Quot.induction_on\u2082 x y; clear x y; intro x y; cases' x with i x; cases' y with j y\n    erw [colimit_add_mk_eq _ \u27e8i, x\u27e9 \u27e8j, y\u27e9 (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 _ \u27e8i, _\u27e9 \u27e8j, _\u27e9 (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 _ \u27e8j, _\u27e9 \u27e8j, _\u27e9 j (\ud835\udfd9 j) (\ud835\udfd9 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 \u27f6 colimit :=\n  {\n    (AddCommGroupCat.FilteredColimits.colimitCocone\n            (F \u22d9 forget\u2082 (ModuleCat R) AddCommGroupCat.{max v u})).\u03b9.app\n      j with\n    map_smul' := fun r x => by erw [colimit_smul_mk_eq F r \u27e8j, x\u27e9]; 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  \u03b9 :=\n    { app := cocone_morphism\n      naturality' := fun j j' f =>\n        LinearMap.coe_injective ((Types.colimitCocone (F \u22d9 forget (ModuleCat R))).\u03b9.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 \u27f6 t.pt :=\n  {\n    (AddCommGroupCat.FilteredColimits.colimitCoconeIsColimit\n          (F \u22d9 forget\u2082 (ModuleCat R) AddCommGroupCat.{max v u})).desc\n      ((forget\u2082 (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.\u03b9.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 \u22d9 forget (ModuleCat R))).fac\n        ((forget (ModuleCat R)).mapCocone t) j\n  uniq t m h :=\n    LinearMap.coe_injective <|\n      (Types.colimitCoconeIsColimit (F \u22d9 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\u2082AddCommGroupPreservesFilteredColimits :\n    PreservesFilteredColimits (forget\u2082 (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 \u22d9 forget\u2082 (ModuleCat.{u} R) AddCommGroupCat.{u})) }\n#align Module.filtered_colimits.forget\u2082_AddCommGroup_preserves_filtered_colimits ModuleCat.FilteredColimits.forget\u2082AddCommGroupPreservesFilteredColimits\n\ninstance forgetPreservesFilteredColimits : PreservesFilteredColimits (forget (ModuleCat.{u} R)) :=\n  Limits.compPreservesFilteredColimits (forget\u2082 (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' : \u2200 (x y : P), dist x y = \u2225(x -\u1d65 y : V)\u2225)\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' : \u2200 (x y : P), dist x y = \u2225(x -\u1d65 y : V)\u2225)\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  [\u03b2 : normed_add_torsor V P] : semi_normed_add_torsor V P := { ..\u03b2 }\n\nvariables {\u03b1 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 = \u2225(x -\u1d65 y)\u2225 :=\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 +\u1d65 x) (v +\u1d65 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\u2081 v\u2082 : V) (x : P) :\n  dist (v\u2081 +\u1d65 x) (v\u2082 +\u1d65 x) = dist v\u2081 v\u2082 :=\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 +\u1d65 x) x = \u2225v\u2225 :=\nby simp [dist_eq_norm_vsub V _ x]\n\n@[simp] lemma dist_vadd_right (v : V) (x : P) : dist x (v +\u1d65 x) = \u2225v\u2225 :=\nby rw [dist_comm, dist_vadd_left]\n\n@[simp] lemma dist_vsub_cancel_left (x y z : P) : dist (x -\u1d65 y) (x -\u1d65 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 -\u1d65 z) (y -\u1d65 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 +\u1d65 p) (v' +\u1d65 p') \u2264 dist v v' + dist p p' :=\nby simpa using dist_triangle (v +\u1d65 p) (v' +\u1d65 p) (v' +\u1d65 p')\n\nlemma dist_vsub_vsub_le (p\u2081 p\u2082 p\u2083 p\u2084 : P) :\n  dist (p\u2081 -\u1d65 p\u2082) (p\u2083 -\u1d65 p\u2084) \u2264 dist p\u2081 p\u2083 + dist p\u2082 p\u2084 :=\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 +\u1d65 p) (v' +\u1d65 p') \u2264 nndist v v' + nndist p p' :=\nby simp only [\u2190 nnreal.coe_le_coe, nnreal.coe_add, \u2190 dist_nndist, dist_vadd_vadd_le]\n\nlemma nndist_vsub_vsub_le (p\u2081 p\u2082 p\u2083 p\u2084 : P) :\n  nndist (p\u2081 -\u1d65 p\u2082) (p\u2083 -\u1d65 p\u2084) \u2264 nndist p\u2081 p\u2083 + nndist p\u2082 p\u2084 :=\nby simp only [\u2190 nnreal.coe_le_coe, nnreal.coe_add, \u2190 dist_nndist, dist_vsub_vsub_le]\n\nlemma edist_vadd_vadd_le (v v' : V) (p p' : P) :\n  edist (v +\u1d65 p) (v' +\u1d65 p') \u2264 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\u2081 p\u2082 p\u2083 p\u2084 : P) :\n  edist (p\u2081 -\u1d65 p\u2082) (p\u2083 -\u1d65 p\u2084) \u2264 edist p\u2081 p\u2083 + edist p\u2082 p\u2084 :=\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 := \u03bb x y, \u2225(x -\u1d65 y : V)\u2225,\n  dist_self := \u03bb x, by simp,\n  dist_comm := \u03bb x y, by simp only [\u2190neg_vsub_eq_vsub_rev y x, norm_neg],\n  dist_triangle := begin\n    intros x y z,\n    change \u2225x -\u1d65 z\u2225 \u2264 \u2225x -\u1d65 y\u2225 + \u2225y -\u1d65 z\u2225,\n    rw \u2190vsub_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 := \u03bb x y, \u2225(x -\u1d65 y : V)\u2225,\n  dist_self := \u03bb x, by simp,\n  eq_of_dist_eq_zero := \u03bb x y h, by simpa using h,\n  dist_comm := \u03bb x y, by simp only [\u2190neg_vsub_eq_vsub_rev y x, norm_neg],\n  dist_triangle := begin\n    intros x y z,\n    change \u2225x -\u1d65 z\u2225 \u2264 \u2225x -\u1d65 y\u2225 + \u2225y -\u1d65 z\u2225,\n    rw \u2190vsub_add_vsub_cancel,\n    apply norm_add_le\n  end }\n\ninclude V\n\nnamespace isometric\n\n/-- The map `v \u21a6 v +\u1d65 p` as an isometric equivalence between `V` and `P`. -/\ndef vadd_const (p : P) : V \u2243\u1d62 P :=\n\u27e8equiv.vadd_const p, isometry_emetric_iff_metric.2 $ \u03bb x\u2081 x\u2082, dist_vadd_cancel_right x\u2081 x\u2082 p\u27e9\n\n@[simp] lemma coe_vadd_const (p : P) : \u21d1(vadd_const p) = \u03bb v, v +\u1d65 p := rfl\n\n@[simp] lemma coe_vadd_const_symm (p : P) : \u21d1(vadd_const p).symm = \u03bb p', p' -\u1d65 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' \u21a6 p -\u1d65 p'` as an equivalence. -/\ndef const_vsub (p : P) : P \u2243\u1d62 V :=\n\u27e8equiv.const_vsub p, isometry_emetric_iff_metric.2 $ \u03bb p\u2081 p\u2082, dist_vsub_cancel_left _ _ _\u27e9\n\n@[simp] lemma coe_const_vsub (p : P) : \u21d1(const_vsub p) = (-\u1d65) p := rfl\n\n@[simp] lemma coe_const_vsub_symm (p : P) : \u21d1(const_vsub p).symm = \u03bb v, -v +\u1d65 p := rfl\n\nvariables (P)\n\n/-- The map `p \u21a6 v +\u1d65 p` as an isometric automorphism of `P`. -/\ndef const_vadd (v : V) : P \u2243\u1d62 P :=\n\u27e8equiv.const_vadd P v, isometry_emetric_iff_metric.2 $ dist_vadd_cancel_left v\u27e9\n\n@[simp] lemma coe_const_vadd (v : V) : \u21d1(const_vadd P v) = (+\u1d65) 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 \u2243\u1d62 P :=\n(const_vsub x).trans (vadd_const x)\n\nlemma point_reflection_apply (x y : P) : point_reflection x y = x -\u1d65 y +\u1d65 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 \u2192 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 [\u2190 (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 = \u2225bit0 (x -\u1d65 y)\u2225 :=\nby rw [point_reflection_apply, dist_eq_norm_vsub V, vadd_vsub_assoc, bit0]\n\nlemma dist_point_reflection_self (\ud835\udd5c : Type*) [normed_field \ud835\udd5c] [semi_normed_space \ud835\udd5c V] (x y : P) :\n  dist (point_reflection x y) y = \u2225(2:\ud835\udd5c)\u2225 * dist x y :=\nby rw [dist_point_reflection_self', \u2190 two_smul' \ud835\udd5c (x -\u1d65 y), norm_smul, \u2190 dist_eq_norm_vsub V]\n\nlemma point_reflection_fixed_iff (\ud835\udd5c : Type*) [normed_field \ud835\udd5c] [semi_normed_space \ud835\udd5c V]\n  [invertible (2:\ud835\udd5c)] {x y : P} : point_reflection x y = y \u2194 y = x :=\naffine_equiv.point_reflection_fixed_iff_of_module \ud835\udd5c\n\nvariables [semi_normed_space \u211d 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 \u211d, real.norm_two], apply_instance }\n\n@[simp] lemma point_reflection_midpoint_left (x y : P) :\n  point_reflection (midpoint \u211d 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 \u211d x y) y = x :=\naffine_equiv.point_reflection_midpoint_right x y\n\nend isometric\n\nlemma lipschitz_with.vadd [pseudo_emetric_space \u03b1] {f : \u03b1 \u2192 V} {g : \u03b1 \u2192 P} {Kf Kg : \u211d\u22650}\n  (hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :\n  lipschitz_with (Kf + Kg) (f +\u1d65 g) :=\n\u03bb x y,\ncalc edist (f x +\u1d65 g x) (f y +\u1d65 g y) \u2264 edist (f x) (f y) + edist (g x) (g y) :\n  edist_vadd_vadd_le _ _ _ _\n... \u2264 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 \u03b1] {f g : \u03b1 \u2192 P} {Kf Kg : \u211d\u22650}\n  (hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :\n  lipschitz_with (Kf + Kg) (f -\u1d65 g) :=\n\u03bb x y,\ncalc edist (f x -\u1d65 g x) (f y -\u1d65 g y) \u2264 edist (f x) (f y) + edist (g x) (g y) :\n  edist_vsub_vsub_le _ _ _ _\n... \u2264 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 (\u03bb x : V \u00d7 P, x.1 +\u1d65 x.2) :=\n(lipschitz_with.prod_fst.vadd lipschitz_with.prod_snd).uniform_continuous\n\nlemma uniform_continuous_vsub : uniform_continuous (\u03bb x : P \u00d7 P, x.1 -\u1d65 x.2) :=\n(lipschitz_with.prod_fst.vsub lipschitz_with.prod_snd).uniform_continuous\n\nlemma continuous_vadd : continuous (\u03bb x : V \u00d7 P, x.1 +\u1d65 x.2) :=\nuniform_continuous_vadd.continuous\n\nlemma continuous_vsub : continuous (\u03bb x : P \u00d7 P, x.1 -\u1d65 x.2) :=\nuniform_continuous_vsub.continuous\n\nlemma filter.tendsto.vadd {l : filter \u03b1} {f : \u03b1 \u2192 V} {g : \u03b1 \u2192 P} {v : V} {p : P}\n  (hf : tendsto f l (\ud835\udcdd v)) (hg : tendsto g l (\ud835\udcdd p)) :\n  tendsto (f +\u1d65 g) l (\ud835\udcdd (v +\u1d65 p)) :=\n(continuous_vadd.tendsto (v, p)).comp (hf.prod_mk_nhds hg)\n\nlemma filter.tendsto.vsub {l : filter \u03b1} {f g : \u03b1 \u2192 P} {x y : P}\n  (hf : tendsto f l (\ud835\udcdd x)) (hg : tendsto g l (\ud835\udcdd y)) :\n  tendsto (f -\u1d65 g) l (\ud835\udcdd (x -\u1d65 y)) :=\n(continuous_vsub.tendsto (x, y)).comp (hf.prod_mk_nhds hg)\n\nsection\n\nvariables [topological_space \u03b1]\n\nlemma continuous.vadd {f : \u03b1 \u2192 V} {g : \u03b1 \u2192 P} (hf : continuous f) (hg : continuous g) :\n  continuous (f +\u1d65 g) :=\ncontinuous_vadd.comp (hf.prod_mk hg)\n\nlemma continuous.vsub {f g : \u03b1 \u2192 P} (hf : continuous f) (hg : continuous g) :\n  continuous (f -\u1d65 g) :=\ncontinuous_vsub.comp (hf.prod_mk hg : _)\n\nlemma continuous_at.vadd {f : \u03b1 \u2192 V} {g : \u03b1 \u2192 P} {x : \u03b1} (hf : continuous_at f x)\n  (hg : continuous_at g x) :\n  continuous_at (f +\u1d65 g) x :=\nhf.vadd hg\n\nlemma continuous_at.vsub {f g : \u03b1 \u2192 P}  {x : \u03b1} (hf : continuous_at f x) (hg : continuous_at g x) :\n  continuous_at (f -\u1d65 g) x :=\nhf.vsub hg\n\nlemma continuous_within_at.vadd {f : \u03b1 \u2192 V} {g : \u03b1 \u2192 P} {x : \u03b1} {s : set \u03b1}\n  (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :\n  continuous_within_at (f +\u1d65 g) s x :=\nhf.vadd hg\n\nlemma continuous_within_at.vsub {f g : \u03b1 \u2192 P} {x : \u03b1} {s : set \u03b1}\n  (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :\n  continuous_within_at (f -\u1d65 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 \u03b1} {f\u2081 f\u2082 : \u03b1 \u2192 P} {g : \u03b1 \u2192 R} {p\u2081 p\u2082 : P} {c : R}\n  (h\u2081 : tendsto f\u2081 l (\ud835\udcdd p\u2081)) (h\u2082 : tendsto f\u2082 l (\ud835\udcdd p\u2082)) (hg : tendsto g l (\ud835\udcdd c)) :\n  tendsto (\u03bb x, affine_map.line_map (f\u2081 x) (f\u2082 x) (g x)) l (\ud835\udcdd $ affine_map.line_map p\u2081 p\u2082 c) :=\n(hg.smul (h\u2082.vsub h\u2081)).vadd h\u2081\n\nlemma filter.tendsto.midpoint [invertible (2:R)] {l : filter \u03b1} {f\u2081 f\u2082 : \u03b1 \u2192 P} {p\u2081 p\u2082 : P}\n  (h\u2081 : tendsto f\u2081 l (\ud835\udcdd p\u2081)) (h\u2082 : tendsto f\u2082 l (\ud835\udcdd p\u2082)) :\n  tendsto (\u03bb x, midpoint R (f\u2081 x) (f\u2082 x)) l (\ud835\udcdd $ midpoint R p\u2081 p\u2082) :=\nh\u2081.line_map h\u2082 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 \u2192 P'} (hf : isometry f) {p : P} {g : V \u2192 V'}\n  (hg : \u2200 v, g v = f (v +\u1d65 p) -\u1d65 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 {\ud835\udd5c : Type*} [normed_field \ud835\udd5c] [semi_normed_space \ud835\udd5c 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 \ud835\udd5c V'] {f : P \u2192\u1d43[\ud835\udd5c] P'} :\n  continuous f.linear \u2194 continuous f :=\nbegin\n  inhabit P,\n  have : (f.linear : V \u2192 V') =\n    (isometric.vadd_const $ f $ default P).to_homeomorph.symm \u2218 f \u2218\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\u2081 p\u2082 : P) (c : \ud835\udd5c) :\n  dist p\u2081 (homothety p\u2081 c p\u2082) = \u2225c\u2225 * dist p\u2081 p\u2082 :=\nby simp [homothety_def, norm_smul, \u2190 dist_eq_norm_vsub, dist_comm]\n\n@[simp] lemma dist_homothety_center (p\u2081 p\u2082 : P) (c : \ud835\udd5c) :\n  dist (homothety p\u2081 c p\u2082) p\u2081 = \u2225c\u2225 * dist p\u2081 p\u2082 :=\nby rw [dist_comm, dist_center_homothety]\n\n@[simp] lemma dist_homothety_self (p\u2081 p\u2082 : P) (c : \ud835\udd5c) :\n  dist (homothety p\u2081 c p\u2082) p\u2082 = \u22251 - c\u2225 * dist p\u2081 p\u2082 :=\nby rw [homothety_eq_line_map, \u2190 line_map_apply_one_sub, \u2190 homothety_eq_line_map,\n  dist_homothety_center, dist_comm]\n\n@[simp] lemma dist_self_homothety (p\u2081 p\u2082 : P) (c : \ud835\udd5c) :\n  dist p\u2082 (homothety p\u2081 c p\u2082) = \u22251 - c\u2225 * dist p\u2081 p\u2082 :=\nby rw [dist_comm, dist_homothety_self]\n\nvariables [invertible (2:\ud835\udd5c)]\n\n@[simp] lemma dist_left_midpoint (p\u2081 p\u2082 : P) :\n  dist p\u2081 (midpoint \ud835\udd5c p\u2081 p\u2082) = \u2225(2:\ud835\udd5c)\u2225\u207b\u00b9 * dist p\u2081 p\u2082 :=\nby rw [midpoint, \u2190 homothety_eq_line_map, dist_center_homothety, inv_of_eq_inv,\n  \u2190 normed_field.norm_inv]\n\n@[simp] lemma dist_midpoint_left (p\u2081 p\u2082 : P) :\n  dist (midpoint \ud835\udd5c p\u2081 p\u2082) p\u2081 = \u2225(2:\ud835\udd5c)\u2225\u207b\u00b9 * dist p\u2081 p\u2082 :=\nby rw [dist_comm, dist_left_midpoint]\n\n@[simp] lemma dist_midpoint_right (p\u2081 p\u2082 : P) :\n  dist (midpoint \ud835\udd5c p\u2081 p\u2082) p\u2082 = \u2225(2:\ud835\udd5c)\u2225\u207b\u00b9 * dist p\u2081 p\u2082 :=\nby rw [midpoint_comm, dist_midpoint_left, dist_comm]\n\n@[simp] lemma dist_right_midpoint (p\u2081 p\u2082 : P) :\n  dist p\u2082 (midpoint \ud835\udd5c p\u2081 p\u2082) = \u2225(2:\ud835\udd5c)\u2225\u207b\u00b9 * dist p\u2081 p\u2082 :=\nby rw [dist_comm, dist_midpoint_right]\n\nlemma dist_midpoint_midpoint_le' (p\u2081 p\u2082 p\u2083 p\u2084 : P) :\n  dist (midpoint \ud835\udd5c p\u2081 p\u2082) (midpoint \ud835\udd5c p\u2083 p\u2084) \u2264 (dist p\u2081 p\u2083 + dist p\u2082 p\u2084) / \u2225(2 : \ud835\udd5c)\u2225 :=\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, \u2190 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 \u211d V] [normed_space \u211d W]\n\nlemma dist_midpoint_midpoint_le (p\u2081 p\u2082 p\u2083 p\u2084 : V) :\n  dist (midpoint \u211d p\u2081 p\u2082) (midpoint \u211d p\u2083 p\u2084) \u2264 (dist p\u2081 p\u2083 + dist p\u2082 p\u2084) / 2 :=\nby simpa using dist_midpoint_midpoint_le' p\u2081 p\u2082 p\u2083 p\u2084\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 \u2192 Q)\n  (h : \u2200 x y, f (midpoint \u211d x y) = midpoint \u211d (f x) (f y))\n  (hfc : continuous f) :\n  P \u2192\u1d43[\u211d] Q :=\naffine_map.mk' f\n  \u2191((add_monoid_hom.of_map_midpoint \u211d \u211d\n    ((affine_equiv.vadd_const \u211d (f $ classical.arbitrary P)).symm \u2218 f \u2218\n      (affine_equiv.vadd_const \u211d (classical.arbitrary P))) (by simp)\n      (\u03bb 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  (\u03bb 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 : \u2115) [h : char_p R p] : char_p R[X] p :=\nlet \u27e8h\u27e9 := h in \u27e8\u03bb n, by rw [\u2190 map_nat_cast C, \u2190 C_0, C_inj, h]\u27e9\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree \u2264 `n`. -/\ndef degree_le (n : with_bot \u2115) : submodule R R[X] :=\n\u2a05 k : \u2115, \u2a05 h : \u2191k > n, (lcoeff R k).ker\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degree_lt (n : \u2115) : submodule R R[X] :=\n\u2a05 k : \u2115, \u2a05 h : k \u2265 n, (lcoeff R k).ker\n\nvariable {R}\n\ntheorem mem_degree_le {n : with_bot \u2115} {f : R[X]} :\n  f \u2208 degree_le R n \u2194 degree f \u2264 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 \u2115} (H : m \u2264 n) :\n  degree_le R m \u2264 degree_le R n :=\n\u03bb f hf, mem_degree_le.2 (le_trans (mem_degree_le.1 hf) H)\n\ntheorem degree_le_eq_span_X_pow {n : \u2115} :\n  degree_le R n = submodule.span R \u2191((finset.range (n+1)).image (\u03bb n, (X : R[X])^n)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_le.1 hp,\n    rw [\u2190 polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (\u03bb k hk, _),\n    show monomial _ _ \u2208 _,\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 \u27e8_, finset.mem_range.2 (nat.lt_succ_of_le this), rfl\u27e9) },\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 : \u2115} {f : R[X]} :\n  f \u2208 degree_lt R n \u2194 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 : \u2115} (H : m \u2264 n) :\n  degree_lt R m \u2264 degree_lt R n :=\n\u03bb 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 : \u2115} :\n  degree_lt R n = submodule.span R \u2191((finset.range n).image (\u03bb n, X^n) : finset R[X]) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_lt.1 hp,\n    rw [\u2190 polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (\u03bb k hk, _),\n    show monomial _ _ \u2208 _,\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 \u27e8_, finset.mem_range.2 this, rfl\u27e9) },\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 \u2192 F`. -/\ndef degree_lt_equiv (F : Type*) [field F] (n : \u2115) : degree_lt F n \u2243\u2097[F] (fin n \u2192 F) :=\n{ to_fun := \u03bb p n, (\u2191p : F[X]).coeff n,\n  inv_fun := \u03bb f, \u27e8\u2211 i : fin n, monomial i (f i),\n    (degree_lt F n).sum_mem (\u03bb 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)))\u27e9,\n  map_add' := \u03bb p q, by { ext, rw [submodule.coe_add, coeff_add], refl },\n  map_smul' := \u03bb x p, by { ext, rw [submodule.coe_smul, coeff_smul], refl },\n  left_inv :=\n  begin\n    rintro \u27e8p, hp\u27e9, 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, \u2190 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 [\u2190 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 (\u03bb n, p.coeff n) p.support\n\nlemma frange_zero : frange (0 : R[X]) = \u2205 :=\nrfl\n\nlemma mem_frange_iff {p : R[X]} {c : R} :\n  c \u2208 p.frange \u2194 \u2203 n \u2208 p.support, c = p.coeff n :=\nby simp [frange, eq_comm]\n\nlemma frange_one : frange (1 : R[X]) \u2286 {1} :=\nbegin\n  simp [frange, finset.image_subset_iff],\n  simp only [\u2190 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 : \u2115) (h : p.coeff n \u2260 0) :\n  p.coeff n \u2208 p.frange :=\nbegin\n  simp only [frange, exists_prop, mem_support_iff, finset.mem_image, ne.def],\n  exact \u27e8n, h, rfl\u27e9,\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 (\u2191p.frange : set R)) :=\n\u2211 i in p.support, monomial i (\u27e8p.coeff i,\n  if H : p.coeff i = 0 then H.symm \u25b8 (subring.closure _).zero_mem\n  else subring.subset_closure (p.coeff_mem_frange _ H)\u27e9 : (subring.closure (\u2191p.frange : set R)))\n\n@[simp] theorem coeff_restriction {p : R[X]} {n : \u2115} :\n  \u2191(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 : \u2115} :\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 [\u2190 coeff_restriction] },\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\nend\n\n@[simp] theorem map_restriction (p : R[X]) : p.restriction.map (algebra_map _ _) = p :=\next $ \u03bb 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) \u2194 monic p :=\nbegin\n  simp only [monic, leading_coeff, nat_degree_restriction],\n  rw [\u2190@coeff_restriction _ _ p],\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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 $ \u03bb i, subtype.eq $ by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs; refl\n\nvariables {S : Type v} [ring S] {f : R \u2192+* S} {x : S}\n\ntheorem eval\u2082_restriction {p : R[X]} :\n  eval\u2082 f x p =\n  eval\u2082 (f.comp (subring.subtype (subring.closure (p.frange : set R)))) x p.restriction :=\nbegin\n  simp only [eval\u2082_eq_sum, sum, support_restriction, \u2190@coeff_restriction _ _ p],\n  refl,\nend\n\nlemma geom_sum_X_comp_X_add_one_eq_sum (n : \u2115) :\n  (geom_sum (X : R[X]) n).comp (X + 1) =\n  (finset.range n).sum (\u03bb (i : \u2115), (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, \u2190 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, \u2190 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 : \u2115} (hn : n \u2260 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 : \u2115} (hn : n \u2260 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 : (\u2191p.frange : set R) \u2286 T) : T[X] :=\n\u2211 i in p.support, monomial i (\u27e8p.coeff i,\n  if H : p.coeff i = 0 then H.symm \u25b8 T.zero_mem\n  else hp (p.coeff_mem_frange _ H)\u27e9 : T)\n\nvariables (hp : (\u2191p.frange : set R) \u2286 T)\ninclude hp\n\n@[simp] theorem coeff_to_subring {n : \u2115} : \u2191(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 : \u2115} : (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 [\u2190 coeff_to_subring p T hp] },\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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) \u2194 monic p :=\nbegin\n  simp_rw [monic, leading_coeff, nat_degree_to_subring, \u2190 coeff_to_subring p T hp],\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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 $ \u03bb 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\u2211 i in p.support, monomial i (p.coeff i : R)\n\nlemma coeff_of_subring (p : T[X]) (n : \u2115) :\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  (\u2191(p.of_subring T).frange : set R) \u2286 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 \u27e8n, hn, h'n\u27e9,\n  rw [\u2190 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 \u2208 (mod_by_monic_hom q).ker \u2194 q \u2223 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 (\u03bb 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*} {\u03c3 : 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 : \u2200 (n : \u2115), (p.coeff n) \u2208 I.comap C) : p \u2208 I :=\nsum_C_mul_X_eq p \u25b8 submodule.sum_mem I (\u03bb 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 \u2208 (ideal.map C I : ideal R[X]) \u2194 \u2200 n : \u2115, f.coeff n \u2208 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 [\u2190 hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [h] } },\n    { simp },\n    { exact \u03bb f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine \u03bb f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (\u03bb c hc, I.mul_mem_left (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw \u2190 sum_monomial_eq f,\n    refine (I.map C : ideal R[X]).sum_mem (\u03bb 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 \u2192+* 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  \u2200 a \u2208 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\u2082_C_mk_eq_zero {I : ideal R} :\n  \u2200 f \u2208 (map C I : ideal R[X]), eval\u2082_ring_hom (C.comp (quotient.mk I)) X f = 0 :=\nbegin\n  intros a ha,\n  rw \u2190 sum_monomial_eq a,\n  dsimp,\n  rw eval\u2082_sum,\n  refine finset.sum_eq_zero (\u03bb n hn, _),\n  dsimp,\n  rw eval\u2082_monomial (C.comp (quotient.mk I)) X,\n  refine mul_eq_zero_of_left (polynomial.ext (\u03bb 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 \u29f8 I) \u2243+* R[X] \u29f8 (map C I : ideal R[X]) :=\n{ to_fun := eval\u2082_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\u2082_ring_hom (C.comp (quotient.mk I)) X) eval\u2082_C_mk_eq_zero,\n  map_mul' := \u03bb f g, by simp only [coe_eval\u2082_ring_hom, eval\u2082_mul],\n  map_add' := \u03bb f g, by simp only [eval\u2082_add, coe_eval\u2082_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\u2082_ring_hom] at hp,\n      simp only [coe_eval\u2082_ring_hom] at hq,\n      simp only [coe_eval\u2082_ring_hom, hp, hq, ring_hom.map_add] },\n    { rintros n \u27e8x\u27e9,\n      simp only [monomial_eq_smul_X, C_mul', quotient.lift_mk, submodule.quotient.quot_mk_eq_mk,\n        quotient.mk_eq_mk, eval\u2082_X_pow, eval\u2082_smul, coe_eval\u2082_ring_hom, ring_hom.map_pow,\n        eval\u2082_C, ring_hom.coe_comp, ring_hom.map_mul, eval\u2082_X] }\n  end,\n  right_inv := begin\n    rintro \u27e8f\u27e9,\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, \u2190 C_mul' a (X ^ n), quotient.lift_mk,\n        submodule.quotient.quot_mk_eq_mk, quotient.mk_eq_mk, eval\u2082_X_pow,\n        eval\u2082_smul, coe_eval\u2082_ring_hom, ring_hom.map_pow, eval\u2082_C, ring_hom.coe_comp,\n        ring_hom.map_mul, eval\u2082_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\u2082_ring_hom, eval\u2082_eq_eval_map, \u2190polynomial.map_map,\n  \u2190eval\u2082_eq_eval_map, polynomial.eval\u2082_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] \u29f8 (map C P : ideal R[X])) :=\nring_equiv.is_domain (polynomial (R \u29f8 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 \u2192 R[x] \u2192 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] \u2192 R'[x]`.\n  In particular we can map `I` across this map, to get `I'` and a new map `R' \u2192 R'[x] \u2192 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 \u2208 (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 \u2264 I,\n  { refine \u03bb f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (\u03bb n, _),\n    rw [mem_comap, \u2190 quotient.eq_zero_iff_mem, \u2190 ring_hom.comp_apply],\n    rw [ring_hom.mem_ker, coe_map_ring_hom] at hf,\n    replace hf := congr_arg (\u03bb (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 \u27e8x, hx'\u27e9 := x,\n  obtain \u27e8y, rfl\u27e9 := (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) \u2208 (I.map (polynomial.map_ring_hom i)),\n  { obtain \u27e8f, hf\u27e9 := 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 \u25b8 I.add_mem (hi' _ : (C y - f) \u2208 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 : \u00ac is_field R[X] :=\nbegin\n  by_contradiction hR,\n  by_cases hR' : \u2203 (x y : R), x \u2260 y,\n  { haveI : nontrivial R := let \u27e8x, y, hxy\u27e9 := hR' in nontrivial_of_ne x y hxy,\n    obtain \u27e8p, hp\u27e9 := 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) \u25b8 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 \u27e8x, y, hxy\u27e9 := hR.exists_pair_ne in hxy (polynomial.ext (\u03bb 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 \u2208 I) : x = 0 :=\nbegin\n  refine classical.by_contradiction (\u03bb hx0, hI.ne_top ((eq_top_iff_one I).2 _)),\n  obtain \u27e8y, hy\u27e9 := hR.mul_inv_cancel hx0,\n  convert I.mul_mem_left (C y) hx,\n  rw [\u2190 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' := \u03bb _ _, I.add_mem,\n  smul_mem' := \u03bb c x H, by { rw [\u2190 C_mul'], exact I.mul_mem_left _ H } }\n\nvariables {I : ideal R[X]}\ntheorem mem_of_polynomial (x) : x \u2208 I.of_polynomial \u2194 x \u2208 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 \u2264 `n`. -/\ndef degree_le (n : with_bot \u2115) : submodule R R[X] :=\ndegree_le R n \u2293 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 \u2264 `n`. -/\ndef leading_coeff_nth (n : \u2115) : ideal R :=\n(I.degree_le n).map $ lcoeff R n\n\ntheorem mem_leading_coeff_nth (n : \u2115) (x) :\n  x \u2208 I.leading_coeff_nth n \u2194 \u2203 p \u2208 I, degree p \u2264 n \u2227 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 \u27e8p, \u27e8hpdeg, hpI\u27e9, rfl\u27e9,\n    cases lt_or_eq_of_le hpdeg with hpdeg hpdeg,\n    { refine \u27e80, I.zero_mem, bot_le, _\u27e9,\n      rw [leading_coeff_zero, eq_comm],\n      exact coeff_eq_zero_of_degree_lt hpdeg },\n    { refine \u27e8p, hpI, le_of_eq hpdeg, _\u27e9,\n      rw [leading_coeff, nat_degree, hpdeg], refl } },\n  { rintro \u27e8p, hpI, hpdeg, rfl\u27e9,\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 \u27e8p * X ^ (n - nat_degree p), \u27e8_, I.mul_mem_right _ hpI\u27e9, _\u27e9,\n    { apply le_trans (degree_mul_le _ _) _,\n      apply le_trans (add_le_add (degree_le_nat_degree) (degree_X_pow_le _)) _,\n      rw [\u2190 with_bot.coe_add, this],\n      exact le_rfl },\n    { rw [leading_coeff, \u2190 coeff_mul_X_pow p (n - nat_degree p), this] } }\nend\n\ntheorem mem_leading_coeff_nth_zero (x) :\n  x \u2208 I.leading_coeff_nth 0 \u2194 C x \u2208 I :=\n(mem_leading_coeff_nth _ _ _).trans\n\u27e8\u03bb \u27e8p, hpI, hpdeg, hpx\u27e9, by rwa [\u2190 hpx, leading_coeff,\n  nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg),\n  \u2190 eq_C_of_degree_le_zero hpdeg],\n\u03bb hx, \u27e8C x, hx, degree_C_le, leading_coeff_C x\u27e9\u27e9\n\ntheorem leading_coeff_nth_mono {m n : \u2115} (H : m \u2264 n) :\n  I.leading_coeff_nth m \u2264 I.leading_coeff_nth n :=\nbegin\n  intros r hr,\n  simp only [set_like.mem_coe, mem_leading_coeff_nth] at hr \u22a2,\n  rcases hr with \u27e8p, hpI, hpdeg, rfl\u27e9,\n  refine \u27e8p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow\u27e9,\n  refine le_trans (degree_mul_le _ _) _,\n  refine le_trans (add_le_add hpdeg (degree_X_pow_le _)) _,\n  rw [\u2190 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\u2a06 n : \u2115, I.leading_coeff_nth n\n\ntheorem mem_leading_coeff (x) :\n  x \u2208 I.leading_coeff \u2194 \u2203 p \u2208 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 \u27e8i, p, hpI, hpdeg, rfl\u27e9, exact \u27e8p, hpI, rfl\u27e9 },\n    rintro \u27e8p, hpI, rfl\u27e9, exact \u27e8nat_degree p, p, hpI, degree_le_nat_degree, rfl\u27e9 },\n  intros i j, exact \u27e8i + j, I.leading_coeff_nth_mono (nat.le_add_right _ _),\n    I.leading_coeff_nth_mono (nat.le_add_left _ _)\u27e9\nend\n\ntheorem is_fg_degree_le [is_noetherian_ring R] (n : \u2115) :\n  submodule.fg (I.degree_le n) :=\nis_noetherian_submodule_left.1 (is_noetherian_of_fg_of_noetherian _\n  \u27e8_, degree_le_eq_span_X_pow.symm\u27e9) _\n\nend ideal\n\nsection prime\nvariables (\u03c3) {r : R}\n\nnamespace polynomial\nlemma prime_C_iff : prime (C r) \u2194 prime r :=\n\u27e8 comap_prime C (eval_ring_hom (0 : R)) (\u03bb r, eval_C),\n  \u03bb hr, by { have := hr.1,\n    rw \u2190 ideal.span_singleton_prime at hr \u22a2,\n    { convert ideal.is_prime_map_C_of_is_prime hr using 1,\n      rw [ideal.map_span, set.image_singleton] },\n    exacts [\u03bb h, this (C_eq_zero.1 h), this] } \u27e9\nend polynomial\n\nnamespace mv_polynomial\n\nprivate lemma prime_C_iff_of_fintype [fintype \u03c3] : prime (C r : mv_polynomial \u03c3 R) \u2194 prime r :=\nbegin\n  rw (rename_equiv R (fintype.equiv_fin \u03c3)).to_mul_equiv.prime_iff,\n  convert_to prime (C r) \u2194 _, { congr, apply rename_C },\n  { symmetry, induction fintype.card \u03c3 with d hd,\n    { exact (is_empty_alg_equiv R (fin 0)).to_mul_equiv.symm.prime_iff },\n    { rw [hd, \u2190 polynomial.prime_C_iff],\n      convert (fin_succ_equiv R d).to_mul_equiv.symm.prime_iff,\n      rw \u2190 fin_succ_equiv_comp_C_eq_C, refl } },\nend\n\nlemma prime_C_iff : prime (C r : mv_polynomial \u03c3 R) \u2194 prime r :=\n\u27e8 comap_prime C constant_coeff constant_coeff_C,\n  \u03bb hr, \u27e8 \u03bb h, hr.1 $ by { rw [\u2190 C_inj, h], simp },\n    \u03bb h, hr.2.1 $ by { rw \u2190 constant_coeff_C r, exact h.map _ },\n    \u03bb a b hd, begin\n      obtain \u27e8s,a',b',rfl,rfl\u27e9 := exists_finset_rename\u2082 a b,\n      rw \u2190 algebra_map_eq at hd, have : algebra_map R _ r \u2223 a' * b',\n      { convert (kill_compl subtype.coe_injective).to_ring_hom.map_dvd hd, simpa, simp },\n      rw \u2190 rename_C (coe : s \u2192 \u03c3), let f := (rename (coe : s \u2192 \u03c3)).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 \u27e9 \u27e9\n\nvariable {\u03c3}\nlemma prime_rename_iff (s : set \u03c3) {p : mv_polynomial s R} :\n  prime (rename (coe : s \u2192 \u03c3) p) \u2194 prime p :=\nbegin\n  classical, symmetry, let eqv := (sum_alg_equiv R _ _).symm.trans\n    (rename_equiv R $ (equiv.sum_comm \u21a5s\u1d9c s).trans $ equiv.set.sum_compl s),\n  rw [\u2190 prime_C_iff \u21a5s\u1d9c, 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 (\u27e8\u03bb (p : R[X]),\n        ((if p = 0 then \u22a4 else \u2191p.degree : with_top (with_bot \u2115)), p.leading_coeff), _\u27e9 :\n        dvd_not_unit \u2192r prod.lex (<) dvd_not_unit)\n      (prod.lex_wf (with_top.well_founded_lt $ with_bot.well_founded_lt nat.lt_wf)\n        \u2039wf_dvd_monoid R\u203a.well_founded_dvd_not_unit),\n    rintros a b \u27e8ane0, \u27e8c, \u27e8not_unit_c, rfl\u27e9\u27e9\u27e9,\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 \u2260 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 _ \u27e8_, \u27e8c.leading_coeff, (\u03bb unit_c, not_unit_c _), rfl\u27e9\u27e9,\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          \u2190 with_bot.coe_add, with_bot.coe_lt_coe],\n      exact lt_add_of_pos_right _ (nat.pos_of_ne_zero (\u03bb h, hdeg (h.symm \u25b8 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 \u27e8assume 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) \u27e8_, \u27e80, rfl\u27e9\u27e9 in\nhave hm : M \u2208 set.range I.leading_coeff_nth := well_founded.min_mem _ _ _,\nlet \u27e8N, HN\u27e9 := hm, \u27e8s, hs\u27e9 := I.is_fg_degree_le N in\nhave hm2 : \u2200 k, I.leading_coeff_nth k \u2264 M := \u03bb k, or.cases_on (le_or_lt k N)\n  (\u03bb h, HN \u25b8 I.leading_coeff_nth_mono h)\n  (\u03bb h x hx, classical.by_contradiction $ \u03bb hxm,\n    have \u00acM < I.leading_coeff_nth k, by refine well_founded.not_lt_min\n      (well_founded_submodule_gt _ _) _ _ _; exact \u27e8k, rfl\u27e9,\n    this \u27e8HN \u25b8 I.leading_coeff_nth_mono (le_of_lt h), \u03bb H, hxm (H hx)\u27e9),\nhave hs2 : \u2200 {x}, x \u2208 I.degree_le N \u2192 x \u2208 ideal.span (\u2191s : set R[X]),\nfrom hs \u25b8 \u03bb x hx, submodule.span_induction hx (\u03bb _ hx, ideal.subset_span hx) (ideal.zero_mem _)\n  (\u03bb _ _, ideal.add_mem _) (\u03bb c f hf, f.C_mul' c \u25b8 ideal.mul_mem_left _ _ hf),\n\u27e8s, le_antisymm\n  (ideal.span_le.2 $ \u03bb x hx, have x \u2208 I.degree_le N, from hs \u25b8 submodule.subset_span hx, this.2) $\nbegin\n  have : submodule.span R[X] \u2191s = ideal.span \u2191s, 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 \u27e8polynomial.mem_degree_le.2\n      (le_trans polynomial.degree_le_nat_degree $ with_bot.coe_le_coe.2 h), hp\u27e9 },\n  { have hp0 : p \u2260 0,\n    { rintro rfl, cases hn, exact nat.not_lt_zero _ h },\n    have : (0 : R) \u2260 1,\n    { intro h, apply hp0, ext i, refine (mul_one _).symm.trans _,\n      rw [\u2190 h, mul_zero], refl },\n    haveI : nontrivial R := \u27e8\u27e80, 1, this\u27e9\u27e9,\n    have : p.leading_coeff \u2208 I.leading_coeff_nth N,\n    { rw HN, exact hm2 k ((I.mem_leading_coeff_nth _ _).2\n        \u27e8_, hp, hn \u25b8 polynomial.degree_le_nat_degree, rfl\u27e9) },\n    rw I.mem_leading_coeff_nth at this,\n    rcases this with \u27e8q, hq, hdq, hlqp\u27e9,\n    have hq0 : q \u2260 0,\n    { intro H, rw [\u2190 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 [\u2190 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 [\u2190 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 \u2190 sub_add_cancel p (q * polynomial.X ^ (k - q.nat_degree)),\n    refine (ideal.span \u2191s).add_mem _ ((ideal.span \u2191s).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 \u27e8polynomial.mem_degree_le.2 hdq, hq\u27e9 }\nend\u27e9\u27e9\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) : \u2203 g, irreducible g \u2227 g \u2223 f :=\nwf_dvd_monoid.exists_irreducible_factor\n  (\u03bb huf, ne_of_gt hf $ degree_eq_zero_of_is_unit huf)\n  (\u03bb hf0, not_lt_of_lt hf $ hf0.symm \u25b8 (@degree_zero R _).symm \u25b8 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) : \u2203 g, irreducible g \u2227 g \u2223 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 \u2260 0) : \u2203 g, irreducible g \u2227 g \u2223 f :=\nexists_irreducible_of_nat_degree_pos $ nat.pos_of_ne_zero hf\n\nlemma linear_independent_powers_iff_aeval\n  (f : M \u2192\u2097[R] M) (v : M) :\n  linear_independent R (\u03bb n : \u2115, (f ^ n) v)\n    \u2194 \u2200 (p : R[X]), aeval f p v = 0 \u2192 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 \u2192\u2097[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 \u27e8p', q', hpq'\u27e9,\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 (\u03bb p : R[X], aeval f p v) hpq'.symm,\nend\n\nlemma sup_aeval_range_eq_top_of_coprime\n  (f : M \u2192\u2097[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  (aeval f p).range \u2294 (aeval f q).range = \u22a4 :=\nbegin\n  rw eq_top_iff,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with \u27e8p', q', hpq'\u27e9,\n  use aeval f (p * p') v,\n  use linear_map.mem_range.2 \u27e8aeval f p' v, by simp only [linear_map.mul_apply, aeval_mul]\u27e9,\n  use aeval f (q * q') v,\n  use linear_map.mem_range.2 \u27e8aeval f q' v, by simp only [linear_map.mul_apply, aeval_mul]\u27e9,\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add]\n    using congr_arg (\u03bb p : R[X], aeval f p v) hpq'\nend\n\nlemma sup_ker_aeval_le_ker_aeval_mul {f : M \u2192\u2097[R] M} {p q : R[X]} :\n  (aeval f p).ker \u2294 (aeval f q).ker \u2264 (aeval f (p * q)).ker :=\nbegin\n  intros v hv,\n  rcases submodule.mem_sup.1 hv with \u27e8x, hx, y, hy, hxy\u27e9,\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, \u2190hxy, 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 \u2192\u2097[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  (aeval f p).ker \u2294 (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 \u27e8p', q', hpq'\u27e9,\n  have h_eval\u2082_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\u2082_pqq' := calc\n    aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v :\n      by rw [\u2190mul_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\u2082_qpp' h_eval\u2082_pqq',\n  refine \u27e8aeval f (q * q') v, linear_map.mem_ker.1 h_eval\u2082_pqq',\n          aeval f (p * p') v, linear_map.mem_ker.1 h_eval\u2082_qpp', _\u27e9,\n  rw [add_comm, mul_comm p p', mul_comm q q'],\n  simpa using congr_arg (\u03bb 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  \u2200 {n : \u2115}, 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 \u03c3] [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial \u03c3 R) :=\n@is_noetherian_ring_of_ring_equiv (mv_polynomial (fin (fintype.card \u03c3)) R) _ _ _\n  (rename_equiv R (fintype.equiv_fin \u03c3).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  \u2200 (n : \u2115), 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) (\u03c3 : Type v) [comm_ring R] [fintype \u03c3]\n  [is_domain R] : is_domain (mv_polynomial \u03c3 R) :=\n@ring_equiv.is_domain _ (mv_polynomial (fin $ fintype.card \u03c3) R) _ _\n  (mv_polynomial.is_domain_fin _ _)\n  (rename_equiv R (fintype.equiv_fin \u03c3)).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] {\u03c3 : Type v}\n  (p q : mv_polynomial \u03c3 R) (h : p * q = 0) : p = 0 \u2228 q = 0 :=\nbegin\n  obtain \u27e8s, p, rfl\u27e9 := exists_finset_rename p,\n  obtain \u27e8t, q, rfl\u27e9 := exists_finset_rename q,\n  have :\n    rename (subtype.map id (finset.subset_union_left s t) : {x // x \u2208 s} \u2192 {x // x \u2208 s \u222a t}) p *\n    rename (subtype.map id (finset.subset_union_right s t) : {x // x \u2208 t} \u2192 {x // x \u2208 s \u222a t}) q = 0,\n  { apply rename_injective _ subtype.val_injective, simpa using h },\n  letI := mv_polynomial.is_domain_fintype R {x // x \u2208 (s \u222a 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} {\u03c3 : Type v} [comm_ring R] [is_domain R] :\n  is_domain (mv_polynomial \u03c3 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 := \u27e80, 1, \u03bb H,\n  begin\n    have : eval\u2082 (ring_hom.id _) (\u03bb s, (0:R)) (0 : mv_polynomial \u03c3 R) =\n      eval\u2082 (ring_hom.id _) (\u03bb s, (0:R)) (1 : mv_polynomial \u03c3 R),\n    { congr, exact H },\n    simpa,\n  end\u27e9,\n  .. (by apply_instance : comm_ring (mv_polynomial \u03c3 R)) }\n\nlemma map_mv_polynomial_eq_eval\u2082 {S : Type*} [comm_ring S] [fintype \u03c3]\n  (\u03d5 : mv_polynomial \u03c3 R \u2192+* S) (p : mv_polynomial \u03c3 R) :\n  \u03d5 p = mv_polynomial.eval\u2082 (\u03d5.comp mv_polynomial.C) (\u03bb s, \u03d5 (mv_polynomial.X s)) p :=\nbegin\n  refine trans (congr_arg \u03d5 (mv_polynomial.as_sum p)) _,\n  rw [mv_polynomial.eval\u2082_eq', \u03d5.map_sum],\n  congr,\n  ext,\n  simp only [monomial_eq, \u03d5.map_pow, \u03d5.map_prod, \u03d5.comp_apply, \u03d5.map_mul, finsupp.prod_pow],\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} {i : R} (hi : i \u2208 I) :\n  (ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial \u03c3 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 \u03c3 R)) (p : mv_polynomial \u03c3 R)\n  (hcoe : \u2200 (m : \u03c3 \u2192\u2080 \u2115), p.coeff m \u2208 I.comap C) : p \u2208 I :=\nbegin\n  rw as_sum p,\n  suffices : \u2200 m \u2208 p.support, monomial m (mv_polynomial.coeff m p) \u2208 I,\n  { exact submodule.sum_mem I this },\n  intros m hm,\n  rw [\u2190 mul_one (coeff m p), \u2190 C_mul_monomial],\n  suffices : C (coeff m p) \u2208 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 \u03c3 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 \u03c3 R} :\n  f \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 R)) \u2194 \u2200 (m : \u03c3 \u2192\u2080 \u2115), f.coeff m \u2208 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 [\u2190 hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [ne.symm h] } },\n    { simp },\n    { exact \u03bb f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine \u03bb f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (\u03bb c hc, I.mul_mem_left (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw as_sum f,\n    suffices : \u2200 m \u2208 f.support, monomial m (coeff m f) \u2208\n      (ideal.map C I : ideal (mv_polynomial \u03c3 R)),\n    { exact submodule.sum_mem _ this },\n    intros m hm,\n    rw [\u2190 mul_one (coeff m f), \u2190 C_mul_monomial],\n    suffices : C (coeff m f) \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 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 \u2192+* S) : (map f : mv_polynomial \u03c3 R \u2192+* mv_polynomial \u03c3 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\u2082_C_mk_eq_zero {I : ideal R} {a : mv_polynomial \u03c3 R}\n  (ha : a \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 R))) :\n  eval\u2082_hom (C.comp (ideal.quotient.mk I)) X a = 0 :=\nbegin\n  rw as_sum a,\n  rw [coe_eval\u2082_hom, eval\u2082_sum],\n  refine finset.sum_eq_zero (\u03bb n hn, _),\n  simp only [eval\u2082_monomial, function.comp_app, ring_hom.coe_comp],\n  refine mul_eq_zero_of_left _ _,\n  suffices : coeff n a \u2208 I,\n  { rw [\u2190 @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 \u03c3 I.quotient` is isomorphic as an\n`R`-algebra to the quotient of `mv_polynomial \u03c3 R` by the ideal generated by `I`. -/\ndef quotient_equiv_quotient_mv_polynomial (I : ideal R) :\n  mv_polynomial \u03c3 (R \u29f8 I) \u2243\u2090[R]\n    mv_polynomial \u03c3 R \u29f8 (ideal.map C I : ideal (mv_polynomial \u03c3 R)) :=\n{ to_fun := eval\u2082_hom (ideal.quotient.lift I ((ideal.quotient.mk (ideal.map C I : ideal\n    (mv_polynomial \u03c3 R))).comp C) (\u03bb i hi, quotient_map_C_eq_zero hi))\n    (\u03bb i, ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial \u03c3 R)) (X i)),\n  inv_fun := ideal.quotient.lift (ideal.map C I : ideal (mv_polynomial \u03c3 R))\n    (eval\u2082_hom (C.comp (ideal.quotient.mk I)) X) (\u03bb a ha, eval\u2082_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 \u27e8r\u27e9,\n      rw [coe_eval\u2082_hom, eval\u2082_C],\n      simp only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk,\n        ideal.quotient.mk_eq_mk, bind\u2082_C_right, ring_hom.coe_comp] },\n    { simp_intros p q hp hq only [ring_hom.map_add, mv_polynomial.coe_eval\u2082_hom, coe_eval\u2082_hom,\n        mv_polynomial.eval\u2082_add, mv_polynomial.eval\u2082_hom_eq_bind\u2082, eval\u2082_hom_eq_bind\u2082],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval\u2082_hom_eq_bind\u2082, coe_eval\u2082_hom],\n      simp only [hp, eval\u2082_hom_eq_bind\u2082, coe_eval\u2082_hom, ideal.quotient.lift_mk, bind\u2082_X_right,\n        eval\u2082_mul, ring_hom.map_mul, eval\u2082_X] }\n  end,\n  right_inv := begin\n    rintro \u27e8f\u27e9,\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\u2082_hom_C] },\n    { simp_intros p q hp hq only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, eval\u2082_add,\n        ring_hom.map_add, coe_eval\u2082_hom, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, coe_eval\u2082_hom,\n        ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk, bind\u2082_X_right, eval\u2082_mul, ring_hom.map_mul,\n        eval\u2082_X],\n      simp only [hp] }\n  end,\n  commutes' := \u03bb r, eval\u2082_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] (\u03c3)\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 \u03c3] :\n  unique_factorization_monoid (mv_polynomial \u03c3 D) :=\n(rename_equiv D (fintype.equiv_fin \u03c3)).to_mul_equiv.symm.unique_factorization_monoid $\nbegin\n  induction fintype.card \u03c3 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 \u03c3 D) :=\nbegin\n  rw iff_exists_prime_factors,\n  intros a ha, obtain \u27e8s,a',rfl\u27e9 := exists_finset_rename a,\n  obtain \u27e8w,h,u,hw\u27e9 := iff_exists_prime_factors.1\n    (unique_factorization_monoid_of_fintype s) a' (\u03bb h, ha $ by simp [h]),\n  exact \u27e8 w.map (rename coe),\n    \u03bb b hb, let \u27e8b',hb',he\u27e9 := multiset.mem_map.1 hb in he \u25b8 (prime_rename_iff \u2191s).2 (h b' hb'),\n    units.map (@rename s \u03c3 D _ coe).to_ring_hom.to_monoid_hom u,\n    by erw [multiset.prod_hom, \u2190 map_mul, hw] \u27e9,\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\u00e7ois 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 \u2192 \u03b2` is `convex_on` a set `s` if `s` is itself a convex set, and for any two\npoints `x y \u2208 s`, the segment joining `(x, f x)` to `(y, f y)` is above the graph of `f`.\nEquivalently, `convex_on \ud835\udd5c f s` means that the epigraph `{p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2}` is\na convex set.\n\n## Main declarations\n\n* `convex_on \ud835\udd5c s f`: The function `f` is convex on `s` with scalars `\ud835\udd5c`.\n* `concave_on \ud835\udd5c s f`: The function `f` is concave on `s` with scalars `\ud835\udd5c`.\n* `strict_convex_on \ud835\udd5c s f`: The function `f` is strictly convex on `s` with scalars `\ud835\udd5c`.\n* `strict_concave_on \ud835\udd5c s f`: The function `f` is strictly concave on `s` with scalars `\ud835\udd5c`.\n-/\n\nopen finset linear_map set\nopen_locale big_operators classical convex pointwise\n\nvariables {\ud835\udd5c E F \u03b2 \u03b9 : Type*}\n\nsection ordered_semiring\nvariables [ordered_semiring \ud835\udd5c]\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 \u03b2]\n\nsection has_scalar\nvariables (\ud835\udd5c) [has_scalar \ud835\udd5c E] [has_scalar \ud835\udd5c \u03b2] (s : set E) (f : E \u2192 \u03b2)\n\n/-- Convexity of functions -/\ndef convex_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y\n\n/-- Concavity of functions -/\ndef concave_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 a + b = 1 \u2192\n    a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)\n\n/-- Strict convexity of functions -/\ndef strict_convex_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y\n\n/-- Strict concavity of functions -/\ndef strict_concave_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    a \u2022 f x + b \u2022 f y < f (a \u2022 x + b \u2022 y)\n\nvariables {\ud835\udd5c s f}\n\nopen order_dual (to_dual of_dual)\n\nlemma convex_on.dual (hf : convex_on \ud835\udd5c s f) : concave_on \ud835\udd5c s (to_dual \u2218 f) := hf\n\nlemma concave_on.dual (hf : concave_on \ud835\udd5c s f) : convex_on \ud835\udd5c s (to_dual \u2218 f) := hf\n\nlemma strict_convex_on.dual (hf : strict_convex_on \ud835\udd5c s f) : strict_concave_on \ud835\udd5c s (to_dual \u2218 f) :=\nhf\n\nlemma strict_concave_on.dual (hf : strict_concave_on \ud835\udd5c s f) : strict_convex_on \ud835\udd5c s (to_dual \u2218 f) :=\nhf\n\nlemma convex_on_id {s : set \u03b2} (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s id := \u27e8hs, by { intros, refl }\u27e9\n\nlemma concave_on_id {s : set \u03b2} (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s id := \u27e8hs, by { intros, refl }\u27e9\n\nlemma convex_on.subset {t : set E} (hf : convex_on \ud835\udd5c t f) (hst : s \u2286 t) (hs : convex \ud835\udd5c s) :\n  convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma concave_on.subset {t : set E} (hf : concave_on \ud835\udd5c t f) (hst : s \u2286 t) (hs : convex \ud835\udd5c s) :\n  concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma strict_convex_on.subset {t : set E} (hf : strict_convex_on \ud835\udd5c t f) (hst : s \u2286 t)\n  (hs : convex \ud835\udd5c s) :\n  strict_convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma strict_concave_on.subset {t : set E} (hf : strict_concave_on \ud835\udd5c t f) (hst : s \u2286 t)\n  (hs : convex \ud835\udd5c s) :\n  strict_concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nend has_scalar\n\nsection distrib_mul_action\nvariables [has_scalar \ud835\udd5c E] [distrib_mul_action \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma convex_on.add (hf : convex_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  convex_on \ud835\udd5c s (f + g) :=\n\u27e8hf.1, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) + g (a \u2022 x + b \u2022 y) \u2264 (a \u2022 f x + b \u2022 f y) + (a \u2022 g x + b \u2022 g y)\n      : add_le_add (hf.2 hx hy ha hb hab) (hg.2 hx hy ha hb hab)\n    ... = a \u2022 (f x + g x) + b \u2022 (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]\u27e9\n\nlemma concave_on.add (hf : concave_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on_const (c : \u03b2) (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s (\u03bb x:E, c) :=\n\u27e8hs, \u03bb x y _ _ a b _ _ hab, (convex.combo_self hab c).ge\u27e9\n\nlemma concave_on_const (c : \u03b2) (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s (\u03bb x:E, c) :=\n@convex_on_const _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ c hs\n\nlemma convex_on_of_convex_epigraph (h : convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2}) :\n  convex_on \ud835\udd5c s f :=\n\u27e8\u03bb x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) \u27e8hx, le_rfl\u27e9 \u27e8hy, le_rfl\u27e9 a b ha hb hab).1,\n  \u03bb x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) \u27e8hx, le_rfl\u27e9 \u27e8hy, le_rfl\u27e9 a b ha hb hab).2\u27e9\n\nlemma concave_on_of_convex_hypograph (h : convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 p.2 \u2264 f p.1}) :\n  concave_on \ud835\udd5c s f :=\n@convex_on_of_convex_epigraph \ud835\udd5c  E \u03b2\u1d52\u1d48 _ _ _ _ _ _ _ h\n\nend module\n\nsection ordered_smul\nvariables [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.convex_le (hf : convex_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | f x \u2264 r} :=\n\u03bb x y hx hy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 ha hb hab\n                  ... \u2264 a \u2022 r + b \u2022 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\u27e9\n\nlemma concave_on.convex_ge (hf : concave_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | r \u2264 f x} :=\nhf.dual.convex_le r\n\nlemma convex_on.convex_epigraph (hf : convex_on \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2} :=\nbegin\n  rintro \u27e8x, r\u27e9 \u27e8y, t\u27e9 \u27e8hx, hr\u27e9 \u27e8hy, ht\u27e9 a b ha hb hab,\n  refine \u27e8hf.1 hx hy ha hb hab, _\u27e9,\n  calc f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha hb hab\n  ... \u2264 a \u2022 r + b \u2022 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 \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 p.2 \u2264 f p.1} :=\nhf.dual.convex_epigraph\n\nlemma convex_on_iff_convex_epigraph :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2} :=\n\u27e8convex_on.convex_epigraph, convex_on_of_convex_epigraph\u27e9\n\nlemma concave_on_iff_convex_hypograph :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 p.2 \u2264 f p.1} :=\n@convex_on_iff_convex_epigraph \ud835\udd5c E \u03b2\u1d52\u1d48 _ _ _ _ _ _ _ f\n\nend ordered_smul\n\nsection module\nvariables [module \ud835\udd5c E] [has_scalar \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\n/-- Right translation preserves convexity. -/\nlemma convex_on.translate_right (hf : convex_on \ud835\udd5c s f) (c : E) :\n  convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\n\u27e8hf.1.translate_preimage_right _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (c + (a \u2022 x + b \u2022 y)) = f (a \u2022 (c + x) + b \u2022 (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... \u2264 a \u2022 f (c + x) + b \u2022 f (c + y) : hf.2 hx hy ha hb hab\u27e9\n\n/-- Right translation preserves concavity. -/\nlemma concave_on.translate_right (hf : concave_on \ud835\udd5c s f) (c : E) :\n  concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves convexity. -/\nlemma convex_on.translate_left (hf : convex_on \ud835\udd5c s f) (c : E) :\n  convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c s f) (c : E) :\n  concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, z + c)) :=\nhf.dual.translate_left _\n\nend module\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2]\n\nlemma convex_on_iff_forall_pos {s : set E} {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y :=\nbegin\n  refine and_congr_right' \u27e8\u03bb h x y hx hy a b ha hb hab, h hx hy ha.le hb.le hab,\n    \u03bb h x y hx hy a b ha hb hab, _\u27e9,\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 \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y) :=\n@convex_on_iff_forall_pos \ud835\udd5c E \u03b2\u1d52\u1d48 _ _ _ _ _ _ _\n\nlemma convex_on_iff_pairwise_pos {s : set E} {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    s.pairwise (\u03bb x y, \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y) :=\nbegin\n  rw convex_on_iff_forall_pos,\n  refine and_congr_right' \u27e8\u03bb h x hx y hy _ a b ha hb hab, h hx hy ha hb hab,\n    \u03bb h x y hx hy a b ha hb hab, _\u27e9,\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 \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n   s.pairwise (\u03bb x y, \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)) :=\n@convex_on_iff_pairwise_pos \ud835\udd5c E \u03b2\u1d52\u1d48 _ _ _ _ _ _ _\n\n/-- A linear map is convex. -/\nlemma linear_map.convex_on (f : E \u2192\u2097[\ud835\udd5c] \u03b2) {s : set E} (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]\u27e9\n\n/-- A linear map is concave. -/\nlemma linear_map.concave_on (f : E \u2192\u2097[\ud835\udd5c] \u03b2) {s : set E} (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]\u27e9\n\nlemma strict_convex_on.convex_on {s : set E} {f : E \u2192 \u03b2} (hf : strict_convex_on \ud835\udd5c s f) :\n  convex_on \ud835\udd5c s f :=\nconvex_on_iff_pairwise_pos.mpr \u27e8hf.1, \u03bb x hx y hy hxy a b ha hb hab, (hf.2 hx hy hxy ha hb hab).le\u27e9\n\nlemma strict_concave_on.concave_on {s : set E} {f : E \u2192 \u03b2} (hf : strict_concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c s f :=\nhf.dual.convex_on\n\nsection ordered_smul\nvariables [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma strict_convex_on.convex_lt (hf : strict_convex_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | f x < r} :=\nconvex_iff_pairwise_pos.2 $ \u03bb x hx y hy hxy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 hxy ha hb hab\n                  ... \u2264 a \u2022 r + b \u2022 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\u27e9\n\nlemma strict_concave_on.convex_gt (hf : strict_concave_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 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 \u2192 \u03b2}\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 \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y` only for `x < y` and positive `a`,\n`b`. The main use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order.\n-/\nlemma linear_order.convex_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y) : convex_on \ud835\udd5c s f :=\nbegin\n  refine convex_on_iff_pairwise_pos.2 \u27e8hs, \u03bb x hx y hy hxy a b ha hb hab, _\u27e9,\n  wlog h : x \u2264 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 \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \u211d` however one can apply it, e.g., to `\u211d^n` with lexicographic order. -/\nlemma linear_order.concave_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n     a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)) : concave_on \ud835\udd5c s f :=\n@linear_order.convex_on_of_lt _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ 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 \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order. -/\nlemma linear_order.strict_convex_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y) : strict_convex_on \ud835\udd5c s f :=\nbegin\n  refine \u27e8hs, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n  wlog h : x \u2264 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 \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order. -/\nlemma linear_order.strict_concave_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n     a \u2022 f x + b \u2022 f y < f (a \u2022 x + b \u2022 y)) : strict_concave_on \ud835\udd5c s f :=\n@linear_order.strict_convex_on_of_lt _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ _ _ hs hf\n\nend linear_order\nend module\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c F] [has_scalar \ud835\udd5c \u03b2]\n\n/-- If `g` is convex on `s`, so is `(f \u2218 g)` on `f \u207b\u00b9' s` for a linear `f`. -/\nlemma convex_on.comp_linear_map {f : F \u2192 \u03b2} {s : set F} (hf : convex_on \ud835\udd5c s f) (g : E \u2192\u2097[\ud835\udd5c] F) :\n  convex_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 g) :=\n\u27e8hf.1.linear_preimage _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (g (a \u2022 x + b \u2022 y)) = f (a \u2022 (g x) + b \u2022 (g y)) : by rw [g.map_add, g.map_smul, g.map_smul]\n                      ... \u2264 a \u2022 f (g x) + b \u2022 f (g y) : hf.2 hx hy ha hb hab\u27e9\n\n/-- If `g` is concave on `s`, so is `(g \u2218 f)` on `f \u207b\u00b9' s` for a linear `f`. -/\nlemma concave_on.comp_linear_map {f : F \u2192 \u03b2} {s : set F} (hf : concave_on \ud835\udd5c s f) (g : E \u2192\u2097[\ud835\udd5c] F) :\n  concave_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 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 \u03b2]\n\nsection distrib_mul_action\nvariables [has_scalar \ud835\udd5c E] [distrib_mul_action \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma strict_convex_on.add_convex_on (hf : strict_convex_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f + g) :=\n\u27e8hf.1, \u03bb x y hx hy hxy a b ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) + g (a \u2022 x + b \u2022 y) < (a \u2022 f x + b \u2022 f y) + (a \u2022 g x + b \u2022 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 \u2022 (f x + g x) + b \u2022 (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]\u27e9\n\nlemma convex_on.add_strict_convex_on (hf : convex_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f + g) :=\n(add_comm g f) \u25b8 hg.add_convex_on hf\n\nlemma strict_convex_on.add (hf : strict_convex_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f + g) :=\n\u27e8hf.1, \u03bb x y hx hy hxy a b ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) + g (a \u2022 x + b \u2022 y) < (a \u2022 f x + b \u2022 f y) + (a \u2022 g x + b \u2022 g y)\n      : add_lt_add (hf.2 hx hy hxy ha hb hab) (hg.2 hx hy hxy ha hb hab)\n    ... = a \u2022 (f x + g x) + b \u2022 (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]\u27e9\n\nlemma strict_concave_on.add_concave_on (hf : strict_concave_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add_convex_on hg.dual\n\nlemma concave_on.add_strict_concave_on (hf : concave_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add_strict_convex_on hg.dual\n\nlemma strict_concave_on.add (hf : strict_concave_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.convex_lt (hf : convex_on \ud835\udd5c s f) (r : \u03b2) : convex \ud835\udd5c {x \u2208 s | f x < r} :=\nconvex_iff_forall_pos.2 $ \u03bb x y hx hy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a \u2022 x + b \u2022 y)\n        \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 ha.le hb.le hab\n    ... < a \u2022 r + b \u2022 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 _\u27e9\n\nlemma concave_on.convex_gt (hf : concave_on \ud835\udd5c s f) (r : \u03b2) : convex \ud835\udd5c {x \u2208 s | r < f x} :=\nhf.dual.convex_lt r\n\nlemma convex_on.open_segment_subset_strict_epigraph (hf : convex_on \ud835\udd5c s f) (p q : E \u00d7 \u03b2)\n  (hp : p.1 \u2208 s \u2227 f p.1 < p.2) (hq : q.1 \u2208 s \u2227 f q.1 \u2264 q.2) :\n  open_segment \ud835\udd5c p q \u2286 {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 < p.2} :=\nbegin\n  rintro _ \u27e8a, b, ha, hb, hab, rfl\u27e9,\n  refine \u27e8hf.1 hp.1 hq.1 ha.le hb.le hab, _\u27e9,\n  calc f (a \u2022 p.1 + b \u2022 q.1) \u2264 a \u2022 f p.1 + b \u2022 f q.1 : hf.2 hp.1 hq.1 ha.le hb.le hab\n  ... < a \u2022 p.2 + b \u2022 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 \ud835\udd5c s f) (p q : E \u00d7 \u03b2)\n  (hp : p.1 \u2208 s \u2227 p.2 < f p.1) (hq : q.1 \u2208 s \u2227 q.2 \u2264 f q.1) :\n  open_segment \ud835\udd5c p q \u2286 {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 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 \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 < p.2} :=\nconvex_iff_open_segment_subset.mpr $\n  \u03bb p q hp hq, hf.open_segment_subset_strict_epigraph p q hp \u27e8hq.1, hq.2.le\u27e9\n\nlemma concave_on.convex_strict_hypograph (hf : concave_on \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 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 \u03b2] [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2]\n  {s : set E} {f g : E \u2192 \u03b2}\n\n/-- The pointwise maximum of convex functions is convex. -/\nlemma convex_on.sup (hf : convex_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  convex_on \ud835\udd5c s (f \u2294 g) :=\nbegin\n  refine \u27e8hf.left, \u03bb x y hx hy a b ha hb hab, sup_le _ _\u27e9,\n  { calc f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.right hx hy ha hb hab\n     ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \u2022 x + b \u2022 y) \u2264 a \u2022 g x + b \u2022 g y : hg.right hx hy ha hb hab\n     ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  concave_on \ud835\udd5c s (f \u2293 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 \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f \u2294 g) :=\n\u27e8hf.left, \u03bb x y hx hy hxy a b ha hb hab, max_lt\n  (calc f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx hy hxy ha hb hab\n    ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \u2022 x + b \u2022 y) < a \u2022 g x + b \u2022 g y : hg.2 hx hy hxy ha hb hab\n    ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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))\u27e9\n\n/-- The pointwise minimum of strictly concave functions is strictly concave. -/\nlemma strict_concave_on.inf (hf : strict_concave_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n   strict_concave_on \ud835\udd5c s (f \u2293 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 \u2264 a) (hb : 0 \u2264 b) (hab : a + b = 1) :\n  f (a \u2022 x + b \u2022 y) \u2264 max (f x) (f y) :=\ncalc\n  f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha hb hab\n  ... \u2264 a \u2022 max (f x) (f y) + b \u2022 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 \u2264 a) (hb : 0 \u2264 b) (hab : a + b = 1) :\n  min (f x) (f y) \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  (hz : z \u2208 [x -[\ud835\udd5c] y]) :\n  f z \u2264 max (f x) (f y) :=\nlet \u27e8a, b, ha, hb, hab, hz\u27e9 := hz in hz \u25b8 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  (hz : z \u2208 [x -[\ud835\udd5c] y]) :\n  min (f x) (f y) \u2264 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  f (a \u2022 x + b \u2022 y) < max (f x) (f y) :=\ncalc\n  f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx hy hxy ha hb hab\n  ... \u2264 a \u2022 max (f x) (f y) + b \u2022 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  min (f x) (f y) < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) (hz : z \u2208 open_segment \ud835\udd5c x y) :\n  f z < max (f x) (f y) :=\nlet \u27e8a, b, ha, hb, hab, hz\u27e9 := hz in hz \u25b8 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) (hz : z \u2208 open_segment \ud835\udd5c 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 \u03b2]\n\nsection ordered_smul\nvariables [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma convex_on.le_left_of_right_le' (hf : convex_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 \u2264 b) (hab : a + b = 1) (hfy : f y \u2264 f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) \u2264 f x :=\nle_of_not_lt $ \u03bb h, lt_irrefl (f (a \u2022 x + b \u2022 y)) $\n  calc\n    f (a \u2022 x + b \u2022 y)\n        \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha.le hb hab\n    ... < a \u2022 f (a \u2022 x + b \u2022 y) + b \u2022 f (a \u2022 x + b \u2022 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 \u2022 x + b \u2022 y) : convex.combo_self hab _\n\nlemma concave_on.left_le_of_le_right' (hf : concave_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 \u2264 b) (hab : a + b = 1) (hfy : f (a \u2022 x + b \u2022 y) \u2264 f y) :\n  f x \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 \u2264 a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x \u2264 f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) \u2264 f y :=\nbegin\n  rw add_comm at \u22a2 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 \u2264 a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a \u2022 x + b \u2022 y) \u2264 f x) :\n  f y \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f y \u2264 f z) :\n  f z \u2264 f x :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f z \u2264 f y) :\n  f x \u2264 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f x \u2264 f z) :\n  f z \u2264 f y :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f z \u2264 f x) :\n  f y \u2264 f z :=\nhf.dual.le_right_of_left_le hx hy hz hxz\n\nend ordered_smul\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\n/- The following lemmas don't require `module \ud835\udd5c E` if you add the hypothesis `x \u2260 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f y < f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) < f x :=\nnot_le.1 $ \u03bb h, lt_irrefl (f (a \u2022 x + b \u2022 y)) $\n  calc\n    f (a \u2022 x + b \u2022 y)\n        < a \u2022 f x + b \u2022 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 \u2022 f (a \u2022 x + b \u2022 y) + b \u2022 f (a \u2022 x + b \u2022 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 \u2022 x + b \u2022 y) : convex.combo_self hab _\n\nlemma strict_concave_on.left_lt_of_lt_right' (hf : strict_concave_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f (a \u2022 x + b \u2022 y) < f y) :\n  f x < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x < f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) < f y :=\nbegin\n  rw add_comm at \u22a2 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a \u2022 x + b \u2022 y) < f x) :\n  f y < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f y < f z) :\n  f z < f x :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f x < f z) :\n  f z < f y :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c 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 \u03b2] [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\n/-- A function `-f` is convex iff `f` is concave. -/\n@[simp] lemma neg_convex_on_iff : convex_on \ud835\udd5c s (-f) \u2194 concave_on \ud835\udd5c s f :=\nbegin\n  split,\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy a b ha hb hab, _\u27e9,\n    simp [neg_apply, neg_le, add_comm] at h,\n    exact h hx hy ha hb hab },\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy a b ha hb hab, _\u27e9,\n    rw \u2190neg_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 \ud835\udd5c s (-f) \u2194 convex_on \ud835\udd5c s f:=\nby rw [\u2190 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 \ud835\udd5c s (-f) \u2194 strict_concave_on \ud835\udd5c s f :=\nbegin\n  split,\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n    simp [neg_apply, neg_lt, add_comm] at h,\n    exact h hx hy hxy ha hb hab },\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n    rw \u2190neg_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 \ud835\udd5c s (-f) \u2194 strict_convex_on \ud835\udd5c s f :=\nby rw [\u2190 neg_strict_convex_on_iff, neg_neg f]\n\nalias neg_convex_on_iff \u2194 _ concave_on.neg\nalias neg_concave_on_iff \u2194 _ convex_on.neg\nalias neg_strict_convex_on_iff \u2194 _ strict_concave_on.neg\nalias neg_strict_concave_on_iff \u2194 _ strict_convex_on.neg\n\nlemma convex_on.sub (hf : convex_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) : convex_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add hg.neg\n\nlemma concave_on.sub (hf : concave_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) : concave_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add hg.neg\n\nlemma strict_convex_on.sub (hf : strict_convex_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add hg.neg\n\nlemma strict_concave_on.sub (hf : strict_concave_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add hg.neg\n\nlemma convex_on.sub_strict_concave_on (hf : convex_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add_strict_convex_on hg.neg\n\nlemma concave_on.sub_strict_convex_on (hf : concave_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add_strict_concave_on hg.neg\n\nlemma strict_convex_on.sub_concave_on (hf : strict_convex_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add_convex_on hg.neg\n\nlemma strict_concave_on.sub_convex_on (hf : strict_concave_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 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 \u03b2] [module \ud835\udd5c E] [has_scalar \ud835\udd5c \u03b2]\n  {s : set E} {f : E \u2192 \u03b2}\n\n/-- Right translation preserves strict convexity. -/\nlemma strict_convex_on.translate_right (hf : strict_convex_on \ud835\udd5c s f) (c : E) :\n  strict_convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\n\u27e8hf.1.translate_preimage_right _, \u03bb x y hx hy hxy a b ha hb hab,\n  calc\n    f (c + (a \u2022 x + b \u2022 y)) = f (a \u2022 (c + x) + b \u2022 (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... < a \u2022 f (c + x) + b \u2022 f (c + y) : hf.2 hx hy ((add_right_injective c).ne hxy) ha hb hab\u27e9\n\n/-- Right translation preserves strict concavity. -/\nlemma strict_concave_on.translate_right (hf : strict_concave_on \ud835\udd5c s f) (c : E) :\n  strict_concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves strict convexity. -/\nlemma strict_convex_on.translate_left (hf : strict_convex_on \ud835\udd5c s f) (c : E) :\n  strict_convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c s f) (c : E) :\n  strict_concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection module\nvariables [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.smul {c : \ud835\udd5c} (hc : 0 \u2264 c) (hf : convex_on \ud835\udd5c s f) : convex_on \ud835\udd5c s (\u03bb x, c \u2022 f x) :=\n\u27e8hf.1, \u03bb x y hx hy a b ha hb hab,\n  calc\n    c \u2022 f (a \u2022 x + b \u2022 y) \u2264 c \u2022 (a \u2022 f x + b \u2022 f y)\n      : smul_le_smul_of_nonneg (hf.2 hx hy ha hb hab) hc\n    ... = a \u2022 (c \u2022 f x) + b \u2022 (c \u2022 f y)\n      : by rw [smul_add, smul_comm c, smul_comm c]; apply_instance\u27e9\n\nlemma concave_on.smul {c : \ud835\udd5c} (hc : 0 \u2264 c) (hf : concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c s (\u03bb x, c \u2022 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 \ud835\udd5c] [add_comm_group E] [add_comm_group F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c F] [has_scalar \ud835\udd5c \u03b2]\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 \u2192 \u03b2} (g : E \u2192\u1d43[\ud835\udd5c] F) {s : set F} (hf : convex_on \ud835\udd5c s f) :\n  convex_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 g) :=\n\u27e8hf.1.affine_preimage _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    (f \u2218 g) (a \u2022 x + b \u2022 y) = f (g (a \u2022 x + b \u2022 y))         : rfl\n                       ...  = f (a \u2022 (g x) + b \u2022 (g y))     : by rw [convex.combo_affine_apply hab]\n                       ...  \u2264 a \u2022 f (g x) + b \u2022 f (g y)     : hf.2 hx hy ha hb hab\u27e9\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 \u2192 \u03b2} (g : E \u2192\u1d43[\ud835\udd5c] F) {s : set F} (hf : concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 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 \ud835\udd5c] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection has_scalar\nvariables [has_scalar \ud835\udd5c E] [has_scalar \ud835\udd5c \u03b2] {s : set E}\n\nlemma convex_on_iff_div {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 0 < a + b\n  \u2192 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) \u2264 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y :=\nand_congr iff.rfl\n\u27e8begin\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 [\u2190add_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\u27e9\n\nlemma concave_on_iff_div {f : E \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b\n  \u2192 0 < a + b \u2192 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y \u2264 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) :=\n@convex_on_iff_div _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ _\n\nlemma strict_convex_on_iff_div {f : E \u2192 \u03b2} :\n  strict_convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a\n    \u2192 0 < b \u2192 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) < (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y :=\nand_congr iff.rfl\n\u27e8begin\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 [\u2190add_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\u27e9\n\nlemma strict_concave_on_iff_div {f : E \u2192 \u03b2} :\n  strict_concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a\n    \u2192 0 < b \u2192 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y < f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) :=\n@strict_convex_on_iff_div _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ _\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\u27e8@continuous_map.to_fun, @continuous_map.id, @continuous_map.comp, @continuous_map.coe_injective\u27e9\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  (\ud835\udfd9 X : X \u2192 X) x = x := rfl\n\n@[simp] lemma comp_app {X Y Z : Top.{u}} (f : X \u27f6 Y) (g : Y \u27f6 Z) (x : X) :\n  (f \u226b g : X \u2192 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 := \u27e8X\u27e9\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 := \u27e8Top.of empty\u27e9\n\n/-- The discrete topology on any type. -/\ndef discrete : Type u \u2964 Top.{u} :=\n{ obj := \u03bb X, \u27e8X, \u22a5\u27e9,\n  map := \u03bb X Y f, { to_fun := f, continuous_to_fun := continuous_bot } }\n\ninstance {X : Type u} : discrete_topology (discrete.obj X) := \u27e8rfl\u27e9\n\n/-- The trivial topology on any type. -/\ndef trivial : Type u \u2964 Top.{u} :=\n{ obj := \u03bb X, \u27e8X, \u22a4\u27e9,\n  map := \u03bb 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 \u2243\u209c Y) : X \u2245 Y :=\n{ hom := \u27e8f\u27e9,\n  inv := \u27e8f.symm\u27e9 }\n\n/-- Any isomorphism in `Top` induces a homeomorphism. -/\n@[simps] def homeo_of_iso {X Y : Top.{u}} (f : X \u2245 Y) : X \u2243\u209c Y :=\n{ to_fun := f.hom,\n  inv_fun := f.inv,\n  left_inv := \u03bb x, by simp,\n  right_inv := \u03bb 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 \u2243\u209c 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 \u2245 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 \u27f6 Y) (g : Y \u27f6 Z) [is_iso g] :\n  open_embedding (f \u226b g) \u2194 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 \u27f6 Y) (g : Y \u27f6 Z) [is_iso f] :\n  open_embedding (f \u226b g) \u2194 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 \u03bb 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": "import data.nat.basic\nimport tactic.squeeze\nimport data.list.perm\n\nnamespace tactic\nnamespace interactive\nsetup_tactic_parser\n\n/-- version of squeeze_simp that tests whether the output matches the expected output -/\nmeta def squeeze_simp_test\n  (key : parse cur_pos)\n  (slow_and_accurate : parse (tk \"?\")?)\n  (use_iota_eqn : parse (tk \"!\")?) (no_dflt : parse only_flag) (hs : parse simp_arg_list)\n  (attr_names : parse with_ident_list) (locat : parse location)\n  (cfg : parse struct_inst?)\n  (_ : parse (tk \"=\")) (l : parse simp_arg_list) : tactic unit :=\ndo (cfg',c) \u2190 parse_config cfg,\n   squeeze_simp_core slow_and_accurate.is_some no_dflt hs\n     (\u03bb l_no_dft l_args, simp use_iota_eqn none l_no_dft l_args attr_names locat cfg')\n     (\u03bb args, guard ((args.map to_string).perm (l.map to_string)) <|> fail!\"{args} expected.\")\nend interactive\nend tactic\n\n-- Test that squeeze_simp succeeds when it closes the goal.\nexample : 1 = 1 :=\nby { squeeze_simp_test = [eq_self_iff_true] }\n\n-- Test that `squeeze_simp` succeeds when given arguments.\nexample {a b : \u2115} (h : a + a = b) : b + 0 = 2 * a :=\nby { squeeze_simp_test [\u2190h, two_mul] = [\u2190h, two_mul, add_zero] }\n\n-- Test that the order of the given hypotheses do not matter.\nexample {a b : \u2115} (h : a + a = b) : b + 0 = 2 * a :=\nby { squeeze_simp_test [\u2190h, two_mul] = [\u2190h, add_zero, two_mul] }\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/squeeze.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300573952054, "lm_q2_score": 0.7090191276365462, "lm_q1q2_score": 0.49810724843280124}}
{"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 \u2022 x = 0`.\n* `submodule.torsion_by R M a` : the `a`-torsion submodule, containing all elements `x` of `M` such\n  that `a \u2022 x = 0`.\n* `submodule.torsion_by_set R M s` : the submodule containing all elements `x` of `M` such that\n  `a \u2022 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 \u2022 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 \u2022 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 \u29f8 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 `\u220f 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 \u2022 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 \u29f8 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 \u2022 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 \u2208 torsion_of R M x \u2194 a \u2022 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 \u29f8 torsion_of R M x) \u2243\u2097[R] (R \u2219 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 \u2022 \u27e8x, submodule.mem_span_singleton_self x\u27e9 := 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 \u2022 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 \u2022 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 \u2022 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 | \u2203 a : S, a \u2022 x = 0 },\n  zero_mem' := \u27e81, smul_zero _\u27e9,\n  add_mem' := \u03bb x y \u27e8a, hx\u27e9 \u27e8b, hy\u27e9,\n    \u27e8b * a,\n      by rw [smul_add, mul_smul, mul_comm, mul_smul, hx, hy, smul_zero, smul_zero, add_zero]\u27e9,\n  smul_mem' := \u03bb a x \u27e8b, h\u27e9, \u27e8b, by rw [smul_comm, h, smul_zero]\u27e9 }\n\n/-- The torsion submodule, containing all elements `x` of `M` such that  `a \u2022 x = 0` for some\n  non-zero-divisor `a` in `R`. -/\n@[reducible] def torsion := torsion' R M R\u2070\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) := \u2200 \u2983x : M\u2984, a \u2022 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) := \u2200 \u2983x : M\u2984 \u2983a : s\u2984, (a : R) \u2022 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] := \u2200 \u2983x : M\u2984, \u2203 a : S, a \u2022 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 := \u2200 \u2983x : M\u2984, \u2203 a : R\u2070, a \u2022 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 \u2022 x = 0 := subtype.ext x.prop\n@[simp] lemma smul_coe_torsion_by (x : torsion_by R M a) : a \u2022 (x : M) = 0 := x.prop\n@[simp] lemma mem_torsion_by_iff (x : M) : x \u2208 torsion_by R M a \u2194 a \u2022 x = 0 := iff.rfl\n\n@[simp] lemma mem_torsion_by_set_iff (x : M) :\n  x \u2208 torsion_by_set R M s \u2194 \u2200 a : s, (a : R) \u2022 x = 0 :=\nbegin\n  refine \u27e8\u03bb h \u27e8a, ha\u27e9, mem_Inf.mp h _ (set.mem_image_of_mem _ ha), \u03bb h, mem_Inf.mpr _\u27e9,\n  rintro _ \u27e8a, ha, rfl\u27e9, exact h \u27e8a, ha\u27e9\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 (\u03bb x hx, _) (torsion_by_set_le_torsion_by_set_of_subset subset_span),\n  rw mem_torsion_by_set_iff at hx \u22a2,\n  suffices : ideal.span s \u2264 ideal.torsion_of R M x,\n  { rintro \u27e8a, ha\u27e9, exact this ha },\n  rw ideal.span_le, exact \u03bb a ha, hx \u27e8a, ha\u27e9\nend\n\nlemma torsion_by_span_singleton_eq : torsion_by_set R M (R \u2219 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 \u2223 b) :\n  torsion_by R M a \u2264 torsion_by R M b :=\nbegin\n  rw [\u2190 torsion_by_span_singleton_eq, \u2190 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 = \u22a5 :=\neq_bot_iff.mpr (\u03bb _ 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 = \u22a5 :=\nby { rw [eq_bot_iff, \u2190 torsion_by_one, \u2190 torsion_by_singleton_eq],\n  exact torsion_by_set_le_torsion_by_set_of_subset (\u03bb _ _, trivial) }\n\nend submodule\nopen submodule\nnamespace module\n\n@[simp] lemma is_torsion_by_singleton_iff : is_torsion_by_set R M {a} \u2194 is_torsion_by R M a :=\nbegin\n  refine \u27e8\u03bb h x, @h _ \u27e8_, set.mem_singleton _\u27e9, \u03bb h x, _\u27e9,\n  rintro \u27e8b, rfl : b = a\u27e9, exact @h _\nend\n\nlemma is_torsion_by_set_iff_torsion_by_set_eq_top :\n  is_torsion_by_set R M s \u2194 submodule.torsion_by_set R M s = \u22a4 :=\n\u27e8\u03bb h, eq_top_iff.mpr (\u03bb _ _, (mem_torsion_by_set_iff _ _).mpr $ @h _),\n  \u03bb h x, by { rw [\u2190 mem_torsion_by_set_iff, h], trivial }\u27e9\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 \u2194 torsion_by R M a = \u22a4 :=\nby rw [\u2190 torsion_by_singleton_eq, \u2190 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 \u2194 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 \u2219 a) \u2194 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\u03bb \u27e8x, hx\u27e9 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 := \u03bb _, smul_torsion_by _ _\n\n@[simp] lemma torsion_by_torsion_by_eq_top : torsion_by R (torsion_by R M a) a = \u22a4 :=\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 = \u22a4 :=\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)\u1d52\u1d48 _ _\n  annihilator (\u03bb I, torsion_by_set R M $ I.of_dual) :=\n\u03bb A I, \u27e8\u03bb h x hx, (mem_torsion_by_set_iff _ _).mpr $ \u03bb \u27e8a, ha\u27e9, mem_annihilator.mp (h ha) x hx,\n  \u03bb h a ha, mem_annihilator.mpr $ \u03bb x hx, (mem_torsion_by_set_iff _ _).mp (h hx) \u27e8a, ha\u27e9\u27e9\n\nvariables {R M}\nsection coprime\nopen_locale big_operators\nvariables {\u03b9 : Type*} {p : \u03b9 \u2192 ideal R} {S : finset \u03b9}\nvariables (hp : (S : set \u03b9).pairwise $ \u03bb i j, p i \u2294 p j = \u22a4)\ninclude hp\n\nlemma supr_torsion_by_ideal_eq_torsion_by_infi :\n  (\u2a06 i \u2208 S, torsion_by_set R M $ p i) = torsion_by_set R M \u2191(\u2a05 i \u2208 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 (\u03bb i, \u2a05 (H : i \u2208 S), p i) i).trans (infi_le _ is), },\n  { intros x hx,\n    rw mem_supr_finset_iff_exists_sum,\n    obtain \u27e8\u03bc, h\u03bc\u27e9 := (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 \u27e8\u03bb i, \u27e8(\u03bc i : R) \u2022 x, _\u27e9, _\u27e9,\n    { rw mem_torsion_by_set_iff at hx \u22a2,\n      rintro \u27e8a, ha\u27e9, rw smul_smul,\n      suffices : a * \u03bc i \u2208 \u2a05 i \u2208 S, p i, from hx \u27e8_, this\u27e9,\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 (\u03bc i), simp only [mem_infi] at this,\n        exact ideal.mul_mem_left _ _ (this j hj ij) } },\n    { simp_rw coe_mk, rw [\u2190 finset.sum_smul, h\u03bc, one_smul] } }\nend\n\nlemma sup_indep_torsion_by_ideal : S.sup_indep (\u03bb i, torsion_by_set R M $ p i) :=\n\u03bb T hT i hi hiT, begin\n  rw [disjoint_iff, finset.sup_eq_supr,\n    supr_torsion_by_ideal_eq_torsion_by_infi $ \u03bb 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 \u22a2,\n  rw [\u2190 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 : \u03b9 \u2192 R} (hq : (S : set \u03b9).pairwise $ is_coprime on q)\ninclude hq\n\nlemma supr_torsion_by_eq_torsion_by_prod :\n  (\u2a06 i \u2208 S, torsion_by R M $ q i) = torsion_by R M (\u220f i in S, q i) :=\nbegin\n  rw [\u2190 torsion_by_span_singleton_eq, ideal.submodule_span_eq,\n    \u2190 ideal.finset_inf_span_singleton _ _ hq, finset.inf_eq_infi,\n    \u2190 supr_torsion_by_ideal_eq_torsion_by_infi],\n  { congr, ext : 1, congr, ext : 1, exact (torsion_by_span_singleton_eq _).symm },\n  { exact \u03bb 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 (\u03bb i, torsion_by R M $ q i) :=\nbegin\n  convert sup_indep_torsion_by_ideal\n    (\u03bb 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 {\u03b9 : Type*} [decidable_eq \u03b9] {S : finset \u03b9}\n\n/--If the `p i` are pairwise coprime, a `\u2a05 i, p i`-torsion module is the internal direct sum of\nits `p i`-torsion submodules.-/\nlemma torsion_by_set_is_internal {p : \u03b9 \u2192 ideal R}\n  (hp : (S : set \u03b9).pairwise $ \u03bb i j, p i \u2294 p j = \u22a4)\n  (hM : module.is_torsion_by_set R M (\u2a05 i \u2208 S, p i : ideal R)) :\n  direct_sum.is_internal (\u03bb 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'' \u2191S $ \u03bb 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 `\u220f i, q i`-torsion module is the internal direct sum of\nits `q i`-torsion submodules.-/\nlemma torsion_by_is_internal {q : \u03b9 \u2192 R} (hq : (S : set \u03b9).pairwise $ is_coprime on q)\n  (hM : module.is_torsion_by R M $ \u220f i in S, q i) :\n  direct_sum.is_internal (\u03bb i : S, torsion_by R M $ q i) :=\nbegin\n  rw [\u2190 module.is_torsion_by_span_singleton_iff, ideal.submodule_span_eq,\n    \u2190 ideal.finset_inf_span_singleton _ _ hq, finset.inf_eq_infi] at hM,\n  convert torsion_by_set_is_internal\n    (\u03bb 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 \u29f8 I) M :=\n{ smul := \u03bb b x, quotient.lift_on' b (\u2022 x) $ \u03bb b\u2081 b\u2082 h, begin\n    show b\u2081 \u2022 x = b\u2082 \u2022 x,\n    have : (-b\u2081 + b\u2082) \u2022 x = 0 := @hM x \u27e8_, h\u27e9,\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 \u2022 x = b \u2022 x := rfl\n\n/-- A `(R \u29f8 I)`-module is a `R`-module which `is_torsion_by_set R M I`. -/\ndef is_torsion_by_set.module : module (R \u29f8 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 \u29f8 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 \u2022 x = b \u2022 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 \u29f8 I) (torsion_by_set R M I) :=\n{ smul_assoc := \u03bb b d x, quotient.induction_on' d $ \u03bb c, (smul_assoc b c x : _) }\n\n/-- The `a`-torsion submodule as a `(R \u29f8 R\u2219a)`-module. -/\ninstance (a : R) : module (R \u29f8 R \u2219 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 \u2219 a) b \u2022 x = b \u2022 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 \u29f8 R \u2219 a) (torsion_by R M a) :=\n{ smul_assoc := \u03bb b d x, quotient.induction_on' d $ \u03bb 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 \u2208 torsion' R M S \u2194 \u2203 a : S, a \u2022 x = 0 := iff.rfl\n@[simp] lemma mem_torsion_iff (x : M) : x \u2208 torsion R M \u2194 \u2203 a : R\u2070, a \u2022 x = 0 := iff.rfl\n\n@[simps] instance : has_scalar S (torsion' R M S) :=\n\u27e8\u03bb s x, \u27e8s \u2022 x, by { obtain \u27e8x, a, h\u27e9 := x, use a, dsimp, rw [smul_comm, h, smul_zero] }\u27e9\u27e9\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 (\u03bb (c : S) x, rfl)\ninstance : smul_comm_class S R (torsion' R M S) := \u27e8\u03bb s a x, subtype.ext $ smul_comm _ _ _\u27e9\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 \u2194 torsion' R M S = \u22a4 :=\n\u27e8\u03bb h, eq_top_iff.mpr (\u03bb _ _, @h _), \u03bb h x, by { rw [\u2190 @mem_torsion'_iff R, h], trivial }\u27e9\n\n/-- The `S`-torsion submodule is a `S`-torsion module. -/\nlemma torsion'_is_torsion' : is_torsion' (torsion' R M S) S := \u03bb \u27e8x, \u27e8a, h\u27e9\u27e9, \u27e8a, subtype.ext h\u27e9\n\n@[simp] lemma torsion'_torsion'_eq_top : torsion' R (torsion' R M S) S = \u22a4 :=\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) = \u22a4 := torsion'_torsion'_eq_top R\u2070\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\u2070\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  \u2203 I : ideal R, (I : set R) \u2229 R\u2070 \u2260 \u2205 \u2227 module.is_torsion_by_set R M I :=\nbegin\n  cases (module.finite_def.mp infer_instance : (\u22a4 : submodule R M).fg) with S h,\n  refine \u27e8\u220f x in S, ideal.torsion_of R M x, _, _\u27e9,\n  { rw set.ne_empty_iff_nonempty,\n    refine \u27e8_, _, (\u220f x in S, (@hM x).some : R\u2070).2\u27e9,\n    rw [subtype.val_eq_coe, submonoid.coe_finset_prod],\n    apply ideal.prod_mem_prod,\n    exact \u03bb x _, (@hM x).some_spec },\n  { rw [module.is_torsion_by_set_iff_torsion_by_set_eq_top, eq_top_iff, \u2190 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 \u27e8a, ha\u27e9, 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 \u2219 x).annihilator \u2260 \u22a5 } :=\nbegin\n  ext x, simp_rw [submodule.ne_bot_iff, mem_annihilator, mem_span_singleton],\n  exact \u27e8\u03bb \u27e8a, hax\u27e9, \u27e8a, \u03bb _ \u27e8b, hb\u27e9, by rw [\u2190 hb, smul_comm, \u2190 submonoid.smul_def, hax, smul_zero],\n    non_zero_divisors.coe_ne_zero _\u27e9,\n    \u03bb \u27e8a, hax, ha\u27e9, \u27e8\u27e8_, mem_non_zero_divisors_of_ne_zero ha\u27e9, hax x \u27e81, one_smul _ _\u27e9\u27e9\u27e9\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 \u2194 torsion R M = \u22a5 :=\nbegin\n  split; intro h,\n  { haveI : no_zero_smul_divisors R M := h,\n    rw eq_bot_iff, rintro x \u27e8a, hax\u27e9,\n    change (a : R) \u2022 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 := \u03bb a x hax, begin\n      by_cases ha : a = 0,\n      { left, exact ha },\n      { right, rw [\u2190 mem_bot _, \u2190 h],\n        exact \u27e8\u27e8a, mem_non_zero_divisors_of_ne_zero ha\u27e9, hax\u27e9 }\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 \u29f8 torsion R M) = \u22a5 :=\neq_bot_iff.mpr $ \u03bb z, quotient.induction_on' z $ \u03bb x \u27e8a, hax\u27e9,\nbegin\n  rw [quotient.mk'_eq_mk, \u2190 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 \u27e8b * a, (mul_smul _ _ _).trans h\u27e9\nend\n\ninstance no_zero_smul_divisors [is_domain R] : no_zero_smul_divisors R (M \u29f8 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) \u2194 \u2200 x : M, \u2203 n : \u2115, p ^ n \u2022 x = 0 :=\n\u27e8\u03bb h x, let \u27e8\u27e8a, \u27e8n, rfl\u27e9\u27e9, hx\u27e9 := @h x in \u27e8n, hx\u27e9,\n\u03bb h x, let \u27e8n, hn\u27e9 := h x in \u27e8\u27e8_, \u27e8n, rfl\u27e9\u27e9, hn\u27e9\u27e9\n\n/--In a `p ^ \u221e`-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 \u2022 x = 0`.-/\ndef p_order {p : R} (hM : is_torsion' M $ submonoid.powers p) (x : M)\n  [\u03a0 n : \u2115, decidable (p ^ n \u2022 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  [\u03a0 n : \u2115, decidable (p ^ n \u2022 x = 0)] : p ^ p_order hM x \u2022 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] [\u03a0 x : M, decidable (x = 0)]\n\nlemma exists_is_torsion_by {p : R} (hM : is_torsion' M $ submonoid.powers p)\n  (d : \u2115) (hd : d \u2260 0) (s : fin d \u2192 M) (hs : span R (set.range s) = \u22a4) :\n  \u2203 j : fin d, module.is_torsion_by R M (p ^ p_order hM (s j)) :=\nbegin\n  let oj := list.argmax (\u03bb i, p_order hM $ s i) (list.fin_range d),\n  have hoj : oj.is_some := (option.ne_none_iff_is_some.mp $\n    \u03bb 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, \u2190 hs, submodule.span_le,\n    set.range_subset_iff], intro i, change _ \u2022 _ = _,\n  have : p_order hM (s i) \u2264 p_order hM (s $ option.get hoj) :=\n    list.le_of_mem_argmax (list.mem_fin_range i) (option.get_mem hoj),\n  rw [\u2190 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 \u2208 R\u2070) :\n  torsion_by R (R \u29f8 R \u2219 a * b) a = R \u2219 (mk _ b) :=\nbegin\n  ext x, rw [mem_torsion_by_iff, mem_span_singleton],\n  obtain \u27e8x, rfl\u27e9 := mk_surjective x, split; intro h,\n  { rw [\u2190 mk_eq_mk, \u2190 quotient.mk_smul, quotient.mk_eq_zero, mem_span_singleton] at h,\n    obtain \u27e8c, h\u27e9 := 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 [\u2190 h, \u2190 mk_eq_mk, \u2190 quotient.mk_smul, smul_eq_mul, mk_eq_mk] },\n  { obtain \u27e8c, h\u27e9 := h,\n    rw [\u2190 h, smul_comm, \u2190 mk_eq_mk, \u2190 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 \u2194 module.is_torsion \u2115 M :=\nbegin\n  refine \u27e8\u03bb h x, _, \u03bb h x, _\u27e9,\n  { obtain \u27e8n, h0, hn\u27e9 := (is_of_fin_add_order_iff_nsmul_eq_zero x).mp (h x),\n    exact \u27e8\u27e8n, mem_non_zero_divisors_of_ne_zero $ ne_of_gt h0\u27e9, hn\u27e9 },\n  { rw is_of_fin_add_order_iff_nsmul_eq_zero,\n    obtain \u27e8n, hn\u27e9 := @h x,\n    refine \u27e8n, nat.pos_of_ne_zero (non_zero_divisors.coe_ne_zero _), hn\u27e9 }\nend\n\ntheorem is_torsion_iff_is_torsion_int [add_comm_group M] :\n  add_monoid.is_torsion M \u2194 module.is_torsion \u2124 M :=\nbegin\n  refine \u27e8\u03bb h x, _, \u03bb h x, _\u27e9,\n  { obtain \u27e8n, h0, hn\u27e9 := (is_of_fin_add_order_iff_nsmul_eq_zero x).mp (h x),\n    exact \u27e8\u27e8n, mem_non_zero_divisors_of_ne_zero $ ne_of_gt $ int.coe_nat_pos.mpr h0\u27e9,\n      (coe_nat_zsmul _ _).trans hn\u27e9 },\n  { rw is_of_fin_add_order_iff_nsmul_eq_zero,\n    obtain \u27e8n, hn\u27e9 := @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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u2260 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 \u2194 x = 0 \u2228 y = 0`, as `norm_num` can not work on disjunctions to\nclose goals of the form `24 \u2260 0`, and replaces it with `mul_ne_zero : x \u2260 0 \u2192 y \u2260 0 \u2192 x * y \u2260 0`\ncreating two goals instead of a disjunction.\n\nFor example,\n```lean\nexample (a b c d x y : \u2102) (hx : x \u2260 0) (hy : y \u2260 0) :\n  a + b / x + c / x^2 + d / x^3 = a + x\u207b\u00b9 * (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 \u03b1` expression across an equivalence `e : \u03b1 \u2243 \u03b2` to solve\na goal of the form `S \u03b2`, 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 \u03b1`\nto a `monoid \u03b2`, the new multiplication is definitionally `\u03bb x y, e (e.symm a * e.symm b)`.\n-/\n\nnamespace tactic\n\n\n/--\nGiven `s : S \u03b1` for some structure `S` depending on a type `\u03b1`,\nand an equivalence `e : \u03b1 \u2243 \u03b2`,\ntry to produce an `S \u03b2`,\nby transporting data and axioms across `e` using `equiv_rw`.\n-/\nnamespace interactive\n\n\n/--\nGiven a goal `\u22a2 S \u03b2` for some type class `S`, and an equivalence `e : \u03b1 \u2243 \u03b2`.\n`transport using e` will look for a hypothesis `s : S \u03b1`,\nand attempt to close the goal by transporting `s` across the equivalence `e`.\n\n```lean\nexample {\u03b1 : Type} [ring \u03b1] {\u03b2 : Type} (e : \u03b1 \u2243 \u03b2) : ring \u03b2 :=\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 \u2192 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\u00f6del 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 \u2192 (\u2115 \u2192 C \u2192 C) \u2192 \u2115 \u2192 C := Nat.rec\n\n@[simp] theorem elim_zero {C : Sort u_1} (a : C) (f : \u2115 \u2192 C \u2192 C) : elim a f 0 = a := rfl\n\n@[simp] theorem elim_succ {C : Sort u_1} (a : C) (f : \u2115 \u2192 C \u2192 C) (n : \u2115) :\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 : \u2115 \u2192 C) : \u2115 \u2192 C := elim a fun (n : \u2115) (_x : C) => f n\n\n@[simp] theorem cases_zero {C : Sort u_1} (a : C) (f : \u2115 \u2192 C) : cases a f 0 = a := rfl\n\n@[simp] theorem cases_succ {C : Sort u_1} (a : C) (f : \u2115 \u2192 C) (n : \u2115) :\n    cases a f (Nat.succ n) = f n :=\n  rfl\n\n@[simp] def unpaired {\u03b1 : Sort u_1} (f : \u2115 \u2192 \u2115 \u2192 \u03b1) (n : \u2115) : \u03b1 :=\n  f (prod.fst (unpair n)) (prod.snd (unpair n))\n\n/-- The primitive recursive functions `\u2115 \u2192 \u2115`. -/\ninductive primrec : (\u2115 \u2192 \u2115) \u2192 Prop where\n| zero : primrec fun (n : \u2115) => 0\n| succ : primrec Nat.succ\n| left : primrec fun (n : \u2115) => prod.fst (unpair n)\n| right : primrec fun (n : \u2115) => prod.snd (unpair n)\n| pair : \u2200 {f g : \u2115 \u2192 \u2115}, primrec f \u2192 primrec g \u2192 primrec fun (n : \u2115) => mkpair (f n) (g n)\n| comp : \u2200 {f g : \u2115 \u2192 \u2115}, primrec f \u2192 primrec g \u2192 primrec fun (n : \u2115) => f (g n)\n| prec :\n    \u2200 {f g : \u2115 \u2192 \u2115},\n      primrec f \u2192\n        primrec g \u2192\n          primrec\n            (unpaired fun (z n : \u2115) => elim (f z) (fun (y IH : \u2115) => g (mkpair z (mkpair y IH))) n)\n\nnamespace primrec\n\n\ntheorem of_eq {f : \u2115 \u2192 \u2115} {g : \u2115 \u2192 \u2115} (hf : primrec f) (H : \u2200 (n : \u2115), f n = g n) : primrec g :=\n  funext H \u25b8 hf\n\ntheorem const (n : \u2115) : primrec fun (_x : \u2115) => n := sorry\n\nprotected theorem id : primrec id := sorry\n\ntheorem prec1 {f : \u2115 \u2192 \u2115} (m : \u2115) (hf : primrec f) :\n    primrec fun (n : \u2115) => elim m (fun (y IH : \u2115) => f (mkpair y IH)) n :=\n  sorry\n\ntheorem cases1 {f : \u2115 \u2192 \u2115} (m : \u2115) (hf : primrec f) : primrec (cases m f) := sorry\n\ntheorem cases {f : \u2115 \u2192 \u2115} {g : \u2115 \u2192 \u2115} (hf : primrec f) (hg : primrec g) :\n    primrec (unpaired fun (z n : \u2115) => cases (f z) (fun (y : \u2115) => g (mkpair z y)) n) :=\n  sorry\n\nprotected theorem swap : primrec (unpaired (function.swap mkpair)) := sorry\n\ntheorem swap' {f : \u2115 \u2192 \u2115 \u2192 \u2115} (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 (\u03b1 : Type u_1) extends encodable \u03b1 where\n  prim : nat.primrec fun (n : \u2115) => encodable.encode (encodable.decode \u03b1 n)\n\nnamespace primcodable\n\n\nprotected instance of_denumerable (\u03b1 : Type u_1) [denumerable \u03b1] : primcodable \u03b1 := mk sorry\n\ndef of_equiv (\u03b1 : Type u_1) {\u03b2 : Type u_2} [primcodable \u03b1] (e : \u03b2 \u2243 \u03b1) : primcodable \u03b2 := mk sorry\n\nprotected instance empty : primcodable empty := mk nat.primrec.zero\n\nprotected instance unit : primcodable PUnit := mk sorry\n\nprotected instance option {\u03b1 : Type u_1} [h : primcodable \u03b1] : primcodable (Option \u03b1) := 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] (f : \u03b1 \u2192 \u03b2) :=\n  nat.primrec fun (n : \u2115) => encodable.encode (option.map f (encodable.decode \u03b1 n))\n\nnamespace primrec\n\n\nprotected theorem encode {\u03b1 : Type u_1} [primcodable \u03b1] : primrec encodable.encode := sorry\n\nprotected theorem decode {\u03b1 : Type u_1} [primcodable \u03b1] : primrec (encodable.decode \u03b1) :=\n  nat.primrec.comp nat.primrec.succ (primcodable.prim \u03b1)\n\ntheorem dom_denumerable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [denumerable \u03b1] [primcodable \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    primrec f \u2194 nat.primrec fun (n : \u2115) => encodable.encode (f (denumerable.of_nat \u03b1 n)) :=\n  sorry\n\ntheorem nat_iff {f : \u2115 \u2192 \u2115} : primrec f \u2194 nat.primrec f := dom_denumerable\n\ntheorem encdec {\u03b1 : Type u_1} [primcodable \u03b1] :\n    primrec fun (n : \u2115) => encodable.encode (encodable.decode \u03b1 n) :=\n  iff.mpr nat_iff (primcodable.prim \u03b1)\n\ntheorem option_some {\u03b1 : Type u_1} [primcodable \u03b1] : primrec some := sorry\n\ntheorem of_eq {\u03b1 : Type u_1} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03c3] {f : \u03b1 \u2192 \u03c3} {g : \u03b1 \u2192 \u03c3}\n    (hf : primrec f) (H : \u2200 (n : \u03b1), f n = g n) : primrec g :=\n  funext H \u25b8 hf\n\ntheorem const {\u03b1 : Type u_1} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03c3] (x : \u03c3) :\n    primrec fun (a : \u03b1) => x :=\n  sorry\n\nprotected theorem id {\u03b1 : Type u_1} [primcodable \u03b1] : primrec id := sorry\n\ntheorem comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b2 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2} (hf : primrec f) (hg : primrec g) :\n    primrec fun (a : \u03b1) => 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 {\u03b1 : Type u_1} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03c3] {f : \u03b1 \u2192 \u03c3} :\n    (primrec fun (a : \u03b1) => encodable.encode (f a)) \u2194 primrec f :=\n  sorry\n\ntheorem of_nat_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [denumerable \u03b1] [primcodable \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    primrec f \u2194 primrec fun (n : \u2115) => f (denumerable.of_nat \u03b1 n) :=\n  iff.trans dom_denumerable (iff.trans (iff.symm nat_iff) encode_iff)\n\nprotected theorem of_nat (\u03b1 : Type u_1) [denumerable \u03b1] : primrec (denumerable.of_nat \u03b1) :=\n  iff.mp of_nat_iff primrec.id\n\ntheorem option_some_iff {\u03b1 : Type u_1} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03c3] {f : \u03b1 \u2192 \u03c3} :\n    (primrec fun (a : \u03b1) => some (f a)) \u2194 primrec f :=\n  { mp :=\n      fun (h : primrec fun (a : \u03b1) => some (f a)) =>\n        iff.mp encode_iff (comp pred (iff.mpr encode_iff h)),\n    mpr := comp option_some }\n\ntheorem of_equiv {\u03b1 : Type u_1} [primcodable \u03b1] {\u03b2 : Type u_2} {e : \u03b2 \u2243 \u03b1} : primrec \u21d1e :=\n  iff.mp encode_iff primrec.encode\n\ntheorem of_equiv_symm {\u03b1 : Type u_1} [primcodable \u03b1] {\u03b2 : Type u_2} {e : \u03b2 \u2243 \u03b1} :\n    primrec \u21d1(equiv.symm e) :=\n  sorry\n\ntheorem of_equiv_iff {\u03b1 : Type u_1} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03c3] {\u03b2 : Type u_2}\n    (e : \u03b2 \u2243 \u03b1) {f : \u03c3 \u2192 \u03b2} : (primrec fun (a : \u03c3) => coe_fn e (f a)) \u2194 primrec f :=\n  sorry\n\ntheorem of_equiv_symm_iff {\u03b1 : Type u_1} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03c3]\n    {\u03b2 : Type u_2} (e : \u03b2 \u2243 \u03b1) {f : \u03c3 \u2192 \u03b1} :\n    (primrec fun (a : \u03c3) => coe_fn (equiv.symm e) (f a)) \u2194 primrec f :=\n  sorry\n\nend primrec\n\n\nnamespace primcodable\n\n\nprotected instance prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] :\n    primcodable (\u03b1 \u00d7 \u03b2) :=\n  mk sorry\n\nend primcodable\n\n\nnamespace primrec\n\n\ntheorem fst {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] : primrec prod.fst :=\n  sorry\n\ntheorem snd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] : primrec prod.snd :=\n  sorry\n\ntheorem pair {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} (hf : primrec f) (hg : primrec g) :\n    primrec fun (a : \u03b1) => (f a, g a) :=\n  sorry\n\ntheorem unpair : primrec nat.unpair := sorry\n\ntheorem list_nth\u2081 {\u03b1 : Type u_1} [primcodable \u03b1] (l : List \u03b1) : primrec (list.nth l) := sorry\n\nend primrec\n\n\n/-- `primrec\u2082 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\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] (f : \u03b1 \u2192 \u03b2 \u2192 \u03c3) :=\n  primrec fun (p : \u03b1 \u00d7 \u03b2) => f (prod.fst p) (prod.snd p)\n\n/-- `primrec_pred p` means `p : \u03b1 \u2192 Prop` is a (decidable)\n  primitive recursive predicate, which is to say that\n  `to_bool \u2218 p : \u03b1 \u2192 bool` is primitive recursive. -/\ndef primrec_pred {\u03b1 : Type u_1} [primcodable \u03b1] (p : \u03b1 \u2192 Prop) [decidable_pred p] :=\n  primrec fun (a : \u03b1) => to_bool (p a)\n\n/-- `primrec_rel p` means `p : \u03b1 \u2192 \u03b2 \u2192 Prop` is a (decidable)\n  primitive recursive relation, which is to say that\n  `to_bool \u2218 p : \u03b1 \u2192 \u03b2 \u2192 bool` is primitive recursive. -/\ndef primrec_rel {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] (s : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    [(a : \u03b1) \u2192 (b : \u03b2) \u2192 Decidable (s a b)] :=\n  primrec\u2082 fun (a : \u03b1) (b : \u03b2) => to_bool (s a b)\n\nnamespace primrec\u2082\n\n\ntheorem of_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (hg : primrec\u2082 f)\n    (H : \u2200 (a : \u03b1) (b : \u03b2), f a b = g a b) : primrec\u2082 g :=\n  (funext fun (a : \u03b1) => funext fun (b : \u03b2) => H a b) \u25b8 hg\n\ntheorem const {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] (x : \u03c3) : primrec\u2082 fun (a : \u03b1) (b : \u03b2) => x :=\n  primrec.const x\n\nprotected theorem pair {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] :\n    primrec\u2082 Prod.mk :=\n  primrec.pair primrec.fst primrec.snd\n\ntheorem left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] :\n    primrec\u2082 fun (a : \u03b1) (b : \u03b2) => a :=\n  primrec.fst\n\ntheorem right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] :\n    primrec\u2082 fun (a : \u03b1) (b : \u03b2) => b :=\n  primrec.snd\n\ntheorem mkpair : primrec\u2082 nat.mkpair := sorry\n\ntheorem unpaired {\u03b1 : Type u_1} [primcodable \u03b1] {f : \u2115 \u2192 \u2115 \u2192 \u03b1} :\n    primrec (nat.unpaired f) \u2194 primrec\u2082 f :=\n  sorry\n\ntheorem unpaired' {f : \u2115 \u2192 \u2115 \u2192 \u2115} : nat.primrec (nat.unpaired f) \u2194 primrec\u2082 f :=\n  iff.trans (iff.symm primrec.nat_iff) unpaired\n\ntheorem encode_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    (primrec\u2082 fun (a : \u03b1) (b : \u03b2) => encodable.encode (f a b)) \u2194 primrec\u2082 f :=\n  primrec.encode_iff\n\ntheorem option_some_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} : (primrec\u2082 fun (a : \u03b1) (b : \u03b2) => some (f a b)) \u2194 primrec\u2082 f :=\n  primrec.option_some_iff\n\ntheorem of_nat_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [denumerable \u03b1] [denumerable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    primrec\u2082 f \u2194 primrec\u2082 fun (m n : \u2115) => f (denumerable.of_nat \u03b1 m) (denumerable.of_nat \u03b2 n) :=\n  sorry\n\ntheorem uncurry {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} : primrec (function.uncurry f) \u2194 primrec\u2082 f :=\n  sorry\n\ntheorem curry {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u00d7 \u03b2 \u2192 \u03c3} : primrec\u2082 (function.curry f) \u2194 primrec f :=\n  sorry\n\nend primrec\u2082\n\n\ntheorem primrec.comp\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03c3 : Type u_5} [primcodable \u03b1]\n    [primcodable \u03b2] [primcodable \u03b3] [primcodable \u03c3] {f : \u03b3 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hf : primrec f)\n    (hg : primrec\u2082 g) : primrec\u2082 fun (a : \u03b1) (b : \u03b2) => f (g a b) :=\n  primrec.comp hf hg\n\ntheorem primrec\u2082.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03c3 : Type u_5} [primcodable \u03b1]\n    [primcodable \u03b2] [primcodable \u03b3] [primcodable \u03c3] {f : \u03b2 \u2192 \u03b3 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2} {h : \u03b1 \u2192 \u03b3}\n    (hf : primrec\u2082 f) (hg : primrec g) (hh : primrec h) : primrec fun (a : \u03b1) => f (g a) (h a) :=\n  primrec.comp hf (primrec.pair hg hh)\n\ntheorem primrec\u2082.comp\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {\u03c3 : Type u_5}\n    [primcodable \u03b1] [primcodable \u03b2] [primcodable \u03b3] [primcodable \u03b4] [primcodable \u03c3] {f : \u03b3 \u2192 \u03b4 \u2192 \u03c3}\n    {g : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b4} (hf : primrec\u2082 f) (hg : primrec\u2082 g) (hh : primrec\u2082 h) :\n    primrec\u2082 fun (a : \u03b1) (b : \u03b2) => f (g a b) (h a b) :=\n  primrec\u2082.comp hf hg hh\n\ntheorem primrec_pred.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2]\n    {p : \u03b2 \u2192 Prop} [decidable_pred p] {f : \u03b1 \u2192 \u03b2} :\n    primrec_pred p \u2192 primrec f \u2192 primrec_pred fun (a : \u03b1) => p (f a) :=\n  primrec.comp\n\ntheorem primrec_rel.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [primcodable \u03b1]\n    [primcodable \u03b2] [primcodable \u03b3] {R : \u03b2 \u2192 \u03b3 \u2192 Prop} [(a : \u03b2) \u2192 (b : \u03b3) \u2192 Decidable (R a b)]\n    {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} :\n    primrec_rel R \u2192 primrec f \u2192 primrec g \u2192 primrec_pred fun (a : \u03b1) => R (f a) (g a) :=\n  primrec\u2082.comp\n\ntheorem primrec_rel.comp\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4}\n    [primcodable \u03b1] [primcodable \u03b2] [primcodable \u03b3] [primcodable \u03b4] {R : \u03b3 \u2192 \u03b4 \u2192 Prop}\n    [(a : \u03b3) \u2192 (b : \u03b4) \u2192 Decidable (R a b)] {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4} :\n    primrec_rel R \u2192\n        primrec\u2082 f \u2192 primrec\u2082 g \u2192 primrec_rel fun (a : \u03b1) (b : \u03b2) => R (f a b) (g a b) :=\n  primrec_rel.comp\n\ntheorem primrec_pred.of_eq {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop}\n    [decidable_pred p] [decidable_pred q] (hp : primrec_pred p) (H : \u2200 (a : \u03b1), p a \u2194 q a) :\n    primrec_pred q :=\n  primrec.of_eq hp fun (a : \u03b1) => to_bool_congr (H a)\n\ntheorem primrec_rel.of_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2]\n    {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {s : \u03b1 \u2192 \u03b2 \u2192 Prop} [(a : \u03b1) \u2192 (b : \u03b2) \u2192 Decidable (r a b)]\n    [(a : \u03b1) \u2192 (b : \u03b2) \u2192 Decidable (s a b)] (hr : primrec_rel r)\n    (H : \u2200 (a : \u03b1) (b : \u03b2), r a b \u2194 s a b) : primrec_rel s :=\n  primrec\u2082.of_eq hr fun (a : \u03b1) (b : \u03b2) => to_bool_congr (H a b)\n\nnamespace primrec\u2082\n\n\ntheorem swap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (h : primrec\u2082 f) : primrec\u2082 (function.swap f) :=\n  comp\u2082 h right left\n\ntheorem nat_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    primrec\u2082 f \u2194\n        nat.primrec\n          (nat.unpaired\n            fun (m n : \u2115) =>\n              encodable.encode\n                (option.bind (encodable.decode \u03b1 m)\n                  fun (a : \u03b1) => option.map (f a) (encodable.decode \u03b2 n))) :=\n  sorry\n\ntheorem nat_iff' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_3} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    primrec\u2082 f \u2194\n        primrec\u2082\n          fun (m n : \u2115) =>\n            option.bind (encodable.decode \u03b1 m)\n              fun (a : \u03b1) => option.map (f a) (encodable.decode \u03b2 n) :=\n  iff.trans nat_iff (iff.trans unpaired' encode_iff)\n\nend primrec\u2082\n\n\nnamespace primrec\n\n\ntheorem to\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u00d7 \u03b2 \u2192 \u03c3} (hf : primrec f) : primrec\u2082 fun (a : \u03b1) (b : \u03b2) => f (a, b) :=\n  of_eq hf\n    fun (_x : \u03b1 \u00d7 \u03b2) =>\n      (fun (_a : \u03b1 \u00d7 \u03b2) =>\n          prod.cases_on _a fun (fst : \u03b1) (snd : \u03b2) => idRhs (f (fst, snd) = f (fst, snd)) rfl)\n        _x\n\ntheorem nat_elim {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {g : \u03b1 \u2192 \u2115 \u00d7 \u03b2 \u2192 \u03b2} (hf : primrec f) (hg : primrec\u2082 g) :\n    primrec\u2082 fun (a : \u03b1) (n : \u2115) => nat.elim (f a) (fun (n : \u2115) (IH : \u03b2) => g a (n, IH)) n :=\n  sorry\n\ntheorem nat_elim' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {f : \u03b1 \u2192 \u2115}\n    {g : \u03b1 \u2192 \u03b2} {h : \u03b1 \u2192 \u2115 \u00d7 \u03b2 \u2192 \u03b2} (hf : primrec f) (hg : primrec g) (hh : primrec\u2082 h) :\n    primrec fun (a : \u03b1) => nat.elim (g a) (fun (n : \u2115) (IH : \u03b2) => h a (n, IH)) (f a) :=\n  primrec\u2082.comp (nat_elim hg hh) primrec.id hf\n\ntheorem nat_elim\u2081 {\u03b1 : Type u_1} [primcodable \u03b1] {f : \u2115 \u2192 \u03b1 \u2192 \u03b1} (a : \u03b1) (hf : primrec\u2082 f) :\n    primrec (nat.elim a f) :=\n  nat_elim' primrec.id (const a) (comp\u2082 hf primrec\u2082.right)\n\ntheorem nat_cases' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {g : \u03b1 \u2192 \u2115 \u2192 \u03b2} (hf : primrec f) (hg : primrec\u2082 g) :\n    primrec\u2082 fun (a : \u03b1) => nat.cases (f a) (g a) :=\n  nat_elim hf (primrec\u2082.comp\u2082 hg primrec\u2082.left (comp\u2082 fst primrec\u2082.right))\n\ntheorem nat_cases {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {f : \u03b1 \u2192 \u2115}\n    {g : \u03b1 \u2192 \u03b2} {h : \u03b1 \u2192 \u2115 \u2192 \u03b2} (hf : primrec f) (hg : primrec g) (hh : primrec\u2082 h) :\n    primrec fun (a : \u03b1) => nat.cases (g a) (h a) (f a) :=\n  primrec\u2082.comp (nat_cases' hg hh) primrec.id hf\n\ntheorem nat_cases\u2081 {\u03b1 : Type u_1} [primcodable \u03b1] {f : \u2115 \u2192 \u03b1} (a : \u03b1) (hf : primrec f) :\n    primrec (nat.cases a f) :=\n  nat_cases primrec.id (const a) (comp\u2082 hf primrec\u2082.right)\n\ntheorem nat_iterate {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {f : \u03b1 \u2192 \u2115}\n    {g : \u03b1 \u2192 \u03b2} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b2} (hf : primrec f) (hg : primrec g) (hh : primrec\u2082 h) :\n    primrec fun (a : \u03b1) => nat.iterate (h a) (f a) (g a) :=\n  sorry\n\ntheorem option_cases {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {o : \u03b1 \u2192 Option \u03b2} {f : \u03b1 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (ho : primrec o) (hf : primrec f)\n    (hg : primrec\u2082 g) : primrec fun (a : \u03b1) => option.cases_on (o a) (f a) (g a) :=\n  sorry\n\ntheorem option_bind {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 Option \u03b2} {g : \u03b1 \u2192 \u03b2 \u2192 Option \u03c3} (hf : primrec f) (hg : primrec\u2082 g) :\n    primrec fun (a : \u03b1) => option.bind (f a) (g a) :=\n  sorry\n\ntheorem option_bind\u2081 {\u03b1 : Type u_1} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03c3]\n    {f : \u03b1 \u2192 Option \u03c3} (hf : primrec f) : primrec fun (o : Option \u03b1) => option.bind o f :=\n  option_bind primrec.id (to\u2082 (comp hf snd))\n\ntheorem option_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 Option \u03b2} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (hf : primrec f) (hg : primrec\u2082 g) :\n    primrec fun (a : \u03b1) => option.map (g a) (f a) :=\n  option_bind hf (comp\u2082 option_some hg)\n\ntheorem option_map\u2081 {\u03b1 : Type u_1} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03c3] {f : \u03b1 \u2192 \u03c3}\n    (hf : primrec f) : primrec (option.map f) :=\n  option_map primrec.id (to\u2082 (comp hf snd))\n\ntheorem option_iget {\u03b1 : Type u_1} [primcodable \u03b1] [Inhabited \u03b1] : primrec option.iget := sorry\n\ntheorem option_is_some {\u03b1 : Type u_1} [primcodable \u03b1] : primrec option.is_some := sorry\n\ntheorem option_get_or_else {\u03b1 : Type u_1} [primcodable \u03b1] : primrec\u2082 option.get_or_else := sorry\n\ntheorem bind_decode_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 Option \u03c3} :\n    (primrec\u2082 fun (a : \u03b1) (n : \u2115) => option.bind (encodable.decode \u03b2 n) (f a)) \u2194 primrec\u2082 f :=\n  sorry\n\ntheorem map_decode_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    (primrec\u2082 fun (a : \u03b1) (n : \u2115) => option.map (f a) (encodable.decode \u03b2 n)) \u2194 primrec\u2082 f :=\n  iff.trans bind_decode_iff primrec\u2082.option_some_iff\n\ntheorem nat_add : primrec\u2082 Add.add := iff.mp primrec\u2082.unpaired' nat.primrec.add\n\ntheorem nat_sub : primrec\u2082 Sub.sub := iff.mp primrec\u2082.unpaired' nat.primrec.sub\n\ntheorem nat_mul : primrec\u2082 Mul.mul := iff.mp primrec\u2082.unpaired' nat.primrec.mul\n\ntheorem cond {\u03b1 : Type u_1} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03c3] {c : \u03b1 \u2192 Bool}\n    {f : \u03b1 \u2192 \u03c3} {g : \u03b1 \u2192 \u03c3} (hc : primrec c) (hf : primrec f) (hg : primrec g) :\n    primrec fun (a : \u03b1) => cond (c a) (f a) (g a) :=\n  sorry\n\ntheorem ite {\u03b1 : Type u_1} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03c3] {c : \u03b1 \u2192 Prop}\n    [decidable_pred c] {f : \u03b1 \u2192 \u03c3} {g : \u03b1 \u2192 \u03c3} (hc : primrec_pred c) (hf : primrec f)\n    (hg : primrec g) : primrec fun (a : \u03b1) => ite (c a) (f a) (g a) :=\n  sorry\n\ntheorem nat_le : primrec_rel LessEq := sorry\n\ntheorem nat_min : primrec\u2082 min := ite nat_le fst snd\n\ntheorem nat_max : primrec\u2082 max := ite (primrec_rel.comp nat_le snd fst) fst snd\n\ntheorem dom_bool {\u03b1 : Type u_1} [primcodable \u03b1] (f : Bool \u2192 \u03b1) : 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\u2082 {\u03b1 : Type u_1} [primcodable \u03b1] (f : Bool \u2192 Bool \u2192 \u03b1) : primrec\u2082 f := sorry\n\nprotected theorem bnot : primrec bnot := dom_bool bnot\n\nprotected theorem band : primrec\u2082 band := dom_bool\u2082 band\n\nprotected theorem bor : primrec\u2082 bor := dom_bool\u2082 bor\n\nprotected theorem not {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} [decidable_pred p]\n    (hp : primrec_pred p) : primrec_pred fun (a : \u03b1) => \u00acp a :=\n  sorry\n\nprotected theorem and {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop}\n    [decidable_pred p] [decidable_pred q] (hp : primrec_pred p) (hq : primrec_pred q) :\n    primrec_pred fun (a : \u03b1) => p a \u2227 q a :=\n  sorry\n\nprotected theorem or {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} [decidable_pred p]\n    [decidable_pred q] (hp : primrec_pred p) (hq : primrec_pred q) :\n    primrec_pred fun (a : \u03b1) => p a \u2228 q a :=\n  sorry\n\nprotected theorem eq {\u03b1 : Type u_1} [primcodable \u03b1] [DecidableEq \u03b1] : primrec_rel Eq := sorry\n\ntheorem nat_lt : primrec_rel Less := sorry\n\ntheorem option_guard {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2]\n    {p : \u03b1 \u2192 \u03b2 \u2192 Prop} [(a : \u03b1) \u2192 (b : \u03b2) \u2192 Decidable (p a b)] (hp : primrec_rel p) {f : \u03b1 \u2192 \u03b2}\n    (hf : primrec f) : primrec fun (a : \u03b1) => 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 {\u03b1 : Type u_1} [primcodable \u03b1] : primrec\u2082 has_orelse.orelse := sorry\n\nprotected theorem decode2 {\u03b1 : Type u_1} [primcodable \u03b1] : primrec (encodable.decode2 \u03b1) :=\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\u2081 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2]\n    {p : \u03b1 \u2192 \u03b2 \u2192 Prop} [(a : \u03b1) \u2192 (b : \u03b2) \u2192 Decidable (p a b)] (hp : primrec_rel p) (l : List \u03b2) :\n    primrec fun (a : \u03b1) => list.find_index (p a) l :=\n  sorry\n\ntheorem list_index_of\u2081 {\u03b1 : Type u_1} [primcodable \u03b1] [DecidableEq \u03b1] (l : List \u03b1) :\n    primrec fun (a : \u03b1) => list.index_of a l :=\n  list_find_index\u2081 primrec.eq l\n\ntheorem dom_fintype {\u03b1 : Type u_1} {\u03c3 : Type u_5} [primcodable \u03b1] [primcodable \u03c3] [fintype \u03b1]\n    (f : \u03b1 \u2192 \u03c3) : 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\u2082.comp nat_add primrec.id primrec.id\n\ntheorem nat_bit1 : primrec bit1 := primrec\u2082.comp nat_add nat_bit0 (const 1)\n\ntheorem nat_bit : primrec\u2082 nat.bit := sorry\n\ntheorem nat_div_mod : primrec\u2082 fun (n k : \u2115) => (n / k, n % k) := sorry\n\ntheorem nat_div : primrec\u2082 Div.div := comp\u2082 fst nat_div_mod\n\ntheorem nat_mod : primrec\u2082 Mod.mod := comp\u2082 snd nat_div_mod\n\nend primrec\n\n\nnamespace primcodable\n\n\nprotected instance sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] :\n    primcodable (\u03b1 \u2295 \u03b2) :=\n  mk sorry\n\nprotected instance list {\u03b1 : Type u_1} [primcodable \u03b1] : primcodable (List \u03b1) := mk sorry\n\nend primcodable\n\n\nnamespace primrec\n\n\ntheorem sum_inl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] : primrec sum.inl :=\n  iff.mp encode_iff (comp nat_bit0 primrec.encode)\n\ntheorem sum_inr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] : primrec sum.inr :=\n  iff.mp encode_iff (comp nat_bit1 primrec.encode)\n\ntheorem sum_cases {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03c3 : Type u_4} [primcodable \u03b1]\n    [primcodable \u03b2] [primcodable \u03b3] [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2295 \u03b3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b3 \u2192 \u03c3}\n    (hf : primrec f) (hg : primrec\u2082 g) (hh : primrec\u2082 h) :\n    primrec fun (a : \u03b1) => sum.cases_on (f a) (g a) (h a) :=\n  sorry\n\ntheorem list_cons {\u03b1 : Type u_1} [primcodable \u03b1] : primrec\u2082 List.cons :=\n  list_cons' (primcodable.prim (List \u03b1))\n\ntheorem list_cases {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b2 \u00d7 List \u03b2 \u2192 \u03c3} :\n    primrec f \u2192\n        primrec g \u2192\n          primrec\u2082 h \u2192\n            primrec\n              fun (a : \u03b1) => list.cases_on (f a) (g a) fun (b : \u03b2) (l : List \u03b2) => h a (b, l) :=\n  list_cases' (primcodable.prim (List \u03b2))\n\ntheorem list_foldl {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03c3 \u00d7 \u03b2 \u2192 \u03c3} :\n    primrec f \u2192\n        primrec g \u2192\n          primrec\u2082 h \u2192\n            primrec fun (a : \u03b1) => list.foldl (fun (s : \u03c3) (b : \u03b2) => h a (s, b)) (g a) (f a) :=\n  list_foldl' (primcodable.prim (List \u03b2))\n\ntheorem list_reverse {\u03b1 : Type u_1} [primcodable \u03b1] : primrec list.reverse :=\n  list_reverse' (primcodable.prim (List \u03b1))\n\ntheorem list_foldr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b2 \u00d7 \u03c3 \u2192 \u03c3} (hf : primrec f)\n    (hg : primrec g) (hh : primrec\u2082 h) :\n    primrec fun (a : \u03b1) => list.foldr (fun (b : \u03b2) (s : \u03c3) => h a (b, s)) (g a) (f a) :=\n  sorry\n\ntheorem list_head' {\u03b1 : Type u_1} [primcodable \u03b1] : primrec list.head' := sorry\n\ntheorem list_head {\u03b1 : Type u_1} [primcodable \u03b1] [Inhabited \u03b1] : primrec list.head :=\n  of_eq (comp option_iget list_head') fun (l : List \u03b1) => Eq.symm (list.head_eq_head' l)\n\ntheorem list_tail {\u03b1 : Type u_1} [primcodable \u03b1] : primrec list.tail := sorry\n\ntheorem list_rec {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b2 \u00d7 List \u03b2 \u00d7 \u03c3 \u2192 \u03c3} (hf : primrec f)\n    (hg : primrec g) (hh : primrec\u2082 h) :\n    primrec\n        fun (a : \u03b1) =>\n          list.rec_on (f a) (g a) fun (b : \u03b2) (l : List \u03b2) (IH : \u03c3) => h a (b, l, IH) :=\n  sorry\n\ntheorem list_nth {\u03b1 : Type u_1} [primcodable \u03b1] : primrec\u2082 list.nth := sorry\n\ntheorem list_inth {\u03b1 : Type u_1} [primcodable \u03b1] [Inhabited \u03b1] : primrec\u2082 list.inth :=\n  comp\u2082 option_iget list_nth\n\ntheorem list_append {\u03b1 : Type u_1} [primcodable \u03b1] : primrec\u2082 append := sorry\n\ntheorem list_concat {\u03b1 : Type u_1} [primcodable \u03b1] :\n    primrec\u2082 fun (l : List \u03b1) (a : \u03b1) => l ++ [a] :=\n  primrec\u2082.comp list_append fst (primrec\u2082.comp list_cons snd (const []))\n\ntheorem list_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03b2]\n    [primcodable \u03c3] {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (hf : primrec f) (hg : primrec\u2082 g) :\n    primrec fun (a : \u03b1) => list.map (g a) (f a) :=\n  sorry\n\ntheorem list_range : primrec list.range := sorry\n\ntheorem list_join {\u03b1 : Type u_1} [primcodable \u03b1] : primrec list.join := sorry\n\ntheorem list_length {\u03b1 : Type u_1} [primcodable \u03b1] : primrec list.length := sorry\n\ntheorem list_find_index {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2]\n    {f : \u03b1 \u2192 List \u03b2} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} [(a : \u03b1) \u2192 (b : \u03b2) \u2192 Decidable (p a b)] (hf : primrec f)\n    (hp : primrec_rel p) : primrec fun (a : \u03b1) => list.find_index (p a) (f a) :=\n  sorry\n\ntheorem list_index_of {\u03b1 : Type u_1} [primcodable \u03b1] [DecidableEq \u03b1] : primrec\u2082 list.index_of :=\n  to\u2082 (list_find_index snd (primrec_rel.comp\u2082 primrec.eq (to\u2082 (comp fst fst)) (to\u2082 snd)))\n\ntheorem nat_strong_rec {\u03b1 : Type u_1} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03c3] (f : \u03b1 \u2192 \u2115 \u2192 \u03c3)\n    {g : \u03b1 \u2192 List \u03c3 \u2192 Option \u03c3} (hg : primrec\u2082 g)\n    (H : \u2200 (a : \u03b1) (n : \u2115), g a (list.map (f a) (list.range n)) = some (f a n)) : primrec\u2082 f :=\n  sorry\n\nend primrec\n\n\nnamespace primcodable\n\n\ndef subtype {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} [decidable_pred p] (hp : primrec_pred p) :\n    primcodable (Subtype p) :=\n  mk sorry\n\nprotected instance fin {n : \u2115} : primcodable (fin n) :=\n  of_equiv (Subtype fun (a : \u2115) => id a < n) (equiv.fin_equiv_subtype n)\n\nprotected instance vector {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primcodable (vector \u03b1 n) :=\n  subtype sorry\n\nprotected instance fin_arrow {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primcodable (fin n \u2192 \u03b1) :=\n  of_equiv (vector \u03b1 n) (equiv.symm (equiv.vector_equiv_fin \u03b1 n))\n\nprotected instance array {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primcodable (array n \u03b1) :=\n  of_equiv (fin n \u2192 \u03b1) (equiv.array_equiv_fin n \u03b1)\n\nprotected instance ulower {\u03b1 : Type u_1} [primcodable \u03b1] : primcodable (ulower \u03b1) :=\n  (fun (this : primrec_pred fun (n : \u2115) => encodable.decode2 \u03b1 n \u2260 none) => subtype sorry) sorry\n\nend primcodable\n\n\nnamespace primrec\n\n\ntheorem subtype_val {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} [decidable_pred p]\n    {hp : primrec_pred p} : primrec subtype.val :=\n  sorry\n\ntheorem subtype_val_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {p : \u03b2 \u2192 Prop}\n    [decidable_pred p] {hp : primrec_pred p} {f : \u03b1 \u2192 Subtype p} :\n    (primrec fun (a : \u03b1) => subtype.val (f a)) \u2194 primrec f :=\n  sorry\n\ntheorem subtype_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {p : \u03b2 \u2192 Prop}\n    [decidable_pred p] {hp : primrec_pred p} {f : \u03b1 \u2192 \u03b2} {h : \u2200 (a : \u03b1), p (f a)} (hf : primrec f) :\n    primrec fun (a : \u03b1) => { val := f a, property := h a } :=\n  iff.mp subtype_val_iff hf\n\ntheorem option_get {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {f : \u03b1 \u2192 Option \u03b2}\n    {h : \u2200 (a : \u03b1), \u21a5(option.is_some (f a))} :\n    primrec f \u2192 primrec fun (a : \u03b1) => option.get (h a) :=\n  sorry\n\ntheorem ulower_down {\u03b1 : Type u_1} [primcodable \u03b1] : primrec ulower.down :=\n  subtype_mk primrec.encode\n\ntheorem ulower_up {\u03b1 : Type u_1} [primcodable \u03b1] : primrec ulower.up :=\n  option_get (comp primrec.decode2 subtype_val)\n\ntheorem fin_val_iff {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} {f : \u03b1 \u2192 fin n} :\n    (primrec fun (a : \u03b1) => subtype.val (f a)) \u2194 primrec f :=\n  iff.trans (iff.trans (iff.refl (primrec fun (a : \u03b1) => subtype.val (f a))) subtype_val_iff)\n    (of_equiv_iff (equiv.fin_equiv_subtype n))\n\ntheorem fin_val {n : \u2115} : primrec coe := iff.mpr fin_val_iff primrec.id\n\ntheorem fin_succ {n : \u2115} : primrec fin.succ := sorry\n\ntheorem vector_to_list {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primrec vector.to_list :=\n  subtype_val\n\ntheorem vector_to_list_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [primcodable \u03b1] [primcodable \u03b2] {n : \u2115}\n    {f : \u03b1 \u2192 vector \u03b2 n} : (primrec fun (a : \u03b1) => vector.to_list (f a)) \u2194 primrec f :=\n  subtype_val_iff\n\ntheorem vector_cons {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primrec\u2082 vector.cons := sorry\n\ntheorem vector_length {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primrec vector.length := const n\n\ntheorem vector_head {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primrec vector.head := sorry\n\ntheorem vector_tail {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primrec vector.tail := sorry\n\ntheorem vector_nth {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primrec\u2082 vector.nth := sorry\n\ntheorem list_of_fn {\u03b1 : Type u_1} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03c3] {n : \u2115}\n    {f : fin n \u2192 \u03b1 \u2192 \u03c3} :\n    (\u2200 (i : fin n), primrec (f i)) \u2192 primrec fun (a : \u03b1) => list.of_fn fun (i : fin n) => f i a :=\n  sorry\n\ntheorem vector_of_fn {\u03b1 : Type u_1} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03c3] {n : \u2115}\n    {f : fin n \u2192 \u03b1 \u2192 \u03c3} (hf : \u2200 (i : fin n), primrec (f i)) :\n    primrec fun (a : \u03b1) => vector.of_fn fun (i : fin n) => f i a :=\n  sorry\n\ntheorem vector_nth' {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primrec vector.nth := of_equiv_symm\n\ntheorem vector_of_fn' {\u03b1 : Type u_1} [primcodable \u03b1] {n : \u2115} : primrec vector.of_fn := of_equiv\n\ntheorem fin_app {\u03c3 : Type u_4} [primcodable \u03c3] {n : \u2115} : primrec\u2082 id := sorry\n\ntheorem fin_curry\u2081 {\u03b1 : Type u_1} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03c3] {n : \u2115}\n    {f : fin n \u2192 \u03b1 \u2192 \u03c3} : primrec\u2082 f \u2194 \u2200 (i : fin n), primrec (f i) :=\n  sorry\n\ntheorem fin_curry {\u03b1 : Type u_1} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03c3] {n : \u2115}\n    {f : \u03b1 \u2192 fin n \u2192 \u03c3} : primrec f \u2194 primrec\u2082 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 \u2115, and so has to\n  work with n-ary functions on \u2115 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 : \u2115} \u2192 (vector \u2115 n \u2192 \u2115) \u2192 Prop where\n| zero : primrec' fun (_x : vector \u2115 0) => 0\n| succ : primrec' fun (v : vector \u2115 1) => Nat.succ (vector.head v)\n| nth : \u2200 {n : \u2115} (i : fin n), primrec' fun (v : vector \u2115 n) => vector.nth v i\n| comp :\n    \u2200 {m n : \u2115} {f : vector \u2115 n \u2192 \u2115} (g : fin n \u2192 vector \u2115 m \u2192 \u2115),\n      primrec' f \u2192\n        (\u2200 (i : fin n), primrec' (g i)) \u2192\n          primrec' fun (a : vector \u2115 m) => f (vector.of_fn fun (i : fin n) => g i a)\n| prec :\n    \u2200 {n : \u2115} {f : vector \u2115 n \u2192 \u2115} {g : vector \u2115 (n + bit0 1) \u2192 \u2115},\n      primrec' f \u2192\n        primrec' g \u2192\n          primrec'\n            fun (v : vector \u2115 (n + 1)) =>\n              elim (f (vector.tail v)) (fun (y IH : \u2115) => g (y::\u1d65IH::\u1d65vector.tail v))\n                (vector.head v)\n\nend nat\n\n\nnamespace nat.primrec'\n\n\ntheorem to_prim {n : \u2115} {f : vector \u2115 n \u2192 \u2115} (pf : primrec' f) : primrec f := sorry\n\ntheorem of_eq {n : \u2115} {f : vector \u2115 n \u2192 \u2115} {g : vector \u2115 n \u2192 \u2115} (hf : primrec' f)\n    (H : \u2200 (i : vector \u2115 n), f i = g i) : primrec' g :=\n  funext H \u25b8 hf\n\ntheorem const {n : \u2115} (m : \u2115) : primrec' fun (v : vector \u2115 n) => m := sorry\n\ntheorem head {n : \u2115} : primrec' vector.head := sorry\n\ntheorem tail {n : \u2115} {f : vector \u2115 n \u2192 \u2115} (hf : primrec' f) :\n    primrec' fun (v : vector \u2115 (Nat.succ n)) => f (vector.tail v) :=\n  sorry\n\ndef vec {n : \u2115} {m : \u2115} (f : vector \u2115 n \u2192 vector \u2115 m) :=\n  \u2200 (i : fin m), primrec' fun (v : vector \u2115 n) => vector.nth (f v) i\n\nprotected theorem nil {n : \u2115} : vec fun (_x : vector \u2115 n) => vector.nil :=\n  fun (i : fin 0) => fin.elim0 i\n\nprotected theorem cons {n : \u2115} {m : \u2115} {f : vector \u2115 n \u2192 \u2115} {g : vector \u2115 n \u2192 vector \u2115 m}\n    (hf : primrec' f) (hg : vec g) : vec fun (v : vector \u2115 n) => f v::\u1d65g v :=\n  sorry\n\ntheorem idv {n : \u2115} : vec id := nth\n\ntheorem comp' {n : \u2115} {m : \u2115} {f : vector \u2115 m \u2192 \u2115} {g : vector \u2115 n \u2192 vector \u2115 m} (hf : primrec' f)\n    (hg : vec g) : primrec' fun (v : vector \u2115 n) => f (g v) :=\n  sorry\n\ntheorem comp\u2081 (f : \u2115 \u2192 \u2115) (hf : primrec' fun (v : vector \u2115 1) => f (vector.head v)) {n : \u2115}\n    {g : vector \u2115 n \u2192 \u2115} (hg : primrec' g) : primrec' fun (v : vector \u2115 n) => f (g v) :=\n  comp (fun (i : fin 1) => g) hf fun (i : fin 1) => hg\n\ntheorem comp\u2082 (f : \u2115 \u2192 \u2115 \u2192 \u2115)\n    (hf : primrec' fun (v : vector \u2115 (bit0 1)) => f (vector.head v) (vector.head (vector.tail v)))\n    {n : \u2115} {g : vector \u2115 n \u2192 \u2115} {h : vector \u2115 n \u2192 \u2115} (hg : primrec' g) (hh : primrec' h) :\n    primrec' fun (v : vector \u2115 n) => f (g v) (h v) :=\n  sorry\n\ntheorem prec' {n : \u2115} {f : vector \u2115 n \u2192 \u2115} {g : vector \u2115 n \u2192 \u2115} {h : vector \u2115 (n + bit0 1) \u2192 \u2115}\n    (hf : primrec' f) (hg : primrec' g) (hh : primrec' h) :\n    primrec' fun (v : vector \u2115 n) => elim (g v) (fun (y IH : \u2115) => h (y::\u1d65IH::\u1d65v)) (f v) :=\n  sorry\n\ntheorem pred : primrec' fun (v : vector \u2115 1) => Nat.pred (vector.head v) := sorry\n\ntheorem add : primrec' fun (v : vector \u2115 (bit0 1)) => vector.head v + vector.head (vector.tail v) :=\n  sorry\n\ntheorem sub : primrec' fun (v : vector \u2115 (bit0 1)) => vector.head v - vector.head (vector.tail v) :=\n  sorry\n\ntheorem mul : primrec' fun (v : vector \u2115 (bit0 1)) => vector.head v * vector.head (vector.tail v) :=\n  sorry\n\ntheorem if_lt {n : \u2115} {a : vector \u2115 n \u2192 \u2115} {b : vector \u2115 n \u2192 \u2115} {f : vector \u2115 n \u2192 \u2115}\n    {g : vector \u2115 n \u2192 \u2115} (ha : primrec' a) (hb : primrec' b) (hf : primrec' f) (hg : primrec' g) :\n    primrec' fun (v : vector \u2115 n) => ite (a v < b v) (f v) (g v) :=\n  sorry\n\ntheorem mkpair :\n    primrec' fun (v : vector \u2115 (bit0 1)) => mkpair (vector.head v) (vector.head (vector.tail v)) :=\n  if_lt head (tail head) (comp\u2082 Add.add add (tail (comp\u2082 Mul.mul mul head head)) head)\n    (comp\u2082 Add.add add (comp\u2082 Add.add add (comp\u2082 Mul.mul mul head head) head) (tail head))\n\nprotected theorem encode {n : \u2115} : primrec' encodable.encode := sorry\n\ntheorem sqrt : primrec' fun (v : vector \u2115 1) => sqrt (vector.head v) := sorry\n\ntheorem unpair\u2081 {n : \u2115} {f : vector \u2115 n \u2192 \u2115} (hf : primrec' f) :\n    primrec' fun (v : vector \u2115 n) => prod.fst (unpair (f v)) :=\n  sorry\n\ntheorem unpair\u2082 {n : \u2115} {f : vector \u2115 n \u2192 \u2115} (hf : primrec' f) :\n    primrec' fun (v : vector \u2115 n) => prod.snd (unpair (f v)) :=\n  sorry\n\ntheorem of_prim {n : \u2115} {f : vector \u2115 n \u2192 \u2115} : primrec f \u2192 primrec' f := sorry\n\ntheorem prim_iff {n : \u2115} {f : vector \u2115 n \u2192 \u2115} : primrec' f \u2194 primrec f :=\n  { mp := to_prim, mpr := of_prim }\n\ntheorem prim_iff\u2081 {f : \u2115 \u2192 \u2115} : (primrec' fun (v : vector \u2115 1) => f (vector.head v)) \u2194 primrec f :=\n  sorry\n\ntheorem prim_iff\u2082 {f : \u2115 \u2192 \u2115 \u2192 \u2115} :\n    (primrec' fun (v : vector \u2115 (bit0 1)) => f (vector.head v) (vector.head (vector.tail v))) \u2194\n        primrec\u2082 f :=\n  sorry\n\ntheorem vec_iff {m : \u2115} {n : \u2115} {f : vector \u2115 m \u2192 vector \u2115 n} : vec f \u2194 primrec f := sorry\n\nend nat.primrec'\n\n\ntheorem primrec.nat_sqrt : primrec nat.sqrt := iff.mp nat.primrec'.prim_iff\u2081 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 `*`, `+`, `-`, `^`, `\u2264`.\n-/\n\nuniverses u v w\n\nnamespace tactic\n\n/-- Reflexivity conversion: given `e` returns `(e, \u22a2 e = e)` -/\nmeta def refl_conv (e : expr) : tactic (expr \u00d7 expr) :=\ndo p \u2190 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 \u2192 tactic (expr \u00d7 expr))\n  (e : expr) : tactic (expr \u00d7 expr) := tac e <|> refl_conv e\n\n/-- Transitivity conversion: given two conversions (which take an\nexpression `e` and returns `(e', \u22a2 e = e')`), produces another\nconversion that combines them with transitivity, treating failures\nas reflexivity conversions. -/\nmeta def trans_conv (t\u2081 t\u2082 : expr \u2192 tactic (expr \u00d7 expr)) (e : expr) :\n  tactic (expr \u00d7 expr) :=\n(do (e\u2081, p\u2081) \u2190 t\u2081 e,\n  (do (e\u2082, p\u2082) \u2190 t\u2082 e\u2081,\n    p \u2190 mk_eq_trans p\u2081 p\u2082, return (e\u2082, p)) <|>\n  return (e\u2081, p\u2081)) <|> t\u2082 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 \u00d7 expr) :=\ndo (c, ai) \u2190 c.get ``has_add,\n   return (c, (expr.const ``bit0 [c.univ]).mk_app [c.\u03b1, ai, e])\n\n/-- Faster version of `mk_app ``bit1 [e]`. -/\nmeta def mk_bit1 (c : instance_cache) (e : expr) : tactic (instance_cache \u00d7 expr) :=\ndo (c, ai) \u2190 c.get ``has_add,\n   (c, oi) \u2190 c.get ``has_one,\n   return (c, (expr.const ``bit1 [c.univ]).mk_app [c.\u03b1, 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 {\u03b1 : Type u}\n\nlemma subst_into_add {\u03b1} [has_add \u03b1] (l r tl tr t)\n  (prl : (l : \u03b1) = tl) (prr : r = tr) (prt : tl + tr = t) : l + r = t :=\nby rw [prl, prr, prt]\n\nlemma subst_into_mul {\u03b1} [has_mul \u03b1] (l r tl tr t)\n  (prl : (l : \u03b1) = tl) (prr : r = tr) (prt : tl * tr = t) : l * r = t :=\nby rw [prl, prr, prt]\n\nlemma subst_into_neg {\u03b1} [has_neg \u03b1] (a ta t : \u03b1) (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 \u2192 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 {\u03b1} [semiring \u03b1] : (0 + 1 : \u03b1) = 1 := zero_add _\ntheorem one_succ {\u03b1} [semiring \u03b1] : (1 + 1 : \u03b1) = 2 := rfl\ntheorem bit0_succ {\u03b1} [semiring \u03b1] (a : \u03b1) : bit0 a + 1 = bit1 a := rfl\ntheorem bit1_succ {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : bit1 a + 1 = bit0 b :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\n\nsection\nopen match_numeral_result\n\n/-- Given `a`, `b` natural numerals, proves `\u22a2 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 \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 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, \u22a2 a + 1 = b)`. -/\nmeta def prove_succ' (c : instance_cache) (a : expr) : tactic (instance_cache \u00d7 expr \u00d7 expr) :=\ndo na \u2190 a.to_nat,\n  (c, b) \u2190 c.of_nat (na + 1),\n  (c, p) \u2190 prove_succ c a b,\n  return (c, b, p)\n\ntheorem zero_adc {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : 0 + a + 1 = b := by rwa zero_add\ntheorem adc_zero {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : a + 0 + 1 = b := by rwa add_zero\ntheorem one_add {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : 1 + a = b := by rwa add_comm\ntheorem add_bit0_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b = c) : bit0 a + bit0 b = bit0 c :=\nh \u25b8 by simp [bit0, add_left_comm, add_assoc]\ntheorem add_bit0_bit1 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b = c) : bit0 a + bit1 b = bit1 c :=\nh \u25b8 by simp [bit0, bit1, add_left_comm, add_assoc]\ntheorem add_bit1_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b = c) : bit1 a + bit0 b = bit1 c :=\nh \u25b8 by simp [bit0, bit1, add_left_comm, add_comm, add_assoc]\ntheorem add_bit1_bit1 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b + 1 = c) : bit1 a + bit1 b = bit0 c :=\nh \u25b8 by simp [bit0, bit1, add_left_comm, add_comm, add_assoc]\ntheorem adc_one_one {\u03b1} [semiring \u03b1] : (1 + 1 + 1 : \u03b1) = 3 := rfl\ntheorem adc_bit0_one {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : bit0 a + 1 + 1 = bit0 b :=\nh \u25b8 by simp [bit0, add_left_comm, add_assoc]\ntheorem adc_one_bit0 {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : 1 + bit0 a + 1 = bit0 b :=\nh \u25b8 by simp [bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_one {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : bit1 a + 1 + 1 = bit1 b :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_one_bit1 {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : 1 + bit1 a + 1 = bit1 b :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit0_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b = c) : bit0 a + bit0 b + 1 = bit1 c :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b + 1 = c) :\n  bit1 a + bit0 b + 1 = bit0 c :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit0_bit1 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b + 1 = c) :\n  bit0 a + bit1 b + 1 = bit0 c :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_bit1 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b + 1 = c) :\n  bit1 a + bit1 b + 1 = bit1 c :=\nh \u25b8 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 \u2192 expr \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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 \u2192 expr \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 expr)\n| c a b r := do\n  match match_numeral a, match_numeral b with\n  | zero, _ := do (c, p) \u2190 prove_succ c b r, c.mk_app ``zero_adc [b, r, p]\n  | _, zero := do (c, p) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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 `\u22a2 a + b = r`. -/\nadd_decl_doc prove_add_nat\n/-- Given `a`,`b`,`r` natural numerals, proves `\u22a2 a + b + 1 = r`. -/\nadd_decl_doc prove_adc_nat\n\n/-- Given `a`,`b` natural numerals, returns `(r, \u22a2 a + b = r)`. -/\nmeta def prove_add_nat' (c : instance_cache) (a b : expr) : tactic (instance_cache \u00d7 expr \u00d7 expr) :=\ndo na \u2190 a.to_nat,\n  nb \u2190 b.to_nat,\n  (c, r) \u2190 c.of_nat (na + nb),\n  (c, p) \u2190 prove_add_nat c a b r,\n  return (c, r, p)\n\nend\n\ntheorem bit0_mul {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a * b = c) :\n  bit0 a * b = bit0 c := h \u25b8 by simp [bit0, add_mul]\ntheorem mul_bit0' {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a * b = c) :\n  a * bit0 b = bit0 c := h \u25b8 by simp [bit0, mul_add]\ntheorem mul_bit0_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a * b = c) :\n  bit0 a * bit0 b = bit0 (bit0 c) := bit0_mul _ _ _ (mul_bit0' _ _ _ h)\ntheorem mul_bit1_bit1 {\u03b1} [semiring \u03b1] (a b c d e : \u03b1)\n  (hc : a * b = c) (hd : a + b = d) (he : bit0 c + d = e) :\n  bit1 a * bit1 b = bit1 e :=\nby rw [\u2190 he, \u2190 hd, \u2190 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, \u22a2 a * b = r)`. -/\nmeta def prove_mul_nat : instance_cache \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 expr \u00d7 expr)\n| ic a b :=\n  match match_numeral a, match_numeral b with\n  | zero, _ := do\n    (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``zero_mul [b],\n    return (ic, z, p)\n  | _, zero := do\n    (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``mul_zero [a],\n    return (ic, z, p)\n  | one, _ := do (ic, p) \u2190 ic.mk_app ``one_mul [b], return (ic, b, p)\n  | _, one := do (ic, p) \u2190 ic.mk_app ``mul_one [a], return (ic, a, p)\n  | bit0 a, bit0 b := do\n    (ic, c, p) \u2190 prove_mul_nat ic a b,\n    (ic, p) \u2190 ic.mk_app ``mul_bit0_bit0 [a, b, c, p],\n    (ic, c') \u2190 ic.mk_bit0 c,\n    (ic, c') \u2190 ic.mk_bit0 c',\n    return (ic, c', p)\n  | bit0 a, _ := do\n    (ic, c, p) \u2190 prove_mul_nat ic a b,\n    (ic, p) \u2190 ic.mk_app ``bit0_mul [a, b, c, p],\n    (ic, c') \u2190 ic.mk_bit0 c,\n    return (ic, c', p)\n  | _, bit0 b := do\n    (ic, c, p) \u2190 prove_mul_nat ic a b,\n    (ic, p) \u2190 ic.mk_app ``mul_bit0' [a, b, c, p],\n    (ic, c') \u2190 ic.mk_bit0 c,\n    return (ic, c', p)\n  | bit1 a, bit1 b := do\n    (ic, c, pc) \u2190 prove_mul_nat ic a b,\n    (ic, d, pd) \u2190 prove_add_nat' ic a b,\n    (ic, c') \u2190 ic.mk_bit0 c,\n    (ic, e, pe) \u2190 prove_add_nat' ic c' d,\n    (ic, p) \u2190 ic.mk_app ``mul_bit1_bit1 [a, b, c, d, e, pc, pd, pe],\n    (ic, e') \u2190 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 `\u22a2 0 < a`. -/\nmeta def prove_pos_nat (c : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| e :=\n  match match_numeral e with\n  | one := c.mk_app ``zero_lt_one' []\n  | bit0 e := do (c, p) \u2190 prove_pos_nat e, c.mk_app ``bit0_pos [e, p]\n  | bit1 e := do (c, p) \u2190 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 `\u22a2 0 < a`. -/\nmeta def prove_pos (c : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| `(%%e\u2081 / %%e\u2082) := do\n  (c, p\u2081) \u2190 prove_pos_nat c e\u2081, (c, p\u2082) \u2190 prove_pos_nat c e\u2082,\n  c.mk_app ``div_pos [e\u2081, e\u2082, p\u2081, p\u2082]\n| e := prove_pos_nat c e\n\n/-- `match_neg (- e) = some e`, otherwise `none` -/\nmeta def match_neg : expr \u2192 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 \u2192 expr \u2295 bool\n| `(- %%e) := sum.inl e\n| `(has_zero.zero) := sum.inr ff\n| _ := sum.inr tt\n\ntheorem ne_zero_of_pos {\u03b1} [ordered_add_comm_group \u03b1] (a : \u03b1) : 0 < a \u2192 a \u2260 0 := ne_of_gt\ntheorem ne_zero_neg {\u03b1} [add_group \u03b1] (a : \u03b1) : a \u2260 0 \u2192 -a \u2260 0 := mt neg_eq_zero.1\n\n/-- Given `a` a rational numeral, returns `\u22a2 a \u2260 0`. -/\nmeta def prove_ne_zero' (c : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| a :=\n  match match_neg a with\n  | some a := do (c, p) \u2190 prove_ne_zero' a, c.mk_app ``ne_zero_neg [a, p]\n  | none := do (c, p) \u2190 prove_pos c a, c.mk_app ``ne_zero_of_pos [a, p]\n  end\n\ntheorem clear_denom_div {\u03b1} [division_ring \u03b1] (a b b' c d : \u03b1)\n  (h\u2080 : b \u2260 0) (h\u2081 : b * b' = d) (h\u2082 : a * b' = c) : (a / b) * d = c :=\nby rwa [\u2190 h\u2081, \u2190 mul_assoc, div_mul_cancel _ h\u2080]\n\n/-- Given `a` nonnegative rational and `d` a natural number, returns `(b, \u22a2 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 \u2192 expr \u2192 \u211a \u2192 tactic (instance_cache \u00d7 expr))\n  (c : instance_cache) (a d : expr) (na : \u211a) (nd : \u2115) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nif na.denom = 1 then\n  prove_mul_nat c a d\nelse do\n  [_, _, a, b] \u2190 return a.get_app_args,\n  (c, b') \u2190 c.of_nat (nd / na.denom),\n  (c, p\u2080) \u2190 prove_ne_zero c b (rat.of_int na.denom),\n  (c, _, p\u2081) \u2190 prove_mul_nat c b b',\n  (c, r, p\u2082) \u2190 prove_mul_nat c a b',\n  (c, p) \u2190 c.mk_app ``clear_denom_div [a, b, b', r, d, p\u2080, p\u2081, p\u2082],\n  return (c, r, p)\n\ntheorem nonneg_pos {\u03b1} [ordered_cancel_add_comm_monoid \u03b1] (a : \u03b1) : 0 < a \u2192 0 \u2264 a := le_of_lt\n\ntheorem lt_one_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) (h : 1 \u2264 a) : 1 < bit0 a :=\nlt_of_lt_of_le one_lt_two (bit0_le_bit0.2 h)\ntheorem lt_one_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) (h : 0 < a) : 1 < bit1 a :=\none_lt_bit1.2 h\ntheorem lt_bit0_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a < b \u2192 bit0 a < bit0 b :=\nbit0_lt_bit0.2\ntheorem lt_bit0_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a \u2264 b) : bit0 a < bit1 b :=\nlt_of_le_of_lt (bit0_le_bit0.2 h) (lt_add_one _)\ntheorem lt_bit1_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a + 1 \u2264 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 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a < b \u2192 bit1 a < bit1 b :=\nbit1_lt_bit1.2\n\ntheorem le_one_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) (h : 1 \u2264 a) : 1 \u2264 bit0 a :=\nle_of_lt (lt_one_bit0 _ h)\n-- deliberately strong hypothesis because bit1 0 is not a numeral\ntheorem le_one_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) (h : 0 < a) : 1 \u2264 bit1 a :=\nle_of_lt (lt_one_bit1 _ h)\ntheorem le_bit0_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a \u2264 b \u2192 bit0 a \u2264 bit0 b :=\nbit0_le_bit0.2\ntheorem le_bit0_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a \u2264 b) : bit0 a \u2264 bit1 b :=\nle_of_lt (lt_bit0_bit1 _ _ h)\ntheorem le_bit1_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a + 1 \u2264 b) : bit1 a \u2264 bit0 b :=\nle_of_lt (lt_bit1_bit0 _ _ h)\ntheorem le_bit1_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a \u2264 b \u2192 bit1 a \u2264 bit1 b :=\nbit1_le_bit1.2\n\ntheorem sle_one_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) : 1 \u2264 a \u2192 1 + 1 \u2264 bit0 a :=\nbit0_le_bit0.2\ntheorem sle_one_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) : 1 \u2264 a \u2192 1 + 1 \u2264 bit1 a :=\nle_bit0_bit1 _ _\ntheorem sle_bit0_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a + 1 \u2264 b \u2192 bit0 a + 1 \u2264 bit0 b :=\nle_bit1_bit0 _ _\ntheorem sle_bit0_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a \u2264 b) : bit0 a + 1 \u2264 bit1 b :=\nbit1_le_bit1.2 h\ntheorem sle_bit1_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a + 1 \u2264 b) :\n  bit1 a + 1 \u2264 bit0 b :=\n(bit1_succ a _ rfl).symm \u25b8 bit0_le_bit0.2 h\ntheorem sle_bit1_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a + 1 \u2264 b) :\n  bit1 a + 1 \u2264 bit1 b :=\n(bit1_succ a _ rfl).symm \u25b8 le_bit0_bit1 _ _ h\n\n/-- Given `a` a rational numeral, returns `\u22a2 0 \u2264 a`. -/\nmeta def prove_nonneg (ic : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| e@`(has_zero.zero) := ic.mk_app ``le_refl [e]\n| e :=\n  if ic.\u03b1 = `(\u2115) then\n    return (ic, `(nat.zero_le).mk_app [e])\n  else do\n    (ic, p) \u2190 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 `\u22a2 1 \u2264 a`. -/\nmeta def prove_one_le_nat (ic : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| a :=\n  match match_numeral a with\n  | one := ic.mk_app ``le_refl [a]\n  | bit0 a := do (ic, p) \u2190 prove_one_le_nat a, ic.mk_app ``le_one_bit0 [a, p]\n  | bit1 a := do (ic, p) \u2190 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 \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 prove_one_le_nat ic b, ic.mk_app ``le_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) \u2190 prove_pos_nat ic b, ic.mk_app ``le_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) \u2190 prove_le_nat a b, ic.mk_app ``le_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) \u2190 prove_le_nat a b, ic.mk_app ``le_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) \u2190 prove_sle_nat a b, ic.mk_app ``le_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) \u2190 prove_le_nat a b, ic.mk_app ``le_bit1_bit1 [a, b, p]\n  | _, _ := failed\n  end\nwith prove_sle_nat : expr \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 prove_one_le_nat ic b, ic.mk_app ``sle_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) \u2190 prove_one_le_nat ic b, ic.mk_app ``sle_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) \u2190 prove_sle_nat a b, ic.mk_app ``sle_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) \u2190 prove_le_nat a b, ic.mk_app ``sle_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) \u2190 prove_sle_nat a b, ic.mk_app ``sle_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) \u2190 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 `\u22a2 a \u2264 b`. -/\nadd_decl_doc prove_le_nat\n/-- Given `a`,`b` natural numerals, proves `\u22a2 a + 1 \u2264 b`. -/\nadd_decl_doc prove_sle_nat\n\n/-- Given `a`,`b` natural numerals, proves `\u22a2 a < b`. -/\nmeta def prove_lt_nat (ic : instance_cache) : expr \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 prove_one_le_nat ic b, ic.mk_app ``lt_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) \u2190 prove_pos_nat ic b, ic.mk_app ``lt_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) \u2190 prove_lt_nat a b, ic.mk_app ``lt_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) \u2190 prove_le_nat ic a b, ic.mk_app ``lt_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) \u2190 prove_sle_nat ic a b, ic.mk_app ``lt_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) \u2190 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 {\u03b1} [linear_ordered_semiring \u03b1] (a a' b b' d : \u03b1)\n  (h\u2080 : 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\u2080)\n\n/-- Given `a`,`b` nonnegative rational numerals, proves `\u22a2 a < b`. -/\nmeta def prove_lt_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nif na.denom = 1 \u2227 nb.denom = 1 then\n  prove_lt_nat ic a b\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) \u2190 ic.of_nat nd,\n  (ic, p\u2080) \u2190 prove_pos ic d,\n  (ic, a', pa) \u2190 prove_clear_denom' (\u03bb ic e _, prove_ne_zero' ic e) ic a d na nd,\n  (ic, b', pb) \u2190 prove_clear_denom' (\u03bb ic e _, prove_ne_zero' ic e) ic b d nb nd,\n  (ic, p) \u2190 prove_lt_nat ic a' b',\n  ic.mk_app ``clear_denom_lt [a, a', b, b', d, p\u2080, pa, pb, p]\n\nlemma lt_neg_pos {\u03b1} [ordered_add_comm_group \u03b1] (a b : \u03b1) (ha : 0 < a) (hb : 0 < b) : -a < b :=\nlt_trans (neg_neg_of_pos ha) hb\n\n/-- Given `a`,`b` rational numerals, proves `\u22a2 a < b`. -/\nmeta def prove_lt_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 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 \u2194 -b < -a`\n  (ic, p) \u2190 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) \u2190 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) \u2190 prove_pos ic a,\n  (ic, pb) \u2190 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 {\u03b1} [linear_ordered_semiring \u03b1] (a a' b b' d : \u03b1)\n  (h\u2080 : 0 < d) (ha : a * d = a') (hb : b * d = b') (h : a' \u2264 b') : a \u2264 b :=\nle_of_mul_le_mul_right (by rwa [ha, hb]) h\u2080\n\n/-- Given `a`,`b` nonnegative rational numerals, proves `\u22a2 a \u2264 b`. -/\nmeta def prove_le_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nif na.denom = 1 \u2227 nb.denom = 1 then\n  prove_le_nat ic a b\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) \u2190 ic.of_nat nd,\n  (ic, p\u2080) \u2190 prove_pos ic d,\n  (ic, a', pa) \u2190 prove_clear_denom' (\u03bb ic e _, prove_ne_zero' ic e) ic a d na nd,\n  (ic, b', pb) \u2190 prove_clear_denom' (\u03bb ic e _, prove_ne_zero' ic e) ic b d nb nd,\n  (ic, p) \u2190 prove_le_nat ic a' b',\n  ic.mk_app ``clear_denom_le [a, a', b, b', d, p\u2080, pa, pb, p]\n\nlemma le_neg_pos {\u03b1} [ordered_add_comm_group \u03b1] (a b : \u03b1) (ha : 0 \u2264 a) (hb : 0 \u2264 b) : -a \u2264 b :=\nle_trans (neg_nonpos_of_nonneg ha) hb\n\n/-- Given `a`,`b` rational numerals, proves `\u22a2 a \u2264 b`. -/\nmeta def prove_le_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  (ic, p) \u2190 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) \u2190 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) \u2190 prove_nonneg ic a,\n  (ic, pb) \u2190 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 `\u22a2 a \u2260 b`. This version tries to prove\n`\u22a2 a < b` or `\u22a2 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 : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nif na < nb then do\n  (ic, p) \u2190 prove_lt_rat ic a b na nb,\n  ic.mk_app ``ne_of_lt [a, b, p]\nelse do\n  (ic, p) \u2190 prove_lt_rat ic b a nb na,\n  ic.mk_app ``ne_of_gt [a, b, p]\n\ntheorem nat_cast_zero {\u03b1} [semiring \u03b1] : \u2191(0 : \u2115) = (0 : \u03b1) := nat.cast_zero\ntheorem nat_cast_one {\u03b1} [semiring \u03b1] : \u2191(1 : \u2115) = (1 : \u03b1) := nat.cast_one\ntheorem nat_cast_bit0 {\u03b1} [semiring \u03b1] (a : \u2115) (a' : \u03b1) (h : \u2191a = a') : \u2191(bit0 a) = bit0 a' :=\nh \u25b8 nat.cast_bit0 _\ntheorem nat_cast_bit1 {\u03b1} [semiring \u03b1] (a : \u2115) (a' : \u03b1) (h : \u2191a = a') : \u2191(bit1 a) = bit1 a' :=\nh \u25b8 nat.cast_bit1 _\ntheorem int_cast_zero {\u03b1} [ring \u03b1] : \u2191(0 : \u2124) = (0 : \u03b1) := int.cast_zero\ntheorem int_cast_one {\u03b1} [ring \u03b1] : \u2191(1 : \u2124) = (1 : \u03b1) := int.cast_one\ntheorem int_cast_bit0 {\u03b1} [ring \u03b1] (a : \u2124) (a' : \u03b1) (h : \u2191a = a') : \u2191(bit0 a) = bit0 a' :=\nh \u25b8 int.cast_bit0 _\ntheorem int_cast_bit1 {\u03b1} [ring \u03b1] (a : \u2124) (a' : \u03b1) (h : \u2191a = a') : \u2191(bit1 a) = bit1 a' :=\nh \u25b8 int.cast_bit1 _\ntheorem rat_cast_bit0 {\u03b1} [division_ring \u03b1] [char_zero \u03b1] (a : \u211a) (a' : \u03b1) (h : \u2191a = a') :\n  \u2191(bit0 a) = bit0 a' :=\nh \u25b8 rat.cast_bit0 _\ntheorem rat_cast_bit1 {\u03b1} [division_ring \u03b1] [char_zero \u03b1] (a : \u211a) (a' : \u03b1) (h : \u2191a = a') :\n  \u2191(bit1 a) = bit1 a' :=\nh \u25b8 rat.cast_bit1 _\n\n/-- Given `a' : \u03b1` a natural numeral, returns `(a : \u2115, \u22a2 \u2191a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_nat_uncast (ic nc : instance_cache) : \u2200 (a' : expr),\n  tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (nc, e) \u2190 nc.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``nat_cast_zero [],\n    return (ic, nc, e, p)\n  | match_numeral_result.one := do\n    (nc, e) \u2190 nc.mk_app ``has_one.one [],\n    (ic, p) \u2190 ic.mk_app ``nat_cast_one [],\n    return (ic, nc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, nc, a, p) \u2190 prove_nat_uncast a',\n    (nc, a0) \u2190 nc.mk_bit0 a,\n    (ic, p) \u2190 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) \u2190 prove_nat_uncast a',\n    (nc, a1) \u2190 nc.mk_bit1 a,\n    (ic, p) \u2190 ic.mk_app ``nat_cast_bit1 [a, a', p],\n    return (ic, nc, a1, p)\n  | _ := failed\n  end\n\n/-- Given `a' : \u03b1` a natural numeral, returns `(a : \u2124, \u22a2 \u2191a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_int_uncast_nat (ic zc : instance_cache) : \u2200 (a' : expr),\n  tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (zc, e) \u2190 zc.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``int_cast_zero [],\n    return (ic, zc, e, p)\n  | match_numeral_result.one := do\n    (zc, e) \u2190 zc.mk_app ``has_one.one [],\n    (ic, p) \u2190 ic.mk_app ``int_cast_one [],\n    return (ic, zc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, zc, a, p) \u2190 prove_int_uncast_nat a',\n    (zc, a0) \u2190 zc.mk_bit0 a,\n    (ic, p) \u2190 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) \u2190 prove_int_uncast_nat a',\n    (zc, a1) \u2190 zc.mk_bit1 a,\n    (ic, p) \u2190 ic.mk_app ``int_cast_bit1 [a, a', p],\n    return (ic, zc, a1, p)\n  | _ := failed\n  end\n\n/-- Given `a' : \u03b1` a natural numeral, returns `(a : \u211a, \u22a2 \u2191a = 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) : \u2200 (a' : expr),\n  tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (qc, e) \u2190 qc.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``rat.cast_zero [],\n    return (ic, qc, e, p)\n  | match_numeral_result.one := do\n    (qc, e) \u2190 qc.mk_app ``has_one.one [],\n    (ic, p) \u2190 ic.mk_app ``rat.cast_one [],\n    return (ic, qc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, qc, a, p) \u2190 prove_rat_uncast_nat a',\n    (qc, a0) \u2190 qc.mk_bit0 a,\n    (ic, p) \u2190 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) \u2190 prove_rat_uncast_nat a',\n    (qc, a1) \u2190 qc.mk_bit1 a,\n    (ic, p) \u2190 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 {\u03b1} [division_ring \u03b1] [char_zero \u03b1] (a b : \u211a) (a' b' : \u03b1)\n  (ha : \u2191a = a') (hb : \u2191b = b') : \u2191(a / b) = a' / b' :=\nha \u25b8 hb \u25b8 rat.cast_div _ _\n\n/-- Given `a' : \u03b1` a nonnegative rational numeral, returns `(a : \u211a, \u22a2 \u2191a = 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' : \u211a) :\n tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr) :=\nif na'.denom = 1 then\n  prove_rat_uncast_nat ic qc cz_inst a'\nelse do\n  [_, _, a', b'] \u2190 return a'.get_app_args,\n  (ic, qc, a, pa) \u2190 prove_rat_uncast_nat ic qc cz_inst a',\n  (ic, qc, b, pb) \u2190 prove_rat_uncast_nat ic qc cz_inst b',\n  (qc, e) \u2190 qc.mk_app ``has_div.div [a, b],\n  (ic, p) \u2190 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 {\u03b1} [ring \u03b1] (a : \u2124) (a' : \u03b1) (h : \u2191a = a') : \u2191-a = -a' :=\nh \u25b8 int.cast_neg _\ntheorem rat_cast_neg {\u03b1} [division_ring \u03b1] (a : \u211a) (a' : \u03b1) (h : \u2191a = a') : \u2191-a = -a' :=\nh \u25b8 rat.cast_neg _\n\n/-- Given `a' : \u03b1` an integer numeral, returns `(a : \u2124, \u22a2 \u2191a = 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 \u00d7 instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_neg a' with\n| some a' := do\n  (ic, zc, a, p) \u2190 prove_int_uncast_nat ic zc a',\n  (zc, e) \u2190 zc.mk_app ``has_neg.neg [a],\n  (ic, p) \u2190 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' : \u03b1` a rational numeral, returns `(a : \u211a, \u22a2 \u2191a = 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' : \u211a) :\n  tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_neg a' with\n| some a' := do\n  (ic, qc, a, p) \u2190 prove_rat_uncast_nonneg ic qc cz_inst a' (-na'),\n  (qc, e) \u2190 qc.mk_app ``has_neg.neg [a],\n  (ic, p) \u2190 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 {\u03b1} [semiring \u03b1] [char_zero \u03b1] (a b : \u2115) (a' b' : \u03b1)\n  (ha : \u2191a = a') (hb : \u2191b = b') (h : a \u2260 b) : a' \u2260 b' :=\nha \u25b8 hb \u25b8 mt nat.cast_inj.1 h\ntheorem int_cast_ne {\u03b1} [ring \u03b1] [char_zero \u03b1] (a b : \u2124) (a' b' : \u03b1)\n  (ha : \u2191a = a') (hb : \u2191b = b') (h : a \u2260 b) : a' \u2260 b' :=\nha \u25b8 hb \u25b8 mt int.cast_inj.1 h\ntheorem rat_cast_ne {\u03b1} [division_ring \u03b1] [char_zero \u03b1] (a b : \u211a) (a' b' : \u03b1)\n  (ha : \u2191a = a') (hb : \u2191b = b') (h : a \u2260 b) : a' \u2260 b' :=\nha \u25b8 hb \u25b8 mt rat.cast_inj.1 h\n\n/-- Given `a`,`b` rational numerals, proves `\u22a2 a \u2260 b`. Currently it tries two methods:\n\n  * Prove `\u22a2 a < b` or `\u22a2 b < a`, if the base type has an order\n  * Embed `\u2191(a':\u211a) = a` and `\u2191(b':\u211a) = b`, and then prove `a' \u2260 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 `\u211a` is well defined.\n\nWe may also add coercions to `\u2124` and `\u2115` as well in order to support `char_zero`\nrings and semirings. -/\nmeta def prove_ne : instance_cache \u2192 expr \u2192 expr \u2192 \u211a \u2192 \u211a \u2192 tactic (instance_cache \u00d7 expr)\n| ic a b na nb := prove_ne_rat ic a b na nb <|> do\n  cz_inst \u2190 mk_mapp ``char_zero [ic.\u03b1, none, none] >>= mk_instance,\n  if na.denom = 1 \u2227 nb.denom = 1 then\n    if na \u2265 0 \u2227 nb \u2265 0 then do\n      guard (ic.\u03b1 \u2260 `(\u2115)),\n      nc \u2190 mk_instance_cache `(\u2115),\n      (ic, nc, a', pa) \u2190 prove_nat_uncast ic nc a,\n      (ic, nc, b', pb) \u2190 prove_nat_uncast ic nc b,\n      (nc, p) \u2190 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.\u03b1 \u2260 `(\u2124)),\n      zc \u2190 mk_instance_cache `(\u2124),\n      (ic, zc, a', pa) \u2190 prove_int_uncast ic zc a,\n      (ic, zc, b', pb) \u2190 prove_int_uncast ic zc b,\n      (zc, p) \u2190 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.\u03b1 \u2260 `(\u211a)),\n    qc \u2190 mk_instance_cache `(\u211a),\n    (ic, qc, a', pa) \u2190 prove_rat_uncast ic qc cz_inst a na,\n    (ic, qc, b', pb) \u2190 prove_rat_uncast ic qc cz_inst b nb,\n    (qc, p) \u2190 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 `\u22a2 a \u2260 0`. -/\nmeta def prove_ne_zero (ic : instance_cache) : expr \u2192 \u211a \u2192 tactic (instance_cache \u00d7 expr)\n| a na := do\n  (ic, z) \u2190 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, \u22a2 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 \u2192 expr \u2192 expr \u2192 \u211a \u2192 \u2115 \u2192\n  tactic (instance_cache \u00d7 expr \u00d7 expr) := prove_clear_denom' prove_ne_zero\n\ntheorem clear_denom_add {\u03b1} [division_ring \u03b1] (a a' b b' c c' d : \u03b1)\n  (h\u2080 : d \u2260 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\u2080 $ by rwa [add_mul, ha, hb, hc]\n\n/-- Given `a`,`b`,`c` nonnegative rational numerals, returns `\u22a2 a + b = c`. -/\nmeta def prove_add_nonneg_rat (ic : instance_cache) (a b c : expr) (na nb nc : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nif na.denom = 1 \u2227 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) \u2190 ic.of_nat nd,\n  (ic, p\u2080) \u2190 prove_ne_zero ic d (rat.of_int nd),\n  (ic, a', pa) \u2190 prove_clear_denom ic a d na nd,\n  (ic, b', pb) \u2190 prove_clear_denom ic b d nb nd,\n  (ic, c', pc) \u2190 prove_clear_denom ic c d nc nd,\n  (ic, p) \u2190 prove_add_nat ic a' b' c',\n  ic.mk_app ``clear_denom_add [a, a', b, b', c, c', d, p\u2080, pa, pb, pc, p]\n\ntheorem add_pos_neg_pos {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : c + b = a) : a + -b = c :=\nh \u25b8 by simp\ntheorem add_pos_neg_neg {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : c + a = b) : a + -b = -c :=\nh \u25b8 by simp\ntheorem add_neg_pos_pos {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : a + c = b) : -a + b = c :=\nh \u25b8 by simp\ntheorem add_neg_pos_neg {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : b + c = a) : -a + b = -c :=\nh \u25b8 by simp\ntheorem add_neg_neg {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : b + a = c) : -a + -b = -c :=\nh \u25b8 by simp\n\n/-- Given `a`,`b`,`c` rational numerals, returns `\u22a2 a + b = c`. -/\nmeta def prove_add_rat (ic : instance_cache) (ea eb ec : expr) (a b c : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nmatch match_neg ea, match_neg eb, match_neg ec with\n| some ea, some eb, some ec := do\n  (ic, p) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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, \u22a2 a + b = c)`. -/\nmeta def prove_add_rat' (ic : instance_cache) (a b : expr) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\ndo na \u2190 a.to_rat,\n  nb \u2190 b.to_rat,\n  let nc := na + nb,\n  (ic, c) \u2190 ic.of_rat nc,\n  (ic, p) \u2190 prove_add_rat ic a b c na nb nc,\n  return (ic, c, p)\n\ntheorem clear_denom_simple_nat {\u03b1} [division_ring \u03b1] (a : \u03b1) :\n  (1:\u03b1) \u2260 0 \u2227 a * 1 = a := \u27e8one_ne_zero, mul_one _\u27e9\ntheorem clear_denom_simple_div {\u03b1} [division_ring \u03b1] (a b : \u03b1) (h : b \u2260 0) :\n  b \u2260 0 \u2227 a / b * b = a := \u27e8h, div_mul_cancel _ h\u27e9\n\n/-- Given `a` a nonnegative rational numeral, returns `(b, c, \u22a2 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 : \u211a) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr \u00d7 expr) :=\nif na.denom = 1 then do\n  (c, d) \u2190 c.mk_app ``has_one.one [],\n  (c, p) \u2190 c.mk_app ``clear_denom_simple_nat [a],\n  return (c, d, a, p)\nelse do\n  [\u03b1, _, a, b] \u2190 return a.get_app_args,\n  (c, p\u2080) \u2190 prove_ne_zero c b (rat.of_int na.denom),\n  (c, p) \u2190 c.mk_app ``clear_denom_simple_div [a, b, p\u2080],\n  return (c, b, a, p)\n\ntheorem clear_denom_mul {\u03b1} [field \u03b1] (a a' b b' c c' d\u2081 d\u2082 d : \u03b1)\n  (ha : d\u2081 \u2260 0 \u2227 a * d\u2081 = a') (hb : d\u2082 \u2260 0 \u2227 b * d\u2082 = b')\n  (hc : c * d = c') (hd : d\u2081 * d\u2082 = 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, \u2190 h, \u2190 ha.2, \u2190 hb.2, \u2190 mul_assoc, mul_right_comm a]\n\n/-- Given `a`,`b` nonnegative rational numerals, returns `(c, \u22a2 a * b = c)`. -/\nmeta def prove_mul_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nif na.denom = 1 \u2227 nb.denom = 1 then\n  prove_mul_nat ic a b\nelse do\n  let nc := na * nb, (ic, c) \u2190 ic.of_rat nc,\n  (ic, d\u2081, a', pa) \u2190 prove_clear_denom_simple ic a na,\n  (ic, d\u2082, b', pb) \u2190 prove_clear_denom_simple ic b nb,\n  (ic, d, pd) \u2190 prove_mul_nat ic d\u2081 d\u2082, nd \u2190 d.to_nat,\n  (ic, c', pc) \u2190 prove_clear_denom ic c d nc nd,\n  (ic, _, p) \u2190 prove_mul_nat ic a' b',\n  (ic, p) \u2190 ic.mk_app ``clear_denom_mul [a, a', b, b', c, c', d\u2081, d\u2082, d, pa, pb, pc, pd, p],\n  return (ic, c, p)\n\ntheorem mul_neg_pos {\u03b1} [ring \u03b1] (a b c : \u03b1) (h : a * b = c) : -a * b = -c := h \u25b8 by simp\ntheorem mul_pos_neg {\u03b1} [ring \u03b1] (a b c : \u03b1) (h : a * b = c) : a * -b = -c := h \u25b8 by simp\ntheorem mul_neg_neg {\u03b1} [ring \u03b1] (a b c : \u03b1) (h : a * b = c) : -a * -b = c := h \u25b8 by simp\n\n/-- Given `a`,`b` rational numerals, returns `(c, \u22a2 a * b = c)`. -/\nmeta def prove_mul_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  (ic, c, p) \u2190 prove_mul_nonneg_rat ic a b (-na) (-nb),\n  (ic, p) \u2190 ic.mk_app ``mul_neg_neg [a, b, c, p],\n  return (ic, c, p)\n| sum.inr ff, _ := do\n  (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n  (ic, p) \u2190 ic.mk_app ``zero_mul [b],\n  return (ic, z, p)\n| _, sum.inr ff := do\n  (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n  (ic, p) \u2190 ic.mk_app ``mul_zero [a],\n  return (ic, z, p)\n| sum.inl a, sum.inr tt := do\n  (ic, c, p) \u2190 prove_mul_nonneg_rat ic a b (-na) nb,\n  (ic, p) \u2190 ic.mk_app ``mul_neg_pos [a, b, c, p],\n  (ic, c') \u2190 ic.mk_app ``has_neg.neg [c],\n  return (ic, c', p)\n| sum.inr tt, sum.inl b := do\n  (ic, c, p) \u2190 prove_mul_nonneg_rat ic a b na (-nb),\n  (ic, p) \u2190 ic.mk_app ``mul_pos_neg [a, b, c, p],\n  (ic, c') \u2190 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 {\u03b1} [division_ring \u03b1] (a b : \u03b1) (h : a\u207b\u00b9 = b) : (-a)\u207b\u00b9 = -b :=\nh \u25b8 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, \u22a2 a\u207b\u00b9 = b)`. -/\nmeta def prove_inv : instance_cache \u2192 expr \u2192 \u211a \u2192 tactic (instance_cache \u00d7 expr \u00d7 expr)\n| ic e n :=\n  match match_sign e with\n  | sum.inl e := do\n    (ic, e', p) \u2190 prove_inv ic e (-n),\n    (ic, r) \u2190 ic.mk_app ``has_neg.neg [e'],\n    (ic, p) \u2190 ic.mk_app ``inv_neg [e, e', p],\n    return (ic, r, p)\n  | sum.inr ff := do\n    (ic, p) \u2190 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) \u2190 ic.mk_app ``inv_one [],\n        return (ic, e, p)\n      else do\n        let e := e.app_arg,\n        (ic, p) \u2190 ic.mk_app ``inv_one_div [e],\n        return (ic, e, p)\n    else if n.denom = 1 then do\n      (ic, p) \u2190 ic.mk_app ``inv_div_one [e],\n      e \u2190 infer_type p,\n      return (ic, e.app_arg, p)\n    else do\n      [_, _, a, b] \u2190 return e.get_app_args,\n      (ic, e') \u2190 ic.mk_app ``has_div.div [b, a],\n      (ic, p) \u2190 ic.mk_app ``inv_div [a, b],\n      return (ic, e', p)\n  end\n\ntheorem div_eq {\u03b1} [division_ring \u03b1] (a b b' c : \u03b1)\n  (hb : b\u207b\u00b9 = b') (h : a * b' = c) : a / b = c :=\nby rwa [ \u2190 hb, \u2190 div_eq_mul_inv] at h\n\n/-- Given `a`,`b` rational numerals, returns `(c, \u22a2 a / b = c)`. -/\nmeta def prove_div (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\ndo (ic, b', pb) \u2190 prove_inv ic b nb,\n  (ic, c, p) \u2190 prove_mul_rat ic a b' na nb\u207b\u00b9,\n  (ic, p) \u2190 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, \u22a2 -a = b)`. -/\nmeta def prove_neg (ic : instance_cache) (a : expr) : tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_sign a with\n| sum.inl a := do\n  (ic, p) \u2190 ic.mk_app ``neg_neg [a],\n  return (ic, a, p)\n| sum.inr ff := do\n  (ic, p) \u2190 ic.mk_app ``neg_zero [],\n  return (ic, a, p)\n| sum.inr tt := do\n  (ic, a') \u2190 ic.mk_app ``has_neg.neg [a],\n  p \u2190 mk_eq_refl a',\n  return (ic, a', p)\nend\n\ntheorem sub_pos {\u03b1} [add_group \u03b1] (a b b' c : \u03b1) (hb : -b = b') (h : a + b' = c) : a - b = c :=\nby rwa [\u2190 hb, \u2190 sub_eq_add_neg] at h\n\ntheorem sub_neg {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : a + b = c) : a - -b = c :=\nby rwa sub_neg_eq_add\n\n/-- Given `a`,`b` rational numerals, returns `(c, \u22a2 a - b = c)`. -/\nmeta def prove_sub (ic : instance_cache) (a b : expr) : tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_sign b with\n| sum.inl b := do\n  (ic, c, p) \u2190 prove_add_rat' ic a b,\n  (ic, p) \u2190 ic.mk_app ``sub_neg [a, b, c, p],\n  return (ic, c, p)\n| sum.inr ff := do\n  (ic, p) \u2190 ic.mk_app ``sub_zero [a],\n  return (ic, a, p)\n| sum.inr tt := do\n  (ic, b', pb) \u2190 prove_neg ic b,\n  (ic, c, p) \u2190 prove_add_rat' ic a b',\n  (ic, p) \u2190 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 : \u2115) (h : b + c = a) : a - b = c :=\nh \u25b8 nat.add_sub_cancel_left _ _\ntheorem sub_nat_neg (a b c : \u2115) (h : a + c = b) : a - b = 0 :=\nnat.sub_eq_zero_of_le $ h \u25b8 nat.le_add_right _ _\n\n/-- Given `a : nat`,`b : nat` natural numerals, returns `(c, \u22a2 a - b = c)`. -/\nmeta def prove_sub_nat (ic : instance_cache) (a b : expr) : tactic (expr \u00d7 expr) :=\ndo na \u2190 a.to_nat, nb \u2190 b.to_nat,\n  if nb \u2264 na then do\n    (ic, c) \u2190 ic.of_nat (na - nb),\n    (ic, p) \u2190 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) \u2190 ic.of_nat (nb - na),\n    (ic, p) \u2190 prove_add_nat ic a c b,\n    return (`(0 : \u2115), `(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 \u2192 tactic (expr \u00d7 expr)\n| `(%%e\u2081 + %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  let n\u2083 := n\u2081 + n\u2082,\n  (c, e\u2083) \u2190 c.of_rat n\u2083,\n  (_, p) \u2190 prove_add_rat c e\u2081 e\u2082 e\u2083 n\u2081 n\u2082 n\u2083,\n  return (e\u2083, p)\n| `(%%e\u2081 * %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  prod.snd <$> prove_mul_rat c e\u2081 e\u2082 n\u2081 n\u2082\n| `(- %%e) := do\n  c \u2190 infer_type e >>= mk_instance_cache,\n  prod.snd <$> prove_neg c e\n| `(@has_sub.sub %%\u03b1 %%inst %%a %%b) := do\n  c \u2190 mk_instance_cache \u03b1,\n  if \u03b1 = `(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 \u2190 e.to_rat,\n  c \u2190 infer_type e >>= mk_instance_cache,\n  prod.snd <$> prove_inv c e n\n| `(%%e\u2081 / %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  prod.snd <$> prove_div c e\u2081 e\u2082 n\u2081 n\u2082\n| _ := failed\n\nlemma pow_bit0 [monoid \u03b1] (a c' c : \u03b1) (b : \u2115)\n  (h : a ^ b = c') (h\u2082 : c' * c' = c) : a ^ bit0 b = c :=\nh\u2082 \u25b8 by simp [pow_bit0, h]\n\nlemma pow_bit1 [monoid \u03b1] (a c\u2081 c\u2082 c : \u03b1) (b : \u2115)\n  (h : a ^ b = c\u2081) (h\u2082 : c\u2081 * c\u2081 = c\u2082) (h\u2083 : c\u2082 * a = c) : a ^ bit1 b = c :=\nby rw [\u2190 h\u2083, \u2190 h\u2082]; simp [pow_bit1, h]\n\nsection\nopen match_numeral_result\n\n/-- Given `a` a rational numeral and `b : nat`, returns `(c, \u22a2 a ^ b = c)`. -/\nmeta def prove_pow (a : expr) (na : \u211a) :\n  instance_cache \u2192 expr \u2192 tactic (instance_cache \u00d7 expr \u00d7 expr)\n| ic b :=\n  match match_numeral b with\n  | zero := do\n    (ic, p) \u2190 ic.mk_app ``pow_zero [a],\n    (ic, o) \u2190 ic.mk_app ``has_one.one [],\n    return (ic, o, p)\n  | one := do\n    (ic, p) \u2190 ic.mk_app ``pow_one [a],\n    return (ic, a, p)\n  | bit0 b := do\n    (ic, c', p) \u2190 prove_pow ic b,\n    nc' \u2190 expr.to_rat c',\n    (ic, c, p\u2082) \u2190 prove_mul_rat ic c' c' nc' nc',\n    (ic, p) \u2190 ic.mk_app ``pow_bit0 [a, c', c, b, p, p\u2082],\n    return (ic, c, p)\n  | bit1 b := do\n    (ic, c\u2081, p) \u2190 prove_pow ic b,\n    nc\u2081 \u2190 expr.to_rat c\u2081,\n    (ic, c\u2082, p\u2082) \u2190 prove_mul_rat ic c\u2081 c\u2081 nc\u2081 nc\u2081,\n    (ic, c, p\u2083) \u2190 prove_mul_rat ic c\u2082 a (nc\u2081 * nc\u2081) na,\n    (ic, p) \u2190 ic.mk_app ``pow_bit1 [a, c\u2081, c\u2082, c, b, p, p\u2082, p\u2083],\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 \u2192 tactic (expr \u00d7 expr)\n| `(@has_pow.pow %%\u03b1 _ %%m %%e\u2081 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  match m with\n  | `(@monoid.has_pow %%_ %%_) := prod.snd <$> prove_pow e\u2081 n\u2081 c e\u2082\n  | _ := failed\n  end\n| `(monoid.npow %%e\u2081 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  prod.snd <$> prove_pow e\u2081 n\u2081 c e\u2082\n| _ := failed\n\n/-- Given `\u22a2 p`, returns `(true, \u22a2 p = true)`. -/\nmeta def true_intro (p : expr) : tactic (expr \u00d7 expr) :=\nprod.mk `(true) <$> mk_app ``eq_true_intro [p]\n\n/-- Given `\u22a2 \u00ac p`, returns `(false, \u22a2 p = false)`. -/\nmeta def false_intro (p : expr) : tactic (expr \u00d7 expr) :=\nprod.mk `(false) <$> mk_app ``eq_false_intro [p]\n\ntheorem not_refl_false_intro {\u03b1} (a : \u03b1) : (a \u2260 a) = false :=\neq_false_intro $ not_not_intro rfl\n\n/-- Evaluates the inequality operations `=`,`<`,`>`,`\u2264`,`\u2265`,`\u2260` on numerals. -/\nmeta def eval_ineq : expr \u2192 tactic (expr \u00d7 expr)\n| `(%%e\u2081 < %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 < n\u2082 then\n    do (_, p) \u2190 prove_lt_rat c e\u2081 e\u2082 n\u2081 n\u2082, true_intro p\n  else if n\u2081 = n\u2082 then do\n    (_, p) \u2190 c.mk_app ``lt_irrefl [e\u2081],\n    false_intro p\n  else do\n    (c, p') \u2190 prove_lt_rat c e\u2082 e\u2081 n\u2082 n\u2081,\n    (_, p) \u2190 c.mk_app ``not_lt_of_gt [e\u2081, e\u2082, p'],\n    false_intro p\n| `(%%e\u2081 \u2264 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 \u2264 n\u2082 then do\n    (_, p) \u2190\n      if n\u2081 = n\u2082 then c.mk_app ``le_refl [e\u2081]\n      else prove_le_rat c e\u2081 e\u2082 n\u2081 n\u2082,\n    true_intro p\n  else do\n    (c, p) \u2190 prove_lt_rat c e\u2082 e\u2081 n\u2082 n\u2081,\n    (_, p) \u2190 c.mk_app ``not_le_of_gt [e\u2081, e\u2082, p],\n    false_intro p\n| `(%%e\u2081 = %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 = n\u2082 then mk_eq_refl e\u2081 >>= true_intro\n  else do (_, p) \u2190 prove_ne c e\u2081 e\u2082 n\u2081 n\u2082, false_intro p\n| `(%%e\u2081 > %%e\u2082) := mk_app ``has_lt.lt [e\u2082, e\u2081] >>= eval_ineq\n| `(%%e\u2081 \u2265 %%e\u2082) := mk_app ``has_le.le [e\u2082, e\u2081] >>= eval_ineq\n| `(%%e\u2081 \u2260 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 = n\u2082 then\n    prod.mk `(false) <$> mk_app ``not_refl_false_intro [e\u2081]\n  else do (_, p) \u2190 prove_ne c e\u2081 e\u2082 n\u2081 n\u2082, true_intro p\n| _ := failed\n\ntheorem nat_succ_eq (a b c : \u2115) (h\u2081 : a = b) (h\u2082 : b + 1 = c) : nat.succ a = c := by rwa h\u2081\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 \u2192 tactic (instance_cache \u00d7 \u2115 \u00d7 expr \u00d7 expr)\n| `(nat.succ %%a) := do\n  (ic, n, b, p\u2081) \u2190 prove_nat_succ a,\n  let n' := n + 1,\n  (ic, c) \u2190 ic.of_nat n',\n  (ic, p\u2082) \u2190 prove_add_nat ic b `(1) c,\n  return (ic, n', c, `(nat_succ_eq).mk_app [a, b, c, p\u2081, p\u2082])\n| e := do\n  n \u2190 e.to_nat,\n  p \u2190 mk_eq_refl e,\n  return (ic, n, e, p)\n\nlemma nat_div (a b q r m : \u2115) (hm : q * b = m) (h : r + m = a) (h\u2082 : r < b) : a / b = q :=\nby rw [\u2190 h, \u2190 hm, nat.add_mul_div_right _ _ (lt_of_le_of_lt (nat.zero_le _) h\u2082),\n       nat.div_eq_of_lt h\u2082, zero_add]\n\nlemma int_div (a b q r m : \u2124) (hm : q * b = m) (h : r + m = a) (h\u2081 : 0 \u2264 r) (h\u2082 : r < b) :\n  a / b = q :=\nby rw [\u2190 h, \u2190 hm, int.add_mul_div_right _ _ (ne_of_gt (lt_of_le_of_lt h\u2081 h\u2082)),\n       int.div_eq_zero_of_lt h\u2081 h\u2082, zero_add]\n\nlemma nat_mod (a b q r m : \u2115) (hm : q * b = m) (h : r + m = a) (h\u2082 : r < b) : a % b = r :=\nby rw [\u2190 h, \u2190 hm, nat.add_mul_mod_self_right, nat.mod_eq_of_lt h\u2082]\n\nlemma int_mod (a b q r m : \u2124) (hm : q * b = m) (h : r + m = a) (h\u2081 : 0 \u2264 r) (h\u2082 : r < b) :\n  a % b = r :=\nby rw [\u2190 h, \u2190 hm, int.add_mul_mod_self, int.mod_eq_of_lt h\u2081 h\u2082]\n\nlemma int_div_neg (a b c' c : \u2124) (h : a / b = c') (h\u2082 : -c' = c) : a / -b = c :=\nh\u2082 \u25b8 h \u25b8 int.div_neg _ _\n\nlemma int_mod_neg (a b c : \u2124) (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, \u22a2 a / b = c)`\n  * `prove_div_mod ic a b tt` returns `(c, \u22a2 a % b = c)`\n-/\nmeta def prove_div_mod (ic : instance_cache) :\n  expr \u2192 expr \u2192 bool \u2192 tactic (instance_cache \u00d7 expr \u00d7 expr)\n| a b mod :=\n  match match_neg b with\n  | some b := do\n    (ic, c', p) \u2190 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\u2082) \u2190 prove_neg ic c',\n      return (ic, c, `(int_div_neg).mk_app [a, b, c', c, p, p\u2082])\n  | none := do\n    nb \u2190 b.to_nat,\n    na \u2190 a.to_int,\n    let nq := na / nb,\n    let nr := na % nb,\n    let nm := nq * nr,\n    (ic, q) \u2190 ic.of_int nq,\n    (ic, r) \u2190 ic.of_int nr,\n    (ic, m, pm) \u2190 prove_mul_rat ic q b (rat.of_int nq) (rat.of_int nb),\n    (ic, p) \u2190 prove_add_rat ic r m a (rat.of_int nr) (rat.of_int nm) (rat.of_int na),\n    (ic, p') \u2190 prove_lt_nat ic r b,\n    if ic.\u03b1 = `(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.\u03b1 = `(int) then do\n      (ic, p\u2080) \u2190 prove_nonneg ic r,\n      if mod then return (ic, r, `(int_mod).mk_app [a, b, q, r, m, pm, p, p\u2080, p'])\n      else        return (ic, q, `(int_div).mk_app [a, b, q, r, m, pm, p, p\u2080, p'])\n    else failed\n  end\n\ntheorem dvd_eq_nat (a b c : \u2115) (p) (h\u2081 : b % a = c) (h\u2082 : (c = 0) = p) : (a \u2223 b) = p :=\n(propext $ by rw [\u2190 h\u2081, nat.dvd_iff_mod_eq_zero]).trans h\u2082\ntheorem dvd_eq_int (a b c : \u2124) (p) (h\u2081 : b % a = c) (h\u2082 : (c = 0) = p) : (a \u2223 b) = p :=\n(propext $ by rw [\u2190 h\u2081, int.dvd_iff_mod_eq_zero]).trans h\u2082\n\ntheorem int_to_nat_pos (a : \u2124) (b : \u2115) (h : (by haveI := @nat.cast_coe \u2124; exact b : \u2124) = a) :\n  a.to_nat = b := by rw \u2190 h; simp\ntheorem int_to_nat_neg (a : \u2124) (h : 0 < a) : (-a).to_nat = 0 :=\nby simp [int.to_nat_zero_of_neg, h]\n\ntheorem nat_abs_pos (a : \u2124) (b : \u2115) (h : (by haveI := @nat.cast_coe \u2124; exact b : \u2124) = a) :\n  a.nat_abs = b := by rw \u2190 h; simp\ntheorem nat_abs_neg (a : \u2124) (b : \u2115) (h : (by haveI := @nat.cast_coe \u2124; exact b : \u2124) = a) :\n  (-a).nat_abs = b := by rw \u2190 h; simp\n\ntheorem neg_succ_of_nat (a b : \u2115) (c : \u2124) (h\u2081 : a + 1 = b)\n  (h\u2082 : (by haveI := @nat.cast_coe \u2124; exact b : \u2124) = c) :\n  -[1+ a] = -c := by rw [\u2190 h\u2082, \u2190 h\u2081, int.nat_cast_eq_coe_nat]; refl\n\n/-- Evaluates some extra numeric operations on `nat` and `int`, specifically\n`nat.succ`, `/` and `%`, and `\u2223` (divisibility). -/\nmeta def eval_nat_int_ext : expr \u2192 tactic (expr \u00d7 expr)\n| e@`(nat.succ _) := do\n  ic \u2190 mk_instance_cache `(\u2115),\n  (_, _, ep) \u2190 prove_nat_succ ic e,\n  return ep\n| `(%%a / %%b) := do\n  c \u2190 infer_type a >>= mk_instance_cache,\n  prod.snd <$> prove_div_mod c a b ff\n| `(%%a % %%b) := do\n  c \u2190 infer_type a >>= mk_instance_cache,\n  prod.snd <$> prove_div_mod c a b tt\n| `(%%a \u2223 %%b) := do\n  \u03b1 \u2190 infer_type a,\n  ic \u2190 mk_instance_cache \u03b1,\n  th \u2190 if \u03b1 = `(nat) then return (`(dvd_eq_nat):expr) else\n       if \u03b1 = `(int) then return `(dvd_eq_int) else failed,\n  (ic, c, p\u2081) \u2190 prove_div_mod ic b a tt,\n  (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n  (e', p\u2082) \u2190 mk_app ``eq [c, z] >>= eval_ineq,\n  return (e', th.mk_app [a, b, c, e', p\u2081, p\u2082])\n| `(int.to_nat %%a) := do\n  n \u2190 a.to_int,\n  ic \u2190 mk_instance_cache `(\u2124),\n  if n \u2265 0 then do\n    nc \u2190 mk_instance_cache `(\u2115),\n    (_, _, b, p) \u2190 prove_nat_uncast ic nc a,\n    pure (b, `(int_to_nat_pos).mk_app [a, b, p])\n  else do\n    a \u2190 match_neg a,\n    (_, p) \u2190 prove_pos ic a,\n    pure (`(0), `(int_to_nat_neg).mk_app [a, p])\n| `(int.nat_abs %%a) := do\n  n \u2190 a.to_int,\n  ic \u2190 mk_instance_cache `(\u2124),\n  nc \u2190 mk_instance_cache `(\u2115),\n  if n \u2265 0 then do\n    (_, _, b, p) \u2190 prove_nat_uncast ic nc a,\n    pure (b, `(nat_abs_pos).mk_app [a, b, p])\n  else do\n    a \u2190 match_neg a,\n    (_, _, b, p) \u2190 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 \u2190 a.to_nat,\n  ic \u2190 mk_instance_cache `(\u2124),\n  nc \u2190 mk_instance_cache `(\u2115),\n  let nb := na + 1,\n  (nc, b) \u2190 nc.of_nat nb,\n  (nc, p\u2081) \u2190 prove_add_nat nc a `(1) b,\n  (ic, c) \u2190 ic.of_nat nb,\n  (_, _, _, p\u2082) \u2190 prove_nat_uncast ic nc c,\n  pure (`(-%%c : \u2124), `(neg_succ_of_nat).mk_app [a, b, c, p\u2081, p\u2082])\n| _ := failed\n\ntheorem int_to_nat_cast (a : \u2115) (b : \u2124)\n  (h : (by haveI := @nat.cast_coe \u2124; exact a : \u2124) = b) :\n  \u2191a = b := eq.trans (by simp) h\n\n/-- Evaluates the `\u2191n` cast operation from `\u2115`, `\u2124`, `\u211a` to an arbitrary type `\u03b1`. -/\nmeta def eval_cast : expr \u2192 tactic (expr \u00d7 expr)\n| `(@coe \u2115 %%\u03b1 %%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 \u2190 a.to_nat,\n      ic \u2190 mk_instance_cache \u03b1,\n      nc \u2190 mk_instance_cache `(\u2115),\n      (ic, b) \u2190 ic.of_nat n,\n      (_, _, _, p) \u2190 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 \u2190 a.to_int,\n      ic \u2190 mk_instance_cache \u03b1,\n      zc \u2190 mk_instance_cache `(\u2124),\n      (ic, b) \u2190 ic.of_int n,\n      (_, _, _, p) \u2190 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 \u2190 a.to_rat,\n      cz_inst \u2190 mk_mapp ``char_zero [\u03b1, none, none] >>= mk_instance,\n      ic \u2190 mk_instance_cache \u03b1,\n      qc \u2190 mk_instance_cache `(\u211a),\n        (ic, b) \u2190 ic.of_rat n,\n      (_, _, _, p) \u2190 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 \u2190 a.to_nat,\n    ic \u2190 mk_instance_cache `(\u2124),\n    nc \u2190 mk_instance_cache `(\u2115),\n    (ic, b) \u2190 ic.of_nat n,\n    (_, _, _, p) \u2190 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 \u00d7 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 \u2192 tactic (expr \u00d7 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 \u2192 tactic (expr \u00d7 expr)) unit :=\n{ name      := `norm_num,\n  descr     := \"Add norm_num derivers\",\n  cache_cfg :=\n  { mk_cache := \u03bb ns, do {\n      t \u2190 ns.mfoldl\n        (\u03bb (t : expr \u2192 tactic (expr \u00d7 expr)) n, do\n          t' \u2190 eval_expr (expr \u2192 tactic (expr \u00d7 expr)) (expr.const n []),\n          pure (\u03bb e, t' e <|> t e))\n        (\u03bb _, failed),\n      pure (\u03bb 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 \u2192 tactic (expr \u00d7 expr)) := norm_num.attr.get_cache\n\n/-- Simplify an expression bottom-up using `step` to simplify the subexpressions. -/\nmeta def derive' (step : expr \u2192 tactic (expr \u00d7 expr))\n  : expr \u2192 tactic (expr \u00d7 expr) | e :=\ndo e \u2190 instantiate_mvars e,\n   (_, e', pr) \u2190\n    ext_simplify_core () {} simp_lemmas.mk (\u03bb _, failed) (\u03bb _ _ _ _ _, failed)\n      (\u03bb _ _ _ _ e,\n        do (new_e, pr) \u2190 step e,\n           guard (\u00ac new_e =\u2090 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 \u00d7 expr) := do f \u2190 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 \u2192 tactic (expr \u00d7 expr))\n  (loc : interactive.loc) : tactic unit :=\ndo ns \u2190 loc.get_locals,\n   success \u2190 tactic.replace_at (norm_num.derive' step) ns loc.include_goal,\n   when loc.include_goal $ try tactic.triv,\n   when (\u00ac 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 \u2192 tactic (expr \u00d7 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 \u2190 get_step, tactic.norm_num1 f loc\n\n/-- Normalize numerical expressions. Supports the operations\n`+` `-` `*` `/` `^` and `%` over numerical types such as\n`\u2115`, `\u2124`, `\u211a`, `\u211d`, `\u2102` and some general algebraic types,\nand can prove goals of the form `A = B`, `A \u2260 B`, `A < B` and `A \u2264 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 \u2190 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\u2081 \u2190 to_expr x,\n  (x\u2082,_) \u2190 derive x\u2081,\n  tactic.exact x\u2082\n\n/--\nNormalises numerical expressions. It supports the operations `+` `-` `*` `/` `^` and `%` over\nnumerical types such as `\u2115`, `\u2124`, `\u211a`, `\u211d`, `\u2102`, and can prove goals of the form `A = B`, `A \u2260 B`,\n`A < B` and `A \u2264 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 : \u211d) + 2 = 4 := by norm_num\nexample : (12345.2 : \u211d) \u2260 12345.3 := by norm_num\nexample : (73 : \u211d) < 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 : \u00ac nat.prime (2^11 - 1) := by norm_num\nexample (x : \u211d) (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 : \u2115 := 2^100\n#print a -- 2 ^ 100\n\ndef normed_a : \u2115 := 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`\u2115`, `\u2124`, `\u211a`, `\u211d`, `\u2102` and some general algebraic types,\nand can prove goals of the form `A = B`, `A \u2260 B`, `A < B` and `A \u2264 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 {\u03b9 \u03b9' : Type*} {\u03b1 \u03b2 : \u03b9 \u2192 Type*} {s s\u2081 s\u2082 : set \u03b9} {t t\u2081 t\u2082 : \u03a0 i, set (\u03b1 i)}\n  {u : set (\u03a3 i, \u03b1 i)} {x : \u03a3 i, \u03b1 i} {i j : \u03b9} {a : \u03b1 i}\n\n@[simp] theorem range_sigma_mk (i : \u03b9) :\n  range (sigma.mk i : \u03b1 i \u2192 sigma \u03b1) = sigma.fst \u207b\u00b9' {i} :=\nbegin\n  apply subset.antisymm,\n  { rintros _ \u27e8b, rfl\u27e9, simp },\n  { rintros \u27e8x, y\u27e9 (rfl|_),\n    exact mem_range_self y }\nend\n\ntheorem preimage_image_sigma_mk_of_ne (h : i \u2260 j) (s : set (\u03b1 j)) :\n  sigma.mk i \u207b\u00b9' (sigma.mk j '' s) = \u2205 :=\nby { ext x, simp [h.symm] }\n\nlemma image_sigma_mk_preimage_sigma_map_subset {\u03b2 : \u03b9' \u2192 Type*} (f : \u03b9 \u2192 \u03b9')\n  (g : \u03a0 i, \u03b1 i \u2192 \u03b2 (f i)) (i : \u03b9) (s : set (\u03b2 (f i))) :\n  sigma.mk i '' (g i \u207b\u00b9' s) \u2286 sigma.map f g \u207b\u00b9' (sigma.mk (f i) '' s) :=\nimage_subset_iff.2 $ \u03bb x hx, \u27e8g i x, hx, rfl\u27e9\n\nlemma image_sigma_mk_preimage_sigma_map {\u03b2 : \u03b9' \u2192 Type*} {f : \u03b9 \u2192 \u03b9'} (hf : function.injective f)\n  (g : \u03a0 i, \u03b1 i \u2192 \u03b2 (f i)) (i : \u03b9) (s : set (\u03b2 (f i))) :\n  sigma.mk i '' (g i \u207b\u00b9' s) = sigma.map f g \u207b\u00b9' (sigma.mk (f i) '' s) :=\nbegin\n  refine (image_sigma_mk_preimage_sigma_map_subset f g i s).antisymm _,\n  rintro \u27e8j, x\u27e9 \u27e8y, hys, hxy\u27e9,\n  simp only [hf.eq_iff, sigma.map] at hxy,\n  rcases hxy with \u27e8rfl, hxy\u27e9, rw [heq_iff_eq] at hxy, subst y,\n  exact \u27e8x, hys, rfl\u27e9\nend\n\n/-- Indexed sum of sets. `s.sigma t` is the set of dependent pairs `\u27e8i, a\u27e9` such that `i \u2208 s` and\n`a \u2208 t i`.-/\nprotected def sigma (s : set \u03b9) (t : \u03a0 i, set (\u03b1 i)) : set (\u03a3 i, \u03b1 i) := {x | x.1 \u2208 s \u2227 x.2 \u2208 t x.1}\n\n@[simp] lemma mem_sigma_iff : x \u2208 s.sigma t \u2194 x.1 \u2208 s \u2227 x.2 \u2208 t x.1 := iff.rfl\n@[simp] lemma mk_sigma_iff : (\u27e8i, a\u27e9 : \u03a3 i, \u03b1 i) \u2208 s.sigma t \u2194 i \u2208 s \u2227 a \u2208 t i := iff.rfl\n\nlemma mk_mem_sigma (hi : i \u2208 s) (ha : a \u2208 t i) : (\u27e8i, a\u27e9 : \u03a3 i, \u03b1 i) \u2208 s.sigma t := \u27e8hi, ha\u27e9\n\nlemma sigma_mono (hs : s\u2081 \u2286 s\u2082) (ht : \u2200 i, t\u2081 i \u2286 t\u2082 i) : s\u2081.sigma t\u2081 \u2286 s\u2082.sigma t\u2082 :=\n\u03bb x hx, \u27e8hs hx.1, ht _ hx.2\u27e9\n\nlemma sigma_subset_iff : s.sigma t \u2286 u \u2194 \u2200 \u2983i\u2984, i \u2208 s \u2192 \u2200 \u2983a\u2984, a \u2208 t i \u2192 (\u27e8i, a\u27e9 : \u03a3 i, \u03b1 i) \u2208 u :=\n\u27e8\u03bb h i hi a ha, h $ mk_mem_sigma hi ha, \u03bb h \u27e8i, a\u27e9 ha, h ha.1 ha.2\u27e9\n\nlemma forall_sigma_iff {p : (\u03a3 i, \u03b1 i) \u2192 Prop} :\n  (\u2200 x \u2208 s.sigma t, p x) \u2194 \u2200 \u2983i\u2984, i \u2208 s \u2192 \u2200 \u2983a\u2984, a \u2208 t i \u2192 p \u27e8i, a\u27e9 :=\nsigma_subset_iff\n\nlemma exists_sigma_iff {p : (\u03a3 i, \u03b1 i) \u2192 Prop} :\n  (\u2203 x \u2208 s.sigma t, p x) \u2194 \u2203 (i \u2208 s) (a \u2208 t i), p \u27e8i, a\u27e9 :=\n\u27e8\u03bb \u27e8\u27e8i, a\u27e9, ha, h\u27e9, \u27e8i, ha.1, a, ha.2, h\u27e9, \u03bb \u27e8i, hi, a, ha, h\u27e9, \u27e8\u27e8i, a\u27e9, \u27e8hi, ha\u27e9, h\u27e9\u27e9\n\n@[simp] lemma sigma_empty : s.sigma (\u03bb i, (\u2205 : set (\u03b1 i))) = \u2205 := ext $ \u03bb _, and_false _\n@[simp] lemma empty_sigma : (\u2205 : set \u03b9).sigma t = \u2205 := ext $ \u03bb _, false_and _\nlemma univ_sigma_univ : (@univ \u03b9).sigma (\u03bb _, @univ (\u03b1 i)) = univ := ext $ \u03bb _, true_and _\n@[simp] lemma sigma_univ : s.sigma (\u03bb _, univ : \u03a0 i, set (\u03b1 i)) = sigma.fst \u207b\u00b9' s :=\next $ \u03bb _, and_true _\n\n@[simp] lemma singleton_sigma : ({i} : set \u03b9).sigma t = sigma.mk i '' t i :=\next $ \u03bb x, begin\n  split,\n  { obtain \u27e8j, a\u27e9 := x,\n    rintro \u27e8(rfl : j = i), ha\u27e9,\n    exact mem_image_of_mem _ ha },\n  { rintro \u27e8b, hb, rfl\u27e9,\n    exact \u27e8rfl, hb\u27e9 }\nend\n\n@[simp] lemma sigma_singleton {a : \u03a0 i, \u03b1 i} :\n  s.sigma (\u03bb i, ({a i} : set (\u03b1 i))) = (\u03bb i, sigma.mk i $ a i) '' s :=\nby { ext \u27e8x, y\u27e9, simp [and.left_comm, eq_comm] }\n\nlemma singleton_sigma_singleton {a : \u03a0 i, \u03b1 i} :\n  ({i} : set \u03b9).sigma (\u03bb i, ({a i} : set (\u03b1 i))) = {\u27e8i, a i\u27e9} :=\nby rw [sigma_singleton, image_singleton]\n\n@[simp] lemma union_sigma : (s\u2081 \u222a s\u2082).sigma t = s\u2081.sigma t \u222a s\u2082.sigma t :=\next $ \u03bb _, or_and_distrib_right\n\n@[simp] lemma sigma_union : s.sigma (\u03bb i, t\u2081 i \u222a t\u2082 i) = s.sigma t\u2081 \u222a s.sigma t\u2082 :=\next $ \u03bb _, and_or_distrib_left\n\nlemma sigma_inter_sigma : s\u2081.sigma t\u2081 \u2229 s\u2082.sigma t\u2082 = (s\u2081 \u2229 s\u2082).sigma (\u03bb i, t\u2081 i \u2229 t\u2082 i) :=\nby { ext \u27e8x, y\u27e9, simp [and_assoc, and.left_comm] }\n\nlemma insert_sigma : (insert i s).sigma t = (sigma.mk i '' t i) \u222a s.sigma t :=\nby rw [insert_eq, union_sigma, singleton_sigma]\n\nlemma sigma_insert {a : \u03a0 i, \u03b1 i} :\n  s.sigma (\u03bb i, insert (a i) (t i)) = ((\u03bb i, \u27e8i, a i\u27e9) '' s) \u222a s.sigma t :=\nby simp_rw [insert_eq, sigma_union, sigma_singleton]\n\nlemma sigma_preimage_eq {f : \u03b9' \u2192 \u03b9} {g : \u03a0 i, \u03b2 i \u2192 \u03b1 i} :\n  (f \u207b\u00b9' s).sigma (\u03bb i, g (f i) \u207b\u00b9' t (f i)) =\n    (\u03bb p : \u03a3 i, \u03b2 (f i), sigma.mk _ (g _ p.2)) \u207b\u00b9' (s.sigma t) := rfl\n\nlemma sigma_preimage_left {f : \u03b9' \u2192 \u03b9} :\n  (f \u207b\u00b9' s).sigma (\u03bb i, t (f i)) = (\u03bb p : \u03a3 i, \u03b1 (f i), sigma.mk _ p.2) \u207b\u00b9' (s.sigma t) := rfl\n\nlemma sigma_preimage_right {g : \u03a0 i, \u03b2 i \u2192 \u03b1 i} :\n  s.sigma (\u03bb i, g i \u207b\u00b9' t i) = (\u03bb p : \u03a3 i, \u03b2 i, sigma.mk p.1 (g _ p.2)) \u207b\u00b9' (s.sigma t) := rfl\n\nlemma preimage_sigma_map_sigma {\u03b1' : \u03b9' \u2192 Type*} (f : \u03b9 \u2192 \u03b9') (g : \u03a0 i, \u03b1 i \u2192 \u03b1' (f i)) (s : set \u03b9')\n  (t : \u03a0 i, set (\u03b1' i)) :\n  sigma.map f g \u207b\u00b9' (s.sigma t) = (f \u207b\u00b9' s).sigma (\u03bb i, g i \u207b\u00b9' t (f i)) := rfl\n\n@[simp] lemma mk_preimage_sigma (hi : i \u2208 s) : sigma.mk i \u207b\u00b9' s.sigma t = t i :=\next $ \u03bb _, and_iff_right hi\n\n@[simp] lemma mk_preimage_sigma_eq_empty (hi : i \u2209 s) : sigma.mk i \u207b\u00b9' s.sigma t = \u2205 :=\next $ \u03bb _, iff_of_false (hi \u2218 and.left) id\n\nlemma mk_preimage_sigma_eq_if [decidable_pred (\u2208 s)] :\n  sigma.mk i \u207b\u00b9' s.sigma t = if i \u2208 s then t i else \u2205 :=\nby split_ifs; simp [h]\n\nlemma mk_preimage_sigma_fn_eq_if {\u03b2 : Type*} [decidable_pred (\u2208 s)] (g : \u03b2 \u2192 \u03b1 i) :\n  (\u03bb b, sigma.mk i (g b)) \u207b\u00b9' s.sigma t = if i \u2208 s then g \u207b\u00b9' t i else \u2205 :=\next $ \u03bb _, by split_ifs; simp [h]\n\nlemma sigma_univ_range_eq {f : \u03a0 i, \u03b1 i \u2192 \u03b2 i} :\n  (univ : set \u03b9).sigma (\u03bb i, range (f i)) = range (\u03bb x : \u03a3 i, \u03b1 i, \u27e8x.1, f _ x.2\u27e9) :=\next $ by simp [range]\n\nprotected lemma nonempty.sigma :\n  s.nonempty \u2192 (\u2200 i, (t i).nonempty) \u2192 (s.sigma t : set _).nonempty :=\n\u03bb \u27e8i, hi\u27e9 h, let \u27e8a, ha\u27e9 := h i in \u27e8\u27e8i, a\u27e9, hi, ha\u27e9\n\nlemma nonempty.sigma_fst : (s.sigma t : set _).nonempty \u2192 s.nonempty := \u03bb \u27e8x, hx\u27e9, \u27e8x.1, hx.1\u27e9\nlemma nonempty.sigma_snd : (s.sigma t : set _).nonempty \u2192 \u2203 i \u2208 s, (t i).nonempty :=\n\u03bb \u27e8x, hx\u27e9, \u27e8x.1, hx.1, x.2, hx.2\u27e9\n\nlemma sigma_nonempty_iff : (s.sigma t : set _).nonempty \u2194 \u2203 i \u2208 s, (t i).nonempty :=\n\u27e8nonempty.sigma_snd, \u03bb \u27e8i, hi, a, ha\u27e9, \u27e8\u27e8i, a\u27e9, hi, ha\u27e9\u27e9\n\nlemma sigma_eq_empty_iff : s.sigma t = \u2205 \u2194 \u2200 i \u2208 s, t i = \u2205 :=\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 : \u03a0 i, \u03b1 i} (ha : \u2200 i, a i \u2208 t i) :\n  (\u03bb i, sigma.mk i (a i)) '' s \u2286 s.sigma t :=\nimage_subset_iff.2 $ \u03bb i hi, \u27e8hi, ha _\u27e9\n\nlemma image_sigma_mk_subset_sigma_right (hi : i \u2208 s) : sigma.mk i '' t i \u2286 s.sigma t :=\nimage_subset_iff.2 $ \u03bb a, and.intro hi\n\nlemma sigma_subset_preimage_fst (s : set \u03b9) (t : \u03a0 i, set (\u03b1 i)) : s.sigma t \u2286 sigma.fst \u207b\u00b9' s :=\n\u03bb a, and.left\n\nlemma fst_image_sigma_subset (s : set \u03b9) (t : \u03a0 i, set (\u03b1 i)) : sigma.fst '' s.sigma t \u2286 s :=\nimage_subset_iff.2 $ \u03bb a, and.left\n\nlemma fst_image_sigma (s : set \u03b9) (ht : \u2200 i, (t i).nonempty) : sigma.fst '' s.sigma t = s :=\n(fst_image_sigma_subset _ _).antisymm $ \u03bb i hi, let \u27e8a, ha\u27e9 := ht i in \u27e8\u27e8i, a\u27e9, \u27e8hi, ha\u27e9, rfl\u27e9\n\nlemma sigma_diff_sigma : s\u2081.sigma t\u2081 \\ s\u2082.sigma t\u2082 = s\u2081.sigma (t\u2081 \\ t\u2082) \u222a (s\u2081 \\ s\u2082).sigma t\u2081 :=\next $ \u03bb x, by by_cases h\u2081 : x.1 \u2208 s\u2081; by_cases h\u2082 : x.2 \u2208 t\u2081 x.1; simp [*, \u2190imp_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 := \u2115\n\ninductive FormO : Type\n| pos : Atom \u00d7 \u2115 \u2192 FormO\n| neg : Atom \u00d7 \u2115 \u2192 FormO\n| tensor : FormO \u2192 FormO \u2192 FormO\n| par : FormO \u2192 FormO \u2192 FormO\n\ndef FormO.negation : FormO \u2192 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 ` \u2297 `:70 := FormO.tensor\ninfix ` \u214b `:65 := FormO.par\nprefix `~` := FormO.negation\n\ninductive Link : Type\n| ax : Atom \u00d7 \u2115 \u2192 Link\n| cut : FormO \u2192 Link\n| tensor : FormO \u2192 FormO \u2192 Link\n| par : FormO \u2192 FormO \u2192 Link\n\ninductive premise : FormO \u2192 Link \u2192 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 \u2192 Link \u2192 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 \u2297 Bi) (Link.tensor Ai Bi)\n| par {Ai Bi}    : conclusion (Ai \u2297 Bi) (Link.par Ai Bi)\n\ninductive mem_Link (Ai : FormO) (l : Link) : Prop\n| prem : premise Ai l \u2192 mem_Link\n| con : conclusion Ai l \u2192 mem_Link\n\ninstance : has_mem FormO Link := \u27e8mem_Link\u27e9\n\nstructure proof_structure : Type :=\n(links : set Link)\n(prem_unique : \u2200 Ai : FormO, \u2200 l\u2081 l\u2082 \u2208 links, premise Ai l\u2081 \u2192 premise Ai l\u2082 \u2192 l\u2081 = l\u2082)\n(con_unique : \u2200 Ai : FormO, \u2200 l\u2081 l\u2082 \u2208 links, conclusion Ai l\u2081 \u2192 conclusion Ai l\u2082 \u2192 l\u2081 = l\u2082)\n\ninductive mem_FormO_ps (Ai : FormO) (ps : proof_structure) : Prop\n| mk {l} : l \u2208 ps.links \u2192 Ai \u2208 l \u2192 mem_FormO_ps\n\ninstance : has_mem FormO proof_structure := \u27e8mem_FormO_ps\u27e9\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 `\u2193`:max_plus := with_down\npostfix `\u2191`: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 \u2192 switch\n\n@[simp]\ndef switch.flip {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b2) : switch \u2192 \u03b1 \u2192 \u03b1 \u2192 \u03b2\n| L a b := f a b\n| R a b := f b a\n\ninductive steps_tensor (Ai Bi : FormO) : FormO \u00d7 dir \u2192 FormO \u00d7 dir \u2192 Prop\n| down : steps_tensor Ai\u2193 (Ai \u2297 Bi)\u2193\n| turn : steps_tensor Bi\u2193 Ai\u2191\n| up : steps_tensor (Ai \u2297 Bi)\u2191 Bi\u2191\n\ninductive steps_par (Ai Bi : FormO) : FormO \u00d7 dir \u2192 FormO \u00d7 dir \u2192 Prop\n| down : steps_par Ai\u2193 (Ai \u214b Bi)\u2193\n| turn : steps_par Bi\u2193 Bi\u2191\n| up : steps_par (Ai \u214b Bi)\u2191 Ai\u2191\n\ninductive steps (T : switch) : Link \u2192 FormO \u00d7 dir \u2192 FormO \u00d7 dir \u2192 Prop\n| ax_pos  {ai} : steps (Link.ax ai) (FormO.pos ai)\u2191 (FormO.neg ai)\u2193\n| ax_neg  {ai} : steps (Link.ax ai) (FormO.neg ai)\u2191 (FormO.pos ai)\u2193\n| cut_pos  {Ai} : steps (Link.cut Ai) Ai\u2193 (~Ai)\u2191\n| cut_neg  {Ai} : steps (Link.cut Ai) (~Ai)\u2193 Ai\u2191\n| tensor {Ai Bi X Y} :\n  T.flip steps_tensor Ai Bi X Y \u2192\n  steps (Link.tensor Ai Bi) X Y\n| par {Ai Bi X Y} :\n  T.flip steps_par Ai Bi X Y \u2192\n  steps (Link.par Ai Bi) X Y\n\ninductive trip (ps : proof_structure) (S : switching) : \u2115 \u2192 FormO \u00d7 dir \u2192 FormO \u00d7 dir \u2192 Prop\n| single {Ai d}    : Ai \u2208 ps \u2192 trip 0 (Ai,d) (Ai,d)\n| cons {X Y Z \u0394 n} : \u0394 \u2208 ps.links \u2192 steps (S \u0394) \u0394 X Y \u2192 trip n Y Z \u2192 trip (n.succ) X Z\n\ninductive journey (ps : proof_structure) (S : switching) : \u2115 \u2192 FormO \u00d7 dir \u2192 FormO \u00d7 dir \u2192 Type\n| trip {n X Y} : trip ps S n X Y \u2192 journey 0 X Y\n| chain {Ai n m X Z} : (\u2200 \u0394 \u2208 ps.links, \u00acpremise Ai \u0394) \u2192 trip ps S n X Ai\u2193 \u2192 journey m Ai\u2191 Z \u2192 journey m.succ X Z \n\ninductive trip2 (ps : proof_structure) (S : switching) : FormO \u00d7 dir \u2192 FormO \u00d7 dir \u2192 Prop\n| single (Ai : FormO) (d : dir) : Ai \u2208 ps \u2192 trip2 (Ai,d) (Ai,d)\n| front (Ai Bi Ci : FormO) (d\u2081 d\u2082 d\u2083 : dir) (\u0394 : Link) :\n  \u0394 \u2208 ps.links \u2192 steps (S \u0394) \u0394 (Ai,d\u2081) (Bi,d\u2082) \u2192 trip2 (Bi,d\u2082) (Ci, d\u2083) \u2192 trip2 (Ai,d\u2081) (Ci,d\u2083)\n| back (Ai Bi Ci : FormO) (d\u2081 d\u2082 d\u2083 : dir) (\u0394 : Link) :\n  \u0394 \u2208 ps.links \u2192 steps (S \u0394) \u0394 (Bi,d\u2082) (Ci,d\u2083) \u2192 trip2 (Ai,d\u2081) (Bi, d\u2082) \u2192 trip2 (Ai,d\u2081) (Ci,d\u2083)\n\ninductive list_trip (ps : proof_structure) (S : switching) : list (FormO \u00d7 dir) \u2192 Prop\n| emp : list_trip []\n| single (Ai : FormO) (d : dir) : Ai \u2208 ps \u2192 list_trip [(Ai,d)]\n| cons (Ai Bi : FormO) (d\u2081 d\u2082 : dir) (\u0393 : list (FormO \u00d7 dir)) (\u0394 : Link) :\n  \u0394 \u2208 ps.links \u2192 steps (S \u0394) \u0394 (Ai,d\u2081) (Bi,d\u2082) \u2192 list_trip ((Bi,d\u2082) :: \u0393) \u2192 list_trip ((Ai,d\u2081) :: (Bi,d\u2082) :: \u0393)\n\nlemma not_self_dual {Ai} : (~Ai) \u2260 Ai :=\n  by induction Ai; rintro \u27e8_\u27e9\n\nlemma not_self_sub_left_tensor {Ai Bi} : Ai \u2260 Ai \u2297 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 \u2260 Ai \u2297 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 [\u2190nat.add_assoc],\n  apply nat.le_add_right,\nend\n\nlemma not_self_sub_left_par {Ai Bi} : Ai \u2260 Ai \u214b 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 \u2260 Ai \u214b 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 [\u2190nat.add_assoc],\n  apply nat.le_add_right,\nend\n\nsection\n  variable {\u0394 : Link}\n  variable {T : switch}\n  variables {Ai Bi Ci : FormO}\n  variables {X Y Z : FormO \u00d7 dir}\n\n  lemma steps_tensor_unique_prev : Ai \u2260 Bi \u2192 steps_tensor Ai Bi X Z \u2192 steps_tensor Ai Bi Y Z \u2192 X = Y :=\n  begin\n    intros nAB s\u2081 s\u2082,\n    generalize_hyp e\u2081 : Z = Z' at s\u2082,\n    cases s\u2081;\n    cases s\u2082;\n    try {refl};\n    try { cases e\u2081, apply absurd rfl nAB};\n    try {generalize_hyp e\u2083 : Ai \u2297 Bi = AiBi at e\u2081, cases e\u2081 },\n  end\n\n  lemma steps_tensor_unique_next : Ai \u2260 Bi \u2192 steps_tensor Ai Bi X Y \u2192 steps_tensor Ai Bi X Z \u2192 Y = Z :=\n  begin\n    intros nAB s\u2081 s\u2082,\n    generalize_hyp e\u2081 : X = X' at s\u2082,\n    cases s\u2081;\n    cases s\u2082;\n    try {refl};\n    try { cases e\u2081, apply absurd rfl nAB};\n    try {generalize_hyp e\u2083 : Ai \u2297 Bi = AiBi at e\u2081, cases e\u2081 },\n  end\n\n  lemma steps_par_unique_prev : Ai \u2260 Bi \u2192 steps_par Ai Bi X Z \u2192 steps_par Ai Bi Y Z \u2192 X = Y :=\n  begin\n    intros nAB s\u2081 s\u2082,\n    generalize_hyp e\u2081 : Z = Z' at s\u2082,\n    cases s\u2081;\n    cases s\u2082;\n    try {refl};\n    try { cases e\u2081, apply absurd rfl nAB};\n    try {generalize_hyp e\u2083 : Ai \u214b Bi = AiBi at e\u2081, cases e\u2081 },\n  end\n\n  lemma steps_par_unique_next : Ai \u2260 Bi \u2192 steps_par Ai Bi X Y \u2192 steps_par Ai Bi X Z \u2192 Y = Z :=\n  begin\n    intros nAB s\u2081 s\u2082,\n    generalize_hyp e\u2081 : X = X' at s\u2082,\n    cases s\u2081;\n    cases s\u2082;\n    try {refl};\n    try { cases e\u2081, apply absurd rfl nAB};\n    try {generalize_hyp e\u2083 : Ai \u214b Bi = AiBi at e\u2081, cases e\u2081 },\n  end\n\n  theorem steps_unique_prev : steps T \u0394 X Z \u2192 steps T \u0394 Y Z \u2192 X = Y :=\n  begin\n    intros s\u2081 s\u2082,\n    cases s\u2081,\n    case steps.ax_pos : ai { cases s\u2082, refl },\n    case steps.ax_neg : ai { cases s\u2082, refl },\n    case steps.cut_pos : Ai { \n      generalize_hyp e\u2081 : (~Ai) = nAi at s\u2082,\n      cases s\u2082, refl, apply absurd e\u2081 not_self_dual },\n    case steps.cut_neg : Ai { \n      generalize_hyp e\u2081 : (Ai,up) = Aiu at s\u2082,\n      cases s\u2082,\n      generalize_hyp e\u2082 : (~Ai) = nAi at e\u2081,\n      cases e\u2081, apply absurd e\u2082 not_self_dual, refl },\n    case steps.tensor : Ai Bi X Z' t\u2081 {\n      rcases s\u2082 with _ | _ | _ | _ | \u27e8_,_,_,_,t\u2082\u27e9,\n      cases T; simp at t\u2081 t\u2082;\n      apply steps_tensor_unique_prev _ t\u2081 t\u2082,\n      cases h\u0394, 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\u2081 {\n      rcases s\u2082 with _ | _ | _ | \u27e8_,_,_,_,_,_,_,p\u2082\u27e9,\n      cases T; simp at p\u2081 p\u2082;\n      apply steps_par_unique_prev _ _ _ p\u2081 p\u2082;\n      cases h\u0394, 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 \u0394 \u2192 steps T \u0394 X Y \u2192 steps T \u0394 X Z \u2192 Y = Z :=\n  begin\n    intros h\u0394 s\u2081 s\u2082,\n    cases s\u2081,\n    case steps.ax : A ai ni Bi Ci d\u2081 {\n      cases s\u2082 with _ _ _ Di _ d\u2082,\n      rw dual_unique_next d\u2081 d\u2082 },\n    case steps.cut : A ai ni Bi Ci d\u2081 {\n      rcases s\u2082 with _ | \u27e8_,_,_,Di,_,d\u2082\u27e9,\n      rw dual_unique_next d\u2082 d\u2081\n    },\n    case steps.tensor : A B ai bi ci X y t\u2081 {\n      rcases s\u2082 with _ | _ | \u27e8_,_,_,_,_,_,_,t\u2082\u27e9,\n      cases T; simp at t\u2081 t\u2082;\n      apply steps_tensor_unique_next _ _ _ t\u2081 t\u2082;\n      cases h\u0394, 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\u2081 {\n      rcases s\u2082 with _ | _ | _ | \u27e8_,_,_,_,_,_,_,p\u2082\u27e9,\n      cases T; simp at p\u2081 p\u2082;\n      apply steps_par_unique_next _ _ _ p\u2081 p\u2082;\n      cases h\u0394, 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 \u0394 Ai\u2191 X \u2192 conclusion Ai \u0394 :=\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 \u0394 Ai\u2193 X \u2192 premise Ai \u0394 :=\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 \u0394 X Ai\u2193 \u2192 conclusion Ai \u0394 :=\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 \u0394 X Ai\u2191 \u2192 premise Ai \u0394 :=\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    \u0394 \u2208 ps.links \u2192 steps T \u0394 (Ai,d) X \u2192 Ai \u2208 ps :=\n  begin\n    intros h\u0394 s, cases d,\n    case bool.ff : { exact \u27e8h\u0394, mem_Link.prem $ prem_of_steps_down s\u27e9, }, \n    case bool.tt : { exact \u27e8h\u0394, mem_Link.con $ con_of_steps_up s\u27e9, }, \n  end\n\n  lemma mem_ps_of_steps_next {ps : proof_structure} {d : dir} :\n    \u0394 \u2208 ps.links \u2192 steps T \u0394 X (Bi,d) \u2192 Bi \u2208 ps :=\n  begin\n    intros h\u0394 s, cases d,\n    case bool.ff : { exact \u27e8h\u0394, mem_Link.con $ con_of_steps_down s\u27e9, }, \n    case bool.tt : { exact \u27e8h\u0394, mem_Link.prem $ prem_of_steps_up s\u27e9, }, \n  end\n\nend\n\nsection\n  variable {ps : proof_structure}\n  variable {S : switching}\n  variables {X Y Z : FormO \u00d7 dir}\n  variables {n m : \u2115}\n\n  theorem link_unique_of_steps_prev {\u0394\u2081 \u0394\u2082} :\n    \u0394\u2081 \u2208 ps.links \u2192 \u0394\u2082 \u2208 ps.links \u2192 steps (S \u0394\u2081) \u0394\u2081 X Y \u2192 steps (S \u0394\u2082) \u0394\u2082 X Z \u2192 \u0394\u2081 = \u0394\u2082 :=\n  begin\n    intros v\u2081 v\u2082 s\u2081 s\u2082,\n    rcases X with \u27e8Ai,\u27e8_|_\u27e9\u27e9,\n      apply ps.prem_unique Ai _ _ v\u2081 v\u2082 (prem_of_steps_down s\u2081) (prem_of_steps_down s\u2082),\n    apply ps.con_unique Ai _ _ v\u2081 v\u2082 (con_of_steps_up s\u2081) (con_of_steps_up s\u2082),\n  end\n\n  theorem link_unique_of_steps_next {\u0394\u2081 \u0394\u2082} :\n    \u0394\u2081 \u2208 ps.links \u2192 \u0394\u2082 \u2208 ps.links \u2192 steps (S \u0394\u2081) \u0394\u2081 X Z \u2192 steps (S \u0394\u2082) \u0394\u2082 Y Z \u2192 \u0394\u2081 = \u0394\u2082 :=\n  begin\n    intros v\u2081 v\u2082 s\u2081 s\u2082,\n    rcases Z with \u27e8Ci,\u27e8_|_\u27e9\u27e9,\n      apply ps.con_unique Ci _ _ v\u2081 v\u2082 (con_of_steps_down s\u2081) (con_of_steps_down s\u2082),\n    apply ps.prem_unique Ci _ _ v\u2081 v\u2082 (prem_of_steps_up s\u2081) (prem_of_steps_up s\u2082),\n  end\n\n  def trip.rcons {\u0394} : \u0394 \u2208 ps.links \u2192 trip ps S n X Y \u2192 steps (S \u0394) \u0394 Y Z \u2192 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\u0394 tXY sYZ,\n    cases tXY,\n    case trip.single : Ai d hA { \n      apply trip.cons h\u0394 sYZ,\n      cases Z with Ci d', simp,\n      apply trip.single,\n      apply mem_ps_of_steps_next h\u0394 sYZ,\n    },\n    case trip.cons : _ W _ \u0394' k h\u0394' sXW tWY {\n      apply trip.cons h\u0394' sXW, simp,\n      apply ih k (lt_add_one k) h\u0394 tWY sYZ },\n    \n  end\n\n  def trip.concat : trip ps S n X Y \u2192 trip ps S m Y Z \u2192 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, \u2190nat.add_succ, nat.add_comm],\n      cases tYZ with _ _ _ _ W _ \u0394' _ h\u0394' sYW tWZ,\n      apply ih _ tWZ,\n      apply trip.rcons h\u0394' tXY sYW }\n  end\n\n  theorem trip_unique_start : trip ps S n X Z \u2192 trip ps S n Y Z \u2192 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 _ | \u27e8_,X',_,\u0394,_,h\u0394,sX,tX'\u27e9,\n      rcases tY with _ | \u27e8_,Y',_,\u0394',_,h\u0394',sY,tY'\u27e9,\n      have : Y' = X', by exact ih tY' tX',\n      rw this at sY,\n      have : \u0394' = \u0394, apply link_unique_of_steps_next h\u0394' h\u0394 sY sX,\n      rw this at sY,\n      exact steps_unique_prev (ps.valid \u0394 h\u0394) sX sY,\n      }\n  end\n\n  lemma trip_exists_rcons : trip ps S n.succ X Z \u2192 \u2203 Y \u0394, \u2203 h\u0394 : \u0394 \u2208 ps.links, \u2203 tXY : trip ps S n X Y, steps (S \u0394) \u0394 Y Z :=\n  begin\n    revert X,\n    induction n,\n    case nat.zero : {\n      intros X tXZ, cases tXZ with _ _ _ _ Y _ \u0394 _ h\u0394 sXY tYZ,\n      use X, use \u0394, refine \u27e8h\u0394,_\u27e9,\n      constructor,\n      cases X with Ai d,\n      constructor,\n      apply mem_ps_of_steps_prev h\u0394 sXY,\n      cases tYZ, assumption,\n      },\n    case nat.succ : n ih {\n      intros X tXZ, cases tXZ with _ _ _ _ Y _ \u0394 _ h\u0394 sXY tYZ,\n      specialize ih tYZ,\n      rcases ih with \u27e8Y',\u0394',h\u0394',tYY',sY'Z\u27e9,\n      exact \u27e8Y',\u0394',h\u0394',trip.cons h\u0394 sXY tYY',sY'Z\u27e9,\n    }\n  end\n\n  theorem trip_unique_stop : trip ps S n X Y \u2192 trip ps S n X Z \u2192 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 \u27e8U,\u0394\u2081,h\u0394\u2081,tXU, sUY\u27e9,\n      rcases (trip_exists_rcons tXZ) with \u27e8V,\u0394\u2082,h\u0394\u2082,tXV, sVZ\u27e9,\n      have : V = U, apply ih tXV tXU,\n      rw this at sVZ,\n      have : \u0394\u2082 = \u0394\u2081, apply link_unique_of_steps_prev h\u0394\u2082 h\u0394\u2081 sVZ sUY,\n      rw this at sVZ,\n      apply steps_unique_next (ps.valid \u0394\u2081 h\u0394\u2081) 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 \u00d7 R) : Prop :=\nvalp (weierstrass e P) > 0 \u2227 valp (dweierstrass_dx e P) > 0 \u2227 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 \u00d7 R) :\n  is_local_singular_point evr.valtn e P \u2194 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 [\u2190 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  \u2203 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 \u00d7 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 \u00d7 R \u00d7 R :=\n\u27e8(singular_point_on_special evr e).1, 0, (singular_point_on_special evr e).2\u27e9\n\n-- def move_singular_point_to_origin_iso [DecidableEq R] (evr : EnatValRing p) (e : Model R) : R \u00d7 R \u00d7 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 \u00d7 R \u00d7 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(\u2203 P, is_local_singular_point evr.valtn e P) \u2192\n  is_local_singular_point evr.valtn (move_singular_point_to_origin_iso evr e) (0, 0) :=\nby\n  rintro \u27e8P, h\u27e9\n  have := Model.Field.move_singular_point_to_origin' (e.map evr.RingCon.mk') \u27e8P.map evr.RingCon.mk' evr.RingCon.mk', ?_\u27e9\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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 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 [\u2190evr.sub_val_mul_right h1, \u2190evr.sub_val_mul_left h1, evr.sub_val_sub_val,\n    \u2190evr.sub_val_mul_right h2, \u2190evr.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 \u2265 1)\n  (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 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 [\u2190evr.sub_val_mul_right h3, \u2190evr.sub_val_mul_left h1, evr.sub_val_sub_val,\n    \u2190evr.sub_val_mul_right h4, \u2190evr.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 \u2265 3)\n  (h6 : evr.valtn e.a6 \u2265 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 [\u2190evr.sub_val_mul_right h3, \u2190evr.sub_val_mul_left h3, evr.sub_val_sub_val,\n    \u2190evr.sub_val_mul_right h6, \u2190evr.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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 2) (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 4)\n  (h6 : evr.valtn e.a6 \u2265 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 [\u2190evr.sub_val_mul_right h1, \u2190evr.sub_val_mul_left h1, evr.sub_val_sub_val,\n    \u2190evr.sub_val_mul_right h6, \u2190evr.sub_val_mul_left (val_mul_ge_of_both_ge evr.valtn h1 h1), evr.sub_val_sub_val]\n  rw [\u2190evr.sub_val_mul_right h3, \u2190evr.sub_val_mul_left h1, evr.sub_val_sub_val,\n    \u2190evr.sub_val_mul_right h4, \u2190evr.sub_val_mul_left (val_mul_ge_of_both_ge evr.valtn h1 h3), evr.sub_val_sub_val]\n  rw [\u2190evr.sub_val_mul_right h2, \u2190evr.sub_val_mul_right h6,\n    \u2190evr.sub_val_mul_left (val_mul_ge_of_right_ge evr.valtn h2), evr.sub_val_sub_val]\n  rw [\u2190evr.sub_val_mul_left h2, \u2190evr.sub_val_mul_right h3, \u2190evr.sub_val_mul_right h3,\n    evr.sub_val_sub_val, \u2190evr.sub_val_mul_left (val_mul_ge_of_both_ge evr.valtn h2 h3), evr.sub_val_sub_val]\n  rw [\u2190evr.sub_val_mul_right h4, \u2190evr.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 [\u2190val_neg] at h134\n  rw [\u2190val_neg] at h44\n\n  rw [sub_eq_add_neg, sub_eq_add_neg, \u2190evr.sub_val_neg, \u2190evr.sub_val_neg,\n    \u2190evr.sub_val_add h116 h134, \u2190evr.sub_val_add _ h26, \u2190evr.sub_val_add _ h233,\n    \u2190evr.sub_val_add _ h44, \u2190sub_eq_add_neg, \u2190sub_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 \u2265 2) (hb4 : evr.valtn e.b4 \u2265 4)\n  (hb6 : evr.valtn e.b6 \u2265 6) (hb8 : evr.valtn e.b8 \u2265 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) \u2265 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) \u2265 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) \u2265 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) \u2265 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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 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 \u2265 1)\n  (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 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 \u2265 3)\n  (h6 : evr.valtn e.a6 \u2265 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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 2) (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 4)\n  (h6 : evr.valtn e.a6 \u2265 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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 2) : evr.valtn e.b2 \u2265 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 \u2265 1)\n  (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 4) : evr.valtn e.b4 \u2265 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 \u2265 3)\n  (h6 : evr.valtn e.a6 \u2265 6) : evr.valtn e.b6 \u2265 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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 2) (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 4)\n  (h6 : evr.valtn e.a6 \u2265 6) : evr.valtn e.b8 \u2265 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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 2) (h3 : evr.valtn e.a3 \u2265 3)\n  (h4 : evr.valtn e.a4 \u2265 4) (h6 : evr.valtn e.a6 \u2265 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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 2) (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 4)\n  (h6 : evr.valtn e.a6 \u2265 6) : evr.valtn e.discr \u2265 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 [\u2190neg_mul_eq_neg_mul, \u2190neg_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 \u2265 1)\n  (h2 : evr.valtn e.a2 \u2265 2) (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 4)\n  (h6 : evr.valtn e.a6 \u2265 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 [\u2190evr.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 \u2265 1)\n  (h2 : SurjVal.v evr.valtn e.toModel.a2 \u2265 2) (h3 : SurjVal.v evr.valtn e.toModel.a3 \u2265 3)\n  (h4 : SurjVal.v evr.valtn e.toModel.a4 \u2265 4) (h6 : SurjVal.v evr.valtn e.toModel.a6 \u2265 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) : \u2115 :=\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 \u2265 1) (h2 : evr.valtn e.a2 \u2265 2)\n  (h3 : evr.valtn e.a3 \u2265 3) (h4 : evr.valtn e.a4 \u2265 4) (h6 : evr.valtn e.a6 \u2265 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 \u2265 1)\n  (h2 : valp e.a2 = 1) : valp e.b2 \u2265 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 \u2265 1)\n  (h3 : valp e.a3 \u2265 q) (h4 : valp e.a4 \u2265 q + 1) : valp e.b4 \u2265 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 : \u2115} (valp : SurjVal p) (e : ValidModel R) (h3 : valp e.a3 \u2265 q)\n  (h6 : valp e.a6 \u2265 2 * q) : valp e.b6 \u2265 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 : \u2115} (valp : SurjVal p) (e : ValidModel R) (h1 : valp e.a1 \u2265 1)\n  (h2 : valp e.a2 = 1) (h3 : valp e.a3 \u2265 q) (h4 : valp e.a4 \u2265 q + 1)\n  (h6 : valp e.a6 \u2265 2 * q) : valp e.b8 \u2265 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 : \u2115) (h : 1 < q) (hn : 2 * q \u2264 n) : 2 * q + 3 \u2264 n + n :=\nby linarith\n\nprivate lemma aux' (n q m t : \u2115) (h : 1 < q) (h2': 1 \u2264 n) (h4': q + 1 \u2264 m) (h6': 2 * q \u2264 t) :\n  2 * q + 3 \u2264 n + (m + t) :=\nby linarith\n\nlemma v_discr_of_v_ai {p : R} {q : \u2115} (valp : SurjVal p) (e : ValidModel R) (hq : q > 1)\n  (h1 : valp e.a1 \u2265 1) (h2 : valp e.a2 = 1) (h3 : valp e.a3 \u2265 q)\n  (h4 : valp e.a4 \u2265 q + 1) (h6 : valp e.a6 \u2265 2 * q) :\n  valp e.discr \u2265 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 [\u2190neg_mul_eq_neg_mul, \u2190neg_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, \u2190add_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 [\u2190add_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 \u2228 p = 3) (valp : SurjVal p) : valp 12 \u2265 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 [\u2190p2]\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 [\u2190p3]\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 \u2265 1) (h_p : valp 12 \u2265 1) : valp (rst_iso r s t e).b2 \u2265 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 \u0394cubic (c : R \u00d7 R \u00d7 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 \u00d7 R \u00d7 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 (\u0394cubic (model_to_cubic evr e)) = 0\n\ndef \u03b4multiplicity (c : R \u00d7 R \u00d7 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 (\u0394cubic (model_to_cubic evr e)) > 0 \u2227 evr.valtn (\u03b4multiplicity (model_to_cubic evr e)) = 0\n\ndef cubic_has_triple_root {p : R} (evr : EnatValRing p) (e : ValidModel R) : Prop :=\nevr.valtn (\u0394cubic (model_to_cubic evr e)) > 0 \u2227 evr.valtn (\u03b4multiplicity (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 \u2227 evr.valtn a4p2 > 0 \u2227 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 \u2192 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 \u2227 evr.valtn a4p2 > 0 \u2227 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 \u2192 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 {\u03b1 \u03b2 : Type _}\n\nopen Topology\n\n/-- If `l` is a filter on `\u03b1`, then a function `f : \u03b1 \u2192 \u03b2` is `zero_at_filter l`\n  if it tends to zero along `l`. -/\ndef ZeroAtFilter [Zero \u03b2] [TopologicalSpace \u03b2] (l : Filter \u03b1) (f : \u03b1 \u2192 \u03b2) : Prop :=\n  Filter.Tendsto f l (\ud835\udcdd 0)\n#align filter.zero_at_filter Filter.ZeroAtFilter\n\ntheorem zero_zeroAtFilter [Zero \u03b2] [TopologicalSpace \u03b2] (l : Filter \u03b1) :\n    ZeroAtFilter l (0 : \u03b1 \u2192 \u03b2) :=\n  tendsto_const_nhds\n#align filter.zero_zero_at_filter Filter.zero_zeroAtFilter\n\ntheorem ZeroAtFilter.add [TopologicalSpace \u03b2] [AddZeroClass \u03b2] [ContinuousAdd \u03b2] {l : Filter \u03b1}\n    {f g : \u03b1 \u2192 \u03b2} (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 \u03b2] [AddGroup \u03b2] [ContinuousNeg \u03b2] {l : Filter \u03b1}\n    {f : \u03b1 \u2192 \u03b2} (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 {\ud835\udd5c : Type _} [TopologicalSpace \ud835\udd5c] [TopologicalSpace \u03b2] [Zero \ud835\udd5c] [Zero \u03b2]\n    [SMulWithZero \ud835\udd5c \u03b2] [ContinuousSMul \ud835\udd5c \u03b2] {l : Filter \u03b1} {f : \u03b1 \u2192 \u03b2} (c : \ud835\udd5c)\n    (hf : ZeroAtFilter l f) : ZeroAtFilter l (c \u2022 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 : \u03b1 \u2192 \u03b2` which\ntend to zero along `l`. -/\ndef zeroAtFilterSubmodule [TopologicalSpace \u03b2] [Semiring \u03b2] [ContinuousAdd \u03b2] [ContinuousMul \u03b2]\n    (l : Filter \u03b1) : Submodule \u03b2 (\u03b1 \u2192 \u03b2)\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 : \u03b1 \u2192 \u03b2`\nwhich tend to zero along `l`. -/\ndef zeroAtFilterAddSubmonoid [TopologicalSpace \u03b2] [AddZeroClass \u03b2] [ContinuousAdd \u03b2]\n    (l : Filter \u03b1) : AddSubmonoid (\u03b1 \u2192 \u03b2)\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 `\u03b1`, then a function `f: \u03b1 \u2192 \u03b2` is `bounded_at_filter l`\nif `f =O[l] 1`. -/\ndef BoundedAtFilter [Norm \u03b2] (l : Filter \u03b1) (f : \u03b1 \u2192 \u03b2) : Prop :=\n  Asymptotics.IsO l f (1 : \u03b1 \u2192 \u211d)\n#align filter.bounded_at_filter Filter.BoundedAtFilter\n\ntheorem ZeroAtFilter.boundedAtFilter [NormedAddCommGroup \u03b2] {l : Filter \u03b1} {f : \u03b1 \u2192 \u03b2}\n    (hf : ZeroAtFilter l f) : BoundedAtFilter l f :=\n  by\n  rw [zero_at_filter, \u2190 Asymptotics.isOCat_const_iff (one_ne_zero' \u211d)] at hf\n  exact hf.is_O\n#align filter.zero_at_filter.bounded_at_filter Filter.ZeroAtFilter.boundedAtFilter\n\ntheorem const_boundedAtFilter [NormedField \u03b2] (l : Filter \u03b1) (c : \u03b2) :\n    BoundedAtFilter l (Function.const \u03b1 c : \u03b1 \u2192 \u03b2) :=\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 \u03b2] {l : Filter \u03b1} {f g : \u03b1 \u2192 \u03b2}\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 \u03b2] {l : Filter \u03b1} {f : \u03b1 \u2192 \u03b2}\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 {\ud835\udd5c : Type _} [NormedField \ud835\udd5c] [NormedAddCommGroup \u03b2] [NormedSpace \ud835\udd5c \u03b2]\n    {l : Filter \u03b1} {f : \u03b1 \u2192 \u03b2} (c : \ud835\udd5c) (hf : BoundedAtFilter l f) : BoundedAtFilter l (c \u2022 f) :=\n  hf.const_smul_left c\n#align filter.bounded_at_filter.smul Filter.BoundedAtFilter.smul\n\ntheorem BoundedAtFilter.mul [NormedField \u03b2] {l : Filter \u03b1} {f g : \u03b1 \u2192 \u03b2} (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 \u03b2] (l : Filter \u03b1) : Submodule \u03b2 (\u03b1 \u2192 \u03b2)\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 \u03b2] (l : Filter \u03b1) : Subalgebra \u03b2 (\u03b1 \u2192 \u03b2) :=\n  by\n  refine' Submodule.toSubalgebra (bounded_filter_submodule l) _ fun f g hf hg => _\n  \u00b7 exact const_bounded_at_filter l (1 : \u03b2)\n  \u00b7 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 \u2192+ B) :=\n{ smul := \u03bb r f,\n  { to_fun := r \u2022 f,\n    map_zero' := by simp,\n    map_add' := \u03bb x y, by simp [smul_add] },\n  one_smul := \u03bb f, by simp,\n  mul_smul := \u03bb r s f, by simp [mul_smul],\n  smul_add := \u03bb r f g, ext $ \u03bb x, by simp [smul_add],\n  smul_zero := \u03bb r, ext $ \u03bb x, by simp [smul_zero] }\n\n@[simp] lemma coe_smul (r : R) (f : A \u2192+ B) : \u21d1(r \u2022 f) = r \u2022 f := rfl\nlemma smul_apply (r : R) (f : A \u2192+ B) (x : A) : (r \u2022 f) x = r \u2022 f x := rfl\n\ninstance [smul_comm_class R S B] : smul_comm_class R S (A \u2192+ B) :=\n\u27e8\u03bb a b f, ext $ \u03bb x, smul_comm _ _ _\u27e9\n\ninstance [has_smul R S] [is_scalar_tower R S B] : is_scalar_tower R S (A \u2192+ B) :=\n\u27e8\u03bb a b f, ext $ \u03bb x, smul_assoc _ _ _\u27e9\n\ninstance [distrib_mul_action R\u1d50\u1d52\u1d56 B] [is_central_scalar R B] : is_central_scalar R (A \u2192+ B) :=\n\u27e8\u03bb a b, ext $ \u03bb x, op_smul_eq_smul _ _\u27e9\n\nend\n\ninstance [semiring R] [add_monoid A] [add_comm_monoid B] [module R B] :\n  module R (A \u2192+ B) :=\n{ add_smul := \u03bb r s x, ext $ \u03bb y, by simp [add_smul],\n  zero_smul := \u03bb x, ext $ \u03bb 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 \u2192 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)\u207b\u00b9 \u2022 (f b -\u1d65 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 \u2192 PE) (a : k) (b : k) : E :=\n  b - a\u207b\u00b9 \u2022 (f b -\u1d65 f a)\n\ntheorem slope_def_field {k : Type u_1} [field k] (f : k \u2192 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 \u2192 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 \u2192 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 \u2192 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 \u2260 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 \u2192 PE)\n    (a : k) (b : k) (c : k) :\n    ((b - a) / (c - a)) \u2022 slope f a b + ((c - b) / (c - a)) \u2022 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 \u2192 PE) (a : k) (b : k) (c : k)\n    (h : a \u2260 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 \u2192 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 \u2264 a')\n    (hr : r \u2264 1) : coe_fn (affine_map.line_map a b) r \u2264 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 \u2264 b') (hr : 0 \u2264 r) :\n    coe_fn (affine_map.line_map a b) r \u2264 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 \u2264 a') (hb : b \u2264 b') (h\u2080 : 0 \u2264 r) (h\u2081 : r \u2264 1) :\n    coe_fn (affine_map.line_map a b) r \u2264 coe_fn (affine_map.line_map a' b') r :=\n  has_le.le.trans (line_map_mono_left ha h\u2081) (line_map_mono_right hb h\u2080)\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\u2080 : 0 \u2264 r) (h\u2081 : r \u2264 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' \u2194 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 \u2194 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 \u2194 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 \u2194 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 \u2194 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 \u2264 coe_fn (affine_map.line_map a b) r' \u2194 a \u2264 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 \u2264 coe_fn (affine_map.line_map a b) r \u2194 a \u2264 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 \u2264 midpoint k a b \u2194 a \u2264 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 \u2264 a \u2194 b \u2264 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 \u2264 a \u2194 b \u2264 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 \u2264 b \u2194 a \u2264 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 \u2264 b \u2194 a \u2264 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 \u2264 coe_fn (affine_map.line_map a b) r \u2194 b \u2264 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 \u2264 midpoint k a b \u2194 b \u2264 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 \u2208 (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 \u2264 line_map (f a) (f b) r \u2194 slope f a c \u2264 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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) :\n    f (coe_fn (affine_map.line_map a b) r) \u2264 coe_fn (affine_map.line_map (f a) (f b)) r \u2194\n        slope f a (coe_fn (affine_map.line_map a b) r) \u2264 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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) :\n    coe_fn (affine_map.line_map (f a) (f b)) r \u2264 f (coe_fn (affine_map.line_map a b) r) \u2194\n        slope f a b \u2264 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 \u2192 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 \u2194\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 \u2192 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) \u2194\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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) :\n    f (coe_fn (affine_map.line_map a b) r) \u2264 coe_fn (affine_map.line_map (f a) (f b)) r \u2194\n        slope f a b \u2264 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 \u2264 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 \u2192 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 \u2264 f (coe_fn (affine_map.line_map a b) r) \u2194\n        slope f (coe_fn (affine_map.line_map a b) r) b \u2264 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 \u2192 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 \u2194\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 \u2192 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) \u2194\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 \u2264 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 \u2192 E} {a : k} {b : k}\n    {r : k} (hab : a < b) (h\u2080 : 0 < r) (h\u2081 : r < 1) :\n    f (coe_fn (affine_map.line_map a b) r) \u2264 coe_fn (affine_map.line_map (f a) (f b)) r \u2194\n        slope f a (coe_fn (affine_map.line_map a b) r) \u2264\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 \u2264 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 \u2192 E} {a : k} {b : k}\n    {r : k} (hab : a < b) (h\u2080 : 0 < r) (h\u2081 : r < 1) :\n    coe_fn (affine_map.line_map (f a) (f b)) r \u2264 f (coe_fn (affine_map.line_map a b) r) \u2194\n        slope f (coe_fn (affine_map.line_map a b) r) b \u2264\n          slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_le_line_map_iff_slope_le_slope hab h\u2080 h\u2081\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 \u2192 E} {a : k} {b : k}\n    {r : k} (hab : a < b) (h\u2080 : 0 < r) (h\u2081 : r < 1) :\n    f (coe_fn (affine_map.line_map a b) r) < coe_fn (affine_map.line_map (f a) (f b)) r \u2194\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\u2080 h\u2081)\n    (map_le_line_map_iff_slope_le_slope hab h\u2080 h\u2081)\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 \u2192 E} {a : k} {b : k}\n    {r : k} (hab : a < b) (h\u2080 : 0 < r) (h\u2081 : r < 1) :\n    coe_fn (affine_map.line_map (f a) (f b)) r < f (coe_fn (affine_map.line_map a b) r) \u2194\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\u2080 h\u2081\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 \u2964 Top` and\n`map (f : X \u27f6 Y) : opens Y \u2964 opens X`, given by taking preimages of open sets.\n\nUnfortunately `opens` isn't (usefully) a functor `Top \u2964 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 (\ud835\udfd9 X) \u2245 \ud835\udfed (opens X)` and\n`map_comp : map (f \u226b g) \u2245 map g \u22d9 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 \u27f6 V` are not just proofs `U \u2264 V`, but rather\n`ulift (plift (U \u2264 V))`.\n-/\n\ninstance opens_hom_has_coe_to_fun {U V : opens X} : has_coe_to_fun (U \u27f6 V) (\u03bb f, U \u2192 V) :=\n\u27e8\u03bb f x, \u27e8x, f.le x.2\u27e9\u27e9\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 \u2293 V \u27f6 U` as a morphism in the category of open sets.\n-/\ndef inf_le_left (U V : opens X) : U \u2293 V \u27f6 U := inf_le_left.hom\n\n/--\nThe inclusion `U \u2293 V \u27f6 V` as a morphism in the category of open sets.\n-/\ndef inf_le_right (U V : opens X) : U \u2293 V \u27f6 V := inf_le_right.hom\n\n/--\nThe inclusion `U i \u27f6 supr U` as a morphism in the category of open sets.\n-/\ndef le_supr {\u03b9 : Type*} (U : \u03b9 \u2192 opens X) (i : \u03b9) : U i \u27f6 supr U := (le_supr U i).hom\n\n/--\nThe inclusion `\u22a5 \u27f6 U` as a morphism in the category of open sets.\n-/\ndef bot_le (U : opens X) : \u22a5 \u27f6 U := bot_le.hom\n\n/--\nThe inclusion `U \u27f6 \u22a4` as a morphism in the category of open sets.\n-/\ndef le_top (U : opens X) : U \u27f6 \u22a4 := 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 = \u27e8x.1, (@_root_.inf_le_left _ _ U V : _ \u2264 _) x.2\u27e9 :=\nrfl\n\n@[simp]\nlemma inf_le_left_apply_mk (U V : opens X) (x) (m) :\n  (inf_le_left U V) \u27e8x, m\u27e9 = \u27e8x, (@_root_.inf_le_left _ _ U V : _ \u2264 _) m\u27e9 :=\nrfl\n\n@[simp]\nlemma le_supr_apply_mk {\u03b9 : Type*} (U : \u03b9 \u2192 opens X) (i : \u03b9) (x) (m) :\n  (le_supr U i) \u27e8x, m\u27e9 = \u27e8x, (_root_.le_supr U i : _) m\u27e9 :=\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 \u2964 Top :=\n{ obj := \u03bb U, \u27e8U, infer_instance\u27e9,\n  map := \u03bb U V i, \u27e8\u03bb x, \u27e8x.1, i.le x.2\u27e9,\n    (embedding.continuous_iff embedding_subtype_coe).2 continuous_induced_dom\u27e9 }\n\n@[simp]\nlemma to_Top_map (X : Top.{u}) {U V : opens X} {f : U \u27f6 V} {x} {h} :\n  ((to_Top X).map f) \u27e8x, h\u27e9 = \u27e8x, f.le h\u27e9 :=\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 \u27f6 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 \u22a4 \u2245 X :=\n{ hom := inclusion \u22a4,\n  inv := \u27e8\u03bb x, \u27e8x, trivial\u27e9, continuous_def.2 $ \u03bb U \u27e8S, hS, hSU\u27e9, hSU \u25b8 hS\u27e9 }\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 \u27f6 Y) : opens Y \u2964 opens X :=\n{ obj := \u03bb U, \u27e8 f \u207b\u00b9' U, U.is_open.preimage f.continuous \u27e9,\n  map := \u03bb U V i, \u27e8 \u27e8 \u03bb x h, i.le h \u27e9 \u27e9 }.\n\nlemma map_coe (f : X \u27f6 Y) (U : opens Y) :\n  \u2191((map f).obj U) = f \u207b\u00b9' U :=\nrfl\n\n@[simp] lemma map_obj (f : X \u27f6 Y) (U) (p) :\n  (map f).obj \u27e8U, p\u27e9 = \u27e8f \u207b\u00b9' U, p.preimage f.continuous\u27e9 := rfl\n\n@[simp] lemma map_id_obj (U : opens X) : (map (\ud835\udfd9 X)).obj U = U :=\nlet \u27e8_,_\u27e9 := U in rfl\n\n@[simp] lemma map_id_obj' (U) (p) : (map (\ud835\udfd9 X)).obj \u27e8U, p\u27e9 = \u27e8U, p\u27e9 :=\nrfl\n\n@[simp] lemma map_id_obj_unop (U : (opens X)\u1d52\u1d56) : (map (\ud835\udfd9 X)).obj (unop U) = unop U :=\nlet \u27e8_,_\u27e9 := U.unop in rfl\n@[simp] \n\n/--\nThe inclusion `U \u27f6 (map f).obj \u22a4` as a morphism in the category of open sets.\n-/\ndef le_map_top (f : X \u27f6 Y) (U : opens X) : U \u27f6 (map f).obj \u22a4 :=\nle_top U\n\n@[simp] lemma map_comp_obj (f : X \u27f6 Y) (g : Y \u27f6 Z) (U) :\n  (map (f \u226b g)).obj U = (map f).obj ((map g).obj U) :=\nrfl\n\n@[simp] lemma map_comp_obj' (f : X \u27f6 Y) (g : Y \u27f6 Z) (U) (p) :\n  (map (f \u226b g)).obj \u27e8U, p\u27e9 = (map f).obj ((map g).obj \u27e8U, p\u27e9) :=\nrfl\n\n@[simp] lemma map_comp_map (f : X \u27f6 Y) (g : Y \u27f6 Z) {U V} (i : U \u27f6 V) :\n  (map (f \u226b g)).map i = (map f).map ((map g).map i) :=\nrfl\n\n@[simp] lemma map_comp_obj_unop (f : X \u27f6 Y) (g : Y \u27f6 Z) (U) :\n  (map (f \u226b g)).obj (unop U) = (map f).obj ((map g).obj (unop U)) :=\nrfl\n\n@[simp] lemma op_map_comp_obj (f : X \u27f6 Y) (g : Y \u27f6 Z) (U) :\n  (map (f \u226b g)).op.obj U = (map f).op.obj ((map g).op.obj U) :=\nrfl\n\nlemma map_supr (f : X \u27f6 Y) {\u03b9 : Type*} (U : \u03b9 \u2192 opens Y) :\n  (map f).obj (supr U) = supr ((map f).obj \u2218 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 \u2964 opens X` given by taking preimages under the identity function\nis naturally isomorphic to the identity functor.\n-/\n@[simps]\ndef map_id : map (\ud835\udfd9 X) \u2245 \ud835\udfed (opens X) :=\n{ hom := { app := \u03bb U, eq_to_hom (map_id_obj U) },\n  inv := { app := \u03bb U, eq_to_hom (map_id_obj U).symm } }\n\nlemma map_id_eq : map (\ud835\udfd9 X) = \ud835\udfed (opens X) :=\nby { unfold map, congr, ext, refl, ext }\n\nend\n\n/--\nThe natural isomorphism between taking preimages under `f \u226b g`, and the composite\nof taking preimages under `g`, then preimages under `f`.\n-/\n@[simps]\ndef map_comp (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map g \u22d9 map f :=\n{ hom := { app := \u03bb U, eq_to_hom (map_comp_obj f g U) },\n  inv := { app := \u03bb U, eq_to_hom (map_comp_obj f g U).symm } }\n\nlemma map_comp_eq (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) = map g \u22d9 map f :=\nrfl\n\n/--\nIf two continuous maps `f g : X \u27f6 Y` are equal,\nthen the functors `opens Y \u2964 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 \u27f6 Y) (h : f = g) : map f \u2245 map g :=\nnat_iso.of_components (\u03bb 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 \u27f6 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 \u27f6 Y) (h) : map_iso f f h = iso.refl (map _) := rfl\n\n@[simp] lemma map_iso_hom_app (f g : X \u27f6 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 \u27f6 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 \u2245 Y) : opens Y \u224c opens X :=\n{ functor := map H.hom,\n  inverse := map H.inv,\n  unit_iso := nat_iso.of_components (\u03bb U, eq_to_iso (by simp [map, set.preimage_preimage]))\n    (by { intros _ _ _, simp }),\n  counit_iso := nat_iso.of_components (\u03bb 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 \u27f6 Y` induces a functor `opens X \u2964 opens Y`.\n-/\n@[simps]\ndef is_open_map.functor {X Y : Top} {f : X \u27f6 Y} (hf : is_open_map f) :\n  opens X \u2964 opens Y :=\n{ obj := \u03bb U, \u27e8f '' U, hf U U.2\u27e9,\n  map := \u03bb U V h, \u27e8\u27e8set.image_subset _ h.down.down\u27e9\u27e9 }\n\n/--\nAn open map `f : X \u27f6 Y` induces an adjunction between `opens X` and `opens Y`.\n-/\ndef is_open_map.adjunction {X Y : Top} {f : X \u27f6 Y} (hf : is_open_map f) :\n  adjunction hf.functor (topological_space.opens.map f) :=\nadjunction.mk_of_unit_counit\n{ unit := { app := \u03bb U, hom_of_le $ \u03bb x hxU, \u27e8x, hxU, rfl\u27e9 },\n  counit := { app := \u03bb V, hom_of_le $ \u03bb y \u27e8x, hfxV, hxy\u27e9, hxy \u25b8 hfxV } }\n\ninstance is_open_map.functor_full_of_mono {X Y : Top} {f : X \u27f6 Y} (hf : is_open_map f)\n  [H : mono f] : full hf.functor :=\n{ preimage := \u03bb U V i, hom_of_le (\u03bb x hx, by\n  { obtain \u27e8y, hy, eq\u27e9 := i.le \u27e8x, hx, rfl\u27e9, exact (Top.mono_iff_injective f).mp H eq \u25b8 hy }) }\n\ninstance is_open_map.functor_faithful {X Y : Top} {f : X \u27f6 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 \u22a4 = 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 = \u22a4 :=\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 \u22a4).is_open_map.functor =\n  map (inclusion_top_iso X).inv :=\nbegin\n  apply functor.hext, intro, abstract obj_eq { ext,\n  exact \u27e8 \u03bb \u27e8\u27e8_,_\u27e9,h,rfl\u27e9, h, \u03bb h, \u27e8\u27e8x,trivial\u27e9,h,rfl\u27e9 \u27e9 },\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 \u27f6 Y} (hf : is_open_map f) (U : opens Y) :\n  hf.functor.obj ((opens.map f).obj U) = hf.functor.obj \u22a4 \u2293 U :=\nbegin\n  ext, split,\n  { rintros \u27e8x, hx, rfl\u27e9, exact \u27e8\u27e8x, trivial, rfl\u27e9, hx\u27e9 },\n  { rintros \u27e8\u27e8x, -, rfl\u27e9, hx\u27e9, exact \u27e8x, hx, rfl\u27e9 }\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 \u2293 U :=\nby { ext1, refine set.image_preimage_eq_inter_range.trans _, simpa }\n\nlemma map_functor_eq' {X U : Top} (f : U \u27f6 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 \u2190 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 \u2964 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\u2081 v\u2082 u\u2081 u\u2082\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\u2081) : Type u\u2081 := V\n\ninstance (V : Type u\u2081) [inhabited V] : inhabited (paths V) := \u27e8(default : V)\u27e9\n\nvariables (V : Type u\u2081) [quiver.{v\u2081+1} V]\n\nnamespace paths\n\ninstance category_paths : category.{max u\u2081 v\u2081} (paths V) :=\n{ hom := \u03bb (X Y : V), quiver.path X Y,\n  id := \u03bb X, quiver.path.nil,\n  comp := \u03bb 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 := \u03bb X, X,\n  map := \u03bb 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 \u2964 C}\n  (h_obj : F.obj = G.obj)\n  (h : \u2200 (a b : V) (e : a \u27f6 b), F.map e.to_path =\n  eq_to_hom (congr_fun h_obj a) \u226b G.map e.to_path \u226b 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\u2082) [quiver.{v\u2082+1} W]\n\n-- A restatement of `prefunctor.map_path_comp` using `f \u226b 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 \u27f6 Y) (g : Y \u27f6 Z) :\n  F.map_path (f \u226b g) = (F.map_path f).comp (F.map_path g) :=\nprefunctor.map_path_comp _ _ _\n\nend\n\nsection\n\nvariables {C : Type u\u2081} [category.{v\u2081} 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} : \u03a0 {Y : C} (p : path X Y), X \u27f6 Y\n| _ path.nil := \ud835\udfd9 X\n| _ (path.cons p e) := compose_path p \u226b e\n\n@[simp]\nlemma compose_path_to_path {X Y : C} (f : X \u27f6 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 \u226b 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 \u27f6 Y) (g : Y \u27f6 Z) :\n  compose_path (f \u226b g) = compose_path f \u226b 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 \u2964 C :=\n{ obj := \u03bb X, X,\n  map := \u03bb 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\u03bb 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 \u2964 quotient (paths_hom_rel C) :=\n{ obj := \u03bb X, quotient.mk X,\n  map := \u03bb X Y f, quot.mk _ f.to_path,\n  map_id' := \u03bb X, quot.sound (quotient.comp_closure.of _ _ _ (by simp)),\n  map_comp' := \u03bb 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) \u2964 C :=\nquotient.lift _ (path_composition C) (\u03bb 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) \u224c C :=\n{ functor := quotient_paths_to C,\n  inverse := to_quotient_paths C,\n  unit_iso := nat_iso.of_components (\u03bb 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 (\u03bb 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 = [] \u2194 xs = [] \u2227 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 \u2192 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 \u2192 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} {\u03b1 : Type u} {\u03b2 : Type v} [SizeOf \u03b1] [SizeOf \u03b2] : PSum \u03b1 \u03b2 \u2192 \u2115\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} (\u03b1 : Type u) (\u03b2 : Type v) [SizeOf \u03b1] [SizeOf \u03b2] :\n    SizeOf (PSum \u03b1 \u03b2) :=\n  \u27e8PSum.Alt.sizeof\u27e9\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 \u2192 expr\n  | expr.app (expr.app (expr.app (expr.app (expr.const `` PSum.hasSizeof l) \u03b1) \u03b2) i\u03b1) i\u03b2 =>\n    (expr.const `` PSum.hasSizeofAlt l : expr) \u03b1 \u03b2 i\u03b1 (mk_alt_sizeof i\u03b2)\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 \u2190 target\n  let rel \u2190 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 \u2192 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 \u2192 tactic (expr \u00d7 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 \u2192 tactic Unit\n  | tac => do\n    let t \u2190 target >>= whnf\n    if t `psigma.lex 6 then\n        let a := t\n        let b := t\n        do\n        let (a\u2081, a\u2082) \u2190 is_psigma_mk a\n        let (b\u2081, b\u2082) \u2190 is_psigma_mk b\n        (is_def_eq a\u2081 b\u2081 >> 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 \u2192 List Name \u2192 tactic simp_lemmas\n  | s, [] => return s\n  | s, n :: ns => do\n    let s' \u2190 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 \u2190 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 \u2190 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 \u2192 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 \u2192 tactic expr\n    | [ ] => to_expr ` `( 0 )\n      | [ a ] => return a\n      | a :: as => do let rs \u2190 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 \u2192 List expr \u2192 tactic expr\n    | [ ] , b => mk_nat_add b\n      | a , [ ] => mk_nat_add a\n      | a , b => do let t \u2190 mk_nat_add a let s \u2190 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 ) ) \u2190 target\n          let ty \u2190 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\u2093 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 \u2190 mk_nat_add_add common ( sort_args lhs_rest )\n                let new_rhs \u2190 mk_nat_add_add common ( sort_args rhs_rest )\n                let lhs_pr \u2190 prove_eq_by_perm lhs new_lhs\n                let rhs_pr \u2190 prove_eq_by_perm rhs new_rhs\n                let\n                  target_pr \u2190 to_expr ` `( congr ( congr_arg ( \u00b7 < \u00b7 ) $ ( lhs_pr ) ) $ ( rhs_pr ) )\n                let new_target \u2190 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 ) ) \u2190 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 \u2192 List expr \u2192 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 {\u03b1 \u03b2 \u03b3 \u03b4 : 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 \u03b1) \u2192 multiset \u03b1 := sum\n\nlemma coe_join : \u2200 L : list (list \u03b1),\n  join (L.map (@coe _ (multiset \u03b1) _) : multiset (multiset \u03b1)) = L.join\n| []       := rfl\n| (l :: L) := congr_arg (\u03bb s : multiset \u03b1, \u2191l + s) (coe_join L)\n\n@[simp] \n\n@[simp] lemma mem_join {a S} : a \u2208 @join \u03b1 S \u2194 \u2203 s \u2208 S, a \u2208 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 \u03b1 S) = sum (map card S) :=\nmultiset.induction_on S (by simp) (by simp)\n\nlemma rel_join {r : \u03b1 \u2192 \u03b2 \u2192 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 : \u03b1) (s t : multiset \u03b1) (f g : \u03b1 \u2192 multiset \u03b2)\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 \u03b1) (f : \u03b1 \u2192 multiset \u03b2) : multiset \u03b2 := (s.map f).join\n\n@[simp] lemma coe_bind (l : list \u03b1) (f : \u03b1 \u2192 list \u03b2) : @bind \u03b1 \u03b2 l (\u03bb a, f a) = l.bind f :=\nby rw [list.bind, \u2190coe_join, list.map_map]; refl\n\n@[simp] lemma zero_bind : bind 0 f = 0 := rfl\n@[simp] lemma cons_bind : (a ::\u2098 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 (\u03bb a, 0 : \u03b1 \u2192 multiset \u03b2) = 0 := by simp [bind, join, nsmul_zero]\n@[simp] lemma bind_add : s.bind (\u03bb a, f a + g a) = s.bind f + s.bind g := by simp [bind, join]\n\n@[simp] lemma bind_cons (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 multiset \u03b2) :\n  s.bind (\u03bb a, f a ::\u2098 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 : \u03b1 \u2192 \u03b2) : s.bind (\u03bb x, ({f x} : multiset \u03b2)) = 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 : \u03b1 \u2192 multiset \u03b2} : b \u2208 bind s f \u2194 \u2203 a \u2208 s, b \u2208 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 \u2218 f)).sum := by simp [bind]\n\nlemma bind_congr {f g : \u03b1 \u2192 multiset \u03b2} {m : multiset \u03b1} :\n  (\u2200 a \u2208 m, f a = g a) \u2192 bind m f = bind m g :=\nby simp [bind] {contextual := tt}\n\nlemma bind_hcongr {\u03b2' : Type*} {m : multiset \u03b1} {f : \u03b1 \u2192 multiset \u03b2} {f' : \u03b1 \u2192 multiset \u03b2'}\n  (h : \u03b2 = \u03b2') (hf : \u2200a \u2208 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 \u03b1) (n : \u03b1 \u2192 multiset \u03b2) (f : \u03b2 \u2192 \u03b3) :\n  map f (bind m n) = bind m (\u03bb a, map f (n a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map (m : multiset \u03b1) (n : \u03b2 \u2192 multiset \u03b3) (f : \u03b1 \u2192 \u03b2) :\n  bind (map f m) n = bind m (\u03bb a, n (f a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_assoc {s : multiset \u03b1} {f : \u03b1 \u2192 multiset \u03b2} {g : \u03b2 \u2192 multiset \u03b3} :\n  (s.bind f).bind g = s.bind (\u03bb a, (f a).bind g) :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma bind_bind (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 multiset \u03b3} :\n  (bind m $ \u03bb a, bind n $ \u03bb b, f a b) = (bind n $ \u03bb b, bind m $ \u03bb a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map_comm (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  (bind m $ \u03bb a, n.map $ \u03bb b, f a b) = (bind n $ \u03bb b, m.map $ \u03bb a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\n@[simp, to_additive]\nlemma prod_bind [comm_monoid \u03b2] (s : multiset \u03b1) (t : \u03b1 \u2192 multiset \u03b2) :\n  (s.bind t).prod = (s.map $ \u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop} {s t} {f : \u03b1 \u2192 multiset \u03b3} {g : \u03b2 \u2192 multiset \u03b4}\n  (h : (r \u21d2 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 (\u03bb a ha b hb hr, h hr) }\n\nlemma count_sum [decidable_eq \u03b1] {m : multiset \u03b2} {f : \u03b2 \u2192 multiset \u03b1} {a : \u03b1} :\n  count a (map f m).sum = sum (m.map $ \u03bb b, count a $ f b) :=\nmultiset.induction_on m (by simp) ( by simp)\n\nlemma count_bind [decidable_eq \u03b1] {m : multiset \u03b2} {f : \u03b2 \u2192 multiset \u03b1} {a : \u03b1} :\n  count a (bind m f) = sum (m.map $ \u03bb b, count a $ f b) := count_sum\n\nlemma le_bind {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192 multiset \u03b2} (S : multiset \u03b1) {x : \u03b1} (hx : x \u2208 S) :\n  f x \u2264 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 \u27e8x, hx, rfl\u27e9\nend\n\n@[simp] theorem attach_bind_coe (s : multiset \u03b1) (f : \u03b1 \u2192 multiset \u03b2) :\n  s.attach.bind (\u03bb 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 : \u03b1) (b : \u03b2) (s : multiset \u03b1) (t : multiset \u03b2)\n\n/-- The multiplicity of `(a, b)` in `s \u00d7\u02e2 t` is\n  the product of the multiplicity of `a` in `s` and `b` in `t`. -/\ndef product (s : multiset \u03b1) (t : multiset \u03b2) : multiset (\u03b1 \u00d7 \u03b2) := s.bind $ \u03bb a, t.map $ prod.mk a\n\n/- This notation binds more strongly than (pre)images, unions and intersections. -/\ninfixr (name := multiset.product) ` \u00d7\u02e2 `:82 := multiset.product\n\n@[simp] lemma coe_product (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) : @product \u03b1 \u03b2 l\u2081 l\u2082 = l\u2081.product l\u2082 :=\nby { rw [product, list.product, \u2190coe_bind], simp }\n\n@[simp] lemma zero_product : @product \u03b1 \u03b2 0 t = 0 := rfl\n@[simp] lemma cons_product : (a ::\u2098 s) \u00d7\u02e2 t = map (prod.mk a) t + s \u00d7\u02e2 t := by simp [product]\n@[simp] lemma product_zero : s \u00d7\u02e2 (0 : multiset \u03b2) = 0 := by simp [product]\n@[simp] lemma product_cons : s \u00d7\u02e2 (b ::\u2098 t) = s.map (\u03bb a, (a, b)) + s \u00d7\u02e2 t := by simp [product]\n\n@[simp] lemma product_singleton : ({a} : multiset \u03b1) \u00d7\u02e2 ({b} : multiset \u03b2) = {(a, b)} :=\nby simp only [product, bind_singleton, map_singleton]\n\n@[simp] lemma add_product (s t : multiset \u03b1) (u : multiset \u03b2) : (s + t) \u00d7\u02e2 u = s \u00d7\u02e2 u + t \u00d7\u02e2 u :=\nby simp [product]\n\n@[simp] lemma product_add (s : multiset \u03b1) : \u2200 t u : multiset \u03b2, s \u00d7\u02e2 (t + u) = s \u00d7\u02e2 t + s \u00d7\u02e2 u :=\nmultiset.induction_on s (\u03bb t u, rfl) $ \u03bb a s IH t u,\n  by rw [cons_product, IH]; simp; cc\n\n@[simp] lemma mem_product {s t} : \u2200 {p : \u03b1 \u00d7 \u03b2}, p \u2208 @product \u03b1 \u03b2 s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t\n| (a, b) := by simp [product, and.left_comm]\n\n@[simp] lemma card_product : (s \u00d7\u02e2 t).card = s.card * t.card := by simp [product]\n\nend product\n\n/-! ### Disjoint sum of multisets -/\n\nsection sigma\nvariables {\u03c3 : \u03b1 \u2192 Type*} (a : \u03b1) (s : multiset \u03b1) (t : \u03a0 a, multiset (\u03c3 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 \u03b1) (t : \u03a0 a, multiset (\u03c3 a)) : multiset (\u03a3 a, \u03c3 a) :=\ns.bind $ \u03bb a, (t a).map $ sigma.mk a\n\n@[simp] lemma coe_sigma (l\u2081 : list \u03b1) (l\u2082 : \u03a0 a, list (\u03c3 a)) :\n  @multiset.sigma \u03b1 \u03c3 l\u2081 (\u03bb a, l\u2082 a) = l\u2081.sigma l\u2082 :=\nby rw [multiset.sigma, list.sigma, \u2190coe_bind]; simp\n\n@[simp] lemma zero_sigma : @multiset.sigma \u03b1 \u03c3 0 t = 0 := rfl\n\n@[simp] lemma cons_sigma : (a ::\u2098 s).sigma t = (t a).map (sigma.mk a) + s.sigma t :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_singleton (b : \u03b1 \u2192 \u03b2) :\n  ({a} : multiset \u03b1).sigma (\u03bb a, ({b a} : multiset \u03b2)) = {\u27e8a, b a\u27e9} := rfl\n\n@[simp] lemma add_sigma (s t : multiset \u03b1) (u : \u03a0 a, multiset (\u03c3 a)) :\n  (s + t).sigma u = s.sigma u + t.sigma u :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_add : \u2200 t u : \u03a0 a, multiset (\u03c3 a),\n  s.sigma (\u03bb a, t a + u a) = s.sigma t + s.sigma u :=\nmultiset.induction_on s (\u03bb t u, rfl) $ \u03bb a s IH t u,\n  by rw [cons_sigma, IH]; simp; cc\n\n@[simp] lemma mem_sigma {s t} : \u2200 {p : \u03a3 a, \u03c3 a},\n  p \u2208 @multiset.sigma \u03b1 \u03c3 s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t p.1\n| \u27e8a, b\u27e9 := by simp [multiset.sigma, and_assoc, and.left_comm]\n\n@[simp] lemma card_sigma :\n  card (s.sigma t) = sum (map (\u03bb a, card (t a)) s) :=\nby simp [multiset.sigma, (\u2218)]\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) (\u03b1 : Type v) [field F] [add_comm_group \u03b1] [vec_space F \u03b1] extends add_subgroup \u03b1 :=\n(smul_mem : \u2200 (a : F) {x}, x \u2208 carrier \u2192 a \u2022 x \u2208 carrier)\n\nnamespace subspace\n\nvariables (F : Type u) (\u03b1 : Type v) [field F] [add_comm_group \u03b1] [vec_space F \u03b1] (\u03b2 : subspace F \u03b1)\n\n--instance : has_coe_t (subspace F \u03b2) (set \u03b2) := \u27e8\u03bb s, s.carrier\u27e9\ninstance : has_coe (subspace F \u03b1) (add_subgroup \u03b1) := { coe := subspace.to_add_subgroup }\n\n\n/-instance : has_coe_t (subspace F \u03b2) (set \u03b2) := \u27e8\u03bb s, s.carrier\u27e9\ninstance : has_mem M (submodule R M) := \u27e8\u03bb x p, x \u2208 (p : set M)\u27e9\ninstance : has_coe_to_sort (submodule R M) := \u27e8_, \u03bb p, {x : M // x \u2208 p}\u27e9\n\n\ninstance : has_add \u03b2 := \u27e8\u03bbx y, \u27e8x.1 + y.1, add_mem _ x.2 y.2\u27e9\u27e9\ninstance : has_zero p := \u27e8\u27e80, zero_mem _\u27e9\u27e9\ninstance : inhabited p := \u27e80\u27e9\ninstance : has_scalar R p := \u27e8\u03bb c x, \u27e8c \u2022 x.1, smul_mem _ c x.2\u27e9\u27e9-/\n\n/-begin\n    intros a b,\n    refine \u27e8a \u2022 b, _\u27e9, \n    exact subspace.smul_mem \u03b2 a b.2, -- b.2 proving that a thing is a subtype\nend,-/\n\ninstance to_vec_space (F : Type u) (\u03b1 : Type v) [field F] [add_comm_group \u03b1] [vec_space F \u03b1](\u03b2 : subspace F \u03b1) : vec_space F \u03b2 :=\n{ smul := \u03bb a b, \u27e8a \u2022 b, \u03b2.smul_mem a b.2\u27e9,\n  smul_add := \u03bb r a b, subtype.eq (vec_space.smul_add r a b),\n  add_smul := \u03bb r s a, subtype.eq (vec_space.add_smul r s a),\n  mul_smul := \u03bb r s a, subtype.eq (vec_space.mul_smul r s a),\n  one_smul := \u03bb a, subtype.eq (vec_space.one_smul a) }\n\nlemma sum_mem_sum (S : finset (subspace F \u03b1)) (f : subspace F \u03b1 \u2192 \u03b1)\n  (hf : \u2200 x \u2208 S, f x \u2208 x.carrier) : \n  (\u2211 x in S, f x) \u2208 (\u2211 x in S, x : set \u03b1) :=\nbegin\n    -- \u2200 U\u1d62 \u2208 {U\u2081, ..., U_m}, f(x) \u2208 U\u1d62\n    -- u\u2081 + ... + u_m \u2208 U\u2081 + ... + 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 \u03b2 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 \u03b1)) (u : \u03b1)\n  (hu : u \u2208 (\u2211 x in S, x : set \u03b1)) : \n  \u2203 (f : subspace F \u03b1 \u2192 \u03b1), (\u2200 x \u2208 S, f x \u2208 x.carrier) \u2227 u = (\u2211 x in S, f x) :=\nbegin -- u \u2208 U\u2081 + ... + U_m then u = \u2211 u\u1d62 for u\u1d62 \u2208 U\u1d62\n-- \u2200 U\u1d62, \u2203 u\u1d62 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 \u03bb 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 \u27e8b, c, hyp3, hyp4, hyp5\u27e9,\n    specialize IH c hyp4,\n    refine \u27e8_, _, _\u27e9,\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 \u2208 s then f x else b,\n    --if x \u2208 s then f x else b, if_pos, if_neg\nend-/\n\n\n/-def subspace_sum (S : finset (subspace F \u03b1)) : subspace F \u03b1 := \n{\n  carrier := \u2211 x in S, x,\n  --{y | \u2203 f : (\u03a0 x : subspace F \u03b1, x \u2208 S \u2192 x), (\u2211 x in S.attach, f x x.2 : \u03b1) = y} , \n  -- {u\u2081 + ... + u_m : u\u2081 \u2208 U\u2081, ..., u_m \u2208 U_m}\n  zero_mem' := \n  begin\n    convert sum_mem_sum F \u03b1 S (\u03bb x, 0) (\u03bb x hyp, add_subgroup.zero_mem x),\n    rw finset.sum_const_zero,\n  end,\n  add_mem' := \u03bb a b hyp hyp2, _,\n  neg_mem' := _,\n  smul_mem := _ }-/\n\n/-def add (s : finset (subspace F \u03b1)) : subspace F \u03b1 :=\n{y | \u2203 (f : \u03a0 (i : (\u2191s : set (subspace F \u03b1))), i), y = \u2211 x in (\u2191s : set (subspace F \u03b1)), 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\u00f6lzl, Patrick Massot, S\u00e9bastien Gou\u00ebzel, 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 `\u2243\u209c`.\n\n# Main definitions\n\n* `homeomorph \u03b1 \u03b2`: The type of homeomorphisms from `\u03b1` to `\u03b2`.\n  This type can be denoted using the following notation: `\u03b1 \u2243\u209c \u03b2`.\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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\n\n/-- Homeomorphism between `\u03b1` and `\u03b2`, also called topological isomorphism -/\n@[nolint has_inhabited_instance] -- not all spaces are homeomorphic to each other\nstructure homeomorph (\u03b1 : Type*) (\u03b2 : Type*) [topological_space \u03b1] [topological_space \u03b2]\n  extends \u03b1 \u2243 \u03b2 :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\ninfix ` \u2243\u209c `:25 := homeomorph\n\nnamespace homeomorph\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4]\n\ninstance : has_coe_to_fun (\u03b1 \u2243\u209c \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := \u27e8\u03bbe, e.to_equiv\u27e9\n\n@[simp] lemma homeomorph_mk_coe (a : equiv \u03b1 \u03b2) (b c) :\n  ((homeomorph.mk a b c) : \u03b1 \u2192 \u03b2) = a :=\nrfl\n\n/-- Inverse of a homeomorphism. -/\nprotected def symm (h : \u03b1 \u2243\u209c \u03b2) : \u03b2 \u2243\u209c \u03b1 :=\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 : \u03b1 \u2243\u209c \u03b2) : \u03b1 \u2192 \u03b2 := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : \u03b1 \u2243\u209c \u03b2) : \u03b2 \u2192 \u03b1 := h.symm\n\ninitialize_simps_projections homeomorph\n  (to_equiv_to_fun \u2192 apply, to_equiv_inv_fun \u2192 symm_apply, -to_equiv)\n\n@[simp] lemma coe_to_equiv (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h.to_equiv = h := rfl\n@[simp] lemma coe_symm_to_equiv (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h.to_equiv.symm = h.symm := rfl\n\nlemma to_equiv_injective : function.injective (to_equiv : \u03b1 \u2243\u209c \u03b2 \u2192 \u03b1 \u2243 \u03b2)\n| \u27e8e, h\u2081, h\u2082\u27e9 \u27e8e', h\u2081', h\u2082'\u27e9 rfl := rfl\n\n@[ext] lemma ext {h h' : \u03b1 \u2243\u209c \u03b2} (H : \u2200 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 (\u03b1 : Type*) [topological_space \u03b1] : \u03b1 \u2243\u209c \u03b1 :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  to_equiv := equiv.refl \u03b1 }\n\n/-- Composition of two homeomorphisms. -/\nprotected def trans (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b2 \u2243\u209c \u03b3) : \u03b1 \u2243\u209c \u03b3 :=\n{ continuous_to_fun  := h\u2082.continuous_to_fun.comp h\u2081.continuous_to_fun,\n  continuous_inv_fun := h\u2081.continuous_inv_fun.comp h\u2082.continuous_inv_fun,\n  to_equiv := equiv.trans h\u2081.to_equiv h\u2082.to_equiv }\n\n@[simp] lemma trans_apply (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b2 \u2243\u209c \u03b3) (a : \u03b1) : h\u2081.trans h\u2082 a = h\u2082 (h\u2081 a) := rfl\n\n@[simp] lemma homeomorph_mk_coe_symm (a : equiv \u03b1 \u03b2) (b c) :\n  ((homeomorph.mk a b c).symm : \u03b2 \u2192 \u03b1) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (homeomorph.refl \u03b1).symm = homeomorph.refl \u03b1 := rfl\n\n@[continuity]\nprotected lemma continuous (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : continuous (h.symm) := h.continuous_inv_fun\n\n@[simp] lemma apply_symm_apply (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b2) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\nprotected lemma bijective (h : \u03b1 \u2243\u209c \u03b2) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : \u03b1 \u2243\u209c \u03b2) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) (g : \u03b2 \u2192 \u03b1) (hg : function.right_inverse g f) : \u03b1 \u2243\u209c \u03b2 :=\nhave g = f.symm, from funext (\u03bb 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 : \u03b1 \u2243\u209c \u03b2) : \u21d1h.symm \u2218 \u21d1h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h \u2218 \u21d1h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : \u03b1 \u2243\u209c \u03b2) : range h = univ :=\nh.surjective.range_eq\n\nlemma image_symm (h : \u03b1 \u2243\u209c \u03b2) : image h.symm = preimage h :=\nfunext h.symm.to_equiv.image_eq_preimage\n\nlemma preimage_symm (h : \u03b1 \u2243\u209c \u03b2) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h '' (h \u207b\u00b9' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h \u207b\u00b9' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma inducing (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : topological_space.induced h \u2039_\u203a = \u2039_\u203a := h.inducing.1.symm\n\nprotected lemma quotient_map (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : topological_space.coinduced h \u2039_\u203a = \u2039_\u203a :=\nh.quotient_map.2.symm\n\nprotected lemma embedding (h : \u03b1 \u2243\u209c \u03b2) : embedding h :=\n\u27e8h.inducing, h.injective\u27e9\n\n/-- Homeomorphism given an embedding. -/\nnoncomputable def of_embedding (f : \u03b1 \u2192 \u03b2) (hf : embedding f) : \u03b1 \u2243\u209c (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 \u03b2]\n  (h : \u03b1 \u2243\u209c \u03b2) :\n  topological_space.second_countable_topology \u03b1 :=\nh.inducing.second_countable_topology\n\nlemma compact_image {s : set \u03b1} (h : \u03b1 \u2243\u209c \u03b2) : is_compact (h '' s) \u2194 is_compact s :=\nh.embedding.is_compact_iff_is_compact_image.symm\n\nlemma compact_preimage {s : set \u03b2} (h : \u03b1 \u2243\u209c \u03b2) : is_compact (h \u207b\u00b9' s) \u2194 is_compact s :=\nby rw \u2190 image_symm; exact h.symm.compact_image\n\n@[simp] lemma comap_cocompact (h : \u03b1 \u2243\u209c \u03b2) : comap h (cocompact \u03b2) = cocompact \u03b1 :=\n(comap_cocompact_le h.continuous).antisymm $\n  (has_basis_cocompact.le_basis_iff (has_basis_cocompact.comap h)).2 $ \u03bb K hK,\n    \u27e8h \u207b\u00b9' K, h.compact_preimage.2 hK, subset.rfl\u27e9\n\n@[simp] lemma map_cocompact (h : \u03b1 \u2243\u209c \u03b2) : map h (cocompact \u03b1) = cocompact \u03b2 :=\nby rw [\u2190 h.comap_cocompact, map_comap_of_surjective h.surjective]\n\nprotected lemma compact_space [compact_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : compact_space \u03b2 :=\n{ compact_univ := by { rw [\u2190 image_univ_of_surjective h.surjective, h.compact_image],\n    apply compact_space.compact_univ } }\n\nprotected lemma t0_space [t0_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : t0_space \u03b2 :=\nh.symm.embedding.t0_space\n\nprotected lemma t1_space [t1_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : t1_space \u03b2 :=\nh.symm.embedding.t1_space\n\nprotected lemma t2_space [t2_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : t2_space \u03b2 :=\nh.symm.embedding.t2_space\n\nprotected lemma regular_space [regular_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : regular_space \u03b2 :=\nh.symm.embedding.regular_space\n\nprotected lemma dense_embedding (h : \u03b1 \u2243\u209c \u03b2) : dense_embedding h :=\n{ dense   := h.surjective.dense_range,\n  .. h.embedding }\n\n@[simp] lemma is_open_preimage (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b2} : is_open (h \u207b\u00b9' s) \u2194 is_open s :=\nh.quotient_map.is_open_preimage\n\n@[simp] lemma is_open_image (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} : is_open (h '' s) \u2194 is_open s :=\nby rw [\u2190 preimage_symm, is_open_preimage]\n\nprotected lemma is_open_map (h : \u03b1 \u2243\u209c \u03b2) : is_open_map h := \u03bb s, h.is_open_image.2\n\n@[simp] lemma is_closed_preimage (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b2} : is_closed (h \u207b\u00b9' s) \u2194 is_closed s :=\nby simp only [\u2190 is_open_compl_iff, \u2190 preimage_compl, is_open_preimage]\n\n@[simp] lemma is_closed_image (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} : is_closed (h '' s) \u2194 is_closed s :=\nby rw [\u2190 preimage_symm, is_closed_preimage]\n\nprotected lemma is_closed_map (h : \u03b1 \u2243\u209c \u03b2) : is_closed_map h := \u03bb s, h.is_closed_image.2\n\nprotected lemma open_embedding (h : \u03b1 \u2243\u209c \u03b2) : open_embedding h :=\nopen_embedding_of_embedding_open h.embedding h.is_open_map\n\nprotected lemma closed_embedding (h : \u03b1 \u2243\u209c \u03b2) : closed_embedding h :=\nclosed_embedding_of_embedding_closed h.embedding h.is_closed_map\n\nprotected lemma normal_space [normal_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : normal_space \u03b2 :=\nh.symm.closed_embedding.normal_space\n\nlemma preimage_closure (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h \u207b\u00b9' (closure s) = closure (h \u207b\u00b9' s) :=\nh.is_open_map.preimage_closure_eq_closure_preimage h.continuous _\n\nlemma image_closure (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h '' (closure s) = closure (h '' s) :=\nby rw [\u2190 preimage_symm, preimage_closure]\n\n\n\nlemma image_interior (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h '' (interior s) = interior (h '' s) :=\nby rw [\u2190 preimage_symm, preimage_interior]\n\nlemma preimage_frontier (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h \u207b\u00b9' (frontier s) = frontier (h \u207b\u00b9' 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 : \u03b2 \u2192 M}\n  (hf : has_compact_mul_support f) (\u03c6 : \u03b1 \u2243\u209c \u03b2) : has_compact_mul_support (f \u2218 \u03c6) :=\nhf.comp_closed_embedding \u03c6.closed_embedding\n\n@[simp] lemma map_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : map h (\ud835\udcdd x) = \ud835\udcdd (h x) :=\nh.embedding.map_nhds_of_mem _ (by simp)\n\nlemma symm_map_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : map h.symm (\ud835\udcdd (h x)) = \ud835\udcdd x :=\nby rw [h.symm.map_nhds_eq, h.symm_apply_apply]\n\nlemma nhds_eq_comap (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : \ud835\udcdd x = comap h (\ud835\udcdd (h x)) :=\nh.embedding.to_inducing.nhds_eq_comap x\n\n@[simp] lemma comap_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (y : \u03b2) : comap h (\ud835\udcdd y) = \ud835\udcdd (h.symm y) :=\nby rw [h.nhds_eq_comap, h.apply_symm_apply]\n\n/-- If an bijective map `e : \u03b1 \u2243 \u03b2` is continuous and open, then it is a homeomorphism. -/\ndef homeomorph_of_continuous_open (e : \u03b1 \u2243 \u03b2) (h\u2081 : continuous e) (h\u2082 : is_open_map e) :\n  \u03b1 \u2243\u209c \u03b2 :=\n{ continuous_to_fun := h\u2081,\n  continuous_inv_fun := begin\n    rw continuous_def,\n    intros s hs,\n    convert \u2190 h\u2082 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 : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (s : set \u03b3) :\n  continuous_on (h \u2218 f) s \u2194 continuous_on f s :=\nh.inducing.continuous_on_iff.symm\n\n@[simp] lemma comp_continuous_iff (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b3 \u2192 \u03b1} :\n  continuous (h \u2218 f) \u2194 continuous f :=\nh.inducing.continuous_iff.symm\n\n@[simp] lemma comp_continuous_iff' (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b2 \u2192 \u03b3} :\n  continuous (f \u2218 h) \u2194 continuous f :=\nh.quotient_map.continuous_iff.symm\n\nlemma comp_continuous_at_iff (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (x : \u03b3) :\n  continuous_at (h \u2218 f) x \u2194 continuous_at f x :=\nh.inducing.continuous_at_iff.symm\n\nlemma comp_continuous_at_iff' (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b2 \u2192 \u03b3) (x : \u03b1) :\n  continuous_at (f \u2218 h) x \u2194 continuous_at f (h x) :=\nh.inducing.continuous_at_iff' (by simp)\n\nlemma comp_continuous_within_at_iff (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (s : set \u03b3) (x : \u03b3) :\n  continuous_within_at f s x \u2194 continuous_within_at (h \u2218 f) s x :=\nh.inducing.continuous_within_at_iff\n\n@[simp] lemma comp_is_open_map_iff (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b3 \u2192 \u03b1} :\n  is_open_map (h \u2218 f) \u2194 is_open_map f :=\nbegin\n  refine \u27e8_, \u03bb hf, h.is_open_map.comp hf\u27e9,\n  intros hf,\n  rw [\u2190 function.comp.left_id f, \u2190 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 : \u03b1 \u2243\u209c \u03b2) {f : \u03b2 \u2192 \u03b3} :\n  is_open_map (f \u2218 h) \u2194 is_open_map f :=\nbegin\n  refine \u27e8_, \u03bb hf, hf.comp h.is_open_map\u27e9,\n  intros hf,\n  rw [\u2190 function.comp.right_id f, \u2190 h.self_comp_symm, \u2190 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 \u03b1} (h : s = t) : s \u2243\u209c 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\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) : \u03b1 \u2295 \u03b3 \u2243\u209c \u03b2 \u2295 \u03b4 :=\n{ continuous_to_fun  :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h\u2081.continuous)\n      (continuous_inr.comp h\u2082.continuous),\n    ext x, cases x; refl,\n  end,\n  continuous_inv_fun :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h\u2081.symm.continuous)\n      (continuous_inr.comp h\u2082.symm.continuous),\n    ext x, cases x; refl\n  end,\n  to_equiv := h\u2081.to_equiv.sum_congr h\u2082.to_equiv }\n\n/-- Product of two homeomorphisms. -/\ndef prod_congr (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) : \u03b1 \u00d7 \u03b3 \u2243\u209c \u03b2 \u00d7 \u03b4 :=\n{ continuous_to_fun  := (h\u2081.continuous.comp continuous_fst).prod_mk\n    (h\u2082.continuous.comp continuous_snd),\n  continuous_inv_fun := (h\u2081.symm.continuous.comp continuous_fst).prod_mk\n    (h\u2082.symm.continuous.comp continuous_snd),\n  to_equiv := h\u2081.to_equiv.prod_congr h\u2082.to_equiv }\n\n@[simp] lemma prod_congr_symm (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) :\n  (h\u2081.prod_congr h\u2082).symm = h\u2081.symm.prod_congr h\u2082.symm := rfl\n\n@[simp] lemma coe_prod_congr (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) :\n  \u21d1(h\u2081.prod_congr h\u2082) = prod.map h\u2081 h\u2082 := rfl\n\nsection\nvariables (\u03b1 \u03b2 \u03b3)\n\n/-- `\u03b1 \u00d7 \u03b2` is homeomorphic to `\u03b2 \u00d7 \u03b1`. -/\ndef prod_comm : \u03b1 \u00d7 \u03b2 \u2243\u209c \u03b2 \u00d7 \u03b1 :=\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 \u03b1 \u03b2 }\n\n@[simp] lemma prod_comm_symm : (prod_comm \u03b1 \u03b2).symm = prod_comm \u03b2 \u03b1 := rfl\n@[simp] lemma coe_prod_comm : \u21d1(prod_comm \u03b1 \u03b2) = prod.swap := rfl\n\n/-- `(\u03b1 \u00d7 \u03b2) \u00d7 \u03b3` is homeomorphic to `\u03b1 \u00d7 (\u03b2 \u00d7 \u03b3)`. -/\ndef prod_assoc : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243\u209c \u03b1 \u00d7 (\u03b2 \u00d7 \u03b3) :=\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 \u03b1 \u03b2 \u03b3 }\n\n/-- `\u03b1 \u00d7 {*}` is homeomorphic to `\u03b1`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : \u03b1 \u00d7 punit \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.prod_punit \u03b1,\n  continuous_to_fun := continuous_fst,\n  continuous_inv_fun := continuous_id.prod_mk continuous_const }\n\n/-- `{*} \u00d7 \u03b1` is homeomorphic to `\u03b1`. -/\ndef punit_prod : punit \u00d7 \u03b1 \u2243\u209c \u03b1 :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : \u21d1(punit_prod \u03b1) = prod.snd := rfl\n\nend\n\n/-- `ulift \u03b1` is homeomorphic to `\u03b1`. -/\ndef {u v} ulift {\u03b1 : Type u} [topological_space \u03b1] : ulift.{v u} \u03b1 \u2243\u209c \u03b1 :=\n{ continuous_to_fun := continuous_ulift_down,\n  continuous_inv_fun := continuous_ulift_up,\n  to_equiv := equiv.ulift }\n\nsection distrib\n\n/-- `(\u03b1 \u2295 \u03b2) \u00d7 \u03b3` is homeomorphic to `\u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3`. -/\ndef sum_prod_distrib : (\u03b1 \u2295 \u03b2) \u00d7 \u03b3 \u2243\u209c \u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3 :=\nbegin\n  refine (homeomorph.homeomorph_of_continuous_open (equiv.sum_prod_distrib \u03b1 \u03b2 \u03b3).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/-- `\u03b1 \u00d7 (\u03b2 \u2295 \u03b3)` is homeomorphic to `\u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3`. -/\ndef prod_sum_distrib : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243\u209c \u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3 :=\n(prod_comm _ _).trans $\nsum_prod_distrib.trans $\nsum_congr (prod_comm _ _) (prod_comm _ _)\n\nvariables {\u03b9 : Type*} {\u03c3 : \u03b9 \u2192 Type*} [\u03a0 i, topological_space (\u03c3 i)]\n\n/-- `(\u03a3 i, \u03c3 i) \u00d7 \u03b2` is homeomorphic to `\u03a3 i, (\u03c3 i \u00d7 \u03b2)`. -/\ndef sigma_prod_distrib : ((\u03a3 i, \u03c3 i) \u00d7 \u03b2) \u2243\u209c (\u03a3 i, (\u03c3 i \u00d7 \u03b2)) :=\nhomeomorph.symm $\nhomeomorph_of_continuous_open (equiv.sigma_prod_distrib \u03c3 \u03b2).symm\n  (continuous_sigma $ \u03bb i,\n    (continuous_sigma_mk.comp continuous_fst).prod_mk continuous_snd)\n  (is_open_map_sigma $ \u03bb i,\n    (open_embedding_sigma_mk.prod open_embedding_id).is_open_map)\n\nend distrib\n\n/-- If `\u03b9` has a unique element, then `\u03b9 \u2192 \u03b1` is homeomorphic to `\u03b1`. -/\n@[simps { fully_applied := ff }]\ndef fun_unique (\u03b9 \u03b1 : Type*) [unique \u03b9] [topological_space \u03b1] : (\u03b9 \u2192 \u03b1) \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.fun_unique \u03b9 \u03b1,\n  continuous_to_fun := continuous_apply _,\n  continuous_inv_fun := continuous_pi (\u03bb _, continuous_id) }\n\n/-- Homeomorphism between dependent functions `\u03a0 i : fin 2, \u03b1 i` and `\u03b1 0 \u00d7 \u03b1 1`. -/\n@[simps { fully_applied := ff }]\ndef {u} pi_fin_two (\u03b1 : fin 2 \u2192 Type u) [\u03a0 i, topological_space (\u03b1 i)] : (\u03a0 i, \u03b1 i) \u2243\u209c \u03b1 0 \u00d7 \u03b1 1 :=\n{ to_equiv := pi_fin_two_equiv \u03b1,\n  continuous_to_fun := (continuous_apply 0).prod_mk (continuous_apply 1),\n  continuous_inv_fun := continuous_pi $ fin.forall_fin_two.2 \u27e8continuous_fst, continuous_snd\u27e9 }\n\n/-- Homeomorphism between `\u03b1\u00b2 = fin 2 \u2192 \u03b1` and `\u03b1 \u00d7 \u03b1`. -/\n@[simps { fully_applied := ff }] def fin_two_arrow : (fin 2 \u2192 \u03b1) \u2243\u209c \u03b1 \u00d7 \u03b1 :=\n{ to_equiv := fin_two_arrow_equiv \u03b1, ..  pi_fin_two (\u03bb _, \u03b1) }\n\n/--\nA subset of a topological space is homeomorphic to its image under a homeomorphism.\n-/\n@[simps] def image (e : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : s \u2243\u209c 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 \u03b1` is homeomorphic to `\u03b1`. -/\n@[simps { fully_applied := ff }]\ndef set.univ (\u03b1 : Type*) [topological_space \u03b1] : (univ : set \u03b1) \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.set.univ \u03b1,\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 \u03b1] [topological_space \u03b2] (f : \u03b1 \u2243 \u03b2)\n  (hf : inducing f) :\n  \u03b1 \u2243\u209c \u03b2 :=\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 \u03b1] [topological_space \u03b2]\n\nlemma continuous_symm_of_equiv_compact_to_t2 [compact_space \u03b1] [t2_space \u03b2]\n  {f : \u03b1 \u2243 \u03b2} (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 \u03b1] [t2_space \u03b2]\n  {f : \u03b1 \u2243 \u03b2} (hf : continuous f) : \u03b1 \u2243\u209c \u03b2 :=\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 `\u03d5 i : N i \u2192* M` for each `i : \u03b9` where elements in the\nimages of different morphisms commute, we obtain a canonical morphism\n`monoid_hom.noncomm_pi_coprod : (\u03a0 i, N i) \u2192* M` that coincides with `\u03d5`\n\n## Main definitions\n\n* `monoid_hom.noncomm_pi_coprod : (\u03a0 i, N i) \u2192* M` is the main homomorphism\n* `subgroup.noncomm_pi_coprod : (\u03a0 i, H i) \u2192* 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 `\u03d5 i` when restricted to `N i`\n* `monoid_hom.noncomm_pi_coprod_mrange`: The range of `monoid_hom.noncomm_pi_coprod` is\n  `\u2a06 (i : \u03b9), (\u03d5 i).mrange`\n* `monoid_hom.noncomm_pi_coprod_range`: The range of `monoid_hom.noncomm_pi_coprod` is\n  `\u2a06 (i : \u03b9), (\u03d5 i).range`\n* `subgroup.noncomm_pi_coprod_range`: The range of `subgroup.noncomm_pi_coprod` is `\u2a06 (i : \u03b9), H i`.\n* `monoid_hom.injective_noncomm_pi_coprod_of_independent`: in the case of groups, `pi_hom.hom` is\n   injective if the `\u03d5` are injective and the ranges of the `\u03d5` are independent.\n* `monoid_hom.independent_range_of_coprime_order`: If the `N i` have coprime orders, then the ranges\n   of the `\u03d5` 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 \u201cinjective\u201d 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 \u201cinjective\u201d 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 {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 G) (comm)\n  (K : \u03b9 \u2192 subgroup G) (hind : complete_lattice.independent K) (hmem : \u2200 (x \u2208 s), f x \u2208 K x)\n  (heq1 : s.noncomm_prod f comm = 1) : \u2200 (i \u2208 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 \u2208 \u2a06 (i \u2208 (s : set \u03b9)), K i,\n    { refine subgroup.noncomm_prod_mem _ _ _,\n      intros x hx,\n      have : K x \u2264 \u2a06 (i \u2208 (s : set \u03b9)), K i := le_supr\u2082 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 \u2209 (s : set \u03b9), by simpa,\n    obtain \u27e8heq1i : f i = 1, heq1S : s.noncomm_prod f _ = 1\u27e9 :=\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 \u27e8rfl | _\u27e9,\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 {\u03b9 : Type*} [hdec : decidable_eq \u03b9] [fintype \u03b9]\nvariables {N : \u03b9 \u2192 Type*} [\u2200 i, monoid (N i)]\n\n-- And morphisms \u03d5 into G\nvariables (\u03d5 : \u03a0 (i : \u03b9), N i \u2192* M)\n\n-- We assume that the elements of different morphism commute\nvariables (hcomm : pairwise $ \u03bb i j, \u2200 x y, commute (\u03d5 i x) (\u03d5 j y))\ninclude hcomm\n\n-- We use `f` and `g` to denote elements of `\u03a0 (i : \u03b9), N i`\nvariables (f g : \u03a0 (i : \u03b9), 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 : (\u03a0 (i : \u03b9), N i) \u2192* M :=\n{ to_fun := \u03bb f, finset.univ.noncomm_prod (\u03bb i, \u03d5 i (f i)) $ \u03bb i _ j _ h, hcomm h _ _,\n  map_one' := by {apply (finset.noncomm_prod_eq_pow_card _ _ _ _ _).trans (one_pow _), simp},\n  map_mul' := \u03bb f g,\n  begin\n    classical,\n    convert @finset.noncomm_prod_mul_distrib _ _ _ _ (\u03bb i, \u03d5 i (f i)) (\u03bb i, \u03d5 i (g i)) _ _ _,\n    { ext i, exact map_mul (\u03d5 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 : \u03b9) (y : N i):\n  noncomm_pi_coprod \u03d5 hcomm (pi.mul_single i y) = \u03d5 i y :=\nbegin\n  change finset.univ.noncomm_prod (\u03bb j, \u03d5 j (pi.mul_single i y j)) _ = \u03d5 i y,\n  simp only [\u2190finset.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  {\u03d5 : \u03a0 i, N i \u2192* M // pairwise (\u03bb i j, \u2200 x y, commute (\u03d5 i x) (\u03d5 j y)) }\n    \u2243 ((\u03a0 i, N i) \u2192* M) :=\n{ to_fun := \u03bb \u03d5, noncomm_pi_coprod \u03d5.1 \u03d5.2,\n  inv_fun := \u03bb f,\n  \u27e8 \u03bb i, f.comp (monoid_hom.single N i),\n    \u03bb i j hij x y, commute.map (pi.mul_single_commute hij x y) f \u27e9,\n  left_inv := \u03bb \u03d5, by { ext, simp, },\n  right_inv := \u03bb f, pi_ext (\u03bb i x, by simp) }\n\nomit hdec\n\ninclude hcomm\n\n@[to_additive]\nlemma noncomm_pi_coprod_mrange : (noncomm_pi_coprod \u03d5 hcomm).mrange = \u2a06 i : \u03b9, (\u03d5 i).mrange :=\nbegin\n  classical,\n  apply le_antisymm,\n  { rintro x \u27e8f, rfl\u27e9,\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 \u27e8y, rfl\u27e9,\n    refine \u27e8pi.mul_single i y, noncomm_pi_coprod_mul_single _ _ _\u27e9, },\nend\n\nend monoid_hom\n\nend family_of_monoids\n\nsection family_of_groups\n\nvariables {G : Type*} [group G]\nvariables {\u03b9 : Type*} [hdec : decidable_eq \u03b9] [hfin : fintype \u03b9]\nvariables {H : \u03b9 \u2192 Type*} [\u2200 i, group (H i)]\nvariables (\u03d5 : \u03a0 (i : \u03b9), H i \u2192* G)\nvariables {hcomm : \u2200 (i j : \u03b9), i \u2260 j \u2192 \u2200 (x : H i) (y : H j), commute (\u03d5 i x) (\u03d5 j y)}\ninclude hcomm\n\n-- We use `f` and `g` to denote elements of `\u03a0 (i : \u03b9), H i`\nvariables (f g : \u03a0 (i : \u03b9), 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 \u03d5 hcomm).range = \u2a06 i : \u03b9, (\u03d5 i).range :=\nbegin\n  classical,\n  apply le_antisymm,\n  { rintro x \u27e8f, rfl\u27e9,\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 \u27e8y, rfl\u27e9,\n    refine \u27e8pi.mul_single i y, noncomm_pi_coprod_mul_single _ _ _\u27e9, },\nend\n\n@[to_additive]\nlemma injective_noncomm_pi_coprod_of_independent\n  (hind : complete_lattice.independent (\u03bb i, (\u03d5 i).range))\n  (hinj : \u2200 i, function.injective (\u03d5 i)) :\n  function.injective (noncomm_pi_coprod \u03d5 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 (\u03bb i, \u03d5 i (f i)) _ = 1 at heq1,\n  change f = 1,\n  have : \u2200 i, i \u2208 finset.univ \u2192 \u03d5 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 \u03b9] [\u03a0 i, fintype (H i)]\n  (hcoprime : \u2200 i j, i \u2260 j \u2192 nat.coprime (fintype.card (H i)) (fintype.card (H j))) :\n  complete_lattice.independent (\u03bb i, (\u03d5 i).range) :=\nbegin\n  casesI nonempty_fintype \u03b9,\n  classical,\n  rintros i,\n  rw disjoint_iff_inf_le,\n  rintros f \u27e8hxi, hxp\u27e9, dsimp at hxi hxp,\n  rw [supr_subtype', \u2190 noncomm_pi_coprod_range] at hxp,\n  rotate, { intros _ _ hj, apply hcomm, exact hj \u2218 subtype.ext },\n  cases hxp with g hgf, cases hxi with g' hg'f,\n  have hxi : order_of f \u2223 fintype.card (H i),\n  { rw \u2190 hg'f, exact (order_of_map_dvd _ _).trans order_of_dvd_card_univ },\n  have hxp : order_of f \u2223 \u220f j : {j // j \u2260 i}, fintype.card (H j),\n  { rw [\u2190 hgf, \u2190 fintype.card_pi], exact (order_of_map_dvd _ _).trans order_of_dvd_card_univ },\n  change f = 1, rw [\u2190 pow_one f, \u2190 order_of_dvd_iff_pow_eq_one],\n  convert \u2190 nat.dvd_gcd hxp hxi, rw \u2190 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 {\u03b9 : Type*} [hdec : decidable_eq \u03b9] [hfin : fintype \u03b9] {H : \u03b9 \u2192 subgroup G}\n\n-- Elements of `\u03a0 (i : \u03b9), H i` are called `f` and `g` here\nvariables (f g : \u03a0 (i : \u03b9), H i)\n\nsection commuting_subgroups\n\n-- We assume that the elements of different subgroups commute\nvariables (hcomm : \u2200 (i j : \u03b9), i \u2260 j \u2192 \u2200 (x y : G), x \u2208 H i \u2192 y \u2208 H j \u2192 commute x y)\ninclude hcomm\n\n@[to_additive]\nlemma commute_subtype_of_commute (i j : \u03b9) (hne : i \u2260 j) :\n  \u2200 (x : H i) (y : H j), commute ((H i).subtype x) ((H j).subtype y) :=\nby { rintros \u27e8x, hx\u27e9 \u27e8y, hy\u27e9, 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 : (\u03a0 (i : \u03b9), H i) \u2192* G :=\n  monoid_hom.noncomm_pi_coprod (\u03bb 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 : \u03b9) (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 = \u2a06 i : \u03b9, 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 \u03b9] [\u2200 i, fintype (H i)]\n  (hcoprime : \u2200 i j, i \u2260 j \u2192 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 (\u03bb 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 \u2192 Type)) (X : Type) extends LinearArrayType T X\n\ninstance (T : Nat \u2192 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 := \u03bb [i] => f i`\n     for `f : I \u2192 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 \u2192 Type) [\u2200 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\u2081,...,n\u2098}` you can:\n  1. get a value: `x[i\u2081,...,i\u2098] : X` for `i\u2081 : Fin n\u2081`, ... , `i\u2098 : Fin n\u2098`\n  2. set a value in do blocks: `x[i\u2081,...,i\u2098] := xi`, `x[i\u2081,...,i\u2098] += xi`\n     for `x : X^{n\u2081,...,n\u2098}`, `i\u2081 : Fin n\u2081`, ... , `i\u2098 : Fin n\u2098`, `xi : X` \n  3. introduce new array: \n     `let x : X^{n\u2081,...,n\u2098} := \u03bb [i\u2081,...,i\u2098] => f i\u2081 ... i\u2098`\n     for `f : Fin n\u2081 \u2192 ... \u2192 Fin n\u2098 \u2192 X`\n\nThe type `X^{n\u2081,...,n\u2098}` is just a notation for `X^(Fin n\u2081 \u00d7 ... Fin n\u2098)`\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 \u2190 ns'.foldrM (\u03bb x y => `(Fin $x \u00d7 $y)) (\u2190 `(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 `\u03bb [j] => A[i,j]` -/\nmacro A:term  noWs \"[\" id1:term \",\" \":\" \"]\" : term => `(\u03bb [j] => $A[($id1, j)])\n/-- `A[i,\u00b7]` is just a notation for `\u03bb [j] => A[i,j]` -/\nmacro A:term  noWs \"[\" id1:term \",\" \"\u00b7\" \"]\" : term => `(\u03bb j => $A[($id1, j)])\n/-- `A[:,j]` is just a notation for `\u03bb [i] => A[i,j]` -/\nmacro A:term  noWs \"[\" \":\" \",\" id2:term \"]\" : term => `(\u03bb [i] => $A[(i, $id2)])\n/-- `A[\u00b7,j]` is just a notation for `\u03bb i => A[i,j]` -/\nmacro A:term  noWs \"[\" \"\u00b7\" \",\" id2:term \"]\" : term => `(\u03bb 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) \"\u03bb\" Lean.Parser.Term.funBinder+  \" ==> \" term : term\nsyntax (name:=powTypeIntroSyntaxAlt) \"\u229e\" 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 \u2192 X) : X^I := introElem \u03bb i => f i\n\nmacro_rules (kind := powTypeIntroSyntax)\n| `(\u03bb $xs:funBinder* ==> $b:term) => `(introPowElem \u03bb $xs* => $b)\nmacro_rules (kind := powTypeIntroSyntaxAlt)\n| `(\u229e $xs:funBinder* , $b:term) => `(introPowElem \u03bb $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 \u2192 X) : X^I := introElem f\nabbrev modify (x : X^I) (i : I) (f : X \u2192 X) : X^I := ArrayType.modifyElem x i f\nabbrev mapIdx (f : I \u2192 X \u2192 X) (x : X^I) : X^I := ArrayType.mapIdx f x\nabbrev map (f : X \u2192 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? (\u03b1 := Array X) json with\n    | .error msg => .error msg\n    | .ok array => \n      if h : (numOf I) = array.size then\n        .ok (introElem \u03bb i => array[h \u25b8 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 \u2192 Type)} [LinearPowType T X]\n\nabbrev empty : X^{0} := ArrayType.empty \nabbrev split {n m : Nat} (x : X^{n+m}) : X^{n} \u00d7 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) \u2192 X^{n'+1} \u2192 X^{n'}) (x : X^{n}) : X^{(n*(n+1))/2} := \n  ArrayType.generateUpperTriangularArray f x\nabbrev upper2DiagonalUpdate [Vec X] (a : Fin n \u2192 \u211d) (b : Fin (n-1) \u2192 \u211d) (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 \u2192 \u211d) (b : Fin (n-1) \u2192 \u211d) (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 : \u211d) (x : X^{n+1}) : X^{n} :=\n  ArrayType.linearInterpolate t x\n\n-- example [Vec X] : IsLin (\u03bb x : X^{n} => x.upper2DiagonalUpdate (\u03bb _ => 1) (\u03bb _ => -1)) := by infer_instance\n-- example [Vec X] : IsLin (\u03bb x : X^{n+1} => x.drop) := by infer_instance\n-- example [Vec X] (xi : X) : IsSmooth (\u03bb x : X^{n} => x.push xi) := by infer_instance\n\n-- example [Vec X] : IsSmooth (\u03bb x : X^{n+1} => x.linearInterpolate) := by infer_instance\n-- example [Vec X] (x : X^{n+1}) : IsSmooth (\u03bb 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\u00d7J) 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\u00d7J)) \u2192 ((X^J)^I) := sorry\n-- def uncurry : ((X^J)^I) \u2192 (X^(I\u00d7J)) := 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u2964 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 \u2964 Meas`: sends a topological space `X` to `X` equipped with the\n`\u03c3`-algebra of Borel sets (the `\u03c3`-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 (\u03b1 : Type u) [measurable_space \u03b1] : Meas := \u27e8\u03b1\u27e9\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 := \u27e8@measurable_id, @measurable.comp\u27e9\n\nattribute [derive [large_category, concrete_category]] Meas\n\ninstance : inhabited Meas := \u27e8Meas.of empty\u27e9\n\n/-- `Measure X` is the measurable space of measures over the measurable space `X`. It is the\nweakest measurable space, s.t. \u03bb\u03bc, \u03bc 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`(\u03bc >>= \u03bd) s = \u222b x. (\u03bd x) s d\u03bc`.\n\nIn probability theory, the `Meas`-morphisms `X \u2192 Prob X` are (sub-)Markov kernels (here `Prob` is\nthe restriction of `Measure` to (sub-)probability space.)\n-/\ndef Measure : Meas \u2964 Meas :=\n{ obj      := \u03bbX, \u27e8@measure_theory.measure X.1 X.2\u27e9,\n  map      := \u03bbX Y f, \u27e8measure.map (f : X \u2192 Y), measure.measurable_map f f.2\u27e9,\n  map_id'  := assume \u27e8\u03b1, I\u27e9, subtype.eq $ funext $ assume \u03bc, @measure.map_id \u03b1 I \u03bc,\n  map_comp':=\n    assume X Y Z \u27e8f, hf\u27e9 \u27e8g, hg\u27e9, subtype.eq $ funext $ assume \u03bc, (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  \u03b7' :=\n  { app         := \u03bbX, \u27e8@measure.dirac X.1 X.2, measure.measurable_dirac\u27e9,\n    naturality' :=\n      assume X Y \u27e8f, hf\u27e9, subtype.eq $ funext $ assume a, (measure.map_dirac hf a).symm },\n  \u03bc' :=\n  { app         := \u03bbX, \u27e8@measure.join X.1 X.2, measure.measurable_join\u27e9,\n    naturality' :=\n      assume X Y \u27e8f, hf\u27e9, subtype.eq $ funext $ assume \u03bc, measure.join_map_map hf \u03bc },\n  assoc' := assume \u03b1, subtype.eq $ funext $ assume \u03bc, @measure.join_map_join _ _ _,\n  left_unit' := assume \u03b1, subtype.eq $ funext $ assume \u03bc, @measure.join_dirac _ _ _,\n  right_unit' := assume \u03b1, subtype.eq $ funext $ assume \u03bc, @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 \u211d\u22650\u221e ,\n  a      := \u27e8\u03bbm:measure \u211d\u22650\u221e, \u222b\u207b x, x \u2202m, measure.measurable_lintegral measurable_id \u27e9,\n  unit'  := subtype.eq $ funext $ assume r:\u211d\u22650\u221e, lintegral_dirac' _ measurable_id,\n  assoc' := subtype.eq $ funext $ assume \u03bc : measure (measure \u211d\u22650\u221e),\n    show \u222b\u207b x, x \u2202 \u03bc.join = \u222b\u207b x, x \u2202 (measure.map (\u03bbm:measure \u211d\u22650\u221e, \u222b\u207b x, x \u2202m) \u03bc),\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\u2082 Top.{u} Meas.{u} :=\nbundled_hom.mk_has_forget\u2082\n  borel\n  (\u03bb X Y f, \u27e8f.1, f.2.borel_measurable\u27e9)\n  (by intros; refl)\n\n/-- The Borel functor, the canonical embedding of topological spaces into measurable spaces. -/\n@[reducible] def Borel : Top.{u} \u2964 Meas.{u} := forget\u2082 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 {\u03b1 : Type*} {X : finset \u03b1}\nparameters {d : \u2115} {h_d : d \u2265 2}\n\n/-- `\ud835\udcd5` is a collection of `d`-sets of `X`-/\n\nvariables (\ud835\udcd5 : finset (finset X)) (H_\ud835\udcd5 : \u2200 A : finset X, A \u2208 \ud835\udcd5 \u2192 A.card = d)\n\ndef two_colorable :=\n  \u2203 c : X \u2192 fin 2, \u2200 A : finset X, A \u2208 \ud835\udcd5 \u2192 \u2203 x y : A, c x = 0 \u2227 c y = 0\n\ninclude H_\ud835\udcd5\ntheorem theorem_1 : \ud835\udcd5.card \u2264 2 ^ (d-1) \u2192 two_colorable \ud835\udcd5 :=\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 : \u2115) (N : \u2115) :=\n  \u2200 c : (complete_graph (fin N)).edge_set \u2192 fin 2,\n  ( \u2203 g : complete_graph (fin m) \u2192g complete_graph (fin N), \u2200 e : (complete_graph (fin m)).edge_set,\n      c (g.map_edge_set e) = 0 ) \u2228\n  ( \u2203 h : complete_graph (fin n) \u2192g complete_graph (fin N), \u2200 e : (complete_graph (fin n)).edge_set,\n    c (h.map_edge_set e) = 1 )\n\n\nlemma ramsey_exists (m n : \u2115) (h_m : m \u2265 2) (h_n : n \u2265 2) : \u2203 N, ramsey_property m n N :=\nbegin\n  sorry,\nend\n\n/--\nThe Ramsey Numbers. Noe that this is only defined for `m, n \u2265 2`\nWould it make sense to make this not noncomputable?\n-/\nnoncomputable def ramsey (m n : \u2115) :=\n   Inf {N : \u2115 | ramsey_property m n N }\n\nnamespace ramsey\n\nlemma symm (m n : \u2115) (h_m : m \u2265 2) (h_n : n \u2265 2) : ramsey m n = ramsey n m :=\nbegin\n  sorry,\nend\n\nlemma two (m : \u2115) (h_m : m \u2265 2) : ramsey m 2 = m :=\nbegin\n  sorry,\nend\n\nlemma bound (m n : \u2115) (h_m : m \u2265 3) (h_n : n \u2265 3) :\n  ramsey m n \u2264 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 : \u2115) (h_k : k \u2265 2) :\n  (ramsey k k : \u211d) \u2265 real.exp ((real.log 2) + (k: \u211d) / 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 : \u2115 | N \u2265 1 \u2227 \u2203 (u : V) (W : G.walk u u), N = W.length \u2227 W.is_cycle}\n\ntheorem theorem_3 (k : \u2115) (h_k : k \u2265 2) :\n  \u2203 (n : \u2115) (G : simple_graph (fin n)), G.chromatic_number > k \u2227 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 : \u2115 | \u2203 (c : V \u2192 \u211d \u00d7 \u211d) (f : G.edge_set \u2192 (set.Icc (0:\u211d) 1) \u2192 \u211d \u00d7 \u211d),\n                  function.injective c \u2227\n                  \u2200 (e : G.edge_set) (v : V) (h : v \u2208 (e : sym2 V)),\n                    ({v, sym2.mem.other h} :set V).image c = (coe \u207b\u00b9' ({0,1} : set \u211d)).image (f e) \u2227\n                    true }\n        -- We'd like that at every point in \u211d\u00d7 \u211d, 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 : \u2115)\n  (H : m \u2265 4 * n) (h_n : n = fintype.card V) (h_m : m = fintype.card G.edge_set) :\n  crossing_number G \u2265 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 \u2964 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\u2081 v\u2081 v\u2082 u\u2081 u\u2082\n\nnamespace category_theory\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n\n/-- The functorial version of `ulift.up`. -/\n@[simps]\ndef ulift.up_functor : C \u2964 (ulift.{u\u2082} C) :=\n{ obj := ulift.up,\n  map := \u03bb X Y f, f }\n\n/-- The functorial version of `ulift.down`. -/\n@[simps]\ndef ulift.down_functor : (ulift.{u\u2082} C) \u2964 C :=\n{ obj := ulift.down,\n  map := \u03bb X Y f, f }\n\n/-- The categorical equivalence between `C` and `ulift C`. -/\n@[simps]\ndef ulift.equivalence : C \u224c (ulift.{u\u2082} C) :=\n{ functor := ulift.up_functor,\n  inverse := ulift.down_functor,\n  unit_iso :=\n  { hom := \ud835\udfd9 _,\n    inv := \ud835\udfd9 _ },\n  counit_iso :=\n  { hom :=\n    { app := \u03bb X, \ud835\udfd9 _,\n      naturality' := \u03bb X Y f, by {change f \u226b \ud835\udfd9 _ = \ud835\udfd9 _ \u226b f, simp} },\n    inv :=\n    { app := \u03bb X, \ud835\udfd9 _,\n      naturality' := \u03bb X Y f, by {change f \u226b \ud835\udfd9 _ = \ud835\udfd9 _ \u226b f, simp} },\n  hom_inv_id' := by {ext, change (\ud835\udfd9 _) \u226b (\ud835\udfd9 _) = \ud835\udfd9 _, simp},\n  inv_hom_id' := by {ext, change (\ud835\udfd9 _) \u226b (\ud835\udfd9 _) = \ud835\udfd9 _, simp} },\n  functor_unit_iso_comp' := \u03bb X, by {change (\ud835\udfd9 X) \u226b (\ud835\udfd9 X) = \ud835\udfd9 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) := \u27e8(arbitrary C : C)\u27e9\n\n/-- The obvious function `ulift_hom C \u2192 C`. -/\ndef ulift_hom.obj_down {C} (A : ulift_hom C) : C := A\n\n/-- The obvious function `C \u2192 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\u2082 v\u2081} (ulift_hom.{v\u2082} C) :=\n{ hom := \u03bb A B, ulift.{v\u2082} $ A.obj_down \u27f6 B.obj_down,\n  id := \u03bb A, \u27e8\ud835\udfd9 _\u27e9,\n  comp := \u03bb A B C f g, \u27e8f.down \u226b g.down\u27e9}\n\n/-- One half of the quivalence between `C` and `ulift_hom C`. -/\n@[simps]\ndef ulift_hom.up : C \u2964 ulift_hom C :=\n{ obj := ulift_hom.obj_up,\n  map := \u03bb X Y f, \u27e8f\u27e9 }\n\n/-- One half of the quivalence between `C` and `ulift_hom C`. -/\n@[simps]\ndef ulift_hom.down : ulift_hom C \u2964 C :=\n{ obj := ulift_hom.obj_down,\n  map := \u03bb X Y f, f.down }\n\n/-- The equivalence between `C` and `ulift_hom C`. -/\ndef ulift_hom.equiv : C \u224c ulift_hom C :=\n{ functor := ulift_hom.up,\n  inverse := ulift_hom.down,\n  unit_iso := nat_iso.of_components (\u03bb A, eq_to_iso rfl) (by tidy),\n  counit_iso := nat_iso.of_components (\u03bb 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\u2081} C) :=\n{ hom := \u03bb X Y, ulift.{max w\u2081 u\u2081} $ X.down \u27f6 Y.down,\n  id := \u03bb X, \u27e8\ud835\udfd9 _\u27e9,\n  comp := \u03bb X Y Z f g, \u27e8f.down \u226b g.down\u27e9 }\n\n/-- One half of the equivalence between `C` and `as_small C`. -/\n@[simps]\ndef as_small.up : C \u2964 as_small C :=\n{ obj := \u03bb X, \u27e8X\u27e9,\n  map := \u03bb X Y f, \u27e8f\u27e9 }\n\n/-- One half of the equivalence between `C` and `as_small C`. -/\n@[simps]\ndef as_small.down : as_small C \u2964 C :=\n{ obj := \u03bb X, X.down,\n  map := \u03bb X Y f, f.down }\n\n/-- The equivalence between `C` and `as_small C`. -/\n@[simps]\ndef as_small.equiv : C \u224c as_small C :=\n{ functor := as_small.up,\n  inverse := as_small.down,\n  unit_iso := nat_iso.of_components (\u03bb X, eq_to_iso rfl) (by tidy),\n  counit_iso := nat_iso.of_components (\u03bb X, eq_to_iso $ by { ext, refl }) (by tidy) }\n\ninstance [inhabited C] : inhabited (as_small C) := \u27e8\u27e8arbitrary _\u27e9\u27e9\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 \u224c 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 \u03b1 = \u03b1\u1d50\u1d52\u1d56` to be the multiplicative opposite of `\u03b1`. It inherits\nall additive algebraic structures on `\u03b1` (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 `\u03b1` to `\u03b1\u1d50\u1d52\u1d56`.\n\nWe also define `add_opposite \u03b1 = \u03b1\u1d43\u1d52\u1d56` to be the additive opposite of `\u03b1`. It inherits all\nmultiplicative algebraic structures on `\u03b1` (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 `\u03b1` to `\u03b1\u1d43\u1d52\u1d56`.\n\n## Notation\n\n* `\u03b1\u1d50\u1d52\u1d56 = mul_opposite \u03b1`\n* `\u03b1\u1d43\u1d52\u1d56 = add_opposite \u03b1`\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 `\u03b1` and\nreverses left and right in multiplication.-/\n@[to_additive \"Additive opposite of a type. This type inherits all multiplicative structures on\n`\u03b1` and reverses left and right in addition.\"]\ndef mul_opposite (\u03b1 : Type u) : Type u := \u03b1\n\npostfix `\u1d50\u1d52\u1d56`:std.prec.max_plus := mul_opposite\npostfix `\u1d43\u1d52\u1d56`:std.prec.max_plus := add_opposite\n\nvariables {\u03b1 : Type u}\n\nnamespace mul_opposite\n\n/-- The element of `mul_opposite \u03b1` that represents `x : \u03b1`. -/\n@[pp_nodot, to_additive \"The element of `\u03b1\u1d43\u1d52\u1d56` that represents `x : \u03b1`.\"]\ndef op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56 := id\n\n/-- The element of `\u03b1` represented by `x : \u03b1\u1d50\u1d52\u1d56`. -/\n@[pp_nodot, to_additive \"The element of `\u03b1` represented by `x : \u03b1\u1d43\u1d52\u1d56`.\"]\ndef unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1 := id\n\nattribute [pp_nodot] add_opposite.op add_opposite.unop\n\n@[simp, to_additive] lemma unop_op (x : \u03b1) : unop (op x) = x := rfl\n@[simp, to_additive] lemma op_unop (x : \u03b1\u1d50\u1d52\u1d56) : op (unop x) = x := rfl\n@[simp, to_additive] lemma op_comp_unop : (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) \u2218 unop = id := rfl\n@[simp, to_additive] lemma unop_comp_op : (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) \u2218 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 : \u03a0 (X : \u03b1\u1d50\u1d52\u1d56), Sort v} (h : \u03a0 X, F (op X)) : \u03a0 X, F X :=\n\u03bb X, h (unop X)\n\n/-- The canonical bijection between `\u03b1` and `\u03b1\u1d50\u1d52\u1d56`. -/\n@[to_additive \"The canonical bijection between `\u03b1` and `\u03b1\u1d43\u1d52\u1d56`.\",\n  simps apply symm_apply { fully_applied := ff }]\ndef op_equiv : \u03b1 \u2243 \u03b1\u1d50\u1d52\u1d56 := \u27e8op, unop, unop_op, op_unop\u27e9\n\n@[to_additive] lemma op_bijective : bijective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_equiv.bijective\n@[to_additive] lemma unop_bijective : bijective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := op_equiv.symm.bijective\n@[to_additive] lemma op_injective : injective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_bijective.injective\n@[to_additive] lemma op_surjective : surjective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_bijective.surjective\n@[to_additive] lemma unop_injective : injective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := unop_bijective.injective\n@[to_additive] lemma unop_surjective : surjective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := unop_bijective.surjective\n\n@[simp, to_additive] lemma op_inj {x y : \u03b1} : op x = op y \u2194 x = y := op_injective.eq_iff\n@[simp, to_additive] lemma unop_inj {x y : \u03b1\u1d50\u1d52\u1d56} : unop x = unop y \u2194 x = y := unop_injective.eq_iff\n\nvariable (\u03b1)\n\n@[to_additive] instance [nontrivial \u03b1] : nontrivial \u03b1\u1d50\u1d52\u1d56 := op_injective.nontrivial\n@[to_additive] instance [inhabited \u03b1] : inhabited \u03b1\u1d50\u1d52\u1d56 := \u27e8op default\u27e9\n@[to_additive] instance [subsingleton \u03b1] : subsingleton \u03b1\u1d50\u1d52\u1d56 := unop_injective.subsingleton\n@[to_additive] instance [unique \u03b1] : unique \u03b1\u1d50\u1d52\u1d56 := unique.mk' _\n@[to_additive] instance [is_empty \u03b1] : is_empty \u03b1\u1d50\u1d52\u1d56 := function.is_empty unop\n\ninstance [has_zero \u03b1] : has_zero \u03b1\u1d50\u1d52\u1d56 := { zero := op 0 }\n\n@[to_additive] instance [has_one \u03b1] : has_one \u03b1\u1d50\u1d52\u1d56 := { one := op 1 }\n\ninstance [has_add \u03b1] : has_add \u03b1\u1d50\u1d52\u1d56 :=\n{ add := \u03bb x y, op (unop x + unop y) }\n\ninstance [has_sub \u03b1] : has_sub \u03b1\u1d50\u1d52\u1d56 :=\n{ sub := \u03bb x y, op (unop x - unop y) }\n\ninstance [has_neg \u03b1] : has_neg \u03b1\u1d50\u1d52\u1d56 :=\n{ neg := \u03bb x, op $ -(unop x) }\n\ninstance [has_involutive_neg \u03b1] : has_involutive_neg \u03b1\u1d50\u1d52\u1d56 :=\n{ neg_neg := \u03bb a, unop_injective $ neg_neg _,\n  ..mul_opposite.has_neg \u03b1 }\n\n@[to_additive] instance [has_mul \u03b1] : has_mul \u03b1\u1d50\u1d52\u1d56 :=\n{ mul := \u03bb x y, op (unop y * unop x) }\n\n@[to_additive] instance [has_inv \u03b1] : has_inv \u03b1\u1d50\u1d52\u1d56 :=\n{ inv := \u03bb x, op $ (unop x)\u207b\u00b9 }\n\n@[to_additive] instance [has_involutive_inv \u03b1] : has_involutive_inv \u03b1\u1d50\u1d52\u1d56 :=\n{ inv_inv := \u03bb a, unop_injective $ inv_inv _,\n  ..mul_opposite.has_inv \u03b1 }\n\n@[to_additive] instance (R : Type*) [has_smul R \u03b1] : has_smul R \u03b1\u1d50\u1d52\u1d56 :=\n{ smul := \u03bb c x, op (c \u2022 unop x) }\n\nsection\nvariables (\u03b1)\n\n@[simp] lemma op_zero [has_zero \u03b1] : op (0 : \u03b1) = 0 := rfl\n@[simp] \n\n@[simp, to_additive] lemma op_one [has_one \u03b1] : op (1 : \u03b1) = 1 := rfl\n@[simp, to_additive] lemma unop_one [has_one \u03b1] : unop (1 : \u03b1\u1d50\u1d52\u1d56) = 1 := rfl\n\nvariable {\u03b1}\n\n@[simp] lemma op_add [has_add \u03b1] (x y : \u03b1) : op (x + y) = op x + op y := rfl\n@[simp] lemma unop_add [has_add \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x + y) = unop x + unop y := rfl\n\n@[simp] lemma op_neg [has_neg \u03b1] (x : \u03b1) : op (-x) = -op x := rfl\n@[simp] lemma unop_neg [has_neg \u03b1] (x : \u03b1\u1d50\u1d52\u1d56) : unop (-x) = -unop x := rfl\n\n@[simp, to_additive] lemma op_mul [has_mul \u03b1] (x y : \u03b1) : op (x * y) = op y * op x := rfl\n@[simp, to_additive] lemma unop_mul [has_mul \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x * y) = unop y * unop x := rfl\n\n@[simp, to_additive] lemma op_inv [has_inv \u03b1] (x : \u03b1) : op (x\u207b\u00b9) = (op x)\u207b\u00b9 := rfl\n@[simp, to_additive] lemma unop_inv [has_inv \u03b1] (x : \u03b1\u1d50\u1d52\u1d56) : unop (x\u207b\u00b9) = (unop x)\u207b\u00b9 := rfl\n\n@[simp] lemma op_sub [has_sub \u03b1] (x y : \u03b1) : op (x - y) = op x - op y := rfl\n@[simp] lemma unop_sub [has_sub \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x - y) = unop x - unop y := rfl\n\n@[simp, to_additive] lemma op_smul {R : Type*} [has_smul R \u03b1] (c : R) (a : \u03b1) :\n  op (c \u2022 a) = c \u2022 op a := rfl\n\n@[simp, to_additive] lemma unop_smul {R : Type*} [has_smul R \u03b1] (c : R) (a : \u03b1\u1d50\u1d52\u1d56) :\n  unop (c \u2022 a) = c \u2022 unop a := rfl\n\nend\n\nvariable {\u03b1}\n\n@[simp] lemma unop_eq_zero_iff [has_zero \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop = (0 : \u03b1) \u2194 a = (0 : \u03b1\u1d50\u1d52\u1d56) :=\nunop_injective.eq_iff' rfl\n\n@[simp] lemma op_eq_zero_iff [has_zero \u03b1] (a : \u03b1) : op a = (0 : \u03b1\u1d50\u1d52\u1d56) \u2194 a = (0 : \u03b1) :=\nop_injective.eq_iff' rfl\n\nlemma unop_ne_zero_iff [has_zero \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop \u2260 (0 : \u03b1) \u2194 a \u2260 (0 : \u03b1\u1d50\u1d52\u1d56) :=\nnot_congr $ unop_eq_zero_iff a\n\nlemma op_ne_zero_iff [has_zero \u03b1] (a : \u03b1) : op a \u2260 (0 : \u03b1\u1d50\u1d52\u1d56) \u2194 a \u2260 (0 : \u03b1) :=\nnot_congr $ op_eq_zero_iff a\n\n@[simp, to_additive] lemma unop_eq_one_iff [has_one \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop = 1 \u2194 a = 1 :=\nunop_injective.eq_iff' rfl\n\n@[simp, to_additive] lemma op_eq_one_iff [has_one \u03b1] (a : \u03b1) : op a = 1 \u2194 a = 1 :=\nop_injective.eq_iff' rfl\n\nend mul_opposite\n\nnamespace add_opposite\n\ninstance [has_one \u03b1] : has_one \u03b1\u1d43\u1d52\u1d56 := { one := op 1 }\n\n@[simp] lemma op_one [has_one \u03b1] : op (1 : \u03b1) = 1 := rfl\n@[simp] lemma unop_one [has_one \u03b1] : unop 1 = (1 : \u03b1) := rfl\n\n@[simp] lemma op_eq_one_iff [has_one \u03b1] {a : \u03b1} : op a = 1 \u2194 a = 1 := op_injective.eq_iff' op_one\n\n@[simp] lemma unop_eq_one_iff [has_one \u03b1] {a : \u03b1\u1d43\u1d52\u1d56} : unop a = 1 \u2194 a = 1 :=\nunop_injective.eq_iff' unop_one\n\ninstance [has_mul \u03b1] : has_mul \u03b1\u1d43\u1d52\u1d56 := { mul := \u03bb a b, op (unop a * unop b) }\n\n@[simp] lemma op_mul [has_mul \u03b1] (a b : \u03b1) : op (a * b) = op a * op b := rfl\n@[simp] lemma unop_mul [has_mul \u03b1] (a b : \u03b1\u1d43\u1d52\u1d56) : unop (a * b) = unop a * unop b := rfl\n\ninstance [has_inv \u03b1] : has_inv \u03b1\u1d43\u1d52\u1d56 := { inv := \u03bb a, op (unop a)\u207b\u00b9 }\n\ninstance [has_involutive_inv \u03b1] : has_involutive_inv \u03b1\u1d43\u1d52\u1d56 :=\n{ inv_inv := \u03bb a, unop_injective $ inv_inv _,\n  ..add_opposite.has_inv }\n\n@[simp] lemma op_inv [has_inv \u03b1] (a : \u03b1) : op a\u207b\u00b9 = (op a)\u207b\u00b9 := rfl\n@[simp] lemma unop_inv [has_inv \u03b1] (a : \u03b1\u1d43\u1d52\u1d56) : unop a\u207b\u00b9 = (unop a)\u207b\u00b9 := rfl\n\ninstance [has_div \u03b1] : has_div \u03b1\u1d43\u1d52\u1d56 := { div := \u03bb a b, op (unop a / unop b) }\n\n@[simp] lemma op_div [has_div \u03b1] (a b : \u03b1) : op (a / b) = op a / op b := rfl\n@[simp] lemma unop_div [has_div \u03b1] (a b : \u03b1\u1d43\u1d52\u1d56) : 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\u2082\u2086 {a b c : Prop} (h\u2081 : a) (h\u2082 : b) : ad a b c :=\n                    have h\u2083 : ad (ad a b c) b a, from ad\u2082 h\u2082,\n                    show ad a b c, from ad\u2081 h\u2081 h\u2083\n                \n                theorem ad\u2084' {a b c : Prop} (h\u2081 : a) : ad c a (ad c a (ad b a c)) :=\n                    have h\u2082 : ad a a a, from ad\u2082\u2086 h\u2081 h\u2081,\n                    have h\u2083 : ad (ad c a (ad c a (ad b a c))) a a, from ad\u2084 h\u2082,\n                    show ad c a (ad c a (ad b a c)), from ad\u2081 h\u2081 h\u2083\n\n                theorem ad\u2082\u2087 {a b c d e : Prop} (h\u2081 : ad (ad a b c) d e) : ad (ad a d e) b c :=\n                    have h\u2082 : (ad a d e) or (ad a b c), from ad\u2081\u2080 h\u2081,\n                    have h\u2083 : (ad a b c) or (ad a d e), from ad\u2081\u2083 h\u2082,\n                    show ad (ad a d e) b c, from ad\u2081\u2081 h\u2083\n            \n                theorem ad\u2086' {a b : Prop} (h\u2081 : a) : a or b := \n                    ad\u2086 h\u2081\n                \n                theorem ad\u2081_ad {a b c d e : Prop} (h\u2081 : ad c d e) (h\u2082 : ad (ad a b c) d e) :\n                    ad a d e := \n                    have h\u2083 : (ad (ad a b c) d e) \u2192 ((ad a d e) or (ad a b c)), from ad\u2081\u2080,\n                    have h\u2084 : ad a d e \u2192 ad a d e, from R,\n                    have h\u2085 : ad c d e \u2192 ad a b c \u2192 ad a d e, from ad\u2089,\n                    have h\u2086 : ad c d e \u2192 ad a d e \u2192 ad a d e, from M\u2081 h\u2084,\n                    have h\u2087 : ad c d e \u2192 ((ad a d e) or (ad a b c)) \u2192 ad a d e, from \u03b4_or\u2082 h\u2086 h\u2085,\n                    have h\u2088 : ad c d e \u2192 (ad (ad a b c) d e) \u2192 ((ad a d e) or (ad a b c)), from M\u2081 h\u2083,\n                    show ad a d e, from (T\u2082 h\u2088 h\u2087) h\u2081 h\u2082\n\n                theorem ad\u2082_ad {a b c d e : Prop} (h\u2081 : 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\u2082 : (ad a d e) \u2192 (((ad c a c) or b') or ((ad c d e) or b')),\n                            from (assume h, ad\u2082\u2080 $ ad\u2081\u2083 $ ad\u2082\u2080 $ ad\u2081\u2080 $ ad\u2088 $ ad\u2081\u2083 $ ad\u2086' h),\n                        have h\u2083 : ((ad c a c) or b') \u2192 ((ad b' d e) or (ad b' a c)),\n                            from (assume h, ad\u2081\u2083 $ ad\u2086' $ ad\u2081\u2081 h),\n                        have h\u2084 : ((ad c d e) or b') \u2192 ((ad b' d e) or (ad b' a c)), \n                            from (assume h, ad\u2086' $ ad\u2081\u2081 h),\n                        have h\u2085 : (((ad c a c) or b') or ((ad c d e) or b')) \u2192 ((ad b' d e) or (ad b' a c)), \n                            from \u03b4_or\u2081 h\u2083 h\u2084,\n                        have h\u2086 : ad a d e \u2192 ((ad b' d e) or (ad b' a c)), \n                            from T\u2081 h\u2082 h\u2085,\n                        show ad (ad b' a c) d e, \n                            from ad\u2081\u2081 (h\u2086 h\u2081)\n\n                theorem ad\u2083_ad {a b c d e f g h : Prop} (h\u2081 : 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\u2082 : (ad (ad a b c) g h) \u2192 ((ad a g h) or (ad a b c)), \n                            from ad\u2081\u2080,\n                        have h\u2083 : ad a g h \u2192 ad (ad i b c) g h,\n                            from (assume h\u2083\u2081, ad\u2081\u2081 $ ad\u2086' $ ad\u2083 h\u2083\u2081),\n                        have h\u2084 : ad a b c \u2192 ad (ad i b c) g h,\n                            from (assume h\u2084\u2081, ad\u2086 $ ad\u2083 h\u2084\u2081),\n                        have h\u2085 : ((ad a g h) or (ad a b c)) \u2192 ad (ad i b c) g h,\n                            from (\u03b4_or\u2081 h\u2083 h\u2084),\n                        (T\u2081 h\u2082 h\u2085) h\u2081\n\n                theorem ad\u2084_ad {a b c d e f g : Prop} (h\u2081 : 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\u2082 : (ad (ad a b c) f g) \u2192 ((ad a f g) or (ad a b c)), \n                            from ad\u2081\u2080,\n                        have h\u2083 : ad a f g \u2192 ad (ad h b c) f g,\n                            from (assume h\u2083\u2081, ad\u2081\u2081 $ ad\u2086' $ ad\u2084 h\u2083\u2081),\n                        have h\u2084 : ad a b c \u2192 ad (ad h b c) f g,\n                            from (assume h\u2084\u2081, ad\u2086 $ ad\u2084 h\u2084\u2081),\n                        have h\u2085 : ((ad a f g) or (ad a b c)) \u2192 ad (ad h b c) f g,\n                            from \u03b4_or\u2081 h\u2083 h\u2084,\n                        (T\u2081 h\u2082 h\u2085) h\u2081\n\n                theorem ad\u2085_ad {a b c d e : Prop} (h\u2081 : ad (ad a b c) d e) : ad (b or a) d e :=\n                    have h\u2082 : ad (ad a b c) d e \u2192 ((ad a d e) or (ad a b c)), \n                        from ad\u2081\u2080,\n                    have h\u2083 : (ad a d e) \u2192 (ad (b or a) d e), \n                        from (assume h, ad\u2088 $ ad\u2081\u2083 $ ad\u2086' h),\n                    have h\u2084 : (ad a b c) \u2192 (ad (b or a) d e), \n                        from (assume h, ad\u2086 $ ad\u2085 h),\n                    have h\u2085 : ((ad a d e) or (ad a b c)) \u2192 (ad (b or a) d e), \n                        from \u03b4_or\u2081 h\u2083 h\u2084,\n                    (T\u2081 h\u2082 h\u2085) h\u2081\n\n                theorem ad\u2086_ad {a b c d e : Prop} (h\u2081 : ad a d e) : ad (ad a b c) d e := \n                    ad\u2081\u2081 $ ad\u2086' h\u2081\n\n                theorem ad\u2087_ad {a b c d e f : Prop} (h\u2081 : 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\u2082 : ad (ad (c or d) a b) e f \u2192 ((ad (c or d) e f) or (ad (c or d) a b)), \n                        from ad\u2081\u2080,\n                    have h\u2083 : ad (c or d) e f \u2192 ((ad c e f) or (ad d e f)),\n                        from ad\u2087,\n                    have h\u2084 : ad c e f \u2192 ad ((ad c a b) or (ad d a b)) e f,\n                        from (assume h, ad\u2088 $ ad\u2086' $ ad\u2081\u2081 $ ad\u2086' h),\n                    have h\u2085 : ad d e f \u2192 ad ((ad c a b) or (ad d a b)) e f,\n                        from (assume h, ad\u2088 $ ad\u2081\u2083 $ ad\u2086' $ ad\u2081\u2081 $ ad\u2086' h),\n                    have h\u2086 : ((ad c e f) or (ad d e f)) \u2192 ad ((ad c a b) or (ad d a b)) e f,\n                        from \u03b4_or\u2081 h\u2084 h\u2085,\n                    have h\u2087 : ad (c or d) e f \u2192 ad ((ad c a b) or (ad d a b)) e f,\n                        from T\u2081 h\u2083 h\u2086,\n                    have h\u2088 : ad (c or d) a b \u2192 ad ((ad c a b) or (ad d a b)) e f,\n                        from (assume h, ad\u2086 $ ad\u2087 h),\n                    have h\u2089 : ((ad (c or d) e f) or (ad (c or d) a b)) \u2192 ad ((ad c a b) or (ad d a b)) e f,\n                        from \u03b4_or\u2081 h\u2087 h\u2088,\n                    (T\u2081 h\u2082 h\u2089) h\u2081\n                        \n                theorem ad\u2081\u2082_ad {a b c: Prop} (h\u2081 : ad (a or a) b c) : ad a b c := \n                    ad\u2081\u2082 $ ad\u2087 h\u2081\n\n                theorem ad\u2081\u2083_ad {a b c d : Prop} (h\u2081 : ad (a or b) c d) : ad (b or a) c d :=\n                    ad\u2088 $ ad\u2081\u2083 $ ad\u2087 h\u2081\n\n                theorem ad\u2081\u2084_ad {a b c d e : Prop} (h\u2081 : ad (a or (b or c)) d e) : ad ((a or b) or c) d e :=\n                    ad\u2088 $ ad\u2081\u2083 $ ad\u2082\u2082 $ ad\u2081\u2083 $ ad\u2081\u2084 $ ad\u2082\u2081 $ ad\u2087 h\u2081\n \n                theorem ad\u2088' {a b c d e f : Prop} (h\u2081 : ad (ad c a b) e f) : ad (ad (c or d) a b) e f := \n                    have h\u2082 : (ad (ad c a b) e f) \u2192 ((ad c e f) or (ad c a b)), from ad\u2081\u2080,\n                    have h\u2083 : (ad c e f) \u2192 (ad (ad (c or d) a b) e f), from (assume h, ad\u2082\u2087 $ ad\u2086 $ ad\u2086_ad h),\n                    have h\u2084 : (ad c a b) \u2192 (ad (ad (c or d) a b) e f), from (assume h, ad\u2086 $ ad\u2086_ad h),\n                    have h\u2085 : ((ad c e f) or (ad c a b)) \u2192 (ad (ad (c or d) a b) e f), from \u03b4_or\u2081 h\u2083 h\u2084,\n                    show ad (ad (c or d) a b) e f, from (T\u2081 h\u2082 h\u2085) h\u2081               \n\n                theorem ad\u2088'' {a b c d e f : Prop} (h\u2081 : ad (ad (c or d) a b) e f) : ad (ad (d or c) a b) e f :=\n                    have h\u2083\u2081 : (ad (ad (c or d) a b) e f) \u2192 ((ad (c or d) e f) or (ad (c or d) a b)),\n                        from ad\u2081\u2080,\n                    have h\u2083\u2082 : ad (c or d) e f \u2192 ad (ad (d or c) a b) e f,\n                        from (assume h, ad\u2082\u2087 $ ad\u2086 $ ad\u2081\u2083_ad h),\n                    have h\u2083\u2083 : ad (c or d) a b \u2192 ad (ad (d or c) a b) e f,\n                        from (assume h, ad\u2086 $ ad\u2081\u2083_ad h),\n                    have h\u2083\u2084 : ((ad (c or d) e f) or (ad (c or d) a b)) \u2192 ad (ad (d or c) a b) e f,\n                        from \u03b4_or\u2081 h\u2083\u2082 h\u2083\u2083,\n                    (T\u2081 h\u2083\u2081 h\u2083\u2084) h\u2081\n                \n                theorem ad\u2088_ad {a b c d e f : Prop} (h\u2081 : 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\u2082 : ad ((ad c a b) or (ad d a b)) e f \u2192 ((ad (ad c a b) e f) or (ad (ad d a b) e f)),\n                        from ad\u2087,\n                    have h\u2083 : ad (ad c a b) e f \u2192 ad (ad (c or d) a b) e f, \n                        from ad\u2088',\n                    have h\u2084 : ad (ad d a b) e f \u2192 ad (ad (c or d) a b) e f, \n                        from (assume h, ad\u2088'' $ ad\u2088' h),\n                    have h\u2085 : ((ad (ad c a b) e f) or (ad (ad d a b) e f)) \u2192 ad (ad (c or d) a b) e f,\n                        from \u03b4_or\u2081 h\u2083 h\u2084,\n                    (T\u2081 h\u2082 h\u2085) h\u2081\n\n                theorem ad\u2089_ad {a b c d e f g : Prop} (h\u2081 : ad (ad a b c) f g) (h\u2082 : 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\u2083 : ad (ad a b c) f g \u2192 ((ad a f g) or (ad a b c)), \n                            from ad\u2081\u2080,\n                        have h\u2084 : ad (ad d e a) f g \u2192 (g' or (ad d e a)), \n                            from ad\u2081\u2080,\n                        have h\u2085 : ad a b c \u2192 ad d f g \u2192 (g' or c'), \n                            from M\u2081 ad\u2086',\n                        have h\u2086 : ad a b c \u2192 ad d e a \u2192 (g' or c'), \n                            from (assume h, assume i, ad\u2081\u2083 $ ad\u2086' $ ad\u2089 h i),\n                        have h\u2087 : ad a f g \u2192 ad d f g \u2192 (g' or c'), \n                            from M\u2081 ad\u2086',\n                        have h\u2088 : ad a f g \u2192 ad d e a \u2192 (g' or c'), \n                            from (assume h, assume i, ad\u2086' $ ad\u2089 h i),\n                        have h\u2089 : (g' or (ad d e a)) \u2192 ad a b c \u2192 (g' or c'),\n                            from flip (\u03b4_or\u2082 h\u2085 h\u2086),\n                        have h\u2081\u2080 : (g' or (ad d e a)) \u2192 ad a f g  \u2192 (g' or c'),\n                            from flip (\u03b4_or\u2082 h\u2087 h\u2088),\n                        have h\u2081\u2081 : (g' or (ad d e a)) \u2192 ((ad a f g) or (ad a b c)) \u2192 (g' or c'),\n                            from \u03b4_or\u2082 h\u2081\u2080 h\u2089,\n                        have h\u2081\u2082 : (ad (ad a b c) f g) \u2192 (g' or (ad d e a)) \u2192 (g' or c'),\n                            from flip (T\u2082 (M\u2081 h\u2083) h\u2081\u2081),\n                        have h\u2081\u2083 : (ad (ad a b c) f g) \u2192 (ad (ad d e a) f g) \u2192 (g' or c'),\n                            from T\u2082 (M\u2081 h\u2084) h\u2081\u2082,\n                        ad\u2081\u2081 (h\u2081\u2083 h\u2081 h\u2082)\n\n                theorem ad\u2081\u2080_ad {a b c d e f g : Prop} (h\u2081 : 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\u2082 : ad (ad (ad e d c) a b) f g \u2192 ((ad (ad e d c) f g) or (ad (ad e d c) a b)), \n                        from ad\u2081\u2080,\n                    have h\u2083 : ad (ad e d c) f g \u2192 ad ((ad e a b) or (ad e d c)) f g,\n                        from (assume h, ad\u2088 $ ad\u2081\u2083 $ ad\u2086' h),\n                    have h\u2084 : ad (ad e d c) a b \u2192 ad ((ad e a b) or (ad e d c)) f g,\n                        from (assume h, ad\u2086 $ ad\u2081\u2080 h),\n                    have h\u2085 : ((ad (ad e d c) f g) or (ad (ad e d c) a b)) \u2192 ad ((ad e a b) or (ad e d c)) f g,\n                        from \u03b4_or\u2081 h\u2083 h\u2084,\n                    (T\u2081 h\u2082 h\u2085) h\u2081\n\n                theorem ad\u2081\u2081_ad {a b c d e f g : Prop} (h\u2081 : 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\u2082 : ad ((ad e a b) or (ad e d c)) f g \u2192 ((ad (ad e a b) f g) or (ad (ad e d c) f g)),\n                        from ad\u2087, \n                    have h\u2083 : ad (ad e a b) f g \u2192 ((ad e f g) or (ad e a b)),\n                        from ad\u2081\u2080,\n                    have h\u2084 : ad e f g \u2192 ((ad e f g) or (ad e d c)), \n                        from ad\u2086',\n                    have h\u2085 : ((ad e f g) or (ad e d c)) \u2192 ad (ad (ad e d c) a b) f g,\n                        from (assume h, ad\u2081\u2081 $ ad\u2081\u2083 $ ad\u2081\u2080 $ ad\u2086 $ ad\u2081\u2081 h),\n                    have h\u2086 : ad e f g \u2192 ad (ad (ad e d c) a b) f g,\n                        from T\u2081 h\u2084 h\u2085,\n                    have h\u2087 : ((ad e a b) or (ad e d c)) \u2192 ad (ad (ad e d c) a b) f g,\n                        from (assume h, ad\u2086 $ ad\u2081\u2081 h),\n                    have h\u2088 : ad e a b \u2192 ((ad e a b) or (ad e d c)), \n                        from ad\u2086',\n                    have h\u2089 : ad e a b \u2192 ad (ad (ad e d c) a b) f g,\n                        from T\u2081 h\u2088 h\u2087,\n                    have h\u2081\u2080 : ((ad e f g) or (ad e a b)) \u2192 ad (ad (ad e d c) a b) f g,\n                        from \u03b4_or\u2081 h\u2086 h\u2089,\n                    have h\u2081\u2081 : ad (ad e a b) f g \u2192 ad (ad (ad e d c) a b) f g,\n                        from T\u2081 h\u2083 h\u2081\u2080,\n                    have h\u2081\u2082 : ad (ad e d c) f g \u2192 ad (ad (ad e d c) a b) f g,\n                        from (assume h, ad\u2082\u2087 $ ad\u2086 $ ad\u2081\u2081 $ ad\u2081\u2080 h),\n                    have h\u2081\u2083 : ((ad (ad e a b) f g) or (ad (ad e d c) f g)) \u2192 ad (ad (ad e d c) a b) f g,\n                        from \u03b4_or\u2081 h\u2081\u2081 h\u2081\u2082,\n                    (T\u2081 h\u2082 h\u2081\u2083) h\u2081\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\u2019s 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 : \u2115}\n\n/-- u_stmt and u_wit are fin-indexed collections of polynomials from the square span program -/\nparameter {u_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {u_wit : fin n_wit \u2192 (polynomial F) }\nparameter {v_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {v_wit : fin n_wit \u2192 (polynomial F) }\nparameter {w_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {w_wit : fin n_wit \u2192 (polynomial F) }\n\n\n\n-- We choose the following exponents\n-- def \u03b1 : \u2115 := 6 \n-- def \u03b2 : \u2115 := 7\n-- def \u03b3 : \u2115 := 0\n-- def \u03b4 : \u2115 := 10\n-- def \u03b7 : \u2115 := 5\n\ndef \u03b1 : \u2115 := 26 \ndef \u03b2 : \u2115 := 27\ndef \u03b3 : \u2115 := 0\ndef \u03b4 : \u2115 := 40\ndef \u03b7 : \u2115 := 24\n\n\n/-- The roots of the polynomial t -/\nparameter {r : fin n_wit \u2192 F} \n/-- l is the polynomial divisibility by which is used to verify satisfaction of the QAP -/\ndef l : polynomial F := \u220f 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 \u2192 F ) (a_wit : fin n_wit \u2192 F) := \n((\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 u_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 u_wit i))\n  * \n(\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 v_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 v_wit i))\n  -\n(\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 w_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 w_wit i)))\n   %\u2098 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) ^ (\u03b2 - \u03b1 + \u03b4) * C (u_wit i) \n + (X vars.y) ^ (\u03b2 - \u03b1 + \u03b3) * C (v_wit i) \n + (X vars.y) ^ (2 * \u03b2 - \u03b1) * C (w_wit i) \n@[crs]\ndef crs'_P_\u03b1_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b1\n@[crs]\ndef crs'_P_powers_1 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b2 * C (polynomial.X ^ (i : \u2115)) \n@[crs]\ndef crs'_P_l_1 (i : fin (n_var - 1)) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ (2 * \u03b2 - \u03b1) * C l * C (polynomial.X ^ (i : \u2115)) \n-- @[crs]\n-- def crs'_P_\u03b3_1 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ \u03b3\n@[crs]\ndef crs'_P_\u03b4_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b4\n@[crs]\ndef crs'_P_se_\u03b1_z_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b1 * (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) ^ \u03b2 * (X vars.z) * C (polynomial.X ^ (i : \u2115))  -- Only in S_qap^se\n-- @[crs]\n-- def crs'_P_\u03b1_2 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ \u03b1\n@[crs]\ndef crs'_P_powers_2 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b2 * C (polynomial.X ^ (i : \u2115)) -- 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) ^ (\u03b2 - \u03b7 + \u03b4) * C (u_stmt i) \n + (X vars.y) ^ (\u03b2 - \u03b7 + \u03b3) * C (v_stmt i) \n + (X vars.y) ^ (2 * \u03b2 - \u03b7) * C (w_stmt i) \n-- @[crs]\n-- def crs'_V_\u03b3_1 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ \u03b3 -- Same as crs'_P_\u03b3_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_\u03b1_2 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ \u03b1\n@[crs]\ndef crs'_V_\u03b4_2 : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ \u03b4\n@[crs]\ndef crs'_V_\u03b7_2 : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ \u03b7\n@[crs]\ndef crs'_V_\u03b3_\u03b4_T : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ (\u03b3 + \u03b4)\n\n-- Elements both prover and verifier use\n\n@[crs]\ndef crs'_\u03b3_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b3\n@[crs]\ndef crs'_\u03b1_2 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b1\n\n\nparameters {A_comp_crs'_P_all_wit_1 : fin n_wit \u2192 F}\nparameters {A_comp_crs'_P_\u03b1_1 : F}\nparameters {A_comp_crs'_P_powers_1 : fin n_var \u2192 F}\nparameters {A_comp_crs'_P_l_1 : fin (n_var - 1) \u2192 F}\nparameters {A_comp_crs'_\u03b3_1 : F}\nparameters {A_comp_crs'_P_\u03b4_1 : F}\n-- parameters {A_comp_crs'_P_se_\u03b1_z_1 : F}\n-- parameters {A_comp_crs'_P_se_powers_1 : fin n_var \u2192 F}\nparameters {A_comp_crs'_V_all_stmt_1 : fin n_stmt \u2192 F}\n-- parameters {A_comp_crs'_V_\u03b3_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  \u2211 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_\u03b1_1 * C (polynomial.C (A_comp_crs'_P_\u03b1_1))\n  +\n  \u2211 i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (A_comp_crs'_P_powers_1 i))\n  +\n  \u2211 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'_\u03b3_1 * C (polynomial.C (A_comp_crs'_\u03b3_1))\n  +\n  crs'_P_\u03b4_1 * C (polynomial.C (A_comp_crs'_P_\u03b4_1))\n  +\n  \u2211 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'_\u03b1_2 : F}\nparameters {B_comp_crs'_P_powers_2 : fin n_var \u2192 F}\n-- parameters {B_comp_crs'_V_\u03b1_2 : F} -- Same as previous\nparameters {B_comp_crs'_V_\u03b4_2 : F}\nparameters {B_comp_crs'_V_\u03b7_2 : F}\n\n/-- Polynomial form of B in the adversary's proof representation -/\ndef B' : mv_polynomial vars (polynomial F) := \n  crs'_\u03b1_2 * C (polynomial.C (B_comp_crs'_\u03b1_2))\n  +\n  \u2211 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_\u03b4_2 * C (polynomial.C (B_comp_crs'_V_\u03b4_2))\n  +\n  crs'_V_\u03b7_2 * C (polynomial.C (B_comp_crs'_V_\u03b7_2))\n\n\nparameters {C_comp_crs'_P_all_wit_1 : fin n_wit \u2192 F}\nparameters {C_comp_crs'_P_\u03b1_1 : F}\nparameters {C_comp_crs'_P_powers_1 : fin n_var \u2192 F}\nparameters {C_comp_crs'_P_l_1 : fin (n_var - 1) \u2192 F}\nparameters {C_comp_crs'_P_\u03b3_1 : F}\nparameters {C_comp_crs'_P_\u03b4_1 : F}\n-- parameters {C_comp_crs'_P_se_\u03b1_z_1 : F}\n-- parameters {C_comp_crs'_P_se_powers_1 : fin n_var \u2192 F}\nparameters {C_comp_crs'_V_all_stmt_1 : fin n_stmt \u2192 F}\n-- parameters {C_comp_crs'_V_\u03b3_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  \u2211 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_\u03b1_1 * C (polynomial.C (C_comp_crs'_P_\u03b1_1))\n  +\n  \u2211 i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (C_comp_crs'_P_powers_1 i))\n  +\n  \u2211 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'_\u03b3_1 * C (polynomial.C (C_comp_crs'_P_\u03b3_1))\n  +\n  crs'_P_\u03b4_1 * C (polynomial.C (C_comp_crs'_P_\u03b4_1))\n  +\n  \u2211 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 \u2192 F ) : Prop :=\n  (\u2211 i in finset.fin_range n_stmt, C (polynomial.C (a_stmt i)) * crs'_V_all_stmt_1 i ) * crs'_V_\u03b7_2 \n  +\n  C' * crs'_\u03b1_2 \n  =\n  (A' + crs'_\u03b3_1) * (B' + crs'_V_\u03b4_2) - crs'_V_\u03b3_\u03b4_T \n\n-- A, modified to be more like what we see in Baghery et al. - this includes athe extra y^\u03b3 we see \n-- that the verifier adds.\n\ndef A_mod_comp_crs_P_\u03b3_1 := A_comp_crs'_\u03b3_1 + 1\n\nlemma A_mod_transform : \n  A' + crs'_\u03b3_1 =\n   \u2211 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_\u03b1_1 * C (polynomial.C (A_comp_crs'_P_\u03b1_1))\n  +\n  \u2211 i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (A_comp_crs'_P_powers_1 i))\n  +\n  \u2211 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'_\u03b3_1 * C (polynomial.C (A_mod_comp_crs_P_\u03b3_1))\n  +\n  crs'_P_\u03b4_1 * C (polynomial.C (A_comp_crs'_P_\u03b4_1))\n  +\n  \u2211 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_\u03b3_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^\u03b3 we see \n-- that the verifier adds. \n\ndef B_mod_comp_crs_V_\u03b4_2 := B_comp_crs'_V_\u03b4_2 + 1\n\nlemma B_mod_transform : \n  B' + crs'_V_\u03b4_2 =\n  crs'_\u03b1_2 * C (polynomial.C (B_comp_crs'_\u03b1_2))\n  +\n  \u2211 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_\u03b4_2 * C (polynomial.C (B_mod_comp_crs_V_\u03b4_2))\n  +\n  crs'_V_\u03b7_2 * C (polynomial.C (B_comp_crs'_V_\u03b7_2)) :=\nbegin\n  rw [B', B_mod_comp_crs_V_\u03b4_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 \u2194 a = 1 :=\ncalc polynomial.C a = 1 \u2194 polynomial.C a = polynomial.C 1 : by rw polynomial.C_1\n         ... \u2194 a = 1 : polynomial.C_inj\n\n\nlemma simplifier1 (x : fin n_stmt) (a_stmt : fin n_stmt \u2192 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 \u2192 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) %\u2098 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_\u03b3_1_mul (p : polynomial F) : p * polynomial.C A_mod_comp_crs_P_\u03b3_1  = polynomial.C A_mod_comp_crs_P_\u03b3_1 * p := by ring\n\nlemma B_mod_comp_crs_V_\u03b4_2_mul (p : polynomial F) : p * polynomial.C B_mod_comp_crs_V_\u03b4_2  = polynomial.C B_mod_comp_crs_V_\u03b4_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 \u2192 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    (\u2211 (i : fin n_stmt) in finset.fin_range n_stmt, u_stmt i * polynomial.C (a_stmt i) + \u2211 (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    (\u2211 (i : fin n_stmt) in finset.fin_range n_stmt, v_stmt i * polynomial.C (a_stmt i) + \u2211 (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    (\u2211 (i : fin n_stmt) in finset.fin_range n_stmt, w_stmt i * polynomial.C (a_stmt i) + \u2211 (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    \u2211 (x : fin (n_var - 1)) in finset.fin_range (n_var - 1), l * polynomial.X ^ (x : \u2115) * polynomial.C (C_comp_crs'_P_l_1 x),\n  {\n    rw <-sub_eq_iff_eq_add' at this,\n    have h := congr_arg (%\u2098 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 [\u03b1, \u03b2, \u03b3, \u03b4, \u03b7, 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 \u03b1 : \u2115 := 26 \n-- def \u03b2 : \u2115 := 27\n-- def \u03b3 : \u2115 := 0\n-- def \u03b4 : \u2115 := 40\n-- def \u03b7 : \u2115 := 24\n\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 1 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 1\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 1 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 1\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 - (\u03b2-\u03b7) * 1 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 1\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2\n  -- -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 3\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 1 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 1\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2,\n\n\n  have h0012 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 1 + (\u03b2-\u03b1) * 0))) eqn',\n  have h0021 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 1))) eqn',\n  have h0022 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n  -- have h0022 := congr_arg (coeff (single vars.y (46))) eqn',\n  have h0112 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 1 + (\u03b2-\u03b1) * 0))) eqn',\n  have h0121 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 1))) eqn',\n  have h0122 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n  have h0212 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 + (\u03b2-\u03b7) * 1 + (\u03b2-\u03b1) * 0))) eqn',\n  have h0221 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 1))) eqn',\n  have h0222 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n  have h1022 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n  -- have h1023 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 0 - (\u03b2-\u03b1) * 3))) eqn',\n  have h1112 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 1 + (\u03b2-\u03b1) * 0))) eqn',\n  have h1121 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 1))) eqn',\n  have h1122 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n\n  simp only [\u03b1, \u03b2, \u03b7, \u03b4, \u03b3, 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_\u03b3_1 *\n      \u2211 (x : fin n_var) in finset.fin_range n_var,\n        polynomial.X ^ (x : \u2115) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n      (\u2211 (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_\u03b7_2 +\n    (\u2211 (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'_\u03b1_2 =\n    \u2211 (x : fin n_stmt) in finset.fin_range n_stmt, v_stmt x * polynomial.C (a_stmt x) +\n      \u2211 (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_\u03b4_1 *\n      \u2211 (x : fin n_var) in finset.fin_range n_var,\n        polynomial.X ^ (x : \u2115) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n    (\u2211 (x : fin n_var) in finset.fin_range n_var,\n       polynomial.X ^ (x : \u2115) * polynomial.C (A_comp_crs'_P_powers_1 x)) *\n            polynomial.C B_mod_comp_crs_V_\u03b4_2 +\n    (\u2211 (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_\u03b7_2 +\n    (\u2211 (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'_\u03b1_2  =\n    \u2211 (x : fin n_stmt) in finset.fin_range n_stmt, u_stmt x * polynomial.C (a_stmt x) +\n      \u2211 (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    (\u2211 (x : fin n_var) in finset.fin_range n_var,\n      polynomial.X ^ (x : \u2115) * polynomial.C (A_comp_crs'_P_powers_1 x)) *\n    \u2211 (x : fin n_var) in finset.fin_range n_var,\n      polynomial.X ^ (x : \u2115) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n    (\u2211 (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_\u03b7_2 +\n    polynomial.C B_comp_crs'_\u03b1_2  * \n      ((\u2211 (x : fin n_wit) in finset.fin_range n_wit, w_wit x * polynomial.C (A_comp_crs'_P_all_wit_1 x)) +\n       (\u2211 (x : fin (n_var - 1)) in finset.fin_range (n_var - 1),\n         l * polynomial.X ^ (x : \u2115) * polynomial.C (A_comp_crs'_P_l_1 x)))\n    =\n    \u2211 (x : fin n_stmt) in finset.fin_range n_stmt, w_stmt x * polynomial.C (a_stmt x) +\n        \u2211 (x : fin n_wit) in finset.fin_range n_wit, w_wit x * polynomial.C (C_comp_crs'_P_all_wit_1 x) +\n      \u2211 (x : fin (n_var - 1)) in\n        finset.fin_range (n_var - 1),\n        l * polynomial.X ^ (x : \u2115) * 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\u03b3\u03b7 : (1 + polynomial.C A_comp_crs'_P_\u03b3_1) * polynomial.C B_comp_crs'_V_\u03b7_2 = 0,\n  -- { rw add_mul, rw <-h5, ring, },\n  -- rw mul_eq_zero at h\u03b3\u03b7,\n\n  -- have h\u03b4\u03b4 : polynomial.C A_comp_crs'_P_\u03b4_1 * (1 + polynomial.C B_comp_crs'_V_\u03b4_2) = 0,\n  -- { rw mul_add, rw <-h0222, ring, },\n  -- rw mul_eq_zero at h\u03b4\u03b4,\n\n  -- have h\u03b3\u03b4 : (1 + polynomial.C A_comp_crs'_P_\u03b3_1) * (1 + polynomial.C B_comp_crs'_V_\u03b4_2) = 1,\n  -- { rw <-sub_eq_zero, rw <-h1122, ring, },\n\n  -- have h\u03b2\u03b2 := h14,\n  -- have h\u03b2\u03b3 := h7,\n  -- have h\u03b2\u03b4 := h17,\n  -- have h\u03b3\u03b3 := h0,\n  -- have h\u03b3\u03b4 := 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\u03b2\u03b3,\n  -- rw <-h\u03b2\u03b4,\n  -- rw <-h\u03b2\u03b2,\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_\u03b4_2_mul],\n    simp only [<-mul_assoc],\n    simp only [A_mod_comp_crs_P_\u03b3_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 \u2192 R) \u2039_\u203a\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 \u2192 R) \u2039_\u203a)\n\nvariables [topological_space $ units R]\n\nlemma units_topology_eq [induced_units R] :\n  \u2039topological_space (units R)\u203a = induced (coe : units R \u2192 R) \u2039_\u203a :=\ninduced_units.top_eq\n\nlemma induced_units.continuous_coe [induced_units R] : continuous (coe : units R \u2192 R) :=\n(units_topology_eq R).symm \u25b8 continuous_induced_dom\n\nlemma units_embedding [induced_units R] :\n  embedding (coe : units R \u2192 R) :=\n{ induced := units_topology_eq R,\n  inj := \u03bb x y h, units.ext h }\n\ninstance top_monoid_units [topological_ring R] [induced_units R] :\n  has_continuous_mul (units R) :=\n\u27e8begin\n  let mulR := (\u03bb (p : R \u00d7 R), p.1*p.2),\n  let mulRx := (\u03bb (p : units R \u00d7 units R), p.1*p.2),\n  have key : coe \u2218 mulRx = mulR \u2218 (\u03bb 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, \u2190 induced_compose],\n  apply induced_mono,\n  rw \u2190 continuous_iff_le_induced,\n  exact continuous_mul,\nend\u27e9\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 : \u2200 x : K, x \u2260 0 \u2192 continuous_at (\u03bb x : K, x\u207b\u00b9 : K \u2192 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 := \u27e8rfl\u27e9\n\nvariables [topological_division_ring K]\n\nlemma units_top_group : topological_group (units K) :=\n{ continuous_inv := begin\n     have : (coe : units K \u2192 K) \u2218 (\u03bb x, x\u207b\u00b9 : units K \u2192 units K) =\n            (\u03bb x, x\u207b\u00b9 : K \u2192 K) \u2218 (coe : units K \u2192 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 [\u2190 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 (\u03bb x : units K, (\u2191(x\u207b\u00b9) : 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 `\ud835\udd5c` to itself.\nTechnically it does not require `\ud835\udd5c` to be a topological field, a topological ring that\nhappens to be a field is enough.\n-/\nvariables {\ud835\udd5c : Type*} [field \ud835\udd5c] [topological_space \ud835\udd5c] [topological_ring \ud835\udd5c]\n\n/--\nThe map `\u03bb x, a * x + b`, as a homeomorphism from `\ud835\udd5c` (a topological field) to itself, when `a \u2260 0`.\n-/\n@[simps]\ndef affine_homeomorph (a b : \ud835\udd5c) (h : a \u2260 0) : \ud835\udd5c \u2243\u209c \ud835\udd5c :=\n{ to_fun := \u03bb x, a * x + b,\n  inv_fun := \u03bb y, (y - b) / a,\n  left_inv := \u03bb x, by { simp only [add_sub_cancel], exact mul_div_cancel_left x h, },\n  right_inv := \u03bb 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 (\u03b1 \u03b2 : Type) := (smul : \u03b1 \u2192 \u03b2 \u2192 \u03b2)\ndef smul {\u03b1 \u03b2 : Type} [has_smul \u03b1 \u03b2] : \u03b1 \u2192 \u03b2 \u2192 \u03b2 := has_smul.smul\ninfixl ` \u2b1d ` := smul\n\ndef pextt {P : Prop} : P \u2192 (P = true) := \u03bb Hp, propext (iff_true_intro Hp)\ndef pextf {P : Prop} : \u00ac P \u2192 (P = false) := \u03bb Hnp, propext (iff.intro (\u03bb Hp, Hnp Hp) (\u03bb Hf, false.rec _ Hf))\n\nnamespace nat\n\nlemma bit1_ne_bit0_eq {n m : \u2115} : (bit1 n \u2260 bit0 m) = true := pextt (nat.bit1_ne_bit0 _ _)\nlemma bit0_ne_bit1_eq {n m : \u2115} : (bit0 n \u2260 bit1 m) = true := pextt (nat.bit0_ne_bit1 _ _)\n\nlemma bit0_inj_eq {n m : \u2115} : (bit0 n \u2260 bit0 m) = (n \u2260 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 : \u2115} : (bit1 n \u2260 bit1 m) = (n \u2260 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 : \u2115} : (0 \u2260 bit0 n) = (n \u2260 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 : \u2115} : (bit0 n \u2260 0) = (n \u2260 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 : \u2115} : (1 \u2260 bit1 n) = (n \u2260 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 : \u2115} : (bit1 n \u2260 1) = (n \u2260 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 : \u2115) : (1 \u2260 bit0 n) = true := pextt (nat.one_ne_bit0 _)\nlemma bit0_ne_one_eq (n : \u2115) : (bit0 n \u2260 1) = true := pextt (nat.bit0_ne_one _)\n\nlemma zero_ne_bit1_eq (n : \u2115) : (0 \u2260 bit1 n) = true := pextt (nat.zero_ne_bit1 _)\nlemma bit1_ne_zero_eq (n : \u2115) : (bit1 n \u2260 0) = true := pextt (nat.bit1_ne_zero _)\n\nlemma zero_ne_one_eq : (0 \u2260 1) = true := pextt nat.zero_ne_one\nlemma one_ne_zero_eq : (1 \u2260 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 \u00d7 B \u2192 A \u00d7 B \u2192 Prop\n| \u27e8x\u2081, y\u2081\u27e9 \u27e8x\u2082, y\u2082\u27e9 := if x\u2081 < x\u2082 then true else (if x\u2082 < x\u2081 then false else (y\u2081 < y\u2082))\n\ninstance : has_lt (A \u00d7 B) := \u27e8less_than\u27e9\n\ndef decidable_less_than : \u2200 (p q : A \u00d7 B), decidable (p < q)\n| \u27e8x\u2081, y\u2081\u27e9 \u27e8x\u2082, y\u2082\u27e9 := show decidable (if x\u2081 < x\u2082 then true else (if x\u2082 < x\u2081 then false else (y\u2081 < y\u2082))), by apply_instance\n\ninstance : decidable_rel (@has_lt.lt (A \u00d7 B) _) := decidable_less_than\n\nend lt\nend prod\n\nlemma pair_neq_of_neq\u2081 {X Y : Type} {x\u2081 x\u2082 : X} {y\u2081 y\u2082 : Y} : x\u2081 \u2260 x\u2082 \u2192 (x\u2081, y\u2081) \u2260 (x\u2082, y\u2082) :=\nassume (H : x\u2081 \u2260 x\u2082) (H_contra : (x\u2081, y\u2081) = (x\u2082, y\u2082)),\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 \u2192 list A \u2192 Prop\n| []      (y::ys) := true\n| _       []      := false\n| (x::xs) (y::ys) := x < y \u2228 (x = y \u2227 less_than xs ys)\n\ninstance : has_lt (list A) := \u27e8less_than\u27e9\n\ndef decidable_less_than : \u2200 (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 \u2228 (x = y \u2227 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 \u00d7 Y) \u2192 list X\n| [] := []\n| (xy::xys) := xy.1 :: p1 xys\n\ndef p2 {X Y : Type} : list (X \u00d7 Y) \u2192 list Y\n| [] := []\n| (xy::xys) := xy.2 :: p2 xys\n\nlemma length_p1_same {X Y : Type} : \u2200 (xs : list (X \u00d7 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} : \u2200 (xs : list (X \u00d7 Y)), length xs^.p2 = length xs\n| []      := rfl\n| (x::xs) := begin dsimp [length, p2], rw length_p2_same end\n\ndef sumr {\u03b1 : Type} [has_add \u03b1] [has_zero \u03b1] : list \u03b1 \u2192 \u03b1\n| [] := 0\n| (x::xs) := x + sumr xs\n\ndef sumrd {\u03b1 : Type} [has_add \u03b1] (d : \u03b1) : list \u03b1 \u2192 \u03b1\n| [] := d\n| (x::xs) := x + sumrd xs\n\nlemma sumrd_sumr {\u03b1 : Type} [add_comm_group \u03b1] (d : \u03b1) : \u2200 (xs : list \u03b1), 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\u2081 {\u03b1 : Type} [has_add \u03b1] [has_zero \u03b1] : list \u03b1 \u2192 \u03b1\n| [] := 0\n| [x] := x\n| (x::y::xs) := x + sumr\u2081 (y::xs)\n\nlemma sumr_sumr\u2081 {\u03b1 : Type} [add_group \u03b1] : \u2200 (xs : list \u03b1), sumr\u2081 xs = sumr xs\n| [] := rfl\n| [x] := begin dunfold sumr sumr\u2081, rw add_zero, end\n| (x::y::xs) := begin dunfold sumr sumr\u2081, rw sumr_sumr\u2081, reflexivity end\n\ndef prod {\u03b1 : Type*} [has_mul \u03b1] [has_one \u03b1] : list \u03b1 \u2192 \u03b1 :=\nfoldr has_mul.mul 1\n\nlemma append_single {\u03b1 : Type*} (x : \u03b1) (xs : list \u03b1) : [x] ++ xs = x :: xs := rfl\n\nlemma append_nil_left {\u03b1 : Type*} (xs : list \u03b1) : [] ++ xs = xs := rfl\n\nlemma in_filter {\u03b1 : Type*} (P : \u03b1 \u2192 Prop) [decidable_pred P] : \u03a0 (xs : list \u03b1) (x : \u03b1), x \u2208 xs \u2192 P x \u2192 x \u2208 filter P xs\n| []      x H_x_in HPx := H_x_in\n| (y::ys) x H_x_in HPx :=\nhave Hx : x = y \u2228 x \u2208 ys, from iff.mp (mem_cons_iff _ _ _) H_x_in,\nhave Hy : P y \u2228 \u00ac (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 {\u03b1 : Type*} (P : \u03b1 \u2192 Prop) [decidable_pred P] : \u03a0 (xs : list \u03b1) (x : \u03b1), x \u2208 filter P xs \u2192 x \u2208 xs \u2227 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 \u2228 \u00ac (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 : \u2115 \u2192 \u2115 \u2192 list \u2115\n| i 0     := []\n| i (k+1) := i :: miota (i+1) k\n\ndef riota : \u2115 \u2192 list \u2115\n| 0 := []\n| (n+1) := n :: riota n\n\nlemma in_riota_lt : \u2200 {idx n : \u2115}, idx \u2208 riota n \u2192 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 \u2192 Y) (g : Y \u2192 Z) (xs : list X) : map g (map f xs) = map (\u03bb x, g (f x)) xs := by apply map_map\n\nlemma map_congr_fn {X Y : Type} (f g : X \u2192 Y) (xs : list X) : f = g \u2192 map f xs = map g xs := begin intro H, rw H end\nlemma map_congr_fn_pred {X Y : Type} (f g : X \u2192 Y) : \u03a0 (xs : list X) (H : \u2200 x, x \u2208 xs \u2192 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 \u2208 x :: xs, by apply mem_cons_self,\n  have H_rest : \u2200 x, x \u2208 xs \u2192 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 {\u03b1 : Type*} [inhabited \u03b1] : list \u03b1 \u2192 nat \u2192 \u03b1\n| []       n     := default \u03b1\n| (a :: l) 0     := a\n| (a :: l) (n+1) := dnth l n\n\nlemma p1_dnth {\u03b1 \u03b2 : Type*} [inhabited \u03b1] [inhabited \u03b2] : \u2200 (xs : list (\u03b1 \u00d7 \u03b2)) (idx : \u2115), (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 {\u03b1 \u03b2 : Type*} [inhabited \u03b1] [inhabited \u03b2] : \u2200 (xs : list (\u03b1 \u00d7 \u03b2)) (idx : \u2115), (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 : \u2115) (x : X) : Prop :=\n  idx < length xs \u2227 x = dnth xs idx\n\ninductive elem_at_idx {X : Type} : \u03a0 (xs : list X) (idx : \u2115) (x : X), Prop\n| base : \u2200 (xs : list X) (x : X), elem_at_idx (x::xs) 0 x\n| step : \u2200 (xs : list X) (x y : X) (idx : \u2115), elem_at_idx xs idx y \u2192 elem_at_idx (x::xs) (idx+1) y\n\n\nlemma elem_at_idx_of_at_idx {X : Type} [inhabited X] : \u2200 {xs : list X} {idx : \u2115} {x : X},\n  at_idx xs idx x \u2192 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\u2080 H_at_idx := by { dsimp [at_idx, dnth] at H_at_idx, rw H_at_idx^.right, constructor }\n| (x::xs) (idx+1) x\u2080 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 {\u03b1 : Type*} [inhabited \u03b1] {x : \u03b1} {xs : list \u03b1} : 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 {\u03b1 : Type*} [inhabited \u03b1] {x x\u2081 x\u2082 : \u03b1} {xs : list \u03b1} : at_idx (x::xs) 0 x\u2081 \u2192 at_idx (x::xs) 0 x\u2082 \u2192 x\u2081 = x\u2082 :=\nbegin dunfold at_idx, intros H\u2081 H\u2082, rw [H\u2081^.right, H\u2082^.right] end\n\nlemma at_idx_of_cons {\u03b1 : Type*} [inhabited \u03b1] {x : \u03b1} {xs : list \u03b1} {y : \u03b1} {idx : \u2115} :\n  at_idx (x::xs) (idx+1) y \u2192 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 {\u03b1 : Type*} [inhabited \u03b1] {x : \u03b1} {xs : list \u03b1} {y : \u03b1} {idx : \u2115} :\n  at_idx xs idx y \u2192 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 {\u03b1 \u03b2 : Type} [inhabited \u03b1] [inhabited \u03b2] {xs : list (\u03b1 \u00d7 \u03b2)} {x : \u03b1 \u00d7 \u03b2} {idx : \u2115} :\n  at_idx xs idx x \u2192 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 {\u03b1 \u03b2 : Type} [inhabited \u03b1] [inhabited \u03b2] {xs : list (\u03b1 \u00d7 \u03b2)} {x : \u03b1 \u00d7 \u03b2} {idx : \u2115} :\n  at_idx xs idx x \u2192 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 {\u03b1 : Type*} [inhabited \u03b1] {x : \u03b1} {xs : list \u03b1} {idx : \u2115} : at_idx xs idx x \u2192 x \u2208 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 : \u2115} {x : X} : at_idx xs idx x \u2192 \u00ac (idx < length xs) \u2192 false :=\nassume H_at_idx H_idx_big, H_idx_big H_at_idx^.left\n\ninstance decidable_at_idx {\u03b1 : Type*} [decidable_eq \u03b1] [inhabited \u03b1] (xs : list \u03b1) (idx : \u2115) (x : \u03b1) : decidable (at_idx xs idx x) :=\nif H : idx < length xs \u2227 x = dnth xs idx then decidable.is_true H else decidable.is_false H\n\nlemma mem_of_cons_same {\u03b1 : Type*} {x : \u03b1} {xs : list \u03b1} : x \u2208 x::xs := by { apply or.inl, reflexivity }\n\ndefinition all_prop {\u03b1 : Type*} (p : \u03b1 \u2192 Prop) (l : list \u03b1) : Prop :=\nfoldr (\u03bb a r, p a \u2227 r) true l\n\ndef rcons {\u03b1 : Type*} (a : \u03b1) : list \u03b1 \u2192 list \u03b1\n| []        := [a]\n| (x :: xs) := x :: (rcons xs)\n\ndef dnth_all {A : Type} [inhabited A] (idxs : list \u2115) (xs : list A) : list A := map (\u03bb idx, dnth xs idx) idxs\n\nlemma mem_not_mem_neq {X : Type*} {x\u2081 x\u2082 : X} {xs : list X} : x\u2081 \u2208 xs \u2192 x\u2082 \u2209 xs \u2192 x\u2081 \u2260 x\u2082 :=\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\u2081 x\u2082 : X} {xs : list X} : x\u2082 \u2208 xs \u2192 nodup (x\u2081 :: xs) \u2192 x\u2081 \u2260 x\u2082 :=\nassume H_in H_nd,\nhave H_nin : x\u2081 \u2209 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 : \u2115} :\n  nodup (x::xs) \u2192 at_idx (x::xs) (idx+1) y \u2192 y \u2260 x :=\nbegin\nintros H_nd H_at_idx,\nnote H_at_idx' := at_idx_of_cons H_at_idx,\nassert H_in_xs : y \u2208 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} : \u00ac (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 {\u03b1 : Type*} {l\u2081 l\u2082 l : list \u03b1} : l\u2081 <+ l \u2192 disjoint l l\u2082 \u2192 disjoint l\u2081 l\u2082 :=\n\u03bb ss d x xinl\u2081, d (subset_of_sublist ss xinl\u2081)\n\nlemma disjoint_of_sublist_right {\u03b1 : Type*} {l\u2081 l\u2082 l : list \u03b1} : l\u2082 <+ l \u2192 disjoint l\u2081 l \u2192 disjoint l\u2081 l\u2082 :=\n\u03bb ss d x xinl xinl\u2081, d xinl (subset_of_sublist ss xinl\u2081)\n\nlemma nodup_append_sublist\u2081 {X : Type*} {ys zs : list X} (xs : list X) : nodup (ys ++ zs) \u2192 xs <+ ys \u2192 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\u2081 xs\u2082 : list X} {x : X} : nodup (xs\u2081 ++ (x :: xs\u2082)) \u2192 nodup ((x::xs\u2081) ++ xs\u2082) :=\nby apply list.nodup_head\n\nlemma nodup_mem_append\u2082 {X : Type} {x : X} {xs\u2081 xs\u2082 : list X} : nodup (xs\u2081 ++ xs\u2082) \u2192 x \u2208 xs\u2082 \u2192 x \u2209 xs\u2081 :=\nassume (H_nd : nodup (xs\u2081 ++ xs\u2082)) (H\u2082 : x \u2208 xs\u2082) (H\u2081 : x \u2208 xs\u2081),\nhave H_dj : disjoint xs\u2081 xs\u2082, from disjoint_of_nodup_append H_nd,\nH_dj H\u2081 H\u2082\n\nlemma nodup_append_cons {X : Type} {xs\u2081 xs\u2082 : list X} {x : X} : nodup (xs\u2081 ++ (x :: xs\u2082)) \u2192 nodup (xs\u2081 ++ [x]) :=\nassume H_nd,\nhave H_nd\u2081 : nodup xs\u2081, from nodup_of_nodup_append_left H_nd,\nhave H_dj : disjoint xs\u2081 (x :: xs\u2082), from disjoint_of_nodup_append H_nd,\nhave H_nin : x \u2209 xs\u2081, from disjoint_right H_dj mem_of_cons_same,\nbegin apply nodup_app_comm, simp, apply nodup_cons H_nin H_nd\u2081 end\n\nlemma nodup_append_cons_rest {X : Type} {xs\u2081 xs\u2082 : list X} {x : X} : nodup (xs\u2081 ++ (x :: xs\u2082)) \u2192 nodup (xs\u2081 ++ xs\u2082) :=\nassume H_nd, nodup_of_nodup_cons (nodup_head H_nd)\n\nlemma nodup_append_neq {X : Type} {xs\u2081 xs\u2082 : list X} {x\u2081 x\u2082 : X} : x\u2081 \u2208 xs\u2081 \u2192 x\u2082 \u2208 xs\u2082 \u2192 nodup (xs\u2081 ++ xs\u2082) \u2192 x\u2081 \u2260 x\u2082 :=\nassume H\u2081_in H\u2082_in H_nd,\nhave H_dj : disjoint xs\u2081 xs\u2082, from disjoint_of_nodup_append H_nd,\nhave H\u2081_nin : x\u2081 \u2209 xs\u2082, from disjoint_left H_dj H\u2081_in,\nne.symm $ mem_not_mem_neq H\u2082_in H\u2081_nin\n\nlemma nodup_append_cons_neq {X : Type} {xs : list X} {x\u2081 x\u2082 : X} : x\u2081 \u2208 xs \u2192 nodup (xs ++ [x\u2082]) \u2192 x\u2081 \u2260 x\u2082 :=\nassume H\u2081_in H_nd,\nhave H_nd' : nodup (x\u2082 :: xs), from nodup_app_comm H_nd,\nhave H\u2082_nin : x\u2082 \u2209 xs, from not_mem_of_nodup_cons H_nd',\nmem_not_mem_neq H\u2081_in H\u2082_nin\n\nlemma nodup_of_append_cons_cons {X : Type} {xs ys : list X} {y\u2081 y\u2082 : X} : nodup (xs ++ (y\u2081 :: y\u2082 :: ys)) \u2192 nodup (xs ++ (y\u2081 :: ys)) :=\nassume H_nd,\nhave H_nd' : nodup (y\u2081 :: (xs ++ y\u2082 :: ys)), from nodup_head H_nd,\nhave H\u2081_nin : y\u2081 \u2209 xs ++ y\u2082 :: ys, from not_mem_of_nodup_cons H_nd',\nhave H\u2081_nin\u2081 : y\u2081 \u2209 xs, from not_mem_of_not_mem_append_left H\u2081_nin,\nhave H\u2081_nin\u2082 : y\u2081 \u2209 ys, from not_mem_of_not_mem_cons (not_mem_of_not_mem_append_right H\u2081_nin),\nhave H_nd'' : nodup (xs ++ y\u2082 :: ys), from nodup_of_nodup_cons H_nd',\nhave H_nd''' : nodup (y\u2082 :: (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\u2081_nin\u2081 H\u2081_nin\u2082) H_nd'''')\n\nlemma map_filter_congr {\u03b1 \u03b2 : Type*} {f g : \u03b1 \u2192 \u03b2} {p : \u03b1 \u2192 Prop} [decidable_pred p] :\n  \u2200 {xs : list \u03b1}, (\u2200 x, x \u2208 xs \u2192 p x \u2192 f x = g x) \u2192 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 \u2228 \u00ac (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 {\u03b1 : Type*} {p q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q] :\n  \u2200 {xs : list \u03b1}, (\u2200 x, x \u2208 xs \u2192 (p x \u2194 q x)) \u2192 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 : \u2200 (idx m : \u2115), idx + 1 \u2208 riota (m + 1) \u2192 idx \u2208 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 : \u2115) : idx \u2208 riota (idx + 1) := by { dunfold riota, apply mem_of_cons_same }\n\nlemma nin_neq_dnth {\u03b1 : Type*} [inhabited \u03b1] [decidable_eq \u03b1] (x : \u03b1) : \u2200 xs, x \u2209 xs \u2192 \u2200 idx, idx \u2208 riota (list.length xs) \u2192 x \u2260 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 {\u03b1 : Type*} : \u03a0 (xs : list \u03b1) (idx : \u2115), idx \u2208 riota (length xs) \u2192 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 {\u03b1 : Type*} [inhabited \u03b1] : \u03a0 (xs : list \u03b1) (idx : \u2115), idx < length xs \u2192 dnth xs idx \u2208 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 {\u03b1 : Type*} [decidable_eq \u03b1] [inhabited \u03b1] : \u03a0 (xs : list \u03b1), filter (\u03bb x, false) xs = nil\n| [] := rfl\n| (x::xs) := begin dunfold filter, simp [filter_false] end\n\nlemma not_in_filter_of_match_riota {\u03b1 : Type*} [decidable_eq \u03b1] [inhabited \u03b1] (x : \u03b1) :\n  \u2200 (xs : list \u03b1), x \u2209 xs \u2192 filter (\u03bb (idx : \u2115), x = dnth xs idx) (riota (length xs)) = nil :=\nassume xs H_nin,\nhave H : filter (\u03bb (idx : \u2115), x = dnth xs idx) (riota (length xs)) = filter (\u03bb idx : \u2115, 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 \u2208 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 \u2192 Type} [m : monad M] {X Y : Type} (f : Y \u2192 X \u2192 M Y) (init : Y) (xs : list X) : M Y :=\n  list.foldr (\u03bb (x : X) (k : Y \u2192 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 : \u00ac 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 \u2227 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 (\u03bb H : P \u2227 Q, np H^.left)\n  | _,           is_false nq := is_false (\u03bb H : P \u2227 Q, nq H^.right)\n  end\n\ndef decidable_or (P Q : Prop) [dP : decidable P] [dQ : decidable Q] : decidable (P \u2228 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 (\u03bb H : P \u2228 Q, or.rec_on H (\u03bb p, np p) (\u03bb 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 `\u2200 x, ...`,\n`\u2203 x, ...` and `\u03bb 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 `\u2200 x, ...`, `\u2203 x, ...` and `\u03bb 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 `\u2190` is applied in the reverse direction.\n  - `simp_rw [lemma_1, ..., lemma_n] at h\u2081 ... h\u2099` will rewrite the given hypotheses.\n  - `simp_rw [...] at \u22a2 h\u2081 ... h\u2099` 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 {\u03b1 \u03b2 : Type} {f : \u03b1 \u2192 \u03b2} {t : set \u03b2} : (\u2200 s, f '' s \u2286 t) = \u2200 s : set \u03b1, \u2200 x \u2208 s, x \u2208 f \u207b\u00b9' 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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\u2082`: Binary map of filters.\n* `Filter.map\u2083`: 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 {\u03b1 \u03b1' \u03b2 \u03b2' \u03b3 \u03b3' \u03b4 \u03b4' \u03b5 \u03b5' : Type _} {m : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {f f\u2081 f\u2082 : Filter \u03b1}\n  {g g\u2081 g\u2082 : Filter \u03b2} {h h\u2081 h\u2082 : Filter \u03b3} {s s\u2081 s\u2082 : Set \u03b1} {t t\u2081 t\u2082 : Set \u03b2} {u : Set \u03b3}\n  {v : Set \u03b4} {a : \u03b1} {b : \u03b2} {c : \u03b3}\n\n/-- The image of a binary function `m : \u03b1 \u2192 \u03b2 \u2192 \u03b3` as a function `Filter \u03b1 \u2192 Filter \u03b2 \u2192 Filter \u03b3`.\nMathematically this should be thought of as the image of the corresponding function `\u03b1 \u00d7 \u03b2 \u2192 \u03b3`. -/\ndef map\u2082 (m : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (f : Filter \u03b1) (g : Filter \u03b2) : Filter \u03b3\n    where\n  sets := { s | \u2203 u v, u \u2208 f \u2227 v \u2208 g \u2227 image2 m u v \u2286 s }\n  univ_sets := \u27e8univ, univ, univ_sets _, univ_sets _, subset_univ _\u27e9\n  sets_of_superset hs hst :=\n    Exists\u2082.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 _ _ \u27e8s\u2081, s\u2082, hs\u2081, hs\u2082, hs\u27e9 \u27e8t\u2081, t\u2082, ht\u2081, ht\u2082, ht\u27e9\n    exact\n      \u27e8s\u2081 \u2229 t\u2081, s\u2082 \u2229 t\u2082, inter_sets f hs\u2081 ht\u2081, inter_sets g hs\u2082 ht\u2082,\n        (image2_subset (inter_subset_left _ _) <| inter_subset_left _ _).trans hs,\n        (image2_subset (inter_subset_right _ _) <| inter_subset_right _ _).trans ht\u27e9\n#align filter.map\u2082 Filter.map\u2082\n\n@[simp]\ntheorem mem_map\u2082_iff : u \u2208 map\u2082 m f g \u2194 \u2203 s t, s \u2208 f \u2227 t \u2208 g \u2227 image2 m s t \u2286 u :=\n  Iff.rfl\n#align filter.mem_map\u2082_iff Filter.mem_map\u2082_iff\n\ntheorem image2_mem_map\u2082 (hs : s \u2208 f) (ht : t \u2208 g) : image2 m s t \u2208 map\u2082 m f g :=\n  \u27e8_, _, hs, ht, Subset.rfl\u27e9\n#align filter.image2_mem_map\u2082 Filter.image2_mem_map\u2082\n\ntheorem map_prod_eq_map\u2082 (m : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (f : Filter \u03b1) (g : Filter \u03b2) :\n    Filter.map (fun p : \u03b1 \u00d7 \u03b2 => m p.1 p.2) (f \u00d7\u1da0 g) = map\u2082 m f g := by\n  ext s\n  simp [mem_prod_iff, prod_subset_iff]\n#align filter.map_prod_eq_map\u2082 Filter.map_prod_eq_map\u2082\n\ntheorem map_prod_eq_map\u2082' (m : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) (f : Filter \u03b1) (g : Filter \u03b2) :\n    Filter.map m (f \u00d7\u1da0 g) = map\u2082 (fun a b => m (a, b)) f g :=\n  map_prod_eq_map\u2082 (curry m) f g\n#align filter.map_prod_eq_map\u2082' Filter.map_prod_eq_map\u2082'\n\n@[simp]\ntheorem map\u2082_mk_eq_prod (f : Filter \u03b1) (g : Filter \u03b2) : map\u2082 Prod.mk f g = f \u00d7\u1da0 g := by\n  simp only [\u2190 map_prod_eq_map\u2082, map_id']\n#align filter.map\u2082_mk_eq_prod Filter.map\u2082_mk_eq_prod\n\n-- lemma image2_mem_map\u2082_iff (hm : injective2 m) : image2 m s t \u2208 map\u2082 m f g \u2194 s \u2208 f \u2227 t \u2208 g :=\n-- \u27e8by { rintro \u27e8u, v, hu, hv, h\u27e9, rw image2_subset_image2_iff hm at h,\n--   exact \u27e8mem_of_superset hu h.1, mem_of_superset hv h.2\u27e9 }, \u03bb h, image2_mem_map\u2082 h.1 h.2\u27e9\ntheorem map\u2082_mono (hf : f\u2081 \u2264 f\u2082) (hg : g\u2081 \u2264 g\u2082) : map\u2082 m f\u2081 g\u2081 \u2264 map\u2082 m f\u2082 g\u2082 :=\n  fun _ \u27e8s, t, hs, ht, hst\u27e9 => \u27e8s, t, hf hs, hg ht, hst\u27e9\n#align filter.map\u2082_mono Filter.map\u2082_mono\n\ntheorem map\u2082_mono_left (h : g\u2081 \u2264 g\u2082) : map\u2082 m f g\u2081 \u2264 map\u2082 m f g\u2082 :=\n  map\u2082_mono Subset.rfl h\n#align filter.map\u2082_mono_left Filter.map\u2082_mono_left\n\ntheorem map\u2082_mono_right (h : f\u2081 \u2264 f\u2082) : map\u2082 m f\u2081 g \u2264 map\u2082 m f\u2082 g :=\n  map\u2082_mono h Subset.rfl\n#align filter.map\u2082_mono_right Filter.map\u2082_mono_right\n\n@[simp]\ntheorem le_map\u2082_iff {h : Filter \u03b3} :\n    h \u2264 map\u2082 m f g \u2194 \u2200 \u2983s\u2984, s \u2208 f \u2192 \u2200 \u2983t\u2984, t \u2208 g \u2192 image2 m s t \u2208 h :=\n  \u27e8fun H _ hs _ ht => H <| image2_mem_map\u2082 hs ht, fun H _ \u27e8_, _, hs, ht, hu\u27e9 =>\n    mem_of_superset (H hs ht) hu\u27e9\n#align filter.le_map\u2082_iff Filter.le_map\u2082_iff\n\n@[simp]\ntheorem map\u2082_bot_left : map\u2082 m \u22a5 g = \u22a5 :=\n  empty_mem_iff_bot.1 \u27e8\u2205, univ, trivial, univ_mem, image2_empty_left.subset\u27e9\n#align filter.map\u2082_bot_left Filter.map\u2082_bot_left\n\n@[simp]\ntheorem map\u2082_bot_right : map\u2082 m f \u22a5 = \u22a5 :=\n  empty_mem_iff_bot.1 \u27e8univ, \u2205, univ_mem, trivial, image2_empty_right.subset\u27e9\n#align filter.map\u2082_bot_right Filter.map\u2082_bot_right\n\n@[simp]\ntheorem map\u2082_eq_bot_iff : map\u2082 m f g = \u22a5 \u2194 f = \u22a5 \u2228 g = \u22a5 := by\n  simp only [\u2190 empty_mem_iff_bot, mem_map\u2082_iff, subset_empty_iff, image2_eq_empty_iff]\n  constructor\n  \u00b7 rintro \u27e8s, t, hs, ht, rfl | rfl\u27e9\n    \u00b7 exact Or.inl hs\n    \u00b7 exact Or.inr ht\n  \u00b7 rintro (h | h)\n    \u00b7 exact \u27e8_, _, h, univ_mem, Or.inl rfl\u27e9\n    \u00b7 exact \u27e8_, _, univ_mem, h, Or.inr rfl\u27e9\n#align filter.map\u2082_eq_bot_iff Filter.map\u2082_eq_bot_iff\n\n@[simp]\ntheorem map\u2082_neBot_iff : (map\u2082 m f g).NeBot \u2194 f.NeBot \u2227 g.NeBot := by\n  simp_rw [neBot_iff]\n  exact map\u2082_eq_bot_iff.not.trans not_or\n#align filter.map\u2082_ne_bot_iff Filter.map\u2082_neBot_iff\n\ntheorem NeBot.map\u2082 (hf : f.NeBot) (hg : g.NeBot) : (map\u2082 m f g).NeBot :=\n  map\u2082_neBot_iff.2 \u27e8hf, hg\u27e9\n#align filter.ne_bot.map\u2082 Filter.NeBot.map\u2082\n\n-- Porting note: Why do I have to specify the `Filter` namespace for `map\u2082` here?\ntheorem NeBot.of_map\u2082_left (h : (Filter.map\u2082 m f g).NeBot) : f.NeBot :=\n  (map\u2082_neBot_iff.1 h).1\n#align filter.ne_bot.of_map\u2082_left Filter.NeBot.of_map\u2082_left\n\ntheorem NeBot.of_map\u2082_right (h : (Filter.map\u2082 m f g).NeBot) : g.NeBot :=\n  (map\u2082_neBot_iff.1 h).2\n#align filter.ne_bot.of_map\u2082_right Filter.NeBot.of_map\u2082_right\n\ntheorem map\u2082_sup_left : map\u2082 m (f\u2081 \u2294 f\u2082) g = map\u2082 m f\u2081 g \u2294 map\u2082 m f\u2082 g := by\n  ext u\n  constructor\n  \u00b7 rintro \u27e8s, t, \u27e8h\u2081, h\u2082\u27e9, ht, hu\u27e9\n    exact \u27e8mem_of_superset (image2_mem_map\u2082 h\u2081 ht) hu, mem_of_superset (image2_mem_map\u2082 h\u2082 ht) hu\u27e9\n  \u00b7 rintro \u27e8\u27e8s\u2081, t\u2081, hs\u2081, ht\u2081, hu\u2081\u27e9, s\u2082, t\u2082, hs\u2082, ht\u2082, hu\u2082\u27e9\n    refine' \u27e8s\u2081 \u222a s\u2082, t\u2081 \u2229 t\u2082, union_mem_sup hs\u2081 hs\u2082, inter_mem ht\u2081 ht\u2082, _\u27e9\n    rw [image2_union_left]\n    exact\n      union_subset ((image2_subset_left <| inter_subset_left _ _).trans hu\u2081)\n        ((image2_subset_left <| inter_subset_right _ _).trans hu\u2082)\n#align filter.map\u2082_sup_left Filter.map\u2082_sup_left\n\ntheorem map\u2082_sup_right : map\u2082 m f (g\u2081 \u2294 g\u2082) = map\u2082 m f g\u2081 \u2294 map\u2082 m f g\u2082 := by\n  ext u\n  constructor\n  \u00b7 rintro \u27e8s, t, hs, \u27e8h\u2081, h\u2082\u27e9, hu\u27e9\n    exact \u27e8mem_of_superset (image2_mem_map\u2082 hs h\u2081) hu, mem_of_superset (image2_mem_map\u2082 hs h\u2082) hu\u27e9\n  \u00b7 rintro \u27e8\u27e8s\u2081, t\u2081, hs\u2081, ht\u2081, hu\u2081\u27e9, s\u2082, t\u2082, hs\u2082, ht\u2082, hu\u2082\u27e9\n    refine' \u27e8s\u2081 \u2229 s\u2082, t\u2081 \u222a t\u2082, inter_mem hs\u2081 hs\u2082, union_mem_sup ht\u2081 ht\u2082, _\u27e9\n    rw [image2_union_right]\n    exact\n      union_subset ((image2_subset_right <| inter_subset_left _ _).trans hu\u2081)\n        ((image2_subset_right <| inter_subset_right _ _).trans hu\u2082)\n#align filter.map\u2082_sup_right Filter.map\u2082_sup_right\n\ntheorem map\u2082_inf_subset_left : map\u2082 m (f\u2081 \u2293 f\u2082) g \u2264 map\u2082 m f\u2081 g \u2293 map\u2082 m f\u2082 g :=\n  le_inf (map\u2082_mono_right inf_le_left) (map\u2082_mono_right inf_le_right)\n#align filter.map\u2082_inf_subset_left Filter.map\u2082_inf_subset_left\n\ntheorem map\u2082_inf_subset_right : map\u2082 m f (g\u2081 \u2293 g\u2082) \u2264 map\u2082 m f g\u2081 \u2293 map\u2082 m f g\u2082 :=\n  le_inf (map\u2082_mono_left inf_le_left) (map\u2082_mono_left inf_le_right)\n#align filter.map\u2082_inf_subset_right Filter.map\u2082_inf_subset_right\n\n@[simp]\ntheorem map\u2082_pure_left : map\u2082 m (pure a) g = g.map fun b => m a b :=\n  Filter.ext fun u =>\n    \u27e8fun \u27e8s, t, hs, ht, hu\u27e9 =>\n      mem_of_superset (image_mem_map ht) ((image_subset_image2_right <| mem_pure.1 hs).trans hu),\n      fun h => \u27e8{a}, _, singleton_mem_pure, h, by rw [image2_singleton_left, image_subset_iff]\u27e9\u27e9\n#align filter.map\u2082_pure_left Filter.map\u2082_pure_left\n\n@[simp]\ntheorem map\u2082_pure_right : map\u2082 m f (pure b) = f.map fun a => m a b :=\n  Filter.ext fun u =>\n    \u27e8fun \u27e8s, t, hs, ht, hu\u27e9 =>\n      mem_of_superset (image_mem_map hs) ((image_subset_image2_left <| mem_pure.1 ht).trans hu),\n      fun h => \u27e8_, {b}, h, singleton_mem_pure, by rw [image2_singleton_right, image_subset_iff]\u27e9\u27e9\n#align filter.map\u2082_pure_right Filter.map\u2082_pure_right\n\ntheorem map\u2082_pure : map\u2082 m (pure a) (pure b) = pure (m a b) := by rw [map\u2082_pure_right, map_pure]\n#align filter.map\u2082_pure Filter.map\u2082_pure\n\ntheorem map\u2082_swap (m : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (f : Filter \u03b1) (g : Filter \u03b2) :\n    map\u2082 m f g = map\u2082 (fun a b => m b a) g f := by\n  ext u\n  constructor <;> rintro \u27e8s, t, hs, ht, hu\u27e9 <;> refine' \u27e8t, s, ht, hs, by rwa [image2_swap]\u27e9\n#align filter.map\u2082_swap Filter.map\u2082_swap\n\n@[simp]\ntheorem map\u2082_left (h : g.NeBot) : map\u2082 (fun x _ => x) f g = f := by\n  ext u\n  refine' \u27e8_, fun hu => \u27e8_, _, hu, univ_mem, (image2_left <| h.nonempty_of_mem univ_mem).subset\u27e9\u27e9\n  rintro \u27e8s, t, hs, ht, hu\u27e9\n  rw [image2_left (h.nonempty_of_mem ht)] at hu\n  exact mem_of_superset hs hu\n#align filter.map\u2082_left Filter.map\u2082_left\n\n@[simp]\ntheorem map\u2082_right (h : f.NeBot) : map\u2082 (fun _ y => y) f g = g := by rw [map\u2082_swap, map\u2082_left h]\n#align filter.map\u2082_right Filter.map\u2082_right\n\n/-- The image of a ternary function `m : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4` as a function\n`Filter \u03b1 \u2192 Filter \u03b2 \u2192 Filter \u03b3 \u2192 Filter \u03b4`. Mathematically this should be thought of as the image\nof the corresponding function `\u03b1 \u00d7 \u03b2 \u00d7 \u03b3 \u2192 \u03b4`. -/\ndef map\u2083 (m : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4) (f : Filter \u03b1) (g : Filter \u03b2) (h : Filter \u03b3) : Filter \u03b4\n    where\n  sets := { s | \u2203 u v w, u \u2208 f \u2227 v \u2208 g \u2227 w \u2208 h \u2227 image3 m u v w \u2286 s }\n  univ_sets := \u27e8univ, univ, univ, univ_sets _, univ_sets _, univ_sets _, subset_univ _\u27e9\n  sets_of_superset hs hst :=\n    Exists\u2083.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 _ _ \u27e8s\u2081, s\u2082, s\u2083, hs\u2081, hs\u2082, hs\u2083, hs\u27e9 \u27e8t\u2081, t\u2082, t\u2083, ht\u2081, ht\u2082, ht\u2083, ht\u27e9\n    exact\n      \u27e8s\u2081 \u2229 t\u2081, s\u2082 \u2229 t\u2082, s\u2083 \u2229 t\u2083, inter_mem hs\u2081 ht\u2081, inter_mem hs\u2082 ht\u2082, inter_mem hs\u2083 ht\u2083,\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\u27e9\n#align filter.map\u2083 Filter.map\u2083\n\ntheorem map\u2082_map\u2082_left (m : \u03b4 \u2192 \u03b3 \u2192 \u03b5) (n : \u03b1 \u2192 \u03b2 \u2192 \u03b4) :\n    map\u2082 m (map\u2082 n f g) h = map\u2083 (fun a b c => m (n a b) c) f g h := by\n  ext w\n  constructor\n  \u00b7 rintro \u27e8s, t, \u27e8u, v, hu, hv, hs\u27e9, ht, hw\u27e9\n    refine' \u27e8u, v, t, hu, hv, ht, _\u27e9\n    rw [\u2190 image2_image2_left]\n    exact (image2_subset_right hs).trans hw\n  \u00b7 rintro \u27e8s, t, u, hs, ht, hu, hw\u27e9\n    exact \u27e8_, u, image2_mem_map\u2082 hs ht, hu, by rwa [image2_image2_left]\u27e9\n#align filter.map\u2082_map\u2082_left Filter.map\u2082_map\u2082_left\n\ntheorem map\u2082_map\u2082_right (m : \u03b1 \u2192 \u03b4 \u2192 \u03b5) (n : \u03b2 \u2192 \u03b3 \u2192 \u03b4) :\n    map\u2082 m f (map\u2082 n g h) = map\u2083 (fun a b c => m a (n b c)) f g h := by\n  ext w\n  constructor\n  \u00b7 rintro \u27e8s, t, hs, \u27e8u, v, hu, hv, ht\u27e9, hw\u27e9\n    refine' \u27e8s, u, v, hs, hu, hv, _\u27e9\n    rw [\u2190 image2_image2_right]\n    exact (image2_subset_left ht).trans hw\n  \u00b7 rintro \u27e8s, t, u, hs, ht, hu, hw\u27e9\n    exact \u27e8s, _, hs, image2_mem_map\u2082 ht hu, by rwa [image2_image2_right]\u27e9\n#align filter.map\u2082_map\u2082_right Filter.map\u2082_map\u2082_right\n\ntheorem map_map\u2082 (m : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (n : \u03b3 \u2192 \u03b4) :\n    (map\u2082 m f g).map n = map\u2082 (fun a b => n (m a b)) f g := by\n  rw [\u2190 map_prod_eq_map\u2082, \u2190 map_prod_eq_map\u2082, map_map]; rfl\n#align filter.map_map\u2082 Filter.map_map\u2082\n\ntheorem map\u2082_map_left (m : \u03b3 \u2192 \u03b2 \u2192 \u03b4) (n : \u03b1 \u2192 \u03b3) :\n    map\u2082 m (f.map n) g = map\u2082 (fun a b => m (n a) b) f g := by\n  rw [\u2190 map_prod_eq_map\u2082, \u2190 map_prod_eq_map\u2082, \u2190 @map_id _ g, prod_map_map_eq, map_map, map_id]; rfl\n#align filter.map\u2082_map_left Filter.map\u2082_map_left\n\ntheorem map\u2082_map_right (m : \u03b1 \u2192 \u03b3 \u2192 \u03b4) (n : \u03b2 \u2192 \u03b3) :\n    map\u2082 m f (g.map n) = map\u2082 (fun a b => m a (n b)) f g := by\n  rw [map\u2082_swap, map\u2082_map_left, map\u2082_swap]\n#align filter.map\u2082_map_right Filter.map\u2082_map_right\n\n@[simp]\ntheorem map\u2082_curry (m : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) (f : Filter \u03b1) (g : Filter \u03b2) :\n    map\u2082 (curry m) f g = (f \u00d7\u1da0 g).map m :=\n  (map_prod_eq_map\u2082' _  _ _).symm\n#align filter.map\u2082_curry Filter.map\u2082_curry\n\n@[simp]\ntheorem map_uncurry_prod (m : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (f : Filter \u03b1) (g : Filter \u03b2) :\n    (f \u00d7\u1da0 g).map (uncurry m) = map\u2082 m f g :=\n  (map\u2082_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\u2082` of those operations.\n\nThe proof pattern is `map\u2082_lemma operation_lemma`. For example, `map\u2082_comm mul_comm` proves that\n`map\u2082 (*) f g = map\u2082 (*) g f` in a `comm_semigroup`.\n-/\n\n\ntheorem map\u2082_assoc {m : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {n : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {m' : \u03b1 \u2192 \u03b5' \u2192 \u03b5} {n' : \u03b2 \u2192 \u03b3 \u2192 \u03b5'}\n    {h : Filter \u03b3} (h_assoc : \u2200 a b c, m (n a b) c = m' a (n' b c)) :\n    map\u2082 m (map\u2082 n f g) h = map\u2082 m' f (map\u2082 n' g h) := by\n  simp only [map\u2082_map\u2082_left, map\u2082_map\u2082_right, h_assoc]\n#align filter.map\u2082_assoc Filter.map\u2082_assoc\n\ntheorem map\u2082_comm {n : \u03b2 \u2192 \u03b1 \u2192 \u03b3} (h_comm : \u2200 a b, m a b = n b a) : map\u2082 m f g = map\u2082 n g f :=\n  (map\u2082_swap _ _ _).trans <| by simp_rw [h_comm]\n#align filter.map\u2082_comm Filter.map\u2082_comm\n\ntheorem map\u2082_left_comm {m : \u03b1 \u2192 \u03b4 \u2192 \u03b5} {n : \u03b2 \u2192 \u03b3 \u2192 \u03b4} {m' : \u03b1 \u2192 \u03b3 \u2192 \u03b4'} {n' : \u03b2 \u2192 \u03b4' \u2192 \u03b5}\n    (h_left_comm : \u2200 a b c, m a (n b c) = n' b (m' a c)) :\n    map\u2082 m f (map\u2082 n g h) = map\u2082 n' g (map\u2082 m' f h) := by\n  rw [map\u2082_swap m', map\u2082_swap m]\n  exact map\u2082_assoc fun _ _ _ => h_left_comm _ _ _\n#align filter.map\u2082_left_comm Filter.map\u2082_left_comm\n\ntheorem map\u2082_right_comm {m : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {n : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {m' : \u03b1 \u2192 \u03b3 \u2192 \u03b4'} {n' : \u03b4' \u2192 \u03b2 \u2192 \u03b5}\n    (h_right_comm : \u2200 a b c, m (n a b) c = n' (m' a c) b) :\n    map\u2082 m (map\u2082 n f g) h = map\u2082 n' (map\u2082 m' f h) g := by\n  rw [map\u2082_swap n, map\u2082_swap n']\n  exact map\u2082_assoc fun _ _ _ => h_right_comm _ _ _\n#align filter.map\u2082_right_comm Filter.map\u2082_right_comm\n\ntheorem map_map\u2082_distrib {n : \u03b3 \u2192 \u03b4} {m' : \u03b1' \u2192 \u03b2' \u2192 \u03b4} {n\u2081 : \u03b1 \u2192 \u03b1'} {n\u2082 : \u03b2 \u2192 \u03b2'}\n    (h_distrib : \u2200 a b, n (m a b) = m' (n\u2081 a) (n\u2082 b)) :\n    (map\u2082 m f g).map n = map\u2082 m' (f.map n\u2081) (g.map n\u2082) := by\n  simp_rw [map_map\u2082, map\u2082_map_left, map\u2082_map_right, h_distrib]\n#align filter.map_map\u2082_distrib Filter.map_map\u2082_distrib\n\n/-- Symmetric statement to `Filter.map\u2082_map_left_comm`. -/\ntheorem map_map\u2082_distrib_left {n : \u03b3 \u2192 \u03b4} {m' : \u03b1' \u2192 \u03b2 \u2192 \u03b4} {n' : \u03b1 \u2192 \u03b1'}\n    (h_distrib : \u2200 a b, n (m a b) = m' (n' a) b) : (map\u2082 m f g).map n = map\u2082 m' (f.map n') g :=\n  map_map\u2082_distrib h_distrib\n#align filter.map_map\u2082_distrib_left Filter.map_map\u2082_distrib_left\n\n/-- Symmetric statement to `Filter.map_map\u2082_right_comm`. -/\ntheorem map_map\u2082_distrib_right {n : \u03b3 \u2192 \u03b4} {m' : \u03b1 \u2192 \u03b2' \u2192 \u03b4} {n' : \u03b2 \u2192 \u03b2'}\n    (h_distrib : \u2200 a b, n (m a b) = m' a (n' b)) : (map\u2082 m f g).map n = map\u2082 m' f (g.map n') :=\n  map_map\u2082_distrib h_distrib\n#align filter.map_map\u2082_distrib_right Filter.map_map\u2082_distrib_right\n\n/-- Symmetric statement to `Filter.map_map\u2082_distrib_left`. -/\ntheorem map\u2082_map_left_comm {m : \u03b1' \u2192 \u03b2 \u2192 \u03b3} {n : \u03b1 \u2192 \u03b1'} {m' : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {n' : \u03b4 \u2192 \u03b3}\n    (h_left_comm : \u2200 a b, m (n a) b = n' (m' a b)) : map\u2082 m (f.map n) g = (map\u2082 m' f g).map n' :=\n  (map_map\u2082_distrib_left fun a b => (h_left_comm a b).symm).symm\n#align filter.map\u2082_map_left_comm Filter.map\u2082_map_left_comm\n\n/-- Symmetric statement to `Filter.map_map\u2082_distrib_right`. -/\ntheorem map_map\u2082_right_comm {m : \u03b1 \u2192 \u03b2' \u2192 \u03b3} {n : \u03b2 \u2192 \u03b2'} {m' : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {n' : \u03b4 \u2192 \u03b3}\n    (h_right_comm : \u2200 a b, m a (n b) = n' (m' a b)) : map\u2082 m f (g.map n) = (map\u2082 m' f g).map n' :=\n  (map_map\u2082_distrib_right fun a b => (h_right_comm a b).symm).symm\n#align filter.map_map\u2082_right_comm Filter.map_map\u2082_right_comm\n\n/-- The other direction does not hold because of the `f`-`f` cross terms on the RHS. -/\ntheorem map\u2082_distrib_le_left {m : \u03b1 \u2192 \u03b4 \u2192 \u03b5} {n : \u03b2 \u2192 \u03b3 \u2192 \u03b4} {m\u2081 : \u03b1 \u2192 \u03b2 \u2192 \u03b2'} {m\u2082 : \u03b1 \u2192 \u03b3 \u2192 \u03b3'}\n    {n' : \u03b2' \u2192 \u03b3' \u2192 \u03b5} (h_distrib : \u2200 a b c, m a (n b c) = n' (m\u2081 a b) (m\u2082 a c)) :\n    map\u2082 m f (map\u2082 n g h) \u2264 map\u2082 n' (map\u2082 m\u2081 f g) (map\u2082 m\u2082 f h) := by\n  rintro s \u27e8t\u2081, t\u2082, \u27e8u\u2081, v, hu\u2081, hv, ht\u2081\u27e9, \u27e8u\u2082, w, hu\u2082, hw, ht\u2082\u27e9, hs\u27e9\n  refine' \u27e8u\u2081 \u2229 u\u2082, _, inter_mem hu\u2081 hu\u2082, image2_mem_map\u2082 hv hw, _\u27e9\n  refine' (image2_distrib_subset_left h_distrib).trans ((image2_subset _ _).trans hs)\n  \u00b7 exact (image2_subset_right <| inter_subset_left _ _).trans ht\u2081\n  \u00b7 exact (image2_subset_right <| inter_subset_right _ _).trans ht\u2082\n#align filter.map\u2082_distrib_le_left Filter.map\u2082_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\u2082_antidistrib {n : \u03b3 \u2192 \u03b4} {m' : \u03b2' \u2192 \u03b1' \u2192 \u03b4} {n\u2081 : \u03b2 \u2192 \u03b2'} {n\u2082 : \u03b1 \u2192 \u03b1'}\n    (h_antidistrib : \u2200 a b, n (m a b) = m' (n\u2081 b) (n\u2082 a)) :\n    (map\u2082 m f g).map n = map\u2082 m' (g.map n\u2081) (f.map n\u2082) := by\n  rw [map\u2082_swap m]\n  exact map_map\u2082_distrib fun _ _ => h_antidistrib _ _\n#align filter.map_map\u2082_antidistrib Filter.map_map\u2082_antidistrib\n\n/-- Symmetric statement to `Filter.map\u2082_map_left_anticomm`. -/\ntheorem map_map\u2082_antidistrib_left {n : \u03b3 \u2192 \u03b4} {m' : \u03b2' \u2192 \u03b1 \u2192 \u03b4} {n' : \u03b2 \u2192 \u03b2'}\n    (h_antidistrib : \u2200 a b, n (m a b) = m' (n' b) a) : (map\u2082 m f g).map n = map\u2082 m' (g.map n') f :=\n  map_map\u2082_antidistrib h_antidistrib\n#align filter.map_map\u2082_antidistrib_left Filter.map_map\u2082_antidistrib_left\n\n/-- Symmetric statement to `Filter.map_map\u2082_right_anticomm`. -/\ntheorem map_map\u2082_antidistrib_right {n : \u03b3 \u2192 \u03b4} {m' : \u03b2 \u2192 \u03b1' \u2192 \u03b4} {n' : \u03b1 \u2192 \u03b1'}\n    (h_antidistrib : \u2200 a b, n (m a b) = m' b (n' a)) : (map\u2082 m f g).map n = map\u2082 m' g (f.map n') :=\n  map_map\u2082_antidistrib h_antidistrib\n#align filter.map_map\u2082_antidistrib_right Filter.map_map\u2082_antidistrib_right\n\n/-- Symmetric statement to `Filter.map_map\u2082_antidistrib_left`. -/\ntheorem map\u2082_map_left_anticomm {m : \u03b1' \u2192 \u03b2 \u2192 \u03b3} {n : \u03b1 \u2192 \u03b1'} {m' : \u03b2 \u2192 \u03b1 \u2192 \u03b4} {n' : \u03b4 \u2192 \u03b3}\n    (h_left_anticomm : \u2200 a b, m (n a) b = n' (m' b a)) :\n    map\u2082 m (f.map n) g = (map\u2082 m' g f).map n' :=\n  (map_map\u2082_antidistrib_left fun a b => (h_left_anticomm b a).symm).symm\n#align filter.map\u2082_map_left_anticomm Filter.map\u2082_map_left_anticomm\n\n/-- Symmetric statement to `Filter.map_map\u2082_antidistrib_right`. -/\ntheorem map_map\u2082_right_anticomm {m : \u03b1 \u2192 \u03b2' \u2192 \u03b3} {n : \u03b2 \u2192 \u03b2'} {m' : \u03b2 \u2192 \u03b1 \u2192 \u03b4} {n' : \u03b4 \u2192 \u03b3}\n    (h_right_anticomm : \u2200 a b, m a (n b) = n' (m' b a)) :\n    map\u2082 m f (g.map n) = (map\u2082 m' g f).map n' :=\n  (map_map\u2082_antidistrib_right fun a b => (h_right_anticomm b a).symm).symm\n#align filter.map_map\u2082_right_anticomm Filter.map_map\u2082_right_anticomm\n\n/-- If `a` is a left identity for `f : \u03b1 \u2192 \u03b2 \u2192 \u03b2`, then `pure a` is a left identity for\n`Filter.map\u2082 f`. -/\ntheorem map\u2082_left_identity {f : \u03b1 \u2192 \u03b2 \u2192 \u03b2} {a : \u03b1} (h : \u2200 b, f a b = b) (l : Filter \u03b2) :\n    map\u2082 f (pure a) l = l := by rw [map\u2082_pure_left, show f a = id from funext h, map_id]\n#align filter.map\u2082_left_identity Filter.map\u2082_left_identity\n\n/-- If `b` is a right identity for `f : \u03b1 \u2192 \u03b2 \u2192 \u03b1`, then `pure b` is a right identity for\n`Filter.map\u2082 f`. -/\ntheorem map\u2082_right_identity {f : \u03b1 \u2192 \u03b2 \u2192 \u03b1} {b : \u03b2} (h : \u2200 a, f a b = a) (l : Filter \u03b1) :\n    map\u2082 f l (pure b) = l := by rw [map\u2082_pure_right, funext h, map_id']\n#align filter.map\u2082_right_identity Filter.map\u2082_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\u2081 l\u2082` applies `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` pointwise to a list `l\u2081 : list \u03b1` and `l\u2082 : list \u03b2`. 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\u2081, a\u2082] [b\u2081, b\u2082, b\u2083] = [(a\u2081, b\u2081), (a\u2082, b\u2082)]`.\n`unzip` undoes `zip`. For example, `unzip [(a\u2081, b\u2081), (a\u2082, b\u2082)] = ([a\u2081, a\u2082], [b\u2081, b\u2082])`.\n-/\n\nuniverse u\n\nopen nat\n\nnamespace list\nvariables {\u03b1 : Type u} {\u03b2 \u03b3 \u03b4 \u03b5 : Type*}\n\n@[simp] theorem zip_with_cons_cons (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (b : \u03b2) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n  zip_with f (a :: l\u2081) (b :: l\u2082) = f a b :: zip_with f l\u2081 l\u2082 := rfl\n\n@[simp] theorem zip_cons_cons (a : \u03b1) (b : \u03b2) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n  zip (a :: l\u2081) (b :: l\u2082) = (a, b) :: zip l\u2081 l\u2082 := rfl\n\n@[simp] theorem zip_with_nil_left (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l) : zip_with f [] l = [] := rfl\n\n@[simp] theorem zip_with_nil_right (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l)  : zip_with f l [] = [] :=\nby cases l; refl\n\n@[simp] lemma zip_with_eq_nil_iff {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {l l'} :\n  zip_with f l l' = [] \u2194 l = [] \u2228 l' = [] :=\nby { cases l; cases l'; simp }\n\n@[simp] theorem zip_nil_left (l : list \u03b1) : zip ([] : list \u03b2) l = [] := rfl\n\n@[simp] theorem zip_nil_right (l : list \u03b1) : zip l ([] : list \u03b2) = [] :=\nzip_with_nil_right _ l\n\n@[simp] theorem zip_swap : \u2200 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n  (zip l\u2081 l\u2082).map prod.swap = zip l\u2082 l\u2081\n| []      l\u2082      := (zip_nil_right _).symm\n| l\u2081      []      := by rw zip_nil_right; refl\n| (a::l\u2081) (b::l\u2082) := by simp only [zip_cons_cons, map_cons, zip_swap l\u2081 l\u2082, prod.swap_prod_mk];\n    split; refl\n\n@[simp] theorem length_zip_with (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u2200  (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n   length (zip_with f l\u2081 l\u2082) = min (length l\u2081) (length l\u2082)\n| []      l\u2082      := rfl\n| l\u2081      []      := by simp only [length, min_zero, zip_with_nil_right]\n| (a::l\u2081) (b::l\u2082) := by simp [length, zip_cons_cons, length_zip_with l\u2081 l\u2082, min_add_add_right]\n\n@[simp] theorem length_zip : \u2200 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n   length (zip l\u2081 l\u2082) = min (length l\u2081) (length l\u2082) :=\nlength_zip_with _\n\ntheorem all\u2082_zip_with {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {p : \u03b3 \u2192 Prop} :\n  \u2200 {l\u2081 : list \u03b1} {l\u2082 : list \u03b2} (h : length l\u2081 = length l\u2082),\n  all\u2082 p (zip_with f l\u2081 l\u2082) \u2194 forall\u2082 (\u03bb x y, p (f x y)) l\u2081 l\u2082\n| [] [] _ := by simp\n| (a :: l\u2081) (b :: l\u2082) h :=\n  by { simp only [length_cons, add_left_inj] at h, simp [all\u2082_zip_with h] }\n\nlemma lt_length_left_of_zip_with {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {i : \u2115} {l : list \u03b1} {l' : list \u03b2}\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {i : \u2115} {l : list \u03b1} {l' : list \u03b2}\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 : \u2115} {l : list \u03b1} {l' : list \u03b2} (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 : \u2115} {l : list \u03b1} {l' : list \u03b2} (h : i < (zip l l').length) :\n  i < l'.length :=\nlt_length_right_of_zip_with h\n\ntheorem zip_append : \u2200 {l\u2081 r\u2081 : list \u03b1} {l\u2082 r\u2082 : list \u03b2} (h : length l\u2081 = length l\u2082),\n   zip (l\u2081 ++ r\u2081) (l\u2082 ++ r\u2082) = zip l\u2081 l\u2082 ++ zip r\u2081 r\u2082\n| []      r\u2081 l\u2082      r\u2082 h := by simp only [eq_nil_of_length_eq_zero h.symm]; refl\n| l\u2081      r\u2081 []      r\u2082 h := by simp only [eq_nil_of_length_eq_zero h]; refl\n| (a::l\u2081) r\u2081 (b::l\u2082) r\u2082 h := by simp only [cons_append, zip_cons_cons, zip_append (succ.inj h)];\n    split; refl\n\ntheorem zip_map (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) : \u2200 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n   zip (l\u2081.map f) (l\u2082.map g) = (zip l\u2081 l\u2082).map (prod.map f g)\n| []      l\u2082      := rfl\n| l\u2081      []      := by simp only [map, zip_nil_right]\n| (a::l\u2081) (b::l\u2082) := by simp only [map, zip_cons_cons, zip_map l\u2081 l\u2082, prod.map]; split; refl\n\ntheorem zip_map_left (f : \u03b1 \u2192 \u03b3) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n   zip (l\u2081.map f) l\u2082 = (zip l\u2081 l\u2082).map (prod.map f id) :=\nby rw [\u2190 zip_map, map_id]\n\ntheorem zip_map_right (f : \u03b2 \u2192 \u03b3) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n   zip l\u2081 (l\u2082.map f) = (zip l\u2081 l\u2082).map (prod.map id f) :=\nby rw [\u2190 zip_map, map_id]\n\n@[simp] lemma zip_with_map {\u03bc}\n  (f : \u03b3 \u2192 \u03b4 \u2192 \u03bc) (g : \u03b1 \u2192 \u03b3) (h : \u03b2 \u2192 \u03b4) (as : list \u03b1) (bs : list \u03b2) :\n  zip_with f (as.map g) (bs.map h) =\n  zip_with (\u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (g : \u03b4 \u2192 \u03b1) (l : list \u03b4) (l' : list \u03b2) :\n  zip_with f (l.map g) l' = zip_with (f \u2218 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l : list \u03b1) (g : \u03b4 \u2192 \u03b2) (l' : list \u03b4) :\n  zip_with f l (l'.map g) = zip_with (\u03bb x, f x \u2218 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 : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) : \u2200 (l : list \u03b1),\n   zip (l.map f) (l.map g) = l.map (\u03bb 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 {\u03b4 : Type*} (f : \u03b1 \u2192 \u03b2) (g : \u03b3 \u2192 \u03b4 \u2192 \u03b1) (l : list \u03b3) (l' : list \u03b4) :\n  map f (zip_with g l l') = zip_with (\u03bb 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} : \u2200 {l\u2081 : list \u03b1} {l\u2082 : list \u03b2},\n   (a, b) \u2208 zip l\u2081 l\u2082 \u2192 a \u2208 l\u2081 \u2227 b \u2208 l\u2082\n| (_::l\u2081) (_::l\u2082) (or.inl rfl) := \u27e8or.inl rfl, or.inl rfl\u27e9\n| (a'::l\u2081) (b'::l\u2082) (or.inr h) := by split; simp only [mem_cons_iff, or_true, mem_zip h]\n\ntheorem map_fst_zip : \u2200 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n  l\u2081.length \u2264 l\u2082.length \u2192\n  map prod.fst (zip l\u2081 l\u2082) = l\u2081\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 : \u2200 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n  l\u2082.length \u2264 l\u2081.length \u2192\n  map prod.snd (zip l\u2081 l\u2082) = l\u2082\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 (\u03b1 \u00d7 \u03b2)) = ([], []) := rfl\n\n@[simp] theorem unzip_cons (a : \u03b1) (b : \u03b2) (l : list (\u03b1 \u00d7 \u03b2)) :\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 : \u2200 (l : list (\u03b1 \u00d7 \u03b2)), 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 (\u03b1 \u00d7 \u03b2)) : (unzip l).1 = l.map prod.fst :=\nby simp only [unzip_eq_map]\n\ntheorem unzip_right (l : list (\u03b1 \u00d7 \u03b2)) : (unzip l).2 = l.map prod.snd :=\nby simp only [unzip_eq_map]\n\ntheorem unzip_swap (l : list (\u03b1 \u00d7 \u03b2)) : unzip (l.map prod.swap) = (unzip l).swap :=\nby simp only [unzip_eq_map, map_map]; split; refl\n\ntheorem zip_unzip : \u2200 (l : list (\u03b1 \u00d7 \u03b2)), 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 : \u2200 {l\u2081 : list \u03b1} {l\u2082 : list \u03b2}, length l\u2081 \u2264 length l\u2082 \u2192\n  (unzip (zip l\u2081 l\u2082)).1 = l\u2081\n| []      l\u2082      h := rfl\n| l\u2081      []      h := by rw eq_nil_of_length_eq_zero (nat.eq_zero_of_le_zero h); refl\n| (a::l\u2081) (b::l\u2082) 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\u2081 : list \u03b1} {l\u2082 : list \u03b2} (h : length l\u2082 \u2264 length l\u2081) :\n  (unzip (zip l\u2081 l\u2082)).2 = l\u2082 :=\nby rw [\u2190 zip_swap, unzip_swap]; exact unzip_zip_left h\n\ntheorem unzip_zip {l\u2081 : list \u03b1} {l\u2082 : list \u03b2} (h : length l\u2081 = length l\u2082) :\n  unzip (zip l\u2081 l\u2082) = (l\u2081, l\u2082) :=\nby rw [\u2190 @prod.mk.eta _ _ (unzip (zip l\u2081 l\u2082)),\n  unzip_zip_left (le_of_eq h), unzip_zip_right (ge_of_eq h)]\n\nlemma zip_of_prod {l : list \u03b1} {l' : list \u03b2} {lp : list (\u03b1 \u00d7 \u03b2)}\n  (hl : lp.map prod.fst = l) (hr : lp.map prod.snd = l') :\n  lp = l.zip l' :=\nby rw [\u2190hl, \u2190hr, \u2190zip_unzip lp, \u2190unzip_left, \u2190unzip_right, zip_unzip, zip_unzip]\n\nlemma map_prod_left_eq_zip {l : list \u03b1} (f : \u03b1 \u2192 \u03b2) : l.map (\u03bb x, (x, f x)) = l.zip (l.map f) :=\nby { rw \u2190zip_map', congr, exact map_id _ }\n\n\n\nlemma zip_with_comm (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u2200 (la : list \u03b1) (lb : list \u03b2),\n  zip_with f la lb = zip_with (\u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (la : list \u03b1) (lb : list \u03b2)\n  (h : list.forall\u2082 (\u03bb 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 : \u03b1 \u2192 \u03b1 \u2192 \u03b2) (comm : \u2200 (x y : \u03b1), f x y = f y x) (l l' : list \u03b1) :\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 : \u03b1 \u2192 \u03b1 \u2192 \u03b4) : \u2200 (l : list \u03b1), zip_with f l l = l.map (\u03bb a, f a a)\n| [] := rfl\n| (x :: xs) := congr_arg _ (zip_with_same xs)\n\nlemma zip_with_zip_with_left (f : \u03b4 \u2192 \u03b3 \u2192 \u03b5) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b4) :\n  \u2200 (la : list \u03b1) (lb : list \u03b2) (lc : list \u03b3),\n    zip_with f (zip_with g la lb) lc = zip_with3 (\u03bb 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 : \u03b1 \u2192 \u03b4 \u2192 \u03b5) (g : \u03b2 \u2192 \u03b3 \u2192 \u03b4) :\n  \u2200 (la : list \u03b1) (lb : list \u03b2) (lc : list \u03b3),\n    zip_with f la (zip_with g lb lc) = zip_with3 (\u03bb 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 : \u03b1 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u2200 (la : list \u03b1) (lb : list \u03b2),\n  zip_with3 f la la lb = zip_with (\u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b1 \u2192 \u03b3) : \u2200 (la : list \u03b1) (lb : list \u03b2),\n  zip_with3 f la lb la = zip_with (\u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2 \u2192 \u03b3) : \u2200 (la : list \u03b1) (lb : list \u03b2),\n  zip_with3 f la lb lb = zip_with (\u03bb 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 : \u03b1 \u2192 \u03b1 \u2192 \u03b2) [is_symm_op \u03b1 \u03b2 f] : is_symm_op (list \u03b1) (list \u03b2) (zip_with f) :=\n\u27e8zip_with_comm_of_comm f is_symm_op.symm_op\u27e9\n\n@[simp] theorem length_revzip (l : list \u03b1) : length (revzip l) = length l :=\nby simp only [revzip, length_zip, length_reverse, min_self]\n\n@[simp] theorem unzip_revzip (l : list \u03b1) : (revzip l).unzip = (l, l.reverse) :=\nunzip_zip (length_reverse l).symm\n\n@[simp] theorem revzip_map_fst (l : list \u03b1) : (revzip l).map prod.fst = l :=\nby rw [\u2190 unzip_left, unzip_revzip]\n\n@[simp] theorem revzip_map_snd (l : list \u03b1) : (revzip l).map prod.snd = l.reverse :=\nby rw [\u2190 unzip_right, unzip_revzip]\n\ntheorem reverse_revzip (l : list \u03b1) : reverse l.revzip = revzip l.reverse :=\nby rw [\u2190 zip_unzip.{u u} (revzip l).reverse, unzip_eq_map]; simp; simp [revzip]\n\ntheorem revzip_swap (l : list \u03b1) : (revzip l).map prod.swap = revzip l.reverse :=\nby simp [revzip]\n\nlemma nth_zip_with (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) (i : \u2115) :\n  (zip_with f l\u2081 l\u2082).nth i = ((l\u2081.nth i).map f).bind (\u03bb g, (l\u2082.nth i).map g) :=\nbegin\n  induction l\u2081 generalizing l\u2082 i,\n  { simp [zip_with, (<*>)] },\n  { cases l\u2082; simp only [zip_with, has_seq.seq, functor.map, nth, option.map_none'],\n    { cases ((l\u2081_hd :: l\u2081_tl).nth i); refl },\n    { cases i; simp only [option.map_some', nth, option.some_bind', *] } }\nend\n\nlemma nth_zip_with_eq_some {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) (z : \u03b3) (i : \u2115) :\n  (zip_with f l\u2081 l\u2082).nth i = some z \u2194 \u2203 x y, l\u2081.nth i = some x \u2227 l\u2082.nth i = some y \u2227 f x y = z :=\nbegin\n  induction l\u2081 generalizing l\u2082 i,\n  { simp [zip_with] },\n  { cases l\u2082; simp only [zip_with, nth, exists_false, and_false, false_and],\n    cases i; simp *, },\nend\n\nlemma nth_zip_eq_some (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) (z : \u03b1 \u00d7 \u03b2) (i : \u2115) :\n  (zip l\u2081 l\u2082).nth i = some z \u2194 l\u2081.nth i = some z.1 \u2227 l\u2082.nth i = some z.2 :=\nbegin\n  cases z,\n  rw [zip, nth_zip_with_eq_some], split,\n  { rintro \u27e8x, y, h\u2080, h\u2081, h\u2082\u27e9, cc },\n  { rintro \u27e8h\u2080, h\u2081\u27e9, exact \u27e8_,_,h\u2080,h\u2081,rfl\u27e9 }\nend\n\n@[simp] lemma nth_le_zip_with {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {l : list \u03b1} {l' : list \u03b2} {i : \u2115}\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 [\u2190option.some_inj, \u2190nth_le_nth, nth_zip_with_eq_some],\n  refine \u27e8l.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 _, _\u27e9,\n  simp only [\u2190nth_le_nth, eq_self_iff_true, and_self]\nend\n\n@[simp] lemma nth_le_zip {l : list \u03b1} {l' : list \u03b2} {i : \u2115} {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 \u03b1} {init tail : list \u03b1} :\n  (init, tail) \u2208 zip l.inits l.tails \u2194 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 (\u27e8rfl, rfl\u27e9 | \u27e8_, _, h, rfl, rfl\u27e9),\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l : list \u03b1) (l' : list \u03b2) :\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 {\u03b3 : Type*} [semiring \u03b3]\n  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (n : \u03b3) (l : list \u03b1) (l' : list \u03b2) :\n  (l.zip_with (\u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l : list \u03b1) (l' : list \u03b2) (n : \u2115)\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 [\u2190drop_one, zip_with_distrib_drop]\n\nlemma zip_with_append (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l la : list \u03b1) (l' lb : list \u03b2) (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 \u03b1]\n\n@[to_additive]\nlemma prod_mul_prod_eq_prod_zip_with_mul_prod_drop : \u2200 (L L' : list \u03b1), 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 \u03b1) (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 \u03b1` 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 {\u03b1 \u03b2 \u03b3 : Type _}\n\nnamespace Finite\n\n#print Finite.of_subsingleton /-\n-- see Note [lower instance priority]\ninstance (priority := 100) of_subsingleton {\u03b1 : Sort _} [Subsingleton \u03b1] : Finite \u03b1 :=\n  of_injective (Function.const \u03b1 ()) <| 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 \u03b1] [Finite \u03b2] : Finite (\u03b1 \u00d7 \u03b2) :=\n  by\n  haveI := Fintype.ofFinite \u03b1\n  haveI := Fintype.ofFinite \u03b2\n  infer_instance\n\ninstance {\u03b1 \u03b2 : Sort _} [Finite \u03b1] [Finite \u03b2] : Finite (PProd \u03b1 \u03b2) :=\n  of_equiv _ Equiv.pprodEquivProdPLift.symm\n\n#print Finite.prod_left /-\ntheorem prod_left (\u03b2) [Finite (\u03b1 \u00d7 \u03b2)] [Nonempty \u03b2] : Finite \u03b1 :=\n  of_surjective (Prod.fst : \u03b1 \u00d7 \u03b2 \u2192 \u03b1) Prod.fst_surjective\n#align finite.prod_left Finite.prod_left\n-/\n\n#print Finite.prod_right /-\ntheorem prod_right (\u03b1) [Finite (\u03b1 \u00d7 \u03b2)] [Nonempty \u03b1] : Finite \u03b2 :=\n  of_surjective (Prod.snd : \u03b1 \u00d7 \u03b2 \u2192 \u03b2) Prod.snd_surjective\n#align finite.prod_right Finite.prod_right\n-/\n\ninstance [Finite \u03b1] [Finite \u03b2] : Finite (Sum \u03b1 \u03b2) :=\n  by\n  haveI := Fintype.ofFinite \u03b1\n  haveI := Fintype.ofFinite \u03b2\n  infer_instance\n\n#print Finite.sum_left /-\ntheorem sum_left (\u03b2) [Finite (Sum \u03b1 \u03b2)] : Finite \u03b1 :=\n  of_injective (Sum.inl : \u03b1 \u2192 Sum \u03b1 \u03b2) Sum.inl_injective\n#align finite.sum_left Finite.sum_left\n-/\n\n#print Finite.sum_right /-\ntheorem sum_right (\u03b1) [Finite (Sum \u03b1 \u03b2)] : Finite \u03b2 :=\n  of_injective (Sum.inr : \u03b2 \u2192 Sum \u03b1 \u03b2) Sum.inr_injective\n#align finite.sum_right Finite.sum_right\n-/\n\ninstance {\u03b2 : \u03b1 \u2192 Type _} [Finite \u03b1] [\u2200 a, Finite (\u03b2 a)] : Finite (\u03a3a, \u03b2 a) :=\n  by\n  letI := Fintype.ofFinite \u03b1\n  letI := fun a => Fintype.ofFinite (\u03b2 a)\n  infer_instance\n\ninstance {\u03b9 : Sort _} {\u03c0 : \u03b9 \u2192 Sort _} [Finite \u03b9] [\u2200 i, Finite (\u03c0 i)] : Finite (\u03a3'i, \u03c0 i) :=\n  of_equiv _ (Equiv.psigmaEquivSigmaPLift \u03c0).symm\n\ninstance [Finite \u03b1] : Finite (Set \u03b1) :=\n  by\n  cases nonempty_fintype \u03b1\n  infer_instance\n\nend Finite\n\n#print Subtype.finite /-\n/-- This instance also provides `[finite s]` for `s : set \u03b1`. -/\ninstance Subtype.finite {\u03b1 : Sort _} [Finite \u03b1] {p : \u03b1 \u2192 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 {\u03b1 : Sort _} {\u03b2 : \u03b1 \u2192 Sort _} [Finite \u03b1] [\u2200 a, Finite (\u03b2 a)] :\n    Finite (\u2200 a, \u03b2 a) := by\n  haveI := Fintype.ofFinite (PLift \u03b1)\n  haveI := fun a => Fintype.ofFinite (PLift (\u03b2 a))\n  exact\n    Finite.of_equiv (\u2200 a : PLift \u03b1, PLift (\u03b2 (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 {\u03b1 : Type _} [Finite \u03b1] {n : \u2115} : Finite (Vector \u03b1 n) :=\n  by\n  haveI := Fintype.ofFinite \u03b1\n  infer_instance\n#align vector.finite Vector.finite\n-/\n\n#print Quot.finite /-\ninstance Quot.finite {\u03b1 : Sort _} [Finite \u03b1] (r : \u03b1 \u2192 \u03b1 \u2192 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 {\u03b1 : Sort _} [Finite \u03b1] (s : Setoid \u03b1) : 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Finite.{u2} \u03b2], Finite.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Finite.{u2} \u03b2], Finite.{max (max 1 u2) u1} (Function.Embedding.{u1, u2} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align function.embedding.finite Function.Embedding.finite\u2093'. -/\ninstance Function.Embedding.finite {\u03b1 \u03b2 : Sort _} [Finite \u03b2] : Finite (\u03b1 \u21aa \u03b2) :=\n  by\n  cases' isEmpty_or_nonempty (\u03b1 \u21aa \u03b2) with _ h\n  \u00b7 infer_instance\n  \u00b7 refine' h.elim fun f => _\n    haveI : Finite \u03b1 := 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Finite.{u2} \u03b2], Finite.{max 1 (imax u1 u2) (imax u2 u1)} (Equiv.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Finite.{u2} \u03b2], Finite.{max (max 1 u2) u1} (Equiv.{u1, u2} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align equiv.finite_right Equiv.finite_right\u2093'. -/\ninstance Equiv.finite_right {\u03b1 \u03b2 : Sort _} [Finite \u03b2] : Finite (\u03b1 \u2243 \u03b2) :=\n  Finite.of_injective Equiv.toEmbedding fun e\u2081 e\u2082 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Finite.{u1} \u03b1], Finite.{max 1 (imax u1 u2) (imax u2 u1)} (Equiv.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Finite.{u1} \u03b1], Finite.{max (max 1 u2) u1} (Equiv.{u1, u2} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align equiv.finite_left Equiv.finite_left\u2093'. -/\ninstance Equiv.finite_left {\u03b1 \u03b2 : Sort _} [Finite \u03b1] : Finite (\u03b1 \u2243 \u03b2) :=\n  Finite.of_equiv _ \u27e8Equiv.symm, Equiv.symm, Equiv.symm_symm, Equiv.symm_symm\u27e9\n#align equiv.finite_left Equiv.finite_left\n\ninstance [Finite \u03b1] {n : \u2115} : Finite (Sym \u03b1 n) :=\n  by\n  haveI := Fintype.ofFinite \u03b1\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 \u22a3 G` with counit `\u03b5`, the pair\n`(FG\u03b5_B, \u03b5_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\u2082 u u\u2082\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable {D : Type u\u2082} [Category.{v\u2082} D]\n\nvariable {A B : C} {f g : A \u27f6 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 \u27f6 B` is reflexive if there is a morphism `B \u27f6 A` which is a section for both.\n-/\nclass IsReflexivePair (f g : A \u27f6 B) : Prop where\n  common_section : \u2203 s : B \u27f6 A, s \u226b f = \ud835\udfd9 B \u2227 s \u226b g = \ud835\udfd9 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 \u27f6 B` is coreflexive if there is a morphism `B \u27f6 A` which is a retraction for both.\n-/\nclass IsCoreflexivePair (f g : A \u27f6 B) : Prop where\n  common_retraction : \u2203 s : B \u27f6 A, f \u226b s = \ud835\udfd9 A \u2227 g \u226b s = \ud835\udfd9 A\n#align category_theory.is_coreflexive_pair CategoryTheory.IsCoreflexivePair\n-/\n\n#print CategoryTheory.IsReflexivePair.mk' /-\ntheorem IsReflexivePair.mk' (s : B \u27f6 A) (sf : s \u226b f = \ud835\udfd9 B) (sg : s \u226b g = \ud835\udfd9 B) :\n    IsReflexivePair f g :=\n  \u27e8\u27e8s, sf, sg\u27e9\u27e9\n#align category_theory.is_reflexive_pair.mk' CategoryTheory.IsReflexivePair.mk'\n-/\n\n#print CategoryTheory.IsCoreflexivePair.mk' /-\ntheorem IsCoreflexivePair.mk' (s : B \u27f6 A) (fs : f \u226b s = \ud835\udfd9 A) (gs : g \u226b s = \ud835\udfd9 A) :\n    IsCoreflexivePair f g :=\n  \u27e8\u27e8s, fs, gs\u27e9\u27e9\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 \u27f6 B) [IsReflexivePair f g] : B \u27f6 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 \u27f6 B) [IsReflexivePair f g] : commonSection f g \u226b f = \ud835\udfd9 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 \u27f6 B) [IsReflexivePair f g] : commonSection f g \u226b g = \ud835\udfd9 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 \u27f6 B) [IsCoreflexivePair f g] : B \u27f6 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 \u27f6 B) [IsCoreflexivePair f g] :\n    f \u226b commonRetraction f g = \ud835\udfd9 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 \u27f6 B) [IsCoreflexivePair f g] :\n    g \u226b commonRetraction f g = \ud835\udfd9 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 \u27f6 A} {q : A \u27f6 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 \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G)\n\n/-- For an adjunction `F \u22a3 G` with counit `\u03b5`, the pair `(FG\u03b5_B, \u03b5_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 [\u2190 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 : \u2200 \u2983A B : C\u2984 (f g : A \u27f6 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 : \u2200 \u2983A B : C\u2984 (f g : A \u27f6 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 \u27f6 B}\n    (r : B \u27f6 A) (rf : r \u226b f = \ud835\udfd9 _) (rg : r \u226b g = \ud835\udfd9 _) : 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 \u27f6 B}\n    (r : B \u27f6 A) (fr : f \u226b r = \ud835\udfd9 _) (gr : g \u226b r = \ud835\udfd9 _) : 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\u00e4rn\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 \u27f6 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 \u2245 Y) \u2243 (X \u27f6 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\u2082 u u\u2082\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 : \u2200 {X Y : obj}, (X \u27f6 Y) \u2192 (Y \u27f6 X)\n  inv_comp' : \u2200 {X Y : obj} (f : X \u27f6 Y), comp (inv f) f = id Y := by obviously\n  comp_inv' : \u2200 {X Y : obj} (f : X \u27f6 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 \u27f6 Y) : IsIso f :=\n  \u27e8\u27e8Groupoid.inv f, Groupoid.comp_inv f, Groupoid.inv_comp f\u27e9\u27e9\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 \u27f6 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 \u27f6 Y) \u2243 (Y \u27f6 X) :=\n  \u27e8Groupoid.inv, Groupoid.inv, fun f => by simp, fun f => by simp\u27e9\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 \u27f6 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 \u2964 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 \u2245 Y) \u2243 (X \u27f6 Y)\n    where\n  toFun := Iso.hom\n  invFun f := \u27e8f, Groupoid.inv f\u27e9\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 \u2964 C\u1d52\u1d56\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 : \u2200 {X Y : C} (f : X \u27f6 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 : \u2200 {X Y : C}, Unique (X \u27f6 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\u2082) [Groupoid.{v} D] (F : C \u2192 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 \u2192 Type u\u2082} [\u2200 i, Groupoid.{v} (J i)] :\n    Groupoid.{max u v} (\u2200 i : I, J i)\n    where inv (x y : \u2200 i, J i) (f : \u2200 i, x i \u27f6 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 {\u03b1 : Type u} {\u03b2 : Type v} [Groupoid.{u\u2082} \u03b1] [Groupoid.{v\u2082} \u03b2] :\n    Groupoid.{max u\u2082 v\u2082} (\u03b1 \u00d7 \u03b2)\n    where inv (x y : \u03b1 \u00d7 \u03b2) (f : x \u27f6 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 (\u03b1 : Type _) (\u03b2 : Type _) [Zero \u03b1] [Zero \u03b2] [One \u03b2] :\n      One (\u03b1 \u2192\u2080 \u03b2) where one := single 0 1\n\n    theorem one_def [Zero \u03b1] [Zero \u03b2] [One \u03b2] : (1 : \u03b1 \u2192\u2080 \u03b2) = single 0 1 := rfl\n\n    theorem all_trivial (\u03b1 : Type _) (\u03b2 : Type _) [Zero \u03b1] [NCSemiring \u03b2] (h10 : (1 : \u03b2) = 0)\n      (x : \u03b1 \u2192\u2080 \u03b2) : x = 0 :=\n        zero_fun fun a => NCSemiring.all_trivial h10 _\n\n    protected noncomputable instance mul' [Monoid \u03b1] [NCSemiring \u03b2] : Mul (\u03b1 \u2192\u2080 \u03b2) where\n      mul :=  fun x y => \u2211 fun a\u2081 b\u2081 => \u2211 fun a\u2082 b\u2082 => single (a\u2081 + a\u2082) (b\u2081 * b\u2082) in y in x\n\n    theorem mul_def [Monoid \u03b1] [NCSemiring \u03b2] {f g : \u03b1 \u2192\u2080 \u03b2} :\n      f * g = \u2211 fun a\u2081 b\u2081 => \u2211 fun a\u2082 b\u2082 => single (a\u2081 + a\u2082) (b\u2081 * b\u2082) in g in f := rfl\n\n    noncomputable instance toNCSemiring [Monoid \u03b1] [NCSemiring \u03b2] : NCSemiring (\u03b1 \u2192\u2080 \u03b2) :=\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\u2081 : \u03b1) (b\u2081 : \u03b2) => \u2211 fun a\u2082 b\u2082 => single (a\u2081 + a\u2082) (b\u2081 * b\u2082) in single 0 1)\n            = fun a\u2081 b\u2081 => single a\u2081 b\u2081 := by\n              apply funext; intro a\u2081; apply funext; intro b\u2081\n              rw [map_sum.single (0 : \u03b1) (1 : \u03b2) (fun a\u2082 b\u2082 => single (a\u2081 + a\u2082) (b\u2081 * b\u2082))\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\u2082 : \u03b1) (b\u2082 : \u03b2) => single (0 + a\u2082) (1 * b\u2082)) = fun a\u2082 b\u2082 => single a\u2082 b\u2082 := by\n            apply funext; intro a\u2082; apply funext; intro b\u2082\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\u2081 : \u2200 a, (\u2211 fun a\u2082 b\u2082 => single (a + a\u2082) (0 * b\u2082) in z) = 0 := by\n            intros; simp only [NCSemiring.zero_mul, single.zero, map_sum.sum_zero]\n          have h\u2082 : \u2200 (a : \u03b1) (b\u2081 b\u2082 : \u03b2),\n            (\u2211 fun a\u2082 b\u2082_1 => single (a + a\u2082) ((b\u2081 + b\u2082) * b\u2082_1) in z) =\n              (\u2211 fun a\u2082 b\u2082 => single (a + a\u2082) (b\u2081 * b\u2082) in z) + \u2211 fun a\u2082 b\u2082_1 => single (a + a\u2082) (b\u2082 * b\u2082_1) in z := by\n                intro a b b'; simp only; rw [\u2190map_sum.sum_add]; apply map_sum.congr\n                intros; rw [\u2190single.add, NCSemiring.mul_distrib_right]\n          have h\u2083 : \u2200 {a\u2081} a, single (a\u2081 + a) (to_fun x a\u2081 * 0) = 0 := by\n            intros; rw [NCSemiring.mul_zero, single.zero]\n          have h\u2084 : \u2200 {a\u2081} (a) (b\u2081 b\u2082), single (a\u2081 + a) (to_fun x a\u2081 * (b\u2081 + b\u2082)) =\n              single (a\u2081 + a) (to_fun x a\u2081 * b\u2081) + single (a\u2081 + a) (to_fun x a\u2081 * b\u2082) := by\n                intros; rw [\u2190single.add, NCSemiring.mul_distrib_left]\n          rw [map_sum.sum_sum h\u2081 h\u2082]; apply map_sum.congr; intros\n          rw [map_sum.sum_sum h\u2081 h\u2082, map_sum.sum_sum h\u2083 h\u2084]; apply map_sum.congr; intros\n          rw [map_sum.single _ _ _ (by\n            conv => rhs; rw [\u2190map_sum.sum_zero z]\n            apply map_sum.congr; intros; rw [NCSemiring.zero_mul, single.zero])]\n          rw [map_sum.sum_sum h\u2083 h\u2084]; 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\u2081 b\u2081 => (\u2211 fun a\u2082 b\u2082 => single (a\u2081 + a\u2082) (b\u2081 * b\u2082) in (y + z))) =\n            fun a\u2081 b\u2081 => (\u2211 fun a\u2082 b\u2082 => single (a\u2081 + a\u2082) (b\u2081 * b\u2082) in y) + \u2211 fun a\u2082 b\u2082 => single (a\u2081 + a\u2082) (b\u2081 * b\u2082) 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 [\u2190single.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 [\u2190map_sum.sum_add]; exact map_sum.congr (by\n                  intros; rw [\u2190single.add, add_apply, NCSemiring.mul_distrib_right]))\n      }\n\n    noncomputable instance toNonTrivialNCSemiring [Monoid \u03b1] [NonTrivialNCSemiring \u03b2] : NonTrivialNCSemiring (\u03b1 \u2192\u2080 \u03b2) where\n      one_neq_zero := by\n        intro h; simp only [one_def] at h\n        have := congrArg (fun (x : \u03b1 \u2192\u2080 \u03b2) => x (0 : \u03b1)) 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 \u03b1] [Semiring \u03b2] : Semiring (\u03b1 \u2192\u2080 \u03b2) 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 \u03b1] [NCRing \u03b2] : NCRing (\u03b1 \u2192\u2080 \u03b2) where\n      toNeg   := Finsupp.neg\n      add_neg := toGroup.add_neg\n\n    noncomputable instance toRing [CommMonoid \u03b1] [Ring \u03b2] : Ring (\u03b1 \u2192\u2080 \u03b2) where\n      toNCRing := toNCRing\n      mul_comm := toSemiring.mul_comm\n\n    noncomputable instance UnitFinsuppNCSemiring [NCSemiring \u03b1] : (Unit \u2192\u2080 \u03b1) \u2245* \u03b1 where\n      toMHomomorphism := UnitFinsuppMonoid.toMHomomorphism\n      preserve_mul := fun x y => by\n        simp only [mul_def]\n        have : (fun a\u2082 b\u2082 => single (Unit.unit + a\u2082) ((0 : \u03b1) * b\u2082)) = fun _ _ => (0 : Unit \u2192\u2080 \u03b1) := 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 \u03b1] : (Unit \u2192\u2080 \u03b1) \u2245\u1d63 \u03b1 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 \u03b1] [NCSemiring \u03b2] {a\u2081 a\u2082 : \u03b1} {b\u2081 b\u2082 : \u03b2} :\n        single a\u2081 b\u2081 * single a\u2082 b\u2082 = single (a\u2081 + a\u2082) (b\u2081 * b\u2082) := 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 \u2192 Prop\n\nvariable h : \u00ac \u2203 x, P x \u2228 Q x\ninclude h\n\ntheorem fol_06 : \u2200 x, \u00ac P x \u2227 \u00ac Q x :=\nassume s,\nhave h1: \u2200 t, \u00ac (P t \u2228 Q t), from\n  (assume t: A,\n   classical.by_contradiction\n    (assume h2: \u00ac\u00ac(P t \u2228 Q t),\n     have h3: P t \u2228 Q t, from classical.by_contradiction h2,\n     h (exists.intro t h3))),\n\nhave h4: \u00ac (P s \u2228 Q s), from h1 s,\n\nhave h5: \u00ac P s, from classical.by_contradiction\n  (assume h6: \u00ac\u00acP s,\n   have h7: P s, from classical.by_contradiction h6,\n   have h8: P s \u2228 Q s, from or.inl h7,\n   h4 h8),\nhave h9: \u00ac Q s, from classical.by_contradiction\n  (assume h10: \u00ac\u00acQ s,\n   have h11: Q s, from classical.by_contradiction h10,\n   have h12: P s \u2228 Q s, from or.inr h11,\n   h4 h12),\n\nhave h13: \u00ac P s \u2227 \u00ac Q s, from and.intro h5 h9,\nshow \u00acP s \u2227 \u00acQ 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 : \u211d)\n  (h\u2080 : 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\u2081, ..., l\u2099]` is a list whose `i`-th element comes from the `i`-th list.\n-/\n\n\nopen nat function\n\nnamespace list\nvariables {\u03b1 \u03b2 : Type*}\n\ntheorem mem_sections {L : list (list \u03b1)} {f} : f \u2208 sections L \u2194 forall\u2082 (\u2208) f L :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { induction L generalizing f, {cases mem_singleton.1 h, exact forall\u2082.nil},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map] at h,\n    rcases h with \u27e8_, _, _, _, rfl\u27e9,\n    simp only [*, forall\u2082_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 \u27e8_, fs, _, al, rfl, rfl\u27e9 }\nend\n\n\n\nlemma rel_sections {r : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  (forall\u2082 (forall\u2082 r) \u21d2 forall\u2082 (forall\u2082 r)) sections sections\n| _ _ forall\u2082.nil := forall\u2082.cons forall\u2082.nil forall\u2082.nil\n| _ _ (forall\u2082.cons h\u2080 h\u2081) :=\n  rel_bind (rel_sections h\u2081) (assume _ _ hl, rel_map (assume _ _ ha, forall\u2082.cons ha hl) h\u2080)\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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 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 \u03b2)) : Multiset \u03b1 :=\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 \u03b2)} : keys (l : Multiset (Sigma \u03b2)) = (l.keys : Multiset \u03b1) :=\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 \u03b2)) : 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 \u03b2)} : @NodupKeys \u03b1 \u03b2 l \u2194 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 (\u03a3a, \u03b2 a)} : m.keys.Nodup \u2194 m.NodupKeys :=\n  by\n  rcases m with \u27e8l\u27e9\n  rfl\n#align multiset.nodup_keys Multiset.nodup_keys\n-/\n\nalias nodup_keys \u2194 _ nodupkeys.nodup_keys\n#align multiset.nodupkeys.nodup_keys Multiset.NodupKeys.nodup_keys\n\n#print Multiset.NodupKeys.nodup /-\ntheorem NodupKeys.nodup {m : Multiset (\u03a3a, \u03b2 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 \u03b2` is the type of finite maps over a multiset. It is effectively\n  a quotient of `alist \u03b2` by permutation of the underlying list. -/\nstructure Finmap (\u03b2 : \u03b1 \u2192 Type v) : Type max u v where\n  entries : Multiset (Sigma \u03b2)\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 \u03b2) : Finmap \u03b2 :=\n  \u27e8s.entries, s.NodupKeys\u27e9\n#align alist.to_finmap AList.toFinmap\n-/\n\n-- mathport name: to_finmap\nlocal notation:arg \"\u27e6\" a \"\u27e7\" => AList.toFinmap a\n\n#print AList.toFinmap_eq /-\ntheorem AList.toFinmap_eq {s\u2081 s\u2082 : AList \u03b2} : \u27e6s\u2081\u27e7 = \u27e6s\u2082\u27e7 \u2194 s\u2081.entries ~ s\u2082.entries := by\n  cases s\u2081 <;> cases s\u2082 <;> 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 \u03b2) : \u27e6s\u27e7.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 \u03b2)`, create a term of type `finmap \u03b2` by removing\nentries with duplicate keys. -/\ndef List.toFinmap [DecidableEq \u03b1] (s : List (Sigma \u03b2)) : Finmap \u03b2 :=\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 \u03b2) : 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 {\u03b3} (s : Finmap \u03b2) (f : AList \u03b2 \u2192 \u03b3)\n    (H : \u2200 a b : AList \u03b2, a.entries ~ b.entries \u2192 f a = f b) : \u03b3 :=\n  by\n  refine'\n    (Quotient.liftOn s.1 (fun l => (\u27e8_, fun nd => f \u27e8l, nd\u27e9\u27e9 : Part \u03b3)) fun l\u2081 l\u2082 p =>\n            Part.ext' (perm_nodupkeys p) _ :\n          Part \u03b3).get\n      _\n  \u00b7 exact fun h\u2081 h\u2082 => H _ _ p\n  \u00b7 have := s.nodupkeys\n    rcases s.entries with \u27e8l\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} {\u03b3 : Type.{u3}} (s : AList.{u1, u2} \u03b1 \u03b2) (f : (AList.{u1, u2} \u03b1 \u03b2) -> \u03b3) (H : forall (a : AList.{u1, u2} \u03b1 \u03b2) (b : AList.{u1, u2} \u03b1 \u03b2), (List.Perm.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2) (AList.entries.{u1, u2} \u03b1 \u03b2 a) (AList.entries.{u1, u2} \u03b1 \u03b2 b)) -> (Eq.{succ u3} \u03b3 (f a) (f b))), Eq.{succ u3} \u03b3 (Finmap.liftOn.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (AList.toFinmap.{u1, u2} \u03b1 \u03b2 s) f H) (f s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : \u03b1 -> Type.{u3}} {\u03b3 : Type.{u1}} (s : AList.{u2, u3} \u03b1 \u03b2) (f : (AList.{u2, u3} \u03b1 \u03b2) -> \u03b3) (H : forall (a : AList.{u2, u3} \u03b1 \u03b2) (b : AList.{u2, u3} \u03b1 \u03b2), (List.Perm.{max u2 u3} (Sigma.{u2, u3} \u03b1 \u03b2) (AList.entries.{u2, u3} \u03b1 \u03b2 a) (AList.entries.{u2, u3} \u03b1 \u03b2 b)) -> (Eq.{succ u1} \u03b3 (f a) (f b))), Eq.{succ u1} \u03b3 (Finmap.liftOn.{u2, u3, u1} \u03b1 \u03b2 \u03b3 (AList.toFinmap.{u2, u3} \u03b1 \u03b2 s) f H) (f s)\nCase conversion may be inaccurate. Consider using '#align finmap.lift_on_to_finmap Finmap.liftOn_toFinmap\u2093'. -/\n@[simp]\ntheorem liftOn_toFinmap {\u03b3} (s : AList \u03b2) (f : AList \u03b2 \u2192 \u03b3) (H) : liftOn \u27e6s\u27e7 f H = f s := by\n  cases s <;> rfl\n#align finmap.lift_on_to_finmap Finmap.liftOn_toFinmap\n\n#print Finmap.liftOn\u2082 /-\n/-- Lift a permutation-respecting function on 2 `alist`s to 2 `finmap`s. -/\n@[elab_as_elim]\ndef liftOn\u2082 {\u03b3} (s\u2081 s\u2082 : Finmap \u03b2) (f : AList \u03b2 \u2192 AList \u03b2 \u2192 \u03b3)\n    (H :\n      \u2200 a\u2081 b\u2081 a\u2082 b\u2082 : AList \u03b2,\n        a\u2081.entries ~ a\u2082.entries \u2192 b\u2081.entries ~ b\u2082.entries \u2192 f a\u2081 b\u2081 = f a\u2082 b\u2082) :\n    \u03b3 :=\n  liftOn s\u2081 (fun l\u2081 => liftOn s\u2082 (f l\u2081) fun b\u2081 b\u2082 p => H _ _ _ _ (Perm.refl _) p) fun a\u2081 a\u2082 p =>\n    by\n    have H' : f a\u2081 = f a\u2082 := funext fun _ => H _ _ _ _ p (Perm.refl _)\n    simp only [H']\n#align finmap.lift_on\u2082 Finmap.liftOn\u2082\n-/\n\n/- warning: finmap.lift_on\u2082_to_finmap -> Finmap.liftOn\u2082_toFinmap is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} {\u03b3 : Type.{u3}} (s\u2081 : AList.{u1, u2} \u03b1 \u03b2) (s\u2082 : AList.{u1, u2} \u03b1 \u03b2) (f : (AList.{u1, u2} \u03b1 \u03b2) -> (AList.{u1, u2} \u03b1 \u03b2) -> \u03b3) (H : forall (a\u2081 : AList.{u1, u2} \u03b1 \u03b2) (b\u2081 : AList.{u1, u2} \u03b1 \u03b2) (a\u2082 : AList.{u1, u2} \u03b1 \u03b2) (b\u2082 : AList.{u1, u2} \u03b1 \u03b2), (List.Perm.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2) (AList.entries.{u1, u2} \u03b1 \u03b2 a\u2081) (AList.entries.{u1, u2} \u03b1 \u03b2 a\u2082)) -> (List.Perm.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2) (AList.entries.{u1, u2} \u03b1 \u03b2 b\u2081) (AList.entries.{u1, u2} \u03b1 \u03b2 b\u2082)) -> (Eq.{succ u3} \u03b3 (f a\u2081 b\u2081) (f a\u2082 b\u2082))), Eq.{succ u3} \u03b3 (Finmap.liftOn\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (AList.toFinmap.{u1, u2} \u03b1 \u03b2 s\u2081) (AList.toFinmap.{u1, u2} \u03b1 \u03b2 s\u2082) f H) (f s\u2081 s\u2082)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : \u03b1 -> Type.{u3}} {\u03b3 : Type.{u1}} (s\u2081 : AList.{u2, u3} \u03b1 \u03b2) (s\u2082 : AList.{u2, u3} \u03b1 \u03b2) (f : (AList.{u2, u3} \u03b1 \u03b2) -> (AList.{u2, u3} \u03b1 \u03b2) -> \u03b3) (H : forall (a\u2081 : AList.{u2, u3} \u03b1 \u03b2) (b\u2081 : AList.{u2, u3} \u03b1 \u03b2) (a\u2082 : AList.{u2, u3} \u03b1 \u03b2) (b\u2082 : AList.{u2, u3} \u03b1 \u03b2), (List.Perm.{max u2 u3} (Sigma.{u2, u3} \u03b1 \u03b2) (AList.entries.{u2, u3} \u03b1 \u03b2 a\u2081) (AList.entries.{u2, u3} \u03b1 \u03b2 a\u2082)) -> (List.Perm.{max u2 u3} (Sigma.{u2, u3} \u03b1 \u03b2) (AList.entries.{u2, u3} \u03b1 \u03b2 b\u2081) (AList.entries.{u2, u3} \u03b1 \u03b2 b\u2082)) -> (Eq.{succ u1} \u03b3 (f a\u2081 b\u2081) (f a\u2082 b\u2082))), Eq.{succ u1} \u03b3 (Finmap.liftOn\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03b3 (AList.toFinmap.{u2, u3} \u03b1 \u03b2 s\u2081) (AList.toFinmap.{u2, u3} \u03b1 \u03b2 s\u2082) f H) (f s\u2081 s\u2082)\nCase conversion may be inaccurate. Consider using '#align finmap.lift_on\u2082_to_finmap Finmap.liftOn\u2082_toFinmap\u2093'. -/\n@[simp]\ntheorem liftOn\u2082_toFinmap {\u03b3} (s\u2081 s\u2082 : AList \u03b2) (f : AList \u03b2 \u2192 AList \u03b2 \u2192 \u03b3) (H) :\n    liftOn\u2082 \u27e6s\u2081\u27e7 \u27e6s\u2082\u27e7 f H = f s\u2081 s\u2082 := by cases s\u2081 <;> cases s\u2082 <;> rfl\n#align finmap.lift_on\u2082_to_finmap Finmap.liftOn\u2082_toFinmap\n\n/-! ### induction -/\n\n\n#print Finmap.induction_on /-\n@[elab_as_elim]\ntheorem induction_on {C : Finmap \u03b2 \u2192 Prop} (s : Finmap \u03b2) (H : \u2200 a : AList \u03b2, C \u27e6a\u27e7) : C s := by\n  rcases s with \u27e8\u27e8a\u27e9, h\u27e9 <;> exact H \u27e8a, h\u27e9\n#align finmap.induction_on Finmap.induction_on\n-/\n\n#print Finmap.induction_on\u2082 /-\n@[elab_as_elim]\ntheorem induction_on\u2082 {C : Finmap \u03b2 \u2192 Finmap \u03b2 \u2192 Prop} (s\u2081 s\u2082 : Finmap \u03b2)\n    (H : \u2200 a\u2081 a\u2082 : AList \u03b2, C \u27e6a\u2081\u27e7 \u27e6a\u2082\u27e7) : C s\u2081 s\u2082 :=\n  induction_on s\u2081 fun l\u2081 => induction_on s\u2082 fun l\u2082 => H l\u2081 l\u2082\n#align finmap.induction_on\u2082 Finmap.induction_on\u2082\n-/\n\n#print Finmap.induction_on\u2083 /-\n@[elab_as_elim]\ntheorem induction_on\u2083 {C : Finmap \u03b2 \u2192 Finmap \u03b2 \u2192 Finmap \u03b2 \u2192 Prop} (s\u2081 s\u2082 s\u2083 : Finmap \u03b2)\n    (H : \u2200 a\u2081 a\u2082 a\u2083 : AList \u03b2, C \u27e6a\u2081\u27e7 \u27e6a\u2082\u27e7 \u27e6a\u2083\u27e7) : C s\u2081 s\u2082 s\u2083 :=\n  induction_on\u2082 s\u2081 s\u2082 fun l\u2081 l\u2082 => induction_on s\u2083 fun l\u2083 => H l\u2081 l\u2082 l\u2083\n#align finmap.induction_on\u2083 Finmap.induction_on\u2083\n-/\n\n/-! ### extensionality -/\n\n\n#print Finmap.ext /-\n@[ext]\ntheorem ext : \u2200 {s t : Finmap \u03b2}, s.entries = t.entries \u2192 s = t\n  | \u27e8l\u2081, h\u2081\u27e9, \u27e8l\u2082, h\u2082\u27e9, H => by congr\n#align finmap.ext Finmap.ext\n-/\n\n#print Finmap.ext_iff /-\n@[simp]\ntheorem ext_iff {s t : Finmap \u03b2} : s.entries = t.entries \u2194 s = t :=\n  \u27e8ext, congr_arg _\u27e9\n#align finmap.ext_iff Finmap.ext_iff\n-/\n\n/-! ### mem -/\n\n\n/-- The predicate `a \u2208 s` means that `s` has a value associated to the key `a`. -/\ninstance : Membership \u03b1 (Finmap \u03b2) :=\n  \u27e8fun a s => a \u2208 s.entries.keys\u27e9\n\n#print Finmap.mem_def /-\ntheorem mem_def {a : \u03b1} {s : Finmap \u03b2} : a \u2208 s \u2194 a \u2208 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 : \u03b1} {s : AList \u03b2} : a \u2208 \u27e6s\u27e7 \u2194 a \u2208 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 \u03b2) : Finset \u03b1 :=\n  \u27e8s.entries.keys, s.NodupKeys.nodup_keys\u27e9\n#align finmap.keys Finmap.keys\n-/\n\n#print Finmap.keys_val /-\n@[simp]\ntheorem keys_val (s : AList \u03b2) : (keys \u27e6s\u27e7).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\u2081 s\u2082 : AList \u03b2} : keys \u27e6s\u2081\u27e7 = keys \u27e6s\u2082\u27e7 \u2194 s\u2081.keys ~ s\u2082.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 : \u03b1} {s : Finmap \u03b2} : a \u2208 s.keys \u2194 a \u2208 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 \u03b2) :=\n  \u27e8\u27e80, nodupKeys_nil\u27e9\u27e9\n\ninstance : Inhabited (Finmap \u03b2) :=\n  \u27e8\u2205\u27e9\n\n#print Finmap.empty_toFinmap /-\n@[simp]\ntheorem empty_toFinmap : (\u27e6\u2205\u27e7 : Finmap \u03b2) = \u2205 :=\n  rfl\n#align finmap.empty_to_finmap Finmap.empty_toFinmap\n-/\n\n#print Finmap.toFinmap_nil /-\n@[simp]\ntheorem toFinmap_nil [DecidableEq \u03b1] : ([].toFinmap : Finmap \u03b2) = \u2205 :=\n  rfl\n#align finmap.to_finmap_nil Finmap.toFinmap_nil\n-/\n\n#print Finmap.not_mem_empty /-\ntheorem not_mem_empty {a : \u03b1} : a \u2209 (\u2205 : Finmap \u03b2) :=\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 : (\u2205 : Finmap \u03b2).keys = \u2205 :=\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 : \u03b1) (b : \u03b2 a) : Finmap \u03b2 :=\n  \u27e6AList.singleton a b\u27e7\n#align finmap.singleton Finmap.singleton\n-/\n\n#print Finmap.keys_singleton /-\n@[simp]\ntheorem keys_singleton (a : \u03b1) (b : \u03b2 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 : \u03b1) (b : \u03b2 y) : x \u2208 singleton y b \u2194 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 \u03b1]\n\n#print Finmap.decidableEq /-\ninstance decidableEq [\u2200 a, DecidableEq (\u03b2 a)] : DecidableEq (Finmap \u03b2)\n  | s\u2081, s\u2082 => 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 : \u03b1) (s : Finmap \u03b2) : Option (\u03b2 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 : \u03b1) (s : AList \u03b2) : lookup a \u27e6s\u27e7 = 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 : \u03b1) (s : List (Sigma \u03b2)) : 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 (\u2205 : Finmap \u03b2) = none :=\n  rfl\n#align finmap.lookup_empty Finmap.lookup_empty\n-/\n\n#print Finmap.lookup_isSome /-\ntheorem lookup_isSome {a : \u03b1} {s : Finmap \u03b2} : (s.dlookup a).isSome \u2194 a \u2208 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 \u03b2} : lookup a s = none \u2194 a \u2209 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 \u03b2} {a : \u03b1} {b : \u03b2 a} :\n    b \u2208 f.dlookup a \u2194 Sigma.mk a b \u2208 f.entries :=\n  by\n  rcases f with \u27e8\u27e8l\u27e9, hl\u27e9\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 \u03b2} {a : \u03b1} {b : \u03b2 a} :\n    f.dlookup a = some b \u2194 Sigma.mk a b \u2208 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 \u03b2) :\n    (f.keys.Sigma fun i => (f.dlookup i).toFinset) = \u27e8f.entries, f.nodup_entries\u27e9 :=\n  by\n  ext x\n  have : x \u2208 f.entries \u2192 x.fst \u2208 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 : \u03b1} {b : \u03b2 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 : \u03b1) (s : Finmap \u03b2) : Decidable (a \u2208 s) :=\n  decidable_of_iff _ lookup_isSome\n\n#print Finmap.mem_iff /-\ntheorem mem_iff {a : \u03b1} {s : Finmap \u03b2} : a \u2208 s \u2194 \u2203 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 : \u03b1} {b : \u03b2 a} {s : Finmap \u03b2} (h : s.dlookup a = some b) : a \u2208 s :=\n  mem_iff.mpr \u27e8_, h\u27e9\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\u2081 s\u2082 : Finmap \u03b2} : (\u2200 x, s\u2081.dlookup x = s\u2082.dlookup x) \u2192 s\u2081 = s\u2082 :=\n  induction_on\u2082 s\u2081 s\u2082 fun s\u2081 s\u2082 h =>\n    by\n    simp only [AList.lookup, lookup_to_finmap] at h\n    rw [AList.toFinmap_eq]\n    apply lookup_ext s\u2081.nodupkeys s\u2082.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 \u03b2` and pairs `(keys : finset \u03b1, lookup : \u03a0 a, option (\u03b2 a))` such\nthat `(lookup a).is_some \u2194 a \u2208 keys`. -/\n@[simps apply_coe_fst apply_coe_snd]\ndef keysLookupEquiv :\n    Finmap \u03b2 \u2243 { f : Finset \u03b1 \u00d7 \u2200 a, Option (\u03b2 a) // \u2200 i, (f.2 i).isSome \u2194 i \u2208 f.1 }\n    where\n  toFun f := \u27e8(f.keys, fun i => f.dlookup i), fun i => lookup_isSome\u27e9\n  invFun f :=\n    \u27e8(f.1.1.Sigma fun i => (f.1.2 i).toFinset).val,\n      by\n      refine' Multiset.nodup_keys.1 ((Finset.nodup _).map_on\u2093 _)\n      simp only [Finset.mem_val, Finset.mem_sigma, Option.mem_toFinset, Option.mem_def]\n      rintro \u27e8i, x\u27e9 \u27e8hi, hx\u27e9 \u27e8j, y\u27e9 \u27e8hj, hy\u27e9 (rfl : i = j)\n      obtain rfl : x = y; exact Option.some.inj (hx.symm.trans hy)\n      rfl\u27e9\n  left_inv f := ext <| by simp\n  right_inv := fun \u27e8\u27e8s, f\u27e9, hf\u27e9 => by\n    ext : 2 <;> dsimp [keys]\n    \u00b7 ext1 i\n      have : i \u2208 s \u2192 \u2203 x, f i = some x := fun hi => \u27e8Option.get _, Option.get_mem <| (hf i).2 hi\u27e9\n      simpa [Multiset.keys]\n    \u00b7 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, \u2190 hf]\n      exact fun h => Option.isSome_iff_exists.2 \u27e8_, h\u27e9\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    \u2200 f : { f : Finset \u03b1 \u00d7 \u2200 a, Option (\u03b2 a) // \u2200 i, (f.2 i).isSome \u2194 i \u2208 f.1 },\n      (keysLookupEquiv.symm f).keys = (f : Finset \u03b1 \u00d7 \u2200 a, Option (\u03b2 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    \u2200 (f : { f : Finset \u03b1 \u00d7 \u2200 a, Option (\u03b2 a) // \u2200 i, (f.2 i).isSome \u2194 i \u2208 f.1 }) (a),\n      (keysLookupEquiv.symm f).dlookup a = (f : Finset \u03b1 \u00d7 \u2200 a, Option (\u03b2 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 : \u03b1) (b : \u03b2 a) (s : Finmap \u03b2) : Finmap \u03b2 :=\n  liftOn s (fun t => \u27e6replace a b t\u27e7) fun s\u2081 s\u2082 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 : \u03b1) (b : \u03b2 a) (s : AList \u03b2) : replace a b \u27e6s\u27e7 = \u27e6s.replace a b\u27e7 := 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 : \u03b1) (b : \u03b2 a) (s : Finmap \u03b2) : (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' : \u03b1} {b : \u03b2 a} {s : Finmap \u03b2} : a' \u2208 replace a b s \u2194 a' \u2208 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 {\u03b4 : Type w} (f : \u03b4 \u2192 \u2200 a, \u03b2 a \u2192 \u03b4)\n    (H : \u2200 d a\u2081 b\u2081 a\u2082 b\u2082, f (f d a\u2081 b\u2081) a\u2082 b\u2082 = f (f d a\u2082 b\u2082) a\u2081 b\u2081) (d : \u03b4) (m : Finmap \u03b2) : \u03b4 :=\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 : \u2200 x, \u03b2 x \u2192 Bool) (s : Finmap \u03b2) : 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 : \u2200 x, \u03b2 x \u2192 Bool) (s : Finmap \u03b2) : 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 \u03b1]\n\n#print Finmap.erase /-\n/-- Erase a key from the map. If the key is not present it does nothing. -/\ndef erase (a : \u03b1) (s : Finmap \u03b2) : Finmap \u03b2 :=\n  liftOn s (fun t => \u27e6erase a t\u27e7) fun s\u2081 s\u2082 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 : \u03b1) (s : AList \u03b2) : erase a \u27e6s\u27e7 = \u27e6s.erase\u2093 a\u27e7 := 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 : \u03b1) (s : AList \u03b2) : keys \u27e6s.erase\u2093 a\u27e7 = (keys \u27e6s\u27e7).erase\u2093 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 : \u03b1) (s : Finmap \u03b2) : (erase a s).keys = s.keys.erase\u2093 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' : \u03b1} {s : Finmap \u03b2} : a' \u2208 erase a s \u2194 a' \u2260 a \u2227 a' \u2208 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 : \u03b1} {s : Finmap \u03b2} : \u00aca \u2208 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 \u03b2) : 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 \u03b2} (h : a \u2260 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' : \u03b1} {s : Finmap \u03b2} : 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 \u03b2) : Finmap \u03b2 :=\n  s'.foldl (fun s x _ => s.erase\u2093 x) (fun a\u2080 a\u2081 _ a\u2082 _ => erase_erase) s\n#align finmap.sdiff Finmap.sdiff\n-/\n\ninstance : SDiff (Finmap \u03b2) :=\n  \u27e8sdiff\u27e9\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 : \u03b1) (b : \u03b2 a) (s : Finmap \u03b2) : Finmap \u03b2 :=\n  liftOn s (fun t => \u27e6insert a b t\u27e7) fun s\u2081 s\u2082 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 : \u03b1) (b : \u03b2 a) (s : AList \u03b2) : insert a b \u27e6s\u27e7 = \u27e6s.insert a b\u27e7 := 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 : \u03b1} {b : \u03b2 a} {s : Finmap \u03b2} :\n    a \u2209 s \u2192 (insert a b s).entries = \u27e8a, b\u27e9 ::\u2098 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' : \u03b1} {b' : \u03b2 a'} {s : Finmap \u03b2} : a \u2208 insert a' b' s \u2194 a = a' \u2228 a \u2208 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 : \u03b2 a} (s : Finmap \u03b2) : 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 : \u03b2 a} (s : Finmap \u03b2) (h : a' \u2260 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' : \u03b2 a} (s : Finmap \u03b2) :\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 : \u03b2 a} {b' : \u03b2 a'} (s : Finmap \u03b2) (h : a \u2260 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 : \u03b1) (b : \u03b2 a) (xs : List (Sigma \u03b2)) :\n    List.toFinmap (\u27e8a, b\u27e9 :: 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 : \u03b1) (xs : List (Sigma \u03b2)) :\n    a \u2208 xs.toFinmap \u2194 \u2203 b : \u03b2 a, Sigma.mk a b \u2208 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 [\u2190 and_true_iff (a = x_fst)]\n  apply and_congr_right\n  rintro \u27e8\u27e9\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 : \u03b1} {b b' : \u03b2 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 : \u03b1) (s : Finmap \u03b2) : Option (\u03b2 a) \u00d7 Finmap \u03b2 :=\n  liftOn s (fun t => Prod.map id toFinmap (extract a t)) fun s\u2081 s\u2082 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 : \u03b1) (s : Finmap \u03b2) : 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\u2081 \u222a s\u2082` is the key-based union of two finite maps. It is left-biased: if\nthere exists an `a \u2208 s\u2081`, `lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081`. -/\ndef union (s\u2081 s\u2082 : Finmap \u03b2) : Finmap \u03b2 :=\n  liftOn\u2082 s\u2081 s\u2082 (fun s\u2081 s\u2082 => \u27e6s\u2081 \u222a s\u2082\u27e7) fun s\u2081 s\u2082 s\u2083 s\u2084 p\u2081\u2083 p\u2082\u2084 =>\n    toFinmap_eq.mpr <| perm_union p\u2081\u2083 p\u2082\u2084\n#align finmap.union Finmap.union\n-/\n\ninstance : Union (Finmap \u03b2) :=\n  \u27e8union\u27e9\n\n#print Finmap.mem_union /-\n@[simp]\ntheorem mem_union {a} {s\u2081 s\u2082 : Finmap \u03b2} : a \u2208 s\u2081 \u222a s\u2082 \u2194 a \u2208 s\u2081 \u2228 a \u2208 s\u2082 :=\n  induction_on\u2082 s\u2081 s\u2082 fun _ _ => mem_union\n#align finmap.mem_union Finmap.mem_union\n-/\n\n#print Finmap.union_toFinmap /-\n@[simp]\ntheorem union_toFinmap (s\u2081 s\u2082 : AList \u03b2) : \u27e6s\u2081\u27e7 \u222a \u27e6s\u2082\u27e7 = \u27e6s\u2081 \u222a s\u2082\u27e7 := by simp [(\u00b7 \u222a \u00b7), union]\n#align finmap.union_to_finmap Finmap.union_toFinmap\n-/\n\n#print Finmap.keys_union /-\ntheorem keys_union {s\u2081 s\u2082 : Finmap \u03b2} : (s\u2081 \u222a s\u2082).keys = s\u2081.keys \u222a s\u2082.keys :=\n  induction_on\u2082 s\u2081 s\u2082 fun s\u2081 s\u2082 => 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\u2081 s\u2082 : Finmap \u03b2} : a \u2208 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081 :=\n  induction_on\u2082 s\u2081 s\u2082 fun s\u2081 s\u2082 => 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\u2081 s\u2082 : Finmap \u03b2} : a \u2209 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2082 :=\n  induction_on\u2082 s\u2081 s\u2082 fun s\u2081 s\u2082 => 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\u2081 s\u2082 : Finmap \u03b2} (h : a \u2209 s\u2082) :\n    lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081 :=\n  by\n  by_cases h' : a \u2208 s\u2081\n  \u00b7 rw [lookup_union_left h']\n  \u00b7 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 : \u03b2 a} {s\u2081 s\u2082 : Finmap \u03b2} :\n    b \u2208 lookup a (s\u2081 \u222a s\u2082) \u2194 b \u2208 lookup a s\u2081 \u2228 a \u2209 s\u2081 \u2227 b \u2208 lookup a s\u2082 :=\n  induction_on\u2082 s\u2081 s\u2082 fun s\u2081 s\u2082 => 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 : \u03b2 a} {s\u2081 s\u2082 s\u2083 : Finmap \u03b2} :\n    b \u2208 lookup a (s\u2081 \u222a s\u2083) \u2192 a \u2209 s\u2082 \u2192 b \u2208 lookup a (s\u2081 \u222a s\u2082 \u222a s\u2083) :=\n  induction_on\u2083 s\u2081 s\u2082 s\u2083 fun s\u2081 s\u2082 s\u2083 => 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 : \u03b2 a} {s\u2081 s\u2082 : Finmap \u03b2} : insert a b (s\u2081 \u222a s\u2082) = insert a b s\u2081 \u222a s\u2082 :=\n  induction_on\u2082 s\u2081 s\u2082 fun a\u2081 a\u2082 => by simp [insert_union]\n#align finmap.insert_union Finmap.insert_union\n-/\n\n#print Finmap.union_assoc /-\ntheorem union_assoc {s\u2081 s\u2082 s\u2083 : Finmap \u03b2} : s\u2081 \u222a s\u2082 \u222a s\u2083 = s\u2081 \u222a (s\u2082 \u222a s\u2083) :=\n  induction_on\u2083 s\u2081 s\u2082 s\u2083 fun s\u2081 s\u2082 s\u2083 => 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\u2081 : Finmap \u03b2} : \u2205 \u222a s\u2081 = s\u2081 :=\n  induction_on s\u2081 fun s\u2081 => by\n    rw [\u2190 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\u2081 : Finmap \u03b2} : s\u2081 \u222a \u2205 = s\u2081 :=\n  induction_on s\u2081 fun s\u2081 => by\n    rw [\u2190 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 : \u03b1) (b : \u03b2 a) (s : Finmap \u03b2) (h : s.dlookup a = some b) :\n    s.erase\u2093 a \u222a singleton a b = s :=\n  ext_lookup fun x => by\n    by_cases h' : x = a\n    \u00b7 subst a\n      rw [lookup_union_right not_mem_erase_self, lookup_singleton_eq, h]\n    \u00b7 have : x \u2209 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\u2081 s\u2082` holds if `s\u2081` and `s\u2082` have no keys in common. -/\ndef Disjoint (s\u2081 s\u2082 : Finmap \u03b2) : Prop :=\n  \u2200 x \u2208 s\u2081, \u00acx \u2208 s\u2082\n#align finmap.disjoint Finmap.Disjoint\n-/\n\n#print Finmap.disjoint_empty /-\ntheorem disjoint_empty (x : Finmap \u03b2) : Disjoint \u2205 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 \u03b2) (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 \u03b2) : Disjoint x y \u2194 Disjoint y x :=\n  \u27e8Disjoint.symm x y, Disjoint.symm y x\u27e9\n#align finmap.disjoint.symm_iff Finmap.Disjoint.symm_iff\n-/\n\nsection\n\nvariable [DecidableEq \u03b1]\n\ninstance : DecidableRel (@Disjoint \u03b1 \u03b2) := fun x y => by dsimp only [Disjoint] <;> infer_instance\n\n#print Finmap.disjoint_union_left /-\ntheorem disjoint_union_left (x y z : Finmap \u03b2) : Disjoint (x \u222a y) z \u2194 Disjoint x z \u2227 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 \u03b2) :\n    Disjoint x (y \u222a z) \u2194 Disjoint x y \u2227 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\u2081 s\u2082 : Finmap \u03b2} : Disjoint s\u2081 s\u2082 \u2192 s\u2081 \u222a s\u2082 = s\u2082 \u222a s\u2081 :=\n  induction_on\u2082 s\u2081 s\u2082 fun s\u2081 s\u2082 => 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\u2081 s\u2082 s\u2083 : Finmap \u03b2} (h : Disjoint s\u2081 s\u2083) (h' : Disjoint s\u2082 s\u2083) :\n    s\u2081 \u222a s\u2083 = s\u2082 \u222a s\u2083 \u2194 s\u2081 = s\u2082 :=\n  \u27e8fun h'' => by\n    apply ext_lookup\n    intro x\n    have : (s\u2081 \u222a s\u2083).dlookup x = (s\u2082 \u222a s\u2083).dlookup x := h'' \u25b8 rfl\n    by_cases hs\u2081 : x \u2208 s\u2081\n    \u00b7 rwa [lookup_union_left hs\u2081, lookup_union_left_of_not_in (h _ hs\u2081)] at this\n    \u00b7 by_cases hs\u2082 : x \u2208 s\u2082\n      \u00b7 rwa [lookup_union_left_of_not_in (h' _ hs\u2082), lookup_union_left hs\u2082] at this\n      \u00b7 rw [lookup_eq_none.mpr hs\u2081, lookup_eq_none.mpr hs\u2082], fun h => h \u25b8 rfl\u27e9\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\u00e9d\u00e9ric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Fr\u00e9d\u00e9ric Dupuis\n-/\nimport analysis.inner_product_space.projection\nimport analysis.normed_space.dual\n\n/-!\n# The Fr\u00e9chet-Riesz representation theorem\n\nWe consider an inner product space `E` over `\ud835\udd5c`, which is either `\u211d` or `\u2102`. 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 `\u03bb y, \u27eax, y\u27eb`.\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\u00e9chet-Riesz representation theorem: every element of\nthe dual of a Hilbert space `E` has the form `\u03bb u, \u27eax, u\u27eb` 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\u00e9chet-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 (\ud835\udd5c : Type*)\nvariables (E : Type*) [is_R_or_C \ud835\udd5c] [inner_product_space \ud835\udd5c E]\nlocal notation `\u27ea`x`, `y`\u27eb` := @inner \ud835\udd5c E _ x y\nlocal postfix `\u2020`:90 := star_ring_aut\n\n/--\nAn element `x` of an inner product space `E` induces an element of the dual space `dual \ud835\udd5c E`,\nthe map `\u03bb y, \u27eax, y\u27eb`; moreover this operation is a conjugate-linear isometric embedding of `E`\ninto `dual \ud835\udd5c E`.\nIf `E` is complete, this operation is surjective, hence a conjugate-linear isometric equivalence;\nsee `to_dual`.\n-/\ndef to_dual_map : E \u2192\u2097\u1d62\u22c6[\ud835\udd5c] normed_space.dual \ud835\udd5c E :=\n{ to_fun := \u03bb x, linear_map.mk_continuous\n    { to_fun := \u03bb y, \u27eax, y\u27eb,\n      map_add' := \u03bb _ _, inner_add_right,\n      map_smul' := \u03bb _ _, inner_smul_right }\n    \u2225x\u2225\n    (\u03bb y, by { rw [is_R_or_C.norm_eq_abs], exact abs_inner_le_norm _ _ }),\n  map_add' := \u03bb x y, by { ext z, simp [inner_add_left] },\n  map_smul' := \u03bb c y, by { ext z, simp [inner_smul_left] },\n  norm_map' := \u03bb 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 \u2225x\u2225 * \u2225x\u2225 = \u2225x\u2225 ^ 2 : by ring\n        ... = re \u27eax, x\u27eb : norm_sq_eq_inner _\n        ... \u2264 abs \u27eax, x\u27eb : re_le_abs _\n        ... = \u2225linear_map.mk_continuous _ _ _ x\u2225 : by simp [norm_eq_abs]\n        ... \u2264 \u2225linear_map.mk_continuous _ _ _\u2225 * \u2225x\u2225 : le_op_norm _ x } }\n  end }\n\nvariables {E}\n\n@[simp] lemma to_dual_map_apply {x y : E} : to_dual_map \ud835\udd5c E x y = \u27eax, y\u27eb := rfl\n\nvariables (E) [complete_space E]\n\n/--\nFr\u00e9chet-Riesz representation: any `\u2113` in the dual of a Hilbert space `E` is of the form\n`\u03bb u, \u27eay, u\u27eb` for some `y : E`, i.e. `to_dual_map` is surjective.\n-/\ndef to_dual : E \u2243\u2097\u1d62\u22c6[\ud835\udd5c] normed_space.dual \ud835\udd5c E :=\nlinear_isometry_equiv.of_surjective (to_dual_map \ud835\udd5c E)\nbegin\n  intros \u2113,\n  set Y := ker \u2113 with hY,\n  by_cases htriv : Y = \u22a4,\n  { have h\u2113 : \u2113 = 0,\n    { have h' := linear_map.ker_eq_top.mp htriv,\n      rw [\u2190coe_zero] at h',\n      apply coe_injective,\n      exact h' },\n    exact \u27e80, by simp [h\u2113]\u27e9 },\n  { rw [\u2190 submodule.orthogonal_eq_bot_iff] at htriv,\n    change Y\u15ee \u2260 \u22a5 at htriv,\n    rw [submodule.ne_bot_iff] at htriv,\n    obtain \u27e8z : E, hz : z \u2208 Y\u15ee, z_ne_0 : z \u2260 0\u27e9 := htriv,\n    refine \u27e8((\u2113 z)\u2020 / \u27eaz, z\u27eb) \u2022 z, _\u27e9,\n    ext x,\n    have h\u2081 : (\u2113 z) \u2022 x - (\u2113 x) \u2022 z \u2208 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 (\u2113 x * \u2113 z) },\n    have h\u2082 : (\u2113 z) * \u27eaz, x\u27eb = (\u2113 x) * \u27eaz, z\u27eb,\n    { have h\u2083 := calc\n        0    = \u27eaz, (\u2113 z) \u2022 x - (\u2113 x) \u2022 z\u27eb       : by { rw [(Y.mem_orthogonal' z).mp hz], exact h\u2081 }\n         ... = \u27eaz, (\u2113 z) \u2022 x\u27eb - \u27eaz, (\u2113 x) \u2022 z\u27eb  : by rw [inner_sub_right]\n         ... = (\u2113 z) * \u27eaz, x\u27eb - (\u2113 x) * \u27eaz, z\u27eb  : by simp [inner_smul_right],\n      exact sub_eq_zero.mp (eq.symm h\u2083) },\n    have h\u2084 := calc\n      \u27ea((\u2113 z)\u2020 / \u27eaz, z\u27eb) \u2022 z, x\u27eb = (\u2113 z) / \u27eaz, z\u27eb * \u27eaz, x\u27eb\n            : by simp [inner_smul_left, ring_equiv.map_div, conj_conj]\n                            ... = (\u2113 z) * \u27eaz, x\u27eb / \u27eaz, z\u27eb\n            : by rw [\u2190div_mul_eq_mul_div]\n                            ... = (\u2113 x) * \u27eaz, z\u27eb / \u27eaz, z\u27eb\n            : by rw [h\u2082]\n                            ... = \u2113 x\n            : begin\n                have : \u27eaz, z\u27eb \u2260 0,\n                { change z = 0 \u2192 false at z_ne_0,\n                  rwa \u2190inner_self_eq_zero at z_ne_0 },\n                field_simp [this]\n              end,\n    exact h\u2084 }\nend\n\nvariables {E}\n\n@[simp] lemma to_dual_apply {x y : E} : to_dual \ud835\udd5c E x y = \u27eax, y\u27eb := rfl\n\n@[simp] lemma to_dual_symm_apply {x : E} {y : normed_space.dual \ud835\udd5c E} :\n  \u27ea(to_dual \ud835\udd5c E).symm y, x\u27eb = y x :=\nbegin\n  rw \u2190 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' {\u0393 : ctxPA agents} (n : nat) (\u03c6 : formPA agents) (h : complexity \u03c6 \u2264 n) : \n  prfPA \u0393 (\u03c6 \u2194 to_PA (translate \u03c6)) :=\nbegin\n  simp at *,\n  induction n with n ih generalizing \u03c6,\n  { have h1 : complexity \u03c6 > 0, from comp_gt_zero, linarith},\n  cases \u03c6,\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 : \u03c6 \u03c8 \n    { rw translate,\n      exact iff_iff_and_iff (ih \u03c6 (compand1 h)) (ih \u03c8 (compand2 h))\n    },\n  case formPA.impl : \u03c6 \u03c8 \n    { rw translate,\n      repeat {rw to_PA},\n      exact iff_iff_imp_iff (ih \u03c6 (compimp1 h)) (ih \u03c8 (compimp2 h))\n    },\n  case formPA.box : a \u03c6 \n    { simp at *,\n      have h1 : complexity \u03c6 \u2264 n, from nat.lt_succ_iff.mp (nat.one_add_le_iff.mp h),\n      exact iff_k_dist (ih \u03c6 h1), \n    },\n  case formPA.update : \u03c6 \u03c8 \n    { cases \u03c8,\n      case formPA.bot \n        { repeat {rw translate},\n          repeat {rw complexity at h},\n          have h1 : complexity \u03c6 \u2264 n, \n            {have : complexity \u03c6 + 1 \u2264 nat.succ n, linarith,\n             exact nat.lt_succ_iff.mp this},\n          have h2 := atomicbot, \n          exact update_iff1 (ih \u03c6 h1) h2\n        },\n      case formPA.var : m \n        { repeat {rw translate},\n          repeat {rw complexity at h},\n          have h1 : complexity \u03c6 \u2264 n, \n            {have : complexity \u03c6 + 1 \u2264 nat.succ n, linarith,\n             exact nat.lt_succ_iff.mp this},\n          have h2 := atomicperm, \n          exact update_iff1 (ih \u03c6 h1) h2\n        },\n      case formPA.and : \u03c8 \u03c7 \n        { repeat {rw translate},\n          exact update_iff2 (ih (U \u03c6 \u03c8) (updatecompand1 h)) (ih (U \u03c6 \u03c7) (updatecompand2 h)) announceconj,\n        },\n      case formPA.impl : \u03c8 \u03c7\n        { repeat {rw translate},\n          exact update_iff3 (ih (U \u03c6 \u03c8) (updatecompimp1 h)) (ih (U \u03c6 \u03c7) (updatecompimp2 h)) announceimp,\n        },\n      case formPA.box : a \u03c8\n        { repeat {rw translate}, \n          exact update_iff4 announceknow (ih (\u03c6 \u2283 K a (U \u03c6 \u03c8)) (updatecompknow2 h))\n        },\n      case formPA.update : \u03c8 \u03c7\n        { rw translate, \n          exact update_iff5 announcecomp (ih (U (\u03c6 & (U \u03c6 \u03c8)) \u03c7) (updatecompupdate h))\n        } \n    }\nend\n\n\ntheorem equiv_translation (\u0393 : ctxPA agents) : \u2200 \u03c6 : formPA agents, prfPA \u0393 (\u03c6 \u2194 to_PA (translate \u03c6)) :=\nbegin\nintro \u03c6,\nhave h : complexity \u03c6 \u2264 complexity \u03c6 + 1, linarith,\nsimp,\nexact equiv_translation_aux' (complexity \u03c6 + 1) \u03c6 h\nend\n\n\nlemma forces_ctxPA_iff_forces_ctx (f : frame agents) \n  (v : nat \u2192 f.states \u2192 Prop) : \n  forces_ctxPA f v \u2205 \u2194 forces_ctx f v \u2205 :=\nbegin\nsplit,\nrepeat {intros h1 \u03c6 x h2,\nexact false.elim h2},\nend\n\n\nlemma global_sem_csqPA_iff_global_sem_csq (F : set (frame agents)) (\u03c6 : form agents) : \n  global_sem_csqPA \u2205 F (to_PA \u03c6) \u2194 global_sem_csq \u2205 F \u03c6 :=\nbegin\nsplit,\nintros h1 f h2 v h3 x,\nhave h4 := (forces_ctxPA_iff_forces_ctx f v).mpr h3,\nexact (forcesPA_iff_forces \u03c6 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 \u03c6 f v x).mpr (h1 f h2 v h4 x)\nend\n\n\ntheorem completenessPA {\u03c6 : formPA agents} (\u0393 : ctxPA agents) : \n  global_sem_csqPA \u2205 equiv_class \u03c6 \u2192 prfPA \u2205 \u03c6 :=\nbegin\nintros h1,\nhave h2 := mp pl5 (equiv_translation \u2205 \u03c6),\nhave h3 := soundnessPA,\nhave h4 : global_sem_csqPA \u2205 equiv_class (to_PA (translate \u03c6)), \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 \u03c6) ).mp h4,\nhave h6 := canonical.completeness sem_consS5 (translate \u03c6),\nhave h7 := to_prfPA (h6 h5),\nsimp at *,\nexact mp (mp pl6 (equiv_translation \u2205 \u03c6)) 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 {\u03b1 : Sort u} (a : \u03b1) : \u03b1 \u2192 Prop where\n  | intro : Eq a a\n\ninductive Nonempty (\u03b1 : Sort u) : Prop where\n  | intro : \u03b1 \u2192 Nonempty \u03b1\n\ntheorem elim_from_prop_is_bad\n(choice : \u2200{\u03b1}, Nonempty \u03b1 \u2192 \u03b1) :\n\u00ac({\u03b1 : Type u} \u2192 {x : \u03b1} \u2192 choice \u27e8x\u27e9 = x) := by\n  intro h\n  let true' : ULift Bool := \u27e8true\u27e9\n  let false' : ULift Bool := \u27e8false\u27e9\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] {\u03b1 : Sort u}\n(h : p \u2228 q) (fp : p \u2192 \u03b1) (fq : q \u2192 \u03b1) : \u03b1 :=\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 \u2192 Sort u}\n(h : (n : Nat) \u2192 ((m : Nat) \u2192 m < n \u2192 p m) \u2192 p n)\n(n : Nat) : p n :=\n  h n (aux n)\nwhere\n  aux : (n m : Nat) \u2192 m < n \u2192 p m\n    | 0, m, h\u2081 => absurd h\u2081 (Nat.not_lt_zero m)\n    | n+1, m, h\u2081 => Or.by_cases (Nat.eq_or_lt_of_le (Nat.le_of_lt_succ h\u2081))\n      (\u03bb h\u2082 => h\u2082 \u25b8 h n (aux n))\n      (\u03bb h\u2082 => (aux n) m h\u2082)\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 \u2964 D` and `G : D \u2964 C` such\nthat `\u03b7 : \ud835\udfed C \u2245 F \u22d9 G` and `\u03b5 : G \u22d9 F \u2245 \ud835\udfed 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 \u2964 D` and `G : D \u2964 C` are adjoint is using\ntwo natural transformations `\u03b7 : \ud835\udfed C \u27f6 F \u22d9 G` and `\u03b5 : G \u22d9 F \u27f6 \ud835\udfed D`, called the unit and the\ncounit, such that the compositions `F \u27f6 FGF \u27f6 F` and `G \u27f6 GFG \u27f6 G` are the identity. Unfortunately,\nit is not the case that the natural isomorphisms `\u03b7` and `\u03b5` 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 `\u03b7` 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, \u03b7, \u03b5)` as in the first paragraph such that the composite `F \u27f6 FGF \u27f6 F` is the\nidentity. By the remark above, this already implies that the tuple is an \"adjoint equivalence\",\ni.e., that the composite `G \u27f6 GFG \u27f6 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 `\u03b7` and `\u03b5`.\n* `ess_surj`: type class on a functor `F` containing the data of the preimages and the isomorphisms\n  `F.obj (preimage d) \u2245 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 \u224c D` (`\\backcong`, not to be confused with `\u2245`/`\\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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\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\u03b7 \u226b \u03b5F = 1`, or in other\n  words the composite `F \u27f6 FGF \u27f6 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 \u27f6 GFG \u27f6 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 \u27f6 F1`.\n\nSee <https://stacks.math.columbia.edu/tag/001J>\n-/\nstructure equivalence (C : Type u\u2081) [category.{v\u2081} C] (D : Type u\u2082) [category.{v\u2082} D] :=\nmk' ::\n(functor : C \u2964 D)\n(inverse : D \u2964 C)\n(unit_iso   : \ud835\udfed C \u2245 functor \u22d9 inverse)\n(counit_iso : inverse \u22d9 functor \u2245 \ud835\udfed D)\n(functor_unit_iso_comp' : \u2200(X : C), functor.map ((unit_iso.hom : \ud835\udfed C \u27f6 functor \u22d9 inverse).app X) \u226b\n  counit_iso.hom.app (functor.obj X) = \ud835\udfd9 (functor.obj X) . obviously)\n\nrestate_axiom equivalence.functor_unit_iso_comp'\n\ninfixr ` \u224c `:10  := equivalence\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} D]\n\nnamespace equivalence\n\n/-- The unit of an equivalence of categories. -/\nabbreviation unit (e : C \u224c D) : \ud835\udfed C \u27f6 e.functor \u22d9 e.inverse := e.unit_iso.hom\n/-- The counit of an equivalence of categories. -/\nabbreviation counit (e : C \u224c D) : e.inverse \u22d9 e.functor \u27f6 \ud835\udfed D := e.counit_iso.hom\n/-- The inverse of the unit of an equivalence of categories. -/\nabbreviation unit_inv (e : C \u224c D) : e.functor \u22d9 e.inverse \u27f6 \ud835\udfed C := e.unit_iso.inv\n/-- The inverse of the counit of an equivalence of categories. -/\nabbreviation counit_inv (e : C \u224c D) : \ud835\udfed D \u27f6 e.inverse \u22d9 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  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).unit = unit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).counit = counit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_unit_inv (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).unit_inv = unit_iso.inv := rfl\n@[simp] lemma equivalence_mk'_counit_inv (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).counit_inv = counit_iso.inv := rfl\n\n@[simp] lemma functor_unit_comp (e : C \u224c D) (X : C) :\n  e.functor.map (e.unit.app X) \u226b e.counit.app (e.functor.obj X) = \ud835\udfd9 (e.functor.obj X) :=\ne.functor_unit_iso_comp X\n\n@[simp] lemma counit_inv_functor_comp (e : C \u224c D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) \u226b e.functor.map (e.unit_inv.app X) = \ud835\udfd9 (e.functor.obj X) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.functor.map_iso (e.unit_iso.app X) \u226a\u226b 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 \u224c D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) = e.functor.map (e.unit.app X) :=\nby { symmetry, erw [\u2190iso.comp_hom_eq_id (e.counit_iso.app _), functor_unit_comp], refl }\n\nlemma counit_app_functor (e : C \u224c D) (X : C) :\n  e.counit.app (e.functor.obj X) = e.functor.map (e.unit_inv.app X) :=\nby { erw [\u2190iso.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 \u224c D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) \u226b e.inverse.map (e.counit.app Y) = \ud835\udfd9 (e.inverse.obj Y) :=\nbegin\n  rw [\u2190id_comp (e.inverse.map _), \u2190map_id e.inverse, \u2190counit_inv_functor_comp, map_comp],\n  dsimp,\n  rw [\u2190iso.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 [\u2190iso.hom_inv_id_assoc (e.inverse.map_iso (e.counit_iso.app _)) (e.unit_inv.app _)] },\n  slice_lhs 3 4 { erw [\u2190map_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 [\u2190map_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 [\u2190map_comp (e.functor \u22d9 e.inverse), (e.unit_iso.app _).hom_inv_id, map_id] },\n  erw [id_comp],\n  slice_lhs 3 4 { erw [\u2190e.unit_inv.naturality] },\n  slice_lhs 2 3 { erw [\u2190map_comp e.inverse, \u2190e.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 \u224c D) (Y : D) :\n  e.inverse.map (e.counit_inv.app Y) \u226b e.unit_inv.app (e.inverse.obj Y) = \ud835\udfd9 (e.inverse.obj Y) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.unit_iso.app (e.inverse.obj Y) \u226a\u226b 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 \u224c D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counit_inv.app Y) :=\nby { erw [\u2190iso.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 \u224c D) (Y : D) :\n  e.unit_inv.app (e.inverse.obj Y) = e.inverse.map (e.counit.app Y) :=\nby { symmetry, erw [\u2190iso.hom_comp_eq_id (e.unit_iso.app _), unit_inverse_comp], refl }\n\n@[simp] lemma fun_inv_map (e : C \u224c D) (X Y : D) (f : X \u27f6 Y) :\n  e.functor.map (e.inverse.map f) = e.counit.app X \u226b f \u226b e.counit_inv.app Y :=\n(nat_iso.naturality_2 (e.counit_iso) f).symm\n\n@[simp] lemma inv_fun_map (e : C \u224c D) (X Y : C) (f : X \u27f6 Y) :\n  e.inverse.map (e.functor.map f) = e.unit_inv.app X \u226b f \u226b 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 \u2964 D} {G : D \u2964 C} (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D)\n\n/-- If `\u03b7 : \ud835\udfed C \u2245 F \u22d9 G` is part of a (not necessarily half-adjoint) equivalence, we can upgrade it\nto a refined natural isomorphism `adjointify_\u03b7 \u03b7 : \ud835\udfed C \u2245 F \u22d9 G` which exhibits the properties\nrequired for a half-adjoint equivalence. See `equivalence.mk`. -/\ndef adjointify_\u03b7 : \ud835\udfed C \u2245 F \u22d9 G :=\ncalc\n  \ud835\udfed C \u2245 F \u22d9 G               : \u03b7\n  ... \u2245 F \u22d9 (\ud835\udfed D \u22d9 G)      : iso_whisker_left F (left_unitor G).symm\n  ... \u2245 F \u22d9 ((G \u22d9 F) \u22d9 G) : iso_whisker_left F (iso_whisker_right \u03b5.symm G)\n  ... \u2245 F \u22d9 (G \u22d9 (F \u22d9 G)) : iso_whisker_left F (associator G F G)\n  ... \u2245 (F \u22d9 G) \u22d9 (F \u22d9 G) : (associator F G (F \u22d9 G)).symm\n  ... \u2245 \ud835\udfed C \u22d9 (F \u22d9 G)      : iso_whisker_right \u03b7.symm (F \u22d9 G)\n  ... \u2245 F \u22d9 G               : left_unitor (F \u22d9 G)\n\nlemma adjointify_\u03b7_\u03b5 (X : C) :\n  F.map ((adjointify_\u03b7 \u03b7 \u03b5).hom.app X) \u226b \u03b5.hom.app (F.obj X) = \ud835\udfd9 (F.obj X) :=\nbegin\n  dsimp [adjointify_\u03b7], simp,\n  have := \u03b5.hom.naturality (F.map (\u03b7.inv.app X)), dsimp at this, rw [this], clear this,\n  rw [\u2190assoc _ _ (F.map _)],\n  have := \u03b5.hom.naturality (\u03b5.inv.app $ F.obj X), dsimp at this, rw [this], clear this,\n  have := (\u03b5.app $ F.obj X).hom_inv_id, dsimp at this, rw [this], clear this,\n  rw [id_comp], have := (F.map_iso $ \u03b7.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 \u22d9 G` and\n    `G \u22d9 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 \u2964 D) (G : D \u2964 C)\n  (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D) : C \u224c D :=\n\u27e8F, G, adjointify_\u03b7 \u03b7 \u03b5, \u03b5, adjointify_\u03b7_\u03b5 \u03b7 \u03b5\u27e9\n\n/-- Equivalence of categories is reflexive. -/\n@[refl, simps] def refl : C \u224c C :=\n\u27e8\ud835\udfed C, \ud835\udfed C, iso.refl _, iso.refl _, \u03bb X, category.id_comp _\u27e9\n\ninstance : inhabited (C \u224c C) :=\n\u27e8refl\u27e9\n\n/-- Equivalence of categories is symmetric. -/\n@[symm, simps] def symm (e : C \u224c D) : D \u224c C :=\n\u27e8e.inverse, e.functor, e.counit_iso.symm, e.unit_iso.symm, e.inverse_counit_inv_comp\u27e9\n\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\n/-- Equivalence of categories is transitive. -/\n@[trans, simps] def trans (e : C \u224c D) (f : D \u224c E) : C \u224c E :=\n{ functor := e.functor \u22d9 f.functor,\n  inverse := f.inverse \u22d9 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' := \u03bb X,\n  begin\n    dsimp,\n    rw [\u2190 f.functor.map_comp_assoc, e.functor.map_comp, \u2190counit_inv_app_functor, fun_inv_map,\n        iso.inv_hom_id_app_assoc, assoc, iso.inv_hom_id_app, counit_app_functor,\n        \u2190 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 \u224c D) (F : C \u2964 E) : e.functor \u22d9 e.inverse \u22d9 F \u2245 F :=\n(functor.associator _ _ _).symm \u226a\u226b iso_whisker_right e.unit_iso.symm F \u226a\u226b F.left_unitor\n\n@[simp] lemma fun_inv_id_assoc_hom_app (e : C \u224c D) (F : C \u2964 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 \u224c D) (F : C \u2964 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 \u224c D) (F : D \u2964 E) : e.inverse \u22d9 e.functor \u22d9 F \u2245 F :=\n(functor.associator _ _ _).symm \u226a\u226b iso_whisker_right e.counit_iso F \u226a\u226b F.left_unitor\n\n@[simp] lemma inv_fun_id_assoc_hom_app (e : C \u224c D) (F : D \u2964 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 \u224c D) (F : D \u2964 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 \u2964 E` is equivalent to `D \u2964 E`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_left (e : C \u224c D) : (C \u2964 E) \u224c (D \u2964 E) :=\nequivalence.mk\n  ((whiskering_left _ _ _).obj e.inverse)\n  ((whiskering_left _ _ _).obj e.functor)\n  (nat_iso.of_components (\u03bb F, (e.fun_inv_id_assoc F).symm) (by tidy))\n  (nat_iso.of_components (\u03bb F, e.inv_fun_id_assoc F) (by tidy))\n\n/-- If `C` is equivalent to `D`, then `E \u2964 C` is equivalent to `E \u2964 D`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_right (e : C \u224c D) : (E \u2964 C) \u224c (E \u2964 D) :=\nequivalence.mk\n  ((whiskering_right _ _ _).obj e.functor)\n  ((whiskering_right _ _ _).obj e.inverse)\n  (nat_iso.of_components\n    (\u03bb F, F.right_unitor.symm \u226a\u226b iso_whisker_left F e.unit_iso \u226a\u226b functor.associator _ _ _)\n    (by tidy))\n  (nat_iso.of_components\n    (\u03bb F, functor.associator _ _ _ \u226a\u226b iso_whisker_left F e.counit_iso \u226a\u226b F.right_unitor)\n    (by tidy))\n\nsection cancellation_lemmas\nvariables (e : C \u224c 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 \u27f6 Y) :\n  f \u226b e.unit.app Y = f' \u226b e.unit.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_inv_right {X Y : C}\n  (f f' : X \u27f6 e.inverse.obj (e.functor.obj Y))   :\n  f \u226b e.unit_inv.app Y = f' \u226b e.unit_inv.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_right {X Y : D}\n  (f f' : X \u27f6 e.functor.obj (e.inverse.obj Y))   :\n  f \u226b e.counit.app Y = f' \u226b e.counit.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right {X Y : D}\n  (f f' : X \u27f6 Y) :\n  f \u226b e.counit_inv.app Y = f' \u226b e.counit_inv.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc {W X X' Y : C}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y) :\n  f \u226b g \u226b e.unit.app Y = f' \u226b g' \u226b e.unit.app Y \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right_assoc {W X X' Y : D}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y) :\n  f \u226b g \u226b e.counit_inv.app Y = f' \u226b g' \u226b e.counit_inv.app Y \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc' {W X X' Y Y' Z : C}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (h : Y \u27f6 Z) (f' : W \u27f6 X') (g' : X' \u27f6 Y') (h' : Y' \u27f6 Z) :\n  f \u226b g \u226b h \u226b e.unit.app Z = f' \u226b g' \u226b h' \u226b e.unit.app Z \u2194 f \u226b g \u226b h = f' \u226b g' \u226b h' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] \n\nend cancellation_lemmas\n\nsection\n\n-- There's of course a monoid structure on `C \u224c 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 \u224c C) : \u2115 \u2192 (C \u224c 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 \u224c C) : \u2124 \u2192 (C \u224c 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 \u224c C) \u2124 := \u27e8pow\u27e9\n\n@[simp] lemma pow_zero (e : C \u224c C) : e^(0 : \u2124) = equivalence.refl := rfl\n@[simp] lemma pow_one (e : C \u224c C) : e^(1 : \u2124) = e := rfl\n@[simp] lemma pow_neg_one (e : C \u224c C) : e^(-1 : \u2124) = e.symm := rfl\n\n-- TODO as necessary, add the natural isomorphisms `(e^a).trans e^b \u2245 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 \u2964 D) :=\nmk' ::\n(inverse    : D \u2964 C)\n(unit_iso   : \ud835\udfed C \u2245 F \u22d9 inverse)\n(counit_iso : inverse \u22d9 F \u2245 \ud835\udfed D)\n(functor_unit_iso_comp' : \u2200 (X : C), F.map ((unit_iso.hom : \ud835\udfed C \u27f6 F \u22d9 inverse).app X) \u226b\n  counit_iso.hom.app (F.obj X) = \ud835\udfd9 (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 \u224c D) : is_equivalence F.functor :=\n{ ..F }\n\ninstance of_equivalence_inverse (F : C \u224c 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 \u22d9 G` and `G \u22d9 F` are naturally isomorphic to identity functors. -/\nprotected definition mk {F : C \u2964 D} (G : D \u2964 C)\n  (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D) : is_equivalence F :=\n\u27e8G, adjointify_\u03b7 \u03b7 \u03b5, \u03b5, adjointify_\u03b7_\u03b5 \u03b7 \u03b5\u27e9\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 \u2964 D) [is_equivalence F] : C \u224c D :=\n\u27e8F, is_equivalence.inverse F, is_equivalence.unit_iso, is_equivalence.counit_iso,\n  is_equivalence.functor_unit_iso_comp\u27e9\n\ninstance is_equivalence_refl : is_equivalence (\ud835\udfed C) :=\nis_equivalence.of_equivalence equivalence.refl\n\n/-- The inverse functor of a functor that is an equivalence. -/\ndef inv (F : C \u2964 D) [is_equivalence F] : D \u2964 C :=\nis_equivalence.inverse F\n\ninstance is_equivalence_inv (F : C \u2964 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 \u2964 D) [is_equivalence F] :\n  F.as_equivalence.functor = F := rfl\n\n@[simp] lemma as_equivalence_inverse (F : C \u2964 D) [is_equivalence F] :\n  F.as_equivalence.inverse = inv F := rfl\n\n@[simp] lemma as_equivalence_unit {F : C \u2964 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 \u2964 D} [is_equivalence F] :\n  F.as_equivalence.counit_iso = is_equivalence.counit_iso := rfl\n\n@[simp] lemma inv_inv (F : C \u2964 D) [is_equivalence F] :\n  inv (inv F) = F := rfl\n\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\ninstance is_equivalence_trans (F : C \u2964 D) (G : D \u2964 E) [is_equivalence F] [is_equivalence G] :\n  is_equivalence (F \u22d9 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 \u224c D) : E.functor.inv = E.inverse := rfl\n\n@[simp]\nlemma inverse_inv (E : C \u224c D) : E.inverse.inv = E.functor := rfl\n\n@[simp]\nlemma functor_as_equivalence (E : C \u224c D) : E.functor.as_equivalence = E :=\nby { cases E, congr, }\n\n@[simp]\nlemma inverse_as_equivalence (E : C \u224c 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 \u2964 D) [is_equivalence F] (X Y : D) (f : X \u27f6 Y) :\n  F.map (F.inv.map f) = F.as_equivalence.counit.app X \u226b f \u226b 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 \u2964 D) [is_equivalence F] (X Y : C) (f : X \u27f6 Y) :\n  F.inv.map (F.map f) = F.as_equivalence.unit_inv.app X \u226b f \u226b 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 \u2964 D} (e : F \u2245 G) (hF : is_equivalence F) : is_equivalence G :=\n{ inverse := hF.inverse,\n  unit_iso := hF.unit_iso \u226a\u226b nat_iso.hcomp e (iso.refl hF.inverse),\n  counit_iso := nat_iso.hcomp (iso.refl hF.inverse) e.symm \u226a\u226b hF.counit_iso,\n  functor_unit_iso_comp' := \u03bb 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 \u2190 e.hom.naturality, },\n    slice_lhs 2 3 { rw [\u2190 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 \u2964 D} (e : F \u2245 G) (e' : G \u2245 H) (hF : is_equivalence F) :\n  (of_iso e' (of_iso e hF)) = of_iso (e \u226a\u226b 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 \u2964 D) (hF : is_equivalence F) : of_iso (iso.refl F) hF = hF :=\nbegin\n  unfreezingI { rcases hF with \u27e8Finv, Funit, Fcounit, Fcomp\u27e9, },\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 \u2964 D} (e : F \u2245 G) : is_equivalence F \u2243 is_equivalence G :=\n{ to_fun := of_iso e,\n  inv_fun := of_iso e.symm,\n  left_inv := \u03bb hF, by rw [of_iso_trans, iso.self_symm_id, of_iso_refl],\n  right_inv := \u03bb hF, by rw [of_iso_trans, iso.symm_self_id, of_iso_refl], }\n\n/-- If `G` and `F \u22d9 G` are equivalence of categories, then `F` is also an equivalence. -/\n@[simp]\ndef cancel_comp_right {E : Type*} [category E]\n  (F : C \u2964 D) (G : D \u2964 E) (hG : is_equivalence G) (hGF : is_equivalence (F \u22d9 G)) :\n  is_equivalence F :=\nof_iso ((functor.associator F G G.inv) \u226a\u226b nat_iso.hcomp (iso.refl F) hG.unit_iso.symm \u226a\u226b\n  right_unitor F) (functor.is_equivalence_trans (F \u22d9 G) (G.inv))\n\n/-- If `F` and `F \u22d9 G` are equivalence of categories, then `G` is also an equivalence. -/\n@[simp]\ndef cancel_comp_left {E : Type*} [category E]\n  (F : C \u2964 D) (G : D \u2964 E) (hF : is_equivalence F) (hGF : is_equivalence (F \u22d9 G)) :\n  is_equivalence G :=\nof_iso ((functor.associator F.inv F G).symm \u226a\u226b nat_iso.hcomp hF.counit_iso (iso.refl G) \u226a\u226b\n  left_unitor G) (functor.is_equivalence_trans F.inv (F \u22d9 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 \u2964 D) [is_equivalence F] : ess_surj F :=\n\u27e8\u03bb Y, \u27e8F.inv.obj Y, \u27e8F.as_equivalence.counit_iso.app Y\u27e9\u27e9\u27e9\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 \u2964 D) [is_equivalence F] : faithful F :=\n{ map_injective' := \u03bb 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 \u2964 D) [is_equivalence F] : full F :=\n{ preimage := \u03bb X Y f, F.as_equivalence.unit.app X \u226b F.inv.map f \u226b F.as_equivalence.unit_inv.app Y,\n  witness' := \u03bb 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 \u2964 D) [full F] [faithful F]\n  [ess_surj F] : D \u2964 C :=\n{ obj  := \u03bb X, F.obj_preimage X,\n  map := \u03bb X Y f, F.preimage ((F.obj_obj_preimage_iso X).hom \u226b f \u226b (F.obj_obj_preimage_iso Y).inv),\n  map_id' := \u03bb X, begin apply F.map_injective, tidy end,\n  map_comp' := \u03bb 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 \u2964 D) [full F] [faithful F] [ess_surj F] : is_equivalence F :=\nis_equivalence.mk (equivalence_inverse F)\n  (nat_iso.of_components\n    (\u03bb X, (F.preimage_iso $ F.obj_obj_preimage_iso $ F.obj X).symm)\n    (\u03bb 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 \u224c D) {X Y : C} (f g : X \u27f6 Y) :\n  e.functor.map f = e.functor.map g \u2194 f = g :=\n\u27e8\u03bb h, e.functor.map_injective h, \u03bb h, h \u25b8 rfl\u27e9\n\n@[simp] lemma inverse_map_inj_iff (e : C \u224c D) {X Y : D} (f g : X \u27f6 Y) :\n  e.inverse.map f = e.inverse.map g \u2194 f = g :=\nfunctor_map_inj_iff e.symm f g\n\ninstance ess_surj_induced_functor {C' : Type*} (e : C' \u2243 D) : ess_surj (induced_functor e) :=\n{ mem_ess_image := \u03bb Y, \u27e8e.symm Y, by simp\u27e9, }\n\nnoncomputable\ninstance induced_functor_of_equiv {C' : Type*} (e : C' \u2243 D) : is_equivalence (induced_functor e) :=\nequivalence.of_fully_faithfully_ess_surj _\n\nnoncomputable\ninstance fully_faithful_to_ess_image (F : C \u2964 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 {\u03b1 : Type u} (b : bool) (a : \u03b1) : 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 : \u00ac(tt = ff) :=\nby contradiction\n\nlemma ff_eq_tt_eq_false : \u00ac(ff = tt) :=\nby contradiction\n\n@[simp] lemma eq_ff_eq_not_eq_tt (b : bool) : (\u00ac(b = tt)) = (b = ff) :=\nby cases b; simp\n\n@[simp] lemma eq_tt_eq_not_eq_ff (b : bool) : (\u00ac(b = ff)) = (b = tt) :=\nby cases b; simp\n\nlemma eq_ff_of_not_eq_tt {b : bool} : (\u00ac(b = tt)) \u2192 (b = ff) :=\neq.mp (eq_ff_eq_not_eq_tt b)\n\nlemma eq_tt_of_not_eq_ff {b : bool} : (\u00ac(b = ff)) \u2192 (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 \u2227 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 \u2228 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 \u2228 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 \u2227 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 : \u2191ff = false :=\nshow (ff = tt) = false, by simp\n\n@[simp] lemma coe_tt : \u2191tt = true :=\nshow (tt = tt) = true, by simp\n\n@[simp] lemma coe_sort_ff : \u21a5ff = false :=\nshow (ff = tt) = false, by simp\n\n@[simp] lemma coe_sort_tt : \u21a5tt = true :=\nshow (tt = tt) = true, by simp\n\n@[simp] theorem to_bool_iff (p : Prop) [d : decidable p] : (to_bool p = tt) \u2194 p :=\nmatch d with\n| is_true hp := \u27e8\u03bbh, hp, \u03bb_, rfl\u27e9\n| is_false hnp := \u27e8\u03bbh, bool.no_confusion h, \u03bbhp, absurd hp hnp\u27e9\nend\n\ntheorem to_bool_true {p : Prop} [decidable p] : p \u2192 to_bool p := (to_bool_iff p).2\n\ntheorem to_bool_tt {p : Prop} [decidable p] : p \u2192 to_bool p = tt := to_bool_true\n\ntheorem of_to_bool_true {p : Prop} [decidable p] : to_bool p \u2192 p := (to_bool_iff p).1\n\ntheorem bool_iff_false {b : bool} : \u00ac b \u2194 b = ff := by cases b; exact dec_trivial\n\ntheorem bool_eq_false {b : bool} : \u00ac b \u2192 b = ff := bool_iff_false.1\n\n@[simp] theorem to_bool_ff_iff (p : Prop) [decidable p] : to_bool p = ff \u2194 \u00acp :=\nbool_iff_false.symm.trans (not_congr (to_bool_iff _))\n\ntheorem to_bool_ff {p : Prop} [decidable p] : \u00acp \u2192 to_bool p = ff := (to_bool_ff_iff p).2\n\ntheorem of_to_bool_ff {p : Prop} [decidable p] : to_bool p = ff \u2192 \u00acp := (to_bool_ff_iff p).1\n\ntheorem to_bool_congr {p q : Prop} [decidable p] [decidable q] (h : p \u2194 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 \u2194 a \u2228 b :=\nby cases a; cases b; exact dec_trivial\n\n@[simp] theorem band_coe_iff (a b : bool) : a && b \u2194 a \u2227 b :=\nby cases a; cases b; exact dec_trivial\n\n@[simp] theorem bxor_coe_iff (a b : bool) : bxor a b \u2194 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 {\u03b1 : Type u} {\u03b2 : 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 : \u2115 \u2192 \u03b1 \u2192 \u03b2) : \u2115 \u2192 List \u03b1 \u2192 List \u03b2\n  | _, []      => []\n  | k, a :: as => f k a :: List.oldMapIdxCore f (k + 1) as\n\n/-- Given a function `f : \u2115 \u2192 \u03b1 \u2192 \u03b2` and `as : List \u03b1`, `as = [a\u2080, a\u2081, ...]`, returns the list\n`[f 0 a\u2080, f 1 a\u2081, ...]`. -/\nprotected def oldMapIdx (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (as : List \u03b1) : List \u03b2 :=\n  List.oldMapIdxCore f 0 as\n\n@[simp]\ntheorem mapIdx_nil {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) : 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 \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (n : \u2115) :\n    l.oldMapIdxCore f n = l.oldMapIdx fun i a \u21a6 f (i + n) a := by\n  induction' l with hd tl hl generalizing f n\n  \u00b7 rfl\n  \u00b7 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 `\u2200 l e, p [] \u2192 (p l \u2192 p (l ++ [e])) \u2192 p l`\n-- Porting note: new theorem.\ntheorem list_reverse_induction (p : List \u03b1 \u2192 Prop) (base : p [])\n    (ind : \u2200 (l : List \u03b1) (e : \u03b1), p l \u2192 p (l ++ [e])) : (\u2200 (l : List \u03b1), p l) := by\n  let q := fun l \u21a6 p (reverse l)\n  have pq : \u2200 l, p (reverse l) \u2192 q l := by simp only [reverse_reverse]; intro; exact id\n  have qp : \u2200 l, q (reverse l) \u2192 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  \u00b7 apply pq; simp only [reverse_nil, base]\n  \u00b7 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 : \u2200 (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (n : \u2115) (l\u2081 l\u2082 : List \u03b1),\n    List.oldMapIdxCore f n (l\u2081 ++ l\u2082) =\n    List.oldMapIdxCore f n l\u2081 ++ List.oldMapIdxCore f (n + l\u2081.length) l\u2082 := by\n  intros f n l\u2081 l\u2082\n  generalize e : (l\u2081 ++ l\u2082).length = len\n  revert n l\u2081 l\u2082\n  induction' len with len ih <;> intros n l\u2081 l\u2082 h\n  \u00b7 have l\u2081_nil : l\u2081 = [] := by cases l\u2081; rfl; contradiction\n    have l\u2082_nil : l\u2082 = [] := by cases l\u2082; rfl; rw [List.length_append] at h; contradiction\n    simp only [l\u2081_nil, l\u2082_nil]; rfl\n  \u00b7 cases' l\u2081 with head tail\n    \u00b7 rfl\n    \u00b7 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 : \u2200 (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (l : List \u03b1) (e : \u03b1),\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 : \u2200 (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (l\u2081 l\u2082 : List \u03b1) (arr : Array \u03b2),\n    mapIdx.go f (l\u2081 ++ l\u2082) arr = mapIdx.go f l\u2082 (List.toArray (mapIdx.go f l\u2081 arr)) := by\n  intros f l\u2081 l\u2082 arr\n  generalize e : (l\u2081 ++ l\u2082).length = len\n  revert l\u2081 l\u2082 arr\n  induction' len with len ih <;> intros l\u2081 l\u2082 arr h\n  \u00b7 have l\u2081_nil : l\u2081 = [] := by cases l\u2081; rfl; contradiction\n    have l\u2082_nil : l\u2082 = [] := by cases l\u2082; rfl; rw [List.length_append] at h; contradiction\n    rw [l\u2081_nil, l\u2082_nil]; simp only [mapIdx.go, Array.toList_eq, Array.toArray_data]\n  \u00b7 cases' l\u2081 with head tail <;> simp only [mapIdx.go]\n    \u00b7 simp only [nil_append, Array.toList_eq, Array.toArray_data]\n    \u00b7 simp only [List.append_eq]\n      rw [ih]\n      \u00b7 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 : \u2200 (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (l : List \u03b1) (arr : Array \u03b2),\n    length (mapIdx.go f l arr) = length l + arr.size := by\n  intro f l\n  induction' l with head tail ih\n  \u00b7 intro; simp only [mapIdx.go, Array.toList_eq, length_nil, zero_add]\n  \u00b7 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 : \u2200 (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (l : List \u03b1) (e : \u03b1),\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    \u2200 (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (l : List \u03b1), l.mapIdx f = List.oldMapIdx f l := by\n  intro f\n  apply list_reverse_induction\n  \u00b7 rfl\n  \u00b7 intro l e h\n    rw [List.oldMapIdx_append, mapIdx_append_one, h]\n\n@[local simp]\ntheorem map_enumFrom_eq_zipWith : \u2200 (l : List \u03b1) (n : \u2115) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2),\n    map (uncurry f) (enumFrom n l) = zipWith (fun i \u21a6 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  \u00b7 have : l = [] := by cases l; rfl; contradiction\n    rw [this] ; rfl\n  \u00b7 cases' l with head tail\n    \u00b7 contradiction\n    \u00b7 simp only [map, uncurry_apply_pair, range_succ_eq_map, zipWith, zero_add, zipWith_map_left]\n      rw [ih]\n      suffices : (fun i \u21a6 f (i + (n + 1))) = ((fun i \u21a6 f (i + n)) \u2218 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 \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) :\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  \u00b7 rfl\n  \u00b7 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 {\u03b1 \u03b2} (l : List \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (a : \u03b1) :\n    mapIdx f (a :: l) = f 0 a :: mapIdx (fun i \u21a6 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 {\u03b1} (K L : List \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) :\n    (K ++ L).mapIdx f = K.mapIdx f ++ L.mapIdx fun i a \u21a6 f (i + K.length) a := by\n  induction' K with a J IH generalizing f\n  \u00b7 rfl\n  \u00b7 simp [IH fun i \u21a6 f (i + 1), add_assoc]\n#align list.map_with_index_append List.mapIdx_append\n\n@[simp]\ntheorem length_mapIdx {\u03b1 \u03b2} (l : List \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) : (l.mapIdx f).length = l.length := by\n  induction' l with hd tl IH generalizing f\n  \u00b7 rfl\n  \u00b7 simp [IH]\n#align list.length_map_with_index List.length_mapIdx\n\n@[simp, deprecated]\ntheorem nthLe_mapIdx {\u03b1 \u03b2} (l : List \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (i : \u2115) (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 {\u03b1 \u03b2} (l : List \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) :\n    l.mapIdx f = ofFn fun i : Fin l.length \u21a6 f (i : \u2115) (l.get i) := by\n  induction' l with hd tl IH generalizing f\n  \u00b7 rfl\n  \u00b7 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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (as : List \u03b1) (start : \u2115) : \u03b2 :=\n  foldr (uncurry f) b <| enumFrom start as\n#align list.foldr_with_index_aux_spec List.foldrIdxSpec\u2093\n\ntheorem foldrIdxSpec_cons (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (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\u2093\n\ntheorem foldrIdx_eq_foldrIdxSpec (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b as start) :\n    foldrIdx f b as start = foldrIdxSpec f b as start := by\n  induction as generalizing start\n  \u00b7 rfl\n  \u00b7 simp only [foldrIdx, foldrIdxSpec_cons, *]\n#align list.foldr_with_index_aux_eq_foldr_with_index_aux_spec List.foldrIdx_eq_foldrIdxSpec\u2093\n\ntheorem foldrIdx_eq_foldr_enum (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (as : List \u03b1) :\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 : \u03b1 \u2192 Prop) [DecidablePred p] (as : List \u03b1) :\n    indexesValues p as = filter (p \u2218 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 : \u03b1 \u2192 Prop) [DecidablePred p] (as : List \u03b1) :\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (bs : List \u03b2) (start : \u2115) : \u03b1 :=\n  foldl (fun a p \u21a6 f p.fst a p.snd) a <| enumFrom start bs\n#align list.foldl_with_index_aux_spec List.foldlIdxSpec\u2093\n\ntheorem foldlIdxSpec_cons (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (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\u2093\n\ntheorem foldlIdx_eq_foldlIdxSpec (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a bs start) :\n    foldlIdx f a bs start = foldlIdxSpec f a bs start := by\n  induction bs generalizing start a\n  \u00b7 rfl\n  \u00b7 simp [foldlIdxSpec, *]\n#align list.foldl_with_index_aux_eq_foldl_with_index_aux_spec List.foldlIdx_eq_foldlIdxSpec\u2093\n\ntheorem foldlIdx_eq_foldl_enum (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (bs : List \u03b2) :\n    foldlIdx f a bs = foldl (fun a p \u21a6 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 \u2192 Type v} [Monad m]\n\ntheorem foldrIdxM_eq_foldrM_enum {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 m \u03b2) (b : \u03b2) (as : List \u03b1) [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] {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b2 \u2192 \u03b1 \u2192 m \u03b2) (b : \u03b2) (as : List \u03b1) :\n    foldlIdxM f b as = List.foldlM (fun b p \u21a6 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 \u2192 Type v} [Monad m] [LawfulMonad m]\n\n/-- Specification of `mapIdxMAux`. -/\ndef mapIdxMAuxSpec {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (start : \u2115) (as : List \u03b1) : m (List \u03b2) :=\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 \u2192 Type u`.\n\n\ntheorem mapIdxMGo_eq_mapIdxMAuxSpec {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (arr : Array \u03b2) (as : List \u03b1) :\n    mapIdxM.go f as arr = (arr.toList ++ \u00b7) <$> 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  \u00b7 have : as = [] := by cases as; rfl; contradiction\n    simp only [this, mapIdxM.go, mapIdxMAuxSpec, List.traverse, map_pure, append_nil]\n  \u00b7 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 {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (as : List \u03b1) :\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 \u2192 Type v} [Monad m] [LawfulMonad m]\n\ntheorem mapIdxMAux'_eq_mapIdxMGo {\u03b1} (f : \u2115 \u2192 \u03b1 \u2192 m PUnit) (as : List \u03b1) (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  \u00b7 simp only [mapIdxMAux', mapIdxM.go, seqRight_eq, map_pure, seq_pure]\n  \u00b7 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 \u27e8\u27e9\n    have : arr_1.size = arr.size + 1 := Array.size_push arr \u27e8\u27e9\n    rw [\u2190 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 {\u03b1} (f : \u2115 \u2192 \u03b1 \u2192 m PUnit) (as : List \u03b1) :\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 \u2192 ftuple A n \u2192 A)\n\nnotation `applyo` := has_app.app\n\n/-\nA morphism of raw algebras relative to a language L.\nUse the notation `A \u2192$[L] B`.\n-/\nstructure ralg_hom (L : lang) (A : Type*) (B : Type*) [has_app L A] [has_app L B] :=\n(to_fn : A \u2192 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 ` \u2192$[`: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 \u2192$[L] B ) := \u27e8_,to_fn\u27e9\n\ntheorem applyo_map {n} {L : lang} {A : Type*} {B : Type*} [has_app L A] [has_app L B] \n  (f : A \u2192$[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 \u2192$[L] B) \u2192 (B \u2192$[L] C) \u2192 (A \u2192$[L] C) := \u03bb f g, \n{ to_fn := g \u2218 f,\n  applyo_map' :=\n  begin\n    intros n t as, \n    change _ = g _,\n    simp_rw \u2190applyo_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 \u2192$[L] B) : \u21d1f = g \u2192 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 \u2192$[L] B) (g : B \u2192$[L] C) (h : C \u2192$[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 \u2192 A :=\n  lang.term.rec_on t \n  (\u03bb _, applyo) \n  (\u03bb as, as 0)\n  (\u03bb _ _ f _ h as, h (as.proj f)) \n  (\u03bb _ _ _ _ h1 h2 as, as.compl h1 h2) \n  (\u03bb _ _ _ _ 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 \u2192$[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 [\u2190ftuple.map_init, h1, \u2190ftuple.map_of, \u2190ftuple.map_last, \u2190ftuple.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 := \u27e8\u03bb n, applyt\u27e9\n\n/-\nnamespace ralg_hom\ndef gen {L : lang} {A : Type*} {B : Type*} [has_app L A] [has_app L B] (f : A \u2192$[L] B) : A \u2192$[L.gen] B := \n  \u27e8f,\u03bb _, by apply gen.applyt_map\u27e9 \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 \u2192 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 \u03b1 \u03b2 [topological_space \u03b1] [topological_space \u03b2] extends pequiv \u03b1 \u03b2 :=\n(to_cont : \u2200 V : set \u03b2, is_open V \u2192 is_open (to_fun \u207b\u00b9' (V \u2229 range) \u2229 domain))\n(inv_cont : \u2200 U : set \u03b1, is_open U \u2192 is_open (inv_fun \u207b\u00b9' (U \u2229 domain) \u2229 range))\n\nnamespace phomeo\nvariables {\u03b1 : Type*} {\u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n\n\ninstance : has_coe (phomeo \u03b1 \u03b2) (pequiv \u03b1 \u03b2) := \u27e8\u03bb f, f.to_pequiv\u27e9\n\ndef symm (f : phomeo \u03b1  \u03b2) : phomeo \u03b2 \u03b1 :=\n\u27e8f.to_pequiv.symm, f.inv_cont, f.to_cont\u27e9\n\nlemma is_open_map {f : phomeo \u03b1 \u03b2} {U : set \u03b1} (H : is_open U) : is_open (f '' (U \u2229 f.domain)) :=\nbegin\n  change is_open ((f.to_pequiv) '' (U \u2229 (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 {\u03b1 \u03b2 \u03b3 \u03b4 : 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 \u03b1) \u2192 multiset \u03b1 := sum\n\nlemma coe_join : \u2200 L : list (list \u03b1),\n  join (L.map (@coe _ (multiset \u03b1) _) : multiset (multiset \u03b1)) = L.join\n| []       := rfl\n| (l :: L) := congr_arg (\u03bb s : multiset \u03b1, \u2191l + s) (coe_join L)\n\n@[simp] \n\n@[simp] lemma mem_join {a S} : a \u2208 @join \u03b1 S \u2194 \u2203 s \u2208 S, a \u2208 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 \u03b1 S) = sum (map card S) :=\nmultiset.induction_on S (by simp) (by simp)\n\nlemma rel_join {r : \u03b1 \u2192 \u03b2 \u2192 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 : \u03b1) (s t : multiset \u03b1) (f g : \u03b1 \u2192 multiset \u03b2)\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 \u03b1) (f : \u03b1 \u2192 multiset \u03b2) : multiset \u03b2 := (s.map f).join\n\n@[simp] lemma coe_bind (l : list \u03b1) (f : \u03b1 \u2192 list \u03b2) : @bind \u03b1 \u03b2 l (\u03bb a, f a) = l.bind f :=\nby rw [list.bind, \u2190coe_join, list.map_map]; refl\n\n@[simp] lemma zero_bind : bind 0 f = 0 := rfl\n@[simp] lemma cons_bind : (a ::\u2098 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 (\u03bb a, 0 : \u03b1 \u2192 multiset \u03b2) = 0 := by simp [bind, join, nsmul_zero]\n@[simp] lemma bind_add : s.bind (\u03bb a, f a + g a) = s.bind f + s.bind g := by simp [bind, join]\n\n@[simp] lemma bind_cons (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 multiset \u03b2) :\n  s.bind (\u03bb a, f a ::\u2098 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 : \u03b1 \u2192 \u03b2) : s.bind (\u03bb x, ({f x} : multiset \u03b2)) = 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 : \u03b1 \u2192 multiset \u03b2} : b \u2208 bind s f \u2194 \u2203 a \u2208 s, b \u2208 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 \u2218 f)).sum := by simp [bind]\n\nlemma bind_congr {f g : \u03b1 \u2192 multiset \u03b2} {m : multiset \u03b1} :\n  (\u2200 a \u2208 m, f a = g a) \u2192 bind m f = bind m g :=\nby simp [bind] {contextual := tt}\n\nlemma bind_hcongr {\u03b2' : Type*} {m : multiset \u03b1} {f : \u03b1 \u2192 multiset \u03b2} {f' : \u03b1 \u2192 multiset \u03b2'}\n  (h : \u03b2 = \u03b2') (hf : \u2200a \u2208 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 \u03b1) (n : \u03b1 \u2192 multiset \u03b2) (f : \u03b2 \u2192 \u03b3) :\n  map f (bind m n) = bind m (\u03bb a, map f (n a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map (m : multiset \u03b1) (n : \u03b2 \u2192 multiset \u03b3) (f : \u03b1 \u2192 \u03b2) :\n  bind (map f m) n = bind m (\u03bb a, n (f a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_assoc {s : multiset \u03b1} {f : \u03b1 \u2192 multiset \u03b2} {g : \u03b2 \u2192 multiset \u03b3} :\n  (s.bind f).bind g = s.bind (\u03bb a, (f a).bind g) :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma bind_bind (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 multiset \u03b3} :\n  (bind m $ \u03bb a, bind n $ \u03bb b, f a b) = (bind n $ \u03bb b, bind m $ \u03bb a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map_comm (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  (bind m $ \u03bb a, n.map $ \u03bb b, f a b) = (bind n $ \u03bb b, m.map $ \u03bb a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\n@[simp, to_additive]\nlemma prod_bind [comm_monoid \u03b2] (s : multiset \u03b1) (t : \u03b1 \u2192 multiset \u03b2) :\n  (s.bind t).prod = (s.map $ \u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop} {s t} {f : \u03b1 \u2192 multiset \u03b3} {g : \u03b2 \u2192 multiset \u03b4}\n  (h : (r \u21d2 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 (\u03bb a ha b hb hr, h hr) }\n\nlemma count_sum [decidable_eq \u03b1] {m : multiset \u03b2} {f : \u03b2 \u2192 multiset \u03b1} {a : \u03b1} :\n  count a (map f m).sum = sum (m.map $ \u03bb b, count a $ f b) :=\nmultiset.induction_on m (by simp) ( by simp)\n\nlemma count_bind [decidable_eq \u03b1] {m : multiset \u03b2} {f : \u03b2 \u2192 multiset \u03b1} {a : \u03b1} :\n  count a (bind m f) = sum (m.map $ \u03bb b, count a $ f b) := count_sum\n\nend bind\n\n/-! ### Product of two multisets -/\n\nsection product\nvariables (a : \u03b1) (b : \u03b2) (s : multiset \u03b1) (t : multiset \u03b2)\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 \u03b1) (t : multiset \u03b2) : multiset (\u03b1 \u00d7 \u03b2) := s.bind $ \u03bb a, t.map $ prod.mk a\n\n@[simp] lemma coe_product (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) : @product \u03b1 \u03b2 l\u2081 l\u2082 = l\u2081.product l\u2082 :=\nby { rw [product, list.product, \u2190coe_bind], simp }\n\n@[simp] lemma zero_product : @product \u03b1 \u03b2 0 t = 0 := rfl\n--TODO: Add `product_zero`\n\n@[simp] lemma cons_product : (a ::\u2098 s).product t = map (prod.mk a) t + s.product t :=\nby simp [product]\n\n@[simp] lemma product_singleton : ({a} : multiset \u03b1).product ({b} : multiset \u03b2) = {(a, b)} :=\nby simp only [product, bind_singleton, map_singleton]\n\n@[simp] lemma add_product (s t : multiset \u03b1) (u : multiset \u03b2) :\n  (s + t).product u = s.product u + product t u :=\nby simp [product]\n\n@[simp] lemma product_add (s : multiset \u03b1) : \u2200 t u : multiset \u03b2,\n  s.product (t + u) = s.product t + s.product u :=\nmultiset.induction_on s (\u03bb t u, rfl) $ \u03bb a s IH t u,\n  by rw [cons_product, IH]; simp; cc\n\n@[simp] lemma mem_product {s t} : \u2200 {p : \u03b1 \u00d7 \u03b2}, p \u2208 @product \u03b1 \u03b2 s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 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, (\u2218), mul_comm]\n\nend product\n\n/-! ### Disjoint sum of multisets -/\n\nsection sigma\nvariables {\u03c3 : \u03b1 \u2192 Type*} (a : \u03b1) (s : multiset \u03b1) (t : \u03a0 a, multiset (\u03c3 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 \u03b1) (t : \u03a0 a, multiset (\u03c3 a)) : multiset (\u03a3 a, \u03c3 a) :=\ns.bind $ \u03bb a, (t a).map $ sigma.mk a\n\n@[simp] lemma coe_sigma (l\u2081 : list \u03b1) (l\u2082 : \u03a0 a, list (\u03c3 a)) :\n  @multiset.sigma \u03b1 \u03c3 l\u2081 (\u03bb a, l\u2082 a) = l\u2081.sigma l\u2082 :=\nby rw [multiset.sigma, list.sigma, \u2190coe_bind]; simp\n\n@[simp] lemma zero_sigma : @multiset.sigma \u03b1 \u03c3 0 t = 0 := rfl\n\n@[simp] lemma cons_sigma : (a ::\u2098 s).sigma t = (t a).map (sigma.mk a) + s.sigma t :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_singleton (b : \u03b1 \u2192 \u03b2) :\n  ({a} : multiset \u03b1).sigma (\u03bb a, ({b a} : multiset \u03b2)) = {\u27e8a, b a\u27e9} := rfl\n\n@[simp] lemma add_sigma (s t : multiset \u03b1) (u : \u03a0 a, multiset (\u03c3 a)) :\n  (s + t).sigma u = s.sigma u + t.sigma u :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_add : \u2200 t u : \u03a0 a, multiset (\u03c3 a),\n  s.sigma (\u03bb a, t a + u a) = s.sigma t + s.sigma u :=\nmultiset.induction_on s (\u03bb t u, rfl) $ \u03bb a s IH t u,\n  by rw [cons_sigma, IH]; simp; cc\n\n@[simp] lemma mem_sigma {s t} : \u2200 {p : \u03a3 a, \u03c3 a},\n  p \u2208 @multiset.sigma \u03b1 \u03c3 s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t p.1\n| \u27e8a, b\u27e9 := by simp [multiset.sigma, and_assoc, and.left_comm]\n\n@[simp] lemma card_sigma :\n  card (s.sigma t) = sum (map (\u03bb a, card (t a)) s) :=\nby simp [multiset.sigma, (\u2218)]\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\n-/\nimport analysis.normed_space.multilinear\n\n/-!\n# Formal multilinear series\n\nIn this file we define `formal_multilinear_series \ud835\udd5c 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 [\u00d7n]\u2192L[\ud835\udd5c] 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 {\ud835\udd5c \ud835\udd5c' E F G : Type*}\n\nsection\nvariables [comm_ring \ud835\udd5c]\n  [add_comm_group E] [module \ud835\udd5c E] [topological_space E] [topological_add_group E]\n  [has_continuous_const_smul \ud835\udd5c E]\n  [add_comm_group F] [module \ud835\udd5c F] [topological_space F] [topological_add_group F]\n  [has_continuous_const_smul \ud835\udd5c F]\n  [add_comm_group G] [module \ud835\udd5c G] [topological_space G] [topological_add_group G]\n  [has_continuous_const_smul \ud835\udd5c G]\n\n\n/-- A formal multilinear series over a field `\ud835\udd5c`, 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 (\ud835\udd5c : Type*) (E : Type*) (F : Type*)\n  [ring \ud835\udd5c]\n  [add_comm_group E] [module \ud835\udd5c E] [topological_space E] [topological_add_group E]\n    [has_continuous_const_smul \ud835\udd5c E]\n  [add_comm_group F] [module \ud835\udd5c F] [topological_space F] [topological_add_group F]\n    [has_continuous_const_smul \ud835\udd5c F] :=\n\u03a0 (n : \u2115), (E [\u00d7n]\u2192L[\ud835\udd5c] F)\n\ninstance : inhabited (formal_multilinear_series \ud835\udd5c E F) := \u27e80\u27e9\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 \ud835\udd5c (formal_multilinear_series \ud835\udd5c E F) :=\nbegin\n  letI : \u03a0 n, module \ud835\udd5c (continuous_multilinear_map \ud835\udd5c (\u03bb (i : fin n), E) F) :=\n    \u03bb 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 \ud835\udd5c E F) : formal_multilinear_series \ud835\udd5c E F\n| 0       := 0\n| (n + 1) := p (n + 1)\n\n@[simp] lemma remove_zero_coeff_zero (p : formal_multilinear_series \ud835\udd5c E F) :\n  p.remove_zero 0 = 0 := rfl\n\n@[simp] lemma remove_zero_coeff_succ (p : formal_multilinear_series \ud835\udd5c E F) (n : \u2115) :\n  p.remove_zero (n+1) = p (n+1) := rfl\n\nlemma remove_zero_of_pos (p : formal_multilinear_series \ud835\udd5c E F) {n : \u2115} (h : 0 < n) :\n  p.remove_zero n = p n :=\nby { rw \u2190 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 \ud835\udd5c E F) {m n : \u2115} {v : fin m \u2192 E} {w : fin n \u2192 E}\n  (h1 : m = n) (h2 : \u2200 (i : \u2115) (him : i < m) (hin : i < n), v \u27e8i, him\u27e9 = w \u27e8i, hin\u27e9) :\n  p m v = p n w :=\nby { cases h1, congr' with \u27e8i, hi\u27e9, exact h2 i hi hi }\n\n/-- Composing each term `p\u2099` 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 \ud835\udd5c F G) (u : E \u2192L[\ud835\udd5c] F) :\n  formal_multilinear_series \ud835\udd5c E G :=\n\u03bb n, (p n).comp_continuous_linear_map (\u03bb (i : fin n), u)\n\n@[simp] lemma comp_continuous_linear_map_apply\n  (p : formal_multilinear_series \ud835\udd5c F G) (u : E \u2192L[\ud835\udd5c] F) (n : \u2115) (v : fin n \u2192 E) :\n  (p.comp_continuous_linear_map u) n v = p n (u \u2218 v) := rfl\n\nvariables (\ud835\udd5c) [comm_ring \ud835\udd5c'] [has_scalar \ud835\udd5c \ud835\udd5c']\nvariables [module \ud835\udd5c' E] [has_continuous_const_smul \ud835\udd5c' E] [is_scalar_tower \ud835\udd5c \ud835\udd5c' E]\nvariables [module \ud835\udd5c' F] [has_continuous_const_smul \ud835\udd5c' F] [is_scalar_tower \ud835\udd5c \ud835\udd5c' F]\n\n/-- Reinterpret a formal `\ud835\udd5c'`-multilinear series as a formal `\ud835\udd5c`-multilinear series. -/\n@[simp] protected def restrict_scalars (p : formal_multilinear_series \ud835\udd5c' E F) :\n  formal_multilinear_series \ud835\udd5c E F :=\n\u03bb n, (p n).restrict_scalars \ud835\udd5c\n\nend formal_multilinear_series\n\nend\n\nnamespace formal_multilinear_series\n\nvariables [nondiscrete_normed_field \ud835\udd5c]\n  [normed_group E] [normed_space \ud835\udd5c E]\n  [normed_group F] [normed_space \ud835\udd5c F]\n  [normed_group G] [normed_space \ud835\udd5c G]\n\nvariables (p : formal_multilinear_series \ud835\udd5c E F)\n\n/-- Forgetting the zeroth term in a formal multilinear series, and interpreting the following terms\nas multilinear maps into `E \u2192L[\ud835\udd5c] 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 \ud835\udd5c E (E \u2192L[\ud835\udd5c] F) :=\n\u03bbn, (p n.succ).curry_right\n\n/-- Adding a zeroth term to a formal multilinear series taking values in `E \u2192L[\ud835\udd5c] 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 \ud835\udd5c E (E \u2192L[\ud835\udd5c] F)) (z : F) :\n  formal_multilinear_series \ud835\udd5c E F\n| 0       := (continuous_multilinear_curry_fin0 \ud835\udd5c E F).symm z\n| (n + 1) := continuous_multilinear_curry_right_equiv' \ud835\udd5c n E F (q n)\n\nend formal_multilinear_series\n\nnamespace continuous_linear_map\nvariables [comm_ring \ud835\udd5c]\n  [add_comm_group E] [module \ud835\udd5c E] [topological_space E] [topological_add_group E]\n  [has_continuous_const_smul \ud835\udd5c E]\n  [add_comm_group F] [module \ud835\udd5c F] [topological_space F] [topological_add_group F]\n  [has_continuous_const_smul \ud835\udd5c F]\n  [add_comm_group G] [module \ud835\udd5c G] [topological_space G] [topological_add_group G]\n  [has_continuous_const_smul \ud835\udd5c G]\n\n/-- Composing each term `p\u2099` 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 \u2218 p\u2099`. -/\ndef comp_formal_multilinear_series (f : F \u2192L[\ud835\udd5c] G) (p : formal_multilinear_series \ud835\udd5c E F) :\n  formal_multilinear_series \ud835\udd5c E G :=\n\u03bb n, f.comp_continuous_multilinear_map (p n)\n\n@[simp] lemma comp_formal_multilinear_series_apply\n  (f : F \u2192L[\ud835\udd5c] G) (p : formal_multilinear_series \ud835\udd5c E F) (n : \u2115) :\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 \u2192L[\ud835\udd5c] G) (p : formal_multilinear_series \ud835\udd5c E F) (n : \u2115) (v : fin n \u2192 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[\u03b1]`\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] \u2192+* adjoin_root f`, the natural ring homomorphism.\n\n*  `of f : R \u2192+* 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 \u2192+* S) (x : S) (h : f.eval\u2082 i x = 0) : (adjoin_root f) \u2192+* S`, the ring\n  homomorphism from R[X]/(f) to S extending `i : R \u2192+* S` and sending `X` to `x`.\n\n* `lift_hom (x : S) (hfx : aeval x f = 0) : adjoin_root f \u2192\u2090[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 \u2192\u2090[F] E) \u2243 {x // x \u2208 (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 \u29f8 (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) := \u27e80\u27e9\n\ninstance : decidable_eq (adjoin_root f) := classical.dec_eq _\n\nprotected lemma nontrivial [is_domain R] (h : degree f \u2260 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] \u2192+* adjoin_root f := ideal.quotient.mk _\n\n@[elab_as_eliminator]\ntheorem induction_on {C : adjoin_root f \u2192 Prop} (x : adjoin_root f)\n  (ih : \u2200 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 \u2192+* 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\u2090_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) := \u27e8of f\u27e9\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\u2081 g\u2082 : adjoin_root f \u2192\u2090[R] S}\n  (h : g\u2081 (root f) = g\u2082 (root f)) : g\u2081 = g\u2082 :=\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 \u2194 f \u2223 g - h :=\nideal.quotient.eq.trans ideal.mem_span_singleton\n\n@[simp] lemma mk_eq_zero {g : R[X]} : mk f g = 0 \u2194 f \u2223 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 \u2260 0) (hd : degree g < degree f) : mk f g \u2260 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 \u2260 0) (hd : nat_degree g < nat_degree f) : mk f g \u2260 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 (\u03bb x, by { rw aeval_C, refl })\n  (\u03bb p q ihp ihq, by rw [alg_hom.map_add, ring_hom.map_add, ihp, ihq])\n  (\u03bb 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)) = \u22a4 :=\nalgebra.eq_top_iff.2 $ \u03bb x, induction_on f x $ \u03bb p,\n(algebra.adjoin_singleton_eq_range_aeval R (root f)).symm \u25b8 \u27e8p, aeval_eq p\u27e9\n\n@[simp] lemma eval\u2082_root (f : R[X]) : f.eval\u2082 (of f) (root f) = 0 :=\nby rw [\u2190 algebra_map_eq, \u2190 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\u2082_root]\n\nlemma is_algebraic_root (hf : f \u2260 0) : is_algebraic R (root f) :=\n\u27e8f, hf, eval\u2082_root f\u27e9\n\nlemma of.injective_of_degree_ne_zero [is_domain R] (hf : f.degree \u2260 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 \u2190 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 \u2192+* S` to `adjoin_root f \u2192+* S`. -/\ndef lift (i : R \u2192+* S) (x : S) (h : f.eval\u2082 i x = 0) : (adjoin_root f) \u2192+* S :=\nbegin\n  apply ideal.quotient.lift _ (eval\u2082_ring_hom i x),\n  intros g H,\n  rcases mem_span_singleton.1 H with \u27e8y, hy\u27e9,\n  rw [hy, ring_hom.map_mul, coe_eval\u2082_ring_hom, h, zero_mul]\nend\n\nvariables {i : R \u2192+* S} {a : S} (h : f.eval\u2082 i a = 0)\n\n@[simp] lemma lift_mk (g : R[X]) : lift i a h (mk f g) = g.eval\u2082 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\u2082_X]\n\n@[simp] lemma lift_of {x : R} : lift i a h x = i x :=\nby rw [\u2190 mk_C x, lift_mk, eval\u2082_C]\n\n@[simp] lemma lift_comp_of : (lift i a h).comp (of f) = i :=\nring_hom.ext $ \u03bb _, @lift_of _ _ _ _ _ _ _ h _\n\nvariables (f) [algebra R S]\n\n/-- Produce an algebra homomorphism `adjoin_root f \u2192\u2090[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 \u2192\u2090[R] S :=\n{ commutes' := \u03bb 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 \u2192+* S) = lift (algebra_map R S) x hfx := rfl\n\n@[simp] lemma aeval_alg_hom_eq_zero (\u03d5 : adjoin_root f \u2192\u2090[R] S) : aeval (\u03d5 (root f)) f = 0 :=\nbegin\n  have h : \u03d5.to_ring_hom.comp (of f) = algebra_map R S := ring_hom.ext_iff.mpr (\u03d5.commutes),\n  rw [aeval_def, \u2190h, \u2190ring_hom.map_zero \u03d5.to_ring_hom, \u2190eval\u2082_root f, hom_eval\u2082],\n  refl,\nend\n\n@[simp] lemma lift_hom_eq_alg_hom (f : R[X]) (\u03d5 : adjoin_root f \u2192\u2090[R] S) :\n  lift_hom f (\u03d5 (root f)) (aeval_alg_hom_eq_zero f \u03d5) = \u03d5 :=\nbegin\n  suffices : \u03d5.equalizer (lift_hom f (\u03d5 (root f)) (aeval_alg_hom_eq_zero f \u03d5)) = \u22a4,\n  { exact (alg_hom.ext (\u03bb x, (set_like.ext_iff.mp (this) x).mpr algebra.mem_top)).symm },\n  rw [eq_top_iff, \u2190adjoin_root_eq_top, algebra.adjoin_le_iff, set.singleton_subset_iff],\n  exact (@lift_root _ _ _ _ _ _ _ (aeval_alg_hom_eq_zero f \u03d5)).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\u2082_sub _).symm.trans $ eval\u2082_root $ C r * X - 1);\n  simp only [eval\u2082_mul, eval\u2082_C, eval\u2082_X, eval\u2082_one]\n\nlemma alg_hom_subsingleton {S : Type*} [comm_ring S] [algebra R S] {r : R} :\n  subsingleton (adjoin_root (C r * X - 1) \u2192\u2090[R] S) :=\n\u27e8\u03bb f g, alg_hom_ext (@inv_unique _ _ (algebra_map R S r) _ _\n  (by rw [\u2190 f.commutes, \u2190 f.map_mul, algebra_map_eq, root_is_inv, map_one])\n  (by rw [\u2190 g.commutes, \u2190 g.map_mul, algebra_map_eq, root_is_inv, map_one]))\u27e9\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 \u2260 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 \u2260 0) : function.injective (coe : K \u2192 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 \u2192 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\u27e8g, hg, eval\u2082_root g\u27e9\n\n/-- `adjoin_root.mod_by_monic_hom` sends the equivalence class of `f` mod `g` to `f %\u2098 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 \u2192\u2097[R] R[X] :=\n(submodule.liftq _ (polynomial.mod_by_monic_hom g)\n  (\u03bb f (hf : f \u2208 (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 %\u2098 g := rfl\n\nlemma mk_left_inverse (hg : g.monic) :\n  function.left_inverse (mk g) (mod_by_monic_hom hg) :=\n\u03bb f, induction_on g f $ \u03bb 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 := \u03bb f i, (mod_by_monic_hom hg f).coeff i,\n  inv_fun := \u03bb c, mk g $ \u2211 (i : fin g.nat_degree), monomial i (c i),\n  map_add' := \u03bb f\u2081 f\u2082, funext $ \u03bb i,\n    by simp only [(mod_by_monic_hom hg).map_add, coeff_add, pi.add_apply],\n  map_smul' := \u03bb f\u2081 f\u2082, funext $ \u03bb i,\n    by simp only [(mod_by_monic_hom hg).map_smul, coeff_smul, pi.smul_apply, ring_hom.id_apply],\n  left_inv := \u03bb f, induction_on g f (\u03bb 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 := \u03bb x, funext $ \u03bb 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 \u2190 C_mul_X_pow_eq_monomial,\n      exact (degree_eq_nat_degree $ hg.ne_zero).symm \u25b8 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 \u2192\u2080 R) :\n  (power_basis_aux' hg).repr.symm c = mk g (\u2211 (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 \u2191i :=\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 := \u03bb 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 \u2190 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 \u2260 0) : is_integral K (root f) :=\nis_algebraic_iff_is_integral.mp (is_algebraic_root hf)\n\nlemma minpoly_root (hf : f \u2260 0) : minpoly K (root f) = f * C (f.leading_coeff\u207b\u00b9) :=\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 [\u2190commutes, ring_hom.comp_apply, mk_self, ring_hom.map_zero],\n    rwa [\u2190ideal.mem_span_singleton, \u2190ideal.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 \u2260 0) : basis (fin f.nat_degree) K (adjoin_root f) :=\nbegin\n  set f' := f * C (f.leading_coeff\u207b\u00b9) 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 _ _ _ (\u03bb (i : fin f.nat_degree), (root f ^ i.val)),\n  { rw [\u2190 deg_f', \u2190 minpoly_eq],\n    exact linear_independent_pow (root f) },\n  { rintros y -,\n    rw [\u2190 deg_f', \u2190 minpoly_eq],\n    apply (is_integral_root hf).mem_span_pow,\n    obtain \u27e8g\u27e9 := 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 \u2260 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 \u2260 0) :\n  minpoly K (power_basis hf).gen = f * C (f.leading_coeff\u207b\u00b9) :=\nby rw [power_basis_gen, minpoly_root hf]\n\nlemma minpoly_power_basis_gen_of_monic (hf : f.monic) (hf' : f \u2260 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) \u2192 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) \u2192\u2090[R] adjoin R ({x} : set S) :=\nlift_hom _ \u27e8x, self_mem_adjoin_singleton R x\u27e9\n  (by simp [\u2190 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) (\u27e8x, self_mem_adjoin_singleton R x\u27e9 : adjoin R ({x} : set S))\n  (by simp [\u2190 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  \u27e8x, self_mem_adjoin_singleton R x\u27e9 :=\nby simp\n\nvariables (R x)\n\nlemma minpoly.to_adjoin.surjective : function.surjective (minpoly.to_adjoin R x) :=\nbegin\n  rw [\u2190 range_top_iff_surjective, _root_.eq_top_iff, \u2190 adjoin_adjoin_coe_preimage],\n  refine adjoin_le _,\n  simp only [alg_hom.coe_range, set.mem_range],\n  rintro \u27e8y\u2081, y\u2082\u27e9 h,\n  refine \u27e8mk (minpoly R x) X, by simpa using h.symm\u27e9\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\u2082 : 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\u2081 : aeval (root g) (minpoly R pb.gen) = 0) (h\u2082 : aeval pb.gen g = 0) :\n  adjoin_root g \u2243\u2090[R] S :=\n{ to_fun := adjoin_root.lift_hom g pb.gen h\u2082,\n  inv_fun := pb.lift (root g) h\u2081,\n  left_inv := \u03bb x, induction_on g x $ \u03bb f, by rw [lift_hom_mk, pb.lift_aeval, aeval_eq],\n  right_inv := \u03bb x, begin\n    nontriviality S,\n    obtain \u27e8f, hf, rfl\u27e9 := 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\u2082 }\n\n@[simp] lemma equiv'_to_alg_hom\n  (h\u2081 : aeval (root g) (minpoly R pb.gen) = 0) (h\u2082 : aeval pb.gen g = 0) :\n  (equiv' g pb h\u2081 h\u2082).to_alg_hom = adjoin_root.lift_hom g pb.gen h\u2082 :=\nrfl\n\n@[simp] lemma equiv'_symm_to_alg_hom\n  (h\u2081 : aeval (root g) (minpoly R pb.gen) = 0) (h\u2082 : aeval pb.gen g = 0) :\n  (equiv' g pb h\u2081 h\u2082).symm.to_alg_hom = pb.lift (root g) h\u2081 :=\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 \u2260 0) :\n  (adjoin_root f \u2192\u2090[F] L) \u2243 {x // x \u2208 (f.map (algebra_map F L)).roots} :=\n(power_basis hf).lift_equiv'.trans ((equiv.refl _).subtype_equiv (\u03bb 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 \u2190 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[\u03b1]/(I[\u03b1]) \u2245 R[\u03b1]/((I[x] \u2294 (f)) / (f))` for `\u03b1` 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 \u29f8 I.map (of f) \u2243+*\n    adjoin_root f \u29f8 (I.map (C : R \u2192+* 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 \u2192+* 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[\u03b1]/((I[x] \u2294 (f)) / (f)) \u2245 (R[x]/I[x])/((f) \u2294 I[x] / I[x])`\n  for `\u03b1` 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) \u29f8 (I.map (C : R \u2192+* R[X])).map (span ({f} : set R[X]))^.quotient.mk \u2243+*\n    (R[X] \u29f8 I.map (C : R \u2192+* R[X])) \u29f8 (span ({f} : set R[X])).map\n    (I.map (C : R \u2192+* R[X]))^.quotient.mk :=\nquot_quot_equiv_comm (ideal.span ({f} : set R[X])) (I.map (C : R \u2192+* 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) \u2245 (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 \u29f8 I)[X] \u29f8 span ({f.map (I^.quotient.mk)} : set (polynomial (R \u29f8 I))) \u2243+*\n    (R[X] \u29f8 map C I) \u29f8 span ({(ideal.quotient.mk (I.map C)) f} : set (R[X] \u29f8 map C I)) :=\nquotient_equiv (span ({f.map (I^.quotient.mk)} : set (polynomial (R \u29f8 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[\u03b1]/I[\u03b1] \u2245 (R/I)[X]/(f mod I)` for `\u03b1` a root of `f : R[X]`\n  and `I : ideal R`.-/\ndef quot_adjoin_root_equiv_quot_polynomial_quot : (adjoin_root f) \u29f8 (I.map (of f)) \u2243+*\n  (R \u29f8 I)[X] \u29f8 (span ({f.map (I^.quotient.mk)} : set (R \u29f8 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 \u2192+* R[X]))^.quotient.mk =\n    span ({(ideal.quotient.mk (I.map polynomial.C)) f} : set (R[X] \u29f8 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 \u29f8 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 \u29f8 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, \u2190 ring_hom.comp_apply, \u2190 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) \u29f8 (ideal.map (of f) I)) \u2243\u2090[R]\n     ((R \u29f8 I) [X]) \u29f8 (ideal.span ({polynomial.map I^.quotient.mk f} : set ((R \u29f8 I) [X]))) :=\nalg_equiv.of_ring_equiv (show \u2200 x, (quot_adjoin_root_equiv_quot_polynomial_quot I f)\n  (algebra_map R _ x) = algebra_map R _ x, from \u03bb x, begin\n    have : algebra_map R ((adjoin_root f) \u29f8 (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 `\u03b1` have minimal polynomial `f` over `R` and `I` be an ideal of `R`,\nthen `R[\u03b1] / (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 \u29f8 I.map (algebra_map R S)) \u2243\u2090[R] (polynomial (R \u29f8 I)) \u29f8\n    (ideal.span ({(minpoly R pb.gen).map I^.quotient.mk} : set (polynomial (R \u29f8 I)))) :=\n(of_ring_equiv\n  (show \u2200 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, \u2190 alg_equiv.coe_ring_hom_commutes,\n          \u2190 adjoin_root.algebra_map_eq, alg_hom.comp_algebra_map]))\n    (algebra_map R (S \u29f8 I.map (algebra_map R S)) x) = algebra_map R _ x, from\n  (\u03bb x, by rw [\u2190 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 \u22a3 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\u2081 w\u2082 v u\nvariables {C : Type u} [category.{v} C] (J : grothendieck_topology C)\nvariables {D : Type w\u2081} [category.{max v u} D]\nvariables {E : Type w\u2082} [category.{max v u} E]\nvariables {F : D \u2964 E} {G : E \u2964 D}\nvariables [\u2200 (X : C) (S : J.cover X) (P : C\u1d52\u1d56 \u2964 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 \u2964 SheafOfTypes J :=\nSheaf_compose J (forget D) \u22d9 (Sheaf_equiv_SheafOfTypes J).functor\n\n-- We need to sheafify...\nvariables\n  [\u2200 (P : C\u1d52\u1d56 \u2964 D) (X : C) (S : J.cover X), has_multiequalizer (S.index P)]\n  [\u2200 (X : C), has_colimits_of_shape (J.cover X)\u1d52\u1d56 D]\n  [\u2200 (X : C), preserves_colimits_of_shape (J.cover X)\u1d52\u1d56 (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 \u22d9 G`. -/\nabbreviation compose_and_sheafify (G : E \u2964 D) : Sheaf J E \u2964 Sheaf J D :=\nSheaf_to_presheaf J E \u22d9 (whiskering_right _ _ _).obj G \u22d9 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 \u22a3 F) (X : Sheaf J E) (Y : Sheaf J D) :\n((compose_and_sheafify J G).obj X \u27f6 Y) \u2243 (X \u27f6 (Sheaf_compose J F).obj Y) :=\nlet A := adj.whisker_right C\u1d52\u1d56 in\n{ to_fun := \u03bb \u03b7, \u27e8A.hom_equiv _ _ (J.to_sheafify _  \u226b \u03b7.val)\u27e9,\n  inv_fun := \u03bb \u03b3, \u27e8J.sheafify_lift ((A.hom_equiv _ _).symm ((Sheaf_to_presheaf _ _).map \u03b3)) Y.2\u27e9,\n  left_inv := begin\n    intros \u03b7,\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 \u03b3,\n    ext1,\n    dsimp,\n    rw [J.to_sheafify_sheafify_lift, equiv.apply_symm_apply],\n  end }\n\n/-- An adjunction `adj : G \u22a3 F` with `F : D \u2964 E` and `G : E \u2964 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 \u22a3 F) : compose_and_sheafify J G \u22a3 Sheaf_compose J F :=\nadjunction.mk_of_hom_equiv\n{ hom_equiv := compose_equiv J adj,\n  hom_equiv_naturality_left_symm' := \u03bb X' X Y f g, by { ext1, dsimp, simp },\n  hom_equiv_naturality_right' := \u03bb X Y Y' f g, by { ext1, dsimp, simp } }\n\ninstance [is_right_adjoint F] : is_right_adjoint (Sheaf_compose J F) :=\n\u27e8_, adjunction J (adjunction.of_right_adjoint F)\u27e9\n\nsection forget_to_type\n\n/-- This is the functor sending a sheaf of types `X` to the sheafification of `X \u22d9 G`. -/\nabbreviation compose_and_sheafify_from_types (G : Type (max v u) \u2964 D) :\n  SheafOfTypes J \u2964 Sheaf J D :=\n(Sheaf_equiv_SheafOfTypes J).inverse \u22d9 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) \u2964 D} (adj : G \u22a3 forget D) :\n  compose_and_sheafify_from_types J G \u22a3 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) \u2964 D} (adj : G \u22a3 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) \u226b\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) \u2964 D} (adj : G \u22a3 forget D)\n  (X : Sheaf J D) :\n  ((adjunction_to_types J adj).counit.app X).val =\n  J.sheafify_lift ((functor.associator _ _ _).hom \u226b (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\u27e8_, adjunction_to_types J (adjunction.of_right_adjoint (forget D))\u27e9\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 \u2192 Y) [HasAdjointT f]\n  : HasAdjoint (f\u2020) := sorry_proof\n\n\ninstance adjoint.arg_fy.isSmooth_2 {X Y W} [Vec W] [SemiHilbert X] [SemiHilbert Y]\n  (A : W \u2192 X \u2192 Y) [\u2200 x, HasAdjointT (A x)] [\u2200 w, IsSmoothT (A w)] [IsSmoothT \u03bb w => \u03bb x \u27ff A w x] (w : W)\n  : IsSmoothT (\u03bb y => (A w)\u2020 y) := sorry_proof\n\ninstance adjoint.arg_fy.isSmooth_1 {X Y W} [Vec W] [SemiHilbert X] [SemiHilbert Y]\n  (A : W \u2192 X \u2192 Y) [\u2200 x, HasAdjointT (A x)] [\u2200 w, IsSmoothT (A w)] [IsSmoothT \u03bb w => \u03bb x \u27ff A w x]\n  : IsSmoothT (\u03bb w => \u03bb y \u27ff (A w)\u2020 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 \u2192 Y) [IsLin A] : HasAdjointT A := sorry_proof\n\n-- example {X Y} [Hilbert X] [Hilbert Y] (A : X \u22b8 Y) : IsLinT \u03bb x => adjoint A x := by infer_instance\n\n--------------------------------------------------------------------------------\n\nvariable {\u03b1 \u03b2 \u03b3 : Type}\nvariable {X Y Z : Type} [SemiHilbert X] [SemiHilbert Y] [SemiHilbert Z]\nvariable {Y\u2081 Y\u2082 : Type} [SemiHilbert Y\u2081] [SemiHilbert Y\u2082]\nvariable {\u03b9 : Type} [Enumtype \u03b9]\n\n@[simp \u2193, diff]\ntheorem id.arg_x.adj_simp\n  : (\u03bb x : X => x)\u2020 = \u03bb x => x := sorry_proof\n\n@[simp \u2193, diff]\ntheorem const.arg_x.adj_simp\n  : (\u03bb (x : X) (i : \u03b9) => x)\u2020 = \u03bb f => \u2211 i, f i := sorry_proof\n\n@[simp \u2193, diff]\ntheorem const.arg_y.adj_simp\n  : (\u03bb (y : Y) => (0 : X))\u2020 = \u03bb y' => (0 : Y) := sorry_proof\n\n@[simp \u2193 low-3, diff low-3]\ntheorem swap.arg_y.adj_simp\n  (f : \u03b9 \u2192 Y \u2192 Z) [\u2200 i, HasAdjointT (f i)] \n  : (\u03bb y i => f i y)\u2020 = \u03bb g => \u2211 i, (f i)\u2020 (g i) := sorry_proof\n\n@[simp \u2193 low-4, diff low-4]\ntheorem swapDep.arg_y.adj_simp\n  {\u03b9 Y} {Z : \u03b9 \u2192 Type} [SemiHilbert Y] [\u2200 i, SemiHilbert (Z i)] [Enumtype \u03b9]\n  (f : (i : \u03b9) \u2192 Y \u2192 Z i) [\u2200 i, HasAdjointT (f i)] \n  : (\u03bb y i => f i y)\u2020 = \u03bb g => \u2211 i, (f i)\u2020 (g i) := sorry_proof\n\n-- @[simp \u2193 (low-1), diff low-4, simp_guard g (\u03bb x => x)]\ntheorem scomb.arg_x.adj_simp\n  (f : X \u2192 Y \u2192 Z) [HasAdjointNT 2 f]\n  (g : X \u2192 Y) [HasAdjointT g]\n  : (\u03bb x => f x (g x))\u2020 \n    =\n    \u03bb z' =>\n      let (x',y') := (uncurryN 2 f)\u2020 z'\n      x' + g\u2020 y'  \n  := sorry_proof\n  \n@[simp \u2193 low, diff low-3, simp_guard g (\u03bb x => x)]\ntheorem comp.arg_x.adj_simp\n  (f : Y \u2192 Z) [HasAdjointT f] \n  (g : X \u2192 Y) [HasAdjointT g] \n  : (\u03bb x => f (g x))\u2020 = \u03bb z => g\u2020 (f\u2020 z) := sorry_proof\n\n-- @[simp \u2193 low]\n-- theorem subst.arg_x.adj_simp\n--   (f : X \u2192 Y \u2192 Z) [HasAdjoint (\u03bb ((x,y) : X \u00d7 Y) => f x y)] \n--   (g : X \u2192 Y) [HasAdjoint g] \n--   : (\u03bb x => f x (g x))\u2020 \n--     = \u03bb z =>\n--         let f' := (\u03bb (x,y) => f x y)\u2020\n--         (f' z).1 + g\u2020 (f' z).2\n-- := by sorry_proof\n\n-- TODO: add simp guard!\n@[simp \u2193 low, diff low, simp_guard g\u2081 Prod.fst, g\u2082 Prod.snd]\ntheorem diag.arg_x.adj_simp\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 Z) [HasAdjointNT 2 f] \n  (g\u2081 : X \u2192 Y\u2081) [HasAdjointT g\u2081] \n  (g\u2082 : X \u2192 Y\u2082) [HasAdjointT g\u2082] \n  : (\u03bb x => f (g\u2081 x) (g\u2082 x))\u2020 \n    = \u03bb z => \n      let (y\u2081, y\u2082) := (uncurryN 2 f)\u2020 z\n      (g\u2081\u2020 y\u2081) + (g\u2082\u2020 y\u2082)\n:= by sorry_proof\n\n-- This prevents an infinite loop when using `adjoint_of_diag` \n-- with `g\u2081 = Prod.fst` and `g\u2082 = Prod.snd`\n-- @[simp \u2193 low+1, diff low+1]\n-- theorem diag.arg_x.adj_simp_safeguard\n--   (f : X \u2192 Y \u2192 Z) [HasAdjointNT 2 f]\n--   : adjoint (\u03bb xy => f xy.1 xy.2) = (uncurryN 2 f)\u2020 := by rfl; done \n\n@[simp \u2193 low, diff low]\ntheorem eval.arg_f.adj_simp\n  (i : \u03b9)\n  : (\u03bb (f : \u03b9 \u2192 X) => f i)\u2020 = (\u03bb f' j => ([[i = j]] \u2022 f' : X))\n:= sorry_proof\n\n@[simp \u2193 low-1, diff low-1]\ntheorem evalDep.arg_f.adj_simp\n  {\u03b9} {X : \u03b9 \u2192 Type} [\u2200 i, SemiHilbert (X i)] [Enumtype \u03b9]\n  (i : \u03b9)\n  : (\u03bb (f : (i' : \u03b9) \u2192 X i') => f i)\u2020 = (\u03bb f' j => (if h : i = j then h \u25b8 f' else 0))\n:= sorry_proof\n\n@[simp \u2193 low-1, diff low-1]\ntheorem eval.arg_x.parm1.adj_simp\n  (f : X \u2192 \u03b9 \u2192 Z) [HasAdjointT f] (i : \u03b9)\n  : (\u03bb x => f x i)\u2020 = (\u03bb x' => f\u2020 (\u03bb j => ([[i = j]] \u2022 x')))\n:= \nby \n  rw [comp.arg_x.adj_simp (\u03bb (x : \u03b9 \u2192 Z) => x i) f]\n  simp; done\n\n@[simp \u2193 low-2, diff low-2]\ntheorem evalDep.arg_x.parm1.adj_simp\n  {\u03b9 Y} {Z : \u03b9 \u2192 Type} [SemiHilbert Y] [\u2200 i, SemiHilbert (Z i)] [Enumtype \u03b9]\n  (f : X \u2192 (i : \u03b9) \u2192 Z i) [HasAdjointT f] (i : \u03b9)\n  : (\u03bb x => f x i)\u2020 = (\u03bb x' => f\u2020 (\u03bb j => (if h : i = j then h \u25b8 x' else 0)))\n:= \nby \n  rw [comp.arg_x.adj_simp (\u03bb (x : (i : \u03b9) \u2192 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 \u2192 Z)\n  (f :  Y \u2192 \u03b1 \u2192 Z) (g  : X \u2192 Y) (a : \u03b1)  \nwhere\n  f? =?= \u03bb x => f x a\n  |- \n  (\u03bb x => f? (g x))\u2020 =?= (\u03bb x => f (g x) a)\u2020\n\nunif_hint comp.arg_x.adj_simp.unif_hint_2 (f? : Y \u2192 Z)  \n  (f  : Y \u2192 \u03b1 \u2192 \u03b2 \u2192 Z) (g  : X \u2192 Y) (a : \u03b1) (b : \u03b2)\nwhere\n  f? =?= \u03bb x => f x a b\n  |-\n  (\u03bb x => f? (g x))\u2020 =?= (\u03bb x => f (g x) a b)\u2020\n\nunif_hint comp.arg_x.adj_simp.unif_hint_3 (f? : Y \u2192 Z)\n  (f  : Y \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 Z) (g  : X \u2192 Y) (a : \u03b1) (b : \u03b2) (c : \u03b3)  \nwhere\n  f? =?= \u03bb x => f x a b c\n  |-\n  (\u03bb x => f? (g x))\u2020 =?= (\u03bb x => f (g x) a b c)\u2020\n\n-- unif_hint scomb.arg_x.adj_simp.unif_hint_1\n--   (a : \u03b1)\n--   (g? : X \u2192 Y) (f? : X \u2192 Y \u2192 Z)\n--   (g : X \u2192 Y) (f  : X \u2192 Y \u2192 \u03b1 \u2192 Z) where\n--   g? =?= g\n--   f? =?= \u03bb x y => f x y a\n--   |-\n--   (\u03bb x => f? x (g? x))\u2020 =?= (\u03bb x => f x (g x) a)\u2020\n\n\nunif_hint diag.arg_x.adj_simp.unif_hint_1 (f? : Y\u2081 \u2192 Y\u2082 \u2192 Z)\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 \u03b1 \u2192 Z) (g\u2081 : X \u2192 Y\u2081) (g\u2082 : X \u2192 Y\u2082) (a : \u03b1)\nwhere  \n  f? =?= \u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a\n  |-\n  (\u03bb x => f? (g\u2081 x) (g\u2082 x))\u2020 =?= (\u03bb x => f (g\u2081 x) (g\u2082 x) a)\u2020 \n\nunif_hint diag.arg_x.adj_simp.unif_hint_2 (f? : Y\u2081 \u2192 Y\u2082 \u2192 Z)\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 \u03b1 \u2192 \u03b2 \u2192 Z) (g\u2081 : X \u2192 Y\u2081) (g\u2082 : X \u2192 Y\u2082) (a : \u03b1) (b : \u03b2)\nwhere  \n  f? =?= \u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a b\n  |-\n  (\u03bb x => f? (g\u2081 x) (g\u2082 x))\u2020 =?= (\u03bb x => f (g\u2081 x) (g\u2082 x) a b)\u2020 \n\nunif_hint diag.arg_x.adj_simp.unif_hint_3 (f? : Y\u2081 \u2192 Y\u2082 \u2192 Z)\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 Z) (g\u2081 : X \u2192 Y\u2081) (g\u2082 : X \u2192 Y\u2082) (a : \u03b1) (b : \u03b2) (c : \u03b3)\nwhere  \n  f? =?= \u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a b c\n  |-\n  (\u03bb x => f? (g\u2081 x) (g\u2082 x))\u2020 =?= (\u03bb x => f (g\u2081 x) (g\u2082 x) a b c)\u2020 \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 \u221ad` where `a b : \u2124`. 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 : \u2124) := mk {} ::\n(re : \u2124)\n(im : \u2124)\n\nprefix `\u2124\u221a`:100 := zsqrtd\n\nnamespace zsqrtd\nsection\n  parameters {d : \u2124}\n\n  instance : decidable_eq \u2124\u221ad :=\n  by tactic.mk_dec_eq_instance\n\n  theorem ext : \u2200 {z w : \u2124\u221ad}, z = w \u2194 z.re = w.re \u2227 z.im = w.im\n  | \u27e8x, y\u27e9 \u27e8x', y'\u27e9 := \u27e8\u03bb h, by injection h; split; assumption,\n                        \u03bb \u27e8h\u2081, h\u2082\u27e9, by congr; assumption\u27e9\n\n  /-- Convert an integer to a `\u2124\u221ad` -/\n  def of_int (n : \u2124) : \u2124\u221ad := \u27e8n, 0\u27e9\n  @[simp] theorem of_int_re (n : \u2124) : (of_int n).re = n := rfl\n  @[simp] theorem of_int_im (n : \u2124) : (of_int n).im = 0 := rfl\n\n  /-- The zero of the ring -/\n  def zero : \u2124\u221ad := of_int 0\n  instance : has_zero \u2124\u221ad := \u27e8zsqrtd.zero\u27e9\n  @[simp] theorem zero_re : (0 : \u2124\u221ad).re = 0 := rfl\n  @[simp] theorem zero_im : (0 : \u2124\u221ad).im = 0 := rfl\n\n  /-- The one of the ring -/\n  def one : \u2124\u221ad := of_int 1\n  instance : has_one \u2124\u221ad := \u27e8zsqrtd.one\u27e9\n  @[simp] theorem one_re : (1 : \u2124\u221ad).re = 1 := rfl\n  @[simp] theorem one_im : (1 : \u2124\u221ad).im = 0 := rfl\n\n  /-- The representative of `\u221ad` in the ring -/\n  def sqrtd : \u2124\u221ad := \u27e80, 1\u27e9\n  @[simp] theorem sqrtd_re : (sqrtd : \u2124\u221ad).re = 0 := rfl\n  @[simp] theorem sqrtd_im : (sqrtd : \u2124\u221ad).im = 1 := rfl\n\n  /-- Addition of elements of `\u2124\u221ad` -/\n  def add : \u2124\u221ad \u2192 \u2124\u221ad \u2192 \u2124\u221ad\n  | \u27e8x, y\u27e9 \u27e8x', y'\u27e9 := \u27e8x + x', y + y'\u27e9\n  instance : has_add \u2124\u221ad := \u27e8zsqrtd.add\u27e9\n  @[simp] theorem add_def (x y x' y' : \u2124) :\n    (\u27e8x, y\u27e9 + \u27e8x', y'\u27e9 : \u2124\u221ad) = \u27e8x + x', y + y'\u27e9 := rfl\n  @[simp] theorem add_re : \u2200 z w : \u2124\u221ad, (z + w).re = z.re + w.re\n  | \u27e8x, y\u27e9 \u27e8x', y'\u27e9 := rfl\n  @[simp] theorem add_im : \u2200 z w : \u2124\u221ad, (z + w).im = z.im + w.im\n  | \u27e8x, y\u27e9 \u27e8x', y'\u27e9 := rfl\n\n  @[simp] theorem bit0_re (z) : (bit0 z : \u2124\u221ad).re = bit0 z.re := add_re _ _\n  @[simp] theorem bit0_im (z) : (bit0 z : \u2124\u221ad).im = bit0 z.im := add_im _ _\n\n  @[simp] theorem bit1_re (z) : (bit1 z : \u2124\u221ad).re = bit1 z.re := by simp [bit1]\n  @[simp] theorem bit1_im (z) : (bit1 z : \u2124\u221ad).im = bit0 z.im := by simp [bit1]\n\n  /-- Negation in `\u2124\u221ad` -/\n  def neg : \u2124\u221ad \u2192 \u2124\u221ad\n  | \u27e8x, y\u27e9 := \u27e8-x, -y\u27e9\n  instance : has_neg \u2124\u221ad := \u27e8zsqrtd.neg\u27e9\n  @[simp] theorem neg_re : \u2200 z : \u2124\u221ad, (-z).re = -z.re\n  | \u27e8x, y\u27e9 := rfl\n  @[simp] theorem neg_im : \u2200 z : \u2124\u221ad, (-z).im = -z.im\n  | \u27e8x, y\u27e9 := rfl\n\n  /-- Conjugation in `\u2124\u221ad`. The conjugate of `a + b \u221ad` is `a - b \u221ad`. -/\n  def conj : \u2124\u221ad \u2192 \u2124\u221ad\n  | \u27e8x, y\u27e9 := \u27e8x, -y\u27e9\n  @[simp] theorem conj_re : \u2200 z : \u2124\u221ad, (conj z).re = z.re\n  | \u27e8x, y\u27e9 := rfl\n  @[simp] theorem conj_im : \u2200 z : \u2124\u221ad, (conj z).im = -z.im\n  | \u27e8x, y\u27e9 := rfl\n\n  /-- Multiplication in `\u2124\u221ad` -/\n  def mul : \u2124\u221ad \u2192 \u2124\u221ad \u2192 \u2124\u221ad\n  | \u27e8x, y\u27e9 \u27e8x', y'\u27e9 := \u27e8x * x' + d * y * y', x * y' + y * x'\u27e9\n  instance : has_mul \u2124\u221ad := \u27e8zsqrtd.mul\u27e9\n  @[simp] theorem mul_re : \u2200 z w : \u2124\u221ad, (z * w).re = z.re * w.re + d * z.im * w.im\n  | \u27e8x, y\u27e9 \u27e8x', y'\u27e9 := rfl\n  @[simp] theorem mul_im : \u2200 z w : \u2124\u221ad, (z * w).im = z.re * w.im + z.im * w.re\n  | \u27e8x, y\u27e9 \u27e8x', y'\u27e9 := rfl\n\n  instance : comm_ring \u2124\u221ad := 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 \u2124\u221ad    := by apply_instance\n  instance : add_monoid \u2124\u221ad         := by apply_instance\n  instance : monoid \u2124\u221ad             := by apply_instance\n  instance : comm_monoid \u2124\u221ad        := by apply_instance\n  instance : comm_semigroup \u2124\u221ad     := by apply_instance\n  instance : semigroup \u2124\u221ad          := by apply_instance\n  instance : add_comm_semigroup \u2124\u221ad := by apply_instance\n  instance : add_semigroup \u2124\u221ad      := by apply_instance\n  instance : comm_semiring \u2124\u221ad      := by apply_instance\n  instance : semiring \u2124\u221ad           := by apply_instance\n  instance : ring \u2124\u221ad               := by apply_instance\n  instance : distrib \u2124\u221ad            := by apply_instance\n\n  instance : zero_ne_one_class \u2124\u221ad :=\n  { zero := 0, one := 1, zero_ne_one := dec_trivial }\n\n  instance : nonzero_comm_ring \u2124\u221ad :=\n  { ..zsqrtd.comm_ring, ..zsqrtd.zero_ne_one_class }\n\n  @[simp] theorem coe_nat_re (n : \u2115) : (n : \u2124\u221ad).re = n :=\n  by induction n; simp *\n  @[simp] theorem coe_nat_im (n : \u2115) : (n : \u2124\u221ad).im = 0 :=\n  by induction n; simp *\n  theorem coe_nat_val (n : \u2115) : (n : \u2124\u221ad) = \u27e8n, 0\u27e9 :=\n  by simp [ext]\n\n  @[simp] theorem coe_int_re (n : \u2124) : (n : \u2124\u221ad).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 : \u2124) : (n : \u2124\u221ad).im = 0 :=\n  by cases n; simp *\n  theorem coe_int_val (n : \u2124) : (n : \u2124\u221ad) = \u27e8n, 0\u27e9 :=\n  by simp [ext]\n\n  instance : char_zero \u2124\u221ad :=\n  { cast_inj := \u03bb m n, \u27e8by simp [zsqrtd.ext], congr_arg _\u27e9 }\n\n  @[simp] theorem of_int_eq_coe (n : \u2124) : (of_int n : \u2124\u221ad) = n :=\n  by simp [ext]\n\n  @[simp] theorem smul_val (n x y : \u2124) : (n : \u2124\u221ad) * \u27e8x, y\u27e9 = \u27e8n * x, n * y\u27e9 :=\n  by simp [ext]\n\n  @[simp] theorem muld_val (x y : \u2124) : sqrtd * \u27e8x, y\u27e9 = \u27e8d * y, x\u27e9 :=\n  by simp [ext]\n\n  @[simp] theorem smuld_val (n x y : \u2124) : sqrtd * (n : \u2124\u221ad) * \u27e8x, y\u27e9 = \u27e8d * n * y, n * x\u27e9 :=\n  by simp [ext]\n\n  theorem decompose {x y : \u2124} : (\u27e8x, y\u27e9 : \u2124\u221ad) = x + sqrtd * y :=\n  by simp [ext]\n\n  theorem mul_conj {x y : \u2124} : (\u27e8x, y\u27e9 * conj \u27e8x, y\u27e9 : \u2124\u221ad) = x * x - d * y * y :=\n  by simp [ext, mul_comm]\n\n  theorem conj_mul : \u03a0 {a b : \u2124\u221ad}, conj (a * b) = conj a * conj b :=\n  by simp [ext]\n\n  protected lemma coe_int_add (m n : \u2124) : (\u2191(m + n) : \u2124\u221ad) = \u2191m + \u2191n := by simp [ext]\n  protected lemma coe_int_sub (m n : \u2124) : (\u2191(m - n) : \u2124\u221ad) = \u2191m - \u2191n := by simp [ext]\n  protected lemma coe_int_mul (m n : \u2124) : (\u2191(m * n) : \u2124\u221ad) = \u2191m * \u2191n := by simp [ext]\n  protected lemma coe_int_inj {m n : \u2124} (h : (\u2191m : \u2124\u221ad) = \u2191n) : m = n :=\n  by simpa using congr_arg re h\n\n  /-- Read `sq_le a c b d` as `a \u221ac \u2264 b \u221ad` -/\n  def sq_le (a c b d : \u2115) : Prop := c*a*a \u2264 d*b*b\n\n  theorem sq_le_of_le {c d x y z w : \u2115} (xz : z \u2264 x) (yw : y \u2264 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 : \u2115} (xy : sq_le x c y d) (zw : sq_le z c w d) :\n    c * (x * z) \u2264 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 : \u2115} (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 : \u2115} (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 : \u2115} (n : \u2115) (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 : \u2115} :\n    (sq_le x 1 y d \u2192 sq_le z 1 w d \u2192 sq_le (x * w + y * z) d (x * z + d * y * w) 1) \u2227\n    (sq_le x 1 y d \u2192 sq_le w d z 1 \u2192 sq_le (x * z + d * y * w) 1 (x * w + y * z) d) \u2227\n    (sq_le y d x 1 \u2192 sq_le z 1 w d \u2192 sq_le (x * z + d * y * w) 1 (x * w + y * z) d) \u2227\n    (sq_le y d x 1 \u2192 sq_le w d z 1 \u2192 sq_le (x * w + y * z) d (x * z + d * y * w) 1) :=\n  by refine \u27e8_, _, _, _\u27e9; {\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 \u221ac + b \u221ad \u2265 0`;\n    we are interested in the case `c = 1` but this is more symmetric -/\n  def nonnegg (c d : \u2115) : \u2124 \u2192 \u2124 \u2192 Prop\n  | (a : \u2115) (b : \u2115) := true\n  | (a : \u2115) -[1+ b] := sq_le (b+1) c a d\n  | -[1+ a] (b : \u2115) := sq_le (a+1) d b c\n  | -[1+ a] -[1+ b] := false\n\n  theorem nonnegg_comm {c d : \u2115} {x y : \u2124} : 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} : \u03a0 {a b : \u2115}, nonnegg c d (-a) b \u2194 sq_le a d b c\n  | 0     b := \u27e8by simp [sq_le, nat.zero_le], \u03bba, trivial\u27e9\n  | (a+1) b := by rw \u2190 int.neg_succ_of_nat_coe; refl\n\n  theorem nonnegg_pos_neg {c d} {a b : \u2115} : nonnegg c d a (-b) \u2194 sq_le b c a d :=\n  by rw nonnegg_comm; exact nonnegg_neg_pos\n\n  theorem nonnegg_cases_right {c d} {a : \u2115} : \u03a0 {b : \u2124}, (\u03a0 x : \u2115, b = -x \u2192 sq_le x c a d) \u2192 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 : \u2115} {a : \u2124} (h : \u03a0 x : \u2115, a = -x \u2192 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 : \u2124\u221ad) : \u2124 := 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 : \u2124) : norm n = n * n := by simp [norm]\n\n@[simp] lemma norm_nat_cast (n : \u2115) : norm n = n * n := norm_int_cast n\n\n@[simp] lemma norm_mul (n m : \u2124\u221ad) : 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 : \u2124\u221ad) : (norm n : \u2124\u221ad) = 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 \u2264 0) (n : \u2124\u221ad) : 0 \u2264 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 : \u2124\u221ad} : x.norm.nat_abs = 1 \u2194 is_unit x :=\n\u27e8\u03bb h, is_unit_iff_dvd_one.2 $\n  (le_total 0 (norm x)).cases_on\n    (\u03bb hx, show x \u2223 1, from \u27e8x.conj,\n      by rwa [\u2190 int.coe_nat_inj', int.nat_abs_of_nonneg hx,\n        \u2190 @int.cast_inj (\u2124\u221ad) _ _, norm_eq_mul_conj, eq_comm] at h\u27e9)\n    (\u03bb hx, show x \u2223 1, from \u27e8- x.conj,\n      by rwa [\u2190 int.coe_nat_inj', int.of_nat_nat_abs_of_nonpos hx,\n        \u2190 @int.cast_inj (\u2124\u221ad) _ _, int.cast_neg, norm_eq_mul_conj, neg_mul_eq_mul_neg,\n        eq_comm] at h\u27e9),\n\u03bb h, let \u27e8y, hy\u27e9 := is_unit_iff_dvd_one.1 h in begin\n  have := congr_arg (int.nat_abs \u2218 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\u27e9\n\nend norm\n\nend\n\nsection\nparameter {d : \u2115}\n\n  /-- Nonnegativity of an element of `\u2124\u221ad`. -/\n  def nonneg : \u2124\u221ad \u2192 Prop | \u27e8a, b\u27e9 := nonnegg d 1 a b\n\n  protected def le (a b : \u2124\u221ad) : Prop := nonneg (b - a)\n\n  instance : has_le \u2124\u221ad := \u27e8zsqrtd.le\u27e9\n\n  protected def lt (a b : \u2124\u221ad) : Prop := \u00ac(b \u2264 a)\n\n  instance : has_lt \u2124\u221ad := \u27e8zsqrtd.lt\u27e9\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 : \u03a0 (a : \u2124\u221ad), decidable (nonneg a)\n  | \u27e8a, b\u27e9 := zsqrtd.decidable_nonnegg _ _ _ _\n\n  instance decidable_le (a b : \u2124\u221ad) : decidable (a \u2264 b) := decidable_nonneg _\n\n  theorem nonneg_cases : \u03a0 {a : \u2124\u221ad}, nonneg a \u2192 \u2203 x y : \u2115, a = \u27e8x, y\u27e9 \u2228 a = \u27e8x, -y\u27e9 \u2228 a = \u27e8-x, y\u27e9\n  | \u27e8(x : \u2115), (y : \u2115)\u27e9 h := \u27e8x, y, or.inl rfl\u27e9\n  | \u27e8(x : \u2115), -[1+ y]\u27e9 h := \u27e8x, y+1, or.inr $ or.inl rfl\u27e9\n  | \u27e8-[1+ x], (y : \u2115)\u27e9 h := \u27e8x+1, y, or.inr $ or.inr rfl\u27e9\n  | \u27e8-[1+ x], -[1+ y]\u27e9 h := false.elim h\n\n  lemma nonneg_add_lem {x y z w : \u2115} (xy : nonneg \u27e8x, -y\u27e9) (zw : nonneg \u27e8-z, w\u27e9) : nonneg (\u27e8x, -y\u27e9 + \u27e8-z, w\u27e9) :=\n  have nonneg \u27e8int.sub_nat_nat x z, int.sub_nat_nat w y\u27e9, from int.sub_nat_nat_elim x z\n    (\u03bbm n i, sq_le y d m 1 \u2192 sq_le n 1 w d \u2192 nonneg \u27e8i, int.sub_nat_nat w y\u27e9)\n    (\u03bbj k, int.sub_nat_nat_elim w y\n      (\u03bbm n i, sq_le n d (k + j) 1 \u2192 sq_le k 1 m d \u2192 nonneg \u27e8int.of_nat j, i\u27e9)\n      (\u03bbm n xy zw, trivial)\n      (\u03bbm n xy zw, sq_le_cancel zw xy))\n    (\u03bbj k, int.sub_nat_nat_elim w y\n      (\u03bbm n i, sq_le n d k 1 \u2192 sq_le (k + j + 1) 1 m d \u2192 nonneg \u27e8-[1+ j], i\u27e9)\n      (\u03bbm n xy zw, sq_le_cancel xy zw)\n      (\u03bbm 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 \u2264 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 \u27e8_, _\u27e9, 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 : \u2124\u221ad} (ha : nonneg a) (hb : nonneg b) : nonneg (a + b) :=\n  begin\n    rcases nonneg_cases ha with \u27e8x, y, rfl|rfl|rfl\u27e9;\n    rcases nonneg_cases hb with \u27e8z, w, rfl|rfl|rfl\u27e9; dsimp [add, nonneg] at ha hb \u22a2,\n    { trivial },\n    { refine nonnegg_cases_right (\u03bbi 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 (\u03bbi 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 (\u03bbi 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 (\u03bbi 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 \u2191y], 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 : \u2124\u221ad) : a \u2264 a := show nonneg (a - a), by simp\n\n  protected theorem le_trans {a b c : \u2124\u221ad} (ab : a \u2264 b) (bc : b \u2264 c) : a \u2264 c :=\n  have nonneg (b - a + (c - b)), from nonneg_add ab bc,\n  by simpa\n\n  theorem nonneg_iff_zero_le {a : \u2124\u221ad} : nonneg a \u2194 0 \u2264 a := show _ \u2194 nonneg _, by simp\n\n  theorem le_of_le_le {x y z w : \u2124} (xz : x \u2264 z) (yw : y \u2264 w) : (\u27e8x, y\u27e9 : \u2124\u221ad) \u2264 \u27e8z, w\u27e9 :=\n  show nonneg \u27e8z - x, w - y\u27e9, from\n  match z - x, w - y, int.le.dest_sub xz, int.le.dest_sub yw with ._, ._, \u27e8a, rfl\u27e9, \u27e8b, rfl\u27e9 := trivial end\n\n  theorem le_arch (a : \u2124\u221ad) : \u2203n : \u2115, a \u2264 n :=\n  let \u27e8x, y, (h : a \u2264 \u27e8x, y\u27e9)\u27e9 := show \u2203x y : \u2115, nonneg (\u27e8x, y\u27e9 + -a), from match -a with\n  | \u27e8int.of_nat x, int.of_nat y\u27e9 := \u27e80, 0, trivial\u27e9\n  | \u27e8int.of_nat x, -[1+ y]\u27e9      := \u27e80, y+1, by simp [int.neg_succ_of_nat_coe]\u27e9\n  | \u27e8-[1+ x],      int.of_nat y\u27e9 := \u27e8x+1, 0, by simp [int.neg_succ_of_nat_coe]\u27e9\n  | \u27e8-[1+ x],      -[1+ y]\u27e9      := \u27e8x+1, y+1, by simp [int.neg_succ_of_nat_coe]\u27e9\n  end in begin\n    refine \u27e8x + d*y, zsqrtd.le_trans h _\u27e9,\n    rw [\u2190 int.cast_coe_nat, \u2190 of_int_eq_coe],\n    change nonneg \u27e8(\u2191x + d*y) - \u2191x, 0-\u2191y\u27e9,\n    cases y with y,\n    { simp },\n    have h : \u2200y, sq_le y d (d * y) 1 := \u03bb 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:\u2124) + d * nat.succ y - x = d * nat.succ y, by simp],\n    exact h (y+1)\n  end\n\n  protected theorem nonneg_total : \u03a0 (a : \u2124\u221ad), nonneg a \u2228 nonneg (-a)\n  | \u27e8(x : \u2115), (y : \u2115)\u27e9 := or.inl trivial\n  | \u27e8-[1+ x], -[1+ y]\u27e9 := or.inr trivial\n  | \u27e80,       -[1+ y]\u27e9 := or.inr trivial\n  | \u27e8-[1+ x], 0\u27e9       := or.inr trivial\n  | \u27e8(x+1:\u2115), -[1+ y]\u27e9 := nat.le_total\n  | \u27e8-[1+ x], (y+1:\u2115)\u27e9 := nat.le_total\n\n  protected theorem le_total (a b : \u2124\u221ad) : a \u2264 b \u2228 b \u2264 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 \u2124\u221ad :=\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 := \u03bb a b,\n      (and_iff_right_of_imp (zsqrtd.le_total _ _).resolve_left).symm }\n\n  protected theorem add_le_add_left (a b : \u2124\u221ad) (ab : a \u2264 b) (c : \u2124\u221ad) : c + a \u2264 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 : \u2124\u221ad) (h : c + a \u2264 c + b) : a \u2264 b :=\n  by simpa using zsqrtd.add_le_add_left _ _ h (-c)\n\n  protected theorem add_lt_add_left (a b : \u2124\u221ad) (h : a < b) (c) : c + a < c + b :=\n  \u03bb h', h (zsqrtd.le_of_add_le_add_left _ _ _ h')\n\n  theorem nonneg_smul {a : \u2124\u221ad} {n : \u2115} (ha : nonneg a) : nonneg (n * a) :=\n  by rw \u2190 int.cast_coe_nat; exact match a, nonneg_cases ha, ha with\n  | ._, \u27e8x, y, or.inl rfl\u27e9,          ha := by rw smul_val; trivial\n  | ._, \u27e8x, y, or.inr $ or.inl rfl\u27e9, ha := by rw smul_val; simpa using\n    nonnegg_pos_neg.2 (sq_le_smul n $ nonnegg_pos_neg.1 ha)\n  | ._, \u27e8x, y, or.inr $ or.inr rfl\u27e9, 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 : \u2124\u221ad} (ha : nonneg a) : nonneg (sqrtd * a) :=\n  by refine match a, nonneg_cases ha, ha with\n  | ._, \u27e8x, y, or.inl rfl\u27e9,          ha := trivial\n  | ._, \u27e8x, y, or.inr $ or.inl rfl\u27e9, 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  | ._, \u27e8x, y, or.inr $ or.inr rfl\u27e9, 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 : \u2115} {a : \u2124\u221ad} (ha : nonneg a) : nonneg (\u27e8x, y\u27e9 * a) :=\n  have (\u27e8x, y\u27e9 * a : \u2124\u221ad) = 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 : \u2124\u221ad} (ha : nonneg a) (hb : nonneg b) : nonneg (a * b) :=\n  match a, b, nonneg_cases ha, nonneg_cases hb, ha, hb with\n  | ._, ._, \u27e8x, y, or.inl rfl\u27e9,          \u27e8z, w, or.inl rfl\u27e9,          ha, hb := trivial\n  | ._, ._, \u27e8x, y, or.inl rfl\u27e9,          \u27e8z, w, or.inr $ or.inr rfl\u27e9, ha, hb := nonneg_mul_lem hb\n  | ._, ._, \u27e8x, y, or.inl rfl\u27e9,          \u27e8z, w, or.inr $ or.inl rfl\u27e9, ha, hb := nonneg_mul_lem hb\n  | ._, ._, \u27e8x, y, or.inr $ or.inr rfl\u27e9, \u27e8z, w, or.inl rfl\u27e9,          ha, hb := by rw mul_comm; exact nonneg_mul_lem ha\n  | ._, ._, \u27e8x, y, or.inr $ or.inl rfl\u27e9, \u27e8z, w, or.inl rfl\u27e9,          ha, hb := by rw mul_comm; exact nonneg_mul_lem ha\n  | ._, ._, \u27e8x, y, or.inr $ or.inr rfl\u27e9, \u27e8z, w, or.inr $ or.inr rfl\u27e9, ha, hb :=\n    by rw [calc (\u27e8-x, y\u27e9 * \u27e8-z, w\u27e9 : \u2124\u221ad) = \u27e8_, _\u27e9 : rfl\n        ... = \u27e8x * z + d * y * w, -(x * w + y * z)\u27e9 : by simp]; exact\n    nonnegg_pos_neg.2 (sq_le_mul.left (nonnegg_neg_pos.1 ha) (nonnegg_neg_pos.1 hb))\n  | ._, ._, \u27e8x, y, or.inr $ or.inr rfl\u27e9, \u27e8z, w, or.inr $ or.inl rfl\u27e9, ha, hb :=\n    by rw [calc (\u27e8-x, y\u27e9 * \u27e8z, -w\u27e9 : \u2124\u221ad) = \u27e8_, _\u27e9 : rfl\n        ... = \u27e8-(x * z + d * y * w), x * w + y * z\u27e9 : by simp]; exact\n    nonnegg_neg_pos.2 (sq_le_mul.right.left (nonnegg_neg_pos.1 ha) (nonnegg_pos_neg.1 hb))\n  | ._, ._, \u27e8x, y, or.inr $ or.inl rfl\u27e9, \u27e8z, w, or.inr $ or.inr rfl\u27e9, ha, hb :=\n    by rw [calc (\u27e8x, -y\u27e9 * \u27e8-z, w\u27e9 : \u2124\u221ad) = \u27e8_, _\u27e9 : rfl\n        ... = \u27e8-(x * z + d * y * w), x * w + y * z\u27e9 : 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  | ._, ._, \u27e8x, y, or.inr $ or.inl rfl\u27e9, \u27e8z, w, or.inr $ or.inl rfl\u27e9, ha, hb :=\n    by rw [calc (\u27e8x, -y\u27e9 * \u27e8z, -w\u27e9 : \u2124\u221ad) = \u27e8_, _\u27e9 : rfl\n        ... = \u27e8x * z + d * y * w, -(x * w + y * z)\u27e9 : 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 : \u2124\u221ad) : 0 \u2264 a \u2192 0 \u2264 b \u2192 0 \u2264 a * b :=\n  by repeat {rw \u2190 nonneg_iff_zero_le}; exact nonneg_mul\n\n  theorem not_sq_le_succ (c d y) (h : c > 0) : \u00acsq_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 : \u2115) : Prop := (ns : \u2200n : \u2115, x \u2260 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 \u2227 y = 0 :=\n  let g := x.gcd y in or.elim g.eq_zero_or_pos\n    (\u03bbH, \u27e8nat.eq_zero_of_gcd_eq_zero_left H, nat.eq_zero_of_gcd_eq_zero_right H\u27e9)\n    (\u03bbgpos, false.elim $\n      let \u27e8m, n, co, (hx : x = m * g), (hy : y = n * g)\u27e9 := 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 : \u2124} (h : x * x = d * y * y) : x = 0 \u2227 y = 0 :=\n  by rw [mul_assoc, \u2190 int.nat_abs_mul_self, \u2190 int.nat_abs_mul_self, \u2190 int.coe_nat_mul, \u2190 mul_assoc] at h;\n  exact let \u27e8h1, h2\u27e9 := divides_sq_eq_zero (int.coe_nat_inj h) in\n  \u27e8int.eq_zero_of_nat_abs_eq_zero h1, int.eq_zero_of_nat_abs_eq_zero h2\u27e9\n\n  theorem not_divides_square (x y) : (x + 1) * (x + 1) \u2260 d * (y + 1) * (y + 1) :=\n  \u03bbe, by have t := (divides_sq_eq_zero e).left; contradiction\n\n  theorem nonneg_antisymm : \u03a0 {a : \u2124\u221ad}, nonneg a \u2192 nonneg (-a) \u2192 a = 0\n  | \u27e80,         0\u27e9         xy yx := rfl\n  | \u27e8-[1+ x],   -[1+ y]\u27e9   xy yx := false.elim xy\n  | \u27e8(x+1:nat), (y+1:nat)\u27e9 xy yx := false.elim yx\n  | \u27e8-[1+ x],   0\u27e9         xy yx := absurd xy (not_sq_le_succ _ _ _ dec_trivial)\n  | \u27e8(x+1:nat), 0\u27e9         xy yx := absurd yx (not_sq_le_succ _ _ _ dec_trivial)\n  | \u27e80,         -[1+ y]\u27e9   xy yx := absurd xy (not_sq_le_succ _ _ _ d_pos)\n  | \u27e80,         (y+1:nat)\u27e9 _  yx := absurd yx (not_sq_le_succ _ _ _ d_pos)\n  | \u27e8(x+1:nat), -[1+ y]\u27e9   (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  | \u27e8-[1+ x],   (y+1:nat)\u27e9 (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 : \u2124\u221ad} (ab : a \u2264 b) (ba : b \u2264 a) : a = b :=\n  eq_of_sub_eq_zero $ nonneg_antisymm ba (by rw neg_sub; exact ab)\n\n  instance : decidable_linear_order \u2124\u221ad :=\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 : \u03a0 {a b : \u2124\u221ad}, a * b = 0 \u2192 a = 0 \u2228 b = 0\n  | \u27e8x, y\u27e9 \u27e8z, w\u27e9 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 \u2192 (\u27e8x, y\u27e9:\u2124\u221ad) = 0, from\n    \u03bbe, match x, y, divides_sq_eq_zero_z e with ._, ._, \u27e8rfl, rfl\u27e9 := 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 \u2124\u221ad :=\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 : \u2124\u221ad) (a0 : 0 < a) (b0 : 0 < b) : 0 < a * b := \u03bbab,\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    (\u03bbe, ne_of_gt a0 e)\n    (\u03bbe, ne_of_gt b0 e)\n\n  instance : decidable_linear_ordered_comm_ring \u2124\u221ad :=\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 \u2124\u221ad := by apply_instance\n  instance : linear_ordered_semiring \u2124\u221ad           := by apply_instance\n  instance : ordered_semiring \u2124\u221ad                  := 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 : \u03b1) : cond c a b = if c then a else b := by cases c <;> rfl\n\ntheorem cond_decide {\u03b1} (p : Prop) [Decidable p] (t e : \u03b1) : 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 \u03b1] (x y : \u03b1) :\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 \u2192 (addDecl s y).contains x\n:= by\n  intro h\n  simp [Std.AssocList.contains, addDecl] at h \u22a2\n  apply Exists.elim h\n  split <;> simp_all\n  done\n\ndef addSubSup: String \u2192 String \u2192 Std.AssocList String Strings \u2192 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: \u2203 x, x \u2208 Std.AssocList.toList (addSubSup sub sup tail) \u2227 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: \u2203 x, x \u2208 Std.AssocList.toList (addSubSup sub sup tail) \u2227 x.fst = sup)\n: \u2203 x, x \u2208 Std.AssocList.toList (addSubSup sub sup (Std.AssocList.cons sup [] (Std.AssocList.cons key value tail))) \u2227 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: \u2203 x, x \u2208 Std.AssocList.toList (addSubSup sub sup (Std.AssocList.cons sup [] tail)) \u2227 x.fst = sup)\n: \u2203 x, x \u2208 Std.AssocList.toList (addSubSup sub sup (Std.AssocList.cons sup [] (Std.AssocList.cons key value tail))) \u2227 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: \u2203 a, a \u2208 Std.AssocList.toList s \u2227 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: \u2203 x, x \u2208 Std.AssocList.toList tail \u2227 x.fst = sup)\n: \u2203 x, x \u2208 Std.AssocList.toList (addSubSup sub sup tail) \u2227 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: \u2203 x, x \u2208 Std.AssocList.toList ss' \u2227 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 \u2192 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\u2081 : a = b) (h\u2082 : c = b) : a = c := by\n  have aux := h\u2082.symm\n  subst aux\n  subst h\u2081\n  exact rfl\n\n\ndef ex1 : {\u03b1 : Type} \u2192 {a b c : \u03b1} \u2192 a = b \u2192 b = c \u2192 a = c :=\n  @(by intro \u03b1 a b c h\u2081 h\u2082\n       exact Eq.trans h\u2081 h\u2082)\n\ndef f1 (x : Nat) : Nat := by\n  apply (\u00b7 + ?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) 2020 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\nimport tactic.fresh_names\n\nopen tactic\nopen native\n\nexample (n m o p : \u2115) : true :=\nby do\n  [n, m, o, p] \u2190 [`n, `m, `o, `p].mmap get_local,\n  [n_uname, m_uname, o_uname, p_uname] \u2190 pure $\n    [n, m, o, p].map expr.local_uniq_name,\n\n  let renames := rb_map.of_list\n    [ (n_uname, [`p, `j]),\n      (m_uname, [`i, `k]),\n      (o_uname, [`i, `k]),\n      (p_uname, [`i]) ],\n  let reserved := name_set.of_list [`i_1],\n  rename_fresh renames reserved,\n\n  `[ guard_hyp p : \u2115 ],\n  `[ guard_hyp i : \u2115 ],\n  `[ guard_hyp k : \u2115 ],\n  `[ guard_hyp i_2 : \u2115 ],\n\n  exact `(trivial)\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/fresh_names.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6859494485880928, "lm_q1q2_score": 0.4972243662413915}}
{"text": "/-\nCopyright (c) 2019 Reid Barton. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 : Type*} {\u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n\ninstance : topological_space (list \u03b1) :=\ntopological_space.mk_of_nhds (traverse nhds)\n\nlemma nhds_list (as : list \u03b1) : \ud835\udcdd as = traverse \ud835\udcdd 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 \u2264 list.cons <$> \ud835\udcdd a <*> traverse \ud835\udcdd 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 \u27e8u, hu, hus\u27e9, clear as hs,\n    have : \u2203v:list (set \u03b1), l.forall\u2082 (\u03bba s, is_open s \u2227 a \u2208 s) v \u2227 sequence v \u2286 s,\n    { induction hu generalizing s,\n      case list.forall\u2082.nil : hs this\n        { existsi [], simpa only [list.forall\u2082_nil_left_iff, exists_eq_left] },\n      case list.forall\u2082.cons : a s as ss ht h ih t hts\n      { rcases mem_nhds_iff.1 ht with \u27e8u, hut, hu\u27e9,\n        rcases ih _ subset.rfl with \u27e8v, hv, hvss\u27e9,\n        exact \u27e8u::v, list.forall\u2082.cons hu hv,\n          subset.trans (set.seq_mono (set.image_subset _ hut) hvss) hts\u27e9 } },\n    rcases this with \u27e8v, hv, hvs\u27e9,\n    refine \u27e8sequence v, mem_traverse _ _ _, hvs, _\u27e9,\n    { exact hv.imp (assume a s \u27e8hs, ha\u27e9, is_open.mem_nhds hs ha) },\n    { assume u hu,\n      have hu := (list.mem_traverse _ _).1 hu,\n      have : list.forall\u2082 (\u03bba s, is_open s \u2227 a \u2208 s) u v,\n      { refine list.forall\u2082.flip _,\n        replace hv := hv.flip,\n        simp only [list.forall\u2082_and_left, flip] at \u22a2 hv,\n        exact \u27e8hv.1, hu.flip\u27e9 },\n      refine mem_of_superset _ hvs,\n      exact mem_traverse _ _ (this.imp $ assume a s \u27e8hs, ha\u27e9, is_open.mem_nhds hs ha) } }\nend\n\n@[simp] lemma nhds_nil : \ud835\udcdd ([] : list \u03b1) = pure [] :=\nby rw [nhds_list, list.traverse_nil _]; apply_instance\n\nlemma nhds_cons (a : \u03b1) (l : list \u03b1) :\n  \ud835\udcdd (a :: l) = list.cons <$> \ud835\udcdd a <*> \ud835\udcdd l  :=\nby rw [nhds_list, list.traverse_cons _, \u2190 nhds_list]; apply_instance\n\nlemma list.tendsto_cons {a : \u03b1} {l : list \u03b1} :\n  tendsto (\u03bbp:\u03b1\u00d7list \u03b1, list.cons p.1 p.2) (\ud835\udcdd a \u00d7\u1da0 \ud835\udcdd l) (\ud835\udcdd (a :: l)) :=\nby rw [nhds_cons, tendsto, filter.map_prod]; exact le_rfl\n\nlemma filter.tendsto.cons {\u03b1 : Type*} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 list \u03b2}\n  {a : _root_.filter \u03b1} {b : \u03b2} {l : list \u03b2} (hf : tendsto f a (\ud835\udcdd b)) (hg : tendsto g a (\ud835\udcdd l)) :\n  tendsto (\u03bba, list.cons (f a) (g a)) a (\ud835\udcdd (b :: l)) :=\nlist.tendsto_cons.comp (tendsto.prod_mk hf hg)\n\nnamespace list\n\nlemma tendsto_cons_iff {\u03b2 : Type*} {f : list \u03b1 \u2192 \u03b2} {b : _root_.filter \u03b2} {a : \u03b1} {l : list \u03b1} :\n  tendsto f (\ud835\udcdd (a :: l)) b \u2194 tendsto (\u03bbp:\u03b1\u00d7list \u03b1, f (p.1 :: p.2)) (\ud835\udcdd a \u00d7\u1da0 \ud835\udcdd l) b :=\nhave \ud835\udcdd (a :: l) = (\ud835\udcdd a \u00d7\u1da0 \ud835\udcdd l).map (\u03bbp:\u03b1\u00d7list \u03b1, (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, (\u2218)] with functor_norm,\nend,\nby rw [this, filter.tendsto_map'_iff]\n\nlemma continuous_cons : continuous (\u03bb x : \u03b1 \u00d7 list \u03b1, (x.1 :: x.2 : list \u03b1)) :=\ncontinuous_iff_continuous_at.mpr $ \u03bb \u27e8x, y\u27e9, continuous_at_fst.cons continuous_at_snd\n\nlemma tendsto_nhds {\u03b2 : Type*} {f : list \u03b1 \u2192 \u03b2} {r : list \u03b1 \u2192 _root_.filter \u03b2}\n  (h_nil : tendsto f (pure []) (r []))\n  (h_cons : \u2200l a, tendsto f (\ud835\udcdd l) (r l) \u2192\n    tendsto (\u03bbp:\u03b1\u00d7list \u03b1, f (p.1 :: p.2)) (\ud835\udcdd a \u00d7\u1da0 \ud835\udcdd l) (r (a::l))) :\n  \u2200l, tendsto f (\ud835\udcdd 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  \u2200(l : list \u03b1), 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 (\u03bbx, x + 1) _) _,\n    refine tendsto.comp ih tendsto_snd }\nend\n\nlemma tendsto_insert_nth' {a : \u03b1} : \u2200{n : \u2115} {l : list \u03b1},\n  tendsto (\u03bbp:\u03b1\u00d7list \u03b1, insert_nth n p.1 p.2) (\ud835\udcdd a \u00d7\u1da0 \ud835\udcdd l) (\ud835\udcdd (insert_nth n a l))\n| 0     l  := tendsto_cons\n| (n+1) [] := by simp\n| (n+1) (a'::l) :=\n  have \ud835\udcdd a \u00d7\u1da0 \ud835\udcdd (a' :: l) =\n    (\ud835\udcdd a \u00d7\u1da0 (\ud835\udcdd a' \u00d7\u1da0 \ud835\udcdd l)).map (\u03bbp:\u03b1\u00d7\u03b1\u00d7list \u03b1, (p.1, p.2.1 :: p.2.2)),\n  begin\n    simp only [nhds_cons, filter.prod_eq, \u2190 filter.map_def, \u2190 filter.seq_eq_filter_seq],\n    simp [-filter.seq_eq_filter_seq, -filter.map_def, (\u2218)] 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 {\u03b2} {n : \u2115} {a : \u03b1} {l : list \u03b1} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 list \u03b1}\n  {b : _root_.filter \u03b2} (hf : tendsto f b (\ud835\udcdd a)) (hg : tendsto g b (\ud835\udcdd l)) :\n  tendsto (\u03bbb:\u03b2, insert_nth n (f b) (g b)) b (\ud835\udcdd (insert_nth n a l)) :=\ntendsto_insert_nth'.comp (tendsto.prod_mk hf hg)\n\nlemma continuous_insert_nth {n : \u2115} : continuous (\u03bbp:\u03b1\u00d7list \u03b1, insert_nth n p.1 p.2) :=\ncontinuous_iff_continuous_at.mpr $\n  assume \u27e8a, l\u27e9, by rw [continuous_at, nhds_prod_eq]; exact tendsto_insert_nth'\n\nlemma tendsto_remove_nth : \u2200{n : \u2115} {l : list \u03b1},\n  tendsto (\u03bbl, remove_nth l n) (\ud835\udcdd l) (\ud835\udcdd (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 : \u2115} : continuous (\u03bbl : list \u03b1, remove_nth l n) :=\ncontinuous_iff_continuous_at.mpr $ assume a, tendsto_remove_nth\n\n@[to_additive]\nlemma tendsto_prod [monoid \u03b1] [has_continuous_mul \u03b1] {l : list \u03b1} :\n  tendsto list.prod (\ud835\udcdd l) (\ud835\udcdd 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 \u03b1] [has_continuous_mul \u03b1] : continuous (prod : list \u03b1 \u2192 \u03b1) :=\ncontinuous_iff_continuous_at.mpr $ \u03bb l, tendsto_prod\n\nend list\n\nnamespace vector\nopen list\n\ninstance (n : \u2115) : topological_space (vector \u03b1 n) :=\nby unfold vector; apply_instance\n\n\n\nlemma tendsto_insert_nth\n  {n : \u2115} {i : fin (n+1)} {a:\u03b1} :\n  \u2200{l:vector \u03b1 n}, tendsto (\u03bbp:\u03b1\u00d7vector \u03b1 n, insert_nth p.1 i p.2)\n    (\ud835\udcdd a \u00d7\u1da0 \ud835\udcdd l) (\ud835\udcdd (insert_nth a i l))\n| \u27e8l, hl\u27e9 :=\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 : \u2115} {i : fin (n+1)} :\n  continuous (\u03bbp:\u03b1\u00d7vector \u03b1 n, insert_nth p.1 i p.2) :=\ncontinuous_iff_continuous_at.mpr $ assume \u27e8a, l\u27e9,\n  by rw [continuous_at, nhds_prod_eq]; exact tendsto_insert_nth\n\nlemma continuous_insert_nth {n : \u2115} {i : fin (n+1)}\n  {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 vector \u03b1 n} (hf : continuous f) (hg : continuous g) :\n  continuous (\u03bbb, insert_nth (f b) i (g b)) :=\ncontinuous_insert_nth'.comp (hf.prod_mk hg : _)\n\nlemma continuous_at_remove_nth {n : \u2115} {i : fin (n+1)} :\n  \u2200{l:vector \u03b1 (n+1)}, continuous_at (remove_nth i) l\n| \u27e8l, hl\u27e9 :=\n--  \u2200{l:vector \u03b1 (n+1)}, tendsto (remove_nth i) (\ud835\udcdd l) (\ud835\udcdd (remove_nth i l))\n--| \u27e8l, hl\u27e9 :=\nbegin\n  rw [continuous_at, remove_nth, tendsto_subtype_rng],\n  simp only [\u2190 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 : \u2115} {i : fin (n+1)} :\n  continuous (remove_nth i : vector \u03b1 (n+1) \u2192 vector \u03b1 n) :=\ncontinuous_iff_continuous_at.mpr $ assume \u27e8a, l\u27e9, 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 \u03b1 n`: `n`-ary function `\u03b1 \u2192 \u03b1 \u2192 ... \u2192 \u03b1`. 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 `\u03c9` 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 \u00d7 y` that can be considered as a ZFC\n  function `x \u2192 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 \u2192 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 `\u03b1 \u2192 \u03b1 \u2192 ... \u2192 \u03b1`. -/\ndef arity (\u03b1 : Type u) : \u2115 \u2192 Type u\n| 0     := \u03b1\n| (n+1) := \u03b1 \u2192 arity n\n\nnamespace arity\n\n/-- Constant `n`-ary function with value `a`. -/\ndef const {\u03b1 : Type u} (a : \u03b1) : \u2200 n, arity \u03b1 n\n| 0     := a\n| (n+1) := \u03bb _, const n\n\ninstance arity.inhabited {\u03b1 n} [inhabited \u03b1] : inhabited (arity \u03b1 n) :=\n\u27e8const default _\u27e9\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 (\u03b1 : Type u) (A : \u03b1 \u2192 pSet) : pSet\n\nnamespace pSet\n\n/-- The underlying type of a pre-set -/\n@[nolint has_inhabited_instance] def type : pSet \u2192 Type u\n| \u27e8\u03b1, A\u27e9 := \u03b1\n\n/-- The underlying pre-set family of a pre-set -/\ndef func : \u03a0 (x : pSet), x.type \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := A\n\ntheorem mk_type_func : \u03a0 (x : pSet), mk x.type x.func = x\n| \u27e8\u03b1, A\u27e9 := 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 (\u03bb \u03b1 z m \u27e8\u03b2, B\u27e9, (\u2200 a, \u2203 b, m a (B b)) \u2227 (\u2200 b, \u2203 a, m a (B b))) x y\n\ntheorem equiv.refl (x) : equiv x x :=\npSet.rec_on x $ \u03bb \u03b1 A IH, \u27e8\u03bb a, \u27e8a, IH a\u27e9, \u03bb a, \u27e8a, IH a\u27e9\u27e9\n\ntheorem equiv.rfl : \u2200 {x}, equiv x x := equiv.refl\n\ntheorem equiv.euc {x} : \u03a0 {y z}, equiv x y \u2192 equiv z y \u2192 equiv x z :=\npSet.rec_on x $ \u03bb \u03b1 A IH y, pSet.cases_on y $ \u03bb \u03b2 B \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 \u27e8\u03b3\u03b2, \u03b2\u03b3\u27e9,\n\u27e8\u03bb a, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a, \u27e8c, bc\u27e9 := \u03b2\u03b3 b in \u27e8c, IH a ab bc\u27e9,\n  \u03bb c, let \u27e8b, cb\u27e9 := \u03b3\u03b2 c, \u27e8a, ba\u27e9 := \u03b2\u03b1 b in \u27e8a, IH a ba cb\u27e9\u27e9\n\ntheorem equiv.symm {x y} : equiv x y \u2192 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\u27e8pSet.equiv, equiv.refl, \u03bb x y, equiv.symm, \u03bb x y z, equiv.trans\u27e9\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 \u2192 pSet \u2192 Prop\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u2200 a, \u2203 b, equiv (A a) (B b)\n\ninstance : has_subset pSet := \u27e8pSet.subset\u27e9\n\ntheorem equiv.ext : \u03a0 (x y : pSet), equiv x y \u2194 (x \u2286 y \u2227 y \u2286 x)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 :=\n  \u27e8\u03bb \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9, \u27e8\u03b1\u03b2, \u03bb b, let \u27e8a, h\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.symm h\u27e9\u27e9,\n    \u03bb \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9, \u27e8\u03b1\u03b2, \u03bb b, let \u27e8a, h\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.symm h\u27e9\u27e9\u27e9\n\ntheorem subset.congr_left : \u03a0 {x y z : pSet}, equiv x y \u2192 (x \u2286 z \u2194 y \u2286 z)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 :=\n  \u27e8\u03bb \u03b1\u03b3 b, let \u27e8a, ba\u27e9 := \u03b2\u03b1 b, \u27e8c, ac\u27e9 := \u03b1\u03b3 a in \u27e8c, (equiv.symm ba).trans ac\u27e9,\n    \u03bb \u03b2\u03b3 a, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a, \u27e8c, bc\u27e9 := \u03b2\u03b3 b in \u27e8c, equiv.trans ab bc\u27e9\u27e9\n\ntheorem subset.congr_right : \u03a0 {x y z : pSet}, equiv x y \u2192 (z \u2286 x \u2194 z \u2286 y)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 :=\n  \u27e8\u03bb \u03b3\u03b1 c, let \u27e8a, ca\u27e9 := \u03b3\u03b1 c, \u27e8b, ab\u27e9 := \u03b1\u03b2 a in \u27e8b, ca.trans ab\u27e9,\n    \u03bb \u03b3\u03b2 c, let \u27e8b, cb\u27e9 := \u03b3\u03b2 c, \u27e8a, ab\u27e9 := \u03b2\u03b1 b in \u27e8a, cb.trans (equiv.symm ab)\u27e9\u27e9\n\n/-- `x \u2208 y` as pre-sets if `x` is extensionally equivalent to a member of the family `y`. -/\ndef mem : pSet \u2192 pSet \u2192 Prop\n| x \u27e8\u03b2, B\u27e9 := \u2203 b, equiv x (B b)\ninstance : has_mem pSet.{u} pSet.{u} := \u27e8mem\u27e9\n\ntheorem mem.mk {\u03b1: Type u} (A : \u03b1 \u2192 pSet) (a : \u03b1) : A a \u2208 mk \u03b1 A :=\n\u27e8a, equiv.refl (A a)\u27e9\n\ntheorem mem.ext : \u03a0 {x y : pSet.{u}}, (\u2200 w : pSet.{u}, w \u2208 x \u2194 w \u2208 y) \u2192 equiv x y\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 h := \u27e8\u03bb a, (h (A a)).1 (mem.mk A a),\n    \u03bb b, let \u27e8a, ha\u27e9 := (h (B b)).2 (mem.mk B b) in \u27e8a, ha.symm\u27e9\u27e9\n\ntheorem mem.congr_right : \u03a0 {x y : pSet.{u}}, equiv x y \u2192 (\u2200 {w : pSet.{u}}, w \u2208 x \u2194 w \u2208 y)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 w :=\n  \u27e8\u03bb \u27e8a, ha\u27e9, let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8b, ha.trans hb\u27e9,\n    \u03bb \u27e8b, hb\u27e9, let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8a, hb.euc ha\u27e9\u27e9\n\ntheorem equiv_iff_mem {x y : pSet.{u}} : equiv x y \u2194 (\u2200 {w : pSet.{u}}, w \u2208 x \u2194 w \u2208 y) :=\n\u27e8mem.congr_right, match x, y with\n| \u27e8\u03b1, A\u27e9, \u27e8\u03b2, B\u27e9, h := \u27e8\u03bb a, h.1 (mem.mk A a), \u03bb b,\n  let \u27e8a, h\u27e9 := h.2 (mem.mk B b) in \u27e8a, h.symm\u27e9\u27e9\nend\u27e9\n\ntheorem mem.congr_left : \u03a0 {x y : pSet.{u}}, equiv x y \u2192 (\u2200 {w : pSet.{u}}, x \u2208 w \u2194 y \u2208 w)\n| x y h \u27e8\u03b1, A\u27e9 := \u27e8\u03bb \u27e8a, ha\u27e9, \u27e8a, h.symm.trans ha\u27e9, \u03bb \u27e8a, ha\u27e9, \u27e8a, h.trans ha\u27e9\u27e9\n\n/-- Convert a pre-set to a `set` of pre-sets. -/\ndef to_set (u : pSet.{u}) : set pSet.{u} := {x | x \u2208 u}\n\n/-- Two pre-sets are equivalent iff they have the same members. -/\ntheorem equiv.eq {x y : pSet} : equiv x y \u2194 to_set x = to_set y :=\nequiv_iff_mem.trans set.ext_iff.symm\n\ninstance : has_coe pSet (set pSet) := \u27e8to_set\u27e9\n\n/-- The empty pre-set -/\nprotected def empty : pSet := \u27e8ulift empty, \u03bb e, match e with end\u27e9\n\ninstance : has_emptyc pSet := \u27e8pSet.empty\u27e9\n\ninstance : inhabited pSet := \u27e8\u2205\u27e9\n\ntheorem mem_empty (x : pSet.{u}) : x \u2209 (\u2205 : pSet.{u}) := \u03bb e, match e with end\n\n/-- Insert an element into a pre-set -/\nprotected def insert : pSet \u2192 pSet \u2192 pSet\n| u \u27e8\u03b1, A\u27e9 := \u27e8option \u03b1, \u03bb o, option.rec u A o\u27e9\n\ninstance : has_insert pSet pSet := \u27e8pSet.insert\u27e9\n\ninstance : has_singleton pSet pSet := \u27e8\u03bb s, insert s \u2205\u27e9\n\ninstance : is_lawful_singleton pSet pSet := \u27e8\u03bb _, rfl\u27e9\n\n/-- The n-th von Neumann ordinal -/\ndef of_nat : \u2115 \u2192 pSet\n| 0     := \u2205\n| (n+1) := pSet.insert (of_nat n) (of_nat n)\n\n/-- The von Neumann ordinal \u03c9 -/\ndef omega : pSet := \u27e8ulift \u2115, \u03bb n, of_nat n.down\u27e9\n\n/-- The pre-set separation operation `{x \u2208 a | p x}` -/\nprotected def sep (p : set pSet) : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8{a // p (A a)}, \u03bb x, A x.1\u27e9\n\ninstance : has_sep pSet pSet := \u27e8pSet.sep\u27e9\n\n/-- The pre-set powerset operator -/\ndef powerset : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8set \u03b1, \u03bb p, \u27e8{a // p a}, \u03bb x, A x.1\u27e9\u27e9\n\ntheorem mem_powerset : \u03a0 {x y : pSet}, y \u2208 powerset x \u2194 y \u2286 x\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u27e8\u03bb \u27e8p, e\u27e9, (subset.congr_left e).2 $ \u03bb \u27e8a, pa\u27e9, \u27e8a, equiv.refl (A a)\u27e9,\n  \u03bb \u03b2\u03b1, \u27e8{a | \u2203 b, equiv (B b) (A a)}, \u03bb b, let \u27e8a, ba\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, b, ba\u27e9, ba\u27e9,\n    \u03bb \u27e8a, b, ba\u27e9, \u27e8b, ba\u27e9\u27e9\u27e9\n\n/-- The pre-set union operator -/\ndef Union : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8\u03a3x, (A x).type, \u03bb \u27e8x, y\u27e9, (A x).func y\u27e9\n\ntheorem mem_Union : \u03a0 {x y : pSet.{u}}, y \u2208 Union x \u2194 \u2203 z : pSet.{u}, \u2203 _ : z \u2208 x, y \u2208 z\n| \u27e8\u03b1, A\u27e9 y :=\n  \u27e8\u03bb \u27e8\u27e8a, c\u27e9, (e : equiv y ((A a).func c))\u27e9,\n    have func (A a) c \u2208 mk (A a).type (A a).func, from mem.mk (A a).func c,\n    \u27e8_, mem.mk _ _, (mem.congr_left e).2 (by rwa mk_type_func at this)\u27e9,\n  \u03bb \u27e8\u27e8\u03b2, B\u27e9, \u27e8a, (e : equiv (mk \u03b2 B) (A a))\u27e9, \u27e8b, yb\u27e9\u27e9,\n    by { rw \u2190(mk_type_func (A a)) at e, exact\n    let \u27e8\u03b2t, t\u03b2\u27e9 := e, \u27e8c, bc\u27e9 := \u03b2t b in \u27e8\u27e8a, c\u27e9, yb.trans bc\u27e9 }\u27e9\n\n/-- The image of a function from pre-sets to pre-sets. -/\ndef image (f : pSet.{u} \u2192 pSet.{u}) : pSet.{u} \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8\u03b1, \u03bb a, f (A a)\u27e9\n\ntheorem mem_image {f : pSet.{u} \u2192 pSet.{u}} (H : \u2200 {x y}, equiv x y \u2192 equiv (f x) (f y)) :\n  \u03a0 {x y : pSet.{u}}, y \u2208 image f x \u2194 \u2203 z \u2208 x, equiv y (f z)\n| \u27e8\u03b1, A\u27e9 y := \u27e8\u03bb \u27e8a, ya\u27e9, \u27e8A a, mem.mk A a, ya\u27e9, \u03bb \u27e8z, \u27e8a, za\u27e9, yz\u27e9, \u27e8a, yz.trans (H za)\u27e9\u27e9\n\n/-- Universe lift operation -/\nprotected def lift : pSet.{u} \u2192 pSet.{max u v}\n| \u27e8\u03b1, A\u27e9 := \u27e8ulift \u03b1, \u03bb \u27e8x\u27e9, lift (A x)\u27e9\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} := \u27e8ulift.{v u+1} pSet, \u03bb \u27e8x\u27e9, pSet.lift.{u (max (u+1) v)} x\u27e9\n\ntheorem lift_mem_embed : \u03a0 (x : pSet.{u}), pSet.lift.{u (max (u+1) v)} x \u2208 embed.{u v} :=\n\u03bb x, \u27e8\u27e8x\u27e9, equiv.rfl\u27e9\n\n/-- Function equivalence is defined so that `f ~ g` iff `\u2200 x y, x ~ y \u2192 f x ~ g y`. This extends to\nequivalence of `n`-ary functions. -/\ndef arity.equiv : \u03a0 {n}, arity pSet.{u} n \u2192 arity pSet.{u} n \u2192 Prop\n| 0     a b := equiv a b\n| (n+1) a b := \u2200 x y, equiv x y \u2192 arity.equiv (a x) (b y)\n\nlemma arity.equiv_const {a : pSet.{u}} : \u2200 n, arity.equiv (arity.const a n) (arity.const a n)\n| 0 := equiv.rfl\n| (n+1) := \u03bb 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\u27e8\u27e8arity.const default _, arity.equiv_const _\u27e9\u27e9\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\u27e8f.1 x, f.2 _ _ $ equiv.refl x\u27e9\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 : \u03a0 {n} {a b c : resp n}, resp.equiv a b \u2192 resp.equiv c b \u2192 resp.equiv a c\n| 0     a b c hab hcb := hab.euc hcb\n| (n+1) a b c hab hcb := \u03bb 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\u27e8resp.equiv, resp.refl, \u03bb x y h, resp.euc (resp.refl y) h,\n  \u03bb x y z h1 h2, resp.euc h1 $ resp.euc (resp.refl z) h2\u27e9\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 : \u03a0 {n}, {f : resp n \u2192 arity Set.{u} n // \u2200 (a b : resp n), resp.equiv a b \u2192 f a = f b}\n| 0     := \u27e8\u03bb a, \u27e6a.1\u27e7, \u03bb a b h, quotient.sound h\u27e9\n| (n+1) := let F : resp (n + 1) \u2192 arity Set (n + 1) := \u03bb a, @quotient.lift _ _ pSet.setoid\n    (\u03bb x, eval_aux.1 (a.f x)) (\u03bb b c h, eval_aux.2 _ _ (a.2 _ _ h)) in\n  \u27e8F, \u03bb b c h, funext $ @quotient.ind _ _ (\u03bb q, F b q = F c q) $ \u03bb z,\n  eval_aux.2 (resp.f b z) (resp.f c z) (h _ _ (equiv.refl z))\u27e9\n\n/-- An equivalence-respecting function yields an n-ary ZFC set function. -/\ndef eval (n) : resp n \u2192 arity Set.{u} n := eval_aux.1\n\ntheorem eval_val {n f x} : (@eval (n+1) f : Set \u2192 arity Set n) \u27e6x\u27e7 = 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 \u2192 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) : \u03a0 {s : arity Set.{u} n} (H : resp.eval _ f = s), definable n s\n| ._ rfl := \u27e8f\u27e9\n\n/-- Turns a definable function into a function that respects equivalence. -/\ndef definable.resp {n} : \u03a0 (s : arity Set.{u} n) [definable n s], resp n\n| ._ \u27e8f\u27e9 := f\n\ntheorem definable.eq {n} :\n  \u03a0 (s : arity Set.{u} n) [H : definable n s], (@definable.resp n s H).eval _ = s\n| ._ \u27e8f\u27e9 := rfl\n\nend pSet\n\nnamespace classical\nopen pSet\n\n/-- All functions are classically definable. -/\nnoncomputable def all_definable : \u03a0 {n} (F : arity Set.{u} n), definable n F\n| 0     F := let p := @quotient.exists_rep pSet _ F in\n              definable.eq_mk \u27e8some p, equiv.rfl\u27e9 (some_spec p)\n| (n+1) (F : arity Set.{u} (n + 1)) := begin\n    have I := \u03bb x, (all_definable (F x)),\n    refine definable.eq_mk \u27e8\u03bb x : pSet, (@definable.resp _ _ (I \u27e6x\u27e7)).1, _\u27e9 _,\n    { dsimp [arity.equiv],\n      introsI x y h,\n      rw @quotient.sound pSet _ _ _ h,\n      exact (definable.resp (F \u27e6y\u27e7)).2 },\n    refine funext (\u03bb q, quotient.induction_on q $ \u03bb x, _),\n    simp_rw [resp.eval_val, resp.f, subtype.val_eq_coe, subtype.coe_eta],\n    exact @definable.eq _ (F \u27e6x\u27e7) (I \u27e6x\u27e7),\n  end\n\nend classical\n\nnamespace Set\nopen pSet\n\n/-- Turns a pre-set into a ZFC set. -/\ndef mk : pSet \u2192 Set := quotient.mk\n\n@[simp] theorem mk_eq (x : pSet) : @eq Set \u27e6x\u27e7 (mk x) := rfl\n\n@[simp] lemma eval_mk {n f x} :\n  (@resp.eval (n+1) f : Set \u2192 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 \u2192 Set \u2192 Prop :=\nquotient.lift\u2082 pSet.mem\n  (\u03bb x y x' y' hx hy, propext ((mem.congr_left hx).trans (mem.congr_right hy)))\n\ninstance : has_mem Set Set := \u27e8mem\u27e9\n\n/-- Convert a ZFC set into a `set` of ZFC sets -/\ndef to_set (u : Set.{u}) : set Set.{u} := {x | x \u2208 u}\n\n/-- `x \u2286 y` as ZFC sets means that all members of `x` are members of `y`. -/\nprotected def subset (x y : Set.{u}) :=\n\u2200 \u2983z\u2984, z \u2208 x \u2192 z \u2208 y\n\ninstance has_subset : has_subset Set :=\n\u27e8Set.subset\u27e9\n\nlemma subset_def {x y : Set.{u}} : x \u2286 y \u2194 \u2200 \u2983z\u2984, z \u2208 x \u2192 z \u2208 y := iff.rfl\n\ntheorem subset_iff : \u03a0 (x y : pSet), mk x \u2286 mk y \u2194 x \u2286 y\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u27e8\u03bb h a, @h \u27e6A a\u27e7 (mem.mk A a),\n  \u03bb h z, quotient.induction_on z (\u03bb z \u27e8a, za\u27e9, let \u27e8b, ab\u27e9 := h a in \u27e8b, za.trans ab\u27e9)\u27e9\n\ntheorem ext {x y : Set.{u}} : (\u2200 z : Set.{u}, z \u2208 x \u2194 z \u2208 y) \u2192 x = y :=\nquotient.induction_on\u2082 x y (\u03bb u v h, quotient.sound (mem.ext (\u03bb w, h \u27e6w\u27e7)))\n\ntheorem ext_iff {x y : Set.{u}} : (\u2200 z : Set.{u}, z \u2208 x \u2194 z \u2208 y) \u2194 x = y :=\n\u27e8ext, \u03bb h, by simp [h]\u27e9\n\n/-- The empty ZFC set -/\ndef empty : Set := mk \u2205\ninstance : has_emptyc Set := \u27e8empty\u27e9\ninstance : inhabited Set := \u27e8\u2205\u27e9\n\n@[simp] theorem mem_empty (x) : x \u2209 (\u2205 : Set.{u}) :=\nquotient.induction_on x pSet.mem_empty\n\ntheorem eq_empty (x : Set.{u}) : x = \u2205 \u2194 \u2200 y : Set.{u}, y \u2209 x :=\n\u27e8\u03bb h y, (h.symm \u25b8 mem_empty y),\n\u03bb h, ext (\u03bb y, \u27e8\u03bb yx, absurd yx (h y), \u03bb y0, absurd y0 (mem_empty _)\u27e9)\u27e9\n\n/-- `insert x y` is the set `{x} \u222a y` -/\nprotected def insert : Set \u2192 Set \u2192 Set :=\nresp.eval 2 \u27e8pSet.insert, \u03bb u v uv \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bb o, match o with\n   | some a := let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8some b, hb\u27e9\n   | none := \u27e8none, uv\u27e9\n   end, \u03bb o, match o with\n   | some b := let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8some a, ha\u27e9\n   | none := \u27e8none, uv\u27e9\n   end\u27e9\u27e9\n\ninstance : has_insert Set Set := \u27e8Set.insert\u27e9\n\ninstance : has_singleton Set Set := \u27e8\u03bb x, insert x \u2205\u27e9\n\ninstance : is_lawful_singleton Set Set := \u27e8\u03bb x, rfl\u27e9\n\n@[simp] theorem mem_insert {x y z : Set.{u}} : x \u2208 insert y z \u2194 x = y \u2228 x \u2208 z :=\nquotient.induction_on\u2083 x y z\n (\u03bb x y \u27e8\u03b1, A\u27e9, show x \u2208 pSet.mk (option \u03b1) (\u03bb o, option.rec y A o) \u2194\n    mk x = mk y \u2228 x \u2208 pSet.mk \u03b1 A, from\n  \u27e8\u03bb m, match m with\n  | \u27e8some a, ha\u27e9 := or.inr \u27e8a, ha\u27e9\n  | \u27e8none, h\u27e9 := or.inl (quotient.sound h)\n  end, \u03bb m, match m with\n  | or.inr \u27e8a, ha\u27e9 := \u27e8some a, ha\u27e9\n  | or.inl h := \u27e8none, quotient.exact h\u27e9\n  end\u27e9)\n\n@[simp] theorem mem_singleton {x y : Set.{u}} : x \u2208 @singleton Set.{u} Set.{u} _ y \u2194 x = y :=\niff.trans mem_insert \u27e8\u03bb o, or.rec (\u03bb h, h) (\u03bb n, absurd n (mem_empty _)) o, or.inl\u27e9\n\n@[simp] theorem mem_pair {x y z : Set.{u}} : x \u2208 ({y, z} : Set) \u2194 x = y \u2228 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 : \u2205 \u2208 omega :=\n\u27e8\u27e80\u27e9, equiv.rfl\u27e9\n\n@[simp] theorem omega_succ {n} : n \u2208 omega.{u} \u2192 insert n n \u2208 omega.{u} :=\nquotient.induction_on n (\u03bb x \u27e8\u27e8n\u27e9, h\u27e9, \u27e8\u27e8n+1\u27e9,\n  have Set.insert \u27e6x\u27e7 \u27e6x\u27e7 = Set.insert \u27e6of_nat n\u27e7 \u27e6of_nat n\u27e7, by rw (@quotient.sound pSet _ _ _ h),\n  quotient.exact this\u27e9)\n\n/-- `{x \u2208 a | p x}` is the set of elements in `a` satisfying `p` -/\nprotected def sep (p : Set \u2192 Prop) : Set \u2192 Set :=\nresp.eval 1 \u27e8pSet.sep (\u03bb y, p \u27e6y\u27e7), \u03bb \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bb \u27e8a, pa\u27e9, let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8\u27e8b, by rwa \u2190(@quotient.sound pSet _ _ _ hb)\u27e9, hb\u27e9,\n   \u03bb \u27e8b, pb\u27e9, let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, by rwa (@quotient.sound pSet _ _ _ ha)\u27e9, ha\u27e9\u27e9\u27e9\n\ninstance : has_sep Set Set := \u27e8Set.sep\u27e9\n\n@[simp] theorem mem_sep {p : Set.{u} \u2192 Prop} {x y : Set.{u}} : y \u2208 {y \u2208 x | p y} \u2194 y \u2208 x \u2227 p y :=\nquotient.induction_on\u2082 x y (\u03bb \u27e8\u03b1, A\u27e9 y,\n  \u27e8\u03bb \u27e8\u27e8a, pa\u27e9, h\u27e9, \u27e8\u27e8a, h\u27e9, by { rw (@quotient.sound pSet _ _ _ h), exact pa }\u27e9,\n  \u03bb \u27e8\u27e8a, h\u27e9, pa\u27e9, \u27e8\u27e8a, by { rw \u2190(@quotient.sound pSet _ _ _ h), exact pa }\u27e9, h\u27e9\u27e9)\n\n/-- The powerset operation, the collection of subsets of a ZFC set -/\ndef powerset : Set \u2192 Set :=\nresp.eval 1 \u27e8powerset, \u03bb \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bb p, \u27e8{b | \u2203 a, p a \u2227 equiv (A a) (B b)},\n    \u03bb \u27e8a, pa\u27e9, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a in \u27e8\u27e8b, a, pa, ab\u27e9, ab\u27e9,\n    \u03bb \u27e8b, a, pa, ab\u27e9, \u27e8\u27e8a, pa\u27e9, ab\u27e9\u27e9,\n   \u03bb q, \u27e8{a | \u2203 b, q b \u2227 equiv (A a) (B b)},\n    \u03bb \u27e8a, b, qb, ab\u27e9, \u27e8\u27e8b, qb\u27e9, ab\u27e9,\n    \u03bb \u27e8b, qb\u27e9, let \u27e8a, ab\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, b, qb, ab\u27e9, ab\u27e9\u27e9\u27e9\u27e9\n\n@[simp] theorem mem_powerset {x y : Set.{u}} : y \u2208 powerset x \u2194 y \u2286 x :=\nquotient.induction_on\u2082 x y ( \u03bb \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9,\n  show (\u27e8\u03b2, B\u27e9 : pSet.{u}) \u2208 (pSet.powerset.{u} \u27e8\u03b1, A\u27e9) \u2194 _,\n    by simp [mem_powerset, subset_iff])\n\ntheorem Union_lem {\u03b1 \u03b2 : Type u} (A : \u03b1 \u2192 pSet) (B : \u03b2 \u2192 pSet) (\u03b1\u03b2 : \u2200 a, \u2203 b, equiv (A a) (B b)) :\n  \u2200 a, \u2203 b, (equiv ((Union \u27e8\u03b1, A\u27e9).func a) ((Union \u27e8\u03b2, B\u27e9).func b))\n| \u27e8a, c\u27e9 := let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in\n  begin\n    induction ea : A a with \u03b3 \u0393,\n    induction eb : B b with \u03b4 \u0394,\n    rw [ea, eb] at hb,\n    cases hb with \u03b3\u03b4 \u03b4\u03b3,\n    exact\n    let c : type (A a) := c, \u27e8d, hd\u27e9 := \u03b3\u03b4 (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    \u27e8\u27e8b, eq.rec d (eq.symm eb)\u27e9, this\u27e9\n  end\n\n/-- The union operator, the collection of elements of elements of a ZFC set -/\ndef Union : Set \u2192 Set :=\nresp.eval 1 \u27e8pSet.Union, \u03bb \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8Union_lem A B \u03b1\u03b2, \u03bb a, exists.elim (Union_lem B A (\u03bb b,\n    exists.elim (\u03b2\u03b1 b) (\u03bb c hc, \u27e8c, pSet.equiv.symm hc\u27e9)) a) (\u03bb b hb, \u27e8b, pSet.equiv.symm hb\u27e9)\u27e9\u27e9\n\nnotation `\u22c3` := Union\n\n@[simp] theorem mem_Union {x y : Set.{u}} : y \u2208 Union x \u2194 \u2203 z \u2208 x, y \u2208 z :=\nquotient.induction_on\u2082 x y (\u03bb x y, iff.trans mem_Union\n  \u27e8\u03bb \u27e8z, h\u27e9, \u27e8\u27e6z\u27e7, h\u27e9, \u03bb \u27e8z, h\u27e9, quotient.induction_on z (\u03bb z h, \u27e8z, h\u27e9) h\u27e9)\n\n@[simp] theorem Union_singleton {x : Set.{u}} : Union {x} = x :=\next $ \u03bb 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} := \u22c3 {x, y}\n\n/-- The binary intersection operation -/\nprotected def inter (x y : Set.{u}) : Set.{u} := {z \u2208 x | z \u2208 y}\n\n/-- The set difference operation -/\nprotected def diff (x y : Set.{u}) : Set.{u} := {z \u2208 x | z \u2209 y}\n\ninstance : has_union Set := \u27e8Set.union\u27e9\ninstance : has_inter Set := \u27e8Set.inter\u27e9\ninstance : has_sdiff Set := \u27e8Set.diff\u27e9\n\n@[simp] theorem mem_union {x y z : Set.{u}} : z \u2208 x \u222a y \u2194 z \u2208 x \u2228 z \u2208 y :=\niff.trans mem_Union\n \u27e8\u03bb \u27e8w, wxy, zw\u27e9, match mem_pair.1 wxy with\n  | or.inl wx := or.inl (by rwa \u2190wx)\n  | or.inr wy := or.inr (by rwa \u2190wy)\n  end, \u03bb zxy, match zxy with\n  | or.inl zx := \u27e8x, mem_pair.2 (or.inl rfl), zx\u27e9\n  | or.inr zy := \u27e8y, mem_pair.2 (or.inr rfl), zy\u27e9\n  end\u27e9\n\n@[simp] theorem mem_inter {x y z : Set.{u}} : z \u2208 x \u2229 y \u2194 z \u2208 x \u2227 z \u2208 y :=\n@@mem_sep (\u03bb z : Set.{u}, z \u2208 y)\n\n@[simp] theorem mem_diff {x y z : Set.{u}} : z \u2208 x \\ y \u2194 z \u2208 x \u2227 z \u2209 y :=\n@@mem_sep (\u03bb z : Set.{u}, z \u2209 y)\n\ntheorem induction_on {p : Set \u2192 Prop} (x) (h : \u2200 x, (\u2200 y \u2208 x, p y) \u2192 p x) : p x :=\nquotient.induction_on x $ \u03bb u, pSet.rec_on u $ \u03bb \u03b1 A IH, h _ $ \u03bb y,\nshow @has_mem.mem _ _ Set.has_mem y \u27e6\u27e8\u03b1, A\u27e9\u27e7 \u2192 p y, from\nquotient.induction_on y (\u03bb v \u27e8a, ha\u27e9, by { rw (@quotient.sound pSet _ _ _ ha), exact IH a })\n\ntheorem regularity (x : Set.{u}) (h : x \u2260 \u2205) : \u2203 y \u2208 x, x \u2229 y = \u2205 :=\nclassical.by_contradiction $ \u03bb ne, h $ (eq_empty x).2 $ \u03bb y,\ninduction_on y $ \u03bb z (IH : \u2200 w : Set.{u}, w \u2208 z \u2192 w \u2209 x), show z \u2209 x, from \u03bb zx,\nne \u27e8z, zx, (eq_empty _).2 (\u03bb w wxz, let \u27e8wx, wz\u27e9 := mem_inter.1 wxz in IH w wz wx)\u27e9\n\n/-- The image of a (definable) ZFC set function -/\ndef image (f : Set \u2192 Set) [H : definable 1 f] : Set \u2192 Set :=\nlet r := @definable.resp 1 f _ in\nresp.eval 1 \u27e8image r.1, \u03bb x y e, mem.ext $ \u03bb z,\n  iff.trans (mem_image r.2) $ iff.trans (by exact\n   \u27e8\u03bb \u27e8w, h1, h2\u27e9, \u27e8w, (mem.congr_right e).1 h1, h2\u27e9,\n    \u03bb \u27e8w, h1, h2\u27e9, \u27e8w, (mem.congr_right e).2 h1, h2\u27e9\u27e9) $\n  iff.symm (mem_image r.2)\u27e9\n\ntheorem image.mk :\n  \u03a0 (f : Set.{u} \u2192 Set.{u}) [H : definable 1 f] (x) {y} (h : y \u2208 x), f y \u2208 @image f H x\n| ._ \u27e8F\u27e9 x y := quotient.induction_on\u2082 x y $ \u03bb \u27e8\u03b1, A\u27e9 y \u27e8a, ya\u27e9, \u27e8a, F.2 _ _ ya\u27e9\n\n@[simp] theorem mem_image : \u03a0 {f : Set.{u} \u2192 Set.{u}} [H : definable 1 f] {x y : Set.{u}},\n  y \u2208 @image f H x \u2194 \u2203 z \u2208 x, f z = y\n| ._ \u27e8F\u27e9 x y := quotient.induction_on\u2082 x y $ \u03bb \u27e8\u03b1, A\u27e9 y,\n  \u27e8\u03bb \u27e8a, ya\u27e9, \u27e8\u27e6A a\u27e7, mem.mk A a, eq.symm $ quotient.sound ya\u27e9,\n  \u03bb \u27e8z, hz, e\u27e9, e \u25b8 image.mk _ _ hz\u27e9\n\n/-- Kuratowski ordered pair -/\ndef pair (x y : Set.{u}) : Set.{u} := {{x}, {x, y}}\n\n/-- A subset of pairs `{(a, b) \u2208 x \u00d7 y | p a b}` -/\ndef pair_sep (p : Set.{u} \u2192 Set.{u} \u2192 Prop) (x y : Set.{u}) : Set.{u} :=\n{z \u2208 powerset (powerset (x \u222a y)) | \u2203 a \u2208 x, \u2203 b \u2208 y, z = pair a b \u2227 p a b}\n\n@[simp] theorem mem_pair_sep {p} {x y z : Set.{u}} :\n  z \u2208 pair_sep p x y \u2194 \u2203 a \u2208 x, \u2203 b \u2208 y, z = pair a b \u2227 p a b :=\nbegin\n  refine mem_sep.trans \u27e8and.right, \u03bb e, \u27e8_, e\u27e9\u27e9,\n  rcases e with \u27e8a, ax, b, bY, rfl, pab\u27e9,\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' \u2227 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' \u2208 ({x} : Set),\n      { simp [h] },\n      rw mem_singleton.mp m } },\n  have he : x = y \u2192 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, \u2190mem_singleton, \u2190xy'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 \u2208 x, b \u2208 y}` -/\ndef prod : Set.{u} \u2192 Set.{u} \u2192 Set.{u} := pair_sep (\u03bb a b, true)\n\n@[simp] theorem mem_prod {x y z : Set.{u}} : z \u2208 prod x y \u2194 \u2203 a \u2208 x, \u2203 b \u2208 y, z = pair a b :=\nby simp [prod]\n\n@[simp] theorem pair_mem_prod {x y a b : Set.{u}} : pair a b \u2208 prod x y \u2194 a \u2208 x \u2227 b \u2208 y :=\n\u27e8\u03bb h, let \u27e8a', a'x, b', b'y, e\u27e9 := mem_prod.1 h in\n  match a', b', pair_inj e, a'x, b'y with ._, ._, \u27e8rfl, rfl\u27e9, ax, bY := \u27e8ax, bY\u27e9 end,\n\u03bb \u27e8ax, bY\u27e9, mem_prod.2 \u27e8a, ax, b, bY, rfl\u27e9\u27e9\n\n/-- `is_func x y f` is the assertion that `f` is a subset of `x \u00d7 y` which relates to each element\nof `x` a unique element of `y`, so that we can consider `f`as a ZFC function `x \u2192 y`. -/\ndef is_func (x y f : Set.{u}) : Prop :=\nf \u2286 prod x y \u2227 \u2200 z : Set.{u}, z \u2208 x \u2192 \u2203! w, pair z w \u2208 f\n\n/-- `funs x y` is `y ^ x`, the set of all set functions `x \u2192 y` -/\ndef funs (x y : Set.{u}) : Set.{u} :=\n{f \u2208 powerset (prod x y) | is_func x y f}\n\n@[simp] theorem mem_funs {x y f : Set.{u}} : f \u2208 funs x y \u2194 is_func x y f :=\nby simp [funs, is_func]\n\n-- TODO(Mario): Prove this computably\nnoncomputable instance map_definable_aux (f : Set \u2192 Set) [H : definable 1 f] :\n  definable 1 (\u03bb 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 \u2208 x` to `f a` -/\nnoncomputable def map (f : Set \u2192 Set) [H : definable 1 f] : Set \u2192 Set :=\nimage (\u03bb y, pair y (f y))\n\n@[simp] theorem mem_map {f : Set \u2192 Set} [H : definable 1 f] {x y : Set} :\n  y \u2208 map f x \u2194 \u2203 z \u2208 x, pair z (f z) = y :=\nmem_image\n\ntheorem map_unique {f : Set.{u} \u2192 Set.{u}} [H : definable 1 f] {x z : Set.{u}} (zx : z \u2208 x) :\n  \u2203! w, pair z w \u2208 map f x :=\n\u27e8f z, image.mk _ _ zx, \u03bb y yx, let \u27e8w, wx, we\u27e9 := mem_image.1 yx, \u27e8wz, fy\u27e9 := pair_inj we in\n  by rw[\u2190fy, wz]\u27e9\n\n@[simp] theorem map_is_func {f : Set \u2192 Set} [H : definable 1 f] {x y : Set} :\n  is_func x y (map f x) \u2194 \u2200 z \u2208 x, f z \u2208 y :=\n\u27e8\u03bb \u27e8ss, h\u27e9 z zx, let \u27e8t, t1, t2\u27e9 := h z zx in\n  (t2 (f z) (image.mk _ _ zx)).symm \u25b8 (pair_mem_prod.1 (ss t1)).right,\n\u03bb h, \u27e8\u03bb y yx, let \u27e8z, zx, ze\u27e9 := mem_image.1 yx in ze \u25b8 pair_mem_prod.2 \u27e8zx, h z zx\u27e9,\n     \u03bb z, map_unique\u27e9\u27e9\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 \u2208 x}\ninstance : has_coe Set Class := \u27e8of_Set\u27e9\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} \u2192 Prop) (A : Class.{u}) : Prop := \u2203 x, \u2191x = A \u2227 p x\n\n/-- `A \u2208 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 := \u27e8Class.mem\u27e9\n\ntheorem mem_univ {A : Class.{u}} : A \u2208 univ.{u} \u2194 \u2203 x : Set.{u}, \u2191x = A :=\nexists_congr $ \u03bb 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 | \u2191y \u2208 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 \u2208 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 `\u22c3` := Union\n\ntheorem of_Set.inj {x y : Set.{u}} (h : (x : Class.{u}) = y) : x = y :=\nSet.ext $ \u03bb z, by { change (x : Class.{u}) z \u2194 (y : Class.{u}) z, rw h }\n\n@[simp] theorem to_Set_of_Set (p : Set.{u} \u2192 Prop) (x : Set.{u}) : to_Set p x \u2194 p x :=\n\u27e8\u03bb \u27e8y, yx, py\u27e9, by rwa of_Set.inj yx at py, \u03bb px, \u27e8x, rfl, px\u27e9\u27e9\n\n@[simp] theorem mem_hom_left (x : Set.{u}) (A : Class.{u}) : (x : Class.{u}) \u2208 A \u2194 A x :=\nto_Set_of_Set _ _\n\n@[simp] theorem mem_hom_right (x y : Set.{u}) : (y : Class.{u}) x \u2194 x \u2208 y := iff.rfl\n\n@[simp] theorem subset_hom (x y : Set.{u}) : (x : Class.{u}) \u2286 y \u2194 x \u2286 y := iff.rfl\n\n@[simp] theorem sep_hom (p : Set.{u} \u2192 Prop) (x : Set.{u}) :\n  (\u2191{y \u2208 x | p y} : Class.{u}) = {y \u2208 x | p y} :=\nset.ext $ \u03bb y, Set.mem_sep\n\n@[simp] theorem empty_hom : \u2191(\u2205 : Set.{u}) = (\u2205 : Class.{u}) :=\nset.ext $ \u03bb 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) = \u2191(insert x y) :=\nset.ext $ \u03bb z, iff.symm Set.mem_insert\n\n@[simp] theorem union_hom (x y : Set.{u}) : (x : Class.{u}) \u222a y = (x \u222a y : Set.{u}) :=\nset.ext $ \u03bb z, iff.symm Set.mem_union\n\n@[simp] theorem inter_hom (x y : Set.{u}) : (x : Class.{u}) \u2229 y = (x \u2229 y : Set.{u}) :=\nset.ext $ \u03bb 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 $ \u03bb z, iff.symm Set.mem_diff\n\n@[simp] theorem powerset_hom (x : Set.{u}) : powerset.{u} x = Set.powerset x :=\nset.ext $ \u03bb z, iff.symm Set.mem_powerset\n\n@[simp] theorem Union_hom (x : Set.{u}) : Union.{u} x = Set.Union x :=\nset.ext $ \u03bb z, by { refine iff.trans _ Set.mem_Union.symm, exact\n\u27e8\u03bb \u27e8._, \u27e8a, rfl, ax\u27e9, za\u27e9, \u27e8a, ax, za\u27e9, \u03bb \u27e8a, ax, za\u27e9, \u27e8_, \u27e8a, rfl, ax\u27e9, za\u27e9\u27e9 }\n\n/-- The definite description operator, which is `{x}` if `{a | p a} = {x}` and `\u2205` otherwise. -/\ndef iota (p : Set \u2192 Prop) : Class := Union {x | \u2200 y, p y \u2194 y = x}\n\ntheorem iota_val (p : Set \u2192 Prop) (x : Set) (H : \u2200 y, p y \u2194 y = x) : iota p = \u2191x :=\nset.ext $ \u03bb y, \u27e8\u03bb \u27e8._, \u27e8x', rfl, h\u27e9, yx'\u27e9, by rwa \u2190((H x').1 $ (h x').2 rfl),\n  \u03bb yx, \u27e8_, \u27e8x, rfl, H\u27e9, yx\u27e9\u27e9\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 \u2192 Prop) \u2192 Set` function. -/\ntheorem iota_ex (p) : iota.{u} p \u2208 univ.{u} :=\nmem_univ.2 $ or.elim (classical.em $ \u2203 x, \u2200 y, p y \u2194 y = x)\n (\u03bb \u27e8x, h\u27e9, \u27e8x, eq.symm $ iota_val p x h\u27e9)\n (\u03bb hn, \u27e8\u2205, set.ext (\u03bb z, empty_hom.symm \u25b8 \u27e8false.rec _, \u03bb \u27e8._, \u27e8x, rfl, H\u27e9, zA\u27e9, hn \u27e8x, H\u27e9\u27e9)\u27e9)\n\n/-- Function value -/\ndef fval (F A : Class.{u}) : Class.{u} := iota (\u03bb y, to_Set (\u03bb x, F (Set.pair x y)) A)\ninfixl `\u2032`:100 := fval\n\ntheorem fval_ex (F A : Class.{u}) : F \u2032 A \u2208 univ.{u} := iota_ex _\n\nend Class\n\nnamespace Set\n\n@[simp] theorem map_fval {f : Set.{u} \u2192 Set.{u}} [H : pSet.definable 1 f]\n  {x y : Set.{u}} (h : y \u2208 x) :\n  (Set.map f x \u2032 y : Class.{u}) = f y :=\nClass.iota_val _ _ (\u03bb z, by { rw [Class.to_Set_of_Set, Class.mem_hom_right, mem_map], exact\n  \u27e8\u03bb \u27e8w, wz, pr\u27e9, let \u27e8wy, fw\u27e9 := Set.pair_inj pr in by rw[\u2190fw, wy],\n  \u03bb e, by { subst e, exact \u27e8_, h, rfl\u27e9 }\u27e9 })\n\nvariables (x : Set.{u}) (h : \u2205 \u2209 x)\n\n/-- A choice function on the class of nonempty ZFC sets. -/\nnoncomputable def choice : Set :=\n@map (\u03bb y, classical.epsilon (\u03bb z, z \u2208 y)) (classical.all_definable _) x\n\ninclude h\ntheorem choice_mem_aux (y : Set.{u}) (yx : y \u2208 x) : classical.epsilon (\u03bb z : Set.{u}, z \u2208 y) \u2208 y :=\n@classical.epsilon_spec _ (\u03bb z : Set.{u}, z \u2208 y) $ classical.by_contradiction $ \u03bb n, h $\nby rwa \u2190((eq_empty y).2 $ \u03bb z zx, n \u27e8z, zx\u27e9)\n\ntheorem choice_is_func : is_func x (Union x) (choice x) :=\n(@map_is_func _ (classical.all_definable _) _ _).2 $\n  \u03bb y yx, mem_Union.2 \u27e8y, yx, choice_mem_aux x h y yx\u27e9\n\ntheorem choice_mem (y : Set.{u}) (yx : y \u2208 x) : (choice x \u2032 y : Class.{u}) \u2208 (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} \u2192 a < b \u2192 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 \u03b1 \u03b2} [Monad m] (as : Array \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) : m \u03b2 := do\nlet rec loop : (i : Nat) \u2192 i \u2264 as.size \u2192 \u03b2 \u2192 m \u03b2\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 \u2190 f (as.get \u27e8as.size - 1 - i, this\u27e9) 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 $ \u00b7 + \u00b7)\n\ntheorem ex : (Id.run $ fold #[1, 2, 3, 4] 0 (pure $ \u00b7 + \u00b7)) = 10 :=\nrfl\n\ndef fold2 {m \u03b1 \u03b2} [Monad m] (as : Array \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) : m \u03b2 :=\nlet rec loop (i : Nat) (h : i \u2264 as.size) (b : \u03b2) : m \u03b2 := 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 \u2190 f (as.get \u27e8as.size - 1 - i, this\u27e9) 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 \u2190 ref.get\nIO.println x\nreturn x + 1\n\ndef fTest : IO Unit := do\nunless (\u2190 f 0 (\u2190 IO.mkRef 10)) == 11 do throw $ IO.userError \"unexpected\"\nunless (\u2190 f 1 (\u2190 IO.mkRef 10)) == 2 do throw $ IO.userError \"unexpected\"\n\ndef g (x y : Nat) (ref : IO.Ref (Nat \u00d7 Nat)) : IO (Nat \u00d7 Nat) := do\n  let mut (x, y) := (x, y)\n  if x == 0 then\n    (x, y) \u2190 ref.get\n  IO.println (\"x: \" ++ toString x ++ \", y: \" ++ toString y)\n  return (x, y)\n\ndef gTest : IO Unit := do\nunless (\u2190 g 2 1 (\u2190 IO.mkRef (10, 20))) == (2, 1)   do throw $ IO.userError \"unexpected\"\nunless (\u2190 g 0 1 (\u2190 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 `\u2016x\u2016 = 0 \u2192 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 \u2192 W\n  /-- A `NormedAddGroupHom` is additive. -/\n  map_add' : \u2200 v\u2081 v\u2082, toFun (v\u2081 + v\u2082) = toFun v\u2081 + toFun v\u2082\n  /-- A `NormedAddGroupHom` is bounded. -/\n  bound' : \u2203 C, \u2200 v, \u2016toFun v\u2016 \u2264 C * \u2016v\u2016\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 `\u211d\u22650` for the bound. -/\ndef mkNormedAddGroupHom (f : V \u2192+ W) (C : \u211d) (h : \u2200 v, \u2016f v\u2016 \u2264 C * \u2016v\u2016) : NormedAddGroupHom V W :=\n  { f with bound' := \u27e8C, h\u27e9 }\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 `\u211d` for the bound. -/\ndef mkNormedAddGroupHom' (f : V \u2192+ W) (C : \u211d\u22650) (hC : \u2200 x, \u2016f x\u2016\u208a \u2264 C * \u2016x\u2016\u208a) :\n    NormedAddGroupHom V W :=\n  { f with bound' := \u27e8C, hC\u27e9 }\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 \u2192 W} (M : \u211d) (h : \u2200 x, \u2016f x\u2016 \u2264 M * \u2016x\u2016) :\n    \u2203 N, 0 < N \u2227 \u2200 x, \u2016f x\u2016 \u2264 N * \u2016x\u2016 :=\n  \u27e8max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), fun x =>\n    calc\n      \u2016f x\u2016 \u2264 M * \u2016x\u2016 := h x\n      _ \u2264 max M 1 * \u2016x\u2016 := mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg _)\n      \u27e9\n#align exists_pos_bound_of_bound exists_pos_bound_of_bound\n\nnamespace NormedAddGroupHom\n\nvariable {V V\u2081 V\u2082 V\u2083 : Type _} [SeminormedAddCommGroup V] [SeminormedAddCommGroup V\u2081]\n  [SeminormedAddCommGroup V\u2082] [SeminormedAddCommGroup V\u2083]\n\nvariable {f g : NormedAddGroupHom V\u2081 V\u2082}\n\n/-- A Lipschitz continuous additive homomorphism is a normed additive group homomorphism. -/\ndef ofLipschitz (f : V\u2081 \u2192+ V\u2082) {K : \u211d\u22650} (h : LipschitzWith K f) : NormedAddGroupHom V\u2081 V\u2082 :=\n  f.mkNormedAddGroupHom K fun x \u21a6 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\u2081 V\u2082) V\u2081 V\u2082 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\u2081 V\u2082) fun _ => V\u2081 \u2192 V\u2082 :=\n  \u27e8FunLike.coe\u27e9\n\ninitialize_simps_projections NormedAddGroupHom (toFun \u2192 apply)\n\ntheorem coe_inj (H : (f : V\u2081 \u2192 V\u2082) = 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\u2081 V\u2082) (V\u2081 \u2192 V\u2082) toFun := by\n  apply coe_inj\n#align normed_add_group_hom.coe_injective NormedAddGroupHom.coe_injective\n\ntheorem coe_inj_iff : f = g \u2194 (f : V\u2081 \u2192 V\u2082) = g :=\n  \u27e8congr_arg _, coe_inj\u27e9\n#align normed_add_group_hom.coe_inj_iff NormedAddGroupHom.coe_inj_iff\n\n@[ext]\ntheorem ext (H : \u2200 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 \u2194 \u2200 x, f x = g x :=\n  \u27e8by rintro rfl x; rfl, ext\u27e9\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\u2081) (h\u2082) (h\u2083) : \u21d1(\u27e8f, h\u2081, h\u2082, h\u2083\u27e9 : NormedAddGroupHom V\u2081 V\u2082) = f :=\n  rfl\n#align normed_add_group_hom.coe_mk NormedAddGroupHom.coe_mk\n\n@[simp]\ntheorem coe_mkNormedAddGroupHom (f : V\u2081 \u2192+ V\u2082) (C) (hC) : \u21d1(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\u2081 \u2192+ V\u2082) (C) (hC) : \u21d1(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\u2081 V\u2082) : V\u2081 \u2192+ V\u2082 :=\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 : \u21d1f.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\u2081 V\u2082 _ _) := fun f g h =>\n  coe_inj <| by rw [\u2190coe_toAddMonoidHom f, \u2190coe_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\u2081) (h\u2082) :\n    (\u27e8f, h\u2081, h\u2082\u27e9 : NormedAddGroupHom V\u2081 V\u2082).toAddMonoidHom = AddMonoidHom.mk' f h\u2081 :=\n  rfl\n#align normed_add_group_hom.mk_to_add_monoid_hom NormedAddGroupHom.mk_toAddMonoidHom\n\ntheorem bound : \u2203 C, 0 < C \u2227 \u2200 x, \u2016f x\u2016 \u2264 C * \u2016x\u2016 :=\n  let \u27e8_C, hC\u27e9 := 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 : \u211d\u22650} (h : \u2200 x, \u2016x\u2016 \u2264 K * \u2016f x\u2016) : 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*\u2016x\u2016`. 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\u2081 V\u2082) (K : AddSubgroup V\u2082) (C : \u211d) : Prop :=\n  \u2200 h \u2208 K, \u2203 g, f g = h \u2227 \u2016g\u2016 \u2264 C * \u2016h\u2016\n#align normed_add_group_hom.surjective_on_with NormedAddGroupHom.SurjectiveOnWith\n\ntheorem SurjectiveOnWith.mono {f : NormedAddGroupHom V\u2081 V\u2082} {K : AddSubgroup V\u2082} {C C' : \u211d}\n    (h : f.SurjectiveOnWith K C) (H : C \u2264 C') : f.SurjectiveOnWith K C' := by\n  intro k k_in\n  rcases h k k_in with \u27e8g, rfl, hg\u27e9\n  use g, rfl\n  by_cases Hg : \u2016f g\u2016 = 0\n  \u00b7 simpa [Hg] using hg\n  \u00b7 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\u2081 V\u2082} {K : AddSubgroup V\u2082} {C : \u211d}\n    (h : f.SurjectiveOnWith K C) : \u2203 C' > 0, f.SurjectiveOnWith K C' := by\n  refine' \u27e8|C| + 1, _, _\u27e9\n  \u00b7 linarith [abs_nonneg C]\n  \u00b7 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\u2081 V\u2082} {K : AddSubgroup V\u2082} {C : \u211d}\n    (h : f.SurjectiveOnWith K C) : Set.SurjOn f Set.univ K := fun x hx =>\n  (h x hx).imp fun _a \u27e8ha, _\u27e9 => \u27e8Set.mem_univ _, ha\u27e9\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\u2081 V\u2082) :=\n  inf\u209b { c | 0 \u2264 c \u2227 \u2200 x, \u2016f x\u2016 \u2264 c * \u2016x\u2016 }\n#align normed_add_group_hom.op_norm NormedAddGroupHom.opNorm\n\ninstance hasOpNorm : Norm (NormedAddGroupHom V\u2081 V\u2082) :=\n  \u27e8opNorm\u27e9\n#align normed_add_group_hom.has_op_norm NormedAddGroupHom.hasOpNorm\n\ntheorem norm_def : \u2016f\u2016 = inf\u209b { c | 0 \u2264 c \u2227 \u2200 x, \u2016f x\u2016 \u2264 c * \u2016x\u2016 } :=\n  rfl\n#align normed_add_group_hom.norm_def NormedAddGroupHom.norm_def\n\n-- So that invocations of `le_cinf\u209b` make sense: we show that the set of\n-- bounds is nonempty and bounded below.\ntheorem bounds_nonempty {f : NormedAddGroupHom V\u2081 V\u2082} :\n    \u2203 c, c \u2208 { c | 0 \u2264 c \u2227 \u2200 x, \u2016f x\u2016 \u2264 c * \u2016x\u2016 } :=\n  let \u27e8M, hMp, hMb\u27e9 := f.bound\n  \u27e8M, le_of_lt hMp, hMb\u27e9\n#align normed_add_group_hom.bounds_nonempty NormedAddGroupHom.bounds_nonempty\n\ntheorem bounds_bddBelow {f : NormedAddGroupHom V\u2081 V\u2082} :\n    BddBelow { c | 0 \u2264 c \u2227 \u2200 x, \u2016f x\u2016 \u2264 c * \u2016x\u2016 } :=\n  \u27e80, fun _ \u27e8hn, _\u27e9 => hn\u27e9\n#align normed_add_group_hom.bounds_bdd_below NormedAddGroupHom.bounds_bddBelow\n\ntheorem opNorm_nonneg : 0 \u2264 \u2016f\u2016 :=\n  le_cinf\u209b bounds_nonempty fun _ \u27e8hx, _\u27e9 => hx\n#align normed_add_group_hom.op_norm_nonneg NormedAddGroupHom.opNorm_nonneg\n\n/-- The fundamental property of the operator norm: `\u2016f x\u2016 \u2264 \u2016f\u2016 * \u2016x\u2016`. -/\ntheorem le_opNorm (x : V\u2081) : \u2016f x\u2016 \u2264 \u2016f\u2016 * \u2016x\u2016 := by\n  obtain \u27e8C, _Cpos, hC\u27e9 := f.bound\n  replace hC := hC x\n  by_cases h : \u2016x\u2016 = 0\n  \u00b7 rwa [h, mul_zero] at hC\u22a2\n  have hlt : 0 < \u2016x\u2016 := lt_of_le_of_ne (norm_nonneg x) (Ne.symm h)\n  exact\n    (div_le_iff hlt).mp\n      (le_cinf\u209b bounds_nonempty fun c \u27e8_, hc\u27e9 => (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 : \u211d} {x} (h : \u2016x\u2016 \u2264 c) : \u2016f x\u2016 \u2264 \u2016f\u2016 * 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 : \u211d} (h : \u2016f\u2016 \u2264 c) (x : V\u2081) : \u2016f x\u2016 \u2264 c * \u2016x\u2016 :=\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 \u27e8\u2016f\u2016, opNorm_nonneg f\u27e9 f :=\n  LipschitzWith.of_dist_le_mul fun x y => by\n    rw [dist_eq_norm, dist_eq_norm, \u2190 map_sub]\n    apply le_opNorm\n#align normed_add_group_hom.lipschitz NormedAddGroupHom.lipschitz\n\nprotected theorem uniformContinuous (f : NormedAddGroupHom V\u2081 V\u2082) : 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\u2081 V\u2082) : Continuous f :=\n  f.uniformContinuous.continuous\n#align normed_add_group_hom.continuous NormedAddGroupHom.continuous\n\ntheorem ratio_le_opNorm (x : V\u2081) : \u2016f x\u2016 / \u2016x\u2016 \u2264 \u2016f\u2016 :=\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 : \u211d} (hMp : 0 \u2264 M) (hM : \u2200 x, \u2016f x\u2016 \u2264 M * \u2016x\u2016) : \u2016f\u2016 \u2264 M :=\n  cinf\u209b_le bounds_bddBelow \u27e8hMp, hM\u27e9\n#align normed_add_group_hom.op_norm_le_bound NormedAddGroupHom.opNorm_le_bound\n\ntheorem opNorm_eq_of_bounds {M : \u211d} (M_nonneg : 0 \u2264 M) (h_above : \u2200 x, \u2016f x\u2016 \u2264 M * \u2016x\u2016)\n    (h_below : \u2200 N \u2265 0, (\u2200 x, \u2016f x\u2016 \u2264 N * \u2016x\u2016) \u2192 M \u2264 N) : \u2016f\u2016 = M :=\n  le_antisymm (f.opNorm_le_bound M_nonneg h_above)\n    ((le_cinf\u209b_iff NormedAddGroupHom.bounds_bddBelow \u27e8M, M_nonneg, h_above\u27e9).mpr\n      fun N \u27e8N_nonneg, hN\u27e9 => 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\u2081 V\u2082} {K : \u211d\u22650} (hf : LipschitzWith K f) :\n    \u2016f\u2016 \u2264 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\u2081 \u2192+ V\u2082) {C : \u211d} (hC : 0 \u2264 C) (h : \u2200 x, \u2016f x\u2016 \u2264 C * \u2016x\u2016) :\n    \u2016f.mkNormedAddGroupHom C h\u2016 \u2264 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\u2081 \u2192+ V\u2082) {K : \u211d\u22650} (h : LipschitzWith K f) :\n    \u2016ofLipschitz f h\u2016 \u2264 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\u2081 \u2192+ V\u2082) {C : \u211d} (h : \u2200 x, \u2016f x\u2016 \u2264 C * \u2016x\u2016) :\n    \u2016f.mkNormedAddGroupHom C h\u2016 \u2264 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 \u2190 _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' \u2190 _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\u2081 V\u2082) :=\n  \u27e8fun f g =>\n    (f.toAddMonoidHom + g.toAddMonoidHom).mkNormedAddGroupHom (\u2016f\u2016 + \u2016g\u2016) fun v =>\n      calc\n        \u2016f v + g v\u2016 \u2264 \u2016f v\u2016 + \u2016g v\u2016 := norm_add_le _ _\n        _ \u2264 \u2016f\u2016 * \u2016v\u2016 + \u2016g\u2016 * \u2016v\u2016 := (add_le_add (le_opNorm f v) (le_opNorm g v))\n        _ = (\u2016f\u2016 + \u2016g\u2016) * \u2016v\u2016 := by rw [add_mul]\n        \u27e9\n\n/-- The operator norm satisfies the triangle inequality. -/\ntheorem opNorm_add_le : \u2016f + g\u2016 \u2264 \u2016f\u2016 + \u2016g\u2016 :=\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\u2081 \u2192 V\u2082)`\n-/\n-/\n\n@[simp]\ntheorem coe_add (f g : NormedAddGroupHom V\u2081 V\u2082) : \u21d1(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\u2081 V\u2082) (v : V\u2081) :\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\u2081 V\u2082) :=\n  \u27e8(0 : V\u2081 \u2192+ V\u2082).mkNormedAddGroupHom 0 (by simp)\u27e9\n\ninstance inhabited : Inhabited (NormedAddGroupHom V\u2081 V\u2082) :=\n  \u27e80\u27e9\n\n/-- The norm of the `0` operator is `0`. -/\ntheorem opNorm_zero : \u2016(0 : NormedAddGroupHom V\u2081 V\u2082)\u2016 = 0 :=\n  le_antisymm\n    (cinf\u209b_le bounds_bddBelow\n      \u27e8ge_of_eq rfl, fun _ =>\n        le_of_eq\n          (by\n            rw [zero_mul]\n            exact norm_zero)\u27e9)\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\u2081 V\u2082 : Type _} [NormedAddCommGroup V\u2081] [NormedAddCommGroup V\u2082]\n    {f : NormedAddGroupHom V\u2081 V\u2082} : \u2016f\u2016 = 0 \u2194 f = 0 :=\n  Iff.intro\n    (fun hn =>\n      ext fun x =>\n        norm_le_zero_iff.1\n          (calc\n            _ \u2264 \u2016f\u2016 * \u2016x\u2016 := 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\u2081) : (0 : NormedAddGroupHom V\u2081 V\u2082) 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 : \u2016(id V : NormedAddGroupHom V V)\u2016 \u2264 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 : \u2203 x : V, \u2016x\u2016 \u2260 0) : \u2016id V\u2016 = 1 :=\n  le_antisymm (norm_id_le V) <| by\n    let \u27e8x, hx\u27e9 := 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] : \u2016id V\u2016 = 1 := by\n  refine' norm_id_of_nontrivial_seminorm V _\n  obtain \u27e8x, hx\u27e9 := exists_ne (0 : V)\n  exact \u27e8x, ne_of_gt (norm_pos_iff.2 hx)\u27e9\n#align normed_add_group_hom.norm_id NormedAddGroupHom.norm_id\n\ntheorem coe_id : (NormedAddGroupHom.id V : V \u2192 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\u2081 V\u2082) :=\n  \u27e8fun f => (-f.toAddMonoidHom).mkNormedAddGroupHom \u2016f\u2016 fun v => by simp [le_opNorm f v]\u27e9\n\n@[simp]\ntheorem coe_neg (f : NormedAddGroupHom V\u2081 V\u2082) : \u21d1(-f) = -f :=\n  rfl\n#align normed_add_group_hom.coe_neg NormedAddGroupHom.coe_neg\n\n@[simp]\ntheorem neg_apply (f : NormedAddGroupHom V\u2081 V\u2082) (v : V\u2081) :\n    (-f : NormedAddGroupHom V\u2081 V\u2082) v = -f v :=\n  rfl\n#align normed_add_group_hom.neg_apply NormedAddGroupHom.neg_apply\n\ntheorem opNorm_neg (f : NormedAddGroupHom V\u2081 V\u2082) : \u2016-f\u2016 = \u2016f\u2016 := 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\u2081 V\u2082) :=\n  \u27e8fun 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' }\u27e9\n\n@[simp]\ntheorem coe_sub (f g : NormedAddGroupHom V\u2081 V\u2082) : \u21d1(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\u2081 V\u2082) (v : V\u2081) :\n    (f - g : NormedAddGroupHom V\u2081 V\u2082) 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\u2082] [PseudoMetricSpace R]\n  [BoundedSMul R V\u2082] [MonoidWithZero R'] [DistribMulAction R' V\u2082] [PseudoMetricSpace R']\n  [BoundedSMul R' V\u2082]\n\ninstance smul : SMul R (NormedAddGroupHom V\u2081 V\u2082) where\n  smul r f :=\n    { toFun := r \u2022 \u21d1f\n      map_add' := (r \u2022 f.toAddMonoidHom).map_add'\n      bound' :=\n        let \u27e8b, hb\u27e9 := f.bound'\n        \u27e8dist 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\u27e9 }\n\n@[simp]\ntheorem coe_smul (r : R) (f : NormedAddGroupHom V\u2081 V\u2082) : \u21d1(r \u2022 f) = r \u2022 \u21d1f :=\n  rfl\n#align normed_add_group_hom.coe_smul NormedAddGroupHom.coe_smul\n\n@[simp]\ntheorem smul_apply (r : R) (f : NormedAddGroupHom V\u2081 V\u2082) (v : V\u2081) : (r \u2022 f) v = r \u2022 f v :=\n  rfl\n#align normed_add_group_hom.smul_apply NormedAddGroupHom.smul_apply\n\ninstance smulCommClass [SMulCommClass R R' V\u2082] :\n    SMulCommClass R R' (NormedAddGroupHom V\u2081 V\u2082) where\n  smul_comm _ _ _ := ext fun _ => smul_comm _ _ _\n\ninstance isScalarTower [SMul R R'] [IsScalarTower R R' V\u2082] :\n    IsScalarTower R R' (NormedAddGroupHom V\u2081 V\u2082) where\n  smul_assoc _ _ _ := ext fun _ => smul_assoc _ _ _\n\ninstance isCentralScalar [DistribMulAction R\u1d50\u1d52\u1d56 V\u2082] [IsCentralScalar R V\u2082] :\n    IsCentralScalar R (NormedAddGroupHom V\u2081 V\u2082) where\n  op_smul_eq_smul _ _ := ext fun _ => op_smul_eq_smul _ _\n\nend SMul\n\ninstance nsmul : SMul \u2115 (NormedAddGroupHom V\u2081 V\u2082) where\n  smul n f :=\n    { toFun := n \u2022 \u21d1f\n      map_add' := (n \u2022 f.toAddMonoidHom).map_add'\n      bound' :=\n        let \u27e8b, hb\u27e9 := f.bound'\n        \u27e8n \u2022 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 _))\u27e9 }\n#align normed_add_group_hom.has_nat_scalar NormedAddGroupHom.nsmul\n\n@[simp]\ntheorem coe_nsmul (r : \u2115) (f : NormedAddGroupHom V\u2081 V\u2082) : \u21d1(r \u2022 f) = r \u2022 \u21d1f :=\n  rfl\n#align normed_add_group_hom.coe_nsmul NormedAddGroupHom.coe_nsmul\n\n@[simp]\ntheorem nsmul_apply (r : \u2115) (f : NormedAddGroupHom V\u2081 V\u2082) (v : V\u2081) : (r \u2022 f) v = r \u2022 f v :=\n  rfl\n#align normed_add_group_hom.nsmul_apply NormedAddGroupHom.nsmul_apply\n\ninstance zsmul : SMul \u2124 (NormedAddGroupHom V\u2081 V\u2082) where\n  smul z f :=\n    { toFun := z \u2022 \u21d1f\n      map_add' := (z \u2022 f.toAddMonoidHom).map_add'\n      bound' :=\n        let \u27e8b, hb\u27e9 := f.bound'\n        \u27e8\u2016z\u2016 \u2022 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 _)\u27e9 }\n#align normed_add_group_hom.has_int_scalar NormedAddGroupHom.zsmul\n\n@[simp]\ntheorem coe_zsmul (r : \u2124) (f : NormedAddGroupHom V\u2081 V\u2082) : \u21d1(r \u2022 f) = r \u2022 \u21d1f :=\n  rfl\n#align normed_add_group_hom.coe_zsmul NormedAddGroupHom.coe_zsmul\n\n@[simp]\ntheorem zsmul_apply (r : \u2124) (f : NormedAddGroupHom V\u2081 V\u2082) (v : V\u2081) : (r \u2022 f) v = r \u2022 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\u2081 V\u2082) :=\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\u2081 V\u2082) :=\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\u2081 V\u2082 : Type _} [NormedAddCommGroup V\u2081] [NormedAddCommGroup V\u2082] :\n    NormedAddCommGroup (NormedAddGroupHom V\u2081 V\u2082) :=\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\u2081 V\u2082 \u2192+ V\u2081 \u2192 V\u2082 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 {\u03b9 : Type _} (s : Finset \u03b9) (f : \u03b9 \u2192 NormedAddGroupHom V\u2081 V\u2082) :\n    \u21d1(\u2211 i in s, f i) = \u2211 i in s, (f i : V\u2081 \u2192 V\u2082) :=\n  (coeAddHom : _ \u2192+ V\u2081 \u2192 V\u2082).map_sum f s\n#align normed_add_group_hom.coe_sum NormedAddGroupHom.coe_sum\n\ntheorem sum_apply {\u03b9 : Type _} (s : Finset \u03b9) (f : \u03b9 \u2192 NormedAddGroupHom V\u2081 V\u2082) (v : V\u2081) :\n    (\u2211 i in s, f i) v = \u2211 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\u2082]\n    [PseudoMetricSpace R] [BoundedSMul R V\u2082] : DistribMulAction R (NormedAddGroupHom V\u2081 V\u2082) :=\n  Function.Injective.distribMulAction coeAddHom coe_injective coe_smul\n\ninstance module {R : Type _} [Semiring R] [Module R V\u2082] [PseudoMetricSpace R] [BoundedSMul R V\u2082] :\n    Module R (NormedAddGroupHom V\u2081 V\u2082) :=\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\u2082 V\u2083) (f : NormedAddGroupHom V\u2081 V\u2082) :\n    NormedAddGroupHom V\u2081 V\u2083 :=\n  (g.toAddMonoidHom.comp f.toAddMonoidHom).mkNormedAddGroupHom (\u2016g\u2016 * \u2016f\u2016) fun v =>\n    calc\n      \u2016g (f v)\u2016 \u2264 \u2016g\u2016 * \u2016f v\u2016 := le_opNorm _ _\n      _ \u2264 \u2016g\u2016 * (\u2016f\u2016 * \u2016v\u2016) := (mul_le_mul_of_nonneg_left (le_opNorm _ _) (opNorm_nonneg _))\n      _ = \u2016g\u2016 * \u2016f\u2016 * \u2016v\u2016 := by rw [mul_assoc]\n\n#align normed_add_group_hom.comp NormedAddGroupHom.comp\n\ntheorem norm_comp_le (g : NormedAddGroupHom V\u2082 V\u2083) (f : NormedAddGroupHom V\u2081 V\u2082) :\n    \u2016g.comp f\u2016 \u2264 \u2016g\u2016 * \u2016f\u2016 :=\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\u2082 V\u2083} {C\u2081 C\u2082 : \u211d} (hg : \u2016g\u2016 \u2264 C\u2082)\n    (hf : \u2016f\u2016 \u2264 C\u2081) : \u2016g.comp f\u2016 \u2264 C\u2082 * C\u2081 :=\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\u2082 V\u2083} (C\u2081 C\u2082 C\u2083 : \u211d) (h : C\u2083 = C\u2082 * C\u2081)\n    (hg : \u2016g\u2016 \u2264 C\u2082) (hf : \u2016f\u2016 \u2264 C\u2081) : \u2016g.comp f\u2016 \u2264 C\u2083 := 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\u2082 V\u2083 \u2192+ NormedAddGroupHom V\u2081 V\u2082 \u2192+ NormedAddGroupHom V\u2081 V\u2083 :=\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\u2082 V\u2083) : f.comp (0 : NormedAddGroupHom V\u2081 V\u2082) = 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\u2081 V\u2082) : (0 : NormedAddGroupHom V\u2082 V\u2083).comp f = 0 := by\n  ext\n  rfl\n#align normed_add_group_hom.zero_comp NormedAddGroupHom.zero_comp\n\ntheorem comp_assoc {V\u2084 : Type _} [SeminormedAddCommGroup V\u2084] (h : NormedAddGroupHom V\u2083 V\u2084)\n    (g : NormedAddGroupHom V\u2082 V\u2083) (f : NormedAddGroupHom V\u2081 V\u2082) :\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\u2081 V\u2082) (g : NormedAddGroupHom V\u2082 V\u2083) :\n    (g.comp f : V\u2081 \u2192 V\u2083) = (g : V\u2082 \u2192 V\u2083) \u2218 (f : V\u2081 \u2192 V\u2082) :=\n  rfl\n#align normed_add_group_hom.coe_comp NormedAddGroupHom.coe_comp\n\nend NormedAddGroupHom\n\nnamespace NormedAddGroupHom\n\nvariable {V W V\u2081 V\u2082 V\u2083 : Type _} [SeminormedAddCommGroup V] [SeminormedAddCommGroup W]\n  [SeminormedAddCommGroup V\u2081] [SeminormedAddCommGroup V\u2082] [SeminormedAddCommGroup V\u2083]\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 \u2192 V)\n  map_add' v w := AddSubgroup.coe_add _ _ _\n  bound' := \u27e81, fun v => by rw [one_mul, AddSubgroup.coe_norm]\u27e9\n#align normed_add_group_hom.incl NormedAddGroupHom.incl\n\ntheorem norm_incl {V' : AddSubgroup V} (x : V') : \u2016incl _ x\u2016 = \u2016x\u2016 :=\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\u2081 V\u2082) (g : NormedAddGroupHom V\u2082 V\u2083)\n\n/-- The kernel of a bounded group homomorphism. Naturally endowed with a\n`SeminormedAddCommGroup` instance. -/\ndef ker : AddSubgroup V\u2081 :=\n  f.toAddMonoidHom.ker\n#align normed_add_group_hom.ker NormedAddGroupHom.ker\n\ntheorem mem_ker (v : V\u2081) : v \u2208 f.ker \u2194 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\u2081 \u2192 V\u2082` satisfying `g.comp f = 0` for some `g : V\u2082 \u2192 V\u2083`,\n    the corestriction of `f` to the kernel of `g`. -/\n@[simps]\ndef ker.lift (h : g.comp f = 0) : NormedAddGroupHom V\u2081 g.ker where\n  toFun v := \u27e8f v, by rw [g.mem_ker, \u2190comp_apply g f, h, zero_apply]\u27e9\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\u2081 V\u2082).ker = \u22a4 := 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\u2081) = (f : V\u2081 \u2192 V\u2082) \u207b\u00b9' {0} :=\n  rfl\n#align normed_add_group_hom.coe_ker NormedAddGroupHom.coe_ker\n\ntheorem isClosed_ker {V\u2082 : Type _} [NormedAddCommGroup V\u2082] (f : NormedAddGroupHom V\u2081 V\u2082) :\n    IsClosed (f.ker : Set V\u2081) :=\n  f.coe_ker \u25b8 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\u2081 V\u2082) (g : NormedAddGroupHom V\u2082 V\u2083)\n\n/-- The image of a bounded group homomorphism. Naturally endowed with a\n`SeminormedAddCommGroup` instance. -/\ndef range : AddSubgroup V\u2082 :=\n  f.toAddMonoidHom.range\n#align normed_add_group_hom.range NormedAddGroupHom.range\n\ntheorem mem_range (v : V\u2082) : v \u2208 f.range \u2194 \u2203 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\u2081) : f v \u2208 f.range :=\n  \u27e8v, rfl\u27e9\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\u2081) : (incl s).range = s := by\n  ext x\n  exact \u27e8fun \u27e8y, hy\u27e9 => by rw [\u2190 hy]; simp, fun hx => \u27e8\u27e8x, hx\u27e9, by simp\u27e9\u27e9\n#align normed_add_group_hom.incl_range NormedAddGroupHom.incl_range\n\n@[simp]\ntheorem range_comp_incl_top : (f.comp (incl (\u22a4 : AddSubgroup V\u2081))).range = f.range := by\n  simp [comp_range, incl_range, \u2190 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 `\u2016f v\u2016 \u2264 \u2016v\u2016` for all `v`. -/\ndef NormNoninc (f : NormedAddGroupHom V W) : Prop :=\n  \u2200 v, \u2016f v\u2016 \u2264 \u2016v\u2016\n#align normed_add_group_hom.norm_noninc NormedAddGroupHom.NormNoninc\n\nnamespace NormNoninc\n\ntheorem normNoninc_iff_norm_le_one : f.NormNoninc \u2194 \u2016f\u2016 \u2264 1 := by\n  refine' \u27e8fun h => _, fun h => fun v => _\u27e9\n  \u00b7 refine' opNorm_le_bound _ zero_le_one fun v => _\n    simpa [one_mul] using h v\n  \u00b7 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\u2081 V\u2082).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\u2082 V\u2083} {f : NormedAddGroupHom V\u2081 V\u2082} (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\u2081 V\u2082} : (-f).NormNoninc \u2194 f.NormNoninc :=\n  \u27e8fun h x => by simpa using h x, fun h x => (norm_neg (f x)).le.trans (h x)\u27e9\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) : \u2016f v\u2016 = \u2016v\u2016 :=\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\u2082 V\u2083} {f : NormedAddGroupHom V\u2081 V\u2082} (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\u2081 W\u2082 W\u2083 : Type _} [SeminormedAddCommGroup W\u2081] [SeminormedAddCommGroup W\u2082]\n  [SeminormedAddCommGroup W\u2083]\n\nvariable (f) (g : NormedAddGroupHom V W)\n\nvariable {f\u2081 g\u2081 : NormedAddGroupHom V\u2081 W\u2081}\n\nvariable {f\u2082 g\u2082 : NormedAddGroupHom V\u2082 W\u2082}\n\nvariable {f\u2083 g\u2083 : NormedAddGroupHom V\u2083 W\u2083}\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 \u03b9 : NormedAddGroupHom (f.equalizer g) V :=\n  incl _\n#align normed_add_group_hom.equalizer.\u03b9 NormedAddGroupHom.Equalizer.\u03b9\n\ntheorem comp_\u03b9_eq : f.comp (\u03b9 f g) = g.comp (\u03b9 f g) := by\n  ext x\n  rw [comp_apply, comp_apply, \u2190 sub_eq_zero, \u2190 NormedAddGroupHom.sub_apply]\n  exact x.2\n#align normed_add_group_hom.equalizer.comp_\u03b9_eq NormedAddGroupHom.Equalizer.comp_\u03b9_eq\n\nvariable {f g}\n\n/-- If `\u03c6 : NormedAddGroupHom V\u2081 V` is such that `f.comp \u03c6 = g.comp \u03c6`, the induced morphism\n`NormedAddGroupHom V\u2081 (f.equalizer g)`. -/\n@[simps]\ndef lift (\u03c6 : NormedAddGroupHom V\u2081 V) (h : f.comp \u03c6 = g.comp \u03c6) :\n    NormedAddGroupHom V\u2081 (f.equalizer g)\n    where\n  toFun v :=\n    \u27e8\u03c6 v,\n      show (f - g) (\u03c6 v) = 0 by\n        rw [NormedAddGroupHom.sub_apply, sub_eq_zero, \u2190 comp_apply, h, comp_apply]\u27e9\n  map_add' v\u2081 v\u2082 := by\n    ext\n    simp only [map_add, AddSubgroup.coe_add, Subtype.coe_mk]\n  bound' := by\n    obtain \u27e8C, _C_pos, hC\u27e9 := \u03c6.bound\n    exact \u27e8C, hC\u27e9\n#align normed_add_group_hom.equalizer.lift NormedAddGroupHom.Equalizer.lift\n\n@[simp]\ntheorem \u03b9_comp_lift (\u03c6 : NormedAddGroupHom V\u2081 V) (h : f.comp \u03c6 = g.comp \u03c6) :\n    (\u03b9 _ _).comp (lift \u03c6 h) = \u03c6 := by\n  ext\n  rfl\n#align normed_add_group_hom.equalizer.\u03b9_comp_lift NormedAddGroupHom.Equalizer.\u03b9_comp_lift\n\n/-- The lifting property of the equalizer as an equivalence. -/\n@[simps]\ndef liftEquiv :\n    { \u03c6 : NormedAddGroupHom V\u2081 V // f.comp \u03c6 = g.comp \u03c6 } \u2243 NormedAddGroupHom V\u2081 (f.equalizer g)\n    where\n  toFun \u03c6 := lift \u03c6 \u03c6.prop\n  invFun \u03c8 := \u27e8(\u03b9 f g).comp \u03c8, by rw [\u2190 comp_assoc, \u2190 comp_assoc, comp_\u03b9_eq]\u27e9\n  left_inv \u03c6 := by simp\n  right_inv \u03c8 := by\n    ext\n    rfl\n#align normed_add_group_hom.equalizer.lift_equiv NormedAddGroupHom.Equalizer.liftEquiv\n\n/-- Given `\u03c6 : NormedAddGroupHom V\u2081 V\u2082` and `\u03c8 : NormedAddGroupHom W\u2081 W\u2082` such that\n`\u03c8.comp f\u2081 = f\u2082.comp \u03c6` and `\u03c8.comp g\u2081 = g\u2082.comp \u03c6`, the induced morphism\n`NormedAddGroupHom (f\u2081.equalizer g\u2081) (f\u2082.equalizer g\u2082)`. -/\ndef map (\u03c6 : NormedAddGroupHom V\u2081 V\u2082) (\u03c8 : NormedAddGroupHom W\u2081 W\u2082) (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6)\n    (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6) : NormedAddGroupHom (f\u2081.equalizer g\u2081) (f\u2082.equalizer g\u2082) :=\n  lift (\u03c6.comp <| \u03b9 _ _) <| by\n    simp only [\u2190 comp_assoc, \u2190 hf, \u2190 hg]\n    simp only [comp_assoc, comp_\u03b9_eq f\u2081 g\u2081]\n#align normed_add_group_hom.equalizer.map NormedAddGroupHom.Equalizer.map\n\nvariable {\u03c6 : NormedAddGroupHom V\u2081 V\u2082} {\u03c8 : NormedAddGroupHom W\u2081 W\u2082}\n\nvariable {\u03c6' : NormedAddGroupHom V\u2082 V\u2083} {\u03c8' : NormedAddGroupHom W\u2082 W\u2083}\n\n@[simp]\ntheorem \u03b9_comp_map (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6) :\n    (\u03b9 f\u2082 g\u2082).comp (map \u03c6 \u03c8 hf hg) = \u03c6.comp (\u03b9 f\u2081 g\u2081) :=\n  \u03b9_comp_lift _ _\n#align normed_add_group_hom.equalizer.\u03b9_comp_map NormedAddGroupHom.Equalizer.\u03b9_comp_map\n\n@[simp]\ntheorem map_id : map (f\u2082 := f\u2081) (g\u2082 := g\u2081) (id V\u2081) (id W\u2081) rfl rfl = id (f\u2081.equalizer g\u2081) := by\n  ext\n  rfl\n#align normed_add_group_hom.equalizer.map_id NormedAddGroupHom.Equalizer.map_id\n\ntheorem comm_sq\u2082 (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hf' : \u03c8'.comp f\u2082 = f\u2083.comp \u03c6') :\n    (\u03c8'.comp \u03c8).comp f\u2081 = f\u2083.comp (\u03c6'.comp \u03c6) := by\n  rw [comp_assoc, hf, \u2190 comp_assoc, hf', comp_assoc]\n#align normed_add_group_hom.equalizer.comm_sq\u2082 NormedAddGroupHom.Equalizer.comm_sq\u2082\n\ntheorem map_comp_map (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6)\n    (hf' : \u03c8'.comp f\u2082 = f\u2083.comp \u03c6') (hg' : \u03c8'.comp g\u2082 = g\u2083.comp \u03c6') :\n    (map \u03c6' \u03c8' hf' hg').comp (map \u03c6 \u03c8 hf hg) =\n      map (\u03c6'.comp \u03c6) (\u03c8'.comp \u03c8) (comm_sq\u2082 hf hf') (comm_sq\u2082 hg hg') := by\n  ext\n  rfl\n#align normed_add_group_hom.equalizer.map_comp_map NormedAddGroupHom.Equalizer.map_comp_map\n\ntheorem \u03b9_normNoninc : (\u03b9 f g).NormNoninc := fun _v => le_rfl\n#align normed_add_group_hom.equalizer.\u03b9_norm_noninc NormedAddGroupHom.Equalizer.\u03b9_normNoninc\n\n/-- The lifting of a norm nonincreasing morphism is norm nonincreasing. -/\ntheorem lift_normNoninc (\u03c6 : NormedAddGroupHom V\u2081 V) (h : f.comp \u03c6 = g.comp \u03c6) (h\u03c6 : \u03c6.NormNoninc) :\n    (lift \u03c6 h).NormNoninc :=\n  h\u03c6\n#align normed_add_group_hom.equalizer.lift_norm_noninc NormedAddGroupHom.Equalizer.lift_normNoninc\n\n/-- If `\u03c6` satisfies `\u2016\u03c6\u2016 \u2264 C`, then the same is true for the lifted morphism. -/\ntheorem norm_lift_le (\u03c6 : NormedAddGroupHom V\u2081 V) (h : f.comp \u03c6 = g.comp \u03c6) (C : \u211d) (h\u03c6 : \u2016\u03c6\u2016 \u2264 C) :\n    \u2016lift \u03c6 h\u2016 \u2264 C :=\n  h\u03c6\n#align normed_add_group_hom.equalizer.norm_lift_le NormedAddGroupHom.Equalizer.norm_lift_le\n\ntheorem map_normNoninc (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6)\n    (h\u03c6 : \u03c6.NormNoninc) : (map \u03c6 \u03c8 hf hg).NormNoninc :=\n  lift_normNoninc _ _ <| h\u03c6.comp \u03b9_normNoninc\n#align normed_add_group_hom.equalizer.map_norm_noninc NormedAddGroupHom.Equalizer.map_normNoninc\n\ntheorem norm_map_le (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6) (C : \u211d)\n    (h\u03c6 : \u2016\u03c6.comp (\u03b9 f\u2081 g\u2081)\u2016 \u2264 C) : \u2016map \u03c6 \u03c8 hf hg\u2016 \u2264 C :=\n  norm_lift_le _ _ _ h\u03c6\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\u2081`.\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 \u2265 `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 : \u2115 \u2192 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 : \u2115} {R : Type u_1} [comm_ring R] (P : \u2115 \u2192 Prop) (x : witt_vector p R) : witt_vector p R :=\n  mk p fun (n : \u2115) => 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 : \u2115 \u2192 Prop) (n : \u2115) : mv_polynomial \u2115 \u2124 :=\n  ite (P n) (mv_polynomial.X n) 0\n\ntheorem coeff_select {p : \u2115} {R : Type u_1} [comm_ring R] (P : \u2115 \u2192 Prop) (x : witt_vector p R) (n : \u2115) : coeff (select P x) n = coe_fn (mv_polynomial.aeval (coeff x)) (select_poly P n) := sorry\n\ntheorem select_is_poly {p : \u2115} (P : \u2115 \u2192 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 : \u2115) => coeff_select P x i)\n\ntheorem select_add_select_not {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (P : \u2115 \u2192 Prop) (x : witt_vector p R) : select P x + select (fun (i : \u2115) => \u00acP i) x = x := sorry\n\ntheorem coeff_add_of_disjoint {p : \u2115} [hp : fact (nat.prime p)] (n : \u2115) {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) (h : \u2200 (n : \u2115), coeff x n = 0 \u2228 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 : \u2115} {R : Type u_1} [comm_ring R] (n : \u2115) : witt_vector p R \u2192 witt_vector p R :=\n  select fun (i : \u2115) => 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 : \u2115} {R : Type u_1} [comm_ring R] (n : \u2115) : witt_vector p R \u2192 witt_vector p R :=\n  select fun (i : \u2115) => n \u2264 i\n\n@[simp] theorem init_add_tail {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : \u2115) : init n x + tail n x = x := sorry\n\n@[simp] theorem init_init {p : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : \u2115) : init n (init n x) = init n x := sorry\n\ntheorem init_add {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) (n : \u2115) : init n (x + y) = init n (init n x + init n y) := sorry\n\ntheorem init_mul {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) (n : \u2115) : init n (x * y) = init n (init n x * init n y) := sorry\n\ntheorem init_neg {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : \u2115) : init n (-x) = init n (-init n x) := sorry\n\ntheorem init_sub {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R] (x : witt_vector p R) (y : witt_vector p R) (n : \u2115) : 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 : \u2115) (n : \u2115) : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => init n :=\n  select_is_poly fun (i : \u2115) => 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 \u2192 \u2124`\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 `\u2124`,\n   mapping negative `x` to `-x`, is admissible.\n * `polynomial.card_pow_degree_is_admissible` shows `card_pow_degree`,\n   mapping `p : polynomial \ud835\udd3d_q` to `q ^ degree p`, is admissible\n-/\n\n\n-- mathport name: \u00abexpr \u227a \u00bb\nlocal infixl:50 \" \u227a \" => EuclideanDomain.r\n\nnamespace AbsoluteValue\n\nvariable {R : Type _} [EuclideanDomain R]\n\nvariable (abv : AbsoluteValue R \u2124)\n\n#print AbsoluteValue.IsAdmissible /-\n/-- An absolute value `R \u2192 \u2124` 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 : \u211d \u2192 \u2115\n  exists_partition' :\n    \u2200 (n : \u2115) {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5) {b : R} (hb : b \u2260 0) (A : Fin n \u2192 R),\n      \u2203 t : Fin n \u2192 Fin (card \u03b5), \u2200 i\u2080 i\u2081, t i\u2080 = t i\u2081 \u2192 (abv (A i\u2081 % b - A i\u2080 % b) : \u211d) < abv b \u2022 \u03b5\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))))} {\u03b9 : Type.{u2}} [_inst_2 : Fintype.{u2} \u03b9] {\u03b5 : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) \u03b5) -> (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 : \u03b9 -> R) (h : AbsoluteValue.IsAdmissible.{u1} R _inst_1 abv), Exists.{succ u2} (\u03b9 -> (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h \u03b5))) (fun (t : \u03b9 -> (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h \u03b5))) => forall (i\u2080 : \u03b9) (i\u2081 : \u03b9), (Eq.{1} (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h \u03b5)) (t i\u2080) (t i\u2081)) -> (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\u2093.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\u2081) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i\u2080) 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) \u03b5)))))\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))))} {\u03b9 : Type.{u2}} [_inst_2 : Fintype.{u2} \u03b9] {\u03b5 : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) \u03b5) -> (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 : \u03b9 -> R) (h : AbsoluteValue.IsAdmissible.{u1} R _inst_1 abv), Exists.{succ u2} (\u03b9 -> (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h \u03b5))) (fun (t : \u03b9 -> (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h \u03b5))) => forall (i\u2080 : \u03b9) (i\u2081 : \u03b9), (Eq.{1} (Fin (AbsoluteValue.IsAdmissible.card.{u1} R _inst_1 abv h \u03b5)) (t i\u2080) (t i\u2081)) -> (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\u2081) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i\u2080) 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) \u03b5)))))\nCase conversion may be inaccurate. Consider using '#align absolute_value.is_admissible.exists_partition AbsoluteValue.IsAdmissible.exists_partition\u2093'. -/\n/-- For all `\u03b5 > 0` and finite families `A`, we can partition the remainders of `A` mod `b`\ninto `abv.card \u03b5` sets, such that all elements in each part of remainders are close together. -/\ntheorem exists_partition {\u03b9 : Type _} [Fintype \u03b9] {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5) {b : R} (hb : b \u2260 0)\n    (A : \u03b9 \u2192 R) (h : abv.IsAdmissible) :\n    \u2203 t : \u03b9 \u2192 Fin (h.card \u03b5), \u2200 i\u2080 i\u2081, t i\u2080 = t i\u2081 \u2192 (abv (A i\u2081 % b - A i\u2080 % b) : \u211d) < abv b \u2022 \u03b5 :=\n  by\n  let e := Fintype.equivFin \u03b9\n  obtain \u27e8t, ht\u27e9 := h.exists_partition' (Fintype.card \u03b9) h\u03b5 hb (A \u2218 e.symm)\n  refine' \u27e8t \u2218 e, fun i\u2080 i\u2081 h => _\u27e9\n  convert ht (e i\u2080) (e i\u2081) 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) {\u03b5 : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) \u03b5) -> (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 \u03b5) 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 \u03b5) n))) (fun (i\u2080 : 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 \u03b5) 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 \u03b5) n))) (fun (i\u2081 : 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 \u03b5) 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 \u03b5) n))) i\u2080 i\u2081) (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\u2093.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\u2081 k) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i\u2080 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) \u03b5))))))\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) {\u03b5 : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) \u03b5) -> (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 \u03b5) 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 \u03b5) n))) (fun (i\u2080 : 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 \u03b5) 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 \u03b5) n))) (fun (i\u2081 : 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 \u03b5) 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 \u03b5) n))) i\u2080 i\u2081) (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\u2081 k) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i\u2080 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) \u03b5))))))\nCase conversion may be inaccurate. Consider using '#align absolute_value.is_admissible.exists_approx_aux AbsoluteValue.IsAdmissible.exists_approx_aux\u2093'. -/\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 : \u2115) (h : abv.IsAdmissible) :\n    \u2200 {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5) {b : R} (hb : b \u2260 0) (A : Fin (h.card \u03b5 ^ n).succ \u2192 Fin n \u2192 R),\n      \u2203 i\u2080 i\u2081, i\u2080 \u2260 i\u2081 \u2227 \u2200 k, (abv (A i\u2081 k % b - A i\u2080 k % b) : \u211d) < abv b \u2022 \u03b5 :=\n  by\n  haveI := Classical.decEq R\n  induction' n with n ih\n  \u00b7 intro \u03b5 h\u03b5 b hb A\n    refine' \u27e80, 1, _, _\u27e9\n    \u00b7 simp\n    rintro \u27e8i, \u27e8\u27e9\u27e9\n  intro \u03b5 h\u03b5 b hb A\n  set M := h.card \u03b5 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 \u27e8s, s_inj, hs\u27e9 :\n    \u2203 s : Fin (M ^ n).succ \u2192 Fin (M ^ n.succ).succ,\n      Function.Injective s \u2227 \u2200 i\u2080 i\u2081, (abv (A (s i\u2081) 0 % b - A (s i\u2080) 0 % b) : \u211d) < abv b \u2022 \u03b5 :=\n    by\n    -- We can partition the `A`s into `M` subsets where\n    -- the first components lie close together:\n    obtain \u27e8t, ht\u27e9 :\n      \u2203 t : Fin (M ^ n.succ).succ \u2192 Fin M,\n        \u2200 i\u2080 i\u2081, t i\u2080 = t i\u2081 \u2192 (abv (A i\u2081 0 % b - A i\u2080 0 % b) : \u211d) < abv b \u2022 \u03b5 :=\n      h.exists_partition h\u03b5 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 \u27e8s, hs\u27e9 :=\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      \u27e8fun i => (finset.univ.filter fun x => t x = s).toList.nthLe i _, _, fun i\u2080 i\u2081 => ht _ _ _\u27e9\n    \u00b7 refine' i.2.trans_le _\n      rwa [Finset.length_toList]\n    \u00b7 intro i j h\n      ext\n      exact list.nodup_iff_nth_le_inj.mp (Finset.nodup_toList _) _ _ _ _ h\n    have :\n      \u2200 i h,\n        (finset.univ.filter fun x => t x = s).toList.nthLe i h \u2208\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 \u27e8_, h\u2080\u27e9 := finset.mem_filter.mp (this i\u2080 _)\n    obtain \u27e8_, h\u2081\u27e9 := finset.mem_filter.mp (this i\u2081 _)\n    exact h\u2080.trans h\u2081.symm\n  -- Since `s` is large enough, there are two elements of `A \u2218 s`\n  -- where the second components lie close together.\n  obtain \u27e8k\u2080, k\u2081, hk, h\u27e9 := ih h\u03b5 hb fun x => Fin.tail (A (s x))\n  refine' \u27e8s k\u2080, s k\u2081, fun h => hk (s_inj h), fun i => Fin.cases _ (fun i => _) i\u27e9\n  \u00b7 exact hs k\u2080 k\u2081\n  \u00b7 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))))} {\u03b9 : Type.{u2}} [_inst_2 : Fintype.{u2} \u03b9] {\u03b5 : Real}, (LT.lt.{0} Real Real.hasLt (OfNat.ofNat.{0} Real 0 (OfNat.mk.{0} Real 0 (Zero.zero.{0} Real Real.hasZero))) \u03b5) -> (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 \u03b5) (Fintype.card.{u2} \u03b9 _inst_2)))) -> \u03b9 -> 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 \u03b5) (Fintype.card.{u2} \u03b9 _inst_2)))) (fun (i\u2080 : 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 \u03b5) (Fintype.card.{u2} \u03b9 _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 \u03b5) (Fintype.card.{u2} \u03b9 _inst_2)))) (fun (i\u2081 : 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 \u03b5) (Fintype.card.{u2} \u03b9 _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 \u03b5) (Fintype.card.{u2} \u03b9 _inst_2)))) i\u2080 i\u2081) (forall (k : \u03b9), 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\u2093.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\u2081 k) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.hasMod.{u1} R _inst_1)) (A i\u2080 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) \u03b5))))))\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))))} {\u03b9 : Type.{u2}} [_inst_2 : Fintype.{u2} \u03b9] {\u03b5 : Real}, (LT.lt.{0} Real Real.instLTReal (OfNat.ofNat.{0} Real 0 (Zero.toOfNat0.{0} Real Real.instZeroReal)) \u03b5) -> (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 \u03b5) (Fintype.card.{u2} \u03b9 _inst_2)))) -> \u03b9 -> 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 \u03b5) (Fintype.card.{u2} \u03b9 _inst_2)))) (fun (i\u2080 : 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 \u03b5) (Fintype.card.{u2} \u03b9 _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 \u03b5) (Fintype.card.{u2} \u03b9 _inst_2)))) (fun (i\u2081 : 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 \u03b5) (Fintype.card.{u2} \u03b9 _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 \u03b5) (Fintype.card.{u2} \u03b9 _inst_2)))) i\u2080 i\u2081) (forall (k : \u03b9), 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\u2081 k) b) (HMod.hMod.{u1, u1, u1} R R R (instHMod.{u1} R (EuclideanDomain.instMod.{u1} R _inst_1)) (A i\u2080 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) \u03b5))))))\nCase conversion may be inaccurate. Consider using '#align absolute_value.is_admissible.exists_approx AbsoluteValue.IsAdmissible.exists_approx\u2093'. -/\n/-- Any large enough family of vectors in `R^\u03b9` has a pair of elements\nwhose remainders are close together, pointwise. -/\ntheorem exists_approx {\u03b9 : Type _} [Fintype \u03b9] {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5) {b : R} (hb : b \u2260 0)\n    (h : abv.IsAdmissible) (A : Fin (h.card \u03b5 ^ Fintype.card \u03b9).succ \u2192 \u03b9 \u2192 R) :\n    \u2203 i\u2080 i\u2081, i\u2080 \u2260 i\u2081 \u2227 \u2200 k, (abv (A i\u2081 k % b - A i\u2080 k % b) : \u211d) < abv b \u2022 \u03b5 :=\n  by\n  let e := Fintype.equivFin \u03b9\n  obtain \u27e8i\u2080, i\u2081, ne, h\u27e9 := h.exists_approx_aux (Fintype.card \u03b9) h\u03b5 hb fun x y => A x (e.symm y)\n  refine' \u27e8i\u2080, i\u2081, Ne, fun k => _\u27e9\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 {\u03b9 : Type*} {M : Type*} [add_comm_group M] [module R M]\n  (v : \u03b9 \u2192 M) (hv : is_basis R v) (a : \u03b9) :\n  linear_map R M M :=\n{ to_fun := \u03bb x, x - hv.repr x a \u2022 v a,\n  map_add' := \u03bb x y, by {show (x + y) - hv.repr (x + y) a \u2022 v a = (x - _) + (y - _),\n  rw linear_map.map_add, erw add_smul, abel, },\n  map_smul' := \u03bb c x, by {show c \u2022 x - hv.repr (c \u2022 x) a \u2022 v a = c \u2022 (x - _),\n  rw linear_map.map_smul, rw smul_sub, rw \u2190mul_smul, refl, } }\n\ntheorem proj_mem {\u03b9 : Type*} {M : Type*} [add_comm_group M] [module R M]\n  {s : set \u03b9} {v : \u03b9 \u2192 M} (hv : is_basis R (v \u2218 subtype.val : s \u2192 M)) {a : \u03b9} (ha : a \u2208 s) {x : M} :\n  projection _ hv \u27e8a, ha\u27e9 x \u2208 submodule.span R (set.range (v \u2218 subtype.val : (s \\ {a} \u2192 M))) :=\nbegin\n  show _ - _ \u2208 _,\n  conv {to_lhs, congr, rw \u2190hv.total_repr x},\n  cases classical.em ((\u27e8a, ha\u27e9 : s) \u2208 (hv.repr x).support),\n  rw finsupp.total_apply, unfold finsupp.sum,\n  rw \u2190finset.insert_erase h,\n  erw finset.sum_insert (finset.not_mem_erase (\u27e8a, ha\u27e9 : 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 \u2218 subtype.val))) (((hv.repr) x).support.erase \u27e8a, ha\u27e9)\n  (\u03bb (y : s), ((hv.repr) x) y \u2022 v y.val) _,\n  intros y hy, dsimp,\n  apply submodule.smul_mem (submodule.span R (set.range (v \u2218 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 = \u27e8a, ha\u27e9 := 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 \u2218 subtype.val)))\n      (((hv.repr) x).support)\n  (\u03bb (y : s), ((hv.repr) x) y \u2022 v y.val) _,\n  intros y hy, dsimp,\n  apply submodule.smul_mem (submodule.span R (set.range (v \u2218 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 = \u27e8a, ha\u27e9 := subtype.ext_iff.2 hya,\n  rw hyan at hy, exact h hy,\nend\n\nlemma proj_ker {\u03b9 : Type*} {M : Type*} [add_comm_group M] [module R M]\n  {s : set \u03b9} {v : \u03b9 \u2192 M} (hv : is_basis R (v \u2218 subtype.val : s \u2192 M)) {a : \u03b9} (ha : a \u2208 s) :\n  (projection _ hv \u27e8a, ha\u27e9).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 \u27e8a, ha\u27e9,\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 \u2190hr, rw linear_map.map_smul,\n  have := @is_basis.repr_eq_single _ _ _ _ _ _ _ hv \u27e8a, ha\u27e9,\n  have hh : hv.repr ((v \u2218 subtype.val) (\u27e8a, ha\u27e9 : s)) (\u27e8a, ha\u27e9 : 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 {\u03b9 : Type*} {M : Type*} [add_comm_group M] [module R M]\n  {v : \u03b9 \u2192 M} (hv : is_basis R v) :\n  projective R M :=\nbegin\n  intros _ _ _ _ _ _ _ _ hg,\n  let F' := \u03bb i : \u03b9, classical.some (hg (f (v i))),\n  let F := @is_basis.constr _ _ _ _ _ _ _ _inst_6 _ _inst_7 hv F',\n  use F,\n  have huh : \u2200 i : \u03b9, 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 (\u03bb x, huh x),\n  intro x,\n  rw \u2190this,\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 \u2192\u2097[R] B) (H : A.subtype.range = f.ker)\n(g : B \u2192\u2097[R] M) (hfg : f.comp g = linear_map.id) (hf : f.range = \u22a4) :\n  A \u2293 g.range = \u22a5 \u2227 A \u2294 g.range = \u22a4 :=\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 \u2190linear_map.mem_ker, rw \u2190H, exact \u27e8\u27e8x, hx.1\u27e9, trivial, rfl\u27e9},\n  rw \u2190hy.2 at this, rw \u2190linear_map.comp_apply at this,\n  rw hfg at this,\n  rw linear_map.id_apply at this,\n  rw \u2190hy.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 \u2190submodule.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 \u27e8f x, rfl\u27e9,\n  rw sub_add_cancel,\nend\n\nvariables {\u03b9 : Type*} {M : Type*} (s : set \u03b9)\n  [fintype \u03b9] [add_comm_group M]\n  [module R M] (v : \u03b9 \u2192 M)\n  (a : \u03b9)\n\nvariables (R)\n\ndef wtf' (i : (s \\ ({a} : set \u03b9) : set \u03b9)) : submodule.span R\n  (set.range (v \u2218 subtype.val : s \\ {a} \u2192 M)) :=\nsubtype.mk ((v \u2218 subtype.val) i) (submodule.subset_span $ set.mem_range_self i)\n\nvariables {R}\nlemma is_basis_diff {n : \u2115} {\u03b9 : Type*} {M : Type*} {s : set \u03b9}\n  [fintype \u03b9] (hs : fintype.card \u21a5s = nat.succ n) [add_comm_group M]\n  [module R M] {v : \u03b9 \u2192 M} (hv : is_basis R (v \u2218 subtype.val : s \u2192 M))\n  {a : \u03b9} (ha : a \u2208 s) :\n is_basis R (wtf' R s v a \u2218 (subtype.val : (@set.univ (s \\ ({a} : set \u03b9) : set \u03b9) : set _) \u2192\n   (s \\ ({a} : set \u03b9) : set \u03b9))) :=\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 \u2218 subtype.val : s \\ {a} \u2192 M) \u2286\n  set.range (v \u2218 subtype.val : s \u2192 M)), by\n  {rw set.range_subset_iff, intro y,\n  exact \u27e8\u27e8(y : \u03b9), set.diff_subset _ _ y.2\u27e9, rfl\u27e9}) this,\n  refine linear_independent.of_subtype_range _ H,\n  have hi := linear_independent.injective hv1,\n  intros x y h,\n  have hxy : (\u27e8(x : \u03b9), set.diff_subset _ _ x.2\u27e9 : s) = (\u27e8(y : \u03b9), set.diff_subset _ _ y.2\u27e9 : 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 \u2190submodule.span_image,\n  rw \u2190set.range_comp, congr' 1,\n  ext,\n  split,\n  rintro \u27e8y, hy\u27e9, simp only [submodule.subtype_apply, function.comp_app, wtf'] at hy,\n  rw \u2190hy, use y.1, refl,\n  rintro \u27e8y, hy\u27e9,\n  rw \u2190hy, use y, simp only [wtf', submodule.subtype_apply, submodule.coe_mk, function.comp_app],\nend\n\ntheorem free_subm0 (\u03b9 : Type*) [fintype \u03b9] (s : set \u03b9) (hs : fintype.card s = 0)\n  (M : Type*) [add_comm_group M] [module R M] (v : \u03b9 \u2192 M)\n  (hv : is_basis R (v \u2218 (subtype.val : s \u2192 \u03b9)))\n  (S : submodule R M) : \u2203 (t : set M), linear_independent R (\u03bb x, x : t \u2192 M) \u2227\n    submodule.span R (set.range (\u03bb x, x : t \u2192 M)) = S :=\nbegin\n  use \u2205,\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 : \u2200 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 \u2218 (subtype.val : s \u2192 \u03b9 )) = \u2205 :=\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 {\u03b9 : Type*} (x : \u03b9)\n  {M : Type*} [add_comm_group M] [module R M] {v : \u03b9 \u2192 M}\n  (hv : is_basis R (v \u2218 (subtype.val : ({x}: set \u03b9) \u2192 \u03b9))) :\n  linear_equiv R R M :=\nequiv_of_is_basis (@is_basis_singleton_one ({x} : set \u03b9) R\n  (set.unique_singleton x) _) hv (equiv.refl _)\n\n\nlemma free_subm1 (\u03b9 : Type*) [fintype \u03b9] (s : set \u03b9) (hs : \u00ac 1 < fintype.card s)\n  (M : Type*) [add_comm_group M] [module R M] (v : \u03b9 \u2192 M) (hv : is_basis R (v \u2218 (subtype.val : s \u2192 \u03b9)))\n  (S : submodule R M) : \u2203 (t : set M), linear_independent R (\u03bb x, x : t \u2192 M) \u2227\n    submodule.span R (set.range (\u03bb x, x : t \u2192 M)) = S :=\nbegin\n  cases classical.em (S = \u22a5),\n  use \u2205, split, exact linear_independent_empty _ _, rw h, simp,\n  have : fintype.card s = 0 \u2228 fintype.card s = 1 := by omega,\n  cases this with hl hr, exact free_subm0 \u03b9 s hl M v hv S,\n  cases fintype.card_eq_one_iff.1 hr with y hy,\n  have hrange : set.range (v \u2218 subtype.val) = {(v \u2218 subtype.val) y} := by {rw \u2190set.image_univ,\n  convert set.image_singleton, symmetry, rw \u2190set.univ_subset_iff, intros t ht, exact hy t,},\n  have hys : {(y : \u03b9)} = s := by {ext a, split, intro ha, convert y.2, intro ha,\n  exact subtype.ext_iff.1 (hy \u27e8a, ha\u27e9)},\n  let Smap := S.map (@free_equiv R _ _ \u03b9 (y : \u03b9) M _ _ v (hys.symm \u25b8 hv)).symm.to_linear_map,\n  cases submodule.is_principal.principal Smap with c hc,\n  let C := @free_equiv R _ _ \u03b9 (y : \u03b9) M _ _ v (hys.symm \u25b8 hv) c,\n  use {C},\n  have hCy : C \u2208 submodule.span R {(v \u2218 subtype.val) y} := by {rw \u2190hrange, 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 \u22a2, rw \u2190set.image_singleton,\n    erw submodule.span_image,\n   rw \u2190hc, rw \u2190submodule.map_comp, symmetry, convert submodule.map_id S, ext z,\n   exact linear_equiv.apply_symm_apply (@free_equiv R _ _ \u03b9 (y : \u03b9) M _ _ v (hys.symm \u25b8 hv)) z,},\n  have hC0 : C \u2260 0 := \u03bb hC0, by {rw hC0 at hCS, change S = submodule.span R (\u22a5 : submodule R M) at hCS,\n    erw submodule.span_eq at hCS, exact h hCS},\n  have hr0 : r \u2260 0 := \u03bb 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 \u2022 v (y : \u03b9)}, rw \u2190hr,\n  rw set.singleton_subset_iff, exact set.mem_singleton _,\n  have hry : {r \u2022 v (y : \u03b9)} = set.range (\u03bb m : s, r \u2022 (v \u2218 subtype.val) m) :=\n    by {rw \u2190set.image_univ, erw \u2190@set.image_singleton _ _ (\u03bb m : s, r \u2022 (v \u2218 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 \u2208 s} \u2192\u2080 R := finsupp.map_range (\u03bb m, r \u2022 m) (smul_zero r) l,\n  have hvL := hv1 L (by {rw finsupp.total_apply at hl \u22a2, 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 : \u2115} {\u03b9 : Type*} {M : Type*} {s : set \u03b9} [h\u03b9 : fintype \u03b9]\n  (hs : fintype.card \u21a5s = n.succ)\n[add_comm_group M] [module R M] {v : \u03b9 \u2192 M} (hv : is_basis R (v \u2218 subtype.val : s \u2192 M))\n{S : submodule R M} (h1 : 1 < fintype.card \u21a5s) {b : \u03b9} (hb : b \u2208 s)\n{t : set \u21a5(submodule.span R (set.range (v \u2218 subtype.val : s \\ {b} \u2192 M)))}\n(ht : linear_independent R (\u03bb (x : t), (\u2191x : submodule.span R (set.range\n (v \u2218 subtype.val : s \\ {b} \u2192 M)))) \u2227 submodule.span R (set.range (\u03bb (x : \u21a5t),\n (\u2191x : submodule.span R (set.range\n (v \u2218 subtype.val : s \\ {b} \u2192 M))))) =\n      submodule.map\n        (linear_map.cod_restrict (submodule.span R (set.range (v \u2218 subtype.val)))\n           (projection (v \u2218 subtype.val) hv \u27e8b, hb\u27e9)\n           (\u03bb c, proj_mem hv hb))\n        S)\n{l : set \u21a5((projection (v \u2218 subtype.val) hv \u27e8b, hb\u27e9).ker)}\n(hl :\n  linear_independent R (\u03bb (x : \u21a5l), (\u2191x : (projection (v \u2218 subtype.val) hv \u27e8b, hb\u27e9).ker)) \u2227\n    submodule.span R (set.range (\u03bb (x : \u21a5l), (\u2191x : (projection (v \u2218 subtype.val) hv \u27e8b, hb\u27e9).ker))) =\n    ((submodule.of_le $ @inf_le_right _ _ S (projection _ hv \u27e8b, hb\u27e9).ker).range))\n(h : l = \u2205) :\n\u2203 (t : set M),\n    linear_independent R (\u03bb (x : \u21a5t), (\u2191x : M)) \u2227 submodule.span R (set.range (\u03bb (x : \u21a5t), \u2191x)) = S :=\nbegin\n  use (submodule.span R (set.range (v \u2218 subtype.val : s \\ {b} \u2192 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 \u2218 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 (\u03b9 : Type*) [fintype \u03b9] (s : set \u03b9) (n : \u2115) (hs : fintype.card s = n)\n  (M : Type*) [add_comm_group M] [module R M] (v : \u03b9 \u2192 M) (hv : is_basis R (v \u2218 (subtype.val : s \u2192 \u03b9)))\n  (S : submodule R M) : \u2203 (t : set M), linear_independent R (\u03bb x, x : t \u2192 M) \u2227 submodule.span R (set.range (\u03bb x, x : t \u2192 M)) = S :=\nbegin\n  unfreezingI {revert \u03b9 M s,\n  induction n using nat.case_strong_induction_on with n hn},\n  intros \u03b9 M s h\u03b9 h0 inst inst' v hv S,\n    exact @free_subm0 _ _ _ \u03b9 h\u03b9 s h0 M inst inst' v hv S,\n  intros \u03b9 M s h\u03b9 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 \u27e8b, hb\u27e9,\n  rcases hn n (nat.le_refl n) (s \\ ({b} : set \u03b9) : set \u03b9)\n    (submodule.span R (set.range (v \u2218 subtype.val : (s \\ ({b} : set \u03b9)) \u2192 M))) (set.univ)\n  (by {\n    apply (add_right_inj 1).1, rw add_comm 1 n, rw \u2190nat.succ_eq_add_one n, rw \u2190 hs,\n    erw univ_card'', rw add_comm,\n    rw (card_insert' (s \\ ({b} : set \u03b9)) not_mem_diff_singleton).symm,\n    congr, rw \u2190eq_insert_erase_of_mem s b hb, apply_instance, apply_instance})\n    (\u03bb i, \u27e8v i, submodule.subset_span $ set.mem_range_self i\u27e9)\n    (by convert is_basis_diff hs hv hb)\n   (S.map $ (projection _ hv \u27e8b, hb\u27e9).cod_restrict (submodule.span R (set.range\n     (v \u2218 subtype.val : (s \\ ({b} : set \u03b9)) \u2192 M)))\n   (\u03bb c, proj_mem hv hb)) with \u27e8t, ht\u27e9,\n  rcases hn 1 (by omega) ({b} : set \u03b9) (projection _ hv \u27e8b, hb\u27e9).ker set.univ sorry\n    (\u03bb x, \u27e8v x, by {rw proj_ker,apply submodule.subset_span,convert set.mem_singleton _, exact x.2.symm}\u27e9)\n  (by {split,\n  suffices : linear_independent R (v \u2218 subtype.val : ({b} : set \u03b9) \u2192 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 \u03b9)) l)\n         (by {rw finsupp.mem_supported, rw finsupp.support_emb_domain,\n         intros x hx, rcases finset.mem_map.1 hx with \u27e8y, hym, hy\u27e9,\n         rw \u2190hy, 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 (\u03bb (i : ({b} : set \u03b9)) (c : R), c \u2022 v (\u2191i : \u03b9)) = 0) \u2192\n  (finsupp.emb_domain (function.embedding.subtype ({b} : set \u03b9)) l = 0)) at this,\n     specialize this (by {rw subtype.ext_iff at hl,dsimp at hl,rw \u2190hl,\n     show _ = submodule.subtype _ _,\n     conv_rhs {rw \u2190finsupp.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 \u2218 subtype.val : ({b} : set \u03b9) \u2192 M) \u2286\n    set.range (v \u2218 subtype.val : s \u2192 M), by\n  {rw set.range_subset_iff, intro y, use b, exact hb, rw \u2190subtype.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 : \u03b9) = b, from c.2), symmetry, exact d.2, exact hm,\n  apply linear_map.map_injective (projection _ hv \u27e8b, hb\u27e9).ker.ker_subtype,\n  rw submodule.map_subtype_top, rw \u2190submodule.span_image, symmetry,\n  convert proj_ker hv hb,\n  rw \u2190set.range_comp,\n  ext m,\n  split,\n  rintro \u27e8k, hk\u27e9,\n  rw \u2190 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 \u27e8b, hb\u27e9).ker).range with \u27e8l, hl\u27e9,\n  cases (classical.em (l = \u2205)),\n    exact one_empty hs hv h1 hb ht hl h,\n  let V := (submodule.span R (set.range (v \u2218 subtype.val : (s \\ ({b} : set \u03b9)) \u2192 M))).subtype '' t,\n  let W := (projection (v \u2218 subtype.val) hv \u27e8b, hb\u27e9).ker.subtype '' l,\n  use V \u222a W,\n  refine union_is_basis_of_gen_compl S ((submodule.span R (set.range (v \u2218 subtype.val :\n    (s \\ ({b} : set \u03b9)) \u2192 M))).comap S.subtype) V (submodule.comap S.subtype $\n    linear_map.ker (projection (v \u2218 subtype.val) hv \u27e8b, hb\u27e9)) 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 \u2190submodule.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 \u03b9 s h1 M v hv S,\nend\n\nlemma tf_iff {M : Type*} [add_comm_group M] [module R M] :\n  tors R M = \u22a5 \u2194 \u2200 (x : M) (r : R), r \u2022 x = 0 \u2192 r = 0 \u2228 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 \u27e8r, h_1, hx\u27e9),\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) : (\u22a4 : 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) \u22a4\n\nlemma span_insert_zero_eq' {s : set M} :\n  submodule.span R (insert (0 : M) s) = submodule.span R s :=\nbegin\n  rw \u2190set.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 \u2260 \u22a5) (hs : submodule.span R (\u2191s : 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) \u2208 s) with hl hr,\n  rw \u2190finset.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 \u2286 {c}) : l = \u2205 \u2228 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 \u2190this,\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 {\u03b1 : Type*} {l : \u03b1 \u2192\u2080 R} {x : \u03b1}\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)) \u2192\u2080 R}\n  (hx : x \u2209 s) (hl : l.2 (\u27e8x, set.mem_insert x (WHY s)\u27e9 : set.insert x (WHY s)) = 0) :\n  WHY s \u2192\u2080 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 \u27e8z, hzm, hz\u27e9, rw \u2190hz, exact\nor.resolve_left z.2 (by {intro hzx, rw finsupp.mem_support_iff at hzm, apply hzm, rw \u2190hl,\n  congr, rw subtype.ext_iff, exact hzx})}),\n  to_fun := \u03bb x, l \u27e8x, set.subset_insert _ _ x.2\u27e9,\n  mem_support_to_fun := \u03bb y, by {split, intros h h0, erw finset.mem_image at h,\n  rcases h with \u27e8b, hmb, hb\u27e9, cases b with b1 b2, erw finset.mem_image at b2, rcases b2 with \u27e8c, hmc, hc\u27e9,\n  apply finsupp.mem_support_iff.1 hmc, rw \u2190subtype.eta c c.2, rw \u2190h0, congr' 1,\n    rw subtype.mk_eq_mk, rw hc, rw \u2190hb, refl,\n    intros h0, apply finset.mem_image.2, use (y : M), apply finset.mem_image.2,\n    use \u27e8y, set.subset_insert _ _ y.2\u27e9,\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)) \u2192\u2080 R}\n  (hx : x \u2209 s) (hl : l.2 (\u27e8x, set.mem_insert x (WHY s)\u27e9 : set.insert x (WHY s)) = 0)\n  {y : M} (hy : y \u2208 s) : finsupp_insert hx hl \u27e8y, hy\u27e9 = l \u27e8y, set.subset_insert _ _ hy\u27e9 :=\nrfl\n\n\n\nlemma finsupp_insert_total {s : finset M} {x : M} {l :  (set.insert x (WHY s)) \u2192\u2080 R}\n  (hx : x \u2209 s) (hl : l.2 (\u27e8x, set.mem_insert x (WHY s)\u27e9 : 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 (\u03bb (z : WHY s), l \u27e8z, set.subset_insert _ _ z.2\u27e9 \u2022 (z : M)) = _,\n  sorry,\nend\n\nvariables (\u03c1 : 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 : \u00ac(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker = \u22a5) :\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 (\u03bb f, f \u2260 0) (by {\n  have h' : \u00ac(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker \u2264 \u22a5, from \u03bb h', h (eq_bot_iff.2 h'),\n  rcases submodule.not_le_iff_exists.1 h' with \u27e8y, hym, hy\u27e9, 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 : \u00ac(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker = \u22a5) : R :=\ndep_coeff_map s z h \u27e8z, (set.mem_insert z _)\u27e9\n\ntheorem dep_coeff_spec {M : Type*} [add_comm_group M] [module R M] (s : finset M) (z : M)\n  (h : \u00ac(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker = \u22a5) :\n  dep_coeff_map s z h \u2260 0 :=\n@classical.some_spec (finsupp.total (set.insert z (WHY s)) M R subtype.val).ker (\u03bb f, f \u2260 0) (by {\n  have h' : \u00ac(finsupp.total (set.insert z (WHY s)) M R subtype.val).ker \u2264 \u22a5,\n    from \u03bb h', h (eq_bot_iff.2 h'),\n  rcases submodule.not_le_iff_exists.1 h' with \u27e8y, hym, hy\u27e9, 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 : \u2200 z : M, z \u2208 Y \\ s \u2192 \u00ac(finsupp.total (set.insert (z : M) (WHY s)) M R subtype.val).ker = \u22a5)\n  (hli : (finsupp.total (WHY s) M R subtype.val).ker = \u22a5) :\n finset.prod (finset.image (\u03bb w : (WHY (Y \\ s)), dep_coeff s (w : M) $ h w w.2)\n (@finset.univ (WHY (Y \\ s)) _)) id \u2260 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 \u27e8x, hxm, hx\u27e9,\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 \u2190hx, congr, rw subtype.ext_iff, exact h_1,\n  have huh := finsupp.ext_iff.1 hF0 \u27e8a, h_1\u27e9,\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 : \u2200 z : M, z \u2208 Y \\ s \u2192 \u00ac(finsupp.total (set.insert (z : M) (WHY s)) M R subtype.val).ker = \u22a5)\n (hli : (finsupp.total (WHY s) M R subtype.val).ker = \u22a5)\n {y} (hy : y \u2208 Y) :\n finset.prod (finset.image (\u03bb w : (WHY (Y \\ s)), dep_coeff s (w : M) $ h w w.2)\n (@finset.univ (WHY (Y \\ s)) _)) id \u2022 y \u2208 submodule.span R (\u2191s : set M) :=\nbegin\n  sorry,\nend\n\nvariables {r : R} (S : submodule R M)\n\nnoncomputable def r_equiv (htf : \u2200 (x : S) (r : R), r \u2022 x = 0 \u2192 r = 0 \u2228 x = 0) (r : R) (hr : r \u2260 0) :=\nlinear_equiv.of_injective ((r \u2022 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 \u2190submodule.coe_smul at hm,\n  rw \u2190@submodule.coe_zero _ _ _ _ _ S at hm, exact hm}) hr})\n\nlemma equiv_apply (htf : \u2200 (x : S) (r : R), r \u2022 x = 0 \u2192 r = 0 \u2228 x = 0) (r : R) (hr : r \u2260 0) {x : S} :\n(r_equiv S htf r hr x : M) = r \u2022 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 : \u2200 (x : S) (r : R), r \u2022 x = 0 \u2192 r = 0 \u2228 x = 0) :\n  \u2203 (t : set M), linear_independent R (\u03bb x, x : t \u2192 M) \u2227\n  submodule.span R (set.range (\u03bb x, x : t \u2192 M)) = S :=\nbegin\n  cases (classical.em (S = \u22a5)),\n  {  use \u2205,\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 : (\u2191Y : set M) \u2286 S := set.subset.trans (finset.erase_subset 0 X) (hX \u25b8 submodule.subset_span),\n  set n := nat.find_greatest (\u03bb n, \u2203 s : finset M, s \u2286 Y \u2227\n    linear_independent R (\u03bb x, x : (WHY s) \u2192 M) \u2227 s.card = n) Y.card,\n  cases @nat.find_greatest_spec (\u03bb n, \u2203 s : finset M, s \u2286 Y \u2227\n    linear_independent R (\u03bb x, x : (WHY s) \u2192 M) \u2227 s.card = n) _ Y.card\n    \u27e81, 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 \u2190finsupp.support_eq_empty, exact hl0,\n    rw single_of_singleton_support hlc at hl \u22a2,\n    rw finsupp.total_single at hl,\n    rw finsupp.single_eq_zero,\n    exact or.resolve_right (htf \u27e8c, hY hc\u27e9 (l c) (subtype.ext_iff.2 $ hl))\n    (\u03bb h0, (finset.mem_erase.1 hc).1 $ subtype.ext_iff.1 h0),\n    exact finset.card_singleton _,\n     }\u27e9 with s hs,\n  cases (classical.em (\u2203 x, x \u2208 Y \\ s)),\n  cases h_1 with z hz,\n  have hnl : \u2200 z, z \u2208 Y \\ s \u2192 \u00ac(linear_independent R $ (\u03bb y, y : (set.insert z (WHY s) : set M) \u2192 M)) :=\n    \u03bb x hx hnl,\n  by {have huh := @nat.find_greatest_is_greatest (\u03bb n, \u2203 s : finset M, s \u2286 Y \u2227\n    linear_independent R (\u03bb x, x : (WHY s) \u2192 M) \u2227 s.card = n) _ Y.card\n      \u27e81, 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 \u2190finsupp.support_eq_empty, exact hl0,\n    rw single_of_singleton_support hlc at hl \u22a2,\n    rw finsupp.total_single at hl,\n    rw finsupp.single_eq_zero,\n    exact or.resolve_right (htf \u27e8c, hY hc\u27e9 (l c) (subtype.ext_iff.2 $ hl))\n      (\u03bb h0, (finset.mem_erase.1 hc).1 $ subtype.ext_iff.1 h0),\n    exact finset.card_singleton _,\n     }\u27e9 n.succ (by {split, exact nat.lt_succ_self _, rw nat.succ_le_iff, simp only [n], erw \u2190hs.2.2,\n     apply finset.card_lt_card, rw finset.ssubset_iff_of_subset, use x,\n     rw \u2190finset.mem_sdiff, exact hx, exact hs.1}),\n     exact huh \u27e8(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      }\u27e9, },\n  unfold linear_independent at hnl,\nset r : R := finset.prod (finset.image (\u03bb w : (\u2191(Y \\ s) : set M),\n   dep_coeff s (w : M) $ hnl w w.2) (@finset.univ (\u2191(Y \\ s) : set M) _)) id,\n have hr0 : r \u2260 0 := prod_ne_zero Y s hnl hs.2.1,\n  have hrX : \u2200 x, x \u2208 X \u2192 r \u2022 x \u2208 submodule.span R (\u2191s : set M) := sorry,\n  have hrS : \u2200 x, x \u2208 S \u2192 r \u2022 x \u2208 submodule.span R (\u2191s : set M) := \u03bb w hw,\n  by {rw \u2190hX at hw, rw \u2190set.image_id (\u2191X : set M) at hw, rcases\n  (finsupp.mem_span_iff_total R).1 hw with \u27e8f, hfm, hf\u27e9,\n  rw \u2190hf, rw finsupp.total_apply, rw finsupp.smul_sum,\n  apply submodule.sum_mem (submodule.span R (\u2191s : set M)), intros c hc,\n  dsimp, rw \u2190mul_smul, rw mul_comm, rw mul_smul,\n  apply submodule.smul_mem (submodule.span R (\u2191s : set M)) (f c),\n  exact hrX c (hfm hc)\n   },\n  cases free_subm (\u2191s : 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 (\u2191s : set M) : set M) (\u03bb x, \u27e8x, submodule.subset_span x.2\u27e9)\n  \u27e8sorry, sorry\u27e9 (submodule.comap (submodule.span R (\u2191s : set M)).subtype\n    (submodule.map (r \u2022 linear_map.id) S)) with t ht,\n  let T := (\u03bb x, r \u2022 x)\u207b\u00b9' (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 \u27e8f, hfm, hf\u27e9,\n  refine absurd ht.1 _,\n  apply submodule.not_le_iff_exists.2,\n  let sset : finset t := @finset.preimage _ _ (subtype.val \u2218 subtype.val)\n     (finset.image (\u03bb x : T, r \u2022 (x : M)) f.1) sorry,\n  let func : t \u2192 R := \u03bb x, f.2 \u27e8r \u2022 x, sorry\u27e9,\n  let F : t \u2192\u2080 R := \u27e8sset, func, sorry\u27e9,\n  use F,\n  split,\n    sorry, sorry,\n  ext i, split,\n  intro hmem,\n  sorry, sorry,\n  use (\u2191s : set M),\n  split,\n  exact hs.2.1,\n  rw \u2190hX,\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) : \u2203 t : set S, linear_independent R (\u03bb x, x : t \u2192 S) \u2227\n  (tors R S) \u2293 (submodule.span R t) = \u22a5 \u2227 (tors R S) \u2294 (submodule.span R t) = \u22a4 :=\nbegin\n  cases free_of_tf (tors R S).quotient \u22a4 (fg_quotient S hfg (tors R S))\n    (tf_iff.1 $ eq_bot_iff.2 $ \u03bb b hb, by {have := eq_bot_iff.1 (tors_free_of_quotient R S),\n    rcases hb with \u27e8c, hc\u27e9,\n    have h0 : c \u2022 (b : (tors R S).quotient) = 0 := by {rw \u2190submodule.coe_smul,\n      rw \u2190@submodule.coe_zero R (tors R S).quotient _ _ _ \u22a4, congr, exact hc.2 },\n    have ffs := this \u27e8c, hc.1, h0\u27e9,\n    rw submodule.mem_bot at ffs \u22a2, 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    (\u03bb x, quotient.induction_on' x $ \u03bb y, \u27e8y, rfl\u27e9)) 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 : _ \u2192 S) \u2218 subtype.val : t \u2192 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 \u2190hl,\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 \u2190set.image_univ,\n  rw set.image_comp, rw submodule.span_image,\n  show _ = (\u22a4 : 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 (\u03bb x, x : tf_basis S hfg \u2192 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) \u2293 (submodule.span R $ tf_basis S hfg) = \u22a5 :=\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) \u2294 (submodule.span R $ tf_basis S hfg) = \u22a4 :=\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\u00eda In\u00e9s de Frutos-Fern\u00e1ndez. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mar\u00eda In\u00e9s de Frutos-Fern\u00e1ndez\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 : \u211d) (hc_pos : 0 < c) (hc_one_lt : 1 < c) : mul_ring_norm (ratfunc K) :=\n{ to_fun := \u03bb r, if r = 0 then 0 else c ^ r.int_degree,\n  map_zero' := sorry,\n  add_le' := sorry,\n  neg' := \u03bb r,\n  begin\n    by_cases r = 0,\n    { simp only [h, neg_zero] } ,\n    { have h\u2081 : \u00ac -r = 0,\n      { intro h\u2081,\n        apply h,\n        exact neg_eq_zero.1 h\u2081 },\n      simp only [h, h\u2081, 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 \u2228 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\u2081 h\u2082,\n      simp only [h\u2081, h\u2082, if_false],\n      rw ratfunc.int_degree_mul h\u2081 h\u2082,\n      repeat {rw \u2190real.rpow_int_cast},\n      push_cast,\n      exact real.rpow_add hc_pos _ _ }\n  end,\n  eq_zero_of_map_eq_zero' := \u03bb 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 : \u211d) \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 : \u211d)\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\u2081 : r = 0,\n    { right,\n      have h\u2082 : \u00ac s = 0,\n      { intro h\u2083,\n        apply h,\n        simp only [h\u2081, h\u2083, add_zero] },\n      simp only [h\u2081, h\u2082, zero_add, if_false] },\n    { have h\u2082 : \u00ac s = 0 := sorry, -- this is false,\n      simp only [h\u2081, h\u2082, 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 : \u211d) \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 := \u03bb 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 : \u00ac 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 : \u00ac 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 \u2228 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 \u2190@zpow_add\u2080 _ _ c (by linarith),\n      congr,\n      rw \u2190to_add_mul,\n      congr,\n      rw \u2190with_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 : \u211d) (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 : \u211d)\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 : \u00ac 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 \u2190real.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 : \u2115) {\u03b9 : \u2115 \u2192 R} : \n  f (\u2211 i in finset.range n, \u03b9 i) \u2264 \u2211 i in finset.range n, f (\u03b9 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 \u2194 (\u2203 x : R, x \u2260 0 \u2227 \u2200 n : \u2115, f (n * x) \u2264 1) := sorry\n\nlemma unknown_name1 {K : Type*} [field K] [decidable_eq (ratfunc K)]\n  {f : mul_ring_norm (ratfunc K)} (hf_nontriv : f \u2260 1) \n    (hf_triv_K : \u2200 {x : K} (hx : x \u2260 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 \u27e81, _\u27e9,\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 \u2190 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 \u2260 f s) : \n    f (r + s) = max (f r) (f s) :=\nbegin\n  have hf\u2081 := hf,\n  specialize hf r s,\n  cases ne.lt_or_lt h_neq with h\u2081 h\u2082,\n  { specialize hf\u2081 (r + s) (-r),\n    simp only [add_neg_cancel_comm, map_neg_eq_map, le_max_iff] at hf\u2081,\n    cases hf\u2081 with h\u2083 h\u2084,\n    { have hrs : f r \u2264 f s := by linarith,\n      rw max_eq_right hrs at hf \u22a2,\n      linarith },\n    { linarith } },\n  { specialize hf\u2081 (r + s) (-s),\n    simp only [add_neg_cancel_right, map_neg_eq_map, le_max_iff] at hf\u2081,\n    cases hf\u2081 with h\u2083 h\u2084,\n    { have hrs : f s \u2264 f r := by linarith,\n      rw max_eq_left hrs at hf \u22a2,\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 \u2115) {g : \u2115 \u2192 R} {a : \u2115}\n    (h_max : \u2200 p : \u2115, f (g p) \u2264 f (g a)) :\n      f (\u2211 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 : \u211d) (hc_pos : 0 < c) (hc_one_lt : 1 < c) (f : mul_ring_norm (ratfunc K))\n    (hf_nontriv : f \u2260 1) (hf_triv_K : \u2200 {x : K} (hx : x \u2260 0), f (ratfunc.C x) = 1) :\n      (mul_ring_norm.equiv f (mul_ring_norm.infty K c hc_pos hc_one_lt)) \u2228\n        \u2203 (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\u2081 := 1 / f (ratfunc.mk X 1),\n    have hc\u2081 : 0 < c\u2081,\n    {sorry}, -- easy\n    have hc\u2082 : 0 \u2264 c\u2081,\n    { linarith [hc\u2081] },\n    have hc\u2083 : c\u2081 \u2260 1,\n    {sorry}, -- easy as well\n    have hc : c \u2260 0,\n    { linarith },\n    have hc1 : 0 \u2264 c,\n    { linarith },\n    have h\u2081 : \u2200 x : K[X], f (ratfunc.mk x 1) = c\u2081 ^ -(x.nat_degree : \u211d),\n    { intro x,\n      nth_rewrite 0 as_sum_support_C_mul_X_pow x,\n      have h\u2081 : ratfunc.mk (x.support.sum (\u03bb (i : \u2115), C (x.coeff i) * X ^ i)) 1\n      = \u2211 p in x.support, (ratfunc.mk (C (x.coeff p) * X ^ p) 1),\n      {sorry},\n      rw h\u2081, clear h\u2081,\n      have h\u2082 : \u2200 (p : \u2115), f (ratfunc.mk (C (x.coeff p) * X ^ p) 1)\n        \u2264 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\u2082,\n      clear h\u2082,\n      have h\u2083 : 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\u2083,\n      clear h\u2083,\n      have h\u2084 : f (ratfunc.mk (C (x.coeff x.nat_degree)) 1) = 1,\n      {sorry},\n      rw h\u2084,\n      clear h\u2084,\n      rw one_mul,\n      have h\u2085 : f (ratfunc.mk (X ^ x.nat_degree) 1) = (f (ratfunc.mk X 1)) ^ (x.nat_degree),\n      {sorry},\n      rw h\u2085,\n      clear h\u2085,\n      dsimp [c\u2081],\n      rw one_div,\n      rw \u2190real.rpow_neg_one,\n      rw \u2190real.rpow_mul,\n      { simp only [neg_mul, one_mul, neg_neg, real.rpow_nat_cast] },\n      sorry}, -- main step here\n    refine \u27e8-real.logb c\u2081 c, _, _\u27e9,\n    {sorry}, -- 0 < -real.logb c\u2081 c-\n    { ext,\n      rw [mul_ring_norm.infty_def],\n      by_cases h\u2082 : x = 0,\n      {sorry}, -- easy\n      { simp only [h\u2082, if_false],\n        have h\u2083 := h\u2081 (x.num),\n        specialize h\u2081 x.denom,\n        have h\u2084 : x = (ratfunc.mk x.num 1) / (ratfunc.mk x.denom 1),\n        {sorry}, -- quite tricky here\n        rw h\u2084,\n        have h\u2085 : 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\u2085,\n        rw [h\u2081, h\u2083],\n        rw \u2190real.rpow_sub hc\u2081,\n        field_simp,\n        rw \u2190real.rpow_mul hc\u2082,\n        rw \u2190neg_mul_comm,\n        field_simp,\n        rw mul_comm,\n        rw real.rpow_mul hc\u2082,\n        rw real.rpow_logb_eq_abs hc\u2081 hc\u2083 hc,\n        rw abs_eq_self.2 hc1,\n        dsimp [ratfunc.int_degree],\n        rw \u2190real.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 \u2194 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 \u2194 a + b = 0 := by\n  apply Iff.intro\n  \u00b7 intro h\n    rw [\u2190h]\n    sorry\n  \u00b7 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\u2082\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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nnamespace category_theory\n\nopen category\n\nvariables (C : Type u\u2081) [category.{v\u2081} C]\nvariables (D : Type u\u2082) [category.{v\u2082} D]\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\n/-- A category is skeletal if isomorphic objects are equal. -/\ndef skeletal : Prop := \u2200 \u2983X Y : C\u2984, is_isomorphic X Y \u2192 X = Y\n\n/--\n`is_skeleton_of C D F` says that `F : D \u2964 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 \u2964 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\u2081 F\u2082 : D \u2964 C} [quiver.is_thin C] (hC : skeletal C)\n  (hF : F\u2081 \u2245 F\u2082) : F\u2081 = F\u2082 :=\nfunctor.ext (\u03bb X, hC \u27e8hF.app X\u27e9) (\u03bb _ _ _, subsingleton.elim _ _)\n\n/--\nIf `C` is thin and skeletal, `D \u2964 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 \u2964 C) :=\n\u03bb F\u2081 F\u2082 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\u2081 := induced_category C quotient.out\n\ninstance [inhabited C] : inhabited (skeleton C) := \u27e8\u27e6default\u27e7\u27e9\n\n/-- The functor from the skeleton of `C` to `C`. -/\n@[simps, derive [full, faithful]]\nnoncomputable def from_skeleton : skeleton C \u2964 C := induced_functor _\n\ninstance : ess_surj (from_skeleton C) :=\n{ mem_ess_image := \u03bb X, \u27e8quotient.mk X, quotient.mk_out X\u27e9 }\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 \u224c C :=\n(from_skeleton C).as_equivalence\n\nlemma skeleton_skeletal : skeletal (skeleton C) :=\nbegin\n  rintro X Y \u27e8h\u27e9,\n  have : X.out \u2248 Y.out := \u27e8(from_skeleton C).map_iso h\u27e9,\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 \u224c D) : skeleton C \u2243 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 := \u03bb X, skeleton_skeletal C \u27e8(f.unit_iso.app X).symm\u27e9,\n  right_inv := \u03bb Y, skeleton_skeletal D \u27e8(f.counit_iso.app Y)\u27e9, }\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\u2081 := quotient (is_isomorphic_setoid C)\n\ninstance inhabited_thin_skeleton [inhabited C] : inhabited (thin_skeleton C) :=\n\u27e8quotient.mk default\u27e9\n\ninstance thin_skeleton.preorder : preorder (thin_skeleton C) :=\n{ le := quotient.lift\u2082 (\u03bb X Y, nonempty (X \u27f6 Y))\n  begin\n    rintros _ _ _ _ \u27e8i\u2081\u27e9 \u27e8i\u2082\u27e9,\n    exact propext \u27e8nonempty.map (\u03bb f, i\u2081.inv \u226b f \u226b i\u2082.hom),\n      nonempty.map (\u03bb f, i\u2081.hom \u226b f \u226b i\u2082.inv)\u27e9,\n  end,\n  le_refl :=\n  begin\n    refine quotient.ind (\u03bb a, _),\n    exact \u27e8\ud835\udfd9 _\u27e9,\n  end,\n  le_trans := \u03bb a b c, quotient.induction_on\u2083 a b c $ \u03bb A B C, nonempty.map2 (\u226b) }\n\n/-- The functor from a category to its thin skeleton. -/\n@[simps]\ndef to_thin_skeleton : C \u2964 thin_skeleton C :=\n{ obj := quotient.mk,\n  map := \u03bb 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\u03bb _ _, \u27e8by { rintros \u27e8\u27e8f\u2081\u27e9\u27e9 \u27e8\u27e8f\u2082\u27e9\u27e9, refl }\u27e9\n\nvariables {C} {D}\n\n/-- A functor `C \u2964 D` computably lowers to a functor `thin_skeleton C \u2964 thin_skeleton D`. -/\n@[simps]\ndef map (F : C \u2964 D) : thin_skeleton C \u2964 thin_skeleton D :=\n{ obj := quotient.map F.obj $ \u03bb X\u2081 X\u2082 \u27e8hX\u27e9, \u27e8F.map_iso hX\u27e9,\n  map := \u03bb X Y, quotient.rec_on_subsingleton\u2082 X Y $\n           \u03bb x y k, hom_of_le (k.le.elim (\u03bb t, \u27e8F.map t\u27e9)) }\n\nlemma comp_to_thin_skeleton (F : C \u2964 D) : F \u22d9 to_thin_skeleton D = to_thin_skeleton C \u22d9 map F :=\nrfl\n\n/-- Given a natural transformation `F\u2081 \u27f6 F\u2082`, induce a natural transformation `map F\u2081 \u27f6 map F\u2082`.-/\ndef map_nat_trans {F\u2081 F\u2082 : C \u2964 D} (k : F\u2081 \u27f6 F\u2082) : map F\u2081 \u27f6 map F\u2082 :=\n{ app := \u03bb X, quotient.rec_on_subsingleton X (\u03bb x, \u27e8\u27e8\u27e8k.app x\u27e9\u27e9\u27e9) }\n\n-- TODO: state the lemmas about what happens when you compose with `to_thin_skeleton`\n/-- A functor `C \u2964 D \u2964 E` computably lowers to a functor\n`thin_skeleton C \u2964 thin_skeleton D \u2964 thin_skeleton E` -/\n@[simps]\ndef map\u2082 (F : C \u2964 D \u2964 E) :\n  thin_skeleton C \u2964 thin_skeleton D \u2964 thin_skeleton E :=\n{ obj := \u03bb x,\n  { obj := \u03bb y, quotient.map\u2082 (\u03bb X Y, (F.obj X).obj Y)\n                (\u03bb X\u2081 X\u2082 \u27e8hX\u27e9 Y\u2081 Y\u2082 \u27e8hY\u27e9, \u27e8(F.obj X\u2081).map_iso hY \u226a\u226b (F.map_iso hX).app Y\u2082\u27e9) x y,\n    map := \u03bb y\u2081 y\u2082, quotient.rec_on_subsingleton x $\n            \u03bb X, quotient.rec_on_subsingleton\u2082 y\u2081 y\u2082 $\n              \u03bb Y\u2081 Y\u2082 hY, hom_of_le (hY.le.elim (\u03bb g, \u27e8(F.obj X).map g\u27e9)) },\n  map := \u03bb x\u2081 x\u2082, quotient.rec_on_subsingleton\u2082 x\u2081 x\u2082 $\n           \u03bb X\u2081 X\u2082 f,\n           { app := \u03bb y, quotient.rec_on_subsingleton y\n              (\u03bb Y, hom_of_le (f.le.elim (\u03bb f', \u27e8(F.map f').app Y\u27e9))) } }\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 \u2964 C :=\n{ obj := quotient.out,\n  map := \u03bb x y, quotient.rec_on_subsingleton\u2082 x y $\n    \u03bb X Y f,\n            (nonempty.some (quotient.mk_out X)).hom\n          \u226b f.le.some\n          \u226b (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 (\u03bb X, (nonempty.some (quotient.mk_out X))) (by tidy),\n  unit_iso :=\n    nat_iso.of_components\n      (\u03bb x, quotient.rec_on_subsingleton x\n        (\u03bb X, eq_to_iso (quotient.sound \u27e8(nonempty.some (quotient.mk_out X)).symm\u27e9)))\n      (by tidy) }\n\n/-- The equivalence between the thin skeleton and the category itself. -/\nnoncomputable def equivalence : thin_skeleton C \u224c C :=\n(from_thin_skeleton C).as_equivalence\n\nvariables {C}\n\nlemma equiv_of_both_ways {X Y : C} (f : X \u27f6 Y) (g : Y \u27f6 X) : X \u2248 Y :=\n\u27e8iso_of_both_ways f g\u27e9\n\ninstance thin_skeleton_partial_order : partial_order (thin_skeleton C) :=\n{ le_antisymm := quotient.ind\u2082\n  begin\n    rintros _ _ \u27e8f\u27e9 \u27e8g\u27e9,\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\u03bb X Y, quotient.induction_on\u2082 X Y $ \u03bb x y h, h.elim $ \u03bb i, i.1.le.antisymm i.2.le\n\nlemma map_comp_eq (F : E \u2964 D) (G : D \u2964 C) : map (F \u22d9 G) = map F \u22d9 map G :=\nfunctor.eq_of_iso skeletal $\n  nat_iso.of_components (\u03bb X, quotient.rec_on_subsingleton X (\u03bb x, iso.refl _)) (by tidy)\n\nlemma map_id_eq : map (\ud835\udfed C) = \ud835\udfed (thin_skeleton C) :=\nfunctor.eq_of_iso skeletal $\n  nat_iso.of_components (\u03bb X, quotient.rec_on_subsingleton X (\u03bb x, iso.refl _)) (by tidy)\n\nlemma map_iso_eq {F\u2081 F\u2082 : D \u2964 C} (h : F\u2081 \u2245 F\u2082) : map F\u2081 = map F\u2082 :=\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\u27e8thin_skeleton_is_skeleton\u27e9\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 \u2964 C) (L : C \u2964 D) (h : L \u22a3 R) :\n  thin_skeleton.map L \u22a3 thin_skeleton.map R :=\nadjunction.mk_of_unit_counit\n{ unit :=\n  { app := \u03bb X,\n    begin\n      letI := is_isomorphic_setoid C,\n      refine quotient.rec_on_subsingleton X (\u03bb x, hom_of_le \u27e8h.unit.app x\u27e9),\n      -- TODO: make quotient.rec_on_subsingleton' so the letI isn't needed\n    end },\n  counit :=\n  { app := \u03bb X,\n    begin\n      letI := is_isomorphic_setoid D,\n      refine quotient.rec_on_subsingleton X (\u03bb x, hom_of_le \u27e8h.counit.app x\u27e9),\n    end } }\n\nend thin_skeleton\n\nopen thin_skeleton\n\nsection\nvariables {C} {\u03b1 : Type*} [partial_order \u03b1]\n\n/--\nWhen `e : C \u224c \u03b1` is a categorical equivalence from a thin category `C` to some partial order `\u03b1`,\nthe `thin_skeleton C` is order isomorphic to `\u03b1`.\n-/\nnoncomputable\ndef equivalence.thin_skeleton_order_iso\n  [quiver.is_thin C] (e : C \u224c \u03b1) : thin_skeleton C \u2243o \u03b1 :=\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\u00f6nne\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 := \u27e8{to_Top := { \u03b1 := pempty }}\u27e9\n\ninstance category : category Profinite := induced_category.category to_Top\ninstance concrete_category : concrete_category Profinite := induced_category.concrete_category _\ninstance has_forget\u2082 : has_forget\u2082 Profinite Top := induced_category.has_forget\u2082 _\n\ninstance : has_coe_to_sort Profinite := \u27e8Type*, \u03bb X, X.to_Top\u27e9\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) : (\ud835\udfd9 X : X \u2192 X) = id := rfl\n\n@[simp] lemma coe_comp {X Y Z : Profinite} (f : X \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g : X \u2192 Z) = g \u2218 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 \u2964 Top := forget\u2082 _ _\n\n/-- The fully faithful embedding of `Profinite` in `CompHaus`. -/\n@[simps] def Profinite.to_CompHaus : Profinite \u2964 CompHaus :=\n{ obj := \u03bb X, { to_Top := X.to_Top },\n  map := \u03bb _ _ f, f }\n\ninstance : full Profinite.to_CompHaus := { preimage := \u03bb _ _ f, f }\ninstance : faithful Profinite.to_CompHaus := {}\n\n@[simp] lemma Profinite.to_CompHaus_to_Top :\n  Profinite.to_CompHaus \u22d9 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\u2081 u\u2082} \u2192 Profinite.{max u\u2081 u\u2082}`.\ndef CompHaus.to_Profinite_obj (X : CompHaus.{u}) : Profinite.{u} :=\n{ to_Top := { \u03b1 := connected_components X.to_Top.\u03b1 },\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 \u27f6 Y) \u2243 (X \u27f6 Profinite.to_CompHaus.obj Y) :=\n{ to_fun := \u03bb f,\n  { to_fun := f.1 \u2218 quotient.mk,\n    continuous_to_fun := continuous.comp f.2 (continuous_quotient_mk) },\n  inv_fun := \u03bb g,\n    { to_fun := continuous.connected_components_lift g.2,\n      continuous_to_fun := continuous.connected_components_lift_continuous g.2},\n  left_inv := \u03bb f, continuous_map.ext $ \u03bb x, quotient.induction_on x $ \u03bb a, rfl,\n  right_inv := \u03bb f, continuous_map.ext $ \u03bb 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 \u2964 Profinite :=\nadjunction.left_adjoint_of_equiv Profinite.to_CompHaus_equivalence (\u03bb _ _ _ _ _, rfl)\n\nlemma CompHaus.to_Profinite_obj' (X : CompHaus) :\n  \u21a5(CompHaus.to_Profinite.obj X) = connected_components X.to_Top.\u03b1 := 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 \u22a3 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 := \u27e8CompHaus.to_Profinite, Profinite.to_Profinite_adj_to_CompHaus\u27e9 }\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 \u2964 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 \u27f6 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 \u27f6 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 \u27f6 Y)\n  (bij : function.bijective f) : X \u2245 Y :=\nby letI := Profinite.is_iso_of_bijective f bij; exact as_iso f\n\ninstance forget_reflects_isomorphisms : reflects_isomorphisms (forget Profinite) :=\n\u27e8by introsI A B f hf; exact Profinite.is_iso_of_bijective _ ((is_iso_iff_bijective \u21d1f).mp hf)\u27e9\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 {\u03b1 : Type*} {\u03b2 : Type*}\nvariables [decidable_eq \u03b1] [add_comm_group \u03b1] [vector_space \u211d \u03b1] [\u211d_inner_product_space \u03b1]\nvariables [decidable_eq \u03b2] [add_comm_group \u03b2] [vector_space \u211d \u03b2] [\u211d_inner_product_space \u03b2]\n\nopen real function\n\ndef \u211d_topological_space : topological_space \u211d := by apply_instance\n\ndef \u03b1_uniform_space : uniform_space \u03b1 :=\nbegin\n    have w := @ip_space_is_metric_space \u03b1 _ _ _ _,\n    exact @metric_space.to_uniform_space \u03b1 w,\nend\n\ndef \u03b1_topological_space : topological_space \u03b1 := @uniform_space.to_topological_space \u03b1 \u03b1_uniform_space\n\nsection ip_map\n\ndef ip_map (x : \u03b1) : linear_map \u211d \u03b1 \u211d :=\nbegin\n    refine_struct {..},\n    use \u03bb y, \u27eax \u2225 y\u27eb,\n    repeat {simp},\nend\n\n@[simp] lemma ip_map_to_fun (x : \u03b1) : \u21d1(ip_map x) = \u03bb y, \u27eax \u2225 y\u27eb := rfl\n\ntheorem ip_map_is_bounded_linear_map (x : \u03b1) : @is_bounded_linear_map \u211d _ \u03b1 ip_space_is_normed_space \u211d _ (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 \u2225x\u2225,\n    split,\n    have w := (@norm_neq_zero_iff_neq_zero \u03b1 (ip_space_is_normed_space) x).2 h,\n    have \u03b1_normed_group : normed_group \u03b1 := begin\n        have w := @ip_space_is_normed_space \u03b1 _ _ _ _,\n        exact @normed_space.to_normed_group \u211d \u03b1 _ w,\n    end,\n    have k := (@norm_pos_iff \u03b1 \u03b1_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 : \u03b1) : @continuous \u03b1 _ \u03b1_topological_space \u211d_topological_space (ip_map x) :=\n@is_bounded_linear_map.continuous \u211d _ \u03b1 ip_space_is_normed_space \u211d _ _ (ip_map_is_bounded_linear_map x)\n\nend ip_map\n\nsection hilbert_space\n\nclass Hilbert_space (\u03b1 : Type*) [decidable_eq \u03b1] [add_comm_group \u03b1] [vector_space \u211d \u03b1] extends \u211d_inner_product_space \u03b1 :=\n(complete : \u2200 {f : filter \u03b1}, (@cauchy \u03b1 (@\u03b1_uniform_space \u03b1 _ _ _ _)) f \u2192 \u2203x, f \u2264 @nhds \u03b1 (@\u03b1_topological_space \u03b1 _ _ _ _) x)\n\nvariables [Hilbert_space \u03b1] [Hilbert_space \u03b2]\n\nstructure unitary_operator (\u03b1 : Type*) (\u03b2 : Type*) [decidable_eq \u03b1] [add_comm_group \u03b1] [vector_space \u211d \u03b1] [\u211d_inner_product_space \u03b1] [Hilbert_space \u03b1]\n[decidable_eq \u03b2] [add_comm_group \u03b2] [vector_space \u211d \u03b2] [\u211d_inner_product_space \u03b2] [Hilbert_space \u03b2] extends linear_map \u211d \u03b1 \u03b2 :=\n(bijective : bijective to_fun)\n(norm_preserving : \u2200 (x : \u03b1), \u2225to_fun x\u2225 = \u2225x\u2225)\n\nvariables {T : unitary_operator \u03b1 \u03b2}\n\n@[simp] lemma norm_preserving (x : \u03b1) : \u2225T.to_fun x\u2225 = \u2225x\u2225 :=\nby apply unitary_operator.norm_preserving\n\nlemma polarisation_identity (x y : \u03b1) : \u27eax \u2225 y\u27eb = 1/4*(\u2225x+y\u2225^2 - \u2225x-y\u2225^2) :=\nbegin\n    conv {to_lhs, rw [\u2190one_mul \u27eax \u2225 y\u27eb, \u2190@inv_mul_cancel _ _ (4 : \u211d) four_ne_zero]},\n    rw [\u2190one_div_eq_inv, mul_assoc],\n    apply congr_arg (\u03bb (r : \u211d), 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, \u2190neg_one_smul \u211d 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 : \u03b1) : \u27eaT.to_fun x \u2225 T.to_fun y\u27eb = \u27eax \u2225 y\u27eb :=\nbegin\n    rw [polarisation_identity (T.to_fun x) (T.to_fun y), \u2190linear_map.add, \n        sub_eq_add_neg (T.to_fun x) (T.to_fun y), \u2190neg_one_smul \u211d (T.to_fun y),\n        \u2190linear_map.smul, \u2190linear_map.add, norm_preserving, norm_preserving,\n        neg_one_smul, \u2190sub_eq_add_neg, \u2190polarisation_identity],\nend\n\nend hilbert_space\n\nopen set finsupp\n\nsection separable\n\n\n\n-- def coeff_sum (f : \u03b1 \u2192\u2080 \u211d) : finset.sum (finset.map (\u03bb (a : \u03b1), f a \u2022 a) f.support)\n\n\nlocal attribute [instance, priority 0] classical.prop_decidable\nnoncomputable theory\n\n-- def lc.total' {\u03b1 \u03b2} [discrete_field \u03b1] [add_comm_group \u03b2] [vector_space \u03b1 \u03b2] (f : \u03b2 \u2192\u2080 \u03b1) : \u03b2 := (lc.total _ _ _ id).1 f\n-- variables [Hilbert_space \u03b1]\n-- variables (sep : \u2203 (S : set \u03b1), countable S \u2227 \u2200 (x : \u03b1) (\u03b5 > 0), \u2203 (f : \u03b1 \u2192\u2080 \u211d), \u2225sum {z | \u2203 (e \u2208 S), z = f e \u2022 e} - x\u2225 < \u03b5)\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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u2964 W.localization` satisfies the universal property\nof the localization. Indeed, if `G : C \u2964 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 \u2964 D` such that `Q W \u226b 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 := \u03bb A B, (A.obj \u27f6 B.obj) \u2295 { f : B.obj \u27f6 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 \u03b9_paths (X : C) : paths (loc_quiver W) := \u27e8X\u27e9\n\n/-- The morphism in the path category associated to a morphism in the original category. -/\n@[simp]\ndef \u03c8\u2081 {X Y : C} (f : X \u27f6 Y) : \u03b9_paths W X \u27f6 \u03b9_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 \u03c8\u2082 {X Y : C} (w : X \u27f6 Y) (hw : W w) : \u03b9_paths W Y \u27f6 \u03b9_paths W X :=\npaths.of.map (sum.inr \u27e8w, hw\u27e9)\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 (\u03c8\u2081 W (\ud835\udfd9 X)) (\ud835\udfd9 _)\n| comp {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  relations (\u03c8\u2081 W (f \u226b g)) (\u03c8\u2081 W f \u226b \u03c8\u2081 W g)\n| Winv\u2081 {X Y : C} (w : X \u27f6 Y) (hw : W w) :\n  relations (\u03c8\u2081 W w \u226b \u03c8\u2082 W w hw) (\ud835\udfd9 _)\n| Winv\u2082 {X Y : C} (w : X \u27f6 Y) (hw : W w) :\n  relations (\u03c8\u2082 W w hw \u226b \u03c8\u2081 W w) (\ud835\udfd9 _)\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 \u2964 W.localization` -/\ndef Q : C \u2964 W.localization :=\n{ obj := \u03bb X, (quotient.functor _).obj (paths.of.obj \u27e8X\u27e9),\n  map := \u03bb X Y f, (quotient.functor _).map (\u03c8\u2081 W f),\n  map_id' := \u03bb X, quotient.sound _ (relations.id X),\n  map_comp' := \u03bb 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 \u27f6 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 \u27e8w, hw\u27e9)),\n  hom_inv_id' := quotient.sound _ (relations.Winv\u2081 w hw),\n  inv_hom_id' := quotient.sound _ (relations.Winv\u2082 w hw), }\n\n/-- The formal inverse in `W.localization` of a morphism `w` in `W`. -/\nabbreviation Winv {X Y : C} (w : X \u27f6 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\u03bb X Y w hw, is_iso.of_iso (localization.construction.Wiso w hw)\n\nvariables {W} (G : C \u2964 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) \u2964 D :=\nQuiv.lift\n{ obj := \u03bb X, G.obj X.obj,\n  map := \u03bb X Y, begin\n    rintro (f|\u27e8g, hg\u27e9),\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 \u2964 D` inverting `W` as a functor `W.localization \u2964 D` -/\n@[simps]\ndef lift : W.localization \u2964 D :=\nquotient.lift (relations W) (lift_to_path_category G hG)\nbegin\n  rintro \u27e8X\u27e9 \u27e8Y\u27e9 f\u2081 f\u2082 r,\n  rcases r,\n  tidy,\nend\n\n@[simp]\nlemma fac : W.Q \u22d9 lift G hG = G :=\nfunctor.ext (\u03bb 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 \u2243 W.localization :=\n{ to_fun := W.Q.obj,\n  inv_fun := \u03bb X, X.as.obj,\n  left_inv := \u03bb X, rfl,\n  right_inv := by { rintro \u27e8\u27e8X\u27e9\u27e9, 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\u2081 : \u2200 \u2983X Y : C\u2984 (f : X \u27f6 Y), P (W.Q.map f))\n  (hP\u2082 : \u2200 \u2983X Y : C\u2984 (w : X \u27f6 Y) (hw : W w), P (Winv w hw))\n  (hP\u2083 : P.stable_under_composition) : P = \u22a4 :=\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 : _ \u2964 W.localization := quotient.functor _,\n    suffices : \u2200 (X\u2081 X\u2082 : C) (p : localization.construction.\u03b9_paths W X\u2081 \u27f6\n      localization.construction.\u03b9_paths W X\u2082), P (G.map p),\n    { rcases X with \u27e8\u27e8X\u27e9\u27e9,\n      rcases Y with \u27e8\u27e8Y\u27e9\u27e9,\n      simpa only [functor.image_preimage] using this _ _ (G.preimage f), },\n    intros X\u2081 X\u2082 p,\n    induction p with X\u2082 X\u2083 p g hp,\n    { simpa only [functor.map_id] using hP\u2081 (\ud835\udfd9 X\u2081), },\n    { cases X\u2082,\n      cases X\u2083,\n      let p' : \u03b9_paths W X\u2081 \u27f6 \u03b9_paths W X\u2082 := p,\n      rw [show p.cons g = p' \u226b quiver.hom.to_path g, by refl, G.map_comp],\n      refine hP\u2083 _ _ hp _,\n      rcases g with (g | \u27e8g, hg\u27e9),\n      { apply hP\u2081, },\n      { apply hP\u2082, }, }, },\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\u2081 : \u2200 \u2983X Y : C\u2984 (f : X \u27f6 Y), P (W.Q.map f))\n  (hP\u2082 : \u2200 \u2983X Y : W.localization\u2984 (e : X \u2245 Y) (he : P e.hom), P e.inv)\n  (hP\u2083 : P.stable_under_composition) : P = \u22a4 :=\nmorphism_property_is_top P hP\u2081 (\u03bb X Y w hw, hP\u2082 _ (by exact hP\u2081 w)) hP\u2083\n\nnamespace nat_trans_extension\n\nvariables {F\u2081 F\u2082 : W.localization \u2964 D} (\u03c4 : W.Q \u22d9 F\u2081 \u27f6 W.Q \u22d9 F\u2082)\ninclude \u03c4\n\n/-- If `F\u2081` and `F\u2082` are functors `W.localization \u2964 D` and if we have\n`\u03c4 : W.Q \u22d9 F\u2081 \u27f6 W.Q \u22d9 F\u2082`, we shall define a natural transformation `F\u2081 \u27f6 F\u2082`.\nThis is the `app` field of this natural transformation. -/\ndef app (X : W.localization) : F\u2081.obj X \u27f6 F\u2082.obj X :=\neq_to_hom (congr_arg F\u2081.obj ((obj_equiv W).right_inv X).symm) \u226b\n    \u03c4.app ((obj_equiv W).inv_fun X) \u226b eq_to_hom (congr_arg F\u2082.obj ((obj_equiv W).right_inv X))\n\n@[simp]\nlemma app_eq (X : C) : (app \u03c4) (W.Q.obj X) = \u03c4.app X :=\nby simpa only [app, eq_to_hom_refl, comp_id, id_comp]\n\nend nat_trans_extension\n\n/-- If `F\u2081` and `F\u2082` are functors `W.localization \u2964 D`, a natural transformation `F\u2081 \u27f6 F\u2082`\ncan be obtained from a natural transformation `W.Q \u22d9 F\u2081 \u27f6 W.Q \u22d9 F\u2082`. -/\n@[simps]\ndef nat_trans_extension {F\u2081 F\u2082 : W.localization \u2964 D} (\u03c4 : W.Q \u22d9 F\u2081 \u27f6 W.Q \u22d9 F\u2082) :\n  F\u2081 \u27f6 F\u2082 :=\n{ app := nat_trans_extension.app \u03c4,\n  naturality' := \u03bb X Y f, begin\n    have h := morphism_property_is_top'\n      (morphism_property.naturality_property (nat_trans_extension.app \u03c4)) _\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 \u03c4.naturality f, },\n    have hf : (\u22a4 : morphism_property _) f := by simp only [pi.top_apply],\n    simpa only [\u2190 h] using hf,\n  end,  }\n\n@[simp]\nlemma nat_trans_extension_hcomp {F G : W.localization \u2964 D} (\u03c4 : W.Q \u22d9 F \u27f6 W.Q \u22d9 G) :\n  (\ud835\udfd9 W.Q) \u25eb nat_trans_extension \u03c4 = \u03c4 :=\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 \u2964 D} {\u03c4\u2081 \u03c4\u2082 : F \u27f6 G}\n  (h : \ud835\udfd9 W.Q \u25eb \u03c4\u2081 = \ud835\udfd9 W.Q \u25eb \u03c4\u2082) : \u03c4\u2081 = \u03c4\u2082 :=\nbegin\n  ext X,\n  have eq := (obj_equiv W).right_inv X,\n  simp only [obj_equiv] at eq,\n  rw [\u2190 eq, \u2190 nat_trans.id_hcomp_app, \u2190 nat_trans.id_hcomp_app, h],\nend\n\nvariables (W D)\n\nnamespace whiskering_left_equivalence\n\n/-- The functor `(W.localization \u2964 D) \u2964 (W.functors_inverting D)` induced by the\ncomposition with `W.Q : C \u2964 W.localization`. -/\n@[simps]\ndef functor : (W.localization \u2964 D) \u2964 (W.functors_inverting D) :=\nfull_subcategory.lift _ ((whiskering_left _ _ D).obj W.Q)\n  (\u03bb F, morphism_property.is_inverted_by.of_comp W W.Q W.Q_inverts _)\n\n/-- The function `(W.functors_inverting D) \u2964 (W.localization \u2964 D)` induced by\n`construction.lift`. -/\n@[simps]\ndef inverse : (W.functors_inverting D) \u2964 (W.localization \u2964 D) :=\n{ obj := \u03bb G, lift G.obj G.property,\n  map := \u03bb G\u2081 G\u2082 \u03c4, nat_trans_extension (eq_to_hom (by rw fac) \u226b \u03c4 \u226b eq_to_hom (by rw fac)),\n  map_id' := \u03bb 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' := \u03bb G\u2081 G\u2082 G\u2083 \u03c4\u2081 \u03c4\u2082, 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 : \ud835\udfed (W.localization \u2964 D) \u2245 functor W D \u22d9 inverse W D := eq_to_iso\nbegin\n  refine functor.ext (\u03bb G, _) (\u03bb G\u2081 G\u2082 \u03c4, _),\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 \u22d9 functor W D \u2245 \ud835\udfed (W.functors_inverting D) := eq_to_iso\nbegin\n  refine functor.ext _ _,\n  { rintro \u27e8G, hG\u27e9,\n    ext1,\n    apply fac, },\n  { rintros \u27e8G\u2081, hG\u2081\u27e9 \u27e8G\u2082, hG\u2082\u27e9 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 \u2964 D) \u224c (W.functors_inverting D)`\ninduced by the composition with `W.Q : C \u2964 W.localization`. -/\ndef whiskering_left_equivalence : (W.localization \u2964 D) \u224c 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' := \u03bb 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 \u211d) (H1 : \u2203 s : \u211d, s \u2208 S) (H2 : \u2203 b : \u211d, \u2200 s : \u211d, s \u2208 S \u2192 s \u2264 b) :\n  \u2203 x : \u211d, is_lub S x \u2227 \n  \u2200 T : set \u211d, (T \u2286 S \u2227 \u2203 t : \u211d, t \u2208 T) \u2192 \u2203 y : \u211d, is_lub T y \u2227 y \u2264 x :=\nbegin\ncases H1 with s\u2081 Hs\u2081,\ncases H2 with b Hb,\nhave Hlub := exists_supremum_real Hs\u2081 Hb,\ncases Hlub with x Hx,\nexistsi x,\nsplit,exact Hx,\nintros T HT,\nhave HT_bounded_above : \u2200 t : \u211d, t \u2208 T \u2192 t \u2264 b,\n{ intros t Ht,\n  apply Hb,\n  apply HT.left,\n  exact Ht,\n},\ncases HT.right with t\u2081 Ht\u2081,\nhave HlubT := exists_supremum_real Ht\u2081 HT_bounded_above,\ncases HlubT with y\u2081 Hy\u2081,\nexistsi y\u2081,\nsplit, exact Hy\u2081,\napply Hy\u2081.right,\nintro t\u2082,\nintro Ht\u2082,\napply Hx.left,\napply HT.left,\nexact Ht\u2082\nend\n\nnoncomputable def decimal_expansion' (x : \u211d) (H1 : x \u2265 0) (H2 : x < 1) : \u2115 \u2192 fin 10\n| 0 := \u27e80,dec_trivial\u27e9\n| (nat.succ m) := decimal_expansion' m \n-- crap I can't do yhis\n\n/-\nnoncomputable def decimal_expansion (x : \u211d) : \u2124 \u00d7 \u03a0 n : \u2115, 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 (\u03bb d, match d with\n| 0 := \u27e80,dec_trivial\u27e9\n| succ e := \u27e81,dec_trivial\u27e9\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 \u03b1 : Type u\n\n-- Two lemmas courtesy of Johannes H\u00f6lzl via gitter, due to be added to mathlib\nlemma infinite_univ_nat : infinite (univ : set \u2115) :=\n assume (h : finite (univ : set \u2115)),\n let \u27e8n, hn\u27e9 := finset.exists_nat_subset_range h.to_finset in\n have n \u2208 finset.range n, from finset.subset_iff.mpr hn $ by simp,\n by simp * at *\n\nlemma not_injective_nat_fintype [fintype \u03b1] [decidable_eq \u03b1] {f : \u2115 \u2192 \u03b1} : \u00ac injective f :=\n assume (h : injective f),\n have finite (f '' univ),\n   from finite_subset (finset.finite_to_set $ fintype.elems \u03b1) (assume a h, fintype.complete a),\n have finite (univ : set \u2115), from finite_of_finite_image h this,\n infinite_univ_nat this\n\nend set\n\n\nnoncomputable instance subtype.fintype_le_nat (n : \u2115) : fintype {i : \u2115 // i \u2264 n} :=\n  classical.choice $ set.finite_le_nat n\n\ntheorem sheet_7_2e (f : \u2115 \u2192 \u2115) (d) : d > 0 \u2192 \u2203 a b, a \u2260 b \u2227 f a \u2261 f b [MOD d]:=begin\n  assume hd,\n  unfold modeq,\n  apply by_contradiction,\n  assume h,\n  let f' : \u2115 \u2192 {i // i \u2264 d} := \u03bb n, \u27e8f n % d, le_of_lt (mod_lt (f n) hd)\u27e9,\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 \u2264 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  (\u2200(s: S), \u2200(P: S \u2192 Prop), P s) \u2194 \n    (\u2200(P: S \u2192 Prop), \u2200(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  (\u2200(s: S), \u2200(P: S \u2192 Prop), P s) \u2194 \n    (\u2200(P': S \u2192 Prop), \u2200(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   (\u2200(p: P), Q) \u2194 (P \u2192 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\nopen function\n\nlemma surjective_comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2}\n  (hg : surjective g) (hf : surjective f) :\nsurjective (g \u2218 f) := (\n  assume c: \u03b3,\n  let \u27e8b, (hgb: g b = c)\u27e9 := hg c in\n  let \u27e8a, (hfa: f a = b)\u27e9 := hf b in\n  have hc: (g \u2218 f) a = c, by rsimp,\n  \u27e8a, hc\u27e9\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": "import Quiz9\nimport Sets.Basic\nimport Lean.Elab.Print\nimport Lean.Elab.Command\n\nopen Set \n\nvariable {\u03b1 : Type}\nvariable (X Y : Set \u03b1)\n\ntheorem desiredType1 : X \u2229 X\u1d9c = \u2205 := sorry \n\ntheorem desiredType2 : X \u222a X\u1d9c = Univ := sorry \n\ntheorem desiredTyep3 : X\u1d9c \u222a X = Univ := sorry \n\nopen Lean\nopen Lean.Meta\nopen Lean.Elab.Command\n\ndef n : String := \"2\"\n\ndef problem : String := \"problem\"++n\n\ndef desired : String := \"desiredType\"++n\n\ndef collectAxiomsOf (constName : Name) : MetaM (List String) := do\n  let env \u2190 getEnv\n  let (_, s) := ((CollectAxioms.collect constName).run env).run {}\n  let a := s.axioms.toList.map toString\n  return a\n\n#eval isDefEq (Expr.const desired []) (Expr.const problem [])\n#eval collectAxiomsOf problem\n", "meta": {"author": "UofSC-Fall-2022-Math-300-H01", "repo": "quiz9", "sha": "95d0b3fdfbb0190af5e011d7213a55a35fc079ee", "save_path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-quiz9", "path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-quiz9/quiz9-95d0b3fdfbb0190af5e011d7213a55a35fc079ee/_Tests/Problem2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128673178375734, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4969724248058595}}
{"text": "/-\nCopyright (c) 2022 Ya\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u2264 b` implies the existence of\n  `a'` such that `a \u2264 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 \u03b1 \u03b2 \u03b3 \u03b4 : Type*}\n\n/-- The type of pseudo-epimorphisms, aka p-morphisms, aka bounded maps, from `\u03b1` to `\u03b2`. -/\nstructure pseudo_epimorphism (\u03b1 \u03b2 : Type*) [preorder \u03b1] [preorder \u03b2] extends \u03b1 \u2192o \u03b2 :=\n(exists_map_eq_of_map_le' \u2983a : \u03b1\u2984 \u2983b : \u03b2\u2984 : to_fun a \u2264 b \u2192 \u2203 c, a \u2264 c \u2227 to_fun c = b)\n\n/-- The type of Esakia morphisms, aka continuous pseudo-epimorphisms, from `\u03b1` to `\u03b2`. -/\nstructure esakia_hom (\u03b1 \u03b2 : Type*) [topological_space \u03b1] [preorder \u03b1] [topological_space \u03b2]\n  [preorder \u03b2] extends \u03b1 \u2192Co \u03b2 :=\n(exists_map_eq_of_map_le' \u2983a : \u03b1\u2984 \u2983b : \u03b2\u2984 : to_fun a \u2264 b \u2192 \u2203 c, a \u2264 c \u2227 to_fun c = b)\n\nsection\nset_option old_structure_cmd true\n\n/-- `pseudo_epimorphism_class F \u03b1 \u03b2` states that `F` is a type of `\u2294`-preserving morphisms.\n\nYou should extend this class when you extend `pseudo_epimorphism`. -/\nclass pseudo_epimorphism_class (F : Type*) (\u03b1 \u03b2 : out_param $ Type*) [preorder \u03b1] [preorder \u03b2]\n  extends rel_hom_class F ((\u2264) : \u03b1 \u2192 \u03b1 \u2192 Prop) ((\u2264) : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n(exists_map_eq_of_map_le (f : F) \u2983a : \u03b1\u2984 \u2983b : \u03b2\u2984 : f a \u2264 b \u2192 \u2203 c, a \u2264 c \u2227 f c = b)\n\n/-- `esakia_hom_class F \u03b1 \u03b2` 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*) (\u03b1 \u03b2 : out_param $ Type*) [topological_space \u03b1] [preorder \u03b1]\n  [topological_space \u03b2] [preorder \u03b2]\n  extends continuous_order_hom_class F \u03b1 \u03b2 :=\n(exists_map_eq_of_map_le (f : F) \u2983a : \u03b1\u2984 \u2983b : \u03b2\u2984 : f a \u2264 b \u2192 \u2203 c, a \u2264 c \u2227 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 \u03b1] [order_top \u03b1] [preorder \u03b2]\n  [order_top \u03b2] [pseudo_epimorphism_class F \u03b1 \u03b2] : top_hom_class F \u03b1 \u03b2 :=\n{ map_top := \u03bb f, let \u27e8b, h\u27e9 := exists_map_eq_of_map_le f (@le_top _ _ _ $ f \u22a4) in\n                  by rw [\u2190top_le_iff.1 h.1, h.2]\n  .. \u2039pseudo_epimorphism_class F \u03b1 \u03b2\u203a }\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_pseudo_epimorphism_class [preorder \u03b1] [preorder \u03b2]\n  [order_iso_class F \u03b1 \u03b2] : pseudo_epimorphism_class F \u03b1 \u03b2 :=\n{ exists_map_eq_of_map_le :=\n      \u03bb f a b h, \u27e8equiv_like.inv f b, (le_map_inv_iff f).2 h, equiv_like.right_inv _ _\u27e9,\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 \u03b1] [preorder \u03b1]\n  [topological_space \u03b2] [preorder \u03b2] [esakia_hom_class F \u03b1 \u03b2] : pseudo_epimorphism_class F \u03b1 \u03b2 :=\n{ .. \u2039esakia_hom_class F \u03b1 \u03b2\u203a }\n\ninstance [preorder \u03b1] [preorder \u03b2] [pseudo_epimorphism_class F \u03b1 \u03b2] :\n  has_coe_t F (pseudo_epimorphism \u03b1 \u03b2) :=\n\u27e8\u03bb f, \u27e8f, exists_map_eq_of_map_le f\u27e9\u27e9\n\ninstance [topological_space \u03b1] [preorder \u03b1] [topological_space \u03b2] [preorder \u03b2]\n  [esakia_hom_class F \u03b1 \u03b2] : has_coe_t F (esakia_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f, \u27e8f, exists_map_eq_of_map_le f\u27e9\u27e9\n\n/-! ### Pseudo-epimorphisms -/\n\nnamespace pseudo_epimorphism\nvariables [preorder \u03b1] [preorder \u03b2] [preorder \u03b3] [preorder \u03b4]\n\ninstance : pseudo_epimorphism_class (pseudo_epimorphism \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := \u03bb f, f.to_fun,\n  coe_injective' := \u03bb f g h, by { obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := f, obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := g, congr' },\n  map_rel := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : pseudo_epimorphism \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n@[ext] lemma ext {f g : pseudo_epimorphism \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) :\n  pseudo_epimorphism \u03b1 \u03b2 :=\n\u27e8f.to_order_hom.copy f' h, by simpa only [h.symm, to_fun_eq_coe] using f.exists_map_eq_of_map_le'\u27e9\n\n@[simp] lemma coe_copy (f : pseudo_epimorphism \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) :\n  \u21d1(f.copy f' h) = f' :=\nrfl\n\nlemma copy_eq (f : pseudo_epimorphism \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) :\n  f.copy f' h = f :=\nfun_like.ext' h\n\nvariables (\u03b1)\n\n/-- `id` as a `pseudo_epimorphism`. -/\nprotected def id : pseudo_epimorphism \u03b1 \u03b1 := \u27e8order_hom.id, \u03bb a b h, \u27e8b, h, rfl\u27e9\u27e9\n\ninstance : inhabited (pseudo_epimorphism \u03b1 \u03b1) := \u27e8pseudo_epimorphism.id \u03b1\u27e9\n\n@[simp] lemma coe_id : \u21d1(pseudo_epimorphism.id \u03b1) = id := rfl\n@[simp] lemma coe_id_order_hom : (pseudo_epimorphism.id \u03b1 : \u03b1 \u2192o \u03b1) = order_hom.id := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : pseudo_epimorphism.id \u03b1 a = a := rfl\n\n/-- Composition of `pseudo_epimorphism`s as a `pseudo_epimorphism`. -/\ndef comp (g : pseudo_epimorphism \u03b2 \u03b3) (f : pseudo_epimorphism \u03b1 \u03b2) : pseudo_epimorphism \u03b1 \u03b3 :=\n\u27e8g.to_order_hom.comp f.to_order_hom, \u03bb a b h\u2080, begin\n  obtain \u27e8b, h\u2081, rfl\u27e9 := g.exists_map_eq_of_map_le' h\u2080,\n  obtain \u27e8b, h\u2082, rfl\u27e9 := f.exists_map_eq_of_map_le' h\u2081,\n  exact \u27e8b, h\u2082, rfl\u27e9,\nend\u27e9\n\n@[simp] lemma coe_comp (g : pseudo_epimorphism \u03b2 \u03b3) (f : pseudo_epimorphism \u03b1 \u03b2) :\n  (g.comp f : \u03b1 \u2192 \u03b3) = g \u2218 f := rfl\n@[simp] lemma coe_comp_order_hom (g : pseudo_epimorphism \u03b2 \u03b3) (f : pseudo_epimorphism \u03b1 \u03b2) :\n  (g.comp f : \u03b1 \u2192o \u03b3) = (g : \u03b2 \u2192o \u03b3).comp f := rfl\n@[simp] lemma comp_apply (g : pseudo_epimorphism \u03b2 \u03b3) (f : pseudo_epimorphism \u03b1 \u03b2) (a : \u03b1) :\n  (g.comp f) a = g (f a) := rfl\n@[simp] lemma comp_assoc (h : pseudo_epimorphism \u03b3 \u03b4) (g : pseudo_epimorphism \u03b2 \u03b3)\n  (f : pseudo_epimorphism \u03b1 \u03b2) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[simp] \n\nlemma cancel_right {g\u2081 g\u2082 : pseudo_epimorphism \u03b2 \u03b3} {f : pseudo_epimorphism \u03b1 \u03b2}\n  (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : pseudo_epimorphism \u03b2 \u03b3} {f\u2081 f\u2082 : pseudo_epimorphism \u03b1 \u03b2} (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, ext $ \u03bb a, hg $ by rw [\u2190comp_apply, h, comp_apply], congr_arg _\u27e9\n\nend pseudo_epimorphism\n\n/-! ### Esakia morphisms -/\n\nnamespace esakia_hom\nvariables [topological_space \u03b1] [preorder \u03b1] [topological_space \u03b2] [preorder \u03b2]\n  [topological_space \u03b3] [preorder \u03b3] [topological_space \u03b4] [preorder \u03b4]\n\n/-- Reinterpret an `esakia_hom` as a `pseudo_epimorphism`. -/\ndef to_pseudo_epimorphism (f : esakia_hom \u03b1 \u03b2) : pseudo_epimorphism \u03b1 \u03b2 := { ..f }\n\ninstance : esakia_hom_class (esakia_hom \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := \u03bb f, f.to_fun,\n  coe_injective' := \u03bb f g h,\n    by { obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := f, obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := g, congr' },\n  map_rel := \u03bb f, f.monotone',\n  map_continuous := \u03bb f, f.continuous_to_fun,\n  exists_map_eq_of_map_le := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : esakia_hom \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n@[ext] lemma ext {f g : esakia_hom \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : esakia_hom \u03b1 \u03b2 :=\n\u27e8f.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'\u27e9\n\n@[simp] lemma coe_copy (f : esakia_hom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(f.copy f' h) = f' := rfl\nlemma copy_eq (f : esakia_hom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : f.copy f' h = f := fun_like.ext' h\n\nvariables (\u03b1)\n\n/-- `id` as an `esakia_hom`. -/\nprotected def id : esakia_hom \u03b1 \u03b1 := \u27e8continuous_order_hom.id \u03b1, \u03bb a b h, \u27e8b, h, rfl\u27e9\u27e9\n\ninstance : inhabited (esakia_hom \u03b1 \u03b1) := \u27e8esakia_hom.id \u03b1\u27e9\n\n@[simp] lemma coe_id : \u21d1(esakia_hom.id \u03b1) = id := rfl\n@[simp] lemma coe_id_continuous_order_hom :\n  (esakia_hom.id \u03b1 : \u03b1 \u2192Co \u03b1) = continuous_order_hom.id \u03b1 := rfl\n@[simp] lemma coe_id_pseudo_epimorphism :\n  (esakia_hom.id \u03b1 : pseudo_epimorphism \u03b1 \u03b1) = pseudo_epimorphism.id \u03b1  := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : esakia_hom.id \u03b1 a = a := rfl\n\n/-- Composition of `esakia_hom`s as an `esakia_hom`. -/\ndef comp (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) : esakia_hom \u03b1 \u03b3 :=\n\u27e8g.to_continuous_order_hom.comp f.to_continuous_order_hom, \u03bb a b h\u2080, begin\n  obtain \u27e8b, h\u2081, rfl\u27e9 := g.exists_map_eq_of_map_le' h\u2080,\n  obtain \u27e8b, h\u2082, rfl\u27e9 := f.exists_map_eq_of_map_le' h\u2081,\n  exact \u27e8b, h\u2082, rfl\u27e9,\nend\u27e9\n\n@[simp] lemma coe_comp (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) : (g.comp f : \u03b1 \u2192 \u03b3) = g \u2218 f := rfl\n@[simp] lemma comp_apply (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) (a : \u03b1) :\n  (g.comp f) a = g (f a) := rfl\n@[simp] lemma coe_comp_continuous_order_hom (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) :\n  (g.comp f : \u03b1 \u2192Co \u03b3) = (g : \u03b2 \u2192Co \u03b3).comp f := rfl\n@[simp] lemma coe_comp_pseudo_epimorphism (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) :\n  (g.comp f : pseudo_epimorphism \u03b1 \u03b3) = (g : pseudo_epimorphism \u03b2 \u03b3).comp f := rfl\n@[simp] lemma comp_assoc (h : esakia_hom \u03b3 \u03b4) (g : esakia_hom \u03b2 \u03b3) (f : esakia_hom \u03b1 \u03b2) :\n  (h.comp g).comp f = h.comp (g.comp f) := rfl\n@[simp] lemma comp_id (f : esakia_hom \u03b1 \u03b2) : f.comp (esakia_hom.id \u03b1) = f := ext $ \u03bb a, rfl\n@[simp] lemma id_comp (f : esakia_hom \u03b1 \u03b2) : (esakia_hom.id \u03b2).comp f = f := ext $ \u03bb a, rfl\n\nlemma cancel_right {g\u2081 g\u2082 : esakia_hom \u03b2 \u03b3} {f : esakia_hom \u03b1 \u03b2} (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : esakia_hom \u03b2 \u03b3} {f\u2081 f\u2082 : esakia_hom \u03b1 \u03b2} (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, ext $ \u03bb a, hg $ by rw [\u2190comp_apply, h, comp_apply], congr_arg _\u27e9\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\u2081 := Module.of R R,\n  X\u2082 := Module.of R R,\n  X\u2083 := Module.of R (R \u29f8(ideal.span {x} : ideal R)),\n  f := x \u2022 \ud835\udfd9 _,\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 \u27e81, by simp\u27e9,\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 \u27e8a\u27e9,\n  exact \u27e8a, rfl\u27e9,\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 \u27e8b, hb\u27e9 := ha,\n  exact \u27e8b, by { dsimp, rw [\u2190 hb, mul_comm], }\u27e9,\nend\n\nlemma mono_f (hx : x \u2208 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 \u2208 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 \u2208 non_zero_divisors R)\n\ndef extension_of_non_zero_divisor (hx : x \u2208 non_zero_divisors R) :\n  extension (Module.of R (R \u29f8(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 \u2245 extension.trivial _ _) \u2194\n    is_unit x :=\nbegin\n  split,\n  { rintro \u27e8e\u27e9,\n    rw is_unit_iff_exists_inv,\n    obtain \u27e8s, hs\u27e9 := (extension.iso_trivial_equiv _).symm.surjective e,\n    refine \u27e8s.r (1 : R),_\u27e9,\n    let \u03c6 : ((of R R) \u27f6 (of R R)) \u2192 R := \u03bb \u03c6, \u03c6 (1 : R),\n    have eq := congr_arg \u03c6 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\u2083,\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 \u27e8\u215fx, by simp only [inv_of_mul_self]\u27e9, },\n    exact\n    { r := \u215fx \u2022 \ud835\udfd9 _,\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 \u03b4_neq_zero  : (extension_of_non_zero_divisor x hx).\u03b4 \u2260 0 \u2194 \u00acis_unit x :=\nby simp only [extension.\u03b4_neq_zero_iff, \u2190 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 : \u2124) (hn : 2 \u2264 n) :\n  n \u2208 non_zero_divisors \u2124 :=\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 \u2964 Group.{max v u}) (j) :\n  group ((F \u22d9 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 \u2964 Group) :\n  subgroup (\u03a0 j, F.obj j) :=\n{ carrier := (F \u22d9 forget Group).sections,\n  inv_mem' := \u03bb 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 \u22d9 forget\u2082 Group Mon)) }\n\n@[to_additive]\ninstance limit_group (F : J \u2964 Group.{max v u}) :\n  group (types.limit_cone (F \u22d9 forget Group)).X :=\nbegin\n  change group (sections_subgroup F),\n  apply_instance,\nend\n\n/-- We show that the forgetful functor `Group \u2964 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 \u2964 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\u2082.creates_limit (F : J \u2964 Group.{max v u}) :\n  creates_limit F (forget\u2082 Group.{max v u} Mon.{max v u}) :=\ncreates_limit_of_reflects_iso (\u03bb c' t,\n{ lifted_cone :=\n  { X := Group.of (types.limit_cone (F \u22d9 forget Group)).X,\n    \u03c0 :=\n    { app := Mon.limit_\u03c0_monoid_hom (F \u22d9 forget\u2082 Group Mon.{max v u}),\n      naturality' :=\n        (Mon.has_limits.limit_cone (F \u22d9 forget\u2082 Group Mon.{max v u})).\u03c0.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\u2082 Group Mon.{max v u})\n    (Mon.has_limits.limit_cone_is_limit _) (\u03bb s, _) (\u03bb 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 \u2964 Group.{max v u}) : cone F :=\nlift_limit (limit.is_limit (F \u22d9 (forget\u2082 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 \u2964 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 := \u03bb J \ud835\udca5, by exactI\n  { has_limit := \u03bb F, has_limit_of_created F (forget\u2082 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\u2082_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\u2082_Mon_preserves_limits_of_size :\n  preserves_limits_of_size.{v v} (forget\u2082 Group Mon.{max v u}) :=\n{ preserves_limits_of_shape := \u03bb J \ud835\udca5,\n  { preserves_limit := \u03bb F, by apply_instance } }\n\n@[to_additive]\ninstance forget\u2082_Mon_preserves_limits : preserves_limits (forget\u2082 Group Mon.{u}) :=\nGroup.forget\u2082_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 := \u03bb J \ud835\udca5, by exactI\n  { preserves_limit := \u03bb F, limits.comp_preserves_limit (forget\u2082 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 \u2964 CommGroup.{max v u}) (j) :\n  comm_group ((F \u22d9 forget CommGroup).obj j) :=\nby { change comm_group (F.obj j), apply_instance }\n\n@[to_additive]\ninstance limit_comm_group (F : J \u2964 CommGroup.{max v u}) :\n  comm_group (types.limit_cone (F \u22d9 forget CommGroup.{max v u})).X :=\n@subgroup.to_comm_group (\u03a0 j, F.obj j) _\n  (Group.sections_subgroup (F \u22d9 forget\u2082 CommGroup Group.{max v u}))\n\n/--\nWe show that the forgetful functor `CommGroup \u2964 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 \u2964 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\u2082.creates_limit (F : J \u2964 CommGroup.{max v u}) :\n  creates_limit F (forget\u2082 CommGroup Group.{max v u}) :=\ncreates_limit_of_reflects_iso (\u03bb c' t,\n{ lifted_cone :=\n  { X := CommGroup.of (types.limit_cone (F \u22d9 forget CommGroup)).X,\n    \u03c0 :=\n    { app := Mon.limit_\u03c0_monoid_hom\n        (F \u22d9 forget\u2082 CommGroup Group.{max v u} \u22d9 forget\u2082 Group Mon.{max v u}),\n      naturality' := (Mon.has_limits.limit_cone _).\u03c0.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\u2082 _ Group.{max v u} \u22d9 forget\u2082 _ Mon.{max v u})\n    (by apply Mon.has_limits.limit_cone_is_limit _) (\u03bb s, _) (\u03bb 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 \u2964 CommGroup.{max v u}) : cone F :=\nlift_limit (limit.is_limit (F \u22d9 (forget\u2082 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 \u2964 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 := \u03bb J \ud835\udca5, by exactI\n  { has_limit := \u03bb F, has_limit_of_created F (forget\u2082 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\u2082_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\u2082_Group_preserves_limits_of_size :\n  preserves_limits_of_size.{v v} (forget\u2082 CommGroup Group.{max v u}) :=\n{ preserves_limits_of_shape := \u03bb J \ud835\udca5,\n  { preserves_limit := \u03bb F, by apply_instance } }\n\n@[to_additive]\ninstance forget\u2082_Group_preserves_limits : preserves_limits (forget\u2082 CommGroup Group.{u}) :=\nCommGroup.forget\u2082_Group_preserves_limits_of_size.{u u}\n\n/--\nAn auxiliary declaration to speed up typechecking.\n-/\n@[to_additive AddCommGroup.forget\u2082_AddCommMon_preserves_limits_aux\n  \"An auxiliary declaration to speed up typechecking.\"]\ndef forget\u2082_CommMon_preserves_limits_aux (F : J \u2964 CommGroup.{max v u}) :\n  is_limit ((forget\u2082 CommGroup CommMon).map_cone (limit_cone F)) :=\nCommMon.limit_cone_is_limit (F \u22d9 forget\u2082 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\u2082_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\u2082_CommMon_preserves_limits_of_size :\n  preserves_limits_of_size.{v v} (forget\u2082 CommGroup CommMon.{max v u}) :=\n{ preserves_limits_of_shape := \u03bb J \ud835\udca5, by exactI\n  { preserves_limit := \u03bb F, preserves_limit_of_preserves_limit_cone\n    (limit_cone_is_limit F) (forget\u2082_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 := \u03bb J \ud835\udca5, by exactI\n  { preserves_limit := \u03bb F, limits.comp_preserves_limit (forget\u2082 CommGroup Group) (forget Group) } }\n\n-- Verify we can form limits indexed over smaller categories.\nexample (f : \u2115 \u2192 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 \u27f6 H) :\n  kernel f \u2245 AddCommGroup.of f.ker :=\n{ hom :=\n  { to_fun := \u03bb g, \u27e8kernel.\u03b9 f g,\n    begin\n      -- TODO where is this `has_coe_t_aux.coe` coming from? can we prevent it appearing?\n      change (kernel.\u03b9 f) g \u2208 f.ker,\n      simp [add_monoid_hom.mem_ker],\n    end\u27e9,\n    map_zero' := by { ext, simp, },\n    map_add' := \u03bb 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 \u27e8x, mem\u27e9,\n    simp,\n  end, }.\n\n@[simp]\nlemma kernel_iso_ker_hom_comp_subtype {G H : AddCommGroup} (f : G \u27f6 H) :\n  (kernel_iso_ker f).hom \u226b add_subgroup.subtype f.ker = kernel.\u03b9 f :=\nby ext; refl\n\n@[simp]\nlemma kernel_iso_ker_inv_comp_\u03b9 {G H : AddCommGroup} (f : G \u27f6 H) :\n  (kernel_iso_ker f).inv \u226b kernel.\u03b9 f = add_subgroup.subtype f.ker :=\nbegin\n  ext,\n  simp [kernel_iso_ker],\nend\n\n/--\nThe categorical kernel inclusion for `f : G \u27f6 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 \u27f6 H) :\n  over.mk (kernel.\u03b9 f) \u2245 @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 \u2192 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\u2081 ai\u2082 : M} (e\u2081 : a * ai\u2081 = 1) (e\u2082 : a * ai\u2082 = 1) : ai\u2081 = ai\u2082 :=\nby rw [\u2190 mul_one ai\u2081, \u2190 e\u2082, \u2190 mul_assoc, mul_comm ai\u2081, e\u2081, 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 \u25b8 J.zero,\n  add := H.symm \u25b8 J.add,\n  smul := H.symm \u25b8 J.smul }\n\ndef ker : ideal A :=\nideal.mk {x | f x = 0} (ideal.comap f \u22a5) $\nset.ext $ \u03bb x, submodule.mem_bot.symm\n\ndef inverts_data (S : set A) (f : A \u2192 B) : Type* :=\n\u03a0 s : S, {si : B // (f s) * si = 1}\n\ndef inverts (S : set A) (f : A \u2192 B) : Prop := \n\u2200 s : S, \u2203 si : B, (f s) * si = 1\n\nlemma inverts_subsingleton (S : set A) (f : A \u2192 B) :\n  subsingleton (inverts_data S f) :=\n\u27e8\u03bb fi1 fi2, funext $ \u03bb s, subtype.eq $ comm_monoid.inv_unique (fi1 s).2 (fi2 s).2\u27e9\n\ndef inverts_of_data (h : inverts_data S f) : inverts S f :=\n\u03bb s, \u27e8(h s).1,(h s).2\u27e9\n\nnoncomputable def inverts_some (h : inverts S f) : inverts_data S f :=\n\u03bb s, classical.indefinite_description _ (h s)\n\ndef has_denom_data (S : set A) (f : A \u2192 B) :=\n\u03a0 b : B, {sa : S \u00d7 A // (f sa.1) * b = f sa.2 }\n\ndef has_denom (S : set A) (f : A \u2192 B) : Prop :=\n\u2200 b : B, \u2203 (sa : S \u00d7 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\u03bb b, subtype.exists_of_subtype (h b)\n\nnoncomputable def has_denom_some (h : has_denom S f) : has_denom_data S f := \n\u03bb b, classical.indefinite_description _ (h b)\n\ndef ann_aux (S : set A) [is_submonoid S] : Type* :=\n{ as : A \u00d7 S // as.1 * as.2 = 0 }\n\nnamespace ann_aux\n\ndef zero : ann_aux S := \u27e8(0, 1), mul_one _\u27e9\n\ndef add (as bt : ann_aux S) : ann_aux S :=\n\u27e8(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, \u2190 mul_assoc, as.2, zero_mul, zero_add, mul_left_comm, bt.2, mul_zero]\u27e9\n\ndef smul (a : A) (bt : ann_aux S) : ann_aux S :=\n\u27e8(a * bt.1.1, bt.1.2), show (a * bt.1.1) * bt.1.2 = 0, by rw [mul_assoc, bt.2, mul_zero]\u27e9\n\nend ann_aux\n\ndef submonoid_ann (S : set A) [is_submonoid S] : ideal A :=\n{ carrier := set.range (\u03bb as : ann_aux S, as.1.1),\n  zero := \u27e8ann_aux.zero S, rfl\u27e9,\n  add := \u03bb _ _ \u27e8as,has\u27e9 \u27e8bt,hbt\u27e9, \u27e8ann_aux.add S as bt, has \u25b8 hbt \u25b8 rfl\u27e9,\n  smul := \u03bb a _ \u27e8bt,h\u27e9, \u27e8ann_aux.smul S a bt, h \u25b8 rfl\u27e9 }\n\nlemma inverts_ker (hf : inverts S f) : submonoid_ann S \u2264 ker f :=\n\u03bb x \u27e8\u27e8\u27e8a,s\u27e9,asz\u27e9,rfl\u27e9, let \u27e8si,e1\u27e9 := hf s in show f x = 0,\nby rw [\u2190 mul_one (f x), \u2190 e1, \u2190 mul_assoc, \u2190 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 \u2264 submonoid_ann S)\n\ndef is_localization : Prop :=\n(inverts S f) \u2227 (has_denom S f) \u2227 (ker f = submonoid_ann S)\n\nlemma localization_epi (hf : is_localization S f)\n  (g\u2081 g\u2082 : B \u2192 C) [is_ring_hom g\u2081] [is_ring_hom g\u2082] \n  (e : g\u2081 \u2218 f = g\u2082 \u2218 f) : g\u2081 = g\u2082 := \nbegin\n  have e' : \u2200 x, g\u2081 (f x) = g\u2082 (f x) := \u03bb x, by convert congr_fun e x,\n  ext b,\n  rcases hf.2.1 b with \u27e8\u27e8s,a\u27e9,e1\u27e9,\n  rcases hf.1 s with \u27e8si,e2\u27e9,\n  have e4 : g\u2081 (f s) * (g\u2081 si) = 1,\n  { rw [\u2190 is_ring_hom.map_mul g\u2081, e2, is_ring_hom.map_one g\u2081] },\n  have e5 : g\u2081 (f s) * (g\u2082 si) = 1,\n  { rw [e', \u2190 is_ring_hom.map_mul g\u2082, e2, is_ring_hom.map_one g\u2082] },\n  rw [\u2190 mul_one b, \u2190 e2, mul_left_comm, \u2190 mul_assoc, e1],\n  rw [is_ring_hom.map_mul g\u2081, is_ring_hom.map_mul g\u2082, e', comm_monoid.inv_unique e4 e5]\nend\n\nsection localization_initial \nvariables (hf : is_localization_data S f) (g : A \u2192 C) [is_ring_hom g] (hg : inverts_data S g)\n\ndef is_localization_initial (hf : is_localization_data S f)\n  (g : A \u2192 C) [is_ring_hom g] (hg : inverts_data S g) : B \u2192 C :=\n\u03bb 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 \u2192 C) [is_ring_hom g] (hg : inverts_data S g)\n  {a\u2081 a\u2082 : A} (H : f a\u2081 = f a\u2082) : g a\u2081 = g a\u2082 :=\nbegin\n  rw [\u2190 sub_eq_zero, \u2190 is_ring_hom.map_sub f] at H,\n  rw [\u2190 sub_eq_zero, \u2190 is_ring_hom.map_sub g],\n  generalize_hyp : a\u2081 - a\u2082 = a at H \u22a2,\n  rcases hf.3 H with \u27e8\u27e8as,h1\u27e9,h2\u27e9,\n  rw [\u2190 h2],\n  cases hg as.2 with c h3,\n  rw [\u2190 mul_one (g as.1), \u2190 h3, \u2190 mul_assoc, \u2190 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 \u2194 z = w :=\n\u27e8\u03bb H, have _ := congr_arg (* y) H, by rwa [mul_assoc, h, mul_one, mul_assoc, h, mul_one] at this,\n\u03bb H, by rw H\u27e9\n\ninstance (hf : is_localization_data S f) (g : A \u2192 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 \u27e8\u27e8s,a\u27e9,h\u27e9,\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 \u2190 h, exact hc\n  end,\n  map_mul := \u03bb x y, begin\n    unfold is_localization_initial,\n    rcases hf.has_denom x with \u27e8\u27e8sx,ax\u27e9,h1\u27e9,\n    rcases hf.has_denom y with \u27e8\u27e8sy,ay\u27e9,h2\u27e9,\n    rcases hf.has_denom (x*y) with \u27e8\u27e8sxy,axy\u27e9,h3\u27e9,\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 [\u2190 useful2 h4, \u2190 useful2 h5, \u2190 useful2 h6],\n    have : g axy * sigxy * g \u2191sx * g \u2191sy * g \u2191sxy = g axy * g \u2191sx * g \u2191sy * (g \u2191sxy * 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 \u2191sx * g \u2191sy * g \u2191sxy = g ax * g ay * g \u2191sxy * (g \u2191sx * sigx) * (g \u2191sy * 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 \u2190 is_ring_hom.map_mul g }, apply useful S f hf g hg,\n    iterate 4 { rw is_ring_hom.map_mul f }, rw \u2190 h3,\n    have : f \u2191sxy * (f ax * sifx * (f ay * sify)) * f \u2191sx * f \u2191sy = f ax * f ay * f \u2191sxy * (f \u2191sx * sifx) * (f \u2191sy * sify),\n    { simp only [mul_assoc, mul_comm, mul_left_comm] }, rw [this, h7, h8, mul_one, mul_one]\n  end,\n  map_add := \u03bb x y, begin\n    unfold is_localization_initial,\n    rcases hf.has_denom x with \u27e8\u27e8sx,ax\u27e9,h1\u27e9,\n    rcases hf.has_denom y with \u27e8\u27e8sy,ay\u27e9,h2\u27e9,\n    rcases hf.has_denom (x+y) with \u27e8\u27e8sxy,axy\u27e9,h3\u27e9,\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 [\u2190 useful2 h4, \u2190 useful2 h5, \u2190 useful2 h6],\n    have : g axy * sigxy * g \u2191sx * g \u2191sy * g \u2191sxy = g axy * g \u2191sx * g \u2191sy * (g \u2191sxy * 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 \u2191sx * g \u2191sy * g \u2191sxy =\n      g ax * g \u2191sy * g \u2191sxy * (g \u2191sx * sigx) + g ay * g \u2191sx * g \u2191sxy * (g \u2191sy * 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 \u2190 is_ring_hom.map_mul g }, rw \u2190 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 \u2190 h3,\n    have : f \u2191sxy * (f ax * sifx + f ay * sify) * f \u2191sx * f \u2191sy =\n      f ax * f \u2191sy * f \u2191sxy * (f \u2191sx * sifx) + f ay * f \u2191sx * f \u2191sxy * (f \u2191sy * 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 \u2192 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 \u27e8\u27e8s,x\u27e9,h1\u27e9,\n  cases hg s with si h2,\n  dsimp only [subtype.coe_mk] at *,\n  rw [\u2190 useful2 h2, mul_right_comm, mul_assoc, h2, mul_one, \u2190 is_ring_hom.map_mul g],\n  apply useful S f hf g hg,\n  rw [\u2190 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} {\u0393\u2080 : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero \u0393\u2080]\nvariables {v : valuation R \u0393\u2080} {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 \u2208 v.integer :=\nlet \u27e8p, hpm, hpx\u27e9 := hx in le_of_not_lt $ \u03bb hvx, begin\n  rw [hpm.as_sum, eval\u2082_add, eval\u2082_pow, eval\u2082_X, eval\u2082_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\u2080.trans_le (one_le_pow_of_one_le' hvx.le _)) (\u03bb i hi, _),\n  rw [eval\u2082_mul, eval\u2082_pow, eval\u2082_C, eval\u2082_X, v.map_mul, v.map_pow, \u2190 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\u2080 hvpi (pow_lt_pow\u2080 hvx $ finset.mem_range.1 hi) },\n  { erw hvpi, rw [one_mul, one_mul], exact pow_lt_pow\u2080 hvx (finset.mem_range.1 hi) }\nend\n\nprotected lemma integral_closure : integral_closure O R = \u22a5 :=\nbot_unique $ \u03bb r hr, let \u27e8x, hx\u27e9 := hv.3 (hv.mem_of_integral hr) in algebra.mem_bot.2 \u27e8x, hx\u27e9\n\nend comm_ring\n\nsection fraction_field\n\nvariables {K : Type u} {\u0393\u2080 : Type v} [field K] [linear_ordered_comm_group_with_zero \u0393\u2080]\nvariables {v : valuation K \u0393\u2080} {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 \u2192 X \u2192 Prop)\n(lt_of_is_maximal : \u2200 {x y}, is_maximal x y \u2192 x < y)\n(sup_eq_of_is_maximal : \u2200 {x y z}, is_maximal x z \u2192 is_maximal y z \u2192\n  x \u2260 y \u2192 x \u2294 y = z)\n(is_maximal_inf : \u2200 {x y z}, is_maximal x z \u2192 is_maximal y z \u2192 x \u2260 y \u2192\n  is_maximal (x \u2293 y) y)\n(isom : (X \u00d7 X) \u2192 (X \u00d7 X) \u2192 Prop)\n(isom_refl : \u2200 x, isom x x)\n(isom_symm : \u2200 {x y}, isom x y \u2192 isom y x)\n(isom_trans : \u2200 {x y z}, isom x y \u2192 isom y z \u2192 isom x z)\n(second_iso : \u2200 x y, isom (y, x \u2294 y) (x \u2293 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 : \u2115)\n(series : fin length.succ \u2192 X)\n(step' : \u2200 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) : \u2200 i : fin s.length,\n  is_maximal (s i.cast_succ) (s i.succ) := s.step'\n\n@[simp] lemma coe_fn_mk (length : \u2115) (series step) :\n  (@composition_series.mk X _ _ length series step : fin length.succ \u2192 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 (\u03bb i h, s.lt_succ \u27e8i, nat.lt_of_succ_lt_succ h\u27e9)\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 \u2194 i = j :=\ns.injective.eq_iff\n\ninstance : has_mem X (composition_series X) :=\n\u27e8\u03bb x s, x \u2208 set.range s\u27e9\n\nlemma mem_def {x : X} {s : composition_series X} : x \u2208 s \u2194 x \u2208 set.range s := iff.rfl\n\nlemma total {s : composition_series X} {x y : X} (hx : x \u2208 s) (hy : y \u2208 s) : x \u2264 y \u2228 y \u2264 x :=\nbegin\n  rcases set.mem_range.1 hx with \u27e8i, rfl\u27e9,\n  rcases set.mem_range.1 hy with \u27e8j, rfl\u27e9,\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\u2081 s\u2082 : composition_series X}\n  (hl : s\u2081.length = s\u2082.length)\n  (h : \u2200 i, s\u2081 i = s\u2082 (fin.cast (congr_arg nat.succ hl) i)) :\n  s\u2081 = s\u2082 :=\nbegin\n  cases s\u2081, cases s\u2082,\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\u03bb s\u2081 s\u2082 (h : list.of_fn s\u2081 = list.of_fn s\u2082),\nhave h\u2081 : s\u2081.length = s\u2082.length,\n  from nat.succ_injective\n    ((list.length_of_fn s\u2081).symm.trans $\n      (congr_arg list.length h).trans $\n      list.length_of_fn s\u2082),\nhave h\u2082 : \u2200 i : fin s\u2081.length.succ, (s\u2081 i) = s\u2082 (fin.cast (congr_arg nat.succ h\u2081) i),\n  begin\n    assume i,\n    rw [\u2190 list.nth_le_of_fn s\u2081 i, \u2190 list.nth_le_of_fn s\u2082],\n    simp [h]\n  end,\nbegin\n  cases s\u2081, cases s\u2082,\n  dsimp at *,\n  subst h\u2081,\n  simp only [heq_iff_eq, eq_self_iff_true, true_and],\n  simp only [fin.cast_refl] at h\u2082,\n  exact funext h\u2082\nend\n\nlemma to_list_sorted (s : composition_series X) : s.to_list.sorted (<) :=\nlist.pairwise_iff_nth_le.2 (\u03bb 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  (\u03bb 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 \u2208 s.to_list \u2194 x \u2208 s :=\nbegin\n  rw [to_list, list.mem_of_fn],\n  refl\nend\n\n@[ext] lemma ext {s\u2081 s\u2082 : composition_series X} (h : \u2200 x, x \u2208 s\u2081 \u2194 x \u2208 s\u2082) : s\u2081 = s\u2082 :=\nto_list_injective $ list.eq_of_perm_of_sorted\n  (by classical; exact list.perm_of_nodup_nodup_to_finset_eq\n    s\u2081.to_list_nodup\n    s\u2082.to_list_nodup\n    (finset.ext $ by simp *))\n  s\u2081.to_list_sorted s\u2082.to_list_sorted\n\ndef top (s : composition_series X) : X := s (fin.last _)\n\nlemma top_mem (s : composition_series X) : s.top \u2208 s :=\nmem_def.2 (set.mem_range.2 \u27e8fin.last _, rfl\u27e9)\n\nlemma le_top {s : composition_series X} {x : X} (hx : x \u2208 s) : x \u2264 s.top :=\nlet \u27e8i, hi\u27e9 := set.mem_range.1 hx in hi \u25b8 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 \u2208 s :=\nmem_def.2 (set.mem_range.2 \u27e80, rfl\u27e9)\n\nlemma bot_le {s : composition_series X} {x : X} (hx : x \u2208 s) : s.bot \u2264 x :=\nlet \u27e8i, hi\u27e9 := set.mem_range.1 hx in hi \u25b8 s.strict_mono.monotone (fin.zero_le _)\n\ninstance : set_like (composition_series X) X :=\n{ coe := \u03bb s, set.range s,\n  coe_injective' := \u03bb s\u2081 s\u2082 h, ext $ \u03bb 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 := \u03bb i, s \u27e8i, lt_of_lt_of_le i.2 (nat.succ_le_succ (nat.sub_le_self _ _))\u27e9,\n  step' := \u03bb i, begin\n    have := s.step \u27e8i, lt_of_lt_of_le i.2 (nat.sub_le_self _ _)\u27e9,\n    cases i,\n    exact this\n  end }\n\nlemma top_erase_top (s : composition_series X) :\n  s.erase_top.top = s \u27e8s.length - 1, lt_of_le_of_lt (nat.sub_le_self _ _) (nat.lt_succ_self _)\u27e9 :=\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 \u2208 s) (hy : y \u2208 s) (hxy : x \u2260 y) :\n  0 < s.length :=\nlet \u27e8i, hi\u27e9 := hx, \u27e8j, hj\u27e9 := hy in\nhave hij : i \u2260 j, from mt s.inj.2 $ \u03bb h, hxy (hi \u25b8 hj \u25b8 h),\nhij.lt_or_lt.elim\n  (\u03bb hij, (lt_of_le_of_lt (zero_le i)\n    (lt_of_lt_of_le hij (nat.le_of_lt_succ j.2))))\n  (\u03bb 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 \u2208 s) (hy : y \u2208 s) : x = y :=\nby_contradiction (\u03bb 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 \u2260 s.top) (hxs : x \u2208 s) : x \u2208 s.erase_top :=\nbegin\n  { rcases hxs with \u27e8i, rfl\u27e9,\n    have hi : (i : \u2115) < (s.length - 1).succ,\n    { conv_rhs { rw [\u2190 nat.succ_sub (length_pos_of_mem_ne \u27e8i, rfl\u27e9 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 \u27e8i.cast_succ, _\u27e9,\n    simp [fin.ext_iff, nat.mod_eq_of_lt hi] }\nend\n\nlemma erase_top_le (s : composition_series X) : s.erase_top \u2264 s :=\nbegin\n  rintros x \u27e8i, rfl\u27e9,\n  simp [mem_def],\nend\n\nlemma mem_erase_top {s : composition_series X} {x : X}\n  (h : 0 < s.length) : x \u2208 s.erase_top \u2194 x \u2260 s.top \u2227 x \u2208 s :=\nbegin\n  simp only [mem_def],\n  dsimp only [erase_top, coe_fn_mk],\n  split,\n  { rintros \u27e8i, rfl\u27e9,\n    have hi : (i : \u2115) < s.length,\n    { conv_rhs { rw [\u2190 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 \u2208 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 [\u2190 nat.succ_sub_one s.length] }; rw nat.succ_sub h,\nbegin\n  rw [top_erase_top, top],\n  convert s.step \u27e8s.length - 1, nat.sub_lt h zero_lt_one\u27e9;\n  ext; simp [this]\nend\n\nlemma append_cast_add_aux\n  {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081 (fin.last _) = s\u2082 0)\n  (i : fin s\u2081.length) :\n  fin.append (nat.add_succ _ _).symm (s\u2081 \u2218 fin.cast_succ) s\u2082\n  (fin.cast_add s\u2082.length i).cast_succ = s\u2081 i.cast_succ :=\nby { cases i, simp [fin.append, *] }\n\nlemma append_succ_cast_add_aux\n  {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081 (fin.last _) = s\u2082 0)\n  (i : fin s\u2081.length) :\n  fin.append (nat.add_succ _ _).symm (s\u2081 \u2218 fin.cast_succ) s\u2082\n  (fin.cast_add s\u2082.length i).succ = s\u2081 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\u2081.length, from le_antisymm hi (le_of_not_gt h_1),\n    calc s\u2082 \u27e8i + 1 - s\u2081.length, by simp [this]\u27e9\n        = s\u2082 0 : congr_arg s\u2082 (by simp [fin.ext_iff, this])\n    ... = s\u2081 (fin.last _) : h.symm\n    ... = _ : congr_arg s\u2081 (by simp [fin.ext_iff, this]) }\nend\n\nlemma append_cast_add_right_aux\n  {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081 (fin.last _) = s\u2082 0)\n  (i : fin s\u2082.length) :\n  fin.append (nat.add_succ _ _).symm (s\u2081 \u2218 fin.cast_succ) s\u2082\n  (fin.cast_add_right s\u2081.length i).cast_succ = s\u2082 i.cast_succ :=\nby { cases i, simp [fin.append, *] }\n\nlemma append_succ_cast_add_right_aux\n  {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081 (fin.last _) = s\u2082 0)\n  (i : fin s\u2082.length) :\n  fin.append (nat.add_succ _ _).symm (s\u2081 \u2218 fin.cast_succ) s\u2082\n  (fin.cast_add_right s\u2081.length i).succ = s\u2082 i.succ :=\nbegin\n  cases i with i hi,\n  simp [fin.append, add_assoc]\nend\n\n@[simps length] def append {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081.top = s\u2082.bot) :\n  composition_series X :=\n{ length := s\u2081.length + s\u2082.length,\n  series := fin.append (nat.add_succ _ _).symm (s\u2081 \u2218 fin.cast_succ) s\u2082,\n  step' := \u03bb 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\u2081.step i },\n    { intro i,\n      rw [append_cast_add_right_aux h, append_succ_cast_add_right_aux h],\n      exact s\u2082.step i }\n  end }\n\n@[simp] lemma append_cast_add\n  {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081.top = s\u2082.bot)\n  (i : fin s\u2081.length) :\n  append h (fin.cast_add s\u2082.length i).cast_succ = s\u2081 i.cast_succ :=\nappend_cast_add_aux h i\n\n@[simp] lemma append_succ_cast_add\n  {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081.top = s\u2082.bot)\n  (i : fin s\u2081.length) :\n  append h (fin.cast_add s\u2082.length i).succ = s\u2081 i.succ :=\nappend_succ_cast_add_aux h i\n\n@[simp] lemma append_cast_add_right\n  {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081.top = s\u2082.bot)\n  (i : fin s\u2082.length) :\n  append h (fin.cast_add_right s\u2081.length i).cast_succ = s\u2082 i.cast_succ :=\nappend_cast_add_right_aux h i\n\n@[simp] lemma append_succ_cast_add_right\n  {s\u2081 s\u2082 : composition_series X}\n  (h : s\u2081.top = s\u2082.bot)\n  (i : fin s\u2082.length) :\n  append h (fin.cast_add_right s\u2081.length i).succ = s\u2082 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' := \u03bb i, begin\n    refine fin.last_cases _ _ i,\n    { rwa [fin.snoc_cast_succ, fin.succ_last, fin.snoc_last, \u2190 top] },\n    { intro i,\n      rw [fin.snoc_cast_succ, \u2190 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 : \u2200 y \u2208 s, y < x)\n--   (hsat : is_maximal s.top x) :\n--   @eq (fin (s.length + 2) \u2192 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, \u2190 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 \u2208 insert s x hsat \u2194 y \u2208 s \u2228 y = x :=\nbegin\n  simp only [insert, mem_def],\n  split,\n  { rintros \u27e8i, rfl\u27e9,\n    refine fin.last_cases _ (\u03bb i, _) i,\n    { right, simp },\n    { left, simp } },\n  { intro h,\n    rcases h with \u27e8i, rfl\u27e9 | 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\u2081 s\u2082 : composition_series X) : Prop :=\n\u2203 f : fin s\u2081.length \u2243 fin s\u2082.length,\n  \u2200 i : fin s\u2081.length,\n    isom (s\u2081 i.cast_succ, s\u2081 i.succ)\n    (s\u2082 (f i).cast_succ, s\u2082 (f i).succ)\n\nnamespace equivalent\n\n@[refl] lemma refl (s : composition_series X) : equivalent s s :=\n\u27e8equiv.refl _, \u03bb _, isom_refl _\u27e9\n\n@[symm] lemma symm {s\u2081 s\u2082 : composition_series X} (h : equivalent s\u2081 s\u2082) :\n  equivalent s\u2082 s\u2081 :=\n\u27e8h.some.symm, \u03bb i, isom_symm (by simpa using h.some_spec (h.some.symm i))\u27e9\n\n@[trans] lemma trans {s\u2081 s\u2082 s\u2083 : composition_series X}\n  (h\u2081 : equivalent s\u2081 s\u2082)\n  (h\u2082 : equivalent s\u2082 s\u2083) :\n  equivalent s\u2081 s\u2083 :=\n\u27e8h\u2081.some.trans h\u2082.some, \u03bb i, isom_trans (h\u2081.some_spec i) (h\u2082.some_spec (h\u2081.some i))\u27e9\n\ndef append\n  {s\u2081 s\u2082 t\u2081 t\u2082 : composition_series X}\n  (hs : s\u2081.top = s\u2082.bot)\n  (ht : t\u2081.top = t\u2082.bot)\n  (h\u2081 : equivalent s\u2081 t\u2081)\n  (h\u2082 : equivalent s\u2082 t\u2082) :\n  equivalent (append hs) (append ht) :=\nlet e : fin (s\u2081.length + s\u2082.length) \u2243 fin (t\u2081.length + t\u2082.length) :=\n  calc fin (s\u2081.length + s\u2082.length) \u2243 fin s\u2081.length \u2295 fin s\u2082.length : fin_sum_fin_equiv.symm\n  ... \u2243 fin t\u2081.length \u2295 fin t\u2082.length : equiv.sum_congr h\u2081.some h\u2082.some\n  ... \u2243 fin (t\u2081.length + t\u2082.length) : fin_sum_fin_equiv in\n\u27e8e, begin\n  assume i,\n  refine fin.add_cases _ _ i,\n  { assume i,\n    simpa [top, bot] using h\u2081.some_spec i },\n  { assume i,\n    simpa [top, bot] using h\u2082.some_spec i }\nend\u27e9\n\nlemma fin.succ_cast_succ {n : \u2115} (i : fin n) :\n  i.cast_succ.succ = i.succ.cast_succ :=\nfin.ext (by simp)\n\nprotected lemma insert\n  {s\u2081 s\u2082 : composition_series X}\n  {x\u2081 x\u2082 : X}\n  {hsat\u2081 : is_maximal s\u2081.top x\u2081}\n  {hsat\u2082 : is_maximal s\u2082.top x\u2082}\n  (hequiv : equivalent s\u2081 s\u2082)\n  (htop : isom (s\u2081.top, x\u2081) (s\u2082.top, x\u2082)) :\n  equivalent (s\u2081.insert x\u2081 hsat\u2081) (s\u2082.insert x\u2082 hsat\u2082) :=\nlet e : fin s\u2081.length.succ \u2243 fin s\u2082.length.succ :=\n  calc fin (s\u2081.length + 1) \u2243 option (fin s\u2081.length) : fin_succ_equiv_last\n  ... \u2243 option (fin s\u2082.length) : functor.map_equiv option hequiv.some\n  ... \u2243 fin (s\u2082.length + 1) : fin_succ_equiv_last.symm in\n\u27e8e,  \u03bb 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\u27e9\n\nvariables {\u03b1 \u03b2 : Type*} (e : \u03b1 \u2243 \u03b2)\n\ndef swap_top_two_fin {m n : \u2115} (e : fin m \u2243 fin n) : fin (m + 2) \u2243 fin (n + 2) :=\ncalc fin (m + 2)\n    \u2243 fin m \u2295 fin 2 : fin_sum_fin_equiv.symm\n... \u2243 fin n \u2295 fin 2 : equiv.sum_congr e (equiv.swap 0 1)\n... \u2243 fin (n + 2) : fin_sum_fin_equiv\n\n@[simp] lemma swap_top_two_fin_last {m n : \u2115} (e : fin m \u2243 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 : \u2115} (e : fin m \u2243 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 : \u2115} (e : fin m \u2243 fin n) (i : fin m) :\n  swap_top_two_fin e i.cast_succ.cast_succ = (e i).cast_succ.cast_succ :=\nhave \u2200 {m : \u2115} {i : fin m}, i.cast_succ.cast_succ = fin.cast_add 2 i := \u03bb _ _, fin.ext rfl,\nby simp [swap_top_two_fin, this]\n\nlemma insert_insert_swap\n  {s\u2081 s\u2082 : composition_series X}\n  {x\u2081 x\u2082 y\u2081 y\u2082 : X}\n  {hsat\u2081 : is_maximal s\u2081.top x\u2081}\n  {hsat\u2082 : is_maximal s\u2082.top x\u2082}\n  {hsaty\u2081 : is_maximal (insert s\u2081 x\u2081 hsat\u2081).top y\u2081}\n  {hsaty\u2082 : is_maximal (insert s\u2082 x\u2082 hsat\u2082).top y\u2082}\n  (hequiv : equivalent s\u2081 s\u2082)\n  (hr\u2081 : isom (s\u2081.top, x\u2081) (x\u2082, y\u2082))\n  (hr\u2082 : isom (x\u2081, y\u2081) (s\u2082.top, x\u2082)) :\n  equivalent\n    (insert (insert s\u2081 x\u2081 hsat\u2081) y\u2081 hsaty\u2081)\n    (insert (insert s\u2082 x\u2082 hsat\u2082) y\u2082 hsaty\u2082) :=\nlet e : fin (s\u2081.length + 1 + 1) \u2243 fin (s\u2082.length + 1 + 1) :=\nswap_top_two_fin hequiv.some in\n\u27e8e, begin\n  intro i,\n  dsimp only [e],\n  refine fin.last_cases _ (\u03bb 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\u2082 },\n  { refine fin.last_cases _ (\u03bb 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\u2081 },\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\u27e9\n\nlemma length_eq {s\u2081 s\u2082 : composition_series X} (h : equivalent s\u2081 s\u2082) : s\u2081.length = s\u2082.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\u2081 s\u2082 : composition_series X}\n  (hb : s\u2081.bot = s\u2082.bot) (ht : s\u2081.top = s\u2082.top)\n  (hs\u2081 : s\u2081.length = 0) : s\u2082.length = 0 :=\nbegin\n  have : s\u2081.bot = s\u2081.top,\n    from congr_arg s\u2081 (fin.ext (by simp [hs\u2081])),\n  have : (fin.last s\u2082.length) = (0 : fin s\u2082.length.succ),\n    from s\u2082.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\u2081 s\u2082 : composition_series X}\n  (hb : s\u2081.bot = s\u2082.bot) (ht : s\u2081.top = s\u2082.top) :\n  0 < s\u2081.length \u2192 0 < s\u2082.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\u2081 s\u2082 : composition_series X}\n  (hb : s\u2081.bot = s\u2082.bot) (ht : s\u2081.top = s\u2082.top)\n  (hs\u20810 : s\u2081.length = 0) :\n  s\u2081 = s\u2082 :=\nhave \u2200 x, x \u2208 s\u2081 \u2194 x = s\u2081.top,\n  from \u03bb x, \u27e8\u03bb hx, forall_mem_eq_of_length_eq_zero hs\u20810 hx s\u2081.top_mem, \u03bb hx, hx.symm \u25b8 s\u2081.top_mem\u27e9,\nhave \u2200 x, x \u2208 s\u2082 \u2194 x = s\u2082.top,\n  from \u03bb x, \u27e8\u03bb 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\u20810)\n    hx s\u2082.top_mem, \u03bb hx, hx.symm \u25b8 s\u2082.top_mem\u27e9,\nby { ext, simp * }\n\nlemma intersection (s : composition_series X) (x : X)\n  (hm : is_maximal x s.top) (hb : s.bot \u2264 x) :\n  \u2203 t : composition_series X, t.bot = s.bot \u2227 t.length + 1 = s.length \u2227\n    \u2203 htx : t.top = x, equivalent s (insert t s.top (htx.symm \u25b8 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 \u25b8 nat.succ_pos _,\n    by_cases hetx : s.erase_top.top = x,\n    { use s.erase_top,\n      simp [\u2190 hetx, hn] },\n    { have imxs : is_maximal (x \u2293 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 \u27e8t, htb, htl, htt, hteqv\u27e9,\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 \u27e8by simp [htb], by simp [htl], by simp, _\u27e9,\n      have : s.equivalent ((insert t s.erase_top.top (htt.symm \u25b8 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 [\u2190 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 [\u2190 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\u2081 s\u2082 : composition_series X)\n  (hb : s\u2081.bot = s\u2082.bot) (ht : s\u2081.top = s\u2082.top) :\n  equivalent s\u2081 s\u2082 :=\nbegin\n  induction hle : s\u2081.length with n ih generalizing s\u2081 s\u2082,\n  { rw [eq_of_bot_eq_bot_of_top_eq_top_of_length_eq_zero hb ht hle] },\n  { have h0s\u2082 : 0 < s\u2082.length,\n      from length_pos_of_bot_eq_bot_of_top_eq_top_of_length_pos hb ht (hle.symm \u25b8 nat.succ_pos _),\n    rcases intersection s\u2081 s\u2082.erase_top.top\n      (ht.symm \u25b8 is_maximal_erase_top_top h0s\u2082)\n      (hb.symm \u25b8 s\u2082.bot_erase_top \u25b8 bot_le (top_mem _)) with \u27e8t\u2082, htb\u2082, htl\u2082, htt\u2082, hteq\u2082\u27e9,\n    have := ih t\u2082 s\u2082.erase_top (by simp [htb\u2082, \u2190 hb]) htt\u2082 (nat.succ_inj'.1 (htl\u2082.trans hle)),\n    refine hteq\u2082.trans _,\n    conv_rhs { rw [eq_insert_erase_top h0s\u2082] },\n    simp only [ht],\n    refine equivalent.insert this (by simp [htt\u2082]) }\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 : \u2115) (h\u2081 : x = y + z) (h\u2082 : 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 \u2227 q \u2194 q :=\nby simp *\n\nexample (hp : p) : p \u2228 q :=\nby simp *\n\nexample (hp : p) (hq : q) : p \u2227 (q \u2228 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 : \u2115) : Int := Int.ofNat n\n\n\nnamespace SciLean\n\ninstance : PowType \u2124 where\n  powType n := {u : Array \u2124 // u.size = n}\n  intro {n} f := Id.run do\n    let mut u : Array \u2124 := Array.mkEmpty n\n    for i in [0:n] do\n      u := u.push (f \u27e8i, sorry\u27e9)\n    \u27e8u, sorry\u27e9\n  get v i := v.1.get \u27e8i, by rw[v.2] apply i.2\u27e9\n  set v i val := \u27e8v.1.set \u27e8i, by rw[v.2] apply i.2\u27e9 val, sorry\u27e9\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 : \u2124^dim\n    lvl : Nat\n\n  abbrev Index (dim : Nat) (size : Nat) := Fin (size^dim)\n\n  def Index.toPos (idx : Index dim size) : \u2124^dim := Id.run do\n    let mut pos : \u2124^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 \u03bb i => ((idx.1 >>> (i.1 * scl)) &&& mask).toInt\n\n  def toIndex {dim : Nat} (p : \u2124^dim) : Index dim scl :=\n    let size := 2^scl\n    \u27e8\u2211 i, (p[i].fmod size).toNat <<< (i.1 * scl), sorry\u27e9\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 := \u27e8i, sorry\u27e9\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) : \u2124 := \u2211 i : Fin (lvl+1), if (i.1 % 2 = 1) then - ((1:\u2115) <<< (i.1 - 1) * scl).toInt else 0\n\n    #eval originOffset 1 2\n    def min (node : GridNode dim scl) : \u2124^dim := node.size.toInt * node.pos\n    def max (node : GridNode dim scl) : \u2124^dim := node.pos.map (\u03bb 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      \u27e8node.pos.map (\u03bb x => x.fdiv scl), node.lvl+1\u27e9\n    def child  (node : GridNode dim scl) (idx : Index dim scl) : GridNode dim scl := \n      if node.lvl = 0 \n      then node\n      else \u27e8((1:\u2115) <<< scl).toInt * node.pos + idx.toPos, node.lvl-1\u27e9\n    def localPos (node : GridNode dim scl) : \u2124^dim := \n      let size := (1:\u2115) <<< scl\n      node.pos.map \u03bb 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 := \u27e8^[-1,0], 0\u27e9\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 : \u2124) (scl : \u2115) : \u2124\u00d7\u2115 := 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:\u2115) <<< 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:\u2115).log2 + 1\n\n    -- def min (node : GridNode dim scl) := ((1:\u2115) <<< 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 : \u2124^dim\n\n  namespace GridCell\n\n    def Impl {\u03b1} (a : \u03b1) := \u03b1\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) : \u2124 := \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 \u2192 GridCell dim size (lvl+n) :=\n      let offset := originOffset size lvl n\n      let nsize := size^n\n      \u03bb \u27e8p\u27e9 => \u27e8p.map \u03bb xi => (xi - offset).fdiv nsize\u27e9\n\n    def child (idx : Fin (size^dim)) : GridCell dim size (lvl+1) \u2192 GridCell dim size lvl :=\n      let offset := originOffset size lvl 1\n      let loc_p : \u2124^dim := sorry\n      \u03bb \u27e8p\u27e9 => \u27e8size.toInt * p + offset * (1:\u2124^dim) + loc_p\u27e9\n\n    def inParentIdx : GridCell dim size lvl \u2192 Fin (size^dim) := sorry\n    def inParentPos (node : GridCell dim size lvl) : \u2124^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 \u27f6 Y$$ and $$g : X \u27f6 Y$$ are morphisms such that $$f = g$$, then $$f \u226b h = g \u226b h$$.\n-/\nlemma id_of_comp_left_id' (X : C) (f : X \u27f6 X) (w : \u2200 {Y : C} (g : X \u27f6 Y), f \u226b g = g) : f = \ud835\udfd9 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 \u27f6 Y`\nasserts the existence of some `P.factor_thru f : X \u27f6 (P : C)` making the obvious diagram commute.\n\n-/\n\n\nuniverse v\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Category CategoryTheory.Limits\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {X Y Z : C}\n\nvariable {D : Type u\u2082} [Category.{v\u2082} D]\n\nnamespace CategoryTheory\n\nnamespace MonoOver\n\n/-- When `f : X \u27f6 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 \u27f6 Y) : Prop :=\n  \u2203 g : X \u27f6 (P : C), g \u226b 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 \u27f6 X) (e : f \u2245 g) :\n    f.Factors h \u2194 g.Factors h :=\n  \u27e8fun \u27e8u, hu\u27e9 => \u27e8u \u226b ((MonoOver.forget _).map e.Hom).left, by simp [hu]\u27e9, fun \u27e8u, hu\u27e9 =>\n    \u27e8u \u226b ((MonoOver.forget _).map e.inv).left, by simp [hu]\u27e9\u27e9\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 \u27f6 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 \u27f6 Y) (h : Factors P f) : X \u27f6 (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 \u27f6 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 \u27f6 Y) : Prop :=\n  Quotient.liftOn' P (fun P => P.Factors f)\n    (by\n      rintro P Q \u27e8h\u27e9\n      apply propext\n      constructor\n      \u00b7 rintro \u27e8i, w\u27e9\n        exact \u27e8i \u226b h.hom.left, by erw [category.assoc, over.w h.hom, w]\u27e9\n      \u00b7 rintro \u27e8i, w\u27e9\n        exact \u27e8i \u226b h.inv.left, by erw [category.assoc, over.w h.inv, w]\u27e9)\n#align category_theory.subobject.factors CategoryTheory.Subobject.Factors\n\n@[simp]\ntheorem mk_factors_iff {X Y Z : C} (f : Y \u27f6 X) [Mono f] (g : Z \u27f6 X) :\n    (Subobject.mk f).Factors g \u2194 (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 \u27f6 Y) [Mono f] : (mk f).Factors f :=\n  \u27e8\ud835\udfd9 _, by simp\u27e9\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 \u27f6 Y) :\n    P.Factors f \u2194 (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 \u27e8\ud835\udfd9 P, by simp\u27e9\n#align category_theory.subobject.factors_self CategoryTheory.Subobject.factors_self\n\ntheorem factors_comp_arrow {X Y : C} {P : Subobject Y} (f : X \u27f6 P) : P.Factors (f \u226b P.arrow) :=\n  (factors_iff _ _).mpr \u27e8f, rfl\u27e9\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 \u27f6 Y) {g : Y \u27f6 Z}\n    (h : P.Factors g) : P.Factors (f \u226b g) := by\n  revert P\n  refine' Quotient.ind' _\n  intro P\n  rintro \u27e8g, rfl\u27e9\n  exact \u27e8f \u226b g, by simp\u27e9\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 \u27f6 Y) :=\n  (factors_iff _ _).mpr \u27e80, by simp\u27e9\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 \u27f6 Y) (h : P \u2264 Q) :\n    P.Factors f \u2192 Q.Factors f := by\n  simp only [factors_iff]\n  exact fun \u27e8u, hu\u27e9 => \u27e8u \u226b of_le _ _ h, by simp [\u2190 hu]\u27e9\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 \u27f6 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 \u27f6 Y) (h : Factors P f) : X \u27f6 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 \u27f6 Y) (h : Factors P f) :\n    P.factorThru f h \u226b 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 = \ud835\udfd9 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 \u27f6 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 \u27f6 P) (h) :\n    P.factorThru (f \u226b 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 \u27f6 Y}\n    {h : Factors P f} : P.factorThru f h = 0 \u2194 f = 0 :=\n  by\n  fconstructor\n  \u00b7 intro w\n    replace w := w =\u226b P.arrow\n    simpa using w\n  \u00b7 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 \u27f6 Y) (g : Y \u27f6 Z) (h : P.Factors g) :\n    f \u226b P.factorThru g h = P.factorThru (f \u226b 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 \u27f6 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 \u27f6 Y} (h : P \u2264 Q) (w : P.Factors f) :\n    Q.factorThru f (factors_of_le f h w) = P.factorThru f w \u226b 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 \u27f6 Y) (wf : P.Factors f)\n    (wg : P.Factors g) : P.Factors (f + g) :=\n  (factors_iff _ _).mpr \u27e8P.factorThru f wf + P.factorThru g wg, by simp\u27e9\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 \u27f6 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 \u27f6 Y)\n    (w : P.Factors (f + g)) (wg : P.Factors g) : P.Factors f :=\n  (factors_iff _ _).mpr \u27e8P.factorThru (f + g) w - P.factorThru g wg, by simp\u27e9\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 \u27f6 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 \u27f6 Y)\n    (w : P.Factors (f + g)) (wf : P.Factors f) : P.Factors g :=\n  (factors_iff _ _).mpr \u27e8P.factorThru (f + g) w - P.factorThru f wf, by simp\u27e9\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 \u27f6 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' : \u2200 (c : R) {x : M}, x \u2208 carrier \u2192 c \u2022 x \u2208 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 \u2208 \u2191p\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 \u2208 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 \u2205 sorry)\n\nprotected instance inhabited {R : Type u} {M : Type v} [has_scalar R M] :\n    Inhabited (sub_mul_action R M) :=\n  { default := \u22a5 }\n\n@[simp] theorem coe_sort_coe {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) :\n    \u21a5\u2191p = \u21a5p :=\n  rfl\n\nprotected theorem exists {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M}\n    {q : \u21a5p \u2192 Prop} : (\u2203 (x : \u21a5p), q x) \u2194 \u2203 (x : M), \u2203 (H : x \u2208 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 : \u21a5p \u2192 Prop} : (\u2200 (x : \u21a5p), q x) \u2194 \u2200 (x : M) (H : x \u2208 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} : \u2191p = \u2191q \u2194 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 \u2194 \u2191p = \u2191q :=\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 : \u2200 (x : M), x \u2208 p \u2194 x \u2208 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 \u2208 \u2191p \u2194 x \u2208 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 \u2208 p) : r \u2022 x \u2208 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 \u21a5p :=\n  has_scalar.mk fun (c : R) (x : \u21a5p) => { val := c \u2022 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 : \u21a5p} {y : \u21a5p} : \u2191x = \u2191y \u2194 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 : \u21a5p) : \u2191(r \u2022 x) = r \u2022 \u2191x :=\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 \u2208 p) : \u2191{ 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 : \u21a5p) : \u2191x \u2208 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 : \u21a5p) (hx : \u2191x \u2208 p) : { val := \u2191x, 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 (\u21a5p) 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 : \u21a5p) : coe_fn (sub_mul_action.subtype p) x = \u2191x :=\n  rfl\n\ntheorem subtype_eq_val {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) :\n    \u21d1(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) : \u2191u \u2022 x \u2208 p \u2194 x \u2208 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 \u21a5p :=\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 \u2191p) : 0 \u2208 p :=\n  sorry\n\n/-- If the scalar product forms a `semimodule`, and the `sub_mul_action` is not `\u22a5`, 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 \u21a5p] : HasZero \u21a5p :=\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 \u2208 p) : -x \u2208 p :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (-x \u2208 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 \u2208 p \u2194 x \u2208 p :=\n  { mp :=\n      fun (h : -x \u2208 p) =>\n        eq.mpr (id (Eq._oldrec (Eq.refl (x \u2208 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 \u21a5p :=\n  { neg := fun (x : \u21a5p) => { 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 : \u21a5p) : \u2191(-x) = -\u2191x :=\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 \u2260 0) : r \u2022 x \u2208 p \u2194 x \u2208 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\u00f6lzl\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 {\u03b1 : Type u} {\u03b2 : Type v}\n\nopen function\n\nnamespace with_top\n\nsection has_one\n\nvariables [has_one \u03b1]\n\n@[to_additive] instance : has_one (with_top \u03b1) := \u27e8(1 : \u03b1)\u27e9\n\n@[simp, norm_cast, to_additive] lemma coe_one : ((1 : \u03b1) : with_top \u03b1) = 1 := rfl\n\n@[simp, norm_cast, to_additive] lemma coe_eq_one {a : \u03b1} : (a : with_top \u03b1) = 1 \u2194 a = 1 :=\ncoe_eq_coe\n\n@[simp, to_additive] lemma untop_one : (1 : with_top \u03b1).untop coe_ne_top = 1 := rfl\n@[simp, to_additive] lemma untop_one' (d : \u03b1) : (1 : with_top \u03b1).untop' d = 1 := rfl\n\n@[simp, norm_cast, to_additive coe_nonneg]\nlemma one_le_coe [has_le \u03b1] {a : \u03b1} : 1 \u2264 (a : with_top \u03b1) \u2194 1 \u2264 a := coe_le_coe\n\n@[simp, norm_cast, to_additive coe_le_zero]\nlemma coe_le_one [has_le \u03b1] {a : \u03b1} : (a : with_top \u03b1) \u2264 1 \u2194 a \u2264 1 := coe_le_coe\n\n@[simp, norm_cast, to_additive coe_pos]\nlemma one_lt_coe [has_lt \u03b1] {a : \u03b1} : 1 < (a : with_top \u03b1) \u2194 1 < a := coe_lt_coe\n\n@[simp, norm_cast, to_additive coe_lt_zero]\nlemma coe_lt_one [has_lt \u03b1] {a : \u03b1} : (a : with_top \u03b1) < 1 \u2194 a < 1 := coe_lt_coe\n\n@[simp, to_additive] protected lemma map_one {\u03b2} (f : \u03b1 \u2192 \u03b2) :\n  (1 : with_top \u03b1).map f = (f 1 : with_top \u03b2) := rfl\n\n@[simp, norm_cast, to_additive] theorem one_eq_coe {a : \u03b1} : 1 = (a : with_top \u03b1) \u2194 a = 1 :=\ntrans eq_comm coe_eq_one\n\n@[simp, to_additive] theorem top_ne_one : \u22a4 \u2260 (1 : with_top \u03b1) .\n@[simp, to_additive] theorem one_ne_top : (1 : with_top \u03b1) \u2260 \u22a4 .\n\ninstance [has_zero \u03b1] [has_le \u03b1] [zero_le_one_class \u03b1] : zero_le_one_class (with_top \u03b1) :=\n\u27e8some_le_some.2 zero_le_one\u27e9\n\nend has_one\n\nsection has_add\nvariables [has_add \u03b1] {a b c d : with_top \u03b1} {x y : \u03b1}\n\ninstance : has_add (with_top \u03b1) := \u27e8option.map\u2082 (+)\u27e9\n\n@[norm_cast] lemma coe_add : ((x + y : \u03b1) : with_top \u03b1) = x + y := rfl\n@[norm_cast] lemma coe_bit0 : ((bit0 x : \u03b1) : with_top \u03b1) = bit0 x := rfl\n@[norm_cast] lemma coe_bit1 [has_one \u03b1] {a : \u03b1} : ((bit1 a : \u03b1) : with_top \u03b1) = bit1 a := rfl\n\n@[simp] lemma top_add (a : with_top \u03b1) : \u22a4 + a = \u22a4 := rfl\n@[simp] \n\n@[simp] lemma add_eq_top : a + b = \u22a4 \u2194 a = \u22a4 \u2228 b = \u22a4 :=\nby cases a; cases b; simp [none_eq_top, some_eq_coe, \u2190with_top.coe_add]\n\nlemma add_ne_top : a + b \u2260 \u22a4 \u2194 a \u2260 \u22a4 \u2227 b \u2260 \u22a4 := add_eq_top.not.trans not_or_distrib\n\nlemma add_lt_top [has_lt \u03b1] {a b : with_top \u03b1} : a + b < \u22a4 \u2194 a < \u22a4 \u2227 b < \u22a4 :=\nby simp_rw [with_top.lt_top_iff_ne_top, add_ne_top]\n\nlemma add_eq_coe : \u2200 {a b : with_top \u03b1} {c : \u03b1},\n  a + b = c \u2194 \u2203 (a' b' : \u03b1), \u2191a' = a \u2227 \u2191b' = b \u2227 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, \u2190 coe_add, coe_eq_coe, exists_and_distrib_left, exists_eq_left]\n\n@[simp] lemma add_coe_eq_top_iff {x : with_top \u03b1} {y : \u03b1} : x + y = \u22a4 \u2194 x = \u22a4 :=\nby { induction x using with_top.rec_top_coe; simp [\u2190 coe_add] }\n\n@[simp] lemma coe_add_eq_top_iff {y : with_top \u03b1} : \u2191x + y = \u22a4 \u2194 y = \u22a4 :=\nby { induction y using with_top.rec_top_coe; simp [\u2190 coe_add] }\n\ninstance covariant_class_add_le [has_le \u03b1] [covariant_class \u03b1 \u03b1 (+) (\u2264)] :\n  covariant_class (with_top \u03b1) (with_top \u03b1) (+) (\u2264) :=\n\u27e8\u03bb a b c h, begin\n  cases a; cases c; try { exact le_top },\n  rcases le_coe_iff.1 h with \u27e8b, rfl, h'\u27e9,\n  exact coe_le_coe.2 (add_le_add_left (coe_le_coe.1 h) _)\nend\u27e9\n\ninstance covariant_class_swap_add_le [has_le \u03b1] [covariant_class \u03b1 \u03b1 (swap (+)) (\u2264)] :\n  covariant_class (with_top \u03b1) (with_top \u03b1) (swap (+)) (\u2264) :=\n\u27e8\u03bb a b c h, begin\n  cases a; cases c; try { exact le_top },\n  rcases le_coe_iff.1 h with \u27e8b, rfl, h'\u27e9,\n  exact coe_le_coe.2 (add_le_add_right (coe_le_coe.1 h) _)\nend\u27e9\n\ninstance contravariant_class_add_lt [has_lt \u03b1] [contravariant_class \u03b1 \u03b1 (+) (<)] :\n  contravariant_class (with_top \u03b1) (with_top \u03b1) (+) (<) :=\n\u27e8\u03bb 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\u27e9\n\ninstance contravariant_class_swap_add_lt [has_lt \u03b1] [contravariant_class \u03b1 \u03b1 (swap (+)) (<)] :\n  contravariant_class (with_top \u03b1) (with_top \u03b1) (swap (+)) (<) :=\n\u27e8\u03bb 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\u27e9\n\nprotected lemma le_of_add_le_add_left [has_le \u03b1] [contravariant_class \u03b1 \u03b1 (+) (\u2264)] (ha : a \u2260 \u22a4)\n  (h : a + b \u2264 a + c) : b \u2264 c :=\nbegin\n  lift a to \u03b1 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 [\u2190 coe_add, coe_le_coe] at h \u22a2,\n  exact le_of_add_le_add_left h\nend\n\nprotected lemma le_of_add_le_add_right [has_le \u03b1] [contravariant_class \u03b1 \u03b1 (swap (+)) (\u2264)]\n  (ha : a \u2260 \u22a4) (h : b + a \u2264 c + a) : b \u2264 c :=\nbegin\n  lift a to \u03b1 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 \u03b1] [covariant_class \u03b1 \u03b1 (+) (<)] (ha : a \u2260 \u22a4) (h : b < c) :\n  a + b < a + c :=\nbegin\n  lift a to \u03b1 using ha,\n  rcases lt_iff_exists_coe.1 h with \u27e8b, rfl, h'\u27e9,\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 \u03b1] [covariant_class \u03b1 \u03b1 (swap (+)) (<)]\n  (ha : a \u2260 \u22a4) (h : b < c) :\n  b + a < c + a :=\nbegin\n  lift a to \u03b1 using ha,\n  rcases lt_iff_exists_coe.1 h with \u27e8b, rfl, h'\u27e9,\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 \u03b1] [covariant_class \u03b1 \u03b1 (+) (\u2264)]\n  [contravariant_class \u03b1 \u03b1 (+) (\u2264)]\n  (ha : a \u2260 \u22a4) : a + b \u2264 a + c \u2194 b \u2264 c :=\n\u27e8with_top.le_of_add_le_add_left ha, \u03bb h, add_le_add_left h a\u27e9\n\nprotected lemma add_le_add_iff_right [has_le \u03b1] [covariant_class \u03b1 \u03b1 (swap (+)) (\u2264)]\n  [contravariant_class \u03b1 \u03b1 (swap (+)) (\u2264)] (ha : a \u2260 \u22a4) : b + a \u2264 c + a \u2194 b \u2264 c :=\n\u27e8with_top.le_of_add_le_add_right ha, \u03bb h, add_le_add_right h a\u27e9\n\nprotected lemma add_lt_add_iff_left [has_lt \u03b1] [covariant_class \u03b1 \u03b1 (+) (<)]\n  [contravariant_class \u03b1 \u03b1 (+) (<)] (ha : a \u2260 \u22a4) : a + b < a + c \u2194 b < c :=\n\u27e8lt_of_add_lt_add_left, with_top.add_lt_add_left ha\u27e9\n\nprotected lemma add_lt_add_iff_right [has_lt \u03b1] [covariant_class \u03b1 \u03b1 (swap (+)) (<)]\n  [contravariant_class \u03b1 \u03b1 (swap (+)) (<)] (ha : a \u2260 \u22a4) : b + a < c + a \u2194 b < c :=\n\u27e8lt_of_add_lt_add_right, with_top.add_lt_add_right ha\u27e9\n\nprotected lemma add_lt_add_of_le_of_lt [preorder \u03b1] [covariant_class \u03b1 \u03b1 (+) (<)]\n  [covariant_class \u03b1 \u03b1 (swap (+)) (\u2264)] (ha : a \u2260 \u22a4) (hab : a \u2264 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 \u03b1] [covariant_class \u03b1 \u03b1 (+) (\u2264)]\n  [covariant_class \u03b1 \u03b1 (swap (+)) (<)] (hc : c \u2260 \u22a4) (hab : a < b) (hcd : c \u2264 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 \u03b2] [add_hom_class F \u03b1 \u03b2] (f : F) (a b : with_top \u03b1) :\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, \u2190 coe_add, \u2190 coe_add, \u2190 map_add],\n      refl } },\nend\n\nend has_add\n\ninstance [add_semigroup \u03b1] : add_semigroup (with_top \u03b1) :=\n{ add_assoc := \u03bb _ _ _, option.map\u2082_assoc add_assoc,\n  ..with_top.has_add }\n\ninstance [add_comm_semigroup \u03b1] : add_comm_semigroup (with_top \u03b1) :=\n{ add_comm := \u03bb _ _, option.map\u2082_comm add_comm,\n  ..with_top.add_semigroup }\n\ninstance [add_zero_class \u03b1] : add_zero_class (with_top \u03b1) :=\n{ zero_add := option.map\u2082_left_identity zero_add,\n  add_zero := option.map\u2082_right_identity add_zero,\n  ..with_top.has_zero,\n  ..with_top.has_add }\n\ninstance [add_monoid \u03b1] : add_monoid (with_top \u03b1) :=\n{ ..with_top.add_zero_class,\n  ..with_top.has_zero,\n  ..with_top.add_semigroup }\n\ninstance [add_comm_monoid \u03b1] : add_comm_monoid (with_top \u03b1) :=\n{ ..with_top.add_monoid, ..with_top.add_comm_semigroup }\n\ninstance [add_monoid_with_one \u03b1] : add_monoid_with_one (with_top \u03b1) :=\n{ nat_cast := \u03bb n, \u2191(n : \u03b1),\n  nat_cast_zero := by rw [nat.cast_zero, with_top.coe_zero],\n  nat_cast_succ := \u03bb 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 \u03b1] : add_comm_monoid_with_one (with_top \u03b1) :=\n{ .. with_top.add_monoid_with_one, .. with_top.add_comm_monoid }\n\ninstance [ordered_add_comm_monoid \u03b1] : ordered_add_comm_monoid (with_top \u03b1) :=\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 \u27e8a, rfl, h\u27e9,\n      simp only [some_eq_coe, \u2190 coe_add, coe_le_coe] at h \u22a2,\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 \u03b1] :\n  linear_ordered_add_comm_monoid_with_top (with_top \u03b1) :=\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 \u03b1] [has_add \u03b1] [has_exists_add_of_le \u03b1] : has_exists_add_of_le (with_top \u03b1) :=\n\u27e8\u03bb a b, match a, b with\n  | \u22a4, \u22a4 := by simp\n  | (a : \u03b1), \u22a4 := \u03bb _, \u27e8\u22a4, rfl\u27e9\n  | (a : \u03b1), (b : \u03b1) := \u03bb h, begin\n      obtain \u27e8c, rfl\u27e9 := exists_add_of_le (with_top.coe_le_coe.1 h),\n      exact \u27e8c, rfl\u27e9\n    end\n  | \u22a4, (b : \u03b1) := \u03bb h, (not_top_le_coe _ h).elim\nend\u27e9\n\ninstance [canonically_ordered_add_monoid \u03b1] : canonically_ordered_add_monoid (with_top \u03b1) :=\n{ le_self_add := \u03bb a b, match a, b with\n  | \u22a4, \u22a4 := le_rfl\n  | (a : \u03b1), \u22a4 := le_top\n  | (a : \u03b1), (b : \u03b1) := with_top.coe_le_coe.2 le_self_add\n  | \u22a4, (b : \u03b1) := 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 \u03b1] :\n  canonically_linear_ordered_add_monoid (with_top \u03b1) :=\n{ ..with_top.canonically_ordered_add_monoid, ..with_top.linear_order }\n\n@[simp, norm_cast] lemma coe_nat [add_monoid_with_one \u03b1] (n : \u2115) : ((n : \u03b1) : with_top \u03b1) = n := rfl\n@[simp] lemma nat_ne_top [add_monoid_with_one \u03b1] (n : \u2115) : (n : with_top \u03b1) \u2260 \u22a4 := coe_ne_top\n@[simp] lemma top_ne_nat [add_monoid_with_one \u03b1] (n : \u2115) : (\u22a4 : with_top \u03b1) \u2260 n := top_ne_coe\n\n/-- Coercion from `\u03b1` to `with_top \u03b1` as an `add_monoid_hom`. -/\ndef coe_add_hom [add_monoid \u03b1] : \u03b1 \u2192+ with_top \u03b1 :=\n\u27e8coe, rfl, \u03bb _ _, rfl\u27e9\n\n@[simp] lemma coe_coe_add_hom [add_monoid \u03b1] : \u21d1(coe_add_hom : \u03b1 \u2192+ with_top \u03b1) = coe := rfl\n\n@[simp] lemma zero_lt_top [ordered_add_comm_monoid \u03b1] : (0 : with_top \u03b1) < \u22a4 :=\ncoe_lt_top 0\n\n@[simp, norm_cast] lemma zero_lt_coe [ordered_add_comm_monoid \u03b1] (a : \u03b1) :\n  (0 : with_top \u03b1) < a \u2194 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 \u2192+ N) :\n  with_top M \u2192+ 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 \u03b1] : has_one (with_bot \u03b1) := with_top.has_one\ninstance [has_add \u03b1] : has_add (with_bot \u03b1) := with_top.has_add\ninstance [add_semigroup \u03b1] : add_semigroup (with_bot \u03b1) := with_top.add_semigroup\ninstance [add_comm_semigroup \u03b1] : add_comm_semigroup (with_bot \u03b1) := with_top.add_comm_semigroup\ninstance [add_zero_class \u03b1] : add_zero_class (with_bot \u03b1) := with_top.add_zero_class\ninstance [add_monoid \u03b1] : add_monoid (with_bot \u03b1) := with_top.add_monoid\ninstance [add_comm_monoid \u03b1] : add_comm_monoid (with_bot \u03b1) := with_top.add_comm_monoid\ninstance [add_monoid_with_one \u03b1] : add_monoid_with_one (with_bot \u03b1) := with_top.add_monoid_with_one\n\ninstance [add_comm_monoid_with_one \u03b1] : add_comm_monoid_with_one (with_bot \u03b1) :=\nwith_top.add_comm_monoid_with_one\n\ninstance [has_zero \u03b1] [has_one \u03b1] [has_le \u03b1] [zero_le_one_class \u03b1] :\n  zero_le_one_class (with_bot \u03b1) :=\n\u27e8some_le_some.2 zero_le_one\u27e9\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 \u03b1] : ((1 : \u03b1) : with_bot \u03b1) = 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 \u03b1] {a : \u03b1} : (a : with_bot \u03b1) = 1 \u2194 a = 1 :=\nwith_top.coe_eq_one\n\n@[simp, to_additive] lemma unbot_one [has_one \u03b1] : (1 : with_bot \u03b1).unbot coe_ne_bot = 1 := rfl\n@[simp, to_additive] lemma unbot_one' [has_one \u03b1] (d : \u03b1) : (1 : with_bot \u03b1).unbot' d = 1 := rfl\n\n@[simp, norm_cast, to_additive coe_nonneg]\nlemma one_le_coe [has_one \u03b1] [has_le \u03b1] {a : \u03b1} : 1 \u2264 (a : with_bot \u03b1) \u2194 1 \u2264 a := coe_le_coe\n\n@[simp, norm_cast, to_additive coe_le_zero]\nlemma coe_le_one [has_one \u03b1] [has_le \u03b1] {a : \u03b1} : (a : with_bot \u03b1) \u2264 1 \u2194 a \u2264 1 := coe_le_coe\n\n@[simp, norm_cast, to_additive coe_pos]\nlemma one_lt_coe [has_one \u03b1] [has_lt \u03b1] {a : \u03b1} : 1 < (a : with_bot \u03b1) \u2194 1 < a := coe_lt_coe\n\n@[simp, norm_cast, to_additive coe_lt_zero]\nlemma coe_lt_one [has_one \u03b1] [has_lt \u03b1] {a : \u03b1} : (a : with_bot \u03b1) < 1 \u2194 a < 1 := coe_lt_coe\n\n@[simp, to_additive] protected lemma map_one {\u03b2} [has_one \u03b1] (f : \u03b1 \u2192 \u03b2) :\n  (1 : with_bot \u03b1).map f = (f 1 : with_bot \u03b2) := rfl\n\n@[norm_cast] lemma coe_nat [add_monoid_with_one \u03b1] (n : \u2115) : ((n : \u03b1) : with_bot \u03b1) = n := rfl\n@[simp] lemma nat_ne_bot [add_monoid_with_one \u03b1] (n : \u2115) : (n : with_bot \u03b1) \u2260 \u22a5 := coe_ne_bot\n@[simp] lemma bot_ne_nat [add_monoid_with_one \u03b1] (n : \u2115) : (\u22a5 : with_bot \u03b1) \u2260 n := bot_ne_coe\n\nsection has_add\nvariables [has_add \u03b1] {a b c d : with_bot \u03b1} {x y : \u03b1}\n\n-- `norm_cast` proves those lemmas, because `with_top`/`with_bot` are reducible\nlemma coe_add (a b : \u03b1) : ((a + b : \u03b1) : with_bot \u03b1) = a + b := rfl\nlemma coe_bit0 : ((bit0 x : \u03b1) : with_bot \u03b1) = bit0 x := rfl\nlemma coe_bit1 [has_one \u03b1] {a : \u03b1} : ((bit1 a : \u03b1) : with_bot \u03b1) = bit1 a := rfl\n\n@[simp] lemma bot_add (a : with_bot \u03b1) : \u22a5 + a = \u22a5 := rfl\n@[simp] lemma add_bot (a : with_bot \u03b1) : a + \u22a5 = \u22a5 := by cases a; refl\n\n@[simp] lemma add_eq_bot : a + b = \u22a5 \u2194 a = \u22a5 \u2228 b = \u22a5 := with_top.add_eq_top\nlemma add_ne_bot : a + b \u2260 \u22a5 \u2194 a \u2260 \u22a5 \u2227 b \u2260 \u22a5 := with_top.add_ne_top\n\nlemma bot_lt_add [has_lt \u03b1] {a b : with_bot \u03b1} : \u22a5 < a + b \u2194 \u22a5 < a \u2227 \u22a5 < b :=\n@with_top.add_lt_top \u03b1\u1d52\u1d48 _ _ _ _\n\nlemma add_eq_coe : a + b = x \u2194 \u2203 (a' b' : \u03b1), \u2191a' = a \u2227 \u2191b' = b \u2227 a' + b' = x := with_top.add_eq_coe\n\n@[simp] lemma add_coe_eq_bot_iff : a + y = \u22a5 \u2194 a = \u22a5 := with_top.add_coe_eq_top_iff\n@[simp] lemma coe_add_eq_bot_iff : \u2191x + b = \u22a5 \u2194 b = \u22a5 := 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 \u03b2] [add_hom_class F \u03b1 \u03b2] (f : F) (a b : with_bot \u03b1) :\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 \u2192+ N) :\n  with_bot M \u2192+ 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 \u03b1]\n\ninstance covariant_class_add_le [covariant_class \u03b1 \u03b1 (+) (\u2264)] :\n  covariant_class (with_bot \u03b1) (with_bot \u03b1) (+) (\u2264) :=\n@order_dual.covariant_class_add_le (with_top \u03b1\u1d52\u1d48) _ _ _\n\ninstance covariant_class_swap_add_le [covariant_class \u03b1 \u03b1 (swap (+)) (\u2264)] :\n  covariant_class (with_bot \u03b1) (with_bot \u03b1) (swap (+)) (\u2264) :=\n@order_dual.covariant_class_swap_add_le (with_top \u03b1\u1d52\u1d48) _ _ _\n\ninstance contravariant_class_add_lt [contravariant_class \u03b1 \u03b1 (+) (<)] :\n  contravariant_class (with_bot \u03b1) (with_bot \u03b1) (+) (<) :=\n@order_dual.contravariant_class_add_lt (with_top \u03b1\u1d52\u1d48) _ _ _\n\ninstance contravariant_class_swap_add_lt [contravariant_class \u03b1 \u03b1 (swap (+)) (<)] :\n  contravariant_class (with_bot \u03b1) (with_bot \u03b1) (swap (+)) (<) :=\n@order_dual.contravariant_class_swap_add_lt (with_top \u03b1\u1d52\u1d48) _ _ _\n\nprotected lemma le_of_add_le_add_left [contravariant_class \u03b1 \u03b1 (+) (\u2264)] (ha : a \u2260 \u22a5)\n  (h : a + b \u2264 a + c) : b \u2264 c :=\n@with_top.le_of_add_le_add_left \u03b1\u1d52\u1d48 _ _ _ _ _ _ ha h\n\nprotected lemma le_of_add_le_add_right [contravariant_class \u03b1 \u03b1 (swap (+)) (\u2264)] (ha : a \u2260 \u22a5)\n  (h : b + a \u2264 c + a) : b \u2264 c :=\n@with_top.le_of_add_le_add_right \u03b1\u1d52\u1d48 _ _ _ _ _ _ ha h\n\nprotected lemma add_lt_add_left [covariant_class \u03b1 \u03b1 (+) (<)] (ha : a \u2260 \u22a5) (h : b < c) :\n  a + b < a + c :=\n@with_top.add_lt_add_left \u03b1\u1d52\u1d48 _ _ _ _ _ _ ha h\n\nprotected lemma add_lt_add_right [covariant_class \u03b1 \u03b1 (swap (+)) (<)] (ha : a \u2260 \u22a5) (h : b < c) :\n  b + a < c + a :=\n@with_top.add_lt_add_right \u03b1\u1d52\u1d48 _ _ _ _ _ _ ha h\n\nprotected lemma add_le_add_iff_left [covariant_class \u03b1 \u03b1 (+) (\u2264)] [contravariant_class \u03b1 \u03b1 (+) (\u2264)]\n  (ha : a \u2260 \u22a5) : a + b \u2264 a + c \u2194 b \u2264 c :=\n\u27e8with_bot.le_of_add_le_add_left ha, \u03bb h, add_le_add_left h a\u27e9\n\nprotected lemma add_le_add_iff_right [covariant_class \u03b1 \u03b1 (swap (+)) (\u2264)]\n  [contravariant_class \u03b1 \u03b1 (swap (+)) (\u2264)] (ha : a \u2260 \u22a5) : b + a \u2264 c + a \u2194 b \u2264 c :=\n\u27e8with_bot.le_of_add_le_add_right ha, \u03bb h, add_le_add_right h a\u27e9\n\nprotected lemma add_lt_add_iff_left [covariant_class \u03b1 \u03b1 (+) (<)] [contravariant_class \u03b1 \u03b1 (+) (<)]\n  (ha : a \u2260 \u22a5) : a + b < a + c \u2194 b < c :=\n\u27e8lt_of_add_lt_add_left, with_bot.add_lt_add_left ha\u27e9\n\nprotected lemma add_lt_add_iff_right [covariant_class \u03b1 \u03b1 (swap (+)) (<)]\n  [contravariant_class \u03b1 \u03b1 (swap (+)) (<)] (ha : a \u2260 \u22a5) : b + a < c + a \u2194 b < c :=\n\u27e8lt_of_add_lt_add_right, with_bot.add_lt_add_right ha\u27e9\n\nprotected lemma add_lt_add_of_le_of_lt [covariant_class \u03b1 \u03b1 (+) (<)]\n  [covariant_class \u03b1 \u03b1 (swap (+)) (\u2264)] (hb : b \u2260 \u22a5) (hab : a \u2264 b) (hcd : c < d) : a + c < b + d :=\n@with_top.add_lt_add_of_le_of_lt \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ hb hab hcd\n\nprotected lemma add_lt_add_of_lt_of_le [covariant_class \u03b1 \u03b1 (+) (\u2264)]\n  [covariant_class \u03b1 \u03b1 (swap (+)) (<)] (hd : d \u2260 \u22a5) (hab : a < b) (hcd : c \u2264 d) : a + c < b + d :=\n@with_top.add_lt_add_of_lt_of_le \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ hd hab hcd\n\nend has_add\n\ninstance [ordered_add_comm_monoid \u03b1] : ordered_add_comm_monoid (with_bot \u03b1) :=\n{ add_le_add_left := \u03bb 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 \u03b1] : linear_ordered_add_comm_monoid (with_bot \u03b1) :=\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": "set_option pp.motives.pi false\n\n#print Nat.add\n\nset_option pp.motives.pi true\n\n#print Nat.add\n\ntheorem ex : \u2200 {\u03b1 \u03b2 : Sort u} (h : \u03b1 = \u03b2) (a : \u03b1), cast h a \u2245 a\n  | \u03b1, _, rfl, a => HEq.refl a\n\nset_option pp.motives.nonConst false\n\n#print ex\n\nset_option pp.motives.nonConst true\n\n#print ex\n\nnoncomputable def fact (n : Nat) : Nat :=\n  Nat.recOn n 1 (fun n acc => (n+1)*acc)\n\nset_option pp.motives.all false\n\n#print fact\n\nset_option pp.motives.all true\n\n#print fact\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/tests/lean/ppMotives.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.679178686187839, "lm_q1q2_score": 0.49651940496027575}}
{"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 \u00d7 D` when `C` and `D` are categories.\n\nWe define:\n* `sectl C Z` : the functor `C \u2964 C \u00d7 D` given by `X \u21a6 \u27e8X, Z\u27e9`\n* `sectr Z D` : the functor `D \u2964 C \u00d7 D` given by `Y \u21a6 \u27e8Z, Y\u27e9`\n* `fst`       : the functor `\u27e8X, Y\u27e9 \u21a6 X`\n* `snd`       : the functor `\u27e8X, Y\u27e9 \u21a6 Y`\n* `swap`      : the functor `C \u00d7 D \u2964 D \u00d7 C` given by `\u27e8X, Y\u27e9 \u21a6 \u27e8Y, X\u27e9`\n    (and the fact this is an equivalence)\n\nWe further define `evaluation : C \u2964 (C \u2964 D) \u2964 D` and `evaluationUncurried : C \u00d7 (C \u2964 D) \u2964 D`,\nand products of functors and natural transformations, written `F.prod G` and `\u03b1.prod \u03b2`.\n-/\n\n\nnamespace CategoryTheory\n\n-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation\nuniverse v\u2081 v\u2082 v\u2083 v\u2084 u\u2081 u\u2082 u\u2083 u\u2084\n\nsection\n\nvariable (C : Type u\u2081) [Category.{v\u2081} C] (D : Type u\u2082) [Category.{v\u2082} 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\u2081 v\u2082} (C \u00d7 D)\n    where\n  Hom X Y := (X.1 \u27f6 Y.1) \u00d7 (X.2 \u27f6 Y.2)\n  id X := \u27e8\ud835\udfd9 X.1, \ud835\udfd9 X.2\u27e9\n  comp f g := (f.1 \u226b g.1, f.2 \u226b 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) : \ud835\udfd9 (X, Y) = (\ud835\udfd9 X, \ud835\udfd9 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) \u27f6 (Q, T)) (g : (Q, T) \u27f6 (R, U)) :\n    f \u226b g = (f.1 \u226b g.1, f.2 \u226b 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) \u27f6 (Q, T)} :\n    IsIso f \u2194 IsIso f.1 \u2227 IsIso f.2 := by\n  constructor\n  \u00b7 rintro \u27e8g, hfg, hgf\u27e9\n    simp at hfg hgf\n    rcases hfg with \u27e8hfg\u2081, hfg\u2082\u27e9\n    rcases hgf with \u27e8hgf\u2081, hgf\u2082\u27e9\n    exact \u27e8\u27e8\u27e8g.1, hfg\u2081, hgf\u2081\u27e9\u27e9, \u27e8\u27e8g.2, hfg\u2082, hgf\u2082\u27e9\u27e9\u27e9\n  \u00b7 rintro \u27e8\u27e8g\u2081, hfg\u2081, hgf\u2081\u27e9, \u27e8g\u2082, hfg\u2082, hgf\u2082\u27e9\u27e9\n    dsimp at hfg\u2081 hgf\u2081 hfg\u2082 hgf\u2082\n    refine' \u27e8\u27e8(g\u2081, g\u2082), _, _\u27e9\u27e9\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 \u00d7 D) : (X.1, X.2) \u2245 X\n    where\n  hom := (\ud835\udfd9 _, \ud835\udfd9 _)\n  inv := (\ud835\udfd9 _, \ud835\udfd9 _)\n#align category_theory.prod.eta_iso CategoryTheory.prod.etaIso\n\n/-- Construct an isomorphism in `C \u00d7 D` out of two isomorphisms in `C` and `D`. -/\n@[simps]\ndef Iso.prod {P Q : C} {S T : D} (f : P \u2245 Q) (g : S \u2245 T) : (P, S) \u2245 (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\u2081) [Category.{v\u2081} C] (D : Type u\u2081) [Category.{v\u2081} 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 \u00d7 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 \u2964 C \u00d7 D` given by `X \u21a6 (X, Z)`. -/\n@[simps]\ndef sectl (C : Type u\u2081) [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} D] (Z : D) : C \u2964 C \u00d7 D\n    where\n  obj X := (X, Z)\n  map f := (f, \ud835\udfd9 Z)\n#align category_theory.prod.sectl CategoryTheory.Prod.sectl\n\n/-- `sectr Z D` is the functor `D \u2964 C \u00d7 D` given by `Y \u21a6 (Z, Y)` . -/\n@[simps]\ndef sectr {C : Type u\u2081} [Category.{v\u2081} C] (Z : C) (D : Type u\u2082) [Category.{v\u2082} D] : D \u2964 C \u00d7 D\n    where\n  obj X := (Z, X)\n  map f := (\ud835\udfd9 Z, f)\n#align category_theory.prod.sectr CategoryTheory.Prod.sectr\n\nvariable (C : Type u\u2081) [Category.{v\u2081} C] (D : Type u\u2082) [Category.{v\u2082} D]\n\n/-- `fst` is the functor `(X, Y) \u21a6 X`. -/\n@[simps]\ndef fst : C \u00d7 D \u2964 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) \u21a6 Y`. -/\n@[simps]\ndef snd : C \u00d7 D \u2964 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 \u00d7 D \u2964 D \u00d7 C`. -/\n@[simps]\ndef swap : C \u00d7 D \u2964 D \u00d7 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 \u22d9 swap D C \u2245 \ud835\udfed (C \u00d7 D)\n    where\n  hom := { app := fun X => \ud835\udfd9 X }\n  inv := { app := fun X => \ud835\udfd9 X }\n#align category_theory.prod.symmetry CategoryTheory.Prod.symmetry\n\n/-- The equivalence, given by swapping factors, between `C \u00d7 D` and `D \u00d7 C`.\n-/\n@[simps!]\ndef braiding : C \u00d7 D \u224c D \u00d7 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\u2081) [Category.{v\u2081} C] (D : Type u\u2082) [Category.{v\u2082} 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 \u2964 (C \u2964 D) \u2964 D\n    where\n  obj X :=\n    { obj := fun F => F.obj X\n      map := fun \u03b1 => \u03b1.app X }\n  map {X} {Y} f :=\n    { app := fun F => F.map f\n      naturality := fun {F} {G} \u03b1 => Eq.symm (\u03b1.naturality f) }\n#align category_theory.evaluation CategoryTheory.evaluation\n\n/-- The \"evaluation of `F` at `X`\" functor,\nas a functor `C \u00d7 (C \u2964 D) \u2964 D`.\n-/\n@[simps]\ndef evaluationUncurried : C \u00d7 (C \u2964 D) \u2964 D\n    where\n  obj p := p.2.obj p.1\n  map := fun {x} {y} f => x.2.map f.1 \u226b 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 [\u2190 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 \u22d9 (evaluation C D).obj X \u2245 \ud835\udfed 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\u2081} [Category.{v\u2081} A] {B : Type u\u2082} [Category.{v\u2082} B] {C : Type u\u2083}\n  [Category.{v\u2083} C] {D : Type u\u2084} [Category.{v\u2084} D]\n\nnamespace Functor\n\n/-- The cartesian product of two functors. -/\n@[simps]\ndef prod (F : A \u2964 B) (G : C \u2964 D) : A \u00d7 C \u2964 B \u00d7 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 \u00d7 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 \u2964 B) (G : A \u2964 C) : A \u2964 B \u00d7 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 \u2964 B) (G : A \u2964 C) : F.prod' G \u22d9 CategoryTheory.Prod.fst B C \u2245 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 \u2964 B) (G : A \u2964 C) : F.prod' G \u22d9 CategoryTheory.Prod.snd B C \u2245 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 \u2964 C \u00d7 C :=\n  (\ud835\udfed C).prod' (\ud835\udfed 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 \u27f6 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 \u2964 B} {H I : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) : F.prod H \u27f6 G.prod I\n    where\n  app X := (\u03b1.app X.1, \u03b2.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 `\u03b1 \u00d7 \u03b2`;\n   use instead `\u03b1.prod \u03b2` or `NatTrans.prod \u03b1 \u03b2`. -/\nend NatTrans\n\n/-- `F.flip` composed with evaluation is the same as evaluating `F`. -/\n@[simps!]\ndef flipCompEvaluation (F : A \u2964 B \u2964 C) (a) : F.flip \u22d9 (evaluation _ _).obj a \u2245 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 \u2964 B) \u00d7 (A \u2964 C) \u2964 A \u2964 B \u00d7 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 \u2964 B \u00d7 C) \u2964 (A \u2964 B) \u00d7 (A \u2964 C)\n    where\n  obj F := \u27e8F \u22d9 CategoryTheory.Prod.fst B C, F \u22d9 CategoryTheory.Prod.snd B C\u27e9\n  map \u03b1 :=\n    \u27e8{  app := fun X => (\u03b1.app X).1\n        naturality := fun X Y f => by\n          simp only [Functor.comp_map, Prod.fst_map, \u2190 prod_comp_fst, \u03b1.naturality] },\n      { app := fun X => (\u03b1.app X).2\n        naturality := fun X Y f => by\n          simp only [Functor.comp_map, Prod.snd_map, \u2190 prod_comp_snd, \u03b1.naturality] }\u27e9\n#align category_theory.functor_prod_to_prod_functor CategoryTheory.functorProdToProdFunctor\n\n/-- The unit isomorphism for `functorProdFunctorEquiv` -/\n@[simps!]\ndef functorProdFunctorEquivUnitIso :\n    \ud835\udfed _ \u2245 prodFunctorToFunctorProd A B C \u22d9 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 \u03b1 => 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 \u22d9 prodFunctorToFunctorProd A B C \u2245 \ud835\udfed _ :=\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 \u2964 B) \u00d7 (A \u2964 C)` and `A \u2964 (B \u00d7 C)` -/\n@[simps]\ndef functorProdFunctorEquiv : (A \u2964 B) \u00d7 (A \u2964 C) \u224c A \u2964 B \u00d7 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 \u2964 Type u) : cone F :=\n{ X := F.sections,\n  \u03c0 := { app := \u03bb 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 \u2964 Type u) : is_limit (limit_cone F) :=\n{ lift := \u03bb s v, \u27e8\u03bb j, s.\u03c0.app j v, \u03bb j j' f, congr_fun (cone.w s f) _\u27e9,\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 := \u03bb J \ud835\udca5, by exactI\n  { has_limit := \u03bb 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 \u2964 Type u} {c : cone F} (t : is_limit c) :\n  c.X \u2243 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 \u2964 Type u} {c : cone F} (t : is_limit c) (j : J) (x : c.X) :\n  (((is_limit_equiv_sections t) x) : \u03a0 j, F.obj j) j = c.\u03c0.app j x :=\nrfl\n\n@[simp]\nlemma is_limit_equiv_sections_symm_apply\n  {F : J \u2964 Type u} {c : cone F} (t : is_limit c) (x : F.sections) (j : J) :\n  c.\u03c0.app j ((is_limit_equiv_sections t).symm x) = (x : \u03a0 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 \u2964 Type u) : (limit F : Type u) \u2243 F.sections :=\nis_limit_equiv_sections (limit.is_limit _)\n\n@[simp]\nlemma limit_equiv_sections_apply (F : J \u2964 Type u) (x : limit F) (j : J) :\n  (((limit_equiv_sections F) x) : \u03a0 j, F.obj j) j = limit.\u03c0 F j x :=\nrfl\n\n@[simp]\nlemma limit_equiv_sections_symm_apply (F : J \u2964 Type u) (x : F.sections) (j : J) :\n  limit.\u03c0 F j ((limit_equiv_sections F).symm x) = (x : \u03a0 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 : \u03a0 j, F.obj j`\nwhich are \"coherent\": `\u2200 (j j') (f : j \u27f6 j'), F.map f (x j) = x j'`.\n-/\n@[ext]\nnoncomputable\ndef limit.mk (F : J \u2964 Type u) (x : \u03a0 j, F.obj j) (h : \u2200 (j j') (f : j \u27f6 j'), F.map f (x j) = x j') :\n  (limit F : Type u) :=\n(limit_equiv_sections F).symm \u27e8x, h\u27e9\n\n@[simp]\nlemma limit.\u03c0_mk\n  (F : J \u2964 Type u) (x : \u03a0 j, F.obj j) (h : \u2200 (j j') (f : j \u27f6 j'), F.map f (x j) = x j') (j) :\n  limit.\u03c0 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 \u2964 Type u) (x y : limit F) (w : \u2200 j, limit.\u03c0 F j x = limit.\u03c0 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 \u2964 Type u) (x y : limit F) :\n  x = y \u2194 (\u2200 j, limit.\u03c0 F j x = limit.\u03c0 F j y) :=\n\u27e8\u03bb t _, t \u25b8 rfl, limit_ext _ _ _\u27e9\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 \u2964 Type u} {j j' : J} {x : limit F} (f : j \u27f6 j') :\n  F.map f (limit.\u03c0 F j x) = limit.\u03c0 F j' x :=\ncongr_fun (limit.w F f) x\n\n@[simp]\nlemma limit.lift_\u03c0_apply (F : J \u2964 Type u) (s : cone F) (j : J) (x : s.X) :\n  limit.\u03c0 F j (limit.lift F s x) = s.\u03c0.app j x :=\ncongr_fun (limit.lift_\u03c0 s j) x\n\n@[simp]\nlemma limit.map_\u03c0_apply {F G : J \u2964 Type u} (\u03b1 : F \u27f6 G) (j : J) (x) :\n  limit.\u03c0 G j (lim_map \u03b1 x) = \u03b1.app j (limit.\u03c0 F j x) :=\ncongr_fun (lim_map_\u03c0 \u03b1 j) x\n\n/--\nThe relation defining the quotient type which implements the colimit of a functor `F : J \u2964 Type u`.\nSee `category_theory.limits.types.quot`.\n-/\ndef quot.rel (F : J \u2964 Type u) : (\u03a3 j, F.obj j) \u2192 (\u03a3 j, F.obj j) \u2192 Prop :=\n(\u03bb p p', \u2203 f : p.1 \u27f6 p'.1, p'.2 = F.map f p.2)\n\n/--\nA quotient type implementing the colimit of a functor `F : J \u2964 Type u`,\nas pairs `\u27e8j, x\u27e9` where `x : F.obj j`, modulo the equivalence relation generated by\n`\u27e8j, x\u27e9 ~ \u27e8j', x'\u27e9` whenever there is a morphism `f : j \u27f6 j'` so `F.map f x = x'`.\n-/\n@[nolint has_inhabited_instance]\ndef quot (F : J \u2964 Type u) : Type u :=\n@quot (\u03a3 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 \u2964 Type u) : cocone F :=\n{ X := quot F,\n  \u03b9 :=\n  { app := \u03bb j x, quot.mk _ \u27e8j, x\u27e9,\n    naturality' := \u03bb j j' f, funext $ \u03bb x, eq.symm (quot.sound \u27e8f, rfl\u27e9) } }\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 \u2964 Type u) : is_colimit (colimit_cocone F) :=\n{ desc := \u03bb s, quot.lift (\u03bb (p : \u03a3 j, F.obj j), s.\u03b9.app p.1 p.2)\n    (assume \u27e8j, x\u27e9 \u27e8j', x'\u27e9 \u27e8f, hf\u27e9, 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 := \u03bb J \ud835\udca5, by exactI\n  { has_colimit := \u03bb 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 \u2964 Type u) : (colimit F : Type u) \u2243 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 \u2964 Type u) (j : J) (x : F.obj j) :\n  (colimit_equiv_quot F).symm (quot.mk _ \u27e8j, x\u27e9) = colimit.\u03b9 F j x :=\nrfl\n\n@[simp]\nlemma colimit_equiv_quot_apply (F : J \u2964 Type u) (j : J) (x : F.obj j) :\n  (colimit_equiv_quot F) (colimit.\u03b9 F j x) = quot.mk _ \u27e8j, x\u27e9 :=\nbegin\n  apply (colimit_equiv_quot F).symm.injective,\n  simp,\nend\n\n@[simp]\nlemma colimit.w_apply {F : J \u2964 Type u} {j j' : J} {x : F.obj j} (f : j \u27f6 j') :\n  colimit.\u03b9 F j' (F.map f x) = colimit.\u03b9 F j x :=\ncongr_fun (colimit.w F f) x\n\n@[simp]\nlemma colimit.\u03b9_desc_apply (F : J \u2964 Type u) (s : cocone F) (j : J) (x : F.obj j) :\n  colimit.desc F s (colimit.\u03b9 F j x) = s.\u03b9.app j x :=\ncongr_fun (colimit.\u03b9_desc s j) x\n\n@[simp]\nlemma colimit.\u03b9_map_apply {F G : J \u2964 Type u} (\u03b1 : F \u27f6 G) (j : J) (x) :\n  colim.map \u03b1 (colimit.\u03b9 F j x) = colimit.\u03b9 G j (\u03b1.app j x) :=\ncongr_fun (colimit.\u03b9_map \u03b1 j) x\n\nlemma colimit_sound\n  {F : J \u2964 Type u} {j j' : J} {x : F.obj j} {x' : F.obj j'} (f : j \u27f6 j') (w : F.map f x = x') :\n  colimit.\u03b9 F j x = colimit.\u03b9 F j' x' :=\nbegin\n  rw [\u2190w],\n  simp,\nend\n\nlemma colimit_sound'\n  {F : J \u2964 Type u} {j j' : J} {x : F.obj j} {x' : F.obj j'} {j'' : J} (f : j \u27f6 j'') (f' : j' \u27f6 j'')\n  (w : F.map f x = F.map f' x') :\n  colimit.\u03b9 F j x = colimit.\u03b9 F j' x' :=\nbegin\n  rw [\u2190colimit.w _ f, \u2190colimit.w _ f'],\n  rw [types_comp_apply, types_comp_apply, w],\nend\n\nlemma colimit_eq {F : J \u2964 Type u } {j j' : J} {x : F.obj j} {x' : F.obj j'}\n  (w : colimit.\u03b9 F j x = colimit.\u03b9 F j' x') : eqv_gen (quot.rel F) \u27e8j, x\u27e9 \u27e8j', x'\u27e9 :=\nbegin\n  apply quot.eq.1,\n  simpa using congr_arg (colimit_equiv_quot F) w,\nend\n\nlemma jointly_surjective (F : J \u2964 Type u) {t : cocone F} (h : is_colimit t)\n  (x : t.X) : \u2203 j y, t.\u03b9.app j y = x :=\nbegin\n  suffices : (\u03bb (x : t.X), ulift.up (\u2203 j y, t.\u03b9.app j y = x)) = (\u03bb _, 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 \u27e8j, y, rfl\u27e9\nend\n\n/-- A variant of `jointly_surjective` for `x : colimit F`. -/\nlemma jointly_surjective' {F : J \u2964 Type u}\n  (x : colimit F) : \u2203 j y, colimit.\u03b9 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 \u2964 Type u)\n\n/--\nAn alternative relation on `\u03a3 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 : \u03a3 j, F.obj j) : Prop :=\n\u2203 k (f : x.1 \u27f6 k) (g : y.1 \u27f6 k), F.map f x.2 = F.map g y.2\n\nprotected lemma r_ge (x y : \u03a3 j, F.obj j) :\n  (\u2203 f : x.1 \u27f6 y.1, y.2 = F.map f x.2) \u2192 filtered_colimit.r F x y :=\n\u03bb \u27e8f, hf\u27e9, \u27e8y.1, f, \ud835\udfd9 y.1, by simp [hf]\u27e9\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 : \u2200 (x : t.X), \u2203 i xi, x = t.\u03b9.app i xi)\n  (hinj : \u2200 i j xi xj, t.\u03b9.app i xi = t.\u03b9.app j xj \u2192\n   \u2203 k (f : i \u27f6 k) (g : j \u27f6 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 \u27e8i, xi, rfl\u27e9,\n      rcases jointly_surjective F (colimit.is_colimit F) b with \u27e8j, xj, rfl\u27e9,\n      change (colimit.\u03b9 F i \u226b colimit.desc F t) xi = (colimit.\u03b9 F j \u226b colimit.desc F t) xj at h,\n      rw [colimit.\u03b9_desc, colimit.\u03b9_desc] at h,\n      rcases hinj i j xi xj h with \u27e8k, f, g, h'\u27e9,\n      change colimit.\u03b9 F i xi = colimit.\u03b9 F j xj,\n      rw [\u2190colimit.w F f, \u2190colimit.w F g],\n      change colimit.\u03b9 F k (F.map f xi) = colimit.\u03b9 F k (F.map g xj),\n      rw h' },\n    { show function.surjective _,\n      intro x,\n      rcases hsurj x with \u27e8i, xi, rfl\u27e9,\n      use colimit.\u03b9 F i xi,\n      simp } },\n  { intro j, apply colimit.\u03b9_desc }\nend\n\nvariables [is_filtered_or_empty J]\n\nprotected lemma r_equiv : equivalence (filtered_colimit.r F) :=\n\u27e8\u03bb x, \u27e8x.1, \ud835\udfd9 x.1, \ud835\udfd9 x.1, rfl\u27e9,\n \u03bb x y \u27e8k, f, g, h\u27e9, \u27e8k, g, f, h.symm\u27e9,\n \u03bb x y z \u27e8k, f, g, h\u27e9 \u27e8k', f', g', h'\u27e9,\n   let \u27e8l, fl, gl, _\u27e9 := is_filtered_or_empty.cocone_objs k k',\n       \u27e8m, n, hn\u27e9 := is_filtered_or_empty.cocone_maps (g \u226b fl) (f' \u226b gl) in\n   \u27e8m, f \u226b fl \u226b n, g' \u226b gl \u226b n, calc\n      F.map (f \u226b fl \u226b n) x.2\n          = F.map (fl \u226b n) (F.map f x.2)  : by simp\n      ... = F.map (fl \u226b n) (F.map g y.2)  : by rw h\n      ... = F.map ((g \u226b fl) \u226b n) y.2      : by simp\n      ... = F.map ((f' \u226b gl) \u226b n) y.2     : by rw hn\n      ... = F.map (gl \u226b n) (F.map f' y.2) : by simp\n      ... = F.map (gl \u226b n) (F.map g' z.2) : by rw h'\n      ... = F.map (g' \u226b gl \u226b n) z.2       : by simp\u27e9\u27e9\n\nprotected lemma r_eq :\n  filtered_colimit.r F = eqv_gen (\u03bb x y, \u2203 f : x.1 \u27f6 y.1, y.2 = F.map f x.2) :=\nbegin\n  apply le_antisymm,\n  { rintros \u27e8i, x\u27e9 \u27e8j, y\u27e9 \u27e8k, f, g, h\u27e9,\n    exact eqv_gen.trans _ \u27e8k, F.map f x\u27e9 _ (eqv_gen.rel _ _ \u27e8f, rfl\u27e9)\n      (eqv_gen.symm _ _ (eqv_gen.rel _ _ \u27e8g, h\u27e9)) },\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).\u03b9.app i xi = (colimit_cocone F).\u03b9.app j xj \u2194\n    \u2203 k (f : i \u27f6 k) (g : j \u27f6 k), F.map f xi = F.map g xj :=\nbegin\n  change quot.mk _ _ = quot.mk _ _ \u2194 _,\n  rw [quot.eq, quot.rel, \u2190filtered_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.\u03b9.app i xi = t.\u03b9.app j xj \u2194 \u2203 k (f : i \u27f6 k) (g : j \u27f6 k), F.map f xi = F.map g xj :=\nlet t' := colimit_cocone F,\n    e : t' \u2245 t := is_colimit.unique_up_to_iso (colimit_cocone_is_colimit F) ht,\n    e' : t'.X \u2245 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 \u2190e.hom.w; refl\nend\n\nlemma colimit_eq_iff {i j : J} {xi : F.obj i} {xj : F.obj j} :\n  colimit.\u03b9 F i xi = colimit.\u03b9 F j xj \u2194 \u2203 k (f : i \u27f6 k) (g : j \u27f6 k), F.map f xi = F.map g xj :=\nis_colimit_eq_iff _ (colimit.is_colimit F)\n\nend filtered_colimit\n\nvariables {\u03b1 \u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2)\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 \u03b1] : inhabited (image f) :=\n{ default := \u27e8f (default \u03b1), \u27e8_, rfl\u27e9\u27e9 }\n\n/-- the inclusion of `image f` into the target -/\ndef image.\u03b9 : image f \u27f6 \u03b2 := subtype.val\n\ninstance : mono (image.\u03b9 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 \u27f6 F'.I :=\n(\u03bb x, F'.e (classical.indefinite_description _ x.2).1 : image f \u2192 F'.I)\n\nlemma image.lift_fac (F' : mono_factorisation f) : image.lift F' \u226b F'.m = image.\u03b9 f :=\nbegin\n  ext x,\n  change (F'.e \u226b 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.\u03b9 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 \u27e8_, is_image f\u27e9\n\ninstance : has_images (Type u) :=\n{ has_image := by apply_instance }\n\ninstance : has_image_maps (Type u) :=\n{ has_image_map := \u03bb f g st, has_image_map.transport st (mono_factorisation f.hom) (is_image g.hom)\n    (\u03bb x, \u27e8st.right x.1, \u27e8st.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\u27e9\u27e9) 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 (\u03b1 : Type u) : Nat \u2192 Type u where\n  | nil  : Vec \u03b1 0\n  | cons : \u03b1 \u2192 Vec \u03b1 n \u2192 Vec \u03b1 (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 `\u03b1` to the type `\u03a3 a : A, B a \u27f9 \u03b1`, with `A : Type` and\n`B : A \u2192 typevec n`. They interact well with Lean's inductive definitions because\nthey guarantee that occurrences of `\u03b1` are positive.\n-/\n\n/--\nmultivariate polynomial functors\n-/\nstructure mvpfunctor (n : \u2115) where\n  A : Type u\n  B : A \u2192 typevec n\n\nnamespace mvpfunctor\n\n\n/-- Applying `P` to an object of `Type` -/\ndef obj {n : \u2115} (P : mvpfunctor n) (\u03b1 : typevec n) := sigma fun (a : A P) => typevec.arrow (B P a) \u03b1\n\n/-- Applying `P` to a morphism of `Type` -/\ndef map {n : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} {\u03b2 : typevec n} (f : typevec.arrow \u03b1 \u03b2) :\n    obj P \u03b1 \u2192 obj P \u03b2 :=\n  fun (_x : obj P \u03b1) => sorry\n\nprotected instance inhabited {n : \u2115} : Inhabited (mvpfunctor n) :=\n  { default := mk Inhabited.default fun (_x : Inhabited.default) => Inhabited.default }\n\nprotected instance obj.inhabited {n : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} [Inhabited (A P)]\n    [(i : fin2 n) \u2192 Inhabited (\u03b1 i)] : Inhabited (obj P \u03b1) :=\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 : \u2115} (P : mvpfunctor n) : mvfunctor (obj P) :=\n  mvfunctor.mk (map P)\n\ntheorem map_eq {n : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} {\u03b2 : typevec n} (g : typevec.arrow \u03b1 \u03b2)\n    (a : A P) (f : typevec.arrow (B P a) \u03b1) :\n    mvfunctor.map g (sigma.mk a f) = sigma.mk a (typevec.comp g f) :=\n  rfl\n\ntheorem id_map {n : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} (x : obj P \u03b1) :\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) \u03b1) =>\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 : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} {\u03b2 : typevec n} {\u03b3 : typevec n}\n    (f : typevec.arrow \u03b1 \u03b2) (g : typevec.arrow \u03b2 \u03b3) (x : obj P \u03b1) :\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 : \u2115} (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 : \u2115) (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 : \u2115) {A : Type u} (x : A) {\u03b1 : typevec n} : obj (const n A) \u03b1 :=\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 : \u2115} {A : Type u} {\u03b1 : typevec n} (x : obj (const n A) \u03b1) : A := sigma.fst x\n\n@[simp] theorem const.get_map {n : \u2115} {A : Type u} {\u03b1 : typevec n} {\u03b2 : typevec n}\n    (f : typevec.arrow \u03b1 \u03b2) (x : obj (const n A) \u03b1) : 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) \u03b1) =>\n      Eq.refl (const.get (mvfunctor.map f (sigma.mk x_fst x_snd)))\n\n@[simp] theorem const.get_mk {n : \u2115} {A : Type u} {\u03b1 : 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 : \u2115} {A : Type u} {\u03b1 : typevec n} (x : obj (const n A) \u03b1) :\n    const.mk n (const.get x) = x :=\n  sorry\n\n/-- Functor composition on polynomial functors -/\ndef comp {n : \u2115} {m : \u2115} (P : mvpfunctor n) (Q : fin2 n \u2192 mvpfunctor m) : mvpfunctor m :=\n  mk (sigma fun (a\u2082 : A P) => (i : fin2 n) \u2192 B P a\u2082 i \u2192 A (Q i))\n    fun (a : sigma fun (a\u2082 : A P) => (i : fin2 n) \u2192 B P a\u2082 i \u2192 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 : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m} {\u03b1 : typevec m}\n    (x : obj P fun (i : fin2 n) => obj (Q i) \u03b1) : obj (comp P Q) \u03b1 :=\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 : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m} {\u03b1 : typevec m}\n    (x : obj (comp P Q) \u03b1) : obj P fun (i : fin2 n) => obj (Q i) \u03b1 :=\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 : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m} {\u03b1 : typevec m}\n    {\u03b2 : typevec m} (f : typevec.arrow \u03b1 \u03b2) (x : obj (comp P Q) \u03b1) :\n    comp.get (mvfunctor.map f x) =\n        mvfunctor.map (fun (i : fin2 n) (x : obj (Q i) \u03b1) => 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) \u03b1) =>\n      Eq.refl (comp.get (mvfunctor.map f (sigma.mk x_fst x_snd)))\n\n@[simp] theorem comp.get_mk {n : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m}\n    {\u03b1 : typevec m} (x : obj P fun (i : fin2 n) => obj (Q i) \u03b1) : comp.get (comp.mk x) = x :=\n  sorry\n\n@[simp] theorem comp.mk_get {n : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m}\n    {\u03b1 : typevec m} (x : obj (comp P Q) \u03b1) : comp.mk (comp.get x) = x :=\n  sorry\n\n/-\nlifting predicates and relations\n-/\n\ntheorem liftp_iff {n : \u2115} {P : mvpfunctor n} {\u03b1 : typevec n} (p : {i : fin2 n} \u2192 \u03b1 i \u2192 Prop)\n    (x : obj P \u03b1) :\n    mvfunctor.liftp p x \u2194\n        \u2203 (a : A P),\n          \u2203 (f : typevec.arrow (B P a) \u03b1),\n            x = sigma.mk a f \u2227 \u2200 (i : fin2 n) (j : B P a i), p (f i j) :=\n  sorry\n\ntheorem liftp_iff' {n : \u2115} {P : mvpfunctor n} {\u03b1 : typevec n} (p : {i : fin2 n} \u2192 \u03b1 i \u2192 Prop)\n    (a : A P) (f : typevec.arrow (B P a) \u03b1) :\n    mvfunctor.liftp p (sigma.mk a f) \u2194 \u2200 (i : fin2 n) (x : B P a i), p (f i x) :=\n  sorry\n\ntheorem liftr_iff {n : \u2115} {P : mvpfunctor n} {\u03b1 : typevec n} (r : {i : fin2 n} \u2192 \u03b1 i \u2192 \u03b1 i \u2192 Prop)\n    (x : obj P \u03b1) (y : obj P \u03b1) :\n    mvfunctor.liftr r x y \u2194\n        \u2203 (a : A P),\n          \u2203 (f\u2080 : typevec.arrow (B P a) \u03b1),\n            \u2203 (f\u2081 : typevec.arrow (B P a) \u03b1),\n              x = sigma.mk a f\u2080 \u2227\n                y = sigma.mk a f\u2081 \u2227 \u2200 (i : fin2 n) (j : B P a i), r (f\u2080 i j) (f\u2081 i j) :=\n  sorry\n\ntheorem supp_eq {n : \u2115} {P : mvpfunctor n} {\u03b1 : typevec n} (a : A P) (f : typevec.arrow (B P a) \u03b1)\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 : \u2115} (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 : \u2115} (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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {\u03b2 : Type u_1} {a : A P}\n    (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 \u03b2) :\n    typevec.arrow (B P a) (\u03b1 ::: \u03b2) :=\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\u00f6nne, 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 | -\u03c0 < im z < \u03c0}` and\n`target = {z | 0 < re z} \u222a {z | im z \u2260 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 \u2102 \u2102 :=\n  LocalHomeomorph.ofContinuousOpen\n    { toFun := exp\n      invFun := log\n      source := { z : \u2102 | z.im \u2208 Ioo (-\u03c0) \u03c0 }\n      target := { z : \u2102 | 0 < z.re } \u222a { z : \u2102 | z.im \u2260 0 }\n      map_source' := by\n        rintro \u27e8x, y\u27e9 \u27e8h\u2081 : -\u03c0 < y, h\u2082 : y < \u03c0\u27e9\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\u2081 h\u2082] using hz\n        rw [mem_set_of_eq, \u2190 of_real_def, exp_of_real_re]\n        exact Real.exp_pos x\n      map_target' := fun z h =>\n        suffices 0 \u2264 z.re \u2228 z.im \u2260 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 : \u2102} (h : 0 < x.re \u2228 x.im \u2260 0) : HasStrictDerivAt log x\u207b\u00b9 x :=\n  have h0 : x \u2260 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 : \u2102} (h : 0 < x.re \u2228 x.im \u2260 0) :\n    HasStrictFderivAt log (x\u207b\u00b9 \u2022 (1 : \u2102 \u2192L[\u211d] \u2102)) 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 : \u2102} (h : 0 < x.re \u2228 x.im \u2260 0) {n : \u2115\u221e} : ContDiffAt \u2102 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 {\u03b1 : Type _} [TopologicalSpace \u03b1] {E : Type _} [NormedAddCommGroup E] [NormedSpace \u2102 E]\n\ntheorem HasStrictFderivAt.clog {f : E \u2192 \u2102} {f' : E \u2192L[\u2102] \u2102} {x : E} (h\u2081 : HasStrictFderivAt f f' x)\n    (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 0) : HasStrictFderivAt (fun t => log (f t)) ((f x)\u207b\u00b9 \u2022 f') x :=\n  (hasStrictDerivAt_log h\u2082).comp_hasStrictFderivAt x h\u2081\n#align has_strict_fderiv_at.clog HasStrictFderivAt.clog\n\ntheorem HasStrictDerivAt.clog {f : \u2102 \u2192 \u2102} {f' x : \u2102} (h\u2081 : HasStrictDerivAt f f' x)\n    (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 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\u2082).comp x h\u2081\n#align has_strict_deriv_at.clog HasStrictDerivAt.clog\n\ntheorem HasStrictDerivAt.clog_real {f : \u211d \u2192 \u2102} {x : \u211d} {f' : \u2102} (h\u2081 : HasStrictDerivAt f f' x)\n    (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 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\u2082).comp_hasStrictDerivAt x h\u2081\n#align has_strict_deriv_at.clog_real HasStrictDerivAt.clog_real\n\ntheorem HasFderivAt.clog {f : E \u2192 \u2102} {f' : E \u2192L[\u2102] \u2102} {x : E} (h\u2081 : HasFderivAt f f' x)\n    (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 0) : HasFderivAt (fun t => log (f t)) ((f x)\u207b\u00b9 \u2022 f') x :=\n  (hasStrictDerivAt_log h\u2082).HasDerivAt.comp_hasFderivAt x h\u2081\n#align has_fderiv_at.clog HasFderivAt.clog\n\ntheorem HasDerivAt.clog {f : \u2102 \u2192 \u2102} {f' x : \u2102} (h\u2081 : HasDerivAt f f' x)\n    (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 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\u2082).HasDerivAt.comp x h\u2081\n#align has_deriv_at.clog HasDerivAt.clog\n\ntheorem HasDerivAt.clog_real {f : \u211d \u2192 \u2102} {x : \u211d} {f' : \u2102} (h\u2081 : HasDerivAt f f' x)\n    (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 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\u2082).HasFderivAt.comp_hasDerivAt x h\u2081\n#align has_deriv_at.clog_real HasDerivAt.clog_real\n\ntheorem DifferentiableAt.clog {f : E \u2192 \u2102} {x : E} (h\u2081 : DifferentiableAt \u2102 f x)\n    (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 0) : DifferentiableAt \u2102 (fun t => log (f t)) x :=\n  (h\u2081.HasFderivAt.clog h\u2082).DifferentiableAt\n#align differentiable_at.clog DifferentiableAt.clog\n\ntheorem HasFderivWithinAt.clog {f : E \u2192 \u2102} {f' : E \u2192L[\u2102] \u2102} {s : Set E} {x : E}\n    (h\u2081 : HasFderivWithinAt f f' s x) (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 0) :\n    HasFderivWithinAt (fun t => log (f t)) ((f x)\u207b\u00b9 \u2022 f') s x :=\n  (hasStrictDerivAt_log h\u2082).HasDerivAt.comp_hasFderivWithinAt x h\u2081\n#align has_fderiv_within_at.clog HasFderivWithinAt.clog\n\ntheorem HasDerivWithinAt.clog {f : \u2102 \u2192 \u2102} {f' x : \u2102} {s : Set \u2102} (h\u2081 : HasDerivWithinAt f f' s x)\n    (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 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\u2082).HasDerivAt.comp_hasDerivWithinAt x h\u2081\n#align has_deriv_within_at.clog HasDerivWithinAt.clog\n\ntheorem HasDerivWithinAt.clog_real {f : \u211d \u2192 \u2102} {s : Set \u211d} {x : \u211d} {f' : \u2102}\n    (h\u2081 : HasDerivWithinAt f f' s x) (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 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\u2082).HasFderivAt.comp_hasDerivWithinAt x h\u2081\n#align has_deriv_within_at.clog_real HasDerivWithinAt.clog_real\n\ntheorem DifferentiableWithinAt.clog {f : E \u2192 \u2102} {s : Set E} {x : E}\n    (h\u2081 : DifferentiableWithinAt \u2102 f s x) (h\u2082 : 0 < (f x).re \u2228 (f x).im \u2260 0) :\n    DifferentiableWithinAt \u2102 (fun t => log (f t)) s x :=\n  (h\u2081.HasFderivWithinAt.clog h\u2082).DifferentiableWithinAt\n#align differentiable_within_at.clog DifferentiableWithinAt.clog\n\ntheorem DifferentiableOn.clog {f : E \u2192 \u2102} {s : Set E} (h\u2081 : DifferentiableOn \u2102 f s)\n    (h\u2082 : \u2200 x \u2208 s, 0 < (f x).re \u2228 (f x).im \u2260 0) : DifferentiableOn \u2102 (fun t => log (f t)) s :=\n  fun x hx => (h\u2081 x hx).clog (h\u2082 x hx)\n#align differentiable_on.clog DifferentiableOn.clog\n\ntheorem Differentiable.clog {f : E \u2192 \u2102} (h\u2081 : Differentiable \u2102 f)\n    (h\u2082 : \u2200 x, 0 < (f x).re \u2228 (f x).im \u2260 0) : Differentiable \u2102 fun t => log (f t) := fun x =>\n  (h\u2081 x).clog (h\u2082 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  \u27e8@ContinuousMap.toFun, @ContinuousMap.id, @ContinuousMap.comp, @ContinuousMap.coe_injective\u27e9\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) : (\ud835\udfd9 X : X \u2192 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 \u27f6 Y) (g : Y \u27f6 Z) (x : X) :\n    (f \u226b g : X \u2192 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  \u27e8X\u27e9\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  \u27e8TopCat.of Empty\u27e9\n\n/-- The discrete topology on any type. -/\ndef discrete : Type u \u2964 TopCat.{u} where\n  obj X := \u27e8X, \u22a5\u27e9\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  \u27e8rfl\u27e9\n\n/-- The trivial topology on any type. -/\ndef trivial : Type u \u2964 TopCat.{u} where\n  obj X := \u27e8X, \u22a4\u27e9\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 \u2243\u209c Y) : X \u2245 Y\n    where\n  Hom := \u27e8f\u27e9\n  inv := \u27e8f.symm\u27e9\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 \u2245 Y) : X \u2243\u209c 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 \u2243\u209c 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 \u2245 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 \u27f6 Y) (g : Y \u27f6 Z) [IsIso g] :\n    OpenEmbedding (f \u226b g) \u2194 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 \u27f6 Y) (g : Y \u27f6 Z) [IsIso f] :\n    OpenEmbedding (f \u226b g) \u2194 OpenEmbedding g :=\n  by\n  constructor\n  \u00b7 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  \u00b7 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 : \u03a0 \u0393 : seqt, node \u0393\n| \u0393 := \nmatch get_contra_seqt \u0393 with \n| inl w := contra_rule_seqt w.2\n| inr no_contra := \n  match get_and_seqt \u0393 with\n  | inl p := \n  let \u0394 := p.1.1 :: p.1.2 :: \u0393.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 \u27e8_,_,_,_\u27e9 \u0393, \n  begin apply split_lt_and_seqt, exact p.2 end,\n  let d_delta : node \u27e8\u0394, \u0393.hdld,_,_\u27e9 := tableau (and_child \u0393 p.2) in \n  and_rule_seqt inst d_delta\n  | inr no_and := \n    match get_or_seqt \u0393 with\n    | inl p := \n    let \u0393\u2081 := p.1.1 :: \u0393.main.erase (nnf.or p.val.1 p.val.2) in \n    let \u0393\u2082 := p.1.2 :: \u0393.main.erase (nnf.or p.val.1 p.val.2) in \n    let inst := or_instance_seqt.cons p.2 in\n    have h\u2081 : prod.measure_lex seqt_size \u27e8\u0393\u2081, \u0393.hdld,_,_\u27e9 \u0393, \n    begin apply split_lt_or_seqt_left, exact p.2 end,\n    have h\u2082 : prod.measure_lex seqt_size \u27e8\u0393\u2082, \u0393.hdld,_,_\u27e9 \u0393, \n    begin apply split_lt_or_seqt_right, exact p.2 end,\n    let d_\u0393\u2081 : node \u27e8\u0393\u2081, \u0393.hdld,_,_\u27e9 := tableau (or_child_left \u0393 p.2) in \n    match d_\u0393\u2081 with\n    | closed pr := or_rule_seqt inst (closed pr) (tableau (or_child_right \u0393 p.2))\n    | open_ w := open_rule_seqt inst w.2\n    end\n    | inr no_or := \n      match get_box_seqt \u0393 with\n      | inl p := \n      let \u0393\u2081 := p.1 :: \u0393.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 \u27e8\u0393\u2081, box p.1 :: \u0393.hdld,_,_\u27e9 \u0393, \n      begin apply copy_lt_seqt, exact p.2 end,\n      let d_delta : node \u27e8\u0393\u2081, box p.1 :: \u0393.hdld,_,_\u27e9 := tableau (box_child \u0393 p.2) in\n      copy_rule_seqt inst d_delta\n      | inr no_box := \n        match get_dia_seqt \u0393 with\n        | inl p := \n        let ma : modal_applicable \u0393 := \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 \u0393.main,\n             hv := \u03bb n, get_var_iff,\n             \u03c6 := p.1,\n             ex := p.2} in \n        let l := @dia_rule_seqt (\u03bb \u0394, prod.measure_lex seqt_size \u0394 \u0393) \n                 (\u03bb x h, tableau x) (unmodal_seqt \u0393) \n                 (unmodal_seqt_size \u0393) 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 \u0393 := \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 \u0393.main,\n           hv := \u03bb 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 := \u03bb _ _, `[exact \u27e8_, prod.measure_lex_wf seqt_size\u27e9], dec_tac := `[assumption]}\n\n@[simp] def mk_seqt (\u0393 : list nnf) : seqt :=\n{ main := \u0393,\n  hdld := [],\n  pmain := begin \n             intros v l \u03c6 h hb hall, exfalso, \n             apply list.not_mem_nil, exact hb \n           end,\n  phdld := box_only_nil }\n\ndef is_sat (\u0393 : list nnf) : bool :=\nmatch tableau (mk_seqt \u0393) with\n| closed _ := ff\n| open_ _  := tt\nend\n\ntheorem correctness (\u0393 : list nnf) : is_sat \u0393 = tt \u2194 \u2203 (st : Type) (k : KT st) s, sat k s \u0393 := \nbegin\n  cases h : is_sat \u0393,\n  constructor,\n  {intro, contradiction},\n  {intro hsat, cases eq : tableau (mk_seqt \u0393), \n   rcases hsat with \u27e8w, k, s, hsat\u27e9,\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 \u0393),\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 : \u2115)\n| imp (a b : fml)\n| not (a : fml)\nopen fml\n\ninfixr ` \u2192' `:50 := imp\nlocal notation ` \u00ac' ` := fml.not\n\ninductive prf : fml \u2192 Type\n| axk (p q) : prf (p \u2192' q \u2192' p)\n| axs (p q r) : prf $ (p \u2192' q \u2192' r) \u2192' (p \u2192' q) \u2192' (p \u2192' r)\n| axn (p q) : prf $ (\u00ac'q \u2192' \u00ac'p) \u2192' p \u2192' q\n| amp (p q) : prf (p \u2192' (p \u2192' q) \u2192' q) -- internal modus ponnens, i couldn't prove it, can you?\n| cn (p q r) : prf (q \u2192' r) \u2192 prf (p \u2192' q) \u2192 prf (p \u2192' r)\n| mp (p q) : prf p \u2192 prf (p \u2192' q) \u2192 prf q\n\ntheorem reflex (P : fml) : prf (P \u2192' P) :=\n    begin\n        have R : fml, exact P,\n        let Q : fml := R \u2192' P,\n        have HPQ : prf (P \u2192' Q),\n            change prf (P \u2192' (R \u2192' P)),\n            apply prf.axk,\n        have HPQP : prf (P \u2192' (Q \u2192' P)),\n            apply prf.axk,\n        have HPQPP : prf ((P \u2192' Q) \u2192' (P \u2192' P)),\n            apply prf.mp (P \u2192' Q \u2192' P),\n            exact HPQP,\n            apply prf.axs,\n        apply prf.mp (P \u2192' Q),\n        exact HPQ,\n        exact HPQPP,\n    end\n\nlemma deduct (P Q : fml) : prf ((P \u2192' Q) \u2192' P \u2192' Q) :=\n    begin\n        apply reflex,\n    end\n\nlemma deduction (P Q : fml) : prf ((P \u2192' (P \u2192' Q)) \u2192' (P \u2192' Q)) :=\n    begin\n        apply prf.mp (P \u2192' ((P \u2192' Q) \u2192' Q)),\n        apply prf.amp,\n        apply prf.axs,\n    end\n\nlemma yesyes (Q : fml) : prf (\u00ac'(\u00ac'Q) \u2192' Q) :=\n    begin\n        have H4213 : prf ((\u00ac'(\u00ac'(\u00ac'(\u00ac'Q))) \u2192' \u00ac'(\u00ac'Q)) \u2192' (\u00ac'Q \u2192' \u00ac'(\u00ac'(\u00ac'Q)))),\n            apply prf.axn,\n        have H1320 : prf ((\u00ac'Q \u2192' \u00ac'(\u00ac'(\u00ac'Q))) \u2192' (\u00ac'(\u00ac'Q) \u2192' Q)),\n            apply prf.axn,\n        have H4220 : prf ((\u00ac'(\u00ac'(\u00ac'(\u00ac'Q))) \u2192' \u00ac'(\u00ac'Q)) \u2192' (\u00ac'(\u00ac'Q) \u2192' Q)),\n            apply prf.cn (\u00ac'(\u00ac'(\u00ac'(\u00ac'Q))) \u2192' \u00ac'(\u00ac'Q)) ((\u00ac'Q \u2192' \u00ac'(\u00ac'(\u00ac'Q)))) (\u00ac'(\u00ac'Q) \u2192' Q),\n            exact H1320, exact H4213,\n        have H242 : prf (\u00ac'(\u00ac'Q) \u2192' ((\u00ac'(\u00ac'(\u00ac'(\u00ac'Q)))) \u2192'(\u00ac'(\u00ac'Q)))),\n            apply prf.axk,\n        have H2020 : prf ((\u00ac' (\u00ac' Q) \u2192' Q) \u2192' (\u00ac' (\u00ac' Q) \u2192' Q)),\n            apply reflex,\n        have H220 : prf (\u00ac' (\u00ac' Q) \u2192' (\u00ac' (\u00ac' Q) \u2192' Q)),\n            apply prf.cn _ ((\u00ac'(\u00ac'(\u00ac'(\u00ac'Q)))) \u2192'(\u00ac'(\u00ac'Q))),\n            exact H4220,\n            exact H242,\n        apply prf.mp (\u00ac' (\u00ac' Q) \u2192' \u00ac' (\u00ac' Q) \u2192' Q),\n        exact H220,\n        apply deduction,\n    end\n\ntheorem notnot (P : fml) : prf (P \u2192' \u00ac'(\u00ac'P)) :=\n    begin\n        have H31 : prf (\u00ac'(\u00ac'(\u00ac'P)) \u2192' \u00ac' P),\n            apply yesyes,\n        apply prf.mp (\u00ac' (\u00ac' (\u00ac' P)) \u2192' \u00ac' 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 \u27f6 S`,\n  then `restrict_scalars : Module S \u2964 Module R` is defined by `M \u21a6 M` where `M : S-module` is seen\n  as `R-module` by `r \u2022 m := f r \u2022 m` and `S`-linear map `l : M \u27f6 M'` is `R`-linear as well.\n\n* `category_theory.Module.extend_scalars`: given **commutative** rings `R, S` and ring homomorphism\n  `f : R \u27f6 S`, then `extend_scalars : Module R \u2964 Module S` is defined by `M \u21a6 S \u2a02 M` where the\n  module structure is defined by `s \u2022 (s' \u2297 m) := (s * s') \u2297 m` and `R`-linear map `l : M \u27f6 M'`\n  is sent to `S`-linear map `s \u2297 m \u21a6 s \u2297 l m : S \u2a02 M \u27f6 S \u2a02 M'`.\n\n## List of notations\nLet `R, S` be rings and `f : R \u2192+* S`\n* if `M` is an `R`-module, `s : S` and `m : M`, then `s \u2297\u209c[R, f] m` is the pure tensor\n  `s \u2297 m : S \u2297[R, f] M`.\n-/\n\n\nnamespace category_theory.Module\n\nuniverses v u\u2081 u\u2082\n\nnamespace restrict_scalars\n\nvariables {R : Type u\u2081} {S : Type u\u2082} [ring R] [ring S] (f : R \u2192+* S)\nvariable (M : Module.{v} S)\n\n/-- Any `S`-module M is also an `R`-module via a ring homomorphism `f : R \u27f6 S` by defining\n    `r \u2022 m := f r \u2022 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 \u2192 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 \u27f6 M') :\n  obj' f M \u27f6 obj' f M' :=\n{ map_smul' := \u03bb r, g.map_smul (f r), ..g }\n\nend restrict_scalars\n\n/--\nThe restriction of scalars operation is functorial. For any `f : R \u2192+* S` a ring homomorphism,\n* an `S`-module `M` can be considered as `R`-module by `r \u2022 m = f r \u2022 m`\n* an `S`-linear map is also `R`-linear\n-/\ndef restrict_scalars {R : Type u\u2081} {S : Type u\u2082} [ring R] [ring S] (f : R \u2192+* S) :\n  Module.{v} S \u2964 Module.{v} R :=\n{ obj := restrict_scalars.obj' f,\n  map := \u03bb _ _, restrict_scalars.map' f,\n  map_id' := \u03bb _, linear_map.ext $ \u03bb m, rfl,\n  map_comp' := \u03bb _ _ _ g h, linear_map.ext $ \u03bb m, rfl }\n\n@[simp] lemma restrict_scalars.map_apply {R : Type u\u2081} {S : Type u\u2082} [ring R] [ring S] (f : R \u2192+* S)\n  {M M' : Module.{v} S} (g : M \u27f6 M') (x) : (restrict_scalars f).map g x = g x := rfl\n\n@[simp] lemma restrict_scalars.smul_def {R : Type u\u2081} {S : Type u\u2082} [ring R] [ring S] (f : R \u2192+* S)\n  {M : Module.{v} S} (r : R) (m : (restrict_scalars f).obj M) : r \u2022 m = (f r \u2022 m : M) := rfl\n\nlemma restrict_scalars.smul_def' {R : Type u\u2081} {S : Type u\u2082} [ring R] [ring S] (f : R \u2192+* S)\n  {M : Module.{v} S} (r : R) (m : M) : (r \u2022 m : (restrict_scalars f).obj M) = (f r \u2022 m : M) := rfl\n\n@[priority 100]\ninstance smul_comm_class_mk {R : Type u\u2081} {S : Type u\u2082} [ring R] [comm_ring S] (f : R \u2192+* 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 := \u03bb r s m, (by simp [\u2190mul_smul, mul_comm] : f r \u2022 s \u2022 m = s \u2022 f r \u2022 m) }\n\nnamespace extend_scalars\n\nopen tensor_product\n\nvariables {R : Type u\u2081} {S : Type u\u2082} [comm_ring R] [comm_ring S] (f : R \u2192+* 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 \u2297\u209c m` where `s : S` and `m : M`;\n-- without this notation, one need to work with `s : (restrict_scalars f).obj \u27e8S\u27e9`.\nlocalized \"notation s `\u2297\u209c[` 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 \u21a6 S \u2a02 M\n-/\ndef obj' : Module S :=\n\u27e8tensor_product R ((restrict_scalars f).obj \u27e8S\u27e9) M\u27e9\n\n/--\nExtension of scalars is a functor where an `R`-module `M` is sent to `S \u2297 M` and\n`l : M1 \u27f6 M2` is sent to `s \u2297 m \u21a6 s \u2297 l m`\n-/\ndef map' {M1 M2 : Module.{v} R} (l : M1 \u27f6 M2) : (obj' f M1) \u27f6 (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 (\ud835\udfd9 M) = \ud835\udfd9 _ :=\nlinear_map.ext $ \u03bb (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\u2081 M\u2082 M\u2083 : Module.{v} R} (l\u2081\u2082 : M\u2081 \u27f6 M\u2082) (l\u2082\u2083 : M\u2082 \u27f6 M\u2083) :\n  map' f (l\u2081\u2082 \u226b l\u2082\u2083) = map' f l\u2081\u2082 \u226b map' f l\u2082\u2083 :=\nlinear_map.ext $ \u03bb (x : obj' f M\u2081),\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 \u2297 M` and\n`l : M1 \u27f6 M2` is sent to `s \u2297 m \u21a6 s \u2297 l m`\n-/\ndef extend_scalars {R : Type u\u2081} {S : Type u\u2082} [comm_ring R] [comm_ring S] (f : R \u2192+* S) :\n  Module.{v} R \u2964 Module.{max v u\u2082} S :=\n{ obj := \u03bb M, extend_scalars.obj' f M,\n  map := \u03bb M1 M2 l, extend_scalars.map' f l,\n  map_id' := \u03bb _, extend_scalars.map'_id f,\n  map_comp' := \u03bb _ _ _, extend_scalars.map'_comp f }\n\nnamespace extend_scalars\n\nopen_locale change_of_rings\n\nvariables {R : Type u\u2081} {S : Type u\u2082} [comm_ring R] [comm_ring S] (f : R \u2192+* S)\n\n@[simp] protected lemma smul_tmul {M : Module.{v} R} (s s' : S) (m : M) :\n  s \u2022 (s' \u2297\u209c[R, f] m : (extend_scalars f).obj M) = (s * s') \u2297\u209c[R, f] m := rfl\n\n@[simp] lemma map_tmul {M M' : Module.{v} R} (g : M \u27f6 M') (s : S) (m : M) :\n  (extend_scalars f).map g (s \u2297\u209c[R, f] m) = s \u2297\u209c[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 {\u039b : Type u} [add_comm_group \u039b]\nvariable {\u03b9 : Type*}\n\nopen_locale big_operators nnrat\n\ndef explicit_dual_set (l : \u03b9 \u2192 \u039b) : submodule \u2115 (\u039b \u2192+ \u2124) :=\n{ carrier := {x | \u2200 i, 0 \u2264 x (l i)},\n  zero_mem' := \u03bb i, le_rfl,\n  add_mem' := \u03bb x y hx hy i, add_nonneg (hx i) (hy i),\n  smul_mem' := \u03bb n x hx i, nsmul_nonneg (hx i) n }\n\nlemma mem_explicit_dual_set (l : \u03b9 \u2192 \u039b) (x : \u039b \u2192+ \u2124) :\n  x \u2208 explicit_dual_set l \u2194 \u2200 i, 0 \u2264 x (l i) := iff.rfl\n\ndef dual_finset (S : finset \u039b) : submodule \u2115 (\u039b \u2192+ \u2124) :=\nexplicit_dual_set (coe : (S : set \u039b) \u2192 \u039b)\n\nlemma mem_dual_finset (S : finset \u039b) (l : \u039b \u2192+ \u2124) :\n  l \u2208 dual_finset S \u2194 \u2200 x \u2208 S, 0 \u2264 l x :=\nbegin\n  rw [dual_finset, mem_explicit_dual_set],\n  simp\nend\n\nlemma dual_finset_antimono {S T : finset \u039b} (hST : S \u2286 T) :\n  dual_finset T \u2264 dual_finset S :=\nbegin\n  rintro \u03c6 h\u03c6 \u27e8i, his : i \u2208 S\u27e9,\n  exact h\u03c6 \u27e8i, hST his\u27e9,\nend\n\nlemma explicit_dual_set_eq_dual_finset [decidable_eq \u039b] [fintype \u03b9] (l : \u03b9 \u2192 \u039b) :\n  explicit_dual_set l = dual_finset (finset.image l finset.univ) :=\nbegin\n  ext \u03c6,\n  split,\n  { rintro h\u03c6 \u27e8t, ht : t \u2208 finset.image _ _\u27e9,\n    rw finset.mem_image at ht,\n    rcases ht with \u27e8i, -, rfl\u27e9,\n    exact h\u03c6 i },\n  { rintro h\u03c6 i,\n    refine h\u03c6 \u27e8l i, (_ : l i \u2208 finset.image _ _)\u27e9,\n    rw finset.mem_image,\n    exact \u27e8i, finset.mem_univ _, rfl\u27e9 }\nend\n\ndef intersect_halfspaces (l : \u03b9 \u2192 \u039b \u2192+ \u2124) : submodule \u2115 \u039b :=\n{ carrier := {x | \u2200 i, 0 \u2264 l i x},\n  zero_mem' := \u03bb i, by simp only [add_monoid_hom.map_zero],\n  add_mem' := \u03bb 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' := \u03bb 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 : \u03b9 \u2192 \u039b \u2192+ \u2124) (x : \u039b) :\n  x \u2208 intersect_halfspaces l \u2194 \u2200 i, 0 \u2264 l i x := iff.rfl\n\ndef intersect_halfspaces_set (s : set (\u039b \u2192+ \u2124)) : submodule \u2115 \u039b :=\nintersect_halfspaces (coe : (s : set (\u039b \u2192+ \u2124)) \u2192 (\u039b \u2192+ \u2124))\n\nlemma mem_intersect_halfspaces_set (S : set (\u039b \u2192+ \u2124)) (x : \u039b) :\n  x \u2208 intersect_halfspaces_set S \u2194 \u2200 (f : \u039b \u2192+ \u2124), f \u2208 S \u2192 0 \u2264 f x :=\nbegin\n  rw [intersect_halfspaces_set, mem_intersect_halfspaces],\n  simp\nend\n\nvariables {\u03b1 : Type*}\n\ndef to_rational_point : (\u03b1 \u2192 \u2124) \u2192\u2097[\u2124] (\u03b1 \u2192 \u211a) :=\n{ to_fun := \u03bb f x, f x,\n  map_add' := \u03bb f g, by { ext1 x, simp only [int.cast_add, pi.add_apply] },\n  map_smul' := \u03bb 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 : \u03b1 \u2192 \u2124) (i : \u03b1) :\n  to_rational_point x i = x i := rfl\n\nlemma to_rational_point_injective : function.injective (to_rational_point : (\u03b1 \u2192 \u2124) \u2192 (\u03b1 \u2192 \u211a)) :=\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 \u211a\u22650 (\u03b1 \u2192 \u211a)) : submodule \u2115 (\u03b1 \u2192 \u2124) :=\n{ carrier := to_rational_point \u207b\u00b9' (S : set (\u03b1 \u2192 \u211a)),\n  zero_mem' :=\n    by simp only [linear_map.map_zero, set.mem_preimage, set_like.mem_coe, submodule.zero_mem],\n  add_mem' := \u03bb a b (ha : to_rational_point a \u2208 S) (hb : to_rational_point b \u2208 S),\n  begin\n    change to_rational_point (a + b) \u2208 S,\n    simp only [linear_map.map_add],\n    apply S.add_mem ha hb,\n  end,\n  smul_mem' := \u03bb c x (hx : to_rational_point x \u2208 S),\n  begin\n    change to_rational_point (c \u2022 x) \u2208 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 (\u211a\u22650) (\u03b1 \u2192 \u211a)) (x : \u03b1 \u2192 \u2124) :\n  x \u2208 lattice_restrict S \u2194 to_rational_point x \u2208 S :=\niff.rfl\n\ndef is_integer (x : \u211a) := \u2203 (z : \u2124), x = z\ndef is_integer_point (x : \u03b1 \u2192 \u211a) := \u2200 a, is_integer (x a)\n\ndef floor_point (x : \u03b1 \u2192 \u211a) : \u03b1 \u2192 \u2124 := \u03bb i, \u230ax i\u230b\nlemma floor_point_eq_of_is_integer_point (x : \u03b1 \u2192 \u211a) (hx : is_integer_point x) :\n  (\u03bb i, floor_point x i : \u03b1 \u2192 \u211a) = x :=\nbegin\n  ext1 i,\n  obtain \u27e8z, hz\u27e9 := hx i,\n  simp [floor_point, hz],\nend\n\nlemma exists_scalings {\u03b9 : Type*} (s : finset \u03b9) (v : \u03b9 \u2192 \u211a) :\n  \u2203 (n : \u2115), 0 < n \u2227 \u2200 i \u2208 s, is_integer (n \u2022 v i) :=\nbegin\n  classical,\n  apply finset.induction_on s,\n  { exact \u27e81, by norm_num, by simp\u27e9 },\n  { rintro x s hx \u27e8m, hm\u2081, hm\u2082\u27e9,\n    refine \u27e8m * (v x).denom, mul_pos hm\u2081 (v x).pos, _\u27e9,\n    simp only [forall_eq_or_imp, nsmul_eq_mul, finset.mem_insert, nat.cast_mul],\n    refine \u27e8\u27e8m * (v x).num, _\u27e9, _\u27e9,\n    { push_cast,\n      rw mul_assoc,\n      norm_cast,\n      rw [mul_comm ((v x).denom : \u211a), rat.mul_denom_eq_num],\n      norm_cast },\n    intros y hy,\n    obtain \u27e8z, hz\u27e9 := hm\u2082 y hy,\n    rw mul_right_comm,\n    refine \u27e8z * (v x).denom, _\u27e9,\n    push_cast,\n    rw \u2190hz,\n    simp }\nend\n\nlemma point_exists_scaling {\u03b1 : Type*} [fintype \u03b1] (x : \u03b1 \u2192 \u211a) :\n  \u2203 (n : \u2115), 0 < n \u2227 is_integer_point ((n) \u2022 x) :=\nlet \u27e8m, hm\u2081, hm\u2082\u27e9 := exists_scalings finset.univ x in \u27e8m, hm\u2081, \u03bb a, by simpa using hm\u2082 a\u27e9\n\nopen_locale classical\n\nnoncomputable def scale_factor {\u03b1 : Type*} [fintype \u03b1] (x : \u03b1 \u2192 \u211a) : \u2115 :=\nnat.find (point_exists_scaling x)\n\nlemma scale_factor_pos {\u03b1 : Type*} [fintype \u03b1] (x : \u03b1 \u2192 \u211a) : 0 < scale_factor x :=\n(nat.find_spec (point_exists_scaling x)).1\n\nlemma rat_scale_factor_ne_zero {\u03b1 : Type*} [fintype \u03b1] (x : \u03b1 \u2192 \u211a) :\n  (scale_factor x : \u211a) \u2260 0 :=\nbegin\n  norm_cast,\n  apply (scale_factor_pos x).ne',\nend\n\nnoncomputable def scale_up {\u03b1 : Type*} [fintype \u03b1] (x : \u03b1 \u2192 \u211a) : \u03b1 \u2192 \u2124 :=\nfloor_point (scale_factor x \u2022 x)\n\nlemma scale_up_is {\u03b1 : Type*} [fintype \u03b1] (x : \u03b1 \u2192 \u211a) :\n  (\u03bb (i : \u03b1), \u2191(scale_up x i)) = scale_factor x \u2022 x :=\nfloor_point_eq_of_is_integer_point _ (nat.find_spec (point_exists_scaling x)).2\n\nlemma scale_up_coord {\u03b1 : Type*} [fintype \u03b1] (x : \u03b1 \u2192 \u211a) (a : \u03b1) :\n  (scale_up x a : \u211a) = scale_factor x * x a :=\nbegin\n  suffices : (scale_up x a : \u211a) = (scale_factor x \u2022 x) a,\n  { simpa using this },\n  rw \u2190scale_up_is,\nend\n\nlemma to_rational_point_scale_up {\u03b1 : Type*} [fintype \u03b1] (x : \u03b1 \u2192 \u211a) :\n  to_rational_point (scale_up x) = scale_factor x \u2022 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 : \u2124} : (a : \u211a) = b \u2192 a = b :=\n\u03bb h, (rat.coe_int_inj a b).mp h\n\nnoncomputable def upgrade_functional {\u03b1 : Type*} [fintype \u03b1] (f : (\u03b1 \u2192 \u2124) \u2192+ \u2124) : (\u03b1 \u2192 \u211a) \u2192\u2097[\u211a] \u211a :=\n{ to_fun := \u03bb g, (f (scale_up g) : \u211a) / scale_factor g,\n  map_add' := \u03bb g\u2081 g\u2082,\n  begin\n    field_simp [rat_scale_factor_ne_zero],\n    norm_cast,\n    suffices : f ((scale_factor g\u2081 * scale_factor g\u2082) \u2022 scale_up (g\u2081 + g\u2082)) =\n      f (scale_factor (g\u2081 + g\u2082) \u2022 (scale_factor g\u2082 \u2022 scale_up g\u2081 + scale_factor g\u2081 \u2022 scale_up g\u2082)),\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 \u2190rat.coe_int_inj,\n    push_cast,\n    simp only [scale_up_coord, pi.add_apply],\n    ring!,\n  end,\n  map_smul' := \u03bb m x,\n  begin\n    simp only [algebra.id.smul_eq_mul],\n    rw \u2190rat.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) \u2022 scale_up (m \u2022 x)) =\n        f ((scale_factor (m \u2022 x) * m.num : \u2124) \u2022 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 \u2190rat.coe_int_inj,\n    push_cast,\n    simp only [scale_up_coord, pi.smul_apply, algebra.id.smul_eq_mul, \u2190rat.mul_denom_eq_num],\n    ring!,\n  end }.\n\nlemma upgrade_id {\u03b1 : Type*} [fintype \u03b1] (f : (\u03b1 \u2192 \u2124) \u2192+ \u2124) (g : \u03b1 \u2192 \u2124) :\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, \u2190nsmul_eq_mul, \u2190add_monoid_hom.map_nsmul],\n  congr' 1,\n  ext a,\n  simp only [nsmul_eq_mul, pi.mul_apply],\n  rw \u2190rat.coe_int_inj,\n  rw scale_up_coord,\n  norm_cast,\nend\n\nsection\n\nlemma finitely_generated_iff_integrally_generated [fintype \u03b1] (C : submodule (\u211a\u22650) (\u03b1 \u2192 \u211a)) :\n  C.fg \u2194 \u2203 S : finset (\u03b1 \u2192 \u2124), submodule.span (\u211a\u22650) (S.image to_rational_point : set (\u03b1 \u2192 \u211a)) = C :=\nbegin\n  split,\n  { rintro \u27e8S, rfl\u27e9,\n    refine \u27e8S.image scale_up, _\u27e9,\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 \u2208 submodule.span (\u211a\u22650) (S : set (\u03b1 \u2192 \u211a)) := submodule.subset_span hy,\n      have z := submodule.smul_mem _ (scale_factor y : \u211a\u22650) 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, \u2190set.image_comp],\n      intro hx,\n      have : scale_factor x \u2022 x \u2208 ((to_rational_point \u2218 scale_up) '' (S : set (\u03b1 \u2192 \u211a))),\n      { refine \u27e8_, hx, _\u27e9,\n        simp only [nsmul_eq_mul, function.comp_app, to_rational_point_scale_up] },\n      have : scale_factor x \u2022 x \u2208\n        submodule.span \u211a\u22650 (to_rational_point \u2218 scale_up '' (S : set (\u03b1 \u2192 \u211a))) :=\n        submodule.subset_span this,\n      have hx\u2082 := submodule.smul_mem _ ((scale_factor x)\u207b\u00b9 : \u211a\u22650) this,\n      convert hx\u2082 using 1,\n      ext1 i,\n      simp only [nsmul_eq_mul, pi.mul_apply, pi.smul_apply],\n      change _ = _ * (_ * _),\n      simp,\n      rw \u2190mul_assoc,\n      convert (one_mul (x i)).symm,\n      convert inv_mul_cancel _,\n      apply rat_scale_factor_ne_zero } },\n  { rintro \u27e8S, rfl\u27e9,\n    refine \u27e8_, rfl\u27e9 }\nend.\n\nlemma finitely_generated_iff_integrally_generated_type {\u03b1 : Type u} [fintype \u03b1]\n  (C : submodule (\u211a\u22650) (\u03b1 \u2192 \u211a)) :\n  C.fg \u2194 \u2203 (\u03b9 : Type u) (s : finset \u03b9) (v : \u03b9 \u2192 \u03b1 \u2192 \u2124) (hv : function.injective v),\n    submodule.span (\u211a\u22650) (s.image (\u03bb i, to_rational_point (v i)) : set (\u03b1 \u2192 \u211a)) = C :=\nbegin\n  rw finitely_generated_iff_integrally_generated,\n  split,\n  { rintro \u27e8S, rfl\u27e9,\n    refine \u27e8_, S, id, \u03bb _ _ h, h, rfl\u27e9 },\n  { rintro \u27e8\u03b9, s, v, _, rfl\u27e9,\n    refine \u27e8s.image v, _\u27e9,\n    rw finset.image_image }\nend\n\nlemma bounded_lattice_thing [fintype \u03b1] {k : \u03b1 \u2192 \u2115} (C : set (\u03b1 \u2192 \u2124))\n  (hC : \u2200 (x : \u03b1 \u2192 \u2124) i, x \u2208 C \u2192 int.nat_abs (x i) \u2264 k i) : C.finite :=\nbegin\n  classical,\n  let C' : finset (\u03b1 \u2192 \u2124) :=\n    (finset.univ.pi (\u03bb i, finset.Ico (-(k i : \u2124)) (k i+1))).image (\u03bb f a, f a (finset.mem_univ _)),\n  have : C \u2286 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 \u27e8\u03bb a _, x a, \u03bb a, _, _\u27e9,\n    { have : abs (x a) \u2264 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 \u27e8this.1, _\u27e9,\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 {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 \u2124) :\n  (\u2211 i in s, f i).nat_abs \u2264 \u2211 i in s, (f i).nat_abs :=\nfinset.le_sum_of_subadditive _ rfl int.nat_abs_add_le _ _\n\nlemma floor_add_floor_le {\u03b1 : Type*} [linear_ordered_ring \u03b1] [floor_ring \u03b1] (x y : \u03b1) :\n  \u230ax\u230b + \u230ay\u230b \u2264 \u230ax + y\u230b :=\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 {\u03b1 : Type*} [linear_ordered_ring \u03b1] [floor_ring \u03b1] {\u03b9 : Type*} (s : finset \u03b9)\n  (f : \u03b9 \u2192 \u03b1) :\n  \u2211 i in s, \u230af i\u230b \u2264 \u230a\u2211 i in s, f i\u230b :=\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 {\u03b1 : Type*} [linear_ordered_ring \u03b1] [floor_ring \u03b1] (x y : \u03b1) :\n  \u2308x + y\u2309 \u2264 \u2308x\u2309 + \u2308y\u2309 :=\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 {\u03b1 : Type*} [linear_ordered_ring \u03b1] [floor_ring \u03b1] {\u03b9 : Type*} (s : finset \u03b9)\n  (f : \u03b9 \u2192 \u03b1) :\n  \u2308\u2211 i in s, f i\u2309 \u2264 \u2211 i in s, \u2308f i\u2309 :=\nfinset.le_sum_of_subadditive _ (by simp) ceil_add_le _ _\n\nlemma nat_abs_lt_nat_abs_of_nonneg_of_lt {a b : \u2124} (w\u2081 : 0 \u2264 a) (w\u2082 : a < b) :\n  a.nat_abs < b.nat_abs :=\nbegin\n  lift b to \u2115 using le_trans w\u2081 (le_of_lt w\u2082),\n  lift a to \u2115 using w\u2081,\n  simpa using w\u2082,\nend\n\nlemma int.coe_sum {\u03b1 : Type*} (f : \u03b1 \u2192 \u2115) (s : finset \u03b1) :\n  \u2211 (x : \u03b1) in s, (f x : \u2124) = (\u2191\u2211 i in s, f i : \u2124) :=\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 \u2208 submodule.span R (S : set M) \u2194 \u2203 (w : M \u2192 R), \u2211 i in S, w i \u2022 i = x :=\nbegin\n  exact mem_span_finset\nend\n\nset_option pp.proofs true\n\nlemma missing [fintype \u03b1] (w : \u03b1 \u2192 \u2124) (n : \u2115) :\n  to_rational_point (n \u2022 w) = (n : \u211a\u22650) \u2022 to_rational_point w :=\nbegin\n  simp only [nsmul_eq_mul],\n  induction n,\n  { simp },\n  { simp [add_smul, \u2190n_ih, add_mul],  },\nend\n\nlemma my_result [fintype \u03b1] (C : submodule (\u211a\u22650) (\u03b1 \u2192 \u211a)) (hC : C.fg) :\n  (lattice_restrict C).fg :=\nbegin\n  rw finitely_generated_iff_integrally_generated_type at hC,\n  rcases hC with \u27e8\u03b9, s, w, hw, rfl\u27e9,\n  let B := {x : \u03b1 \u2192 \u2124 |\n                \u2203 w' : \u03b9 \u2192 \u211a\u22650, (\u2200 (i \u2208 s), w' i < 1) \u2227\n                \u2211 i in s, w' i \u2022 to_rational_point (w i) = to_rational_point x},\n  let k : \u03b1 \u2192 \u2115 := \u03bb a, \u2211 i in s, int.nat_abs (w i a),\n  have : \u2200 (x : \u03b1 \u2192 \u2124) a, x \u2208 B \u2192 int.nat_abs (x a) \u2264 k a,\n  { rintro x a \u27e8w', hw', hw''\u27e9,\n    have hw''' : (\u2211 (i : \u03b9) in s, w' i \u2022 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 \u2211 (c : \u03b9) in s, (w' c : \u211a) * (w c a) = x a at hw''',\n    clear hw'',\n    have : abs (\u2211 (c : \u03b9) in s, (w' c : \u211a) * w c a) \u2264 \u2211 (c : \u03b9) 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 \u27e8_, (hw' i hi).le\u27e9,\n      apply le_trans (show (-1 : \u211a) \u2264 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 \u27e8B' \u222a s.image w, _\u27e9,\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 \u27e8w', hw', hw''\u27e9,\n      change to_rational_point x \u2208 _,\n      rw \u2190hw'',\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 \u27e8_, hi, rfl\u27e9 },\n    { simp only [set.image_subset_iff, finset.coe_image],\n      intros x hx,\n      change to_rational_point (w x) \u2208 _,\n      apply submodule.subset_span,\n      refine \u27e8_, hx, rfl\u27e9 } },\n  { rintro x (hx : to_rational_point _ \u2208 _),\n    simp only [set_like.mem_coe, mem_span_finset] at hx,\n    rcases hx with \u27e8f, hf\u27e9,\n    rw finset.sum_image at hf,\n    { simp only [finset.coe_union, set.finite.coe_to_finset, finset.coe_image],\n      let f' : \u03b9 \u2192 \u211a\u22650 := \u03bb i, f (to_rational_point (w i)),\n      let ns : \u03b9 \u2192 \u2115 := \u03bb i, (\u230a(f' i : \u211a)\u230b).nat_abs,\n      let g' : \u03b9 \u2192 \u211a\u22650 := \u03bb i, f' i - ns i,\n      have ns' : \u2200 i, (ns i : \u2124) = \u230a(f' i : \u211a)\u230b,\n      { intro i,\n        change (int.nat_abs _ : \u2124) = _,\n        rw [\u2190int.abs_eq_nat_abs, abs_of_nonneg],\n        rw [int.floor_nonneg],\n        apply (f' i).2 },\n      have hg' : \u2200 i, (g' i : \u211a) = 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 _ : \u211a) \u2264 _,\n        suffices : ((int.nat_abs \u230a(f' i : \u211a)\u230b : \u2124) : \u211a) \u2264 f' i,\n        { simpa using this },\n        rw ns',\n        apply int.floor_le },\n      change \u2211 x in s, f' x \u2022 to_rational_point (w x) = to_rational_point x at hf,\n      -- have :  \u2264 \u2191(f' i) - \u2191(ns i)\n      have : \u2200 i, (ns i : \u211a\u22650) + g' i = f' i,\n      { intro i,\n        apply nnrat.coe_injective,\n        rw [nnrat.coe_add, hg'],\n        simp },\n      simp_rw [\u2190this, add_smul, finset.sum_add_distrib] at hf,\n      let x_floors := \u2211 (x : \u03b9) in s, ns x \u2022 w x,\n      have : x - x_floors \u2208 B,\n      { refine \u27e8g', _, _\u27e9,\n        { intros i hi,\n          rw \u2190nnrat.coe_lt_coe,\n          rw hg',\n          simp only [nnrat.coe_one],\n          suffices : (f' i : \u211a) - ((ns i : \u2124) : \u211a) < 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 \u2190hf,\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 \u2039x - x_floors \u2208 B\u203a },\n        apply submodule.sum_smul_mem _ ns _,\n        intros i hi,\n        apply submodule.subset_span,\n        right,\n        refine \u27e8_, hi, rfl\u27e9 } },\n    intros x hx y hy t,\n    apply hw,\n    apply to_rational_point_injective t, }\nend\n\nend\n\n-- instance {\u03b1 : Type*} [fintype \u03b1] : finite_dimensional \u211a (\u03b1 \u2192 \u211a) :=\n-- @is_noetherian_pi _ _ _ _ _ _ _ (\u03bb i, infer_instance)\n\nlemma finset_Gordan_aux_pi {\u03b1 : Type*} [fintype \u03b1] (S : finset ((\u03b1 \u2192 \u2124) \u2192+ \u2124)) :\n  (intersect_halfspaces_set (S : set ((\u03b1 \u2192 \u2124) \u2192+ \u2124))).fg  :=\nbegin\n  classical,\n  let S' : finset ((\u03b1 \u2192 \u211a) \u2192\u2097[\u211a] \u211a) := S.image upgrade_functional,\n  suffices : lattice_restrict (set_down_one (S' : set ((\u03b1 \u2192 \u211a) \u2192\u2097[\u211a] \u211a))) =\n              intersect_halfspaces_set (S : set ((\u03b1 \u2192 \u2124) \u2192+ \u2124)),\n  { rw \u2190this,\n    apply my_result,\n    rw \u2190fg_iff_is_polyhedral_cone,\n    rw is_polyhedral_cone_iff_finset,\n    refine \u27e8_, rfl\u27e9 },\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 \u2124 \u039b] [module.free \u2124 \u039b] (S : finset (\u039b \u2192+ \u2124)) :\n  (intersect_halfspaces_set (S : set (\u039b \u2192+ \u2124))).fg :=\nbegin\n  classical,\n  have e := linear_equiv.restrict_scalars \u2115 (module.free.choose_basis \u2124 \u039b).equiv_fun,\n    -- deliberately forget the data here, it makes the simp at the end easier\n  let e' : (\u039b \u2192+ \u2124) \u2192 (module.free.choose_basis_index \u2124 \u039b \u2192 \u2124) \u2192+ \u2124 :=\n    \u03bb f, f.comp e.symm.to_linear_map.to_add_monoid_hom,\n  let L := (intersect_halfspaces_set \u2191(S.image e')).map\n    (e.symm : (module.free.choose_basis_index \u2124 \u039b \u2192 \u2124) \u2192\u2097[\u2115] \u039b),\n  have : L.fg := submodule.fg.map _ (finset_Gordan_aux_pi (S.image e')),\n  suffices : L = intersect_halfspaces_set (S : set (\u039b \u2192+ \u2124)),\n  { rwa \u2190this },\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 \u2124 \u039b] [module.free \u2124 \u039b] (S : finset \u039b) :\n  (dual_finset S).fg :=\nbegin\n  classical,\n  let S' : finset ((\u039b \u2192+ \u2124) \u2192+ \u2124) := S.image add_monoid_hom.eval,\n  letI := module.free.add_monoid_hom \u039b \u2124, --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 \u2124 \u039b] [module.free \u2124 \u039b] [fintype \u03b9] (l : \u03b9 \u2192 \u039b) :\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) \u2264 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  \u2191(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 : \u2115} (h : fintype.card n - 1 \u2264 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) = \u2191(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\u2082_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 : \u2115} [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 : \u2115} [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 \u2223 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 := \u2115\n\nlocal notation `\u0394` := simplex_category\nlocal notation `[`n`]` := fin (n + 1)\n\ninstance : has_coe_to_sort (\u0394) :=\n{S := Type, coe := \u03bb n, [n]}\n\n/- Nota bene: We will abuse the notation (n : \u0394)\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 : \u0394) :=\n{f : m \u2192 n // monotone f}\n\ninstance {m n : \u0394} : has_coe_to_fun (order_preserving_map m n) :=\n{ F := \u03bb _, m \u2192 n, coe := \u03bb f, f.val }\n\ninstance : category \u0394 :=\n{ hom := order_preserving_map, --\u03bb m n : \u0394, {f : m \u2192 n // monotone f},\n  id := \u03bb X, \u27e8id, monotone_id\u27e9,\n  comp := \u03bb _ _ _ f g, \u27e8g.val \u2218 f.val, g.2.comp f.2\u27e9 }\n\nnamespace simplex_category\n\nprotected lemma hom_eq2 {m n : \u0394} {f g : m \u27f6 n} : f = g \u2194 f.val = g.val := by cases f; cases g; simp\n\nvariables {n : \u0394}\n\n/-- The i-th face map from [n] to [n+1] -/\ndef \u03b4 (i : [n+1]) : n \u27f6 ((n + 1) : \u2115) :=\n\u27e8\u03bb a, if h : i.val \u2264 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 \u2264 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 \u2264 b.succ.val,\n      simpa using nat.le_trans H (nat.le_succ b) },\n    { exact H }\n  end\u27e9\n\n/-- The i-th degeneracy map from [n+1] to [n] -/\ndef \u03c3 (i : [n]) : @has_hom.hom \u0394 _ ((n + 1) : \u2115) n :=\n\u27e8\u03bb a, if h : a.val \u2264 i.val\n    then \u27e8a.val, lt_of_le_of_lt h i.is_lt\u27e9\n    else \u27e8a.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\u27e9,\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 \u2264 nat.pred b.val :=\n      begin\n        rw \u2190nat.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\u27e9\n\nlemma simplicial_identity\u2081 {i j : [n+1]} (H : i \u2264 j) : \u03b4 i \u226b \u03b4 j.succ = \u03b4 j \u226b \u03b4 i.cast_succ :=\nbegin\n  rw simplex_category.hom_eq2,\n  dsimp [category_struct.comp, function.comp, \u03b4],\n  funext a,\n  by_cases hja : (j.val \u2264 a.val),\n  { have hja' : ((fin.succ j).val \u2264 (fin.succ a).val) := by simp; exact nat.succ_le_succ hja,\n    have hia : ((fin.cast_succ i).val \u2264 (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 \u2264 a.val),\n    { have hia' : ((fin.cast_succ i).val \u2264 (fin.cast_succ a).val) := hia,\n      have hja' : \u00ac(j.succ.val \u2264 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' : \u00ac(j.succ.val \u2264 a.cast_succ.val) := by simp at *; exact nat.le_trans hja (nat.le_succ j.val),\n      have hia' : \u00ac((fin.cast_succ i).val \u2264 (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\u2082 {i : [n+1]} {j : [n]} (H : i \u2264 j.raise) : \u03b4 i.raise \u226b \u03c3 j.succ = \u03c3 j \u226b \u03b4 i := sorry\n-- lemma simplicial_identity\u2083\n-- lemma simplicial_identity\u2084\n-- lemma simplicial_identity\u2085\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/-! # \u2124[\u221ad]\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 : \u2124`.\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 `\u2124\u221ad \u2192+* 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 \u221ad` where `a b : \u2124`. The components\n  are called `re` and `im` by analogy to the negative `d` case. -/\nstructure Zsqrtd (d : \u2124) where\n  re : \u2124\n  im : \u2124\n#align zsqrtd Zsqrtd\n-/\n\n-- mathport name: \u00abexpr\u2124\u221a \u00bb\nprefix:100 \"\u2124\u221a\" => Zsqrtd\n\nnamespace Zsqrtd\n\nsection\n\nparameter {d : \u2124}\n\n/- ./././Mathport/Syntax/Translate/Tactic/Builtin.lean:69:18: unsupported non-interactive tactic tactic.mk_dec_eq_instance -/\ninstance : DecidableEq (\u2124\u221ad) := by\n  run_tac\n    tactic.mk_dec_eq_instance\n\n#print Zsqrtd.ext /-\ntheorem ext : \u2200 {z w : \u2124\u221ad}, z = w \u2194 z.re = w.re \u2227 z.im = w.im\n  | \u27e8x, y\u27e9, \u27e8x', y'\u27e9 =>\n    \u27e8fun h => by injection h <;> constructor <;> assumption, fun \u27e8h\u2081, h\u2082\u27e9 => by\n      congr <;> assumption\u27e9\n#align zsqrtd.ext Zsqrtd.ext\n-/\n\n#print Zsqrtd.ofInt /-\n/-- Convert an integer to a `\u2124\u221ad` -/\ndef ofInt (n : \u2124) : \u2124\u221ad :=\n  \u27e8n, 0\u27e9\n#align zsqrtd.of_int Zsqrtd.ofInt\n-/\n\n#print Zsqrtd.ofInt_re /-\ntheorem ofInt_re (n : \u2124) : (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 : \u2124) : (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 (\u2124\u221ad) :=\n  \u27e8of_int 0\u27e9\n\n#print Zsqrtd.zero_re /-\n@[simp]\ntheorem zero_re : (0 : \u2124\u221ad).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 : \u2124\u221ad).im = 0 :=\n  rfl\n#align zsqrtd.zero_im Zsqrtd.zero_im\n-/\n\ninstance : Inhabited (\u2124\u221ad) :=\n  \u27e80\u27e9\n\n/-- The one of the ring -/\ninstance : One (\u2124\u221ad) :=\n  \u27e8of_int 1\u27e9\n\n#print Zsqrtd.one_re /-\n@[simp]\ntheorem one_re : (1 : \u2124\u221ad).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 : \u2124\u221ad).im = 0 :=\n  rfl\n#align zsqrtd.one_im Zsqrtd.one_im\n-/\n\n#print Zsqrtd.sqrtd /-\n/-- The representative of `\u221ad` in the ring -/\ndef sqrtd : \u2124\u221ad :=\n  \u27e80, 1\u27e9\n#align zsqrtd.sqrtd Zsqrtd.sqrtd\n-/\n\n#print Zsqrtd.sqrtd_re /-\n@[simp]\ntheorem sqrtd_re : (sqrtd : \u2124\u221ad).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 : \u2124\u221ad).im = 1 :=\n  rfl\n#align zsqrtd.sqrtd_im Zsqrtd.sqrtd_im\n-/\n\n/-- Addition of elements of `\u2124\u221ad` -/\ninstance : Add (\u2124\u221ad) :=\n  \u27e8fun z w => \u27e8z.1 + w.1, z.2 + w.2\u27e9\u27e9\n\n#print Zsqrtd.add_def /-\n@[simp]\ntheorem add_def (x y x' y' : \u2124) : (\u27e8x, y\u27e9 + \u27e8x', y'\u27e9 : \u2124\u221ad) = \u27e8x + x', y + y'\u27e9 :=\n  rfl\n#align zsqrtd.add_def Zsqrtd.add_def\n-/\n\n#print Zsqrtd.add_re /-\n@[simp]\ntheorem add_re (z w : \u2124\u221ad) : (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 : \u2124\u221ad) : (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 : \u2124\u221ad).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 : \u2124\u221ad).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 : \u2124\u221ad).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 : \u2124\u221ad).im = bit0 z.im := by simp [bit1]\n#align zsqrtd.bit1_im Zsqrtd.bit1_im\n-/\n\n/-- Negation in `\u2124\u221ad` -/\ninstance : Neg (\u2124\u221ad) :=\n  \u27e8fun z => \u27e8-z.1, -z.2\u27e9\u27e9\n\n#print Zsqrtd.neg_re /-\n@[simp]\ntheorem neg_re (z : \u2124\u221ad) : (-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 : \u2124\u221ad) : (-z).im = -z.im :=\n  rfl\n#align zsqrtd.neg_im Zsqrtd.neg_im\n-/\n\n/-- Multiplication in `\u2124\u221ad` -/\ninstance : Mul (\u2124\u221ad) :=\n  \u27e8fun z w => \u27e8z.1 * w.1 + d * z.2 * w.2, z.1 * w.2 + z.2 * w.1\u27e9\u27e9\n\n#print Zsqrtd.mul_re /-\n@[simp]\ntheorem mul_re (z w : \u2124\u221ad) : (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 : \u2124\u221ad) : (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 (\u2124\u221ad) := by\n  refine_struct\n          { add := (\u00b7 + \u00b7)\n            zero := (0 : \u2124\u221ad)\n            sub := fun a b => a + -b\n            neg := Neg.neg\n            zsmul := @zsmulRec (\u2124\u221ad) \u27e80\u27e9 \u27e8(\u00b7 + \u00b7)\u27e9 \u27e8Neg.neg\u27e9\n            nsmul := @nsmulRec (\u2124\u221ad) \u27e80\u27e9 \u27e8(\u00b7 + \u00b7)\u27e9 } <;>\n        intros <;>\n      try rfl <;>\n    simp [ext, add_comm, add_left_comm]\n\ninstance : AddGroupWithOne (\u2124\u221ad) :=\n  { Zsqrtd.addCommGroup with\n    natCast := fun n => of_int n\n    intCast := of_int\n    one := 1 }\n\ninstance : CommRing (\u2124\u221ad) := by\n  refine_struct\n          { Zsqrtd.addGroupWithOne with\n            add := (\u00b7 + \u00b7)\n            zero := (0 : \u2124\u221ad)\n            mul := (\u00b7 * \u00b7)\n            one := 1\n            npow := @npowRec (\u2124\u221ad) \u27e81\u27e9 \u27e8(\u00b7 * \u00b7)\u27e9 } <;>\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 (\u2124\u221ad) := by infer_instance\n\ninstance : Monoid (\u2124\u221ad) := by infer_instance\n\ninstance : CommMonoid (\u2124\u221ad) := by infer_instance\n\ninstance : CommSemigroup (\u2124\u221ad) := by infer_instance\n\ninstance : Semigroup (\u2124\u221ad) := by infer_instance\n\ninstance : AddCommSemigroup (\u2124\u221ad) := by infer_instance\n\ninstance : AddSemigroup (\u2124\u221ad) := by infer_instance\n\ninstance : CommSemiring (\u2124\u221ad) := by infer_instance\n\ninstance : Semiring (\u2124\u221ad) := by infer_instance\n\ninstance : Ring (\u2124\u221ad) := by infer_instance\n\ninstance : Distrib (\u2124\u221ad) := by infer_instance\n\n/-- Conjugation in `\u2124\u221ad`. The conjugate of `a + b \u221ad` is `a - b \u221ad`. -/\ninstance : Star (\u2124\u221ad) where unit z := \u27e8z.1, -z.2\u27e9\n\n#print Zsqrtd.star_mk /-\n@[simp]\ntheorem star_mk (x y : \u2124) : star (\u27e8x, y\u27e9 : \u2124\u221ad) = \u27e8x, -y\u27e9 :=\n  rfl\n#align zsqrtd.star_mk Zsqrtd.star_mk\n-/\n\n#print Zsqrtd.star_re /-\n@[simp]\ntheorem star_re (z : \u2124\u221ad) : (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 : \u2124\u221ad) : (star z).im = -z.im :=\n  rfl\n#align zsqrtd.star_im Zsqrtd.star_im\n-/\n\ninstance : StarRing (\u2124\u221ad)\n    where\n  star_involutive x := ext.mpr \u27e8rfl, neg_neg _\u27e9\n  star_mul a b := ext.mpr \u27e8by simp <;> ring, by simp <;> ring\u27e9\n  star_add a b := ext.mpr \u27e8rfl, neg_add _ _\u27e9\n\ninstance : Nontrivial (\u2124\u221ad) :=\n  \u27e8\u27e80, 1, by decide\u27e9\u27e9\n\n#print Zsqrtd.coe_nat_re /-\n@[simp]\ntheorem coe_nat_re (n : \u2115) : (n : \u2124\u221ad).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 : \u2115) : (n : \u2124\u221ad).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 : \u2115) : (n : \u2124\u221ad) = \u27e8n, 0\u27e9 :=\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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_int_re (n : \u2124) : (n : \u2124\u221ad).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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_int_im (n : \u2124) : (n : \u2124\u221ad).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\u2093.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\u2093'. -/\ntheorem coe_int_val (n : \u2124) : (n : \u2124\u221ad) = \u27e8n, 0\u27e9 := by simp [ext]\n#align zsqrtd.coe_int_val Zsqrtd.coe_int_val\n\ninstance : CharZero (\u2124\u221ad) 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\u2093.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\u2093'. -/\n@[simp]\ntheorem ofInt_eq_coe (n : \u2124) : (of_int n : \u2124\u221ad) = 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\u2093.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\u2093'. -/\n@[simp]\ntheorem smul_val (n x y : \u2124) : (n : \u2124\u221ad) * \u27e8x, y\u27e9 = \u27e8n * x, n * y\u27e9 := 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\u2093.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\u2093'. -/\ntheorem smul_re (a : \u2124) (b : \u2124\u221ad) : (\u2191a * 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\u2093.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\u2093'. -/\ntheorem smul_im (a : \u2124) (b : \u2124\u221ad) : (\u2191a * 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 : \u2124) : sqrtd * \u27e8x, y\u27e9 = \u27e8d * y, x\u27e9 := 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\u2093.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\u2093'. -/\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\u2093.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\u2093'. -/\n@[simp]\ntheorem smuld_val (n x y : \u2124) : sqrtd * (n : \u2124\u221ad) * \u27e8x, y\u27e9 = \u27e8d * n * y, n * x\u27e9 := 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\u2093.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\u2093.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\u2093'. -/\ntheorem decompose {x y : \u2124} : (\u27e8x, y\u27e9 : \u2124\u221ad) = 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem mul_star {x y : \u2124} : (\u27e8x, y\u27e9 * star \u27e8x, y\u27e9 : \u2124\u221ad) = 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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem coe_int_add (m n : \u2124) : (\u2191(m + n) : \u2124\u221ad) = \u2191m + \u2191n :=\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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem coe_int_sub (m n : \u2124) : (\u2191(m - n) : \u2124\u221ad) = \u2191m - \u2191n :=\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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem coe_int_mul (m n : \u2124) : (\u2191(m * n) : \u2124\u221ad) = \u2191m * \u2191n :=\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\u2093.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\u2093.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\u2093'. -/\nprotected theorem coe_int_inj {m n : \u2124} (h : (\u2191m : \u2124\u221ad) = \u2191n) : 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\u2093.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\u2093'. -/\ntheorem coe_int_dvd_iff (z : \u2124) (a : \u2124\u221ad) : \u2191z \u2223 a \u2194 z \u2223 a.re \u2227 z \u2223 a.im :=\n  by\n  constructor\n  \u00b7 rintro \u27e8x, rfl\u27e9\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  \u00b7 rintro \u27e8\u27e8r, hr\u27e9, \u27e8i, hi\u27e9\u27e9\n    use \u27e8r, i\u27e9\n    rw [smul_val, ext]\n    exact \u27e8hr, hi\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_int_dvd_coe_int (a b : \u2124) : (a : \u2124\u221ad) \u2223 b \u2194 a \u2223 b :=\n  by\n  rw [coe_int_dvd_iff]\n  constructor\n  \u00b7 rintro \u27e8hre, -\u27e9\n    rwa [coe_int_re] at hre\n  \u00b7 rw [coe_int_re, coe_int_im]\n    exact fun hc => \u27e8hc, dvd_zero a\u27e9\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\u2093.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\u2093.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\u2093'. -/\nprotected theorem eq_of_smul_eq_smul_left {a : \u2124} {b c : \u2124\u221ad} (ha : a \u2260 0) (h : \u2191a * b = a * c) :\n    b = c := by\n  rw [ext] at h\u22a2\n  apply And.imp _ _ h <;> \u00b7 simpa only [smul_re, smul_im] using mul_left_cancel\u2080 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 : \u2124\u221ad) : Int.gcd a.re a.im = 0 \u2194 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 : \u2124\u221ad) : 0 < Int.gcd a.re a.im \u2194 a \u2260 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\u2093'. -/\ntheorem coprime_of_dvd_coprime {a b : \u2124\u221ad} (hcoprime : IsCoprime a.re a.im) (hdvd : b \u2223 a) :\n    IsCoprime b.re b.im := by\n  apply isCoprime_of_dvd\n  \u00b7 rintro \u27e8hre, him\u27e9\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  \u00b7 intro z hz hznezero hzdvdu hzdvdv\n    apply hz\n    obtain \u27e8ha, hb\u27e9 : z \u2223 a.re \u2227 z \u2223 a.im :=\n      by\n      rw [\u2190 coe_int_dvd_iff]\n      apply dvd_trans _ hdvd\n      rw [coe_int_dvd_iff]\n      exact \u27e8hzdvdu, hzdvdv\u27e9\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\u2093.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\u2093.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\u2093'. -/\ntheorem exists_coprime_of_gcd_pos {a : \u2124\u221ad} (hgcd : 0 < Int.gcd a.re a.im) :\n    \u2203 b : \u2124\u221ad, a = ((Int.gcd a.re a.im : \u2124) : \u2124\u221ad) * b \u2227 IsCoprime b.re b.im :=\n  by\n  obtain \u27e8re, im, H1, Hre, Him\u27e9 := Int.exists_gcd_one hgcd\n  rw [mul_comm] at Hre Him\n  refine' \u27e8\u27e8re, im\u27e9, _, _\u27e9\n  \u00b7 rw [smul_val, ext, \u2190 Hre, \u2190 Him]\n    constructor <;> rfl\n  \u00b7 rw [\u2190 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 \u221ac \u2264 b \u221ad` -/\ndef SqLe (a c b d : \u2115) : Prop :=\n  c * a * a \u2264 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 : \u2115} (xz : z \u2264 x) (yw : y \u2264 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 : \u2115} (xy : SqLe x c y d) (zw : SqLe z c w d) :\n    c * (x * z) \u2264 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 : \u2115} (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 : \u2115} (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 : \u2115} (n : \u2115) (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 : \u2115} :\n    (SqLe x 1 y d \u2192 SqLe z 1 w d \u2192 SqLe (x * w + y * z) d (x * z + d * y * w) 1) \u2227\n      (SqLe x 1 y d \u2192 SqLe w d z 1 \u2192 SqLe (x * z + d * y * w) 1 (x * w + y * z) d) \u2227\n        (SqLe y d x 1 \u2192 SqLe z 1 w d \u2192 SqLe (x * z + d * y * w) 1 (x * w + y * z) d) \u2227\n          (SqLe y d x 1 \u2192 SqLe w d z 1 \u2192 SqLe (x * w + y * z) d (x * z + d * y * w) 1) :=\n  by\n  refine' \u27e8_, _, _, _\u27e9 <;>\n    \u00b7 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 \u221ac + b \u221ad \u2265 0`;\n  we are interested in the case `c = 1` but this is more symmetric -/\ndef Nonnegg (c d : \u2115) : \u2124 \u2192 \u2124 \u2192 Prop\n  | (a : \u2115), (b : \u2115) => True\n  | (a : \u2115), -[b+1] => SqLe (b + 1) c a d\n  | -[a+1], (b : \u2115) => 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 : \u2115} {x y : \u2124} : 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} : \u2200 {a b : \u2115}, Nonnegg c d (-a) b \u2194 SqLe a d b c\n  | 0, b => \u27e8by simp [sq_le, Nat.zero_le], fun a => trivial\u27e9\n  | a + 1, b => by rw [\u2190 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 : \u2115} : Nonnegg c d a (-b) \u2194 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 : \u2115} :\n    \u2200 {b : \u2124}, (\u2200 x : \u2115, b = -x \u2192 SqLe x c a d) \u2192 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 : \u2115} {a : \u2124} (h : \u2200 x : \u2115, a = -x \u2192 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 `\u2124[\u221ad]`. -/\ndef norm (n : \u2124\u221ad) : \u2124 :=\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 : \u2124\u221ad) : 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\u2093.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\u2093'. -/\n@[simp]\ntheorem norm_int_cast (n : \u2124) : 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 : \u2115) : 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 : \u2124\u221ad) : 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\u2093'. -/\n/-- `norm` as a `monoid_hom`. -/\ndef normMonoidHom : \u2124\u221ad \u2192* \u2124 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\u2093.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\u2093'. -/\ntheorem norm_eq_mul_conj (n : \u2124\u221ad) : (norm n : \u2124\u221ad) = 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 : \u2124\u221ad) : (-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 : \u2124\u221ad) : (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 \u2264 0) (n : \u2124\u221ad) : 0 \u2264 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\u2093'. -/\ntheorem norm_eq_one_iff {x : \u2124\u221ad} : x.norm.natAbs = 1 \u2194 IsUnit x :=\n  \u27e8fun h =>\n    isUnit_iff_dvd_one.2 <|\n      (le_total 0 (norm x)).casesOn\n        (fun hx =>\n          show x \u2223 1 from\n            \u27e8star x, by\n              rwa [\u2190 Int.coe_nat_inj', Int.natAbs_of_nonneg hx, \u2190 @Int.cast_inj (\u2124\u221ad) _ _,\n                norm_eq_mul_conj, eq_comm] at h\u27e9)\n        fun hx =>\n        show x \u2223 1 from\n          \u27e8-star x, by\n            rwa [\u2190 Int.coe_nat_inj', Int.ofNat_natAbs_of_nonpos hx, \u2190 @Int.cast_inj (\u2124\u221ad) _ _,\n              Int.cast_neg, norm_eq_mul_conj, neg_mul_eq_mul_neg, eq_comm] at h\u27e9,\n    fun h => by\n    let \u27e8y, hy\u27e9 := isUnit_iff_dvd_one.1 h\n    have := congr_arg (Int.natAbs \u2218 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\u27e9\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\u2093'. -/\ntheorem isUnit_iff_norm_isUnit {d : \u2124} (z : \u2124\u221ad) : IsUnit z \u2194 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'\u2093'. -/\ntheorem norm_eq_one_iff' {d : \u2124} (hd : d \u2264 0) (z : \u2124\u221ad) : z.norm = 1 \u2194 IsUnit z := by\n  rw [\u2190 norm_eq_one_iff, \u2190 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 : \u2124} (hd : d < 0) (z : \u2124\u221ad) : z.norm = 0 \u2194 z = 0 :=\n  by\n  constructor\n  \u00b7 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 \u27e8ha, hb\u27e9 := (add_eq_zero_iff' left right).mp h\n    constructor <;> apply eq_zero_of_mul_self_eq_zero\n    \u00b7 exact ha\n    \u00b7 rw [neg_eq_zero, mul_eq_zero] at hb\n      exact hb.resolve_left hd.ne\n  \u00b7 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\u2093'. -/\ntheorem norm_eq_of_associated {d : \u2124} (hd : d \u2264 0) {x y : \u2124\u221ad} (h : Associated x y) :\n    x.norm = y.norm := by\n  obtain \u27e8u, rfl\u27e9 := 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 : \u2115}\n\n#print Zsqrtd.Nonneg /-\n/-- Nonnegativity of an element of `\u2124\u221ad`. -/\ndef Nonneg : \u2124\u221ad \u2192 Prop\n  | \u27e8a, b\u27e9 => Nonnegg d 1 a b\n#align zsqrtd.nonneg Zsqrtd.Nonneg\n-/\n\ninstance : LE (\u2124\u221ad) :=\n  \u27e8fun a b => nonneg (b - a)\u27e9\n\ninstance : LT (\u2124\u221ad) :=\n  \u27e8fun a b => \u00acb \u2264 a\u27e9\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 : \u2200 a : \u2124\u221ad, Decidable (nonneg a)\n  | \u27e8a, b\u27e9 => 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\u2093.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\u2093.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\u2093'. -/\ninstance decidableLE : @DecidableRel (\u2124\u221ad) (\u00b7 \u2264 \u00b7) := fun _ _ => decidable_nonneg _\n#align zsqrtd.decidable_le Zsqrtd.decidableLE\n\n#print Zsqrtd.nonneg_cases /-\ntheorem nonneg_cases : \u2200 {a : \u2124\u221ad}, nonneg a \u2192 \u2203 x y : \u2115, a = \u27e8x, y\u27e9 \u2228 a = \u27e8x, -y\u27e9 \u2228 a = \u27e8-x, y\u27e9\n  | \u27e8(x : \u2115), (y : \u2115)\u27e9, h => \u27e8x, y, Or.inl rfl\u27e9\n  | \u27e8(x : \u2115), -[y+1]\u27e9, h => \u27e8x, y + 1, Or.inr <| Or.inl rfl\u27e9\n  | \u27e8-[x+1], (y : \u2115)\u27e9, h => \u27e8x + 1, y, Or.inr <| Or.inr rfl\u27e9\n  | \u27e8-[x+1], -[y+1]\u27e9, 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 : \u2115} (xy : nonneg \u27e8x, -y\u27e9) (zw : nonneg \u27e8-z, w\u27e9) :\n    nonneg (\u27e8x, -y\u27e9 + \u27e8-z, w\u27e9) :=\n  have : nonneg \u27e8Int.subNatNat x z, Int.subNatNat w y\u27e9 :=\n    Int.subNatNat_elim x z\n      (fun m n i => SqLe y d m 1 \u2192 SqLe n 1 w d \u2192 nonneg \u27e8i, Int.subNatNat w y\u27e9)\n      (fun j k =>\n        Int.subNatNat_elim w y\n          (fun m n i => SqLe n d (k + j) 1 \u2192 SqLe k 1 m d \u2192 nonneg \u27e8Int.ofNat j, i\u27e9)\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 \u2192 SqLe (k + j + 1) 1 m d \u2192 nonneg \u27e8-[j+1], i\u27e9)\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 \u2264 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 \u27e8_, _\u27e9 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 : \u2124\u221ad} (ha : nonneg a) (hb : nonneg b) : nonneg (a + b) :=\n  by\n  rcases nonneg_cases ha with \u27e8x, y, rfl | rfl | rfl\u27e9 <;>\n    rcases nonneg_cases hb with \u27e8z, w, rfl | rfl | rfl\u27e9\n  \u00b7 trivial\n  \u00b7 refine' nonnegg_cases_right fun i h => sq_le_of_le _ _ (nonnegg_pos_neg.1 hb)\n    \u00b7 exact Int.ofNat_le.1 (le_of_neg_le_neg (@Int.le.intro _ _ y (by simp [add_comm, *])))\n    \u00b7 apply Nat.le_add_left\n  \u00b7 refine' nonnegg_cases_left fun i h => sq_le_of_le _ _ (nonnegg_neg_pos.1 hb)\n    \u00b7 exact Int.ofNat_le.1 (le_of_neg_le_neg (@Int.le.intro _ _ x (by simp [add_comm, *])))\n    \u00b7 apply Nat.le_add_left\n  \u00b7 refine' nonnegg_cases_right fun i h => sq_le_of_le _ _ (nonnegg_pos_neg.1 ha)\n    \u00b7 exact Int.ofNat_le.1 (le_of_neg_le_neg (@Int.le.intro _ _ w (by simp [*])))\n    \u00b7 apply Nat.le_add_right\n  \u00b7\n    simpa [add_comm] using\n      nonnegg_pos_neg.2 (sq_le_add (nonnegg_pos_neg.1 ha) (nonnegg_pos_neg.1 hb))\n  \u00b7 exact nonneg_add_lem ha hb\n  \u00b7 refine' nonnegg_cases_left fun i h => sq_le_of_le _ _ (nonnegg_neg_pos.1 ha)\n    \u00b7 exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro h))\n    \u00b7 apply Nat.le_add_right\n  \u00b7 dsimp\n    rw [add_comm, add_comm \u2191y]\n    exact nonneg_add_lem hb ha\n  \u00b7\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem nonneg_iff_zero_le {a : \u2124\u221ad} : nonneg a \u2194 0 \u2264 a :=\n  show _ \u2194 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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem le_of_le_le {x y z w : \u2124} (xz : x \u2264 z) (yw : y \u2264 w) : (\u27e8x, y\u27e9 : \u2124\u221ad) \u2264 \u27e8z, w\u27e9 :=\n  show nonneg \u27e8z - x, w - y\u27e9 from\n    match z - x, w - y, Int.le.dest_sub xz, Int.le.dest_sub yw with\n    | _, _, \u27e8a, rfl\u27e9, \u27e8b, rfl\u27e9 => trivial\n#align zsqrtd.le_of_le_le Zsqrtd.le_of_le_le\n\n#print Zsqrtd.nonneg_total /-\nprotected theorem nonneg_total : \u2200 a : \u2124\u221ad, nonneg a \u2228 nonneg (-a)\n  | \u27e8(x : \u2115), (y : \u2115)\u27e9 => Or.inl trivial\n  | \u27e8-[x+1], -[y+1]\u27e9 => Or.inr trivial\n  | \u27e80, -[y+1]\u27e9 => Or.inr trivial\n  | \u27e8-[x+1], 0\u27e9 => Or.inr trivial\n  | \u27e8(x + 1 : \u2115), -[y+1]\u27e9 => Nat.le_total\n  | \u27e8-[x+1], (y + 1 : \u2115)\u27e9 => 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem le_total (a b : \u2124\u221ad) : a \u2264 b \u2228 b \u2264 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 (\u2124\u221ad) where\n  le := (\u00b7 \u2264 \u00b7)\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 := (\u00b7 < \u00b7)\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\u2093.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\u2093.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\u2093.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\u2093.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) d)) (CoeTC\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem le_arch (a : \u2124\u221ad) : \u2203 n : \u2115, a \u2264 n :=\n  by\n  let \u27e8x, y, (h : a \u2264 \u27e8x, y\u27e9)\u27e9 :=\n    show \u2203 x y : \u2115, nonneg (\u27e8x, y\u27e9 + -a) from\n      match -a with\n      | \u27e8Int.ofNat x, Int.ofNat y\u27e9 => \u27e80, 0, trivial\u27e9\n      | \u27e8Int.ofNat x, -[y+1]\u27e9 => \u27e80, y + 1, by simp [Int.negSucc_coe, add_assoc]\u27e9\n      | \u27e8-[x+1], Int.ofNat y\u27e9 => \u27e8x + 1, 0, by simp [Int.negSucc_coe, add_assoc]\u27e9\n      | \u27e8-[x+1], -[y+1]\u27e9 => \u27e8x + 1, y + 1, by simp [Int.negSucc_coe, add_assoc]\u27e9\n  refine' \u27e8x + d * y, h.trans _\u27e9\n  change nonneg \u27e8\u2191x + d * y - \u2191x, 0 - \u2191y\u27e9\n  cases' y with y\n  \u00b7 simp\n  have h : \u2200 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 : \u2124) + 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem add_le_add_left (a b : \u2124\u221ad) (ab : a \u2264 b) (c : \u2124\u221ad) : c + a \u2264 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem le_of_add_le_add_left (a b c : \u2124\u221ad) (h : c + a \u2264 c + b) : a \u2264 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem add_lt_add_left (a b : \u2124\u221ad) (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 : \u2124\u221ad} {n : \u2115} (ha : nonneg a) : nonneg (n * a) := by\n  simp (config := { singlePass := true }) only [\u2190 Int.cast_ofNat] <;>\n    exact\n      match a, nonneg_cases ha, ha with\n      | _, \u27e8x, y, Or.inl rfl\u27e9, ha => by rw [smul_val] <;> trivial\n      | _, \u27e8x, y, Or.inr <| Or.inl rfl\u27e9, ha => by\n        rw [smul_val] <;> simpa using nonnegg_pos_neg.2 (sq_le_smul n <| nonnegg_pos_neg.1 ha)\n      | _, \u27e8x, y, Or.inr <| Or.inr rfl\u27e9, 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 : \u2124\u221ad} (ha : nonneg a) : nonneg (sqrtd * a) := by\n  refine'\n    match a, nonneg_cases ha, ha with\n    | _, \u27e8x, y, Or.inl rfl\u27e9, ha => trivial\n    | _, \u27e8x, y, Or.inr <| Or.inl rfl\u27e9, 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    | _, \u27e8x, y, Or.inr <| Or.inr rfl\u27e9, 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 : \u2115} {a : \u2124\u221ad} (ha : nonneg a) : nonneg (\u27e8x, y\u27e9 * a) :=\n  by\n  have : (\u27e8x, y\u27e9 * a : \u2124\u221ad) = 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 : \u2124\u221ad} (ha : nonneg a) (hb : nonneg b) : nonneg (a * b) :=\n  match a, b, nonneg_cases ha, nonneg_cases hb, ha, hb with\n  | _, _, \u27e8x, y, Or.inl rfl\u27e9, \u27e8z, w, Or.inl rfl\u27e9, ha, hb => trivial\n  | _, _, \u27e8x, y, Or.inl rfl\u27e9, \u27e8z, w, Or.inr <| Or.inr rfl\u27e9, ha, hb => nonneg_mul_lem hb\n  | _, _, \u27e8x, y, Or.inl rfl\u27e9, \u27e8z, w, Or.inr <| Or.inl rfl\u27e9, ha, hb => nonneg_mul_lem hb\n  | _, _, \u27e8x, y, Or.inr <| Or.inr rfl\u27e9, \u27e8z, w, Or.inl rfl\u27e9, ha, hb => by\n    rw [mul_comm] <;> exact nonneg_mul_lem ha\n  | _, _, \u27e8x, y, Or.inr <| Or.inl rfl\u27e9, \u27e8z, w, Or.inl rfl\u27e9, ha, hb => by\n    rw [mul_comm] <;> exact nonneg_mul_lem ha\n  | _, _, \u27e8x, y, Or.inr <| Or.inr rfl\u27e9, \u27e8z, w, Or.inr <| Or.inr rfl\u27e9, ha, hb => by\n    rw [calc\n          (\u27e8-x, y\u27e9 * \u27e8-z, w\u27e9 : \u2124\u221ad) = \u27e8_, _\u27e9 := rfl\n          _ = \u27e8x * z + d * y * w, -(x * w + y * z)\u27e9 := 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  | _, _, \u27e8x, y, Or.inr <| Or.inr rfl\u27e9, \u27e8z, w, Or.inr <| Or.inl rfl\u27e9, ha, hb => by\n    rw [calc\n          (\u27e8-x, y\u27e9 * \u27e8z, -w\u27e9 : \u2124\u221ad) = \u27e8_, _\u27e9 := rfl\n          _ = \u27e8-(x * z + d * y * w), x * w + y * z\u27e9 := 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  | _, _, \u27e8x, y, Or.inr <| Or.inl rfl\u27e9, \u27e8z, w, Or.inr <| Or.inr rfl\u27e9, ha, hb => by\n    rw [calc\n          (\u27e8x, -y\u27e9 * \u27e8-z, w\u27e9 : \u2124\u221ad) = \u27e8_, _\u27e9 := rfl\n          _ = \u27e8-(x * z + d * y * w), x * w + y * z\u27e9 := 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  | _, _, \u27e8x, y, Or.inr <| Or.inl rfl\u27e9, \u27e8z, w, Or.inr <| Or.inl rfl\u27e9, ha, hb => by\n    rw [calc\n          (\u27e8x, -y\u27e9 * \u27e8z, -w\u27e9 : \u2124\u221ad) = \u27e8_, _\u27e9 := rfl\n          _ = \u27e8x * z + d * y * w, -(x * w + y * z)\u27e9 := 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem mul_nonneg (a b : \u2124\u221ad) : 0 \u2264 a \u2192 0 \u2264 b \u2192 0 \u2264 a * b := by\n  repeat' rw [\u2190 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) : \u00acSqLe (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 : \u2115) : Prop where\n  ns : \u2200 n : \u2115, x \u2260 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 \u2227 y = 0 :=\n  let g := x.gcd y\n  Or.elim g.eq_zero_or_pos\n    (fun H => \u27e8Nat.eq_zero_of_gcd_eq_zero_left H, Nat.eq_zero_of_gcd_eq_zero_right H\u27e9) fun gpos =>\n    False.elim <|\n      by\n      let \u27e8m, n, co, (hx : x = m * g), (hy : y = n * g)\u27e9 := Nat.exists_coprime gpos\n      rw [hx, hy] at h\n      have : m * m = d * (n * n) :=\n        mul_left_cancel\u2080 (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 : \u2124} (h : x * x = d * y * y) : x = 0 \u2227 y = 0 := by\n  rw [mul_assoc, \u2190 Int.natAbs_mul_self, \u2190 Int.natAbs_mul_self, \u2190 Int.ofNat_mul, \u2190 mul_assoc] at\n      h <;>\n    exact\n      let \u27e8h1, h2\u27e9 := divides_sq_eq_zero (Int.ofNat.inj h)\n      \u27e8Int.eq_zero_of_natAbs_eq_zero h1, Int.eq_zero_of_natAbs_eq_zero h2\u27e9\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) \u2260 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 : \u2200 {a : \u2124\u221ad}, nonneg a \u2192 nonneg (-a) \u2192 a = 0\n  | \u27e80, 0\u27e9, xy, yx => rfl\n  | \u27e8-[x+1], -[y+1]\u27e9, xy, yx => False.elim xy\n  | \u27e8(x + 1 : Nat), (y + 1 : Nat)\u27e9, xy, yx => False.elim yx\n  | \u27e8-[x+1], 0\u27e9, xy, yx => absurd xy (not_sqLe_succ _ _ _ (by decide))\n  | \u27e8(x + 1 : Nat), 0\u27e9, xy, yx => absurd yx (not_sqLe_succ _ _ _ (by decide))\n  | \u27e80, -[y+1]\u27e9, xy, yx => absurd xy (not_sqLe_succ _ _ _ d_pos)\n  | \u27e80, (y + 1 : Nat)\u27e9, _, yx => absurd yx (not_sqLe_succ _ _ _ d_pos)\n  | \u27e8(x + 1 : Nat), -[y+1]\u27e9, (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  | \u27e8-[x+1], (y + 1 : Nat)\u27e9, (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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem le_antisymm {a b : \u2124\u221ad} (ab : a \u2264 b) (ba : b \u2264 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 (\u2124\u221ad) :=\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 : \u2200 {a b : \u2124\u221ad}, a * b = 0 \u2192 a = 0 \u2228 b = 0\n  | \u27e8x, y\u27e9, \u27e8z, w\u27e9, 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 \u2192 (\u27e8x, y\u27e9 : \u2124\u221ad) = 0 := fun e =>\n          match x, y, divides_sq_eq_zero_z e with\n          | _, _, \u27e8rfl, rfl\u27e9 => 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\u2080 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\u2080 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 (\u2124\u221ad)\n    where eq_zero_or_eq_zero_of_mul_eq_zero := @Zsqrtd.eq_zero_or_eq_zero_of_mul_eq_zero\n\ninstance : IsDomain (\u2124\u221ad) :=\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\nprotected theorem mul_pos (a b : \u2124\u221ad) (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 (\u2124\u221ad) :=\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 (\u2124\u221ad) := by infer_instance\n\ninstance : OrderedRing (\u2124\u221ad) := by infer_instance\n\nend\n\n#print Zsqrtd.norm_eq_zero /-\ntheorem norm_eq_zero {d : \u2124} (h_nonsquare : \u2200 n : \u2124, d \u2260 n * n) (a : \u2124\u221ad) : norm a = 0 \u2194 a = 0 :=\n  by\n  refine' \u27e8fun ha => ext.mpr _, fun h => by rw [h, norm_zero]\u27e9\n  delta norm at ha\n  rw [sub_eq_zero] at ha\n  by_cases h : 0 \u2264 d\n  \u00b7 obtain \u27e8d', rfl\u27e9 := Int.eq_ofNat_of_zero_le h\n    haveI : nonsquare d' := \u27e8fun n h => h_nonsquare n <| by exact_mod_cast h\u27e9\n    exact divides_sq_eq_zero_z ha\n  \u00b7 push_neg  at h\n    suffices a.re * a.re = 0 by\n      rw [eq_zero_of_mul_self_eq_zero this] at ha\u22a2\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\u2093'. -/\n@[ext]\ntheorem hom_ext [Ring R] {d : \u2124} (f g : \u2124\u221ad \u2192+* R) (h : f sqrtd = g sqrtd) : f = g :=\n  by\n  ext \u27e8x_re, x_im\u27e9\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\u2093.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\u2093'. -/\n/-- The unique `ring_hom` from `\u2124\u221ad` to a ring `R`, constructed by replacing `\u221ad` with the provided\nroot. Conversely, this associates to every mapping `\u2124\u221ad \u2192+* R` a value of `\u221ad` in `R`. -/\n@[simps]\ndef lift {d : \u2124} : { r : R // r * r = \u2191d } \u2243 (\u2124\u221ad \u2192+* 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 := \u27e8f sqrtd, by rw [\u2190 f.map_mul, dmuld, map_intCast]\u27e9\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\n/-- `lift r` is injective if `d` is non-square, and R has characteristic zero (that is, the map from\n`\u2124` into `R` is injective). -/\ntheorem lift_injective [CharZero R] {d : \u2124} (r : { r : R // r * r = \u2191d })\n    (hd : \u2200 n : \u2124, d \u2260 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 : \u2124 \u2192 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 [\u2190 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\u2093'. -/\n/-- An element of `\u2124\u221ad` 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 : \u2124} {a : \u2124\u221ad} : a.norm = 1 \u2194 a \u2208 unitary (\u2124\u221ad) :=\n  by\n  rw [unitary.mem_iff_self_mul_star, \u2190 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\u2093'. -/\n/-- The kernel of the norm map on `\u2124\u221ad` equals the submonoid of unitary elements. -/\ntheorem mker_norm_eq_unitary {d : \u2124} : (@normMonoidHom d).mker = unitary (\u2124\u221ad) :=\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 \u00a9 2019 Fran\u00e7ois 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 {\u03b1 : Type*} (\u03b2 : \u03b1 \u2192 \u03b1 \u2192 Type*) :=\n(op (a b c : \u03b1) : \u03b2 a b \u2192 \u03b2 b c \u2192 \u03b2 a c)\n(id (a : \u03b1) : \u03b2 a a)\n\nnamespace category_sig\nvariables {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 \u03b1 \u2192 Type*} (s : category_sig \u03b2)\n\n@[signature_instance]\ndefinition to_monoid (a : \u03b1) : monoid_sig (\u03b2 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 : \u03b1) : left_action_sig (\u03b2 a a) (\u03b2 a b) :=\n{ act := s.op a a b\n}\n\n@[signature_instance]\ndefinition to_right_action (a b : \u03b1) : right_action_sig (\u03b2 a a) (\u03b2 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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 \u03b1 \u2192 Type*} (s : category_sig \u03b2) : 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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 \u03b1 \u2192 Type*} (s : category_sig \u03b2) [i : category s]\n\ndefinition infer \n[\u03a0 (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[\u03a0 (a b), class.op_left_identity (s.op a a b) (s.id a)]\n[\u03a0 (a b), class.op_right_identity (s.op a b b) (s.id b)] : category s :=\ncategory.intro\n(\u03bb _ _ _ _, op_compatibility _ _ _ _)\n(\u03bb _ _, op_left_identity _ _)\n(\u03bb _ _, op_right_identity _ _)\n\ninclude i\n\ninstance to_monoid (a : \u03b1) : monoid (s.to_monoid a) := monoid.infer _\n\ninstance to_left_monoid_action (a b : \u03b1) : 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 : \u03b1) : 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 {\u03b1 : Type*} (s : monoid_sig \u03b1)\n\n@[signature_instance]\ndefinition to_category : category_sig (\u03bb (_ _ : unit), \u03b1) :=\n{ op := \u03bb _ _ _, s.op\n, id := \u03bb _, s.id\n}\n\nend monoid_sig\n\nnamespace monoid\nvariables {\u03b1 : Type*} (s : monoid_sig \u03b1) [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 (\u03c4: Type) := list \u03c4\n\n/- In the QTT paper, this is the \"precontext\".\n   \u03c4 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 {\u03c4 mult: Type}: precontext \u03c4 \u2192 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 {\u03b3: precontext \u03c4} (\u03c0: mult) (T: \u03c4): context \u03b3 \u2192 context (T::\u03b3)\n\nnotation `\u27e6`\u03c0`\u2b1d`T`\u27e7::`\u0393:90 := context.cons \u03c0 T \u0393\n\n/- Indexes an assumption in the typing context. -/\ninductive debrujin_idx {\u03c4: Type}: precontext \u03c4 \u2192 \u03c4 \u2192 Type\ninfix ` \u220b `:55 := debrujin_idx\n| ZVar: \u03a0 {\u03b3: precontext \u03c4} {T: \u03c4},\n  ----------\n  (T::\u03b3) \u220b T\n| SVar: \u03a0 {\u03b3: precontext \u03c4} {T U: \u03c4},\n  \u03b3 \u220b T\n  ----------\n\u2192 (U::\u03b3) \u220b T\ninfix ` \u220b `:55 := debrujin_idx\n\nnamespace context\n\nvariable {\u03c4: Type}\nvariables {mult: Type} [semiring mult]\n\ndef zeros: \u03a0 (\u03b3: precontext \u03c4), @context \u03c4 mult \u03b3\n| [] := nil\n| (T::\u03b4) := \u27e60\u2b1dT\u27e7::(zeros \u03b4)\n\ninstance {\u03b3: precontext \u03c4} : has_zero (@context \u03c4 mult \u03b3) :=\n  \u27e8zeros \u03b3\u27e9\n\n@[unfold_] lemma zeros_cons {\u03b3: precontext \u03c4} {T: \u03c4}\n  : (0: @context \u03c4 mult (T::\u03b3)) = \u27e6(0: mult)\u2b1dT\u27e7::(0: @context \u03c4 mult \u03b3) := by refl\n\nprotected def add: \u03a0 {\u03b3}, @context \u03c4 mult \u03b3 \u2192 @context \u03c4 mult \u03b3 \u2192 @context \u03c4 mult \u03b3\n| _ nil nil := nil\n| _ (\u27e6\u03c0\u2081\u2b1dT\u27e7::\u0393\u2081) (\u27e6\u03c0\u2082\u2b1d.(T)\u27e7::\u0393\u2082) := \u27e6(\u03c0\u2081+\u03c0\u2082)\u2b1dT\u27e7::(add \u0393\u2081 \u0393\u2082)\n\ninstance {\u03b3: precontext \u03c4} : has_add (@context \u03c4 mult \u03b3) :=\n  \u27e8context.add\u27e9\n\n@[simp] lemma add_nil\n  : (nil: @context \u03c4 mult []) + nil = nil := by refl\n\n@[unfold_] lemma add_cons {\u03b3} {\u0393\u2081 \u0393\u2082: @context \u03c4 mult \u03b3} {\u03c0\u2081 \u03c0\u2082: mult} {T: \u03c4}\n  : \u27e6\u03c0\u2081\u2b1dT\u27e7::\u0393\u2081 + \u27e6\u03c0\u2082\u2b1dT\u27e7::\u0393\u2082 = \u27e6(\u03c0\u2081+\u03c0\u2082)\u2b1dT\u27e7::(\u0393\u2081 + \u0393\u2082) := by refl\n\n/- addition makes a commutative monoid -/\n\n@[simp] lemma zero_add\n  : \u2200 {\u03b3} {\u0393: @context \u03c4 mult \u03b3},\n    0 + \u0393 = \u0393 :=\nbegin\n  intros,\n  induction \u0393 with \u03b3 \u03c0 T \u0393 ih,\n  { refl },\n  { unfold has_zero.zero zeros at *,\n    simp * with unfold_, show \u03c0+0=\u03c0,\n    abel },\nend\n\n@[simp] lemma add_zero\n  : \u2200 {\u03b3} {\u0393: @context \u03c4 mult \u03b3},\n    \u0393 + 0 = \u0393 :=\nbegin\n  intros,\n  induction \u0393 with \u03b3 \u03c0 T \u0393 ih,\n  { refl },\n  { unfold has_zero.zero zeros at *,\n    simp * with unfold_, show \u03c0+0=\u03c0,\n    abel },\nend\n\nlemma add_comm\n  : \u2200 {\u03b3} {\u0393\u2081 \u0393\u2082: @context \u03c4 mult \u03b3},\n    \u0393\u2081 + \u0393\u2082 = \u0393\u2082 + \u0393\u2081 :=\nbegin\n  intros,\n  induction \u0393\u2081 with \u03b3\u2081 \u03c0\u2081 T\u2081 \u0393\u2081 ih\u2081,\n  { cases \u0393\u2082, refl },\n  { cases \u0393\u2082 with _ \u03c0\u2082,\n    simp * with unfold_ },\nend\n\nlemma add_assoc\n  : \u2200 {\u03b3} {\u0393\u2081 \u0393\u2082 \u0393\u2083: @context \u03c4 mult \u03b3},\n    (\u0393\u2081 + \u0393\u2082) + \u0393\u2083 = \u0393\u2081 + (\u0393\u2082 + \u0393\u2083) :=\nbegin\n  intros,\n  induction \u0393\u2081 with \u03b3\u2081 \u03c0\u2081 T\u2081 \u0393\u2081 ih\u2081,\n  { cases \u0393\u2082, cases \u0393\u2083, refl },\n  { cases \u0393\u2082 with _ \u03c0\u2082,\n    cases \u0393\u2083 with _ \u03c0\u2083,\n    simp * with unfold_ },\nend\n\ninstance [h: semiring mult] {\u03b3: precontext \u03c4} : add_comm_monoid (@context \u03c4 mult \u03b3) :=\n{ add := context.add,\n  zero := zeros \u03b3,\n  zero_add := @zero_add \u03c4 mult h \u03b3,\n  add_zero := @add_zero \u03c4 mult h \u03b3,\n  add_comm := @add_comm \u03c4 mult h \u03b3,\n  add_assoc := @add_assoc \u03c4 mult h \u03b3 }\n\nprotected def smul: \u03a0 {\u03b3}, mult \u2192 @context \u03c4 mult \u03b3 \u2192 @context \u03c4 mult \u03b3\n| _ \u03c0 nil := nil\n| _ \u03c0 (\u27e6\u03c0'\u2b1dT\u27e7::\u0393) := \u27e6(\u03c0*\u03c0')\u2b1dT\u27e7::(smul \u03c0 \u0393)\n\ninstance {\u03b3: precontext \u03c4} : has_scalar mult (@context \u03c4 mult \u03b3) :=\n  \u27e8context.smul\u27e9\n\n@[simp] lemma smul_nil {\u03c0: mult}\n  : \u03c0 \u2022 (nil: @context \u03c4 mult []) = nil := by refl\n\n@[unfold_] lemma smul_cons {\u03b3} {\u0393: @context \u03c4 mult \u03b3} {\u03c0 \u03c0': mult} {T: \u03c4}\n  : \u03c0 \u2022 \u27e6\u03c0'\u2b1dT\u27e7::\u0393 = \u27e6(\u03c0*\u03c0')\u2b1dT\u27e7::(\u03c0 \u2022 \u0393) := by refl\n\n/- scalar multiplication (mult \u2022 context) makes a semimodule -/\n\n@[simp] lemma one_smul\n  : \u2200 {\u03b3} {\u0393: @context \u03c4 mult \u03b3},\n    ((1: mult) \u2022 \u0393: @context \u03c4 mult \u03b3) = \u0393 :=\nbegin\n  intros,\n  induction \u0393 with \u03b3 \u03c0 T \u0394 ih,\n  { refl },\n  { simp * with unfold_ },\nend\n\n@[simp] lemma zero_smul\n  : \u2200 {\u03b3} {\u0393: @context \u03c4 mult \u03b3},\n    ((0: mult) \u2022 \u0393: @context \u03c4 mult \u03b3) = 0 :=\nbegin\n  intros,\n  induction \u0393 with \u03b3 \u03c0 T \u0393 ih,\n  { refl },\n  { simp * with unfold_ },\nend\n\n@[simp] lemma smul_zero\n  : \u2200 {\u03b3} {\u03c0: mult},\n    (\u03c0 \u2022 0: @context \u03c4 mult \u03b3) = 0 :=\nbegin\n  intros,\n  induction \u03b3 with T \u03b3 ih,\n  { refl },\n  { unfold has_zero.zero zeros,\n    unfold has_zero.zero zeros at ih,\n    simp * with unfold_,\n    show \u03c0*0=0, simp * },\nend\n\n@[sop_form] lemma smul_add\n  : \u2200 {\u03b3} {\u03c0: mult} {\u0393\u2081 \u0393\u2082: @context \u03c4 mult \u03b3},\n    \u03c0 \u2022 (\u0393\u2081 + \u0393\u2082) = \u03c0\u2022\u0393\u2081 + \u03c0\u2022\u0393\u2082 :=\nbegin\n  intros,\n  induction \u0393\u2081 with \u03b3\u2081 \u03c0\u2081 T\u2081 \u0393\u2081 ih\u2081,\n  { cases \u0393\u2082, refl },\n  { cases \u0393\u2082 with _ \u03c0\u2082,\n    simp [*, left_distrib] with unfold_ },\nend\n\n@[sop_form] lemma add_smul\n  : \u2200 {\u03b3} {\u03c0\u2081 \u03c0\u2082: mult} {\u0393: @context \u03c4 mult \u03b3},\n    (\u03c0\u2081 + \u03c0\u2082) \u2022 \u0393 = \u03c0\u2081\u2022\u0393 + \u03c0\u2082\u2022\u0393 :=\nbegin\n  intros,\n  induction \u0393 with \u03b3 \u03c0 T \u0393 ih,\n  { refl },\n  { simp [*, right_distrib] with unfold_ },\nend\n\nlemma mul_smul\n  : \u2200 {\u03b3} {\u03c0 \u03c0': mult} {\u0393: @context \u03c4 mult \u03b3},\n    (\u03c0 * \u03c0') \u2022 \u0393 = \u03c0 \u2022 (\u03c0' \u2022 \u0393) :=\nbegin\n  intros, induction \u0393 with \u03b3 \u03c0 T \u0393 ih,\n  { refl },\n  { simp [*, mul_assoc] with unfold_ },\nend\n\ninstance [h: semiring mult] {\u03b3: precontext \u03c4} : semimodule mult (@context \u03c4 mult \u03b3) :=\n{ one_smul := @one_smul \u03c4 mult h \u03b3,\n  zero_smul := @zero_smul \u03c4 mult h \u03b3,\n  smul_zero := @smul_zero \u03c4 mult h \u03b3,\n  smul_add := @smul_add \u03c4 mult h \u03b3,\n  add_smul := @add_smul \u03c4 mult h \u03b3,\n  mul_smul := @mul_smul \u03c4 mult h \u03b3 }\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  {\u03b1 \u03b2 : Type}\n  [decidable_eq \u03b1]\n  (f : \u03b1 \u2192 \u03b2)\n  (a' : \u03b1) (b : \u03b2) (a : \u03b1) :=\n  if a = a' then b else f a\n\n\nlemma function.update_ite_comp\n  {\u03b1 \u03b1' \u03b2 : Sort*}\n  [decidable_eq \u03b1]\n  (f : \u03b1' \u2192 \u03b2)\n  (g : \u03b1 \u2192 \u03b1')\n  (i : \u03b1)\n  (v : \u03b1') :\n  f \u2218 (function.update_ite g i v) =\n    function.update_ite (f \u2218 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  {\u03b1 \u03b2 : Type}\n  [decidable_eq \u03b1]\n  (f : \u03b1 \u2192 \u03b2)\n  (a : \u03b1)\n  (x y : \u03b2)  :\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  {\u03b1 : Type}\n  [decidable_eq \u03b1]\n  (x : \u03b1) :\n  function.update_ite (id : \u03b1 \u2192 \u03b1) 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  {\u03b1 \u03b2 : Type}\n  [decidable_eq \u03b1]\n  (l : list \u03b1)\n  (f : \u03b1 \u2192 \u03b2)\n  (a : \u03b1)\n  (b : \u03b2)\n  (h1 : a \u2209 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  {\u03b1 \u03b2 : Type}\n  [decidable_eq \u03b1] [decidable_eq \u03b2]\n  (S : finset \u03b1)\n  (f : \u03b1 \u2192 \u03b2)\n  (a : \u03b1)\n  (b : \u03b2)\n  (h1 : a \u2209 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\u2081\n  {\n    simp only [finset.image_empty],\n  },\n  case h\u2082 : 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 \u22a2 div : int * int -> int\n    ]\n  := by\n  sorry\n\ntheorem div_thm\n  : \u2200 n d : Nat, d > 0 \u2192 \u2203 q r : Nat,\n    r < d \u2227\n    n = q * d + r \u2227\n    [smlprop|\n      program_state \u22a2 div (\u2191n, \u2191d) ==>* program_state \u22a2 \u2191q\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 \u27e80, n, h, by simp, ?_\u27e9\n    (calc\n      (program_state, [sml_exp| div (\u2191n, \u2191d)])\n        ==>* (program_state, [sml_exp| 0 ]) := by sorry\n      _ ==>* (program_state, [sml_exp| \u21910 ]) := \u27e80, rfl, rfl\u27e9\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 \u27e8q,r,hr,hn,steps\u27e9 := ih (n-d) this\n    have : n = (1+q) * d + r := by\n      rw [Nat.add_mul, Nat.add_assoc, \u2190hn, Nat.one_mul, Nat.add_comm, Nat.sub_add_cancel (Nat.ge_of_not_lt h)]\n    refine \u27e8_, _, hr, this, ?_\u27e9\n    (calc\n             (program_state, [sml_exp| div (\u2191n, \u2191d)])\n        ==>* (program_state, [sml_exp| 1 + div (\u2191n-\u2191d,\u2191d)]) := by sorry\n      _ ==>* (program_state, [sml_exp| 1 + \u2191q ])            := by sorry -- ih\n      _ ==>* (program_state, [sml_exp| \u2191(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 : \u2115 \u2192 I \u2192 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 : \u2115 \u2192 A \u2192 A`, extended by 0.\n\n## References \n\n* P. Berthelot (1974), *Cohomologie cristalline des sch\u00e9mas de caract\u00e9ristique $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). \u00ab\u00a0Lois polynomes et lois formelles en th\u00e9orie des modules\u00a0\u00bb. Annales scientifiques de l\u2019\u00c9cole Normale Sup\u00e9rieure 80 (3): 213\u2011348. https://doi.org/10.24033/asens.1124.\n\n* N. Roby (1968), *Construction de certaines alg\u00e8bres \u00e0 puissances divis\u00e9es*, \nBulletin de la Soci\u00e9t\u00e9 Math\u00e9matique de France, Tome 96, p. 97-113. \ndoi: https://doi.org/10.24033/bsmf.1661\n\n* N. Roby (1966), *Sur l'alg\u00e8bre des puissances divis\u00e9es d'un module et le module de ses \ndiff\u00e9rentielles*, Annales scientifiques de l'\u00c9cole Normale Sup\u00e9rieure, S\u00e9rie 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 : \u2115 \u2192 A \u2192 A)\n(dpow_null : \u2200 {n x} (hx : x \u2209 I), dpow n x = 0)\n(dpow_zero : \u2200 {x} (hx : x \u2208 I), dpow 0 x = 1)\n(dpow_one : \u2200 {x} (hx : x \u2208 I), dpow 1 x = x)\n(dpow_mem : \u2200 {n} (hn : n \u2260 0) {x} (hx : x \u2208 I), dpow n x \u2208 I)\n(dpow_add : \u2200 n {x y} (hx : x \u2208 I) (hy : y \u2208 I) , dpow n (x + y)\n  = finset.sum (finset.range (n + 1)) (\u03bb k, (dpow k x) * (dpow (n - k) y)))\n(dpow_smul : \u2200 n {a : A} {x} (hx : x \u2208 I), dpow n (a * x) = (a ^ n) * (dpow n x))\n(dpow_mul : \u2200 m n {x} (hx : x \u2208 I), (dpow m x) * (dpow n x) = (nat.choose (m+n) m) * dpow (m + n) x)\n(dpow_comp : \u2200 m {n} (hn : n \u2260 0) {x} (hx : x \u2208 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) (\u03bb _, \u2115 \u2192 A \u2192 A) :=\n\u27e8\u03bb hI, hI.dpow\u27e9\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 (\u03bb n, hI.dpow n a)\n\nlemma add_dpow_exp (hI : divided_powers I) {a b : A} (ha : a \u2208 I) (hb : b \u2208 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 : \u2200 (n : \u2115) {x : A} (hx : x \u2208 I), hI.dpow n x = hI'.dpow n x ) : hI = hI' :=\nbegin\n  ext n x,\n  by_cases hx : x \u2208 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) (\u03b5 : I \u2192 power_series A) : \n  \u2115 \u2192 A \u2192 A := \u03bb n,\n  function.extend \n    (\u03bb (a : I), a.val) \n    (\u03bb a, power_series.coeff A n (\u03b5 a))\n    (\u03bb (a :A) , (0 : A))\n\n-- Golfed version of definition\nnoncomputable def dpow_of_dpow_exp (I : ideal A) (\u03b5 : I \u2192 power_series A) : \u2115 \u2192 A \u2192 A := \n\u03bb n, function.extend (\u03bb (a : I), (a : A)) (\u03bb (a : I), power_series.coeff A n (\u03b5 a)) 0\n\ndef divided_powers_of_dpow_exp (I : ideal A) (\u03b5 : I \u2192 power_series A)\n  (h\u03b5_add : \u2200 (a b : I), \u03b5(a + b) = \u03b5(a) * \u03b5(b))\n  (h\u03b5_zero : \u03b5(0) = 1) -/\n\n\nvariable (hI : divided_powers I)\n\n/- Rewriting lemmas -/\nlemma dpow_smul' (n : \u2115) {a : A} {x : A} (hx : x \u2208 I) :\n  hI.dpow n (a \u2022 x) = (a ^ n) \u2022 (hI.dpow n x) :=\nby simp only [smul_eq_mul, hI.dpow_smul, hx]\n\nlemma factorial_mul_dpow_eq_pow (n : \u2115) (x : A) (hx : x \u2208 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), \u2190 (n + 1).choose_one_right,\n  \u2190 nat.choose_symm_add, nat.cast_mul, nat.succ_eq_add_one, mul_assoc, \n  \u2190 hI.dpow_mul n 1 hx, \u2190 mul_assoc, ih, hI.dpow_one hx, pow_succ'], }\nend\n\nlemma dpow_eval_zero {n : \u2115} (hn : n \u2260 0) : hI.dpow n 0 = 0 := \nby rw [\u2190 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 : \u2115} (hn : n \u2260 0)\n  (hnI : \u2200 {y : A}(hy : y \u2208 I), n \u2022 y = 0) {x : A} (hx : x \u2208 I) : x^n = 0 := \nbegin\n  have h_fac: (n.factorial : A) * hI.dpow n x = n \u2022 ((n-1).factorial : A) * hI.dpow n x,\n  { rw [nsmul_eq_mul, \u2190 nat.cast_mul, nat.mul_factorial_pred (nat.pos_of_ne_zero hn)] },\n  rw [\u2190 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 \u2022 J \n(Berthelot, 1.6.1 (ii))-/\nlemma coincide_on_smul {J : ideal A} (hJ : divided_powers J) {n : \u2115} {a : A} (ha : a \u2208 I \u2022 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      \u2190 hJ.factorial_mul_dpow_eq_pow n b hb, \u2190 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 {\u03b9 : Type*} [decidable_eq \u03b9] {s : finset \u03b9} (n : \u03b9 \u2192 \u2115) {a : A} (ha : a \u2208 I):\n  s.prod (\u03bb 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 = \u2205 \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 \u2190mul_assoc, \n  nth_rewrite 1 [mul_comm], \n  rw mul_assoc,\n  rw dpow_mul _ _ _ ha, \n  rw \u2190 finset.sum_insert hi, \n  rw \u2190 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 \u201cmultinomial\u201d theorem for divided powers \u2014 but without multinomial coefficients \n  \u2014 using only dpow_zero, dpow_add and dpow_eval_zero  -/\nlemma sum_dpow_aux (dpow : \u2115 \u2192 A \u2192 A) (dpow_zero : \u2200 {x} (hx : x \u2208 I), dpow 0 x = 1)\n  (dpow_add : \u2200 n {x y} (hx : x \u2208 I) (hy : y \u2208 I) , dpow n (x + y) =\n    finset.sum (finset.range (n + 1)) (\u03bb k, (dpow k x) * (dpow (n - k) y)))\n  (dpow_eval_zero : \u2200 {n : \u2115} (hn : n \u2260 0), dpow n 0 = 0) {\u03b9 : Type*} [decidable_eq \u03b9]\n  {s : finset \u03b9} {x : \u03b9 \u2192 A} (hx : \u2200 i \u2208 s, x i \u2208 I) : \n  \u2200 (n : \u2115), dpow n (s.sum x) = \n    (finset.sym s n).sum (\u03bb k, s.prod (\u03bb 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' : \u2200 i, i \u2208 s \u2192 x i \u2208 I := \n    \u03bb 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 (\u03bb i, hx' i)),\n      sum_range, ih hx', mul_sum, sum_sigma'], \n\n    refine (sum_bij' \n      (\u03bb m _, sym.filter_ne a m) \n      (\u03bb m hm, finset.mem_sigma.2 \u27e8mem_univ _, _\u27e9)\n      (\u03bb m hm, _) \n      (\u03bb m _, m.2.fill a m.1)\n      _ \n      (\u03bb 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      (\u03bb 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 \u03bb 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 \u201cmultinomial\u201d theorem for divided powers \u2014 without multinomial coefficients -/\nlemma sum_dpow {\u03b9 : Type*} [decidable_eq \u03b9] {s : finset \u03b9} {x : \u03b9 \u2192 A} (hx : \u2200 i \u2208 s, x i \u2208 I) :\n  \u2200 (n : \u2115), hI.dpow n (s.sum x) = \n    (finset.sym s n).sum (\u03bb k, s.prod (\u03bb i, hI.dpow (multiset.count i k) (x i))) :=\nsum_dpow_aux hI.dpow (\u03bb x hx, hI.dpow_zero hx) \n  (\u03bb n x y hx hy, hI.dpow_add n hx hy) (\u03bb n hn, hI.dpow_eval_zero hn) hx\n\nlemma prod_dpow_self {\u03b9 : Type*} [decidable_eq \u03b9] {s : finset \u03b9} {n : \u03b9 \u2192 \u2115} (a : A) (ha : a \u2208 I) :\n  s.prod (\u03bb 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, \u2190 mul_assoc, mul_comm (hI.dpow _ a), mul_assoc,\n      hI.dpow_mul _ _ ha, \u2190 finset.sum_insert hi, \u2190 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 \u2192+* B) : Prop :=\n(I.map f) \u2264 J \u2227  \u2200 (n : \u2115) (a \u2208 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 \u2192+* B)\n(ideal_comp : I.map to_ring_hom \u2264 J)\n(dpow_comp : \u2200 (n : \u2115) (a \u2208 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 \u2192+* B} (hf : I.map f \u2264 J) : \n  ideal A := \n{ carrier   := {x \u2208 I | \u2200 (n : \u2115), f (hI.dpow n (x : A)) = (hJ.dpow n (f (x : A)))},\n  add_mem'  := \u03bb x y hx hy,\n  begin\n    simp only [set.mem_sep_iff, set_like.mem_coe] at hx hy \u22a2,\n    refine \u27e8I.add_mem hx.1 hy.1, _\u27e9,\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' := \u03bb r x hx,\n  begin\n    simp only [set.mem_sep_iff, set_like.mem_coe] at hx \u22a2,\n    refine \u27e8I.smul_mem r hx.1, _\u27e9,\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 \u2192+* B} {S : set A} (hS : ideal.span S = I)\n  (hf : I.map f \u2264 J) (h : \u2200 (x : S) (n : \u2115), 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   := \u03bb n x hx,\n  begin\n    have hS' : S \u2286 (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 \u2190hS, \n      exact ideal.subset_span hy, \n      exact h \u27e8y, hy\u27e9 },\n    rw [\u2190 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 \u2192+* B} {S : set A} (hS : ideal.span S = I)\n  (hf : I.map f \u2264 J) (h : \u2200 (x : S) (n : \u2115), 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 : \u2200 (n : \u2115) (a \u2208 S), hI.dpow n a = hI'.dpow n a) : hI = hI' :=\nbegin\n  suffices : I.map (ring_hom.id A) \u2264 I, \n  let pd_id := pd_morphism_from_gens hI hI' hS this _,\n  ext n a,\n  by_cases ha : a \u2208 I,\n  have := pd_id.dpow_comp n a ha, \n  suffices pd_id_id : \u2200 (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 `)` \u2192\u209a  `(` B `,` J, `,` hJ `)` := pd_morphism hI hJ\n-- Also, we expect a `pd` subscript\n\n/- TODO : identity, composition\u2026 -/\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 \u211a-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\u2026\n\nstructure divisor_system {R : Type*} [comm_ring R] := \n(dpow_choose : \u2115 \u2192 \u2115 \u2192 R)\n(dpow_mchoose : \u2115 \u2192 \u2115 \u2192 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 [\u00a0] = 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 `\u211d` is\naffine. We formalize it in three definitions:\n\n* `isometric.to_real_linear_isometry_equiv_of_map_zero` : given `E \u2243\u1d62 F` sending `0` to `0`,\n  returns `E \u2243\u2097\u1d62[\u211d] F` with the same `to_fun` and `inv_fun`;\n* `isometric.to_real_linear_isometry_equiv` : given `f : E \u2243\u1d62 F`,\n  returns `g : E \u2243\u2097\u1d62[\u211d] F` with `g x = f x - f 0`.\n* `isometric.to_affine_equiv` : given `PE \u2243\u1d62 PF`, returns `g : PE \u2243\u1d43[\u211d] PF` with the same\n  `to_equiv`.\n\nThe formalization is based on [Jussi V\u00e4is\u00e4l\u00e4, *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 `\u211d` 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 \u211d E]\n    [metric_space PE] [normed_add_torsor E PE] {x : PE} {y : PE} (e : PE \u2243\u1d62 PE) :\n    coe_fn e x = x \u2192 coe_fn e y = y \u2192 coe_fn e (midpoint \u211d x y) = midpoint \u211d 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 \u211d E]\n    [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F]\n    [normed_space \u211d F] [metric_space PF] [normed_add_torsor F PF] (f : PE \u2243\u1d62 PF) (x : PE) (y : PE) :\n    coe_fn f (midpoint \u211d x y) = midpoint \u211d (coe_fn f x) (coe_fn f y) :=\n  sorry\n\n/-!\nSince `f : PE \u2243\u1d62 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 `\u211d` 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 \u211d E]\n    {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 F) (h0 : coe_fn f 0 = 0) :\n    linear_isometry_equiv \u211d 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 \u211d \u211d (\u21d1f) 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 \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 F)\n    (h0 : coe_fn f 0 = 0) : \u21d1(to_real_linear_isometry_equiv_of_map_zero f h0) = \u21d1f :=\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 \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 F)\n    (h0 : coe_fn f 0 = 0) :\n    \u21d1(linear_isometry_equiv.symm (to_real_linear_isometry_equiv_of_map_zero f h0)) =\n        \u21d1(isometric.symm f) :=\n  rfl\n\n/-- Mazur-Ulam Theorem: if `f` is an isometric bijection between two normed vector spaces\nover `\u211d`, then `x \u21a6 f x - f 0` is a linear equivalence. -/\ndef to_real_linear_isometry_equiv {E : Type u_1} [normed_group E] [normed_space \u211d E] {F : Type u_3}\n    [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 F) : linear_isometry_equiv \u211d 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 \u211d E]\n    {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 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 \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 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 \u211d E]\n    [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F]\n    [normed_space \u211d F] [metric_space PF] [normed_add_torsor F PF] (f : PE \u2243\u1d62 PF) :\n    affine_equiv \u211d 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 \u211d E] [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4}\n    [normed_group F] [normed_space \u211d F] [metric_space PF] [normed_add_torsor F PF] (f : PE \u2243\u1d62 PF) :\n    \u21d1(to_affine_equiv f) = \u21d1f :=\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 \u2964 D` is cofinal if for every `d : D`,\nthe comma category of morphisms `d \u27f6 F.obj c` is connected.\n\nWe prove the following three statements are equivalent:\n1. `F : C \u2964 D` is cofinal.\n2. Every functor `G : D \u2964 E` has a colimit if and only if `F \u22d9 G` does,\n   and these colimits are isomorphic via `colimit.pre G F`.\n3. `colimit (F \u22d9 coyoneda.obj (op d)) \u2245 punit`.\n\nStarting at 1. we show (in `cocones_equiv`) that\nthe categories of cocones over `G : D \u2964 E` and over `F \u22d9 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\u1d52\u1d56 \u2964 E` has a limit if and only if `F.op \u22d9 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 \u2964 D` is cofinal if for every `d : D`, the comma category of morphisms `d \u27f6 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 \u2964 D) :=\n  \u2200 (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 \u2964 D) [\u2131 : cofinal F] (d : D) : is_connected (comma (functor.from_punit d) F) :=\n  \u2131 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 \u2964 D) [cofinal F] (d : D) : Nonempty (comma (functor.from_punit d) F) :=\n  is_connected.is_nonempty\n\n/--\nWhen `F : C \u2964 D` is cofinal, we denote by `lift F d` an arbitrary choice of object in `C` such that\nthere exists a morphism `d \u27f6 F.obj (lift F d)`.\n-/\ndef lift {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] (d : D) : C :=\n  comma.right (classical.arbitrary (comma (functor.from_punit d) F))\n\n/--\nWhen `F : C \u2964 D` is cofinal, we denote by `hom_to_lift` an arbitrary choice of morphism\n`d \u27f6 F.obj (lift F d)`.\n-/\ndef hom_to_lift {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] (d : D) : d \u27f6 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\u2080 : C` and `k\u2080 : d \u27f6 F.obj X\u2080` 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 \u2964 D) [cofinal F] {d : D} (Z : (X : C) \u2192 (d \u27f6 functor.obj F X) \u2192 Prop) (h\u2081 : \u2200 (X\u2081 X\u2082 : C) (k\u2081 : d \u27f6 functor.obj F X\u2081) (k\u2082 : d \u27f6 functor.obj F X\u2082) (f : X\u2081 \u27f6 X\u2082),\n  k\u2081 \u226b functor.map F f = k\u2082 \u2192 Z X\u2081 k\u2081 \u2192 Z X\u2082 k\u2082) (h\u2082 : \u2200 (X\u2081 X\u2082 : C) (k\u2081 : d \u27f6 functor.obj F X\u2081) (k\u2082 : d \u27f6 functor.obj F X\u2082) (f : X\u2081 \u27f6 X\u2082),\n  k\u2081 \u226b functor.map F f = k\u2082 \u2192 Z X\u2082 k\u2082 \u2192 Z X\u2081 k\u2081) {X\u2080 : C} {k\u2080 : d \u27f6 functor.obj F X\u2080} (z : Z X\u2080 k\u2080) : Z (lift F d) (hom_to_lift F d) := sorry\n\n/--\nGiven a cocone over `F \u22d9 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 \u2964 D} [cofinal F] {E : Type u} [category E] {G : D \u2964 E} (X : limits.cocone (F \u22d9 G)) (Y : limits.cocone (F \u22d9 G)) (f : X \u27f6 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 \u2964 D} [cofinal F] {E : Type u} [category E] {G : D \u2964 E} (s : limits.cocone (F \u22d9 G)) (j : C) : functor.map G (hom_to_lift F (functor.obj F j)) \u226b nat_trans.app (limits.cocone.\u03b9 s) (lift F (functor.obj F j)) =\n  nat_trans.app (limits.cocone.\u03b9 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 \u2964 D} {H : D\u1d52\u1d56 \u2964 E} (c : limits.cone (functor.op F \u22d9 H)) : limits.cocone (F \u22d9 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.\u03c0 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\u1d52\u1d56 \u2964 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\u1d52\u1d56) => has_hom.hom.unop (nat_trans.app (limits.cocone.\u03b9 c) (opposite.unop j)))\n\n/--\nGiven a cone over `F.op \u22d9 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 \u2964 D} [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 E} (X : limits.cone (functor.op F \u22d9 H)) (Y : limits.cone (functor.op F \u22d9 H)) (f : X \u27f6 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 \u2964 D} [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 E} (s : limits.cone (functor.op F \u22d9 H)) (j : C\u1d52\u1d56) : nat_trans.app (limits.cone.\u03c0 s) (opposite.op (lift F (functor.obj F (opposite.unop j)))) \u226b\n    functor.map H (has_hom.hom.op (hom_to_lift F (functor.obj F (opposite.unop j)))) =\n  nat_trans.app (limits.cone.\u03c0 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 \u22d9 G` is equivalent to the category of cocones on `G`,\nfor any `G : D \u2964 E`.\n-/\n@[simp] theorem cocones_equiv_unit_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] {E : Type u} [category E] (G : D \u2964 E) : equivalence.unit_iso (cocones_equiv F G) =\n  nat_iso.of_components\n    (fun (c : limits.cocone (F \u22d9 G)) =>\n      limits.cocones.ext (iso.refl (limits.cocone.X (functor.obj \ud835\udfed 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 \u22d9 H` is equivalent to the category of cones on `H`,\nfor any `H : D\u1d52\u1d56 \u2964 E`.\n-/\n@[simp] theorem cones_equiv_counit_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] {E : Type u} [category E] (H : D\u1d52\u1d56 \u2964 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) \u22d9 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 _ \u22d9 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 (\u03bb X, iso.refl _) (by tidy) :\n\n--     H \u2245 (unop_unop D \u22d9 H.op).op \u22d9 (op_op_equivalence E).functor)).symm\n\n/--\nWhen `F : C \u2964 D` is cofinal, and `t : cocone G` for some `G : D \u2964 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 \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 E} (t : limits.cocone G) : limits.is_colimit (limits.cocone.whisker F t) \u2243 limits.is_colimit t :=\n  limits.is_colimit.of_cocone_equiv (equivalence.symm (cocones_equiv F G))\n\n/--\nWhen `F : C \u2964 D` is cofinal, and `t : cone H` for some `H : D\u1d52\u1d56 \u2964 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 \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 E} (t : limits.cone H) : limits.is_limit (limits.cone.whisker (functor.op F) t) \u2243 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 \u22d9 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 \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 E} (t : limits.cocone (F \u22d9 G)) : limits.is_colimit (functor.obj extend_cocone t) \u2243 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 \u22d9 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 \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 E} (t : limits.cone (functor.op F \u22d9 H)) : limits.is_limit (functor.obj extend_cone t) \u2243 limits.is_limit t :=\n  limits.is_limit.of_cone_equiv (cones_equiv F H)\n\n/-- Given a colimit cocone over `G : D \u2964 E` we can construct a colimit cocone over `F \u22d9 G`. -/\n@[simp] theorem colimit_cocone_comp_cocone {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 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\u1d52\u1d56 \u2964 E` we can construct a limit cone over `F.op \u22d9 H`. -/\n@[simp] theorem limit_cone_comp_cone {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 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 \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 E} [limits.has_colimit G] : limits.has_colimit (F \u22d9 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 \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 E} [limits.has_limit H] : limits.has_limit (functor.op F \u22d9 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 \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 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) = \ud835\udfd9 := sorry\n\nprotected instance colimit_pre_is_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 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 \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 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) = \ud835\udfd9 := sorry\n\nprotected instance limit_pre_is_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 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 \u2964 D` is cofinal, and `G : D \u2964 E` has a colimit, then `F \u22d9 G` has a colimit also and\n`colimit (F \u22d9 G) \u2245 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 \u2964 D) [cofinal F] {E : Type u} [category E] (G : D \u2964 E) [limits.has_colimit G] : limits.colimit (F \u22d9 G) \u2245 limits.colimit G :=\n  as_iso (limits.colimit.pre G F)\n\n/--\nWhen `F : C \u2964 D` is cofinal, and `H : D\u1d52\u1d56 \u2964 E` has a limit, then `F.op \u22d9 H` has a limit also and\n`limit (F.op \u22d9 H) \u2245 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 \u2964 D) [cofinal F] {E : Type u} [category E] (H : D\u1d52\u1d56 \u2964 E) [limits.has_limit H] : limits.limit (functor.op F \u22d9 H) \u2245 limits.limit H :=\n  iso.symm (as_iso (limits.limit.pre H (functor.op F)))\n\n/-- Given a colimit cocone over `F \u22d9 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 \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 E} (t : limits.colimit_cocone (F \u22d9 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 \u22d9 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 \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 E} (t : limits.limit_cone (functor.op F \u22d9 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 \u22d9 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 \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 E} [limits.has_colimit (F \u22d9 G)] : limits.has_colimit G :=\n  limits.has_colimit.mk (colimit_cocone_of_comp F (limits.get_colimit_cocone (F \u22d9 G)))\n\n/--\nWhen `F` is cofinal, and `F.op \u22d9 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 \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 E} [limits.has_limit (functor.op F \u22d9 H)] : limits.has_limit H :=\n  limits.has_limit.mk (limit_cone_of_comp F (limits.get_limit_cone (functor.op F \u22d9 H)))\n\n/--\nWhen `F` is cofinal, and `F \u22d9 G` has a colimit, then `G` has a colimit also and\n`colimit (F \u22d9 G) \u2245 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 \u2964 D) [cofinal F] {E : Type u} [category E] {G : D \u2964 E} [limits.has_colimit (F \u22d9 G)] : limits.colimit (F \u22d9 G) \u2245 limits.colimit G :=\n  as_iso (limits.colimit.pre G F)\n\n/--\nWhen `F` is cofinal, and `F.op \u22d9 H` has a limit, then `H` has a limit also and\n`limit (F.op \u22d9 H) \u2245 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 \u2964 D) [cofinal F] {E : Type u} [category E] {H : D\u1d52\u1d56 \u2964 E} [limits.has_limit (functor.op F \u22d9 H)] : limits.limit (functor.op F \u22d9 H) \u2245 limits.limit H :=\n  iso.symm (as_iso (limits.limit.pre H (functor.op F)))\n\n/--\nIf the universal morphism `colimit (F \u22d9 coyoneda.obj (op d)) \u27f6 colimit (coyoneda.obj (op d))`\nis an isomorphism (as it always is when `F` is cofinal),\nthen `colimit (F \u22d9 coyoneda.obj (op d)) \u2245 punit`\n(simply because `colimit (coyoneda.obj (op d)) \u2245 punit`).\n-/\ndef colimit_comp_coyoneda_iso {C : Type v} [small_category C] {D : Type v} [small_category D] (F : C \u2964 D) [cofinal F] (d : D) [is_iso (limits.colimit.pre (functor.obj coyoneda (opposite.op d)) F)] : limits.colimit (F \u22d9 functor.obj coyoneda (opposite.op d)) \u2245 PUnit :=\n  as_iso (limits.colimit.pre (functor.obj coyoneda (opposite.op d)) F) \u226a\u226b 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 \u2964 D} {d : D} {f\u2081 : sigma fun (X : C) => d \u27f6 functor.obj F X} {f\u2082 : sigma fun (X : C) => d \u27f6 functor.obj F X} (t : eqv_gen (limits.types.quot.rel (F \u22d9 functor.obj coyoneda (opposite.op d))) f\u2081 f\u2082) : zigzag (comma.mk (sigma.snd f\u2081)) (comma.mk (sigma.snd f\u2082)) := sorry\n\n/--\nIf `colimit (F \u22d9 coyoneda.obj (op d)) \u2245 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 \u2964 D) [cofinal F] (I : (d : D) \u2192 limits.colimit (F \u22d9 functor.obj coyoneda (opposite.op d)) \u2245 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 \u03b1 = \u03b1\u1d50\u1d52\u1d56` to be the multiplicative opposite of `\u03b1`. It inherits\nall additive algebraic structures on `\u03b1` (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 `\u03b1` to `\u03b1\u1d50\u1d52\u1d56`.\n\nWe also define `add_opposite \u03b1 = \u03b1\u1d43\u1d52\u1d56` to be the additive opposite of `\u03b1`. It inherits all\nmultiplicative algebraic structures on `\u03b1` (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 `\u03b1` to `\u03b1\u1d43\u1d52\u1d56`.\n\n## Notation\n\n* `\u03b1\u1d50\u1d52\u1d56 = mul_opposite \u03b1`\n* `\u03b1\u1d43\u1d52\u1d56 = add_opposite \u03b1`\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 `\u03b1` and\nreverses left and right in multiplication.-/\n@[to_additive \"Additive opposite of a type. This type inherits all multiplicative structures on\n`\u03b1` and reverses left and right in addition.\"]\ndef mul_opposite (\u03b1 : Type u) : Type u := \u03b1\n\npostfix `\u1d50\u1d52\u1d56`:std.prec.max_plus := mul_opposite\npostfix `\u1d43\u1d52\u1d56`:std.prec.max_plus := add_opposite\n\nvariables {\u03b1 : Type u}\n\nnamespace mul_opposite\n\n/-- The element of `mul_opposite \u03b1` that represents `x : \u03b1`. -/\n@[pp_nodot, to_additive \"The element of `\u03b1\u1d43\u1d52\u1d56` that represents `x : \u03b1`.\"]\ndef op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56 := id\n\n/-- The element of `\u03b1` represented by `x : \u03b1\u1d50\u1d52\u1d56`. -/\n@[pp_nodot, to_additive \"The element of `\u03b1` represented by `x : \u03b1\u1d43\u1d52\u1d56`.\"]\ndef unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1 := id\n\nattribute [pp_nodot] add_opposite.op add_opposite.unop\n\n@[simp, to_additive] lemma unop_op (x : \u03b1) : unop (op x) = x := rfl\n@[simp, to_additive] lemma op_unop (x : \u03b1\u1d50\u1d52\u1d56) : op (unop x) = x := rfl\n@[simp, to_additive] lemma op_comp_unop : (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) \u2218 unop = id := rfl\n@[simp, to_additive] lemma unop_comp_op : (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) \u2218 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 : \u03a0 (X : \u03b1\u1d50\u1d52\u1d56), Sort v} (h : \u03a0 X, F (op X)) : \u03a0 X, F X :=\n\u03bb X, h (unop X)\n\n/-- The canonical bijection between `\u03b1` and `\u03b1\u1d50\u1d52\u1d56`. -/\n@[to_additive \"The canonical bijection between `\u03b1` and `\u03b1\u1d43\u1d52\u1d56`.\",\n  simps apply symm_apply { fully_applied := ff }]\ndef op_equiv : \u03b1 \u2243 \u03b1\u1d50\u1d52\u1d56 := \u27e8op, unop, unop_op, op_unop\u27e9\n\n@[to_additive] lemma op_bijective : bijective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_equiv.bijective\n@[to_additive] lemma unop_bijective : bijective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := op_equiv.symm.bijective\n@[to_additive] lemma op_injective : injective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_bijective.injective\n@[to_additive] lemma op_surjective : surjective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_bijective.surjective\n@[to_additive] lemma unop_injective : injective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := unop_bijective.injective\n@[to_additive] lemma unop_surjective : surjective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := unop_bijective.surjective\n\n@[simp, to_additive] lemma op_inj {x y : \u03b1} : op x = op y \u2194 x = y := op_injective.eq_iff\n@[simp, to_additive] lemma unop_inj {x y : \u03b1\u1d50\u1d52\u1d56} : unop x = unop y \u2194 x = y := unop_injective.eq_iff\n\nvariable (\u03b1)\n\n@[to_additive] instance [nontrivial \u03b1] : nontrivial \u03b1\u1d50\u1d52\u1d56 := op_injective.nontrivial\n@[to_additive] instance [inhabited \u03b1] : inhabited \u03b1\u1d50\u1d52\u1d56 := \u27e8op default\u27e9\n@[to_additive] instance [subsingleton \u03b1] : subsingleton \u03b1\u1d50\u1d52\u1d56 := unop_injective.subsingleton\n@[to_additive] instance [unique \u03b1] : unique \u03b1\u1d50\u1d52\u1d56 := unique.mk' _\n@[to_additive] instance [is_empty \u03b1] : is_empty \u03b1\u1d50\u1d52\u1d56 := function.is_empty unop\n\ninstance [has_zero \u03b1] : has_zero \u03b1\u1d50\u1d52\u1d56 := { zero := op 0 }\n\n@[to_additive] instance [has_one \u03b1] : has_one \u03b1\u1d50\u1d52\u1d56 := { one := op 1 }\n\ninstance [has_add \u03b1] : has_add \u03b1\u1d50\u1d52\u1d56 :=\n{ add := \u03bb x y, op (unop x + unop y) }\n\ninstance [has_sub \u03b1] : has_sub \u03b1\u1d50\u1d52\u1d56 :=\n{ sub := \u03bb x y, op (unop x - unop y) }\n\ninstance [has_neg \u03b1] : has_neg \u03b1\u1d50\u1d52\u1d56 :=\n{ neg := \u03bb x, op $ -(unop x) }\n\n@[to_additive] instance [has_mul \u03b1] : has_mul \u03b1\u1d50\u1d52\u1d56 :=\n{ mul := \u03bb x y, op (unop y * unop x) }\n\n@[to_additive] instance [has_inv \u03b1] : has_inv \u03b1\u1d50\u1d52\u1d56 :=\n{ inv := \u03bb x, op $ (unop x)\u207b\u00b9 }\n\n@[to_additive] instance (R : Type*) [has_scalar R \u03b1] : has_scalar R \u03b1\u1d50\u1d52\u1d56 :=\n{ smul := \u03bb c x, op (c \u2022 unop x) }\n\nsection\nvariables (\u03b1)\n\n@[simp] lemma op_zero [has_zero \u03b1] : op (0 : \u03b1) = 0 := rfl\n@[simp] \n\n@[simp, to_additive] lemma op_one [has_one \u03b1] : op (1 : \u03b1) = 1 := rfl\n@[simp, to_additive] lemma unop_one [has_one \u03b1] : unop (1 : \u03b1\u1d50\u1d52\u1d56) = 1 := rfl\n\nvariable {\u03b1}\n\n@[simp] lemma op_add [has_add \u03b1] (x y : \u03b1) : op (x + y) = op x + op y := rfl\n@[simp] lemma unop_add [has_add \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x + y) = unop x + unop y := rfl\n\n@[simp] lemma op_neg [has_neg \u03b1] (x : \u03b1) : op (-x) = -op x := rfl\n@[simp] lemma unop_neg [has_neg \u03b1] (x : \u03b1\u1d50\u1d52\u1d56) : unop (-x) = -unop x := rfl\n\n@[simp, to_additive] lemma op_mul [has_mul \u03b1] (x y : \u03b1) : op (x * y) = op y * op x := rfl\n@[simp, to_additive] lemma unop_mul [has_mul \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x * y) = unop y * unop x := rfl\n\n@[simp, to_additive] lemma op_inv [has_inv \u03b1] (x : \u03b1) : op (x\u207b\u00b9) = (op x)\u207b\u00b9 := rfl\n@[simp, to_additive] lemma unop_inv [has_inv \u03b1] (x : \u03b1\u1d50\u1d52\u1d56) : unop (x\u207b\u00b9) = (unop x)\u207b\u00b9 := rfl\n\n@[simp] lemma op_sub [has_sub \u03b1] (x y : \u03b1) : op (x - y) = op x - op y := rfl\n@[simp] lemma unop_sub [has_sub \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x - y) = unop x - unop y := rfl\n\n@[simp, to_additive] lemma op_smul {R : Type*} [has_scalar R \u03b1] (c : R) (a : \u03b1) :\n  op (c \u2022 a) = c \u2022 op a := rfl\n\n@[simp, to_additive] lemma unop_smul {R : Type*} [has_scalar R \u03b1] (c : R) (a : \u03b1\u1d50\u1d52\u1d56) :\n  unop (c \u2022 a) = c \u2022 unop a := rfl\n\nend\n\nvariable {\u03b1}\n\n@[simp] lemma unop_eq_zero_iff [has_zero \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop = (0 : \u03b1) \u2194 a = (0 : \u03b1\u1d50\u1d52\u1d56) :=\nunop_injective.eq_iff' rfl\n\n@[simp] lemma op_eq_zero_iff [has_zero \u03b1] (a : \u03b1) : op a = (0 : \u03b1\u1d50\u1d52\u1d56) \u2194 a = (0 : \u03b1) :=\nop_injective.eq_iff' rfl\n\nlemma unop_ne_zero_iff [has_zero \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop \u2260 (0 : \u03b1) \u2194 a \u2260 (0 : \u03b1\u1d50\u1d52\u1d56) :=\nnot_congr $ unop_eq_zero_iff a\n\nlemma op_ne_zero_iff [has_zero \u03b1] (a : \u03b1) : op a \u2260 (0 : \u03b1\u1d50\u1d52\u1d56) \u2194 a \u2260 (0 : \u03b1) :=\nnot_congr $ op_eq_zero_iff a\n\n@[simp, to_additive] lemma unop_eq_one_iff [has_one \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop = 1 \u2194 a = 1 :=\nunop_injective.eq_iff' rfl\n\n@[simp, to_additive] lemma op_eq_one_iff [has_one \u03b1] (a : \u03b1) : op a = 1 \u2194 a = 1 :=\nop_injective.eq_iff' rfl\n\nend mul_opposite\n\nnamespace add_opposite\n\ninstance [has_one \u03b1] : has_one \u03b1\u1d43\u1d52\u1d56 := { one := op 1 }\n\n@[simp] lemma op_one [has_one \u03b1] : op (1 : \u03b1) = 1 := rfl\n@[simp] lemma unop_one [has_one \u03b1] : unop 1 = (1 : \u03b1) := rfl\n\n@[simp] lemma op_eq_one_iff [has_one \u03b1] {a : \u03b1} : op a = 1 \u2194 a = 1 := op_injective.eq_iff' op_one\n\n@[simp] lemma unop_eq_one_iff [has_one \u03b1] {a : \u03b1\u1d43\u1d52\u1d56} : unop a = 1 \u2194 a = 1 :=\nunop_injective.eq_iff' unop_one\n\ninstance [has_mul \u03b1] : has_mul \u03b1\u1d43\u1d52\u1d56 := { mul := \u03bb a b, op (unop a * unop b) }\n\n@[simp] lemma op_mul [has_mul \u03b1] (a b : \u03b1) : op (a * b) = op a * op b := rfl\n@[simp] lemma unop_mul [has_mul \u03b1] (a b : \u03b1\u1d43\u1d52\u1d56) : unop (a * b) = unop a * unop b := rfl\n\ninstance [has_inv \u03b1] : has_inv \u03b1\u1d43\u1d52\u1d56 := { inv := \u03bb a, op (unop a)\u207b\u00b9 }\n\n@[simp] lemma op_inv [has_inv \u03b1] (a : \u03b1) : op a\u207b\u00b9 = (op a)\u207b\u00b9 := rfl\n@[simp] lemma unop_inv [has_inv \u03b1] (a : \u03b1\u1d43\u1d52\u1d56) : unop a\u207b\u00b9 = (unop a)\u207b\u00b9 := rfl\n\ninstance [has_div \u03b1] : has_div \u03b1\u1d43\u1d52\u1d56 := { div := \u03bb a b, op (unop a / unop b) }\n\n@[simp] lemma op_div [has_div \u03b1] (a b : \u03b1) : op (a / b) = op a / op b := rfl\n@[simp] lemma unop_div [has_div \u03b1] (a b : \u03b1) : 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b9 : Sort*}\n\nsection lift\n\n/-- A variant on `bind` using a function `g` taking a set instead of a member of `\u03b1`.\nThis is essentially a push-forward along a function mapping each set to a filter. -/\nprotected def lift (f : filter \u03b1) (g : set \u03b1 \u2192 filter \u03b2) :=\n\u2a05s \u2208 f.sets, g s\n\nvariables {f f\u2081 f\u2082 : filter \u03b1} {g g\u2081 g\u2082 : set \u03b1 \u2192 filter \u03b2}\n\nlemma lift_sets_eq (hg : monotone g) : (f.lift g).sets = (\u22c3t\u2208f.sets, (g t).sets) :=\ninfi_sets_eq'\n  (assume s hs t ht, \u27e8s \u2229 t, inter_mem_sets hs ht,\n    hg $ inter_subset_left s t, hg $ inter_subset_right s t\u27e9)\n  \u27e8univ, univ_mem_sets\u27e9\n\nlemma mem_lift {s : set \u03b2} {t : set \u03b1} (ht : t \u2208 f.sets) (hs : s \u2208 (g t).sets) :\n  s \u2208 (f.lift g).sets :=\nle_principal_iff.mp $ show f.lift g \u2264 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 \u03b2} :\n  s \u2208 (f.lift g).sets \u2194 (\u2203t\u2208f.sets, s \u2208 (g t).sets) :=\nby rw [lift_sets_eq hg]; simp only [mem_Union]\n\nlemma lift_le {f : filter \u03b1} {g : set \u03b1 \u2192 filter \u03b2} {h : filter \u03b2} {s : set \u03b1}\n  (hs : s \u2208 f.sets) (hg : g s \u2264 h) : f.lift g \u2264 h :=\ninfi_le_of_le s $ infi_le_of_le hs $ hg\n\nlemma le_lift {f : filter \u03b1} {g : set \u03b1 \u2192 filter \u03b2} {h : filter \u03b2}\n  (hh : \u2200s\u2208f.sets, h \u2264 g s) : h \u2264 f.lift g :=\nle_infi $ assume s, le_infi $ assume hs, hh s hs\n\nlemma lift_mono (hf : f\u2081 \u2264 f\u2082) (hg : g\u2081 \u2264 g\u2082) : f\u2081.lift g\u2081 \u2264 f\u2082.lift g\u2082 :=\ninfi_le_infi $ assume s, infi_le_infi2 $ assume hs, \u27e8hf hs, hg s\u27e9\n\nlemma lift_mono' (hg : \u2200s\u2208f.sets, g\u2081 s \u2264 g\u2082 s) : f.lift g\u2081 \u2264 f.lift g\u2082 :=\ninfi_le_infi $ assume s, infi_le_infi $ assume hs, hg s hs\n\nlemma map_lift_eq {m : \u03b2 \u2192 \u03b3} (hg : monotone g) : map m (f.lift g) = f.lift (map m \u2218 g) :=\nhave monotone (map m \u2218 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 : \u03b3 \u2192 \u03b2} (hg : monotone g) : comap m (f.lift g) = f.lift (comap m \u2218 g) :=\nhave monotone (comap m \u2218 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 \u03bb s,\n   \u27e8\u03bb \u27e8b, \u27e8a, ha, hb\u27e9, hs\u27e9, \u27e8a, ha, b, hb, hs\u27e9,\n    \u03bb \u27e8a, ha, b, hb, hs\u27e9, \u27e8b, \u27e8a, ha, hb\u27e9, hs\u27e9\u27e9\nend\n\ntheorem comap_lift_eq2 {m : \u03b2 \u2192 \u03b1} {g : set \u03b2 \u2192 filter \u03b3} (hg : monotone g) :\n  (comap m f).lift g = f.lift (g \u2218 preimage m) :=\nle_antisymm\n  (le_infi $ assume s, le_infi $ assume hs,\n    infi_le_of_le (preimage m s) $ infi_le _ \u27e8s, hs, subset.refl _\u27e9)\n  (le_infi $ assume s, le_infi $ assume \u27e8s', hs', (h_sub : preimage m s' \u2286 s)\u27e9,\n    infi_le_of_le s' $ infi_le_of_le hs' $ hg h_sub)\n\nlemma map_lift_eq2 {g : set \u03b2 \u2192 filter \u03b3} {m : \u03b1 \u2192 \u03b2} (hg : monotone g) :\n  (map m f).lift g = f.lift (g \u2218 image m) :=\nle_antisymm\n  (infi_le_infi2 $ assume s, \u27e8image m s,\n    infi_le_infi2 $ assume hs, \u27e8\n      f.sets_of_superset hs $ assume a h, mem_image_of_mem _ h,\n      le_refl _\u27e9\u27e9)\n  (infi_le_infi2 $ assume t, \u27e8preimage m t,\n    infi_le_infi2 $ assume ht, \u27e8ht,\n      hg $ assume x, assume h : x \u2208 m '' preimage m t,\n        let \u27e8y, hy, h_eq\u27e9 := h in\n        show x \u2208 t, from h_eq \u25b8 hy\u27e9\u27e9)\n\nlemma lift_comm {g : filter \u03b2} {h : set \u03b1 \u2192 set \u03b2 \u2192 filter \u03b3} :\n  f.lift (\u03bbs, g.lift (h s)) = g.lift (\u03bbt, f.lift (\u03bbs, 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 \u03b2 \u2192 filter \u03b3} (hg : monotone g)  :\n  (f.lift g).lift h = f.lift (\u03bbs, (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 \u27e8_, hs, ht\u27e9)\n  (le_infi $ assume t, le_infi $ assume ht,\n    let \u27e8s, hs, h'\u27e9 := (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 \u03b1 \u2192 set \u03b1 \u2192 filter \u03b2} :\n  f.lift (\u03bbs, f.lift (g s)) \u2264 f.lift (\u03bbs, 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 \u03b1 \u2192 set \u03b1 \u2192 filter \u03b2}\n  (hg\u2081 : \u2200s, monotone (\u03bbt, g s t)) (hg\u2082 : \u2200t, monotone (\u03bbs, g s t)):\n  f.lift (\u03bbs, f.lift (g s)) = f.lift (\u03bbs, 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 \u2229 t) $\n    infi_le_of_le (inter_mem_sets hs ht) $\n    calc g (s \u2229 t) (s \u2229 t) \u2264 g s (s \u2229 t) : hg\u2082 (s \u2229 t) (inter_subset_left _ _)\n      ... \u2264 g s t                        : hg\u2081 s (inter_subset_right _ _))\n\nlemma lift_principal {s : set \u03b1} (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 \u03b3] {f : \u03b3 \u2192 filter \u03b1} {g : \u03b3 \u2192 set \u03b1 \u2192 filter \u03b2}\n  (hf : monotone f) (hg : monotone g) : monotone (\u03bbc, (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 \u2260 \u22a5) \u2194 (\u2200s\u2208f.sets, g s \u2260 \u22a5) :=\nclassical.by_cases\n  (assume hn : nonempty \u03b2,\n    calc f.lift g \u2260 \u22a5 \u2194 (\u2a05s : { s // s \u2208 f.sets}, g s.val) \u2260 \u22a5 :\n      by simp only [filter.lift, infi_subtype, iff_self, ne.def]\n      ... \u2194 (\u2200s:{ s // s \u2208 f.sets}, g s.val \u2260 \u22a5) :\n        infi_neq_bot_iff_of_directed hn\n          (assume \u27e8a, ha\u27e9 \u27e8b, hb\u27e9, \u27e8\u27e8a \u2229 b, inter_mem_sets ha hb\u27e9,\n            hm $ inter_subset_left _ _, hm $ inter_subset_right _ _\u27e9)\n      ... \u2194 (\u2200s\u2208f.sets, g s \u2260 \u22a5) : \u27e8assume h s hs, h \u27e8s, hs\u27e9, assume h \u27e8s, hs\u27e9, h s hs\u27e9)\n  (assume hn : \u00ac nonempty \u03b2,\n    have h\u2081 : f.lift g = \u22a5, from filter_eq_bot_of_not_nonempty hn,\n    have h\u2082 : \u2200s, g s = \u22a5, from assume s, filter_eq_bot_of_not_nonempty hn,\n    calc (f.lift g \u2260 \u22a5) \u2194 false : by simp only [h\u2081, iff_self, eq_self_iff_true, not_true, ne.def]\n      ... \u2194 (\u2200s\u2208f.sets, false) : \u27e8false.elim, assume h, h univ univ_mem_sets\u27e9\n      ... \u2194 (\u2200s\u2208f.sets, g s \u2260 \u22a5) : by simp only [h\u2082, iff_self, eq_self_iff_true, not_true, ne.def])\n\n@[simp] lemma lift_const {f : filter \u03b1} {g : filter \u03b2} : f.lift (\u03bbx, 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 \u03b1} {g h : set \u03b1 \u2192 filter \u03b2} :\n  f.lift (\u03bbx, g x \u2293 h x) = f.lift g \u2293 f.lift h :=\nby simp only [filter.lift, infi_inf_eq, eq_self_iff_true]\n\n@[simp] lemma lift_principal2 {f : filter \u03b1} : 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 : \u03b9 \u2192 filter \u03b1} {g : set \u03b1 \u2192 filter \u03b2}\n  (h\u03b9 : nonempty \u03b9) (hg : \u2200{s t}, g s \u2293 g t = g (s \u2229 t)) : (infi f).lift g = (\u2a05i, (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 \u2200t\u2208(infi f).sets, (\u2a05 (i : \u03b9), filter.lift (f i) g) \u2264 g t,\n      from assume t ht, infi_sets_induct ht\n        (let \u27e8i\u27e9 := h\u03b9 in infi_le_of_le i $ infi_le_of_le univ $ infi_le _ univ_mem_sets)\n        (assume i s\u2081 s\u2082 hs\u2081 hs\u2082,\n          @hg s\u2081 s\u2082 \u25b8 le_inf (infi_le_of_le i $ infi_le_of_le s\u2081 $ infi_le _ hs\u2081) hs\u2082)\n        (assume s\u2081 s\u2082 hs\u2081 hs\u2082, le_trans hs\u2082 $ g_mono hs\u2081),\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 \u03b1 \u2192 set \u03b2`. 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 \u03b1) (h : set \u03b1 \u2192 set \u03b2) :=\nf.lift (principal \u2218 h)\n\nvariables {f f\u2081 f\u2082 : filter \u03b1} {h h\u2081 h\u2082 : set \u03b1 \u2192 set \u03b2}\n\nlemma mem_lift' {t : set \u03b1} (ht : t \u2208 f.sets) : h t \u2208 (f.lift' h).sets :=\nle_principal_iff.mp $ show f.lift' h \u2264 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 \u03b2} : s \u2208 (f.lift' h).sets \u2194 (\u2203t\u2208f.sets, h t \u2286 s) :=\nhave monotone (principal \u2218 h),\n  from assume a b h, principal_mono.mpr $ hh h,\nby simp only [filter.lift', @mem_lift_sets \u03b1 \u03b2 f _ this, exists_prop, iff_self, mem_principal_sets, function.comp_app]\n\nlemma lift'_le {f : filter \u03b1} {g : set \u03b1 \u2192 set \u03b2} {h : filter \u03b2} {s : set \u03b1}\n  (hs : s \u2208 f.sets) (hg : principal (g s) \u2264 h) : f.lift' g \u2264 h :=\nlift_le hs hg\n\nlemma lift'_mono (hf : f\u2081 \u2264 f\u2082) (hh : h\u2081 \u2264 h\u2082) : f\u2081.lift' h\u2081 \u2264 f\u2082.lift' h\u2082 :=\nlift_mono hf $ assume s, principal_mono.mpr $ hh s\n\nlemma lift'_mono' (hh : \u2200s\u2208f.sets, h\u2081 s \u2286 h\u2082 s) : f.lift' h\u2081 \u2264 f.lift' h\u2082 :=\ninfi_le_infi $ assume s, infi_le_infi $ assume hs, principal_mono.mpr $ hh s hs\n\nlemma lift'_cong (hh : \u2200s\u2208f.sets, h\u2081 s = h\u2082 s) : f.lift' h\u2081 = f.lift' h\u2082 :=\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 : \u03b2 \u2192 \u03b3} (hh : monotone h) : map m (f.lift' h) = f.lift' (image m \u2218 h) :=\ncalc map m (f.lift' h) = f.lift (map m \u2218 principal \u2218 h) :\n    map_lift_eq $ monotone_comp hh monotone_principal\n  ... = f.lift' (image m \u2218 h) : by simp only [(\u2218), filter.lift', map_principal, eq_self_iff_true]\n\nlemma map_lift'_eq2 {g : set \u03b2 \u2192 set \u03b3} {m : \u03b1 \u2192 \u03b2} (hg : monotone g) :\n  (map m f).lift' g = f.lift' (g \u2218 image m) :=\nmap_lift_eq2 $ monotone_comp hg monotone_principal\n\ntheorem comap_lift'_eq {m : \u03b3 \u2192 \u03b2} (hh : monotone h) :\n  comap m (f.lift' h) = f.lift' (preimage m \u2218 h) :=\ncalc comap m (f.lift' h) = f.lift (comap m \u2218 principal \u2218 h) :\n    comap_lift_eq $ monotone_comp hh monotone_principal\n  ... = f.lift' (preimage m \u2218 h) : by simp only [(\u2218), filter.lift', comap_principal, eq_self_iff_true]\n\ntheorem comap_lift'_eq2 {m : \u03b2 \u2192 \u03b1} {g : set \u03b2 \u2192 set \u03b3} (hg : monotone g) :\n  (comap m f).lift' g = f.lift' (g \u2218 preimage m) :=\ncomap_lift_eq2 $ monotone_comp hg monotone_principal\n\nlemma lift'_principal {s : set \u03b1} (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 \u03b2} (hh : \u2200s\u2208f.sets, t \u2286 h s) :\n  principal t \u2264 f.lift' h :=\nle_infi $ assume s, le_infi $ assume hs, principal_mono.mpr (hh s hs)\n\ntheorem monotone_lift' [preorder \u03b3] {f : \u03b3 \u2192 filter \u03b1} {g : \u03b3 \u2192 set \u03b1 \u2192 set \u03b2}\n  (hf : monotone f) (hg : monotone g) : monotone (\u03bbc, (f c).lift' (g c)) :=\nassume a b h, lift'_mono (hf h) (hg h)\n\nlemma lift_lift'_assoc {g : set \u03b1 \u2192 set \u03b2} {h : set \u03b2 \u2192 filter \u03b3}\n  (hg : monotone g) (hh : monotone h) :\n  (f.lift' g).lift h = f.lift (\u03bbs, h (g s)) :=\ncalc (f.lift' g).lift h = f.lift (\u03bbs, (principal (g s)).lift h) :\n    lift_assoc (monotone_comp hg monotone_principal)\n  ... = f.lift (\u03bbs, h (g s)) : by simp only [lift_principal, hh, eq_self_iff_true]\n\nlemma lift'_lift'_assoc {g : set \u03b1 \u2192 set \u03b2} {h : set \u03b2 \u2192 set \u03b3}\n  (hg : monotone g) (hh : monotone h) :\n  (f.lift' g).lift' h = f.lift' (\u03bbs, h (g s)) :=\nlift_lift'_assoc hg (monotone_comp hh monotone_principal)\n\nlemma lift'_lift_assoc {g : set \u03b1 \u2192 filter \u03b2} {h : set \u03b2 \u2192 set \u03b3}\n  (hg : monotone g) : (f.lift g).lift' h = f.lift (\u03bbs, (g s).lift' h) :=\nlift_assoc hg\n\nlemma lift_lift'_same_le_lift' {g : set \u03b1 \u2192 set \u03b1 \u2192 set \u03b2} :\n  f.lift (\u03bbs, f.lift' (g s)) \u2264 f.lift' (\u03bbs, g s s) :=\nlift_lift_same_le_lift\n\nlemma lift_lift'_same_eq_lift' {g : set \u03b1 \u2192 set \u03b1 \u2192 set \u03b2}\n  (hg\u2081 : \u2200s, monotone (\u03bbt, g s t)) (hg\u2082 : \u2200t, monotone (\u03bbs, g s t)):\n  f.lift (\u03bbs, f.lift' (g s)) = f.lift' (\u03bbs, g s s) :=\nlift_lift_same_eq_lift\n  (assume s, monotone_comp monotone_id $ monotone_comp (hg\u2081 s) monotone_principal)\n  (assume t, monotone_comp (hg\u2082 t) monotone_principal)\n\nlemma lift'_inf_principal_eq {h : set \u03b1 \u2192 set \u03b2} {s : set \u03b2} :\n  f.lift' h \u2293 principal s = f.lift' (\u03bbt, h t \u2229 s) :=\nle_antisymm\n  (le_infi $ assume t, le_infi $ assume ht,\n    calc filter.lift' f h \u2293 principal s \u2264 principal (h t) \u2293 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 \u2260 \u22a5) \u2194 (\u2200s\u2208f.sets, h s \u2260 \u2205) :=\ncalc (f.lift' h \u2260 \u22a5) \u2194 (\u2200s\u2208f.sets, principal (h s) \u2260 \u22a5) :\n    lift_neq_bot_iff (monotone_comp hh monotone_principal)\n  ... \u2194 (\u2200s\u2208f.sets, h s \u2260 \u2205) : by simp only [principal_eq_bot_iff, iff_self, ne.def, principal_eq_bot_iff]\n\n@[simp] lemma lift'_id {f : filter \u03b1} : f.lift' id = f :=\nlift_principal2\n\nlemma le_lift' {f : filter \u03b1} {h : set \u03b1 \u2192 set \u03b2} {g : filter \u03b2}\n  (h_le : \u2200s\u2208f.sets, h s \u2208 g.sets) : g \u2264 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 : \u03b9 \u2192 filter \u03b1} {g : set \u03b1 \u2192 filter \u03b2}\n  (h\u03b9 : nonempty \u03b9) (hf : directed (\u2265) f) (hg : monotone g) : (infi f).lift g = (\u2a05i, (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\u03b9],\n    exact assume t i ht hs, mem_infi_sets i $ mem_lift ht hs\n  end)\n\nlemma lift'_infi {f : \u03b9 \u2192 filter \u03b1} {g : set \u03b1 \u2192 set \u03b2}\n  (h\u03b9 : nonempty \u03b9) (hg : \u2200{s t}, g s \u2229 g t = g (s \u2229 t)) : (infi f).lift' g = (\u2a05i, (f i).lift' g) :=\nlift_infi h\u03b9 $ by simp only [principal_eq_iff_eq, inf_principal, function.comp_app]; apply assume s t, hg\n\ntheorem comap_eq_lift' {f : filter \u03b2} {m : \u03b1 \u2192 \u03b2} :\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 \u03b1}\n\nlemma prod_def {f : filter \u03b1} {g : filter \u03b2} : f.prod g = (f.lift $ \u03bbs, g.lift' $ set.prod s) :=\nhave \u2200(s:set \u03b1) (t : set \u03b2),\n    principal (set.prod s t) = (principal s).comap prod.fst \u2293 (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 [\u2190 comap_lift_eq monotone_principal, \u2190 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' (\u03bbt, 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 (\u03b1\u00d7\u03b1)} :\n  s \u2208 (filter.prod f f).sets \u2194 (\u2203t\u2208f.sets, set.prod t t \u2286 s) :=\nby rw [prod_same_eq, mem_lift'_sets]; exact set.monotone_prod monotone_id monotone_id\n\nlemma tendsto_prod_self_iff {f : \u03b1 \u00d7 \u03b1 \u2192 \u03b2} {x : filter \u03b1} {y : filter \u03b2} :\n  filter.tendsto f (filter.prod x x) y \u2194\n  \u2200 W \u2208 y.sets, \u2203 U \u2208 x.sets, \u2200 (x x' : \u03b1), x \u2208 U \u2192 x' \u2208 U \u2192 f (x, x') \u2208 W :=\nby simp only [tendsto_def, mem_prod_same_iff, prod_sub_preimage_iff, exists_prop, iff_self]\n\nvariables {\u03b1\u2081 : Type*} {\u03b1\u2082 : Type*} {\u03b2\u2081 : Type*} {\u03b2\u2082 : Type*}\n\nlemma prod_lift_lift\n  {f\u2081 : filter \u03b1\u2081} {f\u2082 : filter \u03b1\u2082} {g\u2081 : set \u03b1\u2081 \u2192 filter \u03b2\u2081} {g\u2082 : set \u03b1\u2082 \u2192 filter \u03b2\u2082}\n  (hg\u2081 : monotone g\u2081) (hg\u2082 : monotone g\u2082) :\n  filter.prod (f\u2081.lift g\u2081) (f\u2082.lift g\u2082) = f\u2081.lift (\u03bbs, f\u2082.lift (\u03bbt, filter.prod (g\u2081 s) (g\u2082 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\u2082,\n  exact hg\u2081\nend\n\nlemma prod_lift'_lift'\n  {f\u2081 : filter \u03b1\u2081} {f\u2082 : filter \u03b1\u2082} {g\u2081 : set \u03b1\u2081 \u2192 set \u03b2\u2081} {g\u2082 : set \u03b1\u2082 \u2192 set \u03b2\u2082}\n  (hg\u2081 : monotone g\u2081) (hg\u2082 : monotone g\u2082) :\n  filter.prod (f\u2081.lift' g\u2081) (f\u2082.lift' g\u2082) = f\u2081.lift (\u03bbs, f\u2082.lift' (\u03bbt, set.prod (g\u2081 s) (g\u2082 t))) :=\nbegin\n  rw [prod_def, lift_lift'_assoc],\n  apply congr_arg, funext x,\n  rw [lift'_lift'_assoc],\n  exact hg\u2082,\n  exact set.monotone_prod monotone_const monotone_id,\n  exact hg\u2081,\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 \u2192 Type v} {\u03b1 : Type u_1} [(i : I) \u2192 has_scalar \u03b1 (f i)] : has_scalar \u03b1 ((i : I) \u2192 f i) :=\n  has_scalar.mk fun (s : \u03b1) (x : (i : I) \u2192 f i) (i : I) => s \u2022 x i\n\n@[simp] theorem smul_apply {I : Type u} {f : I \u2192 Type v} (x : (i : I) \u2192 f i) (i : I) {\u03b1 : Type u_1} [(i : I) \u2192 has_scalar \u03b1 (f i)] (s : \u03b1) : has_scalar.smul s x i = s \u2022 x i :=\n  rfl\n\nprotected instance has_scalar' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1} [(i : I) \u2192 has_scalar (f i) (g i)] : has_scalar ((i : I) \u2192 f i) ((i : I) \u2192 g i) :=\n  has_scalar.mk fun (s : (i : I) \u2192 f i) (x : (i : I) \u2192 g i) (i : I) => s i \u2022 x i\n\n@[simp] theorem smul_apply' {I : Type u} {f : I \u2192 Type v} (i : I) {g : I \u2192 Type u_1} [(i : I) \u2192 has_scalar (f i) (g i)] (s : (i : I) \u2192 f i) (x : (i : I) \u2192 g i) : has_scalar.smul s x i = s i \u2022 x i :=\n  rfl\n\nprotected instance is_scalar_tower {I : Type u} {f : I \u2192 Type v} {\u03b1 : Type u_1} {\u03b2 : Type u_2} [has_scalar \u03b1 \u03b2] [(i : I) \u2192 has_scalar \u03b2 (f i)] [(i : I) \u2192 has_scalar \u03b1 (f i)] [\u2200 (i : I), is_scalar_tower \u03b1 \u03b2 (f i)] : is_scalar_tower \u03b1 \u03b2 ((i : I) \u2192 f i) :=\n  is_scalar_tower.mk fun (x : \u03b1) (y : \u03b2) (z : (i : I) \u2192 f i) => funext fun (i : I) => smul_assoc x y (z i)\n\nprotected instance is_scalar_tower' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1} {\u03b1 : Type u_2} [(i : I) \u2192 has_scalar \u03b1 (f i)] [(i : I) \u2192 has_scalar (f i) (g i)] [(i : I) \u2192 has_scalar \u03b1 (g i)] [\u2200 (i : I), is_scalar_tower \u03b1 (f i) (g i)] : is_scalar_tower \u03b1 ((i : I) \u2192 f i) ((i : I) \u2192 g i) :=\n  is_scalar_tower.mk fun (x : \u03b1) (y : (i : I) \u2192 f i) (z : (i : I) \u2192 g i) => funext fun (i : I) => smul_assoc x (y i) (z i)\n\nprotected instance is_scalar_tower'' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1} {h : I \u2192 Type u_2} [(i : I) \u2192 has_scalar (f i) (g i)] [(i : I) \u2192 has_scalar (g i) (h i)] [(i : I) \u2192 has_scalar (f i) (h i)] [\u2200 (i : I), is_scalar_tower (f i) (g i) (h i)] : is_scalar_tower ((i : I) \u2192 f i) ((i : I) \u2192 g i) ((i : I) \u2192 h i) :=\n  is_scalar_tower.mk\n    fun (x : (i : I) \u2192 f i) (y : (i : I) \u2192 g i) (z : (i : I) \u2192 h i) => funext fun (i : I) => smul_assoc (x i) (y i) (z i)\n\nprotected instance mul_action {I : Type u} {f : I \u2192 Type v} (\u03b1 : Type u_1) {m : monoid \u03b1} [(i : I) \u2192 mul_action \u03b1 (f i)] : mul_action \u03b1 ((i : I) \u2192 f i) :=\n  mul_action.mk sorry sorry\n\nprotected instance mul_action' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1} {m : (i : I) \u2192 monoid (f i)} [(i : I) \u2192 mul_action (f i) (g i)] : mul_action ((i : I) \u2192 f i) ((i : I) \u2192 g i) :=\n  mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action {I : Type u} {f : I \u2192 Type v} (\u03b1 : Type u_1) {m : monoid \u03b1} {n : (i : I) \u2192 add_monoid (f i)} [(i : I) \u2192 distrib_mul_action \u03b1 (f i)] : distrib_mul_action \u03b1 ((i : I) \u2192 f i) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1} {m : (i : I) \u2192 monoid (f i)} {n : (i : I) \u2192 add_monoid (g i)} [(i : I) \u2192 distrib_mul_action (f i) (g i)] : distrib_mul_action ((i : I) \u2192 f i) ((i : I) \u2192 g i) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance semimodule (I : Type u) (f : I \u2192 Type v) (\u03b1 : Type u_1) {r : semiring \u03b1} {m : (i : I) \u2192 add_comm_monoid (f i)} [(i : I) \u2192 semimodule \u03b1 (f i)] : semimodule \u03b1 ((i : I) \u2192 f i) :=\n  semimodule.mk sorry sorry\n\nprotected instance semimodule' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1} {r : (i : I) \u2192 semiring (f i)} {m : (i : I) \u2192 add_comm_monoid (g i)} [(i : I) \u2192 semimodule (f i) (g i)] : semimodule ((i : I) \u2192 f i) ((i : I) \u2192 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+ `\u03c3 : 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 \u03c3 R \u2192\u2090[R] mv_polynomial \u03c4 R`\nand a variable evaluation `v : \u03c4 \u2192 R`,\n`comap f v` produces a variable evaluation `\u03c3 \u2192 R`.\n-/\ndef comap {\u03c3 : Type u_1} {\u03c4 : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_hom R (mv_polynomial \u03c3 R) (mv_polynomial \u03c4 R)) : (\u03c4 \u2192 R) \u2192 \u03c3 \u2192 R :=\n  fun (x : \u03c4 \u2192 R) (i : \u03c3) => coe_fn (aeval x) (coe_fn f (X i))\n\n@[simp] theorem comap_apply {\u03c3 : Type u_1} {\u03c4 : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_hom R (mv_polynomial \u03c3 R) (mv_polynomial \u03c4 R)) (x : \u03c4 \u2192 R) (i : \u03c3) :\n    comap f x i = coe_fn (aeval x) (coe_fn f (X i)) :=\n  rfl\n\n@[simp] theorem comap_id_apply {\u03c3 : Type u_1} {R : Type u_4} [comm_semiring R] (x : \u03c3 \u2192 R) :\n    comap (alg_hom.id R (mv_polynomial \u03c3 R)) x = x :=\n  sorry\n\ntheorem comap_id (\u03c3 : Type u_1) (R : Type u_4) [comm_semiring R] :\n    comap (alg_hom.id R (mv_polynomial \u03c3 R)) = id :=\n  funext fun (x : \u03c3 \u2192 R) => comap_id_apply x\n\ntheorem comap_comp_apply {\u03c3 : Type u_1} {\u03c4 : Type u_2} {\u03c5 : Type u_3} {R : Type u_4}\n    [comm_semiring R] (f : alg_hom R (mv_polynomial \u03c3 R) (mv_polynomial \u03c4 R))\n    (g : alg_hom R (mv_polynomial \u03c4 R) (mv_polynomial \u03c5 R)) (x : \u03c5 \u2192 R) :\n    comap (alg_hom.comp g f) x = comap f (comap g x) :=\n  sorry\n\ntheorem comap_comp {\u03c3 : Type u_1} {\u03c4 : Type u_2} {\u03c5 : Type u_3} {R : Type u_4} [comm_semiring R]\n    (f : alg_hom R (mv_polynomial \u03c3 R) (mv_polynomial \u03c4 R))\n    (g : alg_hom R (mv_polynomial \u03c4 R) (mv_polynomial \u03c5 R)) :\n    comap (alg_hom.comp g f) = comap f \u2218 comap g :=\n  funext fun (x : \u03c5 \u2192 R) => comap_comp_apply f g x\n\ntheorem comap_eq_id_of_eq_id {\u03c3 : Type u_1} {R : Type u_4} [comm_semiring R]\n    (f : alg_hom R (mv_polynomial \u03c3 R) (mv_polynomial \u03c3 R))\n    (hf : \u2200 (\u03c6 : mv_polynomial \u03c3 R), coe_fn f \u03c6 = \u03c6) (x : \u03c3 \u2192 R) : comap f x = x :=\n  sorry\n\ntheorem comap_rename {\u03c3 : Type u_1} {\u03c4 : Type u_2} {R : Type u_4} [comm_semiring R] (f : \u03c3 \u2192 \u03c4)\n    (x : \u03c4 \u2192 R) : comap (rename f) x = x \u2218 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 {\u03c3 : Type u_1} {\u03c4 : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_equiv R (mv_polynomial \u03c3 R) (mv_polynomial \u03c4 R)) : (\u03c4 \u2192 R) \u2243 (\u03c3 \u2192 R) :=\n  equiv.mk (comap \u2191f) (comap \u2191(alg_equiv.symm f)) sorry sorry\n\n@[simp] theorem comap_equiv_coe {\u03c3 : Type u_1} {\u03c4 : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_equiv R (mv_polynomial \u03c3 R) (mv_polynomial \u03c4 R)) : \u21d1(comap_equiv f) = comap \u2191f :=\n  rfl\n\n@[simp] theorem comap_equiv_symm_coe {\u03c3 : Type u_1} {\u03c4 : Type u_2} {R : Type u_4} [comm_semiring R]\n    (f : alg_equiv R (mv_polynomial \u03c3 R) (mv_polynomial \u03c4 R)) :\n    \u21d1(equiv.symm (comap_equiv f)) = comap \u2191(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 : \u2115 | x = 1 \u2228 x = 2 \u2228 x = 3 \u2228 x = 4}\ndefinition S6 := {x : \u2115 | false}\n\ndefinition r1 (a b : \u211d) : Prop := a \u2264 b\ndefinition r2 (a b : \u2124) : Prop := \u2203 k, a - b = k ^ 2\ndefinition r3 (a b : \u211d) : Prop := a = b ^ 2\ndefinition r4 (a b : \u2124) : Prop := a + b = 0\n\ndefinition r5 (a b : S5) : Prop := (a : \u2115) = 1 \u2227 (b : \u2115) = 3\ndefinition r6 (a b : S6) : Prop := true\n\n\n\ninstance nat.decidable_bex_lt (n : nat) (P : \u03a0 k < n, Prop) :\n  \u2200 [H : \u2200 n h, decidable (P n h)], decidable (\u2203 k h, P k h) :=\nbegin\n  induction n with n IH; intro; resetI,\n  { exact is_false (\u03bb \u27e8_, h, _\u27e9, nat.not_lt_zero _ h) },\n  cases IH (\u03bb 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 \u27e8n, nat.lt_succ_self n, p\u27e9 },\n    { apply is_false,\n      intro hk,\n      rcases hk with \u27e8k, hk1, hk2\u27e9,\n      cases nat.lt_succ_iff_lt_or_eq.1 hk1 with hk hk,\n      { exact h \u27e8k, hk, hk2\u27e9 },\n      { subst hk, exact p hk2 } } },\n  apply is_true,\n  rcases h with \u27e8k, hk1, hk2\u27e9,\n  exact \u27e8k, nat.lt_succ_of_lt hk1, hk2\u27e9\nend\n\ninstance nat.decidable_bex_le (n : nat) (P : \u03a0 k \u2264 n, Prop)\n  [\u03a0 n h, decidable (P n h)] : decidable (\u2203 k h, P k h) :=\ndecidable_of_iff (\u2203 k < n + 1, P k (nat.le_of_lt_succ H))\n\u27e8\u03bb \u27e8k, h1, h2\u27e9, \u27e8k, nat.le_of_lt_succ h1, h2\u27e9,\n\u03bb \u27e8k, h1, h2\u27e9, \u27e8k, nat.lt_succ_of_le h1, h2\u27e9\u27e9\n\ninstance decidable_mul_self_nat (n : \u2115) : decidable (\u2203 k, k * k = n) :=\ndecidable_of_iff (\u2203 k \u2264 n, k * k = n)\n\u27e8\u03bb \u27e8k, h1, h2\u27e9, \u27e8k, h2\u27e9, \u03bb \u27e8k, h1\u27e9, \u27e8k, h1 \u25b8 nat.le_mul_self k, h1\u27e9\u27e9\n\ninstance decidable_sqr_nat (n : \u2115) : decidable (\u2203 k, k^2 = n) :=\ndecidable_of_iff (\u2203 k, k * k = n)\n\u27e8\u03bb \u27e8k, h\u27e9, \u27e8k, by rwa [nat.pow_two]\u27e9, \u03bb \u27e8k, h\u27e9, \u27e8k, by rwa [nat.pow_two] at h\u27e9\u27e9\n\ninstance decidable_mul_self_int : \u03a0 (n : \u2124), decidable (\u2203 k, k * k = n)\n| (int.of_nat n) := decidable_of_iff (\u2203 k, k * k = n)\n    \u27e8\u03bb \u27e8k, hk\u27e9, \u27e8k, by rw [\u2190 int.coe_nat_mul, hk]; refl\u27e9,\n    \u03bb \u27e8k, hk\u27e9, \u27e8int.nat_abs k, by rw [\u2190 int.nat_abs_mul, hk]; refl\u27e9\u27e9\n| -[1+ n] := is_false $ \u03bb \u27e8k, h1\u27e9, not_lt_of_ge (mul_self_nonneg k) $\n    h1.symm \u25b8 int.neg_succ_of_nat_lt_zero n\n\ninstance decidable_sqr_int (n : \u2124) : decidable (\u2203 k, k^2 = n) :=\ndecidable_of_iff (\u2203 k, k * k = n)\n\u27e8\u03bb \u27e8k, h\u27e9, \u27e8k, by rwa [pow_two]\u27e9, \u03bb \u27e8k, h\u27e9, \u27e8k, by rwa [pow_two] at h\u27e9\u27e9\n\ntheorem what_i_need: \u00ac (\u2203 n : \u2124 ,  n ^ 2 = 2 ) := dec_trivial\ntheorem what_i_need_2: \u00ac (\u2203 n : \u2124 ,  n ^ 2 = -1 ) := dec_trivial\n\n\n--nstance h (m : \u2124) : decidable (\u2203 n : \u2124, n ^ 2 = m) :=\n--decidable_of_iff (0 \u2264 m \u2227 m.nat_abs.sqrt ^ 2 = m.nat_abs)\n--\u27e8\u03bb h, \u27e8nat.sqrt m.nat_abs, by rw [\u2190 int.coe_nat_pow, h.2, int.nat_abs_of_nonneg h.1]\u27e9,\n--\u03bb \u27e8s, hs\u27e9, \u27e8hs \u25b8 (pow_two_nonneg _), by rw [\u2190 hs, pow_two, int.nat_abs_mul, nat.sqrt_eq, nat.pow_two]\u27e9\u27e9\n--#eval (\u00ac \u2203 n : \u2124, n ^ 2 = 2 : bool)\n--lemma two_not_square : \u00ac \u2203 n : \u2124, 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 : \u00ac (symmetric r1) := begin\nunfold symmetric r1,\nintro HP,\nhave h2: (0:\u211d ) \u2264 (1:\u211d), by norm_num,\nhave h3:= HP h2,\nhave h4: \u00ac((1:\u211d) \u2264 (0:\u211d)), by norm_num,\nexact h4 h3,\nend\ntheorem Q1t : transitive r1 := begin\nunfold transitive r1,\nintro a,\nintro b,\nintro c,\nassume h1 : a \u2264 b,\nassume h2 : b \u2264 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 : \u2124) = (0 : \u2124) * (0 : \u2124), norm_num,\nexistsi (0 : \u2124),\nexact h2,\nend\ntheorem Q2s : \u00ac (symmetric r2) := begin\nunfold symmetric r2,\nintro HP,\nhave h1 : (1: \u2124 )-(0: \u2124 ) = 1^2, by norm_num,\nhave h4 := HP(exists.intro(1: \u2124 ) 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 : \u00ac (transitive r2) := begin\nunfold transitive r2,\nintro HP,\nhave h1: (2:\u2124 ) - (1:\u2124 ) = 1^2, by refl,\nhave h2: (1:\u2124 ) - (0:\u2124 ) = 1^2, by refl,\nhave h3: (2:\u2124 ) - (0:\u2124 ) = 2, by norm_num,\nhave h4 := HP (exists.intro (1: \u2124 ) h1)(exists.intro(1:\u2124 ) h2),\napply what_i_need,\nsimp at h4,\ncases h4 with z hz,\nexistsi z,\nrw hz,\nend\n\n\ntheorem Q3r : \u00ac (reflexive r3) := begin\nunfold reflexive r3,\nintro HP,\nlet x := (2 :\u211d ),\nhave h1 : (2 : \u211d ) \u2260 (2:\u211d )^2, by norm_num,\nhave h2 := HP(2: \u211d ),\napply h1,\nexact h2,\nend\ntheorem Q3s : \u00ac (symmetric r3) := begin\nunfold symmetric r3,\nintro HP,\nlet a := (4: \u211d ),\nlet b := (2: \u211d ),\nhave h1 : a = b^2, by refl,\nhave h2 : a^2 = 16, by refl,\nhave h3 : (2 : \u211d) \u2260 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 : \u00ac (transitive r3) := begin\nunfold transitive r3,\nintro HP,\nhave h1: (16: \u211d ) = (4: \u211d )^2, by refl,\nhave h2: (4:\u211d ) = (2:\u211d )^2, by refl,\nhave h3: (16: \u211d ) \u2260 (2:\u211d )^2, by norm_num,\nhave h4 := HP h1 h2,\napply h3,\nexact h4, \nend\n\ntheorem Q4r : \u00ac (reflexive r4) := begin\nunfold reflexive r4,\nintro HP,\nhave h1 : (1:\u2124 )+ (1:\u2124 ) \u2260 (0:\u2124 ), by norm_num,\nhave h2 := HP(1:\u2124 ),\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 : \u00ac (transitive r4) := begin\n\nunfold transitive r4,\nintro HP,\nlet a:= (1:\u2124) , \nlet b:= (-1: \u2124 ),\nlet c:= (1: \u2124 ),\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 :  \u00ac (reflexive r5) := begin\nunfold reflexive r5,\nintro HP,\ndunfold S5 at HP,\nhave h1 : (2:\u2115 ) \u2208 {x : \u2115 | x = 1 \u2228 x = 2 \u2228 x = 3 \u2228 x = 4}, by norm_num,\nhave h2 : (2 : \u2115 ) \u2260 (1 : \u2115 ), by norm_num,\nhave h3 : (2 : \u2115 ) \u2260 (3 : \u2115 ), by norm_num,\nhave h4 := HP \u27e82, by simp\u27e9,\napply h2,\nexact h4.left,\nend\ntheorem Q5s : \u00ac (symmetric r5) := begin\nunfold symmetric r5,\nintro HP,\ndunfold S5 at HP,\nhave h1 : (1 :\u2115 ) \u2208 {x : \u2115 | x = 1 \u2228 x = 2 \u2228 x = 3 \u2228 x = 4}, by norm_num,\nhave h2 : (3 :\u2115 ) \u2208 {x : \u2115 | x = 1 \u2228 x = 2 \u2228 x = 3 \u2228 x = 4}, by norm_num,\nhave h3 : (1 :\u2115 ) \u2260 (3 :\u2115 ), by norm_num,\nhave := @HP \u27e8(1 : \u2115), by simp\u27e9 \u27e83, by simp\u27e9 \u27e8rfl, rfl\u27e9,\napply h3,\nexact this.right,\nend\ntheorem Q5t : (transitive r5) := begin\nunfold transitive r5,\nhave h1 : (1 :\u2115 ) \u2208 {x : \u2115 | x = 1 \u2228 x = 2 \u2228 x = 3 \u2228 x = 4}, by norm_num,\nhave h2 : (3 :\u2115 ) \u2208 {x : \u2115 | x = 1 \u2228 x = 2 \u2228 x = 3 \u2228 x = 4}, by norm_num,\nhave h3 : (1 :\u2115 ) \u2260 (3 :\u2115 ), by norm_num,\nhave h4 : (3 :\u2115 ) \u2260 (1 :\u2115 ), 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\u00f6lzl, 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* `\u2192+`: Bundled `add_monoid` homs. Also use for `add_group` homs.\n* `\u2192*`: Bundled `monoid` homs. Also use for `group` homs.\n* `\u2192*\u2080`: Bundled `monoid_with_zero` homs. Also use for `group_with_zero` homs.\n* `\u2192\u2099*`: 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 {\u03b1 \u03b2 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 \u2192 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 \u2192 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 : \u2200 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\u2093'. -/\ntheorem of_map {R M} [Zero R] [Zero M] [ZeroHomClass F R M] (f : F) {r : R} [NeZero (f r)] :\n    NeZero r :=\n  \u27e8fun h => ne (f r) <| by convert ZeroHomClass.map_zero f\u27e9\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\u2093'. -/\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  \u27e8by\n    rw [\u2190 ZeroHomClass.map_zero f]\n    exact hf.ne (Ne r)\u27e9\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 \u2192 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 \u2192 N\n  map_add' : \u2200 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 : \u2200 (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 \u2192+ N` is the type of functions `M \u2192 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 \u2192+ 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: \u00abexpr \u2192+ \u00bb\ninfixr:25 \" \u2192+ \" => 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 \u2192 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 \u2192 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 : \u2200 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\u2093'. -/\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\u2093'. -/\n@[to_additive]\ntheorem map_eq_one_iff [OneHomClass F M N] (f : F) (hf : Function.Injective f) {x : M} :\n    f x = 1 \u2194 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\u2093'. -/\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 \u2260 1 \u2194 x \u2260 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\u2093'. -/\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 \u2260 1) : x \u2260 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  \u27e8fun f =>\n    { toFun := f\n      map_one' := map_one f }\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem OneHom.coe_coe [OneHomClass F M N] (f : F) : ((f : OneHom M N) : M \u2192 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 \u2192\u2099* N` is the type of functions `M \u2192 N` that preserve multiplication. The `\u2099` 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 \u2192\u2099* 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 \u2192 N\n  map_mul' : \u2200 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: \u00abexpr \u2192\u2099* \u00bb\ninfixr:25 \" \u2192\u2099* \" => 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 : \u2200 (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 \u2192\u2099* 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\u2093'. -/\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 \u2192\u2099* N) :=\n  \u27e8fun f =>\n    { toFun := f\n      map_mul' := map_mul f }\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem MulHom.coe_coe [MulHomClass F M N] (f : F) : ((f : MulHom M N) : M \u2192 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 \u2192* N` is the type of functions `M \u2192 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 \u2192+ 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 \u2192\u2099* 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: \u00abexpr \u2192* \u00bb\ninfixr:25 \" \u2192* \" => 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 \u2192* 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 \u2192* N) :=\n  \u27e8fun f =>\n    { toFun := f\n      map_one' := map_one f\n      map_mul' := map_mul f }\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.coe_coe [MonoidHomClass F M N] (f : F) : ((f : M \u2192* N) : M \u2192 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\u2093'. -/\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 [\u2190 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'\u2093'. -/\n@[to_additive]\ntheorem map_div' [DivInvMonoid G] [DivInvMonoid H] [MonoidHomClass F G H] (f : F)\n    (hf : \u2200 a, f a\u207b\u00b9 = (f a)\u207b\u00b9) (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\u2093'. -/\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\u207b\u00b9 = (f a)\u207b\u00b9 :=\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\u2093'. -/\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\u207b\u00b9) = f a * (f b)\u207b\u00b9 := 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\u2093'. -/\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    \u2200 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\u2093'. -/\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    \u2200 n : \u2115, 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\u2093'. -/\n@[simp]\ntheorem map_nsmul [AddMonoid G] [AddMonoid H] [AddMonoidHomClass F G H] (f : F) (n : \u2115) (a : G) :\n    f (n \u2022 a) = n \u2022 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'\u2093'. -/\n@[to_additive]\ntheorem map_zpow' [DivInvMonoid G] [DivInvMonoid H] [MonoidHomClass F G H] (f : F)\n    (hf : \u2200 x : G, f x\u207b\u00b9 = (f x)\u207b\u00b9) (a : G) : \u2200 n : \u2124, f (a ^ n) = f a ^ n\n  | (n : \u2115) => by rw [zpow_ofNat, map_pow, zpow_ofNat]\n  | -[n+1] => by rw [zpow_negSucc, hf, map_pow, \u2190 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\u2093'. -/\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 : \u2124) :\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\u2093'. -/\n/-- Additive group homomorphisms preserve integer scaling. -/\ntheorem map_zsmul [AddGroup G] [SubtractionMonoid H] [AddMonoidHomClass F G H] (f : F) (n : \u2124)\n    (g : G) : f (n \u2022 g) = n \u2022 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 \u2192*\u2080 N` is the type of functions `M \u2192 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 \u2192*\u2080 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: \u00abexpr \u2192*\u2080 \u00bb\ninfixr:25 \" \u2192*\u2080 \" => 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 \u2192*\u2080 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 \u2192*\u2080 N) :=\n  \u27e8fun f =>\n    { toFun := f\n      map_one' := map_one f\n      map_zero' := map_zero f\n      map_mul' := map_mul f }\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.coe_coe [MonoidWithZeroHomClass F M N] (f : F) :\n    ((f : M \u2192*\u2080 N) : M \u2192 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\u2093'. -/\n@[to_additive]\ninstance MonoidHom.coeToOneHom {mM : MulOneClass M} {mN : MulOneClass N} :\n    Coe (M \u2192* N) (OneHom M N) :=\n  \u27e8MonoidHom.toOneHom\u27e9\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\u2093'. -/\n@[to_additive]\ninstance MonoidHom.coeToMulHom {mM : MulOneClass M} {mN : MulOneClass N} : Coe (M \u2192* N) (M \u2192\u2099* N) :=\n  \u27e8MonoidHom.toMulHom\u27e9\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 \u2192*\u2080 N) (M \u2192* N) :=\n  \u27e8MonoidWithZeroHom.toMonoidHom\u27e9\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\u2093'. -/\ninstance MonoidWithZeroHom.coeToZeroHom {mM : MulZeroOneClass M} {mN : MulZeroOneClass N} :\n    Coe (M \u2192*\u2080 N) (ZeroHom M N) :=\n  \u27e8MonoidWithZeroHom.toZeroHom\u27e9\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 `\u2191f` 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 \u2192* 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 \u2192* N) :\n    (f : M \u2192\u2099* 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 \u2192*\u2080 N) : (f : M \u2192* 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 \u2192*\u2080 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 \u2192 N :=\n  \u27e8OneHom.toFun\u27e9\n\n@[to_additive]\ninstance {mM : Mul M} {mN : Mul N} : CoeFun (M \u2192\u2099* N) fun _ => M \u2192 N :=\n  \u27e8MulHom.toFun\u27e9\n\n@[to_additive]\ninstance {mM : MulOneClass M} {mN : MulOneClass N} : CoeFun (M \u2192* N) fun _ => M \u2192 N :=\n  \u27e8MonoidHom.toFun\u27e9\n\ninstance {mM : MulZeroOneClass M} {mN : MulZeroOneClass N} : CoeFun (M \u2192*\u2080 N) fun _ => M \u2192 N :=\n  \u27e8MonoidWithZeroHom.toFun\u27e9\n\n-- these must come after the coe_to_fun definitions\ninitialize_simps_projections ZeroHom (toFun \u2192 apply)\n\ninitialize_simps_projections AddHom (toFun \u2192 apply)\n\ninitialize_simps_projections AddMonoidHom (toFun \u2192 apply)\n\ninitialize_simps_projections OneHom (toFun \u2192 apply)\n\ninitialize_simps_projections MulHom (toFun \u2192 apply)\n\ninitialize_simps_projections MonoidHom (toFun \u2192 apply)\n\ninitialize_simps_projections MonoidWithZeroHom (toFun \u2192 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\u2093'. -/\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\u2093'. -/\n@[simp, to_additive]\ntheorem MulHom.toFun_eq_coe [Mul M] [Mul N] (f : M \u2192\u2099* 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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.toFun_eq_coe [MulOneClass M] [MulOneClass N] (f : M \u2192* 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 \u2192*\u2080 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\u2093'. -/\n@[simp, to_additive]\ntheorem OneHom.coe_mk [One M] [One N] (f : M \u2192 N) (h1) : (OneHom.mk f h1 : M \u2192 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\u2093'. -/\n@[simp, to_additive]\ntheorem MulHom.coe_mk [Mul M] [Mul N] (f : M \u2192 N) (hmul) : (MulHom.mk f hmul : M \u2192 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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.coe_mk [MulOneClass M] [MulOneClass N] (f : M \u2192 N) (h1 hmul) :\n    (MonoidHom.mk f h1 hmul : M \u2192 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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.coe_mk [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192 N) (h0 h1 hmul) :\n    (MonoidWithZeroHom.mk f h0 h1 hmul : M \u2192 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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.toOneHom_coe [MulOneClass M] [MulOneClass N] (f : M \u2192* N) :\n    (f.toOneHom : M \u2192 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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.toMulHom_coe [MulOneClass M] [MulOneClass N] (f : M \u2192* N) :\n    (f.toMulHom : M \u2192 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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.toZeroHom_coe [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 N) :\n    (f.toZeroHom : M \u2192 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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.toMonoidHom_coe [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 N) :\n    (f.toMonoidHom : M \u2192 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\u2093'. -/\n@[ext, to_additive]\ntheorem OneHom.ext [One M] [One N] \u2983f g : OneHom M N\u2984 (h : \u2200 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\u2093'. -/\n@[ext, to_additive]\ntheorem MulHom.ext [Mul M] [Mul N] \u2983f g : M \u2192\u2099* N\u2984 (h : \u2200 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\u2093'. -/\n@[ext, to_additive]\ntheorem MonoidHom.ext [MulOneClass M] [MulOneClass N] \u2983f g : M \u2192* N\u2984 (h : \u2200 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\u2093'. -/\n@[ext]\ntheorem MonoidWithZeroHom.ext [MulZeroOneClass M] [MulZeroOneClass N] \u2983f g : M \u2192*\u2080 N\u2984\n    (h : \u2200 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\u2093'. -/\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\u2093'. -/\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 \u2192\u2099* 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\u2093'. -/\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 \u2192* 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\u2093'. -/\n/-- Deprecated: use `fun_like.congr_fun` instead. -/\ntheorem MonoidWithZeroHom.congr_fun [MulZeroOneClass M] [MulZeroOneClass N] {f g : M \u2192*\u2080 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\u2093'. -/\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\u2093'. -/\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 \u2192\u2099* 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\u2093'. -/\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 \u2192* 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\u2093'. -/\n/-- Deprecated: use `fun_like.congr_arg` instead. -/\ntheorem MonoidWithZeroHom.congr_arg [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 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\u2093'. -/\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] \u2983f g : OneHom M N\u2984 (h : (f : M \u2192 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\u2093'. -/\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] \u2983f g : M \u2192\u2099* N\u2984 (h : (f : M \u2192 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\u2093'. -/\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] \u2983f g : M \u2192* N\u2984 (h : (f : M \u2192 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\u2093'. -/\n/-- Deprecated: use `fun_like.coe_injective` instead. -/\ntheorem MonoidWithZeroHom.coe_inj [MulZeroOneClass M] [MulZeroOneClass N] \u2983f g : M \u2192*\u2080 N\u2984\n    (h : (f : M \u2192 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\u2093'. -/\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 \u2194 \u2200 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\u2093'. -/\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 \u2192\u2099* N} : f = g \u2194 \u2200 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\u2093'. -/\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 \u2192* N} : f = g \u2194 \u2200 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\u2093'. -/\n/-- Deprecated: use `fun_like.ext_iff` instead. -/\ntheorem MonoidWithZeroHom.ext_iff [MulZeroOneClass M] [MulZeroOneClass N] {f g : M \u2192*\u2080 N} :\n    f = g \u2194 \u2200 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\u2093'. -/\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\u2093'. -/\n@[simp, to_additive]\ntheorem MulHom.mk_coe [Mul M] [Mul N] (f : M \u2192\u2099* 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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.mk_coe [MulOneClass M] [MulOneClass N] (f : M \u2192* 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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.mk_coe [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 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 \u2192 N) (h : f' = f) :\n    OneHom M N where\n  toFun := f'\n  map_one' := h.symm \u25b8 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 (\u1fb0 : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.1262 : M) => N) \u1fb0) (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\u2093'. -/\n@[simp, to_additive]\ntheorem OneHom.coe_copy {hM : One M} {hN : One N} (f : OneHom M N) (f' : M \u2192 N) (h : f' = f) :\n    \u21d1(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\u2093'. -/\n@[to_additive]\ntheorem OneHom.coe_copy_eq {hM : One M} {hN : One N} (f : OneHom M N) (f' : M \u2192 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 \u2192\u2099* N) (f' : M \u2192 N) (h : f' = f) :\n    M \u2192\u2099* N where\n  toFun := f'\n  map_mul' := h.symm \u25b8 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 (\u1fb0 : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) \u1fb0) (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\u2093'. -/\n@[simp, to_additive]\ntheorem MulHom.coe_copy {hM : Mul M} {hN : Mul N} (f : M \u2192\u2099* N) (f' : M \u2192 N) (h : f' = f) :\n    \u21d1(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\u2093'. -/\n@[to_additive]\ntheorem MulHom.coe_copy_eq {hM : Mul M} {hN : Mul N} (f : M \u2192\u2099* N) (f' : M \u2192 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\u2093'. -/\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 \u2192* N) (f' : M \u2192 N)\n    (h : f' = f) : M \u2192* 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 (\u1fb0 : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) \u1fb0) (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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.coe_copy {hM : MulOneClass M} {hN : MulOneClass N} (f : M \u2192* N) (f' : M \u2192 N)\n    (h : f' = f) : \u21d1(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\u2093'. -/\n@[to_additive]\ntheorem MonoidHom.copy_eq {hM : MulOneClass M} {hN : MulOneClass N} (f : M \u2192* N) (f' : M \u2192 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\u2093'. -/\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 \u2192*\u2080 N)\n    (f' : M \u2192 N) (h : f' = f) : M \u2192* 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 (\u1fb0 : M), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : M) => N) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.coe_copy {hM : MulZeroOneClass M} {hN : MulZeroOneClass N} (f : M \u2192*\u2080 N)\n    (f' : M \u2192 N) (h : f' = f) : \u21d1(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\u2093.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\u2093'. -/\ntheorem MonoidWithZeroHom.copy_eq {hM : MulZeroOneClass M} {hN : MulZeroOneClass N} (f : M \u2192*\u2080 N)\n    (f' : M \u2192 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\u2093'. -/\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\u2093'. -/\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 \u2192* 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\u2093'. -/\nprotected theorem MonoidWithZeroHom.map_one [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 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\u2093'. -/\nprotected theorem MonoidWithZeroHom.map_zero [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 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\u2093'. -/\n@[to_additive]\nprotected theorem MulHom.map_mul [Mul M] [Mul N] (f : M \u2192\u2099* 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\u2093'. -/\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 \u2192* 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\u2093'. -/\nprotected theorem MonoidWithZeroHom.map_mul [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 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\u2093'. -/\n/-- Given a monoid homomorphism `f : M \u2192* 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 \u2192+ 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 : \u2203 y, x * y = 1) : \u2203 y, f x * y = 1 :=\n  let \u27e8y, hy\u27e9 := hx\n  \u27e8f y, map_mul_eq_one f hy\u27e9\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\u2093'. -/\n/-- Given a monoid homomorphism `f : M \u2192* 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 \u2192+ 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 : \u2203 y, y * x = 1) : \u2203 y, y * f x = 1 :=\n  let \u27e8y, hy\u27e9 := hx\n  \u27e8f y, map_mul_eq_one f hy\u27e9\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 \u03b1]\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 : \u03b1 \u2192* \u03b1 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 {\u03b1 : Type.{u1}} [_inst_1 : DivisionCommMonoid.{u1} \u03b1], Eq.{succ u1} ((fun (_x : MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) => \u03b1 -> \u03b1) (invMonoidHom.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) (fun (_x : MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) => \u03b1 -> \u03b1) (MonoidHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) (invMonoidHom.{u1} \u03b1 _inst_1)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DivisionCommMonoid.{u1} \u03b1], Eq.{succ u1} (forall (a : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (MonoidHom.monoidHomClass.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))))) (invMonoidHom.{u1} \u03b1 _inst_1)) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align coe_inv_monoid_hom coe_invMonoidHom\u2093'. -/\n@[simp]\ntheorem coe_invMonoidHom : (invMonoidHom : \u03b1 \u2192 \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : DivisionCommMonoid.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) (fun (_x : MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) => \u03b1 -> \u03b1) (MonoidHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) (invMonoidHom.{u1} \u03b1 _inst_1) a) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DivisionCommMonoid.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))) \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (MonoidHom.monoidHomClass.{u1, u1} \u03b1 \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (DivisionMonoid.toDivInvMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1))))))) (invMonoidHom.{u1} \u03b1 _inst_1) a) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (DivisionCommMonoid.toDivisionMonoid.{u1} \u03b1 _inst_1)))) a)\nCase conversion may be inaccurate. Consider using '#align inv_monoid_hom_apply invMonoidHom_apply\u2093'. -/\n@[simp]\ntheorem invMonoidHom_apply (a : \u03b1) : invMonoidHom a = a\u207b\u00b9 :=\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 \u2192\u2099* 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 \u2192* 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 \u2192*\u2080 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 \u2218 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 \u2192\u2099* P) (hmn : M \u2192\u2099* N) : M \u2192\u2099* P\n    where\n  toFun := hnp \u2218 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 \u2192* P) (hmn : M \u2192* N) :\n    M \u2192* P where\n  toFun := hnp \u2218 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 \u2192*\u2080 P) (hmn : M \u2192*\u2080 N) : M \u2192*\u2080 P\n    where\n  toFun := hnp \u2218 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\u2093'. -/\n@[simp, to_additive]\ntheorem OneHom.coe_comp [One M] [One N] [One P] (g : OneHom N P) (f : OneHom M N) :\n    \u21d1(g.comp f) = g \u2218 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\u2093'. -/\n@[simp, to_additive]\ntheorem MulHom.coe_comp [Mul M] [Mul N] [Mul P] (g : N \u2192\u2099* P) (f : M \u2192\u2099* N) : \u21d1(g.comp f) = g \u2218 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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.coe_comp [MulOneClass M] [MulOneClass N] [MulOneClass P] (g : N \u2192* P)\n    (f : M \u2192* N) : \u21d1(g.comp f) = g \u2218 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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.coe_comp [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    (g : N \u2192*\u2080 P) (f : M \u2192*\u2080 N) : \u21d1(g.comp f) = g \u2218 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\u2093'. -/\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\u2093'. -/\n@[to_additive]\ntheorem MulHom.comp_apply [Mul M] [Mul N] [Mul P] (g : N \u2192\u2099* P) (f : M \u2192\u2099* 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\u2093'. -/\n@[to_additive]\ntheorem MonoidHom.comp_apply [MulOneClass M] [MulOneClass N] [MulOneClass P] (g : N \u2192* P)\n    (f : M \u2192* 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\u2093'. -/\ntheorem MonoidWithZeroHom.comp_apply [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    (g : N \u2192*\u2080 P) (f : M \u2192*\u2080 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\u2093'. -/\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\u2093'. -/\n@[to_additive]\ntheorem MulHom.comp_assoc {Q : Type _} [Mul M] [Mul N] [Mul P] [Mul Q] (f : M \u2192\u2099* N) (g : N \u2192\u2099* P)\n    (h : P \u2192\u2099* 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\u2093'. -/\n@[to_additive]\ntheorem MonoidHom.comp_assoc {Q : Type _} [MulOneClass M] [MulOneClass N] [MulOneClass P]\n    [MulOneClass Q] (f : M \u2192* N) (g : N \u2192* P) (h : P \u2192* 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\u2093'. -/\ntheorem MonoidWithZeroHom.comp_assoc {Q : Type _} [MulZeroOneClass M] [MulZeroOneClass N]\n    [MulZeroOneClass P] [MulZeroOneClass Q] (f : M \u2192*\u2080 N) (g : N \u2192*\u2080 P) (h : P \u2192*\u2080 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\u2081 : OneHom.{u2, u3} N P _inst_2 _inst_3} {g\u2082 : 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\u2081 f) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u3) (succ u2)} (OneHom.{u2, u3} N P _inst_2 _inst_3) g\u2081 g\u2082))\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\u2081 : OneHom.{u2, u1} N P _inst_2 _inst_3} {g\u2082 : 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\u2081 f) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u1)} (OneHom.{u2, u1} N P _inst_2 _inst_3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align one_hom.cancel_right OneHom.cancel_right\u2093'. -/\n@[to_additive]\ntheorem OneHom.cancel_right [One M] [One N] [One P] {g\u2081 g\u2082 : OneHom N P} {f : OneHom M N}\n    (hf : Function.Surjective f) : g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => OneHom.ext <| hf.forall.2 (OneHom.ext_iff.1 h), fun h => h \u25b8 rfl\u27e9\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\u2081 : MulHom.{u2, u3} N P _inst_2 _inst_3} {g\u2082 : 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\u2081 f) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u3) (succ u2)} (MulHom.{u2, u3} N P _inst_2 _inst_3) g\u2081 g\u2082))\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\u2081 : MulHom.{u2, u1} N P _inst_2 _inst_3} {g\u2082 : 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\u2081 f) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u1)} (MulHom.{u2, u1} N P _inst_2 _inst_3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align mul_hom.cancel_right MulHom.cancel_right\u2093'. -/\n@[to_additive]\ntheorem MulHom.cancel_right [Mul M] [Mul N] [Mul P] {g\u2081 g\u2082 : N \u2192\u2099* P} {f : M \u2192\u2099* N}\n    (hf : Function.Surjective f) : g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => MulHom.ext <| hf.forall.2 (MulHom.ext_iff.1 h), fun h => h \u25b8 rfl\u27e9\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\u2081 : MonoidHom.{u2, u3} N P _inst_2 _inst_3} {g\u2082 : 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\u2081 f) (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u3) (succ u2)} (MonoidHom.{u2, u3} N P _inst_2 _inst_3) g\u2081 g\u2082))\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\u2081 : MonoidHom.{u2, u1} N P _inst_2 _inst_3} {g\u2082 : 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\u2081 f) (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} N P _inst_2 _inst_3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.cancel_right MonoidHom.cancel_right\u2093'. -/\n@[to_additive]\ntheorem MonoidHom.cancel_right [MulOneClass M] [MulOneClass N] [MulOneClass P] {g\u2081 g\u2082 : N \u2192* P}\n    {f : M \u2192* N} (hf : Function.Surjective f) : g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => MonoidHom.ext <| hf.forall.2 (MonoidHom.ext_iff.1 h), fun h => h \u25b8 rfl\u27e9\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\u2081 : MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3} {g\u2082 : 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\u2081 f) (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u3) (succ u2)} (MonoidWithZeroHom.{u2, u3} N P _inst_2 _inst_3) g\u2081 g\u2082))\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\u2081 : MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3} {g\u2082 : 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\u2081 f) (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u2, u1} N P _inst_2 _inst_3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.cancel_right MonoidWithZeroHom.cancel_right\u2093'. -/\ntheorem MonoidWithZeroHom.cancel_right [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    {g\u2081 g\u2082 : N \u2192*\u2080 P} {f : M \u2192*\u2080 N} (hf : Function.Surjective f) :\n    g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => MonoidWithZeroHom.ext <| hf.forall.2 (MonoidWithZeroHom.ext_iff.1 h), fun h => h \u25b8 rfl\u27e9\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\u2081 : OneHom.{u1, u2} M N _inst_1 _inst_2} {f\u2082 : 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\u2081) (OneHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u2) (succ u1)} (OneHom.{u1, u2} M N _inst_1 _inst_2) f\u2081 f\u2082))\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\u2081 : OneHom.{u3, u2} M N _inst_1 _inst_2} {f\u2082 : 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\u2081) (OneHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u3) (succ u2)} (OneHom.{u3, u2} M N _inst_1 _inst_2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align one_hom.cancel_left OneHom.cancel_left\u2093'. -/\n@[to_additive]\ntheorem OneHom.cancel_left [One M] [One N] [One P] {g : OneHom N P} {f\u2081 f\u2082 : OneHom M N}\n    (hg : Function.Injective g) : g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => OneHom.ext fun x => hg <| by rw [\u2190 OneHom.comp_apply, h, OneHom.comp_apply], fun h =>\n    h \u25b8 rfl\u27e9\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\u2081 : MulHom.{u1, u2} M N _inst_1 _inst_2} {f\u2082 : 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\u2081) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} M N _inst_1 _inst_2) f\u2081 f\u2082))\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\u2081 : MulHom.{u3, u2} M N _inst_1 _inst_2} {f\u2082 : 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\u2081) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u3) (succ u2)} (MulHom.{u3, u2} M N _inst_1 _inst_2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align mul_hom.cancel_left MulHom.cancel_left\u2093'. -/\n@[to_additive]\ntheorem MulHom.cancel_left [Mul M] [Mul N] [Mul P] {g : N \u2192\u2099* P} {f\u2081 f\u2082 : M \u2192\u2099* N}\n    (hg : Function.Injective g) : g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => MulHom.ext fun x => hg <| by rw [\u2190 MulHom.comp_apply, h, MulHom.comp_apply], fun h =>\n    h \u25b8 rfl\u27e9\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\u2081 : MonoidHom.{u1, u2} M N _inst_1 _inst_2} {f\u2082 : 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\u2081) (MonoidHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} M N _inst_1 _inst_2) f\u2081 f\u2082))\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\u2081 : MonoidHom.{u3, u2} M N _inst_1 _inst_2} {f\u2082 : 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\u2081) (MonoidHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u3) (succ u2)} (MonoidHom.{u3, u2} M N _inst_1 _inst_2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.cancel_left MonoidHom.cancel_left\u2093'. -/\n@[to_additive]\ntheorem MonoidHom.cancel_left [MulOneClass M] [MulOneClass N] [MulOneClass P] {g : N \u2192* P}\n    {f\u2081 f\u2082 : M \u2192* N} (hg : Function.Injective g) : g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => MonoidHom.ext fun x => hg <| by rw [\u2190 MonoidHom.comp_apply, h, MonoidHom.comp_apply],\n    fun h => h \u25b8 rfl\u27e9\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\u2081 : MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2} {f\u2082 : 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\u2081) (MonoidWithZeroHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u2) (succ u1)} (MonoidWithZeroHom.{u1, u2} M N _inst_1 _inst_2) f\u2081 f\u2082))\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\u2081 : MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2} {f\u2082 : 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\u2081) (MonoidWithZeroHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u3) (succ u2)} (MonoidWithZeroHom.{u3, u2} M N _inst_1 _inst_2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align monoid_with_zero_hom.cancel_left MonoidWithZeroHom.cancel_left\u2093'. -/\ntheorem MonoidWithZeroHom.cancel_left [MulZeroOneClass M] [MulZeroOneClass N] [MulZeroOneClass P]\n    {g : N \u2192*\u2080 P} {f\u2081 f\u2082 : M \u2192*\u2080 N} (hg : Function.Injective g) : g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h =>\n    MonoidWithZeroHom.ext fun x =>\n      hg <| by rw [\u2190 MonoidWithZeroHom.comp_apply, h, MonoidWithZeroHom.comp_apply],\n    fun h => h \u25b8 rfl\u27e9\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\u2093'. -/\n@[to_additive]\ntheorem MonoidHom.toOneHom_injective [MulOneClass M] [MulOneClass N] :\n    Function.Injective (MonoidHom.toOneHom : (M \u2192* N) \u2192 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\u2093'. -/\n@[to_additive]\ntheorem MonoidHom.toMulHom_injective [MulOneClass M] [MulOneClass N] :\n    Function.Injective (MonoidHom.toMulHom : (M \u2192* N) \u2192 M \u2192\u2099* 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\u2093'. -/\ntheorem MonoidWithZeroHom.toMonoidHom_injective [MulZeroOneClass M] [MulZeroOneClass N] :\n    Function.Injective (MonoidWithZeroHom.toMonoidHom : (M \u2192*\u2080 N) \u2192 M \u2192* 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\u2093'. -/\ntheorem MonoidWithZeroHom.toZeroHom_injective [MulZeroOneClass M] [MulZeroOneClass N] :\n    Function.Injective (MonoidWithZeroHom.toZeroHom : (M \u2192*\u2080 N) \u2192 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\u2093'. -/\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\u2093'. -/\n@[simp, to_additive]\ntheorem MulHom.comp_id [Mul M] [Mul N] (f : M \u2192\u2099* 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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.comp_id [MulOneClass M] [MulOneClass N] (f : M \u2192* 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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.comp_id [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 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\u2093'. -/\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\u2093'. -/\n@[simp, to_additive]\ntheorem MulHom.id_comp [Mul M] [Mul N] (f : M \u2192\u2099* 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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.id_comp [MulOneClass M] [MulOneClass N] (f : M \u2192* 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\u2093'. -/\n@[simp]\ntheorem MonoidWithZeroHom.id_comp [MulZeroOneClass M] [MulZeroOneClass N] (f : M \u2192*\u2080 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\u2093'. -/\n@[to_additive AddMonoidHom.map_nsmul]\nprotected theorem MonoidHom.map_pow [Monoid M] [Monoid N] (f : M \u2192* N) (a : M) (n : \u2115) :\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'\u2093'. -/\n@[to_additive]\nprotected theorem MonoidHom.map_zpow' [DivInvMonoid M] [DivInvMonoid N] (f : M \u2192* N)\n    (hf : \u2200 x, f x\u207b\u00b9 = (f x)\u207b\u00b9) (a : M) (n : \u2124) : 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 \u2192* 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  \u27e81\u27e9\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\u2093'. -/\n@[simp]\ntheorem coe_one : ((1 : Monoid.End M) : M \u2192 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\u2093'. -/\n@[simp]\ntheorem coe_mul (f g) : ((f * g : Monoid.End M) : M \u2192 M) = f \u2218 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 \u2192+ 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  \u27e81\u27e9\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\u2093'. -/\n@[simp]\ntheorem coe_one : ((1 : AddMonoid.End A) : A \u2192 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\u2093'. -/\n@[simp]\ntheorem coe_mul (f g) : ((f * g : AddMonoid.End A) : A \u2192 A) = f \u2218 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  \u27e8\u27e8fun _ => 1, rfl\u27e9\u27e9\n\n/-- `1` is the multiplicative homomorphism sending all elements to `1`. -/\n@[to_additive]\ninstance [Mul M] [MulOneClass N] : One (M \u2192\u2099* N) :=\n  \u27e8\u27e8fun _ => 1, fun _ _ => (one_mul 1).symm\u27e9\u27e9\n\n/-- `1` is the monoid homomorphism sending all elements to `1`. -/\n@[to_additive]\ninstance [MulOneClass M] [MulOneClass N] : One (M \u2192* N) :=\n  \u27e8\u27e8fun _ => 1, rfl, fun _ _ => (one_mul 1).symm\u27e9\u27e9\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\u2093'. -/\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\u2093'. -/\n@[simp, to_additive]\ntheorem MonoidHom.one_apply [MulOneClass M] [MulOneClass N] (x : M) : (1 : M \u2192* 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\u2093'. -/\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\u2093'. -/\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  \u27e81\u27e9\n\n@[to_additive]\ninstance [Mul M] [MulOneClass N] : Inhabited (M \u2192\u2099* N) :=\n  \u27e81\u27e9\n\n@[to_additive]\ninstance [MulOneClass M] [MulOneClass N] : Inhabited (M \u2192* N) :=\n  \u27e81\u27e9\n\n-- unlike the other homs, `monoid_with_zero_hom` does not have a `1` or `0`\ninstance [MulZeroOneClass M] : Inhabited (M \u2192*\u2080 M) :=\n  \u27e8MonoidWithZeroHom.id M\u27e9\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 \u2192\u2099* N) :=\n  \u27e8fun 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, \u2190 mul_assoc, \u2190 mul_assoc, mul_right_comm (f x)] }\u27e9\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\u2093'. -/\n@[simp, to_additive]\ntheorem mul_apply {M N} {mM : Mul M} {mN : CommSemigroup N} (f g : M \u2192\u2099* 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\u2081 : MulHom.{u2, u3} N P _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3))) (g\u2082 : 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\u2081 g\u2082) 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\u2081 f) (MulHom.comp.{u1, u2, u3} M N P _inst_1 _inst_2 (Semigroup.toHasMul.{u3} P (CommSemigroup.toSemigroup.{u3} P _inst_3)) g\u2082 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\u2081 : MulHom.{u2, u1} N P _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3))) (g\u2082 : 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\u2081 g\u2082) 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\u2081 f) (MulHom.comp.{u3, u2, u1} M N P _inst_1 _inst_2 (Semigroup.toMul.{u1} P (CommSemigroup.toSemigroup.{u1} P _inst_3)) g\u2082 f))\nCase conversion may be inaccurate. Consider using '#align mul_hom.mul_comp MulHom.mul_comp\u2093'. -/\n@[to_additive]\ntheorem mul_comp [Mul M] [Mul N] [CommSemigroup P] (g\u2081 g\u2082 : N \u2192\u2099* P) (f : M \u2192\u2099* N) :\n    (g\u2081 * g\u2082).comp f = g\u2081.comp f * g\u2082.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\u2081 : MulHom.{u1, u2} M N _inst_1 (Semigroup.toHasMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (f\u2082 : 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\u2081 f\u2082)) (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\u2081) (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\u2082))\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\u2081 : MulHom.{u3, u2} M N _inst_1 (Semigroup.toMul.{u2} N (CommSemigroup.toSemigroup.{u2} N _inst_2))) (f\u2082 : 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\u2081 f\u2082)) (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\u2081) (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\u2082))\nCase conversion may be inaccurate. Consider using '#align mul_hom.comp_mul MulHom.comp_mul\u2093'. -/\n@[to_additive]\ntheorem comp_mul [Mul M] [CommSemigroup N] [CommSemigroup P] (g : N \u2192\u2099* P) (f\u2081 f\u2082 : M \u2192\u2099* N) :\n    g.comp (f\u2081 * f\u2082) = g.comp f\u2081 * g.comp f\u2082 := 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 \u2192* N) :=\n  \u27e8fun 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, \u2190 mul_assoc, \u2190 mul_assoc, mul_right_comm (f x)] }\u27e9\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\u2093'. -/\n@[simp, to_additive]\ntheorem mul_apply {M N} {mM : MulOneClass M} {mN : CommMonoid N} (f g : M \u2192* 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\u2093'. -/\n@[simp, to_additive]\ntheorem one_comp [MulOneClass M] [MulOneClass N] [MulOneClass P] (f : M \u2192* N) :\n    (1 : N \u2192* 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\u2093'. -/\n@[simp, to_additive]\ntheorem comp_one [MulOneClass M] [MulOneClass N] [MulOneClass P] (f : N \u2192* P) :\n    f.comp (1 : M \u2192* 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\u2081 : MonoidHom.{u2, u3} N P _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5))) (g\u2082 : 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\u2081 g\u2082) 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\u2081 f) (MonoidHom.comp.{u1, u2, u3} M N P _inst_3 _inst_4 (Monoid.toMulOneClass.{u3} P (CommMonoid.toMonoid.{u3} P _inst_5)) g\u2082 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\u2081 : MonoidHom.{u2, u1} N P _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5))) (g\u2082 : 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\u2081 g\u2082) 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\u2081 f) (MonoidHom.comp.{u3, u2, u1} M N P _inst_3 _inst_4 (Monoid.toMulOneClass.{u1} P (CommMonoid.toMonoid.{u1} P _inst_5)) g\u2082 f))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.mul_comp MonoidHom.mul_comp\u2093'. -/\n@[to_additive]\ntheorem mul_comp [MulOneClass M] [MulOneClass N] [CommMonoid P] (g\u2081 g\u2082 : N \u2192* P) (f : M \u2192* N) :\n    (g\u2081 * g\u2082).comp f = g\u2081.comp f * g\u2082.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\u2081 : MonoidHom.{u1, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (f\u2082 : 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\u2081 f\u2082)) (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\u2081) (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\u2082))\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\u2081 : MonoidHom.{u3, u2} M N _inst_3 (Monoid.toMulOneClass.{u2} N (CommMonoid.toMonoid.{u2} N _inst_4))) (f\u2082 : 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\u2081 f\u2082)) (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\u2081) (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\u2082))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.comp_mul MonoidHom.comp_mul\u2093'. -/\n@[to_additive]\ntheorem comp_mul [MulOneClass M] [CommMonoid N] [CommMonoid P] (g : N \u2192* P) (f\u2081 f\u2082 : M \u2192* N) :\n    g.comp (f\u2081 * f\u2082) = g.comp f\u2081 * g.comp f\u2082 := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DivisionMonoid.{u2} \u03b2] (f : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) a)) (Inv.inv.{u2} \u03b2 (DivInvMonoid.toHasInv.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_3 : Group.{u2} \u03b1] [_inst_4 : DivisionMonoid.{u1} \u03b2] (f : MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (Inv.inv.{u2} \u03b1 (InvOneClass.toInv.{u2} \u03b1 (DivInvOneMonoid.toInvOneClass.{u2} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u2} \u03b1 (Group.toDivisionMonoid.{u2} \u03b1 _inst_3)))) a)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f (Inv.inv.{u2} \u03b1 (InvOneClass.toInv.{u2} \u03b1 (DivInvOneMonoid.toInvOneClass.{u2} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u2} \u03b1 (Group.toDivisionMonoid.{u2} \u03b1 _inst_3)))) a)) (Inv.inv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (InvOneClass.toInv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (DivInvOneMonoid.toInvOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (DivisionMonoid.toDivInvOneMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) _inst_4))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f a))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_inv MonoidHom.map_inv\u2093'. -/\n/-- Group homomorphisms preserve inverse. -/\n@[to_additive \"Additive group homomorphisms preserve negation.\"]\nprotected theorem map_inv [Group \u03b1] [DivisionMonoid \u03b2] (f : \u03b1 \u2192* \u03b2) (a : \u03b1) : f a\u207b\u00b9 = (f a)\u207b\u00b9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DivisionMonoid.{u2} \u03b2] (f : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (g : \u03b1) (n : Int), Eq.{succ u2} \u03b2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) g n)) (HPow.hPow.{u2, 0, u2} \u03b2 Int \u03b2 (instHPow.{u2, 0} \u03b2 Int (DivInvMonoid.Pow.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f g) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_3 : Group.{u2} \u03b1] [_inst_4 : DivisionMonoid.{u1} \u03b2] (f : MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (g : \u03b1) (n : Int), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (HPow.hPow.{u2, 0, u2} \u03b1 Int \u03b1 (instHPow.{u2, 0} \u03b1 Int (DivInvMonoid.Pow.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) g n)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f (HPow.hPow.{u2, 0, u2} \u03b1 Int \u03b1 (instHPow.{u2, 0} \u03b1 Int (DivInvMonoid.Pow.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) g n)) (HPow.hPow.{u1, 0, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) Int ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (instHPow.{u1, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) Int (DivInvMonoid.Pow.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (DivisionMonoid.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) _inst_4))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f g) n)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_zpow MonoidHom.map_zpow\u2093'. -/\n/-- Group homomorphisms preserve integer power. -/\n@[to_additive \"Additive group homomorphisms preserve integer scaling.\"]\nprotected theorem map_zpow [Group \u03b1] [DivisionMonoid \u03b2] (f : \u03b1 \u2192* \u03b2) (g : \u03b1) (n : \u2124) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DivisionMonoid.{u2} \u03b2] (f : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (g : \u03b1) (h : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) g h)) (HDiv.hDiv.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHDiv.{u2} \u03b2 (DivInvMonoid.toHasDiv.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f g) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f h))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_3 : Group.{u2} \u03b1] [_inst_4 : DivisionMonoid.{u1} \u03b2] (f : MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (g : \u03b1) (h : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (HDiv.hDiv.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHDiv.{u2} \u03b1 (DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) g h)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f (HDiv.hDiv.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHDiv.{u2} \u03b1 (DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) g h)) (HDiv.hDiv.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) h) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (instHDiv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (DivInvMonoid.toDiv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (DivisionMonoid.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) _inst_4))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f g) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f h))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_div MonoidHom.map_div\u2093'. -/\n/-- Group homomorphisms preserve division. -/\n@[to_additive \"Additive group homomorphisms preserve subtraction.\"]\nprotected theorem map_div [Group \u03b1] [DivisionMonoid \u03b2] (f : \u03b1 \u2192* \u03b2) (g h : \u03b1) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DivisionMonoid.{u2} \u03b2] (f : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (g : \u03b1) (h : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))))) g (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) h))) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4))))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f g) (Inv.inv.{u2} \u03b2 (DivInvMonoid.toHasInv.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (DivisionMonoid.toDivInvMonoid.{u2} \u03b2 _inst_4)))) f h)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_3 : Group.{u2} \u03b1] [_inst_4 : DivisionMonoid.{u1} \u03b2] (f : MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (g : \u03b1) (h : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))))) g (Inv.inv.{u2} \u03b1 (InvOneClass.toInv.{u2} \u03b1 (DivInvOneMonoid.toInvOneClass.{u2} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u2} \u03b1 (Group.toDivisionMonoid.{u2} \u03b1 _inst_3)))) h))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))))) g (Inv.inv.{u2} \u03b1 (InvOneClass.toInv.{u2} \u03b1 (DivInvOneMonoid.toInvOneClass.{u2} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u2} \u03b1 (Group.toDivisionMonoid.{u2} \u03b1 _inst_3)))) h))) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) h) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (Monoid.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (DivInvMonoid.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) (DivisionMonoid.toDivInvMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) g) _inst_4))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f g) (Inv.inv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) h) (InvOneClass.toInv.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) h) (DivInvOneMonoid.toInvOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) h) (DivisionMonoid.toDivInvOneMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) h) _inst_4))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3)))) (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4))) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_3))) (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (DivisionMonoid.toDivInvMonoid.{u1} \u03b2 _inst_4)))))) f h)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.map_mul_inv MonoidHom.map_mul_inv\u2093'. -/\n/-- Group homomorphisms preserve division. -/\n@[to_additive \"Additive group homomorphisms preserve subtraction.\"]\nprotected theorem map_mul_inv [Group \u03b1] [DivisionMonoid \u03b2] (f : \u03b1 \u2192* \u03b2) (g h : \u03b1) :\n    f (g * h\u207b\u00b9) = f g * (f h)\u207b\u00b9 :=\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\u2093'. -/\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 \u2194 \u2200 a, f a = 1 \u2192 a = 1 :=\n  \u27e8fun 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, \u2190 map_mul, mul_inv_self, map_one]\u27e9\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'\u2093'. -/\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 \u2194 \u2200 a, f a = 1 \u2194 a = 1 :=\n  (injective_iff_map_eq_one f).trans <|\n    forall_congr' fun a => \u27e8fun h => \u27e8h, fun H => H.symm \u25b8 map_one f\u27e9, Iff.mp\u27e9\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'\u2093'. -/\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 \u2192 G) (map_mul : \u2200 a b : M, f (a * b) = f a * f b) : M \u2192* G\n    where\n  toFun := f\n  map_mul' := map_mul\n  map_one' := mul_left_eq_self.1 <| by rw [\u2190 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\u2093'. -/\n/-- Makes a group homomorphism from a proof that the map preserves right division `\u03bb x y, x * y\u207b\u00b9`.\nSee also `monoid_hom.of_map_div` for a version using `\u03bb x y, x / y`.\n-/\n@[to_additive\n      \"Makes an additive group homomorphism from a proof that the map preserves\\nthe operation `\u03bb a b, a + -b`. See also `add_monoid_hom.of_map_sub` for a version using\\n`\u03bb a b, a - b`.\"]\ndef ofMapMulInv {H : Type _} [Group H] (f : G \u2192 H)\n    (map_div : \u2200 a b : G, f (a * b\u207b\u00b9) = f a * (f b)\u207b\u00b9) : G \u2192* H :=\n  mk' f fun x y =>\n    calc\n      f (x * y) = f x * (f <| 1 * 1\u207b\u00b9 * y\u207b\u00b9)\u207b\u00b9 := by\n        simp only [one_mul, inv_one, \u2190 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\u2093'. -/\n@[simp, to_additive]\ntheorem coe_of_map_mul_inv {H : Type _} [Group H] (f : G \u2192 H)\n    (map_div : \u2200 a b : G, f (a * b\u207b\u00b9) = f a * (f b)\u207b\u00b9) : \u21d1(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\u2093'. -/\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 \u2192 H) (hf : \u2200 x y, f (x / y) = f x / f y) : G \u2192* 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\u2093'. -/\n@[simp, to_additive]\ntheorem coe_of_map_div {H : Type _} [Group H] (f : G \u2192 H) (hf : \u2200 x y, f (x / y) = f x / f y) :\n    \u21d1(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\u207b\u00b9` is the homomorphism sending\n`x` to `(f x)\u207b\u00b9`. -/\n@[to_additive]\ninstance {M G} [MulOneClass M] [CommGroup G] : Inv (M \u2192* G) :=\n  \u27e8fun f => mk' (fun g => (f g)\u207b\u00b9) fun a b => by rw [\u2190 mul_inv, f.map_mul]\u27e9\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\u2093'. -/\n@[simp, to_additive]\ntheorem inv_apply {M G} {mM : MulOneClass M} {gG : CommGroup G} (f : M \u2192* G) (x : M) :\n    f\u207b\u00b9 x = (f x)\u207b\u00b9 :=\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} (\u03c6 : MonoidHom.{u2, u3} N A gN (Monoid.toMulOneClass.{u3} A (DivInvMonoid.toMonoid.{u3} A (Group.toDivInvMonoid.{u3} A (CommGroup.toGroup.{u3} A gA))))) (\u03c8 : 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) \u03c6) \u03c8) (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)))) \u03c6 \u03c8))\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} (\u03c6 : MonoidHom.{u2, u1} N A gN (Monoid.toMulOneClass.{u1} A (DivInvMonoid.toMonoid.{u1} A (Group.toDivInvMonoid.{u1} A (CommGroup.toGroup.{u1} A gA))))) (\u03c8 : 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) \u03c6) \u03c8) (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)))) \u03c6 \u03c8))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.inv_comp MonoidHom.inv_comp\u2093'. -/\n@[simp, to_additive]\ntheorem inv_comp {M N A} {mM : MulOneClass M} {gN : MulOneClass N} {gA : CommGroup A} (\u03c6 : N \u2192* A)\n    (\u03c8 : M \u2192* N) : \u03c6\u207b\u00b9.comp \u03c8 = (\u03c6.comp \u03c8)\u207b\u00b9 := 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} (\u03c6 : 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))))) (\u03c8 : 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)))) \u03c6 (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) \u03c8)) (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)))) \u03c6 \u03c8))\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} (\u03c6 : 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))))) (\u03c8 : 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)))) \u03c6 (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) \u03c8)) (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)))) \u03c6 \u03c8))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.comp_inv MonoidHom.comp_inv\u2093'. -/\n@[simp, to_additive]\ntheorem comp_inv {M A B} {mM : MulOneClass M} {mA : CommGroup A} {mB : CommGroup B} (\u03c6 : A \u2192* B)\n    (\u03c8 : M \u2192* A) : \u03c6.comp \u03c8\u207b\u00b9 = (\u03c6.comp \u03c8)\u207b\u00b9 := 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 \u2192* G) :=\n  \u27e8fun 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]\u27e9\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\u2093'. -/\n@[simp, to_additive]\ntheorem div_apply {M G} {mM : MulOneClass M} {gG : CommGroup G} (f g : M \u2192* 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 \u2192*\u2080 N) :=\n  \u27e8fun f g =>\n    { (f * g : M \u2192* N) with\n      toFun := fun a => f a * g a\n      map_zero' := by rw [map_zero, MulZeroClass.zero_mul] }\u27e9\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 \u03b1 = \u03b1\u1d50\u1d52\u1d56` to be the multiplicative opposite of `\u03b1`. It inherits\nall additive algebraic structures on `\u03b1` (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 `\u03b1` to `\u03b1\u1d50\u1d52\u1d56`.\n\nWe also define `add_opposite \u03b1 = \u03b1\u1d43\u1d52\u1d56` to be the additive opposite of `\u03b1`. It inherits all\nmultiplicative algebraic structures on `\u03b1` (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 `\u03b1` to `\u03b1\u1d43\u1d52\u1d56`.\n\n## Notation\n\n* `\u03b1\u1d50\u1d52\u1d56 = mul_opposite \u03b1`\n* `\u03b1\u1d43\u1d52\u1d56 = add_opposite \u03b1`\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 `\u03b1` and\nreverses left and right in multiplication.-/\n@[to_additive \"Additive opposite of a type. This type inherits all multiplicative structures on\n`\u03b1` and reverses left and right in addition.\"]\ndef mul_opposite (\u03b1 : Type u) : Type u := \u03b1\n\npostfix `\u1d50\u1d52\u1d56`:std.prec.max_plus := mul_opposite\npostfix `\u1d43\u1d52\u1d56`:std.prec.max_plus := add_opposite\n\nvariables {\u03b1 : Type u}\n\nnamespace mul_opposite\n\n/-- The element of `mul_opposite \u03b1` that represents `x : \u03b1`. -/\n@[pp_nodot, to_additive \"The element of `\u03b1\u1d43\u1d52\u1d56` that represents `x : \u03b1`.\"]\ndef op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56 := id\n\n/-- The element of `\u03b1` represented by `x : \u03b1\u1d50\u1d52\u1d56`. -/\n@[pp_nodot, to_additive \"The element of `\u03b1` represented by `x : \u03b1\u1d43\u1d52\u1d56`.\"]\ndef unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1 := id\n\nattribute [pp_nodot] add_opposite.op add_opposite.unop\n\n@[simp, to_additive] lemma unop_op (x : \u03b1) : unop (op x) = x := rfl\n@[simp, to_additive] lemma op_unop (x : \u03b1\u1d50\u1d52\u1d56) : op (unop x) = x := rfl\n@[simp, to_additive] lemma op_comp_unop : (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) \u2218 unop = id := rfl\n@[simp, to_additive] lemma unop_comp_op : (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) \u2218 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 : \u03a0 (X : \u03b1\u1d50\u1d52\u1d56), Sort v} (h : \u03a0 X, F (op X)) : \u03a0 X, F X :=\n\u03bb X, h (unop X)\n\n/-- The canonical bijection between `\u03b1` and `\u03b1\u1d50\u1d52\u1d56`. -/\n@[to_additive \"The canonical bijection between `\u03b1` and `\u03b1\u1d43\u1d52\u1d56`.\",\n  simps apply symm_apply { fully_applied := ff }]\ndef op_equiv : \u03b1 \u2243 \u03b1\u1d50\u1d52\u1d56 := \u27e8op, unop, unop_op, op_unop\u27e9\n\n@[to_additive] lemma op_bijective : bijective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_equiv.bijective\n@[to_additive] lemma unop_bijective : bijective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := op_equiv.symm.bijective\n@[to_additive] lemma op_injective : injective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_bijective.injective\n@[to_additive] lemma op_surjective : surjective (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := op_bijective.surjective\n@[to_additive] lemma unop_injective : injective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := unop_bijective.injective\n@[to_additive] lemma unop_surjective : surjective (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := unop_bijective.surjective\n\n@[simp, to_additive] lemma op_inj {x y : \u03b1} : op x = op y \u2194 x = y := op_injective.eq_iff\n@[simp, to_additive] lemma unop_inj {x y : \u03b1\u1d50\u1d52\u1d56} : unop x = unop y \u2194 x = y := unop_injective.eq_iff\n\nvariable (\u03b1)\n\n@[to_additive] instance [nontrivial \u03b1] : nontrivial \u03b1\u1d50\u1d52\u1d56 := op_injective.nontrivial\n@[to_additive] instance [inhabited \u03b1] : inhabited \u03b1\u1d50\u1d52\u1d56 := \u27e8op default\u27e9\n@[to_additive] instance [subsingleton \u03b1] : subsingleton \u03b1\u1d50\u1d52\u1d56 := unop_injective.subsingleton\n@[to_additive] instance [unique \u03b1] : unique \u03b1\u1d50\u1d52\u1d56 := unique.mk' _\n@[to_additive] instance [is_empty \u03b1] : is_empty \u03b1\u1d50\u1d52\u1d56 := function.is_empty unop\n\ninstance [has_zero \u03b1] : has_zero \u03b1\u1d50\u1d52\u1d56 := { zero := op 0 }\n\n@[to_additive] instance [has_one \u03b1] : has_one \u03b1\u1d50\u1d52\u1d56 := { one := op 1 }\n\ninstance [has_add \u03b1] : has_add \u03b1\u1d50\u1d52\u1d56 :=\n{ add := \u03bb x y, op (unop x + unop y) }\n\ninstance [has_sub \u03b1] : has_sub \u03b1\u1d50\u1d52\u1d56 :=\n{ sub := \u03bb x y, op (unop x - unop y) }\n\ninstance [has_neg \u03b1] : has_neg \u03b1\u1d50\u1d52\u1d56 :=\n{ neg := \u03bb x, op $ -(unop x) }\n\ninstance [has_involutive_neg \u03b1] : has_involutive_neg \u03b1\u1d50\u1d52\u1d56 :=\n{ neg_neg := \u03bb a, unop_injective $ neg_neg _,\n  ..mul_opposite.has_neg \u03b1 }\n\n@[to_additive] instance [has_mul \u03b1] : has_mul \u03b1\u1d50\u1d52\u1d56 :=\n{ mul := \u03bb x y, op (unop y * unop x) }\n\n@[to_additive] instance [has_inv \u03b1] : has_inv \u03b1\u1d50\u1d52\u1d56 :=\n{ inv := \u03bb x, op $ (unop x)\u207b\u00b9 }\n\n@[to_additive] instance [has_involutive_inv \u03b1] : has_involutive_inv \u03b1\u1d50\u1d52\u1d56 :=\n{ inv_inv := \u03bb a, unop_injective $ inv_inv _,\n  ..mul_opposite.has_inv \u03b1 }\n\n@[to_additive] instance (R : Type*) [has_scalar R \u03b1] : has_scalar R \u03b1\u1d50\u1d52\u1d56 :=\n{ smul := \u03bb c x, op (c \u2022 unop x) }\n\nsection\nvariables (\u03b1)\n\n@[simp] lemma op_zero [has_zero \u03b1] : op (0 : \u03b1) = 0 := rfl\n@[simp] \n\n@[simp, to_additive] lemma op_one [has_one \u03b1] : op (1 : \u03b1) = 1 := rfl\n@[simp, to_additive] lemma unop_one [has_one \u03b1] : unop (1 : \u03b1\u1d50\u1d52\u1d56) = 1 := rfl\n\nvariable {\u03b1}\n\n@[simp] lemma op_add [has_add \u03b1] (x y : \u03b1) : op (x + y) = op x + op y := rfl\n@[simp] lemma unop_add [has_add \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x + y) = unop x + unop y := rfl\n\n@[simp] lemma op_neg [has_neg \u03b1] (x : \u03b1) : op (-x) = -op x := rfl\n@[simp] lemma unop_neg [has_neg \u03b1] (x : \u03b1\u1d50\u1d52\u1d56) : unop (-x) = -unop x := rfl\n\n@[simp, to_additive] lemma op_mul [has_mul \u03b1] (x y : \u03b1) : op (x * y) = op y * op x := rfl\n@[simp, to_additive] lemma unop_mul [has_mul \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x * y) = unop y * unop x := rfl\n\n@[simp, to_additive] lemma op_inv [has_inv \u03b1] (x : \u03b1) : op (x\u207b\u00b9) = (op x)\u207b\u00b9 := rfl\n@[simp, to_additive] lemma unop_inv [has_inv \u03b1] (x : \u03b1\u1d50\u1d52\u1d56) : unop (x\u207b\u00b9) = (unop x)\u207b\u00b9 := rfl\n\n@[simp] lemma op_sub [has_sub \u03b1] (x y : \u03b1) : op (x - y) = op x - op y := rfl\n@[simp] lemma unop_sub [has_sub \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x - y) = unop x - unop y := rfl\n\n@[simp, to_additive] lemma op_smul {R : Type*} [has_scalar R \u03b1] (c : R) (a : \u03b1) :\n  op (c \u2022 a) = c \u2022 op a := rfl\n\n@[simp, to_additive] lemma unop_smul {R : Type*} [has_scalar R \u03b1] (c : R) (a : \u03b1\u1d50\u1d52\u1d56) :\n  unop (c \u2022 a) = c \u2022 unop a := rfl\n\nend\n\nvariable {\u03b1}\n\n@[simp] lemma unop_eq_zero_iff [has_zero \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop = (0 : \u03b1) \u2194 a = (0 : \u03b1\u1d50\u1d52\u1d56) :=\nunop_injective.eq_iff' rfl\n\n@[simp] lemma op_eq_zero_iff [has_zero \u03b1] (a : \u03b1) : op a = (0 : \u03b1\u1d50\u1d52\u1d56) \u2194 a = (0 : \u03b1) :=\nop_injective.eq_iff' rfl\n\nlemma unop_ne_zero_iff [has_zero \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop \u2260 (0 : \u03b1) \u2194 a \u2260 (0 : \u03b1\u1d50\u1d52\u1d56) :=\nnot_congr $ unop_eq_zero_iff a\n\nlemma op_ne_zero_iff [has_zero \u03b1] (a : \u03b1) : op a \u2260 (0 : \u03b1\u1d50\u1d52\u1d56) \u2194 a \u2260 (0 : \u03b1) :=\nnot_congr $ op_eq_zero_iff a\n\n@[simp, to_additive] lemma unop_eq_one_iff [has_one \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop = 1 \u2194 a = 1 :=\nunop_injective.eq_iff' rfl\n\n@[simp, to_additive] lemma op_eq_one_iff [has_one \u03b1] (a : \u03b1) : op a = 1 \u2194 a = 1 :=\nop_injective.eq_iff' rfl\n\nend mul_opposite\n\nnamespace add_opposite\n\ninstance [has_one \u03b1] : has_one \u03b1\u1d43\u1d52\u1d56 := { one := op 1 }\n\n@[simp] lemma op_one [has_one \u03b1] : op (1 : \u03b1) = 1 := rfl\n@[simp] lemma unop_one [has_one \u03b1] : unop 1 = (1 : \u03b1) := rfl\n\n@[simp] lemma op_eq_one_iff [has_one \u03b1] {a : \u03b1} : op a = 1 \u2194 a = 1 := op_injective.eq_iff' op_one\n\n@[simp] lemma unop_eq_one_iff [has_one \u03b1] {a : \u03b1\u1d43\u1d52\u1d56} : unop a = 1 \u2194 a = 1 :=\nunop_injective.eq_iff' unop_one\n\ninstance [has_mul \u03b1] : has_mul \u03b1\u1d43\u1d52\u1d56 := { mul := \u03bb a b, op (unop a * unop b) }\n\n@[simp] lemma op_mul [has_mul \u03b1] (a b : \u03b1) : op (a * b) = op a * op b := rfl\n@[simp] lemma unop_mul [has_mul \u03b1] (a b : \u03b1\u1d43\u1d52\u1d56) : unop (a * b) = unop a * unop b := rfl\n\ninstance [has_inv \u03b1] : has_inv \u03b1\u1d43\u1d52\u1d56 := { inv := \u03bb a, op (unop a)\u207b\u00b9 }\n\ninstance [has_involutive_inv \u03b1] : has_involutive_inv \u03b1\u1d43\u1d52\u1d56 :=\n{ inv_inv := \u03bb a, unop_injective $ inv_inv _,\n  ..add_opposite.has_inv }\n\n@[simp] lemma op_inv [has_inv \u03b1] (a : \u03b1) : op a\u207b\u00b9 = (op a)\u207b\u00b9 := rfl\n@[simp] lemma unop_inv [has_inv \u03b1] (a : \u03b1\u1d43\u1d52\u1d56) : unop a\u207b\u00b9 = (unop a)\u207b\u00b9 := rfl\n\ninstance [has_div \u03b1] : has_div \u03b1\u1d43\u1d52\u1d56 := { div := \u03bb a b, op (unop a / unop b) }\n\n@[simp] lemma op_div [has_div \u03b1] (a b : \u03b1) : op (a / b) = op a / op b := rfl\n@[simp] lemma unop_div [has_div \u03b1] (a b : \u03b1) : 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 \u2194 b) = b :=\n  Eq.symm h \u25b8 propext (true_iff b)\n\ntheorem iff_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a \u2194 b) = a :=\n  Eq.symm h \u25b8 propext (iff_true a)\n\ntheorem iff_eq_true_of_eq {a : Prop} {b : Prop} (h : a = b) : (a \u2194 b) = True :=\n  h \u25b8 propext (iff_self a)\n\ntheorem and_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a \u2227 b) = b :=\n  Eq.symm h \u25b8 propext (true_and b)\n\ntheorem and_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a \u2227 b) = a :=\n  Eq.symm h \u25b8 propext (and_true a)\n\ntheorem and_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a \u2227 b) = False :=\n  Eq.symm h \u25b8 propext (false_and b)\n\ntheorem and_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a \u2227 b) = False :=\n  Eq.symm h \u25b8 propext (and_false a)\n\ntheorem and_eq_of_eq {a : Prop} {b : Prop} (h : a = b) : (a \u2227 b) = a :=\n  h \u25b8 propext (and_self a)\n\ntheorem or_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a \u2228 b) = True :=\n  Eq.symm h \u25b8 propext (true_or b)\n\ntheorem or_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a \u2228 b) = True :=\n  Eq.symm h \u25b8 propext (or_true a)\n\ntheorem or_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a \u2228 b) = b :=\n  Eq.symm h \u25b8 propext (false_or b)\n\ntheorem or_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a \u2228 b) = a :=\n  Eq.symm h \u25b8 propext (or_false a)\n\ntheorem or_eq_of_eq {a : Prop} {b : Prop} (h : a = b) : (a \u2228 b) = a :=\n  h \u25b8 propext (or_self a)\n\ntheorem imp_eq_of_eq_true_left {a : Prop} {b : Prop} (h : a = True) : (a \u2192 b) = b :=\n  Eq.symm h \u25b8 propext { mp := fun (h : True \u2192 b) => h trivial, mpr := fun (h\u2081 : b) (h\u2082 : True) => h\u2081 }\n\ntheorem imp_eq_of_eq_true_right {a : Prop} {b : Prop} (h : b = True) : (a \u2192 b) = True :=\n  Eq.symm h \u25b8 propext { mp := fun (h : a \u2192 True) => trivial, mpr := fun (h\u2081 : True) (h\u2082 : a) => h\u2081 }\n\ntheorem imp_eq_of_eq_false_left {a : Prop} {b : Prop} (h : a = False) : (a \u2192 b) = True :=\n  Eq.symm h \u25b8 propext { mp := fun (h : False \u2192 b) => trivial, mpr := fun (h\u2081 : True) (h\u2082 : False) => false.elim h\u2082 }\n\ntheorem imp_eq_of_eq_false_right {a : Prop} {b : Prop} (h : b = False) : (a \u2192 b) = (\u00aca) :=\n  Eq.symm h \u25b8 propext { mp := fun (h : a \u2192 False) => h, mpr := fun (hna : \u00aca) (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) : (\u00aca \u2192 b) = a := sorry\n\ntheorem imp_eq_true_of_eq {a : Prop} {b : Prop} (h : a = b) : (a \u2192 b) = True :=\n  h \u25b8 propext { mp := fun (h : a \u2192 a) => trivial, mpr := fun (h : True) (ha : a) => ha }\n\ntheorem not_eq_of_eq_true {a : Prop} (h : a = True) : (\u00aca) = False :=\n  Eq.symm h \u25b8 propext not_true_iff\n\ntheorem not_eq_of_eq_false {a : Prop} (h : a = False) : (\u00aca) = True :=\n  Eq.symm h \u25b8 propext not_false_iff\n\ntheorem false_of_a_eq_not_a {a : Prop} (h : a = (\u00aca)) : False :=\n  (fun (this : \u00aca) => 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] {\u03b1 : Sort u} (t : \u03b1) (e : \u03b1) (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] {\u03b1 : Sort u} (t : \u03b1) (e : \u03b1) (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] {\u03b1 : Sort u} {t : \u03b1} {e : \u03b1} (h : t = e) : ite c t e = t := sorry\n\ntheorem eq_true_of_and_eq_true_left {a : Prop} {b : Prop} (h : (a \u2227 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 \u2227 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 \u2228 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 \u2228 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 : (\u00aca) = 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 : (\u00aca) = False) : a = True :=\n  eq_true_intro (classical.by_contradiction fun (hna : \u00aca) => eq.mp h hna)\n\ntheorem ne_of_eq_of_ne {\u03b1 : Sort u} {a : \u03b1} {b : \u03b1} {c : \u03b1} (h\u2081 : a = b) (h\u2082 : b \u2260 c) : a \u2260 c :=\n  Eq.symm h\u2081 \u25b8 h\u2082\n\ntheorem ne_of_ne_of_eq {\u03b1 : Sort u} {a : \u03b1} {b : \u03b1} {c : \u03b1} (h\u2081 : a \u2260 b) (h\u2082 : b = c) : a \u2260 c :=\n  h\u2082 \u25b8 h\u2081\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 `\u2115 \u2192 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 := \u2115 \u2192 a.\n\nvariable {a : Type u}.\n\n/-- s\u2081 ==n== s\u2082 says that streams s\u2081 and s\u2082 are equal up to (and including) time\n`n`. -/\ndef agree_upto (n: \u2115) (s\u2081 s\u2082: stream a) := \u2200 t \u2264 n, s\u2081 t = s\u2082 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 \u2264 s2 = (\u2200 t, s1 t \u2264 s2 t) := rfl.\n\ninstance stream_zero [has_zero a] : has_zero (stream a) := \u27e8\u03bb (_: \u2115), 0\u27e9.\n\n@[refl]\nlemma agree_refl (n: \u2115) : \u2200 (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: \u2115) : \u2200 (s1 s2: stream a), s1 ==n== s2 \u2192 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: \u2115} : \u2200 (s1 s2 s3: stream a), s1 ==n== s2 \u2192 s2 ==n== s3 \u2192 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: \u2115) : is_refl (stream a) (agree_upto n) := \u27e8agree_refl n\u27e9.\ninstance agree_upto_symm (n: \u2115) : is_symm (stream a) (agree_upto n) := \u27e8agree_symm n\u27e9.\ninstance agree_upto_trans (n: \u2115) : is_trans (stream a) (agree_upto n) := \u27e8agree_trans\u27e9.\ninstance agree_upto_preorder (n: \u2115) : is_preorder (stream a) (agree_upto n) := \u27e8\u27e9.\ninstance agree_upto_equiv (n: \u2115) : is_equiv (stream a) (agree_upto n) := \u27e8\u27e9.\n\ntheorem agree_everywhere_eq (s s': stream a) :\n  s = s' \u2194 (\u2200 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': \u2115) :\n  s ==n== s' \u2192\n  n' \u2264 n \u2192\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: \u2115) :\n  s ==n.succ== s' \u2192\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' \u2194 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' \u2192 s n.succ = s' n.succ \u2192 s ==n.succ== s' :=\nbegin\n  intros hagree heq,\n  intros i hle,\n  have h: (i \u2264 n \u2228 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: \u2115) : stream a :=\n  \u03bb 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: \u2115) :\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: \u2115) :\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: \u2115) :\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: \u2115) :\n  s1 ==n== s2 \u2194 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: \u2115) :\n  cut s1 t = cut s2 t \u2192\n  s1 t = s2 t \u2192\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: \u2115) :\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 data.set.lattice\nimport tidy.tidy\n\nexample (X : Type) (R : Type) (D : R \u2192 set X) (\u03b3 : Type) (f : \u03b3 \u2192 R) :\n  \u22c3\u2080(D '' set.range f) = \u22c3 (i : \u03b3), D (f i) := by tidy", "meta": {"author": "semorrison", "repo": "lean-tidy", "sha": "6c1d46de6cff05e1c2c4c9692af812bca3e13b6c", "save_path": "github-repos/lean/semorrison-lean-tidy", "path": "github-repos/lean/semorrison-lean-tidy/lean-tidy-6c1d46de6cff05e1c2c4c9692af812bca3e13b6c/examples/20180426-kbuzzard.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8418256472515684, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4957419736680437}}
{"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 \u2260 0)\n(h2not2tors : neg_of_double_of_affine_plane_point.C E (E.double_of_affine_plane_point P) \u2260 0)\n(hx31 : (E.add_of_affine_plane_point (E.double_of_affine_plane_point P) P).x - P.x \u2260 0)\n(hx21 : (E.double_of_affine_plane_point P).x - P.x \u2260 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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\u2081 u\u2082 v\u2081 v\u2082 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, \u03a0, \u03a3, set, and subtype types\n * proof composition and identity laws\n * implement method to derive relators from datatype\n-/\n\ndef lift_fun {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03b3 : Sort v\u2081} {\u03b4 : Sort v\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) (S : \u03b3 \u2192 \u03b4 \u2192 Prop) (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) :=\n  \u2200 {a : \u03b1} {b : \u03b2}, R a b \u2192 S (f a) (g b)\n\ninfixr:40 \" \u21d2 \" => Mathlib.relator.lift_fun\n\ndef right_total {\u03b1 : Type u\u2081} {\u03b2 : outParam (Type u\u2082)} (R : outParam (\u03b1 \u2192 \u03b2 \u2192 Prop)) :=\n  \u2200 (b : \u03b2), \u2203 (a : \u03b1), R a b\n\ndef left_total {\u03b1 : Type u\u2081} {\u03b2 : outParam (Type u\u2082)} (R : outParam (\u03b1 \u2192 \u03b2 \u2192 Prop)) :=\n  \u2200 (a : \u03b1), \u2203 (b : \u03b2), R a b\n\ndef bi_total {\u03b1 : Type u\u2081} {\u03b2 : outParam (Type u\u2082)} (R : outParam (\u03b1 \u2192 \u03b2 \u2192 Prop)) :=\n  left_total R \u2227 right_total R\n\ndef left_unique {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 {a : \u03b1} {b : \u03b2} {c : \u03b1}, R a b \u2192 R c b \u2192 a = c\n\ndef right_unique {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 {a : \u03b1} {b c : \u03b2}, R a b \u2192 R a c \u2192 b = c\n\ntheorem rel_forall_of_right_total {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) [t : right_total R] : lift_fun (R \u21d2 implies) implies (fun (p : \u03b1 \u2192 Prop) => \u2200 (i : \u03b1), p i) fun (q : \u03b2 \u2192 Prop) => \u2200 (i : \u03b2), q i :=\n  fun (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) (Hrel : lift_fun R implies p q) (H : \u2200 (i : \u03b1), p i) (b : \u03b2) =>\n    exists.elim (t b) fun (a : \u03b1) (Rab : R a b) => Hrel Rab (H a)\n\ntheorem rel_exists_of_left_total {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) [t : left_total R] : lift_fun (R \u21d2 implies) implies (fun (p : \u03b1 \u2192 Prop) => \u2203 (i : \u03b1), p i) fun (q : \u03b2 \u2192 Prop) => \u2203 (i : \u03b2), q i := sorry\n\ntheorem rel_forall_of_total {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) [t : bi_total R] : lift_fun (R \u21d2 Iff) Iff (fun (p : \u03b1 \u2192 Prop) => \u2200 (i : \u03b1), p i) fun (q : \u03b2 \u2192 Prop) => \u2200 (i : \u03b2), q i := sorry\n\ntheorem rel_exists_of_total {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) [t : bi_total R] : lift_fun (R \u21d2 Iff) Iff (fun (p : \u03b1 \u2192 Prop) => \u2203 (i : \u03b1), p i) fun (q : \u03b2 \u2192 Prop) => \u2203 (i : \u03b2), q i := sorry\n\ntheorem left_unique_of_rel_eq {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) {eq' : \u03b2 \u2192 \u03b2 \u2192 Prop} (he : lift_fun R (R \u21d2 Iff) Eq eq') : left_unique R :=\n  fun {a : \u03b1} {b : \u03b2} {c : \u03b1} (\u1fb0 : R a b) (\u1fb0_1 : R c b) =>\n    idRhs (a = c) ((fun (this : eq' b b) => iff.mpr (he \u1fb0 \u1fb0_1) this) (iff.mp (he \u1fb0 \u1fb0) rfl))\n\ntheorem rel_imp : lift_fun Iff (Iff \u21d2 Iff) implies implies :=\n  fun (p q : Prop) (h : p \u2194 q) (r s : Prop) (l : r \u2194 s) => imp_congr h l\n\ntheorem rel_not : lift_fun Iff Iff Not Not :=\n  fun (p q : Prop) (h : p \u2194 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 {\u03b1 : Type u\u2081} : bi_total Eq :=\n  { left := fun (a : \u03b1) => Exists.intro a rfl, right := fun (a : \u03b1) => Exists.intro a rfl }\n\ndef bi_unique {\u03b1 : Type u_1} {\u03b2 : Type u_2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) :=\n  left_unique r \u2227 right_unique r\n\ntheorem left_unique_flip {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (h : left_unique r) : right_unique (flip r) :=\n  fun {a : \u03b2} {b c : \u03b1} (\u1fb0 : flip r a b) (\u1fb0_1 : flip r a c) => idRhs (b = c) (h \u1fb0 \u1fb0_1)\n\ntheorem rel_and : lift_fun Iff (Iff \u21d2 Iff) And And :=\n  fun (a b : Prop) (h\u2081 : a \u2194 b) (c d : Prop) (h\u2082 : c \u2194 d) => and_congr h\u2081 h\u2082\n\ntheorem rel_or : lift_fun Iff (Iff \u21d2 Iff) Or Or :=\n  fun (a b : Prop) (h\u2081 : a \u2194 b) (c d : Prop) (h\u2082 : c \u2194 d) => or_congr h\u2081 h\u2082\n\ntheorem rel_iff : lift_fun Iff (Iff \u21d2 Iff) Iff Iff :=\n  fun (a b : Prop) (h\u2081 : a \u2194 b) (c d : Prop) (h\u2082 : c \u2194 d) => iff_congr h\u2081 h\u2082\n\ntheorem rel_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (hr : bi_unique r) : lift_fun r (r \u21d2 Iff) Eq Eq :=\n  fun (a : \u03b1) (b : \u03b2) (h\u2081 : r a b) (c : \u03b1) (d : \u03b2) (h\u2082 : r c d) =>\n    { mp := fun (h : a = c) => Eq._oldrec (fun (h\u2082 : r a d) => and.right hr a b d h\u2081 h\u2082) h h\u2082,\n      mpr := fun (h : b = d) => Eq._oldrec (fun (h\u2082 : r c b) => and.left hr a b c h\u2081 h\u2082) h h\u2082 }\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] {\u03c3 : Type u_2} (I : ideal (mv_polynomial \u03c3 k)) : set (\u03c3 \u2192 k) :=\n  set_of fun (x : \u03c3 \u2192 k) => \u2200 (p : mv_polynomial \u03c3 k), p \u2208 I \u2192 coe_fn (eval x) p = 0\n\n@[simp] theorem mem_zero_locus_iff {k : Type u_1} [field k] {\u03c3 : Type u_2} {I : ideal (mv_polynomial \u03c3 k)} {x : \u03c3 \u2192 k} : x \u2208 zero_locus I \u2194 \u2200 (p : mv_polynomial \u03c3 k), p \u2208 I \u2192 coe_fn (eval x) p = 0 :=\n  iff.rfl\n\ntheorem zero_locus_anti_mono {k : Type u_1} [field k] {\u03c3 : Type u_2} {I : ideal (mv_polynomial \u03c3 k)} {J : ideal (mv_polynomial \u03c3 k)} (h : I \u2264 J) : zero_locus J \u2264 zero_locus I :=\n  fun (x : \u03c3 \u2192 k) (hx : x \u2208 zero_locus J) (p : mv_polynomial \u03c3 k) (hp : p \u2208 I) => hx p (h hp)\n\ntheorem zero_locus_bot {k : Type u_1} [field k] {\u03c3 : Type u_2} : zero_locus \u22a5 = \u22a4 :=\n  iff.mpr eq_top_iff\n    fun (x : \u03c3 \u2192 k) (hx : x \u2208 \u22a4) (p : mv_polynomial \u03c3 k) (hp : p \u2208 \u22a5) =>\n      trans (congr_arg (\u21d1(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] {\u03c3 : Type u_2} : zero_locus \u22a4 = \u22a5 :=\n  iff.mpr eq_bot_iff\n    fun (x : \u03c3 \u2192 k) (hx : x \u2208 zero_locus \u22a4) => one_ne_zero (ring_hom.map_one (eval x) \u25b8 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] {\u03c3 : Type u_2} (V : set (\u03c3 \u2192 k)) : ideal (mv_polynomial \u03c3 k) :=\n  submodule.mk (set_of fun (p : mv_polynomial \u03c3 k) => \u2200 (x : \u03c3 \u2192 k), x \u2208 V \u2192 coe_fn (eval x) p = 0) sorry sorry sorry\n\n@[simp] theorem mem_vanishing_ideal_iff {k : Type u_1} [field k] {\u03c3 : Type u_2} {V : set (\u03c3 \u2192 k)} {p : mv_polynomial \u03c3 k} : p \u2208 vanishing_ideal V \u2194 \u2200 (x : \u03c3 \u2192 k), x \u2208 V \u2192 coe_fn (eval x) p = 0 :=\n  iff.rfl\n\ntheorem vanishing_ideal_anti_mono {k : Type u_1} [field k] {\u03c3 : Type u_2} {A : set (\u03c3 \u2192 k)} {B : set (\u03c3 \u2192 k)} (h : A \u2264 B) : vanishing_ideal B \u2264 vanishing_ideal A :=\n  fun (p : mv_polynomial \u03c3 k) (hp : p \u2208 vanishing_ideal B) (x : \u03c3 \u2192 k) (hx : x \u2208 A) => hp x (h hx)\n\ntheorem vanishing_ideal_empty {k : Type u_1} [field k] {\u03c3 : Type u_2} : vanishing_ideal \u2205 = \u22a4 :=\n  le_antisymm le_top fun (p : mv_polynomial \u03c3 k) (hp : p \u2208 \u22a4) (x : \u03c3 \u2192 k) (hx : x \u2208 \u2205) => absurd hx (set.not_mem_empty x)\n\ntheorem le_vanishing_ideal_zero_locus {k : Type u_1} [field k] {\u03c3 : Type u_2} (I : ideal (mv_polynomial \u03c3 k)) : I \u2264 vanishing_ideal (zero_locus I) :=\n  fun (p : mv_polynomial \u03c3 k) (hp : p \u2208 I) (x : \u03c3 \u2192 k) (hx : x \u2208 zero_locus I) => hx p hp\n\ntheorem zero_locus_vanishing_ideal_le {k : Type u_1} [field k] {\u03c3 : Type u_2} (V : set (\u03c3 \u2192 k)) : V \u2264 zero_locus (vanishing_ideal V) :=\n  fun (V_1 : \u03c3 \u2192 k) (hV : V_1 \u2208 V) (p : mv_polynomial \u03c3 k) (hp : p \u2208 vanishing_ideal V) => hp V_1 hV\n\ntheorem zero_locus_vanishing_ideal_galois_connection {k : Type u_1} [field k] {\u03c3 : Type u_2} : galois_connection zero_locus vanishing_ideal :=\n  fun (I : ideal (mv_polynomial \u03c3 k)) (V : order_dual (set (\u03c3 \u2192 k))) =>\n    { mp := fun (h : zero_locus I \u2264 V) => le_trans (le_vanishing_ideal_zero_locus I) (vanishing_ideal_anti_mono h),\n      mpr := fun (h : I \u2264 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] {\u03c3 : Type u_2} (x : \u03c3 \u2192 k) (p : mv_polynomial \u03c3 k) : p \u2208 vanishing_ideal (singleton x) \u2194 coe_fn (eval x) p = 0 :=\n  { mp := fun (h : p \u2208 vanishing_ideal (singleton x)) => h x rfl,\n    mpr := fun (hpx : coe_fn (eval x) p = 0) (y : \u03c3 \u2192 k) (hy : y \u2208 singleton x) => Eq.symm hy \u25b8 hpx }\n\nprotected instance vanishing_ideal_singleton_is_maximal {k : Type u_1} [field k] {\u03c3 : Type u_2} {x : \u03c3 \u2192 k} : ideal.is_maximal (vanishing_ideal (singleton x)) := sorry\n\ntheorem radical_le_vanishing_ideal_zero_locus {k : Type u_1} [field k] {\u03c3 : Type u_2} (I : ideal (mv_polynomial \u03c3 k)) : ideal.radical I \u2264 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] {\u03c3 : Type u_2} (x : \u03c3 \u2192 k) : prime_spectrum (mv_polynomial \u03c3 k) :=\n  { val := vanishing_ideal (singleton x), property := sorry }\n\n@[simp] theorem vanishing_ideal_point_to_point {k : Type u_1} [field k] {\u03c3 : Type u_2} (V : set (\u03c3 \u2192 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] {\u03c3 : Type u_2} (I : ideal (mv_polynomial \u03c3 k)) : point_to_point '' zero_locus I \u2264 prime_spectrum.zero_locus \u2191I := sorry\n\ntheorem is_maximal_iff_eq_vanishing_ideal_singleton {k : Type u_1} [field k] {\u03c3 : Type u_2} [is_alg_closed k] [fintype \u03c3] (I : ideal (mv_polynomial \u03c3 k)) : ideal.is_maximal I \u2194 \u2203 (x : \u03c3 \u2192 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] {\u03c3 : Type u_2} [is_alg_closed k] [fintype \u03c3] (I : ideal (mv_polynomial \u03c3 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] {\u03c3 : Type u_2} [is_alg_closed k] [fintype \u03c3] (P : ideal (mv_polynomial \u03c3 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 \u2192 cardinal\n\n@[instance] constant cardinal.has_coe_from_nat : has_coe \u2115 cardinal\n\n@[norm_cast] axiom coe_zero : ((0 : \u2115) : cardinal) = 0\n@[norm_cast] axiom coe_one : ((1 : \u2115) : cardinal) = 1\n@[norm_cast] axiom coe_add {a b : \u2115} : ((a + b : \u2115) : cardinal) = a + b\n@[norm_cast] lemma coe_bit0 {a : \u2115} : ((bit0 a : \u2115) : cardinal) = bit0 a := coe_add\n@[norm_cast] lemma coe_bit1 {a : \u2115} : ((bit1 a : \u2115) : cardinal) = bit1 a :=\nby unfold bit1; norm_cast\n@[norm_cast, priority 900] axiom coe_succ {n : \u2115} : (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\u00ebl 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 `\u03a3 i, \u03b1 i`.\n\n## Main declarations\n\n* `Finset.sigma`: Given a finset `s` in `\u03b9` and finsets `t i` in each `\u03b1 i`, `s.sigma t` is the\n  finset of the dependent sum `\u03a3 i, \u03b1 i`\n* `Finset.sigmaLift`: Lifts maps `\u03b1 i \u2192 \u03b2 i \u2192 Finset (\u03b3 i)` to a map\n  `\u03a3 i, \u03b1 i \u2192 \u03a3 i, \u03b2 i \u2192 Finset (\u03a3 i, \u03b3 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 {\u03b9 : Type _}\n\nnamespace Finset\n\nsection Sigma\n\nvariable {\u03b1 : \u03b9 \u2192 Type _} {\u03b2 : Type _} (s s\u2081 s\u2082 : Finset \u03b9) (t t\u2081 t\u2082 : \u2200 i, Finset (\u03b1 i))\n\n/-- `s.sigma t` is the finset of dependent pairs `\u27e8i, a\u27e9` such that `i \u2208 s` and `a \u2208 t i`. -/\nprotected def sigma : Finset (\u03a3i, \u03b1 i) :=\n  \u27e8_, s.nodup.sigma fun i => (t i).nodup\u27e9\n#align finset.sigma Finset.sigma\n\nvariable {s s\u2081 s\u2082 t t\u2081 t\u2082}\n\n@[simp]\ntheorem mem_sigma {a : \u03a3i, \u03b1 i} : a \u2208 s.sigma t \u2194 a.1 \u2208 s \u2227 a.2 \u2208 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 \u03b9) (t : \u2200 i, Finset (\u03b1 i)) :\n    (s.sigma t : Set (\u03a3i, \u03b1 i)) = (s : Set \u03b9).Sigma fun i => (t i : Set (\u03b1 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 \u2194 \u2203 i \u2208 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 = \u2205 \u2194 \u2200 i \u2208 s, t i = \u2205 := by\n  simp only [\u2190 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\u2081 \u2286 s\u2082) (ht : \u2200 i, t\u2081 i \u2286 t\u2082 i) : s\u2081.sigma t\u2081 \u2286 s\u2082.sigma t\u2082 :=\n  fun \u27e8i, _\u27e9 h =>\n  let \u27e8hi, ha\u27e9 := mem_sigma.1 h\n  mem_sigma.2 \u27e8hs hi, ht i ha\u27e9\n#align finset.sigma_mono Finset.sigma_mono\n\ntheorem pairwiseDisjoint_map_sigmaMk :\n    (s : Set \u03b9).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 _ \u27e8y, _, rfl\u27e9 \u27e8z, _, hz'\u27e9\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\u1d62_map_sigma_mk :\n    s.disjUnion\u1d62 (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\u1d62_map_sigma_mk\n\ntheorem sigma_eq_bunion\u1d62 [DecidableEq (\u03a3i, \u03b1 i)] (s : Finset \u03b9) (t : \u2200 i, Finset (\u03b1 i)) :\n    s.sigma t = s.bunion\u1d62 fun i => (t i).map <| Embedding.sigmaMk i := by\n  ext \u27e8x, y\u27e9\n  simp [and_left_comm]\n#align finset.sigma_eq_bUnion Finset.sigma_eq_bunion\u1d62\n\nvariable (s t) (f : (\u03a3i, \u03b1 i) \u2192 \u03b2)\n\ntheorem sup_sigma [SemilatticeSup \u03b2] [OrderBot \u03b2] :\n    (s.sigma t).sup f = s.sup fun i => (t i).sup fun b => f \u27e8i, b\u27e9 :=\n  by\n  simp only [le_antisymm_iff, Finset.sup_le_iff, mem_sigma, and_imp, Sigma.forall]\n  exact\n    \u27e8fun i a hi ha => (le_sup hi).trans' <| le_sup (f := fun a => f \u27e8i, a\u27e9) ha, fun i hi a ha =>\n      le_sup <| mem_sigma.2 \u27e8hi, ha\u27e9\u27e9\n#align finset.sup_sigma Finset.sup_sigma\n\ntheorem inf_sigma [SemilatticeInf \u03b2] [OrderTop \u03b2] :\n    (s.sigma t).inf f = s.inf fun i => (t i).inf fun b => f \u27e8i, b\u27e9 :=\n  @sup_sigma _ _ \u03b2\u1d52\u1d48 _ _ _ _ _\n#align finset.inf_sigma Finset.inf_sigma\n\nend Sigma\n\nsection SigmaLift\n\nvariable {\u03b1 \u03b2 \u03b3 : \u03b9 \u2192 Type _} [DecidableEq \u03b9]\n\n/-- Lifts maps `\u03b1 i \u2192 \u03b2 i \u2192 Finset (\u03b3 i)` to a map `\u03a3 i, \u03b1 i \u2192 \u03a3 i, \u03b2 i \u2192 Finset (\u03a3 i, \u03b3 i)`. -/\ndef sigmaLift (f : \u2200 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 Finset (\u03b3 i)) (a : Sigma \u03b1) (b : Sigma \u03b2) :\n    Finset (Sigma \u03b3) :=\n  dite (a.1 = b.1) (fun h => (f (h \u25b8 a.2) b.2).map <| Embedding.sigmaMk _) fun _ => \u2205\n#align finset.sigma_lift Finset.sigmaLift\n\ntheorem mem_sigmaLift (f : \u2200 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 Finset (\u03b3 i)) (a : Sigma \u03b1) (b : Sigma \u03b2)\n    (x : Sigma \u03b3) :\n    x \u2208 sigmaLift f a b \u2194 \u2203 (ha : a.1 = x.1)(hb : b.1 = x.1), x.2 \u2208 f (ha \u25b8 a.2) (hb \u25b8 b.2) :=\n  by\n  obtain \u27e8\u27e8i, a\u27e9, j, b\u27e9 := a, b\n  obtain rfl | h := Decidable.eq_or_ne i j\n  \u00b7 constructor\n    \u00b7 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 \u27e8rfl, rfl, hx\u27e9\n    \u00b7 rintro \u27e8\u27e8\u27e9, \u27e8\u27e9, hx\u27e9\n      rw [sigmaLift, dif_pos rfl, mem_map]\n      exact \u27e8_, hx, by simp [Sigma.ext_iff]\u27e9\n  \u00b7 rw [sigmaLift, dif_neg h]\n    refine' iff_of_false (not_mem_empty _) _\n    rintro \u27e8\u27e8\u27e9, \u27e8\u27e9, _\u27e9\n    exact h rfl\n#align finset.mem_sigma_lift Finset.mem_sigmaLift\n\ntheorem mk_mem_sigmaLift (f : \u2200 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 Finset (\u03b3 i)) (i : \u03b9) (a : \u03b1 i) (b : \u03b2 i)\n    (x : \u03b3 i) : (\u27e8i, x\u27e9 : Sigma \u03b3) \u2208 sigmaLift f \u27e8i, a\u27e9 \u27e8i, b\u27e9 \u2194 x \u2208 f a b :=\n  by\n  rw [sigmaLift, dif_pos rfl, mem_map]\n  refine' \u27e8_, fun hx => \u27e8_, hx, rfl\u27e9\u27e9\n  rintro \u27e8x, hx, _, rfl\u27e9\n  exact hx\n#align finset.mk_mem_sigma_lift Finset.mk_mem_sigmaLift\n\ntheorem not_mem_sigmaLift_of_ne_left (f : \u2200 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 Finset (\u03b3 i)) (a : Sigma \u03b1)\n    (b : Sigma \u03b2) (x : Sigma \u03b3) (h : a.1 \u2260 x.1) : x \u2209 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 : \u2200 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 Finset (\u03b3 i)) {a : Sigma \u03b1}\n    (b : Sigma \u03b2) {x : Sigma \u03b3} (h : b.1 \u2260 x.1) : x \u2209 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 : \u2200 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 Finset (\u03b3 i)} {a : \u03a3i, \u03b1 i} {b : \u03a3i, \u03b2 i}\n\ntheorem sigmaLift_nonempty :\n    (sigmaLift f a b).Nonempty \u2194 \u2203 h : a.1 = b.1, (f (h \u25b8 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 = \u2205 \u2194 \u2200 h : a.1 = b.1, f (h \u25b8 a.2) b.2 = \u2205 := 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 : \u2200 \u2983i\u2984 \u2983a : \u03b1 i\u2984 \u2983b : \u03b2 i\u2984, f a b \u2286 g a b) (a : \u03a3i, \u03b1 i) (b : \u03a3i, \u03b2 i) :\n    sigmaLift f a b \u2286 sigmaLift g a b := by\n  rintro x hx\n  rw [mem_sigmaLift] at hx\u22a2\n  obtain \u27e8ha, hb, hx\u27e9 := hx\n  exact \u27e8ha, hb, h hx\u27e9\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 \u25b8 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 \u2022 t`: Scalar multiplication, set of all `x \u2022 y` where `x \u2208 s` and `y \u2208 t`.\n* `s +\u1d65 t`: Scalar addition, set of all `x +\u1d65 y` where `x \u2208 s` and `y \u2208 t`.\n* `s -\u1d65 t`: Scalar subtraction, set of all `x -\u1d65 y` where `x \u2208 s` and `y \u2208 t`.\n* `a \u2022 s`: Scaling, set of all `a \u2022 x` where `x \u2208 s`.\n* `a +\u1d65 s`: Translation, set of all `a +\u1d65 x` where `x \u2208 s`.\n\nFor `\u03b1` a semigroup/monoid, `set \u03b1` 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 \u03b1 \u03b2 \u03b3 : Type*}\n\nnamespace set\n\nopen_locale pointwise\n\n/-! ### Translation/scaling of sets -/\n\nsection smul\n\n/-- The dilation of set `x \u2022 s` is defined as `{x \u2022 y | y \u2208 s}` in locale `pointwise`. -/\n@[to_additive \"The translation of set `x +\u1d65 s` is defined as `{x +\u1d65 y | y \u2208 s}` in\nlocale `pointwise`.\"]\nprotected def has_smul_set [has_smul \u03b1 \u03b2] : has_smul \u03b1 (set \u03b2) :=\n\u27e8\u03bb a, image (has_smul.smul a)\u27e9\n\n/-- The pointwise scalar multiplication of sets `s \u2022 t` is defined as `{x \u2022 y | x \u2208 s, y \u2208 t}` in\nlocale `pointwise`. -/\n@[to_additive \"The pointwise scalar addition of sets `s +\u1d65 t` is defined as\n`{x +\u1d65 y | x \u2208 s, y \u2208 t}` in locale `pointwise`.\"]\nprotected def has_smul [has_smul \u03b1 \u03b2] : has_smul (set \u03b1) (set \u03b2) :=\n\u27e8image2 has_smul.smul\u27e9\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 {\u03b9 : Sort*} {\u03ba : \u03b9 \u2192 Sort*} [has_smul \u03b1 \u03b2] {s s\u2081 s\u2082 : set \u03b1} {t t\u2081 t\u2082 u : set \u03b2} {a : \u03b1}\n  {b : \u03b2}\n\n@[simp, to_additive]\nlemma image2_smul : image2 has_smul.smul s t = s \u2022 t := rfl\n\n@[to_additive add_image_prod]\nlemma image_smul_prod : (\u03bb x : \u03b1 \u00d7 \u03b2, x.fst \u2022 x.snd) '' s \u00d7\u02e2 t = s \u2022 t := image_prod _\n\n@[to_additive]\nlemma mem_smul : b \u2208 s \u2022 t \u2194 \u2203 x y, x \u2208 s \u2227 y \u2208 t \u2227 x \u2022 y = b := iff.rfl\n\n@[to_additive] lemma smul_mem_smul : a \u2208 s \u2192 b \u2208 t \u2192 a \u2022 b \u2208 s \u2022 t := mem_image2_of_mem\n\n@[simp, to_additive] lemma empty_smul : (\u2205 : set \u03b1) \u2022 t = \u2205 := image2_empty_left\n@[simp, to_additive] lemma smul_empty : s \u2022 (\u2205 : set \u03b2) = \u2205 := image2_empty_right\n@[simp, to_additive] lemma smul_eq_empty : s \u2022 t = \u2205 \u2194 s = \u2205 \u2228 t = \u2205 := image2_eq_empty_iff\n@[simp, to_additive] lemma smul_nonempty : (s \u2022 t).nonempty \u2194 s.nonempty \u2227 t.nonempty :=\nimage2_nonempty_iff\n@[to_additive] lemma nonempty.smul : s.nonempty \u2192 t.nonempty \u2192 (s \u2022 t).nonempty := nonempty.image2\n@[to_additive] lemma nonempty.of_smul_left : (s \u2022 t).nonempty \u2192 s.nonempty :=\nnonempty.of_image2_left\n@[to_additive] lemma nonempty.of_smul_right : (s \u2022 t).nonempty \u2192 t.nonempty :=\nnonempty.of_image2_right\n@[simp, to_additive] lemma smul_singleton : s \u2022 {b} = (\u2022 b) '' s := image2_singleton_right\n@[simp, to_additive] lemma singleton_smul : ({a} : set \u03b1) \u2022 t = a \u2022 t := image2_singleton_left\n@[simp, to_additive] lemma singleton_smul_singleton : ({a} : set \u03b1) \u2022 ({b} : set \u03b2) = {a \u2022 b} :=\nimage2_singleton\n\n@[to_additive, mono] lemma smul_subset_smul : s\u2081 \u2286 s\u2082 \u2192 t\u2081 \u2286 t\u2082 \u2192 s\u2081 \u2022 t\u2081 \u2286 s\u2082 \u2022 t\u2082 := image2_subset\n@[to_additive] lemma smul_subset_smul_left : t\u2081 \u2286 t\u2082 \u2192 s \u2022 t\u2081 \u2286 s \u2022 t\u2082 := image2_subset_left\n@[to_additive] lemma smul_subset_smul_right : s\u2081 \u2286 s\u2082 \u2192 s\u2081 \u2022 t \u2286 s\u2082 \u2022 t := image2_subset_right\n@[to_additive] lemma smul_subset_iff : s \u2022 t \u2286 u \u2194 \u2200 (a \u2208 s) (b \u2208 t), a \u2022 b \u2208 u := image2_subset_iff\n\nattribute [mono] vadd_subset_vadd\n\n@[to_additive] lemma union_smul : (s\u2081 \u222a s\u2082) \u2022 t = s\u2081 \u2022 t \u222a s\u2082 \u2022 t := image2_union_left\n@[to_additive] lemma smul_union : s \u2022 (t\u2081 \u222a t\u2082) = s \u2022 t\u2081 \u222a s \u2022 t\u2082 := image2_union_right\n@[to_additive] lemma inter_smul_subset : (s\u2081 \u2229 s\u2082) \u2022 t \u2286 s\u2081 \u2022 t \u2229 s\u2082 \u2022 t := image2_inter_subset_left\n@[to_additive] lemma smul_inter_subset : s \u2022 (t\u2081 \u2229 t\u2082) \u2286 s \u2022 t\u2081 \u2229 s \u2022 t\u2082 :=\nimage2_inter_subset_right\n@[to_additive] lemma inter_smul_union_subset_union :\n  (s\u2081 \u2229 s\u2082) \u2022 (t\u2081 \u222a t\u2082) \u2286 (s\u2081 \u2022 t\u2081) \u222a (s\u2082 \u2022 t\u2082) :=\nimage2_inter_union_subset_union\n@[to_additive] lemma union_smul_inter_subset_union :\n  (s\u2081 \u222a s\u2082) \u2022 (t\u2081 \u2229 t\u2082) \u2286 (s\u2081 \u2022 t\u2081) \u222a (s\u2082 \u2022 t\u2082) :=\nimage2_union_inter_subset_union\n\n@[to_additive] lemma Union_smul_left_image : (\u22c3 a \u2208 s, a \u2022 t) = s \u2022 t := Union_image_left _\n@[to_additive] lemma Union_smul_right_image : (\u22c3 a \u2208 t, (\u2022 a) '' s) = s \u2022 t := Union_image_right _\n\n@[to_additive] lemma Union_smul (s : \u03b9 \u2192 set \u03b1) (t : set \u03b2) : (\u22c3 i, s i) \u2022 t = \u22c3 i, s i \u2022 t :=\nimage2_Union_left _ _ _\n@[to_additive] lemma smul_Union (s : set \u03b1) (t : \u03b9 \u2192 set \u03b2) : s \u2022 (\u22c3 i, t i) = \u22c3 i, s \u2022 t i :=\nimage2_Union_right _ _ _\n\n@[to_additive]\nlemma Union\u2082_smul (s : \u03a0 i, \u03ba i \u2192 set \u03b1) (t : set \u03b2) : (\u22c3 i j, s i j) \u2022 t = \u22c3 i j, s i j \u2022 t :=\nimage2_Union\u2082_left _ _ _\n\n@[to_additive]\n\n\n@[to_additive]\nlemma Inter_smul_subset (s : \u03b9 \u2192 set \u03b1) (t : set \u03b2) : (\u22c2 i, s i) \u2022 t \u2286 \u22c2 i, s i \u2022 t :=\nimage2_Inter_subset_left _ _ _\n\n@[to_additive]\nlemma smul_Inter_subset (s : set \u03b1) (t : \u03b9 \u2192 set \u03b2) : s \u2022 (\u22c2 i, t i) \u2286 \u22c2 i, s \u2022 t i :=\nimage2_Inter_subset_right _ _ _\n\n@[to_additive]\nlemma Inter\u2082_smul_subset (s : \u03a0 i, \u03ba i \u2192 set \u03b1) (t : set \u03b2) :\n  (\u22c2 i j, s i j) \u2022 t \u2286 \u22c2 i j, s i j \u2022 t :=\nimage2_Inter\u2082_subset_left _ _ _\n\n@[to_additive]\nlemma smul_Inter\u2082_subset (s : set \u03b1) (t : \u03a0 i, \u03ba i \u2192 set \u03b2) :\n  s \u2022 (\u22c2 i j, t i j) \u2286 \u22c2 i j, s \u2022 t i j :=\nimage2_Inter\u2082_subset_right _ _ _\n\n@[to_additive] lemma smul_set_subset_smul {s : set \u03b1} : a \u2208 s \u2192 a \u2022 t \u2286 s \u2022 t :=\nimage_subset_image2_right\n\n@[simp, to_additive] lemma bUnion_smul_set (s : set \u03b1) (t : set \u03b2) :\n  (\u22c3 a \u2208 s, a \u2022 t) = s \u2022 t :=\nUnion_image_left _\n\nend has_smul\n\nsection has_smul_set\nvariables {\u03b9 : Sort*} {\u03ba : \u03b9 \u2192 Sort*} [has_smul \u03b1 \u03b2] {s t t\u2081 t\u2082 : set \u03b2} {a : \u03b1} {b : \u03b2} {x y : \u03b2}\n\n@[simp, to_additive] lemma image_smul : (\u03bb x, a \u2022 x) '' t = a \u2022 t := rfl\n\n@[to_additive] lemma mem_smul_set : x \u2208 a \u2022 t \u2194 \u2203 y, y \u2208 t \u2227 a \u2022 y = x := iff.rfl\n\n@[to_additive] lemma smul_mem_smul_set : b \u2208 s \u2192 a \u2022 b \u2208 a \u2022 s := mem_image_of_mem _\n\n@[simp, to_additive] lemma smul_set_empty : a \u2022 (\u2205 : set \u03b2) = \u2205 := image_empty _\n@[simp, to_additive] lemma smul_set_eq_empty : a \u2022 s = \u2205 \u2194 s = \u2205 := image_eq_empty\n@[simp, to_additive] lemma smul_set_nonempty : (a \u2022 s).nonempty \u2194 s.nonempty := nonempty_image_iff\n\n@[simp, to_additive] lemma smul_set_singleton : a \u2022 ({b} : set \u03b2) = {a \u2022 b} := image_singleton\n\n@[to_additive] lemma smul_set_mono : s \u2286 t \u2192 a \u2022 s \u2286 a \u2022 t := image_subset _\n@[to_additive] lemma smul_set_subset_iff : a \u2022 s \u2286 t \u2194 \u2200 \u2983b\u2984, b \u2208 s \u2192 a \u2022 b \u2208 t := image_subset_iff\n\n@[to_additive] lemma smul_set_union : a \u2022 (t\u2081 \u222a t\u2082) = a \u2022 t\u2081 \u222a a \u2022 t\u2082 := image_union _ _ _\n\n@[to_additive]\nlemma smul_set_inter_subset : a \u2022 (t\u2081 \u2229 t\u2082) \u2286 a \u2022 t\u2081 \u2229 (a \u2022 t\u2082) := image_inter_subset _ _ _\n\n@[to_additive]\nlemma smul_set_Union (a : \u03b1) (s : \u03b9 \u2192 set \u03b2) : a \u2022 (\u22c3 i, s i) = \u22c3 i, a \u2022 s i := image_Union\n\n@[to_additive]\nlemma smul_set_Union\u2082 (a : \u03b1) (s : \u03a0 i, \u03ba i \u2192 set \u03b2) : a \u2022 (\u22c3 i j, s i j) = \u22c3 i j, a \u2022 s i j :=\nimage_Union\u2082 _ _\n\n@[to_additive]\nlemma smul_set_Inter_subset (a : \u03b1) (t : \u03b9 \u2192 set \u03b2) : a \u2022 (\u22c2 i, t i) \u2286 \u22c2 i, a \u2022 t i :=\nimage_Inter_subset _ _\n\n@[to_additive]\nlemma smul_set_Inter\u2082_subset (a : \u03b1) (t : \u03a0 i, \u03ba i \u2192 set \u03b2) :\n  a \u2022 (\u22c2 i j, t i j) \u2286 \u22c2 i j, a \u2022 t i j :=\nimage_Inter\u2082_subset _ _\n\n@[to_additive] lemma nonempty.smul_set : s.nonempty \u2192 (a \u2022 s).nonempty := nonempty.image _\n\nend has_smul_set\n\nsection has_mul\nvariables [has_mul \u03b1] {s t u : set \u03b1} {a : \u03b1}\n\n@[to_additive] lemma op_smul_set_subset_mul : a \u2208 t \u2192 op a \u2022 s \u2286 s * t := image_subset_image2_left\n\n@[simp, to_additive] lemma bUnion_op_smul_set (s t : set \u03b1) : (\u22c3 a \u2208 t, op a \u2022 s) = s * t :=\nUnion_image_right _\n\n@[to_additive] lemma mul_subset_iff_left : s * t \u2286 u \u2194 \u2200 a \u2208 s, a \u2022 t \u2286 u := image2_subset_iff_left\n@[to_additive] lemma mul_subset_iff_right : s * t \u2286 u \u2194 \u2200 b \u2208 t, op b \u2022 s \u2286 u :=\nimage2_subset_iff_right\n\nend has_mul\n\nvariables {s s\u2081 s\u2082 : set \u03b1} {t t\u2081 t\u2082 : set \u03b2} {a : \u03b1} {b : \u03b2}\n\n@[to_additive]\ntheorem range_smul_range {\u03b9 \u03ba : Type*} [has_smul \u03b1 \u03b2] (b : \u03b9 \u2192 \u03b1) (c : \u03ba \u2192 \u03b2) :\n  range b \u2022 range c = range (\u03bb p : \u03b9 \u00d7 \u03ba, b p.1 \u2022 c p.2) :=\next $ \u03bb x, \u27e8\u03bb hx, let \u27e8p, q, \u27e8i, hi\u27e9, \u27e8j, hj\u27e9, hpq\u27e9 := set.mem_smul.1 hx in\n  \u27e8(i, j), hpq \u25b8 hi \u25b8 hj \u25b8 rfl\u27e9,\n\u03bb \u27e8\u27e8i, j\u27e9, h\u27e9, set.mem_smul.2 \u27e8b i, c j, \u27e8i, rfl\u27e9, \u27e8j, rfl\u27e9, h\u27e9\u27e9\n\n@[to_additive] lemma smul_set_range [has_smul \u03b1 \u03b2] {\u03b9 : Sort*} {f : \u03b9 \u2192 \u03b2} :\n  a \u2022 range f = range (\u03bb i, a \u2022 f i) := (range_comp _ _).symm\n\n@[to_additive]\ninstance smul_comm_class_set [has_smul \u03b1 \u03b3] [has_smul \u03b2 \u03b3] [smul_comm_class \u03b1 \u03b2 \u03b3] :\n  smul_comm_class \u03b1 \u03b2 (set \u03b3) :=\n\u27e8\u03bb _ _, commute.set_image $ smul_comm _ _\u27e9\n\n@[to_additive]\ninstance smul_comm_class_set' [has_smul \u03b1 \u03b3] [has_smul \u03b2 \u03b3] [smul_comm_class \u03b1 \u03b2 \u03b3] :\n  smul_comm_class \u03b1 (set \u03b2) (set \u03b3) :=\n\u27e8\u03bb _ _ _, image_image2_distrib_right $ smul_comm _\u27e9\n\n@[to_additive]\ninstance smul_comm_class_set'' [has_smul \u03b1 \u03b3] [has_smul \u03b2 \u03b3] [smul_comm_class \u03b1 \u03b2 \u03b3] :\n  smul_comm_class (set \u03b1) \u03b2 (set \u03b3) :=\nby haveI := smul_comm_class.symm \u03b1 \u03b2 \u03b3; exact smul_comm_class.symm _ _ _\n\n@[to_additive]\ninstance smul_comm_class [has_smul \u03b1 \u03b3] [has_smul \u03b2 \u03b3] [smul_comm_class \u03b1 \u03b2 \u03b3] :\n  smul_comm_class (set \u03b1) (set \u03b2) (set \u03b3) :=\n\u27e8\u03bb _ _ _, image2_left_comm smul_comm\u27e9\n\n@[to_additive]\ninstance is_scalar_tower [has_smul \u03b1 \u03b2] [has_smul \u03b1 \u03b3] [has_smul \u03b2 \u03b3] [is_scalar_tower \u03b1 \u03b2 \u03b3] :\n  is_scalar_tower \u03b1 \u03b2 (set \u03b3) :=\n{ smul_assoc := \u03bb a b T, by simp only [\u2190image_smul, image_image, smul_assoc] }\n\n@[to_additive]\ninstance is_scalar_tower' [has_smul \u03b1 \u03b2] [has_smul \u03b1 \u03b3] [has_smul \u03b2 \u03b3] [is_scalar_tower \u03b1 \u03b2 \u03b3] :\n  is_scalar_tower \u03b1 (set \u03b2) (set \u03b3) :=\n\u27e8\u03bb _ _ _, image2_image_left_comm $ smul_assoc _\u27e9\n\n@[to_additive]\ninstance is_scalar_tower'' [has_smul \u03b1 \u03b2] [has_smul \u03b1 \u03b3] [has_smul \u03b2 \u03b3] [is_scalar_tower \u03b1 \u03b2 \u03b3] :\n  is_scalar_tower (set \u03b1) (set \u03b2) (set \u03b3) :=\n{ smul_assoc := \u03bb T T' T'', image2_assoc smul_assoc }\n\n@[to_additive]\ninstance is_central_scalar [has_smul \u03b1 \u03b2] [has_smul \u03b1\u1d50\u1d52\u1d56 \u03b2] [is_central_scalar \u03b1 \u03b2] :\n  is_central_scalar \u03b1 (set \u03b2) :=\n\u27e8\u03bb a S, congr_arg (\u03bb f, f '' S) $ by exact funext (\u03bb _, op_smul_eq_smul _ _)\u27e9\n\n/-- A multiplicative action of a monoid `\u03b1` on a type `\u03b2` gives a multiplicative action of `set \u03b1`\non `set \u03b2`. -/\n@[to_additive \"An additive action of an additive monoid `\u03b1` on a type `\u03b2` gives an additive action\nof `set \u03b1` on `set \u03b2`\"]\nprotected def mul_action [monoid \u03b1] [mul_action \u03b1 \u03b2] : mul_action (set \u03b1) (set \u03b2) :=\n{ mul_smul := \u03bb _ _ _, image2_assoc mul_smul,\n  one_smul := \u03bb s, image2_singleton_left.trans $ by simp_rw [one_smul, image_id'] }\n\n/-- A multiplicative action of a monoid on a type `\u03b2` gives a multiplicative action on `set \u03b2`. -/\n@[to_additive \"An additive action of an additive monoid on a type `\u03b2` gives an additive action\non `set \u03b2`.\"]\nprotected def mul_action_set [monoid \u03b1] [mul_action \u03b1 \u03b2] : mul_action \u03b1 (set \u03b2) :=\n{ mul_smul := by { intros, simp only [\u2190 image_smul, image_image, \u2190 mul_smul] },\n  one_smul := by { intros, simp only [\u2190 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 `\u03b2` gives a distributive\nmultiplicative action on `set \u03b2`. -/\nprotected def distrib_mul_action_set [monoid \u03b1] [add_monoid \u03b2] [distrib_mul_action \u03b1 \u03b2] :\n  distrib_mul_action \u03b1 (set \u03b2) :=\n{ smul_add := \u03bb _ _ _, image_image2_distrib $ smul_add _,\n  smul_zero := \u03bb _, image_singleton.trans $ by rw [smul_zero, singleton_zero] }\n\n/-- A multiplicative action of a monoid on a monoid `\u03b2` gives a multiplicative action on `set \u03b2`. -/\nprotected def mul_distrib_mul_action_set [monoid \u03b1] [monoid \u03b2] [mul_distrib_mul_action \u03b1 \u03b2] :\n  mul_distrib_mul_action \u03b1 (set \u03b2) :=\n{ smul_mul := \u03bb _ _ _, image_image2_distrib $ smul_mul' _,\n  smul_one := \u03bb _, 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 \u03b1] [has_zero \u03b2] [has_smul \u03b1 \u03b2] [no_zero_smul_divisors \u03b1 \u03b2] :\n  no_zero_smul_divisors (set \u03b1) (set \u03b2) :=\n\u27e8\u03bb s t h, begin\n  by_contra' H,\n  have hst : (s \u2022 t).nonempty := h.symm.subst zero_nonempty,\n  simp_rw [\u2190hst.of_smul_left.subset_zero_iff, \u2190hst.of_smul_right.subset_zero_iff, not_subset,\n    mem_zero] at H,\n  obtain \u27e8\u27e8a, hs, ha\u27e9, b, ht, hb\u27e9 := H,\n  exact (eq_zero_or_eq_zero_of_smul_eq_zero $ h.subset $ smul_mem_smul hs ht).elim ha hb,\nend\u27e9\n\ninstance no_zero_smul_divisors_set [has_zero \u03b1] [has_zero \u03b2] [has_smul \u03b1 \u03b2]\n  [no_zero_smul_divisors \u03b1 \u03b2] : no_zero_smul_divisors \u03b1 (set \u03b2) :=\n\u27e8\u03bb a s h, begin\n  by_contra' H,\n  have hst : (a \u2022 s).nonempty := h.symm.subst zero_nonempty,\n  simp_rw [\u2190hst.of_image.subset_zero_iff, not_subset, mem_zero] at H,\n  obtain \u27e8ha, b, ht, hb\u27e9 := H,\n  exact (eq_zero_or_eq_zero_of_smul_eq_zero $ h.subset $ smul_mem_smul_set ht).elim ha hb,\nend\u27e9\n\ninstance [has_zero \u03b1] [has_mul \u03b1] [no_zero_divisors \u03b1] : no_zero_divisors (set \u03b1) :=\n\u27e8\u03bb s t h, eq_zero_or_eq_zero_of_smul_eq_zero h\u27e9\n\nend smul\n\nsection vsub\nvariables {\u03b9 : Sort*} {\u03ba : \u03b9 \u2192 Sort*} [has_vsub \u03b1 \u03b2] {s s\u2081 s\u2082 t t\u2081 t\u2082 : set \u03b2} {u : set \u03b1} {a : \u03b1}\n  {b c : \u03b2}\ninclude \u03b1\n\ninstance has_vsub : has_vsub (set \u03b1) (set \u03b2) := \u27e8image2 (-\u1d65)\u27e9\n\n@[simp] lemma image2_vsub : (image2 has_vsub.vsub s t : set \u03b1) = s -\u1d65 t := rfl\n\nlemma image_vsub_prod : (\u03bb x : \u03b2 \u00d7 \u03b2, x.fst -\u1d65 x.snd) '' s \u00d7\u02e2 t = s -\u1d65 t := image_prod _\n\nlemma mem_vsub : a \u2208 s -\u1d65 t \u2194 \u2203 x y, x \u2208 s \u2227 y \u2208 t \u2227 x -\u1d65 y = a := iff.rfl\n\nlemma vsub_mem_vsub (hb : b \u2208 s) (hc : c \u2208 t) : b -\u1d65 c \u2208 s -\u1d65 t := mem_image2_of_mem hb hc\n\n@[simp] lemma empty_vsub (t : set \u03b2) : \u2205 -\u1d65 t = \u2205 := image2_empty_left\n@[simp] lemma vsub_empty (s : set \u03b2) : s -\u1d65 \u2205 = \u2205 := image2_empty_right\n@[simp] lemma vsub_eq_empty : s -\u1d65 t = \u2205 \u2194 s = \u2205 \u2228 t = \u2205 := image2_eq_empty_iff\n@[simp] lemma vsub_nonempty : (s -\u1d65 t : set \u03b1).nonempty \u2194 s.nonempty \u2227 t.nonempty :=\nimage2_nonempty_iff\nlemma nonempty.vsub : s.nonempty \u2192 t.nonempty \u2192 (s -\u1d65 t : set \u03b1).nonempty := nonempty.image2\nlemma nonempty.of_vsub_left : (s -\u1d65 t :set \u03b1).nonempty \u2192 s.nonempty := nonempty.of_image2_left\nlemma nonempty.of_vsub_right : (s -\u1d65 t : set \u03b1).nonempty \u2192 t.nonempty := nonempty.of_image2_right\n@[simp] lemma vsub_singleton (s : set \u03b2) (b : \u03b2) : s -\u1d65 {b} = (-\u1d65 b) '' s := image2_singleton_right\n@[simp] lemma singleton_vsub (t : set \u03b2) (b : \u03b2) : {b} -\u1d65 t = ((-\u1d65) b) '' t := image2_singleton_left\n@[simp] lemma singleton_vsub_singleton : ({b} : set \u03b2) -\u1d65 {c} = {b -\u1d65 c} := image2_singleton\n\n@[mono] lemma vsub_subset_vsub : s\u2081 \u2286 s\u2082 \u2192 t\u2081 \u2286 t\u2082 \u2192 s\u2081 -\u1d65 t\u2081 \u2286 s\u2082 -\u1d65 t\u2082 := image2_subset\nlemma vsub_subset_vsub_left : t\u2081 \u2286 t\u2082 \u2192 s -\u1d65 t\u2081 \u2286 s -\u1d65 t\u2082 := image2_subset_left\nlemma vsub_subset_vsub_right : s\u2081 \u2286 s\u2082 \u2192 s\u2081 -\u1d65 t \u2286 s\u2082 -\u1d65 t := image2_subset_right\nlemma vsub_subset_iff : s -\u1d65 t \u2286 u \u2194 \u2200 (x \u2208 s) (y \u2208 t), x -\u1d65 y \u2208 u := image2_subset_iff\nlemma vsub_self_mono (h : s \u2286 t) : s -\u1d65 s \u2286 t -\u1d65 t := vsub_subset_vsub h h\n\nlemma union_vsub : (s\u2081 \u222a s\u2082) -\u1d65 t = s\u2081 -\u1d65 t \u222a (s\u2082 -\u1d65 t) := image2_union_left\nlemma vsub_union : s -\u1d65 (t\u2081 \u222a t\u2082) = s -\u1d65 t\u2081 \u222a (s -\u1d65 t\u2082) := image2_union_right\nlemma inter_vsub_subset : s\u2081 \u2229 s\u2082 -\u1d65 t \u2286 (s\u2081 -\u1d65 t) \u2229 (s\u2082 -\u1d65 t) := image2_inter_subset_left\nlemma vsub_inter_subset : s -\u1d65 t\u2081 \u2229 t\u2082 \u2286 (s -\u1d65 t\u2081) \u2229 (s -\u1d65 t\u2082) := image2_inter_subset_right\nlemma inter_vsub_union_subset_union : (s\u2081 \u2229 s\u2082) -\u1d65 (t\u2081 \u222a t\u2082) \u2286 (s\u2081 -\u1d65 t\u2081) \u222a (s\u2082 -\u1d65 t\u2082) :=\nimage2_inter_union_subset_union\nlemma union_vsub_inter_subset_union : (s\u2081 \u222a s\u2082) -\u1d65 (t\u2081 \u2229 t\u2082) \u2286 (s\u2081 -\u1d65 t\u2081) \u222a (s\u2082 -\u1d65 t\u2082) :=\nimage2_union_inter_subset_union\n\nlemma Union_vsub_left_image : (\u22c3 a \u2208 s, ((-\u1d65) a) '' t) = s -\u1d65 t := Union_image_left _\nlemma Union_vsub_right_image : (\u22c3 a \u2208 t, (-\u1d65 a) '' s) = s -\u1d65 t := Union_image_right _\n\nlemma Union_vsub (s : \u03b9 \u2192 set \u03b2) (t : set \u03b2) : (\u22c3 i, s i) -\u1d65 t = \u22c3 i, s i -\u1d65 t :=\nimage2_Union_left _ _ _\nlemma vsub_Union (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : s -\u1d65 (\u22c3 i, t i) = \u22c3 i, s -\u1d65 t i :=\nimage2_Union_right _ _ _\n\nlemma Union\u2082_vsub (s : \u03a0 i, \u03ba i \u2192 set \u03b2) (t : set \u03b2) : (\u22c3 i j, s i j) -\u1d65 t = \u22c3 i j, s i j -\u1d65 t :=\nimage2_Union\u2082_left _ _ _\n\nlemma vsub_Union\u2082 (s : set \u03b2) (t : \u03a0 i, \u03ba i \u2192 set \u03b2) : s -\u1d65 (\u22c3 i j, t i j) = \u22c3 i j, s -\u1d65 t i j :=\nimage2_Union\u2082_right _ _ _\n\nlemma Inter_vsub_subset (s : \u03b9 \u2192 set \u03b2) (t : set \u03b2) : (\u22c2 i, s i) -\u1d65 t \u2286 \u22c2 i, s i -\u1d65 t :=\nimage2_Inter_subset_left _ _ _\n\nlemma vsub_Inter_subset (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : s -\u1d65 (\u22c2 i, t i) \u2286 \u22c2 i, s -\u1d65 t i :=\nimage2_Inter_subset_right _ _ _\n\nlemma Inter\u2082_vsub_subset (s : \u03a0 i, \u03ba i \u2192 set \u03b2) (t : set \u03b2) :\n  (\u22c2 i j, s i j) -\u1d65 t \u2286 \u22c2 i j, s i j -\u1d65 t :=\nimage2_Inter\u2082_subset_left _ _ _\n\nlemma vsub_Inter\u2082_subset (s : set \u03b2) (t : \u03a0 i, \u03ba i \u2192 set \u03b2) :\n  s -\u1d65 (\u22c2 i j, t i j) \u2286 \u22c2 i j, s -\u1d65 t i j :=\nimage2_Inter\u2082_subset_right _ _ _\n\n\nend vsub\n\nopen_locale pointwise\n\n@[to_additive] lemma image_smul_comm [has_smul \u03b1 \u03b2] [has_smul \u03b1 \u03b3] (f : \u03b2 \u2192 \u03b3) (a : \u03b1) (s : set \u03b2) :\n  (\u2200 b, f (a \u2022 b) = a \u2022 f b) \u2192 f '' (a \u2022 s) = a \u2022 f '' s :=\nimage_comm\n\n@[to_additive] lemma image_smul_distrib [mul_one_class \u03b1] [mul_one_class \u03b2] [monoid_hom_class F \u03b1 \u03b2]\n  (f : F) (a : \u03b1) (s : set \u03b1) :\n  f '' (a \u2022 s) = f a \u2022 f '' s :=\nimage_comm $ map_mul _ _\n\nsection has_smul\nvariables[has_smul \u03b1\u1d50\u1d52\u1d56 \u03b2] [has_smul \u03b2 \u03b3] [has_smul \u03b1 \u03b3]\n\n-- TODO: replace hypothesis and conclusion with a typeclass\n@[to_additive] lemma op_smul_set_smul_eq_smul_smul_set (a : \u03b1) (s : set \u03b2) (t : set \u03b3)\n  (h : \u2200 (a : \u03b1) (b : \u03b2) (c : \u03b3), (op a \u2022 b) \u2022 c = b \u2022 a \u2022 c) :\n  (op a \u2022 s) \u2022 t = s \u2022 a \u2022 t :=\nby { ext, simp [mem_smul, mem_smul_set, h] }\n\nend has_smul\n\nsection smul_with_zero\nvariables [has_zero \u03b1] [has_zero \u03b2] [smul_with_zero \u03b1 \u03b2] {s : set \u03b1} {t : set \u03b2}\n\n/-!\nNote that we have neither `smul_with_zero \u03b1 (set \u03b2)` nor `smul_with_zero (set \u03b1) (set \u03b2)`\nbecause `0 * \u2205 \u2260 0`.\n-/\n\nlemma smul_zero_subset (s : set \u03b1) : s \u2022 (0 : set \u03b2) \u2286 0 := by simp [subset_def, mem_smul]\nlemma zero_smul_subset (t : set \u03b2) : (0 : set \u03b1) \u2022 t \u2286 0 := by simp [subset_def, mem_smul]\n\nlemma nonempty.smul_zero (hs : s.nonempty) : s \u2022 (0 : set \u03b2) = 0 :=\ns.smul_zero_subset.antisymm $ by simpa [mem_smul] using hs\n\nlemma nonempty.zero_smul (ht : t.nonempty) : (0 : set \u03b1) \u2022 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 \u03b2} (h : s.nonempty) : (0 : \u03b1) \u2022 s = (0 : set \u03b2) :=\nby simp only [\u2190 image_smul, image_eta, zero_smul, h.image_const, singleton_zero]\n\nlemma zero_smul_set_subset (s : set \u03b2) : (0 : \u03b1) \u2022 s \u2286 0 :=\nimage_subset_iff.2 $ \u03bb x _, zero_smul \u03b1 x\n\nlemma subsingleton_zero_smul_set (s : set \u03b2) : ((0 : \u03b1) \u2022 s).subsingleton :=\nsubsingleton_singleton.anti $ zero_smul_set_subset s\n\nlemma zero_mem_smul_set {t : set \u03b2} {a : \u03b1} (h : (0 : \u03b2) \u2208 t) : (0 : \u03b2) \u2208 a \u2022 t :=\n\u27e80, h, smul_zero _\u27e9\n\nvariables [no_zero_smul_divisors \u03b1 \u03b2] {a : \u03b1}\n\nlemma zero_mem_smul_iff : (0 : \u03b2) \u2208 s \u2022 t \u2194 (0 : \u03b1) \u2208 s \u2227 t.nonempty \u2228 (0 : \u03b2) \u2208 t \u2227 s.nonempty :=\nbegin\n  split,\n  { rintro \u27e8a, b, ha, hb, h\u27e9,\n    obtain rfl | rfl := eq_zero_or_eq_zero_of_smul_eq_zero h,\n    { exact or.inl \u27e8ha, b, hb\u27e9 },\n    { exact or.inr \u27e8hb, a, ha\u27e9 } },\n  { rintro (\u27e8hs, b, hb\u27e9 | \u27e8ht, a, ha\u27e9),\n    { exact \u27e80, b, hs, hb, zero_smul _ _\u27e9 },\n    { exact \u27e8a, 0, ha, ht, smul_zero _\u27e9 } }\nend\n\nlemma zero_mem_smul_set_iff (ha : a \u2260 0) : (0 : \u03b2) \u2208 a \u2022 t \u2194 (0 : \u03b2) \u2208 t :=\nbegin\n  refine \u27e8_, zero_mem_smul_set\u27e9,\n  rintro \u27e8b, hb, h\u27e9,\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 \u03b1]\n\n@[to_additive] lemma op_smul_set_mul_eq_mul_smul_set (a : \u03b1) (s : set \u03b1) (t : set \u03b1) :\n  (op a \u2022 s) * t = s * a \u2022 t :=\nop_smul_set_smul_eq_smul_smul_set _ _ _ $ \u03bb _ _ _, mul_assoc _ _ _\n\nend semigroup\n\nsection left_cancel_semigroup\nvariables [left_cancel_semigroup \u03b1] {s t : set \u03b1}\n\n@[to_additive] lemma pairwise_disjoint_smul_iff :\n  s.pairwise_disjoint (\u2022 t) \u2194 (s \u00d7\u02e2 t).inj_on (\u03bb p, p.1 * p.2) :=\npairwise_disjoint_image_right_iff $ \u03bb _ _, mul_right_injective _\n\nend left_cancel_semigroup\n\nsection group\nvariables [group \u03b1] [mul_action \u03b1 \u03b2] {s t A B : set \u03b2} {a : \u03b1} {x : \u03b2}\n\n@[simp, to_additive]\nlemma smul_mem_smul_set_iff : a \u2022 x \u2208 a \u2022 s \u2194 x \u2208 s := (mul_action.injective _).mem_set_image\n\n@[to_additive]\nlemma mem_smul_set_iff_inv_smul_mem : x \u2208 a \u2022 A \u2194 a\u207b\u00b9 \u2022 x \u2208 A :=\nshow x \u2208 mul_action.to_perm a '' A \u2194 _, from mem_image_equiv\n\n@[to_additive]\nlemma mem_inv_smul_set_iff : x \u2208 a\u207b\u00b9 \u2022 A \u2194 a \u2022 x \u2208 A :=\nby simp only [\u2190 image_smul, mem_image, inv_smul_eq_iff, exists_eq_right]\n\n@[to_additive]\nlemma preimage_smul (a : \u03b1) (t : set \u03b2) : (\u03bb x, a \u2022 x) \u207b\u00b9' t = a\u207b\u00b9 \u2022 t :=\n((mul_action.to_perm a).symm.image_eq_preimage _).symm\n\n@[to_additive]\nlemma preimage_smul_inv (a : \u03b1) (t : set \u03b2) : (\u03bb x, a\u207b\u00b9 \u2022 x) \u207b\u00b9' t = a \u2022 t :=\npreimage_smul (to_units a)\u207b\u00b9 t\n\n@[simp, to_additive]\nlemma set_smul_subset_set_smul_iff : a \u2022 A \u2286 a \u2022 B \u2194 A \u2286 B :=\nimage_subset_image_iff $ mul_action.injective _\n\n@[to_additive]\nlemma set_smul_subset_iff : a \u2022 A \u2286 B \u2194 A \u2286 a\u207b\u00b9 \u2022 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 \u2286 a \u2022 B \u2194 a\u207b\u00b9 \u2022 A \u2286 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 \u2022 (s \u2229 t) = a \u2022 s \u2229 a \u2022 t :=\nimage_inter $ mul_action.injective a\n\n@[to_additive] lemma smul_set_sdiff : a \u2022 (s \\ t) = a \u2022 s \\ a \u2022 t :=\nimage_diff (mul_action.injective a) _ _\n\n@[to_additive] lemma smul_set_symm_diff : a \u2022 (s \u2206 t) = (a \u2022 s) \u2206 (a \u2022 t) :=\nimage_symm_diff (mul_action.injective a) _ _\n\n@[simp, to_additive] lemma smul_set_univ : a \u2022 (univ : set \u03b2) = univ :=\nimage_univ_of_surjective $ mul_action.surjective a\n\n@[simp, to_additive] lemma smul_univ {s : set \u03b1} (hs : s.nonempty) : s \u2022 (univ : set \u03b2) = univ :=\nlet \u27e8a, ha\u27e9 := hs in eq_univ_of_forall $ \u03bb b, \u27e8a, a\u207b\u00b9 \u2022 b, ha, trivial, smul_inv_smul _ _\u27e9\n\n@[to_additive]\nlemma smul_inter_ne_empty_iff {s t : set \u03b1} {x : \u03b1} :\n  x \u2022 s \u2229 t \u2260 \u2205 \u2194 \u2203 a b, (a \u2208 t \u2227 b \u2208 s) \u2227 a * b\u207b\u00b9 = x :=\nbegin\n  rw \u2190nonempty_iff_ne_empty,\n  split,\n  { rintros \u27e8a, h, ha\u27e9,\n    obtain \u27e8b, hb, rfl\u27e9 := mem_smul_set.mp h,\n    exact \u27e8x \u2022 b, b, \u27e8ha, hb\u27e9, by simp\u27e9, },\n  { rintros \u27e8a, b, \u27e8ha, hb\u27e9, rfl\u27e9,\n    exact \u27e8a, mem_inter (mem_smul_set.mpr \u27e8b, hb, by simp\u27e9) ha\u27e9, },\nend\n\n@[to_additive]\nlemma smul_inter_ne_empty_iff' {s t : set \u03b1} {x : \u03b1} :\n  x \u2022 s \u2229 t \u2260 \u2205 \u2194 \u2203 a b, (a \u2208 t \u2227 b \u2208 s) \u2227 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 \u03b1} {x : \u03b1\u1d50\u1d52\u1d56} :\n  x \u2022 s \u2229 t \u2260 \u2205 \u2194 \u2203 a b, (a \u2208 s \u2227 b \u2208 t) \u2227 a\u207b\u00b9 * b = mul_opposite.unop x :=\nbegin\n  rw \u2190nonempty_iff_ne_empty,\n  split,\n  { rintros \u27e8a, h, ha\u27e9,\n    obtain \u27e8b, hb, rfl\u27e9 := mem_smul_set.mp h,\n    exact \u27e8b, x \u2022 b, \u27e8hb, ha\u27e9, by simp\u27e9, },\n  { rintros \u27e8a, b, \u27e8ha, hb\u27e9, H\u27e9,\n    have : mul_opposite.op (a\u207b\u00b9 * b) = x := congr_arg mul_opposite.op H,\n    exact \u27e8b, mem_inter (mem_smul_set.mpr \u27e8a, ha, by simp [\u2190 this]\u27e9) hb\u27e9, },\nend\n\n@[simp, to_additive] lemma Union_inv_smul :\n  (\u22c3 (g : \u03b1), g\u207b\u00b9 \u2022 s) = (\u22c3 (g : \u03b1), g \u2022 s) :=\nfunction.surjective.supr_congr _ inv_surjective $ \u03bb g, rfl\n\n@[to_additive]\nlemma Union_smul_eq_set_of_exists {s : set \u03b2} :\n  (\u22c3 (g : \u03b1), g \u2022 s) = {a | \u2203 (g : \u03b1), g \u2022 a \u2208 s} :=\nby simp_rw [\u2190 Union_set_of, \u2190 Union_inv_smul, \u2190 preimage_smul, preimage]\n\nend group\n\nsection group_with_zero\nvariables [group_with_zero \u03b1] [mul_action \u03b1 \u03b2] {s t : set \u03b2} {a : \u03b1}\n\n@[simp] lemma smul_mem_smul_set_iff\u2080 (ha : a \u2260 0) (A : set \u03b2)\n  (x : \u03b2) : a \u2022 x \u2208 a \u2022 A \u2194 x \u2208 A :=\nshow units.mk0 a ha \u2022 _ \u2208 _ \u2194 _, from smul_mem_smul_set_iff\n\nlemma mem_smul_set_iff_inv_smul_mem\u2080 (ha : a \u2260 0) (A : set \u03b2) (x : \u03b2) :\n  x \u2208 a \u2022 A \u2194 a\u207b\u00b9 \u2022 x \u2208 A :=\nshow _ \u2208 units.mk0 a ha \u2022 _ \u2194 _, from mem_smul_set_iff_inv_smul_mem\n\nlemma mem_inv_smul_set_iff\u2080 (ha : a \u2260 0) (A : set \u03b2) (x : \u03b2) : x \u2208 a\u207b\u00b9 \u2022 A \u2194 a \u2022 x \u2208 A :=\nshow _ \u2208 (units.mk0 a ha)\u207b\u00b9 \u2022 _ \u2194 _, from mem_inv_smul_set_iff\n\nlemma preimage_smul\u2080 (ha : a \u2260 0) (t : set \u03b2) : (\u03bb x, a \u2022 x) \u207b\u00b9' t = a\u207b\u00b9 \u2022 t :=\npreimage_smul (units.mk0 a ha) t\n\nlemma preimage_smul_inv\u2080 (ha : a \u2260 0) (t : set \u03b2) :\n  (\u03bb x, a\u207b\u00b9 \u2022 x) \u207b\u00b9' t = a \u2022 t :=\npreimage_smul ((units.mk0 a ha)\u207b\u00b9) t\n\n@[simp] lemma set_smul_subset_set_smul_iff\u2080 (ha : a \u2260 0) {A B : set \u03b2} :\n  a \u2022 A \u2286 a \u2022 B \u2194 A \u2286 B :=\nshow units.mk0 a ha \u2022 _ \u2286 _ \u2194 _, from set_smul_subset_set_smul_iff\n\nlemma set_smul_subset_iff\u2080 (ha : a \u2260 0) {A B : set \u03b2} : a \u2022 A \u2286 B \u2194 A \u2286 a\u207b\u00b9 \u2022 B :=\nshow units.mk0 a ha \u2022 _ \u2286 _ \u2194 _, from set_smul_subset_iff\n\nlemma subset_set_smul_iff\u2080 (ha : a \u2260 0) {A B : set \u03b2} : A \u2286 a \u2022 B \u2194 a\u207b\u00b9 \u2022 A \u2286 B :=\nshow _ \u2286 units.mk0 a ha \u2022 _ \u2194 _, from subset_set_smul_iff\n\nlemma smul_set_inter\u2080 (ha : a \u2260 0) : a \u2022 (s \u2229 t) = a \u2022 s \u2229 a \u2022 t :=\nshow units.mk0 a ha \u2022 _ = _, from smul_set_inter\n\nlemma smul_set_sdiff\u2080 (ha : a \u2260 0) : a \u2022 (s \\ t) = a \u2022 s \\ a \u2022 t :=\nimage_diff (mul_action.injective\u2080 ha) _ _\n\nlemma smul_set_symm_diff\u2080 (ha : a \u2260 0) : a \u2022 (s \u2206 t) = (a \u2022 s) \u2206 (a \u2022 t) :=\nimage_symm_diff (mul_action.injective\u2080 ha) _ _\n\nlemma smul_set_univ\u2080 (ha : a \u2260 0) : a \u2022 (univ : set \u03b2) = univ :=\nimage_univ_of_surjective $ mul_action.surjective\u2080 ha\n\nlemma smul_univ\u2080 {s : set \u03b1} (hs : \u00ac s \u2286 0) : s \u2022 (univ : set \u03b2) = univ :=\nlet \u27e8a, ha, ha\u2080\u27e9 := not_subset.1 hs in eq_univ_of_forall $ \u03bb b,\n  \u27e8a, a\u207b\u00b9 \u2022 b, ha, trivial, smul_inv_smul\u2080 ha\u2080 _\u27e9\n\nlemma smul_univ\u2080' {s : set \u03b1} (hs : s.nontrivial) : s \u2022 (univ : set \u03b2) = univ :=\nsmul_univ\u2080 hs.not_subset_singleton\n\nend group_with_zero\n\nsection monoid\nvariables [monoid \u03b1] [add_group \u03b2] [distrib_mul_action \u03b1 \u03b2] (a : \u03b1) (s : set \u03b1) (t : set \u03b2)\n\n@[simp] lemma smul_set_neg : a \u2022 -t = -(a \u2022 t) :=\nby simp_rw [\u2190image_smul, \u2190image_neg, image_image, smul_neg]\n\n@[simp] protected lemma smul_neg : s \u2022 -t = -(s \u2022 t) :=\nby { simp_rw \u2190image_neg, exact image_image2_right_comm smul_neg }\n\nend monoid\n\nsection ring\nvariables [ring \u03b1] [add_comm_group \u03b2] [module \u03b1 \u03b2] (a : \u03b1) (s : set \u03b1) (t : set \u03b2)\n\n@[simp] lemma neg_smul_set : -a \u2022 t = -(a \u2022 t) :=\nby simp_rw [\u2190image_smul, \u2190image_neg, image_image, neg_smul]\n\n@[simp] protected lemma neg_smul : -s \u2022 t = -(s \u2022 t) :=\nby { simp_rw \u2190image_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 \u2192 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 \u2192 b) \u2192 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 \u2192 b) \u2192 Sort u} : (a \u2192 (h : b) \u2192 motive (\u03bb _ => h)) \u2192 (t : a \u2192 b) \u2192 a \u2192 motive t :=\n  \u03bb h t ha => h ha (t ha)\n\nprotected def Implies.recOn.{u} {motive : (a \u2192 b) \u2192 Sort u} (t : a \u2192 b) := Implies.rec (motive:=motive) (t:=t)\n\nprotected def Implies.casesOn.{u} {motive : (a \u2192 b) \u2192 Sort u} := Implies.recOn (motive := motive)\n\n/-- eliminator for `Implies` -/\nprotected def Implies.elim.{u} {motive : Sort u} := Implies.recOn (motive := \u03bb _ : a \u2192 b => motive)\n\n/-- modus ponens -/\nprotected abbrev Implies.mp : Implies a b \u2192 a \u2192 b := id\n\n/-- modus tollens -/\nprotected abbrev Implies.mt : Implies a b \u2192 \u00acb \u2192 \u00aca := 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 \u2192 False) \u2192 \u00aca := 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 : \u00aca \u2192 Sort u} (t : \u00aca) : a \u2192 motive t :=\n  \u03bb h => False.casesOn (motive := \u03bb _ => motive t) (t h)\n\nprotected def Not.recOn.{u} {motive : \u00aca \u2192 Sort u} (t : \u00aca) := Not.rec (motive:=motive) t\n\nprotected def Not.casesOn.{u} {motive : \u00acp \u2192 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 := \u03bb _ : \u00aca => motive)\n\n/- eliminator for `And` -/\n-- assert def And.elim.{u} {motive : Sort u} := And.casesOn (motive := \u03bb _ : a \u2227 b => motive)\n\n/- eliminator for `Iff` -/\n-- assert def Iff.elim.{u} {motive : Sort u} := Iff.casesOn (motive := \u03bb _ : a \u2194 b => motive)\n\ntheorem Iff.eq_implies_and_implies (a b : Prop) : (a \u2194 b) = ((a \u2192 b) \u2227 (b \u2192 a)) :=\n  propext (iff_iff_implies_and_implies a b)\n\nprotected def Iff.mt : (a \u2194 b) \u2192 (\u00acb \u2194 \u00aca)\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 \u2228 b \u2192 Sort u} : [Decidable a] \u2192 [Decidable b] \u2192\n  (inl : (h : a) \u2192 motive (Or.inl h)) \u2192 (inr : (h : b) \u2192 motive (Or.inr h)) \u2192 (t : a \u2228 b) \u2192 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 \u03bb | Or.inl h => ha h | Or.inr h => hb h\n\nprotected def Or.recLargeOn.{u} [Decidable a] [Decidable b] {motive : a \u2228 b \u2192 Sort u} (t : a \u2228 b) :=\n  Or.recLarge (motive:=motive) (t:=t)\n\nprotected def Or.casesLargeOn.{u} [Decidable a] [Decidable b] {motive : a \u2228 b \u2192 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 := \u03bb _ : a \u2228 b => motive)\n\n/-- modus tollendo ponens -/\ntheorem Or.mtp : a \u2228 b \u2192 \u00acb \u2192 a :=\n  \u03bb t => Or.elim t (\u03bb h _ => h) absurd\n\n/-- modus tollendo ponens (reversed) -/\ntheorem Or.mtpr : a \u2228 b \u2192 \u00aca \u2192 b :=\n  \u03bb t => Or.elim t absurd (\u03bb h _ => h)\n\n/-- `NOr` connective: `\u00ac(a \u2228 b)` -/\ndef NOr (a b : Prop) : Prop := \u00ac(a \u2228 b)\n\nprotected def NOr.eq_def (a b : Prop) : NOr a b = \u00ac(a \u2228 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 : \u00aca \u2192 \u00acb \u2192 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 \u2192 Sort u} : (intro : (na : \u00aca) \u2192 (nb : \u00acb) \u2192 motive (NOr.intro na nb)) \u2192 (t : NOr a b) \u2192 motive t :=\n  \u03bb h t => h (\u03bb ha => t (Or.inl ha)) (\u03bb 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 \u2192 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 \u2192 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 : \u00aca \u2192 \u00acb \u2192 motive) \u2192 motive :=\n  NOr.recOn (motive := \u03bb _ => motive) t\n\n/-- left projection for `NOr` -/\nprotected def NOr.left : NOr a b \u2192 \u00aca :=\n  \u03bb h => NOr.elim h (\u03bb ha _ => ha)\n\n/-- right projection for `NOr` -/\nprotected def NOr.right : NOr a b \u2192 \u00acb :=\n  \u03bb h => NOr.elim h (\u03bb _ hb => hb)\n\ntheorem nor_of_not_and_not : \u00aca \u2227 \u00acb \u2192 \u00ac(a \u2228 b)\n| And.intro ha hb => NOr.intro ha hb\n\ntheorem not_and_not_of_nor : \u00ac(a \u2228 b) \u2192 \u00aca \u2227 \u00acb :=\n  \u03bb h => And.intro (\u03bb ha => h (Or.inl ha)) (\u03bb hb => h (Or.inr hb))\n\ntheorem nor_iff_not_and_not (a b : Prop) : \u00ac(a \u2228 b) \u2194 \u00aca \u2227 \u00acb :=\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 = (\u00aca \u2227 \u00acb) :=\n  propext (nor_iff_not_and_not a b)\n\n/-- de Morgan's law for `Or` -/\nprotected theorem Or.deMorgan : \u00ac(a \u2228 b) \u2194 \u00aca \u2227 \u00acb := nor_iff_not_and_not a b\n\n/-- `NAnd` connective: `\u00ac(a \u2227 b)` -/\ndef NAnd (a b : Prop) : Prop := \u00ac(a \u2227 b)\n\nprotected def NAnd.eq_def (a b : Prop) : NAnd a b = \u00ac(a \u2227 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 : \u00aca \u2192 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 : \u00acb \u2192 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 \u2192 Prop} : [WeaklyComplemented a] \u2192 [WeaklyComplemented b] \u2192\n  (inl : (h : \u00aca) \u2192 motive (NAnd.inl h)) \u2192 (inr : (h : \u00acb) \u2192 motive (NAnd.inr h)) \u2192 (t : NAnd a b) \u2192 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 \u03bb h => ha \u03bb ha => hb \u03bb 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 \u2192 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 \u2192 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 := \u03bb _ : 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 \u2192 Sort u} : [WeaklyDecidable a] \u2192 [WeaklyDecidable b] \u2192\n  (inl : (h : \u00aca) \u2192 motive (NAnd.inl h)) \u2192 (inr : (h : \u00acb) \u2192 motive (NAnd.inr h)) \u2192 (t : NAnd a b) \u2192 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 \u03bb h => ha \u03bb ha => hb \u03bb hb => h (And.intro ha hb)\n\nprotected def NAnd.recLargeOn.{u} {motive : NAnd a b \u2192 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 \u2192 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 := \u03bb _ : NAnd a b => motive)\n\ntheorem nand_of_not_or_not : \u00aca \u2228 \u00acb \u2192 \u00ac(a \u2227 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] : \u00ac(a \u2227 b) \u2192 \u00aca \u2228 \u00acb :=\n  \u03bb h => NAnd.elim h Or.inl Or.inr\n\ntheorem nand_iff_not_or_not (a b : Prop) [WeaklyComplemented a] [WeaklyComplemented b] : \u00ac(a \u2227 b) \u2194 \u00aca \u2228 \u00acb :=\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 = (\u00aca \u2228 \u00acb) :=\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] : \u00ac(a \u2227 b) \u2194 \u00aca \u2228 \u00acb := 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 \u2208 ray p a \u2192 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 \u2192 sided p q r \u2192 eqd a b p q \u2192 eqd a c p r \u2192 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 \u2192 cong a b c a' b' c' \u2192 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 \u27e8a_1.2.2, a_1.2.1.flip, a_1.1\u27e9\nend\n\ndef l (a b : point) : set point := {x | col a b x}\n\ndef line (k : set point) : Prop := \u2203 a b, a \u2260 b \u2227 k = l a b\n\nlemma six14 {a b : point} : a \u2260 b \u2192 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 \u2260 q \u2192 p \u2260 r \u2192 B q p r \u2192 l p q = ray p q \u222a {p} \u222a 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 \u2260 q \u2192 p \u2260 r \u2192 r \u2208 l p q \u2192 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 \u2192 l p q = l p r :=\n\u03bb 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) \u25b8 h\n\n@[simp] theorem six17a (p q : point) : p \u2208 l p q := (four11 (four12 p q)).1\n\n@[simp] theorem six17b (p q : point) : q \u2208 l p q := (four11 (four12 q p)).2.2.2.1\n\ntheorem six18 {a b : point} {L : set point} : line L \u2192 a \u2260 b \u2192 a \u2208 L \u2192 b \u2208 L \u2192 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 \u2209 l p q \u2192 a \u2260 p \u2227 a \u2260 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 \u2260 b \u2192 \u2203! L : set point, line L \u2227 a \u2208 L \u2227 b \u2208 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 \u2192 a \u2208 A \u2192 b \u2208 A \u2192 a \u2260 b \u2192 col a b c \u2192 c \u2208 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 \u2260 b \u2192 line A \u2192 line B \u2192 a \u2208 A \u2192 a \u2208 B \u2192 b \u2208 A \u2192 b \u2208 B \u2192 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 \u2227 line B \u2227 A \u2260 B \u2227 x \u2208 A \u2227 x \u2208 B\n\ntheorem six21a {x y : point} {A B : set point} : line A \u2192 line B \u2192 A \u2260 B \u2192 x \u2208 A \u2192 x \u2208 B \u2192 y \u2208 A \u2192 y \u2208 B \u2192 x = y :=\n\u03bb h h1 h2 h3 h4 h5 h6, classical.by_contradiction (\u03bb h_1,\nh2 (six21 h_1 h h1 h3 h4 h5 h6))\n\ntheorem six22 {x : point} {A : set point} : line A \u2192 x \u2208 A \u2192 \u2203 y, x \u2260 y \u2227 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 \u2208 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 \u2194 \u2203 (L : set point), line L \u2227 a \u2208 L \u2227 b \u2208 L \u2227 c \u2208 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 : \u00accol (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 \u2260 b \u2192 \u2203 c, \u00accol a b c :=\nbegin\nintro h1,\nby_contradiction h2,\nrw not_exists at h2,\nsimp at h2,\napply @six24 point,\napply six23.2,\nexact \u27e8l a b, six14 h1, h2 P1, h2 P2, h2 P3\u27e9\nend\n\nlemma six13a (a : point) : \u00acline (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 \u2208 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) \u2192 a \u2260 b := \nbegin\nintros h h1,\nsubst b,\napply six13a a,\nexact h\nend\n\ndef tri (a b c : point) : Prop := a \u2260 b \u2227 b \u2260 c \u2227 a \u2260 c\n\ntheorem six26 {a b c : point} : \u00accol a b c \u2192 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 \u2192 a \u2208 A \u2192 c \u2208 A \u2192 B a b c \u2192 b \u2208 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} : \u00accol a b c \u2192 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 \u2208 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 \u2227 eqd m a m b \n\ntheorem M.symm {a b m : point} : M a m b \u2192 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 \u2194 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) : \u2203! 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 \u27e8hq.1, hq.2.symm\u27e9,\nintros y hy,\napply unique_of_exists_unique (two12 a a p p (ne.symm h)),\nexact \u27e8hy.1, hy.2.symm\u27e9,\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 \u2192 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) : \u2203! q, S a q = p :=\nbegin\nexistsi S a p,\nsplit,\n  exact seven7 a p,\nintros q h,\nrw \u2190h,\nexact (seven7 a q).symm\nend\n\ntheorem seven9 {a p q : point} : S a p = S a q \u2192 p = q :=\nbegin\nintro h,\napply unique_of_exists_unique (seven8 a (S a p)),\n  simp,\nrw \u2190h\nend\n\ntheorem seven9a {a b : point} (p : point) : a \u2260 b \u2192 S p a \u2260 S p b :=\nbegin\nintros h h1,\nexact h (seven9 h1)\nend\n\ntheorem seven10 {a p : point} : S a p = p \u2194 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 \u2260 p \u2192 a \u2260 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 \u2260 p \u2192 p \u2260 S a p :=\n\u03bb 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 \u2190hp' 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 \u2260 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 \u2194 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 \u2190(seven7 a p),\nrw \u2190(seven7 a q),\nrw \u2190(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 \u2194 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 \u2194 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 \u2194 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 \u2192 M p b q \u2192 a = b :=\nbegin\nintros h h1,\nhave h2 := seven6 h,\nhave h3 := seven13 a q b,\nhave h4 := seven7 a p,\nrwa \u2190h2 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 \u2190h2 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 \u2192 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 \u2260 b \u2192 S a p \u2260 S b p:=\n\u03bb h h1, h (seven18 h1)\n\ntheorem seven19 {a b p : point} : S a (S b p) = S b (S a p) \u2194 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 \u2192 eqd m a m b \u2192 a = b \u2228 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} : \u00accol a b c \u2192 b \u2260 d \u2192 eqd a b c d \u2192 eqd b c d a \u2192 \ncol a p c \u2192 col b p d \u2192 M a p c \u2227 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 \u2260 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 \u2209 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 \u2227 B b c q \u2227 eqd c a c b \u2227 eqd c p c q \u2227 \nM a m b \u2227 M p n q\n\nlemma seven23 {a b c p q m n : point} : hourglass a b c p q m n \u2192 distle c a c q \u2192 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' \u2260 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 \u2260 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' \u2260 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 \u2192 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 \u2192 a \u2208 A \u2192 (p \u2208 A \u2194 (S a p) \u2208 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 \u2190seven7 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 \u2192 \u2203 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 \u2260 q,\n  intro h_2,\n  rw \u2190h_2 at *,\n  have : col a c b,\n    right, left,\n    exact hq.1,\n  exact h_1 this,\nhave h_3 : b \u2260 p,\n  intro h_3,\n  rw \u2190h_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 \u2260 l b p,\n  intro h_4,\n  suffices : a \u2208 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 \u2190h_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 : \u2115} {m : \u2115} (F : typevec n \u2192 Type u_1) (G : fin2 n \u2192 typevec m \u2192 Type u) (v : typevec m) :=\n  F fun (i : fin2 n) => G i v\n\nnamespace comp\n\n\nprotected instance inhabited {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} {G : fin2 n \u2192 typevec m \u2192 Type u} {\u03b1 : typevec m} [I : Inhabited (F fun (i : fin2 n) => G i \u03b1)] : Inhabited (comp F G \u03b1) :=\n  I\n\n/-- Constructor for functor composition -/\nprotected def mk {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} {G : fin2 n \u2192 typevec m \u2192 Type u} {\u03b1 : typevec m} (x : F fun (i : fin2 n) => G i \u03b1) : comp F G \u03b1 :=\n  x\n\n/-- Destructor for functor composition -/\nprotected def get {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} {G : fin2 n \u2192 typevec m \u2192 Type u} {\u03b1 : typevec m} (x : comp F G \u03b1) : F fun (i : fin2 n) => G i \u03b1 :=\n  x\n\n@[simp] protected theorem mk_get {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} {G : fin2 n \u2192 typevec m \u2192 Type u} {\u03b1 : typevec m} (x : comp F G \u03b1) : comp.mk (comp.get x) = x :=\n  rfl\n\n@[simp] protected theorem get_mk {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} {G : fin2 n \u2192 typevec m \u2192 Type u} {\u03b1 : typevec m} (x : F fun (i : fin2 n) => G i \u03b1) : comp.get (comp.mk x) = x :=\n  rfl\n\n/-- map operation defined on a vector of functors -/\nprotected def map' {n : \u2115} {m : \u2115} {G : fin2 n \u2192 typevec m \u2192 Type u} [fG : (i : fin2 n) \u2192 mvfunctor (G i)] {\u03b1 : typevec m} {\u03b2 : typevec m} (f : typevec.arrow \u03b1 \u03b2) : typevec.arrow (fun (i : fin2 n) => G i \u03b1) fun (i : fin2 n) => G i \u03b2 :=\n  fun (i : fin2 n) => mvfunctor.map f\n\n/-- The composition of functors is itself functorial -/\nprotected def map {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} [fF : mvfunctor F] {G : fin2 n \u2192 typevec m \u2192 Type u} [fG : (i : fin2 n) \u2192 mvfunctor (G i)] {\u03b1 : typevec m} {\u03b2 : typevec m} (f : typevec.arrow \u03b1 \u03b2) : comp F G \u03b1 \u2192 comp F G \u03b2 :=\n  mvfunctor.map fun (i : fin2 n) => mvfunctor.map f\n\nprotected instance mvfunctor {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} [fF : mvfunctor F] {G : fin2 n \u2192 typevec m \u2192 Type u} [fG : (i : fin2 n) \u2192 mvfunctor (G i)] : mvfunctor (comp F G) :=\n  mvfunctor.mk fun (\u03b1 \u03b2 : typevec m) => comp.map\n\ntheorem map_mk {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} [fF : mvfunctor F] {G : fin2 n \u2192 typevec m \u2192 Type u} [fG : (i : fin2 n) \u2192 mvfunctor (G i)] {\u03b1 : typevec m} {\u03b2 : typevec m} (f : typevec.arrow \u03b1 \u03b2) (x : F fun (i : fin2 n) => G i \u03b1) : mvfunctor.map f (comp.mk x) = comp.mk (mvfunctor.map (fun (i : fin2 n) (x : G i \u03b1) => mvfunctor.map f x) x) :=\n  rfl\n\ntheorem get_map {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} [fF : mvfunctor F] {G : fin2 n \u2192 typevec m \u2192 Type u} [fG : (i : fin2 n) \u2192 mvfunctor (G i)] {\u03b1 : typevec m} {\u03b2 : typevec m} (f : typevec.arrow \u03b1 \u03b2) (x : comp F G \u03b1) : comp.get (mvfunctor.map f x) = mvfunctor.map (fun (i : fin2 n) (x : G i \u03b1) => mvfunctor.map f x) (comp.get x) :=\n  rfl\n\nprotected instance mvqpf {n : \u2115} {m : \u2115} {F : typevec n \u2192 Type u_1} [fF : mvfunctor F] [q : mvqpf F] {G : fin2 n \u2192 typevec m \u2192 Type u} [fG : (i : fin2 n) \u2192 mvfunctor (G i)] [q' : (i : fin2 n) \u2192 mvqpf (G i)] : mvqpf (comp F G) :=\n  mk (mvpfunctor.comp (P F) fun (i : fin2 n) => P (G i))\n    (fun (\u03b1 : typevec m) => comp.mk \u2218 (mvfunctor.map fun (i : fin2 n) => abs) \u2218 abs \u2218 mvpfunctor.comp.get)\n    (fun (\u03b1 : typevec m) => mvpfunctor.comp.mk \u2218 repr \u2218 (mvfunctor.map fun (i : fin2 n) => repr) \u2218 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} 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 \u2192 D) : Type (max v\u2081 v\u2082 u\u2081 u\u2082) :=\n(map       : \u03a0 {X Y : C}, (X \u27f6 Y) \u2192 ((F X) \u27f6 (F Y)))\n(map_id'   : \u2200 (X : C), map (\ud835\udfd9 X) = \ud835\udfd9 (F X) . obviously)\n(map_comp' : \u2200 {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z), map (f \u226b g) = (map f) \u226b (map g) . obviously)\n\n/--\nIf `F : C \u2192 D` (just a function) has `[functorial F]`,\nwe can write `map F f : F X \u27f6 F Y` for the action of `F` on a morphism `f : X \u27f6 Y`.\n-/\ndef map (F : C \u2192 D) [functorial.{v\u2081 v\u2082} F] {X Y : C} (f : X \u27f6 Y) : F X \u27f6 F Y :=\nfunctorial.map.{v\u2081 v\u2082} f\n\n@[simp] lemma map_as_map {F : C \u2192 D} [functorial.{v\u2081 v\u2082} F] {X Y : C} {f : X \u27f6 Y} :\n  functorial.map.{v\u2081 v\u2082} f = map F f := rfl\n\n@[simp] lemma functorial.map_id {F : C \u2192 D} [functorial.{v\u2081 v\u2082} F] {X : C} :\n  map F (\ud835\udfd9 X) = \ud835\udfd9 (F X) := functorial.map_id' X\n\n@[simp] lemma functorial.map_comp\n  {F : C \u2192 D} [functorial.{v\u2081 v\u2082} F] {X Y Z : C} {f : X \u27f6 Y} {g : Y \u27f6 Z} :\n  map F (f \u226b g) = map F f \u226b 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 \u2192 D) [I : functorial.{v\u2081 v\u2082} F] : C \u2964 D :=\n{ obj := F,\n  ..I }\n\nend functor\n\ninstance (F : C \u2964 D) : functorial.{v\u2081 v\u2082} (F.obj) := { .. F }\n\n@[simp]\nlemma map_functorial_obj (F : C \u2964 D) {X Y : C} (f : X \u27f6 Y) : map F.obj f = F.map f := rfl\n\ninstance functorial_id : functorial.{v\u2081 v\u2081} (id : C \u2192 C) :=\n{ map := \u03bb X Y f, f }\n\nsection\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\n/--\n`G \u2218 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 \u2192 D) [functorial.{v\u2081 v\u2082} F] (G : D \u2192 E) [functorial.{v\u2082 v\u2083} G] :\n  functorial.{v\u2081 v\u2083} (G \u2218 F) :=\n{ ..(functor.of F \u22d9 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\u2082\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\u2082} [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 \u2964 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 \u2192 C} (b : bicone f) : bicone (F.obj \u2218 f) :=\n{ X := F.obj b.X,\n  \u03c0 := \u03bb j, F.map (b.\u03c0 j),\n  \u03b9 := \u03bb j, F.map (b.\u03b9 j),\n  \u03b9_\u03c0 := \u03bb j j',\n  begin\n    rw \u2190 F.map_comp,\n    split_ifs,\n    { subst h,\n      simp only [bicone_\u03b9_\u03c0_self, category_theory.functor.map_id, eq_to_hom_refl] },\n    { rw [bicone_\u03b9_\u03c0_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 [\u2190 F.map_comp, b.inl_fst, F.map_id],\n  inl_snd' := by rw [\u2190 F.map_comp, b.inl_snd, F.map_zero],\n  inr_fst' := by rw [\u2190 F.map_comp, b.inr_fst, F.map_zero],\n  inr_snd' := by rw [\u2190 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 \u2218 f`. -/\nclass preserves_biproduct (f : J \u2192 C) (F : C \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {b : bicone f}, b.is_bilimit \u2192 (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 \u2218 f`. -/\ndef is_bilimit_of_preserves {f : J \u2192 C} (F : C \u2964 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 \u2192 C`. -/\nclass preserves_biproducts_of_shape (F : C \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {f : J \u2192 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D)\n  [preserves_zero_morphisms F] [preserves_biproducts F] : preserves_finite_biproducts F :=\n{ preserves := \u03bb 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {b : binary_bicone X Y}, b.is_bilimit \u2192 (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 \u2964 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D) [preserves_zero_morphisms F]\n  (X Y : C) [preserves_biproduct (pair_function X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, tidy, }) } }\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_biproducts (F : C \u2964 D)\n  [preserves_zero_morphisms F] [preserves_biproducts_of_shape walking_pair.{v} F] :\n  preserves_binary_biproducts F :=\n{ preserves := \u03bb 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 \u2964 D) [preserves_zero_morphisms F] (f : J \u2192 C)\n  [has_biproduct f] [preserves_biproduct f F]\n\ninstance has_biproduct_of_preserves : has_biproduct (F.obj \u2218 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 (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f)`. -/\n@[simp]\ndef map_biproduct : F.obj (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f) :=\nbiproduct.unique_up_to_iso _ (preserves_biproduct.preserves (biproduct.is_bilimit _))\n\nlemma map_biproduct_hom : (map_biproduct F f).hom = biproduct.lift (\u03bb j, F.map (biproduct.\u03c0 f j)) :=\nrfl\n\nlemma map_biproduct_inv : (map_biproduct F f).inv = biproduct.desc (\u03bb j, F.map (biproduct.\u03b9 f j)) :=\nrfl\n\nend bicone\n\nvariables (F : C \u2964 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 \u229e Y) \u2245 F.obj X \u229e F.obj Y`. -/\n@[simp]\ndef map_biprod : F.obj (X \u229e Y) \u2245 F.obj X \u229e 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 \u2964 D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type v} (f : J \u2192 C) [has_biproduct f] [preserves_biproduct f F]\n  {W : C}\n\nlemma biproduct.map_lift_map_biprod (g : \u03a0 j, W \u27f6 f j) :\n  F.map (biproduct.lift g) \u226b (F.map_biproduct f).hom = biproduct.lift (\u03bb j, F.map (g j)) :=\nby { ext, simp [\u2190 F.map_comp] }\n\nlemma biproduct.map_biproduct_inv_map_desc (g : \u03a0 j, f j \u27f6 W) :\n  (F.map_biproduct f).inv \u226b F.map (biproduct.desc g) = biproduct.desc (\u03bb j, F.map (g j)) :=\nby { ext, simp [\u2190 F.map_comp] }\n\nlemma biproduct.map_biproduct_hom_desc (g : \u03a0 j, f j \u27f6 W) :\n  (F.map_biproduct f).hom \u226b biproduct.desc (\u03bb j, F.map (g j)) = F.map (biproduct.desc g) :=\nby rw [\u2190 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 \u27f6 X) (g : W \u27f6 Y) :\n  F.map (biprod.lift f g) \u226b (F.map_biprod X Y).hom = biprod.lift (F.map f) (F.map g) :=\nby ext; simp [\u2190 F.map_comp]\n\nlemma biprod.lift_map_biprod (f : W \u27f6 X) (g : W \u27f6 Y) :\n  biprod.lift (F.map f) (F.map g) \u226b (F.map_biprod X Y).inv = F.map (biprod.lift f g) :=\nby rw [\u2190 biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n\nlemma biprod.map_biprod_inv_map_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n  (F.map_biprod X Y).inv \u226b F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) :=\nby ext; simp [\u2190 F.map_comp]\n\nlemma biprod.map_biprod_hom_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n (F.map_biprod X Y).hom \u226b biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) :=\nby rw [\u2190 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 \u2964 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 \u2192 C} [preserves_biproduct f F] :\n  preserves_limit (discrete.functor f) F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C} [preserves_limit (discrete.functor f) F] :\n  preserves_biproduct f F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C} [preserves_biproduct f F] :\n  preserves_colimit (discrete.functor f) F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C}\n  [preserves_colimit (discrete.functor f) F] : preserves_biproduct f F :=\n{ preserves := \u03bb 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 := \u03bb 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 := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 := \u03bb 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 := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 := \u03bb 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 := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 := \u03bb 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 := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 := \u03bb 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 (\u03bb T : Type => T))\n  h_len : Ts.length = data.size\n  typed : \u2200 i : Fin Ts.length, (data.get (h_len \u25b8 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 \u25b8 (u.data.get (u.h_len \u25b8 i)).2\n\n  def getOp (self : HArray Ts) (idx : Fin Ts.length) : Ts.get idx\n    := self.typed idx \u25b8 (self.data.get (self.h_len \u25b8 idx)).2\n\n  def set (u : HArray Ts) (i : Fin Ts.length) (x : Ts.get i) : HArray Ts\n    := \u27e8u.data.set (u.h_len \u25b8 i) (\u27e8_, x\u27e9), sorry, sorry\u27e9\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 \u2192 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 : \u2200 j, i + j < Xs.length \u2192 Xs'.get \u27e8j, sorry\u27e9 = Xs.get \u27e8i + j, sorry\u27e9\n  F : Type\n  uncurry : F \u2192 (HArray Xs \u2192 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 := \u03bb 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' \u2192 c.F\n  uncurry := \u03bb f xs => \n    let h : (Xs.get \u27e8i,sorry\u27e9 = X') := sorry\n    let xi : X' := (h \u25b8 xs[\u27e8i,sorry\u27e9])\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 \u25b8 f)\n\n\nexample : huncurry 3 (\u03bb (i j k : Nat) => i + j) \n          = \n          \u03bb xs => xs[#0] + xs[#1] := \nby rfl\n\nexample : huncurry 2 (\u03bb (i j k : Nat) => i + j) \n          = \n          \u03bb 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 {\u03b1 \u03b2: Type}\n\ndef Property (\u03b1 : Type) : Type := \u03b1 \u2192 Prop \n\nstructure Claim (\u03b1 : Type) := make :: (X : set \u03b1) (P : Property \u03b1)\n\n@[instance] def claim_default {\u03b1 : Type} : inhabited (Claim \u03b1) := \n\u27e8Claim.make \u2205 (\u03bb x, true)\u27e9 \n\nnamespace list \n\ndef All {\u03b1 : Type} (pred : \u03b1 \u2192 Prop) : list \u03b1 \u2192 Prop\n| [] := true \n| (h::t) := pred h \u2227 All t\n\nend list \n\n@[reducible]\ndef meaning {\u03b1 : Type} (C : Claim \u03b1) : Prop := \n\u2200 x \u2208 C.X, C.P x \n\nnotation \u27e6C\u27e7 := meaning C \n\nstructure Strategy (\u03b1 : Type) :=\n(parent : Claim \u03b1) (decomp : Claim \u03b1 \u2192 list (Claim \u03b1))\n\n@[instance] def strat_default {\u03b1 : Type} : inhabited (Strategy \u03b1) := \n\u27e8Strategy.mk (default) (\u03bb c, [])\u27e9\n\n\n\ndef deductive (\u03b1 : Type) (S : Strategy \u03b1) : Prop := \nlet subclaims := (S.decomp) S.parent in \n(\u2200 clm \u2208 subclaims, \u27e6clm\u27e7) \u2192  \u27e6S.parent\u27e7 \n\nnamespace Strategy\n\ndef subclaims {\u03b1 : Type} (S : Strategy \u03b1) : list (Claim \u03b1) := \n  S.decomp S.parent \nend Strategy \n\nnamespace property \n\n@[reducible]\ndef decomposition \n(Ps : list (Property \u03b1)) \n(Clm : Claim \u03b1) : list (Claim \u03b1) := \nlist.map (Claim.make Clm.X) Ps\n\nstructure input (\u03b1 : Type) :=\n(Clm : Claim \u03b1)\n(Props : list (Property \u03b1))\n\n@[instance] def input_default {\u03b1 : Type} : inhabited (input \u03b1) := \n\u27e8input.mk (default) []\u27e9\n\nnamespace input \n\n@[reducible]\ndef length (\u0393 : input \u03b1) : \u2115 := \u0393.Props.length\n\nlemma len_decomp (\u0393 : input \u03b1) : \n\u0393.length = (decomposition \u0393.Props \u0393.Clm).length := \nby {rw decomposition, simp}\n\n@[reducible]\ndef subsets (\u0393 : input \u03b1) : fin (\u0393.length) \u2192 set \u03b1 := \n\u03bb i, set_of (\u0393.Props.nth_le i.1 i.2)\n\nend input\n\n\n\ndef justified\n(\u0393 : input \u03b1) : Prop :=\n(\u22c2 i, \u0393.subsets i) \u2286 {x | \u0393.Clm.P x}\n\n\n@[reducible]\ndef strategy (\u0393 : input \u03b1) : Strategy \u03b1 := \n{ parent := \u0393.Clm, \n  decomp := \u03bb C, list.map (Claim.make C.X)  \u0393.Props }  \n\n\n\ntheorem deductive_of_justfd\n: \u03a0 {\u0393 : property.input \u03b1},\njustified \u0393 \u2192 deductive \u03b1 (property.strategy \u0393) :=  \nbegin \n  intro \u0393,\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 \u0393.Props \u0393.Clm).nth_le i.1 (fin.cast (input.len_decomp \u0393) 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 {\u03b1 : Type}\n(P : Property \u03b1) (X : set \u03b1) : Claim \u03b1 := \nClaim.mk X P\n\n@[reducible]\ndef preimages {\u03b1 \u03b2: Type} \n(f : \u03b1 \u2192 \u03b2)\n(Clm : Claim \u03b1)\n(bs : list (set \u03b2)) : list (set \u03b1) := \nlist.map (set.preimage f) bs\n\n@[reducible]\ndef decomposition {\u03b1 \u03b2: Type} \n(f : \u03b1 \u2192 \u03b2)\n(sets_range : list (set \u03b2))\n(Clm : Claim \u03b1) : list (Claim \u03b1) :=\n(preimages f Clm sets_range).map (to_claim Clm.P)\n\nstructure auxiliary (\u03b1 \u03b2 : Type) :=\n(Clm : Claim \u03b1)\n(f : \u03b1 \u2192 \u03b2)\n(range_sets : list (set \u03b2))\n\ndef set_of_list : list \u03b1 \u2192 set \u03b1 \n| [] := \u2205 \n| (h::t) := {h} \u222a set_of_list t\n\ndef complete (\u0393 : auxiliary \u03b1 \u03b2) : Prop := \n \u2200 b : \u03b2, \u2203 s \u2208 \u0393.range_sets, b \u2208 s\n\ndef to_strategy (\u0393 : auxiliary \u03b1 \u03b2) : strategy \u03b1 := \nstrategy.mk (\u0393.Clm) (domain.decomposition \u0393.f \u0393.range_sets)\n\ntheorem deductive_of_justfd_comp (\u0393 : auxiliary \u03b1 \u03b2) : complete \u0393 \u2192  deductive \u03b1 (to_strategy \u0393) :=\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 : \u2203 s \u2208 \u0393.range_sets, \u0393.f x \u2208 s, from H1 (\u0393.f x),\n  rcases H3 with \u27e8s,H3,H4\u27e9,\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`\u207b\u00b9` := adjoin_fun'.inv x\nlocal notation `o` := adjoin_fun'.of_group 1\n\nopen adjoin_fun'\n\ninductive rel : adjoin_fun' G \u2192 adjoin_fun' G \u2192 Prop\n| mul_assoc (x y z) : rel (x * y * z) (x * (y * z))\n| mul_inv (x) : rel (x * x\u207b\u00b9) o\n| inv_mul (x) : rel (x\u207b\u00b9 * 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\u2081 a\u2082 b\u2081 b\u2082} : rel a\u2081 b\u2081 \u2192 rel a\u2082 b\u2082 \u2192 rel (a\u2081 * a\u2082) (b\u2081 * b\u2082)\n| u {a b} : rel a b \u2192 rel (u a) (u b)\n| inv {a b} : rel a b \u2192 rel (a\u207b\u00b9) (b\u207b\u00b9)\n| refl (x) : rel x x\n| symm (x y) : rel x y \u2192 rel y x\n| trans (x y z) : rel x y \u2192 rel y z \u2192 rel x z\n\n\nvariable (G)\n\ninstance rel_setoid : setoid (adjoin_fun' G) :=\n{ r := rel, iseqv := \u27e8rel.refl, rel.symm, rel.trans\u27e9 } \n\ndef adjoin_fun : Type := quotient (rel_setoid G)\n\ninstance : group (adjoin_fun G) :=\n{ mul := \u03bb x y, quotient.lift_on\u2082 x y (\u03bb x y, quotient.mk (x * y)) \n      (\u03bb a\u2081 a\u2082 b\u2081 b\u2082 h\u2081 h\u2082, quotient.sound (rel.mul h\u2081 h\u2082)),\n  one := quotient.mk o,\n  inv := \u03bb x, quotient.lift_on x (\u03bb x, quotient.mk (x\u207b\u00b9)) \n    (\u03bb a b h, quotient.sound (rel.inv h)),\n  mul_assoc := \u03bb x y z, quotient.induction_on\u2083 x y z\n    (\u03bb x y z, quotient.sound (rel.mul_assoc _ _ _)),\n  mul_one := \u03bb x, quotient.induction_on x \n    (\u03bb x, quotient.sound (rel.mul_one _)),\n  one_mul := \u03bb x, quotient.induction_on x\n    (\u03bb x, quotient.sound (rel.one_mul x)),\n  mul_left_inv := \u03bb x, @quotient.induction_on (adjoin_fun' G)\n    (rel_setoid G) (\u03bb x : adjoin_fun G, \n      quotient.lift_on\u2082 (quotient.lift_on x (\u03bb x, quotient.mk (x\u207b\u00b9))\n      (\u03bb a b h, quotient.sound (rel.inv h))) (x) (\u03bb x y, quotient.mk (x * y))\n      (\u03bb a\u2081 a\u2082 b\u2081 b\u2082 h\u2081 h\u2082, quotient.sound (rel.mul h\u2081 h\u2082)) = \u27e6o\u27e7) _ \n      (\u03bb x, quotient.sound (rel.inv_mul _)) }\n\nvariable {G}\n\ndef of_group : G \u2192* adjoin_fun G :=\nmonoid_hom.mk' \n  (\u03bb x, \u27e6of_group x\u27e7)\n  (\u03bb x y, quotient.sound (rel.is_hom _ _))\n\ndef u : adjoin_fun G \u2192 adjoin_fun G :=\n\u03bb x, quotient.lift_on' x (\u03bb x, \u27e6adjoin_fun'.u x\u27e7) \n  (\u03bb a b h, quotient.sound (rel.u h))\n\nend\n\ndef UMP {H : Type} [group H] (f : G \u2192* H) \n  (u : adjoin_fun G \u2192 H \u2192 H) : adjoin_fun G \u2192* H :=\nmonoid_hom.mk' \n  (\u03bb g, quotient.lift_on g \n    (\u03bb g, show H, from adjoin_fun'.rec_on g \n      f\n      (\u03bb g h, u \u27e6g\u27e7 h)\n      (\u03bb _ _, (*))\n      (\u03bb _ h, h\u207b\u00b9)) \n    (\u03bb x y hxy, begin \n      induction hxy; simp [*, mul_assoc] at *,\n      rw [show \u27e6hxy_a\u27e7 = \u27e6hxy_b\u27e7, from quotient.sound hxy_\u1fb0],\n    end))\n  (\u03bb x y, quotient.induction_on\u2082 x y (\u03bb x y, rfl))\n\nexample {A : Type} : (\u2115 \u2192 A) \u2243 (A \u00d7 (\u2115 \u2192 A \u2192 A)) :=\n{ to_fun := \u03bb f, (f 0, \u03bb n _, f n.succ),\n  inv_fun := \u03bb x n, nat.rec_on n x.1 x.2,\n  left_inv := \u03bb f, begin\n    dsimp,\n    ext n,\n    cases n,\n    { refl },\n    { refl },\n  end,\n  right_inv := begin\n    rintros \u27e8a, f\u27e9,\n    ext1,\n    { refl },\n    { ext n,\n      dsimp, }\n    \n  end }\n\ndef UMP' {H : Type} [group H] (f : adjoin_fun G \u2192* H) : (G \u2192* H) \u00d7 (adjoin_fun G \u2192 H \u2192 H) :=\n\u27e8f.comp of_group, \u03bb g h, f (u g)\u27e9", "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 \u2192 S`, a section `S \u2192 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\u2081xy+a\u2083y=x^3+a\u2082x^2+a\u2084x+a\u2086`, with `a\u1d62 : R`, and such that the discriminant\nof the a\u1d62 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\u00e8s 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\u02e3)\n(disc_unit_eq : (disc_unit : R) = EllipticCurve.disc_aux a1 a2 a3 a4 a6)\n\nnamespace EllipticCurve\n\ninstance : inhabited (EllipticCurve \u211a) := \u27e8\u27e80,0,1,-1,0, \u27e837, 37\u207b\u00b9, by norm_num, by norm_num\u27e9,\n  show (37 : \u211a) = _ + _, by norm_num\u27e9\u27e9\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\u207b\u00b9 : R\u02e3)\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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=irrational_orbit_density (\u03b1 : \u211d) (h1 : \u00ac is_rational \u03b1) : dense_set {r | \u2203 i : \u2124, r = i*\u03b1} :=\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 : \u03b1 \u2260 i*\u03b1 := sorry,\n  have h3 : \u2200 (i j : \u2124), i \u2260 j \u2192 i*\u03b1 \u2260 j*\u03b1, from sorry,\n  have h4 : \u2200 (i j : \u2124), i \u2260 j \u2192 \u00ac (i*\u03b1 = j*\u03b1), from sorry,\n\n  -- Hence\n  let S := {r | \u2203 (i : \u2124), r = i*\u03b1},\n  have h5 : S \u2286 {r | \u2203 (i : \u2124), r = i*\u03b1}, from subset.refl S,\n  have h6 : S = {r | \u2203 (i : \u2124), r = i*\u03b1}, 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 : \u2200 (y : \u211d) (\u03b5), y \u2208 Icc 0 1 \u2192 \u03b5 > 0 \u2192 \u2203 x, x \u2208 S \u2227 \u2203 (N : \u2124), \u2191N*(x - x) \u2264 y \u2227 y < \u2191(N+1)*(x - x) \u2227 \u2191N*(x - x) - y < \u03b5, from sorry,\n\n  -- $S$ has a limit point in $[0, 1]$.\n  have h8 : \u2200 (y : \u211d), y \u2208 Icc 0 1 \u2192 \u2203! (x : \u211d), x \u2208 S \u2227 dist x y < \u03b5, from sorry,\n\n  -- One can thus find pairs of elements of $S$ that are arbitrarily close.\n  have h9 : \u2200 (u : \u211d), \u2203 y, y \u2208 S \u2227 dist u y \u2264 dist u y, from sorry,\n  have h10 : \u2200 (y : \u211d) (\u03b5), y \u2208 Icc 0 1 \u2192 \u03b5 > 0 \u2192 \u2203 x, x \u2208 S \u2227 dist x y < \u03b5, 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 : \u2200 (x y : \u211d), x \u2208 S \u2227 y \u2208 S \u2192 \u2203 x', x' \u2208 S \u2227 \u2203 (n : \u2124) \u2208 set.range (\u03bb (n : \u2124), (n : \u2124)), n*(x - y) = x', from sorry,\n  have h12 : \u2200 (y : \u211d) (\u03b5), y \u2208 Icc 0 1 \u2192 \u03b5 > 0 \u2192 \u2203 x, x \u2208 S \u2227 dist x y < \u03b5, from sorry,\n\n  -- By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h13 : \u2200 (y : \u211d), y \u2208 Icc 0 1 \u2192 \u2203! (x : \u211d), x \u2208 S \u2227 dist x y < \u03b5, from sorry,\n  have h14 : \u2200 (y : \u211d) (\u03b5), y \u2208 Icc 0 1 \u2192 \u03b5 > 0 \u2192 \u2203 x, x \u2208 S \u2227 dist x y < \u03b5, from sorry,\n\n  -- It follows that $0$ is a limit point of $S$.\n  have h15 : \u2200 (y : \u211d) (\u03b5), y \u2208 Icc 0 1 \u2192 \u03b5 > 0 \u2192 \u2203 x, x \u2208 S \u2227 dist x y < \u03b5, from sorry,\n\n  sorry,\nend\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit : \u2200 \u03b1 : \u211a, \u03b1.irrational \u2192 \u2203 S : set \u211d, (\u2200 i : \u2124, i \u2208 \u2124 \u2192 (i : \u211a) = \u211a.of_int i \u2227 \u211a.of_int i * \u03b1 \u2208 \u211d) \u2227 (\u2203 N : \u2115, \u2200 i : \u2124, (i \u2208 \u2124 \u2227 \u2124.pos_of_nat N \u2264 i) \u2192 \u211a.of_int i \u2208 S) \u2227 (\u2203 N1 : \u2115, \u2200 i : \u2124, (i \u2208 \u2124 \u2227 i \u2264 \u2124.neg_succ_of_nat N1) \u2192 \u211a.of_int i \u2208 S) :=\nbegin\n  assume \u03b1 h1,\n  let S : set \u211d := (\u03bb a : \u2124, \u2124.to_rat a * \u03b1),\n  have h2 : \u2200 (i : \u2124), i \u2208 \u2124 \u2192 \u2124.to_rat i * \u03b1 \u2208 \u211d, from sorry,\n  have h3 : \u2203 N : \u2115, \u2200 i : \u2124, (i \u2208 \u2124 \u2227 \u2124.pos_of_nat N \u2264 i) \u2192 \u211a.of_int i \u2208 S, from sorry,\n  have h4 : \u2203 N1 : \u2115, \u2200 i : \u2124, (i \u2208 \u2124 \u2227 i \u2264 \u2124.neg_succ_of_nat N1) \u2192 \u211a.of_int i \u2208 S, from sorry,\n  use {\u03b1 : \u2124 | (\u03b1 \u2208 \u2124 \u2227 \u2124.to_rat \u03b1 * \u03b1 \u2208 \u211d)},\n  have h5 : \u2200 i : \u2124, i \u2208 \u2124 \u2192 (i : \u211a) = \u211a.of_int i \u2227 \u211a.of_int i * \u03b1 \u2208 \u211d, from sorry,\n  have h6 : \u2203 N : \u2115, \u2200 i : \u2124, (i \u2208 \u2124 \u2227 \u2124.pos_of_nat N \u2264 i) \u2192 \u211a.of_int i \u2208 S, from sorry,\n  have h7 : \u2203 N1 : \u2115, \u2200 i : \u2124, (i \u2208 \u2124 \u2227 i \u2264 \u2124.neg_succ_of_nat N1) \u2192 \u211a.of_int i \u2208 S, from sorry,\n  sorry,\nend\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_irrational_orbit (a : \u211d) (h1 : \u00ac is_rat a) : \n(\u2200 i j : \u2124, i \u2260 j \u2192 ((a*i) - (floor (a*i))) \u2260 ((a*j) -(floor (a*j)))):= \nbegin\n  assume (hi : \u2200 i j : \u2124, i \u2260 j \u2192 ((a*i) - (floor (a*i))) \u2260 ((a*j) -(floor (a*j)))),\n\n  sorry,\nend\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u03b1 \u2260 0) : \u2203 N : \u2115, \u2200 (x : \u211d) (hx : 0 \u2264 x \u2227 x < 1), \u2203 n \u2265 N, \u2203\u2081 (i : \u2124), \u2203 (j : \u2124), i < j \u2227 i = n*N \u2227 j = n*N + 1 \u2227 (x - i*\u03b1)*(x - j*\u03b1) < 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 : \u2200 (i1 i2 : \u2124), \u00ac ((i1 \u2260 i2) \u2227 (i1 * \u03b1 - i1 : \u2124) * \u03b1 = (i2 * \u03b1 - i2 : \u2124) * \u03b1),\n  from sorry,\n  \n  --Let $S$ be the set $\\{\\{i \\alpha\\} \\mid \\forall i \\in \\mathbb{Z}\\}$\n  let S : set \u211d := sorry,\n  \n  -- $S$ is an infinite subset of $\\left[0,1\\right]$\n  have h2 : \u2200 x : \u211d, x \u2208 S \u2192 0 \u2264 x \u2227 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 : \u2203 x : \u211d, x \u2208  ['0,1] \u2227 \u2200 \u03b5 > 0, \u2203 y \u2208 S, y \u2260 x \u2227 abs (y - x) < \u03b5,\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 : \u2203 x : \u211d, x \u2208  ['0,1] \u2227 \u2200 \u03b5 > 0, \u2203 y \u2208 S, y \u2260 x \u2227 abs (y - x) < \u03b5 \u2227 0 \u2208 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 : \u2200 (y : \u211d) (\u03b5 : \u211d) (hy : 0 \u2264 y \u2227 y < 1) (h\u03b5 : \u03b5 > 0), \u2203 (x : \u211d), x \u2208 S \u2227 x \u2260 0 \u2227 abs (x - 0) < \u03b5 \u2227 0 \u2208 S \u2227 \n    \u2203 N : \u2115, \u2203 n \u2265 N,\n      \u2203 (i : \u2124), \u2203 (j : \u2124), i < j \u2227 i = n*N \u2227 j = n*N + 1 \u2227 (y - i*\u03b1)*(y - j*\u03b1) < 0,\n  from sorry,\n  show \u2203 N : \u2115, \u2200 (x : \u211d) (hx : 0 \u2264 x \u2227 x < 1), \u2203 n \u2265 N, \u2203\u2081 (i : \u2124), \u2203 (j : \u2124), i < j \u2227 i = n*N \u2227 j = n*N + 1 \u2227 (x - i*\u03b1)*(x - j*\u03b1) < 0, \n  from sorry,\nend\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) : \u00ac is_rational \u03b1 \u2192 \u2200 a : \u2124, \u2203 b : \u2124, \u2200 c : \u2124, a \u2260 c \u2192 b * \u03b1 \u2260 c * \u03b1 := \nbegin\n    assume (h1 : \u00ac is_rational \u03b1) (a : \u2124),\n    have h5 : \u2200 a b : \u2124, a \u2260 b \u2192 \u00ac (a / b : \u211d) = \u03b1, from sorry,\n    have h2 : \u2200 n : \u2124, \u2203 m : \u2124, ((n / (m : \u2115) : \u211d) : \u211d) \u2260 \u03b1, from sorry,\n\n    have h3 : \u2200 m n : \u2124, n \u2260 0 \u2192 m \u2260 n * m, from sorry,\n    \n    have h4 : \u2200 m n : \u2124, \u2203 (p : \u2124), (p \u2260 m) \u2227 (p \u2260 n * m), from sorry,\n\n    sorry,\nend\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u03b1 \u2209 \u211a) : \n\u2200 \u03b5 > 0, \u2203 (n : \u2115), \u2203 (m : \u2124), |((n : \u2115) : \u211d) * \u03b1 + (m : \u2124) | < \u03b5 :=\nbegin\n  --Let $\\alpha$ be an irrational number. \n  have h1 : (\u03b1 \u2208 \u211a) \u2192 false, from sorry,\n  have h2 : (\u03b1 \u2209 \u211a) := sorry,\n\n  --Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  have h3 : (\u2200 (i j : \u2124) (hi : i \u2260 j), ((i : \u211d) * \u03b1) % 1 \u2260 ((j : \u211d) * \u03b1) % 1) := sorry,\n\n  --If this were not true, then $\\{i \\alpha\\} = \\{j \\alpha\\}$ \n  have h4 : (\u2200 (i j : \u2124) (hi : i \u2260 j), ((i : \u211d) * \u03b1) % 1 = ((j : \u211d) * \u03b1) % 1) \u2192 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 : (\u2200 (i j : \u2124) (hi : i \u2260 j), (((i : \u211d) * \u03b1) % 1 = ((j : \u211d) * \u03b1) % 1) \u2192 (\u03b1 \u2208 \u211a)) \u2192 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 : (\u2200 i : \u2124, (i : \u211d) * \u03b1 \u2208 {n | 0 \u2264 n \u2227 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 : \u2115) : \u211d) * \u03b1 + (m : \u2124) | < \u03b5$\n  have h27 := sorry,\n  have h28 := sorry,\n  have h29 := sorry,\n\n  have h30 : \u2203 (n : \u2115), \u2203 (m : \u2124), |((n : \u2115) : \u211d) * \u03b1 + (m : \u2124) | < \u03b5, from sorry,\n\n  show \u2200 \u03b5 > 0, \u2203 (n : \u2115), \u2203 (m : \u2124), |((n : \u2115) : \u211d) * \u03b1 + (m : \u2124) | < \u03b5, \n  from sorry,\nend\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) :\nlet orbit : \u2124 \u2192 \u211d := \u03bb i : \u2124, (i * \u03b1) % 1 in\n(\u2200 i j : \u2124, i \u2260 j \u2192 (orbit i) \u2260 (orbit j)) \u2227 (\u2203 l : \u211d, l \u2208 orbit '' (range (1 : \u2124)), \u2200 y : \u211d, y \u2208 Icc (0 : \u211d) (1 : \u211d) \u2192 \u2203 i : \u2124, |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 : \u2200 i j : \u2124, i \u2260 j \u2192 ((i * \u03b1) % 1) \u2260 ((j * \u03b1) % 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 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac (i * \u03b1 - floor (i * \u03b1) = ((j * \u03b1) % 1) \u2227 ((i * \u03b1) % 1) = ((j * \u03b1) % 1) \u2227 (j * \u03b1 - floor (j * \u03b1) = ((j * \u03b1) % 1)):= \n  begin\n    assume (i j : \u2124) (h2 : i \u2260 j) (h3 : i * \u03b1 - floor (i * \u03b1) = ((j * \u03b1) % 1) \u2227 ((i * \u03b1) % 1) = ((j * \u03b1) % 1) \u2227 (j * \u03b1 - floor (j * \u03b1) = ((j * \u03b1) % 1)),\n    have h3 : i * \u03b1 - floor (i * \u03b1) = ((j * \u03b1) % 1), from sorry,\n    have h4 : ((i * \u03b1) % 1) = ((j * \u03b1) % 1), from sorry,\n    have h5 : j * \u03b1 - floor (j * \u03b1) = ((j * \u03b1) % 1), from sorry,\n    have h6 : i * \u03b1 - floor (i * \u03b1) = (j * \u03b1 - floor (j * \u03b1)), from sorry,\n    have h7 : i * \u03b1 = j * \u03b1, from sorry,\n    have h8 : \u03b1 = j / i, by {\n      rw \u2190 @int.cast_mul \u211d _ _ i j at h7,\n      rw \u2190 @int.cast_mul \u211d _ _ j i at h7,\n      exact h7,\n    },\n    have h9 : \u03b1 \u2208 \u211a,\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 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac (i * \u03b1 - floor (i * \u03b1) = ((j * \u03b1) % 1)), from sorry,\n  have h4 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac ((i * \u03b1) % 1) = ((j * \u03b1) % 1)), from sorry,\n  have h5 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac (j * \u03b1 - floor (j * \u03b1) = ((j * \u03b1) % 1)), from sorry,\n  have h6 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac (i * \u03b1 - floor (i * \u03b1) = (j * \u03b1 - floor (j * \u03b1))), from sorry,\n  have h7 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac (i * \u03b1 = j * \u03b1), from sorry,\n  have h8 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac (\u03b1 = j / i), from sorry,\n  have h9 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac (\u03b1 \u2208 \u211a), 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 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac (\u03b1 = (floor (i * \u03b1) - floor (j * \u03b1)) / (i - j)), from sorry,\n  have h11 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac ((\u03b1 = (floor (i * \u03b1) - floor (j * \u03b1)) / (i - j)) \u2227 \u03b1 \u2208 \u211a), from sorry,\n  have h12 : \u2200 i j : \u2124, i \u2260 j \u2192 \u00ac \u03b1 \u2208 \u211a, 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 : (\u2203 i : \u2124, ((i * \u03b1) % 1) \u2208 Icc (0 : \u211d) (1 : \u211d)),\n  from sorry,\n  \n  have h14 : (\u2203 S : set (\u211d), S = {((i * \u03b1) % 1) | i : \u2124} \u2227 S \u2260 \u2205 \u2227 \u2200 x, x \u2208 Icc (0 : \u211d) (1 : \u211d) \u2192 \u2203 i : \u2124, ((i * \u03b1) % 1) = x),\n  from sorry,\n  \n  have h15 : (\u2203 S : set (\u211d), S = {((i * \u03b1) % 1) | i : \u2124} \u2227 S \u2260 \u2205),\n  from sorry,\n  \n  have h16 : (\u2203 S : set (\u211d), S = {((i * \u03b1) % 1) | i : \u2124} \u2227 S \u2260 \u2205 \u2227 \u2200 x, x \u2208 Icc (0 : \u211d) (1 : \u211d) \u2192 \u2203 i : \u2124, ((i * \u03b1) % 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 : \u2203 l : \u211d, l \u2208 orbit '' (range (1 : \u2124)), l \u2208 Icc (0 : \u211d) (1 : \u211d) \u2227 \u2200 \u03b5 > 0, \u2203 i : \u2124, i \u2208 range (1 : \u2124) \u2227 |l - (orbit i)| < \u03b5,\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 : \u2203 l : \u211d, l \u2208 orbit '' (range (1 : \u2124)), l \u2208 Icc (0 : \u211d) (1 : \u211d) \u2227 \u2200 \u03b5 > 0, \u2203 i : \u2124, i \u2208 range (1) \u2227 |l - (orbit i)| < \u03b5 \u2227 (\u2200 j : \u2124, j \u2208 range (1) \u2192 |(orbit i) - (orbit j)| < \u03b5),\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 : \u2200 y : \u211d, y \u2208 Icc (0 : \u211d) (1 : \u211d) \u2192 \u2200 \u03b5 > 0, \u2203 i : \u2124, i \u2208 range (1) \u2227 |y - (orbit i)| < \u03b5 \u2227 (\u2200 j\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit {\u03b1 : Type*} [linear_ordered_field \u03b1] (\u03b1 : \u03b1) (h1 : \u03b1.irrational) : \n\u2200 \u03b5 > 0, \u2203 x : \u03b1, 0 \u2264 x \u2227 x < \u03b5 :=\nbegin\n  assume (\u03b5 : \u03b1) (h\u03b5 : \u03b5 > 0),\n  use 0,\n  show 0 \u2264 0 \u2227 0 < \u03b5, from sorry,\nend\n\n--OUTPUT 9\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_irrational_orbit (\u03b1 : \u211d) (h1 : irrational \u03b1) : \n\u2200 \u03b5 > 0, \u2203 (m : \u2124), |m * \u03b1 - \u230am * \u03b1\u230b| < \u03b5 :=\nbegin\n  assume \u03b5 h2,\n  have h3 : \u2203 N : \u2115, \u2200 (n : \u2115) (h4 : n > N), (n : \u2115) * \u03b1 - \u230a(n : \u2115) * \u03b1\u230b < \u03b5, 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 : \u2115) > N, begin rw h6, exact and.left h6, end,\n  have h8 : (n : \u2115) * \u03b1 - \u230a(n : \u2115) * \u03b1\u230b < \u03b5, 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) [irrational \u03b1] : \u2203 a \u2208 \u2124, (a : \u211d) = \u03b1 :=\nbegin\n    -- We need to show that $\\exists a \u2208 \u2124, (a : \u211d) = \u03b1$.\n    -- We suppose that there doesn't exist $a \u2208 \u2124, (a : \u211d) = \u03b1$ and derive a contradiction.\n\n    -- Assume there does not exist an integer $a$ such that $(a : \u211d) = \u03b1$.\n    assume h : \u2200 a : \u2124, (a : \u211d) \u2260 \u03b1,\n\n    -- We consider the set $A := \\{(a : \u211d) \\mid a \u2208 \u2124\\}$.\n    let A := {(a : \u211d) | a \u2208 \u2124},\n\n    -- We show that $\\forall x \u2208 \u211d, \u2203 y \u2208 A, y = \u03b1$.\n    suffices h1 : \u2200 x : \u211d, \u2203 y \u2208 A, y = \u03b1, by use (h1 \u03b1),\n\n    -- Assume there exists $x \u2208 \u211d$ such that $\\forall y \u2208 A, y \u2260 \u03b1$.\n    assume h2 : \u2203 x : \u211d, \u2200 y \u2208 A, y \u2260 \u03b1,\n\n    -- We consider the set $A_0 := \\{x \u2208 \u211d \\mid \u2200 y \u2208 A, y \u2260 \u03b1\\}$.\n    let A0 := {x : \u211d | \u2200 y \u2208 A, y \u2260 \u03b1},\n\n    -- We show that $A0 \u2260 \u2205$.\n    suffices h3 : A0 \u2260 \u2205, by use h3,\n\n    -- We show that if $x \u2208 A0$, then $x \u2260 \u03b1$.\n    suffices h4 : \u2200 x : \u211d, x \u2208 A0 \u2192 x \u2260 \u03b1,\n\n    -- We show that if $x = \u03b1$, then $x \u2209 A0$.\n    suffices h5 : \u2200 x : \u211d, x = \u03b1 \u2192 x \u2209 A0,\n\n    -- Hence, supposing $A0 = \u2205$, we derive a contradiction.\n    suffices h6 : A0 = \u2205, from absurd h2 \u27e8\u03b1, h5, h6\u27e9,\n\n    -- Assume $x = \u03b1$.\n    assume h7 : \u2200 x : \u211d, x = \u03b1 \u2192 x \u2209 A0,\n\n    -- Assume $x \u2208 A0$.\n    assume h8 : \u2200 x : \u211d, x \u2208 A0 \u2192 x \u2260 \u03b1,\n\n    -- We show that $\u2203 y \u2208 A, y = \u03b1$\n    suffices h9 : \u2203 y \u2208 A, y = \u03b1, by use h9,\n\n    -- We show that if $y \u2208 A$, then $y = \u03b1$.\n    suffices h10 : \u2200 y : \u211d, y \u2208 A \u2192 y = \u03b1,\n\n    -- We consider the set $A_1 := \\{y \u2208 \u211d \\mid y \u2208 A \u2192 y = \u03b1\\}$.\n    let A1 := {y : \u211d | y \u2208 A \u2192 y = \u03b1},\n\n    -- We show that $A1 \u2260 \u2205$.\n    suffices h11 : A1 \u2260 \u2205, by use h11,\n\n    -- We show that if $y \u2208 A1$, then $y \u2208 A$.\n    suffices h12 : \u2200 y : \u211d, y \u2208 A1 \u2192 y \u2208 A,\n\n    -- We show that if $y \u2208 A$, then $y \u2208 A1$.\n    suffices h13 : \u2200 y : \u211d, y \u2208 A \u2192 y \u2208 A1,\n\n    -- Hence, supposing $A1 = \u2205$, we derive a contradiction.\n    suffices h14 : A1 = \u2205, from absurd h10 \u27e8\u03b1, h13, h14\u27e9,\n\n    -- Assume $y \u2208 A$.\n    assume h15 : \u2200 y : \u211d, y \u2208 A \u2192 y \u2208 A1,\n\n    -- Assume $y \u2208 A1$.\n    assume h16 : \u2200 y : \u211d, y \u2208 A1 \u2192 y \u2208 A,\n\n    -- We show that $\u2203 y \u2208 A, y = \u03b1$\n    suffices h17 : \u2203 y \u2208 A, y = \u03b1, by use h17,\n\n    -- We show that if $y \u2208 A$, then $y = \u03b1$.\n    suffices h18 : \u2200 y : \u211d, y \u2208 A \u2192 y = \u03b1,\n\n    -- We consider the set $A_2 := \\{y \u2208 \u211d \\mid y \u2208 A \u2192 y = \u03b1\\}$.\n    let A2 := {y : \u211d | y \u2208 A \u2192 y = \u03b1},\n\n    -- We show that $A2 \u2260 \u2205$.\n    suffices h19 : A2 \u2260 \u2205, by use h19,\n\n    -- We show that if $y \u2208 A2$, then $y \u2208 A$.\n    suffices h20 : \u2200 y : \u211d, y \u2208 A2 \u2192 y \u2208 A,\n\n    -- We show that if $y \u2208 A$, then $y \u2208 A2$.\n    suffices h21 : \u2200 y : \u211d, y \u2208 A \u2192 y \u2208 A2,\n\n    -- Hence, supposing $A2 = \u2205$, we derive a contradiction.\n    suffices h22 : A2 = \u2205, from absurd h18 \u27e8\u03b1, h21, h22\u27e9,\n\n    -- Assume $y \u2208 A$.\n    assume h23 : \u2200 y : \u211d, y \u2208 A \u2192 y \u2208 A2,\n\n    -- Assume $y \u2208 A2$.\n    assume h24 : \u2200 y : \u211d, y \u2208 A2 \u2192 y \u2208 A,\n\n    -- We show that $\u2203 y \u2208 A, y = \u03b1$\n    suffices h25 : \u2203 y \u2208 A, y = \u03b1, by use h25,\n\n    -- We show that if $y \u2208 A$, then $y = \u03b1$.\n    suffices h26 : \u2200 y : \u211d, y \u2208 A \u2192 y = \u03b1,\n\n    -- We consider the set $A_3 := \\{y \u2208 \u211d \\mid y \u2208 A \u2192 y = \u03b1\\}$.\n    let A3 := {y : \u211d | y \u2208 A \u2192 y = \u03b1},\n\n    -- We show that $A3 \u2260 \u2205$.\n    suffices h27 : A3 \u2260 \u2205, by use h27,\n\n    -- We show that if $y \u2208 A3$, then $y \u2208 A$.\n    suffices h28 : \u2200 y : \u211d, y \u2208 A3 \u2192 y \u2208 A,\n\n    -- We show that if $y \u2208 A$, then $y \u2208 A3$.\n    suffices h29 : \u2200 y : \u211d, y \u2208 A \u2192 y \u2208 A3,\n\n    -- Hence, supposing $A3 = \u2205$, we derive a contradiction.\n    suffices h30 : A3 = \u2205, from absurd h26 \u27e8\u03b1, h29, h30\u27e9,\n\n    -- Assume $y \u2208 A$.\n    assume h31 : \u2200 y : \u211d, y \u2208 A \u2192 y \u2208 A3,\n\n    -- Assume $y \u2208 A3$.\n    assume h32 : \u2200 y : \u211d, y \u2208 A3 \u2192 y \u2208 A,\n\n    -- We show that $\u2203 y \u2208 A, y = \u03b1$\n    suffices h33 : \u2203 y \u2208 A, y = \u03b1, by use h33,\n\n    -- We show that if $y \u2208 A$, then $y = \u03b1$.\n    suffices h34 : \u2200 y : \u211d, y \u2208 A \u2192 y = \u03b1,\n\n    -- We consider the set $A_4 := \\{y \u2208 \u211d \\mid y \u2208 A \u2192 y = \u03b1\\}$.\n    let A4 := {y : \u211d | y \u2208 A \u2192 y = \u03b1},\n\n    -- We show that $A4 \u2260 \u2205$.\n    suffices h35 : A4 \u2260 \u2205, by use h35,\n\n    -- We show that if $y \u2208 A4$, then $y \u2208 A$.\n    suffices h36 : \u2200 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from sorry,\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : \u03b5 > 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 \u03b5 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 \u03b5 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 : \u2200 n > N, n > N1 \u2227 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 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \n  from sorry,\n    \n  --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n  have h15 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \n  from sorry,\n\n  --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n  --Hence the result\n  show  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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 `\u03b1 \u2295 \u03b2`\n    and the sigma-type `\u03a3 b : bool, cond b \u03b1 \u03b2`;\n\n  - `equiv.prod_sum_distrib : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243 (\u03b1 \u00d7 \u03b2) \u2295 (\u03b1 \u00d7 \u03b3)` 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 : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082`: combine two equivalences `ea : \u03b1\u2081 \u2243 \u03b1\u2082` and\n    `eb : \u03b2\u2081 \u2243 \u03b2\u2082` 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 {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w}\n\nnamespace Equiv\n\n#print Equiv.pprodEquivProd /-\n/-- `pprod \u03b1 \u03b2` is equivalent to `\u03b1 \u00d7 \u03b2` -/\n@[simps apply symm_apply]\ndef pprodEquivProd {\u03b1 \u03b2 : Type _} : PProd \u03b1 \u03b2 \u2243 \u03b1 \u00d7 \u03b2\n    where\n  toFun x := (x.1, x.2)\n  invFun x := \u27e8x.1, x.2\u27e9\n  left_inv := fun \u27e8x, y\u27e9 => rfl\n  right_inv := fun \u27e8x, y\u27e9 => 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 `\u03b1 \u2243 \u03b2` and `\u03b3 \u2243 \u03b4`, then\n`pprod \u03b1 \u03b3 \u2243 pprod \u03b2 \u03b4`. -/\n@[congr, simps apply]\ndef pprodCongr {\u03b4 : Sort z} (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b3 \u2243 \u03b4) : PProd \u03b1 \u03b3 \u2243 PProd \u03b2 \u03b4\n    where\n  toFun x := \u27e8e\u2081 x.1, e\u2082 x.2\u27e9\n  invFun x := \u27e8e\u2081.symm x.1, e\u2082.symm x.2\u27e9\n  left_inv := fun \u27e8x, y\u27e9 => by simp\n  right_inv := fun \u27e8x, y\u27e9 => 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 {\u03b1\u2081 : Sort.{u1}} {\u03b2\u2081 : Sort.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{u1, succ u3} \u03b1\u2081 \u03b1\u2082) -> (Equiv.{u2, succ u4} \u03b2\u2081 \u03b2\u2082) -> (Equiv.{max 1 u1 u2, max (succ u3) (succ u4)} (PProd.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u3, u4} \u03b1\u2082 \u03b2\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Sort.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Sort.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{u1, succ u2} \u03b1\u2081 \u03b2\u2081) -> (Equiv.{u3, succ u4} \u03b1\u2082 \u03b2\u2082) -> (Equiv.{max (max 1 u3) u1, max (succ u4) (succ u2)} (PProd.{u1, u3} \u03b1\u2081 \u03b1\u2082) (Prod.{u2, u4} \u03b2\u2081 \u03b2\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.pprod_prod Equiv.pprodProd\u2093'. -/\n/-- Combine two equivalences using `pprod` in the domain and `prod` in the codomain. -/\n@[simps apply symm_apply]\ndef pprodProd {\u03b1\u2081 \u03b2\u2081 : Sort _} {\u03b1\u2082 \u03b2\u2082 : Type _} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    PProd \u03b1\u2081 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082 :=\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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Sort.{u3}} {\u03b2\u2082 : Sort.{u4}}, (Equiv.{succ u1, u3} \u03b1\u2081 \u03b1\u2082) -> (Equiv.{succ u2, u4} \u03b2\u2081 \u03b2\u2082) -> (Equiv.{max (succ u1) (succ u2), max 1 u3 u4} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (PProd.{u3, u4} \u03b1\u2082 \u03b2\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Sort.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Sort.{u4}}, (Equiv.{succ u1, u2} \u03b1\u2081 \u03b2\u2081) -> (Equiv.{succ u3, u4} \u03b1\u2082 \u03b2\u2082) -> (Equiv.{max (succ u3) (succ u1), max (max 1 u4) u2} (Prod.{u1, u3} \u03b1\u2081 \u03b1\u2082) (PProd.{u2, u4} \u03b2\u2081 \u03b2\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_pprod Equiv.prodPProd\u2093'. -/\n/-- Combine two equivalences using `pprod` in the codomain and `prod` in the domain. -/\n@[simps apply symm_apply]\ndef prodPProd {\u03b1\u2081 \u03b2\u2081 : Type _} {\u03b1\u2082 \u03b2\u2082 : Sort _} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 PProd \u03b1\u2082 \u03b2\u2082 :=\n  (ea.symm.pprodProd eb.symm).symm\n#align equiv.prod_pprod Equiv.prodPProd\n\n#print Equiv.pprodEquivProdPLift /-\n/-- `pprod \u03b1 \u03b2` is equivalent to `plift \u03b1 \u00d7 plift \u03b2` -/\n@[simps apply symm_apply]\ndef pprodEquivProdPLift {\u03b1 \u03b2 : Sort _} : PProd \u03b1 \u03b2 \u2243 PLift \u03b1 \u00d7 PLift \u03b2 :=\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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{succ u1, succ u3} \u03b1\u2081 \u03b1\u2082) -> (Equiv.{succ u2, succ u4} \u03b2\u2081 \u03b2\u2082) -> (Equiv.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u3, u4} \u03b1\u2082 \u03b2\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) -> (Equiv.{succ u3, succ u4} \u03b1\u2082 \u03b2\u2082) -> (Equiv.{max (succ u3) (succ u1), max (succ u4) (succ u2)} (Prod.{u1, u3} \u03b1\u2081 \u03b1\u2082) (Prod.{u2, u4} \u03b2\u2081 \u03b2\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr Equiv.prodCongr\u2093'. -/\n/-- Product of two equivalences. If `\u03b1\u2081 \u2243 \u03b1\u2082` and `\u03b2\u2081 \u2243 \u03b2\u2082`, then `\u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082`. This is\n`prod.map` as an equivalence. -/\n@[congr, simps (config := { fullyApplied := false }) apply]\ndef prodCongr {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Type _} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082 :=\n  \u27e8Prod.map e\u2081 e\u2082, Prod.map e\u2081.symm e\u2082.symm, fun \u27e8a, b\u27e9 => by simp, fun \u27e8a, b\u27e9 => by simp\u27e9\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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}} (e\u2081 : Equiv.{succ u1, succ u3} \u03b1\u2081 \u03b1\u2082) (e\u2082 : Equiv.{succ u2, succ u4} \u03b2\u2081 \u03b2\u2082), 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} \u03b1\u2082 \u03b2\u2082) (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u3, u4} \u03b1\u2082 \u03b2\u2082) (Equiv.prodCongr.{u1, u2, u3, u4} \u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 e\u2081 e\u2082)) (Equiv.prodCongr.{u3, u4, u1, u2} \u03b1\u2082 \u03b2\u2082 \u03b1\u2081 \u03b2\u2081 (Equiv.symm.{succ u1, succ u3} \u03b1\u2081 \u03b1\u2082 e\u2081) (Equiv.symm.{succ u2, succ u4} \u03b2\u2081 \u03b2\u2082 e\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u4}} {\u03b2\u2081 : Type.{u3}} {\u03b1\u2082 : Type.{u2}} {\u03b2\u2082 : Type.{u1}} (e\u2081 : Equiv.{succ u4, succ u3} \u03b1\u2081 \u03b2\u2081) (e\u2082 : Equiv.{succ u2, succ u1} \u03b1\u2082 \u03b2\u2082), 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} \u03b2\u2081 \u03b2\u2082) (Prod.{u4, u2} \u03b1\u2081 \u03b1\u2082)) (Equiv.symm.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Prod.{u4, u2} \u03b1\u2081 \u03b1\u2082) (Prod.{u3, u1} \u03b2\u2081 \u03b2\u2082) (Equiv.prodCongr.{u4, u3, u2, u1} \u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 e\u2081 e\u2082)) (Equiv.prodCongr.{u3, u4, u1, u2} \u03b2\u2081 \u03b1\u2081 \u03b2\u2082 \u03b1\u2082 (Equiv.symm.{succ u4, succ u3} \u03b1\u2081 \u03b2\u2081 e\u2081) (Equiv.symm.{succ u2, succ u1} \u03b1\u2082 \u03b2\u2082 e\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_symm Equiv.prodCongr_symm\u2093'. -/\n@[simp]\ntheorem prodCongr_symm {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Type _} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    (prodCongr e\u2081 e\u2082).symm = prodCongr e\u2081.symm e\u2082.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: `\u03b1 \u00d7 \u03b2 \u2243 \u03b2 \u00d7 \u03b1`. This is `prod.swap` as an\nequivalence.-/\ndef prodComm (\u03b1 \u03b2 : Type _) : \u03b1 \u00d7 \u03b2 \u2243 \u03b2 \u00d7 \u03b1 :=\n  \u27e8Prod.swap, Prod.swap, Prod.swap_swap, Prod.swap_swap\u27e9\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 (\u03b1 : Type.{u1}) (\u03b2 : Type.{u2}), Eq.{max (max (succ u1) (succ u2)) (succ u2) (succ u1)} ((Prod.{u1, u2} \u03b1 \u03b2) -> (Prod.{u2, u1} \u03b2 \u03b1)) (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} \u03b1 \u03b2) (Prod.{u2, u1} \u03b2 \u03b1)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u2, u1} \u03b2 \u03b1)) => (Prod.{u1, u2} \u03b1 \u03b2) -> (Prod.{u2, u1} \u03b2 \u03b1)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u2, u1} \u03b2 \u03b1)) (Equiv.prodComm.{u1, u2} \u03b1 \u03b2)) (Prod.swap.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall (\u03b1 : Type.{u2}) (\u03b2 : Type.{u1}), Eq.{max (succ u1) (succ u2)} (forall (\u1fb0 : Prod.{u2, u1} \u03b1 \u03b2), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Prod.{u1, u2} \u03b2 \u03b1) \u1fb0) (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} \u03b1 \u03b2) (Prod.{u1, u2} \u03b2 \u03b1)) (Prod.{u2, u1} \u03b1 \u03b2) (fun (_x : Prod.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Prod.{u1, u2} \u03b2 \u03b1) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} \u03b1 \u03b2) (Prod.{u1, u2} \u03b2 \u03b1)) (Equiv.prodComm.{u2, u1} \u03b1 \u03b2)) (Prod.swap.{u2, u1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_prod_comm Equiv.coe_prodComm\u2093'. -/\n@[simp]\ntheorem coe_prodComm (\u03b1 \u03b2 : Type _) : \u21d1(prodComm \u03b1 \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (x : Prod.{u1, u2} \u03b1 \u03b2), Eq.{max (succ u2) (succ u1)} (Prod.{u2, u1} \u03b2 \u03b1) (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} \u03b1 \u03b2) (Prod.{u2, u1} \u03b2 \u03b1)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u2, u1} \u03b2 \u03b1)) => (Prod.{u1, u2} \u03b1 \u03b2) -> (Prod.{u2, u1} \u03b2 \u03b1)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u2, u1} \u03b2 \u03b1)) (Equiv.prodComm.{u1, u2} \u03b1 \u03b2) x) (Prod.swap.{u1, u2} \u03b1 \u03b2 x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (x : Prod.{u2, u1} \u03b1 \u03b2), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Prod.{u1, u2} \u03b2 \u03b1) 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} \u03b1 \u03b2) (Prod.{u1, u2} \u03b2 \u03b1)) (Prod.{u2, u1} \u03b1 \u03b2) (fun (_x : Prod.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Prod.{u1, u2} \u03b2 \u03b1) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} \u03b1 \u03b2) (Prod.{u1, u2} \u03b2 \u03b1)) (Equiv.prodComm.{u2, u1} \u03b1 \u03b2) x) (Prod.swap.{u2, u1} \u03b1 \u03b2 x)\nCase conversion may be inaccurate. Consider using '#align equiv.prod_comm_apply Equiv.prodComm_apply\u2093'. -/\n@[simp]\ntheorem prodComm_apply {\u03b1 \u03b2 : Type _} (x : \u03b1 \u00d7 \u03b2) : prodComm \u03b1 \u03b2 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 (\u03b1 : Type.{u1}) (\u03b2 : 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} \u03b2 \u03b1) (Prod.{u1, u2} \u03b1 \u03b2)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u2, u1} \u03b2 \u03b1) (Equiv.prodComm.{u1, u2} \u03b1 \u03b2)) (Equiv.prodComm.{u2, u1} \u03b2 \u03b1)\nbut is expected to have type\n  forall (\u03b1 : Type.{u2}) (\u03b2 : Type.{u1}), Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} \u03b2 \u03b1) (Prod.{u2, u1} \u03b1 \u03b2)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} \u03b1 \u03b2) (Prod.{u1, u2} \u03b2 \u03b1) (Equiv.prodComm.{u2, u1} \u03b1 \u03b2)) (Equiv.prodComm.{u1, u2} \u03b2 \u03b1)\nCase conversion may be inaccurate. Consider using '#align equiv.prod_comm_symm Equiv.prodComm_symm\u2093'. -/\n@[simp]\ntheorem prodComm_symm (\u03b1 \u03b2) : (prodComm \u03b1 \u03b2).symm = prodComm \u03b2 \u03b1 :=\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 (\u03b1 \u03b2 \u03b3 : Sort _) : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243 \u03b1 \u00d7 \u03b2 \u00d7 \u03b3 :=\n  \u27e8fun p => (p.1.1, p.1.2, p.2), fun p => ((p.1, p.2.1), p.2.2), fun \u27e8\u27e8a, b\u27e9, c\u27e9 => rfl,\n    fun \u27e8a, \u27e8b, c\u27e9\u27e9 => rfl\u27e9\n#align equiv.prod_assoc Equiv.prodAssoc\n-/\n\n#print Equiv.curry /-\n/-- Functions on `\u03b1 \u00d7 \u03b2` are equivalent to functions `\u03b1 \u2192 \u03b2 \u2192 \u03b3`. -/\n@[simps (config := { fullyApplied := false })]\ndef curry (\u03b1 \u03b2 \u03b3 : Type _) : (\u03b1 \u00d7 \u03b2 \u2192 \u03b3) \u2243 (\u03b1 \u2192 \u03b2 \u2192 \u03b3)\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 (\u03b1 : Type.{u2}), Equiv.{max (succ u2) (succ u1), succ u2} (Prod.{u2, u1} \u03b1 PUnit.{succ u1}) \u03b1\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}), Equiv.{max (succ u2) (succ u1), succ u1} (Prod.{u1, u2} \u03b1 PUnit.{succ u2}) \u03b1\nCase conversion may be inaccurate. Consider using '#align equiv.prod_punit Equiv.prodPUnit\u2093'. -/\n/-- `punit` is a right identity for type product up to an equivalence. -/\n@[simps]\ndef prodPUnit (\u03b1 : Type _) : \u03b1 \u00d7 PUnit.{u + 1} \u2243 \u03b1 :=\n  \u27e8fun p => p.1, fun a => (a, PUnit.unit), fun \u27e8_, PUnit.unit\u27e9 => rfl, fun a => rfl\u27e9\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 (\u03b1 : Type.{u2}), Equiv.{max (succ u1) (succ u2), succ u2} (Prod.{u1, u2} PUnit.{succ u1} \u03b1) \u03b1\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}), Equiv.{max (succ u1) (succ u2), succ u1} (Prod.{u2, u1} PUnit.{succ u2} \u03b1) \u03b1\nCase conversion may be inaccurate. Consider using '#align equiv.punit_prod Equiv.punitProd\u2093'. -/\n/-- `punit` is a left identity for type product up to an equivalence. -/\n@[simps]\ndef punitProd (\u03b1 : Type _) : PUnit.{u + 1} \u00d7 \u03b1 \u2243 \u03b1 :=\n  calc\n    PUnit \u00d7 \u03b1 \u2243 \u03b1 \u00d7 PUnit := prodComm _ _\n    _ \u2243 \u03b1 := 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 (\u03b1 : Type.{u_1}) (\u03b2 : Type.{u_2}) [_inst_1 : Unique.{succ u_2} \u03b2], Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b1\nbut is expected to have type\n  forall (\u03b1 : Type.{u_1}) (\u03b2 : Type.{u_2}) [_inst_1 : Unique.{succ u_2} \u03b2], Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b1\nCase conversion may be inaccurate. Consider using '#align equiv.prod_unique Equiv.prodUnique\u2093'. -/\n/-- Any `unique` type is a right identity for type product up to equivalence. -/\ndef prodUnique (\u03b1 \u03b2 : Type _) [Unique \u03b2] : \u03b1 \u00d7 \u03b2 \u2243 \u03b1 :=\n  ((Equiv.refl \u03b1).prodCongr <| equivPUnit \u03b2).trans <| prodPUnit \u03b1\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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_2} \u03b2], Eq.{max (succ u_1) (succ u_2)} ((Prod.{u_1, u_2} \u03b1 \u03b2) -> \u03b1) (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} \u03b1 \u03b2) \u03b1) (fun (_x : Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b1) => (Prod.{u_1, u_2} \u03b1 \u03b2) -> \u03b1) (Equiv.hasCoeToFun.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b1) (Equiv.prodUnique.{u_1, u_2, u_3} \u03b1 \u03b2 _inst_1)) (Prod.fst.{u_1, u_2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_1} \u03b1], Eq.{max (succ u_1) (succ u_2)} (forall (\u1fb0 : Prod.{u_2, u_1} \u03b2 \u03b1), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_2, u_1} \u03b2 \u03b1) => \u03b2) \u1fb0) (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} \u03b2 \u03b1) \u03b2) (Prod.{u_2, u_1} \u03b2 \u03b1) (fun (_x : Prod.{u_2, u_1} \u03b2 \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_2, u_1} \u03b2 \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b2) (Equiv.prodUnique.{u_2, u_1} \u03b2 \u03b1 _inst_1)) (Prod.fst.{u_2, u_1} \u03b2 \u03b1)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_prod_unique Equiv.coe_prodUnique\u2093'. -/\n@[simp]\ntheorem coe_prodUnique {\u03b1 \u03b2 : Type _} [Unique \u03b2] : \u21d1(prodUnique \u03b1 \u03b2) = 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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_2} \u03b2] (x : Prod.{u_1, u_2} \u03b1 \u03b2), Eq.{succ u_1} \u03b1 (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} \u03b1 \u03b2) \u03b1) (fun (_x : Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b1) => (Prod.{u_1, u_2} \u03b1 \u03b2) -> \u03b1) (Equiv.hasCoeToFun.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b1) (Equiv.prodUnique.{u_1, u_2, u_3} \u03b1 \u03b2 _inst_1) x) (Prod.fst.{u_1, u_2} \u03b1 \u03b2 x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_1} \u03b1] (x : Prod.{u_2, u_1} \u03b2 \u03b1), Eq.{succ u_2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_2, u_1} \u03b2 \u03b1) => \u03b2) 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} \u03b2 \u03b1) \u03b2) (Prod.{u_2, u_1} \u03b2 \u03b1) (fun (_x : Prod.{u_2, u_1} \u03b2 \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_2, u_1} \u03b2 \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b2) (Equiv.prodUnique.{u_2, u_1} \u03b2 \u03b1 _inst_1) x) (Prod.fst.{u_2, u_1} \u03b2 \u03b1 x)\nCase conversion may be inaccurate. Consider using '#align equiv.prod_unique_apply Equiv.prodUnique_apply\u2093'. -/\ntheorem prodUnique_apply {\u03b1 \u03b2 : Type _} [Unique \u03b2] (x : \u03b1 \u00d7 \u03b2) : prodUnique \u03b1 \u03b2 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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_2} \u03b2] (x : \u03b1), Eq.{max (succ u_1) (succ u_2)} (Prod.{u_1, u_2} \u03b1 \u03b2) (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)} \u03b1 (Prod.{u_1, u_2} \u03b1 \u03b2)) (fun (_x : Equiv.{succ u_1, max (succ u_1) (succ u_2)} \u03b1 (Prod.{u_1, u_2} \u03b1 \u03b2)) => \u03b1 -> (Prod.{u_1, u_2} \u03b1 \u03b2)) (Equiv.hasCoeToFun.{succ u_1, max (succ u_1) (succ u_2)} \u03b1 (Prod.{u_1, u_2} \u03b1 \u03b2)) (Equiv.symm.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b1 (Equiv.prodUnique.{u_1, u_2, u_3} \u03b1 \u03b2 _inst_1)) x) (Prod.mk.{u_1, u_2} \u03b1 \u03b2 x (Inhabited.default.{succ u_2} \u03b2 (Unique.inhabited.{succ u_2} \u03b2 _inst_1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_1} \u03b1] (x : \u03b2), Eq.{max (succ u_1) (succ u_2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => Prod.{u_2, u_1} \u03b2 \u03b1) 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)} \u03b2 (Prod.{u_2, u_1} \u03b2 \u03b1)) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => Prod.{u_2, u_1} \u03b2 \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u_2, max (succ u_1) (succ u_2)} \u03b2 (Prod.{u_2, u_1} \u03b2 \u03b1)) (Equiv.symm.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b2 (Equiv.prodUnique.{u_2, u_1} \u03b2 \u03b1 _inst_1)) x) (Prod.mk.{u_2, u_1} \u03b2 \u03b1 x (Inhabited.default.{succ u_1} \u03b1 (Unique.instInhabited.{succ u_1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_unique_symm_apply Equiv.prodUnique_symm_apply\u2093'. -/\n@[simp]\ntheorem prodUnique_symm_apply {\u03b1 \u03b2 : Type _} [Unique \u03b2] (x : \u03b1) :\n    (prodUnique \u03b1 \u03b2).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 (\u03b1 : Type.{u_1}) (\u03b2 : Type.{u_2}) [_inst_1 : Unique.{succ u_2} \u03b2], Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b1\nbut is expected to have type\n  forall (\u03b1 : Type.{u_1}) (\u03b2 : Type.{u_2}) [_inst_1 : Unique.{succ u_2} \u03b2], Equiv.{max (succ u_1) (succ u_2), succ u_1} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b1\nCase conversion may be inaccurate. Consider using '#align equiv.unique_prod Equiv.uniqueProd\u2093'. -/\n/-- Any `unique` type is a left identity for type product up to equivalence. -/\ndef uniqueProd (\u03b1 \u03b2 : Type _) [Unique \u03b2] : \u03b2 \u00d7 \u03b1 \u2243 \u03b1 :=\n  ((equivPUnit \u03b2).prodCongr <| Equiv.refl \u03b1).trans <| punitProd \u03b1\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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_2} \u03b2], Eq.{max (succ u_2) (succ u_1)} ((Prod.{u_2, u_1} \u03b2 \u03b1) -> \u03b1) (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} \u03b2 \u03b1) \u03b1) (fun (_x : Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b1) => (Prod.{u_2, u_1} \u03b2 \u03b1) -> \u03b1) (Equiv.hasCoeToFun.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b1) (Equiv.uniqueProd.{u_1, u_2, u_3} \u03b1 \u03b2 _inst_1)) (Prod.snd.{u_2, u_1} \u03b2 \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_1} \u03b1], Eq.{max (succ u_2) (succ u_1)} (forall (\u1fb0 : Prod.{u_1, u_2} \u03b1 \u03b2), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_1, u_2} \u03b1 \u03b2) => \u03b2) \u1fb0) (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} \u03b1 \u03b2) \u03b2) (Prod.{u_1, u_2} \u03b1 \u03b2) (fun (_x : Prod.{u_1, u_2} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_1, u_2} \u03b1 \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{max (succ u_2) (succ u_1), succ u_2} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b2) (Equiv.uniqueProd.{u_2, u_1} \u03b2 \u03b1 _inst_1)) (Prod.snd.{u_1, u_2} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_unique_prod Equiv.coe_uniqueProd\u2093'. -/\n@[simp]\ntheorem coe_uniqueProd {\u03b1 \u03b2 : Type _} [Unique \u03b2] : \u21d1(uniqueProd \u03b1 \u03b2) = 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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_2} \u03b2] (x : Prod.{u_2, u_1} \u03b2 \u03b1), Eq.{succ u_1} \u03b1 (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} \u03b2 \u03b1) \u03b1) (fun (_x : Equiv.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b1) => (Prod.{u_2, u_1} \u03b2 \u03b1) -> \u03b1) (Equiv.hasCoeToFun.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b1) (Equiv.uniqueProd.{u_1, u_2, u_3} \u03b1 \u03b2 _inst_1) x) (Prod.snd.{u_2, u_1} \u03b2 \u03b1 x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_1} \u03b1] (x : Prod.{u_1, u_2} \u03b1 \u03b2), Eq.{succ u_2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_1, u_2} \u03b1 \u03b2) => \u03b2) 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} \u03b1 \u03b2) \u03b2) (Prod.{u_1, u_2} \u03b1 \u03b2) (fun (_x : Prod.{u_1, u_2} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u_1, u_2} \u03b1 \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{max (succ u_2) (succ u_1), succ u_2} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b2) (Equiv.uniqueProd.{u_2, u_1} \u03b2 \u03b1 _inst_1) x) (Prod.snd.{u_1, u_2} \u03b1 \u03b2 x)\nCase conversion may be inaccurate. Consider using '#align equiv.unique_prod_apply Equiv.uniqueProd_apply\u2093'. -/\ntheorem uniqueProd_apply {\u03b1 \u03b2 : Type _} [Unique \u03b2] (x : \u03b2 \u00d7 \u03b1) : uniqueProd \u03b1 \u03b2 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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_2} \u03b2] (x : \u03b1), Eq.{max (succ u_2) (succ u_1)} (Prod.{u_2, u_1} \u03b2 \u03b1) (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)} \u03b1 (Prod.{u_2, u_1} \u03b2 \u03b1)) (fun (_x : Equiv.{succ u_1, max (succ u_2) (succ u_1)} \u03b1 (Prod.{u_2, u_1} \u03b2 \u03b1)) => \u03b1 -> (Prod.{u_2, u_1} \u03b2 \u03b1)) (Equiv.hasCoeToFun.{succ u_1, max (succ u_2) (succ u_1)} \u03b1 (Prod.{u_2, u_1} \u03b2 \u03b1)) (Equiv.symm.{max (succ u_2) (succ u_1), succ u_1} (Prod.{u_2, u_1} \u03b2 \u03b1) \u03b1 (Equiv.uniqueProd.{u_1, u_2, u_3} \u03b1 \u03b2 _inst_1)) x) (Prod.mk.{u_2, u_1} \u03b2 \u03b1 (Inhabited.default.{succ u_2} \u03b2 (Unique.inhabited.{succ u_2} \u03b2 _inst_1)) x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : Unique.{succ u_1} \u03b1] (x : \u03b2), Eq.{max (succ u_1) (succ u_2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => Prod.{u_1, u_2} \u03b1 \u03b2) 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)} \u03b2 (Prod.{u_1, u_2} \u03b1 \u03b2)) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => Prod.{u_1, u_2} \u03b1 \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u_2, max (succ u_1) (succ u_2)} \u03b2 (Prod.{u_1, u_2} \u03b1 \u03b2)) (Equiv.symm.{max (succ u_1) (succ u_2), succ u_2} (Prod.{u_1, u_2} \u03b1 \u03b2) \u03b2 (Equiv.uniqueProd.{u_2, u_1} \u03b2 \u03b1 _inst_1)) x) (Prod.mk.{u_1, u_2} \u03b1 \u03b2 (Inhabited.default.{succ u_1} \u03b1 (Unique.instInhabited.{succ u_1} \u03b1 _inst_1)) x)\nCase conversion may be inaccurate. Consider using '#align equiv.unique_prod_symm_apply Equiv.uniqueProd_symm_apply\u2093'. -/\n@[simp]\ntheorem uniqueProd_symm_apply {\u03b1 \u03b2 : Type _} [Unique \u03b2] (x : \u03b1) :\n    (uniqueProd \u03b1 \u03b2).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 (\u03b1 : Type _) : \u03b1 \u00d7 Empty \u2243 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 (\u03b1 : Type _) : Empty \u00d7 \u03b1 \u2243 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 (\u03b1 : Type _) : \u03b1 \u00d7 PEmpty \u2243 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 (\u03b1 : Type _) : PEmpty \u00d7 \u03b1 \u2243 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 (\u03b1 \u03b2 : Type _) : PSum \u03b1 \u03b2 \u2243 Sum \u03b1 \u03b2\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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{succ u1, succ u3} \u03b1\u2081 \u03b1\u2082) -> (Equiv.{succ u2, succ u4} \u03b2\u2081 \u03b2\u2082) -> (Equiv.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Sum.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Sum.{u3, u4} \u03b1\u2082 \u03b2\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) -> (Equiv.{succ u3, succ u4} \u03b1\u2082 \u03b2\u2082) -> (Equiv.{max (succ u3) (succ u1), max (succ u4) (succ u2)} (Sum.{u1, u3} \u03b1\u2081 \u03b1\u2082) (Sum.{u2, u4} \u03b2\u2081 \u03b2\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_congr Equiv.sumCongr\u2093'. -/\n/-- If `\u03b1 \u2243 \u03b1'` and `\u03b2 \u2243 \u03b2'`, then `\u03b1 \u2295 \u03b2 \u2243 \u03b1' \u2295 \u03b2'`. This is `sum.map` as an equivalence. -/\n@[simps apply]\ndef sumCongr {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Type _} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) : Sum \u03b1\u2081 \u03b2\u2081 \u2243 Sum \u03b1\u2082 \u03b2\u2082 :=\n  \u27e8Sum.map ea eb, Sum.map ea.symm eb.symm, fun x => by simp, fun x => by simp\u27e9\n#align equiv.sum_congr Equiv.sumCongr\n\n#print Equiv.psumCongr /-\n/-- If `\u03b1 \u2243 \u03b1'` and `\u03b2 \u2243 \u03b2'`, then `psum \u03b1 \u03b2 \u2243 psum \u03b1' \u03b2'`. -/\ndef psumCongr {\u03b4 : Sort z} (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b3 \u2243 \u03b4) : PSum \u03b1 \u03b3 \u2243 PSum \u03b2 \u03b4\n    where\n  toFun x := PSum.casesOn x (PSum.inl \u2218 e\u2081) (PSum.inr \u2218 e\u2082)\n  invFun x := PSum.casesOn x (PSum.inl \u2218 e\u2081.symm) (PSum.inr \u2218 e\u2082.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 {\u03b1\u2081 : Sort.{u1}} {\u03b2\u2081 : Sort.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{u1, succ u3} \u03b1\u2081 \u03b1\u2082) -> (Equiv.{u2, succ u4} \u03b2\u2081 \u03b2\u2082) -> (Equiv.{max 1 u1 u2, max (succ u3) (succ u4)} (PSum.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Sum.{u3, u4} \u03b1\u2082 \u03b2\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Sort.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Sort.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{u1, succ u2} \u03b1\u2081 \u03b2\u2081) -> (Equiv.{u3, succ u4} \u03b1\u2082 \u03b2\u2082) -> (Equiv.{max (max 1 u3) u1, max (succ u4) (succ u2)} (PSum.{u1, u3} \u03b1\u2081 \u03b1\u2082) (Sum.{u2, u4} \u03b2\u2081 \u03b2\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.psum_sum Equiv.psumSum\u2093'. -/\n/-- Combine two `equiv`s using `psum` in the domain and `sum` in the codomain. -/\ndef psumSum {\u03b1\u2081 \u03b2\u2081 : Sort _} {\u03b1\u2082 \u03b2\u2082 : Type _} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    PSum \u03b1\u2081 \u03b2\u2081 \u2243 Sum \u03b1\u2082 \u03b2\u2082 :=\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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Sort.{u3}} {\u03b2\u2082 : Sort.{u4}}, (Equiv.{succ u1, u3} \u03b1\u2081 \u03b1\u2082) -> (Equiv.{succ u2, u4} \u03b2\u2081 \u03b2\u2082) -> (Equiv.{max (succ u1) (succ u2), max 1 u3 u4} (Sum.{u1, u2} \u03b1\u2081 \u03b2\u2081) (PSum.{u3, u4} \u03b1\u2082 \u03b2\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Sort.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Sort.{u4}}, (Equiv.{succ u1, u2} \u03b1\u2081 \u03b2\u2081) -> (Equiv.{succ u3, u4} \u03b1\u2082 \u03b2\u2082) -> (Equiv.{max (succ u3) (succ u1), max (max 1 u4) u2} (Sum.{u1, u3} \u03b1\u2081 \u03b1\u2082) (PSum.{u2, u4} \u03b2\u2081 \u03b2\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_psum Equiv.sumPSum\u2093'. -/\n/-- Combine two `equiv`s using `sum` in the domain and `psum` in the codomain. -/\ndef sumPSum {\u03b1\u2081 \u03b2\u2081 : Type _} {\u03b1\u2082 \u03b2\u2082 : Sort _} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    Sum \u03b1\u2081 \u03b2\u2081 \u2243 PSum \u03b1\u2082 \u03b2\u2082 :=\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 {\u03b1\u2081 : Type.{u1}} {\u03b1\u2082 : Type.{u2}} {\u03b2\u2081 : Type.{u3}} {\u03b2\u2082 : Type.{u4}} {\u03b3\u2081 : Type.{u5}} {\u03b3\u2082 : Type.{u6}} (e : Equiv.{succ u1, succ u3} \u03b1\u2081 \u03b2\u2081) (f : Equiv.{succ u2, succ u4} \u03b1\u2082 \u03b2\u2082) (g : Equiv.{succ u3, succ u5} \u03b2\u2081 \u03b3\u2081) (h : Equiv.{succ u4, succ u6} \u03b2\u2082 \u03b3\u2082), 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} \u03b1\u2081 \u03b1\u2082) (Sum.{u5, u6} \u03b3\u2081 \u03b3\u2082)) (Equiv.trans.{max (succ u1) (succ u2), max (succ u3) (succ u4), max (succ u5) (succ u6)} (Sum.{u1, u2} \u03b1\u2081 \u03b1\u2082) (Sum.{u3, u4} \u03b2\u2081 \u03b2\u2082) (Sum.{u5, u6} \u03b3\u2081 \u03b3\u2082) (Equiv.sumCongr.{u1, u2, u3, u4} \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 e f) (Equiv.sumCongr.{u3, u4, u5, u6} \u03b2\u2081 \u03b2\u2082 \u03b3\u2081 \u03b3\u2082 g h)) (Equiv.sumCongr.{u1, u2, u5, u6} \u03b1\u2081 \u03b1\u2082 \u03b3\u2081 \u03b3\u2082 (Equiv.trans.{succ u1, succ u3, succ u5} \u03b1\u2081 \u03b2\u2081 \u03b3\u2081 e g) (Equiv.trans.{succ u2, succ u4, succ u6} \u03b1\u2082 \u03b2\u2082 \u03b3\u2082 f h))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u6}} {\u03b1\u2082 : Type.{u5}} {\u03b2\u2081 : Type.{u4}} {\u03b2\u2082 : Type.{u3}} {\u03b3\u2081 : Type.{u2}} {\u03b3\u2082 : Type.{u1}} (e : Equiv.{succ u6, succ u5} \u03b1\u2081 \u03b1\u2082) (f : Equiv.{succ u4, succ u3} \u03b2\u2081 \u03b2\u2082) (g : Equiv.{succ u5, succ u2} \u03b1\u2082 \u03b3\u2081) (h : Equiv.{succ u3, succ u1} \u03b2\u2082 \u03b3\u2082), 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} \u03b1\u2081 \u03b2\u2081) (Sum.{u2, u1} \u03b3\u2081 \u03b3\u2082)) (Equiv.trans.{max (succ u4) (succ u6), max (succ u3) (succ u5), max (succ u1) (succ u2)} (Sum.{u6, u4} \u03b1\u2081 \u03b2\u2081) (Sum.{u5, u3} \u03b1\u2082 \u03b2\u2082) (Sum.{u2, u1} \u03b3\u2081 \u03b3\u2082) (Equiv.sumCongr.{u6, u5, u4, u3} \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 e f) (Equiv.sumCongr.{u5, u2, u3, u1} \u03b1\u2082 \u03b3\u2081 \u03b2\u2082 \u03b3\u2082 g h)) (Equiv.sumCongr.{u6, u2, u4, u1} \u03b1\u2081 \u03b3\u2081 \u03b2\u2081 \u03b3\u2082 (Equiv.trans.{succ u6, succ u5, succ u2} \u03b1\u2081 \u03b1\u2082 \u03b3\u2081 e g) (Equiv.trans.{succ u4, succ u3, succ u1} \u03b2\u2081 \u03b2\u2082 \u03b3\u2082 f h))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_congr_trans Equiv.sumCongr_trans\u2093'. -/\n@[simp]\ntheorem sumCongr_trans {\u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 \u03b3\u2081 \u03b3\u2082 : Sort _} (e : \u03b1\u2081 \u2243 \u03b2\u2081) (f : \u03b1\u2082 \u2243 \u03b2\u2082) (g : \u03b2\u2081 \u2243 \u03b3\u2081)\n    (h : \u03b2\u2082 \u2243 \u03b3\u2082) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} (e : Equiv.{succ u1, succ u2} \u03b1 \u03b2) (f : Equiv.{succ u3, succ u4} \u03b3 \u03b4), 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} \u03b2 \u03b4) (Sum.{u1, u3} \u03b1 \u03b3)) (Equiv.symm.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Sum.{u1, u3} \u03b1 \u03b3) (Sum.{u2, u4} \u03b2 \u03b4) (Equiv.sumCongr.{u1, u3, u2, u4} \u03b1 \u03b3 \u03b2 \u03b4 e f)) (Equiv.sumCongr.{u2, u4, u1, u3} \u03b2 \u03b4 \u03b1 \u03b3 (Equiv.symm.{succ u1, succ u2} \u03b1 \u03b2 e) (Equiv.symm.{succ u3, succ u4} \u03b3 \u03b4 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} {\u03b4 : Type.{u1}} (e : Equiv.{succ u4, succ u3} \u03b1 \u03b2) (f : Equiv.{succ u2, succ u1} \u03b3 \u03b4), 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} \u03b2 \u03b4) (Sum.{u4, u2} \u03b1 \u03b3)) (Equiv.symm.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Sum.{u4, u2} \u03b1 \u03b3) (Sum.{u3, u1} \u03b2 \u03b4) (Equiv.sumCongr.{u4, u3, u2, u1} \u03b1 \u03b2 \u03b3 \u03b4 e f)) (Equiv.sumCongr.{u3, u4, u1, u2} \u03b2 \u03b1 \u03b4 \u03b3 (Equiv.symm.{succ u4, succ u3} \u03b1 \u03b2 e) (Equiv.symm.{succ u2, succ u1} \u03b3 \u03b4 f))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_congr_symm Equiv.sumCongr_symm\u2093'. -/\n@[simp]\ntheorem sumCongr_symm {\u03b1 \u03b2 \u03b3 \u03b4 : Sort _} (e : \u03b1 \u2243 \u03b2) (f : \u03b3 \u2243 \u03b4) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}}, Eq.{max 1 (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.sumCongr.{u1, u2, u1, u2} \u03b1 \u03b2 \u03b1 \u03b2 (Equiv.refl.{succ u1} \u03b1) (Equiv.refl.{succ u2} \u03b2)) (Equiv.refl.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}}, Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (Sum.{u2, u1} \u03b1 \u03b2)) (Equiv.sumCongr.{u2, u2, u1, u1} \u03b1 \u03b1 \u03b2 \u03b2 (Equiv.refl.{succ u2} \u03b1) (Equiv.refl.{succ u1} \u03b2)) (Equiv.refl.{max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_congr_refl Equiv.sumCongr_refl\u2093'. -/\n@[simp]\ntheorem sumCongr_refl {\u03b1 \u03b2 : Sort _} :\n    Equiv.sumCongr (Equiv.refl \u03b1) (Equiv.refl \u03b2) = Equiv.refl (Sum \u03b1 \u03b2) :=\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 `\u03b1` and of `\u03b2` into a permutation of `\u03b1 \u2295 \u03b2`. -/\n@[reducible]\ndef sumCongr {\u03b1 \u03b2 : Type _} (ea : Equiv.Perm \u03b1) (eb : Equiv.Perm \u03b2) : Equiv.Perm (Sum \u03b1 \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (ea : Equiv.Perm.{succ u1} \u03b1) (eb : Equiv.Perm.{succ u2} \u03b2) (x : Sum.{u1, u2} \u03b1 \u03b2), Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) => (Sum.{u1, u2} \u03b1 \u03b2) -> (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 ea eb) x) (Sum.map.{u1, u2, u1, u2} \u03b1 \u03b1 \u03b2 \u03b2 (coeFn.{succ u1, succ u1} (Equiv.Perm.{succ u1} \u03b1) (fun (_x : Equiv.{succ u1, succ u1} \u03b1 \u03b1) => \u03b1 -> \u03b1) (Equiv.hasCoeToFun.{succ u1, succ u1} \u03b1 \u03b1) ea) (coeFn.{succ u2, succ u2} (Equiv.Perm.{succ u2} \u03b2) (fun (_x : Equiv.{succ u2, succ u2} \u03b2 \u03b2) => \u03b2 -> \u03b2) (Equiv.hasCoeToFun.{succ u2, succ u2} \u03b2 \u03b2) eb) x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (ea : Equiv.Perm.{succ u2} \u03b1) (eb : Equiv.Perm.{succ u1} \u03b2) (x : Sum.{u2, u1} \u03b1 \u03b2), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} \u03b1 \u03b2) => Sum.{u2, u1} \u03b1 \u03b2) 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} \u03b1 \u03b2)) (Sum.{u2, u1} \u03b1 \u03b2) (fun (_x : Sum.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} \u03b1 \u03b2) => Sum.{u2, u1} \u03b1 \u03b2) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (Sum.{u2, u1} \u03b1 \u03b2)) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 ea eb) x) (Sum.map.{u2, u1, u2, u1} \u03b1 \u03b1 \u03b2 \u03b2 (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.Perm.{succ u2} \u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} \u03b1 \u03b1) ea) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.Perm.{succ u1} \u03b2) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} \u03b2 \u03b2) eb) x)\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_apply Equiv.Perm.sumCongr_apply\u2093'. -/\n@[simp]\ntheorem sumCongr_apply {\u03b1 \u03b2 : Type _} (ea : Equiv.Perm \u03b1) (eb : Equiv.Perm \u03b2) (x : Sum \u03b1 \u03b2) :\n    sumCongr ea eb x = Sum.map (\u21d1ea) (\u21d1eb) 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (e : Equiv.Perm.{succ u1} \u03b1) (f : Equiv.Perm.{succ u2} \u03b2) (g : Equiv.Perm.{succ u1} \u03b1) (h : Equiv.Perm.{succ u2} \u03b2), Eq.{max 1 (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.trans.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 e f) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 g h)) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 (Equiv.trans.{succ u1, succ u1, succ u1} \u03b1 \u03b1 \u03b1 e g) (Equiv.trans.{succ u2, succ u2, succ u2} \u03b2 \u03b2 \u03b2 f h))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (e : Equiv.Perm.{succ u2} \u03b1) (f : Equiv.Perm.{succ u1} \u03b2) (g : Equiv.Perm.{succ u2} \u03b1) (h : Equiv.Perm.{succ u1} \u03b2), Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (Sum.{u2, u1} \u03b1 \u03b2)) (Equiv.trans.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (Sum.{u2, u1} \u03b1 \u03b2) (Sum.{u2, u1} \u03b1 \u03b2) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 e f) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 g h)) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 (Equiv.trans.{succ u2, succ u2, succ u2} \u03b1 \u03b1 \u03b1 e g) (Equiv.trans.{succ u1, succ u1, succ u1} \u03b2 \u03b2 \u03b2 f h))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_trans Equiv.Perm.sumCongr_trans\u2093'. -/\n@[simp]\ntheorem sumCongr_trans {\u03b1 \u03b2 : Sort _} (e : Equiv.Perm \u03b1) (f : Equiv.Perm \u03b2) (g : Equiv.Perm \u03b1)\n    (h : Equiv.Perm \u03b2) : (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (e : Equiv.Perm.{succ u1} \u03b1) (f : Equiv.Perm.{succ u2} \u03b2), Eq.{max 1 (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 e f)) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 (Equiv.symm.{succ u1, succ u1} \u03b1 \u03b1 e) (Equiv.symm.{succ u2, succ u2} \u03b2 \u03b2 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (e : Equiv.Perm.{succ u2} \u03b1) (f : Equiv.Perm.{succ u1} \u03b2), Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (Sum.{u2, u1} \u03b1 \u03b2)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (Sum.{u2, u1} \u03b1 \u03b2) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 e f)) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 (Equiv.symm.{succ u2, succ u2} \u03b1 \u03b1 e) (Equiv.symm.{succ u1, succ u1} \u03b2 \u03b2 f))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_symm Equiv.Perm.sumCongr_symm\u2093'. -/\n@[simp]\ntheorem sumCongr_symm {\u03b1 \u03b2 : Sort _} (e : Equiv.Perm \u03b1) (f : Equiv.Perm \u03b2) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}}, Eq.{max 1 (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 (Equiv.refl.{succ u1} \u03b1) (Equiv.refl.{succ u2} \u03b2)) (Equiv.refl.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}}, Eq.{max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2)) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 (Equiv.refl.{succ u2} \u03b1) (Equiv.refl.{succ u1} \u03b2)) (Equiv.refl.{max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_refl Equiv.Perm.sumCongr_refl\u2093'. -/\n@[simp]\ntheorem sumCongr_refl {\u03b1 \u03b2 : Sort _} :\n    sumCongr (Equiv.refl \u03b1) (Equiv.refl \u03b2) = Equiv.refl (Sum \u03b1 \u03b2) :=\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 \u2243 Sum PUnit.{u + 1} PUnit.{v + 1} :=\n  \u27e8fun 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 (\u27e8\u27e8\u27e9\u27e9 | \u27e8\u27e8\u27e9\u27e9) <;> rfl\u27e9\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 (\u03b1 \u03b2 : Type _) : Sum \u03b1 \u03b2 \u2243 Sum \u03b2 \u03b1 :=\n  \u27e8Sum.swap, Sum.swap, Sum.swap_swap, Sum.swap_swap\u27e9\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 (\u03b1 : Type.{u1}) (\u03b2 : 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} \u03b2 \u03b1) (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u2, u1} \u03b2 \u03b1) (Equiv.sumComm.{u1, u2} \u03b1 \u03b2)) (Equiv.sumComm.{u2, u1} \u03b2 \u03b1)\nbut is expected to have type\n  forall (\u03b1 : Type.{u2}) (\u03b2 : Type.{u1}), Eq.{max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b2 \u03b1) (Sum.{u2, u1} \u03b1 \u03b2)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (Sum.{u1, u2} \u03b2 \u03b1) (Equiv.sumComm.{u2, u1} \u03b1 \u03b2)) (Equiv.sumComm.{u1, u2} \u03b2 \u03b1)\nCase conversion may be inaccurate. Consider using '#align equiv.sum_comm_symm Equiv.sumComm_symm\u2093'. -/\n@[simp]\ntheorem sumComm_symm (\u03b1 \u03b2) : (sumComm \u03b1 \u03b2).symm = sumComm \u03b2 \u03b1 :=\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 (\u03b1 \u03b2 \u03b3 : Type _) : Sum (Sum \u03b1 \u03b2) \u03b3 \u2243 Sum \u03b1 (Sum \u03b2 \u03b3) :=\n  \u27e8Sum.elim (Sum.elim Sum.inl (Sum.inr \u2218 Sum.inl)) (Sum.inr \u2218 Sum.inr),\n    Sum.elim (Sum.inl \u2218 Sum.inl) <| Sum.elim (Sum.inl \u2218 Sum.inr) Sum.inr, by\n    rintro (\u27e8_ | _\u27e9 | _) <;> rfl, by rintro (_ | \u27e8_ | _\u27e9) <;> rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (a : \u03b1), Eq.{max (succ u1) (succ (max u2 u3))} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) => (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) -> (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (Equiv.sumAssoc.{u1, u2, u3} \u03b1 \u03b2 \u03b3) (Sum.inl.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 (Sum.inl.{u1, u2} \u03b1 \u03b2 a))) (Sum.inl.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (a : \u03b1), 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} \u03b1 \u03b2) \u03b3) => Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 (Sum.inl.{u3, u2} \u03b1 \u03b2 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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3))) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) (fun (_x : Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) => Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) _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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3))) (Equiv.sumAssoc.{u3, u2, u1} \u03b1 \u03b2 \u03b3) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 (Sum.inl.{u3, u2} \u03b1 \u03b2 a))) (Sum.inl.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) a)\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_apply_inl_inl Equiv.sumAssoc_apply_inl_inl\u2093'. -/\n@[simp]\ntheorem sumAssoc_apply_inl_inl {\u03b1 \u03b2 \u03b3} (a) : sumAssoc \u03b1 \u03b2 \u03b3 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (b : \u03b2), Eq.{max (succ u1) (succ (max u2 u3))} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) => (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) -> (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (Equiv.sumAssoc.{u1, u2, u3} \u03b1 \u03b2 \u03b3) (Sum.inl.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 (Sum.inr.{u1, u2} \u03b1 \u03b2 b))) (Sum.inr.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) (Sum.inl.{u2, u3} \u03b2 \u03b3 b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (b : \u03b2), 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} \u03b1 \u03b2) \u03b3) => Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 (Sum.inr.{u3, u2} \u03b1 \u03b2 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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3))) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) (fun (_x : Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) => Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) _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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3))) (Equiv.sumAssoc.{u3, u2, u1} \u03b1 \u03b2 \u03b3) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 (Sum.inr.{u3, u2} \u03b1 \u03b2 b))) (Sum.inr.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) (Sum.inl.{u2, u1} \u03b2 \u03b3 b))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_apply_inl_inr Equiv.sumAssoc_apply_inl_inr\u2093'. -/\n@[simp]\ntheorem sumAssoc_apply_inl_inr {\u03b1 \u03b2 \u03b3} (b) : sumAssoc \u03b1 \u03b2 \u03b3 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (c : \u03b3), Eq.{max (succ u1) (succ (max u2 u3))} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) => (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) -> (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (Equiv.hasCoeToFun.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (Equiv.sumAssoc.{u1, u2, u3} \u03b1 \u03b2 \u03b3) (Sum.inr.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 c)) (Sum.inr.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) (Sum.inr.{u2, u3} \u03b2 \u03b3 c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (c : \u03b3), 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} \u03b1 \u03b2) \u03b3) => Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.inr.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3))) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) (fun (_x : Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) => Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) _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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3))) (Equiv.sumAssoc.{u3, u2, u1} \u03b1 \u03b2 \u03b3) (Sum.inr.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 c)) (Sum.inr.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) (Sum.inr.{u2, u1} \u03b2 \u03b3 c))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_apply_inr Equiv.sumAssoc_apply_inr\u2093'. -/\n@[simp]\ntheorem sumAssoc_apply_inr {\u03b1 \u03b2 \u03b3} (c) : sumAssoc \u03b1 \u03b2 \u03b3 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (a : \u03b1), Eq.{max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (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} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) => (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) -> (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (Equiv.symm.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Equiv.sumAssoc.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Sum.inl.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) a)) (Sum.inl.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 (Sum.inl.{u1, u2} \u03b1 \u03b2 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (a : \u03b1), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) (Sum.inl.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) 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} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3)) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (fun (_x : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Equiv.sumAssoc.{u3, u2, u1} \u03b1 \u03b2 \u03b3)) (Sum.inl.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) a)) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 (Sum.inl.{u3, u2} \u03b1 \u03b2 a))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_symm_apply_inl Equiv.sumAssoc_symm_apply_inl\u2093'. -/\n@[simp]\ntheorem sumAssoc_symm_apply_inl {\u03b1 \u03b2 \u03b3} (a) : (sumAssoc \u03b1 \u03b2 \u03b3).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (b : \u03b2), Eq.{max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (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} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) => (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) -> (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (Equiv.symm.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Equiv.sumAssoc.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Sum.inr.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) (Sum.inl.{u2, u3} \u03b2 \u03b3 b))) (Sum.inl.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 (Sum.inr.{u1, u2} \u03b1 \u03b2 b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (b : \u03b2), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) (Sum.inr.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) (Sum.inl.{u2, u1} \u03b2 \u03b3 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} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3)) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (fun (_x : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Equiv.sumAssoc.{u3, u2, u1} \u03b1 \u03b2 \u03b3)) (Sum.inr.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) (Sum.inl.{u2, u1} \u03b2 \u03b3 b))) (Sum.inl.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 (Sum.inr.{u3, u2} \u03b1 \u03b2 b))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_symm_apply_inr_inl Equiv.sumAssoc_symm_apply_inr_inl\u2093'. -/\n@[simp]\ntheorem sumAssoc_symm_apply_inr_inl {\u03b1 \u03b2 \u03b3} (b) :\n    (sumAssoc \u03b1 \u03b2 \u03b3).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (c : \u03b3), Eq.{max (succ (max u1 u2)) (succ u3)} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (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} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) => (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) -> (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ u3)} (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (Equiv.symm.{max (succ (max u1 u2)) (succ u3), max (succ u1) (succ (max u2 u3))} (Sum.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (Sum.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Equiv.sumAssoc.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Sum.inr.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) (Sum.inr.{u2, u3} \u03b2 \u03b3 c))) (Sum.inr.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 c)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (c : \u03b3), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) (Sum.inr.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) (Sum.inr.{u2, u1} \u03b2 \u03b3 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} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3)) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (fun (_x : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Equiv.sumAssoc.{u3, u2, u1} \u03b1 \u03b2 \u03b3)) (Sum.inr.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) (Sum.inr.{u2, u1} \u03b2 \u03b3 c))) (Sum.inr.{max u2 u3, u1} (Sum.{u3, u2} \u03b1 \u03b2) \u03b3 c)\nCase conversion may be inaccurate. Consider using '#align equiv.sum_assoc_symm_apply_inr_inr Equiv.sumAssoc_symm_apply_inr_inr\u2093'. -/\n@[simp]\ntheorem sumAssoc_symm_apply_inr_inr {\u03b1 \u03b2 \u03b3} (c) : (sumAssoc \u03b1 \u03b2 \u03b3).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 (\u03b1 \u03b2 : Type _) [IsEmpty \u03b2] : Sum \u03b1 \u03b2 \u2243 \u03b1 :=\n  \u27e8Sum.elim id isEmptyElim, inl, fun s =>\n    by\n    rcases s with (_ | x)\n    rfl\n    exact isEmptyElim x, fun a => rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : IsEmpty.{succ u2} \u03b2] (a : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 \u03b2) \u03b1) (fun (_x : Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 \u03b2) \u03b1) => (Sum.{u1, u2} \u03b1 \u03b2) -> \u03b1) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 \u03b2) \u03b1) (Equiv.sumEmpty.{u1, u2} \u03b1 \u03b2 _inst_1) (Sum.inl.{u1, u2} \u03b1 \u03b2 a)) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : IsEmpty.{succ u2} \u03b1] (a : \u03b2), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u1, u2} \u03b2 \u03b1) => \u03b2) (Sum.inl.{u1, u2} \u03b2 \u03b1 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} \u03b2 \u03b1) \u03b2) (Sum.{u1, u2} \u03b2 \u03b1) (fun (_x : Sum.{u1, u2} \u03b2 \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u1, u2} \u03b2 \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{max (succ u2) (succ u1), succ u1} (Sum.{u1, u2} \u03b2 \u03b1) \u03b2) (Equiv.sumEmpty.{u1, u2} \u03b2 \u03b1 _inst_1) (Sum.inl.{u1, u2} \u03b2 \u03b1 a)) a\nCase conversion may be inaccurate. Consider using '#align equiv.sum_empty_apply_inl Equiv.sumEmpty_apply_inl\u2093'. -/\n@[simp]\ntheorem sumEmpty_apply_inl {\u03b1 \u03b2 : Type _} [IsEmpty \u03b2] (a : \u03b1) : sumEmpty \u03b1 \u03b2 (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 (\u03b1 \u03b2 : Type _) [IsEmpty \u03b1] : Sum \u03b1 \u03b2 \u2243 \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : IsEmpty.{succ u1} \u03b1] (b : \u03b2), Eq.{succ u2} \u03b2 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), succ u2} (Sum.{u1, u2} \u03b1 \u03b2) \u03b2) (fun (_x : Equiv.{max (succ u1) (succ u2), succ u2} (Sum.{u1, u2} \u03b1 \u03b2) \u03b2) => (Sum.{u1, u2} \u03b1 \u03b2) -> \u03b2) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), succ u2} (Sum.{u1, u2} \u03b1 \u03b2) \u03b2) (Equiv.emptySum.{u1, u2} \u03b1 \u03b2 _inst_1) (Sum.inr.{u1, u2} \u03b1 \u03b2 b)) b\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : IsEmpty.{succ u2} \u03b1] (b : \u03b2), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} \u03b1 \u03b2) => \u03b2) (Sum.inr.{u2, u1} \u03b1 \u03b2 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} \u03b1 \u03b2) \u03b2) (Sum.{u2, u1} \u03b1 \u03b2) (fun (_x : Sum.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} \u03b1 \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), succ u1} (Sum.{u2, u1} \u03b1 \u03b2) \u03b2) (Equiv.emptySum.{u2, u1} \u03b1 \u03b2 _inst_1) (Sum.inr.{u2, u1} \u03b1 \u03b2 b)) b\nCase conversion may be inaccurate. Consider using '#align equiv.empty_sum_apply_inr Equiv.emptySum_apply_inr\u2093'. -/\n@[simp]\ntheorem emptySum_apply_inr {\u03b1 \u03b2 : Type _} [IsEmpty \u03b1] (b : \u03b2) : emptySum \u03b1 \u03b2 (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 (\u03b1 : Type.{u2}), Equiv.{succ u2, max (succ u2) (succ u1)} (Option.{u2} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1})\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}), Equiv.{succ u1, max (succ u2) (succ u1)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit Equiv.optionEquivSumPUnit\u2093'. -/\n/-- `option \u03b1` is equivalent to `\u03b1 \u2295 punit` -/\ndef optionEquivSumPUnit (\u03b1 : Type _) : Option \u03b1 \u2243 Sum \u03b1 PUnit.{u + 1} :=\n  \u27e8fun 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 (_ | \u27e8\u27e8\u27e9\u27e9) <;> rfl\u27e9\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 {\u03b1 : Type.{u1}}, Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 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} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (fun (_x : Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) => (Option.{u1} \u03b1) -> (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (Equiv.hasCoeToFun.{succ u1, max (succ u1) (succ u2)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1) (Option.none.{u1} \u03b1)) (Sum.inr.{u1, u2} \u03b1 PUnit.{succ u2} PUnit.unit.{succ u2})\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}}, Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} \u03b1) => Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (Option.none.{u2} \u03b1)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, max (succ u1) (succ u2)} (Equiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1})) (Option.{u2} \u03b1) (fun (_x : Option.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} \u03b1) => Sum.{u2, u1} \u03b1 PUnit.{succ u1}) _x) (Equiv.instFunLikeEquiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1})) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1) (Option.none.{u2} \u03b1)) (Sum.inr.{u2, u1} \u03b1 PUnit.{succ u1} PUnit.unit.{succ u1})\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_none Equiv.optionEquivSumPUnit_none\u2093'. -/\n@[simp]\ntheorem optionEquivSumPUnit_none {\u03b1} : optionEquivSumPUnit \u03b1 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 {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 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} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (fun (_x : Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) => (Option.{u1} \u03b1) -> (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (Equiv.hasCoeToFun.{succ u1, max (succ u1) (succ u2)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1) (Option.some.{u1} \u03b1 a)) (Sum.inl.{u1, u2} \u03b1 PUnit.{succ u2} a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (a : \u03b1), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} \u03b1) => Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (Option.some.{u2} \u03b1 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} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1})) (Option.{u2} \u03b1) (fun (_x : Option.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} \u03b1) => Sum.{u2, u1} \u03b1 PUnit.{succ u1}) _x) (Equiv.instFunLikeEquiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1})) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1) (Option.some.{u2} \u03b1 a)) (Sum.inl.{u2, u1} \u03b1 PUnit.{succ u1} a)\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_some Equiv.optionEquivSumPUnit_some\u2093'. -/\n@[simp]\ntheorem optionEquivSumPUnit_some {\u03b1} (a) : optionEquivSumPUnit \u03b1 (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 {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 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} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (fun (_x : Equiv.{succ u1, max (succ u1) (succ u2)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) => (Option.{u1} \u03b1) -> (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (Equiv.hasCoeToFun.{succ u1, max (succ u1) (succ u2)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2})) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (Option.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (coeOption.{u1} \u03b1))) a)) (Sum.inl.{u1, u2} \u03b1 PUnit.{succ u2} a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (a : \u03b1), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} \u03b1) => Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (Option.some.{u2} \u03b1 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} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1})) (Option.{u2} \u03b1) (fun (_x : Option.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} \u03b1) => Sum.{u2, u1} \u03b1 PUnit.{succ u1}) _x) (Equiv.instFunLikeEquiv.{succ u2, max (succ u1) (succ u2)} (Option.{u2} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1})) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1) (Option.some.{u2} \u03b1 a)) (Sum.inl.{u2, u1} \u03b1 PUnit.{succ u1} a)\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_coe Equiv.optionEquivSumPUnit_coe\u2093'. -/\n@[simp]\ntheorem optionEquivSumPUnit_coe {\u03b1} (a : \u03b1) : optionEquivSumPUnit \u03b1 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 {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Option.{u1} \u03b1) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) (Option.{u1} \u03b1)) (fun (_x : Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) (Option.{u1} \u03b1)) => (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) -> (Option.{u1} \u03b1)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) (Option.{u1} \u03b1)) (Equiv.symm.{succ u1, max (succ u1) (succ u2)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1)) (Sum.inl.{u1, u2} \u03b1 PUnit.{succ u2} a)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (Option.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (coeOption.{u1} \u03b1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (a : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} \u03b1 PUnit.{succ u1}) => Option.{u2} \u03b1) (Sum.inl.{u2, u1} \u03b1 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} \u03b1 PUnit.{succ u1}) (Option.{u2} \u03b1)) (Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (fun (_x : Sum.{u2, u1} \u03b1 PUnit.{succ u1}) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} \u03b1 PUnit.{succ u1}) => Option.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), succ u2} (Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (Option.{u2} \u03b1)) (Equiv.symm.{succ u2, max (succ u1) (succ u2)} (Option.{u2} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1)) (Sum.inl.{u2, u1} \u03b1 PUnit.{succ u1} a)) (Option.some.{u2} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_symm_inl Equiv.optionEquivSumPUnit_symm_inl\u2093'. -/\n@[simp]\ntheorem optionEquivSumPUnit_symm_inl {\u03b1} (a) : (optionEquivSumPUnit \u03b1).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 {\u03b1 : Type.{u1}} (a : PUnit.{succ u2}), Eq.{succ u1} (Option.{u1} \u03b1) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) (Option.{u1} \u03b1)) (fun (_x : Equiv.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) (Option.{u1} \u03b1)) => (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) -> (Option.{u1} \u03b1)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), succ u1} (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) (Option.{u1} \u03b1)) (Equiv.symm.{succ u1, max (succ u1) (succ u2)} (Option.{u1} \u03b1) (Sum.{u1, u2} \u03b1 PUnit.{succ u2}) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1)) (Sum.inr.{u1, u2} \u03b1 PUnit.{succ u2} a)) (Option.none.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (a : PUnit.{succ u1}), Eq.{succ u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} \u03b1 PUnit.{succ u1}) => Option.{u2} \u03b1) (Sum.inr.{u2, u1} \u03b1 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} \u03b1 PUnit.{succ u1}) (Option.{u2} \u03b1)) (Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (fun (_x : Sum.{u2, u1} \u03b1 PUnit.{succ u1}) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{u2, u1} \u03b1 PUnit.{succ u1}) => Option.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), succ u2} (Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (Option.{u2} \u03b1)) (Equiv.symm.{succ u2, max (succ u1) (succ u2)} (Option.{u2} \u03b1) (Sum.{u2, u1} \u03b1 PUnit.{succ u1}) (Equiv.optionEquivSumPUnit.{u2, u1} \u03b1)) (Sum.inr.{u2, u1} \u03b1 PUnit.{succ u1} a)) (Option.none.{u2} \u03b1)\nCase conversion may be inaccurate. Consider using '#align equiv.option_equiv_sum_punit_symm_inr Equiv.optionEquivSumPUnit_symm_inr\u2093'. -/\n@[simp]\ntheorem optionEquivSumPUnit_symm_inr {\u03b1} (a) : (optionEquivSumPUnit \u03b1).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 \u03b1` such that `is_some x` is equivalent to `\u03b1`. -/\n@[simps]\ndef optionIsSomeEquiv (\u03b1 : Type _) : { x : Option \u03b1 // x.isSome } \u2243 \u03b1\n    where\n  toFun o := Option.get o.2\n  invFun x := \u27e8some x, by decide\u27e9\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 \u03b1` of `\u03b2 a` is the binary product of the\nproduct over `\u03b1` of `\u03b2 (some \u03b1)` and `\u03b2 none` -/\n@[simps]\ndef piOptionEquivProd {\u03b1 : Type _} {\u03b2 : Option \u03b1 \u2192 Type _} :\n    (\u2200 a : Option \u03b1, \u03b2 a) \u2243 \u03b2 none \u00d7 \u2200 a : \u03b1, \u03b2 (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/-- `\u03b1 \u2295 \u03b2` is equivalent to a `sigma`-type over `bool`. Note that this definition assumes `\u03b1` and\n`\u03b2` 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 (\u03b1 \u03b2 : Type u) : Sum \u03b1 \u03b2 \u2243 \u03a3b : Bool, cond b \u03b1 \u03b2 :=\n  \u27e8fun s => s.elim (fun x => \u27e8true, x\u27e9) fun x => \u27e8false, x\u27e9, fun s =>\n    match s with\n    | \u27e8tt, a\u27e9 => inl a\n    | \u27e8ff, b\u27e9 => inr b,\n    fun s => by cases s <;> rfl, fun s => by rcases s with \u27e8_ | _, _\u27e9 <;> rfl\u27e9\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 : \u03b1 \u2192 \u03b2` is the natural equivalence between\nthe type of all fibres of `f` and the total space `\u03b1`. -/\n@[simps]\ndef sigmaFiberEquiv {\u03b1 \u03b2 : Type _} (f : \u03b1 \u2192 \u03b2) : (\u03a3y : \u03b2, { x // f x = y }) \u2243 \u03b1 :=\n  \u27e8fun x => \u2191x.2, fun x => \u27e8f x, x, rfl\u27e9, fun \u27e8y, x, rfl\u27e9 => rfl, fun x => rfl\u27e9\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 `\u03b1`,\nthe sum of the two subtypes `{a // p a}` and its complement `{a // \u00ac p a}`\nis naturally equivalent to `\u03b1`.\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 {\u03b1 : Type _} (p : \u03b1 \u2192 Prop) [DecidablePred p] : Sum { a // p a } { a // \u00acp a } \u2243 \u03b1\n    where\n  toFun := Sum.elim coe coe\n  invFun a := if h : p a then Sum.inl \u27e8a, h\u27e9 else Sum.inr \u27e8a, h\u27e9\n  left_inv := by rintro (\u27e8x, hx\u27e9 | \u27e8x, hx\u27e9) <;> 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 {\u03b1 : Type _} (p : \u03b1 \u2192 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 {\u03b1 : Type _} (p : \u03b1 \u2192 Prop) [DecidablePred p] (x : { a // \u00acp 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 {\u03b1 : Type _} (p : \u03b1 \u2192 Prop) [DecidablePred p] (a : \u03b1) (h : p a) :\n    (sumCompl p).symm a = Sum.inl \u27e8a, h\u27e9 :=\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 {\u03b1 : Type _} (p : \u03b1 \u2192 Prop) [DecidablePred p] (a : \u03b1)\n    (h : \u00acp a) : (sumCompl p).symm a = Sum.inr \u27e8a, h\u27e9 :=\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 {\u03b1 : Type _} {p q : \u03b1 \u2192 Prop} [DecidablePred p] [DecidablePred q]\n    (e : { x // p x } \u2243 { x // q x }) (f : { x // \u00acp x } \u2243 { x // \u00acq x }) : Perm \u03b1 :=\n  (sumCompl p).symm.trans ((sumCongr e f).trans (sumCompl q))\n#align equiv.subtype_congr Equiv.subtypeCongr\n-/\n\nopen Equiv\n\nvariable {\u03b5 : Type _} {p : \u03b5 \u2192 Prop} [DecidablePred p]\n\nvariable (ep ep' : Perm { a // p a }) (en en' : Perm { a // \u00acp a })\n\n#print Equiv.Perm.subtypeCongr /-\n/-- Combining permutations on `\u03b5` that permute only inside or outside the subtype\nsplit induced by `p : \u03b5 \u2192 Prop` constructs a permutation on `\u03b5`. -/\ndef Perm.subtypeCongr : Equiv.Perm \u03b5 :=\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 : \u03b5) :\n    ep.subtypeCongr en a = if h : p a then ep \u27e8a, h\u27e9 else en \u27e8a, h\u27e9 := 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 : \u03b5} (h : p a) : ep.subtypeCongr en a = ep \u27e8a, h\u27e9 := 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 : \u03b5} (h : \u00acp a) : ep.subtypeCongr en a = en \u27e8a, h\u27e9 := 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 // \u00acp 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 // \u00acp a }) = Equiv.refl \u03b5 :=\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  \u00b7 have : p (ep.symm \u27e8x, h\u27e9) := Subtype.property _\n    simp [perm.subtype_congr.apply, h, symm_apply_eq, this]\n  \u00b7 have : \u00acp (en.symm \u27e8x, h\u27e9) := 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  \u00b7 have : p (ep \u27e8x, h\u27e9) := Subtype.property _\n    simp [perm.subtype_congr.apply, h, this]\n  \u00b7 have : \u00acp (en \u27e8x, h\u27e9) := 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 : \u03b1 \u2192 Prop) [DecidablePred p] (x\u2080 : { a // p a } \u2192 \u03b2)\n\n#print Equiv.subtypePreimage /-\n/-- For a fixed function `x\u2080 : {a // p a} \u2192 \u03b2` defined on a subtype of `\u03b1`,\nthe subtype of functions `x : \u03b1 \u2192 \u03b2` that agree with `x\u2080` on the subtype `{a // p a}`\nis naturally equivalent to the type of functions `{a // \u00ac p a} \u2192 \u03b2`. -/\n@[simps]\ndef subtypePreimage : { x : \u03b1 \u2192 \u03b2 // x \u2218 coe = x\u2080 } \u2243 ({ a // \u00acp a } \u2192 \u03b2)\n    where\n  toFun (x : { x : \u03b1 \u2192 \u03b2 // x \u2218 coe = x\u2080 }) a := (x : \u03b1 \u2192 \u03b2) a\n  invFun x := \u27e8fun a => if h : p a then x\u2080 \u27e8a, h\u27e9 else x \u27e8a, h\u27e9, funext fun \u27e8a, h\u27e9 => dif_pos h\u27e9\n  left_inv := fun \u27e8x, hx\u27e9 =>\n    Subtype.val_injective <|\n      funext fun a => by\n        dsimp\n        split_ifs <;> [rw [\u2190 hx], skip] <;> rfl\n  right_inv x :=\n    funext fun \u27e8a, h\u27e9 =>\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (p : \u03b1 -> Prop) [_inst_1 : DecidablePred.{u1} \u03b1 p] (x\u2080 : (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (x : (Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (a : \u03b1) (h : p a), Eq.{u2} \u03b2 ((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} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) (\u03b1 -> \u03b2) (HasLiftT.mk.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) (\u03b1 -> \u03b2) (CoeTC\u2093.coe.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) (\u03b1 -> \u03b2) (coeBase.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) (\u03b1 -> \u03b2) (coeSubtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))))) (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} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))) (fun (_x : Equiv.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))) => ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) -> (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))) (Equiv.hasCoeToFun.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))) (Equiv.symm.{max 1 (imax u1 u2), imax (max 1 u1) u2} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Equiv.subtypePreimage.{u1, u2} \u03b1 \u03b2 p (fun (a : \u03b1) => _inst_1 a) x\u2080)) x) a) (x\u2080 (Subtype.mk.{u1} \u03b1 (fun (a : \u03b1) => p a) a h))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (p : \u03b1 -> Prop) [_inst_1 : DecidablePred.{u2} \u03b1 p] (x\u2080 : (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (x : (Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (a : \u03b1) (h : p a), Eq.{u1} \u03b2 (Subtype.val.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080) (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} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080))) ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (fun (_x : (Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : (Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) => Subtype.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080)) _x) (Equiv.instFunLikeEquiv.{imax (max 1 u2) u1, max 1 (imax u2 u1)} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080))) (Equiv.symm.{max 1 (imax u2 u1), imax (max 1 u2) u1} (Subtype.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080)) ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Equiv.subtypePreimage.{u2, u1} \u03b1 \u03b2 p (fun (a : \u03b1) => _inst_1 a) x\u2080)) x) a) (x\u2080 (Subtype.mk.{u2} \u03b1 (fun (a : \u03b1) => 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\u2093'. -/\ntheorem subtypePreimage_symm_apply_coe_pos (x : { a // \u00acp a } \u2192 \u03b2) (a : \u03b1) (h : p a) :\n    ((subtypePreimage p x\u2080).symm x : \u03b1 \u2192 \u03b2) a = x\u2080 \u27e8a, h\u27e9 :=\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (p : \u03b1 -> Prop) [_inst_1 : DecidablePred.{u1} \u03b1 p] (x\u2080 : (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (x : (Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (a : \u03b1) (h : Not (p a)), Eq.{u2} \u03b2 ((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} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) (\u03b1 -> \u03b2) (HasLiftT.mk.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) (\u03b1 -> \u03b2) (CoeTC\u2093.coe.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) (\u03b1 -> \u03b2) (coeBase.{max 1 (imax u1 u2), imax u1 u2} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) (\u03b1 -> \u03b2) (coeSubtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))))) (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} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))) (fun (_x : Equiv.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))) => ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) -> (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))) (Equiv.hasCoeToFun.{imax (max 1 u1) u2, max 1 (imax u1 u2)} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080))) (Equiv.symm.{max 1 (imax u1 u2), imax (max 1 u1) u2} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u1) u2} ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u1, u1, u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (a : \u03b1) => p a))))))) x\u2080)) ((Subtype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Equiv.subtypePreimage.{u1, u2} \u03b1 \u03b2 p (fun (a : \u03b1) => _inst_1 a) x\u2080)) x) a) (x (Subtype.mk.{u1} \u03b1 (fun (a : \u03b1) => Not (p a)) a h))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (p : \u03b1 -> Prop) [_inst_1 : DecidablePred.{u2} \u03b1 p] (x\u2080 : (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (x : (Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (a : \u03b1) (h : Not (p a)), Eq.{u1} \u03b2 (Subtype.val.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080) (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} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080))) ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (fun (_x : (Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : (Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) => Subtype.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080)) _x) (Equiv.instFunLikeEquiv.{imax (max 1 u2) u1, max 1 (imax u2 u1)} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Subtype.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080))) (Equiv.symm.{max 1 (imax u2 u1), imax (max 1 u2) u1} (Subtype.{imax u2 u1} (\u03b1 -> \u03b2) (fun (x : \u03b1 -> \u03b2) => Eq.{imax (max 1 u2) u1} ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) -> \u03b2) (Function.comp.{max 1 u2, u2, u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 \u03b2 x (Subtype.val.{u2} \u03b1 (fun (a : \u03b1) => p a))) x\u2080)) ((Subtype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a))) -> \u03b2) (Equiv.subtypePreimage.{u2, u1} \u03b1 \u03b2 p (fun (a : \u03b1) => _inst_1 a) x\u2080)) x) a) (x (Subtype.mk.{u2} \u03b1 (fun (a : \u03b1) => 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\u2093'. -/\ntheorem subtypePreimage_symm_apply_coe_neg (x : { a // \u00acp a } \u2192 \u03b2) (a : \u03b1) (h : \u00acp a) :\n    ((subtypePreimage p x\u2080).symm x : \u03b1 \u2192 \u03b2) a = x \u27e8a, h\u27e9 :=\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 `\u03a0 a, \u03b2\u2081 a \u2243 \u03b2\u2082 a` generates an equivalence between `\u03a0 a, \u03b2\u2081 a` and\n`\u03a0 a, \u03b2\u2082 a`. -/\ndef piCongrRight {\u03b1} {\u03b2\u2081 \u03b2\u2082 : \u03b1 \u2192 Sort _} (F : \u2200 a, \u03b2\u2081 a \u2243 \u03b2\u2082 a) : (\u2200 a, \u03b2\u2081 a) \u2243 \u2200 a, \u03b2\u2082 a :=\n  \u27e8fun 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\u27e9\n#align equiv.Pi_congr_right Equiv.piCongrRight\n-/\n\n#print Equiv.piComm /-\n/-- Given `\u03c6 : \u03b1 \u2192 \u03b2 \u2192 Sort*`, we have an equivalence between `\u03a0 a b, \u03c6 a b` and `\u03a0 b a, \u03c6 a b`.\nThis is `function.swap` as an `equiv`. -/\n@[simps apply]\ndef piComm {\u03b1 \u03b2} (\u03c6 : \u03b1 \u2192 \u03b2 \u2192 Sort _) : (\u2200 a b, \u03c6 a b) \u2243 \u2200 b a, \u03c6 a b :=\n  \u27e8swap, swap, fun x => rfl, fun y => rfl\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03c6 : \u03b1 -> \u03b2 -> 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 : \u03b2) (a : \u03b1), \u03c6 a b) (forall (a : \u03b1) (b : \u03b2), \u03c6 a b)) (Equiv.symm.{imax u1 u2 u3, imax u2 u1 u3} (forall (a : \u03b1) (b : \u03b2), \u03c6 a b) (forall (b : \u03b2) (a : \u03b1), \u03c6 a b) (Equiv.piComm.{u1, u2, u3} \u03b1 \u03b2 \u03c6)) (Equiv.piComm.{u2, u1, u3} \u03b2 \u03b1 (Function.swap.{u1, u2, succ u3} \u03b1 \u03b2 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b2) => Sort.{u3}) \u03c6))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03c6 : \u03b1 -> \u03b2 -> 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 : \u03b2) (a : \u03b1), \u03c6 a b) (forall (a : \u03b1) (b : \u03b2), \u03c6 a b)) (Equiv.symm.{imax u3 u2 u1, imax u2 u3 u1} (forall (a : \u03b1) (b : \u03b2), \u03c6 a b) (forall (b : \u03b2) (a : \u03b1), \u03c6 a b) (Equiv.piComm.{u3, u2, u1} \u03b1 \u03b2 \u03c6)) (Equiv.piComm.{u2, u3, u1} \u03b2 \u03b1 (Function.swap.{u3, u2, succ u1} \u03b1 \u03b2 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b2) => Sort.{u1}) \u03c6))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_comm_symm Equiv.piComm_symm\u2093'. -/\n@[simp]\ntheorem piComm_symm {\u03b1 \u03b2} {\u03c6 : \u03b1 \u2192 \u03b2 \u2192 Sort _} : (piComm \u03c6).symm = (piComm <| swap \u03c6) :=\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 `\u03a3 i, \u03b2 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 {\u03b1} {\u03b2 : \u03b1 \u2192 Sort _} (\u03b3 : \u2200 a, \u03b2 a \u2192 Sort _) : (\u2200 x : \u03a3i, \u03b2 i, \u03b3 x.1 x.2) \u2243 \u2200 a b, \u03b3 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 {\u03b1\u2081 \u03b2\u2081 \u03b2\u2082 : Type _} (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082)\n\n#print Equiv.prodCongrLeft /-\n/-- A family of equivalences `\u03a0 (a : \u03b1\u2081), \u03b2\u2081 \u2243 \u03b2\u2082` generates an equivalence\nbetween `\u03b2\u2081 \u00d7 \u03b1\u2081` and `\u03b2\u2082 \u00d7 \u03b1\u2081`. -/\ndef prodCongrLeft : \u03b2\u2081 \u00d7 \u03b1\u2081 \u2243 \u03b2\u2082 \u00d7 \u03b1\u2081\n    where\n  toFun ab := \u27e8e ab.2 ab.1, ab.2\u27e9\n  invFun ab := \u27e8(e ab.2).symm ab.1, ab.2\u27e9\n  left_inv := by\n    rintro \u27e8a, b\u27e9\n    simp\n  right_inv := by\n    rintro \u27e8a, b\u27e9\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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u3}} (e : \u03b1\u2081 -> (Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082)) (b : \u03b2\u2081) (a : \u03b1\u2081), Eq.{max (succ u3) (succ u1)} (Prod.{u3, u1} \u03b2\u2082 \u03b1\u2081) (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} \u03b2\u2081 \u03b1\u2081) (Prod.{u3, u1} \u03b2\u2082 \u03b1\u2081)) (fun (_x : Equiv.{max (succ u2) (succ u1), max (succ u3) (succ u1)} (Prod.{u2, u1} \u03b2\u2081 \u03b1\u2081) (Prod.{u3, u1} \u03b2\u2082 \u03b1\u2081)) => (Prod.{u2, u1} \u03b2\u2081 \u03b1\u2081) -> (Prod.{u3, u1} \u03b2\u2082 \u03b1\u2081)) (Equiv.hasCoeToFun.{max (succ u2) (succ u1), max (succ u3) (succ u1)} (Prod.{u2, u1} \u03b2\u2081 \u03b1\u2081) (Prod.{u3, u1} \u03b2\u2082 \u03b1\u2081)) (Equiv.prodCongrLeft.{u1, u2, u3} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 e) (Prod.mk.{u2, u1} \u03b2\u2081 \u03b1\u2081 b a)) (Prod.mk.{u3, u1} \u03b2\u2082 \u03b1\u2081 (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082) (fun (_x : Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082) => \u03b2\u2081 -> \u03b2\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082) (e a) b) a)\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u2}} {\u03b2\u2081 : Type.{u1}} {\u03b2\u2082 : Type.{u3}} (e : \u03b1\u2081 -> (Equiv.{succ u1, succ u3} \u03b2\u2081 \u03b2\u2082)) (b : \u03b2\u2081) (a : \u03b1\u2081), Eq.{max (succ u3) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u1, u2} \u03b2\u2081 \u03b1\u2081) => Prod.{u3, u2} \u03b2\u2082 \u03b1\u2081) (Prod.mk.{u1, u2} \u03b2\u2081 \u03b1\u2081 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} \u03b2\u2081 \u03b1\u2081) (Prod.{u3, u2} \u03b2\u2082 \u03b1\u2081)) (Prod.{u1, u2} \u03b2\u2081 \u03b1\u2081) (fun (_x : Prod.{u1, u2} \u03b2\u2081 \u03b1\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u1, u2} \u03b2\u2081 \u03b1\u2081) => Prod.{u3, u2} \u03b2\u2082 \u03b1\u2081) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u3) (succ u2)} (Prod.{u1, u2} \u03b2\u2081 \u03b1\u2081) (Prod.{u3, u2} \u03b2\u2082 \u03b1\u2081)) (Equiv.prodCongrLeft.{u2, u1, u3} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 e) (Prod.mk.{u1, u2} \u03b2\u2081 \u03b1\u2081 b a)) (Prod.mk.{u3, u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2\u2081) => \u03b2\u2082) b) \u03b1\u2081 (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (Equiv.{succ u1, succ u3} \u03b2\u2081 \u03b2\u2082) \u03b2\u2081 (fun (_x : \u03b2\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2\u2081) => \u03b2\u2082) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u3} \u03b2\u2081 \u03b2\u2082) (e a) b) a)\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_left_apply Equiv.prodCongrLeft_apply\u2093'. -/\n@[simp]\ntheorem prodCongrLeft_apply (b : \u03b2\u2081) (a : \u03b1\u2081) : 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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u3}} (e : Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082), 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} \u03b2\u2081 \u03b1\u2081) (Prod.{u3, u1} \u03b2\u2082 \u03b1\u2081)) (Equiv.prodCongr.{u2, u1, u3, u1} \u03b2\u2081 \u03b1\u2081 \u03b2\u2082 \u03b1\u2081 e (Equiv.refl.{succ u1} \u03b1\u2081)) (Equiv.prodCongrLeft.{u1, u2, u3} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 (fun (_x : \u03b1\u2081) => e))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u3}} {\u03b2\u2082 : Type.{u2}} (e : Equiv.{succ u3, succ u2} \u03b2\u2081 \u03b2\u2082), Eq.{max (max (succ u1) (succ u2)) (succ u3)} (Equiv.{max (succ u1) (succ u3), max (succ u1) (succ u2)} (Prod.{u3, u1} \u03b2\u2081 \u03b1\u2081) (Prod.{u2, u1} \u03b2\u2082 \u03b1\u2081)) (Equiv.prodCongr.{u3, u2, u1, u1} \u03b2\u2081 \u03b2\u2082 \u03b1\u2081 \u03b1\u2081 e (Equiv.refl.{succ u1} \u03b1\u2081)) (Equiv.prodCongrLeft.{u1, u3, u2} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 (fun (_x : \u03b1\u2081) => e))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_refl_right Equiv.prodCongr_refl_right\u2093'. -/\ntheorem prodCongr_refl_right (e : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    prodCongr e (Equiv.refl \u03b1\u2081) = prodCongrLeft fun _ => e :=\n  by\n  ext \u27e8a, b\u27e9 : 1\n  simp\n#align equiv.prod_congr_refl_right Equiv.prodCongr_refl_right\n\n#print Equiv.prodCongrRight /-\n/-- A family of equivalences `\u03a0 (a : \u03b1\u2081), \u03b2\u2081 \u2243 \u03b2\u2082` generates an equivalence\nbetween `\u03b1\u2081 \u00d7 \u03b2\u2081` and `\u03b1\u2081 \u00d7 \u03b2\u2082`. -/\ndef prodCongrRight : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2081 \u00d7 \u03b2\u2082\n    where\n  toFun ab := \u27e8ab.1, e ab.1 ab.2\u27e9\n  invFun ab := \u27e8ab.1, (e ab.1).symm ab.2\u27e9\n  left_inv := by\n    rintro \u27e8a, b\u27e9\n    simp\n  right_inv := by\n    rintro \u27e8a, b\u27e9\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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u3}} (e : \u03b1\u2081 -> (Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082)) (a : \u03b1\u2081) (b : \u03b2\u2081), Eq.{max (succ u1) (succ u3)} (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2082) (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} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2082)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2082)) => (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) -> (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2082)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2082)) (Equiv.prodCongrRight.{u1, u2, u3} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 e) (Prod.mk.{u1, u2} \u03b1\u2081 \u03b2\u2081 a b)) (Prod.mk.{u1, u3} \u03b1\u2081 \u03b2\u2082 a (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082) (fun (_x : Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082) => \u03b2\u2081 -> \u03b2\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082) (e a) b))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u2}} {\u03b2\u2081 : Type.{u1}} {\u03b2\u2082 : Type.{u3}} (e : \u03b1\u2081 -> (Equiv.{succ u1, succ u3} \u03b2\u2081 \u03b2\u2082)) (a : \u03b1\u2081) (b : \u03b2\u2081), Eq.{max (succ u3) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) => Prod.{u2, u3} \u03b1\u2081 \u03b2\u2082) (Prod.mk.{u2, u1} \u03b1\u2081 \u03b2\u2081 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} \u03b1\u2081 \u03b2\u2081) (Prod.{u2, u3} \u03b1\u2081 \u03b2\u2082)) (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) (fun (_x : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) => Prod.{u2, u3} \u03b1\u2081 \u03b2\u2082) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u3) (succ u2)} (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) (Prod.{u2, u3} \u03b1\u2081 \u03b2\u2082)) (Equiv.prodCongrRight.{u2, u1, u3} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 e) (Prod.mk.{u2, u1} \u03b1\u2081 \u03b2\u2081 a b)) (Prod.mk.{u2, u3} \u03b1\u2081 ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2\u2081) => \u03b2\u2082) b) a (FunLike.coe.{max (succ u3) (succ u1), succ u1, succ u3} (Equiv.{succ u1, succ u3} \u03b2\u2081 \u03b2\u2082) \u03b2\u2081 (fun (_x : \u03b2\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2\u2081) => \u03b2\u2082) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u3} \u03b2\u2081 \u03b2\u2082) (e a) b))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_right_apply Equiv.prodCongrRight_apply\u2093'. -/\n@[simp]\ntheorem prodCongrRight_apply (a : \u03b1\u2081) (b : \u03b2\u2081) : 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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u3}} (e : Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082), 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} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2082)) (Equiv.prodCongr.{u1, u2, u1, u3} \u03b1\u2081 \u03b2\u2081 \u03b1\u2081 \u03b2\u2082 (Equiv.refl.{succ u1} \u03b1\u2081) e) (Equiv.prodCongrRight.{u1, u2, u3} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 (fun (_x : \u03b1\u2081) => e))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u3}} {\u03b2\u2082 : Type.{u2}} (e : Equiv.{succ u3, succ u2} \u03b2\u2081 \u03b2\u2082), Eq.{max (max (succ u2) (succ u3)) (succ u1)} (Equiv.{max (succ u3) (succ u1), max (succ u2) (succ u1)} (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2082)) (Equiv.prodCongr.{u1, u1, u3, u2} \u03b1\u2081 \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 (Equiv.refl.{succ u1} \u03b1\u2081) e) (Equiv.prodCongrRight.{u1, u3, u2} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 (fun (_x : \u03b1\u2081) => e))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_congr_refl_left Equiv.prodCongr_refl_left\u2093'. -/\ntheorem prodCongr_refl_left (e : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    prodCongr (Equiv.refl \u03b1\u2081) e = prodCongrRight fun _ => e :=\n  by\n  ext \u27e8a, b\u27e9 : 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 \u27e8a, b\u27e9 : 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 \u27e8a, b\u27e9 : 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 \u03b1\u2081 \u03b2\u2082) =\n      (sigmaEquivProd \u03b1\u2081 \u03b2\u2081).trans (prodCongrRight e) :=\n  by\n  ext \u27e8a, b\u27e9 : 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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b2\u2082 : Type.{u3}} (e : \u03b1\u2081 -> (Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b2\u2082)), 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} \u03b1\u2081 \u03b2\u2081) (Sigma.{u1, u3} \u03b1\u2081 (fun (a : \u03b1\u2081) => \u03b2\u2082))) (Equiv.trans.{max (succ u1) (succ u2), max (succ u1) (succ u2), max (succ u1) (succ u3)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Sigma.{u1, u2} \u03b1\u2081 (fun (_x : \u03b1\u2081) => \u03b2\u2081)) (Sigma.{u1, u3} \u03b1\u2081 (fun (a : \u03b1\u2081) => \u03b2\u2082)) (Equiv.symm.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u1, u2} \u03b1\u2081 (fun (_x : \u03b1\u2081) => \u03b2\u2081)) (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Equiv.sigmaEquivProd.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (Equiv.sigmaCongrRight.{u1, u2, u3} \u03b1\u2081 (fun (_x : \u03b1\u2081) => \u03b2\u2081) (fun (\u1fb0 : \u03b1\u2081) => \u03b2\u2082) e)) (Equiv.trans.{max (succ u1) (succ u2), max (succ u1) (succ u3), max (succ u1) (succ u3)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2082) (Sigma.{u1, u3} \u03b1\u2081 (fun (a : \u03b1\u2081) => \u03b2\u2082)) (Equiv.prodCongrRight.{u1, u2, u3} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 e) (Equiv.symm.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (Sigma.{u1, u3} \u03b1\u2081 (fun (_x : \u03b1\u2081) => \u03b2\u2082)) (Prod.{u1, u3} \u03b1\u2081 \u03b2\u2082) (Equiv.sigmaEquivProd.{u1, u3} \u03b1\u2081 \u03b2\u2082)))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u2}} {\u03b2\u2081 : Type.{u3}} {\u03b2\u2082 : Type.{u1}} (e : \u03b1\u2081 -> (Equiv.{succ u3, succ u1} \u03b2\u2081 \u03b2\u2082)), Eq.{max (max (succ u3) (succ u2)) (succ u1)} (Equiv.{max (succ u3) (succ u2), max (succ u2) (succ u1)} (Prod.{u2, u3} \u03b1\u2081 \u03b2\u2081) (Sigma.{u2, u1} \u03b1\u2081 (fun (a : \u03b1\u2081) => \u03b2\u2082))) (Equiv.trans.{max (succ u3) (succ u2), max (succ u3) (succ u2), max (succ u2) (succ u1)} (Prod.{u2, u3} \u03b1\u2081 \u03b2\u2081) (Sigma.{u2, u3} \u03b1\u2081 (fun (_x : \u03b1\u2081) => \u03b2\u2081)) (Sigma.{u2, u1} \u03b1\u2081 (fun (a : \u03b1\u2081) => \u03b2\u2082)) (Equiv.symm.{max (succ u3) (succ u2), max (succ u3) (succ u2)} (Sigma.{u2, u3} \u03b1\u2081 (fun (_x : \u03b1\u2081) => \u03b2\u2081)) (Prod.{u2, u3} \u03b1\u2081 \u03b2\u2081) (Equiv.sigmaEquivProd.{u2, u3} \u03b1\u2081 \u03b2\u2081)) (Equiv.sigmaCongrRight.{u2, u3, u1} \u03b1\u2081 (fun (_x : \u03b1\u2081) => \u03b2\u2081) (fun (\u1fb0 : \u03b1\u2081) => \u03b2\u2082) e)) (Equiv.trans.{max (succ u3) (succ u2), max (succ u2) (succ u1), max (succ u2) (succ u1)} (Prod.{u2, u3} \u03b1\u2081 \u03b2\u2081) (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2082) (Sigma.{u2, u1} \u03b1\u2081 (fun (a : \u03b1\u2081) => \u03b2\u2082)) (Equiv.prodCongrRight.{u2, u3, u1} \u03b1\u2081 \u03b2\u2081 \u03b2\u2082 e) (Equiv.symm.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (Sigma.{u2, u1} \u03b1\u2081 (fun (_x : \u03b1\u2081) => \u03b2\u2082)) (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2082) (Equiv.sigmaEquivProd.{u2, u1} \u03b1\u2081 \u03b2\u2082)))\nCase conversion may be inaccurate. Consider using '#align equiv.sigma_equiv_prod_sigma_congr_right Equiv.sigmaEquivProd_sigmaCongrRight\u2093'. -/\ntheorem sigmaEquivProd_sigmaCongrRight :\n    (sigmaEquivProd \u03b1\u2081 \u03b2\u2081).symm.trans (sigmaCongrRight e) =\n      (prodCongrRight e).trans (sigmaEquivProd \u03b1\u2081 \u03b2\u2082).symm :=\n  by\n  ext \u27e8a, b\u27e9 : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b3} {g : \u03b2 -> \u03b3}, (forall (c : \u03b3), Equiv.{succ u1, succ u2} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u3} \u03b3 (f a) c)) (Subtype.{succ u2} \u03b2 (fun (b : \u03b2) => Eq.{succ u3} \u03b3 (g b) c))) -> (Equiv.{succ u1, succ u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b2}, (forall (c : \u03b2), Equiv.{succ u1, succ u3} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) c)) (Subtype.{succ u3} \u03b3 (fun (b : \u03b3) => Eq.{succ u2} \u03b2 (g b) c))) -> (Equiv.{succ u1, succ u3} \u03b1 \u03b3)\nCase conversion may be inaccurate. Consider using '#align equiv.of_fiber_equiv Equiv.ofFiberEquiv\u2093'. -/\n-- See also `equiv.of_preimage_equiv`.\n/-- A family of equivalences between fibers gives an equivalence between domains. -/\n@[simps]\ndef ofFiberEquiv {\u03b1 \u03b2 \u03b3 : Type _} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3}\n    (e : \u2200 c, { a // f a = c } \u2243 { b // g b = c }) : \u03b1 \u2243 \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b3} {g : \u03b2 -> \u03b3} (e : forall (c : \u03b3), Equiv.{succ u1, succ u2} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u3} \u03b3 (f a) c)) (Subtype.{succ u2} \u03b2 (fun (b : \u03b2) => Eq.{succ u3} \u03b3 (g b) c))) (a : \u03b1), Eq.{succ u3} \u03b3 (g (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Equiv.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) (Equiv.ofFiberEquiv.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b1) => f a) (fun (b : \u03b2) => g b) e) a)) (f a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {f : \u03b1 -> \u03b3} {g : \u03b2 -> \u03b3} (e : forall (c : \u03b3), Equiv.{succ u3, succ u2} (Subtype.{succ u3} \u03b1 (fun (a : \u03b1) => Eq.{succ u1} \u03b3 (f a) c)) (Subtype.{succ u2} \u03b2 (fun (b : \u03b2) => Eq.{succ u1} \u03b3 (g b) c))) (a : \u03b1), Eq.{succ u1} \u03b3 (g (FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u2} (Equiv.{succ u3, succ u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u3, succ u2} \u03b1 \u03b2) (Equiv.ofFiberEquiv.{u3, u1, u2} \u03b1 \u03b3 \u03b2 (fun (a : \u03b1) => f a) (fun (b : \u03b2) => g b) e) a)) (f a)\nCase conversion may be inaccurate. Consider using '#align equiv.of_fiber_equiv_map Equiv.ofFiberEquiv_map\u2093'. -/\ntheorem ofFiberEquiv_map {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3}\n    (e : \u2200 c, { a // f a = c } \u2243 { b // g b = c }) (a : \u03b1) : 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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{succ u1, succ u3} \u03b1\u2081 \u03b1\u2082) -> (\u03b1\u2081 -> (Equiv.{succ u2, succ u4} \u03b2\u2081 \u03b2\u2082)) -> (Equiv.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u3, u4} \u03b1\u2082 \u03b2\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} {\u03b1\u2082 : Type.{u3}} {\u03b2\u2082 : Type.{u4}}, (Equiv.{succ u1, succ u4} \u03b1\u2081 \u03b2\u2082) -> (\u03b1\u2081 -> (Equiv.{succ u2, succ u3} \u03b2\u2081 \u03b1\u2082)) -> (Equiv.{max (succ u2) (succ u1), max (succ u3) (succ u4)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u4, u3} \u03b2\u2082 \u03b1\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_shear Equiv.prodShear\u2093'. -/\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 {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Type _} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082\n    where\n  toFun := fun x : \u03b1\u2081 \u00d7 \u03b2\u2081 => (e\u2081 x.1, e\u2082 x.1 x.2)\n  invFun := fun y : \u03b1\u2082 \u00d7 \u03b2\u2082 => (e\u2081.symm y.1, (e\u2082 <| e\u2081.symm y.1).symm y.2)\n  left_inv := by\n    rintro \u27e8x\u2081, y\u2081\u27e9\n    simp only [symm_apply_apply]\n  right_inv := by\n    rintro \u27e8x\u2081, y\u2081\u27e9\n    simp only [apply_symm_apply]\n#align equiv.prod_shear Equiv.prodShear\n\nend ProdCongr\n\nnamespace Perm\n\nvariable {\u03b1\u2081 \u03b2\u2081 \u03b2\u2082 : Type _} [DecidableEq \u03b1\u2081] (a : \u03b1\u2081) (e : Perm \u03b2\u2081)\n\n#print Equiv.Perm.prodExtendRight /-\n/-- `prod_extend_right a e` extends `e : perm \u03b2` to `perm (\u03b1 \u00d7 \u03b2)` by sending `(a, b)` to\n`(a, e b)` and keeping the other `(a', b)` fixed. -/\ndef prodExtendRight : Perm (\u03b1\u2081 \u00d7 \u03b2\u2081)\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 \u27e8k', x\u27e9\n    dsimp only\n    split_ifs with h <;> simp [h]\n  right_inv := by\n    rintro \u27e8k', x\u27e9\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 : \u03b2\u2081) : 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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1\u2081] (e : Equiv.Perm.{succ u2} \u03b2\u2081) {a : \u03b1\u2081} {a' : \u03b1\u2081}, (Ne.{succ u1} \u03b1\u2081 a' a) -> (forall (b : \u03b2\u2081), Eq.{max (succ u1) (succ u2)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) => (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) -> (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (Equiv.Perm.prodExtendRight.{u1, u2} \u03b1\u2081 \u03b2\u2081 (fun (a : \u03b1\u2081) (b : \u03b1\u2081) => _inst_1 a b) a e) (Prod.mk.{u1, u2} \u03b1\u2081 \u03b2\u2081 a' b)) (Prod.mk.{u1, u2} \u03b1\u2081 \u03b2\u2081 a' b))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u2}} {\u03b2\u2081 : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b1\u2081] (e : Equiv.Perm.{succ u1} \u03b2\u2081) {a : \u03b1\u2081} {a' : \u03b1\u2081}, (Ne.{succ u2} \u03b1\u2081 a' a) -> (forall (b : \u03b2\u2081), Eq.{max (succ u1) (succ u2)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) => Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) (Prod.mk.{u2, u1} \u03b1\u2081 \u03b2\u2081 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} \u03b1\u2081 \u03b2\u2081)) (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) (fun (_x : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) => Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081)) (Equiv.Perm.prodExtendRight.{u2, u1} \u03b1\u2081 \u03b2\u2081 (fun (a : \u03b1\u2081) (b : \u03b1\u2081) => _inst_1 a b) a e) (Prod.mk.{u2, u1} \u03b1\u2081 \u03b2\u2081 a' b)) (Prod.mk.{u2, u1} \u03b1\u2081 \u03b2\u2081 a' b))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.prod_extend_right_apply_ne Equiv.Perm.prodExtendRight_apply_ne\u2093'. -/\ntheorem prodExtendRight_apply_ne {a a' : \u03b1\u2081} (h : a' \u2260 a) (b : \u03b2\u2081) :\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 \u03b2\u2081} {a a' : \u03b1\u2081} {b : \u03b2\u2081}\n    (h : prodExtendRight a e (a', b) \u2260 (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 {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1\u2081] (a : \u03b1\u2081) (e : Equiv.Perm.{succ u2} \u03b2\u2081) (ab : Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081), Eq.{succ u1} \u03b1\u2081 (Prod.fst.{u1, u2} \u03b1\u2081 \u03b2\u2081 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (fun (_x : Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) => (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) -> (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (Equiv.hasCoeToFun.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Prod.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (Equiv.Perm.prodExtendRight.{u1, u2} \u03b1\u2081 \u03b2\u2081 (fun (a : \u03b1\u2081) (b : \u03b1\u2081) => _inst_1 a b) a e) ab)) (Prod.fst.{u1, u2} \u03b1\u2081 \u03b2\u2081 ab)\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u2}} {\u03b2\u2081 : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b1\u2081] (a : \u03b1\u2081) (e : Equiv.Perm.{succ u1} \u03b2\u2081) (ab : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081), Eq.{succ u2} \u03b1\u2081 (Prod.fst.{u2, u1} \u03b1\u2081 \u03b2\u2081 (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} \u03b1\u2081 \u03b2\u2081)) (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) (fun (_x : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) => Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081) (Prod.{u2, u1} \u03b1\u2081 \u03b2\u2081)) (Equiv.Perm.prodExtendRight.{u2, u1} \u03b1\u2081 \u03b2\u2081 (fun (a : \u03b1\u2081) (b : \u03b1\u2081) => _inst_1 a b) a e) ab)) (Prod.fst.{u2, u1} \u03b1\u2081 \u03b2\u2081 ab)\nCase conversion may be inaccurate. Consider using '#align equiv.perm.fst_prod_extend_right Equiv.Perm.fst_prodExtendRight\u2093'. -/\n@[simp]\ntheorem fst_prodExtendRight (ab : \u03b1\u2081 \u00d7 \u03b2\u2081) : (prodExtendRight a e ab).fst = ab.fst :=\n  by\n  rw [prod_extend_right, [anonymous]]\n  split_ifs with h\n  \u00b7 rw [h]\n  \u00b7 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 `\u03b1 \u00d7 \u03b2` is equivalent to the type of pairs of functions\n`\u03b3 \u2192 \u03b1` and `\u03b3 \u2192 \u03b2`. -/\ndef arrowProdEquivProdArrow (\u03b1 \u03b2 \u03b3 : Type _) : (\u03b3 \u2192 \u03b1 \u00d7 \u03b2) \u2243 (\u03b3 \u2192 \u03b1) \u00d7 (\u03b3 \u2192 \u03b2) :=\n  \u27e8fun 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\u27e9\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 `\u03b1 \u2295 \u03b2` is equivalent to the type of pairs of functions\non `\u03b1` and on `\u03b2`. -/\ndef sumArrowEquivProdArrow (\u03b1 \u03b2 \u03b3 : Type _) : (Sum \u03b1 \u03b2 \u2192 \u03b3) \u2243 (\u03b1 \u2192 \u03b3) \u00d7 (\u03b2 \u2192 \u03b3) :=\n  \u27e8fun f => (f \u2218 inl, f \u2218 inr), fun p => Sum.elim p.1 p.2, fun f => by ext \u27e8\u27e9 <;> rfl, fun p =>\n    by\n    cases p\n    rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : (Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (a : \u03b1), Eq.{succ u3} \u03b3 (Prod.fst.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3) (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} \u03b1 \u03b2) -> \u03b3) (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) (fun (_x : Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) => ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) -> (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) (Equiv.hasCoeToFun.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) (Equiv.sumArrowEquivProdArrow.{u1, u2, u3} \u03b1 \u03b2 \u03b3) f) a) (f (Sum.inl.{u1, u2} \u03b1 \u03b2 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (f : (Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) (a : \u03b1), Eq.{succ u1} \u03b3 (Prod.fst.{max u3 u1, max u2 u1} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3) (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} \u03b1 \u03b2) -> \u03b3) (Prod.{max u3 u1, max u2 u1} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) ((Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) (fun (_x : (Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : (Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) => Prod.{max u3 u1, max u2 u1} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) (Prod.{max u3 u1, max u2 u1} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) (Equiv.sumArrowEquivProdArrow.{u3, u2, u1} \u03b1 \u03b2 \u03b3) f) a) (f (Sum.inl.{u3, u2} \u03b1 \u03b2 a))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_arrow_equiv_prod_arrow_apply_fst Equiv.sumArrowEquivProdArrow_apply_fst\u2093'. -/\n@[simp]\ntheorem sumArrowEquivProdArrow_apply_fst {\u03b1 \u03b2 \u03b3} (f : Sum \u03b1 \u03b2 \u2192 \u03b3) (a : \u03b1) :\n    (sumArrowEquivProdArrow \u03b1 \u03b2 \u03b3 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : (Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (b : \u03b2), Eq.{succ u3} \u03b3 (Prod.snd.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3) (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} \u03b1 \u03b2) -> \u03b3) (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) (fun (_x : Equiv.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) => ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) -> (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) (Equiv.hasCoeToFun.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) (Equiv.sumArrowEquivProdArrow.{u1, u2, u3} \u03b1 \u03b2 \u03b3) f) b) (f (Sum.inr.{u1, u2} \u03b1 \u03b2 b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (f : (Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) (b : \u03b2), Eq.{succ u1} \u03b3 (Prod.snd.{max u3 u1, max u2 u1} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3) (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} \u03b1 \u03b2) -> \u03b3) (Prod.{max u3 u1, max u2 u1} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) ((Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) (fun (_x : (Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : (Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) => Prod.{max u3 u1, max u2 u1} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) (Prod.{max u3 u1, max u2 u1} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3))) (Equiv.sumArrowEquivProdArrow.{u3, u2, u1} \u03b1 \u03b2 \u03b3) f) b) (f (Sum.inr.{u3, u2} \u03b1 \u03b2 b))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_arrow_equiv_prod_arrow_apply_snd Equiv.sumArrowEquivProdArrow_apply_snd\u2093'. -/\n@[simp]\ntheorem sumArrowEquivProdArrow_apply_snd {\u03b1 \u03b2 \u03b3} (f : Sum \u03b1 \u03b2 \u2192 \u03b3) (b : \u03b2) :\n    (sumArrowEquivProdArrow \u03b1 \u03b2 \u03b3 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b3) (g : \u03b2 -> \u03b3) (a : \u03b1), Eq.{succ u3} \u03b3 (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} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3)) (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} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3)) => (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) -> (Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (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} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3)) (Equiv.symm.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) (Equiv.sumArrowEquivProdArrow.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Prod.mk.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3) f g) (Sum.inl.{u1, u2} \u03b1 \u03b2 a)) (f a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (f : \u03b1 -> \u03b2) (g : \u03b3 -> \u03b2) (a : \u03b1), Eq.{succ u2} \u03b2 (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} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) ((Sum.{u3, u1} \u03b1 \u03b3) -> \u03b2)) (Prod.{max u3 u2, max u1 u2} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) (fun (_x : Prod.{max u3 u2, max u1 u2} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u3 u2, max u1 u2} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) => (Sum.{u3, u1} \u03b1 \u03b3) -> \u03b2) _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} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) ((Sum.{u3, u1} \u03b1 \u03b3) -> \u03b2)) (Equiv.symm.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} ((Sum.{u3, u1} \u03b1 \u03b3) -> \u03b2) (Prod.{max u3 u2, max u1 u2} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) (Equiv.sumArrowEquivProdArrow.{u3, u1, u2} \u03b1 \u03b3 \u03b2)) (Prod.mk.{max u2 u3, max u2 u1} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2) f g) (Sum.inl.{u3, u1} \u03b1 \u03b3 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\u2093'. -/\n@[simp]\ntheorem sumArrowEquivProdArrow_symm_apply_inl {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) (a : \u03b1) :\n    ((sumArrowEquivProdArrow \u03b1 \u03b2 \u03b3).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b3) (g : \u03b2 -> \u03b3) (b : \u03b2), Eq.{succ u3} \u03b3 (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} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3)) (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} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3)) => (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) -> (Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (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} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3)) (Equiv.symm.{max (max (succ u1) (succ u2)) (succ u3), max (succ (max u1 u3)) (succ (max u2 u3))} ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Prod.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3)) (Equiv.sumArrowEquivProdArrow.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Prod.mk.{max u1 u3, max u2 u3} (\u03b1 -> \u03b3) (\u03b2 -> \u03b3) f g) (Sum.inr.{u1, u2} \u03b1 \u03b2 b)) (g b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (f : \u03b1 -> \u03b2) (g : \u03b3 -> \u03b2) (b : \u03b3), Eq.{succ u2} \u03b2 (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} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) ((Sum.{u3, u1} \u03b1 \u03b3) -> \u03b2)) (Prod.{max u3 u2, max u1 u2} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) (fun (_x : Prod.{max u3 u2, max u1 u2} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u3 u2, max u1 u2} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) => (Sum.{u3, u1} \u03b1 \u03b3) -> \u03b2) _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} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) ((Sum.{u3, u1} \u03b1 \u03b3) -> \u03b2)) (Equiv.symm.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} ((Sum.{u3, u1} \u03b1 \u03b3) -> \u03b2) (Prod.{max u3 u2, max u1 u2} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2)) (Equiv.sumArrowEquivProdArrow.{u3, u1, u2} \u03b1 \u03b3 \u03b2)) (Prod.mk.{max u2 u3, max u2 u1} (\u03b1 -> \u03b2) (\u03b3 -> \u03b2) f g) (Sum.inr.{u3, u1} \u03b1 \u03b3 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\u2093'. -/\n@[simp]\ntheorem sumArrowEquivProdArrow_symm_apply_inr {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) (b : \u03b2) :\n    ((sumArrowEquivProdArrow \u03b1 \u03b2 \u03b3).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 (\u03b1 \u03b2 \u03b3 : Sort _) : Sum \u03b1 \u03b2 \u00d7 \u03b3 \u2243 Sum (\u03b1 \u00d7 \u03b3) (\u03b2 \u00d7 \u03b3) :=\n  \u27e8fun 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 \u27e8_ | _, _\u27e9 <;> rfl, by\n    rintro (\u27e8_, _\u27e9 | \u27e8_, _\u27e9) <;> rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (a : \u03b1) (c : \u03b3), Eq.{max (succ (max u1 u3)) (succ (max u2 u3))} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) \u03b3) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3))) => (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) -> (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) \u03b3) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3))) (Equiv.sumProdDistrib.{u1, u2, u3} \u03b1 \u03b2 \u03b3) (Prod.mk.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 (Sum.inl.{u1, u2} \u03b1 \u03b2 a) c)) (Sum.inl.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3) (Prod.mk.{u1, u3} \u03b1 \u03b3 a c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (a : \u03b1) (c : \u03b2), 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} \u03b1 \u03b3) \u03b2) => Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) (Prod.mk.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2 (Sum.inl.{u3, u1} \u03b1 \u03b3 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} \u03b1 \u03b3) \u03b2) (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2))) (Prod.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2) (fun (_x : Prod.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2) => Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) _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} \u03b1 \u03b3) \u03b2) (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2))) (Equiv.sumProdDistrib.{u3, u1, u2} \u03b1 \u03b3 \u03b2) (Prod.mk.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2 (Sum.inl.{u3, u1} \u03b1 \u03b3 a) c)) (Sum.inl.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2) (Prod.mk.{u3, u2} \u03b1 \u03b2 a c))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_prod_distrib_apply_left Equiv.sumProdDistrib_apply_left\u2093'. -/\n@[simp]\ntheorem sumProdDistrib_apply_left {\u03b1 \u03b2 \u03b3} (a : \u03b1) (c : \u03b3) :\n    sumProdDistrib \u03b1 \u03b2 \u03b3 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (b : \u03b2) (c : \u03b3), Eq.{max (succ (max u1 u3)) (succ (max u2 u3))} (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) \u03b3) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3))) => (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) -> (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) \u03b3) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3))) (Equiv.sumProdDistrib.{u1, u2, u3} \u03b1 \u03b2 \u03b3) (Prod.mk.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 (Sum.inr.{u1, u2} \u03b1 \u03b2 b) c)) (Sum.inr.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3) (Prod.mk.{u2, u3} \u03b2 \u03b3 b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (b : \u03b1) (c : \u03b2), 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} \u03b3 \u03b1) \u03b2) => Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) (Prod.mk.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2 (Sum.inr.{u1, u3} \u03b3 \u03b1 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} \u03b3 \u03b1) \u03b2) (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2))) (Prod.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2) (fun (_x : Prod.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2) => Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) _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} \u03b3 \u03b1) \u03b2) (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2))) (Equiv.sumProdDistrib.{u1, u3, u2} \u03b3 \u03b1 \u03b2) (Prod.mk.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2 (Sum.inr.{u1, u3} \u03b3 \u03b1 b) c)) (Sum.inr.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2) (Prod.mk.{u3, u2} \u03b1 \u03b2 b c))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_prod_distrib_apply_right Equiv.sumProdDistrib_apply_right\u2093'. -/\n@[simp]\ntheorem sumProdDistrib_apply_right {\u03b1 \u03b2 \u03b3} (b : \u03b2) (c : \u03b3) :\n    sumProdDistrib \u03b1 \u03b2 \u03b3 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (a : Prod.{u1, u3} \u03b1 \u03b3), Eq.{max (succ (max u1 u2)) (succ u3)} (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (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} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) => (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) -> (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (Equiv.sumProdDistrib.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Sum.inl.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3) a)) (Prod.mk.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u1, u3} \u03b1 \u03b3 a)) (Prod.snd.{u1, u3} \u03b1 \u03b3 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (a : Prod.{u3, u2} \u03b1 \u03b2), 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} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) => Prod.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2) (Sum.inl.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2) 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} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) (Prod.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2)) (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) (fun (_x : Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) => Prod.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2) _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} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) (Prod.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2)) (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} \u03b1 \u03b3) \u03b2) (Sum.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2)) (Equiv.sumProdDistrib.{u3, u1, u2} \u03b1 \u03b3 \u03b2)) (Sum.inl.{max u2 u3, max u2 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b3 \u03b2) a)) (Prod.mk.{max u1 u3, u2} (Sum.{u3, u1} \u03b1 \u03b3) \u03b2 (Sum.inl.{u3, u1} \u03b1 \u03b3 (Prod.fst.{u3, u2} \u03b1 \u03b2 a)) (Prod.snd.{u3, u2} \u03b1 \u03b2 a))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_prod_distrib_symm_apply_left Equiv.sumProdDistrib_symm_apply_left\u2093'. -/\n@[simp]\ntheorem sumProdDistrib_symm_apply_left {\u03b1 \u03b2 \u03b3} (a : \u03b1 \u00d7 \u03b3) :\n    (sumProdDistrib \u03b1 \u03b2 \u03b3).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (b : Prod.{u2, u3} \u03b2 \u03b3), Eq.{max (succ (max u1 u2)) (succ u3)} (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3) (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} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) => (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) -> (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (Prod.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3)) (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} \u03b1 \u03b2) \u03b3) (Sum.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3)) (Equiv.sumProdDistrib.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Sum.inr.{max u1 u3, max u2 u3} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u3} \u03b2 \u03b3) b)) (Prod.mk.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) \u03b3 (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u2, u3} \u03b2 \u03b3 b)) (Prod.snd.{u2, u3} \u03b2 \u03b3 b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (b : Prod.{u3, u2} \u03b1 \u03b2), 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} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) => Prod.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2) (Sum.inr.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2) 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} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) (Prod.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2)) (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) (fun (_x : Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) => Prod.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2) _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} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) (Prod.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2)) (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} \u03b3 \u03b1) \u03b2) (Sum.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2)) (Equiv.sumProdDistrib.{u1, u3, u2} \u03b3 \u03b1 \u03b2)) (Sum.inr.{max u2 u1, max u2 u3} (Prod.{u1, u2} \u03b3 \u03b2) (Prod.{u3, u2} \u03b1 \u03b2) b)) (Prod.mk.{max u3 u1, u2} (Sum.{u1, u3} \u03b3 \u03b1) \u03b2 (Sum.inr.{u1, u3} \u03b3 \u03b1 (Prod.fst.{u3, u2} \u03b1 \u03b2 b)) (Prod.snd.{u3, u2} \u03b1 \u03b2 b))\nCase conversion may be inaccurate. Consider using '#align equiv.sum_prod_distrib_symm_apply_right Equiv.sumProdDistrib_symm_apply_right\u2093'. -/\n@[simp]\ntheorem sumProdDistrib_symm_apply_right {\u03b1 \u03b2 \u03b3} (b : \u03b2 \u00d7 \u03b3) :\n    (sumProdDistrib \u03b1 \u03b2 \u03b3).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 (\u03b1 \u03b2 \u03b3 : Sort _) : \u03b1 \u00d7 Sum \u03b2 \u03b3 \u2243 Sum (\u03b1 \u00d7 \u03b2) (\u03b1 \u00d7 \u03b3) :=\n  calc\n    \u03b1 \u00d7 Sum \u03b2 \u03b3 \u2243 Sum \u03b2 \u03b3 \u00d7 \u03b1 := prodComm _ _\n    _ \u2243 Sum (\u03b2 \u00d7 \u03b1) (\u03b3 \u00d7 \u03b1) := (sumProdDistrib _ _ _)\n    _ \u2243 Sum (\u03b1 \u00d7 \u03b2) (\u03b1 \u00d7 \u03b3) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (a : \u03b1) (b : \u03b2), Eq.{max (succ (max u1 u2)) (succ (max u1 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (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} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3))) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3))) => (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) -> (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3))) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3))) (Equiv.prodSumDistrib.{u1, u2, u3} \u03b1 \u03b2 \u03b3) (Prod.mk.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) a (Sum.inl.{u2, u3} \u03b2 \u03b3 b))) (Sum.inl.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3) (Prod.mk.{u1, u2} \u03b1 \u03b2 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (a : \u03b1) (b : \u03b2), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) (Prod.mk.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) a (Sum.inl.{u2, u1} \u03b2 \u03b3 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} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3))) (Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (fun (_x : Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) => Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u1) (succ u2)) (succ u3), max (max (succ u1) (succ u2)) (succ u3)} (Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3))) (Equiv.prodSumDistrib.{u3, u2, u1} \u03b1 \u03b2 \u03b3) (Prod.mk.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) a (Sum.inl.{u2, u1} \u03b2 \u03b3 b))) (Sum.inl.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3) (Prod.mk.{u3, u2} \u03b1 \u03b2 a b))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_sum_distrib_apply_left Equiv.prodSumDistrib_apply_left\u2093'. -/\n@[simp]\ntheorem prodSumDistrib_apply_left {\u03b1 \u03b2 \u03b3} (a : \u03b1) (b : \u03b2) :\n    prodSumDistrib \u03b1 \u03b2 \u03b3 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (a : \u03b1) (c : \u03b3), Eq.{max (succ (max u1 u2)) (succ (max u1 u3))} (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (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} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3))) (fun (_x : Equiv.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3))) => (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) -> (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3))) (Equiv.hasCoeToFun.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3))) (Equiv.prodSumDistrib.{u1, u2, u3} \u03b1 \u03b2 \u03b3) (Prod.mk.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) a (Sum.inr.{u2, u3} \u03b2 \u03b3 c))) (Sum.inr.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3) (Prod.mk.{u1, u3} \u03b1 \u03b3 a c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (a : \u03b1) (c : \u03b2), Eq.{max (max (succ u2) (succ u1)) (succ u3)} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) => Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) (Prod.mk.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2) a (Sum.inr.{u1, u2} \u03b3 \u03b2 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} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2))) (Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) (fun (_x : Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) => Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) _x) (Equiv.instFunLikeEquiv.{max (max (succ u2) (succ u1)) (succ u3), max (max (succ u2) (succ u1)) (succ u3)} (Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2))) (Equiv.prodSumDistrib.{u3, u1, u2} \u03b1 \u03b3 \u03b2) (Prod.mk.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2) a (Sum.inr.{u1, u2} \u03b3 \u03b2 c))) (Sum.inr.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2) (Prod.mk.{u3, u2} \u03b1 \u03b2 a c))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_sum_distrib_apply_right Equiv.prodSumDistrib_apply_right\u2093'. -/\n@[simp]\ntheorem prodSumDistrib_apply_right {\u03b1 \u03b2 \u03b3} (a : \u03b1) (c : \u03b3) :\n    prodSumDistrib \u03b1 \u03b2 \u03b3 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (a : Prod.{u1, u2} \u03b1 \u03b2), Eq.{max (succ u1) (succ (max u2 u3))} (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (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} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) => (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) -> (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (Equiv.symm.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (Equiv.prodSumDistrib.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Sum.inl.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3) a)) (Prod.mk.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) (Prod.fst.{u1, u2} \u03b1 \u03b2 a) (Sum.inl.{u2, u3} \u03b2 \u03b3 (Prod.snd.{u1, u2} \u03b1 \u03b2 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (a : Prod.{u3, u2} \u03b1 \u03b2), 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} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) => Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.inl.{max u2 u3, max u3 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3) 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} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) (Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3))) (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) (fun (_x : Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) => Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) _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} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) (Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3))) (Equiv.symm.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Prod.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3)) (Sum.{max u2 u3, max u1 u3} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3)) (Equiv.prodSumDistrib.{u3, u2, u1} \u03b1 \u03b2 \u03b3)) (Sum.inl.{max u2 u3, max u3 u1} (Prod.{u3, u2} \u03b1 \u03b2) (Prod.{u3, u1} \u03b1 \u03b3) a)) (Prod.mk.{u3, max u1 u2} \u03b1 (Sum.{u2, u1} \u03b2 \u03b3) (Prod.fst.{u3, u2} \u03b1 \u03b2 a) (Sum.inl.{u2, u1} \u03b2 \u03b3 (Prod.snd.{u3, u2} \u03b1 \u03b2 a)))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_sum_distrib_symm_apply_left Equiv.prodSumDistrib_symm_apply_left\u2093'. -/\n@[simp]\ntheorem prodSumDistrib_symm_apply_left {\u03b1 \u03b2 \u03b3} (a : \u03b1 \u00d7 \u03b2) :\n    (prodSumDistrib \u03b1 \u03b2 \u03b3).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (a : Prod.{u1, u3} \u03b1 \u03b3), Eq.{max (succ u1) (succ (max u2 u3))} (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (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} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) => (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) -> (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (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} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3))) (Equiv.symm.{max (succ u1) (succ (max u2 u3)), max (succ (max u1 u2)) (succ (max u1 u3))} (Prod.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3)) (Sum.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3)) (Equiv.prodSumDistrib.{u1, u2, u3} \u03b1 \u03b2 \u03b3)) (Sum.inr.{max u1 u2, max u1 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u3} \u03b1 \u03b3) a)) (Prod.mk.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) (Prod.fst.{u1, u3} \u03b1 \u03b3 a) (Sum.inr.{u2, u3} \u03b2 \u03b3 (Prod.snd.{u1, u3} \u03b1 \u03b3 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (a : Prod.{u3, u2} \u03b1 \u03b2), 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} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) => Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) (Sum.inr.{max u3 u1, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2) 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} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) (Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2))) (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) (fun (_x : Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) => Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) _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} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) (Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2))) (Equiv.symm.{max (max (succ u2) (succ u3)) (succ u1), max (max (succ u2) (succ u3)) (succ u1)} (Prod.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2)) (Sum.{max u1 u3, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2)) (Equiv.prodSumDistrib.{u3, u1, u2} \u03b1 \u03b3 \u03b2)) (Sum.inr.{max u3 u1, max u2 u3} (Prod.{u3, u1} \u03b1 \u03b3) (Prod.{u3, u2} \u03b1 \u03b2) a)) (Prod.mk.{u3, max u2 u1} \u03b1 (Sum.{u1, u2} \u03b3 \u03b2) (Prod.fst.{u3, u2} \u03b1 \u03b2 a) (Sum.inr.{u1, u2} \u03b3 \u03b2 (Prod.snd.{u3, u2} \u03b1 \u03b2 a)))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_sum_distrib_symm_apply_right Equiv.prodSumDistrib_symm_apply_right\u2093'. -/\n@[simp]\ntheorem prodSumDistrib_symm_apply_right {\u03b1 \u03b2 \u03b3} (a : \u03b1 \u00d7 \u03b3) :\n    (prodSumDistrib \u03b1 \u03b2 \u03b3).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 {\u03b9 : Type _} (\u03b1 \u03b2 : \u03b9 \u2192 Type _) :\n    (\u03a3i, Sum (\u03b1 i) (\u03b2 i)) \u2243 Sum (\u03a3i, \u03b1 i) (\u03a3i, \u03b2 i) :=\n  \u27e8fun 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 \u27e8i, a | b\u27e9 <;> rfl, fun p => by rcases p with (\u27e8i, a\u27e9 | \u27e8i, b\u27e9) <;> rfl\u27e9\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 `\u03a3 i, \u03b1 i`) by a type `\u03b2` is\nequivalent to the sum of products `\u03a3 i, (\u03b1 i \u00d7 \u03b2)`. -/\ndef sigmaProdDistrib {\u03b9 : Type _} (\u03b1 : \u03b9 \u2192 Type _) (\u03b2 : Type _) : (\u03a3i, \u03b1 i) \u00d7 \u03b2 \u2243 \u03a3i, \u03b1 i \u00d7 \u03b2 :=\n  \u27e8fun p => \u27e8p.1.1, (p.1.2, p.2)\u27e9, fun p => (\u27e8p.1, p.2.1\u27e9, p.2.2), fun p =>\n    by\n    rcases p with \u27e8\u27e8_, _\u27e9, _\u27e9\n    rfl, fun p => by\n    rcases p with \u27e8_, \u27e8_, _\u27e9\u27e9\n    rfl\u27e9\n#align equiv.sigma_prod_distrib Equiv.sigmaProdDistrib\n-/\n\n#print Equiv.sigmaNatSucc /-\n/-- An equivalence that separates out the 0th fiber of `(\u03a3 (n : \u2115), f n)`. -/\ndef sigmaNatSucc (f : \u2115 \u2192 Type u) : (\u03a3n, f n) \u2243 Sum (f 0) (\u03a3n, f (n + 1)) :=\n  \u27e8fun x =>\n    @Sigma.casesOn \u2115 f (fun _ => Sum (f 0) (\u03a3n, f (n + 1))) x fun n =>\n      @Nat.casesOn (fun i => f i \u2192 Sum (f 0) (\u03a3n : \u2115, f (n + 1))) n (fun x : f 0 => Sum.inl x)\n        fun (n : \u2115) (x : f n.succ) => Sum.inr \u27e8n, x\u27e9,\n    Sum.elim (Sigma.mk 0) (Sigma.map Nat.succ fun _ => id), by rintro \u27e8n | n, x\u27e9 <;> rfl, by\n    rintro (x | \u27e8n, x\u27e9) <;> rfl\u27e9\n#align equiv.sigma_nat_succ Equiv.sigmaNatSucc\n-/\n\n#print Equiv.boolProdEquivSum /-\n/-- The product `bool \u00d7 \u03b1` is equivalent to `\u03b1 \u2295 \u03b1`. -/\n@[simps]\ndef boolProdEquivSum (\u03b1 : Type u) : Bool \u00d7 \u03b1 \u2243 Sum \u03b1 \u03b1\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 \u27e8_ | _, _\u27e9 <;> 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 \u2192 \u03b1` is equivalent to `\u03b1 \u00d7 \u03b1`. -/\n@[simps]\ndef boolArrowEquivProd (\u03b1 : Type u) : (Bool \u2192 \u03b1) \u2243 \u03b1 \u00d7 \u03b1\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 \u27e8rfl, rfl\u27e9\n  right_inv := fun \u27e8x, y\u27e9 => 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 `\u2115 \u2295 punit`. -/\ndef natEquivNatSumPUnit : \u2115 \u2243 Sum \u2115 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/-- `\u2115 \u2295 punit` is equivalent to `\u2115`. -/\ndef natSumPUnitEquivNat : Sum \u2115 PUnit.{u + 1} \u2243 \u2115 :=\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 `\u2115 \u2295 \u2115`. -/\ndef intEquivNatSumNat : \u2124 \u2243 Sum \u2115 \u2115\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 `\u03b1` and `\u03b2` generates an equivalence between `list \u03b1` and `list \u03b2`. -/\ndef listEquivOfEquiv {\u03b1 \u03b2 : Type _} (e : \u03b1 \u2243 \u03b2) : List \u03b1 \u2243 List \u03b2\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 `\u03b1` is equivalent to `\u03b2`, then `unique \u03b1` is equivalent to `unique \u03b2`. -/\ndef uniqueCongr (e : \u03b1 \u2243 \u03b2) : Unique \u03b1 \u2243 Unique \u03b2\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}}, (Equiv.{u1, u2} \u03b1 \u03b2) -> (Iff (IsEmpty.{u1} \u03b1) (IsEmpty.{u2} \u03b2))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}}, (Equiv.{u2, u1} \u03b1 \u03b2) -> (Iff (IsEmpty.{u2} \u03b1) (IsEmpty.{u1} \u03b2))\nCase conversion may be inaccurate. Consider using '#align equiv.is_empty_congr Equiv.isEmpty_congr\u2093'. -/\n/-- If `\u03b1` is equivalent to `\u03b2`, then `is_empty \u03b1` is equivalent to `is_empty \u03b2`. -/\ntheorem isEmpty_congr (e : \u03b1 \u2243 \u03b2) : IsEmpty \u03b1 \u2194 IsEmpty \u03b2 :=\n  \u27e8fun h => @Function.isEmpty _ _ h e.symm, fun h => @Function.isEmpty _ _ h e\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}}, (Equiv.{u1, u2} \u03b1 \u03b2) -> (forall [_inst_1 : IsEmpty.{u2} \u03b2], IsEmpty.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}}, (Equiv.{u2, u1} \u03b1 \u03b2) -> (forall [_inst_1 : IsEmpty.{u1} \u03b2], IsEmpty.{u2} \u03b1)\nCase conversion may be inaccurate. Consider using '#align equiv.is_empty Equiv.isEmpty\u2093'. -/\nprotected theorem isEmpty (e : \u03b1 \u2243 \u03b2) [IsEmpty \u03b2] : IsEmpty \u03b1 :=\n  e.isEmpty_congr.mpr \u2039_\u203a\n#align equiv.is_empty Equiv.isEmpty\n\nsection\n\nopen Subtype\n\n#print Equiv.subtypeEquiv /-\n/-- If `\u03b1` is equivalent to `\u03b2` and the predicates `p : \u03b1 \u2192 Prop` and `q : \u03b2 \u2192 Prop` are equivalent\nat corresponding points, then `{a // p a}` is equivalent to `{b // q b}`.\nFor the statement where `\u03b1 = \u03b2`, that is, `e : perm \u03b1`, see `perm.subtype_perm`. -/\ndef subtypeEquiv {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) (h : \u2200 a, p a \u2194 q (e a)) :\n    { a : \u03b1 // p a } \u2243 { b : \u03b2 // q b }\n    where\n  toFun a := \u27e8e a, (h _).mp a.Prop\u27e9\n  invFun b := \u27e8e.symm b, (h _).mpr ((e.apply_symm_apply b).symm \u25b8 b.Prop)\u27e9\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 : \u03b1 \u2192 Prop} (h : \u2200 a, p a \u2194 p (Equiv.refl _ a) := fun a => Iff.rfl) :\n    (Equiv.refl \u03b1).subtypeEquiv h = Equiv.refl { a : \u03b1 // 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : \u03b1 -> Prop} {q : \u03b2 -> Prop} (e : Equiv.{u1, u2} \u03b1 \u03b2) (h : forall (a : \u03b1), Iff (p a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) 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} \u03b2 (fun (b : \u03b2) => q b)) (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a))) (Equiv.symm.{max 1 u1, max 1 u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.{u2} \u03b2 (fun (b : \u03b2) => q b)) (Equiv.subtypeEquiv.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) => p a) q e h)) (Equiv.subtypeEquiv.{u2, u1} \u03b2 \u03b1 (fun (b : \u03b2) => q b) (fun (a : \u03b1) => p a) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) (fun (a : \u03b2) => Eq.mpr.{0} (Iff (q a) (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a))) (Iff (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a))) (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 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} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a))) ((fun (\u1fb0 : \u03b2) (\u1fb0_1 : \u03b2) (e_1 : Eq.{u2} \u03b2 \u1fb0 \u1fb0_1) => congr_arg.{u2, 1} \u03b2 Prop \u1fb0 \u1fb0_1 q e_1) a (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a)) (Eq.symm.{u2} \u03b2 (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a)) a (Equiv.apply_symm_apply.{u1, u2} \u03b1 \u03b2 e a))) (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a)) (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a)) (rfl.{1} Prop (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a)))) (Iff.symm (p (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a)) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a))) (h (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a)))))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {p : \u03b1 -> Prop} {q : \u03b2 -> Prop} (e : Equiv.{u2, u1} \u03b1 \u03b2) (h : forall (a : \u03b1), Iff (p a) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e a))), Eq.{max (max 1 u2) u1} (Equiv.{max 1 u1, max 1 u2} (Subtype.{u1} \u03b2 (fun (b : \u03b2) => q b)) (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a))) (Equiv.symm.{max 1 u2, max 1 u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.{u1} \u03b2 (fun (b : \u03b2) => q b)) (Equiv.subtypeEquiv.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) => p a) q e h)) (Equiv.subtypeEquiv.{u1, u2} \u03b2 \u03b1 (fun (b : \u03b2) => q b) (fun (a : \u03b1) => p a) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) (fun (a : \u03b2) => Eq.mpr.{0} (Iff (q a) (p (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a))) (Iff (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a))) (p (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a))) (eq_of_heq.{1} Prop (Iff (q a) (p (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a))) (Iff (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a))) (p (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 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} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a))) (eq_of_heq.{1} Prop (q a) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a))) ((fun (a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 : \u03b2) (a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 : \u03b2) (e'_1 : Eq.{u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668) => Eq.casesOn.{0, u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 (fun (a._@.Init.Prelude._hyg.170 : \u03b2) (x : Eq.{u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Init.Prelude._hyg.170) => (Eq.{u1} \u03b2 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Init.Prelude._hyg.170) -> (HEq.{0} (Eq.{u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668) e'_1 (Eq.{u1} \u03b2 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} \u03b2 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) => Eq.ndrec.{0, u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 (fun (a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668.9728 : \u03b2) => forall (e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 : Eq.{u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668.9728), (HEq.{0} (Eq.{u1} \u03b2 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} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (Eq.refl.{u1} \u03b2 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} \u03b2 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} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 (Eq.{u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (Eq.refl.{u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668)) => Eq.ndrec.{0, 0} (Eq.{u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (Eq.refl.{u1} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (fun (e_1._@.Mathlib.Logic.Equiv.Basic._hyg.9729 : Eq.{u1} \u03b2 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} \u03b2 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} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (eq_of_heq.{0} (Eq.{u1} \u03b2 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} \u03b2 a._@.Mathlib.Logic.Equiv.Basic._hyg.9668) h._@.Mathlib.Logic.Equiv.Basic._hyg.9731))) a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668 (Eq.symm.{u1} \u03b2 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} \u03b2 a'._@.Mathlib.Logic.Equiv.Basic._hyg.9668) (HEq.refl.{0} (Eq.{u1} \u03b2 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} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a)) (Eq.symm.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a)) (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a)) a (Equiv.apply_symm_apply.{u2, u1} \u03b1 \u03b2 e a)))) (p (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a)))) (Iff.symm (p (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a)) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a))) (h (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 e) a)))))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_symm Equiv.subtypeEquiv_symm\u2093'. -/\n@[simp]\ntheorem subtypeEquiv_symm {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) (h : \u2200 a : \u03b1, p a \u2194 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {p : \u03b1 -> Prop} {q : \u03b2 -> Prop} {r : \u03b3 -> Prop} (e : Equiv.{u1, u2} \u03b1 \u03b2) (f : Equiv.{u2, u3} \u03b2 \u03b3) (h : forall (a : \u03b1), Iff (p a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e a))) (h' : forall (b : \u03b2), Iff (q b) (r (coeFn.{max 1 (imax u2 u3) (imax u3 u2), imax u2 u3} (Equiv.{u2, u3} \u03b2 \u03b3) (fun (_x : Equiv.{u2, u3} \u03b2 \u03b3) => \u03b2 -> \u03b3) (Equiv.hasCoeToFun.{u2, u3} \u03b2 \u03b3) 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} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.{u3} \u03b3 (fun (b : \u03b3) => r b))) (Equiv.trans.{max 1 u1, max 1 u2, max 1 u3} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.{u2} \u03b2 (fun (b : \u03b2) => q b)) (Subtype.{u3} \u03b3 (fun (b : \u03b3) => r b)) (Equiv.subtypeEquiv.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) => p a) q e h) (Equiv.subtypeEquiv.{u2, u3} \u03b2 \u03b3 (fun (b : \u03b2) => q b) r f h')) (Equiv.subtypeEquiv.{u1, u3} \u03b1 \u03b3 (fun (a : \u03b1) => p a) (fun (b : \u03b3) => r b) (Equiv.trans.{u1, u2, u3} \u03b1 \u03b2 \u03b3 e f) (fun (a : \u03b1) => Iff.trans (p a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e a)) (r (coeFn.{max 1 (imax u1 u3) (imax u3 u1), imax u1 u3} (Equiv.{u1, u3} \u03b1 \u03b3) (fun (_x : Equiv.{u1, u3} \u03b1 \u03b3) => \u03b1 -> \u03b3) (Equiv.hasCoeToFun.{u1, u3} \u03b1 \u03b3) (Equiv.trans.{u1, u2, u3} \u03b1 \u03b2 \u03b3 e f) a)) (h a) (h' (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e a))))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u1}} {p : \u03b1 -> Prop} {q : \u03b2 -> Prop} {r : \u03b3 -> Prop} (e : Equiv.{u3, u2} \u03b1 \u03b2) (f : Equiv.{u2, u1} \u03b2 \u03b3) (h : forall (a : \u03b1), Iff (p a) (q (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u3, u2} \u03b1 \u03b2) e a))) (h' : forall (b : \u03b2), Iff (q b) (r (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b2 \u03b3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b3) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b2 \u03b3) f b))), Eq.{max (max 1 u3) u1} (Equiv.{max 1 u3, max 1 u1} (Subtype.{u3} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.{u1} \u03b3 (fun (b : \u03b3) => r b))) (Equiv.trans.{max 1 u3, max 1 u2, max 1 u1} (Subtype.{u3} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.{u2} \u03b2 (fun (b : \u03b2) => q b)) (Subtype.{u1} \u03b3 (fun (b : \u03b3) => r b)) (Equiv.subtypeEquiv.{u3, u2} \u03b1 \u03b2 (fun (a : \u03b1) => p a) q e h) (Equiv.subtypeEquiv.{u2, u1} \u03b2 \u03b3 (fun (b : \u03b2) => q b) r f h')) (Equiv.subtypeEquiv.{u3, u1} \u03b1 \u03b3 (fun (a : \u03b1) => p a) r (Equiv.trans.{u3, u2, u1} \u03b1 \u03b2 \u03b3 e f) (fun (a : \u03b1) => Iff.trans (p a) (q (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u3, u2} \u03b1 \u03b2) e a)) (r (FunLike.coe.{max (max 1 u3) u1, u3, u1} (Equiv.{u3, u1} \u03b1 \u03b3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b3) _x) (Equiv.instFunLikeEquiv.{u3, u1} \u03b1 \u03b3) (Equiv.trans.{u3, u2, u1} \u03b1 \u03b2 \u03b3 e f) a)) (h a) (h' (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u3, u2} \u03b1 \u03b2) e a))))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_trans Equiv.subtypeEquiv_trans\u2093'. -/\n@[simp]\ntheorem subtypeEquiv_trans {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) (f : \u03b2 \u2243 \u03b3)\n    (h : \u2200 a : \u03b1, p a \u2194 q (e a)) (h' : \u2200 b : \u03b2, q b \u2194 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : \u03b1 -> Prop} {q : \u03b2 -> Prop} (e : Equiv.{u1, u2} \u03b1 \u03b2) (h : forall (a : \u03b1), Iff (p a) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e a))) (x : Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)), Eq.{max 1 u2} (Subtype.{u2} \u03b2 (fun (b : \u03b2) => 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} \u03b1 (fun (a : \u03b1) => (fun (a : \u03b1) => p a) a)) (Subtype.{u2} \u03b2 (fun (b : \u03b2) => q b))) (fun (_x : Equiv.{max 1 u1, max 1 u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => (fun (a : \u03b1) => p a) a)) (Subtype.{u2} \u03b2 (fun (b : \u03b2) => q b))) => (Subtype.{u1} \u03b1 (fun (a : \u03b1) => (fun (a : \u03b1) => p a) a)) -> (Subtype.{u2} \u03b2 (fun (b : \u03b2) => q b))) (Equiv.hasCoeToFun.{max 1 u1, max 1 u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => (fun (a : \u03b1) => p a) a)) (Subtype.{u2} \u03b2 (fun (b : \u03b2) => q b))) (Equiv.subtypeEquiv.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) => p a) q e h) x) (Subtype.mk.{u2} \u03b2 (fun (b : \u03b2) => q b) (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (x : \u03b1) => 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} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (x : \u03b1) => p x))))) x)) (q (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (x : \u03b1) => 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} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b1 (fun (x : \u03b1) => p x)) \u03b1 (coeSubtype.{u1} \u03b1 (fun (x : \u03b1) => p x))))) x)) (Subtype.property.{u1} \u03b1 (fun (x : \u03b1) => p x) x)))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {p : \u03b1 -> Prop} {q : \u03b2 -> Prop} (e : Equiv.{u2, u1} \u03b1 \u03b2) (h : forall (a : \u03b1), Iff (p a) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e a))) (x : Subtype.{u2} \u03b1 (fun (x : \u03b1) => p x)), Eq.{max 1 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) => Subtype.{u1} \u03b2 (fun (b : \u03b2) => 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} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.{u1} \u03b2 (fun (b : \u03b2) => q b))) (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) (fun (_x : Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) => Subtype.{u1} \u03b2 (fun (b : \u03b2) => q b)) _x) (Equiv.instFunLikeEquiv.{max 1 u2, max 1 u1} (Subtype.{u2} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.{u1} \u03b2 (fun (b : \u03b2) => q b))) (Equiv.subtypeEquiv.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) => p a) q e h) x) (Subtype.mk.{u1} \u03b2 (fun (b : \u03b2) => q b) (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (Subtype.val.{u2} \u03b1 (fun (x : \u03b1) => p x) x)) (Iff.mp (p (Subtype.val.{u2} \u03b1 (fun (x : \u03b1) => p x) x)) (q (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) e (Subtype.val.{u2} \u03b1 (fun (x : \u03b1) => p x) x))) (h (Subtype.val.{u2} \u03b1 (fun (x : \u03b1) => p x) x)) (Subtype.property.{u2} \u03b1 (fun (x : \u03b1) => p x) x)))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_apply Equiv.subtypeEquiv_apply\u2093'. -/\n@[simp]\ntheorem subtypeEquiv_apply {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) (h : \u2200 a : \u03b1, p a \u2194 q (e a))\n    (x : { x // p x }) : e.subtypeEquiv h x = \u27e8e x, (h _).1 x.2\u27e9 :=\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 : \u03b1 \u2192 Prop} (e : \u2200 x, p x \u2194 q x) : { x // p x } \u2243 { 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : \u03b2 -> Prop} (e : Equiv.{u1, u2} \u03b1 \u03b2), Equiv.{max 1 u1, max 1 u2} (Subtype.{u1} \u03b1 (fun (a : \u03b1) => p (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e a))) (Subtype.{u2} \u03b2 (fun (b : \u03b2) => p b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : \u03b1 -> Prop} (e : Equiv.{u2, u1} \u03b2 \u03b1), Equiv.{max 1 u2, max 1 u1} (Subtype.{u2} \u03b2 (fun (a : \u03b2) => p (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Equiv.{u2, u1} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b2 \u03b1) e a))) (Subtype.{u1} \u03b1 (fun (b : \u03b1) => p b))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_equiv_of_subtype Equiv.subtypeEquivOfSubtype\u2093'. -/\n/-- If `\u03b1 \u2243 \u03b2`, then for any predicate `p : \u03b2 \u2192 Prop` the subtype `{a // p (e a)}` is equivalent\nto the subtype `{b // p b}`. -/\ndef subtypeEquivOfSubtype {p : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) : { a : \u03b1 // p (e a) } \u2243 { b : \u03b2 // p b } :=\n  subtypeEquiv e <| by simp\n#align equiv.subtype_equiv_of_subtype Equiv.subtypeEquivOfSubtype\n\n#print Equiv.subtypeEquivOfSubtype' /-\n/-- If `\u03b1 \u2243 \u03b2`, then for any predicate `p : \u03b1 \u2192 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 : \u03b1 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) :\n    { a : \u03b1 // p a } \u2243 { b : \u03b2 // 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 {\u03b1 : Sort _} {p q : \u03b1 \u2192 Prop} (h : p = q) : Subtype p \u2243 Subtype q :=\n  subtypeEquiv (Equiv.refl \u03b1) fun a => h \u25b8 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 \u201cinner\u201d predicate to depend on `h : p a`. -/\n@[simps]\ndef subtypeSubtypeEquivSubtypeExists {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) (q : Subtype p \u2192 Prop) :\n    Subtype q \u2243 { a : \u03b1 // \u2203 h : p a, q \u27e8a, h\u27e9 } :=\n  \u27e8fun a =>\n    \u27e8a, a.1.2, by\n      rcases a with \u27e8\u27e8a, hap\u27e9, haq\u27e9\n      exact haq\u27e9,\n    fun a => \u27e8\u27e8a, a.2.fst\u27e9, a.2.snd\u27e9, fun \u27e8\u27e8a, ha\u27e9, h\u27e9 => rfl, fun \u27e8a, h\u2081, h\u2082\u27e9 => rfl\u27e9\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 {\u03b1 : Sort.{u1}} (p : \u03b1 -> Prop) (q : \u03b1 -> Prop), Equiv.{max 1 u1, max 1 u1} (Subtype.{max 1 u1} (Subtype.{u1} \u03b1 p) (fun (x : Subtype.{u1} \u03b1 p) => q (Subtype.val.{u1} \u03b1 p x))) (Subtype.{u1} \u03b1 (fun (x : \u03b1) => And (p x) (q x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (p : \u03b1 -> Prop) (q : \u03b1 -> Prop), Equiv.{succ u1, succ u1} (Subtype.{succ u1} (Subtype.{succ u1} \u03b1 p) (fun (x : Subtype.{succ u1} \u03b1 p) => q (Subtype.val.{succ u1} \u03b1 p x))) (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => And (p x) (q x)))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_subtype_equiv_subtype_inter Equiv.subtypeSubtypeEquivSubtypeInter\u2093'. -/\n/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. -/\n@[simps]\ndef subtypeSubtypeEquivSubtypeInter {\u03b1 : Sort u} (p q : \u03b1 \u2192 Prop) :\n    { x : Subtype p // q x.1 } \u2243 Subtype fun x => p x \u2227 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 {\u03b1 : Type u} {p q : \u03b1 \u2192 Prop} (h : \u2200 {x}, q x \u2192 p x) :\n    { x : Subtype p // q x.1 } \u2243 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 {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} (h : \u2200 x, p x) : Subtype p \u2243 \u03b1 :=\n  \u27e8fun x => x, fun x => \u27e8x, h x\u27e9, fun x => Subtype.eq rfl, fun x => rfl\u27e9\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 {\u03b1 : Type.{u1}} (p : \u03b1 -> Type.{u2}) (q : \u03b1 -> Prop), Equiv.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (Sigma.{u1, u2} \u03b1 p) (fun (y : Sigma.{u1, u2} \u03b1 p) => q (Sigma.fst.{u1, u2} \u03b1 p y))) (Sigma.{u1, u2} (Subtype.{succ u1} \u03b1 q) (fun (x : Subtype.{succ u1} \u03b1 q) => p (Subtype.val.{succ u1} \u03b1 q x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (p : \u03b1 -> Type.{u1}) (q : \u03b1 -> Prop), Equiv.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Subtype.{max (succ u1) (succ u2)} (Sigma.{u2, u1} \u03b1 p) (fun (y : Sigma.{u2, u1} \u03b1 p) => q (Sigma.fst.{u2, u1} \u03b1 p y))) (Sigma.{u2, u1} (Subtype.{succ u2} \u03b1 q) (fun (x : Subtype.{succ u2} \u03b1 q) => p (Subtype.val.{succ u2} \u03b1 q x)))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_sigma_equiv Equiv.subtypeSigmaEquiv\u2093'. -/\n/-- A subtype of a sigma-type is a sigma-type over a subtype. -/\ndef subtypeSigmaEquiv {\u03b1 : Type u} (p : \u03b1 \u2192 Type v) (q : \u03b1 \u2192 Prop) :\n    { y : Sigma p // q y.1 } \u2243 \u03a3x : Subtype q, p x.1 :=\n  \u27e8fun x => \u27e8\u27e8x.1.1, x.2\u27e9, x.1.2\u27e9, fun x => \u27e8\u27e8x.1.1, x.2\u27e9, x.1.2\u27e9, fun \u27e8\u27e8x, h\u27e9, y\u27e9 => rfl,\n    fun \u27e8\u27e8x, y\u27e9, h\u27e9 => rfl\u27e9\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 {\u03b1 : Type.{u1}} (p : \u03b1 -> Type.{u2}) (q : \u03b1 -> Prop), (forall (x : \u03b1), (p x) -> (q x)) -> (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u1, u2} (Subtype.{succ u1} \u03b1 q) (fun (x : Subtype.{succ u1} \u03b1 q) => p ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} \u03b1 q) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 q) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 q) \u03b1 (coeBase.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 q) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => q x))))) x))) (Sigma.{u1, u2} \u03b1 (fun (x : \u03b1) => p x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (p : \u03b1 -> Type.{u1}) (q : \u03b1 -> Prop), (forall (x : \u03b1), (p x) -> (q x)) -> (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u2, u1} (Subtype.{succ u2} \u03b1 q) (fun (x : Subtype.{succ u2} \u03b1 q) => p (Subtype.val.{succ u2} \u03b1 q x))) (Sigma.{u2, u1} \u03b1 (fun (x : \u03b1) => p x)))\nCase conversion may be inaccurate. Consider using '#align equiv.sigma_subtype_equiv_of_subset Equiv.sigmaSubtypeEquivOfSubset\u2093'. -/\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 {\u03b1 : Type u} (p : \u03b1 \u2192 Type v) (q : \u03b1 \u2192 Prop) (h : \u2200 x, p x \u2192 q x) :\n    (\u03a3x : Subtype q, p x) \u2243 \u03a3x : \u03b1, 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 : \u03b2 \u2192 Prop` is true on the range of a map `f : \u03b1 \u2192 \u03b2`, then\n`\u03a3 y : {y // p y}, {x // f x = y}` is equivalent to `\u03b1`. -/\ndef sigmaSubtypeFiberEquiv {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (p : \u03b2 \u2192 Prop) (h : \u2200 x, p (f x)) :\n    (\u03a3y : Subtype p, { x : \u03b1 // f x = y }) \u2243 \u03b1 :=\n  calc\n    _ \u2243 \u03a3y : \u03b2, { x : \u03b1 // f x = y } := sigmaSubtypeEquivOfSubset _ p fun y \u27e8x, h'\u27e9 => h' \u25b8 h x\n    _ \u2243 \u03b1 := 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 \u2194 q (f x)`, then `\u03a3 y : {y // q y}, f \u207b\u00b9' {y}` is equivalent\nto `{x // p x}`. -/\ndef sigmaSubtypeFiberEquivSubtype {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} (h : \u2200 x, p x \u2194 q (f x)) : (\u03a3y : Subtype q, { x : \u03b1 // f x = y }) \u2243 Subtype p :=\n  calc\n    (\u03a3y : Subtype q, { x : \u03b1 // f x = y }) \u2243\n        \u03a3y : 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        \u27e8fun \u27e8hp, h'\u27e9 => congr_arg Subtype.val h', fun h' =>\n          \u27e8(h x).2 (h'.symm \u25b8 y.2), Subtype.eq h'\u27e9\u27e9\n    _ \u2243 Subtype p := sigmaFiberEquiv fun x : Subtype p => (\u27e8f x, (h x).1 x.property\u27e9 : 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 {\u03b1 : Type.{u1}} (p : (Option.{u1} \u03b1) -> Type.{u2}), ((p (Option.none.{u1} \u03b1)) -> False) -> (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u1, u2} (Option.{u1} \u03b1) (fun (x : Option.{u1} \u03b1) => p x)) (Sigma.{u1, u2} \u03b1 (fun (x : \u03b1) => p (Option.some.{u1} \u03b1 x))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (p : (Option.{u2} \u03b1) -> Type.{u1}), ((p (Option.none.{u2} \u03b1)) -> False) -> (Equiv.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Sigma.{u2, u1} (Option.{u2} \u03b1) (fun (x : Option.{u2} \u03b1) => p x)) (Sigma.{u2, u1} \u03b1 (fun (x : \u03b1) => p (Option.some.{u2} \u03b1 x))))\nCase conversion may be inaccurate. Consider using '#align equiv.sigma_option_equiv_of_some Equiv.sigmaOptionEquivOfSome\u2093'. -/\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 {\u03b1 : Type u} (p : Option \u03b1 \u2192 Type v) (h : p none \u2192 False) :\n    (\u03a3x : Option \u03b1, p x) \u2243 \u03a3x : \u03b1, p (some x) :=\n  haveI h' : \u2200 x, p x \u2192 x.isSome := by\n    intro x\n    cases x\n    \u00b7 intro n\n      exfalso\n      exact h n\n    \u00b7 intro s\n      exact rfl\n  (sigma_subtype_equiv_of_subset _ _ h').symm.trans (sigma_congr_left' (option_is_some_equiv \u03b1))\n#align equiv.sigma_option_equiv_of_some Equiv.sigmaOptionEquivOfSome\n\n#print Equiv.piEquivSubtypeSigma /-\n/-- The `pi`-type `\u03a0 i, \u03c0 i` is equivalent to the type of sections `f : \u03b9 \u2192 \u03a3 i, \u03c0 i` of the\n`sigma` type such that for all `i` we have `(f i).fst = i`. -/\ndef piEquivSubtypeSigma (\u03b9 : Type _) (\u03c0 : \u03b9 \u2192 Type _) :\n    (\u2200 i, \u03c0 i) \u2243 { f : \u03b9 \u2192 \u03a3i, \u03c0 i // \u2200 i, (f i).1 = i } :=\n  \u27e8fun f => \u27e8fun i => \u27e8i, f i\u27e9, fun i => rfl\u27e9, fun f i => by rw [\u2190 f.2 i]; exact (f.1 i).2, fun f =>\n    funext fun i => rfl, fun \u27e8f, hf\u27e9 =>\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 _\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : \u03b1 -> Sort.{u2}} {p : forall (a : \u03b1), (\u03b2 a) -> Prop}, Equiv.{max 1 (imax u1 u2), max u1 1 u2} (Subtype.{imax u1 u2} (forall (a : \u03b1), \u03b2 a) (fun (f : forall (a : \u03b1), \u03b2 a) => forall (a : \u03b1), p a (f a))) (forall (a : \u03b1), Subtype.{u2} (\u03b2 a) (fun (b : \u03b2 a) => p a b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : \u03b1 -> Sort.{u1}} {p : forall (a : \u03b1), (\u03b2 a) -> Prop}, Equiv.{max 1 (imax u2 u1), max (max 1 u1) u2} (Subtype.{imax u2 u1} (forall (a : \u03b1), \u03b2 a) (fun (f : forall (a : \u03b1), \u03b2 a) => forall (a : \u03b1), p a (f a))) (forall (a : \u03b1), Subtype.{u1} (\u03b2 a) (fun (b : \u03b2 a) => p a b))\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_pi_equiv_pi Equiv.subtypePiEquivPi\u2093'. -/\n/-- The set of functions `f : \u03a0 a, \u03b2 a` such that for all `a` we have `p a (f a)` is equivalent\nto the set of functions `\u03a0 a, {b : \u03b2 a // p a b}`. -/\ndef subtypePiEquivPi {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {p : \u2200 a, \u03b2 a \u2192 Prop} :\n    { f : \u2200 a, \u03b2 a // \u2200 a, p a (f a) } \u2243 \u2200 a, { b : \u03b2 a // p a b } :=\n  \u27e8fun f a => \u27e8f.1 a, f.2 a\u27e9, fun f => \u27e8fun a => (f a).1, fun a => (f a).2\u27e9,\n    by\n    rintro \u27e8f, h\u27e9\n    rfl, by\n    rintro f\n    funext a\n    exact Subtype.ext_val rfl\u27e9\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 {\u03b1 : Type u} {\u03b2 : Type v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} :\n    { c : \u03b1 \u00d7 \u03b2 // p c.1 \u2227 q c.2 } \u2243 { a // p a } \u00d7 { b // q b } :=\n  \u27e8fun x => \u27e8\u27e8x.1.1, x.2.1\u27e9, \u27e8x.1.2, x.2.2\u27e9\u27e9, fun x => \u27e8\u27e8x.1.1, x.2.1\u27e9, \u27e8x.1.2, x.2.2\u27e9\u27e9,\n    fun \u27e8\u27e8_, _\u27e9, \u27e8_, _\u27e9\u27e9 => rfl, fun \u27e8\u27e8_, _\u27e9, \u27e8_, _\u27e9\u27e9 => rfl\u27e9\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 {\u03b1 \u03b2 : Type _} (p : \u03b1 \u2192 \u03b2 \u2192 Prop) :\n    { x : \u03b1 \u00d7 \u03b2 // p x.1 x.2 } \u2243 \u03a3a, { b : \u03b2 // p a b }\n    where\n  toFun x := \u27e8x.1.1, x.1.2, x.Prop\u27e9\n  invFun x := \u27e8\u27e8x.1, x.2\u27e9, x.2.Prop\u27e9\n  left_inv x := by ext <;> rfl\n  right_inv := fun \u27e8a, b, pab\u27e9 => rfl\n#align equiv.subtype_prod_equiv_sigma_subtype Equiv.subtypeProdEquivSigmaSubtype\n-/\n\n#print Equiv.piEquivPiSubtypeProd /-\n/-- The type `\u03a0 (i : \u03b1), \u03b2 i` can be split as a product by separating the indices in `\u03b1`\ndepending on whether they satisfy a predicate `p` or not. -/\n@[simps]\ndef piEquivPiSubtypeProd {\u03b1 : Type _} (p : \u03b1 \u2192 Prop) (\u03b2 : \u03b1 \u2192 Type _) [DecidablePred p] :\n    (\u2200 i : \u03b1, \u03b2 i) \u2243 (\u2200 i : { x // p x }, \u03b2 i) \u00d7 \u2200 i : { x // \u00acp x }, \u03b2 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 \u27e8x, h\u27e9 else f.2 \u27e8x, h\u27e9\n  right_inv := by\n    rintro \u27e8f, g\u27e9\n    ext1 <;>\n      \u00b7 ext y\n        rcases y with \u27e8\u27e9\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      \u00b7 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 {\u03b1 : Type _} [DecidableEq \u03b1] (i : \u03b1) (\u03b2 : \u03b1 \u2192 Type _) :\n    (\u2200 j, \u03b2 j) \u2243 \u03b2 i \u00d7 \u2200 j : { j // j \u2260 i }, \u03b2 j\n    where\n  toFun f := \u27e8f i, fun j => f j\u27e9\n  invFun f j := if h : j = i then h.symm.rec f.1 else f.2 \u27e8j, h\u27e9\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    \u00b7 subst h\n    \u00b7 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 {\u03b1 : Type _} [DecidableEq \u03b1] (i : \u03b1) (\u03b2 : Type _) :\n    (\u03b1 \u2192 \u03b2) \u2243 \u03b2 \u00d7 ({ j // j \u2260 i } \u2192 \u03b2) :=\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\u2093.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\u2093'. -/\n/-- The type of all functions `X \u2192 Y` with prescribed values for all `x' \u2260 x`\nis equivalent to the codomain `Y`. -/\ndef subtypeEquivCodomain (f : { x' // x' \u2260 x } \u2192 Y) : { g : X \u2192 Y // g \u2218 coe = f } \u2243 Y :=\n  (subtypePreimage _ f).trans <|\n    @funUnique { x' // \u00acx' \u2260 x } _ <|\n      show Unique { x' // \u00acx' \u2260 x } from\n        @Equiv.unique _ _\n          (show Unique { x' // x' = x } from\n            { default := \u27e8x, rfl\u27e9\n              uniq := fun \u27e8x', h\u27e9 => 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_subtypeEquivCodomain (f : { x' // x' \u2260 x } \u2192 Y) :\n    (subtypeEquivCodomain f : { g : X \u2192 Y // g \u2218 coe = f } \u2192 Y) = fun g => (g : X \u2192 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem subtypeEquivCodomain_apply (f : { x' // x' \u2260 x } \u2192 Y) (g : { g : X \u2192 Y // g \u2218 coe = f }) :\n    subtypeEquivCodomain f g = (g : X \u2192 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem coe_subtypeEquivCodomain_symm (f : { x' // x' \u2260 x } \u2192 Y) :\n    ((subtypeEquivCodomain f).symm : Y \u2192 { g : X \u2192 Y // g \u2218 coe = f }) = fun y =>\n      \u27e8fun x' => if h : x' \u2260 x then f \u27e8x', h\u27e9 else y,\n        by\n        funext x'\n        dsimp\n        erw [dif_pos x'.2, Subtype.coe_eta]\u27e9 :=\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem subtypeEquivCodomain_symm_apply (f : { x' // x' \u2260 x } \u2192 Y) (y : Y) (x' : X) :\n    ((subtypeEquivCodomain f).symm y : X \u2192 Y) x' = if h : x' \u2260 x then f \u27e8x', h\u27e9 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem subtypeEquivCodomain_symm_apply_eq (f : { x' // x' \u2260 x } \u2192 Y) (y : Y) :\n    ((subtypeEquivCodomain f).symm y : X \u2192 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem subtypeEquivCodomain_symm_apply_ne (f : { x' // x' \u2260 x } \u2192 Y) (y : Y) (x' : X)\n    (h : x' \u2260 x) : ((subtypeEquivCodomain f).symm y : X \u2192 Y) x' = f \u27e8x', h\u27e9 :=\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 : \u03b1 \u2192 \u03b2) (hf : Bijective f) : \u03b1 \u2243 \u03b2\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (f : \u03b1 -> \u03b2) (hf : Function.Bijective.{u1, u2} \u03b1 \u03b2 f) (x : \u03b2), Eq.{u2} \u03b2 (f (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 (Equiv.ofBijective.{u1, u2} \u03b1 \u03b2 f hf)) x)) x\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (f : \u03b1 -> \u03b2) (hf : Function.Bijective.{u2, u1} \u03b1 \u03b2 f) (x : \u03b2), Eq.{u1} \u03b2 (f (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 (Equiv.ofBijective.{u2, u1} \u03b1 \u03b2 f hf)) x)) x\nCase conversion may be inaccurate. Consider using '#align equiv.of_bijective_apply_symm_apply Equiv.ofBijective_apply_symm_apply\u2093'. -/\ntheorem ofBijective_apply_symm_apply (f : \u03b1 \u2192 \u03b2) (hf : Bijective f) (x : \u03b2) :\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (f : \u03b1 -> \u03b2) (hf : Function.Bijective.{u1, u2} \u03b1 \u03b2 f) (x : \u03b1), Eq.{u1} \u03b1 (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 (Equiv.ofBijective.{u1, u2} \u03b1 \u03b2 f hf)) (f x)) x\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (f : \u03b1 -> \u03b2) (hf : Function.Bijective.{u2, u1} \u03b1 \u03b2 f) (x : \u03b1), Eq.{u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) (f x)) (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 (Equiv.ofBijective.{u2, u1} \u03b1 \u03b2 f hf)) (f x)) x\nCase conversion may be inaccurate. Consider using '#align equiv.of_bijective_symm_apply_apply Equiv.ofBijective_symm_apply_apply\u2093'. -/\n@[simp]\ntheorem ofBijective_symm_apply_apply (f : \u03b1 \u2192 \u03b2) (hf : Bijective f) (x : \u03b1) :\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 (\u03b1 \u2192 \u03b2) (\u03b1 \u2243 \u03b2) coeFn Bijective where prf f hf := \u27e8ofBijective f hf, rfl\u27e9\n\nsection\n\nvariable {\u03b1' \u03b2' : Type _} (e : Perm \u03b1') {p : \u03b2' \u2192 Prop} [DecidablePred p] (f : \u03b1' \u2243 Subtype p)\n\n#print Equiv.Perm.extendDomain /-\n/-- Extend the domain of `e : equiv.perm \u03b1` to one that is over `\u03b2` via `f : \u03b1 \u2192 subtype p`,\nwhere `p : \u03b2 \u2192 Prop`, permuting only the `b : \u03b2` that satisfy `p b`.\nThis can be used to extend the domain across a function `f : \u03b1 \u2192 \u03b2`,\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 \u03b2' :=\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 : \u03b1') : 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 : \u03b2'} (h : p b) :\n    e.extendDomain f b = f (e (f.symm \u27e8b, h\u27e9)) := 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 : \u03b2'} (h : \u00acp 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 {\u03b1' : Type.{u1}} {\u03b2' : Type.{u2}} {p : \u03b2' -> Prop} [_inst_1 : DecidablePred.{succ u2} \u03b2' p] (f : Equiv.{succ u1, succ u2} \u03b1' (Subtype.{succ u2} \u03b2' p)) (e : Equiv.Perm.{succ u1} \u03b1') (e' : Equiv.Perm.{succ u1} \u03b1'), Eq.{succ u2} (Equiv.{succ u2, succ u2} \u03b2' \u03b2') (Equiv.trans.{succ u2, succ u2, succ u2} \u03b2' \u03b2' \u03b2' (Equiv.Perm.extendDomain.{u1, u2} \u03b1' \u03b2' e p (fun (a : \u03b2') => _inst_1 a) f) (Equiv.Perm.extendDomain.{u1, u2} \u03b1' \u03b2' e' p (fun (a : \u03b2') => _inst_1 a) f)) (Equiv.Perm.extendDomain.{u1, u2} \u03b1' \u03b2' (Equiv.trans.{succ u1, succ u1, succ u1} \u03b1' \u03b1' \u03b1' e e') p (fun (a : \u03b2') => _inst_1 a) f)\nbut is expected to have type\n  forall {\u03b1' : Type.{u2}} {\u03b2' : Type.{u1}} {p : \u03b2' -> Prop} [_inst_1 : DecidablePred.{succ u1} \u03b2' p] (f : Equiv.{succ u2, succ u1} \u03b1' (Subtype.{succ u1} \u03b2' p)) (e : Equiv.Perm.{succ u2} \u03b1') (e' : Equiv.Perm.{succ u2} \u03b1'), Eq.{succ u1} (Equiv.{succ u1, succ u1} \u03b2' \u03b2') (Equiv.trans.{succ u1, succ u1, succ u1} \u03b2' \u03b2' \u03b2' (Equiv.Perm.extendDomain.{u2, u1} \u03b1' \u03b2' e p (fun (a : \u03b2') => _inst_1 a) f) (Equiv.Perm.extendDomain.{u2, u1} \u03b1' \u03b2' e' p (fun (a : \u03b2') => _inst_1 a) f)) (Equiv.Perm.extendDomain.{u2, u1} \u03b1' \u03b2' (Equiv.trans.{succ u2, succ u2, succ u2} \u03b1' \u03b1' \u03b1' e e') p (fun (a : \u03b2') => _inst_1 a) f)\nCase conversion may be inaccurate. Consider using '#align equiv.perm.extend_domain_trans Equiv.Perm.extendDomain_trans\u2093'. -/\ntheorem Perm.extendDomain_trans (e e' : Perm \u03b1') :\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 `\u03b1` be a setoid with\nequivalence relation `~`. Let `p\u2082` be a predicate on the quotient type `\u03b1/~`, and `p\u2081` be the lift\nof this predicate to `\u03b1`: `p\u2081 a \u2194 p\u2082 \u27e6a\u27e7`. Let `~\u2082` be the restriction of `~` to `{x // p\u2081 x}`.\nThen `{x // p\u2082 x}` is equivalent to the quotient of `{x // p\u2081 x}` by `~\u2082`. -/\ndef subtypeQuotientEquivQuotientSubtype (p\u2081 : \u03b1 \u2192 Prop) [s\u2081 : Setoid \u03b1] [s\u2082 : Setoid (Subtype p\u2081)]\n    (p\u2082 : Quotient s\u2081 \u2192 Prop) (hp\u2082 : \u2200 a, p\u2081 a \u2194 p\u2082 \u27e6a\u27e7)\n    (h : \u2200 x y : Subtype p\u2081, @Setoid.r _ s\u2082 x y \u2194 (x : \u03b1) \u2248 y) : { x // p\u2082 x } \u2243 Quotient s\u2082\n    where\n  toFun a :=\n    Quotient.hrecOn a.1 (fun a h => \u27e6\u27e8a, (hp\u2082 _).2 h\u27e9\u27e7)\n      (fun a b hab =>\n        hfunext (by rw [Quotient.sound hab]) fun h\u2081 h\u2082 _ =>\n          hEq_of_eq (Quotient.sound ((h _ _).2 hab)))\n      a.2\n  invFun a :=\n    Quotient.liftOn a (fun a => (\u27e8\u27e6a.1\u27e7, (hp\u2082 _).1 a.2\u27e9 : { x // p\u2082 x })) fun a b hab =>\n      Subtype.ext_val (Quotient.sound ((h _ _).1 hab))\n  left_inv := fun \u27e8a, ha\u27e9 => Quotient.inductionOn a (fun a ha => rfl) ha\n  right_inv a := Quotient.inductionOn a fun \u27e8a, ha\u27e9 => rfl\n#align equiv.subtype_quotient_equiv_quotient_subtype Equiv.subtypeQuotientEquivQuotientSubtype\n-/\n\n#print Equiv.subtypeQuotientEquivQuotientSubtype_mk /-\n@[simp]\ntheorem subtypeQuotientEquivQuotientSubtype_mk (p\u2081 : \u03b1 \u2192 Prop) [s\u2081 : Setoid \u03b1]\n    [s\u2082 : Setoid (Subtype p\u2081)] (p\u2082 : Quotient s\u2081 \u2192 Prop) (hp\u2082 : \u2200 a, p\u2081 a \u2194 p\u2082 \u27e6a\u27e7)\n    (h : \u2200 x y : Subtype p\u2081, @Setoid.r _ s\u2082 x y \u2194 (x : \u03b1) \u2248 y) (x hx) :\n    subtypeQuotientEquivQuotientSubtype p\u2081 p\u2082 hp\u2082 h \u27e8\u27e6x\u27e7, hx\u27e9 = \u27e6\u27e8x, (hp\u2082 _).2 hx\u27e9\u27e7 :=\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\u2081 : \u03b1 \u2192 Prop) [s\u2081 : Setoid \u03b1]\n    [s\u2082 : Setoid (Subtype p\u2081)] (p\u2082 : Quotient s\u2081 \u2192 Prop) (hp\u2082 : \u2200 a, p\u2081 a \u2194 p\u2082 \u27e6a\u27e7)\n    (h : \u2200 x y : Subtype p\u2081, @Setoid.r _ s\u2082 x y \u2194 (x : \u03b1) \u2248 y) (x) :\n    (subtypeQuotientEquivQuotientSubtype p\u2081 p\u2082 hp\u2082 h).symm \u27e6x\u27e7 = \u27e8\u27e6x\u27e7, (hp\u2082 _).1 x.Prop\u27e9 :=\n  rfl\n#align equiv.subtype_quotient_equiv_quotient_subtype_symm_mk Equiv.subtypeQuotientEquivQuotientSubtype_symm_mk\n-/\n\nsection Swap\n\nvariable [DecidableEq \u03b1]\n\n#print Equiv.swapCore /-\n/-- A helper function for `equiv.swap`. -/\ndef swapCore (a b r : \u03b1) : \u03b1 :=\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 : \u03b1) : 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 : \u03b1) : 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 : \u03b1) : 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 : \u03b1) : Perm \u03b1 :=\n  \u27e8swapCore a b, swapCore a b, fun r => swapCore_swapCore r a b, fun r => swapCore_swapCore r a b\u27e9\n#align equiv.swap Equiv.swap\n-/\n\n#print Equiv.swap_self /-\n@[simp]\ntheorem swap_self (a : \u03b1) : 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 : \u03b1) : 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 : \u03b1) : 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 : \u03b1) : 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 : \u03b1) : 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 : \u03b1} : x \u2260 a \u2192 x \u2260 b \u2192 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 : \u03b1) : (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 : \u03b1) : (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 : \u03b1} : swap x y = Equiv.refl _ \u2194 x = y :=\n  by\n  refine' \u27e8fun h => (Equiv.refl _).Injective _, fun h => h \u25b8 swap_self _\u27e9\n  rw [\u2190 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 : \u03b1} (\u03c0 : Perm \u03b1) :\n    \u03c0.trans (swap a b) x = if \u03c0 x = a then b else if \u03c0 x = b then a else \u03c0 x :=\n  by\n  cases \u03c0\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 : \u03b1) : (Equiv.swap i j : \u03b1 \u2192 \u03b1) = 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] (i : \u03b1) (j : \u03b1) (f : \u03b1 -> \u03b2), Eq.{imax u1 u2} (\u03b1 -> \u03b2) (Function.comp.{u1, u1, u2} \u03b1 \u03b1 \u03b2 f (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} \u03b1) (fun (_x : Equiv.{u1, u1} \u03b1 \u03b1) => \u03b1 -> \u03b1) (Equiv.hasCoeToFun.{u1, u1} \u03b1 \u03b1) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) i j))) (Function.update.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Function.update.{u1, u2} \u03b1 (fun (a : \u03b1) => \u03b2) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f j (f i)) i (f j))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} [\u03b2 : DecidableEq.{u1} \u03b1] {_inst_1 : Sort.{u2}} (i : \u03b1) (j : \u03b1) (f : \u03b1 -> _inst_1), Eq.{imax u1 u2} (\u03b1 -> _inst_1) (Function.comp.{u1, u1, u2} \u03b1 \u03b1 _inst_1 f (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} \u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u1} \u03b1 \u03b1) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => \u03b2 a b) i j))) (Function.update.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => _inst_1) (fun (a : \u03b1) (b : \u03b1) => \u03b2 a b) (Function.update.{u1, u2} \u03b1 (fun (a : \u03b1) => _inst_1) (fun (a : \u03b1) (b : \u03b1) => \u03b2 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\u2093'. -/\ntheorem comp_swap_eq_update (i j : \u03b1) (f : \u03b1 \u2192 \u03b2) :\n    f \u2218 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] (a : \u03b1) (b : \u03b1) (e : Equiv.{u1, u2} \u03b1 \u03b2), Eq.{max 1 u2} (Equiv.{u2, u2} \u03b2 \u03b2) (Equiv.trans.{u2, u1, u2} \u03b2 \u03b1 \u03b2 (Equiv.trans.{u2, u1, u1} \u03b2 \u03b1 \u03b1 (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b)) e) (Equiv.swap.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e a) (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} [\u03b2 : DecidableEq.{u1} \u03b1] {_inst_1 : Sort.{u2}} [_inst_2 : DecidableEq.{u2} _inst_1] (a : \u03b1) (b : \u03b1) (e : Equiv.{u1, u2} \u03b1 _inst_1), Eq.{max 1 u2} (Equiv.{u2, u2} _inst_1 _inst_1) (Equiv.trans.{u2, u1, u2} _inst_1 \u03b1 _inst_1 (Equiv.trans.{u2, u1, u1} _inst_1 \u03b1 \u03b1 (Equiv.symm.{u1, u2} \u03b1 _inst_1 e) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => \u03b2 a b) a b)) e) (Equiv.swap.{u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => _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} \u03b1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => _inst_1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b1 _inst_1) e a) (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} \u03b1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => _inst_1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b1 _inst_1) e b))\nCase conversion may be inaccurate. Consider using '#align equiv.symm_trans_swap_trans Equiv.symm_trans_swap_trans\u2093'. -/\n@[simp]\ntheorem symm_trans_swap_trans [DecidableEq \u03b2] (a b : \u03b1) (e : \u03b1 \u2243 \u03b2) :\n    (e.symm.trans (swap a b)).trans e = swap (e a) (e b) :=\n  Equiv.ext fun x =>\n    by\n    have : \u2200 a, e.symm x = a \u2194 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] (a : \u03b2) (b : \u03b2) (e : Equiv.{u1, u2} \u03b1 \u03b2), Eq.{max 1 u1} (Equiv.{u1, u1} \u03b1 \u03b1) (Equiv.trans.{u1, u2, u1} \u03b1 \u03b2 \u03b1 (Equiv.trans.{u1, u2, u2} \u03b1 \u03b2 \u03b2 e (Equiv.swap.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) a b)) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e)) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) a) (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} [\u03b2 : DecidableEq.{u1} \u03b1] {_inst_1 : Sort.{u2}} [_inst_2 : DecidableEq.{u2} _inst_1] (a : _inst_1) (b : _inst_1) (e : Equiv.{u1, u2} \u03b1 _inst_1), Eq.{max 1 u1} (Equiv.{u1, u1} \u03b1 \u03b1) (Equiv.trans.{u1, u2, u1} \u03b1 _inst_1 \u03b1 (Equiv.trans.{u1, u2, u2} \u03b1 _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} \u03b1 _inst_1 e)) (Equiv.swap.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : _inst_1) => \u03b1) a) (fun (a : \u03b1) (b : \u03b1) => \u03b2 a b) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Equiv.{u2, u1} _inst_1 \u03b1) _inst_1 (fun (_x : _inst_1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : _inst_1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u1} _inst_1 \u03b1) (Equiv.symm.{u1, u2} \u03b1 _inst_1 e) a) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Equiv.{u2, u1} _inst_1 \u03b1) _inst_1 (fun (_x : _inst_1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : _inst_1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u1} _inst_1 \u03b1) (Equiv.symm.{u1, u2} \u03b1 _inst_1 e) b))\nCase conversion may be inaccurate. Consider using '#align equiv.trans_swap_trans_symm Equiv.trans_swap_trans_symm\u2093'. -/\n@[simp]\ntheorem trans_swap_trans_symm [DecidableEq \u03b2] (a b : \u03b2) (e : \u03b1 \u2243 \u03b2) :\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 : \u03b1) : swap i j (swap i j a) = a := by\n  rw [\u2190 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] {v : \u03b1 -> \u03b2} {i : \u03b1} {j : \u03b1}, (Eq.{u2} \u03b2 (v i) (v j)) -> (forall (k : \u03b1), Eq.{u2} \u03b2 (v (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} \u03b1) (fun (_x : Equiv.{u1, u1} \u03b1 \u03b1) => \u03b1 -> \u03b1) (Equiv.hasCoeToFun.{u1, u1} \u03b1 \u03b1) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) i j) k)) (v k))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} [\u03b2 : DecidableEq.{u1} \u03b1] {_inst_1 : Sort.{u2}} {v : \u03b1 -> _inst_1} {i : \u03b1} {j : \u03b1}, (Eq.{u2} _inst_1 (v i) (v j)) -> (forall (k : \u03b1), Eq.{u2} _inst_1 (v (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} \u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u1} \u03b1 \u03b1) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => \u03b2 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\u2093'. -/\n/-- A function is invariant to a swap if it is equal at both elements -/\ntheorem apply_swap_eq_self {v : \u03b1 \u2192 \u03b2} {i j : \u03b1} (hv : v i = v j) (k : \u03b1) : v (swap i j k) = v k :=\n  by\n  by_cases hi : k = i; \u00b7 rw [hi, swap_apply_left, hv]\n  by_cases hj : k = j; \u00b7 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 : \u03b1} : swap x y z = w \u2194 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 : \u03b1} : swap a b x \u2260 x \u2194 a \u2260 b \u2227 (x = a \u2228 x = b) :=\n  by\n  by_cases hab : a = b\n  \u00b7 simp [hab]\n  by_cases hax : x = a\n  \u00b7 simp [hax, eq_comm]\n  by_cases hbx : x = b\n  \u00b7 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_2 : DecidableEq.{succ u1} \u03b1] [_inst_3 : DecidableEq.{succ u2} \u03b2] (i : \u03b1) (j : \u03b1), Eq.{max 1 (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 (Equiv.swap.{succ u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) i j) (Equiv.refl.{succ u2} \u03b2)) (Equiv.swap.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (fun (a : Sum.{u1, u2} \u03b1 \u03b2) (b : Sum.{u1, u2} \u03b1 \u03b2) => Sum.decidableEq.{u1, u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_3 a b) a b) (Sum.inl.{u1, u2} \u03b1 \u03b2 i) (Sum.inl.{u1, u2} \u03b1 \u03b2 j))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_2 : DecidableEq.{succ u2} \u03b1] [_inst_3 : DecidableEq.{succ u1} \u03b2] (i : \u03b1) (j : \u03b1), Eq.{max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2)) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 (Equiv.swap.{succ u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) i j) (Equiv.refl.{succ u1} \u03b2)) (Equiv.swap.{max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (fun (a : Sum.{u2, u1} \u03b1 \u03b2) (b : Sum.{u2, u1} \u03b1 \u03b2) => Sum.instDecidableEqSum.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_3 a b) a b) (Sum.inl.{u2, u1} \u03b1 \u03b2 i) (Sum.inl.{u2, u1} \u03b1 \u03b2 j))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_swap_refl Equiv.Perm.sumCongr_swap_refl\u2093'. -/\n@[simp]\ntheorem sumCongr_swap_refl {\u03b1 \u03b2 : Sort _} [DecidableEq \u03b1] [DecidableEq \u03b2] (i j : \u03b1) :\n    Equiv.Perm.sumCongr (Equiv.swap i j) (Equiv.refl \u03b2) = Equiv.swap (Sum.inl i) (Sum.inl j) :=\n  by\n  ext x\n  cases x\n  \u00b7 simp [Sum.map, swap_apply_def]\n    split_ifs <;> rfl\n  \u00b7 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_2 : DecidableEq.{succ u1} \u03b1] [_inst_3 : DecidableEq.{succ u2} \u03b2] (i : \u03b2) (j : \u03b2), Eq.{max 1 (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2)) (Equiv.Perm.sumCongr.{u1, u2} \u03b1 \u03b2 (Equiv.refl.{succ u1} \u03b1) (Equiv.swap.{succ u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_3 a b) i j)) (Equiv.swap.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (fun (a : Sum.{u1, u2} \u03b1 \u03b2) (b : Sum.{u1, u2} \u03b1 \u03b2) => Sum.decidableEq.{u1, u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_3 a b) a b) (Sum.inr.{u1, u2} \u03b1 \u03b2 i) (Sum.inr.{u1, u2} \u03b1 \u03b2 j))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_2 : DecidableEq.{succ u2} \u03b1] [_inst_3 : DecidableEq.{succ u1} \u03b2] (i : \u03b2) (j : \u03b2), Eq.{max (succ u1) (succ u2)} (Equiv.Perm.{max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2)) (Equiv.Perm.sumCongr.{u2, u1} \u03b1 \u03b2 (Equiv.refl.{succ u2} \u03b1) (Equiv.swap.{succ u1} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_3 a b) i j)) (Equiv.swap.{max (succ u1) (succ u2)} (Sum.{u2, u1} \u03b1 \u03b2) (fun (a : Sum.{u2, u1} \u03b1 \u03b2) (b : Sum.{u2, u1} \u03b1 \u03b2) => Sum.instDecidableEqSum.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_3 a b) a b) (Sum.inr.{u2, u1} \u03b1 \u03b2 i) (Sum.inr.{u2, u1} \u03b1 \u03b2 j))\nCase conversion may be inaccurate. Consider using '#align equiv.perm.sum_congr_refl_swap Equiv.Perm.sumCongr_refl_swap\u2093'. -/\n@[simp]\ntheorem sumCongr_refl_swap {\u03b1 \u03b2 : Sort _} [DecidableEq \u03b1] [DecidableEq \u03b2] (i j : \u03b2) :\n    Equiv.Perm.sumCongr (Equiv.refl \u03b1) (Equiv.swap i j) = Equiv.swap (Sum.inr i) (Sum.inr j) :=\n  by\n  ext x\n  cases x\n  \u00b7 simp [Sum.map, swap_apply_of_ne_of_ne]\n  \u00b7 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1], (Equiv.{u1, u2} \u03b1 \u03b2) -> \u03b1 -> \u03b2 -> (Equiv.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} [\u03b2 : DecidableEq.{u1} \u03b1] {_inst_1 : Sort.{u2}}, (Equiv.{u1, u2} \u03b1 _inst_1) -> \u03b1 -> _inst_1 -> (Equiv.{u1, u2} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align equiv.set_value Equiv.setValue\u2093'. -/\n/-- Augment an equivalence with a prescribed mapping `f a = b` -/\ndef setValue (f : \u03b1 \u2243 \u03b2) (a : \u03b1) (b : \u03b2) : \u03b1 \u2243 \u03b2 :=\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] (f : Equiv.{u1, u2} \u03b1 \u03b2) (a : \u03b1) (b : \u03b2), Eq.{u2} \u03b2 (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) (Equiv.setValue.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f a b) a) b\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} [\u03b2 : DecidableEq.{u1} \u03b1] {_inst_1 : Sort.{u2}} (f : Equiv.{u1, u2} \u03b1 _inst_1) (a : \u03b1) (b : _inst_1), Eq.{u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => _inst_1) a) (FunLike.coe.{max (max 1 u1) u2, u1, u2} (Equiv.{u1, u2} \u03b1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => _inst_1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b1 _inst_1) (Equiv.setValue.{u1, u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => \u03b2 a b) _inst_1 f a b) a) b\nCase conversion may be inaccurate. Consider using '#align equiv.set_value_eq Equiv.setValue_eq\u2093'. -/\n@[simp]\ntheorem setValue_eq (f : \u03b1 \u2243 \u03b2) (a : \u03b1) (b : \u03b2) : 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 : \u03b1 \u2192 \u03b1) (h : Involutive f) : Equiv.Perm \u03b1 :=\n  \u27e8f, f, h.LeftInverse, h.RightInverse\u27e9\n#align function.involutive.to_perm Function.Involutive.toPerm\n-/\n\n#print Function.Involutive.coe_toPerm /-\n@[simp]\ntheorem coe_toPerm {f : \u03b1 \u2192 \u03b1} (h : Involutive f) : (h.toPerm f : \u03b1 \u2192 \u03b1) = 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 : \u03b1 \u2192 \u03b1} (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 : \u03b1 \u2192 \u03b1} (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 \u03b1} {y : \u03b1} : x = PLift.up y \u2194 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Function.Injective.{u1, u2} \u03b1 \u03b2 f) -> (forall (x : \u03b1) (y : \u03b1) (z : \u03b1), Eq.{u2} \u03b2 (f (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} \u03b1) (fun (_x : Equiv.{u1, u1} \u03b1 \u03b1) => \u03b1 -> \u03b1) (Equiv.hasCoeToFun.{u1, u1} \u03b1 \u03b1) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y) z)) (coeFn.{max 1 u2, u2} (Equiv.Perm.{u2} \u03b2) (fun (_x : Equiv.{u2, u2} \u03b2 \u03b2) => \u03b2 -> \u03b2) (Equiv.hasCoeToFun.{u2, u2} \u03b2 \u03b2) (Equiv.swap.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (f x) (f y)) (f z)))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [_inst_1 : DecidableEq.{u2} \u03b1] [_inst_2 : DecidableEq.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Function.Injective.{u2, u1} \u03b1 \u03b2 f) -> (forall (x : \u03b1) (y : \u03b1) (z : \u03b1), Eq.{u1} \u03b2 (f (FunLike.coe.{max 1 u2, u2, u2} (Equiv.Perm.{u2} \u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u2} \u03b1 \u03b1) (Equiv.swap.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y) z)) (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} \u03b2) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u1, u1} \u03b2 \u03b2) (Equiv.swap.{u1} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _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\u2093'. -/\ntheorem Function.Injective.map_swap {\u03b1 \u03b2 : Sort _} [DecidableEq \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (hf : Function.Injective f) (x y z : \u03b1) : 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\u2081 h\u2082\n  \u00b7 rw [hf h\u2081, Equiv.swap_apply_left]\n  \u00b7 rw [hf h\u2082, Equiv.swap_apply_right]\n  \u00b7 rw [Equiv.swap_apply_of_ne_of_ne (mt (congr_arg f) h\u2081) (mt (congr_arg f) h\u2082)]\n#align function.injective.map_swap Function.Injective.map_swap\n\nnamespace Equiv\n\nsection\n\nvariable (P : \u03b1 \u2192 Sort w) (e : \u03b1 \u2243 \u03b2)\n\n#print Equiv.piCongrLeft' /-\n/-- Transport dependent functions through an equivalence of the base space.\n-/\n@[simps]\ndef piCongrLeft' : (\u2200 a, P a) \u2243 \u2200 b, P (e.symm b)\n    where\n  toFun f x := f (e.symm x)\n  invFun f x := by rw [\u2190 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 : \u03b2 \u2192 Sort w) (e : \u03b1 \u2243 \u03b2)\n\n/- warning: equiv.Pi_congr_left -> Equiv.piCongrLeft is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (P : \u03b2 -> Sort.{u3}) (e : Equiv.{u1, u2} \u03b1 \u03b2), Equiv.{imax u1 u3, imax u2 u3} (forall (a : \u03b1), P (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) e a)) (forall (b : \u03b2), P b)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u3}} (P : \u03b1 -> Sort.{u1}) (e : Equiv.{u3, u2} \u03b2 \u03b1), Equiv.{imax u3 u1, imax u2 u1} (forall (a : \u03b2), P (FunLike.coe.{max (max 1 u2) u3, u3, u2} (Equiv.{u3, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u3, u2} \u03b2 \u03b1) e a)) (forall (b : \u03b1), P b)\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr_left Equiv.piCongrLeft\u2093'. -/\n/-- Transporting dependent functions through an equivalence of the base,\nexpressed as a \"simplification\".\n-/\ndef piCongrLeft : (\u2200 a, P (e a)) \u2243 \u2200 b, P b :=\n  (piCongrLeft' P e.symm).symm\n#align equiv.Pi_congr_left Equiv.piCongrLeft\n\nend\n\nsection\n\nvariable {W : \u03b1 \u2192 Sort w} {Z : \u03b2 \u2192 Sort z} (h\u2081 : \u03b1 \u2243 \u03b2) (h\u2082 : \u2200 a : \u03b1, W a \u2243 Z (h\u2081 a))\n\n/- warning: equiv.Pi_congr -> Equiv.piCongr is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u1, u2} \u03b1 \u03b2), (forall (a : \u03b1), Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a))) -> (Equiv.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u4}} {W : \u03b1 -> Sort.{u1}} {Z : \u03b2 -> Sort.{u2}} (h\u2081 : Equiv.{u3, u4} \u03b1 \u03b2), (forall (a : \u03b1), Equiv.{u1, u2} (W a) (Z (FunLike.coe.{max (max 1 u3) u4, u3, u4} (Equiv.{u3, u4} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u3, u4} \u03b1 \u03b2) h\u2081 a))) -> (Equiv.{imax u3 u1, imax u4 u2} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr Equiv.piCongr\u2093'. -/\n/-- Transport dependent functions through\nan equivalence of the base spaces and a family\nof equivalences of the matching fibers.\n-/\ndef piCongr : (\u2200 a, W a) \u2243 \u2200 b, Z b :=\n  (Equiv.piCongrRight h\u2082).trans (Equiv.piCongrLeft _ h\u2081)\n#align equiv.Pi_congr Equiv.piCongr\n\n#print Equiv.coe_piCongr_symm /-\n@[simp]\ntheorem coe_piCongr_symm :\n    ((h\u2081.piCongr h\u2082).symm : (\u2200 b, Z b) \u2192 \u2200 a, W a) = fun f a => (h\u2082 a).symm (f (h\u2081 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u1, u2} \u03b1 \u03b2) (h\u2082 : forall (a : \u03b1), Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a))) (f : forall (b : \u03b2), Z b), Eq.{imax u1 u3} (forall (a : \u03b1), 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 : \u03b2), Z b) (forall (a : \u03b1), W a)) (fun (_x : Equiv.{imax u2 u4, imax u1 u3} (forall (b : \u03b2), Z b) (forall (a : \u03b1), W a)) => (forall (b : \u03b2), Z b) -> (forall (a : \u03b1), W a)) (Equiv.hasCoeToFun.{imax u2 u4, imax u1 u3} (forall (b : \u03b2), Z b) (forall (a : \u03b1), W a)) (Equiv.symm.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b) (Equiv.piCongr.{u1, u2, u3, u4} \u03b1 \u03b2 (fun (a : \u03b1) => W a) Z h\u2081 h\u2082)) f) (fun (a : \u03b1) => 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} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a)) (W a)) (fun (_x : Equiv.{u4, u3} (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a)) (W a)) => (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a)) -> (W a)) (Equiv.hasCoeToFun.{u4, u3} (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 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} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a)) (h\u2082 a)) (f (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a)))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u2, u1} \u03b1 \u03b2) (h\u2082 : forall (a : \u03b1), Equiv.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a))) (f : forall (b : \u03b2), Z b), Eq.{imax u2 u3} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : \u03b2), Z b) => forall (a : \u03b1), 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 : \u03b2), Z b) (forall (a : \u03b1), W a)) (forall (b : \u03b2), Z b) (fun (_x : forall (b : \u03b2), Z b) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : \u03b2), Z b) => forall (a : \u03b1), W a) _x) (Equiv.instFunLikeEquiv.{imax u1 u4, imax u2 u3} (forall (b : \u03b2), Z b) (forall (a : \u03b1), W a)) (Equiv.symm.{imax u2 u3, imax u1 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b) (Equiv.piCongr.{u3, u4, u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) => W a) Z h\u2081 h\u2082)) f) (fun (a : \u03b1) => 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} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a)) (W a)) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a)) (fun (_x : Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a)) => W a) _x) (Equiv.instFunLikeEquiv.{u4, u3} (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a)) (W a)) (Equiv.symm.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a)) (h\u2082 a)) (f (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a)))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr_symm_apply Equiv.piCongr_symm_apply\u2093'. -/\ntheorem piCongr_symm_apply (f : \u2200 b, Z b) :\n    (h\u2081.piCongr h\u2082).symm f = fun a => (h\u2082 a).symm (f (h\u2081 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u1, u2} \u03b1 \u03b2) (h\u2082 : forall (a : \u03b1), Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a))) (f : forall (a : \u03b1), W a) (a : \u03b1), Eq.{u4} (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 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 : \u03b1), (fun (a : \u03b1) => W a) a) (forall (b : \u03b2), Z b)) (fun (_x : Equiv.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), (fun (a : \u03b1) => W a) a) (forall (b : \u03b2), Z b)) => (forall (a : \u03b1), (fun (a : \u03b1) => W a) a) -> (forall (b : \u03b2), Z b)) (Equiv.hasCoeToFun.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), (fun (a : \u03b1) => W a) a) (forall (b : \u03b2), Z b)) (Equiv.piCongr.{u1, u2, u3, u4} \u03b1 \u03b2 (fun (a : \u03b1) => W a) Z h\u2081 h\u2082) f (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 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} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a))) (fun (_x : Equiv.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a))) => (W a) -> (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a))) (Equiv.hasCoeToFun.{u3, u4} (W a) (Z (coeFn.{max 1 (imax u1 u2) (imax u2 u1), imax u1 u2} (Equiv.{u1, u2} \u03b1 \u03b2) (fun (_x : Equiv.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2) h\u2081 a))) (h\u2082 a) (f a))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u2, u1} \u03b1 \u03b2) (h\u2082 : forall (a : \u03b1), Equiv.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a))) (f : forall (a : \u03b1), W a) (a : \u03b1), Eq.{u4} (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 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 : \u03b1), W a) (forall (b : \u03b2), Z b)) (forall (a : \u03b1), W a) (fun (_x : forall (a : \u03b1), W a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : \u03b1), W a) => forall (b : \u03b2), Z b) _x) (Equiv.instFunLikeEquiv.{imax u2 u3, imax u1 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b)) (Equiv.piCongr.{u3, u4, u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) => W a) Z h\u2081 h\u2082) f (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 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} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 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} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) a) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a)) _x) (Equiv.instFunLikeEquiv.{u3, u4} (W a) (Z (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Equiv.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u2, u1} \u03b1 \u03b2) h\u2081 a))) (h\u2082 a) (f a))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr_apply_apply Equiv.piCongr_apply_apply\u2093'. -/\n@[simp]\ntheorem piCongr_apply_apply (f : \u2200 a, W a) (a : \u03b1) : h\u2081.piCongr h\u2082 f (h\u2081 a) = h\u2082 a (f a) :=\n  by\n  change cast _ ((h\u2082 (h\u2081.symm (h\u2081 a))) (f (h\u2081.symm (h\u2081 a)))) = (h\u2082 a) (f a)\n  generalize_proofs hZa\n  revert hZa\n  rw [h\u2081.symm_apply_apply a]\n  simp\n#align equiv.Pi_congr_apply_apply Equiv.piCongr_apply_apply\n\nend\n\nsection\n\nvariable {W : \u03b1 \u2192 Sort w} {Z : \u03b2 \u2192 Sort z} (h\u2081 : \u03b1 \u2243 \u03b2) (h\u2082 : \u2200 b : \u03b2, W (h\u2081.symm b) \u2243 Z b)\n\n/- warning: equiv.Pi_congr' -> Equiv.piCongr' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u1, u2} \u03b1 \u03b2), (forall (b : \u03b2), Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)) (Z b)) -> (Equiv.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u4}} {W : \u03b1 -> Sort.{u1}} {Z : \u03b2 -> Sort.{u2}} (h\u2081 : Equiv.{u3, u4} \u03b1 \u03b2), (forall (b : \u03b2), Equiv.{u1, u2} (W (FunLike.coe.{max (max 1 u3) u4, u4, u3} (Equiv.{u4, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u4, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u4} \u03b1 \u03b2 h\u2081) b)) (Z b)) -> (Equiv.{imax u3 u1, imax u4 u2} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr' Equiv.piCongr'\u2093'. -/\n/-- Transport dependent functions through\nan equivalence of the base spaces and a family\nof equivalences of the matching fibres.\n-/\ndef piCongr' : (\u2200 a, W a) \u2243 \u2200 b, Z b :=\n  (piCongr h\u2081.symm fun b => (h\u2082 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u1, u2} \u03b1 \u03b2) (h\u2082 : forall (b : \u03b2), Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)) (Z b)), Eq.{imax (imax u1 u3) u2 u4} ((fun (_x : Equiv.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), (fun (b : \u03b2) => Z b) b)) => (forall (a : \u03b1), W a) -> (forall (b : \u03b2), (fun (b : \u03b2) => Z b) b)) (Equiv.piCongr'.{u1, u2, u3, u4} \u03b1 \u03b2 W (fun (b : \u03b2) => Z b) h\u2081 h\u2082)) (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 : \u03b1), W a) (forall (b : \u03b2), (fun (b : \u03b2) => Z b) b)) (fun (_x : Equiv.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), (fun (b : \u03b2) => Z b) b)) => (forall (a : \u03b1), W a) -> (forall (b : \u03b2), (fun (b : \u03b2) => Z b) b)) (Equiv.hasCoeToFun.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), (fun (b : \u03b2) => Z b) b)) (Equiv.piCongr'.{u1, u2, u3, u4} \u03b1 \u03b2 W (fun (b : \u03b2) => Z b) h\u2081 h\u2082)) (fun (f : forall (a : \u03b1), W a) (b : \u03b2) => 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} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)) (Z b)) (fun (_x : Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)) (Z b)) => (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)) -> (Z b)) (Equiv.hasCoeToFun.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)) (Z b)) (h\u2082 b) (f (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u2, u1} \u03b1 \u03b2) (h\u2082 : forall (b : \u03b2), Equiv.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) (Z b)), Eq.{imax (imax u2 u3) u1 u4} (forall (a : forall (a : \u03b1), W a), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : \u03b1), W a) => forall (b : \u03b2), 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 : \u03b1), W a) (forall (b : \u03b2), Z b)) (forall (a : \u03b1), W a) (fun (_x : forall (a : \u03b1), W a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : \u03b1), W a) => forall (b : \u03b2), Z b) _x) (Equiv.instFunLikeEquiv.{imax u2 u3, imax u1 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b)) (Equiv.piCongr'.{u3, u4, u2, u1} \u03b1 \u03b2 W (fun (b : \u03b2) => Z b) h\u2081 h\u2082)) (fun (f : forall (a : \u03b1), W a) (b : \u03b2) => 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} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) (Z b)) (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) (fun (_x : W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) => Z b) _x) (Equiv.instFunLikeEquiv.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) (Z b)) (h\u2082 b) (f (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)))\nCase conversion may be inaccurate. Consider using '#align equiv.coe_Pi_congr' Equiv.coe_piCongr'\u2093'. -/\n@[simp]\ntheorem coe_piCongr' :\n    (h\u2081.piCongr' h\u2082 : (\u2200 a, W a) \u2192 \u2200 b, Z b) = fun f b => h\u2082 b <| f <| h\u2081.symm b :=\n  rfl\n#align equiv.coe_Pi_congr' Equiv.coe_piCongr'\n\n#print Equiv.piCongr'_apply /-\ntheorem piCongr'_apply (f : \u2200 a, W a) : h\u2081.piCongr' h\u2082 f = fun b => h\u2082 b <| f <| h\u2081.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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u1, u2} \u03b1 \u03b2) (h\u2082 : forall (b : \u03b2), Equiv.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)) (Z b)) (f : forall (b : \u03b2), Z b) (b : \u03b2), Eq.{u3} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) 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 : \u03b2), Z b) (forall (a : \u03b1), W a)) (fun (_x : Equiv.{imax u2 u4, imax u1 u3} (forall (b : \u03b2), Z b) (forall (a : \u03b1), W a)) => (forall (b : \u03b2), Z b) -> (forall (a : \u03b1), W a)) (Equiv.hasCoeToFun.{imax u2 u4, imax u1 u3} (forall (b : \u03b2), Z b) (forall (a : \u03b1), W a)) (Equiv.symm.{imax u1 u3, imax u2 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b) (Equiv.piCongr'.{u1, u2, u3, u4} \u03b1 \u03b2 W (fun (b : \u03b2) => Z b) h\u2081 h\u2082)) f (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) 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} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b))) (fun (_x : Equiv.{u4, u3} (Z b) (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b))) => (Z b) -> (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b))) (Equiv.hasCoeToFun.{u4, u3} (Z b) (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b))) (Equiv.symm.{u3, u4} (W (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 h\u2081) b)) (Z b) (h\u2082 b)) (f b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {W : \u03b1 -> Sort.{u3}} {Z : \u03b2 -> Sort.{u4}} (h\u2081 : Equiv.{u2, u1} \u03b1 \u03b2) (h\u2082 : forall (b : \u03b2), Equiv.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) (Z b)) (f : forall (b : \u03b2), Z b) (b : \u03b2), Eq.{u3} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) 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 : \u03b2), Z b) (forall (a : \u03b1), W a)) (forall (b : \u03b2), Z b) (fun (_x : forall (b : \u03b2), Z b) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : \u03b2), Z b) => forall (a : \u03b1), W a) _x) (Equiv.instFunLikeEquiv.{imax u1 u4, imax u2 u3} (forall (b : \u03b2), Z b) (forall (a : \u03b1), W a)) (Equiv.symm.{imax u2 u3, imax u1 u4} (forall (a : \u03b1), W a) (forall (b : \u03b2), Z b) (Equiv.piCongr'.{u3, u4, u2, u1} \u03b1 \u03b2 W (fun (b : \u03b2) => Z b) h\u2081 h\u2082)) f (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) 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} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) 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} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) _x) (Equiv.instFunLikeEquiv.{u4, u3} (Z b) (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b))) (Equiv.symm.{u3, u4} (W (FunLike.coe.{max (max 1 u2) u1, u1, u2} (Equiv.{u1, u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u1, u2} \u03b2 \u03b1) (Equiv.symm.{u2, u1} \u03b1 \u03b2 h\u2081) b)) (Z b) (h\u2082 b)) (f b))\nCase conversion may be inaccurate. Consider using '#align equiv.Pi_congr'_symm_apply_symm_apply Equiv.piCongr'_symm_apply_symm_apply\u2093'. -/\n@[simp]\ntheorem piCongr'_symm_apply_symm_apply (f : \u2200 b, Z b) (b : \u03b2) :\n    (h\u2081.piCongr' h\u2082).symm f (h\u2081.symm b) = (h\u2082 b).symm (f b) :=\n  by\n  change cast _ ((h\u2082 (h\u2081 (h\u2081.symm b))).symm (f (h\u2081 (h\u2081.symm b)))) = (h\u2082 b).symm (f b)\n  generalize_proofs hWb\n  revert hWb\n  generalize hb : h\u2081 (h\u2081.symm b) = b'\n  rw [h\u2081.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 {\u03b1\u2081 \u03b2\u2081 : Type _} (e : \u03b1\u2081 \u2243 \u03b2\u2081) (f : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 \u03b1\u2081)\n\n/- warning: equiv.semiconj_conj -> Equiv.semiconj_conj is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} (e : Equiv.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) (f : \u03b1\u2081 -> \u03b1\u2081), Function.Semiconj.{u1, u2} \u03b1\u2081 \u03b2\u2081 (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) (fun (_x : Equiv.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) => \u03b1\u2081 -> \u03b2\u2081) (Equiv.hasCoeToFun.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) e) f (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} (\u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081)) (fun (_x : Equiv.{succ u1, succ u2} (\u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081)) => (\u03b1\u2081 -> \u03b1\u2081) -> \u03b2\u2081 -> \u03b2\u2081) (Equiv.hasCoeToFun.{succ u1, succ u2} (\u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081)) (Equiv.conj.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081 e) f)\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u2}} {\u03b2\u2081 : Type.{u1}} (e : Equiv.{succ u2, succ u1} \u03b1\u2081 \u03b2\u2081) (f : \u03b1\u2081 -> \u03b1\u2081), Function.Semiconj.{u2, u1} \u03b1\u2081 \u03b2\u2081 (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Equiv.{succ u2, succ u1} \u03b1\u2081 \u03b2\u2081) \u03b1\u2081 (fun (_x : \u03b1\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1\u2081) => \u03b2\u2081) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} \u03b1\u2081 \u03b2\u2081) e) f (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Equiv.{succ u2, succ u1} (\u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081)) (\u03b1\u2081 -> \u03b1\u2081) (fun (_x : \u03b1\u2081 -> \u03b1\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1\u2081 -> \u03b1\u2081) => \u03b2\u2081 -> \u03b2\u2081) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} (\u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081)) (Equiv.conj.{succ u2, succ u1} \u03b1\u2081 \u03b2\u2081 e) f)\nCase conversion may be inaccurate. Consider using '#align equiv.semiconj_conj Equiv.semiconj_conj\u2093'. -/\ntheorem semiconj_conj (f : \u03b1\u2081 \u2192 \u03b1\u2081) : Semiconj e f (e.conj f) := fun x => by simp\n#align equiv.semiconj_conj Equiv.semiconj_conj\n\n/- warning: equiv.semiconj\u2082_conj -> Equiv.semiconj\u2082_conj is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b2\u2081 : Type.{u2}} (e : Equiv.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) (f : \u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081), Function.Semiconj\u2082.{u1, u2} \u03b1\u2081 \u03b2\u2081 (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) (fun (_x : Equiv.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) => \u03b1\u2081 -> \u03b2\u2081) (Equiv.hasCoeToFun.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081) e) f (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} (\u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081 -> \u03b2\u2081)) (fun (_x : Equiv.{succ u1, succ u2} (\u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081 -> \u03b2\u2081)) => (\u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) -> \u03b2\u2081 -> \u03b2\u2081 -> \u03b2\u2081) (Equiv.hasCoeToFun.{succ u1, succ u2} (\u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081 -> \u03b2\u2081)) (Equiv.arrowCongr.{succ u1, succ u1, succ u2, succ u2} \u03b1\u2081 (\u03b1\u2081 -> \u03b1\u2081) \u03b2\u2081 (\u03b2\u2081 -> \u03b2\u2081) e (Equiv.conj.{succ u1, succ u2} \u03b1\u2081 \u03b2\u2081 e)) f)\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u2}} {\u03b2\u2081 : Type.{u1}} (e : Equiv.{succ u2, succ u1} \u03b1\u2081 \u03b2\u2081) (f : \u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081), Function.Semiconj\u2082.{u2, u1} \u03b1\u2081 \u03b2\u2081 (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Equiv.{succ u2, succ u1} \u03b1\u2081 \u03b2\u2081) \u03b1\u2081 (fun (_x : \u03b1\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1\u2081) => \u03b2\u2081) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} \u03b1\u2081 \u03b2\u2081) e) f (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Equiv.{succ u2, succ u1} (\u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081 -> \u03b2\u2081)) (\u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) (fun (_x : \u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) => \u03b2\u2081 -> \u03b2\u2081 -> \u03b2\u2081) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} (\u03b1\u2081 -> \u03b1\u2081 -> \u03b1\u2081) (\u03b2\u2081 -> \u03b2\u2081 -> \u03b2\u2081)) (Equiv.arrowCongr.{succ u2, succ u2, succ u1, succ u1} \u03b1\u2081 (\u03b1\u2081 -> \u03b1\u2081) \u03b2\u2081 (\u03b2\u2081 -> \u03b2\u2081) e (Equiv.conj.{succ u2, succ u1} \u03b1\u2081 \u03b2\u2081 e)) f)\nCase conversion may be inaccurate. Consider using '#align equiv.semiconj\u2082_conj Equiv.semiconj\u2082_conj\u2093'. -/\ntheorem semiconj\u2082_conj : Semiconj\u2082 e f (e.arrowCongr e.conj f) := fun x y => by simp\n#align equiv.semiconj\u2082_conj Equiv.semiconj\u2082_conj\n\ninstance [IsAssociative \u03b1\u2081 f] : IsAssociative \u03b2\u2081 (e.arrowCongr (e.arrowCongr e) f) :=\n  (e.semiconj\u2082_conj f).isAssociative_right e.Surjective\n\ninstance [IsIdempotent \u03b1\u2081 f] : IsIdempotent \u03b2\u2081 (e.arrowCongr (e.arrowCongr e) f) :=\n  (e.semiconj\u2082_conj f).isIdempotent_right e.Surjective\n\ninstance [IsLeftCancel \u03b1\u2081 f] : IsLeftCancel \u03b2\u2081 (e.arrowCongr (e.arrowCongr e) f) :=\n  \u27e8e.Surjective.forall\u2083.2 fun x y z => by simpa using @IsLeftCancel.left_cancel _ f _ x y z\u27e9\n\ninstance [IsRightCancel \u03b1\u2081 f] : IsRightCancel \u03b2\u2081 (e.arrowCongr (e.arrowCongr e) f) :=\n  \u27e8e.Surjective.forall\u2083.2 fun x y z => by simpa using @IsRightCancel.right_cancel _ f _ x y z\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Function.Injective.{u1, u2} \u03b1 \u03b2 f) -> (forall (x : \u03b1) (y : \u03b1) (z : \u03b1), Eq.{u2} \u03b2 (coeFn.{max 1 u2, u2} (Equiv.Perm.{u2} \u03b2) (fun (_x : Equiv.{u2, u2} \u03b2 \u03b2) => \u03b2 -> \u03b2) (Equiv.hasCoeToFun.{u2, u2} \u03b2 \u03b2) (Equiv.swap.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (f x) (f y)) (f z)) (f (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} \u03b1) (fun (_x : Equiv.{u1, u1} \u03b1 \u03b1) => \u03b1 -> \u03b1) (Equiv.hasCoeToFun.{u1, u1} \u03b1 \u03b1) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y) z)))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [_inst_1 : DecidableEq.{u2} \u03b1] [_inst_2 : DecidableEq.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Function.Injective.{u2, u1} \u03b1 \u03b2 f) -> (forall (x : \u03b1) (y : \u03b1) (z : \u03b1), Eq.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b2) (f z)) (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} \u03b2) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u1, u1} \u03b2 \u03b2) (Equiv.swap.{u1} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (f x) (f y)) (f z)) (f (FunLike.coe.{max 1 u2, u2, u2} (Equiv.Perm.{u2} \u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u2} \u03b1 \u03b1) (Equiv.swap.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y) z)))\nCase conversion may be inaccurate. Consider using '#align function.injective.swap_apply Function.Injective.swap_apply\u2093'. -/\ntheorem Function.Injective.swap_apply [DecidableEq \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (hf : Function.Injective f) (x y z : \u03b1) : Equiv.swap (f x) (f y) (f z) = f (Equiv.swap x y z) :=\n  by\n  by_cases hx : z = x; \u00b7 simp [hx]\n  by_cases hy : z = y; \u00b7 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Function.Injective.{u1, u2} \u03b1 \u03b2 f) -> (forall (x : \u03b1) (y : \u03b1), Eq.{imax u1 u2} (\u03b1 -> \u03b2) (Function.comp.{u1, u2, u2} \u03b1 \u03b2 \u03b2 (coeFn.{max 1 u2, u2} (Equiv.Perm.{u2} \u03b2) (fun (_x : Equiv.{u2, u2} \u03b2 \u03b2) => \u03b2 -> \u03b2) (Equiv.hasCoeToFun.{u2, u2} \u03b2 \u03b2) (Equiv.swap.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (f x) (f y))) f) (Function.comp.{u1, u1, u2} \u03b1 \u03b1 \u03b2 f (coeFn.{max 1 u1, u1} (Equiv.Perm.{u1} \u03b1) (fun (_x : Equiv.{u1, u1} \u03b1 \u03b1) => \u03b1 -> \u03b1) (Equiv.hasCoeToFun.{u1, u1} \u03b1 \u03b1) (Equiv.swap.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y))))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [_inst_1 : DecidableEq.{u2} \u03b1] [_inst_2 : DecidableEq.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Function.Injective.{u2, u1} \u03b1 \u03b2 f) -> (forall (x : \u03b1) (y : \u03b1), Eq.{imax u2 u1} (\u03b1 -> \u03b2) (Function.comp.{u2, u1, u1} \u03b1 \u03b2 \u03b2 (FunLike.coe.{max 1 u1, u1, u1} (Equiv.Perm.{u1} \u03b2) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u1, u1} \u03b2 \u03b2) (Equiv.swap.{u1} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (f x) (f y))) f) (Function.comp.{u2, u2, u1} \u03b1 \u03b1 \u03b2 f (FunLike.coe.{max 1 u2, u2, u2} (Equiv.Perm.{u2} \u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u2} \u03b1 \u03b1) (Equiv.swap.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y))))\nCase conversion may be inaccurate. Consider using '#align function.injective.swap_comp Function.Injective.swap_comp\u2093'. -/\ntheorem Function.Injective.swap_comp [DecidableEq \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (hf : Function.Injective f) (x y : \u03b1) : Equiv.swap (f x) (f y) \u2218 f = f \u2218 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 `\u03b1` is a subsingleton, then it is equivalent to `\u03b1 \u00d7 \u03b1`. -/\ndef subsingletonProdSelfEquiv {\u03b1 : Type _} [Subsingleton \u03b1] : \u03b1 \u00d7 \u03b1 \u2243 \u03b1\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 \u03b1] [Subsingleton \u03b2] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) :\n    \u03b1 \u2243 \u03b2 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 {\u03b1 : Sort.{u2}} [h : Nonempty.{u2} \u03b1] [_inst_1 : Subsingleton.{u2} \u03b1], Equiv.{u2, u1} \u03b1 PUnit.{u1}\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} [h : Nonempty.{u1} \u03b1] [_inst_1 : Subsingleton.{u1} \u03b1], Equiv.{u1, u2} \u03b1 PUnit.{u2}\nCase conversion may be inaccurate. Consider using '#align equiv.punit_of_nonempty_of_subsingleton Equiv.punitOfNonemptyOfSubsingleton\u2093'. -/\n/-- A nonempty subsingleton type is (noncomputably) equivalent to `punit`. -/\nnoncomputable def Equiv.punitOfNonemptyOfSubsingleton {\u03b1 : Sort _} [h : Nonempty \u03b1]\n    [Subsingleton \u03b1] : \u03b1 \u2243 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 \u03b1)` is equivalent to `unique \u03b1`. -/\ndef uniqueUniqueEquiv : Unique (Unique \u03b1) \u2243 Unique \u03b1 :=\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b1' : Sort.{u3}} [_inst_1 : DecidableEq.{u3} \u03b1'] [_inst_2 : DecidableEq.{u1} \u03b1] (f : \u03b1 -> \u03b2) (g : Equiv.{u3, u1} \u03b1' \u03b1) (a : \u03b1) (v : \u03b2), Eq.{imax u3 u2} (\u03b1' -> \u03b2) (Function.comp.{u3, u1, u2} \u03b1' \u03b1 \u03b2 (Function.update.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) f a v) (coeFn.{max 1 (imax u3 u1) (imax u1 u3), imax u3 u1} (Equiv.{u3, u1} \u03b1' \u03b1) (fun (_x : Equiv.{u3, u1} \u03b1' \u03b1) => \u03b1' -> \u03b1) (Equiv.hasCoeToFun.{u3, u1} \u03b1' \u03b1) g)) (Function.update.{u3, u2} \u03b1' (fun (\u1fb0 : \u03b1') => \u03b2) (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) (Function.comp.{u3, u1, u2} \u03b1' \u03b1 \u03b2 f (coeFn.{max 1 (imax u3 u1) (imax u1 u3), imax u3 u1} (Equiv.{u3, u1} \u03b1' \u03b1) (fun (_x : Equiv.{u3, u1} \u03b1' \u03b1) => \u03b1' -> \u03b1) (Equiv.hasCoeToFun.{u3, u1} \u03b1' \u03b1) g)) (coeFn.{max 1 (imax u1 u3) (imax u3 u1), imax u1 u3} (Equiv.{u1, u3} \u03b1 \u03b1') (fun (_x : Equiv.{u1, u3} \u03b1 \u03b1') => \u03b1 -> \u03b1') (Equiv.hasCoeToFun.{u1, u3} \u03b1 \u03b1') (Equiv.symm.{u3, u1} \u03b1' \u03b1 g) a) v)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03b1' : Sort.{u1}} [_inst_1 : DecidableEq.{u3} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] (f : \u03b2 -> \u03b1') (g : Equiv.{u3, u2} \u03b1 \u03b2) (a : \u03b2) (v : \u03b1'), Eq.{imax u3 u1} (\u03b1 -> \u03b1') (Function.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b1' (Function.update.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1') (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f a v) (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u3, u2} \u03b1 \u03b2) g)) (Function.update.{u3, u1} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1') (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Function.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b1' f (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u3, u2} \u03b1 \u03b2) g)) (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 g) a) v)\nCase conversion may be inaccurate. Consider using '#align function.update_comp_equiv Function.update_comp_equiv\u2093'. -/\ntheorem update_comp_equiv {\u03b1 \u03b2 \u03b1' : Sort _} [DecidableEq \u03b1'] [DecidableEq \u03b1] (f : \u03b1 \u2192 \u03b2)\n    (g : \u03b1' \u2243 \u03b1) (a : \u03b1) (v : \u03b2) : update f a v \u2218 g = update (f \u2218 g) (g.symm a) v := by\n  rw [\u2190 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b1' : Sort.{u3}} [_inst_1 : DecidableEq.{u3} \u03b1'] [_inst_2 : DecidableEq.{u1} \u03b1] (f : \u03b1 -> \u03b2) (g : Equiv.{u3, u1} \u03b1' \u03b1) (a : \u03b1) (v : \u03b2) (a' : \u03b1'), Eq.{u2} \u03b2 (Function.update.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) f a v (coeFn.{max 1 (imax u3 u1) (imax u1 u3), imax u3 u1} (Equiv.{u3, u1} \u03b1' \u03b1) (fun (_x : Equiv.{u3, u1} \u03b1' \u03b1) => \u03b1' -> \u03b1) (Equiv.hasCoeToFun.{u3, u1} \u03b1' \u03b1) g a')) (Function.update.{u3, u2} \u03b1' (fun (\u1fb0 : \u03b1') => \u03b2) (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) (Function.comp.{u3, u1, u2} \u03b1' \u03b1 \u03b2 f (coeFn.{max 1 (imax u3 u1) (imax u1 u3), imax u3 u1} (Equiv.{u3, u1} \u03b1' \u03b1) (fun (_x : Equiv.{u3, u1} \u03b1' \u03b1) => \u03b1' -> \u03b1) (Equiv.hasCoeToFun.{u3, u1} \u03b1' \u03b1) g)) (coeFn.{max 1 (imax u1 u3) (imax u3 u1), imax u1 u3} (Equiv.{u1, u3} \u03b1 \u03b1') (fun (_x : Equiv.{u1, u3} \u03b1 \u03b1') => \u03b1 -> \u03b1') (Equiv.hasCoeToFun.{u1, u3} \u03b1 \u03b1') (Equiv.symm.{u3, u1} \u03b1' \u03b1 g) a) v a')\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03b1' : Sort.{u1}} [_inst_1 : DecidableEq.{u3} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] (f : \u03b2 -> \u03b1') (g : Equiv.{u3, u2} \u03b1 \u03b2) (a : \u03b2) (v : \u03b1') (a' : \u03b1), Eq.{u1} \u03b1' (Function.update.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1') (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f a v (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u3, u2} \u03b1 \u03b2) g a')) (Function.update.{u3, u1} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1') (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Function.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b1' f (FunLike.coe.{max (max 1 u3) u2, u3, u2} (Equiv.{u3, u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{u3, u2} \u03b1 \u03b2) g)) (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 g) a) v a')\nCase conversion may be inaccurate. Consider using '#align function.update_apply_equiv_apply Function.update_apply_equiv_apply\u2093'. -/\ntheorem update_apply_equiv_apply {\u03b1 \u03b2 \u03b1' : Sort _} [DecidableEq \u03b1'] [DecidableEq \u03b1] (f : \u03b1 \u2192 \u03b2)\n    (g : \u03b1' \u2243 \u03b1) (a : \u03b1) (v : \u03b2) (a' : \u03b1') : update f a v (g a') = update (f \u2218 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] (P : \u03b1 -> Sort.{u3}) (e : Equiv.{u1, u2} \u03b1 \u03b2) (f : forall (a : \u03b1), P a) (b : \u03b2) (x : P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)), Eq.{imax u2 u3} (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 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 : \u03b1), P a) (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))) (fun (_x : Equiv.{imax u1 u3, imax u2 u3} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))) => (forall (a : \u03b1), P a) -> (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))) (Equiv.hasCoeToFun.{imax u1 u3, imax u2 u3} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))) (Equiv.piCongrLeft'.{u1, u2, u3} \u03b1 \u03b2 P e) (Function.update.{u1, u3} \u03b1 (fun (a : \u03b1) => P a) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b) x)) (Function.update.{u2, u3} \u03b2 (fun (b : \u03b2) => P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (fun (a : \u03b2) (b : \u03b2) => _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 : \u03b1), P a) (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))) (fun (_x : Equiv.{imax u1 u3, imax u2 u3} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))) => (forall (a : \u03b1), P a) -> (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))) (Equiv.hasCoeToFun.{imax u1 u3, imax u2 u3} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b))) (Equiv.piCongrLeft'.{u1, u2, u3} \u03b1 \u03b2 P e) f) b x)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u3} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] (P : \u03b1 -> Sort.{u1}) (e : Equiv.{u3, u2} \u03b1 \u03b2) (f : forall (a : \u03b1), P a) (b : \u03b2) (x : P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)), Eq.{imax u2 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : \u03b1), P a) => forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (Function.update.{u3, u1} \u03b1 (fun (a : \u03b1) => P a) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 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 : \u03b1), P a) (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b))) (forall (a : \u03b1), P a) (fun (_x : forall (a : \u03b1), P a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : \u03b1), P a) => forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) _x) (Equiv.instFunLikeEquiv.{imax u3 u1, imax u2 u1} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b))) (Equiv.piCongrLeft'.{u3, u2, u1} \u03b1 \u03b2 P e) (Function.update.{u3, u1} \u03b1 (fun (a : \u03b1) => P a) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b) x)) (Function.update.{u2, u1} \u03b2 (fun (b : \u03b2) => P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (fun (a : \u03b2) (b : \u03b2) => _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 : \u03b1), P a) (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b))) (forall (a : \u03b1), P a) (fun (_x : forall (a : \u03b1), P a) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (a : \u03b1), P a) => forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) _x) (Equiv.instFunLikeEquiv.{imax u3 u1, imax u2 u1} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b))) (Equiv.piCongrLeft'.{u3, u2, u1} \u03b1 \u03b2 P e) f) b x)\nCase conversion may be inaccurate. Consider using '#align function.Pi_congr_left'_update Function.piCongrLeft'_update\u2093'. -/\ntheorem piCongrLeft'_update [DecidableEq \u03b1] [DecidableEq \u03b2] (P : \u03b1 \u2192 Sort _) (e : \u03b1 \u2243 \u03b2)\n    (f : \u2200 a, P a) (b : \u03b2) (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  \u00b7 simp\n  \u00b7 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u1} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] (P : \u03b1 -> Sort.{u3}) (e : Equiv.{u1, u2} \u03b1 \u03b2) (f : forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (b : \u03b2) (x : P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)), Eq.{imax u1 u3} (forall (a : \u03b1), 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 : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) (fun (_x : Equiv.{imax u2 u3, imax u1 u3} (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) => (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) -> (forall (a : \u03b1), P a)) (Equiv.hasCoeToFun.{imax u2 u3, imax u1 u3} (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) (Equiv.symm.{imax u1 u3, imax u2 u3} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (Equiv.piCongrLeft'.{u1, u2, u3} \u03b1 \u03b2 P e)) (Function.update.{u2, u3} \u03b2 (fun (b : \u03b2) => P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f b x)) (Function.update.{u1, u3} \u03b1 (fun (a : \u03b1) => P a) (fun (a : \u03b1) (b : \u03b1) => _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 : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) (fun (_x : Equiv.{imax u2 u3, imax u1 u3} (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) => (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) -> (forall (a : \u03b1), P a)) (Equiv.hasCoeToFun.{imax u2 u3, imax u1 u3} (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) (Equiv.symm.{imax u1 u3, imax u2 u3} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b)) (Equiv.piCongrLeft'.{u1, u2, u3} \u03b1 \u03b2 P e)) f) (coeFn.{max 1 (imax u2 u1) (imax u1 u2), imax u2 u1} (Equiv.{u2, u1} \u03b2 \u03b1) (fun (_x : Equiv.{u2, u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{u2, u1} \u03b2 \u03b1) (Equiv.symm.{u1, u2} \u03b1 \u03b2 e) b) x)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} [_inst_1 : DecidableEq.{u3} \u03b1] [_inst_2 : DecidableEq.{u2} \u03b2] (P : \u03b1 -> Sort.{u1}) (e : Equiv.{u3, u2} \u03b1 \u03b2) (f : forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (b : \u03b2) (x : P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)), Eq.{imax u3 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) => forall (a : \u03b1), P a) (Function.update.{u2, u1} \u03b2 (fun (b : \u03b2) => P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (fun (a : \u03b2) (b : \u03b2) => _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 : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (fun (_x : forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) => forall (a : \u03b1), P a) _x) (Equiv.instFunLikeEquiv.{imax u2 u1, imax u3 u1} (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) (Equiv.symm.{imax u3 u1, imax u2 u1} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (Equiv.piCongrLeft'.{u3, u2, u1} \u03b1 \u03b2 P e)) (Function.update.{u2, u1} \u03b2 (fun (b : \u03b2) => P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f b x)) (Function.update.{u3, u1} \u03b1 (fun (a : \u03b1) => P a) (fun (a : \u03b1) (b : \u03b1) => _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 : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (fun (_x : forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) a) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) => forall (a : \u03b1), P a) _x) (Equiv.instFunLikeEquiv.{imax u2 u1, imax u3 u1} (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (forall (a : \u03b1), P a)) (Equiv.symm.{imax u3 u1, imax u2 u1} (forall (a : \u03b1), P a) (forall (b : \u03b2), P (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b)) (Equiv.piCongrLeft'.{u3, u2, u1} \u03b1 \u03b2 P e)) f) (FunLike.coe.{max (max 1 u3) u2, u2, u3} (Equiv.{u2, u3} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{u2, u3} \u03b2 \u03b1) (Equiv.symm.{u3, u2} \u03b1 \u03b2 e) b) x)\nCase conversion may be inaccurate. Consider using '#align function.Pi_congr_left'_symm_update Function.piCongrLeft'_symm_update\u2093'. -/\ntheorem piCongrLeft'_symm_update [DecidableEq \u03b1] [DecidableEq \u03b2] (P : \u03b1 \u2192 Sort _) (e : \u03b1 \u2243 \u03b2)\n    (f : \u2200 b, P (e.symm b)) (b : \u03b2) (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_\ud835\udd39_iff_\ud835\udd46 {\u03c4 : lin_type} : \u03c4 \u2260 \ud835\udd39 \u2194 \u03c4 = \ud835\udd46 :=\nbegin\n  cases \u03c4; \n  split; intro h; contradiction <|> refl\nend\n\nlemma not_\ud835\udd46_iff_\ud835\udd39 {\u03c4 : lin_type} : \u03c4 \u2260 \ud835\udd46 \u2194 \u03c4 = \ud835\udd39 :=\nbegin\n  cases \u03c4; \n  split; intro h; contradiction <|> refl\nend\n\nsection FV_wf\n  open finset\n  open list\n\n  theorem FV_sub_wf_context {\u03b4 : program} {\u03b2 : const \u2192 var \u2192 lin_type} {\u0393 : finset var} {F : fn_body} \n    (h : \u03b2; \u03b4; \u0393 \u22a2 F) : \n    FV F \u2286 \u0393 :=\n  begin\n    with_cases { induction F using rc_correctness.fn_body.rec_wf generalizing \u0393 };\n    simp only [subset_iff],\n    case ret : x {\n      intros y h\u2081, \n      simp only [FV, finset.mem_singleton, insert_empty_eq_singleton] at h\u2081,\n      cases h,\n      rwa h\u2081\n    },\n    case \u00ablet\u00bb : x e F ih {\n      intros y h\u2081, \n      simp only [FV, mem_erase, finset.mem_union] at h\u2081,\n      cases h\u2081,\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\u2081;\n        try { simp only [subset_iff, mem_to_finset] at h_ys_def };\n        try { exact h_ys_def h\u2081 };\n        try { rwa h\u2081 },\n        cases h\u2081; rwa h\u2081 },\n      { cases h\u2081,\n        cases h; \n        { replace ih := subset_iff.mp (ih h_F_wf) h\u2081_right,\n          rw mem_insert at ih,\n          cases ih,\n          { contradiction },\n          { assumption } } }\n    },\n    case \u00abcase\u00bb : x Fs ih {\n      intros y h\u2081, \n      simp only [FV, mem_insert, finset.mem_join] at h\u2081,\n      cases h,\n      cases h\u2081, \n      { rwa h\u2081 },\n      rw map_wf_eq_map at h\u2081,\n      simp only [exists_prop, list.mem_map] at h\u2081,\n      rcases h\u2081 with \u27e8l, \u27e8\u27e8a, \u27e8a_in_Fs, FV_a_eq_l\u27e9\u27e9, y_in_l\u27e9\u27e9,\n      rw \u2190FV_a_eq_l at y_in_l,\n      have a_wf : (\u03b2; \u03b4; \u0393 \u22a2 a), from h_Fs_wf a a_in_Fs,\n      have FV_a_sub_\u0393 : FV a \u2286 \u0393, from ih a a_in_Fs a_wf,\n      exact subset_iff.mp FV_a_sub_\u0393 y_in_l\n    },\n    all_goals {\n      intros x F ih \u0393 h y h\u2081,\n      cases h\n    }\n  end\nend FV_wf\n\nsection FV_C\n  open finset\n\n  lemma FV_inc_\ud835\udd46_var_eq_FV {x : var} {F : fn_body} (V : finset var) (\u03b2\u2097 : var \u2192 lin_type) \n    (h : x \u2208 FV F) :\n    FV (inc_\ud835\udd46_var x V F \u03b2\u2097) = FV F :=\n  begin\n    unfold inc_\ud835\udd46_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_\ud835\udd46 (ys : list var) (F : fn_body) (\u03b2\u2097 : var \u2192 lin_type) \n    : FV F \u2286 FV (dec_\ud835\udd46 ys F \u03b2\u2097) :=\n  begin\n    apply subset_iff.mpr,\n    intros x h,\n    unfold dec_\ud835\udd46 dec_\ud835\udd46_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_\ud835\udd46_filter (ys : list var) (F : fn_body) (\u03b2\u2097 : var \u2192 lin_type) \n    : FV (dec_\ud835\udd46 ys F \u03b2\u2097) = ys.to_finset.filter (\u03bb y, \u03b2\u2097 y = \ud835\udd46 \u2227 y \u2209 FV F) \u222a FV F :=\n  begin\n    induction ys,\n    { simp only [dec_\ud835\udd46, filter_empty, finset.empty_union, list.to_finset_nil, list.foldr_nil] },\n    simp only [dec_\ud835\udd46, dec_\ud835\udd46_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 (\u03bb (x : var) (acc : fn_body), \n          ite (\u03b2\u2097 x = \ud835\udd46 \u2227 x \u2209 FV acc) (dec x; acc) acc) \n          F ys_tl) = FV (dec_\ud835\udd46 ys_tl F \u03b2\u2097), from rfl,\n      rw this at h,\n      exact absurd (subset_iff.mp (FV_sub_FV_dec_\ud835\udd46 ys_tl F \u03b2\u2097) 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_\ud835\udd46_sub_vars_FV (vars : list var) (F : fn_body) (\u03b2\u2097 : var \u2192 lin_type) \n  : FV (dec_\ud835\udd46 vars F \u03b2\u2097) \u2286 vars.to_finset \u222a FV F :=\n  begin\n    simp only [FV_dec_\ud835\udd46_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 \u2208 FV_expr e \u222a erase (FV F) z) : \n    FV_expr e \u222a erase (FV (dec x; F)) z = FV_expr e \u222a erase (FV F) z :=\n  begin\n    unfold FV, \n    have hem : x = z \u2228 x \u2260 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 \u00d7 lin_type)} {z : var} {e : expr} {F1 F2 : fn_body} (\u03b2\u2097 : var \u2192 lin_type)\n    (heq : FV F1 = FV F2) (h : \u2200 x\u03c4 \u2208 xs, (x\u03c4 : var \u00d7 lin_type).1 \u2208 FV (z \u2254 e; F1)) : \n    FV (C_app xs (z \u2254 e; F1) \u03b2\u2097) = FV (z \u2254 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 \u03c4,\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 \u03c4,\n    { rw if_pos rfl,\n      unfold inc_\ud835\udd46_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_\ud835\udd46_var, if_false], \n      split_ifs,\n      { suffices h2 : \u2200 (x\u03c4 : var \u00d7 lin_type), x\u03c4 \u2208 xs_tl \u2192 x\u03c4.fst \u2208 FV_expr e \u222a 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\u03c4 y\u03c4_in_tl,\n          have y_in_FV, from h y\u03c4 y\u03c4_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 (\u03b2 : const \u2192 var \u2192 lin_type) (F : fn_body) (\u03b2\u2097 : var \u2192 lin_type) : FV (C \u03b2 F \u03b2\u2097) = FV F :=\n  begin\n    with_cases { induction F using rc_correctness.fn_body.rec_wf generalizing \u03b2\u2097 },\n    case ret : x {\n      unfold FV C inc_\ud835\udd46_var, \n      split_ifs;\n      simp only [FV, insert_eq_of_mem, insert_empty_eq_singleton, mem_singleton]\n    },\n    case \u00abcase\u00bb : 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 \u27e8S, h, a_in_S\u27e9, \n          simp only [list.mem_map, function.comp_app] at h,\n          rcases h with \u27e8b, b_in_Fs, h\u27e9, \n          rw \u2190h at a_in_S,\n          have h2, from FV_dec_\ud835\udd46_sub_vars_FV (sort var_le (insert x (join (list.map FV Fs)))) (C \u03b2 b \u03b2\u2097) \u03b2\u2097,\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 \u27e8l, m, r\u27e9,\n          { exact or.inl h3 },\n          { exact or.inr h3 },\n          rw ih b b_in_Fs \u03b2\u2097 at h3,\n          simp only [exists_prop, list.mem_map, mem_join],\n          exact or.inr \u27e8FV b, \u27e8\u27e8b, \u27e8b_in_Fs, rfl\u27e9\u27e9, h3\u27e9\u27e9 } },\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 \u27e8S, h, a_in_S\u27e9, \n          rw list.mem_map at h,\n          rcases h with \u27e8b, \u27e8b_in_Fs, FV_b_eq_S\u27e9\u27e9,\n          apply or.inr,\n          simp only [mem_join, exists_prop, list.mem_map, function.comp_app],\n          apply exists.intro (FV (dec_\ud835\udd46 (sort var_le (insert x (join (list.map FV Fs)))) (C \u03b2 b \u03b2\u2097) \u03b2\u2097)),\n          apply and.intro,\n          { exact \u27e8b, \u27e8b_in_Fs, rfl\u27e9\u27e9 },\n          rw \u2190ih b b_in_Fs \u03b2\u2097 at FV_b_eq_S,\n          rw \u2190FV_b_eq_S at a_in_S,\n          have h, from FV_sub_FV_dec_\ud835\udd46 (sort var_le (insert x (join (list.map FV Fs)))) (C \u03b2 b \u03b2\u2097) \u03b2\u2097,\n          exact mem_of_subset h a_in_S } }\n    },\n    case \u00ablet\u00bb : x e F ih {\n      induction e;\n      unfold C;\n      try {\n        apply FV_Capp_eq_FV \u03b2\u2097 (ih (\u03b2\u2097[x\u21a6\ud835\udd46])),\n        intros x\u03c4 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\u03c4_def, \n        cases x\u03c4,\n        rw \u2190x\u03c4_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_\ud835\udd46_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 (\u03b2\u2097[x\u21a6\ud835\udd46]) at *,\n          have hem : e_x = x \u2228 e_x \u2260 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 (\u03b2\u2097[x\u21a6\ud835\udd46]) },\n        { rw ih (\u03b2\u2097[x\u21a6\ud835\udd39]) } },\n    },\n    all_goals { intros x F ih \u03b2\u2097, simp only [FV, C] }\n  end\nend FV_C\n\nsection sandwich\n  open finset\n\n  lemma wf_sandwich {\u03b2 : const \u2192 var \u2192 lin_type} {\u03b4 : program} {\u0393 \u0393' \u0393'' : finset var} {F : fn_body} \n    (\u0393_sub_\u0393' : \u0393 \u2286 \u0393') (\u0393'_sub_\u0393'' : \u0393' \u2286 \u0393'') (h\u0393 : \u03b2; \u03b4; \u0393 \u22a2 F) (h\u0393'' : \u03b2; \u03b4; \u0393'' \u22a2 F)\n    : \u03b2; \u03b4; \u0393' \u22a2 F :=\n  begin\n    with_cases { induction F using rc_correctness.fn_body.rec_wf generalizing \u0393 \u0393' \u0393'' },\n    case ret : x {\n      apply fn_body_wf.ret,\n      cases h\u0393,\n      exact subset_iff.mp \u0393_sub_\u0393' h\u0393_x_def\n    },\n    case \u00ablet\u00bb : x e F ih {\n      cases e;\n      cases h\u0393;\n      cases h\u0393'';\n      let h1 := insert_subset_insert x \u0393_sub_\u0393';\n      let h2 := insert_subset_insert x \u0393'_sub_\u0393'',\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\u0393_ys_def },\n        { assumption }\n      },\n      any_goals {\n        intro h,\n        have h', from subset_iff.mp \u0393'_sub_\u0393'' h,\n        contradiction\n      },\n      any_goals { exact ih h1 h2 h\u0393_F_wf h\u0393''_F_wf },\n      any_goals { exact subset_iff.mp \u0393_sub_\u0393' h\u0393_x_def },\n      any_goals { exact subset_iff.mp \u0393_sub_\u0393' h\u0393_y_in_\u0393 }\n    },\n    case \u00abcase\u00bb : x Fs ih {\n      cases h\u0393,\n      cases h\u0393'',\n      apply fn_body_wf.case,\n      { exact subset_iff.mp \u0393_sub_\u0393' h\u0393_x_def },\n      intros F F_in_Fs,\n      exact ih F F_in_Fs \u0393_sub_\u0393' \u0393'_sub_\u0393'' (h\u0393_Fs_wf F F_in_Fs) (h\u0393''_Fs_wf F F_in_Fs)\n    },\n    case \u00abinc\u00bb : x F ih {\n      cases h\u0393\n    },\n    case \u00abdec\u00bb : x F ih {\n      cases h\u0393\n    }\n  end\n\n  lemma FV_wf {\u03b2 : const \u2192 var \u2192 lin_type} {\u03b4 : program} {\u0393 : finset var} {F : fn_body} (h : \u03b2; \u03b4; \u0393 \u22a2 F)\n    : \u03b2; \u03b4; FV F \u22a2 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 \u2208 h_\u0393, 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 \u27e8eq, x_in_FV\u27e9 } \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 \u27e8F_in_Fs, rfl\u27e9 },\n        { assumption } },\n      { intros x h,\n        cases h,\n        { rwa h },\n        rcases h with \u27e8S, \u27e8\u27e8a, \u27e8a_in_Fs, a_def\u27e9\u27e9, x_in_S\u27e9\u27e9,\n        rw \u2190a_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 {\u03b2 : const \u2192 var \u2192 lin_type} {\u03b4 : program} {\u0393 \u0393' : finset var} {F : fn_body} \n    (\u0393'_low : FV F \u2286 \u0393') (\u0393'_high : \u0393' \u2286 \u0393) (h : \u03b2; \u03b4; \u0393 \u22a2 F)\n    : \u03b2; \u03b4; \u0393' \u22a2 F := wf_sandwich \u0393'_low \u0393'_high (FV_wf h) h\nend sandwich\n\nlemma vars_sub_FV_dec_\ud835\udd46 (ys : list var) (F : fn_body) (\u03b2\u2097 : var \u2192 lin_type) \n  : \u2200 y \u2208 ys, \u03b2\u2097 y = \ud835\udd46 \u2192 y \u2208 FV (dec_\ud835\udd46 ys F \u03b2\u2097) :=\nbegin\n  intros y y_in_ys y\ud835\udd46,\n  rw FV_dec_\ud835\udd46_filter,\n  simp only [list.mem_to_finset, finset.mem_union, finset.mem_filter],\n  by_cases y \u2208 FV F,\n  { exact or.inr h },\n  { exact or.inl \u27e8y_in_ys, y\ud835\udd46, h\u27e9 }\nend\n\nlemma dec_\ud835\udd46_eq_dec_\ud835\udd46'_of_nodup {ys : list var} (F : fn_body) (\u03b2\u2097 : var \u2192 lin_type)\n  (d : list.nodup ys) : dec_\ud835\udd46 ys F \u03b2\u2097 = dec_\ud835\udd46' ys F \u03b2\u2097 :=\nbegin\n  unfold dec_\ud835\udd46 dec_\ud835\udd46_var dec_\ud835\udd46',\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 \u27e8rfl, ys_ih nodup_ys_tl\u27e9 },\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_\ud835\udd46 ys_tl F \u03b2\u2097) (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_\ud835\udd46_sub_vars_FV ys_tl F \u03b2\u2097) (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' {\u03b2 : const \u2192 var \u2192 lin_type} {ys : list var} {y\ud835\udd46 y\ud835\udd39 : multiset var} {F : fn_body} {\u03b2\u2097 : var \u2192 lin_type}\n  (ys_sub_vars : \u2191ys \u2286 y\ud835\udd46 + y\ud835\udd39) (d : list.nodup ys)\n  (y\ud835\udd46_\ud835\udd46 : \u2200 y \u2208 y\ud835\udd46, \u03b2\u2097 y = \ud835\udd46) (y\ud835\udd39_\ud835\udd39 : \u2200 y \u2208 y\ud835\udd39, \u03b2\u2097 y = \ud835\udd39) (nd_y\ud835\udd46 : nodup y\ud835\udd46) (nd_y\ud835\udd39 : nodup y\ud835\udd39)\n  (h : \u03b2; (filter (\u03bb y, y \u2209 ys \u2228 y \u2208 FV F) y\ud835\udd46 {\u2236} \ud835\udd46) + (y\ud835\udd39 {\u2236} \ud835\udd39) \u22a9 F \u2237 \ud835\udd46)\n  : \u03b2; (y\ud835\udd46 {\u2236} \ud835\udd46) + (y\ud835\udd39 {\u2236} \ud835\udd39) \u22a9 dec_\ud835\udd46 ys F \u03b2\u2097 \u2237 \ud835\udd46 :=\nbegin\n  have h_congr : \u2200 {ys_hd : var} {ys_tl : list var} {ys' : multiset var} \n    (f : \u2200 y \u2208 ys', y \u2209 ys_tl \u2192 \u00acy = ys_hd \u2227 y \u2209 ys_tl \u2228 y \u2208 FV F), \n    \u2200 y \u2208 ys', y \u2209 (ys_hd :: ys_tl : list var) \u2228 y \u2208 FV F \u2194 y \u2209 ys_tl \u2228 y \u2208 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 \u27e8\u03bb h', h'.elim (\u03bb h'', or.inl h''.right) (\u03bb h'', or.inr h''), \n           \u03bb h', h'.elim (\u03bb h'', f y y_in_ys' h'') (\u03bb h'', or.inr h'')\u27e9 },\n  rw dec_\ud835\udd46_eq_dec_\ud835\udd46'_of_nodup F \u03b2\u2097 d,\n  induction ys generalizing y\ud835\udd46 y\ud835\udd39,\n  { rw [dec_\ud835\udd46', 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 \u2190cons_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_\ud835\udd46', list.foldr_cons], \n  split_ifs,\n  { cases ys_hd_def, swap,\n    { rw y\ud835\udd39_\ud835\udd39 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\ud835\udd46' y\ud835\udd46_def,\n    rw [y\ud835\udd46_def, map_cons, cons_add],\n    apply linear.dec,\n    apply ys_ih,\n    { assumption },\n    { rw y\ud835\udd46_def at ys_tl_sub_vars,\n      rw subset_iff at ys_tl_sub_vars \u22a2,\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\ud835\udd46_def, mem_cons] at y\ud835\udd46_\ud835\udd46,\n      intros y y_in_y\ud835\udd46',\n      exact y\ud835\udd46_\ud835\udd46 y (or.inr y_in_y\ud835\udd46') },\n    { assumption }, \n    { simp only [y\ud835\udd46_def, nodup_cons] at nd_y\ud835\udd46,\n      exact nd_y\ud835\udd46.right },\n    { assumption },\n    { rw y\ud835\udd46_def at h nd_y\ud835\udd46,\n      rw filter_cons_of_neg at h, swap,\n      { simp, exact h_1.right },\n      rw nodup_cons at nd_y\ud835\udd46,\n      have : \u2200 y \u2208 y\ud835\udd46', y \u2209 ys_tl \u2192 \u00acy = ys_hd \u2227 y \u2209 ys_tl \u2228 y \u2208 FV F,\n      { intros y y_in_y\ud835\udd46' h',\n        apply or.inl (and.intro _ h'),\n        intro h',\n        rw h' at y_in_y\ud835\udd46',\n        exact absurd y_in_y\ud835\udd46' nd_y\ud835\udd46.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 [\u2190ne.def, not_\ud835\udd46_iff_\ud835\udd39] at h_1,\n    cases ys_hd_def,\n    { rw y\ud835\udd46_\ud835\udd46 ys_hd ys_hd_def at h_1,\n      contradiction },\n    have : \u2200 y \u2208 y\ud835\udd46, y \u2209 ys_tl \u2192 \u00acy = ys_hd \u2227 y \u2209 ys_tl \u2228 y \u2208 FV F,\n    { intros y y_in_y\ud835\udd46 h',\n      apply or.inl (and.intro _ h'),\n      intro h'',\n      rw h'' at y_in_y\ud835\udd46,\n      rw y\ud835\udd46_\ud835\udd46 ys_hd y_in_y\ud835\udd46 at h_1,\n      contradiction },\n    rwa filter_congr (h_congr this) at h },\n  { have : \u2200 y \u2208 y\ud835\udd46, y \u2209 ys_tl \u2192 \u00acy = ys_hd \u2227 y \u2209 ys_tl \u2228 y \u2208 FV F,\n    { intros y y_in_y\ud835\udd46 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 \u27e8h'', h'\u27e9 } },\n    rwa filter_congr (h_congr this) at h }\nend\n\nlemma inductive_dec {\u03b2 : const \u2192 var \u2192 lin_type} {ys : list var} {y\ud835\udd46 y\ud835\udd39 : multiset var} {F : fn_body} {\u03b2\u2097 : var \u2192 lin_type}\n  (y\ud835\udd46_sub_ys : y\ud835\udd46 \u2286 \u2191ys) (ys_sub_vars : \u2191ys \u2286 y\ud835\udd46 + y\ud835\udd39) (d : list.nodup ys)\n  (y\ud835\udd46_\ud835\udd46 : \u2200 y \u2208 y\ud835\udd46, \u03b2\u2097 y = \ud835\udd46) (y\ud835\udd39_\ud835\udd39 : \u2200 y \u2208 y\ud835\udd39, \u03b2\u2097 y = \ud835\udd39) (nd_y\ud835\udd46 : nodup y\ud835\udd46) (nd_y\ud835\udd39 : nodup y\ud835\udd39)\n  (h : \u03b2; (filter (\u03bb y, y \u2208 FV F) y\ud835\udd46 {\u2236} \ud835\udd46) + (y\ud835\udd39 {\u2236} \ud835\udd39) \u22a9 F \u2237 \ud835\udd46)\n  : \u03b2; (y\ud835\udd46 {\u2236} \ud835\udd46) + (y\ud835\udd39 {\u2236} \ud835\udd39) \u22a9 dec_\ud835\udd46 ys F \u03b2\u2097 \u2237 \ud835\udd46 :=\nbegin\n  have : \u2200 y \u2208 y\ud835\udd46, y \u2208 FV F \u2194 y \u2209 ys \u2228 y \u2208 FV F,\n  { intros y y_in_y\ud835\udd46,\n    split; intro h',\n    { exact or.inr h' },\n    { cases h', \n      { exact absurd (y\ud835\udd46_sub_ys y_in_y\ud835\udd46) h' },\n      { assumption } } },\n  rw filter_congr this at h,\n  exact inductive_dec' ys_sub_vars d y\ud835\udd46_\ud835\udd46 y\ud835\udd39_\ud835\udd39 nd_y\ud835\udd46 nd_y\ud835\udd39 h\nend\n\nlemma inductive_weakening {\u03b2 : const \u2192 var \u2192 lin_type} {ys : multiset typed_var} {y\ud835\udd39 : multiset var} \n  {r : rc} {\u03c4 : lin_type} \n  (h : \u03b2; ys \u22a9 r \u2237 \u03c4)\n  : \u03b2; ys + (y\ud835\udd39 {\u2236} \ud835\udd39) \u22a9 r \u2237 \u03c4 :=\nbegin\n  apply multiset.induction_on y\ud835\udd39,\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 {\u03b2 : const \u2192 var \u2192 lin_type} {\u03b2\u2097 : var \u2192 lin_type} {\u03b4 : program}\n  {y : var} {e : expr} {F : fn_body} {y\ud835\udd46 y\ud835\udd39 : multiset var} {\u0393 : list (var \u00d7 lin_type)}\n  (ih : \u2200 (\u03b2\u2097 : var \u2192 lin_type),\n    nodup y\ud835\udd46 \u2192\n    nodup y\ud835\udd39 \u2192\n    (\u2200 (y : var), y \u2208 y\ud835\udd46 \u2192 \u03b2\u2097 y = \ud835\udd46) \u2192\n    (\u2200 (y : var), y \u2208 y\ud835\udd39 \u2192 \u03b2\u2097 y = \ud835\udd39) \u2192\n    (\u03b2; \u03b4; to_finset y\ud835\udd46 \u222a to_finset y\ud835\udd39 \u22a2 F) \u2192\n    (\u2200 \u2983x : var\u2984, x \u2208 y\ud835\udd46 \u2192 x \u2208 FV F) \u2192\n    (\u03b2; (y\ud835\udd46 {\u2236} \ud835\udd46) + (y\ud835\udd39 {\u2236} \ud835\udd39) \u22a9 \u2191(C \u03b2 F \u03b2\u2097) \u2237 \ud835\udd46))\n  (nd_y\ud835\udd46 : nodup y\ud835\udd46) (nd_y\ud835\udd39 : nodup y\ud835\udd39)\n  (y\ud835\udd46_\ud835\udd46 : \u2200 (y : var), y \u2208 y\ud835\udd46 \u2192 \u03b2\u2097 y = \ud835\udd46)\n  (y\ud835\udd39_\ud835\udd39 : \u2200 (y : var), y \u2208 y\ud835\udd39 \u2192 \u03b2\u2097 y = \ud835\udd39)\n  (wf : \u03b2; \u03b4; to_finset y\ud835\udd46 \u222a to_finset y\ud835\udd39 \u22a2 (y \u2254 e; F))\n  (y\ud835\udd46_free : \u2200 \u2983x : var\u2984, x \u2208 y\ud835\udd46 \u2192 x \u2208 FV (y \u2254 e; F))\n  (ty : \u03b2; (\u0393.map (\u03bb (y\u03c4 : var \u00d7 lin_type), y\u03c4.1 \u2236 y\u03c4.2)) \u22a9 e \u2237 \ud835\udd46)\n  : (\u03b2; (y\ud835\udd46 {\u2236} \ud835\udd46) + (y\ud835\udd39 {\u2236} \ud835\udd39) \u22a9 \u2191(C_app \u0393 (y \u2254 e; C \u03b2 F (\u03b2\u2097[y\u21a6\ud835\udd46])) \u03b2\u2097) \u2237 \ud835\udd46) :=\nbegin\n  sorry\nend\n\n\n\ntheorem rc_insertion_correctness' {\u03b2 : const \u2192 var \u2192 lin_type} {\u03b4 : program} {c : const}\n  {y\ud835\udd46 y\ud835\udd39 : multiset var}\n  (nd_y\ud835\udd46 : nodup y\ud835\udd46) (nd_y\ud835\udd39 : nodup y\ud835\udd39)\n  (y\ud835\udd46_\ud835\udd46 : \u2200 y \u2208 y\ud835\udd46, \u03b2 c y = \ud835\udd46) (y\ud835\udd39_\ud835\udd39 : \u2200 y \u2208 y\ud835\udd39, \u03b2 c y = \ud835\udd39)\n  (y\ud835\udd46_sub_FV : y\ud835\udd46.to_finset \u2286 FV (\u03b4 c).F) (wf : \u03b2; \u03b4; y\ud835\udd46.to_finset \u222a y\ud835\udd39.to_finset \u22a2 (\u03b4 c).F)\n  : \u03b2; (y\ud835\udd46 {\u2236} \ud835\udd46) + (y\ud835\udd39 {\u2236} \ud835\udd39) \u22a9 C \u03b2 ((\u03b4 c).F) (\u03b2 c) \u2237 \ud835\udd46 :=\nbegin\n  generalize h : \u03b2 c = \u03b2\u2097, \n  rw h at *,\n  clear h,\n  simp only [finset.subset_iff, mem_to_finset] at y\ud835\udd46_sub_FV,\n  generalize h : (\u03b4 c).F = F,\n  rw h at *,\n  clear h,\n  with_cases { induction F using rc_correctness.fn_body.rec_wf generalizing y\ud835\udd46 y\ud835\udd39 \u03b2\u2097 },\n  case ret : x {\n    unfold C,\n    unfold FV at y\ud835\udd46_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_\ud835\udd46_var,\n    cases wf_x_def,\n    { have : \u03b2\u2097 x = \ud835\udd46 \u2227 x \u2209 finset.empty, from \u27e8y\ud835\udd46_\ud835\udd46 x wf_x_def, finset.not_mem_empty x\u27e9,\n      rw if_pos this,\n      have : y\ud835\udd46 = x :: 0,\n      { rw nodup_ext nd_y\ud835\udd46 (nodup_singleton x),\n        intro a,\n        split;\n        intro h,\n        { exact y\ud835\udd46_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 \u2190singleton_add,\n      apply inductive_weakening,\n      apply linear.ret },\n    { have : \u00ac(\u03b2\u2097 x = \ud835\udd46 \u2227 x \u2209 finset.empty),\n      { simp only [not_and], \n        intro h,\n        rw y\ud835\udd39_\ud835\udd39 x wf_x_def at h, \n        simp only [] at h, \n        contradiction },\n      rw if_neg this,\n      apply linear.inc_\ud835\udd39,\n      { apply mem_add.mpr,\n        apply or.inr,\n        exact mem_map_of_mem _ wf_x_def },\n      have : y\ud835\udd46 = \u2205,\n      { apply eq_zero_of_forall_not_mem,\n        simp only [finset.insert_empty_eq_singleton, finset.mem_singleton] at y\ud835\udd46_sub_FV,\n        intros y y_in_y\ud835\udd46, \n        have x_in_y\ud835\udd46, from (y\ud835\udd46_sub_FV y_in_y\ud835\udd46).subst y_in_y\ud835\udd46,\n        have dj : multiset.disjoint y\ud835\udd46 y\ud835\udd39,\n        { rw disjoint_iff_ne,\n          intros a a_in_y\ud835\udd46 b b_in_y\ud835\udd39 h,\n          rw h at a_in_y\ud835\udd46,\n          let := y\ud835\udd46_\ud835\udd46 b a_in_y\ud835\udd46,\n          rw y\ud835\udd39_\ud835\udd39 b b_in_y\ud835\udd39 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 \u2190singleton_add,\n      apply inductive_weakening,\n      apply linear.ret } \n  },\n  case \u00ablet\u00bb : 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\ud835\udd46 : x \u2208 y\ud835\udd46,\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 \u2208 y\ud835\udd46 \u2228 x \u2208 y\ud835\udd39, from this (or.inl rfl),\n          cases h,\n          { assumption },\n          { rw y\ud835\udd39_\ud835\udd39 x h_1 at h,\n            contradiction } },\n        apply linear.proj_\ud835\udd46,\n        { simpa },\n        unfold dec_\ud835\udd46_var,\n        split_ifs,\n        { rcases exists_cons_of_mem x_in_y\ud835\udd46 with \u27e8y\ud835\udd46', y\ud835\udd46_def\u27e9,\n          rw y\ud835\udd46_def at *,\n          simp only [map_cons, cons_add],\n          rw cons_swap,\n          apply linear.dec,\n          rw \u2190cons_add,\n          rw \u2190map_cons (\u2236 \ud835\udd46),\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 \u22a2 nd_y\ud835\udd46,\n            exact \u27e8wf_z_undef.left.right, nd_y\ud835\udd46.right\u27e9 },\n          { simp only [mem_cons],\n            intros z z_in_y\ud835\udd46',\n            cases z_in_y\ud835\udd46',\n            { rw z_in_y\ud835\udd46',\n              rw function.update_same },\n            { by_cases z = y,\n              { rw [h, function.update_same] },\n              { rw function.update_noteq,\n                { exact y\ud835\udd46_\ud835\udd46 z (mem_cons_of_mem z_in_y\ud835\udd46') },\n                { assumption } } } },\n          { intros z z_in_y\ud835\udd39,\n            by_cases z = y,\n            { cases wf,\n              simp [not_or_distrib] at wf_z_undef,\n              rw h at z_in_y\ud835\udd39,\n              exact absurd z_in_y\ud835\udd39 wf_z_undef.right },\n            { rw function.update_noteq,\n              { exact y\ud835\udd39_\ud835\udd39 z z_in_y\ud835\udd39 },\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 \u22a2 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 \u22a2 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 \u22a2 y\ud835\udd46_sub_FV,\n            intros z h',\n            cases h',\n            { rwa h' },\n            have h'', from y\ud835\udd46_sub_FV (or.inr h'),\n            cases h'',\n            { rw h'' at h',\n              rw nodup_cons at nd_y\ud835\udd46,\n              exact absurd h' nd_y\ud835\udd46.left },\n            { exact h''.right } } },\n        simp only [not_and_distrib, not_not] at h_1, \n        rw [\u2190ne.def, not_\ud835\udd46_iff_\ud835\udd39] at h_1,\n        cases h_1,\n        { rw h at h_1, contradiction },\n        rw \u2190cons_add,\n        rw \u2190map_cons (\u2236 \ud835\udd46), \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 \u27e8wf_z_undef.left, nd_y\ud835\udd46\u27e9 },\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\ud835\udd46_\ud835\udd46 z h' },\n            symmetry,\n            assumption } },\n        { intros z z_in_y\ud835\udd39,\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\ud835\udd39,\n            exact absurd z_in_y\ud835\udd39 wf_z_undef.right },\n          { rw function.update_noteq,\n            { exact y\ud835\udd39_\ud835\udd39 z z_in_y\ud835\udd39 },\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 \u22a2 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 \u22a2 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\ud835\udd46_sub_FV,\n          intros z h',\n          cases h',\n          { rwa h' },\n          have h'', from y\ud835\udd46_sub_FV h',\n          cases h'',\n          { rw h'',\n            rwa FV_C_eq_FV at h_1 },\n          { exact h''.right } } },\n      rw [\u2190ne.def, not_\ud835\udd46_iff_\ud835\udd39] at h,\n      have x_in_y\ud835\udd39 : x \u2208 y\ud835\udd39,\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 \u2208 y\ud835\udd46 \u2228 x \u2208 y\ud835\udd39, from this (or.inl rfl),\n        cases h,\n        { rw y\ud835\udd46_\ud835\udd46 x h_1 at h,\n          contradiction },\n        { assumption } },\n      apply linear.proj_\ud835\udd39,\n      { simpa },\n      rw [add_comm, \u2190cons_add, add_comm, \u2190map_cons (\u2236 \ud835\udd39)],\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 \u27e8wf_z_undef.right, nd_y\ud835\udd39\u27e9 },\n      { intros z z_in_y\ud835\udd46,\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\ud835\udd46,\n          exact absurd z_in_y\ud835\udd46 wf_z_undef.left },\n        { rw function.update_noteq,\n          { exact y\ud835\udd46_\ud835\udd46 z z_in_y\ud835\udd46 },\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\ud835\udd39_\ud835\udd39 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 \u22a2 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 \u22a2 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\ud835\udd46_sub_FV,\n        intros z z_in_y\ud835\udd46,\n        have h', from y\ud835\udd46_sub_FV z_in_y\ud835\udd46,\n        cases h',\n        { rw h' at z_in_y\ud835\udd46,\n          rw y\ud835\udd46_\ud835\udd46 x z_in_y\ud835\udd46 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\ud835\udd46 nd_y\ud835\udd39 y\ud835\udd46_\ud835\udd46 y\ud835\udd39_\ud835\udd39 wf y\ud835\udd46_sub_FV,\n      simp only [list.map_map],\n      have : \u2200 y \u2208 ys, ((\u03bb (y\u03c4 : var \u00d7 lin_type), y\u03c4.fst \u2236 y\u03c4.snd) \u2218 (\u03bb (y : var), (y, \u03b2 c' y))) y = (\u03bb (y : var), y \u2236 \u03b2 c' y) y,\n      { intros y' y'_in_ys, \n        refl },\n      rw list.map_congr this,\n      exact linear.const_app_full \u03b2 ys c'\n    },\n    case rc_correctness.expr.const_app_part : c' ys {\n      unfold C,\n      have : \u2200 y \u2208 ys, (y, \u03b2 c' y) = (y, \ud835\udd46),\n      { cases wf,\n        intros y' y'_in_ys,\n        have not_\ud835\udd39, from wf_no_\ud835\udd39_var y',\n        rw not_\ud835\udd39_iff_\ud835\udd46 at not_\ud835\udd39,\n        rw not_\ud835\udd39 },\n      rw list.map_congr this,\n      apply C_app_rc_insertion_correctness ih nd_y\ud835\udd46 nd_y\ud835\udd39 y\ud835\udd46_\ud835\udd46 y\ud835\udd39_\ud835\udd39 wf y\ud835\udd46_sub_FV,\n      rw list.map_map,\n      have : \u2200 y \u2208 ys, ((\u03bb (y\u03c4 : var \u00d7 lin_type), y\u03c4.fst \u2236 y\u03c4.snd) \u2218 (\u03bb (y : var), (y, \ud835\udd46))) y = (\u03bb (y : var), y \u2236 \ud835\udd46) y,\n      { intros y' y'_in_ys, \n        refl },\n      rw list.map_congr this,\n      exact linear.const_app_part \u03b2 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\ud835\udd46 nd_y\ud835\udd39 y\ud835\udd46_\ud835\udd46 y\ud835\udd39_\ud835\udd39 wf y\ud835\udd46_sub_FV,\n      simp only [list.map],\n      exact linear.var_app \u03b2 x z\n    },\n    case rc_correctness.expr.ctor : i ys {\n      unfold C,\n      apply C_app_rc_insertion_correctness ih nd_y\ud835\udd46 nd_y\ud835\udd39 y\ud835\udd46_\ud835\udd46 y\ud835\udd39_\ud835\udd39 wf y\ud835\udd46_sub_FV,\n      rw list.map_map,\n      have : \u2200 y \u2208 ys, ((\u03bb (y\u03c4 : var \u00d7 lin_type), y\u03c4.fst \u2236 y\u03c4.snd) \u2218 (\u03bb (y : var), (y, \ud835\udd46))) y = (\u03bb (y : var), y \u2236 \ud835\udd46) y,\n      { intros y' y'_in_ys, \n        refl },\n      rw list.map_congr this,\n      exact linear.ctor_app \u03b2 ys i\n    }\n  },\n  case \u00abcase\u00bb : x Fs ih {\n    unfold C,\n    have FV_sub_y\ud835\udd46_y\ud835\udd39 : (FV (case x of Fs)).val \u2286 y\ud835\udd46 + y\ud835\udd39,\n    { let := FV_sub_wf_context wf,\n      rw finset.subset_def at this,\n      rw subset_iff at \u22a2 this,\n      simp only [mem_union, to_finset_val, mem_add, mem_erase_dup, finset.union_val] at \u22a2 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_\ud835\udd46, \n    { simpa },\n    swap,\n    apply linear.case_\ud835\udd39,\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 \u27e8F, \u27e8F_in_Fs, F'_def\u27e9\u27e9, \n      rw \u2190F'_def,\n      apply inductive_dec,\n      any_goals { assumption },\n      { rw subset_iff,\n        rw finset.sort_eq,\n        intros y y_in_y\ud835\udd46,\n        exact y\ud835\udd46_sub_FV y_in_y\ud835\udd46 },\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\ud835\udd46 h,\n        exact y\ud835\udd46_\ud835\udd46 y y_in_y\ud835\udd46 },\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\ud835\udd46_y\ud835\udd39,\n          simp only [FV, list.map_wf_eq_map, mem_ndinsert, mem_add, finset.insert_val] at FV_sub_y\ud835\udd46_y\ud835\udd39, \n          simp [FV, list.map_wf_eq_map, not_or_distrib],\n          intros y y_in_FV,\n          replace FV_sub_y\ud835\udd46_y\ud835\udd39 := @FV_sub_y\ud835\udd46_y\ud835\udd39 y,\n          rw \u2190finset.mem_def at FV_sub_y\ud835\udd46_y\ud835\udd39,\n          simp only [exists_prop, list.mem_map, finset.mem_join] at FV_sub_y\ud835\udd46_y\ud835\udd39,\n          rw FV_C_eq_FV,\n          have : \u2203 (S : finset var), (\u2203 (a : fn_body), a \u2208 Fs \u2227 FV a = S) \u2227 y \u2208 S,\n          { use FV F, apply and.intro _ y_in_FV, use F, exact \u27e8F_in_Fs, rfl\u27e9 },\n          have : y \u2208 y\ud835\udd46 \u2228 y \u2208 y\ud835\udd39, from FV_sub_y\ud835\udd46_y\ud835\udd39 (or.inr this),\n          cases this,\n          { exact or.inr \u27e8this_1, y_in_FV\u27e9 },\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 \u00abinc\u00bb : x F ih {\n    cases wf\n  },\n  case \u00abdec\u00bb : x F ih {\n    cases wf\n  }\nend\n\ntheorem rc_insertion_correctness (\u03b2 : const \u2192 var \u2192 lin_type) (\u03b4 : program) (wf : \u03b2 \u22a2 \u03b4) : \u03b2 \u22a9 C_prog \u03b2 \u03b4 :=\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 := (\u03b4 c).ys,\n  let \u0393 := (\u2191(list.map (\u03bb (y : var), y \u2236 \u03b2 c y) ys) : multiset typed_var),\n  let y\ud835\udd46 := filter (\u03bb y, \u03b2 c y = \ud835\udd46) ys,\n  let y\ud835\udd39 := filter (\u03bb y, \u03b2 c y = \ud835\udd39) ys,\n  obtain \u27e8y\ud835\udd46_\ud835\udd46, y\ud835\udd39_\ud835\udd39\u27e9 \n    : (\u2200 y \u2208 y\ud835\udd46, \u03b2 c y = \ud835\udd46) \u2227 (\u2200 y \u2208 y\ud835\udd39, \u03b2 c y = \ud835\udd39),\n  { repeat { split }; { intros y h, rw (mem_filter.mp h).right } },\n  obtain \u27e8y\ud835\udd46_sub_ys, y\ud835\udd39_sub_ys\u27e9 : (y\ud835\udd46 \u2286 ys \u2227 y\ud835\udd39 \u2286 ys),\n  { repeat { split }; simp only [filter_subset] },\n  obtain \u27e8ys_\ud835\udd46_sub_y\ud835\udd46, ys_\ud835\udd39_sub_y\ud835\udd39\u27e9\n    : (\u2200 y \u2208 ys, \u03b2 c y = \ud835\udd46 \u2192 y \u2208 y\ud835\udd46) \u2227 (\u2200 y \u2208 ys, \u03b2 c y = \ud835\udd39 \u2192 y \u2208 y\ud835\udd39),\n  { repeat { split };\n    { intros y y_in_ys y_ty, \n      simp only [mem_filter, mem_coe], try { rw \u2190coe_eq_coe }, exact \u27e8y_in_ys, y_ty\u27e9 } },\n  obtain \u27e8nd_y\ud835\udd46, nd_y\ud835\udd39\u27e9 : multiset.nodup y\ud835\udd46 \u2227 multiset.nodup y\ud835\udd39,\n  { split; exact nodup_filter _ (coe_nodup.mpr wf_const_wf_nd_ys) },\n  have ys_subdiv : \u2191ys = y\ud835\udd46 + y\ud835\udd39,\n  { have : \u2200 y \u2208 (\u2191ys : multiset var), \u03b2 c y = \ud835\udd39 \u2194 \u03b2 c y \u2260 \ud835\udd46, \n    { intros y y_in_ys,\n      split; intro h; cases \u03b2 c y; simp at h \u22a2; assumption },\n    simp only [y\ud835\udd46, y\ud835\udd39],\n    rw filter_congr this,\n    exact (filter_add_not \u2191ys).symm },\n  have \u0393_subdiv : \u2191(list.map (\u03bb (y : var), y \u2236 \u03b2 c y) ys) = (y\ud835\udd46 {\u2236} \ud835\udd46) + (y\ud835\udd39 {\u2236} \ud835\udd39),\n  { have : \u2191(list.map (\u03bb (y : var), y \u2236 \u03b2 c y) ys) = map (\u03bb (y : var), y \u2236 \u03b2 c y) \u2191ys, \n      from rfl,\n    rw this,\n    rw ys_subdiv,\n    simp only [map_add],  \n    have : \u2200 (\u03c4 : lin_type) (y\u03c4 : multiset var), (\u2200 y \u2208 y\u03c4, \u03b2 c y = \u03c4) \u2192\n      \u2200 y \u2208 y\u03c4, (y \u2236 \u03b2 c y) = (y \u2236 \u03c4), \n    { intros \u03c4 y\u03c4 h y y_in_y\u03c4, \n      rw h y y_in_y\u03c4 },\n    simp only [map_congr (this \ud835\udd46 y\ud835\udd46 y\ud835\udd46_\ud835\udd46), map_congr (this \ud835\udd39 y\ud835\udd39 y\ud835\udd39_\ud835\udd39)] },\n  have y\ud835\udd46_sub_FV : y\ud835\udd46.to_finset \u2286 FV (dec_\ud835\udd46 ((\u03b4 c).ys) (C \u03b2 ((\u03b4 c).F) (\u03b2 c)) (\u03b2 c)), \n  { rw finset.subset_iff,\n    intros y y_in_y\ud835\udd46,\n    simp only [mem_filter, mem_coe, mem_to_finset] at y_in_y\ud835\udd46,\n    exact vars_sub_FV_dec_\ud835\udd46 ys (C \u03b2 ((\u03b4 c).F) (\u03b2 c)) (\u03b2 c) y y_in_y\ud835\udd46.left y_in_y\ud835\udd46.right },\n  rw \u0393_subdiv,\n  unfold list.to_finset at wf,\n  rw ys_subdiv at wf,\n  have : \u2191ys \u2286 y\ud835\udd46 + y\ud835\udd39, { rw ys_subdiv, exact subset.refl _ },\n  apply inductive_dec y\ud835\udd46_sub_ys this wf_const_wf_nd_ys y\ud835\udd46_\ud835\udd46 y\ud835\udd39_\ud835\udd39 nd_y\ud835\udd46 nd_y\ud835\udd39, \n  let y\ud835\udd46' := filter (\u03bb (y : var), y \u2208 FV (C \u03b2 ((\u03b4 c).F) (\u03b2 c))) y\ud835\udd46,\n  have y\ud835\udd46'_\ud835\udd46 : \u2200 y \u2208 y\ud835\udd46', \u03b2 c y = \ud835\udd46,\n  { simp only [and_imp, mem_filter, mem_coe], \n    intros y y_in_ys y_\ud835\udd46 y_in_FV,\n    assumption },\n  have nd_y\ud835\udd46' : nodup y\ud835\udd46', from nodup_filter _ nd_y\ud835\udd46,\n  have y\ud835\udd46'_sub_y\ud835\udd46 : y\ud835\udd46' \u2286 y\ud835\udd46, from filter_subset y\ud835\udd46,\n  have y\ud835\udd46'_sub_FV : y\ud835\udd46'.to_finset \u2286 FV (\u03b4 c).F,\n  { rw finset.subset_iff, rw finset.subset_iff at y\ud835\udd46_sub_FV, rw subset_iff at y\ud835\udd46'_sub_y\ud835\udd46,\n    simp only [mem_to_finset], simp only [mem_to_finset] at y\ud835\udd46_sub_FV,\n    rw FV_dec_\ud835\udd46_filter at y\ud835\udd46_sub_FV, \n    intros x x_in_y\ud835\udd46',\n    have h, from y\ud835\udd46_sub_FV (y\ud835\udd46'_sub_y\ud835\udd46 x_in_y\ud835\udd46'),\n    simp only [mem_filter, mem_coe] at x_in_y\ud835\udd46',\n    simp only [list.mem_to_finset, finset.mem_union, finset.mem_filter] at h,\n    cases h,\n    { exact absurd x_in_y\ud835\udd46'.right h.right.right },\n    rwa FV_C_eq_FV at h },\n  have wf' : (\u03b2; \u03b4; to_finset y\ud835\udd46' \u222a to_finset y\ud835\udd39 \u22a2 (\u03b4 c).F),\n  { rw to_finset_add at wf,\n    have h1 : FV (\u03b4 c).F \u2286 to_finset y\ud835\udd46' \u222a to_finset y\ud835\udd39,\n    { have : FV (\u03b4 c).F \u2286 to_finset y\ud835\udd46 \u222a to_finset y\ud835\udd39, 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 \u22a2, \n      cases this,\n      { rw FV_C_eq_FV,\n        exact or.inl \u27e8this_1, x_in_FV \u27e9 },\n      { exact or.inr this_1 } },\n    have h2 : to_finset y\ud835\udd46' \u222a to_finset y\ud835\udd39 \u2286 to_finset y\ud835\udd46 \u222a to_finset y\ud835\udd39,\n    { rw subset_iff at y\ud835\udd46'_sub_y\ud835\udd46,\n      simp only [finset.subset_iff, finset.mem_union, mem_to_finset], \n      intros x h,\n      cases h,\n      { exact or.inl (y\ud835\udd46'_sub_y\ud835\udd46 h) },\n      { exact or.inr h } },\n    exact wf_FV_sandwich h1 h2 wf },\n  exact rc_insertion_correctness' nd_y\ud835\udd46' nd_y\ud835\udd39 y\ud835\udd46'_\ud835\udd46 y\ud835\udd39_\ud835\udd39 y\ud835\udd46'_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 {\u03b1 : Type*} {n : \u2115}\n\n\nlemma nil_append (as : dvector \u03b1 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 \u03b1 n) : fin n \u2192 \u03b1 :=\n\u03bb k, dvector.nth' as k\n @[simp] lemma cons_nth'_succ_eq_nth' {n} {x : \u03b1} {as : dvector \u03b1 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 : \u03b1} {as : dvector \u03b1 n} :\n  fin_val (dvector.cons x as) = fin.x_val x (fin_val as) :=\nfunext (\n  @fin.cases n\n  (\u03bb k, fin_val (dvector.cons x as) k = fin.x_val x (fin_val as) k)\n  rfl\n  (\u03bb k, begin unfold fin_val, simp, end)\n  )\n\nlemma nth_eq_succ_nth : \u03a0 {k n : \u2115} {as : dvector \u03b1 (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 : \u03a0 (as : list \u03b1), dvector \u03b1 (list.length as)\n| list.nil := dvector.nil\n| (list.cons a as) := dvector.cons a (of_list as)\n\ndef reverse : \u03a0 {n : \u2115} (v : dvector \u03b1 n),\n  dvector \u03b1 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 : \u03a0 {xl yl : \u2115}\n  {xs : dvector \u03b1 xl} {ys : dvector \u03b1 yl} {n : \u2115} (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 \u2190 (@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 : \u03a0 {xl yl : \u2115}\n  {xs : dvector \u03b1 xl} {ys : dvector \u03b1 yl} {n : \u2115}\n  (hbig : xl \u2264 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 : \u03a0 {xl yl k : \u2115}\n  {xs : dvector \u03b1 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 : \u03a0 (l : list \u03b1) (k : \u2115) (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 \u2192 \u03b1) \u2192 dvector \u03b1 n :=\n\u03bb f, dvector.cast (list.length_of_fn _) (dvector.of_list (list.of_fn f))\n\nlemma nth_of_fn (as : fin n \u2192 \u03b1) (k : \u2115) (hk : k < n) :\n  (dvector.of_fn as).nth k hk = as \u27e8 k , hk \u27e9 :=\nby rw [of_fn, nth_cast, nth_of_list, list.nth_le_of_fn']\n\nlemma nth'_of_fn (as : fin n \u2192 \u03b1) (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 \u2192 \u03b1) :\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 : \u03a0 {n : \u2115},\n  dvector \u03b1 n \u2192 list \u03b1\n| 0            as := []\n| (nat.succ n) (dvector.cons a as) := list.cons a (to_list as)\n\nlemma to_list_length : \u03a0 {n : \u2115} {as : dvector \u03b1 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 : \u2115} (i : fin n) (k : fin m) :\n  i.val * m + \u2191k < 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 \u27e8 i.1 , hi \u27e9),\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 : \u2115} (i : fin n) (xs : dvector \u03b1 (n * m)) :\n  dvector \u03b1 m :=\n  of_fn (\u03bb k, dvector.nth xs (i.1 * m + k) (dvector.ith_chunk_aux i k))\n\nlemma nth'_eq {\u03b1} {n} (ys : dvector \u03b1 n) :\n  (\u03bb (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 : \u2115} (i : fin n) (xs : dvector \u03b1 (n * m))\n  (l : \u2115) (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 \u27e8 l , hl \u27e9) :=\nby simpa only [dvector.ith_chunk, dvector.nth_of_fn]\n\nlemma nth_remove_mth_big_m : \u03a0 {n m} (xs : dvector \u03b1 (n+1)) {k : \u2115}\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 \u2190 nat.succ_lt_succ_iff,\n  exact hm,\nend\n\nlemma ext : \u03a0 {as bs : dvector \u03b1 n},\n  as = bs \u2194 \u2200 (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 \u27e8 i + 1 , nat.succ_lt_succ i.2 \u27e9,\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 : \u2115 \u2192 \u03b1} :\n  of_fn (\u03bb i : fin (n+1), f i) =\n  cons (f 0) (of_fn (\u03bb (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 : \u2115} : \u03a0 {f : \u2115 \u2192 \u03b1},\n  dvector.remove_mth n (of_fn (\u03bb (i : fin (n+1)), f i))\n  =\n  dvector.of_fn (\u03bb 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 (\u03bb (i : fin (n+2)), f i))\n      = cons (f 0) (of_fn (\u03bb i : fin n.succ, f (i + 1))) :=\n    of_fn_eq_cons_of_fn_succ,\n    have hrw1 : of_fn (\u03bb (i : fin n.succ), f i)\n      = cons (f 0) (of_fn (\u03bb 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 (\u03bb n, f (n + 1)),\n  },\nend\n\nsection ulift\n\ndef ulift_up {\u03b1} {n} : dvector \u03b1 n \u2192 dvector (ulift \u03b1) n :=\n  dvector.map ulift.up\n\ndef ulift_down {\u03b1} {n} : dvector (ulift \u03b1) n \u2192 dvector \u03b1 n :=\n  dvector.map ulift.down\n\nend ulift\n\n@[simp] protected lemma map_id' : \u2200{n : \u2115} (xs : dvector \u03b1 n), xs.map id = xs\n| _ dvector.nil      := rfl\n| _ (dvector.cons x xs) := by { dsimp, simp* }\n\n@[simp] protected lemma map_comp {\u03b2 \u03b3 : Type*} :\n\u2200{n : \u2115} (xs : dvector \u03b1 n) (g : \u03b1 \u2192 \u03b2) (f : \u03b2 \u2192 \u03b3),\n  xs.map (f \u2218 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 \u03b1 n} {k : \u2115} (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 \u03b1 n} {k : fin n} :\n  dvector.pmem (xs.nth' k) xs := pmem_nth _\n\n\nlemma cast_nil {\u03b1} (h : 0 = 0) : (dvector.cast h dvector.nil : dvector \u03b1 0) = dvector.nil :=\nby refl\n\nlemma of_fn_zero {\u03b1 : Type*} (f : fin 0 \u2192 \u03b1) : dvector.of_fn f = dvector.nil := rfl\n\nlemma of_fn_eq_cons_of_fn_succ' {\u03b1 : Type*} {n : \u2115} {f : fin n.succ \u2192 \u03b1} :\n  dvector.of_fn f = dvector.cons (f 0) (dvector.of_fn (\u03bb (i : fin n), f (i + 1))) :=\nbegin\n  set g : \u2115 \u2192 \u03b1 := \u03bb k, ite (k < n.succ) (f k) (f 0) with hg,\n  have hrw1 : dvector.of_fn f = dvector.of_fn (\u03bb k, g k),\n  { congr, ext x, rw hg, simp only [fin.coe_coe_eq_self],\n    by_cases hx : (x : \u2115) < 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 : \u2115) + 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\u207b\u00b9`.\n\n## Main results\n\n- `adjoin_adjoin_left`: adjoining S and then T is the same as adjoining `S \u222a T`.\n- `bot_eq_top_of_dim_adjoin_eq_one`: if `F\u27eex\u27ef` has dimension `1` over `F` for every `x`\n  in `E` then `F = E`\n\n## Notation\n\n - `F\u27ee\u03b1\u27ef`: adjoin a single element `\u03b1` 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 \u2286 E`. -/\ndef adjoin : intermediate_field F E :=\n{ algebra_map_mem' := \u03bb x, subfield.subset_closure (or.inl (set.mem_range_self x)),\n  ..subfield.closure (set.range (algebra_map F E) \u222a 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 \u2264 T \u2194 S \u2264 T :=\n\u27e8\u03bb H, le_trans (le_trans (set.subset_union_right _ _) subfield.subset_closure) H,\n  \u03bb H, (@subfield.closure_le E _ (set.range (algebra_map F E) \u222a S) T.to_subfield).mpr\n  (set.union_subset (intermediate_field.set_range_subset T) H)\u27e9\n\nlemma gc : galois_connection (adjoin F : set E \u2192 intermediate_field F E) coe := \u03bb _ _, adjoin_le_iff\n\n/-- Galois insertion between `adjoin` and `coe`. -/\ndef gi : galois_insertion (adjoin F : set E \u2192 intermediate_field F E) coe :=\n{ choice := \u03bb S _, adjoin F S,\n  gc := intermediate_field.gc,\n  le_l_u := \u03bb S, (intermediate_field.gc (S : set E) (adjoin F S)).1 $ le_refl _,\n  choice_eq := \u03bb _ _, rfl }\n\ninstance : complete_lattice (intermediate_field F E) :=\ngalois_insertion.lift_complete_lattice intermediate_field.gi\n\ninstance : inhabited (intermediate_field F E) := \u27e8\u22a4\u27e9\n\nlemma mem_bot {x : E} : x \u2208 (\u22a5 : intermediate_field F E) \u2194 x \u2208 set.range (algebra_map F E) :=\nbegin\n  suffices : set.range (algebra_map F E) = (\u22a5 : intermediate_field F E),\n  { rw this, refl },\n  { change set.range (algebra_map F E) = subfield.closure (set.range (algebra_map F E) \u222a \u2205),\n    simp [\u2190set.image_univ, \u2190ring_hom.map_field_closure] }\nend\n\nlemma mem_top {x : E} : x \u2208 (\u22a4 : intermediate_field F E) :=\nsubfield.subset_closure $ or.inr trivial\n\n@[simp] lemma bot_to_subalgebra : (\u22a5 : intermediate_field F E).to_subalgebra = \u22a5 :=\nby { ext, rw [mem_to_subalgebra, algebra.mem_bot, mem_bot] }\n\n@[simp] lemma top_to_subalgebra : (\u22a4 : intermediate_field F E).to_subalgebra = \u22a4 :=\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 \u2243\u2090[F] Y :=\nby refine { to_fun := \u03bb x, \u27e8x, _\u27e9, inv_fun := \u03bb x, \u27e8x, _\u27e9, .. }; tidy\n\n/-- The bottom intermediate_field is isomorphic to the field. -/\nnoncomputable def bot_equiv : (\u22a5 : intermediate_field F E) \u2243\u2090[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 (\u22a5 : intermediate_field F E) x) = x :=\nalg_equiv.commutes bot_equiv x\n\nnoncomputable instance algebra_over_bot : algebra (\u22a5 : 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 (\u22a5 : intermediate_field F E) F E :=\nis_scalar_tower.of_algebra_map_eq\nbegin\n  intro x,\n  let \u03d5 := algebra.of_id F (\u22a5 : subalgebra F E),\n  let \u03c8 := alg_equiv.of_bijective \u03d5 ((algebra.bot_equiv F E).symm.bijective),\n  change (\u2191x : E) = \u2191(\u03c8 (\u03c8.symm \u27e8x, _\u27e9)),\n  rw alg_equiv.apply_symm_apply \u03c8 \u27e8x, _\u27e9,\n  refl\nend\n\n/-- The top intermediate_field is isomorphic to the field. -/\nnoncomputable def top_equiv : (\u22a4 : intermediate_field F E) \u2243\u2090[F] E :=\n(subalgebra.equiv_of_eq top_to_subalgebra).trans algebra.top_equiv\n\n@[simp] lemma top_equiv_def (x : (\u22a4 : intermediate_field F E)) : top_equiv x = \u2191x :=\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    \u27e8\u03bb _ _, subtype.mk.inj, \u03bb x, \u27e8x.val, by { ext, refl }\u27e9\u27e9 : E \u2243\u2090[F] (\u22a4 : 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) : \u2191(\u22a5 : 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  \u2191(\u22a4 : intermediate_field K E) = (\u22a4 : intermediate_field F E) :=\nintermediate_field.ext'_iff.mpr (set.ext_iff.mpr (\u03bb _, 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 \u2208 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) \u2286 adjoin F S :=\nbegin\n  intros x hx,\n  cases hx with f hf,\n  rw \u2190 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 := \u03bb x, \u27e8algebra_map F E x, adjoin.algebra_map_mem F S x\u27e9}\n\nlemma subset_adjoin : S \u2286 adjoin F S :=\n\u03bb x hx, subfield.subset_closure (or.inr hx)\n\ninstance adjoin.set_coe : has_coe_t S (adjoin F S) :=\n{coe := \u03bb x, \u27e8x,subset_adjoin F S (subtype.mem x)\u27e9}\n\n@[mono] lemma adjoin.mono (T : set E) (h : S \u2286 T) : adjoin F S \u2264 adjoin F T :=\ngalois_connection.monotone_l gc h\n\nlemma adjoin_contains_field_as_subfield (F : subfield E) : (F : set E) \u2286 adjoin F S :=\n\u03bb x hx, adjoin.algebra_map_mem F S \u27e8x, hx\u27e9\n\nlemma subset_adjoin_of_subset_left {F : subfield E} {T : set E} (HT : T \u2286 F) : T \u2286 adjoin F S :=\n\u03bb x hx, (adjoin F S).algebra_map_mem \u27e8x, HT hx\u27e9\n\nlemma subset_adjoin_of_subset_right {T : set E} (H : T \u2286 S) : T \u2286 adjoin F S :=\n\u03bb 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 (\u2205 : set E) = \u22a5 :=\neq_bot_iff.mpr (adjoin_le_iff.mpr (set.empty_subset _))\n\n/-- If `K` is a field with `F \u2286 K` and `S \u2286 K` then `adjoin F S \u2264 K`. -/\nlemma adjoin_le_subfield {K : subfield E} (HF : set.range (algebra_map F E) \u2286 K)\n  (HS : S \u2286 K) : (adjoin F S).to_subfield \u2264 K :=\nbegin\n  apply subfield.closure_le.mpr,\n  rw set.union_subset_iff,\n  exact \u27e8HF, HS\u27e9,\nend\n\nlemma adjoin_subset_adjoin_iff {F' : Type*} [field F'] [algebra F' E]\n  {S S' : set E} : (adjoin F S : set E) \u2286 adjoin F' S' \u2194\n  set.range (algebra_map F E) \u2286 adjoin F' S' \u2227 S \u2286 adjoin F' S' :=\n\u27e8\u03bb h, \u27e8trans (adjoin.range_algebra_map_subset _ _) h, trans (subset_adjoin _ _) h\u27e9,\n  \u03bb \u27e8hF, hS\u27e9, subfield.closure_le.mpr (set.union_subset hF hS)\u27e9\n\n/-- `F[S][T] = F[S \u222a T]` -/\nlemma adjoin_adjoin_left (T : set E) : \u2191(adjoin (adjoin F S) T) = adjoin F (S \u222a T) :=\nbegin\n  rw intermediate_field.ext'_iff,\n  change \u2191(adjoin (adjoin F S) T) = _,\n  apply set.eq_of_subset_of_subset; rw adjoin_subset_adjoin_iff; split,\n  { rintros _ \u27e8\u27e8x, hx\u27e9, rfl\u27e9, 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 \u27e8subset_adjoin _ _ (set.mem_insert _ _),\n   adjoin_le_iff.mpr (subset_adjoin_of_subset_right _ _ (set.subset_insert _ _))\u27e9))\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  \u2191(adjoin (adjoin F S) T) = (\u2191(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 \u2192\u2090[F] E') :\n  (adjoin F S).map f = adjoin F (f '' S) :=\nbegin\n  ext x,\n  show x \u2208 (subfield.closure (set.range (algebra_map F E) \u222a S)).map (f : E \u2192+* E') \u2194\n       x \u2208 subfield.closure (set.range (algebra_map F E') \u222a f '' S),\n  rw [ring_hom.map_field_closure, set.image_union, \u2190 set.range_comp, \u2190 ring_hom.coe_comp,\n      f.comp_algebra_map],\n  refl,\nend\n\nlemma algebra_adjoin_le_adjoin : algebra.adjoin F S \u2264 (adjoin F S).to_subalgebra :=\nalgebra.adjoin_le (subset_adjoin _ _)\n\nlemma adjoin_eq_algebra_adjoin (inv_mem : \u2200 x \u2208 algebra.adjoin F S, x\u207b\u00b9 \u2208 algebra.adjoin F S) :\n  (adjoin F S).to_subalgebra = algebra.adjoin F S :=\nle_antisymm\n  (show adjoin F S \u2264\n      { neg_mem' := \u03bb 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 \u2190 h,\n  refl\nend\n\n@[elab_as_eliminator]\nlemma adjoin_induction {s : set E} {p : E \u2192 Prop} {x} (h : x \u2208 adjoin F s)\n  (Hs : \u2200 x \u2208 s, p x) (Hmap : \u2200 x, p (algebra_map F E x))\n  (Hadd : \u2200 x y, p x \u2192 p y \u2192 p (x + y))\n  (Hneg : \u2200 x, p x \u2192 p (-x))\n  (Hinv : \u2200 x, p x \u2192 p x\u207b\u00b9)\n  (Hmul : \u2200 x y, p x \u2192 p y \u2192 p (x * y)) : p x :=\nsubfield.closure_induction h (\u03bb x hx, or.cases_on hx (\u03bb \u27e8x, hx\u27e9, hx \u25b8 Hmap x) (Hs x))\n  ((algebra_map F E).map_one \u25b8 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 {\u03b1 : Type*} (s : set \u03b1) :=\n(insert : \u03b1 \u2192 set \u03b1)\n\n@[priority 1000]\ninstance insert_empty {\u03b1 : Type*} : insert (\u2205 : set \u03b1) :=\n{ insert := \u03bb x, @singleton _ _ set.has_singleton x }\n\n@[priority 900]\ninstance insert_nonempty {\u03b1 : Type*} (s : set \u03b1) : insert s :=\n{ insert := \u03bb x, set.insert x s }\n\nnotation K`\u27ee`:std.prec.max_plus l:(foldr `, ` (h t, insert.insert t h) \u2205) `\u27ef` := adjoin K l\n\nsection adjoin_simple\nvariables (\u03b1 : E)\n\nlemma mem_adjoin_simple_self : \u03b1 \u2208 F\u27ee\u03b1\u27ef :=\nsubset_adjoin F {\u03b1} (set.mem_singleton \u03b1)\n\n/-- generator of `F\u27ee\u03b1\u27ef` -/\ndef adjoin_simple.gen : F\u27ee\u03b1\u27ef := \u27e8\u03b1, mem_adjoin_simple_self F \u03b1\u27e9\n\n@[simp] lemma adjoin_simple.algebra_map_gen : algebra_map F\u27ee\u03b1\u27ef E (adjoin_simple.gen F \u03b1) = \u03b1 := rfl\n\nlemma adjoin_simple_adjoin_simple (\u03b2 : E) : \u2191F\u27ee\u03b1\u27ef\u27ee\u03b2\u27ef = F\u27ee\u03b1, \u03b2\u27ef :=\nadjoin_adjoin_left _ _ _\n\nlemma adjoin_simple_comm (\u03b2 : E) : \u2191F\u27ee\u03b1\u27ef\u27ee\u03b2\u27ef = (\u2191F\u27ee\u03b2\u27ef\u27ee\u03b1\u27ef : 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\u03b1 : is_integral F \u03b1) :\n  (F\u27ee\u03b1\u27ef).to_subalgebra = algebra.adjoin F {\u03b1} :=\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 {\u03b1}) },\n\n  let \u03d5 := alg_equiv.adjoin_singleton_equiv_adjoin_root_minpoly F \u03b1,\n  haveI := minpoly.irreducible h\u03b1,\n  suffices : \u03d5 \u27e8x, hx\u27e9 * (\u03d5 \u27e8x, hx\u27e9)\u207b\u00b9 = 1,\n  { convert subtype.mem (\u03d5.symm (\u03d5 \u27e8x, hx\u27e9)\u207b\u00b9),\n    refine (eq_inv_of_mul_right_eq_one _).symm,\n    apply_fun \u03d5.symm at this,\n    rw [alg_equiv.map_one, alg_equiv.map_mul, alg_equiv.symm_apply_apply] at this,\n    rw [\u2190subsemiring.coe_one, \u2190this, subsemiring.coe_mul, subtype.coe_mk] },\n\n  rw mul_inv_cancel (mt (\u03bb key, _) h),\n  rw \u2190 \u03d5.map_zero at key,\n  change \u2191(\u27e8x, hx\u27e9 : algebra.adjoin F {\u03b1}) = _,\n  rw [\u03d5.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] {\u03b1 : E} {S : set E}\n\n@[simp] lemma adjoin_eq_bot_iff : adjoin F S = \u22a5 \u2194 S \u2286 (\u22a5 : intermediate_field F E) :=\nby { rw [eq_bot_iff, adjoin_le_iff], refl, }\n\n@[simp] lemma adjoin_simple_eq_bot_iff : F\u27ee\u03b1\u27ef = \u22a5 \u2194 \u03b1 \u2208 (\u22a5 : intermediate_field F E) :=\nby { rw adjoin_eq_bot_iff, exact set.singleton_subset_iff }\n\n@[simp] lemma adjoin_zero : F\u27ee(0 : E)\u27ef = \u22a5 :=\nadjoin_simple_eq_bot_iff.mpr (zero_mem \u22a5)\n\n@[simp] lemma adjoin_one : F\u27ee(1 : E)\u27ef = \u22a5 :=\nadjoin_simple_eq_bot_iff.mpr (one_mem \u22a5)\n\n@[simp] lemma adjoin_int (n : \u2124) : F\u27ee(n : E)\u27ef = \u22a5 :=\nadjoin_simple_eq_bot_iff.mpr (coe_int_mem \u22a5 n)\n\n@[simp] lemma adjoin_nat (n : \u2115) : F\u27ee(n : E)\u27ef = \u22a5 :=\nadjoin_simple_eq_bot_iff.mpr (coe_int_mem \u22a5 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 \u2194 K = \u22a5 :=\nby rw [\u2190 to_subalgebra_eq_iff, \u2190 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 \u2194 K = \u22a5 :=\nby rw [\u2190 to_subalgebra_eq_iff, \u2190 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 \u2194 S \u2286 (\u22a5 : 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\u27ee\u03b1\u27ef = 1 \u2194 \u03b1 \u2208 (\u22a5 : 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 \u2194 S \u2286 (\u22a5 : 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\u27ee\u03b1\u27ef = 1 \u2194 \u03b1 \u2208 (\u22a5 : intermediate_field F E) :=\nby { rw [findim_adjoin_eq_one_iff], exact set.singleton_subset_iff }\n\n/-- If `F\u27eex\u27ef` has dimension `1` over `F` for every `x \u2208 E` then `F = E`. -/\nlemma bot_eq_top_of_dim_adjoin_eq_one (h : \u2200 x : E, dim F F\u27eex\u27ef = 1) :\n  (\u22a5 : intermediate_field F E) = \u22a4 :=\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 : \u2200 x : E, findim F F\u27eex\u27ef = 1) :\n  (\u22a5 : intermediate_field F E) = \u22a4 :=\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 : \u2200 x : E, dim F F\u27eex\u27ef = 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 : \u2200 x : E, findim F F\u27eex\u27ef = 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\u27eex\u27ef` has dimension `\u22641` over `F` for every `x \u2208 E` then `F = E`. -/\nlemma bot_eq_top_of_findim_adjoin_le_one [finite_dimensional F E]\n  (h : \u2200 x : E, findim F F\u27eex\u27ef \u2264 1) : (\u22a5 : intermediate_field F E) = \u22a4 :=\nbegin\n  apply bot_eq_top_of_findim_adjoin_eq_one,\n  exact \u03bb x, by linarith [h x, show 0 < findim F F\u27eex\u27ef, from findim_pos],\nend\n\nlemma subsingleton_of_findim_adjoin_le_one [finite_dimensional F E]\n  (h : \u2200 x : E, findim F F\u27eex\u27ef \u2264 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] {\u03b1 : E}\nvariables {K : Type*} [field K] [algebra F K]\n\nlemma aeval_gen_minpoly (\u03b1 : E) :\n  aeval (adjoin_simple.gen F \u03b1) (minpoly F \u03b1) = 0 :=\nbegin\n  ext,\n  convert minpoly.aeval F \u03b1,\n  conv in (aeval \u03b1) { rw [\u2190 adjoin_simple.algebra_map_gen F \u03b1] },\n  exact is_scalar_tower.algebra_map_aeval F F\u27ee\u03b1\u27ef E _ _\nend\n\n/-- algebra isomorphism between `adjoin_root` and `F\u27ee\u03b1\u27ef` -/\nnoncomputable def adjoin_root_equiv_adjoin (h : is_integral F \u03b1) :\n  adjoin_root (minpoly F \u03b1) \u2243\u2090[F] F\u27ee\u03b1\u27ef :=\nalg_equiv.of_bijective (alg_hom.mk (adjoin_root.lift (algebra_map F F\u27ee\u03b1\u27ef)\n  (adjoin_simple.gen F \u03b1) (aeval_gen_minpoly F \u03b1)) (ring_hom.map_one _)\n  (\u03bb x y, ring_hom.map_mul _ x y) (ring_hom.map_zero _) (\u03bb x y, ring_hom.map_add _ x y)\n  (by { exact \u03bb _, adjoin_root.lift_of })) (begin\n    set f := adjoin_root.lift _ _ (aeval_gen_minpoly F \u03b1),\n    haveI := minpoly.irreducible h,\n    split,\n    { exact ring_hom.injective f },\n    { suffices : F\u27ee\u03b1\u27ef.to_subfield \u2264 ring_hom.field_range ((F\u27ee\u03b1\u27ef.to_subfield.subtype).comp f),\n      { exact \u03bb x, Exists.cases_on (this (subtype.mem x)) (\u03bb y hy, \u27e8y, subtype.ext hy.2\u27e9) },\n      exact subfield.closure_le.mpr (set.union_subset (\u03bb x hx, Exists.cases_on hx (\u03bb y hy, \u27e8y,\n        \u27e8subfield.mem_top y, by { rw [ring_hom.comp_apply, adjoin_root.lift_of], exact hy }\u27e9\u27e9))\n        (set.singleton_subset_iff.mpr \u27e8adjoin_root.root (minpoly F \u03b1),\n        \u27e8subfield.mem_top (adjoin_root.root (minpoly F \u03b1)),\n        by { rw [ring_hom.comp_apply, adjoin_root.lift_root], refl }\u27e9\u27e9)) } end)\n\nlemma adjoin_root_equiv_adjoin_apply_root (h : is_integral F \u03b1) :\n  adjoin_root_equiv_adjoin F h (adjoin_root.root (minpoly F \u03b1)) =\n    adjoin_simple.gen F \u03b1 :=\nbegin\n  refine adjoin_root.lift_root,\n  { exact minpoly F \u03b1 },\n  { exact aeval_gen_minpoly F \u03b1 }\nend\n\n/-- Algebra homomorphism `F\u27ee\u03b1\u27ef \u2192\u2090[F] K` are in bijection with the set of roots\nof `minpoly \u03b1` in `K`. -/\nnoncomputable def alg_hom_adjoin_integral_equiv (h : is_integral F \u03b1) :\n  (F\u27ee\u03b1\u27ef \u2192\u2090[F] K) \u2243 {x // x \u2208 ((minpoly F \u03b1).map (algebra_map F K)).roots} :=\nlet \u03d5 := adjoin_root_equiv_adjoin F h,\n  swap1 : (F\u27ee\u03b1\u27ef \u2192\u2090[F] K) \u2243 (adjoin_root (minpoly F \u03b1) \u2192\u2090[F] K) :=\n  { to_fun := \u03bb f, f.comp \u03d5.to_alg_hom,\n    inv_fun := \u03bb f, f.comp \u03d5.symm.to_alg_hom,\n    left_inv := \u03bb _, 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 := \u03bb _, 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 \u03b1) (minpoly.ne_zero h) in\nswap1.trans swap2\n\n/-- Fintype of algebra homomorphism `F\u27ee\u03b1\u27ef \u2192\u2090[F] K` -/\nnoncomputable def fintype_of_alg_hom_adjoin_integral (h : is_integral F \u03b1) :\n  fintype (F\u27ee\u03b1\u27ef \u2192\u2090[F] K) :=\nfintype.of_equiv _ (alg_hom_adjoin_integral_equiv F h).symm\n\nlemma card_alg_hom_adjoin_integral (h : is_integral F \u03b1) (h_sep : (minpoly F \u03b1).separable)\n  (h_splits : (minpoly F \u03b1).splits (algebra_map F K)) :\n  @fintype.card (F\u27ee\u03b1\u27ef \u2192\u2090[F] K) (fintype_of_alg_hom_adjoin_integral F h) =\n    (minpoly F \u03b1).nat_degree :=\nbegin\n  let s := ((minpoly F \u03b1).map (algebra_map F K)).roots.to_finset,\n  have H := \u03bb 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 := \u2203 (t : finset E), adjoin F \u2191t = S\n\nlemma fg_adjoin_finset (t : finset E) : (adjoin F (\u2191t : set E)).fg :=\n\u27e8t, rfl\u27e9\n\ntheorem fg_def {S : intermediate_field F E} : S.fg \u2194 \u2203 t : set E, set.finite t \u2227 adjoin F t = S :=\n\u27e8\u03bb \u27e8t, ht\u27e9, \u27e8\u2191t, set.finite_mem_finset t, ht\u27e9,\n \u03bb \u27e8t, ht1, ht2\u27e9, \u27e8ht1.to_finset, by rwa set.finite.coe_to_finset\u27e9\u27e9\n\ntheorem fg_bot : (\u22a5 : intermediate_field F E).fg :=\n\u27e8\u2205, adjoin_empty F E\u27e9\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 \u27e8t, (eq_adjoin_of_eq_algebra_adjoin _ _ _ ht.symm).symm\u27e9\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 \u2192 Prop) (base : P \u22a5)\n  (ih : \u2200 (K : intermediate_field F E) (x \u2208 S), P K \u2192 P \u2191K\u27eex\u27ef) : P (adjoin F \u2191S) :=\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, \u2190adjoin_adjoin_left],\n    exact ih (adjoin F s) a h1 h4 }\nend\n\nlemma induction_on_adjoin_fg (P : intermediate_field F E \u2192 Prop)\n  (base : P \u22a5) (ih : \u2200 (K : intermediate_field F E) (x : E), P K \u2192 P \u2191K\u27eex\u27ef)\n  (K : intermediate_field F E) (hK : K.fg) : P K :=\nbegin\n  obtain \u27e8S, rfl\u27e9 := hK,\n  exact induction_on_adjoin_finset S P base (\u03bb K x _ hK, ih K x hK),\nend\n\nlemma induction_on_adjoin [fd : finite_dimensional F E] (P : intermediate_field F E \u2192 Prop)\n  (base : P \u22a5) (ih : \u2200 (K : intermediate_field F E) (x : E), P K \u2192 P \u2191K\u27eex\u27ef)\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 \u2192 K` of `F \u2192 K` -/\ndef lifts := \u03a3 (L : intermediate_field F E), (L \u2192\u2090[F] K)\n\nvariables {F E K}\n\nnoncomputable instance : order_bot (lifts F E K) :=\n{ le := \u03bb x y, x.1 \u2264 y.1 \u2227 (\u2200 (s : x.1) (t : y.1), (s : E) = t \u2192 x.2 s = y.2 t),\n  le_refl := \u03bb x, \u27e8le_refl x.1, \u03bb s t hst, congr_arg x.2 (subtype.ext hst)\u27e9,\n  le_trans := \u03bb x y z hxy hyz, \u27e8le_trans hxy.1 hyz.1, \u03bb s u hsu, eq.trans\n    (hxy.2 s \u27e8s, hxy.1 s.mem\u27e9 rfl) (hyz.2 \u27e8s, hxy.1 s.mem\u27e9 u hsu)\u27e9,\n  le_antisymm :=\n  begin\n    rintros \u27e8x1, x2\u27e9 \u27e8y1, y2\u27e9 \u27e8hxy1, hxy2\u27e9 \u27e8hyx1, hyx2\u27e9,\n    have : x1 = y1 := le_antisymm hxy1 hyx1,\n    subst this,\n    congr,\n    exact alg_hom.ext (\u03bb s, hxy2 s s rfl),\n  end,\n  bot := \u27e8\u22a5, (algebra.of_id F K).comp bot_equiv.to_alg_hom\u27e9,\n  bot_le := \u03bb x, \u27e8bot_le, \u03bb 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\u27e9 }\n\nnoncomputable instance : inhabited (lifts F E K) := \u27e8\u22a5\u27e9\n\nlemma lifts.eq_of_le {x y : lifts F E K} (hxy : x \u2264 y) (s : x.1) :\n  x.2 s = y.2 \u27e8s, hxy.1 s.mem\u27e9 := hxy.2 s \u27e8s, hxy.1 s.mem\u27e9 rfl\n\nlemma lifts.exists_max_two {c : set (lifts F E K)} {x y : lifts F E K} (hc : zorn.chain (\u2264) c)\n  (hx : x \u2208 set.insert \u22a5 c) (hy : y \u2208 set.insert \u22a5 c) :\n  \u2203 z : lifts F E K, z \u2208 set.insert \u22a5 c \u2227 x \u2264 z \u2227 y \u2264 z :=\nbegin\n  cases (zorn.chain_insert hc (\u03bb _ _ _, or.inl bot_le)).total_of_refl hx hy with hxy hyx,\n  { exact \u27e8y, hy, hxy, le_refl y\u27e9 },\n  { exact \u27e8x, hx, le_refl x, hyx\u27e9 },\nend\n\nlemma lifts.exists_max_three {c : set (lifts F E K)} {x y z : lifts F E K} (hc : zorn.chain (\u2264) c)\n  (hx : x \u2208 set.insert \u22a5 c) (hy : y \u2208 set.insert \u22a5 c) (hz : z \u2208 set.insert \u22a5 c) :\n  \u2203 w  : lifts F E K, w \u2208 set.insert \u22a5 c \u2227 x \u2264 w \u2227 y \u2264 w \u2227 z \u2264 w :=\nbegin\n  obtain \u27e8v, hv, hxv, hyv\u27e9 := lifts.exists_max_two hc hx hy,\n  obtain \u27e8w, hw, hzw, hvw\u27e9 := lifts.exists_max_two hc hz hv,\n  exact \u27e8w, hw, le_trans hxv hvw, le_trans hyv hvw, hzw\u27e9,\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 (\u2264) c) :\n  intermediate_field F E :=\n{ carrier := \u03bb s, \u2203 x : (lifts F E K), x \u2208 set.insert \u22a5 c \u2227 (s \u2208 x.1 : Prop),\n  zero_mem' := \u27e8\u22a5, set.mem_insert \u22a5 c, zero_mem \u22a5\u27e9,\n  one_mem' := \u27e8\u22a5, set.mem_insert \u22a5 c, one_mem \u22a5\u27e9,\n  neg_mem' := by { rintros _ \u27e8x, y, h\u27e9, exact \u27e8x, \u27e8y, x.1.neg_mem h\u27e9\u27e9 },\n  inv_mem' := by { rintros _ \u27e8x, y, h\u27e9, exact \u27e8x, \u27e8y, x.1.inv_mem h\u27e9\u27e9 },\n  add_mem' := by\n  { rintros _ _ \u27e8x, hx, ha\u27e9 \u27e8y, hy, hb\u27e9,\n    obtain \u27e8z, hz, hxz, hyz\u27e9 := lifts.exists_max_two hc hx hy,\n    exact \u27e8z, hz, z.1.add_mem (hxz.1 ha) (hyz.1 hb)\u27e9 },\n  mul_mem' := by\n  { rintros _ _ \u27e8x, hx, ha\u27e9 \u27e8y, hy, hb\u27e9,\n    obtain \u27e8z, hz, hxz, hyz\u27e9 := lifts.exists_max_two hc hx hy,\n    exact \u27e8z, hz, z.1.mul_mem (hxz.1 ha) (hyz.1 hb)\u27e9 },\n  algebra_map_mem' := \u03bb s, \u27e8\u22a5, set.mem_insert \u22a5 c, algebra_map_mem \u22a5 s\u27e9 }\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 (\u2264) c) :\n  lifts.upper_bound_intermediate_field hc \u2192\u2090[F] K :=\n{ to_fun := \u03bb s, (classical.some s.mem).2 \u27e8s, (classical.some_spec s.mem).2\u27e9,\n  map_zero' := alg_hom.map_zero _,\n  map_one' := alg_hom.map_one _,\n  map_add' := \u03bb s t, begin\n    obtain \u27e8w, hw, hxw, hyw, hzw\u27e9 := 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, \u2190w.2.map_add],\n    refl,\n  end,\n  map_mul' := \u03bb s t, begin\n    obtain \u27e8w, hw, hxw, hyw, hzw\u27e9 := 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, \u2190w.2.map_mul],\n    refl,\n  end,\n  commutes' := \u03bb _, 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 (\u2264) c) :\n  lifts F E K :=\n\u27e8lifts.upper_bound_intermediate_field hc, lifts.upper_bound_alg_hom hc\u27e9\n\nlemma lifts.exists_upper_bound (c : set (lifts F E K)) (hc : zorn.chain (\u2264) c) :\n  \u2203 ub, \u2200 a \u2208 c, a \u2264 ub :=\n\u27e8lifts.upper_bound hc,\nbegin\n  intros x hx,\n  split,\n  { exact \u03bb s hs, \u27e8x, set.mem_insert_of_mem \u22a5 hx, hs\u27e9 },\n  { intros s t hst,\n    change x.2 s = (classical.some t.mem).2 \u27e8t, (classical.some_spec t.mem).2\u27e9,\n    obtain \u27e8z, hz, hxz, hyz\u27e9 := lifts.exists_max_two hc (set.mem_insert_of_mem \u22a5 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\u27e9\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 (\u03bb y, x.2.commutes y)}))\n  (minpoly.dvd_map_of_is_scalar_tower _ _ _) in\n\u27e8\u2191x.1\u27ees\u27ef, (@alg_hom_equiv_sigma F x.1 (\u2191x.1\u27ees\u27ef : intermediate_field F E) K _ _ _ _ _ _ _\n  (intermediate_field.algebra x.1\u27ees\u27ef) (is_scalar_tower.of_algebra_map_eq (\u03bb _, rfl))).inv_fun\n  \u27e8x.2, (@alg_hom_adjoin_integral_equiv x.1 _ E _ _ s K _ x.2.to_ring_hom.to_algebra\n  h3).inv_fun \u27e8root_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, \u2190eval\u2082_eq_eval_map],\n  exact map_root_of_splits x.2.to_ring_hom key (ne_of_gt (minpoly.degree_pos h3)) }\u27e9\u27e9\u27e9\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 \u2264 x.lift_of_splits h1 h2 :=\n\u27e8\u03bb z hz, algebra_map_mem x.1\u27ees\u27ef \u27e8z, hz\u27e9, \u03bb t u htu, eq.symm begin\n  rw [\u2190(show algebra_map x.1 x.1\u27ees\u27ef 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\u27e9\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 \u2208 (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)) : \u2203 y, x \u2264 y \u2227 s \u2208 y.1 :=\n\u27e8x.lift_of_splits h1 h2, x.le_lifts_of_splits h1 h2, x.mem_lifts_of_splits h1 h2\u27e9\n\nlemma alg_hom_mk_adjoin_splits\n  (hK : \u2200 s \u2208 S, is_integral F (s : E) \u2227 (minpoly F s).splits (algebra_map F K)) :\n  nonempty (adjoin F S \u2192\u2090[F] K) :=\nbegin\n  obtain \u27e8x : lifts F E K, hx\u27e9 := zorn.zorn_partial_order lifts.exists_upper_bound,\n  refine \u27e8alg_hom.mk (\u03bb s, x.2 \u27e8s, adjoin_le_iff.mpr (\u03bb s hs, _) s.mem\u27e9) x.2.map_one (\u03bb s t,\n    x.2.map_mul \u27e8s, _\u27e9 \u27e8t, _\u27e9) x.2.map_zero (\u03bb s t, x.2.map_add \u27e8s, _\u27e9 \u27e8t, _\u27e9) x.2.commutes\u27e9,\n  rcases (x.exists_lift_of_splits (hK s hs).1 (hK s hs).2) with \u27e8y, h1, h2\u27e9,\n  rwa hx y h1 at h2\nend\n\nlemma alg_hom_mk_adjoin_splits' (hS : adjoin F S = \u22a4)\n  (hK : \u2200 x \u2208 S, is_integral F (x : E) \u2227 (minpoly F x).splits (algebra_map F K)) :\n  nonempty (E \u2192\u2090[F] K) :=\nbegin\n  cases alg_hom_mk_adjoin_splits hK with \u03d5,\n  rw hS at \u03d5,\n  exact \u27e8\u03d5.comp top_equiv.symm.to_alg_hom\u27e9,\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 (\u03bb (i : fin (minpoly K x).nat_degree), (adjoin_simple.gen K x ^ (i : \u2115))) :=\nbegin\n  let \u03d5 := (adjoin_root_equiv_adjoin K hx).to_linear_equiv,\n  have key : \u03d5 (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 : \u03d5 \u2218 (\u03bb (i : fin (minpoly K x).nat_degree),\n    adjoin_root.root (minpoly K x) ^ (i.val)) =\n      (\u03bb (i : fin (minpoly K x).nat_degree),\n        (adjoin_simple.gen K x) ^ \u2191i),\n  { rw \u2190 this, exact linear_equiv.is_basis\n    (adjoin_root.power_basis_is_basis (minpoly.ne_zero hx)) \u03d5 },\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\u27eex\u27ef`,\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\u27eex\u27ef :=\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       \u2190 minpoly.eq_of_algebra_map_eq (algebra_map K\u27eex\u27ef 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\u27eex\u27ef :=\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\u27eex\u27ef = (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\u27eepb.gen\u27ef` and `L` itself. -/\nnoncomputable def equiv_adjoin_simple (pb : power_basis K L) :\n  K\u27eepb.gen\u27ef \u2243\u2090[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 (\u03b1 : Sort u) (default : \u03b1) : optParam \u03b1 default = \u03b1 :=\n  rfl\n\ndef id {\u03b1 : Sort u} (a : \u03b1) : \u03b1 :=\n  a\n\ndef flip {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03c6 : Sort w} (f : \u03b1 \u2192 \u03b2 \u2192 \u03c6) : \u03b2 \u2192 \u03b1 \u2192 \u03c6 :=\n  fun (b : \u03b2) (a : \u03b1) => f a b\n\n/- implication -/\n\ndef implies (a : Prop) (b : Prop) :=\n  a \u2192 b\n\n/-- Implication `\u2192` is transitive. If `P \u2192 Q` and `Q \u2192 R` then `P \u2192 R`. -/\ntheorem implies.trans {p : Prop} {q : Prop} {r : Prop} (h\u2081 : implies p q) (h\u2082 : implies q r) : implies p r :=\n  fun (hp : p) => h\u2082 (h\u2081 hp)\n\ndef trivial : True :=\n  True.intro\n\n/-- We can't have `a` and `\u00aca`, that would be absurd!-/\ndef absurd {a : Prop} {b : Sort v} (h\u2081 : a) (h\u2082 : \u00aca) : b :=\n  False._oldrec (h\u2082 h\u2081)\n\ntheorem not.intro {a : Prop} (h : a \u2192 False) : \u00aca :=\n  h\n\n/-- Modus tollens. If an implication is true, then so is its contrapositive. -/\ntheorem mt {a : Prop} {b : Prop} (h\u2081 : a \u2192 b) (h\u2082 : \u00acb) : \u00aca :=\n  fun (ha : a) => h\u2082 (h\u2081 ha)\n\n/- not -/\n\ntheorem not_false : \u00acFalse :=\n  id\n\ndef non_contradictory (a : Prop) :=\n  \u00ac\u00aca\n\ntheorem non_contradictory_intro {a : Prop} (ha : a) : \u00ac\u00aca :=\n  fun (hna : \u00aca) => 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\u2081 : a) (h\u2082 : a) : h\u2081 = h\u2082 :=\n  rfl\n\n@[simp] theorem id.def {\u03b1 : Sort u} (a : \u03b1) : id a = a :=\n  rfl\n\ndef eq.mp {\u03b1 : Sort u} {\u03b2 : Sort u} : \u03b1 = \u03b2 \u2192 \u03b1 \u2192 \u03b2 :=\n  eq.rec_on\n\ndef eq.mpr {\u03b1 : Sort u} {\u03b2 : Sort u} : \u03b1 = \u03b2 \u2192 \u03b2 \u2192 \u03b1 :=\n  fun (h\u2081 : \u03b1 = \u03b2) (h\u2082 : \u03b2) => eq.rec_on sorry h\u2082\n\ntheorem eq.substr {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} (h\u2081 : b = a) : p a \u2192 p b :=\n  Eq.subst (Eq.symm h\u2081)\n\ntheorem congr {\u03b1 : Sort u} {\u03b2 : Sort v} {f\u2081 : \u03b1 \u2192 \u03b2} {f\u2082 : \u03b1 \u2192 \u03b2} {a\u2081 : \u03b1} {a\u2082 : \u03b1} (h\u2081 : f\u2081 = f\u2082) (h\u2082 : a\u2081 = a\u2082) : f\u2081 a\u2081 = f\u2082 a\u2082 :=\n  h\u2081 \u25b8 h\u2082 \u25b8 rfl\n\ntheorem congr_fun {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {f : (x : \u03b1) \u2192 \u03b2 x} {g : (x : \u03b1) \u2192 \u03b2 x} (h : f = g) (a : \u03b1) : f a = g a :=\n  h \u25b8 Eq.refl (f a)\n\ntheorem congr_arg {\u03b1 : Sort u} {\u03b2 : Sort v} {a\u2081 : \u03b1} {a\u2082 : \u03b1} (f : \u03b1 \u2192 \u03b2) : a\u2081 = a\u2082 \u2192 f a\u2081 = f a\u2082 :=\n  congr rfl\n\ntheorem trans_rel_left {\u03b1 : Sort u} {a : \u03b1} {b : \u03b1} {c : \u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (h\u2081 : r a b) (h\u2082 : b = c) : r a c :=\n  h\u2082 \u25b8 h\u2081\n\ntheorem trans_rel_right {\u03b1 : Sort u} {a : \u03b1} {b : \u03b1} {c : \u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (h\u2081 : a = b) (h\u2082 : r b c) : r a c :=\n  Eq.symm h\u2081 \u25b8 h\u2082\n\ntheorem of_eq_true {p : Prop} (h : p = True) : p :=\n  Eq.symm h \u25b8 trivial\n\ntheorem not_of_eq_false {p : Prop} (h : p = False) : \u00acp :=\n  fun (hp : p) => h \u25b8 hp\n\ndef cast {\u03b1 : Sort u} {\u03b2 : Sort u} (h : \u03b1 = \u03b2) (a : \u03b1) : \u03b2 :=\n  Eq._oldrec a h\n\ntheorem cast_proof_irrel {\u03b1 : Sort u} {\u03b2 : Sort u} (h\u2081 : \u03b1 = \u03b2) (h\u2082 : \u03b1 = \u03b2) (a : \u03b1) : cast h\u2081 a = cast h\u2082 a :=\n  rfl\n\ntheorem cast_eq {\u03b1 : Sort u} (h : \u03b1 = \u03b1) (a : \u03b1) : cast h a = a :=\n  rfl\n\n/- ne -/\n\ndef ne {\u03b1 : Sort u} (a : \u03b1) (b : \u03b1) :=\n  \u00aca = b\n\ninfixl:50 \" \u2260 \" => Mathlib.ne\n\n@[simp] theorem ne.def {\u03b1 : Sort u} (a : \u03b1) (b : \u03b1) : a \u2260 b = (\u00aca = b) :=\n  rfl\n\nnamespace ne\n\n\ntheorem intro {\u03b1 : Sort u} {a : \u03b1} {b : \u03b1} (h : a = b \u2192 False) : a \u2260 b :=\n  h\n\ntheorem elim {\u03b1 : Sort u} {a : \u03b1} {b : \u03b1} (h : a \u2260 b) : a = b \u2192 False :=\n  h\n\ntheorem irrefl {\u03b1 : Sort u} {a : \u03b1} (h : a \u2260 a) : False :=\n  h rfl\n\ntheorem symm {\u03b1 : Sort u} {a : \u03b1} {b : \u03b1} (h : a \u2260 b) : b \u2260 a :=\n  fun (h\u2081 : b = a) => h (Eq.symm h\u2081)\n\nend ne\n\n\ntheorem false_of_ne {\u03b1 : Sort u} {a : \u03b1} : a \u2260 a \u2192 False :=\n  ne.irrefl\n\ntheorem ne_false_of_self {p : Prop} : p \u2192 p \u2260 False :=\n  fun (hp : p) (heq : p = False) => heq \u25b8 hp\n\ntheorem ne_true_of_not {p : Prop} : \u00acp \u2192 p \u2260 True :=\n  fun (hnp : \u00acp) (heq : p = True) => Eq.subst heq hnp trivial\n\ntheorem true_ne_false : \u00acTrue = False :=\n  ne_false_of_self trivial\n\ntheorem heq.elim {\u03b1 : Sort u} {a : \u03b1} {p : \u03b1 \u2192 Sort v} {b : \u03b1} (h\u2081 : a == b) : p a \u2192 p b :=\n  eq.rec_on (eq_of_heq h\u2081)\n\ntheorem heq.subst {\u03b1 : Sort u} {\u03b2 : Sort u} {a : \u03b1} {b : \u03b2} {p : (T : Sort u) \u2192 T \u2192 Prop} : a == b \u2192 p \u03b1 a \u2192 p \u03b2 b :=\n  heq.rec_on\n\ntheorem heq.symm {\u03b1 : Sort u} {\u03b2 : Sort u} {a : \u03b1} {b : \u03b2} (h : a == b) : b == a :=\n  heq.rec_on h (HEq.refl a)\n\ntheorem heq_of_eq {\u03b1 : Sort u} {a : \u03b1} {a' : \u03b1} (h : a = a') : a == a' :=\n  h \u25b8 HEq.refl a\n\ntheorem heq.trans {\u03b1 : Sort u} {\u03b2 : Sort u} {\u03c6 : Sort u} {a : \u03b1} {b : \u03b2} {c : \u03c6} (h\u2081 : a == b) (h\u2082 : b == c) : a == c :=\n  HEq.subst h\u2082 h\u2081\n\ntheorem heq_of_heq_of_eq {\u03b1 : Sort u} {\u03b2 : Sort u} {a : \u03b1} {b : \u03b2} {b' : \u03b2} (h\u2081 : a == b) (h\u2082 : b = b') : a == b' :=\n  HEq.trans h\u2081 (heq_of_eq h\u2082)\n\ntheorem heq_of_eq_of_heq {\u03b1 : Sort u} {\u03b2 : Sort u} {a : \u03b1} {a' : \u03b1} {b : \u03b2} (h\u2081 : a = a') (h\u2082 : a' == b) : a == b :=\n  HEq.trans (heq_of_eq h\u2081) h\u2082\n\ndef type_eq_of_heq {\u03b1 : Sort u} {\u03b2 : Sort u} {a : \u03b1} {b : \u03b2} (h : a == b) : \u03b1 = \u03b2 :=\n  heq.rec_on h (Eq.refl \u03b1)\n\ntheorem eq_rec_heq {\u03b1 : Sort u} {\u03c6 : \u03b1 \u2192 Sort v} {a : \u03b1} {a' : \u03b1} (h : a = a') (p : \u03c6 a) : eq.rec_on h p == p := sorry\n\ntheorem heq_of_eq_rec_left {\u03b1 : Sort u} {\u03c6 : \u03b1 \u2192 Sort v} {a : \u03b1} {a' : \u03b1} {p\u2081 : \u03c6 a} {p\u2082 : \u03c6 a'} (e : a = a') (h\u2082 : eq.rec_on e p\u2081 = p\u2082) : p\u2081 == p\u2082 := sorry\n\ntheorem heq_of_eq_rec_right {\u03b1 : Sort u} {\u03c6 : \u03b1 \u2192 Sort v} {a : \u03b1} {a' : \u03b1} {p\u2081 : \u03c6 a} {p\u2082 : \u03c6 a'} (e : a' = a) (h\u2082 : p\u2081 = eq.rec_on e p\u2082) : p\u2081 == p\u2082 := 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 {\u03b1 : Sort u} {\u03b2 : Sort u} {\u03c6 : Sort u} (p\u2081 : \u03b2 = \u03c6) (p\u2082 : \u03b1 = \u03b2) (a : \u03b1) : eq.rec_on p\u2081 (eq.rec_on p\u2082 a) = eq.rec_on (Eq.trans p\u2082 p\u2081) a := sorry\n\ntheorem cast_heq {\u03b1 : Sort u} {\u03b2 : Sort u} (h : \u03b1 = \u03b2) (a : \u03b1) : cast h a == a := sorry\n\ninfixr:35 \" /\\ \" => Mathlib.and\n\ninfixr:35 \" \u2227 \" => Mathlib.and\n\n/- and -/\n\ntheorem and.elim {a : Prop} {b : Prop} {c : Prop} (h\u2081 : a \u2227 b) (h\u2082 : a \u2192 b \u2192 c) : c :=\n  And._oldrec h\u2082 h\u2081\n\ntheorem and.swap {a : Prop} {b : Prop} : a \u2227 b \u2192 b \u2227 a :=\n  fun (_x : a \u2227 b) =>\n    (fun (_a : a \u2227 b) => and.dcases_on _a fun (left : a) (right : b) => idRhs (b \u2227 a) { left := right, right := left }) _x\n\ndef and.symm {a : Prop} {b : Prop} : a \u2227 b \u2192 b \u2227 a :=\n  and.swap\n\ninfixr:30 \" \\/ \" => Mathlib.or\n\ninfixr:30 \" \u2228 \" => Mathlib.or\n\n/- or -/\n\nnamespace or\n\n\ntheorem elim {a : Prop} {b : Prop} {c : Prop} (h\u2081 : a \u2228 b) (h\u2082 : a \u2192 c) (h\u2083 : b \u2192 c) : c :=\n  Or._oldrec h\u2082 h\u2083 h\u2081\n\nend or\n\n\ntheorem non_contradictory_em (a : Prop) : \u00ac\u00ac(a \u2228 \u00aca) :=\n  fun (not_em : \u00ac(a \u2228 \u00aca)) =>\n    (fun (neg_a : \u00aca) => 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) : \u00ac\u00ac(a \u2228 \u00aca) :=\n  non_contradictory_em\n\ntheorem or.swap {a : Prop} {b : Prop} : a \u2228 b \u2192 b \u2228 a :=\n  Or._oldrec Or.inr Or.inl\n\ndef or.symm {a : Prop} {b : Prop} : a \u2228 b \u2192 b \u2228 a :=\n  or.swap\n\n/- xor -/\n\ndef xor (a : Prop) (b : Prop) :=\n  a \u2227 \u00acb \u2228 b \u2227 \u00aca\n\n/- iff -/\n\n/-- `iff P Q`, with notation `P \u2194 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 \" \u2194 \" => Mathlib.iff\n\ntheorem iff.elim {a : Prop} {b : Prop} {c : Prop} : ((a \u2192 b) \u2192 (b \u2192 a) \u2192 c) \u2192 (a \u2194 b) \u2192 c :=\n  Iff._oldrec\n\ntheorem iff.elim_left {a : Prop} {b : Prop} : (a \u2194 b) \u2192 a \u2192 b :=\n  iff.mp\n\ntheorem iff.elim_right {a : Prop} {b : Prop} : (a \u2194 b) \u2192 b \u2192 a :=\n  iff.mpr\n\ntheorem iff_iff_implies_and_implies (a : Prop) (b : Prop) : a \u2194 b \u2194 (a \u2192 b) \u2227 (b \u2192 a) :=\n  { mp := fun (h : a \u2194 b) => { left := iff.mp h, right := iff.mpr h },\n    mpr := fun (h : (a \u2192 b) \u2227 (b \u2192 a)) => { mp := and.left h, mpr := and.right h } }\n\ntheorem iff.refl (a : Prop) : a \u2194 a :=\n  { mp := fun (h : a) => h, mpr := fun (h : a) => h }\n\ntheorem iff.rfl {a : Prop} : a \u2194 a :=\n  iff.refl a\n\ntheorem iff.trans {a : Prop} {b : Prop} {c : Prop} (h\u2081 : a \u2194 b) (h\u2082 : b \u2194 c) : a \u2194 c :=\n  { mp := fun (ha : a) => iff.mp h\u2082 (iff.mp h\u2081 ha), mpr := fun (hc : c) => iff.mpr h\u2081 (iff.mpr h\u2082 hc) }\n\ntheorem iff.symm {a : Prop} {b : Prop} (h : a \u2194 b) : b \u2194 a :=\n  { mp := iff.elim_right h, mpr := iff.elim_left h }\n\ntheorem iff.comm {a : Prop} {b : Prop} : a \u2194 b \u2194 (b \u2194 a) :=\n  { mp := iff.symm, mpr := iff.symm }\n\ntheorem eq.to_iff {a : Prop} {b : Prop} (h : a = b) : a \u2194 b :=\n  eq.rec_on h iff.rfl\n\ntheorem neq_of_not_iff {a : Prop} {b : Prop} : \u00ac(a \u2194 b) \u2192 a \u2260 b :=\n  fun (h\u2081 : \u00ac(a \u2194 b)) (h\u2082 : a = b) => (fun (this : a \u2194 b) => absurd this h\u2081) (h\u2082 \u25b8 iff.refl a)\n\ntheorem not_iff_not_of_iff {a : Prop} {b : Prop} (h\u2081 : a \u2194 b) : \u00aca \u2194 \u00acb :=\n  { mp := fun (hna : \u00aca) (hb : b) => hna (iff.elim_right h\u2081 hb),\n    mpr := fun (hnb : \u00acb) (ha : a) => hnb (iff.elim_left h\u2081 ha) }\n\ntheorem of_iff_true {a : Prop} (h : a \u2194 True) : a :=\n  iff.mp (iff.symm h) trivial\n\ntheorem not_of_iff_false {a : Prop} : (a \u2194 False) \u2192 \u00aca :=\n  iff.mp\n\ntheorem iff_true_intro {a : Prop} (h : a) : a \u2194 True :=\n  { mp := fun (hl : a) => trivial, mpr := fun (hr : True) => h }\n\ntheorem iff_false_intro {a : Prop} (h : \u00aca) : a \u2194 False :=\n  { mp := h, mpr := False._oldrec }\n\ntheorem not_non_contradictory_iff_absurd (a : Prop) : \u00ac\u00ac\u00aca \u2194 \u00aca :=\n  { mp := fun (hl : \u00ac\u00ac\u00aca) (ha : a) => hl (non_contradictory_intro ha), mpr := absurd }\n\ndef not_not_not_iff (a : Prop) : \u00ac\u00ac\u00aca \u2194 \u00aca :=\n  not_non_contradictory_iff_absurd\n\ntheorem imp_congr {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h\u2081 : a \u2194 c) (h\u2082 : b \u2194 d) : a \u2192 b \u2194 c \u2192 d :=\n  { mp := fun (hab : a \u2192 b) (hc : c) => iff.mp h\u2082 (hab (iff.mpr h\u2081 hc)),\n    mpr := fun (hcd : c \u2192 d) (ha : a) => iff.mpr h\u2082 (hcd (iff.mp h\u2081 ha)) }\n\ntheorem imp_congr_ctx {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h\u2081 : a \u2194 c) (h\u2082 : c \u2192 (b \u2194 d)) : a \u2192 b \u2194 c \u2192 d :=\n  { mp := fun (hab : a \u2192 b) (hc : c) => (fun (ha : a) => (fun (hb : b) => iff.mp (h\u2082 hc) hb) (hab ha)) (iff.mpr h\u2081 hc),\n    mpr := fun (hcd : c \u2192 d) (ha : a) => (fun (hc : c) => (fun (hd : d) => iff.mpr (h\u2082 hc) hd) (hcd hc)) (iff.mp h\u2081 ha) }\n\ntheorem imp_congr_right {a : Prop} {b : Prop} {c : Prop} (h : a \u2192 (b \u2194 c)) : a \u2192 b \u2194 a \u2192 c :=\n  { mp := fun (hab : a \u2192 b) (ha : a) => iff.elim_left (h ha) (hab ha),\n    mpr := fun (hab : a \u2192 c) (ha : a) => iff.elim_right (h ha) (hab ha) }\n\ntheorem not_not_intro {a : Prop} (ha : a) : \u00ac\u00aca :=\n  fun (hna : \u00aca) => hna ha\n\ntheorem not_of_not_not_not {a : Prop} (h : \u00ac\u00ac\u00aca) : \u00aca :=\n  fun (ha : a) => absurd (not_not_intro ha) h\n\n@[simp] theorem not_true : \u00acTrue \u2194 False :=\n  iff_false_intro (not_not_intro trivial)\n\ndef not_true_iff : \u00acTrue \u2194 False :=\n  not_true\n\n@[simp] theorem not_false_iff : \u00acFalse \u2194 True :=\n  iff_true_intro not_false\n\ntheorem not_congr {a : Prop} {b : Prop} (h : a \u2194 b) : \u00aca \u2194 \u00acb :=\n  { mp := fun (h\u2081 : \u00aca) (h\u2082 : b) => h\u2081 (iff.mpr h h\u2082), mpr := fun (h\u2081 : \u00acb) (h\u2082 : a) => h\u2081 (iff.mp h h\u2082) }\n\n@[simp] theorem ne_self_iff_false {\u03b1 : Sort u} (a : \u03b1) : \u00aca = a \u2194 False :=\n  { mp := false_of_ne, mpr := false.elim }\n\n@[simp] theorem eq_self_iff_true {\u03b1 : Sort u} (a : \u03b1) : a = a \u2194 True :=\n  iff_true_intro rfl\n\n@[simp] theorem heq_self_iff_true {\u03b1 : Sort u} (a : \u03b1) : a == a \u2194 True :=\n  iff_true_intro (HEq.refl a)\n\n@[simp] theorem iff_not_self (a : Prop) : a \u2194 \u00aca \u2194 False :=\n  iff_false_intro fun (h : a \u2194 \u00aca) => (fun (h' : \u00aca) => h' (iff.mpr h h')) fun (ha : a) => iff.mp h ha ha\n\n@[simp] theorem not_iff_self (a : Prop) : \u00aca \u2194 a \u2194 False :=\n  iff_false_intro fun (h : \u00aca \u2194 a) => (fun (h' : \u00aca) => h' (iff.mp h h')) fun (ha : a) => iff.mpr h ha ha\n\n@[simp] theorem true_iff_false : True \u2194 False \u2194 False :=\n  iff_false_intro fun (h : True \u2194 False) => iff.mp h trivial\n\n@[simp] theorem false_iff_true : False \u2194 True \u2194 False :=\n  iff_false_intro fun (h : False \u2194 True) => iff.mpr h trivial\n\ntheorem false_of_true_iff_false : (True \u2194 False) \u2192 False :=\n  fun (h : True \u2194 False) => iff.mp h trivial\n\ntheorem false_of_true_eq_false : True = False \u2192 False :=\n  fun (h : True = False) => h \u25b8 trivial\n\ntheorem true_eq_false_of_false : False \u2192 True = False :=\n  false.elim\n\ntheorem eq_comm {\u03b1 : Sort u} {a : \u03b1} {b : \u03b1} : a = b \u2194 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 \u2192 c) (hbd : b \u2192 d) : a \u2227 b \u2192 c \u2227 d := sorry\n\ndef and_implies {a : Prop} {b : Prop} {c : Prop} {d : Prop} (hac : a \u2192 c) (hbd : b \u2192 d) : a \u2227 b \u2192 c \u2227 d :=\n  and.imp\n\ntheorem and_congr {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h\u2081 : a \u2194 c) (h\u2082 : b \u2194 d) : a \u2227 b \u2194 c \u2227 d :=\n  { mp := and.imp (iff.mp h\u2081) (iff.mp h\u2082), mpr := and.imp (iff.mpr h\u2081) (iff.mpr h\u2082) }\n\ntheorem and_congr_right {a : Prop} {b : Prop} {c : Prop} (h : a \u2192 (b \u2194 c)) : a \u2227 b \u2194 a \u2227 c := sorry\n\ntheorem and.comm {a : Prop} {b : Prop} : a \u2227 b \u2194 b \u2227 a :=\n  { mp := and.swap, mpr := and.swap }\n\ntheorem and_comm (a : Prop) (b : Prop) : a \u2227 b \u2194 b \u2227 a :=\n  and.comm\n\ntheorem and.assoc {a : Prop} {b : Prop} {c : Prop} : (a \u2227 b) \u2227 c \u2194 a \u2227 b \u2227 c := sorry\n\ntheorem and_assoc {c : Prop} (a : Prop) (b : Prop) : (a \u2227 b) \u2227 c \u2194 a \u2227 b \u2227 c :=\n  and.assoc\n\ntheorem and.left_comm {a : Prop} {b : Prop} {c : Prop} : a \u2227 b \u2227 c \u2194 b \u2227 a \u2227 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 \u2227 b \u2194 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 \u2227 b \u2194 b :=\n  { mp := and.right, mpr := And.intro ha }\n\n@[simp] theorem and_true (a : Prop) : a \u2227 True \u2194 a :=\n  and_iff_left trivial\n\n@[simp] theorem true_and (a : Prop) : True \u2227 a \u2194 a :=\n  and_iff_right trivial\n\n@[simp] theorem and_false (a : Prop) : a \u2227 False \u2194 False :=\n  iff_false_intro and.right\n\n@[simp] theorem false_and (a : Prop) : False \u2227 a \u2194 False :=\n  iff_false_intro and.left\n\n@[simp] theorem not_and_self (a : Prop) : \u00aca \u2227 a \u2194 False :=\n  iff_false_intro fun (h : \u00aca \u2227 a) => and.elim h fun (h\u2081 : \u00aca) (h\u2082 : a) => absurd h\u2082 h\u2081\n\n@[simp] theorem and_not_self (a : Prop) : a \u2227 \u00aca \u2194 False :=\n  iff_false_intro\n    fun (_x : a \u2227 \u00aca) =>\n      (fun (_a : a \u2227 \u00aca) => and.dcases_on _a fun (left : a) (right : \u00aca) => idRhs False (absurd left right)) _x\n\n@[simp] theorem and_self (a : Prop) : a \u2227 a \u2194 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\u2082 : a \u2192 c) (h\u2083 : b \u2192 d) : a \u2228 b \u2192 c \u2228 d :=\n  Or._oldrec (fun (h : a) => Or.inl (h\u2082 h)) fun (h : b) => Or.inr (h\u2083 h)\n\ntheorem or.imp_left {a : Prop} {b : Prop} {c : Prop} (h : a \u2192 b) : a \u2228 c \u2192 b \u2228 c :=\n  or.imp h id\n\ntheorem or.imp_right {a : Prop} {b : Prop} {c : Prop} (h : a \u2192 b) : c \u2228 a \u2192 c \u2228 b :=\n  or.imp id h\n\ntheorem or_congr {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h\u2081 : a \u2194 c) (h\u2082 : b \u2194 d) : a \u2228 b \u2194 c \u2228 d :=\n  { mp := or.imp (iff.mp h\u2081) (iff.mp h\u2082), mpr := or.imp (iff.mpr h\u2081) (iff.mpr h\u2082) }\n\ntheorem or.comm {a : Prop} {b : Prop} : a \u2228 b \u2194 b \u2228 a :=\n  { mp := or.swap, mpr := or.swap }\n\ntheorem or_comm (a : Prop) (b : Prop) : a \u2228 b \u2194 b \u2228 a :=\n  or.comm\n\ntheorem or.assoc {a : Prop} {b : Prop} {c : Prop} : (a \u2228 b) \u2228 c \u2194 a \u2228 b \u2228 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 \u2228 b) \u2228 c \u2194 a \u2228 b \u2228 c :=\n  or.assoc\n\ntheorem or.left_comm {a : Prop} {b : Prop} {c : Prop} : a \u2228 b \u2228 c \u2194 b \u2228 a \u2228 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 \u2192 b) : a \u2228 b \u2194 b :=\n  { mp := Or._oldrec ha id, mpr := Or.inr }\n\ntheorem or_iff_left_of_imp {a : Prop} {b : Prop} (hb : b \u2192 a) : a \u2228 b \u2194 a :=\n  { mp := Or._oldrec id hb, mpr := Or.inl }\n\n@[simp] theorem or_true (a : Prop) : a \u2228 True \u2194 True :=\n  iff_true_intro (Or.inr trivial)\n\n@[simp] theorem true_or (a : Prop) : True \u2228 a \u2194 True :=\n  iff_true_intro (Or.inl trivial)\n\n@[simp] theorem or_false (a : Prop) : a \u2228 False \u2194 a :=\n  { mp := Or._oldrec id false.elim, mpr := Or.inl }\n\n@[simp] theorem false_or (a : Prop) : False \u2228 a \u2194 a :=\n  iff.trans or.comm (or_false a)\n\n@[simp] theorem or_self (a : Prop) : a \u2228 a \u2194 a :=\n  { mp := Or._oldrec id id, mpr := Or.inl }\n\ntheorem not_or {a : Prop} {b : Prop} : \u00aca \u2192 \u00acb \u2192 \u00ac(a \u2228 b) :=\n  fun (\u1fb0 : \u00aca) (\u1fb0_1 : \u00acb) (\u1fb0_2 : a \u2228 b) =>\n    or.dcases_on \u1fb0_2 (fun (\u1fb0_1 : a) => idRhs False (absurd \u1fb0_1 \u1fb0)) fun (\u1fb0_1_1 : b) => idRhs False (absurd \u1fb0_1_1 \u1fb0_1)\n\n/- or resolution rulse -/\n\ndef or.resolve_left {a : Prop} {b : Prop} (h : a \u2228 b) (na : \u00aca) : b :=\n  or.elim h (fun (ha : a) => absurd ha na) id\n\ndef or.neg_resolve_left {a : Prop} {b : Prop} (h : \u00aca \u2228 b) (ha : a) : b :=\n  or.elim h (fun (na : \u00aca) => absurd ha na) id\n\ndef or.resolve_right {a : Prop} {b : Prop} (h : a \u2228 b) (nb : \u00acb) : a :=\n  or.elim h id fun (hb : b) => absurd hb nb\n\ndef or.neg_resolve_right {a : Prop} {b : Prop} (h : a \u2228 \u00acb) (hb : b) : a :=\n  or.elim h id fun (nb : \u00acb) => absurd hb nb\n\n/- iff simp rules -/\n\n@[simp] theorem iff_true (a : Prop) : a \u2194 True \u2194 a :=\n  { mp := fun (h : a \u2194 True) => iff.mpr h trivial, mpr := iff_true_intro }\n\n@[simp] theorem true_iff (a : Prop) : True \u2194 a \u2194 a :=\n  iff.trans iff.comm (iff_true a)\n\n@[simp] theorem iff_false (a : Prop) : a \u2194 False \u2194 \u00aca :=\n  { mp := iff.mp, mpr := iff_false_intro }\n\n@[simp] theorem false_iff (a : Prop) : False \u2194 a \u2194 \u00aca :=\n  iff.trans iff.comm (iff_false a)\n\n@[simp] theorem iff_self (a : Prop) : a \u2194 a \u2194 True :=\n  iff_true_intro iff.rfl\n\ntheorem iff_congr {a : Prop} {b : Prop} {c : Prop} {d : Prop} (h\u2081 : a \u2194 c) (h\u2082 : b \u2194 d) : a \u2194 b \u2194 (c \u2194 d) :=\n  iff.trans (iff_iff_implies_and_implies a b)\n    (iff.trans (and_congr (imp_congr h\u2081 h\u2082) (imp_congr h\u2082 h\u2081)) (iff.symm (iff_iff_implies_and_implies c d)))\n\n/- implies simp rule -/\n\n@[simp] theorem implies_true_iff (\u03b1 : Sort u) : \u03b1 \u2192 True \u2194 True :=\n  { mp := fun (h : \u03b1 \u2192 True) => trivial, mpr := fun (ha : True) (h : \u03b1) => trivial }\n\n@[simp] theorem false_implies_iff (a : Prop) : False \u2192 a \u2194 True :=\n  { mp := fun (h : False \u2192 a) => trivial, mpr := fun (ha : True) (h : False) => false.elim h }\n\n@[simp] theorem true_implies_iff (\u03b1 : Prop) : True \u2192 \u03b1 \u2194 \u03b1 :=\n  { mp := fun (h : True \u2192 \u03b1) => h trivial, mpr := fun (h : \u03b1) (h' : True) => h }\n\n/--\nThe existential quantifier.\n\nTo prove a goal of the form `\u22a2 \u2203 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 `\u22a2 p y`.\n\nTo extract a witness `x` and proof `hx : p x` from a hypothesis `h : \u2203 x, p x`,\nuse the tactic `cases h with x hx`. See also the mathlib tactics `obtain` and `rcases`.\n-/\ndef exists.intro {\u03b1 : Sort u_1} {p : \u03b1 \u2192 Prop} (w : \u03b1) (h : p w) : Exists p :=\n  Exists.intro\n\ntheorem exists.elim {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} {b : Prop} (h\u2081 : \u2203 (x : \u03b1), p x) (h\u2082 : \u2200 (a : \u03b1), p a \u2192 b) : b :=\n  Exists._oldrec h\u2082 h\u2081\n\n/- exists unique -/\n\ndef exists_unique {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) :=\n  \u2203 (x : \u03b1), p x \u2227 \u2200 (y : \u03b1), p y \u2192 y = x\n\ntheorem exists_unique.intro {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (w : \u03b1) (h\u2081 : p w) (h\u2082 : \u2200 (y : \u03b1), p y \u2192 y = w) : exists_unique fun (x : \u03b1) => p x :=\n  exists.intro w { left := h\u2081, right := h\u2082 }\n\ntheorem exists_unique.elim {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} {b : Prop} (h\u2082 : exists_unique fun (x : \u03b1) => p x) (h\u2081 : \u2200 (x : \u03b1), p x \u2192 (\u2200 (y : \u03b1), p y \u2192 y = x) \u2192 b) : b :=\n  exists.elim h\u2082 fun (w : \u03b1) (hw : (fun (x : \u03b1) => p x) w \u2227 \u2200 (y : \u03b1), p y \u2192 y = w) => h\u2081 w (and.left hw) (and.right hw)\n\ntheorem exists_unique_of_exists_of_unique {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} (hex : \u2203 (x : \u03b1), p x) (hunique : \u2200 (y\u2081 y\u2082 : \u03b1), p y\u2081 \u2192 p y\u2082 \u2192 y\u2081 = y\u2082) : exists_unique fun (x : \u03b1) => p x :=\n  exists.elim hex fun (x : \u03b1) (px : p x) => exists_unique.intro x px fun (y : \u03b1) (this : p y) => hunique y x this px\n\ntheorem exists_of_exists_unique {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (h : exists_unique fun (x : \u03b1) => p x) : \u2203 (x : \u03b1), p x :=\n  exists.elim h fun (x : \u03b1) (hx : (fun (x : \u03b1) => p x) x \u2227 \u2200 (y : \u03b1), p y \u2192 y = x) => Exists.intro x (and.left hx)\n\ntheorem unique_of_exists_unique {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (h : exists_unique fun (x : \u03b1) => p x) {y\u2081 : \u03b1} {y\u2082 : \u03b1} (py\u2081 : p y\u2081) (py\u2082 : p y\u2082) : y\u2081 = y\u2082 :=\n  exists_unique.elim h\n    fun (x : \u03b1) (this : p x) (unique : \u2200 (y : \u03b1), p y \u2192 y = x) =>\n      (fun (this : y\u2081 = y\u2082) => this) (Eq.trans (unique y\u2081 py\u2081) (Eq.symm (unique y\u2082 py\u2082)))\n\n/- exists, forall, exists unique congruences -/\n\ntheorem forall_congr {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} (h : \u2200 (a : \u03b1), p a \u2194 q a) : (\u2200 (a : \u03b1), p a) \u2194 \u2200 (a : \u03b1), q a :=\n  { mp := fun (p_1 : \u2200 (a : \u03b1), p a) (a : \u03b1) => iff.mp (h a) (p_1 a),\n    mpr := fun (q_1 : \u2200 (a : \u03b1), q a) (a : \u03b1) => iff.mpr (h a) (q_1 a) }\n\ntheorem exists_imp_exists {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} (h : \u2200 (a : \u03b1), p a \u2192 q a) : (\u2203 (a : \u03b1), p a) \u2192 \u2203 (a : \u03b1), q a :=\n  fun (p_1 : \u2203 (a : \u03b1), p a) => exists.elim p_1 fun (a : \u03b1) (hp : p a) => Exists.intro a (h a hp)\n\ntheorem exists_congr {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} (h : \u2200 (a : \u03b1), p a \u2194 q a) : Exists p \u2194 \u2203 (a : \u03b1), q a :=\n  { mp := exists_imp_exists fun (a : \u03b1) => iff.mp (h a), mpr := exists_imp_exists fun (a : \u03b1) => iff.mpr (h a) }\n\ntheorem exists_unique_congr {\u03b1 : Sort u} {p\u2081 : \u03b1 \u2192 Prop} {p\u2082 : \u03b1 \u2192 Prop} (h : \u2200 (x : \u03b1), p\u2081 x \u2194 p\u2082 x) : exists_unique p\u2081 \u2194 exists_unique fun (x : \u03b1) => p\u2082 x :=\n  exists_congr fun (x : \u03b1) => and_congr (h x) (forall_congr fun (y : \u03b1) => imp_congr (h y) iff.rfl)\n\ntheorem forall_not_of_not_exists {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} : (\u00ac\u2203 (x : \u03b1), p x) \u2192 \u2200 (x : \u03b1), \u00acp x :=\n  fun (hne : \u00ac\u2203 (x : \u03b1), p x) (x : \u03b1) (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\u2081 : \u00acp) => false) fun (h\u2082 : 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 : \u00acTrue) => 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 : \u00acFalse) => 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] {\u03b1 : Sort u} : (c \u2192 \u03b1) \u2192 (\u00acc \u2192 \u03b1) \u2192 \u03b1 :=\n  fun (t : c \u2192 \u03b1) (e : \u00acc \u2192 \u03b1) => decidable.rec_on h e t\n\n/- if-then-else -/\n\ndef ite (c : Prop) [h : Decidable c] {\u03b1 : Sort u} (t : \u03b1) (e : \u03b1) : \u03b1 :=\n  decidable.rec_on h (fun (hnc : \u00acc) => e) fun (hc : c) => t\n\nnamespace decidable\n\n\ndef rec_on_true {p : Prop} [h : Decidable p] {h\u2081 : p \u2192 Sort u} {h\u2082 : \u00acp \u2192 Sort u} (h\u2083 : p) (h\u2084 : h\u2081 h\u2083) : decidable.rec_on h h\u2082 h\u2081 :=\n  decidable.rec_on h (fun (h : \u00acp) => False._oldrec (h h\u2083)) fun (h : p) => h\u2084\n\ndef rec_on_false {p : Prop} [h : Decidable p] {h\u2081 : p \u2192 Sort u} {h\u2082 : \u00acp \u2192 Sort u} (h\u2083 : \u00acp) (h\u2084 : h\u2082 h\u2083) : decidable.rec_on h h\u2082 h\u2081 :=\n  decidable.rec_on h (fun (h : \u00acp) => h\u2084) fun (h : p) => False._oldrec (h\u2083 h)\n\ndef by_cases {p : Prop} {q : Sort u} [\u03c6 : Decidable p] : (p \u2192 q) \u2192 (\u00acp \u2192 q) \u2192 q :=\n  dite p\n\ntheorem em (p : Prop) [Decidable p] : p \u2228 \u00acp :=\n  by_cases Or.inl Or.inr\n\ntheorem by_contradiction {p : Prop} [Decidable p] (h : \u00acp \u2192 False) : p :=\n  dite p (fun (h\u2081 : p) => h\u2081) fun (h\u2081 : \u00acp) => False._oldrec (h h\u2081)\n\ntheorem of_not_not {p : Prop} [Decidable p] : \u00ac\u00acp \u2192 p :=\n  fun (hnn : \u00ac\u00acp) => by_contradiction fun (hn : \u00acp) => absurd hn hnn\n\ntheorem not_not_iff (p : Prop) [Decidable p] : \u00ac\u00acp \u2194 p :=\n  { mp := of_not_not, mpr := not_not_intro }\n\ntheorem not_and_iff_or_not (p : Prop) (q : Prop) [d\u2081 : Decidable p] [d\u2082 : Decidable q] : \u00ac(p \u2227 q) \u2194 \u00acp \u2228 \u00acq := sorry\n\ntheorem not_or_iff_and_not (p : Prop) (q : Prop) [d\u2081 : Decidable p] [d\u2082 : Decidable q] : \u00ac(p \u2228 q) \u2194 \u00acp \u2227 \u00acq := sorry\n\nend decidable\n\n\ndef decidable_of_decidable_of_iff {p : Prop} {q : Prop} (hp : Decidable p) (h : p \u2194 q) : Decidable q :=\n  dite p (fun (hp : p) => is_true (iff.mp h hp)) fun (hp : \u00acp) => 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] {\u03b1 : Sort u} (h : p \u2228 q) (h\u2081 : p \u2192 \u03b1) (h\u2082 : q \u2192 \u03b1) : \u03b1 :=\n  dite p (fun (hp : p) => h\u2081 hp)\n    fun (hp : \u00acp) => dite q (fun (hq : q) => h\u2082 hq) fun (hq : \u00acq) => False._oldrec (or.elim h hp hq)\n\nprotected instance and.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (p \u2227 q) :=\n  dite p (fun (hp : p) => dite q (fun (hq : q) => is_true { left := hp, right := hq }) fun (hq : \u00acq) => is_false sorry)\n    fun (hp : \u00acp) => is_false sorry\n\nprotected instance or.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (p \u2228 q) :=\n  dite p (fun (hp : p) => is_true (Or.inl hp))\n    fun (hp : \u00acp) => dite q (fun (hq : q) => is_true (Or.inr hq)) fun (hq : \u00acq) => is_false (Or._oldrec hp hq)\n\nprotected instance not.decidable {p : Prop} [Decidable p] : Decidable (\u00acp) :=\n  dite p (fun (hp : p) => is_false (absurd hp)) fun (hp : \u00acp) => is_true hp\n\nprotected instance implies.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (p \u2192 q) :=\n  dite p (fun (hp : p) => dite q (fun (hq : q) => is_true sorry) fun (hq : \u00acq) => is_false sorry)\n    fun (hp : \u00acp) => is_true sorry\n\nprotected instance iff.decidable {p : Prop} {q : Prop} [Decidable p] [Decidable q] : Decidable (p \u2194 q) :=\n  dite p (fun (hp : p) => dite q (fun (hq : q) => is_true sorry) fun (hq : \u00acq) => is_false sorry)\n    fun (hp : \u00acp) => dite q (fun (hq : q) => is_false sorry) fun (hq : \u00acq) => 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 : \u00acq) => is_true sorry)\n    fun (hp : \u00acp) => dite q (fun (hq : q) => is_true sorry) fun (hq : \u00acq) => is_false sorry\n\nprotected instance exists_prop_decidable {p : Prop} (P : p \u2192 Prop) [Dp : Decidable p] [DP : (h : p) \u2192 Decidable (P h)] : Decidable (\u2203 (h : p), P h) :=\n  dite p (fun (h : p) => decidable_of_decidable_of_iff (DP h) sorry) fun (h : \u00acp) => is_false sorry\n\nprotected instance forall_prop_decidable {p : Prop} (P : p \u2192 Prop) [Dp : Decidable p] [DP : (h : p) \u2192 Decidable (P h)] : Decidable (\u2200 (h : p), P h) :=\n  dite p (fun (h : p) => decidable_of_decidable_of_iff (DP h) sorry) fun (h : \u00acp) => is_true sorry\n\nprotected instance ne.decidable {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) : Decidable (a \u2260 b) :=\n  implies.decidable\n\ntheorem bool.ff_ne_tt : false = tt \u2192 False :=\n  fun (\u1fb0 : false = tt) => eq.dcases_on \u1fb0 (fun (H_1 : tt = false) => bool.no_confusion H_1) (Eq.refl tt) (HEq.refl \u1fb0)\n\ndef is_dec_eq {\u03b1 : Sort u} (p : \u03b1 \u2192 \u03b1 \u2192 Bool) :=\n  \u2200 {x y : \u03b1}, p x y = tt \u2192 x = y\n\ndef is_dec_refl {\u03b1 : Sort u} (p : \u03b1 \u2192 \u03b1 \u2192 Bool) :=\n  \u2200 (x : \u03b1), p x x = tt\n\nprotected instance bool.decidable_eq : DecidableEq Bool :=\n  sorry\n\ndef decidable_eq_of_bool_pred {\u03b1 : Sort u} {p : \u03b1 \u2192 \u03b1 \u2192 Bool} (h\u2081 : is_dec_eq p) (h\u2082 : is_dec_refl p) : DecidableEq \u03b1 :=\n  fun (x y : \u03b1) => dite (p x y = tt) (fun (hp : p x y = tt) => is_true (h\u2081 hp)) fun (hp : \u00acp x y = tt) => is_false sorry\n\ntheorem decidable_eq_inl_refl {\u03b1 : Sort u} [h : DecidableEq \u03b1] (a : \u03b1) : h a a = is_true (Eq.refl a) := sorry\n\ntheorem decidable_eq_inr_neg {\u03b1 : Sort u} [h : DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} (n : a \u2260 b) : h a b = is_false n := sorry\n\n/- inhabited -/\n\ndef arbitrary (\u03b1 : Sort u) [Inhabited \u03b1] : \u03b1 :=\n  Inhabited.default\n\nprotected instance prop.inhabited : Inhabited Prop :=\n  { default := True }\n\nprotected instance pi.inhabited (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(x : \u03b1) \u2192 Inhabited (\u03b2 x)] : Inhabited ((x : \u03b1) \u2192 \u03b2 x) :=\n  { default := fun (a : \u03b1) => 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 {\u03b1 : Sort u} {p : Prop} (h\u2081 : Nonempty \u03b1) (h\u2082 : \u03b1 \u2192 p) : p :=\n  Nonempty._oldrec h\u2082 h\u2081\n\nprotected instance nonempty_of_inhabited {\u03b1 : Sort u} [Inhabited \u03b1] : Nonempty \u03b1 :=\n  Nonempty.intro Inhabited.default\n\ntheorem nonempty_of_exists {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} : (\u2203 (x : \u03b1), p x) \u2192 Nonempty \u03b1 :=\n  fun (\u1fb0 : \u2203 (x : \u03b1), p x) => Exists.dcases_on \u1fb0 fun (\u1fb0_w : \u03b1) (\u1fb0_h : p \u1fb0_w) => idRhs (Nonempty \u03b1) (Nonempty.intro \u1fb0_w)\n\n/- subsingleton -/\n\nclass inductive subsingleton (\u03b1 : Sort u) \nwhere\n| intro : (\u2200 (a b : \u03b1), a = b) \u2192 subsingleton \u03b1\n\nprotected def subsingleton.elim {\u03b1 : Sort u} [h : subsingleton \u03b1] (a : \u03b1) (b : \u03b1) : a = b :=\n  subsingleton._oldrec (fun (p : \u2200 (a b : \u03b1), a = b) => p) h\n\nprotected def subsingleton.helim {\u03b1 : Sort u} {\u03b2 : Sort u} [h : subsingleton \u03b1] : \u03b1 = \u03b2 \u2192 \u2200 (a : \u03b1) (b : \u03b2), a == b :=\n  fun (h_1 : \u03b1 = \u03b2) => eq.rec_on h_1 fun (a b : \u03b1) => 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\u2081 : Decidable p) => sorry\n\nprotected theorem rec_subsingleton {p : Prop} [h : Decidable p] {h\u2081 : p \u2192 Sort u} {h\u2082 : \u00acp \u2192 Sort u} [h\u2083 : \u2200 (h : p), subsingleton (h\u2081 h)] [h\u2084 : \u2200 (h : \u00acp), subsingleton (h\u2082 h)] : subsingleton (decidable.rec_on h h\u2082 h\u2081) := sorry\n\ntheorem if_pos {c : Prop} [h : Decidable c] (hc : c) {\u03b1 : Sort u} {t : \u03b1} {e : \u03b1} : ite c t e = t := sorry\n\ntheorem if_neg {c : Prop} [h : Decidable c] (hnc : \u00acc) {\u03b1 : Sort u} {t : \u03b1} {e : \u03b1} : ite c t e = e := sorry\n\n@[simp] theorem if_t_t (c : Prop) [h : Decidable c] {\u03b1 : Sort u} (t : \u03b1) : 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 \u2192 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) : \u00acc \u2192 e :=\n  fun (hnc : \u00acc) => eq.rec_on (if_neg hnc) h\n\ntheorem if_ctx_congr {\u03b1 : Sort u} {b : Prop} {c : Prop} [dec_b : Decidable b] [dec_c : Decidable c] {x : \u03b1} {y : \u03b1} {u : \u03b1} {v : \u03b1} (h_c : b \u2194 c) (h_t : c \u2192 x = u) (h_e : \u00acc \u2192 y = v) : ite b x y = ite c u v := sorry\n\ntheorem if_congr {\u03b1 : Sort u} {b : Prop} {c : Prop} [dec_b : Decidable b] [dec_c : Decidable c] {x : \u03b1} {y : \u03b1} {u : \u03b1} {v : \u03b1} (h_c : b \u2194 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 : \u00acc) => h_e\n\n@[simp] theorem if_true {\u03b1 : Sort u} {h : Decidable True} (t : \u03b1) (e : \u03b1) : ite True t e = t :=\n  if_pos trivial\n\n@[simp] theorem if_false {\u03b1 : Sort u} {h : Decidable False} (t : \u03b1) (e : \u03b1) : 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 \u2194 c) (h_t : c \u2192 (x \u2194 u)) (h_e : \u00acc \u2192 (y \u2194 v)) : ite b x y \u2194 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 \u2194 c) (h_t : x \u2194 u) (h_e : y \u2194 v) : ite b x y \u2194 ite c u v :=\n  if_ctx_congr_prop h_c (fun (h : c) => h_t) fun (h : \u00acc) => 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 \u2194 c) (h_t : c \u2192 (x \u2194 u)) (h_e : \u00acc \u2192 (y \u2194 v)) : ite b x y \u2194 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 \u2194 c) (h_t : x \u2194 u) (h_e : y \u2194 v) : ite b x y \u2194 ite c u v :=\n  if_ctx_simp_congr_prop h_c (fun (h : c) => h_t) fun (h : \u00acc) => h_e\n\n@[simp] theorem dif_pos {c : Prop} [h : Decidable c] (hc : c) {\u03b1 : Sort u} {t : c \u2192 \u03b1} {e : \u00acc \u2192 \u03b1} : dite c t e = t hc := sorry\n\n@[simp] theorem dif_neg {c : Prop} [h : Decidable c] (hnc : \u00acc) {\u03b1 : Sort u} {t : c \u2192 \u03b1} {e : \u00acc \u2192 \u03b1} : dite c t e = e hnc := sorry\n\ntheorem dif_ctx_congr {\u03b1 : Sort u} {b : Prop} {c : Prop} [dec_b : Decidable b] [dec_c : Decidable c] {x : b \u2192 \u03b1} {u : c \u2192 \u03b1} {y : \u00acb \u2192 \u03b1} {v : \u00acc \u2192 \u03b1} (h_c : b \u2194 c) (h_t : \u2200 (h : c), x (iff.mpr h_c h) = u h) (h_e : \u2200 (h : \u00acc), 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 {\u03b1 : Sort u} {b : Prop} {c : Prop} [dec_b : Decidable b] {x : b \u2192 \u03b1} {u : c \u2192 \u03b1} {y : \u00acb \u2192 \u03b1} {v : \u00acc \u2192 \u03b1} (h_c : b \u2194 c) (h_t : \u2200 (h : c), x (iff.mpr h_c h) = u h) (h_e : \u2200 (h : \u00acc), 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] {\u03b1 : Sort u} (t : \u03b1) (e : \u03b1) : (dite c (fun (h : c) => t) fun (h : \u00acc) => 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 \u2192 Prop} {e : \u00acc \u2192 Prop} [d_c : Decidable c] [d_t : (h : c) \u2192 Decidable (t h)] [d_e : (h : \u00acc) \u2192 Decidable (e h)] : Decidable (dite c (fun (h : c) => t h) fun (h : \u00acc) => 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\u2081 : Decidable c] (h\u2082 : as_true c) : c :=\n  sorry\n\n/-- Universe lifting operation -/\nstructure ulift (\u03b1 : Type s) \n  up ::\nwhere (down : \u03b1)\n\nnamespace ulift\n\n\n/- Bijection between \u03b1 and ulift.{v} \u03b1 -/\n\ntheorem up_down {\u03b1 : Type u} (b : ulift \u03b1) : up (down b) = b :=\n  cases_on b fun (b : \u03b1) => idRhs (up (down (up b)) = up (down (up b))) rfl\n\nend ulift\n\n\ntheorem ulift.down_up {\u03b1 : Type u} (a : \u03b1) : ulift.down (ulift.up a) = a :=\n  rfl\n\n/-- Universe lifting operation from Sort to Type -/\nstructure plift (\u03b1 : Sort u) \n  up ::\nwhere (down : \u03b1)\n\nnamespace plift\n\n\n/- Bijection between \u03b1 and plift \u03b1 -/\n\ntheorem up_down {\u03b1 : Sort u} (b : plift \u03b1) : up (down b) = b :=\n  cases_on b fun (b : \u03b1) => idRhs (up (down (up b)) = up (down (up b))) rfl\n\nend plift\n\n\ntheorem plift.down_up {\u03b1 : Sort u} (a : \u03b1) : plift.down (plift.up a) = a :=\n  rfl\n\n/- Equalities for rewriting let-expressions -/\n\ntheorem let_value_eq {\u03b1 : Sort u} {\u03b2 : Sort v} {a\u2081 : \u03b1} {a\u2082 : \u03b1} (b : \u03b1 \u2192 \u03b2) : a\u2081 = a\u2082 \u2192\n  (let x : \u03b1 := a\u2081;\n    b x) =\n    let x : \u03b1 := a\u2082;\n    b x :=\n  fun (h : a\u2081 = a\u2082) => eq.rec_on h rfl\n\ntheorem let_value_heq {\u03b1 : Sort v} {\u03b2 : \u03b1 \u2192 Sort u} {a\u2081 : \u03b1} {a\u2082 : \u03b1} (b : (x : \u03b1) \u2192 \u03b2 x) : a\u2081 = a\u2082 \u2192\n  (let x : \u03b1 := a\u2081;\n    b x) ==\n    let x : \u03b1 := a\u2082;\n    b x :=\n  fun (h : a\u2081 = a\u2082) => eq.rec_on h (HEq.refl (b a\u2081))\n\ntheorem let_body_eq {\u03b1 : Sort v} {\u03b2 : \u03b1 \u2192 Sort u} (a : \u03b1) {b\u2081 : (x : \u03b1) \u2192 \u03b2 x} {b\u2082 : (x : \u03b1) \u2192 \u03b2 x} : (\u2200 (x : \u03b1), b\u2081 x = b\u2082 x) \u2192\n  (let x : \u03b1 := a;\n    b\u2081 x) =\n    let x : \u03b1 := a;\n    b\u2082 x :=\n  fun (h : \u2200 (x : \u03b1), b\u2081 x = b\u2082 x) => h a\n\ntheorem let_eq {\u03b1 : Sort v} {\u03b2 : Sort u} {a\u2081 : \u03b1} {a\u2082 : \u03b1} {b\u2081 : \u03b1 \u2192 \u03b2} {b\u2082 : \u03b1 \u2192 \u03b2} : a\u2081 = a\u2082 \u2192\n  (\u2200 (x : \u03b1), b\u2081 x = b\u2082 x) \u2192\n    (let x : \u03b1 := a\u2081;\n      b\u2081 x) =\n      let x : \u03b1 := a\u2082;\n      b\u2082 x :=\n  fun (h\u2081 : a\u2081 = a\u2082) (h\u2082 : \u2200 (x : \u03b1), b\u2081 x = b\u2082 x) => eq.rec_on h\u2081 (h\u2082 a\u2081)\n\ndef reflexive {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 (x : \u03b2), r x x\n\ndef symmetric {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 {x y : \u03b2}, r x y \u2192 r y x\n\ndef transitive {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 {x y z : \u03b2}, r x y \u2192 r y z \u2192 r x z\n\ndef equivalence {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n  reflexive r \u2227 symmetric r \u2227 transitive r\n\ndef total {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 (x y : \u03b2), r x y \u2228 r y x\n\ndef mk_equivalence {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) (rfl : reflexive r) (symm : symmetric r) (trans : transitive r) : equivalence r :=\n  { left := rfl, right := { left := symm, right := trans } }\n\ndef irreflexive {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 (x : \u03b2), \u00acr x x\n\ndef anti_symmetric {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 {x y : \u03b2}, r x y \u2192 r y x \u2192 x = y\n\ndef empty_relation {\u03b1 : Sort u} (a\u2081 : \u03b1) (a\u2082 : \u03b1) :=\n  False\n\ndef subrelation {\u03b2 : Sort v} (q : \u03b2 \u2192 \u03b2 \u2192 Prop) (r : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 {x y : \u03b2}, q x y \u2192 r x y\n\ndef inv_image {\u03b1 : Sort u} {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b1 \u2192 Prop :=\n  fun (a\u2081 a\u2082 : \u03b1) => r (f a\u2081) (f a\u2082)\n\ntheorem inv_image.trans {\u03b1 : Sort u} {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) (h : transitive r) : transitive (inv_image r f) :=\n  fun (a\u2081 a\u2082 a\u2083 : \u03b1) (h\u2081 : inv_image r f a\u2081 a\u2082) (h\u2082 : inv_image r f a\u2082 a\u2083) => h h\u2081 h\u2082\n\ntheorem inv_image.irreflexive {\u03b1 : Sort u} {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) (h : irreflexive r) : irreflexive (inv_image r f) :=\n  fun (a : \u03b1) (h\u2081 : inv_image r f a a) => h (f a) h\u2081\n\ninductive tc {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : \u03b1 \u2192 \u03b1 \u2192 Prop\nwhere\n| base : \u2200 (a b : \u03b1), r a b \u2192 tc r a b\n| trans : \u2200 (a b c : \u03b1), tc r a b \u2192 tc r b c \u2192 tc r a c\n\ndef commutative {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) :=\n  \u2200 (a b : \u03b1), f a b = f b a\n\ndef associative {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) :=\n  \u2200 (a b c : \u03b1), f (f a b) c = f a (f b c)\n\ndef left_identity {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (one : \u03b1) :=\n  \u2200 (a : \u03b1), f one a = a\n\ndef right_identity {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (one : \u03b1) :=\n  \u2200 (a : \u03b1), f a one = a\n\ndef right_inverse {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (inv : \u03b1 \u2192 \u03b1) (one : \u03b1) :=\n  \u2200 (a : \u03b1), f a (inv a) = one\n\ndef left_cancelative {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) :=\n  \u2200 (a b c : \u03b1), f a b = f a c \u2192 b = c\n\ndef right_cancelative {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) :=\n  \u2200 (a b c : \u03b1), f a b = f c b \u2192 a = c\n\ndef left_distributive {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (g : \u03b1 \u2192 \u03b1 \u2192 \u03b1) :=\n  \u2200 (a b c : \u03b1), f a (g b c) = g (f a b) (f a c)\n\ndef right_distributive {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (g : \u03b1 \u2192 \u03b1 \u2192 \u03b1) :=\n  \u2200 (a b c : \u03b1), f (g a b) c = g (f a c) (f b c)\n\ndef right_commutative {\u03b1 : Type u} {\u03b2 : Type v} (h : \u03b2 \u2192 \u03b1 \u2192 \u03b2) :=\n  \u2200 (b : \u03b2) (a\u2081 a\u2082 : \u03b1), h (h b a\u2081) a\u2082 = h (h b a\u2082) a\u2081\n\ndef left_commutative {\u03b1 : Type u} {\u03b2 : Type v} (h : \u03b1 \u2192 \u03b2 \u2192 \u03b2) :=\n  \u2200 (a\u2081 a\u2082 : \u03b1) (b : \u03b2), h a\u2081 (h a\u2082 b) = h a\u2082 (h a\u2081 b)\n\ntheorem left_comm {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) : commutative f \u2192 associative f \u2192 left_commutative f :=\n  fun (hcomm : commutative f) (hassoc : associative f) (a b c : \u03b1) =>\n    Eq.trans (Eq.trans (Eq.symm (hassoc a b c)) (hcomm a b \u25b8 rfl)) (hassoc b a c)\n\ntheorem right_comm {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) : commutative f \u2192 associative f \u2192 right_commutative f :=\n  fun (hcomm : commutative f) (hassoc : associative f) (a b c : \u03b1) =>\n    Eq.trans (Eq.trans (hassoc a b c) (hcomm b c \u25b8 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u2115` and `\u2124`, 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 {\u03b1 : Type _}\n\n#print NormalizationMonoid /-\n/-- Normalization monoid: multiplying with `norm_unit` gives a normal form for associated\nelements. -/\n@[protect_proj]\nclass NormalizationMonoid (\u03b1 : Type _) [CancelCommMonoidWithZero \u03b1] where\n  normUnit : \u03b1 \u2192 \u03b1\u02e3\n  normUnit_zero : norm_unit 0 = 1\n  normUnit_mul : \u2200 {a b}, a \u2260 0 \u2192 b \u2260 0 \u2192 norm_unit (a * b) = norm_unit a * norm_unit b\n  normUnit_coe_units : \u2200 u : \u03b1\u02e3, norm_unit u = u\u207b\u00b9\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 \u03b1] [NormalizationMonoid \u03b1]\n\n/- warning: norm_unit_one -> normUnit_one is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (OfNat.mk.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (One.one.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulOneClass.toHasOne.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Units.mulOneClass.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (One.toOfNat1.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (InvOneClass.toOne.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivInvOneMonoid.toInvOneClass.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivisionCommMonoid.toDivisionMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommGroup.toDivisionCommMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Units.instCommGroupUnitsToMonoid.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align norm_unit_one normUnit_one\u2093'. -/\n@[simp]\ntheorem normUnit_one : normUnit (1 : \u03b1) = 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 : \u03b1 \u2192*\u2080 \u03b1 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)\nCase conversion may be inaccurate. Consider using '#align associated_normalize associated_normalize\u2093'. -/\ntheorem associated_normalize (x : \u03b1) : Associated x (normalize x) :=\n  \u27e8_, rfl\u27e9\n#align associated_normalize associated_normalize\n\n/- warning: normalize_associated -> normalize_associated is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) x\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Associated.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) x\nCase conversion may be inaccurate. Consider using '#align normalize_associated normalize_associated\u2093'. -/\ntheorem normalize_associated (x : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1} {y : \u03b1}, Iff (Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) y)) (Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x y)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1} {y : \u03b1}, Iff (Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) y)) (Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x y)\nCase conversion may be inaccurate. Consider using '#align associated_normalize_iff associated_normalize_iff\u2093'. -/\ntheorem associated_normalize_iff {x y : \u03b1} : Associated x (normalize y) \u2194 Associated x y :=\n  \u27e8fun h => h.trans (normalize_associated y), fun h => h.trans (associated_normalize y)\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1} {y : \u03b1}, Iff (Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) y) (Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x y)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1} {y : \u03b1}, Iff (Associated.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) y) (Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x y)\nCase conversion may be inaccurate. Consider using '#align normalize_associated_iff normalize_associated_iff\u2093'. -/\ntheorem normalize_associated_iff {x y : \u03b1} : Associated (normalize x) y \u2194 Associated x y :=\n  \u27e8fun h => (associated_normalize _).trans h, fun h => (normalize_associated _).trans h\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Eq.{succ u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)) (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Eq.{succ u1} (Associates.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1)))) (Associates.mk.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)) (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x)\nCase conversion may be inaccurate. Consider using '#align associates.mk_normalize Associates.mk_normalize\u2093'. -/\ntheorem Associates.mk_normalize (x : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (coeBase.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (Units.hasCoe.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 _inst_2 x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) x (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 _inst_2 x)))\nCase conversion may be inaccurate. Consider using '#align normalize_apply normalize_apply\u2093'. -/\n@[simp]\ntheorem normalize_apply (x : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (CommMonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) _inst_1))))\nCase conversion may be inaccurate. Consider using '#align normalize_zero normalize_zero\u2093'. -/\n@[simp]\ntheorem normalize_zero : normalize (0 : \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (Monoid.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align normalize_one normalize_one\u2093'. -/\n@[simp]\ntheorem normalize_one : normalize (1 : \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (u : Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (coeBase.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (Units.hasCoe.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) u)) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (u : Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) (Monoid.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align normalize_coe_units normalize_coe_units\u2093'. -/\ntheorem normalize_coe_units (u : \u03b1\u02e3) : normalize (u : \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1}, Iff (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (Eq.{succ u1} \u03b1 x (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))))) (Eq.{succ u1} \u03b1 x (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align normalize_eq_zero normalize_eq_zero\u2093'. -/\ntheorem normalize_eq_zero {x : \u03b1} : normalize x = 0 \u2194 x = 0 :=\n  \u27e8fun hx => (associated_zero_iff_eq_zero x).1 <| hx \u25b8 associated_normalize _, by\n    rintro rfl <;> exact normalize_zero\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1}, Iff (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (Monoid.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))))))) (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) x)\nCase conversion may be inaccurate. Consider using '#align normalize_eq_one normalize_eq_one\u2093'. -/\ntheorem normalize_eq_one {x : \u03b1} : normalize x = 1 \u2194 IsUnit x :=\n  \u27e8fun hx => isUnit_iff_exists_inv.2 \u27e8_, hx\u27e9, fun \u27e8u, hu\u27e9 => hu \u25b8 normalize_coe_units u\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (coeBase.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (Units.hasCoe.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 _inst_2 a)))) (OfNat.ofNat.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (OfNat.mk.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (One.one.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulOneClass.toHasOne.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Units.mulOneClass.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 _inst_2 a)))) (OfNat.ofNat.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (One.toOfNat1.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (InvOneClass.toOne.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivInvOneMonoid.toInvOneClass.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivisionCommMonoid.toDivisionMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommGroup.toDivisionCommMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Units.instCommGroupUnitsToMonoid.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align norm_unit_mul_norm_unit normUnit_mul_normUnit\u2093'. -/\n@[simp]\ntheorem normUnit_mul_normUnit (a : \u03b1) : normUnit (a * normUnit a) = 1 :=\n  by\n  nontriviality \u03b1 using Subsingleton.elim a 0\n  obtain rfl | h := eq_or_ne a 0\n  \u00b7 rw [norm_unit_zero, MulZeroClass.zero_mul, norm_unit_zero]\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (fun (_x : (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))))) (MulOneClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1)))) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1))))))) (normalize.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) _inst_1 _inst_2) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x)\nCase conversion may be inaccurate. Consider using '#align normalize_idem normalize_idem\u2093'. -/\ntheorem normalize_idem (x : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a) -> (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) b))\nCase conversion may be inaccurate. Consider using '#align normalize_eq_normalize normalize_eq_normalize\u2093'. -/\ntheorem normalize_eq_normalize {a b : \u03b1} (hab : a \u2223 b) (hba : b \u2223 a) : normalize a = normalize b :=\n  by\n  nontriviality \u03b1\n  rcases associated_of_dvd_dvd hab hba with \u27e8u, rfl\u27e9\n  refine' by_cases (by rintro rfl <;> simp only [MulZeroClass.zero_mul]) fun ha : a \u2260 0 => _\n  suffices a * \u2191(norm_unit a) = a * \u2191u * \u2191(norm_unit a) * \u2191u\u207b\u00b9 by\n    simpa only [normalize_apply, mul_assoc, norm_unit_mul ha u.ne_zero, norm_unit_coe_units]\n  calc\n    a * \u2191(norm_unit a) = a * \u2191(norm_unit a) * \u2191u * \u2191u\u207b\u00b9 := (Units.mul_inv_cancel_right _ _).symm\n    _ = a * \u2191u * \u2191(norm_unit a) * \u2191u\u207b\u00b9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1} {y : \u03b1}, Iff (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) y)) (And (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) x y) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) y x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {x : \u03b1} {y : \u03b1}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) y)) (And (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) x y) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) y x))\nCase conversion may be inaccurate. Consider using '#align normalize_eq_normalize_iff normalize_eq_normalize_iff\u2093'. -/\ntheorem normalize_eq_normalize_iff {x y : \u03b1} : normalize x = normalize y \u2194 x \u2223 y \u2227 y \u2223 x :=\n  \u27e8fun h => \u27e8Units.dvd_mul_right.1 \u27e8_, h.symm\u27e9, Units.dvd_mul_right.1 \u27e8_, h\u27e9\u27e9, fun \u27e8hxy, hyx\u27e9 =>\n    normalize_eq_normalize hxy hyx\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1}, (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) a) a) -> (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) b) b) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a) -> (Eq.{succ u1} \u03b1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1}, (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) a) a) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) b) b) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a) -> (Eq.{succ u1} \u03b1 a b)\nCase conversion may be inaccurate. Consider using '#align dvd_antisymm_of_normalize_eq dvd_antisymm_of_normalize_eq\u2093'. -/\ntheorem dvd_antisymm_of_normalize_eq {a b : \u03b1} (ha : normalize a = a) (hb : normalize b = b)\n    (hab : a \u2223 b) (hba : b \u2223 a) : a = b :=\n  ha \u25b8 hb \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1}, Iff (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) b)) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1}, Iff (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) b)) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b)\nCase conversion may be inaccurate. Consider using '#align dvd_normalize_iff dvd_normalize_iff\u2093'. -/\n--can be proven by simp\ntheorem dvd_normalize_iff {a b : \u03b1} : a \u2223 normalize b \u2194 a \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1}, Iff (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) a) b) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1}, Iff (Dvd.dvd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (semigroupDvd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (SemigroupWithZero.toSemigroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (MonoidWithZero.toSemigroupWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) a) b) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b)\nCase conversion may be inaccurate. Consider using '#align normalize_dvd_iff normalize_dvd_iff\u2093'. -/\n--can be proven by simp\ntheorem normalize_dvd_iff {a b : \u03b1} : normalize a \u2223 b \u2194 a \u2223 b :=\n  Units.mul_right_dvd\n#align normalize_dvd_iff normalize_dvd_iff\n\nend NormalizationMonoid\n\nnamespace Associates\n\nvariable [CancelCommMonoidWithZero \u03b1] [NormalizationMonoid \u03b1]\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 \u03b1 \u2192 \u03b1 :=\n  Quotient.lift (normalize : \u03b1 \u2192 \u03b1) fun a b \u27e8u, hu\u27e9 =>\n    hu \u25b8 normalize_eq_normalize \u27e8_, rfl\u27e9 (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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (Associates.out.{u1} \u03b1 _inst_1 _inst_2 (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) a)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (Associates.out.{u1} \u03b1 _inst_1 _inst_2 (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) a)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) a)\nCase conversion may be inaccurate. Consider using '#align associates.out_mk Associates.out_mk\u2093'. -/\n@[simp]\ntheorem out_mk (a : \u03b1) : (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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} \u03b1 (Associates.out.{u1} \u03b1 _inst_1 _inst_2 (OfNat.ofNat.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (OfNat.mk.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (One.one.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.hasOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} \u03b1 (Associates.out.{u1} \u03b1 _inst_1 _inst_2 (OfNat.ofNat.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (One.toOfNat1.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instOneAssociates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align associates.out_one Associates.out_one\u2093'. -/\n@[simp]\ntheorem out_one : (1 : Associates \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (b : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Eq.{succ u1} \u03b1 (Associates.out.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (instHMul.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.hasMul.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) a b)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 a) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (b : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Eq.{succ u1} \u03b1 (Associates.out.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (instHMul.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instMulAssociatesToMonoid.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) a b)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 a) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 b))\nCase conversion may be inaccurate. Consider using '#align associates.out_mul Associates.out_mul\u2093'. -/\ntheorem out_mul (a b : Associates \u03b1) : (a * b).out = a.out * b.out :=\n  Quotient.induction_on\u2082 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Iff (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (Associates.out.{u1} \u03b1 _inst_1 _inst_2 b)) (LE.le.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Preorder.toLE.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.preorder.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) a) b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Iff (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (Associates.out.{u1} \u03b1 _inst_1 _inst_2 b)) (LE.le.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Preorder.toLE.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instPreorderAssociatesToMonoid.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) a) b)\nCase conversion may be inaccurate. Consider using '#align associates.dvd_out_iff Associates.dvd_out_iff\u2093'. -/\ntheorem dvd_out_iff (a : \u03b1) (b : Associates \u03b1) : a \u2223 b.out \u2194 Associates.mk a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Iff (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 b) a) (LE.le.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Preorder.toLE.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.preorder.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) b (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Iff (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 b) a) (LE.le.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Preorder.toLE.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instPreorderAssociatesToMonoid.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) b (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) a))\nCase conversion may be inaccurate. Consider using '#align associates.out_dvd_iff Associates.out_dvd_iff\u2093'. -/\ntheorem out_dvd_iff (a : \u03b1) (b : Associates \u03b1) : b.out \u2223 a \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} \u03b1 (Associates.out.{u1} \u03b1 _inst_1 _inst_2 (Top.top.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.hasTop.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1], Eq.{succ u1} \u03b1 (Associates.out.{u1} \u03b1 _inst_1 _inst_2 (Top.top.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instTopAssociates.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align associates.out_top Associates.out_top\u2093'. -/\n@[simp]\ntheorem out_top : (\u22a4 : Associates \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 a)) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] (a : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 a)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 a)) (Associates.out.{u1} \u03b1 _inst_1 _inst_2 a)\nCase conversion may be inaccurate. Consider using '#align associates.normalize_out Associates.normalize_out\u2093'. -/\n@[simp]\ntheorem normalize_out (a : Associates \u03b1) : 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 \u03b1) : 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 : _ \u2192 \u03b1) :=\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 (\u03b1 : Type _) [CancelCommMonoidWithZero \u03b1] where\n  gcd : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  lcm : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  gcd_dvd_left : \u2200 a b, gcd a b \u2223 a\n  gcd_dvd_right : \u2200 a b, gcd a b \u2223 b\n  dvd_gcd : \u2200 {a b c}, a \u2223 c \u2192 a \u2223 b \u2192 a \u2223 gcd c b\n  gcd_mul_lcm : \u2200 a b, Associated (gcd a b * lcm a b) (a * b)\n  lcm_zero_left : \u2200 a, lcm 0 a = 0\n  lcm_zero_right : \u2200 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 (\u03b1 : Type _) [CancelCommMonoidWithZero \u03b1] extends NormalizationMonoid \u03b1,\n  GCDMonoid \u03b1 where\n  normalize_gcd : \u2200 a b, normalize (gcd a b) = gcd a b\n  normalize_lcm : \u2200 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 \u03b1]\n\n/- warning: normalize_gcd -> normalize_gcd is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)\nCase conversion may be inaccurate. Consider using '#align normalize_gcd normalize_gcd\u2093'. -/\n@[simp]\ntheorem normalize_gcd [NormalizedGCDMonoid \u03b1] : \u2200 a b : \u03b1, 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 a b)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 a b)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b)\nCase conversion may be inaccurate. Consider using '#align gcd_mul_lcm gcd_mul_lcm\u2093'. -/\ntheorem gcd_mul_lcm [GCDMonoid \u03b1] : \u2200 a b : \u03b1, 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 \u03b1] (a b c : \u03b1) : a \u2223 gcd b c \u2194 a \u2223 b \u2227 a \u2223 c :=\n  Iff.intro (fun h => \u27e8h.trans (gcd_dvd_left _ _), h.trans (gcd_dvd_right _ _)\u27e9) fun \u27e8hab, hac\u27e9 =>\n    dvd_gcd hab hac\n#align dvd_gcd_iff dvd_gcd_iff\n-/\n\n#print gcd_comm /-\ntheorem gcd_comm [NormalizedGCDMonoid \u03b1] (a b : \u03b1) : 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 \u03b1] (a b : \u03b1) : 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 \u03b1] (m n k : \u03b1) : 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 \u03b1] (m n k : \u03b1) : 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 \u03b1] : IsCommutative \u03b1 gcd :=\n  \u27e8gcd_comm\u27e9\n\ninstance [NormalizedGCDMonoid \u03b1] : IsAssociative \u03b1 gcd :=\n  \u27e8gcd_assoc\u27e9\n\n/- warning: gcd_eq_normalize -> gcd_eq_normalize is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) c) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) c) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) c))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_normalize gcd_eq_normalize\u2093'. -/\ntheorem gcd_eq_normalize [NormalizedGCDMonoid \u03b1] {a b c : \u03b1} (habc : gcd a b \u2223 c)\n    (hcab : c \u2223 gcd a b) : gcd a b = normalize c :=\n  normalize_gcd a b \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))))) a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align gcd_zero_left gcd_zero_left\u2093'. -/\n@[simp]\ntheorem gcd_zero_left [NormalizedGCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))))) a) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) a) a\nCase conversion may be inaccurate. Consider using '#align gcd_zero_left' gcd_zero_left'\u2093'. -/\ntheorem gcd_zero_left' [GCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align gcd_zero_right gcd_zero_right\u2093'. -/\n@[simp]\ntheorem gcd_zero_right [NormalizedGCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a\nCase conversion may be inaccurate. Consider using '#align gcd_zero_right' gcd_zero_right'\u2093'. -/\ntheorem gcd_zero_right' [GCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Iff (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (And (Eq.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (Eq.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Iff (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (And (Eq.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Eq.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_zero_iff gcd_eq_zero_iff\u2093'. -/\n@[simp]\ntheorem gcd_eq_zero_iff [GCDMonoid \u03b1] (a b : \u03b1) : gcd a b = 0 \u2194 a = 0 \u2227 b = 0 :=\n  Iff.intro\n    (fun h => by\n      let \u27e8ca, ha\u27e9 := gcd_dvd_left a b\n      let \u27e8cb, hb\u27e9 := gcd_dvd_right a b\n      rw [h, MulZeroClass.zero_mul] at ha hb <;> exact \u27e8ha, hb\u27e9)\n    fun \u27e8ha, hb\u27e9 => by\n    rw [ha, hb, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))))) a) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_one_left gcd_one_left\u2093'. -/\n@[simp]\ntheorem gcd_one_left [NormalizedGCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))))) a) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_one_left' gcd_one_left'\u2093'. -/\n@[simp]\ntheorem gcd_one_left' [GCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_one_right gcd_one_right\u2093'. -/\n@[simp]\ntheorem gcd_one_right [NormalizedGCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align gcd_one_right' gcd_one_right'\u2093'. -/\n@[simp]\ntheorem gcd_one_right' [GCDMonoid \u03b1] (a : \u03b1) : 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 \u03b1] {a b c d : \u03b1} (hab : a \u2223 b) (hcd : c \u2223 d) : gcd a c \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align gcd_same gcd_same\u2093'. -/\n@[simp]\ntheorem gcd_same [NormalizedGCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) \u03b1 ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (MulZeroClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (MulZeroOneClass.toMulZeroClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) _inst_1)))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align gcd_mul_left gcd_mul_left\u2093'. -/\n@[simp]\ntheorem gcd_mul_left [NormalizedGCDMonoid \u03b1] (a b c : \u03b1) :\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 \u2260 0 =>\n    suffices gcd (a * b) (a * c) = normalize (a * gcd b c) by\n      simpa only [normalize.map_mul, normalize_gcd]\n    let \u27e8d, Eq\u27e9 := dvd_gcd (dvd_mul_right a b) (dvd_mul_right a c)\n    gcd_eq_normalize\n      (Eq.symm \u25b8 mul_dvd_mul_left a <|\n        show d \u2223 gcd b c from\n          dvd_gcd ((mul_dvd_mul_iff_left ha).1 <| Eq \u25b8 gcd_dvd_left _ _)\n            ((mul_dvd_mul_iff_left ha).1 <| Eq \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 b c))\nCase conversion may be inaccurate. Consider using '#align gcd_mul_left' gcd_mul_left'\u2093'. -/\ntheorem gcd_mul_left' [GCDMonoid \u03b1] (a b c : \u03b1) : Associated (gcd (a * b) (a * c)) (a * gcd b c) :=\n  by\n  obtain rfl | ha := eq_or_ne a 0\n  \u00b7 simp only [MulZeroClass.zero_mul, gcd_zero_left']\n  obtain \u27e8d, eq\u27e9 := dvd_gcd (dvd_mul_right a b) (dvd_mul_right a c)\n  apply associated_of_dvd_dvd\n  \u00b7 rw [Eq]\n    apply mul_dvd_mul_left\n    exact\n      dvd_gcd ((mul_dvd_mul_iff_left ha).1 <| Eq \u25b8 gcd_dvd_left _ _)\n        ((mul_dvd_mul_iff_left ha).1 <| Eq \u25b8 gcd_dvd_right _ _)\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) b c) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} \u03b1 ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) b c) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a))\nCase conversion may be inaccurate. Consider using '#align gcd_mul_right gcd_mul_right\u2093'. -/\n@[simp]\ntheorem gcd_mul_right [NormalizedGCDMonoid \u03b1] (a b c : \u03b1) :\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 b c) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 b c) a)\nCase conversion may be inaccurate. Consider using '#align gcd_mul_right' gcd_mul_right'\u2093'. -/\n@[simp]\ntheorem gcd_mul_right' [GCDMonoid \u03b1] (a b c : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a) a) -> (Iff (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) a) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a) a) -> (Iff (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) a) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_left_iff gcd_eq_left_iff\u2093'. -/\ntheorem gcd_eq_left_iff [NormalizedGCDMonoid \u03b1] (a b : \u03b1) (h : normalize a = a) :\n    gcd a b = a \u2194 a \u2223 b :=\n  Iff.intro (fun eq => Eq \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) b) b) -> (Iff (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) b) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) b) b) -> (Iff (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) b) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a))\nCase conversion may be inaccurate. Consider using '#align gcd_eq_right_iff gcd_eq_right_iff\u2093'. -/\ntheorem gcd_eq_right_iff [NormalizedGCDMonoid \u03b1] (a b : \u03b1) (h : normalize b = b) :\n    gcd a b = b \u2194 b \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) k m) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) k m) n)\nCase conversion may be inaccurate. Consider using '#align gcd_dvd_gcd_mul_left gcd_dvd_gcd_mul_left\u2093'. -/\ntheorem gcd_dvd_gcd_mul_left [GCDMonoid \u03b1] (m n k : \u03b1) : gcd m n \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m k) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m k) n)\nCase conversion may be inaccurate. Consider using '#align gcd_dvd_gcd_mul_right gcd_dvd_gcd_mul_right\u2093'. -/\ntheorem gcd_dvd_gcd_mul_right [GCDMonoid \u03b1] (m n k : \u03b1) : gcd m n \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) k n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) k n))\nCase conversion may be inaccurate. Consider using '#align gcd_dvd_gcd_mul_left_right gcd_dvd_gcd_mul_left_right\u2093'. -/\ntheorem gcd_dvd_gcd_mul_left_right [GCDMonoid \u03b1] (m n k : \u03b1) : gcd m n \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) n k))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) n k))\nCase conversion may be inaccurate. Consider using '#align gcd_dvd_gcd_mul_right_right gcd_dvd_gcd_mul_right_right\u2093'. -/\ntheorem gcd_dvd_gcd_mul_right_right [GCDMonoid \u03b1] (m n k : \u03b1) : gcd m n \u2223 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 \u03b1] {m n : \u03b1} (h : Associated m n) (k : \u03b1) :\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 \u03b1] {m n : \u03b1} (h : Associated m n) (k : \u03b1) :\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {m : \u03b1} {n : \u03b1} {k : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 k m) n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {m : \u03b1} {n : \u03b1} {k : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _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\u2093'. -/\ntheorem dvd_gcd_mul_of_dvd_mul [GCDMonoid \u03b1] {m n k : \u03b1} (H : k \u2223 m * n) : k \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {m : \u03b1} {n : \u03b1} {k : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 k n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {m : \u03b1} {n : \u03b1} {k : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m (GCDMonoid.gcd.{u1} \u03b1 _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\u2093'. -/\ntheorem dvd_mul_gcd_of_dvd_mul [GCDMonoid \u03b1] {m n k : \u03b1} (H : k \u2223 m * n) : k \u2223 m * gcd k n :=\n  by\n  rw [mul_comm] at H\u22a2\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {m : \u03b1} {n : \u03b1} {k : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) -> (Exists.{succ u1} \u03b1 (fun (d\u2081 : \u03b1) => Exists.{succ u1} \u03b1 (fun (d\u2082 : \u03b1) => And (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 m) (And (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2082 n) (Eq.{succ u1} \u03b1 k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) d\u2081 d\u2082))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {m : \u03b1} {n : \u03b1} {k : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) -> (Exists.{succ u1} \u03b1 (fun (d\u2081 : \u03b1) => Exists.{succ u1} \u03b1 (fun (d\u2082 : \u03b1) => And (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 m) (And (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2082 n) (Eq.{succ u1} \u03b1 k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) d\u2081 d\u2082))))))\nCase conversion may be inaccurate. Consider using '#align exists_dvd_and_dvd_of_dvd_mul exists_dvd_and_dvd_of_dvd_mul\u2093'. -/\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 `\u2115`.  -/\ntheorem exists_dvd_and_dvd_of_dvd_mul [GCDMonoid \u03b1] {m n k : \u03b1} (H : k \u2223 m * n) :\n    \u2203 d\u2081 d\u2082, d\u2081 \u2223 m \u2227 d\u2082 \u2223 n \u2227 k = d\u2081 * d\u2082 :=\n  by\n  by_cases h0 : gcd k m = 0\n  \u00b7 rw [gcd_eq_zero_iff] at h0\n    rcases h0 with \u27e8rfl, rfl\u27e9\n    refine' \u27e80, n, dvd_refl 0, dvd_refl n, _\u27e9\n    simp\n  \u00b7 obtain \u27e8a, ha\u27e9 := gcd_dvd_left k m\n    refine' \u27e8gcd k m, a, gcd_dvd_right _ _, _, ha\u27e9\n    suffices h : gcd k m * a \u2223 gcd k m * n\n    \u00b7 cases' h with b hb\n      use b\n      rw [mul_assoc] at hb\n      apply mul_left_cancel\u2080 h0 hb\n    rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {k : \u03b1} {m : \u03b1} {n : \u03b1}, Iff (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) (Exists.{succ u1} \u03b1 (fun (d\u2081 : \u03b1) => Exists.{succ u1} \u03b1 (fun (d\u2082 : \u03b1) => And (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 m) (And (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2082 n) (Eq.{succ u1} \u03b1 k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) d\u2081 d\u2082))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {k : \u03b1} {m : \u03b1} {n : \u03b1}, Iff (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) (Exists.{succ u1} \u03b1 (fun (d\u2081 : \u03b1) => Exists.{succ u1} \u03b1 (fun (d\u2082 : \u03b1) => And (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 m) (And (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2082 n) (Eq.{succ u1} \u03b1 k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) d\u2081 d\u2082))))))\nCase conversion may be inaccurate. Consider using '#align dvd_mul dvd_mul\u2093'. -/\ntheorem dvd_mul [GCDMonoid \u03b1] {k m n : \u03b1} : k \u2223 m * n \u2194 \u2203 d\u2081 d\u2082, d\u2081 \u2223 m \u2227 d\u2082 \u2223 n \u2227 k = d\u2081 * d\u2082 :=\n  by\n  refine' \u27e8exists_dvd_and_dvd_of_dvd_mul, _\u27e9\n  rintro \u27e8d\u2081, d\u2082, hy, hz, rfl\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (k : \u03b1) (m : \u03b1) (n : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 k m) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 k n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (k : \u03b1) (m : \u03b1) (n : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 k (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m n)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 k m) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 k n))\nCase conversion may be inaccurate. Consider using '#align gcd_mul_dvd_mul_gcd gcd_mul_dvd_mul_gcd\u2093'. -/\ntheorem gcd_mul_dvd_mul_gcd [GCDMonoid \u03b1] (k m n : \u03b1) : gcd k (m * n) \u2223 gcd k m * gcd k n :=\n  by\n  obtain \u27e8m', n', hm', hn', h\u27e9 := 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' \u2223 k := h \u25b8 gcd_dvd_left _ _\n  apply mul_dvd_mul\n  \u00b7 have hm'k : m' \u2223 k := (dvd_mul_right m' n').trans hm'n'\n    exact dvd_gcd hm'k hm'\n  \u00b7 have hn'k : n' \u2223 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 \u03b1] {a b : \u03b1} {k : \u2115} : gcd a (b ^ k) \u2223 gcd a b ^ k :=\n  by\n  by_cases hg : gcd a b = 0\n  \u00b7 rw [gcd_eq_zero_iff] at hg\n    rcases hg with \u27e8rfl, rfl\u27e9\n    exact\n      (gcd_zero_left' (0 ^ k : \u03b1)).Dvd.trans\n        (pow_dvd_pow_of_dvd (gcd_zero_left' (0 : \u03b1)).symm.Dvd _)\n  \u00b7 induction' k with k hk\n    \u00b7 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 \u03b1] {a b : \u03b1} {k : \u2115} : gcd (a ^ k) b \u2223 gcd a b ^ k :=\n  calc\n    gcd (a ^ k) b \u2223 gcd b (a ^ k) := (gcd_comm' _ _).Dvd\n    _ \u2223 gcd b a ^ k := gcd_pow_right_dvd_pow_gcd\n    _ \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d\u2081 : \u03b1} {d\u2082 : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) -> (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c k)) -> (Eq.{succ u1} \u03b1 c (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) d\u2081 d\u2082)) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 a) -> (And (Ne.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 k) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 k) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d\u2081 : \u03b1} {d\u2082 : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) -> (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c k)) -> (Eq.{succ u1} \u03b1 c (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) d\u2081 d\u2082)) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 a) -> (And (Ne.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 k) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d\u2081 k) a)))\nCase conversion may be inaccurate. Consider using '#align pow_dvd_of_mul_eq_pow pow_dvd_of_mul_eq_pow\u2093'. -/\ntheorem pow_dvd_of_mul_eq_pow [GCDMonoid \u03b1] {a b c d\u2081 d\u2082 : \u03b1} (ha : a \u2260 0) (hab : IsUnit (gcd a b))\n    {k : \u2115} (h : a * b = c ^ k) (hc : c = d\u2081 * d\u2082) (hd\u2081 : d\u2081 \u2223 a) : d\u2081 ^ k \u2260 0 \u2227 d\u2081 ^ k \u2223 a :=\n  by\n  have h1 : IsUnit (gcd (d\u2081 ^ k) b) := by\n    apply isUnit_of_dvd_one\n    trans gcd d\u2081 b ^ k\n    \u00b7 exact gcd_pow_left_dvd_pow_gcd\n    \u00b7 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\u2081 (dvd_refl b)\n  have h2 : d\u2081 ^ k \u2223 a * b := by\n    use d\u2082 ^ k\n    rw [h, hc]\n    exact mul_pow d\u2081 d\u2082 k\n  rw [mul_comm] at h2\n  have h3 : d\u2081 ^ k \u2223 a := by\n    apply (dvd_gcd_mul_of_dvd_mul h2).trans\n    rw [IsUnit.mul_left_dvd _ _ _ h1]\n  have h4 : d\u2081 ^ k \u2260 0 := by\n    intro hdk\n    rw [hdk] at h3\n    apply absurd (zero_dvd_iff.mp h3) ha\n  exact \u27e8h4, h3\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c k)) -> (Exists.{succ u1} \u03b1 (fun (d : \u03b1) => Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d k) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c k)) -> (Exists.{succ u1} \u03b1 (fun (d : \u03b1) => Associated.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _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\u2093'. -/\ntheorem exists_associated_pow_of_mul_eq_pow [GCDMonoid \u03b1] {a b c : \u03b1} (hab : IsUnit (gcd a b))\n    {k : \u2115} (h : a * b = c ^ k) : \u2203 d : \u03b1, Associated (d ^ k) a :=\n  by\n  cases subsingleton_or_nontrivial \u03b1\n  \u00b7 use 0\n    rw [Subsingleton.elim a (0 ^ k)]\n  by_cases ha : a = 0\n  \u00b7 use 0\n    rw [ha]\n    obtain rfl | hk := k.eq_zero_or_pos\n    \u00b7 exfalso\n      revert h\n      rw [ha, MulZeroClass.zero_mul, pow_zero]\n      apply zero_ne_one\n    \u00b7 rw [zero_pow hk]\n  by_cases hb : b = 0\n  \u00b7 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  \u00b7 use 1\n    rw [pow_zero] at h\u22a2\n    use Units.mkOfMulEqOne _ _ h\n    rw [Units.val_mkOfMulEqOne, one_mul]\n  have hc : c \u2223 a * b := by\n    rw [h]\n    exact dvd_pow_self _ hk.ne'\n  obtain \u27e8d\u2081, d\u2082, hd\u2081, hd\u2082, hc\u27e9 := exists_dvd_and_dvd_of_dvd_mul hc\n  use d\u2081\n  obtain \u27e8h0\u2081, \u27e8a', ha'\u27e9\u27e9 := pow_dvd_of_mul_eq_pow ha hab h hc hd\u2081\n  rw [mul_comm] at h hc\n  rw [(gcd_comm' a b).isUnit_iff] at hab\n  obtain \u27e8h0\u2082, \u27e8b', hb'\u27e9\u27e9 := pow_dvd_of_mul_eq_pow hb hab h hc hd\u2082\n  rw [ha', hb', hc, mul_pow] at h\n  have h' : a' * b' = 1 := by\n    apply (mul_right_inj' h0\u2081).mp\n    rw [mul_one]\n    apply (mul_right_inj' h0\u2082).mp\n    rw [\u2190 h]\n    rw [mul_assoc, mul_comm a', \u2190 mul_assoc _ b', \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] [_inst_3 : Unique.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c k)) -> (Exists.{succ u1} \u03b1 (fun (d : \u03b1) => Eq.{succ u1} \u03b1 a (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) d k))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] [_inst_3 : Unique.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (GCDMonoid.gcd.{u1} \u03b1 _inst_1 _inst_2 a b)) -> (forall {k : Nat}, (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c k)) -> (Exists.{succ u1} \u03b1 (fun (d : \u03b1) => Eq.{succ u1} \u03b1 a (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _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\u2093'. -/\ntheorem exists_eq_pow_of_mul_eq_pow [GCDMonoid \u03b1] [Unique \u03b1\u02e3] {a b c : \u03b1} (hab : IsUnit (gcd a b))\n    {k : \u2115} (h : a * b = c ^ k) : \u2203 d : \u03b1, a = d ^ k :=\n  let \u27e8d, hd\u27e9 := exists_associated_pow_of_mul_eq_pow hab h\n  \u27e8d, (associated_iff_eq.mp hd).symm\u27e9\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 {\u03b1 : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_3 : NormalizedGCDMonoid.{u1} \u03b1 _inst_2] {a : \u03b1} {b : \u03b1} {d : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) d a) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) d b) -> (forall (e : \u03b1), (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) e a) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) e b) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) e d)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_2 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_2 _inst_3) a b) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) (normalize.{u1} \u03b1 _inst_2 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_2 _inst_3)) d))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_3 : NormalizedGCDMonoid.{u1} \u03b1 _inst_2] {a : \u03b1} {b : \u03b1} {d : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) d a) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) d b) -> (forall (e : \u03b1), (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) e a) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) e b) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) e d)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_2 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_2 _inst_3) a b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))))) (normalize.{u1} \u03b1 _inst_2 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_2 _inst_3)) d))\nCase conversion may be inaccurate. Consider using '#align gcd_greatest gcd_greatest\u2093'. -/\ntheorem gcd_greatest {\u03b1 : Type _} [CancelCommMonoidWithZero \u03b1] [NormalizedGCDMonoid \u03b1] {a b d : \u03b1}\n    (hda : d \u2223 a) (hdb : d \u2223 b) (hd : \u2200 e : \u03b1, e \u2223 a \u2192 e \u2223 b \u2192 e \u2223 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 {\u03b1 : Type _} [CancelCommMonoidWithZero \u03b1] [GCDMonoid \u03b1] {a b d : \u03b1}\n    (hda : d \u2223 a) (hdb : d \u2223 b) (hd : \u2200 e : \u03b1, e \u2223 a \u2192 e \u2223 b \u2192 e \u2223 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 {\u03b1 : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_3 : GCDMonoid.{u1} \u03b1 _inst_2] {x : \u03b1} {y : \u03b1} {x' : \u03b1} {y' : \u03b1}, (Eq.{succ u1} \u03b1 x (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) x')) -> (Eq.{succ u1} \u03b1 y (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) y')) -> (Ne.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))))))) -> (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x' y'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_3 : GCDMonoid.{u1} \u03b1 _inst_2] {x : \u03b1} {y : \u03b1} {x' : \u03b1} {y' : \u03b1}, (Eq.{succ u1} \u03b1 x (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) x')) -> (Eq.{succ u1} \u03b1 y (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) y')) -> (Ne.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))))) -> (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (GCDMonoid.gcd.{u1} \u03b1 _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\u2093'. -/\ntheorem isUnit_gcd_of_eq_mul_gcd {\u03b1 : Type _} [CancelCommMonoidWithZero \u03b1] [GCDMonoid \u03b1]\n    {x y x' y' : \u03b1} (ex : x = gcd x y * x') (ey : y = gcd x y * y') (h : gcd x y \u2260 0) :\n    IsUnit (gcd x' y') := by\n  rw [\u2190 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 [\u2190 ex, \u2190 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 {\u03b1 : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_3 : GCDMonoid.{u1} \u03b1 _inst_2] (x : \u03b1) (y : \u03b1), Exists.{succ u1} \u03b1 (fun (x' : \u03b1) => Exists.{succ u1} \u03b1 (fun (y' : \u03b1) => And (Eq.{succ u1} \u03b1 x (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) x')) (And (Eq.{succ u1} \u03b1 y (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) y')) (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x' y')))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_2 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_3 : GCDMonoid.{u1} \u03b1 _inst_2] (x : \u03b1) (y : \u03b1), Exists.{succ u1} \u03b1 (fun (x' : \u03b1) => Exists.{succ u1} \u03b1 (fun (y' : \u03b1) => And (Eq.{succ u1} \u03b1 x (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) x')) (And (Eq.{succ u1} \u03b1 y (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2)))))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x y) y')) (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_2))) (GCDMonoid.gcd.{u1} \u03b1 _inst_2 _inst_3 x' y')))))\nCase conversion may be inaccurate. Consider using '#align extract_gcd extract_gcd\u2093'. -/\ntheorem extract_gcd {\u03b1 : Type _} [CancelCommMonoidWithZero \u03b1] [GCDMonoid \u03b1] (x y : \u03b1) :\n    \u2203 x' y', x = gcd x y * x' \u2227 y = gcd x y * y' \u2227 IsUnit (gcd x' y') :=\n  by\n  by_cases h : gcd x y = 0\n  \u00b7 obtain \u27e8rfl, rfl\u27e9 := (gcd_eq_zero_iff x y).1 h\n    simp_rw [\u2190 associated_one_iff_isUnit]\n    exact\n      \u27e81, 1, by rw [h, MulZeroClass.zero_mul], by rw [h, MulZeroClass.zero_mul], gcd_one_left' 1\u27e9\n  obtain \u27e8x', ex\u27e9 := gcd_dvd_left x y\n  obtain \u27e8y', ey\u27e9 := gcd_dvd_right x y\n  exact \u27e8x', y', ex, ey, isUnit_gcd_of_eq_mul_gcd ex ey h\u27e9\n#align extract_gcd extract_gcd\n\nend Gcd\n\nsection Lcm\n\n#print lcm_dvd_iff /-\ntheorem lcm_dvd_iff [GCDMonoid \u03b1] {a b c : \u03b1} : lcm a b \u2223 c \u2194 a \u2223 c \u2227 b \u2223 c :=\n  by\n  by_cases this : a = 0 \u2228 b = 0\n  \u00b7\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  \u00b7 obtain \u27e8h1, h2\u27e9 := not_or.1 this\n    have h : gcd a b \u2260 0 := fun H => h1 ((gcd_eq_zero_iff _ _).1 H).1\n    rw [\u2190 mul_dvd_mul_iff_left h, (gcd_mul_lcm a b).dvd_iff_dvd_left, \u2190\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 \u03b1] (a b : \u03b1) : a \u2223 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 \u03b1] (a b : \u03b1) : b \u2223 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 \u03b1] {a b c : \u03b1} (hab : a \u2223 b) (hcb : c \u2223 b) : lcm a c \u2223 b :=\n  lcm_dvd_iff.2 \u27e8hab, hcb\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Iff (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 a b) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (Or (Eq.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (Eq.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Iff (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 a b) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Or (Eq.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Eq.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_zero_iff lcm_eq_zero_iff\u2093'. -/\n@[simp]\ntheorem lcm_eq_zero_iff [GCDMonoid \u03b1] (a b : \u03b1) : lcm a b = 0 \u2194 a = 0 \u2228 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)\nCase conversion may be inaccurate. Consider using '#align normalize_lcm normalize_lcm\u2093'. -/\n@[simp]\ntheorem normalize_lcm [NormalizedGCDMonoid \u03b1] (a b : \u03b1) : 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 \u03b1] (a b : \u03b1) : 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 \u03b1] (a b : \u03b1) : 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 \u03b1] (m n k : \u03b1) : 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 \u03b1] (m n k : \u03b1) : 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 \u03b1] : IsCommutative \u03b1 lcm :=\n  \u27e8lcm_comm\u27e9\n\ninstance [NormalizedGCDMonoid \u03b1] : IsAssociative \u03b1 lcm :=\n  \u27e8lcm_assoc\u27e9\n\n/- warning: lcm_eq_normalize -> lcm_eq_normalize is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) c) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) c) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) c))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_normalize lcm_eq_normalize\u2093'. -/\ntheorem lcm_eq_normalize [NormalizedGCDMonoid \u03b1] {a b c : \u03b1} (habc : lcm a b \u2223 c)\n    (hcab : c \u2223 lcm a b) : lcm a b = normalize c :=\n  normalize_lcm a b \u25b8 normalize_eq_normalize habc hcab\n#align lcm_eq_normalize lcm_eq_normalize\n\n#print lcm_dvd_lcm /-\ntheorem lcm_dvd_lcm [GCDMonoid \u03b1] {a b c d : \u03b1} (hab : a \u2223 b) (hcd : c \u2223 d) : lcm a c \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (u : Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (coeBase.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (Units.hasCoe.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) u) a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (u : Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_units_coe_left lcm_units_coe_left\u2093'. -/\n@[simp]\ntheorem lcm_units_coe_left [NormalizedGCDMonoid \u03b1] (u : \u03b1\u02e3) (a : \u03b1) : lcm (\u2191u) 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (u : Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (coeBase.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (Units.hasCoe.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) u)) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (u : Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a (Units.val.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) u)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_units_coe_right lcm_units_coe_right\u2093'. -/\n@[simp]\ntheorem lcm_units_coe_right [NormalizedGCDMonoid \u03b1] (a : \u03b1) (u : \u03b1\u02e3) : lcm a \u2191u = 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))))) a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_one_left lcm_one_left\u2093'. -/\n@[simp]\ntheorem lcm_one_left [NormalizedGCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_one_right lcm_one_right\u2093'. -/\n@[simp]\ntheorem lcm_one_right [NormalizedGCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a a) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align lcm_same lcm_same\u2093'. -/\n@[simp]\ntheorem lcm_same [NormalizedGCDMonoid \u03b1] (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Iff (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (And (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), Iff (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (And (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_one_iff lcm_eq_one_iff\u2093'. -/\n@[simp]\ntheorem lcm_eq_one_iff [NormalizedGCDMonoid \u03b1] (a b : \u03b1) : lcm a b = 1 \u2194 a \u2223 1 \u2227 b \u2223 1 :=\n  Iff.intro (fun eq => Eq \u25b8 \u27e8dvd_lcm_left _ _, dvd_lcm_right _ _\u27e9) fun \u27e8\u27e8c, hc\u27e9, \u27e8d, hd\u27e9\u27e9 =>\n    show lcm (Units.mkOfMulEqOne a c hc.symm : \u03b1) (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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a b) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) a c)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) \u03b1 ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (MulZeroClass.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (MulZeroOneClass.toMulZeroClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (MonoidWithZero.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (CommMonoidWithZero.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) _inst_1)))))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) b c))\nCase conversion may be inaccurate. Consider using '#align lcm_mul_left lcm_mul_left\u2093'. -/\n@[simp]\ntheorem lcm_mul_left [NormalizedGCDMonoid \u03b1] (a b c : \u03b1) :\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 \u2260 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 \u2223 lcm (a * b) (a * c) := (dvd_mul_right _ _).trans (dvd_lcm_left _ _)\n    let \u27e8d, Eq\u27e9 := 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 \u25b8\n        (mul_dvd_mul_left a <|\n          lcm_dvd ((mul_dvd_mul_iff_left ha).1 <| Eq \u25b8 dvd_lcm_left _ _)\n            ((mul_dvd_mul_iff_left ha).1 <| Eq \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) b c) (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) b a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) c a)) (HMul.hMul.{u1, u1, u1} \u03b1 ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) b c) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a))\nCase conversion may be inaccurate. Consider using '#align lcm_mul_right lcm_mul_right\u2093'. -/\n@[simp]\ntheorem lcm_mul_right [NormalizedGCDMonoid \u03b1] (a b c : \u03b1) :\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a) a) -> (Iff (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) a) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) a) a) -> (Iff (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) a) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_left_iff lcm_eq_left_iff\u2093'. -/\ntheorem lcm_eq_left_iff [NormalizedGCDMonoid \u03b1] (a b : \u03b1) (h : normalize a = a) :\n    lcm a b = a \u2194 b \u2223 a :=\n  Iff.intro (fun eq => Eq \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), (Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) b) b) -> (Iff (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) b) (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizedGCDMonoid.{u1} \u03b1 _inst_1] (a : \u03b1) (b : \u03b1), (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) b) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toNormalizationMonoid.{u1} \u03b1 _inst_1 _inst_2)) b) b) -> (Iff (Eq.{succ u1} \u03b1 (GCDMonoid.lcm.{u1} \u03b1 _inst_1 (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 _inst_1 _inst_2) a b) b) (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b))\nCase conversion may be inaccurate. Consider using '#align lcm_eq_right_iff lcm_eq_right_iff\u2093'. -/\ntheorem lcm_eq_right_iff [NormalizedGCDMonoid \u03b1] (a b : \u03b1) (h : normalize b = b) :\n    lcm a b = b \u2194 a \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) k m) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) k m) n)\nCase conversion may be inaccurate. Consider using '#align lcm_dvd_lcm_mul_left lcm_dvd_lcm_mul_left\u2093'. -/\ntheorem lcm_dvd_lcm_mul_left [GCDMonoid \u03b1] (m n k : \u03b1) : lcm m n \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m k) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) m k) n)\nCase conversion may be inaccurate. Consider using '#align lcm_dvd_lcm_mul_right lcm_dvd_lcm_mul_right\u2093'. -/\ntheorem lcm_dvd_lcm_mul_right [GCDMonoid \u03b1] (m n k : \u03b1) : lcm m n \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) k n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) k n))\nCase conversion may be inaccurate. Consider using '#align lcm_dvd_lcm_mul_left_right lcm_dvd_lcm_mul_left_right\u2093'. -/\ntheorem lcm_dvd_lcm_mul_left_right [GCDMonoid \u03b1] (m n k : \u03b1) : lcm m n \u2223 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) n k))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : GCDMonoid.{u1} \u03b1 _inst_1] (m : \u03b1) (n : \u03b1) (k : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m n) (GCDMonoid.lcm.{u1} \u03b1 _inst_1 _inst_2 m (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) n k))\nCase conversion may be inaccurate. Consider using '#align lcm_dvd_lcm_mul_right_right lcm_dvd_lcm_mul_right_right\u2093'. -/\ntheorem lcm_dvd_lcm_mul_right_right [GCDMonoid \u03b1] (m n k : \u03b1) : lcm m n \u2223 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 \u03b1] {m n : \u03b1} (h : Associated m n) (k : \u03b1) :\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 \u03b1] {m n : \u03b1} (h : Associated m n) (k : \u03b1) :\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 \u03b1] {x : \u03b1} (hi : Irreducible x) : Prime x :=\n  \u27e8hi.NeZero,\n    \u27e8hi.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      \u00b7 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      \u00b7 left\n        rw [hy]\n        exact dvd_trans (associated_mul_unit_left _ _ hu).Dvd (gcd_dvd_right x a)\u27e9\u27e9\n#align gcd_monoid.prime_of_irreducible GCDMonoid.prime_of_irreducible\n-/\n\n#print GCDMonoid.irreducible_iff_prime /-\ntheorem irreducible_iff_prime [GCDMonoid \u03b1] {p : \u03b1} : Irreducible p \u2194 Prime p :=\n  \u27e8prime_of_irreducible, Prime.irreducible\u27e9\n#align gcd_monoid.irreducible_iff_prime GCDMonoid.irreducible_iff_prime\n-/\n\nend GCDMonoid\n\nend GCDMonoid\n\nsection UniqueUnit\n\nvariable [CancelCommMonoidWithZero \u03b1] [Unique \u03b1\u02e3]\n\n#print normalizationMonoidOfUniqueUnits /-\n-- see Note [lower instance priority]\ninstance (priority := 100) normalizationMonoidOfUniqueUnits : NormalizationMonoid \u03b1\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 \u03b1)\n    where\n  default := normalizationMonoidOfUniqueUnits\n  uniq := fun \u27e8u, _, _, _\u27e9 => 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 \u03b1) :=\n  \u27e8fun g\u2081 g\u2082 =>\n    by\n    have hgcd : g\u2081.gcd = g\u2082.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\u2081.lcm = g\u2082.lcm := by\n      ext (a b)\n      refine' associated_iff_eq.mp (associated_of_dvd_dvd _ _) <;>\n        apply lcm_dvd_iff.2 \u27e8dvd_lcm_left _ _, dvd_lcm_right _ _\u27e9\n    cases g\u2081\n    cases g\u2082\n    dsimp only at hgcd hlcm\n    simp only [hgcd, hlcm]\u27e9\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 \u03b1) :=\n  \u27e8by\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\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : Unique.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))] (x : \u03b1), Eq.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 (normalizationMonoidOfUniqueUnits.{u1} \u03b1 _inst_1 _inst_2) x) (OfNat.ofNat.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (OfNat.mk.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (One.one.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulOneClass.toHasOne.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Units.mulOneClass.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : Unique.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))] (x : \u03b1), Eq.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (NormalizationMonoid.normUnit.{u1} \u03b1 _inst_1 (normalizationMonoidOfUniqueUnits.{u1} \u03b1 _inst_1 _inst_2) x) (OfNat.ofNat.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) 1 (One.toOfNat1.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (InvOneClass.toOne.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivInvOneMonoid.toInvOneClass.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (DivisionCommMonoid.toDivisionMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommGroup.toDivisionCommMonoid.{u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Units.instCommGroupUnitsToMonoid.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align norm_unit_eq_one normUnit_eq_one\u2093'. -/\n@[simp]\ntheorem normUnit_eq_one (x : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : Unique.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))] (x : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 (normalizationMonoidOfUniqueUnits.{u1} \u03b1 _inst_1 _inst_2)) x) x\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : Unique.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))] (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 (normalizationMonoidOfUniqueUnits.{u1} \u03b1 _inst_1 _inst_2)) x) x\nCase conversion may be inaccurate. Consider using '#align normalize_eq normalize_eq\u2093'. -/\n@[simp]\ntheorem normalize_eq (x : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : Unique.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))], MulEquiv.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (Associates.hasMul.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : Unique.{succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))], MulEquiv.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (Associates.instMulAssociatesToMonoid.{u1} \u03b1 (CommMonoidWithZero.toCommMonoid.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align associates_equiv_of_unique_units associatesEquivOfUniqueUnits\u2093'. -/\n/-- If a monoid's only unit is `1`, then it is isomorphic to its associates. -/\n@[simps]\ndef associatesEquivOfUniqueUnits : Associates \u03b1 \u2243* \u03b1\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 \u03b1] [IsDomain \u03b1] [NormalizedGCDMonoid \u03b1]\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 {\u03b1 : Type.{u1}} [_inst_1 : CommRing.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))] [_inst_3 : NormalizedGCDMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2)] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (NonUnitalSemiring.toSemigroupWithZero.{u1} \u03b1 (NonUnitalRing.toNonUnitalSemiring.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 (CommRing.toNonUnitalCommRing.{u1} \u03b1 _inst_1)))))) a (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) b c)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) _inst_3) a b) (GCDMonoid.gcd.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) _inst_3) a c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CommRing.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))] [_inst_3 : NormalizedGCDMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2)] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (NonUnitalSemiring.toSemigroupWithZero.{u1} \u03b1 (NonUnitalRing.toNonUnitalSemiring.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 (CommRing.toNonUnitalCommRing.{u1} \u03b1 _inst_1)))))) a (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))) b c)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) _inst_3) a b) (GCDMonoid.gcd.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem gcd_eq_of_dvd_sub_right {a b c : \u03b1} (h : a \u2223 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' \u27e8gcd_dvd_left _ _, _\u27e9\n  \u00b7 rcases h with \u27e8d, hd\u27e9\n    rcases gcd_dvd_right a b with \u27e8e, he\u27e9\n    rcases gcd_dvd_left a b with \u27e8f, hf\u27e9\n    use e - f * d\n    rw [mul_sub, \u2190 he, \u2190 mul_assoc, \u2190 hf, \u2190 hd, sub_sub_cancel]\n  \u00b7 rcases h with \u27e8d, hd\u27e9\n    rcases gcd_dvd_right a c with \u27e8e, he\u27e9\n    rcases gcd_dvd_left a c with \u27e8f, hf\u27e9\n    use e + f * d\n    rw [mul_add, \u2190 he, \u2190 mul_assoc, \u2190 hf, \u2190 hd, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : CommRing.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))] [_inst_3 : NormalizedGCDMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2)] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (NonUnitalSemiring.toSemigroupWithZero.{u1} \u03b1 (NonUnitalRing.toNonUnitalSemiring.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 (CommRing.toNonUnitalCommRing.{u1} \u03b1 _inst_1)))))) a (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) b c)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) _inst_3) b a) (GCDMonoid.gcd.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) (NormalizedGCDMonoid.toGcdMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) _inst_3) c a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CommRing.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))] [_inst_3 : NormalizedGCDMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2)] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (NonUnitalSemiring.toSemigroupWithZero.{u1} \u03b1 (NonUnitalRing.toNonUnitalSemiring.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 (CommRing.toNonUnitalCommRing.{u1} \u03b1 _inst_1)))))) a (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))) b c)) -> (Eq.{succ u1} \u03b1 (GCDMonoid.gcd.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) _inst_3) b a) (GCDMonoid.gcd.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1) _inst_2) (NormalizedGCDMonoid.toGCDMonoid.{u1} \u03b1 (IsDomain.toCancelCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem gcd_eq_of_dvd_sub_left {a b c : \u03b1} (h : a \u2223 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 \u03b1]\n\nprivate theorem map_mk_unit_aux [DecidableEq \u03b1] {f : Associates \u03b1 \u2192* \u03b1}\n    (hinv : Function.RightInverse f Associates.mk) (a : \u03b1) :\n    a * \u2191(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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b1] (f : MonoidHom.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.commMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))), (Function.RightInverse.{succ u1, succ u1} \u03b1 (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (coeFn.{succ u1, succ u1} (MonoidHom.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.commMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (fun (_x : MonoidHom.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.commMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) => (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) -> \u03b1) (MonoidHom.hasCoeToFun.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.commMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) f) (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) -> (NormalizationMonoid.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b1] (f : MonoidHom.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))), (Function.RightInverse.{succ u1, succ u1} \u03b1 (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidHom.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidHom.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulOneClass.toMul.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidHom.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidHom.monoidHomClass.{u1, u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (MulZeroOneClass.toMulOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (CommMonoidWithZero.toMonoidWithZero.{u1} (Associates.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (Associates.instCommMonoidWithZeroAssociatesToMonoidToMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) f) (Associates.mk.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) -> (NormalizationMonoid.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align normalization_monoid_of_monoid_hom_right_inverse normalizationMonoidOfMonoidHomRightInverse\u2093'. -/\n/-- Define `normalization_monoid` on a structure from a `monoid_hom` inverse to `associates.mk`. -/\ndef normalizationMonoidOfMonoidHomRightInverse [DecidableEq \u03b1] (f : Associates \u03b1 \u2192* \u03b1)\n    (hinv : Function.RightInverse f Associates.mk) : NormalizationMonoid \u03b1\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 * \u2191(Classical.choose (associated_map_mk hinv (a * b))) =\n        a * \u2191(Classical.choose (associated_map_mk hinv a)) *\n          (b * \u2191(Classical.choose (associated_map_mk hinv b)))\n      by\n      apply mul_left_cancel\u2080 (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, \u2190\n      MonoidHom.map_mul, Associates.mk_mul_mk]\n  normUnit_coe_units u := by\n    nontriviality \u03b1\n    rw [if_neg (Units.ne_zero u), Units.ext_iff]\n    apply mul_left_cancel\u2080 (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 \u27e8u, rfl\u27e9),\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 \u03b1] (gcd : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n    (gcd_dvd_left : \u2200 a b, gcd a b \u2223 a) (gcd_dvd_right : \u2200 a b, gcd a b \u2223 b)\n    (dvd_gcd : \u2200 {a b c}, a \u2223 c \u2192 a \u2223 b \u2192 a \u2223 gcd c b) : GCDMonoid \u03b1 :=\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      \u00b7 rw [MulZeroClass.mul_zero, a0, MulZeroClass.zero_mul]\n      \u00b7 rw [\u2190 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      \u00b7 rfl\n      have h := (Classical.choose_spec ((gcd_dvd_left a 0).trans (Dvd.intro 0 rfl))).symm\n      have a0' : gcd a 0 \u2260 0 := by\n        contrapose! a0\n        rw [\u2190 associated_zero_iff_eq_zero, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] [_inst_3 : DecidableEq.{succ u1} \u03b1] (gcd : \u03b1 -> \u03b1 -> \u03b1), (forall (a : \u03b1) (b : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (gcd a b) a) -> (forall (a : \u03b1) (b : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (gcd a b) b) -> (forall {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a c) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (gcd c b))) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (gcd a b)) (gcd a b)) -> (NormalizedGCDMonoid.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] [_inst_3 : DecidableEq.{succ u1} \u03b1] (gcd : \u03b1 -> \u03b1 -> \u03b1), (forall (a : \u03b1) (b : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (gcd a b) a) -> (forall (a : \u03b1) (b : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (gcd a b) b) -> (forall {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a c) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a b) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (gcd c b))) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (gcd a b)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (gcd a b)) (gcd a b)) -> (NormalizedGCDMonoid.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align normalized_gcd_monoid_of_gcd normalizedGCDMonoidOfGCD\u2093'. -/\n/-- Define `normalized_gcd_monoid` on a structure just from the `gcd` and its properties. -/\nnoncomputable def normalizedGCDMonoidOfGCD [NormalizationMonoid \u03b1] [DecidableEq \u03b1] (gcd : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n    (gcd_dvd_left : \u2200 a b, gcd a b \u2223 a) (gcd_dvd_right : \u2200 a b, gcd a b \u2223 b)\n    (dvd_gcd : \u2200 {a b c}, a \u2223 c \u2192 a \u2223 b \u2192 a \u2223 gcd c b)\n    (normalize_gcd : \u2200 a b, normalize (gcd a b) = gcd a b) : NormalizedGCDMonoid \u03b1 :=\n  { (inferInstance : NormalizationMonoid \u03b1) 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      \u00b7 exact @normalize_zero \u03b1 _ _\n      \u00b7 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        \u00b7 simp only [normalize_zero, MulZeroClass.mul_zero, mul_eq_zero] at this\n          obtain ha | hl := this\n          \u00b7 apply (a0 _).elim\n            rw [\u2190 zero_dvd_iff, \u2190 ha]\n            exact gcd_dvd_left _ _\n          \u00b7 convert@normalize_zero \u03b1 _ _\n        have h1 : gcd a b \u2260 0 := by\n          have hab : a * b \u2260 0 := mul_ne_zero a0 hb\n          contrapose! hab\n          rw [\u2190 normalize_eq_zero, \u2190 this, hab, MulZeroClass.zero_mul]\n        have h2 : normalize (gcd a b * l) = gcd a b * l := by rw [this, normalize_idem]\n        rw [\u2190 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      \u00b7 rw [MulZeroClass.mul_zero, a0, MulZeroClass.zero_mul]\n      \u00b7 rw [\u2190\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      \u00b7 rfl\n      rw [\u2190 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 [\u2190 normalize_gcd]\n        exact normalize_eq_normalize (gcd_dvd_left _ _) (dvd_gcd (dvd_refl a) (dvd_zero a))\n      rw [\u2190 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 \u03b1] (lcm : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n    (dvd_lcm_left : \u2200 a b, a \u2223 lcm a b) (dvd_lcm_right : \u2200 a b, b \u2223 lcm a b)\n    (lcm_dvd : \u2200 {a b c}, c \u2223 a \u2192 b \u2223 a \u2192 lcm c b \u2223 a) : GCDMonoid \u03b1 :=\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      \u00b7 rw [h, eq_zero_of_zero_dvd (dvd_lcm_left _ _), MulZeroClass.mul_zero, MulZeroClass.zero_mul]\n      \u00b7 rw [h_1, eq_zero_of_zero_dvd (dvd_lcm_right _ _), MulZeroClass.mul_zero]\n      rw [mul_comm, \u2190 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      \u00b7 rw [h]\n        apply dvd_zero\n      \u00b7 exact dvd_rfl\n      have h0 : lcm a b \u2260 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 [\u2190 mul_dvd_mul_iff_left h0, \u2190 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      \u00b7 exact dvd_rfl\n      \u00b7 rw [h_1]\n        apply dvd_zero\n      have h0 : lcm a b \u2260 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 [\u2190 mul_dvd_mul_iff_left h0, \u2190 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      \u00b7 exact ab\n      \u00b7 exact ac\n      have h0 : lcm c b \u2260 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 [\u2190 mul_dvd_mul_iff_left h0, \u2190 Classical.choose_spec (exists_gcd c b)]\n      rcases ab with \u27e8d, rfl\u27e9\n      rw [mul_eq_zero] at h_1\n      push_neg  at h_1\n      rw [mul_comm a, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] [_inst_3 : DecidableEq.{succ u1} \u03b1] (lcm : \u03b1 -> \u03b1 -> \u03b1), (forall (a : \u03b1) (b : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (lcm a b)) -> (forall (a : \u03b1) (b : \u03b1), Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b (lcm a b)) -> (forall {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c a) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a) -> (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (lcm c b) a)) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (fun (_x : MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) => \u03b1 -> \u03b1) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (lcm a b)) (lcm a b)) -> (NormalizedGCDMonoid.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CancelCommMonoidWithZero.{u1} \u03b1] [_inst_2 : NormalizationMonoid.{u1} \u03b1 _inst_1] [_inst_3 : DecidableEq.{succ u1} \u03b1] (lcm : \u03b1 -> \u03b1 -> \u03b1), (forall (a : \u03b1) (b : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) a (lcm a b)) -> (forall (a : \u03b1) (b : \u03b1), Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b (lcm a b)) -> (forall {a : \u03b1} {b : \u03b1} {c : \u03b1}, (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) c a) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) b a) -> (Dvd.dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (MonoidWithZero.toSemigroupWithZero.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (lcm c b) a)) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) (lcm a b)) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1)))) \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} \u03b1 \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))) (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (CommMonoidWithZero.toMonoidWithZero.{u1} \u03b1 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} \u03b1 _inst_1))))))) (normalize.{u1} \u03b1 _inst_1 _inst_2) (lcm a b)) (lcm a b)) -> (NormalizedGCDMonoid.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align normalized_gcd_monoid_of_lcm normalizedGCDMonoidOfLCM\u2093'. -/\n/-- Define `normalized_gcd_monoid` on a structure just from the `lcm` and its properties. -/\nnoncomputable def normalizedGCDMonoidOfLCM [NormalizationMonoid \u03b1] [DecidableEq \u03b1] (lcm : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n    (dvd_lcm_left : \u2200 a b, a \u2223 lcm a b) (dvd_lcm_right : \u2200 a b, b \u2223 lcm a b)\n    (lcm_dvd : \u2200 {a b c}, c \u2223 a \u2192 b \u2223 a \u2192 lcm c b \u2223 a)\n    (normalize_lcm : \u2200 a b, normalize (lcm a b) = lcm a b) : NormalizedGCDMonoid \u03b1 :=\n  let exists_gcd a b := dvd_normalize_iff.2 (lcm_dvd (Dvd.intro b rfl) (Dvd.intro_left a rfl))\n  { (inferInstance : NormalizationMonoid \u03b1) 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      \u00b7 rw [h, eq_zero_of_zero_dvd (dvd_lcm_left _ _), MulZeroClass.mul_zero, MulZeroClass.zero_mul]\n      \u00b7\n        rw [h_1, eq_zero_of_zero_dvd (dvd_lcm_right _ _), MulZeroClass.mul_zero,\n          MulZeroClass.mul_zero]\n      rw [mul_comm, \u2190 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      \u00b7 apply normalize_idem\n      \u00b7 apply normalize_idem\n      have h0 : lcm a b \u2260 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\u2080 h0\n      refine' trans _ (Classical.choose_spec (exists_gcd a b))\n      conv_lhs =>\n        congr\n        rw [\u2190 normalize_lcm a b]\n      erw [\u2190 normalize.map_mul, \u2190 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      \u00b7 rw [h]\n        apply dvd_zero\n      \u00b7 exact (normalize_associated _).Dvd\n      have h0 : lcm a b \u2260 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 [\u2190 mul_dvd_mul_iff_left h0, \u2190 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      \u00b7 exact (normalize_associated _).Dvd\n      \u00b7 rw [h_1]\n        apply dvd_zero\n      have h0 : lcm a b \u2260 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 [\u2190 mul_dvd_mul_iff_left h0, \u2190 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      \u00b7 apply dvd_normalize_iff.2 ab\n      \u00b7 apply dvd_normalize_iff.2 ac\n      have h0 : lcm c b \u2260 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 [\u2190 mul_dvd_mul_iff_left h0, \u2190\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 \u27e8d, rfl\u27e9\n      rw [mul_eq_zero] at h_1\n      push_neg  at h_1\n      rw [mul_comm a, \u2190 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 \u03b1]\n    (h : \u2200 a b : \u03b1, \u2203 c : \u03b1, \u2200 d : \u03b1, d \u2223 a \u2227 d \u2223 b \u2194 d \u2223 c) : GCDMonoid \u03b1 :=\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 \u27e8ac, ab\u27e9\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 \u03b1] [DecidableEq \u03b1]\n    (h : \u2200 a b : \u03b1, \u2203 c : \u03b1, \u2200 d : \u03b1, d \u2223 a \u2227 d \u2223 b \u2194 d \u2223 c) : NormalizedGCDMonoid \u03b1 :=\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 \u27e8ac, ab\u27e9))\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 \u03b1]\n    (h : \u2200 a b : \u03b1, \u2203 c : \u03b1, \u2200 d : \u03b1, a \u2223 d \u2227 b \u2223 d \u2194 c \u2223 d) : GCDMonoid \u03b1 :=\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 \u27e8ac, ab\u27e9\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 \u03b1] [DecidableEq \u03b1]\n    (h : \u2200 a b : \u03b1, \u2203 c : \u03b1, \u2200 d : \u03b1, a \u2223 d \u2227 b \u2223 d \u2194 c \u2223 d) : NormalizedGCDMonoid \u03b1 :=\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 \u27e8ac, ab\u27e9))\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\u2080 : Type _) [CommGroupWithZero G\u2080] [DecidableEq G\u2080]\n\n-- see Note [lower instance priority]\ninstance (priority := 100) : NormalizedGCDMonoid G\u2080\n    where\n  normUnit x := if h : x = 0 then 1 else (Units.mk0 x h)\u207b\u00b9\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 \u2227 b = 0 then 0 else 1\n  lcm a b := if a = 0 \u2228 b = 0 then 0 else 1\n  gcd_dvd_left a b := by\n    split_ifs with h\n    \u00b7 rw [h.1]\n    \u00b7 exact one_dvd _\n  gcd_dvd_right a b := by\n    split_ifs with h\n    \u00b7 rw [h.2]\n    \u00b7 exact one_dvd _\n  dvd_gcd a b c hac hab := by\n    split_ifs with h; \u00b7 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; \u00b7 simp [ha]\n    by_cases hb : b = 0; \u00b7 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 \u2227 b = 0 then by simp [if_pos h] else by simp [if_neg h]\n  normalize_lcm a b := if h : a = 0 \u2228 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\u2080 : Type.{u1}) [_inst_1 : CommGroupWithZero.{u1} G\u2080] [_inst_2 : DecidableEq.{succ u1} G\u2080] {a : G\u2080}, (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.toGroupWithZero.{u1} G\u2080 _inst_1))))))))) -> (Eq.{succ u1} G\u2080 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))))))) (NormalizationMonoid.normUnit.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1) (CommGroupWithZero.normalizedGcdMonoid.{u1} G\u2080 _inst_1 (fun (a : G\u2080) (b : G\u2080) => _inst_2 a b))) a)) (Inv.inv.{u1} G\u2080 (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 (CommGroupWithZero.toGroupWithZero.{u1} G\u2080 _inst_1))) a))\nbut is expected to have type\n  forall (G\u2080 : Type.{u1}) [_inst_1 : CommGroupWithZero.{u1} G\u2080] [_inst_2 : DecidableEq.{succ u1} G\u2080] {a : G\u2080}, (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (CommMonoidWithZero.toZero.{u1} G\u2080 (CommGroupWithZero.toCommMonoidWithZero.{u1} G\u2080 _inst_1))))) -> (Eq.{succ u1} G\u2080 (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (NormalizationMonoid.normUnit.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1) (CommGroupWithZero.instNormalizedGCDMonoidCancelCommMonoidWithZero.{u1} G\u2080 _inst_1 (fun (a : G\u2080) (b : G\u2080) => _inst_2 a b))) a)) (Inv.inv.{u1} G\u2080 (CommGroupWithZero.toInv.{u1} G\u2080 _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align comm_group_with_zero.coe_norm_unit CommGroupWithZero.coe_normUnit\u2093'. -/\n@[simp]\ntheorem coe_normUnit {a : G\u2080} (h0 : a \u2260 0) : (\u2191(normUnit a) : G\u2080) = a\u207b\u00b9 := 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\u2080 : Type.{u1}) [_inst_1 : CommGroupWithZero.{u1} G\u2080] [_inst_2 : DecidableEq.{succ u1} G\u2080] {a : G\u2080}, (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.toGroupWithZero.{u1} G\u2080 _inst_1))))))))) -> (Eq.{succ u1} G\u2080 (coeFn.{succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) (fun (_x : MonoidWithZeroHom.{u1, u1} G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) => G\u2080 -> G\u2080) (MonoidWithZeroHom.hasCoeToFun.{u1, u1} G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) (normalize.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1) (CommGroupWithZero.normalizedGcdMonoid.{u1} G\u2080 _inst_1 (fun (a : G\u2080) (b : G\u2080) => _inst_2 a b)))) a) (OfNat.ofNat.{u1} G\u2080 1 (OfNat.mk.{u1} G\u2080 1 (One.one.{u1} G\u2080 (MulOneClass.toHasOne.{u1} G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.toGroupWithZero.{u1} G\u2080 _inst_1)))))))))\nbut is expected to have type\n  forall (G\u2080 : Type.{u1}) [_inst_1 : CommGroupWithZero.{u1} G\u2080] [_inst_2 : DecidableEq.{succ u1} G\u2080] {a : G\u2080}, (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (CommMonoidWithZero.toZero.{u1} G\u2080 (CommGroupWithZero.toCommMonoidWithZero.{u1} G\u2080 _inst_1))))) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) a) (FunLike.coe.{succ u1, succ u1, succ u1} (MonoidWithZeroHom.{u1, u1} G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) G\u2080 (fun (_x : G\u2080) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) _x) (MulHomClass.toFunLike.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) G\u2080 G\u2080 (MulOneClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))))) (MulOneClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))))) (MonoidHomClass.toMulHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) G\u2080 G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) (MonoidWithZeroHomClass.toMonoidHomClass.{u1, u1, u1} (MonoidWithZeroHom.{u1, u1} G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1))))) G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZeroHom.monoidWithZeroHomClass.{u1, u1} G\u2080 G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))) (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (CommMonoidWithZero.toMonoidWithZero.{u1} G\u2080 (CancelCommMonoidWithZero.toCommMonoidWithZero.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1)))))))) (normalize.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1) (NormalizedGCDMonoid.toNormalizationMonoid.{u1} G\u2080 (CommGroupWithZero.cancelCommMonoidWithZero.{u1} G\u2080 _inst_1) (CommGroupWithZero.instNormalizedGCDMonoidCancelCommMonoidWithZero.{u1} G\u2080 _inst_1 (fun (a : G\u2080) (b : G\u2080) => _inst_2 a b)))) a) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) a) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) a) (InvOneClass.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) a) (DivInvOneMonoid.toInvOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) a) (DivisionMonoid.toDivInvOneMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) a) (DivisionCommMonoid.toDivisionMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) a) (CommGroupWithZero.toDivisionCommMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : G\u2080) => G\u2080) a) _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align comm_group_with_zero.normalize_eq_one CommGroupWithZero.normalize_eq_one\u2093'. -/\ntheorem normalize_eq_one {a : G\u2080} (h0 : a \u2260 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 \u2102 E]\nvariables {F : Type*} [normed_add_comm_group F] [normed_space \u2102 F] [strict_convex_space \u211d F]\n\nvariables {M : Type*} [topological_space M] [compact_space M] [charted_space E M]\n  [smooth_manifold_with_corners \ud835\udcd8(\u2102, E) M]\n\n/-- A holomorphic function on a compact complex manifold is locally constant. -/\nprotected lemma is_locally_constant {f : M \u2192 F} (hf : mdifferentiable \ud835\udcd8(\u2102, E) \ud835\udcd8(\u2102, 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\u2082 hs\u2083 a ha b hb,\n  have hs\u2081 : is_compact s := hs\u2083.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\u2080` be a point where the value of `f` has maximal norm\n  obtain \u27e8p\u2080, hp\u2080s, hp\u2080\u27e9 := hs\u2081.exists_forall_ge hs' hf.continuous.norm.continuous_on,\n  -- we will show `f` agrees everywhere with `f p\u2080`\n  suffices : s \u2286 {r : M | f r = f p\u2080} \u2229 s,\n  { exact (this hb).1.trans (this ha).1.symm }, clear ha hb a b,\n  refine hs\u2082.subset_clopen _ \u27e8p\u2080, hp\u2080s, \u27e8rfl, hp\u2080s\u27e9\u27e9,\n  -- closedness of the set of points sent to `f p\u2080`\n  refine \u27e8_, (is_closed_singleton.preimage hf.continuous).inter hs\u2083.2\u27e9,\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 \u27e8hp : f p = _, hps\u27e9, -- let `p` be  in this set\n  have hps' : s \u2208 \ud835\udcdd p := hs\u2083.1.mem_nhds hps,\n  have key\u2081 : (chart_at E p).symm \u207b\u00b9' s \u2208 \ud835\udcdd (chart_at E p p),\n  { rw [\u2190 filter.mem_map, (chart_at E p).symm_map_nhds_eq (mem_chart_source E p)],\n    exact hps' },\n  have key\u2082 : (chart_at E p).target \u2208 \ud835\udcdd (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' : \u2200\u1da0 (z : E) in \ud835\udcdd (chart_at E p p), differentiable_at \u2102 (f \u2218 (chart_at E p).symm) z,\n  { refine filter.eventually_of_mem key\u2082 (\u03bb z hz, _),\n    have H\u2081 : (chart_at E p).symm z \u2208 (chart_at E p).source := (chart_at E p).map_target hz,\n    have H\u2082 : f ((chart_at E p).symm z) \u2208 (chart_at F (0:F)).source := trivial,\n    have H := (mdifferentiable_at_iff_of_mem_source H\u2081 H\u2082).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 \u2218 f \u2218 (chart_at E p).symm) (chart_at E p p),\n  { refine filter.eventually_of_mem key\u2081 (\u03bb z hz, _),\n    refine (hp\u2080 ((chart_at E p).symm z) hz).trans (_ : \u2016f p\u2080\u2016 \u2264 \u2016f _\u2016),\n    rw [\u2190 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 \u27e8U, hU, hUf\u27e9 := (complex.eventually_eq_of_is_local_max_norm hf' hf'').exists_mem,\n  have H\u2081 : (chart_at E p) \u207b\u00b9' U \u2208 \ud835\udcdd p := (chart_at E p).continuous_at (mem_chart_source E p) hU,\n  have H\u2082 : (chart_at E p).source \u2208 \ud835\udcdd 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\u2081 H\u2082)),\n  rintros q \u27e8hqs, hq : chart_at E p q \u2208 _, hq'\u27e9,\n  refine \u27e8_, hqs\u27e9,\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 \u2192 F} (hf : mdifferentiable \ud835\udcd8(\u2102, E) \ud835\udcd8(\u2102, 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 \u2261 v`,\nfor some value `v`. -/\nlemma exists_eq_const_of_compact_space [preconnected_space M]\n  {f : M \u2192 F} (hf : mdifferentiable \ud835\udcd8(\u2102, E) \ud835\udcd8(\u2102, F) f) :\n  \u2203 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 \u2192 Type v) extends Functor f where\n    /- Lift a normal value into an applicative context. -/\n    pure : \u03b1 \u2192 f \u03b1\n    /- Apply a function inside an applicative to a value inside an applicative. -/\n    apply : \u2200 {\u03b1 \u03b2 : Type u}, f (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n    /- Lift a funcion of arity 2 (2 parameters) to the applicative context. -/\n    liftA2 : (\u03b1 \u2192 \u03b2 \u2192 \u03b3) \u2192 f \u03b1 \u2192 f \u03b2 \u2192 f \u03b3 := \u03bb 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 \u03b1 \u2192 f \u03b2 \u2192 f \u03b2 := \u03bb 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 \u03b1 \u2192 f \u03b2 \u2192 f \u03b1 := liftA2 (Function.const \u03b2)\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 \u2192 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 : \u2200 x : f \u03b1, 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: \u2200 (x : \u03b1) (g : \u03b1 \u2192 \u03b2), 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: \u2200 {\u03b1 \u03b2 : Type u} (x : \u03b1) (g : f (\u03b1 \u2192 \u03b2)), g <*> pure x = pure (\u00b7 $ x) <*> g\n    /- A modified associativity property for <*>. -/\n    apply_comp : \u2200 {\u03b1 \u03b2 \u03b3: Type u} (x : f (\u03b2 \u2192 \u03b3)) (y : f (\u03b1 \u2192 \u03b2)) (z : f \u03b1), pure (@Function.comp \u03b1 \u03b2 \u03b3) <*> 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 : \u2200 (g : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (x : f \u03b1) (y : f \u03b2), 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 : \u2200 (a1 : f \u03b1) (a2 : f \u03b2), a1 *> a2 = (id <$ a1) <*> a2\n    /- If there is a custom <* definition it has to behave like the default one -/\n    seq_left_behaved : \u2200 (a1 : f \u03b1) (a2 : f \u03b2), a1 <* a2 = liftA2 (Function.const \u03b2) 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 : \u2200 (g : \u03b1 \u2192 \u03b2) (x : f \u03b1), g <$> x = app.pure g <*> x\n\n\n  namespace LawfulApplicative\n    variable {f : Type u \u2192 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 {\u03b1 \u03b2 : Type u} {g : f (\u03b1 \u2192 \u03b2)} {x : f \u03b1} : g <*> (pure id <*> x) = g <*> x := by rw [apply_id]\n    example {\u03b1 \u03b2 : Type u} {g : f (\u03b1 \u2192 \u03b2)} {x : f \u03b1} : pure id <*> (g <*> x) = g <*> x := by rw [apply_id]\n    example {\u03b1 \u03b2 \u03b3 \u03b4 \u03b5: Type u} {h : f (\u03b4 \u2192 \u03b5)}{g : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4} {x : \u03b1} { y : \u03b2} { z : \u03b3} : 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 : (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2 := \u03bb g a => pure g <*> a\n\n    -- First law\n    example : \u2200 {\u03b1 : Type u} (x : f \u03b1), apply_fmap id x = x := by\n      intro \u03b1 x\n      simp only [apply_fmap]\n      rw [apply_id]\n\n    -- Second law\n    example : \u2200 {\u03b1 \u03b2 \u03b3 : Type u} (g : \u03b1 \u2192 \u03b2) (h : \u03b2 \u2192 \u03b3) (x : f \u03b1), apply_fmap (h \u2218 g) x = apply_fmap h (apply_fmap g x) := by\n      intro \u03b1 \u03b2 \u03b3 g h x\n      simp only [apply_fmap]\n      rw [\u2190apply_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": "import Smt\n\ntheorem triv : Nat.zero + Nat.succ Nat.zero = Nat.succ Nat.zero := 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/Nat/Triv.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8104789178257654, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.4955122000936246}}
{"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 : \u2115) : \u2115 \u2192 \u2115 :=\n  well_founded.fix lt_wf div.F\n\nprotected instance has_div : Div \u2115 :=\n  { div := nat.div }\n\ntheorem div_def_aux (x : \u2115) (y : \u2115) : x / y = dite (0 < y \u2227 y \u2264 x) (fun (h : 0 < y \u2227 y \u2264 x) => (x - y) / y + 1) fun (h : \u00ac(0 < y \u2227 y \u2264 x)) => 0 :=\n  congr_fun (well_founded.fix_eq lt_wf div.F x) y\n\nprotected def mod (x : \u2115) : \u2115 \u2192 \u2115 :=\n  well_founded.fix lt_wf mod.F\n\nprotected instance has_mod : Mod \u2115 :=\n  { mod := nat.mod }\n\ntheorem mod_def_aux (x : \u2115) (y : \u2115) : x % y = dite (0 < y \u2227 y \u2264 x) (fun (h : 0 < y \u2227 y \u2264 x) => (x - y) % y) fun (h : \u00ac(0 < y \u2227 y \u2264 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 : \u2102)\n  (h\u2080 : a + b = 2 * c)\n  (h\u2081 : c = complex.I) :\n  a * c + b * c = -2 :=\nbegin\n  rw [\u2190 add_mul, h\u2080, h\u2081, 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": "import .add\nimport principia.mynat.induction\n\nnamespace hidden\nnamespace oldint\n\ntheorem intduction (p : oldint \u2192 Prop) :\np 0 \u2192 (\u2200 {n}, p n \u2192 p (n + 1)) \u2192 (\u2200 {n}, p n \u2192 p (n - 1)) \u2192\n\u2200 n, p n :=\nbegin\n  assume h0 hnext hprev,\n  intro n,\n  cases n, {\n    induction n with n hn, {\n      rwa [mynat.zz, \u2190coe_nat_eq, zero_nat],\n    }, {\n      rw \u2190coe_nat_eq at hn,\n      have h := hnext hn,\n      rwa [\u2190coe_nat_eq], -- magic?\n    },\n  }, {\n    induction n with n hn, {\n      rw [mynat.zz, \u2190neg_one],\n      apply @hprev 0,\n      assumption,\n    }, {\n      rw [\u2190neg_coe_succ, \u2190mynat.add_one_succ, \u2190nat_nat_add, neg_distr,\n          one_nat, \u2190sub_add_neg],\n      apply @hprev (-\u2191(mynat.succ n)),\n      rwa neg_coe_succ,\n    },\n  },\nend\n\nopen mynat\nprivate theorem one: (1: mynat) = succ 0 := rfl\n\ntheorem intduction_from {m : oldint} (p : oldint \u2192 Prop):\n(\u2200 {n}, p n \u2192 p (n + 1)) \u2192 (\u2200 {n}, p n \u2192 p (n - 1)) \u2192\np m \u2192 \u2200 n, p n :=\nbegin\n  assume hnext hprev hex,\n  suffices : p 0,\n    apply intduction, repeat {assumption},\n  cases m, {\n    revert m,\n    apply descend_to_zero,\n    intro m,\n    assume hsucc,\n    have := hprev hsucc,\n    rwa [sub_add_neg, neg_one, \u2190coe_nat_eq, nat_neg_add, sub_succ_succ,\n         nat_sub_zero] at this,\n  }, {\n    suffices : p (-1), from hnext this,\n    rw neg_one,\n    revert m,\n    apply descend_to_zero,\n    intro m,\n    assume hsucc,\n    have := hnext hsucc,\n    rwa [\u2190one_nat, neg_nat_add, one, sub_succ_succ, zero_sub_neg,\n        neg_succ] at this,\n  },\nend\n\nend oldint\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/experimental/oldint/induction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802476562641, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.49546080444292034}}
{"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} {\u03b1 : Type u} {motive : List \u03b1 \u2192 Sort u_1} (nil : motive [])\n  (cons : (head : \u03b1) \u2192 (tail : List \u03b1) \u2192 motive tail \u2192 motive (head :: tail)) :\n    (l : List \u03b1) \u2192 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 \u03b1 motive nil cons l\n  induction l with\n  | nil => rfl\n  | cons x xs ih =>\n    rw [List.recC, \u2190ih]\n\n/-- A computable version of `List._sizeOf_inst`. -/\ndef _sizeOf_instC.{u} (\u03b1 : Type u) [SizeOf \u03b1] : SizeOf (List \u03b1) 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 {\u03b1 \u03b2 \u03b3 \u03b4 \u03b5 \u03b6 : Type _}\n\ninstance [DecidableEq \u03b1] : SDiff (List \u03b1) :=\n  \u27e8List.diff\u27e9\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 \u03b1] (l : List \u03b1) (n : Nat) : \u03b1 :=\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 \u03b1] (n : Nat) (l : List \u03b1) : List \u03b1 :=\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 \u03b1] [One \u03b1] : List \u03b1 \u2192 \u03b1 :=\n  foldl (\u00b7 * \u00b7) 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 \u03b1] [Zero \u03b1] : List \u03b1 \u2192 \u03b1 :=\n  foldl (\u00b7 + \u00b7) 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 \u2192 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 \u2192 G\n  | [] => 1\n  | g :: [] => g\n  | g :: h :: t => g * h\u207b\u00b9 * 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 {\u03b1} {m : Type u \u2192 Type v} [Alternative m] (tac : \u03b1 \u2192 m PUnit) : List \u03b1 \u2192 m \u03b1 :=\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 \u2192 Type v}\n    [Monad m] {\u03b1 : Type u}\n    (p : \u03b1 \u2192 m (ULift Bool)) : List \u03b1 \u2192 m (Option \u03b1)\n  | [] => pure none\n  | x :: xs => do\n    let \u27e8px\u27e9 \u2190 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 \u2192 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) \u2192 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) \u2192 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 \u2192 Type w} [Monad m]\n\n/-- Monadic variant of `foldlIdx`. -/\ndef foldlIdxM {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b2 \u2192 \u03b1 \u2192 m \u03b2) (b : \u03b2) (as : List \u03b1) : m \u03b2 :=\n  as.foldlIdx\n    (fun i ma b => do\n      let a \u2190 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 {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 m \u03b2) (b : \u03b2) (as : List \u03b1) : m \u03b2 :=\n  as.foldrIdx\n    (fun i a mb => do\n      let b \u2190 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 \u2192 Type w} [Monad m]\n\n/-- Auxiliary definition for `mapIdxM'`. -/\ndef mapIdxMAux' {\u03b1} (f : \u2115 \u2192 \u03b1 \u2192 m PUnit) : \u2115 \u2192 List \u03b1 \u2192 m PUnit\n  | _, [] => pure \u27e8\u27e9\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' {\u03b1} (f : \u2115 \u2192 \u03b1 \u2192 m PUnit) (as : List \u03b1) : 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\u2082 List.Forall\u2082\n\n/-- `l.all\u2082 p` is equivalent to `\u2200 a \u2208 l, p a`, but unfolds directly to a conjunction, i.e.\n`list.all\u2082 p [0, 1, 2] = p 0 \u2227 p 1 \u2227 p 2`. -/\n@[simp]\ndef All\u2082 (p : \u03b1 \u2192 Prop) : List \u03b1 \u2192 Prop\n  | [] => True\n  | x :: [] => p x\n  | x :: l => p x \u2227 All\u2082 p l\n#align list.all\u2082 List.All\u2082\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 \u2264 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 : \u03b1) (ts : List \u03b1) (r : List \u03b2) : List \u03b1 \u2192 (List \u03b1 \u2192 \u03b2) \u2192 List \u03b1 \u00d7 List \u03b2\n  | [], _ => (ts, r)\n  | y :: ys, f =>\n    let (us, zs) := permutationsAux2 t ts r ys (fun x: List \u03b1 => 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\u2081 l\u2082` for all `l\u2081`, `l\u2082`, it suffices to have it for\n`l\u2082 = []` and to be able to pour the elements of `l\u2081` into `l\u2082`. -/\ndef permutationsAux.rec {C : List \u03b1 \u2192 List \u03b1 \u2192 Sort v} (H0 : \u2200 is, C [] is)\n    (H1 : \u2200 t ts is, C ts (t :: is) \u2192 C is [] \u2192 C (t :: ts) is) : \u2200 l\u2081 l\u2082, C l\u2081 l\u2082\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 \u03b1 \u2192 List \u03b1 \u2192 List (List \u03b1) :=\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 \u03b1) : List (List \u03b1) :=\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 : \u03b1) : List \u03b1 \u2192 List (List \u03b1)\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 \u03b1 \u2192 List (List \u03b1)\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\u2093 -- 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 : \u03b1 \u2192 Prop) [DecidablePred p] : List \u03b1 \u2192 Option \u03b1 \u00d7 List \u03b1\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 \" \u00d7\u02e2 \" => 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 : \u03b1} {l : List \u03b1} : Chain R a (b :: l) \u2194 R a b \u2227 Chain R b l :=\n  \u27e8fun p \u21a6 by cases p with | cons n p => exact \u27e8n, p\u27e9,\n   fun \u27e8n, p\u27e9 \u21a6 p.cons n\u27e9\n#align list.chain_cons List.chain_cons\n\ninstance decidableChain [DecidableRel R] (a : \u03b1) (l : List \u03b1) :\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 \u03b1) : 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 (\u2260)`.\n\n     dedup [1, 0, 2, 2, 1] = [0, 2, 1] -/\ndef dedup [DecidableEq \u03b1] : List \u03b1 \u2192 List \u03b1 :=\n  pwFilter (\u00b7 \u2260 \u00b7)\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 \u2260; for example, `destutter' (\u2260) 1 [2, 2, 1, 1] = [1, 2, 1]`,\n`destutter' (\u2260) 1, [2, 3, 3] = [1, 2, 3]`, `destutter' (<) 1 [2, 5, 2, 3, 4, 9] = [1, 2, 5, 9]`. -/\ndef destutter' (R : \u03b1 \u2192 \u03b1 \u2192 Prop) [DecidableRel R] : \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\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 \u2208 l`,\n`R a b` holds. Mostly used with \u2260; for example, `destutter (\u2260) [1, 2, 2, 1, 1] = [1, 2, 1]`,\n`destutter (\u2260) [1, 2, 3, 3] = [1, 2, 3]`, `destutter (<) [1, 2, 5, 2, 3, 4, 9] = [1, 2, 5, 9]`. -/\ndef destutter (R : \u03b1 \u2192 \u03b1 \u2192 Prop) [DecidableRel R] : List \u03b1 \u2192 List \u03b1\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 : \u03b1 \u2192 Prop) [DecidablePred p] (l : List \u03b1)\n\n/-- Given a decidable predicate `p` and a proof of existence of `a \u2208 l` such that `p a`,\nchoose the first element with this property. This version returns both `a` and proofs\nof `a \u2208 l` and `p a`. -/\ndef chooseX : \u2200 l : List \u03b1, \u2200 _ : \u2203 a, a \u2208 l \u2227 p a, { a // a \u2208 l \u2227 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 \u27e8l, \u27e8mem_cons.mpr <| Or.inl rfl, pl\u27e9\u27e9\n    else\n      let \u27e8a, \u27e8a_mem_ls, pa\u27e9\u27e9 :=\n        chooseX ls\n          (hp.imp fun _ \u27e8o, h\u2082\u27e9 => \u27e8(mem_cons.mp o).resolve_left fun e => pl <| e \u25b8 h\u2082, h\u2082\u27e9)\n      \u27e8a, \u27e8mem_cons.mpr <| Or.inr a_mem_ls, pa\u27e9\u27e9\n#align list.choose_x List.chooseX\n\n/-- Given a decidable predicate `p` and a proof of existence of `a \u2208 l` such that `p a`,\nchoose the first element with this property. This version returns `a : \u03b1`, and properties\nare given by `choose_mem` and `choose_property`. -/\ndef choose (hp : \u2203 a, a \u2208 l \u2227 p a) : \u03b1 :=\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 \u00d7 l`.\nThat is, for each `e \u2208 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] {\u03b1} (f : \u03b1 \u2192 \u03b1 \u2192 m Unit) : List \u03b1 \u2192 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    _ \u2190 f h h\n    _ \u2190 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 \u2192 Type v} [Applicative F] {\u03b1 \u03b2 : Type _} (f : \u03b1 \u2192 F \u03b2)\n    : List \u03b1 \u2192 F (List \u03b2)\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\u2082`. `map\u2082Left' f as bs` applies `f` to each\npair of elements `a\u1d62 \u2208 as` and `b\u1d62 \u2208 bs`. If `bs` is shorter than `as`, `f` is\napplied to `none` for the remaining `a\u1d62`. Returns the results of the `f`\napplications and the remaining `bs`.\n\n```\nmap\u2082Left' prod.mk [1, 2] ['a'] = ([(1, some 'a'), (2, none)], [])\n\nmap\u2082Left' prod.mk [1] ['a', 'b'] = ([(1, some 'a')], ['b'])\n```\n-/\n@[simp]\ndef map\u2082Left' (f : \u03b1 \u2192 Option \u03b2 \u2192 \u03b3) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3 \u00d7 List \u03b2\n  | [], bs => ([], bs)\n  | a :: as, [] => ((a :: as).map fun a => f a none, [])\n  | a :: as, b :: bs =>\n    let rec' := map\u2082Left' f as bs\n    (f a (some b) :: rec'.fst, rec'.snd)\n#align list.map\u2082_left' List.map\u2082Left'\n\n/-- Right-biased version of `List.map\u2082`. `map\u2082Right' f as bs` applies `f` to each\npair of elements `a\u1d62 \u2208 as` and `b\u1d62 \u2208 bs`. If `as` is shorter than `bs`, `f` is\napplied to `none` for the remaining `b\u1d62`. Returns the results of the `f`\napplications and the remaining `as`.\n\n```\nmap\u2082Right' prod.mk [1] ['a', 'b'] = ([(some 1, 'a'), (none, 'b')], [])\n\nmap\u2082Right' prod.mk [1, 2] ['a'] = ([(some 1, 'a')], [2])\n```\n-/\ndef map\u2082Right' (f : Option \u03b1 \u2192 \u03b2 \u2192 \u03b3) (as : List \u03b1) (bs : List \u03b2) : List \u03b3 \u00d7 List \u03b1 :=\n  map\u2082Left' (flip f) bs as\n#align list.map\u2082_right' List.map\u2082Right'\n\n\n/-- Left-biased version of `List.map\u2082`. `map\u2082Left f as bs` applies `f` to each pair\n`a\u1d62 \u2208 as` and `b\u1d62 \u200c\u2208 bs`. If `bs` is shorter than `as`, `f` is applied to `none`\nfor the remaining `a\u1d62`.\n\n```\nmap\u2082Left Prod.mk [1, 2] ['a'] = [(1, some 'a'), (2, none)]\n\nmap\u2082Left Prod.mk [1] ['a', 'b'] = [(1, some 'a')]\n\nmap\u2082Left f as bs = (map\u2082Left' f as bs).fst\n```\n-/\n@[simp]\ndef map\u2082Left (f : \u03b1 \u2192 Option \u03b2 \u2192 \u03b3) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3\n  | [], _ => []\n  | a :: as, [] => (a :: as).map fun a => f a none\n  | a :: as, b :: bs => f a (some b) :: map\u2082Left f as bs\n#align list.map\u2082_left List.map\u2082Left\n\n/-- Right-biased version of `List.map\u2082`. `map\u2082Right f as bs` applies `f` to each\npair `a\u1d62 \u2208 as` and `b\u1d62 \u200c\u2208 bs`. If `as` is shorter than `bs`, `f` is applied to\n`none` for the remaining `b\u1d62`.\n\n```\nmap\u2082Right Prod.mk [1, 2] ['a'] = [(some 1, 'a')]\n\nmap\u2082Right Prod.mk [1] ['a', 'b'] = [(some 1, 'a'), (none, 'b')]\n\nmap\u2082Right f as bs = (map\u2082Right' f as bs).fst\n```\n-/\ndef map\u2082Right (f : Option \u03b1 \u2192 \u03b2 \u2192 \u03b3) (as : List \u03b1) (bs : List \u03b2) : List \u03b3 :=\n  map\u2082Left (flip f) bs as\n#align list.map\u2082_right List.map\u2082Right\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (xs : List \u03b1) (chunk_size := 1024) : List \u03b2 :=\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 $ \u03bb \u27e8x, y, z\u27e9, f x y z`.\n-/\n\n/-- Ternary version of `List.zipWith`. -/\ndef zipWith3 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3 \u2192 List \u03b4\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4 \u2192 \u03b5) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3 \u2192 List \u03b4 \u2192 List \u03b5\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4 \u2192 \u03b5 \u2192 \u03b6) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3 \u2192 List \u03b4 \u2192 List \u03b5 \u2192 List \u03b6\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 \u03b1 \u2192 List Bool \u2192 List \u03b1 \u2192 List \u03b1\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\n-/\nimport geometry.manifold.smooth_manifold_with_corners\nimport analysis.inner_product_space.pi_L2\n\n/-!\n# Constructing examples of manifolds over \u211d\n\nWe introduce the necessary bits to be able to define manifolds modelled over `\u211d^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 \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n)` for the model space\n  used to define `n`-dimensional real manifolds with boundary\n* `model_with_corners \u211d (euclidean_space \u211d (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* `\ud835\udce1 n` for the identity model with corners on `euclidean_space \u211d (fin n)`\n* `\ud835\udce1\u2202 n` for `model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n)`.\n\nFor instance, if a manifold `M` is boundaryless, smooth and modelled on `euclidean_space \u211d (fin m)`,\nand `N` is smooth with boundary modelled on `euclidean_half_space n`, and `f : M \u2192 N` is a smooth\nmap, then the derivative of `f` can be written simply as `mfderiv (\ud835\udce1 m) (\ud835\udce1\u2202 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 `\u211d^n`, used to model manifolds with boundary. We only define it when\n`1 \u2264 n`, as the definition only makes sense in this case.\n-/\ndef euclidean_half_space (n : \u2115) [has_zero (fin n)] : Type :=\n{x : euclidean_space \u211d (fin n) // 0 \u2264 x 0}\n\n/--\nThe quadrant in `\u211d^n`, used to model manifolds with corners, made of all vectors with nonnegative\ncoordinates.\n-/\ndef euclidean_quadrant (n : \u2115) : Type := {x : euclidean_space \u211d (fin n) // \u2200i:fin n, 0 \u2264 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 : \u2115}\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) := \u27e8\u27e80, le_rfl\u27e9\u27e9\ninstance : inhabited (euclidean_quadrant n) := \u27e8\u27e80, \u03bb i, le_rfl\u27e9\u27e9\n\nlemma range_half_space (n : \u2115) [has_zero (fin n)] :\n  range (\u03bbx : euclidean_half_space n, x.val) = {y | 0 \u2264 y 0} :=\nby simp\n\nlemma range_quadrant (n : \u2115) :\n  range (\u03bbx : euclidean_quadrant n, x.val) = {y | \u2200i:fin n, 0 \u2264 y i} :=\nby simp\n\nend\n\n/--\nDefinition of the model with corners `(euclidean_space \u211d (fin n), euclidean_half_space n)`, used as\na model for manifolds with boundary. In the locale `manifold`, use the shortcut `\ud835\udce1\u2202 n`.\n-/\ndef model_with_corners_euclidean_half_space (n : \u2115) [has_zero (fin n)] :\n  model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := \u03bbx, \u27e8update x 0 (max (x 0) 0), by simp [le_refl]\u27e9,\n  source      := univ,\n  target      := {x | 0 \u2264 x 0},\n  map_source' := \u03bbx hx, x.property,\n  map_target' := \u03bbx hx, mem_univ _,\n  left_inv'   := \u03bb \u27e8xval, xprop\u27e9 hx, begin\n    rw [subtype.mk_eq_mk, update_eq_iff],\n    exact \u27e8max_eq_left xprop, \u03bb i _, rfl\u27e9\n  end,\n  right_inv'  := \u03bbx hx, update_eq_iff.2 \u27e8max_eq_left hx, \u03bb i _, rfl\u27e9,\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on \u211d _ :=\n      unique_diff_on.pi (fin n) (\u03bb _, \u211d) _ _ (\u03bb i \u2208 ({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 \u211d (fin n), euclidean_quadrant n)`, used as a\nmodel for manifolds with corners -/\ndef model_with_corners_euclidean_quadrant (n : \u2115) :\n  model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_quadrant n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := \u03bbx, \u27e8\u03bbi, max (x i) 0, \u03bbi, by simp only [le_refl, or_true, le_max_iff]\u27e9,\n  source      := univ,\n  target      := {x | \u2200 i, 0 \u2264 x i},\n  map_source' := \u03bbx hx, by simpa only [subtype.range_val] using x.property,\n  map_target' := \u03bbx hx, mem_univ _,\n  left_inv'   := \u03bb \u27e8xval, xprop\u27e9 hx, by { ext i, simp only [subtype.coe_mk, xprop i, max_eq_left] },\n  right_inv' := \u03bb 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 \u211d _ :=\n      unique_diff_on.univ_pi (fin n) (\u03bb _, \u211d) _ (\u03bb 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 $ \u03bb i,\n    (continuous_id.max continuous_const).comp (continuous_apply i)) _ }\n\nlocalized \"notation (name := model_with_corners_self.euclidean) `\ud835\udce1 `n :=\n  (model_with_corners_self \u211d (euclidean_space \u211d (fin n)) :\n    model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_space \u211d (fin n)))\" in manifold\nlocalized \"notation (name := model_with_corners_euclidean_half_space.euclidean) `\ud835\udce1\u2202 `n :=\n  (model_with_corners_euclidean_half_space n :\n    model_with_corners \u211d (euclidean_space \u211d (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 : \u211d) [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      := \u03bb(z : Icc x y), \u27e8\u03bbi, z.val - x, sub_nonneg.mpr z.property.1\u27e9,\n  inv_fun     := \u03bbz, \u27e8min (z.val 0 + x) y, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y))]\u27e9,\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 \u27e8z, hz\u27e9 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 \u27e8z, hz\u27e9 h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x + z 0 \u2264 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 : \u211d | z < y} := is_open_Iio,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : \u211d | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space \u211d (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (\u03bb _, \u211d) _ 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 (\u03bb (z : \u211d) (i : fin 1), z - x) :=\n      continuous.sub (continuous_pi $ \u03bbi, 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 (\u03bb z : \u211d, min (z + x) y) :=\n      (continuous_id.add continuous_const).min continuous_const,\n    have B : continuous (\u03bbz : euclidean_space \u211d (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 : \u211d) [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      := \u03bb(z : Icc x y), \u27e8\u03bbi, y - z.val, sub_nonneg.mpr z.property.2\u27e9,\n  inv_fun     := \u03bbz,\n    \u27e8max (y - z.val 0) x, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y)), sub_eq_add_neg]\u27e9,\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 \u27e8z, hz\u27e9 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 \u27e8z, hz\u27e9 h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x \u2264 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 : \u211d | x < z} := is_open_Ioi,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : \u211d | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space \u211d (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (\u03bb _, \u211d) _ 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 (\u03bb (z : \u211d) (i : fin 1), y - z) :=\n      continuous_const.sub (continuous_pi (\u03bbi, 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 (\u03bb z : \u211d, max (y - z) x) :=\n      (continuous_const.sub continuous_id).max continuous_const,\n    have B : continuous (\u03bbz : euclidean_space \u211d (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 : \u211d) [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 := \u03bbz, if z.val < y then Icc_left_chart x y else Icc_right_chart x y,\n  mem_chart_source := \u03bbz, 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 := \u03bb z, by by_cases h' : (z : \u211d) < y; simp [h'] }\n\n/--\nThe manifold structure on `[x, y]` is smooth.\n-/\ninstance Icc_smooth_manifold (x y : \u211d) [fact (x < y)] :\n  smooth_manifold_with_corners (\ud835\udce1\u2202 1) (Icc x y) :=\nbegin\n  have M : cont_diff_on \u211d \u221e (\u03bbz : euclidean_space \u211d (fin 1), - z + (\u03bbi, 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^\u221e` 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 _ \u27e8\u27e8hz\u2081, hz\u2082\u27e9, \u27e8\u27e8z, hz\u2080\u27e9, rfl\u27e9\u27e9,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      update_same, max_eq_left, hz\u2080, lt_sub_iff_add_lt] with mfld_simps at hz\u2081 hz\u2082,\n    rw [min_eq_left hz\u2081.le, lt_add_iff_pos_left] at hz\u2082,\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\u2081.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 _ \u27e8\u27e8hz\u2081, hz\u2082\u27e9, \u27e8z, hz\u2080\u27e9, rfl\u27e9,\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\u2080] with mfld_simps at hz\u2081 hz\u2082,\n    rw lt_sub_comm at hz\u2081,\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\u2080, hz\u2081.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 : \u211d) 1) := by apply_instance\ninstance : smooth_manifold_with_corners (\ud835\udce1\u2202 1) (Icc (0 : \u211d) 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) \u2192 option (proposal pid_t value_t)\n                                            \u2192 option (proposal pid_t value_t)\n| none      none      := none\n| (some p\u2081) none      := some p\u2081\n| none      (some p\u2082) := some p\u2082\n| (some p\u2081) (some p\u2082) := if (p\u2081.bal < p\u2082.bal) then some p\u2082 else some p\u2081\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) \u2192 value_t \u2192 value_t\n| none     := (\u03bb v, v)\n| (some p) := (\u03bb _, 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  \u2203 res, merge (some p_left) p_or = some res \u2227 res.bal \u2265 p_left.bal :=\nbegin\ncases p_or,\n  case none : {\n    exact \u27e8p_left, by refl, le_refl p_left.bal\u27e9\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 \u27e8p_right, by refl, le_of_lt h\u27e9 },\n    rw if_neg h,\n    exact \u27e8p_left, by refl, le_refl p_left.bal\u27e9\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  \u2203 res, merge p_or (some p_right) = some res \u2227 res.bal \u2265 p_right.bal :=\nbegin\ncases p_or,\n  case none : {\n    exact \u27e8p_right, by refl, le_refl p_right.bal\u27e9\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 \u27e8p_right, by refl, le_refl p_right.bal\u27e9 },\n    rw if_neg h,\n    exact \u27e8p_left, by refl, le_of_not_lt h\u27e9\n  }\nend\n\n-- Merging two proposals results in either the left one or the right one.\nlemma merge_is_one_of (p_or\u2081 p_or\u2082 : option (proposal pid_t value_t)) :\n  merge p_or\u2081 p_or\u2082 = p_or\u2081 \u2228 merge p_or\u2081 p_or\u2082 = p_or\u2082 :=\nbegin\ncases p_or\u2081,\n  case none : {\n    cases p_or\u2082,\n      case none : { unfold merge, left, refl },\n      case some : p\u2082 { unfold merge, right, refl }\n  },\n  case some : p\u2081 {\n    cases p_or\u2082,\n      case none : { unfold merge, left, refl },\n      case some : p\u2082 {\n        unfold merge,\n        cases decidable.em (p\u2081.bal < p\u2082.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 \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P`, where `M` and `N`\nare modules over `R` and `S` respectively, `P` is a module over both `R\u2082` and `S\u2082` with\ncommuting actions, and `\u03c1\u2081\u2082 : R \u2192+* R\u2082` and `\u03c3\u2081\u2082 : S \u2192+* S\u2082`.\n\n## Main declarations\n\n* `LinearMap.mk\u2082`: a constructor for bilinear maps,\n  taking an unbundled function together with proof witnesses of bilinearity\n* `LinearMap.flip`: turns a bilinear map `M \u00d7 N \u2192 P` into `N \u00d7 M \u2192 P`\n* `LinearMap.lcomp` and `LinearMap.llcomp`: composition of linear maps as a bilinear map\n* `LinearMap.compl\u2082`: composition of a bilinear map `M \u00d7 N \u2192 P` with a linear map `Q \u2192 M`\n* `LinearMap.compr\u2082`: composition of a bilinear map `M \u00d7 N \u2192 P` with a linear map `Q \u2192 N`\n* `LinearMap.lsmul`: scalar multiplication as a bilinear map `R \u00d7 M \u2192 M`\n\n## Tags\n\nbilinear\n-/\n\n\nnamespace LinearMap\n\nsection Semiring\n\n-- the `\u2097` 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\u2082 : Type _} [Semiring R\u2082] {S\u2082 : Type _} [Semiring S\u2082]\n\nvariable {M : Type _} {N : Type _} {P : Type _}\n\nvariable {M\u2082 : Type _} {N\u2082 : Type _} {P\u2082 : Type _}\n\nvariable {N\u2097 : Type _} {P\u2097 : Type _}\n\nvariable {M' : Type _} {N' : Type _} {P' : Type _}\n\nvariable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P]\n\nvariable [AddCommMonoid M\u2082] [AddCommMonoid N\u2082] [AddCommMonoid P\u2082]\n\nvariable [AddCommMonoid N\u2097] [AddCommMonoid P\u2097]\n\nvariable [AddCommGroup M'] [AddCommGroup N'] [AddCommGroup P']\n\nvariable [Module R M] [Module S N] [Module R\u2082 P] [Module S\u2082 P]\n\nvariable [Module R M\u2082] [Module S N\u2082] [Module R P\u2082] [Module S\u2082 P\u2082]\n\nvariable [Module R P\u2097] [Module S P\u2097]\n\nvariable [Module R M'] [Module S N'] [Module R\u2082 P'] [Module S\u2082 P']\n\nvariable [SMulCommClass S\u2082 R\u2082 P] [SMulCommClass S R P\u2097] [SMulCommClass S\u2082 R\u2082 P']\n\nvariable [SMulCommClass S\u2082 R P\u2082]\n\nvariable {\u03c1\u2081\u2082 : R \u2192+* R\u2082} {\u03c3\u2081\u2082 : S \u2192+* S\u2082}\n\nvariable (\u03c1\u2081\u2082 \u03c3\u2081\u2082)\n\n/-- Create a bilinear map from a function that is semilinear in each component.\nSee `mk\u2082'` and `mk\u2082` for the linear case. -/\ndef mk\u2082'\u209b\u2097 (f : M \u2192 N \u2192 P) (H1 : \u2200 m\u2081 m\u2082 n, f (m\u2081 + m\u2082) n = f m\u2081 n + f m\u2082 n)\n    (H2 : \u2200 (c : R) (m n), f (c \u2022 m) n = \u03c1\u2081\u2082 c \u2022 f m n)\n    (H3 : \u2200 m n\u2081 n\u2082, f m (n\u2081 + n\u2082) = f m n\u2081 + f m n\u2082)\n    (H4 : \u2200 (c : S) (m n), f m (c \u2022 n) = \u03c3\u2081\u2082 c \u2022 f m n) : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] 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\u2081 m\u2082 := LinearMap.ext <| H1 m\u2081 m\u2082\n  map_smul' c m := LinearMap.ext <| H2 c m\n#align linear_map.mk\u2082'\u209b\u2097 LinearMap.mk\u2082'\u209b\u2097\n\nvariable {\u03c1\u2081\u2082 \u03c3\u2081\u2082}\n\n@[simp]\ntheorem mk\u2082'\u209b\u2097_apply (f : M \u2192 N \u2192 P) {H1 H2 H3 H4} (m : M) (n : N) :\n    (mk\u2082'\u209b\u2097 \u03c1\u2081\u2082 \u03c3\u2081\u2082 f H1 H2 H3 H4 : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) m n = f m n := rfl\n#align linear_map.mk\u2082'\u209b\u2097_apply LinearMap.mk\u2082'\u209b\u2097_apply\n\nvariable (R S)\n\n/-- Create a bilinear map from a function that is linear in each component.\nSee `mk\u2082` for the special case where both arguments come from modules over the same ring. -/\ndef mk\u2082' (f : M \u2192 N \u2192 P\u2097) (H1 : \u2200 m\u2081 m\u2082 n, f (m\u2081 + m\u2082) n = f m\u2081 n + f m\u2082 n)\n    (H2 : \u2200 (c : R) (m n), f (c \u2022 m) n = c \u2022 f m n)\n    (H3 : \u2200 m n\u2081 n\u2082, f m (n\u2081 + n\u2082) = f m n\u2081 + f m n\u2082)\n    (H4 : \u2200 (c : S) (m n), f m (c \u2022 n) = c \u2022 f m n) : M \u2192\u2097[R] N \u2192\u2097[S] P\u2097 :=\n  mk\u2082'\u209b\u2097 (RingHom.id R) (RingHom.id S) f H1 H2 H3 H4\n#align linear_map.mk\u2082' LinearMap.mk\u2082'\n\nvariable {R S}\n\n@[simp]\ntheorem mk\u2082'_apply (f : M \u2192 N \u2192 P\u2097) {H1 H2 H3 H4} (m : M) (n : N) :\n    (mk\u2082' R S f H1 H2 H3 H4 : M \u2192\u2097[R] N \u2192\u2097[S] P\u2097) m n = f m n := rfl\n#align linear_map.mk\u2082'_apply LinearMap.mk\u2082'_apply\n\ntheorem ext\u2082 {f g : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P} (H : \u2200 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\u2082 LinearMap.ext\u2082\n\ntheorem congr_fun\u2082 {f g : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] 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\u2082 LinearMap.congr_fun\u2082\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 \u00d7 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 \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) : N \u2192\u209b\u2097[\u03c3\u2081\u2082] M \u2192\u209b\u2097[\u03c1\u2081\u2082] P :=\n  mk\u2082'\u209b\u2097 \u03c3\u2081\u2082 \u03c1\u2081\u2082 (fun n m => f m n) (fun n\u2081 n\u2082 m => (f m).map_add _ _)\n    (fun c n  m  => (f m).map_smul\u209b\u2097 _ _)\n    (fun n m\u2081 m\u2082 => by simp only [map_add, add_apply])\n    (fun c n  m  => by simp only [map_smul\u209b\u2097, smul_apply])\n#align linear_map.flip LinearMap.flip\n\nend\n\n@[simp]\ntheorem flip_apply (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] 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 \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) : f.flip.flip = f :=\n  LinearMap.ext\u2082 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 \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P} (H : flip f = flip g) : f = g :=\n  ext\u2082 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\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (y) : f 0 y = 0 :=\n  (flip f y).map_zero\n#align linear_map.map_zero\u2082 LinearMap.map_zero\u2082\n\ntheorem map_neg\u2082 (f : M' \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P') (x y) : f (-x) y = -f x y :=\n  (flip f y).map_neg _\n#align linear_map.map_neg\u2082 LinearMap.map_neg\u2082\n\ntheorem map_sub\u2082 (f : M' \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] 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\u2082 LinearMap.map_sub\u2082\n\ntheorem map_add\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (x\u2081 x\u2082 y) : f (x\u2081 + x\u2082) y = f x\u2081 y + f x\u2082 y :=\n  (flip f y).map_add _ _\n#align linear_map.map_add\u2082 LinearMap.map_add\u2082\n\ntheorem map_smul\u2082 (f : M\u2082 \u2192\u2097[R] N\u2082 \u2192\u209b\u2097[\u03c3\u2081\u2082] P\u2082) (r : R) (x y) : f (r \u2022 x) y = r \u2022 f x y :=\n  (flip f y).map_smul _ _\n#align linear_map.map_smul\u2082 LinearMap.map_smul\u2082\n\ntheorem map_smul\u209b\u2097\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (r : R) (x y) : f (r \u2022 x) y = \u03c1\u2081\u2082 r \u2022 f x y :=\n  (flip f y).map_smul\u209b\u2097 _ _\n#align linear_map.map_smul\u209b\u2097\u2082 LinearMap.map_smul\u209b\u2097\u2082\n\ntheorem map_sum\u2082 {\u03b9 : Type _} (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (t : Finset \u03b9) (x : \u03b9 \u2192 M) (y) :\n    f (\u2211 i in t, x i) y = \u2211 i in t, f (x i) y :=\n  (flip f y).map_sum\n#align linear_map.map_sum\u2082 LinearMap.map_sum\u2082\n\n/-- Restricting a bilinear map in the second entry -/\ndef domRestrict\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (q : Submodule S N) : M \u2192\u209b\u2097[\u03c1\u2081\u2082] q \u2192\u209b\u2097[\u03c3\u2081\u2082] P\n    where\n  toFun m := (f m).domRestrict q\n  map_add' m\u2081 m\u2082 := 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\u209b\u2097, domRestrict_apply, smul_apply]\n#align linear_map.dom_restrict\u2082 LinearMap.domRestrict\u2082\n\ntheorem domRestrict\u2082_apply (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (q : Submodule S N) (x : M) (y : q) :\n    f.domRestrict\u2082 q x y = f x y := rfl\n#align linear_map.dom_restrict\u2082_apply LinearMap.domRestrict\u2082_apply\n\n/-- Restricting a bilinear map in both components -/\ndef domRestrict\u2081\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (p : Submodule R M) (q : Submodule S N) :\n    p \u2192\u209b\u2097[\u03c1\u2081\u2082] q \u2192\u209b\u2097[\u03c3\u2081\u2082] P :=\n  (f.domRestrict p).domRestrict\u2082 q\n#align linear_map.dom_restrict\u2081\u2082 LinearMap.domRestrict\u2081\u2082\n\ntheorem domRestrict\u2081\u2082_apply (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (p : Submodule R M) (q : Submodule S N)\n    (x : p) (y : q) : f.domRestrict\u2081\u2082 p q x y = f x y := rfl\n#align linear_map.dom_restrict\u2081\u2082_apply LinearMap.domRestrict\u2081\u2082_apply\n\nend Semiring\n\nsection CommSemiring\n\nvariable {R : Type _} [CommSemiring R] {R\u2082 : Type _} [CommSemiring R\u2082]\n\nvariable {R\u2083 : Type _} [CommSemiring R\u2083] {R\u2084 : Type _} [CommSemiring R\u2084]\n\nvariable {M : Type _} {N : Type _} {P : Type _} {Q : Type _}\n\nvariable {M\u2097 : Type _} {N\u2097 : Type _} {P\u2097 : Type _} {Q\u2097 Q\u2097' : Type _}\n\nvariable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q]\n\nvariable [AddCommMonoid M\u2097] [AddCommMonoid N\u2097] [AddCommMonoid P\u2097]\n\nvariable [AddCommMonoid Q\u2097] [AddCommMonoid Q\u2097']\n\nvariable [Module R M] [Module R\u2082 N] [Module R\u2083 P] [Module R\u2084 Q]\n\nvariable [Module R M\u2097] [Module R N\u2097] [Module R P\u2097] [Module R Q\u2097] [Module R Q\u2097']\n\nvariable {\u03c3\u2081\u2082 : R \u2192+* R\u2082} {\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083} {\u03c3\u2081\u2083 : R \u2192+* R\u2083}\n\nvariable {\u03c3\u2084\u2082 : R\u2084 \u2192+* R\u2082} {\u03c3\u2084\u2083 : R\u2084 \u2192+* R\u2083}\n\nvariable [RingHomCompTriple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083] [RingHomCompTriple \u03c3\u2084\u2082 \u03c3\u2082\u2083 \u03c3\u2084\u2083]\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\u2082'` for the common case when `R = S`. -/\ndef mk\u2082 (f : M \u2192 N\u2097 \u2192 P\u2097) (H1 : \u2200 m\u2081 m\u2082 n, f (m\u2081 + m\u2082) n = f m\u2081 n + f m\u2082 n)\n    (H2 : \u2200 (c : R) (m n), f (c \u2022 m) n = c \u2022 f m n)\n    (H3 : \u2200 m n\u2081 n\u2082, f m (n\u2081 + n\u2082) = f m n\u2081 + f m n\u2082)\n    (H4 : \u2200 (c : R) (m n), f m (c \u2022 n) = c \u2022 f m n) : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097 :=\n  mk\u2082' R R f H1 H2 H3 H4\n#align linear_map.mk\u2082 LinearMap.mk\u2082\n\n@[simp]\ntheorem mk\u2082_apply (f : M \u2192 N\u2097 \u2192 P\u2097) {H1 H2 H3 H4} (m : M) (n : N\u2097) :\n    (mk\u2082 R f H1 H2 H3 H4 : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) m n = f m n := rfl\n#align linear_map.mk\u2082_apply LinearMap.mk\u2082_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 \u2192 N \u2192 P`,\nchange the order of variables and get a linear map from `N` to linear maps from `M` to `P`. -/\ndef lflip : (M \u2192\u209b\u2097[\u03c3\u2081\u2083] N \u2192\u209b\u2097[\u03c3\u2082\u2083] P) \u2192\u2097[R\u2083] N \u2192\u209b\u2097[\u03c3\u2082\u2083] M \u2192\u209b\u2097[\u03c3\u2081\u2083] 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 \u2192\u209b\u2097[\u03c3\u2081\u2083] N \u2192\u209b\u2097[\u03c3\u2082\u2083] 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\u2097)\n\n/-- Composing a linear map `M \u2192 N` and a linear map `N \u2192 P` to form a linear map `M \u2192 P`. -/\ndef lcomp (f : M \u2192\u2097[R] N\u2097) : (N\u2097 \u2192\u2097[R] P\u2097) \u2192\u2097[R] M \u2192\u2097[R] P\u2097 :=\n  flip <| LinearMap.comp (flip id) f\n#align linear_map.lcomp LinearMap.lcomp\n\nvariable {R P\u2097}\n\n@[simp]\ntheorem lcomp_apply (f : M \u2192\u2097[R] N\u2097) (g : N\u2097 \u2192\u2097[R] P\u2097) (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 \u2192\u2097[R] N\u2097) (g : N\u2097 \u2192\u2097[R] P\u2097) : lcomp R P\u2097 f g = g \u2218\u2097 f := rfl\n#align linear_map.lcomp_apply' LinearMap.lcomp_apply'\n\nvariable (P \u03c3\u2082\u2083)\n\n/-- Composing a semilinear map `M \u2192 N` and a semilinear map `N \u2192 P` to form a semilinear map\n`M \u2192 P` is itself a linear map. -/\ndef lcomp\u209b\u2097 (f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] N) : (N \u2192\u209b\u2097[\u03c3\u2082\u2083] P) \u2192\u2097[R\u2083] M \u2192\u209b\u2097[\u03c3\u2081\u2083] P :=\n  flip <| LinearMap.comp (flip id) f\n#align linear_map.lcomp\u209b\u2097 LinearMap.lcomp\u209b\u2097\n\nvariable {P \u03c3\u2082\u2083}\n\n@[simp]\n\n\nvariable (R M N\u2097 P\u2097)\n\n/-- Composing a linear map `M \u2192 N` and a linear map `N \u2192 P` to form a linear map `M \u2192 P`. -/\ndef llcomp : (N\u2097 \u2192\u2097[R] P\u2097) \u2192\u2097[R] (M \u2192\u2097[R] N\u2097) \u2192\u2097[R] M \u2192\u2097[R] P\u2097 :=\n  flip\n    { toFun := lcomp R P\u2097\n      map_add' := fun _f _f' => ext\u2082 fun g _x => g.map_add _ _\n      map_smul' := fun (_c : R) _f => ext\u2082 fun g _x => g.map_smul _ _ }\n#align linear_map.llcomp LinearMap.llcomp\n\nvariable {R M N\u2097 P\u2097}\n\nsection\n\n@[simp]\ntheorem llcomp_apply (f : N\u2097 \u2192\u2097[R] P\u2097) (g : M \u2192\u2097[R] N\u2097) (x : M) :\n    llcomp R M N\u2097 P\u2097 f g x = f (g x) := rfl\n#align linear_map.llcomp_apply LinearMap.llcomp_apply\n\ntheorem llcomp_apply' (f : N\u2097 \u2192\u2097[R] P\u2097) (g : M \u2192\u2097[R] N\u2097) : llcomp R M N\u2097 P\u2097 f g = f \u2218\u2097 g := rfl\n#align linear_map.llcomp_apply' LinearMap.llcomp_apply'\n\nend\n\n/-- Composing a linear map `Q \u2192 N` and a bilinear map `M \u2192 N \u2192 P` to\nform a bilinear map `M \u2192 Q \u2192 P`. -/\ndef compl\u2082 (g : Q \u2192\u209b\u2097[\u03c3\u2084\u2082] N) : M \u2192\u209b\u2097[\u03c3\u2081\u2083] Q \u2192\u209b\u2097[\u03c3\u2084\u2083] P :=\n  (lcomp\u209b\u2097 _ _ g).comp f\n#align linear_map.compl\u2082 LinearMap.compl\u2082\n\n@[simp]\ntheorem compl\u2082_apply (g : Q \u2192\u209b\u2097[\u03c3\u2084\u2082] N) (m : M) (q : Q) : f.compl\u2082 g m q = f m (g q) := rfl\n#align linear_map.compl\u2082_apply LinearMap.compl\u2082_apply\n\n@[simp]\ntheorem compl\u2082_id : f.compl\u2082 LinearMap.id = f := by\n  ext\n  rw [compl\u2082_apply, id_coe, id.def]\n#align linear_map.compl\u2082_id LinearMap.compl\u2082_id\n\n/-- Composing linear maps `Q \u2192 M` and `Q' \u2192 N` with a bilinear map `M \u2192 N \u2192 P` to\nform a bilinear map `Q \u2192 Q' \u2192 P`. -/\ndef compl\u2081\u2082 (f : M\u2097 \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) (g : Q\u2097 \u2192\u2097[R] M\u2097) (g' : Q\u2097' \u2192\u2097[R] N\u2097) :\n    Q\u2097 \u2192\u2097[R] Q\u2097' \u2192\u2097[R] P\u2097 :=\n  (f.comp g).compl\u2082 g'\n#align linear_map.compl\u2081\u2082 LinearMap.compl\u2081\u2082\n\n@[simp]\ntheorem compl\u2081\u2082_apply (f : M\u2097 \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) (g : Q\u2097 \u2192\u2097[R] M\u2097) (g' : Q\u2097' \u2192\u2097[R] N\u2097) (x : Q\u2097)\n    (y : Q\u2097') : f.compl\u2081\u2082 g g' x y = f (g x) (g' y) := rfl\n#align linear_map.compl\u2081\u2082_apply LinearMap.compl\u2081\u2082_apply\n\n@[simp]\ntheorem compl\u2081\u2082_id_id (f : M\u2097 \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) : f.compl\u2081\u2082 LinearMap.id LinearMap.id = f := by\n  ext\n  simp_rw [compl\u2081\u2082_apply, id_coe, id.def]\n#align linear_map.compl\u2081\u2082_id_id LinearMap.compl\u2081\u2082_id_id\n\ntheorem compl\u2081\u2082_inj {f\u2081 f\u2082 : M\u2097 \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097} {g : Q\u2097 \u2192\u2097[R] M\u2097} {g' : Q\u2097' \u2192\u2097[R] N\u2097}\n    (h\u2097 : Function.Surjective g) (h\u1d63 : Function.Surjective g') :\n    f\u2081.compl\u2081\u2082 g g' = f\u2082.compl\u2081\u2082 g g' \u2194 f\u2081 = f\u2082 := by\n  constructor <;> intro h\n  \u00b7 -- B\u2081.comp l r = B\u2082.comp l r \u2192 B\u2081 = B\u2082\n    ext (x y)\n    cases' h\u2097 x with x' hx\n    subst hx\n    cases' h\u1d63 y with y' hy\n    subst hy\n    convert LinearMap.congr_fun\u2082 h x' y' using 0\n  \u00b7 -- B\u2081 = B\u2082 \u2192 B\u2081.comp l r = B\u2082.comp l r\n    subst h; rfl\n#align linear_map.compl\u2081\u2082_inj LinearMap.compl\u2081\u2082_inj\n\n/-- Composing a linear map `P \u2192 Q` and a bilinear map `M \u2192 N \u2192 P` to\nform a bilinear map `M \u2192 N \u2192 Q`. -/\ndef compr\u2082 (f : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) (g : P\u2097 \u2192\u2097[R] Q\u2097) : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] Q\u2097 :=\n  llcomp R N\u2097 P\u2097 Q\u2097 g \u2218\u2097 f\n#align linear_map.compr\u2082 LinearMap.compr\u2082\n\n@[simp]\ntheorem compr\u2082_apply (f : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) (g : P\u2097 \u2192\u2097[R] Q\u2097) (m : M) (n : N\u2097) :\n    f.compr\u2082 g m n = g (f m n) := rfl\n#align linear_map.compr\u2082_apply LinearMap.compr\u2082_apply\n\nvariable (R M)\n\n/-- Scalar multiplication as a bilinear map `R \u2192 M \u2192 M`. -/\ndef lsmul : R \u2192\u2097[R] M \u2192\u2097[R] M :=\n  mk\u2082 R (\u00b7 \u2022 \u00b7) 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 \u2022 m := rfl\n#align linear_map.lsmul_apply LinearMap.lsmul_apply\n\nend CommSemiring\n\nsection CommRing\n\nvariable {R R\u2082 S S\u2082 M N P : Type _}\n\nvariable {M\u2097 N\u2097 P\u2097 : Type _}\n\nvariable [CommRing R] [CommRing S] [CommRing R\u2082] [CommRing S\u2082]\n\nsection AddCommGroup\n\nvariable [AddCommGroup M] [AddCommGroup N] [AddCommGroup P]\n\nvariable [Module R M] [Module S N] [Module R\u2082 P] [Module S\u2082 P]\n\ntheorem lsmul_injective [NoZeroSMulDivisors R M] {x : R} (hx : x \u2260 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 \u2260 0) :\n  LinearMap.ker (LinearMap.lsmul R M a) = \u22a5 :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u03c3-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\u03c3-algebras on a fixed set `\u03b1` form a complete lattice. Here we order\n\u03c3-algebras by writing `m\u2081 \u2264 m\u2082` if every set which is `m\u2081`-measurable is\nalso `m\u2082`-measurable (that is, `m\u2081` is a subset of `m\u2082`). In particular, any\ncollection of subsets of `\u03b1` generates a smallest \u03c3-algebra which\ncontains all of them. A function `f : \u03b1 \u2192 \u03b2` induces a Galois connection\nbetween the lattices of \u03c3-algebras on `\u03b1` and `\u03b2`.\n\nA measurable equivalence between measurable spaces is an equivalence\nwhich respects the \u03c3-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 \u2208 f` includes a measurable\nset `t \u2208 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 \u03c0-\u03bb theorem, which appears\nhere as an induction principle `induction_on_inter`. Suppose `s` is a\ncollection of subsets of `\u03b1` such that the intersection of two members\nof `s` belongs to `s` whenever it is nonempty. Let `m` be the \u03c3-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 `\u03b1 \u2243\u1d50 \u03b2` for measurable equivalences between the measurable spaces `\u03b1` and `\u03b2`.\n  This should not be confused with `\u2243\u2098` which is used for diffeomorphisms between manifolds.\n\n## Implementation notes\n\nMeasurability of a function `f : \u03b1 \u2192 \u03b2` 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, \u03c3-algebra, measurable function, measurable equivalence, dynkin system,\n\u03c0-\u03bb theorem, \u03c0-system\n-/\n\n/-- A measurable space is a space equipped with a \u03c3-algebra. -/\nclass measurable_space (\u03b1 : Type u_7) \nwhere\n  is_measurable' : set \u03b1 \u2192 Prop\n  is_measurable_empty : is_measurable' \u2205\n  is_measurable_compl : \u2200 (s : set \u03b1), is_measurable' s \u2192 is_measurable' (s\u1d9c)\n  is_measurable_Union : \u2200 (f : \u2115 \u2192 set \u03b1), (\u2200 (i : \u2115), is_measurable' (f i)) \u2192 is_measurable' (set.Union fun (i : \u2115) => f i)\n\nprotected instance order_dual.measurable_space {\u03b1 : Type u_1} [h : measurable_space \u03b1] : measurable_space (order_dual \u03b1) :=\n  h\n\n/-- `is_measurable s` means that `s` is measurable (in the ambient measure space on `\u03b1`) -/\ndef is_measurable {\u03b1 : Type u_1} [measurable_space \u03b1] : set \u03b1 \u2192 Prop :=\n  measurable_space.is_measurable' _inst_1\n\n@[simp] theorem is_measurable.empty {\u03b1 : Type u_1} [measurable_space \u03b1] : is_measurable \u2205 :=\n  measurable_space.is_measurable_empty _inst_1\n\ntheorem is_measurable.compl {\u03b1 : Type u_1} {s : set \u03b1} [measurable_space \u03b1] : is_measurable s \u2192 is_measurable (s\u1d9c) :=\n  measurable_space.is_measurable_compl _inst_1 s\n\ntheorem is_measurable.of_compl {\u03b1 : Type u_1} {s : set \u03b1} [measurable_space \u03b1] (h : is_measurable (s\u1d9c)) : is_measurable s :=\n  compl_compl s \u25b8 is_measurable.compl h\n\n@[simp] theorem is_measurable.compl_iff {\u03b1 : Type u_1} {s : set \u03b1} [measurable_space \u03b1] : is_measurable (s\u1d9c) \u2194 is_measurable s :=\n  { mp := is_measurable.of_compl, mpr := is_measurable.compl }\n\n@[simp] theorem is_measurable.univ {\u03b1 : Type u_1} [measurable_space \u03b1] : is_measurable set.univ :=\n  eq.mpr (id (Eq.refl (is_measurable set.univ)))\n    (eq.mp ((fun (\u1fb0 \u1fb0_1 : set \u03b1) (e_2 : \u1fb0 = \u1fb0_1) => congr_arg is_measurable e_2) (\u2205\u1d9c) set.univ set.compl_empty)\n      (is_measurable.compl is_measurable.empty))\n\ntheorem subsingleton.is_measurable {\u03b1 : Type u_1} [measurable_space \u03b1] [subsingleton \u03b1] {s : set \u03b1} : is_measurable s :=\n  subsingleton.set_cases is_measurable.empty is_measurable.univ s\n\ntheorem is_measurable.congr {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set \u03b1} {t : set \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [encodable \u03b2] {f : \u03b2 \u2192 set \u03b1} (h : \u2200 (b : \u03b2), is_measurable (f b)) (n : \u2115) : is_measurable (set.Union fun (b : \u03b2) => set.Union fun (H : b \u2208 encodable.decode2 \u03b2 n) => f b) :=\n  encodable.Union_decode2_cases is_measurable.empty h\n\ntheorem is_measurable.Union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [encodable \u03b2] {f : \u03b2 \u2192 set \u03b1} (h : \u2200 (b : \u03b2), is_measurable (f b)) : is_measurable (set.Union fun (b : \u03b2) => f b) := sorry\n\ntheorem is_measurable.bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] {f : \u03b2 \u2192 set \u03b1} {s : set \u03b2} (hs : set.countable s) (h : \u2200 (b : \u03b2), b \u2208 s \u2192 is_measurable (f b)) : is_measurable (set.Union fun (b : \u03b2) => set.Union fun (H : b \u2208 s) => f b) := sorry\n\ntheorem set.finite.is_measurable_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] {f : \u03b2 \u2192 set \u03b1} {s : set \u03b2} (hs : set.finite s) (h : \u2200 (b : \u03b2), b \u2208 s \u2192 is_measurable (f b)) : is_measurable (set.Union fun (b : \u03b2) => set.Union fun (H : b \u2208 s) => f b) :=\n  is_measurable.bUnion (set.finite.countable hs) h\n\ntheorem finset.is_measurable_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] {f : \u03b2 \u2192 set \u03b1} (s : finset \u03b2) (h : \u2200 (b : \u03b2), b \u2208 s \u2192 is_measurable (f b)) : is_measurable (set.Union fun (b : \u03b2) => set.Union fun (H : b \u2208 s) => f b) :=\n  set.finite.is_measurable_bUnion (finset.finite_to_set s) h\n\ntheorem is_measurable.sUnion {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set (set \u03b1)} (hs : set.countable s) (h : \u2200 (t : set \u03b1), t \u2208 s \u2192 is_measurable t) : is_measurable (\u22c3\u2080s) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (\u22c3\u2080s))) set.sUnion_eq_bUnion)) (is_measurable.bUnion hs h)\n\ntheorem set.finite.is_measurable_sUnion {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set (set \u03b1)} (hs : set.finite s) (h : \u2200 (t : set \u03b1), t \u2208 s \u2192 is_measurable t) : is_measurable (\u22c3\u2080s) :=\n  is_measurable.sUnion (set.finite.countable hs) h\n\ntheorem is_measurable.Union_Prop {\u03b1 : Type u_1} [measurable_space \u03b1] {p : Prop} {f : p \u2192 set \u03b1} (hf : \u2200 (b : p), is_measurable (f b)) : is_measurable (set.Union fun (b : p) => f b) := sorry\n\ntheorem is_measurable.Inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [encodable \u03b2] {f : \u03b2 \u2192 set \u03b1} (h : \u2200 (b : \u03b2), is_measurable (f b)) : is_measurable (set.Inter fun (b : \u03b2) => f b) := sorry\n\ntheorem is_measurable.Union_fintype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [fintype \u03b2] {f : \u03b2 \u2192 set \u03b1} (h : \u2200 (b : \u03b2), is_measurable (f b)) : is_measurable (set.Union fun (b : \u03b2) => f b) :=\n  is_measurable.Union h\n\ntheorem is_measurable.Inter_fintype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [fintype \u03b2] {f : \u03b2 \u2192 set \u03b1} (h : \u2200 (b : \u03b2), is_measurable (f b)) : is_measurable (set.Inter fun (b : \u03b2) => f b) :=\n  is_measurable.Inter h\n\ntheorem is_measurable.bInter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] {f : \u03b2 \u2192 set \u03b1} {s : set \u03b2} (hs : set.countable s) (h : \u2200 (b : \u03b2), b \u2208 s \u2192 is_measurable (f b)) : is_measurable (set.Inter fun (b : \u03b2) => set.Inter fun (H : b \u2208 s) => f b) := sorry\n\ntheorem set.finite.is_measurable_bInter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] {f : \u03b2 \u2192 set \u03b1} {s : set \u03b2} (hs : set.finite s) (h : \u2200 (b : \u03b2), b \u2208 s \u2192 is_measurable (f b)) : is_measurable (set.Inter fun (b : \u03b2) => set.Inter fun (H : b \u2208 s) => f b) :=\n  is_measurable.bInter (set.finite.countable hs) h\n\ntheorem finset.is_measurable_bInter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] {f : \u03b2 \u2192 set \u03b1} (s : finset \u03b2) (h : \u2200 (b : \u03b2), b \u2208 s \u2192 is_measurable (f b)) : is_measurable (set.Inter fun (b : \u03b2) => set.Inter fun (H : b \u2208 s) => f b) :=\n  set.finite.is_measurable_bInter (finset.finite_to_set s) h\n\ntheorem is_measurable.sInter {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set (set \u03b1)} (hs : set.countable s) (h : \u2200 (t : set \u03b1), t \u2208 s \u2192 is_measurable t) : is_measurable (\u22c2\u2080s) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (\u22c2\u2080s))) set.sInter_eq_bInter)) (is_measurable.bInter hs h)\n\ntheorem set.finite.is_measurable_sInter {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set (set \u03b1)} (hs : set.finite s) (h : \u2200 (t : set \u03b1), t \u2208 s \u2192 is_measurable t) : is_measurable (\u22c2\u2080s) :=\n  is_measurable.sInter (set.finite.countable hs) h\n\ntheorem is_measurable.Inter_Prop {\u03b1 : Type u_1} [measurable_space \u03b1] {p : Prop} {f : p \u2192 set \u03b1} (hf : \u2200 (b : p), is_measurable (f b)) : is_measurable (set.Inter fun (b : p) => f b) := sorry\n\n@[simp] theorem is_measurable.union {\u03b1 : Type u_1} [measurable_space \u03b1] {s\u2081 : set \u03b1} {s\u2082 : set \u03b1} (h\u2081 : is_measurable s\u2081) (h\u2082 : is_measurable s\u2082) : is_measurable (s\u2081 \u222a s\u2082) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (s\u2081 \u222a s\u2082))) set.union_eq_Union))\n    (is_measurable.Union (iff.mpr bool.forall_bool { left := h\u2082, right := h\u2081 }))\n\n@[simp] theorem is_measurable.inter {\u03b1 : Type u_1} [measurable_space \u03b1] {s\u2081 : set \u03b1} {s\u2082 : set \u03b1} (h\u2081 : is_measurable s\u2081) (h\u2082 : is_measurable s\u2082) : is_measurable (s\u2081 \u2229 s\u2082) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (is_measurable (s\u2081 \u2229 s\u2082))) (set.inter_eq_compl_compl_union_compl s\u2081 s\u2082)))\n    (is_measurable.compl (is_measurable.union (is_measurable.compl h\u2081) (is_measurable.compl h\u2082)))\n\n@[simp] theorem is_measurable.diff {\u03b1 : Type u_1} [measurable_space \u03b1] {s\u2081 : set \u03b1} {s\u2082 : set \u03b1} (h\u2081 : is_measurable s\u2081) (h\u2082 : is_measurable s\u2082) : is_measurable (s\u2081 \\ s\u2082) :=\n  is_measurable.inter h\u2081 (is_measurable.compl h\u2082)\n\n@[simp] theorem is_measurable.disjointed {\u03b1 : Type u_1} [measurable_space \u03b1] {f : \u2115 \u2192 set \u03b1} (h : \u2200 (i : \u2115), is_measurable (f i)) (n : \u2115) : is_measurable (set.disjointed f n) :=\n  set.disjointed_induct (h n) fun (t : set \u03b1) (i : \u2115) (ht : is_measurable t) => is_measurable.diff ht (h i)\n\n@[simp] theorem is_measurable.const {\u03b1 : Type u_1} [measurable_space \u03b1] (p : Prop) : is_measurable (set_of fun (a : \u03b1) => p) := sorry\n\n/-- Every set has a measurable superset. Declare this as local instance as needed. -/\ntheorem nonempty_measurable_superset {\u03b1 : Type u_1} [measurable_space \u03b1] (s : set \u03b1) : Nonempty (Subtype fun (t : set \u03b1) => s \u2286 t \u2227 is_measurable t) :=\n  Nonempty.intro { val := set.univ, property := { left := set.subset_univ s, right := is_measurable.univ } }\n\ntheorem measurable_space.ext {\u03b1 : Type u_1} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} : (\u2200 (s : set \u03b1), measurable_space.is_measurable' m\u2081 s \u2194 measurable_space.is_measurable' m\u2082 s) \u2192 m\u2081 = m\u2082 := sorry\n\ntheorem measurable_space.ext_iff {\u03b1 : Type u_1} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} : m\u2081 = m\u2082 \u2194 \u2200 (s : set \u03b1), measurable_space.is_measurable' m\u2081 s \u2194 measurable_space.is_measurable' m\u2082 s :=\n  { mp := fun (\u1fb0 : m\u2081 = m\u2082) => Eq._oldrec (fun (s : set \u03b1) => iff.refl (measurable_space.is_measurable' m\u2081 s)) \u1fb0,\n    mpr := measurable_space.ext }\n\n/-- A typeclass mixin for `measurable_space`s such that each singleton is measurable. -/\nclass measurable_singleton_class (\u03b1 : Type u_7) [measurable_space \u03b1] \nwhere\n  is_measurable_singleton : \u2200 (x : \u03b1), is_measurable (singleton x)\n\ntheorem is_measurable_eq {\u03b1 : Type u_1} [measurable_space \u03b1] [measurable_singleton_class \u03b1] {a : \u03b1} : is_measurable (set_of fun (x : \u03b1) => x = a) :=\n  is_measurable_singleton a\n\ntheorem is_measurable.insert {\u03b1 : Type u_1} [measurable_space \u03b1] [measurable_singleton_class \u03b1] {s : set \u03b1} (hs : is_measurable s) (a : \u03b1) : is_measurable (insert a s) :=\n  is_measurable.union (is_measurable_singleton a) hs\n\n@[simp] theorem is_measurable_insert {\u03b1 : Type u_1} [measurable_space \u03b1] [measurable_singleton_class \u03b1] {a : \u03b1} {s : set \u03b1} : is_measurable (insert a s) \u2194 is_measurable s := sorry\n\ntheorem set.finite.is_measurable {\u03b1 : Type u_1} [measurable_space \u03b1] [measurable_singleton_class \u03b1] {s : set \u03b1} (hs : set.finite s) : is_measurable s :=\n  set.finite.induction_on hs is_measurable.empty\n    fun (a : \u03b1) (s : set \u03b1) (ha : \u00aca \u2208 s) (hsf : set.finite s) (hsm : is_measurable s) => is_measurable.insert hsm a\n\nprotected theorem finset.is_measurable {\u03b1 : Type u_1} [measurable_space \u03b1] [measurable_singleton_class \u03b1] (s : finset \u03b1) : is_measurable \u2191s :=\n  set.finite.is_measurable (finset.finite_to_set s)\n\nnamespace measurable_space\n\n\nprotected instance partial_order {\u03b1 : Type u_1} : partial_order (measurable_space \u03b1) :=\n  partial_order.mk (fun (m\u2081 m\u2082 : measurable_space \u03b1) => is_measurable' m\u2081 \u2264 is_measurable' m\u2082)\n    (preorder.lt._default fun (m\u2081 m\u2082 : measurable_space \u03b1) => is_measurable' m\u2081 \u2264 is_measurable' m\u2082) sorry sorry sorry\n\n/-- The smallest \u03c3-algebra containing a collection `s` of basic sets -/\ninductive generate_measurable {\u03b1 : Type u_1} (s : set (set \u03b1)) : set \u03b1 \u2192 Prop\nwhere\n| basic : \u2200 (u : set \u03b1), u \u2208 s \u2192 generate_measurable s u\n| empty : generate_measurable s \u2205\n| compl : \u2200 (s_1 : set \u03b1), generate_measurable s s_1 \u2192 generate_measurable s (s_1\u1d9c)\n| union : \u2200 (f : \u2115 \u2192 set \u03b1), (\u2200 (n : \u2115), generate_measurable s (f n)) \u2192 generate_measurable s (set.Union fun (i : \u2115) => f i)\n\n/-- Construct the smallest measure space containing a collection of basic sets -/\ndef generate_from {\u03b1 : Type u_1} (s : set (set \u03b1)) : measurable_space \u03b1 :=\n  mk (generate_measurable s) generate_measurable.empty generate_measurable.compl generate_measurable.union\n\ntheorem is_measurable_generate_from {\u03b1 : Type u_1} {s : set (set \u03b1)} {t : set \u03b1} (ht : t \u2208 s) : is_measurable' (generate_from s) t :=\n  generate_measurable.basic t ht\n\ntheorem generate_from_le {\u03b1 : Type u_1} {s : set (set \u03b1)} {m : measurable_space \u03b1} (h : \u2200 (t : set \u03b1), t \u2208 s \u2192 is_measurable' m t) : generate_from s \u2264 m := sorry\n\ntheorem generate_from_le_iff {\u03b1 : Type u_1} {s : set (set \u03b1)} (m : measurable_space \u03b1) : generate_from s \u2264 m \u2194 s \u2286 set_of fun (t : set \u03b1) => is_measurable' m t :=\n  { mp := fun (h : generate_from s \u2264 m) (u : set \u03b1) (hu : u \u2208 s) => h u (is_measurable_generate_from hu),\n    mpr := fun (h : s \u2286 set_of fun (t : set \u03b1) => is_measurable' m t) => generate_from_le h }\n\n@[simp] theorem generate_from_is_measurable {\u03b1 : Type u_1} [measurable_space \u03b1] : generate_from (set_of fun (s : set \u03b1) => is_measurable s) = _inst_1 :=\n  le_antisymm (generate_from_le fun (_x : set \u03b1) => id) fun (s : set \u03b1) => is_measurable_generate_from\n\n/-- If `g` is a collection of subsets of `\u03b1` such that the `\u03c3`-algebra generated from `g` contains\nthe same sets as `g`, then `g` was already a `\u03c3`-algebra. -/\nprotected def mk_of_closure {\u03b1 : Type u_1} (g : set (set \u03b1)) (hg : (set_of fun (t : set \u03b1) => is_measurable' (generate_from g) t) = g) : measurable_space \u03b1 :=\n  mk (fun (s : set \u03b1) => s \u2208 g) sorry sorry sorry\n\ntheorem mk_of_closure_sets {\u03b1 : Type u_1} {s : set (set \u03b1)} {hs : (set_of fun (t : set \u03b1) => 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 `\u03c3`-algebras on `\u03b1` and `set (set \u03b1)` by using `generate_from`\n  on one side and the collection of measurable sets on the other side. -/\ndef gi_generate_from {\u03b1 : Type u_1} : galois_insertion generate_from fun (m : measurable_space \u03b1) => set_of fun (t : set \u03b1) => is_measurable t :=\n  galois_insertion.mk\n    (fun (g : set (set \u03b1)) (hg : (set_of fun (t : set \u03b1) => is_measurable t) \u2264 g) =>\n      measurable_space.mk_of_closure g sorry)\n    sorry sorry sorry\n\nprotected instance complete_lattice {\u03b1 : Type u_1} : complete_lattice (measurable_space \u03b1) :=\n  galois_insertion.lift_complete_lattice gi_generate_from\n\nprotected instance inhabited {\u03b1 : Type u_1} : Inhabited (measurable_space \u03b1) :=\n  { default := \u22a4 }\n\ntheorem is_measurable_bot_iff {\u03b1 : Type u_1} {s : set \u03b1} : is_measurable s \u2194 s = \u2205 \u2228 s = set.univ := sorry\n\n@[simp] theorem is_measurable_top {\u03b1 : Type u_1} {s : set \u03b1} : is_measurable s :=\n  trivial\n\n@[simp] theorem is_measurable_inf {\u03b1 : Type u_1} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} {s : set \u03b1} : is_measurable s \u2194 is_measurable s \u2227 is_measurable s :=\n  iff.rfl\n\n@[simp] theorem is_measurable_Inf {\u03b1 : Type u_1} {ms : set (measurable_space \u03b1)} {s : set \u03b1} : is_measurable s \u2194 \u2200 (m : measurable_space \u03b1), m \u2208 ms \u2192 is_measurable s := sorry\n\n@[simp] theorem is_measurable_infi {\u03b1 : Type u_1} {\u03b9 : Sort u_2} {m : \u03b9 \u2192 measurable_space \u03b1} {s : set \u03b1} : is_measurable s \u2194 \u03b9 \u2192 is_measurable s := sorry\n\ntheorem is_measurable_sup {\u03b1 : Type u_1} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} {s : set \u03b1} : is_measurable s \u2194 generate_measurable (is_measurable' m\u2081 \u222a is_measurable' m\u2082) s :=\n  iff.refl (is_measurable s)\n\ntheorem is_measurable_Sup {\u03b1 : Type u_1} {ms : set (measurable_space \u03b1)} {s : set \u03b1} : is_measurable s \u2194\n  generate_measurable (set_of fun (s : set \u03b1) => \u2203 (m : measurable_space \u03b1), \u2203 (H : m \u2208 ms), is_measurable s) s := sorry\n\ntheorem is_measurable_supr {\u03b1 : Type u_1} {\u03b9 : Sort u_2} {m : \u03b9 \u2192 measurable_space \u03b1} {s : set \u03b1} : is_measurable s \u2194 generate_measurable (set_of fun (s : set \u03b1) => \u2203 (i : \u03b9), 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 \u03b2`\n  whose preimage under `f` is measurable. -/\nprotected def map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (m : measurable_space \u03b1) : measurable_space \u03b2 :=\n  mk (fun (s : set \u03b2) => is_measurable' m (f \u207b\u00b9' s)) (is_measurable_empty m) sorry sorry\n\n@[simp] theorem map_id {\u03b1 : Type u_1} {m : measurable_space \u03b1} : measurable_space.map id m = m :=\n  ext fun (s : set \u03b1) => iff.rfl\n\n@[simp] theorem map_comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {m : measurable_space \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} : measurable_space.map g (measurable_space.map f m) = measurable_space.map (g \u2218 f) m :=\n  ext fun (s : set \u03b3) => iff.rfl\n\n/-- The reverse image of a measure space under a function. `comap f m` contains the sets `s : set \u03b1`\n  such that `s` is the `f`-preimage of a measurable set in `\u03b2`. -/\nprotected def comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (m : measurable_space \u03b2) : measurable_space \u03b1 :=\n  mk (fun (s : set \u03b1) => \u2203 (s' : set \u03b2), is_measurable' m s' \u2227 f \u207b\u00b9' s' = s) sorry sorry sorry\n\n@[simp] theorem comap_id {\u03b1 : Type u_1} {m : measurable_space \u03b1} : measurable_space.comap id m = m := sorry\n\n@[simp] theorem comap_comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {m : measurable_space \u03b1} {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b2} : measurable_space.comap g (measurable_space.comap f m) = measurable_space.comap (f \u2218 g) m := sorry\n\ntheorem comap_le_iff_le_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m : measurable_space \u03b1} {m' : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} : measurable_space.comap f m' \u2264 m \u2194 m' \u2264 measurable_space.map f m := sorry\n\ntheorem gc_comap_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) : galois_connection (measurable_space.comap f) (measurable_space.map f) :=\n  fun (f_1 : measurable_space \u03b2) (g : measurable_space \u03b1) => comap_le_iff_le_map\n\ntheorem map_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} {f : \u03b1 \u2192 \u03b2} (h : m\u2081 \u2264 m\u2082) : measurable_space.map f m\u2081 \u2264 measurable_space.map f m\u2082 :=\n  galois_connection.monotone_u (gc_comap_map f) h\n\ntheorem monotone_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} : monotone (measurable_space.map f) :=\n  fun (a b : measurable_space \u03b1) (h : a \u2264 b) => map_mono h\n\ntheorem comap_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} {g : \u03b2 \u2192 \u03b1} (h : m\u2081 \u2264 m\u2082) : measurable_space.comap g m\u2081 \u2264 measurable_space.comap g m\u2082 :=\n  galois_connection.monotone_l (gc_comap_map g) h\n\ntheorem monotone_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {g : \u03b2 \u2192 \u03b1} : monotone (measurable_space.comap g) :=\n  fun (a b : measurable_space \u03b1) (h : a \u2264 b) => comap_mono h\n\n@[simp] theorem comap_bot {\u03b1 : Type u_1} {\u03b2 : Type u_2} {g : \u03b2 \u2192 \u03b1} : measurable_space.comap g \u22a5 = \u22a5 :=\n  galois_connection.l_bot (gc_comap_map g)\n\n@[simp] theorem comap_sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} {g : \u03b2 \u2192 \u03b1} : measurable_space.comap g (m\u2081 \u2294 m\u2082) = measurable_space.comap g m\u2081 \u2294 measurable_space.comap g m\u2082 :=\n  galois_connection.l_sup (gc_comap_map g)\n\n@[simp] theorem comap_supr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b9 : Sort u_6} {g : \u03b2 \u2192 \u03b1} {m : \u03b9 \u2192 measurable_space \u03b1} : measurable_space.comap g (supr fun (i : \u03b9) => m i) = supr fun (i : \u03b9) => measurable_space.comap g (m i) :=\n  galois_connection.l_supr (gc_comap_map g)\n\n@[simp] theorem map_top {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} : measurable_space.map f \u22a4 = \u22a4 :=\n  galois_connection.u_top (gc_comap_map f)\n\n@[simp] theorem map_inf {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} {f : \u03b1 \u2192 \u03b2} : measurable_space.map f (m\u2081 \u2293 m\u2082) = measurable_space.map f m\u2081 \u2293 measurable_space.map f m\u2082 :=\n  galois_connection.u_inf (gc_comap_map f)\n\n@[simp] theorem map_infi {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b9 : Sort u_6} {f : \u03b1 \u2192 \u03b2} {m : \u03b9 \u2192 measurable_space \u03b1} : measurable_space.map f (infi fun (i : \u03b9) => m i) = infi fun (i : \u03b9) => measurable_space.map f (m i) :=\n  galois_connection.u_infi (gc_comap_map f)\n\ntheorem comap_map_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m : measurable_space \u03b1} {f : \u03b1 \u2192 \u03b2} : measurable_space.comap f (measurable_space.map f m) \u2264 m :=\n  galois_connection.l_u_le (gc_comap_map f) m\n\ntheorem le_map_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m : measurable_space \u03b1} {g : \u03b2 \u2192 \u03b1} : m \u2264 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 {\u03b1 : Type u_1} {s : set (set \u03b1)} {t : set (set \u03b1)} (h : s \u2286 t) : generate_from s \u2264 generate_from t :=\n  galois_connection.monotone_l (galois_insertion.gc gi_generate_from) h\n\ntheorem generate_from_sup_generate_from {\u03b1 : Type u_1} {s : set (set \u03b1)} {t : set (set \u03b1)} : generate_from s \u2294 generate_from t = generate_from (s \u222a t) :=\n  Eq.symm (galois_connection.l_sup (galois_insertion.gc gi_generate_from))\n\ntheorem comap_generate_from {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {s : set (set \u03b2)} : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (f : \u03b1 \u2192 \u03b2) :=\n  \u2200 {t : set \u03b2}, is_measurable t \u2192 is_measurable (f \u207b\u00b9' t)\n\ntheorem measurable_iff_le_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} : measurable f \u2194 m\u2082 \u2264 measurable_space.map f m\u2081 :=\n  iff.rfl\n\ntheorem measurable.of_le_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} : m\u2082 \u2264 measurable_space.map f m\u2081 \u2192 measurable f :=\n  iff.mpr measurable_iff_le_map\n\ntheorem measurable_iff_comap_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} : measurable f \u2194 measurable_space.comap f m\u2082 \u2264 m\u2081 :=\n  iff.symm measurable_space.comap_le_iff_le_map\n\ntheorem measurable.comap_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} : measurable f \u2192 measurable_space.comap f m\u2082 \u2264 m\u2081 :=\n  iff.mp measurable_iff_comap_le\n\ntheorem measurable.mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} {ma : measurable_space \u03b1} {ma' : measurable_space \u03b1} {mb : measurable_space \u03b2} {mb' : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} (hf : measurable f) (ha : ma \u2264 ma') (hb : mb' \u2264 mb) : measurable f :=\n  fun (t : set \u03b2) (ht : is_measurable t) => ha (f \u207b\u00b9' t) (hf (hb t ht))\n\ntheorem measurable_from_top {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b2] {f : \u03b1 \u2192 \u03b2} : measurable f :=\n  fun (s : set \u03b2) (hs : is_measurable s) => trivial\n\ntheorem measurable_generate_from {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] {s : set (set \u03b2)} {f : \u03b1 \u2192 \u03b2} (h : \u2200 (t : set \u03b2), t \u2208 s \u2192 is_measurable (f \u207b\u00b9' t)) : measurable f :=\n  measurable.of_le_map (measurable_space.generate_from_le h)\n\ntheorem measurable_id {\u03b1 : Type u_1} [measurable_space \u03b1] : measurable id :=\n  fun (t : set \u03b1) => id\n\ntheorem measurable.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : measurable g) (hf : measurable f) : measurable (g \u2218 f) :=\n  fun (t : set \u03b3) (ht : is_measurable t) => hf (hg ht)\n\ntheorem subsingleton.measurable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] [subsingleton \u03b1] {f : \u03b1 \u2192 \u03b2} : measurable f :=\n  fun (s : set \u03b2) (hs : is_measurable s) => subsingleton.is_measurable\n\ntheorem measurable.piecewise {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {s : set \u03b1} {_x : decidable_pred s} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {p : \u03b1 \u2192 Prop} {_x : decidable_pred p} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (hp : is_measurable (set_of fun (a : \u03b1) => p a)) (hf : measurable f) (hg : measurable g) : measurable fun (x : \u03b1) => ite (p x) (f x) (g x) :=\n  measurable.piecewise hp hf hg\n\n@[simp] theorem measurable_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {a : \u03b1} : measurable fun (b : \u03b2) => a :=\n  fun (s : set \u03b1) (hs : is_measurable s) => is_measurable.const (a \u2208 s)\n\ntheorem measurable.indicator {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} (hf : measurable f) (hs : is_measurable s) : measurable (set.indicator s f) :=\n  measurable.piecewise hs hf measurable_const\n\ntheorem measurable_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] [HasZero \u03b1] : measurable 0 :=\n  measurable_const\n\ntheorem measurable_of_not_nonempty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (h : \u00acNonempty \u03b1) (f : \u03b1 \u2192 \u03b2) : measurable f := sorry\n\nprotected instance empty.measurable_space : measurable_space empty :=\n  \u22a4\n\nprotected instance punit.measurable_space : measurable_space PUnit :=\n  \u22a4\n\nprotected instance bool.measurable_space : measurable_space Bool :=\n  \u22a4\n\nprotected instance nat.measurable_space : measurable_space \u2115 :=\n  \u22a4\n\nprotected instance int.measurable_space : measurable_space \u2124 :=\n  \u22a4\n\nprotected instance rat.measurable_space : measurable_space \u211a :=\n  \u22a4\n\ntheorem measurable_to_encodable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] [encodable \u03b1] {f : \u03b2 \u2192 \u03b1} (h : \u2200 (y : \u03b2), is_measurable (f \u207b\u00b9' singleton (f y))) : measurable f := sorry\n\ntheorem measurable_unit {\u03b1 : Type u_1} [measurable_space \u03b1] (f : Unit \u2192 \u03b1) : measurable f :=\n  measurable_from_top\n\ntheorem measurable_from_nat {\u03b1 : Type u_1} [measurable_space \u03b1] {f : \u2115 \u2192 \u03b1} : measurable f :=\n  measurable_from_top\n\ntheorem measurable_to_nat {\u03b1 : Type u_1} [measurable_space \u03b1] {f : \u03b1 \u2192 \u2115} : (\u2200 (y : \u03b1), is_measurable (f \u207b\u00b9' singleton (f y))) \u2192 measurable f :=\n  measurable_to_encodable\n\ntheorem measurable_find_greatest' {\u03b1 : Type u_1} [measurable_space \u03b1] {p : \u03b1 \u2192 \u2115 \u2192 Prop} {N : \u2115} (hN : \u2200 (k : \u2115), k \u2264 N \u2192 is_measurable (set_of fun (x : \u03b1) => nat.find_greatest (p x) N = k)) : measurable fun (x : \u03b1) => nat.find_greatest (p x) N :=\n  measurable_to_nat fun (x : \u03b1) => hN (nat.find_greatest (p x) N) nat.find_greatest_le\n\ntheorem measurable_find_greatest {\u03b1 : Type u_1} [measurable_space \u03b1] {p : \u03b1 \u2192 \u2115 \u2192 Prop} {N : \u2115} (hN : \u2200 (k : \u2115), k \u2264 N \u2192 is_measurable (set_of fun (x : \u03b1) => p x k)) : measurable fun (x : \u03b1) => nat.find_greatest (p x) N := sorry\n\ntheorem measurable_find {\u03b1 : Type u_1} [measurable_space \u03b1] {p : \u03b1 \u2192 \u2115 \u2192 Prop} (hp : \u2200 (x : \u03b1), \u2203 (N : \u2115), p x N) (hm : \u2200 (k : \u2115), is_measurable (set_of fun (x : \u03b1) => p x k)) : measurable fun (x : \u03b1) => nat.find (hp x) := sorry\n\nprotected instance subtype.measurable_space {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [m : measurable_space \u03b1] : measurable_space (Subtype p) :=\n  measurable_space.comap coe m\n\ntheorem measurable_subtype_coe {\u03b1 : Type u_1} [measurable_space \u03b1] {p : \u03b1 \u2192 Prop} : measurable coe :=\n  measurable_space.le_map_comap\n\ntheorem measurable.subtype_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {p : \u03b2 \u2192 Prop} {f : \u03b1 \u2192 Subtype p} (hf : measurable f) : measurable fun (a : \u03b1) => \u2191(f a) :=\n  measurable.comp measurable_subtype_coe hf\n\ntheorem measurable.subtype_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {p : \u03b2 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} (hf : measurable f) {h : \u2200 (x : \u03b1), p (f x)} : measurable fun (x : \u03b1) => { val := f x, property := h x } := sorry\n\ntheorem is_measurable.subtype_image {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set \u03b1} {t : set \u21a5s} (hs : is_measurable s) : is_measurable t \u2192 is_measurable (coe '' t) := sorry\n\ntheorem measurable_of_measurable_union_cover {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {f : \u03b1 \u2192 \u03b2} (s : set \u03b1) (t : set \u03b1) (hs : is_measurable s) (ht : is_measurable t) (h : set.univ \u2286 s \u222a t) (hc : measurable fun (a : \u21a5s) => f \u2191a) (hd : measurable fun (a : \u21a5t) => f \u2191a) : measurable f := sorry\n\ntheorem measurable_of_measurable_on_compl_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_singleton_class \u03b1] {f : \u03b1 \u2192 \u03b2} (a : \u03b1) (hf : measurable (set.restrict f (set_of fun (x : \u03b1) => x \u2260 a))) : measurable f :=\n  measurable_of_measurable_union_cover (set_of fun (x : \u03b1) => x = a) ((set_of fun (x : \u03b1) => x = a)\u1d9c) is_measurable_eq\n    (is_measurable.compl is_measurable_eq)\n    (fun (x : \u03b1) (hx : x \u2208 set.univ) => classical.em (x \u2208 set_of fun (x : \u03b1) => x = a)) subsingleton.measurable hf\n\nprotected instance prod.measurable_space {\u03b1 : Type u_1} {\u03b2 : Type u_2} [m\u2081 : measurable_space \u03b1] [m\u2082 : measurable_space \u03b2] : measurable_space (\u03b1 \u00d7 \u03b2) :=\n  measurable_space.comap prod.fst m\u2081 \u2294 measurable_space.comap prod.snd m\u2082\n\ntheorem measurable_fst {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : measurable prod.fst :=\n  measurable.of_comap_le le_sup_left\n\ntheorem measurable.fst {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2 \u00d7 \u03b3} (hf : measurable f) : measurable fun (a : \u03b1) => prod.fst (f a) :=\n  measurable.comp measurable_fst hf\n\ntheorem measurable_snd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : measurable prod.snd :=\n  measurable.of_comap_le le_sup_right\n\ntheorem measurable.snd {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2 \u00d7 \u03b3} (hf : measurable f) : measurable fun (a : \u03b1) => prod.snd (f a) :=\n  measurable.comp measurable_snd hf\n\ntheorem measurable.prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2 \u00d7 \u03b3} (hf\u2081 : measurable fun (a : \u03b1) => prod.fst (f a)) (hf\u2082 : measurable fun (a : \u03b1) => prod.snd (f a)) : measurable f := sorry\n\ntheorem measurable_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2 \u00d7 \u03b3} : measurable f \u2194 (measurable fun (a : \u03b1) => prod.fst (f a)) \u2227 measurable fun (a : \u03b1) => prod.snd (f a) := sorry\n\ntheorem measurable.prod_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} (hf : measurable f) (hg : measurable g) : measurable fun (a : \u03b1) => (f a, g a) :=\n  measurable.prod hf hg\n\ntheorem measurable_prod_mk_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {x : \u03b1} : measurable (Prod.mk x) :=\n  measurable.prod_mk measurable_const measurable_id\n\ntheorem measurable_prod_mk_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {y : \u03b2} : measurable fun (x : \u03b1) => (x, y) :=\n  measurable.prod_mk measurable_id measurable_const\n\ntheorem measurable.of_uncurry_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hf : measurable (function.uncurry f)) {x : \u03b1} : measurable (f x) :=\n  measurable.comp hf measurable_prod_mk_left\n\ntheorem measurable.of_uncurry_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hf : measurable (function.uncurry f)) {y : \u03b2} : measurable fun (x : \u03b1) => f x y :=\n  measurable.comp hf measurable_prod_mk_right\n\ntheorem measurable_swap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : measurable prod.swap :=\n  measurable.prod measurable_snd measurable_fst\n\ntheorem measurable_swap_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} : measurable (f \u2218 prod.swap) \u2194 measurable f := sorry\n\ntheorem is_measurable.prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {s : set \u03b1} {t : set \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {s : set \u03b1} {t : set \u03b2} (h : set.nonempty (set.prod s t)) : is_measurable (set.prod s t) \u2194 is_measurable s \u2227 is_measurable t := sorry\n\ntheorem is_measurable_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {s : set \u03b1} {t : set \u03b2} : is_measurable (set.prod s t) \u2194 is_measurable s \u2227 is_measurable t \u2228 s = \u2205 \u2228 t = \u2205 := sorry\n\ntheorem is_measurable_swap_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {s : set (\u03b1 \u00d7 \u03b2)} : is_measurable (prod.swap \u207b\u00b9' s) \u2194 is_measurable s := sorry\n\nprotected instance measurable_space.pi {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [m : (a : \u03b4) \u2192 measurable_space (\u03c0 a)] : measurable_space ((a : \u03b4) \u2192 \u03c0 a) :=\n  supr fun (a : \u03b4) => measurable_space.comap (fun (b : (a : \u03b4) \u2192 \u03c0 a) => b a) (m a)\n\ntheorem measurable_pi_iff {\u03b1 : Type u_1} {\u03b4 : Type u_4} [measurable_space \u03b1] {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] {g : \u03b1 \u2192 (a : \u03b4) \u2192 \u03c0 a} : measurable g \u2194 \u2200 (a : \u03b4), measurable fun (x : \u03b1) => g x a := sorry\n\ntheorem measurable_pi_apply {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] (a : \u03b4) : measurable fun (f : (a : \u03b4) \u2192 \u03c0 a) => f a :=\n  measurable.of_comap_le (le_supr (fun (a : \u03b4) => measurable_space.comap (fun (f : (a : \u03b4) \u2192 \u03c0 a) => f a) (_inst_4 a)) a)\n\ntheorem measurable.eval {\u03b1 : Type u_1} {\u03b4 : Type u_4} [measurable_space \u03b1] {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] {a : \u03b4} {g : \u03b1 \u2192 (a : \u03b4) \u2192 \u03c0 a} (hg : measurable g) : measurable fun (x : \u03b1) => g x a :=\n  measurable.comp (measurable_pi_apply a) hg\n\ntheorem measurable_pi_lambda {\u03b1 : Type u_1} {\u03b4 : Type u_4} [measurable_space \u03b1] {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] (f : \u03b1 \u2192 (a : \u03b4) \u2192 \u03c0 a) (hf : \u2200 (a : \u03b4), measurable fun (c : \u03b1) => f c a) : measurable f :=\n  iff.mpr measurable_pi_iff hf\n\n/-- The function `update f a : \u03c0 a \u2192 \u03a0 a, \u03c0 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 {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] (f : (a : \u03b4) \u2192 \u03c0 a) {a : \u03b4} : 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 {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] {s : set \u03b4} {t : (i : \u03b4) \u2192 set (\u03c0 i)} (hs : set.countable s) (ht : \u2200 (i : \u03b4), i \u2208 s \u2192 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 : \u03b4) (hi : i \u2208 s) => measurable_pi_apply i (ht i hi))\n\ntheorem is_measurable.pi_univ {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] [encodable \u03b4] {t : (i : \u03b4) \u2192 set (\u03c0 i)} (ht : \u2200 (i : \u03b4), is_measurable (t i)) : is_measurable (set.pi set.univ t) :=\n  is_measurable.pi (set.countable_encodable set.univ) fun (i : \u03b4) (_x : i \u2208 set.univ) => ht i\n\ntheorem is_measurable_pi_of_nonempty {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] {s : set \u03b4} {t : (i : \u03b4) \u2192 set (\u03c0 i)} (hs : set.countable s) (h : set.nonempty (set.pi s t)) : is_measurable (set.pi s t) \u2194 \u2200 (i : \u03b4), i \u2208 s \u2192 is_measurable (t i) := sorry\n\ntheorem is_measurable_pi {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] {s : set \u03b4} {t : (i : \u03b4) \u2192 set (\u03c0 i)} (hs : set.countable s) : is_measurable (set.pi s t) \u2194 (\u2200 (i : \u03b4), i \u2208 s \u2192 is_measurable (t i)) \u2228 set.pi s t = \u2205 := sorry\n\ntheorem is_measurable.pi_fintype {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(a : \u03b4) \u2192 measurable_space (\u03c0 a)] [fintype \u03b4] {s : set \u03b4} {t : (i : \u03b4) \u2192 set (\u03c0 i)} (ht : \u2200 (i : \u03b4), i \u2208 s \u2192 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 {\u03b4 : Type u_4} (\u03c0 : \u03b4 \u2192 Type u_1) [(x : \u03b4) \u2192 measurable_space (\u03c0 x)] (l : List \u03b4) : measurable_space (list.tprod \u03c0 l) :=\n  sorry\n\ntheorem measurable_tprod_mk {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(x : \u03b4) \u2192 measurable_space (\u03c0 x)] (l : List \u03b4) : measurable (list.tprod.mk l) :=\n  List.rec measurable_const\n    (fun (i : \u03b4) (l : List \u03b4) (ih : measurable (list.tprod.mk l)) => measurable.prod_mk (measurable_pi_apply i) ih) l\n\ntheorem measurable_tprod_elim {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(x : \u03b4) \u2192 measurable_space (\u03c0 x)] {l : List \u03b4} {i : \u03b4} (hi : i \u2208 l) : measurable fun (v : list.tprod \u03c0 l) => list.tprod.elim v hi := sorry\n\ntheorem measurable_tprod_elim' {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(x : \u03b4) \u2192 measurable_space (\u03c0 x)] {l : List \u03b4} (h : \u2200 (i : \u03b4), i \u2208 l) : measurable (list.tprod.elim' h) :=\n  measurable_pi_lambda (list.tprod.elim' h) fun (i : \u03b4) => measurable_tprod_elim (h i)\n\ntheorem is_measurable.tprod {\u03b4 : Type u_4} {\u03c0 : \u03b4 \u2192 Type u_7} [(x : \u03b4) \u2192 measurable_space (\u03c0 x)] (l : List \u03b4) {s : (i : \u03b4) \u2192 set (\u03c0 i)} (hs : \u2200 (i : \u03b4), is_measurable (s i)) : is_measurable (set.tprod l s) :=\n  List.rec is_measurable.univ\n    (fun (i : \u03b4) (l : List \u03b4) (ih : is_measurable (set.tprod l s)) => is_measurable.prod (hs i) ih) l\n\nprotected instance sum.measurable_space {\u03b1 : Type u_1} {\u03b2 : Type u_2} [m\u2081 : measurable_space \u03b1] [m\u2082 : measurable_space \u03b2] : measurable_space (\u03b1 \u2295 \u03b2) :=\n  measurable_space.map sum.inl m\u2081 \u2293 measurable_space.map sum.inr m\u2082\n\ntheorem measurable_inl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : measurable sum.inl :=\n  measurable.of_le_map inf_le_left\n\ntheorem measurable_inr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : measurable sum.inr :=\n  measurable.of_le_map inf_le_right\n\ntheorem measurable_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} (hl : measurable (f \u2218 sum.inl)) (hr : measurable (f \u2218 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3} (hf : measurable f) (hg : measurable g) : measurable (sum.elim f g) :=\n  measurable_sum hf hg\n\ntheorem is_measurable.inl_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {s : set \u03b1} (hs : is_measurable s) : is_measurable (sum.inl '' s) := sorry\n\ntheorem is_measurable_range_inl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] {s : set \u03b2} (hs : is_measurable s) : is_measurable (sum.inr '' s) := sorry\n\ntheorem is_measurable_range_inr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : 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 {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} [m : (a : \u03b1) \u2192 measurable_space (\u03b2 a)] : measurable_space (sigma \u03b2) :=\n  infi fun (a : \u03b1) => 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 (\u03b1 : Type u_7) (\u03b2 : Type u_8) [measurable_space \u03b1] [measurable_space \u03b2] \nextends \u03b1 \u2243 \u03b2\nwhere\n  measurable_to_fun : measurable (equiv.to_fun _to_equiv)\n  measurable_inv_fun : measurable (equiv.inv_fun _to_equiv)\n\ninfixl:25 \" \u2243\u1d50 \" => Mathlib.measurable_equiv\n\nnamespace measurable_equiv\n\n\nprotected instance has_coe_to_fun (\u03b1 : Type u_1) (\u03b2 : Type u_2) [measurable_space \u03b1] [measurable_space \u03b2] : has_coe_to_fun (\u03b1 \u2243\u1d50 \u03b2) :=\n  has_coe_to_fun.mk (fun (_x : \u03b1 \u2243\u1d50 \u03b2) => \u03b1 \u2192 \u03b2) fun (e : \u03b1 \u2243\u1d50 \u03b2) => \u21d1(to_equiv e)\n\ntheorem coe_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (e : \u03b1 \u2243\u1d50 \u03b2) : \u21d1e = \u21d1(to_equiv e) :=\n  rfl\n\nprotected theorem measurable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (e : \u03b1 \u2243\u1d50 \u03b2) : measurable \u21d1e :=\n  measurable_to_fun e\n\n@[simp] theorem coe_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (e : \u03b1 \u2243 \u03b2) (h1 : measurable \u21d1e) (h2 : measurable \u21d1(equiv.symm e)) : \u21d1(mk e h1 h2) = \u21d1e :=\n  rfl\n\n/-- Any measurable space is equivalent to itself. -/\ndef refl (\u03b1 : Type u_1) [measurable_space \u03b1] : \u03b1 \u2243\u1d50 \u03b1 :=\n  mk (equiv.refl \u03b1) measurable_id measurable_id\n\nprotected instance inhabited {\u03b1 : Type u_1} [measurable_space \u03b1] : Inhabited (\u03b1 \u2243\u1d50 \u03b1) :=\n  { default := refl \u03b1 }\n\n/-- The composition of equivalences between measurable spaces. -/\ndef trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] (ab : \u03b1 \u2243\u1d50 \u03b2) (bc : \u03b2 \u2243\u1d50 \u03b3) : \u03b1 \u2243\u1d50 \u03b3 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (ab : \u03b1 \u2243\u1d50 \u03b2) : to_equiv (symm ab) = equiv.symm (to_equiv ab) :=\n  Eq.refl (to_equiv (symm ab))\n\n@[simp] theorem coe_symm_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (e : \u03b1 \u2243 \u03b2) (h1 : measurable \u21d1e) (h2 : measurable \u21d1(equiv.symm e)) : \u21d1(symm (mk e h1 h2)) = \u21d1(equiv.symm e) :=\n  rfl\n\n@[simp] theorem symm_comp_self {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (e : \u03b1 \u2243\u1d50 \u03b2) : \u21d1(symm e) \u2218 \u21d1e = id :=\n  funext (equiv.left_inv (to_equiv e))\n\n@[simp] theorem self_comp_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (e : \u03b1 \u2243\u1d50 \u03b2) : \u21d1e \u2218 \u21d1(symm e) = id :=\n  funext (equiv.right_inv (to_equiv e))\n\n/-- Equal measurable spaces are equivalent. -/\nprotected def cast {\u03b1 : Type u_1} {\u03b2 : Type u_1} [i\u2081 : measurable_space \u03b1] [i\u2082 : measurable_space \u03b2] (h : \u03b1 = \u03b2) (hi : i\u2081 == i\u2082) : \u03b1 \u2243\u1d50 \u03b2 :=\n  mk (equiv.cast h) sorry sorry\n\nprotected theorem measurable_coe_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b2 \u2192 \u03b3} (e : \u03b1 \u2243\u1d50 \u03b2) : measurable (f \u2218 \u21d1e) \u2194 measurable f := sorry\n\n/-- Products of equivalent measurable spaces are equivalent. -/\ndef prod_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] [measurable_space \u03b4] (ab : \u03b1 \u2243\u1d50 \u03b2) (cd : \u03b3 \u2243\u1d50 \u03b4) : \u03b1 \u00d7 \u03b3 \u2243\u1d50 \u03b2 \u00d7 \u03b4 :=\n  mk (equiv.prod_congr (to_equiv ab) (to_equiv cd)) sorry sorry\n\n/-- Products of measurable spaces are symmetric. -/\ndef prod_comm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : \u03b1 \u00d7 \u03b2 \u2243\u1d50 \u03b2 \u00d7 \u03b1 :=\n  mk (equiv.prod_comm \u03b1 \u03b2) sorry sorry\n\n/-- Products of measurable spaces are associative. -/\ndef prod_assoc {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243\u1d50 \u03b1 \u00d7 \u03b2 \u00d7 \u03b3 :=\n  mk (equiv.prod_assoc \u03b1 \u03b2 \u03b3) sorry sorry\n\n/-- Sums of measurable spaces are symmetric. -/\ndef sum_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] [measurable_space \u03b4] (ab : \u03b1 \u2243\u1d50 \u03b2) (cd : \u03b3 \u2243\u1d50 \u03b4) : \u03b1 \u2295 \u03b3 \u2243\u1d50 \u03b2 \u2295 \u03b4 :=\n  mk (equiv.sum_congr (to_equiv ab) (to_equiv cd)) sorry sorry\n\n/-- `set.prod s t \u2243 (s \u00d7 t)` as measurable spaces. -/\ndef set.prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (s : set \u03b1) (t : set \u03b2) : \u21a5(set.prod s t) \u2243\u1d50 \u21a5s \u00d7 \u21a5t :=\n  mk (equiv.set.prod s t) sorry sorry\n\n/-- `univ \u03b1 \u2243 \u03b1` as measurable spaces. -/\ndef set.univ (\u03b1 : Type u_1) [measurable_space \u03b1] : \u21a5set.univ \u2243\u1d50 \u03b1 :=\n  mk (equiv.set.univ \u03b1) sorry sorry\n\n/-- `{a} \u2243 unit` as measurable spaces. -/\ndef set.singleton {\u03b1 : Type u_1} [measurable_space \u03b1] (a : \u03b1) : \u21a5(singleton a) \u2243\u1d50 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (hf : function.injective f) (hfm : measurable f) (hfi : \u2200 (s : set \u03b1), is_measurable s \u2192 is_measurable (f '' s)) : \u21a5s \u2243\u1d50 \u21a5(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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] (f : \u03b1 \u2192 \u03b2) (hf : function.injective f) (hfm : measurable f) (hfi : \u2200 (s : set \u03b1), is_measurable s \u2192 is_measurable (f '' s)) : \u03b1 \u2243\u1d50 \u21a5(set.range f) :=\n  trans (symm (set.univ \u03b1)) (trans (set.image f set.univ hf hfm hfi) (measurable_equiv.cast sorry sorry))\n\n/-- `\u03b1` is equivalent to its image in `\u03b1 \u2295 \u03b2` as measurable spaces. -/\ndef set.range_inl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : \u21a5(set.range sum.inl) \u2243\u1d50 \u03b1 :=\n  mk\n    (equiv.mk (fun (ab : \u21a5(set.range sum.inl)) => sorry) (fun (a : \u03b1) => { val := sum.inl a, property := sorry }) sorry\n      sorry)\n    sorry sorry\n\n/-- `\u03b2` is equivalent to its image in `\u03b1 \u2295 \u03b2` as measurable spaces. -/\ndef set.range_inr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [measurable_space \u03b1] [measurable_space \u03b2] : \u21a5(set.range sum.inr) \u2243\u1d50 \u03b2 :=\n  mk\n    (equiv.mk (fun (ab : \u21a5(set.range sum.inr)) => sorry) (fun (b : \u03b2) => { 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 (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] : (\u03b1 \u2295 \u03b2) \u00d7 \u03b3 \u2243\u1d50 \u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3 :=\n  mk (equiv.sum_prod_distrib \u03b1 \u03b2 \u03b3) sorry sorry\n\n/-- Products distribute over sums (on the left) as measurable spaces. -/\ndef prod_sum_distrib (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243\u1d50 \u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3 :=\n  trans prod_comm (trans (sum_prod_distrib \u03b2 \u03b3 \u03b1) (sum_congr prod_comm prod_comm))\n\n/-- Products distribute over sums as measurable spaces. -/\ndef sum_prod_sum (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) (\u03b4 : Type u_4) [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] [measurable_space \u03b4] : (\u03b1 \u2295 \u03b2) \u00d7 (\u03b3 \u2295 \u03b4) \u2243\u1d50 (\u03b1 \u00d7 \u03b3 \u2295 \u03b1 \u00d7 \u03b4) \u2295 \u03b2 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b4 :=\n  trans (sum_prod_distrib \u03b1 \u03b2 (\u03b3 \u2295 \u03b4)) (sum_congr (prod_sum_distrib \u03b1 \u03b3 \u03b4) (prod_sum_distrib \u03b2 \u03b3 \u03b4))\n\n/-- A family of measurable equivalences `\u03a0 a, \u03b2\u2081 a \u2243\u1d50 \u03b2\u2082 a` generates a measurable equivalence\n  between  `\u03a0 a, \u03b2\u2081 a` and `\u03a0 a, \u03b2\u2082 a`. -/\ndef Pi_congr_right {\u03b4' : Type u_5} {\u03c0 : \u03b4' \u2192 Type u_7} {\u03c0' : \u03b4' \u2192 Type u_8} [(x : \u03b4') \u2192 measurable_space (\u03c0 x)] [(x : \u03b4') \u2192 measurable_space (\u03c0' x)] (e : (a : \u03b4') \u2192 \u03c0 a \u2243\u1d50 \u03c0' a) : ((a : \u03b4') \u2192 \u03c0 a) \u2243\u1d50 ((a : \u03b4') \u2192 \u03c0' a) :=\n  mk (equiv.Pi_congr_right fun (a : \u03b4') => to_equiv (e a)) sorry sorry\n\n/-- Pi-types are measurably equivalent to iterated products. -/\ndef pi_measurable_equiv_tprod {\u03b4' : Type u_5} {\u03c0 : \u03b4' \u2192 Type u_7} [(x : \u03b4') \u2192 measurable_space (\u03c0 x)] {l : List \u03b4'} (hnd : list.nodup l) (h : \u2200 (i : \u03b4'), i \u2208 l) : ((i : \u03b4') \u2192 \u03c0 i) \u2243\u1d50 list.tprod \u03c0 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 `\u03b1` 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 {\u03b1 : Type u_1} (C : set (set \u03b1)) :=\n  \u2200 (s t : set \u03b1), s \u2208 C \u2192 t \u2208 C \u2192 set.nonempty (s \u2229 t) \u2192 s \u2229 t \u2208 C\n\nnamespace measurable_space\n\n\ntheorem is_pi_system_is_measurable {\u03b1 : Type u_1} [measurable_space \u03b1] : is_pi_system (set_of fun (s : set \u03b1) => is_measurable s) :=\n  fun (s t : set \u03b1) (hs : s \u2208 set_of fun (s : set \u03b1) => is_measurable s)\n    (ht : t \u2208 set_of fun (s : set \u03b1) => is_measurable s) (_x : set.nonempty (s \u2229 t)) => is_measurable.inter hs ht\n\n/-- A Dynkin system is a collection of subsets of a type `\u03b1` 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 `\u03c3`-algebras.\n\n  The main purpose of Dynkin systems is to provide a powerful induction rule for \u03c3-algebras\n  generated by intersection stable set systems.\n\n  A Dynkin system is also known as a \"\u03bb-system\" or a \"d-system\".\n-/\nstructure dynkin_system (\u03b1 : Type u_7) \nwhere\n  has : set \u03b1 \u2192 Prop\n  has_empty : has \u2205\n  has_compl : \u2200 {a : set \u03b1}, has a \u2192 has (a\u1d9c)\n  has_Union_nat : \u2200 {f : \u2115 \u2192 set \u03b1}, pairwise (disjoint on f) \u2192 (\u2200 (i : \u2115), has (f i)) \u2192 has (set.Union fun (i : \u2115) => f i)\n\nnamespace dynkin_system\n\n\ntheorem ext {\u03b1 : Type u_1} {d\u2081 : dynkin_system \u03b1} {d\u2082 : dynkin_system \u03b1} : (\u2200 (s : set \u03b1), has d\u2081 s \u2194 has d\u2082 s) \u2192 d\u2081 = d\u2082 := sorry\n\ntheorem has_compl_iff {\u03b1 : Type u_1} (d : dynkin_system \u03b1) {a : set \u03b1} : has d (a\u1d9c) \u2194 has d a := sorry\n\ntheorem has_univ {\u03b1 : Type u_1} (d : dynkin_system \u03b1) : has d set.univ := sorry\n\ntheorem has_Union {\u03b1 : Type u_1} (d : dynkin_system \u03b1) {\u03b2 : Type u_2} [encodable \u03b2] {f : \u03b2 \u2192 set \u03b1} (hd : pairwise (disjoint on f)) (h : \u2200 (i : \u03b2), has d (f i)) : has d (set.Union fun (i : \u03b2) => f i) := sorry\n\ntheorem has_union {\u03b1 : Type u_1} (d : dynkin_system \u03b1) {s\u2081 : set \u03b1} {s\u2082 : set \u03b1} (h\u2081 : has d s\u2081) (h\u2082 : has d s\u2082) (h : s\u2081 \u2229 s\u2082 \u2286 \u2205) : has d (s\u2081 \u222a s\u2082) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (has d (s\u2081 \u222a s\u2082))) set.union_eq_Union))\n    (has_Union d (iff.mpr pairwise_disjoint_on_bool h) (iff.mpr bool.forall_bool { left := h\u2082, right := h\u2081 }))\n\ntheorem has_diff {\u03b1 : Type u_1} (d : dynkin_system \u03b1) {s\u2081 : set \u03b1} {s\u2082 : set \u03b1} (h\u2081 : has d s\u2081) (h\u2082 : has d s\u2082) (h : s\u2082 \u2286 s\u2081) : has d (s\u2081 \\ s\u2082) := sorry\n\nprotected instance partial_order {\u03b1 : Type u_1} : partial_order (dynkin_system \u03b1) :=\n  partial_order.mk (fun (m\u2081 m\u2082 : dynkin_system \u03b1) => has m\u2081 \u2264 has m\u2082)\n    (preorder.lt._default fun (m\u2081 m\u2082 : dynkin_system \u03b1) => has m\u2081 \u2264 has m\u2082) sorry sorry sorry\n\n/-- Every measurable space (\u03c3-algebra) forms a Dynkin system -/\ndef of_measurable_space {\u03b1 : Type u_1} (m : measurable_space \u03b1) : dynkin_system \u03b1 :=\n  mk (is_measurable' m) (is_measurable_empty m) (is_measurable_compl m) sorry\n\ntheorem of_measurable_space_le_of_measurable_space_iff {\u03b1 : Type u_1} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} : of_measurable_space m\u2081 \u2264 of_measurable_space m\u2082 \u2194 m\u2081 \u2264 m\u2082 :=\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 {\u03b1 : Type u_1} (s : set (set \u03b1)) : set \u03b1 \u2192 Prop\nwhere\n| basic : \u2200 (t : set \u03b1), t \u2208 s \u2192 generate_has s t\n| empty : generate_has s \u2205\n| compl : \u2200 {a : set \u03b1}, generate_has s a \u2192 generate_has s (a\u1d9c)\n| Union : \u2200 {f : \u2115 \u2192 set \u03b1},\n  pairwise (disjoint on f) \u2192 (\u2200 (i : \u2115), generate_has s (f i)) \u2192 generate_has s (set.Union fun (i : \u2115) => f i)\n\ntheorem generate_has_compl {\u03b1 : Type u_1} {C : set (set \u03b1)} {s : set \u03b1} : generate_has C (s\u1d9c) \u2194 generate_has C s := sorry\n\n/-- The least Dynkin system containing a collection of basic sets. -/\ndef generate {\u03b1 : Type u_1} (s : set (set \u03b1)) : dynkin_system \u03b1 :=\n  mk (generate_has s) generate_has.empty sorry sorry\n\ntheorem generate_has_def {\u03b1 : Type u_1} {C : set (set \u03b1)} : has (generate C) = generate_has C :=\n  rfl\n\nprotected instance inhabited {\u03b1 : Type u_1} : Inhabited (dynkin_system \u03b1) :=\n  { default := generate set.univ }\n\n/-- If a Dynkin system is closed under binary intersection, then it forms a `\u03c3`-algebra. -/\ndef to_measurable_space {\u03b1 : Type u_1} (d : dynkin_system \u03b1) (h_inter : \u2200 (s\u2081 s\u2082 : set \u03b1), has d s\u2081 \u2192 has d s\u2082 \u2192 has d (s\u2081 \u2229 s\u2082)) : measurable_space \u03b1 :=\n  mk (has d) (has_empty d) sorry sorry\n\ntheorem of_measurable_space_to_measurable_space {\u03b1 : Type u_1} (d : dynkin_system \u03b1) (h_inter : \u2200 (s\u2081 s\u2082 : set \u03b1), has d s\u2081 \u2192 has d s\u2082 \u2192 has d (s\u2081 \u2229 s\u2082)) : of_measurable_space (to_measurable_space d h_inter) = d :=\n  ext fun (s : set \u03b1) => iff.rfl\n\n/-- If `s` is in a Dynkin system `d`, we can form the new Dynkin system `{s \u2229 t | t \u2208 d}`. -/\ndef restrict_on {\u03b1 : Type u_1} (d : dynkin_system \u03b1) {s : set \u03b1} (h : has d s) : dynkin_system \u03b1 :=\n  mk (fun (t : set \u03b1) => has d (t \u2229 s)) sorry sorry sorry\n\ntheorem generate_le {\u03b1 : Type u_1} (d : dynkin_system \u03b1) {s : set (set \u03b1)} (h : \u2200 (t : set \u03b1), t \u2208 s \u2192 has d t) : generate s \u2264 d := sorry\n\ntheorem generate_has_subset_generate_measurable {\u03b1 : Type u_1} {C : set (set \u03b1)} {s : set \u03b1} (hs : has (generate C) s) : is_measurable' (generate_from C) s :=\n  generate_le (of_measurable_space (generate_from C)) (fun (t : set \u03b1) => is_measurable_generate_from) s hs\n\ntheorem generate_inter {\u03b1 : Type u_1} {s : set (set \u03b1)} (hs : is_pi_system s) {t\u2081 : set \u03b1} {t\u2082 : set \u03b1} (ht\u2081 : has (generate s) t\u2081) (ht\u2082 : has (generate s) t\u2082) : has (generate s) (t\u2081 \u2229 t\u2082) := 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 \u03c3-algebra it generates.\n  This result is known as the \u03c0-\u03bb theorem.\n  A collection of sets closed under binary intersection is called a \"\u03c0-system\" if it is non-empty.\n-/\ntheorem generate_from_eq {\u03b1 : Type u_1} {s : set (set \u03b1)} (hs : is_pi_system s) : generate_from s = to_measurable_space (generate s) fun (t\u2081 t\u2082 : set \u03b1) => generate_inter hs := sorry\n\nend dynkin_system\n\n\ntheorem induction_on_inter {\u03b1 : Type u_1} {C : set \u03b1 \u2192 Prop} {s : set (set \u03b1)} [m : measurable_space \u03b1] (h_eq : m = generate_from s) (h_inter : is_pi_system s) (h_empty : C \u2205) (h_basic : \u2200 (t : set \u03b1), t \u2208 s \u2192 C t) (h_compl : \u2200 (t : set \u03b1), is_measurable t \u2192 C t \u2192 C (t\u1d9c)) (h_union : \u2200 (f : \u2115 \u2192 set \u03b1),\n  pairwise (disjoint on f) \u2192 (\u2200 (i : \u2115), is_measurable (f i)) \u2192 (\u2200 (i : \u2115), C (f i)) \u2192 C (set.Union fun (i : \u2115) => f i)) {t : set \u03b1} : is_measurable t \u2192 C t := sorry\n\nend measurable_space\n\n\nnamespace filter\n\n\n/-- A filter `f` is measurably generates if each `s \u2208 f` includes a measurable `t \u2208 f`. -/\nclass is_measurably_generated {\u03b1 : Type u_1} [measurable_space \u03b1] (f : filter \u03b1) \nwhere\n  exists_measurable_subset : \u2200 {s : set \u03b1}, s \u2208 f \u2192 \u2203 (t : set \u03b1), \u2203 (H : t \u2208 f), is_measurable t \u2227 t \u2286 s\n\nprotected instance is_measurably_generated_bot {\u03b1 : Type u_1} [measurable_space \u03b1] : is_measurably_generated \u22a5 :=\n  is_measurably_generated.mk\n    fun (_x : set \u03b1) (_x_1 : _x \u2208 \u22a5) =>\n      Exists.intro \u2205 (Exists.intro mem_bot_sets { left := is_measurable.empty, right := set.empty_subset _x })\n\nprotected instance is_measurably_generated_top {\u03b1 : Type u_1} [measurable_space \u03b1] : is_measurably_generated \u22a4 :=\n  is_measurably_generated.mk\n    fun (s : set \u03b1) (hs : s \u2208 \u22a4) =>\n      Exists.intro set.univ\n        (Exists.intro univ_mem_sets { left := is_measurable.univ, right := fun (x : \u03b1) (_x : x \u2208 set.univ) => hs x })\n\ntheorem eventually.exists_measurable_mem {\u03b1 : Type u_1} [measurable_space \u03b1] {f : filter \u03b1} [is_measurably_generated f] {p : \u03b1 \u2192 Prop} (h : filter.eventually (fun (x : \u03b1) => p x) f) : \u2203 (s : set \u03b1), \u2203 (H : s \u2208 f), is_measurable s \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 p x :=\n  is_measurably_generated.exists_measurable_subset h\n\ntheorem eventually.exists_measurable_mem_of_lift' {\u03b1 : Type u_1} [measurable_space \u03b1] {f : filter \u03b1} [is_measurably_generated f] {p : set \u03b1 \u2192 Prop} (h : filter.eventually (fun (s : set \u03b1) => p s) (filter.lift' f set.powerset)) : \u2203 (s : set \u03b1), \u2203 (H : s \u2208 f), is_measurable s \u2227 p s := sorry\n\nprotected instance inf_is_measurably_generated {\u03b1 : Type u_1} [measurable_space \u03b1] (f : filter \u03b1) (g : filter \u03b1) [is_measurably_generated f] [is_measurably_generated g] : is_measurably_generated (f \u2293 g) := sorry\n\ntheorem principal_is_measurably_generated_iff {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set \u03b1} : is_measurably_generated (principal s) \u2194 is_measurable s := sorry\n\ntheorem Mathlib.is_measurable.principal_is_measurably_generated {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set \u03b1} : is_measurable s \u2192 is_measurably_generated (principal s) :=\n  iff.mpr principal_is_measurably_generated_iff\n\nprotected instance infi_is_measurably_generated {\u03b1 : Type u_1} {\u03b9 : Sort u_6} [measurable_space \u03b1] {f : \u03b9 \u2192 filter \u03b1} [\u2200 (i : \u03b9), is_measurably_generated (f i)] : is_measurably_generated (infi fun (i : \u03b9) => 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 {\u03b1 : Type u_1} (C : set (set \u03b1)) :=\n  \u2203 (s : \u2115 \u2192 set \u03b1), (\u2200 (n : \u2115), s n \u2208 C) \u2227 (set.Union fun (n : \u2115) => s n) = set.univ\n\ntheorem is_countably_spanning_is_measurable {\u03b1 : Type u_1} [measurable_space \u03b1] : is_countably_spanning (set_of fun (s : set \u03b1) => is_measurable s) :=\n  Exists.intro (fun (_x : \u2115) => set.univ)\n    { left := fun (_x : \u2115) => 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 \u2964 D` for any additive functor `F`\nout of a category with injective resolutions.\n\nThe definition is\n```\ninjective_resolutions C \u22d9 F.map_homotopy_category _ \u22d9 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) \u2245 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 \u2964 D) [F.additive] (n : \u2115) : C \u2964 D :=\ninjective_resolutions C \u22d9 F.map_homotopy_category _ \u22d9 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 \u2964 D) [F.additive] (n : \u2115)\n  {X : C} (P : InjectiveResolution X) :\n  (F.right_derived n).obj X \u2245\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  \u226a\u226b (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 \u2964 D) [F.additive]\n  (X : C) [injective X] :\n  (F.right_derived 0).obj X \u2245 F.obj X :=\nF.right_derived_obj_iso 0 (InjectiveResolution.self X) \u226a\u226b\n  (homology_functor _ _ _).map_iso ((cochain_complex.single\u2080_map_homological_complex F).app X) \u226a\u226b\n  (cochain_complex.homology_functor_0_single\u2080 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 \u2964 D) [F.additive] (n : \u2115)\n  (X : C) [injective X] :\n  (F.right_derived (n+1)).obj X \u2245 0 :=\nF.right_derived_obj_iso (n+1) (InjectiveResolution.self X) \u226a\u226b\n  (homology_functor _ _ _).map_iso ((cochain_complex.single\u2080_map_homological_complex F).app X) \u226a\u226b\n  (cochain_complex.homology_functor_succ_single\u2080 D n).app (F.obj X) \u226a\u226b\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 \u2964 D) [F.additive] (n : \u2115) {X Y : C} (f : Y \u27f6 X)\n  {P : InjectiveResolution X} {Q : InjectiveResolution Y} (g : Q.cocomplex \u27f6 P.cocomplex)\n  (w : Q.\u03b9 \u226b g = (cochain_complex.single\u2080 C).map f \u226b P.\u03b9) :\n  (F.right_derived n).map f =\n  (F.right_derived_obj_iso n Q).hom \u226b\n    (homology_functor D _ n).map ((F.map_homological_complex _).map g) \u226b\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 [\u2190homology_functor_map, homotopy_category.homology_functor_map_factors],\n  simp only [\u2190functor.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_\u03b9_assoc],\n    rw [\u2190category.assoc, w, category.assoc],\n    simp only [InjectiveResolution.homotopy_equiv_inv_\u03b9], },\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 \u2964 D} [F.additive] [G.additive] (\u03b1 : F \u27f6 G) (n : \u2115) :\n  F.right_derived n \u27f6 G.right_derived n :=\nwhisker_left (injective_resolutions C)\n  (whisker_right (nat_trans.map_homotopy_category \u03b1 _)\n    (homotopy_category.homology_functor D _ n))\n\n@[simp] lemma nat_trans.right_derived_id (F : C \u2964 D) [F.additive] (n : \u2115) :\n  nat_trans.right_derived (\ud835\udfd9 F) n = \ud835\udfd9 (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 \u2964 D} [F.additive] [G.additive] [H.additive]\n  (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H) (n : \u2115) :\n  nat_trans.right_derived (\u03b1 \u226b \u03b2) n = nat_trans.right_derived \u03b1 n \u226b nat_trans.right_derived \u03b2 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 \u2964 D} [F.additive] [G.additive] (\u03b1 : F \u27f6 G) (n : \u2115)\n  {X : C} (P : InjectiveResolution X) :\n  (nat_trans.right_derived \u03b1 n).app X =\n    (F.right_derived_obj_iso n P).hom \u226b\n      (homology_functor D _ n).map ((nat_trans.map_homological_complex \u03b1 _).app P.cocomplex) \u226b\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 [\u2190homology_functor_map, homotopy_category.homology_functor_map_factors],\n  simp only [\u2190functor.map_comp],\n  congr' 1,\n  apply homotopy_category.eq_of_homotopy,\n  simp only [nat_trans.map_homological_complex_naturality_assoc,\n    \u2190functor.map_comp],\n  apply homotopy.comp_left_id,\n  rw [\u2190functor.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 \u2964 D) {X Y Z : C} {f : X \u27f6 Y} {g : Y \u27f6 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 [\u2190 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 \u27f6 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 \u27f6 F.obj X :=\n(right_derived_obj_iso F 0 P).hom \u226b (homology_iso_kernel_desc _ _ _).hom \u226b\n  kernel.map _ _ (cokernel.desc _ (\ud835\udfd9 _) (by simp)) (\ud835\udfd9 _) (by { ext, simp }) \u226b\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 \u27f6 (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 \u27f6 (F.right_derived 0).obj X :=\nhomology.lift _ _ _ (F.map (P.\u03b9.f 0) \u226b cokernel.\u03c0 _) begin\n  have : (complex_shape.up \u2115).rel 0 1 := rfl,\n  rw [category.assoc, cokernel.\u03c0_desc, homological_complex.d_from_eq _ this,\n    map_homological_complex_obj_d, \u2190 category.assoc, \u2190 functor.map_comp],\n  simp only [InjectiveResolution.\u03b9_f_zero_comp_complex_d, functor.map_zero, zero_comp],\nend \u226b (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 \u226b\n  right_derived_zero_to_self_app_inv F P = \ud835\udfd9 _ :=\nbegin\n  dsimp [right_derived_zero_to_self_app, right_derived_zero_to_self_app_inv],\n  rw [\u2190 category.assoc, iso.comp_inv_eq, category.id_comp, category.assoc, category.assoc,\n    \u2190 iso.eq_inv_comp, iso.inv_hom_id],\n  ext,\n  rw [category.assoc, category.assoc, homology.lift_\u03b9, category.id_comp,\n    homology.\u03c0'_\u03b9, category.assoc, \u2190category.assoc _ _ (cokernel.\u03c0 _), abelian.kernel.lift.inv,\n    \u2190 category.assoc, \u2190 category.assoc _ (kernel.\u03b9 _), limits.kernel.lift_\u03b9, category.assoc,\n    category.assoc, \u2190 category.assoc (homology_iso_kernel_desc _ _ _).hom _ _, \u2190 homology.\u03b9,\n    \u2190category.assoc, homology.\u03c0'_\u03b9, category.assoc, \u2190category.assoc (cokernel.\u03c0 _), cokernel.\u03c0_desc,\n    whisker_eq],\n  convert category.id_comp (cokernel.\u03c0 _),\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 \u226b\n  right_derived_zero_to_self_app F P = \ud835\udfd9 _ :=\nbegin\n  dsimp [right_derived_zero_to_self_app, right_derived_zero_to_self_app_inv],\n  rw [\u2190 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    \u2190 category.assoc, \u2190 category.assoc, is_iso.comp_inv_eq, category.id_comp],\n  ext,\n  simp only [limits.kernel.lift_\u03b9_assoc, category.assoc, limits.kernel.lift_\u03b9, homology.lift],\n  rw [\u2190 category.assoc, \u2190 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 \u2245 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 \u2245 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 \u27f6 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 \u27f6 Y)\n  (P : InjectiveResolution X) (Q : InjectiveResolution Y) :\n  F.map f \u226b right_derived_zero_to_self_app_inv F Q =\n  right_derived_zero_to_self_app_inv F P \u226b (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, \u2190 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, \u2190 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_\u03b9, category.assoc, homology.map_\u03b9,\n    \u2190category.assoc (homology.lift _ _ _ _ _) _ _, homology.lift_\u03b9, category.assoc, cokernel.\u03c0_desc,\n    \u2190category.assoc, \u2190 functor.map_comp, \u2190 category.assoc, homological_complex.hom.sq_from_left,\n    map_homological_complex_map_f, \u2190 functor.map_comp,\n    show f \u226b Q.\u03b9.f 0 = P.\u03b9.f 0 \u226b (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) \u2245 F`. -/\ndef right_derived_zero_iso_self [enough_injectives C] [preserves_finite_limits F] :\n  (F.right_derived 0) \u2245 F := iso.symm $\nnat_iso.of_components (\u03bb X, (right_derived_zero_to_self_app_iso _ (InjectiveResolution.of X)).symm)\n  (\u03bb 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 (\u2119 : Type u) :=\n(entails : \u2119 \u2192 \u2119 \u2192 Prop)\n(empty : \u2119)\n(pure : Prop \u2192 \u2119)\n(and : \u2119 \u2192 \u2119 \u2192 \u2119)\n(or : \u2119 \u2192 \u2119 \u2192 \u2119)\n(implies : \u2119 \u2192 \u2119 \u2192 \u2119)\n(for_all (A : Type u) : (A \u2192 \u2119) \u2192 \u2119)\n(there_exists (A : Type u) : (A \u2192 \u2119) \u2192 \u2119)\n(sep : \u2119 \u2192 \u2119 \u2192 \u2119)\n(wand : \u2119 \u2192 \u2119 \u2192 \u2119)\n(persistently : \u2119 \u2192 \u2119)\n(later : \u2119 \u2192 \u2119)\n\ninfixr ` \u22a2 `:26 := bi_struct.entails\nnotation `\u231c`:1 p:200 `\u231d` := bi_struct.pure p\ninfixr ` \u22c0 `:35 := bi_struct.and\ninfixr ` \u22c1 `:30 := bi_struct.or\ninfixr ` => `:28 := bi_struct.implies\nnotation `\u2200'` binders `, ` r:(scoped f, bi_struct.for_all _ f) := r\nnotation `\u2203'` binders `, ` r:(scoped f, bi_struct.there_exists _ f) := r\ninfixl ` \u2217 `:80 := bi_struct.sep\ninfixr ` -\u2217 `:90 := bi_struct.wand\nprefix `\u25b7 `:100 := bi_struct.later\n\nexport bi_struct (persistently)\n\ndef bi.empty {\u2119 : Type u} [bi_struct \u2119] : \u2119 := bi_struct.empty\ndef bi.true {\u2119 : Type u} [bi_struct \u2119] : \u2119 := \u231ctrue\u231d\ndef bi.false {\u2119 : Type u} [bi_struct \u2119] : \u2119 := \u231cfalse\u231d\n\n/-- Laws for `\u22a2`. -/\nclass bi_entails (\u2119 : Type u) [bi_struct \u2119] :=\n(entails_preorder : is_preorder \u2119 (\u22a2))\n(propext {P Q : \u2119} : P \u22a2 Q \u2192 Q \u22a2 P \u2192 P = Q)\n\n-- TODO: Is `bi_mixin_pure_ne` required given Lean's `propext`?\n\n/-- Nonexpansivity laws. -/\nclass bi_nonexpansive (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] :=\n(and_nonexpansive : is_nonexpansive (function.uncurry ((\u22c0) : \u2119 \u2192 \u2119 \u2192 \u2119)))\n(or_nonexpansive : is_nonexpansive (function.uncurry ((\u22c1) : \u2119 \u2192 \u2119 \u2192 \u2119)))\n(implies_nonexpansive : is_nonexpansive (function.uncurry ((=>) : \u2119 \u2192 \u2119 \u2192 \u2119)))\n(forall_nonexpansive (A : Type u) : is_nonexpansive (bi_struct.for_all A : (A \u2192 \u2119) \u2192 \u2119))\n(exists_nonexpansive (A : Type u) : is_nonexpansive (bi_struct.there_exists A : (A \u2192 \u2119) \u2192 \u2119))\n(sep_nonexpansive : is_nonexpansive (function.uncurry ((\u2217) : \u2119 \u2192 \u2119 \u2192 \u2119)))\n(wand_nonexpansive : is_nonexpansive (function.uncurry ((-\u2217) : \u2119 \u2192 \u2119 \u2192 \u2119)))\n(persistently_nonexpansive : is_nonexpansive (bi_struct.persistently : \u2119 \u2192 \u2119))\n\n/-- Laws for higher-order logic. -/\nclass bi_hol (\u2119 : Type u) [bi_struct \u2119] :=\n(pure_intro {p : Prop} {P : \u2119} : p \u2192 P \u22a2 \u231cp\u231d)\n(pure_elim {p : Prop} {P : \u2119} : (p \u2192 bi.true \u22a2 P) \u2192 \u231cp\u231d \u22a2 P)\n(and_intro {P Q R : \u2119} : P \u22a2 Q \u2192 P \u22a2 R \u2192 P \u22a2 Q \u22c0 R)\n(and_elim_left {P Q : \u2119} : P \u22c0 Q \u22a2 P)\n(and_elim_right {P Q : \u2119} : P \u22c0 Q \u22a2 Q)\n(or_intro_left {P Q : \u2119} : P \u22a2 P \u22c1 Q)\n(or_intro_right {P Q : \u2119} : Q \u22a2 P \u22c1 Q)\n(or_elim {P Q R : \u2119} : P \u22a2 R \u2192 Q \u22a2 R \u2192 P \u22c1 Q \u22a2 R)\n(implies_intro {P Q R : \u2119} : P \u22c0 Q \u22a2 R \u2192 P \u22a2 Q => R)\n(implies_elim {P Q R : \u2119} : P \u22a2 Q => R \u2192 P \u22c0 Q \u22a2 R)\n(forall_intro {A : Type u} {P : \u2119} {Q : A \u2192 \u2119} : (\u2200 a, P \u22a2 Q a) \u2192 P \u22a2 \u2200' a, Q a)\n(forall_elim {A : Type u} {\u03a6 : A \u2192 \u2119} {a : A} : (\u2200' a, \u03a6 a) \u22a2 \u03a6 a)\n(exists_intro {A : Type u} {\u03a6 : A \u2192 \u2119} {a : A} : \u03a6 a \u22a2 \u2203' a, \u03a6 a)\n(exists_elim {A : Type u} {P : \u2119} {Q : A \u2192 \u2119} : (\u2200 a, Q a \u22a2 P) \u2192 (\u2203' a, Q a) \u22a2 P)\n\n/-- Laws for separating conjunction. -/\nclass bi_connectives (\u2119 : Type u) [bi_struct \u2119] :=\n(sep_mono {P Q R S : \u2119} : P \u22a2 Q \u2192 R \u22a2 S \u2192 P \u2217 R \u22a2 Q \u2217 S)\n(empty_sep {P : \u2119} : P \u22a2 bi.empty \u2217 P)\n(sep_empty {P : \u2119} : P \u22a2 P \u2217 bi.empty)\n(sep_comm {P Q : \u2119} : P \u2217 Q \u22a2 Q \u2217 P)\n(sep_assoc {P Q R : \u2119} : P \u2217 Q \u2217 R \u22a2 P \u2217 (Q \u2217 R))\n(wand_intro {P Q R : \u2119} : P \u2217 Q \u22a2 R \u2192 P \u22a2 Q -\u2217 R)\n(wand_elim {P Q R : \u2119} : P \u22a2 Q -\u2217 R \u2192 P \u2217 Q \u22a2 R)\n\nclass bi_persistently (\u2119 : Type u) [bi_struct \u2119] :=\n(persistently_mono {P Q : \u2119} : P \u22a2 Q \u2192 persistently P \u22a2 persistently Q)\n(persistently_persistently {P : \u2119} : persistently P \u22a2 persistently (persistently P))\n(persistently_empty : (bi.empty : \u2119) \u22a2 persistently bi.empty)\n(persistently_and {P Q : \u2119} : persistently P \u22c0 persistently Q \u22a2 persistently (P \u22c0 Q))\n(persistently_exists {A : Type u} {\u03a6 : A \u2192 \u2119} :\n  persistently (\u2203' a, \u03a6 a) \u22a2 \u2203' a, persistently (\u03a6 a))\n(persistently_sep {P Q : \u2119} : persistently (P \u2217 Q) \u22a2 persistently P)\n(persistently_and_sep_elim {P Q : \u2119} : persistently (P \u22c0 Q) \u22a2 P \u2217 Q)\n\nclass bi_later (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] :=\n(later_nonexpansive : is_nonexpansive (bi_struct.later : \u2119 \u2192 \u2119))\n(later_mono {P Q : \u2119} : P \u22a2 Q \u2192 \u25b7 P \u22a2 \u25b7 Q)\n(later_intro {P : \u2119} : P \u22a2 \u25b7 P)\n(forall_later {A : Type u} {\u03a6 : A \u2192 \u2119} : (\u2200' a, \u25b7 \u03a6 a) \u22a2 \u25b7 \u2200' a, \u03a6 a)\n(later_exists_false {A : Type u} {\u03a6 : A \u2192 \u2119} : (\u25b7 \u2203' a, \u03a6 a) \u22a2 \u25b7 bi.false \u22c1 (\u2203' a, \u25b7 \u03a6 a))\n(later_sep {P Q : \u2119} : \u25b7 (P \u2217 Q) \u22a2 \u25b7 P \u2217 \u25b7 Q)\n(later_sep' {P Q : \u2119} : \u25b7 P \u2217 \u25b7 Q \u22a2 \u25b7 (P \u2217 Q))\n(persistently_later {P : \u2119} : \u25b7 persistently P \u22a2 persistently \u25b7 P)\n(later_persistently {P : \u2119} : persistently \u25b7 P \u22a2 \u25b7 persistently P)\n(later_false_em {P : \u2119} : \u25b7 P \u22a2 \u25b7 bi.false \u22c1 (\u25b7 bi.false => P))\n\nclass bi (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] extends\n  bi_entails \u2119, bi_nonexpansive \u2119, bi_hol \u2119, bi_connectives \u2119, bi_persistently \u2119, bi_later \u2119\n\nnamespace bi\n\nvariables {\u2119 : Type u} [ofe \u2119] [bi_struct \u2119] [bi \u2119]\nvariables {n : \u2115} {p : Prop} {A : Type u} {P Q R S : \u2119} {\u03a6 \u03a8 : A \u2192 \u2119}\n\n/-!\n# Laws for `\u22a2`\n-/\n\n@[refl] lemma entails_refl (P : \u2119) : P \u22a2 P := bi_entails.entails_preorder.1.refl P\nlemma entails_rfl {P : \u2119} : P \u22a2 P := entails_refl P\n/-- The cut law. -/\n@[trans] lemma entails_trans : P \u22a2 Q \u2192 Q \u22a2 R \u2192 P \u22a2 R := bi_entails.entails_preorder.2.trans P Q R\nlemma propext : P \u22a2 Q \u2192 Q \u22a2 P \u2192 P = Q := bi_entails.propext\n\nlemma propext_iff : P = Q \u2194 (P \u22a2 Q) \u2227 (Q \u22a2 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 \u2192 Q =[n] S \u2192 (P \u22c0 Q) =[n] (R \u22c0 S) :=\nbegin\n  intros h\u2081 h\u2082,\n  have := bi_nonexpansive.and_nonexpansive,\n  exact @this n \u27e8P, Q\u27e9 \u27e8R, S\u27e9 \u27e8h\u2081, h\u2082\u27e9,\n  apply_instance,\nend\n\nlemma or_eq_at : P =[n] R \u2192 Q =[n] S \u2192 (P \u22c1 Q) =[n] (R \u22c1 S) :=\nbegin\n  intros h\u2081 h\u2082,\n  have := bi_nonexpansive.or_nonexpansive,\n  exact @this n \u27e8P, Q\u27e9 \u27e8R, S\u27e9 \u27e8h\u2081, h\u2082\u27e9,\n  apply_instance,\nend\n\nlemma implies_eq_at : P =[n] R \u2192 Q =[n] S \u2192 (P => Q) =[n] (R => S) :=\nbegin\n  intros h\u2081 h\u2082,\n  have := bi_nonexpansive.implies_nonexpansive,\n  exact @this n \u27e8P, Q\u27e9 \u27e8R, S\u27e9 \u27e8h\u2081, h\u2082\u27e9,\n  apply_instance,\nend\n\nlemma forall_eq_at : (\u2200 a, \u03a6 a =[n] \u03a8 a) \u2192 (\u2200' a, \u03a6 a) =[n] (\u2200' a, \u03a8 a) :=\n\u03bb h, bi_nonexpansive.forall_nonexpansive A h\n\nlemma exists_eq_at : (\u2200 a, \u03a6 a =[n] \u03a8 a) \u2192 (\u2203' a, \u03a6 a) =[n] (\u2203' a, \u03a8 a) :=\n\u03bb h, bi_nonexpansive.exists_nonexpansive A h\n\nlemma sep_eq_at : P =[n] R \u2192 Q =[n] S \u2192 (P \u2217 Q) =[n] (R \u2217 S) :=\nbegin\n  intros h\u2081 h\u2082,\n  have := bi_nonexpansive.sep_nonexpansive,\n  exact @this n \u27e8P, Q\u27e9 \u27e8R, S\u27e9 \u27e8h\u2081, h\u2082\u27e9,\n  apply_instance,\nend\n\nlemma wand_eq_at : P =[n] R \u2192 Q =[n] S \u2192 (P -\u2217 Q) =[n] (R -\u2217 S) :=\nbegin\n  intros h\u2081 h\u2082,\n  have := bi_nonexpansive.wand_nonexpansive,\n  exact @this n \u27e8P, Q\u27e9 \u27e8R, S\u27e9 \u27e8h\u2081, h\u2082\u27e9,\n  apply_instance,\nend\n\nlemma persistently_eq_at : P =[n] Q \u2192 persistently P =[n] persistently Q :=\n\u03bb 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 \u2192 P \u22a2 \u231cp\u231d := bi_hol.pure_intro\nlemma pure_elim : (p \u2192 true \u22a2 P) \u2192 \u231cp\u231d \u22a2 P := bi_hol.pure_elim\nlemma entails_true : P \u22a2 true := pure_intro trivial\nlemma false_entails : false \u22a2 P := pure_elim false.elim\n\n/-! ## Basic logical laws -/\n\nlemma and_intro : P \u22a2 Q \u2192 P \u22a2 R \u2192 P \u22a2 Q \u22c0 R := bi_hol.and_intro\nlemma and_elim_left : P \u22c0 Q \u22a2 P := bi_hol.and_elim_left\nlemma and_elim_right : P \u22c0 Q \u22a2 Q := bi_hol.and_elim_right\n\nlemma or_intro_left : P \u22a2 P \u22c1 Q := bi_hol.or_intro_left\nlemma or_intro_right : Q \u22a2 P \u22c1 Q := bi_hol.or_intro_right\nlemma or_elim : P \u22a2 R \u2192 Q \u22a2 R \u2192 P \u22c1 Q \u22a2 R := bi_hol.or_elim\n\nlemma implies_intro : P \u22c0 Q \u22a2 R \u2192 P \u22a2 Q => R := bi_hol.implies_intro\nlemma implies_elim : P \u22a2 Q => R \u2192 P \u22c0 Q \u22a2 R := bi_hol.implies_elim\nlemma implies_iff : P \u22a2 Q => R \u2194 P \u22c0 Q \u22a2 R := \u27e8implies_elim, implies_intro\u27e9\n\nlemma forall_intro : (\u2200 a, P \u22a2 \u03a6 a) \u2192 P \u22a2 \u2200' a, \u03a6 a := bi_hol.forall_intro\nlemma forall_elim (\u03a6 : A \u2192 \u2119) (a : A) : (\u2200' a, \u03a6 a) \u22a2 \u03a6 a := bi_hol.forall_elim\n\nlemma exists_intro (\u03a6 : A \u2192 \u2119) (a : A) : \u03a6 a \u22a2 \u2203' a, \u03a6 a := bi_hol.exists_intro\nlemma exists_elim : (\u2200 a, \u03a6 a \u22a2 P) \u2192 (\u2203' a, \u03a6 a) \u22a2 P := bi_hol.exists_elim\n\n/-!\n## Heyting algebra\n\nWe show `\u2119` forms a Heyting algebra and a complete lattice.\nWe can deduce many logical laws from these typeclasses.\n-/\n\ninstance : lattice \u2119 := {\n  sup := (\u22c1),\n  inf := (\u22c0),\n  le := (\u22a2),\n  le_refl := entails_refl,\n  le_trans := \u03bb _ _ _, entails_trans,\n  le_antisymm := \u03bb _ _, propext,\n  le_sup_left := \u03bb _ _, or_intro_left,\n  le_sup_right := \u03bb _ _, or_intro_right,\n  sup_le := \u03bb _ _ _, or_elim,\n  inf_le_left := \u03bb _ _, and_elim_left,\n  inf_le_right := \u03bb _ _, and_elim_right,\n  le_inf := \u03bb _ _ _, and_intro,\n}\n\ninstance : heyting_algebra \u2119 := {\n  top := true,\n  himp := (=>),\n  le_top := \u03bb _, entails_true,\n  le_himp_iff := \u03bb _ _ _, implies_iff,\n  bot := false,\n  compl := \u03bb P, P => false,\n  bot_le := \u03bb _, false_entails,\n  himp_bot := \u03bb _, rfl,\n  ..bi.lattice\n}\n\ninstance : complete_lattice \u2119 := {\n  Sup := \u03bb S, \u2203' P : S, P,\n  le_Sup := \u03bb S P hP, exists_intro (\u03bb p : S, (p : \u2119)) (\u27e8P, hP\u27e9 : S),\n  Sup_le := \u03bb S P h, exists_elim (\u03bb Q, h Q Q.prop),\n  Inf := \u03bb S, \u2200' P : S, P,\n  Inf_le := \u03bb S P hP, forall_elim (\u03bb p : S, (p : \u2119)) (\u27e8P, hP\u27e9 : S),\n  le_Inf := \u03bb S P h, forall_intro (\u03bb Q, h Q Q.prop),\n  ..bi.heyting_algebra\n}\n\ninstance : distrib_lattice \u2119 := generalized_heyting_algebra.to_distrib_lattice\n\nlemma and_or_distrib_left : (P \u22c0 (Q \u22c1 R)) = (P \u22c0 Q \u22c1 P \u22c0 R) := inf_sup_left\nlemma and_or_distrib_right : ((P \u22c1 Q) \u22c0 R) = (P \u22c0 R \u22c1 Q \u22c0 R) := inf_sup_right\nlemma or_and_distrib_left : (P \u22c1 (Q \u22c0 R)) = ((P \u22c1 Q) \u22c0 (P \u22c1 R)) := sup_inf_left\nlemma or_and_distrib_right : ((P \u22c0 Q) \u22c1 R) = ((P \u22c1 R) \u22c0 (Q \u22c1 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 \u22a2 Q \u2192 R \u22a2 S \u2192 P \u2217 R \u22a2 Q \u2217 S := bi_connectives.sep_mono\nlemma empty_sep : P \u22a2 empty \u2217 P := bi_connectives.empty_sep\nlemma sep_empty : P \u22a2 P \u2217 empty := bi_connectives.sep_empty\nlemma sep_comm : P \u2217 Q = Q \u2217 P := propext bi_connectives.sep_comm bi_connectives.sep_comm\nlemma sep_assoc : P \u2217 Q \u2217 R = P \u2217 (Q \u2217 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 \u22a2 Q -\u2217 R) \u2194 (P \u2217 Q \u22a2 R) :=\n\u27e8bi_connectives.wand_elim, bi_connectives.wand_intro\u27e9\n\n/-!\n## Persistently\n-/\n\nlemma persistently_mono : P \u22a2 Q \u2192 persistently P \u22a2 persistently Q :=\nbi_persistently.persistently_mono\n\nlemma persistently_persistently : persistently P \u22a2 persistently (persistently P) :=\nbi_persistently.persistently_persistently\n\nlemma persistently_empty : (empty : \u2119) \u22a2 persistently empty :=\nbi_persistently.persistently_empty\n\nlemma persistently_and : persistently P \u22c0 persistently Q \u22a2 persistently (P \u22c0 Q) :=\nbi_persistently.persistently_and\n\nlemma persistently_exists : persistently (\u2203' a, \u03a6 a) \u22a2 \u2203' a, persistently (\u03a6 a) :=\nbi_persistently.persistently_exists\n\nlemma persistently_sep : persistently (P \u2217 Q) \u22a2 persistently P :=\nbi_persistently.persistently_sep\n\nlemma persistently_and_sep_elim : persistently (P \u22c0 Q) \u22a2 P \u2217 Q :=\nbi_persistently.persistently_and_sep_elim\n\n/-!\n# Later\n-/\n\nlemma later_nonexpansive : is_nonexpansive (bi_struct.later : \u2119 \u2192 \u2119) :=\nbi_later.later_nonexpansive\n\nlemma later_mono : P \u22a2 Q \u2192 \u25b7 P \u22a2 \u25b7 Q :=\nbi_later.later_mono\n\nlemma later_intro : P \u22a2 \u25b7 P :=\nbi_later.later_intro\n\nlemma forall_later : (\u2200' a, \u25b7 \u03a6 a) \u22a2 \u25b7 \u2200' a, \u03a6 a :=\nbi_later.forall_later\n\nlemma later_exists_false : (\u25b7 \u2203' a, \u03a6 a) \u22a2 \u25b7 false \u22c1 (\u2203' a, \u25b7 \u03a6 a) :=\nbi_later.later_exists_false\n\nlemma later_sep : (\u25b7 (P \u2217 Q)) = (\u25b7 P \u2217 \u25b7 Q) :=\npropext bi_later.later_sep bi_later.later_sep'\n\nlemma persistently_later : (\u25b7 persistently P) = (persistently \u25b7 P) :=\npropext bi_later.persistently_later bi_later.later_persistently\n\nlemma later_false_em : \u25b7 P \u22a2 \u25b7 false \u22c1 (\u25b7 false => P) :=\nbi_later.later_false_em\n\n/-!\n# Derived connectives\n-/\n\ndef iff (P Q : \u2119) : \u2119 := (P => Q) \u22c0 (Q => P)\ninfixr ` <=> `:28 := iff\n\ndef wand_iff (P Q : \u2119) : \u2119 := (P -\u2217 Q) \u22c0 (Q -\u2217 P)\ninfixr ` \u2217-\u2217 `:90 := wand_iff\n\nclass persistent (P : \u2119) : Prop :=\n(entails_persistently : P \u22a2 persistently P)\n\ndef affinely (P : \u2119) := empty \u22c0 P\n\nclass affine (P : \u2119) : Prop :=\n(entails_empty : P \u22a2 empty)\n\ndef absorbingly (P : \u2119) := true \u2217 P\n\nclass absorbing (P : \u2119) : Prop :=\n(absorbingly_entails : absorbingly P \u22a2 P)\n\ndef intuitionistically : \u2119 \u2192 \u2119 := affinely \u2218 persistently\nprefix `\u25a1 `:100 := intuitionistically\n\ndef persistently_if (p : Prop) [decidable p] (P : \u2119) :=\nif p then persistently P else P\n\ndef affinely_if (p : Prop) [decidable p] (P : \u2119) :=\nif p then affinely P else P\n\ndef absorbingly_if (p : Prop) [decidable p] (P : \u2119) :=\nif p then absorbingly P else P\n\ndef intuitionistically_if (p : Prop) [decidable p] (P : \u2119) :=\nif p then \u25a1 P else P\n\ndef latern : \u03a0 (n : \u2115) (P : \u2119), \u2119\n| 0 P := P\n| (n + 1) P := \u25b7 latern n P\n\ndef except_zero (P : \u2119) := \u25b7 false \u22c1 P\nprefix `\u25c7 `:100 := except_zero\n\nclass timeless (P : \u2119) : Prop :=\n(later_entails_except_zero : \u25b7 P \u22a2 \u25c7 P)\n\n/-!\n# Extensions\n\nDefinitions for various extensions to the BI interface.\n-/\n\nclass bi_affine (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] [bi \u2119] : Prop :=\n(is_affine (P : \u2119) : affine P)\n\nclass bi_positive (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] [bi \u2119] : Prop :=\n(affinely_sep (P Q : \u2119) : affinely (P \u2217 Q) \u22a2 affinely P \u2217 Q)\n\nclass bi_loeb (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] [bi \u2119] : Prop :=\n(true_entails (P : \u2119) : \u25b7 P \u22a2 P \u2192 true \u22a2 P)\n\nclass bi_later_contractive (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] [bi \u2119] : Prop :=\n(later_contractive : is_contractive (bi_struct.later : \u2119 \u2192 \u2119))\n\nclass bi_persistently_forall (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] [bi \u2119] : Prop :=\n(persistently_forall {A : Type u} {\u03a6 : A \u2192 \u2119} : (\u2200' a, persistently (\u03a6 a)) \u22a2 persistently \u2200' a, \u03a6 a)\n\nclass bi_pure_forall (\u2119 : Type u) [ofe \u2119] [bi_struct \u2119] [bi \u2119] : Prop :=\n(pure_forall {A : Type u} {\u03a6 : A \u2192 Prop} : (\u2200' a, \u231c\u03a6 a\u231d : \u2119) \u22a2 \u231c\u2200 a, \u03a6 a\u231d)\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 \u2192 list A \u2192 list A \n  | a [] := []\n  | a (x::xs) := ite (a \u2208 (x::xs)) (rmv_unt_aux a xs) (x::xs)\n  \nlemma rmv_aux_not_a {A : Type} [decidable_eq A] : \u2200 a : A, \u2200 l : list A,\na \u2209 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] : \u2200 a b: A, \u2200 l : list A,\ncount b (rmv_unt_aux a l) \u2264 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] : \u2200 a: A, \u2200 l : list A,\nlength (rmv_unt_aux a l) \u2264 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] : \u2200 a b: A, \u2200 l : list A,\nb \u2208 (rmv_unt_aux a l) \u2192 b \u2208 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] : \u2200 a : A, \u2200 l : list A,\n(rmv_unt_aux a l) = l \u2228 (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] : \u2200 a : A, \u2200 l : list A,\n(rmv_unt_aux a l) = l \u2194 (a \u2209 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] : \u2200 a : A, \u2200 l : list A,\n(rmv_unt_aux a l) = nil \u2194 l = nil \u2228 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 \u2192 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] : \u2200 b: A, \u2200 l : list A,\n b \u2208 (rmv_unt l) \u2192 b \u2208 l  :=\nbegin \n  intros b l,\n  obtain \u27e8n, hn\u27e9 : {n : \u2115 // l.length = n} := \u27e8_, rfl\u27e9,\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 \u22a2,\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 \u2190 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] : \u2200 l : list A,\nnodup (rmv_unt l) :=\nbegin \n  intros l,\n  obtain \u27e8n, hn\u27e9 : {n : \u2115 // l.length = n} := \u27e8_, rfl\u27e9,\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 \u2190 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] : \u2200 l : list A,\nl = nil \u2194 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] : \u2200 l : list A,\n(l \u2260 nil) \u2192 (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] : \u2200 l : list A,\n(l \u2260 nil) \u2192 (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 \u00d7 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 (\u21a5G \u00d7 \u21a5H))\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 \u21a5G \u21a5H)\n            (add_monoid_hom.snd \u21a5G \u21a5H)))\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.\u03c0 s)\n            category_theory.limits.walking_pair.left)\n          (category_theory.nat_trans.app (category_theory.limits.cone.\u03c0 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 \u229e H \u2245 of (\u21a5G \u00d7 \u21a5H) :=\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 \u2964 AddCommGroup)\n    (s : category_theory.limits.cone F) :\n    category_theory.limits.cone.X s \u27f6\n        of ((j : category_theory.discrete J) \u2192 \u21a5(category_theory.functor.obj F j)) :=\n  add_monoid_hom.mk\n    (fun (x : \u21a5(category_theory.limits.cone.X s)) (j : category_theory.discrete J) =>\n      coe_fn (category_theory.nat_trans.app (category_theory.limits.cone.\u03c0 s) j) x)\n    sorry sorry\n\n@[simp] theorem lift_apply {J : Type u} (F : category_theory.discrete J \u2964 AddCommGroup)\n    (s : category_theory.limits.cone F) (x : \u21a5(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.\u03c0 s) j) x :=\n  rfl\n\n/--\nConstruct limit data for a product in `AddCommGroup`, using `AddCommGroup.of (\u03a0 j, F.obj j)`.\n-/\ndef product_limit_cone {J : Type u} (F : category_theory.discrete J \u2964 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) \u2192 \u21a5(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) => \u21a5(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 \u2192 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 \u2192 AddCommGroup) :\n    \u2a01 f \u2245 of ((j : J) \u2192 \u21a5(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 \u2192 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 \u2286 J\u00b9(E, F)` which consist of all\n`(x, y, \u03d5)` such that if `x` is outside a ball around the origin with chosen radius `R < 1` then\n`\u03d5` must be injective on `(\u211d \u2219 x)\u15ee` (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 \u2243 \u211d\u00b3`.\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 \u211d E]\n{F : Type*} [normed_add_comm_group F] [inner_product_space \u211d F]\n\nlocal notation `\ud835\udd4a\u00b2` := sphere (0 : E) 1\nlocal notation `dim` := finrank \u211d\nlocal notation `pr[`x`]\u15ee` := orthogonal_projection (\u211d \u2219 x)\u15ee\nlocal notation (name := dot_print_only) R ` \u2219 `:1000 x := submodule.span R {x}\nlocal notation (name := dot_local) R ` \u2219 `: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 \u2208 \ud835\udd4a\u00b2` 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 \u2208 \ud835\udd4a\u00b2` since otherwise `D f x = 0`.\n-/\ndef sphere_immersion (f : E \u2192 F) : Prop :=\n\u2200 x \u2208 \ud835\udd4a\u00b2, inj_on (D f x) (\u211d \u2219 x)\u15ee\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 \u2209 B \u2192 inj_on w.2.2 (\u211d \u2219 w.1)\u15ee }\n\nlocal notation `R` := immersion_sphere_rel E F\n\nvariables {E F}\n\n@[simp] lemma mem_loc_immersion_rel {x y \u03c6} :\n  (\u27e8x, y, \u03c6\u27e9 : one_jet E F) \u2208 immersion_sphere_rel E F \u2194 x \u2209 B \u2192 inj_on \u03c6 (\u211d \u2219 x)\u15ee :=\niff.rfl\n\nlemma sphere_immersion_of_sol (f : E \u2192 F) :\n  (\u2200 x \u2208 \ud835\udd4a\u00b2, (x, f x, fderiv \u211d f x) \u2208 immersion_sphere_rel E F) \u2192 sphere_immersion f :=\nbegin\n  intros h x x_in,\n  have : x \u2209 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} {\u03c6 : E \u2192L[\u211d] F} {p : dual_pair E}\n  (hx : x \u2209 B) (y : F) : w \u2208 slice R p (x, y, \u03c6) \u2194 inj_on (p.update \u03c6 w) (\u211d \u2219 x)\u15ee :=\nbegin\n  change (x \u2209 B \u2192 inj_on (p.update \u03c6 w) (\u211d \u2219 x)\u15ee) \u2194 inj_on (p.update \u03c6 w) (\u211d \u2219 x)\u15ee,\n  simp_rw [eq_true_intro hx, true_implies_iff]\nend\n\nsection assume_finite_dimensional\n\nvariables [finite_dimensional \u211d 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\u2080 : E} {y\u2080 : F} {\u03c6\u2080 : E \u2192L[\u211d] F} (hx\u2080 : x\u2080 \u2209 B)\n  (H : inj_on \u03c6\u2080 (\u211d \u2219 x\u2080)\u15ee) :\n  \u2200\u1da0 (p : one_jet E F) in \ud835\udcdd (x\u2080, y\u2080, \u03c6\u2080), \u27eax\u2080, p.1\u27eb \u2260 0 \u2227\n  injective ((p.2.2.comp $ (subtypeL (\u211d \u2219 p.1)\u15ee).comp pr[p.1]\u15ee).comp (\u211d \u2219 x\u2080)\u15ee.subtypeL) :=\nbegin\n  -- This is true at (x\u2080, y\u2080, \u03c6\u2080) and is an open condition because `p \u21a6 \u27eax\u2080, p.1\u27eb` and\n  -- `p \u21a6 (p.2.2.comp $ (subtypeL (\u211d \u2219 p.1)\u15ee).comp pr[p.1]\u15ee).comp j\u2080` are continuous\n  set j\u2080 := subtypeL (\u211d \u2219 x\u2080)\u15ee,\n  let f : one_jet E F \u2192 \u211d \u00d7 ((\u211d \u2219 x\u2080)\u15ee \u2192L[\u211d] F) :=\n      \u03bb p, (\u27eax\u2080, p.1\u27eb, (p.2.2.comp $ (subtypeL (\u211d \u2219 p.1)\u15ee).comp pr[p.1]\u15ee).comp j\u2080),\n  let P : \u211d \u00d7 ((\u211d \u2219 x\u2080)\u15ee \u2192L[\u211d] F) \u2192 Prop :=\n      \u03bb q, q.1 \u2260 0 \u2227 injective q.2,\n  have x\u2080_ne : x\u2080 \u2260 0,\n  { refine \u03bb hx\u2080', hx\u2080 _,\n    rw hx\u2080',\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 : \u2200\u1da0 (p : one_jet E F) in \ud835\udcdd (x\u2080, y\u2080, \u03c6\u2080), 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 ((\u03bb x, (\u211d \u2219 x)\u15ee.subtypeL.comp pr[x]\u15ee) \u2218 prod.fst) (x\u2080, y\u2080, \u03c6\u2080),\n      { exact this },\n      apply continuous_at.comp _ continuous_at_fst,\n      exact continuous_at_orthogonal_projection_orthogonal x\u2080_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 \u27eax\u2080, x\u2080\u27eb \u2260 0,\n      apply (inner_self_eq_zero.not).mpr x\u2080_ne },\n    { change injective (\u03c6\u2080 \u2218 (coe \u2218 (pr[x\u2080]\u15ee \u2218 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 \u27e8x\u2080, y\u2080, \u03c6\u2080\u27e9 (H : x\u2080 \u2209 B \u2192 inj_on \u03c6\u2080 (\u211d \u2219 x\u2080)\u15ee),\n  change \u2200\u1da0 (p : one_jet E F) in \ud835\udcdd (x\u2080, y\u2080, \u03c6\u2080), _,\n  by_cases hx\u2080 : x\u2080 \u2208 B,\n  { have : \u2200\u1da0 (p : one_jet E F) in \ud835\udcdd (x\u2080, y\u2080, \u03c6\u2080), p.1 \u2208 B,\n    { rw nhds_prod_eq,\n      apply (is_open_ball.eventually_mem hx\u2080).prod_inl },\n    apply this.mono,\n    rintros \u27e8x, y, \u03c6\u27e9 (hx : x \u2208 B) (Hx : x \u2209 B),\n    exact (Hx hx).elim },\n  { replace H := H hx\u2080,\n    set j\u2080 := subtypeL (\u211d \u2219 x\u2080)\u15ee,\n    let f : one_jet E F \u2192 \u211d \u00d7 ((\u211d \u2219 x\u2080)\u15ee \u2192L[\u211d] F) :=\n      \u03bb p, (\u27eax\u2080, p.1\u27eb, (p.2.2.comp $ (subtypeL (\u211d \u2219 p.1)\u15ee).comp pr[p.1]\u15ee).comp j\u2080),\n    let P : \u211d \u00d7 ((\u211d \u2219 x\u2080)\u15ee \u2192L[\u211d] F) \u2192 Prop :=\n      \u03bb q, q.1 \u2260 0 \u2227 injective q.2,\n    have : \u2200\u1da0 (p : one_jet E F) in \ud835\udcdd (x\u2080, y\u2080, \u03c6\u2080), P (f p),\n    { exact loc_immersion_rel_open_aux hx\u2080 H },\n    apply this.mono, clear this,\n    rintros \u27e8x, y, \u03c6\u27e9 \u27e8hxx\u2080 : \u27eax\u2080, x\u27eb \u2260 0, H\u03c6\u27e9 (hx : x \u2209 B),\n    dsimp only [P, f] at H\u03c6,\n    change inj_on \u03c6 (\u211d \u2219 x)\u15ee,\n    have : range ((subtypeL (\u211d \u2219 x)\u15ee) \u2218 pr[x]\u15ee \u2218 j\u2080) = (\u211d \u2219 x)\u15ee,\n    { rw function.surjective.range_comp,\n      exact subtype.range_coe,\n      exact (orthogonal_projection_orthogonal_line_iso hxx\u2080).surjective },\n    rw \u2190 this, clear this,\n    exact function.injective.inj_on_range H\u03c6 },\nend\n\nvariables [finite_dimensional \u211d 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 : \u2115) [fact (dim E = n+1)] (h : finrank \u211d E \u2264 finrank \u211d F) :\n  (immersion_sphere_rel E F).is_ample :=\nbegin\n  classical, -- gives a minor speedup\n  rw is_ample_iff,\n  rintro \u27e8x, y, \u03c6\u27e9 p h_mem,\n  by_cases hx : x \u2208 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 \u2260 0,\n  { rintro rfl,\n    apply hx,\n    apply mem_ball_self,\n    norm_num1 },\n  have h\u03c6 : inj_on \u03c6 (\u211d \u2219 x)\u15ee := h_mem hx, clear h_mem,\n  let u : E := (inner_product_space.to_dual \u211d E).symm p.\u03c0,\n  have u_ne : u \u2260 0,\n  { exact (inner_product_space.to_dual \u211d E).symm.apply_ne_zero p.pi_ne_zero },\n  by_cases H : ker p.\u03c0 = (\u211d \u2219 x)\u15ee,\n  { have key : \u2200 w, eq_on (p.update \u03c6 w) \u03c6 (\u211d \u2219 x)\u15ee,\n    { intros w x,\n      rw \u2190 H,\n      exact p.update_ker_pi \u03c6 w },\n    exact ample_slice_of_forall _ p (\u03bb w _, h\u03c6.congr (key w).symm) },\n  obtain \u27e8v', v'_in, hv', h\u03c0v'\u27e9 :\n    \u2203 v' : E, v' \u2208 (\u211d \u2219 x)\u15ee \u2227 (\u211d \u2219 x)\u15ee = (ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee) \u2294 (\u211d \u2219 v') \u2227 p.\u03c0 v' = 1,\n  { have ne_z : p.\u03c0 (pr[x]\u15ee u) \u2260 0,\n    { rw \u2190 to_dual_symm_apply,\n      change \u00ac \u27eau, pr[x]\u15ee u\u27eb = 0,\n      rw inner_projection_self_eq_zero_iff.not,\n      contrapose! H,\n      rw orthogonal_orthogonal at H,\n      rw [\u2190 orthogonal_span_to_dual_symm, span_singleton_eq_span_singleton_of_ne u_ne H],\n      apply_instance },\n    have ne_z' : (p.\u03c0 $ pr[x]\u15ee u)\u207b\u00b9 \u2260 0,\n    { exact inv_ne_zero ne_z },\n    refine \u27e8(p.\u03c0 $ pr[x]\u15ee u)\u207b\u00b9 \u2022 pr[x]\u15ee u, (\u211d \u2219 x)\u15ee.smul_mem _ (pr[x]\u15ee u).2, _, _\u27e9,\n    { have := orthogonal_line_inf_sup_line u x,\n      rw [\u2190 orthogonal_span_to_dual_symm p.\u03c0,\n        span_singleton_smul_eq ne_z'.is_unit],\n      exact (orthogonal_line_inf_sup_line u x).symm },\n    rw [p.\u03c0.map_smul, smul_eq_mul, inv_mul_cancel ne_z] },\n  let p' : dual_pair E := { \u03c0 := p.\u03c0, v := v', pairing := h\u03c0v' },\n  apply ample_slice_of_ample_slice (show p'.\u03c0 = p.\u03c0, from rfl),\n  suffices : slice R p' (x, y, \u03c6) = (map \u03c6 (ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee))\u1d9c,\n  { rw [this],\n    apply ample_of_two_le_codim,\n    let \u03a6 := \u03c6.to_linear_map,\n    suffices : 2 \u2264 dim (F \u29f8 map \u03a6 (ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee)),\n    { rw \u2190 finrank_eq_dim,\n      exact_mod_cast this },\n    apply le_of_add_le_add_right,\n    rw submodule.finrank_quotient_add_finrank (map \u03a6 $ ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee),\n    have : dim (ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee : submodule \u211d E) + 1 = n,\n    { have eq := submodule.dim_sup_add_dim_inf_eq (ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee) (span \u211d {v'}),\n      have eq\u2081 : dim (\u211d \u2219 x)\u15ee = n, from finrank_orthogonal_span_singleton x_ne,\n      have eq\u2082 : ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee \u2293 span \u211d {v'} = (\u22a5 : submodule \u211d E),\n      { erw [inf_left_right_swap, inf_comm, \u2190 inf_assoc, p'.inf_eq_bot, bot_inf_eq] },\n      have eq\u2083 : dim (span \u211d {v'}) = 1, apply finrank_span_singleton p'.v_ne_zero,\n      rw [\u2190 hv', eq\u2081, eq\u2083, eq\u2082] at eq,\n      simpa only [finrank_bot] using eq.symm },\n    have : dim E = n+1, from fact.out _,\n    linarith [finrank_map_le \u211d \u03a6 (ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee)] },\n  ext w,\n  rw mem_slice_iff_of_not_mem hx y,\n  rw inj_on_iff_injective,\n  let j := (\u211d \u2219 x)\u15ee.subtypeL,\n  let p'' : dual_pair (\u211d \u2219 x)\u15ee := \u27e8p.\u03c0.comp j, \u27e8v', v'_in\u27e9, h\u03c0v'\u27e9,\n  have eq : ((\u211d \u2219 x)\u15ee : set E).restrict (p'.update \u03c6 w) = (p''.update (\u03c6.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 (\u03c6.comp j) (ker p''.\u03c0) = map \u03c6 (ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee),\n  { have : map \u2191j (ker p''.\u03c0) = ker p.\u03c0 \u2293 (\u211d \u2219 x)\u15ee,\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 \u27e8t, ht, rfl\u27e9,\n        rw [continuous_linear_map.coe_coe, subtypeL_apply],\n        exact \u27e8ht, t.2\u27e9 },\n      { rintros \u27e8hz, z_in\u27e9,\n        exact \u27e8\u27e8z, z_in\u27e9, hz, rfl\u27e9 }, },\n    erw [\u2190 this, map_comp],\n    refl },\n  rw [eq, p''.injective_update_iff, mem_compl_iff, eq'],\n  exact iff.rfl,\n  rw \u2190 show ((\u211d \u2219 x)\u15ee : set E).restrict \u03c6 = \u03c6.comp j, by { ext, refl },\n  exact h\u03c6.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_\u03c6 [fact (dim E = 3)] (\u03c9 : orientation \u211d E (fin 3))\n  (t : \u211d) (x : E) : E \u2192L[\u211d] E :=\n\u03c9.rot (t, x) - (2 * t) \u2022 (submodule.subtypeL (\u211d \u2219 x) \u2218L orthogonal_projection (\u211d \u2219 x))\n\nsection assume_finite_dimensional\n\nvariables [fact (dim E = 3)] [finite_dimensional \u211d E] (\u03c9 : orientation \u211d E (fin 3))\n\nlemma smooth_at_loc_formal_eversion_aux_\u03c6 {p : \u211d \u00d7 E} (hx : p.2 \u2260 0) :\n  cont_diff_at \u211d \u221e (uncurry (loc_formal_eversion_aux_\u03c6 \u03c9)) p :=\nbegin\n  refine (\u03c9.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 `\ud835\udd4a\u00b2`, viewed as a homotopy. -/\ndef loc_formal_eversion_aux : htpy_jet_sec E E :=\n{ f := \u03bb (t : \u211d) (x : E), (1 - 2 * smooth_step t) \u2022 x,\n  \u03c6 := \u03bb t x, smooth_step (\u2016x\u2016 ^ 2) \u2022 loc_formal_eversion_aux_\u03c6 \u03c9 (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  \u03c6_diff := begin\n    refine cont_diff_iff_cont_diff_at.mpr (\u03bb 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 : ((\u03bb x, \u2016x\u2016 ^ 2) \u207b\u00b9' Iio (1/4)) \u2208 \ud835\udcdd (0 : E),\n      { refine is_open.mem_nhds _ _,\n        exact (is_open_Iio.preimage (cont_diff_norm_sq \u211d : \ud835\udc9e \u221e _).continuous),\n        simp_rw [mem_preimage, norm_zero, zero_pow two_pos, mem_Iio],\n        norm_num },\n      have : ((\u03bb x, smooth_step (\u2016x\u2016 ^ 2)) \u207b\u00b9' {0}) \u2208 \ud835\udcdd (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 : ((\u03bb p : \u211d \u00d7 E, smooth_step (\u2016p.2\u2016 ^ 2)) \u207b\u00b9' {0}) \u2208 \ud835\udcdd x,\n      { rw [\u2190 hx] at this, exact continuous_at_snd.preimage_mem_nhds this },\n      refine eventually_of_mem this _,\n      rintro \u27e8t, x\u27e9 hx,\n      simp_rw [mem_preimage, mem_singleton_iff] at hx,\n      show smooth_step (\u2016x\u2016 ^ 2) \u2022 loc_formal_eversion_aux_\u03c6 \u03c9 (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 \u211d).comp cont_diff_snd).cont_diff_at,\n    exact (smooth_at_loc_formal_eversion_aux_\u03c6 \u03c9\n      (show (prod.map smooth_step id x).2 \u2260 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 `\ud835\udd4a\u00b2` into its ambient Euclidean space.\nThe corresponding map `E \u2192 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 * \u03c0`. 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 `\u03c9.rot` to also have the right behavior on `(\u211d \u2219 x)`\n  at `t = 1` (it is the identity, but it should be `-id`). Therefore, we subtract\n  `(2 * t) \u2022 (submodule.subtypeL (\u211d \u2219 x) \u2218L orthogonal_projection (\u211d \u2219 x))`,\n  which is `2t` times the identity on `(\u211d \u2219 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 (\u2016x\u2016 ^ 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 \u2209 B \u2192\n      inj_on (smooth_step (\u2016x\u2016 ^ 2) \u2022 loc_formal_eversion_aux_\u03c6 \u03c9 (smooth_step t) x) (\u211d \u2219 x)\u15ee,\n    intros hx,\n    have h2x : smooth_step (\u2016x\u2016 ^ 2) = 1,\n    { refine smooth_step.of_gt _,\n      rw [mem_ball, not_lt, dist_zero_right] at hx,\n      refine (show (3 : \u211d)/4 < 0.9 ^ 2, by norm_num).trans_le _,\n      rwa [sq_le_sq, show |(0.9 : \u211d)| = 0.9, by norm_num, abs_norm_eq_norm] },\n    rw [h2x, one_smul],\n    have h3x : x \u2260 0,\n    { rintro rfl, apply hx, exact mem_ball_self (by norm_num) },\n    refine (eq_on.inj_on_iff _).mpr (\u03c9.inj_on_rot_of_ne (smooth_step t) h3x),\n    intros v hv,\n    simp_rw [loc_formal_eversion_aux_\u03c6, 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 \u03c9 }\n\n@[simp]\nlemma loc_formal_eversion_f (t : \u211d) :\n  (loc_formal_eversion \u03c9 t).f = \u03bb x : E, ((1 : \u211d) - 2 * smooth_step t) \u2022 x :=\nrfl\n\nlemma loc_formal_eversion_\u03c6 (t : \u211d) (x : E) (v : E) :\n  (loc_formal_eversion \u03c9 t).\u03c6 x v = smooth_step (\u2016x\u2016 ^ 2) \u2022\n    (\u03c9.rot (smooth_step t, x) v -\n    (2 * smooth_step t) \u2022 orthogonal_projection (\u211d \u2219 x) v) :=\nrfl\n\nlemma loc_formal_eversion_zero (x : E) : (loc_formal_eversion \u03c9 0).f x = x :=\nby simp\n\nlemma loc_formal_eversion_one (x : E) : (loc_formal_eversion \u03c9 1).f x = -x :=\nby simp [show (1 : \u211d) - 2 = -1, by norm_num]\n\nlemma loc_formal_eversion_hol_at_zero {t : \u211d} (ht : t < 1/4) {x : E}\n  (hx : smooth_step (\u2016x\u2016 ^ 2) = 1) : (loc_formal_eversion \u03c9 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_\u03c6, smooth_step.of_lt ht, hx, \u03c9.rot_zero, mul_zero, zero_smul, sub_zero,\n    show (has_smul.smul (1 : \u211d) : E \u2192 E) = id, from funext (one_smul \u211d), fderiv_id, function.id_def,\n    eq_self_iff_true, implies_true_iff]\n\nlemma loc_formal_eversion_hol_at_one {t : \u211d} (ht : 3/4 < t) {x : E}\n  (hx : smooth_step (\u2016x\u2016 ^ 2) = 1) : (loc_formal_eversion \u03c9 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_\u03c6, smooth_step.of_gt ht, hx],\n  intro v,\n  simp_rw [mul_one, show (1 : \u211d) - 2 = -1, by norm_num,\n    show (has_smul.smul (-1 : \u211d) : E \u2192 E) = \u03bb x, - x, from funext (\u03bb v, by rw [neg_smul, one_smul]),\n    fderiv_neg, fderiv_id', continuous_linear_map.neg_apply, continuous_linear_map.id_apply],\n  obtain \u27e8v', hv', v, hv, rfl\u27e9 := submodule.exists_sum_mem_mem_orthogonal (\u211d \u2219 x) v,\n  simp_rw [continuous_linear_map.map_add, \u03c9.rot_one _ hv, \u03c9.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  \u2200\u1da0 (p : \u211d \u00d7 E) near {0, 1} \u00d7\u02e2 \ud835\udd4a\u00b2, (loc_formal_eversion \u03c9 p.1).is_holonomic_at p.2 :=\nbegin\n  have : (Iio (1/4 : \u211d) \u222a Ioi (3/4)) \u00d7\u02e2 ((\u03bb x, \u2016x\u2016 ^ 2) \u207b\u00b9' Ioi (3/4)) \u2208\n    \ud835\udcdd\u02e2 (({0, 1} : set \u211d) \u00d7\u02e2 \ud835\udd4a\u00b2),\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 \u211d : \ud835\udc9e \u221e _).continuous),\n    rintro \u27e8s, x\u27e9 \u27e8hs, hx\u27e9,\n    refine \u27e8_, _\u27e9,\n    simp_rw [mem_insert_iff, mem_singleton_iff] at hs,\n    rcases hs with rfl|rfl,\n    exact or.inl (show (0 : \u211d) < 1 / 4, by norm_num),\n    exact or.inr (show (3 / 4 : \u211d) < 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 : \u211d) \u222a Ioi (3/4)) \u00d7\u02e2 ((\u03bb x, smooth_step (\u2016x\u2016 ^ 2)) \u207b\u00b9' {1}) \u2208\n    \ud835\udcdd\u02e2 (({0, 1} : set \u211d) \u00d7\u02e2 \ud835\udd4a\u00b2),\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 \u27e8t, x\u27e9 \u27e8ht|ht, hx\u27e9,\n  { exact loc_formal_eversion_hol_at_zero \u03c9 ht hx },\n  { exact loc_formal_eversion_hol_at_one \u03c9 ht hx }\nend\n\nend assume_finite_dimensional\n\nopen_locale unit_interval\n\ntheorem sphere_eversion_of_loc [fact (dim E = 3)] :\n  \u2203 f : \u211d \u2192 E \u2192 E,\n  (\ud835\udc9e \u221e \u21bff) \u2227\n  (\u2200 x \u2208 \ud835\udd4a\u00b2, f 0 x = x) \u2227\n  (\u2200 x \u2208 \ud835\udd4a\u00b2, f 1 x = -x) \u2227\n  \u2200 t \u2208 I, sphere_immersion (f t) :=\nbegin\n  classical,\n  borelize E,\n  have rankE := fact.out (dim E = 3),\n  haveI : finite_dimensional \u211d E := finite_dimensional_of_finrank_eq_succ rankE,\n  let \u03c9 : orientation \u211d 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 \u211d) :=\n  (by simp : ({0, 1} : set \u211d).finite).is_closed,\n  obtain \u27e8f, h\u2081, h\u2082, h\u2083\u27e9 :=\n    (loc_formal_eversion \u03c9).exists_sol loc_immersion_rel_open (loc_immersion_rel_ample 2 le_rfl)\n    ({0, 1} \u00d7\u02e2 \ud835\udd4a\u00b2) (is_closed_pair.prod is_closed_sphere) \ud835\udd4a\u00b2 (is_compact_sphere 0 1)\n    (loc_formal_eversion_hol \u03c9),\n  refine \u27e8f, h\u2081, _, _, _\u27e9,\n  { intros x hx, rw [h\u2082 (0, x) (mk_mem_prod (by simp) hx), loc_formal_eversion_zero] },\n  { intros x hx, rw [h\u2082 (1, x) (mk_mem_prod (by simp) hx), loc_formal_eversion_one] },\n  { exact \u03bb t ht, sphere_immersion_of_sol _ (\u03bb x hx, h\u2083 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 \u211d E] [fact (finrank \u211d E = 3)] :\n  \u2203 f : \u211d \u2192 E \u2192 E,\n  (cont_diff \u211d \u22a4 (uncurry f)) \u2227\n  (\u2200 x \u2208 sphere (0 : E) 1, f 0 x = x) \u2227\n  (\u2200 x \u2208 sphere (0 : E) 1, f 1 x = -x) \u2227\n  \u2200 t \u2208 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) : \u03b2 \u2192 Type (max u v)\n| mk : (a : \u03b1) \u2192 Imf f (f a)\n\ndef h {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} : {b : \u03b2} \u2192 Imf f b \u2192 \u03b1\n| _, Imf.mk a => a\n\n#print h\n\ntheorem ex : \u2200 {\u03b1 \u03b2 : Sort u} (h : \u03b1 = \u03b2) (a : \u03b1), cast h a \u2245 a\n  | \u03b1, _, 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 `\u2192*`, for\nmorphisms between monoids or groups. For example use `\u03c6 : G \u2192* H` to represent a group\nhomomorphism between multiplicative groups, and `\u03c8 : A \u2192+ 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 {\u03b1 : Type u} {\u03b2 : Type v}\n\n/-- Predicate for maps which preserve an addition. -/\nstructure is_add_hom {\u03b1 \u03b2 : Type*} [has_add \u03b1] [has_add \u03b2] (f : \u03b1 \u2192 \u03b2) : Prop :=\n(map_add [] : \u2200 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 {\u03b1 \u03b2 : Type*} [has_mul \u03b1] [has_mul \u03b2] (f : \u03b1 \u2192 \u03b2) : Prop :=\n(map_mul [] : \u2200 x y, f (x * y) = f x * f y)\n\nnamespace is_mul_hom\nvariables [has_mul \u03b1] [has_mul \u03b2] {\u03b3 : Type*} [has_mul \u03b3]\n\n/-- The identity map preserves multiplication. -/\n@[to_additive \"The identity map preserves addition\"]\nlemma id : is_mul_hom (id : \u03b1 \u2192 \u03b1) := {map_mul := \u03bb _ _, 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 : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hf : is_mul_hom f) (hg : is_mul_hom g) : is_mul_hom (g \u2218 f) :=\n{ map_mul := \u03bb 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 {\u03b1 \u03b2} [semigroup \u03b1] [comm_semigroup \u03b2]\n  {f g : \u03b1 \u2192 \u03b2} (hf : is_mul_hom f) (hg : is_mul_hom g) :\n  is_mul_hom (\u03bb a, f a * g a) :=\n{ map_mul := \u03bb 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 {\u03b1 \u03b2} [has_mul \u03b1] [comm_group \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_mul_hom f) :\n  is_mul_hom (\u03bb a, (f a)\u207b\u00b9) :=\n{ map_mul := \u03bb a b, (hf.map_mul a b).symm \u25b8 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 \u03b1] [add_zero_class \u03b2] (f : \u03b1 \u2192 \u03b2)\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 \u03b1] [mul_one_class \u03b2] (f : \u03b1 \u2192 \u03b2)\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 \u2192 N` as a homomorphism `M \u2192* N`. -/\n@[to_additive \"Interpret a map `f : M \u2192 N` as a homomorphism `M \u2192+ N`.\"]\ndef of {f : M \u2192 N} (h : is_monoid_hom f) : M \u2192* 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 \u2192 N} (hf : is_monoid_hom f) : \u21d1 (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 \u2243* N) : is_mul_hom h := \u27e8h.map_mul\u27e9\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 \u2243* 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 \u03b1] [mul_one_class \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 \u03b2} [mul_one_class \u03b1] [comm_group \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_monoid_hom f) :\n  is_monoid_hom (\u03bb a, (f a)\u207b\u00b9) :=\n{ map_one := hf.map_one.symm \u25b8 inv_one,\n  map_mul := \u03bb a b, (hf.map_mul a b).symm \u25b8 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 \u03b1] [group \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_mul_hom f) :\n  is_monoid_hom f :=\n{ map_one := mul_right_eq_self.1 $ by rw [\u2190 hf.map_mul, one_mul],\n  map_mul := hf.map_mul }\n\nnamespace is_monoid_hom\nvariables [mul_one_class \u03b1] [mul_one_class \u03b2] {f : \u03b1 \u2192 \u03b2}\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 \u03b1) := { map_one := rfl, map_mul := \u03bb _ _, 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) {\u03b3} [mul_one_class \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : is_monoid_hom g) :\n  is_monoid_hom (g \u2218 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 {\u03b3 : Type*} [non_unital_non_assoc_semiring \u03b3] (x : \u03b3) :\n  is_add_monoid_hom (\u03bb y : \u03b3, x * y) :=\n{ map_zero := mul_zero x, map_add := \u03bb 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 {\u03b3 : Type*} [non_unital_non_assoc_semiring \u03b3] (x : \u03b3) :\n  is_add_monoid_hom (\u03bb y : \u03b3, y * x) :=\n{ map_zero := zero_mul x, map_add := \u03bb 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 \u03b1] [add_group \u03b2] (f : \u03b1 \u2192 \u03b2) 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 \u03b1] [group \u03b2] (f : \u03b1 \u2192 \u03b2) 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 \u2192* H) :\n  is_group_hom (f : G \u2192 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 \u2243* 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 \u03b1] [group \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : \u2200 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 \u03b1] [group \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_group_hom f)\nopen is_mul_hom (map_mul)\n\nlemma map_mul : \u2200 (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 : \u03b1) : f a\u207b\u00b9 = (f a)\u207b\u00b9 :=\neq_inv_of_mul_eq_one_left $ by rw [\u2190 hf.map_mul, inv_mul_self, hf.map_one]\n\n@[to_additive] lemma map_div (hf : is_group_hom f) (a b : \u03b1) : 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 \u03b1) := { map_mul := \u03bb _ _, 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) {\u03b3} [group \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : is_group_hom g) :\n  is_group_hom (g \u2218 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 : \u03b1 \u2192 \u03b2} (hf : is_group_hom f) :\n  function.injective f \u2194 (\u2200 a, f a = 1 \u2192 a = 1) :=\n\u27e8\u03bb h _, by rw \u2190 hf.map_one; exact @h _ _,\n  \u03bb h x y hxy, eq_of_div_eq_one $ h _ $ by rwa [hf.map_div, div_eq_one]\u27e9\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 {\u03b1 \u03b2} [group \u03b1] [comm_group \u03b2]\n  {f g : \u03b1 \u2192 \u03b2} (hf : is_group_hom f) (hg : is_group_hom g) :\n  is_group_hom (\u03bba, 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 {\u03b1 \u03b2} [group \u03b1] [comm_group \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_group_hom f) :\n  is_group_hom (\u03bba, (f a)\u207b\u00b9) :=\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 `\u2192+*`.\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 \u2192+* 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 \u2192+* 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 \u2192+* 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 \u03b1] : is_group_hom (has_inv.inv : \u03b1 \u2192 \u03b1) :=\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 {\u03b1 \u03b2} [add_group \u03b1] [add_comm_group \u03b2]\n  {f g : \u03b1 \u2192 \u03b2} (hf : is_add_group_hom f) (hg : is_add_group_hom g) :\n  is_add_group_hom (\u03bba, 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 \u2192 N} (hf : is_monoid_hom f) : M\u02e3 \u2192* N\u02e3 :=\n  map (monoid_hom.of hf)\n\n@[simp] lemma coe_map' {f : M \u2192 N} (hf : is_monoid_hom f) (x : M\u02e3) :\n  \u2191((map' hf : M\u02e3 \u2192 N\u02e3) x) = f x :=\nrfl\n\nlemma coe_is_monoid_hom : is_monoid_hom (coe : M\u02e3 \u2192 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 \u2192 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 \u03b1] [has_mul \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_mul_hom f) :\n  @is_add_hom (additive \u03b1) (additive \u03b2) _ _ f :=\n{ map_add := is_mul_hom.map_mul hf }\n\nlemma multiplicative.is_mul_hom [has_add \u03b1] [has_add \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_add_hom f) :\n  @is_mul_hom (multiplicative \u03b1) (multiplicative \u03b2) _ _ f :=\n{ map_mul := is_add_hom.map_add hf }\n\n-- defeq abuse\nlemma additive.is_add_monoid_hom [mul_one_class \u03b1] [mul_one_class \u03b2] {f : \u03b1 \u2192 \u03b2}\n  (hf : is_monoid_hom f) : @is_add_monoid_hom (additive \u03b1) (additive \u03b2) _ _ 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 \u03b1] [add_zero_class \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_add_monoid_hom f) :\n  @is_monoid_hom (multiplicative \u03b1) (multiplicative \u03b2) _ _ 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 \u03b1] [group \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_group_hom f) :\n  @is_add_group_hom (additive \u03b1) (additive \u03b2) _ _ f :=\n{ map_add := hf.to_is_mul_hom.map_mul }\n\nlemma multiplicative.is_group_hom [add_group \u03b1] [add_group \u03b2] {f : \u03b1 \u2192 \u03b2}\n  (hf : is_add_group_hom f) : @is_group_hom (multiplicative \u03b1) (multiplicative \u03b2) _ _ 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 {\u03b1 \u03b2 : Sort*}\n\nlemma equiv.exists_congr_left' {p : \u03b1 \u2192 Prop} (f : \u03b1 \u2243 \u03b2) :\n  (\u2203x, p x) \u2194 (\u2203y, p (f.symm y)) :=\n\u27e8\u03bb \u27e8x, h\u27e9, \u27e8f x, by rwa f.symm_apply_apply\u27e9, \u03bb \u27e8y, h\u27e9, \u27e8f.symm y, h\u27e9\u27e9\n\nlemma equiv.exists_congr_left {p : \u03b2 \u2192 Prop} (f : \u03b1 \u2243 \u03b2) :\n  (\u2203x, p (f x)) \u2194 (\u2203y, 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": "def OrderDual (\u03b1 : Type u) : Type u := \u03b1\n\nvariable (\u03b1 : Type u) [LE \u03b1] {a b : \u03b1}\ninstance : LE (OrderDual \u03b1) := \u27e8fun x y : \u03b1 => y \u2264 x\u27e9\n\ntheorem foo' (c : \u03b1) : a \u2264 b := sorry\n\nexample : a \u2264 b :=\n  foo' (OrderDual \u03b1) a\n\ntheorem foo : a \u2264 b := sorry\n\nexample : a \u2264 b :=\n  foo (OrderDual \u03b1)\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/1892.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8006920020959543, "lm_q2_score": 0.6187804267137442, "lm_q1q2_score": 0.49545253872321676}}
{"text": "import data.real.basic\n\nopen set\n\nlemma mem_Icc_iff {x a b : \u211d} : x \u2208 Icc a b \u2194 a \u2264 x \u2227 x \u2264 b := iff.rfl\n", "meta": {"author": "ImperialCollegeLondon", "repo": "real-number-game", "sha": "f9dcb7d9255a79b57e62038228a23346c2dc301b", "save_path": "github-repos/lean/ImperialCollegeLondon-real-number-game", "path": "github-repos/lean/ImperialCollegeLondon-real-number-game/real-number-game-f9dcb7d9255a79b57e62038228a23346c2dc301b/src/kb_real_defs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.815232489352, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.49538675863039533}}
{"text": "/-\nCopyright (c) 2017 Johannes H\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b9 : Type*}\n\nlemma has_sum_of_absolute_convergence_real {f : \u2115 \u2192 \u211d} :\n  (\u2203r, tendsto (\u03bbn, (range n).sum (\u03bbi, abs (f i))) at_top (nhds r)) \u2192 has_sum f\n| \u27e8r, hr\u27e9 :=\n  begin\n    refine has_sum_of_has_sum_norm \u27e8r, (is_sum_iff_tendsto_nat_of_nonneg _ _).2 _\u27e9,\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 : \u211d} (h : r > 1) : tendsto (\u03bbn:\u2115, r ^ n) at_top at_top :=\ntendsto_infi.2 $ assume p, tendsto_principal.2 $\n  let \u27e8n, hn\u27e9 := exists_nat_gt (p / (r - 1)) in\n  have hn_nn : (0:\u211d) \u2264 n, from nat.cast_nonneg n,\n  have r - 1 > 0, from sub_lt_iff_lt_add.mp $ by simp; assumption,\n  have p \u2264 r ^ n,\n    from calc p = (p / (r - 1)) * (r - 1) : (div_mul_cancel _ $ ne_of_gt this).symm\n      ... \u2264 n * (r - 1) : mul_le_mul (le_of_lt hn) (le_refl _) (le_of_lt this) hn_nn\n      ... \u2264 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      ... \u2264 (1 + (r - 1)) ^ n : pow_ge_one_add_mul (le_of_lt this) _\n      ... \u2264 r ^ n : by simp; exact le_refl _,\n  show {n | p \u2264 r ^ n} \u2208 at_top,\n    from mem_at_top_sets.mpr \u27e8n, assume m hnm, le_trans this (pow_le_pow (le_of_lt h) hnm)\u27e9\n\nlemma tendsto_inverse_at_top_nhds_0 : tendsto (\u03bbr:\u211d, r\u207b\u00b9) at_top (nhds 0) :=\ntendsto_orderable_unbounded (no_top 0) (no_bot 0) $ assume l u hl hu,\n  mem_at_top_sets.mpr \u27e8u\u207b\u00b9 + 1, assume b hb,\n    have u\u207b\u00b9 < b, from lt_of_lt_of_le (lt_add_of_pos_right _ zero_lt_one) hb,\n    \u27e8lt_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\u27e9\u27e9\n\nlemma tendsto_pow_at_top_nhds_0_of_lt_1 {r : \u211d} (h\u2081 : 0 \u2264 r) (h\u2082 : r < 1) :\n  tendsto (\u03bbn:\u2115, 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 \u2260 0,\n    have tendsto (\u03bbn, (r\u207b\u00b9 ^ n)\u207b\u00b9) at_top (nhds 0),\n      from (tendsto_pow_at_top_at_top_of_gt_1 $ one_lt_inv (lt_of_le_of_ne h\u2081 this.symm) h\u2082).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 : \u2115} (h : 1 < k) :\n  tendsto (\u03bbn:\u2115, k ^ n) at_top at_top :=\ntendsto_coe_nat_real_at_top_iff.1 $\n  have hr : 1 < (k : \u211d), by rw [\u2190 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 (\u03bb n : \u2115, (n : \u211d)\u207b\u00b9) 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 (\u03bb n : \u2115, 1/(n : \u211d)) 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 (\u03bb n : \u2115, 1 / ((n : \u211d) + 1)) at_top (nhds 0) :=\nsuffices tendsto (\u03bb n : \u2115, 1 / (\u2191(n + 1) : \u211d)) 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 : \u211d} (h\u2081 : 0 \u2264 r) (h\u2082 : r < 1) :\n  is_sum (\u03bbn:\u2115, r ^ n) (1 / (1 - r)) :=\nhave r \u2260 1, from ne_of_lt h\u2082,\nhave r + -1 \u2260 0,\n  by rw [\u2190sub_eq_add_neg, ne, sub_eq_iff_eq_add]; simp; assumption,\nhave tendsto (\u03bbn, (r ^ n - 1) * (r - 1)\u207b\u00b9) at_top (nhds ((0 - 1) * (r - 1)\u207b\u00b9)),\n  from tendsto_mul\n    (tendsto_sub (tendsto_pow_at_top_nhds_0_of_lt_1 h\u2081 h\u2082) tendsto_const_nhds) tendsto_const_nhds,\n(is_sum_iff_tendsto_nat_of_nonneg (pow_nonneg h\u2081) _).mpr $\n  by simp [neg_inv, geom_sum, div_eq_mul_inv, *] at *\n\nlemma is_sum_geometric_two (a : \u211d) : is_sum (\u03bbn:\u2115, (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 \u2190 pow_inv; [refl, exact two_ne_zero] },\n  { norm_num, rw div_mul_cancel _ two_ne_zero }\nend\n\ndef pos_sum_of_encodable {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5)\n  (\u03b9) [encodable \u03b9] : {\u03b5' : \u03b9 \u2192 \u211d // (\u2200 i, 0 < \u03b5' i) \u2227 \u2203 c, is_sum \u03b5' c \u2227 c \u2264 \u03b5} :=\nbegin\n  let f := \u03bb n, (\u03b5 / 2) / 2 ^ n,\n  have hf : is_sum f \u03b5 := is_sum_geometric_two _,\n  have f0 : \u2200 n, 0 < f n := \u03bb n, div_pos (half_pos h\u03b5) (pow_pos two_pos _),\n  refine \u27e8f \u2218 encodable.encode, \u03bb i, f0 _, _\u27e9,\n  rcases has_sum_comp_of_has_sum_of_injective f (has_sum_spec hf) (@encodable.encode_injective \u03b9 _)\n    with \u27e8c, hg\u27e9,\n  refine \u27e8c, hg, is_sum_le_inj _ (@encodable.encode_injective \u03b9 _) _ _ hg hf\u27e9,\n  { assume i _, exact le_of_lt (f0 _) },\n  { assume n, exact le_refl _ }\nend\n\nlemma cauchy_seq_of_le_geometric [metric_space \u03b1] (r C : \u211d) (hr : r < 1) {f : \u2115 \u2192 \u03b1}\n  (hu : \u2200n, dist (f n) (f (n+1)) \u2264 C * r^n) : cauchy_seq f :=\nbegin\n  refine cauchy_seq_of_has_sum_dist (has_sum_of_norm_bounded (\u03bbn, 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 \u2265 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 \u2200n, abs (dist (f n) (f (n+1))) \u2264 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 {\u03b5 : nnreal} (h\u03b5 : 0 < \u03b5) (\u03b9) [encodable \u03b9] :\n  \u2203 \u03b5' : \u03b9 \u2192 nnreal, (\u2200 i, 0 < \u03b5' i) \u2227 \u2203c, is_sum \u03b5' c \u2227 c < \u03b5 :=\nlet \u27e8a, a0, a\u03b5\u27e9 := dense h\u03b5 in\nlet \u27e8\u03b5', h\u03b5', c, hc, hc\u03b5\u27e9 := pos_sum_of_encodable a0 \u03b9 in\n\u27e8 \u03bbi, \u27e8\u03b5' i, le_of_lt $ h\u03b5' i\u27e9, assume i, nnreal.coe_lt.2 $ h\u03b5' i,\n  \u27e8c, is_sum_le (assume i, le_of_lt $ h\u03b5' i) is_sum_zero hc \u27e9, nnreal.is_sum_coe.1 hc,\n   lt_of_le_of_lt (nnreal.coe_le.1 hc\u03b5) a\u03b5 \u27e9\n\nend nnreal\n\nnamespace ennreal\n\ntheorem exists_pos_sum_of_encodable {\u03b5 : ennreal} (h\u03b5 : 0 < \u03b5) (\u03b9) [encodable \u03b9] :\n  \u2203 \u03b5' : \u03b9 \u2192 nnreal, (\u2200 i, 0 < \u03b5' i) \u2227 (\u2211 i, (\u03b5' i : ennreal)) < \u03b5 :=\nbegin\n  rcases dense h\u03b5 with \u27e8r, h0r, hr\u03b5\u27e9,\n  rcases lt_iff_exists_coe.1 hr\u03b5 with \u27e8x, rfl, hx\u27e9,\n  rcases nnreal.exists_pos_sum_of_encodable (coe_lt_coe.1 h0r) \u03b9 with \u27e8\u03b5', hp, c, hc, hcr\u27e9,\n  exact \u27e8\u03b5', hp, (ennreal.tsum_coe_eq hc).symm \u25b8 lt_trans (coe_lt_coe.2 hcr) hr\u03b5\u27e9\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 \u0393} :\n    lookup x (ctx.cons x A \u0393) A\n| there {x y A B \u0393} :\n    x \u2260 y ->\n    lookup x \u0393 A ->\n    lookup x (ctx.cons y B \u0393) A\n\ninductive of : ctx -> tm -> ty -> Prop\n| var {x \u0393 A} :\n    lookup x \u0393 A ->\n    of \u0393 (tm.var x) A\n| unit {\u0393} :\n    of \u0393 tm.unit ty.unit\n| true {\u0393} :\n    of \u0393 tm.true ty.bool\n| false {\u0393} :\n    of \u0393 tm.false ty.bool\n| app {\u0393 e1 e2 A B} :\n    of \u0393 e1 (ty.arrow A B) ->\n    of \u0393 e2 A ->\n    of \u0393 (tm.app e1 e2) B\n| lam {\u0393 x e A B} :\n    of (ctx.cons x A \u0393) e B ->\n    of \u0393 (tm.lam x e) (ty.arrow A B)\n| if_then_else {\u0393 e e1 e2 A} :\n    of \u0393 e ty.bool ->\n    of \u0393 e1 A ->\n    of \u0393 e2 A ->\n    of \u0393 (tm.if_then_else e e1 e2) A\n\ntheorem substitution {\u0393 x A e e' A'} :\n    of \u0393 e A\n    -> of (ctx.cons x A \u0393) e' A'\n    -> of \u0393 (subst x e e') A'\n:=\nbegin\n  intros H,\n  generalize ctx_cons : (ctx.cons x A \u0393) = \u0393',\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 {\u0393 A}, of \u0393 e A ->\n    of \u0393 e' A\n:=\nbegin\n    intros Hstep,\n    induction Hstep,\n    repeat {intros \u0393 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) \u2228 (exists e', step e e')\n:=\nbegin\n    generalize empty : ctx.nil = \u0393,\n    intros H,\n    induction H,\n    case of.var {\n        rewrite \u2190empty 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 \u2190empty 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 \u2190empty 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 `\u03b1`, `(<)` is well-founded on `N`, and `0` is a bottom element in `N`,\nthen the lexicographic `(<)` is well-founded on `\u03b1 \u2192\u2080 N`.\n\n`finsupp.lex.well_founded_lt_of_finite` says that if `\u03b1` is finite and equipped with a linear\norder and `(<)` is well-founded on `N`, then the lexicographic `(<)` is well-founded on `\u03b1 \u2192\u2080 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 `\u03b1`.\n\nAll results are transferred from `dfinsupp` via `finsupp.to_dfinsupp`.\n-/\n\n\nvariable {\u03b1 N : Type _}\n\nnamespace Finsupp\n\nvariable [hz : Zero N] {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : N \u2192 N \u2192 Prop} (hbot : \u2200 \u2983n\u2984, \u00acs 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 {\u03b1 : Type.{u1}} {N : Type.{u2}} [hz : Zero.{u2} N] {r : \u03b1 -> \u03b1 -> 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} \u03b1 N hz), (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a (Finsupp.support.{u1, u2} \u03b1 N hz x)) -> (Acc.{succ u1} \u03b1 (Inf.inf.{u1} (\u03b1 -> \u03b1 -> Prop) (Pi.hasInf.{u1, u1} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1 -> Prop) (fun (i : \u03b1) => Pi.hasInf.{u1, 0} \u03b1 (fun (\u1fb0 : \u03b1) => Prop) (fun (i : \u03b1) => SemilatticeInf.toHasInf.{0} Prop (Lattice.toSemilatticeInf.{0} Prop (ConditionallyCompleteLattice.toLattice.{0} Prop (CompleteLattice.toConditionallyCompleteLattice.{0} Prop Prop.completeLattice)))))) (HasCompl.compl.{u1} (\u03b1 -> \u03b1 -> Prop) (Pi.hasCompl.{u1, u1} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1 -> Prop) (fun (i : \u03b1) => Pi.hasCompl.{u1, 0} \u03b1 (fun (\u1fb0 : \u03b1) => Prop) (fun (i : \u03b1) => Prop.hasCompl))) r) (Ne.{succ u1} \u03b1)) a)) -> (Acc.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b1 N hz) (Finsupp.Lex.{u1, u2} \u03b1 N hz r s) x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {N : Type.{u1}} [hz : Zero.{u1} N] {r : \u03b1 -> \u03b1 -> 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} \u03b1 N hz), (forall (a : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) a (Finsupp.support.{u2, u1} \u03b1 N hz x)) -> (Acc.{succ u2} \u03b1 (Inf.inf.{u2} (\u03b1 -> \u03b1 -> Prop) (Pi.instInfForAll.{u2, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1 -> Prop) (fun (i : \u03b1) => Pi.instInfForAll.{u2, 0} \u03b1 (fun (\u1fb0 : \u03b1) => Prop) (fun (i : \u03b1) => 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} (\u03b1 -> \u03b1 -> Prop) (Pi.hasCompl.{u2, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1 -> Prop) (fun (i : \u03b1) => Pi.hasCompl.{u2, 0} \u03b1 (fun (\u1fb0 : \u03b1) => Prop) (fun (i : \u03b1) => Prop.hasCompl))) r) (fun (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.102 : \u03b1) (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.104 : \u03b1) => Ne.{succ u2} \u03b1 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.102 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.104)) a)) -> (Acc.{max (succ u1) (succ u2)} (Finsupp.{u2, u1} \u03b1 N hz) (Finsupp.Lex.{u2, u1} \u03b1 N hz r s) x))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.acc Finsupp.Lex.acc\u2093'. -/\n/-- Transferred from `dfinsupp.lex.acc`. See the top of that file for an explanation for the\n  appearance of the relation `r\u1d9c \u2293 (\u2260)`. -/\ntheorem Lex.acc (x : \u03b1 \u2192\u2080 N) (h : \u2200 a \u2208 x.support, Acc (r\u1d9c \u2293 (\u00b7 \u2260 \u00b7)) 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 {\u03b1 : Type.{u1}} {N : Type.{u2}} [hz : Zero.{u2} N] {r : \u03b1 -> \u03b1 -> 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} \u03b1 (Inf.inf.{u1} (\u03b1 -> \u03b1 -> Prop) (Pi.hasInf.{u1, u1} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1 -> Prop) (fun (i : \u03b1) => Pi.hasInf.{u1, 0} \u03b1 (fun (\u1fb0 : \u03b1) => Prop) (fun (i : \u03b1) => SemilatticeInf.toHasInf.{0} Prop (Lattice.toSemilatticeInf.{0} Prop (ConditionallyCompleteLattice.toLattice.{0} Prop (CompleteLattice.toConditionallyCompleteLattice.{0} Prop Prop.completeLattice)))))) (HasCompl.compl.{u1} (\u03b1 -> \u03b1 -> Prop) (Pi.hasCompl.{u1, u1} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1 -> Prop) (fun (i : \u03b1) => Pi.hasCompl.{u1, 0} \u03b1 (fun (\u1fb0 : \u03b1) => Prop) (fun (i : \u03b1) => Prop.hasCompl))) r) (Ne.{succ u1} \u03b1))) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b1 N hz) (Finsupp.Lex.{u1, u2} \u03b1 N hz r s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {N : Type.{u1}} [hz : Zero.{u1} N] {r : \u03b1 -> \u03b1 -> 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} \u03b1 (Inf.inf.{u2} (\u03b1 -> \u03b1 -> Prop) (Pi.instInfForAll.{u2, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1 -> Prop) (fun (i : \u03b1) => Pi.instInfForAll.{u2, 0} \u03b1 (fun (\u1fb0 : \u03b1) => Prop) (fun (i : \u03b1) => 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} (\u03b1 -> \u03b1 -> Prop) (Pi.hasCompl.{u2, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b1 -> Prop) (fun (i : \u03b1) => Pi.hasCompl.{u2, 0} \u03b1 (fun (\u1fb0 : \u03b1) => Prop) (fun (i : \u03b1) => Prop.hasCompl))) r) (fun (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.228 : \u03b1) (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.230 : \u03b1) => Ne.{succ u2} \u03b1 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.228 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.230))) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u2, u1} \u03b1 N hz) (Finsupp.Lex.{u2, u1} \u03b1 N hz r s))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded Finsupp.Lex.wellFounded\u2093'. -/\ntheorem Lex.wellFounded (hr : WellFounded <| r\u1d9c \u2293 (\u00b7 \u2260 \u00b7)) : WellFounded (Finsupp.Lex r s) :=\n  \u27e8fun x => Lex.acc hbot hs x fun a _ => hr.apply a\u27e9\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 {\u03b1 : Type.{u1}} {N : Type.{u2}} [hz : Zero.{u2} N] {r : \u03b1 -> \u03b1 -> 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} \u03b1 r], (WellFounded.{succ u1} \u03b1 (Function.swap.{succ u1, succ u1, 1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => Prop) r)) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b1 N hz) (Finsupp.Lex.{u1, u2} \u03b1 N hz r s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {N : Type.{u1}} [hz : Zero.{u1} N] {r : \u03b1 -> \u03b1 -> 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} \u03b1 r], (WellFounded.{succ u2} \u03b1 (Function.swap.{succ u2, succ u2, 1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => Prop) r)) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u2, u1} \u03b1 N hz) (Finsupp.Lex.{u2, u1} \u03b1 N hz r s)))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded' Finsupp.Lex.wellFounded'\u2093'. -/\ntheorem Lex.wellFounded' [IsTrichotomous \u03b1 r] (hr : WellFounded r.symm) :\n    WellFounded (Finsupp.Lex r s) :=\n  (lex_eq_invImage_dfinsupp_lex r s).symm \u25b8\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 {\u03b1 : Type.{u1}} {N : Type.{u2}} [_inst_1 : LT.{u1} \u03b1] [_inst_2 : IsTrichotomous.{u1} \u03b1 (LT.lt.{u1} \u03b1 _inst_1)] [h\u03b1 : WellFoundedGT.{u1} \u03b1 _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} \u03b1 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} \u03b1 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 {\u03b1 : Type.{u1}} {N : Type.{u2}} [_inst_1 : LT.{u1} \u03b1] [_inst_2 : IsTrichotomous.{u1} \u03b1 (fun (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.381 : \u03b1) (x._@.Mathlib.Data.Finsupp.WellFounded._hyg.383 : \u03b1) => LT.lt.{u1} \u03b1 _inst_1 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.381 x._@.Mathlib.Data.Finsupp.WellFounded._hyg.383)] [h\u03b1 : WellFoundedGT.{u1} \u03b1 _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} \u03b1 N (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_3)))))) (Finsupp.instLTLexFinsupp.{u1, u2} \u03b1 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\u2093'. -/\ninstance Lex.wellFoundedLT [LT \u03b1] [IsTrichotomous \u03b1 (\u00b7 < \u00b7)] [h\u03b1 : WellFoundedGT \u03b1]\n    [CanonicallyOrderedAddMonoid N] [hN : WellFoundedLT N] : WellFoundedLT (Lex (\u03b1 \u2192\u2080 N)) :=\n  \u27e8Lex.wellFounded' (fun n => (zero_le n).not_lt) hN.wf h\u03b1.wf\u27e9\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 {\u03b1 : Type.{u1}} {N : Type.{u2}} (r : \u03b1 -> \u03b1 -> Prop) {s : N -> N -> Prop} [_inst_1 : IsStrictTotalOrder.{u1} \u03b1 r] [_inst_2 : Finite.{succ u1} \u03b1] [_inst_3 : Zero.{u2} N], (WellFounded.{succ u2} N s) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b1 N _inst_3) (Finsupp.Lex.{u1, u2} \u03b1 N _inst_3 r s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {N : Type.{u1}} (r : \u03b1 -> \u03b1 -> Prop) {s : N -> N -> Prop} [_inst_1 : IsStrictTotalOrder.{u2} \u03b1 r] [_inst_2 : Finite.{succ u2} \u03b1] [_inst_3 : Zero.{u1} N], (WellFounded.{succ u1} N s) -> (WellFounded.{max (succ u1) (succ u2)} (Finsupp.{u2, u1} \u03b1 N _inst_3) (Finsupp.Lex.{u2, u1} \u03b1 N _inst_3 r s))\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded_of_finite Finsupp.Lex.wellFounded_of_finite\u2093'. -/\ntheorem Lex.wellFounded_of_finite [IsStrictTotalOrder \u03b1 r] [Finite \u03b1] [Zero N]\n    (hs : WellFounded s) : WellFounded (Finsupp.Lex r s) :=\n  InvImage.wf (@equivFunOnFinite \u03b1 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 {\u03b1 : Type.{u1}} {N : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : Finite.{succ u1} \u03b1] [_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} \u03b1 N _inst_3)) (Finsupp.Lex.hasLt.{u1, u2} \u03b1 N _inst_3 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) _inst_4)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {N : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : Finite.{succ u2} \u03b1] [_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} \u03b1 N _inst_3)) (Finsupp.instLTLexFinsupp.{u2, u1} \u03b1 N _inst_3 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) _inst_4)\nCase conversion may be inaccurate. Consider using '#align finsupp.lex.well_founded_lt_of_finite Finsupp.Lex.wellFoundedLT_of_finite\u2093'. -/\ntheorem Lex.wellFoundedLT_of_finite [LinearOrder \u03b1] [Finite \u03b1] [Zero N] [LT N]\n    [hwf : WellFoundedLT N] : WellFoundedLT (Lex (\u03b1 \u2192\u2080 N)) :=\n  \u27e8Finsupp.Lex.wellFounded_of_finite (\u00b7 < \u00b7) hwf.1\u27e9\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 : \u2200 n : N, \u00acn < 0) :\n    WellFoundedLT (\u03b1 \u2192\u2080 N) :=\n  \u27e8InvImage.wf toDfinsupp (Dfinsupp.wellFoundedLT fun i a => hbot a).wf\u27e9\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 {\u03b1 : 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} \u03b1 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} \u03b1 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} \u03b1 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 {\u03b1 : 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} \u03b1 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} \u03b1 N (AddMonoid.toZero.{u2} N (AddCommMonoid.toAddMonoid.{u2} N (OrderedAddCommMonoid.toAddCommMonoid.{u2} N (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} N _inst_1))))) (Finsupp.preorder.{u1, u2} \u03b1 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'\u2093'. -/\ninstance wellFoundedLT' [CanonicallyOrderedAddMonoid N] [WellFoundedLT N] :\n    WellFoundedLT (\u03b1 \u2192\u2080 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 \u03b1] [Zero N] [Preorder N] [WellFoundedLT N] :\n    WellFoundedLT (\u03b1 \u2192\u2080 N) :=\n  \u27e8InvImage.wf equivFunOnFinite Function.wellFoundedLT.wf\u27e9\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\u00f6lzl\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 `\u21be 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 \u2964 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 {\u03b1 : Type u} {\u03b2 : Type u} : (\u03b1 \u27f6 \u03b2) = (\u03b1 \u2192 \u03b2) :=\n  rfl\n\ntheorem types_id (X : Type u) : \ud835\udfd9 = id :=\n  rfl\n\ntheorem types_comp {X : Type u} {Y : Type u} {Z : Type u} (f : X \u27f6 Y) (g : Y \u27f6 Z) : f \u226b g = g \u2218 f :=\n  rfl\n\n@[simp] theorem types_id_apply (X : Type u) (x : X) : \ud835\udfd9 = x :=\n  rfl\n\n@[simp] theorem types_comp_apply {X : Type u} {Y : Type u} {Z : Type u} (f : X \u27f6 Y) (g : Y \u27f6 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 \u2245 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 \u2245 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 {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) : \u03b1 \u27f6 \u03b2 :=\n  f\n\nprefix:200 \"\u21be\" => Mathlib.category_theory.as_hom\n\nnamespace functor\n\n\n/--\nThe sections of a functor `J \u2964 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 \u27f6 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 \u2964 Type w) : set ((j : J) \u2192 obj F j) :=\n  set_of fun (u : (j : J) \u2192 obj F j) => \u2200 {j j' : J} (f : j \u27f6 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 \u2964 Type w) {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) (a : functor.obj F X) : functor.map F (f \u226b 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 \u2964 Type w) {X : C} (a : functor.obj F X) : functor.map F \ud835\udfd9 a = a := sorry\n\ntheorem naturality {C : Type u} [category C] (F : C \u2964 Type w) (G : C \u2964 Type w) {X : C} {Y : C} (\u03c3 : F \u27f6 G) (f : X \u27f6 Y) (x : functor.obj F X) : nat_trans.app \u03c3 Y (functor.map F f x) = functor.map G f (nat_trans.app \u03c3 X x) :=\n  congr_fun (nat_trans.naturality \u03c3 f) x\n\n@[simp] theorem comp {C : Type u} [category C] (F : C \u2964 Type w) (G : C \u2964 Type w) (H : C \u2964 Type w) {X : C} (\u03c3 : F \u27f6 G) (\u03c4 : G \u27f6 H) (x : functor.obj F X) : nat_trans.app (\u03c3 \u226b \u03c4) X x = nat_trans.app \u03c4 X (nat_trans.app \u03c3 X x) :=\n  rfl\n\n@[simp] theorem hcomp {C : Type u} [category C] (F : C \u2964 Type w) (G : C \u2964 Type w) (\u03c3 : F \u27f6 G) {D : Type u'} [\ud835\udc9f : category D] (I : D \u2964 C) (J : D \u2964 C) (\u03c1 : I \u27f6 J) {W : D} (x : functor.obj (I \u22d9 F) W) : nat_trans.app (\u03c1 \u25eb \u03c3) W x = functor.map G (nat_trans.app \u03c1 W) (nat_trans.app \u03c3 (functor.obj I W) x) :=\n  rfl\n\n@[simp] theorem map_inv_map_hom_apply {C : Type u} [category C] (F : C \u2964 Type w) {X : C} {Y : C} (f : X \u2245 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 \u2964 Type w) {X : C} {Y : C} (f : X \u2245 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 \u2964 Type w) (G : C \u2964 Type w) (\u03b1 : F \u2245 G) (X : C) (x : functor.obj F X) : nat_trans.app (iso.inv \u03b1) X (nat_trans.app (iso.hom \u03b1) X x) = x :=\n  congr_fun (iso.hom_inv_id_app \u03b1 X) x\n\n@[simp] theorem inv_hom_id_app_apply {C : Type u} [category C] (F : C \u2964 Type w) (G : C \u2964 Type w) (\u03b1 : F \u2245 G) (X : C) (x : functor.obj G X) : nat_trans.app (iso.hom \u03b1) X (nat_trans.app (iso.inv \u03b1) X x) = x :=\n  congr_fun (iso.inv_hom_id_app \u03b1 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 \u2245 V :=\n  iso.mk (id fun (\u1fb0 : ulift V) => ulift.cases_on \u1fb0 fun (\u1fb0 : V) => \u1fb0) 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 \u2964 Type 5`.\n-/\ndef ulift_functor : Type u \u2964 Type (max u v) :=\n  functor.mk (fun (X : Type u) => ulift X) fun (X Y : Type u) (f : X \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 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 \u2194 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 \u27f6 Y) : mono f \u2194 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 \u27f6 Y) : epi f \u2194 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 \u2192 Type v) [Functor m] [is_lawful_functor m] : Type u \u2964 Type v :=\n  functor.mk m fun (\u03b1 \u03b2 : Type u) => Functor.map\n\n@[simp] theorem of_type_functor_obj (m : Type u \u2192 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 \u2192 Type v) [Functor m] [is_lawful_functor m] {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) : 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 \u2243 Y) : X \u2245 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 \u2243 Y} : category_theory.iso.hom (to_iso e) = \u21d1e :=\n  rfl\n\n@[simp] theorem to_iso_inv {X : Type u} {Y : Type u} {e : X \u2243 Y} : category_theory.iso.inv (to_iso e) = \u21d1(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 \u2245 Y) : X \u2243 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 \u2245 Y) : \u21d1(to_equiv i) = hom i :=\n  rfl\n\n@[simp] theorem to_equiv_symm_fun {X : Type u} {Y : Type u} (i : X \u2245 Y) : \u21d1(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 \u2245 Y) (g : Y \u2245 Z) : to_equiv (f \u226a\u226b 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 \u27f6 Y) : is_iso f \u2243 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 \u2243 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 \u2243 Y \u2243 (X \u2245 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 \u2243 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 \u2245 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 `+\u1d65` for adding a group element to a point and\n`-\u1d65` 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 +\u1d65 p` is a notation for `has_vadd.vadd`, the left action of an additive monoid;\n\n* `p\u2081 -\u1d65 p\u2082` 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 `+\u1d65` notation. -/\nclass has_vadd (G : Type u_1) (P : Type u_2) \nwhere\n  vadd : G \u2192 P \u2192 P\n\n/-- Type class for the `-\u1d65` notation. -/\nclass has_vsub (G : outParam (Type u_1)) (P : Type u_2) \nwhere\n  vsub : P \u2192 P \u2192 G\n\ninfixl:65 \" +\u1d65 \" => Mathlib.has_vadd.vadd\n\ninfixl:65 \" -\u1d65 \" => 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' : \u2200 (p : P), 0 +\u1d65 p = p\n  vadd_assoc' : \u2200 (g1 g2 : G) (p : P), g1 +\u1d65 (g2 +\u1d65 p) = g1 + g2 +\u1d65 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 `+\u1d65` operation and a corresponding subtraction given by the\n`-\u1d65` 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' : \u2200 (p1 p2 : P), p1 -\u1d65 p2 +\u1d65 p2 = p1\n  vadd_vsub' : \u2200 (g : G) (p : P), g +\u1d65 p -\u1d65 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 +\u1d65 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 -\u1d65 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 +\u1d65 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 +\u1d65 (g2 +\u1d65 p) = g1 + g2 +\u1d65 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 +\u1d65 (g2 +\u1d65 p) = g2 +\u1d65 (g1 +\u1d65 p) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (g1 +\u1d65 (g2 +\u1d65 p) = g2 +\u1d65 (g1 +\u1d65 p))) (vadd_assoc g1 g2 p)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (g1 + g2 +\u1d65 p = g2 +\u1d65 (g1 +\u1d65 p))) (vadd_assoc g2 g1 p)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (g1 + g2 +\u1d65 p = g2 + g1 +\u1d65 p)) (add_comm g1 g2))) (Eq.refl (g2 + g1 +\u1d65 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 +\u1d65 p1 = g +\u1d65 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\u2081 : P} {p\u2082 : P} (g : G) : g +\u1d65 p\u2081 = g +\u1d65 p\u2082 \u2194 p\u2081 = p\u2082 :=\n  { mp := vadd_left_cancel g, mpr := fun (h : p\u2081 = p\u2082) => h \u25b8 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 -\u1d65 p2 +\u1d65 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 +\u1d65 p -\u1d65 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 +\u1d65 p = g2 +\u1d65 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 +\u1d65 p -\u1d65 p = g2)) h))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (g2 +\u1d65 p -\u1d65 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 +\u1d65 p = g2 +\u1d65 p \u2194 g1 = g2 :=\n  { mp := vadd_right_cancel p, mpr := fun (h : g1 = g2) => h \u25b8 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 +\u1d65 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 +\u1d65 p1 -\u1d65 p2 = g + (p1 -\u1d65 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 -\u1d65 p = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (p -\u1d65 p = 0)) (Eq.symm (zero_add (p -\u1d65 p)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (0 + (p -\u1d65 p) = 0)) (Eq.symm (vadd_vsub_assoc 0 p p))))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (0 +\u1d65 p -\u1d65 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 -\u1d65 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 -\u1d65 p2 +\u1d65 p2 = p2)) h))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (0 +\u1d65 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 -\u1d65 p2 = 0 \u2194 p1 = p2 :=\n  { mp := eq_of_vsub_eq_zero, mpr := fun (h : p1 = p2) => h \u25b8 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 -\u1d65 p2 + (p2 -\u1d65 p3) = p1 -\u1d65 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 -\u1d65 p2) = p2 -\u1d65 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 -\u1d65 (g +\u1d65 p2) = p1 -\u1d65 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 -\u1d65 p3 - (p2 -\u1d65 p3) = p1 -\u1d65 p2 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (p1 -\u1d65 p3 - (p2 -\u1d65 p3) = p1 -\u1d65 p2)) (Eq.symm (vsub_vadd_eq_vsub_sub p1 p3 (p2 -\u1d65 p3)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (p1 -\u1d65 (p2 -\u1d65 p3 +\u1d65 p3) = p1 -\u1d65 p2)) (vsub_vadd p2 p3))) (Eq.refl (p1 -\u1d65 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 +\u1d65 p2 \u2194 p1 -\u1d65 p2 = g :=\n  { mp := fun (h : p1 = g +\u1d65 p2) => Eq.symm h \u25b8 vadd_vsub g p2,\n    mpr := fun (h : p1 -\u1d65 p2 = g) => h \u25b8 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\u2081 : G} {v\u2082 : G} {p\u2081 : P} {p\u2082 : P} : v\u2081 +\u1d65 p\u2081 = v\u2082 +\u1d65 p\u2082 \u2194 -v\u2081 + v\u2082 = p\u2081 -\u1d65 p\u2082 := 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 -\u1d65 \u2205 = \u2205 :=\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) : \u2205 -\u1d65 s = \u2205 :=\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 -\u1d65 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 -\u1d65 singleton p = (fun (_x : P) => _x -\u1d65 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 -\u1d65 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 -\u1d65 t) :=\n  finite.image2 (fun (a b : P) => a -\u1d65 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 \u2208 s) (ht : pt \u2208 t) : ps -\u1d65 pt \u2208 s -\u1d65 t :=\n  mem_image2_of_mem hs ht\n\n/-- `s -\u1d65 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 \u2286 s') (ht : t \u2286 t') : s -\u1d65 t \u2286 s' -\u1d65 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 \u2286 t) : s -\u1d65 s \u2286 t -\u1d65 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 -\u1d65 t \u2286 u \u2194 \u2200 (x : P), x \u2208 s \u2192 \u2200 (y : P), y \u2208 t \u2192 x -\u1d65 y \u2208 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 \u2286 s') (ht : t \u2286 t') : s +\u1d65 t \u2286 s' +\u1d65 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 +\u1d65 singleton p = (fun (_x : G) => _x +\u1d65 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 +\u1d65 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 +\u1d65 t) :=\n  finite.image2 (fun (a : G) (b : P) => a +\u1d65 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\u2081 : G) (v\u2082 : G) (p : P) : v\u2081 +\u1d65 p -\u1d65 (v\u2082 +\u1d65 p) = v\u2081 - v\u2082 := 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 -\u1d65 p = p2 -\u1d65 p) : p1 = p2 :=\n  eq.mp (Eq._oldrec (Eq.refl (p1 -\u1d65 p2 = 0)) (propext vsub_eq_zero_iff_eq))\n    (eq.mp (Eq._oldrec (Eq.refl (p1 -\u1d65 p - (p2 -\u1d65 p) = 0)) (vsub_sub_vsub_cancel_right p1 p2 p))\n      (eq.mp (Eq._oldrec (Eq.refl (p1 -\u1d65 p = p2 -\u1d65 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 -\u1d65 p = p2 -\u1d65 p \u2194 p1 = p2 :=\n  { mp := vsub_left_cancel, mpr := fun (h : p1 = p2) => h \u25b8 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 -\u1d65 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 -\u1d65 p1 = p -\u1d65 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 -\u1d65 p1 = p -\u1d65 p2 \u2194 p1 = p2 :=\n  { mp := vsub_right_cancel, mpr := fun (h : p1 = p2) => h \u25b8 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 -\u1d65 p2 - (p3 -\u1d65 p1) = p1 -\u1d65 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 +\u1d65 p1 -\u1d65 (v +\u1d65 p2) = p1 -\u1d65 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 -\u1d65 p2 +\u1d65 p3 = p3 -\u1d65 p2 +\u1d65 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\u2081 : G} {v\u2082 : G} {p\u2081 : P} {p\u2082 : P} : v\u2081 +\u1d65 p\u2081 = v\u2082 +\u1d65 p\u2082 \u2194 v\u2082 - v\u2081 = p\u2081 -\u1d65 p\u2082 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (v\u2081 +\u1d65 p\u2081 = v\u2082 +\u1d65 p\u2082 \u2194 v\u2082 - v\u2081 = p\u2081 -\u1d65 p\u2082)) (propext vadd_eq_vadd_iff_neg_add_eq_vsub)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (-v\u2081 + v\u2082 = p\u2081 -\u1d65 p\u2082 \u2194 v\u2082 - v\u2081 = p\u2081 -\u1d65 p\u2082)) (neg_add_eq_sub v\u2081 v\u2082)))\n      (iff.refl (v\u2082 - v\u2081 = p\u2081 -\u1d65 p\u2082)))\n\ntheorem vsub_sub_vsub_comm {G : Type u_1} {P : Type u_2} [add_comm_group G] [add_torsor G P] (p\u2081 : P) (p\u2082 : P) (p\u2083 : P) (p\u2084 : P) : p\u2081 -\u1d65 p\u2082 - (p\u2083 -\u1d65 p\u2084) = p\u2081 -\u1d65 p\u2083 - (p\u2082 -\u1d65 p\u2084) := 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 \u00d7 G') (P \u00d7 P') :=\n  add_torsor.mk (fun (v : G \u00d7 G') (p : P \u00d7 P') => (fst v +\u1d65 fst p, snd v +\u1d65 snd p)) sorry sorry\n    (fun (p\u2081 p\u2082 : P \u00d7 P') => (fst p\u2081 -\u1d65 fst p\u2082, snd p\u2081 -\u1d65 snd p\u2082)) 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 \u00d7 G') (p : P \u00d7 P') : fst (v +\u1d65 p) = fst v +\u1d65 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 \u00d7 G') (p : P \u00d7 P') : snd (v +\u1d65 p) = snd v +\u1d65 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') +\u1d65 (p, p') = (v +\u1d65 p, v' +\u1d65 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\u2081 : P \u00d7 P') (p\u2082 : P \u00d7 P') : fst (p\u2081 -\u1d65 p\u2082) = fst p\u2081 -\u1d65 fst p\u2082 :=\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\u2081 : P \u00d7 P') (p\u2082 : P \u00d7 P') : snd (p\u2081 -\u1d65 p\u2082) = snd p\u2081 -\u1d65 snd p\u2082 :=\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\u2081 : P) (p\u2082 : P) (p\u2081' : P') (p\u2082' : P') : (p\u2081, p\u2081') -\u1d65 (p\u2082, p\u2082') = (p\u2081 -\u1d65 p\u2082, p\u2081' -\u1d65 p\u2082') :=\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 \u2192 Type v} [(i : I) \u2192 add_group (fg i)] {fp : I \u2192 Type w} [T : (i : I) \u2192 add_torsor (fg i) (fp i)] : add_torsor ((i : I) \u2192 fg i) ((i : I) \u2192 fp i) :=\n  add_torsor.mk (fun (g : (i : I) \u2192 fg i) (p : (i : I) \u2192 fp i) (i : I) => g i +\u1d65 p i) sorry sorry\n    (fun (p\u2081 p\u2082 : (i : I) \u2192 fp i) (i : I) => p\u2081 i -\u1d65 p\u2082 i) sorry sorry\n\n/-- Addition in a product of `add_torsor`s. -/\n@[simp] theorem vadd_apply {I : Type u} {fg : I \u2192 Type v} [(i : I) \u2192 add_group (fg i)] {fp : I \u2192 Type w} [T : (i : I) \u2192 add_torsor (fg i) (fp i)] (x : (i : I) \u2192 fg i) (y : (i : I) \u2192 fp i) {i : I} : has_vadd.vadd x y i = x i +\u1d65 y i :=\n  rfl\n\nend pi\n\n\nnamespace equiv\n\n\n/-- `v \u21a6 v +\u1d65 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 \u2243 P :=\n  mk (fun (v : G) => v +\u1d65 p) (fun (p' : P) => p' -\u1d65 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) : \u21d1(vadd_const p) = fun (v : G) => v +\u1d65 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) : \u21d1(equiv.symm (vadd_const p)) = fun (p' : P) => p' -\u1d65 p :=\n  rfl\n\n/-- `p' \u21a6 p -\u1d65 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 \u2243 G :=\n  mk (has_vsub.vsub p) (fun (v : G) => -v +\u1d65 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) : \u21d1(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) : \u21d1(equiv.symm (const_vsub p)) = fun (v : G) => -v +\u1d65 p :=\n  rfl\n\n/-- The permutation given by `p \u21a6 v +\u1d65 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) : \u21d1(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\u2081 : G) (v\u2082 : G) : const_vadd P (v\u2081 + v\u2082) = const_vadd P v\u2081 * const_vadd P v\u2082 :=\n  ext fun (p : P) => Eq.symm (vadd_assoc v\u2081 v\u2082 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 \u2192* 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 -\u1d65 y +\u1d65 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 \u21d1(point_reflection x) := sorry\n\n/-- `x` is the only fixed point of `point_reflection x`. This lemma requires\n`x + x = y + y \u2194 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 \u2194 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 : \u00ac\u00acp) : p :=\n  by_cases\n    (assume h1 : p, h1)\n    (assume h1 : \u00acp, 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 : \u2115) [h : CharP R p] : CharP R[X] p :=\n  let \u27e8h\u27e9 := h\n  \u27e8fun n => by rw [\u2190 map_natCast C, \u2190 C_0, C_inj, h]\u27e9\n\nvariable (R)\n\n#print Polynomial.degreeLe /-\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree \u2264 `n`. -/\ndef degreeLe (n : WithBot \u2115) : Submodule R R[X] :=\n  \u2a05 k : \u2115, \u2a05 h : \u2191k > 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 : \u2115) : Submodule R R[X] :=\n  \u2a05 k : \u2115, \u2a05 h : k \u2265 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 \u2115} {f : R[X]} : f \u2208 degreeLe R n \u2194 degree f \u2264 n := by\n  simp only [degree_le, Submodule.mem_inf\u1d62, 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\u2093'. -/\n@[mono]\ntheorem degreeLe_mono {m n : WithBot \u2115} (H : m \u2264 n) : degreeLe R m \u2264 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 : \u2115} :\n    degreeLe R n = Submodule.span R \u2191((Finset.range (n + 1)).image fun n => (X : R[X]) ^ n) :=\n  by\n  apply le_antisymm\n  \u00b7 intro p hp\n    replace hp := mem_degree_le.1 hp\n    rw [\u2190 Polynomial.sum_monomial_eq p, Polynomial.sum]\n    refine' Submodule.sum_mem _ fun k hk => _\n    show monomial _ _ \u2208 _\n    have := WithBot.coe_le_coe.1 (Finset.sup_le_iff.1 hp k hk)\n    rw [\u2190 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 \u27e8_, Finset.mem_range.2 (Nat.lt_succ_of_le this), rfl\u27e9)\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 : \u2115} {f : R[X]} : f \u2208 degreeLt R n \u2194 degree f < n :=\n  by\n  simp_rw [degree_lt, Submodule.mem_inf\u1d62, 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\u2093'. -/\n@[mono]\ntheorem degreeLt_mono {m n : \u2115} (H : m \u2264 n) : degreeLt R m \u2264 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 : \u2115} :\n    degreeLt R n = Submodule.span R \u2191((Finset.range n).image fun n => X ^ n : Finset R[X]) :=\n  by\n  apply le_antisymm\n  \u00b7 intro p hp\n    replace hp := mem_degree_lt.1 hp\n    rw [\u2190 Polynomial.sum_monomial_eq p, Polynomial.sum]\n    refine' Submodule.sum_mem _ fun k hk => _\n    show monomial _ _ \u2208 _\n    have := WithBot.coe_lt_coe.1 ((Finset.sup_lt_iff <| WithBot.bot_lt_coe n).1 hp k hk)\n    rw [\u2190 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 \u27e8_, Finset.mem_range.2 this, rfl\u27e9)\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 \u2192 R`. -/\ndef degreeLtEquiv (R) [Semiring R] (n : \u2115) : degreeLt R n \u2243\u2097[R] Fin n \u2192 R\n    where\n  toFun p n := (\u2191p : R[X]).coeff n\n  invFun f :=\n    \u27e8\u2211 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))\u27e9\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 \u27e8p, hp\u27e9; ext1\n    simp only [Submodule.coe_mk]\n    by_cases hp0 : p = 0\n    \u00b7 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, \u2190 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    \u00b7 rintro j - hji\n      rw [coeff_monomial, if_neg]\n      rwa [\u2190 Fin.ext_iff]\n    \u00b7 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 (\u1fb0 : 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 (\u1fb0 : 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 (\u1fb0 : 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 (\u1fb0 : 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\u2093'. -/\n@[simp]\ntheorem degreeLtEquiv_eq_zero_iff_eq_zero {n : \u2115} {p : R[X]} (hp : p \u2208 degreeLt R n) :\n    degreeLtEquiv _ _ \u27e8p, hp\u27e9 = 0 \u2194 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 (\u1fb0 : 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 (\u1fb0 : 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 (\u1fb0 : 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\u2093.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\u2093'. -/\ntheorem eval_eq_sum_degreeLtEquiv {n : \u2115} {p : R[X]} (hp : p \u2208 degreeLt R n) (x : R) :\n    p.eval x = \u2211 i, degreeLtEquiv _ _ \u27e8p, hp\u27e9 i * x ^ (i : \u2115) :=\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]) = \u2205 :=\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\u2093'. -/\ntheorem mem_frange_iff {p : R[X]} {c : R} : c \u2208 p.frange \u2194 \u2203 n \u2208 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]) \u2286 {1} :=\n  by\n  simp [frange, Finset.image_subset_iff]\n  simp only [\u2190 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\u2093'. -/\ntheorem coeff_mem_frange (p : R[X]) (n : \u2115) (h : p.coeff n \u2260 0) : p.coeff n \u2208 p.frange :=\n  by\n  simp only [frange, exists_prop, mem_support_iff, Finset.mem_image, Ne.def]\n  exact \u27e8n, h, rfl\u27e9\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 : \u2115) :\n    (\u2211 i in range n, (X : R[X]) ^ i).comp (X + 1) =\n      (Finset.range n).Sum fun i : \u2115 => (n.choose (i + 1) : R[X]) * X ^ i :=\n  by\n  ext i\n  trans (n.choose (i + 1) : R); swap\n  \u00b7 simp only [finset_sum_coeff, \u2190 C_eq_nat_cast, coeff_C_mul_X_pow]\n    rw [Finset.sum_eq_single i, if_pos rfl]\n    \u00b7\n      simp (config := { contextual := true }) only [@eq_comm _ i, if_false, eq_self_iff_true,\n        imp_true_iff]\n    \u00b7\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  \u00b7 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 : \u2115} (hn : n \u2260 0) :\n    (\u2211 i in range n, P ^ i).Monic := by\n  nontriviality R\n  cases n; \u00b7 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  \u00b7 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  \u00b7 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 : \u2115} (hn : n \u2260 0) :\n    (\u2211 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 : \u2115} (hn : n \u2260 0) : (\u2211 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\u2093.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\u2093.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\u2093.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\u2093'. -/\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 (\u2191p.frange : Set R)) :=\n  \u2211 i in p.support,\n    monomial i\n      (\u27e8p.coeff i,\n          if H : p.coeff i = 0 then H.symm \u25b8 (Subring.closure _).zero_mem\n          else Subring.subset_closure (p.coeff_mem_frange _ H)\u27e9 :\n        Subring.closure (\u2191p.frange : Set R))\n#align polynomial.restriction Polynomial.restriction\n\n#print Polynomial.coeff_restriction /-\n@[simp]\ntheorem coeff_restriction {p : R[X]} {n : \u2115} : \u2191(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  \u00b7 rw [h]\n    rfl\n  \u00b7 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 : \u2115} : (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 [\u2190 coeff_restriction]\n  exact\n    \u27e8fun H => by\n      rw [H]\n      rfl, fun H => Subtype.coe_injective H\u27e9\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem monic_restriction {p : R[X]} : Monic (restriction p) \u2194 Monic p :=\n  by\n  simp only [monic, leading_coeff, nat_degree_restriction]\n  rw [\u2190 @coeff_restriction _ _ p]\n  exact\n    \u27e8fun H => by\n      rw [H]\n      rfl, fun H => Subtype.coe_injective H\u27e9\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\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 \u2192+* S} {x : S}\n\n/- warning: polynomial.eval\u2082_restriction -> Polynomial.eval\u2082_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\u2082.{u1, u2} R S (Ring.toSemiring.{u1} R _inst_1) _inst_2 f x p) (Polynomial.eval\u2082.{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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2082.{u2, u1} R S (Ring.toSemiring.{u2} R _inst_1) _inst_2 f x p) (Polynomial.eval\u2082.{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\u2082_restriction Polynomial.eval\u2082_restriction\u2093'. -/\ntheorem eval\u2082_restriction {p : R[X]} :\n    eval\u2082 f x p =\n      eval\u2082 (f.comp (Subring.subtype (Subring.closure (p.frange : Set R)))) x p.restriction :=\n  by\n  simp only [eval\u2082_eq_sum, Sum, support_restriction, \u2190 @coeff_restriction _ _ p]\n  rfl\n#align polynomial.eval\u2082_restriction Polynomial.eval\u2082_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\u2093.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\u2093.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\u2093'. -/\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 : (\u2191p.frange : Set R) \u2286 T) : T[X] :=\n  \u2211 i in p.support,\n    monomial i\n      (\u27e8p.coeff i, if H : p.coeff i = 0 then H.symm \u25b8 T.zero_mem else hp (p.coeff_mem_frange _ H)\u27e9 :\n        T)\n#align polynomial.to_subring Polynomial.toSubring\n\nvariable (hp : (\u2191p.frange : Set R) \u2286 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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coeff_toSubring {n : \u2115} : \u2191(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  \u00b7 rw [h]\n    rfl\n  \u00b7 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\u2093.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\u2093.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'\u2093'. -/\n@[simp]\ntheorem coeff_to_subring' {n : \u2115} : (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\u2093.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\u2093.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\u2093'. -/\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 [\u2190 coeff_to_subring p T hp]\n  exact\n    \u27e8fun H => by\n      rw [H]\n      rfl, fun H => Subtype.coe_injective H\u27e9\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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem monic_toSubring : Monic (toSubring p T hp) \u2194 Monic p :=\n  by\n  simp_rw [monic, leading_coeff, nat_degree_to_subring, \u2190 coeff_to_subring p T hp]\n  exact\n    \u27e8fun H => by\n      rw [H]\n      rfl, fun H => Subtype.coe_injective H\u27e9\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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)] (\u1fb0 : Set.{u1} R) (\u1fb0_1 : Set.{u1} R) (e_2 : Eq.{succ u1} (Set.{u1} R) \u1fb0 \u1fb0_1) (\u1fb0_2 : Set.{u1} R) (\u1fb0_3 : Set.{u1} R) (e_3 : Eq.{succ u1} (Set.{u1} R) \u1fb0_2 \u1fb0_3) => congr.{succ u1, 1} (Set.{u1} R) Prop (HasSubset.Subset.{u1} (Set.{u1} R) self \u1fb0) (HasSubset.Subset.{u1} (Set.{u1} R) self \u1fb0_1) \u1fb0_2 \u1fb0_3 (congr_arg.{succ u1, succ u1} (Set.{u1} R) ((Set.{u1} R) -> Prop) \u1fb0 \u1fb0_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\u2093.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\u2093.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\u2093.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)] (\u1fb0 : Finset.{u1} R) (\u1fb0_1 : Finset.{u1} R) (e_2 : Eq.{succ u1} (Finset.{u1} R) \u1fb0 \u1fb0_1) => congr_arg.{succ u1, succ u1} (Finset.{u1} R) (Set.{u1} R) \u1fb0 \u1fb0_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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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 {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) => iff_true_intro (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.hasEmptyc.{u1} \u03b1)) s) (Set.empty_subset.{u1} \u03b1 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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\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  \u2211 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\u2093.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\u2093'. -/\ntheorem coeff_ofSubring (p : T[X]) (n : \u2115) : 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem frange_ofSubring {p : T[X]} : (\u2191(p.ofSubring T).frange : Set R) \u2286 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 \u27e8n, hn, h'n\u27e9\n  rw [\u2190 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\u2093'. -/\ntheorem mem_ker_mod_by_monic (hq : q.Monic) {p : R[X]} : p \u2208 (modByMonicHom q).ker \u2194 q \u2223 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\u2093'. -/\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 [\u2190 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 \u2208 I.ofPolynomial \u2194 x \u2208 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 \u2264 `n`. -/\ndef degreeLe (n : WithBot \u2115) : Submodule R R[X] :=\n  degreeLe R n \u2293 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 \u2264 `n`. -/\ndef leadingCoeffNth (n : \u2115) : 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  \u2a06 n : \u2115, 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\u2093'. -/\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 : \u2200 n : \u2115, p.coeff n \u2208 I.comap (C : R \u2192+* R[X])) : p \u2208 I :=\n  sum_C_mul_X_pow_eq p \u25b8 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\u2093'. -/\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 \u2208 (Ideal.map (C : R \u2192+* R[X]) I : Ideal R[X]) \u2194 \u2200 n : \u2115, f.coeff n \u2208 I :=\n  by\n  constructor\n  \u00b7 intro hf\n    apply Submodule.span_induction hf\n    \u00b7 intro f hf n\n      cases' (Set.mem_image _ _ _).mp hf with x hx\n      rw [\u2190 hx.right, coeff_C]\n      by_cases n = 0\n      \u00b7 simpa [h] using hx.left\n      \u00b7 simp [h]\n    \u00b7 simp\n    \u00b7 exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]\n    \u00b7 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  \u00b7 intro hf\n    rw [\u2190 sum_monomial_eq f]\n    refine' (I.map C : Ideal R[X]).sum_mem fun n hn => _\n    simp [\u2190 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\u2093'. -/\ntheorem Polynomial.ker_mapRingHom (f : R \u2192+* S) :\n    (Polynomial.mapRingHom f).ker = f.ker.map (C : R \u2192+* 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\u2093.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\u2093'. -/\ntheorem mem_leadingCoeffNth (n : \u2115) (x) :\n    x \u2208 I.leadingCoeffNth n \u2194 \u2203 p \u2208 I, degree p \u2264 n \u2227 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  \u00b7 rintro \u27e8p, \u27e8hpdeg, hpI\u27e9, rfl\u27e9\n    cases' lt_or_eq_of_le hpdeg with hpdeg hpdeg\n    \u00b7 refine' \u27e80, I.zero_mem, bot_le, _\u27e9\n      rw [leading_coeff_zero, eq_comm]\n      exact coeff_eq_zero_of_degree_lt hpdeg\n    \u00b7 refine' \u27e8p, hpI, le_of_eq hpdeg, _\u27e9\n      rw [Polynomial.leadingCoeff, nat_degree, hpdeg]\n      rfl\n  \u00b7 rintro \u27e8p, hpI, hpdeg, rfl\u27e9\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' \u27e8p * X ^ (n - nat_degree p), \u27e8_, I.mul_mem_right _ hpI\u27e9, _\u27e9\n    \u00b7 apply le_trans (degree_mul_le _ _) _\n      apply le_trans (add_le_add degree_le_nat_degree (degree_X_pow_le _)) _\n      rw [\u2190 WithBot.coe_add, this]\n      exact le_rfl\n    \u00b7 rw [Polynomial.leadingCoeff, \u2190 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\u2093'. -/\ntheorem mem_leadingCoeffNth_zero (x) : x \u2208 I.leadingCoeffNth 0 \u2194 C x \u2208 I :=\n  (mem_leadingCoeffNth _ _ _).trans\n    \u27e8fun \u27e8p, hpI, hpdeg, hpx\u27e9 => by\n      rwa [\u2190 hpx, Polynomial.leadingCoeff,\n        Nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg), \u2190 eq_C_of_degree_le_zero hpdeg],\n      fun hx => \u27e8C x, hx, degree_C_le, leadingCoeff_C x\u27e9\u27e9\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\u2093'. -/\ntheorem leadingCoeffNth_mono {m n : \u2115} (H : m \u2264 n) : I.leadingCoeffNth m \u2264 I.leadingCoeffNth n :=\n  by\n  intro r hr\n  simp only [SetLike.mem_coe, mem_leading_coeff_nth] at hr\u22a2\n  rcases hr with \u27e8p, hpI, hpdeg, rfl\u27e9\n  refine' \u27e8p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow\u27e9\n  refine' le_trans (degree_mul_le _ _) _\n  refine' le_trans (add_le_add hpdeg (degree_X_pow_le _)) _\n  rw [\u2190 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\u2093'. -/\ntheorem mem_leadingCoeff (x) : x \u2208 I.leadingCoeff \u2194 \u2203 p \u2208 I, Polynomial.leadingCoeff p = x :=\n  by\n  rw [leading_coeff, Submodule.mem_sup\u1d62_of_directed]\n  simp only [mem_leading_coeff_nth]\n  \u00b7 constructor\n    \u00b7 rintro \u27e8i, p, hpI, hpdeg, rfl\u27e9\n      exact \u27e8p, hpI, rfl\u27e9\n    rintro \u27e8p, hpI, rfl\u27e9\n    exact \u27e8nat_degree p, p, hpI, degree_le_nat_degree, rfl\u27e9\n  intro i j;\n  exact\n    \u27e8i + j, I.leading_coeff_nth_mono (Nat.le_add_right _ _),\n      I.leading_coeff_nth_mono (Nat.le_add_left _ _)\u27e9\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] {\u03b9 : Type.{u2}} (s : Finset.{u2} \u03b9) (f : \u03b9 -> (Polynomial.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))) (I : Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (n : \u03b9 -> Nat), (forall (i : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.hasMem.{u2} \u03b9) 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)) \u03b9 (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 \u03b9 Nat.addCommMonoid s n) k)))\nbut is expected to have type\n  forall {R : Type.{u2}} [_inst_1 : CommSemiring.{u2} R] {\u03b9 : Type.{u1}} (s : Finset.{u1} \u03b9) (f : \u03b9 -> (Polynomial.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))) (I : Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (n : \u03b9 -> Nat), (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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)) \u03b9 (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 \u03b9 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\u2093'. -/\n/-- If `I` is an ideal, and `p\u1d62` is a finite family of polynomials each satisfying\n`\u2200 k, (p\u1d62)\u2096 \u2208 I\u207f\u2071\u207b\u1d4f` for some `n\u1d62`, then `p = \u220f p\u1d62` also satisfies `\u2200 k, p\u2096 \u2208 I\u207f\u207b\u1d4f` with `n = \u2211 n\u1d62`.\n-/\ntheorem Polynomial.coeff_prod_mem_ideal_pow_tsub {\u03b9 : Type _} (s : Finset \u03b9) (f : \u03b9 \u2192 R[X])\n    (I : Ideal R) (n : \u03b9 \u2192 \u2115) (h : \u2200 i \u2208 s, \u2200 (k), (f i).coeff k \u2208 I ^ (n i - k)) (k : \u2115) :\n    (s.Prod f).coeff k \u2208 I ^ (s.Sum n - k) := by\n  classical\n    induction' s using Finset.induction with a s ha hs generalizing k\n    \u00b7 rw [sum_empty, prod_empty, coeff_one, zero_tsub, pow_zero, Ideal.one_eq_top]\n      exact Submodule.mem_top\n    \u00b7 rw [sum_insert ha, prod_insert ha, coeff_mul]\n      apply sum_mem\n      rintro \u27e8i, j\u27e9 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 : \u00acIsField R[X] :=\n  by\n  nontriviality R\n  intro hR\n  obtain \u27e8p, hp\u27e9 := hR.mul_inv_cancel X_ne_zero\n  have hp0 : p \u2260 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 [\u2190 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\u2093'. -/\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 \u2208 I) : x = 0 :=\n  by\n  refine' by_contradiction fun hx0 => hI.ne_top ((eq_top_iff_one I).2 _)\n  obtain \u27e8y, hy\u27e9 := hR.mul_inv_cancel hx0\n  convert I.mul_mem_left (C y) hx\n  rw [\u2190 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\u2093'. -/\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 \u2192+* R[X]) P : Ideal R[X]) \u2194 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  \u00b7 intro H\n    have := @comap_is_prime R R[X] (R \u2192+* 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    \u00b7 rintro h (- | n)\n      \u00b7 simpa only [coeff_C_zero] using h\n      \u00b7 simp only [coeff_C_ne_zero (Nat.succ_ne_zero _), Submodule.zero_mem]\n    \u00b7 intro h\n      simpa only [coeff_C_zero] using h 0\n  \u00b7 intro h\n    constructor\n    \u00b7 rw [Ne.def, eq_top_iff_one, mem_map_C_iff, not_forall]\n      use 0\n      rw [coeff_one_zero, \u2190 eq_top_iff_one]\n      exact h.1\n    \u00b7 intro f g\n      simp only [mem_map_C_iff]\n      contrapose!\n      rintro \u27e8hf, hg\u27e9\n      classical\n        let m := Nat.find hf\n        let n := Nat.find hg\n        refine' \u27e8m + n, _\u27e9\n        rw [coeff_mul, \u2190 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        \u00b7 apply mt h.2\n          rw [not_or]\n          exact \u27e8Nat.find_spec hf, Nat.find_spec hg\u27e9\n        apply P.sum_mem\n        rintro \u27e8i, j\u27e9 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 \u2228 j < n :=\n          by\n          rw [or_iff_not_imp_left, not_lt, le_iff_lt_or_eq]\n          rintro (hmi | rfl)\n          \u00b7 rw [\u2190 not_le]\n            intro hnj\n            exact (add_lt_add_of_lt_of_le hmi hnj).Ne hij.2.symm\n          \u00b7\n            simpa only [eq_self_iff_true, not_true, false_or_iff, add_right_inj,\n              not_and_self_iff] using hij\n        \u00b7 rw [mul_comm]\n          apply P.mul_mem_left\n          exact Classical.not_not.1 (Nat.find_min hf hi)\n        \u00b7 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\u2093'. -/\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 \u2192+* 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 : \u2115) :\n    Submodule.Fg (I.degreeLe n) :=\n  isNoetherian_submodule_left.1\n    (isNoetherian_of_fg_of_noetherian _ \u27e8_, degreeLe_eq_span_X_pow.symm\u27e9) _\n#align ideal.is_fg_degree_le Ideal.is_fg_degreeLe\n-/\n\nend CommRing\n\nend Ideal\n\nvariable {\u03c3 : Type v} {M : Type w}\n\nvariable [CommRing R] [CommRing S] [AddCommGroup M] [Module R M]\n\nsection Prime\n\nvariable (\u03c3) {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\u2093'. -/\ntheorem prime_C_iff : Prime (C r) \u2194 Prime r :=\n  \u27e8comap_prime C (evalRingHom (0 : R)) fun r => eval_C, fun hr =>\n    by\n    have := hr.1\n    rw [\u2190 Ideal.span_singleton_prime] at hr\u22a2\n    \u00b7 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]\u27e9\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 \u03c3] : Prime (C r : MvPolynomial \u03c3 R) \u2194 Prime r :=\n  by\n  rw [(rename_equiv R (Fintype.equivFin \u03c3)).toMulEquiv.prime_iff]\n  convert_to Prime (C r) \u2194 _;\n  \u00b7 congr\n    apply rename_C\n  \u00b7 symm\n    induction' Fintype.card \u03c3 with d hd\n    \u00b7 exact (is_empty_alg_equiv R (Fin 0)).toMulEquiv.symm.prime_iff\n    \u00b7 rw [hd, \u2190 Polynomial.prime_C_iff]\n      convert(finSuccEquiv R d).toMulEquiv.symm.prime_iff\n      rw [\u2190 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}} (\u03c3 : Type.{u2}) [_inst_1 : CommRing.{u1} R] {r : R}, Iff (Prime.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toCommMonoidWithZero.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (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} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (fun (_x : RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) => R -> (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1))) (RingHom.hasCoeToFun.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R \u03c3 (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}} (\u03c3 : 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} \u03c3 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} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) r) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _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} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => MvPolynomial.{u2, u1} \u03c3 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} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)))))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u1, max u2 u1} (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u1, max u2 u1} (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)))) (RingHom.instRingHomClassRingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)))))))) (MvPolynomial.C.{u1, u2} R \u03c3 (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\u2093'. -/\ntheorem prime_C_iff : Prime (C r : MvPolynomial \u03c3 R) \u2194 Prime r :=\n  \u27e8comap_prime C constantCoeff (constantCoeff_C _), fun hr =>\n    \u27e8fun h =>\n      hr.1 <| by\n        rw [\u2190 C_inj, h]\n        simp,\n      fun h =>\n      hr.2.1 <| by\n        rw [\u2190 constant_coeff_C _ r]\n        exact h.map _,\n      fun a b hd => by\n      obtain \u27e8s, a', b', rfl, rfl\u27e9 := exists_finset_rename\u2082 a b\n      rw [\u2190 algebra_map_eq] at hd\n      have : algebraMap R _ r \u2223 a' * b' :=\n        by\n        convert(kill_compl Subtype.coe_injective).toRingHom.map_dvd hd\n        simpa\n        simp\n      rw [\u2190 rename_C (coe : s \u2192 \u03c3)]\n      let f := (rename (coe : s \u2192 \u03c3)).toRingHom\n      exact (((prime_C_iff_of_fintype s).2 hr).2.2 a' b' this).imp f.map_dvd f.map_dvd\u27e9\u27e9\n#align mv_polynomial.prime_C_iff MvPolynomial.prime_C_iff\n\nvariable {\u03c3}\n\n#print MvPolynomial.prime_rename_iff /-\ntheorem prime_rename_iff (s : Set \u03c3) {p : MvPolynomial s R} :\n    Prime (rename (coe : s \u2192 \u03c3) p) \u2194 Prime p := by\n  classical\n    symm\n    let eqv :=\n      (sum_alg_equiv R _ _).symm.trans\n        (rename_equiv R <| (Equiv.sumComm (\u21a5(s\u1d9c)) s).trans <| Equiv.Set.sumCompl s)\n    rw [\u2190 prime_C_iff \u21a5(s\u1d9c), 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    \u00b7 apply ring_hom_ext\n      \u00b7 intro\n        dsimp [eqv]\n        erw [iter_to_sum_C_C, rename_C, rename_C]\n      \u00b7 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          (\u27e8fun p : R[X] =>\n              ((if p = 0 then \u22a4 else \u2191p.degree : WithTop (WithBot \u2115)), p.leadingCoeff), _\u27e9 :\n            DvdNotUnit \u2192r Prod.Lex (\u00b7 < \u00b7) DvdNotUnit)\n          (WellFounded.prod_lex (WithTop.wellFounded_lt <| WithBot.wellFounded_lt Nat.lt_wfRel)\n            \u2039WfDvdMonoid R\u203a.wellFounded_dvdNotUnit)\n      rintro a b \u27e8ane0, \u27e8c, \u27e8not_unit_c, rfl\u27e9\u27e9\u27e9\n      rw [Polynomial.degree_mul, if_neg ane0]\n      split_ifs with hac\n      \u00b7 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 \u2260 0 := right_ne_zero_of_mul hac\n      simp only [cne0, ane0, Polynomial.leadingCoeff_mul]\n      by_cases hdeg : c.degree = 0\n      \u00b7 simp only [hdeg, add_zero]\n        refine' Prod.Lex.right _ \u27e8_, \u27e8c.leading_coeff, fun unit_c => not_unit_c _, rfl\u27e9\u27e9\n        \u00b7 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      \u00b7 apply Prod.Lex.left\n        rw [Polynomial.degree_eq_natDegree cne0] at *\n        rw [WithTop.coe_lt_coe, Polynomial.degree_eq_natDegree ane0, \u2190 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 \u25b8 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    \u27e8fun I : Ideal R[X] =>\n      let M :=\n        WellFounded.min (isNoetherian_iff_wellFounded.1 (by infer_instance))\n          (Set.range I.leadingCoeffNth) \u27e8_, \u27e80, rfl\u27e9\u27e9\n      have hm : M \u2208 Set.range I.leadingCoeffNth := WellFounded.min_mem _ _ _\n      let \u27e8N, HN\u27e9 := hm\n      let \u27e8s, hs\u27e9 := I.is_fg_degreeLe N\n      have hm2 : \u2200 k, I.leadingCoeffNth k \u2264 M := fun k =>\n        Or.cases_on (le_or_lt k N) (fun h => HN \u25b8 I.leadingCoeffNth_mono h) fun h x hx =>\n          by_contradiction fun hxm =>\n            have : \u00acM < I.leadingCoeffNth k := by\n              refine' WellFounded.not_lt_min (wellFounded_submodule_gt _ _) _ _ _ <;> exact \u27e8k, rfl\u27e9\n            this \u27e8HN \u25b8 I.leadingCoeffNth_mono (le_of_lt h), fun H => hxm (H hx)\u27e9\n      have hs2 : \u2200 {x}, x \u2208 I.degreeLe N \u2192 x \u2208 Ideal.span (\u2191s : Set R[X]) :=\n        hs \u25b8 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 \u25b8 Ideal.mul_mem_left _ _ hf\n      \u27e8s,\n        le_antisymm\n            (Ideal.span_le.2 fun x hx =>\n              have : x \u2208 I.degreeLe N := hs \u25b8 Submodule.subset_span hx\n              this.2) <|\n          by\n          have : Submodule.span R[X] \u2191s = Ideal.span \u2191s := 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          \u00b7 subst k\n            refine'\n              hs2\n                \u27e8Polynomial.mem_degreeLe.2\n                    (le_trans Polynomial.degree_le_natDegree <| WithBot.coe_le_coe.2 h),\n                  hp\u27e9\n          \u00b7 have hp0 : p \u2260 0 := by\n              rintro rfl\n              cases hn\n              exact Nat.not_lt_zero _ h\n            have : (0 : R) \u2260 1 := by\n              intro h\n              apply hp0\n              ext i\n              refine' (mul_one _).symm.trans _\n              rw [\u2190 h, MulZeroClass.mul_zero]\n              rfl\n            haveI : Nontrivial R := \u27e8\u27e80, 1, this\u27e9\u27e9\n            have : p.leading_coeff \u2208 I.leading_coeff_nth N :=\n              by\n              rw [HN]\n              exact\n                hm2 k\n                  ((I.mem_leading_coeff_nth _ _).2\n                    \u27e8_, hp, hn \u25b8 Polynomial.degree_le_natDegree, rfl\u27e9)\n            rw [I.mem_leading_coeff_nth] at this\n            rcases this with \u27e8q, hq, hdq, hlqp\u27e9\n            have hq0 : q \u2260 0 := by\n              intro H\n              rw [\u2190 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 [\u2190 WithBot.coe_add, add_tsub_cancel_of_le, hn]\n              \u00b7 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 [\u2190 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 [\u2190 sub_add_cancel p (q * Polynomial.X ^ (k - q.nat_degree))]\n            refine' (Ideal.span \u2191s).add_mem _ ((Ideal.span \u2191s).mul_mem_right _ _)\n            \u00b7 by_cases hpq : p - q * Polynomial.X ^ (k - q.nat_degree) = 0\n              \u00b7 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 \u27e8Polynomial.mem_degreeLe.2 hdq, hq\u27e9\u27e9\u27e9\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\u2093'. -/\ntheorem exists_irreducible_of_degree_pos {R : Type u} [CommRing R] [IsDomain R] [WfDvdMonoid R]\n    {f : R[X]} (hf : 0 < f.degree) : \u2203 g, Irreducible g \u2227 g \u2223 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 \u25b8 (@degree_zero R _).symm \u25b8 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\u2093'. -/\ntheorem exists_irreducible_of_natDegree_pos {R : Type u} [CommRing R] [IsDomain R] [WfDvdMonoid R]\n    {f : R[X]} (hf : 0 < f.natDegree) : \u2203 g, Irreducible g \u2227 g \u2223 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\u2093'. -/\ntheorem exists_irreducible_of_natDegree_ne_zero {R : Type u} [CommRing R] [IsDomain R]\n    [WfDvdMonoid R] {f : R[X]} (hf : f.natDegree \u2260 0) : \u2203 g, Irreducible g \u2227 g \u2223 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\u2093'. -/\ntheorem linearIndependent_powers_iff_aeval (f : M \u2192\u2097[R] M) (v : M) :\n    (LinearIndependent R fun n : \u2115 => (f ^ n) v) \u2194 \u2200 p : R[X], aeval f p v = 0 \u2192 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 \u2192\u2097[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 \u27e8p', q', hpq'\u27e9\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\u2093'. -/\ntheorem sup_aeval_range_eq_top_of_coprime (f : M \u2192\u2097[R] M) {p q : R[X]} (hpq : IsCoprime p q) :\n    (aeval f p).range \u2294 (aeval f q).range = \u22a4 :=\n  by\n  rw [eq_top_iff]\n  intro v hv\n  rw [Submodule.mem_sup]\n  rcases hpq with \u27e8p', q', hpq'\u27e9\n  use aeval f (p * p') v\n  use LinearMap.mem_range.2 \u27e8aeval f p' v, by simp only [LinearMap.mul_apply, aeval_mul]\u27e9\n  use aeval f (q * q') v\n  use LinearMap.mem_range.2 \u27e8aeval f q' v, by simp only [LinearMap.mul_apply, aeval_mul]\u27e9\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\u2093'. -/\ntheorem sup_ker_aeval_le_ker_aeval_mul {f : M \u2192\u2097[R] M} {p q : R[X]} :\n    (aeval f p).ker \u2294 (aeval f q).ker \u2264 (aeval f (p * q)).ker :=\n  by\n  intro v hv\n  rcases Submodule.mem_sup.1 hv with \u27e8x, hx, y, hy, hxy\u27e9\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, \u2190 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\u2093'. -/\ntheorem sup_ker_aeval_eq_ker_aeval_mul_of_coprime (f : M \u2192\u2097[R] M) {p q : R[X]}\n    (hpq : IsCoprime p q) : (aeval f p).ker \u2294 (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 \u27e8p', q', hpq'\u27e9\n  have h_eval\u2082_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\u2082_pqq' :=\n    calc\n      aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v := by rw [\u2190 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\u2082_qpp' h_eval\u2082_pqq'\n  refine'\n    \u27e8aeval f (q * q') v, LinearMap.mem_ker.1 h_eval\u2082_pqq', aeval f (p * p') v,\n      LinearMap.mem_ker.1 h_eval\u2082_qpp', _\u27e9\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    \u2200 {n : \u2115}, 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 \u03c3] [IsNoetherianRing R] : IsNoetherianRing (MvPolynomial \u03c3 R) :=\n  by\n  cases nonempty_fintype \u03c3 <;>\n    exact\n      @isNoetherianRing_of_ringEquiv (MvPolynomial (Fin (Fintype.card \u03c3)) R) _ _ _\n        (rename_equiv R (Fintype.equivFin \u03c3).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\u2093'. -/\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    \u2200 n : \u2115, 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}) (\u03c3 : Type.{u2}) [_inst_5 : CommSemiring.{u1} R] [_inst_6 : Finite.{succ u2} \u03c3] [_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} \u03c3 R _inst_5) (Distrib.toHasMul.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (NonUnitalNonAssocSemiring.toDistrib.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_5)))))) (MulZeroClass.toHasZero.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (NonUnitalNonAssocSemiring.toMulZeroClass.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_5))))))\nbut is expected to have type\n  forall (R : Type.{u1}) (\u03c3 : Type.{u2}) [_inst_5 : CommSemiring.{u1} R] [_inst_6 : Finite.{succ u2} \u03c3] [_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} \u03c3 R _inst_5) (NonUnitalNonAssocSemiring.toMul.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_5))))) (CommMonoidWithZero.toZero.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (CommSemiring.toCommMonoidWithZero.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_5) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_5)))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.no_zero_divisors_of_finite MvPolynomial.noZeroDivisors_of_finite\u2093'. -/\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) (\u03c3 : Type v) [CommSemiring R] [Finite \u03c3]\n    [NoZeroDivisors R] : NoZeroDivisors (MvPolynomial \u03c3 R) :=\n  by\n  cases nonempty_fintype \u03c3\n  haveI := no_zero_divisors_fin R (Fintype.card \u03c3)\n  exact (rename_equiv R (Fintype.equivFin \u03c3)).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] {\u03c3 : Type v} :\n    NoZeroDivisors (MvPolynomial \u03c3 R) :=\n  \u27e8fun p q h => by\n    obtain \u27e8s, p, rfl\u27e9 := exists_finset_rename p\n    obtain \u27e8t, q, rfl\u27e9 := exists_finset_rename q\n    have :\n      rename (Subtype.map id (Finset.subset_union_left s t) : { x // x \u2208 s } \u2192 { x // x \u2208 s \u222a t })\n            p *\n          rename\n            (Subtype.map id (Finset.subset_union_right s t) : { x // x \u2208 t } \u2192 { x // x \u2208 s \u222a 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 \u2208 s \u222a t }\n    rw [mul_eq_zero] at this\n    cases this <;> [left, right]\n    all_goals simpa using congr_arg (rename Subtype.val) this\u27e9\n\n/-- The multivariate polynomial ring over an integral domain is an integral domain. -/\ninstance {R : Type u} {\u03c3 : Type v} [CommRing R] [IsDomain R] : IsDomain (MvPolynomial \u03c3 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\u2082 -> MvPolynomial.map_mvPolynomial_eq_eval\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : CommRing.{u1} R] {S : Type.{u3}} [_inst_5 : CommRing.{u3} S] [_inst_6 : Finite.{succ u2} \u03c3] (\u03d5 : RingHom.{max u2 u1, u3} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) (p : MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) => (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) -> S) (RingHom.hasCoeToFun.{max u2 u1, u3} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) \u03d5 p) (MvPolynomial.eval\u2082.{u1, u3, u2} R S \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1) (CommRing.toCommSemiring.{u3} S _inst_5) (RingHom.comp.{u1, max u2 u1, u3} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5))) \u03d5 (MvPolynomial.C.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))) (fun (s : \u03c3) => coeFn.{max (succ (max u2 u1)) (succ u3), max (succ (max u2 u1)) (succ u3)} (RingHom.{max u2 u1, u3} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) => (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) -> S) (RingHom.hasCoeToFun.{max u2 u1, u3} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toNonAssocRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u3} S (Ring.toNonAssocRing.{u3} S (CommRing.toRing.{u3} S _inst_5)))) \u03d5 (MvPolynomial.X.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1) s)) p)\nbut is expected to have type\n  forall {R : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : CommRing.{u2} R] {S : Type.{u1}} [_inst_5 : CommRing.{u1} S] [_inst_6 : Finite.{succ u3} \u03c3] (\u03d5 : RingHom.{max u2 u3, u1} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (p : MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u3, u2} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (fun (_x : MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u3, u2} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonUnitalNonAssocSemiring.toMul.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))))))) \u03d5 p) (MvPolynomial.eval\u2082.{u2, u1, u3} R S \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1) (CommRing.toCommSemiring.{u1} S _inst_5) (RingHom.comp.{u2, max u2 u3, u1} R (MvPolynomial.{u3, u2} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))) \u03d5 (MvPolynomial.C.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1))) (fun (s : \u03c3) => 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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (fun (_x : MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u3, u2} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonUnitalNonAssocSemiring.toMul.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5)))) (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) S (NonAssocRing.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (Ring.toNonAssocRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommRing.toRing.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u2, u3} R \u03c3 _inst_1)))) (NonAssocRing.toNonAssocSemiring.{u1} S (Ring.toNonAssocRing.{u1} S (CommRing.toRing.{u1} S _inst_5))))))) \u03d5 (MvPolynomial.X.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1) s)) p)\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.map_mv_polynomial_eq_eval\u2082 MvPolynomial.map_mvPolynomial_eq_eval\u2082\u2093'. -/\ntheorem map_mvPolynomial_eq_eval\u2082 {S : Type _} [CommRing S] [Finite \u03c3] (\u03d5 : MvPolynomial \u03c3 R \u2192+* S)\n    (p : MvPolynomial \u03c3 R) :\n    \u03d5 p = MvPolynomial.eval\u2082 (\u03d5.comp MvPolynomial.C) (fun s => \u03d5 (MvPolynomial.X s)) p :=\n  by\n  cases nonempty_fintype \u03c3\n  refine' trans (congr_arg \u03d5 (MvPolynomial.as_sum p)) _\n  rw [MvPolynomial.eval\u2082_eq', \u03d5.map_sum]\n  congr\n  ext\n  simp only [monomial_eq, \u03d5.map_pow, \u03d5.map_prod, \u03d5.comp_apply, \u03d5.map_mul, Finsupp.prod_pow]\n#align mv_polynomial.map_mv_polynomial_eq_eval\u2082 MvPolynomial.map_mvPolynomial_eq_eval\u2082\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}} {\u03c3 : Type.{u2}} [_inst_1 : CommRing.{u1} R] (I : Ideal.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (p : MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)), (forall (m : Finsupp.{u2, 0} \u03c3 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 \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1) m p) (Ideal.comap.{u1, max u2 u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1))) (RingHom.ringHomClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)) I)) -> (Membership.Mem.{max u2 u1, max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (SetLike.hasMem.{max u2 u1, max u2 u1} (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Submodule.setLike.{max u2 u1, max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))))) (Semiring.toModule.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))))) p I)\nbut is expected to have type\n  forall {R : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : CommRing.{u1} R] (I : Ideal.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1)))) (p : MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)), (forall (m : Finsupp.{u2, 0} \u03c3 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 \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1) m p) (Ideal.comap.{u1, max u1 u2, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (CommSemiring.toSemiring.{u1} R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1))) (RingHom.instRingHomClassRingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)) I)) -> (Membership.mem.{max u1 u2, max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ideal.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1)))) (SetLike.instMembership.{max u1 u2, max u1 u2} (Ideal.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1)))) (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Submodule.setLike.{max u1 u2, max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1)))))) (Semiring.toModule.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _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\u2093'. -/\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 \u03c3 R)) (p : MvPolynomial \u03c3 R)\n    (hcoe : \u2200 m : \u03c3 \u2192\u2080 \u2115, p.coeff m \u2208 I.comap (C : R \u2192+* MvPolynomial \u03c3 R)) : p \u2208 I :=\n  by\n  rw [as_sum p]\n  suffices \u2200 m \u2208 p.support, monomial m (MvPolynomial.coeff m p) \u2208 I by\n    exact Submodule.sum_mem I this\n  intro m hm\n  rw [\u2190 mul_one (coeff m p), \u2190 C_mul_monomial]\n  suffices C (coeff m p) \u2208 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}} {\u03c3 : 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)}, Iff (Membership.Mem.{max u2 u1, max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (SetLike.hasMem.{max u2 u1, max u2 u1} (Ideal.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))) (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Submodule.setLike.{max u2 u1, max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))))) (Semiring.toModule.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1)))))) f (Ideal.map.{u1, max u2 u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commRing.{u1, u2} R \u03c3 _inst_1))) (RingHom.ringHomClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)) I)) (forall (m : Finsupp.{u2, 0} \u03c3 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 \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1) m f) I)\nbut is expected to have type\n  forall {R : Type.{u1}} {\u03c3 : 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)}, Iff (Membership.mem.{max u1 u2, max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ideal.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1)))) (SetLike.instMembership.{max u1 u2, max u1 u2} (Ideal.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1)))) (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Submodule.setLike.{max u1 u2, max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1))) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1)))))) (Semiring.toModule.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1)))))) f (Ideal.map.{u1, max u1 u2, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (Ring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommRing.toRing.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.instCommRingMvPolynomialToCommSemiring.{u1, u2} R \u03c3 _inst_1))) (RingHom.instRingHomClassRingHom.{u1, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)) I)) (forall (m : Finsupp.{u2, 0} \u03c3 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 \u03c3 (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\u2093'. -/\n/-- The push-forward of an ideal `I` of `R` to `mv_polynomial \u03c3 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 \u03c3 R} :\n    f \u2208 (Ideal.map (C : R \u2192+* MvPolynomial \u03c3 R) I : Ideal (MvPolynomial \u03c3 R)) \u2194\n      \u2200 m : \u03c3 \u2192\u2080 \u2115, f.coeff m \u2208 I :=\n  by\n  constructor\n  \u00b7 intro hf\n    apply Submodule.span_induction hf\n    \u00b7 intro f hf n\n      cases' (Set.mem_image _ _ _).mp hf with x hx\n      rw [\u2190 hx.right, coeff_C]\n      by_cases n = 0\n      \u00b7 simpa [h] using hx.left\n      \u00b7 simp [Ne.symm h]\n    \u00b7 simp\n    \u00b7 exact fun f g hf hg n => by simp [I.add_mem (hf n) (hg n)]\n    \u00b7 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  \u00b7 intro hf\n    rw [as_sum f]\n    suffices \u2200 m \u2208 f.support, monomial m (coeff m f) \u2208 (Ideal.map C I : Ideal (MvPolynomial \u03c3 R)) by\n      exact Submodule.sum_mem _ this\n    intro m hm\n    rw [\u2190 mul_one (coeff m f), \u2190 C_mul_monomial]\n    suffices C (coeff m f) \u2208 (Ideal.map C I : Ideal (MvPolynomial \u03c3 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}} {\u03c3 : 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)))) (RingHom.ker.{max u2 u1, max u2 u3, max (max u2 u1) u2 u3} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u3} \u03c3 S (CommRing.toCommSemiring.{u3} S _inst_2)) (RingHom.{max u2 u1, max u2 u3} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u3} \u03c3 S (CommRing.toCommSemiring.{u3} S _inst_2)) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 S (CommRing.toCommSemiring.{u3} S _inst_2)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 S (CommRing.toCommSemiring.{u3} S _inst_2)) (MvPolynomial.commSemiring.{u3, u2} S \u03c3 (CommRing.toCommSemiring.{u3} S _inst_2))))) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 S (CommRing.toCommSemiring.{u3} S _inst_2)) (MvPolynomial.commSemiring.{u3, u2} S \u03c3 (CommRing.toCommSemiring.{u3} S _inst_2))) (RingHom.ringHomClass.{max u2 u1, max u2 u3} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.{u2, u3} \u03c3 S (CommRing.toCommSemiring.{u3} S _inst_2)) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1)))) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 S (CommRing.toCommSemiring.{u3} S _inst_2)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 S (CommRing.toCommSemiring.{u3} S _inst_2)) (MvPolynomial.commSemiring.{u3, u2} S \u03c3 (CommRing.toCommSemiring.{u3} S _inst_2))))) (MvPolynomial.map.{u1, u3, u2} R S \u03c3 (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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (RingHom.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (Ring.toSemiring.{u1} R (CommRing.toRing.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))) (RingHom.ringHomClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R (CommRing.toCommSemiring.{u1} R _inst_1)) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 (CommRing.toCommSemiring.{u1} R _inst_1))))) (MvPolynomial.C.{u1, u2} R \u03c3 (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}} {\u03c3 : 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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1)))) (RingHom.ker.{max u2 u3, max u3 u1, max (max u2 u3) u1} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.{u3, u1} \u03c3 S (CommRing.toCommSemiring.{u1} S _inst_2)) (RingHom.{max u2 u3, max u1 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.{u3, u1} \u03c3 S (CommRing.toCommSemiring.{u1} S _inst_2)) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1)))) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u3, u1} \u03c3 S (CommRing.toCommSemiring.{u1} S _inst_2)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u3, u1} \u03c3 S (CommRing.toCommSemiring.{u1} S _inst_2)) (MvPolynomial.commSemiring.{u1, u3} S \u03c3 (CommRing.toCommSemiring.{u1} S _inst_2))))) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1))) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u3, u1} \u03c3 S (CommRing.toCommSemiring.{u1} S _inst_2)) (MvPolynomial.commSemiring.{u1, u3} S \u03c3 (CommRing.toCommSemiring.{u1} S _inst_2))) (RingHom.instRingHomClassRingHom.{max u2 u3, max u3 u1} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.{u3, u1} \u03c3 S (CommRing.toCommSemiring.{u1} S _inst_2)) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1)))) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u3, u1} \u03c3 S (CommRing.toCommSemiring.{u1} S _inst_2)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u3, u1} \u03c3 S (CommRing.toCommSemiring.{u1} S _inst_2)) (MvPolynomial.commSemiring.{u1, u3} S \u03c3 (CommRing.toCommSemiring.{u1} S _inst_2))))) (MvPolynomial.map.{u2, u1, u3} R S \u03c3 (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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (RingHom.{u2, max u2 u3} R (MvPolynomial.{u3, u2} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1))))) (Ring.toSemiring.{u2} R (CommRing.toRing.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1))) (RingHom.instRingHomClassRingHom.{u2, max u2 u3} R (MvPolynomial.{u3, u2} \u03c3 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} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u3, u2} \u03c3 R (CommRing.toCommSemiring.{u2} R _inst_1)) (MvPolynomial.commSemiring.{u2, u3} R \u03c3 (CommRing.toCommSemiring.{u2} R _inst_1))))) (MvPolynomial.C.{u2, u3} R \u03c3 (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\u2093'. -/\ntheorem ker_map (f : R \u2192+* S) :\n    (map f : MvPolynomial \u03c3 R \u2192+* MvPolynomial \u03c3 S).ker = f.ker.map (C : R \u2192+* MvPolynomial \u03c3 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] (\u03c3)\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 \u03c3] :\n    UniqueFactorizationMonoid (MvPolynomial \u03c3 D) :=\n  (renameEquiv D (Fintype.equivFin \u03c3)).toMulEquiv.symm.UniqueFactorizationMonoid <|\n    by\n    induction' Fintype.card \u03c3 with d hd\n    \u00b7 apply (is_empty_alg_equiv D (Fin 0)).toMulEquiv.symm.UniqueFactorizationMonoid\n      infer_instance\n    \u00b7 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 \u03c3 D) :=\n  by\n  rw [iff_exists_prime_factors]\n  intro a ha; obtain \u27e8s, a', rfl\u27e9 := exists_finset_rename a\n  obtain \u27e8w, h, u, hw\u27e9 :=\n    iff_exists_prime_factors.1 (unique_factorization_monoid_of_fintype s) a' fun h =>\n      ha <| by simp [h]\n  exact\n    \u27e8w.map (rename coe), fun b hb =>\n      let \u27e8b', hb', he\u27e9 := Multiset.mem_map.1 hb\n      he \u25b8 (prime_rename_iff \u2191s).2 (h b' hb'),\n      Units.map (@rename s \u03c3 D _ coe).toRingHom.toMonoidHom u, by\n      erw [Multiset.prod_hom, \u2190 map_mul, hw]\u27e9\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 `\u2124`.\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\u2093.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\u2093.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\u2093'. -/\n@[norm_cast]\ntheorem coe_nat_dvd {m n : \u2115} : (\u2191m : \u2124) \u2223 \u2191n \u2194 m \u2223 n :=\n  \u27e8fun \u27e8a, ae\u27e9 =>\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 \u2124 _ m a (by simp [ae.symm]) (by simpa using m0l)) with\n        k e\n      subst a\n      exact \u27e8k, Int.ofNat.inj ae\u27e9,\n    fun \u27e8k, e\u27e9 => Dvd.intro k <| by rw [e, Int.ofNat_mul]\u27e9\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\u2093.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\u2093'. -/\ntheorem coe_nat_dvd_left {n : \u2115} {z : \u2124} : (\u2191n : \u2124) \u2223 z \u2194 n \u2223 z.natAbs := by\n  rcases nat_abs_eq z with (eq | eq) <;> rw [Eq] <;> simp [\u2190 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\u2093.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\u2093'. -/\ntheorem coe_nat_dvd_right {n : \u2115} {z : \u2124} : z \u2223 (\u2191n : \u2124) \u2194 z.natAbs \u2223 n := by\n  rcases nat_abs_eq z with (eq | eq) <;> rw [Eq] <;> simp [\u2190 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\u2093'. -/\ntheorem le_of_dvd {a b : \u2124} (bpos : 0 < b) (H : a \u2223 b) : a \u2264 b :=\n  match a, b, eq_succ_of_zero_lt bpos, H with\n  | (m : \u2115), _, \u27e8n, rfl\u27e9, H => ofNat_le_ofNat_of_le <| Nat.le_of_dvd n.succ_pos <| coe_nat_dvd.1 H\n  | -[m+1], _, \u27e8n, rfl\u27e9, _ => 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\u2093'. -/\ntheorem eq_one_of_dvd_one {a : \u2124} (H : 0 \u2264 a) (H' : a \u2223 1) : a = 1 :=\n  match a, eq_ofNat_of_zero_le H, H' with\n  | _, \u27e8n, rfl\u27e9, 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 : \u2124} (H : 0 \u2264 a) (H' : a * b = 1) : a = 1 :=\n  eq_one_of_dvd_one H \u27e8b, H'.symm\u27e9\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 : \u2124} (H : 0 \u2264 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\u2093.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\u2093'. -/\ntheorem ofNat_dvd_of_dvd_natAbs {a : \u2115} : \u2200 {z : \u2124} (haz : a \u2223 z.natAbs), \u2191a \u2223 z\n  | Int.ofNat _, haz => Int.coe_nat_dvd.2 haz\n  | -[k+1], haz => by\n    change \u2191a \u2223 -(k + 1 : \u2124)\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\u2093.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\u2093'. -/\ntheorem dvd_natAbs_of_ofNat_dvd {a : \u2115} : \u2200 {z : \u2124} (haz : \u2191a \u2223 z), a \u2223 z.natAbs\n  | Int.ofNat _, haz => Int.coe_nat_dvd.1 (Int.dvd_natAbs.2 haz)\n  | -[k+1], haz =>\n    have haz' : (\u2191a : \u2124) \u2223 (\u2191(k + 1) : \u2124) := 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\u2093'. -/\ntheorem dvd_antisymm {a b : \u2124} (H1 : 0 \u2264 a) (H2 : 0 \u2264 b) : a \u2223 b \u2192 b \u2223 a \u2192 a = b :=\n  by\n  rw [\u2190 abs_of_nonneg H1, \u2190 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 (\u03b1 : Type u) := reader_t (ulift \u2115) rand \u03b1\n\nvariable (\u03b1 : 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 {\u03b1} (x : gen \u03b1) (i : \u2115) : io \u03b1 :=\nio.run_rand (x.run \u27e8i\u27e9)\n\nnamespace gen\n\nsection rand\n\n/-- Lift `random.random` to the `gen` monad. -/\ndef choose_any [random \u03b1] : gen \u03b1 :=\n\u27e8 \u03bb _, rand.random \u03b1 \u27e9\n\nvariables {\u03b1} [preorder \u03b1]\n\n/-- Lift `random.random_r` to the `gen` monad. -/\ndef choose [bounded_random \u03b1] (x y : \u03b1) (p : x \u2264 y) : gen (x .. y) :=\n\u27e8 \u03bb _, rand.random_r x y p \u27e9\n\nend rand\n\nopen nat (hiding choose)\n\n/-- Generate a `nat` example between `x` and `y`. -/\ndef choose_nat (x y : \u2115) (p : x \u2264 y) : gen (x .. y) :=\nchoose x y p\n\n/-- Generate a `nat` example between `x` and `y`. -/\ndef choose_nat' (x y : \u2115) (p : x < y) : gen (set.Ico x y) :=\nhave \u2200 i, x < i \u2192 i \u2264 y \u2192 i.pred < y,\n  from \u03bb i h\u2080 h\u2081,\n     show i.pred.succ \u2264 y,\n     by rwa succ_pred_eq_of_pos; apply lt_of_le_of_lt (nat.zero_le _) h\u2080,\nsubtype.map pred (\u03bb i (h : x+1 \u2264 i \u2227 i \u2264 y), \u27e8le_pred_of_lt h.1, this _ h.1 h.2\u27e9) <$>\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\u27e8 \u03bb \u03b1 x y, do\n  b \u2190 uliftable.up $ choose_any bool,\n  if b.down then x else y \u27e9\n\nvariable {\u03b1}\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 : \u2115 \u2192 gen \u03b1) : gen \u03b1 :=\n\u27e8 \u03bb \u27e8sz\u27e9, reader_t.run (cmd sz) \u27e8sz\u27e9 \u27e9\n\n/-- Apply a function to the size parameter. -/\ndef resize (f : \u2115 \u2192 \u2115) (cmd : gen \u03b1) : gen \u03b1 :=\n\u27e8 \u03bb \u27e8sz\u27e9, reader_t.run cmd \u27e8f sz\u27e9 \u27e9\n\n/-- Create `n` examples using `cmd`. -/\ndef vector_of : \u2200 (n : \u2115) (cmd : gen \u03b1), gen (vector \u03b1 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 \u03b1) : gen (list \u03b1) :=\nsized $ \u03bb sz, do\ndo \u27e8 n \u27e9 \u2190 uliftable.up $ choose_nat 0 (sz + 1) dec_trivial,\n   v \u2190 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 \u03b1)) (pos : 0 < xs.length) : gen \u03b1 := do\n\u27e8\u27e8n, h, h'\u27e9\u27e9 \u2190 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 \u03b1) (pos : 0 < xs.length) : gen \u03b1 := do\n\u27e8\u27e8n,h\u2080,h\u2081\u27e9\u27e9 \u2190 uliftable.up $ choose_nat' 0 xs.length pos,\npure $ list.nth_le xs n h\u2081\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 : \u03a0 (xs : list (\u2115+ \u00d7 gen \u03b1)) i, i < (xs.map (subtype.val \u2218 prod.fst)).sum \u2192 gen \u03b1\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 (\u2115+ \u00d7 gen \u03b1)) (pos : 0 < xs.length) : gen \u03b1 :=\nlet s := (xs.map (subtype.val \u2218 prod.fst)).sum in\nhave ha : 1 \u2264 s, from\n  (le_trans pos $\n    list.length_map (subtype.val \u2218 prod.fst) xs \u25b8\n      (list.length_le_sum_of_one_le _ (\u03bb i, by { simp, intros, assumption }))),\nhave 0 \u2264 s - 1, from le_tsub_of_add_le_right ha,\nuliftable.adapt_up gen.{0} gen.{u} (choose_nat 0 (s-1) this) $ \u03bb i,\nfreq_aux xs i.1 (by rcases i with \u27e8i,h\u2080,h\u2081\u27e9; rwa le_tsub_iff_right at h\u2081; exact ha)\n\n/-- Generate a random permutation of a given list. -/\ndef permutation_of {\u03b1 : Type u} : \u03a0 xs : list \u03b1, gen (subtype $ list.perm xs)\n| [] := pure \u27e8[], list.perm.nil \u27e9\n| (x :: xs) := do\n\u27e8xs',h\u27e9 \u2190 permutation_of xs,\n\u27e8\u27e8n,_,h'\u27e9\u27e9 \u2190 uliftable.up $ choose_nat 0 xs'.length dec_trivial,\npure \u27e8list.insert_nth n x xs',\n  list.perm.trans (list.perm.cons _ h)\n    (list.perm_insert_nth _ _ h').symm \u27e9\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 \u2227 Q \u2192 Q \u2227 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1]\n    (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : \u03b1 :=\n  fold lcm 1 f s\n\ntheorem lcm_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} : lcm s f = multiset.lcm (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem lcm_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {f : \u03b2 \u2192 \u03b1} : lcm \u2205 f = 1 :=\n  fold_empty\n\n@[simp] theorem lcm_dvd_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n    lcm s f \u2223 a \u2194 \u2200 (b : \u03b2), b \u2208 s \u2192 f b \u2223 a :=\n  sorry\n\ntheorem lcm_dvd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n    (\u2200 (b : \u03b2), b \u2208 s \u2192 f b \u2223 a) \u2192 lcm s f \u2223 a :=\n  iff.mpr lcm_dvd_iff\n\ntheorem dvd_lcm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {b : \u03b2} (hb : b \u2208 s) : f b \u2223 lcm s f :=\n  iff.mp lcm_dvd_iff (dvd_refl (lcm s f)) b hb\n\n@[simp] theorem lcm_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [DecidableEq \u03b2] {b : \u03b2} :\n    lcm (insert b s) f = lcm (f b) (lcm s f) :=\n  sorry\n\n@[simp] theorem lcm_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n    lcm (singleton b) f = coe_fn normalize (f b) :=\n  multiset.lcm_singleton\n\n@[simp] theorem normalize_lcm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} :\n    coe_fn normalize (lcm s f) = lcm s f :=\n  sorry\n\ntheorem lcm_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [DecidableEq \u03b2] :\n    lcm (s\u2081 \u222a s\u2082) f = lcm (lcm s\u2081 f) (lcm s\u2082 f) :=\n  sorry\n\ntheorem lcm_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (hs : s\u2081 = s\u2082)\n    (hfg : \u2200 (a : \u03b2), a \u2208 s\u2082 \u2192 f a = g a) : lcm s\u2081 f = lcm s\u2082 g :=\n  Eq._oldrec (fun (hfg : \u2200 (a : \u03b2), a \u2208 s\u2081 \u2192 f a = g a) => fold_congr hfg) hs hfg\n\ntheorem lcm_mono_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (h : \u2200 (b : \u03b2), b \u2208 s \u2192 f b \u2223 g b) :\n    lcm s f \u2223 lcm s g :=\n  lcm_dvd fun (b : \u03b2) (hb : b \u2208 s) => dvd_trans (h b hb) (dvd_lcm hb)\n\ntheorem lcm_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} (h : s\u2081 \u2286 s\u2082) :\n    lcm s\u2081 f \u2223 lcm s\u2082 f :=\n  lcm_dvd fun (b : \u03b2) (hb : b \u2208 s\u2081) => dvd_lcm (h hb)\n\n/-! ### gcd -/\n\n/-- Greatest common divisor of a finite set -/\ndef gcd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1] [gcd_monoid \u03b1]\n    (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : \u03b1 :=\n  fold gcd 0 f s\n\ntheorem gcd_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} : gcd s f = multiset.gcd (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem gcd_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {f : \u03b2 \u2192 \u03b1} : gcd \u2205 f = 0 :=\n  fold_empty\n\ntheorem dvd_gcd_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} : a \u2223 gcd s f \u2194 \u2200 (b : \u03b2), b \u2208 s \u2192 a \u2223 f b :=\n  sorry\n\ntheorem gcd_dvd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {b : \u03b2} (hb : b \u2208 s) : gcd s f \u2223 f b :=\n  iff.mp dvd_gcd_iff (dvd_refl (gcd s f)) b hb\n\ntheorem dvd_gcd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n    (\u2200 (b : \u03b2), b \u2208 s \u2192 a \u2223 f b) \u2192 a \u2223 gcd s f :=\n  iff.mpr dvd_gcd_iff\n\n@[simp] theorem gcd_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [DecidableEq \u03b2] {b : \u03b2} :\n    gcd (insert b s) f = gcd (f b) (gcd s f) :=\n  sorry\n\n@[simp] theorem gcd_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n    gcd (singleton b) f = coe_fn normalize (f b) :=\n  multiset.gcd_singleton\n\n@[simp] theorem normalize_gcd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} :\n    coe_fn normalize (gcd s f) = gcd s f :=\n  sorry\n\ntheorem gcd_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} [DecidableEq \u03b2] :\n    gcd (s\u2081 \u222a s\u2082) f = gcd (gcd s\u2081 f) (gcd s\u2082 f) :=\n  sorry\n\ntheorem gcd_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (hs : s\u2081 = s\u2082)\n    (hfg : \u2200 (a : \u03b2), a \u2208 s\u2082 \u2192 f a = g a) : gcd s\u2081 f = gcd s\u2082 g :=\n  Eq._oldrec (fun (hfg : \u2200 (a : \u03b2), a \u2208 s\u2081 \u2192 f a = g a) => fold_congr hfg) hs hfg\n\ntheorem gcd_mono_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (h : \u2200 (b : \u03b2), b \u2208 s \u2192 f b \u2223 g b) :\n    gcd s f \u2223 gcd s g :=\n  dvd_gcd fun (b : \u03b2) (hb : b \u2208 s) => dvd_trans (gcd_dvd hb) (h b hb)\n\ntheorem gcd_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s\u2081 : finset \u03b2} {s\u2082 : finset \u03b2} {f : \u03b2 \u2192 \u03b1} (h : s\u2081 \u2286 s\u2082) :\n    gcd s\u2082 f \u2223 gcd s\u2081 f :=\n  dvd_gcd fun (b : \u03b2) (hb : b \u2208 s\u2081) => gcd_dvd (h hb)\n\ntheorem gcd_eq_zero_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} :\n    gcd s f = 0 \u2194 \u2200 (x : \u03b2), x \u2208 s \u2192 f x = 0 :=\n  sorry\n\ntheorem gcd_eq_gcd_filter_ne_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1]\n    [nontrivial \u03b1] [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1}\n    [decidable_pred fun (x : \u03b2) => f x = 0] : gcd s f = gcd (filter (fun (x : \u03b2) => f x \u2260 0) s) f :=\n  sorry\n\ntheorem gcd_mul_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n    (gcd s fun (x : \u03b2) => a * f x) = coe_fn normalize a * gcd s f :=\n  sorry\n\ntheorem gcd_mul_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [comm_cancel_monoid_with_zero \u03b1] [nontrivial \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n    (gcd s fun (x : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b2] [integral_domain \u03b1]\n    [gcd_monoid \u03b1] {s : finset \u03b2} {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a : \u03b1}\n    (h : \u2200 (x : \u03b2), x \u2208 s \u2192 a \u2223 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n\nsection reflects_iso\nvariables {D : Type u\u2082} [category.{v\u2082} D]\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\n/--\nDefine what it means for a functor `F : C \u2964 D` to reflect isomorphisms: for any\nmorphism `f : A \u27f6 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 \u2964 D) : Prop :=\n(reflects : \u03a0 {A B : C} (f : A \u27f6 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 \u27f6 B) (F : C \u2964 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 \u2964 D) [full F] [faithful F] : reflects_isomorphisms F :=\n{ reflects := \u03bb X Y f i, by exactI\n  \u27e8\u27e8F.preimage (inv (F.map f)), \u27e8F.map_injective (by simp), F.map_injective (by simp)\u27e9\u27e9\u27e9 }\n\ninstance (F : C \u2964 D) (G : D \u2964 E) [reflects_isomorphisms F] [reflects_isomorphisms G] :\n  reflects_isomorphisms (F \u22d9 G) :=\n\u27e8\u03bb _ _ 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 }\u27e9\n\n@[priority 100]\ninstance reflects_isomorphisms_of_reflects_monomorphisms_of_reflects_epimorphisms [balanced C]\n  (F : C \u2964 D) [reflects_monomorphisms F] [reflects_epimorphisms F] : reflects_isomorphisms F :=\n{ reflects := \u03bb 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083 \n\nnamespace Mathlib\n\nnamespace category_theory.bifunctor\n\n\n@[simp] theorem map_id {C : Type u\u2081} {D : Type u\u2082} {E : Type u\u2083} [category C] [category D]\n    [category E] (F : C \u00d7 D \u2964 E) (X : C) (Y : D) : functor.map F (\ud835\udfd9, \ud835\udfd9) = \ud835\udfd9 :=\n  functor.map_id F (X, Y)\n\n@[simp] theorem map_id_comp {C : Type u\u2081} {D : Type u\u2082} {E : Type u\u2083} [category C] [category D]\n    [category E] (F : C \u00d7 D \u2964 E) (W : C) {X : D} {Y : D} {Z : D} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n    functor.map F (\ud835\udfd9, f \u226b g) = functor.map F (\ud835\udfd9, f) \u226b functor.map F (\ud835\udfd9, g) :=\n  sorry\n\n@[simp] theorem map_comp_id {C : Type u\u2081} {D : Type u\u2082} {E : Type u\u2083} [category C] [category D]\n    [category E] (F : C \u00d7 D \u2964 E) (X : C) (Y : C) (Z : C) (W : D) (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n    functor.map F (f \u226b g, \ud835\udfd9) = functor.map F (f, \ud835\udfd9) \u226b functor.map F (g, \ud835\udfd9) :=\n  sorry\n\n@[simp] theorem diagonal {C : Type u\u2081} {D : Type u\u2082} {E : Type u\u2083} [category C] [category D]\n    [category E] (F : C \u00d7 D \u2964 E) (X : C) (X' : C) (f : X \u27f6 X') (Y : D) (Y' : D) (g : Y \u27f6 Y') :\n    functor.map F (\ud835\udfd9, g) \u226b functor.map F (f, \ud835\udfd9) = functor.map F (f, g) :=\n  sorry\n\n@[simp] theorem diagonal' {C : Type u\u2081} {D : Type u\u2082} {E : Type u\u2083} [category C] [category D]\n    [category E] (F : C \u00d7 D \u2964 E) (X : C) (X' : C) (f : X \u27f6 X') (Y : D) (Y' : D) (g : Y \u27f6 Y') :\n    functor.map F (f, \ud835\udfd9) \u226b functor.map F (\ud835\udfd9, 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 \u03b2 \u03b3 : Sort _} {f : \u03b1 \u2192 \u03b2}\n\n/-- Evaluate a function at an argument. Useful if you want to talk about the partially applied\n  `Function.eval x : (\u2200 x, \u03b2 x) \u2192 \u03b2 x`. -/\n@[reducible, simp] def eval {\u03b2 : \u03b1 \u2192 Sort _} (x : \u03b1) (f : \u2200 x, \u03b2 x) : \u03b2 x := f x\n\nlemma const_def {y : \u03b2} : (\u03bb x : \u03b1 => y) = const \u03b1 y := rfl\n\n@[simp] lemma const_comp {f : \u03b1 \u2192 \u03b2} {c : \u03b3} : const \u03b2 c \u2218 f = const \u03b1 c := rfl\n\n@[simp] lemma comp_const {f : \u03b2 \u2192 \u03b3} {b : \u03b2} : f \u2218 const \u03b1 b = const \u03b1 (f b) := rfl\n\nlemma id_def : @id \u03b1 = \u03bb x => x := rfl\n\nlemma hfunext {\u03b1 \u03b1': Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {\u03b2' : \u03b1' \u2192 Sort v} {f : \u2200a, \u03b2 a} {f' : \u2200a, \u03b2' a}\n  (h\u03b1 : \u03b1 = \u03b1') (h : \u2200a a', HEq a a' \u2192 HEq (f a) (f' a')) : HEq f f' := by\n  subst h\u03b1\n  have : \u2200a, HEq (f a) (f' a) := \u03bb a => h a a (HEq.refl a)\n  have : \u03b2 = \u03b2' := 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 {\u03b2 : \u03b1 \u2192 Sort _} {f\u2081 f\u2082 : \u2200 (x : \u03b1), \u03b2 x} : f\u2081 = f\u2082 \u2194 (\u2200a, f\u2081 a = f\u2082 a) :=\nIff.intro (\u03bb h a => h \u25b8 rfl) funext\n\nprotected lemma bijective.injective {f : \u03b1 \u2192 \u03b2} (hf : bijective f) : injective f := hf.1\nprotected lemma bijective.surjective {f : \u03b1 \u2192 \u03b2} (hf : bijective f) : surjective f := hf.2\n\ntheorem injective.eq_iff (I : injective f) {a b : \u03b1} :\n  f a = f b \u2194 a = b :=\n\u27e8@I _ _, congr_arg f\u27e9\n\ntheorem injective.eq_iff' (I : injective f) {a b : \u03b1} {c : \u03b2} (h : f b = c) :\n  f a = c \u2194 a = b :=\nh \u25b8 I.eq_iff\n\nlemma injective.ne (hf : injective f) {a\u2081 a\u2082 : \u03b1} : a\u2081 \u2260 a\u2082 \u2192 f a\u2081 \u2260 f a\u2082 :=\nmt (\u03bb h => hf h)\n\nlemma injective.ne_iff (hf : injective f) {x y : \u03b1} : f x \u2260 f y \u2194 x \u2260 y :=\n\u27e8mt $ congr_arg f, hf.ne\u27e9\n\nlemma injective.ne_iff' (hf : injective f) {x y : \u03b1} {z : \u03b2} (h : f y = z) :\n  f x \u2260 z \u2194 x \u2260 y :=\nh \u25b8 hf.ne_iff\n\n/-- If the co-domain `\u03b2` of an injective function `f : \u03b1 \u2192 \u03b2` has decidable equality, then\nthe domain `\u03b1` also has decidable equality. -/\ndef injective.decidable_eq [DecidableEq \u03b2] (I : injective f) : DecidableEq \u03b1 :=\n\u03bb a b => decidable_of_iff _ I.eq_iff\n\nlemma injective.of_comp {g : \u03b3 \u2192 \u03b1} (I : injective (f \u2218 g)) : injective g :=\n\u03bb {x y} h => I $ show f (g x) = f (g y) from congr_arg f h\n\nlemma injective.of_comp_iff {f : \u03b1 \u2192 \u03b2} (hf : injective f) (g : \u03b3 \u2192 \u03b1) :\n  injective (f \u2218 g) \u2194 injective g :=\n\u27e8injective.of_comp, hf.comp\u27e9\n\nlemma injective.of_comp_iff' (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : bijective g) :\n  injective (f \u2218 g) \u2194 injective f :=\n\u27e8 \u03bb h x y => let \u27e8x', hx\u27e9 := hg.surjective x\n             let \u27e8y', hy\u27e9 := hg.surjective y\n             hx \u25b8 hy \u25b8 \u03bb hf => h hf \u25b8 rfl,\n  \u03bb h => h.comp hg.injective\u27e9\n\nlemma injective_of_subsingleton [Subsingleton \u03b1] (f : \u03b1 \u2192 \u03b2) :\n  injective f :=\n\u03bb {a b} ab => Subsingleton.elim _ _\n\nlemma injective.dite (p : \u03b1 \u2192 Prop) [DecidablePred p]\n  {f : {a : \u03b1 // p a} \u2192 \u03b2} {f' : {a : \u03b1 // \u00ac p a} \u2192 \u03b2}\n  (hf : injective f) (hf' : injective f')\n  (im_disj : \u2200 {x x' : \u03b1} {hx : p x} {hx' : \u00ac p x'}, f \u27e8x, hx\u27e9 \u2260 f' \u27e8x', hx'\u27e9) :\n  Function.injective (\u03bb x => if h : p x then f \u27e8x, h\u27e9 else f' \u27e8x, h\u27e9) :=\nby intros x\u2081 x\u2082 h\n   --TODO mathlib3 uses dsimp here\n   have hrw1 : (fun (x : \u03b1) => if h : p x then f \u27e8x, h\u27e9 else f' \u27e8x, h\u27e9) x\u2081 =\n                if h : p x\u2081 then f \u27e8x\u2081, h\u27e9 else f' \u27e8x\u2081, h\u27e9 := rfl\n   have hrw2 : (fun (x : \u03b1) => if h : p x then f \u27e8x, h\u27e9 else f' \u27e8x, h\u27e9) x\u2082 =\n               if h : p x\u2082 then f \u27e8x\u2082, h\u27e9 else f' \u27e8x\u2082, h\u27e9 := rfl\n   rw [hrw1, hrw2] at h\n   exact Decidable.byCases\n     (\u03bb (h\u2081 : p x\u2081) =>\n       Decidable.byCases\n         (\u03bb (h\u2082 : p x\u2082) => by rw [dif_pos h\u2081, dif_pos h\u2082] at h\n                              injection (hf h)\n                              assumption)\n         (\u03bb (h\u2082 : \u00ac p x\u2082) => by rw [dif_pos h\u2081, dif_neg h\u2082] at h\n                                exact (im_disj h).elim))\n     (\u03bb (h\u2081 : \u00ac p x\u2081) =>\n       Decidable.byCases\n         (\u03bb (h\u2082 : p x\u2082) => by rw [dif_neg h\u2081, dif_pos h\u2082] at h\n                              exact (im_disj h.symm).elim)\n         (\u03bb (h\u2082 : \u00ac p x\u2082) => by rw [dif_neg h\u2081, dif_neg h\u2082] at h\n                                injection (hf' h)\n                                assumption))\n\nlemma surjective.of_comp {g : \u03b3 \u2192 \u03b1} (S : surjective (f \u2218 g)) : surjective f :=\n\u03bb y => let \u27e8x, h\u27e9 := S y\n       \u27e8g x, h\u27e9\n\nlemma surjective.of_comp_iff (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : surjective g) :\n  surjective (f \u2218 g) \u2194 surjective f :=\n\u27e8surjective.of_comp, \u03bb h => h.comp hg\u27e9\n\nlemma surjective.of_comp_iff' {f : \u03b1 \u2192 \u03b2} (hf : bijective f) (g : \u03b3 \u2192 \u03b1) :\n  surjective (f \u2218 g) \u2194 surjective g :=\n\u27e8\u03bb h x => let \u27e8x', hx'\u27e9 := h (f x)\n          \u27e8x', hf.injective hx'\u27e9, hf.surjective.comp\u27e9\n\ninstance decidable_eq_pfun (p : Prop) [Decidable p] (\u03b1 : p \u2192 Type _)\n  [\u2200 hp, DecidableEq (\u03b1 hp)] : DecidableEq (\u2200hp, \u03b1 hp)\n| f, g => decidable_of_iff (\u2200 hp, f hp = g hp) funext_iff.symm\n\ntheorem surjective.forall {f : \u03b1 \u2192 \u03b2} (hf : surjective f) {p : \u03b2 \u2192 Prop} :\n  (\u2200 y, p y) \u2194 \u2200 x, p (f x) :=\n\u27e8\u03bb h x => h (f x),\n \u03bb h y => let \u27e8x, hx\u27e9 := hf y\n          hx \u25b8 h x\u27e9\n\ntheorem surjective.forall\u2082 {f : \u03b1 \u2192 \u03b2} (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2200 y\u2081 y\u2082, p y\u2081 y\u2082) \u2194 \u2200 x\u2081 x\u2082, p (f x\u2081) (f x\u2082) :=\nhf.forall.trans $ forall_congr' $ \u03bb x => hf.forall\n\ntheorem surjective.forall\u2083 {f : \u03b1 \u2192 \u03b2} (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2200 y\u2081 y\u2082 y\u2083, p y\u2081 y\u2082 y\u2083) \u2194 \u2200 x\u2081 x\u2082 x\u2083, p (f x\u2081) (f x\u2082) (f x\u2083) :=\nhf.forall.trans $ forall_congr' $ \u03bb x => hf.forall\u2082\n\ntheorem surjective.exists {f : \u03b1 \u2192 \u03b2} (hf : surjective f) {p : \u03b2 \u2192 Prop} :\n  (\u2203 y, p y) \u2194 \u2203 x, p (f x) :=\n\u27e8\u03bb \u27e8y, hy\u27e9 => let \u27e8x, hx\u27e9 := hf y\n              \u27e8x, hx.symm \u25b8 hy\u27e9,\n \u03bb \u27e8x, hx\u27e9 => \u27e8f x, hx\u27e9\u27e9\n\ntheorem surjective.exists\u2082 {f : \u03b1 \u2192 \u03b2} (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2203 y\u2081 y\u2082, p y\u2081 y\u2082) \u2194 \u2203 x\u2081 x\u2082, p (f x\u2081) (f x\u2082) :=\nhf.exists.trans $ exists_congr $ \u03bb x => hf.exists\n\ntheorem surjective.exists\u2083 {f : \u03b1 \u2192 \u03b2} (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2203 y\u2081 y\u2082 y\u2083, p y\u2081 y\u2082 y\u2083) \u2194 \u2203 x\u2081 x\u2082 x\u2083, p (f x\u2081) (f x\u2082) (f x\u2083) :=\nhf.exists.trans $ exists_congr $ \u03bb x => hf.exists\u2082\n\nlemma bijective_iff_exists_unique (f : \u03b1 \u2192 \u03b2) : bijective f \u2194\n  \u2200 b : \u03b2, \u2203! (a : \u03b1), f a = b :=\n\u27e8 \u03bb hf b => let \u27e8a, ha\u27e9 := hf.surjective b\n            \u27e8a, ha, \u03bb a' ha' => hf.injective (ha'.trans ha.symm)\u27e9,\n  \u03bb he => \u27e8\n    \u03bb {a a'} h => unique_of_exists_unique (he (f a')) h rfl,\n    \u03bb b => ExistsUnique.exists (he b) \u27e9\u27e9\n\n/-- Shorthand for using projection notation with `function.bijective_iff_exists_unique`. -/\nlemma bijective.exists_unique {f : \u03b1 \u2192 \u03b2} (hf : bijective f) (b : \u03b2) : \u2203! (a : \u03b1), f a = b :=\n(bijective_iff_exists_unique f).mp hf b\n\nlemma bijective.of_comp_iff (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : bijective g) :\n  bijective (f \u2218 g) \u2194 bijective f :=\nand_congr (injective.of_comp_iff' _ hg) (surjective.of_comp_iff _ hg.surjective)\n\nlemma bijective.of_comp_iff' {f : \u03b1 \u2192 \u03b2} (hf : bijective f) (g : \u03b3 \u2192 \u03b1) :\n  Function.bijective (f \u2218 g) \u2194 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 `\u03b1`\nto `Set \u03b1`. -/\ntheorem cantor_surjective {\u03b1} (f : \u03b1 \u2192 Set \u03b1) : \u00ac Function.surjective f\n| h => let \u27e8D, e\u27e9 := h (\u03bb a => \u00ac 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 \u03b1` to `\u03b1`. -/\ntheorem cantor_injective {\u03b1 : Type _} (f : (Set \u03b1) \u2192 \u03b1) :\n  \u00ac Function.injective f\n| i => cantor_surjective (\u03bb a b => \u2200 U, a = f U \u2192 U b) $\n       RightInverse.surjective\n         (\u03bb U => funext $ \u03bb a => propext \u27e8\u03bb h => h U rfl, \u03bb h' U' e => i e \u25b8 h'\u27e9)\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 Option \u03b1) : Prop :=\n\u2200 x y, g y = some x \u2194 f x = y\n\ntheorem is_partial_inv_left {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g) (x) : g (f x) = some x :=\n(H _ _).2 rfl\n\ntheorem injective_of_partial_inv {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g) : injective f :=\n\u03bb {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 {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g)\n (x y b) (h\u2081 : g x = some b) (h\u2082 : g y = some b) : x = y :=\n((H _ _).1 h\u2081).symm.trans ((H _ _).1 h\u2082)\n\ntheorem LeftInverse.comp_eq_id {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : LeftInverse f g) : f \u2218 g = id :=\nfunext h\n\ntheorem LeftInverse_iff_comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} : LeftInverse f g \u2194 f \u2218 g = id :=\n\u27e8LeftInverse.comp_eq_id, congr_fun\u27e9\n\ntheorem RightInverse.comp_eq_id {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : RightInverse f g) : g \u2218 f = id :=\nfunext h\n\ntheorem RightInverse_iff_comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} : RightInverse f g \u2194 g \u2218 f = id :=\n\u27e8RightInverse.comp_eq_id, congr_fun\u27e9\n\ntheorem LeftInverse.comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} {h : \u03b2 \u2192 \u03b3} {i : \u03b3 \u2192 \u03b2}\n  (hf : LeftInverse f g) (hh : LeftInverse h i) : LeftInverse (h \u2218 f) (g \u2218 i) :=\n\u03bb a => show h (f (g (i a))) = a by rw [hf (i a), hh a]\n\ntheorem RightInverse.comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} {h : \u03b2 \u2192 \u03b3} {i : \u03b3 \u2192 \u03b2}\n  (hf : RightInverse f g) (hh : RightInverse h i) : RightInverse (h \u2218 f) (g \u2218 i) :=\nLeftInverse.comp hh hf\n\ntheorem LeftInverse.RightInverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : LeftInverse g f) :\n  RightInverse f g := h\n\ntheorem RightInverse.LeftInverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : RightInverse g f) :\n  LeftInverse f g := h\n\ntheorem LeftInverse.surjective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : LeftInverse f g) :\n  surjective f :=\nh.RightInverse.surjective\n\ntheorem RightInverse.injective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : RightInverse f g) :\n  injective f :=\nh.LeftInverse.injective\n\ntheorem LeftInverse.eq_RightInverse {f : \u03b1 \u2192 \u03b2} {g\u2081 g\u2082 : \u03b2 \u2192 \u03b1} (h\u2081 : LeftInverse g\u2081 f)\n  (h\u2082 : Function.RightInverse g\u2082 f) :\n  g\u2081 = g\u2082 := by\n  have h\u2083 : g\u2081 = g\u2081 \u2218 f \u2218 g\u2082 := by rw [h\u2082.comp_eq_id, comp.right_id]\n  have h\u2084 : g\u2081 \u2218 f \u2218 g\u2082 = g\u2082 := by rw [\u2190 comp.assoc, h\u2081.comp_eq_id, comp.left_id]\n  rwa [\u2190h\u2084]\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (b : \u03b2) : Option \u03b1 :=\nif h : \u2203 a, f a = b then some (Classical.choose h) else none\n\ntheorem partial_inv_of_injective {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} (I : injective f) :\n  is_partial_inv f (partial_inv f)\n| a, b =>\n\u27e8\u03bb h => have hpi: partial_inv f b = if h : \u2203 a, f a = b then some (Classical.choose h) else none := rfl\n        if h' : \u2203 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 \u03bb e => e \u25b8 have h : \u2203 a', f a' = f a := \u27e8_, rfl\u27e9\n            (dif_pos h).trans (congr_arg _ (I $ Classical.choose_spec h))\u27e9\n\ntheorem partial_inv_left {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} (I : injective f) : \u2200 x, partial_inv f (f x) = some x :=\nis_partial_inv_left (partial_inv_of_injective I)\n\nend\n\nsection inv_fun\nvariable {\u03b1 : Type u} [n : Nonempty \u03b1] {\u03b2 : Sort v} {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} {a : \u03b1} {b : \u03b2}\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 : \u03b1 \u2192 \u03b2) (s : Set \u03b1) (b : \u03b2) : \u03b1 :=\nif h : \u2203a, a \u2208 s \u2227 f a = b then Classical.choose h else Classical.choice n\n\ntheorem inv_fun_on_pos (h : \u2203a\u2208s, f a = b) : inv_fun_on f s b \u2208 s \u2227 f (inv_fun_on f s b) = b :=\nby have h1 : inv_fun_on f s b =\n     if h : \u2203a, a \u2208 s \u2227 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 : \u2203a\u2208s, f a = b) : inv_fun_on f s b \u2208 s := (inv_fun_on_pos h).left\n\ntheorem inv_fun_on_eq (h : \u2203a\u2208s, f a = b) : f (inv_fun_on f s b) = b := (inv_fun_on_pos h).right\n\ntheorem inv_fun_on_eq' (h : \u2200 x \u2208 s, \u2200 y \u2208 s, f x = f y \u2192 x = y) (ha : a \u2208 s) :\n  inv_fun_on f s (f a) = a :=\nhave : \u2203a'\u2208s, f a' = f a := \u27e8a, ha, rfl\u27e9\nh _ (inv_fun_on_mem this) _ ha (inv_fun_on_eq this)\n\ntheorem inv_fun_on_neg (h : \u00ac \u2203a\u2208s, f a = b) : inv_fun_on f s b = Classical.choice n :=\nby have h1 : inv_fun_on f s b =\n     if h : \u2203a, a \u2208 s \u2227 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 : \u03b1 \u2192 \u03b2) : \u03b2 \u2192 \u03b1 := inv_fun_on f Set.univ\n\ntheorem inv_fun_eq (h : \u2203a, f a = b) : f (inv_fun f b) = b :=\ninv_fun_on_eq $ let \u27e8a, ha\u27e9 := h\n                \u27e8a, trivial, ha\u27e9\n\nlemma inv_fun_neg (h : \u00ac \u2203 a, f a = b) : inv_fun f b = Classical.choice n :=\nby refine inv_fun_on_neg (mt ?_ h); exact \u03bb \u27e8a, _, ha\u27e9 => \u27e8a, ha\u27e9\n\ntheorem inv_fun_eq_of_injective_of_RightInverse {g : \u03b2 \u2192 \u03b1}\n  (hf : injective f) (hg : RightInverse g f) : inv_fun f = g :=\nfunext $ \u03bb b => hf (by rw [hg b]\n                       exact inv_fun_eq \u27e8g b, hg b\u27e9)\n\nlemma RightInverse_inv_fun (hf : surjective f) : RightInverse (inv_fun f) f :=\n\u03bb b => inv_fun_eq $ hf b\n\nlemma LeftInverse_inv_fun (hf : injective f) : LeftInverse (inv_fun f) f :=\n\u03bb b => have : f (inv_fun f (f b)) = f b := inv_fun_eq \u27e8b, rfl\u27e9\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 \u2218 f = id := funext $ LeftInverse_inv_fun hf\n\nend inv_fun\n\nsection inv_fun\nvariable {\u03b1 : Type u} [i : Nonempty \u03b1] {\u03b2 : Sort v} {f : \u03b1 \u2192 \u03b2}\n\nlemma injective.has_LeftInverse (hf : injective f) : has_LeftInverse f :=\n\u27e8inv_fun f, LeftInverse_inv_fun hf\u27e9\n\nlemma injective_iff_has_LeftInverse : injective f \u2194 has_LeftInverse f :=\n\u27e8injective.has_LeftInverse, has_LeftInverse.injective\u27e9\n\nend inv_fun\n\nsection surj_inv\nvariable {\u03b1 : Sort u} {\u03b2 : Sort v} {f : \u03b1 \u2192 \u03b2}\n\n/-- The inverse of a surjective function. (Unlike `inv_fun`, this does not require\n  `\u03b1` to be inhabited.) -/\nnoncomputable def surj_inv {f : \u03b1 \u2192 \u03b2} (h : surjective f) (b : \u03b2) : \u03b1 := 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\u27e8_, RightInverse_surj_inv hf\u27e9\n\nlemma surjective_iff_has_RightInverse : surjective f \u2194 has_RightInverse f :=\n\u27e8surjective.has_RightInverse, has_RightInverse.surjective\u27e9\n\nlemma bijective_iff_has_inverse : bijective f \u2194 \u2203 g, LeftInverse g f \u2227 RightInverse g f :=\n\u27e8\u03bb hf =>  \u27e8_, LeftInverse_surj_inv hf, RightInverse_surj_inv hf.2\u27e9,\n \u03bb \u27e8g, gl, gr\u27e9 => \u27e8gl.injective,  gr.surjective\u27e9\u27e9\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 \u03b1] [Subsingleton \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  surjective f :=\n\u03bb y => let \u27e8a\u27e9 := na; \u27e8a, Subsingleton.elim _ _\u27e9\n\nend surj_inv\n\nsection update\nvariable {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {\u03b1' : Sort w} [DecidableEq \u03b1] [DecidableEq \u03b1']\n\n/-- Replacing the value of a function at a given point by a given value. -/\ndef update (f : \u2200a, \u03b2 a) (a' : \u03b1) (v : \u03b2 a') (a : \u03b1) : \u03b2 a :=\nif h : a = a' then Eq.rec (motive := \u03bb a _ => \u03b2 a) v h.symm else f a\n\n/-- On non-dependent functions, `function.update` can be expressed as an `ite` -/\nlemma update_apply {\u03b2 : Sort _} (f : \u03b1 \u2192 \u03b2) (a' : \u03b1) (b : \u03b2) (a : \u03b1) :\n  update f a' b a = if a = a' then b else f a :=\nby have h2 : (h : a = a') \u2192 Eq.rec (motive := \u03bb a b => \u03b2) b h.symm = b :=\n     by intro h\n        rw [eq_rec_constant]\n   have h3 : (\u03bb h : a = a' => Eq.rec (motive := \u03bb a b => \u03b2) b h.symm) =\n             (\u03bb _ : a = a' =>  b) := funext h2\n   let f := \u03bb x => dite (a = a') x (\u03bb (_: \u00ac a = a') => (f a))\n   exact congrArg f h3\n\n@[simp] lemma update_same (a : \u03b1) (v : \u03b2 a) (f : \u2200a, \u03b2 a) : update f a v a = v :=\ndif_pos rfl\n\nlemma update_injective (f : \u2200a, \u03b2 a) (a' : \u03b1) : 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' : \u03b1} (h : a \u2260 a') (v : \u03b2 a') (f : \u2200a, \u03b2 a) :\n  update f a' v a = f a :=\ndif_neg h\n\nlemma forall_update_iff (f : \u2200a, \u03b2 a) {a : \u03b1} {b : \u03b2 a} (p : \u2200a, \u03b2 a \u2192 Prop) :\n  (\u2200 x, p x (update f a b x)) \u2194 p a b \u2227 \u2200 x, x \u2260 a \u2192 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 \u27e8h1, ?_\u27e9\n      intro x hx\n      have h3 := update_noteq hx b f\n      rw [\u2190h3]\n      exact h x)\n  (by intro \u27e8hp,h\u27e9 x\n      have h1 : x = a \u2228 x \u2260 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 : \u03b1} {b : \u03b2 a} {f g : \u2200 a, \u03b2 a} :\n  update f a b = g \u2194 b = g a \u2227 \u2200 x, x \u2260 a -> f x = g x :=\nfunext_iff.trans $ forall_update_iff _ (\u03bb x y => y = g x)\n\nlemma eq_update_iff {a : \u03b1} {b : \u03b2 a} {f g : \u2200 a, \u03b2 a} :\n  g = update f a b \u2194 g a = b \u2227 \u2200 x, x \u2260 a -> g x = f x :=\nfunext_iff.trans $ forall_update_iff _ (\u03bb x y => g x = y)\n\n@[simp] lemma update_eq_self (a : \u03b1) (f : \u2200a, \u03b2 a) : update f a (f a) = f :=\nupdate_eq_iff.2 \u27e8rfl, \u03bb _ _ => rfl\u27e9\n\nlemma update_comp_eq_of_forall_ne' {\u03b1'} (g : \u2200 a, \u03b2 a) {f : \u03b1' \u2192 \u03b1} {i : \u03b1} (a : \u03b2 i)\n  (h : \u2200 x, f x \u2260 i) :\n  (\u03bb j => (update g i a) (f j)) = (\u03bb j => g (f j)) :=\nfunext $ \u03bb x => update_noteq (h _) _ _\n\n/-- Non-dependent version of `function.update_comp_eq_of_forall_ne'` -/\nlemma update_comp_eq_of_forall_ne {\u03b1 \u03b2 : Sort _} (g : \u03b1' \u2192 \u03b2) {f : \u03b1 \u2192 \u03b1'} {i : \u03b1'} (a : \u03b2)\n  (h : \u2200 x, f x \u2260 i) :\n  (update g i a) \u2218 f = g \u2218 f :=\nupdate_comp_eq_of_forall_ne' g a h\n\nlemma update_comp_eq_of_injective' (g : \u2200a, \u03b2 a) {f : \u03b1' \u2192 \u03b1} (hf : Function.injective f)\n  (i : \u03b1') (a : \u03b2 (f i)) :\n  (\u03bb j => update g (f i) a (f j)) = update (\u03bb i => g (f i)) i a :=\neq_update_iff.2 \u27e8update_same _ _ _, \u03bb j hj => update_noteq (hf.ne hj) _ _\u27e9\n\n/-- Non-dependent version of `function.update_comp_eq_of_injective'` -/\nlemma update_comp_eq_of_injective {\u03b2 : Sort _} (g : \u03b1' \u2192 \u03b2) {f : \u03b1 \u2192 \u03b1'}\n  (hf : Function.injective f) (i : \u03b1) (a : \u03b2) :\n  (Function.update g (f i) a) \u2218 f = Function.update (g \u2218 f) i a :=\nupdate_comp_eq_of_injective' g hf i a\n\nlemma apply_update {\u03b9 : Sort _} [DecidableEq \u03b9] {\u03b1 \u03b2 : \u03b9 \u2192 Sort _}\n  (f : \u2200i, \u03b1 i \u2192 \u03b2 i) (g : \u2200i, \u03b1 i) (i : \u03b9) (v : \u03b1 i) (j : \u03b9) :\n  f j (update g i v j) = update (\u03bb 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 {\u03b1' : Sort _} {\u03b2 : Sort _} (f : \u03b1' \u2192 \u03b2) (g : \u03b1 \u2192 \u03b1') (i : \u03b1) (v : \u03b1') :\n  f \u2218 (update g i v) = update (f \u2218 g) i (f v) :=\nfunext $ apply_update _ _ _ _\n\ntheorem update_comm {\u03b1} [DecidableEq \u03b1] {\u03b2 : \u03b1 \u2192 Sort _}\n  {a b : \u03b1} (h : a \u2260 b) (v : \u03b2 a) (w : \u03b2 b) (f : \u2200a, \u03b2 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\u2081 : c = b <;> by_cases h\u2082 : c = a\n   \u00b7 rw [dif_pos h\u2081, dif_pos h\u2082]\n     cases h (h\u2082.symm.trans h\u2081)\n   \u00b7 rw [dif_pos h\u2081, dif_pos h\u2081, dif_neg h\u2082]\n   \u00b7 rw [dif_neg h\u2081, dif_neg h\u2081, dif_pos h\u2082]\n   \u00b7 rw [dif_neg h\u2081, dif_neg h\u2081, dif_neg h\u2082]\n\n@[simp] theorem update_idem {\u03b1} [DecidableEq \u03b1] {\u03b2 : \u03b1 \u2192 Sort _}\n  {a : \u03b1} (v w : \u03b2 a) (f : \u2200a, \u03b2 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 {\u03b1 \u03b2 \u03b3 : Type _} {f : \u03b1 \u2192 \u03b2}\n\n/-- `extend f g e'` extends a function `g : \u03b1 \u2192 \u03b3`\nalong a function `f : \u03b1 \u2192 \u03b2` to a function `\u03b2 \u2192 \u03b3`,\nby using the values of `g` on the range of `f`\nand the values of an auxiliary function `e' : \u03b2 \u2192 \u03b3` elsewhere.\n\nMostly useful when `f` is injective. -/\nnoncomputable def extend (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) : \u03b2 \u2192 \u03b3 :=\n\u03bb b => if h : \u2203 a, f a = b then g (Classical.choose h) else e' b\n\nlemma extend_def (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (b : \u03b2) [hd : Decidable (\u2203 a, f a = b)] :\n  extend f g e' b = if h : \u2203 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 : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (a : \u03b1) :\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 : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) :\n  extend f g e' \u2218 f = g :=\nfunext $ \u03bb a => extend_apply hf g e' a\n\nend extend\n\nlemma uncurry_def {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : uncurry f = (\u03bbp => f p.1 p.2) :=\nrfl\n\n@[simp] lemma uncurry_apply_pair {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (x : \u03b1) (y : \u03b2) :\n  uncurry f (x, y) = f x y :=\nrfl\n\n@[simp] lemma curry_apply {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) (x : \u03b1) (y : \u03b2) :\n  curry f x y = f (x, y) :=\nrfl\n\nsection bicomp\nvariable {\u03b1 \u03b2 \u03b3 \u03b4 \u03b5 : 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 : \u03b3 \u2192 \u03b4 \u2192 \u03b5) (g : \u03b1 \u2192 \u03b3) (h : \u03b2 \u2192 \u03b4) (a b) :=\nf (g a) (h b)\n\n/-- Compose an unary function `f` with a binary function `g`. -/\ndef bicompr (f : \u03b3 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a b) :=\nf (g a b)\n\n-- Suggested local notation:\nlocal notation f  \" \u2218\u2082 \" g => bicompr f g\n\nlemma uncurry_bicompr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (g : \u03b3 \u2192 \u03b4) :\n  uncurry (g \u2218\u2082 f) = (g \u2218 uncurry f) := rfl\n\nlemma uncurry_bicompl (f : \u03b3 \u2192 \u03b4 \u2192 \u03b5) (g : \u03b1 \u2192 \u03b3) (h : \u03b2 \u2192 \u03b4) :\n  uncurry (bicompl f g h) = (uncurry f) \u2218 (Prod.map g h) :=\nby ext \u27e8x, y\u27e9; exact rfl\n\nend bicomp\n\nsection uncurry\n\n/-- Records a way to turn an element of `\u03b1` into a function from `\u03b2` to `\u03b3`. The most generic use\nis to recursively uncurry. For instance `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4` will be turned into\n`\u21bff : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3 \u2192 \u03b4`. One can also add instances for bundled maps. -/\nclass HasUncurry (\u03b1 : Type u) (\u03b2 : outParam (Type v)) (\u03b3 : outParam (Type w)) where\n  uncurry : \u03b1 \u2192 (\u03b2 \u2192 \u03b3)\n\n/- Uncurrying operator. The most generic use is to recursively uncurry. For instance\n`f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4` will be turned into `\u21bff : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3 \u2192 \u03b4`. One can also add instances\nfor bundled maps. -/\nnotation:max \"\u21bf\" x:max => HasUncurry.uncurry x\n\ninstance HasUncurry_base : HasUncurry (\u03b1 \u2192 \u03b2) \u03b1 \u03b2 := \u27e8id\u27e9\n\ninstance HasUncurry_induction [HasUncurry \u03b2 \u03b3 \u03b4] : HasUncurry (\u03b1 \u2192 \u03b2) (\u03b1 \u00d7 \u03b3) \u03b4 :=\n\u27e8\u03bb f p => \u21bf(f p.1) p.2\u27e9\n\nend uncurry\n\n/-- A function is involutive, if `f \u2218 f = id`. -/\ndef involutive {\u03b1} (f : \u03b1 \u2192 \u03b1) : Prop := \u2200 x, f (f x) = x\n\nlemma involutive_iff_iter_2_eq_id {\u03b1} {f : \u03b1 \u2192 \u03b1} : involutive f \u2194 (f^[2] = id) :=\nfunext_iff.symm\n\nnamespace involutive\nvariable {\u03b1 : Sort u} {f : \u03b1 \u2192 \u03b1} (h : involutive f)\n\n@[simp]\nlemma comp_self : f \u2218 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 := \u03bb x => \u27e8f x, h x\u27e9\nprotected lemma bijective : bijective f := \u27e8h.injective, h.surjective\u27e9\n\n/-- Involuting an `ite` of an involuted value `x : \u03b1` negates the `Prop` condition in the `ite`. -/\nprotected lemma ite_not (P : Prop) [Decidable P] (x : \u03b1) :\n  f (ite P x (f x)) = ite (\u00ac 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 : \u03b1} : f x = y \u2194 x = f y :=\nFunction.injective.eq_iff' (involutive.injective h) (h y)\n\nend involutive\n\n/-- The property of a binary function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` being injective.\nMathematically this should be thought of as the corresponding function `\u03b1 \u00d7 \u03b2 \u2192 \u03b3` being injective.\n-/\n@[reducible] def injective2 {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : Prop :=\n\u2200 {a\u2081 a\u2082 b\u2081 b\u2082}, f a\u2081 b\u2081 = f a\u2082 b\u2082 \u2192 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082\n\nnamespace injective2\nvariable {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n\nprotected lemma left (hf : injective2 f) {a\u2081 a\u2082 b\u2081 b\u2082} (h : f a\u2081 b\u2081 = f a\u2082 b\u2082) : a\u2081 = a\u2082 :=\n(hf h).1\n\nprotected lemma right (hf : injective2 f) {a\u2081 a\u2082 b\u2081 b\u2082} (h : f a\u2081 b\u2081 = f a\u2082 b\u2082) : b\u2081 = b\u2082 :=\n(hf h).2\n\nlemma eq_iff (hf : injective2 f) {a\u2081 a\u2082 b\u2081 b\u2082} : f a\u2081 b\u2081 = f a\u2082 b\u2082 \u2194 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082 :=\n\u27e8\u03bb h => hf h, \u03bb\u27e8h1, h2\u27e9 => congr_arg2 f h1 h2\u27e9\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 `\u03b1` is a proposition, in which case `f` is necessarily a\nconstant function, so that `sometimes f = f a` for all `a`. -/\nnoncomputable def sometimes {\u03b1 \u03b2} [Nonempty \u03b2] (f : \u03b1 \u2192 \u03b2) : \u03b2 :=\nif h : Nonempty \u03b1 then f (Classical.choice h) else Classical.choice \u2039_\u203a\n\ntheorem sometimes_eq {p : Prop} {\u03b1} [Nonempty \u03b1] (f : p \u2192 \u03b1) (a : p) : sometimes f = f a :=\ndif_pos \u27e8a\u27e9\n\ntheorem sometimes_spec {p : Prop} {\u03b1} [Nonempty \u03b1]\n  (P : \u03b1 \u2192 Prop) (f : p \u2192 \u03b1) (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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Sort v} (s : Set \u03b1) (f g : \u2200i, \u03b2 i)\n  [\u2200j, Decidable (j \u2208 s)] :\n  \u2200i, \u03b2 i :=\n\u03bbi => if i \u2208 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 {\u03b1 \u03b2 : Type _} (A : Set (\u03b1 \u2192 \u03b2)) : Prop :=\n\u2200 {x y : \u03b1}, x \u2260 y \u2192 \u2203 f \u2208 A, (f x : \u03b2) \u2260 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\u00f6nne, 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 \u2192 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 \u2264 B` mathematically means that `B.proj` factors through `A.proj`.\nThe top element `\u22a4` is the trivial quotient, meaning that every element of `X` is collapsed\nto a point. Given `h : A \u2264 B`, the map `A \u2192 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 `\u22a5` 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 \u2192 B`.  If\n`cond : DiscreteQuotient.LeComap h A B`, the function `A \u2192 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\u2082, 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 {\u03b1 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 : \u2200 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  | \u27e8_, _\u27e9, \u27e8_, _\u27e9, _ => 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 := \u27e8fun x y => x \u2208 A \u2194 y \u2208 A, fun _ => Iff.rfl,  Iff.symm,  Iff.trans\u27e9\n  isOpen_setOf_rel x := by by_cases hx : x \u2208 A <;> simp [Setoid.Rel, hx, h.1, h.2, \u2190 compl_setOf]\n#align discrete_quotient.of_clopen DiscreteQuotient.ofClopen\n\ntheorem refl : \u2200 x, S.Rel x x := S.refl'\n#align discrete_quotient.refl DiscreteQuotient.refl\n\ntheorem symm (x y : X) : S.Rel x y \u2192 S.Rel y x := S.symm'\n#align discrete_quotient.symm DiscreteQuotient.symm\n\ntheorem trans (x y z : X) : S.Rel x y \u2192 S.Rel y z \u2192 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  \u27e8fun S => Quotient S.toSetoid\u27e9\n\ninstance : TopologicalSpace S :=\n  inferInstanceAs (TopologicalSpace (Quotient S.toSetoid))\n\n/-- The projection from `X` to the given discrete quotient. -/\ndef proj : X \u2192 S := Quotient.mk''\n#align discrete_quotient.proj DiscreteQuotient.proj\n\ntheorem fiber_eq (x : X) : S.proj \u207b\u00b9' {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 [\u2190 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 \u207b\u00b9' 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 \u207b\u00b9' 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 \u207b\u00b9' 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 [\u2190 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  \u27e8fun S\u2081 S\u2082 => \u27e8S\u2081.1 \u2293 S\u2082.1, fun x => (S\u2081.2 x).inter (S\u2082.2 x)\u27e9\u27e9\n\ninstance : SemilatticeInf (DiscreteQuotient X) :=\n  Injective.semilatticeInf toSetoid toSetoid_injective fun _ _ => rfl\n\ninstance : OrderTop (DiscreteQuotient X) where\n  top := \u27e8\u22a4, fun _ => isOpen_univ\u27e9\n  le_top a := by tauto\n\ninstance : Inhabited (DiscreteQuotient X) := \u27e8\u22a4\u27e9\n\ninstance inhabitedQuotient [Inhabited X] : Inhabited S := \u27e8S.proj default\u27e9\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 \u2039_\u203a\n\n-- porting note: new lemma\n/-- The quotient by `\u22a4 : DiscreteQuotient X` is a `Subsingleton`. -/\ninstance : Subsingleton (\u22a4 : DiscreteQuotient X) where\n  allEq := by rintro \u27e8_\u27e9 \u27e8_\u27e9; 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 \u2264 B) : A.comap f \u2264 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 \u2264 B) : A \u2192 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 \u27e8\u27e9\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\u2081 : A \u2264 B) (h\u2082 : B \u2264 C) (x : A) : ofLe h\u2082 (ofLe h\u2081 x) = ofLe (h\u2081.trans h\u2082) x :=\n  by\n  rcases x with \u27e8\u27e9\n  rfl\n#align discrete_quotient.of_le_of_le DiscreteQuotient.ofLe_ofLe\n\n@[simp]\ntheorem ofLe_comp_ofLe (h\u2081 : A \u2264 B) (h\u2082 : B \u2264 C) : ofLe h\u2082 \u2218 ofLe h\u2081 = ofLe (le_trans h\u2081 h\u2082) :=\n  funext <| ofLe_ofLe _ _\n#align discrete_quotient.of_le_comp_of_le DiscreteQuotient.ofLe_comp_ofLe\n\ntheorem ofLe_continuous (h : A \u2264 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 \u2264 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 \u2264 B) : ofLe h \u2218 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, \u2190 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 \u25b8 mem_connectedComponent\n\n@[simp]\ntheorem proj_bot_eq [LocallyConnectedSpace X] {x y : X} :\n    proj \u22a5 x = proj \u22a5 y \u2194 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 \u22a5 x = proj \u22a5 y \u2194 x = y := by simp\n#align discrete_quotient.proj_bot_inj DiscreteQuotient.proj_bot_inj\n\ntheorem proj_bot_injective [DiscreteTopology X] : Injective (\u22a5 : 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 (\u22a5 : DiscreteQuotient X).proj :=\n  \u27e8proj_bot_injective, proj_surjective _\u27e9\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 \u2264 B.comap f`. Mathematically this means that `f` descends to a morphism `A \u2192 B`. -/\ndef LeComap : Prop :=\n  A \u2264 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' \u2194 A \u2264 A' :=\n  Iff.rfl\n#align discrete_quotient.le_comap_id_iff DiscreteQuotient.leComap_id_iff\n\ntheorem LeComap.comp : LeComap g B C \u2192 LeComap f A B \u2192 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' \u2264 A) (hB : B \u2264 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 \u2192 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 \u2218 A.proj = B.proj \u2218 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 \u27e8\u27e9; 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 \u2218 map f h2 := by\n  ext \u27e8\u27e9\n  rfl\n#align discrete_quotient.map_comp DiscreteQuotient.map_comp\n\n@[simp]\ntheorem ofLe_map (cond : LeComap f A B) (h : B \u2264 B') (a : A) :\n    ofLe h (map f cond a) = map f (cond.mono le_rfl h) a := by\n  rcases a with \u27e8\u27e9\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 \u2264 B') :\n    ofLe h \u2218 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' \u2264 A) (c : A') :\n    map f cond (ofLe h c) = map f (cond.mono h le_rfl) c := by\n  rcases c with \u27e8\u27e9\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' \u2264 A) :\n    map f cond \u2218 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 \u2264 B) (a : A) :\n    A.proj \u207b\u00b9' {a} \u2286 B.proj \u207b\u00b9' {ofLe h a} := by\n  rcases A.proj_surjective a with \u27e8a, rfl\u27e9\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) \u2192 Q)\n    (compat : \u2200 (A B : DiscreteQuotient X) (h : A \u2264 B), ofLe h (Qs _) = Qs _) :\n    \u2203 x : X, \u2200 Q : DiscreteQuotient X, Q.proj x = Qs _ := by\n  have H\u2081 : \u2200 Q\u2081 Q\u2082, Q\u2081 \u2264 Q\u2082 \u2192 proj Q\u2081 \u207b\u00b9' {Qs Q\u2081} \u2286 proj Q\u2082 \u207b\u00b9' {Qs Q\u2082} := fun _ _ h => by\n    rw [\u2190 compat _ _ h]\n    exact fiber_subset_ofLe _ _\n  obtain \u27e8x, hx\u27e9 : Set.Nonempty (\u22c2 Q, proj Q \u207b\u00b9' {Qs Q}) :=\n    IsCompact.nonempty_inter\u1d62_of_directed_nonempty_compact_closed\n      (fun Q : DiscreteQuotient X => Q.proj \u207b\u00b9' {Qs _}) (directed_of_inf H\u2081)\n      (fun Q => (singleton_nonempty _).preimage Q.proj_surjective)\n      (fun Q => (Q.isClosed_preimage {Qs _}).isCompact) fun Q => Q.isClosed_preimage _\n  exact \u27e8x, mem_inter\u1d62.1 hx\u27e9\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 [\u2190 isCompact_univ_iff, isCompact_iff_finite, finite_univ_iff] at this\n\nend DiscreteQuotient\n\nnamespace LocallyConstant\n\nvariable (f : LocallyConstant X \u03b1)\n\n/-- Any locally constant function induces a discrete quotient. -/\ndef discreteQuotient : DiscreteQuotient X where\n  toSetoid := .comap f \u22a5\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 \u03b1 :=\n  \u27e8fun a => Quotient.liftOn' a f fun _ _ => id, fun _ => isOpen_discrete _\u27e9\n#align locally_constant.lift LocallyConstant.lift\n\n@[simp]\ntheorem lift_comp_proj : f.lift \u2218 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 \u27f6 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.\u03b9 : image f \u27f6 H := f.range.subtype\n\ninstance : mono (image.\u03b9 f) := concrete_category.mono_of_injective (image.\u03b9 f) subtype.val_injective\n\n/-- the corestriction map to the image -/\ndef factor_thru_image : G \u27f6 image f := f.range_restrict\n\nlemma image.fac : factor_thru_image f \u226b image.\u03b9 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 \u27f6 F'.I :=\n{ to_fun :=\n  (\u03bb x, F'.e (classical.indefinite_description _ x.2).1 : image f \u2192 F'.I),\n  map_zero' :=\n  begin\n    haveI := F'.m_mono,\n    apply injective_of_mono F'.m,\n    change (F'.e \u226b F'.m) _ = _,\n    rw [F'.fac, add_monoid_hom.map_zero],\n    exact (classical.indefinite_description (\u03bb 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 \u226b F'.m) _ = (F'.e \u226b F'.m) _ + (F'.e \u226b F'.m) _,\n    rw [F'.fac],\n    rw (classical.indefinite_description (\u03bb z, f z = _) _).2,\n    rw (classical.indefinite_description (\u03bb z, f z = _) _).2,\n    rw (classical.indefinite_description (\u03bb z, f z = _) _).2,\n    refl,\n  end,\n }\nlemma image.lift_fac (F' : mono_factorisation f) : image.lift F' \u226b F'.m = image.\u03b9 f :=\nbegin\n  ext x,\n  change (F'.e \u226b 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.\u03b9 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 \u27f6 H) :\n  limits.image f \u2245 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) (\u03b1 : Type u) : Type u :=\n  StateM (ULift.{u} g) \u03b1\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 `\u2115` -/\ndef RandG.next {g : Type} [RandomGen g] : RandG g \u2115 :=\n  \u27e8Prod.map id up \u2218 RandomGen.next \u2218 down\u27e9\n#align rand_g.next RandG.next\n\n-- mathport name: \u00abexpr .. \u00bb\nlocal infixl:41 \" .. \" => Set.Icc\n\nopen Stream'\n\n#print BoundedRandom /-\n/-- `bounded_random \u03b1` gives us machinery to generate values of type `\u03b1` between certain bounds -/\nclass BoundedRandom (\u03b1 : Type u) [Preorder \u03b1] where\n  randomR : \u2200 (g) [RandomGen g] (x y : \u03b1), x \u2264 y \u2192 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 \u03b1` gives us machinery to generate values of type `\u03b1` -/\nclass Random (\u03b1 : Type u) where\n  Random : \u2200 (g : Type) [RandomGen g], RandG g \u03b1\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 : \u2115 := by apply_normed 2 ^ 31\n#align shift_31_left shift31Left\n\nnamespace Rand\n\nopen Stream'\n\nvariable (\u03b1 : 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  \u27e8Prod.map id up \u2218 RandomGen.split \u2218 down\u27e9\n#align rand.split Rand.split\n-/\n\nvariable {g}\n\nsection Random\n\nvariable [Random \u03b1]\n\nexport Random (Random)\n\n/-- Generate a random value of type `\u03b1`. -/\ndef random : RandG g \u03b1 :=\n  Random.random \u03b1 g\n#align rand.random Rand.random\n\n/-- generate an infinite series of random values of type `\u03b1` -/\ndef randomSeries : RandG g (Stream' \u03b1) := do\n  let gen \u2190 Uliftable.up (split g)\n  pure <| Stream'.corecState (Random.random \u03b1 g) gen\n#align rand.random_series Rand.randomSeries\n\nend Random\n\nvariable {\u03b1}\n\n/-- Generate a random value between `x` and `y` inclusive. -/\ndef randomR [Preorder \u03b1] [BoundedRandom \u03b1] (x y : \u03b1) (h : x \u2264 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 `\u03b1` between `x` and `y` inclusive. -/\ndef randomSeriesR [Preorder \u03b1] [BoundedRandom \u03b1] (x y : \u03b1) (h : x \u2264 y) :\n    RandG g (Stream' (x .. y)) := do\n  let gen \u2190 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 : \u2115) (c : Char) : \u2115 :=\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 \u2190 Io.rand 0 shift31Left\n  return <| mkStdGen seed\n#align io.mk_generator Io.mkGenerator\n\nvariable {\u03b1 : Type}\n\n/-- Run `cmd` using a randomly seeded random number generator -/\ndef runRand (cmd : Rand \u03b1) : Io \u03b1 := do\n  let g \u2190 Io.mkGenerator\n  return <| (cmd \u27e8g\u27e9).1\n#align io.run_rand Io.runRand\n\n/-- Run `cmd` using the provided seed. -/\ndef runRandWith (seed : \u2115) (cmd : Rand \u03b1) : Io \u03b1 :=\n  return <| (cmd.run \u27e8mkStdGen seed\u27e9).1\n#align io.run_rand_with Io.runRandWith\n\nsection Random\n\nvariable [Random \u03b1]\n\n/-- randomly generate a value of type \u03b1 -/\ndef random : Io \u03b1 :=\n  Io.runRand (Rand.random \u03b1)\n#align io.random Io.random\n\n/-- randomly generate an infinite series of value of type \u03b1 -/\ndef randomSeries : Io (Stream' \u03b1) :=\n  Io.runRand (Rand.randomSeries \u03b1)\n#align io.random_series Io.randomSeries\n\nend Random\n\nsection BoundedRandom\n\nvariable [Preorder \u03b1] [BoundedRandom \u03b1]\n\n/-- randomly generate a value of type \u03b1 between `x` and `y` -/\ndef randomR (x y : \u03b1) (p : x \u2264 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 \u03b1 between `x` and `y` -/\ndef randomSeriesR (x y : \u03b1) (h : x \u2264 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 {\u03b1 : Type u} (cmd : Rand \u03b1) : tactic \u03b1 := do\n  let \u27e8g\u27e9 \u2190 tactic.up mk_generator\n  return (cmd \u27e8g\u27e9).1\n#align tactic.run_rand tactic.run_rand\n\nvariable {\u03b1 : Type u}\n\nsection BoundedRandom\n\nvariable [Preorder \u03b1] [BoundedRandom \u03b1]\n\n/-- Generate a random value between `x` and `y` inclusive. -/\nunsafe def random_r (x y : \u03b1) (h : x \u2264 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 `\u03b1` between `x` and `y` inclusive. -/\nunsafe def random_series_r (x y : \u03b1) (h : x \u2264 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 \u03b1]\n\n/-- randomly generate a value of type \u03b1 -/\nunsafe def random : tactic \u03b1 :=\n  run_rand (Rand.random \u03b1)\n#align tactic.random tactic.random\n\n/-- randomly generate an infinite series of value of type \u03b1 -/\nunsafe def random_series : tactic (Stream' \u03b1) :=\n  run_rand (Rand.randomSeries \u03b1)\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 : \u2115} [NeZero n]\n\n/-- generate a `fin` randomly -/\nprotected def random : RandG g (Fin n) :=\n  \u27e8fun \u27e8g\u27e9 => Prod.map ofNat'' up <| randNat g 0 n\u27e9\n#align fin.random Fin.random\n\nend Fin\n\nopen Nat\n\ninstance natBoundedRandom : BoundedRandom \u2115\n    where randomR g inst x y hxy := do\n    let z \u2190 @Fin.random g inst (succ <| y - x) _\n    pure\n        \u27e8z + x, Nat.le_add_left _ _, by\n          rw [\u2190 le_tsub_iff_right hxy] <;> apply le_of_succ_le_succ z.is_lt\u27e9\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 \u2124\n    where randomR g inst x y hxy := do\n    let \u27e8z, h\u2080, h\u2081\u27e9 \u2190 @BoundedRandom.randomR \u2115 _ _ g inst 0 (Int.natAbs <| y - x) (by decide)\n    pure\n        \u27e8z + 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\u2081)\n              (le_of_eq <| Int.ofNat_natAbs_eq_of_nonneg (Int.sub_nonneg_of_le hxy))\u27e9\n#align int_bounded_random intBoundedRandom\n\ninstance finRandom (n : \u2115) [NeZero n] : Random (Fin n) where Random g inst := @Fin.random g inst _ _\n#align fin_random finRandom\n\ninstance finBoundedRandom (n : \u2115) : BoundedRandom (Fin n)\n    where randomR g inst (x y : Fin n) p := do\n    let \u27e8r, h, h'\u27e9 \u2190 @Rand.randomR \u2115 g inst _ _ x.val y.val p\n    pure \u27e8\u27e8r, lt_of_le_of_lt h' y\u27e9, h, h'\u27e9\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 : \u2200 {n : \u2115} (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 : \u2115) :\n    n \u2208 (x.toNat .. y.toNat) \u2192 Bool.ofNat n \u2208 (x .. y) :=\n  by\n  simp only [and_imp, Set.mem_Icc]; intro h\u2080 h\u2081\n  constructor <;> [have h\u2082 := Bool.ofNat_le_ofNat h\u2080, have h\u2082 := Bool.ofNat_le_ofNat h\u2081] <;>\n      rw [Bool.ofNat_toNat] at h\u2082 <;>\n    exact h\u2082\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 \u2218 Subtype.val) <$> @BoundedRandom.randomR \u2115 _ _ 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 \u2115 _ _ 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 : \u2115) : 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 : \u2115} (x y : Bitvec n) (h : x \u2264 y) : RandG g (x .. y) :=\n  have h' : \u2200 a : Fin (2 ^ n), a \u2208 (x.toFin .. y.toFin) \u2192 Bitvec.ofFin a \u2208 (x .. y) :=\n    by\n    simp only [and_imp, Set.mem_Icc]; intro z h\u2080 h\u2081\n    replace h\u2080 := Bitvec.ofFin_le_ofFin_of_le h\u2080\n    replace h\u2081 := Bitvec.ofFin_le_ofFin_of_le h\u2081\n    rw [Bitvec.ofFin_toFin] at h\u2080 h\u2081; 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 : \u2115) : Random (Bitvec n) where Random _ inst := @Bitvec.random _ inst n\n#align random_bitvec randomBitvec\n\ninstance boundedRandomBitvec (n : \u2115) : 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 \"\u211d\" : term => \n  do return Lean.TSyntax.raw (\u2190 `(Real))\nmacro \"\u2211\" i:Lean.Parser.Term.funBinder \",\" t:term : term => \n  do return Lean.TSyntax.raw (\u2190 `(Finset.sum Finset.univ (fun $i => $t)))\nmacro \"\u2211\" i:Lean.Parser.Term.funBinder \"in\" s:term \",\" t:term : term => \n  do return Lean.TSyntax.raw (\u2190 `(Finset.sum $s (fun $i => $t)))\nmacro \"\u220f\" i:Lean.Parser.Term.funBinder \",\" t:term : term => \n  do return Lean.TSyntax.raw (\u2190 `(Finset.prod Finset.univ (fun $i => $t)))\nmacro \"\u220f\" i:Lean.Parser.Term.funBinder \"in\" s:term \",\" t:term : term => \n  do return Lean.TSyntax.raw (\u2190 `(Finset.prod $s (fun $i => $t)))\nmacro:75 l:term:75 \" \u2b1d \" r:term:76 : term => \n  do return Lean.TSyntax.raw (\u2190 `(Matrix.mul $l $r))\nmacro:75 l:term:75 \" \u2b1d\u1d65 \" r:term:76 : term => \n  do return Lean.TSyntax.raw (\u2190 `(Matrix.dotProduct $l $r))\nmacro:50 l:term:50 \" \u2208 \" r:term:51 : term => \n  do return Lean.TSyntax.raw (\u2190 `(HasMem.Mem $l $r))\nmacro:75 l:term:75 \" \u2022 \" r:term:76 : term => \n  do return Lean.TSyntax.raw (\u2190 `(HasSmul.smul $l $r))\n\nmacro \"![\" ts:term,* \"]\" : term => do\n  let ts : Array (Lean.TSyntax _) := ts.getElems\n  let res \u2190 ts.foldrM (init := \u2190 `(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 \u2227 (b \u2227 c)) = (b \u2227 (a \u2227 c)) := by rw [\u2190 and_assoc, and_comm a b, and_assoc]\n\nend Logic\n\nnamespace Nat\n\ninstance : LE \u2115 := { le := Nat.le }\n\nattribute [-instance] Nat.hasSub\ninstance : Sub \u2115 :=\n  \u27e8Nat.sub\u27e9\n\nattribute [-instance] Nat.hasAdd\ninstance : Add \u2115 :=\n  \u27e8Nat.add\u27e9\n\nattribute [-instance] Nat.hasMul\ninstance : Mul \u2115 :=\n  \u27e8Nat.mul\u27e9\n\nattribute [-instance] Nat.inhabited\ninstance inhabited' : Inhabited \u2115 :=\n  \u27e8Nat.zero\u27e9\n\ninstance decidableEq' : DecidableEq \u2115\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 \u25b8 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 \u2192 Type} [\u2200 i, Zero (f i)] : Zero (\u2200 i : I, f i) :=\n  \u27e8fun _ => Zero.zero\u27e9\n\nattribute [-instance] Pi.hasOne\ninstance hasOne' {I : Type} {f : I \u2192 Type} [\u2200 i, One (f i)] : One (\u2200 i : I, f i) :=\n  \u27e8fun _ => One.one\u27e9\n\nend Pi\n\nnamespace Bool\n\nattribute [-instance] Bool.inhabited\ninstance Bool.inhabited' : Inhabited Bool :=\n  \u27e8false\u27e9\n\nend Bool\n\nnamespace Prod\n\nattribute [-instance] Prod.inhabited\ninstance Prod.inhabited' [Inhabited \u03b1] [Inhabited \u03b2] : Inhabited (Prod \u03b1 \u03b2) :=\n  \u27e8(default, default)\u27e9\n\nend Prod\n\nnamespace List\n\nattribute [-instance] List.inhabited\ninstance List.inhabited' (\u03b1 : Type u) : Inhabited (List \u03b1) :=\n  \u27e8List.nil\u27e9\n\nattribute [-instance] List.hasAppend\ninstance : Append (List \u03b1) :=\n  \u27e8List.append\u27e9\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\u2093 \u03b1]\n\ninstance (a b : \u03b1) : Decidable (a < b) :=\n  LinearOrder\u2093.decidableLt a b\n\ninstance (a b : \u03b1) : Decidable (a \u2264 b) :=\n  LinearOrder\u2093.decidableLe a b\n\ninstance (a b : \u03b1) : Decidable (a = b) :=\n  LinearOrder\u2093.decidableEq a b\n\nend LinearOrder\n\nnamespace Int\n\nattribute [-instance] Int.decidableLt\ninstance Int.decidableLt' : LT Int :=\n  \u27e8Int.Lt\u27e9\n\nattribute [-instance] Int.linearOrder Int.hasSub\n\ninstance Int.hasZero' : Zero \u2124 :=\n  \u27e8ofNat 0\u27e9\n\ninstance Int.hasOne' : One \u2124 :=\n  \u27e8ofNat 1\u27e9\n\ninstance Int.hasSub' : Sub \u2124 :=\n  \u27e8Int.sub\u27e9\n\ninstance Int.hasSAdd' : Add \u2124 :=\n  \u27e8Int.add\u27e9\n\ninstance Decidable.true' : Decidable True :=\n  isTrue trivial\u2093\n\ninstance Decidable.false' : Decidable False :=\n  isFalse not_false\n\ndef decidableNonneg' (a : \u2124) : Decidable (Nonneg a) :=\n  Int.casesOn a (fun a => Decidable.true') fun a => Decidable.false'\n\ninstance decidableLe' (a b : \u2124) : Decidable (a \u2264 b) :=\n  decidableNonneg' (b - a)\n\ninstance decidableLt' (a b : \u2124) : Decidable (a < b) :=\n  decidableNonneg' (b - (a + ofNat 1))\n\ninstance decidableEq' (a b : \u2124) : 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 \u03bb h => by cases h\n| ofNat a, negSucc b => Decidable.isFalse \u03bb 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 \u2192 q) :=\n  if hp : p then if hq : q then isTrue fun h => hq else isFalse fun h : p \u2192 q => absurd (h hp) hq\n  else isTrue fun h => absurd h hp\n\nattribute [-instance] Ne.decidable\ninstance Ne.decidable' {\u03b1 : Sort u} [DecidableEq \u03b1] (a b : \u03b1) : Decidable (a \u2260 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\u2081 v\u2082 u u\u2081 u\u2082\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\nvariables {D : Type u\u2082} [category.{v\u2082} D]\nvariables (G : C \u2964 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)) \u2243 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 := \u03bb 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 (\u22a4_ C)) :=\nterminal_is_terminal.is_terminal_obj G (\u22a4_ 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\u27e8\u03bb F,\nbegin\n  haveI := has_limit.mk \u27e8_, is_limit_of_has_terminal_of_preserves_limit G\u27e9,\n  apply has_limit_of_iso F.unique_from_empty.symm,\nend\u27e9\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 \u22a4 \u27f6 \u22a4`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_is_iso\n  (f : G.obj (\u22a4_ C) \u27f6 \u22a4_ 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 \u22a4 \u2245 \u22a4`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_iso\n  (f : G.obj (\u22a4_ C) \u2245 \u22a4_ 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 (\u22a4_ C) \u2245 \u22a4_ 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 \u2190 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\u2081} X)) \u2243 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 := \u03bb 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 (\u22a5_ C)) :=\ninitial_is_initial.is_initial_obj G (\u22a5_ 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\u27e8\u03bb F,\nbegin\n  haveI := has_colimit.mk \u27e8_, is_colimit_of_has_initial_of_preserves_colimit G\u27e9,\n  apply has_colimit_of_iso F.unique_from_empty,\nend\u27e9\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 `\u22a5 \u27f6 G.obj \u22a5`, then `G` preserves initial objects. -/\ndef preserves_initial_of_is_iso\n  (f : \u22a5_ D \u27f6 G.obj (\u22a5_ 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 `\u22a5 \u2245 G.obj \u22a5 `, then `G` preserves initial objects. -/\ndef preserves_initial_of_iso\n  (f : \u22a5_ D \u2245 G.obj (\u22a5_ 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 (\u22a5_ C) \u2245 \u22a5_ 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 \u2190 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 {\u03b1 : Type} (x y z : \u03b1) (xs ys zs : list \u03b1)\n\ndef mk_symm (xs : list \u03b1) := xs ++ reverse xs\n\ntheorem reverse_mk_symm (xs : list \u03b1) :\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": "inductive Ty :=\n| int: Ty\n| other: Ty\n\ninductive Tensor :=\n| int: Int -> Tensor\n| nested: List Tensor -> Tensor\n\ndef hasBaseType: Tensor \u2192 Ty \u2192 Bool\n  | .int _, Ty.int      => true\n  | .int _, Ty.other    => true\n  | .nested _, _        => true\n\ndef flatten (e: Tensor) (\u03c4: Ty) (h: hasBaseType e \u03c4): List Int :=\n  match e, \u03c4 with\n  | .int _, Ty.int     => []\n  | .int _, _          => []\n  | .nested [], _      => []\n  | .nested (_::_), _  => []\n\ntheorem flatten_list (l: List Tensor) \u03c4 (h: hasBaseType (.nested l) \u03c4):\n    flatten (.nested l) \u03c4 h = [] := by\n  simp [flatten]\n  repeat 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/matchEqnsHEqIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619177503206, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.494832445687087}}
{"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 \u2192 G \u2192 G := \u03bb g : G, \u03bb 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 \u2192 G \u2192 G := \u03bb g : G, \u03bb x : G, x * g\n\nend has_mul\n\nsection times_cont_diff\n\nvariables {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E]\n{F : Type*} [normed_group F] [normed_space \ud835\udd5c F]\n{G : Type*} [normed_group G] [normed_space \ud835\udd5c G]\n{s s\u2081 t u : set E} {f f\u2081 : E \u2192 F} {g : F \u2192 G} {x : E} {c : F}\n{b : E \u00d7 F \u2192 G}\n\n/--\nThe first projection at a point in a product is `C^\u221e`.\n-/\nlemma times_cont_diff_at_fst {p : E \u00d7 F} {n : with_top \u2115} :\n  times_cont_diff_at \ud835\udd5c n (prod.fst : E \u00d7 F \u2192 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^\u221e`.\n-/\nlemma times_cont_diff_within_at_fst {s : set (E \u00d7 F)} {p : E \u00d7 F} {n : with_top \u2115} :\n  times_cont_diff_within_at \ud835\udd5c n (prod.fst : E \u00d7 F \u2192 E) s p :=\ntimes_cont_diff_fst.times_cont_diff_within_at\n\nlemma times_cont_diff_add {n : with_top \u2115} : times_cont_diff \ud835\udd5c n (\u03bbp : F \u00d7 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 \u2115} {f g : E \u2192 F}\n  (hf : times_cont_diff \ud835\udd5c n f) (hg : times_cont_diff \ud835\udd5c n g) : times_cont_diff \ud835\udd5c n (\u03bbx, f x + g x) :=\ntimes_cont_diff_add.comp (hf.prod hg)\n\nlemma times_cont_diff_neg {n : with_top \u2115} : times_cont_diff \ud835\udd5c n (\u03bbp : 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 \u2115} {f : E \u2192 F} (hf : times_cont_diff \ud835\udd5c n f) :\n  times_cont_diff \ud835\udd5c n (\u03bbx, -f x) :=\ntimes_cont_diff_neg.comp hf\n\nsection prod_map\nvariables {E' : Type*} [normed_group E'] [normed_space \ud835\udd5c E']\n{F' : Type*} [normed_group F'] [normed_space \ud835\udd5c F']\n{n : with_top \u2115}\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 \u2192 F} {g : E' \u2192 F'} {p : E \u00d7 E'}\n  (hf : times_cont_diff_within_at \ud835\udd5c n f s p.1) (hg : times_cont_diff_within_at \ud835\udd5c n g t p.2) :\n  times_cont_diff_within_at \ud835\udd5c 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 \u2192 F} {g : E' \u2192 F'} {x : E} {y : E'}\n  (hf : times_cont_diff_within_at \ud835\udd5c n f s x) (hg : times_cont_diff_within_at \ud835\udd5c n g t y) :\n  times_cont_diff_within_at \ud835\udd5c 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 \u2192 F} {g : E' \u2192 F'} {x : E} {y : E'}\n  (hf : times_cont_diff_at \ud835\udd5c n f x) (hg : times_cont_diff_at \ud835\udd5c n g y) :\n  times_cont_diff_at \ud835\udd5c 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 \u2192 F} {g : E' \u2192 F'} {p : E \u00d7 E'}\n  (hf : times_cont_diff_at \ud835\udd5c n f p.1) (hg : times_cont_diff_at \ud835\udd5c n g p.2) :\n  times_cont_diff_at \ud835\udd5c 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 \u2192 F} {g : E' \u2192 F'}\n  (hf : times_cont_diff \ud835\udd5c n f) (hg : times_cont_diff \ud835\udd5c n g) :\n  times_cont_diff \ud835\udd5c n (prod.map f g) :=\nbegin\n  rw times_cont_diff_iff_times_cont_diff_at at *,\n  exact \u03bb \u27e8x, y\u27e9, (hf x).prod_map (hg y)\nend\n\nend prod_map\n\nend times_cont_diff\n\nsection times_cont_mdiff\n\nvariables {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n-- declare a smooth manifold `M` over the pair `(E, H)`.\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E]\n{H : Type*} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E']\n{H' : Type*} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 \ud835\udd5c F]\n{G : Type*} [topological_space G] {J : model_with_corners \ud835\udd5c 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 \ud835\udd5c F']\n{G' : Type*} [topological_space G'] {J' : model_with_corners \ud835\udd5c 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\u2081 : M \u2192 M'} {s s\u2081 t : set M} {x : M} {m n : with_top \u2115}\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 \u2192 M'} {g : M \u2192 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 (\u03bb x, (f x, g x)) s x :=\nbegin\n  rw times_cont_mdiff_within_at_iff at *,\n  refine \u27e8hf.1.prod hg.1, (hf.2.mono _).prod (hg.2.mono _)\u27e9;\n  mfld_set_tac,\nend\n\nlemma times_cont_mdiff_at.prod_mk {f : M \u2192 M'} {g : M \u2192 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 (\u03bb x, (f x, g x)) x :=\nhf.prod_mk hg\n\nlemma times_cont_mdiff_on.prod_mk {f : M \u2192 M'} {g : M \u2192 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 (\u03bb x, (f x, g x)) s :=\n\u03bb x hx, (hf x hx).prod_mk (hg x hx)\n\nlemma times_cont_mdiff.prod_mk {f : M \u2192 M'} {g : M \u2192 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 (\u03bb x, (f x, g x)) :=\n\u03bb x, (hf x).prod_mk (hg x)\n\nlemma smooth_within_at.prod_mk {f : M \u2192 M'} {g : M \u2192 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') (\u03bb x, (f x, g x)) s x :=\nhf.prod_mk hg\n\nlemma smooth_at.prod_mk {f : M \u2192 M'} {g : M \u2192 N'}\n  (hf : smooth_at I I' f x) (hg : smooth_at I J' g x) :\n  smooth_at I (I'.prod J') (\u03bb x, (f x, g x)) x :=\nhf.prod_mk hg\n\nlemma smooth_on.prod_mk {f : M \u2192 M'} {g : M \u2192 N'}\n  (hf : smooth_on I I' f s) (hg : smooth_on I J' g s) :\n  smooth_on I (I'.prod J') (\u03bb x, (f x, g x)) s :=\nhf.prod_mk hg\n\nlemma smooth.prod_mk {f : M \u2192 M'} {g : M \u2192 N'}\n  (hf : smooth I I' f) (hg : smooth I J' g) :\n  smooth I (I'.prod J') (\u03bb 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 \u00d7 N)} {p : M \u00d7 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 \u27e8continuous_within_at_fst, _\u27e9,\n  refine times_cont_diff_within_at_fst.congr (\u03bb 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 \u00d7 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 \u00d7 N)} :\n  times_cont_mdiff_on (I.prod J) I n prod.fst s :=\n\u03bb 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\u03bb x, times_cont_mdiff_at_fst\n\nlemma smooth_within_at_fst {s : set (M \u00d7 N)} {p : M \u00d7 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 \u00d7 N} :\n  smooth_at (I.prod J) I prod.fst p :=\ntimes_cont_mdiff_at_fst\n\nlemma smooth_on_fst {s : set (M \u00d7 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 \u00d7 N)} {p : M \u00d7 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 \u27e8continuous_within_at_snd, _\u27e9,\n  refine times_cont_diff_within_at_snd.congr (\u03bb 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 \u00d7 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 \u00d7 N)} :\n  times_cont_mdiff_on (I.prod J) J n prod.snd s :=\n\u03bb 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\u03bb x, times_cont_mdiff_at_snd\n\nlemma smooth_within_at_snd {s : set (M \u00d7 N)} {p : M \u00d7 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 \u00d7 N} :\n  smooth_at (I.prod J) J prod.snd p :=\ntimes_cont_mdiff_at_snd\n\nlemma smooth_on_snd {s : set (M \u00d7 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 \u2192 M' \u00d7 N'} :\n  (smooth I (I'.prod J') f) \u2194 (smooth I I' (prod.fst \u2218 f)) \u2227 (smooth I J' (prod.snd \u2218 f)) :=\nbegin\n  split,\n  { intro h, exact \u27e8smooth_fst.comp h, smooth_snd.comp h\u27e9 },\n  { rintro \u27e8h_fst, h_snd\u27e9, simpa only [prod.mk.eta] using h_fst.prod_mk h_snd, }\nend\n\nend projections\n\nsection prod_map\n\nvariables {g : N \u2192 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 \u00d7 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 \u2190 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 \u00d7 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 \u00a9 2020 Nicol\u00f2 Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Nicol\u00f2 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` \u00d7 `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 \ud835\udd5c 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 \u00d7 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 \ud835\udd5c 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space \ud835\udd5c E] (I : model_with_corners \ud835\udd5c 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 (\u03bb p : G\u00d7G, p.1 + p.2))\n(smooth_neg : smooth I I (\u03bb 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space \ud835\udd5c E] (I : model_with_corners \ud835\udd5c 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 (\u03bb p : G\u00d7G, p.1 * p.2))\n(smooth_inv : smooth I I (\u03bb a:G, a\u207b\u00b9))\n\nsection lie_group\n\nvariables {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n{H : Type*} [topological_space H]\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E] {I : model_with_corners \ud835\udd5c E H}\n{F : Type*} [normed_group F] [normed_space \ud835\udd5c F] {J : model_with_corners \ud835\udd5c 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 \ud835\udd5c E']\n{H' : Type*} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'']\n{H'' : Type*} [topological_space H''] {I'' : model_with_corners \ud835\udd5c 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 (\u03bb p : G\u00d7G, p.1 * p.2) :=\nlie_group.smooth_mul\n\n@[to_additive]\nlemma smooth.mul {f : M \u2192 G} {g : M \u2192 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 \u2192 G} {g : M \u2192 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 : \u2200 n : \u2115, smooth I I (\u03bb a : G, a ^ n)\n| 0 := by { simp only [pow_zero], exact smooth_const }\n| (k+1) := show smooth I I (\u03bb (a : G), a * a ^ k), from smooth_id.mul (smooth_pow _)\n\n@[to_additive]\nlemma smooth_inv : smooth I I (\u03bb x : G, x\u207b\u00b9) :=\nlie_group.smooth_inv\n\n@[to_additive]\nlemma smooth.inv {f : M \u2192 G}\n  (hf : smooth I' I f) : smooth I' I (\u03bbx, (f x)\u207b\u00b9) :=\nsmooth_inv.comp hf\n\n@[to_additive]\nlemma smooth_on.inv {f : M \u2192 G} {s : set M}\n  (hf : smooth_on I' I f s) : smooth_on I' I (\u03bbx, (f x)\u207b\u00b9) 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c] {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space \ud835\udd5c E]  {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E']\n  {H' : Type*} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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\u00d7G') :=\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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E]\n{E' : Type*} [normed_group E'] [normed_space \ud835\udd5c E']\n\n/-- Morphism of additive Lie groups. -/\nstructure lie_add_group_morphism (I : model_with_corners \ud835\udd5c E E) (I' : model_with_corners \ud835\udd5c 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 \ud835\udd5c E E) (I' : model_with_corners \ud835\udd5c 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 \ud835\udd5c E E} {I' : model_with_corners \ud835\udd5c 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') := \u27e8\u27e81, smooth_const\u27e9\u27e9\nThis conversation was marked as resolved by sgouezel\n\n@[to_additive]\ninstance : inhabited (lie_group_morphism I I' G G') := \u27e81\u27e9\n\n@[to_additive]\ninstance : has_coe_to_fun (lie_group_morphism I I' G G') := \u27e8_, \u03bb a, a.to_fun\u27e9\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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n  {E : Type*} [normed_group E]\n  [normed_space \ud835\udd5c E] (I : model_with_corners \ud835\udd5c 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 (\u03bb p : G\u00d7G, p.1 + p.2))\n(smooth_neg : smooth I I (\u03bb 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n  {E : Type*} [normed_group E]\n  [normed_space \ud835\udd5c E] (I : model_with_corners \ud835\udd5c 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 (\u03bb p : G\u00d7G, p.1 * p.2))\n(smooth_inv : smooth I I (\u03bb a:G, a\u207b\u00b9))\n\nvariables {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E] {I : model_with_corners \ud835\udd5c E E}\n{F : Type*} [normed_group F] [normed_space \ud835\udd5c F] {J : model_with_corners \ud835\udd5c 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 \ud835\udd5c _ _ _ 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E] :\nlie_add_group (model_with_corners_self \ud835\udd5c E) E :=\n{ smooth_add :=\n  begin\n    rw smooth_iff,\n    refine \u27e8continuous_add, \u03bb x y, _\u27e9,\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 \u27e8continuous_neg, \u03bb x y, _\u27e9,\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 \u211d \u211d) \u211d := 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 \u2192 Type v) [Monad m] [LawfulMonad m]\n    (f : \u03b1 \u2192 \u03b2) (x : m \u03b1) : f <$> x = x >>= pure \u2218 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 \u2192 Type v} [Functor m] (cmd : StateT \u03c3 m \u03b1) (s : \u03c3) : m \u03b1 :=\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\u2081 : Type u\u2080 \u2192 Type v\u2080} {m\u2082 : Type u\u2081 \u2192 Type v\u2081}\n    (F : (\u03c3\u2081 \u2192 m\u2081 (\u03b1\u2081 \u00d7 \u03c3\u2081)) \u2243 (\u03c3\u2082 \u2192 m\u2082 (\u03b1\u2082 \u00d7 \u03c3\u2082))) : StateT \u03c3\u2081 m\u2081 \u03b1\u2081 \u2243 StateT \u03c3\u2082 m\u2082 \u03b1\u2082 :=\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\u2081 : Type u\u2080 \u2192 Type v\u2080} {m\u2082 : Type u\u2081 \u2192 Type v\u2081}\n    (F : (\u03c1\u2081 \u2192 m\u2081 \u03b1\u2081) \u2243 (\u03c1\u2082 \u2192 m\u2082 \u03b1\u2082)) : ReaderT \u03c1\u2081 m\u2081 \u03b1\u2081 \u2243 ReaderT \u03c1\u2082 m\u2082 \u03b1\u2082 :=\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 \u00a9 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  \u2200 a: nnreal, \u2200 b: nnreal, a + b = 1 \u2192 a = (1:nnreal) - b :=\nassume a b h, h \u25b8 (nnreal.add_sub_cancel).symm\n\nlemma delta_helper:\n  \u2200 \u03b4: nnreal, \u03b4 > (0:nnreal) \u2192 (1:nnreal) - \u03b4 \u2264 (1: nnreal) :=\nassume h, by simp\n\nlemma coe_pmeas:\n  \u2200 a: ennreal, \u2200 b: ennreal, a \u2264 (1:ennreal) \u2192 b \u2264 (1: ennreal) \u2192 a \u2264 b \u2192 ennreal.to_nnreal a \u2264 ennreal.to_nnreal b :=\nbegin\n  intros a b h\u2081 h\u2082 h\u2083,\n  rw [\u2190 coe_le_coe, coe_to_nnreal,coe_to_nnreal],\n  assumption,\n  rw \u2190ennreal.lt_top_iff_ne_top,\n  exact lt_of_le_of_lt h\u2082 (ennreal.lt_top_iff_ne_top.2 one_ne_top),\n  rw \u2190ennreal.lt_top_iff_ne_top,\n  exact lt_of_le_of_lt h\u2081 (ennreal.lt_top_iff_ne_top.2 one_ne_top),\nend\n\nlemma pow_preserves_order:\n  \u2200 n: \u2115, \u2200 a: nnreal, \u2200 b: nnreal, a \u2264 b \u2192 a^n \u2264 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  \u2200 A: Prop, \u2200 B: Prop, (\u00ac (A \u2194 B)) \u2194 ((\u00ac (A \u2192 B)) \u2228 (\u00ac (B \u2192 A))) :=\nbegin\n  intros,\n  split; intros; try {finish},\nend\n\nlemma nnreal_sub_trans:\n  \u2200 a: nnreal, \u2200 b: nnreal,\n  a \u2265 b \u2192 1 - a \u2264 1 - b :=\nbegin\nintros,\nrw nnreal.sub_le_iff_le_add,\nsimp,\nby_cases (b \u2264 1),\n{\n  have h: 1 + (a - b) = a + (1 - b),\n  by calc 1 + (a - b) = 1 + a - b   : by rw [\u2190nnreal.eq_iff,nnreal.coe_add, (nnreal.coe_sub _ _ a_1), \u2190add_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 [\u2190nnreal.eq_iff,nnreal.coe_add, (nnreal.coe_sub _ _ h), \u2190add_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 {\u03b1: Type} {\u03b2: Type}:\n  \u2200 P\u2081: \u03b1 \u2192 Prop,\n  \u2200 P\u2082: \u03b2 \u2192 Prop,\n  { v : \u03b1 \u00d7 \u03b2 | P\u2081 v.fst \u2227 P\u2082 v.snd} = set.prod {x: \u03b1 | P\u2081 x} {x: \u03b2 | P\u2082 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 {\u03b1: Type}:\n  \u2200 P: \u03b1 \u2192 Prop,\n  \u2200 x: vec \u03b1 0,\n  (\u2200 (i: dfin 1), P (kth_projn x i)) \u2194 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' {\u03b1: Type}:\n  \u2200 P: \u03b1 \u2192 Prop,\n  { x: vec \u03b1 0 | \u2200 (i: dfin 1), P (kth_projn x i)} = {x: \u03b1 | 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 {\u03b1: Type} [measurable_space \u03b1]:\n  \u2200 P: \u03b1 \u2192 Prop,\n  is_measurable {x: \u03b1 | P x} \u2192\n  \u2200 n,\n  is_measurable {v: vec \u03b1 n | \u2200 (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 (\u03bb x, P x) (\u03bb x, \u2200 (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: \u2200 n: \u2115, 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 : \u2200 n:\u2115, 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 : \u2115) : vec.measurable_space n = measure_theory.borel (vec nnreal n) :=\nbegin\n  induction n with k ih,\n  refl,\n  dsimp [vec], rw \u2190measure_theory.borel_prod,\n  rw prod.measurable_space, rw \u2190ih, refl,\nend\n\nlemma is_measurable_of_continuous_vec :\n  \u2200 n: \u2115,\n  \u2200 f: nnreal \u00d7 vec nnreal n \u2192 nnreal,\n  \u2200 g: nnreal \u00d7 vec nnreal n \u2192 nnreal,\n  continuous f \u2192\n  continuous g \u2192\n  is_measurable {p: nnreal \u00d7 (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 \u2190measure_theory.borel_prod, rw vec.measurable_space_eq_borel n, refl,\nend\n\nlemma to_nnreal_sub {r\u2081 r\u2082 : ennreal} (h\u2081 : r\u2081 < \u22a4) (h\u2082 : r\u2082 < \u22a4) :\n  (r\u2081 - r\u2082).to_nnreal = r\u2081.to_nnreal - r\u2082.to_nnreal :=\nby rw [\u2190 ennreal.coe_eq_coe, ennreal.coe_sub, ennreal.coe_to_nnreal (ne_top_of_lt h\u2082), ennreal.coe_to_nnreal (ne_top_of_lt h\u2081),\n  ennreal.coe_to_nnreal ((lt_top_iff_ne_top.1 (lt_of_le_of_lt (sub_le_self _ _) h\u2081)))]\n\nsection to_borel_space\n\n/- Move these back to borel_space.lean -/\n\nvariables {\u03b1 : Type*} [linear_order \u03b1] [topological_space \u03b1] [ordered_topology \u03b1] {a b c : \u03b1}\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  \u2200 x: nnreal, Ioi x = - (Iio x \u222a {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: \u00ac (x < x), simp,\n    contradiction,\n  },\n  {\n    push_neg at a,\n    cases a,\n    by_contradiction,\n    have FOO: \u00ac (x \u2264 x_1),by simp at * ; exact lt_of_le_of_ne a a_left,\n    contradiction,\n  },\nend\n\nlemma Icc_diff_Ioc:\n  \u2200 a: nnreal, \u2200 b: nnreal, \u2200 c: nnreal,\n  a \u2264 b \u2192 b \u2264 c \u2192 (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 (\u03bb 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 {\u03bc: probability_measure nnreal}:\n  \u2200 a: nnreal, \u2200 b: nnreal, a \u2264 b \u2192 \u03bc (Icc 0 a) \u2264 \u03bc (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  \u2200 x: nnreal, \u2200 y: nnreal, x > 0 \u2192 y > 0 \u2192 (x \u2264 y \u2194 log x \u2264 log y) :=\nbegin\n  intros,\n  rw log_le_log,\n  refl, assumption, assumption,\nend\n\nlemma log_pow_nnreal:\n  \u2200 x: nnreal, x > 0 \u2192 \u2200 n: \u2115, 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  \u2200 a: nnreal, \u2200 n: \u2115, a.val ^ n = (a ^ n).val :=\nbegin\n  intros,\n  induction n,\n  simp, refl,\n  have pow_nnreal: \u2200 a: nnreal, \u2200 n: \u2115, a ^ (nat.succ n) = a * a ^ n, intros, exact rfl,\n  rw pow_nnreal,\n  have mul_coe: \u2200 a: nnreal, \u2200 b: nnreal, (a * b).val = a.val * b.val, intros, refl,\n  rw mul_coe,\n  rw \u2190 n_ih,\n  refl,\nend\n\nlemma sub_nnreal:\n  \u2200 a: nnreal, \u2200 b: nnreal, a \u2265 b \u2192 (a - b).val = a.val - b.val :=\nbegin\n  intros a b h,\n  change (\u2191(a-b) = \u2191a - \u2191b),\n  rw nnreal.coe_sub _ _ h,\nend\n\nlemma ite_equals_union_interval:\n  \u2200 \u03b8 > 0, \u2200 y: nnreal, {x: nnreal | ite (to_bool(x \u2264 y)) x 0 < \u03b8} = Ico 0 \u03b8 \u222a 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: \u00ac (y < x), by simp at h \u22a2 ; 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 \u2192 fix`.\n`cofix` : the final coalgebra with structure map `cofix \u2192 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 `\u03b1`,\nelements of `F \u03b1` are represented by pairs `\u27e8a, f\u27e9`, where `a` is the shape of the object and\n`f` indexes the relevant elements of `\u03b1`, in a suitably natural manner.\n-/\nclass Qpf (F : Type u \u2192 Type u) [Functor F] where\n  p : PFunctor.{u}\n  abs : \u2200 {\u03b1}, P.Obj \u03b1 \u2192 F \u03b1\n  repr : \u2200 {\u03b1}, F \u03b1 \u2192 P.Obj \u03b1\n  abs_repr : \u2200 {\u03b1} (x : F \u03b1), abs (repr x) = x\n  abs_map : \u2200 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (p : P.Obj \u03b1), abs (f <$> p) = f <$> abs p\n#align qpf Qpf\n\nnamespace Qpf\n\nvariable {F : Type u \u2192 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 {\u03b1 : Type _} (x : F \u03b1) : id <$> x = x :=\n  by\n  rw [\u2190 abs_repr x]\n  cases' repr x with a f\n  rw [\u2190 abs_map]\n  rfl\n#align qpf.id_map Qpf.id_map\n\ntheorem comp_map {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (x : F \u03b1) :\n    (g \u2218 f) <$> x = g <$> f <$> x := by\n  rw [\u2190 abs_repr x]\n  cases' repr x with a f\n  rw [\u2190 abs_map, \u2190 abs_map, \u2190 abs_map]\n  rfl\n#align qpf.comp_map Qpf.comp_map\n\ntheorem lawfulFunctor\n    (h : \u2200 \u03b1 \u03b2 : Type u, @Functor.mapConst F _ \u03b1 _ = Functor.map \u2218 Function.const \u03b2) :\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 {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) (x : F \u03b1) :\n    Liftp p x \u2194 \u2203 a f, x = abs \u27e8a, f\u27e9 \u2227 \u2200 i, p (f i) :=\n  by\n  constructor\n  \u00b7 rintro \u27e8y, hy\u27e9\n    cases' h : repr y with a f\n    use a, fun i => (f i).val\n    constructor\n    \u00b7 rw [\u2190 hy, \u2190 abs_repr y, h, \u2190 abs_map]\n      rfl\n    intro i\n    apply (f i).property\n  rintro \u27e8a, f, h\u2080, h\u2081\u27e9; dsimp at *\n  use abs \u27e8a, fun i => \u27e8f i, h\u2081 i\u27e9\u27e9\n  rw [\u2190 abs_map, h\u2080]; rfl\n#align qpf.liftp_iff Qpf.liftp_iff\n\ntheorem liftp_iff' {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) (x : F \u03b1) :\n    Liftp p x \u2194 \u2203 u : q.p.Obj \u03b1, abs u = x \u2227 \u2200 i, p (u.snd i) :=\n  by\n  constructor\n  \u00b7 rintro \u27e8y, hy\u27e9\n    cases' h : repr y with a f\n    use \u27e8a, fun i => (f i).val\u27e9\n    dsimp\n    constructor\n    \u00b7 rw [\u2190 hy, \u2190 abs_repr y, h, \u2190 abs_map]\n      rfl\n    intro i\n    apply (f i).property\n  rintro \u27e8\u27e8a, f\u27e9, h\u2080, h\u2081\u27e9; dsimp at *\n  use abs \u27e8a, fun i => \u27e8f i, h\u2081 i\u27e9\u27e9\n  rw [\u2190 abs_map, \u2190 h\u2080]; rfl\n#align qpf.liftp_iff' Qpf.liftp_iff'\n\ntheorem liftr_iff {\u03b1 : Type u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (x y : F \u03b1) :\n    Liftr r x y \u2194 \u2203 a f\u2080 f\u2081, x = abs \u27e8a, f\u2080\u27e9 \u2227 y = abs \u27e8a, f\u2081\u27e9 \u2227 \u2200 i, r (f\u2080 i) (f\u2081 i) :=\n  by\n  constructor\n  \u00b7 rintro \u27e8u, xeq, yeq\u27e9\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    \u00b7 rw [\u2190 xeq, \u2190 abs_repr u, h, \u2190 abs_map]\n      rfl\n    constructor\n    \u00b7 rw [\u2190 yeq, \u2190 abs_repr u, h, \u2190 abs_map]\n      rfl\n    intro i\n    exact (f i).property\n  rintro \u27e8a, f\u2080, f\u2081, xeq, yeq, h\u27e9\n  use abs \u27e8a, fun i => \u27e8(f\u2080 i, f\u2081 i), h i\u27e9\u27e9\n  dsimp; constructor\n  \u00b7 rw [xeq, \u2190 abs_map]\n    rfl\n  rw [yeq, \u2190 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 \u03b1 \u2192 \u03b1` rather than `g : P \u03b1 \u2192 \u03b1` -/\ndef recF {\u03b1 : Type _} (g : F \u03b1 \u2192 \u03b1) : q.p.W \u2192 \u03b1\n  | \u27e8a, f\u27e9 => g (abs \u27e8a, fun x => recF (f x)\u27e9)\n#align qpf.recF Qpf.recF\n\ntheorem recF_eq {\u03b1 : Type _} (g : F \u03b1 \u2192 \u03b1) (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' {\u03b1 : Type _} (g : F \u03b1 \u2192 \u03b1) (a : q.p.A) (f : q.p.B a \u2192 q.p.W) :\n    recF g \u27e8a, f\u27e9 = g (abs (recF g <$> \u27e8a, f\u27e9)) :=\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 \u2192 q.p.W \u2192 Prop\n  | ind (a : q.p.A) (f f' : q.p.B a \u2192 q.p.W) : (\u2200 x, Wequiv (f x) (f' x)) \u2192 Wequiv \u27e8a, f\u27e9 \u27e8a, f'\u27e9\n  |\n  abs (a : q.p.A) (f : q.p.B a \u2192 q.p.W) (a' : q.p.A) (f' : q.p.B a' \u2192 q.p.W) :\n    abs \u27e8a, f\u27e9 = abs \u27e8a', f'\u27e9 \u2192 Wequiv \u27e8a, f\u27e9 \u27e8a', f'\u27e9\n  | trans (u v w : q.p.W) : Wequiv u v \u2192 Wequiv v w \u2192 Wequiv u w\n#align qpf.Wequiv Qpf.Wequiv\n\n/-- recF is insensitive to the representation -/\ntheorem recF_eq_of_wequiv {\u03b1 : Type u} (u : F \u03b1 \u2192 \u03b1) (x y : q.p.W) :\n    Wequiv x y \u2192 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\u2081 e\u2082 ih\u2081 ih\u2082 => exact Eq.trans ih\u2081 ih\u2082\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 \u2192 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\u2081 e\u2082 ih\u2081 ih\u2082 => exact Qpf.Wequiv.trans _ _ _ ih\u2082 ih\u2081\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 \u2192 q.p.W :=\n  recF (PFunctor.W.mk \u2218 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  \u00b7 change Wequiv (Wrepr \u27e8a, f\u27e9) (PFunctor.W.mk (Wrepr <$> \u27e8a, f\u27e9))\n    apply Wequiv.abs'\n    have : Wrepr \u27e8a, f\u27e9 = PFunctor.W.mk (repr (abs (Wrepr <$> \u27e8a, f\u27e9))) := 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  \u27e8Wequiv, @Wequiv.refl _ _ _, @Wequiv.symm _ _ _, @Wequiv.trans _ _ _\u27e9\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 \u2192 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 {\u03b1 : Type _} (g : F \u03b1 \u2192 \u03b1) : Fix F \u2192 \u03b1 :=\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 \u2192 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 \u2192 F (Fix F) :=\n  Fix.rec (Functor.map Fix.mk)\n#align qpf.fix.dest Qpf.Fix.dest\n\ntheorem Fix.rec_eq {\u03b1 : Type _} (g : F \u03b1 \u2192 \u03b1) (x : F (Fix F)) :\n    Fix.rec g (Fix.mk x) = g (Fix.rec g <$> x) :=\n  by\n  have : recF g \u2218 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, \u2190 PFunctor.map_eq, PFunctor.W.dest_mk, \u2190 PFunctor.comp_map, abs_map,\n    \u2190 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 \u2192 q.p.W) :\n    Fix.mk (abs \u27e8a, fun x => \u27e6f x\u27e7\u27e9) = \u27e6\u27e8a, f\u27e9\u27e7 :=\n  by\n  have : Fix.mk (abs \u27e8a, fun x => \u27e6f x\u27e7\u27e9) = \u27e6wrepr \u27e8a, f\u27e9\u27e7 :=\n    by\n    apply Quot.sound; apply Wequiv.abs'\n    rw [PFunctor.W.dest_mk, abs_map, abs_repr, \u2190 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 {\u03b1 : Type u} (g\u2081 g\u2082 : Fix F \u2192 \u03b1)\n    (h : \u2200 x : F (Fix F), g\u2081 <$> x = g\u2082 <$> x \u2192 g\u2081 (Fix.mk x) = g\u2082 (Fix.mk x)) : \u2200 x, g\u2081 x = g\u2082 x :=\n  by\n  apply Quot.ind\n  intro x\n  induction' x with a f ih\n  change g\u2081 \u27e6\u27e8a, f\u27e9\u27e7 = g\u2082 \u27e6\u27e8a, f\u27e9\u27e7\n  rw [\u2190 fix.ind_aux a f]; apply h\n  rw [\u2190 abs_map, \u2190 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 {\u03b1 : Type u} (g : F \u03b1 \u2192 \u03b1) (h : Fix F \u2192 \u03b1)\n    (hyp : \u2200 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, \u2190 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 \u2218 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, \u2190 fix.dest, \u2190 comp_map]\n  conv =>\n    rhs\n    rw [\u2190 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 \u2192 Prop) (h : \u2200 x : F (Fix F), Liftp p x \u2192 p (Fix.mk x)) : \u2200 x, p x :=\n  by\n  apply Quot.ind\n  intro x\n  induction' x with a f ih\n  change p \u27e6\u27e8a, f\u27e9\u27e7\n  rw [\u2190 fix.ind_aux a f]\n  apply h\n  rw [liftp_iff]\n  refine' \u27e8_, _, rfl, _\u27e9\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 \u2192 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 : \u03b1 \u2192 F \u03b1` rather than `g : \u03b1 \u2192 P \u03b1` -/\ndef corecF {\u03b1 : Type _} (g : \u03b1 \u2192 F \u03b1) : \u03b1 \u2192 q.p.M :=\n  PFunctor.M.corec fun x => repr (g x)\n#align qpf.corecF Qpf.corecF\n\ntheorem corecF_eq {\u03b1 : Type _} (g : \u03b1 \u2192 F \u03b1) (x : \u03b1) :\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 \u2192 q.p.M \u2192 Prop) : Prop :=\n  \u2200 \u2983x y\u2984, r x y \u2192 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 \u2192 q.p.M \u2192 Prop := fun x y => \u2203 r, IsPrecongr r \u2227 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 \u2192 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  \u27e8Quot.mk _ default\u27e9\n\n/-- corecursor for type defined by `cofix` -/\ndef Cofix.corec {\u03b1 : Type _} (g : \u03b1 \u2192 F \u03b1) (x : \u03b1) : 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 \u2192 F (Cofix F) :=\n  Quot.lift (fun x => Quot.mk Mcongr <$> abs (PFunctor.M.dest x))\n    (by\n      rintro x y \u27e8r, pr, rxy\u27e9\n      dsimp\n      have : \u2200 x y, r x y \u2192 Mcongr x y := by\n        intro x y h\n        exact \u27e8r, pr, h\u27e9\n      rw [\u2190 Quot.factor_mk_eq _ _ this]\n      dsimp\n      conv =>\n        lhs\n        rw [comp_map, \u2190 abs_map, pr rxy, abs_map, \u2190 comp_map])\n#align qpf.cofix.dest Qpf.Cofix.dest\n\ntheorem Cofix.dest_corec {\u03b1 : Type u} (g : \u03b1 \u2192 F \u03b1) (x : \u03b1) :\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, \u2190 comp_map]; rfl\n#align qpf.cofix.dest_corec Qpf.Cofix.dest_corec\n\nprivate theorem cofix.bisim_aux (r : Cofix F \u2192 Cofix F \u2192 Prop) (h' : \u2200 x, r x x)\n    (h : \u2200 x y, r x y \u2192 Quot.mk r <$> Cofix.dest x = Quot.mk r <$> Cofix.dest y) :\n    \u2200 x y, r x y \u2192 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\u2080 :\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\u2081 : \u2200 u v : q.P.M, Mcongr u v \u2192 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 \u2192 Quot r' :=\n      Quot.lift (Quot.lift (Quot.mk r') h\u2081)\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 \u2218 Quot.mk r \u2218 Quot.mk Mcongr = Quot.mk r' := rfl\n    rw [\u2190 this, PFunctor.comp_map _ _ f, PFunctor.comp_map _ _ (Quot.mk r), abs_map, abs_map,\n      abs_map, h\u2080]\n    rw [PFunctor.comp_map _ _ f, PFunctor.comp_map _ _ (Quot.mk r), abs_map, abs_map, abs_map]\n  refine' \u27e8r', this, rxy\u27e9\n#align qpf.cofix.bisim_aux qpf.cofix.bisim_aux\n\ntheorem Cofix.bisim_rel (r : Cofix F \u2192 Cofix F \u2192 Prop)\n    (h : \u2200 x y, r x y \u2192 Quot.mk r <$> Cofix.dest x = Quot.mk r <$> Cofix.dest y) :\n    \u2200 x y, r x y \u2192 x = y := by\n  let r' (x y) := x = y \u2228 r x y\n  intro x y rxy\n  apply cofix.bisim_aux r'\n  \u00b7 intro x\n    left\n    rfl\n  \u00b7 intro x y r'xy\n    cases r'xy\n    \u00b7 rw [r'xy]\n    have : \u2200 x y, r x y \u2192 r' x y := fun x y h => Or.inr h\n    rw [\u2190 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 \u2192 Cofix F \u2192 Prop)\n    (h : \u2200 x y, r x y \u2192 Liftr r (Cofix.dest x) (Cofix.dest y)) : \u2200 x y, r x y \u2192 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 \u27e8a, f\u2080, f\u2081, dxeq, dyeq, h'\u27e9\n  rw [dxeq, dyeq, \u2190 abs_map, \u2190 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' {\u03b1 : Type _} (Q : \u03b1 \u2192 Prop) (u v : \u03b1 \u2192 Cofix F)\n    (h :\n      \u2200 x,\n        Q x \u2192\n          \u2203 a f f',\n            Cofix.dest (u x) = abs \u27e8a, f\u27e9 \u2227\n              Cofix.dest (v x) = abs \u27e8a, f'\u27e9 \u2227 \u2200 i, \u2203 x', Q x' \u2227 f i = u x' \u2227 f' i = v x') :\n    \u2200 x, Q x \u2192 u x = v x := fun x Qx =>\n  let R := fun w z : Cofix F => \u2203 x', Q x' \u2227 w = u x' \u2227 z = v x'\n  Cofix.bisim R\n    (fun x y \u27e8x', Qx', xeq, yeq\u27e9 =>\n      by\n      rcases h x' Qx' with \u27e8a, f, f', ux'eq, vx'eq, h'\u27e9\n      rw [liftr_iff]\n      refine' \u27e8a, f, f', xeq.symm \u25b8 ux'eq, yeq.symm \u25b8 vx'eq, h'\u27e9)\n    _ _ \u27e8x, Qx, rfl, rfl\u27e9\n#align qpf.cofix.bisim' Qpf.Cofix.bisim'\n\nend Qpf\n\n/-\nComposition of qpfs.\n-/\nnamespace Qpf\n\nvariable {F\u2082 : Type u \u2192 Type u} [Functor F\u2082] [q\u2082 : Qpf F\u2082]\n\nvariable {F\u2081 : Type u \u2192 Type u} [Functor F\u2081] [q\u2081 : Qpf F\u2081]\n\ninclude q\u2082 q\u2081\n\n/-- composition of qpfs gives another qpf  -/\ndef comp : Qpf (Functor.Comp F\u2082 F\u2081)\n    where\n  p := PFunctor.comp q\u2082.p q\u2081.p\n  abs \u03b1 := by\n    dsimp [Functor.Comp]\n    intro p\n    exact abs \u27e8p.1.1, fun x => abs \u27e8p.1.2 x, fun y => p.2 \u27e8x, y\u27e9\u27e9\u27e9\n  repr \u03b1 := by\n    dsimp [Functor.Comp]\n    intro y\n    refine' \u27e8\u27e8(repr y).1, fun u => (repr ((repr y).2 u)).1\u27e9, _\u27e9\n    dsimp [PFunctor.comp]\n    intro x\n    exact (repr ((repr y).2 x.1)).snd x.2\n  abs_repr \u03b1 := by\n    abstract \n      dsimp [Functor.Comp]\n      intro x\n      conv =>\n        rhs\n        rw [\u2190 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 [\u2190 h', abs_repr]\n  abs_map \u03b1 \u03b2 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 [\u2190 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 \u2192 Type u} [Functor F] [q : Qpf F]\n\nvariable {G : Type u \u2192 Type u} [Functor G]\n\nvariable {FG_abs : \u2200 {\u03b1}, F \u03b1 \u2192 G \u03b1}\n\nvariable {FG_repr : \u2200 {\u03b1}, G \u03b1 \u2192 F \u03b1}\n\n/-- Given a qpf `F` and a well-behaved surjection `FG_abs` from F \u03b1 to\nfunctor G \u03b1, `G` is a qpf. We can consider `G` a quotient on `F` where\nelements `x y : F \u03b1` are in the same equivalence class if\n`FG_abs x = FG_abs y`  -/\ndef quotientQpf (FG_abs_repr : \u2200 {\u03b1} (x : G \u03b1), FG_abs (FG_repr x) = x)\n    (FG_abs_map : \u2200 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (x : F \u03b1), FG_abs (f <$> x) = f <$> FG_abs x) : Qpf G\n    where\n  p := q.p\n  abs {\u03b1} p := FG_abs (abs p)\n  repr {\u03b1} x := repr (FG_repr x)\n  abs_repr {\u03b1} x := by rw [abs_repr, FG_abs_repr]\n  abs_map {\u03b1 \u03b2} 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 \u2192 Type u} [Functor F] [q : Qpf F]\n\ninclude q\n\nopen Functor (Liftp Liftr supp)\n\nopen Set\n\ntheorem mem_supp {\u03b1 : Type u} (x : F \u03b1) (u : \u03b1) :\n    u \u2208 supp x \u2194 \u2200 a f, abs \u27e8a, f\u27e9 = x \u2192 u \u2208 f '' univ :=\n  by\n  rw [supp]; dsimp; constructor\n  \u00b7 intro h a f haf\n    have : liftp (fun u => u \u2208 f '' univ) x :=\n      by\n      rw [liftp_iff]\n      refine' \u27e8a, f, haf.symm, fun i => mem_image_of_mem _ (mem_univ _)\u27e9\n    exact h this\n  intro h p; rw [liftp_iff]\n  rintro \u27e8a, f, xeq, h'\u27e9\n  rcases h a f xeq.symm with \u27e8i, _, hi\u27e9\n  rw [\u2190 hi]; apply h'\n#align qpf.mem_supp Qpf.mem_supp\n\ntheorem supp_eq {\u03b1 : Type u} (x : F \u03b1) : supp x = { u | \u2200 a f, abs \u27e8a, f\u27e9 = x \u2192 u \u2208 f '' univ } :=\n  by ext <;> apply mem_supp\n#align qpf.supp_eq Qpf.supp_eq\n\ntheorem has_good_supp_iff {\u03b1 : Type u} (x : F \u03b1) :\n    (\u2200 p, Liftp p x \u2194 \u2200 u \u2208 supp x, p u) \u2194\n      \u2203 a f, abs \u27e8a, f\u27e9 = x \u2227 \u2200 a' f', abs \u27e8a', f'\u27e9 = x \u2192 f '' univ \u2286 f' '' univ :=\n  by\n  constructor\n  \u00b7 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 \u27e8a, f, xeq, h'\u27e9\n    refine' \u27e8a, f, xeq.symm, _\u27e9\n    intro a' f' h''\n    rintro u \u27e8i, _, hfi\u27e9\n    have : u \u2208 supp x := by rw [\u2190 hfi] <;> apply h'\n    exact (mem_supp x u).mp this _ _ h''\n  rintro \u27e8a, f, xeq, h\u27e9 p; rw [liftp_iff]; constructor\n  \u00b7 rintro \u27e8a', f', xeq', h'\u27e9 u usuppx\n    rcases(mem_supp x u).mp usuppx a' f' xeq'.symm with \u27e8i, _, f'ieq\u27e9\n    rw [\u2190 f'ieq]\n    apply h'\n  intro h'\n  refine' \u27e8a, f, xeq.symm, _\u27e9; 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  \u2200 \u2983\u03b1 : Type u\u2984 (a a' : q.p.A) (f : q.p.B a \u2192 \u03b1) (f' : q.p.B a' \u2192 \u03b1),\n    abs \u27e8a, f\u27e9 = abs \u27e8a', f'\u27e9 \u2192 f '' univ = f' '' univ\n#align qpf.is_uniform Qpf.IsUniform\n\n/-- does `abs` preserve `liftp`? -/\ndef LiftpPreservation : Prop :=\n  \u2200 \u2983\u03b1\u2984 (p : \u03b1 \u2192 Prop) (x : q.p.Obj \u03b1), Liftp p (abs x) \u2194 Liftp p x\n#align qpf.liftp_preservation Qpf.LiftpPreservation\n\n/-- does `abs` preserve `supp`? -/\ndef SuppPreservation : Prop :=\n  \u2200 \u2983\u03b1\u2984 (x : q.p.Obj \u03b1), supp (abs x) = supp x\n#align qpf.supp_preservation Qpf.SuppPreservation\n\nvariable (q)\n\ntheorem supp_eq_of_isUniform (h : q.IsUniform) {\u03b1 : Type u} (a : q.p.A) (f : q.p.B a \u2192 \u03b1) :\n    supp (abs \u27e8a, f\u27e9) = f '' univ := by\n  ext u; rw [mem_supp]; constructor\n  \u00b7 intro h'\n    apply h' _ _ rfl\n  intro h' a' f' e\n  rw [\u2190 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) {\u03b1 : Type u} (x : F \u03b1) (p : \u03b1 \u2192 Prop) :\n    Liftp p x \u2194 \u2200 u \u2208 supp x, p u :=\n  by\n  rw [liftp_iff, \u2190 abs_repr x]\n  cases' repr x with a f; constructor\n  \u00b7 rintro \u27e8a', f', abseq, hf\u27e9 u\n    rw [supp_eq_of_is_uniform h, h _ _ _ _ abseq]\n    rintro \u27e8i, _, hi\u27e9\n    rw [\u2190 hi]\n    apply hf\n  intro h'\n  refine' \u27e8a, f, rfl, fun i => h' _ _\u27e9\n  rw [supp_eq_of_is_uniform h]\n  exact \u27e8i, mem_univ i, rfl\u27e9\n#align qpf.liftp_iff_of_is_uniform Qpf.liftp_iff_of_isUniform\n\ntheorem supp_map (h : q.IsUniform) {\u03b1 \u03b2 : Type u} (g : \u03b1 \u2192 \u03b2) (x : F \u03b1) :\n    supp (g <$> x) = g '' supp x := by\n  rw [\u2190 abs_repr x]; cases' repr x with a f; rw [\u2190 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 \u2194 q.IsUniform :=\n  by\n  constructor\n  \u00b7 intro h \u03b1 a a' f f' h'\n    rw [\u2190 PFunctor.supp_eq, \u2190 PFunctor.supp_eq, \u2190 h, h', h]\n  \u00b7 rintro h \u03b1 \u27e8a, f\u27e9\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 \u2194 q.LiftpPreservation :=\n  by\n  constructor <;> intro h\n  \u00b7 rintro \u03b1 p \u27e8a, f\u27e9\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    \u00b7 simp only [image_univ, mem_range, exists_imp]\n      constructor <;> intros <;> subst_vars <;> solve_by_elim\n  \u00b7 rintro \u03b1 \u27e8a, f\u27e9\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 \u2194 q.IsUniform := by\n  rw [\u2190 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 `\u03b1`, we take the colimit of the filtered\ndiagram of all coproducts of finite subsets of `\u03b1`.\n\nWe also deduce the dual statement by invoking the original statement in `C\u1d52\u1d56`.\n-/\n\n\nuniverse w v u\n\nnoncomputable section\n\nopen CategoryTheory\n\nvariable {C : Type u} [Category.{v} C] {\u03b1 : Type w}\n\nnamespace CategoryTheory.Limits\n\nnamespace CoproductsFromFiniteFiltered\n\n/-- If `C` has finite coproducts, a functor `Discrete \u03b1 \u2964 C` lifts to a functor\n    `Finset (Discrete \u03b1) \u2964 C` by taking coproducts. -/\n@[simps!]\ndef liftToFinset [HasFiniteCoproducts C] (F : Discrete \u03b1 \u2964 C) : Finset (Discrete \u03b1) \u2964 C where\n  obj s := \u2210 fun x : s => F.obj x\n  map {_ Y} h := Sigma.desc fun y =>\n    Sigma.\u03b9 (fun (x : { x // x \u2208 Y }) => F.obj x) \u27e8y, h.down.down y.2\u27e9\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 \u03b1] (F : Discrete \u03b1 \u2964 C) : ColimitCocone F where\n  cocone :=\n    { pt := colimit (liftToFinset F)\n      \u03b9 :=\n        Discrete.natTrans fun j =>\n          @Sigma.\u03b9 _ _ _ (fun x : ({j} : Finset (Discrete \u03b1)) => F.obj x) _ \u27e8j, by simp\u27e9 \u226b\n            colimit.\u03b9 (liftToFinset F) {j} }\n  isColimit :=\n    { desc := fun s =>\n        colimit.desc (liftToFinset F)\n          { pt := s.pt\n            \u03b9 := { app := fun t => Sigma.desc fun x => s.\u03b9.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 \u27e8\u27e8j, hj\u27e9\u27e9\n        convert h j using 1\n        . simp [\u2190 colimit.w (liftToFinset F) \u27e8\u27e8Finset.singleton_subset_iff.2 hj\u27e9\u27e9]\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 \u03b1 => by\n  classical exact \u27e8fun F => HasColimit.mk (liftToFinsetColimitCocone F)\u27e9\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\u1d52\u1d56 := 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 \u2228 q \u2228 r) \u2227 (q \u2228 p \u2228 r) \u2227 (q \u2228 r \u2228 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 \u2228 q \u2228 r) \u2227 (q \u2228 p \u2228 r) \u2227 (q \u2228 r \u2228 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": "import game.limits.bounded_if_convergent -- hide\nimport game.limits.Lemmas -- hide\nimport game.limits.Blockus_time -- hide\nimport game.sets.L01defs -- hide\nimport game.sup_inf.GLBprop_if_LUBprop -- hide\nimport data.real.basic -- hide\nimport tactic.linarith -- hide\n\nnamespace xena -- hide\n\n/-\n# Chapter 7 : Limits\n\n## Level 6\n\nIn this proof you will be showing that if you have two real numbers a and b in which b is positive.\nand multiply them together, the product will be \u2264 e * b if a \u2264 e. This is true regardless of\nwhat is being added to a * b or e * b as long as it is consistent. \nJust like the last proof this should be a pretty obvious fact but to Lean it isn't trivial.\n\nYou will also be given some lemmas that are trivial that will not need to be proved but\nwill be useful in proving lim_mul.\n\n-/\n\n/-\nLemma : mul_div_mul_self\n{a b c : \u211d} (h1 : 0 < a) (h2 : 0 < c) :  (b * a) / (c * a) = b/ c\n-/\n\n/-\nLemma : so_obvious \n{a b c d: \u211d} (hb : 0 < b) (hc : 0 < c): a * b + c * d < a * b + b + d * c + c\n-/\n\n\nlemma pos_mul_pos_add_pos_mul_pos_le2 {a b c d e: \u211d} (hb : 0 \u2264 b) \n  (hae: a \u2264 e): a * b + c * d \u2264 e * b + c * d :=\nbegin\nhave L1 : b \u2264 b, linarith, \nhave L2 : a * b \u2264 e * b, \nexact mul_le_mul_right1 hb hae,  \nlinarith, \n\nend \n\n\n\n\n\n\nend xena -- hide", "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/Limit_Lemmas/Level05.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "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 \u27f6 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 \u27f6 R` is mono if and only if `g \u226b f = 0 \u2192 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 \u226b (-g)` and `(-f) \u226b g` both become `-(f \u226b g)`, and `(-f) \u226b (-g)`\nis simplified to `f \u226b 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 \u27f6 Q` is an abelian group such that composition is\n    linear in both variables. -/\nclass preadditive :=\n(hom_group : \u03a0 P Q : C, add_comm_group (P \u27f6 Q) . tactic.apply_instance)\n(add_comp' : \u2200 (P Q R : C) (f f' : P \u27f6 Q) (g : Q \u27f6 R),\n  (f + f') \u226b g = f \u226b g + f' \u226b g . obviously)\n(comp_add' : \u2200 (P Q R : C) (f : P \u27f6 Q) (g g' : Q \u27f6 R),\n  f \u226b (g + g') = f \u226b g + f \u226b 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 \u2192 C)\n\ninstance induced_category.category : preadditive.{v} (induced_category C F) :=\n{ hom_group := \u03bb P Q, @preadditive.hom_group C _ _ (F P) (F Q),\n  add_comp' := \u03bb P Q R f f' g, add_comp' _ _ _ _ _ _,\n  comp_add' := \u03bb 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 := \u03bb f g h, preadditive.add_comp X X X g h f,\n  right_distrib := \u03bb 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 \u27f6 Q) : (Q \u27f6 R) \u2192+ (P \u27f6 R) :=\nmk' (\u03bb g, f \u226b g) $ \u03bb 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 \u27f6 R) : (P \u27f6 Q) \u2192+ (P \u27f6 R) :=\nmk' (\u03bb f, f \u226b g) $ \u03bb f f', by simp\n\nvariables {P Q R : C} (f f' : P \u27f6 Q) (g g' : Q \u27f6 R)\n\n/-- Composition as a bilinear group homomorphism -/\ndef comp_hom : (P \u27f6 Q) \u2192+ (Q \u27f6 R) \u2192+ (P \u27f6 R) :=\nadd_monoid_hom.mk' (\u03bb f, left_comp _ f) $\n  \u03bb f\u2081 f\u2082, add_monoid_hom.ext $ \u03bb g, (right_comp _ g).map_add f\u2081 f\u2082\n\n@[simp, reassoc] lemma sub_comp :\n  (f - f') \u226b g = f \u226b g - f' \u226b 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 \u226b (g - g') = f \u226b g - f \u226b g' :=\nmap_sub (left_comp R f) g g'\n\n@[simp, reassoc] lemma neg_comp : (-f) \u226b g = -(f \u226b 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 \u226b (-g) = -(f \u226b g) :=\nmap_neg (left_comp R f) g\n\n@[reassoc] lemma neg_comp_neg : (-f) \u226b (-g) = f \u226b g :=\nby simp\n\nlemma nsmul_comp (n : \u2115) : (n \u2022 f) \u226b g = n \u2022 (f \u226b g) :=\nmap_nsmul (right_comp P g) n f\n\nlemma comp_nsmul (n : \u2115) : f \u226b (n \u2022 g) = n \u2022 (f \u226b g) :=\nmap_nsmul (left_comp R f) n g\n\nlemma zsmul_comp (n : \u2124) : (n \u2022 f) \u226b g = n \u2022 (f \u226b g) :=\nmap_zsmul (right_comp P g) n f\n\nlemma comp_zsmul (n : \u2124) : f \u226b (n \u2022 g) = n \u2022 (f \u226b 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 \u27f6 Q) (g : J \u2192 (Q \u27f6 R)) :\n  f \u226b \u2211 j in s, g j = \u2211 j in s, f \u226b 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 \u2192 (P \u27f6 Q)) (g : Q \u27f6 R) :\n  (\u2211 j in s, f j) \u226b g  = \u2211 j in s, f j \u226b g :=\nmap_sum (right_comp P g) _ _\n\ninstance {P Q : C} {f : P \u27f6 Q} [epi f] : epi (-f) :=\n\u27e8\u03bb R g g' H, by rwa [neg_comp, neg_comp, \u2190comp_neg, \u2190comp_neg, cancel_epi, neg_inj] at H\u27e9\n\ninstance {P Q : C} {f : P \u27f6 Q} [mono f] : mono (-f) :=\n\u27e8\u03bb R g g' H, by rwa [comp_neg, comp_neg, \u2190neg_comp, \u2190neg_comp, cancel_mono, neg_inj] at H\u27e9\n\n@[priority 100]\ninstance preadditive_has_zero_morphisms : has_zero_morphisms C :=\n{ has_zero := infer_instance,\n  comp_zero' := \u03bb P Q f R, show left_comp R f 0 = 0, from map_zero _,\n  zero_comp' := \u03bb 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 \u27f6 Y) :=\n{ smul_add := \u03bb r f g, add_comp _ _ _ _ _ _,\n  smul_zero := \u03bb r, zero_comp,\n  add_smul := \u03bb r s f, comp_add _ _ _ _ _ _,\n  zero_smul := \u03bb r, comp_zero }\n\nlemma mono_of_cancel_zero {Q R : C} (f : Q \u27f6 R) (h : \u2200 {P : C} (g : P \u27f6 Q), g \u226b f = 0 \u2192 g = 0) :\n  mono f :=\n\u27e8\u03bb P g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (right_comp P f) g g').trans $ sub_eq_zero.2 hg\u27e9\n\nlemma mono_iff_cancel_zero {Q R : C} (f : Q \u27f6 R) :\n  mono f \u2194 \u2200 (P : C) (g : P \u27f6 Q), g \u226b f = 0 \u2192 g = 0 :=\n\u27e8\u03bb m P g, by exactI zero_of_comp_mono _, mono_of_cancel_zero f\u27e9\n\nlemma mono_of_kernel_zero {X Y : C} {f : X \u27f6 Y} [has_limit (parallel_pair f 0)]\n  (w : kernel.\u03b9 f = 0) : mono f :=\nmono_of_cancel_zero f (\u03bb P g h, by rw [\u2190kernel.lift_\u03b9 f g h, w, limits.comp_zero])\n\nlemma epi_of_cancel_zero {P Q : C} (f : P \u27f6 Q) (h : \u2200 {R : C} (g : Q \u27f6 R), f \u226b g = 0 \u2192 g = 0) :\n  epi f :=\n\u27e8\u03bb R g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (left_comp R f) g g').trans $ sub_eq_zero.2 hg\u27e9\n\nlemma epi_iff_cancel_zero {P Q : C} (f : P \u27f6 Q) :\n  epi f \u2194 \u2200 (R : C) (g : Q \u27f6 R), f \u226b g = 0 \u2192 g = 0 :=\n\u27e8\u03bb e R g, by exactI zero_of_epi_comp _, epi_of_cancel_zero f\u27e9\n\nlemma epi_of_cokernel_zero {X Y : C} {f : X \u27f6 Y} [has_colimit (parallel_pair f 0 )]\n  (w : cokernel.\u03c0 f = 0) : epi f :=\nepi_of_cancel_zero f (\u03bb P g h, by rw [\u2190cokernel.\u03c0_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 \u226b g = 0 \u2194 g = 0 :=\nby rw [\u2190 is_iso.eq_inv_comp, limits.comp_zero]\n\n@[simp] lemma comp_right_eq_zero [is_iso g] :\n  f \u226b g = 0 \u2194 f = 0 :=\nby rw [\u2190 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 \u27f6 Y} [has_limit (parallel_pair f 0)]\n  (w : kernel f \u2245 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 \u27f6 Y} [has_colimit (parallel_pair f 0)]\n  (w : cokernel f \u2245 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 \u27f6 Y} {g : X \u27f6 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_\u03b9 c.\u03b9 $ by rw [\u2190 sub_eq_zero, \u2190 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_\u03b9 c.\u03b9 $ by rw [comp_sub, comp_zero, sub_eq_zero, c.condition]\n\n@[simp] lemma kernel_fork_of_fork_\u03b9 (c : fork f g) : (kernel_fork_of_fork c).\u03b9 = c.\u03b9 := rfl\n\n@[simp] lemma kernel_fork_of_fork_of_\u03b9 {P : C} (\u03b9 : P \u27f6 X) (w : \u03b9 \u226b f = \u03b9 \u226b g) :\n  (kernel_fork_of_fork (fork.of_\u03b9 \u03b9 w)) = kernel_fork.of_\u03b9 \u03b9 (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' _ $ \u03bb s,\n  \u27e8i.lift (kernel_fork_of_fork s), i.fac _ _,\n   \u03bb m h, by apply fork.is_limit.hom_ext i; tidy\u27e9\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' _ $ \u03bb s,\n  \u27e8i.lift (fork_of_kernel_fork s), i.fac _ _,\n    \u03bb m h, by apply fork.is_limit.hom_ext i; tidy\u27e9\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_\u03c0 c.\u03c0 $ by rw [\u2190 sub_eq_zero, \u2190 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_\u03c0 c.\u03c0 $ by rw [sub_comp, zero_comp, sub_eq_zero, c.condition]\n\n@[simp] lemma cokernel_cofork_of_cofork_\u03c0 (c : cofork f g) :\n  (cokernel_cofork_of_cofork c).\u03c0 = c.\u03c0 := rfl\n\n@[simp] lemma cokernel_cofork_of_cofork_of_\u03c0 {P : C} (\u03c0 : Y \u27f6 P) (w : f \u226b \u03c0 = g \u226b \u03c0) :\n  (cokernel_cofork_of_cofork (cofork.of_\u03c0 \u03c0 w)) = cokernel_cofork.of_\u03c0 \u03c0 (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' _ $ \u03bb s,\n  \u27e8i.desc (cokernel_cofork_of_cofork s), i.fac _ _,\n    \u03bb m h, by apply cofork.is_colimit.hom_ext i; tidy\u27e9\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' _ $ \u03bb s,\n  \u27e8i.desc (cofork_of_cokernel_cofork s), i.fac _ _,\n    \u03bb m h, by apply cofork.is_colimit.hom_ext i; tidy\u27e9\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 _ _ (\u03bb _ _ 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 _ _ (\u03bb _ _ 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u211a` and prove basic lemmas about it.\nMoreoever, we provide the expected casts from `\u2115` and `\u2124` into `\u211a`, i.e. `(\u2191n : \u211a) = n / 1`.\n\n## Main Definitions\n\n- `rat` is the structure encoding `\u211a`.\n- `rat.mk n d` constructs a rational number `q = n / d` from `n d : \u2124`.\n\n## Notations\n\n- `/.` is infix notation for `rat.mk`.\n\n## Tags\n\nrat, rationals, field, \u211a, numerator, denominator, num, denom\n-/\n\n/-- `rat`, or `\u211a`, is the type of rational numbers. It is defined\n  as the set of pairs \u27e8n, d\u27e9 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 : \u2124) (denom : \u2115) (pos : 0 < denom) (cop : nat.coprime (int.nat_abs num) denom)\n\nnotation:1024 \"\u211a\" => Mathlib.rat\n\nnamespace rat\n\n\nprotected def repr : \u211a \u2192 string := sorry\n\nprotected instance has_repr : has_repr \u211a := has_repr.mk rat.repr\n\nprotected instance has_to_string : has_to_string \u211a := has_to_string.mk rat.repr\n\nprotected instance encodable : encodable \u211a :=\n  encodable.of_equiv\n    (sigma fun (n : \u2124) => Subtype fun (d : \u2115) => 0 < d \u2227 nat.coprime (int.nat_abs n) d)\n    (equiv.mk (fun (_x : \u211a) => sorry)\n      (fun\n        (_x : sigma fun (n : \u2124) => Subtype fun (d : \u2115) => 0 < d \u2227 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 : \u2124) : \u211a := mk' n 1 nat.one_pos sorry\n\nprotected instance has_zero : HasZero \u211a := { zero := of_int 0 }\n\nprotected instance has_one : HasOne \u211a := { one := of_int 1 }\n\nprotected instance inhabited : Inhabited \u211a := { default := 0 }\n\n/-- Form the quotient `n / d` where `n:\u2124` and `d:\u2115+` (not necessarily coprime) -/\ndef mk_pnat (n : \u2124) : \u2115+ \u2192 \u211a := sorry\n\n/-- Form the quotient `n / d` where `n:\u2124` and `d:\u2115`. In the case `d = 0`, we\n  define `n / 0 = 0` by convention. -/\ndef mk_nat (n : \u2124) (d : \u2115) : \u211a :=\n  dite (d = 0) (fun (d0 : d = 0) => 0)\n    fun (d0 : \u00acd = 0) => mk_pnat n { val := d, property := nat.pos_of_ne_zero d0 }\n\n/-- Form the quotient `n / d` where `n d : \u2124`. -/\ndef mk : \u2124 \u2192 \u2124 \u2192 \u211a := sorry\n\ntheorem mk_pnat_eq (n : \u2124) (d : \u2115) (h : 0 < d) : mk_pnat n { val := d, property := h } = mk n \u2191d :=\n  sorry\n\ntheorem mk_nat_eq (n : \u2124) (d : \u2115) : mk_nat n d = mk n \u2191d := rfl\n\n@[simp] theorem mk_zero (n : \u2124) : mk n 0 = 0 := rfl\n\n@[simp] theorem zero_mk_pnat (n : \u2115+) : mk_pnat 0 n = 0 := sorry\n\n@[simp] theorem zero_mk_nat (n : \u2115) : mk_nat 0 n = 0 := sorry\n\n@[simp] theorem zero_mk (n : \u2124) : mk 0 n = 0 := sorry\n\n@[simp] theorem mk_eq_zero {a : \u2124} {b : \u2124} (b0 : b \u2260 0) : mk a b = 0 \u2194 a = 0 := sorry\n\ntheorem mk_eq {a : \u2124} {b : \u2124} {c : \u2124} {d : \u2124} (hb : b \u2260 0) (hd : d \u2260 0) :\n    mk a b = mk c d \u2194 a * d = c * b :=\n  sorry\n\n@[simp] theorem div_mk_div_cancel_left {a : \u2124} {b : \u2124} {c : \u2124} (c0 : c \u2260 0) :\n    mk (a * c) (b * c) = mk a b :=\n  sorry\n\n@[simp] theorem num_denom {a : \u211a} : mk (num a) \u2191(denom a) = a := sorry\n\ntheorem num_denom' {n : \u2124} {d : \u2115} {h : 0 < d} {c : nat.coprime (int.nat_abs n) d} :\n    mk' n d h c = mk n \u2191d :=\n  Eq.symm num_denom\n\ntheorem of_int_eq_mk (z : \u2124) : of_int z = mk z 1 := num_denom'\n\ndef num_denom_cases_on {C : \u211a \u2192 Sort u} (a : \u211a)\n    (H : (n : \u2124) \u2192 (d : \u2115) \u2192 0 < d \u2192 nat.coprime (int.nat_abs n) d \u2192 C (mk n \u2191d)) : C a :=\n  sorry\n\ndef num_denom_cases_on' {C : \u211a \u2192 Sort u} (a : \u211a) (H : (n : \u2124) \u2192 (d : \u2115) \u2192 d \u2260 0 \u2192 C (mk n \u2191d)) :\n    C a :=\n  num_denom_cases_on a\n    fun (n : \u2124) (d : \u2115) (h : 0 < d) (c : nat.coprime (int.nat_abs n) d) => H n d sorry\n\ntheorem num_dvd (a : \u2124) {b : \u2124} (b0 : b \u2260 0) : num (mk a b) \u2223 a := sorry\n\ntheorem denom_dvd (a : \u2124) (b : \u2124) : \u2191(denom (mk a b)) \u2223 b := sorry\n\nprotected def add : \u211a \u2192 \u211a \u2192 \u211a := sorry\n\nprotected instance has_add : Add \u211a := { add := rat.add }\n\ntheorem lift_binop_eq (f : \u211a \u2192 \u211a \u2192 \u211a) (f\u2081 : \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124) (f\u2082 : \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124)\n    (fv :\n      \u2200 {n\u2081 : \u2124} {d\u2081 : \u2115} {h\u2081 : 0 < d\u2081} {c\u2081 : nat.coprime (int.nat_abs n\u2081) d\u2081} {n\u2082 : \u2124} {d\u2082 : \u2115}\n        {h\u2082 : 0 < d\u2082} {c\u2082 : nat.coprime (int.nat_abs n\u2082) d\u2082},\n        f (mk' n\u2081 d\u2081 h\u2081 c\u2081) (mk' n\u2082 d\u2082 h\u2082 c\u2082) = mk (f\u2081 n\u2081 (\u2191d\u2081) n\u2082 \u2191d\u2082) (f\u2082 n\u2081 (\u2191d\u2081) n\u2082 \u2191d\u2082))\n    (f0 : \u2200 {n\u2081 d\u2081 n\u2082 d\u2082 : \u2124}, d\u2081 \u2260 0 \u2192 d\u2082 \u2260 0 \u2192 f\u2082 n\u2081 d\u2081 n\u2082 d\u2082 \u2260 0) (a : \u2124) (b : \u2124) (c : \u2124) (d : \u2124)\n    (b0 : b \u2260 0) (d0 : d \u2260 0)\n    (H :\n      \u2200 {n\u2081 d\u2081 n\u2082 d\u2082 : \u2124},\n        a * d\u2081 = n\u2081 * b \u2192\n          c * d\u2082 = n\u2082 * d \u2192 f\u2081 n\u2081 d\u2081 n\u2082 d\u2082 * f\u2082 a b c d = f\u2081 a b c d * f\u2082 n\u2081 d\u2081 n\u2082 d\u2082) :\n    f (mk a b) (mk c d) = mk (f\u2081 a b c d) (f\u2082 a b c d) :=\n  sorry\n\n@[simp] theorem add_def {a : \u2124} {b : \u2124} {c : \u2124} {d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 0) :\n    mk a b + mk c d = mk (a * d + c * b) (b * d) :=\n  sorry\n\nprotected def neg : \u211a \u2192 \u211a := sorry\n\nprotected instance has_neg : Neg \u211a := { neg := rat.neg }\n\n@[simp] theorem neg_def {a : \u2124} {b : \u2124} : -mk a b = mk (-a) b := sorry\n\nprotected def mul : \u211a \u2192 \u211a \u2192 \u211a := sorry\n\nprotected instance has_mul : Mul \u211a := { mul := rat.mul }\n\n@[simp] theorem mul_def {a : \u2124} {b : \u2124} {c : \u2124} {d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 0) :\n    mk a b * mk c d = mk (a * c) (b * d) :=\n  sorry\n\nprotected def inv : \u211a \u2192 \u211a := sorry\n\nprotected instance has_inv : has_inv \u211a := has_inv.mk rat.inv\n\n@[simp] theorem inv_def {a : \u2124} {b : \u2124} : mk a b\u207b\u00b9 = mk b a := sorry\n\nprotected theorem add_zero (a : \u211a) : a + 0 = a := sorry\n\nprotected theorem zero_add (a : \u211a) : 0 + a = a := sorry\n\nprotected theorem add_comm (a : \u211a) (b : \u211a) : a + b = b + a := sorry\n\nprotected theorem add_assoc (a : \u211a) (b : \u211a) (c : \u211a) : a + b + c = a + (b + c) := sorry\n\nprotected theorem add_left_neg (a : \u211a) : -a + a = 0 := sorry\n\nprotected theorem mul_one (a : \u211a) : a * 1 = a := sorry\n\nprotected theorem one_mul (a : \u211a) : 1 * a = a := sorry\n\nprotected theorem mul_comm (a : \u211a) (b : \u211a) : a * b = b * a := sorry\n\nprotected theorem mul_assoc (a : \u211a) (b : \u211a) (c : \u211a) : a * b * c = a * (b * c) := sorry\n\nprotected theorem add_mul (a : \u211a) (b : \u211a) (c : \u211a) : (a + b) * c = a * c + b * c := sorry\n\nprotected theorem mul_add (a : \u211a) (b : \u211a) (c : \u211a) : a * (b + c) = a * b + a * c := sorry\n\nprotected theorem zero_ne_one : 0 \u2260 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 : \u211a) : a \u2260 0 \u2192 a * (a\u207b\u00b9) = 1 := sorry\n\nprotected theorem inv_mul_cancel (a : \u211a) (h : a \u2260 0) : a\u207b\u00b9 * a = 1 :=\n  Eq.trans (rat.mul_comm (a\u207b\u00b9) a) (rat.mul_inv_cancel a h)\n\nprotected instance decidable_eq : DecidableEq \u211a :=\n  id\n    fun (_v : \u211a) =>\n      cases_on _v\n        fun (num : \u2124) (denom : \u2115) (pos : 0 < denom) (cop : nat.coprime (int.nat_abs num) denom)\n          (w : \u211a) =>\n          cases_on w\n            fun (w_num : \u2124) (w_denom : \u2115) (w_pos : 0 < w_denom)\n              (w_cop : nat.coprime (int.nat_abs w_num) w_denom) =>\n              decidable.by_cases\n                (fun (\u1fb0 : num = w_num) =>\n                  Eq._oldrec\n                    (fun (w_cop : nat.coprime (int.nat_abs num) w_denom) =>\n                      decidable.by_cases\n                        (fun (\u1fb0 : 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                            \u1fb0 w_pos w_cop)\n                        fun (\u1fb0 : \u00acdenom = w_denom) => isFalse sorry)\n                    \u1fb0 w_cop)\n                fun (\u1fb0 : \u00acnum = w_num) => isFalse sorry\n\nprotected instance field : field \u211a :=\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 \u211a := field.to_division_ring\n\n-- TODO(Mario): this instance slows down data.real.basic\n\nprotected instance integral_domain : integral_domain \u211a := field.to_integral_domain\n\n--instance : domain \u211a           := by apply_instance\n\nprotected instance nontrivial : nontrivial \u211a := euclidean_domain.to_nontrivial \u211a\n\n--instance : ring \u211a             := by apply_instance\n\nprotected instance comm_ring : comm_ring \u211a := euclidean_domain.to_comm_ring \u211a\n\nprotected instance comm_semiring : comm_semiring \u211a := comm_ring.to_comm_semiring\n\nprotected instance semiring : semiring \u211a := ring.to_semiring\n\nprotected instance add_comm_group : add_comm_group \u211a := ring.to_add_comm_group \u211a\n\nprotected instance add_group : add_group \u211a := add_comm_group.to_add_group \u211a\n\nprotected instance add_comm_monoid : add_comm_monoid \u211a := add_comm_group.to_add_comm_monoid \u211a\n\nprotected instance add_monoid : add_monoid \u211a := sub_neg_monoid.to_add_monoid \u211a\n\nprotected instance add_left_cancel_semigroup : add_left_cancel_semigroup \u211a :=\n  add_left_cancel_monoid.to_add_left_cancel_semigroup \u211a\n\nprotected instance add_right_cancel_semigroup : add_right_cancel_semigroup \u211a :=\n  add_right_cancel_monoid.to_add_right_cancel_semigroup \u211a\n\nprotected instance add_comm_semigroup : add_comm_semigroup \u211a :=\n  add_comm_monoid.to_add_comm_semigroup \u211a\n\nprotected instance add_semigroup : add_semigroup \u211a := add_monoid.to_add_semigroup \u211a\n\nprotected instance comm_monoid : comm_monoid \u211a := comm_semiring.to_comm_monoid \u211a\n\nprotected instance monoid : monoid \u211a := ring.to_monoid \u211a\n\nprotected instance comm_semigroup : comm_semigroup \u211a := comm_ring.to_comm_semigroup \u211a\n\nprotected instance semigroup : semigroup \u211a := monoid.to_semigroup \u211a\n\ntheorem sub_def {a : \u2124} {b : \u2124} {c : \u2124} {d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 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 : \u211a) : denom (-q) = denom q :=\n  cases_on q\n    fun (q_num : \u2124) (q_denom : \u2115) (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 : \u211a) : num (-q) = -num q :=\n  cases_on q\n    fun (q_num : \u2124) (q_denom : \u2115) (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 : \u211a} (hq : num q = 0) : q = 0 := sorry\n\ntheorem zero_iff_num_zero {q : \u211a} : q = 0 \u2194 num q = 0 := sorry\n\ntheorem num_ne_zero_of_ne_zero {q : \u211a} (h : q \u2260 0) : num q \u2260 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 : \u211a) : denom q \u2260 0 := ne_of_gt (pos q)\n\ntheorem eq_iff_mul_eq_mul {p : \u211a} {q : \u211a} : p = q \u2194 num p * \u2191(denom q) = num q * \u2191(denom p) := sorry\n\ntheorem mk_num_ne_zero_of_ne_zero {q : \u211a} {n : \u2124} {d : \u2124} (hq : q \u2260 0) (hqnd : q = mk n d) :\n    n \u2260 0 :=\n  sorry\n\ntheorem mk_denom_ne_zero_of_ne_zero {q : \u211a} {n : \u2124} {d : \u2124} (hq : q \u2260 0) (hqnd : q = mk n d) :\n    d \u2260 0 :=\n  sorry\n\ntheorem mk_ne_zero_of_ne_zero {n : \u2124} {d : \u2124} (h : n \u2260 0) (hd : d \u2260 0) : mk n d \u2260 0 :=\n  fun (this : mk n d = 0) => h (iff.mp (mk_eq_zero hd) this)\n\ntheorem mul_num_denom (q : \u211a) (r : \u211a) : q * r = mk (num q * num r) \u2191(denom q * denom r) := sorry\n\ntheorem div_num_denom (q : \u211a) (r : \u211a) : q / r = mk (num q * \u2191(denom r)) (\u2191(denom q) * num r) :=\n  sorry\n\ntheorem num_denom_mk {q : \u211a} {n : \u2124} {d : \u2124} (hn : n \u2260 0) (hd : d \u2260 0) (qdf : q = mk n d) :\n    \u2203 (c : \u2124), n = c * num q \u2227 d = c * \u2191(denom q) :=\n  sorry\n\ntheorem mk_pnat_num (n : \u2124) (d : \u2115+) : num (mk_pnat n d) = n / \u2191(nat.gcd (int.nat_abs n) \u2191d) :=\n  subtype.cases_on d\n    fun (d_val : \u2115) (d_property : 0 < d_val) =>\n      Eq.refl (num (mk_pnat n { val := d_val, property := d_property }))\n\ntheorem mk_pnat_denom (n : \u2124) (d : \u2115+) : denom (mk_pnat n d) = \u2191d / nat.gcd (int.nat_abs n) \u2191d :=\n  subtype.cases_on d\n    fun (d_val : \u2115) (d_property : 0 < d_val) =>\n      Eq.refl (denom (mk_pnat n { val := d_val, property := d_property }))\n\ntheorem mul_num (q\u2081 : \u211a) (q\u2082 : \u211a) :\n    num (q\u2081 * q\u2082) =\n        num q\u2081 * num q\u2082 / \u2191(nat.gcd (int.nat_abs (num q\u2081 * num q\u2082)) (denom q\u2081 * denom q\u2082)) :=\n  sorry\n\ntheorem mul_denom (q\u2081 : \u211a) (q\u2082 : \u211a) :\n    denom (q\u2081 * q\u2082) =\n        denom q\u2081 * denom q\u2082 / nat.gcd (int.nat_abs (num q\u2081 * num q\u2082)) (denom q\u2081 * denom q\u2082) :=\n  sorry\n\ntheorem mul_self_num (q : \u211a) : num (q * q) = num q * num q := sorry\n\ntheorem mul_self_denom (q : \u211a) : denom (q * q) = denom q * denom q := sorry\n\ntheorem add_num_denom (q : \u211a) (r : \u211a) :\n    q + r = mk (num q * \u2191(denom r) + \u2191(denom q) * num r) (\u2191(denom q) * \u2191(denom r)) :=\n  sorry\n\ntheorem coe_int_eq_mk (z : \u2124) : \u2191z = mk z 1 := sorry\n\ntheorem mk_eq_div (n : \u2124) (d : \u2124) : mk n d = \u2191n / \u2191d := sorry\n\ntheorem exists_eq_mul_div_num_and_eq_mul_div_denom {n : \u2124} {d : \u2124} (n_ne_zero : n \u2260 0)\n    (d_ne_zero : d \u2260 0) : \u2203 (c : \u2124), n = c * num (\u2191n / \u2191d) \u2227 d = c * \u2191(denom (\u2191n / \u2191d)) :=\n  num_denom_mk n_ne_zero d_ne_zero\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n / \u2191d = mk n d)) (Eq.symm (mk_eq_div n d))))\n      (Eq.refl (mk n d)))\n\ntheorem coe_int_eq_of_int (z : \u2124) : \u2191z = 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 : \u2124) : num \u2191n = n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (num \u2191n = n)) (coe_int_eq_of_int n))) (Eq.refl (num (of_int n)))\n\n@[simp] theorem coe_int_denom (n : \u2124) : denom \u2191n = 1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (denom \u2191n = 1)) (coe_int_eq_of_int n)))\n    (Eq.refl (denom (of_int n)))\n\ntheorem coe_int_num_of_denom_eq_one {q : \u211a} (hq : denom q = 1) : \u2191(num q) = q := sorry\n\ntheorem denom_eq_one_iff (r : \u211a) : denom r = 1 \u2194 \u2191(num r) = r :=\n  { mp := coe_int_num_of_denom_eq_one, mpr := fun (h : \u2191(num r) = r) => h \u25b8 coe_int_denom (num r) }\n\nprotected instance int.can_lift : can_lift \u211a \u2124 := can_lift.mk coe (fun (q : \u211a) => denom q = 1) sorry\n\ntheorem coe_nat_eq_mk (n : \u2115) : \u2191n = mk (\u2191n) 1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n = mk (\u2191n) 1)) (Eq.symm (int.cast_coe_nat n))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191\u2191n = mk (\u2191n) 1)) (coe_int_eq_mk \u2191n))) (Eq.refl (mk (\u2191n) 1)))\n\n@[simp] theorem coe_nat_num (n : \u2115) : num \u2191n = \u2191n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (num \u2191n = \u2191n)) (Eq.symm (int.cast_coe_nat n))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (num \u2191\u2191n = \u2191n)) (coe_int_num \u2191n))) (Eq.refl \u2191n))\n\n@[simp] theorem coe_nat_denom (n : \u2115) : denom \u2191n = 1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (denom \u2191n = 1)) (Eq.symm (int.cast_coe_nat n))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (denom \u2191\u2191n = 1)) (coe_int_denom \u2191n))) (Eq.refl 1))\n\n-- Will be subsumed by `int.coe_inj` after we have defined\n\n-- `linear_ordered_field \u211a` (which implies characteristic zero).\n\ntheorem coe_int_inj (m : \u2124) (n : \u2124) : \u2191m = \u2191n \u2194 m = n := sorry\n\ntheorem inv_def' {q : \u211a} : q\u207b\u00b9 = \u2191(denom q) / \u2191(num q) := sorry\n\n@[simp] theorem mul_denom_eq_num {q : \u211a} : q * \u2191(denom q) = \u2191(num q) := sorry\n\ntheorem denom_div_cast_eq_one_iff (m : \u2124) (n : \u2124) (hn : n \u2260 0) : denom (\u2191m / \u2191n) = 1 \u2194 n \u2223 m :=\n  sorry\n\ntheorem num_div_eq_of_coprime {a : \u2124} {b : \u2124} (hb0 : 0 < b)\n    (h : nat.coprime (int.nat_abs a) (int.nat_abs b)) : num (\u2191a / \u2191b) = a :=\n  sorry\n\ntheorem denom_div_eq_of_coprime {a : \u2124} {b : \u2124} (hb0 : 0 < b)\n    (h : nat.coprime (int.nat_abs a) (int.nat_abs b)) : \u2191(denom (\u2191a / \u2191b)) = b :=\n  sorry\n\ntheorem div_int_inj {a : \u2124} {b : \u2124} {c : \u2124} {d : \u2124} (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 : \u2191a / \u2191b = \u2191c / \u2191d) : a = c \u2227 b = d :=\n  sorry\n\ntheorem coe_int_div_self (n : \u2124) : \u2191(n / n) = \u2191n / \u2191n := sorry\n\ntheorem coe_nat_div_self (n : \u2115) : \u2191(n / n) = \u2191n / \u2191n := coe_int_div_self \u2191n\n\ntheorem coe_int_div (a : \u2124) (b : \u2124) (h : b \u2223 a) : \u2191(a / b) = \u2191a / \u2191b := sorry\n\ntheorem coe_nat_div (a : \u2115) (b : \u2115) (h : b \u2223 a) : \u2191(a / b) = \u2191a / \u2191b := sorry\n\nprotected theorem forall {p : \u211a \u2192 Prop} : (\u2200 (r : \u211a), p r) \u2194 \u2200 (a b : \u2124), p (\u2191a / \u2191b) := sorry\n\nprotected theorem exists {p : \u211a \u2192 Prop} : (\u2203 (r : \u211a), p r) \u2194 \u2203 (a : \u2124), \u2203 (b : \u2124), p (\u2191a / \u2191b) :=\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 `\u211d\u22650`.\nSee also Definition 9.3 of [Analytic]. -/\n@[derive category_theory.category]\ndef system_of_double_complexes : Type (u+1) :=\n\u211d\u22650\u1d52\u1d56 \u2964 (cochain_complex (cochain_complex SemiNormedGroup.{u} \u2115) \u2115)\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 : \u211d\u22650) (p q : \u2115) : SemiNormedGroup :=\n((C.obj $ op c).X p).X q\n\n/-- `C.res` is the restriction map `C.X c' p q \u27f6 C.X c p q` for a system of complexes `C`,\nand nonnegative reals `c \u2264 c'`. -/\ndef res {c' c : \u211d\u22650} {p q : \u2115} [h : fact (c \u2264 c')] :\n  C.X c' p q \u27f6 C.X c p q :=\n((C.map (hom_of_le h.out).op).f p).f q\n\nvariables (c : \u211d\u22650) {c\u2081 c\u2082 c\u2083 : \u211d\u22650} (p p' q q' : \u2115)\n\n@[simp] lemma res_refl : @res C c c p q _ = \ud835\udfd9 _ :=\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\u2082 = c\u2081) (x : C.X c\u2081 p q) : \u2225@res C _ _ p q \u27e8h.le\u27e9 x\u2225 = \u2225x\u2225 :=\nby { cases h, rw res_refl, refl }\n\n@[simp] lemma res_comp_res (h\u2081 : fact (c\u2082 \u2264 c\u2081)) (h\u2082 : fact (c\u2083 \u2264 c\u2082)) :\n  @res C _ _ p q h\u2081 \u226b @res C _ _ p q h\u2082  = @res C _ _ p q \u27e8h\u2082.out.trans h\u2081.out\u27e9 :=\nbegin\n  have := (category_theory.functor.map_comp C (hom_of_le h\u2081.out).op (hom_of_le h\u2082.out).op),\n  rw [\u2190 op_comp] at this,\n  delta res, erw this, refl,\nend\n\n@[simp] lemma res_res (h\u2081 : fact (c\u2082 \u2264 c\u2081)) (h\u2082 : fact (c\u2083 \u2264 c\u2082)) (x : C.X c\u2081 p q) :\n  @res C _ _ p q h\u2082 (@res C _ _ p q h\u2081 x) = @res C _ _ p q \u27e8h\u2082.out.trans h\u2081.out\u27e9 x :=\nby { rw \u2190 (C.res_comp_res p q h\u2081 h\u2082), refl }\n\n/-- `C.d` is the differential `C.X c p q \u27f6 C.X c (p+1) q` for a system of double complexes `C`. -/\ndef d {c : \u211d\u22650} (p p' : \u2115) {q : \u2115} : C.X c p q \u27f6 C.X c p' q :=\n((C.obj $ op c).d p p').f q\n\nlemma d_eq_zero (c : \u211d\u22650) (h : p + 1 \u2260 p') : (C.d p p' : C.X c p q \u27f6 _) = 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 : \u211d\u22650) (h : p + 1 \u2260 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 : \u211d\u22650) (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\u2082 \u2264 c\u2081)) :\n  C.d p p' \u226b @res C _ _ _ q h = @res C _ _ p q _ \u226b 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\u2082 \u2264 c\u2081)) (x) :\n  @d C c\u2082 p p' q (@res C _ _ p q _ x) = @res C _ _ _ _ h (@d C c\u2081 p p' q x) :=\nshow (@res C _ _ p q _ \u226b C.d p p') x = (C.d p p' \u226b @res C _ _ _ _ h) x,\nby rw d_comp_res\n\n@[simp] lemma d_comp_d {c : \u211d\u22650} {p p' p'' q : \u2115} :\n  @d C c p p' q \u226b 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 : \u211d\u22650} {p p' p'' q : \u2115} (x : C.X c p q) :\n  C.d p' p'' (C.d p p' x) = 0 :=\nshow (C.d _ _ \u226b C.d _ _) x = 0, by { rw d_comp_d, refl }\n\n/-- `C.d'` is the differential `C.X c p q \u27f6 C.X c p (q+1)` for a system of double complexes `C`. -/\ndef d' {c : \u211d\u22650} {p : \u2115} (q q' : \u2115) : C.X c p q \u27f6 C.X c p q' :=\n((C.obj $ op c).X p).d q q'\n\nlemma d'_eq_zero (c : \u211d\u22650) (h : q + 1 \u2260 q') : (C.d' q q' : C.X c p q \u27f6 _) = 0 :=\n((C.obj $ op c).X p).shape _ _ h\n\nlemma d'_eq_zero_apply (c : \u211d\u22650) (h : q + 1 \u2260 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 : \u211d\u22650) (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\u2082 \u2264 c\u2081)) :\n  @d' C c\u2081 p q q' \u226b @res C _ _ _ _ h = @res C _ _ p q _ \u226b @d' C c\u2082 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\u2082 \u2264 c\u2081)) (x) :\n  C.d' q q' (@res C _ _ p q _ x) = @res C _ _ _ _ h (C.d' q q' x) :=\nshow (@res C _ _ p q _ \u226b C.d' q q') x = (C.d' q q' \u226b @res C _ _ _ _ h) x,\nby rw d'_comp_res\n\n@[simp] lemma d'_comp_d' {c : \u211d\u22650} {p q q' q'' : \u2115} :\n  @d' C c p q q' \u226b 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 : \u211d\u22650} {p q q' q'' : \u2115} (x : C.X c p q) :\n  C.d' q' q'' (C.d' q q' x) = 0 :=\nshow (C.d' _ _ \u226b C.d' _ _) x = 0, by { rw d'_comp_d', refl }\n\nlemma d'_comp_d (c : \u211d\u22650) (p p' q q' : \u2115) :\n  C.d' q q' \u226b C.d p p' = C.d p p' \u226b (C.d' q q' : C.X c p' q \u27f6 _) :=\n(((C.obj $ op c).d p p').comm q q').symm\n\nlemma d'_d (c : \u211d\u22650) (p p' q q' : \u2115) (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' \u226b C.d' q q') x = (C.d' q q' \u226b 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' : \u211d\u22650} {p p' q q' : \u2115} (hc : c = c') (hp : p = p') (hq : q = q') :\n  C.X c p q \u27f6 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 : \u2115) : system_of_complexes.{u} :=\nC \u22d9 homological_complex.forget _ _ \u22d9 pi.eval _ p\n\n@[simp] lemma row_X (C : system_of_double_complexes) (p q : \u2115) (c : \u211d\u22650) :\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 : \u2115) {c' c : \u211d\u22650} [h : fact (c \u2264 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 : \u211d\u22650) (p : \u2115) :\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' : \u2115) :\n  C.row p \u27f6 C.row p' :=\n{ app := \u03bb c,\n  { f := \u03bb q, (C.d p p' : C.X c.unop p q \u27f6 C.X c.unop p' q),\n    comm' := \u03bb q q' _, (C.d'_comp_d _ p p' q q').symm },\n  naturality' := \u03bb c\u2081 c\u2082 h, (C.map h).comm p p' }\n\n@[simp] lemma row_map_apply (C : system_of_double_complexes.{u})\n  (c : \u211d\u22650) (p p' q : \u2115) (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 \u2115) \u22d9\n--   pi.eval (\u03bb (_ : \u2115), SemiNormedGroup) q).additive :=\n-- { map_zero' := \u03bb C\u2081 C\u2082, 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 : \u2115) : system_of_complexes.{u} :=\nC \u22d9 functor.map_homological_complex (homological_complex.eval _ _ q) _\n\n@[simp] lemma col_X (C : system_of_double_complexes) (p q : \u2115) (c : \u211d\u22650) :\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 : \u2115) {c' c : \u211d\u22650} [h : fact (c \u2264 c')] :\n  (@system_of_complexes.res (C.col q) _ _ p h : C.col q c' p \u27f6 C.col q c p) =\n  -- (@res C _ _ p q h : C.X c' p q \u27f6 C.X c p q) :=\n  by dsimp_result { dsimp, exact (@res C _ _ p q h : C.X c' p q \u27f6 C.X c p q) } :=\nrfl\n\n@[simp] lemma col_d (C : system_of_double_complexes) (c : \u211d\u22650) (p p' q : \u2115) :\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' : \u2115) :\n  C.col q \u27f6 C.col q' :=\n{ app := \u03bb c,\n  { f := \u03bb p, (C.d' q q' : C.X c.unop p q \u27f6 C.X c.unop p q'),\n    comm' := \u03bb p p' _, (C.d'_comp_d _ p p' q q') },\n  naturality' := \u03bb c\u2081 c\u2082 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' : \u2200 c p p' q (h : p + 1 = p'), (@d C c p p' q).norm_noninc)\n(d'_norm_noninc' : \u2200 c p q q' (h : q + 1 = q'), (@d' C c p q q').norm_noninc)\n(res_norm_noninc : \u2200 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 : \u211d\u22650) (p p' q : \u2115) :\n  (C.d p p' : C.X c p q \u27f6 _).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 : \u211d\u22650) (p q q' : \u2115) :\n  (C.d' q q' : C.X c p q \u27f6 _).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 : \u2115) : (C.col q).admissible :=\n{ d_norm_noninc' := \u03bb c i j h, hC.d_norm_noninc _ _ _ _,\n  res_norm_noninc := \u03bb c i j h, hC.res_norm_noninc _ _ _ _ _ }\n\nlemma row (hC : C.admissible) (p : \u2115) : (C.row p).admissible :=\n{ d_norm_noninc' := \u03bb c i j h, hC.d'_norm_noninc _ _ _ _,\n  res_norm_noninc := \u03bb c i j h, hC.res_norm_noninc _ _ _ _ _ }\n\nlemma mk' (h : \u2200 p, (C.row p).admissible)\n  (hd : \u2200 c p p' q (h : p + 1 = p'), (@d C c p p' q).norm_noninc) :\n  C.admissible :=\n{ d_norm_noninc' := \u03bb c p p' q h', hd c p p' q h',\n  d'_norm_noninc' := \u03bb c p q q' h', (h p).d_norm_noninc' _ _ _ h',\n  res_norm_noninc := \u03bb c\u2081 c\u2082 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": "lemma contrapositive2 (P Q : Prop) : (\u00ac Q \u2192 \u00ac P) \u2192 (P \u2192 Q) :=\nbegin\n    \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_wrld10.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7853085909370422, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.49456740954868883}}
{"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    \u2200\n      (x :\n        \u21a5(PresheafedSpace.carrier\n            (SheafedSpace.to_PresheafedSpace (LocallyRingedSpace.to_SheafedSpace _X)))),\n      \u2203 (U :\n        topological_space.opens\n          \u21a5(PresheafedSpace.carrier\n              (SheafedSpace.to_PresheafedSpace (LocallyRingedSpace.to_SheafedSpace _X)))),\n        \u2203 (m : x \u2208 U),\n          \u2203 (R : CommRing),\n            \u2203 (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) \u2245\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 := \u2205 }\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 \u0393 : Scheme\u1d52\u1d56 \u2964 CommRing :=\n  category_theory.functor.op (category_theory.induced_functor to_LocallyRingedSpace) \u22d9\n    LocallyRingedSpace.\u0393\n\ntheorem \u0393_def :\n    \u0393 =\n        category_theory.functor.op (category_theory.induced_functor to_LocallyRingedSpace) \u22d9\n          LocallyRingedSpace.\u0393 :=\n  rfl\n\n@[simp] theorem \u0393_obj (X : Scheme\u1d52\u1d56) :\n    category_theory.functor.obj \u0393 X =\n        category_theory.functor.obj\n          (PresheafedSpace.presheaf\n            (SheafedSpace.to_PresheafedSpace\n              (LocallyRingedSpace.to_SheafedSpace (X (opposite.unop X)))))\n          (opposite.op \u22a4) :=\n  rfl\n\ntheorem \u0393_obj_op (X : Scheme) :\n    category_theory.functor.obj \u0393 (opposite.op X) =\n        category_theory.functor.obj\n          (PresheafedSpace.presheaf\n            (SheafedSpace.to_PresheafedSpace (LocallyRingedSpace.to_SheafedSpace (X X))))\n          (opposite.op \u22a4) :=\n  rfl\n\n@[simp] theorem \u0393_map {X : Scheme\u1d52\u1d56} {Y : Scheme\u1d52\u1d56} (f : X \u27f6 Y) :\n    category_theory.functor.map \u0393 f =\n        category_theory.nat_trans.app\n            (PresheafedSpace.hom.c (subtype.val (category_theory.has_hom.hom.unop f)))\n            (opposite.op \u22a4) \u226b\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))) \u22a4)) :=\n  rfl\n\ntheorem \u0393_map_op {X : Scheme} {Y : Scheme} (f : X \u27f6 Y) :\n    category_theory.functor.map \u0393 (category_theory.has_hom.hom.op f) =\n        category_theory.nat_trans.app (PresheafedSpace.hom.c (subtype.val f)) (opposite.op \u22a4) \u226b\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)) \u22a4)) :=\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\u2081 v\u2081 w\u2081\n\ninfix ` \u2297 `:100 := tensor_product\n\nvariables {R : Type u} {A : Type v} {B : Type w} {C : Type u\u2081} {D : Type v\u2081}\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 \u2297 iB.mod \u2192\u2097 iA.mod \u2297 iB.mod \u2192\u2097 iA.mod \u2297 iB.mod :=\nlift $ linear_map.compr\u2082\n  ((linear_map.lflip _ _ _ _).comp $\n    linear_map.compr\u2082\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 \u2297\u209c q) (r \u2297\u209c s) = (p * r) \u2297\u209c (q * s) :=\nby rw [lmul, lift.tmul, compr\u2082_apply, uncurry_apply, comp_apply, lflip_apply, compr\u2082_apply, lcurry_apply,\n    curry_apply, curry_apply, map_tmul, lift.tmul, lift.tmul]; refl\n\ninstance : comm_ring (iA.mod \u2297 iB.mod) :=\n{ mul := \u03bb 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 _ (\u03bb z\u2081 z\u2082, _) (\u03bb z\u2081 z\u2082 ih\u2081 ih\u2082, _),\n    { simp only [map_zero] },\n    { refine tensor_product.induction_on _ _ y _ (\u03bb y\u2081 y\u2082, _) (\u03bb y\u2081 y\u2082 ih\u2081 ih\u2082, _),\n      { rw [map_zero\u2082, map_zero, map_zero\u2082] },\n      { refine tensor_product.induction_on _ _ x _ (\u03bb x\u2081 x\u2082, _) (\u03bb x\u2081 x\u2082 ih\u2081 ih\u2082, _),\n        { rw [map_zero\u2082, map_zero\u2082, map_zero\u2082] },\n        { iterate 4 { rw [lmul_tmul] },\n          iterate 2 { rw mul_assoc } },\n        { rw [map_add\u2082, map_add\u2082, map_add\u2082], congr' 1, exacts [ih\u2081, ih\u2082] } },\n      { rw [map_add\u2082, map_add, map_add\u2082, map_add], congr' 1, exacts [ih\u2081, ih\u2082] } },\n    { rw [map_add, map_add, map_add], congr' 1, exacts [ih\u2081, ih\u2082] }\n  end,\n  one := 1 \u2297\u209c 1,\n  one_mul := \u03bb x, show lmul iA iB (1 \u2297\u209c 1) x = x, from\n    tensor_product.induction_on _ _ x (map_zero _)\n    (\u03bb x y, (lmul_tmul _ _ _ _ _ _).trans $ by rw [one_mul, one_mul])\n    (\u03bb x y ihx ihy, (map_add _ _ _).trans $ by rw [ihx, ihy]),\n  mul_one := \u03bb x, show lmul iA iB x (1 \u2297\u209c 1) = x, from\n    tensor_product.induction_on _ _ x (map_zero\u2082 _ _)\n    (\u03bb x y, (lmul_tmul _ _ _ _ _ _).trans $ by rw [mul_one, mul_one])\n    (\u03bb x y ihx ihy, (map_add\u2082 _ _ _ _).trans $ by rw [ihx, ihy]),\n  left_distrib := \u03bb _, map_add _,\n  right_distrib := map_add\u2082 _,\n  mul_comm := \u03bb x y, show lmul iA iB x y = lmul iA iB y x, from\n    tensor_product.induction_on _ _ x (by rw [map_zero\u2082, map_zero])\n      (\u03bb x\u2081 x\u2082, tensor_product.induction_on _ _ y (by rw [map_zero\u2082, map_zero])\n        (\u03bb y\u2081 y\u2082, by rw [lmul_tmul, lmul_tmul, mul_comm x\u2081 y\u2081, mul_comm x\u2082 y\u2082])\n        (\u03bb y\u2081 y\u2082 ih\u2081 ih\u2082, by rw [map_add\u2082, map_add, ih\u2081, ih\u2082]))\n      (\u03bb x\u2081 x\u2082 ih\u2081 ih\u2082, by rw [map_add\u2082, map_add, ih\u2081, ih\u2082]),\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 \u2297\u209c q) * (r \u2297\u209c s) = (p * r) \u2297\u209c (q * s) :=\nlmul_tmul _ _ _ _ _ _\n\ntheorem one_def : (1 : iA.mod \u2297 iB.mod) = 1 \u2297\u209c 1 := rfl\n\nend tensor_product\n\nnamespace algebra\nopen tensor_product linear_map\n\ndef tensor_product : algebra R (iA.mod \u2297 iB.mod) :=\n{ to_fun := \u03bb r, iA r \u2297\u209c 1,\n  hom := \u27e8by rw iA.map_one; refl,\n    \u03bb x y, by rw [iA.map_mul, mul_def, mul_one],\n    \u03bb x y, by rw [iA.map_add, add_tmul]\u27e9,\n  smul_def' := \u03bb r x, tensor_product.induction_on _ _ x\n    (by rw [smul_zero, mul_zero])\n    (\u03bb x y, by rw [\u2190 tmul_smul, \u2190 smul_tmul, mul_def, iA.smul_def, one_mul])\n    (\u03bb x y ihx ihy, by rw [smul_add, mul_add, ihx, ihy]) }\n\ndef inl : iA \u2192\u2090 iA.tensor_product iB :=\n{ to_fun := \u03bb x, x \u2297\u209c 1,\n  hom := \u27e8rfl, \u03bb x y, by rw [mul_def, mul_one], \u03bb x y, add_tmul _ _ _\u27e9,\n  commutes' := \u03bb r, rfl }\n\ntheorem inl_def (p : iA.mod) : iA.inl iB p = p \u2297\u209c 1 := rfl\n\ndef inr : iB \u2192\u2090 iA.tensor_product iB :=\n{ to_fun := \u03bb x, 1 \u2297\u209c x,\n  hom := \u27e8rfl, \u03bb x y, by rw [mul_def, mul_one], \u03bb x y, tmul_add _ _ _\u27e9,\n  commutes' := \u03bb r, by rw [\u2190 mul_one (iB r), \u2190 iB.smul_def, \u2190 smul_tmul, iA.smul_def, mul_one]; refl }\n\ntheorem inr_def (q : iB.mod) : iA.inr iB q = 1 \u2297\u209c 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 \u2192\u2090 iC) (g : iB \u2192\u2090 iC) : iA.tensor_product iB \u2192\u2090 iC :=\n{ to_fun := (tensor_product.lift iC.lmul).comp $ map f.to_linear_map g.to_linear_map,\n  hom := \u27e8by 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    \u03bb x y, tensor_product.induction_on _ _ x\n      (by rw [zero_mul, linear_map.map_zero]; exact (zero_mul _).symm)\n      (\u03bb x\u2081 x\u2082, tensor_product.induction_on _ _ y\n        (by rw [mul_zero, linear_map.map_zero]; exact (mul_zero _).symm)\n        (\u03bb y\u2081 y\u2082, 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\u2081)])\n        (\u03bb y\u2081 y\u2082 ih\u2081 ih\u2082, by simp only [mul_add, linear_map.map_add, ih\u2081, ih\u2082]))\n      (\u03bb x\u2081 x\u2082 ih\u2081 ih\u2082, by simp only [add_mul, linear_map.map_add, ih\u2081, ih\u2082]),\n    linear_map.map_add _\u27e9,\n  commutes' := \u03bb r, show lift iC.lmul (map f.to_linear_map g.to_linear_map (iA r \u2297\u209c 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 \u2192\u2090 iC) (g : iB \u2192\u2090 iC) (p : iA.mod) (q : iB.mod) :\n  arec f g (p \u2297\u209c q) = f p * g q :=\nlift.tmul _ _\n\nvariables (iA iB iC)\ndef UMP : ((iA \u2192\u2090 iC) \u00d7 (iB \u2192\u2090 iC)) \u2243 (iA.tensor_product iB \u2192\u2090 iC) :=\n{ to_fun := \u03bb \u03c6, arec \u03c6.1 \u03c6.2,\n  inv_fun := \u03bb \u03c6, (\u03c6.comp (iA.inl iB), \u03c6.comp (iA.inr iB)),\n  left_inv := \u03bb \u27e8\u03c6\u2081, \u03c6\u2082\u27e9, prod.ext\n    (by ext p; change (arec \u03c6\u2081 \u03c6\u2082) (p \u2297\u209c 1) = \u03c6\u2081 p;\n      rw [arec_tmul, \u03c6\u2082.map_one', mul_one])\n    (by ext q; change (arec \u03c6\u2081 \u03c6\u2082) (1 \u2297\u209c q) = \u03c6\u2082 q;\n      rw [arec_tmul, \u03c6\u2081.map_one', one_mul]),\n  right_inv := \u03bb \u03c6, alg_hom.to_linear_map_inj $ tensor_product.ext $ \u03bb 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, \u2190 \u03c6.map_mul, mul_def, mul_one, one_mul] }\n\nvariables {iA iB iC iD}\ndef amap (f : iA \u2192\u2090 iC) (g : iB \u2192\u2090 iD) : (iA.tensor_product iB) \u2192\u2090 (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 \u2192\u2090 iC) (g : iB \u2192\u2090 iD) (x : A) (y : B) :\n  amap f g (x \u2297\u209c y) = f x \u2297\u209c 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 \u2192\u2090\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 \u2297\u209c y \u2297\u209c z) = x \u2297\u209c (y \u2297\u209c 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 \u2192\u2090 iA :=\narec iA.of_id (alg_hom.id iA)\n\n@[simp] lemma id_tensor_tmul (r x) : id_tensor iA (r \u2297\u209c x) = ((r : R) \u2022 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) \u2192\u2090 iA :=\narec (alg_hom.id iA) iA.of_id\n\n@[simp] lemma tensor_id_tmul (r x) : tensor_id iA (x \u2297\u209c r) = ((r : R) \u2022 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 \u2297 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 \u2297\u209c 1 := rfl\n\nset_option class.instance_max_depth 100\ndef base_change_left_rec {D : Type v\u2081} [comm_ring D] (iD : algebra iA.mod D)\n  (\u03c6 : iB \u2192\u2090 iA.comap iD) : base_change_left iA iB \u2192\u2090 iD :=\n{ to_fun := (tensor_product.lift (iA.comap iD).lmul).comp\n    (map (iA.to_comap iD).to_linear_map \u03c6.to_linear_map),\n  hom := \u27e8by simp only [comp_apply, one_def, map_tmul, alg_hom.to_linear_map_apply, lmul_apply,\n      lift.tmul, \u03c6.map_one', (to_comap iA iD).map_one']; apply mul_one,\n    \u03bb x y, tensor_product.induction_on _ _ x\n      (by rw [zero_mul, linear_map.map_zero]; exact (zero_mul _).symm)\n      (\u03bb x\u2081 x\u2082, tensor_product.induction_on _ _ y\n        (by rw [mul_zero, linear_map.map_zero]; exact (mul_zero _).symm)\n        (\u03bb y\u2081 y\u2082, 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, \u03c6.map_mul, mul_assoc]; rw mul_left_comm ((iA.to_comap iD) y\u2081))\n        (\u03bb y\u2081 y\u2082 ih\u2081 ih\u2082, by rw [mul_add, linear_map.map_add, ih\u2081, ih\u2082, linear_map.map_add, mul_add]))\n      (\u03bb x\u2081 x\u2082 ih\u2081 ih\u2082, by rw [add_mul, linear_map.map_add, ih\u2081, ih\u2082, linear_map.map_add, add_mul]),\n    linear_map.map_add _\u27e9,\n  commutes' := \u03bb 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, \u03c6.map_one']; exact mul_one _ }\nset_option class.instance_max_depth 32\n\ndef base_change_right : algebra B (iA.mod \u2297 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 {\u03c3 : Type*} {\u03b1 : Type*} [decidable_eq \u03c3] [decidable_eq \u03b1] [discrete_field \u03b1] [fintype \u03c3]\nvariables [decidable_linear_order (\u03c3 \u2192\u2080 \u2115)] [is_well_founded (\u03c3 \u2192\u2080 \u2115) (<)] [is_monomial_order (\u03c3 \u2192\u2080 \u2115) (\u2264)] \n\nsection reduction\n\ndef reduction (a b : mv_polynomial \u03c3 \u03b1) := \n    a - b * (monomial (a.LM - b.LM) (a.LC / b.LC))\n\ndef red_list_aux : mv_polynomial \u03c3 \u03b1 \u2192 list (mv_polynomial \u03c3 \u03b1) \u2192 mv_polynomial \u03c3 \u03b1\n| a [] := a\n| a (hd :: tl) := if h : hd.LM \u2223 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 \u03c3 \u03b1} (hp : p.LM = 0) (hq : q.LM = 0) (hq' : q \u2260 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 : \u2200 (l : list (mv_polynomial \u03c3 \u03b1)), red_list_aux 0 l = 0\n| [] := by simp [red_list_aux]\n| (q :: l') := begin\n    by_cases q.LM \u2223 (0 : mv_polynomial (\u03c3) \u03b1).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 \u03c3 \u03b1} (hba : b.LM \u2223 a.LM) (ha : a.LM \u2260 0) (hb : b \u2260 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 : \u2200 (l : list (mv_polynomial \u03c3 \u03b1)) {p q : mv_polynomial \u03c3 \u03b1} (hqp : q.LM \u2223 p.LM) (hp : p.LM \u2260 0) (hq : q \u2260 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\u03bb p q hqp hp hq, begin \n    by_cases h_dvd : r.LM \u2223 (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 : \u2200 (l : list (mv_polynomial \u03c3 \u03b1)) (p : mv_polynomial \u03c3 \u03b1) (hp : p.LM \u2260 0) \n(h_red : red_list_aux p l \u2260 p), (red_list_aux p l).LM < p.LM \n| [] := by simp [red_list_aux] \n| (r :: l') := \u03bb p hp h_red, begin\n    by_cases hr : r = 0,\n    {simp [red_list_aux, reduction, hr] at h_red \u22a2, apply red_list_aux_LM_lt, assumption'},\n    by_cases hrp : r.LM \u2223 p.LM;\n    simp [red_list_aux, hrp] at h_red \u22a2, \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 \u03c3 \u03b1 \u2192 list (mv_polynomial \u03c3 \u03b1) \u2192 mv_polynomial \u03c3 \u03b1\n| a l := \n    let r := red_list_aux a l in\n    if h\u2081 : r = a\n    then r\n    else if h\u2082 : a.LM = 0\n        then 0\n        else have r.LM < a.LM := red_list_aux_LM_lt _ _ h\u2082 h\u2081,\n            red_list r l\nusing_well_founded \n{ rel_tac := \u03bb _ _, `[exact \u27e8_, inv_image.wf (\u03bb a, a.1.LM) _inst_6.wf\u27e9] \n, dec_tac := tactic.assumption }\n\nlemma zero_red_list : \u2200 (l : list (mv_polynomial \u03c3 \u03b1)), 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 : \u2200 (l : list (mv_polynomial \u03c3 \u03b1)) (p : mv_polynomial \u03c3 \u03b1), \n(red_list_aux p l = p) \u2192 (\u2203 (q : mv_polynomial \u03c3 \u03b1) (hq\u2081 : q \u2208 l) (hq\u2082 : q \u2260 0), q.LM = 0) \u2192 p = 0 \n| [] := by simp\n| (r :: l') := \u03bb p, begin\n    simp_intros hp\u2081 hl [red_list_aux, -finset.insert_empty_eq_singleton],\n    rcases hl with \u27e8q, \u27e8hq | hq, hq'\u2081, hq'\u2082\u27e9\u27e9,\n    {\n        rw hq at hq'\u2081 hq'\u2082,\n        simp [hq'\u2082] at hp\u2081,\n        by_cases hp\u2082 : p.LM = 0,\n        {rwa [reduction_of_LM_eqz hp\u2082 hq'\u2082 hq'\u2081, zero_red_list_aux, eq_comm] at hp\u2081},\n        {\n            have h := red_list_aux_red_LM_lt l' (by simp [hq'\u2082]) hp\u2082 hq'\u2081,\n            rw hp\u2081 at h,\n            apply absurd h (lt_irrefl _),\n        },\n    },\n    by_cases hrp : r.LM \u2223 p.LM;\n    simp [hrp] at hp\u2081,\n    {\n        by_cases hr : r = 0, \n        {exact eqz_of_red_list_aux_eq l' _ (by simpa [hr, reduction] using hp\u2081) \u27e8q, hq, hq'\u2081, hq'\u2082\u27e9},\n        {\n            \n            by_cases hp\u2082 : p.LM = 0,\n            {\n                simp [hp\u2082] at hrp,\n                rwa [reduction_of_LM_eqz hp\u2082 hrp hr, zero_red_list_aux, eq_comm] at hp\u2081,\n            },\n            {\n                have h := red_list_aux_red_LM_lt l' hrp hp\u2082 hr,\n                rw hp\u2081 at h,\n                apply absurd h (lt_irrefl _),\n            },\n        },\n    },\n    {apply eqz_of_red_list_aux_eq l' _ hp\u2081, refine \u27e8q, hq, hq'\u2081, hq'\u2082\u27e9},\nend\n\nlemma red_list_eqz_of_const : \u2200 (p : mv_polynomial \u03c3 \u03b1) (l : list (mv_polynomial \u03c3 \u03b1)), \n(\u2203 (q : mv_polynomial \u03c3 \u03b1) (hq\u2081 : q \u2208 l) (hq\u2082 : q \u2260 0), q.LM = 0) \u2192 red_list p l = 0 \n| p l := \u03bb h, begin \n    unfold red_list, \n    by_cases hp\u2081 : red_list_aux p l = p;\n    by_cases hp\u2082 : p.LM = 0;\n    simp [hp\u2081, hp\u2082], \n    repeat {apply eqz_of_red_list_aux_eq l _ hp\u2081 h},\n    {\n        let : (red_list_aux p l).LM < p.LM, from red_list_aux_LM_lt l p hp\u2082 hp\u2081,\n        apply red_list_eqz_of_const, assumption,\n    }\nend\nusing_well_founded \n{ rel_tac := \u03bb _ _, `[exact \u27e8_, inv_image.wf (\u03bb a, a.1.LM) _inst_6.wf\u27e9] \n, dec_tac := tactic.assumption }\n\n\nlemma red_list_nez_no_const : \u2200 (l : list (mv_polynomial \u03c3 \u03b1)) (p : mv_polynomial \u03c3 \u03b1) (h : red_list p l \u2260 0) \n(q : mv_polynomial \u03c3 \u03b1) (hq\u2081 : q \u2208 l) (hq\u2082 : q \u2260 0), q.LM \u2260 0 :=\n\u03bb l p h q hq\u2081 hq\u2082 hq\u2083, h (red_list_eqz_of_const _ _ \u27e8q, hq\u2081, hq\u2082, hq\u2083\u27e9)\n\n\nlemma red_list_aux_not_div : \u2200 (l : list (mv_polynomial \u03c3 \u03b1)) (p : mv_polynomial \u03c3 \u03b1) (h : red_list_aux p l = p)\n    (q : mv_polynomial \u03c3 \u03b1) (hq\u2081 : q \u2208 l) (hq\u2082 : q.LM \u2260 0), q.LM \u2224 p.LM\n| [] := by simp\n| (r :: l') := begin \n    simp_intros p hp\u2081 q hq\u2081 hq\u2082 [red_list_aux, -finset.insert_empty_eq_singleton], cases hq\u2081;\n    by_cases hrp : r.LM \u2223 p.LM; simp [hrp] at hp\u2081,\n    {\n        by_cases hp : p.LM = 0,\n        {\n            rw hq\u2081 at hq\u2082,\n            simp [hp] at hrp,\n            apply absurd hrp hq\u2082,\n        },\n        {\n            rw hq\u2081 at hq\u2082,\n            have h_r := red_list_aux_red_LM_lt l' hrp hp (nez_of_LM_nez hq\u2082),\n            rw [hp\u2081] at h_r, apply absurd h_r (lt_irrefl _),\n        },\n    },\n    {rwa hq\u2081,},\n    {\n        by_cases hr : r = 0,\n        {simp [reduction, hr] at hp\u2081, 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\u2081,\n                simpa [hp\u2081.symm] using hq\u2082,\n            },\n            {\n                have h_r := red_list_aux_red_LM_lt l' hrp hp hr,\n                rw [hp\u2081] 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 : \u2200 (p : mv_polynomial \u03c3 \u03b1) (l : list (mv_polynomial \u03c3 \u03b1)) (h : red_list p l \u2260 0)\n    (q : mv_polynomial \u03c3 \u03b1) (hq\u2081 : q \u2208 l) (hq\u2082 : q \u2260 0), q.LM \u2224 (red_list p l).LM\n| p l := \u03bb h q hq\u2081 hq\u2082, begin\n    have hq\u2083 := red_list_nez_no_const l p h _ hq\u2081 hq\u2082,\n    unfold red_list at \u22a2 h, \n    by_cases hp\u2081 : red_list_aux p l = p; \n    by_cases hp\u2082 : p.LM = 0; \n    simp [hp\u2081, hp\u2082], assumption',\n    {apply red_list_aux_not_div _ _ hp\u2081 _ hq\u2081 hq\u2083},\n    {\n        let : (red_list_aux p l).LM < p.LM, from red_list_aux_LM_lt l p hp\u2082 hp\u2081,\n        apply red_list_not_div, simp [hp\u2081, hp\u2082] at h,\n        assumption',\n    }\nend\nusing_well_founded \n{ rel_tac := \u03bb _ _, `[exact \u27e8_, inv_image.wf (\u03bb a, a.1.LM) _inst_6.wf\u27e9] \n, dec_tac := tactic.assumption }\n\nend reduction\n\ndef s_poly (p q : mv_polynomial \u03c3 \u03b1) : mv_polynomial \u03c3 \u03b1 := \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 \u03c3 \u03b1 \u2192 list (mv_polynomial \u03c3 \u03b1) \u2192 list (mv_polynomial \u03c3 \u03b1)\n| p [] := []\n| p (q :: l\u2081) := s_poly p q :: s_polyL p l\u2081\n\ndef s_polys : list (mv_polynomial \u03c3 \u03b1) \u2192 list (mv_polynomial \u03c3 \u03b1)\n| [] := []\n| (a :: l) := s_polyL a l ++ (s_polys l)\n\nlemma mem_s_polyL {p q : mv_polynomial \u03c3 \u03b1} : \u2200 {l : list (mv_polynomial \u03c3 \u03b1)},\nq \u2208 l \u2192 s_poly p q \u2208 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 \u03c3 \u03b1} : 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 \u03c3 \u03b1)) (p : mv_polynomial \u03c3 \u03b1) (h : red_list p l \u2260 0) :\n    monomial_ideal l < monomial_ideal (list.cons (red_list p l) l) := \nbegin\n    simp [lt_iff_le_and_ne], \n    refine \u27e8by apply ideal.span_mono; simp, _\u27e9,\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 \u2190LC_nez_iff) l h_mem with \u27e8q, \u27e8hq\u2081, hq\u2082\u27e9, hq\u2083\u27e9, \n        apply red_list_not_div p l h, assumption',\n    },\n    {\n        simp [monomial_ideal, ideal.mem_span_insert], \n        refine \u27e81, 0, by simp, by simp\u27e9, \n    }\nend\n\ndef buchberger : (list (mv_polynomial \u03c3 \u03b1) \u00d7 list (mv_polynomial \u03c3 \u03b1)) \u2192 list (mv_polynomial \u03c3 \u03b1)\n| \u27e8l\u2081, []\u27e9 := l\u2081\n| \u27e8l\u2081, (p :: l\u2082)\u27e9 :=\n    let lex := prod.lex ((>) : ideal (mv_polynomial \u03c3 \u03b1) \u2192 ideal (mv_polynomial \u03c3 \u03b1) \u2192 Prop) nat.lt in\n    let a := red_list p l\u2081 in\n    if h : a = 0 \n    then \n        have lex \u27e8monomial_ideal l\u2081, l\u2082.length\u27e9 \u27e8monomial_ideal l\u2081, (list.cons p l\u2082).length\u27e9 := \n            by right; rw [list.length_cons]; apply nat.lt_succ_self,\n        buchberger \u27e8l\u2081, l\u2082\u27e9\n    else \n        have lex \u27e8monomial_ideal (list.cons a l\u2081), (s_polyL a l\u2081 ++ l\u2082).length\u27e9 \u27e8monomial_ideal l\u2081, (list.cons p l\u2082).length\u27e9 := \n            by left; exact ideal_increase l\u2081 p h,\n        buchberger \u27e8a :: l\u2081, s_polyL a l\u2081 ++ l\u2082\u27e9\nusing_well_founded \n{ rel_tac := \u03bb _ _, \n`[exact \u27e8_, inv_image.wf (\u03bb \u27e8l\u2081, l\u2082\u27e9, prod.mk (monomial_ideal l\u2081) l\u2082.length) (prod.lex_wf ideal_wf nat.lt_wf)\u27e9 ] \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 \u2208 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  {\u03b1 : Type u} {a : \u03b1} (b : \u03b1) {l : list \u03b1}      : a \u2208 l \u2192 a \u2208 b::l :=\nmem_cons_of_mem _\n\nlemma in_head  {\u03b1 : Type u} (a : \u03b1) (l : list \u03b1)              : a \u2208 a::l :=\nmem_cons_self _ _\n\nlemma in_left  {\u03b1 : Type u} {a : \u03b1}   {l : list \u03b1} (r : list \u03b1) : a \u2208 l \u2192 a \u2208 l ++ r :=\nmem_append_left _\n\nlemma in_right {\u03b1 : Type u} {a : \u03b1}   (l : list \u03b1) {r : list \u03b1} : a \u2208 r \u2192 a \u2208 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 \u2192 tactic unit\n       | () := ... f () ...\n-/\n\nmeta def mk_mem_list_rec : unit \u2192 tactic unit\n| () :=\nwhen_tracing `search_mem_list (do t \u2190 target, f \u2190 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 \u2208 [b, c] ++ [b, a, b] :=\nby mk_mem_list\n\nexample (a b c : nat) : a \u2208 [b, c] ++ [b, a+0, b] :=\nby mk_mem_list\n\nexample (a b c : nat) : a \u2208 [b, c] ++ [b, c, c] ++ [b, a+0, b] :=\nby mk_mem_list\n\n--- my example\nexample (a b c : nat) : a \u2208 [b, c] ++ [b, c+0, c] ++ [b, a+1, b] :=\nby mk_mem_list\n\nexample (a b c : nat) (l : list nat) : a \u2208 l \u2192 a \u2208 [b, c] ++ b::l :=\nbegin intros, mk_mem_list end\n\nexample (a b c : nat) (l\u2081 l\u2082 : list nat) : a \u2208 l\u2081 \u2192 a \u2208 b::b::c::l\u2082 ++ b::c::l\u2081 ++ [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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : 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\u2093'. -/\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  \u27e8(\u00b7 * \u00b7) r, mul_add r\u27e9\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\u2093'. -/\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  \u27e8fun a => a * r, fun _ _ => add_mul _ _ r\u27e9\n#align add_hom.mul_right AddHom.mulRight\n\nend AddHom\n\nsection AddHomClass\n\nvariable {F : Type _} [NonAssocSemiring \u03b1] [NonAssocSemiring \u03b2] [AddHomClass F \u03b1 \u03b2]\n\n/- warning: map_bit0 -> map_bit0 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {F : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : NonAssocSemiring.{u2} \u03b2] [_inst_3 : AddHomClass.{u3, u1, u2} F \u03b1 \u03b2 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_2)))] (f : F) (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (AddHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_2))) _inst_3)) f (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) a)) (bit0.{u2} \u03b2 (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_2))) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (AddHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_2))) _inst_3)) f a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {F : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : NonAssocSemiring.{u3} \u03b2] [_inst_3 : AddHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u3} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 _inst_2)))] (f : F) (a : \u03b1), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) (bit0.{u2} \u03b1 (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) a)) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u3} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 _inst_2))) _inst_3) f (bit0.{u2} \u03b1 (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) a)) (bit0.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) a) (Distrib.toAdd.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) a) (NonUnitalNonAssocSemiring.toDistrib.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) a) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) a) _inst_2))) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u3} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 _inst_2))) _inst_3) f a))\nCase conversion may be inaccurate. Consider using '#align map_bit0 map_bit0\u2093'. -/\n/-- Additive homomorphisms preserve `bit0`. -/\n@[simp]\ntheorem map_bit0 (f : F) (a : \u03b1) : (f (bit0 a) : \u03b2) = 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 \u2192+ R\n    where\n  toFun := (\u00b7 * \u00b7) 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 (\u1fb0 : R), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : R) => R) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_mul_left {R : Type _} [NonUnitalNonAssocSemiring R] (r : R) :\n    \u21d1(mulLeft r) = (\u00b7 * \u00b7) 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 \u2192+ 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 (\u1fb0 : R), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : R) => R) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_mul_right {R : Type _} [NonUnitalNonAssocSemiring R] (r : R) :\n    \u21d1(mulRight r) = (\u00b7 * 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\u2093'. -/\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 \u03b1] [HasDistribNeg \u03b1]\n\nopen MulOpposite\n\ninstance : HasDistribNeg \u03b1\u1d50\u1d52\u1d56 :=\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 \u03b1] [HasDistribNeg \u03b1]\n\n/- warning: inv_neg' -> inv_neg' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Group.{u1} \u03b1] [_inst_2 : HasDistribNeg.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_1))))] (a : \u03b1), Eq.{succ u1} \u03b1 (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_1)) (Neg.neg.{u1} \u03b1 (InvolutiveNeg.toHasNeg.{u1} \u03b1 (HasDistribNeg.toHasInvolutiveNeg.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_1)))) _inst_2)) a)) (Neg.neg.{u1} \u03b1 (InvolutiveNeg.toHasNeg.{u1} \u03b1 (HasDistribNeg.toHasInvolutiveNeg.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_1)))) _inst_2)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_1)) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Group.{u1} \u03b1] [_inst_2 : HasDistribNeg.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_1))))] (a : \u03b1), Eq.{succ u1} \u03b1 (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_1)))) (Neg.neg.{u1} \u03b1 (InvolutiveNeg.toNeg.{u1} \u03b1 (HasDistribNeg.toInvolutiveNeg.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_1)))) _inst_2)) a)) (Neg.neg.{u1} \u03b1 (InvolutiveNeg.toNeg.{u1} \u03b1 (HasDistribNeg.toInvolutiveNeg.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_1)))) _inst_2)) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_1)))) a))\nCase conversion may be inaccurate. Consider using '#align inv_neg' inv_neg'\u2093'. -/\n@[simp]\ntheorem inv_neg' (a : \u03b1) : (-a)\u207b\u00b9 = -a\u207b\u00b9 := 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 \u03b1] {a b c : \u03b1}\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 {\u03b1 : Type.{u1}} [_inst_1 : NonUnitalCommRing.{u1} \u03b1] {b : \u03b1} {c : \u03b1} {x : \u03b1}, (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) x x) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) b x)) c) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1))))))))) -> (Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) y y) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) b y)) c) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1))))))))) (And (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) x y) b) (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) x y) c))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonUnitalCommRing.{u1} \u03b1] {b : \u03b1} {c : \u03b1} {x : \u03b1}, (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))) x x) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))) b x)) c) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (SemigroupWithZero.toZero.{u1} \u03b1 (NonUnitalSemiring.toSemigroupWithZero.{u1} \u03b1 (NonUnitalRing.toNonUnitalSemiring.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1))))))) -> (Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))) y y) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))) b y)) c) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (SemigroupWithZero.toZero.{u1} \u03b1 (NonUnitalSemiring.toSemigroupWithZero.{u1} \u03b1 (NonUnitalRing.toNonUnitalSemiring.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1))))))) (And (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))))) x y) b) (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonUnitalRing.toNonUnitalNonAssocRing.{u1} \u03b1 (NonUnitalCommRing.toNonUnitalRing.{u1} \u03b1 _inst_1)))) x y) c))))\nCase conversion may be inaccurate. Consider using '#align Vieta_formula_quadratic vieta_formula_quadratic\u2093'. -/\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 : \u03b1} (h : x * x - b * x + c = 0) :\n    \u2203 y : \u03b1, y * y - b * y + c = 0 \u2227 x + y = b \u2227 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' \u27e8b - x, _, by simp, by rw [this]\u27e9\n  rw [this, sub_add, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocRing.{u1} \u03b1] [_inst_2 : Nontrivial.{u1} \u03b1] (a : \u03b1), Ne.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u1} \u03b1 _inst_1)))))))) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocRing.{u1} \u03b1] [_inst_2 : Nontrivial.{u1} \u03b1] (a : \u03b1), Ne.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 _inst_1)))) a\nCase conversion may be inaccurate. Consider using '#align succ_ne_self succ_ne_self\u2093'. -/\ntheorem succ_ne_self [NonAssocRing \u03b1] [Nontrivial \u03b1] (a : \u03b1) : a + 1 \u2260 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocRing.{u1} \u03b1] [_inst_2 : Nontrivial.{u1} \u03b1] (a : \u03b1), Ne.{succ u1} \u03b1 (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u1} \u03b1 _inst_1)))))))) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocRing.{u1} \u03b1] [_inst_2 : Nontrivial.{u1} \u03b1] (a : \u03b1), Ne.{succ u1} \u03b1 (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (AddGroupWithOne.toSub.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u1} \u03b1 _inst_1)))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 _inst_1)))) a\nCase conversion may be inaccurate. Consider using '#align pred_ne_self pred_ne_self\u2093'. -/\ntheorem pred_ne_self [NonAssocRing \u03b1] [Nontrivial \u03b1] (a : \u03b1) : a - 1 \u2260 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 (\u03b1)\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 (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : IsLeftCancelMulZero.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 _inst_1)) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1)))))], NoZeroDivisors.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 _inst_1)) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : IsLeftCancelMulZero.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)))], NoZeroDivisors.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align is_left_cancel_mul_zero.to_no_zero_divisors IsLeftCancelMulZero.to_noZeroDivisors\u2093'. -/\ntheorem IsLeftCancelMulZero.to_noZeroDivisors [Ring \u03b1] [IsLeftCancelMulZero \u03b1] : NoZeroDivisors \u03b1 :=\n  by\n  refine' \u27e8fun x y h => _\u27e9\n  by_cases hx : x = 0\n  \u00b7 left\n    exact hx\n  \u00b7 right\n    rw [\u2190 sub_zero (x * y), \u2190 MulZeroClass.mul_zero x, \u2190 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 (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : IsRightCancelMulZero.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 _inst_1)) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1)))))], NoZeroDivisors.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 _inst_1)) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : IsRightCancelMulZero.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)))], NoZeroDivisors.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align is_right_cancel_mul_zero.to_no_zero_divisors IsRightCancelMulZero.to_noZeroDivisors\u2093'. -/\ntheorem IsRightCancelMulZero.to_noZeroDivisors [Ring \u03b1] [IsRightCancelMulZero \u03b1] :\n    NoZeroDivisors \u03b1 := by\n  refine' \u27e8fun x y h => _\u27e9\n  by_cases hy : y = 0\n  \u00b7 right\n    exact hy\n  \u00b7 left\n    rw [\u2190 sub_zero (x * y), \u2190 MulZeroClass.zero_mul y, \u2190 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 (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : NoZeroDivisors.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 _inst_1)) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1)))))], IsCancelMulZero.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 _inst_1)) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : NoZeroDivisors.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)))], IsCancelMulZero.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align no_zero_divisors.to_is_cancel_mul_zero NoZeroDivisors.to_isCancelMulZero\u2093'. -/\ninstance (priority := 100) NoZeroDivisors.to_isCancelMulZero [Ring \u03b1] [NoZeroDivisors \u03b1] :\n    IsCancelMulZero \u03b1\n    where\n  mul_left_cancel_of_ne_zero a b c ha h :=\n    by\n    rw [\u2190 sub_eq_zero, \u2190 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 [\u2190 sub_eq_zero, \u2190 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 (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [h : Nontrivial.{u1} \u03b1] [_inst_2 : NoZeroDivisors.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 _inst_1)) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1)))))], IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [h : Nontrivial.{u1} \u03b1] [_inst_2 : NoZeroDivisors.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)))], IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align no_zero_divisors.to_is_domain NoZeroDivisors.to_isDomain\u2093'. -/\ntheorem NoZeroDivisors.to_isDomain [Ring \u03b1] [h : Nontrivial \u03b1] [NoZeroDivisors \u03b1] : IsDomain \u03b1 :=\n  { NoZeroDivisors.to_isCancelMulZero \u03b1, 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 (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)], NoZeroDivisors.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 _inst_1)) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)], NoZeroDivisors.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align is_domain.to_no_zero_divisors IsDomain.to_noZeroDivisors\u2093'. -/\ninstance (priority := 100) IsDomain.to_noZeroDivisors [Ring \u03b1] [IsDomain \u03b1] : NoZeroDivisors \u03b1 :=\n  IsRightCancelMulZero.to_noZeroDivisors \u03b1\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 \u03b9 I M s` is a collection of\n`smooth_bump_function`s `f i` indexed by `i : \u03b9` 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 \u2208 s`, there exists `i : \u03b9` such that `f i =\u1da0[\ud835\udcdd x] 1`.\nIn the same settings, a `smooth_partition_of_unity \u03b9 I M s` is a collection of smooth nonnegative\nfunctions `f i : C^\u221e\u27eeI, M; \ud835\udcd8(\u211d), \u211d\u27ef`, `i : \u03b9`, such that\n\n* the family of sets `support (f i)` is locally finite;\n* for each `x \u2208 s`, the sum `\u2211\u1da0 i, f i x` equals one;\n* for each `x`, the sum `\u2211\u1da0 i, f i x` is less than or equal to one.\n\nWe say that `f : smooth_bump_covering \u03b9 I M s` is *subordinate* to a map `U : M \u2192 set M` if for each\nindex `i`, we have `tsupport (f i) \u2286 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 `\u03c3`-compact Hausdorff topology,\nfor any `U : M \u2192 set M` such that `\u2200 x \u2208 s, U x \u2208 \ud835\udcdd x` there exists a `smooth_bump_covering \u03b9 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\u03b9 uE uH uM\n\nopen function filter finite_dimensional set\nopen_locale topological_space manifold classical filter big_operators\n\nnoncomputable theory\n\nvariables {\u03b9 : Type u\u03b9}\n{E : Type uE} [normed_group E] [normed_space \u211d E] [finite_dimensional \u211d E]\n{H : Type uH} [topological_space H] (I : model_with_corners \u211d 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 \u03b9 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\u2208 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 `\u03c3`-compact Hausdorff topology, for\nany `U : M \u2192 set M` such that `\u2200 x \u2208 s, U x \u2208 \ud835\udcdd x` there exists a `smooth_bump_covering \u03b9 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 `\u211d^n` for large enough `n`.  -/\n\nvariables (\u03b9 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 \u2208 s` for all `i`;\n* the family `\u03bb i, support (f i)` is locally finite;\n* for each point `x \u2208 s` there exists `i` such that `f i =\u1da0[\ud835\udcdd 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 \u2192 set M`, `\u2200 x, U x \u2208 \ud835\udcdd 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 : \u03b9 \u2192 M)\n(to_fun : \u03a0 i, smooth_bump_function I (c i))\n(c_mem' : \u2200 i, c i \u2208 s)\n(locally_finite' : locally_finite (\u03bb i, support (to_fun i)))\n(eventually_eq_one' : \u2200 x \u2208 s, \u2203 i, to_fun i =\u1da0[\ud835\udcdd 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 `\u03bb i, support (f i)` is locally finite;\n* for all `x \u2208 s` the sum `\u2211\u1da0 i, f i x` equals one;\n* for all `x`, the sum `\u2211\u1da0 i, f i x` is less than or equal to one. -/\nstructure smooth_partition_of_unity (s : set M := univ) :=\n(to_fun : \u03b9 \u2192 C^\u221e\u27eeI, M; \ud835\udcd8(\u211d), \u211d\u27ef)\n(locally_finite' : locally_finite (\u03bb i, support (to_fun i)))\n(nonneg' : \u2200 i x, 0 \u2264 to_fun i x)\n(sum_eq_one' : \u2200 x \u2208 s, \u2211\u1da0 i, to_fun i x = 1)\n(sum_le_one' : \u2200 x, \u2211\u1da0 i, to_fun i x \u2264 1)\n\nvariables {\u03b9 I M}\n\nnamespace smooth_partition_of_unity\n\nvariables {s : set M} (f : smooth_partition_of_unity \u03b9 I M s)\n\ninstance {s : set M} : has_coe_to_fun (smooth_partition_of_unity \u03b9 I M s)\n  (\u03bb _, \u03b9 \u2192 C^\u221e\u27eeI, M; \ud835\udcd8(\u211d), \u211d\u27ef) :=\n\u27e8smooth_partition_of_unity.to_fun\u27e9\n\nprotected lemma locally_finite : locally_finite (\u03bb i, support (f i)) :=\nf.locally_finite'\n\nlemma nonneg (i : \u03b9) (x : M) : 0 \u2264 f i x := f.nonneg' i x\n\nlemma sum_eq_one {x} (hx : x \u2208 s) : \u2211\u1da0 i, f i x = 1 := f.sum_eq_one' x hx\n\nlemma sum_le_one (x : M) : \u2211\u1da0 i, f i x \u2264 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 \u03b9 M s :=\n{ to_fun := \u03bb i, f i, .. f }\n\nlemma smooth_sum : smooth I \ud835\udcd8(\u211d) (\u03bb x, \u2211\u1da0 i, f i x) :=\nsmooth_finsum (\u03bb i, (f i).smooth) f.locally_finite\n\nlemma le_one (i : \u03b9) (x : M) : f i x \u2264 1 := f.to_partition_of_unity.le_one i x\n\nlemma sum_nonneg (x : M) : 0 \u2264 \u2211\u1da0 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 \u03b9 I M s) (U : \u03b9 \u2192 set M) :=\n\u2200 i, tsupport (f i) \u2286 U i\n\n@[simp] lemma is_subordinate_to_partition_of_unity {f : smooth_partition_of_unity \u03b9 I M s}\n  {U : \u03b9 \u2192 set M} :\n  f.to_partition_of_unity.is_subordinate U \u2194 f.is_subordinate U :=\niff.rfl\n\nalias is_subordinate_to_partition_of_unity \u2194\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 \u211d E] and [smooth_manifold_with_corners I M]\nlemma smooth_to_partition_of_unity {E : Type uE} [normed_group E] [normed_space \u211d E]\n  {H : Type uH} [topological_space H] {I : model_with_corners \u211d E H}\n  {M : Type uM} [topological_space M] [charted_space H M] {s : set M}\n  (f : bump_covering \u03b9 M s) (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (f i)) (i : \u03b9) :\n  smooth I \ud835\udcd8(\u211d) (f.to_partition_of_unity i) :=\n(hf i).mul $ smooth_finprod_cond (\u03bb 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 \u03b9 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 \u03b9 M s) (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (f i)) :\n  smooth_partition_of_unity \u03b9 I M s :=\n{ to_fun := \u03bb i, \u27e8f.to_partition_of_unity i, f.smooth_to_partition_of_unity hf i\u27e9,\n  .. f.to_partition_of_unity }\n\n@[simp] lemma to_smooth_partition_of_unity_to_partition_of_unity (f : bump_covering \u03b9 M s)\n  (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (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 \u03b9 M s)\n  (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (f i)) (i : \u03b9) :\n  \u21d1(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 \u03b9 M s}\n  {U : \u03b9 \u2192 set M} (h : f.is_subordinate U) (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (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 \u2192 set M} (fs : smooth_bump_covering \u03b9 I M s) {I}\n\ninstance : has_coe_to_fun (smooth_bump_covering \u03b9 I M s)\n  (\u03bb x, \u03a0 (i : \u03b9), smooth_bump_function I (x.c i)) :=\n\u27e8to_fun\u27e9\n\n@[simp] lemma coe_mk (c : \u03b9 \u2192 M) (to_fun : \u03a0 i, smooth_bump_function I (c i))\n  (h\u2081 h\u2082 h\u2083) : \u21d1(mk c to_fun h\u2081 h\u2082 h\u2083 : smooth_bump_covering \u03b9 I M s) = to_fun :=\nrfl\n\n/--\nWe say that `f : smooth_bump_covering \u03b9 I M s` is *subordinate* to a map `U : M \u2192 set M` if for each\nindex `i`, we have `tsupport (f i) \u2286 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 \u03b9 I M s) (U : M \u2192 set M) :=\n\u2200 i, tsupport (f i) \u2286 U (f.c i)\n\nlemma is_subordinate.support_subset {fs : smooth_bump_covering \u03b9 I M s} {U : M \u2192 set M}\n  (h : fs.is_subordinate U) (i : \u03b9) :\n  support (fs i) \u2286 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 `\u03c3`-compact topological space. Let `s` be a closed set\nin `M` and `U : M \u2192 set M` be a collection of sets such that `U x \u2208 \ud835\udcdd x` for every `x \u2208 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 : \u2200 x \u2208 s, U x \u2208 \ud835\udcdd x) :\n  \u2203 (\u03b9 : Type uM) (f : smooth_bump_covering \u03b9 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 := \u03bb 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 \u27e8\u03b9, c, f, hf, hsub', hfin\u27e9, 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 (\u03bb i, (f i).open_support)\n    (\u03bb x hx, hfin.point_finite x) hsub' with \u27e8V, hsV, hVc, hVf\u27e9,\n  choose r hrR hr using \u03bb i, (f i).exists_r_pos_lt_subset_ball (hVc i) (hVf i),\n  refine \u27e8\u03b9, \u27e8c, \u03bb i, (f i).update_r (r i) (hrR i), hcs, _, \u03bb x hx, _\u27e9, \u03bb i, _\u27e9,\n  { simpa only [smooth_bump_function.support_update_r] },\n  { refine (mem_Union.1 $ hsV hx).imp (\u03bb 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 (\u03bb i, support (fs i)) := fs.locally_finite'\n\nprotected lemma point_finite (x : M) : {i | fs i x \u2260 0}.finite :=\nfs.locally_finite.point_finite x\n\nlemma mem_chart_at_source_of_eq_one {i : \u03b9} {x : M} (h : fs i x = 1) :\n  x \u2208 (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 : \u03b9} {x : M} (h : fs i x = 1) :\n  x \u2208 (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 =\u1da0[\ud835\udcdd x] 1`. -/\ndef ind (x : M) (hx : x \u2208 s) : \u03b9 := (fs.eventually_eq_one' x hx).some\n\nlemma eventually_eq_one (x : M) (hx : x \u2208 s) : fs (fs.ind x hx) =\u1da0[\ud835\udcdd x] 1 :=\n(fs.eventually_eq_one' x hx).some_spec\n\nlemma apply_ind (x : M) (hx : x \u2208 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 \u2208 s) : x \u2208 support (fs $ fs.ind x hx) :=\nby simp [fs.apply_ind x hx]\n\nlemma mem_chart_at_ind_source (x : M) (hx : x \u2208 s) :\n  x \u2208 (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 \u2208 s) :\n  x \u2208 (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 \u03b9 :=\nfs.locally_finite.fintype_of_compact $ \u03bb 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 \u03b9 M s` with smooth functions `f i` is a `smooth_bump_covering`. -/\ndef to_bump_covering : bump_covering \u03b9 M s :=\n{ to_fun := \u03bb i, \u27e8fs i, (fs i).continuous\u27e9,\n  locally_finite' := fs.locally_finite,\n  nonneg' := \u03bb i x, (fs i).nonneg,\n  le_one' := \u03bb 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 \u03b9 I M s} {U : M \u2192 set M} :\n  f.to_bump_covering.is_subordinate (\u03bb i, U (f.c i)) \u2194 f.is_subordinate U :=\niff.rfl\n\nalias is_subordinate_to_bump_covering \u2194\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 \u03b9 I M s :=\nfs.to_bump_covering.to_smooth_partition_of_unity (\u03bb i, (fs i).smooth)\n\nlemma to_smooth_partition_of_unity_apply (i : \u03b9) (x : M) :\n  fs.to_smooth_partition_of_unity i x = fs i x * \u220f\u1da0 j (hj : well_ordering_rel j i), (1 - fs j x) :=\nrfl\n\nlemma to_smooth_partition_of_unity_eq_mul_prod (i : \u03b9) (x : M) (t : finset \u03b9)\n  (ht : \u2200 j, well_ordering_rel j i \u2192 fs j x \u2260 0 \u2192 j \u2208 t) :\n  fs.to_smooth_partition_of_unity i x =\n    fs i x * \u220f j in t.filter (\u03bb 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 : \u03b9) (x : M) :\n  \u2203 t : finset \u03b9, fs.to_smooth_partition_of_unity i =\u1da0[\ud835\udcdd x]\n    fs i * \u220f j in t.filter (\u03bb 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 : \u03b9} {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 : \u03b9) :\n  support (fs.to_smooth_partition_of_unity i) \u2286 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 \u03b9 I M s} {U : M \u2192 set M}\n  (h : f.is_subordinate U) :\n  f.to_smooth_partition_of_unity.is_subordinate (\u03bb 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  \u2211\u1da0 i, fs.to_smooth_partition_of_unity i x = 1 - \u220f\u1da0 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 \u03c3-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  \u2203 f : C^\u221e\u27eeI, M; \ud835\udcd8(\u211d), \u211d\u27ef, eq_on f 0 s \u2227 eq_on f 1 t \u2227 \u2200 x, f x \u2208 Icc (0 : \u211d) 1 :=\nbegin\n  have : \u2200 x \u2208 t, s\u1d9c \u2208 \ud835\udcdd x, from \u03bb 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 \u27e8\u03b9, f, hf\u27e9,\n  set g := f.to_smooth_partition_of_unity,\n  refine \u27e8\u27e8_, g.smooth_sum\u27e9, \u03bb x hx, _, \u03bb x, g.sum_eq_one, \u03bb x, \u27e8g.sum_nonneg x, g.sum_le_one x\u27e9\u27e9,\n  suffices : \u2200 i, g i x = 0,\n    by simp only [this, cont_mdiff_map.coe_fn_mk, finsum_zero, pi.zero_apply],\n  refine \u03bb 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 : \u03b9) (s : set M) : smooth_partition_of_unity \u03b9 I M s :=\n(bump_covering.single i s).to_smooth_partition_of_unity $ \u03bb 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 \u03b9] (s : set M) : inhabited (smooth_partition_of_unity \u03b9 I M s) :=\n\u27e8single default s\u27e9\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 \u03b9 X s` that is subordinate to `U`. -/\nlemma exists_is_subordinate {s : set M} (hs : is_closed s) (U : \u03b9 \u2192 set M) (ho : \u2200 i, is_open (U i))\n  (hU : s \u2286 \u22c3 i, U i) :\n  \u2203 f : smooth_partition_of_unity \u03b9 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 \ud835\udcd8(\u211d)) _ hs U ho hU\n    with \u27e8f, hf, hfU\u27e9,\n  { exact \u27e8f.to_smooth_partition_of_unity hf, hfU.to_smooth_partition_of_unity hf\u27e9 },\n  { intros s t hs ht hd,\n    rcases exists_smooth_zero_one_of_closed I hs ht hd with \u27e8f, hf\u27e9,\n    exact \u27e8f, f.smooth, hf\u27e9 }\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 tactic --hide\nlemma not_iff_imp_false (P : Prop) : \u00ac P \u2194 P \u2192 false := iff.rfl -- hide\nlemma contra (P Q : Prop) : (P \u2227 \u00ac P) \u2192 Q := by {cc} --hide\n\n\n/-Lemma\n$\u00ac \\mathrm{true}$ implies $\\mathrm{false}$.\n-/\nlemma not_true_imp_false : \u00ac true \u2192 false :=\nbegin\n  rw not_iff_imp_false,\n  intro h,\n  apply h,\n  triv,\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/logic3/nottf.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7718434978390747, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4944706190407526}}
{"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 \u2208 (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 : (\u2200(s : Set), \u2203(t : Set), \u2200(sel sel_el tel: Set), \n--   sel \u2208 s \u2192 sel_el \u2208 sel \u2192 tel \u2208 t \u2194 sel_el = tel) \u2227 (\u2200(s: Set) (\u03c6 : Set \u2192 Set),\n--    (\u2200(x y a : Set), x \u2208 s \u2227 \u03c6(x) = y \u2192 \u03c6(x) = a \u2194 a = y) \u2192 \u2203(t : Set), \u2200(z x: Set),\n--     x \u2208 s \u2192 z \u2208 t \u2194 \u03c6(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 \u2192 prop \u2192 state_t \u2115 option proof`: The main entry point.\n  Gets a context and a goal, and returns a `proof` object or fails, using `state_t \u2115` for the name\n  generator.\n* `search : context \u2192 prop \u2192 state_t \u2115 option proof`: Same meaning as `proof`, called during the\n  search phase (see below).\n* `context.add : prop \u2192 proof \u2192 context \u2192 except (prop \u2192 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 `\u0393, \u22a4 \u22a2 B` to `\u0393 \u22a2 B`\n    * `\u0393, \u22a5 \u22a2 B` is true\n    * simplify `\u0393, A \u2227 B \u22a2 C` to `\u0393, A, B \u22a2 C`\n    * simplify `\u0393, \u22a5 \u2192 A \u22a2 B` to `\u0393 \u22a2 B`\n    * simplify `\u0393, \u22a4 \u2192 A \u22a2 B` to `\u0393, A \u22a2 B`\n    * simplify `\u0393, A \u2227 B \u2192 C \u22a2 D` to `\u0393, A \u2192 B \u2192 C \u22a2 D`\n    * simplify `\u0393, A \u2228 B \u2192 C \u22a2 D` to `\u0393, A \u2192 C, B \u2192 C \u22a2 D`\n  * `prove`:\n    * `\u0393 \u22a2 \u22a4` is true\n    * simplify `\u0393 \u22a2 A \u2192 B` to `\u0393, A \u22a2 B`\n  * `search`:\n    * `\u0393, P \u22a2 P` is true\n    * simplify `\u0393, P, P \u2192 A \u22a2 B` to `\u0393, P, A \u22a2 B`\n* level 2: Splitting rules, validity preserving: apply after level 1 rules. Done in `prove`\n  * simplify `\u0393 \u22a2 A \u2227 B` to `\u0393 \u22a2 A` and `\u0393 \u22a2 B`\n  * simplify `\u0393, A \u2228 B \u22a2 C` to `\u0393, A \u22a2 C` and `\u0393, B \u22a2 C`\n* level 3: Splitting rules, not validity preserving: apply only if nothing else applies.\n  Done in `search`\n  * `\u0393 \u22a2 A \u2228 B` follows from `\u0393 \u22a2 A`\n  * `\u0393 \u22a2 A \u2228 B` follows from `\u0393 \u22a2 B`\n  * `\u0393, (A\u2081 \u2192 A\u2082) \u2192 C \u22a2 B` follows from `\u0393, A\u2082 \u2192 C, A\u2081 \u22a2 A\u2082` and `\u0393, C \u22a2 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 \u2192 q) \u2227 (q \u2192 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 := \u27e8and_kind.and\u27e9\n\n/-- A reified inductive type for propositional logic. -/\n@[derive [has_reflect, decidable_eq]]\ninductive prop : Type\n| var : \u2115 \u2192 prop            -- propositional atoms P_i\n| true : prop               -- \u22a4\n| false : prop              -- \u22a5\n| and' : and_kind \u2192 prop \u2192 prop \u2192 prop  -- p \u2227 q, p \u2194 q, p = q\n| or : prop \u2192 prop \u2192 prop   -- p \u2228 q\n| imp : prop \u2192 prop \u2192 prop  -- p \u2192 q\n\n/-- Constructor for `p \u2227 q`. -/\n@[pattern] def prop.and : prop \u2192 prop \u2192 prop := prop.and' and_kind.and\n/-- Constructor for `p \u2194 q`. -/\n@[pattern] def prop.iff : prop \u2192 prop \u2192 prop := prop.and' and_kind.iff\n/-- Constructor for `p = q`. -/\n@[pattern] def prop.eq : prop \u2192 prop \u2192 prop := prop.and' and_kind.eq\n/-- Constructor for `\u00ac 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 := \u27e8prop.true\u27e9\n\n/-- Given the contents of an `and` variant, return the two conjuncts. -/\ndef and_kind.sides : and_kind \u2192 prop \u2192 prop \u2192 prop \u00d7 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 \u2192 format\n| (prop.var i) := format!\"v{i}\"\n| prop.true := format!\"\u22a4\"\n| prop.false := format!\"\u22a5\"\n| (prop.and p q) := format!\"({p.to_format} \u2227 {q.to_format})\"\n| (prop.iff p q) := format!\"({p.to_format} \u2194 {q.to_format})\"\n| (prop.eq p q) := format!\"({p.to_format} = {q.to_format})\"\n| (prop.or p q) := format!\"({p.to_format} \u2228 {q.to_format})\"\n| (prop.imp p q) := format!\"({p.to_format} \u2192 {q.to_format})\"\n\nmeta instance : has_to_format prop := \u27e8prop.to_format\u27e9\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\u2081 p\u2082 _ _ p\u2081 p\u2082 _ _ p\u2081 p\u2082 _ _ p\u2081 p\u2082 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\u2081 q\u2082 { exact (ap.cmp aq).or_else ((p\u2081 q\u2081).or_else (p\u2082 q\u2082)) },\n  case or or : q\u2081 q\u2082 { exact (p\u2081 q\u2081).or_else (p\u2082 q\u2082) },\n  case imp imp : q\u2081 q\u2082 { exact (p\u2081 q\u2081).or_else (p\u2082 q\u2082) },\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 := \u27e8\u03bb p q, p.cmp q = lt\u27e9\n\ninstance : decidable_rel (@has_lt.lt prop _) := \u03bb _ _, ordering.decidable_eq _ _\n\nend\n\n/-- A reified inductive proof type for intuitionistic propositional logic. -/\n@[derive has_reflect]\ninductive proof\n-- \u22a2 A, causes failure during reconstruction\n| \u00absorry\u00bb : proof\n-- (n: A) \u22a2 A\n| hyp (n : name) : proof\n-- \u22a2 \u22a4\n| triv : proof\n-- (p: \u22a5) \u22a2 A\n| exfalso' (p : proof) : proof\n-- (p: (x: A) \u22a2 B) \u22a2 A \u2192 B\n| intro (x : name) (p : proof) : proof\n-- ak = and:  (p: A \u2227 B) \u22a2 A\n-- ak = iff:  (p: A \u2194 B) \u22a2 A \u2192 B\n-- ak = eq:  (p: A = B) \u22a2 A \u2192 B\n| and_left (ak : and_kind) (p : proof) : proof\n-- ak = and:  (p: A \u2227 B) \u22a2 B\n-- ak = iff:  (p: A \u2194 B) \u22a2 B \u2192 A\n-- ak = eq:  (p: A = B) \u22a2 B \u2192 A\n| and_right (ak : and_kind) (p : proof) : proof\n-- ak = and:  (p\u2081: A) (p\u2082: B) \u22a2 A \u2227 B\n-- ak = iff:  (p\u2081: A \u2192 B) (p\u2081: B \u2192 A) \u22a2 A \u2194 B\n-- ak = eq:  (p\u2081: A \u2192 B) (p\u2081: B \u2192 A) \u22a2 A = B\n| and_intro (ak : and_kind) (p\u2081 p\u2082 : proof) : proof\n-- ak = and:  (p: A \u2227 B \u2192 C) \u22a2 A \u2192 B \u2192 C\n-- ak = iff:  (p: (A \u2194 B) \u2192 C) \u22a2 (A \u2192 B) \u2192 (B \u2192 A) \u2192 C\n-- ak = eq:  (p: (A = B) \u2192 C) \u22a2 (A \u2192 B) \u2192 (B \u2192 A) \u2192 C\n| curry (ak : and_kind) (p : proof) : proof\n-- This is a partial application of curry.\n-- ak = and:  (p: A \u2227 B \u2192 C) (q : A) \u22a2 B \u2192 C\n-- ak = iff:  (p: (A \u2194 B) \u2192 C) (q: A \u2192 B) \u22a2 (B \u2192 A) \u2192 C\n-- ak = eq:  (p: (A \u2194 B) \u2192 C) (q: A \u2192 B) \u22a2 (B \u2192 A) \u2192 C\n| curry\u2082 (ak : and_kind) (p q : proof) : proof\n-- (p: A \u2192 B) (q: A) \u22a2 B\n| app' : proof \u2192 proof \u2192 proof\n-- (p: A \u2228 B \u2192 C) \u22a2 A \u2192 C\n| or_imp_left (p : proof) : proof\n-- (p: A \u2228 B \u2192 C) \u22a2 B \u2192 C\n| or_imp_right (p : proof) : proof\n-- (p: A) \u22a2 A \u2228 B\n| or_inl (p : proof) : proof\n-- (p: B) \u22a2 A \u2228 B\n| or_inr (p : proof) : proof\n-- (p: B) \u22a2 A \u2228 B\n-- (p\u2081: A \u2228 B) (p\u2082: (x: A) \u22a2 C) (p\u2083: (x: B) \u22a2 C) \u22a2 C\n| or_elim' (p\u2081 : proof) (x : name) (p\u2082 p\u2083 : proof) : proof\n-- (p\u2081: decidable A) (p\u2082: (x: A) \u22a2 C) (p\u2083: (x: \u00ac A) \u22a2 C) \u22a2 C\n| decidable_elim (classical : bool) (p\u2081 x : name) (p\u2082 p\u2083 : proof) : proof\n-- classical = ff: (p: decidable A) \u22a2 A \u2228 \u00acA\n-- classical = tt: (p: Prop) \u22a2 p \u2228 \u00acp\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) \u2192 B) \u2192 C) \u22a2 B \u2192 C\n| imp_imp_simp (x : name) (p : proof) : proof\n\ninstance : inhabited proof := \u27e8proof.triv\u27e9\n\n/-- Debugging printer for proof objects. -/\nmeta def proof.to_format : proof \u2192 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!\"(\u03bb {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!\"\u27e8{p.to_format}, {q.to_format}\u27e9\"\n| (proof.curry _ p) := format!\"(curry {p.to_format})\"\n| (proof.curry\u2082 _ 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 (\u03bb {x}, {q.to_format}) (\u03bb {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 (\u03bb {x}, {q.to_format}) (\u03bb {x}, {r.to_format})\"\n| (proof.imp_imp_simp _ p) := format!\"(imp_imp_simp {p.to_format})\"\n\nmeta instance : has_to_format proof := \u27e8proof.to_format\u27e9\n\n/-- A variant on `proof.exfalso'` that performs opportunistic simplification. -/\nmeta def proof.exfalso : prop \u2192 proof \u2192 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 \u2192 name \u2192 proof \u2192 proof \u2192 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 \u2192 proof \u2192 proof\n| (proof.curry ak p) q := proof.curry\u2082 ak p q\n| (proof.curry\u2082 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 \u2192 proof \u2192 option prop\n| \u0393 (proof.hyp i) := \u0393.find i\n| \u0393 proof.triv := some prop.true\n| \u0393 (proof.exfalso' A p) := guard (p.check \u0393 = some prop.false) $> A\n| \u0393 (proof.intro x A p) := do B \u2190 p.check (\u0393.insert x A), pure (prop.imp A B)\n| \u0393 (proof.and_left ak p) := do\n  prop.and' ak' A B \u2190 p.check \u0393 | none,\n  guard (ak = ak') $> (ak.sides A B).1\n| \u0393 (proof.and_right ak p) := do\n  prop.and' ak' A B \u2190 p.check \u0393 | none,\n  guard (ak = ak') $> (ak.sides A B).2\n| \u0393 (proof.and_intro and_kind.and p q) := do\n  A \u2190 p.check \u0393, B \u2190 q.check \u0393,\n  pure (A.and B)\n| \u0393 (proof.and_intro ak p q) := do\n  prop.imp A B \u2190 p.check \u0393 | none,\n  C \u2190 q.check \u0393, guard (C = prop.imp B A) $> (A.and' ak B)\n| \u0393 (proof.curry ak p) := do\n  prop.imp (prop.and' ak' A B) C \u2190 p.check \u0393 | none,\n  let (A', B') := ak.sides A B,\n  guard (ak = ak') $> (A'.imp $ B'.imp C)\n| \u0393 (proof.curry\u2082 ak p q) := do\n  prop.imp (prop.and' ak' A B) C \u2190 p.check \u0393 | none,\n  A\u2082 \u2190 q.check \u0393,\n  let (A', B') := ak.sides A B,\n  guard (ak = ak' \u2227 A\u2082 = A') $> (B'.imp C)\n| \u0393 (proof.app' p q) := do prop.imp A B \u2190 p.check \u0393 | none, A' \u2190 q.check \u0393, guard (A = A') $> B\n| \u0393 (proof.or_imp_left B p) := do\n  prop.imp (prop.or A B') C \u2190 p.check \u0393 | none,\n  guard (B = B') $> (A.imp C)\n| \u0393 (proof.or_imp_right A p) := do\n  prop.imp (prop.or A' B) C \u2190 p.check \u0393 | none,\n  guard (A = A') $> (B.imp C)\n| \u0393 (proof.or_inl B p) := do A \u2190 p.check \u0393 | none, pure (A.or B)\n| \u0393 (proof.or_inr A p) := do B \u2190 p.check \u0393 | none, pure (A.or B)\n| \u0393 (proof.or_elim p x q r) := do\n  prop.or A B \u2190 p.check \u0393 | none,\n  C \u2190 q.check (\u0393.insert x A),\n  C' \u2190 r.check (\u0393.insert x B),\n  guard (C = C') $> C\n| \u0393 (proof.imp_imp_simp x A p) := do\n  prop.imp (prop.imp A' B) C \u2190 p.check \u0393 | 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 : \u2115 \u2192 name \u00d7 \u2115 :=\n\u03bb 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 (\u0393 : context) : format :=\n\u0393.fold \"\" $ \u03bb P p f, P.to_format /- ++ \" := \" ++ p.to_format -/ ++ \",\\n\" ++ f\n\nmeta instance : has_to_format context := \u27e8context.to_format\u27e9\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 `\u22a4` and `A \u2192 \u22a4` hypotheses, close the goal if we find a `\u22a5`\nhypothesis, split all conjunctions, and also simplify `\u22a5 \u2192 A` (drop), `\u22a4 \u2192 A` (simplify to `A`),\n`A \u2227 B \u2192 C` (curry to `A \u2192 B \u2192 C`) and `A \u2228 B \u2192 C` (rewrite to `(A \u2192 C) \u2227 (B \u2192 C)` and split). -/\nmeta def context.add : prop \u2192 proof \u2192 context \u2192 except (prop \u2192 proof) context\n| prop.true p \u0393 := pure \u0393\n| prop.false p \u0393 := except.error (\u03bb A, proof.exfalso A p)\n| (prop.and' ak A B) p \u0393 := do\n  let (A, B) := ak.sides A B,\n  \u0393 \u2190 \u0393.add A (p.and_left ak),\n  \u0393.add B (p.and_right ak)\n| (prop.imp prop.false A) p \u0393 := pure \u0393\n| (prop.imp prop.true A) p \u0393 := \u0393.add A (p.app proof.triv)\n| (prop.imp (prop.and' ak A B) C) p \u0393 :=\n  let (A, B) := ak.sides A B in\n  \u0393.add (prop.imp A (B.imp C)) (p.curry ak)\n| (prop.imp (prop.or A B) C) p \u0393 := do\n  \u0393 \u2190 \u0393.add (A.imp C) p.or_imp_left,\n  \u0393.add (B.imp C) p.or_imp_right\n| (prop.imp A prop.true) p \u0393 := pure \u0393\n| A p \u0393 := pure (\u0393.insert A p)\n\n/-- Add `A` to the context `\u0393` with proof `p`. This version of `context.add` takes a continuation\nand a target proposition `B`, so that in the case that `\u22a5` is found we can skip the continuation\nand just prove `B` outright. -/\n@[inline] meta def context.with_add (\u0393 : context) (A : prop) (p : proof)\n  (B : prop) (f : context \u2192 prop \u2192 \u2115 \u2192 bool \u00d7 proof \u00d7 \u2115) (n : \u2115) : bool \u00d7 proof \u00d7 \u2115 :=\nmatch \u0393.add A p with\n| except.ok \u0393_A := f \u0393_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 \u2192 proof) : bool \u00d7 proof \u00d7 \u2115 \u2192 bool \u00d7 proof \u00d7 \u2115\n| (b, p, n) := (b, f p, n)\n\n/-- Convert a value-with-success to an optional value. -/\ndef is_ok {\u03b1} : bool \u00d7 \u03b1 \u2192 option \u03b1\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 \u2192 (\u2115 \u2192 bool \u00d7 proof \u00d7 \u2115) \u2192 \u2115 \u2192 bool \u00d7 proof \u00d7 \u2115\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 \u2228 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 \u2192 C \u22a2 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\u2081 \u2192 A\u2082) \u2192 C \u22a2 B`. We decompose the double implication into two subgoals: one to\nprove `A\u2081 \u2192 A\u2082`, which can be written `A\u2082 \u2192 C, A\u2081 \u22a2 A\u2082` (where we used `A\u2081` to simplify\n`(A\u2081 \u2192 A\u2082) \u2192 C`), and one to use the consequent, `C \u22a2 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 \u2192 prop \u2192 \u2115 \u2192 bool \u00d7 proof \u00d7 \u2115) :\n  context \u2192 prop \u2192 \u2115 \u2192 bool \u00d7 proof \u00d7 \u2115\n| \u0393 B n := match \u0393.find B with\n  | some p := (tt, p, n)\n  | none :=\n    let search\u2081 := \u0393.fold none $ \u03bb A p r, match r with\n    | some r := some r\n    | none := match A with\n      | prop.imp A' C := match \u0393.find A' with\n        | some q := is_ok $ context.with_add (\u0393.erase A) C (p.app q) B prove n\n        | none := match A' with\n          | prop.imp A\u2081 A\u2082 := do\n            let \u0393 : context := \u0393.erase A,\n            let (a, n) := fresh_name n,\n            (p\u2081, n) \u2190 is_ok $ \u0393.with_add A\u2081 (proof.hyp a) A\u2082 (\u03bb \u0393_A\u2081 A\u2082,\n              \u0393_A\u2081.with_add (prop.imp A\u2082 C) (proof.imp_imp_simp a p) A\u2082 prove) n,\n            is_ok $ \u0393.with_add C (p.app (proof.intro a p\u2081)) B prove n\n          | _ := none\n          end\n        end\n      | _ := none\n      end\n    end in\n    match search\u2081 with\n    | some r := (tt, r)\n    | none := match B with\n      | prop.or B\u2081 B\u2082 := match map_proof proof.or_inl (prove \u0393 B\u2081 n) with\n        | (ff, _) := map_proof proof.or_inr (prove \u0393 B\u2082 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 `\u0393 \u22a2 \u22a4` and `\u0393 \u22a2 A \u2192 B`, these are easy to\nhandle. The rule `\u0393 \u22a2 A \u2227 B` is a level 2 rule, also handled here. If none of these apply, we try\nthe level 2 rule `A \u2228 B \u22a2 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 \u2192 prop \u2192 \u2115 \u2192 bool \u00d7 proof \u00d7 \u2115\n| \u0393 prop.true n := (tt, proof.triv, n)\n| \u0393 (prop.imp A B) n :=\n  let (a, n) := fresh_name n in\n  map_proof (proof.intro a) $ \u0393.with_add A (proof.hyp a) B prove n\n| \u0393 (prop.and' ak A B) n :=\n  let (A, B) := ak.sides A B in\n  let (b, p, n) := prove \u0393 A n in\n  map_proof (p.and_intro ak) $ when_ok b (prove \u0393 B) n\n| \u0393 B n := \u0393.fold (\u03bb b \u0393, cond b prove (search prove) \u0393 B) (\u03bb A p IH b \u0393 n,\n    match A with\n    | prop.or A\u2081 A\u2082 :=\n      let \u0393 : context := \u0393.erase A in\n      let (a, n) := fresh_name n in\n      let (b, p\u2081, n) := \u0393.with_add A\u2081 (proof.hyp a) B (\u03bb \u0393 _, IH tt \u0393) n in\n      map_proof (proof.or_elim p a p\u2081) $\n        when_ok b (\u0393.with_add A\u2082 (proof.hyp a) B (\u03bb \u0393 _, IH tt \u0393)) n\n    | _ := IH b \u0393 n\n    end) ff \u0393 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 \u2190 read_ref atoms,\n  o \u2190 try_core $ vec.iterate failure (\u03bb 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 \u2192 tactic prop\n| `(true) := pure prop.true\n| `(false) := pure prop.false\n| `(\u00ac %%a) := prop.not <$> reify a\n| `(%%a \u2227 %%b) := prop.and <$> reify a <*> reify b\n| `(%%a \u2228 %%b) := prop.or <$> reify a <*> reify b\n| `(%%a \u2194 %%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 \u2192 %%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 \u2192 proof \u2192 tactic unit\n| \u0393 proof.sorry := fail \"itauto failed\"\n| \u0393 (proof.hyp n) := do e \u2190 \u0393.find n, exact e\n| \u0393 proof.triv := triv\n| \u0393 (proof.exfalso' p) := do\n  t \u2190 mk_mvar, to_expr ``(false.elim %%t) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.intro x p) := do e \u2190 intro_core x, apply_proof (\u0393.insert x e) p\n| \u0393 (proof.and_left and_kind.and p) := do\n  t \u2190 mk_mvar, to_expr ``(and.left %%t) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.and_left and_kind.iff p) := do\n  t \u2190 mk_mvar, to_expr ``(iff.mp %%t) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.and_left and_kind.eq p) := do\n  t \u2190 mk_mvar, to_expr ``(cast %%t) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.and_right and_kind.and p) := do\n  t \u2190 mk_mvar, to_expr ``(and.right %%t) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.and_right and_kind.iff p) := do\n  t \u2190 mk_mvar, to_expr ``(iff.mpr %%t) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.and_right and_kind.eq p) := do\n  t \u2190 mk_mvar, to_expr ``(cast (eq.symm %%t)) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.and_intro and_kind.and p q) := do\n  t\u2081 \u2190 mk_mvar, t\u2082 \u2190 mk_mvar, to_expr ``(and.intro %%t\u2081 %%t\u2082) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t\u2081::t\u2082::gs), apply_proof \u0393 p >> apply_proof \u0393 q\n| \u0393 (proof.and_intro and_kind.iff p q) := do\n  t\u2081 \u2190 mk_mvar, t\u2082 \u2190 mk_mvar, to_expr ``(iff.intro %%t\u2081 %%t\u2082) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t\u2081::t\u2082::gs), apply_proof \u0393 p >> apply_proof \u0393 q\n| \u0393 (proof.and_intro and_kind.eq p q) := do\n  t\u2081 \u2190 mk_mvar, t\u2082 \u2190 mk_mvar, to_expr ``(propext (iff.intro %%t\u2081 %%t\u2082)) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t\u2081::t\u2082::gs), apply_proof \u0393 p >> apply_proof \u0393 q\n| \u0393 (proof.curry ak p) := do\n  e \u2190 intro_core `_, let n := e.local_uniq_name,\n  apply_proof (\u0393.insert n e) (proof.curry\u2082 ak p (proof.hyp n))\n| \u0393 (proof.curry\u2082 ak p q) := do\n  e \u2190 intro_core `_, let n := e.local_uniq_name,\n  apply_proof (\u0393.insert n e) (p.app (q.and_intro ak (proof.hyp n)))\n| \u0393 (proof.app' p q) := do\n  A \u2190 mk_meta_var (expr.sort level.zero),\n  B \u2190 mk_meta_var (expr.sort level.zero),\n  g\u2081 \u2190 mk_meta_var `((%%A : Prop) \u2192 (%%B : Prop)),\n  g\u2082 \u2190 mk_meta_var A,\n  g :: gs \u2190 get_goals,\n  unify (g\u2081 g\u2082) g,\n  set_goals (g\u2081::g\u2082::gs) >> apply_proof \u0393 p >> apply_proof \u0393 q\n| \u0393 (proof.or_imp_left p) := do\n  e \u2190 intro_core `_, let n := e.local_uniq_name,\n  apply_proof (\u0393.insert n e) (p.app (proof.hyp n).or_inl)\n| \u0393 (proof.or_imp_right p) := do\n  e \u2190 intro_core `_, let n := e.local_uniq_name,\n  apply_proof (\u0393.insert n e) (p.app (proof.hyp n).or_inr)\n| \u0393 (proof.or_inl p) := do\n  t \u2190 mk_mvar, to_expr ``(or.inl %%t) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.or_inr p) := do\n  t \u2190 mk_mvar, to_expr ``(or.inr %%t) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t::gs), apply_proof \u0393 p\n| \u0393 (proof.or_elim' p x p\u2081 p\u2082) := do\n  t\u2081 \u2190 mk_mvar, t\u2082 \u2190 mk_mvar, t\u2083 \u2190 mk_mvar, to_expr ``(or.elim %%t\u2081 %%t\u2082 %%t\u2083) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t\u2081::t\u2082::t\u2083::gs), apply_proof \u0393 p,\n  e \u2190 intro_core x, apply_proof (\u0393.insert x e) p\u2081,\n  e \u2190 intro_core x, apply_proof (\u0393.insert x e) p\u2082\n| \u0393 (proof.em ff n) := do\n  e \u2190 \u0393.find n,\n  to_expr ``(@decidable.em _ %%e) >>= exact\n| \u0393 (proof.em tt n) := do\n  e \u2190 \u0393.find n,\n  to_expr ``(@classical.em %%e) >>= exact\n| \u0393 (proof.decidable_elim ff n x p\u2081 p\u2082) := do\n  e \u2190 \u0393.find n,\n  t\u2081 \u2190 mk_mvar, t\u2082 \u2190 mk_mvar, to_expr ``(@dite _ _ %%e %%t\u2081 %%t\u2082) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t\u2081::t\u2082::gs),\n  e \u2190 intro_core x, apply_proof (\u0393.insert x e) p\u2081,\n  e \u2190 intro_core x, apply_proof (\u0393.insert x e) p\u2082\n| \u0393 (proof.decidable_elim tt n x p\u2081 p\u2082) := do\n  e \u2190 \u0393.find n,\n  e \u2190 to_expr ``(@classical.dec %%e),\n  t\u2081 \u2190 mk_mvar, t\u2082 \u2190 mk_mvar, to_expr ``(@dite _ _ %%e %%t\u2081 %%t\u2082) tt ff >>= exact,\n  gs \u2190 get_goals, set_goals (t\u2081::t\u2082::gs),\n  e \u2190 intro_core x, apply_proof (\u0393.insert x e) p\u2081,\n  e \u2190 intro_core x, apply_proof (\u0393.insert x e) p\u2082\n| \u0393 (proof.imp_imp_simp x p) := do\n  e \u2190 intro_core `_, let n := e.local_uniq_name,\n  apply_proof (\u0393.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 \u2228 \u00ac a` to the context for every decidable atomic proposition `a`.\n* `use_classical` will allow `a \u2228 \u00ac a` to be added even if the proposition is not decidable,\n  using classical logic.\n* `extra_dec` will add `a \u2228 \u00ac 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 $ \u03bb atoms,\nusing_new_ref mk_name_map $ \u03bb hs, do\n  t \u2190 target,\n  t \u2190 mcond (is_prop t) (reify atoms t) (tactic.exfalso $> prop.false),\n  hyps \u2190 local_context,\n  (\u0393, decs) \u2190 hyps.mfoldl\n    (\u03bb (\u0393 : except (prop \u2192 proof) context \u00d7 native.rb_map prop (bool \u00d7 expr)) h, do\n      e \u2190 infer_type h,\n      mcond (is_prop e)\n        (do A \u2190 reify atoms e,\n          let n := h.local_uniq_name,\n          read_ref hs >>= \u03bb \u0393, write_ref hs (\u0393.insert n h),\n          pure (\u0393.1 >>= \u03bb \u0393', \u0393'.add A (proof.hyp n), \u0393.2))\n        (match e with\n        | `(decidable %%p) :=\n          if use_dec then do\n            A \u2190 reify atoms p,\n            let n := h.local_uniq_name,\n            pure (\u0393.1, \u0393.2.insert A (ff, h))\n          else pure \u0393\n        | _ := pure \u0393\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 \u00d7 expr)) (e : expr) := (do\n    A \u2190 reify atoms e,\n    dec_e \u2190 mk_app ``decidable [e],\n    res \u2190 try_core (mk_instance dec_e),\n    if res.is_none \u2227 \u00ac use_classical then\n      if force then do\n        m \u2190 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 \u2190 extra_dec.mfoldl (add_dec tt) decs,\n  decs \u2190 if use_dec then do\n    let decided := match \u0393 with\n    | except.ok \u0393 := \u0393.fold native.mk_rb_set $ \u03bb 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 >>= \u03bb ats, ats.2.iterate (pure decs) $ \u03bb i e r,\n      if decided.contains i.1 then r else r >>= \u03bb decs, add_dec ff decs e\n  else pure decs,\n  \u0393 \u2190 decs.fold (pure \u0393) (\u03bb A \u27e8cl, pf\u27e9 r, r >>= \u03bb \u0393, do\n    n \u2190 mk_fresh_name,\n    read_ref hs >>= \u03bb \u0393, write_ref hs (\u0393.insert n pf),\n    pure (\u0393 >>= \u03bb \u0393', \u0393'.add (A.or A.not) (proof.em cl n))),\n  let p := match \u0393 with\n  | except.ok \u0393 := (prove \u0393 t 0).2.1\n  | except.error p := p t\n  end,\n  hs \u2190 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) : \u00ac (p \u2194 \u00ac 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)? \u2192 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 {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\nvariables {E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E]\nvariables {F : Type*} [normed_add_comm_group F] [normed_space \ud835\udd5c F]\n\nsection fderiv\n\nvariables {p : formal_multilinear_series \ud835\udd5c E F} {r : \u211d\u22650\u221e}\nvariables {f : E \u2192 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 \ud835\udd5c 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 \u27e8\u03bb y, \u2016y - (x, x)\u2016, _, eventually_eq.rfl\u27e9,\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 \ud835\udd5c 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 \ud835\udd5c f x :=\nh.has_fderiv_at.differentiable_at\n\nlemma analytic_at.differentiable_at : analytic_at \ud835\udd5c f x \u2192 differentiable_at \ud835\udd5c f x\n| \u27e8p, hp\u27e9 := hp.differentiable_at\n\nlemma analytic_at.differentiable_within_at (h : analytic_at \ud835\udd5c f x) :\n  differentiable_within_at \ud835\udd5c 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 \ud835\udd5c f x = continuous_multilinear_curry_fin1 \ud835\udd5c 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 \ud835\udd5c f (emetric.ball x r) :=\n\u03bb y hy, (h.analytic_at_of_mem hy).differentiable_within_at\n\nlemma analytic_on.differentiable_on (h : analytic_on \ud835\udd5c f s) :\n  differentiable_on \ud835\udd5c f s :=\n\u03bb 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 : (\u2016y\u2016\u208a : \u211d\u22650\u221e) < r) :\n  has_fderiv_at f (continuous_multilinear_curry_fin1 \ud835\udd5c 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 : (\u2016y\u2016\u208a : \u211d\u22650\u221e) < r) :\n  fderiv \ud835\udd5c f (x + y) = continuous_multilinear_curry_fin1 \ud835\udd5c 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 \ud835\udd5c f)\n    ((continuous_multilinear_curry_fin1 \ud835\udd5c E F : (E [\u00d71]\u2192L[\ud835\udd5c] F) \u2192L[\ud835\udd5c] (E \u2192L[\ud835\udd5c] F))\n      .comp_formal_multilinear_series (p.change_origin_series 1)) x r :=\nbegin\n  suffices A : has_fpower_series_on_ball\n    (\u03bb z, continuous_multilinear_curry_fin1 \ud835\udd5c E F (p.change_origin (z - x) 1))\n      ((continuous_multilinear_curry_fin1 \ud835\udd5c E F : (E [\u00d71]\u2192L[\ud835\udd5c] F) \u2192L[\ud835\udd5c] (E \u2192L[\ud835\udd5c] 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 [\u2190 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 (\u03bb z, p.change_origin (z - x) 1)\n    (p.change_origin_series 1) x r,\n      from (continuous_multilinear_curry_fin1 \ud835\udd5c 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\u00e9chet derivative. -/\nlemma analytic_on.fderiv [complete_space F] (h : analytic_on \ud835\udd5c f s) :\n  analytic_on \ud835\udd5c (fderiv \ud835\udd5c f) s :=\nbegin\n  assume y hy,\n  rcases h y hy with \u27e8p, r, hp\u27e9,\n  exact hp.fderiv.analytic_at,\nend\n\n/-- If a function is analytic on a set `s`, so are its successive Fr\u00e9chet derivative. -/\nlemma analytic_on.iterated_fderiv [complete_space F] (h : analytic_on \ud835\udd5c f s) (n : \u2115) :\n  analytic_on \ud835\udd5c (iterated_fderiv \ud835\udd5c n f) s :=\nbegin\n  induction n with n IH,\n  { rw iterated_fderiv_zero_eq_comp,\n    exact ((continuous_multilinear_curry_fin0 \ud835\udd5c E F).symm : F \u2192L[\ud835\udd5c] (E [\u00d70]\u2192L[\ud835\udd5c] F))\n      .comp_analytic_on h },\n  { rw iterated_fderiv_succ_eq_comp_left,\n    apply (continuous_multilinear_curry_left_equiv \ud835\udd5c (\u03bb (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 \ud835\udd5c f s) {n : \u2115\u221e} :\n  cont_diff_on \ud835\udd5c n f s :=\nbegin\n  let t := {x | analytic_at \ud835\udd5c f x},\n  suffices : cont_diff_on \ud835\udd5c n f t, from this.mono h,\n  have H : analytic_on \ud835\udd5c f t := \u03bb x hx, hx,\n  have t_open : is_open t := is_open_analytic_at \ud835\udd5c 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 \ud835\udd5c \ud835\udd5c F} {r : \u211d\u22650\u221e}\nvariables {f : \ud835\udd5c \u2192 F} {x : \ud835\udd5c} {s : set \ud835\udd5c}\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 (\u03bb _, 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 (\u03bb _, 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 (\u03bb _, 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 \ud835\udd5c f s) :\n  analytic_on \ud835\udd5c (deriv f) s :=\n(continuous_linear_map.apply \ud835\udd5c F (1 : \ud835\udd5c)).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 \ud835\udd5c f s) (n : \u2115) :\n  analytic_on \ud835\udd5c (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 {\u03b1 : Type u_1} [comm_ring \u03b1] {n1 : \u03b1} {n2 : \u03b1} {k : \u03b1} {e1 : \u03b1} {e2 : \u03b1} {t1 : \u03b1} {t2 : \u03b1} (h1 : n1 * e1 = t1) (h2 : n2 * e2 = t2) (h3 : n1 * n2 = k) : k * (e1 * e2) = t1 * t2 := sorry\n\ntheorem div_subst {\u03b1 : Type u_1} [field \u03b1] {n1 : \u03b1} {n2 : \u03b1} {k : \u03b1} {e1 : \u03b1} {e2 : \u03b1} {t1 : \u03b1} (h1 : n1 * e1 = t1) (h2 : n2 / e2 = 1) (h3 : n1 * n2 = k) : k * (e1 / e2) = t1 := sorry\n\ntheorem cancel_factors_eq_div {\u03b1 : Type u_1} [field \u03b1] {n : \u03b1} {e : \u03b1} {e' : \u03b1} (h : n * e = e') (h2 : n \u2260 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 {\u03b1 : Type u_1} [ring \u03b1] {n : \u03b1} {e1 : \u03b1} {e2 : \u03b1} {t1 : \u03b1} {t2 : \u03b1} (h1 : n * e1 = t1) (h2 : n * e2 = t2) : n * (e1 + e2) = t1 + t2 := sorry\n\ntheorem sub_subst {\u03b1 : Type u_1} [ring \u03b1] {n : \u03b1} {e1 : \u03b1} {e2 : \u03b1} {t1 : \u03b1} {t2 : \u03b1} (h1 : n * e1 = t1) (h2 : n * e2 = t2) : n * (e1 - e2) = t1 - t2 := sorry\n\ntheorem neg_subst {\u03b1 : Type u_1} [ring \u03b1] {n : \u03b1} {e : \u03b1} {t : \u03b1} (h1 : n * e = t) : n * -e = -t := sorry\n\ntheorem cancel_factors_lt {\u03b1 : Type u_1} [linear_ordered_field \u03b1] {a : \u03b1} {b : \u03b1} {ad : \u03b1} {bd : \u03b1} {a' : \u03b1} {b' : \u03b1} {gcd : \u03b1} (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 {\u03b1 : Type u_1} [linear_ordered_field \u03b1] {a : \u03b1} {b : \u03b1} {ad : \u03b1} {bd : \u03b1} {a' : \u03b1} {b' : \u03b1} {gcd : \u03b1} (ha : ad * a = a') (hb : bd * b = b') (had : 0 < ad) (hbd : 0 < bd) (hgcd : 0 < gcd) : a \u2264 b = (1 / gcd * (bd * a') \u2264 1 / gcd * (ad * b')) := sorry\n\ntheorem cancel_factors_eq {\u03b1 : Type u_1} [linear_ordered_field \u03b1] {a : \u03b1} {b : \u03b1} {ad : \u03b1} {bd : \u03b1} {a' : \u03b1} {b' : \u03b1} {gcd : \u03b1} (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 \u2208 {<, \u2264, =}`, 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 \u2208 {<, \u2264, =, \u2265, >}`.\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 {\u03b1 : Type} [linear_ordered_field \u03b1] (a b c : \u03b1)\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\u00e9d\u00e9ric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Fr\u00e9d\u00e9ric 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 \u2192\u1d43[R] F} :\n  continuous f \u2194 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 \u21d1(line_map p v : R \u2192\u1d43[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 : \u21d1(homothety x t) = \u03bb y, t \u2022 (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 \u2260 0) : is_open_map $ homothety x t :=\nbegin\n  apply is_open_map.of_inverse (homothety_continuous x t\u207b\u00b9);\n  intros e;\n  simp [\u2190 affine_map.comp_apply, \u2190 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 \u2192 (Q \u2192 R)) \u2192 ((P \u2192 Q) \u2192 (P \u2192 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  \u27e8\u27e9\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 (\u03b1 : Type _) [PartialOrder \u03b1] : PartOrd :=\n  Bundled.of \u03b1\n#align PartOrd.of PartOrd.of\n\n@[simp]\ntheorem coe_of (\u03b1 : Type _) [PartialOrder \u03b1] : \u21a5(of \u03b1) = \u03b1 :=\n  rfl\n#align PartOrd.coe_of PartOrd.coe_of\n\ninstance : Inhabited PartOrd :=\n  \u27e8of PUnit\u27e9\n\ninstance (\u03b1 : PartOrd) : PartialOrder \u03b1 :=\n  \u03b1.str\n\ninstance hasForgetToPreord : HasForget\u2082 PartOrd Preord :=\n  BundledHom.forget\u2082 _ _\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 {\u03b1 \u03b2 : PartOrd.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2\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 \u2964 PartOrd where\n  obj X := of X\u1d52\u1d48\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 \u224c 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 \u22d9 forget\u2082 PartOrd Preord = forget\u2082 PartOrd Preord \u22d9 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} \u2964 PartOrd\n    where\n  obj X := PartOrd.of (Antisymmetrization X (\u00b7 \u2264 \u00b7))\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} \u22a3 forget\u2082 PartOrd Preord :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f =>\n            \u27e8f \u2218 toAntisymmetrization (\u00b7 \u2264 \u00b7), f.mono.comp toAntisymmetrization_mono\u27e9\n          invFun := fun f =>\n            \u27e8fun a => Quotient.liftOn' a f fun a b h => (AntisymmRel.image h f.mono).Eq, fun a b =>\n              Quotient.inductionOn\u2082' a b fun a b h => f.mono h\u27e9\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} \u22d9 PartOrd.dual \u2245 Preord.dual \u22d9 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 \u00d7 val)\n```\n\nThen we can use `f : key \u2192 IO key'` and `g : val \u2192 IO val'` to manipulate the `AList`'s key\nand value respectively with `Bitraverse f g : AList key val \u2192 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 \u2192 Type u \u2192 Type u) extends Bifunctor t where\n  bitraverse :\n    \u2200 {m : Type u \u2192 Type u} [Applicative m] {\u03b1 \u03b1' \u03b2 \u03b2'},\n      (\u03b1 \u2192 m \u03b1') \u2192 (\u03b2 \u2192 m \u03b2') \u2192 t \u03b1 \u03b2 \u2192 m (t \u03b1' \u03b2')\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] {\u03b1 \u03b2} : t (m \u03b1) (m \u03b2) \u2192 m (t \u03b1 \u03b2) :=\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 \u2192 Type u \u2192 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 : \u2200 {\u03b1 \u03b2} (x : t \u03b1 \u03b2), bitraverse (m := Id) pure pure x = pure x\n  comp_bitraverse :\n    \u2200 {F G} [Applicative F] [Applicative G] [LawfulApplicative F] [LawfulApplicative G]\n      {\u03b1 \u03b1' \u03b2 \u03b2' \u03b3 \u03b3'} (f : \u03b2 \u2192 F \u03b3) (f' : \u03b2' \u2192 F \u03b3') (g : \u03b1 \u2192 G \u03b2) (g' : \u03b1' \u2192 G \u03b2') (x : t \u03b1 \u03b1'),\n      bitraverse (Comp.mk \u2218 map f \u2218 g) (Comp.mk \u2218 map f' \u2218 g') x =\n        Comp.mk (bitraverse f f' <$> bitraverse g g' x)\n  bitraverse_eq_bimap_id :\n    \u2200 {\u03b1 \u03b1' \u03b2 \u03b2'} (f : \u03b1 \u2192 \u03b2) (f' : \u03b1' \u2192 \u03b2') (x : t \u03b1 \u03b1'),\n      bitraverse (m := Id) (pure \u2218 f) (pure \u2218 f') x = pure (bimap f f' x)\n  binaturality :\n    \u2200 {F G} [Applicative F] [Applicative G] [LawfulApplicative F] [LawfulApplicative G]\n      (\u03b7 : ApplicativeTransformation F G) {\u03b1 \u03b1' \u03b2 \u03b2'} (f : \u03b1 \u2192 F \u03b2) (f' : \u03b1' \u2192 F \u03b2') (x : t \u03b1 \u03b1'),\n      \u03b7 (bitraverse f f' x) = bitraverse (@\u03b7 _ \u2218 f) (@\u03b7 _ \u2218 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\u00f6lzl, 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 \u2192 Z` to a regular (T\u2083) space Z to extend along a dense embedding\n`i : X \u2192 Y` to a continuous function `g : Y \u2192 Z`. Actually `i` only\nhas to be `dense_inducing` (not necessarily injective).\n\n-/\n\n/-- `i : \u03b1 \u2192 \u03b2` is \"dense inducing\" if it has dense range and the topology on `\u03b1`\n  is the one induced by `i` from the topology on `\u03b2`. -/\nstructure dense_inducing {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (i : \u03b1 \u2192 \u03b2) \nextends inducing i\nwhere\n  dense : dense_range i\n\nnamespace dense_inducing\n\n\ntheorem nhds_eq_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (di : dense_inducing i) (a : \u03b1) : nhds a = filter.comap i (nhds (i a)) :=\n  inducing.nhds_eq_comap (to_inducing di)\n\nprotected theorem continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (di : dense_inducing i) : continuous i :=\n  inducing.continuous (to_inducing di)\n\ntheorem closure_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} {s : set \u03b2} (di : dense_inducing i) : is_open s \u2192 s \u2286 closure (i '' (i \u207b\u00b9' s)) := sorry\n\ntheorem closure_image_nhds_of_nhds {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} {s : set \u03b1} {a : \u03b1} (di : dense_inducing i) : s \u2208 nhds a \u2192 closure (i '' s) \u2208 nhds (i a) := sorry\n\n/-- The product of two dense inducings is a dense inducing -/\nprotected theorem prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] {e\u2081 : \u03b1 \u2192 \u03b2} {e\u2082 : \u03b3 \u2192 \u03b4} (de\u2081 : dense_inducing e\u2081) (de\u2082 : dense_inducing e\u2082) : dense_inducing fun (p : \u03b1 \u00d7 \u03b3) => (e\u2081 (prod.fst p), e\u2082 (prod.snd p)) :=\n  mk (inducing.mk (inducing.induced (inducing.prod_mk (to_inducing de\u2081) (to_inducing de\u2082))))\n    (dense_range.prod_map (dense de\u2081) (dense de\u2082))\n\n/-- If the domain of a `dense_inducing` map is a separable space, then so is the codomain. -/\nprotected theorem separable_space {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (di : dense_inducing i) [topological_space.separable_space \u03b1] : topological_space.separable_space \u03b2 :=\n  dense_range.separable_space (dense di) (dense_inducing.continuous di)\n\n/--\n \u03b3 -f\u2192 \u03b1\ng\u2193     \u2193e\n \u03b4 -h\u2192 \u03b2\n-/\ntheorem tendsto_comap_nhds_nhds {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} [topological_space \u03b4] {f : \u03b3 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b4} {h : \u03b4 \u2192 \u03b2} {d : \u03b4} {a : \u03b1} (di : dense_inducing i) (H : filter.tendsto h (nhds d) (nhds (i a))) (comm : h \u2218 g = i \u2218 f) : filter.tendsto f (filter.comap g (nhds d)) (nhds a) := sorry\n\nprotected theorem nhds_within_ne_bot {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (di : dense_inducing i) (b : \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (di : dense_inducing i) (b : \u03b2) : filter.ne_bot (filter.comap i (nhds b)) := sorry\n\n/-- If `i : \u03b1 \u2192 \u03b2` is a dense inducing, then any function `f : \u03b1 \u2192 \u03b3` \"extends\"\n  to a function `g = extend di f : \u03b2 \u2192 \u03b3`. If `\u03b3` 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} [topological_space \u03b3] (di : dense_inducing i) (f : \u03b1 \u2192 \u03b3) (b : \u03b2) : \u03b3 :=\n  lim (filter.comap i (nhds b)) f\n\ntheorem extend_eq_of_tendsto {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (di : dense_inducing i) [topological_space \u03b3] [t2_space \u03b3] {b : \u03b2} {c : \u03b3} {f : \u03b1 \u2192 \u03b3} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (di : dense_inducing i) [topological_space \u03b3] [t2_space \u03b3] {f : \u03b1 \u2192 \u03b3} (a : \u03b1) (hf : continuous_at f a) : extend di f (i a) = f a :=\n  extend_eq_of_tendsto di (nhds_eq_comap di a \u25b8 hf)\n\ntheorem extend_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} (di : dense_inducing i) [topological_space \u03b3] [t2_space \u03b3] {f : \u03b1 \u2192 \u03b3} (hf : continuous f) (a : \u03b1) : extend di f (i a) = f a :=\n  extend_eq_at di a (continuous.continuous_at hf)\n\ntheorem extend_unique_at {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} [topological_space \u03b3] [t2_space \u03b3] {b : \u03b2} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3} (di : dense_inducing i) (hf : filter.eventually (fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} [topological_space \u03b3] [t2_space \u03b3] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3} (di : dense_inducing i) (hf : \u2200 (x : \u03b1), g (i x) = f x) (hg : continuous g) : extend di f = g :=\n  funext fun (b : \u03b2) => extend_unique_at di (filter.eventually_of_forall hf) (continuous.continuous_at hg)\n\ntheorem continuous_at_extend {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} [topological_space \u03b3] [regular_space \u03b3] {b : \u03b2} {f : \u03b1 \u2192 \u03b3} (di : dense_inducing i) (hf : filter.eventually (fun (x : \u03b2) => \u2203 (c : \u03b3), filter.tendsto f (filter.comap i (nhds x)) (nhds c)) (nhds b)) : continuous_at (extend di f) b := sorry\n\ntheorem continuous_extend {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] {i : \u03b1 \u2192 \u03b2} [topological_space \u03b3] [regular_space \u03b3] {f : \u03b1 \u2192 \u03b3} (di : dense_inducing i) (hf : \u2200 (b : \u03b2), \u2203 (c : \u03b3), filter.tendsto f (filter.comap i (nhds b)) (nhds c)) : continuous (extend di f) :=\n  iff.mpr continuous_iff_continuous_at fun (b : \u03b2) => continuous_at_extend di (filter.univ_mem_sets' hf)\n\ntheorem mk' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (i : \u03b1 \u2192 \u03b2) (c : continuous i) (dense : \u2200 (x : \u03b2), x \u2208 closure (set.range i)) (H : \u2200 (a : \u03b1) (s : set \u03b1) (H : s \u2208 nhds a), \u2203 (t : set \u03b2), \u2203 (H : t \u2208 nhds (i a)), \u2200 (b : \u03b1), i b \u2208 t \u2192 b \u2208 s) : dense_inducing i := sorry\n\nend dense_inducing\n\n\n/-- A dense embedding is an embedding with dense image. -/\nstructure dense_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : \u03b1 \u2192 \u03b2) \nextends dense_inducing e\nwhere\n  inj : function.injective e\n\ntheorem dense_embedding.mk' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : \u03b1 \u2192 \u03b2) (c : continuous e) (dense : dense_range e) (inj : function.injective e) (H : \u2200 (a : \u03b1) (s : set \u03b1) (H : s \u2208 nhds a), \u2203 (t : set \u03b2), \u2203 (H : t \u2208 nhds (e a)), \u2200 (b : \u03b1), e b \u2208 t \u2192 b \u2208 s) : dense_embedding e := sorry\n\nnamespace dense_embedding\n\n\ntheorem inj_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} (de : dense_embedding e) {x : \u03b1} {y : \u03b1} : e x = e y \u2194 x = y :=\n  function.injective.eq_iff (inj de)\n\ntheorem to_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} (de : dense_embedding e) [topological_space.separable_space \u03b1] : topological_space.separable_space \u03b2 :=\n  dense_inducing.separable_space (to_dense_inducing de)\n\n/-- The product of two dense embeddings is a dense embedding. -/\nprotected theorem prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] {e\u2081 : \u03b1 \u2192 \u03b2} {e\u2082 : \u03b3 \u2192 \u03b4} (de\u2081 : dense_embedding e\u2081) (de\u2082 : dense_embedding e\u2082) : dense_embedding fun (p : \u03b1 \u00d7 \u03b3) => (e\u2081 (prod.fst p), e\u2082 (prod.snd p)) := sorry\n\n/-- The dense embedding of a subtype inside its closure. -/\ndef subtype_emb {\u03b2 : Type u_2} [topological_space \u03b2] {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (e : \u03b1 \u2192 \u03b2) (x : Subtype fun (x : \u03b1) => p x) : Subtype fun (x : \u03b2) => x \u2208 closure (e '' set_of fun (x : \u03b1) => p x) :=\n  { val := e \u2191x, property := sorry }\n\nprotected theorem subtype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} (de : dense_embedding e) (p : \u03b1 \u2192 Prop) : dense_embedding (subtype_emb p e) := sorry\n\nend dense_embedding\n\n\ntheorem is_closed_property {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} (he : dense_range e) (hp : is_closed (set_of fun (x : \u03b2) => p x)) (h : \u2200 (a : \u03b1), p (e a)) (b : \u03b2) : p b := sorry\n\ntheorem is_closed_property2 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 \u03b2 \u2192 Prop} (he : dense_range e) (hp : is_closed (set_of fun (q : \u03b2 \u00d7 \u03b2) => p (prod.fst q) (prod.snd q))) (h : \u2200 (a\u2081 a\u2082 : \u03b1), p (e a\u2081) (e a\u2082)) (b\u2081 : \u03b2) (b\u2082 : \u03b2) : p b\u2081 b\u2082 :=\n  (fun (this : \u2200 (q : \u03b2 \u00d7 \u03b2), p (prod.fst q) (prod.snd q)) (b\u2081 b\u2082 : \u03b2) => this (b\u2081, b\u2082))\n    (is_closed_property (dense_range.prod_map he he) hp fun (_x : \u03b1 \u00d7 \u03b1) => h (prod.fst _x) (prod.snd _x))\n\ntheorem is_closed_property3 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 \u03b2 \u2192 \u03b2 \u2192 Prop} (he : dense_range e) (hp : is_closed (set_of fun (q : \u03b2 \u00d7 \u03b2 \u00d7 \u03b2) => p (prod.fst q) (prod.fst (prod.snd q)) (prod.snd (prod.snd q)))) (h : \u2200 (a\u2081 a\u2082 a\u2083 : \u03b1), p (e a\u2081) (e a\u2082) (e a\u2083)) (b\u2081 : \u03b2) (b\u2082 : \u03b2) (b\u2083 : \u03b2) : p b\u2081 b\u2082 b\u2083 := sorry\n\ntheorem dense_range.induction_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} (he : dense_range e) {p : \u03b2 \u2192 Prop} (b\u2080 : \u03b2) (hp : is_closed (set_of fun (b : \u03b2) => p b)) (ih : \u2200 (a : \u03b1), p (e a)) : p b\u2080 :=\n  is_closed_property he hp ih b\u2080\n\ntheorem dense_range.induction_on\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 \u03b2 \u2192 Prop} (he : dense_range e) (hp : is_closed (set_of fun (q : \u03b2 \u00d7 \u03b2) => p (prod.fst q) (prod.snd q))) (h : \u2200 (a\u2081 a\u2082 : \u03b1), p (e a\u2081) (e a\u2082)) (b\u2081 : \u03b2) (b\u2082 : \u03b2) : p b\u2081 b\u2082 :=\n  is_closed_property2 he hp h b\u2081 b\u2082\n\ntheorem dense_range.induction_on\u2083 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b2] {e : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 \u03b2 \u2192 \u03b2 \u2192 Prop} (he : dense_range e) (hp : is_closed (set_of fun (q : \u03b2 \u00d7 \u03b2 \u00d7 \u03b2) => p (prod.fst q) (prod.fst (prod.snd q)) (prod.snd (prod.snd q)))) (h : \u2200 (a\u2081 a\u2082 a\u2083 : \u03b1), p (e a\u2081) (e a\u2082) (e a\u2083)) (b\u2081 : \u03b2) (b\u2082 : \u03b2) (b\u2083 : \u03b2) : p b\u2081 b\u2082 b\u2083 :=\n  is_closed_property3 he hp h b\u2081 b\u2082 b\u2083\n\n/-- Two continuous functions to a t2-space that agree on the dense range of a function are equal. -/\ntheorem dense_range.equalizer {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b2] [topological_space \u03b3] [t2_space \u03b3] {f : \u03b1 \u2192 \u03b2} (hfd : dense_range f) {g : \u03b2 \u2192 \u03b3} {h : \u03b2 \u2192 \u03b3} (hg : continuous g) (hh : continuous h) (H : g \u2218 f = h \u2218 f) : g = h :=\n  funext fun (y : \u03b2) => 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 \u226b app b \u27f6 app a \u226b 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 \u03b7 \u03b8` : the vertical composition of oplax natural transformations `\u03b7`\n  and `\u03b8`\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\u2081 w\u2082 v\u2081 v\u2082 u\u2081 u\u2082\n\nvariable {B : Type u\u2081} [Bicategory.{w\u2081, v\u2081} B] {C : Type u\u2082} [Bicategory.{w\u2082, v\u2082} C]\n\n/-- If `\u03b7` is an oplax natural transformation between `F` and `G`, we have a 1-morphism\n`\u03b7.app a : F.obj a \u27f6 G.obj a` for each object `a : B`. We also have a 2-morphism\n`\u03b7.naturality f : F.map f \u226b app b \u27f6 app a \u226b G.map f` for each 1-morphism `f : a \u27f6 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 \u27f6 G.obj a\n  naturality {a b : B} (f : a \u27f6 b) : F.map f \u226b app b \u27f6 app a \u226b G.map f\n  naturality_naturality' :\n    \u2200 {a b : B} {f g : a \u27f6 b} (\u03b7 : f \u27f6 g),\n      F.zipWith \u03b7 \u25b7 app b \u226b naturality g = naturality f \u226b app a \u25c1 G.zipWith \u03b7 := by\n    obviously\n  naturality_id' :\n    \u2200 a : B,\n      naturality (\ud835\udfd9 a) \u226b app a \u25c1 G.map_id a =\n        F.map_id a \u25b7 app a \u226b (\u03bb_ (app a)).Hom \u226b (\u03c1_ (app a)).inv := by\n    obviously\n  naturality_comp' :\n    \u2200 {a b c : B} (f : a \u27f6 b) (g : b \u27f6 c),\n      naturality (f \u226b g) \u226b app a \u25c1 G.map_comp f g =\n        F.map_comp f g \u25b7 app c \u226b\n          (\u03b1_ _ _ _).Hom \u226b\n            F.map f \u25c1 naturality g \u226b (\u03b1_ _ _ _).inv \u226b naturality f \u25b7 G.map g \u226b (\u03b1_ _ _ _).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 := \ud835\udfd9 (F.obj a)\n  naturality a b f := (\u03c1_ (F.map f)).Hom \u226b (\u03bb_ (F.map f)).inv\n#align category_theory.oplax_nat_trans.id CategoryTheory.OplaxNatTrans.id\n\ninstance : Inhabited (OplaxNatTrans F F) :=\n  \u27e8id F\u27e9\n\nvariable {F} {G H : OplaxFunctor B C} (\u03b7 : OplaxNatTrans F G) (\u03b8 : OplaxNatTrans G H)\n\nsection\n\nvariable {a b c : B} {a' : C}\n\n@[simp, reassoc.1]\ntheorem whiskerLeft_naturality_naturality (f : a' \u27f6 G.obj a) {g h : a \u27f6 b} (\u03b2 : g \u27f6 h) :\n    f \u25c1 G.zipWith \u03b2 \u25b7 \u03b8.app b \u226b f \u25c1 \u03b8.naturality h =\n      f \u25c1 \u03b8.naturality g \u226b f \u25c1 \u03b8.app a \u25c1 H.zipWith \u03b2 :=\n  by simp_rw [\u2190 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 \u27f6 b} (\u03b2 : f \u27f6 g) (h : G.obj b \u27f6 a') :\n    F.zipWith \u03b2 \u25b7 \u03b7.app b \u25b7 h \u226b \u03b7.naturality g \u25b7 h =\n      \u03b7.naturality f \u25b7 h \u226b (\u03b1_ _ _ _).Hom \u226b \u03b7.app a \u25c1 G.zipWith \u03b2 \u25b7 h \u226b (\u03b1_ _ _ _).inv :=\n  by rw [\u2190 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' \u27f6 G.obj a) (g : a \u27f6 b) (h : b \u27f6 c) :\n    f \u25c1 \u03b8.naturality (g \u226b h) \u226b f \u25c1 \u03b8.app a \u25c1 H.map_comp g h =\n      f \u25c1 G.map_comp g h \u25b7 \u03b8.app c \u226b\n        f \u25c1 (\u03b1_ _ _ _).Hom \u226b\n          f \u25c1 G.map g \u25c1 \u03b8.naturality h \u226b\n            f \u25c1 (\u03b1_ _ _ _).inv \u226b f \u25c1 \u03b8.naturality g \u25b7 H.map h \u226b f \u25c1 (\u03b1_ _ _ _).Hom :=\n  by simp_rw [\u2190 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 \u27f6 b) (g : b \u27f6 c) (h : G.obj c \u27f6 a') :\n    \u03b7.naturality (f \u226b g) \u25b7 h \u226b (\u03b1_ _ _ _).Hom \u226b \u03b7.app a \u25c1 G.map_comp f g \u25b7 h =\n      F.map_comp f g \u25b7 \u03b7.app c \u25b7 h \u226b\n        (\u03b1_ _ _ _).Hom \u25b7 h \u226b\n          (\u03b1_ _ _ _).Hom \u226b\n            F.map f \u25c1 \u03b7.naturality g \u25b7 h \u226b\n              (\u03b1_ _ _ _).inv \u226b\n                (\u03b1_ _ _ _).inv \u25b7 h \u226b\n                  \u03b7.naturality f \u25b7 G.map g \u25b7 h \u226b (\u03b1_ _ _ _).Hom \u25b7 h \u226b (\u03b1_ _ _ _).Hom :=\n  by\n  rw [\u2190 associator_naturality_middle, \u2190 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' \u27f6 G.obj a) :\n    f \u25c1 \u03b8.naturality (\ud835\udfd9 a) \u226b f \u25c1 \u03b8.app a \u25c1 H.map_id a =\n      f \u25c1 G.map_id a \u25b7 \u03b8.app a \u226b f \u25c1 (\u03bb_ (\u03b8.app a)).Hom \u226b f \u25c1 (\u03c1_ (\u03b8.app a)).inv :=\n  by simp_rw [\u2190 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 \u27f6 a') :\n    \u03b7.naturality (\ud835\udfd9 a) \u25b7 f \u226b (\u03b1_ _ _ _).Hom \u226b \u03b7.app a \u25c1 G.map_id a \u25b7 f =\n      F.map_id a \u25b7 \u03b7.app a \u25b7 f \u226b (\u03bb_ (\u03b7.app a)).Hom \u25b7 f \u226b (\u03c1_ (\u03b7.app a)).inv \u25b7 f \u226b (\u03b1_ _ _ _).Hom :=\n  by\n  rw [\u2190 associator_naturality_middle, \u2190 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 (\u03b7 : OplaxNatTrans F G) (\u03b8 : OplaxNatTrans G H) : OplaxNatTrans F H\n    where\n  app a := \u03b7.app a \u226b \u03b8.app a\n  naturality a b f :=\n    (\u03b1_ _ _ _).inv \u226b\n      \u03b7.naturality f \u25b7 \u03b8.app b \u226b (\u03b1_ _ _ _).Hom \u226b \u03b7.app a \u25c1 \u03b8.naturality f \u226b (\u03b1_ _ _ _).inv\n  naturality_comp' a b c f g :=\n    by\n    calc\n      _ =\n          _ \u226b\n            F.map_comp f g \u25b7 \u03b7.app c \u25b7 \u03b8.app c \u226b\n              _ \u226b\n                F.map f \u25c1 \u03b7.naturality g \u25b7 \u03b8.app c \u226b\n                  _ \u226b\n                    (F.map f \u226b \u03b7.app b) \u25c1 \u03b8.naturality g \u226b\n                      \u03b7.naturality f \u25b7 (\u03b8.app b \u226b H.map g) \u226b\n                        _ \u226b \u03b7.app a \u25c1 \u03b8.naturality f \u25b7 H.map g \u226b _ :=\n        _\n      _ = _ := _\n      \n    exact (\u03b1_ _ _ _).inv\n    exact (\u03b1_ _ _ _).Hom \u25b7 _ \u226b (\u03b1_ _ _ _).Hom\n    exact _ \u25c1 (\u03b1_ _ _ _).Hom \u226b (\u03b1_ _ _ _).inv\n    exact (\u03b1_ _ _ _).Hom \u226b _ \u25c1 (\u03b1_ _ _ _).inv\n    exact _ \u25c1 (\u03b1_ _ _ _).Hom \u226b (\u03b1_ _ _ _).inv\n    \u00b7 rw [whisker_exchange_assoc]\n      simp\n    \u00b7 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 `\u0393` between oplax natural transformations `\u03b7` and `\u03b8` consists of a family of\n2-morphisms `\u0393.app a : \u03b7.app a \u27f6 \u03b8.app a`, which satisfies the equation\n`(F.map f \u25c1 app b) \u226b \u03b8.naturality f = \u03b7.naturality f \u226b (app a \u25b7 G.map f)`\nfor each 1-morphism `f : a \u27f6 b`.\n-/\n@[ext]\nstructure Modification (\u03b7 \u03b8 : F \u27f6 G) where\n  app (a : B) : \u03b7.app a \u27f6 \u03b8.app a\n  naturality' :\n    \u2200 {a b : B} (f : a \u27f6 b),\n      F.map f \u25c1 app b \u226b \u03b8.naturality f = \u03b7.naturality f \u226b app a \u25b7 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 {\u03b7 \u03b8 \u03b9 : F \u27f6 G}\n\nnamespace Modification\n\nvariable (\u03b7)\n\n/-- The identity modification. -/\n@[simps]\ndef id : Modification \u03b7 \u03b7 where app a := \ud835\udfd9 (\u03b7.app a)\n#align category_theory.oplax_nat_trans.modification.id CategoryTheory.OplaxNatTrans.Modification.id\n\ninstance : Inhabited (Modification \u03b7 \u03b7) :=\n  \u27e8Modification.id \u03b7\u27e9\n\nvariable {\u03b7}\n\nsection\n\nvariable (\u0393 : Modification \u03b7 \u03b8) {a b c : B} {a' : C}\n\n@[simp, reassoc.1]\ntheorem whiskerLeft_naturality (f : a' \u27f6 F.obj b) (g : b \u27f6 c) :\n    f \u25c1 F.map g \u25c1 \u0393.app c \u226b f \u25c1 \u03b8.naturality g = f \u25c1 \u03b7.naturality g \u226b f \u25c1 \u0393.app b \u25b7 G.map g := by\n  simp_rw [\u2190 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 \u27f6 b) (g : G.obj b \u27f6 a') :\n    F.map f \u25c1 \u0393.app b \u25b7 g \u226b (\u03b1_ _ _ _).inv \u226b \u03b8.naturality f \u25b7 g =\n      (\u03b1_ _ _ _).inv \u226b \u03b7.naturality f \u25b7 g \u226b \u0393.app a \u25b7 G.map f \u25b7 g :=\n  by simp_rw [associator_inv_naturality_middle_assoc, \u2190 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 (\u0393 : Modification \u03b7 \u03b8) (\u0394 : Modification \u03b8 \u03b9) : Modification \u03b7 \u03b9\n    where app a := \u0393.app a \u226b \u0394.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 \u27f6 G)\n    where\n  Hom := Modification\n  id := Modification.id\n  comp \u03b7 \u03b8 \u03b9 := 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 : \u2200 a, \u03b7.app a \u2245 \u03b8.app a)\n    (naturality :\n      \u2200 {a b} (f : a \u27f6 b),\n        F.map f \u25c1 (app b).Hom \u226b \u03b8.naturality f = \u03b7.naturality f \u226b (app a).Hom \u25b7 G.map f) :\n    \u03b7 \u2245 \u03b8 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 => _ \u25c1 (app b).inv \u226b f \u226b (app a).inv \u25b7 _) (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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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\u2082`: 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\u2083` as its only purpose so far would be to prove properties of\n`Option.map\u2082` and casing already fulfills this task.\n-/\n\n\nopen Function\n\nnamespace Option\n\nvariable {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {a : Option \u03b1} {b : Option \u03b2} {c : Option \u03b3}\n\n/-- The image of a binary function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` as a function `Option \u03b1 \u2192 Option \u03b2 \u2192 Option \u03b3`.\nMathematically this should be thought of as the image of the corresponding function `\u03b1 \u00d7 \u03b2 \u2192 \u03b3`. -/\ndef map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : Option \u03b2) : Option \u03b3 :=\n  a.bind fun a => b.map <| f a\n#align option.map\u2082 Option.map\u2082\n\n/-- `Option.map\u2082` in terms of monadic operations. Note that this can't be taken as the definition\nbecause of the lack of universe polymorphism. -/\ntheorem map\u2082_def {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : Option \u03b2) :\n    map\u2082 f a b = f <$> a <*> b :=\n  by cases a <;> rfl\n#align option.map\u2082_def Option.map\u2082_def\n\n-- porting note: In Lean3, was `@[simp]` but now `simp` can prove it\ntheorem map\u2082_some_some (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (b : \u03b2) : map\u2082 f (some a) (some b) = f a b := rfl\n#align option.map\u2082_some_some Option.map\u2082_some_some\n\ntheorem map\u2082_coe_coe (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (b : \u03b2) : map\u2082 f a b = f a b := rfl\n#align option.map\u2082_coe_coe Option.map\u2082_coe_coe\n\n@[simp]\ntheorem map\u2082_none_left (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (b : Option \u03b2) : map\u2082 f none b = none := rfl\n#align option.map\u2082_none_left Option.map\u2082_none_left\n\n@[simp]\ntheorem map\u2082_none_right (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) : map\u2082 f a none = none := by cases a <;> rfl\n#align option.map\u2082_none_right Option.map\u2082_none_right\n\n@[simp]\ntheorem map\u2082_coe_left (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (b : Option \u03b2) : map\u2082 f a b = b.map fun b => f a b :=\n  rfl\n#align option.map\u2082_coe_left Option.map\u2082_coe_left\n\n-- porting note: This proof was `rfl` in Lean3, but now is not.\n@[simp]\ntheorem map\u2082_coe_right (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : \u03b2) : map\u2082 f a b = a.map fun a => f a b :=\n  by cases a <;> rfl\n#align option.map\u2082_coe_right Option.map\u2082_coe_right\n\n-- porting note: Removed the `@[simp]` tag as membership of an `Option` is no-longer simp-normal.\ntheorem mem_map\u2082_iff {c : \u03b3} : c \u2208 map\u2082 f a b \u2194 \u2203 a' b', a' \u2208 a \u2227 b' \u2208 b \u2227 f a' b' = c :=\n  by simp [map\u2082]\n#align option.mem_map\u2082_iff Option.mem_map\u2082_iff\n\n@[simp]\ntheorem map\u2082_eq_none_iff : map\u2082 f a b = none \u2194 a = none \u2228 b = none :=\n  by cases a <;> cases b <;> simp\n#align option.map\u2082_eq_none_iff Option.map\u2082_eq_none_iff\n\ntheorem map\u2082_swap (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : Option \u03b2) :\n    map\u2082 f a b = map\u2082 (fun a b => f b a) b a := by cases a <;> cases b <;> rfl\n#align option.map\u2082_swap Option.map\u2082_swap\n\ntheorem map_map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (g : \u03b3 \u2192 \u03b4) :\n    (map\u2082 f a b).map g = map\u2082 (fun a b => g (f a b)) a b := by cases a <;> cases b <;> rfl\n#align option.map_map\u2082 Option.map_map\u2082\n\ntheorem map\u2082_map_left (f : \u03b3 \u2192 \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b3) :\n    map\u2082 f (a.map g) b = map\u2082 (fun a b => f (g a) b) a b := by cases a <;> rfl\n#align option.map\u2082_map_left Option.map\u2082_map_left\n\n\n\n@[simp]\ntheorem map\u2082_curry (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : Option \u03b2) :\n    map\u2082 (curry f) a b = Option.map f (map\u2082 Prod.mk a b) := (map_map\u2082 _ _).symm\n#align option.map\u2082_curry Option.map\u2082_curry\n\n@[simp]\ntheorem map_uncurry (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (x : Option (\u03b1 \u00d7 \u03b2)) :\n    x.map (uncurry f) = map\u2082 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\u2082` of those operations.\nThe proof pattern is `map\u2082_lemma operation_lemma`. For example, `map\u2082_comm mul_comm` proves that\n`map\u2082 (*) a b = map\u2082 (*) g f` in a `CommSemigroup`.\n-/\n\ntheorem map\u2082_assoc {f : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b5' \u2192 \u03b5} {g' : \u03b2 \u2192 \u03b3 \u2192 \u03b5'}\n    (h_assoc : \u2200 a b c, f (g a b) c = f' a (g' b c)) :\n    map\u2082 f (map\u2082 g a b) c = map\u2082 f' a (map\u2082 g' b c) :=\n  by cases a <;> cases b <;> cases c <;> simp [h_assoc]\n#align option.map\u2082_assoc Option.map\u2082_assoc\n\ntheorem map\u2082_comm {g : \u03b2 \u2192 \u03b1 \u2192 \u03b3} (h_comm : \u2200 a b, f a b = g b a) : map\u2082 f a b = map\u2082 g b a :=\n  by cases a <;> cases b <;> simp [h_comm]\n#align option.map\u2082_comm Option.map\u2082_comm\n\ntheorem map\u2082_left_comm {f : \u03b1 \u2192 \u03b4 \u2192 \u03b5} {g : \u03b2 \u2192 \u03b3 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b3 \u2192 \u03b4'} {g' : \u03b2 \u2192 \u03b4' \u2192 \u03b5}\n    (h_left_comm : \u2200 a b c, f a (g b c) = g' b (f' a c)) :\n    map\u2082 f a (map\u2082 g b c) = map\u2082 g' b (map\u2082 f' a c) :=\n  by cases a <;> cases b <;> cases c <;> simp [h_left_comm]\n#align option.map\u2082_left_comm Option.map\u2082_left_comm\n\ntheorem map\u2082_right_comm {f : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b3 \u2192 \u03b4'} {g' : \u03b4' \u2192 \u03b2 \u2192 \u03b5}\n    (h_right_comm : \u2200 a b c, f (g a b) c = g' (f' a c) b) :\n    map\u2082 f (map\u2082 g a b) c = map\u2082 g' (map\u2082 f' a c) b :=\n  by cases a <;> cases b <;> cases c <;> simp [h_right_comm]\n#align option.map\u2082_right_comm Option.map\u2082_right_comm\n\ntheorem map_map\u2082_distrib {g : \u03b3 \u2192 \u03b4} {f' : \u03b1' \u2192 \u03b2' \u2192 \u03b4} {g\u2081 : \u03b1 \u2192 \u03b1'} {g\u2082 : \u03b2 \u2192 \u03b2'}\n    (h_distrib : \u2200 a b, g (f a b) = f' (g\u2081 a) (g\u2082 b)) :\n    (map\u2082 f a b).map g = map\u2082 f' (a.map g\u2081) (b.map g\u2082) :=\n  by cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map\u2082_distrib Option.map_map\u2082_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\u2082_map_left_comm`. -/\ntheorem map_map\u2082_distrib_left {g : \u03b3 \u2192 \u03b4} {f' : \u03b1' \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b1 \u2192 \u03b1'}\n    (h_distrib : \u2200 a b, g (f a b) = f' (g' a) b) :\n    (map\u2082 f a b).map g = map\u2082 f' (a.map g') b := by cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map\u2082_distrib_left Option.map_map\u2082_distrib_left\n\n/-- Symmetric statement to `Option.map_map\u2082_right_comm`. -/\ntheorem map_map\u2082_distrib_right {g : \u03b3 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b2' \u2192 \u03b4} {g' : \u03b2 \u2192 \u03b2'}\n    (h_distrib : \u2200 a b, g (f a b) = f' a (g' b)) : (map\u2082 f a b).map g = map\u2082 f' a (b.map g') :=\n  by cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map\u2082_distrib_right Option.map_map\u2082_distrib_right\n\n/-- Symmetric statement to `Option.map_map\u2082_distrib_left`. -/\ntheorem map\u2082_map_left_comm {f : \u03b1' \u2192 \u03b2 \u2192 \u03b3} {g : \u03b1 \u2192 \u03b1'} {f' : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_left_comm : \u2200 a b, f (g a) b = g' (f' a b)) : map\u2082 f (a.map g) b = (map\u2082 f' a b).map g' :=\n  by cases a <;> cases b <;> simp [h_left_comm]\n#align option.map\u2082_map_left_comm Option.map\u2082_map_left_comm\n\n/-- Symmetric statement to `Option.map_map\u2082_distrib_right`. -/\ntheorem map_map\u2082_right_comm {f : \u03b1 \u2192 \u03b2' \u2192 \u03b3} {g : \u03b2 \u2192 \u03b2'} {f' : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_right_comm : \u2200 a b, f a (g b) = g' (f' a b)) : map\u2082 f a (b.map g) = (map\u2082 f' a b).map g' :=\n  by cases a <;> cases b <;> simp [h_right_comm]\n#align option.map_map\u2082_right_comm Option.map_map\u2082_right_comm\n\ntheorem map_map\u2082_antidistrib {g : \u03b3 \u2192 \u03b4} {f' : \u03b2' \u2192 \u03b1' \u2192 \u03b4} {g\u2081 : \u03b2 \u2192 \u03b2'} {g\u2082 : \u03b1 \u2192 \u03b1'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' (g\u2081 b) (g\u2082 a)) :\n    (map\u2082 f a b).map g = map\u2082 f' (b.map g\u2081) (a.map g\u2082) :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map\u2082_antidistrib Option.map_map\u2082_antidistrib\n\n/-- Symmetric statement to `Option.map\u2082_map_left_anticomm`. -/\ntheorem map_map\u2082_antidistrib_left {g : \u03b3 \u2192 \u03b4} {f' : \u03b2' \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b2 \u2192 \u03b2'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' (g' b) a) :\n    (map\u2082 f a b).map g = map\u2082 f' (b.map g') a :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map\u2082_antidistrib_left Option.map_map\u2082_antidistrib_left\n\n/-- Symmetric statement to `Option.map_map\u2082_right_anticomm`. -/\ntheorem map_map\u2082_antidistrib_right {g : \u03b3 \u2192 \u03b4} {f' : \u03b2 \u2192 \u03b1' \u2192 \u03b4} {g' : \u03b1 \u2192 \u03b1'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' b (g' a)) : (map\u2082 f a b).map g = map\u2082 f' b (a.map g') :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map\u2082_antidistrib_right Option.map_map\u2082_antidistrib_right\n\n/-- Symmetric statement to `Option.map_map\u2082_antidistrib_left`. -/\ntheorem map\u2082_map_left_anticomm {f : \u03b1' \u2192 \u03b2 \u2192 \u03b3} {g : \u03b1 \u2192 \u03b1'} {f' : \u03b2 \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_left_anticomm : \u2200 a b, f (g a) b = g' (f' b a)) :\n    map\u2082 f (a.map g) b = (map\u2082 f' b a).map g' := by cases a <;> cases b <;> simp [h_left_anticomm]\n#align option.map\u2082_map_left_anticomm Option.map\u2082_map_left_anticomm\n\n/-- Symmetric statement to `Option.map_map\u2082_antidistrib_right`. -/\ntheorem map_map\u2082_right_anticomm {f : \u03b1 \u2192 \u03b2' \u2192 \u03b3} {g : \u03b2 \u2192 \u03b2'} {f' : \u03b2 \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_right_anticomm : \u2200 a b, f a (g b) = g' (f' b a)) :\n    map\u2082 f a (b.map g) = (map\u2082 f' b a).map g' := by cases a <;> cases b <;> simp [h_right_anticomm]\n#align option.map_map\u2082_right_anticomm Option.map_map\u2082_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\u2082 f`. -/\nlemma map\u2082_left_identity {f : \u03b1 \u2192 \u03b2 \u2192 \u03b2} {a : \u03b1} (h : \u2200 b, f a b = b) (o : Option \u03b2) :\n    map\u2082 f (some a) o = o := by\n  cases o; exacts [rfl, congr_arg some (h _)]\n#align option.map\u2082_left_identity Option.map\u2082_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\u2082 f`. -/\nlemma map\u2082_right_identity {f : \u03b1 \u2192 \u03b2 \u2192 \u03b1} {b : \u03b2} (h : \u2200 a, f a b = a) (o : Option \u03b1) :\n    map\u2082 f o (some b) = o := by\n  simp [h, map\u2082]\n#align option.map\u2082_right_identity Option.map\u2082_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 \u03b1 \u03b2` is finite if both `\u03b1` and `\u03b2` 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 _) {\u03b1 \u03b3 : Type _} {\u03b2 : \u03b1 \u2192 Type _} [FunLike F \u03b1 \u03b2] [FunLike G \u03b1 fun _ => \u03b3]\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 \u03b1] [Fintype \u03b1] [\u2200 i, Fintype (\u03b2 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 \u03b1] [Fintype \u03b1] [Fintype \u03b3] : 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 _) {\u03b1 \u03b3 : Sort _} {\u03b2 : \u03b1 \u2192 Sort _} [FunLike F \u03b1 \u03b2] [FunLike G \u03b1 fun _ => \u03b3]\n\n/- warning: fun_like.finite -> FunLike.finite is a dubious translation:\nlean 3 declaration is\n  forall (F : Sort.{u1}) {\u03b1 : Sort.{u2}} {\u03b2 : \u03b1 -> Sort.{u3}} [_inst_1 : FunLike.{u1, u2, u3} F \u03b1 \u03b2] [_inst_3 : Finite.{u2} \u03b1] [_inst_4 : forall (i : \u03b1), Finite.{u3} (\u03b2 i)], Finite.{u1} F\nbut is expected to have type\n  forall (F : Sort.{u1}) {\u03b1 : Sort.{u3}} {\u03b2 : \u03b1 -> Sort.{u2}} [_inst_1 : FunLike.{u1, u3, u2} F \u03b1 \u03b2] [_inst_3 : Finite.{u3} \u03b1] [_inst_4 : forall (i : \u03b1), Finite.{u2} (\u03b2 i)], Finite.{u1} F\nCase conversion may be inaccurate. Consider using '#align fun_like.finite FunLike.finite\u2093'. -/\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 \u03b1] [\u2200 i, Finite (\u03b2 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}) {\u03b1 : Sort.{u2}} {\u03b3 : Sort.{u3}} [_inst_2 : FunLike.{u1, u2, u3} G \u03b1 (fun (_x : \u03b1) => \u03b3)] [_inst_3 : Finite.{u2} \u03b1] [_inst_4 : Finite.{u3} \u03b3], Finite.{u1} G\nbut is expected to have type\n  forall (G : Sort.{u1}) {\u03b1 : Sort.{u3}} {\u03b3 : Sort.{u2}} [_inst_2 : FunLike.{u1, u3, u2} G \u03b1 (fun (_x : \u03b1) => \u03b3)] [_inst_3 : Finite.{u3} \u03b1] [_inst_4 : Finite.{u2} \u03b3], Finite.{u1} G\nCase conversion may be inaccurate. Consider using '#align fun_like.finite' FunLike.finite'\u2093'. -/\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 \u03b1] [Finite \u03b3] : 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 \u2286 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 `(+) := (\u2294)` and `\u22a5 := 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 `\u22a5.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 \u2286 R` for some `a \u2260 0`. -/\ndef is_fractional (I : submodule R f.codomain) :=\n\u2203 a \u2208 S, \u2200 b \u2208 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 \u2208 R`.\n\n  More precisely, let `P` be a localization of `R` at some submonoid `S`,\n  then a fractional ideal `I \u2286 P` is an `R`-submodule of `P`,\n  such that there is a nonzero `a : R` with `a I \u2286 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) := \u27e8\u03bb I, I.val\u27e9\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) := \u27e8\u03bb x I, x \u2208 (I : submodule R f.codomain)\u27e9\n\nlemma mem_coe {x : f.codomain} {I : fractional_ideal f} :\n  x \u2208 (I : submodule R f.codomain) \u2194 x \u2208 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 \u2192 I = J :=\nsubtype.ext_iff_val.mpr\n\nlemma ext_iff {I J : fractional_ideal f} : (\u2200 x, (x \u2208 I \u2194 x \u2208 J)) \u2194 I = J :=\n\u27e8 \u03bb h, ext (submodule.ext h), \u03bb h x, h \u25b8 iff.rfl \u27e9\n\nlemma fractional_of_subset_one (I : submodule R f.codomain)\n  (h : I \u2264 (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 \u2190submodule.one_eq_span at h,\n  obtain \u27e8b', b'_mem, b'_eq_b\u27e9 := 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 \u2264 J) : is_fractional f I :=\nbegin\n  obtain \u27e8a, a_mem, ha\u27e9 := 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\u27e8 \u03bb I, \u27e8f.coe_submodule I, fractional_of_subset_one _ $ \u03bb x \u27e8y, hy, h\u27e9,\n  submodule.mem_span_singleton.2 \u27e8y, by rw \u2190h; exact mul_one _\u27e9\u27e9 \u27e9\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 \u2208 (I : fractional_ideal f) \u2194 \u2203 (x' \u2208 I), f.to_map x' = x :=\n\u27e8 \u03bb \u27e8x', hx', hx\u27e9, \u27e8x', hx', hx\u27e9,\n  \u03bb \u27e8x', hx', hx\u27e9, \u27e8x', hx', hx\u27e9 \u27e9\n\ninstance : has_zero (fractional_ideal f) := \u27e8(0 : ideal R)\u27e9\n\n@[simp] lemma mem_zero_iff {x : P} : x \u2208 (0 : fractional_ideal f) \u2194 x = 0 :=\n\u27e8 (\u03bb \u27e8x', x'_mem_zero, x'_eq_x\u27e9,\n    have x'_eq_zero : x' = 0 := x'_mem_zero,\n    by simp [x'_eq_x.symm, x'_eq_zero]),\n  (\u03bb hx, \u27e80, rfl, by simp [hx]\u27e9) \u27e9\n\n@[simp, norm_cast] lemma coe_zero : \u2191(0 : fractional_ideal f) = (\u22a5 : submodule R f.codomain) :=\nsubmodule.ext $ \u03bb _, mem_zero_iff\n\n@[simp, norm_cast] lemma coe_to_fractional_ideal_bot : ((\u22a5 : ideal R) : fractional_ideal f) = 0 :=\nrfl\n\n@[simp] lemma exists_mem_to_map_eq {x : R} {I : ideal R} (h : S \u2264 non_zero_divisors R) :\n  (\u2203 x', x' \u2208 I \u2227 f.to_map x' = f.to_map x) \u2194 x \u2208 I :=\n\u27e8\u03bb \u27e8x', hx', eq\u27e9, f.injective h eq \u25b8 hx', \u03bb h, \u27e8x, h, rfl\u27e9\u27e9\n\nlemma coe_to_fractional_ideal_injective (h : S \u2264 non_zero_divisors R) :\n  function.injective (coe : ideal R \u2192 fractional_ideal f) :=\n\u03bb I J heq, have\n  \u2200 (x : R), f.to_map x \u2208 (I : fractional_ideal f) \u2194 f.to_map x \u2208 (J : fractional_ideal f) :=\n\u03bb x, heq \u25b8 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 \u2264 non_zero_divisors R) :\n  (I : fractional_ideal f) = 0 \u2194 I = (\u22a5 : ideal R) :=\n\u27e8\u03bb h, coe_to_fractional_ideal_injective hS h,\n \u03bb h, by rw [h, coe_to_fractional_ideal_bot]\u27e9\n\nlemma coe_to_fractional_ideal_ne_zero {I : ideal R} (hS : S \u2264 non_zero_divisors R) :\n  (I : fractional_ideal f) \u2260 0 \u2194 I \u2260 (\u22a5 : 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) = \u22a5 \u2194 I = 0 :=\n\u27e8\u03bb h, ext (by simp [h]),\n \u03bb h, by simp [h] \u27e9\n\nlemma coe_to_submodule_ne_bot {I : fractional_ideal f} :\n  \u2191I \u2260 (\u22a5 : submodule R f.codomain) \u2194 I \u2260 0 :=\nnot_iff_not.mpr coe_to_submodule_eq_bot\n\ninstance : inhabited (fractional_ideal f) := \u27e80\u27e9\n\ninstance : has_one (fractional_ideal f) :=\n\u27e8(1 : ideal R)\u27e9\n\nlemma mem_one_iff {x : P} : x \u2208 (1 : fractional_ideal f) \u2194 \u2203 x' : R, f.to_map x' = x :=\niff.intro (\u03bb \u27e8x', _, h\u27e9, \u27e8x', h\u27e9) (\u03bb \u27e8x', h\u27e9, \u27e8x', \u27e8x', set.mem_univ _, rfl\u27e9, h\u27e9)\n\nlemma coe_mem_one (x : R) : f.to_map x \u2208 (1 : fractional_ideal f) :=\nmem_one_iff.mpr \u27e8x, rfl\u27e9\n\nlemma one_mem_one : (1 : P) \u2208 (1 : fractional_ideal f) :=\nmem_one_iff.mpr \u27e81, f.to_map.map_one\u27e9\n\n/-- `(1 : fractional_ideal f)` is defined as the R-submodule `f(R) \u2264 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  \u2191(1 : fractional_ideal f) = f.coe_submodule (1 : ideal R) :=\nrfl\n\n@[simp, norm_cast] lemma coe_one :\n  (\u2191(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 := \u03bb I J, I.1 \u2264 J.1,\n  le_refl := \u03bb I, le_refl I.1,\n  le_antisymm := \u03bb \u27e8I, hI\u27e9 \u27e8J, hJ\u27e9 hIJ hJI, by { congr, exact le_antisymm hIJ hJI },\n  le_trans := \u03bb _ _ _ hIJ hJK, le_trans hIJ hJK }\n\nlemma le_iff_mem {I J : fractional_ideal f} : I \u2264 J \u2194 (\u2200 x \u2208 I, x \u2208 J) :=\niff.rfl\n\n@[simp] lemma coe_le_coe {I J : fractional_ideal f} :\n  (I : submodule R f.codomain) \u2264 (J : submodule R f.codomain) \u2194 I \u2264 J :=\niff.rfl\n\nlemma zero_le (I : fractional_ideal f) : 0 \u2264 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 : (\u22a5 : fractional_ideal f) = 0 :=\nrfl\n\n@[simp] lemma le_zero_iff {I : fractional_ideal f} : I \u2264 0 \u2194 I = 0 :=\nle_bot_iff\n\nlemma eq_zero_iff {I : fractional_ideal f} : I = 0 \u2194 (\u2200 x \u2208 I, x = (0 : P)) :=\n\u27e8 (\u03bb h x hx, by simpa [h, mem_zero_iff] using hx),\n  (\u03bb h, le_bot_iff.mp (\u03bb x hx, mem_zero_iff.mpr (h x hx))) \u27e9\n\nlemma fractional_sup (I J : fractional_ideal f) : is_fractional f (I.1 \u2294 J.1) :=\nbegin\n  rcases I.2 with \u27e8aI, haI, hI\u27e9,\n  rcases J.2 with \u27e8aJ, haJ, hJ\u27e9,\n  use aI * aJ,\n  use S.mul_mem haI haJ,\n  intros b hb,\n  rcases mem_sup.mp hb with\n    \u27e8bI, hbI, bJ, hbJ, hbIJ\u27e9,\n  rw [\u2190hbIJ, 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 \u2293 J.1) :=\nbegin\n  rcases I.2 with \u27e8aI, haI, hI\u27e9,\n  use aI,\n  use haI,\n  intros b hb,\n  rcases mem_inf.mp hb with \u27e8hbI, hbJ\u27e9,\n  exact (hI b hbI)\nend\n\ninstance lattice : lattice (fractional_ideal f) :=\n{ inf := \u03bb I J, \u27e8I.1 \u2293 J.1, fractional_inf I J\u27e9,\n  sup := \u03bb I J, \u27e8I.1 \u2294 J.1, fractional_sup I J\u27e9,\n  inf_le_left := \u03bb I J, show I.1 \u2293 J.1 \u2264 I.1, from inf_le_left,\n  inf_le_right := \u03bb I J, show I.1 \u2293 J.1 \u2264 J.1, from inf_le_right,\n  le_inf := \u03bb I J K hIJ hIK, show I.1 \u2264 (J.1 \u2293 K.1), from le_inf hIJ hIK,\n  le_sup_left := \u03bb I J, show I.1 \u2264 I.1 \u2294 J.1, from le_sup_left,\n  le_sup_right := \u03bb I J, show J.1 \u2264 I.1 \u2294 J.1, from le_sup_right,\n  sup_le := \u03bb I J K hIK hJK, show (I.1 \u2294 J.1) \u2264 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  \u2191I \u2264 J \u2194 \u2200 x \u2208 I, f.to_map x \u2208 J :=\n\u27e8\u03bb h x hx, h \u27e8x, hx, rfl\u27e9,\n \u03bb h x hx, let \u27e8x', hx', eq_x\u27e9 := fractional_ideal.mem_coe_ideal.mp hx in eq_x \u25b8 h x' hx'\u27e9\n\nend lattice\n\nsection semiring\n\ninstance : has_add (fractional_ideal f) := \u27e8(\u2294)\u27e9\n\n@[simp]\nlemma sup_eq_add (I J : fractional_ideal f) : I \u2294 J = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_add (I J : fractional_ideal f) : (\u2191(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 \u27e8I, aI, haI, hI\u27e9,\n  rcases J with \u27e8I, aJ, haJ, hJ\u27e9,\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 \u27e8n', hn'\u27e9 := hJ n hn,\n    rw [f.to_map.map_mul, mul_comm m, \u2190mul_assoc, mul_assoc _ _ n],\n    erw \u2190hn', rw mul_assoc,\n    apply hI,\n    exact submodule.smul_mem _ _ hm },\n  { rw [mul_zero],\n    exact \u27e80, f.to_map.map_zero\u27e9 },\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 [\u2190mul_assoc, \u2190f.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\u27e8I.1 * J.1, fractional_mul I J\u27e9\n\nlocal attribute [semireducible] mul\n\ninstance : has_mul (fractional_ideal f) := \u27e8\u03bb I J, mul I J\u27e9\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) : (\u2191(I * J) : submodule R f.codomain) = I * J := rfl\n\nlemma mul_left_mono (I : fractional_ideal f) : monotone ((*) I) :=\n\u03bb J J' h, mul_le.mpr (\u03bb x hx y hy, mul_mem_mul hx (h hy))\n\nlemma mul_right_mono (I : fractional_ideal f) : monotone (\u03bb J, J * I) :=\n\u03bb J J' h, mul_le.mpr (\u03bb 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 \u2208 I) (hj : j \u2208 J) :\n  i * j \u2208 I * J := submodule.mul_mem_mul hi hj\n\nlemma mul_le {I J K : fractional_ideal f} :\n  I * J \u2264 K \u2194 (\u2200 (i \u2208 I) (j \u2208 J), i * j \u2208 K) :=\nsubmodule.mul_le\n\n@[elab_as_eliminator] protected theorem mul_induction_on\n  {I J : fractional_ideal f}\n  {C : f.codomain \u2192 Prop} {r : f.codomain} (hr : r \u2208 I * J)\n  (hm : \u2200 (i \u2208 I) (j \u2208 J), C (i * j))\n  (h0 : C 0) (ha : \u2200 x y, C x \u2192 C y \u2192 C (x + y))\n  (hs : \u2200 (r : R) x, C x \u2192 C (r \u2022 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  (\u2191(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 (\u03bb x hx y hy, _) _ (\u03bb x y hx hy, _) (\u03bb 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 \u27e8x, hx, rfl\u27e9 },\n      { exact \u27e8y, hy, rfl\u27e9 } },\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 \u27e8x', hx', rfl\u27e9 := fractional_ideal.mem_coe_ideal.mp hx,\n    obtain \u27e8y', hy', rfl\u27e9 := fractional_ideal.mem_coe_ideal.mp hy,\n    rw fractional_ideal.mem_coe_ideal,\n    exact \u27e8x' * y', ideal.mul_mem_mul hx' hy', f.to_map.map_mul _ _\u27e9 },\nend\n\ninstance comm_semiring : comm_semiring (fractional_ideal f) :=\n{ add_assoc := \u03bb I J K, sup_assoc,\n  add_comm := \u03bb I J, sup_comm,\n  add_zero := \u03bb I, sup_bot_eq,\n  zero_add := \u03bb I, bot_sup_eq,\n  mul_assoc := \u03bb I J K, ext (submodule.mul_assoc _ _ _),\n  mul_comm := \u03bb I J, ext (submodule.mul_comm _ _),\n  mul_one := \u03bb I, begin\n    ext,\n    split; intro h,\n    { apply mul_le.mpr _ h,\n      rintros x hx y \u27e8y', y'_mem_R, y'_eq_y\u27e9,\n      rw [\u2190y'_eq_y, mul_comm],\n      exact submodule.smul_mem _ _ hx },\n    { have : x * 1 \u2208 (I * 1) := mul_mem_mul h one_mem_one,\n      rwa [mul_one] at this }\n  end,\n  one_mul := \u03bb I, begin\n    ext,\n    split; intro h,\n    { apply mul_le.mpr _ h,\n      rintros x \u27e8x', x'_mem_R, x'_eq_x\u27e9 y hy,\n      rw \u2190x'_eq_x,\n      exact submodule.smul_mem _ _ hy },\n    { have : 1 * x \u2208 (1 * I) := mul_mem_mul one_mem_one h,\n      rwa [one_mul] at this }\n  end,\n  mul_zero := \u03bb I, eq_zero_iff.mpr (\u03bb x hx, submodule.mul_induction_on hx\n    (\u03bb x hx y hy, by simp [mem_zero_iff.mp hy])\n    rfl\n    (\u03bb x y hx hy, by simp [hx, hy])\n    (\u03bb r x hx, by simp [hx])),\n  zero_mul := \u03bb I, eq_zero_iff.mpr (\u03bb x hx, submodule.mul_induction_on hx\n    (\u03bb x hx y hy, by simp [mem_zero_iff.mp hx])\n    rfl\n    (\u03bb x y hx hy, by simp [hx, hy])\n    (\u03bb r x hx, by simp [hx])),\n  left_distrib := \u03bb I J K, ext (mul_add _ _ _),\n  right_distrib := \u03bb 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 \u2264 J) (J' : fractional_ideal f) :\n  J' + I \u2264 J' + J :=\nsup_le_sup_left hIJ J'\n\nlemma mul_le_mul_left {I J : fractional_ideal f} (hIJ : I \u2264 J) (J' : fractional_ideal f) :\n  J' * I \u2264 J' * J :=\nmul_le.mpr (\u03bb k hk j hj, mul_mem_mul hk (hIJ hj))\n\nlemma le_self_mul_self {I : fractional_ideal f} (hI: 1 \u2264 I) : I \u2264 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 \u2264 1) : I * I \u2264 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) \u2264 1 :=\n\u03bb x hx, let \u27e8y, _, hy\u27e9 := fractional_ideal.mem_coe_ideal.mp hx\n  in fractional_ideal.mem_one_iff.mpr \u27e8y, hy\u27e9\n\nlemma le_one_iff_exists_coe_ideal {J : fractional_ideal f} :\n  J \u2264 (1 : fractional_ideal f) \u2194 \u2203 (I : ideal R), \u2191I = J :=\nbegin\n  split,\n  { intro hJ,\n    refine \u27e8\u27e8{x : R | f.to_map x \u2208 J}, _, _, _\u27e9, _\u27e9,\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 \u27e8y, hy, eq_y\u27e9,\n        rwa \u2190 eq_y },\n      { intro hx,\n        obtain \u27e8y, eq_x\u27e9 := fractional_ideal.mem_one_iff.mp (hJ hx),\n        rw \u2190 eq_x at *,\n        exact \u27e8y, hx, rfl\u27e9 } } },\n  { rintro \u27e8I, hI\u27e9,\n    rw \u2190 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 \u2192\u2090[R] f'.codomain) (I : fractional_ideal f) :\n  is_fractional f' (submodule.map g.to_linear_map I.1) :=\nbegin\n  rcases I with \u27e8I, a, a_nonzero, hI\u27e9,\n  use [a, a_nonzero],\n  intros b hb,\n  obtain \u27e8b', b'_mem, hb'\u27e9 := submodule.mem_map.mp hb,\n  obtain \u27e8x, hx\u27e9 := hI b' b'_mem,\n  use x,\n  erw [\u2190g.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 \u2192\u2090[R] f'.codomain) :\n  fractional_ideal f \u2192 fractional_ideal f' :=\n\u03bb I, \u27e8submodule.map g.to_linear_map I.1, fractional_map g I\u27e9\n\n@[simp, norm_cast] lemma coe_map (g : f.codomain \u2192\u2090[R] f'.codomain) (I : fractional_ideal f) :\n  \u2191(map g I) = submodule.map g.to_linear_map I := rfl\n\n@[simp] lemma mem_map {I : fractional_ideal f} {g : f.codomain \u2192\u2090[R] f'.codomain}\n  {y : f'.codomain} : y \u2208 I.map g \u2194 \u2203 x, x \u2208 I \u2227 g x = y :=\nsubmodule.mem_map\n\nvariables (I J : fractional_ideal f) (g : f.codomain \u2192\u2090[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 \u2192\u2090[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 \u27e8_, \u27e8y, hy, rfl\u27e9, rfl\u27e9,\n    exact \u27e8y, hy, (g.commutes y).symm\u27e9 },\n  { rintro \u27e8y, hy, rfl\u27e9,\n    exact \u27e8_, \u27e8y, hy, rfl\u27e9, g.commutes y\u27e9 },\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 \u2243\u2090[R] f'.codomain) :\n  (I.map (g : f.codomain \u2192\u2090[R] f'.codomain)).map (g.symm : f'.codomain \u2192\u2090[R] f.codomain) = I :=\nby rw [\u2190map_comp, g.symm_comp, map_id]\n\n@[simp] lemma map_symm_map (I : fractional_ideal f') (g : f.codomain \u2243\u2090[R] f'.codomain) :\n  (I.map (g.symm : f'.codomain \u2192\u2090[R] f.codomain)).map (g : f.codomain \u2192\u2090[R] f'.codomain) = I :=\nby rw [\u2190map_comp, g.comp_symm, map_id]\n\n/-- If `g` is an equivalence, `map g` is an isomorphism -/\ndef map_equiv (g : f.codomain \u2243\u2090[R] f'.codomain) :\n  fractional_ideal f \u2243+* fractional_ideal f' :=\n{ to_fun := map g,\n  inv_fun := map g.symm,\n  map_add' := \u03bb I J, map_add I J _,\n  map_mul' := \u03bb I J, map_mul I J _,\n  left_inv := \u03bb I, by { rw [\u2190map_comp, alg_equiv.symm_comp, map_id] },\n  right_inv := \u03bb I, by { rw [\u2190map_comp, alg_equiv.comp_symm, map_id] } }\n\n@[simp] lemma coe_fun_map_equiv (g : f.codomain \u2243\u2090[R] f'.codomain) :\n  \u21d1(map_equiv g) = map g :=\nrfl\n\n@[simp] lemma map_equiv_apply (g : f.codomain \u2243\u2090[R] f'.codomain) (I : fractional_ideal f) :\n  map_equiv g I = map \u2191g I := rfl\n\n@[simp] lemma map_equiv_symm (g : f.codomain \u2243\u2090[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 (\u03bb x, by simp)\n\nlemma is_fractional_span_iff {s : set f.codomain} :\nis_fractional f (span R s) \u2194 \u2203 a \u2208 S, \u2200 (b : P), b \u2208 s \u2192 f.is_integer (f.to_map a * b) :=\n\u27e8 \u03bb \u27e8a, a_mem, h\u27e9, \u27e8a, a_mem, \u03bb b hb, h b (subset_span hb)\u27e9,\n  \u03bb \u27e8a, a_mem, h\u27e9, \u27e8a, a_mem, \u03bb b hb, span_induction hb\n    h\n    (by { rw mul_zero, exact f.is_integer_zero })\n    (\u03bb x y hx hy, by { rw mul_add, exact is_integer_add hx hy })\n    (\u03bb s x hx, by { rw algebra.mul_smul_comm, exact is_integer_smul hx }) \u27e9 \u27e9\n\nlemma is_fractional_of_fg {I : submodule R f.codomain} (hI : I.fg) :\n  is_fractional f I :=\nbegin\n  rcases hI with \u27e8I, rfl\u27e9,\n  rcases localization_map.exist_integer_multiples_of_finset f I with \u27e8\u27e8s, hs1\u27e9, hs\u27e9,\n  rw is_fractional_span_iff,\n  exact \u27e8s, hs1, hs\u27e9,\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 \u2243+* fractional_ideal f' :=\nmap_equiv\n  { commutes' := \u03bb 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 \u2208 canonical_equiv f f' I \u2194\n    \u2203 y \u2208 I, @localization_map.map _ _ _ _ _ _ _ f (ring_hom.id _) _ (\u03bb \u27e8y, hy\u27e9, hy) _ _ f' y = x :=\nbegin\n  rw [canonical_equiv, map_equiv_apply, mem_map],\n  exact \u27e8\u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9, \u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9\u27e9\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 $ \u03bb I, fractional_ideal.ext_iff.mp $ \u03bb x,\nby { erw [mem_canonical_equiv_apply, canonical_equiv, map_equiv_symm, map_equiv, mem_map],\n    exact \u27e8\u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9, \u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9\u27e9 }\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 [\u2190canonical_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 \u2192\u2090[R] g'.codomain)\n\n/-- Nonzero fractional ideals contain a nonzero integer. -/\nlemma exists_ne_zero_mem_is_integer [nontrivial R] (hI : I \u2260 0) :\n  \u2203 x \u2260 (0 : R), g.to_map x \u2208 I :=\nbegin\n  obtain \u27e8y, y_mem, y_not_mem\u27e9 := submodule.exists_of_lt (bot_lt_iff_ne_bot.mpr hI),\n  have y_ne_zero : y \u2260 0 := by simpa using y_not_mem,\n  obtain \u27e8z, \u27e8x, hx\u27e9\u27e9 := g.exists_integer_multiple y,\n  refine \u27e8x, _, _\u27e9,\n  { rw [ne.def, \u2190 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 \u2260 0) : I.map h \u2260 0 :=\nbegin\n  obtain \u27e8x, x_ne_zero, hx\u27e9 := 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 \u27e8g.to_map x, hx, h.commutes x\u27e9,\nend\n\n@[simp] lemma map_eq_zero_iff [nontrivial R] : I.map h = 0 \u2194 I = 0 :=\n\u27e8imp_of_not_imp_not _ _ (map_ne_zero _),\n \u03bb hI, hI.symm \u25b8 map_zero h\u27e9\n\n@[simp, norm_cast]\nlemma coe_ideal_le_coe_ideal {I J : ideal R} :\n(I : fractional_ideal g) \u2264 (J : fractional_ideal g) \u2194 I \u2264 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 \u22a2,\n    obtain \u27e8y, hy, y_eq\u27e9 := hx,\n    exact \u27e8y, h hy, y_eq\u27e9 },\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\u2081 : Type*} [integral_domain R\u2081] {K : Type*} [field K] {g : fraction_map R\u2081 K}\n\ninstance : nontrivial (fractional_ideal g) :=\n\u27e8\u27e80, 1, \u03bb h,\n  have this : (1 : K) \u2208 (0 : fractional_ideal g) :=\n    by rw \u2190g.to_map.map_one; convert coe_mem_one _,\n  one_ne_zero (mem_zero_iff.mp this) \u27e9\u27e9\n\nlemma fractional_div_of_nonzero {I J : fractional_ideal g} (h : J \u2260 0) :\n  is_fractional g (I.1 / J.1) :=\nbegin\n  rcases I with \u27e8I, aI, haI, hI\u27e9,\n  rcases J with \u27e8J, aJ, haJ, hJ\u27e9,\n  obtain \u27e8y, mem_J, not_mem_zero\u27e9 := exists_of_lt (bot_lt_iff_ne_bot.mpr h),\n  obtain \u27e8y', hy'\u27e9 := hJ y mem_J,\n  use (aI * y'),\n  split,\n  { apply (non_zero_divisors R\u2081).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 [\u2190hy', 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 \u2260 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\u27e8 \u03bb I J, if h : J = 0 then 0 else \u27e8I.1 / J.1, fractional_div_of_nonzero h\u27e9 \u27e9\n\nvariables {I J : fractional_ideal g} [ J \u2260 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 \u2260 0) :\n  (I / J) = \u27e8I.1 / J.1, fractional_div_of_nonzero h\u27e9 :=\ndif_neg h\n\n@[simp] lemma coe_div {I J : fractional_ideal g} (hJ : J \u2260 0) :\n  (\u2191(I / J) : submodule R\u2081 g.codomain) = \u2191I / (\u2191J : submodule R\u2081 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 \u2260 0) {x} :\n  x \u2208 I / J \u2194 \u2200 y \u2208 J, x * y \u2208 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) \u2264 1 :=\nbegin\n  by_cases hI : I = 0,\n  { rw [hI, div_zero, mul_zero],\n    exact zero_le 1 },\n  { rw [\u2190 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 \u2264 (1 : fractional_ideal g)) :\n  I \u2264 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 [\u2190 coe_le_coe, coe_mul, coe_div hI_nz, coe_one],\n    rw [\u2190 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' \u2260 0) :\n  I \u2264 J / J' \u2194 \u2200 (x \u2208 I) (y \u2208 J'), x * y \u2208 J :=\n\u27e8 \u03bb h x hx, (mem_div_iff_of_nonzero hJ').mp (h hx),\n  \u03bb h x hx, (mem_div_iff_of_nonzero hJ').mpr (h x hx) \u27e9\n\nlemma le_div_iff_mul_le {I J J' : fractional_ideal g} (hJ' : J' \u2260 0) : I \u2264 J / J' \u2194 I * J' \u2264 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, \u2190coe_mul],\n  refl,\nend\n\nlemma mul_one_div_le_div {I J : fractional_ideal g} : I * (1 / J) \u2264 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... \u2264 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 \u25b8 coe_mem_one 1), simp },\n  { apply mem_div_iff_forall_mul_mem.mpr,\n    rintros y \u27e8y', _, y_eq_y'\u27e9,\n    rw mul_comm,\n    convert submodule.smul_mem _ y' h,\n    rw \u2190y_eq_y',\n    refl }\nend\n\nlemma ne_zero_of_mul_eq_one (I J : fractional_ideal g) (h : I * J = 1) : I \u2260 0 :=\n\u03bb 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 \u2260 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 \u2190 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 \u2194 \u2203 J, I * J = 1 :=\n\u27e8\u03bb h, \u27e8(1 / I), h\u27e9, \u03bb \u27e8J, hJ\u27e9, by rwa [\u2190 eq_one_div_of_mul_eq_one I J hJ]\u27e9\n\nvariables {K' : Type*} [field K'] {g' : fraction_map R\u2081 K'}\n\n@[simp] lemma map_div (I J : fractional_ideal g) (h : g.codomain \u2243\u2090[R\u2081] g'.codomain) :\n  (I / J).map (h : g.codomain \u2192\u2090[R\u2081] 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 \u2243\u2090[R\u2081] g'.codomain) :\n  (1 / I).map (h : g.codomain \u2192\u2090[R\u2081] g'.codomain) = 1 / I.map h :=\nby rw [map_div, map_one]\n\nend quotient\n\nsection principal_ideal_ring\n\nvariables {R\u2081 : Type*} [integral_domain R\u2081] {K : Type*} [field K] {g : fraction_map R\u2081 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 \u27e8a, ha\u27e9 := f.exists_integer_multiple x in\nis_fractional_span_iff.mpr \u27e8 a.1, a.2, \u03bb x hx, (mem_singleton_iff.mp hx).symm \u25b8 ha\u27e9\n\n/-- `span_singleton x` is the fractional ideal generated by `x` if `0 \u2209 S` -/\n@[irreducible]\ndef span_singleton (x : f.codomain) : fractional_ideal f :=\n\u27e8span R {x}, is_fractional_span_singleton x\u27e9\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 \u2208 span_singleton y \u2194 \u2203 (z : R), z \u2022 y = x :=\nsubmodule.mem_span_singleton\n\nlemma mem_span_singleton_self (x : f.codomain) :\n  x \u2208 span_singleton x :=\nmem_span_singleton.mpr \u27e81, one_smul _ _\u27e9\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) \u2194 \u2203 x, I = span_singleton x :=\n\u27e8\u03bb h, \u27e8@generator _ _ _ _ _ I.1 h, @eq_span_singleton_of_principal _ _ _ _ _ _ I h\u27e9,\n \u03bb \u27e8x, hx\u27e9, { principal := \u27e8x, trans (congr_arg _ hx) (coe_span_singleton x)\u27e9 } \u27e9\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 \u2194 y = 0 :=\n\u27e8\u03bb h, span_eq_bot.mp (by simpa using congr_arg subtype.val h : span R {y} = \u22a5) y (mem_singleton y),\n \u03bb h, by simp [h] \u27e9\n\nlemma span_singleton_ne_zero_iff {y : f.codomain} : span_singleton y \u2260 0 \u2194 y \u2260 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  (\u2191(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 \u27e8y', hy', rfl\u27e9,\n    obtain \u27e8x', rfl\u27e9 := submodule.mem_span_singleton.mp hy',\n    use x',\n    rw [smul_eq_mul, f.to_map.map_mul],\n    refl },\n  { rintros \u27e8y', rfl\u27e9,\n    exact \u27e8y' * x, submodule.mem_span_singleton.mpr \u27e8y', rfl\u27e9, f.to_map.map_mul _ _\u27e9 }\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 \u2200 (y : S), ring_hom.id _ y.1 \u2208 S, from \u03bb 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 \u27e8x', hx', rfl\u27e9 := mem_canonical_equiv_apply.mp h,\n    obtain \u27e8z, rfl\u27e9 := 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 \u27e8z, rfl\u27e9 := mem_span_singleton.mp h,\n    use f.to_map z * x,\n    use mem_span_singleton.mpr \u27e8z, rfl\u27e9,\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 \u2208 span_singleton x * I \u2194 \u2203 y' \u2208 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 \u27e8a, ha\u27e9 := mem_span_singleton.mp hx',\n      use [a \u2022 y', I.1.smul_mem a hy'],\n      rw [\u2190ha, algebra.mul_smul_comm, algebra.smul_mul_assoc] },\n    { exact \u27e80, I.1.zero_mem, (mul_zero x).symm\u27e9 },\n    { rintros _ _ \u27e8y, hy, rfl\u27e9 \u27e8y', hy', rfl\u27e9,\n      exact \u27e8y + y', I.1.add_mem hy hy', (mul_add _ _ _).symm\u27e9 },\n    { rintros r _ \u27e8y', hy', rfl\u27e9,\n      exact \u27e8r \u2022 y', I.1.smul_mem r hy', (algebra.mul_smul_comm _ _ _).symm \u27e9 } },\n  { rintros \u27e8y', hy', rfl\u27e9,\n    exact mul_mem_mul (mem_span_singleton.mpr \u27e81, one_smul _ _\u27e9) hy' }\nend\n\nlemma one_div_span_singleton (x : g.codomain) :\n  1 / span_singleton x = span_singleton (x\u207b\u00b9) :=\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\u207b\u00b9) * J :=\nbegin\n  rw \u2190 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 \u2260 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\u207b\u00b9 * (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  \u2203 (a : R\u2081) (aI : ideal R\u2081), a \u2260 0 \u2227 I = span_singleton (g.to_map a)\u207b\u00b9 * aI :=\nbegin\n  obtain \u27e8a_inv, nonzero, ha\u27e9 := 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 \u27e8x', hx'\u27e9 := ha x hx,\n    refine \u27e8g.to_map x', mem_coe_ideal.mpr \u27e8x', (mem_singleton_mul.mpr \u27e8x, hx, hx'\u27e9), rfl\u27e9, _\u27e9,\n    erw [hx', \u2190mul_assoc, inv_mul_cancel map_a_nonzero, one_mul] },\n  { rintros \u27e8y, hy, rfl\u27e9,\n    obtain \u27e8x', hx', rfl\u27e9 := mem_coe_ideal.mp hy,\n    obtain \u27e8y', hy', hx'\u27e9 := mem_singleton_mul.mp hx',\n    rw lin_coe_apply at hx',\n    erw [hx', \u2190mul_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 \u27e8a, aI, -, ha\u27e9 := exists_eq_span_singleton_mul I,\n  use (f.to_map a)\u207b\u00b9 * f.to_map (generator aI),\n  suffices : I = span_singleton ((f.to_map a)\u207b\u00b9 * f.to_map (generator aI)),\n  { exact congr_arg subtype.val this },\n  conv_lhs { rw [ha, \u2190span_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\u2081 : Type*} [integral_domain R\u2081]\nvariables {K : Type*} [field K] {g : fraction_map R\u2081 K}\n\nlocal attribute [instance] classical.prop_decidable\n\nlemma is_noetherian_zero : is_noetherian R\u2081 (0 : fractional_ideal g) :=\nis_noetherian_submodule.mpr (\u03bb I (hI : I \u2264 (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\u2081 I \u2194 \u2200 J \u2264 I, (J : submodule R\u2081 g.codomain).fg :=\nis_noetherian_submodule.trans \u27e8\u03bb h J hJ, h _ hJ, \u03bb h J hJ, h \u27e8J, is_fractional_of_le hJ\u27e9 hJ\u27e9\n\nlemma is_noetherian_coe_to_fractional_ideal [is_noetherian_ring R\u2081] (I : ideal R\u2081) :\n  is_noetherian R\u2081 (I : fractional_ideal g) :=\nbegin\n  rw is_noetherian_iff,\n  intros J hJ,\n  obtain \u27e8J, rfl\u27e9 := 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\u2081) {I : fractional_ideal g}\n  (hI : is_noetherian R\u2081 I) :\n  is_noetherian R\u2081 (span_singleton (g.to_map x)\u207b\u00b9 * 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 \u2260 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) \u2260 (0 : fractional_ideal g),\n    from span_singleton_ne_zero_iff.mpr h_gx,\n  rw is_noetherian_iff at \u22a2 hI,\n  intros J hJ,\n  rw [\u2190 div_span_singleton, le_div_iff_mul_le h_spanx] at hJ,\n  obtain \u27e8s, hs\u27e9 := hI _ hJ,\n  use s * {(g.to_map x)\u207b\u00b9},\n  rw [finset.coe_mul, finset.coe_singleton, \u2190 span_mul_span, hs, \u2190 coe_span_singleton, \u2190 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\u2081] (I : fractional_ideal g) : is_noetherian R\u2081 I :=\nbegin\n  obtain \u27e8d, J, h_nzd, rfl\u27e9 := 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 \u2228 I = 1 :=\nbegin\n  rw or_iff_not_imp_left,\n  intro hI,\n  simp only [\u2190 fractional_ideal.ext_iff, fractional_ideal.mem_one_iff],\n  intro x,\n  split,\n  { intro x_mem,\n    obtain \u27e8n, d, rfl\u27e9 := f.mk'_surjective x,\n    refine \u27e8n / d, _\u27e9,\n    rw [ring_hom.map_div, f.mk'_eq_div] },\n  { rintro \u27e8x, rfl\u27e9,\n    obtain \u27e8y, y_ne, y_mem\u27e9 := fractional_ideal.exists_ne_zero_mem_is_integer hI,\n    rw [\u2190 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\u2081)\n  (I : fractional_ideal g) : I = 0 \u2228 I = 1 :=\nby { letI : field R\u2081 := hF.to_field R\u2081, 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u2192 B` and a homeomorphism `h : Z' \u2243\u209c Z`, returns a local trivialization of the fiber bundle\n  `p \u2218 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 `\u2102` and as a\nvector bundle over `\u211d`, 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 {\u03b9 : Type*} {B : Type*} {F : Type*} {E : B \u2192 Type*}\nvariables (F) {Z : Type*} [topological_space B] [topological_space F] {proj : Z \u2192 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 \u2192 B) extends local_equiv Z (B \u00d7 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 \u207b\u00b9' base_set)\n(target_eq     : target = base_set \u00d7\u02e2 univ)\n(proj_to_fun   : \u2200 p \u2208 source, (to_fun p).1 = proj p)\n\nnamespace pretrivialization\n\ninstance : has_coe_to_fun (pretrivialization F proj) (\u03bb _, Z \u2192 (B \u00d7 F)) := \u27e8\u03bb e, e.to_fun\u27e9\n\nvariables {F} (e : pretrivialization F proj) {x : Z}\n\n@[simp, mfld_simps] lemma coe_coe : \u21d1e.to_local_equiv = e := rfl\n@[simp, mfld_simps] lemma coe_fst (ex : x \u2208 e.source) : (e x).1 = proj x := e.proj_to_fun x ex\nlemma mem_source : x \u2208 e.source \u2194 proj x \u2208 e.base_set := by rw [e.source_eq, mem_preimage]\nlemma coe_fst' (ex : proj x \u2208 e.base_set) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex)\nprotected lemma eq_on : eq_on (prod.fst \u2218 e) proj e.source := \u03bb x hx, e.coe_fst hx\nlemma mk_proj_snd (ex : x \u2208 e.source) : (proj x, (e x).2) = e x := prod.ext (e.coe_fst ex).symm rfl\nlemma mk_proj_snd' (ex : proj x \u2208 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 \u2192 Z := e.target.restrict e.to_local_equiv.symm\n\nlemma mem_target {x : B \u00d7 F} : x \u2208 e.target \u2194 x.1 \u2208 e.base_set :=\nby rw [e.target_eq, prod_univ, mem_preimage]\n\nlemma proj_symm_apply {x : B \u00d7 F} (hx : x \u2208 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 [\u2190 e.coe_coe, e.to_local_equiv.right_inv hx] at this\nend\n\nlemma proj_symm_apply' {b : B} {x : F} (hx : b \u2208 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\u03bb b hb, let \u27e8y\u27e9 := \u2039nonempty F\u203a in \u27e8e.to_local_equiv.symm (b, y),\n  e.to_local_equiv.map_target $ e.mem_target.2 hb, e.proj_symm_apply' hb\u27e9\n\nlemma apply_symm_apply {x : B \u00d7 F} (hx : x \u2208 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 \u2208 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 \u2208 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 \u2208 e.source) :\n  e.to_local_equiv.symm (proj x, (e x).2) = x :=\nby rw [\u2190 e.coe_fst ex, prod.mk.eta, \u2190 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 \u207b\u00b9' (proj \u207b\u00b9' e.base_set)) \u2229 e.target  = e.target :=\nbegin\n  refine inter_eq_right_iff_subset.mpr (\u03bb 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 \u207b\u00b9' (proj \u207b\u00b9' s)) \u2229 e.base_set \u00d7\u02e2 univ = (s \u2229 e.base_set) \u00d7\u02e2 univ :=\nbegin\n  ext \u27e8x, y\u27e9,\n  suffices : x \u2208 e.base_set \u2192 (proj (e.to_local_equiv.symm (x, y)) \u2208 s \u2194 x \u2208 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 \u2229 (f.to_local_equiv.symm) \u207b\u00b9' e.source = (e.base_set \u2229 f.base_set) \u00d7\u02e2 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 \u2229 f.base_set) \u00d7\u02e2 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 \u2229 e'.base_set) \u00d7\u02e2 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 \u2229 e'.base_set) \u00d7\u02e2 univ :=\nby rw [\u2190 local_equiv.symm_source, symm_trans_symm, symm_trans_source_eq, inter_comm]\n\nvariables {B F} (e' : pretrivialization F (\u03c0 E)) {x' : total_space E} {b : B} {y : E b}\n\nlemma coe_mem_source : \u2191y \u2208 e'.source \u2194 b \u2208 e'.base_set := e'.mem_source\n\n@[simp, mfld_simps] \n\nlemma mk_mem_target {x : B} {y : F} : (x, y) \u2208 e'.target \u2194 x \u2208 e'.base_set :=\ne'.mem_target\n\nlemma symm_coe_proj {x : B} {y : F} (e' : pretrivialization F (\u03c0 E)) (h : x \u2208 e'.base_set) :\n  (e'.to_local_equiv.symm (x, y)).1 = x :=\ne'.proj_symm_apply' h\n\nsection has_zero\nvariables [\u2200 x, has_zero (E x)]\n\n/-- A fiberwise inverse to `e`. This is the function `F \u2192 E b` that induces a local inverse\n`B \u00d7 F \u2192 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 (\u03c0 E)) (b : B) (y : F) : E b :=\nif hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2209 e.base_set) (y : F) :\n  e.symm b y = 0 :=\ndif_neg hb\n\nlemma coe_symm_of_not_mem (e : pretrivialization F (\u03c0 E)) {b : B} (hb : b \u2209 e.base_set) :\n  (e.symm b : F \u2192 E b) = 0 :=\nfunext $ \u03bb y, dif_neg hb\n\nlemma mk_symm (e : pretrivialization F (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) (z : total_space E)\n  (hz : z.proj \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 \u2192 B` with fiber `F`, as a local homeomorphism between `Z` and `B \u00d7 F` defined between two\nsets of the form `proj \u207b\u00b9' base_set` and `base_set \u00d7 F`, acting trivially on the first coordinate.\n-/\n@[ext, nolint has_nonempty_instance]\nstructure trivialization (proj : Z \u2192 B)\n  extends local_homeomorph Z (B \u00d7 F) :=\n(base_set      : set B)\n(open_base_set : is_open base_set)\n(source_eq     : source = proj \u207b\u00b9' base_set)\n(target_eq     : target = base_set \u00d7\u02e2 univ)\n(proj_to_fun   : \u2200 p \u2208 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) (\u03bb _, Z \u2192 B \u00d7 F) := \u27e8\u03bb e, e.to_fun\u27e9\ninstance : has_coe (trivialization F proj) (pretrivialization F proj) :=\n\u27e8to_pretrivialization\u27e9\n\nlemma to_pretrivialization_injective :\n  function.injective (\u03bb e : trivialization F proj, e.to_pretrivialization) :=\nby { intros e e', rw [pretrivialization.ext_iff, trivialization.ext_iff,\n  \u2190 local_homeomorph.to_local_equiv_injective.eq_iff], exact id }\n\n@[simp, mfld_simps] lemma coe_coe : \u21d1e.to_local_homeomorph = e := rfl\n@[simp, mfld_simps] lemma coe_fst (ex : x \u2208 e.source) : (e x).1 = proj x := e.proj_to_fun x ex\nprotected lemma eq_on : eq_on (prod.fst \u2218 e) proj e.source := \u03bb x hx, e.coe_fst hx\nlemma mem_source : x \u2208 e.source \u2194 proj x \u2208 e.base_set := by rw [e.source_eq, mem_preimage]\nlemma coe_fst' (ex : proj x \u2208 e.base_set) : (e x).1 = proj x := e.coe_fst (e.mem_source.2 ex)\nlemma mk_proj_snd (ex : x \u2208 e.source) : (proj x, (e x).2) = e x := prod.ext (e.coe_fst ex).symm rfl\nlemma mk_proj_snd' (ex : proj x \u2208 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 \u00d7 F)) :\n  e.source \u2229 (e \u207b\u00b9' (e.target \u2229 s)) = e.source \u2229 (e \u207b\u00b9' s) :=\ne.to_local_homeomorph.source_inter_preimage_target_inter s\n\n@[simp, mfld_simps] lemma coe_mk (e : local_homeomorph Z (B \u00d7 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 \u00d7 F} : x \u2208 e.target \u2194 x.1 \u2208 e.base_set :=\ne.to_pretrivialization.mem_target\n\nlemma map_target {x : B \u00d7 F} (hx : x \u2208 e.target) : e.to_local_homeomorph.symm x \u2208 e.source :=\ne.to_local_homeomorph.map_target hx\n\nlemma proj_symm_apply {x : B \u00d7 F} (hx : x \u2208 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 \u2208 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 \u00d7 F} (hx : x \u2208 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 \u2208 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 \u2208 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 \u2229 e'.base_set) \u00d7\u02e2 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 \u2229 e'.base_set) \u00d7\u02e2 univ :=\npretrivialization.symm_trans_target_eq e.to_pretrivialization e'\n\nlemma coe_fst_eventually_eq_proj (ex : x \u2208 e.source) : prod.fst \u2218 e =\u1da0[\ud835\udcdd x] proj  :=\nmem_nhds_iff.2 \u27e8e.source, \u03bb y hy, e.coe_fst hy, e.open_source, ex\u27e9\n\nlemma coe_fst_eventually_eq_proj' (ex : proj x \u2208 e.base_set) : prod.fst \u2218 e =\u1da0[\ud835\udcdd x] proj :=\ne.coe_fst_eventually_eq_proj (e.mem_source.2 ex)\n\nlemma map_proj_nhds (ex : x \u2208 e.source) : map proj (\ud835\udcdd x) = \ud835\udcdd (proj x) :=\nby rw [\u2190 e.coe_fst ex, \u2190 map_congr (e.coe_fst_eventually_eq_proj ex), \u2190 map_map, \u2190 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 \u2286 e.base_set) : proj \u207b\u00b9' s \u2286 e.source :=\n\u03bb p hp, e.mem_source.mpr (hb hp)\n\nlemma image_preimage_eq_prod_univ {s : set B} (hb : s \u2286 e.base_set) :\n  e '' (proj \u207b\u00b9' s) = s \u00d7\u02e2 univ :=\nsubset.antisymm (image_subset_iff.mpr (\u03bb p hp,\n  \u27e8(e.proj_to_fun p (e.preimage_subset_source hb hp)).symm \u25b8 hp, trivial\u27e9)) (\u03bb p hp,\n  let hp' : p \u2208 e.target := e.mem_target.mpr (hb hp.1) in\n  \u27e8e.inv_fun p, mem_preimage.mpr ((e.proj_symm_apply hp').symm \u25b8 hp.1), e.apply_symm_apply hp'\u27e9)\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 \u2286 e.base_set) : proj \u207b\u00b9' s \u2243\u209c s \u00d7 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 \u2286 e.base_set) (p : proj \u207b\u00b9' s) :\n  e.preimage_homeomorph hb p = (\u27e8proj p, p.2\u27e9, (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 \u2286 e.base_set) (p : s \u00d7 F) :\n  (e.preimage_homeomorph hb).symm p = \u27e8e.symm (p.1, p.2), ((e.preimage_homeomorph hb).symm p).2\u27e9 :=\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 \u2243\u209c e.base_set \u00d7 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 = (\u27e8proj p, e.mem_source.mp p.2\u27e9, (e p).2) :=\ne.preimage_homeomorph_apply subset_rfl \u27e8p, e.mem_source.mp p.2\u27e9\n\n@[simp] lemma source_homeomorph_base_set_prod_symm_apply (p : e.base_set \u00d7 F) :\n  e.source_homeomorph_base_set_prod.symm p =\n    \u27e8e.symm (p.1, p.2), (e.source_homeomorph_base_set_prod.symm p).2\u27e9 :=\nrfl\n\n/-- Each fiber of a trivialization is homeomorphic to the specified fiber. -/\ndef preimage_singleton_homeomorph {b : B} (hb : b \u2208 e.base_set) : proj \u207b\u00b9' {b} \u2243\u209c 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 \u2208 e.base_set)\n  (p : proj \u207b\u00b9' {b}) : e.preimage_singleton_homeomorph hb p = (e p).2 :=\nrfl\n\n@[simp] lemma preimage_singleton_homeomorph_symm_apply {b : B} (hb : b \u2208 e.base_set) (p : F) :\n  (e.preimage_singleton_homeomorph hb).symm p =\n    \u27e8e.symm (b, p), by rw [mem_preimage, e.proj_symm_apply' hb, mem_singleton_iff]\u27e9 :=\nrfl\n\n/-- In the domain of a bundle trivialization, the projection is continuous-/\nlemma continuous_at_proj (ex : x \u2208 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' \u2243\u209c Z) :\n  trivialization F (proj \u2218 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 := \u03bb p hp,\n    have hp : h p \u2208 e.source, by simpa using hp,\n    by simp [hp] }\n\n/-- Read off the continuity of a function `f : Z \u2192 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 \u2192 X} {z : Z}\n  (e : trivialization F proj) (he : proj z \u2208 e.base_set)\n  (hf : continuous_at (f \u2218 e.to_local_equiv.symm) (e z)) :\n  continuous_at f z :=\nbegin\n  have hez : z \u2208 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 \u2192 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 \u2192 Z} {x : X}\n  (e : trivialization F proj) (hf_proj : continuous_at (proj \u2218 f) x) (he : proj (f x) \u2208 e.base_set)\n  (hf : continuous_at (e \u2218 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, \u2190 preimage_comp],\n  exact hf_proj.preimage_mem_nhds (e.open_base_set.mem_nhds he),\nend\n\nvariables {E} (e' : trivialization F (\u03c0 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 : \u2191y \u2208 e'.source \u2194 b \u2208 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 \u2208 e'.base_set) : (e' y).1 = b :=\ne'.coe_fst (e'.mem_source.2 hb)\n\nlemma mk_mem_target {y : F} : (b, y) \u2208 e'.target \u2194 b \u2208 e'.base_set :=\ne'.to_pretrivialization.mem_target\n\nlemma symm_apply_apply {x : total_space E} (hx : x \u2208 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 (\u03c0 E)) (h : x \u2208 e.base_set) :\n  (e.to_local_homeomorph.symm (x, y)).1 = x := e.proj_symm_apply' h\n\nsection has_zero\nvariables [\u2200 x, has_zero (E x)]\n\n/-- A fiberwise inverse to `e'`. The function `F \u2192 E x` that induces a local inverse\n`B \u00d7 F \u2192 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 (\u03c0 E)) (b : B) (y : F) : E b :=\ne.to_pretrivialization.symm b y\n\nlemma symm_apply (e : trivialization F (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2209 e.base_set) (y : F) :\n  e.symm b y = 0 :=\ndif_neg hb\n\nlemma mk_symm (e : trivialization F (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) (z : total_space E)\n  (hz : z.proj \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) :\n  continuous_on (\u03bb z : B \u00d7 F, total_space_mk z.1 (e.symm z.1 z.2)) (e.base_set \u00d7\u02e2 univ) :=\nbegin\n  have : \u2200 (z : B \u00d7 F) (hz : z \u2208 e.base_set \u00d7\u02e2 (univ : set F)),\n    total_space_mk z.1 (e.symm z.1 z.2) = e.to_local_homeomorph.symm z,\n  { rintro x \u27e8hx : x.1 \u2208 e.base_set, _\u27e9, simp_rw [e.mk_symm hx, prod.mk.eta] },\n  refine continuous_on.congr _ this,\n  rw [\u2190 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 \u2192 B` with fiber `F` and `h` is a homeomorphism\n`F \u2243\u209c 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 \u2243\u209c 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 \u2243\u209c 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 \u2243\u209c F`. -/\ndef coord_change (e\u2081 e\u2082 : trivialization F proj) (b : B) (x : F) : F :=\n(e\u2082 $ e\u2081.to_local_homeomorph.symm (b, x)).2\n\nlemma mk_coord_change\n  (e\u2081 e\u2082 : trivialization F proj) {b : B}\n  (h\u2081 : b \u2208 e\u2081.base_set) (h\u2082 : b \u2208 e\u2082.base_set) (x : F) :\n  (b, e\u2081.coord_change e\u2082 b x) = e\u2082 (e\u2081.to_local_homeomorph.symm (b, x)) :=\nbegin\n  refine prod.ext _ rfl,\n  rw [e\u2082.coe_fst', \u2190 e\u2081.coe_fst', e\u2081.apply_symm_apply' h\u2081],\n  { rwa [e\u2081.proj_symm_apply' h\u2081] },\n  { rwa [e\u2081.proj_symm_apply' h\u2081] }\nend\n\nlemma coord_change_apply_snd\n  (e\u2081 e\u2082 : trivialization F proj) {p : Z}\n  (h : proj p \u2208 e\u2081.base_set) :\n  e\u2081.coord_change e\u2082 (proj p) (e\u2081 p).snd = (e\u2082 p).snd :=\nby rw [coord_change, e\u2081.symm_apply_mk_proj (e\u2081.mem_source.2 h)]\n\nlemma coord_change_same_apply\n  (e : trivialization F proj) {b : B} (h : b \u2208 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 \u2208 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\u2081 e\u2082 e\u2083 : trivialization F proj) {b : B}\n  (h\u2081 : b \u2208 e\u2081.base_set) (h\u2082 : b \u2208 e\u2082.base_set) (x : F) :\n  e\u2082.coord_change e\u2083 b (e\u2081.coord_change e\u2082 b x) = e\u2081.coord_change e\u2083 b x :=\nbegin\n  rw [coord_change, e\u2081.mk_coord_change _ h\u2081 h\u2082, \u2190 e\u2082.coe_coe,\n    e\u2082.to_local_homeomorph.left_inv, coord_change],\n  rwa [e\u2082.mem_source, e\u2081.proj_symm_apply' h\u2081]\nend\n\nlemma continuous_coord_change (e\u2081 e\u2082 : trivialization F proj) {b : B}\n  (h\u2081 : b \u2208 e\u2081.base_set) (h\u2082 : b \u2208 e\u2082.base_set) :\n  continuous (e\u2081.coord_change e\u2082 b) :=\nbegin\n  refine continuous_snd.comp (e\u2082.to_local_homeomorph.continuous_on.comp_continuous\n    (e\u2081.to_local_homeomorph.continuous_on_symm.comp_continuous _ _) _),\n  { exact continuous_const.prod_mk continuous_id },\n  { exact \u03bb x, e\u2081.mem_target.2 h\u2081 },\n  { intro x,\n    rwa [e\u2082.mem_source, e\u2081.proj_symm_apply' h\u2081] }\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\u2081 e\u2082 : trivialization F proj) {b : B} (h\u2081 : b \u2208 e\u2081.base_set) (h\u2082 : b \u2208 e\u2082.base_set) :\n  F \u2243\u209c F :=\n{ to_fun := e\u2081.coord_change e\u2082 b,\n  inv_fun := e\u2082.coord_change e\u2081 b,\n  left_inv := \u03bb x, by simp only [*, coord_change_coord_change, coord_change_same_apply],\n  right_inv := \u03bb x, by simp only [*, coord_change_coord_change, coord_change_same_apply],\n  continuous_to_fun := e\u2081.continuous_coord_change e\u2082 h\u2081 h\u2082,\n  continuous_inv_fun := e\u2082.continuous_coord_change e\u2081 h\u2082 h\u2081 }\n\n@[simp] lemma coord_change_homeomorph_coe\n  (e\u2081 e\u2082 : trivialization F proj) {b : B} (h\u2081 : b \u2208 e\u2081.base_set) (h\u2082 : b \u2208 e\u2082.base_set) :\n  \u21d1(e\u2081.coord_change_homeomorph e\u2082 h\u2081 h\u2082) = e\u2081.coord_change e\u2082 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 \u207b\u00b9' s) (s \u00d7\u02e2 univ) :=\n\u03bb 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 \u2229 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 := \u03bb 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 \u2229 frontier (proj \u207b\u00b9' s) = proj \u207b\u00b9' (e.base_set \u2229 frontier s) :=\nby rw [\u2190 (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 \u2192 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 \u2208 e.base_set \u2229 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 \u207b\u00b9 s` and is equal to `e'`\notherwise. -/\nnoncomputable def piecewise (e e' : trivialization F proj) (s : set B)\n  (Hs : e.base_set \u2229 frontier s = e'.base_set \u2229 frontier s)\n  (Heq : eq_on e e' $ proj \u207b\u00b9' (e.base_set \u2229 frontier s)) :\n  trivialization F proj :=\n{ to_local_homeomorph := e.to_local_homeomorph.piecewise e'.to_local_homeomorph\n    (proj \u207b\u00b9' s) (s \u00d7\u02e2 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 (\u27e8he, hs\u27e9|\u27e8he, hs\u27e9); simp * }\n\n/-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z \u2192 B`\nover a linearly ordered base `B` and a point `a \u2208 e.base_set \u2229 e'.base_set` such that\n`e` equals `e'` on `proj \u207b\u00b9' {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 \u2264 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 \u2208 e.base_set) (He' : a \u2208 e'.base_set)\n  (Heq : \u2200 p, proj p = a \u2192 e p = e' p) :\n  trivialization F proj :=\ne.piecewise e' (Iic a)\n  (set.ext $ \u03bb x, and.congr_left_iff.2 $ \u03bb hx,\n    by simp [He, He', mem_singleton_iff.1 (frontier_Iic_subset _ hx)])\n  (\u03bb p hp, Heq p $ frontier_Iic_subset _ hp.2)\n\n/-- Given two bundle trivializations `e`, `e'` of a topological fiber bundle `proj : Z \u2192 B` over a\nlinearly ordered base `B` and a point `a \u2208 e.base_set \u2229 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 \u2264 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 \u2208 e.base_set) (He' : a \u2208 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 \u27e8hx.1.1, hx.2.1\u27e9 }),\n  base_set := e.base_set \u222a e'.base_set,\n  open_base_set := is_open.union e.open_base_set e'.open_base_set,\n  source_eq := congr_arg2 (\u222a) e.source_eq e'.source_eq,\n  target_eq := (congr_arg2 (\u222a) 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' \u22a2,\n        exact \u03bb h, H.le_bot \u27e8h, hp'\u27e9 }\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 (\u03b1\u2080,..,\u03b1\u2099)`, we take the least fixed point of `F` with\nregards to its last argument `\u03b1\u2099`. The result is a `n`-ary functor: `fix F (\u03b1\u2080,..,\u03b1\u2099\u208b\u2081)`.\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 \u03b1`\n\n## Implementation notes\n\nFor `F` a QPF, we define `cofix F \u03b1` 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 \u03b1`.\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 : \u2115} {F : TypeVec.{u} (n + 1) \u2192 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 \u03b1`. `corecF`\nuses corecursion to construct the M-type generated by `q.P` and uses function on `F`\nas a corecursive step -/\ndef corecF {\u03b1 : TypeVec n} {\u03b2 : Type _} (g : \u03b2 \u2192 F (\u03b1.append1 \u03b2)) : \u03b2 \u2192 q.p.M \u03b1 :=\n  M.corec _ fun x => repr (g x)\n#align mvqpf.corecF MvQPF.corecF\n\ntheorem corecF_eq {\u03b1 : TypeVec n} {\u03b2 : Type _} (g : \u03b2 \u2192 F (\u03b1.append1 \u03b2)) (x : \u03b2) :\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 {\u03b1 : TypeVec n} (r : q.p.M \u03b1 \u2192 q.p.M \u03b1 \u2192 Prop) : Prop :=\n  \u2200 \u2983x y\u2984,\n    r x y \u2192\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 {\u03b1 : TypeVec n} (x y : q.p.M \u03b1) : Prop :=\n  \u2203 r, IsPrecongr r \u2227 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) \u2192 Type u) [MvFunctor F] [q : MvQPF F] (\u03b1 : TypeVec n) :=\n  Quot (@Mcongr _ F _ q \u03b1)\n#align mvqpf.cofix MvQPF.Cofix\n\ninstance {\u03b1 : TypeVec n} [Inhabited q.p.A] [\u2200 i : Fin2 n, Inhabited (\u03b1 i)] :\n    Inhabited (Cofix F \u03b1) :=\n  \u27e8Quot.mk _ default\u27e9\n\n/-- maps every element of the W type to a canonical representative -/\ndef mrepr {\u03b1 : TypeVec n} : q.p.M \u03b1 \u2192 q.p.M \u03b1 :=\n  corecF (abs \u2218 M.dest q.p)\n#align mvqpf.Mrepr MvQPF.mrepr\n\n/-- the map function for the functor `cofix F` -/\ndef Cofix.map {\u03b1 \u03b2 : TypeVec n} (g : \u03b1 \u27f9 \u03b2) : Cofix F \u03b1 \u2192 Cofix F \u03b2 :=\n  Quot.lift (fun x : q.p.M \u03b1 => Quot.mk Mcongr (g <$$> x))\n    (by\n      rintro aa\u2081 aa\u2082 \u27e8r, pr, ra\u2081a\u2082\u27e9; apply Quot.sound\n      let r' b\u2081 b\u2082 := \u2203 a\u2081 a\u2082 : q.P.M \u03b1, r a\u2081 a\u2082 \u2227 b\u2081 = g <$$> a\u2081 \u2227 b\u2082 = g <$$> a\u2082\n      use r'; constructor\n      \u00b7 show is_precongr r'\n        rintro b\u2081 b\u2082 \u27e8a\u2081, a\u2082, ra\u2081a\u2082, b\u2081eq, b\u2082eq\u27e9\n        let u : Quot r \u2192 Quot r' :=\n          Quot.lift (fun x : q.P.M \u03b1 => Quot.mk r' (g <$$> x))\n            (by\n              intro a\u2081 a\u2082 ra\u2081a\u2082\n              apply Quot.sound\n              exact \u27e8a\u2081, a\u2082, ra\u2081a\u2082, rfl, rfl\u27e9)\n        have hu : (Quot.mk r' \u2218 fun x : q.P.M \u03b1 => g <$$> x) = u \u2218 Quot.mk r :=\n          by\n          ext x\n          rfl\n        rw [b\u2081eq, b\u2082eq, M.dest_map, M.dest_map, \u2190 q.P.comp_map, \u2190 q.P.comp_map]\n        rw [\u2190 append_fun_comp, id_comp, hu, hu, \u2190 comp_id g, append_fun_comp]\n        rw [q.P.comp_map, q.P.comp_map, abs_map, pr ra\u2081a\u2082, \u2190 abs_map]\n      show r' (g <$$> aa\u2081) (g <$$> aa\u2082); exact \u27e8aa\u2081, aa\u2082, ra\u2081a\u2082, rfl, rfl\u27e9)\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 {\u03b1 : TypeVec n} {\u03b2 : Type u} (g : \u03b2 \u2192 F (\u03b1.append1 \u03b2)) : \u03b2 \u2192 Cofix F \u03b1 := 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 {\u03b1 : TypeVec n} : Cofix F \u03b1 \u2192 F (\u03b1.append1 (Cofix F \u03b1)) :=\n  Quot.lift (fun x => appendFun id (Quot.mk Mcongr) <$$> abs (M.dest q.p x))\n    (by\n      rintro x y \u27e8r, pr, rxy\u27e9\n      dsimp\n      have : \u2200 x y, r x y \u2192 Mcongr x y := by\n        intro x y h\n        exact \u27e8r, pr, h\u27e9\n      rw [\u2190 Quot.factor_mk_eq _ _ this]\n      dsimp\n      conv =>\n        lhs\n        rw [append_fun_comp_id, comp_map, \u2190 abs_map, pr rxy, abs_map, \u2190 comp_map, \u2190\n          append_fun_comp_id])\n#align mvqpf.cofix.dest MvQPF.Cofix.dest\n\n/-- Abstraction function for `cofix F \u03b1` -/\ndef Cofix.abs {\u03b1} : q.p.M \u03b1 \u2192 Cofix F \u03b1 :=\n  Quot.mk _\n#align mvqpf.cofix.abs MvQPF.Cofix.abs\n\n/-- Representation function for `cofix F \u03b1` -/\ndef Cofix.repr {\u03b1} : Cofix F \u03b1 \u2192 q.p.M \u03b1 :=\n  M.corec _ <| repr \u2218 Cofix.dest\n#align mvqpf.cofix.repr MvQPF.Cofix.repr\n\n/-- Corecursor for `cofix F` -/\ndef Cofix.corec'\u2081 {\u03b1 : TypeVec n} {\u03b2 : Type u} (g : \u2200 {X}, (\u03b2 \u2192 X) \u2192 F (\u03b1.append1 X)) (x : \u03b2) :\n    Cofix F \u03b1 :=\n  Cofix.corec (fun x => g id) x\n#align mvqpf.cofix.corec'\u2081 MvQPF.Cofix.corec'\u2081\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' {\u03b1 : TypeVec n} {\u03b2 : Type u} (g : \u03b2 \u2192 F (\u03b1.append1 (Sum (Cofix F \u03b1) \u03b2))) (x : \u03b2) :\n    Cofix F \u03b1 :=\n  let f : (\u03b1 ::: Cofix F \u03b1) \u27f9 (\u03b1 ::: Sum (Cofix F \u03b1) \u03b2) := id ::: Sum.inl\n  Cofix.corec (Sum.elim (MvFunctor.map f \u2218 Cofix.dest) g) (Sum.inr x : Sum (Cofix F \u03b1) \u03b2)\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\u2081 {\u03b1 : TypeVec n} {\u03b2 : Type u}\n    (g : \u2200 {X}, (Cofix F \u03b1 \u2192 X) \u2192 (\u03b2 \u2192 X) \u2192 \u03b2 \u2192 F (\u03b1 ::: X)) (x : \u03b2) : Cofix F \u03b1 :=\n  Cofix.corec' (fun x => g Sum.inl Sum.inr x) x\n#align mvqpf.cofix.corec\u2081 MvQPF.Cofix.corec\u2081\n\ntheorem Cofix.dest_corec {\u03b1 : TypeVec n} {\u03b2 : Type u} (g : \u03b2 \u2192 F (\u03b1.append1 \u03b2)) (x : \u03b2) :\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, \u2190 comp_map, \u2190 append_fun_comp]; rfl\n#align mvqpf.cofix.dest_corec MvQPF.Cofix.dest_corec\n\n/-- constructor for `cofix F` -/\ndef Cofix.mk {\u03b1 : TypeVec n} : F (\u03b1.append1 <| Cofix F \u03b1) \u2192 Cofix F \u03b1 :=\n  Cofix.corec fun x => (appendFun id fun i : Cofix F \u03b1 => 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 \u03b1`.\n\nA bisimulation relation `R` for values `x y : cofix F \u03b1`:\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 {\u03b1 : TypeVec n} (r : Cofix F \u03b1 \u2192 Cofix F \u03b1 \u2192 Prop) (h' : \u2200 x, r x x)\n    (h :\n      \u2200 x y,\n        r x y \u2192\n          appendFun id (Quot.mk r) <$$> Cofix.dest x = appendFun id (Quot.mk r) <$$> Cofix.dest y) :\n    \u2200 x y, r x y \u2192 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\u2080 :\n      append_fun id (Quot.mk r \u2218 Quot.mk Mcongr) <$$> abs (M.dest q.P a) =\n        append_fun id (Quot.mk r \u2218 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\u2081 : \u2200 u v : q.P.M \u03b1, Mcongr u v \u2192 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 \u2192 Quot r' :=\n      Quot.lift (Quot.lift (Quot.mk r') h\u2081)\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 \u2218 Quot.mk r \u2218 Quot.mk Mcongr = Quot.mk r' := rfl\n    rw [\u2190 this, append_fun_comp_id, q.P.comp_map, q.P.comp_map, abs_map, abs_map, abs_map, abs_map,\n      h\u2080]\n  refine' \u27e8r', this, rxy\u27e9\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 {\u03b1 : TypeVec n} (r : Cofix F \u03b1 \u2192 Cofix F \u03b1 \u2192 Prop)\n    (h :\n      \u2200 x y,\n        r x y \u2192\n          appendFun id (Quot.mk r) <$$> Cofix.dest x = appendFun id (Quot.mk r) <$$> Cofix.dest y) :\n    \u2200 x y, r x y \u2192 x = y := by\n  let r' (x y) := x = y \u2228 r x y\n  intro x y rxy\n  apply cofix.bisim_aux r'\n  \u00b7 intro x\n    left\n    rfl\n  \u00b7 intro x y r'xy\n    cases r'xy\n    \u00b7 rw [r'xy]\n    have : \u2200 x y, r x y \u2192 r' x y := fun x y h => Or.inr h\n    rw [\u2190 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 {\u03b1 : TypeVec n} (r : Cofix F \u03b1 \u2192 Cofix F \u03b1 \u2192 Prop)\n    (h : \u2200 x y, r x y \u2192 LiftR (RelLast \u03b1 r) (Cofix.dest x) (Cofix.dest y)) : \u2200 x y, r x y \u2192 x = y :=\n  by\n  apply cofix.bisim_rel\n  intro x y rxy\n  rcases(liftr_iff (rel_last \u03b1 r) _ _).mp (h x y rxy) with \u27e8a, f\u2080, f\u2081, dxeq, dyeq, h'\u27e9\n  rw [dxeq, dyeq, \u2190 abs_map, \u2190 abs_map, MvPFunctor.map_eq, MvPFunctor.map_eq]\n  rw [\u2190 split_drop_fun_last_fun f\u2080, \u2190 split_drop_fun_last_fun f\u2081]\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  \u00b7 apply Quot.sound\n    apply h' _ j\n  \u00b7 change f\u2080 _ j = f\u2081 _ 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\u2082 {\u03b1 : TypeVec n} (r : Cofix F \u03b1 \u2192 Cofix F \u03b1 \u2192 Prop)\n    (h : \u2200 x y, r x y \u2192 LiftR' (RelLast' \u03b1 r) (Cofix.dest x) (Cofix.dest y)) :\n    \u2200 x y, r x y \u2192 x = y :=\n  Cofix.bisim _ <| by intros <;> rw [\u2190 liftr_last_rel_iff] <;> apply h <;> assumption\n#align mvqpf.cofix.bisim\u2082 MvQPF.Cofix.bisim\u2082\n\n/-- Bisimulation principle the values `\u27e8a,f\u27e9` of the polynomial functor representing\n`cofix F \u03b1` as well as an invariant `Q : \u03b2 \u2192 Prop` and a state `\u03b2` generating the\nleft-hand side and right-hand side of the equality through functions `u v : \u03b2 \u2192 cofix F \u03b1` -/\ntheorem Cofix.bisim' {\u03b1 : TypeVec n} {\u03b2 : Type _} (Q : \u03b2 \u2192 Prop) (u v : \u03b2 \u2192 Cofix F \u03b1)\n    (h :\n      \u2200 x,\n        Q x \u2192\n          \u2203 a f' f\u2080 f\u2081,\n            Cofix.dest (u x) = abs \u27e8a, q.p.appendContents f' f\u2080\u27e9 \u2227\n              Cofix.dest (v x) = abs \u27e8a, q.p.appendContents f' f\u2081\u27e9 \u2227\n                \u2200 i, \u2203 x', Q x' \u2227 f\u2080 i = u x' \u2227 f\u2081 i = v x') :\n    \u2200 x, Q x \u2192 u x = v x := fun x Qx =>\n  let R := fun w z : Cofix F \u03b1 => \u2203 x', Q x' \u2227 w = u x' \u2227 z = v x'\n  Cofix.bisim R\n    (fun x y \u27e8x', Qx', xeq, yeq\u27e9 =>\n      by\n      rcases h x' Qx' with \u27e8a, f', f\u2080, f\u2081, ux'eq, vx'eq, h'\u27e9\n      rw [liftr_iff]\n      refine'\n        \u27e8a, q.P.append_contents f' f\u2080, q.P.append_contents f' f\u2081, xeq.symm \u25b8 ux'eq,\n          yeq.symm \u25b8 vx'eq, _\u27e9\n      intro i; cases i\n      \u00b7 apply h'\n      \u00b7 intro j\n        apply Eq.refl)\n    _ _ \u27e8x, Qx, rfl, rfl\u27e9\n#align mvqpf.cofix.bisim' MvQPF.Cofix.bisim'\n\ntheorem Cofix.mk_dest {\u03b1 : TypeVec n} (x : Cofix F \u03b1) : Cofix.mk (Cofix.dest x) = x :=\n  by\n  apply cofix.bisim_rel (fun x y : cofix F \u03b1 => 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 [\u2190 comp_map, \u2190 append_fun_comp, id_comp]\n  rw [\u2190 comp_map, \u2190 append_fun_comp, id_comp, \u2190 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 {\u03b1 : TypeVec n} (x : F (\u03b1.append1 <| Cofix F \u03b1)) :\n    Cofix.dest (Cofix.mk x) = x :=\n  by\n  have : cofix.mk \u2218 cofix.dest = @_root_.id (cofix F \u03b1) := funext cofix.mk_dest\n  rw [cofix.mk, cofix.dest_corec, \u2190 comp_map, \u2190 cofix.mk, \u2190 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 {\u03b1 : TypeVec n} (x y : Cofix F \u03b1) (h : x.dest = y.dest) : x = y := by\n  rw [\u2190 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 {\u03b1 : TypeVec n} (x y : F (\u03b1 ::: Cofix F \u03b1)) (h : Cofix.mk x = Cofix.mk y) :\n    x = y := by rw [\u2190 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 {\u03b1 \u03b2 : TypeVec n} {F' : TypeVec n \u2192 Type u} [MvFunctor F'] [LawfulMvFunctor F']\n    (R : \u03b2 \u2297 \u03b2 \u27f9 repeat n Prop) (x : F' \u03b1) (f g : \u03b1 \u27f9 \u03b2) (h : \u03b1 \u27f9 Subtype_ R)\n    (hh : subtypeVal _ \u229a h = (f \u2297' g) \u229a 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, \u2190 comp_assoc, fst_prod_mk, comp_assoc, fst_diag]\n  rw [MvFunctor.map_map, comp_assoc, hh, \u2190 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] {\u03b1 : TypeVec n} {\u03b9 \u03b9'} (R : \u03b9' \u2192 \u03b9' \u2192 Prop)\n    (x : F (\u03b1 ::: \u03b9)) (f g : \u03b9 \u2192 \u03b9') (hh : \u2200 x : \u03b9, R (f x) (g x)) :\n    LiftR' (RelLast' _ R) ((id ::: f) <$$> x) ((id ::: g) <$$> x) :=\n  let h : \u03b9 \u2192 { x : \u03b9' \u00d7 \u03b9' // uncurry R x } := fun x => \u27e8(f x, g x), hh x\u27e9\n  let b : (\u03b1 ::: \u03b9) \u27f9 _ := @diagSub n \u03b1 ::: h\n  let c :\n    (Subtype_ \u03b1.repeatEq ::: { x // uncurry R x }) \u27f9\n      ((fun i : Fin2 n => { x // ofRepeat (\u03b1.RelLast' R i.fs x) }) ::: Subtype (uncurry R)) :=\n    ofSubtype _ ::: id\n  have hh :\n    subtypeVal _ \u229a toSubtype _ \u229a fromAppend1DropLast \u229a c \u229a b =\n      ((id ::: f) \u2297' (id ::: g)) \u229a prod.diag :=\n    by\n    dsimp [c, b]\n    apply eq_of_drop_last_eq\n    \u00b7 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 _ \u229a fromAppend1DropLast \u229a c \u229a 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] {\u03b1 : TypeVec n} {\u03b9} (R : \u03b9 \u2192 \u03b9 \u2192 Prop) (x : F (\u03b1 ::: \u03b9))\n    (f : \u03b9 \u2192 \u03b9) (hh : \u2200 x : \u03b9, 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 {\u03b1} (x : Cofix F \u03b1) : Quot.mk _ (Cofix.repr x) = x :=\n  by\n  let R := fun x y : cofix F \u03b1 => cofix.abs (cofix.repr y) = x\n  refine' cofix.bisim\u2082 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, \u2190 append_fun_comp_id, \u2190 append_fun_comp_id]\n  let f : (\u03b1 ::: (P F).M \u03b1) \u27f9 subtype_ (\u03b1.rel_last' R) :=\n    split_fun diag_sub fun x => \u27e8(cofix.abs (cofix.abs x).repr, cofix.abs x), _\u27e9\n  refine' liftr_map _ _ _ _ f _\n  \u00b7 simp only [\u2190 append_prod_append_fun, prod_map_id]\n    apply eq_of_drop_last_eq\n    \u00b7 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 \u2190 to_expr e\n  let expr.pi n bi d b \u2190\n    retrieve do\n        generalize e\n        target\n  let q(@Eq $(t) $(l) $(r)) \u2190 pure b\n  let x \u2190 mk_local_def `n d\n  let v\u2080 \u2190 mk_local_def `a t\n  let v\u2081 \u2190 mk_local_def `b t\n  let x\u2080 \u2190 mk_app `` Eq [v\u2080, l.instantiate_var x]\n  let x\u2081 \u2190 mk_app `` Eq [v\u2081, r.instantiate_var x]\n  let xx \u2190 mk_app `` And [x\u2080, x\u2081]\n  let ex \u2190 lambdas [x] xx\n  let ex \u2190 mk_app `` Exists [ex] >>= lambdas [v\u2080, v\u2081]\n  let R \u2190 pose `R none ex\n  refine ``(Cofix.bisim\u2082 $(R) _ _ _ \u27e8_, rfl, rfl\u27e9)\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\u2080, w :: ids\u2081) \u2190 pure <| List.splitAt 2 ids\n  intro_lst ids\u2080\n  let h \u2190 intro1\n  let [(_, [w, h], _)] \u2190 cases_core h [w]\n  cases h ids\u2081\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 {\u03b1 : TypeVec n} {X Y} {x\u2080 : X} (f : X \u2192 Y) (g : Y \u2192 F (\u03b1 ::: X)) :\n    Cofix.corec (g \u2218 f) x\u2080 = Cofix.corec (MvFunctor.map (id ::: f) \u2218 g) (f x\u2080) :=\n  by\n  mv_bisim x\u2080\n  rw [Ha, Hb, cofix.dest_corec, cofix.dest_corec]\n  rw [MvFunctor.map_map, \u2190 append_fun_comp_id]\n  refine' liftr_map_last _ _ _ _ _\n  intro a; refine' \u27e8a, rfl, rfl\u27e9\n#align mvqpf.corec_roll MvQPF.corec_roll\n\ntheorem Cofix.dest_corec' {\u03b1 : TypeVec n} {\u03b2 : Type u} (g : \u03b2 \u2192 F (\u03b1.append1 (Sum (Cofix F \u03b1) \u03b2)))\n    (x : \u03b2) :\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  \u00b7 mv_bisim i\n    rw [Ha, Hb, cofix.dest_corec]\n    dsimp [(\u00b7 \u2218 \u00b7)]\n    repeat' rw [MvFunctor.map_map, \u2190 append_fun_comp_id]\n    apply liftr_map_last'\n    dsimp [(\u00b7 \u2218 \u00b7), R]\n    intros\n    exact \u27e8_, rfl, rfl\u27e9\n  \u00b7 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\u2081 {\u03b1 : TypeVec n} {\u03b2 : Type u}\n    (g : \u2200 {X}, (Cofix F \u03b1 \u2192 X) \u2192 (\u03b2 \u2192 X) \u2192 \u03b2 \u2192 F (\u03b1.append1 X)) (x : \u03b2)\n    (h :\n      \u2200 (X Y) (f : Cofix F \u03b1 \u2192 X) (f' : \u03b2 \u2192 X) (k : X \u2192 Y),\n        g (k \u2218 f) (k \u2218 f') x = (id ::: k) <$$> g f f' x) :\n    Cofix.dest (Cofix.corec\u2081 (@g) x) = g id (Cofix.corec\u2081 @g) x := by\n  rw [cofix.corec\u2081, cofix.dest_corec', \u2190 h] <;> rfl\n#align mvqpf.cofix.dest_corec\u2081 MvQPF.Cofix.dest_corec\u2081\n\ninstance mvqpfCofix : MvQPF (Cofix F) where\n  p := q.p.mp\n  abs \u03b1 := Quot.mk Mcongr\n  repr \u03b1 := Cofix.repr\n  abs_repr \u03b1 := Cofix.abs_repr\n  abs_map \u03b1 \u03b2 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 {\u03b1 : Type}\nvariable [comm_semigroup_with_zero \u03b1]\n\nlemma transition.encap_deadlock (A z) (a : \u03b1):\ntransition (encap A (\u03b4 : mcrl2 \u03b1)) a z \u2194 transition (\u03b4 : mcrl2 \u03b1) a z :=\nbegin\n  simp [transition.encap_iff, transition.deadlock_iff],\nend\n\nlemma transition.encap_success (a\u2081 : \u03b1) (A) (h : a\u2081 \u2209 A) (z a\u2082) :\ntransition (encap A (atom a\u2081)) a\u2082 z \u2194 transition (atom a\u2081) a\u2082 z :=\nbegin\n  simp [transition.encap_iff, transition.atom_iff, h, \u2190and_assoc, h],\n  intros _ _ h,\n  rw h,\n  assumption\nend\n\nlemma transition.encap_fail (a\u2081 : \u03b1) (A) (h : a\u2081 \u2208 A) (z a\u2082) :\ntransition (encap A (atom a\u2081)) a\u2082 z \u2194 transition \u03b4 a\u2082 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 \u03b1) (y A z) (a : \u03b1) :\ntransition (encap A (x + y)) a z \u2194 transition ((encap A x) + (encap A y)) a z:=\nbegin\n  simp [transition.encap_iff, transition.alt_iff, \u2190exists_and_distrib_right, and_or_distrib_left, or_and_distrib_right, exists_or_distrib]\nend\n\n/- encap_seq (\u2202_H(x \u2b1d y) = \u2202_H(x) \u2b1d \u2202_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": "@[default_instance] instance : Pow Int Nat where\n  pow m n := m ^ n\n\ninstance : @Trans Int Int Int (\u00b7 < \u00b7) (\u00b7 < \u00b7) (\u00b7 < \u00b7) where\n  trans := sorry\n\nexample {n : Int} : n ^ 2 < 1 :=\n  calc\n    n ^ 2 < 1 ^ 2 := sorry\n    _ < 1 := 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/2079.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8558511543206819, "lm_q2_score": 0.5774953651858117, "lm_q1q2_score": 0.4942500749091207}}
{"text": "import algebra.direct_sum.basic\n\nnamespace direct_sum\n\nuniverses u v w u\u2081\n\nvariables (\u03b9 : Type v) [decidable_eq \u03b9] (\u03b2 : \u03b9 \u2192 Type w)\nvariables [\u03a0 (i : \u03b9), add_comm_monoid (\u03b2 i)]\n\nlemma of_congr {i j : \u03b9} (h : i = j) (x : \u03b2 i) (y : \u03b2 j) (h' : y = (by rw h at x; exact x : \u03b2 j)) :\n  of \u03b2 i x = of \u03b2 j y := \nbegin\n  subst h,\n  subst h',\n  refl,\nend\n\nend direct_sum", "meta": {"author": "jjaassoonn", "repo": "twist", "sha": "8b12ca696c19c239c2e9deeab51c5dc04e586fed", "save_path": "github-repos/lean/jjaassoonn-twist", "path": "github-repos/lean/jjaassoonn-twist/twist-8b12ca696c19c239c2e9deeab51c5dc04e586fed/src/lemmas/about_direct_sum.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8615382094310357, "lm_q2_score": 0.5736784074525098, "lm_q1q2_score": 0.4942458679458834}}
{"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 := \u27e8\u27e8Type u, category_theory.types\u27e9\u27e9\n\ninstance : has_coe_to_sort Cat (Type u) := \u27e8bundled.\u03b1\u27e9\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 := \u03bb C D, C \u2964 D,\n  id := \u03bb C, \ud835\udfed C,\n  comp := \u03bb C D E F G, F \u22d9 G,\n  hom_category := \u03bb C D, functor.category C D,\n  whisker_left := \u03bb C D E F G H \u03b7, whisker_left F \u03b7,\n  whisker_right := \u03bb C D E F G \u03b7 H, whisker_right \u03b7 H,\n  associator := \u03bb A B C D, functor.associator,\n  left_unitor :=  \u03bb A B, functor.left_unitor,\n  right_unitor := \u03bb A B, functor.right_unitor,\n  pentagon' := \u03bb A B C D E, functor.pentagon,\n  triangle' := \u03bb A B C, functor.triangle }\n\n/-- `Cat` is a strict bicategory. -/\ninstance bicategory.strict : bicategory.strict Cat.{v u} :=\n{ id_comp' := \u03bb C D F, by cases F; refl,\n  comp_id' := \u03bb 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 \u27f6 Y) : (\ud835\udfd9 C : C \u2964 C).map f = f :=\nfunctor.id_map f\n\n@[simp]\nlemma comp_obj {C D E : Cat} (F : C \u27f6 D) (G : D \u27f6 E) (X : C) :\n  (F \u226b 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 \u27f6 D) (G : D \u27f6 E) {X Y : C} (f : X \u27f6 Y) :\n  (F \u226b 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} \u2964 Type u :=\n{ obj := \u03bb C, C,\n  map := \u03bb 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} (\u03b3 : C \u2245 D) : C \u224c D :=\n{ functor := \u03b3.hom,\n  inverse := \u03b3.inv,\n  unit_iso := eq_to_iso $ eq.symm \u03b3.hom_inv_id,\n  counit_iso := eq_to_iso \u03b3.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 \u2964 Cat :=\n{ obj := \u03bb X, Cat.of (discrete X),\n  map := \u03bb X Y f, discrete.functor (discrete.mk \u2218 f),\n  map_id' := \u03bb X, begin apply functor.ext, tidy, end,\n  map_comp' := \u03bb X Y Z f g, begin apply functor.ext, tidy, end }\n\ninstance : faithful Type_to_Cat.{u} :=\n{ map_injective' := \u03bb X Y f g h, funext (\u03bb x, congr_arg discrete.as (functor.congr_obj h \u27e8x\u27e9)), }\n\ninstance : full Type_to_Cat.{u} :=\n{ preimage := \u03bb X Y F, discrete.as \u2218 F.obj \u2218 discrete.mk,\n  witness' :=\n  begin\n    intros X Y F,\n    apply functor.ext,\n    { intros x y f, dsimp, ext, },\n    { rintros \u27e8x\u27e9, 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     \u22a5  :=  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 \u2227 (hom a2 = b2))\n\n\nopen is_ring_hom  --- to have acces map_mul map_one \ndef comp (A B: Type)(\u03c6 : A \u2192 B)[comm_ring A][comm_ring B][is_ring_hom \u03c6] (a b : A) : (comax a b) \u2192 comax (\u03c6 a) (\u03c6 b) := \u03bb \u27e8u_ab,v_ab,certificat_ab\u27e9, --- {} or \u27e8 \u27e9 \u03bb OBJET and then OBJET.u etc \n    begin\n        have certificat : (\u03c6 a) * (\u03c6 u_ab) + (\u03c6 b) * (\u03c6 v_ab) = 1,          -- It's trivial ring identity, but i have to control ! \n            rw [ \u2190  map_mul \u03c6, \u2190 map_mul \u03c6 , \u2190 map_add \u03c6,certificat_ab],\n            apply map_one,\n        exact {u := \u03c6 u_ab,v := \u03c6 v_ab,certificat := certificat},            --- the constructor of structure  : i thinck better than  \u27e8  \u27e9 \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     \u22a5  :=  comax   --- notation \n\n\ndef symm  :  (a) \u22a5  (b)  \u2192   (b) \u22a5 (a)   :=   --- a u + b v = 1 \u2192 b v + a u = 1 \n    \u03bb \u27e8u,v,certificat\u27e9,    \n        begin   \n            have  t :  b * v + a * u = 1, \n                rw add_comm,  assumption,\n            use \u27e8v,u,t\u27e9,\n        end \nlemma one_perp  :  1 \u22a5 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 \u27e81,0,h\u27e9\nend\nlemma abab_trick : (a \u22a5 c) \u2192 (b \u22a5 c) \u2192 (a * b) \u22a5 c :=    ---  Trick to simplify proof !  if a \u22a5 c and b \u22a5 c then ab \u22a5 c  from calculus !  \n    \u03bb \u27e8ua,va,ka\u27e9  \u27e8ub,vb,kb\u27e9, \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 \u27e8 ua * ub,  a * ua * vb + va * b * ub + va * c * vb , J\u27e9,\n        end\nopen nat\nlemma star (a  b : R) (n : nat):   (a \u22a5 b) \u2192 ((a^n) \u22a5 b)  := \n    \u03bb u,\n        nat.rec_on n\n                (show  (a^0) \u22a5 b, {rw pow_zero a, apply one_perp, })\n                (assume n, assume re : ((a^n) \u22a5 b), show (a^(n+1)) \u22a5 b,\n                       {rw pow_succ a n,apply abab_trick, assumption,assumption})\n\ntheorem My_favorite_localisation_lemma (n m : nat) : (a \u22a5 b) \u2192 (a^n) \u22a5 (b^m) :=                 --- the goals \n    \u03bb 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 \ud835\udd38 is a local functor : a scheaf for global Zariski for Aff\u1d52\u1d56. \n----   ( Note \ud835\udd38 is structural for Ring so if you do the job for \ud835\udd38 you do the job for all ring i.e Spec R := Hom(R,\u2022) 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 \u2208 R :  f \u22a5 g. \n---                      Let a \u2208 R : \n---                             \u2203 m n : \u2115,  f^m a = 0 \u2227  g^n a = 0   --- i.e a = 0 in localisation  {f^k k \u2208 N\u22c6} and   {g^k k \u2208 N\u22c6}\n---                      Since f \u22a5 g , we have f^m \u22a5 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 : \u2115)(n : \u2115)\n(proof_localy_zero : f^m * a = 0 \u2227 g^n * a = 0)\n\ntheorem Separation_axiom (a : R) : f \u22a5 g \u2192 localy_zero (a)   \u2192   a = 0  :=  \u03bb coma \u27e8t,m,n,proof_localy_zero \u27e9,\nbegin \n     have H : (f^m) \u22a5 (g^n),\n        apply My_favorite_localisation_lemma,\n        assumption,\n    rcases H with \u27e8ua,va,ka\u27e9,\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 : \u2115) extends f \u22a5 g  :=    --- comment est structur\u00e9 la notion de desc\n(m : \u2115)                                                                      ---   F : N \u2192\u2080 R  + certiticat F^\u22a5 : N \u2192\u2080 R  co-max \n(proof_m : f^m * g^(n+m) * s_f = g^m * f^(n+m) * s_g )                       ---   l\u00e0 j'ai acc\u00e9es a des fonctions touts faites \n                                                                             ---    --->  F,  :::  s_F : \u2115  \u2192 R  et  n_F : N \u2192 \u2115   \n                                                                             ---    ' \u03b6_f :=  s_f / f^n_f ' (data)\nparameters s_f s_g : R                                                       ---    descent data + \u2203 m_f t q  (f,g) ---> certificat f g\nparameters n : \u2115                                                             ---   \n\nstructure effective_descente_data  extends descent_data s_f  s_g n:=\n( s : R)\n(N_f : \u2115) (N_g : \u2115)\n(proof_n_plus_m_f_g : f^(N_f+n) * s = f^N_f * s_f \u2227  g^(N_g+n) * s = g^N_g * s_g)\n\n\nset_option class.instance_max_depth 20\ntheorem gluing_data  :   f \u22a5 g \u2192      descent_data s_f s_g n    \u2192   effective_descente_data  := \n         \u03bb comma,\u03bb y, \n            begin\n                rcases comma with \u27e8u,v,proof_of_comax\u27e9,\n                rcases y with \u27e8t,m,proof_m\u27e9,  \n                have H: (f^(n+m)) \u22a5 (g^(n+m)),\n                    apply My_favorite_localisation_lemma,\n                assumption,\n            rcases H with \u27e8vf,vg,proof_n_plus_m_f_g\u27e9,\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 \u2227  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 := \u27e8t,m,proof_m\u27e9, 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\u2013Smith-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\u20132019:\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\u2014find\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 \u2227 b = 4}`\n    `{b \u2265 5} b := b + 1 {b \u2265 6}`\n    `{false} skip {b = 100}`\n    `{true} while i \u2260 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    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Skip\n    {P} skip {P}\n\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn\n    {Q[a/x]} x := a {Q}\n\n    {P} S {R}   {R} S' {Q}\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Seq\n    {P} S; S' {Q}\n\n    {P \u2227 b} S {Q}   {P \u2227 \u00acb} S' {Q}\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 If\n    {P} if b then S else S' {Q}\n\n    {I \u2227 b} S {I}\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 While\n    {I} while b do S {I \u2227 \u00acb}\n\n    P' \u2192 P   {P} S {Q}   Q \u2192 Q'\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 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    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn   \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn\n    {a = 2} b := a {b = 2}       {b = 2} c := b {c = 2}\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Seq\n    {a = 2} b := a; c := b {c = 2}\n\n\n                     \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn\n    x > 10 \u2192 x > 5   {x > 5} y := x {y > 5}   y > 5 \u2192 y > 0\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 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 \u2192 Q\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Skip'\n    {P} skip {Q}\n\n    P \u2192 Q[a/x]\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn'\n    {P} x := a {Q}\n\n    {P \u2227 b} S {P}   P \u2227 \u00acb \u2192 Q\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 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 \u2192 Prop`) to represent pre- and\npostconditions, following the shallow embedding style. -/\n\ndef partial_hoare (P : state \u2192 Prop) (S : stmt)\n  (Q : state \u2192 Prop) : Prop :=\n\u2200s t, P s \u2192 (S, s) \u27f9 t \u2192 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 \u2192 Prop) {x} {a : state \u2192 \u2115} :\n  {* \u03bbs, P (s{x \u21a6 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 \u2192 Prop} {S T}\n    (hS : {* \u03bbs, P s \u2227 b s *} S {* Q *})\n    (hT : {* \u03bbs, P s \u2227 \u00ac 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 \u2192 Prop) {b : state \u2192 Prop} {S}\n    (h : {* \u03bbs, P s \u2227 b s *} S {* P *}) :\n  {* P *} stmt.while b S {* \u03bbs, P s \u2227 \u00ac 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 \u2192 Prop} {S}\n    (h : {* P *} S {* Q *}) (hp : \u2200s, P' s \u2192 P s)\n    (hq : \u2200s, Q s \u2192 Q' s) :\n  {* P' *} S {* Q' *} :=\nfix s t,\nassume hs : P' s,\nassume hst : (S, s) \u27f9 t,\nshow Q' t, from\n  hq _ (h s t (hp s hs) hst)\n\nlemma consequence_left (P' : state \u2192 Prop) {P Q S}\n    (h : {* P *} S {* Q *}) (hp : \u2200s, P' s \u2192 P s) :\n  {* P' *} S {* Q *} :=\nconsequence h hp (by cc)\n\nlemma consequence_right (Q) {Q' : state \u2192 Prop} {P S}\n    (h : {* P *} S {* Q *}) (hq : \u2200s, Q s \u2192 Q' s) :\n  {* P *} S {* Q' *} :=\nconsequence h (by cc) hq\n\nlemma skip_intro' {P Q : state \u2192 Prop} (h : \u2200s, P s \u2192 Q s) :\n  {* P *} stmt.skip {* Q *} :=\nconsequence skip_intro h (by cc)\n\nlemma assign_intro' {P Q : state \u2192 Prop} {x} {a : state \u2192 \u2115}\n    (h : \u2200s, P s \u2192 Q (s{x \u21a6 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 \u2192 Prop} {S}\n    (I : state \u2192 Prop)\n    (hS : {* \u03bbs, I s \u2227 b s *} S {* I *})\n    (hP : \u2200s, P s \u2192 I s)\n    (hQ : \u2200s, \u00ac b s \u2192 I s \u2192 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  {* \u03bbs, \u2203n\u2080, P (s{x \u21a6 n\u2080}) \u2227 s x = a (s{x \u21a6 n\u2080}) *} :=\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 \u2192 Prop) {x}\n    {a : state \u2192 \u2115} :\n  {* \u03bbs, \u2203n', Q (s{x \u21a6 n'}) \u2227 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\" (\u03bbs, s \"a\") ;;\nstmt.assign \"a\" (\u03bbs, s \"b\") ;;\nstmt.assign \"b\" (\u03bbs, s \"t\")\n\nlemma SWAP_correct (a\u2080 b\u2080 : \u2115) :\n  {* \u03bbs, s \"a\" = a\u2080 \u2227 s \"b\" = b\u2080 *}\n  SWAP\n  {* \u03bbs, s \"a\" = b\u2080 \u2227 s \"b\" = a\u2080 *} :=\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\u2082 (a\u2080 b\u2080 : \u2115) :\n  {* \u03bbs, s \"a\" = a\u2080 \u2227 s \"b\" = b\u2080 *}\n  SWAP\n  {* \u03bbs, s \"a\" = b\u2080 \u2227 s \"b\" = a\u2080 *} :=\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 (\u03bbs, s \"n\" \u2260 0)\n  (stmt.assign \"n\" (\u03bbs, s \"n\" - 1) ;;\n   stmt.assign \"m\" (\u03bbs, s \"m\" + 1))\n\nlemma ADD_correct (n\u2080 m\u2080 : \u2115) :\n  {* \u03bbs, s \"n\" = n\u2080 \u2227 s \"m\" = m\u2080 *}\n  ADD\n  {* \u03bbs, s \"n\" = 0 \u2227 s \"m\" = n\u2080 + m\u2080 *} :=\npartial_hoare.while_intro' (\u03bbs, s \"n\" + s \"m\" = n\u2080 + m\u2080)\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 \u2190hnm,\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 \u2192 Prop) (S : stmt) : stmt :=\nstmt.while b S\n\nnamespace partial_hoare\n\nlemma while_inv_intro {b I Q : state \u2192 Prop} {S}\n    (hS : {* \u03bbs, I s \u2227 b s *} S {* I *})\n    (hQ : \u2200s, \u00ac b s \u2192 I s \u2192 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 \u2192 Prop} {S}\n    (hS : {* \u03bbs, I s \u2227 b s *} S {* I *})\n    (hP : \u2200s, P s \u2192 I s) (hQ : \u2200s, \u00ac b s \u2192 I s \u2192 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 \u2190 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\u2082 (n\u2080 m\u2080 : \u2115) :\n  {* \u03bbs, s \"n\" = n\u2080 \u2227 s \"m\" = m\u2080 *}\n  ADD\n  {* \u03bbs, s \"n\" = 0 \u2227 s \"m\" = n\u2080 + m\u2080 *} :=\nshow {* \u03bbs, s \"n\" = n\u2080 \u2227 s \"m\" = m\u2080 *}\n     stmt.while_inv (\u03bbs, s \"n\" + s \"m\" = n\u2080 + m\u2080)\n       (\u03bbs, s \"n\" \u2260 0)\n       (stmt.assign \"n\" (\u03bbs, s \"n\" - 1) ;;\n        stmt.assign \"m\" (\u03bbs, s \"m\" + 1))\n     {* \u03bbs, s \"n\" = 0 \u2227 s \"m\" = n\u2080 + m\u2080 *}, from\n  begin\n    vcg; simp { contextual := tt },\n    intros s hnm hnz,\n    rw \u2190hnm,\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 \u2264 100] while i \u2260 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 \u2227 b \u2227 V = v\u2080] S [I \u2227 V < v\u2080]\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 While-Var\n    [I] while b do S [I \u2227 \u00acb]\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' \u2264 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\u2081 J\u2082 : 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\u2081.Covers S f\n  downward_closed' Y Z f hS := J\u2081.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 \u2264 J\u2081.close S := fun Y g hg =>\n  J\u2081.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  \u2200 \u2983Y : C\u2984 (f : Y \u27f6 X), J\u2081.Covers S f \u2192 S f\n#align category_theory.grothendieck_topology.is_closed CategoryTheory.GrothendieckTopology.IsClosed\n\n/-- If `S` is `J\u2081`-closed, then `S` covers exactly the arrows it contains. -/\ntheorem covers_iff_mem_of_closed {X : C} {S : Sieve X} (h : J\u2081.IsClosed S) {Y : C} (f : Y \u27f6 X) :\n    J\u2081.Covers S f \u2194 S f :=\n  \u27e8h _, J\u2081.arrow_max _ _\u27e9\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 \u27f6 X) (S : Sieve X) :\n    J\u2081.IsClosed S \u2192 J\u2081.IsClosed (S.pullback f) := fun hS Z g hg =>\n  hS (g \u226b f) (by rwa [J\u2081.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 \u2264 T) (hT : J\u2081.IsClosed T) :\n    J\u2081.close S \u2264 T := fun Y f hf => hT _ (J\u2081.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\u2081.IsClosed (J\u2081.close S) := fun Y g hg =>\n  J\u2081.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\u2081.IsClosed S \u2194 J\u2081.close S = S :=\n  by\n  constructor\n  \u00b7 intro h\n    apply le_antisymm\n    \u00b7 intro Y f hf\n      rw [\u2190 J\u2081.covers_iff_mem_of_closed h]\n      apply hf\n    \u00b7 apply J\u2081.le_close\n  \u00b7 intro e\n    rw [\u2190 e]\n    apply J\u2081.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\u2081.IsClosed S) : J\u2081.close S = S :=\n  (J\u2081.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 \u27f6 X) (S : Sieve X) :\n    J\u2081.close (S.pullback f) = (J\u2081.close S).pullback f :=\n  by\n  apply le_antisymm\n  \u00b7 refine' J\u2081.le_close_of_is_closed (sieve.pullback_monotone _ (J\u2081.le_close S)) _\n    apply J\u2081.is_closed_pullback _ _ (J\u2081.close_is_closed _)\n  \u00b7 intro Z g hg\n    change _ \u2208 J\u2081 _\n    rw [\u2190 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\u2081.close : Sieve X \u2192 Sieve X) := fun S\u2081 S\u2082 h =>\n  J\u2081.le_close_of_isClosed (h.trans (J\u2081.le_close _)) (J\u2081.close_isClosed S\u2082)\n#align category_theory.grothendieck_topology.monotone_close CategoryTheory.GrothendieckTopology.monotone_close\n\n@[simp]\ntheorem close_close {X : C} (S : Sieve X) : J\u2081.close (J\u2081.close S) = J\u2081.close S :=\n  le_antisymm (J\u2081.le_close_of_isClosed le_rfl (J\u2081.close_isClosed S))\n    (J\u2081.monotone_close (J\u2081.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\u2081.close S = \u22a4 \u2194 S \u2208 J\u2081 X :=\n  by\n  constructor\n  \u00b7 intro h\n    apply J\u2081.transitive (J\u2081.top_mem X)\n    intro Y f hf\n    change J\u2081.close S f\n    rwa [h]\n  \u00b7 intro hS\n    rw [eq_top_iff]\n    intro Y f hf\n    apply J\u2081.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\u2081.close\n    (fun S\u2081 S\u2082 h => J\u2081.le_close_of_isClosed (h.trans (J\u2081.le_close _)) (J\u2081.close_isClosed S\u2082))\n    J\u2081.le_close fun S => J\u2081.le_close_of_isClosed le_rfl (J\u2081.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 \u2208 (J\u2081.ClosureOperator X).closed \u2194 J\u2081.IsClosed S :=\n  (J\u2081.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\u1d52\u1d56 \u2964 Type max v u\n    where\n  obj X := { S : Sieve X.unop // J\u2081.IsClosed S }\n  map X Y f S := \u27e8S.1.pullback f.unop, J\u2081.isClosed_pullback f.unop _ S.2\u27e9\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\u2081 (Functor.closedSieves J\u2081) :=\n  by\n  intro X S hS\n  rw [\u2190 presieve.is_separated_for_and_exists_is_amalgamation_iff_sheaf_for]\n  refine' \u27e8_, _\u27e9\n  \u00b7 rintro x \u27e8M, hM\u27e9 \u27e8N, hN\u27e9 hM\u2082 hN\u2082\n    ext\n    dsimp only [Subtype.coe_mk]\n    rw [\u2190 J\u2081.covers_iff_mem_of_closed hM, \u2190 J\u2081.covers_iff_mem_of_closed hN]\n    have q : \u2200 \u2983Z : C\u2984 (g : Z \u27f6 X) (hg : S g), M.pullback g = N.pullback g :=\n      by\n      intro Z g hg\n      apply congr_arg Subtype.val ((hM\u2082 g hg).trans (hN\u2082 g hg).symm)\n    have MSNS : M \u2293 S = N \u2293 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    \u00b7 intro hf\n      rw [J\u2081.covers_iff]\n      apply J\u2081.superset_covering (sieve.pullback_monotone f inf_le_left)\n      rw [\u2190 MSNS]\n      apply J\u2081.arrow_intersect f M S hf (J\u2081.pullback_stable _ hS)\n    \u00b7 intro hf\n      rw [J\u2081.covers_iff]\n      apply J\u2081.superset_covering (sieve.pullback_monotone f inf_le_left)\n      rw [MSNS]\n      apply J\u2081.arrow_intersect f N S hf (J\u2081.pullback_stable _ hS)\n  \u00b7 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 : \u2200 \u2983Y\u2984 (f : Y \u27f6 X) (hf : S f), M.pullback f = (x f hf).1 :=\n      by\n      intro Y f hf\n      apply le_antisymm\n      \u00b7 rintro Z u \u27e8W, g, f', hf', hg : (x f' hf').1 _, c\u27e9\n        rw [sieve.pullback_eq_top_iff_mem, \u2190\n          show (x (u \u226b f) _).1 = (x f hf).1.pullback u from congr_arg Subtype.val (hx f u hf)]\n        simp_rw [\u2190 c]\n        rw [show (x (g \u226b f') _).1 = _ from congr_arg Subtype.val (hx f' g hf')]\n        apply sieve.pullback_eq_top_of_mem _ hg\n      \u00b7 apply sieve.le_pullback_bind S fun Y f hf => (x f hf).1\n    refine' \u27e8\u27e8_, J\u2081.close_is_closed M\u27e9, _\u27e9\n    \u00b7 intro Y f hf\n      ext1\n      dsimp\n      rw [\u2190 J\u2081.pullback_close, this _ hf]\n      apply le_antisymm (J\u2081.le_close_of_is_closed le_rfl (x f hf).2) (J\u2081.le_close _)\n#align category_theory.classifier_is_sheaf CategoryTheory.classifier_isSheaf\n\n/-- If presheaf of `J\u2081`-closed sieves is a `J\u2082`-sheaf then `J\u2081 \u2264 J\u2082`. Note the converse is true by\n`classifier_is_sheaf` and `is_sheaf_of_le`.\n-/\ntheorem le_topology_of_closedSieves_isSheaf {J\u2081 J\u2082 : GrothendieckTopology C}\n    (h : Presieve.IsSheaf J\u2081 (Functor.closedSieves J\u2082)) : J\u2081 \u2264 J\u2082 := fun X S hS =>\n  by\n  rw [\u2190 J\u2082.close_eq_top_iff_mem]\n  have : J\u2082.is_closed (\u22a4 : sieve X) := by\n    intro Y f hf\n    trivial\n  suffices (\u27e8J\u2082.close S, J\u2082.close_is_closed S\u27e9 : Subtype _) = \u27e8\u22a4, this\u27e9\n    by\n    rw [Subtype.ext_iff] at this\n    exact this\n  apply (h S hS).IsSeparatedFor.ext\n  \u00b7 intro Y f hf\n    ext1\n    dsimp\n    rw [sieve.pullback_top, \u2190 J\u2082.pullback_close, S.pullback_eq_top_of_mem hf,\n      J\u2082.close_eq_top_iff_mem]\n    apply J\u2082.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\u2081` is equivalent to being a sheaf for `J\u2082`, then `J\u2081 = J\u2082`. -/\ntheorem topology_eq_iff_same_sheaves {J\u2081 J\u2082 : GrothendieckTopology C} :\n    J\u2081 = J\u2082 \u2194 \u2200 P : C\u1d52\u1d56 \u2964 Type max v u, Presieve.IsSheaf J\u2081 P \u2194 Presieve.IsSheaf J\u2082 P :=\n  by\n  constructor\n  \u00b7 rintro rfl\n    intro P\n    rfl\n  \u00b7 intro h\n    apply le_antisymm\n    \u00b7 apply le_topology_of_closed_sieves_is_sheaf\n      rw [h]\n      apply classifier_is_sheaf\n    \u00b7 apply le_topology_of_closed_sieves_is_sheaf\n      rw [\u2190 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 : \u2200 X : C, ClosureOperator (Sieve X))\n    (hc : \u2200 \u2983X Y : C\u2984 (f : Y \u27f6 X) (S : Sieve X), c _ (S.pullback f) = (c _ S).pullback f) :\n    GrothendieckTopology C where\n  sieves X := { S | c X S = \u22a4 }\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, \u2190 (c X).idempotent, eq_top_iff, \u2190 hS]\n    apply (c X).Monotone fun Y f hf => _\n    rw [sieve.pullback_eq_top_iff_mem, \u2190 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\u2081.ClosureOperator fun X Y => J\u2081.pullback_close) = J\u2081 :=\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 : \u2200 X : C, ClosureOperator (Sieve X))\n    (pb : \u2200 \u2983X Y : C\u2984 (f : Y \u27f6 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) = \u22a4 \u2194 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 \u03b1` guarantees that `\u03b1` is an initial model of the theory `th`.\nstructure is_initial (th : theory) (\u03b1 : Type _) [model th \u03b1] :=\n  (elim : \u03a0 {\u03b2 : Type _} [mb : model th \u03b2], @morphism th \u03b1 \u03b2 _ mb.to_premodel)\n  (hunique : \u03a0 {\u03b2 : Type _} [mb : model th \u03b2], \u2200 (g : @morphism th \u03b1 \u03b2 _ mb.to_premodel) (a : \u03b1), 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] (\u03b1 : Type _) [model th \u03b1] : \u03b1 := ((@is_initial.elim th unit _ ht.init_unit) \u03b1 _).val ()\n\n--- Proof that `fixed th \u03b1` is closed under operations in the theory `th`.\ntheorem fixed_op (th : theory) [ht : has_trivial_init th] (\u03b1 : Type _) [model th \u03b1] : \u2200 {n} \u03bc, fixed_element th \u03b1 = @premodel.act th \u03b1 _ n \u03bc (vect.repeat (fixed_element th \u03b1) n) :=\n  begin\n    intros n \u03bc,\n    dsimp [fixed_element],\n    cases hht: ht.init_unit with f hf,\n    dsimp [is_initial.elim],\n    rw [\u2190vect.map_repeat],\n    let hact := (@f \u03b1 _).property,\n    dunfold is_morphism at hact,\n    rw [\u2190hact],\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] (\u03b1 : Type _) [model th \u03b1] : \u2200 (\u03bc : th.op 0), fixed_element th \u03b1 = @premodel.act th \u03b1 _ _ \u03bc vect.nil :=\n  fixed_op th \u03b1\n\n--- The morphism that factors through the terminal model.\ndefinition null_morphism (th : theory) [ht : has_trivial_init th] (\u03b1 \u03b2 : Type _) [model th \u03b1] [model th \u03b2] : morphism th \u03b1 \u03b2 :=\n  \u27e8(\u03bb _, fixed_element th \u03b2), by intros n \u03bc as; dsimp *; rw [vect.map_const,\u2190fixed_op th \u03b2 \u03bc]\u27e9\n\n--- If `unit` is an initial model, then there is a canonical morphism that injects a model `\u03b1` into the first component of a product `\u03b1\u00d7\u03b2`.\ndefinition prod_inl (th : theory) [has_trivial_init th] {\u03b1 \u03b2 : Type _} [model th \u03b1] [model th \u03b2] : morphism th \u03b1 (\u03b1\u00d7\u03b2) :=\n{\n  val := \u03bb a, (a, fixed_element th \u03b2),\n  property :=\n    begin\n      intros n \u03bc as,\n      dsimp [premodel.act, prod.map],\n      rw [vect.unzip_fst_is_map_fst, vect.unzip_snd_is_map_snd],\n      csimp [\u2190vect.map_comp],\n      dsimp [function.comp],\n      have : @id \u03b1 = (\u03bb x,x) , from rfl,\n      rw [\u2190this,vect.map_id]; clear this,\n      rw [vect.map_const],\n      rw [\u2190fixed_op th \u03b2 \u03bc],\n    end\n}\n\n--- If `unit` is an initial model, then there is a canonical morphism that injects a model `\u03b2` into the second component of a product `\u03b1\u00d7\u03b2`.\ndefinition prod_inr (th : theory) [has_trivial_init th] {\u03b1 \u03b2 : Type _} [model th \u03b1] [model th \u03b2] : morphism th \u03b2 (\u03b1\u00d7\u03b2) :=\n{\n  val := \u03bb b, (fixed_element th \u03b1,b),\n  property :=\n    begin\n      intros n \u03bc as,\n      dsimp [premodel.act, prod.map],\n      rw [vect.unzip_fst_is_map_fst, vect.unzip_snd_is_map_snd],\n      csimp [\u2190vect.map_comp],\n      dsimp [function.comp],\n      have : @id \u03b2 = (\u03bb x,x) , from rfl,\n      rw [\u2190this,vect.map_id]; clear this,\n      rw [vect.map_const],\n      rw [\u2190fixed_op th \u03b1 \u03bc],\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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (M : F.Model), infinite M :=\nbegin\n  -- For each $n$, let $\\mathbf A_n$ be the formula:\n  let A : \u2115 \u2192 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 : \u2200 n : \u2115, A n = \u2203' (x : fin n), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n    assume n : \u2115,\n    have h2 : \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n      assume (i j : fin n) (hne : i \u2260 j),\n      have h3 : i < n \u2227 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 \u2260 j, from by {apply ne_of_lt, exact h3.left},\n      have h5 : i \u2260 j, from by {apply ne_of_lt, exact h3.right},\n      show x i \u2260 x j, from by {apply ne_of_ne_of_ne, exact h4, exact h5},\n    },\n    show A n = \u2203' (x : fin n), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n      apply funext,\n      assume x : fin n,\n      show (\u2203' (x : fin n), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j) x \u2194 \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n        split,\n        assume h3 : (\u2203' (x : fin n), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j) x,\n        show \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n          assume (i j : fin n) (hne : i \u2260 j),\n          have h4 : \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n            assume (i j : fin n) (hne : i \u2260 j),\n            have h5 : i < n \u2227 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 \u2260 j, from by {apply ne_of_lt, exact h5.left},\n            have h7 : i \u2260 j, from by {apply ne_of_lt, exact h5.right},\n            show x i \u2260 x j, from by {apply ne_of_ne_of_ne, exact h6, exact h7},\n          },\n          show x i \u2260 x j, from by {apply h4, exact hne},\n        },\n        assume h3 : \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j,\n        show (\u2203' (x : fin n), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j) x, from by {\n          apply exists.intro x,\n          show \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n            assume (i j : fin n) (hne : i \u2260 j),\n            have h4 : \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n              assume (i j : fin n) (hne : i \u2260 j),\n              have h5 : i < n \u2227 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 \u2260 j, from by {apply ne_of_lt, exact h5.left},\n              have h7 : i \u2260 j, from by {apply ne_of_lt, exact h5.right},\n              show x i \u2260 x j, from by {apply ne_of_ne_of_ne, exact h6, exact h7},\n            },\n            show x i \u2260 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 : \u2200 (n : \u2115) (M : F.Model), M \u22a8 A n \u2194 fintype.card M \u2265 n, from by {\n    assume (n : \u2115) (M : F.Model),\n    have h3 : \u2200 (n : \u2115) (M : F.Model), M \u22a8 A n \u2192 fintype.card M \u2265 n, from by {\n      assume (n : \u2115) (M : F.Model) (h4 : M \u22a8 A n),\n      have h5 : \u2203 (x : fin n \u2192 M), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n        have h6 : \u2203 (x : fin n \u2192 M), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n          apply exists.elim h4,\n          assume (x : fin n \u2192 M),\n          assume h7 : \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j,\n          show \u2203 (x : fin n \u2192 M), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n            apply exists.intro x,\n            show \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n              assume (i j : fin n) (hne : i \u2260 j),\n              have h8 : \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n                assume (i j : fin n) (hne : i \u2260 j),\n                have h9 : i < n \u2227 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 \u2260 j, from by {apply ne_of_lt, exact h9.left},\n                have h11 : i \u2260 j, from by {apply ne_of_lt, exact h9.right},\n                show x i \u2260 x j, from by {apply ne_of_ne_of_ne, exact h10, exact h11},\n              },\n              show x i \u2260 x j, from by {apply h8, exact hne},\n            },\n          },\n        },\n        show \u2203 (x : fin n \u2192 M), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n          apply exists.elim h6,\n          assume (x : fin n \u2192 M),\n          assume h7 : \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j,\n          show \u2203 (x : fin n \u2192 M), \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n            apply exists.intro x,\n            show \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n              assume (i j : fin n) (hne : i \u2260 j),\n              have h8 : \u2200 (i j : fin n), i \u2260 j \u2192 x i \u2260 x j, from by {\n                assume (i j : fin n) (hne : i \u2260 j),\n                have h9 : i < n \u2227 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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 : \u2200 n : \u2115, \u2203 (m : F.Model) [mfin : fintype m], n \u2264 @fintype.card m mfin) : \u2203 (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 {\u03b2 : Type*} [add_comm_group \u03b2] {b : \u03b2}\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 : \u03b2} (h : i = j) : X.X i \u27f6 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 : \u03b2) :\n  X.X_eq_to_hom (refl i) = \ud835\udfd9 _ := rfl\n\n@[simp, reassoc] lemma eq_to_hom_d (X : differential_object (graded_object_with_shift b V))\n  {x y : \u03b2} (h : x = y) :\n  X.X_eq_to_hom h \u226b X.d y = X.d x \u226b 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 : \u03b2} (h : y = z) :\n  X.d x y \u226b 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 \u27f6 Y) {x y : \u03b2} (h : x = y) :\n  X.X_eq_to_hom h \u226b f.f y = f.f x \u226b 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) \u2964\n    homological_complex V (complex_shape.up' b) :=\n{ obj := \u03bb X,\n  { X := \u03bb i, X.X i,\n    d := \u03bb i j, if h : i + b = j then\n      X.d i \u226b X.X_eq_to_hom (show i + (1 : \u2124) \u2022 b = j, by simp [h]) else 0,\n    shape' := \u03bb i j w, by { dsimp at w, convert dif_neg w },\n    d_comp_d' := \u03bb i j k hij hjk, begin\n      dsimp at hij hjk, substs hij hjk,\n      have : X.d i \u226b X.d _ = _ := (congr_fun X.d_squared i : _),\n      reassoc! this,\n      simp [this],\n    end },\n  map := \u03bb X Y f,\n  { f := f.f,\n    comm' := \u03bb i j h, begin\n      dsimp at h \u22a2,\n      subst h,\n      have : f.f i \u226b Y.d i = X.d i \u226b f.f (i + 1 \u2022 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) \u2964\n    differential_object (graded_object_with_shift b V) :=\n{ obj := \u03bb X,\n  { X := \u03bb i, X.X i,\n    d := \u03bb i, X.d i (i + 1 \u2022 b),\n    d_squared' := by { ext i, dsimp, simp, } },\n  map := \u03bb 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  \ud835\udfed (differential_object (graded_object_with_shift b V)) \u2245\n    dgo_to_homological_complex b V \u22d9 homological_complex_to_dgo b V :=\nnat_iso.of_components (\u03bb X,\n  { hom := { f := \u03bb i, \ud835\udfd9 (X.X i), },\n    inv := { f := \u03bb i, \ud835\udfd9 (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 \u22d9 dgo_to_homological_complex b V \u2245\n    \ud835\udfed (homological_complex V (complex_shape.up' b)) :=\nnat_iso.of_components (\u03bb X,\n  { hom :=\n    { f := \u03bb i, \ud835\udfd9 (X.X i),\n      comm' := \u03bb i j h, begin\n        dsimp at h \u22a2, subst h,\n        delta homological_complex_to_dgo,\n        simp,\n      end },\n    inv :=\n    { f := \u03bb i, \ud835\udfd9 (X.X i),\n      comm' := \u03bb i j h, begin\n        dsimp at h \u22a2, 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) \u224c\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 : \u03b1} {b : Option \u03b1} : a \u2208 b \u2194 b = a := .rfl\n\ntheorem some_ne_none (x : \u03b1) : some x \u2260 none := fun.\n\nprotected theorem \u00abforall\u00bb {p : Option \u03b1 \u2192 Prop} : (\u2200 x, p x) \u2194 p none \u2227 \u2200 x, p (some x) :=\n  \u27e8fun h => \u27e8h _, fun _ => h _\u27e9, fun h x => Option.casesOn x h.1 h.2\u27e9\n\nprotected theorem \u00abexists\u00bb {p : Option \u03b1 \u2192 Prop} : (\u2203 x, p x) \u2194 p none \u2228 \u2203 x, p (some x) :=\n  \u27e8fun | \u27e8none, hx\u27e9 => .inl hx | \u27e8some x, hx\u27e9 => .inr \u27e8x, hx\u27e9,\n   fun | .inl h => \u27e8_, h\u27e9 | .inr \u27e8_, hx\u27e9 => \u27e8_, hx\u27e9\u27e9\n\ntheorem get_mem : \u2200 {o : Option \u03b1} (h : isSome o), o.get h \u2208 o\n| some _, _ => rfl\n\ntheorem get_of_mem : \u2200 {o : Option \u03b1} (h : isSome o), a \u2208 o \u2192 o.get h = a\n| _, _, rfl => rfl\n\ntheorem not_mem_none (a : \u03b1) : a \u2209 (none : Option \u03b1) := fun.\n\n@[simp] theorem some_get : \u2200 {x : Option \u03b1} (h : isSome x), some (x.get h) = x\n| some _, _ => rfl\n\n@[simp] theorem get_some (x : \u03b1) (h : isSome (some x)) : (some x).get h = x := rfl\n\ntheorem getD_of_ne_none {x : Option \u03b1} (hx : x \u2260 none) (y : \u03b1) : some (x.getD y) = x := by\n  cases x; {contradiction}; rw [getD_some]\n\ntheorem mem_unique {o : Option \u03b1} {a b : \u03b1} (ha : a \u2208 o) (hb : b \u2208 o) : a = b :=\n  some.inj <| ha \u25b8 hb\n\n@[ext] theorem ext : \u2200 {o\u2081 o\u2082 : Option \u03b1}, (\u2200 a, a \u2208 o\u2081 \u2194 a \u2208 o\u2082) \u2192 o\u2081 = o\u2082\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 \u2194 \u2200 a, a \u2209 o :=\n  \u27e8fun e a h => by rw [e] at h; (cases h), fun h => ext <| by simp; exact h\u27e9\n\n@[simp] theorem isSome_none : @isSome \u03b1 none = false := rfl\n\n@[simp] theorem isSome_some : isSome (some a) = true := rfl\n\ntheorem isSome_iff_exists : isSome x \u2194 \u2203 a, x = some a := by cases x <;> simp [isSome]\n\n@[simp] theorem isNone_none : @isNone \u03b1 none = true := rfl\n\n@[simp] theorem isNone_some : isNone (some a) = false := rfl\n\n@[simp] theorem not_isSome : isSome a = false \u2194 a.isNone = true := by\n  cases a <;> simp\n\ntheorem eq_some_iff_get_eq : o = some a \u2194 \u2203 h : o.isSome, o.get h = a := by\n  cases o <;> simp; intro.\n\ntheorem eq_some_of_isSome : \u2200 {o : Option \u03b1} (h : o.isSome), o = some (o.get h)\n  | some _, _ => rfl\n\ntheorem not_isSome_iff_eq_none : \u00aco.isSome \u2194 o = none := by\n  cases o <;> simp\n\ntheorem ne_none_iff_isSome : o \u2260 none \u2194 o.isSome := by cases o <;> simp\n\ntheorem ne_none_iff_exists : o \u2260 none \u2194 \u2203 x, some x = o := by cases o <;> simp\n\ntheorem ne_none_iff_exists' : o \u2260 none \u2194 \u2203 x, o = some x :=\n  ne_none_iff_exists.trans <| exists_congr fun _ => eq_comm\n\n\n\ntheorem ball_ne_none {p : Option \u03b1 \u2192 Prop} : (\u2200 x (_ : x \u2260 none), p x) \u2194 \u2200 x, p (some x) :=\n  \u27e8fun 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 \u22a2\n      exact this\u27e9\n\n@[simp] theorem bind_some (x : Option \u03b1) : x.bind some = x := by cases x <;> rfl\n\n@[simp] theorem bind_eq_some : x.bind f = some b \u2194 \u2203 a, x = some a \u2227 f a = some b := by\n  cases x <;> simp\n\n@[simp] theorem bind_eq_none {o : Option \u03b1} {f : \u03b1 \u2192 Option \u03b2} :\n    o.bind f = none \u2194 \u2200 b a, a \u2208 o \u2192 b \u2209 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 : \u03b1 \u2192 \u03b2 \u2192 Option \u03b3} (a : Option \u03b1) (b : Option \u03b2) :\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 \u03b1) (f : \u03b1 \u2192 Option \u03b2) (g : \u03b2 \u2192 Option \u03b3) :\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 \u2194 x = some (some a) := by\n  simp\n\ntheorem join_ne_none : x.join \u2260 none \u2194 \u2203 z, x = some (some z) := by\n  simp only [ne_none_iff_exists', join_eq_some, iff_self]\n\ntheorem join_ne_none' : \u00acx.join = none \u2194 \u2203 z, x = some (some z) :=\n  join_ne_none\n\ntheorem join_eq_none : o.join = none \u2194 o = none \u2228 o = some none :=\n  match o with | none | some none | some (some _) => by simp\n\ntheorem bind_id_eq_join {x : Option (Option \u03b1)} : 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 \u2194 \u2203 a, x = some a \u2227 f a = b := by cases x <;> simp\n\ntheorem map_eq_some : f <$> x = some b \u2194 \u2203 a, x = some a \u2227 f a = b := map_eq_some'\n\n@[simp] theorem map_eq_none' : x.map f = none \u2194 x = none := by\n  cases x <;> simp only [map_none', map_some', eq_self_iff_true]\n\ntheorem map_eq_none : f <$> x = none \u2194 x = none := map_eq_none'\n\ntheorem map_eq_bind {x : Option \u03b1} : x.map f = x.bind (some \u2218 f) := by\n  cases x <;> simp [Option.bind]\n\ntheorem map_congr {x : Option \u03b1} (h : \u2200 a \u2208 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 \u03b1) = id := map_id\n\n@[simp] theorem map_map (h : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) (x : Option \u03b1) :\n    (x.map g).map h = x.map (h \u2218 g) := by\n  cases x <;> simp only [map_none', map_some', \u00b7\u2218\u00b7]\n\ntheorem comp_map (h : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) (x : Option \u03b1) : x.map (h \u2218 g) = (x.map g).map h :=\n  (map_map ..).symm\n\n@[simp] theorem map_comp_map (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) :\n    Option.map g \u2218 Option.map f = Option.map (g \u2218 f) := by funext x; simp\n\ntheorem mem_map_of_mem (g : \u03b1 \u2192 \u03b2) (h : a \u2208 x) : g a \u2208 Option.map g x := h.symm \u25b8 map_some' ..\n\ntheorem bind_map_comm {\u03b1 \u03b2} {x : Option (Option \u03b1)} {f : \u03b1 \u2192 \u03b2} :\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 : \u03b1 \u2192 \u03b2} {x : Option (Option \u03b1)} :\n    (x.map (Option.map f)).join = x.join.map f := by cases x <;> simp\n\ntheorem join_join {x : Option (Option (Option \u03b1))} : x.join.join = (x.map join).join := by\n  cases x <;> simp\n\ntheorem mem_of_mem_join {a : \u03b1} {x : Option (Option \u03b1)} (h : a \u2208 x.join) : some a \u2208 x :=\n  h.symm \u25b8 join_eq_some.1 h\n\n@[simp] theorem some_orElse (a : \u03b1) (x : Option \u03b1) : (some a <|> x) = some a := rfl\n\n@[simp] theorem none_orElse (x : Option \u03b1) : (none <|> x) = x := rfl\n\n@[simp] theorem orElse_none (x : Option \u03b1) : (x <|> none) = x := by cases x <;> rfl\n\n@[simp] theorem guard_eq_some [DecidablePred p] : guard p a = some b \u2194 a = b \u2227 p a := by\n  by_cases h : p a <;> simp [Option.guard, h]\n\ntheorem liftOrGet_eq_or_eq {f : \u03b1 \u2192 \u03b1 \u2192 \u03b1} (h : \u2200 a b, f a b = a \u2228 f a b = b) :\n    \u2200 o\u2081 o\u2082, liftOrGet f o\u2081 o\u2082 = o\u2081 \u2228 liftOrGet f o\u2081 o\u2082 = o\u2082\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 \u22a2; exact this\n\n@[simp] theorem liftOrGet_none_left {f} {b : Option \u03b1} : liftOrGet f none b = b := by\n  cases b <;> rfl\n\n@[simp] theorem liftOrGet_none_right {f} {a : Option \u03b1} : liftOrGet f a none = a := by\n  cases a <;> rfl\n\n@[simp] theorem liftOrGet_some_some {f} {a b : \u03b1} :\n  liftOrGet f (some a) (some b) = f a b := rfl\n\ntheorem elim_none (x : \u03b2) (f : \u03b1 \u2192 \u03b2) : none.elim x f = x := rfl\n\ntheorem elim_some (x : \u03b2) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : (some a).elim x f = f a := rfl\n\n@[simp] theorem getD_map (f : \u03b1 \u2192 \u03b2) (x : \u03b1) (o : Option \u03b1) :\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 : \u03b1` if `\u03b1` is nonempty, and otherwise `none`. -/\nnoncomputable def choice (\u03b1 : Type _) : Option \u03b1 :=\n  if h : Nonempty \u03b1 then some (Classical.choice h) else none\n\ntheorem choice_eq {\u03b1 : Type _} [Subsingleton \u03b1] (a : \u03b1) : choice \u03b1 = some a := by\n  simp [choice]\n  rw [dif_pos (\u27e8a\u27e9 : Nonempty \u03b1)]\n  simp; apply Subsingleton.elim\n\ntheorem choice_isSome_iff_nonempty {\u03b1 : Type _} : (choice \u03b1).isSome \u2194 Nonempty \u03b1 :=\n  \u27e8fun h => \u27e8(choice \u03b1).get h\u27e9, fun h => by simp only [choice, dif_pos h, isSome_some]\u27e9\n\nend\n\n@[simp] theorem to_list_some (a : \u03b1) : (a : Option \u03b1).toList = [a] := rfl\n\n@[simp] theorem to_list_none (\u03b1 : Type _) : (none : Option \u03b1).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\u00e9d\u00e9ric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Fr\u00e9d\u00e9ric 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 \u2192\u1d43[R] F} :\n  continuous f \u2194 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 \u21d1(line_map p v : R \u2192\u1d43[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 : \u21d1(homothety x t) = \u03bb y, t \u2022 (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 \u2260 0) : is_open_map $ homothety x t :=\nbegin\n  apply is_open_map.of_inverse (homothety_continuous x t\u207b\u00b9);\n  intros e;\n  simp [\u2190 affine_map.comp_apply, \u2190 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\u2082` says that `\u03bb p : \u03b1 \u00d7 \u03b1, 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 `\u03b1` equipped with the Borel `\u03c3`-algebra, instances for `has_measurable_mul\u2082`\netc require `\u03b1` to have a second countable topology.\n\nWe define separate classes for `has_measurable_div`/`has_measurable_sub`\nbecause on some types (e.g., `\u2115`, `\u211d\u22650\u221e`) division and/or subtraction are not defined as `a * b\u207b\u00b9` /\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\u2082`.\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\u2082`. -/\nclass HasMeasurableAdd (M : Type _) [MeasurableSpace M] [Add M] : Prop where\n  measurable_const_add : \u2200 c : M, Measurable ((\u00b7 + \u00b7) c)\n  measurable_add_const : \u2200 c : M, Measurable (\u00b7 + 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\u2082 (M : Type _) [MeasurableSpace M] [Add M] : Prop where\n  measurable_add : Measurable fun p : M \u00d7 M => p.1 + p.2\n#align has_measurable_add\u2082 HasMeasurableAdd\u2082\n\nexport HasMeasurableAdd\u2082 (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\u2082`. -/\n@[to_additive]\nclass HasMeasurableMul (M : Type _) [MeasurableSpace M] [Mul M] : Prop where\n  measurable_const_mul : \u2200 c : M, Measurable ((\u00b7 * \u00b7) c)\n  measurable_mul_const : \u2200 c : M, Measurable (\u00b7 * 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\u2082]\nclass HasMeasurableMul\u2082 (M : Type _) [MeasurableSpace M] [Mul M] : Prop where\n  measurable_mul : Measurable fun p : M \u00d7 M => p.1 * p.2\n#align has_measurable_mul\u2082 HasMeasurableMul\u2082\n#align has_measurable_add\u2082 HasMeasurableAdd\u2082\n\nexport HasMeasurableMul\u2082 (measurable_mul)\n\nsection Mul\n\nvariable {M \u03b1 : Type _} [MeasurableSpace M] [Mul M] {m : MeasurableSpace \u03b1} {f g : \u03b1 \u2192 M}\n  {\u03bc : Measure \u03b1}\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 \u03bc) (c : M) :\n    AeMeasurable (fun x => c * f x) \u03bc :=\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 \u03bc) (c : M) :\n    AeMeasurable (fun x => f x * c) \u03bc :=\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\u2082 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\u2082 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\u2082 M] (hf : AeMeasurable f \u03bc) (hg : AeMeasurable g \u03bc) :\n    AeMeasurable (f * g) \u03bc :=\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\u2082 M] (hf : AeMeasurable f \u03bc) (hg : AeMeasurable g \u03bc) :\n    AeMeasurable (fun a => f a * g a) \u03bc :=\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\u2082.to_hasMeasurableMul [HasMeasurableMul\u2082 M] :\n    HasMeasurableMul M :=\n  \u27e8fun c => measurable_const.mul measurable_id, fun c => measurable_id.mul measurable_const\u27e9\n#align has_measurable_mul\u2082.to_has_measurable_mul HasMeasurableMul\u2082.to_hasMeasurableMul\n#align has_measurable_add\u2082.to_has_measurable_add HasMeasurableAdd\u2082.to_has_measurable_add\n\n@[to_additive]\ninstance Pi.hasMeasurableMul {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Mul (\u03b1 i)]\n    [\u2200 i, MeasurableSpace (\u03b1 i)] [\u2200 i, HasMeasurableMul (\u03b1 i)] : HasMeasurableMul (\u2200 i, \u03b1 i) :=\n  \u27e8fun 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 _\u27e9\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\u2082]\ninstance Pi.hasMeasurableMul\u2082 {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Mul (\u03b1 i)]\n    [\u2200 i, MeasurableSpace (\u03b1 i)] [\u2200 i, HasMeasurableMul\u2082 (\u03b1 i)] : HasMeasurableMul\u2082 (\u2200 i, \u03b1 i) :=\n  \u27e8measurable_pi_iff.mpr fun i => measurable_fst.eval.mul measurable_snd.eval\u27e9\n#align pi.has_measurable_mul\u2082 Pi.hasMeasurableMul\u2082\n#align pi.has_measurable_add\u2082 Pi.has_measurable_add\u2082\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 `\u03b2 \u00d7 \u03b3 \u2192 \u03b2` given by `(x, y) \u21a6 x ^ y` is measurable. -/\nclass HasMeasurablePow (\u03b2 \u03b3 : Type _) [MeasurableSpace \u03b2] [MeasurableSpace \u03b3] [Pow \u03b2 \u03b3] where\n  measurable_pow : Measurable fun p : \u03b2 \u00d7 \u03b3 => 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\u2082 M] :\n    HasMeasurablePow M \u2115 :=\n  \u27e8measurable_from_prod_countable fun n =>\n      by\n      induction' n with n ih\n      \u00b7 simp only [pow_zero, \u2190 Pi.one_def, measurable_one]\n      \u00b7 simp only [pow_succ]\n        exact measurable_id.mul ih\u27e9\n#align monoid.has_measurable_pow Monoid.hasMeasurablePow\n\nsection Pow\n\nvariable {\u03b2 \u03b3 \u03b1 : Type _} [MeasurableSpace \u03b2] [MeasurableSpace \u03b3] [Pow \u03b2 \u03b3] [HasMeasurablePow \u03b2 \u03b3]\n  {m : MeasurableSpace \u03b1} {\u03bc : Measure \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3}\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 \u03bc) (hg : AeMeasurable g \u03bc) :\n    AeMeasurable (fun x => f x ^ g x) \u03bc :=\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 : \u03b3) : 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 \u03bc) (c : \u03b3) : AeMeasurable (fun x => f x ^ c) \u03bc :=\n  hf.pow aeMeasurableConst\n#align ae_measurable.pow_const AeMeasurable.powConst\n\n@[measurability]\ntheorem Measurable.const_pow (hg : Measurable g) (c : \u03b2) : 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 \u03bc) (c : \u03b2) : AeMeasurable (fun x => c ^ g x) \u03bc :=\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 `(\u03bb x, c - x)` and `(\u03bb x, x - c)` are measurable\nfunctions. For a typeclass assuming measurability of `uncurry (-)` see `has_measurable_sub\u2082`. -/\nclass HasMeasurableSub (G : Type _) [MeasurableSpace G] [Sub G] : Prop where\n  measurable_const_sub : \u2200 c : G, Measurable fun x => c - x\n  measurable_sub_const : \u2200 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\u2082 (G : Type _) [MeasurableSpace G] [Sub G] : Prop where\n  measurable_sub : Measurable fun p : G \u00d7 G => p.1 - p.2\n#align has_measurable_sub\u2082 HasMeasurableSub\u2082\n\nexport HasMeasurableSub\u2082 (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\u2082`. -/\n@[to_additive]\nclass HasMeasurableDiv (G\u2080 : Type _) [MeasurableSpace G\u2080] [Div G\u2080] : Prop where\n  measurable_const_div : \u2200 c : G\u2080, Measurable ((\u00b7 / \u00b7) c)\n  measurable_div_const : \u2200 c : G\u2080, Measurable (\u00b7 / 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\u2082]\nclass HasMeasurableDiv\u2082 (G\u2080 : Type _) [MeasurableSpace G\u2080] [Div G\u2080] : Prop where\n  measurable_div : Measurable fun p : G\u2080 \u00d7 G\u2080 => p.1 / p.2\n#align has_measurable_div\u2082 HasMeasurableDiv\u2082\n#align has_measurable_sub\u2082 HasMeasurableSub\u2082\n\nexport HasMeasurableDiv\u2082 (measurable_div)\n\nsection Div\n\nvariable {G \u03b1 : Type _} [MeasurableSpace G] [Div G] {m : MeasurableSpace \u03b1} {f g : \u03b1 \u2192 G}\n  {\u03bc : Measure \u03b1}\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 \u03bc) (c : G) :\n    AeMeasurable (fun x => c / f x) \u03bc :=\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 \u03bc) (c : G) :\n    AeMeasurable (fun x => f x / c) \u03bc :=\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\u2082 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\u2082 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\u2082 G] (hf : AeMeasurable f \u03bc) (hg : AeMeasurable g \u03bc) :\n    AeMeasurable (f / g) \u03bc :=\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\u2082 G] (hf : AeMeasurable f \u03bc) (hg : AeMeasurable g \u03bc) :\n    AeMeasurable (fun a => f a / g a) \u03bc :=\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\u2082.to_hasMeasurableDiv [HasMeasurableDiv\u2082 G] :\n    HasMeasurableDiv G :=\n  \u27e8fun c => measurable_const.div measurable_id, fun c => measurable_id.div measurable_const\u27e9\n#align has_measurable_div\u2082.to_has_measurable_div HasMeasurableDiv\u2082.to_hasMeasurableDiv\n#align has_measurable_sub\u2082.to_has_measurable_sub HasMeasurableSub\u2082.to_has_measurable_sub\n\n@[to_additive]\ninstance Pi.hasMeasurableDiv {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Div (\u03b1 i)]\n    [\u2200 i, MeasurableSpace (\u03b1 i)] [\u2200 i, HasMeasurableDiv (\u03b1 i)] : HasMeasurableDiv (\u2200 i, \u03b1 i) :=\n  \u27e8fun 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 _\u27e9\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\u2082]\ninstance Pi.hasMeasurableDiv\u2082 {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Div (\u03b1 i)]\n    [\u2200 i, MeasurableSpace (\u03b1 i)] [\u2200 i, HasMeasurableDiv\u2082 (\u03b1 i)] : HasMeasurableDiv\u2082 (\u2200 i, \u03b1 i) :=\n  \u27e8measurable_pi_iff.mpr fun i => measurable_fst.eval.div measurable_snd.eval\u27e9\n#align pi.has_measurable_div\u2082 Pi.hasMeasurableDiv\u2082\n#align pi.has_measurable_sub\u2082 Pi.has_measurable_sub\u2082\n\n@[measurability]\ntheorem measurableSet_eq_fun {m : MeasurableSpace \u03b1} {E} [MeasurableSpace E] [AddGroup E]\n    [MeasurableSingletonClass E] [HasMeasurableSub\u2082 E] {f g : \u03b1 \u2192 E} (hf : Measurable f)\n    (hg : Measurable g) : MeasurableSet { x | f x = g x } :=\n  by\n  suffices h_set_eq : { x : \u03b1 | f x = g x } = { x | (f - g) x = (0 : E) }\n  \u00b7 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\u2082 E] {f g : \u03b1 \u2192 E} (hf : AeMeasurable f \u03bc) (hg : AeMeasurable g \u03bc) :\n    NullMeasurableSet { x | f x = g x } \u03bc :=\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 \u03b1} {E} [MeasurableSpace E]\n    [MeasurableSingletonClass E] [Countable E] {f g : \u03b1 \u2192 E} (hf : Measurable f)\n    (hg : Measurable g) : MeasurableSet { x | f x = g x } :=\n  by\n  have : { x | f x = g x } = \u22c3 j, { x | f x = j } \u2229 { x | g x = j } :=\n    by\n    ext1 x\n    simp only [Set.mem_setOf_eq, Set.mem_union\u1d62, Set.mem_inter_iff, exists_eq_right']\n  rw [this]\n  refine' MeasurableSet.union\u1d62 fun j => MeasurableSet.inter _ _\n  \u00b7 exact hf (measurable_set_singleton j)\n  \u00b7 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 {\u03b1 E} {m m0 : MeasurableSpace \u03b1} {\u03bc : Measure \u03b1}\n    [MeasurableSpace E] [AddGroup E] [MeasurableSingletonClass E] [HasMeasurableSub\u2082 E]\n    (hm : m \u2264 m0) {f g : \u03b1 \u2192 E} (hf : measurable[m] f) (hg : measurable[m] g) (hfg : f =\u1d50[\u03bc] g) :\n    f =\u1da0[@Measure.ae \u03b1 m (\u03bc.trim hm)] g :=\n  by\n  rwa [Filter.EventuallyEq, ae_iff, trim_measurable_set_eq hm _]\n  exact @MeasurableSet.compl \u03b1 _ m (@measurableSet_eq_fun \u03b1 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 \u21a6 -x` is a measurable function. -/\nclass HasMeasurableNeg (G : Type _) [Neg G] [MeasurableSpace G] : Prop where\n  measurable_neg : Measurable (Neg.neg : G \u2192 G)\n#align has_measurable_neg HasMeasurableNeg\n\n/-- We say that a type `has_measurable_inv` if `x \u21a6 x\u207b\u00b9` is a measurable function. -/\n@[to_additive]\nclass HasMeasurableInv (G : Type _) [Inv G] [MeasurableSpace G] : Prop where\n  measurable_inv : Measurable (Inv.inv : G \u2192 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\u207b\u00b9\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 \u03b1 : Type _} [Inv G] [MeasurableSpace G] [HasMeasurableInv G] {m : MeasurableSpace \u03b1}\n  {f : \u03b1 \u2192 G} {\u03bc : Measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem Measurable.inv (hf : Measurable f) : Measurable fun x => (f x)\u207b\u00b9 :=\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 \u03bc) : AeMeasurable (fun x => (f x)\u207b\u00b9) \u03bc :=\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 : \u03b1 \u2192 G} : (Measurable fun x => (f x)\u207b\u00b9) \u2194 Measurable f :=\n  \u27e8fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv\u27e9\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 : \u03b1 \u2192 G} : AeMeasurable (fun x => (f x)\u207b\u00b9) \u03bc \u2194 AeMeasurable f \u03bc :=\n  \u27e8fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv\u27e9\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\u2080 {G\u2080 : Type _} [GroupWithZero G\u2080] [MeasurableSpace G\u2080]\n    [HasMeasurableInv G\u2080] {f : \u03b1 \u2192 G\u2080} : (Measurable fun x => (f x)\u207b\u00b9) \u2194 Measurable f :=\n  \u27e8fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv\u27e9\n#align measurable_inv_iff\u2080 measurable_inv_iff\u2080\n\n@[simp]\ntheorem aeMeasurable_inv_iff\u2080 {G\u2080 : Type _} [GroupWithZero G\u2080] [MeasurableSpace G\u2080]\n    [HasMeasurableInv G\u2080] {f : \u03b1 \u2192 G\u2080} : AeMeasurable (fun x => (f x)\u207b\u00b9) \u03bc \u2194 AeMeasurable f \u03bc :=\n  \u27e8fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv\u27e9\n#align ae_measurable_inv_iff\u2080 aeMeasurable_inv_iff\u2080\n\nomit m\n\n@[to_additive]\ninstance Pi.hasMeasurableInv {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Inv (\u03b1 i)]\n    [\u2200 i, MeasurableSpace (\u03b1 i)] [\u2200 i, HasMeasurableInv (\u03b1 i)] : HasMeasurableInv (\u2200 i, \u03b1 i) :=\n  \u27e8measurable_pi_iff.mpr fun i => (measurable_pi_apply i).inv\u27e9\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\u207b\u00b9 :=\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\u2082 G] [HasMeasurableInv G] : HasMeasurablePow G \u2124 :=\n  \u27e8measurable_from_prod_countable fun n => by\n      cases' n with n n\n      \u00b7 simp_rw [zpow_ofNat]\n        exact measurable_id.pow_const _\n      \u00b7 simp_rw [zpow_negSucc]\n        exact (measurable_id.pow_const (n + 1)).inv\u27e9\n#align div_inv_monoid.has_measurable_zpow DivInvMonoid.hasMeasurableZpow\n\n@[to_additive]\ninstance (priority := 100) hasMeasurableDiv\u2082_of_mul_inv (G : Type _) [MeasurableSpace G]\n    [DivInvMonoid G] [HasMeasurableMul\u2082 G] [HasMeasurableInv G] : HasMeasurableDiv\u2082 G :=\n  \u27e8by\n    simp only [div_eq_mul_inv]\n    exact measurable_fst.mul measurable_snd.inv\u27e9\n#align has_measurable_div\u2082_of_mul_inv hasMeasurableDiv\u2082_of_mul_inv\n#align has_measurable_div\u2082_of_add_neg hasMeasurableDiv\u2082_of_add_neg\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_vadd` if for each `c` the map `x \u21a6 c +\u1d65 x`\nis a measurable function and for each `x` the map `c \u21a6 c +\u1d65 x` is a measurable function. -/\nclass HasMeasurableVadd (M \u03b1 : Type _) [VAdd M \u03b1] [MeasurableSpace M] [MeasurableSpace \u03b1] :\n  Prop where\n  measurable_const_vadd : \u2200 c : M, Measurable ((\u00b7 +\u1d65 \u00b7) c : \u03b1 \u2192 \u03b1)\n  measurable_vadd_const : \u2200 x : \u03b1, Measurable fun c : M => c +\u1d65 x\n#align has_measurable_vadd HasMeasurableVadd\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_smul` if for each `c` the map `x \u21a6 c \u2022 x`\nis a measurable function and for each `x` the map `c \u21a6 c \u2022 x` is a measurable function. -/\n@[to_additive]\nclass HasMeasurableSmul (M \u03b1 : Type _) [SMul M \u03b1] [MeasurableSpace M] [MeasurableSpace \u03b1] :\n  Prop where\n  measurable_const_smul : \u2200 c : M, Measurable ((\u00b7 \u2022 \u00b7) c : \u03b1 \u2192 \u03b1)\n  measurable_smul_const : \u2200 x : \u03b1, Measurable fun c : M => c \u2022 x\n#align has_measurable_smul HasMeasurableSmul\n#align has_measurable_vadd HasMeasurableVadd\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_vadd\u2082` if the map\n`(c, x) \u21a6 c +\u1d65 x` is a measurable function. -/\nclass HasMeasurableVadd\u2082 (M \u03b1 : Type _) [VAdd M \u03b1] [MeasurableSpace M] [MeasurableSpace \u03b1] :\n  Prop where\n  measurable_vadd : Measurable (Function.uncurry (\u00b7 +\u1d65 \u00b7) : M \u00d7 \u03b1 \u2192 \u03b1)\n#align has_measurable_vadd\u2082 HasMeasurableVadd\u2082\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_smul\u2082` if the map\n`(c, x) \u21a6 c \u2022 x` is a measurable function. -/\n@[to_additive HasMeasurableVadd\u2082]\nclass HasMeasurableSmul\u2082 (M \u03b1 : Type _) [SMul M \u03b1] [MeasurableSpace M] [MeasurableSpace \u03b1] :\n  Prop where\n  measurable_smul : Measurable (Function.uncurry (\u00b7 \u2022 \u00b7) : M \u00d7 \u03b1 \u2192 \u03b1)\n#align has_measurable_smul\u2082 HasMeasurableSmul\u2082\n#align has_measurable_vadd\u2082 HasMeasurableVadd\u2082\n\nexport HasMeasurableSmul (measurable_const_smul measurable_smul_const)\n\nexport HasMeasurableSmul\u2082 (measurable_smul)\n\nexport HasMeasurableVadd (measurable_const_vadd measurable_vadd_const)\n\nexport HasMeasurableVadd\u2082 (measurable_vadd)\n\n@[to_additive]\ninstance hasMeasurableSmul_of_mul (M : Type _) [Mul M] [MeasurableSpace M] [HasMeasurableMul M] :\n    HasMeasurableSmul M M :=\n  \u27e8measurable_id.const_mul, measurable_id.mul_const\u27e9\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\u2082_of_mul (M : Type _) [Mul M] [MeasurableSpace M] [HasMeasurableMul\u2082 M] :\n    HasMeasurableSmul\u2082 M M :=\n  \u27e8measurable_mul\u27e9\n#align has_measurable_smul\u2082_of_mul hasMeasurableSmul\u2082_of_mul\n#align has_measurable_smul\u2082_of_add hasMeasurableSmul\u2082_of_add\n\n@[to_additive]\ninstance Submonoid.hasMeasurableSmul {M \u03b1} [MeasurableSpace M] [MeasurableSpace \u03b1] [Monoid M]\n    [MulAction M \u03b1] [HasMeasurableSmul M \u03b1] (s : Submonoid M) : HasMeasurableSmul s \u03b1 :=\n  \u27e8fun c => by simpa only using measurable_const_smul (c : M), fun x =>\n    (measurable_smul_const x : Measurable fun c : M => c \u2022 x).comp measurable_subtype_coe\u27e9\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 \u03b1} [MeasurableSpace G] [MeasurableSpace \u03b1] [Group G]\n    [MulAction G \u03b1] [HasMeasurableSmul G \u03b1] (s : Subgroup G) : HasMeasurableSmul s \u03b1 :=\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 \u03b2 \u03b1 : Type _} [MeasurableSpace M] [MeasurableSpace \u03b2] [SMul M \u03b2] {m : MeasurableSpace \u03b1}\n  {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 \u03b2}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem Measurable.smul [HasMeasurableSmul\u2082 M \u03b2] (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun x => f x \u2022 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\u2082 M \u03b2] {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc)\n    (hg : AeMeasurable g \u03bc) : AeMeasurable (fun x => f x \u2022 g x) \u03bc :=\n  HasMeasurableSmul\u2082.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\u2082.to_hasMeasurableSmul [HasMeasurableSmul\u2082 M \u03b2] :\n    HasMeasurableSmul M \u03b2 :=\n  \u27e8fun c => measurable_const.smul measurable_id, fun y => measurable_id.smul measurable_const\u27e9\n#align has_measurable_smul\u2082.to_has_measurable_smul HasMeasurableSmul\u2082.to_hasMeasurableSmul\n#align has_measurable_vadd\u2082.to_has_measurable_vadd HasMeasurableVadd\u2082.to_has_measurable_vadd\n\ninclude m\n\nvariable [HasMeasurableSmul M \u03b2] {\u03bc : Measure \u03b1}\n\n@[measurability, to_additive]\ntheorem Measurable.smul_const (hf : Measurable f) (y : \u03b2) : Measurable fun x => f x \u2022 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 \u03bc) (y : \u03b2) :\n    AeMeasurable (fun x => f x \u2022 y) \u03bc :=\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 \u2022 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 \u2022 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 \u03bc) (c : M) :\n    AeMeasurable (fun x => c \u2022 g x) \u03bc :=\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 \u03bc) (c : M) : AeMeasurable (c \u2022 g) \u03bc :=\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 {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, SMul M (\u03b1 i)]\n    [\u2200 i, MeasurableSpace (\u03b1 i)] [\u2200 i, HasMeasurableSmul M (\u03b1 i)] :\n    HasMeasurableSmul M (\u2200 i, \u03b1 i) :=\n  \u27e8fun 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 _\u27e9\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\u2082 (M : Type _) [AddMonoid M] [MeasurableSpace M]\n    [HasMeasurableAdd\u2082 M] : HasMeasurableSmul\u2082 \u2115 M :=\n  \u27e8by\n    suffices Measurable fun p : M \u00d7 \u2115 => p.2 \u2022 p.1 by apply this.comp measurable_swap\n    refine' measurable_from_prod_countable fun n => _\n    induction' n with n ih\n    \u00b7 simp only [zero_smul, \u2190 Pi.zero_def, measurable_zero]\n    \u00b7 simp only [succ_nsmul]\n      exact measurable_id.add ih\u27e9\n#align add_monoid.has_measurable_smul_nat\u2082 AddMonoid.has_measurable_smul_nat\u2082\n\n/-- `sub_neg_monoid.has_smul_int` is measurable. -/\ninstance SubNegMonoid.has_measurable_smul_int\u2082 (M : Type _) [SubNegMonoid M] [MeasurableSpace M]\n    [HasMeasurableAdd\u2082 M] [HasMeasurableNeg M] : HasMeasurableSmul\u2082 \u2124 M :=\n  \u27e8by\n    suffices Measurable fun p : M \u00d7 \u2124 => p.2 \u2022 p.1 by apply this.comp measurable_swap\n    refine' measurable_from_prod_countable fun n => _\n    induction' n with n n ih\n    \u00b7 simp only [ofNat_zsmul]\n      exact measurable_const_smul _\n    \u00b7 simp only [negSucc_zsmul]\n      exact (measurable_const_smul _).neg\u27e9\n#align sub_neg_monoid.has_measurable_smul_int\u2082 SubNegMonoid.has_measurable_smul_int\u2082\n\nend Smul\n\nsection MulAction\n\nvariable {M \u03b2 \u03b1 : Type _} [MeasurableSpace M] [MeasurableSpace \u03b2] [Monoid M] [MulAction M \u03b2]\n  [HasMeasurableSmul M \u03b2] [MeasurableSpace \u03b1] {f : \u03b1 \u2192 \u03b2} {\u03bc : Measure \u03b1}\n\nvariable {G : Type _} [Group G] [MeasurableSpace G] [MulAction G \u03b2] [HasMeasurableSmul G \u03b2]\n\n@[to_additive]\ntheorem measurable_const_smul_iff (c : G) : (Measurable fun x => c \u2022 f x) \u2194 Measurable f :=\n  \u27e8fun h => by simpa only [inv_smul_smul] using h.const_smul' c\u207b\u00b9, fun h => h.const_smul c\u27e9\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 \u2022 f x) \u03bc \u2194 AeMeasurable f \u03bc :=\n  \u27e8fun h => by simpa only [inv_smul_smul] using h.const_smul' c\u207b\u00b9, fun h => h.const_smul c\u27e9\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\u02e3 :=\n  MeasurableSpace.comap (coe : M\u02e3 \u2192 M) \u2039_\u203a\n\n@[to_additive]\ninstance Units.hasMeasurableSmul : HasMeasurableSmul M\u02e3 \u03b2\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 \u2022 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 \u2022 f x) \u2194 Measurable f :=\n  let \u27e8u, hu\u27e9 := hc\n  hu \u25b8 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 \u2022 f x) \u03bc \u2194 AeMeasurable f \u03bc :=\n  let \u27e8u, hu\u27e9 := hc\n  hu \u25b8 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\u2080 : Type _} [GroupWithZero G\u2080] [MeasurableSpace G\u2080] [MulAction G\u2080 \u03b2]\n  [HasMeasurableSmul G\u2080 \u03b2]\n\ntheorem measurable_const_smul_iff\u2080 {c : G\u2080} (hc : c \u2260 0) :\n    (Measurable fun x => c \u2022 f x) \u2194 Measurable f :=\n  (IsUnit.mk0 c hc).measurable_const_smul_iff\n#align measurable_const_smul_iff\u2080 measurable_const_smul_iff\u2080\n\ntheorem aeMeasurable_const_smul_iff\u2080 {c : G\u2080} (hc : c \u2260 0) :\n    AeMeasurable (fun x => c \u2022 f x) \u03bc \u2194 AeMeasurable f \u03bc :=\n  (IsUnit.mk0 c hc).aeMeasurable_const_smul_iff\n#align ae_measurable_const_smul_iff\u2080 aeMeasurable_const_smul_iff\u2080\n\nend MulAction\n\n/-!\n### Opposite monoid\n-/\n\n\nsection Opposite\n\nopen MulOpposite\n\n@[to_additive]\ninstance {\u03b1 : Type _} [h : MeasurableSpace \u03b1] : MeasurableSpace \u03b1\u1d50\u1d52\u1d56 :=\n  MeasurableSpace.map op h\n\n@[to_additive]\ntheorem measurable_mul_op {\u03b1 : Type _} [MeasurableSpace \u03b1] : Measurable (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := 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 {\u03b1 : Type _} [MeasurableSpace \u03b1] : Measurable (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) :=\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\u1d50\u1d52\u1d56 :=\n  \u27e8fun c => measurable_mul_op.comp (measurable_mul_unop.mul_const _), fun c =>\n    measurable_mul_op.comp (measurable_mul_unop.const_mul _)\u27e9\n\n@[to_additive]\ninstance {M : Type _} [Mul M] [MeasurableSpace M] [HasMeasurableMul\u2082 M] : HasMeasurableMul\u2082 M\u1d50\u1d52\u1d56 :=\n  \u27e8measurable_mul_op.comp\n      ((measurable_mul_unop.comp measurable_snd).mul (measurable_mul_unop.comp measurable_fst))\u27e9\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance HasMeasurableSmul.op {M \u03b1} [MeasurableSpace M] [MeasurableSpace \u03b1] [SMul M \u03b1] [SMul M\u1d50\u1d52\u1d56 \u03b1]\n    [IsCentralScalar M \u03b1] [HasMeasurableSmul M \u03b1] : HasMeasurableSmul M\u1d50\u1d52\u1d56 \u03b1 :=\n  \u27e8MulOpposite.rec' fun c =>\n      show Measurable fun x => op c \u2022 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) \u2022 x by\n      simpa only [op_smul_eq_smul] using (measurable_smul_const x).comp measurable_mul_unop\u27e9\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\u2082.op {M \u03b1} [MeasurableSpace M] [MeasurableSpace \u03b1] [SMul M \u03b1]\n    [SMul M\u1d50\u1d52\u1d56 \u03b1] [IsCentralScalar M \u03b1] [HasMeasurableSmul\u2082 M \u03b1] : HasMeasurableSmul\u2082 M\u1d50\u1d52\u1d56 \u03b1 :=\n  \u27e8show Measurable fun x : M\u1d50\u1d52\u1d56 \u00d7 \u03b1 => op (unop x.1) \u2022 x.2\n      by\n      simp_rw [op_smul_eq_smul]\n      refine' (measurable_mul_unop.comp measurable_fst).smul measurable_snd\u27e9\n#align has_measurable_smul\u2082.op HasMeasurableSmul\u2082.op\n\n@[to_additive]\ninstance hasMeasurableSmul_opposite_of_mul {M : Type _} [Mul M] [MeasurableSpace M]\n    [HasMeasurableMul M] : HasMeasurableSmul M\u1d50\u1d52\u1d56 M :=\n  \u27e8fun c => measurable_mul_const (unop c), fun x => measurable_mul_unop.const_mul x\u27e9\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\u2082_opposite_of_mul {M : Type _} [Mul M] [MeasurableSpace M]\n    [HasMeasurableMul\u2082 M] : HasMeasurableSmul\u2082 M\u1d50\u1d52\u1d56 M :=\n  \u27e8measurable_snd.mul (measurable_mul_unop.comp measurable_fst)\u27e9\n#align has_measurable_smul\u2082_opposite_of_mul hasMeasurableSmul\u2082_opposite_of_mul\n#align has_measurable_smul\u2082_opposite_of_add hasMeasurableSmul\u2082_opposite_of_add\n\nend Opposite\n\n/-!\n### Big operators: `\u220f` and `\u2211`\n-/\n\n\nsection Monoid\n\nvariable {M \u03b1 : Type _} [Monoid M] [MeasurableSpace M] [HasMeasurableMul\u2082 M] {m : MeasurableSpace \u03b1}\n  {\u03bc : Measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem List.measurable_prod' (l : List (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, Measurable f) : Measurable l.Prod :=\n  by\n  induction' l with f l ihl; \u00b7 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 (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, AeMeasurable f \u03bc) :\n    AeMeasurable l.Prod \u03bc := by\n  induction' l with f l ihl; \u00b7 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 (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, Measurable f) :\n    Measurable fun x => (l.map fun f : \u03b1 \u2192 M => f x).Prod := by\n  simpa only [\u2190 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 (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => (l.map fun f : \u03b1 \u2192 M => f x).Prod) \u03bc := by\n  simpa only [\u2190 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 \u03b9 \u03b1 : Type _} [CommMonoid M] [MeasurableSpace M] [HasMeasurableMul\u2082 M]\n  {m : MeasurableSpace \u03b1} {\u03bc : Measure \u03b1} {f : \u03b9 \u2192 \u03b1 \u2192 M}\n\ninclude m\n\n@[measurability, to_additive]\ntheorem Multiset.measurable_prod' (l : Multiset (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, Measurable f) :\n    Measurable l.Prod := by\n  rcases l with \u27e8l\u27e9\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 (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, AeMeasurable f \u03bc) :\n    AeMeasurable l.Prod \u03bc := by\n  rcases l with \u27e8l\u27e9\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 (\u03b1 \u2192 M)) (hs : \u2200 f \u2208 s, Measurable f) :\n    Measurable fun x => (s.map fun f : \u03b1 \u2192 M => f x).Prod := by\n  simpa only [\u2190 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 (\u03b1 \u2192 M)) (hs : \u2200 f \u2208 s, AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => (s.map fun f : \u03b1 \u2192 M => f x).Prod) \u03bc := by\n  simpa only [\u2190 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 \u03b9) (hf : \u2200 i \u2208 s, Measurable (f i)) :\n    Measurable (\u220f 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 \u03b9) (hf : \u2200 i \u2208 s, Measurable (f i)) :\n    Measurable fun a => \u220f i in s, f i a := by\n  simpa only [\u2190 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 \u03b9) (hf : \u2200 i \u2208 s, AeMeasurable (f i) \u03bc) :\n    AeMeasurable (\u220f i in s, f i) \u03bc :=\n  Multiset.aeMeasurableProd' _ fun g hg =>\n    let \u27e8i, hi, hg\u27e9 := Multiset.mem_map.1 hg\n    hg \u25b8 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 \u03b9) (hf : \u2200 i \u2208 s, AeMeasurable (f i) \u03bc) :\n    AeMeasurable (fun a => \u220f i in s, f i a) \u03bc := by\n  simpa only [\u2190 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\u2081 u\u2082 u\u2083 u\u2084\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 \u2192 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 : \u2115 \u2192 Type* \u2192 Type*\n  | 0     X := X\n  | (n+1) X := loop (loopn n X)\n\n  notation `\u03a9` := loop\n  notation `\u03a9[`:95 n:0 `]`:0 := loopn n\n\n  @[hott] def is_trunc_pointed_MK (n : \u2115\u208b\u2082) {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 : \u2115\u208b\u2082) [H : is_trunc (n.+1) A] : is_trunc n (\u03a9 A) :=\n  is_trunc_eq _ _ _\n\n  @[hott] def loopn_zero_eq (A : Type*)\n    : \u03a9[0] A = A := rfl\n\n  @[hott] def loopn_succ_eq (k : \u2115) (A : Type*)\n    : \u03a9[succ k] A = \u03a9 (\u03a9[k] A) := rfl\n\n  @[hott,reducible] def rfln  {n : \u2115} {A : Type*} : \u03a9[n] A := pt\n  @[hott,reducible] def refln (n : \u2115) (A : Type*) : \u03a9[n] A := Point _\n  @[hott] def refln_eq_refl (A : Type*) (n : \u2115) : rfln = rfl :> \u03a9[succ n] A := rfl\n\n  @[hott] def loopn_space (A : Type _) [H : pointed A] (n : \u2115) : Type _ :=\n  \u03a9[n] (pointed.mk' A)\n\n  @[hott] def loop_mul {k : \u2115} {A : Type*} (mul : A \u2192 A \u2192 A) : \u03a9[k] A \u2192 \u03a9[k] A \u2192 \u03a9[k] A :=\n  begin cases k with k, exact mul, exact concat end\n\n  @[hott] def pType_eq {A B : Type*} (f : A \u2243 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 [\u2190cast_def, cast_ua], exact p },\n  end\n\n  @[hott] def pType_eq_elim {A B : Type*} (p : A = B :> Type*)\n    : \u03a3(p : carrier A = carrier B :> Type _), Point A =[p; \u03bbX, X] Point B :=\n  by induction p; exact \u27e8idp, idpo\u27e9\n\n  @[hott] protected def pType.sigma_char : pType.{u} \u2243 \u03a3(X : Type u), X :=\n  begin\n    fapply equiv.MK,\n    { intro x, induction x with X x, exact \u27e8X, x\u27e9},\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 `\u208a`:(max+1) := add_point\n  -- the inclusion A \u2192 A\u208a 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 : \u2115\u208b\u2082} {A B : n-Type*}\n    (p : \u21a5A = \u21a5B) (q : Point (\u2191A) =[p; \u03bbX, X] Point (\u2191B)) : A = B :=\n  begin\n    induction A with A HA, induction B with B HB, \n    induction A with A a\u2080, induction B with B b\u2080, 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 : \u2115\u208b\u2082} {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 : \u2115\u208b\u2082} (A : n-Type*) : is_trunc n A :=\n  trunctype.struct A\n\nend pointed open pointed\n\nnamespace pointed\n  variables {A : pType.{u\u2081}} {B : pType.{u\u2082}} {C : pType.{u\u2083}} {D : pType.{u\u2084}}\n            {f g h : A \u2192* B} {P : A \u2192 Type _} {p\u2080 : P pt} {k k' l m : ppi P p\u2080}\n\n  /- categorical properties of pointed maps -/\n\n  @[hott, refl] def pid (A : Type*) : A \u2192* A :=\n  pmap.mk id idp\n\n  @[hott, trans] def pcompose {A B C : Type*} (g : B \u2192* C) (f : A \u2192* B) : A \u2192* C :=\n  pmap.mk (\u03bba, g (f a)) (ap g (respect_pt f) \u2b1d respect_pt g)\n\n  infixr ` \u2218* `:60 := pcompose\n\n  @[hott] def pmap_of_map {A B : Type _} (f : A \u2192 B) (a : A) :\n    pointed.MK A a \u2192* pointed.MK B (f a) :=\n  pmap.mk f idp\n\n  @[hott, hsimp] def respect_pt_pcompose {A B C : Type*} (g : B \u2192* C) (f : A \u2192* B)\n    : respect_pt (g \u2218* f) = ap g (respect_pt f) \u2b1d respect_pt g :=\n  idp\n\n  @[hott] def passoc (h : C \u2192* D) (g : B \u2192* C) (f : A \u2192* B) : (h \u2218* g) \u2218* f ~* h \u2218* (g \u2218* f) :=\n  phomotopy.mk (\u03bba, idp)\n    begin abstract {\n      refine (idp_con _ \u2b1d whisker_right _ (ap_con _ _ _ \u2b1d whisker_right _ _) \u2b1d (con.assoc _ _ _)),\n      exact ap_compose' h g (respect_pt f)\n    } end\n\n  @[hott] def pid_pcompose (f : A \u2192* B) : pid B \u2218* f ~* f :=\n  begin\n    fapply phomotopy.mk,\n    { intro a, reflexivity},\n    { reflexivity}\n  end\n\n  @[hott] def pcompose_pid (f : A \u2192* B) : f \u2218* 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 \u2192 Type _) (b\u2080 : B pt) :\n    ppi B b\u2080 \u2243 \u03a3(k : \u03a0a, B a), k pt = b\u2080 :=\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 \u2192* B) \u2243 \u03a3(f : A \u2192 B), f pt = pt :=\n  ppi.sigma_char _ _\n\n  @[hott] def pmap.eta_expand {A B : Type*} (f : A \u2192* B) : A \u2192* B :=\n  pmap.mk f (respect_pt f)\n\n  @[hott] def pmap_equiv_right (A : Type*) (B : Type _)\n    : (\u03a3(b : B), A \u2192* (pointed.Mk b)) \u2243 (A \u2192 B) :=\n  begin\n    fapply equiv.MK,\n    { intros u a, exact u.2 a},\n    { intro f, refine \u27e8f pt, _\u27e9, 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 \u2192* 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 (\u03bba, B)\n\n  @[hott] def pcast {A B : Type*} (p : A = B) : A \u2192* B :=\n  pmap.mk (cast (ap pType.carrier p)) (by induction p; reflexivity)\n\n  @[hott] def pinverse (X : Type*) : \u03a9 X \u2192* \u03a9 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 \u2192 B) {a a' : A}\n    {b b' : B} (q : f a = b) (q' : f a' = b') (p : a = a') : b = b' :=\n  q\u207b\u00b9 \u2b1d ap f p \u2b1d q'\n\n  @[hott] def ap1_gen_idp {A B : Type _} (f : A \u2192 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 \u2192 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 \u2192 B) {a : A} (p : a = a) (q : ap f p = idp) :\n    ap1_gen_idp_left f p \u2b1d q = ap (concat idp) q :=\n  idp_con_idp q\n\n  @[hott] def ap1 (f : A \u2192* B) : \u03a9 A \u2192* \u03a9 B :=\n  pmap.mk (\u03bbp, ap1_gen f (respect_pt f) (respect_pt f) p) (ap1_gen_idp f (respect_pt f))\n\n  @[hott] def apn (n : \u2115) (f : A \u2192* B) : \u03a9[n] A \u2192* \u03a9[n] B :=\n  begin\n  induction n with n IH,\n  { exact f },\n  { exact ap1 IH }\n  end\n\n  notation `\u03a9\u2192`:(max+5) := ap1\n  notation `\u03a9\u2192[`:95 n:0 `]`:0 := apn n\n\n  @[hott] def ptransport {A : Type _} (B : A \u2192 Type*) {a a' : A} (p : a = a')\n    : B a \u2192* B a' :=\n  pmap.mk (transport _ p) (apdt (\u03bba, 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 \u2192* pointed.MK A a' :=\n  pmap.mk id p\n\n  @[hott] def pbool_pmap {A : Type*} (a : A) : pbool \u2192* A :=\n  pmap.mk (\u03bbb, bool.rec pt a b) idp\n\n  /- properties of pointed maps -/\n\n  @[hott] def apn_zero (f : A \u2192* B) : \u03a9\u2192[0] f = f := idp\n  @[hott] def apn_succ (n : \u2115) (f : A \u2192* B) : \u03a9\u2192[n + 1] f = \u03a9\u2192 (\u03a9\u2192[n] f) := idp\n\n  @[hott] def ap1_gen_con {A B : Type _} (f : A \u2192 B) {a\u2081 a\u2082 a\u2083 : A} {b\u2081 b\u2082 b\u2083 : B}\n    (q\u2081 : f a\u2081 = b\u2081) (q\u2082 : f a\u2082 = b\u2082) (q\u2083 : f a\u2083 = b\u2083) (p\u2081 : a\u2081 = a\u2082) (p\u2082 : a\u2082 = a\u2083) :\n    ap1_gen f q\u2081 q\u2083 (p\u2081 \u2b1d p\u2082) = ap1_gen f q\u2081 q\u2082 p\u2081 \u2b1d ap1_gen f q\u2082 q\u2083 p\u2082 :=\n  begin induction p\u2082, induction q\u2083, induction q\u2082, reflexivity end\n\n  @[hott] def ap1_gen_inv {A B : Type _} (f : A \u2192 B) {a\u2081 a\u2082 : A}\n    {b\u2081 b\u2082 : B} (q\u2081 : f a\u2081 = b\u2081) (q\u2082 : f a\u2082 = b\u2082) (p\u2081 : a\u2081 = a\u2082) :\n    ap1_gen f q\u2082 q\u2081 p\u2081\u207b\u00b9 = (ap1_gen f q\u2081 q\u2082 p\u2081)\u207b\u00b9 :=\n  begin induction p\u2081, induction q\u2081, induction q\u2082, reflexivity end\n\n  @[hott] def ap1_con {A B : Type*} (f : A \u2192* B) (p q : \u03a9 A) : ap1 f (p \u2b1d q) = ap1 f p \u2b1d 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 \u2192* B) (p : \u03a9 A) : ap1 f p\u207b\u00b9 = (ap1 f p)\u207b\u00b9 :=\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 \u2192 B) {a\u2081 a\u2082 a\u2083 : A} {p\u2081 p\u2081' : a\u2081 = a\u2082}\n    {p\u2082 p\u2082' : a\u2082 = a\u2083}\n    {b\u2081 b\u2082 b\u2083 : B} (q\u2081 : f a\u2081 = b\u2081) (q\u2082 : f a\u2082 = b\u2082) (q\u2083 : f a\u2083 = b\u2083)\n    (r\u2081 : p\u2081 = p\u2081') (r\u2082 : p\u2082 = p\u2082') :\n      square (ap1_gen_con f q\u2081 q\u2082 q\u2083 p\u2081 p\u2082)\n             (ap1_gen_con f q\u2081 q\u2082 q\u2083 p\u2081' p\u2082')\n             (ap (ap1_gen f q\u2081 q\u2083) (r\u2081 \u25fe r\u2082))\n             (ap (ap1_gen f q\u2081 q\u2082) r\u2081 \u25fe ap (ap1_gen f q\u2082 q\u2083) r\u2082) :=\n  begin induction r\u2081, induction r\u2082, exact vrfl end\n\n  @[hott] def ap1_gen_con_idp {A B : Type _} (f : A \u2192 B) {a : A} {b : B} (q : f a = b) :\n    ap1_gen_con f q q q idp idp \u2b1d con.left_inv q \u25fe con.left_inv q = con.left_inv q :=\n  by induction q; reflexivity\n\n  @[hott] def apn_con (n : \u2115) (f : A \u2192* B) (p q : \u03a9[succ n] A)\n    : (\u03a9\u2192[succ n] f) (p \u2b1d q) = (\u03a9\u2192[succ n] f) p \u2b1d (\u03a9\u2192[succ n] f) q :=\n  ap1_con (\u03a9\u2192[n] f) p q\n\n  @[hott] def apn_inv (n : \u2115) (f : A \u2192* B) (p : \u03a9[succ n] A) :\n    \u03a9\u2192[succ n] f p\u207b\u00b9\u1d56 = (\u03a9\u2192[succ n] f p)\u207b\u00b9\u1d56 :=\n  ap1_inv (\u03a9\u2192[n] f) p\n\n  @[hott] def is_equiv_ap1 (f : A \u2192* 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 _)\u207b\u00b9, apply_instance\n  end\n\n  @[hott] def is_equiv_apn (n : \u2115) (f : A \u2192* B) [H : is_equiv f]\n    : is_equiv (\u03a9\u2192[n] f) :=\n  begin\n    induction n with n IH,\n    { exact H },\n    { exact @is_equiv_ap1 _ _ (\u03a9\u2192[n] f) IH }\n  end\n\n  @[hott] def pinverse_con {X : Type*} (p q : \u03a9 X)\n    : pinverse X (p \u2b1d q) = pinverse X q \u2b1d pinverse X p :=\n  con_inv p q\n\n  @[hott] def pinverse_inv {X : Type*} (p : \u03a9 X)\n    : pinverse X p\u207b\u00b9 = (pinverse X p)\u207b\u00b9 :=\n  idp\n\n  @[hott] def ap1_pcompose_pinverse {X Y : Type*} (f : X \u2192* Y) :\n    \u03a9\u2192 f \u2218* pinverse X ~* pinverse Y \u2218* \u03a9\u2192 f :=\n  phomotopy.mk (ap1_gen_inv f (respect_pt f) (respect_pt f))\n    begin\n      induction Y with Y y\u2080, induction f with f f\u2080, dsimp at f f\u2080, induction f\u2080,\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\u207b\u00b9\u02b0\u1d57\u02b8 (inv_con_eq_of_eq_con (to_homotopy_pt p)\u207b\u00b9)\n\n  @[hott, trans] protected def phomotopy.trans (p : k ~* l) (q : l ~* m) :\n    k ~* m :=\n  phomotopy.mk (\u03bba, p a \u2b1d q a) (con.assoc _ _ _ \u2b1d whisker_left (p pt) (to_homotopy_pt q) \u2b1d to_homotopy_pt p)\n\n  infix ` \u2b1d* `:75 := phomotopy.trans\n  postfix `\u207b\u00b9*`:(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 \u2192 Type _)\n    (H : \u03a0(h : k ~ l) (p : h pt \u2b1d 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 (\u03bbp, 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 : \u2115\u208b\u2082) {A : Type*} (B : A \u2192 Type _) (b\u2080 : B pt) [\u03a0a, is_trunc n (B a)] :\n    is_trunc n (ppi B b\u2080) :=\n  is_trunc_equiv_closed_rev _ (ppi.sigma_char _ _) (by infer)\n\n  @[hott, instance] def is_trunc_pmap (n : \u2115\u208b\u2082) (A B : Type*) [is_trunc n B] :\n    is_trunc n (A \u2192* B) :=\n  is_trunc_ppi _ _ _\n\n  @[hott, instance] def is_trunc_ppmap (n : \u2115\u208b\u2082) {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\u2080) : 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 \u2b1d* phomotopy_of_eq q\n\n  @[hott] def eq_pconcat (p : k = l) (q : l ~* m) : k ~* m :=\n  phomotopy_of_eq p \u2b1d* q\n\n  infix ` \u2b1d*p `:75 := pconcat_eq\n  infix ` \u2b1dp* `: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 \u2192* C) (p : f ~* g) : h \u2218* f ~* h \u2218* g :=\n  phomotopy.mk (\u03bba, ap h (p a))\n    begin abstract {exact con.assoc' _ _ _ \u2b1d whisker_right _ ((ap_con _ _ _)\u207b\u00b9 \u2b1d ap02 _ (to_homotopy_pt p))} end\n\n  @[hott] def pwhisker_right (h : C \u2192* A) (p : f ~* g) : f \u2218* h ~* g \u2218* h :=\n  phomotopy.mk (\u03bbc, p (h c))\n    (by abstract {exact con.assoc' _ _ _ \u2b1d whisker_right _ (ap_con_eq_con_ap _ _)\u207b\u00b9 \u2b1d\n       con.assoc _ _ _ \u2b1d whisker_left _ (to_homotopy_pt p)})\n\n  @[hott] def pconcat2 {A B C : Type*} {h i : B \u2192* C} {f g : A \u2192* B}\n    (q : h ~* i) (p : f ~* g) : h \u2218* f ~* i \u2218* g :=\n  pwhisker_left _ p \u2b1d* pwhisker_right _ q\n\n  variables (k l)\n\n  @[hott] def phomotopy.sigma_char\n    : (k ~* l) \u2243 \u03a3(p : k ~ l), p pt \u2b1d respect_pt l = respect_pt k :=\n  begin\n    fapply equiv.MK, all_goals {intros h},\n    { exact \u27e8h , to_homotopy_pt h\u27e9 },\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) \u2243 (k ~* l) :=\n    calc (k = l) \u2243 ppi.sigma_char P p\u2080 k = ppi.sigma_char P p\u2080 l\n                   : eq_equiv_fn_eq (ppi.sigma_char P p\u2080) k l\n            ...  \u2243 \u03a3(p : k = l :> \u03a0a, P a),\n                     respect_pt k =[p; \u03bb(h : \u03a0a, P a), h pt = p\u2080] respect_pt l\n                   : sigma_eq_equiv _ _\n            ...  \u2243 \u03a3(p : k = l :> \u03a0a, P a),\n                     respect_pt k = ap (\u03bb(h : \u03a0a, P a), h pt) p \u2b1d respect_pt l\n                   : sigma_equiv_sigma_right\n                       (\u03bbp, eq_pathover_equiv_Fl p (respect_pt k) (respect_pt l))\n            ...  \u2243 \u03a3(p : k = l :> \u03a0a, P a),\n                     respect_pt k = apd10 p pt \u2b1d respect_pt l\n                   : sigma_equiv_sigma_right\n                       (\u03bbp, equiv_eq_closed_right _ (whisker_right _ (ap_eq_apd10 p _)))\n            ...  \u2243 \u03a3(p : k ~ l), respect_pt k = p pt \u2b1d respect_pt l\n                   : sigma_equiv_sigma_left' (\u03bb(p : k ~ l), respect_pt k = p pt \u2b1d respect_pt l) (eq_equiv_homotopy k l)\n            ...  \u2243 \u03a3(p : k ~ l), p pt \u2b1d respect_pt l = respect_pt k\n                   : sigma_equiv_sigma_right (\u03bbp, eq_equiv_eq_symm _ _)\n            ...  \u2243 (k ~* l) : (phomotopy.sigma_char k l)\u207b\u00b9\u1d49\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\u2080,\n    induction k\u2080, reflexivity\n  end\n\n  @[hott] def ppi_eq_equiv : (k = l) \u2243 (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 \u2192* B) : (f = g) \u2243 (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\u2080) : 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) [\u03a0a, 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 [\u03a0a, 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') \u2192 Type _} (p : k ~* k')\n    (H : \u03a0(q : k = k'), Q (phomotopy_of_eq q)) : Q p :=\n  phomotopy_of_eq_of_phomotopy p \u25b8 H (eq_of_phomotopy p)\n\n  @[hott, induction, reducible] def phomotopy_rec_idp {Q : \u03a0 {k' : ppi P p\u2080}, (k ~* k') \u2192 Type _}\n    {k' : ppi P p\u2080} (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 \u25b8 q,\n  end\n\n  @[hott] def phomotopy_rec_idp' (Q : \u03a0 \u2983k' : ppi P p\u2080\u2984, (k ~* k') \u2192 (k = k') \u2192 Type _)\n    (q : Q phomotopy.rfl idp) \u2983k' : ppi P p\u2080\u2984 (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 _)\u207b\u00b9 q\n  end\n\n  @[hott] theorem phomotopy_rec_eq_phomotopy_of_eq {Q : (k ~* l) \u2192 Type _} (p : k = l)\n    (H : \u03a0(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 _) _ \u2b1d _,\n    refine tr_ap _ _ _ _ \u2b1d _,\n    apply apdt\n  end\n\n  @[hott] def phomotopy_rec_idp_refl {Q : \u03a0{l}, (k ~* l) \u2192 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 : \u03a0 \u2983k' : ppi P p\u2080\u2984, (k ~* k') \u2192 (k = k') \u2192 Type _)\n    (q : Q phomotopy.rfl idp) :\n    phomotopy_rec_idp' Q q phomotopy.rfl = transport (Q phomotopy.rfl) (eq_of_phomotopy_refl _)\u207b\u00b9 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\u2080) [\u03a0a, is_contr (P a)] :\n    k ~* l :=\n  phomotopy.mk (\u03bba, eq_of_is_contr _ _) (eq_of_is_contr _ _)\n\n  @[hott] def phomotopy_of_is_contr_cod_pmap (f g : A \u2192* 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\u2080) [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 _ _) \u2b1dop respect_pt k \u2b1d (respect_pt l)\u207b\u00b9 \u2b1do 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 (-)\u208a : Type _ \u2192 Type* and pType.carrier : Type* \u2192 Type _  -/\n  @[hott] def pmap_equiv_left (A : Type _) (B : Type*) : A\u208a \u2192* B \u2243 (A \u2192 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\u207b\u00b9, 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 \u2192* B) \u2243 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\u207b\u00b9, 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 \u2192* B) \u2192 (C \u2192* D)) {f g : A \u2192* 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 \u2192* B) \u2192 (C \u2192* D)) (f : A \u2192* 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 \u2192* B} (p : f ~* g) : \u03a9\u2192 f ~* \u03a9\u2192 g :=\n  pap \u03a9\u2192 p\n\n  @[hott] def ap1_phomotopy_refl {X Y : Type*} (f : X \u2192* Y) :\n    ap1_phomotopy (phomotopy.refl f) = phomotopy.refl (\u03a9\u2192 f) :=\n  pap_refl _ _\n\n  --a proof not using function extensionality:\n  @[hott] def ap1_phomotopy_explicit {f g : A \u2192* B} (p : f ~* g) : \u03a9\u2192 f ~* \u03a9\u2192 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 _ \u2b1d (idp_con _)\u207b\u00b9, \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 \u2192* B} (n : \u2115) (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 \u2192* B} (p : f ~* g) (a : A) :\n    ap (\u03bbf : A \u2192* 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 \u2192* 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 (\u03bbx, 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 \u2192* B} (p : f ~* g) :\n    ap \u03a9\u2192 (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 _) \u2b1d (eq_of_phomotopy_refl _)\u207b\u00b9 \u2b1d ap eq_of_phomotopy _,\n    exact (ap1_phomotopy_refl _)\u207b\u00b9\n  end\n\n  /- pointed homotopies between the given pointed maps -/\n\n  @[hott] def ap1_pid {A : Type*} : ap1 (pid A) ~* pid (\u03a9 A) :=\n  begin\n    fapply phomotopy.mk,\n    { intro p, refine idp_con _ \u2b1d ap_id _ },\n    { refl }\n  end\n\n  @[hott] def ap1_pinverse {A : Type*} : ap1 (@pinverse A) ~* @pinverse (\u03a9 A) :=\n  begin\n    fapply phomotopy.mk,\n    { intro p, refine idp_con _ \u2b1d _, exact (inv_eq_inv2 _)\u207b\u00b9 },\n    { refl }\n  end\n\n  @[hott] def ap1_gen_compose {A B C : Type _} (g : B \u2192 C) (f : A \u2192 B) {a\u2081 a\u2082 : A} {b\u2081 b\u2082 : B}\n    {c\u2081 c\u2082 : C} (q\u2081 : f a\u2081 = b\u2081) (q\u2082 : f a\u2082 = b\u2082) (r\u2081 : g b\u2081 = c\u2081) (r\u2082 : g b\u2082 = c\u2082) (p : a\u2081 = a\u2082) :\n    ap1_gen (g \u2218 f) (ap g q\u2081 \u2b1d r\u2081) (ap g q\u2082 \u2b1d r\u2082) p = ap1_gen g r\u2081 r\u2082 (ap1_gen f q\u2081 q\u2082 p) :=\n  begin induction p, induction q\u2081, induction q\u2082, induction r\u2081, induction r\u2082, reflexivity end\n\n  @[hott] def ap1_gen_compose_idp {A B C : Type _} (g : B \u2192 C) (f : A \u2192 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 \u2b1d (ap (ap1_gen g r r) (ap1_gen_idp f q) \u2b1d ap1_gen_idp g r) =\n    ap1_gen_idp (g \u2218 f) (ap g q \u2b1d r) :=\n  begin induction q, induction r, reflexivity end\n\n  @[hott] def ap1_pcompose {A B C : Type*} (g : B \u2192* C) (f : A \u2192* B) :\n    ap1 (g \u2218* f) ~* ap1 g \u2218* 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*) : \u03a9\u2192(pconst A B) ~* pconst (\u03a9 A) (\u03a9 B) :=\n  phomotopy.mk (\u03bbp, ap1_gen_idp_left (const A pt) p \u2b1d ap_constant p pt) rfl\n\n  @[hott] def ap1_gen_con_left {A B : Type _} {a a' : A} {b\u2080 b\u2081 b\u2082 : B}\n    {f : A \u2192 b\u2080 = b\u2081} {f' : A \u2192 b\u2081 = b\u2082} {q\u2080 q\u2081 : b\u2080 = b\u2081} {q\u2080' q\u2081' : b\u2081 = b\u2082}\n    (r\u2080 : f a = q\u2080) (r\u2081 : f a' = q\u2081) (r\u2080' : f' a = q\u2080') (r\u2081' : f' a' = q\u2081') (p : a = a') :\n      ap1_gen (\u03bba, f a \u2b1d f' a) (r\u2080 \u25fe r\u2080') (r\u2081 \u25fe r\u2081') p =\n      whisker_right q\u2080' (ap1_gen f r\u2080 r\u2081 p) \u2b1d whisker_left q\u2081 (ap1_gen f' r\u2080' r\u2081' p) :=\n  begin induction r\u2080, induction r\u2081, induction r\u2080', induction r\u2081', induction p, reflexivity end\n\n  @[hott] def ap1_gen_con_left_idp {A B : Type _} {a : A} {b\u2080 b\u2081 b\u2082 : B}\n    {f : A \u2192 b\u2080 = b\u2081} {f' : A \u2192 b\u2081 = b\u2082} {q\u2080 : b\u2080 = b\u2081} {q\u2081 : b\u2081 = b\u2082}\n    (r\u2080 : f a = q\u2080) (r\u2081 : f' a = q\u2081) :\n      ap1_gen_con_left r\u2080 r\u2080 r\u2081 r\u2081 idp =\n      con.left_inv _ \u2b1d (ap (whisker_right q\u2081) (con.left_inv _) \u25fe ap (whisker_left _) (con.left_inv _))\u207b\u00b9 :=\n  begin induction r\u2080, induction r\u2081, reflexivity end\n\n  @[hott] def ptransport_change_eq {A : Type _} (B : A \u2192 Type*) {a a' : A} {p q : a = a'}\n    (r : p = q) : ptransport B p ~* ptransport B q :=\n  phomotopy.mk (\u03bbb, ap (\u03bbp, transport (\u03bba, B a) p b) r) begin induction r, apply idp_con end\n\n  @[hott] def pnatural_square {A B : Type _} (X : B \u2192 Type*) {f g : A \u2192 B}\n    (h : \u03a0a, X (f a) \u2192* X (g a)) {a a' : A} (p : a = a') :\n    h a' \u2218* ptransport X (ap f p) ~* ptransport X (ap g p) \u2218* h a :=\n  by induction p; exact pcompose_pid _ \u2b1d* (pid_pcompose _)\u207b\u00b9*\n\n  @[hott] def apn_pid {A : Type*} (n : \u2115) : apn n (pid A) ~* pid (\u03a9[n] A) :=\n  begin\n    induction n with n IH,\n    { reflexivity},\n    { exact ap1_phomotopy IH \u2b1d* ap1_pid}\n  end\n\n  @[hott] def apn_pconst (A B : Type*) (n : \u2115) :\n    apn n (pconst A B) ~* pconst (\u03a9[n] A) (\u03a9[n] B) :=\n  begin\n    induction n with n IH,\n    { reflexivity },\n    { exact ap1_phomotopy IH \u2b1d* ap1_pconst _ _ }\n  end\n\n  @[hott] def apn_pcompose (n : \u2115) (g : B \u2192* C) (f : A \u2192* B) :\n    apn n (g \u2218* f) ~* apn n g \u2218* apn n f :=\n  begin\n    induction n with n IH,\n    { reflexivity},\n    { refine ap1_phomotopy IH \u2b1d* _, 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 \u2218* pinverse A ~* pid (\u03a9 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 \u03a9 p) ~* ap1 (pcast p) :=\n  begin\n    fapply phomotopy.mk,\n    { intro a, induction p, symmetry, exact idp_con _ \u2b1d ap_id _ },\n    { induction p, refl }\n  end\n\n  @[hott] def ap1_pmap_of_map {A B : Type _} (f : A \u2192 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 \u2192 Type*} (f : \u03a0a, B a \u2192* C a)\n    {a\u2081 a\u2082 : A} (p : a\u2081 = a\u2082) : pcast (ap C p) \u2218* f a\u2081 ~* f a\u2082 \u2218* pcast (ap B p) :=\n  phomotopy.mk\n    begin induction p, reflexivity end\n    begin induction p, refine idp_con _ \u2b1d idp_con _ \u2b1d _, symmetry, apply ap_id end\n\n  /- pointed equivalences -/\n\n  structure pequiv (A B : Type*) :=\n  mk' :: (to_pmap : A \u2192* B)\n         (to_pinv1 : B \u2192* A)\n         (to_pinv2 : B \u2192* A)\n         (pright_inv : to_pmap \u2218* to_pinv1 ~* pid B)\n         (pleft_inv : to_pinv2 \u2218* to_pmap ~* pid A)\n\n  infix ` \u2243* `:25 := pequiv\n\n  @[hott, reducible] def pmap_of_pequiv {A B : Type*} (f : A \u2243* B) :\n    @ppi A (\u03bba, B) pt :=\n  f.to_pmap\n\n  @[hott, reducible] def pequiv.to_fun {A B : Type*} (f : A \u2243* B) : A \u2192 B := f.to_pmap\n\n  @[hott] instance {A B : Type*} (f : A \u2243* B) : has_coe (A \u2243* B) (A \u2192* B) :=\n  \u27e8pmap_of_pequiv\u27e9\n\n  @[hott] def to_pinv (f : A \u2243* B) : B \u2192* A :=\n  pequiv.to_pinv1 f\n\n  @[hott] def pleft_inv' (f : A \u2243* B) : to_pinv f \u2218* f.to_pmap ~* pid A :=\n  let g := to_pinv f in\n  let h := pequiv.to_pinv2 f in\n  calc g \u2218* f.to_pmap ~* pid A \u2218* (g \u2218* f.to_pmap)    : by exact (pid_pcompose _)\u207b\u00b9*\n          ... ~* (h \u2218* f.to_pmap) \u2218* (g \u2218* f.to_pmap) : by exact pwhisker_right _ (pequiv.pleft_inv f)\u207b\u00b9*\n          ... ~* h \u2218* (f.to_pmap \u2218* g) \u2218* f.to_pmap   : by exact passoc _ _ _ \u2b1d* pwhisker_left _ (passoc _ _ _)\u207b\u00b9*\n          ... ~* h \u2218* pid B \u2218* f.to_pmap              : by exact pwhisker_left _ (pwhisker_right _ (pequiv.pright_inv _))\n          ... ~* h \u2218* 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 \u2243* B) : A \u2243 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 \u2243* B) : A \u2243 B := equiv_of_pequiv f\n\n  @[hott] instance pequiv_to_equiv {A B : Type*} (f : A \u2243* B) : has_coe (A \u2243* B) (A \u2243 B) :=\n  \u27e8equiv_of_pequiv\u27e9\n\n  @[hott, instance] def pequiv.to_is_equiv (f : A \u2243* B) : is_equiv (f.to_pmap) :=\n  to_is_equiv (equiv_of_pequiv f)\n\n  @[hott] protected def pequiv.MK (f : A \u2192* B) (g : B \u2192* A)\n    (gf : g \u2218* f ~* pid A) (fg : f \u2218* g ~* pid B) : A \u2243* B :=\n  pequiv.mk' f g g fg gf\n\n  @[hott] def pinv (f : A \u2192* B) (H : is_equiv f) : B \u2192* A :=\n  pmap.mk f\u207b\u00b9\u1da0 (ap f\u207b\u00b9\u1da0 (respect_pt f)\u207b\u00b9 \u2b1d (left_inv f pt))\n\n  @[hott] def pequiv_of_pmap (f : A \u2192* B) (H : is_equiv f) : A \u2243* 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\u2080, induction B with B b\u2080, dsimp at *, induction f\u2080,\n    exactI adj f pt \u2b1d ap02 f (idp_con _)\u207b\u00b9\u1d56 }\n  end\n  begin abstract\n    {fapply phomotopy.mk, exact left_inv f,\n    unfreezeI, induction f with f f\u2080, induction B with B b\u2080, dsimp at *, induction f\u2080,\n    exact (idp_con _)\u207b\u00b9 \u2b1d (idp_con _)\u207b\u00b9}\n  end\n\n  @[hott] def pequiv.mk (f : A \u2192 B) (H : is_equiv f) (p : f pt = pt) : A \u2243* B :=\n  pequiv_of_pmap (pmap.mk f p) H\n\n  @[hott] def pequiv_of_equiv (f : A \u2243 B) (H : f pt = pt) : A \u2243* B :=\n  pequiv.mk f f.to_is_equiv H\n\n  @[hott, hsimp] def respect_pt_pequiv_of_equiv (f : A \u2243 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 \u2243 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 \u2192* B) (g : B \u2192 A)\n    (gf : \u03a0a, g (f a) = a) (fg : \u03a0b, f (g b) = b) : A \u2243* 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 \u2243* A :=\n  pequiv.mk' (pid A) (pid A) (pid A) (pid_pcompose _) (pcompose_pid _)\n\n  @[hott, refl, reducible] protected def pequiv.rfl : A \u2243* A :=\n  pequiv.refl A\n\n  @[hott, symm] protected def pequiv.symm (f : A \u2243* B) : B \u2243* A :=\n  pequiv.MK (to_pinv f) f.to_pmap (pequiv.pright_inv f) (pleft_inv' f)\n\n  postfix `\u207b\u00b9\u1d49*`:(max + 1) := pequiv.symm\n\n  @[hott] def pleft_inv (f : A \u2243* B) : f\u207b\u00b9\u1d49*.to_pmap \u2218* f.to_pmap ~* pid A :=\n  pleft_inv' f\n\n  @[hott] def pright_inv (f : A \u2243* B) : f.to_pmap \u2218* f\u207b\u00b9\u1d49*.to_pmap ~* pid B :=\n  pequiv.pright_inv f\n\n  @[hott] def to_pmap_pequiv_of_pmap {A B : Type*} (f : A \u2192* 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 \u2192* B) (g : B \u2192* A)\n    (gf : g \u2218* f ~* pid A) (fg : f \u2218* 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 \u2192* B) (g : B \u2192* A)\n    (gf : g \u2218* f ~* pid A) (fg : f \u2218* 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 \u2192 Type*) {a a' : A} (p : a = a')\n    : B a \u2243* B a' :=\n  pequiv_of_pmap (ptransport B p) (is_equiv_tr (\u03bba, B a) p)\n\n  @[hott] def pequiv_change_fun (f : A \u2243* B) (f' : A \u2192* B) (Heq : f.to_pmap ~ f') : A \u2243* B :=\n  pequiv_of_pmap f' (is_equiv.homotopy_closed f.to_pmap Heq)\n\n  @[hott] def pequiv_change_inv (f : A \u2243* B) (f' : B \u2192* A) (Heq : to_pinv f ~ f')\n    : A \u2243* 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 \u2243* B) (P : A \u2192 B \u2192 Type _)\n    (g : \u03a0b, P ((equiv_of_pequiv f)\u207b\u00b9\u1d49 b) b) (a : A) : P a (f.to_pmap a) :=\n  transport (\u03bbx, 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 \u2243* 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 \u2243* B :=\n  pequiv_of_pmap (pcast p) (is_equiv_tr (\u03bba, a) _)\n\n  @[hott] def eq_of_pequiv {A B : Type*} (p : A \u2243* B) : A = B :=\n  pType_eq (equiv_of_pequiv p) (respect_pt _)\n\n  @[hott] def peap {A B : Type*} (F : Type* \u2192 Type*) (p : A \u2243* B) : F A \u2243* 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 \u2192 Type*} (f : \u03a0a, B a \u2192* C a)\n    {a\u2081 a\u2082 : A} (p : a\u2081 = a\u2082) : (pequiv_of_eq (ap C p)).to_pmap \u2218* f a\u2081 ~* f a\u2082 \u2218* (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 \u2243* B) : A \u2243* 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 \u2243* C) {g h : A \u2192* B} (p : f.to_pmap \u2218* g ~* f.to_pmap \u2218* h) : g ~* h :=\n  begin\n    refine _\u207b\u00b9* \u2b1d* pwhisker_left f\u207b\u00b9\u1d49*.to_pmap p \u2b1d* _,\n    all_goals {refine (passoc _ _ _)\u207b\u00b9* \u2b1d* _,\n    refine pwhisker_right _ (pleft_inv f) \u2b1d* _,\n    apply pid_pcompose }\n  end\n\n  @[hott] def pcancel_right (f : A \u2243* B) {g h : B \u2192* C} (p : g \u2218* f.to_pmap ~* h \u2218* f.to_pmap) : g ~* h :=\n  begin\n    refine _\u207b\u00b9* \u2b1d* pwhisker_right f\u207b\u00b9\u1d49*.to_pmap p \u2b1d* _,\n    all_goals {refine passoc _ _ _ \u2b1d* _,\n    refine pwhisker_left _ (pright_inv f) \u2b1d* _,\n    apply pcompose_pid }\n  end\n\n  @[hott] def phomotopy_pinv_right_of_phomotopy {f : A \u2243* B} {g : B \u2192* C} {h : A \u2192* C}\n    (p : g \u2218* f.to_pmap ~* h) : g ~* h \u2218* f\u207b\u00b9\u1d49*.to_pmap :=\n  begin\n    refine _ \u2b1d* pwhisker_right _ p, symmetry,\n    refine passoc _ _ _ \u2b1d* _,\n    refine pwhisker_left _ (pright_inv f) \u2b1d* _,\n    apply pcompose_pid\n  end\n\n  @[hott] def phomotopy_of_pinv_right_phomotopy {f : B \u2243* A} {g : B \u2192* C} {h : A \u2192* C}\n    (p : g \u2218* f\u207b\u00b9\u1d49*.to_pmap ~* h) : g ~* h \u2218* f.to_pmap :=\n  begin\n    refine _ \u2b1d* pwhisker_right _ p, symmetry,\n    refine passoc _ _ _ \u2b1d* _,\n    refine pwhisker_left _ (pleft_inv f) \u2b1d* _,\n    apply pcompose_pid\n  end\n\n  @[hott] def pinv_right_phomotopy_of_phomotopy {f : A \u2243* B} {g : B \u2192* C} {h : A \u2192* C}\n    (p : h ~* g \u2218* f.to_pmap) : h \u2218* f\u207b\u00b9\u1d49*.to_pmap ~* g :=\n  (phomotopy_pinv_right_of_phomotopy p\u207b\u00b9*)\u207b\u00b9*\n\n  @[hott] def phomotopy_of_phomotopy_pinv_right {f : B \u2243* A} {g : B \u2192* C} {h : A \u2192* C}\n    (p : h ~* g \u2218* f\u207b\u00b9\u1d49*.to_pmap) : h \u2218* f.to_pmap ~* g :=\n  (phomotopy_of_pinv_right_phomotopy p\u207b\u00b9*)\u207b\u00b9*\n\n  @[hott] def phomotopy_pinv_left_of_phomotopy {f : B \u2243* C} {g : A \u2192* B} {h : A \u2192* C}\n    (p : f.to_pmap \u2218* g ~* h) : g ~* f\u207b\u00b9\u1d49*.to_pmap \u2218* h :=\n  begin\n    refine _ \u2b1d* pwhisker_left _ p, symmetry,\n    refine (passoc _ _ _)\u207b\u00b9* \u2b1d* _,\n    refine pwhisker_right _ (pleft_inv f) \u2b1d* _,\n    apply pid_pcompose\n  end\n\n  @[hott] def phomotopy_of_pinv_left_phomotopy {f : C \u2243* B} {g : A \u2192* B} {h : A \u2192* C}\n    (p : f\u207b\u00b9\u1d49*.to_pmap \u2218* g ~* h) : g ~* f.to_pmap \u2218* h :=\n  begin\n    refine _ \u2b1d* pwhisker_left _ p, symmetry,\n    refine (passoc _ _ _)\u207b\u00b9* \u2b1d* _,\n    refine pwhisker_right _ (pright_inv f) \u2b1d* _,\n    apply pid_pcompose\n  end\n\n  @[hott] def pinv_left_phomotopy_of_phomotopy {f : B \u2243* C} {g : A \u2192* B} {h : A \u2192* C}\n    (p : h ~* f.to_pmap \u2218* g) : f\u207b\u00b9\u1d49*.to_pmap \u2218* h ~* g :=\n  (phomotopy_pinv_left_of_phomotopy p\u207b\u00b9*)\u207b\u00b9*\n\n  @[hott] def phomotopy_of_phomotopy_pinv_left {f : C \u2243* B} {g : A \u2192* B} {h : A \u2192* C}\n    (p : h ~* f\u207b\u00b9\u1d49*.to_pmap \u2218* g) : f.to_pmap \u2218* h ~* g :=\n  (phomotopy_of_pinv_left_phomotopy p\u207b\u00b9*)\u207b\u00b9*\n\n  @[hott] def pcompose2 {A B C : Type*} {g g' : B \u2192* C} {f f' : A \u2192* B} (q : g ~* g') (p : f ~* f') :\n    g \u2218* f ~* g' \u2218* f' :=\n  pwhisker_right f q \u2b1d* pwhisker_left g' p\n\n  infixr ` \u25fe* `:80 := pcompose2\n\n  @[hott] def phomotopy_pinv_of_phomotopy_pid {A B : Type*} {f : A \u2192* B} {g : B \u2243* A}\n    (p : g.to_pmap \u2218* f ~* pid A) : f ~* g\u207b\u00b9\u1d49*.to_pmap :=\n  phomotopy_pinv_left_of_phomotopy p \u2b1d* pcompose_pid _\n\n  @[hott] def phomotopy_pinv_of_phomotopy_pid' {A B : Type*} {f : A \u2192* B} {g : B \u2243* A}\n    (p : f \u2218* g.to_pmap ~* pid B) : f ~* g\u207b\u00b9\u1d49*.to_pmap :=\n  phomotopy_pinv_right_of_phomotopy p \u2b1d* pid_pcompose _\n\n  @[hott] def pinv_phomotopy_of_pid_phomotopy {A B : Type*} {f : A \u2192* B} {g : B \u2243* A}\n    (p : pid A ~* g.to_pmap \u2218* f) : g\u207b\u00b9\u1d49*.to_pmap ~* f :=\n  (phomotopy_pinv_of_phomotopy_pid p\u207b\u00b9*)\u207b\u00b9*\n\n  @[hott] def pinv_phomotopy_of_pid_phomotopy' {A B : Type*} {f : A \u2192* B} {g : B \u2243* A}\n    (p : pid B ~* f \u2218* g.to_pmap) : g\u207b\u00b9\u1d49*.to_pmap ~* f :=\n  (phomotopy_pinv_of_phomotopy_pid' p\u207b\u00b9*)\u207b\u00b9*\n\n  @[hott] def pinv_pcompose_cancel_left {A B C : Type*} (g : B \u2243* C) (f : A \u2192* B) :\n    g\u207b\u00b9\u1d49*.to_pmap \u2218* (g.to_pmap \u2218* f) ~* f :=\n  (passoc _ _ _)\u207b\u00b9* \u2b1d* pwhisker_right f (pleft_inv _) \u2b1d* pid_pcompose _\n\n  @[hott] def pcompose_pinv_cancel_left {A B C : Type*} (g : C \u2243* B) (f : A \u2192* B) :\n    g.to_pmap \u2218* (g\u207b\u00b9\u1d49*.to_pmap \u2218* f) ~* f :=\n  (passoc _ _ _)\u207b\u00b9* \u2b1d* pwhisker_right f (pright_inv _) \u2b1d* pid_pcompose _\n\n  @[hott] def pinv_pcompose_cancel_right {A B C : Type*} (g : B \u2192* C) (f : B \u2243* A) :\n    (g \u2218* f\u207b\u00b9\u1d49*.to_pmap) \u2218* f.to_pmap ~* g :=\n  passoc _ _ _ \u2b1d* pwhisker_left g (pleft_inv _) \u2b1d* pcompose_pid _\n\n  @[hott] def pcompose_pinv_cancel_right {A B C : Type*} (g : B \u2192* C) (f : A \u2243* B) :\n    (g \u2218* f.to_pmap) \u2218* f\u207b\u00b9\u1d49*.to_pmap ~* g :=\n  passoc _ _ _ \u2b1d* pwhisker_left g (pright_inv _) \u2b1d* pcompose_pid _\n\n  @[hott] def pinv_pinv {A B : Type*} (f : A \u2243* B) : (f\u207b\u00b9\u1d49*)\u207b\u00b9\u1d49*.to_pmap ~* f.to_pmap :=\n  (phomotopy_pinv_of_phomotopy_pid (pleft_inv f))\u207b\u00b9*\n\n  @[hott] def pinv2 {A B : Type*} {f f' : A \u2243* B} (p : f.to_pmap ~* f'.to_pmap) : f\u207b\u00b9\u1d49*.to_pmap ~* f'\u207b\u00b9\u1d49*.to_pmap :=\n  phomotopy_pinv_of_phomotopy_pid (pinv_right_phomotopy_of_phomotopy (pid_pcompose _ \u2b1d* p)\u207b\u00b9*)\n\n  postfix [parsing_only] `\u207b\u00b2*`:(max+10) := pinv2\n\n  @[hott, trans] protected def pequiv.trans (f : A \u2243* B) (g : B \u2243* C) : A \u2243* C :=\n  pequiv.MK (g.to_pmap \u2218* f.to_pmap) (f\u207b\u00b9\u1d49*.to_pmap \u2218* g\u207b\u00b9\u1d49*.to_pmap)\n    begin abstract {exact passoc _ _ _ \u2b1d* pwhisker_left _ (pinv_pcompose_cancel_left g f.to_pmap) \u2b1d* pleft_inv f} end\n    begin abstract {exact passoc _ _ _ \u2b1d* pwhisker_left _ (pcompose_pinv_cancel_left f g\u207b\u00b9\u1d49*.to_pmap) \u2b1d* pright_inv g} end\n\n  @[hott] def pequiv_compose {A B C : Type*} (g : B \u2243* C) (f : A \u2243* B) : A \u2243* C :=\n  pequiv.trans f g\n\n  infix ` \u2b1de* `:75 := pequiv.trans\n  infixr ` \u2218*\u1d49 `:60 := pequiv_compose\n\n  @[hott] def to_pmap_pequiv_trans {A B C : Type*} (f : A \u2243* B) (g : B \u2243* C)\n    : (f \u2b1de* g).to_pmap = g.to_pmap \u2218* f.to_pmap :=\n  by reflexivity\n\n  @[hott] def to_fun_pequiv_trans {X Y Z : Type*} (f : X \u2243* Y) (g :Y \u2243* Z) : (f \u2b1de* g).to_pmap ~ g.to_pmap \u2218 f.to_pmap :=\n  \u03bbx, idp\n\n  @[hott] def peconcat_eq {A B C : Type*} (p : A \u2243* B) (q : B = C) : A \u2243* C :=\n  p \u2b1de* pequiv_of_eq q\n\n  @[hott] def eq_peconcat {A B C : Type*} (p : A = B) (q : B \u2243* C) : A \u2243* C :=\n  pequiv_of_eq p \u2b1de* q\n\n\n  infix ` \u2b1de*p `:75 := peconcat_eq\n  infix ` \u2b1dpe* `:75 := eq_peconcat\n\n\n  @[hott] def trans_pinv {A B C : Type*} (f : A \u2243* B) (g : B \u2243* C) :\n    (f \u2b1de* g)\u207b\u00b9\u1d49*.to_pmap ~* f\u207b\u00b9\u1d49*.to_pmap \u2218* g\u207b\u00b9\u1d49*.to_pmap :=\n  by reflexivity\n\n  @[hott] def pinv_trans_pinv_left {A B C : Type*} (f : B \u2243* A) (g : B \u2243* C) :\n    (f\u207b\u00b9\u1d49* \u2b1de* g)\u207b\u00b9\u1d49*.to_pmap ~* f.to_pmap \u2218* g\u207b\u00b9\u1d49*.to_pmap :=\n  by reflexivity\n\n  @[hott] def pinv_trans_pinv_right {A B C : Type*} (f : A \u2243* B) (g : C \u2243* B) :\n    (f \u2b1de* g\u207b\u00b9\u1d49*)\u207b\u00b9\u1d49*.to_pmap ~* f\u207b\u00b9\u1d49*.to_pmap \u2218* g.to_pmap :=\n  by reflexivity\n\n  @[hott] def pinv_trans_pinv_pinv {A B C : Type*} (f : B \u2243* A) (g : C \u2243* B) :\n    (f\u207b\u00b9\u1d49* \u2b1de* g\u207b\u00b9\u1d49*)\u207b\u00b9\u1d49*.to_pmap ~* f.to_pmap \u2218* 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 : \u2115) (f : A \u2243* B) : \u03a9[n] A \u2243* \u03a9[n] B :=\n  pequiv.MK (apn n f.to_pmap) (apn n f\u207b\u00b9\u1d49*.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 _ _)\u207b\u00b9* \u2b1d* _,\n      refine ap1_phomotopy IH \u2b1d* _,\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 _ _)\u207b\u00b9* \u2b1d* _,\n      refine ap1_phomotopy IH \u2b1d* _,\n      apply ap1_pid}}\n  end\n\n  @[hott] def loop_pequiv_loop (f : A \u2243* B) : \u03a9 A \u2243* \u03a9 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 \u2243* 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 : \u2115) (f : A \u2243* 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 : \u2115) (f : A \u2243* B)\n    : (loopn_pequiv_loopn n f)\u207b\u00b9\u1d49*.to_pmap ~* apn n f\u207b\u00b9\u1d49*.to_pmap :=\n  by refl\n\n  @[hott] def loopn_pequiv_loopn_con (n : \u2115) (f : A \u2243* B) (p q : \u03a9[n+1] A)\n    : (loopn_pequiv_loopn (n+1) f).to_pmap.to_fun (p \u2b1d q) =\n    (loopn_pequiv_loopn (n+1) f).to_pmap.to_fun p \u2b1d (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 \u2243* B) (p q : \u03a9 A)\n    : (loop_pequiv_loop f).to_pmap (p \u2b1d q) = (loop_pequiv_loop f).to_pmap p \u2b1d (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 : \u2115) (A : Type*) :\n    (loopn_pequiv_loopn n (pequiv.refl A)).to_pmap ~* (pequiv.refl (\u03a9[n] A)).to_pmap :=\n  begin\n    exact to_pmap_loopn_pequiv_loopn _ _ \u2b1d* 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 (\u03a9 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 : \u2115) {A B : Type*} (f : A \u2243* B) :\n    \u03a9\u2192[n] f\u207b\u00b9\u1d49*.to_pmap ~* (loopn_pequiv_loopn n f)\u207b\u00b9\u1d49*.to_pmap :=\n  by reflexivity\n\n  @[hott] def pmap_functor {A A' B B' : Type*} (f : A' \u2192* A) (g : B \u2192* B') :\n    ppmap A B \u2192* ppmap A' B' :=\n  pmap.mk (\u03bbh, g \u2218* h \u2218* f)\n    begin abstract {fapply eq_of_phomotopy, fapply phomotopy.mk,\n      { hintro a, exact respect_pt g},\n      { symmetry, refine _ \u25fe idp \u2b1d idp_con _,\n        exact ap02 g (ap_constant _ _) }}\n    end\n\n  @[hott] def pequiv_pinverse (A : Type*) : \u03a9 A \u2243* \u03a9 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 \u2243* 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 \u2243* 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 \u2192* B) :\n    (pointed_eta_pequiv B \u2b1de* (pequiv_of_eq_pt (respect_pt f))\u207b\u00b9\u1d49*).to_pmap \u2218* f \u2218*\n      (pointed_eta_pequiv A)\u207b\u00b9\u1d49*.to_pmap ~* pmap_of_map f pt :=\n  begin\n    fapply phomotopy.mk,\n    { reflexivity},\n    { symmetry, exact (ap_id _ \u2b1d idp_con _) \u25fe (idp_con _ \u2b1d ap_id _) \u2b1d con.right_inv _ }\n  end\n\n  /- properties of iterated loop space -/\n  variable (A)\n  @[hott] def loopn_succ_in (n : \u2115) : \u03a9[succ n] A \u2243* \u03a9[n] (\u03a9 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 : \u2115) : \u03a9[n] (\u03a9[m] A) \u2243* \u03a9[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 : \u2115) : \u03a9[succ n] A \u2243* \u03a9(\u03a9[n] A)  :=\n  by reflexivity\n\n  variable {A}\n\n  @[hott] def loopn_succ_in_con {n : \u2115} (p q : \u03a9[succ (succ n)] A) :\n    (loopn_succ_in A (succ n)).to_pmap (p \u2b1d q) =\n    (loopn_succ_in A (succ n)).to_pmap p \u2b1d (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) : \u03a9(pointed.Mk p) = \u03a9[2] A :=\n  begin\n    intros, fapply pType_eq,\n    { transitivity _,\n      apply eq_equiv_fn_eq_of_equiv (equiv_eq_closed_right _ p\u207b\u00b9),\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 : \u2115) (p : point A = point A)\n    : \u03a9[succ n](pointed.Mk p) = \u03a9[succ (succ n)] A :> pType :=\n  calc\n    \u03a9[succ n](pointed.Mk p) = \u03a9[n](\u03a9 (pointed.Mk p)) : eq_of_pequiv $ loopn_succ_in _ _\n      ... = \u03a9[n] (\u03a9[2] A)                            : ap \u03a9[n] $ loopn_loop_irrel p\n      ... = \u03a9[n+1] (\u03a9 A)                             : eq_of_pequiv $ (loopn_succ_in _ _)\u207b\u00b9\u1d49*\n      ... = \u03a9[n+2] A                                 : eq_of_pequiv $ (loopn_succ_in _ _)\u207b\u00b9\u1d49*\n\n  @[hott] def apn_succ_phomotopy_in (n : \u2115) (f : A \u2192* B) :\n    (loopn_succ_in B n).to_pmap \u2218* \u03a9\u2192[n + 1] f ~* \u03a9\u2192[n] (\u03a9\u2192 f) \u2218* (loopn_succ_in A n).to_pmap :=\n  begin\n    induction n with n IH,\n    { reflexivity},\n    { exact (ap1_pcompose _ _)\u207b\u00b9* \u2b1d* ap1_phomotopy IH \u2b1d* (ap1_pcompose _ _)}\n  end\n\n  @[hott] def loopn_succ_in_natural {A B : Type*} (n : \u2115) (f : A \u2192* B) :\n    (loopn_succ_in B n).to_pmap \u2218* \u03a9\u2192[n+1] f ~* \u03a9\u2192[n] (\u03a9\u2192 f) \u2218* (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 : \u2115) (f : A \u2192* B) :\n    \u03a9\u2192[n + 1] f \u2218* (loopn_succ_in A n)\u207b\u00b9\u1d49*.to_pmap ~* (loopn_succ_in B n)\u207b\u00b9\u1d49*.to_pmap \u2218* \u03a9\u2192[n] (\u03a9\u2192 f):=\n  begin\n    apply pinv_right_phomotopy_of_phomotopy,\n    refine _ \u2b1d* (passoc _ _ _)\u207b\u00b9*,\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 :\u2261 k \u2218* f ~* g \u2218* 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\u2080\u2080 : Type*} {A\u2082\u2080 : Type*} {A\u2084\u2080 : Type*} \n            {A\u2080\u2082 : Type*} {A\u2082\u2082 : Type*} {A\u2084\u2082 : Type*} \n            {A\u2080\u2084 : Type*} {A\u2082\u2084 : Type*} {A\u2084\u2084 : Type*}\n            {f\u2081\u2080 f\u2081\u2080' : A\u2080\u2080 \u2192* A\u2082\u2080} {f\u2083\u2080 : A\u2082\u2080 \u2192* A\u2084\u2080}\n            {f\u2080\u2081 f\u2080\u2081' : A\u2080\u2080 \u2192* A\u2080\u2082} {f\u2082\u2081 f\u2082\u2081' : A\u2082\u2080 \u2192* A\u2082\u2082} {f\u2084\u2081 : A\u2084\u2080 \u2192* A\u2084\u2082}\n            {f\u2081\u2082 f\u2081\u2082' : A\u2080\u2082 \u2192* A\u2082\u2082} {f\u2083\u2082 : A\u2082\u2082 \u2192* A\u2084\u2082}\n            {f\u2080\u2083 : A\u2080\u2082 \u2192* A\u2080\u2084} {f\u2082\u2083 : A\u2082\u2082 \u2192* A\u2082\u2084} {f\u2084\u2083 : A\u2084\u2082 \u2192* A\u2084\u2084}\n            {f\u2081\u2084 : A\u2080\u2084 \u2192* A\u2082\u2084} {f\u2083\u2084 : A\u2082\u2084 \u2192* A\u2084\u2084}\n\n  @[hott, reducible] def psquare (f\u2081\u2080 : A\u2080\u2080 \u2192* A\u2082\u2080) (f\u2081\u2082 : A\u2080\u2082 \u2192* A\u2082\u2082)\n                                 (f\u2080\u2081 : A\u2080\u2080 \u2192* A\u2080\u2082) (f\u2082\u2081 : A\u2082\u2080 \u2192* A\u2082\u2082) : Type _ :=\n  f\u2082\u2081 \u2218* f\u2081\u2080 ~* f\u2081\u2082 \u2218* f\u2080\u2081\n\n  @[hott] def psquare_of_phomotopy (p : f\u2082\u2081 \u2218* f\u2081\u2080 ~* f\u2081\u2082 \u2218* f\u2080\u2081) : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081 :=\n  p\n\n  @[hott] def phomotopy_of_psquare (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) : f\u2082\u2081 \u2218* f\u2081\u2080 ~* f\u2081\u2082 \u2218* f\u2080\u2081 :=\n  p\n\n  @[hott] def phdeg_square {f f' : A \u2192* A'} (p : f ~* f') : psquare (pid A) (pid A') f f' :=\n  pcompose_pid _ \u2b1d* p\u207b\u00b9* \u2b1d* (pid_pcompose _)\u207b\u00b9*\n  @[hott] def pvdeg_square {f f' : A \u2192* A'} (p : f ~* f') : psquare f f' (pid A) (pid A') :=\n  pid_pcompose _ \u2b1d* p \u2b1d* (pcompose_pid _)\u207b\u00b9*\n\n  variables (f\u2080\u2081 f\u2081\u2080)\n  @[hott] def phrefl : psquare (pid A\u2080\u2080) (pid A\u2080\u2082) f\u2080\u2081 f\u2080\u2081 := phdeg_square phomotopy.rfl\n  @[hott] def pvrefl : psquare f\u2081\u2080 f\u2081\u2080 (pid A\u2080\u2080) (pid A\u2082\u2080) := pvdeg_square phomotopy.rfl\n  variables {f\u2080\u2081 f\u2081\u2080}\n  @[hott] def phrfl : psquare (pid A\u2080\u2080) (pid A\u2080\u2082) f\u2080\u2081 f\u2080\u2081 := phrefl f\u2080\u2081\n  @[hott] def pvrfl : psquare f\u2081\u2080 f\u2081\u2080 (pid A\u2080\u2080) (pid A\u2082\u2080) := pvrefl f\u2081\u2080\n\n  @[hott] def phconcat (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) (q : psquare f\u2083\u2080 f\u2083\u2082 f\u2082\u2081 f\u2084\u2081) :\n    psquare (f\u2083\u2080 \u2218* f\u2081\u2080) (f\u2083\u2082 \u2218* f\u2081\u2082) f\u2080\u2081 f\u2084\u2081 :=\n  (passoc _ _ _)\u207b\u00b9* \u2b1d* pwhisker_right f\u2081\u2080 q \u2b1d* passoc _ _ _ \u2b1d* pwhisker_left f\u2083\u2082 p \u2b1d* (passoc _ _ _)\u207b\u00b9*\n\n  @[hott] def pvconcat (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) (q : psquare f\u2081\u2082 f\u2081\u2084 f\u2080\u2083 f\u2082\u2083) :\n    psquare f\u2081\u2080 f\u2081\u2084 (f\u2080\u2083 \u2218* f\u2080\u2081) (f\u2082\u2083 \u2218* f\u2082\u2081) :=\n  passoc _ _ _ \u2b1d* pwhisker_left _ p \u2b1d* (passoc _ _ _)\u207b\u00b9* \u2b1d* pwhisker_right _ q \u2b1d* passoc _ _ _\n\n  @[hott] def phinverse {f\u2081\u2080 : A\u2080\u2080 \u2243* A\u2082\u2080} {f\u2081\u2082 : A\u2080\u2082 \u2243* A\u2082\u2082} \n    (p : psquare f\u2081\u2080.to_pmap f\u2081\u2082.to_pmap f\u2080\u2081 f\u2082\u2081) : \n    psquare f\u2081\u2080\u207b\u00b9\u1d49*.to_pmap f\u2081\u2082\u207b\u00b9\u1d49*.to_pmap f\u2082\u2081 f\u2080\u2081 :=\n  (pid_pcompose _)\u207b\u00b9* \u2b1d* pwhisker_right _ (pleft_inv f\u2081\u2082)\u207b\u00b9* \u2b1d* passoc _ _ _ \u2b1d*\n  pwhisker_left _\n    ((passoc _ _ _)\u207b\u00b9* \u2b1d* pwhisker_right _ p\u207b\u00b9* \u2b1d* passoc _ _ _ \u2b1d* pwhisker_left _ (pright_inv _) \u2b1d* (pcompose_pid _))\n\n  @[hott] def pvinverse {f\u2080\u2081 : A\u2080\u2080 \u2243* A\u2080\u2082} {f\u2082\u2081 : A\u2082\u2080 \u2243* A\u2082\u2082} \n    (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081.to_pmap f\u2082\u2081.to_pmap) : \n    psquare f\u2081\u2082 f\u2081\u2080 f\u2080\u2081\u207b\u00b9\u1d49*.to_pmap f\u2082\u2081\u207b\u00b9\u1d49*.to_pmap :=\n  (phinverse p\u207b\u00b9*)\u207b\u00b9*\n\n  @[hott] def phomotopy_hconcat (q : f\u2080\u2081' ~* f\u2080\u2081) (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) :\n    psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081' f\u2082\u2081 :=\n  p \u2b1d* pwhisker_left f\u2081\u2082 q\u207b\u00b9*\n\n  @[hott] def hconcat_phomotopy (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) (q : f\u2082\u2081' ~* f\u2082\u2081) :\n    psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081' :=\n  pwhisker_right f\u2081\u2080 q \u2b1d* p\n\n  @[hott] def phomotopy_vconcat (q : f\u2081\u2080' ~* f\u2081\u2080) (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) :\n    psquare f\u2081\u2080' f\u2081\u2082 f\u2080\u2081 f\u2082\u2081 :=\n  pwhisker_left f\u2082\u2081 q \u2b1d* p\n\n  @[hott] def vconcat_phomotopy (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) (q : f\u2081\u2082' ~* f\u2081\u2082) :\n    psquare f\u2081\u2080 f\u2081\u2082' f\u2080\u2081 f\u2082\u2081 :=\n  p \u2b1d* pwhisker_right f\u2080\u2081 q\u207b\u00b9*\n\n  infix ` \u2b1dh* `:73 := phconcat\n  infix ` \u2b1dv* `:73 := pvconcat\n  infixl ` \u2b1dhp* `:72 := hconcat_phomotopy\n  infixr ` \u2b1dph* `:72 := phomotopy_hconcat\n  infixl ` \u2b1dvp* `:72 := vconcat_phomotopy\n  infixr ` \u2b1dpv* `:72 := phomotopy_vconcat\n  postfix `\u207b\u00b9\u02b0*`:(max+1) := phinverse\n  postfix `\u207b\u00b9\u1d5b*`:(max+1) := pvinverse\n\n  @[hott, hsimp] def ptranspose (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) : psquare f\u2080\u2081 f\u2082\u2081 f\u2081\u2080 f\u2081\u2082 :=\n  p\u207b\u00b9*\n\n  @[hott] def pwhisker_tl (f : A \u2192* A\u2080\u2080) (q : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) :\n    psquare (f\u2081\u2080 \u2218* f) f\u2081\u2082 (f\u2080\u2081 \u2218* f) f\u2082\u2081 :=\n  (passoc _ _ _)\u207b\u00b9* \u2b1d* pwhisker_right f q \u2b1d* passoc _ _ _\n\n  @[hott] def ap1_psquare (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) :\n    psquare (\u03a9\u2192 f\u2081\u2080) (\u03a9\u2192 f\u2081\u2082) (\u03a9\u2192 f\u2080\u2081) (\u03a9\u2192 f\u2082\u2081) :=\n  (ap1_pcompose _ _)\u207b\u00b9* \u2b1d* ap1_phomotopy p \u2b1d* ap1_pcompose _ _\n\n  @[hott] def apn_psquare (n : \u2115) (p : psquare f\u2081\u2080 f\u2081\u2082 f\u2080\u2081 f\u2082\u2081) :\n    psquare (\u03a9\u2192[n] f\u2081\u2080) (\u03a9\u2192[n] f\u2081\u2082) (\u03a9\u2192[n] f\u2080\u2081) (\u03a9\u2192[n] f\u2082\u2081) :=\n  (apn_pcompose _ _ _)\u207b\u00b9* \u2b1d* apn_phomotopy n p \u2b1d* 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 (\u039b : Type*) [polyhedral_lattice \u039b]\n\nlemma filtration_finite (\u03b5 : \u211d\u22650) : (filtration \u039b \u03b5).finite :=\nbegin\n  classical,\n  obtain \u27e8\u03b9, _\u03b9_inst, l, hl, hl'\u27e9 := polyhedral_lattice.polyhedral \u039b, resetI,\n  let n : \u03b9 \u2192 \u2115 := \u03bb i, \u2308(\u03b5 / \u2225l i\u2225\u208a : \u211d)\u2309.nat_abs + 1,\n  let S := finset.univ.pi (\u03bb i, finset.range (n i)),\n  let S' : finset \u039b := S.image (\u03bb x, \u2211 i, x i (finset.mem_univ _) \u2022 l i),\n  apply S'.finite_to_set.subset,\n  intros l\u2080 H,\n  obtain \u27e8c, h1, h2\u27e9 := hl.generates_nnnorm l\u2080,\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 \u27e8\u03bb i _, c i, _, h1.symm\u27e9,\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 < \u2225l i\u2225\u208a,\n  { rw [zero_lt_iff, ne.def, nnnorm_eq_zero], exact hl' i },\n  calc \u03b5\n      \u2264 (\u2308(\u03b5 / \u2225l i\u2225\u208a : \u211d)\u2309.nat_abs : \u211d\u22650) * \u2225l i\u2225\u208a : _\n  ... < \u2191(c i) * \u2225l i\u2225\u208a : _\n  ... \u2264 \u2211 (i : \u03b9), \u2191(c i) * \u2225l i\u2225\u208a : _,\n  { rw [\u2190 nnreal.div_le_iff aux.ne', \u2190 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 \u03bb _ _, zero_le', }\nend\n\nopen metric seminormed_add_comm_group\n\ninstance : discrete_topology \u039b :=\ndiscrete_topology_of_open_singleton_zero $\nbegin\n  classical,\n  have aux := filtration_finite \u039b 1,\n  let s := aux.to_finset,\n  let s\u2080 := s.erase 0,\n  by_cases hs\u2080 : s\u2080.nonempty,\n  { let \u03b5 : \u211d\u22650 := finset.min' (s\u2080.image $ nnnorm) (hs\u2080.image _),\n    obtain \u27e8a, has\u2080, ha\u27e9 : \u2203 a \u2208 s\u2080, \u2225a\u2225\u208a = \u03b5,\n    { rw \u2190 finset.mem_image, apply finset.min'_mem },\n    have H : 0 < \u2225a\u2225 := by simpa only [norm_pos_iff] using finset.ne_of_mem_erase has\u2080,\n    have h0\u03b5 : 0 < \u03b5, { simpa only [\u2190 ha] },\n    have h\u03b51 : \u03b5 \u2264 1,\n    { replace has\u2080 := finset.mem_of_mem_erase has\u2080,\n      simp only [set.finite.mem_to_finset, mem_filtration_iff] at has\u2080,\n      rwa [\u2190 ha] },\n    suffices : ({0} : set \u039b) = ball (0:\u039b) \u03b5,\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\u03b5 },\n    intro h,\n    have hx : x \u2208 s,\n    { simp only [set.finite.mem_to_finset, mem_filtration_iff],\n      exact le_of_lt (lt_of_lt_of_le h h\u03b51) },\n    by_contra hx0,\n    replace hx := finset.mem_erase_of_ne_of_mem hx0 hx,\n    have := finset.min'_le (s\u2080.image $ nnnorm),\n    refine not_lt.2 (this \u2225x\u2225\u208a _) h,\n    simp only [exists_prop, set.finite.mem_to_finset, finset.mem_image],\n    use \u27e8x, \u27e8hx, rfl\u27e9\u27e9 },\n  { suffices : ({0} : set \u039b) = ball (0:\u039b) 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\u2080,\n    refine \u27e8x, _\u27e9,\n    simp only [set.finite.mem_to_finset, finset.mem_erase, mem_filtration_iff, nnreal.coe_one],\n    exact \u27e8hs\u2080, h.le\u27e9 }\nend\n\ninstance filtration_fintype (c : \u211d\u22650) : fintype (filtration \u039b c) :=\n(filtration_finite \u039b c).fintype\n\n-- we don't need this\ninstance : profinitely_filtered_pseudo_normed_group \u039b :=\n{ compact := \u03bb c, by apply_instance, -- compact of finite\n  continuous_add' := \u03bb _ _, continuous_of_discrete_topology,\n  continuous_neg' := \u03bb _, continuous_of_discrete_topology,\n  continuous_cast_le := \u03bb _ _ _, continuous_of_discrete_topology,\n  .. (show pseudo_normed_group \u039b, 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 \u25b8 hq.symm \u25b8 rfl\n\ntheorem and_left : {p q : Bool} \u2192 (p && q) = true \u2192 p = true\n| true, _, _ => rfl\n| false, _, h => false_and _ \u25b8 h\n\ntheorem and_right : {p q : Bool} \u2192 (p && q) = true \u2192 q = true\n| _, true, _ => rfl\n| _, false, h => and_false _ \u25b8 h\n\nend\n\nend Bool\n\n\n-- section\n-- instance (p : Fin k \u2192 Prop) [Decidable (\u2200 k, \u00acp k)] : Decidable (\u2203 k, p k) :=\n--   if h : \u2200 k, \u00acp k then isFalse $ not_exists.mpr h\n--   else isTrue $ let \u27e8x, hx\u27e9 := not_forall.mp h; \u27e8x, of_not_not hx\u27e9\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} (\u03b2 : H \u21a6 K) (\u03b1 : G \u21a6 H) : G \u21a6 K :=\n  morphism.mk (\u03b2.vertex_map \u2218 \u03b1.vertex_map) (\u03b2.edge_map \u2218 \u03b1.edge_map) (by exact compatability \u03b1 \u03b2)\n\ninfix `\u229a`:80 := compose\n\nlemma mor_assoc {G H K L : graph} (\u03b1 : G \u21a6 H) (\u03b2 : H \u21a6 K) (\u03b3 : K \u21a6 L) : \u03b3 \u229a (\u03b2 \u229a \u03b1) = (\u03b3 \u229a \u03b2) \u229a \u03b1 :=\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 \u2192 Q) : Q :=\nbegin\n  sorry\nend\n\nexample (HQ : Q) : P \u2192 Q :=\nbegin\n  sorry,\nend\n\nexample : P \u2192 P :=\nbegin\n  sorry,\nend\n\nexample (HR : R) : P \u2192 (Q \u2192 R) :=\nbegin\n  sorry,\nend\n\nexample : true :=\nbegin\n  sorry\nend\n\nexample : false \u2192 false :=\nbegin\n  sorry\nend\n\nexample : P \u2192 \u00ac (\u00ac P) :=\nbegin\n  sorry,\nend\n\nexample : \u00ac \u00ac P \u2192 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u03bc \u03bd` registers that the image of `\u03bc` under `f` coincides with the image of `\u03bd`\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 \u03bc \u03bd`). 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_\u2112p_snd`: if `f` and `g` are identically distributed and `f`\n  belongs to `\u2112p`, then so does `g`.\n\nWe also register several dot notation shortcuts for convenience.\nFor instance, if `h : ident_distrib f g \u03bc \u03bd`, then `h.sq` states that `f^2` and `g^2` are\nidentically distributed, and `h.norm` states that `\u2016f\u2016` and `\u2016g\u2016` 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 {\u03b1 \u03b2 \u03b3 \u03b4 : Type*} [measurable_space \u03b1] [measurable_space \u03b2]\n  [measurable_space \u03b3] [measurable_space \u03b4]\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 : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) (\u03bc : measure \u03b1 . volume_tac) (\u03bd : measure \u03b2 . volume_tac) : Prop :=\n(ae_measurable_fst : ae_measurable f \u03bc)\n(ae_measurable_snd : ae_measurable g \u03bd)\n(map_eq : measure.map f \u03bc = measure.map g \u03bd)\n\nnamespace ident_distrib\n\nopen topological_space\n\nvariables {\u03bc : measure \u03b1} {\u03bd : measure \u03b2} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3}\n\nprotected lemma refl (hf : ae_measurable f \u03bc) :\n  ident_distrib f f \u03bc \u03bc :=\n{ ae_measurable_fst := hf,\n  ae_measurable_snd := hf,\n  map_eq := rfl }\n\nprotected lemma symm (h : ident_distrib f g \u03bc \u03bd) : ident_distrib g f \u03bd \u03bc :=\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 {\u03c1 : measure \u03b4} {h : \u03b4 \u2192 \u03b3}\n  (h\u2081 : ident_distrib f g \u03bc \u03bd) (h\u2082 : ident_distrib g h \u03bd \u03c1) : ident_distrib f h \u03bc \u03c1 :=\n{ ae_measurable_fst := h\u2081.ae_measurable_fst,\n  ae_measurable_snd := h\u2082.ae_measurable_snd,\n  map_eq := h\u2081.map_eq.trans h\u2082.map_eq }\n\nprotected lemma comp_of_ae_measurable {u : \u03b3 \u2192 \u03b4} (h : ident_distrib f g \u03bc \u03bd)\n  (hu : ae_measurable u (measure.map f \u03bc)) :\n  ident_distrib (u \u2218 f) (u \u2218 g) \u03bc \u03bd :=\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 [\u2190 ae_measurable.map_map_of_ae_measurable hu h.ae_measurable_fst,\n      \u2190 ae_measurable.map_map_of_ae_measurable _ h.ae_measurable_snd, h.map_eq],\n    rwa \u2190 h.map_eq,\n  end }\n\nprotected lemma comp {u : \u03b3 \u2192 \u03b4} (h : ident_distrib f g \u03bc \u03bd) (hu : measurable u) :\n  ident_distrib (u \u2218 f) (u \u2218 g) \u03bc \u03bd :=\nh.comp_of_ae_measurable hu.ae_measurable\n\nprotected lemma of_ae_eq {g : \u03b1 \u2192 \u03b3} (hf : ae_measurable f \u03bc) (heq : f =\u1d50[\u03bc] g) :\n  ident_distrib f g \u03bc \u03bc :=\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 \u03bc \u03bd) {s : set \u03b3} (hs : measurable_set s) :\n  \u03bc (f \u207b\u00b9' s) = \u03bd (g \u207b\u00b9' s) :=\nby rw [\u2190 measure.map_apply_of_ae_measurable h.ae_measurable_fst hs,\n  \u2190 measure.map_apply_of_ae_measurable h.ae_measurable_snd hs, h.map_eq]\n\nalias measure_mem_eq \u2190 measure_preimage_eq\n\nlemma ae_snd (h : ident_distrib f g \u03bc \u03bd) {p : \u03b3 \u2192 Prop}\n  (pmeas : measurable_set {x | p x}) (hp : \u2200\u1d50 x \u2202\u03bc, p (f x)) :\n   \u2200\u1d50 x \u2202\u03bd, p (g x) :=\nbegin\n  apply (ae_map_iff h.ae_measurable_snd pmeas).1,\n  rw \u2190 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 \u03bc \u03bd) {t : set \u03b3}\n  (tmeas : measurable_set t) (ht : \u2200\u1d50 x \u2202\u03bc, f x \u2208 t) :\n   \u2200\u1d50 x \u2202\u03bd, g x \u2208 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 \u03b3] [metrizable_space \u03b3] [borel_space \u03b3]\n  (h : ident_distrib f g \u03bc \u03bd) (hf : ae_strongly_measurable f \u03bc) :\n  ae_strongly_measurable g \u03bd :=\nbegin\n  refine ae_strongly_measurable_iff_ae_measurable_separable.2 \u27e8h.ae_measurable_snd, _\u27e9,\n  rcases (ae_strongly_measurable_iff_ae_measurable_separable.1 hf).2 with \u27e8t, t_sep, ht\u27e9,\n  refine \u27e8closure t, t_sep.closure, _\u27e9,\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 \u03b3] [metrizable_space \u03b3] [borel_space \u03b3]\n  (h : ident_distrib f g \u03bc \u03bd) :\n  ae_strongly_measurable f \u03bc \u2194 ae_strongly_measurable g \u03bd :=\n\u27e8\u03bb hf, h.ae_strongly_measurable_snd hf, \u03bb hg, h.symm.ae_strongly_measurable_snd hg\u27e9\n\nlemma ess_sup_eq [conditionally_complete_linear_order \u03b3] [topological_space \u03b3]\n  [opens_measurable_space \u03b3] [order_closed_topology \u03b3] (h : ident_distrib f g \u03bc \u03bd) :\n  ess_sup f \u03bc = ess_sup g \u03bd :=\nbegin\n  have I : \u2200 a, \u03bc {x : \u03b1 | a < f x} = \u03bd {x : \u03b2 | a < g x} :=\n    \u03bb a, h.measure_mem_eq measurable_set_Ioi,\n  simp_rw [ess_sup_eq_Inf, I],\nend\n\nlemma lintegral_eq {f : \u03b1 \u2192 \u211d\u22650\u221e} {g : \u03b2 \u2192 \u211d\u22650\u221e} (h : ident_distrib f g \u03bc \u03bd) :\n  \u222b\u207b x, f x \u2202\u03bc = \u222b\u207b x, g x \u2202\u03bd :=\nbegin\n  change \u222b\u207b x, id (f x) \u2202\u03bc = \u222b\u207b x, id (g x) \u2202\u03bd,\n  rw [\u2190 lintegral_map' ae_measurable_id h.ae_measurable_fst,\n      \u2190 lintegral_map' ae_measurable_id h.ae_measurable_snd, h.map_eq],\nend\n\nlemma integral_eq [normed_add_comm_group \u03b3] [normed_space \u211d \u03b3] [complete_space \u03b3] [borel_space \u03b3]\n  (h : ident_distrib f g \u03bc \u03bd) : \u222b x, f x \u2202\u03bc = \u222b x, g x \u2202\u03bd :=\nbegin\n  by_cases hf : ae_strongly_measurable f \u03bc,\n  { have A : ae_strongly_measurable id (measure.map f \u03bc),\n    { rw ae_strongly_measurable_iff_ae_measurable_separable,\n      rcases (ae_strongly_measurable_iff_ae_measurable_separable.1 hf).2 with \u27e8t, t_sep, ht\u27e9,\n      refine \u27e8ae_measurable_id, \u27e8closure t, t_sep.closure, _\u27e9\u27e9,\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 \u222b x, id (f x) \u2202\u03bc = \u222b x, id (g x) \u2202\u03bd,\n    rw [\u2190 integral_map h.ae_measurable_fst A],\n    rw h.map_eq at A,\n    rw [\u2190 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 \u03b3] [opens_measurable_space \u03b3] (h : ident_distrib f g \u03bc \u03bd)\n  (p : \u211d\u22650\u221e) :\n  snorm f p \u03bc = snorm g p \u03bd :=\nbegin\n  by_cases h0 : p = 0,\n  { simp [h0], },\n  by_cases h_top : p = \u221e,\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_\u2112p_snd [normed_add_comm_group \u03b3] [borel_space \u03b3]\n  {p : \u211d\u22650\u221e} (h : ident_distrib f g \u03bc \u03bd) (hf : mem_\u2112p f p \u03bc) :\n  mem_\u2112p g p \u03bd :=\nbegin\n  refine \u27e8h.ae_strongly_measurable_snd hf.ae_strongly_measurable, _\u27e9,\n  rw \u2190 h.snorm_eq,\n  exact hf.2\nend\n\nlemma mem_\u2112p_iff [normed_add_comm_group \u03b3] [borel_space \u03b3] {p : \u211d\u22650\u221e} (h : ident_distrib f g \u03bc \u03bd) :\n  mem_\u2112p f p \u03bc \u2194 mem_\u2112p g p \u03bd :=\n\u27e8\u03bb hf, h.mem_\u2112p_snd hf, \u03bb hg, h.symm.mem_\u2112p_snd hg\u27e9\n\nlemma integrable_snd [normed_add_comm_group \u03b3] [borel_space \u03b3] (h : ident_distrib f g \u03bc \u03bd)\n  (hf : integrable f \u03bc) : integrable g \u03bd :=\nbegin\n  rw \u2190 mem_\u2112p_one_iff_integrable at hf \u22a2,\n  exact h.mem_\u2112p_snd hf\nend\n\nlemma integrable_iff [normed_add_comm_group \u03b3] [borel_space \u03b3] (h : ident_distrib f g \u03bc \u03bd) :\n  integrable f \u03bc \u2194 integrable g \u03bd :=\n\u27e8\u03bb hf, h.integrable_snd hf, \u03bb hg, h.symm.integrable_snd hg\u27e9\n\nprotected lemma norm [normed_add_comm_group \u03b3] [borel_space \u03b3] (h : ident_distrib f g \u03bc \u03bd) :\n  ident_distrib (\u03bb x, \u2016f x\u2016) (\u03bb x, \u2016g x\u2016) \u03bc \u03bd :=\nh.comp measurable_norm\n\nprotected lemma nnnorm [normed_add_comm_group \u03b3] [borel_space \u03b3] (h : ident_distrib f g \u03bc \u03bd) :\n  ident_distrib (\u03bb x, \u2016f x\u2016\u208a) (\u03bb x, \u2016g x\u2016\u208a) \u03bc \u03bd :=\nh.comp measurable_nnnorm\n\nprotected lemma pow [has_pow \u03b3 \u2115] [has_measurable_pow \u03b3 \u2115] (h : ident_distrib f g \u03bc \u03bd) {n : \u2115} :\n  ident_distrib (\u03bb x, (f x) ^ n) (\u03bb x, (g x) ^ n) \u03bc \u03bd :=\nh.comp (measurable_id.pow_const n)\n\nprotected lemma sq [has_pow \u03b3 \u2115] [has_measurable_pow \u03b3 \u2115] (h : ident_distrib f g \u03bc \u03bd) :\n  ident_distrib (\u03bb x, (f x) ^ 2) (\u03bb x, (g x) ^ 2) \u03bc \u03bd :=\nh.comp (measurable_id.pow_const 2)\n\nprotected lemma coe_nnreal_ennreal {f : \u03b1 \u2192 \u211d\u22650} {g : \u03b2 \u2192 \u211d\u22650} (h : ident_distrib f g \u03bc \u03bd) :\n  ident_distrib (\u03bb x, (f x : \u211d\u22650\u221e)) (\u03bb x, (g x : \u211d\u22650\u221e)) \u03bc \u03bd :=\nh.comp measurable_coe_nnreal_ennreal\n\n@[to_additive]\nlemma mul_const [has_mul \u03b3] [has_measurable_mul \u03b3] (h : ident_distrib f g \u03bc \u03bd) (c : \u03b3) :\n  ident_distrib (\u03bb x, f x * c) (\u03bb x, g x * c) \u03bc \u03bd :=\nh.comp (measurable_mul_const c)\n\n@[to_additive]\nlemma const_mul [has_mul \u03b3] [has_measurable_mul \u03b3] (h : ident_distrib f g \u03bc \u03bd) (c : \u03b3) :\n  ident_distrib (\u03bb x, c * f x) (\u03bb x, c * g x) \u03bc \u03bd :=\nh.comp (measurable_const_mul c)\n\n@[to_additive]\nlemma div_const [has_div \u03b3] [has_measurable_div \u03b3] (h : ident_distrib f g \u03bc \u03bd) (c : \u03b3) :\n  ident_distrib (\u03bb x, f x / c) (\u03bb x, g x / c) \u03bc \u03bd :=\nh.comp (has_measurable_div.measurable_div_const c)\n\n@[to_additive]\nlemma const_div [has_div \u03b3] [has_measurable_div \u03b3] (h : ident_distrib f g \u03bc \u03bd) (c : \u03b3) :\n  ident_distrib (\u03bb x, c / f x) (\u03bb x, c / g x) \u03bc \u03bd :=\nh.comp (has_measurable_div.measurable_const_div c)\n\nlemma evariance_eq {f : \u03b1 \u2192 \u211d} {g : \u03b2 \u2192 \u211d} (h : ident_distrib f g \u03bc \u03bd) :\n  evariance f \u03bc = evariance g \u03bd :=\nbegin\n  convert (h.sub_const (\u222b x, f x \u2202\u03bc)).nnnorm.coe_nnreal_ennreal.sq.lintegral_eq,\n  rw h.integral_eq,\n  refl\nend\n\nlemma variance_eq {f : \u03b1 \u2192 \u211d} {g : \u03b2 \u2192 \u211d} (h : ident_distrib f g \u03bc \u03bd) :\n  variance f \u03bc = variance g \u03bd :=\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] {\u03bc : measure \u03b1} [is_finite_measure \u03bc]\n\n/-- This lemma is superceded by `mem_\u2112p.uniform_integrable_of_ident_distrib` which only require\n`ae_strongly_measurable`. -/\nlemma mem_\u2112p.uniform_integrable_of_ident_distrib_aux {\u03b9 : Type*} {f : \u03b9 \u2192 \u03b1 \u2192 E}\n  {j : \u03b9} {p : \u211d\u22650\u221e} (hp : 1 \u2264 p) (hp' : p \u2260 \u221e)\n  (h\u2112p : mem_\u2112p (f j) p \u03bc) (hfmeas : \u2200 i, strongly_measurable (f i))\n  (hf : \u2200 i, ident_distrib (f i) (f j) \u03bc \u03bc) :\n  uniform_integrable f p \u03bc :=\nbegin\n  refine uniform_integrable_of' hp hp' hfmeas (\u03bb \u03b5 h\u03b5, _),\n  by_cases h\u03b9 : nonempty \u03b9,\n  swap, { exact \u27e80, \u03bb i, false.elim (h\u03b9 $ nonempty.intro i)\u27e9 },\n  obtain \u27e8C, hC\u2081, hC\u2082\u27e9 := h\u2112p.snorm_indicator_norm_ge_pos_le \u03bc (hfmeas _) h\u03b5,\n  have hmeas : \u2200 i, measurable_set {x | (\u27e8C, hC\u2081.le\u27e9 : \u211d\u22650) \u2264 \u2016f i x\u2016\u208a} :=\n    \u03bb i, measurable_set_le measurable_const (hfmeas _).measurable.nnnorm,\n  refine \u27e8\u27e8C, hC\u2081.le\u27e9, \u03bb i, le_trans (le_of_eq _) hC\u2082\u27e9,\n  have : {x : \u03b1 | (\u27e8C, hC\u2081.le\u27e9 : \u211d\u22650) \u2264 \u2016f i x\u2016\u208a}.indicator (f i) =\n    (\u03bb x : E, if (\u27e8C, hC\u2081.le\u27e9 : \u211d\u22650) \u2264 \u2016x\u2016\u208a then x else 0) \u2218 (f i),\n  { ext x,\n    simp only [set.indicator, set.mem_set_of_eq] },\n  simp_rw [coe_nnnorm, this],\n  rw [\u2190 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\u1d56 functions is p-uniformly integrable. -/\nlemma mem_\u2112p.uniform_integrable_of_ident_distrib {\u03b9 : Type*} {f : \u03b9 \u2192 \u03b1 \u2192 E}\n  {j : \u03b9} {p : \u211d\u22650\u221e} (hp : 1 \u2264 p) (hp' : p \u2260 \u221e)\n  (h\u2112p : mem_\u2112p (f j) p \u03bc) (hf : \u2200 i, ident_distrib (f i) (f j) \u03bc \u03bc) :\n  uniform_integrable f p \u03bc :=\nbegin\n  have hfmeas : \u2200 i, ae_strongly_measurable (f i) \u03bc :=\n    \u03bb i, (hf i).ae_strongly_measurable_iff.2 h\u2112p.1,\n  set g : \u03b9 \u2192 \u03b1 \u2192 E := \u03bb i, (hfmeas i).some,\n  have hgmeas : \u2200 i, strongly_measurable (g i) := \u03bb i, (Exists.some_spec $ hfmeas i).1,\n  have hgeq : \u2200 i, g i =\u1d50[\u03bc] f i := \u03bb i, (Exists.some_spec $ hfmeas i).2.symm,\n  have hg\u2112p : mem_\u2112p (g j) p \u03bc := h\u2112p.ae_eq (hgeq j).symm,\n  exact uniform_integrable.ae_eq (mem_\u2112p.uniform_integrable_of_ident_distrib_aux hp hp'\n    hg\u2112p hgmeas $\n    \u03bb 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": "/-\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-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.algebra.geom_sum\nimport Mathlib.ring_theory.ideal.basic\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\n\ntheorem dvd_sub_pow_of_dvd_sub {R : Type u_1} [comm_ring R] {p : \u2115} {a : R} {b : R} (h : \u2191p \u2223 a - b)\n    (k : \u2115) : \u2191p ^ (k + 1) \u2223 a ^ p ^ k - b ^ p ^ 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/number_theory/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4937592526151671}}
{"text": "import tactic\n\ndef square {A B : Type*} (R : A \u2192 B \u2192 Prop) : Prop :=\n\u2200 x\u2081 x\u2082 y\u2081 y\u2082, R x\u2081 y\u2081 \u2192 R x\u2082 y\u2081 \u2192 R x\u2082 y\u2082 \u2192 R x\u2081 y\u2082\n\nstructure edge (X Y : Type) : Type :=\n( R : X \u2192 Y \u2192 Prop )\n( square : square R )\n\nnamespace edge\n\nvariables {X Y : Type}\n\ndef le : edge X Y \u2192 edge X Y \u2192 Prop :=\n\u03bb e\u2081 e\u2082, \u2203 (f : X \u2192 X) (g : Y \u2192 Y), \u2200 x y, e\u2081.R (f x) y \u2194 e\u2082.R x (g y)\n\ninstance : preorder (edge X Y) :=\n{ le := le,\n  le_refl := \u03bb _, \u27e8id, id, \u03bb _ _, iff.rfl\u27e9,\n  le_trans := \u03bb a b c \u27e8f\u2081, g\u2081, h\u2081\u27e9 \u27e8f\u2082, g\u2082, h\u2082\u27e9, \n    \u27e8f\u2081 \u2218 f\u2082, g\u2082 \u2218 g\u2081, \u03bb x y, (h\u2081 _ _).trans $ h\u2082 _ _\u27e9 }\n\ndef of_fun (f : X \u2192 Y) : edge X Y := \n{ R := \u03bb x y, f x = y,\n  square := \u03bb _ _ _ _, by cc }\n\nlemma maximal_of_fun (f : X \u2192 Y) (E : edge X Y) (h : of_fun f \u2264 E) : \n  E \u2264 of_fun f :=\nbegin\n  rcases h with \u27e8a, b, h\u27e9,\n  \n  refine \u27e8a, b, _\u27e9,\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 (\u03b1 : Type) :=\n-- \u03b1 represents the type of squares on the chessboard\n(left : \u03b1 \u2192 \u03b1 \u2192 Prop)\n(white_turn : Prop)\n(K : \u03b1 \u2192 Prop)  -- Is the White king on this square?\n(k : \u03b1 \u2192 Prop)  -- ...    Black ...\n(left_nonrefl : \u2200 x y, left x y \u2192 x \u2260 y)\n(left_trans : \u2200 x y z, left x y \u2227 left y z \u2192 left x z)\n(square_one_piece_K : \u2200 x, K x \u2192 \u00ac k x)\n(square_one_piece_k : \u2200 x, k x \u2192 \u00ac K x)\n\nvariables {\u03b1 : Type} (G : gamestate \u03b1)\n\ndef adjleft (x y : \u03b1) := G.left x y \u2227 (\u2200 z, \u00ac G.left x z \u2227 \u00ac 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 : \u03b1) := G.K x \u2227 (adjleft G x y \u2228 adjleft G y x)\ndef can'_black (x y : \u03b1) := G.k x \u2227 (adjleft G x y \u2228 adjleft G y x)\ndef can' (x y : \u03b1) := (G.white_turn \u2192 can'_white G x y) \u2227 (\u00ac G.white_turn \u2192 can'_black G x y)\n\n-- `can_<color> x y` iff only 1 and 2 from above hold\ndef can_white (x y : \u03b1) := G.K x \u2227 \u00ac G.K y \u2227 (adjleft G x y \u2228 adjleft G y x)\ndef can_black (x y : \u03b1) := G.k x \u2227 \u00ac G.k y \u2227 (adjleft G x y \u2228 adjleft G y x)\ndef can (x y : \u03b1) := (G.white_turn \u2192 can_white G x y) \u2227 (\u00ac G.white_turn \u2192 can_black G x y)\n\ndef checked_white := \u2203 (x y : \u03b1), G.K y \u2227 can_black G x y\ndef checked_black := \u2203 (x y : \u03b1), G.k y \u2227 can_white G x y\ndef checked := (G.white_turn \u2192 checked_white G) \u2227 (\u00ac G.white_turn \u2192 checked_black G)\ndef checking := (G.white_turn \u2192 checked_black G) \u2227 (\u00ac G.white_turn \u2192 checked_white G)\n\ndef move (x y : \u03b1) (h : can G x y) : gamestate \u03b1 :=\n{ left := G.left,\n  white_turn := \u00ac 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 := \u03bb z, ite (z = x) false\n    (ite (z = y) (G.K x) (G.K z)),\n  k := \u03bb 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 : \u03b1) (h : can G x y) := \u00ac checking (move G x y h)\ndef got_can := \u2203 (x y : \u03b1), can G x y\ndef got_legal := \u2203 (x y : \u03b1) {h : can G x y}, legal G x y h\ndef stalemated := \u00ac checked G \u2227 (\u00ac got_can G \u2228 \u00ac got_legal G)\ndef checkmated := checked G \u2227 (\u00ac got_can G \u2228 \u00ac got_legal G)\n\ndef winning : \u2115 \u2192 gamestate \u03b1 \u2192 Prop\n| 0 := \u03bb G, \u00ac G.white_turn \u2227 checkmated G\n| (k+1) := \u03bb G, \u00ac stalemated G \u2227 got_can G \u2227\n  (\u00ac G.white_turn \u2192 \u2200 (x y : \u03b1) {h : can G x y}, legal G x y h \u2227 winning k (move G x y h)) \u2227\n  (G.white_turn \u2192 \u2203 (x y : \u03b1) (h : can G x y), legal G x y h \u2227 winning k (move G x y h))\n\ndef losing : \u2115 \u2192 gamestate \u03b1 \u2192 Prop\n| 0 := \u03bb G, G.white_turn \u2227 checkmated G\n| (k+1) := \u03bb G, \u00ac stalemated G \u2227 got_can G \u2227\n  (G.white_turn \u2192 \u2200 (x y : \u03b1) {h : can G x y}, legal G x y h \u2227 losing k (move G x y h)) \u2227\n  (\u00ac G.white_turn \u2192 \u2203 (x y : \u03b1) (h : can G x y), legal G x y h \u2227 losing k (move G x y h))\n\ndef draw := \u2200 (k : \u2115), \u00ac winning k G \u2227 \u00ac 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 : \u03b1} (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 : \u03b1) := G.K x \u2227 (\u2200 (z : \u03b1), G.K z \u2192 z = x)\ndef one_black_piece (x : \u03b1) := G.k x \u2227 (\u2200 (z : \u03b1), G.k z \u2192 z = x)\n\nlemma adj_of_can {x y : \u03b1} (hcan : can G x y) : adjleft G x y \u2228 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 : \u03b1} (h : adjleft G x y \u2228 adjleft G y x) : x \u2260 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 : \u03b1} (hcan : can G x y) : x \u2260 y := neq_of_adj G (adj_of_can G hcan)\n\nlemma K_of_move {x y : \u03b1} (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 : \u03b1} (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 : \u03b1} (hK : G.K x) (hk : G.k z) (hcan : can G x y)\n  (hxz : x \u2260 z) (hyz : y \u2260 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 : \u03b1} (hk : G.k x) (hK : G.K z) (hcan : can G x y)\n  (hxz : x \u2260 z) (hyz : y \u2260 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 : \u03b1} (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 \u2260 x := \u03bb 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 : \u03b1} (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 \u2260 x := \u03bb 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 : \u03b1} (hblack : \u00ac G.white_turn) (hone : one_white_piece G z)\n  (hcan : can G x y) (hyz : y \u2260 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 : \u03b1} (hwhite : G.white_turn) (hone : one_black_piece G z)\n  (hcan : can G x y) (hyz : y \u2260 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 : \u03b1} (hcan : can G x y) : adjleft G x y \u2228 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 := \u2203 (x y : \u03b1), one_white_piece G x \u2227 one_black_piece G y \u2227 \u00ac adjleft G x y \u2227 \u00ac adjleft G y x\n\n-- 1. A KvK position is a check for neither player\nlemma KvK_no_check (h : KvK G) : \u00ac 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 \u27e8x', y', hx', hy', hnotadj\u27e9,\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 \u27e8x', y', hx', hy', hnotadj\u27e9,\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 : \u03b1} (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 \u27e8x1, x2, hx1, hx2, hnotadj\u27e9,\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 \u2260 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 \u2260 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 (\u03bb h, (KvK_no_check G hG) (check_of_checkmate G h)) },\n    unfold losing,\n    rw not_and_distrib,\n    right,\n    exact (\u03bb 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 \u27e8x, y, hxy\u27e9,\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 \u27e8x, y, hxy\u27e9,\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 \u2192 q \u2192 p := \u03bb hp : p, \u03bb 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 {\u03b1} (S : Rel \u03b1) where\n    RedForm  : \u03b1 \u2192 Prop \n    NormForm : \u03b1 \u2192 Prop\n    norm_red : \u2200 x, NormForm x \u2192 RedForm x\n    norm_eq  : \u2200 x y, S x y \u2192 NormForm x \u2192 NormForm y \u2192 x = y\n\n  open QForm\n\n  class IsQHomR (S : Rel \u03b1) (R : Rel \u03b2) [QForm S] [QForm R] (f : \u03b1 \u2192 \u03b2) extends IsQHom S R f where\n    preserve_red : \u2200 x : \u03b1, RedForm S x \u2192 RedForm R (f x)\n\n  class IsQHomN (S : Rel \u03b1) (R : Rel \u03b2) [QForm S] [QForm R] (f : \u03b1 \u2192 \u03b2) extends IsQHomR S R f where\n    preserve_norm : \u2200 x : \u03b1, NormForm S x \u2192 NormForm R (f x)\n\n  ---\n  \n  class QReduce {\u03b1} (S : Rel \u03b1) [QForm S] where\n    reduce : \u03b1 \u2192 \u03b1\n    is_reduce : \u2200 x, RedForm S (reduce x)\n    eq_reduce : \u2200 x, \u27e6x, S\u27e7 = \u27e6reduce x\u27e7\n    preserve_norm : \u2200 x, NormForm S x \u2192 NormForm S (reduce x)\n\n  class Reduce (\u03b1) where\n    reduce : \u03b1 \u2192 \u03b1\n    id_reduce : \u2200 x : \u03b1, reduce x = x\n\n  ---\n  \n  class QNormalize {\u03b1} (S : Rel \u03b1) [QForm S] where\n    normalize : \u03b1 \u2192 \u03b1\n    is_normalize : \u2200 x, NormForm S (normalize x)\n    eq_normalize : \u2200 x, \u27e6x, S\u27e7 = \u27e6normalize x\u27e7\n\n  class Normalize (\u03b1) where\n    normalize : \u03b1 \u2192 \u03b1\n    id_normalize : \u2200 x : \u03b1, normalize x = x\n\n  ---\n\n  -- This just tags `Repr` in which form they are\n  inductive QRepr {\u03b1} (S : Rel \u03b1) [QForm S] where\n    | raw  (x : \u03b1) : QRepr S\n    | red  (x : \u03b1) (h : RedForm S x)  : QRepr S\n    | norm (x : \u03b1) (h : NormForm S x) : QRepr S\n\n  namespace QRepr \n\n    variable {\u03b1} {S : Rel \u03b1} [QForm S]\n\n    def repr (x : QRepr S) : \u03b1 :=\n      match x with\n      | raw  x   => x\n      | red  x _ => x\n      | norm x _ => x\n\n    @[simp]\n    theorem raw_repr (x : \u03b1) : (raw x : QRepr S).repr = x := by simp[repr] done\n\n    @[simp]\n    theorem red_repr (x : \u03b1) (h : RedForm S x) : (red x h : QRepr S).repr = x := by simp[repr] done\n\n    @[simp]\n    theorem norm_repr (x : \u03b1) (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'  \u2192 Repr'  \u2192 Prop} [Symbolic R']\n    -- variable {Repr''} {R'' : Repr'' \u2192 Repr'' \u2192 Prop} [Symbolic R'']\n\n    -- def lift (f : Repr \u2192 Repr') (x : QRepr R) : QRepr R' := raw (f x.repr)\n\n    -- def lift\u2082 (f : Repr \u2192 Repr' \u2192 Repr'') (x : QRepr R) (x' : QRepr R') : QRepr R'' :=\n    --   raw (f x.repr x'.repr)\n\n    -- def liftHom (f : Repr \u2192 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 \u2192 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\u2082 (f : Repr \u2192 Repr' \u2192 Repr'') (h : SHom\u2082 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' {\u03b1} (S : Rel \u03b1) [QForm S]\n  := Quot (\u03bb x y : QRepr S => S x.repr y.repr)\n\nnamespace Quot'\n\n  variable {\u03b1} {S : Rel \u03b1} [QForm S]\n\n  -- Normalized representant is unique, follows from `QForm.norm_eq`\n  def nrepr [QNormalize S] : Quot' S \u2192 \u03b1 := Quot.lift (\u03bb 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) : \u03b1 := 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 : \u00ac p`.\n`by_contra' h` can be used to name the hypothesis `h : \u00ac p`.\nThe hypothesis `\u00ac p` will be negation normalized using `push_neg`.\nFor instance, `\u00ac a < b` will be changed to `b \u2264 a`.\n`by_contra' h : q` will normalize negations in `\u00ac 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 \u2264 1 \u22a2 false\nend\n\nexample : 1 < 2 :=\nbegin\n  by_contra' h : \u00ac 1 < 2,\n  -- h : \u00ac 1 < 2 \u22a2 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 \u2190 target\n  mk_mapp `classical.by_contradiction [some tgt] >>= tactic.eapply\n  let h\u2081 \u2190 tactic.intro h\n  let t' \u2190 infer_type h\u2081\n  let-- negation-normalize `t'` to the expression `e'` and get a proof `pr'` of `t' = e'`\n    (e', pr')\n    \u2190 push_neg.normalize_negations t' <|> refl_conv t'\n  match t with\n    | none => () <$ replace_hyp h\u2081 e' pr'\n    | some t => do\n      let t \u2190 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        \u2190 push_neg.normalize_negations t <|> refl_conv t\n      unify e e'\n      () <$ (mk_eq_symm pr >>= mk_eq_trans pr' >>= replace_hyp h\u2081 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 `\u03a0\u2080 i, \u03b1 i` when `\u03b1` itself is locally\nfinite and calculates the cardinality of its finite intervals.\n-/\n\n\nopen Dfinsupp Finset\n\nopen BigOperators Pointwise\n\nvariable {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _}\n\nnamespace Finset\n\nvariable [DecidableEq \u03b9] [\u2200 i, Zero (\u03b1 i)] {s : Finset \u03b9} {f : \u03a0\u2080 i, \u03b1 i} {t : \u2200 i, Finset (\u03b1 i)}\n\n#print Finset.dfinsupp /-\n/-- Finitely supported product of finsets. -/\ndef dfinsupp (s : Finset \u03b9) (t : \u2200 i, Finset (\u03b1 i)) : Finset (\u03a0\u2080 i, \u03b1 i) :=\n  (s.pi t).map\n    \u27e8fun 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 \u27e8i, hi\u27e9\u27e9\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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] (s : Finset.{u1} \u03b9) (t : forall (i : \u03b9), Finset.{u2} (\u03b1 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) (Finset.dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_2 i) s t)) (Finset.prod.{0, u1} Nat \u03b9 Nat.commMonoid s (fun (i : \u03b9) => Finset.card.{u2} (\u03b1 i) (t i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] (s : Finset.{u2} \u03b9) (t : forall (i : \u03b9), Finset.{u1} (\u03b1 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) (Finset.dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_2 i) s t)) (Finset.prod.{0, u2} Nat \u03b9 Nat.commMonoid s (fun (i : \u03b9) => Finset.card.{u1} (\u03b1 i) (t i)))\nCase conversion may be inaccurate. Consider using '#align finset.card_dfinsupp Finset.card_dfinsupp\u2093'. -/\n@[simp]\ntheorem card_dfinsupp (s : Finset \u03b9) (t : \u2200 i, Finset (\u03b1 i)) :\n    (s.Dfinsupp t).card = \u220f i in s, (t i).card :=\n  (card_map _).trans <| card_pi _ _\n#align finset.card_dfinsupp Finset.card_dfinsupp\n\nvariable [\u2200 i, DecidableEq (\u03b1 i)]\n\n/- warning: finset.mem_dfinsupp_iff -> Finset.mem_dfinsupp_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] {s : Finset.{u1} \u03b9} {f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)} {t : forall (i : \u03b9), Finset.{u2} (\u03b1 i)} [_inst_3 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)], Iff (Membership.Mem.{max u1 u2, max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) (Finset.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i))) (Finset.hasMem.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i))) f (Finset.dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_2 i) s t)) (And (HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_2 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_2 i))))) f) s) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) -> (Membership.Mem.{u2, u2} (\u03b1 i) (Finset.{u2} (\u03b1 i)) (Finset.hasMem.{u2} (\u03b1 i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) f i) (t i))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] {s : Finset.{u2} \u03b9} {f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)} {t : forall (i : \u03b9), Finset.{u1} (\u03b1 i)} [_inst_3 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)], Iff (Membership.mem.{max u2 u1, max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) (Finset.{max u1 u2} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i))) (Finset.instMembershipFinset.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i))) f (Finset.dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_2 i) s t)) (And (HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_2 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_2 i)))) (_inst_3 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_2 i))))) f) s) (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) -> (Membership.mem.{u1, u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (Finset.{u1} (\u03b1 i)) (Finset.instMembershipFinset.{u1} (\u03b1 i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_2 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_2 i) i)) f i) (t i))))\nCase conversion may be inaccurate. Consider using '#align finset.mem_dfinsupp_iff Finset.mem_dfinsupp_iff\u2093'. -/\ntheorem mem_dfinsupp_iff : f \u2208 s.Dfinsupp t \u2194 f.support \u2286 s \u2227 \u2200 i \u2208 s, f i \u2208 t i :=\n  by\n  refine' mem_map.trans \u27e8_, _\u27e9\n  \u00b7 rintro \u27e8f, hf, rfl\u27e9\n    refine' \u27e8support_mk_subset, fun i hi => _\u27e9\n    convert mem_pi.1 hf i hi\n    exact mk_of_mem hi\n  \u00b7 refine' fun h => \u27e8fun i _ => f i, mem_pi.2 h.2, _\u27e9\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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] {s : Finset.{u1} \u03b9} {f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)} [_inst_3 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] {t : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_2 i))}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_2 i)) (fun (i : \u03b9) (x : Finset.{u2} (\u03b1 i)) => Ne.decidable.{succ u2} (Finset.{u2} (\u03b1 i)) (fun (a : Finset.{u2} (\u03b1 i)) (b : Finset.{u2} (\u03b1 i)) => Finset.decidableEq.{u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) a b) x (OfNat.ofNat.{u2} (Finset.{u2} (\u03b1 i)) 0 (OfNat.mk.{u2} (Finset.{u2} (\u03b1 i)) 0 (Zero.zero.{u2} (Finset.{u2} (\u03b1 i)) (Finset.zero.{u2} (\u03b1 i) (_inst_2 i)))))) t) s) -> (Iff (Membership.Mem.{max u1 u2, max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) (Finset.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i))) (Finset.hasMem.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i))) f (Finset.dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_2 i) s (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_2 i))) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_2 i))) => forall (i : \u03b9), Finset.{u2} (\u03b1 i)) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_2 i))) t))) (forall (i : \u03b9), Membership.Mem.{u2, u2} (\u03b1 i) (Finset.{u2} (\u03b1 i)) (Finset.hasMem.{u2} (\u03b1 i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_2 i))) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_2 i))) => forall (i : \u03b9), Finset.{u2} (\u03b1 i)) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_2 i))) t i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] {s : Finset.{u2} \u03b9} {f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)} [_inst_3 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] {t : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_2 i))}, (HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_2 i)) (fun (i : \u03b9) (x : Finset.{u1} (\u03b1 i)) => instDecidableNot (Eq.{succ u1} (Finset.{u1} (\u03b1 i)) x (OfNat.ofNat.{u1} (Finset.{u1} (\u03b1 i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (\u03b1 i)) (Finset.zero.{u1} (\u03b1 i) (_inst_2 i))))) (Finset.decidableEq.{u1} (\u03b1 i) ((fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) i) x (OfNat.ofNat.{u1} (Finset.{u1} (\u03b1 i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (\u03b1 i)) (Finset.zero.{u1} (\u03b1 i) (_inst_2 i)))))) t) s) -> (Iff (Membership.mem.{max u2 u1, max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i)) (Finset.{max u1 u2} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i))) (Finset.instMembershipFinset.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_2 i))) f (Finset.dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_2 i) s (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_2 i)) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_2 i)) i)) t))) (forall (i : \u03b9), Membership.mem.{u1, u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) ((fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) i) (Finset.instMembershipFinset.{u1} (\u03b1 i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_2 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_2 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_2 i)) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 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\u2093'. -/\n/-- When `t` is supported on `s`, `f \u2208 s.dfinsupp t` precisely means that `f` is pointwise in `t`.\n-/\n@[simp]\ntheorem mem_dfinsupp_iff_of_support_subset {t : \u03a0\u2080 i, Finset (\u03b1 i)} (ht : t.support \u2286 s) :\n    f \u2208 s.Dfinsupp t \u2194 \u2200 i, f i \u2208 t i :=\n  by\n  refine'\n    mem_dfinsupp_iff.trans\n      (forall_and_distrib.symm.trans <|\n        forall_congr' fun i =>\n          \u27e8fun h => _, fun h =>\n            \u27e8fun hi => ht <| mem_support_iff.2 fun H => mem_support_iff.1 hi _, fun _ => h\u27e9\u27e9)\n  \u00b7 by_cases hi : i \u2208 s\n    \u00b7 exact h.2 hi\n    \u00b7 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  \u00b7 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 [\u2200 i, Zero (\u03b1 i)] {f : \u03a0\u2080 i, \u03b1 i} {i : \u03b9} {a : \u03b1 i}\n\n#print Dfinsupp.singleton /-\n/-- Pointwise `finset.singleton` bundled as a `dfinsupp`. -/\ndef singleton (f : \u03a0\u2080 i, \u03b1 i) : \u03a0\u2080 i, Finset (\u03b1 i)\n    where\n  toFun i := {f i}\n  support' := f.support'.map fun s => \u27e8s, fun i => (s.Prop i).imp id (congr_arg _)\u27e9\n#align dfinsupp.singleton Dfinsupp.singleton\n-/\n\n#print Dfinsupp.mem_singleton_apply_iff /-\ntheorem mem_singleton_apply_iff : a \u2208 f.singleton i \u2194 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 [\u2200 i, Zero (\u03b1 i)] [\u2200 i, PartialOrder (\u03b1 i)] [\u2200 i, LocallyFiniteOrder (\u03b1 i)]\n  {f g : \u03a0\u2080 i, \u03b1 i} {i : \u03b9} {a : \u03b1 i}\n\n#print Dfinsupp.rangeIcc /-\n/-- Pointwise `finset.Icc` bundled as a `dfinsupp`. -/\ndef rangeIcc (f g : \u03a0\u2080 i, \u03b1 i) : \u03a0\u2080 i, Finset (\u03b1 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        \u27e8fs + 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 _\u27e9\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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_2 : forall (i : \u03b9), PartialOrder.{u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_2 i))] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (g : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (i : \u03b9), Eq.{succ u2} (Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (fun (i : \u03b9) => Finset.zero.{u2} ((fun (i : \u03b9) => \u03b1 i) i) ((fun (i : \u03b9) => _inst_1 i) i))) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (fun (i : \u03b9) => Finset.zero.{u2} ((fun (i : \u03b9) => \u03b1 i) i) ((fun (i : \u03b9) => _inst_1 i) i))) => forall (i : \u03b9), Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (fun (i : \u03b9) => Finset.zero.{u2} ((fun (i : \u03b9) => \u03b1 i) i) ((fun (i : \u03b9) => _inst_1 i) i))) (Dfinsupp.rangeIcc.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) => _inst_2 i) (fun (i : \u03b9) => _inst_3 i) f g) i) (Finset.Icc.{u2} ((fun (i : \u03b9) => \u03b1 i) i) (PartialOrder.toPreorder.{u2} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_2 i)) (_inst_3 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) g i))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_2 : forall (i : \u03b9), PartialOrder.{u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_2 i))] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (g : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (i : \u03b9), Eq.{succ u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i)) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i)) i)) (Dfinsupp.rangeIcc.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) => _inst_2 i) (fun (i : \u03b9) => _inst_3 i) f g) i) (Finset.Icc.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_2 i)) (_inst_3 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_1 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_1 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_1 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_1 i) i)) g i))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.range_Icc_apply Dfinsupp.rangeIcc_apply\u2093'. -/\n@[simp]\ntheorem rangeIcc_apply (f g : \u03a0\u2080 i, \u03b1 i) (i : \u03b9) : 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 \u2208 f.rangeIcc g i \u2194 f i \u2264 a \u2227 a \u2264 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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_2 : forall (i : \u03b9), PartialOrder.{u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_2 i))] {f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)} {g : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)} [_inst_4 : DecidableEq.{succ u1} \u03b9] [_inst_5 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)], HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i)) (fun (i : \u03b9) (x : Finset.{u2} (\u03b1 i)) => Ne.decidable.{succ u2} (Finset.{u2} (\u03b1 i)) (fun (a : Finset.{u2} (\u03b1 i)) (b : Finset.{u2} (\u03b1 i)) => Finset.decidableEq.{u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_5 i a b) a b) x (OfNat.ofNat.{u2} (Finset.{u2} (\u03b1 i)) 0 (OfNat.mk.{u2} (Finset.{u2} (\u03b1 i)) 0 (Zero.zero.{u2} (Finset.{u2} (\u03b1 i)) (Finset.zero.{u2} (\u03b1 i) (_inst_1 i)))))) (Dfinsupp.rangeIcc.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) => _inst_2 i) (fun (i : \u03b9) => _inst_3 i) f g)) (Union.union.{u1} (Finset.{u1} \u03b9) (Finset.hasUnion.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b)) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_5 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_1 i))))) f) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_5 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_1 i))))) g))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_2 : forall (i : \u03b9), PartialOrder.{u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_2 i))] {f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)} {g : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)} [_inst_4 : DecidableEq.{succ u2} \u03b9] [_inst_5 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)], HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b) (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i)) (fun (i : \u03b9) (x : Finset.{u1} (\u03b1 i)) => instDecidableNot (Eq.{succ u1} (Finset.{u1} (\u03b1 i)) x (OfNat.ofNat.{u1} (Finset.{u1} (\u03b1 i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (\u03b1 i)) (Finset.zero.{u1} (\u03b1 i) (_inst_1 i))))) (Finset.decidableEq.{u1} (\u03b1 i) ((fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_5 i a b) i) x (OfNat.ofNat.{u1} (Finset.{u1} (\u03b1 i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (\u03b1 i)) (Finset.zero.{u1} (\u03b1 i) (_inst_1 i)))))) (Dfinsupp.rangeIcc.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) => _inst_2 i) (fun (i : \u03b9) => _inst_3 i) f g)) (Union.union.{u2} (Finset.{u2} \u03b9) (Finset.instUnionFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b)) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_1 i)))) (_inst_5 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_1 i))))) f) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_1 i)))) (_inst_5 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_1 i))))) g))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.support_range_Icc_subset Dfinsupp.support_rangeIcc_subset\u2093'. -/\ntheorem support_rangeIcc_subset [DecidableEq \u03b9] [\u2200 i, DecidableEq (\u03b1 i)] :\n    (f.rangeIcc g).support \u2286 f.support \u222a 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 [\u2200 i, Zero (\u03b1 i)] [DecidableEq \u03b9] [\u2200 i, DecidableEq (\u03b1 i)]\n\n#print Dfinsupp.pi /-\n/-- Given a finitely supported function `f : \u03a0\u2080 i, finset (\u03b1 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 : \u03a0\u2080 i, Finset (\u03b1 i)) : Finset (\u03a0\u2080 i, \u03b1 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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_2 : DecidableEq.{succ u1} \u03b9] [_inst_3 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] {f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i))} {g : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)}, Iff (Membership.Mem.{max u1 u2, max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (Finset.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i))) (Finset.hasMem.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i))) g (Dfinsupp.pi.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) f)) (forall (i : \u03b9), Membership.Mem.{u2, u2} (\u03b1 i) (Finset.{u2} (\u03b1 i)) (Finset.hasMem.{u2} (\u03b1 i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) g i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i))) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i))) => forall (i : \u03b9), Finset.{u2} (\u03b1 i)) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i))) f i))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_2 : DecidableEq.{succ u2} \u03b9] [_inst_3 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] {f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i))} {g : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)}, Iff (Membership.mem.{max u2 u1, max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (Finset.{max u1 u2} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i))) (Finset.instMembershipFinset.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i))) g (Dfinsupp.pi.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) f)) (forall (i : \u03b9), Membership.mem.{u1, u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) ((fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) i) (Finset.instMembershipFinset.{u1} (\u03b1 i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_1 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_1 i) i)) g i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i)) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i)) i)) f i))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.mem_pi Dfinsupp.mem_pi\u2093'. -/\n@[simp]\ntheorem mem_pi {f : \u03a0\u2080 i, Finset (\u03b1 i)} {g : \u03a0\u2080 i, \u03b1 i} : g \u2208 f.pi \u2194 \u2200 i, g i \u2208 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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_2 : DecidableEq.{succ u1} \u03b9] [_inst_3 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i))), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (Dfinsupp.pi.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) f)) (Dfinsupp.prod.{u1, u2, 0} \u03b9 Nat (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i)) (fun (i : \u03b9) (x : Finset.{u2} (\u03b1 i)) => Ne.decidable.{succ u2} (Finset.{u2} (\u03b1 i)) (fun (a : Finset.{u2} (\u03b1 i)) (b : Finset.{u2} (\u03b1 i)) => Finset.decidableEq.{u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) a b) x (OfNat.ofNat.{u2} (Finset.{u2} (\u03b1 i)) 0 (OfNat.mk.{u2} (Finset.{u2} (\u03b1 i)) 0 (Zero.zero.{u2} (Finset.{u2} (\u03b1 i)) (Finset.zero.{u2} (\u03b1 i) (_inst_1 i)))))) Nat.commMonoid f (fun (i : \u03b9) => (fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat ((Finset.{u2} (\u03b1 i)) -> Nat) (HasLiftT.mk.{1, succ u2} Nat ((Finset.{u2} (\u03b1 i)) -> Nat) (CoeTC\u2093.coe.{1, succ u2} Nat ((Finset.{u2} (\u03b1 i)) -> Nat) (Nat.castCoe.{u2} ((Finset.{u2} (\u03b1 i)) -> Nat) (Pi.hasNatCast.{u2, 0} (Finset.{u2} (\u03b1 i)) (fun (\u1fb0 : Finset.{u2} (\u03b1 i)) => Nat) (fun (a : Finset.{u2} (\u03b1 i)) => AddMonoidWithOne.toNatCast.{0} Nat (AddCommMonoidWithOne.toAddMonoidWithOne.{0} Nat (NonAssocSemiring.toAddCommMonoidWithOne.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)))))))) (Finset.card.{u2} (\u03b1 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i))) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i))) => forall (i : \u03b9), Finset.{u2} (\u03b1 i)) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u2} (\u03b1 i) (_inst_1 i))) f i))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_2 : DecidableEq.{succ u2} \u03b9] [_inst_3 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i))), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) (Dfinsupp.pi.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) f)) (Dfinsupp.prod.{u2, u1, 0} \u03b9 Nat (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b) (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i)) (fun (i : \u03b9) (x : Finset.{u1} (\u03b1 i)) => instDecidableNot (Eq.{succ u1} (Finset.{u1} (\u03b1 i)) x (OfNat.ofNat.{u1} (Finset.{u1} (\u03b1 i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (\u03b1 i)) (Finset.zero.{u1} (\u03b1 i) (_inst_1 i))))) (Finset.decidableEq.{u1} (\u03b1 i) ((fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_3 i a b) i) x (OfNat.ofNat.{u1} (Finset.{u1} (\u03b1 i)) 0 (Zero.toOfNat0.{u1} (Finset.{u1} (\u03b1 i)) (Finset.zero.{u1} (\u03b1 i) (_inst_1 i)))))) Nat.commMonoid f (fun (i : \u03b9) => Nat.cast.{u1} ((Finset.{u1} (\u03b1 i)) -> Nat) (Pi.natCast.{u1, 0} (Finset.{u1} (\u03b1 i)) (fun (a._@.Mathlib.Data.Dfinsupp.Basic._hyg.25484 : Finset.{u1} (\u03b1 i)) => Nat) (fun (a : Finset.{u1} (\u03b1 i)) => instNatCastNat)) (Finset.card.{u1} (\u03b1 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i)) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_1 i)) i)) f i))))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_pi Dfinsupp.card_pi\u2093'. -/\n@[simp]\ntheorem card_pi (f : \u03a0\u2080 i, Finset (\u03b1 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 \u03b9] [\u2200 i, DecidableEq (\u03b1 i)]\n\nvariable [\u2200 i, PartialOrder (\u03b1 i)] [\u2200 i, Zero (\u03b1 i)] [\u2200 i, LocallyFiniteOrder (\u03b1 i)]\n\ninstance : LocallyFiniteOrder (\u03a0\u2080 i, \u03b1 i) :=\n  LocallyFiniteOrder.ofIcc (\u03a0\u2080 i, \u03b1 i) (fun f g => (f.support \u222a 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 : \u03a0\u2080 i, \u03b1 i)\n\n/- warning: dfinsupp.Icc_eq -> Dfinsupp.Icc_eq is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u2} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i))) (Finset.Icc.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g) (Finset.dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (Union.union.{u1} (Finset.{u1} \u03b9) (Finset.hasUnion.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) g)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (fun (i : \u03b9) => Finset.zero.{u2} ((fun (i : \u03b9) => \u03b1 i) i) ((fun (i : \u03b9) => _inst_4 i) i))) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (fun (i : \u03b9) => Finset.zero.{u2} ((fun (i : \u03b9) => \u03b1 i) i) ((fun (i : \u03b9) => _inst_4 i) i))) => forall (i : \u03b9), Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => Finset.{u2} ((fun (i : \u03b9) => \u03b1 i) i)) (fun (i : \u03b9) => Finset.zero.{u2} ((fun (i : \u03b9) => \u03b1 i) i) ((fun (i : \u03b9) => _inst_4 i) i))) (Dfinsupp.rangeIcc.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_5 i) f g)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u1} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{max (succ u2) (succ u1)} (Finset.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i))) (Finset.Icc.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g) (Finset.dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (Union.union.{u2} (Finset.{u2} \u03b9) (Finset.instUnionFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) g)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_4 i)) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.{u1} (\u03b1 i)) i) (fun (i : \u03b9) => (fun (i : \u03b9) => Finset.zero.{u1} (\u03b1 i) (_inst_4 i)) i)) (Dfinsupp.rangeIcc.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_5 i) f g)))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.Icc_eq Dfinsupp.Icc_eq\u2093'. -/\ntheorem Icc_eq : Icc f g = (f.support \u222a 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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u2} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Finset.Icc.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g)) (Finset.prod.{0, u1} Nat \u03b9 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b9) (Finset.hasUnion.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) g)) (fun (i : \u03b9) => Finset.card.{u2} (\u03b1 i) (Finset.Icc.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i)) (_inst_5 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) g i))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u1} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Finset.Icc.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g)) (Finset.prod.{0, u2} Nat \u03b9 Nat.commMonoid (Union.union.{u2} (Finset.{u2} \u03b9) (Finset.instUnionFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) g)) (fun (i : \u03b9) => Finset.card.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (Finset.Icc.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)) (_inst_5 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) g i))))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_Icc Dfinsupp.card_Icc\u2093'. -/\ntheorem card_Icc : (Icc f g).card = \u220f i in f.support \u222a 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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u2} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Finset.Ico.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat \u03b9 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b9) (Finset.hasUnion.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) g)) (fun (i : \u03b9) => Finset.card.{u2} (\u03b1 i) (Finset.Icc.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i)) (_inst_5 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _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 {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u1} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Finset.Ico.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u2} Nat \u03b9 Nat.commMonoid (Union.union.{u2} (Finset.{u2} \u03b9) (Finset.instUnionFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) g)) (fun (i : \u03b9) => Finset.card.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (Finset.Icc.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)) (_inst_5 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _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\u2093'. -/\ntheorem card_Ico : (Ico f g).card = (\u220f i in f.support \u222a 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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u2} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Finset.Ioc.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat \u03b9 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b9) (Finset.hasUnion.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) g)) (fun (i : \u03b9) => Finset.card.{u2} (\u03b1 i) (Finset.Icc.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i)) (_inst_5 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _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 {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u1} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Finset.Ioc.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u2} Nat \u03b9 Nat.commMonoid (Union.union.{u2} (Finset.{u2} \u03b9) (Finset.instUnionFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) g)) (fun (i : \u03b9) => Finset.card.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (Finset.Icc.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)) (_inst_5 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _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\u2093'. -/\ntheorem card_Ioc : (Ioc f g).card = (\u220f i in f.support \u222a 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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u2} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u2} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Finset.Ioo.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i))) (Dfinsupp.locallyFiniteOrder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat \u03b9 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b9) (Finset.hasUnion.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (_inst_4 i))))) g)) (fun (i : \u03b9) => Finset.card.{u2} (\u03b1 i) (Finset.Icc.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (_inst_3 i)) (_inst_5 i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) f i) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _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 {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), PartialOrder.{u1} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), Zero.{u1} (\u03b1 i)] [_inst_5 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (g : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Finset.Ioo.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i)) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (_inst_3 i))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) => _inst_5 i)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u2} Nat \u03b9 Nat.commMonoid (Union.union.{u2} (Finset.{u2} \u03b9) (Finset.instUnionFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) f) (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => _inst_4 i) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i)))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (_inst_4 i))))) g)) (fun (i : \u03b9) => Finset.card.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (Finset.Icc.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)) (_inst_5 i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _inst_4 i) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => _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\u2093'. -/\ntheorem card_Ioo : (Ioo f g).card = (\u220f i in f.support \u222a 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 \u03b9] [\u2200 i, DecidableEq (\u03b1 i)]\n\nvariable [\u2200 i, CanonicallyOrderedAddMonoid (\u03b1 i)] [\u2200 i, LocallyFiniteOrder (\u03b1 i)]\n\nvariable (f : \u03a0\u2080 i, \u03b1 i)\n\n/- warning: dfinsupp.card_Iic -> Dfinsupp.card_Iic is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), CanonicallyOrderedAddMonoid.{u2} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) (Finset.Iic.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))) (Dfinsupp.orderBot.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_3 i)) (Dfinsupp.locallyFiniteOrder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))) (fun (i : \u03b9) => _inst_4 i))) f)) (Finset.prod.{0, u1} Nat \u03b9 Nat.commMonoid (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))))))) f) (fun (i : \u03b9) => Finset.card.{u2} (\u03b1 i) (Finset.Iic.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))) (CanonicallyOrderedAddMonoid.toOrderBot.{u2} (\u03b1 i) (_inst_3 i)) (_inst_4 i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) f i))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), CanonicallyOrderedAddMonoid.{u1} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u1} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (\u03b1 i) (_inst_3 i))))] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))) (Finset.Iic.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u1} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (\u03b1 i) (_inst_3 i))))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u1} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (\u03b1 i) (_inst_3 i))))) (Dfinsupp.instOrderBotDfinsuppToZeroToAddMonoidToAddCommMonoidToOrderedAddCommMonoidInstLEDfinsuppToLEToPreorderToPartialOrder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_3 i)) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => OrderedAddCommMonoid.toPartialOrder.{u1} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (\u03b1 i) (_inst_3 i))) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) (fun (i : \u03b9) => _inst_4 i))) f)) (Finset.prod.{0, u2} Nat \u03b9 Nat.commMonoid (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))))))) f) (fun (i : \u03b9) => Finset.card.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (Finset.Iic.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)))) (CanonicallyOrderedAddMonoid.toOrderBot.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)) (_inst_4 i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) i)) f i))))\nCase conversion may be inaccurate. Consider using '#align dfinsupp.card_Iic Dfinsupp.card_Iic\u2093'. -/\ntheorem card_Iic : (Iic f).card = \u220f 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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u2} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), CanonicallyOrderedAddMonoid.{u2} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), LocallyFiniteOrder.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))] (f : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))), Eq.{1} Nat (Finset.card.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) (Finset.Iio.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{max u1 u2} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) (Dfinsupp.preorder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))) (Dfinsupp.orderBot.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_3 i)) (Dfinsupp.locallyFiniteOrder.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))) (fun (i : \u03b9) => _inst_4 i))) f)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat \u03b9 Nat.commMonoid (Dfinsupp.support.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))) (fun (i : \u03b9) (x : \u03b1 i) => Ne.decidable.{succ u2} (\u03b1 i) (fun (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) x (OfNat.ofNat.{u2} (\u03b1 i) 0 (OfNat.mk.{u2} (\u03b1 i) 0 (Zero.zero.{u2} (\u03b1 i) (AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))))))))) f) (fun (i : \u03b9) => Finset.card.{u2} (\u03b1 i) (Finset.Iic.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u2} (\u03b1 i) (PartialOrder.toPreorder.{u2} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i)))) (CanonicallyOrderedAddMonoid.toOrderBot.{u2} (\u03b1 i) (_inst_3 i)) (_inst_4 i)) (coeFn.{succ (max u1 u2), max (succ u1) (succ u2)} (Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) (fun (_x : Dfinsupp.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 i) (_inst_3 i))))))) => forall (i : \u03b9), \u03b1 i) (Dfinsupp.hasCoeToFun.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddZeroClass.toHasZero.{u2} (\u03b1 i) (AddMonoid.toAddZeroClass.{u2} (\u03b1 i) (AddCommMonoid.toAddMonoid.{u2} (\u03b1 i) (OrderedAddCommMonoid.toAddCommMonoid.{u2} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} (\u03b1 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 {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : forall (i : \u03b9), DecidableEq.{succ u1} (\u03b1 i)] [_inst_3 : forall (i : \u03b9), CanonicallyOrderedAddMonoid.{u1} (\u03b1 i)] [_inst_4 : forall (i : \u03b9), LocallyFiniteOrder.{u1} (\u03b1 i) (PartialOrder.toPreorder.{u1} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u1} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (\u03b1 i) (_inst_3 i))))] (f : Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))), Eq.{1} Nat (Finset.card.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))) (Finset.Iio.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u1} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (\u03b1 i) (_inst_3 i))))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{max u2 u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))) (Dfinsupp.instPreorderDfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} (\u03b1 i) (OrderedAddCommMonoid.toPartialOrder.{u1} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (\u03b1 i) (_inst_3 i))))) (Dfinsupp.instOrderBotDfinsuppToZeroToAddMonoidToAddCommMonoidToOrderedAddCommMonoidInstLEDfinsuppToLEToPreorderToPartialOrder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_3 i)) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) (a : \u03b1 i) (b : \u03b1 i) => _inst_2 i a b) (fun (i : \u03b9) => OrderedAddCommMonoid.toPartialOrder.{u1} (\u03b1 i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} (\u03b1 i) (_inst_3 i))) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) (fun (i : \u03b9) => _inst_4 i))) f)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u2} Nat \u03b9 Nat.commMonoid (Dfinsupp.support.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) (fun (i : \u03b9) (x : \u03b1 i) => instDecidableNot (Eq.{succ u1} (\u03b1 i) x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i)))))))) (_inst_2 i x (OfNat.ofNat.{u1} (\u03b1 i) 0 (Zero.toOfNat0.{u1} (\u03b1 i) (AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))))))) f) (fun (i : \u03b9) => Finset.card.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (Finset.Iic.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)))) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (PartialOrder.toPreorder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)))) (CanonicallyOrderedAddMonoid.toOrderBot.{u1} ((fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) i) (_inst_3 i)) (_inst_4 i)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Dfinsupp.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (_inst_3 i))))) i)) \u03b9 (fun (_x : \u03b9) => (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) _x) (Dfinsupp.funLike.{u2, u1} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => \u03b1 i) i) (fun (i : \u03b9) => (fun (i : \u03b9) => AddMonoid.toZero.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (AddCommMonoid.toAddMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (OrderedAddCommMonoid.toAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 i) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (i : \u03b9) => \u03b1 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\u2093'. -/\ntheorem card_Iio : (Iio f).card = (\u220f 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 \u2192 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 \u2192 Cat \u2192 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} \u2192 (X : Obj C) \u2192 Prop\n| _, Obj.var _ _     => False\n| _, Obj.varApp _ X  => ObjContainsRAdj L X\n| _, Obj.rAdjApp F X => FuncContainsRAdj L F \u2228 ObjContainsRAdj L X \u2228 HEq L F\n\ndef FuncContainsRAdj {C' D' : Cat} (L : Func C' D') : {C D : Cat} \u2192 (F : Func C D) \u2192 Prop\n| _, _, Func.id _         => False\n| _, _, Func.compVar G v  => FuncContainsRAdj L G\n| _, _, Func.compRAdj G H => FuncContainsRAdj L G \u2228 FuncContainsRAdj L H \u2228 HEq L H\n\nend\n\nnoncomputable def Func.compAux {D E : Cat} (G : Func D E) : (C : Cat) \u2192 (F : Func C D) \u2192 Func C E :=\n@Func.recOn (\u03bb _ _ => Unit) (\u03bb D E G => (C : Cat) \u2192 (F : Func C D) \u2192 Func C E)\n  D E G\n  (\u03bb _ _ => ())\n  (\u03bb _ _ _ => ())\n  (\u03bb _ _ _ _ => ())\n  (\u03bb _ _ F => F)\n  (\u03bb D v ih C F => compVar (ih _ F) v)\n  (\u03bb 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) \u2192 Obj D :=\n@Func.recOn (\u03bb _ _ => Unit) (\u03bb C D _ => Obj C \u2192 Obj D)\n  C D F\n  (\u03bb _ _ => ())\n  (\u03bb _ _ _ => ())\n  (\u03bb _ _ _ _ => ())\n  (\u03bb _ X => X)\n  (\u03bb F v ih X => Obj.varApp v (ih X))\n  (\u03bb 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} \u2192 (X Y : Obj C) \u2192 \u03a3 D : Cat, Obj D \u00d7 Obj D\n| C, X, rAdjApp F Y => cases (F.app X) Y\n| C, X,           Y => \u27e8C, X, Y\u27e9\n\ntheorem FuncAppContainsRAdj {C' D' : Cat} (G : Func C' D') :\n  {C D : Cat} \u2192 (F : Func C D) \u2192 (X : Obj C) \u2192\n  ObjContainsRAdj G (F.app X) \u2194 FuncContainsRAdj G F \u2228 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} \u2192 {X Y : Obj E} \u2192 {F : Func C D} \u2192\n  ObjContainsRAdj F (X.cases Y).2.1 \u2192 ObjContainsRAdj F X \u2228 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} \u2192 {X Y : Obj E} \u2192 {F : Func C D} \u2192\n  ObjContainsRAdj F (X.cases Y).2.2 \u2192 ObjContainsRAdj F X \u2228 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} \u2192 (X Y : Obj C) \u2192 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 \u2192 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} \u2192 (X Y : Obj C) \u2192 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} \u2192 {X Y : Obj C} \u2192 HomAux X Y \u2192 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} \u2192 {X Y : Obj C} \u2192 Hom X Y \u2192 Prop\n| _, _, _, Hom.id _ => False\n| _, _, _, Hom.comp' f g => HomAuxContainsVar A B v f \u2228 HomContainsVar A B v g\n\nend\n\nmutual\n\nnoncomputable def HomAuxContainsRAdj {C' D' : Cat} (F : Func C' D') :\n  {C : Cat} \u2192 {X Y : Obj C} \u2192 HomAux X Y \u2192 Prop\n| _, _, _, HomAux.mapVar _ f   => HomAuxContainsRAdj F f\n| _, _, _, HomAux.mapRAdj G f  => HomAuxContainsRAdj F f \u2228 HEq F G\n  \u2228 FuncContainsRAdj F G\n| _, _, _, @HomAux.var _ X Y w => ObjContainsRAdj F X \u2228 ObjContainsRAdj F Y\n| _, _, _, HomAux.restrict G f => HomContainsRAdj F f \u2228 HEq F G \u2228 FuncContainsRAdj F G\n| _, _, _, HomAux.counit G X   => ObjContainsRAdj F X \u2228 HEq F G \u2228 FuncContainsRAdj F G\n\nnoncomputable def HomContainsRAdj {C' D' : Cat} (F : Func C' D') :\n  {C : Cat} \u2192 {X Y : Obj C} \u2192 Hom X Y \u2192 Prop\n| _, X, _, Hom.id _ => ObjContainsRAdj F X\n| _, _, _, Hom.comp' f g => HomAuxContainsRAdj F f \u2228 HomContainsRAdj F g\n\nend\n\nvariable {\u0393}\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} \u2192 {X Y Z : Obj C} \u2192\n  Hom X Y \u2192 Hom Y Z \u2192 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} \u2192 (F : Func C D) \u2192 {X Y : Obj C} \u2192\n  (f : HomAux X Y) \u2192 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} \u2192\n  (f : Hom X Y) \u2192 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} \u2192 (f : Hom X Y) \u2192 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} \u2192\n  (f : Hom W X) \u2192 (g : Hom X Y) \u2192 (h : Hom Y Z) \u2192\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} \u2192 (f : Hom X Y) \u2192 (g : Hom Y Z) \u2192\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 \u2192 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 \u2192 Prop )\n( hasRAdj {C D : Cat} (F : Func C D) : Prop )\n-- ( h : \u2200 {C : Cat} (X Y : Obj C) (v : Nat),\n--     HomVar X Y v \u2192 \u2200 {C' D' : Cat} (F : Func C' D'),\n--     ObjContainsRAdj F X \u2228 ObjContainsRAdj F Y \u2192\n--     hasRAdj F )\n\ndef SmallestContext {C : Cat} {X Y : Obj C} (f : Hom X Y) : Context :=\n{ HomVar  := \u03bb X Y n => HomContainsVar X Y n f,\n  hasRAdj := \u03bb F     => HomContainsRAdj F f }\n\ndef lessRAdj (\u0393\u2081 \u0393\u2082 : Context) : Prop :=\n@Context.HomVar \u0393\u2081 = @Context.HomVar \u0393\u2082 \u2227\n  \u2200 {C D : Cat} (F : Func C D), \u0393\u2081.hasRAdj F \u2192 \u0393\u2082.hasRAdj F\n\nvariable (\u0393 : Context)\n\ndef ObjC (C : Cat) : Type :=\n\u03a3' X : Obj C, \u2200 (C' D' : Cat) (F : Func C' D'), ObjContainsRAdj F X \u2192 \u0393.hasRAdj F\n\ndef FuncC (C D : Cat) : Type :=\n\u03a3' F : Func C D, \u2200 (C' D' : Cat) (G : Func C' D'), FuncContainsRAdj G F \u2192 \u0393.hasRAdj G\n\ndef HomC {C : Cat} (X Y : ObjC \u0393 C) : Type :=\n\u03a3' f : Hom X.1 Y.1,\n  (\u2200 (C' D' : Cat) (F : Func C' D'), HomContainsRAdj F f \u2192 \u0393.hasRAdj F) \u2227\n  \u2200 (C' : Cat) (X' Y' : ObjC \u0393 C') (v : Nat), HomContainsVar X'.1 Y'.1 v f \u2192\n    \u0393.HomVar X'.1 Y'.1 v\n\nvariable {\u0393}\n\nnoncomputable def ObjC.cases {C : Cat} (X Y : ObjC \u0393 C) : \u03a3 D : Cat, ObjC \u0393 D \u00d7 ObjC \u0393 D :=\nlet B := Obj.cases X.1 Y.1\n\u27e8B.1, \u27e8B.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\u27e9,\n  \u27e8B.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\u27e9\u27e9\n\nnoncomputable def FuncC.app {C D : Cat} (F : FuncC \u0393 C D) (X : ObjC \u0393 C) : ObjC \u0393 D :=\n\u27e8F.1.app X.1, sorry\u27e9\n\nnamespace HomC\n\nnoncomputable def var (X Y : ObjC \u0393 C) (v : Nat) (h : \u0393.HomVar X.1 Y.1 v) :\n  HomC \u0393 (X.cases Y).2.1 (X.cases Y).2.2 :=\n\u27e8Hom.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 \u27e9\n\nnoncomputable def id {C : Cat} (X : ObjC \u0393 C) : HomC \u0393 X X :=\n\u27e8Hom.id X.1, sorry\u27e9\n\nnoncomputable def comp {C : Cat} {X Y Z : ObjC \u0393 C} :\n  HomC \u0393 X Y \u2192 HomC \u0393 Y Z \u2192 HomC \u0393 X Z :=\n\u03bb f g => \u27e8Hom.comp f.1 g.1, sorry\u27e9\n\nnoncomputable def map {C D : Cat} (F : FuncC \u0393 C D) {X Y : ObjC \u0393 C}\n  (f : HomC \u0393 X Y) : HomC \u0393 (F.app X) (F.app Y) :=\n\u27e8Hom.map F.1 f.1, sorry\u27e9\n\nnoncomputable def restrict {C D : Cat} (F : FuncC \u0393 C D)\n  {X : ObjC \u0393 C} {Y : ObjC \u0393 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 \u00a9 2020 Nicol\u00f2 Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicol\u00f2 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E]\n{E' : Type*} [normed_group E'] [normed_space \ud835\udd5c E']\n{H : Type*} [topological_space H]\n{H' : Type*} [topological_space H']\n(I : model_with_corners \ud835\udd5c E H) (I' : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'']\n{H'' : Type*} [topological_space H'']\n{I'' : model_with_corners \ud835\udd5c E'' H''}\n{M'' : Type*} [topological_space M''] [charted_space H'' M'']\n(n : with_top \u2115)\n\n/-- Bundled `n` times continuously differentiable maps. -/\n@[protect_proj]\nstructure cont_mdiff_map :=\n(to_fun                  : M \u2192 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' \u22a4\n\nlocalized \"notation `C^` n `\u27ee` I `, ` M `; ` I' `, ` M' `\u27ef` :=\n  cont_mdiff_map I I' M M' n\" in manifold\nlocalized \"notation `C^` n `\u27ee` I `, ` M `; ` k `\u27ef` :=\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\u27eeI, M; I', M'\u27ef (\u03bb _, M \u2192 M') := \u27e8cont_mdiff_map.to_fun\u27e9\ninstance : has_coe C^n\u27eeI, M; I', M'\u27ef C(M, M') :=\n\u27e8\u03bb f, \u27e8f, f.cont_mdiff_to_fun.continuous\u27e9\u27e9\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\u27eeI, M; I', M'\u27ef}\n\n@[simp] lemma coe_fn_mk (f : M \u2192 M') (hf : cont_mdiff I I' n f) :\n  (mk f hf : M \u2192 M') = f :=\nrfl\n\nprotected lemma cont_mdiff (f : C^n\u27eeI, M; I', M'\u27ef) :\n  cont_mdiff I I' n f := f.cont_mdiff_to_fun\n\nprotected lemma smooth (f : C^\u221e\u27eeI, M; I', M'\u27ef) :\n  smooth I I' f := f.cont_mdiff_to_fun\n\nprotected lemma mdifferentiable' (f : C^n\u27eeI, M; I', M'\u27ef) (hn : 1 \u2264 n) :\n  mdifferentiable I I' f :=\nf.cont_mdiff.mdifferentiable hn\n\nprotected \n\nprotected lemma mdifferentiable_at (f : C^\u221e\u27eeI, M; I', M'\u27ef) {x} :\n  mdifferentiable_at I I' f x :=\nf.mdifferentiable x\n\nlemma coe_inj \u2983f g : C^n\u27eeI, M; I', M'\u27ef\u2984 (h : (f : M \u2192 M') = g) : f = g :=\nby cases f; cases g; cases h; refl\n\n@[ext] theorem ext (h : \u2200 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\u27eeI, M; I, M\u27ef := \u27e8id, cont_mdiff_id\u27e9\n\n/-- The composition of smooth maps, as a smooth map. -/\ndef comp (f : C^n\u27eeI', M'; I'', M''\u27ef) (g : C^n\u27eeI, M; I', M'\u27ef) : C^n\u27eeI, M; I'', M''\u27ef :=\n{ to_fun := \u03bb 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\u27eeI', M'; I'', M''\u27ef) (g : C^n\u27eeI, M; I', M'\u27ef) (x : M) :\n  f.comp g x = f (g x) := rfl\n\ninstance [inhabited M'] : inhabited C^n\u27eeI, M; I', M'\u27ef :=\n\u27e8\u27e8\u03bb _, default, cont_mdiff_const\u27e9\u27e9\n\n/-- Constant map as a smooth map -/\ndef const (y : M') : C^n\u27eeI, M; I', M'\u27ef := \u27e8\u03bb x, y, cont_mdiff_const\u27e9\n\nend cont_mdiff_map\n\ninstance continuous_linear_map.has_coe_to_cont_mdiff_map :\n  has_coe (E \u2192L[\ud835\udd5c] E') C^n\u27ee\ud835\udcd8(\ud835\udd5c, E), E; \ud835\udcd8(\ud835\udd5c, E'), E'\u27ef :=\n\u27e8\u03bb f, \u27e8f.to_fun, f.cont_mdiff\u27e9\u27e9\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 \u2964 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) [\ud835\udca5 : SmallCategory J] [@FinCategory J \ud835\udca5] : @HasLimitsOfShape J \ud835\udca5 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  \u27e8fun J hJ hJ' =>\n    haveI := hasLimitsOfSizeShrink.{0, 0} C\n    has_limits_of_shape_of_equivalence (fin_category.equiv_as_type J)\u27e9\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      \u2200 (J : Type w) {\ud835\udca5 : SmallCategory J} (hJ : @FinCategory J \ud835\udca5),\n        by\n        skip\n        exact has_limits_of_shape J C) :\n    HasFiniteLimits C :=\n  \u27e8fun 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\u27e9\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 \u2964 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) [\ud835\udca5 : SmallCategory J] [@FinCategory J \ud835\udca5] : @HasColimitsOfShape J \ud835\udca5 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  \u27e8fun J hJ hJ' =>\n    haveI := hasColimitsOfSize_shrink.{0, 0} C\n    has_colimits_of_shape_of_equivalence (fin_category.equiv_as_type J)\u27e9\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      \u2200 (J : Type w) {\ud835\udca5 : SmallCategory J} (hJ : @FinCategory J \ud835\udca5),\n        by\n        skip\n        exact has_colimits_of_shape J C) :\n    HasFiniteColimits C :=\n  \u27e8fun 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\u27e9\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' \u2205 [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 \u27f6 j')\n    where\n  elems := by\n    cases j'\n    \u00b7 cases j\n      \u00b7 exact {hom.id none}\n      \u00b7 exact {hom.term j}\n    \u00b7 by_cases some j' = j\n      \u00b7 rw [h]\n        exact {hom.id j}\n      \u00b7 exact \u2205\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 \u27f6 j')\n    where\n  elems := by\n    cases j\n    \u00b7 cases j'\n      \u00b7 exact {hom.id none}\n      \u00b7 exact {hom.init j'}\n    \u00b7 by_cases some j = j'\n      \u00b7 rw [h]\n        exact {hom.id j'}\n      \u00b7 exact \u2205\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  \u27e8fun J _ => has_finite_limits.out _\u27e9\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  \u27e8fun J _ => has_finite_colimits.out _\u27e9\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] (\u03b1 : Type v) :=\n  m \u2192 n \u2192 \u03b1\n\nnamespace matrix\n\n\ntheorem ext_iff {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} {M : matrix m n \u03b1} {N : matrix m n \u03b1} : (\u2200 (i : m) (j : n), M i j = N i j) \u2194 M = N := sorry\n\ntheorem ext {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} {M : matrix m n \u03b1} {N : matrix m n \u03b1} : (\u2200 (i : m) (j : n), M i j = N i j) \u2192 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] {\u03b1 : Type v} (M : matrix m n \u03b1) {\u03b2 : Type w} (f : \u03b1 \u2192 \u03b2) : matrix m n \u03b2 :=\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] {\u03b1 : Type v} {M : matrix m n \u03b1} {\u03b2 : Type w} {f : \u03b1 \u2192 \u03b2} {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] {\u03b1 : Type v} {M : matrix m n \u03b1} {\u03b2 : Type u_1} {\u03b3 : Type u_4} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} : map (map M f) g = map M (g \u2218 f) := sorry\n\n/-- The transpose of a matrix. -/\ndef transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} (M : matrix m n \u03b1) : matrix n m \u03b1 :=\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] {\u03b1 : Type v} (w : m \u2192 \u03b1) : matrix m Unit \u03b1 :=\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] {\u03b1 : Type v} (v : n \u2192 \u03b1) : matrix Unit n \u03b1 :=\n  sorry\n\nprotected instance inhabited {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [Inhabited \u03b1] : Inhabited (matrix m n \u03b1) :=\n  pi.inhabited m\n\nprotected instance has_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [Add \u03b1] : Add (matrix m n \u03b1) :=\n  pi.has_add\n\nprotected instance add_semigroup {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [add_semigroup \u03b1] : add_semigroup (matrix m n \u03b1) :=\n  pi.add_semigroup\n\nprotected instance add_comm_semigroup {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [add_comm_semigroup \u03b1] : add_comm_semigroup (matrix m n \u03b1) :=\n  pi.add_comm_semigroup\n\nprotected instance has_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [HasZero \u03b1] : HasZero (matrix m n \u03b1) :=\n  pi.has_zero\n\nprotected instance add_monoid {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [add_monoid \u03b1] : add_monoid (matrix m n \u03b1) :=\n  pi.add_monoid\n\nprotected instance add_comm_monoid {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [add_comm_monoid \u03b1] : add_comm_monoid (matrix m n \u03b1) :=\n  pi.add_comm_monoid\n\nprotected instance has_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [Neg \u03b1] : Neg (matrix m n \u03b1) :=\n  pi.has_neg\n\nprotected instance has_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [Sub \u03b1] : Sub (matrix m n \u03b1) :=\n  pi.has_sub\n\nprotected instance add_group {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [add_group \u03b1] : add_group (matrix m n \u03b1) :=\n  pi.add_group\n\nprotected instance add_comm_group {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [add_comm_group \u03b1] : add_comm_group (matrix m n \u03b1) :=\n  pi.add_comm_group\n\n@[simp] theorem zero_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [HasZero \u03b1] (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] {\u03b1 : Type v} [Neg \u03b1] (M : matrix m n \u03b1) (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] {\u03b1 : Type v} [Add \u03b1] (M : matrix m n \u03b1) (N : matrix m n \u03b1) (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] {\u03b1 : Type v} [Sub \u03b1] (M : matrix m n \u03b1) (N : matrix m n \u03b1) (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] {\u03b1 : Type v} [HasZero \u03b1] {\u03b2 : Type w} [HasZero \u03b2] {f : \u03b1 \u2192 \u03b2} (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] {\u03b1 : Type v} [add_monoid \u03b1] {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2192+ \u03b2) (M : matrix m n \u03b1) (N : matrix m n \u03b1) : map (M + N) \u21d1f = map M \u21d1f + map N \u21d1f := sorry\n\ntheorem map_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [add_group \u03b1] {\u03b2 : Type w} [add_group \u03b2] (f : \u03b1 \u2192+ \u03b2) (M : matrix m n \u03b1) (N : matrix m n \u03b1) : map (M - N) \u21d1f = map M \u21d1f - map N \u21d1f := sorry\n\ntheorem subsingleton_of_empty_left {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} (hm : \u00acNonempty m) : subsingleton (matrix m n \u03b1) := sorry\n\ntheorem subsingleton_of_empty_right {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} (hn : \u00acNonempty n) : subsingleton (matrix m n \u03b1) := 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] {\u03b1 : Type v} [add_monoid \u03b1] {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2192+ \u03b2) : matrix m n \u03b1 \u2192+ matrix m n \u03b2 :=\n  add_monoid_hom.mk (fun (M : matrix m n \u03b1) => matrix.map M \u21d1f) 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] {\u03b1 : Type v} [add_monoid \u03b1] {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2192+ \u03b2) (M : matrix m n \u03b1) : coe_fn (add_monoid_hom.map_matrix f) M = matrix.map M \u21d1f :=\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 \u2260 j`. -/\ndef diagonal {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] (d : n \u2192 \u03b1) : matrix n n \u03b1 :=\n  fun (i j : n) => ite (i = j) (d i) 0\n\n@[simp] theorem diagonal_apply_eq {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] {d : n \u2192 \u03b1} (i : n) : diagonal d i i = d i := sorry\n\n@[simp] theorem diagonal_apply_ne {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] {d : n \u2192 \u03b1} {i : n} {j : n} (h : i \u2260 j) : diagonal d i j = 0 := sorry\n\ntheorem diagonal_apply_ne' {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] {d : n \u2192 \u03b1} {i : n} {j : n} (h : j \u2260 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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] : (diagonal fun (_x : n) => 0) = 0 := sorry\n\n@[simp] theorem diagonal_transpose {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] (v : n \u2192 \u03b1) : transpose (diagonal v) = diagonal v := sorry\n\n@[simp] theorem diagonal_add {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [add_monoid \u03b1] (d\u2081 : n \u2192 \u03b1) (d\u2082 : n \u2192 \u03b1) : diagonal d\u2081 + diagonal d\u2082 = diagonal fun (i : n) => d\u2081 i + d\u2082 i := sorry\n\n@[simp] theorem diagonal_map {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] {\u03b2 : Type w} [HasZero \u03b1] [HasZero \u03b2] {f : \u03b1 \u2192 \u03b2} (h : f 0 = 0) {d : n \u2192 \u03b1} : map (diagonal d) f = diagonal fun (m : n) => f (d m) := sorry\n\nprotected instance has_one {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1] : HasOne (matrix n n \u03b1) :=\n  { one := diagonal fun (_x : n) => 1 }\n\n@[simp] theorem diagonal_one {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1] : (diagonal fun (_x : n) => 1) = 1 :=\n  rfl\n\ntheorem one_apply {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1] {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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1] (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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1] {i : n} {j : n} : i \u2260 j \u2192 HasOne.one i j = 0 :=\n  diagonal_apply_ne\n\ntheorem one_apply_ne' {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1] {i : n} {j : n} : j \u2260 i \u2192 HasOne.one i j = 0 :=\n  diagonal_apply_ne'\n\n@[simp] theorem one_map {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1] {\u03b2 : Type w} [HasZero \u03b2] [HasOne \u03b2] {f : \u03b1 \u2192 \u03b2} (h\u2080 : f 0 = 0) (h\u2081 : f 1 = 1) : map 1 f = 1 := sorry\n\n@[simp] theorem bit0_apply {m : Type u_2} [fintype m] {\u03b1 : Type v} [Add \u03b1] (M : matrix m m \u03b1) (i : m) (j : m) : bit0 M i j = bit0 (M i j) :=\n  rfl\n\ntheorem bit1_apply {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [add_monoid \u03b1] [HasOne \u03b1] (M : matrix n n \u03b1) (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] {\u03b1 : Type v} [DecidableEq n] [add_monoid \u03b1] [HasOne \u03b1] (M : matrix n n \u03b1) (i : n) : bit1 M i i = bit1 (M i i) := sorry\n\n@[simp] theorem bit1_apply_ne {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [add_monoid \u03b1] [HasOne \u03b1] (M : matrix n n \u03b1) {i : n} {j : n} (h : i \u2260 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] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : \u03b1 :=\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] {\u03b1 : Type v} [semiring \u03b1] (u : m \u2192 \u03b1) (v : m \u2192 n \u2192 \u03b1) (w : n \u2192 \u03b1) : 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] {\u03b1 : Type v} [comm_semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : dot_product v w = dot_product w v := sorry\n\n@[simp] theorem dot_product_punit {\u03b1 : Type v} [add_comm_monoid \u03b1] [Mul \u03b1] (v : PUnit \u2192 \u03b1) (w : PUnit \u2192 \u03b1) : dot_product v w = v PUnit.unit * w PUnit.unit := sorry\n\n@[simp] theorem dot_product_zero {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) : dot_product v 0 = 0 := sorry\n\n@[simp] theorem dot_product_zero' {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) : (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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) : dot_product 0 v = 0 := sorry\n\n@[simp] theorem zero_dot_product' {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (u : m \u2192 \u03b1) (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (u : m \u2192 \u03b1) (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [DecidableEq m] [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [DecidableEq m] [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [DecidableEq m] [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [ring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : dot_product (-v) w = -dot_product v w := sorry\n\n@[simp] theorem dot_product_neg {m : Type u_2} [fintype m] {\u03b1 : Type v} [ring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : dot_product v (-w) = -dot_product v w := sorry\n\n@[simp] theorem smul_dot_product {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (x : \u03b1) (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : dot_product (x \u2022 v) w = x * dot_product v w := sorry\n\n@[simp] theorem dot_product_smul {m : Type u_2} [fintype m] {\u03b1 : Type v} [comm_semiring \u03b1] (x : \u03b1) (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : dot_product v (x \u2022 w) = x * dot_product v w := sorry\n\n/-- `M \u2b1d N` is the usual product of matrices `M` and `N`, i.e. we have that\n    `(M \u2b1d N) i k` is the dot product of the `i`-th row of `M` by the `k`-th column of `\u01f8`. -/\nprotected def mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] (M : matrix l m \u03b1) (N : matrix m n \u03b1) : matrix l n \u03b1 :=\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] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] {M : matrix l m \u03b1} {N : matrix m n \u03b1} {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] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] : Mul (matrix n n \u03b1) :=\n  { mul := matrix.mul }\n\n@[simp] theorem mul_eq_mul {n : Type u_3} [fintype n] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] (M : matrix n n \u03b1) (N : matrix n n \u03b1) : M * N = matrix.mul M N :=\n  rfl\n\ntheorem mul_apply' {n : Type u_3} [fintype n] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] {M : matrix n n \u03b1} {N : matrix n n \u03b1} {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] {\u03b1 : Type v} [semiring \u03b1] (L : matrix l m \u03b1) (M : matrix m n \u03b1) (N : matrix n o \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] : semigroup (matrix n n \u03b1) :=\n  semigroup.mk Mul.mul matrix.mul_assoc\n\n@[simp] theorem diagonal_neg {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [add_group \u03b1] (d : n \u2192 \u03b1) : -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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (L : matrix m n \u03b1) (M : matrix n o \u03b1) (N : matrix n o \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (L : matrix l m \u03b1) (M : matrix l m \u03b1) (N : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] (d : m \u2192 \u03b1) (M : matrix m n \u03b1) (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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] (d : n \u2192 \u03b1) (M : matrix m n \u03b1) (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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] (M : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] (M : matrix m n \u03b1) : matrix.mul M 1 = M := sorry\n\nprotected instance monoid {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] : monoid (matrix n n \u03b1) :=\n  monoid.mk semigroup.mul sorry 1 sorry sorry\n\nprotected instance semiring {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] : semiring (matrix n n \u03b1) :=\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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] (d\u2081 : n \u2192 \u03b1) (d\u2082 : n \u2192 \u03b1) : matrix.mul (diagonal d\u2081) (diagonal d\u2082) = diagonal fun (i : n) => d\u2081 i * d\u2082 i := sorry\n\ntheorem diagonal_mul_diagonal' {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] (d\u2081 : n \u2192 \u03b1) (d\u2082 : n \u2192 \u03b1) : diagonal d\u2081 * diagonal d\u2082 = diagonal fun (i : n) => d\u2081 i * d\u2082 i :=\n  diagonal_mul_diagonal d\u2081 d\u2082\n\n@[simp] theorem map_mul {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} [semiring \u03b1] {L : matrix m n \u03b1} {M : matrix n o \u03b1} {\u03b2 : Type w} [semiring \u03b2] {f : \u03b1 \u2192+* \u03b2} : map (matrix.mul L M) \u21d1f = matrix.mul (map L \u21d1f) (map M \u21d1f) := 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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2192+* \u03b2) : map 1 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2243+* \u03b2) : map 1 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type w} [HasZero \u03b2] (f : zero_hom \u03b1 \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2192+ \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2243+ \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {R : Type u_1} [semiring R] {\u03b2 : Type w} [add_comm_monoid \u03b2] [semimodule R \u03b1] [semimodule R \u03b2] (f : linear_map R \u03b1 \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {R : Type u_1} [semiring R] {\u03b2 : Type w} [add_comm_monoid \u03b2] [semimodule R \u03b1] [semimodule R \u03b2] (f : linear_equiv R \u03b1 \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2192+* \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2243+* \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix l m \u03b1) : is_add_monoid_hom fun (x : matrix m n \u03b1) => 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) : is_add_monoid_hom fun (x : matrix l m \u03b1) => 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type u_4} (s : finset \u03b2) (f : \u03b2 \u2192 matrix l m \u03b1) (M : matrix m n \u03b1) : matrix.mul (finset.sum s fun (a : \u03b2) => f a) M = finset.sum s fun (a : \u03b2) => matrix.mul (f a) M :=\n  Eq.symm (finset.sum_hom s fun (x : matrix l m \u03b1) => 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type u_4} (s : finset \u03b2) (f : \u03b2 \u2192 matrix m n \u03b1) (M : matrix l m \u03b1) : matrix.mul M (finset.sum s fun (a : \u03b2) => f a) = finset.sum s fun (a : \u03b2) => matrix.mul M (f a) :=\n  Eq.symm (finset.sum_hom s fun (x : matrix m n \u03b1) => 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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [DecidableEq m] [semiring \u03b1] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2192+* \u03b2) : matrix m m \u03b1 \u2192+* matrix m m \u03b2 :=\n  ring_hom.mk (fun (M : matrix m m \u03b1) => matrix.map M \u21d1f) sorry sorry sorry sorry\n\n@[simp] theorem ring_hom.map_matrix_apply {m : Type u_2} [fintype m] {\u03b1 : Type v} [DecidableEq m] [semiring \u03b1] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2192+* \u03b2) (M : matrix m m \u03b1) : coe_fn (ring_hom.map_matrix f) M = matrix.map M \u21d1f :=\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] {\u03b1 : Type v} [ring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1] (M : matrix m n \u03b1) (M' : matrix m n \u03b1) (N : matrix n o \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) (N' : matrix n o \u03b1) : matrix.mul M (N - N') = matrix.mul M N - matrix.mul M N' := sorry\n\nprotected instance ring {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [ring \u03b1] : ring (matrix n n \u03b1) :=\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] {\u03b1 : Type v} [semiring \u03b1] : has_scalar \u03b1 (matrix m n \u03b1) :=\n  pi.has_scalar\n\nprotected instance semimodule {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} {\u03b2 : Type w} [semiring \u03b1] [add_comm_monoid \u03b2] [semimodule \u03b1 \u03b2] : semimodule \u03b1 (matrix m n \u03b2) :=\n  pi.semimodule m (fun (\u1fb0 : m) => n \u2192 \u03b2) \u03b1\n\n@[simp] theorem smul_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1] (a : \u03b1) (A : matrix m n \u03b1) (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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] (M : matrix m n \u03b1) (a : \u03b1) : a \u2022 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (a : \u03b1) (N : matrix n l \u03b1) : matrix.mul (a \u2022 M) N = a \u2022 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) (a : \u03b1) : matrix.mul (fun (i : m) (j : n) => a * M i j) N = a \u2022 matrix.mul M N := sorry\n\n/--\nThe ring homomorphism `\u03b1 \u2192+* matrix n n \u03b1`\nsending `a` to the diagonal matrix with `a` on the diagonal.\n-/\ndef scalar {\u03b1 : Type v} [semiring \u03b1] (n : Type u) [DecidableEq n] [fintype n] : \u03b1 \u2192+* matrix n n \u03b1 :=\n  ring_hom.mk (fun (a : \u03b1) => a \u2022 1) sorry sorry sorry sorry\n\n@[simp] theorem coe_scalar {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] : \u21d1(scalar n) = fun (a : \u03b1) => a \u2022 1 :=\n  rfl\n\ntheorem scalar_apply_eq {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] (a : \u03b1) (i : n) : coe_fn (scalar n) a i i = a := sorry\n\ntheorem scalar_apply_ne {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] (a : \u03b1) (i : n) (j : n) (h : i \u2260 j) : coe_fn (scalar n) a i j = 0 := sorry\n\ntheorem scalar_inj {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] [Nonempty n] {r : \u03b1} {s : \u03b1} : coe_fn (scalar n) r = coe_fn (scalar n) s \u2194 r = s := sorry\n\ntheorem smul_eq_mul_diagonal {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [comm_semiring \u03b1] [DecidableEq n] (M : matrix m n \u03b1) (a : \u03b1) : a \u2022 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] {\u03b1 : Type v} [comm_semiring \u03b1] (M : matrix m n \u03b1) (a : \u03b1) (N : matrix n l \u03b1) : matrix.mul M (a \u2022 N) = a \u2022 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] {\u03b1 : Type v} [comm_semiring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) (a : \u03b1) : (matrix.mul M fun (i : n) (j : o) => a * N i j) = a \u2022 matrix.mul M N := sorry\n\ntheorem scalar.commute {n : Type u_3} [fintype n] {\u03b1 : Type v} [comm_semiring \u03b1] [DecidableEq n] (r : \u03b1) (M : matrix n n \u03b1) : 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 \u2b1d row v`. -/\ndef vec_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1] (w : m \u2192 \u03b1) (v : n \u2192 \u03b1) : matrix m n \u03b1 :=\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 \u2b1d col v` (see `col_mul_vec`). -/\ndef mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (v : n \u2192 \u03b1) : m \u2192 \u03b1 :=\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 \u2b1d M` (see `row_vec_mul`). -/\ndef vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) (M : matrix m n \u03b1) : n \u2192 \u03b1 :=\n  sorry\n\nprotected instance mul_vec.is_add_monoid_hom_left {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1] (v : n \u2192 \u03b1) : is_add_monoid_hom fun (M : matrix m n \u03b1) => 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 : \u03b1) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : \u03b1) (e_2 : \u1fb0 = \u1fb0_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] {\u03b1 : Type v} (v v_1 : n \u2192 \u03b1) (e_5 : v = v_1) (w w_1 : n \u2192 \u03b1)\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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] (v : m \u2192 \u03b1) : mul_vec 1 v = v := sorry\n\n@[simp] theorem vec_mul_one {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) (M : matrix m n \u03b1) (N : matrix n o \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (v : o \u2192 \u03b1) (M : matrix m n \u03b1) (N : matrix n o \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (w : m \u2192 \u03b1) (v : n \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : \u03b1) : matrix m n \u03b1 :=\n  fun (i' : m) (j' : n) => ite (i' = i \u2227 j' = j) a 0\n\n@[simp] theorem smul_std_basis_matrix {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : \u03b1) (b : \u03b1) : b \u2022 std_basis_matrix i j a = std_basis_matrix i j (b \u2022 a) := sorry\n\n@[simp] theorem std_basis_matrix_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1] [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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : \u03b1) (b : \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] [DecidableEq n] (x : matrix n m \u03b1) : 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 \u2192 Prop} (m : matrix n n X) (h_zero : M 0) (h_add : \u2200 (p q : matrix n n X), M p \u2192 M q \u2192 M (p + q)) (h_std_basis : \u2200 (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 \u2192 Prop} (m : matrix n n X) (h_add : \u2200 (p q : matrix n n X), M p \u2192 M q \u2192 M (p + q)) (h_std_basis : \u2200 (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] {\u03b1 : Type v} [ring \u03b1] (v : m \u2192 \u03b1) (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1] (v : m \u2192 \u03b1) (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1] (v : n \u2192 \u03b1) (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1] (v : n \u2192 \u03b1) (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1] (A : matrix n n \u03b1) (b : n \u2192 \u03b1) (a : \u03b1) : mul_vec (a \u2022 A) b = a \u2022 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] {\u03b1 : Type v} (M : matrix m n \u03b1) (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] {\u03b1 : Type v} (M : matrix m n \u03b1) : 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] {\u03b1 : Type v} [HasZero \u03b1] : 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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1] : transpose 1 = 1 := sorry\n\n@[simp] theorem transpose_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [Add \u03b1] (M : matrix m n \u03b1) (N : matrix m n \u03b1) : 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] {\u03b1 : Type v} [add_group \u03b1] (M : matrix m n \u03b1) (N : matrix m n \u03b1) : 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] {\u03b1 : Type v} [comm_semiring \u03b1] (M : matrix m n \u03b1) (N : matrix n l \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (c : \u03b1) (M : matrix m n \u03b1) : transpose (c \u2022 M) = c \u2022 transpose M :=\n  ext fun (i : n) (j : m) => Eq.refl (transpose (c \u2022 M) i j)\n\n@[simp] theorem transpose_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [Neg \u03b1] (M : matrix m n \u03b1) : 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] {\u03b1 : Type v} {\u03b2 : Type w} {f : \u03b1 \u2192 \u03b2} {M : matrix m n \u03b1} : 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] {\u03b1 : Type v} (A : matrix m n \u03b1) (row : l \u2192 m) (col : o \u2192 n) : matrix l o \u03b1 :=\n  fun (i : l) (j : o) => A (row i) (col j)\n\n/-- The left `n \u00d7 l` part of a `n \u00d7 (l+r)` matrix. -/\ndef sub_left {\u03b1 : Type v} {m : \u2115} {l : \u2115} {r : \u2115} (A : matrix (fin m) (fin (l + r)) \u03b1) : matrix (fin m) (fin l) \u03b1 :=\n  minor A id \u21d1(fin.cast_add r)\n\n/-- The right `n \u00d7 r` part of a `n \u00d7 (l+r)` matrix. -/\ndef sub_right {\u03b1 : Type v} {m : \u2115} {l : \u2115} {r : \u2115} (A : matrix (fin m) (fin (l + r)) \u03b1) : matrix (fin m) (fin r) \u03b1 :=\n  minor A id \u21d1(fin.nat_add l)\n\n/-- The top `u \u00d7 n` part of a `(u+d) \u00d7 n` matrix. -/\ndef sub_up {\u03b1 : Type v} {d : \u2115} {u : \u2115} {n : \u2115} (A : matrix (fin (u + d)) (fin n) \u03b1) : matrix (fin u) (fin n) \u03b1 :=\n  minor A (\u21d1(fin.cast_add d)) id\n\n/-- The bottom `d \u00d7 n` part of a `(u+d) \u00d7 n` matrix. -/\ndef sub_down {\u03b1 : Type v} {d : \u2115} {u : \u2115} {n : \u2115} (A : matrix (fin (u + d)) (fin n) \u03b1) : matrix (fin d) (fin n) \u03b1 :=\n  minor A (\u21d1(fin.nat_add u)) id\n\n/-- The top-right `u \u00d7 r` part of a `(u+d) \u00d7 (l+r)` matrix. -/\ndef sub_up_right {\u03b1 : Type v} {d : \u2115} {u : \u2115} {l : \u2115} {r : \u2115} (A : matrix (fin (u + d)) (fin (l + r)) \u03b1) : matrix (fin u) (fin r) \u03b1 :=\n  sub_up (sub_right A)\n\n/-- The bottom-right `d \u00d7 r` part of a `(u+d) \u00d7 (l+r)` matrix. -/\ndef sub_down_right {\u03b1 : Type v} {d : \u2115} {u : \u2115} {l : \u2115} {r : \u2115} (A : matrix (fin (u + d)) (fin (l + r)) \u03b1) : matrix (fin d) (fin r) \u03b1 :=\n  sub_down (sub_right A)\n\n/-- The top-left `u \u00d7 l` part of a `(u+d) \u00d7 (l+r)` matrix. -/\ndef sub_up_left {\u03b1 : Type v} {d : \u2115} {u : \u2115} {l : \u2115} {r : \u2115} (A : matrix (fin (u + d)) (fin (l + r)) \u03b1) : matrix (fin u) (fin l) \u03b1 :=\n  sub_up (sub_left A)\n\n/-- The bottom-left `d \u00d7 l` part of a `(u+d) \u00d7 (l+r)` matrix. -/\ndef sub_down_left {\u03b1 : Type v} {d : \u2115} {u : \u2115} {l : \u2115} {r : \u2115} (A : matrix (fin (u + d)) (fin (l + r)) \u03b1) : matrix (fin d) (fin l) \u03b1 :=\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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (x : \u03b1) (v : m \u2192 \u03b1) : col (x \u2022 v) = x \u2022 col v :=\n  ext fun (i : m) (j : Unit) => Eq.refl (col (x \u2022 v) i j)\n\n@[simp] theorem row_add {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (x : \u03b1) (v : m \u2192 \u03b1) : row (x \u2022 v) = x \u2022 row v :=\n  ext fun (i : Unit) (j : m) => Eq.refl (row (x \u2022 v) i j)\n\n@[simp] theorem col_apply {m : Type u_2} [fintype m] {\u03b1 : Type v} (v : m \u2192 \u03b1) (i : m) (j : Unit) : col v i j = v i :=\n  rfl\n\n@[simp] theorem row_apply {m : Type u_2} [fintype m] {\u03b1 : Type v} (v : m \u2192 \u03b1) (i : Unit) (j : m) : row v i j = v j :=\n  rfl\n\n@[simp] theorem transpose_col {m : Type u_2} [fintype m] {\u03b1 : Type v} (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v} (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (v : n \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (v : n \u2192 \u03b1) : 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] {\u03b1 : Type v} [DecidableEq n] (M : matrix n m \u03b1) (i : n) (b : m \u2192 \u03b1) : matrix n m \u03b1 :=\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] {\u03b1 : Type v} [DecidableEq m] (M : matrix n m \u03b1) (j : m) (b : n \u2192 \u03b1) : matrix n m \u03b1 :=\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] {\u03b1 : Type v} {M : matrix n m \u03b1} {i : n} {b : m \u2192 \u03b1} [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] {\u03b1 : Type v} {M : matrix n m \u03b1} {i : n} {j : m} {c : n \u2192 \u03b1} [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] {\u03b1 : Type v} {M : matrix n m \u03b1} {i : n} {b : m \u2192 \u03b1} [DecidableEq n] {i' : n} (i_ne : i' \u2260 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] {\u03b1 : Type v} {M : matrix n m \u03b1} {i : n} {j : m} {c : n \u2192 \u03b1} [DecidableEq m] {j' : m} (j_ne : j' \u2260 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] {\u03b1 : Type v} {M : matrix n m \u03b1} {i : n} {j : m} {b : m \u2192 \u03b1} [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] {\u03b1 : Type v} {M : matrix n m \u03b1} {i : n} {j : m} {c : n \u2192 \u03b1} [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] {\u03b1 : Type v} {M : matrix n m \u03b1} {j : m} {c : n \u2192 \u03b1} [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] {\u03b1 : Type v} {M : matrix n m \u03b1} {i : n} {b : m \u2192 \u03b1} [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] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) : matrix (n \u2295 o) (l \u2295 m) \u03b1 :=\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\u2081\u2081 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (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\u2081\u2082 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (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\u2082\u2081 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (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\u2082\u2082 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (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\u2081\u2081 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : matrix n l \u03b1 :=\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\u2081\u2082 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : matrix n m \u03b1 :=\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\u2082\u2081 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : matrix o l \u03b1 :=\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\u2082\u2082 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : matrix o m \u03b1 :=\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] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : from_blocks (to_blocks\u2081\u2081 M) (to_blocks\u2081\u2082 M) (to_blocks\u2082\u2081 M) (to_blocks\u2082\u2082 M) = M := sorry\n\n@[simp] theorem to_blocks_from_blocks\u2081\u2081 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) : to_blocks\u2081\u2081 (from_blocks A B C D) = A :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks\u2081\u2082 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) : to_blocks\u2081\u2082 (from_blocks A B C D) = B :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks\u2082\u2081 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) : to_blocks\u2082\u2081 (from_blocks A B C D) = C :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks\u2082\u2082 {l : Type u_1} {m : Type u_2} {n : Type u_3} {o : Type u_4} [fintype l] [fintype m] [fintype n] [fintype o] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) : to_blocks\u2082\u2082 (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] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (x : \u03b1) (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) : x \u2022 from_blocks A B C D = from_blocks (x \u2022 A) (x \u2022 B) (x \u2022 C) (x \u2022 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] {\u03b1 : Type v} [semiring \u03b1] (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (A' : matrix n l \u03b1) (B' : matrix n m \u03b1) (C' : matrix o l \u03b1) (D' : matrix o m \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] {p : Type u_5} {q : Type u_6} [fintype p] [fintype q] (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (A' : matrix l p \u03b1) (B' : matrix l q \u03b1) (C' : matrix m p \u03b1) (D' : matrix m q \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq l] [DecidableEq m] (d\u2081 : l \u2192 \u03b1) (d\u2082 : m \u2192 \u03b1) : from_blocks (diagonal d\u2081) 0 0 (diagonal d\u2082) = diagonal (sum.elim d\u2081 d\u2082) := sorry\n\n@[simp] theorem from_blocks_one {l : Type u_1} {m : Type u_2} [fintype l] [fintype m] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq l] [DecidableEq m] : from_blocks 1 0 0 1 = 1 := sorry\n\n/-- `matrix.block_diagonal M` turns `M : o \u2192 matrix m n \u03b1'` into a\n`m \u00d7 o`-by`n \u00d7 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] : matrix (m \u00d7 o) (n \u00d7 o) \u03b1 :=\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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] (ik : m \u00d7 o) (jk : n \u00d7 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] (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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] (i : m) (j : n) {k : o} {k' : o} (h : k \u2260 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] : 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] {\u03b1 : Type v} [DecidableEq o] [HasZero \u03b1] : block_diagonal 0 = 0 := sorry\n\n@[simp] theorem block_diagonal_diagonal {m : Type u_2} {o : Type u_4} [fintype m] [fintype o] {\u03b1 : Type v} [DecidableEq o] [HasZero \u03b1] [DecidableEq m] (d : o \u2192 m \u2192 \u03b1) : (block_diagonal fun (k : o) => diagonal (d k)) = diagonal fun (ik : m \u00d7 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] {\u03b1 : Type v} [DecidableEq o] [HasZero \u03b1] [DecidableEq m] [HasOne \u03b1] : 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) (N : o \u2192 matrix m n \u03b1) [DecidableEq o] [add_monoid \u03b1] : 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [add_group \u03b1] : 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) (N : o \u2192 matrix m n \u03b1) [DecidableEq o] [add_group \u03b1] : 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] {p : Type u_1} [fintype p] [semiring \u03b1] (N : o \u2192 matrix n p \u03b1) : (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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] {R : Type u_1} [semiring R] [add_comm_monoid \u03b1] [semimodule R \u03b1] (x : R) : block_diagonal (x \u2022 M) = x \u2022 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] {\u03b1 : Type v} {\u03b2 : Type u_5} [semiring \u03b1] [semiring \u03b2] (M : matrix m n \u03b1) (N : matrix n o \u03b1) (i : m) (j : o) (f : \u03b1 \u2192+* \u03b2) : 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 : \u2115) [h : char_p R p] : char_p (polynomial R) p :=\nlet \u27e8h\u27e9 := h in \u27e8\u03bb n, by rw [\u2190 C.map_nat_cast, \u2190 C_0, C_inj, h]\u27e9\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree \u2264 `n`. -/\ndef degree_le (n : with_bot \u2115) : submodule R (polynomial R) :=\n\u2a05 k : \u2115, \u2a05 h : \u2191k > n, (lcoeff R k).ker\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degree_lt (n : \u2115) : submodule R (polynomial R) :=\n\u2a05 k : \u2115, \u2a05 h : k \u2265 n, (lcoeff R k).ker\n\nvariable {R}\n\ntheorem mem_degree_le {n : with_bot \u2115} {f : polynomial R} :\n  f \u2208 degree_le R n \u2194 degree f \u2264 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 \u2115} (H : m \u2264 n) :\n  degree_le R m \u2264 degree_le R n :=\n\u03bb f hf, mem_degree_le.2 (le_trans (mem_degree_le.1 hf) H)\n\ntheorem degree_le_eq_span_X_pow {n : \u2115} :\n  degree_le R n = submodule.span R \u2191((finset.range (n+1)).image (\u03bb n, (X : polynomial R)^n)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_le.1 hp,\n    rw [\u2190 polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (\u03bb k hk, _),\n    show monomial _ _ \u2208 _,\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 \u27e8_, finset.mem_range.2 (nat.lt_succ_of_le this), rfl\u27e9) },\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 : \u2115} {f : polynomial R} :\n  f \u2208 degree_lt R n \u2194 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 : \u2115} (H : m \u2264 n) :\n  degree_lt R m \u2264 degree_lt R n :=\n\u03bb 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 : \u2115} :\n  degree_lt R n = submodule.span R \u2191((finset.range n).image (\u03bb n, X^n) : finset (polynomial R)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_lt.1 hp,\n    rw [\u2190 polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (\u03bb k hk, _),\n    show monomial _ _ \u2208 _,\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 \u27e8_, finset.mem_range.2 this, rfl\u27e9) },\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 \u2192 F`. -/\ndef degree_lt_equiv (F : Type*) [field F] (n : \u2115) : degree_lt F n \u2243\u2097[F] (fin n \u2192 F) :=\n{ to_fun := \u03bb p n, (\u2191p : polynomial F).coeff n,\n  inv_fun := \u03bb f, \u27e8\u2211 i : fin n, monomial i (f i),\n    (degree_lt F n).sum_mem (\u03bb 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)))\u27e9,\n  map_add' := \u03bb p q, by { ext, rw [submodule.coe_add, coeff_add], refl },\n  map_smul' := \u03bb x p, by { ext, rw [submodule.coe_smul, coeff_smul], refl },\n  left_inv :=\n  begin\n    rintro \u27e8p, hp\u27e9, 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, \u2190 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 [\u2190 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 (\u03bb n, p.coeff n) p.support\n\nlemma frange_zero : frange (0 : polynomial R) = \u2205 :=\nrfl\n\nlemma mem_frange_iff {p : polynomial R} {c : R} :\n  c \u2208 p.frange \u2194 \u2203 n \u2208 p.support, c = p.coeff n :=\nby simp [frange, eq_comm]\n\nlemma frange_one : frange (1 : polynomial R) \u2286 {1} :=\nbegin\n  simp [frange, finset.image_subset_iff],\n  simp only [\u2190 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 : \u2115) (h : p.coeff n \u2260 0) :\n  p.coeff n \u2208 p.frange :=\nbegin\n  simp only [frange, exists_prop, mem_support_iff, finset.mem_image, ne.def],\n  exact \u27e8n, h, rfl\u27e9,\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 (\u2191p.frange : set R)) :=\n\u2211 i in p.support, monomial i (\u27e8p.coeff i,\n  if H : p.coeff i = 0 then H.symm \u25b8 (subring.closure _).zero_mem\n  else subring.subset_closure (p.coeff_mem_frange _ H)\u27e9 : (subring.closure (\u2191p.frange : set R)))\n\n@[simp] theorem coeff_restriction {p : polynomial R} {n : \u2115} :\n  \u2191(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 : \u2115} :\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 [\u2190 coeff_restriction] },\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\nend\n\n@[simp] theorem map_restriction (p : polynomial R) : p.restriction.map (algebra_map _ _) = p :=\next $ \u03bb 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) \u2194 monic p :=\nbegin\n  simp only [monic, leading_coeff, nat_degree_restriction],\n  rw [\u2190@coeff_restriction _ _ p],\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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 $ \u03bb i, subtype.eq $ by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs; refl\n\nvariables {S : Type v} [ring S] {f : R \u2192+* S} {x : S}\n\ntheorem eval\u2082_restriction {p : polynomial R} :\n  eval\u2082 f x p = eval\u2082 (f.comp (subring.subtype _)) x p.restriction :=\nbegin\n  simp only [eval\u2082_eq_sum, sum, support_restriction, \u2190@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 : (\u2191p.frange : set R) \u2286 T) : polynomial T :=\n\u2211 i in p.support, monomial i (\u27e8p.coeff i,\n  if H : p.coeff i = 0 then H.symm \u25b8 T.zero_mem\n  else hp (p.coeff_mem_frange _ H)\u27e9 : T)\n\nvariables (hp : (\u2191p.frange : set R) \u2286 T)\ninclude hp\n\n@[simp] theorem coeff_to_subring {n : \u2115} : \u2191(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 : \u2115} : (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 [\u2190 coeff_to_subring p T hp] },\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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) \u2194 monic p :=\nbegin\n  simp_rw [monic, leading_coeff, nat_degree_to_subring, \u2190 coeff_to_subring p T hp],\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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 $ \u03bb 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\u2211 i in p.support, monomial i (p.coeff i : R)\n\nlemma coeff_of_subring (p : polynomial T) (n : \u2115) :\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  (\u2191(p.of_subring T).frange : set R) \u2286 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 \u27e8n, hn, h'n\u27e9,\n  rw [\u2190 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 \u2208 (mod_by_monic_hom hq).ker \u2194 q \u2223 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 (\u03bb 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*} {\u03c3 : 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 : \u2200 (n : \u2115), (p.coeff n) \u2208 I.comap C) : p \u2208 I :=\nsum_C_mul_X_eq p \u25b8 submodule.sum_mem I (\u03bb 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 \u2208 (ideal.map C I : ideal (polynomial R)) \u2194 \u2200 n : \u2115, f.coeff n \u2208 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 [\u2190 hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [h] } },\n    { simp },\n    { exact \u03bb f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine \u03bb f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (\u03bb c hc, I.smul_mem (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw \u2190 sum_monomial_eq f,\n    refine (I.map C : ideal (polynomial R)).sum_mem (\u03bb 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 \u2192+* 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  \u2200 a \u2208 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\u2082_C_mk_eq_zero {I : ideal R} :\n  \u2200 f \u2208 (map C I : ideal (polynomial R)), eval\u2082_ring_hom (C.comp (quotient.mk I)) X f = 0 :=\nbegin\n  intros a ha,\n  rw \u2190 sum_monomial_eq a,\n  dsimp,\n  rw eval\u2082_sum,\n  refine finset.sum_eq_zero (\u03bb n hn, _),\n  dsimp,\n  rw eval\u2082_monomial (C.comp (quotient.mk I)) X,\n  refine mul_eq_zero_of_left (polynomial.ext (\u03bb 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 \u29f8 I) \u2243+* polynomial R \u29f8 (map C I : ideal (polynomial R)) :=\n{ to_fun := eval\u2082_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\u2082_ring_hom (C.comp (quotient.mk I)) X) eval\u2082_C_mk_eq_zero,\n  map_mul' := \u03bb f g, by simp only [coe_eval\u2082_ring_hom, eval\u2082_mul],\n  map_add' := \u03bb f g, by simp only [eval\u2082_add, coe_eval\u2082_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\u2082_ring_hom] at hp,\n      simp only [coe_eval\u2082_ring_hom] at hq,\n      simp only [coe_eval\u2082_ring_hom, hp, hq, ring_hom.map_add] },\n    { rintros n \u27e8x\u27e9,\n      simp only [monomial_eq_smul_X, C_mul', quotient.lift_mk, submodule.quotient.quot_mk_eq_mk,\n        quotient.mk_eq_mk, eval\u2082_X_pow, eval\u2082_smul, coe_eval\u2082_ring_hom, ring_hom.map_pow,\n        eval\u2082_C, ring_hom.coe_comp, ring_hom.map_mul, eval\u2082_X] }\n  end,\n  right_inv := begin\n    rintro \u27e8f\u27e9,\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, \u2190 C_mul' a (X ^ n), quotient.lift_mk,\n        submodule.quotient.quot_mk_eq_mk, quotient.mk_eq_mk, eval\u2082_X_pow,\n        eval\u2082_smul, coe_eval\u2082_ring_hom, ring_hom.map_pow, eval\u2082_C, ring_hom.coe_comp,\n        ring_hom.map_mul, eval\u2082_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\u2082_ring_hom, eval\u2082_eq_eval_map, \u2190polynomial.map_map,\n  \u2190eval\u2082_eq_eval_map, polynomial.eval\u2082_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 \u29f8 (map C P : ideal (polynomial R))) :=\nring_equiv.is_domain (polynomial (R \u29f8 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 \u2192 R[x] \u2192 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] \u2192 R'[x]`.\n  In particular we can map `I` across this map, to get `I'` and a new map `R' \u2192 R'[x] \u2192 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 \u2208 (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 \u2264 I,\n  { refine \u03bb f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (\u03bb n, _),\n    rw [mem_comap, \u2190 quotient.eq_zero_iff_mem, \u2190 ring_hom.comp_apply],\n    rw [ring_hom.mem_ker, coe_map_ring_hom] at hf,\n    replace hf := congr_arg (\u03bb (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 \u27e8x, hx'\u27e9 := x,\n  obtain \u27e8y, rfl\u27e9 := (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) \u2208 (I.map (polynomial.map_ring_hom i)),\n  { obtain \u27e8f, hf\u27e9 := 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 \u25b8 I.add_mem (hi' _ : (C y - f) \u2208 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 : \u00ac is_field (polynomial R) :=\nbegin\n  by_contradiction hR,\n  by_cases hR' : \u2203 (x y : R), x \u2260 y,\n  { haveI : nontrivial R := let \u27e8x, y, hxy\u27e9 := hR' in nontrivial_of_ne x y hxy,\n    obtain \u27e8p, hp\u27e9 := 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) \u25b8 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 \u27e8x, y, hxy\u27e9 := hR.exists_pair_ne in hxy (polynomial.ext (\u03bb 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 \u2208 I) : x = 0 :=\nbegin\n  refine classical.by_contradiction (\u03bb hx0, hI.ne_top ((eq_top_iff_one I).2 _)),\n  obtain \u27e8y, hy\u27e9 := hR.mul_inv_cancel hx0,\n  convert I.smul_mem (C y) hx,\n  rw [smul_eq_mul, \u2190 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' := \u03bb _ _, I.add_mem,\n  smul_mem' := \u03bb c x H, by { rw [\u2190 C_mul'], exact I.mul_mem_left _ H } }\n\nvariables {I : ideal (polynomial R)}\ntheorem mem_of_polynomial (x) : x \u2208 I.of_polynomial \u2194 x \u2208 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 \u2264 `n`. -/\ndef degree_le (n : with_bot \u2115) : submodule R (polynomial R) :=\ndegree_le R n \u2293 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 \u2264 `n`. -/\ndef leading_coeff_nth (n : \u2115) : ideal R :=\n(I.degree_le n).map $ lcoeff R n\n\ntheorem mem_leading_coeff_nth (n : \u2115) (x) :\n  x \u2208 I.leading_coeff_nth n \u2194 \u2203 p \u2208 I, degree p \u2264 n \u2227 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 \u27e8p, \u27e8hpdeg, hpI\u27e9, rfl\u27e9,\n    cases lt_or_eq_of_le hpdeg with hpdeg hpdeg,\n    { refine \u27e80, I.zero_mem, bot_le, _\u27e9,\n      rw [leading_coeff_zero, eq_comm],\n      exact coeff_eq_zero_of_degree_lt hpdeg },\n    { refine \u27e8p, hpI, le_of_eq hpdeg, _\u27e9,\n      rw [leading_coeff, nat_degree, hpdeg], refl } },\n  { rintro \u27e8p, hpI, hpdeg, rfl\u27e9,\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 \u27e8p * X ^ (n - nat_degree p), \u27e8_, I.mul_mem_right _ hpI\u27e9, _\u27e9,\n    { apply le_trans (degree_mul_le _ _) _,\n      apply le_trans (add_le_add (degree_le_nat_degree) (degree_X_pow_le _)) _,\n      rw [\u2190 with_bot.coe_add, this],\n      exact le_refl _ },\n    { rw [leading_coeff, \u2190 coeff_mul_X_pow p (n - nat_degree p), this] } }\nend\n\ntheorem mem_leading_coeff_nth_zero (x) :\n  x \u2208 I.leading_coeff_nth 0 \u2194 C x \u2208 I :=\n(mem_leading_coeff_nth _ _ _).trans\n\u27e8\u03bb \u27e8p, hpI, hpdeg, hpx\u27e9, by rwa [\u2190 hpx, leading_coeff,\n  nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg),\n  \u2190 eq_C_of_degree_le_zero hpdeg],\n\u03bb hx, \u27e8C x, hx, degree_C_le, leading_coeff_C x\u27e9\u27e9\n\ntheorem leading_coeff_nth_mono {m n : \u2115} (H : m \u2264 n) :\n  I.leading_coeff_nth m \u2264 I.leading_coeff_nth n :=\nbegin\n  intros r hr,\n  simp only [set_like.mem_coe, mem_leading_coeff_nth] at hr \u22a2,\n  rcases hr with \u27e8p, hpI, hpdeg, rfl\u27e9,\n  refine \u27e8p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow\u27e9,\n  refine le_trans (degree_mul_le _ _) _,\n  refine le_trans (add_le_add hpdeg (degree_X_pow_le _)) _,\n  rw [\u2190 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\u2a06 n : \u2115, I.leading_coeff_nth n\n\ntheorem mem_leading_coeff (x) :\n  x \u2208 I.leading_coeff \u2194 \u2203 p \u2208 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 \u27e8i, p, hpI, hpdeg, rfl\u27e9, exact \u27e8p, hpI, rfl\u27e9 },\n    rintro \u27e8p, hpI, rfl\u27e9, exact \u27e8nat_degree p, p, hpI, degree_le_nat_degree, rfl\u27e9 },\n  intros i j, exact \u27e8i + j, I.leading_coeff_nth_mono (nat.le_add_right _ _),\n    I.leading_coeff_nth_mono (nat.le_add_left _ _)\u27e9\nend\n\ntheorem is_fg_degree_le [is_noetherian_ring R] (n : \u2115) :\n  submodule.fg (I.degree_le n) :=\nis_noetherian_submodule_left.1 (is_noetherian_of_fg_of_noetherian _\n  \u27e8_, degree_le_eq_span_X_pow.symm\u27e9) _\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      \u27e8\u03bb p, (if p = 0 then \u22a4 else \u2191p.degree, p.leading_coeff), _\u27e9\n      (prod.lex_wf (with_top.well_founded_lt $ with_bot.well_founded_lt nat.lt_wf)\n        \u2039wf_dvd_monoid R\u203a.well_founded_dvd_not_unit),\n    rintros a b \u27e8ane0, \u27e8c, \u27e8not_unit_c, rfl\u27e9\u27e9\u27e9,\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 \u2260 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 _ \u27e8_, \u27e8c.leading_coeff, (\u03bb unit_c, not_unit_c _), rfl\u27e9\u27e9,\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          \u2190 with_bot.coe_add, with_bot.coe_lt_coe],\n      exact lt_add_of_pos_right _ (nat.pos_of_ne_zero (\u03bb h, hdeg (h.symm \u25b8 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 \u27e8assume 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) \u27e8_, \u27e80, rfl\u27e9\u27e9 in\nhave hm : M \u2208 set.range I.leading_coeff_nth := well_founded.min_mem _ _ _,\nlet \u27e8N, HN\u27e9 := hm, \u27e8s, hs\u27e9 := I.is_fg_degree_le N in\nhave hm2 : \u2200 k, I.leading_coeff_nth k \u2264 M := \u03bb k, or.cases_on (le_or_lt k N)\n  (\u03bb h, HN \u25b8 I.leading_coeff_nth_mono h)\n  (\u03bb h x hx, classical.by_contradiction $ \u03bb hxm,\n    have \u00acM < I.leading_coeff_nth k, by refine well_founded.not_lt_min\n      (well_founded_submodule_gt _ _) _ _ _; exact \u27e8k, rfl\u27e9,\n    this \u27e8HN \u25b8 I.leading_coeff_nth_mono (le_of_lt h), \u03bb H, hxm (H hx)\u27e9),\nhave hs2 : \u2200 {x}, x \u2208 I.degree_le N \u2192 x \u2208 ideal.span (\u2191s : set (polynomial R)),\nfrom hs \u25b8 \u03bb x hx, submodule.span_induction hx (\u03bb _ hx, ideal.subset_span hx) (ideal.zero_mem _)\n  (\u03bb _ _, ideal.add_mem _) (\u03bb c f hf, f.C_mul' c \u25b8 ideal.mul_mem_left _ _ hf),\n\u27e8s, le_antisymm\n  (ideal.span_le.2 $ \u03bb x hx, have x \u2208 I.degree_le N, from hs \u25b8 submodule.subset_span hx, this.2) $\nbegin\n  have : submodule.span (polynomial R) \u2191s = ideal.span \u2191s, 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 \u27e8polynomial.mem_degree_le.2\n      (le_trans polynomial.degree_le_nat_degree $ with_bot.coe_le_coe.2 h), hp\u27e9 },\n  { have hp0 : p \u2260 0,\n    { rintro rfl, cases hn, exact nat.not_lt_zero _ h },\n    have : (0 : R) \u2260 1,\n    { intro h, apply hp0, ext i, refine (mul_one _).symm.trans _,\n      rw [\u2190 h, mul_zero], refl },\n    haveI : nontrivial R := \u27e8\u27e80, 1, this\u27e9\u27e9,\n    have : p.leading_coeff \u2208 I.leading_coeff_nth N,\n    { rw HN, exact hm2 k ((I.mem_leading_coeff_nth _ _).2\n        \u27e8_, hp, hn \u25b8 polynomial.degree_le_nat_degree, rfl\u27e9) },\n    rw I.mem_leading_coeff_nth at this,\n    rcases this with \u27e8q, hq, hdq, hlqp\u27e9,\n    have hq0 : q \u2260 0,\n    { intro H, rw [\u2190 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 [\u2190 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 [\u2190 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 \u2190 sub_add_cancel p (q * polynomial.X ^ (k - q.nat_degree)),\n    refine (ideal.span \u2191s).add_mem _ ((ideal.span \u2191s).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 \u27e8polynomial.mem_degree_le.2 hdq, hq\u27e9 }\nend\u27e9\u27e9\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) : \u2203 g, irreducible g \u2227 g \u2223 f :=\nwf_dvd_monoid.exists_irreducible_factor\n  (\u03bb huf, ne_of_gt hf $ degree_eq_zero_of_is_unit huf)\n  (\u03bb hf0, not_lt_of_lt hf $ hf0.symm \u25b8 (@degree_zero R _).symm \u25b8 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) : \u2203 g, irreducible g \u2227 g \u2223 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 \u2260 0) : \u2203 g, irreducible g \u2227 g \u2223 f :=\nexists_irreducible_of_nat_degree_pos $ nat.pos_of_ne_zero hf\n\nlemma linear_independent_powers_iff_aeval\n  (f : M \u2192\u2097[R] M) (v : M) :\n  linear_independent R (\u03bb n : \u2115, (f ^ n) v)\n    \u2194 \u2200 (p : polynomial R), aeval f p v = 0 \u2192 p = 0 :=\nbegin\n  rw linear_independent_iff,\n  simp only [finsupp.total_apply, aeval_endomorphism, forall_iff_forall_finsupp, sum, support,\n    coeff, \u2190 zero_to_finsupp],\n  exact iff.rfl,\nend\n\nlemma disjoint_ker_aeval_of_coprime\n  (f : M \u2192\u2097[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 \u27e8p', q', hpq'\u27e9,\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 (\u03bb p : polynomial R, aeval f p v) hpq'.symm,\nend\n\nlemma sup_aeval_range_eq_top_of_coprime\n  (f : M \u2192\u2097[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  (aeval f p).range \u2294 (aeval f q).range = \u22a4 :=\nbegin\n  rw eq_top_iff,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with \u27e8p', q', hpq'\u27e9,\n  use aeval f (p * p') v,\n  use linear_map.mem_range.2 \u27e8aeval f p' v, by simp only [linear_map.mul_apply, aeval_mul]\u27e9,\n  use aeval f (q * q') v,\n  use linear_map.mem_range.2 \u27e8aeval f q' v, by simp only [linear_map.mul_apply, aeval_mul]\u27e9,\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add]\n    using congr_arg (\u03bb p : polynomial R, aeval f p v) hpq'\nend\n\nlemma sup_ker_aeval_le_ker_aeval_mul {f : M \u2192\u2097[R] M} {p q : polynomial R} :\n  (aeval f p).ker \u2294 (aeval f q).ker \u2264 (aeval f (p * q)).ker :=\nbegin\n  intros v hv,\n  rcases submodule.mem_sup.1 hv with \u27e8x, hx, y, hy, hxy\u27e9,\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, \u2190hxy, 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 \u2192\u2097[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  (aeval f p).ker \u2294 (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 \u27e8p', q', hpq'\u27e9,\n  have h_eval\u2082_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\u2082_pqq' := calc\n    aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v :\n      by rw [\u2190mul_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\u2082_qpp' h_eval\u2082_pqq',\n  refine \u27e8aeval f (q * q') v, linear_map.mem_ker.1 h_eval\u2082_pqq',\n          aeval f (p * p') v, linear_map.mem_ker.1 h_eval\u2082_qpp', _\u27e9,\n  rw [add_comm, mul_comm p p', mul_comm q q'],\n  simpa using congr_arg (\u03bb 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  \u2200 {n : \u2115}, 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 \u03c3] [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial \u03c3 R) :=\n@is_noetherian_ring_of_ring_equiv (mv_polynomial (fin (fintype.card \u03c3)) R) _ _ _\n  (rename_equiv R (fintype.equiv_fin \u03c3).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  \u2200 (n : \u2115), 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) (\u03c3 : Type v) [comm_ring R] [fintype \u03c3]\n  [is_domain R] : is_domain (mv_polynomial \u03c3 R) :=\n@ring_equiv.is_domain _ (mv_polynomial (fin $ fintype.card \u03c3) R) _ _\n  (mv_polynomial.is_domain_fin _ _)\n  (rename_equiv R (fintype.equiv_fin \u03c3)).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] {\u03c3 : Type v}\n  (p q : mv_polynomial \u03c3 R) (h : p * q = 0) : p = 0 \u2228 q = 0 :=\nbegin\n  obtain \u27e8s, p, rfl\u27e9 := exists_finset_rename p,\n  obtain \u27e8t, q, rfl\u27e9 := exists_finset_rename q,\n  have :\n    rename (subtype.map id (finset.subset_union_left s t) : {x // x \u2208 s} \u2192 {x // x \u2208 s \u222a t}) p *\n    rename (subtype.map id (finset.subset_union_right s t) : {x // x \u2208 t} \u2192 {x // x \u2208 s \u222a t}) q = 0,\n  { apply rename_injective _ subtype.val_injective, simpa using h },\n  letI := mv_polynomial.is_domain_fintype R {x // x \u2208 (s \u222a 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} {\u03c3 : Type v} [comm_ring R] [is_domain R] :\n  is_domain (mv_polynomial \u03c3 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 := \u27e80, 1, \u03bb H,\n  begin\n    have : eval\u2082 (ring_hom.id _) (\u03bb s, (0:R)) (0 : mv_polynomial \u03c3 R) =\n      eval\u2082 (ring_hom.id _) (\u03bb s, (0:R)) (1 : mv_polynomial \u03c3 R),\n    { congr, exact H },\n    simpa,\n  end\u27e9,\n  .. (by apply_instance : comm_ring (mv_polynomial \u03c3 R)) }\n\nlemma map_mv_polynomial_eq_eval\u2082 {S : Type*} [comm_ring S] [fintype \u03c3]\n  (\u03d5 : mv_polynomial \u03c3 R \u2192+* S) (p : mv_polynomial \u03c3 R) :\n  \u03d5 p = mv_polynomial.eval\u2082 (\u03d5.comp mv_polynomial.C) (\u03bb s, \u03d5 (mv_polynomial.X s)) p :=\nbegin\n  refine trans (congr_arg \u03d5 (mv_polynomial.as_sum p)) _,\n  rw [mv_polynomial.eval\u2082_eq', \u03d5.map_sum],\n  congr,\n  ext,\n  simp only [monomial_eq, \u03d5.map_pow, \u03d5.map_prod, \u03d5.comp_apply, \u03d5.map_mul, finsupp.prod_pow],\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} {i : R} (hi : i \u2208 I) :\n  (ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial \u03c3 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 \u03c3 R)) (p : mv_polynomial \u03c3 R)\n  (hcoe : \u2200 (m : \u03c3 \u2192\u2080 \u2115), p.coeff m \u2208 I.comap C) : p \u2208 I :=\nbegin\n  rw as_sum p,\n  suffices : \u2200 m \u2208 p.support, monomial m (mv_polynomial.coeff m p) \u2208 I,\n  { exact submodule.sum_mem I this },\n  intros m hm,\n  rw [\u2190 mul_one (coeff m p), \u2190 C_mul_monomial],\n  suffices : C (coeff m p) \u2208 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 \u03c3 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 \u03c3 R} :\n  f \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 R)) \u2194 \u2200 (m : \u03c3 \u2192\u2080 \u2115), f.coeff m \u2208 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 [\u2190 hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [ne.symm h] } },\n    { simp },\n    { exact \u03bb f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine \u03bb f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (\u03bb c hc, I.smul_mem (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw as_sum f,\n    suffices : \u2200 m \u2208 f.support, monomial m (coeff m f) \u2208\n      (ideal.map C I : ideal (mv_polynomial \u03c3 R)),\n    { exact submodule.sum_mem _ this },\n    intros m hm,\n    rw [\u2190 mul_one (coeff m f), \u2190 C_mul_monomial],\n    suffices : C (coeff m f) \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 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 \u2192+* S) : (map f : mv_polynomial \u03c3 R \u2192+* mv_polynomial \u03c3 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\u2082_C_mk_eq_zero {I : ideal R} {a : mv_polynomial \u03c3 R}\n  (ha : a \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 R))) :\n  eval\u2082_hom (C.comp (ideal.quotient.mk I)) X a = 0 :=\nbegin\n  rw as_sum a,\n  rw [coe_eval\u2082_hom, eval\u2082_sum],\n  refine finset.sum_eq_zero (\u03bb n hn, _),\n  simp only [eval\u2082_monomial, function.comp_app, ring_hom.coe_comp],\n  refine mul_eq_zero_of_left _ _,\n  suffices : coeff n a \u2208 I,\n  { rw [\u2190 @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 \u03c3 I.quotient` is isomorphic as an\n`R`-algebra to the quotient of `mv_polynomial \u03c3 R` by the ideal generated by `I`. -/\ndef quotient_equiv_quotient_mv_polynomial (I : ideal R) :\n  mv_polynomial \u03c3 (R \u29f8 I) \u2243\u2090[R]\n    mv_polynomial \u03c3 R \u29f8 (ideal.map C I : ideal (mv_polynomial \u03c3 R)) :=\n{ to_fun := eval\u2082_hom (ideal.quotient.lift I ((ideal.quotient.mk (ideal.map C I : ideal\n    (mv_polynomial \u03c3 R))).comp C) (\u03bb i hi, quotient_map_C_eq_zero hi))\n    (\u03bb i, ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial \u03c3 R)) (X i)),\n  inv_fun := ideal.quotient.lift (ideal.map C I : ideal (mv_polynomial \u03c3 R))\n    (eval\u2082_hom (C.comp (ideal.quotient.mk I)) X) (\u03bb a ha, eval\u2082_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 \u27e8r\u27e9,\n      rw [coe_eval\u2082_hom, eval\u2082_C],\n      simp only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk,\n        ideal.quotient.mk_eq_mk, bind\u2082_C_right, ring_hom.coe_comp] },\n    { simp_intros p q hp hq only [ring_hom.map_add, mv_polynomial.coe_eval\u2082_hom, coe_eval\u2082_hom,\n        mv_polynomial.eval\u2082_add, mv_polynomial.eval\u2082_hom_eq_bind\u2082, eval\u2082_hom_eq_bind\u2082],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval\u2082_hom_eq_bind\u2082, coe_eval\u2082_hom],\n      simp only [hp, eval\u2082_hom_eq_bind\u2082, coe_eval\u2082_hom, ideal.quotient.lift_mk, bind\u2082_X_right,\n        eval\u2082_mul, ring_hom.map_mul, eval\u2082_X] }\n  end,\n  right_inv := begin\n    rintro \u27e8f\u27e9,\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\u2082_hom_C] },\n    { simp_intros p q hp hq only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, eval\u2082_add,\n        ring_hom.map_add, coe_eval\u2082_hom, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, coe_eval\u2082_hom,\n        ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk, bind\u2082_X_right, eval\u2082_mul, ring_hom.map_mul,\n        eval\u2082_X],\n      simp only [hp] }\n  end,\n  commutes' := \u03bb r, eval\u2082_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 {\u03b1 : Type*} {p : \u03b1 \u2192 Prop} [decidable_pred p] {l : list \u03b1} {a : \u03b1}\n\nnamespace list\n\n@[simp] theorem all_nil (p : \u03b1 \u2192 bool) : all [] p = tt := rfl\n\n@[simp] theorem all_cons (p : \u03b1 \u2192 bool) (a : \u03b1) (l : list \u03b1) : all (a::l) p = (p a && all l p) :=\nrfl\n\n\n\ntheorem all_iff_forall_prop : all l (\u03bb a, p a) \u2194 \u2200 a \u2208 l, p a :=\nby simp only [all_iff_forall, bool.of_to_bool_iff]\n\n@[simp] theorem any_nil (p : \u03b1 \u2192 bool) : any [] p = ff := rfl\n\n@[simp] theorem any_cons (p : \u03b1 \u2192 bool) (a : \u03b1) (l : list \u03b1) : any (a :: l) p = (p a || any l p) :=\nrfl\n\ntheorem any_iff_exists {p : \u03b1 \u2192 bool} : any l p \u2194 \u2203 a \u2208 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 (\u03bb a, p a) \u2194 \u2203 a \u2208 l, p a := by simp [any_iff_exists]\n\ntheorem any_of_mem {p : \u03b1 \u2192 bool} (h\u2081 : a \u2208 l) (h\u2082 : p a) : any l p := any_iff_exists.2 \u27e8_, h\u2081, h\u2082\u27e9\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 : Sort _} {\u03b2 : Sort _}\n\nnamespace Setoid\n\n#align setoid.r Setoid.r\n\ntheorem ext {\u03b1 : Sort _} : \u2200 {s t : Setoid \u03b1},\n    (\u2200 a b, @Setoid.r \u03b1 s a b \u2194 @Setoid.r \u03b1 t a b) \u2192 s = t\n  | \u27e8r, _\u27e9, \u27e8p, _\u27e9, Eq =>\n  by have : r = p := funext fun a \u21a6 funext fun b \u21a6 propext <| Eq a b\n     subst this\n     rfl\n#align setoid.ext Setoid.ext\n\nend Setoid\n\nnamespace Quot\n\nvariable {ra : \u03b1 \u2192 \u03b1 \u2192 Prop} {rb : \u03b2 \u2192 \u03b2 \u2192 Prop} {\u03c6 : Quot ra \u2192 Quot rb \u2192 Sort _}\n\n-- mathport name: mk\n@[inherit_doc]\nlocal notation:arg \"\u27e6\" a \"\u27e7\" => Quot.mk _ a\n\n@[elab_as_elim]\nprotected theorem induction_on {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Quot r \u2192 Prop} (q : Quot r)\n    (h : \u2200 a, \u03b2 (Quot.mk r a)) : \u03b2 q :=\n  ind h q\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Inhabited \u03b1] : Inhabited (Quot r) :=\n  \u27e8\u27e6default\u27e7\u27e9\n\nprotected instance Subsingleton [Subsingleton \u03b1] : Subsingleton (Quot ra) :=\n  \u27e8fun x \u21a6 Quot.induction_on x fun _ \u21a6 Quot.ind fun _ \u21a6 congr_arg _ (Subsingleton.elim _ _)\u27e9\n#align quot.subsingleton Quot.Subsingleton\n\n/-- Recursion on two `Quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrecOn\u2082 (qa : Quot ra) (qb : Quot rb) (f : \u2200 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n    (ca : \u2200 {b a\u2081 a\u2082}, ra a\u2081 a\u2082 \u2192 HEq (f a\u2081 b) (f a\u2082 b))\n    (cb : \u2200 {a b\u2081 b\u2082}, rb b\u2081 b\u2082 \u2192 HEq (f a b\u2081) (f a b\u2082)) :\n    \u03c6 qa qb :=\n  Quot.hrecOn (motive := fun qa \u21a6 \u03c6 qa qb) qa\n    (fun a \u21a6 Quot.hrecOn qb (f a) (fun b\u2081 b\u2082 pb \u21a6 cb pb))\n    fun a\u2081 a\u2082 pa \u21a6\n      Quot.induction_on qb fun b \u21a6\n        have h\u2081 : HEq (@Quot.hrecOn _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2081) (@cb _)) (f a\u2081 b) :=\n          by simp [heq_self_iff_true]\n        have h\u2082 : HEq (f a\u2082 b) (@Quot.hrecOn _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2082) (@cb _)) :=\n          by simp [heq_self_iff_true]\n        (h\u2081.trans (ca pa)).trans h\u2082\n#align quot.hrec_on\u2082 Quot.hrecOn\u2082\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` such that `ra x y` implies `rb (f x) (f y)`\nto a map `Quot ra \u2192 Quot rb`. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : (ra \u21d2 rb) f f) : Quot ra \u2192 Quot rb :=\n  (Quot.lift fun x \u21a6 \u27e6f x\u27e7) fun x y (h\u2081 : ra x y) \u21a6 Quot.sound <| h h\u2081\n#align quot.map Quot.map\n\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `Quot ra \u2192 Quot ra'`. -/\nprotected def mapRight {ra' : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : \u2200 a\u2081 a\u2082, ra a\u2081 a\u2082 \u2192 ra' a\u2081 a\u2082) :\n    Quot ra \u2192 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 {\u03b1 : Type _} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) : Quot r \u2192 Quot s :=\n  Quot.lift (Quot.mk s) fun x y rxy \u21a6 Quot.sound (h x y rxy)\n#align quot.factor Quot.factor\n\ntheorem factor_mk_eq {\u03b1 : Type _} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) :\n    factor r s h \u2218 Quot.mk _ = Quot.mk _ :=\n  rfl\n#align quot.factor_mk_eq Quot.factor_mk_eq\n\nvariable {\u03b3 : Sort _} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n\n-- Porting note: used to be an Alias of `quot.lift_beta`.\ntheorem lift_mk (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) (a : \u03b1) :\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 : \u03b1) (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) :\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 : \u03b1 \u2192 \u03b3} (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) :\n    Function.Surjective (lift f h) \u2194 Function.Surjective f :=\n  \u27e8fun hf => hf.comp Quot.exists_rep, fun hf y => let \u27e8x, hx\u27e9 := hf y; \u27e8Quot.mk _ x, hx\u27e9\u27e9\n#align quot.surjective_lift Quot.surjective_lift\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2`. -/\n-- porting note: removed `@[elab_as_elim]`, gave \"unexpected resulting type \u03b3\"\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\nprotected def lift\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) (q\u2081 : Quot r) (q\u2082 : Quot s) : \u03b3 :=\n  Quot.lift (fun a \u21a6 Quot.lift (f a) (hr a))\n    (fun a\u2081 a\u2082 ha \u21a6 funext fun q \u21a6 Quot.induction_on q fun b \u21a6 hs a\u2081 a\u2082 b ha) q\u2081 q\u2082\n#align quot.lift\u2082 Quot.lift\u2082\n\n@[simp]\ntheorem lift\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b)\n    (a : \u03b1) (b : \u03b2) : Quot.lift\u2082 f hr hs (Quot.mk r a) (Quot.mk s b) = f a b :=\n  rfl\n#align quot.lift\u2082_mk Quot.lift\u2082_mk\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` and applies it. -/\n-- porting note: removed `@[elab_as_elim]`, gave \"unexpected resulting type \u03b3\"\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\nprotected def liftOn\u2082 (p : Quot r) (q : Quot s) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n    (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082) (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) : \u03b3 :=\n  Quot.lift\u2082 f hr hs p q\n#align quot.lift_on\u2082 Quot.liftOn\u2082\n\n@[simp]\ntheorem liftOn\u2082_mk (a : \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) :\n    Quot.liftOn\u2082 (Quot.mk r a) (Quot.mk s b) f hr hs = f a b :=\n  rfl\n#align quot.lift_on\u2082_mk Quot.liftOn\u2082_mk\n\nvariable {t : \u03b3 \u2192 \u03b3 \u2192 Prop}\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` wih values in a quotient of\n`\u03b3`. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b)) (q\u2081 : Quot r) (q\u2082 : Quot s) : Quot t :=\n  Quot.lift\u2082 (fun a b \u21a6 Quot.mk t <| f a b) (fun a b\u2081 b\u2082 hb \u21a6 Quot.sound (hr a b\u2081 b\u2082 hb))\n    (fun a\u2081 a\u2082 b ha \u21a6 Quot.sound (hs a\u2081 a\u2082 b ha)) q\u2081 q\u2082\n#align quot.map\u2082 Quot.map\u2082\n\n@[simp]\ntheorem map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b)) (a : \u03b1) (b : \u03b2) :\n    Quot.map\u2082 f hr hs (Quot.mk r a) (Quot.mk s b) = Quot.mk t (f a b) :=\n  rfl\n#align quot.map\u2082_mk Quot.map\u2082_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\u2082 {\u03c6 : Quot r \u2192 Quot s \u2192 Sort _}\n    [h : \u2200 a b, Subsingleton (\u03c6 \u27e6a\u27e7 \u27e6b\u27e7)] (q\u2081 : Quot r)\n    (q\u2082 : Quot s) (f : \u2200 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7) : \u03c6 q\u2081 q\u2082 :=\n  @Quot.recOnSubsingleton _ r (fun q \u21a6 \u03c6 q q\u2082)\n    (fun a \u21a6 Quot.ind (\u03b2 := \u03bb b => Subsingleton (\u03c6 (mk r a) b)) (h a) q\u2082) q\u2081\n    fun a \u21a6 Quot.recOnSubsingleton q\u2082 fun b \u21a6 f a b\n#align quot.rec_on_subsingleton\u2082 Quot.recOnSubsingleton\u2082\n\n@[elab_as_elim]\nprotected theorem induction_on\u2082 {\u03b4 : Quot r \u2192 Quot s \u2192 Prop} (q\u2081 : Quot r) (q\u2082 : Quot s)\n    (h : \u2200 a b, \u03b4 (Quot.mk r a) (Quot.mk s b)) : \u03b4 q\u2081 q\u2082 :=\n  Quot.ind (\u03b2 := \u03bb a => \u03b4 a q\u2082) (fun a\u2081 \u21a6 Quot.ind (fun a\u2082 \u21a6 h a\u2081 a\u2082) q\u2082) q\u2081\n#align quot.induction_on\u2082 Quot.induction_on\u2082\n\n@[elab_as_elim]\nprotected theorem induction_on\u2083 {\u03b4 : Quot r \u2192 Quot s \u2192 Quot t \u2192 Prop} (q\u2081 : Quot r)\n    (q\u2082 : Quot s) (q\u2083 : Quot t) (h : \u2200 a b c, \u03b4 (Quot.mk r a) (Quot.mk s b) (Quot.mk t c)) :\n    \u03b4 q\u2081 q\u2082 q\u2083 :=\n  Quot.ind (\u03b2 := \u03bb a => \u03b4 a q\u2082 q\u2083) (fun a\u2081 \u21a6 Quot.ind (\u03b2 := \u03bb b => \u03b4 _ b q\u2083)\n    (fun a\u2082 \u21a6 Quot.ind (fun a\u2083 \u21a6 h a\u2081 a\u2082 a\u2083) q\u2083) q\u2082) q\u2081\n#align quot.induction_on\u2083 Quot.induction_on\u2083\n\ninstance lift.decidablePred (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (f : \u03b1 \u2192 Prop) (h : \u2200 a b, r a b \u2192 f a = f b)\n    [hf : DecidablePred f] :\n    DecidablePred (Quot.lift f h) :=\n  fun q \u21a6 Quot.recOnSubsingleton (motive := \u03bb _ => Decidable _) q hf\n\n/-- Note that this provides `DecidableRel (Quot.Lift\u2082 f ha hb)` when `\u03b1 = \u03b2`. -/\ninstance lift\u2082.decidablePred (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (ha : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082) (hb : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b)\n    [hf : \u2200 a, DecidablePred (f a)] (q\u2081 : Quot r) :\n    DecidablePred (Quot.lift\u2082 f ha hb q\u2081) :=\n  fun q\u2082 \u21a6 Quot.recOnSubsingleton\u2082 q\u2081 q\u2082 hf\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (q : Quot r) (f : \u03b1 \u2192 Prop) (h : \u2200 a b, r a b \u2192 f a = f b)\n    [DecidablePred f] :\n    Decidable (Quot.liftOn q f h) :=\n  Quot.lift.decidablePred _ _ _ _\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) (q\u2081 : Quot r) (q\u2082 : Quot s) (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (ha : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082) (hb : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b)\n    [\u2200 a, DecidablePred (f a)] :\n    Decidable (Quot.liftOn\u2082 q\u2081 q\u2082 f ha hb) :=\n  Quot.lift\u2082.decidablePred _ _ _ _ _ _ _\n\nend Quot\n\nnamespace Quotient\n\nvariable [sa : Setoid \u03b1] [sb : Setoid \u03b2]\n\nvariable {\u03c6 : Quotient sa \u2192 Quotient sb \u2192 Sort _}\n\n@[inherit_doc]\nnotation:arg \"\u27e6\" a \"\u27e7\" => Quotient.mk _ a\n\ninstance (s : Setoid \u03b1) [Inhabited \u03b1] : Inhabited (Quotient s) :=\n  \u27e8\u27e6default\u27e7\u27e9\n\ninstance (s : Setoid \u03b1) [Subsingleton \u03b1] : Subsingleton (Quotient s) :=\n  Quot.Subsingleton\n\ninstance {\u03b1 : Type _} [Setoid \u03b1] : IsEquiv \u03b1 (\u00b7 \u2248 \u00b7) 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 `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrecOn\u2082 (qa : Quotient sa) (qb : Quotient sb) (f : \u2200 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n    (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 HEq (f a\u2081 b\u2081) (f a\u2082 b\u2082)) : \u03c6 qa qb :=\n  Quot.hrecOn\u2082 qa qb f (fun p \u21a6 c _ _ _ _ p (Setoid.refl _)) fun p \u21a6 c _ _ _ _ (Setoid.refl _) p\n#align quotient.hrec_on\u2082 Quotient.hrecOn\u2082\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `Quotient sa \u2192 Quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : ((\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7)) f f) : Quotient sa \u2192 Quotient sb :=\n  Quot.map f h\n#align quotient.map Quotient.map\n\n@[simp]\ntheorem map_mk (f : \u03b1 \u2192 \u03b2) (h : ((\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7)) f f) (x : \u03b1) :\n    Quotient.map f h (\u27e6x\u27e7 : Quotient sa) = (\u27e6f x\u27e7 : Quotient sb) :=\n  rfl\n#align quotient.map_mk Quotient.map_mk\n\nvariable {\u03b3 : Sort _} [sc : Setoid \u03b3]\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` that sends equivalent elements to equivalent elements\nto a function `f : Quotient sa \u2192 Quotient sb \u2192 Quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7)) f f) :\n    Quotient sa \u2192 Quotient sb \u2192 Quotient sc :=\n  Quotient.lift\u2082 (fun x y \u21a6 \u27e6f x y\u27e7) fun _ _ _ _ h\u2081 h\u2082 \u21a6 Quot.sound <| h h\u2081 h\u2082\n#align quotient.map\u2082 Quotient.map\u2082\n\n@[simp]\ntheorem map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7)) f f) (x : \u03b1) (y : \u03b2) :\n    Quotient.map\u2082 f h (\u27e6x\u27e7 : Quotient sa) (\u27e6y\u27e7 : Quotient sb) = (\u27e6f x y\u27e7 : Quotient sc) :=\n  rfl\n#align quotient.map\u2082_mk Quotient.map\u2082_mk\n\ninstance lift.decidablePred (f : \u03b1 \u2192 Prop) (h : \u2200 a b, a \u2248 b \u2192 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\u2082 f h)` when `\u03b1 = \u03b2`. -/\ninstance lift\u2082.decidablePred (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (h : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 = f a\u2082 b\u2082)\n    [hf : \u2200 a, DecidablePred (f a)]\n    (q\u2081 : Quotient sa) : DecidablePred (Quotient.lift\u2082 f h q\u2081) :=\n  fun q\u2082 \u21a6 Quotient.recOnSubsingleton\u2082 q\u2081 q\u2082 hf\n\ninstance (q : Quotient sa) (f : \u03b1 \u2192 Prop) (h : \u2200 a b, a \u2248 b \u2192 f a = f b) [DecidablePred f] :\n    Decidable (Quotient.liftOn q f h) :=\n  Quotient.lift.decidablePred _ _ _\n\ninstance (q\u2081 : Quotient sa) (q\u2082 : Quotient sb) (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (h : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 = f a\u2082 b\u2082) [\u2200 a, DecidablePred (f a)] :\n    Decidable (Quotient.liftOn\u2082 q\u2081 q\u2082 f h) :=\n  Quotient.lift\u2082.decidablePred _ _ _ _\n\nend Quotient\n\ntheorem Quot.eq {\u03b1 : Type _} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {x y : \u03b1} :\n    Quot.mk r x = Quot.mk r y \u2194 EqvGen r x y :=\n  \u27e8Quot.exact r, Quot.EqvGen_sound\u27e9\n#align quot.eq Quot.eq\n\n@[simp]\ntheorem Quotient.eq [r : Setoid \u03b1] {x y : \u03b1} : Quotient.mk r x = \u27e6y\u27e7 \u2194 x \u2248 y :=\n  \u27e8Quotient.exact, Quotient.sound\u27e9\n\ntheorem forall_quotient_iff {\u03b1 : Type _} [r : Setoid \u03b1] {p : Quotient r \u2192 Prop} :\n    (\u2200 a : Quotient r, p a) \u2194 \u2200 a : \u03b1, p \u27e6a\u27e7 :=\n  \u27e8fun h _ \u21a6 h _, fun h a \u21a6 a.induction_on h\u27e9\n#align forall_quotient_iff forall_quotient_iff\n\n@[simp]\ntheorem Quotient.lift_mk [s : Setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 a b : \u03b1, a \u2248 b \u2192 f a = f b) (x : \u03b1) :\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 \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 a b : \u03b1, a \u2248 b \u2192 f a = f b) :\n    Quotient.lift f h \u2218 Quotient.mk _ = f :=\n  rfl\n#align quotient.lift_comp_mk Quotient.lift_comp_mk\n\n@[simp]\ntheorem Quotient.lift\u2082_mk {\u03b1 : Sort _} {\u03b2 : Sort _} {\u03b3 : Sort _} [Setoid \u03b1] [Setoid \u03b2]\n    (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n    (h : \u2200 (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082)\n    (a : \u03b1) (b : \u03b2) :\n    Quotient.lift\u2082 f h (Quotient.mk _ a) (Quotient.mk _ b) = f a b :=\n  rfl\n#align quotient.lift\u2082_mk Quotient.lift\u2082_mk\n\ntheorem Quotient.liftOn_mk [s : Setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 a b : \u03b1, a \u2248 b \u2192 f a = f b) (x : \u03b1) :\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\u2082_mk {\u03b1 : Sort _} {\u03b2 : Sort _} [Setoid \u03b1] (f : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n    (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082 : \u03b1, a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) (x y : \u03b1) :\n    Quotient.liftOn\u2082 (Quotient.mk _ x) (Quotient.mk _ y) f h = f x y :=\n  rfl\n#align quotient.lift_on\u2082_mk Quotient.liftOn\u2082_mk\n\n/-- `Quot.mk r` is a surjective function. -/\ntheorem surjective_quot_mk (r : \u03b1 \u2192 \u03b1 \u2192 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 (\u03b1 : Sort _) [s : Setoid \u03b1] :\n    Function.Surjective (Quotient.mk _ : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} (q : Quot r) : \u03b1 :=\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 : \u03b1 \u2192 \u03b1 \u2192 Prop} : Quot r \u2192 \u03b1 :=\n  cast lcProof -- porting notes: was `unchecked_cast` before, which unfolds to `cast undefined`\n\n@[simp]\ntheorem Quot.out_eq {r : \u03b1 \u2192 \u03b1 \u2192 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 \u03b1] : Quotient s \u2192 \u03b1 :=\n  Quot.out\n#align quotient.out Quotient.out\n\n@[simp]\ntheorem Quotient.out_eq [s : Setoid \u03b1] (q : Quotient s) : \u27e6q.out\u27e7 = q :=\n  Quot.out_eq q\n#align quotient.out_eq Quotient.out_eq\n\ntheorem Quotient.mk_out [Setoid \u03b1] (a : \u03b1) : \u27e6a\u27e7.out \u2248 a :=\n  Quotient.exact (Quotient.out_eq _)\n#align quotient.mk_out Quotient.mk_out\n\ntheorem Quotient.mk_eq_iff_out [s : Setoid \u03b1] {x : \u03b1} {y : Quotient s} :\n    \u27e6x\u27e7 = y \u2194 x \u2248 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 \u03b1] {x : Quotient s} {y : \u03b1} :\n    x = \u27e6y\u27e7 \u2194 Quotient.out x \u2248 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 \u03b1} {x y : Quotient s} : x.out \u2248 y.out \u2194 x = y := by\n  rw [\u2190 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 \u03b1} : Function.Injective (@Quotient.out \u03b1 s) :=\n  fun _ _ h \u21a6 Quotient.out_equiv_out.1 <| h \u25b8 Setoid.refl _\n#align quotient.out_injective Quotient.out_injective\n\n@[simp]\ntheorem Quotient.out_inj {s : Setoid \u03b1} {x y : Quotient s} : x.out = y.out \u2194 x = y :=\n  \u27e8fun h \u21a6 Quotient.out_injective h, fun h \u21a6 h \u25b8 rfl\u27e9\n#align quotient.out_inj Quotient.out_inj\n\nsection Pi\n\ninstance piSetoid {\u03b9 : Sort _} {\u03b1 : \u03b9 \u2192 Sort _} [\u2200 i, Setoid (\u03b1 i)] : Setoid (\u2200 i, \u03b1 i) where\n  r a b := \u2200 i, a i \u2248 b i\n  iseqv := \u27e8fun _ _ \u21a6 Setoid.refl _,\n            fun h _ \u21a6 Setoid.symm (h _),\n            fun h\u2081 h\u2082 _ \u21a6 Setoid.trans (h\u2081 _) (h\u2082 _)\u27e9\n\n/-- Given a function `f : \u03a0 i, Quotient (S i)`, returns the class of functions `\u03a0 i, \u03b1 i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def Quotient.choice {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [S : \u2200 i, Setoid (\u03b1 i)]\n    (f : \u2200 i, Quotient (S i)) :\n    @Quotient (\u2200 i, \u03b1 i) (by infer_instance) :=\n  \u27e6fun i \u21a6 (f i).out\u27e7\n#align quotient.choice Quotient.choice\n\n@[simp]\ntheorem Quotient.choice_eq {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Setoid (\u03b1 i)] (f : \u2200 i, \u03b1 i) :\n    (Quotient.choice fun i \u21a6 \u27e6f i\u27e7) = \u27e6f\u27e7 :=\n  Quotient.sound fun _ \u21a6 Quotient.mk_out _\n#align quotient.choice_eq Quotient.choice_eq\n\n@[elab_as_elim]\ntheorem Quotient.induction_on_pi {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Sort _} [s : \u2200 i, Setoid (\u03b1 i)]\n    {p : (\u2200 i, Quotient (s i)) \u2192 Prop} (f : \u2200 i, Quotient (s i))\n    (h : \u2200 a : \u2200 i, \u03b1 i, p fun i \u21a6 \u27e6a i\u27e7) : p f := by\n  rw [\u2190 (funext fun i \u21a6 Quotient.out_eq (f i) : (fun i \u21a6 \u27e6(f i).out\u27e7) = f)]\n  apply h\n#align quotient.induction_on_pi Quotient.induction_on_pi\n\nend Pi\n\ntheorem nonempty_quotient_iff (s : Setoid \u03b1) : Nonempty (Quotient s) \u2194 Nonempty \u03b1 :=\n  \u27e8fun \u27e8a\u27e9 \u21a6 Quotient.inductionOn a Nonempty.intro, fun \u27e8a\u27e9 \u21a6 \u27e8\u27e6a\u27e7\u27e9\u27e9\n#align nonempty_quotient_iff nonempty_quotient_iff\n\n/-! ### Truncation -/\n\n\ntheorem true_equivalence : @Equivalence \u03b1 fun _ _ \u21a6 True :=\n  \u27e8fun _ \u21a6 trivial, fun _ \u21a6 trivial, fun _ _ \u21a6 trivial\u27e9\n#align true_equivalence true_equivalence\n\n/-- Always-true relation as a `Setoid`.\n\nNote that in later files the preferred spelling is `\u22a4 : Setoid \u03b1`. -/\ndef trueSetoid : Setoid \u03b1 :=\n  \u27e8_, true_equivalence\u27e9\n#align true_setoid trueSetoid\n\n/-- `Trunc \u03b1` is the quotient of `\u03b1` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `Nonempty \u03b1`, but unlike `Nonempty \u03b1`, `Trunc \u03b1` is data,\n  so the VM representation is the same as `\u03b1`, and so this can be used to\n  maintain computability. -/\ndef Trunc.{u} (\u03b1 : Sort u) : Sort u :=\n  @Quotient \u03b1 trueSetoid\n#align trunc Trunc\n\nnamespace Trunc\n\n/-- Constructor for `Trunc \u03b1` -/\ndef mk (a : \u03b1) : Trunc \u03b1 :=\n  Quot.mk _ a\n#align trunc.mk Trunc.mk\n\ninstance [Inhabited \u03b1] : Inhabited (Trunc \u03b1) :=\n  \u27e8mk default\u27e9\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : \u03b1 \u2192 \u03b2) (c : \u2200 a b : \u03b1, f a = f b) : Trunc \u03b1 \u2192 \u03b2 :=\n  Quot.lift f fun a b _ \u21a6 c a b\n#align trunc.lift Trunc.lift\n\ntheorem ind {\u03b2 : Trunc \u03b1 \u2192 Prop} : (\u2200 a : \u03b1, \u03b2 (mk a)) \u2192 \u2200 q : Trunc \u03b1, \u03b2 q :=\n  Quot.ind\n#align trunc.ind Trunc.ind\n\nprotected theorem lift_mk (f : \u03b1 \u2192 \u03b2) (c) (a : \u03b1) : 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 \u03b1`. -/\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 \u03b1) (f : \u03b1 \u2192 \u03b2) (c : \u2200 a b : \u03b1, f a = f b) : \u03b2 :=\n  lift f c q\n#align trunc.lift_on Trunc.liftOn\n\n@[elab_as_elim]\nprotected theorem induction_on {\u03b2 : Trunc \u03b1 \u2192 Prop} (q : Trunc \u03b1) (h : \u2200 a, \u03b2 (mk a)) : \u03b2 q :=\n  ind h q\n#align trunc.induction_on Trunc.induction_on\n\ntheorem exists_rep (q : Trunc \u03b1) : \u2203 a : \u03b1, 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\u2082 {C : Trunc \u03b1 \u2192 Trunc \u03b2 \u2192 Prop} (q\u2081 : Trunc \u03b1) (q\u2082 : Trunc \u03b2)\n    (h : \u2200 a b, C (mk a) (mk b)) : C q\u2081 q\u2082 :=\n  Trunc.induction_on q\u2081 fun a\u2081 \u21a6 Trunc.induction_on q\u2082 (h a\u2081)\n#align trunc.induction_on\u2082 Trunc.induction_on\u2082\n\nprotected theorem eq (a b : Trunc \u03b1) : a = b :=\n  Trunc.induction_on\u2082 a b fun _ _ \u21a6 Quot.sound trivial\n#align trunc.eq Trunc.eq\n\ninstance : Subsingleton (Trunc \u03b1) :=\n  \u27e8Trunc.eq\u27e9\n\n/-- The `bind` operator for the `Trunc` monad. -/\ndef bind (q : Trunc \u03b1) (f : \u03b1 \u2192 Trunc \u03b2) : Trunc \u03b2 :=\n  Trunc.liftOn q f fun _ _ \u21a6 Trunc.eq _ _\n#align trunc.bind Trunc.bind\n\n/-- A function `f : \u03b1 \u2192 \u03b2` defines a function `map f : Trunc \u03b1 \u2192 Trunc \u03b2`. -/\ndef map (f : \u03b1 \u2192 \u03b2) (q : Trunc \u03b1) : Trunc \u03b2 :=\n  bind q (Trunc.mk \u2218 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 \u03b1 \u2192 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 : \u2200 a, C (mk a))\n    (h : \u2200 a b : \u03b1, (Eq.ndrec (f a) (Trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n    (q : Trunc \u03b1) : C q :=\n  Quot.rec f (fun a b _ \u21a6 h a b) q\n#align trunc.rec Trunc.rec\n\n/-- A version of `Trunc.rec` taking `q : Trunc \u03b1` as the first argument. -/\n-- porting note: removed `@[reducible]` because it caused extremely slow `simp`\n@[elab_as_elim]\nprotected def recOn (q : Trunc \u03b1) (f : \u2200 a, C (mk a))\n    (h : \u2200 a b : \u03b1, (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 [\u2200 a, Subsingleton (C (mk a))] (q : Trunc \u03b1) (f : \u2200 a, C (mk a)) :\n    C q :=\n  Trunc.rec f (fun _ b \u21a6 Subsingleton.elim _ (f b)) q\n#align trunc.rec_on_subsingleton Trunc.recOnSubsingleton\n\n/-- Noncomputably extract a representative of `Trunc \u03b1` (using the axiom of choice). -/\nnoncomputable def out : Trunc \u03b1 \u2192 \u03b1 :=\n  Quot.out\n#align trunc.out Trunc.out\n\n@[simp]\ntheorem out_eq (q : Trunc \u03b1) : mk q.out = q :=\n  Trunc.eq _ _\n#align trunc.out_eq Trunc.out_eq\n\nprotected theorem nonempty (q : Trunc \u03b1) : Nonempty \u03b1 :=\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 {\u03b3 : Sort _} {\u03c6 : Sort _} {s\u2081 : Setoid \u03b1} {s\u2082 : Setoid \u03b2} {s\u2083 : Setoid \u03b3}\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 \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk'' (a : \u03b1) : Quotient s\u2081 :=\n  Quot.mk s\u2081.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'' : \u03b1 \u2192 Quotient s\u2081) :=\n  Quot.exists_rep\n#align quotient.surjective_quotient_mk' Quotient.surjective_Quotient_mk''\n\n/-- A version of `Quotient.liftOn` taking `{s : Setoid \u03b1}` 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\u2081) (f : \u03b1 \u2192 \u03c6) (h : \u2200 a b, @Setoid.r \u03b1 s\u2081 a b \u2192 f a = f b) :\n    \u03c6 :=\n  Quotient.liftOn q f h\n#align quotient.lift_on' Quotient.liftOn'\n\n@[simp]\nprotected theorem liftOn'_mk'' (f : \u03b1 \u2192 \u03c6) (h) (x : \u03b1) :\n    Quotient.liftOn' (@Quotient.mk'' _ s\u2081 x) f h = f x :=\n  rfl\n\n@[simp] lemma surjective_liftOn' {f : \u03b1 \u2192 \u03c6} (h) :\n    Function.Surjective (\u03bb x : Quotient s\u2081 => x.liftOn' f h) \u2194 Function.Surjective f :=\n  Quot.surjective_lift _\n#align quotient.surjective_lift_on' Quotient.surjective_liftOn'\n\n/-- A version of `Quotient.liftOn\u2082` taking `{s\u2081 : Setoid \u03b1} {s\u2082 : Setoid \u03b2}` 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\u2082' (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n    (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082, @Setoid.r \u03b1 s\u2081 a\u2081 b\u2081 \u2192 @Setoid.r \u03b2 s\u2082 a\u2082 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) : \u03b3 :=\n  Quotient.liftOn\u2082 q\u2081 q\u2082 f h\n#align quotient.lift_on\u2082' Quotient.liftOn\u2082'\n\n@[simp]\nprotected theorem liftOn\u2082'_mk'' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (a : \u03b1) (b : \u03b2) :\n    Quotient.liftOn\u2082' (@Quotient.mk'' _ s\u2081 a) (@Quotient.mk'' _ s\u2082 b) f h = f a b :=\n  rfl\n\n/-- A version of `Quotient.ind` taking `{s : Setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_elim]\nprotected theorem ind' {p : Quotient s\u2081 \u2192 Prop} (h : \u2200 a, p (Quotient.mk'' a)) (q : Quotient s\u2081) :\n    p q :=\n  Quotient.ind h q\n#align quotient.ind' Quotient.ind'\n\n/-- A version of `Quotient.ind\u2082` taking `{s\u2081 : Setoid \u03b1} {s\u2082 : Setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem ind\u2082' {p : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Prop}\n    (h : \u2200 a\u2081 a\u2082, p (Quotient.mk'' a\u2081) (Quotient.mk'' a\u2082))\n    (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) : p q\u2081 q\u2082 :=\n  Quotient.ind\u2082 h q\u2081 q\u2082\n#align quotient.ind\u2082' Quotient.ind\u2082'\n\n/-- A version of `Quotient.inductionOn` taking `{s : Setoid \u03b1}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_elim]\nprotected theorem inductionOn' {p : Quotient s\u2081 \u2192 Prop} (q : Quotient s\u2081)\n    (h : \u2200 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\u2082` taking `{s\u2081 : Setoid \u03b1} {s\u2082 : Setoid \u03b2}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem inductionOn\u2082' {p : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Prop} (q\u2081 : Quotient s\u2081)\n    (q\u2082 : Quotient s\u2082)\n    (h : \u2200 a\u2081 a\u2082, p (Quotient.mk'' a\u2081) (Quotient.mk'' a\u2082)) : p q\u2081 q\u2082 :=\n  Quotient.inductionOn\u2082 q\u2081 q\u2082 h\n#align quotient.induction_on\u2082' Quotient.inductionOn\u2082'\n\n/-- A version of `Quotient.inductionOn\u2083` taking `{s\u2081 : Setoid \u03b1} {s\u2082 : Setoid \u03b2} {s\u2083 : Setoid \u03b3}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem inductionOn\u2083' {p : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Quotient s\u2083 \u2192 Prop}\n    (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) (q\u2083 : Quotient s\u2083)\n    (h : \u2200 a\u2081 a\u2082 a\u2083, p (Quotient.mk'' a\u2081) (Quotient.mk'' a\u2082) (Quotient.mk'' a\u2083)) :\n    p q\u2081 q\u2082 q\u2083 :=\n  Quotient.inductionOn\u2083 q\u2081 q\u2082 q\u2083 h\n#align quotient.induction_on\u2083' Quotient.inductionOn\u2083'\n\n/-- A version of `Quotient.recOnSubsingleton` taking `{s\u2081 : Setoid \u03b1}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_elim]\nprotected def recOnSubsingleton' {\u03c6 : Quotient s\u2081 \u2192 Sort _} [\u2200 a, Subsingleton (\u03c6 \u27e6a\u27e7)]\n    (q : Quotient s\u2081)\n    (f : \u2200 a, \u03c6 (Quotient.mk'' a)) : \u03c6 q :=\n  Quotient.recOnSubsingleton q f\n#align quotient.rec_on_subsingleton' Quotient.recOnSubsingleton'\n\n/-- A version of `Quotient.recOnSubsingleton\u2082` taking `{s\u2081 : Setoid \u03b1} {s\u2082 : Setoid \u03b1}`\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\u2082' {\u03c6 : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Sort _}\n    [\u2200 a b, Subsingleton (\u03c6 \u27e6a\u27e7 \u27e6b\u27e7)]\n    (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) (f : \u2200 a\u2081 a\u2082, \u03c6 (Quotient.mk'' a\u2081) (Quotient.mk'' a\u2082)) :\n    \u03c6 q\u2081 q\u2082 :=\n  Quotient.recOnSubsingleton\u2082 q\u2081 q\u2082 f\n#align quotient.rec_on_subsingleton\u2082' Quotient.recOnSubsingleton\u2082'\n\n/-- Recursion on a `Quotient` argument `a`, result type depends on `\u27e6a\u27e7`. -/\nprotected def hrecOn' {\u03c6 : Quotient s\u2081 \u2192 Sort _} (qa : Quotient s\u2081) (f : \u2200 a, \u03c6 (Quotient.mk'' a))\n    (c : \u2200 a\u2081 a\u2082, a\u2081 \u2248 a\u2082 \u2192 HEq (f a\u2081) (f a\u2082)) : \u03c6 qa :=\n  Quot.hrecOn qa f c\n#align quotient.hrec_on' Quotient.hrecOn'\n\n@[simp]\ntheorem hrecOn'_mk'' {\u03c6 : Quotient s\u2081 \u2192 Sort _} (f : \u2200 a, \u03c6 (Quotient.mk'' a))\n    (c : \u2200 a\u2081 a\u2082, a\u2081 \u2248 a\u2082 \u2192 HEq (f a\u2081) (f a\u2082))\n    (x : \u03b1) : (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 `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrecOn\u2082' {\u03c6 : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Sort _} (qa : Quotient s\u2081)\n    (qb : Quotient s\u2082) (f : \u2200 a b, \u03c6 (Quotient.mk'' a) (Quotient.mk'' b))\n    (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 HEq (f a\u2081 b\u2081) (f a\u2082 b\u2082)) :\n    \u03c6 qa qb :=\n  Quotient.hrecOn\u2082 qa qb f c\n#align quotient.hrec_on\u2082' Quotient.hrecOn\u2082'\n\n@[simp]\ntheorem hrecOn\u2082'_mk'' {\u03c6 : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Sort _}\n    (f : \u2200 a b, \u03c6 (Quotient.mk'' a) (Quotient.mk'' b))\n    (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 HEq (f a\u2081 b\u2081) (f a\u2082 b\u2082)) (x : \u03b1) (qb : Quotient s\u2082) :\n    (Quotient.mk'' x).hrecOn\u2082' qb f c = qb.hrecOn' (f x) fun _ _ \u21a6 c _ _ _ _ (Setoid.refl _) :=\n  rfl\n#align quotient.hrec_on\u2082'_mk' Quotient.hrecOn\u2082'_mk''\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `Quotient sa \u2192 Quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : \u03b1 \u2192 \u03b2) (h : (s\u2081.r \u21d2 s\u2082.r) f f) : Quotient s\u2081 \u2192 Quotient s\u2082 :=\n  Quot.map f h\n#align quotient.map' Quotient.map'\n\n@[simp]\ntheorem map'_mk'' (f : \u03b1 \u2192 \u03b2) (h) (x : \u03b1) :\n    (Quotient.mk'' x : Quotient s\u2081).map' f h = (Quotient.mk'' (f x) : Quotient s\u2082) :=\n  rfl\n\n/-- A version of `Quotient.map\u2082` using curly braces and unification. -/\nprotected def map\u2082' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : (s\u2081.r \u21d2 s\u2082.r \u21d2 s\u2083.r) f f) :\n    Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Quotient s\u2083 :=\n  Quotient.map\u2082 f h\n#align quotient.map\u2082' Quotient.map\u2082'\n\n@[simp]\ntheorem map\u2082'_mk'' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (x : \u03b1) :\n    (Quotient.mk'' x : Quotient s\u2081).map\u2082' f h =\n      (Quotient.map' (f x) (h (Setoid.refl x)) : Quotient s\u2082 \u2192 Quotient s\u2083) :=\n  rfl\n\ntheorem exact' {a b : \u03b1} :\n    (Quotient.mk'' a : Quotient s\u2081) = Quotient.mk'' b \u2192 @Setoid.r _ s\u2081 a b :=\n  Quotient.exact\n#align quotient.exact' Quotient.exact'\n\ntheorem sound' {a b : \u03b1} : @Setoid.r _ s\u2081 a b \u2192 @Quotient.mk'' \u03b1 s\u2081 a = Quotient.mk'' b :=\n  Quotient.sound\n#align quotient.sound' Quotient.sound'\n\n@[simp]\nprotected theorem eq' [s\u2081 : Setoid \u03b1] {a b : \u03b1} :\n    @Quotient.mk' \u03b1 s\u2081 a = @Quotient.mk' \u03b1 s\u2081 b \u2194 @Setoid.r _ s\u2081 a b :=\n  Quotient.eq\n#align quotient.eq Quotient.eq'\n\n@[simp]\nprotected theorem eq'' {a b : \u03b1} : @Quotient.mk'' \u03b1 s\u2081 a = Quotient.mk'' b \u2194 @Setoid.r _ s\u2081 a b :=\n  Quotient.eq\n#align quotient.eq' Quotient.eq''\n\n/-- A version of `Quotient.out` taking `{s\u2081 : Setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : Quotient s\u2081) : \u03b1 :=\n  Quotient.out a\n#align quotient.out' Quotient.out'\n\n@[simp]\ntheorem out_eq' (q : Quotient s\u2081) : Quotient.mk'' q.out' = q :=\n  q.out_eq\n#align quotient.out_eq' Quotient.out_eq'\n\ntheorem mk_out' (a : \u03b1) : @Setoid.r \u03b1 s\u2081 (Quotient.mk'' a : Quotient s\u2081).out' a :=\n  Quotient.exact (Quotient.out_eq _)\n#align quotient.mk_out' Quotient.mk_out'\n\nsection\n\nvariable [s : Setoid \u03b1]\n\nprotected theorem mk''_eq_mk (x : \u03b1) : Quotient.mk'' x = Quotient.mk s x :=\n  rfl\n\n@[simp]\nprotected theorem liftOn'_mk (x : \u03b1) (f : \u03b1 \u2192 \u03b2) (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\u2082'_mk [t : Setoid \u03b2] (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (a : \u03b1) (b : \u03b2) :\n    Quotient.liftOn\u2082' (Quotient.mk s a) (Quotient.mk t b) f h = f a b :=\n  Quotient.liftOn\u2082'_mk'' _ _ _ _\n#align quotient.lift_on\u2082'_mk Quotient.liftOn\u2082'_mk\n\n@[simp]\n\n\nend\n\ninstance (q : Quotient s\u2081) (f : \u03b1 \u2192 Prop) (h : \u2200 a b, @Setoid.r \u03b1 s\u2081 a b \u2192 f a = f b)\n    [DecidablePred f] :\n    Decidable (Quotient.liftOn' q f h) :=\n  Quotient.lift.decidablePred _ _ q\n\ninstance (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (h : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, @Setoid.r \u03b1 s\u2081 a\u2081 a\u2082 \u2192 @Setoid.r \u03b2 s\u2082 b\u2081 b\u2082 \u2192 f a\u2081 b\u2081 = f a\u2082 b\u2082)\n    [\u2200 a, DecidablePred (f a)] :\n    Decidable (Quotient.liftOn\u2082' q\u2081 q\u2082 f h) :=\n  Quotient.lift\u2082.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' \u27e8fun X => \u27e8\u27e8\u27e81\u27e9, fun f => _\u27e9\u27e9, fun X => \u27e8\u27e8\u27e81\u27e9, fun f => _\u27e9\u27e9\u27e9\n  \u00b7 ext x\n    have : x = 1 := Subsingleton.elim _ _\n    rw [this, Hom.map_one, Hom.map_one]\n  \u00b7 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  \u27e8\u27e8of PUnit, isZero_of_subsingleton _\u27e9\u27e9\n\nend GroupCat\n\nnamespace CommGroupCat\n\n@[to_additive]\ntheorem isZero_of_subsingleton (G : CommGroupCat) [Subsingleton G] : IsZero G := by\n  refine' \u27e8fun X => \u27e8\u27e8\u27e81\u27e9, fun f => _\u27e9\u27e9, fun X => \u27e8\u27e8\u27e81\u27e9, fun f => _\u27e9\u27e9\u27e9\n  \u00b7 ext x\n    have : x = 1 := Subsingleton.elim _ _\n    rw [this, Hom.map_one, Hom.map_one]\n  \u00b7 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  \u27e8\u27e8of PUnit, isZero_of_subsingleton _\u27e9\u27e9\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 `\u03b1`\n\nThis file provides extra lemmas about some `subgroup`s that exist within `equiv.perm \u03b1`.\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [fintype \u21a5(monoid_hom.range (sum_congr_hom \u03b1 \u03b2))] [fintype (perm \u03b1 \u00d7 perm \u03b2)] : fintype.card \u21a5(monoid_hom.range (sum_congr_hom \u03b1 \u03b2)) = fintype.card (perm \u03b1 \u00d7 perm \u03b2) :=\n  iff.mpr fintype.card_eq (Nonempty.intro (equiv.symm (set.range (\u21d1(sum_congr_hom \u03b1 \u03b2)) sum_congr_hom_injective)))\n\n@[simp] theorem sigma_congr_right_hom.card_range {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} [fintype \u21a5(monoid_hom.range (sigma_congr_right_hom \u03b2))] [fintype ((a : \u03b1) \u2192 perm (\u03b2 a))] : fintype.card \u21a5(monoid_hom.range (sigma_congr_right_hom \u03b2)) = fintype.card ((a : \u03b1) \u2192 perm (\u03b2 a)) :=\n  iff.mpr fintype.card_eq\n    (Nonempty.intro (equiv.symm (set.range (\u21d1(sigma_congr_right_hom \u03b2)) 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 \u2227 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) : \u00ac x + 1 \u2264 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) : \u00ac x + 1 \u2264 x := Nat.not_succ_le_self x\n\nprotected theorem succ_le_succ' {x y : Nat} : x \u2264 y \u2192 x + 1 \u2264 y + 1 := Nat.succ_le_succ\n\nprotected theorem le_of_succ_le_succ' {x y : Nat} : x + 1 \u2264 y + 1 \u2192 x \u2264 y := Nat.le_of_succ_le_succ\n\nprotected theorem succ_lt_succ' {x y : Nat} : x < y \u2192 x + 1 < y + 1 := Nat.succ_lt_succ\n\nprotected theorem lt_of_succ_lt_succ' {x y : Nat} : x + 1 < y + 1 \u2192 x < y := Nat.lt_of_succ_lt_succ\n\nprotected theorem succ_le_of_lt' {x y : Nat} : x + 1 \u2264 y \u2192 x < y := Nat.succ_le_of_lt\n\nprotected theorem lt_of_succ_le' {x y : Nat} : x + 1 \u2264 y \u2192 x < y := Nat.lt_of_succ_le\n\nprotected theorem lt_succ_of_le' {x y : Nat} : x \u2264 y \u2192 x < y + 1 := Nat.lt_succ_of_le\n\nprotected theorem le_of_lt_succ' {x y : Nat} : x < y + 1 \u2192 x \u2264 y := Nat.le_of_lt_succ\n\nprotected theorem succ_le_iff_lt (x y : Nat) : x + 1 \u2264 y \u2194 x < y :=\n  \u27e8Nat.lt_of_succ_le, Nat.succ_le_of_lt\u27e9\n\nprotected theorem lt_succ_iff_le (x y : Nat) : x < y + 1 \u2194 x \u2264 y :=\n  \u27e8Nat.le_of_lt_succ, Nat.lt_succ_of_le\u27e9\n\nprotected theorem succ_le_succ_iff_le (x y : Nat) : x + 1 \u2264 y + 1 \u2194 x \u2264 y :=\n  \u27e8Nat.le_of_succ_le_succ, Nat.succ_le_succ\u27e9\n\nprotected theorem succ_lt_succ_iff_lt (x y : Nat) : x + 1 < y + 1 \u2194 x < y :=\n  \u27e8Nat.lt_of_succ_lt_succ, Nat.succ_lt_succ\u27e9\n\nprotected theorem pred_le_iff_le_succ (x y : Nat) : x - 1 \u2264 y \u2194 x \u2264 y + 1 := by\n  cases x, y with\n  | left x =>\n    cases x with\n    | zero =>\n      constr\n      \u00b7 intro\n        apply Nat.zero_le\n      \u00b7 intro\n        apply Nat.zero_le\n    | succ x =>\n      constr\n      \u00b7 exact Nat.succ_le_succ\n      \u00b7 exact Nat.le_of_succ_le_succ\n  | right y =>\n    constr\n    \u00b7 intro\n      apply Nat.zero_le\n    \u00b7 intro\n      apply Nat.zero_le\n  | diag x y =>\n    constr\n    \u00b7 exact Nat.succ_le_succ\n    \u00b7 exact Nat.le_of_succ_le_succ\n\nprotected theorem succ_lt_iff_lt_pred (x y : Nat) : x + 1 < y \u2194 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 \u2264 y \u2228 x = 0 \u2194 x \u2264 y - 1 := by\n  cases x, y with\n  | left x =>\n    constr\n    \u00b7 intro\n      | Or.inl h => absurd h; apply Nat.not_succ_le_zero\n      | Or.inr h => rw [h]; apply Nat.le_refl\n    \u00b7 intro h\n      right\n      antisymmetry using LE.le\n      exact h\n      exact Nat.zero_le x\n  | right y =>\n    constr\n    \u00b7 intro; apply Nat.zero_le\n    \u00b7 intro; right; reflexivity\n  | diag x y =>\n    constr\n    \u00b7 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    \u00b7 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 \u2228 x = 0 \u2194 x < y + 1 := by\n  cases x, y using Nat.casesDiagAuxOn with\n  | left x =>\n    constr\n    \u00b7 intro\n      | Or.inl h => absurd h; apply Nat.not_lt_zero\n      | Or.inr h => rw [h]; apply Nat.zero_lt_one\n    \u00b7 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    \u00b7 intro\n      apply Nat.zero_lt_succ\n    \u00b7 intro\n      right\n      reflexivity\n  | diag x y =>\n    constr\n    \u00b7 intro\n      | Or.inl h => exact Nat.succ_lt_succ h\n      | Or.inr h => absurd h; apply Nat.succ_ne_zero\n    \u00b7 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 : \u2115) (x : \u211a) :\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 : \u2115) (x : \u211a) :\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 : \u2115) (x : \u211a) :\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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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 : \u2115) (x : \u211a) :\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 (\u03b1:Type*) (A B:filter \u03b1):\n  (\u2200 a, a\u2208 B \u2192 a\u2208 A)\u2192 (A\u2264 B)  :=\nbegin\n  intros,\n  apply (@filter.le_def \u03b1 A B).mpr,\n  assumption,\nend\n\n\nlemma filter_le_intro2 (\u03b1:Type*) (A B:filter \u03b1):\n  (B.sets \u2286 A.sets)\u2192 (A\u2264 B)  :=\nbegin\n  intros,\n  apply (@filter.le_def \u03b1 A B).mpr,\n  have A1:((B.sets \u2286 A.sets) \u2194 (\u2200 a\u2208 B.sets, a\u2208 A.sets)),\n  {\n     refl,\n  },\n  assumption,\nend\n\n\nlemma filter_le_elim {\u03b1:Type*} {A B:filter \u03b1} {a:set \u03b1}:\n   (A\u2264 B) \u2192 (a\u2208 B)\u2192 (a\u2208 A) :=\nbegin\n  intros,\n  apply (@filter.le_def \u03b1 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 \u03b2)\u2192 (set \u03b1)\n  --set.preimage f B = {x:f x \u2208 B}\n  --set.preimage (set.preimage f) has type (set (set \u03b1)) \u2192 (set (set \u03b2))\n  --set.preimage (set.preimage f) AF = {y:(set.preimage f) y \u2208 AF}\n  --set.preimage (set.preimage f) AF = {y:{x:f x\u2208 y} \u2208 AF}\n\n-/\nlemma filter_map_def (\u03b1 \u03b2:Type*) (A:filter \u03b1) (f:\u03b1 \u2192 \u03b2):\n  (filter.map f A).sets = set.preimage (set.preimage f) A.sets :=\nbegin\n  refl,\nend\n\nlemma filter_mem_def (\u03b1:Type*) (A:filter \u03b1) (a:set \u03b1):\n  (a\u2208 A) = (a \u2208 A.sets) :=\nbegin\n  refl,\nend\n\n\nlemma filter_map_intro (\u03b1 \u03b2 : Type*) (A : filter \u03b1) (f : \u03b1 \u2192 \u03b2) (X : set \u03b1) (Y : set \u03b2)\n (a: X\u2208 A) (a_1 : X=set.preimage f Y) : (Y\u2208 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 \u2190 a_1,\n  assumption,\nend\n\nlemma filter_map_elim (\u03b1 \u03b2:Type*) (A:filter \u03b1) (f:\u03b1 \u2192 \u03b2) (Y:set \u03b2)\n  (a : Y \u2208 filter.map f A) : (\u2203 (X\u2208 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 (\u03b1 \u03b2:Type*)   (f:\u03b1 \u2192 \u03b2) (A:filter \u03b1) (B:filter \u03b2):\n  (\u2200 b\u2208 B, set.preimage f b \u2208 A) \u2192 (@filter.tendsto \u03b1 \u03b2  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 \u2208 B \u2192 f \u207b\u00b9' a_1 \u2208 A,\n  {\n    apply a,\n  },\n\n  have A2:f \u207b\u00b9' a_1 \u2208 A,\n  {\n     apply A1,\n     apply a_2,\n  },\n  apply A2,\n  refl,\nend\n\nlemma filter_tendsto_elim {\u03b1 \u03b2:Type*} {f:\u03b1 \u2192 \u03b2} {A:filter \u03b1} {B:filter \u03b2} {s:set \u03b2}:\n   (@filter.tendsto \u03b1 \u03b2  f A B) \u2192(s\u2208 B)\u2192  (set.preimage f s \u2208 A) :=\nbegin\n  intros a a_1,\n  unfold filter.tendsto at a,\n  have A1:s\u2208 filter.map f A,\n  {\n    apply filter_le_elim,\n    apply a,\n    apply a_1,\n  },\n\n  have A2:(\u2203 (X\u2208 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 {\u03b1:Type*} (a:finset \u03b1) (b:set (finset \u03b1)):\n  ({c : finset \u03b1 | a \u2286 c} \u2286 b) \u2192 b \u2208 (filter.principal  {c:finset \u03b1 | a\u2286 c}):=\nbegin\n  --apply b\u2208 (filter.principal  {c:finset \u2115 | a\u2286 c}),\n  intros a_1,\n  unfold filter.principal,\n  have A1:b \u2208 {t : set (finset \u03b1) | {c : finset \u03b1 | a \u2286 c} \u2286 t},\n  {\n    simp,\n    apply a_1,\n  },\n  apply A1,\nend\n\n\nlemma filter_principal_elim {\u03b1:Type*} (a:finset \u03b1) (b:set (finset \u03b1)):\n  b \u2208 (filter.principal  {c:finset \u03b1 | a\u2286 c}) \u2192 ({c : finset \u03b1 | a \u2286 c} \u2286 b) :=\nbegin\n  intros a_1,\n  apply (@filter.mem_principal_sets (finset \u03b1) b {c:finset \u03b1 | a\u2286 c}).mp,\n  apply a_1,\nend\n\n\n\nlemma filter_principal_intro2 {\u03b1:Type*} (a:finset \u03b1) (b:set (finset \u03b1)):\n  (\u2200 c:finset \u03b1, a\u2286 c \u2192 c\u2208 b) \u2192 b \u2208 (filter.principal  {c:finset \u03b1 | a\u2286 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 {\u03b1:Type*} (a b:set \u03b1):\n  (a\u2286 b) \u2192 b \u2208 filter.principal  a:=\nbegin\n  simp [filter.principal],\nend\n\n\nlemma filter_principal_elim2 {\u03b1:Type*} (a:finset \u03b1) (b:set (finset \u03b1)) (c:finset \u03b1):\n  b \u2208 (filter.principal  {c:finset \u03b1 | a\u2286 c}) \u2192 (a \u2286 c) \u2192 (c\u2208 b) :=\nbegin\n  intros a_1 a_2,\n  apply (@filter_principal_elim \u03b1 a b),\n  {\n    apply a_1,\n  },\n  apply a_2,\nend\n\nlemma filter_principal_elim3 {\u03b1:Type*} (a b:set \u03b1):\n  b \u2208 filter.principal  a \u2192 (a\u2286 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}} \u2293\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    (\u03b1:Type*) (A B:set \u03b1):\n    (filter.principal A \u2293 filter.principal B = filter.principal (A\u2229B)) :=\nbegin\n  simp,\nend\n\n\nlemma principal_inf_sets2 {\u03b1:Type*} [semilattice_sup_bot \u03b1] (b c:\u03b1):\n   filter.principal {d:\u03b1 |b \u2264 d} \u2293 filter.principal {d: \u03b1 |c \u2264 d}\n   = filter.principal {d:\u03b1 |(b \u2294 c) \u2264 d} :=\nbegin\n  have A1:{d:\u03b1 |b \u2264 d} \u2229 {d:\u03b1 |c \u2264 d} = {d: \u03b1 |(b \u2294 c) \u2264 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 \u2190 A1,\n  apply principal_inf,\nend\n\n-- Use apply principal_inf_sets2,\nlemma principal_inf_sets {\u03b1:Type*} [decidable_eq \u03b1] (b c:finset \u03b1):\n   filter.principal {d:finset \u03b1 |b \u2264 d} \u2293 filter.principal {d:finset \u03b1 |c \u2264 d}\n   = filter.principal {d:finset \u03b1 |(b \u222a c) \u2264 d} :=\nbegin\n  apply principal_inf_sets2,\nend\n\n\n\n-- src/data/set/lattice.lean\nlemma set_Inf_def (\u03b1:Type*) (S:set (set \u03b1)):\n(Inf S) = {a | \u2200 t \u2208 S, a \u2208 t } :=\nbegin\n  refl,\nend\n\n\nlemma set_Inf_intro (\u03b1:Type*) (S:set (set \u03b1)) (x:\u03b1):\n   (\u2200 X\u2208 S, x\u2208 X) \u2192 x\u2208 Inf S :=\nbegin\n  intros a,\n  rw set_Inf_def,\n  simp,\n  exact a,\nend\n\n\nlemma set_Inf_range_intro (\u03b1 \u03b2:Type*) (f:\u03b1 \u2192 set (\u03b2)) (x:\u03b2):\n   (\u2200 y:\u03b1, x\u2208 f y) \u2192  x\u2208 Inf (set.range  (\u03bb (a : \u03b1), 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 \u2190 H_h,\n  apply a,\nend\n\nlemma glb_intro {\u03b1 \u03b2:Type*} (f:\u03b1 \u2192 set (\u03b2)) (x:\u03b2):\n(\u2200 a:\u03b1, x\u2208 f a) \u2192 x \u2208  \u2a05 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 (\u03b1:Type*) (s : set (filter \u03b1)) (a : filter \u03b1) :\n    (\u2200 (b : filter \u03b1 ), b \u2208 s \u2192 a \u2264 b) \u2192 a \u2264 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 (\u03b1 : Type*)  (s : set (filter \u03b1)) (a : filter \u03b1) :\n  a \u2208 s \u2192 complete_lattice.Inf s \u2264 a :=\nbegin\n  intros a_1,\n  apply (complete_lattice.Inf_le s),\n  assumption,\nend\n\nlemma mem_Inf_intro {\u03b1 : Type*}  {s : set (filter \u03b1)} {a : filter \u03b1} {t:set \u03b1}:\n  t \u2208 a \u2192 a \u2208 s \u2192 t\u2208  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 (\u03b1:Type*) (S : set (filter \u03b1)):set (set \u03b1) :=\n  {s:set \u03b1 | \u2203 f\u2208 S, s\u2208 f}\n\nlemma inf_filter_sets_of_superset2 (\u03b1:Type*) (S : set (filter \u03b1)) (s t:set \u03b1):\n  s\u2208 (inf_filter_sets_def \u03b1 S) \u2192 s\u2286 t \u2192 t\u2208 (inf_filter_sets_def \u03b1 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 (\u03b1:Type*) (S : set (filter \u03b1))\n  (H:\u2200 a b:filter \u03b1, a\u2208 S\u2192 b\u2208 S\u2192 a\u2293b\u2208 S)  (s t:set \u03b1):\n  s\u2208 (inf_filter_sets_def \u03b1 S) \u2192\n  t\u2208 (inf_filter_sets_def \u03b1 S) \u2192\n  s \u2229 t \u2208 (inf_filter_sets_def \u03b1 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\u2293x_1)),\n  split,\n  {\n    apply H;assumption,\n  },\n  {\n     simp only [filter.mem_inf_sets, \u2190 filter_mem_def],\n     have B1:(s \u2229 t) \u2208 x \u2293 x_1 \u2194 \u2203t\u2081\u2208x, \u2203t\u2082\u2208x_1, t\u2081 \u2229 t\u2082 \u2286 (s \u2229 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 (\u03b1:Type*) (S : set (filter \u03b1)) (b:filter \u03b1):\n  (b\u2208 S) \u2192 set.univ \u2208 (inf_filter_sets_def \u03b1 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 (\u03b1:Type*) (S : set (filter \u03b1)) (b:filter \u03b1) (H:b\u2208 S)\n  (H2:\u2200 a b:filter \u03b1, a\u2208 S\u2192 b\u2208 S\u2192 a\u2293b\u2208 S):filter \u03b1 := {\n  sets := inf_filter_sets_def \u03b1 S,\n  sets_of_superset := inf_filter_sets_of_superset2 \u03b1 S,\n  univ_sets := (inf_filter_univ_sets2 \u03b1 S b H),\n  inter_sets := inf_filter_sets_inter_sets2 \u03b1 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 (\u03b1:Type*) (S : set (filter \u03b1))\n(b:filter \u03b1) (H:b\u2208 S)\n  (H2:\u2200 a b:filter \u03b1, a\u2208 S\u2192 b\u2208 S\u2192 a\u2293b\u2208 S) (s:set \u03b1):\n(s \u2208 Inf S)\u2194 (\u2203 t\u2208 S, s\u2208 t) :=\nbegin\n  have A1:(inf_filter_def2 \u03b1  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 \u2190 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 {\u03b1:Type} {S : set (filter \u03b1)} {l : filter \u03b1}\n  (h : \u2200 {s}, s \u2208 l \u2194 \u2203 f \u2208 S, s \u2208 f) : l = Inf S :=\nle_antisymm (le_Inf $ \u03bb f hf s hs, h.2 \u27e8f, hf, hs\u27e9)\n  (\u03bb s hs, let \u27e8f, hf, hs\u27e9 := h.1 hs in (Inf_le hf : Inf S \u2264 f) hs)\n\n\n--def filter_from_element (\u03b1:Type) (a:\u03b1):filter \u03b1  := filter.principal (\u03bb 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 \u2115)) (s:set (finset \u2115)):\n  (s\u2208 F)\u2192 (F \u2264 filter.principal s) :=\nbegin\n  intros a,\n  apply (filter_le_intro2 (finset \u2115) 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\u222aT) (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\u2208 nhds x)\u2194 (\u2203 u:set nnreal, (u\u2286 b) \u2227 is_open u \u2227 x\u2208 u) :=\n\n-/\nlemma mem_nhds_elim_real_rat (b:set real) (x:real): b\u2208 nhds x \u2192\n(\u2203 p q:\u211a, (p < q) \u2227 ((set.Ioo p q:set \u211d) \u2286 b) \u2227 ((p:\u211d) < x) \u2227 (x < (q:\u211d)))\n  :=\nbegin\n  let rat_basis := (\u22c3 (a b : \u211a) (h : a < b), {set.Ioo \u2191a \u2191b}),\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 \u2208 nhds x \u2194 \u2203 (t : set real) (H : t \u2208 rat_basis), x \u2208 t \u2227 t \u2286 b),\n  {\n    apply @topological_space.mem_nhds_of_is_topological_basis,\n    apply A1,\n  },\n  have A3: (\u2203 (t : set real) (H : t \u2208 rat_basis), x \u2208 t \u2227 t \u2286 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 {\u03b1 \u03b2:Type*} [T\u03b1:topological_space \u03b1] \n  [T\u03b2:topological_space \u03b2]\n  {f:\u03b1 \u2192 \u03b2} {S:set (set \u03b2)}:(inducing f) \u2192 \n  (topological_space.is_topological_basis S) \u2192\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\u2081 A3 t\u2082 A4 x A5,\n    cases A3 with u\u2081 A3,\n    cases A4 with u\u2082 A4,\n    cases A5 with A6 A7,\n    cases A3 with A8 A9,\n    cases A4 with A10 A11,\n    subst t\u2081,\n    subst t\u2082,\n    simp at A6,\n    simp at A7,\n    have A12:f x \u2208 u\u2081 \u2229 u\u2082,\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\u2081 A8 u\u2082 A10 (f x) A12,\n    cases A13 with u\u2083 A13,\n    cases A13 with A14 A15,\n    cases A15 with A16 A17,\n    apply exists.intro (f \u207b\u00b9' u\u2083),\n    have A18:f \u207b\u00b9' u\u2083 \u2208 set.preimage f '' S,\n    {\n      simp,\n      apply exists.intro u\u2083,\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 \u2208 \u22c3\u2080 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 \u2208 nhds x \u2194 \n   (\u2203 C\u2208 nhds (x.val),set.preimage (@coe nnreal real _) C\u2286 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\u2208 nhds x \u2192\n(\u2203 p q:\u211d, (p < q) \u2227 ((set.Ioo p q) \u2286 b) \u2227 (p < x) \u2227 (x < q))\n  :=\nbegin\n  intros a,\n  have A1:(\u2203 prat qrat:\u211a, (prat < qrat) \u2227 ((set.Ioo prat qrat:set \u211d) \u2286 b) \u2227 ((prat:\u211d) < x) \u2227 (x < (qrat:\u211d))),\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:\u211d),\n  apply exists.intro (A1_h_w:\u211d),\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\u2208 nhds x \u2192\n(\u2203 p q:\u211d, (p < q) \u2227 \n          (set.preimage  (@coe nnreal real _) (set.Ioo p q) \u2286 b) \u2227 \n          (p < \u2191x) \u2227 (\u2191x < 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:\u211d}:(p < 0) \u2192 (0 \u2264 q) \u2192\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 \u2190 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 \u2190 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:\u211d}:(0 \u2264 p) \u2192 (p < q) \u2192\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 \u2264 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 \u2190 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 \u2190 nnreal.coe_of_real p,\n      rw nnreal.coe_lt_coe,\n      apply A4,\n      apply A1,\n    },\n    {\n      rw \u2190 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 \u2260 0 \u2192  b\u2208 nhds x \u2192\n(\u2203 p q:nnreal, (p < q) \u2227 \n          ((set.Ioo p q) \u2286 b) \u2227 \n          (p < x) \u2227 (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 \u2228 0 \u2264 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 \u2190 A12,\n    rw nnreal.coe_lt_coe,\n    apply A11,\n  },\n  have A15:0 \u2264 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 \u2190 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 \u2190 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) \u2286 \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 \u2190 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 \u2190 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\u2208 nhds x \u2192\n(\u2203 r>0, (set.Ioo (x-r) (x+r)) \u2286 b)\n  :=\nbegin\n  intros a,\n  have A1:(\u2203 p q:\u211d, (p < q) \u2227 ((set.Ioo p q) \u2286 b) \u2227 (p < x) \u2227 (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) \u2286 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 \u2264 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 \u2264 b \u2192 a - c \u2264 b - c :=\nbegin\n  intro A1,\n  have A2:(c \u2264 a) \u2228 (a \u2264 c) := le_total c a,\n  cases A2,\n  {\n    rw \u2190 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 \u2264 x \u2192 r \u2264 x - p \u2192 p \u2264 x - r :=\nbegin\n  intros A1 A2,\n  rw \u2190 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 \u2264 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\u22600\nlemma mem_nhds_elim_nnreal_bound (b:set nnreal) (x:nnreal):x \u2260 0 \u2192  b\u2208 nhds x \u2192\n(\u2203 r>0, (set.Ioo (x-r) (x+r)) \u2286 b)\n  :=\nbegin\n  intros AX a,\n  have A1:(\u2203 p q:nnreal, (p < q) \u2227 ((set.Ioo p q) \u2286 b) \u2227 (p < x) \u2227 (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) \u2286 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 \u2190 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 {\u03b1:Type*} [preorder \u03b1]:\nfilter.at_top = \u2a05 a:\u03b1, filter.principal {b | a \u2264 b} := rfl\n\nlemma filter_at_top_def (\u03b1:Type*):\n  (@filter.at_top (finset \u03b1) _)=  \u2a05 (a:(finset \u03b1)),\n   filter.principal  {b:finset \u03b1 | a\u2286  b} := rfl\n\n--This is (roughly) filter.at_top_mem_sets\nlemma mem_filter_at_top_def2 {\u03b1:Type*}  [SL:semilattice_sup_bot \u03b1] {S:set \u03b1}:\n  (S\u2208 @filter.at_top \u03b1 _)\u2194\n  (\u2203 a:\u03b1, {b:\u03b1|a \u2264 b}\u2286 S) :=\nbegin\n  have B1:order_bot \u03b1 := semilattice_sup_bot.to_order_bot \u03b1,\n  have B2:has_bot \u03b1 := order_bot.to_has_bot \u03b1,\n  rw filter_at_top_def3,\n  unfold infi,\n  have A1:(\u2200 X Y:filter \u03b1,\n  X \u2208 (set.range (\u03bb (a :\u03b1), filter.principal {b : \u03b1 | a \u2264 b})) \u2192\n  Y \u2208 (set.range (\u03bb (a : \u03b1), filter.principal {b : \u03b1 | a \u2264 b})) \u2192\n  X \u2293 Y \u2208 (set.range (\u03bb (a : \u03b1), filter.principal {b : \u03b1 | a \u2264 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 \u2294 a_1_w),\n    symmetry,\n    apply principal_inf_sets2,\n  },\n  have A2:filter.principal {b : \u03b1 | \u22a5 \u2264  b} \u2208\n   (set.range (\u03bb (a : \u03b1), filter.principal {b : \u03b1 | a \u2264 b})),\n  {\n    rw set.mem_range,\n    apply exists.intro \u22a5,\n    refl,\n  },\n  have A3:(S \u2208 Inf (set.range (\u03bb (a : \u03b1), filter.principal {b :  \u03b1 | a \u2264 b})))\u2194\n          (\u2203 t\u2208 (set.range (\u03bb (a : \u03b1), filter.principal {b : \u03b1 | a \u2264 b})), S\u2208 t),\n  {\n    apply (@Inf_filter_def (\u03b1)\n          (set.range (\u03bb (a : \u03b1), filter.principal {b : \u03b1 | a \u2264 b}))\n          (filter.principal {b : \u03b1 | \u22a5 \u2264 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 : \u03b1 | a_w \u2264 b}),\n    have A4:filter.principal {b : \u03b1 | a_w \u2264 b} \u2208\n        set.range (\u03bb (a : \u03b1), filter.principal {b : \u03b1 | a \u2264 b}),\n    {\n      simp,\n    },\n    apply exists.intro A4,\n    apply a_h,\n  }\nend\n\n\nlemma filter_at_top_def2 (\u03b1:Type*) [decidable_eq \u03b1] (S:set (finset \u03b1)):\n  (S\u2208 @filter.at_top (finset \u03b1) _)\u2194\n  (\u2203 a:finset \u03b1, {b:finset \u03b1|a \u2264 b}\u2286 S) :=\nbegin\n  apply mem_filter_at_top_def2,\nend\n\n\n--See alternatives below.\nlemma filter_at_top_intro {\u03b1:Type*} (b:set (finset \u03b1)) (c:finset \u03b1):\n  (b\u2208 (filter.principal {d:finset \u03b1 |c \u2264 d} )) \u2192\n  (b \u2208 (@filter.at_top (finset \u03b1) _)) :=\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 \u03b1 |c \u2264 d} ) \u2208\n    set.range (\u03bb (a : finset \u03b1), filter.principal {b : finset \u03b1 | a \u2286 b}),\n    {\n      unfold set.range,\n      simp,\n    },\n    apply A1,\n  },\n  {\n    assumption,\n  }\nend\n\nlemma filter_at_top_elim {\u03b1:Type*} [decidable_eq \u03b1] {S:set (finset \u03b1)} :\n  (S \u2208 (@filter.at_top (finset \u03b1) _))\u2192\n  (\u2203 a:(finset \u03b1), {b:finset \u03b1|a \u2264 b}\u2286 S) :=\nbegin\n  apply (filter_at_top_def2 \u03b1 S).mp,\nend\n\nlemma filter_at_top_intro2 {\u03b1:Type*} (b:set (finset \u03b1)) (c:finset \u03b1):\n  ({d:finset \u03b1 |c \u2264 d} \u2286 b) \u2192\n  (b \u2208 (@filter.at_top (finset \u03b1) _)) :=\nbegin\n  intros a,\n  have A1:b\u2208 filter.principal {d:finset \u03b1 |c \u2264 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 (\u03b1 \u03b2:Type) (B:filter \u03b2) (S T:set \u03b1) (f:\u03b2  \u2192 \u03b1):\n  (S\u2286 T)\u2192 ({x:\u03b2 |f x \u2208 S}\u2208 B) \u2192 ({x:\u03b2 |f x \u2208 T}\u2208 B) :=\nbegin\n  intros a a_1,\n  have A1:{x:\u03b2 |f x \u2208 S} \u2286 {x:\u03b2 |f x \u2208 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  {\u03b1 \u03b2:Type*} (c:finset \u03b1) (S:set \u03b2) (f:finset \u03b1 \u2192 \u03b2):\n  (\u2200 d \u2265 c, f d \u2208 S) \u2192\n  ({x:finset \u03b1|f x\u2208 S} \u2208 (@filter.at_top (finset \u03b1) _)) :=\nbegin\n  intros a,\n  have A1:({d:finset \u03b1 |c \u2264 d} \u2286 {x:finset \u03b1|f x\u2208 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 {\u03b1:Type*} [P:semilattice_sup_bot \u03b1] {S:set \u03b1} {x:\u03b1}:\n  {y|x\u2264 y}\u2286 S \u2192\n  S\u2208 (@filter.at_top \u03b1 _) :=\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 {\u03b1:Type*} [P:semilattice_sup_bot \u03b1] {S:set \u03b1} :\n  (S \u2208 (@filter.at_top \u03b1 _))\u2192\n  (\u2203 a:\u03b1, {b:\u03b1|a \u2264 b}\u2286 S) :=\nbegin\n  apply (mem_filter_at_top_def2).mp,\nend\n\nlemma in_own_Ioo {x \u03b5:\u211d}:(0 < \u03b5)\u2192 x \u2208 set.Ioo (x -\u03b5) (x + \u03b5) :=\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 \u2208 {s : set nnreal | x \u2208 s \u2227 is_open s}):\n (set.range (\u03bb (H : s \u2208 {s : set nnreal | x \u2208 s \u2227 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 (\u03b1:Type*):\n  (@Inf (filter \u03b1) _ \u2205) = \u22a4 :=\nbegin\n  simp,\nend\n\nlemma set_in_lattice_infih (\u03b1:Type*) (s:set \u03b1) (S:set (set \u03b1))\n  (H2 : s \u2209 S):\n (set.range (\u03bb (H : s \u2208 S), filter.principal s)) = \u2205\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 (\u03b1:Type*) (s:set \u03b1) (S:set (set \u03b1))\n  (H2 : s \u2208 S):\n (set.range (\u03bb (H : s \u2208 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 (\u03b1:Type*) (S:set (filter \u03b1)):lower_bounds S = lower_bounds (S \u222a {\u22a4}) :=\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 (\u03b1:Type*) (S:set (filter \u03b1)):\nInf (S\u222a {\u22a4}) = Inf S :=\nbegin\n  have A2:is_glb S (Inf S),\n  {\n    apply is_glb_Inf,\n  },\n  have A3:is_glb (S\u222a {\u22a4}) (Inf S),\n  {\n    cases A2,\n    split,\n    {\n      rw \u2190 lower_bounds_top,\n      exact A2_left,\n    },\n    {\n      rw \u2190 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 (\u03b1:Type*) (S:set (set \u03b1)):\n(\u2a05 (s\u2208 S), (filter.principal s)) = Inf  (set.image (filter.principal) S) :=\nbegin\n  unfold infi,\n  rw \u2190 (@set.image_union_image_compl_eq_range (set \u03b1) _ S),\n  have A1:(\u03bb (s : set \u03b1), Inf (set.range (\u03bb (H : s \u2208 S), filter.principal s))) '' (S)\u1d9c =\n    (\u03bb (s : set \u03b1), \u22a4) '' S\u1d9c,\n  {\n    rw set.image_congr,\n    intros,\n    have A1AA:set.range (\u03bb (H : a \u2208 S), filter.principal a) = \u2205,\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:(\u03bb (s : set \u03b1), Inf (set.range (\u03bb (H : s \u2208 S), filter.principal s))) '' (S) =\n    (\u03bb (s : set \u03b1), filter.principal s) '' S,\n  {\n    rw set.image_congr,\n    intros,\n    have A2A:set.range (\u03bb (H : a \u2208 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\u1d9c = \u2205)\u2228 set.nonempty S\u1d9c,\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:\u2200 k:filter \u03b1,(\u03bb (s : set \u03b1), k) '' S\u1d9c = {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:(\u03bb (s : set \u03b1), \u22a4) '' S\u1d9c = {\u22a4},\n    {\n      apply (A4A \u22a4),\n    },\n    rw A4B,\n    apply Inf_union_top,\n  }\nend\n\n\nlemma open_nhds_inter\n    (\u03b1:Type*) [topological_space \u03b1] (x:\u03b1) (A B:set \u03b1):\n    (A\u2208 {s:set \u03b1|x\u2208 s\u2227 is_open s}) \u2192\n    (B\u2208 {s:set \u03b1|x\u2208 s\u2227 is_open s}) \u2192\n    ((A\u2229 B) \u2208 {s:set \u03b1|x\u2208 s\u2227 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 (\u03b1:Type*) [topological_space \u03b1] (x:\u03b1):\nnhds x = Inf  (set.image (filter.principal) {S:set \u03b1|x\u2208 S \u2227 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\u2208 U \u2192\nis_open U \u2192\nU \u2286 b \u2192\nb\u2208 nhds x :=\nbegin\n  intros A1 A2 A3,\n  rw nhds_def1,\n  have A4:b\u2208 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\u2208 set.Ioo y z \u2192\nset.Ioo y z \u2286 b \u2192\nb\u2208 nhds x :=\nbegin\n  intros A1 A2,\n  apply mem_nhds_intro_real2 A1 _ A2,\n  apply @is_open_Ioo \u211d _ _ _ y z,\nend\n\n\nlemma mem_nhds_filter_principal_intro (\u03b1:Type*) [topological_space \u03b1] (x:\u03b1) (V:set \u03b1):\n  V\u2208 {S:set \u03b1|x\u2208 S \u2227 is_open S}\u2192 filter.principal V \u2208 (set.image (filter.principal) {S:set \u03b1|x\u2208 S \u2227 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 (\u03b1:Type*) [topological_space \u03b1] (x:\u03b1) (V:set \u03b1):\n  filter.principal V \u2208 (set.image (filter.principal) {S:set \u03b1|x\u2208 S \u2227 is_open S}) \u2192\n  V\u2208 {S:set \u03b1|x\u2208 S \u2227 is_open S} :=\nbegin\n  intros a,\n  simp at a,\n  apply a,\nend\n\n\nlemma mem_nhds_filter_principal_elim2 (\u03b1:Type*) [topological_space \u03b1] (x:\u03b1) (Z:filter \u03b1):\n  Z \u2208 (set.image (filter.principal) {S:set \u03b1|x\u2208 S \u2227 is_open S}) \u2192\n  (\u2203 V:set \u03b1, V\u2208 {S:set \u03b1|x\u2208 S \u2227 is_open S} \u2227 filter.principal V = Z) :=\nbegin\n  intros a,\n  simp at a,\n  apply a,\nend\n\n\nlemma has_open_neighborhood (\u03b1:Type*) [topological_space \u03b1] (x:\u03b1):\u2203 U:set \u03b1, x\u2208 U \u2227 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 (\u03b1:Type*) [topological_space \u03b1] (x:\u03b1) (S:set \u03b1):\nS \u2208 nhds x \u2194\n(\u2203 u:set \u03b1, (u\u2286 S) \u2227 is_open u \u2227 (x\u2208 u)) :=\nbegin\n  rw nhds_def1,\n  have H:\u2203 U:set \u03b1, x\u2208 U \u2227 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:(\u2203 V:set \u03b1, V\u2208 {S:set \u03b1|x\u2208 S \u2227 is_open S} \u2227 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:(\u2203 V:set \u03b1, V\u2208 {S:set \u03b1|x\u2208 S \u2227 is_open S} \u2227 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 \u2229 A2_w) \u2208 {s:set \u03b1|x\u2208 s\u2227 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:(\u2203 V:set \u03b1, V\u2208 {S:set \u03b1|x\u2208 S \u2227 is_open S} \u2227 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 \u2208 filter.principal '' {S : set \u03b1 | x \u2208 S \u2227 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 (\u03b1:Type*) [topological_space \u03b1] (x:\u03b1) (S:set \u03b1):\nS \u2208 nhds x \u2192 x\u2208 S :=\nbegin\n  intros a,\n   have A1:(\u2203 u:set \u03b1, (u\u2286 S) \u2227 is_open u \u2227 (x\u2208 u)),\n   {\n     apply (nhds_def2 \u03b1 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 \u03b5:\u211d}:(0 < \u03b5)\u2192 set.Ioo (x -\u03b5) (x + \u03b5) \u2208 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} {\u03b5:nnreal}:x \u2260 0 \u2192 \u03b5 >0 \u2192 set.Ioo (x - \u03b5) (x + \u03b5) \u2208 nhds x :=\nbegin\n  intros A1 A2,\n  rw @mem_nhds_sets_iff,\n--  have A3:(\u03b5\u2264x) \u2228 (x < \u03b5) := le_or_lt \u03b5 x,\n  apply exists.intro (set.Ioo (x - \u03b5) (x + \u03b5)),\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 \u2260 0\nlemma set_Iio_in_nhds_of_lt {x y:nnreal}:x \u2260 0 \u2192 x < y \u2192 set.Iio y \u2208 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\u00f6lzl, Patrick Massot, S\u00e9bastien Gou\u00ebzel, 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 `\u2243\u209c`.\n\n# Main definitions\n\n* `homeomorph \u03b1 \u03b2`: The type of homeomorphisms from `\u03b1` to `\u03b2`.\n  This type can be denoted using the following notation: `\u03b1 \u2243\u209c \u03b2`.\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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\n\n/-- Homeomorphism between `\u03b1` and `\u03b2`, also called topological isomorphism -/\n@[nolint has_inhabited_instance] -- not all spaces are homeomorphic to each other\nstructure homeomorph (\u03b1 : Type*) (\u03b2 : Type*) [topological_space \u03b1] [topological_space \u03b2]\n  extends \u03b1 \u2243 \u03b2 :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\ninfix ` \u2243\u209c `:25 := homeomorph\n\nnamespace homeomorph\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4]\n\ninstance : has_coe_to_fun (\u03b1 \u2243\u209c \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := \u27e8\u03bbe, e.to_equiv\u27e9\n\n@[simp] lemma homeomorph_mk_coe (a : equiv \u03b1 \u03b2) (b c) :\n  ((homeomorph.mk a b c) : \u03b1 \u2192 \u03b2) = a :=\nrfl\n\n@[simp] lemma coe_to_equiv (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h.to_equiv = h := rfl\n\n/-- Inverse of a homeomorphism. -/\nprotected def symm (h : \u03b1 \u2243\u209c \u03b2) : \u03b2 \u2243\u209c \u03b1 :=\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 : \u03b1 \u2243\u209c \u03b2) : \u03b1 \u2192 \u03b2 := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : \u03b1 \u2243\u209c \u03b2) : \u03b2 \u2192 \u03b1 := h.symm\n\ninitialize_simps_projections homeomorph\n  (to_equiv_to_fun \u2192 apply, to_equiv_inv_fun \u2192 symm_apply, -to_equiv)\n\nlemma to_equiv_injective : function.injective (to_equiv : \u03b1 \u2243\u209c \u03b2 \u2192 \u03b1 \u2243 \u03b2)\n| \u27e8e, h\u2081, h\u2082\u27e9 \u27e8e', h\u2081', h\u2082'\u27e9 rfl := rfl\n\n@[ext] lemma ext {h h' : \u03b1 \u2243\u209c \u03b2} (H : \u2200 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 (\u03b1 : Type*) [topological_space \u03b1] : \u03b1 \u2243\u209c \u03b1 :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  to_equiv := equiv.refl \u03b1 }\n\n/-- Composition of two homeomorphisms. -/\nprotected def trans (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b2 \u2243\u209c \u03b3) : \u03b1 \u2243\u209c \u03b3 :=\n{ continuous_to_fun  := h\u2082.continuous_to_fun.comp h\u2081.continuous_to_fun,\n  continuous_inv_fun := h\u2081.continuous_inv_fun.comp h\u2082.continuous_inv_fun,\n  to_equiv := equiv.trans h\u2081.to_equiv h\u2082.to_equiv }\n\n@[simp] lemma trans_apply (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b2 \u2243\u209c \u03b3) (a : \u03b1) : h\u2081.trans h\u2082 a = h\u2082 (h\u2081 a) := rfl\n\n@[simp] lemma homeomorph_mk_coe_symm (a : equiv \u03b1 \u03b2) (b c) :\n  ((homeomorph.mk a b c).symm : \u03b2 \u2192 \u03b1) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (homeomorph.refl \u03b1).symm = homeomorph.refl \u03b1 := rfl\n\n@[continuity]\nprotected lemma continuous (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : continuous (h.symm) := h.continuous_inv_fun\n\n@[simp] lemma apply_symm_apply (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b2) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\nprotected lemma bijective (h : \u03b1 \u2243\u209c \u03b2) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : \u03b1 \u2243\u209c \u03b2) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) (g : \u03b2 \u2192 \u03b1) (hg : function.right_inverse g f) : \u03b1 \u2243\u209c \u03b2 :=\nhave g = f.symm, from funext (\u03bb 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 : \u03b1 \u2243\u209c \u03b2) : \u21d1h.symm \u2218 \u21d1h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h \u2218 \u21d1h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : \u03b1 \u2243\u209c \u03b2) : range h = univ :=\nh.surjective.range_eq\n\nlemma image_symm (h : \u03b1 \u2243\u209c \u03b2) : image h.symm = preimage h :=\nfunext h.symm.to_equiv.image_eq_preimage\n\nlemma preimage_symm (h : \u03b1 \u2243\u209c \u03b2) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h '' (h \u207b\u00b9' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h \u207b\u00b9' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma inducing (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : topological_space.induced h \u2039_\u203a = \u2039_\u203a := h.inducing.1.symm\n\nprotected lemma quotient_map (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : topological_space.coinduced h \u2039_\u203a = \u2039_\u203a :=\nh.quotient_map.2.symm\n\nprotected lemma embedding (h : \u03b1 \u2243\u209c \u03b2) : embedding h :=\n\u27e8h.inducing, h.injective\u27e9\n\n/-- Homeomorphism given an embedding. -/\nnoncomputable def of_embedding (f : \u03b1 \u2192 \u03b2) (hf : embedding f) : \u03b1 \u2243\u209c (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 \u03b2]\n  (h : \u03b1 \u2243\u209c \u03b2) :\n  topological_space.second_countable_topology \u03b1 :=\nh.inducing.second_countable_topology\n\nlemma compact_image {s : set \u03b1} (h : \u03b1 \u2243\u209c \u03b2) : is_compact (h '' s) \u2194 is_compact s :=\nh.embedding.is_compact_iff_is_compact_image.symm\n\nlemma compact_preimage {s : set \u03b2} (h : \u03b1 \u2243\u209c \u03b2) : is_compact (h \u207b\u00b9' s) \u2194 is_compact s :=\nby rw \u2190 image_symm; exact h.symm.compact_image\n\nlemma compact_space [compact_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : compact_space \u03b2 :=\n{ compact_univ := by { rw [\u2190 image_univ_of_surjective h.surjective, h.compact_image],\n    apply compact_space.compact_univ } }\n\nlemma t2_space [t2_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : t2_space \u03b2 :=\n{ t2 :=\n  begin\n    intros x y hxy,\n    obtain \u27e8u, v, hu, hv, hxu, hyv, huv\u27e9 := t2_separation (h.symm.injective.ne hxy),\n    refine \u27e8h.symm \u207b\u00b9' u, h.symm \u207b\u00b9' v,\n      h.symm.continuous.is_open_preimage _ hu,\n      h.symm.continuous.is_open_preimage _ hv,\n      hxu, hyv, _\u27e9,\n    rw [\u2190 preimage_inter, huv, preimage_empty],\n  end }\n\nprotected lemma dense_embedding (h : \u03b1 \u2243\u209c \u03b2) : dense_embedding h :=\n{ dense   := h.surjective.dense_range,\n  .. h.embedding }\n\n@[simp] lemma is_open_preimage (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b2} : is_open (h \u207b\u00b9' s) \u2194 is_open s :=\nh.quotient_map.is_open_preimage\n\n@[simp] lemma is_open_image (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} : is_open (h '' s) \u2194 is_open s :=\nby rw [\u2190 preimage_symm, is_open_preimage]\n\n@[simp] lemma is_closed_preimage (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b2} : is_closed (h \u207b\u00b9' s) \u2194 is_closed s :=\nby simp only [\u2190 is_open_compl_iff, \u2190 preimage_compl, is_open_preimage]\n\n@[simp] lemma is_closed_image (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} : is_closed (h '' s) \u2194 is_closed s :=\nby rw [\u2190 preimage_symm, is_closed_preimage]\n\nlemma preimage_closure (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h \u207b\u00b9' (closure s) = closure (h \u207b\u00b9' s) :=\nby rw [h.embedding.closure_eq_preimage_closure_image, h.image_preimage]\n\nlemma image_closure (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h '' (closure s) = closure (h '' s) :=\nby rw [\u2190 preimage_symm, preimage_closure]\n\nprotected lemma is_open_map (h : \u03b1 \u2243\u209c \u03b2) : is_open_map h := \u03bb s, h.is_open_image.2\n\nprotected lemma is_closed_map (h : \u03b1 \u2243\u209c \u03b2) : is_closed_map h := \u03bb s, h.is_closed_image.2\n\nprotected lemma open_embedding (h : \u03b1 \u2243\u209c \u03b2) : open_embedding h :=\nopen_embedding_of_embedding_open h.embedding h.is_open_map\n\nprotected lemma closed_embedding (h : \u03b1 \u2243\u209c \u03b2) : closed_embedding h :=\nclosed_embedding_of_embedding_closed h.embedding h.is_closed_map\n\n@[simp] lemma map_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : map h (\ud835\udcdd x) = \ud835\udcdd (h x) :=\nh.embedding.map_nhds_of_mem _ (by simp)\n\nlemma symm_map_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : map h.symm (\ud835\udcdd (h x)) = \ud835\udcdd x :=\nby rw [h.symm.map_nhds_eq, h.symm_apply_apply]\n\nlemma nhds_eq_comap (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : \ud835\udcdd x = comap h (\ud835\udcdd (h x)) :=\nh.embedding.to_inducing.nhds_eq_comap x\n\n@[simp] lemma comap_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (y : \u03b2) : comap h (\ud835\udcdd y) = \ud835\udcdd (h.symm y) :=\nby rw [h.nhds_eq_comap, h.apply_symm_apply]\n\n/-- If an bijective map `e : \u03b1 \u2243 \u03b2` is continuous and open, then it is a homeomorphism. -/\ndef homeomorph_of_continuous_open (e : \u03b1 \u2243 \u03b2) (h\u2081 : continuous e) (h\u2082 : is_open_map e) :\n  \u03b1 \u2243\u209c \u03b2 :=\n{ continuous_to_fun := h\u2081,\n  continuous_inv_fun := begin\n    rw continuous_def,\n    intros s hs,\n    convert \u2190 h\u2082 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 : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (s : set \u03b3) :\n  continuous_on (h \u2218 f) s \u2194 continuous_on f s :=\nh.inducing.continuous_on_iff.symm\n\n@[simp] lemma comp_continuous_iff (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b3 \u2192 \u03b1} :\n  continuous (h \u2218 f) \u2194 continuous f :=\nh.inducing.continuous_iff.symm\n\n@[simp] lemma comp_continuous_iff' (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b2 \u2192 \u03b3} :\n  continuous (f \u2218 h) \u2194 continuous f :=\nh.quotient_map.continuous_iff.symm\n\nlemma comp_continuous_at_iff (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (x : \u03b3) :\n  continuous_at (h \u2218 f) x \u2194 continuous_at f x :=\nh.inducing.continuous_at_iff.symm\n\nlemma comp_continuous_at_iff' (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b2 \u2192 \u03b3) (x : \u03b1) :\n  continuous_at (f \u2218 h) x \u2194 continuous_at f (h x) :=\nh.inducing.continuous_at_iff' (by simp)\n\nlemma comp_continuous_within_at_iff (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (s : set \u03b3) (x : \u03b3) :\n  continuous_within_at f s x \u2194 continuous_within_at (h \u2218 f) s x :=\nh.inducing.continuous_within_at_iff\n\n@[simp] lemma comp_is_open_map_iff (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b3 \u2192 \u03b1} :\n  is_open_map (h \u2218 f) \u2194 is_open_map f :=\nbegin\n  refine \u27e8_, \u03bb hf, h.is_open_map.comp hf\u27e9,\n  intros hf,\n  rw [\u2190 function.comp.left_id f, \u2190 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 : \u03b1 \u2243\u209c \u03b2) {f : \u03b2 \u2192 \u03b3} :\n  is_open_map (f \u2218 h) \u2194 is_open_map f :=\nbegin\n  refine \u27e8_, \u03bb hf, hf.comp h.is_open_map\u27e9,\n  intros hf,\n  rw [\u2190 function.comp.right_id f, \u2190 h.self_comp_symm, \u2190 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 \u03b1} (h : s = t) : s \u2243\u209c 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\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) : \u03b1 \u2295 \u03b3 \u2243\u209c \u03b2 \u2295 \u03b4 :=\n{ continuous_to_fun  :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h\u2081.continuous)\n      (continuous_inr.comp h\u2082.continuous),\n    ext x, cases x; refl,\n  end,\n  continuous_inv_fun :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h\u2081.symm.continuous)\n      (continuous_inr.comp h\u2082.symm.continuous),\n    ext x, cases x; refl\n  end,\n  to_equiv := h\u2081.to_equiv.sum_congr h\u2082.to_equiv }\n\n/-- Product of two homeomorphisms. -/\ndef prod_congr (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) : \u03b1 \u00d7 \u03b3 \u2243\u209c \u03b2 \u00d7 \u03b4 :=\n{ continuous_to_fun  := (h\u2081.continuous.comp continuous_fst).prod_mk\n    (h\u2082.continuous.comp continuous_snd),\n  continuous_inv_fun := (h\u2081.symm.continuous.comp continuous_fst).prod_mk\n    (h\u2082.symm.continuous.comp continuous_snd),\n  to_equiv := h\u2081.to_equiv.prod_congr h\u2082.to_equiv }\n\n@[simp] lemma prod_congr_symm (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) :\n  (h\u2081.prod_congr h\u2082).symm = h\u2081.symm.prod_congr h\u2082.symm := rfl\n\n@[simp] lemma coe_prod_congr (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) :\n  \u21d1(h\u2081.prod_congr h\u2082) = prod.map h\u2081 h\u2082 := rfl\n\nsection\nvariables (\u03b1 \u03b2 \u03b3)\n\n/-- `\u03b1 \u00d7 \u03b2` is homeomorphic to `\u03b2 \u00d7 \u03b1`. -/\ndef prod_comm : \u03b1 \u00d7 \u03b2 \u2243\u209c \u03b2 \u00d7 \u03b1 :=\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 \u03b1 \u03b2 }\n\n@[simp] lemma prod_comm_symm : (prod_comm \u03b1 \u03b2).symm = prod_comm \u03b2 \u03b1 := rfl\n@[simp] lemma coe_prod_comm : \u21d1(prod_comm \u03b1 \u03b2) = prod.swap := rfl\n\n/-- `(\u03b1 \u00d7 \u03b2) \u00d7 \u03b3` is homeomorphic to `\u03b1 \u00d7 (\u03b2 \u00d7 \u03b3)`. -/\ndef prod_assoc : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243\u209c \u03b1 \u00d7 (\u03b2 \u00d7 \u03b3) :=\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 \u03b1 \u03b2 \u03b3 }\n\n/-- `\u03b1 \u00d7 {*}` is homeomorphic to `\u03b1`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : \u03b1 \u00d7 punit \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.prod_punit \u03b1,\n  continuous_to_fun := continuous_fst,\n  continuous_inv_fun := continuous_id.prod_mk continuous_const }\n\n/-- `{*} \u00d7 \u03b1` is homeomorphic to `\u03b1`. -/\ndef punit_prod : punit \u00d7 \u03b1 \u2243\u209c \u03b1 :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : \u21d1(punit_prod \u03b1) = prod.snd := rfl\n\nend\n\n/-- `ulift \u03b1` is homeomorphic to `\u03b1`. -/\ndef {u v} ulift {\u03b1 : Type u} [topological_space \u03b1] : ulift.{v u} \u03b1 \u2243\u209c \u03b1 :=\n{ continuous_to_fun := continuous_ulift_down,\n  continuous_inv_fun := continuous_ulift_up,\n  to_equiv := equiv.ulift }\n\nsection distrib\n\n/-- `(\u03b1 \u2295 \u03b2) \u00d7 \u03b3` is homeomorphic to `\u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3`. -/\ndef sum_prod_distrib : (\u03b1 \u2295 \u03b2) \u00d7 \u03b3 \u2243\u209c \u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3 :=\nbegin\n  refine (homeomorph.homeomorph_of_continuous_open (equiv.sum_prod_distrib \u03b1 \u03b2 \u03b3).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/-- `\u03b1 \u00d7 (\u03b2 \u2295 \u03b3)` is homeomorphic to `\u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3`. -/\ndef prod_sum_distrib : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243\u209c \u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3 :=\n(prod_comm _ _).trans $\nsum_prod_distrib.trans $\nsum_congr (prod_comm _ _) (prod_comm _ _)\n\nvariables {\u03b9 : Type*} {\u03c3 : \u03b9 \u2192 Type*} [\u03a0 i, topological_space (\u03c3 i)]\n\n/-- `(\u03a3 i, \u03c3 i) \u00d7 \u03b2` is homeomorphic to `\u03a3 i, (\u03c3 i \u00d7 \u03b2)`. -/\ndef sigma_prod_distrib : ((\u03a3 i, \u03c3 i) \u00d7 \u03b2) \u2243\u209c (\u03a3 i, (\u03c3 i \u00d7 \u03b2)) :=\nhomeomorph.symm $\nhomeomorph_of_continuous_open (equiv.sigma_prod_distrib \u03c3 \u03b2).symm\n  (continuous_sigma $ \u03bb i,\n    (continuous_sigma_mk.comp continuous_fst).prod_mk continuous_snd)\n  (is_open_map_sigma $ \u03bb i,\n    (open_embedding_sigma_mk.prod open_embedding_id).is_open_map)\n\nend distrib\n\n/-- If `\u03b9` has a unique element, then `\u03b9 \u2192 \u03b1` is homeomorphic to `\u03b1`. -/\n@[simps { fully_applied := ff }]\ndef fun_unique (\u03b9 \u03b1 : Type*) [unique \u03b9] [topological_space \u03b1] : (\u03b9 \u2192 \u03b1) \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.fun_unique \u03b9 \u03b1,\n  continuous_to_fun := continuous_apply _,\n  continuous_inv_fun := continuous_pi (\u03bb _, continuous_id) }\n\n/-- Homeomorphism between dependent functions `\u03a0 i : fin 2, \u03b1 i` and `\u03b1 0 \u00d7 \u03b1 1`. -/\n@[simps { fully_applied := ff }]\ndef {u} pi_fin_two (\u03b1 : fin 2 \u2192 Type u) [\u03a0 i, topological_space (\u03b1 i)] : (\u03a0 i, \u03b1 i) \u2243\u209c \u03b1 0 \u00d7 \u03b1 1 :=\n{ to_equiv := pi_fin_two_equiv \u03b1,\n  continuous_to_fun := (continuous_apply 0).prod_mk (continuous_apply 1),\n  continuous_inv_fun := continuous_pi $ fin.forall_fin_two.2 \u27e8continuous_fst, continuous_snd\u27e9 }\n\n/-- Homeomorphism between `\u03b1\u00b2 = fin 2 \u2192 \u03b1` and `\u03b1 \u00d7 \u03b1`. -/\n@[simps { fully_applied := ff }] def fin_two_arrow : (fin 2 \u2192 \u03b1) \u2243\u209c \u03b1 \u00d7 \u03b1 :=\n{ to_equiv := fin_two_arrow_equiv \u03b1, ..  pi_fin_two (\u03bb _, \u03b1) }\n\n/--\nA subset of a topological space is homeomorphic to its image under a homeomorphism.\n-/\ndef image (e : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : s \u2243\u209c 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 (\u03bb 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' \u2194 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 _ \u2194 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 \u2192+* 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 [\u2190 mul_one x, \u2190 one_mul y, \u2190 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] \u2243\u2090[S] S[X] :=\n{ inv_fun := (polynomial.eval\u2082_ring_hom (algebra.tensor_product.include_left.to_ring_hom :\n    S \u2192+* tensor_product R S R[X]) (1 \u2297\u209c polynomial.X) : _) ,\n  left_inv := begin\n    intro x,\n    rw [alg_hom.to_fun_eq_coe, \u2190 alg_hom.coe_to_ring_hom, \u2190 ring_hom.comp_apply],\n    conv_rhs { rw \u2190 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\u2082_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\u2082_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 \u2297\u209c[R] 1 = 1 \u2297\u209c[R] polynomial.C y, { simpa only [polynomial.map_C,\n polynomial.eval\u2082_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\u2082_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        \u2190 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\u2082_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\u2082_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, \u2190 alg_hom.coe_to_ring_hom, \u2190 ring_hom.comp_apply],\n    conv_rhs { rw \u2190 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\u2082_ring_hom,\n polynomial.eval\u2082_C,\n polynomial.eval\u2082_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 \u27e8\u27e8_\u27e9, \u27e8pushout_cocone.is_colimit_aux' _ _\u27e9\u27e9,\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.\u03b9.app $ walking_span.zero).to_algebra,\n    let f : S \u2192\u2090[R] T :=\n      { commutes' := ring_hom.congr_fun (s.\u03b9.naturality walking_span.hom.fst), ..s.inl },\n    let g : R' \u2192\u2090[R] T :=\n      { commutes' := ring_hom.congr_fun (s.\u03b9.naturality walking_span.hom.snd), ..s.inr },\n    refine \u27e8(algebra.pushout_desc S' f g $ \u03bb _ _, mul_comm _ _).to_ring_hom, _, _, _\u27e9,\n    { ext, exact algebra.pushout_desc_left S' f g (\u03bb _ _, mul_comm _ _) x },\n    { ext, exact algebra.pushout_desc_right S' f g (\u03bb _ _, mul_comm _ _) x },\n    { intros m hm\u2081 hm\u2082,\n      ext x,\n      apply H.1.induction_on x,\n  { simp only [map_zero] },\n  { intro y, exact (ring_hom.congr_fun hm\u2082 y).trans\n      (algebra.pushout_desc_right S' f g (\u03bb _ _, 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\u2081 y).trans\n      (algebra.pushout_desc_left  S' f g (\u03bb _ _, mul_comm _ _) y).symm },\n  { intros s\u2081 s\u2082 e\u2081 e\u2082, rw [map_add, map_add, e\u2081, e\u2082] } } }\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 \u2208 J X` then its pullback along any `h : Y \u27f6 X` is in `J Y`.\n3. If `S \u2208 J X` and `R` is a sieve on `X`, then provided that the pullback of `R` along any arrow\n   `f : Y \u27f6 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 \u2208 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 : \u03a0 (X : C), set (sieve X))\n(top_mem' : \u2200 X, \u22a4 \u2208 sieves X)\n(pullback_stable' : \u2200 \u2983X Y : C\u2984 \u2983S : sieve X\u2984 (f : Y \u27f6 X), S \u2208 sieves X \u2192 S.pullback f \u2208 sieves Y)\n(transitive' : \u2200 \u2983X\u2984 \u2983S : sieve X\u2984 (hS : S \u2208 sieves X) (R : sieve X),\n              (\u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984, S f \u2192 R.pullback f \u2208 sieves Y) \u2192 R \u2208 sieves X)\n\nnamespace grothendieck_topology\n\ninstance : has_coe_to_fun (grothendieck_topology C) :=\n\u27e8_, \u03bb J, J.sieves\u27e9\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\u2081 J\u2082 : grothendieck_topology C} (h : (J\u2081 : \u03a0 (X : C), set (sieve X)) = J\u2082) : J\u2081 = J\u2082 :=\nby { cases J\u2081, cases J\u2082, congr, apply h }\n\n@[simp] lemma mem_sieves_iff_coe : S \u2208 J.sieves X \u2194 S \u2208 J X := iff.rfl\n\n-- Also known as the maximality axiom.\n@[simp] lemma top_mem (X : C) : \u22a4 \u2208 J X := J.top_mem' X\n-- Also known as the stability axiom.\n@[simp] lemma pullback_stable (f : Y \u27f6 X) (hS : S \u2208 J X) : S.pullback f \u2208 J Y :=\nJ.pullback_stable' f hS\nlemma transitive (hS : S \u2208 J X) (R : sieve X)\n  (h : \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984, S f \u2192 R.pullback f \u2208 J Y) :\n  R \u2208 J X :=\nJ.transitive' hS R h\n\nlemma covering_of_eq_top : S = \u22a4 \u2192 S \u2208 J X := \u03bb h, h.symm \u25b8 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 \u2264 R) (sjx : S \u2208 J X) : R \u2208 J X :=\nbegin\n  apply J.transitive sjx R (\u03bb Y f hf, _),\n  apply covering_of_eq_top,\n  rw [\u2190 top_le_iff, \u2190 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 \u2208 J X) (sj : S \u2208 J X) : R \u2293 S \u2208 J X :=\nbegin\n  apply J.transitive rj _ (\u03bb 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 \u2293 S \u2208 J X \u2194 R \u2208 J X \u2227 S \u2208 J X :=\n\u27e8\u03bb h, \u27e8J.superset_covering inf_le_left h, J.superset_covering inf_le_right h\u27e9,\n \u03bb t, intersection_covering _ t.1 t.2\u27e9\n\n\n\n/--\nThe sieve `S` on `X` `J`-covers an arrow `f` to `X` if `S.pullback f \u2208 J Y`.\nThis definition is an alternate way of presenting a Grothendieck topology.\n-/\ndef covers (S : sieve X) (f : Y \u27f6 X) : Prop := S.pullback f \u2208 J Y\n\nlemma covers_iff (S : sieve X) (f : Y \u27f6 X) : J.covers S f \u2194 S.pullback f \u2208 J Y :=\niff.rfl\n\nlemma covering_iff_covers_id (S : sieve X) : S \u2208 J X \u2194 J.covers S (\ud835\udfd9 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 \u27f6 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 \u226b f` for any `g`. -/\nlemma arrow_stable (f : Y \u27f6 X) (S : sieve X) (h : J.covers S f) {Z : C} (g : Z \u27f6 Y) :\n  J.covers S (g \u226b f) :=\nbegin\n  rw covers_iff at h \u22a2,\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 \u27f6 X) (S R : sieve X) (h : J.covers S f) :\n  (\u2200 {Z : C} (g : Z \u27f6 X), S g \u2192 J.covers R g) \u2192 J.covers R f :=\nbegin\n  intro k,\n  apply J.transitive h,\n  intros Z g hg,\n  rw \u2190 sieve.pullback_comp,\n  apply k (g \u226b f) hg,\nend\n\nlemma arrow_intersect (f : Y \u27f6 X) (S R : sieve X) (hS : J.covers S f) (hR : J.covers R f) :\n  J.covers (S \u2293 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 := \u03bb X, {\u22a4},\n  top_mem' := \u03bb X, rfl,\n  pullback_stable' := \u03bb X Y S f hf,\n  begin\n    rw set.mem_singleton_iff at \u22a2 hf,\n    simp [hf],\n  end,\n  transitive' := \u03bb X S hS R hR,\n  begin\n    rw [set.mem_singleton_iff, \u2190 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 := \u03bb X, set.univ,\n  top_mem' := by simp,\n  pullback_stable' := \u03bb X Y f, by simp,\n  transitive' := by simp }\nvariable {C}\n\nlemma trivial_covering : S \u2208 trivial C X \u2194 S = \u22a4 := set.mem_singleton_iff\n\n/-- See https://stacks.math.columbia.edu/tag/00Z6 -/\ninstance : partial_order (grothendieck_topology C) :=\n{ le := \u03bb J\u2081 J\u2082, (J\u2081 : \u03a0 (X : C), set (sieve X)) \u2264 (J\u2082 : \u03a0 (X : C), set (sieve X)),\n  le_refl := \u03bb J\u2081, le_refl _,\n  le_trans := \u03bb J\u2081 J\u2082 J\u2083 h\u2081\u2082 h\u2082\u2083, le_trans h\u2081\u2082 h\u2082\u2083,\n  le_antisymm := \u03bb J\u2081 J\u2082 h\u2081\u2082 h\u2082\u2081, grothendieck_topology.ext (le_antisymm h\u2081\u2082 h\u2082\u2081) }\n\n/-- See https://stacks.math.columbia.edu/tag/00Z7 -/\ninstance : has_Inf (grothendieck_topology C) :=\n{ Inf := \u03bb T,\n  { sieves := Inf (sieves '' T),\n    top_mem' :=\n    begin\n      rintro X S \u27e8\u27e8_, J, hJ, rfl\u27e9, rfl\u27e9,\n      simp,\n    end,\n    pullback_stable' :=\n    begin\n      rintro X Y S hS f _ \u27e8\u27e8_, J, hJ, rfl\u27e9, rfl\u27e9,\n      apply J.pullback_stable _ (f _ \u27e8\u27e8_, _, hJ, rfl\u27e9, rfl\u27e9),\n    end,\n    transitive' :=\n    begin\n      rintro X S hS R h _ \u27e8\u27e8_, J, hJ, rfl\u27e9, rfl\u27e9,\n      apply J.transitive (hS _ \u27e8\u27e8_, _, hJ, rfl\u27e9, rfl\u27e9) _ (\u03bb Y f hf, h hf _ \u27e8\u27e8_, _, hJ, rfl\u27e9, rfl\u27e9),\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) := \u27e8\u22a4\u27e9\n\n@[simp] lemma trivial_eq_bot : trivial C = \u22a5 := rfl\n@[simp] lemma discrete_eq_top : discrete C = \u22a4 := rfl\n\n@[simp] lemma bot_covering : S \u2208 (\u22a5 : grothendieck_topology C) X \u2194 S = \u22a4 := trivial_covering\n@[simp] lemma top_covering : S \u2208 (\u22a4 : grothendieck_topology C) X := \u27e8\u27e9\n\nlemma bot_covers (S : sieve X) (f : Y \u27f6 X) :\n  (\u22a5 : grothendieck_topology C).covers S f \u2194 S f :=\nby rw [covers_iff, bot_covering, \u2190 sieve.pullback_eq_top_iff_mem]\n\n@[simp] lemma top_covers (S : sieve X) (f : Y \u27f6 X) : (\u22a4 : 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 := \u03bb X S, \u2200 {Y : C} (f : Y \u27f6 X), \u2203 Z (g : Z \u27f6 Y), S (g \u226b f),\n  top_mem' := \u03bb X Y f, \u27e8Y, \ud835\udfd9 Y, \u27e8\u27e9\u27e9,\n  pullback_stable' :=\n  begin\n    intros X Y S h H Z f,\n    rcases H (f \u226b h) with \u27e8W, g, H'\u27e9,\n    exact \u27e8W, g, by simpa\u27e9,\n  end,\n  transitive' :=\n  begin\n    intros X S H\u2081 R H\u2082 Y f,\n    rcases H\u2081 f with \u27e8Z, g, H\u2083\u27e9,\n    rcases H\u2082 H\u2083 (\ud835\udfd9 Z) with \u27e8W, h, H\u2084\u27e9,\n    exact \u27e8W, (h \u226b g), by simpa using H\u2084\u27e9,\n  end }\n\nlemma dense_covering : S \u2208 dense X \u2194 \u2200 {Y} (f : Y \u27f6 X), \u2203 Z (g : Z \u27f6 Y), S (g \u226b 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\u2200 {X Y Z : C} (yx : Y \u27f6 X) (zx : Z \u27f6 X), \u2203 W (wy : W \u27f6 Y) (wz : W \u27f6 Z), wy \u226b yx = wz \u226b zx\n\nlemma right_ore_of_pullbacks [limits.has_pullbacks C] : right_ore_condition C :=\n\u03bb X Y Z yx zx, \u27e8_, _, _, limits.pullback.condition\u27e9\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 := \u03bb X S, \u2203 Y (f : Y \u27f6 X), S f,\n  top_mem' := \u03bb X, \u27e8_, \ud835\udfd9 _, \u27e8\u27e9\u27e9,\n  pullback_stable' :=\n  begin\n    rintros X Y S h \u27e8Z, f, hf\u27e9,\n    rcases hro h f with \u27e8W, g, k, comm\u27e9,\n    refine \u27e8_, g, _\u27e9,\n    simp [comm, hf],\n  end,\n  transitive' :=\n  begin\n    rintros X S \u27e8Y, f, hf\u27e9 R h,\n    rcases h hf with \u27e8Z, g, hg\u27e9,\n    exact \u27e8_, _, hg\u27e9,\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 `\u03b1 \u2192 \u03b2` into a function `t' \u03b1 \u2192 t' \u03b2` using the functor\n  `t` and the equivalence `\u03a0 \u03b1, t \u03b1 \u2243 t' \u03b1`.\n* `Equiv.functor`: `Equiv.map` as a functor.\n* `Equiv.traverse`: Turns traversably a function `\u03b1 \u2192 m \u03b2` into a function `t' \u03b1 \u2192 m (t' \u03b2)` using\n  the traversable functor `t` and the equivalence `\u03a0 \u03b1, t \u03b1 \u2243 t' \u03b1`.\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 \u2192 Type u} (eqv : \u2200 \u03b1, t \u03b1 \u2243 t' \u03b1)\n\nvariable [Functor t]\n\nopen Functor\n\n/-- Given a functor `t`, a function `t' : Type u \u2192 Type u`, and\nequivalences `t \u03b1 \u2243 t' \u03b1` for all `\u03b1`, then every function `\u03b1 \u2192 \u03b2` can\nbe mapped to a function `t' \u03b1 \u2192 t' \u03b2` functorially (see\n`Equiv.functor`). -/\nprotected def map {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) (x : t' \u03b1) : t' \u03b2 :=\n  eqv \u03b2 <| map f ((eqv \u03b1).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 {\u03b1 : Type u} (x : t' \u03b1) : 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 {\u03b1 \u03b2 \u03b3 : Type u} (g : \u03b1 \u2192 \u03b2) (h : \u03b2 \u2192 \u03b3) (x : t' \u03b1) :\n    Equiv.map eqv (h \u2218 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\u2080 : \u2200 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2), Functor.map f = Equiv.map eqv f)\n    (h\u2081 : \u2200 {\u03b1 \u03b2} (f : \u03b2), Functor.mapConst f = (Equiv.map eqv \u2218 Function.const \u03b1) 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 [\u2190 h\u2080], rw [\u2190 h\u2081]] <;> 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 \u2192 Type u} (eqv : \u2200 \u03b1, t \u03b1 \u2243 t' \u03b1)\n\nvariable [Traversable t]\n\nvariable {m : Type u \u2192 Type u} [Applicative m]\n\nvariable {\u03b1 \u03b2 : Type u}\n\n/-- Like `Equiv.map`, a function `t' : Type u \u2192 Type u` can be given\nthe structure of a traversable functor using a traversable functor\n`t'` and equivalences `t \u03b1 \u2243 t' \u03b1` for all \u03b1. See `Equiv.traversable`. -/\nprotected def traverse (f : \u03b1 \u2192 m \u03b2) (x : t' \u03b1) : m (t' \u03b2) :=\n  eqv \u03b2 <$> traverse f ((eqv \u03b1).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 \u2192 Type u} (eqv : \u2200 \u03b1, t \u03b1 \u2243 t' \u03b1)\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 \u2192 Type u} [Applicative F] [Applicative G]\n\nvariable [LawfulApplicative F] [LawfulApplicative G]\n\nvariable (\u03b7 : ApplicativeTransformation F G)\n\nvariable {\u03b1 \u03b2 \u03b3 : Type u}\n\nopen IsLawfulTraversable Functor\n\n-- Porting note: Id.bind_eq is missing an `#align`.\n\nprotected theorem id_traverse (x : t' \u03b1) : Equiv.traverse eqv (pure : \u03b1 \u2192 Id \u03b1) 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 : \u03b1 \u2192 \u03b2) (x : t' \u03b1) :\n    Equiv.traverse eqv ((pure : \u03b2 \u2192 Id \u03b2) \u2218 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 : \u03b2 \u2192 F \u03b3) (g : \u03b1 \u2192 G \u03b2) (x : t' \u03b1) :\n    Equiv.traverse eqv (Comp.mk \u2218 Functor.map f \u2218 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 : \u03b1 \u2192 F \u03b2) (x : t' \u03b1) :\n    \u03b7 (Equiv.traverse eqv f x) = Equiv.traverse eqv (@\u03b7 _ \u2218 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\u2080 : \u2200 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2), map f = Equiv.map eqv f)\n    (h\u2081 : \u2200 {\u03b1 \u03b2} (f : \u03b2), mapConst f = (Equiv.map eqv \u2218 Function.const \u03b1) f)\n    (h\u2082 :\n      \u2200 {F : Type u \u2192 Type u} [Applicative F],\n        \u2200 [LawfulApplicative F] {\u03b1 \u03b2} (f : \u03b1 \u2192 F \u03b2), 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\u2082 needs a `LawfulApplicative` assumption\n  refine' { toLawfulFunctor := Equiv.lawfulFunctor' eqv @h\u2080 @h\u2081.. } <;> intros\n  \u00b7 rw [h\u2082, Equiv.id_traverse]\n  \u00b7 rw [h\u2082, Equiv.comp_traverse, h\u2082]\n    congr\n    rw [h\u2082]\n  \u00b7 rw [h\u2082, Equiv.traverse_eq_map_id, h\u2080]; rfl\n  \u00b7 rw [h\u2082, Equiv.naturality, h\u2082]\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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) :=\n  \u2200 (s : finset \u03b9) (w : \u03b9 \u2192 k),\n    (finset.sum s fun (i : \u03b9) => w i) = 0 \u2192\n      coe_fn (finset.weighted_vsub s p) w = 0 \u2192 \u2200 (i : \u03b9), i \u2208 s \u2192 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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) :\n    affine_independent k p \u2194\n        \u2200 (s : finset \u03b9) (w : \u03b9 \u2192 k),\n          (finset.sum s fun (i : \u03b9) => w i) = 0 \u2192\n            coe_fn (finset.weighted_vsub s p) w = 0 \u2192 \u2200 (i : \u03b9), i \u2208 s \u2192 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] {\u03b9 : Type u_4} [subsingleton \u03b9] (p : \u03b9 \u2192 P) :\n    affine_independent k p :=\n  fun (s : finset \u03b9) (w : \u03b9 \u2192 k) (h : (finset.sum s fun (i : \u03b9) => w i) = 0)\n    (hs : coe_fn (finset.weighted_vsub s p) w = 0) (i : \u03b9) (hi : i \u2208 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] {\u03b9 : Type u_4} [fintype \u03b9] (p : \u03b9 \u2192 P) :\n    affine_independent k p \u2194\n        \u2200 (w : \u03b9 \u2192 k),\n          (finset.sum finset.univ fun (i : \u03b9) => w i) = 0 \u2192\n            coe_fn (finset.weighted_vsub finset.univ p) w = 0 \u2192 \u2200 (i : \u03b9), 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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) (i1 : \u03b9) :\n    affine_independent k p \u2194\n        linear_independent k fun (i : Subtype fun (x : \u03b9) => x \u2260 i1) => p \u2191i -\u1d65 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\u2081 : P}\n    (hp\u2081 : p\u2081 \u2208 s) :\n    (affine_independent k fun (p : \u21a5s) => \u2191p) \u2194\n        linear_independent k fun (v : \u21a5((fun (p : P) => p -\u1d65 p\u2081) '' (s \\ singleton p\u2081))) => \u2191v :=\n  sorry\n\n/-- A set of nonzero vectors is linearly independent if and only if,\ngiven a point `p\u2081`, the vectors added to `p\u2081` and `p\u2081` 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 : \u2200 (v : V), v \u2208 s \u2192 v \u2260 0) (p\u2081 : P) :\n    (linear_independent k fun (v : \u21a5s) => \u2191v) \u2194\n        affine_independent k fun (p : \u21a5(singleton p\u2081 \u222a (fun (v : V) => v +\u1d65 p\u2081) '' s)) => \u2191p :=\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] {\u03b9 : Type u_4}\n    (p : \u03b9 \u2192 P) :\n    affine_independent k p \u2194\n        \u2200 (s1 s2 : finset \u03b9) (w1 w2 : \u03b9 \u2192 k),\n          (finset.sum s1 fun (i : \u03b9) => w1 i) = 1 \u2192\n            (finset.sum s2 fun (i : \u03b9) => w2 i) = 1 \u2192\n              coe_fn (finset.affine_combination s1 p) w1 =\n                  coe_fn (finset.affine_combination s2 p) w2 \u2192\n                set.indicator (\u2191s1) w1 = set.indicator (\u2191s2) 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] {\u03b9 : Type u_4} [nontrivial k] {p : \u03b9 \u2192 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] {\u03b9 : Type u_4}\n    {\u03b92 : Type u_5} (f : \u03b92 \u21aa \u03b9) {p : \u03b9 \u2192 P} (ha : affine_independent k p) :\n    affine_independent k (p \u2218 \u21d1f) :=\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] {\u03b9 : Type u_4}\n    {p : \u03b9 \u2192 P} (ha : affine_independent k p) (s : set \u03b9) :\n    affine_independent k fun (i : \u21a5s) => p \u2191i :=\n  affine_independent_embedding_of_affine_independent\n    (function.embedding.subtype fun (x : \u03b9) => x \u2208 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] {\u03b9 : Type u_4} {p : \u03b9 \u2192 P}\n    (ha : affine_independent k p) : affine_independent k fun (x : \u21a5(set.range p)) => \u2191x :=\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 : \u21a5t) => \u2191x) (hs : s \u2286 t) :\n    affine_independent k fun (x : \u21a5s) => \u2191x :=\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] {\u03b9 : Type u_4}\n    {p : \u03b9 \u2192 P} (ha : affine_independent k fun (x : \u21a5(set.range p)) => \u2191x)\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    {\u03b9 : Type u_4} [nontrivial k] {p : \u03b9 \u2192 P} (ha : affine_independent k p) {s1 : set \u03b9}\n    {s2 : set \u03b9} {p0 : P} (hp0s1 : p0 \u2208 affine_span k (p '' s1))\n    (hp0s2 : p0 \u2208 affine_span k (p '' s2)) : \u2203 (i : \u03b9), i \u2208 s1 \u2229 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] {\u03b9 : Type u_4}\n    [nontrivial k] {p : \u03b9 \u2192 P} (ha : affine_independent k p) {s1 : set \u03b9} {s2 : set \u03b9}\n    (hd : s1 \u2229 s2 = \u2205) : \u2191(affine_span k (p '' s1)) \u2229 \u2191(affine_span k (p '' s2)) = \u2205 :=\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] {\u03b9 : Type u_4}\n    [nontrivial k] {p : \u03b9 \u2192 P} (ha : affine_independent k p) (i : \u03b9) (s : set \u03b9) :\n    p i \u2208 affine_span k (p '' s) \u2194 i \u2208 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] {\u03b9 : Type u_4} [nontrivial k]\n    {p : \u03b9 \u2192 P} (ha : affine_independent k p) (i : \u03b9) (s : set \u03b9) :\n    \u00acp i \u2208 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 : \u21a5s) => \u2191p) :\n    \u2203 (t : set P), s \u2286 t \u2227 (affine_independent k fun (p : \u21a5t) => \u2191p) \u2227 affine_span k t = \u22a4 :=\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\u2081 : P} {p\u2082 : P} (h : p\u2081 \u2260 p\u2082) :\n    affine_independent k (matrix.vec_cons p\u2081 (matrix.vec_cons p\u2082 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 : \u2115)\n    where\n  points : fin (n + 1) \u2192 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 : \u2115} {s1 : simplex k P n} {s2 : simplex k P n}\n    (h : \u2200 (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 : \u2115} (s1 : simplex k P n) (s2 : simplex k P n) :\n    s1 = s2 \u2194 \u2200 (i : fin (n + 1)), points s1 i = points s2 i :=\n  { mp := fun (h : s1 = s2) (_x : fin (n + 1)) => h \u25b8 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 : \u2115} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : \u2115}\n    (h : finset.card fs = m + 1) : simplex k P m :=\n  mk (points s \u2218 \u21d1(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 : \u2115} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : \u2115}\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 : \u2115} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : \u2115}\n    (h : finset.card fs = m + 1) : points (face s h) = points s \u2218 \u21d1(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 : \u2115} (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 : \u2115} (s : simplex k P n)\n    {fs : finset (fin (n + 1))} {m : \u2115} (h : finset.card fs = m + 1) :\n    set.range (points (face s h)) = points s '' \u2191fs :=\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 : \u2115} (s : simplex k P n)\n    {fs : finset (fin (n + 1))} {m : \u2115} (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 : \u2115} (s : simplex k P n)\n    {fs\u2081 : finset (fin (n + 1))} {fs\u2082 : finset (fin (n + 1))} {m\u2081 : \u2115} {m\u2082 : \u2115}\n    (h\u2081 : finset.card fs\u2081 = m\u2081 + 1) (h\u2082 : finset.card fs\u2082 = m\u2082 + 1) :\n    finset.centroid k fs\u2081 (points s) = finset.centroid k fs\u2082 (points s) \u2194 fs\u2081 = fs\u2082 :=\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 : \u2115} (s : simplex k P n)\n    {fs\u2081 : finset (fin (n + 1))} {fs\u2082 : finset (fin (n + 1))} {m\u2081 : \u2115} {m\u2082 : \u2115}\n    (h\u2081 : finset.card fs\u2081 = m\u2081 + 1) (h\u2082 : finset.card fs\u2082 = m\u2082 + 1) :\n    finset.centroid k finset.univ (points (face s h\u2081)) =\n          finset.centroid k finset.univ (points (face s h\u2082)) \u2194\n        fs\u2081 = fs\u2082 :=\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 : \u2115} {s\u2081 : simplex k P n}\n    {s\u2082 : simplex k P n} (h : set.range (points s\u2081) = set.range (points s\u2082)) :\n    finset.centroid k finset.univ (points s\u2081) = finset.centroid k finset.univ (points s\u2082) :=\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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u2265 3`, `a\u2081, ..., a\u2099` be strictly positive integers such that `a\u1d62 \u2223 a\u1d62\u208b\u2081 + a\u1d62\u208a\u2081` for\n`i = 2, ..., n - 1`. Show that $\\sum_{i=1}^{n-1}\\dfrac{a_0a_n}{a_ia_{i+1}} \u2208 \\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 : \u2115` whose cast to `\u03b1` is the sum we want.\n\nIn mathlib, `\u2115` starts at `0`. To make the indexing cleaner, we use `a\u2080, ..., a\u2099\u208b\u2081` instead of\n`a\u2081, ..., a\u2099`. Similarly, it's nicer to not use subtraction of naturals, so we replace\n`a\u1d62 \u2223 a\u1d62\u208b\u2081 + a\u1d62\u208a\u2081` by `a\u1d62\u208a\u2081 \u2223 a\u1d62 + a\u1d62\u208a\u2082`.\n\nWe don't actually have to work in `\u211a` or `\u211d`. 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 : \u2115 \u2192 \u2115`.\n\nIn the proof itself, we replace `n : \u2115, 1 \u2264 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 : \u2115`, `a : \u2115 \u2192 \u2115`, `\u2200 i \u2264 n, 0 < a i`, `\u2200 i, i + 2 \u2264 n \u2192 a\u1d62\u208a\u2081 \u2223 a\u1d62 + a\u1d62\u208a\u2082` (read `\u2192` as\n\"implies\"). Then there exists `b : \u2115` 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\u2099\u208a\u2081 \u2223 a\u2099 * b - a\u2080` 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\u2080 * 1 - a\u2080 = 0` is clearly divisible by `a\u2081`.\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} \u00d7 \\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} \u00d7 b + a_0 / a_{n+1}\n      = (a_n + a_{n+2}) / a_{n+1} \u00d7 b - (a_n b - a_0)(a_{n+1})$$\n    which is a natural because `(a\u2099 + a\u2099\u208a\u2082)/a\u2099\u208a\u2081`, `b` and `(a\u2099 * b - a\u2080)/a\u2099\u208a\u2081` are (plus an\n    annoying inequality, or the fact that the original sum is positive because its terms are).\n  * Divisibility condition:\n    `a\u2099\u208a\u2081 * ((a\u2099 + a\u2099\u208a\u2082)/a\u2099\u208a\u2081 * b - (a\u2099 * b - a\u2080)/a\u2099\u208a\u2081) - a\u2080 = a\u2099\u208a\u2081a\u2099\u208a\u2082b` is divisible by `a\u2099\u208a\u2082`.\n-/\n\nopen_locale big_operators\n\nvariables {\u03b1 : Type*} [linear_ordered_field \u03b1]\n\ntheorem week3_p1 (n : \u2115) (a : \u2115 \u2192 \u2115) (a_pos : \u2200 i \u2264 n, 0 < a i)\n  (ha : \u2200 i, i + 2 \u2264 n \u2192 a (i + 1) \u2223 a i + a (i + 2)) :\n  \u2203 b : \u2115, (b : \u03b1) = \u2211 i in finset.range n, (a 0 * a n)/(a i * a (i + 1)) :=\nbegin\n  -- Treat separately `n = 0` and `n \u2265 1`\n  cases n,\n  /- Case `n = 0`\n  The sum is trivially equal to `0` -/\n  { exact \u27e80, by rw [nat.cast_zero, finset.sum_range_zero]\u27e9 }, -- `\u27e8Claim it, Prove it\u27e9`\n  /- Case `n \u2265 1`. We replace `n` by `n + 1` everywhere to make this inequality explicit\n  Set up the stronger induction hypothesis -/\n  rsuffices \u27e8b, hb, -\u27e9 :\n    \u2203 b : \u2115, (b : \u03b1) = \u2211 i in finset.range (n + 1), (a 0 * a (n + 1)) / (a i * a (i + 1))\n    \u2227 a (n + 1) \u2223 a n * b - a 0,\n  { exact \u27e8b, hb\u27e9 },\n  simp_rw \u2190@nat.cast_pos \u03b1 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 \u27e81, _, _\u27e9,\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 \u27e8b, hb, han\u27e9 := ih (\u03bb i hi, ha i $ nat.le_succ_of_le hi)\n    (\u03bb i hi, a_pos i $ nat.le_succ_of_le hi),\n  specialize ha n le_rfl,\n  have ha\u2080 : a 0 \u2264 a n * b, -- Needing this is an artifact of `\u2115`-subtraction.\n  { rw [\u2190@nat.cast_le \u03b1, nat.cast_mul, hb, \u2190div_le_iff' (a_pos _ $ n.le_succ.trans $ nat.le_succ _),\n      \u2190mul_div_mul_right _ _ (a_pos _ $ nat.le_succ _).ne'],\n    suffices h : \u2200 i, i \u2208 finset.range (n + 1) \u2192 0 \u2264 (a 0 : \u03b1) * a (n + 1) / (a i * a (i + 1)),\n    { exact finset.single_le_sum h (finset.self_mem_range_succ n) },\n    refine (\u03bb i _, div_nonneg _ _); refine mul_nonneg _ _; exact nat.cast_nonneg _ },\n  -- Claim that the sum equals `(a\u2099 + a\u2099\u208a\u2082)/a\u2099\u208a\u2081 * b - (a\u2099 * b - a\u2080)/a\u2099\u208a\u2081`\n  refine \u27e8(a n + a (n + 2))/ a (n + 1) * b - (a n * b - a 0) / a (n + 1), _, _\u27e9,\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) : \u2115) : \u03b1)\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 [\u2190mul_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    ... = \u2211 (i : \u2115) 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 [\u2190mul_div_assoc, \u2190mul_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, \u2190 mul_assoc, nat.mul_div_cancel' ha, add_mul,\n      nat.mul_div_cancel' han, add_tsub_tsub_cancel ha\u2080, 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 `\u22a4`. This implementation uses `part \u2115` as an\nimplementation. Use `\u2115\u221e` 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 `\u2115\u221e`, with theorems that it plays well\nwith `+` and `\u2264`.\n\n* `with_top_add_equiv : part_enat \u2243+ \u2115\u221e`\n* `with_top_order_iso : part_enat \u2243o \u2115\u221e`\n\n## Implementation details\n\n`part_enat` is defined to be `part \u2115`.\n\n`+` and `\u2264` are defined on `part_enat`, but there is an issue with `*` because it's not\nclear what `0 * \u22a4` should be. `mul` is hence left undefined. Similarly `\u22a4 - \u22a4` 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, \u2115\u221e\n-/\nopen part (hiding some)\n\n/-- Type of natural numbers with infinity (`\u22a4`) -/\ndef part_enat : Type := part \u2115\n\nnamespace part_enat\n\n/-- The computable embedding `\u2115 \u2192 part_enat`.\n\nThis coincides with the coercion `coe : \u2115 \u2192 part_enat`, see `part_enat.some_eq_coe`.\nHowever, `coe` is noncomputable so `some` is preferable when computability is a concern. -/\ndef some : \u2115 \u2192 part_enat := part.some\n\ninstance : has_zero part_enat := \u27e8some 0\u27e9\ninstance : inhabited part_enat := \u27e80\u27e9\ninstance : has_one part_enat := \u27e8some 1\u27e9\ninstance : has_add part_enat := \u27e8\u03bb x y, \u27e8x.dom \u2227 y.dom, \u03bb h, get x h.1 + get y h.2\u27e9\u27e9\n\ninstance (n : \u2115) : decidable (some n).dom := is_true trivial\n\n@[simp] lemma dom_some (x : \u2115) : (some x).dom := trivial\n\ninstance : add_comm_monoid part_enat :=\n{ add       := (+),\n  zero      := (0),\n  add_comm  := \u03bb x y, part.ext' and.comm (\u03bb _ _, add_comm _ _),\n  zero_add  := \u03bb x, part.ext' (true_and _) (\u03bb _ _, zero_add _),\n  add_zero  := \u03bb x, part.ext' (and_true _) (\u03bb _ _, add_zero _),\n  add_assoc := \u03bb x y z, part.ext' and.assoc (\u03bb _ _, 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 := \u03bb _, part.ext' (true_and _).symm (\u03bb _ _, rfl),\n  .. part_enat.add_comm_monoid }\n\nlemma some_eq_coe (n : \u2115) : some n = n := rfl\n\n@[simp, norm_cast] lemma coe_inj {x y : \u2115} : (x : part_enat) = y \u2194 x = y := part.some_inj\n\n@[simp] \n\ninstance : can_lift part_enat \u2115 coe dom := \u27e8\u03bb n hn, \u27e8n.get hn, part.some_get _\u27e9\u27e9\n\ninstance : has_le part_enat := \u27e8\u03bb x y, \u2203 h : y.dom \u2192 x.dom, \u2200 hy : y.dom, x.get (h hy) \u2264 y.get hy\u27e9\ninstance : has_top part_enat := \u27e8none\u27e9\ninstance : has_bot part_enat := \u27e80\u27e9\ninstance : has_sup part_enat := \u27e8\u03bb x y, \u27e8x.dom \u2227 y.dom, \u03bb h, x.get h.1 \u2294 y.get h.2\u27e9\u27e9\n\nlemma le_def (x y : part_enat) :\n  x \u2264 y \u2194 \u2203 h : y.dom \u2192 x.dom, \u2200 hy : y.dom, x.get (h hy) \u2264 y.get hy :=\niff.rfl\n\n@[elab_as_eliminator] protected lemma cases_on' {P : part_enat \u2192 Prop} :\n  \u2200 a : part_enat, P \u22a4 \u2192 (\u2200 n : \u2115, P (some n)) \u2192 P a :=\npart.induction_on\n\n@[elab_as_eliminator] protected lemma cases_on {P : part_enat \u2192 Prop} :\n  \u2200 a : part_enat, P \u22a4 \u2192 (\u2200 n : \u2115, P n) \u2192 P a :=\nby { simp only [\u2190 some_eq_coe], exact part_enat.cases_on' }\n\n@[simp] lemma top_add (x : part_enat) : \u22a4 + x = \u22a4 :=\npart.ext' (false_and _) (\u03bb h, h.left.elim)\n\n@[simp] lemma add_top (x : part_enat) : x + \u22a4 = \u22a4 :=\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 [\u2190 some_eq_coe], exact part.ext' (iff_of_true trivial h) (\u03bb _ _, rfl) }\n\n@[simp, norm_cast] lemma get_coe' (x : \u2115) (h : (x : part_enat).dom) : get (x : part_enat) h = x :=\nby rw [\u2190 coe_inj, coe_get]\n\nlemma get_coe {x : \u2115} : get (x : part_enat) (dom_coe x) = x := get_coe' _ _\n\nlemma coe_add_get {x : \u2115} {y : part_enat} (h : ((x : part_enat) + y).dom) :\n  get ((x : part_enat) + y) h = x + get y h.2 :=\nby { simp only [\u2190 some_eq_coe] at h \u22a2, 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 : \u2115} :\n  a.get ha = b \u2194 a = some b := get_eq_iff_eq_some\n\nlemma get_eq_iff_eq_coe {a : part_enat} {ha : a.dom} {b : \u2115} :\n  a.get ha = b \u2194 a = b := by rw [get_eq_iff_eq_some, some_eq_coe]\n\nlemma dom_of_le_of_dom {x y : part_enat} : x \u2264 y \u2192 y.dom \u2192 x.dom := \u03bb \u27e8h, _\u27e9, h\n\nlemma dom_of_le_some {x : part_enat} {y : \u2115} (h : x \u2264 some y) : x.dom := dom_of_le_of_dom h trivial\n\nlemma dom_of_le_coe {x : part_enat} {y : \u2115} (h : x \u2264 y) : x.dom :=\nby { rw [\u2190 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 \u2264 y) :=\nif hx : x.dom\nthen decidable_of_decidable_of_iff\n  (show decidable (\u2200 (hy : (y : part_enat).dom), x.get hx \u2264 (y : part_enat).get hy),\n    from forall_prop_decidable _) $\n  by { dsimp [(\u2264)], simp only [hx, exists_prop_of_true, forall_true_iff] }\nelse if hy : y.dom\nthen is_false $ \u03bb h, hx $ dom_of_le_of_dom h hy\nelse is_true \u27e8\u03bb h, (hy h).elim, \u03bb h, (hy h).elim\u27e9\n\n/-- The coercion `\u2115 \u2192 part_enat` preserves `0` and addition. -/\ndef coe_hom : \u2115 \u2192+ part_enat := \u27e8coe, nat.cast_zero, nat.cast_add\u27e9\n\n@[simp] lemma coe_coe_hom : \u21d1coe_hom = coe := rfl\n\ninstance : partial_order part_enat :=\n{ le          := (\u2264),\n  le_refl     := \u03bb x, \u27e8id, \u03bb _, le_rfl\u27e9,\n  le_trans    := \u03bb x y z \u27e8hxy\u2081, hxy\u2082\u27e9 \u27e8hyz\u2081, hyz\u2082\u27e9,\n    \u27e8hxy\u2081 \u2218 hyz\u2081, \u03bb _, le_trans (hxy\u2082 _) (hyz\u2082 _)\u27e9,\n  le_antisymm := \u03bb x y \u27e8hxy\u2081, hxy\u2082\u27e9 \u27e8hyx\u2081, hyx\u2082\u27e9, part.ext' \u27e8hyx\u2081, hxy\u2081\u27e9\n    (\u03bb _ _, le_antisymm (hxy\u2082 _) (hyx\u2082 _)) }\n\nlemma lt_def (x y : part_enat) : x < y \u2194 \u2203 (hx : x.dom), \u2200 (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 \u27e8\u27e8hyx, H\u27e9, h\u27e9,\n    by_cases hx : x.dom,\n    { use hx, intro hy,\n      specialize H hy, specialize h (\u03bb _, hy),\n      rw not_forall at h, cases h with hx' h,\n      rw not_le at h, exact h },\n    { specialize h (\u03bb hx', (hx hx').elim),\n      rw not_forall at h, cases h with hx' h,\n      exact (hx hx').elim } },\n  { rintro \u27e8hx, H\u27e9, exact \u27e8\u27e8\u03bb _, hx, \u03bb hy, (H hy).le\u27e9, \u03bb hxy h, not_lt_of_le (h _) (H _)\u27e9 }\nend\n\n@[simp, norm_cast] lemma coe_le_coe {x y : \u2115} : (x : part_enat) \u2264 y \u2194 x \u2264 y :=\nby { rw [\u2190 some_eq_coe, \u2190 some_eq_coe], exact \u27e8\u03bb \u27e8_, h\u27e9, h trivial, \u03bb h, \u27e8\u03bb _, trivial, \u03bb _, h\u27e9\u27e9 }\n\n@[simp, norm_cast] lemma coe_lt_coe {x y : \u2115} : (x : part_enat) < y \u2194 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 \u2264 y.get hy \u2194 x \u2264 y :=\nby conv { to_lhs, rw [\u2190 coe_le_coe, coe_get, coe_get]}\n\nlemma le_coe_iff (x : part_enat) (n : \u2115) : x \u2264 n \u2194 \u2203 h : x.dom, x.get h \u2264 n :=\nbegin\n  rw [\u2190 some_eq_coe],\n  show (\u2203 (h : true \u2192 x.dom), _) \u2194 \u2203 h : x.dom, x.get h \u2264 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 : \u2115) : x < n \u2194 \u2203 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 : \u2115) (x : part_enat) : (n : part_enat) \u2264 x \u2194 \u2200 h : x.dom, n \u2264 x.get h :=\nbegin\n  rw [\u2190 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 : \u2115) (x : part_enat) : (n : part_enat) < x \u2194 \u2200 h : x.dom, n < x.get h :=\nbegin\n  rw [\u2190 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) := \u27e8coe_inj.not.mpr dec_trivial\u27e9\n\ninstance semilattice_sup : semilattice_sup part_enat :=\n{ sup := (\u2294),\n  le_sup_left := \u03bb _ _, \u27e8and.left, \u03bb _, le_sup_left\u27e9,\n  le_sup_right := \u03bb _ _, \u27e8and.right, \u03bb _, le_sup_right\u27e9,\n  sup_le := \u03bb x y z \u27e8hx\u2081, hx\u2082\u27e9 \u27e8hy\u2081, hy\u2082\u27e9, \u27e8\u03bb hz, \u27e8hx\u2081 hz, hy\u2081 hz\u27e9,\n    \u03bb _, sup_le (hx\u2082 _) (hy\u2082 _)\u27e9,\n  ..part_enat.partial_order }\n\ninstance order_bot : order_bot part_enat :=\n{ bot := (\u22a5),\n  bot_le := \u03bb _, \u27e8\u03bb _, trivial, \u03bb _, nat.zero_le _\u27e9 }\n\ninstance order_top : order_top part_enat :=\n{ top := (\u22a4),\n  le_top := \u03bb x, \u27e8\u03bb h, false.elim h, \u03bb hy, false.elim hy\u27e9 }\n\nlemma eq_zero_iff {x : part_enat} : x = 0 \u2194 x \u2264 0 := eq_bot_iff\nlemma ne_zero_iff {x : part_enat} : x \u2260 0 \u2194 \u22a5 < x := bot_lt_iff_ne_bot.symm\n\nlemma dom_of_lt {x y : part_enat} : x < y \u2192 x.dom :=\npart_enat.cases_on x not_top_lt $ \u03bb _ _, dom_coe _\n\nlemma top_eq_none : (\u22a4 : part_enat) = none := rfl\n\n@[simp] lemma coe_lt_top (x : \u2115) : (x : part_enat) < \u22a4 :=\nne.lt_top (\u03bb h, absurd (congr_arg dom h) $ by simpa only [dom_coe] using true_ne_false)\n\n@[simp] lemma coe_ne_top (x : \u2115) : (x : part_enat) \u2260 \u22a4 := ne_of_lt (coe_lt_top x)\n\nlemma not_is_max_coe (x : \u2115) : \u00ac is_max (x : part_enat) :=\nnot_is_max_of_lt (coe_lt_top x)\n\nlemma ne_top_iff {x : part_enat} : x \u2260 \u22a4 \u2194 \u2203 (n : \u2115), x = n :=\nby simpa only [\u2190 some_eq_coe] using part.ne_none_iff\n\nlemma ne_top_iff_dom {x : part_enat} : x \u2260 \u22a4 \u2194 x.dom :=\nby classical; exact not_iff_comm.1 part.eq_none_iff'.symm\n\nlemma not_dom_iff_eq_top {x : part_enat} : \u00ac x.dom \u2194 x = \u22a4 :=\niff.not_left ne_top_iff_dom.symm\n\nlemma ne_top_of_lt {x y : part_enat} (h : x < y) : x \u2260 \u22a4 :=\nne_of_lt $ lt_of_lt_of_le h le_top\n\nlemma eq_top_iff_forall_lt (x : part_enat) : x = \u22a4 \u2194 \u2200 n : \u2115, (n : part_enat) < x :=\nbegin\n  split,\n  { rintro rfl n, exact coe_lt_top _ },\n  { contrapose!, rw ne_top_iff, rintro \u27e8n, rfl\u27e9, exact \u27e8n, irrefl _\u27e9 }\nend\n\nlemma eq_top_iff_forall_le (x : part_enat) : x = \u22a4 \u2194 \u2200 n : \u2115, (n : part_enat) \u2264 x :=\n(eq_top_iff_forall_lt x).trans\n\u27e8\u03bb h n, (h n).le, \u03bb h n, lt_of_lt_of_le (coe_lt_coe.mpr n.lt_succ_self) (h (n + 1))\u27e9\n\nlemma pos_iff_one_le {x : part_enat} : 0 < x \u2194 1 \u2264 x :=\npart_enat.cases_on x (by simp only [iff_true, le_top, coe_lt_top, \u2190 @nat.cast_zero part_enat]) $\n  \u03bb n, by { rw [\u2190 nat.cast_zero, \u2190 nat.cast_one, part_enat.coe_lt_coe, part_enat.coe_le_coe], refl }\n\ninstance : is_total part_enat (\u2264) :=\n{ total := \u03bb x y, part_enat.cases_on x\n    (or.inr le_top) (part_enat.cases_on y (\u03bb _, or.inl le_top)\n      (\u03bb x y, (le_total x y).elim (or.inr \u2218 coe_le_coe.2)\n        (or.inl \u2218 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 := (\u2294),\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 := \u03bb _ _ _, le_min,\n  ..part_enat.semilattice_sup }\n\ninstance : ordered_add_comm_monoid part_enat :=\n{ add_le_add_left := \u03bb a b \u27e8h\u2081, h\u2082\u27e9 c,\n    part_enat.cases_on c (by simp)\n      (\u03bb c, \u27e8\u03bb h, and.intro (dom_coe _) (h\u2081 h.2),\n        \u03bb h, by simpa only [coe_add_get] using add_le_add_left (h\u2082 _) c\u27e9),\n  ..part_enat.linear_order,\n  ..part_enat.add_comm_monoid }\n\ninstance : canonically_ordered_add_monoid part_enat :=\n{ le_self_add := \u03bb a b, part_enat.cases_on b (le_top.trans_eq (add_top _).symm) $\n    \u03bb b, part_enat.cases_on a (top_add _).ge $\n      \u03bb a, (coe_le_coe.2 le_self_add).trans_eq (nat.cast_add _ _),\n  exists_add_of_le := \u03bb a b, part_enat.cases_on b (\u03bb _, \u27e8\u22a4, (add_top _).symm\u27e9) $\n    \u03bb b, part_enat.cases_on a (\u03bb h, ((coe_lt_top _).not_le h).elim) $ \u03bb a h, \u27e8(b - a : \u2115),\n        by rw [\u2190nat.cast_add, coe_inj, add_comm, tsub_add_cancel_of_le (coe_le_coe.1 h)]\u27e9,\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 : \u2115} (h : x + y = n) :\n  x = \u2191(n - y.get (dom_of_le_coe ((le_add_left le_rfl).trans_eq h))) :=\nbegin\n  lift x to \u2115 using dom_of_le_coe ((le_add_right le_rfl).trans_eq h),\n  lift y to \u2115 using dom_of_le_coe ((le_add_left le_rfl).trans_eq h),\n  rw [\u2190 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 \u2260 \u22a4) : x + z < y + z :=\nbegin\n  rcases ne_top_iff.mp (ne_top_of_lt h) with \u27e8m, rfl\u27e9,\n  rcases ne_top_iff.mp hz with \u27e8k, rfl\u27e9,\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 \u2260 \u22a4) : x + z < y + z \u2194 x < y :=\n\u27e8lt_of_add_lt_add_right, \u03bb h, part_enat.add_lt_add_right h hz\u27e9\n\nprotected lemma add_lt_add_iff_left {x y z : part_enat} (hz : z \u2260 \u22a4) : z + x < z + y \u2194 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 \u2260 \u22a4) : x < x + y \u2194 0 < y :=\nby { conv_rhs { rw [\u2190 part_enat.add_lt_add_iff_left hx] }, rw [add_zero] }\n\nlemma lt_add_one {x : part_enat} (hx : x \u2260 \u22a4) : 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 \u2264 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 \u27e8m, rfl\u27e9,\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 \u2264 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 \u27e8m, rfl\u27e9,\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 \u2260 \u22a4) : x + 1 \u2264 y \u2194 x < y :=\nbegin\n  split, swap, exact add_one_le_of_lt,\n  intro h, rcases ne_top_iff.mp hx with \u27e8m, rfl\u27e9,\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 \u2260 \u22a4) : x < y + 1 \u2194 x \u2264 y :=\nbegin\n  split, exact le_of_lt_add_one,\n  intro h, rcases ne_top_iff.mp hx with \u27e8m, rfl\u27e9,\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 = \u22a4 \u2194 a = \u22a4 \u2228 b = \u22a4 :=\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 \u2260 \u22a4) : a + c = b + c \u2194 a = b :=\nbegin\n  rcases ne_top_iff.1 hc with \u27e8c, rfl\u27e9,\n  apply part_enat.cases_on a; apply part_enat.cases_on b;\n  simp [add_eq_top_iff, coe_ne_top, @eq_comm _ (\u22a4 : 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 \u2260 \u22a4) : a + b = a + c \u2194 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 `\u2115\u221e`. -/\ndef to_with_top (x : part_enat) [decidable x.dom] : \u2115\u221e := x.to_option\n\nlemma to_with_top_top : to_with_top \u22a4 = \u22a4 := rfl\n\n@[simp] lemma to_with_top_top' {h : decidable (\u22a4 : part_enat).dom} : to_with_top \u22a4 = \u22a4 :=\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 : \u2115) : to_with_top (some n) = n := rfl\n\nlemma to_with_top_coe (n : \u2115) {_ : decidable (n : part_enat).dom} : to_with_top n = n :=\nby simp only [\u2190 some_eq_coe, \u2190 to_with_top_some]\n\n@[simp] lemma to_with_top_coe' (n : \u2115) {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} : \u03a0 [decidable x.dom]\n  [decidable y.dom], by exactI to_with_top x \u2264 to_with_top y \u2194 x \u2264 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 \u2194 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 [\u2190 nat.cast_add, \u2190 enat.coe_add]\n\n/-- `equiv` between `part_enat` and `\u2115\u221e` (for the order isomorphism see\n`with_top_order_iso`). -/\nnoncomputable def with_top_equiv : part_enat \u2243 \u2115\u221e :=\n{ to_fun := \u03bb x, to_with_top x,\n  inv_fun := \u03bb x, match x with (option.some n) := coe n | none := \u22a4 end,\n  left_inv := \u03bb x, by apply part_enat.cases_on x; intros; simp; refl,\n  right_inv := \u03bb x, by cases x; simp [with_top_equiv._match_1]; refl }\n\n@[simp] lemma with_top_equiv_top : with_top_equiv \u22a4 = \u22a4 :=\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 \u2264 with_top_equiv y \u2194 x \u2264 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 \u2194 x < y :=\nto_with_top_lt\n\n/-- `to_with_top` induces an order isomorphism between `part_enat` and `\u2115\u221e`. -/\nnoncomputable def with_top_order_iso : part_enat \u2243o \u2115\u221e :=\n{ map_rel_iff' := \u03bb _ _, with_top_equiv_le,\n  .. with_top_equiv}\n\n@[simp] lemma with_top_equiv_symm_top : with_top_equiv.symm \u22a4 = \u22a4 :=\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 : \u2115\u221e} :\n  with_top_equiv.symm x \u2264 with_top_equiv.symm y \u2194 x \u2264 y :=\nby rw \u2190 with_top_equiv_le; simp\n\n@[simp] lemma with_top_equiv_symm_lt {x y : \u2115\u221e} :\n  with_top_equiv.symm x < with_top_equiv.symm y \u2194 x < y :=\nby rw \u2190 with_top_equiv_lt; simp\n\n/-- `to_with_top` induces an additive monoid isomorphism between `part_enat` and `\u2115\u221e`. -/\nnoncomputable def with_top_add_equiv : part_enat \u2243+ \u2115\u221e :=\n{ map_add' := \u03bb 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 (\u03bb a b : part_enat, a < b),\n  simp_rw \u2190to_with_top_lt,\n  exact inv_image.wf _ (with_top.well_founded_lt nat.lt_wf)\nend\n\ninstance : well_founded_lt part_enat := \u27e8lt_wf\u27e9\ninstance : is_well_order part_enat (<) := { }\ninstance : has_well_founded part_enat := \u27e8(<), lt_wf\u27e9\n\nsection find\n\nvariables (P : \u2115 \u2192 Prop) [decidable_pred P]\n\n/-- The smallest `part_enat` satisfying a (decidable) predicate `P : \u2115 \u2192 Prop` -/\ndef find : part_enat := \u27e8\u2203 n, P n, nat.find\u27e9\n\n@[simp] lemma find_get (h : (find P).dom) : (find P).get h = nat.find h := rfl\n\nlemma find_dom (h : \u2203 n, P n) : (find P).dom := h\n\nlemma lt_find (n : \u2115) (h : \u2200 m \u2264 n, \u00acP 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 : \u2115) : (n : part_enat) < find P \u2194 (\u2200 m \u2264 n, \u00acP m) :=\nbegin\n  refine \u27e8_, lt_find P n\u27e9,\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 : \u2115) (h : P n) : find P \u2264 n :=\nby { rw le_coe_iff, refine \u27e8\u27e8_, h\u27e9, @nat.find_min' P _ _ _ h\u27e9 }\n\nlemma find_eq_top_iff : find P = \u22a4 \u2194 \u2200 n, \u00acP n :=\n(eq_top_iff_forall_lt _).trans\n\u27e8\u03bb h n, (lt_find_iff P n).mp (h n) _ le_rfl, \u03bb h n, lt_find P n $ \u03bb _ _, h _\u27e9\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 := (\u2293),\n  sup := (\u2294),\n  top := \u22a4,\n  bot := \u22a5,\n  le := (\u2264),\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 \u2192 regular_sequence \u2192 regular_sequence :=\n\u03bb a b,\n  { val := \u03bb 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        ... \u2264 |a_val (2 * m) - a_val (2 * n)| + |b_val (2 * m) - b_val (2 * n)| : abs_add _ _\n        ... \u2264 ((\u2191(2 * m))\u207b\u00b9 + (\u2191(2 * n))\u207b\u00b9) + ((\u2191(2 * m))\u207b\u00b9 + (\u2191(2 * n))\u207b\u00b9) : add_le_add a_property b_property\n        ... = (\u2191m)\u207b\u00b9 + (\u2191n)\u207b\u00b9 : by { push_cast, rw mul_inv\u2080, simp, norm_num, ring_nf, simp, rw mul_inv\u2080, ring,},\n    end\n  }\n\ndef neg (a: regular_sequence): regular_sequence :=\n  { val := (\u03bb x, -(a x)),\n    property := \u03bb _ _ m_pos n_pos, let h := a.property m_pos n_pos \n        in by rwa [\u2190abs_neg, neg_sub_neg, neg_sub] }\n\ninstance : has_neg regular_sequence :=\n  \u27e8neg\u27e9\n\nlemma neg_apply (a: regular_sequence) (n: \u2115): -a n = -(a n) := rfl\n\ninstance : has_sub regular_sequence :=\n  \u27e8\u03bb a b, add a (neg b)\u27e9\n\n@[simp] lemma sub_apply (a b: regular_sequence) (n: \u2115): (a - b) n = a (2*n) - b (2*n) := rfl\n\nlemma subs' {a b : regular_sequence} {n : \u2115}: (a-b) n  =  a (2*n) - b (2*n)  := rfl \n\ninstance : has_add regular_sequence :=\n  \u27e8add\u27e9\n\n@[simp] lemma add_apply' (a b: regular_sequence) (n: \u2115): (a + b).val n = a (2*n) + b (2*n) := rfl\n\n@[simp] lemma add_apply (a b: regular_sequence) (n: \u2115): (a + b) n = a (2*n) + b (2*n) := rfl\n\n\nlemma zero_add {a : regular_sequence} {n : \u2115}: (0 + a) n = a (2*n) :=\n  begin\n    simp,\n    refl,\n  end\n\nlemma add_zero {a : regular_sequence} {n : \u2115}: (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 \u27e8N\u2081, hN\u2081\u27e9 := hf (2*j) (mul_pos zero_lt_two hj),\n    obtain \u27e8N\u2082, hN\u2082\u27e9 := hg (2*j) (mul_pos zero_lt_two hj),\n    use max N\u2081 N\u2082,\n    intros n hn,\n    have h3 : | f (2*n) | + | g (2*n) | \u2264 (2*j: \u211a)\u207b\u00b9+ (2*j: \u211a)\u207b\u00b9,\n    {\n      have hfg : | f (2*n) | \u2264 (2*j: \u211a)\u207b\u00b9 \u2227 | g (2*n) | \u2264 (2*j: \u211a)\u207b\u00b9,\n      {\n        have : 2*n \u2265 N\u2081 \u2227 2*n \u2265 N\u2082,\n        {\n          have : n \u2264 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 \u27e8le_trans (le_of_max_le_left hn) this, le_trans (le_of_max_le_right hn) this\u27e9\n        },\n        obtain tt := hN\u2081 (2*n) this.1,\n        obtain ttt := hN\u2082 (2*n) this.2,\n        simp only [nat.cast_bit0, nat.cast_one, nat.cast_mul] at *,\n        exact \u27e8tt,ttt\u27e9,\n      },\n      exact add_le_add hfg.1 hfg.2,\n    },\n    rw [\u2190 one_mul (j : \u211a)\u207b\u00b9 ,\u2190 mul_inv_cancel (@two_ne_zero \u211a _ _), mul_assoc, \u2190 @mul_inv\u2080 \u211a _ 2 (j : \u211a), 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 \u2192 real \u2192 real :=\n  quotient.lift\u2082 (\u03bb x y, \u27e6regular_sequence.add x y\u27e7)\n  begin\n    simp only [quotient.eq],\n    intros a\u2081 b\u2081 a\u2082 b\u2082 a\u2081_eq_a\u2082 b\u2081_eq_b\u2082,\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\u2081_eq_a\u2082 (2*j) two_j_pos,\n    specialize b\u2081_eq_b\u2082 (2*j) two_j_pos,\n    obtain \u27e8N, hN\u27e9 := a\u2081_eq_a\u2082,\n    obtain \u27e8M, hM\u27e9 := b\u2081_eq_b\u2082,\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 {\u03b1 : Type} \n\ndef N (\u03b1 : Type) : Type := nat \u2192 \u03b1 \n\ndef NN (\u03b1 : Type) : Type := nat \u2192 nat \u2192 \u03b1 \n\ndef N.eq (n : nat) (a b : N \u03b1) : Prop :=\n\u2200 j < n, a j = b j\n\ndef NN.eq (m n : nat) (A B : NN \u03b1) : Prop :=\n\u2200 i < m, \u2200 j < n, A i j = B i j\n\ndef NN.mul_aux [ring \u03b1] (A B : NN \u03b1) (i j : nat) : nat \u2192 \u03b1 \n| 0       := 0\n| (m + 1) := NN.mul_aux m + (A i m * B m j)\n\ndef NN.mul [ring \u03b1] (k m n : nat) (A B : NN \u03b1) : NN \u03b1 | i j := \nNN.mul_aux A B i j m \n\nlemma N.eq_zero (a b : N \u03b1) : \n  N.eq 0 a b := forall_lt_zero _\n\nlemma N.eq_succ {n : nat} {a b : N \u03b1} : \n  a n = b n \u2192 N.eq n a b \u2192 N.eq n.succ a b := \nforall_lt_succ _ n\n\nlemma NN.eq_zero {n : nat} {A B : NN \u03b1} : \n  NN.eq 0 n A B := forall_lt_zero _\n\nlemma NN.eq_succ {m n : nat} {A B : NN \u03b1} : \n  N.eq n (A m) (B m) \u2192 NN.eq m n A B \u2192 \n  NN.eq m.succ n A B := forall_lt_succ _ m\n\nlemma NN.eq_symm {m n : nat} {A B : NN \u03b1} : \nNN.eq m n A B \u2192 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 \u03b1} : \nNN.eq m n A B \u2192 NN.eq m n B C \u2192 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 \u03b1] : list \u03b1 \u2192 nat \u2192  \u03b1 \n| []      _     := inhabited.default \u03b1\n| (a::as) 0     := a\n| (a::as) (j+1) := N.of_list as j\n\ndef NN.of_lists (\u03b1 : Type) [inhabited \u03b1] : list (list \u03b1) \u2192 NN \u03b1 \n| []      _     _ := inhabited.default \u03b1\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 \u03b1] (n : nat) :\n  decidable_rel (@N.eq \u03b1 n) := \nby {intros A B, apply forall_lt.decidable} \n\ninstance NN.eq.decidable [decidable_eq \u03b1] (m n : nat) :\n  decidable_rel (@NN.eq \u03b1 m n) := \nby {intros A B, apply forall_lt.decidable} \n\n\n/- repr -/\n\ndef N.cell_size [has_repr \u03b1] (b : N \u03b1) : nat \u2192 nat \n| 0     := 0 \n| (n+1) := max (N.cell_size n) (repr $ b n).length\n\ndef NN.cell_size [has_repr \u03b1] (A : NN \u03b1) : nat \u2192 nat \u2192 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 \u03b1] (k : nat) (b : N \u03b1) : nat \u2192 string \n| 0     := \"|\" \n| (n+1) := N.repr n ++ \" \" ++ (repr $ b n).resize k ++ \" |\"\n\ndef NN.repr_aux [has_repr \u03b1] (k : nat) (A : NN \u03b1) : nat \u2192 nat \u2192 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 \u03b1] (A : NN \u03b1) : string := \nNN.repr_aux (NN.cell_size A m n) A m n  \n\ndef N.le [has_le \u03b1] (k : nat) (v w : N \u03b1) : Prop :=\n\u2200 x < k, v x \u2264 w x \n\ninstance N.le.decidable [has_le \u03b1] [decidable_rel ((\u2264) : \u03b1 \u2192 \u03b1 \u2192 Prop)] \n  (k : nat) (v w : N \u03b1) : decidable (N.le k v w) :=\nforall_lt.decidable _ _ \n   \ndef N.zero (\u03b1 : Type) [has_zero \u03b1] : N \u03b1 := \u03bb _, 0\n\ndef N.sum [has_zero \u03b1] [has_add \u03b1] : \u2200 k : nat, \u2200 v : N \u03b1, \u03b1  \n| 0       _ := 0\n| (k + 1) v := v k + v.sum k \n\ndef dot_prod [has_zero \u03b1] [has_add \u03b1] [has_mul \u03b1] (k : nat) (v w : N \u03b1) : \u03b1 := \nN.sum k (\u03bb m, v m * w m)\n\ndef mul_vec [has_zero \u03b1] [has_add \u03b1] [has_mul \u03b1] (k : nat) (A : NN \u03b1) (x : N \u03b1) : N \u03b1 := \n\u03bb m, dot_prod k (A m) x\n\n\n/- norm -/\n\nopen tactic expr\n\n/- (N.mk_meta n) returns \u231cg : nat \u2192 \u03b1\u231d, where \u231cf j\u231d is \n   a unique metavariable for any j < n, and \u231cg j\u231d = x \n   otherwise. -/\nmeta def N.mk_meta (\u03c4x tx : expr) : nat \u2192 tactic expr \n| 0     := to_expr ``(\u03bb x : nat, (%%tx : %%\u03c4x))\n| (n+1) := \n  do gx \u2190 N.mk_meta n,\n     sx \u2190 mk_meta_var \u03c4x, \n     to_expr ``(update %%\u03c4x %%`(n) %%sx %%gx)\n\n/- (mk_meta m n) returns \u231cf : NN \u03b1\u231d, where each \n   \u231cf i j\u231d is a unique metavariable for any \n   i < m and j < n, and \u231cf i j\u231d = x otherwise. -/\nmeta def NN.mk_meta (\u03b1x ax : expr) : nat \u2192 nat \u2192 tactic expr \n| 0     _ := to_expr ``(\u03bb i j : nat, (%%ax : %%\u03b1x))\n| (m+1) n := \n  do fx \u2190 NN.mk_meta m n,\n     gx \u2190 N.mk_meta \u03b1x ax n,\n     to_expr ``(update (N %%\u03b1x) %%`(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 \u2192 tactic simp_lemmas \n| []      := return simp_lemmas.mk\n| (n::ns) := \n  do s \u2190 get_simp_lemmas ns,\n     s.add_simp n\n\nmeta def simp_mul (x : expr) : tactic (expr \u00d7 expr) := \ndo s \u2190 get_simp_lemmas mul_simp_lemmas,\n   simplify s [] x\n\n/- Return \u231ch : t = s\u231d -/\nmeta def prove_eq (\u03b1x tx ux : expr) : tactic expr := \ndo (sx,px) \u2190 simp_mul tx,\n   (rx,qx) \u2190 norm_num.derive' sx,\n   unify rx ux,\n   to_expr ``(@eq.trans %%\u03b1x %%tx %%sx %%rx %%px %%qx)\n\n/- Return \u231ch : N.eq n a b\u231d -/\nmeta def N.prove_eq (\u03b1x ax bx : expr) : nat \u2192 tactic expr\n| 0     := return `(@N.eq_zero %%\u03b1x %%ax %%bx)\n| (n+1) := \n  do px \u2190 prove_eq \u03b1x (app ax `(n)) (app bx `(n)),\n     qx \u2190 N.prove_eq n,\n     return `(@N.eq_succ %%\u03b1x %%`(n) %%ax %%bx %%px %%qx)\n\n/- Return \u231ch : NN.eq m n A B\u231d -/\nmeta def NN.prove_eq (\u03b1x Ax Bx : expr) : nat \u2192 nat \u2192 tactic expr\n| 0     n := return `(@NN.eq_zero %%\u03b1x %%`(n) %%Ax %%Bx)\n| (m+1) n :=\n  do px \u2190 N.prove_eq \u03b1x (app Ax `(m)) (app Bx `(m)) n,\n     qx \u2190 NN.prove_eq m n,\n     return `(@NN.eq_succ %%\u03b1x %%`(m) %%`(n) %%Ax %%Bx %%px %%qx)\n\n/- Return \u231cB : NN \u03b1\u231d and \u231ch : NN.eq m n A B\u231d -/\nmeta def NN.norm (\u03b1x ax Ax : expr) (m n : nat) : tactic (expr \u00d7 expr) := \ndo Bx \u2190 NN.mk_meta \u03b1x ax m n, \n   px \u2190 NN.prove_eq \u03b1x Ax Bx m n,\n   return (Bx,px)\n\nmeta def NN.equate : tactic unit :=\ndo `(@NN.eq %%\u03b1x %%mx %%nx %%Ax %%Bx) \u2190 target,\n   ax \u2190 get_default \u03b1x, \n   m \u2190 eval_expr nat mx, \n   n \u2190 eval_expr nat nx, \n   (A'x, px) \u2190 NN.norm \u03b1x ax Ax m n, \n   (B'x, qx) \u2190 NN.norm \u03b1x ax Bx m n, \n   ( do is_def_eq A'x B'x, \n        pq \u2190 to_expr ``(@NN.eq_trans %%\u03b1x %%mx %%nx %%Ax %%A'x %%Bx\n               %%px (@NN.eq_symm %%\u03b1x %%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 : \u2200 {A B C : Prop}, (A \u2228 B) \u2192 (\u00ac A \u2228 C) \u2192 B \u2228 C := by\n  intros A B C h\u2081 h\u2082\n  cases h\u2081 with\n  | inl ap => cases h\u2082 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\u2082 : \u2200 {A C: Prop}, A \u2192 (\u00ac A \u2228 C) \u2192 C := \u03bb a ornac =>\n  match ornac with\n  | Or.inl na => False.elim (na a)\n  | Or.inr c  => c\n\ntheorem resolution_thm\u2083 : \u2200 {A B: Prop}, (A \u2228 B) \u2192 \u00ac A \u2192 B := \u03bb orab na =>\n  match orab with\n  | Or.inl a => False.elim (na a)\n  | Or.inr b => b\n\ntheorem resolution_thm\u2084 : \u2200 {A : Prop}, A \u2192 \u00ac A \u2192 False := \u03bb a na => na a\n\ndef resolutionCore (firstHyp secondHyp : Ident) (pivotTerm : Term) : TacticM Unit := do\n  let fident1 \u2190 mkIdent <$> mkFreshId\n  let fident2 \u2190 mkIdent <$> mkFreshId\n  let notPivot : Term := Syntax.mkApp (mkIdent `Not) #[pivotTerm]\n  let pivotExpr     \u2190 elabTerm pivotTerm none\n  let notPivotExpr  \u2190 elabTerm notPivot none\n  let firstHypType  \u2190 inferType (\u2190 elabTerm firstHyp none)\n  let secondHypType \u2190 inferType (\u2190 elabTerm secondHyp none)\n\n  let lenGoal \u2190 getLength <$> getMainTarget\n  pullCore pivotExpr    firstHypType  firstHyp  fident1\n  pullCore notPivotExpr secondHypType secondHyp fident2\n\n  let mut len\u2081 := getLength firstHypType\n  if Option.isNone (getIndex pivotExpr firstHypType) then\n    len\u2081 := len\u2081 - (getLength pivotExpr) + 1\n\n  let len\u2082 := getLength secondHypType\n\n  if lenGoal > 2 then\n    for s in getCongAssoc (len\u2081 - 2) `orAssocConv do\n      evalTactic (\u2190 `(tactic| apply $s))\n      logInfo m!\"....apply {s}\"\n      printGoal\n\n  if len\u2081 > 1 then\n    if len\u2082 > 1 then\n      evalTactic (\u2190 `(tactic| exact resolution_thm $fident1 $fident2))\n      logInfo m!\"..close goal with resolution_thm\"\n    else\n      evalTactic (\u2190 `(tactic| exact resolution_thm\u2083 $fident1 $fident2))\n      logInfo m!\"..close goal with resolution_thm\u2083\"\n  else\n    if len\u2082 > 1 then\n      evalTactic (\u2190 `(tactic| exact resolution_thm\u2082 $fident1 $fident2))\n      logInfo m!\"..close goal with resolution_thm\u2082\"\n    else\n      evalTactic (\u2190 `(tactic| exact resolution_thm\u2084 $fident1 $fident2))\n      logInfo m!\"..close goal with resolution_thm\u2084\"\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 := \u27e8stx[1]\u27e9\n    let secondHyp : Ident := \u27e8stx[3]\u27e9\n    let pivotTerm : Term := \u27e8stx[5]\u27e9\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 := \u27e8stx[1]\u27e9\n    let secondHyp : Ident := \u27e8stx[3]\u27e9\n    let pivotTerm : Term := \u27e8stx[5]\u27e9\n    resolutionCore secondHyp firstHyp pivotTerm\n\nexample : A \u2228 B \u2228 D \u2228 (W \u2228 Z) \u2192 E \u2228 F \u2228 G \u2228 \u00ac (W \u2228 Z) \u2192 A \u2228 B \u2228 D \u2228 E \u2228 F \u2228 G := by\n  intros h\u2081 h\u2082\n  R1 h\u2081, h\u2082, (W \u2228 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\u2081 v\u2081 l \n\nnamespace Mathlib\n\n/-!\n# The Yoneda embedding\n\nThe Yoneda embedding as a functor `yoneda : C \u2964 (C\u1d52\u1d56 \u2964 Type v\u2081)`,\nalong with an instance that it is `fully_faithful`.\n\nAlso the Yoneda lemma, `yoneda_lemma : (yoneda_pairing C) \u2245 (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\u2081} [category C] : C \u2964 C\u1d52\u1d56 \u2964 Type v\u2081 :=\n  functor.mk\n    (fun (X : C) =>\n      functor.mk (fun (Y : C\u1d52\u1d56) => opposite.unop Y \u27f6 X)\n        fun (Y Y' : C\u1d52\u1d56) (f : Y \u27f6 Y') (g : opposite.unop Y \u27f6 X) => has_hom.hom.unop f \u226b g)\n    fun (X X' : C) (f : X \u27f6 X') =>\n      nat_trans.mk\n        fun (Y : C\u1d52\u1d56)\n          (g :\n          functor.obj\n            (functor.mk (fun (Y : C\u1d52\u1d56) => opposite.unop Y \u27f6 X)\n              fun (Y Y' : C\u1d52\u1d56) (f : Y \u27f6 Y') (g : opposite.unop Y \u27f6 X) => has_hom.hom.unop f \u226b g)\n            Y) =>\n          g \u226b f\n\n/--\nThe co-Yoneda embedding, as a functor from `C\u1d52\u1d56` into co-presheaves on `C`.\n-/\n@[simp] theorem coyoneda_obj_map {C : Type u\u2081} [category C] (X : C\u1d52\u1d56) (Y : C) (Y' : C) (f : Y \u27f6 Y') (g : opposite.unop X \u27f6 Y) : functor.map (functor.obj coyoneda X) f g = g \u226b f :=\n  Eq.refl (functor.map (functor.obj coyoneda X) f g)\n\nnamespace yoneda\n\n\ntheorem obj_map_id {C : Type u\u2081} [category C] {X : C} {Y : C} (f : opposite.op X \u27f6 opposite.op Y) : functor.map (functor.obj yoneda X) f \ud835\udfd9 = nat_trans.app (functor.map yoneda (has_hom.hom.unop f)) (opposite.op Y) \ud835\udfd9 := sorry\n\n@[simp] theorem naturality {C : Type u\u2081} [category C] {X : C} {Y : C} (\u03b1 : functor.obj yoneda X \u27f6 functor.obj yoneda Y) {Z : C} {Z' : C} (f : Z \u27f6 Z') (h : Z' \u27f6 X) : f \u226b nat_trans.app \u03b1 (opposite.op Z') h = nat_trans.app \u03b1 (opposite.op Z) (f \u226b h) :=\n  Eq.symm (functor_to_types.naturality (functor.obj yoneda X) (functor.obj yoneda Y) \u03b1 (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\u2081} [category C] : full yoneda :=\n  full.mk fun (X Y : C) (f : functor.obj yoneda X \u27f6 functor.obj yoneda Y) => nat_trans.app f (opposite.op X) \ud835\udfd9\n\n/--\nThe Yoneda embedding is faithful.\n\nSee https://stacks.math.columbia.edu/tag/001P.\n-/\nprotected instance yoneda_faithful {C : Type u\u2081} [category C] : faithful yoneda :=\n  faithful.mk\n\n/-- Extensionality via Yoneda. The typical usage would be\n```\n-- Goal is `X \u2245 Y`\n\n-- Goal is `X \u2245 Y`\napply yoneda.ext,\n-- Goals are now functions `(Z \u27f6 X) \u2192 (Z \u27f6 Y)`, `(Z \u27f6 Y) \u2192 (Z \u27f6 X)`, and the fact that these\n\n-- Goals are now functions `(Z \u27f6 X) \u2192 (Z \u27f6 Y)`, `(Z \u27f6 Y) \u2192 (Z \u27f6 X)`, and the fact that these\nfunctions are inverses and natural in `Z`.\n```\n-/\ndef ext {C : Type u\u2081} [category C] (X : C) (Y : C) (p : {Z : C} \u2192 (Z \u27f6 X) \u2192 (Z \u27f6 Y)) (q : {Z : C} \u2192 (Z \u27f6 Y) \u2192 (Z \u27f6 X)) (h\u2081 : \u2200 {Z : C} (f : Z \u27f6 X), q (p f) = f) (h\u2082 : \u2200 {Z : C} (f : Z \u27f6 Y), p (q f) = f) (n : \u2200 {Z Z' : C} (f : Z' \u27f6 Z) (g : Z \u27f6 X), p (f \u226b g) = f \u226b p g) : X \u2245 Y :=\n  preimage_iso (nat_iso.of_components (fun (Z : C\u1d52\u1d56) => iso.mk p q) sorry)\n\n/--\nIf `yoneda.map f` is an isomorphism, so was `f`.\n-/\ndef is_iso {C : Type u\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081} [category C] {X : C\u1d52\u1d56} {Y : C\u1d52\u1d56} (\u03b1 : functor.obj coyoneda X \u27f6 functor.obj coyoneda Y) {Z : C} {Z' : C} (f : Z' \u27f6 Z) (h : opposite.unop X \u27f6 Z') : nat_trans.app \u03b1 Z' h \u226b f = nat_trans.app \u03b1 Z (h \u226b f) := sorry\n\nprotected instance coyoneda_full {C : Type u\u2081} [category C] : full coyoneda :=\n  full.mk\n    fun (X Y : C\u1d52\u1d56) (f : functor.obj coyoneda X \u27f6 functor.obj coyoneda Y) =>\n      has_hom.hom.op (nat_trans.app f (opposite.unop X) \ud835\udfd9)\n\nprotected instance coyoneda_faithful {C : Type u\u2081} [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\u2081} [category C] {X : C\u1d52\u1d56} {Y : C\u1d52\u1d56} (f : X \u27f6 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\u1d52\u1d56 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\u2081} [category C] (P : C \u2964 Type v\u2081) (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 \u2245 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\u2081} [category C] (F : C\u1d52\u1d56 \u2964 Type v\u2081) \nwhere\n  X : C\n  w : functor.obj yoneda X \u2245 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\u2081) [category C] : category ((C\u1d52\u1d56 \u2964 Type v\u2081) \u00d7 (C\u1d52\u1d56)) :=\n  category_theory.prod (C\u1d52\u1d56 \u2964 Type v\u2081) (C\u1d52\u1d56)\n\nprotected instance prod_category_instance_2 (C : Type u\u2081) [category C] : category (C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081)) :=\n  category_theory.prod (C\u1d52\u1d56) (C\u1d52\u1d56 \u2964 Type v\u2081)\n\n/--\nThe \"Yoneda evaluation\" functor, which sends `X : C\u1d52\u1d56` and `F : C\u1d52\u1d56 \u2964 Type`\nto `F.obj X`, functorially in both `X` and `F`.\n-/\ndef yoneda_evaluation (C : Type u\u2081) [category C] : C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081) \u2964 Type (max u\u2081 v\u2081) :=\n  evaluation_uncurried (C\u1d52\u1d56) (Type v\u2081) \u22d9 ulift_functor\n\n@[simp] theorem yoneda_evaluation_map_down (C : Type u\u2081) [category C] (P : C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081)) (Q : C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081)) (\u03b1 : P \u27f6 Q) (x : functor.obj (yoneda_evaluation C) P) : ulift.down (functor.map (yoneda_evaluation C) \u03b1 x) =\n  nat_trans.app (prod.snd \u03b1) (prod.fst Q) (functor.map (prod.snd P) (prod.fst \u03b1) (ulift.down x)) :=\n  rfl\n\n/--\nThe \"Yoneda pairing\" functor, which sends `X : C\u1d52\u1d56` and `F : C\u1d52\u1d56 \u2964 Type`\nto `yoneda.op.obj X \u27f6 F`, functorially in both `X` and `F`.\n-/\ndef yoneda_pairing (C : Type u\u2081) [category C] : C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081) \u2964 Type (max u\u2081 v\u2081) :=\n  functor.prod (functor.op yoneda) \ud835\udfed \u22d9 functor.hom (C\u1d52\u1d56 \u2964 Type v\u2081)\n\n@[simp] theorem yoneda_pairing_map (C : Type u\u2081) [category C] (P : C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081)) (Q : C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081)) (\u03b1 : P \u27f6 Q) (\u03b2 : functor.obj (yoneda_pairing C) P) : functor.map (yoneda_pairing C) \u03b1 \u03b2 = functor.map yoneda (has_hom.hom.unop (prod.fst \u03b1)) \u226b \u03b2 \u226b prod.snd \u03b1 :=\n  rfl\n\n/--\nThe Yoneda lemma asserts that that the Yoneda pairing\n`(X : C\u1d52\u1d56, F : C\u1d52\u1d56 \u2964 Type) \u21a6 (yoneda.obj (unop X) \u27f6 F)`\nis naturally isomorphic to the evaluation `(X, F) \u21a6 F.obj X`.\n\nSee https://stacks.math.columbia.edu/tag/001P.\n-/\ndef yoneda_lemma (C : Type u\u2081) [category C] : yoneda_pairing C \u2245 yoneda_evaluation C :=\n  iso.mk\n    (nat_trans.mk\n      fun (F : C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081)) (x : functor.obj (yoneda_pairing C) F) => ulift.up (nat_trans.app x (prod.fst F) \ud835\udfd9))\n    (nat_trans.mk\n      fun (F : C\u1d52\u1d56 \u00d7 (C\u1d52\u1d56 \u2964 Type v\u2081)) (x : functor.obj (yoneda_evaluation C) F) =>\n        nat_trans.mk\n          fun (X : C\u1d52\u1d56)\n            (a : functor.obj (opposite.unop (prod.fst (functor.obj (functor.prod (functor.op yoneda) \ud835\udfed) F))) X) =>\n            functor.map (prod.snd F) (has_hom.hom.op a) (ulift.down x))\n\n/--\nThe isomorphism between `yoneda.obj X \u27f6 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\u2081} [category C] (X : C) (F : C\u1d52\u1d56 \u2964 Type v\u2081) : (functor.obj yoneda X \u27f6 F) \u2245 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\u2081} [category C] {X : C} {F : C\u1d52\u1d56 \u2964 Type v\u2081} : (functor.obj yoneda X \u27f6 F) \u2243 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\u2081} [category C] {X : C} {Y : C} {F : C\u1d52\u1d56 \u2964 Type v\u2081} (f : functor.obj yoneda X \u27f6 F) (g : Y \u27f6 X) : functor.map F (has_hom.hom.op g) (coe_fn yoneda_equiv f) = coe_fn yoneda_equiv (functor.map yoneda g \u226b f) := sorry\n\n@[simp] theorem yoneda_equiv_apply {C : Type u\u2081} [category C] {X : C} {F : C\u1d52\u1d56 \u2964 Type v\u2081} (f : functor.obj yoneda X \u27f6 F) : coe_fn yoneda_equiv f = nat_trans.app f (opposite.op X) \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem yoneda_equiv_symm_app_apply {C : Type u\u2081} [category C] {X : C} {F : C\u1d52\u1d56 \u2964 Type v\u2081} (x : functor.obj F (opposite.op X)) (Y : C\u1d52\u1d56) (f : opposite.unop Y \u27f6 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\u2081} [small_category C] (X : C) (F : C\u1d52\u1d56 \u2964 Type u\u2081) : (functor.obj yoneda X \u27f6 F) \u2245 functor.obj F (opposite.op X) :=\n  yoneda_sections X F \u226a\u226b ulift_trivial (functor.obj F (opposite.op X))\n\n@[simp] theorem yoneda_sections_small_hom {C : Type u\u2081} [small_category C] (X : C) (F : C\u1d52\u1d56 \u2964 Type u\u2081) (f : functor.obj yoneda X \u27f6 F) : iso.hom (yoneda_sections_small X F) f = nat_trans.app f (opposite.op X) \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem yoneda_sections_small_inv_app_apply {C : Type u\u2081} [small_category C] (X : C) (F : C\u1d52\u1d56 \u2964 Type u\u2081) (t : functor.obj F (opposite.op X)) (Y : C\u1d52\u1d56) (f : opposite.unop Y \u27f6 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\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable section\n\nopen CategoryTheory CategoryTheory.Category CategoryTheory.Limits\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {X Y Z : C}\n\nvariable {D : Type u\u2082} [Category.{v\u2082} D]\n\nnamespace CategoryTheory\n\nnamespace MonoOver\n\nsection Top\n\ninstance {X : C} : Top (MonoOver X) where top := mk' (\ud835\udfd9 _)\n\ninstance {X : C} : Inhabited (MonoOver X) :=\n  \u27e8\u22a4\u27e9\n\n/-- The morphism to the top object in `mono_over X`. -/\ndef leTop (f : MonoOver X) : f \u27f6 \u22a4 :=\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) : ((\u22a4 : 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) : (\u22a4 : MonoOver X).arrow = \ud835\udfd9 X :=\n  rfl\n#align category_theory.mono_over.top_arrow CategoryTheory.MonoOver.top_arrow\n\n/-- `map f` sends `\u22a4 : mono_over X` to `\u27e8X, f\u27e9 : mono_over Y`. -/\ndef mapTop (f : X \u27f6 Y) [Mono f] : (map f).obj \u22a4 \u2245 mk' f :=\n  iso_of_both_ways (homMk (\ud835\udfd9 _) rfl) (homMk (\ud835\udfd9 _) (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 \u27f6 Y) : (pullback f).obj \u22a4 \u2245 \u22a4 :=\n  iso_of_both_ways (leTop _) (homMk (pullback.lift f (\ud835\udfd9 _) (by tidy)) (pullback.lift_snd _ _ _))\n#align category_theory.mono_over.pullback_top CategoryTheory.MonoOver.pullbackTop\n\n/-- There is a morphism from `\u22a4 : 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 \u27f6 B) [Mono f] :\n    (\u22a4 : MonoOver A) \u27f6 (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 \u27f6 B) [Mono f] : (pullback f).obj (mk' f) \u2245 \u22a4 :=\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) : ((\u22a5 : MonoOver X) : C) = \u22a5_ C :=\n  rfl\n#align category_theory.mono_over.bot_left CategoryTheory.MonoOver.bot_left\n\n@[simp]\ntheorem bot_arrow {X : C} : (\u22a5 : 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 `\u22a5 : mono_over X` to any other `f : mono_over X`. -/\ndef botLe {X : C} (f : MonoOver X) : \u22a5 \u27f6 f :=\n  homMk (initial.to _) (by simp)\n#align category_theory.mono_over.bot_le CategoryTheory.MonoOver.botLe\n\n/-- `map f` sends `\u22a5 : mono_over X` to `\u22a5 : mono_over Y`. -/\ndef mapBot (f : X \u27f6 Y) [Mono f] : (map f).obj \u22a5 \u2245 \u22a5 :=\n  iso_of_both_ways (homMk (initial.to _) (by simp)) (homMk (\ud835\udfd9 _) (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 `\u22a5 : subobject B` is (up to isomorphism) the zero object. -/\ndef botCoeIsoZero {B : C} : ((\u22a5 : MonoOver B) : C) \u2245 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} : (\u22a5 : 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 \u2964 MonoOver A \u2964 MonoOver A\n    where\n  obj f := pullback f.arrow \u22d9 map f.arrow\n  map f\u2081 f\u2082 k :=\n    {\n      app := fun g => by\n        apply hom_mk _ _\n        apply pullback.lift pullback.fst (pullback.snd \u226b 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 \u27f6 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 \u27f6 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 \u27f6 f) \u2192 (h \u27f6 g) \u2192 (h \u27f6 (inf.obj f).obj g) :=\n  by\n  intro k\u2081 k\u2082\n  refine' hom_mk (pullback.lift k\u2082.left k\u2081.left _) _\n  rw [w k\u2081, w k\u2082]\n  erw [pullback.lift_snd_assoc, w k\u2081]\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 \u2964 MonoOver A \u2964 MonoOver A :=\n  curryObj ((forget A).Prod (forget A) \u22d9 uncurry.obj Over.coprod \u22d9 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 \u27f6 (sup.obj f).obj g :=\n  by\n  refine' hom_mk (coprod.inl \u226b 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 \u27f6 (sup.obj f).obj g :=\n  by\n  refine' hom_mk (coprod.inr \u226b 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 \u27f6 h) \u2192 (g \u27f6 h) \u2192 ((sup.obj f).obj g \u27f6 h) :=\n  by\n  intro k\u2081 k\u2082\n  refine' hom_mk _ _\n  apply image.lift \u27e8_, h.arrow, coprod.desc k\u2081.left k\u2082.left, _\u27e9\n  \u00b7 dsimp\n    ext1\n    \u00b7 simp [w k\u2081]\n    \u00b7 simp [w k\u2082]\n  \u00b7 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'' \u22a4\n  le_top := by\n    refine' Quotient.ind' fun f => _\n    exact \u27e8mono_over.le_top f\u27e9\n#align category_theory.subobject.order_top CategoryTheory.Subobject.orderTop\n\ninstance {X : C} : Inhabited (Subobject X) :=\n  \u27e8\u22a4\u27e9\n\ntheorem top_eq_id (B : C) : (\u22a4 : Subobject B) = Subobject.mk (\ud835\udfd9 B) :=\n  rfl\n#align category_theory.subobject.top_eq_id CategoryTheory.Subobject.top_eq_id\n\ntheorem underlyingIso_top_hom {B : C} : (underlyingIso (\ud835\udfd9 B)).Hom = (\u22a4 : Subobject B).arrow :=\n  by\n  convert underlying_iso_hom_comp_eq_mk (\ud835\udfd9 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 (\u22a4 : Subobject B).arrow :=\n  by\n  rw [\u2190 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 \u226b (\u22a4 : Subobject B).arrow = \ud835\udfd9 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 \u27f6 Y) [Mono f] : (map f).obj \u22a4 = Subobject.mk f :=\n  Quotient.sound' \u27e8MonoOver.mapTop f\u27e9\n#align category_theory.subobject.map_top CategoryTheory.Subobject.map_top\n\ntheorem top_factors {A B : C} (f : A \u27f6 B) : (\u22a4 : Subobject B).Factors f :=\n  \u27e8f, comp_id _\u27e9\n#align category_theory.subobject.top_factors CategoryTheory.Subobject.top_factors\n\ntheorem isIso_iff_mk_eq_top {X Y : C} (f : X \u27f6 Y) [Mono f] : IsIso f \u2194 mk f = \u22a4 :=\n  \u27e8fun _ => mk_eq_mk_of_comm _ _ (as_iso f) (category.comp_id _), fun h =>\n    by\n    rw [\u2190 of_mk_le_mk_comp h.le, category.comp_id]\n    exact is_iso.of_iso (iso_of_mk_eq_mk _ _ h)\u27e9\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 \u2194 P = \u22a4 := 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 (\u22a4 : 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 \u27f6 Y) [IsIso f] : mk f = \u22a4 :=\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 = \u22a4 :=\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 \u27f6 Y) : (pullback f).obj \u22a4 = \u22a4 :=\n  Quotient.sound' \u27e8MonoOver.pullbackTop f\u27e9\n#align category_theory.subobject.pullback_top CategoryTheory.Subobject.pullback_top\n\ntheorem pullback_self {A B : C} (f : A \u27f6 B) [Mono f] : (pullback f).obj (mk f) = \u22a4 :=\n  Quotient.sound' \u27e8MonoOver.pullbackSelf f\u27e9\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'' \u22a5\n  bot_le := by\n    refine' Quotient.ind' fun f => _\n    exact \u27e8mono_over.bot_le f\u27e9\n#align category_theory.subobject.order_bot CategoryTheory.Subobject.orderBot\n\ntheorem bot_eq_initial_to {B : C} : (\u22a5 : 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 `\u22a5 : subobject B` is (up to isomorphism) the initial object. -/\ndef botCoeIsoInitial {B : C} : ((\u22a5 : Subobject B) : C) \u2245 \u22a5_ C :=\n  underlyingIso _\n#align category_theory.subobject.bot_coe_iso_initial CategoryTheory.Subobject.botCoeIsoInitial\n\ntheorem map_bot (f : X \u27f6 Y) [Mono f] : (map f).obj \u22a5 = \u22a5 :=\n  Quotient.sound' \u27e8MonoOver.mapBot f\u27e9\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 `\u22a5 : subobject B` is (up to isomorphism) the zero object. -/\ndef botCoeIsoZero {B : C} : ((\u22a5 : Subobject B) : C) \u2245 0 :=\n  botCoeIsoInitial \u226a\u226b 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} : (\u22a5 : Subobject B) = Subobject.mk (0 : 0 \u27f6 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} : (\u22a5 : 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 \u27f6 B) : (\u22a5 : Subobject B).Factors f \u2194 f = 0 :=\n  \u27e8by\n    rintro \u27e8h, rfl\u27e9\n    simp, by\n    rintro rfl\n    exact \u27e80, by simp\u27e9\u27e9\n#align category_theory.subobject.bot_factors_iff_zero CategoryTheory.Subobject.bot_factors_iff_zero\n\ntheorem mk_eq_bot_iff_zero {f : X \u27f6 Y} [Mono f] : Subobject.mk f = \u22a5 \u2194 f = 0 :=\n  \u27e8fun 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])\u27e9\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\u1d52\u1d56 \u2964 Type`. -/\n@[simps]\ndef functor [HasPullbacks C] : C\u1d52\u1d56 \u2964 Type max u\u2081 v\u2081\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 \u2964 Subobject A \u2964 Subobject A :=\n  ThinSkeleton.map\u2082 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 \u2264 f :=\n  Quotient.inductionOn\u2082' f g fun a b => \u27e8MonoOver.infLeLeft _ _\u27e9\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 \u2264 g :=\n  Quotient.inductionOn\u2082' f g fun a b => \u27e8MonoOver.infLeRight _ _\u27e9\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 \u2264 f \u2192 h \u2264 g \u2192 h \u2264 (inf.obj f).obj g :=\n  Quotient.inductionOn\u2083' h f g\n    (by\n      rintro f g h \u27e8k\u27e9 \u27e8l\u27e9\n      exact \u27e8mono_over.le_inf _ _ _ k l\u27e9)\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 \u27f6 B}\n    (h : (X \u2293 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 \u27f6 B}\n    (h : (X \u2293 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 \u27f6 B) :\n    (X \u2293 Y).Factors f \u2194 X.Factors f \u2227 Y.Factors f :=\n  \u27e8fun h => \u27e8factors_left_of_inf_factors h, factors_right_of_inf_factors h\u27e9,\n    by\n    revert X Y\n    refine' Quotient.ind\u2082' _\n    rintro X Y \u27e8\u27e8g\u2081, rfl\u27e9, \u27e8g\u2082, hg\u2082\u27e9\u27e9\n    exact \u27e8_, pullback.lift_snd_assoc _ _ hg\u2082 _\u27e9\u27e9\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 \u2293 Y).arrow :=\n  (factors_iff _ _).mpr \u27e8ofLe (X \u2293 Y) X (inf_le_left X Y), by simp\u27e9\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 \u2293 Y).arrow :=\n  (factors_iff _ _).mpr \u27e8ofLe (X \u2293 Y) Y (inf_le_right X Y), by simp\u27e9\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 \u2192 Subobject B} (f : A \u27f6 B) :\n    (s.inf P).Factors f \u2194 \u2200 i \u2208 s, (P i).Factors f := by\n  classical\n    apply Finset.induction_on s\n    \u00b7 simp [top_factors]\n    \u00b7 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 \u2192 Subobject B) (i : I)\n    (m : i \u2208 s) : (P i).Factors (s.inf P).arrow :=\n  by\n  revert i m\n  classical\n    apply Finset.induction_on s\n    \u00b7 rintro _ \u27e8\u27e9\n    \u00b7 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      \u00b7 rw [\u2190 factor_thru_arrow _ _ (inf_arrow_factors_left _ _)]\n        exact factors_comp_arrow _\n      \u00b7 rw [\u2190 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\u2081 : MonoOver A) (f\u2082 : Subobject A) :\n    (Subobject.inf.obj (Quotient.mk'' f\u2081)).obj f\u2082 =\n      (Subobject.map f\u2081.arrow).obj ((Subobject.pullback f\u2081.arrow).obj f\u2082) :=\n  by\n  apply Quotient.inductionOn' f\u2082\n  intro f\u2082\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\u2081 : MonoOver A) (f\u2082 : Subobject A) :\n    (Quotient.mk'' f\u2081 \u2293 f\u2082 : Subobject A) = (map f\u2081.arrow).obj ((pullback f\u2081.arrow).obj f\u2082) :=\n  inf_eq_map_pullback' f\u2081 f\u2082\n#align category_theory.subobject.inf_eq_map_pullback CategoryTheory.Subobject.inf_eq_map_pullback\n\ntheorem prod_eq_inf {A : C} {f\u2081 f\u2082 : Subobject A} [HasBinaryProduct f\u2081 f\u2082] : (f\u2081 \u2a2f f\u2082) = f\u2081 \u2293 f\u2082 :=\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 \u2293 m' = (inf.obj m).obj m' :=\n  rfl\n#align category_theory.subobject.inf_def CategoryTheory.Subobject.inf_def\n\n/-- `\u2293` commutes with pullback. -/\ntheorem inf_pullback {X Y : C} (g : X \u27f6 Y) (f\u2081 f\u2082) :\n    (pullback g).obj (f\u2081 \u2293 f\u2082) = (pullback g).obj f\u2081 \u2293 (pullback g).obj f\u2082 :=\n  by\n  revert f\u2081\n  apply Quotient.ind'\n  intro f\u2081\n  erw [inf_def, inf_def, inf_eq_map_pullback', inf_eq_map_pullback', \u2190 pullback_comp, \u2190\n    map_pullback pullback.condition (pullback_is_pullback f\u2081.arrow g), \u2190 pullback_comp,\n    pullback.condition]\n  rfl\n#align category_theory.subobject.inf_pullback CategoryTheory.Subobject.inf_pullback\n\n/-- `\u2293` commutes with map. -/\ntheorem inf_map {X Y : C} (g : Y \u27f6 X) [Mono g] (f\u2081 f\u2082) :\n    (map g).obj (f\u2081 \u2293 f\u2082) = (map g).obj f\u2081 \u2293 (map g).obj f\u2082 :=\n  by\n  revert f\u2081\n  apply Quotient.ind'\n  intro f\u2081\n  erw [inf_def, inf_def, inf_eq_map_pullback', inf_eq_map_pullback', \u2190 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 \u2964 Subobject A \u2964 Subobject A :=\n  ThinSkeleton.map\u2082 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\u2082' m n fun a b => \u27e8MonoOver.leSupLeft _ _\u27e9\n    le_sup_right := fun m n => Quotient.inductionOn\u2082' m n fun a b => \u27e8MonoOver.leSupRight _ _\u27e9\n    sup_le := fun m n k =>\n      Quotient.inductionOn\u2083' m n k fun a b c \u27e8i\u27e9 \u27e8j\u27e9 => \u27e8MonoOver.supLe _ _ _ i j\u27e9 }\n\ntheorem sup_factors_of_factors_left {A B : C} {X Y : Subobject B} {f : A \u27f6 B} (P : X.Factors f) :\n    (X \u2294 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 \u27f6 B} (P : Y.Factors f) :\n    (X \u2294 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 \u2192 Subobject B} {f : A \u27f6 B}\n    (h : \u2203 i \u2208 s, (P i).Factors f) : (s.sup P).Factors f := by\n  classical\n    revert h\n    apply Finset.induction_on s\n    \u00b7 rintro \u27e8_, \u27e8\u27e8\u27e9, _\u27e9\u27e9\n    \u00b7 rintro i s nm ih \u27e8j, \u27e8m, h\u27e9\u27e9\n      simp only [Finset.sup_insert]\n      simp at m\n      rcases m with (rfl | m)\n      \u00b7 exact sup_factors_of_factors_left h\n      \u00b7 exact sup_factors_of_factors_right (ih \u27e8j, \u27e8m, h\u27e9\u27e9)\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) \u2964 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 : \u2200 g \u2208 s, f \u2264 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 \u27e8-, \u27e8g, \u27e8m, rfl\u27e9\u27e9\u27e9\n              simpa using m))))\n    (by tidy)\n#align category_theory.subobject.le_Inf_cone CategoryTheory.Subobject.leInfCone\n\n@[simp]\ntheorem leInfCone_\u03c0_app_none {A : C} (s : Set (Subobject A)) (f : Subobject A)\n    (k : \u2200 g \u2208 s, f \u2264 g) : (leInfCone s f k).\u03c0.app none = f.arrow :=\n  rfl\n#align category_theory.subobject.le_Inf_cone_\u03c0_app_none CategoryTheory.Subobject.leInfCone_\u03c0_app_none\n\nvariable [HasWidePullbacks.{v\u2081} 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\u03b9 {A : C} (s : Set (Subobject A)) : widePullback s \u27f6 A :=\n  Limits.limit.\u03c0 (wideCospan s) none\n#align category_theory.subobject.wide_pullback_\u03b9 CategoryTheory.Subobject.widePullback\u03b9\n\ninstance widePullback\u03b9_mono {A : C} (s : Set (Subobject A)) : Mono (widePullback\u03b9 s) :=\n  \u27e8fun W u v h =>\n    limit.hom_ext fun j => by\n      cases j\n      \u00b7 exact h\n      \u00b7 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\u27e9\n#align category_theory.subobject.wide_pullback_\u03b9_mono CategoryTheory.Subobject.widePullback\u03b9_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\u2093'. -/\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\u03b9 s)\n#align category_theory.subobject.Inf CategoryTheory.Subobject.inf\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (f \u00abexpr \u2208 \u00bb s) -/\ntheorem inf_le {A : C} (s : Set (Subobject A)) (f) (_ : f \u2208 s) : inf s \u2264 f :=\n  by\n  fapply le_of_comm\n  \u00b7 refine'\n      (underlying_iso _).Hom \u226b\n        limits.limit.\u03c0 (wide_cospan s)\n            (some \u27e8equivShrink _ f, Set.mem_image_of_mem (equivShrink (subobject A)) H\u27e9) \u226b\n          _\n    apply eq_to_hom\n    apply congr_arg fun X : subobject A => (X : C)\n    exact Equiv.symm_apply_apply _ _\n  \u00b7 dsimp [Inf]\n    simp only [category.comp_id, category.assoc, \u2190 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\u2093'. -/\ntheorem le_inf {A : C} (s : Set (Subobject A)) (f : Subobject A) (k : \u2200 g \u2208 s, f \u2264 g) : f \u2264 inf s :=\n  by\n  fapply le_of_comm\n  \u00b7 exact limits.limit.lift _ (le_Inf_cone s f k) \u226b (underlying_iso _).inv\n  \u00b7 dsimp [Inf, wide_pullback_\u03b9]\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\u209b := inf\n    inf_le := inf_le\n    le_inf := le_inf }\n\nend Inf\n\nsection Sup\n\nvariable [WellPowered C] [HasCoproducts.{v\u2081} 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)) : _ \u27f6 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\u2093'. -/\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.\u03b9 (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 \u00abexpr \u2208 \u00bb s) -/\ntheorem le_sup {A : C} (s : Set (Subobject A)) (f) (_ : f \u2208 s) : f \u2264 sup s :=\n  by\n  fapply le_of_comm\n  \u00b7 dsimp [Sup]\n    refine' _ \u226b factor_thru_image _ \u226b (underlying_iso _).inv\n    refine' _ \u226b sigma.\u03b9 _ \u27e8equivShrink _ f, by simpa [Set.mem_image] using H\u27e9\n    exact eq_to_hom (congr_arg (fun X : subobject A => (X : C)) (Equiv.symm_apply_apply _ _).symm)\n  \u00b7 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 {\u03b1 \u03b2 : Type _} (e : \u03b1 \u2243 \u03b2) (s : Set \u03b1) (x : \u03b2) :\n    e.symm x \u2208 s \u2194 x \u2208 e '' s :=\n  \u27e8fun h => \u27e8e.symm x, h, by simp\u27e9, by\n    rintro \u27e8a, m, rfl\u27e9\n    simpa using m\u27e9\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 : \u2200 g \u2208 s, g \u2264 f) : sup s \u2264 f :=\n  by\n  fapply le_of_comm\n  \u00b7 dsimp [Sup]\n    refine' (underlying_iso _).Hom \u226b image.lift \u27e8_, f.arrow, _, _\u27e9\n    \u00b7 refine' sigma.desc _\n      rintro \u27e8g, m\u27e9\n      refine' underlying.map (hom_of_le (k _ _))\n      simpa [symm_apply_mem_iff_mem_image] using m\n    \u00b7 ext j\n      rcases j with \u27e8j, m\u27e9\n      dsimp [small_coproduct_desc]\n      simp\n      dsimp\n      simp\n  \u00b7 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\u209b := sup\n    le_sup := le_sup\n    sup_le := sup_le }\n\nend Sup\n\nsection CompleteLattice\n\nvariable [WellPowered C] [HasWidePullbacks.{v\u2081} C] [HasImages C] [HasCoproducts.{v\u2081} 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 : \u00acIsZero X) : Nontrivial (Subobject X) :=\n  \u27e8\u27e8mk (0 : 0 \u27f6 X), mk (\ud835\udfd9 X), fun w => h (IsZero.of_iso (isZero_zero C) (isoOfMkEqMk _ _ w).symm)\u27e9\u27e9\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) \u2243o Set.Iic Y\n    where\n  toFun Z :=\n    \u27e8Subobject.mk (Z.arrow \u226b Y.arrow),\n      Set.mem_Iic.mpr (le_of_comm ((underlyingIso _).Hom \u226b Z.arrow) (by simp))\u27e9\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 [\u2190 iso.eq_inv_comp]))\n  map_rel_iff' W Z :=\n    \u27e8fun h =>\n      le_of_comm ((underlyingIso _).inv \u226b ofLe _ _ (Subtype.mk_le_mk.mp h) \u226b (underlyingIso _).Hom)\n        (by\n          ext\n          simp),\n      fun h =>\n      Subtype.mk_le_mk.mpr\n        (le_of_comm ((underlyingIso _).Hom \u226b ofLe _ _ h \u226b (underlyingIso _).inv) (by simp))\u27e9\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 \u266f tactic is never used\n-- local prefix:0 \"\u266f\" => 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 : \u2115 \u2192 Type u\n  | continue : CofixA 0\n  | intro {n} : \u2200 a, (F.B a \u2192 CofixA n) \u2192 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] : \u2200 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  \u27e8CofixA.default F n\u27e9\n\ntheorem cofixA_eq_zero : \u2200 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' : \u2200 {n}, CofixA F (succ n) \u2192 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' : \u2200 {n} (x : CofixA F (succ n)), F.B (head' x) \u2192 CofixA F n\n  | _, CofixA.intro _ f => f\n#align pfunctor.approx.children' PFunctor.Approx.children'\n\ntheorem approx_eta {n : \u2115} (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 : \u2200 {n : \u2115}, CofixA F n \u2192 CofixA F (n + 1) \u2192 Prop\n  | continu (x : CofixA F 0) (y : CofixA F 1) : Agree x y\n  | intro {n} {a} (x : F.B a \u2192 CofixA F n) (x' : F.B a \u2192 CofixA F (n + 1)) :\n    (\u2200 i : F.B a, Agree (x i) (x' i)) \u2192 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 : \u2200 n, CofixA F n) :=\n  \u2200 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 : \u2115} (x : CofixA F (succ n)) (y : CofixA F (succ n + 1)) {i j}\n    (h\u2080 : HEq i j) (h\u2081 : Agree x y) : Agree (children' x i) (children' y j) := by\n  cases' h\u2081 with _ _ _ _ _ _ hagree; cases h\u2080\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 : \u2200 {n : \u2115}, CofixA F (n + 1) \u2192 CofixA F n\n  | 0, CofixA.intro _ _ => CofixA.continue\n  | succ _, CofixA.intro i f => CofixA.intro i <| truncate \u2218 f\n#align pfunctor.approx.truncate PFunctor.Approx.truncate\n\ntheorem truncate_eq_of_agree {n : \u2115} (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  \u00b7 rfl\n  \u00b7 -- cases' h with _ _ _ _ _ h\u2080 h\u2081\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\u2081\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\u2081\n#align pfunctor.approx.truncate_eq_of_agree PFunctor.Approx.truncate_eq_of_agree\n\nvariable {X : Type w}\n\nvariable (f : X \u2192 F.Obj X)\n\n/-- `sCorec f i n` creates an approximation of height `n`\nof the final coalgebra of `f` -/\ndef sCorec : X \u2192 \u2200 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 : \u2115) : 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  \u27e8[]\u27e9\n#align pfunctor.approx.path.inhabited PFunctor.Approx.Path.inhabited\n\nopen List Nat\n\ninstance CofixA.instSubsingleton : Subsingleton (CofixA F 0) :=\n  \u27e8by rintro \u27e8\u27e9 \u27e8\u27e9; rfl\u27e9\n\ntheorem head_succ' (n m : \u2115) (x : \u2200 n, CofixA F n) (Hconsistent : AllAgree x) :\n    head' (x (succ n)) = head' (x (succ m)) := by\n  suffices \u2200 n, head' (x (succ n)) = head' (x 1) by simp [this]\n  clear m n\n  intro n\n  cases' h\u2080 : x (succ n) with _ i\u2080 f\u2080\n  cases' h\u2081 : x 1 with _ i\u2081 f\u2081\n  dsimp only [head']\n  induction' n with n n_ih\n  \u00b7 rw [h\u2081] at h\u2080\n    cases h\u2080\n    trivial\n  \u00b7 have H := Hconsistent (succ n)\n    cases' h\u2082 : x (succ n) with _ i\u2082 f\u2082\n    rw [h\u2080, h\u2082] at H\n    apply n_ih (truncate \u2218 f\u2080)\n    rw [h\u2082]\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 : \u2200 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] : \u2200 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  \u27e8{  approx := default\n      consistent := M.default_consistent _ }\u27e9\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 : \u2200 i : \u2115, 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 \u2192 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 : \u2115 => @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 : \u2115) (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' : \u2200 (x : M F) (n : \u2115), head x = head' (x.approx <| n + 1)\n  | \u27e8_, h\u27e9, _ => 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 : \u2200 (x : M F) (n : \u2115), head' (x.approx <| n + 1) = head x\n  | \u27e8_, h\u27e9, _ => 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 : \u2115) : 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 \u2192 F.Obj (M F)\n  | x => \u27e8head x, fun i => children x i\u27e9\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) : \u2200 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' : \u2115 \u2192 M F \u2192 M F \u2192 Prop\n  | trivial (x y : M F) : Agree' 0 x y\n  | step {n : \u2115} {a} (x y : F.B a \u2192 M F) {x' y'} :\n      x' = M.mk \u27e8a, x\u27e9 \u2192 y' = M.mk \u27e8a, y\u27e9 \u2192 (\u2200 i, Agree' n (x i) (y i)) \u2192 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 [\u2190 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 \u2192 Sort w} (f : \u2200 x : F.Obj <| M F, r (M.mk x)) (x : M F) : r x :=\n  suffices r (M.mk (dest x)) by\n    rw [\u2190 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 \u2192 Sort w} (x : M F) (f : \u2200 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 \u2192 Sort w} (x : M F) (f : \u2200 a f, r (M.mk \u27e8a, f\u27e9)) : r x :=\n  M.casesOn x (fun \u27e8a, g\u27e9 => 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 \u2192 M F) (i : \u2115) :\n    (M.mk \u27e8a, f\u27e9).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 : \u2115} (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 : \u2115} (x y : M F) :\n    Agree (x.approx n) (y.approx <| n + 1) \u2194 Agree' n x y := by\n  constructor <;> intro h\n  \u00b7 induction' n with _ n_ih generalizing x y\n    constructor\n    \u00b7 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  \u00b7 induction' n with _ n_ih generalizing x y\n    constructor\n    \u00b7 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 \u2039M.mk \u27e8x_a, x_f\u27e9 = M.mk \u27e8a, x'\u27e9\u203a\n      cases h_a_1\n      replace h_a_2 := mk_inj \u2039M.mk \u27e8y_a, y_f\u27e9 = M.mk \u27e8a, y'\u27e9\u203a\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 \u2192 Sort _} (x : F.Obj <| M F) (f : \u2200 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 \u2192 Sort _} (x : F.Obj <| M F) (f : \u2200 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 \u2192 Sort _} {a} (x : F.B a \u2192 M F)\n                    (f : \u2200 (a) (f : F.B a \u2192 M F), r (M.mk \u27e8a, f\u27e9)) :\n    PFunctor.M.casesOn' (M.mk \u27e8a, x\u27e9) f = f a x :=\n  @cases_mk F r \u27e8a, x\u27e9 (fun \u27e8a, g\u27e9 => 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 \u2192 M F \u2192 Prop\n  | nil (x : M F) : IsPath [] x\n  |\n  cons (xs : Path F) {a} (x : M F) (f : F.B a \u2192 M F) (i : F.B a) :\n    x = M.mk \u27e8a, f\u27e9 \u2192 IsPath xs (f i) \u2192 IsPath (\u27e8a, i\u27e9 :: 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 \u2192 M F} {i : F.B a'} :\n    IsPath (\u27e8a', i\u27e9 :: xs) (M.mk \u27e8a, f\u27e9) \u2192 a = a' := by\n  generalize h : M.mk \u27e8a, f\u27e9 = x\n  rintro (_ | \u27e8_, _, _, _, rfl, _\u27e9)\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 \u2192 M F} {i : F.B a} :\n    IsPath (\u27e8a, i\u27e9 :: xs) (M.mk \u27e8a, f\u27e9) \u2192 IsPath xs (f i) := by\n  generalize h : M.mk \u27e8a, f\u27e9 = x\n  rintro (_ | \u27e8_, _, _, _, rfl, hp\u27e9)\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 \u2192 M F \u2192 M F\n  | [], x => x\n  | \u27e8a, i\u27e9 :: 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 (\u03b1 := 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 \u2192 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 : \u00acIsPath ps x) : iselect ps x = head default := by\n  induction' ps with ps_hd ps_tail ps_ih generalizing x\n  \u00b7 exfalso\n    apply h\n    constructor\n  \u00b7 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\u22a2\n    by_cases h'' : a = x_a\n    subst x_a\n    \u00b7 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    \u00b7 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 \u2192 M F) (i : F.B (head (M.mk \u27e8a, x\u27e9))) :\n    children (M.mk \u27e8a, x\u27e9) 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 \u2192 M F)\n    {i : F.B a} : isubtree (\u27e8_, i\u27e9 :: ps) (M.mk \u27e8a, f\u27e9) = 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 \u2192 M F) :\n    iselect nil (M.mk \u27e8a, f\u27e9) = 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 \u2192 M F) {i} :\n    iselect (\u27e8a, i\u27e9 :: ps) (M.mk \u27e8a, f\u27e9) = 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 \u2192 F.Obj X) (x\u2080 : X) : M.corec f x\u2080 = M.mk (M.corec f <$> f x\u2080) := by\n  dsimp only [M.corec, M.mk]\n  congr with n\n  cases' n with n\n  \u00b7 dsimp only [sCorec, Approx.sMk]\n  \u00b7 dsimp only [sCorec, Approx.sMk]\n    cases h : f x\u2080\n    dsimp only [(\u00b7 <$> \u00b7), 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 : \u2115} (x y z : M F) (hx : Agree' n z x)\n    (hy : Agree' n z y) (hrec : \u2200 ps : Path F, n = ps.length \u2192 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  \u00b7 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  \u00b7 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 \u2039_\u203a; cases this)\n    rename_i n_ih a f\u2083 f\u2082 hAgree\u2082 _ _ h\u2082 _ _ f\u2081 h\u2081 hAgree\u2081 clr\n    simp only [approx_mk, true_and_iff, eq_self_iff_true, heq_iff_eq]\n\n    have := mk_inj h\u2081\n    cases this; clear h\u2081\n    have := mk_inj h\u2082\n    cases this; clear h\u2082\n\n    congr\n    ext i\n    apply n_ih\n    \u00b7 solve_by_elim\n    \u00b7 solve_by_elim\n    introv h\n    specialize hrec (\u27e8_, i\u27e9 :: 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 : \u2200 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  \u00b7 cases x.approx 0\n    cases y.approx 0\n    constructor\n  \u00b7 apply ext_aux x y x\n    \u00b7 rw [\u2190 agree_iff_agree']\n      apply x.consistent\n    \u00b7 rw [\u2190 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 \u2192 M F \u2192 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 : \u2200 {a a'} {f f'}, M.mk \u27e8a, f\u27e9 ~ M.mk \u27e8a', f'\u27e9 \u2192 a = a'\n  /-- The tails are equal -/\n  tail : \u2200 {a} {f f' : F.B a \u2192 M F}, M.mk \u27e8a, f\u27e9 ~ M.mk \u27e8a, f'\u27e9 \u2192 \u2200 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\u2081 s\u2082) (ps : Path F) :\n    (R s\u2081 s\u2082) \u2192\n      IsPath ps s\u2081 \u2228 IsPath ps s\u2082 \u2192\n        iselect ps s\u2081 = iselect ps s\u2082 \u2227\n          \u2203 (a : _)(f f' : F.B a \u2192 M F),\n            isubtree ps s\u2081 = M.mk \u27e8a, f\u27e9 \u2227\n              isubtree ps s\u2082 = M.mk \u27e8a, f'\u27e9 \u2227 \u2200 i : F.B a, f i ~ f' i := by\n  intro h\u2080 hh\n  induction' s\u2081 using PFunctor.M.casesOn' with a f\n  rename_i h\u2081 hh\u2081\n  induction' s\u2082 using PFunctor.M.casesOn' with a' f'\n  rename_i h\u2081' hh\u2081' h\u2082 hh\u2082\n  clear h\u2081 hh\u2081 h\u2082 hh\u2082 hh\u2081'\n  obtain rfl : a = a' := bisim.head h\u2080\n  induction' ps with i ps ps_ih generalizing a f f'\n  \u00b7 exists rfl, a, f, f', rfl, rfl\n    apply bisim.tail h\u2080\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\u22a2\n  have h\u2081 := bisim.tail h\u2080 i\n  induction' h : f i using PFunctor.M.casesOn' with a\u2080 f\u2080\n  induction' h' : f' i using PFunctor.M.casesOn' with a\u2081 f\u2081\n  simp only [h, h', isubtree_cons] at ps_ih\u22a2\n  rw [h, h'] at h\u2081\n  obtain rfl : a\u2080 = a\u2081 := bisim.head h\u2081\n  apply ps_ih _ _ _ h\u2081\n  rw [\u2190 h, \u2190 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) : \u2200 s\u2081 s\u2082, R s\u2081 s\u2082 \u2192 s\u2081 = s\u2082 := by\n  inhabit M F\n  introv Hr; apply ext\n  introv\n  by_cases h : IsPath ps s\u2081 \u2228 IsPath ps s\u2082\n  \u00b7 have H := nth_of_bisim R bisim _ _ ps Hr h\n    exact H.left\n  \u00b7 rw [not_or] at h\n    cases' h with h\u2080 h\u2081\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\u2080 : X) (f : X \u2192 F.Obj X) : M F :=\n  M.corec f x\u2080\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.corec_on PFunctor.M.corecOn\n\nvariable {P : PFunctor.{u}} {\u03b1 : Type u}\n\ntheorem dest_corec (g : \u03b1 \u2192 P.Obj \u03b1) (x : \u03b1) : 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 \u2192 M P \u2192 Prop)\n    (h : \u2200 x y, R x y \u2192 \u2203 a f f', M.dest x = \u27e8a, f\u27e9 \u2227 M.dest y = \u27e8a, f'\u27e9 \u2227 \u2200 i, R (f i) (f' i)) :\n    \u2200 x y, R x y \u2192 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 \u27e8a'', g, g', h\u2080, h\u2081, h\u2082\u27e9 <;> clear h\n  \u00b7 replace h\u2080 := congr_arg Sigma.fst h\u2080\n    replace h\u2081 := congr_arg Sigma.fst h\u2081\n    simp only [dest_mk] at h\u2080 h\u2081\n    rw [h\u2080, h\u2081]\n  \u00b7 simp only [dest_mk] at h\u2080 h\u2081\n    cases h\u2080\n    cases h\u2081\n    apply h\u2082\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.bisim PFunctor.M.bisim\n\ntheorem bisim' {\u03b1 : Type _} (Q : \u03b1 \u2192 Prop) (u v : \u03b1 \u2192 M P)\n    (h : \u2200 x, Q x \u2192 \u2203 a f f',\n          M.dest (u x) = \u27e8a, f\u27e9\n          \u2227 M.dest (v x) = \u27e8a, f'\u27e9\n          \u2227 \u2200 i, \u2203 x', Q x' \u2227 f i = u x' \u2227 f' i = v x'\n      ) :\n    \u2200 x, Q x \u2192 u x = v x := fun x Qx =>\n  let R := fun w z : M P => \u2203 x', Q x' \u2227 w = u x' \u2227 z = v x'\n  @M.bisim P R\n    (fun _ _ \u27e8x', Qx', xeq, yeq\u27e9 =>\n      let \u27e8a, f, f', ux'eq, vx'eq, h'\u27e9 := h x' Qx'\n      \u27e8a, f, f', xeq.symm \u25b8 ux'eq, yeq.symm \u25b8 vx'eq, h'\u27e9)\n    _ _ \u27e8x, Qx, rfl, rfl\u27e9\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 \u2192 M P \u2192 Prop)\n    (h : \u2200 x y, R x y \u2192 \u2203 a f f', M.dest x = \u27e8a, f\u27e9 \u2227 M.dest y = \u27e8a, f'\u27e9 \u2227 \u2200 i, R (f i) (f' i)) :\n    \u2200 x y, R x y \u2192 x = y := fun x y Rxy =>\n  let Q : M P \u00d7 M P \u2192 Prop := fun p => R p.fst p.snd\n  bisim' Q Prod.fst Prod.snd\n    (fun p Qp =>\n      let \u27e8a, f, f', hx, hy, h'\u27e9 := h p.fst p.snd Qp\n      \u27e8a, f, f', hx, hy, fun i => \u27e8\u27e8f i, f' i\u27e9, h' i, rfl, rfl\u27e9\u27e9)\n    \u27e8x, y\u27e9 Rxy\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.bisim_equiv PFunctor.M.bisim_equiv\n\ntheorem corec_unique (g : \u03b1 \u2192 P.Obj \u03b1) (f : \u03b1 \u2192 M P) (hyp : \u2200 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\u2080 : M.dest (f x) = \u27e8a, f \u2218 f'\u27e9 := by rw [hyp, gxeq, PFunctor.map_eq]\n  have h\u2081 : M.dest (M.corec g x) = \u27e8a, M.corec g \u2218 f'\u27e9 := by rw [dest_corec, gxeq, PFunctor.map_eq]\n  refine' \u27e8_, _, _, h\u2080, h\u2081, _\u27e9\n  intro i\n  exact \u27e8f' i, trivial, rfl, rfl\u27e9\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\u2081 {\u03b1 : Type u} (F : \u2200 X, (\u03b1 \u2192 X) \u2192 \u03b1 \u2192 P.Obj X) : \u03b1 \u2192 M P :=\n  M.corec (F _ id)\nset_option linter.uppercaseLean3 false in\n#align pfunctor.M.corec\u2081 PFunctor.M.corec\u2081\n\n/-- corecursor where it is possible to return a fully formed value at any point\nof the computation -/\ndef corec' {\u03b1 : Type u} (F : \u2200 {X : Type u}, (\u03b1 \u2192 X) \u2192 \u03b1 \u2192 Sum (M P) (P.Obj X)) (x : \u03b1) : M P :=\n  corec\u2081\n    (fun _ rec (a : Sum (M P) \u03b1) =>\n      let y := a >>= F (rec \u2218 Sum.inr)\n      match y with\n      | Sum.inr y => y\n      | Sum.inl y => (rec \u2218 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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u224c chain_complex C \u2115`\nfor a pseudoabelian category `C` from the equivalence\n`karoubi (simplicial_object C) \u224c karoubi (chain_complex C \u2115)` and the two\nequivalences `simplicial_object C \u2245 karoubi (simplicial_object C)` and\n`chain_complex C \u2115 \u2245 karoubi (chain_complex C \u2115)`.\n\nIt is certainly possible to get an equivalence `simplicial_object C \u224c chain_complex C \u2115`\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`\u0393\u2080 : simplicial_object C \u2964 chain_complex C \u2115` which was constructed in `functor_gamma.lean`.\n\nIn this file, given four categories `A`, `A'`, `B`, `B'`, equivalences `eA : A \u2245 A'`,\n`eB : B \u2245 B'`, `e' : A' \u2245 B'`, functors `F : A \u2964 B'`, `G : B \u2964 A` equipped with certain\ncompatibilities, we construct successive equivalences:\n- `equivalence\u2080` from `A` to `B'`, which is the composition of `eA` and `e'`.\n- `equivalence\u2081` from `A` to `B'`, with the same inverse functor as `equivalence\u2080`,\nbut whose functor is `F`.\n- `equivalence\u2082` from `A` to `B`, which is the composition of `equivalence\u2081` and the\ninverse of `eB`:\n- `equivalence` from `A` to `B`, which has the same functor `F \u22d9 eB.inverse` as `equivalence\u2082`,\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 \u224c A') (eB : B \u224c B') (e' : A' \u224c B')\n  {F : A \u2964 B'} (hF : eA.functor \u22d9 e'.functor \u2245 F)\n  {G : B \u2964 A} (hG : eB.functor \u22d9 e'.inverse \u2245 G \u22d9 eA.functor)\n\n/-- A basic equivalence `A \u2245 B'` obtained by composing `eA : A \u2245 A'` and `e' : A' \u2245 B'`. -/\n@[simps functor inverse unit_iso_hom_app]\ndef equivalence\u2080 : A \u224c B' := eA.trans e'\n\ninclude hF\nvariables {eA} {e'}\n\n/-- An intermediate equivalence `A \u2245 B'` whose functor is `F` and whose inverse is\n`e'.inverse \u22d9 eA.inverse`. -/\n@[simps functor]\ndef equivalence\u2081 : A \u224c B' :=\nbegin\n  letI : is_equivalence F :=\n    is_equivalence.of_iso hF (is_equivalence.of_equivalence (equivalence\u2080 eA e')),\n  exact F.as_equivalence,\nend\n\nlemma equivalence\u2081_inverse : (equivalence\u2081 hF).inverse = e'.inverse \u22d9 eA.inverse := rfl\n\n/-- The counit isomorphism of the equivalence `equivalence\u2081` between `A` and `B'`. -/\n@[simps]\ndef equivalence\u2081_counit_iso :\n  (e'.inverse \u22d9 eA.inverse) \u22d9 F \u2245 \ud835\udfed B' :=\ncalc (e'.inverse \u22d9 eA.inverse) \u22d9 F\n  \u2245 (e'.inverse \u22d9 eA.inverse) \u22d9 (eA.functor \u22d9 e'.functor) : iso_whisker_left _ hF.symm\n... \u2245 e'.inverse \u22d9 (eA.inverse \u22d9 eA.functor) \u22d9 e'.functor : iso.refl _\n... \u2245 e'.inverse \u22d9 \ud835\udfed _ \u22d9 e'.functor : iso_whisker_left _ (iso_whisker_right eA.counit_iso _)\n... \u2245 e'.inverse \u22d9 e'.functor : iso.refl _\n... \u2245 \ud835\udfed B' : e'.counit_iso\n\nlemma equivalence\u2081_counit_iso_eq : (equivalence\u2081 hF).counit_iso = equivalence\u2081_counit_iso hF :=\nbegin\n  ext Y,\n  dsimp [equivalence\u2080, equivalence\u2081, is_equivalence.inverse, is_equivalence.of_equivalence],\n  simp only [equivalence\u2081_counit_iso_hom_app, category_theory.functor.map_id, comp_id],\nend\n\n/-- The unit isomorphism of the equivalence `equivalence\u2081` between `A` and `B'`. -/\n@[simps]\ndef equivalence\u2081_unit_iso :\n  \ud835\udfed A \u2245 F \u22d9 (e'.inverse \u22d9 eA.inverse) :=\ncalc \ud835\udfed A \u2245 eA.functor \u22d9 eA.inverse : eA.unit_iso\n... \u2245 eA.functor \u22d9 \ud835\udfed A' \u22d9 eA.inverse : iso.refl _\n... \u2245 eA.functor \u22d9 (e'.functor \u22d9 e'.inverse) \u22d9 eA.inverse :\n  iso_whisker_left _ (iso_whisker_right e'.unit_iso _)\n... \u2245 (eA.functor \u22d9 e'.functor) \u22d9 (e'.inverse \u22d9 eA.inverse) : iso.refl _\n... \u2245 F \u22d9 (e'.inverse \u22d9 eA.inverse) : iso_whisker_right hF _\n\nlemma equivalence\u2081_unit_iso_eq : (equivalence\u2081 hF).unit_iso = equivalence\u2081_unit_iso hF :=\nbegin\n  ext X,\n  dsimp [equivalence\u2080, equivalence\u2081, nat_iso.hcomp,\n    is_equivalence.of_equivalence],\n  simp only [id_comp, assoc, equivalence\u2081_unit_iso_hom_app],\nend\n\ninclude eB\n\n/-- An intermediate equivalence `A \u2245 B` obtained as the composition of `equivalence\u2081` and\nthe inverse of `eB : B \u224c B'`. -/\n@[simps functor]\ndef equivalence\u2082 : A \u224c B := (equivalence\u2081 hF).trans eB.symm\n\nlemma equivalence\u2082_inverse : (equivalence\u2082 eB hF).inverse =\n  eB.functor \u22d9 e'.inverse \u22d9 eA.inverse := rfl\n\n/-- The counit isomorphism of the equivalence `equivalence\u2082` between `A` and `B`. -/\n@[simps]\ndef equivalence\u2082_counit_iso :\n  (eB.functor \u22d9 e'.inverse \u22d9 eA.inverse) \u22d9 (F \u22d9 eB.inverse) \u2245 \ud835\udfed B :=\ncalc (eB.functor \u22d9 e'.inverse \u22d9 eA.inverse) \u22d9 (F \u22d9 eB.inverse)\n  \u2245 eB.functor \u22d9 (e'.inverse \u22d9 eA.inverse \u22d9 F) \u22d9 eB.inverse : iso.refl _\n... \u2245 eB.functor \u22d9 \ud835\udfed _ \u22d9 eB.inverse :\n  iso_whisker_left _ (iso_whisker_right (equivalence\u2081_counit_iso hF) _)\n... \u2245 eB.functor \u22d9 eB.inverse : iso.refl _\n... \u2245 \ud835\udfed B : eB.unit_iso.symm\n\n\n\n/-- The unit isomorphism of the equivalence `equivalence\u2082` between `A` and `B`. -/\n@[simps]\ndef equivalence\u2082_unit_iso :\n  \ud835\udfed A \u2245 (F \u22d9 eB.inverse) \u22d9 (eB.functor \u22d9 e'.inverse \u22d9 eA.inverse) :=\ncalc \ud835\udfed A \u2245 F \u22d9 e'.inverse \u22d9 eA.inverse : equivalence\u2081_unit_iso hF\n... \u2245 F \u22d9 \ud835\udfed B' \u22d9 (e'.inverse \u22d9 eA.inverse) : iso.refl _\n... \u2245 F \u22d9 (eB.inverse \u22d9 eB.functor) \u22d9 e'.inverse \u22d9 eA.inverse :\n  iso_whisker_left _ (iso_whisker_right eB.counit_iso.symm _)\n... \u2245 (F \u22d9 eB.inverse) \u22d9 (eB.functor \u22d9 e'.inverse \u22d9 eA.inverse) : iso.refl _\n\nlemma equivalence\u2082_unit_iso_eq :\n  (equivalence\u2082 eB hF).unit_iso = equivalence\u2082_unit_iso eB hF :=\nbegin\n  ext X,\n  dsimp [equivalence\u2082],\n  simpa only [equivalence\u2082_unit_iso_hom_app, equivalence\u2081_unit_iso_eq,\n    equivalence\u2081_unit_iso_hom_app, assoc, nat_iso.cancel_nat_iso_hom_left],\nend\n\nvariable {eB}\ninclude hG\n\n/-- The equivalence `A \u2245 B` whose functor is `F \u22d9 eB.inverse` and\nwhose inverse is `G : B \u2245 A`. -/\n@[simps inverse]\ndef equivalence : A \u224c B :=\nbegin\n  letI : is_equivalence G := begin\n    refine is_equivalence.of_iso _ (is_equivalence.of_equivalence (equivalence\u2082 eB hF).symm),\n    calc eB.functor \u22d9 e'.inverse \u22d9 eA.inverse\n      \u2245 (eB.functor \u22d9 e'.inverse) \u22d9 eA.inverse : iso.refl _\n    ... \u2245 (G \u22d9 eA.functor) \u22d9 eA.inverse : iso_whisker_right hG _\n    ... \u2245 G \u22d9 \ud835\udfed A : iso_whisker_left _ eA.unit_iso.symm\n    ... \u2245 G : functor.right_unitor G,\n  end,\n  exact G.as_equivalence.symm,\nend\n\nlemma equivalence_functor : (equivalence hF hG).functor = F \u22d9 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} (\ud835\udfed T) (\ud835\udfed T)\n\n-- Satisfying the inhabited linter\ninstance arrow.inhabited [inhabited T] : inhabited (arrow T) :=\n{ default := show comma (\ud835\udfed T) (\ud835\udfed T), from default (comma (\ud835\udfed T) (\ud835\udfed T)) }\n\nend\n\nnamespace arrow\n\n@[simp] lemma id_left (f : arrow T) : comma_morphism.left (\ud835\udfd9 f) = \ud835\udfd9 (f.left) := rfl\n@[simp] lemma id_right (f : arrow T) : comma_morphism.right (\ud835\udfd9 f) = \ud835\udfd9 (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 \u27f6 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 \u27f6 B) \u2192 arrow T) :=\n\u03bb f g h, by { cases h, refl }\n\ntheorem mk_inj (A B : T) {f g : A \u27f6 B} : arrow.mk f = arrow.mk g \u2194 f = g :=\n(mk_injective A B).eq_iff\ninstance {X Y : T} : has_coe (X \u27f6 Y) (arrow T) := \u27e8mk\u27e9\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 \u27f6 g.left} {v : f.right \u27f6 g.right}\n  (w : u \u226b g.hom = f.hom \u226b v) : f \u27f6 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 \u27f6 Y} {P Q : T} {g : P \u27f6 Q} {u : X \u27f6 P} {v : Y \u27f6 Q}\n  (w : u \u226b g = f \u226b v) : arrow.mk f \u27f6 arrow.mk g :=\n{ left := u,\n  right := v,\n  w' := w }\n\n@[simp, reassoc] lemma w {f g : arrow T} (sq : f \u27f6 g) : sq.left \u226b g.hom = f.hom \u226b 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 \u27f6 Y} (sq : f \u27f6 mk g) :\n  sq.left \u226b g = f.hom \u226b sq.right :=\nsq.w\n\nlemma is_iso_of_iso_left_of_is_iso_right\n  {f g : arrow T} (ff : f \u27f6 g) [is_iso ff.left] [is_iso ff.right] : is_iso ff :=\n{ out := \u27e8\u27e8inv ff.left, inv ff.right\u27e9,\n          by { ext; dsimp; simp only [is_iso.hom_inv_id] },\n          by { ext; dsimp; simp only [is_iso.inv_hom_id] }\u27e9 }\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 \u2245 g.left) (r : f.right \u2245 g.right) (h : l.hom \u226b g.hom = f.hom \u226b r.hom) :\n  f \u2245 g :=\ncomma.iso_mk l r h\n\nsection\n\nvariables {f g : arrow T} (sq : f \u27f6 g)\n\ninstance is_iso_left [is_iso sq] : is_iso sq.left :=\n{ out := \u27e8(inv sq).left, by simp only [\u2190 comma.comp_left, is_iso.hom_inv_id, is_iso.inv_hom_id,\n    arrow.id_left, eq_self_iff_true, and_self]\u27e9 }\n\ninstance is_iso_right [is_iso sq] : is_iso sq.right :=\n{ out := \u27e8(inv sq).right, by simp only [\u2190 comma.comp_right, is_iso.hom_inv_id, is_iso.inv_hom_id,\n    arrow.id_right, eq_self_iff_true, and_self]\u27e9 }\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 [\u2190 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 [\u2190 comma.comp_right, is_iso.hom_inv_id, id_right]\n\n@[simp] lemma left_hom_inv_right [is_iso sq] : sq.left \u226b g.hom \u226b inv sq.right = f.hom :=\nby simp only [\u2190 category.assoc, is_iso.comp_inv_eq, w]\n\n-- simp proves this\nlemma inv_left_hom_right [is_iso sq] : inv sq.left \u226b f.hom \u226b 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 := \u03bb Z \u03c6 \u03c8 h, begin\n    let aux : (Z \u27f6 f.left) \u2192 (arrow.mk (\ud835\udfd9 Z) \u27f6 f) := \u03bb \u03c6, { left := \u03c6, right := \u03c6 \u226b f.hom },\n    show (aux \u03c6).left = (aux \u03c8).left,\n    congr' 1,\n    rw \u2190 cancel_mono sq,\n    ext,\n    { exact h },\n    { simp only [comma.comp_right, category.assoc, \u2190 arrow.w],\n      simp only [\u2190 category.assoc, h], },\n  end }\n\ninstance epi_right [epi sq] : epi sq.right :=\n{ left_cancellation := \u03bb Z \u03c6 \u03c8 h, begin\n    let aux : (g.right \u27f6 Z) \u2192 (g \u27f6 arrow.mk (\ud835\udfd9 Z)) := \u03bb \u03c6, { right := \u03c6, left := g.hom \u226b \u03c6 },\n    show (aux \u03c6).right = (aux \u03c8).right,\n    congr' 1,\n    rw \u2190 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 \u2245 Y) (sq : i \u27f6 arrow.mk p.hom) :\n  i.hom \u226b sq.right \u226b 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 \u2245 Y) (p : arrow T) (sq : arrow.mk i.hom \u27f6 p) :\n  i.inv \u226b sq.left \u226b 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 \u27f6 g) :=\n(lift : f.right \u27f6 g.left)\n(fac_left' : f.hom \u226b lift = sq.left . obviously)\n(fac_right' : lift \u226b 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 (\ud835\udfd9 (arrow.mk (\ud835\udfd9 X)))) :=\n\u27e8\u27e8\ud835\udfd9 _, category.id_comp _, category.comp_id _\u27e9\u27e9\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 \u27f6 g) : Prop :=\nmk' :: (exists_lift : nonempty (lift_struct sq))\n\nlemma has_lift.mk {f g : arrow T} {sq : f \u27f6 g} (s : lift_struct sq) : has_lift sq :=\n\u27e8nonempty.intro s\u27e9\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 \u27f6 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 \u27f6 g) [has_lift sq] : f.right \u27f6 g.left :=\n(has_lift.struct sq).lift\n\nlemma lift.fac_left {f g : arrow T} (sq : f \u27f6 g) [has_lift sq] : f.hom \u226b lift sq = sq.left :=\nby simp\n\nlemma lift.fac_right {f g : arrow T} (sq : f \u27f6 g) [has_lift sq] : lift sq \u226b 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 \u27f6 Y} (sq : f \u27f6 mk g) [has_lift sq] :\n  lift sq \u226b g = sq.right :=\nby simp only [\u2190mk_hom g, lift.fac_right]\n\n@[simp, reassoc]\nlemma lift.fac_left_of_from_mk {X Y : T} {f : X \u27f6 Y} {g : arrow T} (sq : mk f \u27f6 g) [has_lift sq] :\n  f \u226b lift sq = sq.left :=\nby simp only [\u2190mk_hom f, lift.fac_left]\n\n@[simp, reassoc]\nlemma lift_mk'_left {X Y P Q : T} {f : X \u27f6 Y} {g : P \u27f6 Q} {u : X \u27f6 P} {v : Y \u27f6 Q}\n  (h : u \u226b g = f \u226b v) [has_lift $ arrow.hom_mk' h] : f \u226b lift (arrow.hom_mk' h) = u :=\nby simp only [\u2190arrow.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 \u27f6 Y} {g : P \u27f6 Q} {u : X \u27f6 P} {v : Y \u27f6 Q}\n  (h : u \u226b g = f \u226b v) [has_lift $ arrow.hom_mk' h] : lift (arrow.hom_mk' h) \u226b g = v :=\nby simp only [\u2190arrow.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 \u27f6 g) [epi f.hom] :\n  subsingleton (lift_struct sq) :=\nsubsingleton.intro $ \u03bb 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 \u27f6 g) [mono g.hom] :\n  subsingleton (lift_struct sq) :=\nsubsingleton.intro $ \u03bb 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 \u226b g`, produce a square between\n`i` and `g`, whose top leg uses `f`:\nA  \u2192 X\n     \u2193f\n\u2193i   Y             --> A \u2192 Y\n     \u2193g                \u2193i  \u2193g\nB  \u2192 Z                 B \u2192 Z\n -/\n@[simps] def square_to_snd {X Y Z: C} {i : arrow C} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (sq : i \u27f6 arrow.mk (f \u226b g)) :\n  i \u27f6 arrow.mk g :=\n{ left := sq.left \u226b f,\n  right := sq.right }\n\n/-- The functor sending an arrow to its source. -/\n@[simps] def left_func : arrow C \u2964 C := comma.fst _ _\n\n/-- The functor sending an arrow to its target. -/\n@[simps] def right_func : arrow C \u2964 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 \u2964 C) \u27f6 right_func :=\n{ app := \u03bb f, f.hom }\n\nend arrow\n\nnamespace functor\n\nuniverses v\u2081 v\u2082 u\u2081 u\u2082\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `C \u2964 D` induces a functor between the corresponding arrow categories. -/\n@[simps]\ndef map_arrow (F : C \u2964 D) : arrow C \u2964 arrow D :=\n{ obj := \u03bb a,\n  { left := F.obj a.left,\n    right := F.obj a.right,\n    hom := F.map a.hom, },\n  map := \u03bb 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 [\u2190F.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 \u2113' \u2113 \u2113obj \u2113hom\n\n\n\n/- -----------------------------------------------------------------------\nConstant homs.\n----------------------------------------------------------------------- -/\n\n/-! #brief A constant hom in LeanCat.\n-/\ndefinition LeanCat.const_hom\n    {X Y : LeanCat.{\u2113}^.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.{\u2113obj \u2113hom} LeanCat.{max \u2113 \u2113obj}\n:= { has_limit\n      := \u03bb X L\n         , HasLimit.show\n            { g : \u2200 (x : X^.obj), L^.obj x\n               // \u2200 {x\u2081 x\u2082 : X^.obj} (f : X^.hom x\u2081 x\u2082)\n                  , g x\u2082 = L^.hom f (g x\u2081)\n            }\n            (\u03bb x g, g^.val x)\n            (\u03bb x\u2081 x\u2082 f, funext (\u03bb g, g^.property f))\n            (\u03bb C hom \u03c9hom c\n             , { val := \u03bb x, hom x c\n               , property := \u03bb x\u2081 x\u2082 f, begin rw \u03c9hom f, trivial end\n               })\n            (\u03bb C hom \u03c9hom x, rfl)\n            (\u03bb C hom \u03c9hom f \u03c9f\n             , funext (\u03bb c, subtype.eq (funext (\u03bb x, eq.symm (by apply congr_fun (\u03c9f x) c)))))\n   }\n\n/-! #brief The equivalence relation underlying colimits in LeanCat.\n-/\ndefinition LeanCat.HasAllCoLimits.prop {X : Cat.{\u2113obj \u2113hom}}\n    (L : Fun X LeanCat.{max \u2113 \u2113obj})\n    (a b : (\u03a3 (x : X^.obj), L^.obj x))\n    : Prop\n:= \u2203 (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.{\u2113obj \u2113hom} LeanCat.{max \u2113 \u2113obj}\n:= { has_colimit\n      := \u03bb X L\n         , HasCoLimit.show\n            (quot (LeanCat.HasAllCoLimits.prop L))\n            (\u03bb x Lx, quot.mk _ {fst := x, snd := Lx})\n            (\u03bb x\u2081 x\u2082 f, funext (\u03bb Lx, quot.sound (exists.intro f rfl)))\n            (\u03bb C hom \u03c9hom\n             , let f : (\u03a3 (x : X^.obj), L^.obj x) \u2192 C\n                      := \u03bb Lx, hom Lx^.fst Lx^.snd in\n               let \u03c9f : \u2200 (a b : \u03a3 (x : \u27e6X\u27e7), L^.obj x)\n                        , LeanCat.HasAllCoLimits.prop L a b\n                        \u2192 f a = f b\n                     := \u03bb a b \u03c9ab\n                        , begin\n                            dsimp,\n                            cases \u03c9ab with g \u03c9g,\n                            rw [\u03c9g, \u03c9hom g],\n                            trivial\n                          end\n               in quot.lift f \u03c9f)\n            (\u03bb C hom \u03c9hom x, rfl)\n            (\u03bb C hom \u03c9hom f \u03c9f\n             , funext (quot.ind (begin\n                                   intro Lx,\n                                   cases Lx with x Lx,\n                                   apply eq.symm (congr_fun (\u03c9f 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 \u2113 \u2113obj}^.obj)\n    {X : Cat.{\u2113obj \u2113hom}}\n    (L : Fun X (OverCat LeanCat B))\n    : LeanCat^.hom (colimit (OverFun.out LeanCat B \u25a1\u25a1 L)) B\n:= let f : (\u03a3 (x : X^.obj), (L^.obj x)^.obj) \u2192 B\n        := \u03bb 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 \u03c9, cases \u03c9 with h \u03c9b,\n      dsimp at h,\n      dsimp at \u03c9b, subst \u03c9b,\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 \u2113 \u2113obj}^.obj)\n    {X : Cat.{\u2113obj \u2113hom}} (L : Fun X (OverCat LeanCat B))\n    : HasCoLimit L\n:= HasCoLimit.show\n    { obj := colimit (OverFun.out LeanCat B \u25a1\u25a1 L)\n    , hom := LeanCat.Over.HasCoLimit.colim_hom B L\n    }\n    (\u03bb x, { hom := \u03bb Lx, quot.mk _ { fst := x, snd := Lx }\n          , triangle := sorry\n          })\n    (\u03bb x\u2081 x\u2082 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 \u2113 \u2113obj}^.obj)\n    : HasAllCoLimits.{\u2113obj \u2113hom}\n        (OverCat LeanCat.{max \u2113 \u2113obj} B)\n:= { has_colimit := @LeanCat.Over.HasCoLimit B\n   }      \n\n/-! #brief Handy simplifier.\n-/\ntheorem LeanCat.Over.HasCoLimit.obj\n    (B : LeanCat.{max \u2113 \u2113obj}^.obj)\n    {X : Cat.{\u2113obj \u2113hom}} (L : Fun X (OverCat LeanCat B))\n    : (colimit L)^.obj = colimit (OverFun.out LeanCat B \u25a1\u25a1 L)\n:= rfl\n\n\n\n/- -----------------------------------------------------------------------\nProducts.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has all products.\n-/\ninstance LeanCat.HasProduct\n    {A : Type \u2113'} (factor : A \u2192 LeanCat.{max \u2113 \u2113'}^.obj)\n    : HasProduct LeanCat.{max \u2113 \u2113'} factor\n:= HasProduct.show LeanCat factor\n    (\u2200 (a : A), factor a)\n    (\u03bb a fa, fa a)\n    (\u03bb T f t a, f a t)\n    (\u03bb T f a, rfl)\n    (\u03bb T f h \u03c9h\n      , begin\n          apply funext, intro t,\n          apply funext, intro a,\n          rw \u03c9h,\n          trivial\n        end)\n\n/-! #brief LeanCat has all products.\n-/\ninstance LeanCat.HasAllProducts\n    : HasAllProducts.{\u2113'} LeanCat.{max \u2113 \u2113'}\n:= { has_product := @LeanCat.HasProduct\n   }\n\n/-! #brief Finite product type in LeanCat.\n-/\ndefinition ListProd\n    : \u2200 (TT : list LeanCat.{\u2113}^.obj)\n      , LeanCat.{\u2113}^.obj\n| [] := punit\n| [T] := T\n| (T :: TT) := T \u00d7 ListProd TT\n\n/-! #brief A fancy way of mapping through a ListProd.\n-/\ndefinition {\u2113b \u2113x \u2113y} ListProd.map\n    {Ba : Type \u2113b} {Tx : Ba \u2192 Type \u2113x} {Ty : Ba \u2192 Type \u2113y}\n    (f : \u2200 (b : Ba), Tx b \u2192 Ty b)\n    : \u2200 (BB : list Ba)\n      , ListProd (list.map Tx BB)\n      \u2192 ListProd (list.map Ty BB)\n| [] _ := punit.star\n| [Ba] x := f Ba x\n| (Ba :: Ba\u2080 :: BB) (prod.mk x xx) := (f Ba x, @ListProd.map (Ba\u2080 :: BB) xx)\n\n/-! #brief Projection from finite product type in LeanCat.\n-/\ndefinition ListProd.\u03c0\n    : \u2200 (TT : list LeanCat.{\u2113}^.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 \u03c90) X := X\n| [T] (fin.mk (nat.succ n) \u03c9n) X := false.rec _ begin cases \u03c9n, cases a end\n| (T :: T\u2081 :: TT) (fin.mk 0 \u03c90) X := X^.fst\n| (T :: T\u2081 :: TT) (fin.mk (nat.succ n) \u03c9n) X := ListProd.\u03c0 (T\u2081 :: TT) { val := n, is_lt := nat.lt_of_succ_lt_succ \u03c9n } X^.snd\n\n/-! #brief Enumerating a map into a finite product.\n-/\ndefinition ListProd.univ\n    : \u2200 (TT : list LeanCat.{\u2113}^.obj)\n        (S : LeanCat.{\u2113}^.obj)\n        (f : \u2200 (n : \u2115)\n               (\u03c9n : n < list.length TT)\n             , S \u2192 list.get TT { val := n, is_lt := \u03c9n })\n      , S \u2192 ListProd TT\n| [] S f s := punit.star\n| [T] S f s := f 0 (fin_of 0)^.is_lt s\n| (T :: T\u2081 :: TT) S f s\n:= ( f 0 (fin_of 0)^.is_lt s\n   , ListProd.univ (T\u2081 :: TT) S (\u03bb n \u03c9n s', f (nat.succ n) (nat.succ_lt_succ \u03c9n) s') s\n   )\n\n/-! #brief Factoring property of the universal map.\n-/\ndefinition ListProd.univ.factor\n    : \u2200 {TT : list LeanCat.{\u2113}^.obj}\n        {S : LeanCat.{\u2113}^.obj}\n        {f : \u2200 (n : \u2115)\n               (\u03c9n : n < list.length TT)\n             , S \u2192 list.get TT { val := n, is_lt := \u03c9n }}\n        {n : \u2115} {\u03c9n : n < list.length TT}\n        {s : S}\n      , f n \u03c9n s = ListProd.\u03c0 TT\n                    { val := n, is_lt := \u03c9n }\n                    (ListProd.univ TT S f s)\n| [] S f n \u03c9n s := by cases \u03c9n\n| [T] S f 0 \u03c90 s := rfl\n| [T] S f (nat.succ n) \u03c9n s := false.rec _ begin cases \u03c9n, cases a end\n| (T :: T\u2081 :: TT) S f 0 \u03c90 s := rfl\n| (T :: T\u2081 :: TT) S f (nat.succ n) \u03c9n s\n:= begin\n     refine eq.trans _ (@ListProd.univ.factor (T\u2081 :: TT) S _ n _ s),\n     trivial\n   end\n\n/-! #brief LeanCat has all finite products.\n-/\ninstance LeanCat.HasFinProduct (factor : list LeanCat.{\u2113}^.obj)\n    : HasFinProduct LeanCat factor\n:= HasProduct.show LeanCat (list.get factor)\n    (ListProd factor)\n    (ListProd.\u03c0 factor)\n    (\u03bb T f, ListProd.univ factor T (\u03bb n \u03c9n, f { val := n, is_lt := \u03c9n }))\n    (\u03bb T f n\n      , begin\n          apply funext, intro t,\n          cases n with n \u03c9n,\n          refine eq.trans _ (ListProd.univ.factor),\n          trivial\n        end)\n    (\u03bb T f h \u03c9h\n      , begin\n          assert \u03c9f : f = \u03bb n t, ListProd.\u03c0 factor n (h t),\n          { apply funext @\u03c9h },\n          subst \u03c9f,\n          apply funext, intro t,\n          induction factor with T factor rec,\n          { apply punit.uniq },\n          cases factor with T\u2081 factor,\n          { trivial },\n          { apply prod.eq,\n            { trivial },\n            { refine eq.trans _ (rec (\u03bb 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.{\u2113}\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 \u2113'} (factor : A \u2192 LeanCat.{max \u2113 \u2113'}^.obj)\n    : HasCoProduct LeanCat.{max \u2113 \u2113'} factor\n:= HasCoProduct.show LeanCat factor\n    (\u03a3 (a : A), factor a)\n    (sigma.mk)\n    (\u03bb T f af, f af^.fst af^.snd)\n    (\u03bb T f a, rfl)\n    (\u03bb T f h \u03c9h\n      , begin\n          apply funext, intro af,\n          cases af with a f,\n          rw \u03c9h,\n          trivial\n        end)\n\n/-! #brief LeanCat has all co-products.\n-/\ninstance LeanCat.HasAllCoProducts\n    : HasAllCoProducts.{\u2113'} LeanCat.{max \u2113 \u2113'}\n:= { has_coproduct := @LeanCat.HasCoProduct\n   }\n\n/-! #brief Finite sum type in LeanCat.\n-/\ndefinition ListSum\n    : \u2200 (TT : list LeanCat.{\u2113}^.obj)\n      , LeanCat.{\u2113}^.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 {\u2113b \u2113x \u2113y} ListSum.map\n    {Ba : Type \u2113b} {Tx : Ba \u2192 Type \u2113x} {Ty : Ba \u2192 Type \u2113y}\n    : \u2200 (BB : list Ba)\n        (f : \u2200 (n : \u2115) (\u03c9n : n < list.length BB)\n             , Tx (list.get BB {val := n, is_lt := \u03c9n}) \u2192 Ty (list.get BB {val := n, is_lt := \u03c9n}))\n      , ListSum (list.map Tx BB)\n      \u2192 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\u2080 :: BB) f (sum.inl x) := sum.inl (f 0 fin.zero^.is_lt x)\n| (Ba :: Ba\u2080 :: BB) f (sum.inr xx)\n:= sum.inr (ListSum.map (Ba\u2080 :: BB)\n             (\u03bb n \u03c9n, f (nat.succ n) (nat.succ_le_succ \u03c9n))\n            xx)\n\n/-! #brief Inclusion into finite sum type in LeanCat.\n-/\ndefinition ListSum.\u03b9\n    : \u2200 (TT : list LeanCat.{\u2113}^.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 \u03c90) x := x\n| [T] (fin.mk (nat.succ n) \u03c9n) x := false.rec _ begin cases \u03c9n, cases a end\n| (T :: T\u2081 :: TT) (fin.mk 0 \u03c90) x := sum.inl x\n| (T :: T\u2081 :: TT) (fin.mk (nat.succ n) \u03c9n) x\n:= sum.inr (ListSum.\u03b9 (T\u2081 :: TT) { val := n, is_lt := nat.lt_of_succ_lt_succ \u03c9n } x)\n\n/-! #brief Enumerating a map out of a finite sum.\n-/\ndefinition ListSum.univ\n    : \u2200 (TT : list LeanCat.{\u2113}^.obj)\n        (S : LeanCat.{\u2113}^.obj)\n        (f : \u2200 (n : \u2115)\n               (\u03c9n : n < list.length TT)\n             , list.get TT { val := n, is_lt := \u03c9n } \u2192 S)\n      , ListSum TT \u2192 S\n| [] S f e := by cases e\n| [T] S f s := f 0 (fin_of 0)^.is_lt s\n| (T :: T\u2081 :: TT) S f (sum.inl s)\n:= f 0 (fin_of 0)^.is_lt s\n| (T :: T\u2081 :: TT) S f (sum.inr s)\n:= ListSum.univ (T\u2081 :: TT) S (\u03bb n \u03c9n s', f (nat.succ n) (nat.succ_lt_succ \u03c9n) s') s\n\n/-! #brief Factoring property of the universal map.\n-/\ndefinition ListSum.univ.factor\n    : \u2200 {TT : list LeanCat.{\u2113}^.obj}\n        {S : LeanCat.{\u2113}^.obj}\n        {f : \u2200 (n : \u2115)\n               (\u03c9n : n < list.length TT)\n             , list.get TT { val := n, is_lt := \u03c9n } \u2192 S}\n        {n : \u2115} {\u03c9n : n < list.length TT}\n        {s : list.get TT { val := n, is_lt := \u03c9n }}\n      , f n \u03c9n s = ListSum.univ TT S f\n                     (ListSum.\u03b9 TT { val := n, is_lt := \u03c9n } s)\n| [] S f n \u03c9n s := by cases \u03c9n\n| [T] S f 0 \u03c90 s := rfl\n| [T] S f (nat.succ n) \u03c9n s := false.rec _ begin cases \u03c9n, cases a end\n| (T :: T\u2081 :: TT) S f 0 \u03c90 s := rfl\n| (T :: T\u2081 :: TT) S f (nat.succ n) \u03c9n s\n:= begin\n     refine eq.trans _ (@ListSum.univ.factor (T\u2081 :: TT) S _ n _ s),\n     trivial\n   end\n\n/-! #brief LeanCat has all finite products.\n-/\ninstance LeanCat.HasFinCoProduct (factor : list LeanCat.{\u2113}^.obj)\n    : HasFinCoProduct LeanCat factor\n:= HasCoProduct.show LeanCat (list.get factor)\n    (ListSum factor)\n    (ListSum.\u03b9 factor)\n    (\u03bb T f, ListSum.univ factor T (\u03bb n \u03c9n, f { val := n, is_lt := \u03c9n }))\n    (\u03bb T f n\n      , begin\n          apply funext, intro t,\n          cases n with n \u03c9n,\n          refine eq.trans _ (ListSum.univ.factor),\n          trivial\n        end)\n    (\u03bb T f h \u03c9h\n      , begin\n          assert \u03c9f : f = \u03bb n t, h (ListSum.\u03b9 factor n t),\n          { apply funext @\u03c9h },\n          subst \u03c9f,\n          apply funext, intro t,\n          induction factor with T factor rec,\n          { cases t },\n          cases factor with T\u2081 factor,\n          { trivial },\n          { cases t,\n            { trivial },\n            { refine eq.trans _ (rec (\u03bb 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.{\u2113}\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.{\u2113}^.obj} {factor : list LeanCat.{\u2113}^.obj}\n    {T : LeanCat.{\u2113}^.obj}\n    (maps : @HomsIn LeanCat (base :: factor) T)\n    : HasPullback LeanCat maps\n:= HasPullback.show LeanCat.{\u2113} maps\n    { p : finproduct LeanCat (base :: factor)\n      // \u2200 (n : fin (list.length (base :: factor)))\n         , HomsIn.get maps (fin_of 0) (finproduct.\u03c0 LeanCat (base :: factor) (fin_of 0) p)\n            = HomsIn.get maps n (finproduct.\u03c0 LeanCat (base :: factor) n p)\n    }\n    (\u03bb p, HomsIn.get maps (fin_of 0) (finproduct.\u03c0 LeanCat (base :: factor) (fin_of 0) p^.val))\n    (HomsOut.comp (finproduct.cone LeanCat (base :: factor))^.Proj (\u03bb p, p^.val))\n    begin\n      cases maps with _ m_base _ maps,\n      -- apply HomsList.eq,\n      -- { trivial },\n      -- induction maps with _ m\u2081 _ maps rec,\n      -- { trivial },\n      exact sorry\n    end\n    sorry\n    sorry\n    sorry\n\n\ninstance LeanCat.HasAllPullbacks\n    : HasAllPullbacks LeanCat.{\u2113}\n:= { has_pullback\n      := \u03bb base factor T maps\n         , LeanCat.HasPullback maps\n   }\n\n/-! #brief A handy wrapper.\n-/\ndefinition LeanCat.BaseChangeFun\n    {X Y : LeanCat.{\u2113}^.obj}\n    (f : LeanCat.{\u2113}^.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\u2080 : LeanCat.{\u2113}^.obj)\n    (factor : list (OverCat LeanCat T\u2080)^.obj)\n    : HasFinProduct (OverCat LeanCat T\u2080) factor\n:= OverCat.HasFinProduct LeanCat.{\u2113} T\u2080 factor\n\n\n\n/- -----------------------------------------------------------------------\nExponentials.\n----------------------------------------------------------------------- -/\n\n/-! #brief LeanCat has exponential objects.\n-/\ninstance LeanCat.HasExp (X Y : LeanCat.{\u2113}^.obj)\n    : @HasExp LeanCat X Y\n:= { exp := Y \u2192 X\n   , ev\n      := \u03bb exp_Y_HasFinProduct p\n         , let f := @finproduct.\u03c0 _ _ exp_Y_HasFinProduct (@fin_of 1 0)\n        in let y := @finproduct.\u03c0 _ _ exp_Y_HasFinProduct (@fin_of 0 1)\n        in f p (y p)\n   , univ\n      := \u03bb Z Z_Y_HasFinProduct e z y\n         , e (finproduct.iso (LeanCat.HasFinProduct [Z, Y]) Z_Y_HasFinProduct (z, y))\n   , factor := \u03bb 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 := \u03bb exp_Y_HasFinProduct Z Z_Y_HasFinProduct e u \u03c9u\n             , begin\n                 apply funext, intro z,\n                 apply funext, intro y,\n                 rw \u03c9u,\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\u2080 : LeanCat.{\u2113}^.obj)\n      (T S : (OverCat LeanCat T\u2080)^.obj)\n      : OverObj LeanCat.{\u2113} T\u2080\n:= { obj := \u03a3 (t\u2080 : T\u2080)\n            , {s : S^.dom // S^.hom s = t\u2080}\n              \u2192 {t : T^.obj // T^.hom t = t\u2080}\n   , hom := sigma.fst\n   }\n\n/-! #brief LeanCat has exponential objects.\n-/\ninstance LeanCat.Over.HasExp\n      (T\u2080 : LeanCat.{\u2113}^.obj)\n      (X Y : (OverCat LeanCat T\u2080)^.obj)\n    : @HasExp (OverCat LeanCat T\u2080) X Y\n:= { exp := LeanCat.Over.exp T\u2080 X Y\n   , ev\n      := \u03bb p_HasProd\n         , { hom := \u03bb p, let f := (@finproduct.\u03c0 (OverCat LeanCat T\u2080) [LeanCat.Over.exp T\u2080 X Y, Y] p_HasProd (@fin_of 1 0))^.hom p\n                      in let y := (@finproduct.\u03c0 (OverCat LeanCat T\u2080) [LeanCat.Over.exp T\u2080 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      := \u03bb A A_HasProd f\n         , let a_y : \u2200 (a : A^.obj)\n                       (y : {s // Y^.hom s = A^.hom a})\n                     , OverObj.dom (finproduct (OverCat LeanCat T\u2080) [A, Y])\n                   := \u03bb a y\n                      , { val := (a, y^.val)\n                        , property\n                           := begin\n                                intro n\u03c9n, cases n\u03c9n with n \u03c9n,\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 \u03c9n\n                              end\n                        }\n        in let a_y' := \u03bb a y, ((finproduct.iso (LeanCat.Over.HasFinProduct T\u2080 [A, Y]) A_HasProd)^.hom (a_y a y))\n        in { hom\n              := \u03bb a\n                 , \u27e8 A^.hom a\n                   , \u03bb 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                   \u27e9\n         , triangle := sorry\n         }\n   , factor := \u03bb A p_HasProd A_HasProd e\n               , sorry\n   , uniq := \u03bb exp_Y_HasFinProduct Z Z_Y_HasFinProduct e u \u03c9u\n             , sorry\n   }\n\n/-! #brief OverCat LeanCat has all exponentials.\n-/\ninstance LeanCat.Over.HasAllExp\n    (T\u2080 : LeanCat.{\u2113}^.obj)\n    : @HasAllExp (OverCat LeanCat T\u2080)\n:= { has_exp := LeanCat.Over.HasExp T\u2080\n   }\n\n/-! #brief LeanCat has exponentials in all slices.\n-/\ninstance LeanCat.HasAllLocalExp\n    : HasAllLocalExp LeanCat.{\u2113}\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.{\u2113}\n:= HasSubobjClass.show\n    (\u03bb LeanCat_HasFinal, Lean.LevelMax Prop)\n    (\u03bb LeanCat_HasFinal, \u03bb u, Lean.LevelMax.lift true)\n    (\u03bb LeanCat_HasFinal U X m m_Monic, \u03bb x, Lean.LevelMax.lift (\u2203 (u : U), m u = x))\n    (\u03bb LeanCat_HasFinal U X V m m_Monic h \u03c9h x\n     , let u\u2080 : \u2203 (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 \u03c9h\n                end in\n       let u : \u2203! (u : U), h x = m u\n            := exists.elim u\u2080\n                (\u03bb u \u03c9u\n                 , exists_unique.intro u (eq.symm \u03c9u)\n                    (\u03bb u' \u03c9u', LeanCat.Monic.inj m_Monic\n                                (eq.symm (eq.trans \u03c9u \u03c9u'))))\n       in unique_choice u)\n    (\u03bb 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    (\u03bb LeanCat_HasFinal U V X m m_Monic h \u03c9h\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 \u03c9h v)))) \u03c9,\n         intro \u03c9, cases \u03c9 with u \u03c9u,\n         refine eq.trans (eq.symm _) (eq.symm (congr_arg m unique_choice.simp)),\n         exact \u03c9u\n       end)\n    (\u03bb LeanCat_HasFinal U V X m m_Monic h \u03c9h\n     , begin\n         apply funext, intro v,\n         generalize (of_iff_true (eq.to_iff (Lean.LevelMax.lift.inj (congr_fun \u03c9h v)))) \u03c9,\n         intro \u03c9, cases \u03c9 with u \u03c9u,\n         refine eq.trans _ (eq.symm unique_choice.simp),\n         apply LeanCat.Monic.inj m_Monic,\n         exact eq.symm \u03c9u\n       end)\n    (\u03bb LeanCat_HasFinal U X m m_Monic char' char'_IsPullback\n     , sorry)\n\n\n--    , char_uniq\n--       := \u03bb LeanCat_HasFinal U X m m_Monic char' \u03c9char'\n--          , let char'' : X \u2192 Prop\n--                      := \u03bb x, Lean.LevelMax.cases_on (char' x) (\u03bb P, P)\n--         in begin\n--              apply funext, intro x,\n--              assert \u03c9char'' : char' x = Lean.LevelMax.lift (Lean.LevelMax.cases_on (char' x) (\u03bb P, P)),\n--              { generalize (char' x) char'_x,\n--                intro char'_x, cases char'_x,\n--                trivial,\n--              },\n--              refine eq.trans \u03c9char'' (congr_arg Lean.LevelMax.lift _),\n--              apply iff.to_eq,\n--              apply iff.intro,\n--              { intro \u03c9P_x, exact sorry\n--              },\n--              { intro \u03c9u, cases \u03c9u with u \u03c9u,\n--                subst \u03c9u,\n--                -- true because \u03c9char' 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.{\u2113} LeanCat.HasFinal\n:= { nn := Lean.LevelMax \u2115\n   , zero := \u03bb u, Lean.LevelMax.lift 0\n   , succ := Lean.LevelMax.map nat.succ\n   , univ := \u03bb A z s n, nat.rec_on (Lean.LevelMax.unlift n)\n                         (z punit.star)\n                         (\u03bb n' a, s a)\n   , comm_zero\n      := \u03bb A z s\n         , begin\n             apply funext, intro u, cases u,\n             trivial\n           end\n   , comm_succ\n      := \u03bb 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      := \u03bb A z s u' \u03c9zero \u03c9succ\n         , begin\n             apply funext, intro n, cases n with n,\n             induction n with n rec,\n             { rw \u03c9zero, trivial },\n             { refine eq.trans (eq.symm (congr_fun \u03c9succ (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 {\u03b1 : Type} [semiring \u03b1] {\u03b2 : Type} (e : \u03b1 \u2243 \u03b2) : semiring \u03b2 :=\nby transport using e\n\n-- Indeed, it can equally well move a `semilattice_sup`.\ndef sup.map {\u03b1 : Type} [semilattice_sup \u03b1] {\u03b2 : Type} (e : \u03b1 \u2243 \u03b2) : semilattice_sup \u03b2 :=\nby transport using e\n\n-- Verify definitional equality of the new structure data.\nexample {\u03b1 : Type} [semilattice_sup \u03b1] {\u03b2 : Type} (e : \u03b1 \u2243 \u03b2) (x y : \u03b2) :\nbegin\n  haveI := sup.map e,\n  exact (x \u2264 y) = (e.symm x \u2264 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 \u2192 mynat\n\ndef mynat_equiv : \u2115 \u2243 mynat :=\n{ to_fun := \u03bb n, nat.rec_on n mynat.zero (\u03bb n, mynat.succ),\n  inv_fun := \u03bb n, mynat.rec_on n nat.zero (\u03bb n, nat.succ),\n  left_inv := \u03bb n, begin induction n, refl, exact congr_arg nat.succ n_ih, end,\n  right_inv := \u03bb 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 : \u2115) :\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 : \u2115) \u2022 (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 \u2192 Q)\n(i : Q \u2192 R)\n(j : Q \u2192 T)\n(k : S \u2192 T)\n(l : T \u2192 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 {\u03b1 : Type*}\n\ndef is_prefix (l\u2081 : list \u03b1) (l\u2082 : list \u03b1) : Prop :=\n  \u2203 t, l\u2081 ++ t = l\u2082\n\ndef list_has_le : has_le (list \u03b1) := \u27e8is_prefix\u27e9\n\nsection\n  local attribute [instance] list_has_le\n\n  theorem list.is_prefix_refl (l : list \u03b1) : l \u2264 l :=\n    \u27e8[], by simp\u27e9\nend\n\n-- error:\n-- theorem bar (l : list \u03b1) : l \u2264 l :=\n--   \u27e8[], by simp\u27e9\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\u00e9my Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: R\u00e9my 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# \u2112p space and Lp space\n\nThis file describes properties of almost everywhere measurable functions with finite seminorm,\ndenoted by `snorm f p \u03bc` and defined for `p:ennreal` as `0` if `p=0`, `(\u222b \u2225f a\u2225^p \u2202\u03bc) ^ (1/p)` for\n`0 < p < \u221e` and `ess_sup \u2225f\u2225 \u03bc` for `p=\u221e`.\n\nThe Prop-valued `mem_\u2112p f p \u03bc` states that a function `f : \u03b1 \u2192 E` has finite seminorm.\nThe space `Lp \u03b1 E p \u03bc` is the subtype of elements of `\u03b1 \u2192\u2098[\u03bc] E` (see ae_eq_fun) such that\n`snorm f p \u03bc` is finite. For `1 \u2264 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 \u03bc` : `(\u222b \u2225f a\u2225^p \u2202\u03bc) ^ (1/p)` for `f : \u03b1 \u2192 F` and `p : \u211d`, where `\u03b1` is a  measurable\n  space and `F` is a normed group.\n* `snorm_ess_sup f \u03bc` : seminorm in `\u2112\u221e`, equal to the essential supremum `ess_sup \u2225f\u2225 \u03bc`.\n* `snorm f p \u03bc` : for `p : ennreal`, seminorm in `\u2112p`, equal to `0` for `p=0`, to `snorm' f p \u03bc`\n  for `0 < p < \u221e` and to `snorm_ess_sup f \u03bc` for `p = \u221e`.\n\n* `mem_\u2112p f p \u03bc` : property that the function `f` is almost everywhere measurable and has finite\n  p-seminorm for measure `\u03bc` (`snorm f p \u03bc < \u221e`)\n* `Lp E p \u03bc` : elements of `\u03b1 \u2192\u2098[\u03bc] E` (see ae_eq_fun) such that `snorm f p \u03bc` is finite. Defined\n  as an `add_subgroup` of `\u03b1 \u2192\u2098[\u03bc] E`.\n\n-/\n\nnamespace measure_theory\n\n\n/-- `(\u222b \u2225f a\u2225^p \u2202\u03bc) ^ (1/p)`, which is a seminorm on the space of measurable functions for which\nthis quantity is finite -/\ndef snorm' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] (f : \u03b1 \u2192 F) (p : \u211d) (\u03bc : measure \u03b1) : ennreal :=\n  (lintegral \u03bc fun (a : \u03b1) => \u2191(nnnorm (f a)) ^ p) ^ (1 / p)\n\n/-- seminorm for `\u2112\u221e`, equal to the essential supremum of `\u2225f\u2225`. -/\ndef snorm_ess_sup {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] (f : \u03b1 \u2192 F) (\u03bc : measure \u03b1) : ennreal :=\n  ess_sup (fun (x : \u03b1) => \u2191(nnnorm (f x))) \u03bc\n\n/-- `\u2112p` seminorm, equal to `0` for `p=0`, to `(\u222b \u2225f a\u2225^p \u2202\u03bc) ^ (1/p)` for `0 < p < \u221e` and to\n`ess_sup \u2225f\u2225 \u03bc` for `p = \u221e`. -/\ndef snorm {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] (f : \u03b1 \u2192 F) (q : ennreal) (\u03bc : measure \u03b1) : ennreal :=\n  ite (q = 0) 0 (ite (q = \u22a4) (snorm_ess_sup f \u03bc) (snorm' f (ennreal.to_real q) \u03bc))\n\ntheorem snorm_eq_snorm' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {q : ennreal} (hq_ne_zero : q \u2260 0) (hq_ne_top : q \u2260 \u22a4) {f : \u03b1 \u2192 F} : snorm f q \u03bc = snorm' f (ennreal.to_real q) \u03bc := sorry\n\n@[simp] theorem snorm_exponent_top {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} : snorm f \u22a4 \u03bc = snorm_ess_sup f \u03bc := sorry\n\n/-- The property that `f:\u03b1\u2192E` is ae_measurable and `(\u222b \u2225f a\u2225^p \u2202\u03bc)^(1/p)` is finite -/\ndef mem_\u2112p {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] [measurable_space E] [normed_group E] (f : \u03b1 \u2192 E) (p : ennreal) (\u03bc : measure \u03b1) :=\n  ae_measurable f \u2227 snorm f p \u03bc < \u22a4\n\ntheorem lintegral_rpow_nnnorm_eq_rpow_snorm' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp0_lt : 0 < p) : (lintegral \u03bc fun (a : \u03b1) => \u2191(nnnorm (f a)) ^ p) = snorm' f p \u03bc ^ p := sorry\n\ntheorem mem_\u2112p_one_iff_integrable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {f : \u03b1 \u2192 E} : mem_\u2112p f 1 \u03bc \u2194 integrable f := sorry\n\ntheorem mem_\u2112p.snorm_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} {f : \u03b1 \u2192 E} (hfp : mem_\u2112p f q \u03bc) : snorm f q \u03bc < \u22a4 :=\n  and.right hfp\n\ntheorem mem_\u2112p.snorm_ne_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} {f : \u03b1 \u2192 E} (hfp : mem_\u2112p f q \u03bc) : snorm f q \u03bc \u2260 \u22a4 :=\n  ne_of_lt (and.right hfp)\n\ntheorem lintegral_rpow_nnnorm_lt_top_of_snorm'_lt_top {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp0_lt : 0 < p) (hfp : snorm' f p \u03bc < \u22a4) : (lintegral \u03bc fun (a : \u03b1) => \u2191(nnnorm (f a)) ^ p) < \u22a4 := sorry\n\n@[simp] theorem snorm'_exponent_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} : snorm' f 0 \u03bc = 1 := sorry\n\n@[simp] theorem snorm_exponent_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} : snorm f 0 \u03bc = 0 := sorry\n\ntheorem mem_\u2112p_zero_iff_ae_measurable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {f : \u03b1 \u2192 E} : mem_\u2112p f 0 \u03bc \u2194 ae_measurable f := sorry\n\n@[simp] theorem snorm'_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (hp0_lt : 0 < p) : snorm' 0 p \u03bc = 0 := sorry\n\n@[simp] theorem snorm'_zero' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (hp0_ne : p \u2260 0) (h\u03bc : \u03bc \u2260 0) : snorm' 0 p \u03bc = 0 := sorry\n\n@[simp] theorem snorm_ess_sup_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] : snorm_ess_sup 0 \u03bc = 0 := sorry\n\n@[simp] theorem snorm_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {q : ennreal} : snorm 0 q \u03bc = 0 := sorry\n\ntheorem zero_mem_\u2112p {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} : mem_\u2112p 0 q \u03bc :=\n  { left := measurable.ae_measurable measurable_zero,\n    right := eq.mpr (id (Eq._oldrec (Eq.refl (snorm 0 q \u03bc < \u22a4)) snorm_zero)) ennreal.coe_lt_top }\n\ntheorem snorm'_measure_zero_of_pos {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp_pos : 0 < p) : snorm' f p 0 = 0 := sorry\n\ntheorem snorm'_measure_zero_of_exponent_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] {f : \u03b1 \u2192 F} : snorm' f 0 0 = 1 := sorry\n\ntheorem snorm'_measure_zero_of_neg {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp_neg : p < 0) : snorm' f p 0 = \u22a4 := sorry\n\n@[simp] theorem snorm_ess_sup_measure_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] {f : \u03b1 \u2192 F} : snorm_ess_sup f 0 = 0 := sorry\n\n@[simp] theorem snorm_measure_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] {q : ennreal} {f : \u03b1 \u2192 F} : snorm f q 0 = 0 := sorry\n\ntheorem snorm'_const {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (c : F) (hp_pos : 0 < p) : snorm' (fun (x : \u03b1) => c) p \u03bc = \u2191(nnnorm c) * coe_fn \u03bc set.univ ^ (1 / p) := sorry\n\ntheorem snorm'_const' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} [finite_measure \u03bc] (c : F) (hc_ne_zero : c \u2260 0) (hp_ne_zero : p \u2260 0) : snorm' (fun (x : \u03b1) => c) p \u03bc = \u2191(nnnorm c) * coe_fn \u03bc set.univ ^ (1 / p) := sorry\n\ntheorem snorm_ess_sup_const {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] (c : F) (h\u03bc : \u03bc \u2260 0) : snorm_ess_sup (fun (x : \u03b1) => c) \u03bc = \u2191(nnnorm c) := sorry\n\ntheorem snorm'_const_of_probability_measure {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (c : F) (hp_pos : 0 < p) [probability_measure \u03bc] : snorm' (fun (x : \u03b1) => c) p \u03bc = \u2191(nnnorm c) := sorry\n\ntheorem snorm_const {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {q : ennreal} (c : F) (h0 : q \u2260 0) (h\u03bc : \u03bc \u2260 0) : snorm (fun (x : \u03b1) => c) q \u03bc = \u2191(nnnorm c) * coe_fn \u03bc set.univ ^ (1 / ennreal.to_real q) := sorry\n\ntheorem snorm_const' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {q : ennreal} (c : F) (h0 : q \u2260 0) (h_top : q \u2260 \u22a4) : snorm (fun (x : \u03b1) => c) q \u03bc = \u2191(nnnorm c) * coe_fn \u03bc set.univ ^ (1 / ennreal.to_real q) := sorry\n\ntheorem mem_\u2112p_const {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} (c : E) [finite_measure \u03bc] : mem_\u2112p (fun (a : \u03b1) => c) q \u03bc := sorry\n\ntheorem snorm'_congr_ae {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} {g : \u03b1 \u2192 F} (hfg : filter.eventually_eq (measure.ae \u03bc) f g) : snorm' f p \u03bc = snorm' g p \u03bc := sorry\n\ntheorem snorm_ess_sup_congr_ae {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} {g : \u03b1 \u2192 F} (hfg : filter.eventually_eq (measure.ae \u03bc) f g) : snorm_ess_sup f \u03bc = snorm_ess_sup g \u03bc := sorry\n\ntheorem snorm_congr_ae {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {q : ennreal} {f : \u03b1 \u2192 F} {g : \u03b1 \u2192 F} (hfg : filter.eventually_eq (measure.ae \u03bc) f g) : snorm f q \u03bc = snorm g q \u03bc := sorry\n\ntheorem mem_\u2112p.ae_eq {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hfg : filter.eventually_eq (measure.ae \u03bc) f g) (hf_Lp : mem_\u2112p f q \u03bc) : mem_\u2112p g q \u03bc := sorry\n\ntheorem mem_\u2112p_congr_ae {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hfg : filter.eventually_eq (measure.ae \u03bc) f g) : mem_\u2112p f q \u03bc \u2194 mem_\u2112p g q \u03bc :=\n  { mp := fun (h : mem_\u2112p f q \u03bc) => mem_\u2112p.ae_eq hfg h,\n    mpr := fun (h : mem_\u2112p g q \u03bc) => mem_\u2112p.ae_eq (filter.eventually_eq.symm hfg) h }\n\ntheorem snorm'_eq_zero_of_ae_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp0_lt : 0 < p) (hf_zero : filter.eventually_eq (measure.ae \u03bc) f 0) : snorm' f p \u03bc = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (snorm' f p \u03bc = 0)) (snorm'_congr_ae hf_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (snorm' 0 p \u03bc = 0)) (snorm'_zero hp0_lt))) (Eq.refl 0))\n\ntheorem snorm'_eq_zero_of_ae_zero' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (hp0_ne : p \u2260 0) (h\u03bc : \u03bc \u2260 0) {f : \u03b1 \u2192 F} (hf_zero : filter.eventually_eq (measure.ae \u03bc) f 0) : snorm' f p \u03bc = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (snorm' f p \u03bc = 0)) (snorm'_congr_ae hf_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (snorm' 0 p \u03bc = 0)) (snorm'_zero' hp0_ne h\u03bc))) (Eq.refl 0))\n\ntheorem ae_eq_zero_of_snorm'_eq_zero {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : \u211d} [opens_measurable_space E] {f : \u03b1 \u2192 E} (hp0 : 0 \u2264 p) (hf : ae_measurable f) (h : snorm' f p \u03bc = 0) : filter.eventually_eq (measure.ae \u03bc) f 0 := sorry\n\ntheorem snorm'_eq_zero_iff {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : \u211d} [opens_measurable_space E] (hp0_lt : 0 < p) {f : \u03b1 \u2192 E} (hf : ae_measurable f) : snorm' f p \u03bc = 0 \u2194 filter.eventually_eq (measure.ae \u03bc) 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 {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] (f : \u03b1 \u2192 F) (\u03bc : measure \u03b1) : filter.eventually (fun (x : \u03b1) => \u2191(nnnorm (f x)) \u2264 snorm_ess_sup f \u03bc) (measure.ae \u03bc) :=\n  ennreal.ae_le_ess_sup fun (x : \u03b1) => \u2191(nnnorm (f x))\n\ntheorem snorm_ess_sup_eq_zero_iff {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} : snorm_ess_sup f \u03bc = 0 \u2194 filter.eventually_eq (measure.ae \u03bc) f 0 := sorry\n\ntheorem snorm_eq_zero_iff {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [opens_measurable_space E] {f : \u03b1 \u2192 E} (hf : ae_measurable f) (h0 : q \u2260 0) : snorm f q \u03bc = 0 \u2194 filter.eventually_eq (measure.ae \u03bc) f 0 := sorry\n\n@[simp] theorem snorm'_neg {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} : snorm' (-f) p \u03bc = snorm' f p \u03bc := sorry\n\n@[simp] theorem snorm_neg {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {q : ennreal} {f : \u03b1 \u2192 F} : snorm (-f) q \u03bc = snorm f q \u03bc := sorry\n\ntheorem mem_\u2112p.neg {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc) : mem_\u2112p (-f) q \u03bc := sorry\n\ntheorem snorm'_le_snorm'_mul_rpow_measure_univ {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] {p : \u211d} {q : \u211d} (hp0_lt : 0 < p) (hpq : p \u2264 q) {f : \u03b1 \u2192 E} (hf : ae_measurable f) : snorm' f p \u03bc \u2264 snorm' f q \u03bc * coe_fn \u03bc set.univ ^ (1 / p - 1 / q) := sorry\n\ntheorem snorm'_le_snorm_ess_sup_mul_rpow_measure_univ {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (hp_pos : 0 < p) {f : \u03b1 \u2192 F} : snorm' f p \u03bc \u2264 snorm_ess_sup f \u03bc * coe_fn \u03bc set.univ ^ (1 / p) := sorry\n\ntheorem snorm'_le_snorm'_of_exponent_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] [measurable_space E] [normed_group E] [borel_space E] {p : \u211d} {q : \u211d} (hp0_lt : 0 < p) (hpq : p \u2264 q) (\u03bc : measure \u03b1) [probability_measure \u03bc] {f : \u03b1 \u2192 E} (hf : ae_measurable f) : snorm' f p \u03bc \u2264 snorm' f q \u03bc := sorry\n\ntheorem snorm'_le_snorm_ess_sup {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (hp_pos : 0 < p) {f : \u03b1 \u2192 F} [probability_measure \u03bc] : snorm' f p \u03bc \u2264 snorm_ess_sup f \u03bc := sorry\n\ntheorem snorm_le_snorm_of_exponent_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] {p : ennreal} {q : ennreal} (hpq : p \u2264 q) [probability_measure \u03bc] {f : \u03b1 \u2192 E} (hf : ae_measurable f) : snorm f p \u03bc \u2264 snorm f q \u03bc := sorry\n\ntheorem snorm'_lt_top_of_snorm'_lt_top_of_exponent_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] {p : \u211d} {q : \u211d} [finite_measure \u03bc] {f : \u03b1 \u2192 E} (hf : ae_measurable f) (hfq_lt_top : snorm' f q \u03bc < \u22a4) (hp_nonneg : 0 \u2264 p) (hpq : p \u2264 q) : snorm' f p \u03bc < \u22a4 := sorry\n\ntheorem mem_\u2112p.mem_\u2112p_of_exponent_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] {p : ennreal} {q : ennreal} [finite_measure \u03bc] {f : \u03b1 \u2192 E} (hfq : mem_\u2112p f q \u03bc) (hpq : p \u2264 q) : mem_\u2112p f p \u03bc := sorry\n\ntheorem mem_\u2112p.integrable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] (hq1 : 1 \u2264 q) {f : \u03b1 \u2192 E} [finite_measure \u03bc] (hfq : mem_\u2112p f q \u03bc) : integrable f :=\n  iff.mp mem_\u2112p_one_iff_integrable (mem_\u2112p.mem_\u2112p_of_exponent_le hfq hq1)\n\ntheorem snorm'_add_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : \u211d} [borel_space E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : ae_measurable f) (hg : ae_measurable g) (hp1 : 1 \u2264 p) : snorm' (f + g) p \u03bc \u2264 snorm' f p \u03bc + snorm' g p \u03bc := sorry\n\ntheorem snorm_ess_sup_add_le {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} {g : \u03b1 \u2192 F} : snorm_ess_sup (f + g) \u03bc \u2264 snorm_ess_sup f \u03bc + snorm_ess_sup g \u03bc := sorry\n\ntheorem snorm_add_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : ae_measurable f) (hg : ae_measurable g) (hq1 : 1 \u2264 q) : snorm (f + g) q \u03bc \u2264 snorm f q \u03bc + snorm g q \u03bc := sorry\n\ntheorem snorm_add_lt_top_of_one_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc) (hg : mem_\u2112p g q \u03bc) (hq1 : 1 \u2264 q) : snorm (f + g) q \u03bc < \u22a4 :=\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 {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : \u211d} [borel_space E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : ae_measurable f) (hg : ae_measurable g) (hf_snorm : snorm' f p \u03bc < \u22a4) (hg_snorm : snorm' g p \u03bc < \u22a4) (hp_pos : 0 < p) (hp1 : p \u2264 1) : snorm' (f + g) p \u03bc < \u22a4 := sorry\n\ntheorem snorm_add_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc) (hg : mem_\u2112p g q \u03bc) : snorm (f + g) q \u03bc < \u22a4 := sorry\n\ntheorem mem_\u2112p.add {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] [topological_space.second_countable_topology E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc) (hg : mem_\u2112p g q \u03bc) : mem_\u2112p (f + g) q \u03bc :=\n  { left := ae_measurable.add (and.left hf) (and.left hg), right := snorm_add_lt_top hf hg }\n\ntheorem mem_\u2112p.sub {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] [topological_space.second_countable_topology E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc) (hg : mem_\u2112p g q \u03bc) : mem_\u2112p (f - g) q \u03bc :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (mem_\u2112p (f - g) q \u03bc)) (sub_eq_add_neg f g))) (mem_\u2112p.add hf (mem_\u2112p.neg hg))\n\ntheorem snorm'_const_smul {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c F] {f : \u03b1 \u2192 F} (c : \ud835\udd5c) (hp0_lt : 0 < p) : snorm' (c \u2022 f) p \u03bc = \u2191(nnnorm c) * snorm' f p \u03bc := sorry\n\ntheorem snorm_ess_sup_const_smul {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c F] {f : \u03b1 \u2192 F} (c : \ud835\udd5c) : snorm_ess_sup (c \u2022 f) \u03bc = \u2191(nnnorm c) * snorm_ess_sup f \u03bc := sorry\n\ntheorem snorm_const_smul {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {q : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c F] {f : \u03b1 \u2192 F} (c : \ud835\udd5c) : snorm (c \u2022 f) q \u03bc = \u2191(nnnorm c) * snorm f q \u03bc := sorry\n\ntheorem mem_\u2112p.const_smul {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] [borel_space E] {f : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc) (c : \ud835\udd5c) : mem_\u2112p (c \u2022 f) q \u03bc :=\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' {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : \u211d} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] [opens_measurable_space E] [measurable_space \ud835\udd5c] [opens_measurable_space \ud835\udd5c] {q : \u211d} {r : \u211d} {f : \u03b1 \u2192 E} (hf : ae_measurable f) {\u03c6 : \u03b1 \u2192 \ud835\udd5c} (h\u03c6 : ae_measurable \u03c6) (hp0_lt : 0 < p) (hpq : p < q) (hpqr : 1 / p = 1 / q + 1 / r) : snorm' (\u03c6 \u2022 f) p \u03bc \u2264 snorm' \u03c6 q \u03bc * snorm' f r \u03bc := sorry\n\n/-! ### Lp space\n\nThe space of equivalence classes of measurable functions for which `snorm f p \u03bc < \u22a4`.\n-/\n\n@[simp] theorem snorm_ae_eq_fun {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : ennreal} {f : \u03b1 \u2192 E} (hf : ae_measurable f) : snorm (\u21d1(ae_eq_fun.mk f hf)) p \u03bc = snorm f p \u03bc :=\n  snorm_congr_ae (ae_eq_fun.coe_fn_mk f hf)\n\ntheorem mem_\u2112p.snorm_mk_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : ennreal} {f : \u03b1 \u2192 E} (hfp : mem_\u2112p f p \u03bc) : snorm (\u21d1(ae_eq_fun.mk f (and.left hfp))) p \u03bc < \u22a4 := sorry\n\n/-- Lp space -/\ndef Lp {\u03b1 : Type u_1} (E : Type u_2) [measurable_space \u03b1] [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] (p : ennreal) (\u03bc : measure \u03b1) : add_subgroup (ae_eq_fun \u03b1 E \u03bc) :=\n  add_subgroup.mk (set_of fun (f : ae_eq_fun \u03b1 E \u03bc) => snorm (\u21d1f) p \u03bc < \u22a4) sorry sorry sorry\n\n/-- make an element of Lp from a function verifying `mem_\u2112p` -/\ndef mem_\u2112p.to_Lp {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] (f : \u03b1 \u2192 E) {p : ennreal} {\u03bc : measure \u03b1} (h_mem_\u2112p : mem_\u2112p f p \u03bc) : \u21a5(Lp E p \u03bc) :=\n  { val := ae_eq_fun.mk f sorry, property := mem_\u2112p.snorm_mk_lt_top h_mem_\u2112p }\n\ntheorem mem_\u2112p.coe_fn_to_Lp {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {\u03bc : measure \u03b1} {p : ennreal} {f : \u03b1 \u2192 E} (hf : mem_\u2112p f p \u03bc) : filter.eventually_eq (measure.ae \u03bc) (\u21d1(mem_\u2112p.to_Lp f hf)) f :=\n  ae_eq_fun.coe_fn_mk f (mem_\u2112p.to_Lp._proof_1 f hf)\n\nnamespace Lp\n\n\ntheorem mem_Lp_iff_snorm_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ae_eq_fun \u03b1 E \u03bc} : f \u2208 Lp E p \u03bc \u2194 snorm (\u21d1f) p \u03bc < \u22a4 :=\n  iff.refl (f \u2208 Lp E p \u03bc)\n\ntheorem antimono {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] [finite_measure \u03bc] {p : ennreal} {q : ennreal} (hpq : p \u2264 q) : Lp E q \u03bc \u2264 Lp E p \u03bc :=\n  fun (f : ae_eq_fun \u03b1 E \u03bc) (hf : f \u2208 Lp E q \u03bc) =>\n    and.right (mem_\u2112p.mem_\u2112p_of_exponent_le { left := ae_eq_fun.ae_measurable f, right := hf } hpq)\n\ntheorem coe_fn_mk {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : ae_eq_fun \u03b1 E \u03bc} (hf : snorm (\u21d1f) p \u03bc < \u22a4) : filter.eventually_eq (measure.ae \u03bc) \u21d1{ val := f, property := hf } \u21d1f := sorry\n\ntheorem snorm_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) : snorm (\u21d1f) p \u03bc < \u22a4 :=\n  subtype.prop f\n\ntheorem snorm_ne_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) : snorm (\u21d1f) p \u03bc \u2260 \u22a4 :=\n  has_lt.lt.ne (snorm_lt_top f)\n\ntheorem measurable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) : measurable \u21d1f :=\n  ae_eq_fun.measurable (subtype.val f)\n\ntheorem ae_measurable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) : ae_measurable \u21d1f :=\n  ae_eq_fun.ae_measurable (subtype.val f)\n\ntheorem mem_\u2112p {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) : mem_\u2112p (\u21d1f) p \u03bc :=\n  { left := ae_measurable f, right := subtype.prop f }\n\ntheorem coe_fn_zero {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} : filter.eventually_eq (measure.ae \u03bc) (\u21d10) 0 :=\n  ae_eq_fun.coe_fn_zero\n\ntheorem coe_fn_neg {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)} : filter.eventually_eq (measure.ae \u03bc) (\u21d1(-f)) (-\u21d1f) :=\n  ae_eq_fun.coe_fn_neg \u2191f\n\ntheorem coe_fn_add {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)} {g : \u21a5(Lp E p \u03bc)} : filter.eventually_eq (measure.ae \u03bc) (\u21d1(f + g)) (\u21d1f + \u21d1g) :=\n  ae_eq_fun.coe_fn_add (subtype.val f) (subtype.val g)\n\ntheorem coe_fn_sub {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)} {g : \u21a5(Lp E p \u03bc)} : filter.eventually_eq (measure.ae \u03bc) (\u21d1(f - g)) (\u21d1f - \u21d1g) :=\n  ae_eq_fun.coe_fn_sub \u2191f \u2191g\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} (\u03b1 : Type u_1) [measurable_space \u03b1] (\u03bc : measure \u03b1) (c : E) [finite_measure \u03bc] : ae_eq_fun.const \u03b1 c \u2208 Lp E p \u03bc :=\n  mem_\u2112p.snorm_mk_lt_top (mem_\u2112p_const c)\n\nprotected instance has_norm {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} : has_norm \u21a5(Lp E p \u03bc) :=\n  has_norm.mk fun (f : \u21a5(Lp E p \u03bc)) => ennreal.to_real (snorm (\u21d1f) p \u03bc)\n\ntheorem norm_def {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) : norm f = ennreal.to_real (snorm (\u21d1f) p \u03bc) :=\n  rfl\n\n@[simp] theorem norm_zero {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [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 {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)} (hp : 0 < p) : norm f = 0 \u2194 f = 0 := sorry\n\n@[simp] theorem norm_neg {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)} : norm (-f) = norm f := sorry\n\nprotected instance normed_group {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} [hp : fact (1 \u2264 p)] : normed_group \u21a5(Lp E p \u03bc) :=\n  normed_group.of_core \u21a5(Lp E p \u03bc) sorry\n\ntheorem mem_Lp_const_smul {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] (c : \ud835\udd5c) (f : \u21a5(Lp E p \u03bc)) : c \u2022 \u2191f \u2208 Lp E p \u03bc := sorry\n\nprotected instance has_scalar {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] : has_scalar \ud835\udd5c \u21a5(Lp E p \u03bc) :=\n  has_scalar.mk fun (c : \ud835\udd5c) (f : \u21a5(Lp E p \u03bc)) => { val := c \u2022 \u2191f, property := mem_Lp_const_smul c f }\n\ntheorem coe_fn_smul {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] {f : \u21a5(Lp E p \u03bc)} {c : \ud835\udd5c} : filter.eventually_eq (measure.ae \u03bc) (\u21d1(c \u2022 f)) (c \u2022 \u21d1f) :=\n  ae_eq_fun.coe_fn_smul c \u2191f\n\nprotected instance semimodule {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] : semimodule \ud835\udd5c \u21a5(Lp E p \u03bc) :=\n  semimodule.mk sorry sorry\n\ntheorem norm_const_smul {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] (c : \ud835\udd5c) (f : \u21a5(Lp E p \u03bc)) : norm (c \u2022 f) = norm c * norm f := sorry\n\nprotected instance normed_space {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] [fact (1 \u2264 p)] : normed_space \ud835\udd5c \u21a5(Lp E p \u03bc) :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u211a 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, \u211a, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\nnamespace rat\nvariable {\u03b1 : Type*}\nopen_locale rat\n\nsection with_div_ring\nvariable [division_ring \u03b1]\n\n/-- Construct the canonical injection from `\u211a` 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 \u211a \u03b1 := \u27e8\u03bb r, r.1 / r.2\u27e9\n\ntheorem cast_def (r : \u211a) : (r : \u03b1) = r.num / r.denom := rfl\n\n@[simp] theorem cast_of_int (n : \u2124) : (of_int n : \u03b1) = n :=\nshow (n / (1:\u2115) : \u03b1) = n, by rw [nat.cast_one, div_one]\n\n@[simp, norm_cast] theorem cast_coe_int (n : \u2124) : ((n : \u211a) : \u03b1) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp, norm_cast] theorem cast_coe_nat (n : \u2115) : ((n : \u211a) : \u03b1) = n := cast_coe_int n\n\n@[simp, norm_cast] theorem cast_zero : ((0 : \u211a) : \u03b1) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp, norm_cast] theorem cast_one : ((1 : \u211a) : \u03b1) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem cast_commute (r : \u211a) (a : \u03b1) : commute \u2191r a :=\n(r.1.cast_commute a).div_left (r.2.cast_commute a)\n\ntheorem cast_comm (r : \u211a) (a : \u03b1) : (r : \u03b1) * a = a * r :=\n(cast_commute r a).eq\n\ntheorem commute_cast (a : \u03b1) (r : \u211a) : commute a r :=\n(r.cast_commute a).symm\n\n@[norm_cast] theorem cast_mk_of_ne_zero (a b : \u2124)\n  (b0 : (b:\u03b1) \u2260 0) : (a /. b : \u03b1) = a / b :=\nbegin\n  have b0' : b \u2260 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:\u03b1) \u2260 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:\u2124) \u2223 b, by rwa e at dd) with k ke,\n    have : (b:\u03b1) = (d:\u03b1) * (k:\u03b1), {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 : \u2124 \u2192 \u03b1) ((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 : \u03b1) = n / d,\n  rw [div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq,\n      \u2190 mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\n@[norm_cast] theorem cast_add_of_ne_zero : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m + n : \u211a) : \u03b1) = m + n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', add_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * (d\u2082 * (d\u2082\u207b\u00b9 * d\u2081\u207b\u00b9)) +\n    n\u2082 * (d\u2081 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9 : \u03b1) = n\u2081 * d\u2081\u207b\u00b9 + n\u2082 * d\u2082\u207b\u00b9,\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\u2080, d\u20810, d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820]} },\n  rw [\u2190 mul_assoc (d\u2082:\u03b1), mul_inv_cancel d\u20820, one_mul,\n      (nat.cast_commute _ _).eq], simp [d\u20810, mul_assoc]\nend\n\n@[simp, norm_cast] theorem cast_neg : \u2200 n, ((-n : \u211a) : \u03b1) = -n\n| \u27e8n, d, h, c\u27e9 := show (\u2191-n / d : \u03b1) = -(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 : \u211a}\n  (m0 : (m.denom : \u03b1) \u2260 0) (n0 : (n.denom : \u03b1) \u2260 0) : ((m - n : \u211a) : \u03b1) = m - n :=\nhave ((-n).denom : \u03b1) \u2260 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 : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m * n : \u211a) : \u03b1) = m * n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', mul_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * ((n\u2082 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9) : \u03b1) = n\u2081 * (d\u2081\u207b\u00b9 * (n\u2082 * d\u2082\u207b\u00b9)),\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, mul_inv_rev\u2080, d\u20810, d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820]} },\n  rw [(d\u2081.commute_cast (_:\u03b1)).inv_right\u2080.eq]\nend\n\n@[simp] theorem cast_inv_nat (n : \u2115) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\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 : \u2124) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\nbegin\n  cases n,\n  { exact cast_inv_nat _ },\n  { simp only [int.cast_neg_succ_of_nat, \u2190 nat.cast_succ, cast_neg, inv_neg, cast_inv_nat] }\nend\n\n@[norm_cast] theorem cast_inv_of_ne_zero : \u2200 {n : \u211a},\n  (n.num : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9\n| \u27e8n, d, h, c\u27e9 := \u03bb (n0 : (n:\u03b1) \u2260 0) (d0 : (d:\u03b1) \u2260 0), begin\n  have n0' : (n:\u2124) \u2260 0 := \u03bb e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb 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 : \u211a} (md : (m.denom : \u03b1) \u2260 0)\n  (nn : (n.num : \u03b1) \u2260 0) (nd : (n.denom : \u03b1) \u2260 0) : ((m / n : \u211a) : \u03b1) = m / n :=\nhave (n\u207b\u00b9.denom : \u2124) \u2223 n.num,\nby conv in n\u207b\u00b9.denom { rw [\u2190(@num_denom n), inv_def] };\n   apply denom_dvd,\nhave (n\u207b\u00b9.denom : \u03b1) = 0 \u2192 (n.num : \u03b1) = 0, from\n\u03bb h, let \u27e8k, e\u27e9 := this in\n  by have := congr_arg (coe : \u2124 \u2192 \u03b1) 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 \u03b1] : \u2200 {m n : \u211a}, (m : \u03b1) = n \u2194 m = n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := begin\n  refine \u27e8\u03bb h, _, congr_arg _\u27e9,\n  have d\u20810 : d\u2081 \u2260 0 := ne_of_gt h\u2081,\n  have d\u20820 : d\u2082 \u2260 0 := ne_of_gt h\u2082,\n  have d\u2081a : (d\u2081:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20810,\n  have d\u2082a : (d\u2082:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20820,\n  rw [num_denom', num_denom'] at h \u22a2,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d\u20810, d\u20820] at h \u22a2,\n  rwa [eq_div_iff_mul_eq d\u2082a, division_def, mul_assoc, (d\u2081.cast_commute (d\u2082:\u03b1)).inv_left\u2080.eq,\n    \u2190 mul_assoc, \u2190 division_def, eq_comm, eq_div_iff_mul_eq d\u2081a, eq_comm,\n    \u2190 int.cast_coe_nat, \u2190 int.cast_mul, \u2190 int.cast_coe_nat, \u2190 int.cast_mul,\n    int.cast_inj, \u2190 mk_eq (int.coe_nat_ne_zero.2 d\u20810) (int.coe_nat_ne_zero.2 d\u20820)] at h\nend\n\ntheorem cast_injective [char_zero \u03b1] : function.injective (coe : \u211a \u2192 \u03b1)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) = 0 \u2194 n = 0 :=\nby rw [\u2190 cast_zero, cast_inj]\n\ntheorem cast_ne_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) \u2260 0 \u2194 n \u2260 0 :=\nnot_congr cast_eq_zero\n\n@[simp, norm_cast] theorem cast_add [char_zero \u03b1] (m n) :\n  ((m + n : \u211a) : \u03b1) = 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 \u03b1] (m n) :\n  ((m - n : \u211a) : \u03b1) = 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 \u03b1] (m n) :\n  ((m * n : \u211a) : \u03b1) = 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 \u03b1] (n : \u211a) :\n  ((bit0 n : \u211a) : \u03b1) = bit0 n :=\ncast_add _ _\n\n@[simp, norm_cast] theorem cast_bit1 [char_zero \u03b1] (n : \u211a) :\n  ((bit1 n : \u211a) : \u03b1) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\nvariable (\u03b1)\n\n/-- Coercion `\u211a \u2192 \u03b1` as a `ring_hom`. -/\ndef cast_hom [char_zero \u03b1] : \u211a \u2192+* \u03b1 := \u27e8coe, cast_one, cast_mul, cast_zero, cast_add\u27e9\n\nvariable {\u03b1}\n\n@[simp] lemma coe_cast_hom [char_zero \u03b1] : \u21d1(cast_hom \u03b1) = coe := rfl\n\n@[simp, norm_cast] theorem cast_inv [char_zero \u03b1] (n) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\n(cast_hom \u03b1).map_inv _\n\n@[simp, norm_cast] theorem cast_div [char_zero \u03b1] (m n) :\n  ((m / n : \u211a) : \u03b1) = m / n :=\n(cast_hom \u03b1).map_div _ _\n\n@[norm_cast] theorem cast_mk [char_zero \u03b1] (a b : \u2124) : ((a /. b) : \u03b1) = a / b :=\nby simp only [mk_eq_div, cast_div, cast_coe_int]\n\n@[simp, norm_cast] theorem cast_pow [char_zero \u03b1] (q) (k : \u2115) :\n  ((q ^ k : \u211a) : \u03b1) = q ^ k :=\n(cast_hom \u03b1).map_pow q k\n\nend with_div_ring\n\n@[simp, norm_cast] theorem cast_nonneg [linear_ordered_field \u03b1] : \u2200 {n : \u211a}, 0 \u2264 (n : \u03b1) \u2194 0 \u2264 n\n| \u27e8n, d, h, c\u27e9 :=\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 \u03b1] {m n : \u211a} : (m : \u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw [\u2190 sub_nonneg, \u2190 cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp, norm_cast] theorem cast_lt [linear_ordered_field \u03b1] {m n : \u211a} : (m : \u03b1) < n \u2194 m < n :=\nby simpa [-cast_le] using not_congr (@cast_le \u03b1 _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) \u2264 0 \u2194 n \u2264 0 :=\nby rw [\u2190 cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field \u03b1] {n : \u211a} : (0 : \u03b1) < n \u2194 0 < n :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) < 0 \u2194 n < 0 :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp, norm_cast] theorem cast_id : \u2200 n : \u211a, \u2191n = n\n| \u27e8n, d, h, c\u27e9 := by rw [num_denom', cast_mk, mk_eq_div]\n\n@[simp] lemma cast_hom_rat : cast_hom \u211a = ring_hom.id \u211a :=\nring_hom.ext cast_id\n\n@[simp, norm_cast] theorem cast_min [linear_ordered_field \u03b1] {a b : \u211a} :\n  (\u2191(min a b) : \u03b1) = min a b :=\nby by_cases a \u2264 b; simp [h, min_def]\n\n@[simp, norm_cast] theorem cast_max [linear_ordered_field \u03b1] {a b : \u211a} :\n  (\u2191(max a b) : \u03b1) = max a b :=\nby by_cases b \u2264 a; simp [h, max_def]\n\n@[simp, norm_cast] theorem cast_abs [linear_ordered_field \u03b1] {q : \u211a} :\n  ((|q| : \u211a) : \u03b1) = |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 : \u211a \u2192+* k) (r : \u211a) : f r = r :=\ncalc f r = f (r.1 / r.2) : by rw [\u2190 int.cast_coe_nat, \u2190 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 \u2192+* k') (r : \u211a) :\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 : \u211a \u2192+* R) : f = g :=\nbegin\n  ext r,\n  refine rat.num_denom_cases_on' r _,\n  intros a b b0,\n  let \u03c6 : \u2124 \u2192+* R := f.comp (int.cast_ring_hom \u211a),\n  let \u03c8 : \u2124 \u2192+* R := g.comp (int.cast_ring_hom \u211a),\n  rw [rat.mk_eq_div, int.cast_coe_nat],\n  have b0' : (b:\u211a) \u2260 0 := nat.cast_ne_zero.2 b0,\n  have : \u2200 n : \u2124, f n = g n := \u03bb n, show \u03c6 n = \u03c8 n, by rw [\u03c6.ext_int \u03c8],\n  calc f (a * b\u207b\u00b9)\n      = f a * f b\u207b\u00b9 * (g (b:\u2124) * g b\u207b\u00b9) :\n        by rw [int.cast_coe_nat, \u2190 g.map_mul, mul_inv_cancel b0', g.map_one, mul_one, f.map_mul]\n  ... = g a * f b\u207b\u00b9 * (f (b:\u2124) * g b\u207b\u00b9) : by rw [this a, \u2190 this b]\n  ... = g (a * b\u207b\u00b9) :\n        by rw [int.cast_coe_nat, mul_assoc, \u2190 mul_assoc (f b\u207b\u00b9),\n              \u2190 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 (\u211a \u2192+* R) :=\n\u27e8ring_hom.ext_rat\u27e9\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 `\u03c6`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : \u211a \u2192*\u2080 M}\n  (same_on_int : f.comp (int.cast_ring_hom \u211a).to_monoid_with_zero_hom =\n    g.comp (int.cast_ring_hom \u211a).to_monoid_with_zero_hom) : f = g :=\nbegin\n  have same_on_int' : \u2200 k : \u2124, f k = g k := congr_fun same_on_int,\n  ext x,\n  rw [\u2190 @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 `\u03c6` and its value on `-1` completely determine `\u03c6`. -/\ntheorem ext_rat_on_pnat {f g : \u211a \u2192*\u2080 M}\n  (same_on_neg_one : f (-1) = g (-1)) (same_on_pnat : \u2200 n : \u2115, 0 < n \u2192 f n = g n) : f = g :=\next_rat $ ext_int' (by simpa) \u2039_\u203a\n\nend monoid_with_zero_hom\n\nnamespace mul_opposite\n\nvariables {\u03b1 : Type*} [division_ring \u03b1]\n\n@[simp, norm_cast] lemma op_rat_cast (r : \u211a) : op (r : \u03b1) = (\u2191r : \u03b1\u1d50\u1d52\u1d56) :=\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 : \u211a) : unop (r : \u03b1\u1d50\u1d52\u1d56) = 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 \u03bb-calculus or typed functional programming languages\n(ML, OCaml, Haskell).\n\nTypes `\u03c3`, `\u03c4`, `\u03c5`:\n\n* type variables `\u03b1`;\n* basic types `T`;\n* complex types `T \u03c31 \u2026 \u03c3N`.\n\n-/\n\n#check \u2115\n#check \u2124\n\n#check empty\n#check unit\n#check bool\n\n/-!\nSome type constructors `T` are written infix, e.g., `\u2192` (function type).\n\nThe function arrow is right-associative:\n`\u03c3\u2081 \u2192 \u03c3\u2082 \u2192 \u03c3\u2083 \u2192 \u03c4` = `\u03c3\u2081 \u2192 (\u03c3\u2082 \u2192 (\u03c3\u2083 \u2192 \u03c4))`.\n\n-/ \n\n#check \u2115 \u2192 \u2124\n#check \u2124 \u2192 \u2115\n#check bool \u2192 \u2115 \u2192 \u2124\n#check (bool \u2192 \u2115) \u2192 \u2124\n#check \u2115 \u2192 (bool \u2192 \u2115) \u2192 \u2124\n\n#check prod \u2115 bool \n#check prod\n\n/-!\n\nPolymorphic types are also possible. In Lean, the type variables must be bound\nusing `\u2200`, e.g., `\u2200\u03b1, \u03b1 \u2192 \u03b1`.\n\nYou'll also see the capital Pi `\u03a0` used in place of `\u2200`. \n\n-/\n\n#check \u2200 (\u03b1 : Type), \u03b1 \u2192 \u03b1\n\n/-!\nTerms `t`, `u`:\n\n* constants `c`;\n* variables `x`;\n* applications `t u`;\n* \u03bb-expressions `\u03bbx, 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 \u03bbx : \u2115, x\n#check \u03bbf : \u2115 \u2192 \u2115, \u03bbg : \u2115 \u2192 \u2115, \u03bbh : \u2115 \u2192 \u2115, \u03bbx : \u2115, h (g (f x))\n#check \u03bb(f g h : \u2115 \u2192 \u2115) (x : \u2115), h (g (f x))\n\nconstants a b : \u2124\nconstant f : \u2124 \u2192 \u2124\nconstant g : \u2124 \u2192 \u2124 \u2192 \u2124\n\n#check \u03bbx : \u2124, g (f (g a x)) (g x b)\n#check \u03bbx, g (f (g a x)) (g x b)\n\n#check \u03bbx, 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 \u22a2 t : \u03c3`, meaning `t` has type `\u03c3` in local context `C`.\n\nTyping rules:\n\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Cst   if c is declared with type \u03c3\n    C \u22a2 c : \u03c3\n\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Var   if x : \u03c3 occurs in C\n    C \u22a2 x : \u03c3\n\n    C \u22a2 t : \u03c3 \u2192 \u03c4    C \u22a2 u : \u03c3\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 App\n    C \u22a2 t u : \u03c4\n\n    C, x : \u03c3 \u22a2 t : \u03c4\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Lam\n    C \u22a2 (\u03bbx : \u03c3, t) : \u03c3 \u2192 \u03c4\n\n\n### Type Inhabitation\n\nGiven a type `\u03c3`, the __type inhabitation__ problem consists of finding a term\nof that type.\n\nRecursive procedure:\n\n1. If `\u03c3` is of the form `\u03c4 \u2192 \u03c5`, a candidate inhabitant is an anonymous\n   function of the form `\u03bbx, _`.\n\n2. Alternatively, you can use any constant or variable `x : \u03c4\u2081 \u2192 \u22ef \u2192 \u03c4N \u2192 \u03c3` to\n   build the term `x _ \u2026 _`. -/\n\nconstants \u03b1 \u03b2 \u03b3 : Type\n\ndef some_fun_of_type : (\u03b1 \u2192 \u03b2 \u2192 \u03b3) \u2192 ((\u03b2 \u2192 \u03b1) \u2192 \u03b2) \u2192 \u03b1 \u2192 \u03b3 :=\n\u03bbf g a, f a (g (\u03bbb, 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` (= `\u2115`) of natural numbers, using Peano-style unary\nnotation: -/\n\ninductive nat : Type\n| zero : nat\n| succ : nat \u2192 nat\n\n#check nat\n#check nat.zero\n#check nat.succ\n\nend my_nat\n\n#print nat\n#print \u2115\n\n\n/-! ### Arithmetic Expressions -/\n\ninductive aexp : Type\n| num : \u2124 \u2192 aexp\n| var : string \u2192 aexp\n| add : aexp \u2192 aexp \u2192 aexp\n| sub : aexp \u2192 aexp \u2192 aexp\n| mul : aexp \u2192 aexp \u2192 aexp\n| div : aexp \u2192 aexp \u2192 aexp\n\n\n/-! ### Lists -/\n\nnamespace my_list\n\ninductive list (\u03b1 : Type) : Type\n| nil  : list\n| cons : \u03b1 \u2192 list \u2192 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 : \u2115 \u2192 \u2115 \u2192 \u2115\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 : \u2115 \u2192 \u2115 \u2192 \u2115\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 : \u2115 \u2192 \u2115 \u2192 \u2115\n| _ nat.zero     := 1\n| m (nat.succ n) := m * power m n\n\n#eval power 2 5\n\ndef power\u2082 (m : \u2115) : \u2115 \u2192 \u2115\n| nat.zero     := 1\n| (nat.succ n) := m * power\u2082 n\n\n#eval power\u2082 2 5\n\ndef iter (\u03b1 : Type) (z : \u03b1) (f : \u03b1 \u2192 \u03b1) : \u2115 \u2192 \u03b1\n| nat.zero     := z\n| (nat.succ n) := f (iter n)\n\n#check iter\n\ndef power\u2083 (m n : \u2115) : \u2115 :=\niter \u2115 1 (\u03bbl, m * l) n\n\n#eval power\u2083 2 5\n\ndef append (\u03b1 : Type) : list \u03b1 \u2192 list \u03b1 \u2192 list \u03b1\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\u2081, \u2026, xN]` := `x\u2081 :: \u2026 :: xN :: []` -/\n\ndef append\u2082 {\u03b1 : Type} : list \u03b1 \u2192 list \u03b1 \u2192 list \u03b1\n| list.nil         ys := ys\n| (list.cons x xs) ys := list.cons x (append\u2082 xs ys)\n\n#check append\u2082\n#eval append\u2082 [3, 1] [4, 1, 5]\n\n#check @append\u2082\n#eval @append\u2082 _ [3, 1] [4, 1, 5]\n\ndef append\u2083 {\u03b1 : Type} : list \u03b1 \u2192 list \u03b1 \u2192 list \u03b1\n| []        ys := ys\n| (x :: xs) ys := x :: append\u2083 xs ys\n\ndef reverse {\u03b1 : Type} : list \u03b1 \u2192 list \u03b1\n| []        := []\n| (x :: xs) := reverse xs ++ [x]\n\ndef eval (env : string \u2192 \u2124) : aexp \u2192 \u2124\n| (aexp.num i)     := i\n| (aexp.var x)     := env x\n| (aexp.add e\u2081 e\u2082) := eval e\u2081 + eval e\u2082\n| (aexp.sub e\u2081 e\u2082) := eval e\u2081 - eval e\u2082\n| (aexp.mul e\u2081 e\u2082) := eval e\u2081 * eval e\u2082\n| (aexp.div e\u2081 e\u2082) := eval e\u2081 / eval e\u2082\n\n#eval eval (\u03bbs, 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 : \u2115) :\n  add m n = add n m :=\nsorry\n\nlemma add_assoc (l m n : \u2115) :\n  add (add l m) n = add l (add m n) :=\nsorry\n\nlemma mul_comm (m n : \u2115) :\n  mul m n = mul n m :=\nsorry\n\nlemma mul_assoc (l m n : \u2115) :\n  mul (mul l m) n = mul l (mul m n) :=\nsorry\n\nlemma mul_add (l m n : \u2115) :\n  mul l (add m n) = add (mul l m) (mul l n) :=\nsorry\n\nlemma reverse_reverse {\u03b1 : Type} (xs : list \u03b1) :\n  reverse (reverse xs) = xs :=\nsorry\n\n/-! Axioms are like lemmas but without proofs (`:= \u2026`). Constant declarations\nare like definitions but without bodies (`:= \u2026`). -/\n\nconstants a b : \u2124\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 {\u03b1 : Type u} {\u03b2 : Type v}\n\n/- Indices of a list -/\n@[derive decidable_eq]\ninductive pointer: list \u03b1 \u2192 Type u\n| here (x : \u03b1) (xs : list \u03b1): pointer (x :: xs)\n| tail {xs : list \u03b1} (y : \u03b1): pointer xs \u2192 pointer (y :: xs)\n\n/- List membership with concrete witness (position) -/\n@[derive decidable_eq]\ninductive list_at: \u03b1 \u2192 list \u03b1 \u2192 Type u\n| here (x : \u03b1) (xs : list \u03b1): list_at x (x :: xs)\n| tail {x : \u03b1} {l : list \u03b1} (y : \u03b1): list_at x l \u2192 list_at x (y :: l)\n\nlemma list_at_mem {x : \u03b1} {l : list \u03b1} : list_at x l \u2192 x \u2208 l :=\nbegin\n    intro H,\n    induction l,\n    cases H,\n    cases H,\n    constructor, refl,\n    have: x \u2208 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 (\u03b1 : Type u) := (l : list \u03b1)\n\n@[reducible]\ndef queue.add (q : queue \u03b1) (x : \u03b1) : queue \u03b1 := \u27e8q.l ++ [x]\u27e9\n@[reducible]\ndef queue.empty : queue \u03b1 \u2192 bool\n| \u27e8[]\u27e9 := tt\n| \u27e8(x :: l)\u27e9 := ff\ndef queue.full : queue \u03b1 \u2192 Prop := \u03bbq, q \u2260 \u27e8[]\u27e9\n@[reducible]\ndef queue.remove : \u03a0 q : queue \u03b1, queue.full q \u2192 \u03b1 \u00d7 queue \u03b1\n| \u27e8[]\u27e9 H := begin exfalso, apply H, simp end\n| \u27e8(x :: l)\u27e9 _ := \u27e8x, \u27e8l\u27e9\u27e9\n@[reducible]\ndef queue.first (q : queue \u03b1) (H : queue.full q) : \u03b1 :=\n  (queue.remove q H).fst\n@[reducible]\ndef queue.unshift (q : queue \u03b1) (H : queue.full q) : queue \u03b1 :=\n  (queue.remove q H).snd\n@[reducible]\ndef queue.poll : queue \u03b1 \u2192 option (\u03b1 \u00d7 queue \u03b1)\n| \u27e8[]\u27e9 := none\n| \u27e8(x :: l)\u27e9 := some \u27e8x, \u27e8l\u27e9\u27e9\ninstance queue.has_zero : has_zero (queue \u03b1) := \u27e8\u27e8[]\u27e9\u27e9\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 \u03b1] [decidable_eq \u03b2] [has_zero \u03b2]\n\ndef update (f : \u03b1 \u2192\u2080 \u03b2) (a : \u03b1) (b : \u03b2) : \u03b1 \u2192\u2080 \u03b2 :=\n  \u27e8if b = 0 then f.support.erase a else f.support \u222a {a},\n   (\u03bba', if a = a' then b else f a'), \u03bba',\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 : \u00aca' = a, intro, apply H,\n            apply eq.symm, assumption, \n          exact \u27e8this, a_1\u27e9 } },\n      { split, {intro, cases a_1, exfalso,\n          apply H, apply eq.symm, assumption, assumption},\n        { intro, right, assumption } }\n    end\u27e9\n\n@[simp]\ntheorem update.to_fun (f : \u03b1 \u2192\u2080 \u03b2) (a : \u03b1) (b : \u03b2) :\n  (update f a b).to_fun = (\u03bba', if a = a' then b else f a') := rfl\n\n@[simp]\ntheorem update.app_new_eq (f : \u03b1 \u2192\u2080 \u03b2) (a : \u03b1) (b : \u03b2) :\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 : \u03b1 \u2192\u2080 \u03b2) (a : \u03b1) (b : \u03b2)\n    (c : \u03b1) (H : a \u2260 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 {\u03b2 : Sort v} (t : option \u03b1)\n    (f : t = none \u2192 \u03b2) (g : \u03a0(a : \u03b1), t = some a \u2192 \u03b2) : \u03b2 :=\n  match t, rfl : (\u2200 b, t = b \u2192 \u03b2) 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 : \u03b1} :\n  head (lift (@nil \u03b1)) \u2260 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 : \u03b1} {tl : list \u03b1} :\n  head (lift (list.cons hd tl)) = some a \u2192 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 \u03b1]\n  (rem: finset \u03b1) (elem: \u03b1) : Type\n| mk: elem \u2209 rem \u2192 decomp_finset\ninstance decomp_finset.coe_finset [decidable_eq \u03b1]\n  (rem: finset \u03b1) (elem: \u03b1) : has_coe (decomp_finset rem elem) (finset \u03b1) := \u27e8\u03bb_, rem \u222a {elem}\u27e9\n\nnotation \u0393 `;;` x := decomp_finset \u0393 x\n\n/- Existence of a proof of a proposition implies that proposition. -/\nlemma exists_proof_prop (P Q : Prop) : (\u2203x : P, Q) \u2192 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 : \u2124) (hn : 0 < n) (hk : 0 \u2264 k + n) (hu : 0 \u2264 u)\n  (h : k + n = 2 + x) (f : false) :\n  k + n = m + x :=\nbegin\n  lift n to \u2115 using le_of_lt hn,\n    guard_target (k + \u2191n = m + x), guard_hyp hn : (0 : \u2124) < \u2191n,\n  lift m to \u2115,\n    guard_target (k + \u2191n = \u2191m + x), tactic.swap, guard_target (0 \u2264 m), tactic.swap,\n    tactic.num_goals >>= \u03bb n, guard (n = 2),\n  lift (k + n) to \u2115 using hk with l hl,\n    guard_hyp l : \u2115, guard_hyp hl : \u2191l = k + \u2191n, guard_target (\u2191l = \u2191m + x),\n    tactic.success_if_fail (tactic.get_local `hk),\n  lift x to \u2115 with y hy,\n    guard_hyp y : \u2115, guard_hyp hy : \u2191y = x, guard_target (\u2191l = \u2191m + x),\n  lift z to \u2115 with w,\n    guard_hyp w : \u2115, tactic.success_if_fail (tactic.get_local `z),\n  lift u to \u2115 using hu with u rfl hu,\n    guard_hyp hu : (0 : \u2124) \u2264 \u2191u,\n\n  all_goals { exfalso, assumption },\nend\n\n-- test lift of functions\nexample (\u03b1 : Type*) (f : \u03b1 \u2192 \u2124) (hf : \u2200 a, 0 \u2264 f a) (hf' : \u2200 a, f a < 1) (a : \u03b1) : 0 \u2264 2 * f a :=\nbegin\n  lift f to \u03b1 \u2192 \u2115 using hf,\n    guard_target ((0:\u2124) \u2264 2 * (\u03bb i : \u03b1, (f i : \u2124)) a),\n    guard_hyp hf' : \u2200 a, ((\u03bb i : \u03b1, (f i:\u2124)) a) < 1,\n  exact int.coe_nat_nonneg _\nend\n\n-- fail gracefully when the lifted variable is a local definition\nexample : let n : \u2124 := 3 in n = n :=\nbegin\n  intro n,\n  success_if_fail_with_msg { lift n to \u2115 }\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\u27e8id, \u03bb x, true, \u03bb x _, \u27e8x, rfl\u27e9\u27e9\n\n/- test whether new instances of `can_lift` are added as simp lemmas -/\nrun_cmd do l \u2190 can_lift_attr.get_cache, guard (`can_lift_unit \u2208 l)\n\n/- test error messages -/\nexample (n : \u2124) (hn : 0 < n) : true :=\nbegin\n  success_if_fail_with_msg {lift n to \u2115 using hn} \"lift tactic failed.\ninvalid type ascription, term has type\\n  0 < n\\nbut is expected to have type\\n  0 \u2264 n\",\n  success_if_fail_with_msg {lift (n : option \u2124) to \u2115}\n    \"Failed to find a lift from option \u2124 to \u2115. Provide an instance of\\n  can_lift (option \u2124) \u2115\",\n  trivial\nend\n\nexample (n : \u2124) : \u2115 :=\nbegin\n  success_if_fail_with_msg {lift n to \u2115}\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 \u2192 Prop) : can_lift R {x // P x} :=\n{ coe := coe,\n  cond := \u03bb x, P x,\n  prf := \u03bb x hx, \u27e8\u27e8x, hx\u27e9, rfl\u27e9 }\n\ninstance can_lift_set (R : Type*) (s : set R) : can_lift R s :=\n{ coe := coe,\n  cond := \u03bb x, x \u2208 s,\n  prf := \u03bb x hx, \u27e8\u27e8x, hx\u27e9, rfl\u27e9 }\n\nexample {R : Type*} {P : R \u2192 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 \u2208 s) : true :=\nby { lift x to s using hx with y, trivial }\n\nexample (n : \u2124) (hn : 0 \u2264 n) : true :=\nby { lift n to \u2115, trivial, exact hn }\n\nexample (n : \u2124) (hn : 0 \u2264 n) : true :=\nby { lift n to \u2115 using hn, trivial }\n\nexample (n : \u2124) (hn : n \u2265 0) : true :=\nby { lift n to \u2115 using ge.le _, trivial, guard_target (n \u2265 0), exact hn }\n\nexample (n : \u2124) (hn : 0 \u2264 1 * n) : true :=\nbegin\n  lift n to \u2115 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 \u2264 1 * ((k : \u2115) : \u2124),\n  trivial\nend\n\nexample (n : \u2124) (hn : 0 \u2264 n \u2194 true) : true :=\nbegin\n  lift n to \u2115 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 : \u03b9 \u2192 finset \u03b1` have `\u03b9` be a `fintype`.\nThe `combinatorics.hall.basic` module applies a compactness argument to this version\nto remove the `fintype` constraint on `\u03b9`.\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 {\u03b9 : Type u} {\u03b1 : Type v} [fintype \u03b9] {t : \u03b9 \u2192 finset \u03b1} [decidable_eq \u03b1]\n\nlemma hall_cond_of_erase {x : \u03b9} (a : \u03b1)\n  (ha : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card)\n  (s' : finset {x' : \u03b9 | x' \u2260 x}) :\n  s'.card \u2264 (s'.bUnion (\u03bb x', (t x').erase a)).card :=\nbegin\n  haveI := classical.dec_eq \u03b9,\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 (\u03bb x, t x)).card,\n    { convert ha he (\u03bb h, by simpa [\u2190h] 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 \u2190erase_bUnion,\n    by_cases hb : a \u2208 s'.bUnion (\u03bb 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`\u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`\u03b9'` of cardinality \u2264 `n`, then it is true for `\u03b9` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_A {n : \u2115} (hn : fintype.card \u03b9 = n + 1)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (ih : \u2200 {\u03b9' : Type u} [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n        by exactI fintype.card \u03b9' \u2264 n \u2192\n                  (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                  \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x)\n  (ha : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  haveI : nonempty \u03b9 := fintype.card_pos_iff.mp (hn.symm \u25b8 nat.succ_pos _),\n  haveI := classical.dec_eq \u03b9,\n  /- Choose an arbitrary element `x : \u03b9` and `y : t x`. -/\n  let x := classical.arbitrary \u03b9,\n  have tx_ne : (t x).nonempty,\n  { rw \u2190finset.card_pos,\n    calc 0 < 1 : nat.one_pos\n       ... \u2264 (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 \u03b9' := {x' : \u03b9 | x' \u2260 x},\n  let t' : \u03b9' \u2192 finset \u03b1 := \u03bb x', (t x').erase y,\n  have card_\u03b9' : fintype.card \u03b9' = n :=\n    calc fintype.card \u03b9' = fintype.card \u03b9 - 1 : set.card_ne_eq _\n                     ... = n : by { rw [hn, nat.add_succ_sub_one, add_zero], },\n  rcases ih t' card_\u03b9'.le (hall_cond_of_erase y ha) with \u27e8f', hfinj, hfr\u27e9,\n  /- Extend the resulting function. -/\n  refine \u27e8\u03bb z, if h : z = x then y else f' \u27e8z, h\u27e9, _, _\u27e9,\n  { rintro z\u2081 z\u2082,\n    have key : \u2200 {x}, y \u2260 f' x,\n    { intros x h,\n      simpa [\u2190h] using hfr x, },\n    by_cases h\u2081 : z\u2081 = x; by_cases h\u2082 : z\u2082 = x; simp [h\u2081, h\u2082, hfinj.eq_iff, key, key.symm], },\n  { intro z,\n    split_ifs with hz,\n    { rwa hz },\n    { specialize hfr \u27e8z, hz\u27e9,\n      rw mem_erase at hfr,\n      exact hfr.2, }, },\nend\n\nlemma hall_cond_of_restrict {\u03b9 : Type u} {t : \u03b9 \u2192 finset \u03b1} {s : finset \u03b9}\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (s' : finset (s : set \u03b9)) :\n  s'.card \u2264 (s'.bUnion (\u03bb a', t a')).card :=\nbegin\n  classical,\n  rw \u2190 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 {\u03b9 : Type u} {t : \u03b9 \u2192 finset \u03b1} {s : finset \u03b9}\n  (hus : s.card = (s.bUnion t).card)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (s' : finset (s\u1d9c : set \u03b9)) :\n  s'.card \u2264 (s'.bUnion (\u03bb x', t x' \\ s.bUnion t)).card :=\nbegin\n  haveI := classical.dec_eq \u03b9,\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 \u222a 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 \u2190 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 | \u27e8x', hx', rfl\u27e9) rat hs,\n    { exact (hs x hx rat).elim },\n    { exact \u27e8\u27e8x', hx', rat\u27e9, hs\u27e9, } },\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`\u2203 (s : finset \u03b9), s \u2260 univ \u2192 s.card = (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`\u03b9'` of cardinality \u2264 `n`, then it is true for `\u03b9` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_B {n : \u2115} (hn : fintype.card \u03b9 = n + 1)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (ih : \u2200 {\u03b9' : Type u} [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n        by exactI fintype.card \u03b9' \u2264 n \u2192\n                  (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                  \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x)\n  (s : finset \u03b9)\n  (hs : s.nonempty)\n  (hns : s \u2260 univ)\n  (hus : s.card = (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  haveI := classical.dec_eq \u03b9,\n  /- Restrict to `s` -/\n  let t' : s \u2192 finset \u03b1 := \u03bb x', t x',\n  rw nat.add_one at hn,\n  have card_\u03b9'_le : fintype.card s \u2264 n,\n  { apply nat.le_of_lt_succ,\n    calc fintype.card s = s.card : fintype.card_coe _\n                    ... < fintype.card \u03b9 : (card_lt_iff_ne_univ _).mpr hns\n                    ... = n.succ : hn },\n  rcases ih t' card_\u03b9'_le (hall_cond_of_restrict ht) with \u27e8f', hf', hsf'\u27e9,\n  /- Restrict to `s\u1d9c` in the domain and `(s.bUnion t)\u1d9c` in the codomain. -/\n  set \u03b9'' := (s : set \u03b9)\u1d9c with \u03b9''_def,\n  let t'' : \u03b9'' \u2192 finset \u03b1 := \u03bb a'', t a'' \\ s.bUnion t,\n  have card_\u03b9''_le : fintype.card \u03b9'' \u2264 n,\n  { simp_rw [\u2190 nat.lt_succ_iff, \u2190 hn, \u03b9'', \u2190 finset.coe_compl, coe_sort_coe],\n    rwa [fintype.card_coe, card_compl_lt_iff_nonempty] },\n  rcases ih t'' card_\u03b9''_le (hall_cond_of_compl hus ht) with \u27e8f'', hf'', hsf''\u27e9,\n  /- Put them together -/\n  have f'_mem_bUnion : \u2200 {x'} (hx' : x' \u2208 s), f' \u27e8x', hx'\u27e9 \u2208 s.bUnion t,\n  { intros x' hx',\n    rw mem_bUnion,\n    exact \u27e8x', hx', hsf' _\u27e9, },\n  have f''_not_mem_bUnion : \u2200 {x''} (hx'' : \u00ac x'' \u2208 s), \u00ac f'' \u27e8x'', hx''\u27e9 \u2208 s.bUnion t,\n  { intros x'' hx'',\n    have h := hsf'' \u27e8x'', hx''\u27e9,\n    rw mem_sdiff at h,\n    exact h.2, },\n  have im_disj : \u2200 (x' x'' : \u03b9) (hx' : x' \u2208 s) (hx'' : \u00acx'' \u2208 s), f' \u27e8x', hx'\u27e9 \u2260 f'' \u27e8x'', hx''\u27e9,\n  { intros _ _ hx' hx'' h,\n    apply f''_not_mem_bUnion hx'',\n    rw \u2190h,\n    apply f'_mem_bUnion, },\n  refine \u27e8\u03bb x, if h : x \u2208 s then f' \u27e8x, h\u27e9 else f'' \u27e8x, h\u27e9, _, _\u27e9,\n  { exact hf'.dite _ hf'' im_disj },\n  { intro x,\n    split_ifs with h,\n    { exact hsf' \u27e8x, h\u27e9 },\n    { exact sdiff_subset _ _ (hsf'' \u27e8x, h\u27e9) } }\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 : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  unfreezingI\n  { induction hn : fintype.card \u03b9 using nat.strong_induction_on with n ih generalizing \u03b9 },\n  rcases n with _|_,\n  { rw fintype.card_eq_zero_iff at hn,\n    exactI \u27e8is_empty_elim, is_empty_elim, is_empty_elim\u27e9, },\n  { have ih' : \u2200 (\u03b9' : Type u) [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n                 by exactI fintype.card \u03b9' \u2264 n \u2192\n                    (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                    \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x,\n    { introsI \u03b9' _ _ h\u03b9' ht',\n      exact ih _ (nat.lt_succ_of_le h\u03b9') ht' rfl, },\n    by_cases h : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 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 \u27e8s, sne, snu, sle\u27e9,\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 : \u03b9 \u2192 finset \u03b1` with `\u03b9` 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 \u03b9` constraint is removed.\n-/\ntheorem finset.all_card_le_bUnion_card_iff_exists_injective'\n  {\u03b9 \u03b1 : Type*} [fintype \u03b9] [decidable_eq \u03b1] (t : \u03b9 \u2192 finset \u03b1) :\n  (\u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card) \u2194\n    (\u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x) :=\nbegin\n  split,\n  { exact hall_marriage_theorem.hall_hard_inductive },\n  { rintro \u27e8f, hf\u2081, hf\u2082\u27e9 s,\n    rw \u2190card_image_of_injective s hf\u2081,\n    apply card_le_of_subset,\n    intro _,\n    rw [mem_image, mem_bUnion],\n    rintros \u27e8x, hx, rfl\u27e9,\n    exact \u27e8x, hx, hf\u2082 x\u27e9, },\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 {\u03b1 \u03b2 \u03b3 \u03b4 : Sort*}\n\nnamespace pprod\n\n@[simp] lemma mk.eta {p : pprod \u03b1 \u03b2} : pprod.mk p.1 p.2 = p :=\npprod.cases_on p (\u03bb a b, rfl)\n\n@[simp] theorem \u00abforall\u00bb {p : pprod \u03b1 \u03b2 \u2192 Prop} : (\u2200 x, p x) \u2194 (\u2200 a b, p \u27e8a, b\u27e9) :=\n\u27e8assume h a b, h \u27e8a, b\u27e9, assume h \u27e8a, b\u27e9, h a b\u27e9\n\n@[simp] theorem \u00abexists\u00bb {p : pprod \u03b1 \u03b2 \u2192 Prop} : (\u2203 x, p x) \u2194 (\u2203 a b, p \u27e8a, b\u27e9) :=\n\u27e8assume \u27e8\u27e8a, b\u27e9, h\u27e9, \u27e8a, b, h\u27e9, assume \u27e8a, b, h\u27e9, \u27e8\u27e8a, b\u27e9, h\u27e9\u27e9\n\ntheorem forall' {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2200 x : pprod \u03b1 \u03b2, p x.1 x.2) \u2194 \u2200 a b, p a b :=\npprod.forall\n\ntheorem exists' {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2203 x : pprod \u03b1 \u03b2, p x.1 x.2) \u2194 \u2203 a b, p a b :=\npprod.exists\n\nend pprod\n\nlemma function.injective.pprod_map {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b4} (hf : injective f) (hg : injective g) :\n  injective (\u03bb x, \u27e8f x.1, g x.2\u27e9 : pprod \u03b1 \u03b3 \u2192 pprod \u03b2 \u03b4) :=\n\u03bb \u27e8x\u2081, x\u2082\u27e9 \u27e8y\u2081, y\u2082\u27e9 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\u00e9montrer de nombreux\nth\u00e9or\u00e8mes parmi les plus subtils de Math 101 : la caract\u00e9risation\ns\u00e9quentielle des bornes sup\u00e9rieures, l'\u00e9quivalence entre continuit\u00e9\ns\u00e9quentielle et continuit\u00e9, le fait que toute fonction continue sur un segment\nest major\u00e9e et atteint son maximum, et enfin le th\u00e9or\u00e8me des valeurs\ninterm\u00e9diaires.\n\nIl est inutile d'aborder cette feuille sans \u00eatre \u00e0 l'aise avec les feuilles\npr\u00e9c\u00e9dentes. R\u00e9viser les feuilles pr\u00e9c\u00e9dentes et poser des questions est toujours \nune bonne id\u00e9e.\n\nOn commence par un \u00e9chauffement, une variante du\n\n  lim_le (hu : limite_suite u x) (ineg : \u2200 n, u n \u2264 y) : x \u2264 y\n\nde la feuille 11, avec l'autre in\u00e9galit\u00e9 et seulement \u00e0 partir d'un certain rang.\n\nOn pourra utiliser les lemmes habituels :\n\n  `abs_inferieur_ssi (x y : \u211d) : |x| \u2264 y \u2194 -y \u2264 x \u2227 x \u2264 y`\n\n  `superieur_max_ssi (p q r) : r \u2265 max p q  \u2194 r \u2265 p \u2227 r \u2265 q`\n\n  `inferieur_max_gauche p q : p \u2264 max p q`\n\n  `inferieur_max_droite p q : q \u2264 max p q`\n\nainsi que le lemme\n\n  `inferieur_si_inferieur_plus_eps : (\u2200 \u03b5 > 0, y \u2264 x + \u03b5) \u2192  y \u2264 x`\n\nd\u00e9montr\u00e9 dans la feuille 11\n-/\n\n-- Si u tend vers x et y \u2264 u_n pour n assez grand n alors y \u2264 x.\nlemma le_lim {x y : \u211d} {u : \u2115 \u2192 \u211d} (hu : limite_suite u x)\n  (ineg : \u2203 N, \u2200 n \u2265 N, y \u2264 u n) : y \u2264 x :=\nbegin\n  sorry\nend\n\n/-\nLe premier objectif s\u00e9rieux de cette feuille est de d\u00e9montrer la caract\u00e9risation\ns\u00e9quentielle des bornes sup\u00e9rieures. Pour cela, et pour les objectifs suivants,\nnous aurons besoin de pas mal de choses des feuilles pr\u00e9c\u00e9dentes, et de\nquelques extras.\n\nNous avons d\u00e9montr\u00e9 dans la feuille 8 qu'une suite constante converge vers\nsa valeur :\n\n  `lim_constante (x : \u211d) : limite_suite (fct n \u21a6 x) x`\n\net le th\u00e9or\u00e8me des gendarmes :\n\n  `gendarmes (lim_u : limite_suite u l) (lim_w : limite_suite w l)`\n    `(hu : \u2200 n, u n \u2264 v n) (hw : \u2200 n, v n \u2264 w n)  : limite_suite v l`\n\nDans la feuille 11, nous avons introduit les deux d\u00e9finitions :\n\n  Le r\u00e9el x est un majorant de l'ensemble de r\u00e9els A :\n  `def majorant (A : set \u211d) (x : \u211d) := \u2200 a \u2208 A, a \u2264 x`\n\n  Le r\u00e9el x est une  borne sup\u00e9rieure de l'ensemble de r\u00e9els A :\n  `def borne_sup (A : set \u211d) (x : \u211d) := majorant A x \u2227 \u2200 y, majorant A y \u2192 x \u2264 y`\n\net montr\u00e9 que si un r\u00e9el x est borne sup\u00e9rieure d'un ensemble de r\u00e9els 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) : \u2200 y, y < x \u2192 \u2203 a \u2208 A, y < a`\n\nDans les exercices suivants, on pourra aussi utiliser les lemmes\n\n  `inv_succ_pos : \u2200 n : \u2115, 1/(n + 1 : \u211d) > 0`\n\n  `limite_inv_succ :  \u2200 \u03b5 > 0, \u2203 N : \u2115, \u2200 n \u2265 N, 1/(n + 1 : \u211d) \u2264 \u03b5`\n\net les cons\u00e9quences faciles suivantes de limite_inv_succ :\n\n  `limite_si_inferieur_un_sur (h : \u2200 n, |u n - x| \u2264 1/(n+1)) : limite_suite u x`\n\n  `lim_plus_un_sur (x : \u211d) : limite_suite (fct n \u21a6 x + 1/(n+1)) x`\n\n  `lim_moins_un_sur (x : \u211d) : limite_suite (fct n \u21a6 x - 1/(n+1)) x`\n\nLa structure de la d\u00e9monstration est offerte. Les accolades servent \u00e0\nd\u00e9limiter les objectifs interm\u00e9diaires, tout en faisant provisoirement\ndispara\u00eetre l'affichage des objectifs en attente. Il ne faut surtout pas\nles supprimer, sous peine de se perdre irr\u00e9m\u00e9diablement.\n\nEnfin on notera l'apparition dans la structure de d\u00e9monstration ci-dessous\nde la commande `Par ... on choisit ... tel que`. Cette commande est d\u00e9crite \ndans la derni\u00e8re section du chapitre 3 du cours, intitul\u00e9e \n\u00ab Utilisation d'un \u2200x, \u2203y et axiome du choix \u00bb\n(qu'il convient donc de relire ou de lire), mais n'\u00e9tait pas encore apparue\ndans les exercices.\n-/\n\n-- Un r\u00e9el x est borne sup\u00e9rieure d'un ensemble de r\u00e9els A ssi il est\n-- majorant de A et il existe une suite d'\u00e9l\u00e9ments de A qui tend vers x.\nlemma borne_sup_ssi (A : set \u211d) (x : \u211d) :\n(borne_sup A x) \u2194 (majorant A x \u2227 \u2203 u : \u2115 \u2192 \u211d, limite_suite u x \u2227 \u2200 n, u n \u2208 A) :=\nbegin\n  Montrons que (borne_sup A x) \u2192 (majorant A x \u2227 \u2203 u : \u2115 \u2192 \u211d, limite_suite u x \u2227 \u2200 n, u n \u2208 A),\n  { Supposons h : borne_sup A x,\n    Montrons que majorant A x,\n    { \n  sorry\n    },\n    Montrons que \u2203 (u : \u2115 \u2192 \u211d), limite_suite u x \u2227 \u2200 n, u n \u2208 A,\n    { Fait F1 : \u2200 n : \u2115, \u2203 a \u2208 A, x - 1/(n+1) < a,\n      { \n  sorry\n        },\n      Par F1 on choisit u tel que (hu : \u2200 n, u n \u2208 A) (hu' : \u2200 (n : \u2115), x - 1 / (n + 1 : \u211d) < u n),\n  sorry\n           } },\n  { \n  sorry\n      },\nend\n\n\n/-\nLes autres exercices de cette feuille utiliseront la d\u00e9finition de la\ncontinuit\u00e9 d'une fonction de \u211d dans \u211d en un point de \u211d.\n-/\n\n/-- La fonction `f` est continue en `x\u2080`. -/\ndef continue_en (f : \u211d \u2192 \u211d) (x\u2080 : \u211d) : Prop :=\n\u2200 \u03b5 > 0, \u2203 \u03b4 > 0, \u2200 x, |x - x\u2080| \u2264 \u03b4 \u2192 |f x - f x\u2080| \u2264 \u03b5\n\n-- Dans la suite, f d\u00e9signera une fonction de \u211d dans \u211d, x\u2080 un r\u00e9el et u\n-- une suite de r\u00e9els\nvariables {f : \u211d \u2192 \u211d} {x\u2080 : \u211d} {u : \u2115 \u2192 \u211d}\n\n/-\nOn commence par un \u00e9chauffement concernant d\u00e9finition de la continuit\u00e9.\n-/\n\n/-- Une fonction continue en x\u2080 est s\u00e9quentiellement continue en x\u2080 -/\nlemma seq_continue_si_continue (hf : continue_en f x\u2080)\n  (hu : limite_suite u x\u2080) : limite_suite (f \u2218 u) (f x\u2080) :=\nbegin\n  sorry\nend\n\n/-\nLa r\u00e9ciproque de du lemme pr\u00e9c\u00e9dent est vraie aussi :\nLa continuit\u00e9 s\u00e9quentielle en x\u2080 implique la continuit\u00e9 en x\u2080.\nMais la d\u00e9monstration est moins courte. On pourra s'inspirer de\nla d\u00e9monstration de borne_sup_ssi (et du poly de math 101 !).\n-/\nexample :\n  (\u2200 u : \u2115 \u2192 \u211d, limite_suite u x\u2080 \u2192 limite_suite (f \u2218 u) (f x\u2080)) \u2192\n  continue_en f x\u2080 :=\nbegin\n  sorry\nend\n\n/-\nDans la suite, \u00e9tant donn\u00e9s deux r\u00e9els,\non utilise la notation habituelle [a, b] pour d\u00e9signer 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\u00e9finition d'un segment assure le\nlemme suivant (dont l'utilisation est rarement n\u00e9cessaire vu qu'il ne fait que\nd\u00e9plier une d\u00e9finition).\n-/\n\nlemma dans_segment {a b x : \u211d}  : x \u2208 [a, b] \u2194 a \u2264 x \u2227 x \u2264 b :=\niff.rfl -- cette ligne signifie : \u00ab C'est \u00e9quivalent par d\u00e9finition. \u00bb\n\n/-\nNous avons vu dans la feuille 9 les d\u00e9finitions et le lemme :\n\nUne extraction est une fonction strictement croissante de \u2115 dans \u2115 :\n\n  `def extraction (\u03c6 : \u2115 \u2192 \u2115) := \u2200 n m, n < m \u2192 \u03c6 n < \u03c6 m`\n\nUn r\u00e9el a est valeur d'adh\u00e9rence d'une suite u s'il\nexiste une suite extraite de u qui tend vers a.\n\n  `def valeur_adherence (u : \u2115 \u2192 \u211d) (a : \u211d) := \u2203 \u03c6, extraction \u03c6 \u2227 limite_suite (u \u2218 \u03c6) a`\n\nToute extraction est sup\u00e9rieure \u00e0 l'identit\u00e9 :\n\n  `extraction_superieur_id : extraction \u03c6 \u2192 \u2200 n, n \u2264 \u03c6 n`\n\nEt dans la feuille 11 la d\u00e9finition et le lemme :\n\nLa suite u tend vers +\u221e.\n\n  `def limite_infinie_suite (u : \u2115 \u2192 \u211d) := \u2200 A, \u2203 N, \u2200 n \u2265 N, u n \u2265 A`\n\nSi u tend vers +\u221e alors u ne tend vers aucune limite finie\n\n  `limite_infinie_pas_finie : limite_infinie_suite u \u2192 \u2200 l, \u00ac limite_suite u l`\n-/\n\n-- Dans la suite, \u03c6 sera une fonction de \u2115 dans \u2115\nvariables {\u03c6 : \u2115 \u2192 \u2115}\n\n\n/-- Si `u` tend vers `+\u221e` alors toutes ses suites extraites tendent vers `+\u221e`. -/\nlemma limite_infinie_extraction_si_limite\n  (h : limite_infinie_suite u) (h\u03c6 : extraction \u03c6) :\nlimite_infinie_suite (u \u2218 \u03c6) :=\nbegin\n  sorry\nend\n\nlemma limite_infinie_gendarme {u v : \u2115 \u2192 \u211d} (hu : limite_infinie_suite u)\n(huv : \u2200 n, u n \u2264 v n) : limite_infinie_suite v :=\nbegin\n  sorry\nend\n\n/-\nDans la suite, on pourra aussi utiliser le th\u00e9or\u00e8me de Bolzano-Weirstrass :\n\nToute suite \u00e0 valeur dans un segment [a, b] admet une valeur d'adh\u00e9rence\ndans [a, b].\n\n  `bolzano_weierstrass (h : \u2200 n, u n \u2208 [a, b]) : \u2203 c \u2208 [a, b], valeur_adherence u c`\n\nCe th\u00e9or\u00e8me se d\u00e9montre \u00e0 partir du th\u00e9or\u00e8me de la borne sup\u00e9rieure, mais il\nfaut construire une suite par r\u00e9currence, ce que nous n'avons pas appris \u00e0\nfaire dans Lean.\n\nOn pourra utiliser aussi le lemme suivant, qui lui est \u00e9vident\n\n  `limite_suite_id : limite_infinie_suite (fct n \u21a6 n)`\n-/\n\n-- Toute fonction continue sur un segment y est major\u00e9e.\nlemma majoree_segment {f : \u211d \u2192 \u211d} {a b : \u211d} (hf : \u2200 x \u2208 [a, b], continue_en f x) :\n\u2203 M, \u2200 x \u2208 [a, b], f x \u2264 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\u2080 alors -f est aussi continue en x\u2080\nlemma continue_opposee {f : \u211d \u2192 \u211d} {x\u2080 : \u211d} (h : continue_en f x\u2080) :\n  continue_en (fct x \u21a6 -f x) x\u2080 :=\nbegin\n  sorry\nend\n\n-- Toute fonction continue sur un segment y est minor\u00e9e.\nlemma minoree_segment {f : \u211d \u2192 \u211d} {a b : \u211d} (hf : \u2200 x \u2208 [a, b], continue_en f x) :\n\u2203 m, \u2200 x \u2208 [a, b], m \u2264 f x :=\nbegin\n  Fait clef : \u2203 M, \u2200 x \u2208 [a, b], -f x \u2264 M,\n  {\n  sorry\n  },\n  sorry\nend\n\n/-\nNous avons d\u00e9montr\u00e9 dans la feuille 8 qu'une suite a au plus une limite :\n\n `unicite_limite : limite_suite u l \u2192 limite_suite u l' \u2192 l = l'`\n\net d\u00e9montr\u00e9 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\u03c6 : extraction \u03c6) :` \n    `limite_suite (u \u2218 \u03c6) l`\n\nOn admet une version du th\u00e9or\u00e8me de la borne sup\u00e9rieure (qu'on ne peut pas\nd\u00e9montrer sans construire les nombres r\u00e9els ou admettre un autre th\u00e9or\u00e8me\naussi fort) :\n\n`sup_segment {a b : \u211d} {A : set \u211d} (hnonvide : \u2203 x, x \u2208 A) (h : A \u2286 [a, b]) :`\n  `\u2203 x \u2208 [a, b], borne_sup A x`\n\nDans l'exercice suivant, il peut \u00eatre utile de d\u00e9montrer une inclusion\nentre ensembles A et B de nombres r\u00e9els.\nPar d\u00e9finition, `A \u2286 B` signifie : `\u2200 x, x \u2208 A \u2192 x \u2208 B`.\nOn peut donc commencer la d\u00e9monstration de A \u2286 B par \u00ab Soit (x \u2208 A) \u00bb\nqui fait appara\u00eetre \u00ab x : \u211d \u00bb et \u00ab x_mem : x \u2208 A  \u00bb dans le contexte,\npuis d\u00e9montrer x \u2208 B.\n\nOn remarquera aussi l'utilisation de la notation\n  {x | P x}\nqui d\u00e9signe l'ensemble des x v\u00e9rifiant le pr\u00e9dicat P.\nPar exemple, la d\u00e9finition du segment [a, b] est :\n`[a, b] = { x | a \u2264 x \u2227 x \u2264 b }`\n\nAinsi l'\u00e9nonc\u00e9 `y \u2208 { x | P x}` signifie `P y`, par d\u00e9finition.\n\n-/\n\n/-- Toute fonction continue sur un segment non vide y admet un maximum. -/\nexample {a b : \u211d} (hab : a \u2264 b) (hf : \u2200 x \u2208 [a, b], continue_en f x) :\n\u2203 x\u2080 \u2208 [a, b], \u2200 x \u2208 [a, b], f x \u2264 f x\u2080 :=\nbegin\n  Par minoree_segment appliqu\u00e9 \u00e0 hf on obtient m \n     tel que hm : \u2200 (x : \u211d), x \u2208 [a, b] \u2192 m \u2264 f x,\n  Par majoree_segment appliqu\u00e9 \u00e0 hf on obtient M \n     tel que hM : \u2200 (x : \u211d), x \u2208 [a, b] \u2192 f x \u2264 M,\n  Posons A := {y | \u2203 x \u2208 [a, b], y = f x}, -- A est l'image de [a, b] par f\n  Fait etape1 : \u2203 y\u2080 \u2208 [m, M], borne_sup A y\u2080,\n  {\n  sorry\n  }, \n  Par etape1 on obtient y\u2080 tel que (y_dans : y\u2080 \u2208 [m, M]) (y_sup : borne_sup A y\u2080),\n  On r\u00e9\u00e9crit via borne_sup_ssi dans y_sup,\n  Par y_sup on obtient (y_maj : majorant A y\u2080) \n                       (u : \u2115 \u2192 \u211d) (lim_u : limite_suite u y\u2080) (u_dans : \u2200 n, u n \u2208 A),\n  Par u_dans on choisit (v : \u2115 \u2192 \u211d) tel que \n    (v_dans : \u2200 n, v n \u2208 [a, b]) (hufv : \u2200 n, u n = f (v n)),\n  Fait hu_eq_comp : u = f \u2218 v,\n    On conclut par funext appliqu\u00e9 \u00e0 hufv,\n  sorry\nend\n\n-- Malheureusement `On combine` ne fait pas tout seul le lemme suivant\nlemma stupide {a b x : \u211d} (h : x \u2208 [a, b]) (h' : x \u2260 b) : x < b :=\nbegin\n  On conclut par lt_of_le_of_ne appliqu\u00e9 \u00e0 [h.right, h'],\nend\n/-\nEt maintenant le boss final...\n\nOn pourra utiliser le lemme `not_and {P Q : Prop} : (\u00ac(P \u2227 Q)) \u2194 (P \u2192 \u00acQ)`\nplut\u00f4t que d'utiliser directement la commande `On pousse la n\u00e9gation` qui utilise\nune autre reformulation de `\u00ac(P \u2227 Q)`.\n-/\n\n/-- Le th\u00e9or\u00e8me des valeurs interm\u00e9diaires -/\nexample (f : \u211d \u2192 \u211d) (hf : \u2200 x, continue_en f x) (h\u2080 : f 0 < 0) (h\u2081 : f 1 > 0) :\n\u2203 x\u2080 \u2208 [0, 1], f x\u2080 = 0 :=\nbegin\n  Posons A := { x | x \u2208 [0, 1] \u2227 f x < 0},\n  Fait ex_x\u2080 : \u2203 x\u2080 \u2208 [0, 1], borne_sup A x\u2080,\n  {\n  sorry\n  },\n  Par ex_x\u2080 on obtient x\u2080 tel que x\u2080_dans x\u2080_sup,\n  Montrons que x\u2080 convient,\n    On conclut par x\u2080_dans,\n  Fait fx\u2080_neg : f x\u2080 \u2264 0,\n  {\n  sorry\n  },\n  Fait x\u2080_1: x\u2080 < 1,\n  {\n  sorry\n  },\n  Fait fx\u2080_pos : f x\u2080 \u2265 0,\n  { Fait dans' : \u2203 N : \u2115, \u2200 n \u2265 N, x\u2080 + 1/(n+1) \u2208 [0, 1],\n    { Fait dans'' : \u2203 N : \u2115, \u2200 n\u2265 N, 1/(n+1 : \u211d) \u2264 1-x\u2080,\n      {\n  sorry\n      },\n  sorry\n    },\n    Fait pas_dans : \u2200 n : \u2115, x\u2080 + 1/(n+1) \u2209 A,\n    -- Par d\u00e9finition, x \u2209 A signifie \u00ab non (x \u2208 A) \u00bb.\n    {\n  sorry\n    },\n    On reformule pas_dans en \u2200 n : \u2115, \u00ac(x\u2080 + 1 / (n + 1 : \u211d) \u2208 [0, 1] \u2227 f (x\u2080 + 1 / (n + 1 : \u211d)) < 0),\n  sorry\n  },\n  On combine [fx\u2080_pos, fx\u2080_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 \u03b1`:  Typeclass saying that a type is finite. It takes as fields a `finset` and a proof\n  that all terms of type `\u03b1` 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 \u03b1)`, and pigeonhole principles.\n\n## Instances\n\nInstances for `fintype` for\n* `{x // p x}` are in this file as `fintype.subtype`\n* `option \u03b1` are in `data.fintype.option`\n* `\u03b1 \u00d7 \u03b2` are in `data.fintype.prod`\n* `\u03b1 \u2295 \u03b2` are in `data.fintype.sum`\n* `\u03a3 (a : \u03b1), \u03b2 a` are in `data.fintype.sigma`\n\nThese files also contain appropriate `infinite` instances for these types.\n\n`infinite` instances for `\u2115`, `\u2124`, `multiset \u03b1`, and `list \u03b1` 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 {\u03b1 \u03b2 \u03b3 : Type*}\n\n/-- `fintype \u03b1` means that `\u03b1` is finite, i.e. there are only\n  finitely many distinct elements of type `\u03b1`. 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 `\u03b1` is in the list. -/\nclass fintype (\u03b1 : Type*) :=\n(elems [] : finset \u03b1)\n(complete : \u2200 x : \u03b1, x \u2208 elems)\n\nnamespace finset\nvariables [fintype \u03b1] {s t : finset \u03b1}\n\n/-- `univ` is the universal finite set of type `finset \u03b1` implied from\n  the assumption `fintype \u03b1`. -/\ndef univ : finset \u03b1 := fintype.elems \u03b1\n\n@[simp] theorem mem_univ (x : \u03b1) : x \u2208 (univ : finset \u03b1) :=\nfintype.complete x\n\n@[simp] theorem mem_univ_val : \u2200 x, x \u2208 (univ : finset \u03b1).1 := mem_univ\n\nlemma eq_univ_iff_forall : s = univ \u2194 \u2200 x, x \u2208 s := by simp [ext_iff]\nlemma eq_univ_of_forall  : (\u2200 x, x \u2208 s) \u2192 s = univ := eq_univ_iff_forall.2\n\n@[simp, norm_cast] lemma coe_univ : \u2191(univ : finset \u03b1) = (set.univ : set \u03b1) := by ext; simp\n@[simp, norm_cast] lemma coe_eq_univ : (s : set \u03b1) = set.univ \u2194 s = univ :=\nby rw [\u2190coe_univ, coe_inj]\n\nlemma nonempty.eq_univ [subsingleton \u03b1] : s.nonempty \u2192 s = univ :=\nby { rintro \u27e8x, hx\u27e9, refine eq_univ_of_forall (\u03bb y, by rwa subsingleton.elim y x) }\n\nlemma univ_nonempty_iff : (univ : finset \u03b1).nonempty \u2194 nonempty \u03b1 :=\nby rw [\u2190 coe_nonempty, coe_univ, set.nonempty_iff_univ_nonempty]\n\nlemma univ_nonempty [nonempty \u03b1] : (univ : finset \u03b1).nonempty :=\nuniv_nonempty_iff.2 \u2039_\u203a\n\nlemma univ_eq_empty_iff : (univ : finset \u03b1) = \u2205 \u2194 is_empty \u03b1 :=\nby rw [\u2190 not_nonempty_iff, \u2190 univ_nonempty_iff, not_nonempty_iff_eq_empty]\n\n@[simp] lemma univ_eq_empty [is_empty \u03b1] : (univ : finset \u03b1) = \u2205 := univ_eq_empty_iff.2 \u2039_\u203a\n\n@[simp] lemma univ_unique [unique \u03b1] : (univ : finset \u03b1) = {default} :=\nfinset.ext $ \u03bb x, iff_of_true (mem_univ _) $ mem_singleton.2 $ subsingleton.elim x default\n\n@[simp] theorem subset_univ (s : finset \u03b1) : s \u2286 univ := \u03bb a _, mem_univ a\n\ninstance : bounded_order (finset \u03b1) :=\n{ top := univ,\n  le_top := subset_univ,\n  .. finset.order_bot }\n\n@[simp] lemma top_eq_univ : (\u22a4 : finset \u03b1) = univ := rfl\n\nlemma ssubset_univ_iff {s : finset \u03b1} : s \u2282 univ \u2194 s \u2260 univ := @lt_top_iff_ne_top _ _ _ s\n\nlemma codisjoint_left : codisjoint s t \u2194 \u2200 \u2983a\u2984, a \u2209 s \u2192 a \u2208 t :=\nby { classical, simp [codisjoint_iff, eq_univ_iff_forall, or_iff_not_imp_left] }\n\nlemma codisjoint_right : codisjoint s t \u2194 \u2200 \u2983a\u2984, a \u2209 t \u2192 a \u2208 s :=\ncodisjoint.comm.trans codisjoint_left\n\nsection boolean_algebra\nvariables [decidable_eq \u03b1] {a : \u03b1}\n\ninstance : boolean_algebra (finset \u03b1) := generalized_boolean_algebra.to_boolean_algebra\n\nlemma sdiff_eq_inter_compl (s t : finset \u03b1) : s \\ t = s \u2229 t\u1d9c := sdiff_eq\n\nlemma compl_eq_univ_sdiff (s : finset \u03b1) : s\u1d9c = univ \\ s := rfl\n\n@[simp] lemma mem_compl : a \u2208 s\u1d9c \u2194 a \u2209 s := by simp [compl_eq_univ_sdiff]\n\nlemma not_mem_compl : a \u2209 s\u1d9c \u2194 a \u2208 s := by rw [mem_compl, not_not]\n\n@[simp, norm_cast] lemma coe_compl (s : finset \u03b1) : \u2191(s\u1d9c) = (\u2191s : set \u03b1)\u1d9c :=\nset.ext $ \u03bb x, mem_compl\n\n@[simp] lemma compl_empty : (\u2205 : finset \u03b1)\u1d9c = univ := compl_bot\n\n@[simp] lemma compl_univ : (univ : finset \u03b1)\u1d9c = \u2205 := compl_top\n\n@[simp] lemma compl_eq_empty_iff (s : finset \u03b1) : s\u1d9c = \u2205 \u2194 s = univ := compl_eq_bot\n\n@[simp] lemma compl_eq_univ_iff (s : finset \u03b1) : s\u1d9c = univ \u2194 s = \u2205 := compl_eq_top\n\n@[simp] lemma union_compl (s : finset \u03b1) : s \u222a s\u1d9c = univ := sup_compl_eq_top\n\n@[simp] lemma inter_compl (s : finset \u03b1) : s \u2229 s\u1d9c = \u2205 := inf_compl_eq_bot\n\n@[simp] lemma compl_union (s t : finset \u03b1) : (s \u222a t)\u1d9c = s\u1d9c \u2229 t\u1d9c := compl_sup\n\n@[simp] lemma compl_inter (s t : finset \u03b1) : (s \u2229 t)\u1d9c = s\u1d9c \u222a t\u1d9c := compl_inf\n\n@[simp] lemma compl_erase : (s.erase a)\u1d9c = insert a s\u1d9c :=\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)\u1d9c = s\u1d9c.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 : \u03b1) : insert x ({x}\u1d9c : finset \u03b1) = univ :=\nby rw [\u2190compl_erase, erase_singleton, compl_empty]\n\n@[simp] lemma compl_filter (p : \u03b1 \u2192 Prop) [decidable_pred p] [\u03a0 x, decidable (\u00acp x)] :\n  (univ.filter p)\u1d9c = univ.filter (\u03bb x, \u00acp x) :=\n(filter_not _ _).symm\n\nlemma compl_ne_univ_iff_nonempty (s : finset \u03b1) : s\u1d9c \u2260 univ \u2194 s.nonempty :=\nby simp [eq_univ_iff_forall, finset.nonempty]\n\nlemma compl_singleton (a : \u03b1) : ({a} : finset \u03b1)\u1d9c = univ.erase a :=\nby rw [compl_eq_univ_sdiff, sdiff_singleton_eq_erase]\n\nlemma insert_inj_on' (s : finset \u03b1) : set.inj_on (\u03bb a, insert a s) (s\u1d9c : finset \u03b1) :=\nby { rw coe_compl, exact s.insert_inj_on }\n\nlemma image_univ_of_surjective [fintype \u03b2] {f : \u03b2 \u2192 \u03b1} (hf : surjective f) : univ.image f = univ :=\neq_univ_of_forall $ hf.forall.2 $ \u03bb _, mem_image_of_mem _ $ mem_univ _\n\nend boolean_algebra\n\nlemma map_univ_of_surjective [fintype \u03b2] {f : \u03b2 \u21aa \u03b1} (hf : surjective f) : univ.map f = univ :=\neq_univ_of_forall $ hf.forall.2 $ \u03bb _, mem_map_of_mem _ $ mem_univ _\n\n@[simp] lemma map_univ_equiv [fintype \u03b2] (f : \u03b2 \u2243 \u03b1) : univ.map f.to_embedding = univ :=\nmap_univ_of_surjective f.surjective\n\n@[simp] lemma univ_inter [decidable_eq \u03b1] (s : finset \u03b1) :\n  univ \u2229 s = s := ext $ \u03bb a, by simp\n\n@[simp] lemma inter_univ [decidable_eq \u03b1] (s : finset \u03b1) :\n  s \u2229 univ = s :=\nby rw [inter_comm, univ_inter]\n\n@[simp] lemma piecewise_univ [\u03a0 i : \u03b1, decidable (i \u2208 (univ : finset \u03b1))]\n  {\u03b4 : \u03b1 \u2192 Sort*} (f g : \u03a0 i, \u03b4 i) : univ.piecewise f g = f :=\nby { ext i, simp [piecewise] }\n\nlemma piecewise_compl [decidable_eq \u03b1] (s : finset \u03b1) [\u03a0 i : \u03b1, decidable (i \u2208 s)]\n  [\u03a0 i : \u03b1, decidable (i \u2208 s\u1d9c)] {\u03b4 : \u03b1 \u2192 Sort*} (f g : \u03a0 i, \u03b4 i) :\n  s\u1d9c.piecewise f g = s.piecewise g f :=\nby { ext i, simp [piecewise] }\n\n@[simp] lemma piecewise_erase_univ {\u03b4 : \u03b1 \u2192 Sort*} [decidable_eq \u03b1] (a : \u03b1) (f g : \u03a0 a, \u03b4 a) :\n  (finset.univ.erase a).piecewise f g = function.update f a (g a) :=\nby rw [\u2190compl_singleton, piecewise_compl, piecewise_singleton]\n\nlemma univ_map_equiv_to_embedding {\u03b1 \u03b2 : Type*} [fintype \u03b1] [fintype \u03b2] (e : \u03b1 \u2243 \u03b2) :\n  univ.map e.to_embedding = univ :=\neq_univ_iff_forall.mpr (\u03bb b, mem_map.mpr \u27e8e.symm b, mem_univ _, by simp\u27e9)\n\n@[simp] lemma univ_filter_exists (f : \u03b1 \u2192 \u03b2) [fintype \u03b2]\n  [decidable_pred (\u03bb y, \u2203 x, f x = y)] [decidable_eq \u03b2] :\n  finset.univ.filter (\u03bb y, \u2203 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 : \u03b1 \u2192 \u03b2) [fintype \u03b2]\n  [decidable_pred (\u03bb y, y \u2208 set.range f)] [decidable_eq \u03b2] :\n  finset.univ.filter (\u03bb y, y \u2208 set.range f) = finset.univ.image f :=\nuniv_filter_exists f\n\nlemma coe_filter_univ (p : \u03b1 \u2192 Prop) [decidable_pred p] : (univ.filter p : set \u03b1) = {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 {\u03b1} {\u03b2 : \u03b1 \u2192 Type*} [\u2200 a, decidable_eq (\u03b2 a)] [fintype \u03b1] :\n  decidable_eq (\u03a0 a, \u03b2 a) :=\n\u03bb f g, decidable_of_iff (\u2200 a \u2208 fintype.elems \u03b1, f a = g a)\n  (by simp [function.funext_iff, fintype.complete])\n\ninstance decidable_forall_fintype {p : \u03b1 \u2192 Prop} [decidable_pred p] [fintype \u03b1] :\n  decidable (\u2200 a, p a) :=\ndecidable_of_iff (\u2200 a \u2208 @univ \u03b1 _, p a) (by simp)\n\ninstance decidable_exists_fintype {p : \u03b1 \u2192 Prop} [decidable_pred p] [fintype \u03b1] :\n  decidable (\u2203 a, p a) :=\ndecidable_of_iff (\u2203 a \u2208 @univ \u03b1 _, p a) (by simp)\n\ninstance decidable_mem_range_fintype [fintype \u03b1] [decidable_eq \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  decidable_pred (\u2208 set.range f) :=\n\u03bb x, fintype.decidable_exists_fintype\n\nsection bundled_homs\n\ninstance decidable_eq_equiv_fintype [decidable_eq \u03b2] [fintype \u03b1] :\n  decidable_eq (\u03b1 \u2243 \u03b2) :=\n\u03bb a b, decidable_of_iff (a.1 = b.1) equiv.coe_fn_injective.eq_iff\n\ninstance decidable_eq_embedding_fintype [decidable_eq \u03b2] [fintype \u03b1] :\n  decidable_eq (\u03b1 \u21aa \u03b2) :=\n\u03bb a b, decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = b) function.embedding.coe_injective.eq_iff\n\n@[to_additive]\ninstance decidable_eq_one_hom_fintype [decidable_eq \u03b2] [fintype \u03b1] [has_one \u03b1] [has_one \u03b2]:\n  decidable_eq (one_hom \u03b1 \u03b2) :=\n\u03bb a b, decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = b) (injective.eq_iff one_hom.coe_inj)\n\n@[to_additive]\ninstance decidable_eq_mul_hom_fintype [decidable_eq \u03b2] [fintype \u03b1] [has_mul \u03b1] [has_mul \u03b2]:\n  decidable_eq (\u03b1 \u2192\u2099* \u03b2) :=\n\u03bb a b, decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = b) (injective.eq_iff mul_hom.coe_inj)\n\n@[to_additive]\ninstance decidable_eq_monoid_hom_fintype [decidable_eq \u03b2] [fintype \u03b1]\n  [mul_one_class \u03b1] [mul_one_class \u03b2]:\n  decidable_eq (\u03b1 \u2192* \u03b2) :=\n\u03bb a b, decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = b) (injective.eq_iff monoid_hom.coe_inj)\n\ninstance decidable_eq_monoid_with_zero_hom_fintype [decidable_eq \u03b2] [fintype \u03b1]\n  [mul_zero_one_class \u03b1] [mul_zero_one_class \u03b2] :\n  decidable_eq (\u03b1 \u2192*\u2080 \u03b2) :=\n\u03bb a b, decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = b) (injective.eq_iff monoid_with_zero_hom.coe_inj)\n\ninstance decidable_eq_ring_hom_fintype [decidable_eq \u03b2] [fintype \u03b1]\n  [semiring \u03b1] [semiring \u03b2]:\n  decidable_eq (\u03b1 \u2192+* \u03b2) :=\n\u03bb a b, decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = b) (injective.eq_iff ring_hom.coe_inj)\n\nend bundled_homs\n\ninstance decidable_injective_fintype [decidable_eq \u03b1] [decidable_eq \u03b2] [fintype \u03b1] :\n  decidable_pred (injective : (\u03b1 \u2192 \u03b2) \u2192 Prop) := \u03bb x, by unfold injective; apply_instance\n\ninstance decidable_surjective_fintype [decidable_eq \u03b2] [fintype \u03b1] [fintype \u03b2] :\n  decidable_pred (surjective : (\u03b1 \u2192 \u03b2) \u2192 Prop) := \u03bb x, by unfold surjective; apply_instance\n\ninstance decidable_bijective_fintype [decidable_eq \u03b1] [decidable_eq \u03b2] [fintype \u03b1] [fintype \u03b2] :\n  decidable_pred (bijective : (\u03b1 \u2192 \u03b2) \u2192 Prop) := \u03bb x, by unfold bijective; apply_instance\n\ninstance decidable_right_inverse_fintype [decidable_eq \u03b1] [fintype \u03b1] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) :\n  decidable (function.right_inverse f g) :=\nshow decidable (\u2200 x, g (f x) = x), by apply_instance\n\ninstance decidable_left_inverse_fintype [decidable_eq \u03b2] [fintype \u03b2] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) :\n  decidable (function.left_inverse f g) :=\nshow decidable (\u2200 x, f (g x) = x), by apply_instance\n\n/-- Construct a proof of `fintype \u03b1` from a universal multiset -/\ndef of_multiset [decidable_eq \u03b1] (s : multiset \u03b1) (H : \u2200 x : \u03b1, x \u2208 s) :\n  fintype \u03b1 :=\n\u27e8s.to_finset, by simpa using H\u27e9\n\n/-- Construct a proof of `fintype \u03b1` from a universal list -/\ndef of_list [decidable_eq \u03b1] (l : list \u03b1) (H : \u2200 x : \u03b1, x \u2208 l) :\n  fintype \u03b1 :=\n\u27e8l.to_finset, by simpa using H\u27e9\n\ninstance (\u03b1 : Type*) : subsingleton (fintype \u03b1) :=\n\u27e8\u03bb \u27e8s\u2081, h\u2081\u27e9 \u27e8s\u2082, h\u2082\u27e9, by congr; simp [finset.ext_iff, h\u2081, h\u2082]\u27e9\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 : \u03b1 \u2192 Prop} (s : finset \u03b1) (H : \u2200 x : \u03b1, x \u2208 s \u2194 p x) :\n  fintype {x // p x} :=\n\u27e8\u27e8s.1.pmap subtype.mk (\u03bb x, (H x).1),\n  s.nodup.pmap $ \u03bb a _ b _, congr_arg subtype.val\u27e9,\n\u03bb \u27e8x, px\u27e9, multiset.mem_pmap.2 \u27e8x, (H x).2 px, rfl\u27e9\u27e9\n\n/-- Construct a fintype from a finset with the same elements. -/\ndef of_finset {p : set \u03b1} (s : finset \u03b1) (H : \u2200 x, x \u2208 s \u2194 x \u2208 p) : fintype p :=\nfintype.subtype s H\n\n/-- If `f : \u03b1 \u2192 \u03b2` is a bijection and `\u03b1` is a fintype, then `\u03b2` is also a fintype. -/\ndef of_bijective [fintype \u03b1] (f : \u03b1 \u2192 \u03b2) (H : function.bijective f) : fintype \u03b2 :=\n\u27e8univ.map \u27e8f, H.1\u27e9,\n\u03bb b, let \u27e8a, e\u27e9 := H.2 b in e \u25b8 mem_map_of_mem _ (mem_univ _)\u27e9\n\n/-- If `f : \u03b1 \u2192 \u03b2` is a surjection and `\u03b1` is a fintype, then `\u03b2` is also a fintype. -/\ndef of_surjective [decidable_eq \u03b2] [fintype \u03b1] (f : \u03b1 \u2192 \u03b2) (H : function.surjective f) :\n  fintype \u03b2 :=\n\u27e8univ.image f, \u03bb b, let \u27e8a, e\u27e9 := H b in e \u25b8 mem_image_of_mem _ (mem_univ _)\u27e9\n\nend fintype\n\nnamespace finset\nvariables [fintype \u03b1] [decidable_eq \u03b1] {s t : finset \u03b1}\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 \u03b1] [decidable_eq \u03b2]\n\nnamespace injective\n\nvariables {f : \u03b1 \u2192 \u03b2} (hf : function.injective f)\n\n/--\nThe inverse of an `hf : injective` function `f : \u03b1 \u2192 \u03b2`, of the type `\u21a5(set.range f) \u2192 \u03b1`.\nThis is the computable version of `function.inv_fun` that requires `fintype \u03b1` and `decidable_eq \u03b2`,\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 : \u03b1` to find the `f a = b`, so it is O(N) where\n`N = fintype.card \u03b1`.\n-/\ndef inv_of_mem_range : set.range f \u2192 \u03b1 :=\n\u03bb b, finset.choose (\u03bb 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 (\u03bb a, f a = b) _ _).right\n\n@[simp] lemma right_inv_of_inv_of_mem_range (a : \u03b1) :\n  hf.inv_of_mem_range (\u27e8f a, set.mem_range_self a\u27e9) = a :=\nhf (finset.choose_spec (\u03bb a', f a' = f a) _ _).right\n\nlemma inv_fun_restrict [nonempty \u03b1] :\n  (set.range f).restrict (inv_fun f) = hf.inv_of_mem_range :=\nbegin\n  ext \u27e8b, h\u27e9,\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\u03bb a, \u27e8\u27e8f a, set.mem_range_self a\u27e9, by simp\u27e9\n\nend injective\n\nnamespace embedding\nvariables (f : \u03b1 \u21aa \u03b2) (b : set.range f)\n\n/--\nThe inverse of an embedding `f : \u03b1 \u21aa \u03b2`, of the type `\u21a5(set.range f) \u2192 \u03b1`.\nThis is the computable version of `function.inv_fun` that requires `fintype \u03b1` and `decidable_eq \u03b2`,\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 : \u03b1` to find the `f a = b`, so it is O(N) where\n`N = fintype.card \u03b1`.\n-/\ndef inv_of_mem_range : \u03b1 :=\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 : \u03b1) :\n  f.inv_of_mem_range \u27e8f a, set.mem_range_self a\u27e9 = a :=\nf.injective.right_inv_of_inv_of_mem_range a\n\nlemma inv_fun_restrict [nonempty \u03b1] :\n  (set.range f).restrict (inv_fun f) = f.inv_of_mem_range :=\nbegin\n  ext \u27e8b, h\u27e9,\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\u03bb a, \u27e8\u27e8f a, set.mem_range_self a\u27e9, by simp\u27e9\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 \u03b2] (f : \u03b1 \u2192 \u03b2) (H : function.injective f) : fintype \u03b1 :=\nby letI := classical.dec; exact\nif h\u03b1 : nonempty \u03b1 then by letI := classical.inhabited_of_nonempty h\u03b1;\n  exact of_surjective (inv_fun f) (inv_fun_surjective H)\nelse \u27e8\u2205, \u03bb x, (h\u03b1 \u27e8x\u27e9).elim\u27e9\n\n/-- If `f : \u03b1 \u2243 \u03b2` and `\u03b1` is a fintype, then `\u03b2` is also a fintype. -/\ndef of_equiv (\u03b1 : Type*) [fintype \u03b1] (f : \u03b1 \u2243 \u03b2) : fintype \u03b2 := of_bijective _ f.bijective\n\n/-- Any subsingleton type with a witness is a fintype (with one term). -/\ndef of_subsingleton (a : \u03b1) [subsingleton \u03b1] : fintype \u03b1 :=\n\u27e8{a}, \u03bb b, finset.mem_singleton.2 (subsingleton.elim _ _)\u27e9\n\n@[simp] theorem univ_of_subsingleton (a : \u03b1) [subsingleton \u03b1] :\n  @univ _ (of_subsingleton a) = {a} := rfl\n\n@[priority 100] -- see Note [lower instance priority]\ninstance of_is_empty [is_empty \u03b1] : fintype \u03b1 := \u27e8\u2205, is_empty_elim\u27e9\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 \u03b1] : @univ \u03b1 _ = \u2205 := rfl\n\nend fintype\n\nnamespace set\nvariables {s t : set \u03b1}\n\n/-- Construct a finset enumerating a set `s`, given a `fintype` instance.  -/\ndef to_finset (s : set \u03b1) [fintype s] : finset \u03b1 :=\n(@finset.univ s _).map $ function.embedding.subtype _\n\n@[congr]\nlemma to_finset_congr {s t : set \u03b1} [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 \u03b1} [fintype s] {a : \u03b1} : a \u2208 s.to_finset \u2194 a \u2208 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 \u03b1} (s : finset \u03b1) (H : \u2200 x, x \u2208 s \u2194 x \u2208 p) :\n  @set.to_finset _ p (fintype.of_finset s H) = s :=\nfinset.ext (\u03bb 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 \u03b1] (s : set \u03b1) [fintype s] (a) : decidable (a \u2208 s) :=\ndecidable_of_iff _ mem_to_finset\n\n@[simp] theorem coe_to_finset (s : set \u03b1) [fintype s] : (\u2191s.to_finset : set \u03b1) = s :=\nset.ext $ \u03bb _, mem_to_finset\n\n@[simp] lemma to_finset_nonempty {s : set \u03b1} [fintype s] : s.to_finset.nonempty \u2194 s.nonempty :=\nby rw [\u2190finset.coe_nonempty, coe_to_finset]\n\n@[simp] theorem to_finset_inj {s t : set \u03b1} [fintype s] [fintype t] :\n  s.to_finset = t.to_finset \u2194 s = t :=\n\u27e8\u03bb h, by rw [\u2190s.coe_to_finset, h, t.coe_to_finset], \u03bb h, by simp [h]; congr\u27e9\n\n@[mono]\nlemma to_finset_subset_to_finset [fintype s] [fintype t] : s.to_finset \u2286 t.to_finset \u2194 s \u2286 t :=\nby simp [finset.subset_iff, set.subset_def]\n\n@[simp] lemma to_finset_ssubset [fintype s] {t : finset \u03b1} : s.to_finset \u2282 t \u2194 s \u2282 t :=\nby rw [\u2190finset.coe_ssubset, coe_to_finset]\n\n@[simp] lemma subset_to_finset {s : finset \u03b1} [fintype t] : s \u2286 t.to_finset \u2194 \u2191s \u2286 t :=\nby rw [\u2190finset.coe_subset, coe_to_finset]\n\n@[simp] lemma ssubset_to_finset {s : finset \u03b1} [fintype t] : s \u2282 t.to_finset \u2194 \u2191s \u2282 t :=\nby rw [\u2190finset.coe_ssubset, coe_to_finset]\n\n@[mono]\nlemma to_finset_ssubset_to_finset [fintype s] [fintype t] : s.to_finset \u2282 t.to_finset \u2194 s \u2282 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 \u03b1} : s.to_finset \u2286 t \u2194 s \u2286 t :=\nby rw [\u2190finset.coe_subset, coe_to_finset]\n\nalias to_finset_subset_to_finset \u2194 _ to_finset_mono\nalias to_finset_ssubset_to_finset \u2194 _ to_finset_strict_mono\n\n@[simp] lemma disjoint_to_finset [fintype s] [fintype t] :\n  disjoint s.to_finset t.to_finset \u2194 disjoint s t :=\nby simp only [\u2190disjoint_coe, coe_to_finset]\n\nsection decidable_eq\nvariables [decidable_eq \u03b1] (s t) [fintype s] [fintype t]\n\n@[simp] lemma to_finset_inter [fintype \u21a5(s \u2229 t)] : (s \u2229 t).to_finset = s.to_finset \u2229 t.to_finset :=\nby { ext, simp }\n\n@[simp] lemma to_finset_union [fintype \u21a5(s \u222a t)] : (s \u222a t).to_finset = s.to_finset \u222a t.to_finset :=\nby { ext, simp }\n\n@[simp] lemma to_finset_diff [fintype \u21a5(s \\ t)] : (s \\ t).to_finset = s.to_finset \\ t.to_finset :=\nby { ext, simp }\n\n@[simp] lemma to_finset_symm_diff [fintype \u21a5(s \u2206 t)] :\n  (s \u2206 t).to_finset = s.to_finset \u2206 t.to_finset :=\nby { ext, simp [mem_symm_diff, finset.mem_symm_diff] }\n\n@[simp] lemma to_finset_compl [fintype \u03b1] [fintype \u21a5s\u1d9c] : s\u1d9c.to_finset = s.to_finset\u1d9c :=\nby { ext, simp }\n\nend decidable_eq\n\n/- TODO The `\u21a5` circumvents an elaboration bug. See comment on `set.to_finset_univ`. -/\n@[simp] lemma to_finset_empty [fintype \u21a5(\u2205 : set \u03b1)] : (\u2205 : set \u03b1).to_finset = \u2205 := by { ext, simp }\n\n/- TODO Without the coercion arrow (`\u21a5`) there is an elaboration bug in the following two;\nit essentially infers `fintype.{v} (set.univ.{u} : set \u03b1)` with `v` and `u` distinct.\nReported in leanprover-community/lean#672 -/\n@[simp] lemma to_finset_univ [fintype \u03b1] [fintype \u21a5(set.univ : set \u03b1)] :\n  (set.univ : set \u03b1).to_finset = finset.univ :=\nby { ext, simp }\n\n@[simp] lemma to_finset_eq_empty [fintype s] : s.to_finset = \u2205 \u2194 s = \u2205 :=\nby rw [\u2190to_finset_empty, to_finset_inj]\n\n@[simp] lemma to_finset_eq_univ [fintype \u03b1] [fintype s] : s.to_finset = finset.univ \u2194 s = univ :=\nby rw [\u2190 coe_inj, coe_to_finset, coe_univ]\n\n@[simp] lemma to_finset_set_of [fintype \u03b1] (p : \u03b1 \u2192 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 \u03b1] {s : set \u03b1} [fintype s] :\n  s.to_finset \u2282 finset.univ \u2194 s \u2282 univ :=\nby rw [\u2190 coe_ssubset, coe_to_finset, coe_univ]\n\n@[simp]\nlemma to_finset_image [decidable_eq \u03b2] (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) [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 \u03b1] [fintype \u03b2] (f : \u03b2 \u2192 \u03b1) [fintype (set.range f)] :\n  (set.range f).to_finset = finset.univ.image f :=\nby { ext, simp }\n\n/- TODO The `\u21a5` circumvents an elaboration bug. See comment on `set.to_finset_univ`. -/\nlemma to_finset_singleton (a : \u03b1) [fintype \u21a5({a} : set \u03b1)] : ({a} : set \u03b1).to_finset = {a} :=\nby { ext, simp }\n\n/- TODO The `\u21a5` circumvents an elaboration bug. See comment on `set.to_finset_univ`. -/\n@[simp] lemma to_finset_insert [decidable_eq \u03b1] {a : \u03b1} {s : set \u03b1}\n  [fintype \u21a5(insert a s : set \u03b1)] [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 \u03b1] (s : set \u03b1) [fintype s] [decidable_pred (\u2208 s)] :\n  finset.univ.filter (\u2208 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 \u03b1) [fintype \u21a5(s : set \u03b1)] :\n  (s : set \u03b1).to_finset = s :=\next $ \u03bb _, set.mem_to_finset\n\ninstance (n : \u2115) : fintype (fin n) :=\n\u27e8\u27e8list.fin_range n, list.nodup_fin_range n\u27e9, list.mem_fin_range\u27e9\n\nlemma fin.univ_def (n : \u2115) : (univ : finset (fin n)) = \u27e8list.fin_range n, list.nodup_fin_range n\u27e9 :=\nrfl\n\n@[simp] lemma fin.image_succ_above_univ {n : \u2115} (i : fin (n + 1)) :\n  univ.image i.succ_above = {i}\u1d9c :=\nby { ext m, simp }\n\n@[simp] lemma fin.image_succ_univ (n : \u2115) : (univ : finset (fin n)).image fin.succ = {0}\u1d9c :=\nby rw [\u2190 fin.succ_above_zero, fin.image_succ_above_univ]\n\n@[simp] lemma fin.image_cast_succ (n : \u2115) :\n  (univ : finset (fin n)).image fin.cast_succ = {fin.last n}\u1d9c :=\nby rw [\u2190 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 : \u2115) :\n  (univ : finset (fin (n + 1))) =\n    cons 0 (univ.map \u27e8fin.succ, fin.succ_injective _\u27e9) (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 : \u2115) :\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 : \u2115) (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 {\u03b1 : Type*} [unique \u03b1] : fintype \u03b1 :=\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 : \u03b1) : 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 : \u03b1) : fintype {x // y = x} :=\nfintype.subtype {y} (by simp [eq_comm])\n\n@[simp] theorem fintype.univ_empty : @univ empty _ = \u2205 := rfl\n\n@[simp] theorem fintype.univ_pempty : @univ pempty _ = \u2205 := 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 := \u27e8\u27e8{tt, ff}, by simp\u27e9, \u03bb x, by cases x; simp\u27e9\n\n@[simp] theorem fintype.univ_bool : @univ bool _ = {tt, ff} := rfl\n\ninstance additive.fintype : \u03a0 [fintype \u03b1], fintype (additive \u03b1) := id\n\ninstance multiplicative.fintype : \u03a0 [fintype \u03b1], fintype (multiplicative \u03b1) := id\n\n/-- Given that `\u03b1 \u00d7 \u03b2` is a fintype, `\u03b1` is also a fintype. -/\ndef fintype.prod_left {\u03b1 \u03b2} [decidable_eq \u03b1] [fintype (\u03b1 \u00d7 \u03b2)] [nonempty \u03b2] : fintype \u03b1 :=\n\u27e8(fintype.elems (\u03b1 \u00d7 \u03b2)).image prod.fst,\n  \u03bb a, let \u27e8b\u27e9 := \u2039nonempty \u03b2\u203a in by simp; exact \u27e8b, fintype.complete _\u27e9\u27e9\n\n/-- Given that `\u03b1 \u00d7 \u03b2` is a fintype, `\u03b2` is also a fintype. -/\ndef fintype.prod_right {\u03b1 \u03b2} [decidable_eq \u03b2] [fintype (\u03b1 \u00d7 \u03b2)] [nonempty \u03b1] : fintype \u03b2 :=\n\u27e8(fintype.elems (\u03b1 \u00d7 \u03b2)).image prod.snd,\n  \u03bb b, let \u27e8a\u27e9 := \u2039nonempty \u03b1\u203a in by simp; exact \u27e8a, fintype.complete _\u27e9\u27e9\n\ninstance (\u03b1 : Type*) [fintype \u03b1] : fintype (ulift \u03b1) :=\nfintype.of_equiv _ equiv.ulift.symm\n\ninstance (\u03b1 : Type*) [fintype \u03b1] : fintype (plift \u03b1) :=\nfintype.of_equiv _ equiv.plift.symm\n\ninstance (\u03b1 : Type*) [fintype \u03b1] : fintype \u03b1\u1d52\u1d48 := \u2039fintype \u03b1\u203a\ninstance (\u03b1 : Type*) [finite \u03b1] : finite \u03b1\u1d52\u1d48 := \u2039finite \u03b1\u203a\n\ninstance (\u03b1 : Type*) [fintype \u03b1] : fintype (lex \u03b1) := \u2039fintype \u03b1\u203a\n\nsection finset\n\n/-! ### `fintype (s : finset \u03b1)` -/\n\ninstance finset.fintype_coe_sort {\u03b1 : Type u} (s : finset \u03b1) : fintype s :=\n\u27e8s.attach, s.mem_attach\u27e9\n\n@[simp] lemma finset.univ_eq_attach {\u03b1 : Type u} (s : finset \u03b1) :\n  (univ : finset s) = s.attach :=\nrfl\n\nend finset\n\nlemma fintype.coe_image_univ [fintype \u03b1] [decidable_eq \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  \u2191(finset.image f finset.univ) = set.range f :=\nby { ext x, simp }\n\ninstance list.subtype.fintype [decidable_eq \u03b1] (l : list \u03b1) : fintype {x // x \u2208 l} :=\nfintype.of_list l.attach l.mem_attach\n\ninstance multiset.subtype.fintype [decidable_eq \u03b1] (s : multiset \u03b1) : fintype {x // x \u2208 s} :=\nfintype.of_multiset s.attach s.mem_attach\n\ninstance finset.subtype.fintype (s : finset \u03b1) : fintype {x // x \u2208 s} :=\n\u27e8s.attach, s.mem_attach\u27e9\n\ninstance finset_coe.fintype (s : finset \u03b1) : fintype (\u2191s : set \u03b1) :=\nfinset.subtype.fintype s\n\nlemma finset.attach_eq_univ {s : finset \u03b1} : s.attach = finset.univ := rfl\n\ninstance plift.fintype_Prop (p : Prop) [decidable p] : fintype (plift p) :=\n\u27e8if h : p then {\u27e8h\u27e9} else \u2205, \u03bb \u27e8h\u27e9, by simp [h]\u27e9\n\ninstance Prop.fintype : fintype Prop :=\n\u27e8\u27e8{true, false}, by simp [true_ne_false]\u27e9, classical.cases (by simp) (by simp)\u27e9\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 : \u03b1 \u2192 Prop) [decidable_pred p] [fintype \u03b1] : 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 \u03b1] (s : set \u03b1) [decidable_pred (\u2208 s)] : fintype s :=\nsubtype.fintype (\u03bb x, x \u2208 s)\n\nsection\nvariables (\u03b1)\n\n/-- The `\u03b1\u02e3` type is equivalent to a subtype of `\u03b1 \u00d7 \u03b1`. -/\n@[simps]\ndef _root_.units_equiv_prod_subtype [monoid \u03b1] :\n  \u03b1\u02e3 \u2243 {p : \u03b1 \u00d7 \u03b1 // p.1 * p.2 = 1 \u2227 p.2 * p.1 = 1} :=\n{ to_fun := \u03bb u, \u27e8(u, \u2191u\u207b\u00b9), u.val_inv, u.inv_val\u27e9,\n  inv_fun := \u03bb p, units.mk (p : \u03b1 \u00d7 \u03b1).1 (p : \u03b1 \u00d7 \u03b1).2 p.prop.1 p.prop.2,\n  left_inv := \u03bb u, units.ext rfl,\n  right_inv := \u03bb p, subtype.ext $ prod.ext rfl rfl}\n\n/-- In a `group_with_zero` `\u03b1`, the unit group `\u03b1\u02e3` is equivalent to the subtype of nonzero\nelements. -/\n@[simps]\ndef _root_.units_equiv_ne_zero [group_with_zero \u03b1] : \u03b1\u02e3 \u2243 {a : \u03b1 // a \u2260 0} :=\n\u27e8\u03bb a, \u27e8a, a.ne_zero\u27e9, \u03bb a, units.mk0 _ a.prop, \u03bb _, units.ext rfl, \u03bb _, subtype.ext rfl\u27e9\n\nend\n\nnamespace fintype\n\n/-- Given `fintype \u03b1`, `finset_equiv_set` is the equiv between `finset \u03b1` and `set \u03b1`. (All\nsets on a finite type are finite.) -/\nnoncomputable def finset_equiv_set [fintype \u03b1] : finset \u03b1 \u2243 set \u03b1 :=\n{ to_fun := coe,\n  inv_fun := by { classical, exact \u03bb s, s.to_finset },\n  left_inv := \u03bb s, by convert finset.to_finset_coe s,\n  right_inv := \u03bb s, by { classical, exact s.coe_to_finset } }\n\n@[simp] lemma finset_equiv_set_apply [fintype \u03b1] (s : finset \u03b1) : finset_equiv_set s = s := rfl\n\n@[simp] \n\nend fintype\n\ninstance quotient.fintype [fintype \u03b1] (s : setoid \u03b1)\n  [decidable_rel ((\u2248) : \u03b1 \u2192 \u03b1 \u2192 Prop)] : fintype (quotient s) :=\nfintype.of_surjective quotient.mk (\u03bb x, quotient.induction_on x (\u03bb x, \u27e8x, rfl\u27e9))\n\ninstance psigma.fintype_prop_left {\u03b1 : Prop} {\u03b2 : \u03b1 \u2192 Type*} [decidable \u03b1] [\u2200 a, fintype (\u03b2 a)] :\n  fintype (\u03a3' a, \u03b2 a) :=\nif h : \u03b1 then fintype.of_equiv (\u03b2 h) \u27e8\u03bb x, \u27e8h, x\u27e9, psigma.snd, \u03bb _, rfl, \u03bb \u27e8_, _\u27e9, rfl\u27e9\nelse \u27e8\u2205, \u03bb x, h x.1\u27e9\n\ninstance psigma.fintype_prop_right {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Prop} [\u2200 a, decidable (\u03b2 a)] [fintype \u03b1] :\n  fintype (\u03a3' a, \u03b2 a) :=\nfintype.of_equiv {a // \u03b2 a} \u27e8\u03bb \u27e8x, y\u27e9, \u27e8x, y\u27e9, \u03bb \u27e8x, y\u27e9, \u27e8x, y\u27e9, \u03bb \u27e8x, y\u27e9, rfl, \u03bb \u27e8x, y\u27e9, rfl\u27e9\n\ninstance psigma.fintype_prop_prop {\u03b1 : Prop} {\u03b2 : \u03b1 \u2192 Prop} [decidable \u03b1] [\u2200 a, decidable (\u03b2 a)] :\n  fintype (\u03a3' a, \u03b2 a) :=\nif h : \u2203 a, \u03b2 a then \u27e8{\u27e8h.fst, h.snd\u27e9}, \u03bb \u27e8_, _\u27e9, by simp\u27e9 else \u27e8\u2205, \u03bb \u27e8x, y\u27e9, h \u27e8x, y\u27e9\u27e9\n\ninstance pfun_fintype (p : Prop) [decidable p] (\u03b1 : p \u2192 Type*)\n  [\u03a0 hp, fintype (\u03b1 hp)] : fintype (\u03a0 hp : p, \u03b1 hp) :=\nif hp : p then fintype.of_equiv (\u03b1 hp) \u27e8\u03bb a _, a, \u03bb f, f hp, \u03bb _, rfl, \u03bb _, rfl\u27e9\n          else \u27e8singleton (\u03bb h, (hp h).elim), by simp [hp, function.funext_iff]\u27e9\n\nlemma mem_image_univ_iff_mem_range\n  {\u03b1 \u03b2 : Type*} [fintype \u03b1] [decidable_eq \u03b2] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} :\n  b \u2208 univ.image f \u2194 b \u2208 set.range f :=\nby simp\n\nnamespace fintype\n\nsection choose\nopen fintype equiv\n\nvariables [fintype \u03b1] (p : \u03b1 \u2192 Prop) [decidable_pred p]\n\n/-- Given a fintype `\u03b1` and a predicate `p`, associate to a proof that there is a unique element of\n`\u03b1` satisfying `p` this unique element, as an element of the corresponding subtype. -/\ndef choose_x (hp : \u2203! a : \u03b1, p a) : {a // p a} :=\n\u27e8finset.choose p univ (by simp; exact hp), finset.choose_property _ _ _\u27e9\n\n/-- Given a fintype `\u03b1` and a predicate `p`, associate to a proof that there is a unique element of\n`\u03b1` satisfying `p` this unique element, as an element of `\u03b1`. -/\ndef choose (hp : \u2203! a, p a) : \u03b1 := choose_x p hp\n\nlemma choose_spec (hp : \u2203! a, p a) : p (choose p hp) :=\n(choose_x p hp).property\n\n@[simp] lemma choose_subtype_eq {\u03b1 : Type*} (p : \u03b1 \u2192 Prop) [fintype {a : \u03b1 // p a}]\n  [decidable_eq \u03b1] (x : {a : \u03b1 // p a})\n  (h : \u2203! (a : {a // p a}), (a : \u03b1) = x := \u27e8x, rfl, \u03bb y hy, by simpa [subtype.ext_iff] using hy\u27e9) :\n  fintype.choose (\u03bb (y : {a : \u03b1 // p a}), (y : \u03b1) = x) h = x :=\nby rw [subtype.ext_iff, fintype.choose_spec (\u03bb (y : {a : \u03b1 // p a}), (y : \u03b1) = x) _]\n\nend choose\n\nsection bijection_inverse\nopen function\n\nvariables [fintype \u03b1] [decidable_eq \u03b2] {f : \u03b1 \u2192 \u03b2}\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 : \u03b2) : \u03b1 :=\nfintype.choose (\u03bb a, f a = b)\nbegin\n  rcases f_bij.right b with \u27e8a', fa_eq_b\u27e9,\n  rw \u2190 fa_eq_b,\n  exact \u27e8a', \u27e8rfl, (\u03bb a h, f_bij.left h)\u27e9\u27e9\nend\n\nlemma left_inverse_bij_inv (f_bij : bijective f) : left_inverse (bij_inv f_bij) f :=\n\u03bb a, f_bij.left (choose_spec (\u03bb a', f a' = f a) _)\n\nlemma right_inverse_bij_inv (f_bij : bijective f) : right_inverse (bij_inv f_bij) f :=\n\u03bb b, choose_spec (\u03bb a', f a' = b) _\n\nlemma bijective_bij_inv (f_bij : bijective f) : bijective (bij_inv f_bij) :=\n\u27e8(right_inverse_bij_inv _).injective, (left_inverse_bij_inv _).surjective\u27e9\n\nend bijection_inverse\nend fintype\n\nsection trunc\n\n/--\nFor `s : multiset \u03b1`, we can lift the existential statement that `\u2203 x, x \u2208 s` to a `trunc \u03b1`.\n-/\ndef trunc_of_multiset_exists_mem {\u03b1} (s : multiset \u03b1) : (\u2203 x, x \u2208 s) \u2192 trunc \u03b1 :=\nquotient.rec_on_subsingleton s $ \u03bb 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 (\u03b1) [nonempty \u03b1] [fintype \u03b1] : trunc \u03b1 :=\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 `\u2203 a, P a`\nto `trunc (\u03a3' a, P a)`, containing data.\n-/\ndef trunc_sigma_of_exists {\u03b1} [fintype \u03b1] {P : \u03b1 \u2192 Prop} [decidable_pred P] (h : \u2203 a, P a) :\n  trunc (\u03a3' a, P a) :=\n@trunc_of_nonempty_fintype (\u03a3' a, P a) (exists.elim h $ \u03bb a ha, \u27e8\u27e8a, ha\u27e9\u27e9) _\n\nend trunc\n\nnamespace multiset\n\nvariables [fintype \u03b1] [decidable_eq \u03b1]\n\n@[simp] lemma count_univ (a : \u03b1) :\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  {\u03b1 : Type*} [decidable_eq \u03b1] (P : \u03b1 \u2192 Prop) (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  (h : \u2200 (s : finset \u03b1), \u2203 y, (\u2200 x \u2208 s, P x) \u2192 (P y \u2227 (\u2200 x \u2208 s, r x y))) : \u2115 \u2192 \u03b1\n| n := classical.some (h (finset.image (\u03bb (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 : \u2115 \u2192 \u03b1` 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 {\u03b1 : Type*} (P : \u03b1 \u2192 Prop) (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  (h : \u2200 (s : finset \u03b1), (\u2200 x \u2208 s, P x) \u2192 \u2203 y, P y \u2227 (\u2200 x \u2208 s, r x y)) :\n  \u2203 (f : \u2115 \u2192 \u03b1), (\u2200 n, P (f n)) \u2227 (\u2200 m n, m < n \u2192 r (f m) (f n)) :=\nbegin\n  classical,\n  haveI : nonempty \u03b1,\n  { rcases h \u2205 (by simp) with \u27e8y, hy\u27e9,\n    exact \u27e8y\u27e9 },\n  choose! F hF using h,\n  have h' : \u2200 (s : finset \u03b1), \u2203 y, (\u2200 x \u2208 s, P x) \u2192 (P y \u2227 (\u2200 x \u2208 s, r x y)) := \u03bb s, \u27e8F s, hF s\u27e9,\n  set f := seq_of_forall_finset_exists_aux P r h' with hf,\n  have A : \u2200 (n : \u2115), P (f n),\n  { assume n,\n    induction n using nat.strong_induction_on with n IH,\n    have IH' : \u2200 (x : fin n), P (f x) := \u03bb n, IH n.1 n.2,\n    rw [hf, seq_of_forall_finset_exists_aux],\n    exact (classical.some_spec (h' (finset.image (\u03bb (i : fin n), f i)\n      (finset.univ : finset (fin n)))) (by simp [IH'])).1 },\n  refine \u27e8f, A, \u03bb m n hmn, _\u27e9,\n  nth_rewrite 1 hf,\n  rw seq_of_forall_finset_exists_aux,\n  apply (classical.some_spec (h' (finset.image (\u03bb (i : fin n), f i)\n    (finset.univ : finset (fin n)))) (by simp [A])).2,\n  exact finset.mem_image.2 \u27e8\u27e8m, hmn\u27e9, finset.mem_univ _, rfl\u27e9,\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 : \u2115 \u2192 \u03b1` such that `r (f m) (f n)` holds whenever `m \u2260 n`.\nWe also ensure that all constructed points satisfy a given predicate `P`. -/\nlemma exists_seq_of_forall_finset_exists' {\u03b1 : Type*} (P : \u03b1 \u2192 Prop) (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [is_symm \u03b1 r]\n  (h : \u2200 (s : finset \u03b1), (\u2200 x \u2208 s, P x) \u2192 \u2203 y, P y \u2227 (\u2200 x \u2208 s, r x y)) :\n  \u2203 (f : \u2115 \u2192 \u03b1), (\u2200 n, P (f n)) \u2227 (\u2200 m n, m \u2260 n \u2192 r (f m) (f n)) :=\nbegin\n  rcases exists_seq_of_forall_finset_exists P r h with \u27e8f, hf, hf'\u27e9,\n  refine \u27e8f, hf, \u03bb m n hmn, _\u27e9,\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 \u27f6 B` and `g : B \u27f6 C`\nare exact if `f \u226b g = 0` and the natural map `image f \u27f6 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.\u03b9 f` is a kernel of `g` or\n2. `image f \u27f6 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.\u03b9 s \u226b cofork.\u03c0 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 \u226b i.hom` and `i.inv \u226b 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\u2082 u u\u2082\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 \u27f6 B`, `g : B \u27f6 C` are called exact if `w : f \u226b g = 0` and the natural map\n`image_to_kernel f g w : image_subobject f \u27f6 kernel_subobject g` is an epimorphism.\n\nIn any preadditive category, this is equivalent to `w : f \u226b g = 0` and `homology f g w \u2245 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 \u2192 exact g h \u2192 exact (f \u226b g) h` and `exact f g \u2192 mono h \u2192 exact f (g \u226b 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 \u27f6 B) (g : B \u27f6 C) : Prop :=\n(w : f \u226b 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 \u226b 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 \u27f6 B) (g : B \u27f6 C) :\n  exact f g \u2194 \u2203 w : f \u226b g = 0, nonempty (homology f g w \u2245 0) :=\n\u27e8\u03bb h, \u27e8h.w, \u27e8cokernel.of_epi _\u27e9\u27e9,\n  \u03bb h, begin\n    obtain \u27e8w, \u27e8i\u27e9\u27e9 := h,\n    exact \u27e8w, preadditive.epi_of_cokernel_zero ((cancel_mono i.hom).mp (by ext))\u27e9,\n  end\u27e9\n\nlemma preadditive.exact_of_iso_of_exact {A\u2081 B\u2081 C\u2081 A\u2082 B\u2082 C\u2082 : V}\n  (f\u2081 : A\u2081 \u27f6 B\u2081) (g\u2081 : B\u2081 \u27f6 C\u2081) (f\u2082 : A\u2082 \u27f6 B\u2082) (g\u2082 : B\u2082 \u27f6 C\u2082)\n  (\u03b1 : arrow.mk f\u2081 \u2245 arrow.mk f\u2082) (\u03b2 : arrow.mk g\u2081 \u2245 arrow.mk g\u2082) (p : \u03b1.hom.right = \u03b2.hom.left)\n  (h : exact f\u2081 g\u2081) :\n  exact f\u2082 g\u2082 :=\nbegin\n  rw preadditive.exact_iff_homology_zero at h \u22a2,\n  rcases h with \u27e8w\u2081, \u27e8i\u27e9\u27e9,\n  suffices w\u2082 : f\u2082 \u226b g\u2082 = 0, from \u27e8w\u2082, \u27e8(homology.map_iso w\u2081 w\u2082 \u03b1 \u03b2 p).symm.trans i\u27e9\u27e9,\n  rw [\u2190 cancel_epi \u03b1.hom.left, \u2190 cancel_mono \u03b2.inv.right, comp_zero, zero_comp, \u2190 w\u2081],\n  simp only [\u2190 arrow.mk_hom f\u2081, \u2190 arrow.left_hom_inv_right \u03b1.hom,\n      \u2190 arrow.mk_hom g\u2081, \u2190 arrow.left_hom_inv_right \u03b2.hom, p],\n  simp only [arrow.mk_hom, is_iso.inv_hom_id_assoc, category.assoc, \u2190 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\u2081 B\u2081 C\u2081 A\u2082 B\u2082 C\u2082 : V}\n  (f\u2081 : A\u2081 \u27f6 B\u2081) (g\u2081 : B\u2081 \u27f6 C\u2081) (f\u2082 : A\u2082 \u27f6 B\u2082) (g\u2082 : B\u2082 \u27f6 C\u2082)\n  (\u03b1 : A\u2081 \u2245 A\u2082) (\u03b2 : B\u2081 \u2245 B\u2082) (\u03b3 : C\u2081 \u2245 C\u2082) (hsq\u2081 : \u03b1.hom \u226b f\u2082 = f\u2081 \u226b \u03b2.hom)\n  (hsq\u2082 : \u03b2.hom \u226b g\u2082 = g\u2081 \u226b \u03b3.hom)\n  (h : exact f\u2081 g\u2081) :\n  exact f\u2082 g\u2082 :=\npreadditive.exact_of_iso_of_exact f\u2081 g\u2081 f\u2082 g\u2082 (arrow.iso_mk \u03b1 \u03b2 hsq\u2081) (arrow.iso_mk \u03b2 \u03b3 hsq\u2082) rfl h\n\nlemma preadditive.exact_iff_exact_of_iso {A\u2081 B\u2081 C\u2081 A\u2082 B\u2082 C\u2082 : V}\n  (f\u2081 : A\u2081 \u27f6 B\u2081) (g\u2081 : B\u2081 \u27f6 C\u2081) (f\u2082 : A\u2082 \u27f6 B\u2082) (g\u2082 : B\u2082 \u27f6 C\u2082)\n  (\u03b1 : arrow.mk f\u2081 \u2245 arrow.mk f\u2082) (\u03b2 : arrow.mk g\u2081 \u2245 arrow.mk g\u2082) (p : \u03b1.hom.right = \u03b2.hom.left) :\n  exact f\u2081 g\u2081 \u2194 exact f\u2082 g\u2082 :=\n\u27e8preadditive.exact_of_iso_of_exact _ _ _ _ _ _ p,\npreadditive.exact_of_iso_of_exact _ _ _ _ \u03b1.symm \u03b2.symm\n  begin\n    rw \u2190 cancel_mono \u03b1.hom.right,\n    simp only [iso.symm_hom, \u2190 comma.comp_right, \u03b1.inv_hom_id],\n    simp only [p, \u2190comma.comp_left, arrow.id_right, arrow.id_left, iso.inv_hom_id],\n    refl\n  end\u27e9\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 \u27f6 B) (g : B \u27f6 C)\n  (p : image_subobject f = kernel_subobject g) : f \u226b g = 0 :=\nbegin\n  rw [\u2190image_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 \u27f6 B) (g : B \u27f6 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 \u27e8\u27e8subobject.of_le _ _ p.ge, _\u27e9\u27e9,\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 \u27f6 B) (g : B \u27f6 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 \u27f6 B} {g : B \u27f6 C} {h : C \u27f6 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 \u2245 D) (h : exact f g) : exact (f \u226b i.hom) (i.inv \u226b g) :=\nbegin\n  refine \u27e8by simp [h.w], _\u27e9,\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 \u2245 B) (h : exact f g) : exact (f \u226b i.inv) (i.hom \u226b g) :=\nexact_comp_hom_inv_comp i.symm h\n\nlemma exact_comp_hom_inv_comp_iff (i : B \u2245 D) : exact (f \u226b i.hom) (i.inv \u226b g) \u2194 exact f g :=\n\u27e8\u03bb h, by simpa using exact_comp_inv_hom_comp i h, exact_comp_hom_inv_comp i\u27e9\n\nlemma exact_epi_comp (hgh : exact g h) [epi f] : exact (f \u226b g) h :=\nbegin\n  refine \u27e8by simp [hgh.w], _\u27e9,\n  rw image_to_kernel_comp_left,\n  apply_instance,\nend\n\n@[simp]\nlemma exact_iso_comp [is_iso f] : exact (f \u226b g) h \u2194 exact g h :=\n\u27e8\u03bb w, by { rw \u2190is_iso.inv_hom_id_assoc f g, exact exact_epi_comp w }, \u03bb w, exact_epi_comp w\u27e9\n\nlemma exact_comp_mono (hfg : exact f g) [mono h] : exact f (g \u226b h) :=\nbegin\n  refine \u27e8by simp [hfg.w_assoc], _\u27e9,\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 \u226b h) \u2194 exact f g :=\nbegin\n  refine \u27e8\u03bb hfg, \u27e8zero_of_comp_mono h (by rw [category.assoc, hfg.1]), _\u27e9, \u03bb h, exact_comp_mono h\u27e9,\n  rw \u2190 (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 \u27e8by simp, _\u27e9,\n  apply @is_iso.epi_of_iso _ _ _ _ _ _,\n  exact \u27e8\u27e8factor_thru_image_subobject _, by { ext, simp, }, by { ext, simp, }\u27e9\u27e9,\nend\n\nlemma exact_kernel_\u03b9 : exact (kernel.\u03b9 f) f :=\nby { rw [\u2190kernel_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 \u2190factor_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 \u2190factor_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 \u27f6 B) g) :\n  (kernel_subobject g).arrow = 0 :=\nbegin\n  rw [\u2190cancel_epi (image_to_kernel (0 : A \u27f6 B) g h.w),\n    \u2190cancel_epi (factor_thru_image_subobject (0 : A \u27f6 B))],\n  simp\nend\n\nlemma kernel_\u03b9_eq_zero_of_exact_zero_left (h : exact (0 : A \u27f6 B) g) :\n  kernel.\u03b9 g = 0 :=\nby { rw \u2190kernel_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 \u27f6 B) g :=\n\u27e8by simp, image_to_kernel_epi_of_zero_of_mono _\u27e9\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.\u03b9 g \u226b cokernel.\u03c0 f = 0 :=\nbegin\n  rw [\u2190kernel_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, \u2190image_subobject_arrow, category.assoc, \u2190iso.eq_inv_comp],\n  ext,\n  simp,\nend\n\nlemma comp_eq_zero_of_exact (h : exact f g) {X Y : V} {\u03b9 : X \u27f6 B} (h\u03b9 : \u03b9 \u226b g = 0) {\u03c0 : B \u27f6 Y}\n  (h\u03c0 : f \u226b \u03c0 = 0) : \u03b9 \u226b \u03c0 = 0 :=\nby rw [\u2190kernel.lift_\u03b9 _ _ h\u03b9, \u2190cokernel.\u03c0_desc _ _ h\u03c0, category.assoc,\n  kernel_comp_cokernel_assoc _ _ h, zero_comp, comp_zero]\n\n@[simp, reassoc] lemma fork_\u03b9_comp_cofork_\u03c0 (h : exact f g) (s : kernel_fork g)\n  (t : cokernel_cofork f) : fork.\u03b9 s \u226b cofork.\u03c0 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 \u27f6 0) (g : 0 \u27f6 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 \u27f6 C) [mono f] : exact (0 : (0 \u27f6 B)) f :=\n\u27e8by simp, infer_instance\u27e9\n\nlemma exact_epi_zero {A B : V} (f : A \u27f6 B) [epi f] : exact f (0 : (B \u27f6 0)) :=\n\u27e8by simp, infer_instance\u27e9\n\nend\n\nsection\nvariables [preadditive V]\n\nlemma mono_iff_exact_zero_left [has_kernels V] {B C : V} (f : B \u27f6 C) :\n  mono f \u2194 exact (0 : (0 \u27f6 B)) f :=\n\u27e8\u03bb h, by exactI exact_zero_mono _,\n  \u03bb h, preadditive.mono_of_kernel_iso_zero\n      ((kernel_subobject_iso f).symm \u226a\u226b iso_zero_of_epi_zero (by simpa using h.epi))\u27e9\n\nlemma epi_iff_exact_zero_right [has_equalizers V] {A B : V} (f : A \u27f6 B) :\n  epi f \u2194 exact f (0 : (B \u27f6 0)) :=\n\u27e8\u03bb h, by exactI exact_epi_zero _,\n  \u03bb h, begin\n    have e\u2081 := h.epi,\n    rw image_to_kernel_zero_right at e\u2081,\n    have e\u2082 : epi (((image_subobject f).arrow \u226b inv (kernel_subobject 0).arrow) \u226b\n      (kernel_subobject 0).arrow) := @epi_comp _ _ _ _ _ _ e\u2081 _ _,\n    rw [category.assoc, is_iso.inv_hom_id, category.comp_id] at e\u2082,\n    rw [\u2190image_subobject_arrow] at e\u2082,\n    resetI,\n    haveI : epi (image.\u03b9 f) := epi_of_epi (image_subobject_iso f).hom (image.\u03b9 f),\n    apply epi_of_epi_image,\n  end\u27e9\n\nend\n\nend\n\nnamespace functor\nvariables [has_zero_morphisms V] [has_kernels V] {W : Type u\u2082} [category.{v\u2082} 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 \u2964 W) :=\n(reflects : \u2200 {A B C : V} (f : A \u27f6 B) (g : B \u27f6 C), exact (F.map f) (F.map g) \u2192 exact f g)\n\nlemma exact_of_exact_map (F : V \u2964 W) [reflects_exact_sequences F] {A B C : V} {f : A \u27f6 B}\n  {g : B \u27f6 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\u2081 w\u2082 v v\u2081 v\u2082 u u\u2081 u\u2082\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) : \u03a0 [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 \u2192 B \u2192 Type (max u v)\n| of {a b : B} (f : a \u27f6 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 \u27f6 b)] : inhabited (hom a b) := \u27e8hom.of default\u27e9\n\n/-- Representatives of 2-morphisms in the free bicategory. -/\n@[nolint has_nonempty_instance]\ninductive hom\u2082 : \u03a0 {a b : B}, hom a b \u2192 hom a b \u2192 Type (max u v)\n| id {a b} (f : hom a b) : hom\u2082 f f\n| vcomp {a b} {f g h : hom a b} (\u03b7 : hom\u2082 f g) (\u03b8 : hom\u2082 g h) : hom\u2082 f h\n| whisker_left {a b c} (f : hom a b) {g h : hom b c} (\u03b7 : hom\u2082 g h) : hom\u2082 (f.comp g) (f.comp h)\n-- `\u03b7` 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) (\u03b7 : hom\u2082 f g) : hom\u2082 (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\u2082 ((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\u2082 (f.comp (g.comp h)) ((f.comp g).comp h)\n| right_unitor     {a b} (f : hom a b) : hom\u2082 (f.comp (hom.id b)) f\n| right_unitor_inv {a b} (f : hom a b) : hom\u2082 f (f.comp (hom.id b))\n| left_unitor      {a b} (f : hom a b) : hom\u2082 ((hom.id a).comp f) f\n| left_unitor_inv  {a b} (f : hom a b) : hom\u2082 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) ` \u226b ` := hom\u2082.vcomp\nlocal notation (name := id) `\ud835\udfd9` := hom\u2082.id\nlocal notation (name := whisker_left) f ` \u25c1 ` \u03b7 := hom\u2082.whisker_left f \u03b7\nlocal notation (name := whisker_right) \u03b7 ` \u25b7 ` h := hom\u2082.whisker_right h \u03b7\nlocal notation (name := associator) `\u03b1_` := hom\u2082.associator\nlocal notation (name := left_unitor) `\u03bb_` := hom\u2082.left_unitor\nlocal notation (name := right_unitor) `\u03c1_` := hom\u2082.right_unitor\nlocal notation (name := associator_inv) `\u03b1\u207b\u00b9_` := hom\u2082.associator_inv\nlocal notation (name := left_unitor_inv) `\u03bb\u207b\u00b9_` := hom\u2082.left_unitor_inv\nlocal notation (name := right_unitor_inv) `\u03c1\u207b\u00b9_` := hom\u2082.right_unitor_inv\n\n/-- Relations between 2-morphisms in the free bicategory. -/\ninductive rel : \u03a0 {a b : B} {f g : hom a b}, hom\u2082 f g \u2192 hom\u2082 f g \u2192 Prop\n| vcomp_right {a b} {f g h : hom a b} (\u03b7 : hom\u2082 f g) (\u03b8\u2081 \u03b8\u2082 : hom\u2082 g h) :\n    rel \u03b8\u2081 \u03b8\u2082 \u2192 rel (\u03b7 \u226b \u03b8\u2081) (\u03b7 \u226b \u03b8\u2082)\n| vcomp_left {a b} {f g h : hom a b} (\u03b7\u2081 \u03b7\u2082 : hom\u2082 f g) (\u03b8 : hom\u2082 g h) :\n    rel \u03b7\u2081 \u03b7\u2082 \u2192 rel (\u03b7\u2081 \u226b \u03b8) (\u03b7\u2082 \u226b \u03b8)\n| id_comp {a b} {f g : hom a b} (\u03b7 : hom\u2082 f g) :\n    rel (\ud835\udfd9 f \u226b \u03b7) \u03b7\n| comp_id {a b} {f g : hom a b} (\u03b7 : hom\u2082 f g) :\n    rel (\u03b7 \u226b \ud835\udfd9 g) \u03b7\n| assoc {a b} {f g h i : hom a b} (\u03b7 : hom\u2082 f g) (\u03b8 : hom\u2082 g h) (\u03b9 : hom\u2082 h i) :\n    rel ((\u03b7 \u226b \u03b8) \u226b \u03b9) (\u03b7 \u226b (\u03b8 \u226b \u03b9))\n| whisker_left {a b c} (f : hom a b) (g h : hom b c) (\u03b7 \u03b7' : hom\u2082 g h) :\n    rel \u03b7 \u03b7' \u2192 rel (f \u25c1 \u03b7) (f \u25c1 \u03b7')\n| whisker_left_id {a b c} (f : hom a b) (g : hom b c) :\n    rel (f \u25c1 \ud835\udfd9 g) (\ud835\udfd9 (f.comp g))\n| whisker_left_comp {a b c} (f : hom a b) {g h i : hom b c} (\u03b7 : hom\u2082 g h) (\u03b8 : hom\u2082 h i) :\n    rel (f \u25c1 (\u03b7 \u226b \u03b8)) (f \u25c1 \u03b7 \u226b f \u25c1 \u03b8)\n| id_whisker_left {a b} {f g : hom a b} (\u03b7 : hom\u2082 f g) :\n    rel (hom.id a \u25c1 \u03b7) (\u03bb_ f \u226b \u03b7 \u226b \u03bb\u207b\u00b9_ g)\n| comp_whisker_left\n    {a b c d} (f : hom a b) (g : hom b c) {h h' : hom c d} (\u03b7 : hom\u2082 h h') :\n    rel ((f.comp g) \u25c1 \u03b7) (\u03b1_ f g h \u226b f \u25c1 g \u25c1 \u03b7 \u226b \u03b1\u207b\u00b9_ f g h')\n| whisker_right {a b c} (f g : hom a b) (h : hom b c) (\u03b7 \u03b7' : hom\u2082 f g) :\n    rel \u03b7 \u03b7' \u2192 rel (\u03b7 \u25b7 h) (\u03b7' \u25b7 h)\n| id_whisker_right {a b c} (f : hom a b) (g : hom b c) :\n    rel (\ud835\udfd9 f \u25b7 g) (\ud835\udfd9 (f.comp g))\n| comp_whisker_right {a b c} {f g h : hom a b} (i : hom b c) (\u03b7 : hom\u2082 f g) (\u03b8 : hom\u2082 g h) :\n    rel ((\u03b7 \u226b \u03b8) \u25b7 i) (\u03b7 \u25b7 i \u226b \u03b8 \u25b7 i)\n| whisker_right_id {a b} {f g : hom a b} (\u03b7 : hom\u2082 f g) :\n    rel (\u03b7 \u25b7 hom.id b) (\u03c1_ f \u226b \u03b7 \u226b \u03c1\u207b\u00b9_ g)\n| whisker_right_comp\n    {a b c d} {f f' : hom a b} (g : hom b c) (h : hom c d) (\u03b7 : hom\u2082 f f') :\n    rel (\u03b7 \u25b7 (g.comp h)) (\u03b1\u207b\u00b9_ f g h \u226b \u03b7 \u25b7 g \u25b7 h \u226b \u03b1_ f' g h)\n| whisker_assoc\n    {a b c d} (f : hom a b) {g g' : hom b c} (\u03b7 : hom\u2082 g g') (h : hom c d) :\n    rel ((f \u25c1 \u03b7) \u25b7 h) (\u03b1_ f g h \u226b f \u25c1 (\u03b7 \u25b7 h)\u226b \u03b1\u207b\u00b9_ f g' h)\n| whisker_exchange {a b c} {f g : hom a b} {h i : hom b c} (\u03b7 : hom\u2082 f g) (\u03b8 : hom\u2082 h i) :\n    rel (f \u25c1 \u03b8 \u226b \u03b7 \u25b7 i) (\u03b7 \u25b7 h \u226b g \u25c1 \u03b8)\n| associator_hom_inv {a b c d} (f : hom a b) (g : hom b c) (h : hom c d) :\n    rel (\u03b1_ f g h \u226b \u03b1\u207b\u00b9_ f g h) (\ud835\udfd9 ((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 (\u03b1\u207b\u00b9_ f g h \u226b \u03b1_ f g h) (\ud835\udfd9 (f.comp (g.comp h)))\n| left_unitor_hom_inv {a b} (f : hom a b) :\n    rel (\u03bb_ f \u226b \u03bb\u207b\u00b9_ f) (\ud835\udfd9 ((hom.id a).comp f))\n| left_unitor_inv_hom {a b} (f : hom a b) :\n    rel (\u03bb\u207b\u00b9_ f \u226b \u03bb_ f) (\ud835\udfd9 f)\n| right_unitor_hom_inv {a b} (f : hom a b) :\n    rel (\u03c1_ f \u226b \u03c1\u207b\u00b9_ f) (\ud835\udfd9 (f.comp (hom.id b)))\n| right_unitor_inv_hom {a b} (f : hom a b) :\n    rel (\u03c1\u207b\u00b9_ f \u226b \u03c1_ f) (\ud835\udfd9 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 (\u03b1_ f g h \u25b7 i \u226b \u03b1_ f (g.comp h) i \u226b f \u25c1 \u03b1_ g h i)\n        (\u03b1_ (f.comp g) h i \u226b \u03b1_ f g (h.comp i))\n| triangle {a b c} (f : hom a b) (g : hom b c) :\n    rel (\u03b1_ f (hom.id b) g \u226b f \u25c1 \u03bb_ g) (\u03c1_ f \u25b7 g)\n\nend\n\nvariables {B}\n\ninstance hom_category (a b : B) : category (hom a b) :=\n{ hom       := \u03bb f g, quot (@rel _ _ _ _ f g),\n  id        := \u03bb f, quot.mk rel (hom\u2082.id f),\n  comp      := \u03bb f g h, quot.map\u2082 hom\u2082.vcomp rel.vcomp_right rel.vcomp_left,\n  id_comp'  := by { rintros f g \u27e8\u03b7\u27e9, exact quot.sound (rel.id_comp \u03b7) },\n  comp_id'  := by { rintros f g \u27e8\u03b7\u27e9, exact quot.sound (rel.comp_id \u03b7) },\n  assoc'    := by { rintros f g h i \u27e8\u03b7\u27e9 \u27e8\u03b8\u27e9 \u27e8\u03b9\u27e9, exact quot.sound (rel.assoc \u03b7 \u03b8 \u03b9) } }\n\n/-- Bicategory structure on the free bicategory. -/\ninstance bicategory : bicategory (free_bicategory B) :=\n{ hom   := \u03bb a b : B, hom a b,\n  id    := hom.id,\n  comp  := \u03bb a b c, hom.comp,\n  hom_category := free_bicategory.hom_category,\n  whisker_left := \u03bb a b c f g h \u03b7,\n    quot.map (hom\u2082.whisker_left f) (rel.whisker_left f g h) \u03b7,\n  whisker_left_id' := \u03bb 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 \u27e8\u03b7\u27e9 \u27e8\u03b8\u27e9, exact quot.sound (rel.whisker_left_comp f \u03b7 \u03b8) },\n  id_whisker_left' := by\n  { rintros a b f g \u27e8\u03b7\u27e9, exact quot.sound (rel.id_whisker_left \u03b7) },\n  comp_whisker_left' := by\n  { rintros a b c d f g h h' \u27e8\u03b7\u27e9, exact quot.sound (rel.comp_whisker_left f g \u03b7) },\n  whisker_right := \u03bb a b c f g \u03b7 h,\n    quot.map (hom\u2082.whisker_right h) (rel.whisker_right f g h) \u03b7,\n  id_whisker_right' := \u03bb 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 \u27e8\u03b7\u27e9 \u27e8\u03b8\u27e9 i, exact quot.sound (rel.comp_whisker_right i \u03b7 \u03b8) },\n  whisker_right_id' := by\n  { rintros a b f g \u27e8\u03b7\u27e9, exact quot.sound (rel.whisker_right_id \u03b7) },\n  whisker_right_comp' := by\n  { rintros a b c d f f' \u27e8\u03b7\u27e9 g h, exact quot.sound (rel.whisker_right_comp g h \u03b7) },\n  whisker_assoc' := by\n  { rintros a b c d f g g' \u27e8\u03b7\u27e9 h, exact quot.sound (rel.whisker_assoc f \u03b7 h) },\n  whisker_exchange' := by\n  { rintros a b c f g h i \u27e8\u03b7\u27e9 \u27e8\u03b8\u27e9, exact quot.sound (rel.whisker_exchange \u03b7 \u03b8) },\n  associator := \u03bb a b c d f g h,\n  { hom := quot.mk rel (hom\u2082.associator f g h),\n    inv := quot.mk rel (hom\u2082.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 := \u03bb a b f,\n  { hom := quot.mk rel (hom\u2082.left_unitor f),\n    inv := quot.mk rel (hom\u2082.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 := \u03bb a b f,\n  { hom := quot.mk rel (hom\u2082.right_unitor f),\n    inv := quot.mk rel (hom\u2082.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' := \u03bb a b c d e f g h i, quot.sound (rel.pentagon f g h i),\n  triangle' := \u03bb 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 \u27f6 b} (\u03b7 : hom\u2082 f g) (\u03b8 : hom\u2082 g h) :\n  quot.mk rel (\u03b7.vcomp \u03b8) = (quot.mk rel \u03b7 \u226b quot.mk rel \u03b8 : f \u27f6 h) := rfl\n@[simp] lemma mk_whisker_left (f : a \u27f6 b) {g h : b \u27f6 c} (\u03b7 : hom\u2082 g h) :\n  quot.mk rel (hom\u2082.whisker_left f \u03b7) = (f \u25c1 quot.mk rel \u03b7 : f \u226b g \u27f6 f \u226b h) := rfl\n@[simp] lemma mk_whisker_right {f g : a \u27f6 b} (\u03b7 : hom\u2082 f g) (h : b \u27f6 c) :\n  quot.mk rel (hom\u2082.whisker_right h \u03b7) = (quot.mk rel \u03b7 \u25b7 h : f \u226b h \u27f6 g \u226b h) := rfl\n\nvariables (f : a \u27f6 b) (g : b \u27f6 c) (h : c \u27f6 d)\n\nlemma id_def : hom.id a = \ud835\udfd9 a := rfl\nlemma comp_def : hom.comp f g = f \u226b g := rfl\n@[simp] lemma mk_id : quot.mk _ (hom\u2082.id f) = \ud835\udfd9 f := rfl\n@[simp] lemma mk_associator_hom : quot.mk _ (hom\u2082.associator f g h) = (\u03b1_ 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 := \u03bb a b, hom.of }\n\nend\n\nsection\nvariables {B : Type u\u2081} [quiver.{v\u2081+1} B] {C : Type u\u2082} [category_struct.{v\u2082} C]\nvariables (F : prefunctor B C)\n\n/-- Auxiliary definition for `lift`. -/\n@[simp]\ndef lift_hom : \u2200 {a b : B}, hom a b \u2192 (F.obj a \u27f6 F.obj b)\n| _ _ (hom.of f)      := F.map f\n| _ _ (hom.id a)      := \ud835\udfd9 (F.obj a)\n| _ _ (hom.comp f g)  := lift_hom f \u226b lift_hom g\n\n@[simp] lemma lift_hom_id (a : free_bicategory B) : lift_hom F (\ud835\udfd9 a) = \ud835\udfd9 (F.obj a) := rfl\n@[simp] lemma lift_hom_comp {a b c : free_bicategory B} (f : a \u27f6 b) (g : b \u27f6 c) :\n  lift_hom F (f \u226b g) = lift_hom F f \u226b lift_hom F g := rfl\n\nend\n\nsection\nvariables {B : Type u\u2081} [quiver.{v\u2081+1} B] {C : Type u\u2082} [bicategory.{w\u2082 v\u2082} C]\nvariables (F : prefunctor B C)\n\n/-- Auxiliary definition for `lift`. -/\n@[simp]\ndef lift_hom\u2082 : \u2200 {a b : B} {f g : hom a b}, hom\u2082 f g \u2192 (lift_hom F f \u27f6 lift_hom F g)\n| _ _ _ _ (hom\u2082.id _)                   := \ud835\udfd9 _\n| _ _ _ _ (hom\u2082.associator _ _ _)       := (\u03b1_ _ _ _).hom\n| _ _ _ _ (hom\u2082.associator_inv _ _ _)   := (\u03b1_ _ _ _).inv\n| _ _ _ _ (hom\u2082.left_unitor _)          := (\u03bb_ _).hom\n| _ _ _ _ (hom\u2082.left_unitor_inv _)      := (\u03bb_ _).inv\n| _ _ _ _ (hom\u2082.right_unitor _)         := (\u03c1_ _).hom\n| _ _ _ _ (hom\u2082.right_unitor_inv _)     := (\u03c1_ _).inv\n| _ _ _ _ (hom\u2082.vcomp \u03b7 \u03b8)              := lift_hom\u2082 \u03b7 \u226b lift_hom\u2082 \u03b8\n| _ _ _ _ (hom\u2082.whisker_left f \u03b7)       := lift_hom F f \u25c1 lift_hom\u2082 \u03b7\n| _ _ _ _ (hom\u2082.whisker_right h \u03b7)      := lift_hom\u2082 \u03b7 \u25b7 lift_hom F h\n\nlocal attribute [simp] whisker_exchange\n\nlemma lift_hom\u2082_congr {a b : B} {f g : hom a b} {\u03b7 \u03b8 : hom\u2082 f g} (H : rel \u03b7 \u03b8) :\n  lift_hom\u2082 F \u03b7 = lift_hom\u2082 F \u03b8 :=\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       := \u03bb a b, lift_hom F,\n  map\u2082      := \u03bb a b f g, quot.lift (lift_hom\u2082 F) (\u03bb \u03b7 \u03b8 H, lift_hom\u2082_congr F H),\n  map_id    := \u03bb a, iso.refl _,\n  map_comp  := \u03bb 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\u2081 P\u2081 V\u2082 P\u2082 : Type _} [Ring k] [AddCommGroup V\u2081] [AddCommGroup V\u2082] [Module k V\u2081]\n  [Module k V\u2082] [AddTorsor V\u2081 P\u2081] [AddTorsor V\u2082 P\u2082]\n\ninclude V\u2081 V\u2082\n\n/- warning: affine_subspace.nonempty_map -> AffineSubspace.nonempty_map is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {V\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} [Ene : Nonempty.{succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E)] {\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))\nbut is expected to have type\n  forall {k : Type.{u5}} {V\u2081 : Type.{u4}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} {P\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : AddCommGroup.{u2} V\u2082] [_inst_4 : Module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_5 : Module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _inst_3)] {E : AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} [Ene : Nonempty.{succ u3} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E))] {\u03c6 : AffineMap.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, Nonempty.{succ u1} (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E)))\nCase conversion may be inaccurate. Consider using '#align affine_subspace.nonempty_map AffineSubspace.nonempty_map\u2093'. -/\n-- not an instance because it loops with `nonempty`\ntheorem AffineSubspace.nonempty_map {E : AffineSubspace k P\u2081} [Ene : Nonempty E] {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} :\n    Nonempty (E.map \u03c6) := by\n  obtain \u27e8x, hx\u27e9 := id Ene\n  refine' \u27e8\u27e8\u03c6 x, affine_subspace.mem_map.mpr \u27e8x, hx, rfl\u27e9\u27e9\u27e9\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\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] (\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _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\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F)], (LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F) -> (AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9))\nbut is expected to have type\n  forall {k : Type.{u1}} {V\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] (\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u5} (Subtype.{succ u5} P\u2082 (fun (x : P\u2082) => Membership.mem.{u5, u5} P\u2082 (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F))], (LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F) -> (AffineMap.{u1, u2, u3, u4, u5} k (Subtype.{succ u2} V\u2081 (fun (x : V\u2081) => Membership.mem.{u2, u2} V\u2081 (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u4} V\u2082 (fun (x : V\u2082) => Membership.mem.{u4, u4} V\u2082 (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u5} P\u2082 (fun (x : P\u2082) => Membership.mem.{u5, u5} P\u2082 (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict AffineMap.restrict\u2093'. -/\n/-- Restrict domain and codomain of an affine map to the given subspaces. -/\ndef AffineMap.restrict (\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082) {E : AffineSubspace k P\u2081} {F : AffineSubspace k P\u2082}\n    [Nonempty E] [Nonempty F] (hEF : E.map \u03c6 \u2264 F) : E \u2192\u1d43[k] F :=\n  by\n  refine' \u27e8_, _, _\u27e9\n  \u00b7 exact fun x => \u27e8\u03c6 x, hEF <| affine_subspace.mem_map.mpr \u27e8x, x.property, rfl\u27e9\u27e9\n  \u00b7 refine' \u03c6.linear.restrict (_ : E.direction \u2264 F.direction.comap \u03c6.linear)\n    rw [\u2190 Submodule.map_le_iff_le_comap, \u2190 AffineSubspace.map_direction]\n    exact AffineSubspace.direction_le hEF\n  \u00b7 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\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] (\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _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\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F)] (hEF : LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F) (x : coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E), Eq.{succ u5} P\u2082 ((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\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) P\u2082 (HasLiftT.mk.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) P\u2082 (CoeTC\u2093.coe.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) P\u2082 (coeBase.{succ u5, succ u5} (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) P\u2082 (coeSubtype.{succ u5} P\u2082 (fun (x : P\u2082) => Membership.Mem.{u5, u5} P\u2082 (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.hasMem.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) => (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) -> (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) => P\u2081 -> P\u2082) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) \u03c6 ((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\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) P\u2081 (HasLiftT.mk.{succ u3, succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) P\u2081 (CoeTC\u2093.coe.{succ u3, succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) P\u2081 (coeBase.{succ u3, succ u3} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) P\u2081 (coeSubtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.Mem.{u3, u3} P\u2081 (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.hasMem.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E))))) x))\nbut is expected to have type\n  forall {k : Type.{u5}} {V\u2081 : Type.{u4}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} {P\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : AddCommGroup.{u2} V\u2082] [_inst_4 : Module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_5 : Module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _inst_3)] (\u03c6 : AffineMap.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u1} (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F))] (hEF : LE.le.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F) (x : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)), Eq.{succ u1} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) (Subtype.val.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (Set.{u3} P\u2081) (Set.instMembershipSet.{u3} P\u2081) x (SetLike.coe.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) E)) x)) (Subtype.val.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (Set.{u1} P\u2082) (Set.instMembershipSet.{u1} P\u2082) x (SetLike.coe.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _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\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (fun (_x : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) \u03c6 (Subtype.val.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (Set.{u3} P\u2081) (Set.instMembershipSet.{u3} P\u2081) x (SetLike.coe.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _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\u2093'. -/\ntheorem AffineMap.restrict.coe_apply (\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082) {E : AffineSubspace k P\u2081}\n    {F : AffineSubspace k P\u2082} [Nonempty E] [Nonempty F] (hEF : E.map \u03c6 \u2264 F) (x : E) :\n    \u2191(\u03c6.restrict hEF x) = \u03c6 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\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] {\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7} {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7}, (LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F) -> (LE.le.{u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) (Preorder.toLE.{u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) (PartialOrder.toPreorder.{u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) (SetLike.partialOrder.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)))) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E) (Submodule.comap.{u1, u1, u2, u4, max u2 u4} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_4 _inst_5) (LinearMap.semilinearMapClass.{u1, u1, u2, u4} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)))\nbut is expected to have type\n  forall {k : Type.{u5}} {V\u2081 : Type.{u4}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} {P\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : AddCommGroup.{u2} V\u2082] [_inst_4 : Module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_5 : Module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _inst_3)] {\u03c6 : AffineMap.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7} {E : AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7}, (LE.le.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F) -> (LE.le.{u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (Preorder.toLE.{u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (PartialOrder.toPreorder.{u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (OmegaCompletePartialOrder.toPartialOrder.{u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (CompleteLattice.instOmegaCompletePartialOrder.{u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (Submodule.completeLattice.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4))))) (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E) (Submodule.comap.{u5, u5, u4, u2, max u4 u2} k k V\u2081 V\u2082 (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_4 _inst_5) (LinearMap.instSemilinearMapClassLinearMap.{u5, u5, u4, u2} k k V\u2081 V\u2082 (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6) (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _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\u2093'. -/\ntheorem AffineMap.restrict.linear_aux {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} {E : AffineSubspace k P\u2081}\n    {F : AffineSubspace k P\u2082} (hEF : E.map \u03c6 \u2264 F) : E.direction \u2264 F.direction.comap \u03c6.linear :=\n  by\n  rw [\u2190 Submodule.map_le_iff_le_comap, \u2190 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\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] (\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _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\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F)] (hEF : LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AddCommGroup.toAddCommMonoid.{u2} (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (AddCommGroup.toAddCommMonoid.{u4} (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E F _inst_8 _inst_9 hEF)) (LinearMap.restrict.{u1, u2, u4} k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_4 _inst_5 (AffineMap.linear.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F) (AffineMap.restrict.linear_aux.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E F hEF))\nbut is expected to have type\n  forall {k : Type.{u5}} {V\u2081 : Type.{u4}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} {P\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : AddCommGroup.{u2} V\u2082] [_inst_4 : Module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_5 : Module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _inst_3)] (\u03c6 : AffineMap.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u1} (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F))] (hEF : LE.le.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 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\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (AddCommGroup.toAddCommMonoid.{u4} (Subtype.{succ u4} V\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (AddCommGroup.toAddCommMonoid.{u2} (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (AffineMap.linear.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E F _inst_8 _inst_9 hEF)) (LinearMap.restrict.{u5, u4, u2} k V\u2081 V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_4 _inst_5 (AffineMap.linear.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6) (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E) (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F) (AffineMap.restrict.linear_aux.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E F hEF))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.linear AffineMap.restrict.linear\u2093'. -/\ntheorem AffineMap.restrict.linear (\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082) {E : AffineSubspace k P\u2081}\n    {F : AffineSubspace k P\u2082} [Nonempty E] [Nonempty F] (hEF : E.map \u03c6 \u2264 F) :\n    (\u03c6.restrict hEF).linear = \u03c6.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\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] {\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, (Function.Injective.{succ u3, succ u5} P\u2081 P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) => P\u2081 -> P\u2082) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) \u03c6)) -> (forall {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _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\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F)] (hEF : LE.le.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F), Function.Injective.{succ u3, succ u5} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) => (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) -> (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E F _inst_8 _inst_9 hEF)))\nbut is expected to have type\n  forall {k : Type.{u5}} {V\u2081 : Type.{u4}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} {P\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : AddCommGroup.{u2} V\u2082] [_inst_4 : Module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_5 : Module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _inst_3)] {\u03c6 : AffineMap.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, (Function.Injective.{succ u3, succ u1} P\u2081 P\u2082 (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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) \u03c6)) -> (forall {E : AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u1} (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F))] (hEF : LE.le.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (Preorder.toLE.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7))))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F), Function.Injective.{succ u3, succ u1} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _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\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (fun (_x : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E F _inst_8 _inst_9 hEF)))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.injective AffineMap.restrict.injective\u2093'. -/\ntheorem AffineMap.restrict.injective {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} (h\u03c6 : Function.Injective \u03c6)\n    {E : AffineSubspace k P\u2081} {F : AffineSubspace k P\u2082} [Nonempty E] [Nonempty F]\n    (hEF : E.map \u03c6 \u2264 F) : Function.Injective (AffineMap.restrict \u03c6 hEF) :=\n  by\n  intro x y h\n  simp only [Subtype.ext_iff, Subtype.coe_mk, AffineMap.restrict.coe_apply] at h\u22a2\n  exact h\u03c6 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\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] (\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _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\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F)] (h : Eq.{succ u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F), Function.Surjective.{succ u3, succ u5} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) => (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) -> (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) F) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E F _inst_8 _inst_9 (le_of_eq.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F h)))\nbut is expected to have type\n  forall {k : Type.{u5}} {V\u2081 : Type.{u4}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} {P\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : AddCommGroup.{u2} V\u2082] [_inst_4 : Module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_5 : Module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _inst_3)] (\u03c6 : AffineMap.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) {E : AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} {F : AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E))] [_inst_9 : Nonempty.{succ u1} (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F))] (h : Eq.{succ u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F), Function.Surjective.{succ u3, succ u1} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _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\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (fun (_x : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x F)) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F)) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 F _inst_9)) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E F _inst_8 _inst_9 (le_of_eq.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) F h)))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.surjective AffineMap.restrict.surjective\u2093'. -/\ntheorem AffineMap.restrict.surjective (\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082) {E : AffineSubspace k P\u2081}\n    {F : AffineSubspace k P\u2082} [Nonempty E] [Nonempty F] (h : E.map \u03c6 = F) :\n    Function.Surjective (AffineMap.restrict \u03c6 (le_of_eq h)) :=\n  by\n  rintro \u27e8x, hx : x \u2208 F\u27e9\n  rw [\u2190 h, AffineSubspace.mem_map] at hx\n  obtain \u27e8y, hy, rfl\u27e9 := hx\n  exact \u27e8\u27e8y, hy\u27e9, rfl\u27e9\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\u2081 : Type.{u2}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u4}} {P\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : AddCommGroup.{u4} V\u2082] [_inst_4 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : Module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u4, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u4} V\u2082 _inst_3)] {E : AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E)] {\u03c6 : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, (Function.Injective.{succ u3, succ u5} P\u2081 P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u3) (succ u5)} (AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) => P\u2081 -> P\u2082) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) \u03c6)) -> (Function.Bijective.{succ u3, succ u5} (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 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\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E)) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 \u03c6))) (fun (_x : AffineMap.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E)) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 \u03c6))) => (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) -> (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (AffineMap.hasCoeToFun.{u1, u2, u3, u4, u5} k (coeSort.{succ u2, succ (succ u2)} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) Type.{u2} (SetLike.hasCoeToSort.{u2, u2} (Submodule.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4)) (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (coeSort.{succ u3, succ (succ u3)} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) Type.{u3} (SetLike.hasCoeToSort.{u3, u3} (AffineSubspace.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.setLike.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) E) (coeSort.{succ u4, succ (succ u4)} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) Type.{u4} (SetLike.hasCoeToSort.{u4, u4} (Submodule.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5)) (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (coeSort.{succ u5, succ (succ u5)} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) Type.{u5} (SetLike.hasCoeToSort.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E)) _inst_1 (Submodule.addCommGroup.{u1, u2} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u1, u2, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u1, u4} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (Submodule.module.{u1, u4} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (AffineSubspace.toAddTorsor.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 \u03c6))) (AffineMap.restrict.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) _inst_8 (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 \u03c6) (le_refl.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.partialOrder.{u5, u5} (AffineSubspace.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.setLike.{u1, u4, u5} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7))) (AffineSubspace.map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E)))))\nbut is expected to have type\n  forall {k : Type.{u5}} {V\u2081 : Type.{u4}} {P\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} {P\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : AddCommGroup.{u2} V\u2082] [_inst_4 : Module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_5 : Module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3)] [_inst_6 : AddTorsor.{u4, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_7 : AddTorsor.{u2, u1} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _inst_3)] {E : AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6} [_inst_8 : Nonempty.{succ u3} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E))] {\u03c6 : AffineMap.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7}, (Function.Injective.{succ u3, succ u1} P\u2081 P\u2082 (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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7) \u03c6)) -> (Function.Bijective.{succ u3, succ u1} (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 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\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E)))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 \u03c6))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (fun (_x : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) => Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k (Subtype.{succ u4} V\u2081 (fun (x : V\u2081) => Membership.mem.{u4, u4} V\u2081 (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) (SetLike.instMembership.{u4, u4} (Submodule.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4) V\u2081 (Submodule.setLike.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4)) x (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E))) (Subtype.{succ u3} P\u2081 (fun (x : P\u2081) => Membership.mem.{u3, u3} P\u2081 (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) (SetLike.instMembership.{u3, u3} (AffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6) P\u2081 (AffineSubspace.instSetLikeAffineSubspace.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6)) x E)) (Subtype.{succ u2} V\u2082 (fun (x : V\u2082) => Membership.mem.{u2, u2} V\u2082 (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) (SetLike.instMembership.{u2, u2} (Submodule.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5) V\u2082 (Submodule.setLike.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5)) x (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E)))) (Subtype.{succ u1} P\u2082 (fun (x : P\u2082) => Membership.mem.{u1, u1} P\u2082 (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (SetLike.instMembership.{u1, u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) P\u2082 (AffineSubspace.instSetLikeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)) x (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) _inst_1 (Submodule.addCommGroup.{u5, u4} k V\u2081 _inst_1 _inst_2 _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (Submodule.module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_4 (AffineSubspace.direction.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E)) (AffineSubspace.toAddTorsor.{u5, u4, u3} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_4 _inst_6 E _inst_8) (Submodule.addCommGroup.{u5, u2} k V\u2082 _inst_1 _inst_3 _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (Submodule.module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_3) _inst_5 (AffineSubspace.direction.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E))) (AffineSubspace.toAddTorsor.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7 (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 \u03c6))) (AffineMap.restrict.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 E (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E) _inst_8 (AffineSubspace.nonempty_map.{u1, u2, u3, u4, u5} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 E _inst_8 \u03c6) (le_refl.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (PartialOrder.toPreorder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (OmegaCompletePartialOrder.toPartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (CompleteLattice.instOmegaCompletePartialOrder.{u1} (AffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7) (AffineSubspace.instCompleteLatticeAffineSubspace.{u5, u2, u1} k V\u2082 P\u2082 _inst_1 _inst_3 _inst_5 _inst_7)))) (AffineSubspace.map.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_4 _inst_6 _inst_3 _inst_5 _inst_7 \u03c6 E)))))\nCase conversion may be inaccurate. Consider using '#align affine_map.restrict.bijective AffineMap.restrict.bijective\u2093'. -/\ntheorem AffineMap.restrict.bijective {E : AffineSubspace k P\u2081} [Nonempty E] {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082}\n    (h\u03c6 : Function.Injective \u03c6) : Function.Bijective (\u03c6.restrict (le_refl (E.map \u03c6))) :=\n  \u27e8AffineMap.restrict.injective h\u03c6 _, AffineMap.restrict.surjective _ rfl\u27e9\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\u00f6lzl, 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 \u03b1` on a type `\u03b1` is a nonempty collection of sets of `\u03b1`\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 \u03b1` such that a set belongs\nto `B.filter` if and only if it contains an element of `B`.\n\nGiven an indexing type `\u03b9`, a predicate `p : \u03b9 \u2192 Prop`, and a map `s : \u03b9 \u2192 set \u03b1`,\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 `\u03b1`, `filter.has_basis l p s` (where `p : \u03b9 \u2192 Prop`\nand `s : \u03b9 \u2192 set \u03b1` 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 \u2208 l)` that returns\nsome index `i` such that `p i` and `s i \u2286 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 \u03b1`, `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 \u2208 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 \u2293 l'`,\n  `l \u2293 \ud835\udcdf t`, `l \u00d7\u1da0 l'`, `l \u00d7\u1da0 l`, `l.map f`, `l.comap f` respectively;\n* `has_basis.le_iff`, `has_basis.ge_iff`, has_basis.le_basis_iff` : restate `l \u2264 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 `\u2115`.\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 \u03b1)`;\n* `has_basis l s`, `s : \u03b9 \u2192 set \u03b1`;\n* `has_basis l p s`, `p : \u03b9 \u2192 Prop`, `s : \u03b9 \u2192 set \u03b1`.\n\nWe use the latter one because, e.g., `\ud835\udcdd 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 = \u03bb _, 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 = \u03bb _, true`.\n-/\n\nopen set filter\nopen_locale filter classical\n\nsection sort\n\nvariables {\u03b1 \u03b2 \u03b3 : Type*} {\u03b9 \u03b9' : Sort*}\n\n/-- A filter basis `B` on a type `\u03b1` is a nonempty collection of sets of `\u03b1`\nsuch that the intersection of two elements of this collection contains some element\nof the collection. -/\nstructure filter_basis (\u03b1 : Type*) :=\n(sets                   : set (set \u03b1))\n(nonempty               : sets.nonempty)\n(inter_sets {x y}       : x \u2208 sets \u2192 y \u2208 sets \u2192 \u2203 z \u2208 sets, z \u2286 x \u2229 y)\n\ninstance filter_basis.nonempty_sets (B : filter_basis \u03b1) : nonempty B.sets := B.nonempty.to_subtype\n\n/-- If `B` is a filter basis on `\u03b1`, and `U` a subset of `\u03b1` then we can write `U \u2208 B` as\non paper. -/\n@[reducible]\ninstance {\u03b1 : Type*}: has_mem (set \u03b1) (filter_basis \u03b1) := \u27e8\u03bb U B, U \u2208 B.sets\u27e9\n\n-- For illustration purposes, the filter basis defining (at_top : filter \u2115)\ninstance : inhabited (filter_basis \u2115) :=\n\u27e8{ sets := range Ici,\n  nonempty := \u27e8Ici 0, mem_range_self 0\u27e9,\n  inter_sets := begin\n    rintros _ _ \u27e8n, rfl\u27e9 \u27e8m, rfl\u27e9,\n    refine \u27e8Ici (max n m), mem_range_self _, _\u27e9,\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 }\u27e9\n\n/-- View a filter as a filter basis. -/\ndef filter.as_basis (f : filter \u03b1) : filter_basis \u03b1 :=\n\u27e8f.sets, \u27e8univ, univ_mem\u27e9, \u03bb x y hx hy, \u27e8x \u2229 y, inter_mem hx hy, subset_rfl\u27e9\u27e9\n\n/-- `is_basis p s` means the image of `s` bounded by `p` is a filter basis. -/\nprotected structure filter.is_basis (p : \u03b9 \u2192 Prop) (s : \u03b9 \u2192 set \u03b1) : Prop :=\n(nonempty : \u2203 i, p i)\n(inter : \u2200 {i j}, p i \u2192 p j \u2192 \u2203 k, p k \u2227 s k \u2286 s i \u2229 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 : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1} (h : is_basis p s) : filter_basis \u03b1 :=\n{ sets := {t | \u2203 i, p i \u2227 s i = t},\n  nonempty := let \u27e8i, hi\u27e9 := h.nonempty in \u27e8s i, \u27e8i, hi, rfl\u27e9\u27e9,\n  inter_sets := by { rintros _ _ \u27e8i, hi, rfl\u27e9 \u27e8j, hj, rfl\u27e9,\n                     rcases h.inter hi hj with \u27e8k, hk, hk'\u27e9,\n                     exact \u27e8_, \u27e8k, hk, rfl\u27e9, hk'\u27e9 } }\n\nvariables {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1} (h : is_basis p s)\n\nlemma mem_filter_basis_iff {U : set \u03b1} : U \u2208 h.filter_basis \u2194 \u2203 i, p i \u2227 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 \u03b1) : filter \u03b1 :=\n{ sets := {s | \u2203 t \u2208 B, t \u2286 s},\n  univ_sets := let \u27e8s, s_in\u27e9 := B.nonempty in \u27e8s, s_in, s.subset_univ\u27e9,\n  sets_of_superset := \u03bb x y \u27e8s, s_in, h\u27e9 hxy, \u27e8s, s_in, set.subset.trans h hxy\u27e9,\n  inter_sets := \u03bb x y \u27e8s, s_in, hs\u27e9 \u27e8t, t_in, ht\u27e9,\n                let \u27e8u, u_in, u_sub\u27e9 := B.inter_sets s_in t_in in\n                \u27e8u, u_in, set.subset.trans u_sub $ set.inter_subset_inter hs ht\u27e9 }\n\nlemma mem_filter_iff (B : filter_basis \u03b1) {U : set \u03b1} : U \u2208 B.filter \u2194 \u2203 s \u2208 B, s \u2286 U :=\niff.rfl\n\nlemma mem_filter_of_mem (B : filter_basis \u03b1) {U : set \u03b1} : U \u2208 B \u2192 U \u2208 B.filter:=\n\u03bb U_in, \u27e8U, U_in, subset.refl _\u27e9\n\nlemma eq_infi_principal (B : filter_basis \u03b1) : B.filter = \u2a05 s : B.sets, \ud835\udcdf s :=\nbegin\n  have : directed (\u2265) (\u03bb (s : B.sets), \ud835\udcdf (s : set \u03b1)),\n  { rintros \u27e8U, U_in\u27e9 \u27e8V, V_in\u27e9,\n    rcases B.inter_sets U_in V_in with \u27e8W, W_in, W_sub\u27e9,\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 \u03b1) : 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 \u27e8V, V_in, h\u27e9,\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 : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1}\n\n/-- Constructs a filter from an indexed family of sets satisfying `is_basis`. -/\nprotected def filter (h : is_basis p s) : filter \u03b1 := h.filter_basis.filter\n\nprotected lemma mem_filter_iff (h : is_basis p s) {U : set \u03b1} :\n  U \u2208 h.filter \u2194 \u2203 i, p i \u2227 s i \u2286 U :=\nbegin\n  erw [h.filter_basis.mem_filter_iff],\n  simp only [mem_filter_basis_iff h, exists_prop],\n  split,\n  { rintros \u27e8_, \u27e8i, pi, rfl\u27e9, h\u27e9,\n    tauto },\n  { tauto }\nend\n\nlemma filter_eq_generate (h : is_basis p s) : h.filter = generate {U | \u2203 i, p i \u2227 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 : \u03b9 \u2192 set \u03b1` bounded by `p : \u03b9 \u2192 Prop`,\nif `t \u2208 l` if and only if `t` includes `s i` for some `i` such that `p i`. -/\nprotected structure has_basis (l : filter \u03b1) (p : \u03b9 \u2192 Prop) (s : \u03b9 \u2192 set \u03b1) : Prop :=\n(mem_iff' : \u2200 (t : set \u03b1), t \u2208 l \u2194 \u2203 i (hi : p i), s i \u2286 t)\n\nsection same_type\n\nvariables {l l' : filter \u03b1} {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1} {t : set \u03b1} {i : \u03b9}\n  {p' : \u03b9' \u2192 Prop} {s' : \u03b9' \u2192 set \u03b1} {i' : \u03b9'}\n\nlemma has_basis_generate (s : set (set \u03b1)) :\n  (generate s).has_basis (\u03bb t, set.finite t \u2227 t \u2286 s) (\u03bb t, \u22c2\u2080 t) :=\n\u27e8\u03bb U, by simp only [mem_generate_iff, exists_prop, and.assoc, and.left_comm]\u27e9\n\n/-- The smallest filter basis containing a given collection of sets. -/\ndef filter_basis.of_sets (s : set (set \u03b1)) : filter_basis \u03b1 :=\n{ sets := sInter '' { t | set.finite t \u2227 t \u2286 s},\n  nonempty := \u27e8univ, \u2205, \u27e8\u27e8finite_empty, empty_subset s\u27e9, sInter_empty\u27e9\u27e9,\n  inter_sets := begin\n    rintros _ _ \u27e8a, \u27e8fina, suba\u27e9, rfl\u27e9 \u27e8b, \u27e8finb, subb\u27e9, rfl\u27e9,\n    exact \u27e8\u22c2\u2080 (a \u222a b), mem_image_of_mem _ \u27e8fina.union finb, union_subset suba subb\u27e9,\n           by rw sInter_union\u27e9,\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 \u2208 l \u2194 \u2203 i (hi : p i), s i \u2286 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 \u2194 \u2200 t, t \u2208 l \u2194 \u2203 i (hi : p i), s i \u2286 t :=\n\u27e8\u03bb \u27e8h\u27e9, h, \u03bb h, \u27e8h\u27e9\u27e9\n\nlemma has_basis.ex_mem (h : l.has_basis p s) : \u2203 i, p i :=\nlet \u27e8i, pi, h\u27e9 := h.mem_iff.mp univ_mem in \u27e8i, pi\u27e9\n\nprotected lemma has_basis.nonempty (h : l.has_basis p s) : nonempty \u03b9 :=\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\u27e8\u03bb t, by simp only [h.mem_filter_iff, exists_prop]\u27e9\n\nlemma has_basis.mem_of_superset (hl : l.has_basis p s) (hi : p i) (ht : s i \u2286 t) : t \u2208 l :=\n(hl.mem_iff).2 \u27e8i, hi, ht\u27e9\n\nlemma has_basis.mem_of_mem (hl : l.has_basis p s) (hi : p i) : s i \u2208 l :=\nhl.mem_of_superset hi $ subset.refl _\n\n/-- Index of a basis set such that `s i \u2286 t` as an element of `subtype p`. -/\nnoncomputable def has_basis.index (h : l.has_basis p s) (t : set \u03b1) (ht : t \u2208 l) :\n  {i : \u03b9 // p i} :=\n\u27e8(h.mem_iff.1 ht).some, (h.mem_iff.1 ht).some_spec.fst\u27e9\n\nlemma has_basis.property_index (h : l.has_basis p s) (ht : t \u2208 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 \u2208 l) : s (h.index t ht) \u2208 l :=\nh.mem_of_mem $ h.property_index _\n\nlemma has_basis.set_index_subset (h : l.has_basis p s) (ht : t \u2208 l) : s (h.index t ht) \u2286 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 \u27e8i, hi, H\u27e9 := h.mem_iff.mp univ_mem in \u27e8i, hi\u27e9,\n  inter := \u03bb 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 | \u2203 i, p i \u2227 s i = U } :=\nby rw [\u2190 h.is_basis.filter_eq_generate, h.filter_eq]\n\nlemma generate_eq_generate_inter (s : set (set \u03b1)) :\n  generate s = generate (sInter '' { t | set.finite t \u2227 t \u2286 s}) :=\nby erw [(filter_basis.of_sets s).generate, \u2190 (has_basis_generate s).filter_eq] ; refl\n\nlemma of_sets_filter_eq_generate (s : set (set \u03b1)) : (filter_basis.of_sets s).filter = generate s :=\nby rw [\u2190 (filter_basis.of_sets s).generate, generate_eq_generate_inter s] ; refl\n\nprotected lemma _root_.filter_basis.has_basis {\u03b1 : Type*} (B : filter_basis \u03b1) :\n  has_basis (B.filter) (\u03bb s : set \u03b1, s \u2208 B) id :=\n\u27e8\u03bb t, B.mem_filter_iff\u27e9\n\nlemma has_basis.to_has_basis' (hl : l.has_basis p s) (h : \u2200 i, p i \u2192 \u2203 i', p' i' \u2227 s' i' \u2286 s i)\n  (h' : \u2200 i', p' i' \u2192 s' i' \u2208 l) : l.has_basis p' s' :=\nbegin\n  refine \u27e8\u03bb t, \u27e8\u03bb ht, _, \u03bb \u27e8i', hi', ht\u27e9, mem_of_superset (h' i' hi') ht\u27e9\u27e9,\n  rcases hl.mem_iff.1 ht with \u27e8i, hi, ht\u27e9,\n  rcases h i hi with \u27e8i', hi', hs's\u27e9,\n  exact \u27e8i', hi', subset.trans hs's ht\u27e9\nend\n\nlemma has_basis.to_has_basis (hl : l.has_basis p s) (h : \u2200 i, p i \u2192 \u2203 i', p' i' \u2227 s' i' \u2286 s i)\n  (h' : \u2200 i', p' i' \u2192 \u2203 i, p i \u2227 s i \u2286 s' i') : l.has_basis p' s' :=\nhl.to_has_basis' h $ \u03bb i' hi', let \u27e8i, hi, hss'\u27e9 := h' i' hi' in hl.mem_iff.2 \u27e8i, hi, hss'\u27e9\n\nlemma has_basis.to_subset (hl : l.has_basis p s) {t : \u03b9 \u2192 set \u03b1} (h : \u2200 i, p i \u2192 t i \u2286 s i)\n  (ht : \u2200 i, p i \u2192 t i \u2208 l) : l.has_basis p t :=\nhl.to_has_basis' (\u03bb i hi, \u27e8i, hi, h i hi\u27e9) ht\n\nlemma has_basis.eventually_iff (hl : l.has_basis p s) {q : \u03b1 \u2192 Prop} :\n  (\u2200\u1da0 x in l, q x) \u2194 \u2203 i, p i \u2227 \u2200 \u2983x\u2984, x \u2208 s i \u2192 q x :=\nby simpa using hl.mem_iff\n\nlemma has_basis.frequently_iff (hl : l.has_basis p s) {q : \u03b1 \u2192 Prop} :\n  (\u2203\u1da0 x in l, q x) \u2194 \u2200 i, p i \u2192 \u2203 x \u2208 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 \u03b1 \u2192 Prop}\n  (mono : \u2200 \u2983s t\u2984, s \u2286 t \u2192 P t \u2192 P s) :\n  (\u2203 s \u2208 l, P s) \u2194 \u2203 (i) (hi : p i), P (s i) :=\n\u27e8\u03bb \u27e8s, hs, hP\u27e9, let \u27e8i, hi, his\u27e9 := hl.mem_iff.1 hs in \u27e8i, hi, mono his hP\u27e9,\n  \u03bb \u27e8i, hi, hP\u27e9, \u27e8s i, hl.mem_of_mem hi, hP\u27e9\u27e9\n\nlemma has_basis.forall_iff (hl : l.has_basis p s) {P : set \u03b1 \u2192 Prop}\n  (mono : \u2200 \u2983s t\u2984, s \u2286 t \u2192 P s \u2192 P t) :\n  (\u2200 s \u2208 l, P s) \u2194 \u2200 i, p i \u2192 P (s i) :=\n\u27e8\u03bb H i hi, H (s i) $ hl.mem_of_mem hi,\n  \u03bb H s hs, let \u27e8i, hi, his\u27e9 := hl.mem_iff.1 hs in mono his (H i hi)\u27e9\n\nlemma has_basis.ne_bot_iff (hl : l.has_basis p s) :\n  ne_bot l \u2194 (\u2200 {i}, p i \u2192 (s i).nonempty) :=\nforall_mem_nonempty_iff_ne_bot.symm.trans $ hl.forall_iff $ \u03bb _ _, nonempty.mono\n\nlemma has_basis.eq_bot_iff (hl : l.has_basis p s) :\n  l = \u22a5 \u2194 \u2203 i, p i \u2227 s i = \u2205 :=\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 \u03b1)} :\n  ne_bot (generate s) \u2194 \u2200 t \u2286 s, t.finite \u2192 (\u22c2\u2080 t).nonempty :=\n(has_basis_generate s).ne_bot_iff.trans $ by simp only [\u2190 and_imp, and_comm]\n\nlemma basis_sets (l : filter \u03b1) : l.has_basis (\u03bb s : set \u03b1, s \u2208 l) id :=\n\u27e8\u03bb t, exists_mem_subset_iff.symm\u27e9\n\nlemma as_basis_filter (f : filter \u03b1) : f.as_basis.filter = f :=\nby ext t; exact exists_mem_subset_iff\n\nlemma has_basis_self {l : filter \u03b1} {P : set \u03b1 \u2192 Prop} :\n  has_basis l (\u03bb s, s \u2208 l \u2227 P s) id \u2194 \u2200 t \u2208 l, \u2203 r \u2208 l, P r \u2227 r \u2286 t :=\nbegin\n  simp only [has_basis_iff, exists_prop, id, and_assoc],\n  exact forall_congr (\u03bb s, \u27e8\u03bb h, h.1, \u03bb h, \u27e8h, \u03bb \u27e8t, hl, hP, hts\u27e9, mem_of_superset hl hts\u27e9\u27e9)\nend\n\nlemma has_basis.comp_surjective (h : l.has_basis p s) {g : \u03b9' \u2192 \u03b9} (hg : function.surjective g) :\n  l.has_basis (p \u2218 g) (s \u2218 g) :=\n\u27e8\u03bb t, h.mem_iff.trans hg.exists\u27e9\n\nlemma has_basis.comp_equiv (h : l.has_basis p s) (e : \u03b9' \u2243 \u03b9) : l.has_basis (p \u2218 e) (s \u2218 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 \u2227 q j`, then `{s j | p j \u2227 q j}` is a basis of `l`. -/\nlemma has_basis.restrict (h : l.has_basis p s) {q : \u03b9 \u2192 Prop}\n  (hq : \u2200 i, p i \u2192 \u2203 j, p j \u2227 q j \u2227 s j \u2286 s i) :\n  l.has_basis (\u03bb i, p i \u2227 q i) s :=\nbegin\n  refine \u27e8\u03bb t, \u27e8\u03bb ht, _, \u03bb \u27e8i, hpi, hti\u27e9, h.mem_iff.2 \u27e8i, hpi.1, hti\u27e9\u27e9\u27e9,\n  rcases h.mem_iff.1 ht with \u27e8i, hpi, hti\u27e9,\n  rcases hq i hpi with \u27e8j, hpj, hqj, hji\u27e9,\n  exact \u27e8j, \u27e8hpj, hqj\u27e9, subset.trans hji hti\u27e9\nend\n\n/-- If `{s i | p i}` is a basis of a filter `l` and `V \u2208 l`, then `{s i | p i \u2227 s i \u2286 V}`\nis a basis of `l`. -/\nlemma has_basis.restrict_subset (h : l.has_basis p s) {V : set \u03b1} (hV : V \u2208 l) :\n  l.has_basis (\u03bb i, p i \u2227 s i \u2286 V) s :=\nh.restrict $ \u03bb i hi, (h.mem_iff.1 (inter_mem hV (h.mem_of_mem hi))).imp $\n  \u03bb j hj, \u27e8hj.fst, subset_inter_iff.1 hj.snd\u27e9\n\nlemma has_basis.has_basis_self_subset {p : set \u03b1 \u2192 Prop} (h : l.has_basis (\u03bb s, s \u2208 l \u2227 p s) id)\n  {V : set \u03b1} (hV : V \u2208 l) : l.has_basis (\u03bb s, s \u2208 l \u2227 p s \u2227 s \u2286 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 \u2264 l' \u2194 \u2200 i', p' i' \u2192 s' i' \u2208 l :=\n\u27e8\u03bb h i' hi', h $ hl'.mem_of_mem hi',\n  \u03bb h s hs, let \u27e8i', hi', hs\u27e9 := hl'.mem_iff.1 hs in mem_of_superset (h _ hi') hs\u27e9\n\ntheorem has_basis.le_iff (hl : l.has_basis p s) : l \u2264 l' \u2194 \u2200 t \u2208 l', \u2203 i (hi : p i), s i \u2286 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 \u2264 l' \u2194 \u2200 i', p' i' \u2192 \u2203 i (hi : p i), s i \u2286 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 : \u2200 i, p i \u2192 \u2203 i', p' i' \u2227 s' i' \u2286 s i)\n  (h' : \u2200 i', p' i' \u2192 \u2203 i, p i \u2227 s i \u2286 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 \u2293 l').has_basis (\u03bb i : pprod \u03b9 \u03b9', p i.1 \u2227 p' i.2) (\u03bb i, s i.1 \u2229 s' i.2) :=\n\u27e8begin\n  intro t,\n  split,\n  { simp only [mem_inf_iff, exists_prop, hl.mem_iff, hl'.mem_iff],\n    rintros \u27e8t, \u27e8i, hi, ht\u27e9, t', \u27e8i', hi', ht'\u27e9, rfl\u27e9,\n    use [\u27e8i, i'\u27e9, \u27e8hi, hi'\u27e9, inter_subset_inter ht ht'] },\n  { rintros \u27e8\u27e8i, i'\u27e9, \u27e8hi, hi'\u27e9, H\u27e9,\n    exact mem_inf_of_inter (hl.mem_of_mem hi) (hl'.mem_of_mem hi') H }\nend\u27e9\n\nlemma has_basis.inf {\u03b9 \u03b9' : Type*} {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1} {p' : \u03b9' \u2192 Prop}\n  {s' : \u03b9' \u2192 set \u03b1} (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  (l \u2293 l').has_basis (\u03bb i : \u03b9 \u00d7 \u03b9', p i.1 \u2227 p' i.2) (\u03bb i, s i.1 \u2229 s' i.2) :=\n(hl.inf' hl').to_has_basis (\u03bb i hi, \u27e8\u27e8i.1, i.2\u27e9, hi, subset.rfl\u27e9)\n  (\u03bb i hi, \u27e8\u27e8i.1, i.2\u27e9, hi, subset.rfl\u27e9)\n\nlemma has_basis_infi' {\u03b9 : Type*} {\u03b9' : \u03b9 \u2192 Type*} {l : \u03b9 \u2192 filter \u03b1}\n  {p : \u03a0 i, \u03b9' i \u2192 Prop} {s : \u03a0 i, \u03b9' i \u2192 set \u03b1} (hl : \u2200 i, (l i).has_basis (p i) (s i)) :\n  (\u2a05 i, l i).has_basis (\u03bb If : set \u03b9 \u00d7 \u03a0 i, \u03b9' i, If.1.finite \u2227 \u2200 i \u2208 If.1, p i (If.2 i))\n    (\u03bb If : set \u03b9 \u00d7 \u03a0 i, \u03b9' i, \u22c2 i \u2208 If.1, s i (If.2 i)) :=\n\u27e8begin\n  intro t,\n  split,\n  { simp only [mem_infi', (hl _).mem_iff],\n    rintros \u27e8I, hI, V, hV, -, rfl, -\u27e9,\n    choose u hu using hV,\n    exact \u27e8\u27e8I, u\u27e9, \u27e8hI, \u03bb i _, (hu i).1\u27e9, Inter_mono (\u03bb i, Inter_mono $ \u03bb hi, (hu i).2)\u27e9 },\n  { rintros \u27e8\u27e8I, f\u27e9, \u27e8hI\u2081, hI\u2082\u27e9, hsub\u27e9,\n    refine mem_of_superset _ hsub,\n    exact (bInter_mem hI\u2081).mpr (\u03bb i hi, mem_infi_of_mem i $ (hl i).mem_of_mem $ hI\u2082 _ hi) }\nend\u27e9\n\nlemma has_basis_infi {\u03b9 : Type*} {\u03b9' : \u03b9 \u2192 Type*} {l : \u03b9 \u2192 filter \u03b1}\n  {p : \u03a0 i, \u03b9' i \u2192 Prop} {s : \u03a0 i, \u03b9' i \u2192 set \u03b1} (hl : \u2200 i, (l i).has_basis (p i) (s i)) :\n  (\u2a05 i, l i).has_basis (\u03bb If : \u03a3 I : set \u03b9, \u03a0 i : I, \u03b9' i, If.1.finite \u2227 \u2200 i : If.1, p i (If.2 i))\n    (\u03bb If, \u22c2 i : If.1, s i (If.2 i)) :=\nbegin\n  refine \u27e8\u03bb t, \u27e8\u03bb ht, _, _\u27e9\u27e9,\n  { rcases (has_basis_infi' hl).mem_iff.mp ht with \u27e8\u27e8I, f\u27e9, \u27e8hI, hf\u27e9, hsub\u27e9,\n    exact \u27e8\u27e8I, \u03bb i, f i\u27e9, \u27e8hI, subtype.forall.mpr hf\u27e9,\n      trans_rel_right _ (Inter_subtype _ _) hsub\u27e9 },\n  { rintro \u27e8\u27e8I, f\u27e9, \u27e8hI, hf\u27e9, hsub\u27e9,\n    refine mem_of_superset _ hsub,\n    casesI hI.nonempty_fintype,\n    exact Inter_mem.2 (\u03bb i, mem_infi_of_mem i $ (hl i).mem_of_mem $ hf _) }\nend\n\nlemma has_basis_infi_of_directed' {\u03b9 : Type*} {\u03b9' : \u03b9 \u2192 Sort*}\n  [nonempty \u03b9]\n  {l : \u03b9 \u2192 filter \u03b1} (s : \u03a0 i, (\u03b9' i) \u2192 set \u03b1) (p : \u03a0 i, (\u03b9' i) \u2192 Prop)\n  (hl : \u2200 i, (l i).has_basis (p i) (s i)) (h : directed (\u2265) l) :\n  (\u2a05 i, l i).has_basis (\u03bb (ii' : \u03a3 i, \u03b9' i), p ii'.1 ii'.2) (\u03bb ii', s ii'.1 ii'.2) :=\nbegin\n  refine \u27e8\u03bb t, _\u27e9,\n  rw [mem_infi_of_directed h, sigma.exists],\n  exact exists_congr (\u03bb i, (hl i).mem_iff)\nend\n\nlemma has_basis_infi_of_directed {\u03b9 : Type*} {\u03b9' : Sort*}\n  [nonempty \u03b9]\n  {l : \u03b9 \u2192 filter \u03b1} (s : \u03b9 \u2192 \u03b9' \u2192 set \u03b1) (p : \u03b9 \u2192 \u03b9' \u2192 Prop)\n  (hl : \u2200 i, (l i).has_basis (p i) (s i)) (h : directed (\u2265) l) :\n  (\u2a05 i, l i).has_basis (\u03bb (ii' : \u03b9 \u00d7 \u03b9'), p ii'.1 ii'.2) (\u03bb ii', s ii'.1 ii'.2) :=\nbegin\n  refine \u27e8\u03bb t, _\u27e9,\n  rw [mem_infi_of_directed h, prod.exists],\n  exact exists_congr (\u03bb i, (hl i).mem_iff)\nend\n\nlemma has_basis_binfi_of_directed' {\u03b9 : Type*} {\u03b9' : \u03b9 \u2192 Sort*}\n  {dom : set \u03b9} (hdom : dom.nonempty)\n  {l : \u03b9 \u2192 filter \u03b1} (s : \u03a0 i, (\u03b9' i) \u2192 set \u03b1) (p : \u03a0 i, (\u03b9' i) \u2192 Prop)\n  (hl : \u2200 i \u2208 dom, (l i).has_basis (p i) (s i)) (h : directed_on (l \u207b\u00b9'o ge) dom) :\n  (\u2a05 i \u2208 dom, l i).has_basis (\u03bb (ii' : \u03a3 i, \u03b9' i), ii'.1 \u2208 dom \u2227 p ii'.1 ii'.2)\n    (\u03bb ii', s ii'.1 ii'.2) :=\nbegin\n  refine \u27e8\u03bb t, _\u27e9,\n  rw [mem_binfi_of_directed h hdom, sigma.exists],\n  refine exists_congr (\u03bb i, \u27e8_, _\u27e9),\n  { rintros \u27e8hi, hti\u27e9,\n    rcases (hl i hi).mem_iff.mp hti with \u27e8b, hb, hbt\u27e9,\n    exact \u27e8b, \u27e8hi, hb\u27e9, hbt\u27e9 },\n  { rintros \u27e8b, \u27e8hi, hb\u27e9, hibt\u27e9,\n    exact \u27e8hi, (hl i hi).mem_iff.mpr \u27e8b, hb, hibt\u27e9\u27e9 }\nend\n\nlemma has_basis_binfi_of_directed {\u03b9 : Type*} {\u03b9' : Sort*}\n  {dom : set \u03b9} (hdom : dom.nonempty)\n  {l : \u03b9 \u2192 filter \u03b1} (s : \u03b9 \u2192 \u03b9' \u2192 set \u03b1) (p : \u03b9 \u2192 \u03b9' \u2192 Prop)\n  (hl : \u2200 i \u2208 dom, (l i).has_basis (p i) (s i)) (h : directed_on (l \u207b\u00b9'o ge) dom) :\n  (\u2a05 i \u2208 dom, l i).has_basis (\u03bb (ii' : \u03b9 \u00d7 \u03b9'), ii'.1 \u2208 dom \u2227 p ii'.1 ii'.2)\n    (\u03bb ii', s ii'.1 ii'.2) :=\nbegin\n  refine \u27e8\u03bb t, _\u27e9,\n  rw [mem_binfi_of_directed h hdom, prod.exists],\n  refine exists_congr (\u03bb i, \u27e8_, _\u27e9),\n  { rintros \u27e8hi, hti\u27e9,\n    rcases (hl i hi).mem_iff.mp hti with \u27e8b, hb, hbt\u27e9,\n    exact \u27e8b, \u27e8hi, hb\u27e9, hbt\u27e9 },\n  { rintros \u27e8b, \u27e8hi, hb\u27e9, hibt\u27e9,\n    exact \u27e8hi, (hl i hi).mem_iff.mpr \u27e8b, hb, hibt\u27e9\u27e9 }\nend\n\nlemma has_basis_principal (t : set \u03b1) : (\ud835\udcdf t).has_basis (\u03bb i : unit, true) (\u03bb i, t) :=\n\u27e8\u03bb U, by simp\u27e9\n\nlemma has_basis_pure (x : \u03b1) : (pure x : filter \u03b1).has_basis (\u03bb i : unit, true) (\u03bb i, {x}) :=\nby simp only [\u2190 principal_singleton, has_basis_principal]\n\nlemma has_basis.sup' (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  (l \u2294 l').has_basis (\u03bb i : pprod \u03b9 \u03b9', p i.1 \u2227 p' i.2) (\u03bb i, s i.1 \u222a s' i.2) :=\n\u27e8begin\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 [\u2190 and_assoc, exists_and_distrib_right, and_comm]\nend\u27e9\n\nlemma has_basis.sup {\u03b9 \u03b9' : Type*} {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1} {p' : \u03b9' \u2192 Prop}\n  {s' : \u03b9' \u2192 set \u03b1} (hl : l.has_basis p s) (hl' : l'.has_basis p' s') :\n  (l \u2294 l').has_basis (\u03bb i : \u03b9 \u00d7 \u03b9', p i.1 \u2227 p' i.2) (\u03bb i, s i.1 \u222a s' i.2) :=\n(hl.sup' hl').to_has_basis (\u03bb i hi, \u27e8\u27e8i.1, i.2\u27e9, hi, subset.rfl\u27e9)\n  (\u03bb i hi, \u27e8\u27e8i.1, i.2\u27e9, hi, subset.rfl\u27e9)\n\nlemma has_basis_supr {\u03b9 : Sort*} {\u03b9' : \u03b9 \u2192 Type*} {l : \u03b9 \u2192 filter \u03b1}\n  {p : \u03a0 i, \u03b9' i \u2192 Prop} {s : \u03a0 i, \u03b9' i \u2192 set \u03b1} (hl : \u2200 i, (l i).has_basis (p i) (s i)) :\n  (\u2a06 i, l i).has_basis (\u03bb f : \u03a0 i, \u03b9' i, \u2200 i, p i (f i)) (\u03bb f : \u03a0 i, \u03b9' i, \u22c3 i, s i (f i)) :=\nhas_basis_iff.mpr $ \u03bb 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 \u03b1) :\n  (l \u2294 \ud835\udcdf t).has_basis p (\u03bb i, s i \u222a t) :=\n\u27e8\u03bb u, by simp only [(hl.sup' (has_basis_principal t)).mem_iff, pprod.exists, exists_prop, and_true,\n  unique.exists_iff]\u27e9\n\nlemma has_basis.sup_pure (hl : l.has_basis p s) (x : \u03b1) :\n  (l \u2294 pure x).has_basis p (\u03bb i, s i \u222a {x}) :=\nby simp only [\u2190 principal_singleton, hl.sup_principal]\n\nlemma has_basis.inf_principal (hl : l.has_basis p s) (s' : set \u03b1) :\n  (l \u2293 \ud835\udcdf s').has_basis p (\u03bb i, s i \u2229 s') :=\n\u27e8\u03bb t, by simp only [mem_inf_principal, hl.mem_iff, subset_def, mem_set_of_eq,\n  mem_inter_iff, and_imp]\u27e9\n\nlemma has_basis.principal_inf (hl : l.has_basis p s) (s' : set \u03b1) :\n  (\ud835\udcdf s' \u2293 l).has_basis p (\u03bb i, s' \u2229 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 \u2293 l') \u2194 \u2200 \u2983i\u2984 (hi : p i) \u2983i'\u2984 (hi' : p' i'), (s i \u2229 s' i').nonempty :=\n(hl.inf' hl').ne_bot_iff.trans $ by simp [@forall_swap _ \u03b9']\n\nlemma has_basis.inf_ne_bot_iff (hl : l.has_basis p s) :\n  ne_bot (l \u2293 l') \u2194 \u2200 \u2983i\u2984 (hi : p i) \u2983s'\u2984 (hs' : s' \u2208 l'), (s i \u2229 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 \u03b1} :\n  ne_bot (l \u2293 \ud835\udcdf t) \u2194 \u2200 \u2983i\u2984 (hi : p i), (s i \u2229 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' \u2194 \u2203 i (hi : p i) i' (hi' : p' i'), disjoint (s i) (s' i') :=\nnot_iff_not.mp $ by simp only [disjoint_iff, \u2190 ne.def, \u2190 ne_bot_iff, hl.inf_basis_ne_bot_iff hl',\n  not_exists, bot_eq_empty, \u2190nonempty_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  \u2203 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 \u2192 filter \u03b1} {\u03b9 : I \u2192 Sort*} {p : \u03a0 i, \u03b9 i \u2192 Prop} {s : \u03a0 i, \u03b9 i \u2192 set \u03b1}\n  (hd : pairwise (disjoint on l)) (h : \u2200 i, (l i).has_basis (p i) (s i)) :\n  \u2203 ind : \u03a0 i, \u03b9 i, (\u2200 i, p i (ind i)) \u2227 pairwise (disjoint on \u03bb i, s i (ind i)) :=\nbegin\n  rcases hd.exists_mem_filter_of_disjoint with \u27e8t, htl, hd\u27e9,\n  choose ind hp ht using \u03bb i, (h i).mem_iff.1 (htl i),\n  exact \u27e8ind, hp, hd.mono $ \u03bb i j hij, hij.mono (ht _) (ht _)\u27e9\nend\n\nlemma _root_.set.pairwise_disjoint.exists_mem_filter_basis {I : Type*} {l : I \u2192 filter \u03b1}\n  {\u03b9 : I \u2192 Sort*} {p : \u03a0 i, \u03b9 i \u2192 Prop} {s : \u03a0 i, \u03b9 i \u2192 set \u03b1} {S : set I}\n  (hd : S.pairwise_disjoint l) (hS : S.finite) (h : \u2200 i, (l i).has_basis (p i) (s i)) :\n  \u2203 ind : \u03a0 i, \u03b9 i, (\u2200 i, p i (ind i)) \u2227 S.pairwise_disjoint (\u03bb i, s i (ind i)) :=\nbegin\n  rcases hd.exists_mem_filter hS with \u27e8t, htl, hd\u27e9,\n  choose ind hp ht using \u03bb i, (h i).mem_iff.1 (htl i),\n  exact \u27e8ind, hp, hd.mono ht\u27e9\nend\n\nlemma inf_ne_bot_iff :\n  ne_bot (l \u2293 l') \u2194 \u2200 \u2983s : set \u03b1\u2984 (hs : s \u2208 l) \u2983s'\u2984 (hs' : s' \u2208 l'), (s \u2229 s').nonempty :=\nl.basis_sets.inf_ne_bot_iff\n\nlemma inf_principal_ne_bot_iff {s : set \u03b1} :\n  ne_bot (l \u2293 \ud835\udcdf s) \u2194 \u2200 U \u2208 l, (U \u2229 s).nonempty :=\nl.basis_sets.inf_principal_ne_bot_iff\n\nlemma mem_iff_inf_principal_compl {f : filter \u03b1} {s : set \u03b1} :\n  s \u2208 f \u2194 f \u2293 \ud835\udcdf s\u1d9c = \u22a5 :=\nbegin\n  refine not_iff_not.1 ((inf_principal_ne_bot_iff.trans _).symm.trans ne_bot_iff),\n  exact \u27e8\u03bb h hs, by simpa [not_nonempty_empty] using h s hs,\n    \u03bb hs t ht, inter_compl_nonempty_iff.2 $ \u03bb hts, hs $ mem_of_superset ht hts\u27e9,\nend\n\nlemma not_mem_iff_inf_principal_compl {f : filter \u03b1} {s : set \u03b1} :\n  s \u2209 f \u2194 ne_bot (f \u2293 \ud835\udcdf s\u1d9c) :=\n(not_congr mem_iff_inf_principal_compl).trans ne_bot_iff.symm\n\n@[simp] lemma disjoint_principal_right {f : filter \u03b1} {s : set \u03b1} :\n  disjoint f (\ud835\udcdf s) \u2194 s\u1d9c \u2208 f :=\nby rw [mem_iff_inf_principal_compl, compl_compl, disjoint_iff]\n\n@[simp] lemma disjoint_principal_left {f : filter \u03b1} {s : set \u03b1} :\n  disjoint (\ud835\udcdf s) f \u2194 s\u1d9c \u2208 f :=\nby rw [disjoint.comm, disjoint_principal_right]\n\n@[simp] lemma disjoint_principal_principal {s t : set \u03b1} :\n  disjoint (\ud835\udcdf s) (\ud835\udcdf t) \u2194 disjoint s t :=\nby simp [\u2190subset_compl_iff_disjoint_left]\n\nalias disjoint_principal_principal \u2194 _ _root_.disjoint.filter_principal\n\n@[simp] lemma disjoint_pure_pure {x y : \u03b1} :\n  disjoint (pure x : filter \u03b1) (pure y) \u2194 x \u2260 y :=\nby simp only [\u2190 principal_singleton, disjoint_principal_principal, disjoint_singleton]\n\n@[simp] lemma compl_diagonal_mem_prod {l\u2081 l\u2082 : filter \u03b1} :\n  (diagonal \u03b1)\u1d9c \u2208 l\u2081 \u00d7\u1da0 l\u2082 \u2194 disjoint l\u2081 l\u2082 :=\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' \u2194 \u2203 i (hi : p i), (s i)\u1d9c \u2208 l' :=\nby simp only [h.disjoint_iff l'.basis_sets, exists_prop, id, \u2190 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 \u2194 \u2203 i (hi : p i), (s i)\u1d9c \u2208 l' :=\ndisjoint.comm.trans h.disjoint_iff_left\n\nlemma le_iff_forall_inf_principal_compl {f g : filter \u03b1} :\n  f \u2264 g \u2194 \u2200 V \u2208 g, f \u2293 \ud835\udcdf V\u1d9c = \u22a5 :=\nforall\u2082_congr $ \u03bb _ _, mem_iff_inf_principal_compl\n\nlemma inf_ne_bot_iff_frequently_left {f g : filter \u03b1} :\n  ne_bot (f \u2293 g) \u2194 \u2200 {p : \u03b1 \u2192 Prop}, (\u2200\u1da0 x in f, p x) \u2192 \u2203\u1da0 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 \u03b1} :\n  ne_bot (f \u2293 g) \u2194 \u2200 {p : \u03b1 \u2192 Prop}, (\u2200\u1da0 x in g, p x) \u2192 \u2203\u1da0 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 = \u2a05 i (_ : p i), \ud835\udcdf (s i) :=\neq_binfi_of_mem_iff_exists_mem $ \u03bb t, by simp only [h.mem_iff, mem_principal]\n\nlemma has_basis.eq_infi (h : l.has_basis (\u03bb _, true) s) :\n  l = \u2a05 i, \ud835\udcdf (s i) :=\nby simpa only [infi_true] using h.eq_binfi\n\nlemma has_basis_infi_principal {s : \u03b9 \u2192 set \u03b1} (h : directed (\u2265) s) [nonempty \u03b9] :\n  (\u2a05 i, \ud835\udcdf (s i)).has_basis (\u03bb _, true) s :=\n\u27e8begin\n  refine \u03bb t, (mem_infi_of_directed (h.mono_comp _ _) t).trans $\n    by simp only [exists_prop, true_and, mem_principal],\n  exact \u03bb _ _, principal_mono.2\nend\u27e9\n\n/-- If `s : \u03b9 \u2192 set \u03b1` is an indexed family of sets, then finite intersections of `s i` form a basis\nof `\u2a05 i, \ud835\udcdf (s i)`.  -/\nlemma has_basis_infi_principal_finite {\u03b9 : Type*} (s : \u03b9 \u2192 set \u03b1) :\n  (\u2a05 i, \ud835\udcdf (s i)).has_basis (\u03bb t : set \u03b9, t.finite) (\u03bb t, \u22c2 i \u2208 t, s i) :=\nbegin\n  refine \u27e8\u03bb U, (mem_infi_finite _).trans _\u27e9,\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 : \u03b2 \u2192 set \u03b1} {S : set \u03b2} (h : directed_on (s \u207b\u00b9'o (\u2265)) S)\n  (ne : S.nonempty) :\n  (\u2a05 i \u2208 S, \ud835\udcdf (s i)).has_basis (\u03bb i, i \u2208 S) s :=\n\u27e8begin\n  refine \u03bb t, (mem_binfi_of_directed _ ne).trans $ by simp only [mem_principal],\n  rw [directed_on_iff_directed, \u2190 directed_comp, (\u2218)] at h \u22a2,\n  apply h.mono_comp _ _,\n  exact \u03bb _ _, principal_mono.2\nend\u27e9\n\nlemma has_basis_binfi_principal' {\u03b9 : Type*} {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1}\n  (h : \u2200 i, p i \u2192 \u2200 j, p j \u2192 \u2203 k (h : p k), s k \u2286 s i \u2227 s k \u2286 s j) (ne : \u2203 i, p i) :\n  (\u2a05 i (h : p i), \ud835\udcdf (s i)).has_basis p s :=\nfilter.has_basis_binfi_principal h ne\n\nlemma has_basis.map (f : \u03b1 \u2192 \u03b2) (hl : l.has_basis p s) :\n  (l.map f).has_basis p (\u03bb i, f '' (s i)) :=\n\u27e8\u03bb t, by simp only [mem_map, image_subset_iff, hl.mem_iff, preimage]\u27e9\n\nlemma has_basis.comap (f : \u03b2 \u2192 \u03b1) (hl : l.has_basis p s) :\n  (l.comap f).has_basis p (\u03bb i, f \u207b\u00b9' (s i)) :=\n\u27e8begin\n  intro t,\n  simp only [mem_comap, exists_prop, hl.mem_iff],\n  split,\n  { rintros \u27e8t', \u27e8i, hi, ht'\u27e9, H\u27e9,\n    exact \u27e8i, hi, subset.trans (preimage_mono ht') H\u27e9 },\n  { rintros \u27e8i, hi, H\u27e9,\n    exact \u27e8s i, \u27e8i, hi, subset.refl _\u27e9, H\u27e9 }\nend\u27e9\n\nlemma comap_has_basis (f : \u03b1 \u2192 \u03b2) (l : filter \u03b2) :\n  has_basis (comap f l) (\u03bb s : set \u03b2, s \u2208 l) (\u03bb s, f \u207b\u00b9' s) :=\n\u27e8\u03bb t, mem_comap\u27e9\n\n\n\nprotected lemma has_basis.binfi_mem [complete_lattice \u03b2] {f : set \u03b1 \u2192 \u03b2} (h : has_basis l p s)\n  (hf : monotone f) :\n  (\u2a05 t \u2208 l, f t) = \u2a05 i (hi : p i), f (s i) :=\nle_antisymm (le_infi\u2082 $ \u03bb i hi, infi\u2082_le (s i) (h.mem_of_mem hi)) $\n  le_infi\u2082 $ \u03bb t ht, let \u27e8i, hpi, hi\u27e9 := h.mem_iff.1 ht in infi\u2082_le_of_le i hpi (hf hi)\n\nprotected lemma has_basis.bInter_mem {f : set \u03b1 \u2192 set \u03b2} (h : has_basis l p s) (hf : monotone f) :\n  (\u22c2 t \u2208 l, f t) = \u22c2 i (hi : p i), f (s i) :=\nh.binfi_mem hf\n\nlemma has_basis.sInter_sets (h : has_basis l p s) : \u22c2\u2080 l.sets = \u22c2 i (hi : p i), s i :=\nby { rw [sInter_eq_bInter], exact h.bInter_mem monotone_id }\n\nvariables {\u03b9'' : Type*} [preorder \u03b9''] (l) (s'' : \u03b9'' \u2192 set \u03b1)\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 (\u03bb _, true) s'' : Prop :=\n(antitone : antitone s'')\n\n/-- We say that a filter `l` has an antitone basis `s : \u03b9 \u2192 set \u03b1`, if `t \u2208 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 \u03b1) (s : \u03b9'' \u2192 set \u03b1)\n  extends has_basis l (\u03bb _, true) s : Prop :=\n(antitone : antitone s)\n\nlemma has_antitone_basis.map {l : filter \u03b1} {s : \u03b9'' \u2192 set \u03b1} {m : \u03b1 \u2192 \u03b2}\n  (hf : has_antitone_basis l s) :\n  has_antitone_basis (map m l) (\u03bb n, m '' s n) :=\n\u27e8has_basis.map _ hf.to_has_basis, \u03bb i j hij, image_subset _ $ hf.2 hij\u27e9\n\nend same_type\n\nsection two_types\n\nvariables {la : filter \u03b1} {pa : \u03b9 \u2192 Prop} {sa : \u03b9 \u2192 set \u03b1}\n  {lb : filter \u03b2} {pb : \u03b9' \u2192 Prop} {sb : \u03b9' \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2}\n\nlemma has_basis.tendsto_left_iff (hla : la.has_basis pa sa) :\n  tendsto f la lb \u2194 \u2200 t \u2208 lb, \u2203 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 \u2194 \u2200 i (hi : pb i), \u2200\u1da0 x in la, f x \u2208 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 \u2194 \u2200 ib (hib : pb ib), \u2203 ia (hia : pa ia), \u2200 x \u2208 sa ia, f x \u2208 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  \u2200 t \u2208 lb, \u2203 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  \u2200 i (hi : pb i), \u2200\u1da0 x in la, f x \u2208 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  \u2200 ib (hib : pb ib), \u2203 ia (hia : pa ia), \u2200 x \u2208 sa ia, f x \u2208 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 \u00d7\u1da0 lb).has_basis (\u03bb i : pprod \u03b9 \u03b9', pa i.1 \u2227 pb i.2) (\u03bb i, sa i.1 \u00d7\u02e2 sb i.2) :=\n(hla.comap prod.fst).inf' (hlb.comap prod.snd)\n\nlemma has_basis.prod {\u03b9 \u03b9' : Type*} {pa : \u03b9 \u2192 Prop} {sa : \u03b9 \u2192 set \u03b1} {pb : \u03b9' \u2192 Prop}\n  {sb : \u03b9' \u2192 set \u03b2} (hla : la.has_basis pa sa) (hlb : lb.has_basis pb sb) :\n  (la \u00d7\u1da0 lb).has_basis (\u03bb i : \u03b9 \u00d7 \u03b9', pa i.1 \u2227 pb i.2) (\u03bb i, sa i.1 \u00d7\u02e2 sb i.2) :=\n(hla.comap prod.fst).inf (hlb.comap prod.snd)\n\nlemma has_basis.prod_same_index {p : \u03b9 \u2192 Prop} {sb : \u03b9 \u2192 set \u03b2}\n  (hla : la.has_basis p sa) (hlb : lb.has_basis p sb)\n  (h_dir : \u2200 {i j}, p i \u2192 p j \u2192 \u2203 k, p k \u2227 sa k \u2286 sa i \u2227 sb k \u2286 sb j) :\n  (la \u00d7\u1da0 lb).has_basis p (\u03bb i, sa i \u00d7\u02e2 sb i) :=\nbegin\n  simp only [has_basis_iff, (hla.prod_pprod hlb).mem_iff],\n  refine \u03bb t, \u27e8_, _\u27e9,\n  { rintros \u27e8\u27e8i, j\u27e9, \u27e8hi, hj\u27e9, hsub : sa i \u00d7\u02e2 sb j \u2286 t\u27e9,\n    rcases h_dir hi hj with \u27e8k, hk, ki, kj\u27e9,\n    exact \u27e8k, hk, (set.prod_mono ki kj).trans hsub\u27e9 },\n  { rintro \u27e8i, hi, h\u27e9,\n    exact \u27e8\u27e8i, i\u27e9, \u27e8hi, hi\u27e9, h\u27e9 },\nend\n\nlemma has_basis.prod_same_index_mono {\u03b9 : Type*} [linear_order \u03b9]\n  {p : \u03b9 \u2192 Prop} {sa : \u03b9 \u2192 set \u03b1} {sb : \u03b9 \u2192 set \u03b2}\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 \u00d7\u1da0 lb).has_basis p (\u03bb i, sa i \u00d7\u02e2 sb i) :=\nhla.prod_same_index hlb $ \u03bb i j hi hj,\n  have p (min i j), from min_rec' _ hi hj,\n  \u27e8min i j, this, hsa this hi $ min_le_left _ _, hsb this hj $ min_le_right _ _\u27e9\n\nlemma has_basis.prod_same_index_anti {\u03b9 : Type*} [linear_order \u03b9]\n  {p : \u03b9 \u2192 Prop} {sa : \u03b9 \u2192 set \u03b1} {sb : \u03b9 \u2192 set \u03b2}\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 \u00d7\u1da0 lb).has_basis p (\u03bb i, sa i \u00d7\u02e2 sb i) :=\n@has_basis.prod_same_index_mono _ _ _ _ \u03b9\u1d52\u1d48 _ _ _ _  hla hlb hsa.dual_left hsb.dual_left\n\nlemma has_basis.prod_self (hl : la.has_basis pa sa) :\n  (la \u00d7\u1da0 la).has_basis pa (\u03bb i, sa i \u00d7\u02e2 sa i) :=\nhl.prod_same_index hl $ \u03bb 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 \u2208 la \u00d7\u1da0 la \u2194 \u2203 t \u2208 la, t \u00d7\u02e2 t \u2286 s :=\nla.basis_sets.prod_self.mem_iff\n\nlemma has_antitone_basis.prod {\u03b9 : Type*} [linear_order \u03b9] {f : filter \u03b1} {g : filter \u03b2}\n  {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b2} (hf : has_antitone_basis f s) (hg : has_antitone_basis g t) :\n  has_antitone_basis (f \u00d7\u1da0 g) (\u03bb n, s n \u00d7\u02e2 t n) :=\n\u27e8hf.1.prod_same_index_anti hg.1 (hf.2.antitone_on _) (hg.2.antitone_on _), hf.2.set_prod hg.2\u27e9\n\nlemma has_basis.coprod {\u03b9 \u03b9' : Type*} {pa : \u03b9 \u2192 Prop} {sa : \u03b9 \u2192 set \u03b1} {pb : \u03b9' \u2192 Prop}\n  {sb : \u03b9' \u2192 set \u03b2} (hla : la.has_basis pa sa) (hlb : lb.has_basis pb sb) :\n  (la.coprod lb).has_basis (\u03bb i : \u03b9 \u00d7 \u03b9', pa i.1 \u2227 pb i.2)\n    (\u03bb i, prod.fst \u207b\u00b9' sa i.1 \u222a prod.snd \u207b\u00b9' sb i.2) :=\n(hla.comap prod.fst).sup (hlb.comap prod.snd)\n\nend two_types\n\nlemma map_sigma_mk_comap {\u03c0 : \u03b1 \u2192 Type*} {\u03c0' : \u03b2 \u2192 Type*} {f : \u03b1 \u2192 \u03b2}\n  (hf : function.injective f) (g : \u03a0 a, \u03c0 a \u2192 \u03c0' (f a)) (a : \u03b1) (l : filter (\u03c0' (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 {\u03b1 \u03b2 \u03b3 \u03b9 : Type*} {\u03b9' : Sort*}\n\n/-- `is_countably_generated f` means `f = generate s` for some countable `s`. -/\nclass is_countably_generated (f : filter \u03b1) : Prop :=\n(out [] : \u2203 s : set (set \u03b1), s.countable \u2227 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 : \u03b9 \u2192 Prop) (s : \u03b9 \u2192 set \u03b1) 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 : \u03b9 \u2192 set \u03b1` bounded by `p : \u03b9 \u2192 Prop`,\nif `t \u2208 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 \u03b1) (p : \u03b9 \u2192 Prop) (s : \u03b9 \u2192 set \u03b1)\n  extends has_basis l p s : Prop :=\n(countable : (set_of p).countable)\n\n/-- A countable filter basis `B` on a type `\u03b1` is a nonempty countable collection of sets of `\u03b1`\nsuch that the intersection of two elements of this collection contains some element\nof the collection. -/\nstructure countable_filter_basis (\u03b1 : Type*) extends filter_basis \u03b1 :=\n(countable : sets.countable)\n\n-- For illustration purposes, the countable filter basis defining (at_top : filter \u2115)\ninstance nat.inhabited_countable_filter_basis : inhabited (countable_filter_basis \u2115) :=\n\u27e8{ countable := countable_range (\u03bb n, Ici n),\n   ..(default : filter_basis \u2115) }\u27e9\n\nlemma has_countable_basis.is_countably_generated {f : filter \u03b1} {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1}\n  (h : f.has_countable_basis p s) :\n  f.is_countably_generated :=\n\u27e8\u27e8{t | \u2203 i, p i \u2227 s i = t}, h.countable.image s, h.to_has_basis.eq_generate\u27e9\u27e9\n\nlemma antitone_seq_of_seq (s : \u2115 \u2192 set \u03b1) :\n  \u2203 t : \u2115 \u2192 set \u03b1, antitone t \u2227 (\u2a05 i, \ud835\udcdf $ s i) = \u2a05 i, \ud835\udcdf (t i) :=\nbegin\n  use \u03bb n, \u22c2 m \u2264 n, s m, split,\n  { exact \u03bb i j hij, bInter_mono (Iic_subset_Iic.2 hij) (\u03bb 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 (\u03bb j hji, _),\n    rw \u2190 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 \u03b1] {B : set \u03b9} (Bcbl : B.countable)\n  (Bne : B.nonempty) (f : \u03b9 \u2192 \u03b1) :\n  \u2203 (x : \u2115 \u2192 \u03b9), (\u2a05 t \u2208 B, f t) = \u2a05 i, f (x i) :=\nlet \u27e8g, hg\u27e9 := Bcbl.exists_eq_range Bne in \u27e8g, hg.symm \u25b8 infi_range\u27e9\n\nlemma countable_binfi_eq_infi_seq' [complete_lattice \u03b1] {B : set \u03b9} (Bcbl : B.countable) (f : \u03b9 \u2192 \u03b1)\n  {i\u2080 : \u03b9} (h : f i\u2080 = \u22a4) :\n  \u2203 (x : \u2115 \u2192 \u03b9), (\u2a05 t \u2208 B, f t) = \u2a05 i, f (x i) :=\nbegin\n  cases B.eq_empty_or_nonempty with hB Bnonempty,\n  { rw [hB, infi_emptyset],\n    use \u03bb n, i\u2080,\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 \u03b1)} (Bcbl : B.countable) :\n  \u2203 (x : \u2115 \u2192 set \u03b1), (\u2a05 t \u2208 B, \ud835\udcdf t) = \u2a05 i, \ud835\udcdf (x i) :=\ncountable_binfi_eq_infi_seq' Bcbl \ud835\udcdf principal_univ\n\nsection is_countably_generated\n\nprotected lemma has_antitone_basis.mem_iff [preorder \u03b9] {l : filter \u03b1} {s : \u03b9 \u2192 set \u03b1}\n  (hs : l.has_antitone_basis s) {t : set \u03b1} : t \u2208 l \u2194 \u2203 i, s i \u2286 t :=\nhs.to_has_basis.mem_iff.trans $ by simp only [exists_prop, true_and]\n\nprotected lemma has_antitone_basis.mem [preorder \u03b9] {l : filter \u03b1} {s : \u03b9 \u2192 set \u03b1}\n  (hs : l.has_antitone_basis s) (i : \u03b9) : s i \u2208 l :=\nhs.to_has_basis.mem_of_mem trivial\n\nlemma has_antitone_basis.has_basis_ge [preorder \u03b9] [is_directed \u03b9 (\u2264)] {l : filter \u03b1}\n  {s : \u03b9 \u2192 set \u03b1} (hs : l.has_antitone_basis s) (i : \u03b9) :\n  l.has_basis (\u03bb j, i \u2264 j) s :=\nhs.1.to_has_basis (\u03bb j _, (exists_ge_ge i j).imp $ \u03bb k hk, \u27e8hk.1, hs.2 hk.2\u27e9)\n  (\u03bb j hj, \u27e8j, trivial, subset.rfl\u27e9)\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 \u03b1} [h : f.is_countably_generated]\n  {p : \u03b9' \u2192 Prop} {s : \u03b9' \u2192 set \u03b1} (hs : f.has_basis p s) :\n  \u2203 x : \u2115 \u2192 \u03b9', (\u2200 i, p (x i)) \u2227 f.has_antitone_basis (\u03bb i, s (x i)) :=\nbegin\n  obtain \u27e8x', hx'\u27e9 : \u2203 x : \u2115 \u2192 set \u03b1, f = \u2a05 i, \ud835\udcdf (x i),\n  { unfreezingI { rcases h with \u27e8s, hsc, rfl\u27e9 },\n    rw generate_eq_binfi,\n    exact countable_binfi_principal_eq_seq_infi hsc },\n  have : \u2200 i, x' i \u2208 f := \u03bb i, hx'.symm \u25b8 (infi_le (\u03bb i, \ud835\udcdf (x' i)) i) (mem_principal_self _),\n  let x : \u2115 \u2192 {i : \u03b9' // p i} := \u03bb n, nat.rec_on n (hs.index _ $ this 0)\n    (\u03bb n xn, (hs.index _ $ inter_mem (this $ n + 1) (hs.mem_of_mem xn.2))),\n  have x_mono : antitone (\u03bb i, s (x i)),\n  { refine antitone_nat_of_succ_le (\u03bb i, _),\n    exact (hs.set_index_subset _).trans (inter_subset_right _ _) },\n  have x_subset : \u2200 i, s (x i) \u2286 x' i,\n  { rintro (_|i),\n    exacts [hs.set_index_subset _, subset.trans (hs.set_index_subset _) (inter_subset_left _ _)] },\n  refine \u27e8\u03bb i, x i, \u03bb i, (x i).2, _\u27e9,\n  have : (\u2a05 i, \ud835\udcdf (s (x i))).has_antitone_basis (\u03bb i, s (x i)) :=\n    \u27e8has_basis_infi_principal (directed_of_sup x_mono), x_mono\u27e9,\n  convert this,\n  exact le_antisymm (le_infi $ \u03bb i, le_principal_iff.2 $ by cases i; apply hs.set_index_mem)\n    (hx'.symm \u25b8 le_infi (\u03bb i, le_principal_iff.2 $\n      this.to_has_basis.mem_iff.2 \u27e8i, trivial, x_subset i\u27e9))\nend\n\n/-- A countably generated filter admits a basis formed by an antitone sequence of sets. -/\nlemma exists_antitone_basis (f : filter \u03b1) [f.is_countably_generated] :\n  \u2203 x : \u2115 \u2192 set \u03b1, f.has_antitone_basis x :=\nlet \u27e8x, hxf, hx\u27e9 := f.basis_sets.exists_antitone_subbasis in \u27e8x, hx\u27e9\n\nlemma exists_antitone_seq (f : filter \u03b1) [f.is_countably_generated] :\n  \u2203 x : \u2115 \u2192 set \u03b1, antitone x \u2227 \u2200 {s}, (s \u2208 f \u2194 \u2203 i, x i \u2286 s) :=\nlet \u27e8x, hx\u27e9 := f.exists_antitone_basis in\n\u27e8x, hx.antitone, \u03bb s, by simp [hx.to_has_basis.mem_iff]\u27e9\n\ninstance inf.is_countably_generated (f g : filter \u03b1) [is_countably_generated f]\n  [is_countably_generated g] :\n  is_countably_generated (f \u2293 g) :=\nbegin\n  rcases f.exists_antitone_basis with \u27e8s, hs\u27e9,\n  rcases g.exists_antitone_basis with \u27e8t, ht\u27e9,\n  exact has_countable_basis.is_countably_generated\n    \u27e8hs.to_has_basis.inf ht.to_has_basis, set.to_countable _\u27e9\nend\n\ninstance map.is_countably_generated (l : filter \u03b1) [l.is_countably_generated] (f : \u03b1 \u2192 \u03b2) :\n  (map f l).is_countably_generated :=\nlet \u27e8x, hxl\u27e9 := l.exists_antitone_basis in\nhas_countable_basis.is_countably_generated \u27e8hxl.map.to_has_basis, to_countable _\u27e9\n\ninstance comap.is_countably_generated (l : filter \u03b2) [l.is_countably_generated] (f : \u03b1 \u2192 \u03b2) :\n  (comap f l).is_countably_generated :=\nlet \u27e8x, hxl\u27e9 := l.exists_antitone_basis in\nhas_countable_basis.is_countably_generated \u27e8hxl.to_has_basis.comap _, to_countable _\u27e9\n\ninstance sup.is_countably_generated (f g : filter \u03b1) [is_countably_generated f]\n  [is_countably_generated g] :\n  is_countably_generated (f \u2294 g) :=\nbegin\n  rcases f.exists_antitone_basis with \u27e8s, hs\u27e9,\n  rcases g.exists_antitone_basis with \u27e8t, ht\u27e9,\n  exact has_countable_basis.is_countably_generated\n    \u27e8hs.to_has_basis.sup ht.to_has_basis, set.to_countable _\u27e9\nend\n\ninstance prod.is_countably_generated (la : filter \u03b1) (lb : filter \u03b2) [is_countably_generated la]\n  [is_countably_generated lb] : is_countably_generated (la \u00d7\u1da0 lb) :=\nfilter.inf.is_countably_generated _ _\n\ninstance coprod.is_countably_generated (la : filter \u03b1) (lb : filter \u03b2) [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 \u03b2] (x : \u03b2 \u2192 set \u03b1) :\n  is_countably_generated (\u2a05 i, \ud835\udcdf $ 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 \u03b1} (h : \u2203 x : \u2115 \u2192 set \u03b1, f = \u2a05 i, \ud835\udcdf $ x i) :\n  f.is_countably_generated  :=\nlet \u27e8x, h\u27e9 := h in by rw h ; apply is_countably_generated_seq\n\nlemma is_countably_generated_binfi_principal {B : set $ set \u03b1} (h : B.countable) :\n  is_countably_generated (\u2a05 (s \u2208 B), \ud835\udcdf s) :=\nis_countably_generated_of_seq (countable_binfi_principal_eq_seq_infi h)\n\nlemma is_countably_generated_iff_exists_antitone_basis {f : filter \u03b1} :\n  is_countably_generated f \u2194 \u2203 x : \u2115 \u2192 set \u03b1, f.has_antitone_basis x :=\nbegin\n  split,\n  { introI h, exact f.exists_antitone_basis },\n  { rintros \u27e8x, h\u27e9,\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 \u03b1) : is_countably_generated (\ud835\udcdf s) :=\nis_countably_generated_of_seq \u27e8\u03bb _, s, infi_const.symm\u27e9\n\n@[instance] lemma is_countably_generated_pure (a : \u03b1) : is_countably_generated (pure a) :=\nby { rw \u2190 principal_singleton, exact is_countably_generated_principal _, }\n\n@[instance] lemma is_countably_generated_bot : is_countably_generated (\u22a5 : filter \u03b1) :=\n@principal_empty \u03b1 \u25b8 is_countably_generated_principal _\n\n@[instance] lemma is_countably_generated_top : is_countably_generated (\u22a4 : filter \u03b1) :=\n@principal_univ \u03b1 \u25b8 is_countably_generated_principal _\n\ninstance infi.is_countably_generated {\u03b9 : Sort*} [countable \u03b9] (f : \u03b9 \u2192 filter \u03b1)\n  [\u2200 i, is_countably_generated (f i)] : is_countably_generated (\u2a05 i, f i) :=\nbegin\n  choose s hs using \u03bb i, exists_antitone_basis (f i),\n  rw [\u2190 plift.down_surjective.infi_comp],\n  refine has_countable_basis.is_countably_generated\n    \u27e8has_basis_infi (\u03bb n, (hs _).to_has_basis), _\u27e9,\n  refine (countable_range $ sigma.map (coe : finset (plift \u03b9) \u2192 set (plift \u03b9)) (\u03bb _, id)).mono _,\n  rintro \u27e8I, f\u27e9 \u27e8hI, -\u27e9,\n  lift I to finset (plift \u03b9) using hI,\n  exact \u27e8\u27e8I, f\u27e9, rfl\u27e9\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} [\ud835\udc9e : category.{v} C] [has_binary_products.{v} C] {A U V W X Y Z : C}\ninclude \ud835\udc9e\n\nlocal attribute [tidy] tactic.case_bash\n\ndef prodinl (X : C) : C \u2964 C := prod_functor.obj X\n\n@[simp] lemma prodinl_map_def {f : Y \u27f6 Z} : (prodinl X).map f = limits.prod.map (\ud835\udfd9 X) f := rfl\n@[simp] lemma map_fst {f : U \u27f6 V} {g : W \u27f6 X} : limits.prod.map f g \u226b limits.prod.fst = limits.prod.fst \u226b f := by simp\n@[simp] lemma map_snd {f : U \u27f6 V} {g : W \u27f6 X} : limits.prod.map f g \u226b limits.prod.snd = limits.prod.snd \u226b g := by simp\n@[simp] lemma prod.map_id : limits.prod.map (\ud835\udfd9 X) (\ud835\udfd9 Y) = \ud835\udfd9 (X\u2a2fY) := begin apply prod.hom_ext, simp, simp end\n@[simp] lemma lift_fst {f : W \u27f6 X} {g : W \u27f6 Y} : limits.prod.lift f g \u226b limits.prod.fst = f := by simp\n@[simp] lemma lift_snd {f : W \u27f6 X} {g : W \u27f6 Y} : limits.prod.lift f g \u226b limits.prod.snd = g := by simp\nopen category\n\ndef prodinl_comp (X Y : C) : prodinl (X \u2a2f Y) \u2245 prodinl Y \u22d9 prodinl X :=\nnat_iso.of_components (limits.prod.associator _ _) (by tidy)\n\nend\n\nclass exponentiable {C : Type u} [\ud835\udc9e : category.{v} C] [bp : @has_binary_products C \ud835\udc9e] (X : C) :=\n(exponentiable : is_left_adjoint (prodinl X))\n\ndef binary_product_exponentiable {C : Type u} [\ud835\udc9e : category.{v} C] [bp : @has_binary_products C \ud835\udc9e] {X Y : C}\n  (hX : exponentiable X) (hY : exponentiable Y) : exponentiable (X \u2a2f Y) :=\n{ exponentiable :=\n  { right := hX.exponentiable.right \u22d9 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) [\ud835\udc9e : category.{v} C] [has_binary_products.{v} C] extends has_terminal.{v} C :=\n(cart_closed : \u03a0 (X : C), exponentiable X)\n\ninstance exponentiable_of_cc {C : Type u} [\ud835\udc9e : category.{v} C] [@has_binary_products C \ud835\udc9e] [is_cartesian_closed C] {A : C} :\n  exponentiable A := is_cartesian_closed.cart_closed A\n\nvariables {C : Type u} [\ud835\udc9e : category.{v} C] [has_binary_products.{v} C] {X X' Y Y' Z A B : C} [exponentiable A]\ninclude \ud835\udc9e\n\n/-- This is (-)^A -/\ndef exp.functor (A : C) [exponentiable A] : C \u2964 C :=\n(exponentiable.exponentiable A).right\n\ndef exp.adjunction : prodinl A \u22a3 exp.functor A :=\n(exponentiable.exponentiable A).adj\n\ndef ev.nat_trans (A : C) [exponentiable A] : exp.functor A \u22d9 prodinl A \u27f6 \ud835\udfed C :=\nexp.adjunction.counit\n\ndef coev.nat_trans (A : C) [exponentiable A] : \ud835\udfed C \u27f6 prodinl A \u22d9 exp.functor A :=\nexp.adjunction.unit\n\n/-- `B ^ A` or `A \u27f9 B` -/\ndef exp (A : C) (B : C) [exponentiable A] : C := (exp.functor A).obj B\n\ninfixl `\u27f9`:20 := exp\n\n-- [todo] rename as 'post compose' or similar?\ndef post (A : C) [exponentiable A] {X Y : C} (f : X \u27f6 Y) : A\u27f9X \u27f6 A\u27f9Y :=\n(exp.functor A).map f\n\nlemma post.map_comp {f : X \u27f6 Y} {g : Y \u27f6 Z} : post A (f \u226b g) = post A f \u226b post A g :=\nbegin\n  show functor.map _ _ = _ \u226b _,\n  rw (exp.functor A).map_comp',\n  refl,\nend\n\ndef ev : A \u2a2f (A\u27f9B) \u27f6 B :=\n(ev.nat_trans A).app B\n\ndef coev : B \u27f6 A\u27f9(A\u2a2fB) :=\n(coev.nat_trans A).app B\n\n@[simp] lemma ev_coev : limits.prod.map (\ud835\udfd9 A) coev \u226b ev = \ud835\udfd9 (A\u2a2fB) :=\n(@adjunction.left_triangle_components C _ C _ (prodinl A) (exp.functor A) exp.adjunction B)\n\n@[simp] lemma coev_ev : coev \u226b post _ ev = \ud835\udfd9 (A\u27f9B) :=\n(@adjunction.right_triangle_components C _ C _ (prodinl A) (exp.functor A) exp.adjunction B)\n\nlemma coev_nat (f : X \u27f6 Y) : f \u226b coev = coev \u226b post _ (limits.prod.map (\ud835\udfd9 A) f) :=\n(coev.nat_trans A).naturality f\n\nlemma ev_nat {f : X \u27f6 Y} : limits.prod.map (\ud835\udfd9 A) (post _ f) \u226b ev = ev \u226b f :=\n(ev.nat_trans A).naturality f\n\ndef exp_transpose : (A \u2a2f Y \u27f6 X) \u2243 (Y \u27f6 A\u27f9X) :=\nexp.adjunction.hom_equiv _ _\n\nlemma exp_transpose_natural_left  (f : X \u27f6 X') (g : A \u2a2f X' \u27f6 Y) :\n  exp_transpose.to_fun (limits.prod.map (\ud835\udfd9 _) f \u226b g) = f \u226b exp_transpose.to_fun g :=\nadjunction.hom_equiv_naturality_left _ _ _\n\nlemma exp_transpose_natural_right (f : A \u2a2f X \u27f6 Y) (g : Y \u27f6 Y') :\n  exp_transpose.to_fun (f \u226b g) = exp_transpose.to_fun f \u226b post _ g :=\nadjunction.hom_equiv_naturality_right _ _ _\n\nlemma exp_transpose_natural_right_symm  (f : X \u27f6 A\u27f9Y) (g : Y \u27f6 Y') :\n  exp_transpose.inv_fun (f \u226b post A g) = exp_transpose.inv_fun f \u226b g :=\nadjunction.hom_equiv_naturality_right_symm _ _ _\n\nlemma exp_transpose_natural_left_symm  (f : X \u27f6 X') (g : X' \u27f6 A\u27f9Y) :\n  exp_transpose.inv_fun (f \u226b g) = limits.prod.map (\ud835\udfd9 _) f \u226b 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 \u27f6 Y):\n  (prod.left_unitor X).inv \u226b limits.prod.map (\ud835\udfd9 _) f = f \u226b (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 \u22a4_C :=\n{ exponentiable := {\n  right := \ud835\udfed C,\n  adj := adjunction.mk_of_hom_equiv\n  { hom_equiv := \u03bb X _, have unitor : _, from prod.left_unitor X,\n      \u27e8\u03bb a, unitor.inv \u226b a, \u03bb a, unitor.hom \u226b a, by tidy, by tidy\u27e9 } } }\n\nattribute [instance] terminal_exponentiable\n\ndef exp_terminal_iso : (\u22a4_C \u27f9 X) \u2245 X :=\nbegin\n  apply yoneda.ext (\u22a4_ C \u27f9 X) X _ _ _ _ _,\n  intros Y f, exact (prod.left_unitor Y).inv \u226b exp_transpose.inv_fun f,\n  intros Y f, exact exp_transpose.to_fun ((prod.left_unitor Y).hom \u226b f),\n  { intros Z g, dsimp,\n    rw \u2190 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 \u2190 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 \u2190 assoc, rw \u2190 assoc,\n    erw prod_left_unitor_naturality _, refl },\nend\n\n@[reducible]\ndef point_at_hom (f : A \u27f6 Y) : \u22a4_C \u27f6 (A \u27f9 Y) :=\nexp_transpose.to_fun (limits.prod.fst \u226b 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 \u27e8f,g\u27e9 might be nice but the rest can go (TODO)\nlocal notation `\u27e8`f`, `g`\u27e9` := limits.prod.map f g\n\n@[reducible]\ndef hat : (A \u2a2f Y \u27f6 X) \u2192 (Y \u27f6 A \u27f9 X) := exp_transpose.to_fun\n@[reducible]\ndef unhat : (Y \u27f6 A \u27f9 X) \u2192 (A \u2a2f Y \u27f6 X) := exp_transpose.inv_fun\n\ndef pre (X : C) (f : B \u27f6 A) :  (A\u27f9X) \u27f6 B\u27f9X :=\nhat (\u27e8f, \ud835\udfd9 (A \u27f9 X)\u27e9 \u226b unhat (\ud835\udfd9 (A \u27f9 X)))\n\nlemma pre_id : pre X (\ud835\udfd9 A) = \ud835\udfd9 (A\u27f9X) :=\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 \u27f6 B} {g : B \u27f6 D} : pre X (f \u226b g) = pre X g \u226b pre X f :=\nbegin\n  dunfold pre, apply function.injective_of_left_inverse exp_transpose.right_inv,\n  rw exp_transpose.left_inv, rw \u2190 exp_transpose_natural_left, rw exp_transpose.left_inv,\n  show \u27e8f \u226b g, \ud835\udfd9 (D \u27f9 X)\u27e9 \u226b unhat (\ud835\udfd9 (D \u27f9 X)) =\n    \u27e8\ud835\udfd9 A, (hat (\u27e8g, \ud835\udfd9 (D \u27f9 X)\u27e9 \u226b unhat (\ud835\udfd9 (D \u27f9 X))))\u27e9 \u226b\n      \u27e8f, \ud835\udfd9 (B \u27f9 X)\u27e9 \u226b unhat (\ud835\udfd9 (B \u27f9 X)),\n  suffices: \u27e8f \u226b g, \ud835\udfd9 (D \u27f9 X)\u27e9 \u226b unhat (\ud835\udfd9 (D \u27f9 X)) =\n    (\u27e8f, \ud835\udfd9 (D \u27f9 X)\u27e9 \u226b \u27e8\ud835\udfd9 B, (hat (\u27e8g, \ud835\udfd9 (D \u27f9 X)\u27e9 \u226b unhat (\ud835\udfd9 (D \u27f9 X))))\u27e9) \u226b unhat (\ud835\udfd9 (B \u27f9 X)),\n  rw this, rw \u2190 assoc, congr' 1, apply prod.hom_ext, simp, dsimp, simp, simp, dsimp, simp,\n  have: \u27e8f \u226b g, \ud835\udfd9 (D \u27f9 X)\u27e9 = \u27e8f, \ud835\udfd9 _\u27e9 \u226b \u27e8g, \ud835\udfd9 _\u27e9, apply prod.hom_ext, simp, simp,\n  rw this, rw assoc, rw assoc, congr' 1, erw \u2190 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\u1d52\u1d56 \u2964 C :=\n{ obj := \u03bb A, (A.unop) \u27f9 X,\n  map := \u03bb 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\u1d52\u1d56) (f : A \u27f6 B) (g : X \u27f6 Y) :\n  (pre.functor A).map g \u226b post (opposite.unop Y) f = post (opposite.unop X) f \u226b (pre.functor B).map g :=\nbegin\n  dunfold pre.functor,\n  dsimp, dunfold pre,\n  show _ = _,\n  rw \u2190 exp_transpose_natural_right,\n  rw \u2190 exp_transpose_natural_left,\n  congr' 1,\n  rw assoc,\n  rw \u2190 exp_transpose_natural_right_symm,\n  rw \u2190 assoc,\n  show _ = (limits.prod.map _ _ \u226b _) \u226b _,\n  rw prod_map_comm,\n  rw assoc,\n  erw \u2190 exp_transpose_natural_left_symm,\n  rw id_comp,\n  rw comp_id\nend\n\ndef exp.difunctor [is_cartesian_closed C] : C \u2964 C\u1d52\u1d56 \u2964 C :=\n{ obj := pre.functor,\n  map := \u03bb A B f, { app := \u03bb X, post X.unop f, naturality' := \u03bb X Y g, begin apply exp_natural end },\n  map_id' := \u03bb X, begin ext, apply functor.map_id end,\n  map_comp' := \u03bb X Y Z f g, begin ext, apply functor.map_comp end\n}\n\nsection functor\n\nuniverses v\u2082 u\u2082\n\nvariables {D : Type u} [category.{v} D] [has_binary_products.{v} D]\nvariables (F : C \u2964 D) [preserves_limits_of_shape (discrete walking_pair) F]\n\n-- (implementation)\ndef alternative_cone (A B : C) : cone (pair A B \u22d9 F) :=\n{ X := F.obj A \u2a2f F.obj B,\n  \u03c0 := nat_trans.of_homs (\u03bb 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 \u2a2f B) \u2245 F.obj A \u2a2f 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 \u27e8j\u27e9,\n      rw assoc, rw (alt_is_limit F A B).fac,\n      erw limit.lift_\u03c0, simp,\n    rw assoc, rw (alt_is_limit F A B).fac,\n    erw limit.lift_\u03c0, simp\n  end,\n  inv_hom_id' :=\n  begin\n    ext \u27e8j\u27e9, 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 \u27f9 B) \u27f6 F.obj A \u27f9 F.obj B :=\nhat ((mult_comparison F A _).inv \u226b 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 (\u2211 a\u2099 x\u207f)` is `\u2211 a\u2099 x\u207f\u1d56`.\n* `polynomial.contract p f`: the opposite of `expand`, so it sends `\u2211 a\u2099 x\u207f\u1d56` to `\u2211 a\u2099 x\u207f`.\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 \u2194 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 \u2194 \u2203 (a : polynomial R), \u2203 (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) \u2194 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 \u2223 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 : \u2115} (h : separable (f ^ n)) : is_unit f \u2228 separable f \u2227 n = 1 \u2228 n = 0 := sorry\n\ntheorem separable.of_pow {R : Type u} [comm_semiring R] {f : polynomial R} (hf : \u00acis_unit f) {n : \u2115} (hn : n \u2260 0) (hfs : separable (f ^ n)) : separable f \u2227 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 \u2192+* S} : separable (map f p) := sorry\n\n/-- Expand the polynomial by a factor of p, so `\u2211 a\u2099 x\u207f` becomes `\u2211 a\u2099 x\u207f\u1d56`. -/\ndef expand (R : Type u) [comm_semiring R] (p : \u2115) : alg_hom R (polynomial R) (polynomial R) :=\n  alg_hom.mk (ring_hom.to_fun (eval\u2082_ring_hom C (X ^ p))) sorry sorry sorry sorry sorry\n\ntheorem coe_expand (R : Type u) [comm_semiring R] (p : \u2115) : \u21d1(expand R p) = eval\u2082 C (X ^ p) :=\n  rfl\n\ntheorem expand_eq_sum {R : Type u} [comm_semiring R] (p : \u2115) {f : polynomial R} : coe_fn (expand R p) f = finsupp.sum f fun (e : \u2115) (a : R) => coe_fn C a * (X ^ p) ^ e :=\n  id (Eq.refl (finsupp.sum f fun (e : \u2115) (a : R) => coe_fn C a * (X ^ p) ^ e))\n\n@[simp] theorem expand_C {R : Type u} [comm_semiring R] (p : \u2115) (r : R) : coe_fn (expand R p) (coe_fn C r) = coe_fn C r :=\n  eval\u2082_C C (X ^ p)\n\n@[simp] theorem expand_X {R : Type u} [comm_semiring R] (p : \u2115) : coe_fn (expand R p) X = X ^ p :=\n  eval\u2082_X C (X ^ p)\n\n@[simp] theorem expand_monomial {R : Type u} [comm_semiring R] (p : \u2115) (q : \u2115) (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 : \u2115) (q : \u2115) (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 : \u2115) (q : \u2115) (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 : \u2115) (q : \u2115) (f : polynomial R) : coe_fn (expand R (p ^ q)) f = nat.iterate (\u21d1(expand R p)) q f := sorry\n\ntheorem derivative_expand {R : Type u} [comm_semiring R] (p : \u2115) (f : polynomial R) : coe_fn derivative (coe_fn (expand R p) f) = coe_fn (expand R p) (coe_fn derivative f) * (\u2191p * X ^ (p - 1)) := sorry\n\ntheorem coeff_expand {R : Type u} [comm_semiring R] {p : \u2115} (hp : 0 < p) (f : polynomial R) (n : \u2115) : coeff (coe_fn (expand R p) f) n = ite (p \u2223 n) (coeff f (n / p)) 0 := sorry\n\n@[simp] theorem coeff_expand_mul {R : Type u} [comm_semiring R] {p : \u2115} (hp : 0 < p) (f : polynomial R) (n : \u2115) : 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 : \u2115} (hp : 0 < p) (f : polynomial R) (n : \u2115) : 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 : \u2115) (f : polynomial R) : coe_fn (expand R p) f = finsupp.map_domain (fun (_x : \u2115) => _x * p) f := sorry\n\ntheorem expand_inj {R : Type u} [comm_semiring R] {p : \u2115} (hp : 0 < p) {f : polynomial R} {g : polynomial R} : coe_fn (expand R p) f = coe_fn (expand R p) g \u2194 f = g := sorry\n\ntheorem expand_eq_zero {R : Type u} [comm_semiring R] {p : \u2115} (hp : 0 < p) {f : polynomial R} : coe_fn (expand R p) f = 0 \u2194 f = 0 := sorry\n\ntheorem expand_eq_C {R : Type u} [comm_semiring R] {p : \u2115} (hp : 0 < p) {f : polynomial R} {r : R} : coe_fn (expand R p) f = coe_fn C r \u2194 f = coe_fn C r := sorry\n\ntheorem nat_degree_expand {R : Type u} [comm_semiring R] (p : \u2115) (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 : \u2115} (hp : 0 < p) {f : R \u2192+* 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] {\u03b9 : Type u_1} {f : \u03b9 \u2192 polynomial R} {s : finset \u03b9} : (\u2200 (x : \u03b9), x \u2208 s \u2192 \u2200 (y : \u03b9), y \u2208 s \u2192 x \u2260 y \u2192 is_coprime (f x) (f y)) \u2192\n  (\u2200 (x : \u03b9), x \u2208 s \u2192 separable (f x)) \u2192 separable (finset.prod s fun (x : \u03b9) => f x) := sorry\n\ntheorem separable_prod {R : Type u} [comm_ring R] {\u03b9 : Type u_1} [fintype \u03b9] {f : \u03b9 \u2192 polynomial R} (h1 : pairwise (is_coprime on f)) (h2 : \u2200 (x : \u03b9), separable (f x)) : separable (finset.prod finset.univ fun (x : \u03b9) => f x) :=\n  separable_prod' (fun (x : \u03b9) (hx : x \u2208 finset.univ) (y : \u03b9) (hy : y \u2208 finset.univ) (hxy : x \u2260 y) => h1 x y hxy)\n    fun (x : \u03b9) (hx : x \u2208 finset.univ) => h2 x\n\ntheorem separable.inj_of_prod_X_sub_C {R : Type u} [comm_ring R] [nontrivial R] {\u03b9 : Type u_1} {f : \u03b9 \u2192 R} {s : finset \u03b9} (hfs : separable (finset.prod s fun (i : \u03b9) => X - coe_fn C (f i))) {x : \u03b9} {y : \u03b9} (hx : x \u2208 s) (hy : y \u2208 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] {\u03b9 : Type u_1} [fintype \u03b9] {f : \u03b9 \u2192 R} (hfs : separable (finset.prod finset.univ fun (i : \u03b9) => X - coe_fn C (f i))) : function.injective f :=\n  fun (x y : \u03b9) (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 \u2223 p) : is_unit q := sorry\n\ntheorem is_local_ring_hom_expand (R : Type u) [integral_domain R] {p : \u2115} (hp : 0 < p) : is_local_ring_hom \u2191(expand R p) := sorry\n\ntheorem separable_iff_derivative_ne_zero {F : Type u} [field F] {f : polynomial F} (hf : irreducible f) : separable f \u2194 coe_fn derivative f \u2260 0 := sorry\n\ntheorem separable_map {F : Type u} [field F] {K : Type v} [field K] (f : F \u2192+* K) {p : polynomial F} : separable (map f p) \u2194 separable p := sorry\n\n/-- The opposite of `expand`: sends `\u2211 a\u2099 x\u207f\u1d56` to `\u2211 a\u2099 x\u207f`. -/\ndef contract {F : Type u} [field F] (p : \u2115) [hp : fact (nat.prime p)] (f : polynomial F) : polynomial F :=\n  finsupp.mk (finset.preimage (finsupp.support f) (fun (_x : \u2115) => _x * p) sorry) (fun (n : \u2115) => coeff f (n * p)) sorry\n\ntheorem coeff_contract {F : Type u} [field F] (p : \u2115) [hp : fact (nat.prime p)] (f : polynomial F) (n : \u2115) : coeff (contract p f) n = coeff f (n * p) :=\n  rfl\n\ntheorem of_irreducible_expand {F : Type u} [field F] (p : \u2115) [hp : fact (nat.prime p)] {f : polynomial F} (hf : irreducible (coe_fn (expand F p) f)) : irreducible f :=\n  of_irreducible_map (\u2191(expand F p)) hf\n\ntheorem of_irreducible_expand_pow {F : Type u} [field F] (p : \u2115) [hp : fact (nat.prime p)] {f : polynomial F} {n : \u2115} : irreducible (coe_fn (expand F (p ^ n)) f) \u2192 irreducible f := sorry\n\ntheorem expand_char {F : Type u} [field F] (p : \u2115) [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 : \u2115) [hp : fact (nat.prime p)] [HF : char_p F p] (f : polynomial F) (n : \u2115) : 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 : \u2115) [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 : \u2115) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (hf : irreducible f) : separable f \u2228 \u00acseparable f \u2227 \u2203 (g : polynomial F), irreducible g \u2227 coe_fn (expand F p) g = f := sorry\n\ntheorem exists_separable_of_irreducible {F : Type u} [field F] (p : \u2115) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (hf : irreducible f) (hf0 : f \u2260 0) : \u2203 (n : \u2115), \u2203 (g : polynomial F), separable g \u2227 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 : \u2115) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (n : \u2115) (hf : separable (coe_fn (expand F (p ^ n)) f)) : is_unit f \u2228 n = 0 := sorry\n\ntheorem unique_separable_of_irreducible {F : Type u} [field F] (p : \u2115) [hp : fact (nat.prime p)] [HF : char_p F p] {f : polynomial F} (hf : irreducible f) (hf0 : f \u2260 0) (n\u2081 : \u2115) (g\u2081 : polynomial F) (hg\u2081 : separable g\u2081) (hgf\u2081 : coe_fn (expand F (p ^ n\u2081)) g\u2081 = f) (n\u2082 : \u2115) (g\u2082 : polynomial F) (hg\u2082 : separable g\u2082) (hgf\u2082 : coe_fn (expand F (p ^ n\u2082)) g\u2082 = f) : n\u2081 = n\u2082 \u2227 g\u2081 = g\u2082 := sorry\n\ntheorem separable_prod_X_sub_C_iff' {F : Type u} [field F] {\u03b9 : Type u_1} {f : \u03b9 \u2192 F} {s : finset \u03b9} : separable (finset.prod s fun (i : \u03b9) => X - coe_fn C (f i)) \u2194 \u2200 (x : \u03b9), x \u2208 s \u2192 \u2200 (y : \u03b9), y \u2208 s \u2192 f x = f y \u2192 x = y := sorry\n\ntheorem separable_prod_X_sub_C_iff {F : Type u} [field F] {\u03b9 : Type u_1} [fintype \u03b9] {f : \u03b9 \u2192 F} : separable (finset.prod finset.univ fun (i : \u03b9) => X - coe_fn C (f i)) \u2194 function.injective f := sorry\n\ntheorem not_unit_X_sub_C {F : Type u} [field F] (a : F) : \u00acis_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 : \u00acis_unit q) (hsep : separable p) : multiplicity q p \u2264 1 := sorry\n\ntheorem separable.squarefree {F : Type u} [field F] {p : polynomial F} (hsep : separable p) : squarefree p := sorry\n\n/--If `n \u2260 0` in `F`, then ` X ^ n - a` is separable for any `a \u2260 0`. -/\ntheorem separable_X_pow_sub_C {F : Type u} [field F] {n : \u2115} (a : F) (hn : \u2191n \u2260 0) (ha : a \u2260 0) : separable (X ^ n - coe_fn C a) := sorry\n\n/--If `n \u2260 0` in `F`, then ` X ^ n - a` is squarefree for any `a \u2260 0`. -/\ntheorem squarefree_X_pow_sub_C {F : Type u} [field F] {n : \u2115} (a : F) (hn : \u2191n \u2260 0) (ha : a \u2260 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 \u2260 0) (hsep : separable p) (x : F) : root_multiplicity x p \u2264 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) \u2264 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 \u2192+* K} {x : F} {h : polynomial F} (h_ne_zero : h \u2260 0) (h_sep : separable h) (h_root : eval x h = 0) (h_splits : splits i h) (h_roots : \u2200 (y : K), y \u2208 roots (map i h) \u2192 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  \u2200 (x : K), is_integral F x \u2227 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nnamespace CategoryTheory.Functor\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} D] {E : Type u\u2083}\n  [Category.{v\u2083} E]\n\n#print CategoryTheory.Functor.PreservesMonomorphisms /-\n/-- A functor preserves monomorphisms if it maps monomorphisms to monomorphisms. -/\nclass PreservesMonomorphisms (F : C \u2964 D) : Prop where\n  preserves : \u2200 {X Y : C} (f : X \u27f6 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\u2093'. -/\ninstance map_mono (F : C \u2964 D) [PreservesMonomorphisms F] {X Y : C} (f : X \u27f6 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 \u2964 D) : Prop where\n  preserves : \u2200 {X Y : C} (f : X \u27f6 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\u2093'. -/\ninstance map_epi (F : C \u2964 D) [PreservesEpimorphisms F] {X Y : C} (f : X \u27f6 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 \u2964 D) : Prop where\n  reflects : \u2200 {X Y : C} (f : X \u27f6 Y), Mono (F.map f) \u2192 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\u2093'. -/\ntheorem mono_of_mono_map (F : C \u2964 D) [ReflectsMonomorphisms F] {X Y : C} {f : X \u27f6 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 \u2964 D) : Prop where\n  reflects : \u2200 {X Y : C} (f : X \u27f6 Y), Epi (F.map f) \u2192 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\u2093'. -/\ntheorem epi_of_epi_map (F : C \u2964 D) [ReflectsEpimorphisms F] {X Y : C} {f : X \u27f6 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 \u2964 D) (G : D \u2964 E) [PreservesMonomorphisms F]\n    [PreservesMonomorphisms G] : PreservesMonomorphisms (F \u22d9 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 \u2964 D) (G : D \u2964 E) [PreservesEpimorphisms F]\n    [PreservesEpimorphisms G] : PreservesEpimorphisms (F \u22d9 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 \u2964 D) (G : D \u2964 E) [ReflectsMonomorphisms F]\n    [ReflectsMonomorphisms G] : ReflectsMonomorphisms (F \u22d9 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 \u2964 D) (G : D \u2964 E) [ReflectsEpimorphisms F]\n    [ReflectsEpimorphisms G] : ReflectsEpimorphisms (F \u22d9 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 \u2964 D) (G : D \u2964 E)\n    [PreservesEpimorphisms (F \u22d9 G)] [ReflectsEpimorphisms G] : PreservesEpimorphisms F :=\n  \u27e8fun X Y f hf => G.epi_of_epi_map <| show Epi ((F \u22d9 G).map f) from inferInstance\u27e9\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 \u2964 D) (G : D \u2964 E)\n    [PreservesMonomorphisms (F \u22d9 G)] [ReflectsMonomorphisms G] : PreservesMonomorphisms F :=\n  \u27e8fun X Y f hf => G.mono_of_mono_map <| show Mono ((F \u22d9 G).map f) from inferInstance\u27e9\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 \u2964 D) (G : D \u2964 E)\n    [PreservesEpimorphisms G] [ReflectsEpimorphisms (F \u22d9 G)] : ReflectsEpimorphisms F :=\n  \u27e8fun X Y f hf => (F \u22d9 G).epi_of_epi_map <| show Epi (G.map (F.map f)) from inferInstance\u27e9\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 \u2964 D) (G : D \u2964 E)\n    [PreservesMonomorphisms G] [ReflectsMonomorphisms (F \u22d9 G)] : ReflectsMonomorphisms F :=\n  \u27e8fun X Y f hf => (F \u22d9 G).mono_of_mono_map <| show Mono (G.map (F.map f)) from inferInstance\u27e9\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 \u2964 D} [PreservesMonomorphisms F] (\u03b1 : F \u2245 G) :\n    PreservesMonomorphisms G :=\n  {\n    preserves := fun X Y f h =>\n      by\n      haveI : mono (F.map f \u226b (\u03b1.app Y).Hom) := mono_comp _ _\n      convert(mono_comp _ _ : mono ((\u03b1.app X).inv \u226b F.map f \u226b (\u03b1.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 \u2964 D} (\u03b1 : F \u2245 G) :\n    PreservesMonomorphisms F \u2194 PreservesMonomorphisms G :=\n  \u27e8fun h => preserves_monomorphisms.of_iso \u03b1, fun h => preserves_monomorphisms.of_iso \u03b1.symm\u27e9\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 \u2964 D} [PreservesEpimorphisms F] (\u03b1 : F \u2245 G) :\n    PreservesEpimorphisms G :=\n  {\n    preserves := fun X Y f h =>\n      by\n      haveI : epi (F.map f \u226b (\u03b1.app Y).Hom) := epi_comp _ _\n      convert(epi_comp _ _ : epi ((\u03b1.app X).inv \u226b F.map f \u226b (\u03b1.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 \u2964 D} (\u03b1 : F \u2245 G) :\n    PreservesEpimorphisms F \u2194 PreservesEpimorphisms G :=\n  \u27e8fun h => preserves_epimorphisms.of_iso \u03b1, fun h => preserves_epimorphisms.of_iso \u03b1.symm\u27e9\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 \u2964 D} [ReflectsMonomorphisms F] (\u03b1 : F \u2245 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 \u226b (\u03b1.app Y).inv) := mono_comp _ _\n      convert(mono_comp _ _ : mono ((\u03b1.app X).Hom \u226b G.map f \u226b (\u03b1.app Y).inv))\n      rw [\u2190 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 \u2964 D} (\u03b1 : F \u2245 G) :\n    ReflectsMonomorphisms F \u2194 ReflectsMonomorphisms G :=\n  \u27e8fun h => reflects_monomorphisms.of_iso \u03b1, fun h => reflects_monomorphisms.of_iso \u03b1.symm\u27e9\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 \u2964 D} [ReflectsEpimorphisms F] (\u03b1 : F \u2245 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 \u226b (\u03b1.app Y).inv) := epi_comp _ _\n      convert(epi_comp _ _ : epi ((\u03b1.app X).Hom \u226b G.map f \u226b (\u03b1.app Y).inv))\n      rw [\u2190 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 \u2964 D} (\u03b1 : F \u2245 G) :\n    ReflectsEpimorphisms F \u2194 ReflectsEpimorphisms G :=\n  \u27e8fun h => reflects_epimorphisms.of_iso \u03b1, fun h => reflects_epimorphisms.of_iso \u03b1.symm\u27e9\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 \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) :\n    PreservesEpimorphisms F :=\n  {\n    preserves := fun X Y f hf =>\n      \u27e8by\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\u27e9 }\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 \u2964 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 \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) :\n    PreservesMonomorphisms G :=\n  {\n    preserves := fun X Y f hf =>\n      \u27e8by\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\u27e9 }\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 \u2964 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 \u2964 D) [Faithful F] :\n    ReflectsMonomorphisms F\n    where reflects X Y f hf :=\n    \u27e8fun Z g h hgh =>\n      F.map_injective ((cancel_mono (F.map f)).1 (by rw [\u2190 F.map_comp, hgh, F.map_comp]))\u27e9\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 \u2964 D) [Faithful F] :\n    ReflectsEpimorphisms F\n    where reflects X Y f hf :=\n    \u27e8fun Z g h hgh =>\n      F.map_injective ((cancel_epi (F.map f)).1 (by rw [\u2190 F.map_comp, hgh, F.map_comp]))\u27e9\n#align category_theory.functor.reflects_epimorphisms_of_faithful CategoryTheory.Functor.reflectsEpimorphisms_of_faithful\n-/\n\nsection\n\nvariable (F : C \u2964 D) {X Y : C} (f : X \u27f6 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\u2093'. -/\n/-- If `F` is a fully faithful functor, split epimorphisms are preserved and reflected by `F`. -/\ndef splitEpiEquiv [Full F] [Faithful F] : SplitEpi f \u2243 SplitEpi (F.map f)\n    where\n  toFun f := f.map F\n  invFun s := by\n    refine' \u27e8F.preimage s.section_, _\u27e9\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\u2093'. -/\n@[simp]\ntheorem isSplitEpi_iff [Full F] [Faithful F] : IsSplitEpi (F.map f) \u2194 IsSplitEpi f :=\n  by\n  constructor\n  \u00b7 intro h\n    exact is_split_epi.mk' ((split_epi_equiv F f).invFun h.exists_split_epi.some)\n  \u00b7 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\u2093'. -/\n/-- If `F` is a fully faithful functor, split monomorphisms are preserved and reflected by `F`. -/\ndef splitMonoEquiv [Full F] [Faithful F] : SplitMono f \u2243 SplitMono (F.map f)\n    where\n  toFun f := f.map F\n  invFun s := by\n    refine' \u27e8F.preimage s.retraction, _\u27e9\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\u2093'. -/\n@[simp]\ntheorem isSplitMono_iff [Full F] [Faithful F] : IsSplitMono (F.map f) \u2194 IsSplitMono f :=\n  by\n  constructor\n  \u00b7 intro h\n    exact is_split_mono.mk' ((split_mono_equiv F f).invFun h.exists_split_mono.some)\n  \u00b7 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\u2081 : CategoryTheory.Functor.PreservesEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [hF\u2082 : 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\u2081 : CategoryTheory.Functor.PreservesEpimorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [hF\u2082 : 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\u2093'. -/\n@[simp]\ntheorem epi_map_iff_epi [hF\u2081 : PreservesEpimorphisms F] [hF\u2082 : ReflectsEpimorphisms F] :\n    Epi (F.map f) \u2194 Epi f := by\n  constructor\n  \u00b7 exact F.epi_of_epi_map\n  \u00b7 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\u2081 : CategoryTheory.Functor.PreservesMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [hF\u2082 : 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\u2081 : CategoryTheory.Functor.PreservesMonomorphisms.{u1, u2, u3, u4} C _inst_1 D _inst_2 F] [hF\u2082 : 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\u2093'. -/\n@[simp]\ntheorem mono_map_iff_mono [hF\u2081 : PreservesMonomorphisms F] [hF\u2082 : ReflectsMonomorphisms F] :\n    Mono (F.map f) \u2194 Mono f := by\n  constructor\n  \u00b7 exact F.mono_of_mono_map\n  \u00b7 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 \u2964 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  \u27e8fun X Y f => by\n    intro\n    rw [\u2190 F.inv.is_split_epi_iff f]\n    apply is_split_epi_of_epi\u27e9\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 \u2964 D} {F' : D \u2964 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\u2081 : CategoryTheory.Functor.PreservesMonomorphisms.{u4, u3, u2, u1} D _inst_2 C _inst_1 F'] [h\u2082 : 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\u2081 : CategoryTheory.Functor.PreservesMonomorphisms.{u3, u4, u1, u2} D _inst_2 C _inst_1 F'] [h\u2082 : 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\u2093'. -/\ntheorem strongEpi_map_of_strongEpi (adj : F \u22a3 F') (f : A \u27f6 B) [h\u2081 : F'.PreservesMonomorphisms]\n    [h\u2082 : F.PreservesEpimorphisms] [StrongEpi f] : StrongEpi (F.map f) :=\n  \u27e8inferInstance, fun X Y Z => by\n    intro\n    rw [adj.has_lifting_property_iff]\n    infer_instance\u27e9\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\u2093'. -/\ninstance strongEpi_map_of_isEquivalence [IsEquivalence F] (f : A \u27f6 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 \u2964 D} {A B : C} (f : A \u27f6 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\u2093'. -/\n@[simp]\ntheorem strongEpi_map_iff_strongEpi_of_isEquivalence [IsEquivalence F] :\n    StrongEpi (F.map f) \u2194 StrongEpi f := by\n  constructor\n  \u00b7 intro\n    have e : arrow.mk f \u2245 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  \u00b7 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 : \u2115) : n.coprime 2 \u2194 \u00ac 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 : \u2115) : (2 : \u2115).coprime n \u2194 \u00ac even n :=\nby rw [nat.coprime_comm, nat.coprime_two_iff_odd]\n\n@[parity_simps]\nlemma nat.coprime_bit0 (n m : \u2115) : n.coprime (bit0 m) \u2194 \u00ac even n \u2227 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 : \u2115) : (bit0 n).coprime m \u2194 \u00ac even m \u2227 n.coprime m :=\nby rw [nat.coprime_comm, nat.coprime_bit0, nat.coprime_comm]\n\nexample : \u00ac (8 : \u2115).coprime 6 := by simp with parity_simps\nexample : (8 : \u2115).coprime 9 := by simp with parity_simps\n\nend parity\n\n\n/-! # zeroness of zmod powers-/\nsection pow_zmod_nat\nvariables {n m : \u2115} (e : \u2115)\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 : \u2115} {m : \u2124} (e : \u2115)\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 \u03b9 : Type*} [comm_ring R] [comm_ring S] [algebra R S] [nontrivial S]\n  [fintype \u03b9] (b : basis \u03b9 R S) : algebra.norm R (0 : S) = 0 :=\nbegin\n  have h\u03b9 : nonempty \u03b9 := b.index_nonempty,\n  letI := classical.dec_eq \u03b9,\n  rw algebra.norm_eq_matrix_det b,\n  rw [alg_hom.map_zero, matrix.det_zero h\u03b9],\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 : \u2124} : squarefree z \u2194 squarefree (int.nat_abs z) :=\nbegin\n  rw [squarefree, squarefree],\n  split; intros h x hx,\n  { specialize h x _, norm_cast, rw \u2190 int.coe_nat_dvd_left at hx, exact hx,\n    norm_cast at h, exact h },\n  { specialize h x.nat_abs _, rw \u2190 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 \u2192 tactic (expr \u00d7 expr)\n-- | `(squarefree (%%e : \u2124)) := 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 {\u03b1 \u03b2 : Type*} [monoid \u03b1] [monoid \u03b2] [unique \u03b2\u02e3] {p : \u03b1}\n  {F : Type*} [monoid_hom_class F \u03b1 \u03b2] (f : F) (hf : \u2200 x, f x = 1 \u2192 x = 1)\n  (h : irreducible $ f p) : irreducible p :=\n{ not_unit := \u03bb hn, h.not_unit (hn.map f),\n  is_unit_or_is_unit' := \u03bb a b hab, begin\n    have := map_mul f a b,\n    rw \u2190 hab at this,\n    apply or.imp _ _ (h.is_unit_or_is_unit this);\n    rintro \u27e8ua, ha\u27e9;\n    [rw hf a, rw hf b];\n    { exact is_unit_one } <|>\n    { simp [\u2190 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) = \u22a5 := by simp\n@[simp] lemma span_one : span ({1} : set R) = \u22a4 := by simp\ninstance : submodule.is_principal (\u22a5 : ideal R) :=\n{ principal := \u27e80, by {rw \u2190 submodule.span_zero, refl}\u27e9 }\ninstance {a : R} : submodule.is_principal (span ({a} : set R)) := { principal := \u27e8a, rfl\u27e9 }\n\n@[simp]\nlemma generator_bot : submodule.is_principal.generator (\u22a5 : 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 ` ~\u1d64 ` : 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)) ~\u1d64 a := -- TODO notation for associated?\nbegin\n  apply associated_of_dvd_dvd; rw \u2190 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\u02e3) : is_unit $ algebra.norm \u2124 (u : R) :=\nbegin\n  apply is_unit_of_mul_eq_one _ (algebra.norm \u2124 (\u2191u\u207b\u00b9 : R)),\n  simp [\u2190 _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 \u2124 a) (algebra.norm \u2124 b) :=\nbegin\n  obtain \u27e8u, hu\u27e9 := h,\n  apply_fun (algebra.norm \u2124) at hu,\n  rw _root_.map_mul at hu,\n  obtain \u27e8Nu, hNu\u27e9 := 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 (\u22a4 : ideal R)) :=\nis_unit_of_dvd_one (generator \u22a4) $ (mem_iff_generator_dvd \u22a4).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 \u27e8ideal.span ({x} : set R), h\u27e9 = 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\u2080 : Type*} [group_with_zero G\u2080] (x : G\u2080) {n : \u2115} (hn : 0 < n) (hxy) :\n  units.mk0 (x ^ n) hxy = (units.mk0 x (\u03bb 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 \u2208 p.roots) :\n  p /\u2098 (X - C a) * (X - C a) = p :=\nhave monic (X - C a), from (monic_X_sub_C _),\nby conv_rhs { rw [\u2190 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 \u2190 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) : \u00ac 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 \u2264 3) (hpl : 2 \u2264 p.nat_degree) : irreducible p \u2194 p.roots = 0 :=\nbegin\n  have hpz : p \u2260 0 := polynomial.ne_zero_of_nat_degree_gt hpl,\n  have hpu : \u00ac 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 \u27e8r, hr\u27e9 := multiset.exists_mem_of_ne_zero h,\n    -- rw \u2190 polynomial.div_by_monic_mul_pow_root_multiplicity_eq p r,\n    refine \u27e8p /\u2098 (X - C r), X - C r, _, _, _\u27e9,\n    { conv_lhs\n      { rw [\u2190 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 : \u2200 (A B : R[X]) (Hpl : 2 \u2264 (A * B).nat_degree) (Hpu : \u00acis_unit (A * B))\n      (H : (A * B).roots = 0) (Hpz : \u00acA = 0 \u2227 \u00acB = 0) (Hp : A.nat_degree + B.nat_degree \u2264 3)\n      (this : 1 \u2264 A.nat_degree),\n      is_unit A \u2228 is_unit B,\n    { clear_except,\n      intros A B Hpl Hpu H Hpz Hp this,\n      have : A.nat_degree \u2264 3 := le_of_add_le_left Hp,\n      interval_cases A.nat_degree with H_eq,\n      { exfalso,\n        have : A.roots \u2260 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 \u2190 le_tsub_iff_left (by norm_num : 2 \u2264 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 \u2260 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 \u22a2 Hp,\n        right,\n        rw [polynomial.degree_eq_nat_degree Hpz.2, Hp, enat.coe_zero], }, },\n    have : 1 \u2264 a.nat_degree \u2228 1 \u2264 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\u02e3] (m : M) :\n  is_unit m \u2194 m = 1 :=\nbegin\n  split; intro h,\n  { lift m to M\u02e3 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 \u2243+* S) :\n  (f : R \u2243 S).symm = (f.symm : S \u2243 R) := rfl\n\nend ring_equiv\n\n\nsection dvd_sub_self\n\nvariables {\u03b1 : Type*} [ring \u03b1]\n\ntheorem dvd_sub_iff_left {a b c : \u03b1} (h : a \u2223 c) : a \u2223 b \u2194 a \u2223 b - c :=\n\u27e8\u03bbh\u2082, dvd_sub h\u2082 h, \u03bbH, by have t := dvd_add H h; rwa sub_add_cancel at t\u27e9\n\ntheorem dvd_sub_iff_right {a b c : \u03b1} (h : a \u2223 b) : a \u2223 c \u2194 a \u2223 b - c :=\n\u27e8\u03bbh\u2082, dvd_sub h h\u2082, \u03bbH, by have t := dvd_sub h H; rwa [\u2190 sub_add, sub_self, zero_add] at t\u27e9\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 : \u03b1} (h : a \u2223 c) : a \u2223 b - c \u2194 a \u2223 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 : \u03b1} (h : a \u2223 b) : a \u2223 b - c \u2194 a \u2223 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 : \u03b1} : a \u2223 a - b \u2194 a \u2223 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 : \u03b1} : a \u2223 b - a \u2194 a \u2223 b :=\ndvd_sub_left (dvd_refl a)\n\nend dvd_sub_self\n\nsection zmod_reduced\n\ninstance {n : \u2115} [fact $ squarefree n] : is_reduced (zmod n) :=\n\u27e8begin\n  casesI n,\n  { exfalso,\n    apply not_squarefree_zero _inst_1.out, },\n  rintro \u27e8x, hx\u27e9 \u27e8_ | m, h\u27e9,\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 : ((\u27e8x, hx\u27e9 : 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 \u22a2,\n    norm_cast at h,\n    rw zmod.nat_coe_zmod_eq_zero_iff_dvd at h \u22a2,\n    rwa unique_factorization_monoid.dvd_pow_iff_dvd_of_squarefree at h,\n    exact fact.out _,\n    exact ne_zero.ne _, }\nend\u27e9\n\nend zmod_reduced\n\nsection squarefree_gcd_of_squarefree\n\nvariables {\u03b1 : Type*} [cancel_comm_monoid_with_zero \u03b1] [gcd_monoid \u03b1]\n\nlemma squarefree_gcd_of_squarefree_right {a b : \u03b1} (hb : squarefree b) :\n  squarefree (gcd a b) :=\n\u03bb x hx, hb x $ hx.trans $ gcd_dvd_right _ _\n\nlemma squarefree_gcd_of_squarefree_left {a b : \u03b1} (ha : squarefree a) :\n  squarefree (gcd a b) :=\n\u03bb 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 : \u2115} : is_unit (n : \u2124) \u2194 n = 1 :=\nby rw [int.is_unit_iff_nat_abs_eq, int.nat_abs_of_nat]\n\ninstance : \u03a0 (n : \u2115), slim_check.sampleable (zmod n)\n| 0 := show slim_check.sampleable \u2124, by apply_instance\n| (n+1) := show slim_check.sampleable (fin (n + 1)), by apply_instance\n\n\nlemma is_square.nonneg {\u03b1 : Type*} [linear_ordered_field \u03b1] {a : \u03b1} (h : is_square a) : 0 \u2264 a :=\nbegin\n  rcases h with \u27e8h_w, rfl\u27e9,\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 : \u03b1) : List \u03b1 \u2192 Prop where\n  | head {as} : Mem a (a::as)\n  | tail {as} : Mem a as \u2192 Mem a (a'::as)\n\ninfix:50 (priority := high) \" \u2208 \" => Mem\n\nexample (a b : Nat) (h : a \u2208 [b]) : b = a :=\n  match h with\n  | Mem.head => rfl\n\nexample {as : List \u03b1} (h : a \u2208 b :: as) : b = a \u2228 a \u2208 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 (\u03b1 : Type u) : Nat \u2192 Type u where\n  | nil  : Vec \u03b1 0\n  | cons : \u03b1 \u2192 Vec \u03b1 n \u2192 Vec \u03b1 (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 \u00d7 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} \u2192 Vec (Type u) n \u2192 Type (u+1)\n  | nil  : HVec Vec.nil\n  | cons : {\u03b1s : Vec (Type u) n} \u2192 \u03b1 \u2192 HVec \u03b1s \u2192 HVec (Vec.cons \u03b1 \u03b1s)\n\nabbrev HVec.TypeHead {\u03b1s : Vec (Type u) n} (xs : HVec \u03b1s) : Type u :=\n  match xs with\n  | HVec.nil => PUnit\n  | HVec.cons (\u03b1 := \u03b1) .. => \u03b1\n\ndef HVec.head {\u03b1s : Vec (Type u) n} (xs : HVec \u03b1s) : 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\u00f6lzl\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 \ud835\udd5c f` if it is linear and satisfies the\ninequality `\u2225 f x \u2225 \u2264 M * \u2225 x \u2225` for some positive constant `M`. -/\nstructure is_bounded_linear_map (\ud835\udd5c : Type u_5) [normed_field \ud835\udd5c] {E : Type u_6} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_7} [normed_group F] [normed_space \ud835\udd5c F] (f : E \u2192 F) \nextends is_linear_map \ud835\udd5c f\nwhere\n  bound : \u2203 (M : \u211d), 0 < M \u2227 \u2200 (x : E), norm (f x) \u2264 M * norm x\n\ntheorem is_linear_map.with_bound {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (hf : is_linear_map \ud835\udd5c f) (M : \u211d) (h : \u2200 (x : E), norm (f x) \u2264 M * norm x) : is_bounded_linear_map \ud835\udd5c f := sorry\n\n/-- A continuous linear map satisfies `is_bounded_linear_map` -/\ntheorem continuous_linear_map.is_bounded_linear_map {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] (f : continuous_linear_map \ud835\udd5c E F) : is_bounded_linear_map \ud835\udd5c \u21d1f := sorry\n\nnamespace is_bounded_linear_map\n\n\n/-- Construct a linear map from a function `f` satisfying `is_bounded_linear_map \ud835\udd5c f`. -/\ndef to_linear_map {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] (f : E \u2192 F) (h : is_bounded_linear_map \ud835\udd5c f) : linear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (hf : is_bounded_linear_map \ud835\udd5c f) : continuous_linear_map \ud835\udd5c E F :=\n  continuous_linear_map.mk (linear_map.mk (linear_map.to_fun (to_linear_map f hf)) sorry sorry)\n\ntheorem zero {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] : is_bounded_linear_map \ud835\udd5c fun (x : E) => 0 := sorry\n\ntheorem id {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] : is_bounded_linear_map \ud835\udd5c fun (x : E) => x := sorry\n\ntheorem fst {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] : is_bounded_linear_map \ud835\udd5c fun (x : E \u00d7 F) => prod.fst x := sorry\n\ntheorem snd {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] : is_bounded_linear_map \ud835\udd5c fun (x : E \u00d7 F) => prod.snd x := sorry\n\ntheorem smul {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (c : \ud835\udd5c) (hf : is_bounded_linear_map \ud835\udd5c f) : is_bounded_linear_map \ud835\udd5c fun (e : E) => c \u2022 f e := sorry\n\ntheorem neg {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (hf : is_bounded_linear_map \ud835\udd5c f) : is_bounded_linear_map \ud835\udd5c fun (e : E) => -f e := sorry\n\ntheorem add {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} {g : E \u2192 F} (hf : is_bounded_linear_map \ud835\udd5c f) (hg : is_bounded_linear_map \ud835\udd5c g) : is_bounded_linear_map \ud835\udd5c fun (e : E) => f e + g e := sorry\n\ntheorem sub {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} {g : E \u2192 F} (hf : is_bounded_linear_map \ud835\udd5c f) (hg : is_bounded_linear_map \ud835\udd5c g) : is_bounded_linear_map \ud835\udd5c fun (e : E) => f e - g e := sorry\n\ntheorem comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u2192 F} {g : F \u2192 G} (hg : is_bounded_linear_map \ud835\udd5c g) (hf : is_bounded_linear_map \ud835\udd5c f) : is_bounded_linear_map \ud835\udd5c (g \u2218 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (x : E) (hf : is_bounded_linear_map \ud835\udd5c f) : filter.tendsto f (nhds x) (nhds (f x)) := sorry\n\ntheorem continuous {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (hf : is_bounded_linear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (hf : is_bounded_linear_map \ud835\udd5c f) : filter.tendsto f (nhds 0) (nhds 0) :=\n  linear_map.map_zero (is_linear_map.mk' f (to_is_linear_map hf)) \u25b8 iff.mp continuous_iff_continuous_at (continuous hf) 0\n\ntheorem is_O_id {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (h : is_bounded_linear_map \ud835\udd5c f) (l : filter E) : asymptotics.is_O f (fun (x : E) => x) l := sorry\n\ntheorem is_O_comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {E : Type u_2} {g : F \u2192 G} (hg : is_bounded_linear_map \ud835\udd5c g) {f : E \u2192 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 \u22a4) le_top\n\ntheorem is_O_sub {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {f : E \u2192 F} (h : is_bounded_linear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] : is_bounded_linear_map \ud835\udd5c\n  fun (p : continuous_linear_map \ud835\udd5c E F \u00d7 continuous_linear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {\u03b9 : Type u_5} [DecidableEq \u03b9] [fintype \u03b9] {E : \u03b9 \u2192 Type u_2} [(i : \u03b9) \u2192 normed_group (E i)] [(i : \u03b9) \u2192 normed_space \ud835\udd5c (E i)] : is_bounded_linear_map \ud835\udd5c\n  fun (p : continuous_multilinear_map \ud835\udd5c E F \u00d7 continuous_multilinear_map \ud835\udd5c 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\u2081, ..., g m\u2099)` is a bounded linear operation. -/\ntheorem is_bounded_linear_map_continuous_multilinear_map_comp_linear {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {\u03b9 : Type u_5} [DecidableEq \u03b9] [fintype \u03b9] (g : continuous_linear_map \ud835\udd5c G E) : is_bounded_linear_map \ud835\udd5c\n  fun (f : continuous_multilinear_map \ud835\udd5c (fun (i : \u03b9) => E) F) =>\n    continuous_multilinear_map.comp_continuous_linear_map f fun (_x : \u03b9) => g := sorry\n\n/-- A map `f : E \u00d7 F \u2192 G` satisfies `is_bounded_bilinear_map \ud835\udd5c f` if it is bilinear and\ncontinuous. -/\nstructure is_bounded_bilinear_map (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] (f : E \u00d7 F \u2192 G) \nwhere\n  add_left : \u2200 (x\u2081 x\u2082 : E) (y : F), f (x\u2081 + x\u2082, y) = f (x\u2081, y) + f (x\u2082, y)\n  smul_left : \u2200 (c : \ud835\udd5c) (x : E) (y : F), f (c \u2022 x, y) = c \u2022 f (x, y)\n  add_right : \u2200 (x : E) (y\u2081 y\u2082 : F), f (x, y\u2081 + y\u2082) = f (x, y\u2081) + f (x, y\u2082)\n  smul_right : \u2200 (c : \ud835\udd5c) (x : E) (y : F), f (x, c \u2022 y) = c \u2022 f (x, y)\n  bound : \u2203 (C : \u211d), \u2203 (H : C > 0), \u2200 (x : E) (y : F), norm (f (x, y)) \u2264 C * norm x * norm y\n\nprotected theorem is_bounded_bilinear_map.is_O {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c f) : asymptotics.is_O f (fun (p : E \u00d7 F) => norm (prod.fst p) * norm (prod.snd p)) \u22a4 := sorry\n\ntheorem is_bounded_bilinear_map.is_O_comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} {\u03b1 : Type u_5} (H : is_bounded_bilinear_map \ud835\udd5c f) {g : \u03b1 \u2192 E} {h : \u03b1 \u2192 F} {l : filter \u03b1} : asymptotics.is_O (fun (x : \u03b1) => f (g x, h x)) (fun (x : \u03b1) => 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' {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c f) : asymptotics.is_O f (fun (p : E \u00d7 F) => norm p * norm p) \u22a4 :=\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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c f) (y : F) : is_bounded_linear_map \ud835\udd5c fun (x : E) => f (x, y) := sorry\n\ntheorem is_bounded_bilinear_map.is_bounded_linear_map_right {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c f) (x : E) : is_bounded_linear_map \ud835\udd5c fun (y : F) => f (x, y) := sorry\n\ntheorem is_bounded_bilinear_map_smul {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] : is_bounded_bilinear_map \ud835\udd5c fun (p : \ud835\udd5c \u00d7 E) => prod.fst p \u2022 prod.snd p := sorry\n\ntheorem is_bounded_bilinear_map_smul_algebra {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {\ud835\udd5c' : Type u_2} [normed_field \ud835\udd5c'] [normed_algebra \ud835\udd5c \ud835\udd5c'] {E : Type u_3} [normed_group E] [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c' E] [is_scalar_tower \ud835\udd5c \ud835\udd5c' E] : is_bounded_bilinear_map \ud835\udd5c fun (p : \ud835\udd5c' \u00d7 E) => prod.fst p \u2022 prod.snd p := sorry\n\ntheorem is_bounded_bilinear_map_mul {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] : is_bounded_bilinear_map \ud835\udd5c fun (p : \ud835\udd5c \u00d7 \ud835\udd5c) => prod.fst p * prod.snd p :=\n  is_bounded_bilinear_map_smul\n\ntheorem is_bounded_bilinear_map_comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] : is_bounded_bilinear_map \ud835\udd5c\n  fun (p : continuous_linear_map \ud835\udd5c E F \u00d7 continuous_linear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] (g : continuous_linear_map \ud835\udd5c F G) : is_bounded_linear_map \ud835\udd5c fun (f : continuous_linear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] (f : continuous_linear_map \ud835\udd5c E F) : is_bounded_linear_map \ud835\udd5c fun (g : continuous_linear_map \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] : is_bounded_bilinear_map \ud835\udd5c fun (p : continuous_linear_map \ud835\udd5c E F \u00d7 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 \u2192 \ud835\udd5c` and a scalar `c : F` the tensor product `f \u2297 c` as a continuous linear map from `E` to\n`F`, is a bounded bilinear map. -/\ntheorem is_bounded_bilinear_map_smul_right {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] : is_bounded_bilinear_map \ud835\udd5c\n  fun (p : continuous_linear_map \ud835\udd5c E \ud835\udd5c \u00d7 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {\u03b9 : Type u_2} {E : \u03b9 \u2192 Type u_5} [DecidableEq \u03b9] [fintype \u03b9] [(i : \u03b9) \u2192 normed_group (E i)] [(i : \u03b9) \u2192 normed_space \ud835\udd5c (E i)] : is_bounded_bilinear_map \ud835\udd5c\n  fun (p : continuous_linear_map \ud835\udd5c F G \u00d7 continuous_multilinear_map \ud835\udd5c 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 \u21a6 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 \u00d7 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c f) (p : E \u00d7 F) : linear_map \ud835\udd5c (E \u00d7 F) G :=\n  linear_map.mk (fun (q : E \u00d7 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 \u00d7 F`, as a continuous linear map\nfrom `E \u00d7 F` to `G`. -/\ndef is_bounded_bilinear_map.deriv {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c f) (p : E \u00d7 F) : continuous_linear_map \ud835\udd5c (E \u00d7 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c f) (p : E \u00d7 F) (q : E \u00d7 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 : \ud835\udd5c' \u00d7 \ud835\udd5c' \u2192 (\ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c')` is a bounded bilinear map. -/\ntheorem continuous_linear_map.lmul_left_right_is_bounded_bilinear (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] (\ud835\udd5c' : Type u_2) [normed_ring \ud835\udd5c'] [normed_algebra \ud835\udd5c \ud835\udd5c'] : is_bounded_bilinear_map \ud835\udd5c (continuous_linear_map.lmul_left_right \ud835\udd5c \ud835\udd5c') := 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] {f : E \u00d7 F \u2192 G} (h : is_bounded_bilinear_map \ud835\udd5c f) : is_bounded_linear_map \ud835\udd5c fun (p : E \u00d7 F) => is_bounded_bilinear_map.deriv h p := sorry\n\n/-- A linear isometry preserves the norm. -/\ntheorem linear_map.norm_apply_of_isometry {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] (f : linear_map \ud835\udd5c E F) {x : E} (hf : isometry \u21d1f) : 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] (f : linear_map \ud835\udd5c E F) (hf : isometry \u21d1f) (hfr : linear_map.range f = \u22a4) : continuous_linear_equiv \ud835\udd5c E F :=\n  continuous_linear_equiv.of_homothety \ud835\udd5c (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 .logic\n\nopen tactic\n\n-- def varstr (n : nat) := \"x\" ++ to_string n 11\n\nvariables {\u03b1 : Type}\n\n#check expr\n\nmeta def to_fm (\u03b1 \u03b2 : Type) (to_atom : nat \u2192 expr \u2192 tactic (\u03b1 \u00d7 list \u03b2)) : \n  nat \u2192 expr \u2192 tactic (fm \u03b1 \u00d7 list \u03b2) :=\nlet to_fm_bin (n) (c : fm \u03b1 \u2192 fm \u03b1 \u2192 fm \u03b1) (e1) (e2) := \n  do (p,bs1) \u2190 to_fm n e1, \n     (q,bs2) \u2190 to_fm (n + list.length bs1) e2, \n     return ((c p q), bs1++bs2) in\n\u03bb n e, \n  match e with \n  | `(true) := return (\u22a4',[]) \n  | `(false) := return (\u22a5',[]) \n  | `(\u00ac %%pe) := do (p,bs) \u2190 to_fm n pe, return (\u00ac' p, bs)\n  | `(%%pe \u2227 %%qe) := to_fm_bin n fm.and pe qe\n  | `(%%pe \u2228 %%qe) := to_fm_bin n fm.or  pe qe\n  | `(Exists %%e) :=\n    match e with \n    | (expr.lam _ _ d pe) := \n      do (p,bs) \u2190 to_fm (n+1) pe, \n         return (\u2203' p, bs)\n    | _ := failed\n    end\n  | e := do (a,bs) \u2190 to_atom n e, \n            return (A' a, bs)\n  end\n\n#exit\nmeta def to_fm_rec : expr \u2192 tactic (fm \u03b1) :=\nlet to_fm_rec_bin (c : fm \u03b1 \u2192 fm \u03b1 \u2192 fm \u03b1) (e1) (e2) := \n  do \u03c6 \u2190 to_fm_rec e1, \u03c8 \u2190 to_fm_rec e2, return $ c \u03c6 \u03c8 in\n\u03bb e, \n  match e with \n  | `(%%e1 \u2227 %%e2) := to_fm_rec_bin fm.and e1 e2\n  | `(%%e1 \u2228 %%e2) := to_fm_rec_bin fm.or  e1 e2\n  -- | `(%%e1 \u2194 %%e2) := to_fm_rec_bin fm.iff n e1 e2\n  | `(Exists %%e2) :=\n    let xs := varstr n in \n    do e' \u2190 to_fm_rec (n+1) e2, \n       return $ fm.ex xs $ inst_dbv_frm xs e' \n  -- | (expr.pi _ _ e1 e2) :=\n    -- monad.cond (is_prop e1) \n      -- (to_fm_rec_bin formula.Imp n e1 e2)\n      -- (let xs := varstr n in \n       -- do e' \u2190 to_fm_rec (n+1) e2, \n          -- return $ formula.Forall xs $ inst_dbv_frm xs e') \n  | _ := failed\n  end\n\nmeta def to_fm (e) := to_fm_rec 0 e \n\n\n-- example : forall (x : nat), exists (y : nat), x = 2 * y \u2228 x = 2 * y + 1 := sorry ", "meta": {"author": "avigad", "repo": "qelim", "sha": "b7d22864f1f0a2d21adad0f4fb3fc7ba665f8e60", "save_path": "github-repos/lean/avigad-qelim", "path": "github-repos/lean/avigad-qelim/qelim-b7d22864f1f0a2d21adad0f4fb3fc7ba665f8e60/common/to_fm.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851918, "lm_q2_score": 0.640635841117624, "lm_q1q2_score": 0.4927003577812736}}
{"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 \u27f6 Y be a morphism. Show that f is an epimorphism\nif and only if the diagram\n\nX --f--\u2192 Y\n|        |\nf        \ud835\udfd9\n|        |\n\u2193        \u2193\nY --\ud835\udfd9--\u2192 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 \u27f6 Y) [epi f] :\n  is_colimit (pushout_cocone.mk (\ud835\udfd9 Y) (\ud835\udfd9 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 \u27f6 Y)\n  (is_colim : is_colimit (pushout_cocone.mk (\ud835\udfd9 Y) (\ud835\udfd9 Y) rfl : pushout_cocone f f)) : epi f :=\n{ left_cancellation := \u03bb 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' : \u2200 (x y : P), dist x y = \u2225(x -\u1d65 y : V)\u2225)\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' : \u2200 (x y : P), dist x y = \u2225(x -\u1d65 y : V)\u2225)\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  [\u03b2 : normed_add_torsor V P] : semi_normed_add_torsor V P := { ..\u03b2 }\n\nvariables {\u03b1 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 = \u2225(x -\u1d65 y)\u2225 :=\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 +\u1d65 x) (v +\u1d65 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\u2081 v\u2082 : V) (x : P) :\n  dist (v\u2081 +\u1d65 x) (v\u2082 +\u1d65 x) = dist v\u2081 v\u2082 :=\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 +\u1d65 x) x = \u2225v\u2225 :=\nby simp [dist_eq_norm_vsub V _ x]\n\n@[simp] lemma dist_vadd_right (v : V) (x : P) : dist x (v +\u1d65 x) = \u2225v\u2225 :=\nby rw [dist_comm, dist_vadd_left]\n\n@[simp] lemma dist_vsub_cancel_left (x y z : P) : dist (x -\u1d65 y) (x -\u1d65 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 -\u1d65 z) (y -\u1d65 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 +\u1d65 p) (v' +\u1d65 p') \u2264 dist v v' + dist p p' :=\nby simpa using dist_triangle (v +\u1d65 p) (v' +\u1d65 p) (v' +\u1d65 p')\n\nlemma dist_vsub_vsub_le (p\u2081 p\u2082 p\u2083 p\u2084 : P) :\n  dist (p\u2081 -\u1d65 p\u2082) (p\u2083 -\u1d65 p\u2084) \u2264 dist p\u2081 p\u2083 + dist p\u2082 p\u2084 :=\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 +\u1d65 p) (v' +\u1d65 p') \u2264 nndist v v' + nndist p p' :=\nby simp only [\u2190 nnreal.coe_le_coe, nnreal.coe_add, \u2190 dist_nndist, dist_vadd_vadd_le]\n\nlemma nndist_vsub_vsub_le (p\u2081 p\u2082 p\u2083 p\u2084 : P) :\n  nndist (p\u2081 -\u1d65 p\u2082) (p\u2083 -\u1d65 p\u2084) \u2264 nndist p\u2081 p\u2083 + nndist p\u2082 p\u2084 :=\nby simp only [\u2190 nnreal.coe_le_coe, nnreal.coe_add, \u2190 dist_nndist, dist_vsub_vsub_le]\n\nlemma edist_vadd_vadd_le (v v' : V) (p p' : P) :\n  edist (v +\u1d65 p) (v' +\u1d65 p') \u2264 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\u2081 p\u2082 p\u2083 p\u2084 : P) :\n  edist (p\u2081 -\u1d65 p\u2082) (p\u2083 -\u1d65 p\u2084) \u2264 edist p\u2081 p\u2083 + edist p\u2082 p\u2084 :=\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 := \u03bb x y, \u2225(x -\u1d65 y : V)\u2225,\n  dist_self := \u03bb x, by simp,\n  dist_comm := \u03bb x y, by simp only [\u2190neg_vsub_eq_vsub_rev y x, norm_neg],\n  dist_triangle := begin\n    intros x y z,\n    change \u2225x -\u1d65 z\u2225 \u2264 \u2225x -\u1d65 y\u2225 + \u2225y -\u1d65 z\u2225,\n    rw \u2190vsub_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 := \u03bb x y, \u2225(x -\u1d65 y : V)\u2225,\n  dist_self := \u03bb x, by simp,\n  eq_of_dist_eq_zero := \u03bb x y h, by simpa using h,\n  dist_comm := \u03bb x y, by simp only [\u2190neg_vsub_eq_vsub_rev y x, norm_neg],\n  dist_triangle := begin\n    intros x y z,\n    change \u2225x -\u1d65 z\u2225 \u2264 \u2225x -\u1d65 y\u2225 + \u2225y -\u1d65 z\u2225,\n    rw \u2190vsub_add_vsub_cancel,\n    apply norm_add_le\n  end }\n\ninclude V\n\nlemma lipschitz_with.vadd [pseudo_emetric_space \u03b1] {f : \u03b1 \u2192 V} {g : \u03b1 \u2192 P} {Kf Kg : \u211d\u22650}\n  (hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :\n  lipschitz_with (Kf + Kg) (f +\u1d65 g) :=\n\u03bb x y,\ncalc edist (f x +\u1d65 g x) (f y +\u1d65 g y) \u2264 edist (f x) (f y) + edist (g x) (g y) :\n  edist_vadd_vadd_le _ _ _ _\n... \u2264 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 \u03b1] {f g : \u03b1 \u2192 P} {Kf Kg : \u211d\u22650}\n  (hf : lipschitz_with Kf f) (hg : lipschitz_with Kg g) :\n  lipschitz_with (Kf + Kg) (f -\u1d65 g) :=\n\u03bb x y,\ncalc edist (f x -\u1d65 g x) (f y -\u1d65 g y) \u2264 edist (f x) (f y) + edist (g x) (g y) :\n  edist_vsub_vsub_le _ _ _ _\n... \u2264 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 (\u03bb x : V \u00d7 P, x.1 +\u1d65 x.2) :=\n(lipschitz_with.prod_fst.vadd lipschitz_with.prod_snd).uniform_continuous\n\nlemma uniform_continuous_vsub : uniform_continuous (\u03bb x : P \u00d7 P, x.1 -\u1d65 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 (\u03bb x : P \u00d7 P, x.1 -\u1d65 x.2) :=\nuniform_continuous_vsub.continuous\n\nlemma filter.tendsto.vsub {l : filter \u03b1} {f g : \u03b1 \u2192 P} {x y : P}\n  (hf : tendsto f l (\ud835\udcdd x)) (hg : tendsto g l (\ud835\udcdd y)) :\n  tendsto (f -\u1d65 g) l (\ud835\udcdd (x -\u1d65 y)) :=\n(continuous_vsub.tendsto (x, y)).comp (hf.prod_mk_nhds hg)\n\nsection\n\nvariables [topological_space \u03b1]\n\nlemma continuous.vsub {f g : \u03b1 \u2192 P} (hf : continuous f) (hg : continuous g) :\n  continuous (f -\u1d65 g) :=\ncontinuous_vsub.comp (hf.prod_mk hg : _)\n\nlemma continuous_at.vsub {f g : \u03b1 \u2192 P}  {x : \u03b1} (hf : continuous_at f x) (hg : continuous_at g x) :\n  continuous_at (f -\u1d65 g) x :=\nhf.vsub hg\n\nlemma continuous_within_at.vsub {f g : \u03b1 \u2192 P} {x : \u03b1} {s : set \u03b1}\n  (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :\n  continuous_within_at (f -\u1d65 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 \u03b1} {f\u2081 f\u2082 : \u03b1 \u2192 P} {g : \u03b1 \u2192 R} {p\u2081 p\u2082 : P} {c : R}\n  (h\u2081 : tendsto f\u2081 l (\ud835\udcdd p\u2081)) (h\u2082 : tendsto f\u2082 l (\ud835\udcdd p\u2082)) (hg : tendsto g l (\ud835\udcdd c)) :\n  tendsto (\u03bb x, affine_map.line_map (f\u2081 x) (f\u2082 x) (g x)) l (\ud835\udcdd $ affine_map.line_map p\u2081 p\u2082 c) :=\n(hg.smul (h\u2082.vsub h\u2081)).vadd h\u2081\n\nlemma filter.tendsto.midpoint [invertible (2:R)] {l : filter \u03b1} {f\u2081 f\u2082 : \u03b1 \u2192 P} {p\u2081 p\u2082 : P}\n  (h\u2081 : tendsto f\u2081 l (\ud835\udcdd p\u2081)) (h\u2082 : tendsto f\u2082 l (\ud835\udcdd p\u2082)) :\n  tendsto (\u03bb x, midpoint R (f\u2081 x) (f\u2082 x)) l (\ud835\udcdd $ midpoint R p\u2081 p\u2082) :=\nh\u2081.line_map h\u2082 tendsto_const_nhds\n\nend\n\nsection normed_space\n\nvariables {\ud835\udd5c : Type*} [normed_field \ud835\udd5c] [semi_normed_space \ud835\udd5c V]\n\nopen affine_map\n\n@[simp] lemma dist_center_homothety (p\u2081 p\u2082 : P) (c : \ud835\udd5c) :\n  dist p\u2081 (homothety p\u2081 c p\u2082) = \u2225c\u2225 * dist p\u2081 p\u2082 :=\nby simp [homothety_def, norm_smul, \u2190 dist_eq_norm_vsub, dist_comm]\n\n@[simp] lemma dist_homothety_center (p\u2081 p\u2082 : P) (c : \ud835\udd5c) :\n  dist (homothety p\u2081 c p\u2082) p\u2081 = \u2225c\u2225 * dist p\u2081 p\u2082 :=\nby rw [dist_comm, dist_center_homothety]\n\n@[simp] lemma dist_homothety_self (p\u2081 p\u2082 : P) (c : \ud835\udd5c) :\n  dist (homothety p\u2081 c p\u2082) p\u2082 = \u22251 - c\u2225 * dist p\u2081 p\u2082 :=\nby rw [homothety_eq_line_map, \u2190 line_map_apply_one_sub, \u2190 homothety_eq_line_map,\n  dist_homothety_center, dist_comm]\n\n@[simp] lemma dist_self_homothety (p\u2081 p\u2082 : P) (c : \ud835\udd5c) :\n  dist p\u2082 (homothety p\u2081 c p\u2082) = \u22251 - c\u2225 * dist p\u2081 p\u2082 :=\nby rw [dist_comm, dist_homothety_self]\n\nvariables [invertible (2:\ud835\udd5c)]\n\n@[simp] lemma dist_left_midpoint (p\u2081 p\u2082 : P) :\n  dist p\u2081 (midpoint \ud835\udd5c p\u2081 p\u2082) = \u2225(2:\ud835\udd5c)\u2225\u207b\u00b9 * dist p\u2081 p\u2082 :=\nby rw [midpoint, \u2190 homothety_eq_line_map, dist_center_homothety, inv_of_eq_inv,\n  \u2190 normed_field.norm_inv]\n\n@[simp] lemma dist_midpoint_left (p\u2081 p\u2082 : P) :\n  dist (midpoint \ud835\udd5c p\u2081 p\u2082) p\u2081 = \u2225(2:\ud835\udd5c)\u2225\u207b\u00b9 * dist p\u2081 p\u2082 :=\nby rw [dist_comm, dist_left_midpoint]\n\n@[simp] lemma dist_midpoint_right (p\u2081 p\u2082 : P) :\n  dist (midpoint \ud835\udd5c p\u2081 p\u2082) p\u2082 = \u2225(2:\ud835\udd5c)\u2225\u207b\u00b9 * dist p\u2081 p\u2082 :=\nby rw [midpoint_comm, dist_midpoint_left, dist_comm]\n\n@[simp] lemma dist_right_midpoint (p\u2081 p\u2082 : P) :\n  dist p\u2082 (midpoint \ud835\udd5c p\u2081 p\u2082) = \u2225(2:\ud835\udd5c)\u2225\u207b\u00b9 * dist p\u2081 p\u2082 :=\nby rw [dist_comm, dist_midpoint_right]\n\nlemma dist_midpoint_midpoint_le' (p\u2081 p\u2082 p\u2083 p\u2084 : P) :\n  dist (midpoint \ud835\udd5c p\u2081 p\u2082) (midpoint \ud835\udd5c p\u2083 p\u2084) \u2264 (dist p\u2081 p\u2083 + dist p\u2082 p\u2084) / \u2225(2 : \ud835\udd5c)\u2225 :=\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, \u2190 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 \u211d V] [normed_space \u211d W]\n\nlemma dist_midpoint_midpoint_le (p\u2081 p\u2082 p\u2083 p\u2084 : V) :\n  dist (midpoint \u211d p\u2081 p\u2082) (midpoint \u211d p\u2083 p\u2084) \u2264 (dist p\u2081 p\u2083 + dist p\u2082 p\u2084) / 2 :=\nby simpa using dist_midpoint_midpoint_le' p\u2081 p\u2082 p\u2083 p\u2084\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 \u2192 Q)\n  (h : \u2200 x y, f (midpoint \u211d x y) = midpoint \u211d (f x) (f y))\n  (hfc : continuous f) :\n  P \u2192\u1d43[\u211d] Q :=\naffine_map.mk' f\n  \u2191((add_monoid_hom.of_map_midpoint \u211d \u211d\n    ((affine_equiv.vadd_const \u211d (f $ classical.arbitrary P)).symm \u2218 f \u2218\n      (affine_equiv.vadd_const \u211d (classical.arbitrary P))) (by simp)\n      (\u03bb 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  (\u03bb 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 {\u03b1:Type*}\n  (M M2:set \u03b1 \u2192 Prop):\n  M \u2264 M2 \u2194\n  (\u2200 X:set \u03b1, M X \u2192 M2 X)\n   :=\nbegin\n  refl,\nend\n\nlemma finset_union_measurable {\u03b1:Type*} {T:finset \u03b1} {\u03b2:Type*} [measurable_space \u03b2] {U:\u03b1 \u2192 set \u03b2}:\n  (\u2200 t\u2208 T, measurable_set (U t)) \u2192\n  measurable_set (\u22c3 x \u2208 T, U x) :=\nbegin\n  intros a,\n  have A1:(set.sUnion (set.image U ({a|a\u2208 T}:set \u03b1))) = (\u22c3 x \u2208 T, U x),\n  {\n    simp,\n  },\n  rw \u2190 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 {\u03b1:Type*} {T:finset \u03b1} {\u03b2:Type*} [measurable_space \u03b2] {U:\u03b1 \u2192 set \u03b2}:\n  (\u2200 t\u2208 T, measurable_set (U t)) \u2192\n  measurable_set (\u22c2 x \u2208 T, U x) :=\nbegin\n  intros a,\n  have A1:(set.sInter (set.image U ({a|a\u2208 T}:set \u03b1))) = (\u22c2 x \u2208 T, U x),\n  {\n    simp,\n  },\n  rw \u2190 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 {\u03b1:Type*}\n  (M:measurable_space \u03b1) (M2:measurable_space \u03b1):\n  M.measurable_set' \u2264  M2.measurable_set'\n  \u2194  M \u2264 M2 :=\nbegin\n  refl,\nend\n\nlemma measurable_space_le_def2 {\u03b1:Type*}\n  (M:measurable_space \u03b1) (M2:measurable_space \u03b1):\n  (\u2200 X:set \u03b1, M.measurable_set' X \u2192 M2.measurable_set' X) \u2194\n   M \u2264 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 {\u03b1:Type*}\n  (M:measurable_space \u03b1) (M2:measurable_space \u03b1):\n  (\u2200 X:set \u03b1, M.measurable_set' X \u2192 M2.measurable_set' X) \u2192\n   M \u2264 M2 :=\nbegin\n  intros a,\n  have A1:M.measurable_set' \u2264  M2.measurable_set'\n  \u2194  M \u2264 M2,\n  {\n    apply measurable_space_le_def,\n  },\n  apply A1.mp,\n  have A2:M.measurable_set' \u2264 M2.measurable_set' \u2194\n  (\u2200 X:set \u03b1, M.measurable_set' X \u2192 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 {\u03b1 \u03b2:Type*}\n  [M1:measurable_space \u03b1] [M2:measurable_space \u03b2] (f:\u03b1 \u2192 \u03b2):\n  (\u2200 B:(set \u03b2), (measurable_set B) \u2192 measurable_set (f \u207b\u00b9' B))\n  \u2194 (measurable f) :=\nbegin\n  unfold measurable,\nend\n\nlemma measurable_intro {\u03b1 \u03b2:Type*}\n  [measurable_space \u03b1] [measurable_space \u03b2] (f:\u03b1 \u2192 \u03b2):\n  (\u2200 B:(set \u03b2), measurable_set B \u2192 measurable_set (f \u207b\u00b9' B))\n  \u2192 (measurable f) :=\nbegin\n  apply (measurable_def _).mp,\nend\n\nlemma measurable_elim {\u03b1 \u03b2:Type*}\n  [measurable_space \u03b1] [measurable_space \u03b2] (f:\u03b1 \u2192 \u03b2) (B:set \u03b2):\n  (measurable f)\u2192 (measurable_set B) \u2192 (measurable_set (f \u207b\u00b9' 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 {\u03b1 \u03b2:Type*}\n  [M1:measurable_space \u03b1] [M2:measurable_space \u03b2]:\n  (@prod.measurable_space \u03b1 \u03b2 M1 M2) = M1.comap prod.fst \u2294 M2.comap prod.snd :=\nbegin\n  refl\nend\n\n\nlemma comap_elim {\u03b1 \u03b2:Type*} [M2:measurable_space \u03b2] (f:\u03b1 \u2192 \u03b2) (B:set \u03b2):\n  (measurable_set B) \u2192\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 {\u03b1 \u03b2:Type*} [M1:measurable_space \u03b1] [M2:measurable_space \u03b2] (f:\u03b1 \u2192 \u03b2):\n  (M2.comap f) \u2264 M1 \u2192 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 \u2190 measurable_space_le_def2 at a,\n  apply a,\n  apply A1,\nend\n\nlemma fst_measurable {\u03b1 \u03b2:Type*}\n  [M1:measurable_space \u03b1] [M2:measurable_space \u03b2]:measurable (\u03bb x:(\u03b1 \u00d7 \u03b2), x.fst) :=\nbegin\n  apply measurable_comap,\n  have A1:M1.comap prod.fst \u2264 (@prod.measurable_space \u03b1 \u03b2 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 {\u03b1 \u03b2:Type*}\n  [M1:measurable_space \u03b1] [M2:measurable_space \u03b2]:measurable (\u03bb x:(\u03b1 \u00d7 \u03b2), x.snd) :=\nbegin\n  apply measurable_comap,\n  have A1:M2.comap prod.snd \u2264 (@prod.measurable_space \u03b1 \u03b2 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 {\u03b1 \u03b2:Type*} {B:set (set \u03b2)}\n  (f:\u03b1 \u2192 \u03b2):\n  @measurable_space.comap \u03b1 \u03b2 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 {\u03b1 \u03b2:Type*} {B\u03b1:set (set \u03b1)}:\n  (measurable_space.generate_from B\u03b1).comap (@prod.fst \u03b1 \u03b2) =\n  measurable_space.generate_from {U:set (\u03b1 \u00d7 \u03b2)|\u2203 A\u2208 B\u03b1, 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 {\u03b1 \u03b2:Type*} {B\u03b2:set (set \u03b2)}:\n  (measurable_space.generate_from B\u03b2).comap (@prod.snd \u03b1 \u03b2) =\n  measurable_space.generate_from {U:set (\u03b1 \u00d7 \u03b2)|\u2203 B\u2208 B\u03b2, 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 {\u03b1:Type*} {B C:set (set \u03b1)}:\n  (measurable_space.generate_from B) \u2294 (measurable_space.generate_from C) =\n  (measurable_space.generate_from (B \u222a C)) :=\nbegin\n  apply measurable_space.generate_from_sup_generate_from,\nend\n\nlemma prod_measurable_space_def {\u03b1 \u03b2:Type*} {B\u03b1:set (set \u03b1)}\n  {B\u03b2:set (set \u03b2)}:\n  (@prod.measurable_space \u03b1 \u03b2 (measurable_space.generate_from B\u03b1)\n  (measurable_space.generate_from B\u03b2)) =\n  @measurable_space.generate_from (\u03b1 \u00d7 \u03b2) (\n    {U:set (\u03b1 \u00d7 \u03b2)|\u2203 A\u2208 B\u03b1, U = set.prod A set.univ} \u222a\n    {U:set (\u03b1 \u00d7 \u03b2)|\u2203 B\u2208 B\u03b2, 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 {\u03b1:Type*} {S:set (set \u03b1)} (a:\u03b1):\n  (set.sUnion S = set.univ) \u2192 (\u2203 T\u2208S, a\u2208 T) :=\nbegin\n  intro A1,\n  have A2:a\u2208 set.univ := set.mem_univ a,\n  rw \u2190 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 {\u03b1 \u03b2:Type*} {B\u03b1:set (set \u03b1)}\n  {B\u03b2:set (set \u03b2)}:\n  @measurable_space.generate_from (\u03b1 \u00d7 \u03b2) \n    {U:set (\u03b1 \u00d7 \u03b2)|\u2203 A\u2208 B\u03b1, \u2203 B\u2208B\u03b2,  U = set.prod A B} \u2264\n  (@prod.measurable_space \u03b1 \u03b2 (measurable_space.generate_from B\u03b1)\n  (measurable_space.generate_from B\u03b2))\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 \u03b2)) \u2229 \n          (set.prod (@set.univ \u03b1) 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 \u2190 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 {\u03b1 \u03b2:Type*} {B\u03b1:set (set \u03b1)}\n  {B\u03b2:set (set \u03b2)} {C\u03b1:set (set \u03b1)} {C\u03b2:set (set \u03b2)}:\n  (set.countable C\u03b1) \u2192\n  (set.countable C\u03b2) \u2192\n  (C\u03b1 \u2286 B\u03b1) \u2192\n  (C\u03b2 \u2286 B\u03b2) \u2192\n  (set.sUnion C\u03b1 = set.univ) \u2192\n  (set.sUnion C\u03b2 = set.univ) \u2192\n  (@prod.measurable_space \u03b1 \u03b2 (measurable_space.generate_from B\u03b1)\n  (measurable_space.generate_from B\u03b2)) =\n  @measurable_space.generate_from (\u03b1 \u00d7 \u03b2) \n    {U:set (\u03b1 \u00d7 \u03b2)|\u2203 A\u2208 B\u03b1, \u2203 B\u2208B\u03b2,  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\u03b2), \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 (\u03bb x, set.prod x B)  C\u03b1), \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 {\u03b1 \u03b2:Type*} (f:\u03b1 \u2192 \u03b2) (S:set \u03b2):\n  (f \u207b\u00b9' S\u1d9c) = ((f \u207b\u00b9' S)\u1d9c) :=\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 {\u03b1 \u03b2:Type*} (f:\u03b1 \u2192 \u03b2) (g:\u2115 \u2192 set \u03b2):\n   (f \u207b\u00b9' \u22c3 (i : \u2115), g i)=(\u22c3 (i : \u2115), f \u207b\u00b9' (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 {\u03b1 \u03b2:Type*} [M:measurable_space \u03b1] [M2:measurable_space \u03b2]\n   (X:set (set \u03b2)) (f:\u03b1 \u2192 \u03b2):\n   (measurable_space.generate_from X = M2)\u2192\n   (\u2200 B\u2208 X, measurable_set (set.preimage f B))\u2192\n   (measurable f) :=\nbegin\n  intros a a_1,\n  apply measurable_intro,\n  intros B a_2,\n  have A1:@measurable_set \u03b2 (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  { -- \u22a2 measurable_set (f \u207b\u00b9' -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_\u1fb0,\n    }\n  }\nend\n\n\nlemma generate_from_self {\u03b1:Type*}\n  (M:measurable_space \u03b1):\n  M = measurable_space.generate_from {s : set \u03b1|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 {\u03b1 \u03b2:Type*}\n  [M2:measurable_space \u03b2]  (f:\u03b1 \u2192 \u03b2):\n  measurable_space.comap f M2 = measurable_space.generate_from\n  {s : set \u03b1|\u2203 (s' : set \u03b2), measurable_space.measurable_set' M2 s' \u2227 f \u207b\u00b9' s' = s} :=\nbegin\n  unfold measurable_space.comap,\n  apply generate_from_self,\nend\n\n\n\n\nlemma measurable_fun_product_measurable {\u03b1 \u03b2 \u03b3:Type*}\n  [M1:measurable_space \u03b1] [M2:measurable_space \u03b2] [M3:measurable_space \u03b3]\n  (X: \u03b1 \u2192  \u03b2) (Y: \u03b1 \u2192 \u03b3):\n  measurable X \u2192\n  measurable Y \u2192\n  measurable (\u03bb a:\u03b1, prod.mk (X a) (Y a)) :=\nbegin\n  intros B1 B2,\n  have A1:@measurable _ _ _ (@prod.measurable_space \u03b2 \u03b3 M2 M3) (\u03bb a:\u03b1, prod.mk (X a) (Y a)),\n  {\n    have A1A:(@prod.measurable_space \u03b2  \u03b3  M2 M3)=measurable_space.generate_from (\n      {s : set (\u03b2 \u00d7 \u03b3) | \u2203 (s' : set \u03b2), measurable_space.measurable_set' M2 s' \u2227 prod.fst \u207b\u00b9' s' = s} \u222a\n      {s : set (\u03b2  \u00d7 \u03b3) | \u2203 (s' : set \u03b3), measurable_space.measurable_set' M3 s' \u2227 prod.snd \u207b\u00b9' 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:(\u03bb (a : \u03b1), (X a, Y a)) \u207b\u00b9' (prod.fst \u207b\u00b9' B) = (X \u207b\u00b9' 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:(\u03bb (a : \u03b1), (X a, Y a)) \u207b\u00b9' (prod.snd \u207b\u00b9' C) = (Y \u207b\u00b9' 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 {\u03b1 \u03b2 \u03b3:Type*}\n  [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3]\n  (X:\u03b2 \u2192 \u03b3) (Y: \u03b1\u2192  \u03b2):\n  measurable X \u2192\n  measurable Y \u2192\n  measurable (X \u2218 Y) :=\nbegin\n  intros B1 B2,\n  apply measurable_intro,\n  intros B a,\n  have A1:(X \u2218 Y \u207b\u00b9' B)=(Y \u207b\u00b9' (X \u207b\u00b9' 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 {\u03a9:Type*} [measurable_space \u03a9] {\u03b2:Type*} [measurable_space \u03b2] (c:\u03b2):\n  (measurable (\u03bb \u03c9:\u03a9, c)) :=\nbegin\n  apply measurable_const,\nend\n\nlemma measurable_set_of_le_of_measurable_set\n{\u03b1 : Type*} {M1 : measurable_space \u03b1} {M2 : measurable_space \u03b1} \n  {X:set \u03b1}:\n  M1 \u2264 M2 \u2192\nmeasurable_space.measurable_set' M1 X \u2192\n   measurable_space.measurable_set' M2 X :=\nbegin\n  intros A2 A1,\n  rw \u2190 measurable_space_le_def2 at A2,\n  apply A2,\n  apply A1,\nend\n\n-- cf. measurable_set_prod\nlemma measurable_set_prod' {\u03b2 : Type*} {\u03b3 : Type*}\n  {M\u03b2 : measurable_space \u03b2} {M\u03b3 : measurable_space \u03b3} \n  {X:set \u03b2} {Y:set \u03b3}:measurable_set X \u2192\n   measurable_set Y \u2192\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\u03b2,\n  rw generate_from_self M\u03b3,\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 {\u03b1 \u03b2:Type*} [measurable_space \u03b1] [measurable_space \u03b2] {f:\u03b1 \u2192 \u03b2}\n   {S:set \u03b2}:measurable f \u2192 measurable_set S \u2192 measurable_set (set.preimage f S) :=\nbegin\n  intros A1 A2,\n  apply A1,\n  apply A2,\nend\n\nlemma measurable.if {\u03b1 \u03b2:Type*}\n  {M\u03b1:measurable_space \u03b1} {M\u03b2:measurable_space \u03b2}\n  {E:set \u03b1} {D:decidable_pred E}\n  {X Y:\u03b1 \u2192 \u03b2}:measurable_set E \u2192\n  measurable X \u2192\n  measurable Y \u2192\n  measurable (\u03bb a:\u03b1, 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' {\u03b1:Type*} [F:fintype \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)]\n  {P:\u03a0 a, set (\u03b2 a)} (T:set \u03b1):(\u2200 a, measurable_set (P a)) \u2192\n  measurable_set (set.pi T P) := begin\n  classical,\n  intros A0,\n  have A1:(set.pi T P) = \u22c2 (a \u2208 T), ((\u03bb (p:\u03a0 a, \u03b2 a), p a) \u207b\u00b9' (P a)),\n  { ext x, simp,  },\n  rw A1,\n  have A3:trunc (encodable \u03b1) := encodable.trunc_encodable_of_fintype \u03b1,\n  trunc_cases A3,\n  haveI:encodable \u03b1 := A3,\n  apply measurable_set.Inter,\n  intros a',\n  cases classical.em (a' \u2208 T) with A4 A4,\n  { have A5:(\u22c2 (H : a' \u2208 T), (\u03bb (p : \u03a0 (a : \u03b1), \u03b2 a), p a') \u207b\u00b9' P a') =\n            (\u03bb (p : \u03a0 (a : \u03b1), \u03b2 a), p a') \u207b\u00b9' 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 (\u03bb (p:\u03a0 a, \u03b2 a), p a') (M a') \u2264 measurable_space.pi,\n    { simp [measurable_space.pi], apply @le_supr (measurable_space (\u03a0 a, \u03b2 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:(\u22c2 (H : a' \u2208 T), (\u03bb (p : \u03a0 (a : \u03b1), \u03b2 a), p a') \u207b\u00b9' 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 {\u03b1:Type*} {s t:set (set \u03b1)}:\n  (s \u2286 t) \u2192 \n  (\u2200 u, (measurable_space.generate_measurable s u \u2192 \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 `\u03b1`, in this file we define\n\n* `set.proj_Icc (a b : \u03b1) (h : a \u2264 b)` to be the map `\u03b1 \u2192 [a, b]` sending `(-\u221e, a]` to `a`, `[b, \u221e)`\n  to `b`, and each point `x \u2208 [a, b]` to itself;\n* `set.Icc_extend {a b : \u03b1} (h : a \u2264 b) (f : Icc a b \u2192 \u03b2)` to be the extension of `f` to `\u03b1` defined\n  as `f \u2218 proj_Icc a b h`.\n\nWe also prove some trivial properties of these maps.\n-/\n\n\nvariable {\u03b1 \u03b2 : Type _} [LinearOrder \u03b1]\n\nopen Function\n\nnamespace Set\n\n#print Set.projIcc /-\n/-- Projection of `\u03b1` to the closed interval `[a, b]`. -/\ndef projIcc (a b : \u03b1) (h : a \u2264 b) (x : \u03b1) : Icc a b :=\n  \u27e8max a (min b x), le_max_left _ _, max_le h (min_le_left _ _)\u27e9\n#align set.proj_Icc Set.projIcc\n-/\n\nvariable {a b : \u03b1} (h : a \u2264 b) {x : \u03b1}\n\n#print Set.projIcc_of_le_left /-\ntheorem projIcc_of_le_left (hx : x \u2264 a) : projIcc a b h x = \u27e8a, left_mem_Icc.2 h\u27e9 := 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 = \u27e8a, left_mem_Icc.2 h\u27e9 :=\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 \u2264 x) : projIcc a b h x = \u27e8b, right_mem_Icc.2 h\u27e9 := 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 = \u27e8b, right_mem_Icc.2 h\u27e9 :=\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 = \u27e8a, left_mem_Icc.mpr h.le\u27e9 \u2194 x \u2264 a :=\n  by\n  refine' \u27e8fun h' => _, proj_Icc_of_le_left _\u27e9\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 = \u27e8b, right_mem_Icc.mpr h.le\u27e9 \u2194 b \u2264 x :=\n  by\n  refine' \u27e8fun h' => _, proj_Icc_of_right_le _\u27e9\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 \u2208 Icc a b) : projIcc a b h x = \u27e8x, hx\u27e9 := 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  \u27e8x, x.2, projIcc_val h x\u27e9\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 => \u27e8x, projIcc_val h x\u27e9\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] \u2192 \u03b2` to a map `\u03b1 \u2192 \u03b2`. -/\ndef IccExtend {a b : \u03b1} (h : a \u2264 b) (f : Icc a b \u2192 \u03b2) : \u03b1 \u2192 \u03b2 :=\n  f \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2), Eq.{succ u2} (Set.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f)) (Set.range.{u2, succ u1} \u03b2 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) (f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2), Eq.{succ u1} (Set.{u1} \u03b2) (Set.range.{u1, succ u2} \u03b2 \u03b1 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f)) (Set.range.{u1, succ u2} \u03b2 (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) f)\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_range Set.IccExtend_range\u2093'. -/\n@[simp]\ntheorem IccExtend_range (f : Icc a b \u2192 \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) {x : \u03b1} (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2), (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) x a) -> (Eq.{succ u2} \u03b2 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f x) (f (Subtype.mk.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) a (Iff.mpr (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) (Set.left_mem_Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b) h))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) {x : \u03b1} (f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2), (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) x a) -> (Eq.{succ u1} \u03b2 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f x) (f (Subtype.mk.{succ u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) a (Iff.mpr (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) (Set.left_mem_Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b) h))))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_of_le_left Set.IccExtend_of_le_left\u2093'. -/\ntheorem IccExtend_of_le_left (f : Icc a b \u2192 \u03b2) (hx : x \u2264 a) :\n    IccExtend h f x = f \u27e8a, left_mem_Icc.2 h\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2), Eq.{succ u2} \u03b2 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f a) (f (Subtype.mk.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) a (Iff.mpr (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) (Set.left_mem_Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b) h)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) (f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2), Eq.{succ u1} \u03b2 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f a) (f (Subtype.mk.{succ u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) a (Iff.mpr (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) (Set.left_mem_Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b) h)))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_left Set.IccExtend_left\u2093'. -/\n@[simp]\ntheorem IccExtend_left (f : Icc a b \u2192 \u03b2) : IccExtend h f a = f \u27e8a, left_mem_Icc.2 h\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) {x : \u03b1} (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2), (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) b x) -> (Eq.{succ u2} \u03b2 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f x) (f (Subtype.mk.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) b (Iff.mpr (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) b (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) (Set.right_mem_Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b) h))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) {x : \u03b1} (f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2), (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) b x) -> (Eq.{succ u1} \u03b2 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f x) (f (Subtype.mk.{succ u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) b (Iff.mpr (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) b (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) (Set.right_mem_Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b) h))))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_of_right_le Set.IccExtend_of_right_le\u2093'. -/\ntheorem IccExtend_of_right_le (f : Icc a b \u2192 \u03b2) (hx : b \u2264 x) :\n    IccExtend h f x = f \u27e8b, right_mem_Icc.2 h\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2), Eq.{succ u2} \u03b2 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f b) (f (Subtype.mk.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) b (Iff.mpr (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) b (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) (Set.right_mem_Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b) h)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) (f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2), Eq.{succ u1} \u03b2 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f b) (f (Subtype.mk.{succ u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) b (Iff.mpr (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) b (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) (Set.right_mem_Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b) h)))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_right Set.IccExtend_right\u2093'. -/\n@[simp]\ntheorem IccExtend_right (f : Icc a b \u2192 \u03b2) : IccExtend h f b = f \u27e8b, right_mem_Icc.2 h\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) {x : \u03b1} (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (hx : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)), Eq.{succ u2} \u03b2 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f x) (f (Subtype.mk.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) x hx))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) {x : \u03b1} (f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2) (hx : Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)), Eq.{succ u1} \u03b2 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f x) (f (Subtype.mk.{succ u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) x hx))\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_of_mem Set.IccExtend_of_mem\u2093'. -/\ntheorem IccExtend_of_mem (f : Icc a b \u2192 \u03b2) (hx : x \u2208 Icc a b) : IccExtend h f x = f \u27e8x, hx\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) (f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (x : coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)), Eq.{succ u2} \u03b2 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)))))) x)) (f x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) (f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2) (x : Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)), Eq.{succ u1} \u03b2 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f (Subtype.val.{succ u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) x)) (f x)\nCase conversion may be inaccurate. Consider using '#align set.Icc_extend_coe Set.Icc_extend_coe\u2093'. -/\n@[simp]\ntheorem Icc_extend_coe (f : Icc a b \u2192 \u03b2) (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 \u03b2] {a b : \u03b1} (h : a \u2264 b) {f : Icc a b \u2192 \u03b2}\n\n/- warning: monotone.Icc_extend -> Monotone.IccExtend is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) {f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2}, (Monotone.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2 (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))) _inst_2 f) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) {f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2}, (Monotone.{u2, u1} (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) \u03b2 (Subtype.preorder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b))) _inst_2 f) -> (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_2 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f))\nCase conversion may be inaccurate. Consider using '#align monotone.Icc_extend Monotone.IccExtend\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {a : \u03b1} {b : \u03b1} (h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b) {f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2}, (StrictMono.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2 (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))) _inst_2 f) -> (StrictMonoOn.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {a : \u03b1} {b : \u03b1} (h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b) {f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2}, (StrictMono.{u2, u1} (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) \u03b2 (Subtype.preorder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b))) _inst_2 f) -> (StrictMonoOn.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_2 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f) (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b))\nCase conversion may be inaccurate. Consider using '#align strict_mono.strict_mono_on_Icc_extend StrictMono.strictMonoOn_IccExtend\u2093'. -/\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 \u2228 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.\u03b1\n  +\n  mv_polynomial.C B * X vars.\u03b2\n\ndef proof2 : mv_polynomial vars F := \n  mv_polynomial.C C * X vars.\u03b1\n  +\n  mv_polynomial.C D * X vars.\u03b2\n\ndef proof3 : mv_polynomial vars F := \n  mv_polynomial.C E * X vars.\u03b1 * X vars.\u03b2\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 \u03b1 2 + single \u03b2 0)) eqn,\n  have h11 := congr_arg (coeff (single \u03b1 1 + single \u03b2 1)) eqn,\n  have h02 := congr_arg (coeff (single \u03b1 0 + single \u03b2 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 \u2264 k < u`. -/\ndef Ico (l : \u2115+) (u : \u2115+) : finset \u2115+ :=\n  finset.map\n    (function.embedding.mk\n      (fun (n : Subtype fun (x : \u2115) => x \u2208 finset.Ico \u2191l \u2191u) => { val := \u2191n, property := sorry })\n      sorry)\n    (finset.attach (finset.Ico \u2191l \u2191u))\n\n@[simp] theorem Ico.mem {n : \u2115+} {m : \u2115+} {l : \u2115+} : l \u2208 Ico n m \u2194 n \u2264 l \u2227 l < m := sorry\n\n@[simp] theorem Ico.card (l : \u2115+) (u : \u2115+) : finset.card (Ico l u) = \u2191u - \u2191l := 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 _ \u2192 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 \u2192 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 \u2194 s \u2286 interior R s :=\nsubset_interior_iff_open.symm\n\nlemma mem_interior_iff {s : set X} {x : X} :\n  x \u2208 interior R s \u2194\n  \u2203 (l u : fin _ \u2192 R), (\u2200 i, l i < coords R x i \u2227 coords R x i < u i)\n    \u2227 \u2200 y, (\u2200 i, l i < coords R y i \u2227 coords R y i < u i) \u2192 y \u2208 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 _ \u2192 R` for the types of `l`, `u`?\n  -- bring back instance for `fin n \u2192 R` (or `fin n \u2192 X`)?\n  suffices : def_set S\n    {x | \u2203 (l u : finvec _ R), (\u2200 i, l i < coords R x i \u2227 coords R x i < u i)\n         \u2227 \u2200 y, (\u2200 i, l i < coords R y i \u2227 coords R y i < u i) \u2192 y \u2208 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\u1d50\u1d52\u1d56` for the monoidal opposite of a monoidal category `C`.\n-/\n\n\nuniverse v\u2081 v\u2082 u\u2081 u\u2082\n\nvariable {C : Type u\u2081}\n\nnamespace CategoryTheory\n\nopen CategoryTheory.MonoidalCategory\n\n/-- A type synonym for the monoidal opposite. Use the notation `C\u1d39\u1d52\u1d56`. -/\n@[nolint has_nonempty_instance]\ndef MonoidalOpposite (C : Type u\u2081) :=\n  C\n#align category_theory.monoidal_opposite CategoryTheory.MonoidalOpposite\n\nnamespace MonoidalOpposite\n\n-- mathport name: \u00abexpr \u1d39\u1d52\u1d56\u00bb\nnotation:max C \"\u1d39\u1d52\u1d56\" => MonoidalOpposite C\n\n/-- Think of an object of `C` as an object of `C\u1d39\u1d52\u1d56`. -/\n@[pp_nodot]\ndef mop (X : C) : C\u1d39\u1d52\u1d56 :=\n  X\n#align category_theory.monoidal_opposite.mop CategoryTheory.MonoidalOpposite.mop\n\n/-- Think of an object of `C\u1d39\u1d52\u1d56` as an object of `C`. -/\n@[pp_nodot]\ndef unmop (X : C\u1d39\u1d52\u1d56) : C :=\n  X\n#align category_theory.monoidal_opposite.unmop CategoryTheory.MonoidalOpposite.unmop\n\ntheorem op_injective : Function.Injective (mop : C \u2192 C\u1d39\u1d52\u1d56) := fun _ _ => id\n#align category_theory.monoidal_opposite.op_injective CategoryTheory.MonoidalOpposite.op_injective\n\ntheorem unop_injective : Function.Injective (unmop : C\u1d39\u1d52\u1d56 \u2192 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 \u2194 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\u1d39\u1d52\u1d56) : unmop x = unmop y \u2194 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\u1d39\u1d52\u1d56) : 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\u2081} C] : Category C\u1d39\u1d52\u1d56\n    where\n  Hom X Y := unmop X \u27f6 unmop Y\n  id X := \ud835\udfd9 (unmop X)\n  comp X Y Z f g := f \u226b 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\u2081} C]\n\n/-- The monoidal opposite of a morphism `f : X \u27f6 Y` is just `f`, thought of as `mop X \u27f6 mop Y`. -/\ndef Quiver.Hom.mop {X Y : C} (f : X \u27f6 Y) : @Quiver.Hom C\u1d39\u1d52\u1d56 _ (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 \u27f6 mop Y` as a morphism `X \u27f6 Y`. -/\ndef Quiver.Hom.unmop {X Y : C\u1d39\u1d52\u1d56} (f : X \u27f6 Y) : unmop X \u27f6 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 \u27f6 Y) \u2192 (mop X \u27f6 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\u1d39\u1d52\u1d56} :\n    Function.Injective (Quiver.Hom.unmop : (X \u27f6 Y) \u2192 (unmop X \u27f6 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 \u27f6 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\u1d39\u1d52\u1d56} {f : X \u27f6 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 \u27f6 Y} {g : Y \u27f6 Z} : (f \u226b g).mop = f.mop \u226b g.mop :=\n  rfl\n#align category_theory.mop_comp CategoryTheory.mop_comp\n\n@[simp]\ntheorem mop_id {X : C} : (\ud835\udfd9 X).mop = \ud835\udfd9 (mop X) :=\n  rfl\n#align category_theory.mop_id CategoryTheory.mop_id\n\n@[simp]\ntheorem unmop_comp {X Y Z : C\u1d39\u1d52\u1d56} {f : X \u27f6 Y} {g : Y \u27f6 Z} : (f \u226b g).unmop = f.unmop \u226b g.unmop :=\n  rfl\n#align category_theory.unmop_comp CategoryTheory.unmop_comp\n\n@[simp]\ntheorem unmop_id {X : C\u1d39\u1d52\u1d56} : (\ud835\udfd9 X).unmop = \ud835\udfd9 (unmop X) :=\n  rfl\n#align category_theory.unmop_id CategoryTheory.unmop_id\n\n@[simp]\ntheorem unmop_id_mop {X : C} : (\ud835\udfd9 (mop X)).unmop = \ud835\udfd9 X :=\n  rfl\n#align category_theory.unmop_id_mop CategoryTheory.unmop_id_mop\n\n@[simp]\ntheorem mop_id_unmop {X : C\u1d39\u1d52\u1d56} : (\ud835\udfd9 (unmop X)).mop = \ud835\udfd9 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\u1d39\u1d52\u1d56`. -/\n@[simps]\ndef mop (f : X \u2245 Y) : mop X \u2245 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\u2081} 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\u1d52\u1d56\n    where\n  tensorObj X Y := op (unop X \u2297 unop Y)\n  tensorHom X\u2081 Y\u2081 X\u2082 Y\u2082 f g := (f.unop \u2297 g.unop).op\n  tensorUnit := op (\ud835\udfd9_ C)\n  associator X Y Z := (\u03b1_ (unop X) (unop Y) (unop Z)).symm.op\n  leftUnitor X := (\u03bb_ (unop X)).symm.op\n  rightUnitor X := (\u03c1_ (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\u1d52\u1d56) : X \u2297 Y = op (unop X \u2297 unop Y) :=\n  rfl\n#align category_theory.op_tensor_obj CategoryTheory.op_tensorObj\n\ntheorem op_tensorUnit : \ud835\udfd9_ C\u1d52\u1d56 = op (\ud835\udfd9_ 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\u1d39\u1d52\u1d56\n    where\n  tensorObj X Y := mop (unmop Y \u2297 unmop X)\n  tensorHom X\u2081 Y\u2081 X\u2082 Y\u2082 f g := (g.unmop \u2297 f.unmop).mop\n  tensorUnit := mop (\ud835\udfd9_ C)\n  associator X Y Z := (\u03b1_ (unmop Z) (unmop Y) (unmop X)).symm.mop\n  leftUnitor X := (\u03c1_ (unmop X)).mop\n  rightUnitor X := (\u03bb_ (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\u1d39\u1d52\u1d56) : X \u2297 Y = mop (unmop Y \u2297 unmop X) :=\n  rfl\n#align category_theory.mop_tensor_obj CategoryTheory.mop_tensorObj\n\ntheorem mop_tensorUnit : \ud835\udfd9_ C\u1d39\u1d52\u1d56 = mop (\ud835\udfd9_ 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 (\u03b1 : Type u) :=\n(x : \u03b1) (f : \u03b1 \u2192 \u03b1 := \u03bb x => x)\n\nstructure B (\u03b1 : Type u) extends A \u03b1 :=\n(y : \u03b1 := f (f x)) (g : \u03b1 \u2192 \u03b1 \u2192 \u03b1 := \u03bb x y => f x)\n\nstructure C (\u03b1 : Type u) extends B \u03b1 :=\n(z : \u03b1 := 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 \u00d7 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": "example (x : Nat) : x + 1 > 0 := by\n  induction x\n  decide\n  --^ $/lean/plainGoal\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/anonHyp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7401743620390162, "lm_q2_score": 0.6654105521116443, "lm_q1q2_score": 0.4925198309032659}}
{"text": "/-\nCopyright \u00a9 2020 Nicol\u00f2 Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicol\u00f2 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` \u00d7 `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 \ud835\udd5c 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 \u00d7 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 \ud835\udd5c 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 {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E] (I : model_with_corners \ud835\udd5c 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 (\u03bb 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 {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E] (I : model_with_corners \ud835\udd5c 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 (\u03bb a:G, a\u207b\u00b9))\n\nsection lie_group\n\nvariables {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\n{H : Type*} [topological_space H]\n{E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E] {I : model_with_corners \ud835\udd5c E H}\n{F : Type*} [normed_add_comm_group F] [normed_space \ud835\udd5c F] {J : model_with_corners \ud835\udd5c 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 \ud835\udd5c E']\n{H' : Type*} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'}\n{M : Type*} [topological_space M] [charted_space H' M]\n{E'' : Type*} [normed_add_comm_group E''] [normed_space \ud835\udd5c E'']\n{H'' : Type*} [topological_space H''] {I'' : model_with_corners \ud835\udd5c 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 (\u03bb x : G, x\u207b\u00b9) :=\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 \u2192 G}\n  (hf : smooth I' I f) : smooth I' I (\u03bbx, (f x)\u207b\u00b9) :=\n(smooth_inv I).comp hf\n\n@[to_additive]\nlemma smooth_on.inv {f : M \u2192 G} {s : set M}\n  (hf : smooth_on I' I f s) : smooth_on I' I (\u03bbx, (f x)\u207b\u00b9) s :=\n(smooth_inv I).comp_smooth_on hf\n\n@[to_additive]\nlemma smooth.div {f g : M \u2192 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 \u2192 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 {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c] {H : Type*} [topological_space H]\n  {E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E]  {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E']\n  {H' : Type*} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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\u00d7G') :=\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 {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\n  {E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E] :\n  lie_add_group (\ud835\udcd8(\ud835\udd5c, E)) E :=\n{ smooth_add := smooth_iff.2 \u27e8continuous_add, \u03bb x y, cont_diff_add.cont_diff_on\u27e9,\n  smooth_neg := smooth_iff.2 \u27e8continuous_neg, \u03bb x y, cont_diff_neg.cont_diff_on\u27e9,\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 `\u22a5` 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 {\u03b9 : Type u} {E : Type v} [fintype \u03b9] [normed_add_comm_group E] [normed_space \u211d 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 (\u03b9 \u2192 \u211d)} (hs : measurable_set s) (I : box \u03b9) (y : E)\n  (\u03bc : measure (\u03b9 \u2192 \u211d)) [is_locally_finite_measure \u03bc] :\n  has_integral.{u v v} I l (s.indicator (\u03bb _, y)) \u03bc.to_box_additive.to_smul\n    ((\u03bc (s \u2229 I)).to_real \u2022 y) :=\nbegin\n  refine has_integral_of_mul (\u2016y\u2016) (\u03bb \u03b5 \u03b50, _),\n  lift \u03b5 to \u211d\u22650 using \u03b50.le, rw nnreal.coe_pos at \u03b50,\n  /- First we choose a closed set `F \u2286 s \u2229 I.Icc` and an open set `U \u2287 s` such that\n  both `(s \u2229 I.Icc) \\ F` and `U \\ s` have measuer less than `\u03b5`. -/\n  have A : \u03bc (s \u2229 I.Icc) \u2260 \u221e,\n    from ((measure_mono $ set.inter_subset_right _ _).trans_lt (I.measure_Icc_lt_top \u03bc)).ne,\n  have B : \u03bc (s \u2229 I) \u2260 \u221e,\n    from ((measure_mono $ set.inter_subset_right _ _).trans_lt (I.measure_coe_lt_top \u03bc)).ne,\n  obtain \u27e8F, hFs, hFc, h\u03bcF\u27e9 : \u2203 F \u2286 s \u2229 I.Icc, is_closed F \u2227 \u03bc ((s \u2229 I.Icc) \\ F) < \u03b5,\n    from (hs.inter I.measurable_set_Icc).exists_is_closed_diff_lt A (ennreal.coe_pos.2 \u03b50).ne',\n  obtain \u27e8U, hsU, hUo, hUt, h\u03bcU\u27e9 : \u2203 U \u2287 s \u2229 I.Icc, is_open U \u2227 \u03bc U < \u221e \u2227 \u03bc (U \\ (s \u2229 I.Icc)) < \u03b5,\n    from (hs.inter I.measurable_set_Icc).exists_is_open_diff_lt A (ennreal.coe_pos.2 \u03b50).ne',\n  /- Then we choose `r` so that `closed_ball x (r x) \u2286 U` whenever `x \u2208 s \u2229 I.Icc` and\n  `closed_ball x (r x)` is disjoint with `F` otherwise. -/\n  have : \u2200 x \u2208 s \u2229 I.Icc, \u2203 r : Ioi (0 : \u211d), closed_ball x r \u2286 U,\n    from \u03bb x hx, subtype.exists'.1 (nhds_basis_closed_ball.mem_iff.1 (hUo.mem_nhds $ hsU hx)),\n  choose! rs hrsU,\n  have : \u2200 x \u2208 I.Icc \\ s, \u2203 r : Ioi (0 : \u211d), closed_ball x r \u2286 F\u1d9c,\n    from \u03bb x hx, subtype.exists'.1 (nhds_basis_closed_ball.mem_iff.1 (hFc.is_open_compl.mem_nhds $\n      \u03bb hx', hx.2 (hFs hx').1)),\n  choose! rs' hrs'F,\n  set r : (\u03b9 \u2192 \u211d) \u2192 Ioi (0 : \u211d) := s.piecewise rs rs',\n  refine \u27e8\u03bb c, r, \u03bb c, l.r_cond_of_bRiemann_eq_ff hl, \u03bb c \u03c0 h\u03c0 h\u03c0p, _\u27e9, rw mul_comm,\n  /- Then the union of boxes `J \u2208 \u03c0` such that `\u03c0.tag \u2208 s` includes `F` and is included by `U`,\n  hence its measure is `\u03b5`-close to the measure of `s`. -/\n  dsimp [integral_sum],\n  simp only [mem_closed_ball, dist_eq_norm, \u2190 indicator_const_smul_apply,\n    sum_indicator_eq_sum_filter, \u2190 sum_smul, \u2190 sub_smul, norm_smul, real.norm_eq_abs,\n    \u2190 prepartition.filter_boxes, \u2190 prepartition.measure_Union_to_real],\n  refine mul_le_mul_of_nonneg_right _ (norm_nonneg y),\n  set t := (\u03c0.to_prepartition.filter (\u03bb J, \u03c0.tag J \u2208 s)).Union,\n  change abs ((\u03bc t).to_real - (\u03bc (s \u2229 I)).to_real) \u2264 \u03b5,\n  have htU : t \u2286 U \u2229 I,\n  { simp only [t, prepartition.Union_def, Union_subset_iff, prepartition.mem_filter, and_imp],\n    refine \u03bb J hJ hJs x hx, \u27e8hrsU _ \u27e8hJs, \u03c0.tag_mem_Icc J\u27e9  _, \u03c0.le_of_mem' J hJ hx\u27e9,\n    simpa only [r, s.piecewise_eq_of_mem _ _ hJs] using h\u03c0.1 J hJ (box.coe_subset_Icc hx) },\n  refine abs_sub_le_iff.2 \u27e8_, _\u27e9,\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 $ \u03bb x hx, _).trans h\u03bcU.le,\n    exact \u27e8hx.1.1, \u03bb hx', hx.2 \u27e8hx'.1, hx.1.2\u27e9\u27e9 },\n  { have h\u03bct : \u03bc t \u2260 \u221e :=\n      ((measure_mono (htU.trans (inter_subset_left _ _))).trans_lt hUt).ne,\n    refine (ennreal.le_to_real_sub h\u03bct).trans (ennreal.to_real_le_coe_of_le_coe _),\n    refine le_measure_diff.trans ((measure_mono _).trans h\u03bcF.le),\n    rintro x \u27e8\u27e8hxs, hxI\u27e9, hxt\u27e9,\n    refine \u27e8\u27e8hxs, box.coe_subset_Icc hxI\u27e9, \u03bb hxF, hxt _\u27e9,\n    simp only [t, prepartition.Union_def, prepartition.mem_filter, set.mem_Union, exists_prop],\n    rcases h\u03c0p x hxI with \u27e8J, hJ\u03c0, hxJ\u27e9,\n    refine \u27e8J, \u27e8hJ\u03c0, _\u27e9, hxJ\u27e9,\n    contrapose hxF,\n    refine hrs'F _ \u27e8\u03c0.tag_mem_Icc J, hxF\u27e9 _,\n    simpa only [r, s.piecewise_eq_of_not_mem _ _ hxF] using h\u03c0.1 J hJ\u03c0 (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 \u03b9} {f : (\u03b9 \u2192 \u211d) \u2192 E}\n  {\u03bc : measure (\u03b9 \u2192 \u211d)} [is_locally_finite_measure \u03bc] (hf : f =\u1d50[\u03bc.restrict I] 0)\n  (hl : l.bRiemann = ff) :\n  has_integral.{u v v} I l f \u03bc.to_box_additive.to_smul 0 :=\nbegin\n  /- Each set `{x | n < \u2016f x\u2016 \u2264 n + 1}`, `n : \u2115`, has measure zero. We cover it by an open set of\n  measure less than `\u03b5 / 2 ^ n / (n + 1)`. Then the norm of the integral sum is less than `\u03b5`. -/\n  refine has_integral_iff.2 (\u03bb \u03b5 \u03b50, _),\n  lift \u03b5 to \u211d\u22650 using \u03b50.lt.le, rw [gt_iff_lt, nnreal.coe_pos] at \u03b50,\n  rcases nnreal.exists_pos_sum_of_countable \u03b50.ne' \u2115 with \u27e8\u03b4, \u03b40, c, h\u03b4c, hc\u03b5\u27e9,\n  haveI := fact.mk (I.measure_coe_lt_top \u03bc),\n  change \u03bc.restrict I {x | f x \u2260 0} = 0 at hf,\n  set N : (\u03b9 \u2192 \u211d) \u2192 \u2115 := \u03bb x, \u2308\u2016f x\u2016\u2309\u208a,\n  have N0 : \u2200 {x}, N x = 0 \u2194 f x = 0, by { intro x, simp [N] },\n  have : \u2200 n, \u2203 U \u2287 N \u207b\u00b9' {n}, is_open U \u2227 \u03bc.restrict I U < \u03b4 n / n,\n  { refine \u03bb n, (N \u207b\u00b9' {n}).exists_is_open_lt_of_lt _ _,\n    cases n,\n    { simpa [ennreal.div_zero (ennreal.coe_pos.2 (\u03b40 _)).ne']\n        using measure_lt_top (\u03bc.restrict I) _ },\n    { refine (measure_mono_null _ hf).le.trans_lt _,\n      { exact \u03bb x hxN hxf, n.succ_ne_zero ((eq.symm hxN).trans $ N0.2 hxf) },\n      { simp [(\u03b40 _).ne'] } } },\n  choose U hNU hUo h\u03bcU,\n  have : \u2200 x, \u2203 r : Ioi (0 : \u211d), closed_ball x r \u2286 U (N x),\n    from \u03bb x, subtype.exists'.1 (nhds_basis_closed_ball.mem_iff.1 ((hUo _).mem_nhds (hNU _ rfl))),\n  choose r hrU,\n  refine \u27e8\u03bb _, r, \u03bb c, l.r_cond_of_bRiemann_eq_ff hl, \u03bb c \u03c0 h\u03c0 h\u03c0p, _\u27e9,\n  rw [dist_eq_norm, sub_zero, \u2190 integral_sum_fiberwise (\u03bb J, N (\u03c0.tag J))],\n  refine le_trans _ (nnreal.coe_lt_coe.2 hc\u03b5).le,\n  refine (norm_sum_le_of_le _ _).trans\n    (sum_le_has_sum _ (\u03bb n _, (\u03b4 n).2) (nnreal.has_sum_coe.2 h\u03b4c)),\n  rintro n -,\n  dsimp [integral_sum],\n  have : \u2200 J \u2208 \u03c0.filter (\u03bb J, N (\u03c0.tag J) = n),\n    \u2016(\u03bc \u2191J).to_real \u2022 f (\u03c0.tag J)\u2016 \u2264 (\u03bc 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 \u25b8 nat.le_ceil _) ennreal.to_real_nonneg },\n  refine (norm_sum_le_of_le _ this).trans _, clear this,\n  rw [\u2190 sum_mul, \u2190 prepartition.measure_Union_to_real],\n  generalize hm : \u03bc (\u03c0.filter (\u03bb J, N (\u03c0.tag J) = n)).Union = m,\n  have : m < \u03b4 n / n,\n  { simp only [measure.restrict_apply (hUo _).measurable_set] at h\u03bcU,\n    refine hm \u25b8 (measure_mono _).trans_lt (h\u03bcU _),\n    simp only [set.subset_def, tagged_prepartition.mem_Union, exists_prop,\n      tagged_prepartition.mem_filter],\n    rintro x \u27e8J, \u27e8hJ, rfl\u27e9, hx\u27e9,\n    exact \u27e8hrU _ (h\u03c0.1 _ hJ (box.coe_subset_Icc hx)), \u03c0.le_of_mem' J hJ hx\u27e9 },\n  lift m to \u211d\u22650 using ne_top_of_lt this,\n  rw [ennreal.coe_to_real, \u2190 nnreal.coe_nat_cast, \u2190 nnreal.coe_mul, nnreal.coe_le_coe,\n    \u2190 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 `\u03bc` 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 \u03b9} {y : E} {f g : (\u03b9 \u2192 \u211d) \u2192 E}\n  {\u03bc : measure (\u03b9 \u2192 \u211d)} [is_locally_finite_measure \u03bc]\n  (hf : has_integral.{u v v} I l f \u03bc.to_box_additive.to_smul y)\n  (hfg : f =\u1d50[\u03bc.restrict I] g) (hl : l.bRiemann = ff) :\n  has_integral.{u v v} I l g \u03bc.to_box_additive.to_smul y :=\nbegin\n  have : (g - f) =\u1d50[\u03bc.restrict I] 0, from hfg.mono (\u03bb 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 (\u03b9 \u2192 \u211d) E) (\u03bc : measure (\u03b9 \u2192 \u211d))\n  [is_locally_finite_measure \u03bc] (I : box \u03b9) (l : integration_params) (hl : l.bRiemann = ff) :\n  has_integral.{u v v} I l f \u03bc.to_box_additive.to_smul (f.integral (\u03bc.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 \u03bc },\n  { borelize E, haveI := fact.mk (I.measure_coe_lt_top \u03bc),\n    rw integral_add,\n    exacts [hfi.add hgi, integrable_iff.2 $ \u03bb _ _, measure_lt_top _ _,\n      integrable_iff.2 $ \u03bb _ _, measure_lt_top _ _] }\nend\n\n/-- For a simple function, its McShane (or Henstock, or `\u22a5`) box integral is equal to its\nintegral in the sense of `measure_theory.simple_func.integral`. -/\nlemma box_integral_eq_integral (f : simple_func (\u03b9 \u2192 \u211d) E) (\u03bc : measure (\u03b9 \u2192 \u211d))\n  [is_locally_finite_measure \u03bc] (I : box \u03b9) (l : integration_params) (hl : l.bRiemann = ff) :\n  box_integral.integral.{u v v} I l f \u03bc.to_box_additive.to_smul = f.integral (\u03bc.restrict I) :=\n(f.has_box_integral \u03bc I l hl).integral_eq\n\nend simple_func\n\nopen topological_space\n\n/-- If `f : \u211d\u207f \u2192 E` is Bochner integrable w.r.t. a locally finite measure `\u03bc` 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 : (\u03b9 \u2192 \u211d) \u2192 E} {\u03bc : measure (\u03b9 \u2192 \u211d)}\n  [is_locally_finite_measure \u03bc] {I : box \u03b9} (hf : integrable_on f I \u03bc) (l : integration_params)\n  (hl : l.bRiemann = ff) :\n  has_integral.{u v v} I l f \u03bc.to_box_additive.to_smul (\u222b x in I, f x \u2202 \u03bc) :=\nbegin\n  borelize E,\n  /- First we replace an `ae_strongly_measurable` function by a measurable one. -/\n  rcases hf.ae_strongly_measurable with \u27e8g, hg, hfg\u27e9,\n  haveI : separable_space (range g \u222a {0} : set E) := hg.separable_space_range_union_singleton,\n  rw integral_congr_ae hfg, have hgi : integrable_on g I \u03bc := (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 \u222a {0}) 0 (by simp)`\n  approximating `g`. Recall some properties of this sequence. -/\n  set f : \u2115 \u2192 simple_func (\u03b9 \u2192 \u211d) E :=\n    simple_func.approx_on g hg.measurable (range g \u222a {0}) 0 (by simp),\n  have hfi : \u2200 n, integrable_on (f n) I \u03bc,\n    from simple_func.integrable_approx_on_range hg.measurable hgi,\n  have hfi' := \u03bb n, ((f n).has_box_integral \u03bc I l hl).integrable,\n  have hfgi : tendsto (\u03bb n, (f n).integral (\u03bc.restrict I)) at_top (\ud835\udcdd $ \u222b x in I, g x \u2202\u03bc),\n    from tendsto_integral_approx_on_of_measurable_of_range_subset hg.measurable hgi _ subset.rfl,\n  have hfg_mono : \u2200 x {m n}, m \u2264 n \u2192 \u2016f n x - g x\u2016 \u2264 \u2016f m x - g x\u2016,\n  { intros x m n hmn,\n    rw [\u2190 dist_eq_norm, \u2190 dist_eq_norm, dist_nndist, dist_nndist, nnreal.coe_le_coe,\n      \u2190 ennreal.coe_le_coe, \u2190 edist_nndist, \u2190 edist_nndist],\n    exact simple_func.edist_approx_on_mono hg.measurable _ x hmn },\n  /- Now consider `\u03b5 > 0`. We need to find `r` such that for any tagged partition subordinate\n  to `r`, the integral sum is `(\u03bc I + 1 + 1) * \u03b5`-close to the Bochner integral. -/\n  refine has_integral_of_mul ((\u03bc I).to_real + 1 + 1) (\u03bb \u03b5 \u03b50, _),\n  lift \u03b5 to \u211d\u22650 using \u03b50.le, rw nnreal.coe_pos at \u03b50, have \u03b50' := ennreal.coe_pos.2 \u03b50,\n  /- Choose `N` such that the integral of `\u2016f N x - g x\u2016` is less than or equal to `\u03b5`. -/\n  obtain \u27e8N\u2080, hN\u2080\u27e9 : \u2203 N : \u2115, \u222b x in I, \u2016f N x - g x\u2016 \u2202\u03bc \u2264 \u03b5,\n  { have : tendsto (\u03bb n, \u222b\u207b x in I, \u2016f n x - g x\u2016\u208a \u2202\u03bc) at_top (\ud835\udcdd 0),\n      from simple_func.tendsto_approx_on_range_L1_nnnorm hg.measurable hgi,\n    refine (this.eventually (ge_mem_nhds \u03b50')).exists.imp (\u03bb N hN, _),\n    exact integral_coe_le_of_lintegral_coe_le hN },\n  /- For each `x`, we choose `Nx x \u2265 N\u2080` such that `dist (f Nx x) (g x) \u2264 \u03b5`. -/\n  have : \u2200 x, \u2203 N\u2081, N\u2080 \u2264 N\u2081 \u2227 dist (f N\u2081 x) (g x) \u2264 \u03b5,\n  { intro x,\n    have : tendsto (\u03bb n, f n x) at_top (\ud835\udcdd $ g x),\n      from simple_func.tendsto_approx_on hg.measurable _ (subset_closure (by simp)),\n    exact ((eventually_ge_at_top N\u2080).and $ this $ closed_ball_mem_nhds _ \u03b50).exists },\n  choose Nx hNx hNx\u03b5,\n  /- We also choose a convergent series with `\u2211' i : \u2115, \u03b4 i < \u03b5`. -/\n  rcases nnreal.exists_pos_sum_of_countable \u03b50.ne' \u2115 with \u27e8\u03b4, \u03b40, c, h\u03b4c, hc\u03b5\u27e9,\n  /- Since each simple function `f\u1d62` is integrable, there exists `r\u1d62 : \u211d\u207f \u2192 (0, \u221e)` such that\n  the integral sum of `f` over any tagged prepartition is `\u03b4\u1d62`-close to the sum of integrals\n  of `f\u1d62` over the boxes of this prepartition. For each `x`, we choose `r (Nx x)` as the radius\n  at `x`. -/\n  set r : \u211d\u22650 \u2192 (\u03b9 \u2192 \u211d) \u2192 Ioi (0 : \u211d) := \u03bb c x, (hfi' $ Nx x).convergence_r (\u03b4 $ Nx x) c x,\n  refine \u27e8r, \u03bb c, l.r_cond_of_bRiemann_eq_ff hl, \u03bb c \u03c0 h\u03c0 h\u03c0p, _\u27e9,\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 `\u03bc J \u2022 f (Nx (\u03c0.tag J)) (\u03c0.tag J)`\n  by the Bochner integral of `f (Nx (\u03c0.tag J)) x` over `J`, then we jump to the Bochner\n  integral of `g`. -/\n  refine (dist_triangle4 _ (\u2211 J in \u03c0.boxes, (\u03bc J).to_real \u2022 f (Nx $ \u03c0.tag J) (\u03c0.tag J))\n    (\u2211 J in \u03c0.boxes, \u222b x in J, f (Nx $ \u03c0.tag J) x \u2202\u03bc) _).trans _,\n  rw [add_mul, add_mul, one_mul],\n  refine add_le_add_three _ _ _,\n  { /- Since each `f (Nx $ \u03c0.tag J)` is `\u03b5`-close to `g (\u03c0.tag J)`, replacing the latter with\n    the former in the formula for the integral sum changes the sum at most by `\u03bc I * \u03b5`. -/\n    rw [\u2190 h\u03c0p.Union_eq, \u03c0.to_prepartition.measure_Union_to_real, sum_mul, integral_sum],\n    refine dist_sum_sum_le_of_le _ (\u03bb J hJ, _), dsimp,\n    rw [dist_eq_norm, \u2190 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 [\u2190 dist_eq_norm'], exact hNx\u03b5 _ },\n  { /- We group the terms of both sums by the values of `Nx (\u03c0.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 `\u03b4\u1d62`-close\n    to the corresponding integral sum due to the Henstock-Sacks inequality. -/\n    rw [\u2190 \u03c0.to_prepartition.sum_fiberwise (\u03bb J, Nx (\u03c0.tag J)),\n      \u2190 \u03c0.to_prepartition.sum_fiberwise (\u03bb J, Nx (\u03c0.tag J))],\n    refine le_trans _ (nnreal.coe_lt_coe.2 hc\u03b5).le,\n    refine (dist_sum_sum_le_of_le _ (\u03bb n hn, _)).trans\n      (sum_le_has_sum _ (\u03bb n _, (\u03b4 n).2) (nnreal.has_sum_coe.2 h\u03b4c)),\n    have hNxn : \u2200 J \u2208 \u03c0.filter (\u03bb J, Nx (\u03c0.tag J) = n), Nx (\u03c0.tag J) = n,\n      from \u03bb J hJ, (\u03c0.mem_filter.1 hJ).2,\n    have hrn : \u2200 J \u2208 \u03c0.filter (\u03bb J, Nx (\u03c0.tag J) = n),\n      r c (\u03c0.tag J) = (hfi' n).convergence_r (\u03b4 n) c (\u03c0.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 (\u03b4 n) c) (\u03c0.filter (\u03bb J, Nx (\u03c0.tag J) = n)),\n      from (h\u03c0.filter _).mono' _ le_rfl le_rfl (\u03bb J hJ, (hrn J hJ).le),\n    convert (hfi' n).dist_integral_sum_sum_integral_le_of_mem_base_set (\u03b40 _) this using 2,\n    { refine sum_congr rfl (\u03bb J hJ, _),\n      simp [hNxn J hJ] },\n    { refine sum_congr rfl (\u03bb J hJ, _),\n      rw [\u2190 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\u2080 x` and `g x` and the integral of `\u2016f N\u2080 x - g x\u2016`\n    is less than or equal to `\u03b5`. -/\n    refine le_trans _ hN\u2080,\n    have hfi : \u2200 n (J \u2208 \u03c0), integrable_on (f n) \u2191J  \u03bc,\n      from \u03bb n J hJ, (hfi n).mono_set (\u03c0.le_of_mem' J hJ),\n    have hgi : \u2200 J \u2208 \u03c0, integrable_on g \u2191J \u03bc, from \u03bb J hJ, hgi.mono_set (\u03c0.le_of_mem' J hJ),\n    have hfgi : \u2200 n (J \u2208 \u03c0), integrable_on (\u03bb x, \u2016f n x - g x\u2016) J \u03bc,\n      from \u03bb n J hJ, ((hfi n J hJ).sub (hgi J hJ)).norm,\n    rw [\u2190 h\u03c0p.Union_eq, prepartition.Union_def',\n      integral_finset_bUnion \u03c0.boxes (\u03bb J hJ, J.measurable_set_coe) \u03c0.pairwise_disjoint hgi,\n      integral_finset_bUnion \u03c0.boxes (\u03bb J hJ, J.measurable_set_coe) \u03c0.pairwise_disjoint (hfgi _)],\n    refine dist_sum_sum_le_of_le _ (\u03bb J hJ, _),\n    rw [dist_eq_norm, \u2190 integral_sub (hfi _ J hJ) (hgi J hJ)],\n    refine norm_integral_le_of_norm_le (hfgi _ J hJ) (eventually_of_forall $ \u03bb x, _),\n    exact hfg_mono x (hNx (\u03c0.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 \u2192 free\n| op {n} : L n \u2192 (fin n \u2192 free) \u2192 free\n\nnamespace free\ninstance : has_app L (L.free S) :=  \n{ app := \u03bb _, op }\n\ndef univ : S \u2192 L.free S := of\n\nvariable {S} \ndef lift {B : Type*} [has_app L B] (f : S \u2192 B) : L.free S \u2192$[L] B := \n{ to_fn := \u03bb t, free.rec_on t f (\u03bb 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 \u2192 B) : (lift L f) \u2218 (univ L S) = f := rfl\n\ntheorem lift_unique {B : Type*} [has_app L B] (f : S \u2192 B) (g : L.free S \u2192$[L] B) (hyp : g \u2218 (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 \u2218 (univ _ _)) x = _,\n    rw hyp, refl },\n  { change g (applyo t as) = (lift L f) (applyo t as),\n    simp_rw \u2190ralg_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 \u2190 add_assoc,\nrw \u2190 Pk,\nrw \u2190 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": "\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 fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval in Lean mathlib\n \n--OUTPUT 1\ntheorem dense_fractional_parts (a : \u211d) (ha : a \u2260 0) : dense {x | \u2203 n : \u2124, x = n \u2022 a} :=\nbegin\n  sorry\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_max_tokens_2000_n_1/clean_files/fractional parts of the integer multiples of an irrational number form a dense subset of the unit interval.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8006920020959544, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4924959264980664}}
{"text": "/-\nCopyright (c) 2017 Johannes H\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\ud835\udce4 X` on `X \u00d7 X` satisfying some conditions\nwhich makes it reasonable to say that `\u2200\u1da0 (p : X \u00d7 X) in \ud835\udce4 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 \u2208 \ud835\udce4 X \u2194 \u2203 \u03b5 > 0, { p | dist p.1 p.2 < \u03b5 } \u2286 V`\n* If `G` is an additive topological group, `V \u2208 \ud835\udce4 G \u2194 \u2203 U \u2208 \ud835\udcdd (0 : G), {p | p.2 - p.1 \u2208 U} \u2286 V`\n\nThose examples are generalizations in two different directions of the elementary example where\n`X = \u211d` and `V \u2208 \ud835\udce4 \u211d \u2194 \u2203 \u03b5 > 0, { p | |p.2 - p.1| < \u03b5 } \u2286 V` which features both the topological\ngroup structure on `\u211d` and its metric space structure.\n\nEach uniform structure on `X` induces a topology on `X` characterized by\n\n> `nhds_eq_comap_uniformity : \u2200 {x : X}, \ud835\udcdd x = comap (prod.mk x) (\ud835\udce4 X)`\n\nwhere `prod.mk x : X \u2192 X \u00d7 X := (\u03bb 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) \u2208 V` for some `V \u2208 \ud835\udce4 X`\n* a ball `ball x r` roughly corresponds to `uniform_space.ball x V := {y | (x, y) \u2208 V}`\n  for some `V \u2208 \ud835\udce4 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 \u2194 \u2200 x \u2208 s, \u2203 V \u2208 \ud835\udce4 X, ball x V \u2286 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`\u2200 (x y z : X) (r r' : \u211d), dist x y \u2264 r \u2192 dist y z \u2264 r' \u2192 dist x z \u2264 r + r'`.\nThen, for any `V` and `W` with type `set (X \u00d7 X)`, the composition `V \u25cb W : set (X \u00d7 X)` is\ndefined as `{ p : X \u00d7 X | \u2203 z, (p.1, z) \u2208 V \u2227 (z, p.2) \u2208 W }`.\nIn the metric space case, if `V = { p | dist p.1 p.2 \u2264 r }` and `W = { p | dist p.1 p.2 \u2264 r' }`\nthen the triangle inequality, as reformulated above, says `V \u25cb W` is contained in\n`{p | dist p.1 p.2 \u2264 r + r'}` which is the entourage associated to the radius `r + r'`.\nIn general we have `mem_ball_comp (h : y \u2208 ball x V) (h' : z \u2208 ball y W) : z \u2208 ball x (V \u25cb 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 `\ud835\udce4 X` to satisfy the following:\n* every `V \u2208 \ud835\udce4 X` contains the diagonal `id_rel = { p | p.1 = p.2 }`. This abstracts the fact\n  that `dist x x \u2264 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 \u2208 \ud835\udce4 X \u2192 prod.swap '' V \u2208 \ud835\udce4 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* `\u2200 V \u2208 \ud835\udce4 X, \u2203 W \u2208 \ud835\udce4 X, W \u25cb W \u2286 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##\u00a0Main 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 : \u03b1 \u2192 \u03b2` between uniform spaces\n  is uniformly continuous : `\u2200 r \u2208 \ud835\udce4 \u03b2, \u2200\u1da0 (x : \u03b1 \u00d7 \u03b1) in \ud835\udce4 \u03b1, (f x.1, f x.2) \u2208 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 `\ud835\udce4 X` for the uniformity on a uniform space `X`,\nand `\u25cb` for composition of relations, seen as terms with type `set (X \u00d7 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 (\u03b1 \u03b2 : Type*) := \u03b1 \u2192 \u03b2 \u2192 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 (\u03b1 \u00d7 \u03b1)`\ninstead of `rel \u03b1 \u03b1` because we really need sets to use the filter library, and elements\nof filters on `\u03b1 \u00d7 \u03b1` have type `set (\u03b1 \u00d7 \u03b1)`.\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 (\u03b1 \u00d7 \u03b1)`\n-/\n\n/-- The identity relation, or the graph of the identity function -/\ndef id_rel {\u03b1 : Type u_1} : set (\u03b1 \u00d7 \u03b1) := set_of fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p = prod.snd p\n\n@[simp] theorem mem_id_rel {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : (a, b) \u2208 id_rel \u2194 a = b := iff.rfl\n\n@[simp] theorem id_rel_subset {\u03b1 : Type u_1} {s : set (\u03b1 \u00d7 \u03b1)} :\n    id_rel \u2286 s \u2194 \u2200 (a : \u03b1), (a, a) \u2208 s :=\n  sorry\n\n/-- The composition of relations -/\ndef comp_rel {\u03b1 : Type u} (r\u2081 : set (\u03b1 \u00d7 \u03b1)) (r\u2082 : set (\u03b1 \u00d7 \u03b1)) : set (\u03b1 \u00d7 \u03b1) :=\n  set_of fun (p : \u03b1 \u00d7 \u03b1) => \u2203 (z : \u03b1), (prod.fst p, z) \u2208 r\u2081 \u2227 (z, prod.snd p) \u2208 r\u2082\n\n@[simp] theorem mem_comp_rel {\u03b1 : Type u_1} {r\u2081 : set (\u03b1 \u00d7 \u03b1)} {r\u2082 : set (\u03b1 \u00d7 \u03b1)} {x : \u03b1} {y : \u03b1} :\n    (x, y) \u2208 comp_rel r\u2081 r\u2082 \u2194 \u2203 (z : \u03b1), (x, z) \u2208 r\u2081 \u2227 (z, y) \u2208 r\u2082 :=\n  iff.rfl\n\n@[simp] theorem swap_id_rel {\u03b1 : Type u_1} : prod.swap '' id_rel = id_rel := sorry\n\ntheorem monotone_comp_rel {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b2] {f : \u03b2 \u2192 set (\u03b1 \u00d7 \u03b1)}\n    {g : \u03b2 \u2192 set (\u03b1 \u00d7 \u03b1)} (hf : monotone f) (hg : monotone g) :\n    monotone fun (x : \u03b2) => comp_rel (f x) (g x) :=\n  sorry\n\ntheorem comp_rel_mono {\u03b1 : Type u_1} {f : set (\u03b1 \u00d7 \u03b1)} {g : set (\u03b1 \u00d7 \u03b1)} {h : set (\u03b1 \u00d7 \u03b1)}\n    {k : set (\u03b1 \u00d7 \u03b1)} (h\u2081 : f \u2286 h) (h\u2082 : g \u2286 k) : comp_rel f g \u2286 comp_rel h k :=\n  sorry\n\ntheorem prod_mk_mem_comp_rel {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} {c : \u03b1} {s : set (\u03b1 \u00d7 \u03b1)}\n    {t : set (\u03b1 \u00d7 \u03b1)} (h\u2081 : (a, c) \u2208 s) (h\u2082 : (c, b) \u2208 t) : (a, b) \u2208 comp_rel s t :=\n  Exists.intro c { left := h\u2081, right := h\u2082 }\n\n@[simp] theorem id_comp_rel {\u03b1 : Type u_1} {r : set (\u03b1 \u00d7 \u03b1)} : comp_rel id_rel r = r := sorry\n\ntheorem comp_rel_assoc {\u03b1 : Type u_1} {r : set (\u03b1 \u00d7 \u03b1)} {s : set (\u03b1 \u00d7 \u03b1)} {t : set (\u03b1 \u00d7 \u03b1)} :\n    comp_rel (comp_rel r s) t = comp_rel r (comp_rel s t) :=\n  sorry\n\ntheorem subset_comp_self {\u03b1 : Type u_1} {s : set (\u03b1 \u00d7 \u03b1)} (h : id_rel \u2286 s) : s \u2286 comp_rel s s :=\n  sorry\n\n/-- The relation is invariant under swapping factors. -/\ndef symmetric_rel {\u03b1 : Type u_1} (V : set (\u03b1 \u00d7 \u03b1)) := prod.swap \u207b\u00b9' V = V\n\n/-- The maximal symmetric relation contained in a given relation. -/\ndef symmetrize_rel {\u03b1 : Type u_1} (V : set (\u03b1 \u00d7 \u03b1)) : set (\u03b1 \u00d7 \u03b1) := V \u2229 prod.swap \u207b\u00b9' V\n\ntheorem symmetric_symmetrize_rel {\u03b1 : Type u_1} (V : set (\u03b1 \u00d7 \u03b1)) :\n    symmetric_rel (symmetrize_rel V) :=\n  sorry\n\ntheorem symmetrize_rel_subset_self {\u03b1 : Type u_1} (V : set (\u03b1 \u00d7 \u03b1)) : symmetrize_rel V \u2286 V :=\n  set.sep_subset V fun (a : \u03b1 \u00d7 \u03b1) => a \u2208 prod.swap \u207b\u00b9' V\n\ntheorem symmetrize_mono {\u03b1 : Type u_1} {V : set (\u03b1 \u00d7 \u03b1)} {W : set (\u03b1 \u00d7 \u03b1)} (h : V \u2286 W) :\n    symmetrize_rel V \u2286 symmetrize_rel W :=\n  set.inter_subset_inter h (set.preimage_mono h)\n\ntheorem symmetric_rel_inter {\u03b1 : Type u_1} {U : set (\u03b1 \u00d7 \u03b1)} {V : set (\u03b1 \u00d7 \u03b1)}\n    (hU : symmetric_rel U) (hV : symmetric_rel V) : symmetric_rel (U \u2229 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 (\u03b1 : Type u) where\n  uniformity : filter (\u03b1 \u00d7 \u03b1)\n  refl : filter.principal id_rel \u2264 uniformity\n  symm : filter.tendsto prod.swap uniformity uniformity\n  comp : (filter.lift' uniformity fun (s : set (\u03b1 \u00d7 \u03b1)) => comp_rel s s) \u2264 uniformity\n\n/-- An alternative constructor for `uniform_space.core`. This version unfolds various\n`filter`-related definitions. -/\ndef uniform_space.core.mk' {\u03b1 : Type u} (U : filter (\u03b1 \u00d7 \u03b1))\n    (refl : \u2200 (r : set (\u03b1 \u00d7 \u03b1)), r \u2208 U \u2192 \u2200 (x : \u03b1), (x, x) \u2208 r)\n    (symm : \u2200 (r : set (\u03b1 \u00d7 \u03b1)), r \u2208 U \u2192 prod.swap \u207b\u00b9' r \u2208 U)\n    (comp : \u2200 (r : set (\u03b1 \u00d7 \u03b1)) (H : r \u2208 U), \u2203 (t : set (\u03b1 \u00d7 \u03b1)), \u2203 (H : t \u2208 U), comp_rel t t \u2286 r) :\n    uniform_space.core \u03b1 :=\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 {\u03b1 : Type u} (u : uniform_space.core \u03b1) :\n    topological_space \u03b1 :=\n  topological_space.mk\n    (fun (s : set \u03b1) =>\n      \u2200 (x : \u03b1),\n        x \u2208 s \u2192\n          (set_of fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p = x \u2192 prod.snd p \u2208 s) \u2208\n            uniform_space.core.uniformity u)\n    sorry sorry sorry\n\ntheorem uniform_space.core_eq {\u03b1 : Type u_1} {u\u2081 : uniform_space.core \u03b1}\n    {u\u2082 : uniform_space.core \u03b1} :\n    uniform_space.core.uniformity u\u2081 = uniform_space.core.uniformity u\u2082 \u2192 u\u2081 = u\u2082 :=\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 `\u03b1 \u00d7 \u03b1` 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 (\u03b1 : Type u) extends uniform_space.core \u03b1, topological_space \u03b1 where\n  is_open_uniformity :\n    \u2200 (s : set \u03b1),\n      topological_space.is_open _to_topological_space s \u2194\n        \u2200 (x : \u03b1),\n          x \u2208 s \u2192\n            (set_of fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p = x \u2192 prod.snd p \u2208 s) \u2208\n              uniform_space.core.uniformity _to_core\n\n/-- Alternative constructor for `uniform_space \u03b1` when a topology is already given. -/\ndef uniform_space.mk' {\u03b1 : Type u_1} (t : topological_space \u03b1) (c : uniform_space.core \u03b1)\n    (is_open_uniformity :\n      \u2200 (s : set \u03b1),\n        topological_space.is_open t s \u2194\n          \u2200 (x : \u03b1),\n            x \u2208 s \u2192\n              (set_of fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p = x \u2192 prod.snd p \u2208 s) \u2208\n                uniform_space.core.uniformity c) :\n    uniform_space \u03b1 :=\n  uniform_space.mk c is_open_uniformity\n\n/-- Construct a `uniform_space` from a `uniform_space.core`. -/\ndef uniform_space.of_core {\u03b1 : Type u} (u : uniform_space.core \u03b1) : uniform_space \u03b1 :=\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 {\u03b1 : Type u} (u : uniform_space.core \u03b1) (t : topological_space \u03b1)\n    (h : t = uniform_space.core.to_topological_space u) : uniform_space \u03b1 :=\n  uniform_space.mk u sorry\n\ntheorem uniform_space.to_core_to_topological_space {\u03b1 : Type u_1} (u : uniform_space \u03b1) :\n    uniform_space.core.to_topological_space uniform_space.to_core =\n        uniform_space.to_topological_space :=\n  sorry\n\ntheorem uniform_space_eq {\u03b1 : Type u_1} {u\u2081 : uniform_space \u03b1} {u\u2082 : uniform_space \u03b1} :\n    uniform_space.core.uniformity uniform_space.to_core =\n          uniform_space.core.uniformity uniform_space.to_core \u2192\n        u\u2081 = u\u2082 :=\n  sorry\n\ntheorem uniform_space.of_core_eq_to_core {\u03b1 : Type u_1} (u : uniform_space \u03b1)\n    (t : topological_space \u03b1)\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 \u03b1 \u00d7 \u03b1 (inferred from an ambient uniform space\n  structure on \u03b1). -/\ndef uniformity (\u03b1 : Type u) [uniform_space \u03b1] : filter (\u03b1 \u00d7 \u03b1) :=\n  uniform_space.core.uniformity uniform_space.to_core\n\ntheorem is_open_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set \u03b1} :\n    is_open s \u2194\n        \u2200 (x : \u03b1),\n          x \u2208 s \u2192 (set_of fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p = x \u2192 prod.snd p \u2208 s) \u2208 uniformity \u03b1 :=\n  uniform_space.is_open_uniformity s\n\ntheorem refl_le_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    filter.principal id_rel \u2264 uniformity \u03b1 :=\n  uniform_space.core.refl uniform_space.to_core\n\ntheorem refl_mem_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {x : \u03b1} {s : set (\u03b1 \u00d7 \u03b1)}\n    (h : s \u2208 uniformity \u03b1) : (x, x) \u2208 s :=\n  refl_le_uniformity h rfl\n\ntheorem symm_le_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    filter.map prod.swap (uniformity \u03b1) \u2264 uniformity \u03b1 :=\n  uniform_space.core.symm uniform_space.to_core\n\ntheorem comp_le_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    (filter.lift' (uniformity \u03b1) fun (s : set (\u03b1 \u00d7 \u03b1)) => comp_rel s s) \u2264 uniformity \u03b1 :=\n  uniform_space.core.comp uniform_space.to_core\n\ntheorem tendsto_swap_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    filter.tendsto prod.swap (uniformity \u03b1) (uniformity \u03b1) :=\n  symm_le_uniformity\n\ntheorem comp_mem_uniformity_sets {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set (\u03b1 \u00d7 \u03b1)}\n    (hs : s \u2208 uniformity \u03b1) : \u2203 (t : set (\u03b1 \u00d7 \u03b1)), \u2203 (H : t \u2208 uniformity \u03b1), comp_rel t t \u2286 s :=\n  (fun (this : s \u2208 filter.lift' (uniformity \u03b1) fun (t : set (\u03b1 \u00d7 \u03b1)) => 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 `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is transitive. -/\ntheorem filter.tendsto.uniformity_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    {l : filter \u03b2} {f\u2081 : \u03b2 \u2192 \u03b1} {f\u2082 : \u03b2 \u2192 \u03b1} {f\u2083 : \u03b2 \u2192 \u03b1}\n    (h\u2081\u2082 : filter.tendsto (fun (x : \u03b2) => (f\u2081 x, f\u2082 x)) l (uniformity \u03b1))\n    (h\u2082\u2083 : filter.tendsto (fun (x : \u03b2) => (f\u2082 x, f\u2083 x)) l (uniformity \u03b1)) :\n    filter.tendsto (fun (x : \u03b2) => (f\u2081 x, f\u2083 x)) l (uniformity \u03b1) :=\n  sorry\n\n/-- Relation `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is symmetric -/\ntheorem filter.tendsto.uniformity_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    {l : filter \u03b2} {f : \u03b2 \u2192 \u03b1 \u00d7 \u03b1} (h : filter.tendsto f l (uniformity \u03b1)) :\n    filter.tendsto (fun (x : \u03b2) => (prod.snd (f x), prod.fst (f x))) l (uniformity \u03b1) :=\n  filter.tendsto.comp tendsto_swap_uniformity h\n\n/-- Relation `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is reflexive. -/\ntheorem tendsto_diag_uniformity {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] (f : \u03b2 \u2192 \u03b1)\n    (l : filter \u03b2) : filter.tendsto (fun (x : \u03b2) => (f x, f x)) l (uniformity \u03b1) :=\n  fun (s : set (\u03b1 \u00d7 \u03b1)) (hs : s \u2208 uniformity \u03b1) =>\n    iff.mpr filter.mem_map (filter.univ_mem_sets' fun (x : \u03b2) => refl_mem_uniformity hs)\n\ntheorem tendsto_const_uniformity {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] {a : \u03b1}\n    {f : filter \u03b2} : filter.tendsto (fun (_x : \u03b2) => (a, a)) f (uniformity \u03b1) :=\n  tendsto_diag_uniformity (fun (_x : \u03b2) => a) f\n\ntheorem symm_of_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set (\u03b1 \u00d7 \u03b1)}\n    (hs : s \u2208 uniformity \u03b1) :\n    \u2203 (t : set (\u03b1 \u00d7 \u03b1)), \u2203 (H : t \u2208 uniformity \u03b1), (\u2200 (a b : \u03b1), (a, b) \u2208 t \u2192 (b, a) \u2208 t) \u2227 t \u2286 s :=\n  sorry\n\ntheorem comp_symm_of_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set (\u03b1 \u00d7 \u03b1)}\n    (hs : s \u2208 uniformity \u03b1) :\n    \u2203 (t : set (\u03b1 \u00d7 \u03b1)),\n        \u2203 (H : t \u2208 uniformity \u03b1), (\u2200 {a b : \u03b1}, (a, b) \u2208 t \u2192 (b, a) \u2208 t) \u2227 comp_rel t t \u2286 s :=\n  sorry\n\ntheorem uniformity_le_symm {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    uniformity \u03b1 \u2264 prod.swap <$> uniformity \u03b1 :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (uniformity \u03b1 \u2264 prod.swap <$> uniformity \u03b1))\n        filter.map_swap_eq_comap_swap))\n    (iff.mp filter.map_le_iff_le_comap tendsto_swap_uniformity)\n\ntheorem uniformity_eq_symm {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    uniformity \u03b1 = prod.swap <$> uniformity \u03b1 :=\n  le_antisymm uniformity_le_symm symm_le_uniformity\n\ntheorem symmetrize_mem_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {V : set (\u03b1 \u00d7 \u03b1)}\n    (h : V \u2208 uniformity \u03b1) : symmetrize_rel V \u2208 uniformity \u03b1 :=\n  sorry\n\ntheorem uniformity_lift_le_swap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    {g : set (\u03b1 \u00d7 \u03b1) \u2192 filter \u03b2} {f : filter \u03b2} (hg : monotone g)\n    (h : (filter.lift (uniformity \u03b1) fun (s : set (\u03b1 \u00d7 \u03b1)) => g (prod.swap \u207b\u00b9' s)) \u2264 f) :\n    filter.lift (uniformity \u03b1) g \u2264 f :=\n  sorry\n\ntheorem uniformity_lift_le_comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    {f : set (\u03b1 \u00d7 \u03b1) \u2192 filter \u03b2} (h : monotone f) :\n    (filter.lift (uniformity \u03b1) fun (s : set (\u03b1 \u00d7 \u03b1)) => f (comp_rel s s)) \u2264\n        filter.lift (uniformity \u03b1) f :=\n  sorry\n\ntheorem comp_le_uniformity3 {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    (filter.lift' (uniformity \u03b1) fun (s : set (\u03b1 \u00d7 \u03b1)) => comp_rel s (comp_rel s s)) \u2264\n        uniformity \u03b1 :=\n  sorry\n\ntheorem comp_symm_mem_uniformity_sets {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set (\u03b1 \u00d7 \u03b1)}\n    (hs : s \u2208 uniformity \u03b1) :\n    \u2203 (t : set (\u03b1 \u00d7 \u03b1)), \u2203 (H : t \u2208 uniformity \u03b1), symmetric_rel t \u2227 comp_rel t t \u2286 s :=\n  sorry\n\ntheorem subset_comp_self_of_mem_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set (\u03b1 \u00d7 \u03b1)}\n    (h : s \u2208 uniformity \u03b1) : s \u2286 comp_rel s s :=\n  subset_comp_self (refl_le_uniformity h)\n\ntheorem comp_comp_symm_mem_uniformity_sets {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set (\u03b1 \u00d7 \u03b1)}\n    (hs : s \u2208 uniformity \u03b1) :\n    \u2203 (t : set (\u03b1 \u00d7 \u03b1)),\n        \u2203 (H : t \u2208 uniformity \u03b1), symmetric_rel t \u2227 comp_rel (comp_rel t t) t \u2286 s :=\n  sorry\n\n/-!\n###\u00a0Balls in uniform spaces\n-/\n\n/-- The ball around `(x : \u03b2)` with respect to `(V : set (\u03b2 \u00d7 \u03b2))`. Intended to be\nused for `V \u2208 \ud835\udce4 \u03b2`, 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 {\u03b2 : Type u_2} (x : \u03b2) (V : set (\u03b2 \u00d7 \u03b2)) : set \u03b2 := Prod.mk x \u207b\u00b9' V\n\ntheorem uniform_space.mem_ball_self {\u03b1 : Type u_1} [uniform_space \u03b1] (x : \u03b1) {V : set (\u03b1 \u00d7 \u03b1)}\n    (hV : V \u2208 uniformity \u03b1) : x \u2208 uniform_space.ball x V :=\n  refl_mem_uniformity hV\n\n/-- The triangle inequality for `uniform_space.ball` -/\ntheorem mem_ball_comp {\u03b2 : Type u_2} {V : set (\u03b2 \u00d7 \u03b2)} {W : set (\u03b2 \u00d7 \u03b2)} {x : \u03b2} {y : \u03b2} {z : \u03b2}\n    (h : y \u2208 uniform_space.ball x V) (h' : z \u2208 uniform_space.ball y W) :\n    z \u2208 uniform_space.ball x (comp_rel V W) :=\n  prod_mk_mem_comp_rel h h'\n\ntheorem ball_subset_of_comp_subset {\u03b2 : Type u_2} {V : set (\u03b2 \u00d7 \u03b2)} {W : set (\u03b2 \u00d7 \u03b2)} {x : \u03b2}\n    {y : \u03b2} (h : x \u2208 uniform_space.ball y W) (h' : comp_rel W W \u2286 V) :\n    uniform_space.ball x W \u2286 uniform_space.ball y V :=\n  fun (z : \u03b2) (z_in : z \u2208 uniform_space.ball x W) => h' (mem_ball_comp h z_in)\n\ntheorem ball_mono {\u03b2 : Type u_2} {V : set (\u03b2 \u00d7 \u03b2)} {W : set (\u03b2 \u00d7 \u03b2)} (h : V \u2286 W) (x : \u03b2) :\n    uniform_space.ball x V \u2286 uniform_space.ball x W :=\n  id fun (a : \u03b2) (\u1fb0 : a \u2208 uniform_space.ball x V) => h \u1fb0\n\ntheorem mem_ball_symmetry {\u03b2 : Type u_2} {V : set (\u03b2 \u00d7 \u03b2)} (hV : symmetric_rel V) {x : \u03b2} {y : \u03b2} :\n    x \u2208 uniform_space.ball y V \u2194 y \u2208 uniform_space.ball x V :=\n  sorry\n\ntheorem ball_eq_of_symmetry {\u03b2 : Type u_2} {V : set (\u03b2 \u00d7 \u03b2)} (hV : symmetric_rel V) {x : \u03b2} :\n    uniform_space.ball x V = set_of fun (y : \u03b2) => (y, x) \u2208 V :=\n  sorry\n\ntheorem mem_comp_of_mem_ball {\u03b2 : Type u_2} {V : set (\u03b2 \u00d7 \u03b2)} {W : set (\u03b2 \u00d7 \u03b2)} {x : \u03b2} {y : \u03b2}\n    {z : \u03b2} (hV : symmetric_rel V) (hx : x \u2208 uniform_space.ball z V)\n    (hy : y \u2208 uniform_space.ball z W) : (x, y) \u2208 comp_rel V W :=\n  Exists.intro z\n    { left :=\n        eq.mp (Eq._oldrec (Eq.refl (x \u2208 uniform_space.ball z V)) (propext (mem_ball_symmetry hV)))\n          hx,\n      right := hy }\n\ntheorem uniform_space.is_open_ball {\u03b1 : Type u_1} [uniform_space \u03b1] (x : \u03b1) {V : set (\u03b1 \u00d7 \u03b1)}\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 {\u03b2 : Type u_2} {V : set (\u03b2 \u00d7 \u03b2)} {W : set (\u03b2 \u00d7 \u03b2)} {M : set (\u03b2 \u00d7 \u03b2)}\n    (hW' : symmetric_rel W) {p : \u03b2 \u00d7 \u03b2} :\n    p \u2208 comp_rel (comp_rel V M) W \u2194\n        set.nonempty\n          (set.prod (uniform_space.ball (prod.fst p) V) (uniform_space.ball (prod.snd p) W) \u2229 M) :=\n  sorry\n\n/-!\n### Neighborhoods in uniform spaces\n-/\n\ntheorem mem_nhds_uniformity_iff_right {\u03b1 : Type u_1} [uniform_space \u03b1] {x : \u03b1} {s : set \u03b1} :\n    s \u2208 nhds x \u2194 (set_of fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p = x \u2192 prod.snd p \u2208 s) \u2208 uniformity \u03b1 :=\n  sorry\n\ntheorem mem_nhds_uniformity_iff_left {\u03b1 : Type u_1} [uniform_space \u03b1] {x : \u03b1} {s : set \u03b1} :\n    s \u2208 nhds x \u2194 (set_of fun (p : \u03b1 \u00d7 \u03b1) => prod.snd p = x \u2192 prod.fst p \u2208 s) \u2208 uniformity \u03b1 :=\n  sorry\n\ntheorem nhds_eq_comap_uniformity_aux {\u03b1 : Type u} {x : \u03b1} {s : set \u03b1} {F : filter (\u03b1 \u00d7 \u03b1)} :\n    (set_of fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p = x \u2192 prod.snd p \u2208 s) \u2208 F \u2194\n        s \u2208 filter.comap (Prod.mk x) F :=\n  sorry\n\ntheorem nhds_eq_comap_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {x : \u03b1} :\n    nhds x = filter.comap (Prod.mk x) (uniformity \u03b1) :=\n  sorry\n\ntheorem is_open_iff_ball_subset {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set \u03b1} :\n    is_open s \u2194\n        \u2200 (x : \u03b1) (H : x \u2208 s),\n          \u2203 (V : set (\u03b1 \u00d7 \u03b1)), \u2203 (H : V \u2208 uniformity \u03b1), uniform_space.ball x V \u2286 s :=\n  sorry\n\ntheorem nhds_basis_uniformity' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] {p : \u03b2 \u2192 Prop}\n    {s : \u03b2 \u2192 set (\u03b1 \u00d7 \u03b1)} (h : filter.has_basis (uniformity \u03b1) p s) {x : \u03b1} :\n    filter.has_basis (nhds x) p fun (i : \u03b2) => uniform_space.ball x (s i) :=\n  sorry\n\ntheorem nhds_basis_uniformity {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] {p : \u03b2 \u2192 Prop}\n    {s : \u03b2 \u2192 set (\u03b1 \u00d7 \u03b1)} (h : filter.has_basis (uniformity \u03b1) p s) {x : \u03b1} :\n    filter.has_basis (nhds x) p fun (i : \u03b2) => set_of fun (y : \u03b1) => (y, x) \u2208 s i :=\n  sorry\n\ntheorem uniform_space.mem_nhds_iff {\u03b1 : Type u_1} [uniform_space \u03b1] {x : \u03b1} {s : set \u03b1} :\n    s \u2208 nhds x \u2194 \u2203 (V : set (\u03b1 \u00d7 \u03b1)), \u2203 (H : V \u2208 uniformity \u03b1), uniform_space.ball x V \u2286 s :=\n  sorry\n\ntheorem uniform_space.ball_mem_nhds {\u03b1 : Type u_1} [uniform_space \u03b1] (x : \u03b1) {V : set (\u03b1 \u00d7 \u03b1)}\n    (V_in : V \u2208 uniformity \u03b1) : uniform_space.ball x V \u2208 nhds x :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (uniform_space.ball x V \u2208 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 {\u03b1 : Type u_1} [uniform_space \u03b1] {x : \u03b1} {s : set \u03b1} :\n    s \u2208 nhds x \u2194\n        \u2203 (V : set (\u03b1 \u00d7 \u03b1)),\n          \u2203 (H : V \u2208 uniformity \u03b1), symmetric_rel V \u2227 uniform_space.ball x V \u2286 s :=\n  sorry\n\ntheorem uniform_space.has_basis_nhds {\u03b1 : Type u_1} [uniform_space \u03b1] (x : \u03b1) :\n    filter.has_basis (nhds x) (fun (s : set (\u03b1 \u00d7 \u03b1)) => s \u2208 uniformity \u03b1 \u2227 symmetric_rel s)\n        fun (s : set (\u03b1 \u00d7 \u03b1)) => uniform_space.ball x s :=\n  sorry\n\ntheorem uniform_space.has_basis_nhds_prod {\u03b1 : Type u_1} [uniform_space \u03b1] (x : \u03b1) (y : \u03b1) :\n    filter.has_basis (nhds (x, y)) (fun (s : set (\u03b1 \u00d7 \u03b1)) => s \u2208 uniformity \u03b1 \u2227 symmetric_rel s)\n        fun (s : set (\u03b1 \u00d7 \u03b1)) => set.prod (uniform_space.ball x s) (uniform_space.ball y s) :=\n  sorry\n\ntheorem nhds_eq_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {x : \u03b1} :\n    nhds x = filter.lift' (uniformity \u03b1) (uniform_space.ball x) :=\n  filter.has_basis.eq_binfi (nhds_basis_uniformity' (filter.basis_sets (uniformity \u03b1)))\n\ntheorem mem_nhds_left {\u03b1 : Type u_1} [uniform_space \u03b1] (x : \u03b1) {s : set (\u03b1 \u00d7 \u03b1)}\n    (h : s \u2208 uniformity \u03b1) : (set_of fun (y : \u03b1) => (x, y) \u2208 s) \u2208 nhds x :=\n  uniform_space.ball_mem_nhds x h\n\ntheorem mem_nhds_right {\u03b1 : Type u_1} [uniform_space \u03b1] (y : \u03b1) {s : set (\u03b1 \u00d7 \u03b1)}\n    (h : s \u2208 uniformity \u03b1) : (set_of fun (x : \u03b1) => (x, y) \u2208 s) \u2208 nhds y :=\n  mem_nhds_left y (symm_le_uniformity h)\n\ntheorem tendsto_right_nhds_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {a : \u03b1} :\n    filter.tendsto (fun (a' : \u03b1) => (a', a)) (nhds a) (uniformity \u03b1) :=\n  fun (s : set (\u03b1 \u00d7 \u03b1)) => mem_nhds_right a\n\ntheorem tendsto_left_nhds_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {a : \u03b1} :\n    filter.tendsto (fun (a' : \u03b1) => (a, a')) (nhds a) (uniformity \u03b1) :=\n  fun (s : set (\u03b1 \u00d7 \u03b1)) => mem_nhds_left a\n\ntheorem lift_nhds_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] {x : \u03b1}\n    {g : set \u03b1 \u2192 filter \u03b2} (hg : monotone g) :\n    filter.lift (nhds x) g =\n        filter.lift (uniformity \u03b1) fun (s : set (\u03b1 \u00d7 \u03b1)) => g (set_of fun (y : \u03b1) => (x, y) \u2208 s) :=\n  sorry\n\ntheorem lift_nhds_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] {x : \u03b1}\n    {g : set \u03b1 \u2192 filter \u03b2} (hg : monotone g) :\n    filter.lift (nhds x) g =\n        filter.lift (uniformity \u03b1) fun (s : set (\u03b1 \u00d7 \u03b1)) => g (set_of fun (y : \u03b1) => (y, x) \u2208 s) :=\n  sorry\n\ntheorem nhds_nhds_eq_uniformity_uniformity_prod {\u03b1 : Type u_1} [uniform_space \u03b1] {a : \u03b1} {b : \u03b1} :\n    filter.prod (nhds a) (nhds b) =\n        filter.lift (uniformity \u03b1)\n          fun (s : set (\u03b1 \u00d7 \u03b1)) =>\n            filter.lift' (uniformity \u03b1)\n              fun (t : set (\u03b1 \u00d7 \u03b1)) =>\n                set.prod (set_of fun (y : \u03b1) => (y, a) \u2208 s) (set_of fun (y : \u03b1) => (b, y) \u2208 t) :=\n  sorry\n\ntheorem nhds_eq_uniformity_prod {\u03b1 : Type u_1} [uniform_space \u03b1] {a : \u03b1} {b : \u03b1} :\n    nhds (a, b) =\n        filter.lift' (uniformity \u03b1)\n          fun (s : set (\u03b1 \u00d7 \u03b1)) =>\n            set.prod (set_of fun (y : \u03b1) => (y, a) \u2208 s) (set_of fun (y : \u03b1) => (b, y) \u2208 s) :=\n  sorry\n\ntheorem nhdset_of_mem_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {d : set (\u03b1 \u00d7 \u03b1)}\n    (s : set (\u03b1 \u00d7 \u03b1)) (hd : d \u2208 uniformity \u03b1) :\n    \u2203 (t : set (\u03b1 \u00d7 \u03b1)),\n        is_open t \u2227\n          s \u2286 t \u2227\n            t \u2286\n              set_of\n                fun (p : \u03b1 \u00d7 \u03b1) =>\n                  \u2203 (x : \u03b1), \u2203 (y : \u03b1), (prod.fst p, x) \u2208 d \u2227 (x, y) \u2208 s \u2227 (y, prod.snd p) \u2208 d :=\n  sorry\n\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem nhds_le_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] (x : \u03b1) : nhds (x, x) \u2264 uniformity \u03b1 :=\n  sorry\n\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem supr_nhds_le_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    (supr fun (x : \u03b1) => nhds (x, x)) \u2264 uniformity \u03b1 :=\n  supr_le nhds_le_uniformity\n\n/-!\n### Closure and interior in uniform spaces\n-/\n\ntheorem closure_eq_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] (s : set (\u03b1 \u00d7 \u03b1)) :\n    closure s =\n        set.Inter\n          fun (V : set (\u03b1 \u00d7 \u03b1)) =>\n            set.Inter\n              fun (H : V \u2208 set_of fun (V : set (\u03b1 \u00d7 \u03b1)) => V \u2208 uniformity \u03b1 \u2227 symmetric_rel V) =>\n                comp_rel (comp_rel V s) V :=\n  sorry\n\ntheorem uniformity_has_basis_closed {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    filter.has_basis (uniformity \u03b1) (fun (V : set (\u03b1 \u00d7 \u03b1)) => V \u2208 uniformity \u03b1 \u2227 is_closed V) id :=\n  sorry\n\n/-- Closed entourages form a basis of the uniformity filter. -/\ntheorem uniformity_has_basis_closure {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    filter.has_basis (uniformity \u03b1) (fun (V : set (\u03b1 \u00d7 \u03b1)) => V \u2208 uniformity \u03b1) closure :=\n  sorry\n\ntheorem closure_eq_inter_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {t : set (\u03b1 \u00d7 \u03b1)} :\n    closure t =\n        set.Inter\n          fun (d : set (\u03b1 \u00d7 \u03b1)) =>\n            set.Inter fun (H : d \u2208 uniformity \u03b1) => comp_rel d (comp_rel t d) :=\n  sorry\n\ntheorem uniformity_eq_uniformity_closure {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    uniformity \u03b1 = filter.lift' (uniformity \u03b1) closure :=\n  sorry\n\ntheorem uniformity_eq_uniformity_interior {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    uniformity \u03b1 = filter.lift' (uniformity \u03b1) interior :=\n  sorry\n\ntheorem interior_mem_uniformity {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set (\u03b1 \u00d7 \u03b1)}\n    (hs : s \u2208 uniformity \u03b1) : interior s \u2208 uniformity \u03b1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (interior s \u2208 uniformity \u03b1)) uniformity_eq_uniformity_interior))\n    (filter.mem_lift' hs)\n\ntheorem mem_uniformity_is_closed {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set (\u03b1 \u00d7 \u03b1)}\n    (h : s \u2208 uniformity \u03b1) : \u2203 (t : set (\u03b1 \u00d7 \u03b1)), \u2203 (H : t \u2208 uniformity \u03b1), is_closed t \u2227 t \u2286 s :=\n  sorry\n\n/-- The uniform neighborhoods of all points of a dense set cover the whole space. -/\ntheorem dense.bUnion_uniformity_ball {\u03b1 : Type u_1} [uniform_space \u03b1] {s : set \u03b1} {U : set (\u03b1 \u00d7 \u03b1)}\n    (hs : dense s) (hU : U \u2208 uniformity \u03b1) :\n    (set.Union fun (x : \u03b1) => set.Union fun (H : x \u2208 s) => uniform_space.ball x U) = set.univ :=\n  sorry\n\n/-!\n### Uniformity bases\n-/\n\n/-- Open elements of `\ud835\udce4 \u03b1` form a basis of `\ud835\udce4 \u03b1`. -/\ntheorem uniformity_has_basis_open {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    filter.has_basis (uniformity \u03b1) (fun (V : set (\u03b1 \u00d7 \u03b1)) => V \u2208 uniformity \u03b1 \u2227 is_open V) id :=\n  sorry\n\ntheorem filter.has_basis.mem_uniformity_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    {p : \u03b2 \u2192 Prop} {s : \u03b2 \u2192 set (\u03b1 \u00d7 \u03b1)} (h : filter.has_basis (uniformity \u03b1) p s)\n    {t : set (\u03b1 \u00d7 \u03b1)} :\n    t \u2208 uniformity \u03b1 \u2194 \u2203 (i : \u03b2), \u2203 (hi : p i), \u2200 (a b : \u03b1), (a, b) \u2208 s i \u2192 (a, b) \u2208 t :=\n  sorry\n\n/-- Symmetric entourages form a basis of `\ud835\udce4 \u03b1` -/\ntheorem uniform_space.has_basis_symmetric {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    filter.has_basis (uniformity \u03b1) (fun (s : set (\u03b1 \u00d7 \u03b1)) => s \u2208 uniformity \u03b1 \u2227 symmetric_rel s)\n        id :=\n  sorry\n\n/-- Open elements `s : set (\u03b1 \u00d7 \u03b1)` of `\ud835\udce4 \u03b1` such that `(x, y) \u2208 s \u2194 (y, x) \u2208 s` form a basis\nof `\ud835\udce4 \u03b1`. -/\ntheorem uniformity_has_basis_open_symmetric {\u03b1 : Type u_1} [uniform_space \u03b1] :\n    filter.has_basis (uniformity \u03b1)\n        (fun (V : set (\u03b1 \u00d7 \u03b1)) => V \u2208 uniformity \u03b1 \u2227 is_open V \u2227 symmetric_rel V) id :=\n  sorry\n\ntheorem uniform_space.has_seq_basis {\u03b1 : Type u_1} [uniform_space \u03b1]\n    (h : filter.is_countably_generated (uniformity \u03b1)) :\n    \u2203 (V : \u2115 \u2192 set (\u03b1 \u00d7 \u03b1)),\n        filter.has_antimono_basis (uniformity \u03b1) (fun (_x : \u2115) => True) V \u2227\n          \u2200 (n : \u2115), symmetric_rel (V n) :=\n  sorry\n\n/-! ### Uniform continuity -/\n\n/-- A function `f : \u03b1 \u2192 \u03b2` 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 `\u03b1`. -/\ndef uniform_continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    (f : \u03b1 \u2192 \u03b2) :=\n  filter.tendsto (fun (x : \u03b1 \u00d7 \u03b1) => (f (prod.fst x), f (prod.snd x))) (uniformity \u03b1) (uniformity \u03b2)\n\n/-- A function `f : \u03b1 \u2192 \u03b2` is *uniformly continuous* on `s : set \u03b1` 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) :=\n  filter.tendsto (fun (x : \u03b1 \u00d7 \u03b1) => (f (prod.fst x), f (prod.snd x)))\n    (uniformity \u03b1 \u2293 filter.principal (set.prod s s)) (uniformity \u03b2)\n\ntheorem uniform_continuous_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} :\n    uniform_continuous f \u2194\n        \u2200 (r : set (\u03b2 \u00d7 \u03b2)),\n          r \u2208 uniformity \u03b2 \u2192\n            (set_of fun (x : \u03b1 \u00d7 \u03b1) => (f (prod.fst x), f (prod.snd x)) \u2208 r) \u2208 uniformity \u03b1 :=\n  iff.rfl\n\ntheorem uniform_continuous_iff_eventually {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    uniform_continuous f \u2194\n        \u2200 (r : set (\u03b2 \u00d7 \u03b2)),\n          r \u2208 uniformity \u03b2 \u2192\n            filter.eventually (fun (x : \u03b1 \u00d7 \u03b1) => (f (prod.fst x), f (prod.snd x)) \u2208 r)\n              (uniformity \u03b1) :=\n  iff.rfl\n\ntheorem uniform_continuous_of_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {c : \u03b1 \u2192 \u03b2} (h : \u2200 (a b : \u03b1), c a = c b) : uniform_continuous c :=\n  sorry\n\ntheorem uniform_continuous_id {\u03b1 : Type u_1} [uniform_space \u03b1] : uniform_continuous id := sorry\n\ntheorem uniform_continuous_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {b : \u03b2} : uniform_continuous fun (a : \u03b1) => b :=\n  uniform_continuous_of_const fun (_x _x : \u03b1) => rfl\n\ntheorem uniform_continuous.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : uniform_continuous g)\n    (hf : uniform_continuous f) : uniform_continuous (g \u2218 f) :=\n  filter.tendsto.comp hg hf\n\ntheorem filter.has_basis.uniform_continuous_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3}\n    {\u03b4 : Type u_4} [uniform_space \u03b1] [uniform_space \u03b2] {p : \u03b3 \u2192 Prop} {s : \u03b3 \u2192 set (\u03b1 \u00d7 \u03b1)}\n    (ha : filter.has_basis (uniformity \u03b1) p s) {q : \u03b4 \u2192 Prop} {t : \u03b4 \u2192 set (\u03b2 \u00d7 \u03b2)}\n    (hb : filter.has_basis (uniformity \u03b2) q t) {f : \u03b1 \u2192 \u03b2} :\n    uniform_continuous f \u2194\n        \u2200 (i : \u03b4), q i \u2192 \u2203 (j : \u03b3), \u2203 (hj : p j), \u2200 (x y : \u03b1), (x, y) \u2208 s j \u2192 (f x, f y) \u2208 t i :=\n  sorry\n\ntheorem filter.has_basis.uniform_continuous_on_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3}\n    {\u03b4 : Type u_4} [uniform_space \u03b1] [uniform_space \u03b2] {p : \u03b3 \u2192 Prop} {s : \u03b3 \u2192 set (\u03b1 \u00d7 \u03b1)}\n    (ha : filter.has_basis (uniformity \u03b1) p s) {q : \u03b4 \u2192 Prop} {t : \u03b4 \u2192 set (\u03b2 \u00d7 \u03b2)}\n    (hb : filter.has_basis (uniformity \u03b2) q t) {f : \u03b1 \u2192 \u03b2} {S : set \u03b1} :\n    uniform_continuous_on f S \u2194\n        \u2200 (i : \u03b4),\n          q i \u2192\n            \u2203 (j : \u03b3), \u2203 (hj : p j), \u2200 (x y : \u03b1), x \u2208 S \u2192 y \u2208 S \u2192 (x, y) \u2208 s j \u2192 (f x, f y) \u2208 t i :=\n  sorry\n\nprotected instance uniform_space.partial_order {\u03b1 : Type u_1} : partial_order (uniform_space \u03b1) :=\n  partial_order.mk\n    (fun (t s : uniform_space \u03b1) =>\n      uniform_space.core.uniformity uniform_space.to_core \u2264\n        uniform_space.core.uniformity uniform_space.to_core)\n    (preorder.lt._default\n      fun (t s : uniform_space \u03b1) =>\n        uniform_space.core.uniformity uniform_space.to_core \u2264\n          uniform_space.core.uniformity uniform_space.to_core)\n    sorry sorry sorry\n\nprotected instance uniform_space.has_Inf {\u03b1 : Type u_1} : has_Inf (uniform_space \u03b1) :=\n  has_Inf.mk\n    fun (s : set (uniform_space \u03b1)) =>\n      uniform_space.of_core\n        (uniform_space.core.mk\n          (infi fun (u : uniform_space \u03b1) => infi fun (H : u \u2208 s) => uniformity \u03b1) sorry sorry\n          sorry)\n\nprotected instance uniform_space.has_top {\u03b1 : Type u_1} : has_top (uniform_space \u03b1) :=\n  has_top.mk (uniform_space.of_core (uniform_space.core.mk \u22a4 sorry sorry sorry))\n\nprotected instance uniform_space.has_bot {\u03b1 : Type u_1} : has_bot (uniform_space \u03b1) :=\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 {\u03b1 : Type u_1} :\n    complete_lattice (uniform_space \u03b1) :=\n  complete_lattice.mk\n    (fun (a b : uniform_space \u03b1) => Inf (set_of fun (x : uniform_space \u03b1) => a \u2264 x \u2227 b \u2264 x))\n    partial_order.le partial_order.lt sorry sorry sorry sorry sorry sorry\n    (fun (a b : uniform_space \u03b1) => Inf (insert a (singleton b))) sorry sorry sorry \u22a4 sorry \u22a5 sorry\n    (fun (tt : set (uniform_space \u03b1)) =>\n      Inf (set_of fun (t : uniform_space \u03b1) => \u2200 (t' : uniform_space \u03b1), t' \u2208 tt \u2192 t' \u2264 t))\n    Inf sorry sorry sorry sorry\n\ntheorem infi_uniformity {\u03b1 : Type u_1} {\u03b9 : Sort u_2} {u : \u03b9 \u2192 uniform_space \u03b1} :\n    uniform_space.core.uniformity uniform_space.to_core =\n        infi fun (i : \u03b9) => uniform_space.core.uniformity uniform_space.to_core :=\n  sorry\n\ntheorem inf_uniformity {\u03b1 : Type u_1} {u : uniform_space \u03b1} {v : uniform_space \u03b1} :\n    uniform_space.core.uniformity uniform_space.to_core =\n        uniform_space.core.uniformity uniform_space.to_core \u2293\n          uniform_space.core.uniformity uniform_space.to_core :=\n  sorry\n\nprotected instance inhabited_uniform_space {\u03b1 : Type u_1} : Inhabited (uniform_space \u03b1) :=\n  { default := \u22a5 }\n\nprotected instance inhabited_uniform_space_core {\u03b1 : Type u_1} : Inhabited (uniform_space.core \u03b1) :=\n  { default := uniform_space.to_core }\n\n/-- Given `f : \u03b1 \u2192 \u03b2` and a uniformity `u` on `\u03b2`, the inverse image of `u` under `f`\n  is the inverse image in the filter sense of the induced function `\u03b1 \u00d7 \u03b1 \u2192 \u03b2 \u00d7 \u03b2`. -/\ndef uniform_space.comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (u : uniform_space \u03b2) :\n    uniform_space \u03b1 :=\n  uniform_space.mk\n    (uniform_space.core.mk\n      (filter.comap (fun (p : \u03b1 \u00d7 \u03b1) => (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (h : _inst_1 = uniform_space.comap f _inst_2) :\n    uniformity \u03b1 = filter.comap (prod.map f f) (uniformity \u03b2) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (uniformity \u03b1 = filter.comap (prod.map f f) (uniformity \u03b2))) h))\n    (Eq.refl (uniformity \u03b1))\n\ntheorem uniform_space_comap_id {\u03b1 : Type u_1} : uniform_space.comap id = id := sorry\n\ntheorem uniform_space.comap_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3}\n    [u\u03b3 : uniform_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} :\n    uniform_space.comap (g \u2218 f) u\u03b3 = uniform_space.comap f (uniform_space.comap g u\u03b3) :=\n  sorry\n\ntheorem uniform_continuous_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [u\u03b1 : uniform_space \u03b1]\n    [u\u03b2 : uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} : uniform_continuous f \u2194 u\u03b1 \u2264 uniform_space.comap f u\u03b2 :=\n  filter.map_le_iff_le_comap\n\ntheorem uniform_continuous_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} [u : uniform_space \u03b2] :\n    uniform_continuous f :=\n  filter.tendsto_comap\n\ntheorem to_topological_space_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {u : uniform_space \u03b2} :\n    uniform_space.to_topological_space =\n        topological_space.induced f uniform_space.to_topological_space :=\n  rfl\n\ntheorem uniform_continuous_comap' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {f : \u03b3 \u2192 \u03b2}\n    {g : \u03b1 \u2192 \u03b3} [v : uniform_space \u03b2] [u : uniform_space \u03b1] (h : uniform_continuous (f \u2218 g)) :\n    uniform_continuous g :=\n  iff.mpr filter.tendsto_comap_iff h\n\ntheorem to_topological_space_mono {\u03b1 : Type u_1} {u\u2081 : uniform_space \u03b1} {u\u2082 : uniform_space \u03b1}\n    (h : u\u2081 \u2264 u\u2082) : uniform_space.to_topological_space \u2264 uniform_space.to_topological_space :=\n  sorry\n\ntheorem uniform_continuous.continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} : uniform_space.to_topological_space = \u22a5 := rfl\n\ntheorem to_topological_space_top {\u03b1 : Type u_1} : uniform_space.to_topological_space = \u22a4 := sorry\n\ntheorem to_topological_space_infi {\u03b1 : Type u_1} {\u03b9 : Sort u_2} {u : \u03b9 \u2192 uniform_space \u03b1} :\n    uniform_space.to_topological_space = infi fun (i : \u03b9) => uniform_space.to_topological_space :=\n  sorry\n\ntheorem to_topological_space_Inf {\u03b1 : Type u_1} {s : set (uniform_space \u03b1)} :\n    uniform_space.to_topological_space =\n        infi\n          fun (i : uniform_space \u03b1) => infi fun (H : i \u2208 s) => uniform_space.to_topological_space :=\n  sorry\n\ntheorem to_topological_space_inf {\u03b1 : Type u_1} {u : uniform_space \u03b1} {v : uniform_space \u03b1} :\n    uniform_space.to_topological_space =\n        uniform_space.to_topological_space \u2293 uniform_space.to_topological_space :=\n  sorry\n\nprotected instance empty.uniform_space : uniform_space empty := \u22a5\n\nprotected instance unit.uniform_space : uniform_space Unit := \u22a5\n\nprotected instance bool.uniform_space : uniform_space Bool := \u22a5\n\nprotected instance nat.uniform_space : uniform_space \u2115 := \u22a5\n\nprotected instance int.uniform_space : uniform_space \u2124 := \u22a5\n\nprotected instance subtype.uniform_space {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [t : uniform_space \u03b1] :\n    uniform_space (Subtype p) :=\n  uniform_space.comap subtype.val t\n\ntheorem uniformity_subtype {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [t : uniform_space \u03b1] :\n    uniformity (Subtype p) =\n        filter.comap\n          (fun (q : Subtype p \u00d7 Subtype p) => (subtype.val (prod.fst q), subtype.val (prod.snd q)))\n          (uniformity \u03b1) :=\n  rfl\n\ntheorem uniform_continuous_subtype_val {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [uniform_space \u03b1] :\n    uniform_continuous subtype.val :=\n  uniform_continuous_comap\n\ntheorem uniform_continuous_subtype_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} {p : \u03b1 \u2192 Prop} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b2 \u2192 \u03b1} (hf : uniform_continuous f) (h : \u2200 (x : \u03b2), p (f x)) :\n    uniform_continuous fun (x : \u03b2) => { val := f x, property := h x } :=\n  uniform_continuous_comap' hf\n\ntheorem uniform_continuous_on_iff_restrict {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} :\n    uniform_continuous_on f s \u2194 uniform_continuous (set.restrict f s) :=\n  sorry\n\ntheorem tendsto_of_uniform_continuous_subtype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {a : \u03b1}\n    (hf : uniform_continuous fun (x : \u21a5s) => f (subtype.val x)) (ha : s \u2208 nhds a) :\n    filter.tendsto f (nhds a) (nhds (f a)) :=\n  sorry\n\ntheorem uniform_continuous_on.continuous_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [u\u2081 : uniform_space \u03b1]\n    [u\u2082 : uniform_space \u03b2] : uniform_space (\u03b1 \u00d7 \u03b2) :=\n  uniform_space.of_core_eq uniform_space.to_core prod.topological_space sorry\n\ntheorem uniformity_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2] :\n    uniformity (\u03b1 \u00d7 \u03b2) =\n        filter.comap (fun (p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2) => (prod.fst (prod.fst p), prod.fst (prod.snd p)))\n            (uniformity \u03b1) \u2293\n          filter.comap (fun (p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2) => (prod.snd (prod.fst p), prod.snd (prod.snd p)))\n            (uniformity \u03b2) :=\n  inf_uniformity\n\ntheorem uniformity_prod_eq_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2] :\n    uniformity (\u03b1 \u00d7 \u03b2) =\n        filter.map\n          (fun (p : (\u03b1 \u00d7 \u03b1) \u00d7 \u03b2 \u00d7 \u03b2) =>\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 \u03b1) (uniformity \u03b2)) :=\n  sorry\n\ntheorem mem_map_sets_iff' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : filter \u03b1} {m : \u03b1 \u2192 \u03b2} {t : set \u03b2} :\n    t \u2208 filter.sets (filter.map m f) \u2194 \u2203 (s : set \u03b1), \u2203 (H : s \u2208 f), m '' s \u2286 t :=\n  filter.mem_map_sets_iff\n\ntheorem mem_uniformity_of_uniform_continuous_invariant {\u03b1 : Type u_1} [uniform_space \u03b1]\n    {s : set (\u03b1 \u00d7 \u03b1)} {f : \u03b1 \u2192 \u03b1 \u2192 \u03b1}\n    (hf : uniform_continuous fun (p : \u03b1 \u00d7 \u03b1) => f (prod.fst p) (prod.snd p))\n    (hs : s \u2208 uniformity \u03b1) :\n    \u2203 (u : set (\u03b1 \u00d7 \u03b1)), \u2203 (H : u \u2208 uniformity \u03b1), \u2200 (a b c : \u03b1), (a, b) \u2208 u \u2192 (f a c, f b c) \u2208 s :=\n  sorry\n\ntheorem mem_uniform_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [t\u2081 : uniform_space \u03b1] [t\u2082 : uniform_space \u03b2]\n    {a : set (\u03b1 \u00d7 \u03b1)} {b : set (\u03b2 \u00d7 \u03b2)} (ha : a \u2208 uniformity \u03b1) (hb : b \u2208 uniformity \u03b2) :\n    (set_of\n          fun (p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2) =>\n            (prod.fst (prod.fst p), prod.fst (prod.snd p)) \u2208 a \u2227\n              (prod.snd (prod.fst p), prod.snd (prod.snd p)) \u2208 b) \u2208\n        uniformity (\u03b1 \u00d7 \u03b2) :=\n  sorry\n\ntheorem tendsto_prod_uniformity_fst {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] :\n    filter.tendsto (fun (p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2) => (prod.fst (prod.fst p), prod.fst (prod.snd p)))\n        (uniformity (\u03b1 \u00d7 \u03b2)) (uniformity \u03b1) :=\n  le_trans (filter.map_mono inf_le_left) filter.map_comap_le\n\ntheorem tendsto_prod_uniformity_snd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] :\n    filter.tendsto (fun (p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2) => (prod.snd (prod.fst p), prod.snd (prod.snd p)))\n        (uniformity (\u03b1 \u00d7 \u03b2)) (uniformity \u03b2) :=\n  le_trans (filter.map_mono inf_le_right) filter.map_comap_le\n\ntheorem uniform_continuous_fst {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2] :\n    uniform_continuous fun (p : \u03b1 \u00d7 \u03b2) => prod.fst p :=\n  tendsto_prod_uniformity_fst\n\ntheorem uniform_continuous_snd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2] :\n    uniform_continuous fun (p : \u03b1 \u00d7 \u03b2) => prod.snd p :=\n  tendsto_prod_uniformity_snd\n\ntheorem uniform_continuous.prod_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] {f\u2081 : \u03b1 \u2192 \u03b2} {f\u2082 : \u03b1 \u2192 \u03b3} (h\u2081 : uniform_continuous f\u2081)\n    (h\u2082 : uniform_continuous f\u2082) : uniform_continuous fun (a : \u03b1) => (f\u2081 a, f\u2082 a) :=\n  sorry\n\ntheorem uniform_continuous.prod_mk_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3}\n    [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (h : uniform_continuous f)\n    (b : \u03b2) : uniform_continuous fun (a : \u03b1) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3}\n    [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (h : uniform_continuous f)\n    (a : \u03b1) : uniform_continuous fun (b : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4}\n    [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] [uniform_space \u03b4] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4}\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [u : uniform_space \u03b1]\n    [v : uniform_space \u03b2] : uniform_space.to_topological_space = prod.topological_space :=\n  rfl\n\n/-- Uniform continuity for functions of two variables. -/\ndef uniform_continuous\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :=\n  uniform_continuous (function.uncurry f)\n\ntheorem uniform_continuous\u2082_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :\n    uniform_continuous\u2082 f \u2194 uniform_continuous (function.uncurry f) :=\n  iff.rfl\n\ntheorem uniform_continuous\u2082.uniform_continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3}\n    [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n    (h : uniform_continuous\u2082 f) : uniform_continuous (function.uncurry f) :=\n  h\n\ntheorem uniform_continuous\u2082_curry {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [uniform_space \u03b1]\n    [uniform_space \u03b2] [uniform_space \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) :\n    uniform_continuous\u2082 (function.curry f) \u2194 uniform_continuous f :=\n  sorry\n\ntheorem uniform_continuous\u2082.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4}\n    [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] [uniform_space \u03b4] {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n    {g : \u03b3 \u2192 \u03b4} (hg : uniform_continuous g) (hf : uniform_continuous\u2082 f) :\n    uniform_continuous\u2082 (function.bicompr g f) :=\n  uniform_continuous.comp hg hf\n\ntheorem uniform_continuous\u2082.bicompl {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4}\n    {\u03b4' : Type u_6} [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] [uniform_space \u03b4]\n    [uniform_space \u03b4'] {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {ga : \u03b4 \u2192 \u03b1} {gb : \u03b4' \u2192 \u03b2} (hf : uniform_continuous\u2082 f)\n    (hga : uniform_continuous ga) (hgb : uniform_continuous gb) :\n    uniform_continuous\u2082 (function.bicompl f ga gb) :=\n  uniform_continuous.comp (uniform_continuous\u2082.uniform_continuous hf)\n    (uniform_continuous.prod_map hga hgb)\n\ntheorem to_topological_space_subtype {\u03b1 : Type u_1} [u : uniform_space \u03b1] {p : \u03b1 \u2192 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2] :\n    uniform_space.core (\u03b1 \u2295 \u03b2) :=\n  uniform_space.core.mk'\n    (filter.map (fun (p : \u03b1 \u00d7 \u03b1) => (sum.inl (prod.fst p), sum.inl (prod.snd p))) (uniformity \u03b1) \u2294\n      filter.map (fun (p : \u03b2 \u00d7 \u03b2) => (sum.inr (prod.fst p), sum.inr (prod.snd p))) (uniformity \u03b2))\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {a : set (\u03b1 \u00d7 \u03b1)} (ha : a \u2208 uniformity \u03b1) {b : set (\u03b2 \u00d7 \u03b2)} (hb : b \u2208 uniformity \u03b2) :\n    (fun (p : \u03b1 \u00d7 \u03b1) => (sum.inl (prod.fst p), sum.inl (prod.snd p))) '' a \u222a\n          (fun (p : \u03b2 \u00d7 \u03b2) => (sum.inr (prod.fst p), sum.inr (prod.snd p))) '' b \u2208\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {s : set (\u03b1 \u2295 \u03b2)} (hs : is_open s) {x : \u03b1 \u2295 \u03b2} (xs : x \u2208 s) :\n    (set_of fun (p : (\u03b1 \u2295 \u03b2) \u00d7 (\u03b1 \u2295 \u03b2)) => prod.fst p = x \u2192 prod.snd p \u2208 s) \u2208\n        uniform_space.core.uniformity uniform_space.core.sum :=\n  sorry\n\ntheorem open_of_uniformity_sum_aux {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2]\n    {s : set (\u03b1 \u2295 \u03b2)}\n    (hs :\n      \u2200 (x : \u03b1 \u2295 \u03b2),\n        x \u2208 s \u2192\n          (set_of fun (p : (\u03b1 \u2295 \u03b2) \u00d7 (\u03b1 \u2295 \u03b2)) => prod.fst p = x \u2192 prod.snd p \u2208 s) \u2208\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [uniform_space \u03b2] : uniform_space (\u03b1 \u2295 \u03b2) :=\n  uniform_space.mk uniform_space.core.sum sorry\n\ntheorem sum.uniformity {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [uniform_space \u03b2] :\n    uniformity (\u03b1 \u2295 \u03b2) =\n        filter.map (fun (p : \u03b1 \u00d7 \u03b1) => (sum.inl (prod.fst p), sum.inl (prod.snd p)))\n            (uniformity \u03b1) \u2294\n          filter.map (fun (p : \u03b2 \u00d7 \u03b2) => (sum.inr (prod.fst p), sum.inr (prod.snd p)))\n            (uniformity \u03b2) :=\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 : \u03b9 \u2192 set \u03b1` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x \u2208 s` its `n`-neighborhood is contained in some `c i`. -/\ntheorem lebesgue_number_lemma {\u03b1 : Type u} [uniform_space \u03b1] {s : set \u03b1} {\u03b9 : Sort u_1}\n    {c : \u03b9 \u2192 set \u03b1} (hs : is_compact s) (hc\u2081 : \u2200 (i : \u03b9), is_open (c i))\n    (hc\u2082 : s \u2286 set.Union fun (i : \u03b9) => c i) :\n    \u2203 (n : set (\u03b1 \u00d7 \u03b1)),\n        \u2203 (H : n \u2208 uniformity \u03b1),\n          \u2200 (x : \u03b1), x \u2208 s \u2192 \u2203 (i : \u03b9), (set_of fun (y : \u03b1) => (x, y) \u2208 n) \u2286 c i :=\n  sorry\n\n/-- Let `c : set (set \u03b1)` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x \u2208 s` its `n`-neighborhood is contained in some `t \u2208 c`. -/\ntheorem lebesgue_number_lemma_sUnion {\u03b1 : Type u} [uniform_space \u03b1] {s : set \u03b1} {c : set (set \u03b1)}\n    (hs : is_compact s) (hc\u2081 : \u2200 (t : set \u03b1), t \u2208 c \u2192 is_open t) (hc\u2082 : s \u2286 \u22c3\u2080c) :\n    \u2203 (n : set (\u03b1 \u00d7 \u03b1)),\n        \u2203 (H : n \u2208 uniformity \u03b1),\n          \u2200 (x : \u03b1) (H : x \u2208 s), \u2203 (t : set \u03b1), \u2203 (H : t \u2208 c), \u2200 (y : \u03b1), (x, y) \u2208 n \u2192 y \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] {f : filter \u03b2}\n    {u : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n    filter.tendsto u f (nhds a) \u2194 filter.tendsto (fun (x : \u03b2) => (a, u x)) f (uniformity \u03b1) :=\n  sorry\n\ntheorem tendsto_nhds_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] {f : filter \u03b2} {u : \u03b2 \u2192 \u03b1}\n    {a : \u03b1} :\n    filter.tendsto u f (nhds a) \u2194 filter.tendsto (fun (x : \u03b2) => (u x, a)) f (uniformity \u03b1) :=\n  sorry\n\ntheorem continuous_at_iff'_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n    continuous_at f b \u2194 filter.tendsto (fun (x : \u03b2) => (f b, f x)) (nhds b) (uniformity \u03b1) :=\n  sorry\n\ntheorem continuous_at_iff'_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n    continuous_at f b \u2194 filter.tendsto (fun (x : \u03b2) => (f x, f b)) (nhds b) (uniformity \u03b1) :=\n  sorry\n\ntheorem continuous_at_iff_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [topological_space \u03b2]\n    {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n    continuous_at f b \u2194\n        filter.tendsto (fun (x : \u03b2 \u00d7 \u03b2) => (f (prod.fst x), f (prod.snd x))) (nhds (b, b))\n          (uniformity \u03b1) :=\n  sorry\n\ntheorem continuous_within_at_iff'_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} {s : set \u03b2} :\n    continuous_within_at f s b \u2194\n        filter.tendsto (fun (x : \u03b2) => (f b, f x)) (nhds_within b s) (uniformity \u03b1) :=\n  sorry\n\ntheorem continuous_within_at_iff'_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} {s : set \u03b2} :\n    continuous_within_at f s b \u2194\n        filter.tendsto (fun (x : \u03b2) => (f x, f b)) (nhds_within b s) (uniformity \u03b1) :=\n  sorry\n\ntheorem continuous_on_iff'_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {s : set \u03b2} :\n    continuous_on f s \u2194\n        \u2200 (b : \u03b2),\n          b \u2208 s \u2192 filter.tendsto (fun (x : \u03b2) => (f b, f x)) (nhds_within b s) (uniformity \u03b1) :=\n  sorry\n\ntheorem continuous_on_iff'_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1]\n    [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {s : set \u03b2} :\n    continuous_on f s \u2194\n        \u2200 (b : \u03b2),\n          b \u2208 s \u2192 filter.tendsto (fun (x : \u03b2) => (f x, f b)) (nhds_within b s) (uniformity \u03b1) :=\n  sorry\n\ntheorem continuous_iff'_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [topological_space \u03b2]\n    {f : \u03b2 \u2192 \u03b1} :\n    continuous f \u2194 \u2200 (b : \u03b2), filter.tendsto (fun (x : \u03b2) => (f b, f x)) (nhds b) (uniformity \u03b1) :=\n  iff.trans continuous_iff_continuous_at (forall_congr fun (b : \u03b2) => tendsto_nhds_right)\n\ntheorem continuous_iff'_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [topological_space \u03b2]\n    {f : \u03b2 \u2192 \u03b1} :\n    continuous f \u2194 \u2200 (b : \u03b2), filter.tendsto (fun (x : \u03b2) => (f x, f b)) (nhds b) (uniformity \u03b1) :=\n  iff.trans continuous_iff_continuous_at (forall_congr fun (b : \u03b2) => tendsto_nhds_left)\n\nend uniform\n\n\ntheorem filter.tendsto.congr_uniformity {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {g : \u03b1 \u2192 \u03b2} {l : filter \u03b1} {b : \u03b2} (hf : filter.tendsto f l (nhds b))\n    (hg : filter.tendsto (fun (x : \u03b1) => (f x, g x)) l (uniformity \u03b2)) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {g : \u03b1 \u2192 \u03b2} {l : filter \u03b1} {b : \u03b2}\n    (hfg : filter.tendsto (fun (x : \u03b1) => (f x, g x)) l (uniformity \u03b2)) :\n    filter.tendsto f l (nhds b) \u2194 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 \u21a5(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] {\u03b9 : Type u_4}\n    [fintype \u03b9] (p : \u03b9 \u2192 P) : finite_dimensional k \u21a5(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] {\u03b9 : Type u_4}\n    [fintype \u03b9] (p : \u03b9 \u2192 P) (s : set \u03b9) : finite_dimensional k \u21a5(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 \u21a5(affine_subspace.direction (affine_span k s)) :=\n  Eq.symm (direction_affine_span k s) \u25b8 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] {\u03b9 : Type u_4}\n    [fintype \u03b9] (p : \u03b9 \u2192 P) :\n    finite_dimensional k \u21a5(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    {\u03b9 : Type u_4} [fintype \u03b9] (p : \u03b9 \u2192 P) (s : set \u03b9) :\n    finite_dimensional k \u21a5(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] {\u03b9 : Type u_4}\n    {p : \u03b9 \u2192 P} (hi : affine_independent k p) {s : finset \u03b9} {n : \u2115} (hc : finset.card s = n + 1) :\n    finite_dimensional.findim k \u21a5(vector_span k (p '' \u2191s)) = 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] {\u03b9 : Type u_4} [fintype \u03b9]\n    {p : \u03b9 \u2192 P} (hi : affine_independent k p) {n : \u2115} (hc : fintype.card \u03b9 = n + 1) :\n    finite_dimensional.findim k \u21a5(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] {\u03b9 : Type u_4} {p : \u03b9 \u2192 P} (hi : affine_independent k p) {s : finset \u03b9}\n    {sm : submodule k V} [finite_dimensional k \u21a5sm] (hle : vector_span k (p '' \u2191s) \u2264 sm)\n    (hc : finset.card s = finite_dimensional.findim k \u21a5sm + 1) : vector_span k (p '' \u2191s) = 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    {\u03b9 : Type u_4} [fintype \u03b9] {p : \u03b9 \u2192 P} (hi : affine_independent k p) {sm : submodule k V}\n    [finite_dimensional k \u21a5sm] (hle : vector_span k (set.range p) \u2264 sm)\n    (hc : fintype.card \u03b9 = finite_dimensional.findim k \u21a5sm + 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] {\u03b9 : Type u_4} {p : \u03b9 \u2192 P} (hi : affine_independent k p) {s : finset \u03b9}\n    {sp : affine_subspace k P} [finite_dimensional k \u21a5(affine_subspace.direction sp)]\n    (hle : affine_span k (p '' \u2191s) \u2264 sp)\n    (hc : finset.card s = finite_dimensional.findim k \u21a5(affine_subspace.direction sp) + 1) :\n    affine_span k (p '' \u2191s) = 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    {\u03b9 : Type u_4} [fintype \u03b9] {p : \u03b9 \u2192 P} (hi : affine_independent k p) {sp : affine_subspace k P}\n    [finite_dimensional k \u21a5(affine_subspace.direction sp)] (hle : affine_span k (set.range p) \u2264 sp)\n    (hc : fintype.card \u03b9 = finite_dimensional.findim k \u21a5(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`\u22a4`. -/\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    {\u03b9 : Type u_4} [finite_dimensional k V] [fintype \u03b9] {p : \u03b9 \u2192 P} (hi : affine_independent k p)\n    (hc : fintype.card \u03b9 = finite_dimensional.findim k V + 1) : vector_span k (set.range p) = \u22a4 :=\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`\u22a4`. -/\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    {\u03b9 : Type u_4} [finite_dimensional k V] [fintype \u03b9] {p : \u03b9 \u2192 P} (hi : affine_independent k p)\n    (hc : fintype.card \u03b9 = finite_dimensional.findim k V + 1) : affine_span k (set.range p) = \u22a4 :=\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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) (s : finset \u03b9)\n    {n : \u2115} (hc : finset.card s = n + 1) :\n    finite_dimensional.findim k \u21a5(vector_span k (p '' \u2191s)) \u2264 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] {\u03b9 : Type u_4} [fintype \u03b9] (p : \u03b9 \u2192 P) {n : \u2115}\n    (hc : fintype.card \u03b9 = n + 1) :\n    finite_dimensional.findim k \u21a5(vector_span k (set.range p)) \u2264 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] {\u03b9 : Type u_4} [fintype \u03b9]\n    (p : \u03b9 \u2192 P) {n : \u2115} (hc : fintype.card \u03b9 = n + 1) :\n    affine_independent k p \u2194 finite_dimensional.findim k \u21a5(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] {\u03b9 : Type u_4} [fintype \u03b9]\n    (p : \u03b9 \u2192 P) {n : \u2115} (hc : fintype.card \u03b9 = n + 1) :\n    affine_independent k p \u2194 n \u2264 finite_dimensional.findim k \u21a5(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] {\u03b9 : Type u_4}\n    [fintype \u03b9] (p : \u03b9 \u2192 P) {n : \u2115} (hc : fintype.card \u03b9 = n + bit0 1) :\n    affine_independent k p \u2194 \u00acfinite_dimensional.findim k \u21a5(vector_span k (set.range p)) \u2264 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] {\u03b9 : Type u_4}\n    [fintype \u03b9] (p : \u03b9 \u2192 P) {n : \u2115} (hc : fintype.card \u03b9 = n + bit0 1) :\n    finite_dimensional.findim k \u21a5(vector_span k (set.range p)) \u2264 n \u2194 \u00acaffine_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 \u21a5(vector_span k s) \u2264 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 \u2194 vector_space.dim k \u21a5(vector_span k s) \u2264 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 \u21a5(vector_span k s)] :\n    collinear k s \u2194 finite_dimensional.findim k \u21a5(vector_span k s) \u2264 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 \u2205 :=\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\u2080` 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\u2080`. -/\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\u2080 : P} (h : p\u2080 \u2208 s) :\n    collinear k s \u2194 \u2203 (v : V), \u2200 (p : P), p \u2208 s \u2192 \u2203 (r : k), p = r \u2022 v +\u1d65 p\u2080 :=\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 \u2194 \u2203 (p\u2080 : P), \u2203 (v : V), \u2200 (p : P), p \u2208 s \u2192 \u2203 (r : k), p = r \u2022 v +\u1d65 p\u2080 :=\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\u2081 : P) (p\u2082 : P) :\n    collinear k (insert p\u2081 (singleton p\u2082)) :=\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) \u2192 P) :\n    affine_independent k p \u2194 \u00accollinear 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) \u2192 P) :\n    collinear k (set.range p) \u2194 \u00acaffine_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 \u211a)\n\nvariables (b : matrix m one \u211a) (c x : matrix n one \u211a)\n\nlocal notation M `\u2b1d` N := M.mul N\nlocal postfix `\u1d40` : 1500 := transpose\n\ndef is_feasible : Prop := 0 \u2264 x \u2227 A \u2b1d x = b\n\ninstance decidable_le : decidable_rel ((\u2264) : matrix m n \u211a \u2192 matrix m n \u211a \u2192 Prop) :=\n\u03bb M N, show decidable (\u2200 i j, M i j \u2264 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 \u2227 \u2200 y, is_feasible A b y \u2192 c\u1d40 \u2b1d y \u2264 c\u1d40 \u2b1d x\n\ndef basis (B : m \u2192 n) : matrix m m \u211a := minor A id B\n\ndef non_basis (B : m \u2192 n) : matrix m {b // b \u2209 univ.image B}  \u211a :=\nminor A id subtype.val\n\ndef c_basis (B : m \u2192 n) : matrix m one \u211a := minor c B id\n\ndef c_non_basis (B : m \u2192 n) : matrix {b // b \u2209 univ.image B} one \u211a :=\nminor c subtype.val id\n\n--#print non_basis\ndef reduced_cost (B : m \u2192 n) : Prop :=\nis_invertible (basis A B) \u2227\n(c_non_basis c B)\u1d40 \u2b1d 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 \u2227 is_feasible A b x \u2192 is_optimal A b c x := sorry\n\nset_option profiler true\n\ndef ex.A : matrix (fin 2) (fin 4) \u211a :=\n\u03bb 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 := \u03bb i _, (list.nth_le [1,1,0,0] i sorry)\n\ndef ex.b : cvec 2 := \u03bb i _, (list.nth_le [2,4] i sorry)\n\ndef ex.x : cvec 4 := \u03bb 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) \u211a :=\n  \u03bb 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 := \u03bb i _, (list.nth_le [1,1,0,0] i sorry)\n\ndef ex2.b : cvec 2 := \u03bb i _, (list.nth_le [2,4] i sorry)\n\ndef ex2.x : cvec 4 := \u03bb 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 \u2964 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 `\ud835\udfed (free_monoidal_category C) \u2245 full_normalize \u22d9 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    `(((\ud835\udfd9_ C) \u2297 X\u2081) \u2297 X\u2082) \u2297 \u22ef`. -/\n@[nolint has_nonempty_instance]\ninductive normal_monoidal_object : Type u\n| unit : normal_monoidal_object\n| tensor : normal_monoidal_object \u2192 C \u2192 normal_monoidal_object\n\nend\n\nlocal notation `F` := free_monoidal_category\nlocal notation `N` := discrete \u2218 normal_monoidal_object\nlocal infixr ` \u27f6\u1d50 `:10 := hom\n\n/-- Auxiliary definition for `inclusion`. -/\n@[simp] def inclusion_obj : normal_monoidal_object C \u2192 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 \u2964 F C :=\ndiscrete.functor inclusion_obj\n\n/-- Auxiliary definition for `normalize`. -/\n@[simp] def normalize_obj : F C \u2192 normal_monoidal_object C \u2192 N C\n| unit n := \u27e8n\u27e9\n| (of X) n := \u27e8normal_monoidal_object.tensor n X\u27e9\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 (\ud835\udfd9_ (F C)) n = \u27e8n\u27e9 :=\nrfl\n\n@[simp] lemma normalize_obj_tensor (X Y : F C) (n : normal_monoidal_object C) :\n  normalize_obj (X \u2297 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 : \u03a0 {X Y : F C},\n  (X \u27f6\u1d50 Y) \u2192\n    ((discrete.functor (normalize_obj X) : _ \u2964 N C) \u27f6 discrete.functor (normalize_obj Y))\n| _ _ (id _) := \ud835\udfd9 _\n| _ _ (\u03b1_hom _ _ _) := \u27e8\u03bb X, \ud835\udfd9 _, by { rintros \u27e8X\u27e9 \u27e8Y\u27e9 f, simp }\u27e9\n| _ _ (\u03b1_inv _ _ _) := \u27e8\u03bb X, \ud835\udfd9 _, by { rintros \u27e8X\u27e9 \u27e8Y\u27e9 f, simp }\u27e9\n| _ _ (l_hom _) := \u27e8\u03bb X, \ud835\udfd9 _, by { rintros \u27e8X\u27e9 \u27e8Y\u27e9 f, simp }\u27e9\n| _ _ (l_inv _) := \u27e8\u03bb X, \ud835\udfd9 _, by { rintros \u27e8X\u27e9 \u27e8Y\u27e9 f, simp }\u27e9\n| _ _ (\u03c1_hom _) := \u27e8\u03bb \u27e8X\u27e9, \u27e8\u27e8by simp\u27e9\u27e9, by { rintros \u27e8X\u27e9 \u27e8Y\u27e9 f, simp }\u27e9\n| _ _ (\u03c1_inv _) := \u27e8\u03bb \u27e8X\u27e9, \u27e8\u27e8by simp\u27e9\u27e9, by { rintros \u27e8X\u27e9 \u27e8Y\u27e9 f, simp }\u27e9\n| X Y (@comp _ U V W f g) := normalize_map_aux f \u226b normalize_map_aux g\n| X Y (@hom.tensor _ T U V W f g) :=\n    \u27e8\u03bb X, (normalize_map_aux g).app (normalize_obj T X.as) \u226b\n      (discrete.functor (normalize_obj W) : _ \u2964 N C).map ((normalize_map_aux f).app X), by tidy\u27e9\n\nend\n\nsection\nvariables (C)\n\n/-- Our normalization procedure works by first defining a functor `F C \u2964 (N C \u2964 N C)` (which turns\n    out to be very easy), and then obtain a functor `F C \u2964 N C` by plugging in the normal object\n    `\ud835\udfd9_ C`. -/\n@[simp] def normalize : F C \u2964 N C \u2964 N C :=\n{ obj := \u03bb X, discrete.functor (normalize_obj X),\n  map := \u03bb 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 \u2964 N C \u2964 F C :=\nnormalize C \u22d9 (whiskering_right _ _ _).obj inclusion\n\n/-- The normalization functor for the free monoidal category over `C`. -/\ndef full_normalize : F C \u2964 N C :=\n{ obj := \u03bb X, ((normalize C).obj X).obj \u27e8normal_monoidal_object.unit\u27e9,\n  map := \u03bb X Y f, ((normalize C).map f).app \u27e8normal_monoidal_object.unit\u27e9 }\n\n/-- Given an object `X` of the free monoidal category and an object `n` in normal form, taking\n    the tensor product `n \u2297 X` in the free monoidal category is functorial in both `X` and `n`. -/\n@[simp] def tensor_func : F C \u2964 N C \u2964 F C :=\n{ obj := \u03bb X, discrete.functor (\u03bb n, (inclusion.obj \u27e8n\u27e9) \u2297 X),\n  map := \u03bb X Y f, \u27e8\u03bb n, \ud835\udfd9 _ \u2297 f, by { rintro \u27e8X\u27e9 \u27e8Y\u27e9, tidy }\u27e9 }\n\nlemma tensor_func_map_app {X Y : F C} (f : X \u27f6 Y) (n) : ((tensor_func C).map f).app n =\n  \ud835\udfd9 _ \u2297 f :=\nrfl\n\nlemma tensor_func_obj_map (Z : F C) {n n' : N C} (f : n \u27f6 n') :\n  ((tensor_func C).obj Z).map f = inclusion.map f \u2297 \ud835\udfd9 Z :=\nby { cases n, cases n', tidy }\n\n/-- Auxiliary definition for `normalize_iso`. Here we construct the isomorphism between\n    `n \u2297 X` and `normalize X n`. -/\n@[simp] def normalize_iso_app :\n  \u03a0 (X : F C) (n : N C), ((tensor_func C).obj X).obj n \u2245 ((normalize' C).obj X).obj n\n| (of X) n := iso.refl _\n| unit n := \u03c1_ _\n| (tensor X Y) n :=\n    (\u03b1_ _ _ _).symm \u226a\u226b tensor_iso (normalize_iso_app X n) (iso.refl _) \u226a\u226b normalize_iso_app _ _\n\n@[simp] lemma normalize_iso_app_tensor (X Y : F C) (n : N C) :\n  normalize_iso_app C (X \u2297 Y) n =\n  (\u03b1_ _ _ _).symm \u226a\u226b tensor_iso (normalize_iso_app C X n) (iso.refl _) \u226a\u226b\n    normalize_iso_app _ _ _ :=\nrfl\n\n@[simp] lemma normalize_iso_app_unitor (n : N C) : normalize_iso_app C (\ud835\udfd9_ (F C)) n = \u03c1_ _ :=\nrfl\n\n/-- Auxiliary definition for `normalize_iso`. -/\n@[simp] def normalize_iso_aux (X : F C) : (tensor_func C).obj X \u2245 (normalize' C).obj X :=\nnat_iso.of_components (normalize_iso_app C X) (by { rintros \u27e8X\u27e9 \u27e8Y\u27e9, tidy })\n\nsection\nvariables {D : Type u} [category.{u} D] {I : Type u} (f : I \u2192 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 \u27f6 X) : (discrete.functor f).map g = \ud835\udfd9 _ :=\nby tidy\n\nend\n\n/-- The isomorphism between `n \u2297 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 \u2245 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, \u2190pentagon_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      \u2190associator_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 [\u2190(iso.inv_comp_eq _).2 (right_unitor_tensor _ _), category.assoc, \u2190right_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 [\u2190(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 \u27e6f_g\u27e7, \u2190category.assoc, f_ih_f \u27e6f_f\u27e7, category.assoc,\n      \u2190functor.map_comp],\n    congr' 2 },\n  { dsimp at *,\n    rw associator_inv_naturality_assoc,\n    slice_lhs 2 3 { rw [\u2190tensor_comp, f_ih_f \u27e6f_f\u27e7] },\n    conv_lhs { rw [\u2190@category.id_comp (F C) _ _ _ \u27e6f_g\u27e7] },\n    simp only [category.comp_id, tensor_comp, category.assoc],\n    congr' 2,\n    rw [\u2190mk_tensor, quotient.lift_mk],\n    dsimp,\n    rw [functor.map_comp, \u2190category.assoc, \u2190f_ih_g \u27e6f_g\u27e7, \u2190@category.comp_id (F C) _ _ _ \u27e6f_g\u27e7,\n      \u2190category.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 : \ud835\udfed (F C) \u2245 full_normalize C \u22d9 inclusion :=\nnat_iso.of_components\n  (\u03bb X, (\u03bb_ X).symm \u226a\u226b ((normalize_iso C).app X).app \u27e8normal_monoidal_object.unit\u27e9)\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 (\u03bb 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\u03bb _ _,\n  \u27e8\u03bb f g, have (full_normalize C).map f = (full_normalize C).map g, from subsingleton.elim _ _,\n  begin\n    rw [\u2190functor.id_map f, \u2190functor.id_map g],\n    simp [\u2190nat_iso.naturality_2 (full_normalize_iso.{u} C), this]\n  end\u27e9\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 : \u03a0 {X Y : F C}, (X \u27f6\u1d50 Y) \u2192 (Y \u27f6\u1d50 X)\n| _ _ (id X) := id X\n| _ _ (\u03b1_hom _ _ _) := \u03b1_inv _ _ _\n| _ _ (\u03b1_inv _ _ _) := \u03b1_hom _ _ _\n| _ _ (\u03c1_hom _) := \u03c1_inv _\n| _ _ (\u03c1_inv _) := \u03c1_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 := \u03bb X Y, quotient.lift (\u03bb f, \u27e6inverse_aux f\u27e7) (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 ..expressions.time_expr_current\n\n\nopen lang.time\n\n--K is now an abbreviation - set to \u211a\ndef std_fr : time_frame_expr := [time_std_frame K] \n--def std_sp : time_space_expr std_fr :=  [mk_space K std_fr.value] --issue with has_lit type class\ndef std_sp : time_space_expr std_fr :=  [time_std_space K]\n\nlemma p1 : std_sp.value = time_std_space K := rfl\n\n\n/-\nUse of new notation\n-/\ndef launch_time : \n  time_expr std_sp\n  :=\n  [(mk_time (time_std_space K) 0)]\n\ndef one_second := \n  [(mk_duration std_sp.value 1)]\n\n-- TODO: Introduce concrete syntax notations\n\n/-\nFrame definition updated with embedding into expression\n-/\ndef mission_frame : time_frame_expr  := \n    mk_time_frame_expr launch_time one_second\n/-\nConstruct a new space with this frame\n\ndef mission_time := mk_space \u211a (time_frame)\n-/\n\n/-\nSpace definition updated with embedding into expression\n-/\n\ndef mission_space :=\n  [(mk_space \u211a mission_frame.value)]\n\n\n/-\nDefine new times and durations in terms of this new frame,\ndemonstrate \n-/\n\ndef ego_launch_time : \n  time_expr mission_space\n  :=\n  [(mk_time mission_space.value 0)]\n\ndef one_minute : \n  duration_expr mission_space\n  := \n  [(mk_duration mission_space.value 60)]\n\ndef t_plus_one_minute' : _ := \n  one_minute +\u1d65 ego_launch_time     -- coordinate free in coordinate space\ndef t_plus_one_second : _  := one_second +\u1d65 ego_launch_time     -- frame error\n\n\n\n--build a transform\ndef std_to_mission : \n  transform_expr std_sp mission_space  --type\n  :=    \n  [(std_sp.value.time_tr mission_space.value)] --value\n\n#check std_to_mission.value\n\n--transform original launch_time point in std_space to mission space\ndef launch_time_in_time_frame : \n  time_expr mission_space \n  := \n    [(std_to_mission.value.transform_time launch_time.value)]\n\n\ndef mission_to_std : \n  transform_expr mission_space std_sp\n  := \n  [(mission_space.value.time_tr std_sp.value)]\n\n--cannot deeply embed this due to type limitations\ndef std_to_std_compose := \n  transform_expr.compose_lit std_to_mission.value mission_to_std.value", "meta": {"author": "kevinsullivan", "repo": "lang", "sha": "e9d869bff94fb13ad9262222a6f3c4aafba82d5e", "save_path": "github-repos/lean/kevinsullivan-lang", "path": "github-repos/lean/kevinsullivan-lang/lang-e9d869bff94fb13ad9262222a6f3c4aafba82d5e/demo/expressions_demo_current_alternate.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.4923497100234096}}
{"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 : \u2200 p : polynomial k, p.monic \u2192 irreducible p \u2192 nat_degree p \u2260 0 \u2192 \u2203 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 \u27e8 1 , rfl \u27e9,\n  },\n  apply H p hmonic hirr hdeg,\nend\n\nlemma of_nat_degree_ne_zero_exists_root {k : Type*} [field k]\n  (H : \u2200 p : polynomial k, nat_degree p \u2260 0 \u2192 \u2203 x, p.eval x = 0) :\n  is_alg_closed k :=\nof_exists_root_nat_degree $ \u03bb _ _ hdeg, H _\n\nend is_alg_closed\n\n\nsection zmod\n\nvariables (p : \u2115) [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  \u03a0 {n : \u2115}, (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 \u2190 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 \u2190 (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 \u2190 ulift.up_down \u2191n,\n    rw \u2190 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 : \u2115) [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 {\u03b1 \u03b2 : Type*} (hequiv : \u03b1 \u2243 \u03b2) (p : Type* \u2192 Prop) :\n--   p \u03b1 \u2194 p \u03b2 :=\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--   \u03a0 {n : \u2115}, (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 \u2190 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 \u2190 (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 \u2190 ulift.up_down \u2191n,\n--     rw \u2190 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\u00f6lzl, 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\u27e8\u03bb M N [semiring M] [semiring N], by exactI @ring_hom.to_fun M N _ _,\n \u03bb M [semiring M], by exactI @ring_hom.id M _,\n \u03bb M N P [semiring M] [semiring N] [semiring P], by exactI @ring_hom.comp M N P _ _ _,\n \u03bb M N [semiring M] [semiring N], by exactI @ring_hom.coe_inj M N _ _\u27e9\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 \u2192+* S) : of R \u27f6 of S := f\n\ninstance : inhabited SemiRing := \u27e8of punit\u27e9\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\u2082 SemiRing Mon :=\nbundled_hom.mk_has_forget\u2082\n  (\u03bb R hR, @monoid_with_zero.to_monoid R (@semiring.to_monoid_with_zero R hR))\n  (\u03bb R\u2081 R\u2082, ring_hom.to_monoid_hom) (\u03bb _ _ _, rfl)\n\ninstance has_forget_to_AddCommMon : has_forget\u2082 SemiRing AddCommMon :=\n-- can't use bundled_hom.mk_has_forget\u2082, since AddCommMon is an induced category\n{ forget\u2082 :=\n  { obj := \u03bb R, AddCommMon.of R,\n    map := \u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\n\nattribute [derive [(\u03bb 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 \u2192+* S) : of R \u27f6 of S := f\n\ninstance : inhabited Ring := \u27e8of punit\u27e9\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\u2082 Ring SemiRing := bundled_hom.forget\u2082 _ _\ninstance has_forget_to_AddCommGroup : has_forget\u2082 Ring AddCommGroup :=\n-- can't use bundled_hom.mk_has_forget\u2082, since AddCommGroup is an induced category\n{ forget\u2082 :=\n  { obj := \u03bb R, AddCommGroup.of R,\n    map := \u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\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 \u2192+* S) : of R \u27f6 of S := f\n\ninstance : inhabited CommSemiRing := \u27e8of punit\u27e9\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\u2082 CommSemiRing SemiRing := bundled_hom.forget\u2082 _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommMon : has_forget\u2082 CommSemiRing CommMon :=\nhas_forget\u2082.mk'\n  (\u03bb R : CommSemiRing, CommMon.of R) (\u03bb R, rfl)\n  (\u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\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 \u2192+* S) : of R \u27f6 of S := f\n\ninstance : inhabited CommRing := \u27e8of punit\u27e9\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\u2082 CommRing Ring := bundled_hom.forget\u2082 _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommSemiRing : has_forget\u2082 CommRing CommSemiRing :=\nhas_forget\u2082.mk' (\u03bb R : CommRing, CommSemiRing.of R) (\u03bb R, rfl) (\u03bb R\u2081 R\u2082 f, f) (by tidy)\n\ninstance : full (forget\u2082 CommRing CommSemiRing) :=\n{ preimage := \u03bb 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 \u27f6 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 \u2243+* Y) : Ring.of X \u2245 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 \u2243+* Y) :\n  CommRing.of X \u2245 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 \u2245 Y) : X \u2243+* 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 \u2245 Y) : X \u2243+* 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 \u2243+* Y) \u2245 (Ring.of X \u2245 Ring.of Y) :=\n{ hom := \u03bb e, e.to_Ring_iso,\n  inv := \u03bb 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 \u2243+* Y) \u2245 (CommRing.of X \u2245 CommRing.of Y) :=\n{ hom := \u03bb e, e.to_CommRing_iso,\n  inv := \u03bb i, i.CommRing_iso_to_ring_equiv, }\n\ninstance Ring.forget_reflects_isos : reflects_isomorphisms (forget Ring.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Ring).map f),\n    let e : X \u2243+* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Ring_iso).1\u27e9,\n  end }\n\ninstance CommRing.forget_reflects_isos : reflects_isomorphisms (forget CommRing.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommRing).map f),\n    let e : X \u2243+* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommRing_iso).1\u27e9,\n  end }\n\n-- It would be nice if we could have the following,\n-- but it requires making `reflects_isomorphisms_forget\u2082` an instance,\n-- which can cause typeclass loops:\n\nlocal attribute [priority 50,instance] reflects_isomorphisms_forget\u2082\nexample : reflects_isomorphisms (forget\u2082 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\u00e9bastien Gou\u00ebzel, 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 `\u2225x\u2225 = 0 \u2192 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 \u03c3]`.\n\n-/\n\nnoncomputable theory\nopen_locale classical nnreal topological_space\n\n-- the `\u2097` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariables {\ud835\udd5c : Type*} {\ud835\udd5c\u2082 : Type*} {\ud835\udd5c\u2083 : Type*} {E : Type*} {F : Type*} {F\u2097 : Type*} {G : Type*}\n  {G\u2097 : Type*}\n\nsection semi_normed\n\nvariables [semi_normed_group E] [semi_normed_group F] [semi_normed_group F\u2097] [semi_normed_group G]\n  [semi_normed_group G\u2097]\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 `\u2225f x\u2225 \u2264 C \u2225x\u2225` from the continuity of f.\nHowever, the other direction always holds.\nIn this section, we just assume that `\ud835\udd5c` is a normed field.\nIn the remainder of the file, it will be non-discrete. -/\n\nvariables [normed_field \ud835\udd5c] [normed_field \ud835\udd5c\u2082] [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c\u2082 F]\nvariables [normed_space \ud835\udd5c G] {\u03c3 : \ud835\udd5c \u2192+* \ud835\udd5c\u2082} (f : E \u2192\u209b\u2097[\u03c3] F)\n\nlemma linear_map.lipschitz_of_bound (C : \u211d) (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\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 : \u211d\u22650) (h : \u2200 x, \u2225f x\u2225\u208a \u2264 C * \u2225x\u2225\u208a) :\n  lipschitz_with C f :=\nf.to_add_monoid_hom.lipschitz_of_bound_nnnorm C h\n\ntheorem linear_map.antilipschitz_of_bound {K : \u211d\u22650} (h : \u2200 x, \u2225x\u2225 \u2264 K * \u2225f x\u2225) :\n  antilipschitz_with K f :=\nantilipschitz_with.of_le_mul_dist $\n\u03bb x y, by simpa only [dist_eq_norm, f.map_sub] using h (x - y)\n\nlemma linear_map.bound_of_antilipschitz {K : \u211d\u22650} (h : antilipschitz_with K f) (x) :\n  \u2225x\u2225 \u2264 K * \u2225f x\u2225 :=\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 : \u211d) (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  uniform_continuous f :=\n(f.lipschitz_of_bound C h).uniform_continuous\n\nlemma linear_map.continuous_of_bound (C : \u211d) (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\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 : \u211d) (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) : E \u2192SL[\u03c3] F :=\n\u27e8f, linear_map.continuous_of_bound f C h\u27e9\n\n/-- Reinterpret a linear map `\ud835\udd5c \u2192\u2097[\ud835\udd5c] 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\u2081 (f : \ud835\udd5c \u2192\u2097[\ud835\udd5c] E) : \ud835\udd5c \u2192L[\ud835\udd5c] E :=\nf.mk_continuous (\u2225f 1\u2225) $ \u03bb x, le_of_eq $\nby { conv_lhs { rw \u2190 mul_one x }, rw [\u2190 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 : \u2203C, \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) : E \u2192SL[\u03c3] F :=\n\u27e8f, let \u27e8C, hC\u27e9 := h in linear_map.continuous_of_bound f C hC\u27e9\n\nlemma continuous_of_linear_of_bound\u209b\u2097 {f : E \u2192 F} (h_add : \u2200 x y, f (x + y) = f x + f y)\n  (h_smul : \u2200 (c : \ud835\udd5c) x, f (c \u2022 x) = (\u03c3 c) \u2022 f x) {C : \u211d} (h_bound : \u2200 x, \u2225f x\u2225 \u2264 C*\u2225x\u2225) :\n  continuous f :=\nlet \u03c6 : E \u2192\u209b\u2097[\u03c3] F := { to_fun := f, map_add' := h_add, map_smul' := h_smul } in\n\u03c6.continuous_of_bound C h_bound\n\nlemma continuous_of_linear_of_bound {f : E \u2192 G} (h_add : \u2200 x y, f (x + y) = f x + f y)\n  (h_smul : \u2200 (c : \ud835\udd5c) x, f (c \u2022 x) = c \u2022 f x) {C : \u211d} (h_bound : \u2200 x, \u2225f x\u2225 \u2264 C*\u2225x\u2225) :\n  continuous f :=\nlet \u03c6 : E \u2192\u2097[\ud835\udd5c] G := { to_fun := f, map_add' := h_add, map_smul' := h_smul } in\n\u03c6.continuous_of_bound C h_bound\n\n@[simp, norm_cast] lemma linear_map.mk_continuous_coe (C : \u211d) (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  ((f.mk_continuous C h) : E \u2192\u209b\u2097[\u03c3] F) = f := rfl\n\n@[simp] lemma linear_map.mk_continuous_apply (C : \u211d) (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) (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 : \u2203C, \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  ((f.mk_continuous_of_exists_bound h) : E \u2192\u209b\u2097[\u03c3] F) = f := rfl\n\n@[simp] lemma linear_map.mk_continuous_of_exists_bound_apply (h : \u2203C, \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) (x : E) :\n  f.mk_continuous_of_exists_bound h x = f x := rfl\n\n@[simp] lemma linear_map.to_continuous_linear_map\u2081_coe (f : \ud835\udd5c \u2192\u2097[\ud835\udd5c] E) :\n  (f.to_continuous_linear_map\u2081 : \ud835\udd5c \u2192\u2097[\ud835\udd5c] E) = f :=\nrfl\n\n@[simp] lemma linear_map.to_continuous_linear_map\u2081_apply (f : \ud835\udd5c \u2192\u2097[\ud835\udd5c] E) (x) :\n  f.to_continuous_linear_map\u2081 x = f x :=\nrfl\n\nend normed_field\n\nvariables [nondiscrete_normed_field \ud835\udd5c] [nondiscrete_normed_field \ud835\udd5c\u2082] [nondiscrete_normed_field \ud835\udd5c\u2083]\n  [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c\u2082 F] [normed_space \ud835\udd5c F\u2097]\n  [normed_space \ud835\udd5c\u2083 G] [normed_space \ud835\udd5c G\u2097]\n  {\u03c3\u2081\u2082 : \ud835\udd5c \u2192+* \ud835\udd5c\u2082} {\u03c3\u2082\u2083 : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c\u2083} {\u03c3\u2081\u2083 : \ud835\udd5c \u2192+* \ud835\udd5c\u2083}\n  [ring_hom_comp_triple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083]\n\n/-- If `\u2225x\u2225 = 0` and `f` is continuous then `\u2225f x\u2225 = 0`. -/\nlemma norm_image_of_norm_zero {f : E \u2192\u209b\u2097[\u03c3\u2081\u2082] F} (hf : continuous f) {x : E} (hx : \u2225x\u2225 = 0) :\n  \u2225f x\u2225 = 0 :=\nbegin\n  refine le_antisymm (le_of_forall_pos_le_add (\u03bb \u03b5 h\u03b5, _)) (norm_nonneg (f x)),\n  rcases normed_group.tendsto_nhds_nhds.1 (hf.tendsto 0) \u03b5 h\u03b5 with \u27e8\u03b4, \u03b4_pos, h\u03b4\u27e9,\n  replace h\u03b4 := h\u03b4 x,\n  rw [sub_zero, hx] at h\u03b4,\n  replace h\u03b4 := le_of_lt (h\u03b4 \u03b4_pos),\n  rw [linear_map.map_zero, sub_zero] at h\u03b4,\n  rwa [zero_add]\nend\n\nsection\n\nvariables [ring_hom_isometric \u03c3\u2081\u2082] [ring_hom_isometric \u03c3\u2082\u2083]\n\nlemma linear_map.bound_of_shell_semi_normed (f : E \u2192\u209b\u2097[\u03c3\u2081\u2082] F) {\u03b5 C : \u211d} (\u03b5_pos : 0 < \u03b5) {c : \ud835\udd5c}\n  (hc : 1 < \u2225c\u2225) (hf : \u2200 x, \u03b5 / \u2225c\u2225 \u2264 \u2225x\u2225 \u2192 \u2225x\u2225 < \u03b5 \u2192 \u2225f x\u2225 \u2264 C * \u2225x\u2225) {x : E} (hx : \u2225x\u2225 \u2260 0) :\n  \u2225f x\u2225 \u2264 C * \u2225x\u2225 :=\nbegin\n  rcases rescale_to_shell_semi_normed hc \u03b5_pos hx with \u27e8\u03b4, h\u03b4, \u03b4xle, le\u03b4x, \u03b4inv\u27e9,\n  have := hf (\u03b4 \u2022 x) le\u03b4x \u03b4xle,\n  simpa only [f.map_smul\u209b\u2097, norm_smul, mul_left_comm C, mul_le_mul_left (norm_pos_iff.2 h\u03b4),\n              ring_hom_isometric.is_iso] using hf (\u03b4 \u2022 x) le\u03b4x \u03b4xle\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 `\u03b5`. The nondiscreteness is then used to\nrescale any element into an element of norm in `[\u03b5/C, \u03b5]`, whose image has a controlled norm. The\nnorm control for the original element follows by rescaling. -/\nlemma linear_map.bound_of_continuous (f : E \u2192\u209b\u2097[\u03c3\u2081\u2082] F) (hf : continuous f) :\n  \u2203 C, 0 < C \u2227 (\u2200 x : E, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :=\nbegin\n  rcases normed_group.tendsto_nhds_nhds.1 (hf.tendsto 0) 1 zero_lt_one with \u27e8\u03b5, \u03b5_pos, h\u03b5\u27e9,\n  simp only [sub_zero, f.map_zero] at h\u03b5,\n  rcases normed_field.exists_one_lt_norm \ud835\udd5c with \u27e8c, hc\u27e9,\n  have : 0 < \u2225c\u2225 / \u03b5, from div_pos (zero_lt_one.trans hc) \u03b5_pos,\n  refine \u27e8\u2225c\u2225 / \u03b5, this, \u03bb x, _\u27e9,\n  by_cases hx : \u2225x\u2225 = 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 \u03b5_pos hc (\u03bb x hle hlt, _) hx,\n  refine (h\u03b5 _ hlt).le.trans _,\n  rwa [\u2190 div_le_iff' this, one_div_div]\nend\n\nend\n\nnamespace continuous_linear_map\n\ntheorem bound [ring_hom_isometric \u03c3\u2081\u2082] (f : E \u2192SL[\u03c3\u2081\u2082] F) :\n  \u2203 C, 0 < C \u2227 (\u2200 x : E, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :=\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 `\ud835\udd5c` need not have `\u211d` 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 \u2192\u209b\u2097[\u03c3\u2081\u2082] F) (a : \u211d) (hf : \u2200x, \u2225f x\u2225 = a * \u2225x\u2225) : E \u2192SL[\u03c3\u2081\u2082] F :=\nf.mk_continuous a (\u03bb x, le_of_eq (hf x))\n\nvariable (\ud835\udd5c)\n\nlemma to_span_singleton_homothety (x : E) (c : \ud835\udd5c) :\n  \u2225linear_map.to_span_singleton \ud835\udd5c E x c\u2225 = \u2225x\u2225 * \u2225c\u2225 :=\nby {rw mul_comm, exact norm_smul _ _}\n\n/-- Given an element `x` of a normed space `E` over a field `\ud835\udd5c`, the natural continuous\n    linear map from `\ud835\udd5c` to `E` by taking multiples of `x`.-/\ndef to_span_singleton (x : E) : \ud835\udd5c \u2192L[\ud835\udd5c] E :=\nof_homothety (linear_map.to_span_singleton \ud835\udd5c E x) \u2225x\u2225 (to_span_singleton_homothety \ud835\udd5c x)\n\nlemma to_span_singleton_apply (x : E) (r : \ud835\udd5c) : to_span_singleton \ud835\udd5c x r = r \u2022 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 \ud835\udd5c (x + y) = to_span_singleton \ud835\udd5c x + to_span_singleton \ud835\udd5c y :=\nby { ext1, simp [to_span_singleton_apply], }\n\nlemma to_span_singleton_smul' (\ud835\udd5c') [nondiscrete_normed_field \ud835\udd5c'] [normed_space \ud835\udd5c' E]\n  [smul_comm_class \ud835\udd5c \ud835\udd5c' E] (c : \ud835\udd5c') (x : E) :\n  to_span_singleton \ud835\udd5c (c \u2022 x) = c \u2022 to_span_singleton \ud835\udd5c x :=\nby { ext1, rw [to_span_singleton_apply, smul_apply, to_span_singleton_apply, smul_comm], }\n\nlemma to_span_singleton_smul (c : \ud835\udd5c) (x : E) :\n  to_span_singleton \ud835\udd5c (c \u2022 x) = c \u2022 to_span_singleton \ud835\udd5c x :=\nto_span_singleton_smul' \ud835\udd5c \ud835\udd5c c x\n\nvariables (\ud835\udd5c E)\n/-- Given a unit-length element `x` of a normed space `E` over a field `\ud835\udd5c`, the natural linear\n    isometry map from `\ud835\udd5c` to `E` by taking multiples of `x`.-/\ndef _root_.linear_isometry.to_span_singleton {v : E} (hv : \u2225v\u2225 = 1) : \ud835\udd5c \u2192\u2097\u1d62[\ud835\udd5c] E :=\n{ norm_map' := \u03bb x, by simp [norm_smul, hv],\n  .. linear_map.to_span_singleton \ud835\udd5c E v }\nvariables {\ud835\udd5c E}\n\n@[simp] lemma _root_.linear_isometry.to_span_singleton_apply {v : E} (hv : \u2225v\u2225 = 1) (a : \ud835\udd5c) :\n  linear_isometry.to_span_singleton \ud835\udd5c E hv a = a \u2022 v :=\nrfl\n\n@[simp] lemma _root_.linear_isometry.coe_to_span_singleton {v : E} (hv : \u2225v\u2225 = 1) :\n  (linear_isometry.to_span_singleton \ud835\udd5c E hv).to_linear_map = linear_map.to_span_singleton \ud835\udd5c 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 \u2192SL[\u03c3\u2081\u2082] F) := Inf {c | 0 \u2264 c \u2227 \u2200 x, \u2225f x\u2225 \u2264 c * \u2225x\u2225}\ninstance has_op_norm : has_norm (E \u2192SL[\u03c3\u2081\u2082] F) := \u27e8op_norm\u27e9\n\nlemma norm_def (f : E \u2192SL[\u03c3\u2081\u2082] F) : \u2225f\u2225 = Inf {c | 0 \u2264 c \u2227 \u2200 x, \u2225f x\u2225 \u2264 c * \u2225x\u2225} := 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 \u03c3\u2081\u2082] {f : E \u2192SL[\u03c3\u2081\u2082] F} :\n  \u2203 c, c \u2208 { c | 0 \u2264 c \u2227 \u2200 x, \u2225f x\u2225 \u2264 c * \u2225x\u2225 } :=\nlet \u27e8M, hMp, hMb\u27e9 := f.bound in \u27e8M, le_of_lt hMp, hMb\u27e9\n\nlemma bounds_bdd_below {f : E \u2192SL[\u03c3\u2081\u2082] F} :\n  bdd_below { c | 0 \u2264 c \u2227 \u2200 x, \u2225f x\u2225 \u2264 c * \u2225x\u2225 } :=\n\u27e80, \u03bb _ \u27e8hn, _\u27e9, hn\u27e9\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 \u2192SL[\u03c3\u2081\u2082] F) {M : \u211d} (hMp: 0 \u2264 M) (hM : \u2200 x, \u2225f x\u2225 \u2264 M * \u2225x\u2225) :\n  \u2225f\u2225 \u2264 M :=\ncInf_le bounds_bdd_below \u27e8hMp, hM\u27e9\n\ntheorem op_norm_le_of_lipschitz {f : E \u2192SL[\u03c3\u2081\u2082] F} {K : \u211d\u22650} (hf : lipschitz_with K f) :\n  \u2225f\u2225 \u2264 K :=\nf.op_norm_le_bound K.2 $ \u03bb x, by simpa only [dist_zero_right, f.map_zero] using hf.dist_le_mul x 0\n\nlemma op_norm_eq_of_bounds {\u03c6 : E \u2192SL[\u03c3\u2081\u2082] F} {M : \u211d} (M_nonneg : 0 \u2264 M)\n  (h_above : \u2200 x, \u2225\u03c6 x\u2225 \u2264 M*\u2225x\u2225) (h_below : \u2200 N \u2265 0, (\u2200 x, \u2225\u03c6 x\u2225 \u2264 N*\u2225x\u2225) \u2192 M \u2264 N) :\n  \u2225\u03c6\u2225 = M :=\nle_antisymm (\u03c6.op_norm_le_bound M_nonneg h_above)\n  ((le_cInf_iff continuous_linear_map.bounds_bdd_below \u27e8M, M_nonneg, h_above\u27e9).mpr $\n   \u03bb N \u27e8N_nonneg, hN\u27e9, h_below N N_nonneg hN)\n\nlemma op_norm_neg (f : E \u2192SL[\u03c3\u2081\u2082] F) : \u2225-f\u2225 = \u2225f\u2225 := by simp only [norm_def, neg_apply, norm_neg]\n\ntheorem antilipschitz_of_bound (f : E \u2192SL[\u03c3\u2081\u2082] F) {K : \u211d\u22650} (h : \u2200 x, \u2225x\u2225 \u2264 K * \u2225f x\u2225) :\n  antilipschitz_with K f :=\nlinear_map.antilipschitz_of_bound _ h\n\nlemma bound_of_antilipschitz (f : E \u2192SL[\u03c3\u2081\u2082] F) {K : \u211d\u22650} (h : antilipschitz_with K f) (x) :\n  \u2225x\u2225 \u2264 K * \u2225f x\u2225 :=\nlinear_map.bound_of_antilipschitz _ h x\n\nsection\n\nvariables [ring_hom_isometric \u03c3\u2081\u2082] [ring_hom_isometric \u03c3\u2082\u2083]\n  (f g : E \u2192SL[\u03c3\u2081\u2082] F) (h : F \u2192SL[\u03c3\u2082\u2083] G) (x : E)\n\nlemma op_norm_nonneg : 0 \u2264 \u2225f\u2225 :=\nle_cInf bounds_nonempty (\u03bb _ \u27e8hx, _\u27e9, hx)\n\n/-- The fundamental property of the operator norm: `\u2225f x\u2225 \u2264 \u2225f\u2225 * \u2225x\u2225`. -/\ntheorem le_op_norm : \u2225f x\u2225 \u2264 \u2225f\u2225 * \u2225x\u2225 :=\nbegin\n  obtain \u27e8C, Cpos, hC\u27e9 := f.bound,\n  replace hC := hC x,\n  by_cases h : \u2225x\u2225 = 0,\n  { rwa [h, mul_zero] at \u22a2 hC },\n  have hlt : 0 < \u2225x\u2225 := lt_of_le_of_ne (norm_nonneg x) (ne.symm h),\n  exact  (div_le_iff hlt).mp (le_cInf bounds_nonempty (\u03bb c \u27e8_, hc\u27e9,\n    (div_le_iff hlt).mpr $ by { apply hc })),\nend\n\ntheorem le_op_norm_of_le {c : \u211d} {x} (h : \u2225x\u2225 \u2264 c) : \u2225f x\u2225 \u2264 \u2225f\u2225 * 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 : \u211d} (h : \u2225f\u2225 \u2264 c) (x : E) : \u2225f x\u2225 \u2264 c * \u2225x\u2225 :=\n(f.le_op_norm x).trans (mul_le_mul_of_nonneg_right h (norm_nonneg x))\n\nlemma ratio_le_op_norm : \u2225f x\u2225 / \u2225x\u2225 \u2264 \u2225f\u2225 :=\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 : \u2225x\u2225 \u2264 1 \u2192 \u2225f x\u2225 \u2264 \u2225f\u2225 :=\nmul_one \u2225f\u2225 \u25b8 f.le_op_norm_of_le\n\nlemma op_norm_le_of_shell {f : E \u2192SL[\u03c3\u2081\u2082] F} {\u03b5 C : \u211d} (\u03b5_pos : 0 < \u03b5) (hC : 0 \u2264 C)\n  {c : \ud835\udd5c} (hc : 1 < \u2225c\u2225) (hf : \u2200 x, \u03b5 / \u2225c\u2225 \u2264 \u2225x\u2225 \u2192 \u2225x\u2225 < \u03b5 \u2192 \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  \u2225f\u2225 \u2264 C :=\nbegin\n  refine f.op_norm_le_bound hC (\u03bb x, _),\n  by_cases hx : \u2225x\u2225 = 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 \u03b5_pos hc hf hx\nend\n\nlemma op_norm_le_of_ball {f : E \u2192SL[\u03c3\u2081\u2082] F} {\u03b5 : \u211d} {C : \u211d} (\u03b5_pos : 0 < \u03b5) (hC : 0 \u2264 C)\n  (hf : \u2200 x \u2208 ball (0 : E) \u03b5, \u2225f x\u2225 \u2264 C * \u2225x\u2225) : \u2225f\u2225 \u2264 C :=\nbegin\n  rcases normed_field.exists_one_lt_norm \ud835\udd5c with \u27e8c, hc\u27e9,\n  refine op_norm_le_of_shell \u03b5_pos hC hc (\u03bb x _ hx, hf x _),\n  rwa ball_zero_eq\nend\n\nlemma op_norm_le_of_nhds_zero {f : E \u2192SL[\u03c3\u2081\u2082] F} {C : \u211d} (hC : 0 \u2264 C)\n  (hf : \u2200\u1da0 x in \ud835\udcdd (0 : E), \u2225f x\u2225 \u2264 C * \u2225x\u2225) : \u2225f\u2225 \u2264 C :=\nlet \u27e8\u03b5, \u03b50, h\u03b5\u27e9 := metric.eventually_nhds_iff_ball.1 hf in op_norm_le_of_ball \u03b50 hC h\u03b5\n\nlemma op_norm_le_of_shell' {f : E \u2192SL[\u03c3\u2081\u2082] F} {\u03b5 C : \u211d} (\u03b5_pos : 0 < \u03b5) (hC : 0 \u2264 C)\n  {c : \ud835\udd5c} (hc : \u2225c\u2225 < 1) (hf : \u2200 x, \u03b5 * \u2225c\u2225 \u2264 \u2225x\u2225 \u2192 \u2225x\u2225 < \u03b5 \u2192 \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  \u2225f\u2225 \u2264 C :=\nbegin\n  by_cases h0 : c = 0,\n  { refine op_norm_le_of_ball \u03b5_pos hC (\u03bb x hx, hf x _ _),\n    { simp [h0] },\n    { rwa ball_zero_eq at hx } },\n  { rw [\u2190 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 \u03b5_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 : \u2225f + g\u2225 \u2264 \u2225f\u2225 + \u2225g\u2225 :=\n(f + g).op_norm_le_bound (add_nonneg f.op_norm_nonneg g.op_norm_nonneg) $\n  \u03bb 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 : \u2225(0 : E \u2192SL[\u03c3\u2081\u2082] F)\u2225 = 0 :=\nle_antisymm (cInf_le bounds_bdd_below\n    \u27e8ge_of_eq rfl, \u03bb _, le_of_eq (by { rw [zero_mul], exact norm_zero })\u27e9)\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 : \u2225id \ud835\udd5c E\u2225 \u2264 1 :=\nop_norm_le_bound _ zero_le_one (\u03bbx, 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 : \u2203 (x : E), \u2225x\u2225 \u2260 0) : \u2225id \ud835\udd5c E\u2225 = 1 :=\nle_antisymm norm_id_le $ let \u27e8x, hx\u27e9 := h in\nhave _ := (id \ud835\udd5c E).ratio_le_op_norm x,\nby rwa [id_apply, div_self hx] at this\n\nlemma op_norm_smul_le {\ud835\udd5c' : Type*} [normed_field \ud835\udd5c'] [normed_space \ud835\udd5c' F]\n  [smul_comm_class \ud835\udd5c\u2082 \ud835\udd5c' F] (c : \ud835\udd5c') (f : E \u2192SL[\u03c3\u2081\u2082] F) : \u2225c \u2022 f\u2225 \u2264 \u2225c\u2225 * \u2225f\u2225 :=\n((c \u2022 f).op_norm_le_bound\n  (mul_nonneg (norm_nonneg _) (op_norm_nonneg _)) (\u03bb _,\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 \u2192SL[\u03c3\u2081\u2082] F) :=\nsemi_normed_group.of_core _ \u27e8op_norm_zero, \u03bb x y, op_norm_add_le x y, op_norm_neg\u27e9\n\ninstance to_normed_space {\ud835\udd5c' : Type*} [normed_field \ud835\udd5c'] [normed_space \ud835\udd5c' F]\n  [smul_comm_class \ud835\udd5c\u2082 \ud835\udd5c' F] : normed_space \ud835\udd5c' (E \u2192SL[\u03c3\u2081\u2082] F) :=\n\u27e8op_norm_smul_le\u27e9\n\ninclude \u03c3\u2081\u2083\n/-- The operator norm is submultiplicative. -/\nlemma op_norm_comp_le (f : E \u2192SL[\u03c3\u2081\u2082] F) : \u2225h.comp f\u2225 \u2264 \u2225h\u2225 * \u2225f\u2225 :=\n(cInf_le bounds_bdd_below\n  \u27e8mul_nonneg (op_norm_nonneg _) (op_norm_nonneg _), \u03bb x,\n    by { rw mul_assoc, exact h.le_op_norm_of_le (f.le_op_norm x) } \u27e9)\nomit \u03c3\u2081\u2083\n\n/-- Continuous linear maps form a seminormed ring with respect to the operator norm. -/\ninstance to_semi_normed_ring : semi_normed_ring (E \u2192L[\ud835\udd5c] E) :=\n{ norm_mul := \u03bb f g, op_norm_comp_le f g,\n  .. continuous_linear_map.to_semi_normed_group }\n\ntheorem le_op_nnnorm : \u2225f x\u2225\u208a \u2264 \u2225f\u2225\u208a * \u2225x\u2225\u208a := f.le_op_norm x\n\n/-- continuous linear maps are Lipschitz continuous. -/\ntheorem lipschitz : lipschitz_with \u2225f\u2225\u208a f :=\n(f : E \u2192\u209b\u2097[\u03c3\u2081\u2082] 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 \u2225x\u2225\u208a (\u03bb f : E \u2192SL[\u03c3\u2081\u2082] F, f x) :=\nlipschitz_with_iff_norm_sub_le.2 $ \u03bb f g, ((f - g).le_op_norm x).trans_eq (mul_comm _ _)\n\nend\n\nsection\n\nlemma op_norm_ext [ring_hom_isometric \u03c3\u2081\u2083] (f : E \u2192SL[\u03c3\u2081\u2082] F) (g : E \u2192SL[\u03c3\u2081\u2083] G)\n  (h : \u2200 x, \u2225f x\u2225 = \u2225g x\u2225) : \u2225f\u2225 = \u2225g\u2225 :=\nop_norm_eq_of_bounds (norm_nonneg _) (\u03bb x, by { rw h x, exact le_op_norm _ _ })\n  (\u03bb c hc h\u2082, op_norm_le_bound _ hc (\u03bb z, by { rw \u2190h z, exact h\u2082 z }))\n\nvariables [ring_hom_isometric \u03c3\u2082\u2083]\n\ntheorem op_norm_le_bound\u2082 (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) {C : \u211d} (h0 : 0 \u2264 C)\n  (hC : \u2200 x y, \u2225f x y\u2225 \u2264 C * \u2225x\u2225 * \u2225y\u2225) :\n  \u2225f\u2225 \u2264 C :=\nf.op_norm_le_bound h0 $ \u03bb x,\n  (f x).op_norm_le_bound (mul_nonneg h0 (norm_nonneg _)) $ hC x\n\ntheorem le_op_norm\u2082 [ring_hom_isometric \u03c3\u2081\u2083] (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) (x : E) (y : F) :\n  \u2225f x y\u2225 \u2264 \u2225f\u2225 * \u2225x\u2225 * \u2225y\u2225 :=\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 \u2192L[\ud835\udd5c] F\u2097) (g : E \u2192L[\ud835\udd5c] G\u2097) : \u2225f.prod g\u2225 = \u2225(f, g)\u2225 :=\nle_antisymm\n  (op_norm_le_bound _ (norm_nonneg _) $ \u03bb 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 _) $ \u03bb x, (le_max_left _ _).trans ((f.prod g).le_op_norm x))\n    (op_norm_le_bound _ (norm_nonneg _) $ \u03bb 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\u2097\u1d62 (R : Type*) [semiring R] [module R F\u2097] [module R G\u2097]\n  [has_continuous_const_smul R F\u2097] [has_continuous_const_smul R G\u2097]\n  [smul_comm_class \ud835\udd5c R F\u2097] [smul_comm_class \ud835\udd5c R G\u2097] :\n  (E \u2192L[\ud835\udd5c] F\u2097) \u00d7 (E \u2192L[\ud835\udd5c] G\u2097) \u2243\u2097\u1d62[R] (E \u2192L[\ud835\udd5c] F\u2097 \u00d7 G\u2097) :=\n\u27e8prod\u2097 R, \u03bb \u27e8f, g\u27e9, op_norm_prod f g\u27e9\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 \u2192SL[\u03c3\u2081\u2082] F) : isometry f \u2194 \u2200x, \u2225f x\u2225 = \u2225x\u2225 :=\nf.to_linear_map.to_add_monoid_hom.isometry_iff_norm\n\nvariables [ring_hom_isometric \u03c3\u2081\u2082] (f : E \u2192SL[\u03c3\u2081\u2082] 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] : \u2225f\u2225 = 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 \u03c3\u2081\u2082]\n  (c : \ud835\udd5c) (f g : E \u2192SL[\u03c3\u2081\u2082] F) (h : F \u2192SL[\u03c3\u2082\u2083] G) (x y z : E)\n\nopen asymptotics\n\ntheorem is_O_with_id (l : filter E) : is_O_with \u2225f\u2225 f (\u03bb x, x) l :=\nis_O_with_of_le' _ f.le_op_norm\n\ntheorem is_O_id (l : filter E) : is_O f (\u03bb x, x) l :=\n(f.is_O_with_id l).is_O\n\ntheorem is_O_with_comp [ring_hom_isometric \u03c3\u2082\u2083] {\u03b1 : Type*} (g : F \u2192SL[\u03c3\u2082\u2083] G) (f : \u03b1 \u2192 F)\n  (l : filter \u03b1) :\n  is_O_with \u2225g\u2225 (\u03bb x', g (f x')) f l :=\n(g.is_O_with_id \u22a4).comp_tendsto le_top\n\ntheorem is_O_comp [ring_hom_isometric \u03c3\u2082\u2083] {\u03b1 : Type*} (g : F \u2192SL[\u03c3\u2082\u2083] G) (f : \u03b1 \u2192 F)\n  (l : filter \u03b1) :\n  is_O (\u03bb x', g (f x')) f l :=\n(g.is_O_with_comp f l).is_O\n\ntheorem is_O_with_sub (f : E \u2192SL[\u03c3\u2081\u2082] F) (l : filter E) (x : E) :\n  is_O_with \u2225f\u2225 (\u03bb x', f (x' - x)) (\u03bb x', x' - x) l :=\nf.is_O_with_comp _ l\n\ntheorem is_O_sub (f : E \u2192SL[\u03c3\u2081\u2082] F) (l : filter E) (x : E) :\n  is_O (\u03bb x', f (x' - x)) (\u03bb 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 \u2192\u209b\u2097\u1d62[\u03c3\u2081\u2082] F) :\n  \u2225f.to_continuous_linear_map\u2225 \u2264 1 :=\nf.to_continuous_linear_map.op_norm_le_bound zero_le_one $ \u03bb 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 \u2192\u209b\u2097[\u03c3\u2081\u2082] F) {C : \u211d} (hC : 0 \u2264 C) (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  \u2225f.mk_continuous C h\u2225 \u2264 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 \u2192\u209b\u2097[\u03c3\u2081\u2082] F) {C : \u211d} (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  \u2225f.mk_continuous C h\u2225 \u2264 max C 0 :=\ncontinuous_linear_map.op_norm_le_bound _ (le_max_right _ _) $ \u03bb x, (h x).trans $\n  mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg x)\n\nvariables [ring_hom_isometric \u03c3\u2082\u2083]\n\n/-- Create a bilinear map (represented as a map `E \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] 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\u2082`. -/\ndef mk_continuous\u2082 (f : E \u2192\u209b\u2097[\u03c3\u2081\u2083] F \u2192\u209b\u2097[\u03c3\u2082\u2083] G) (C : \u211d)\n  (hC : \u2200 x y, \u2225f x y\u2225 \u2264 C * \u2225x\u2225 * \u2225y\u2225) :\n  E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G :=\nlinear_map.mk_continuous\n  { to_fun := \u03bb x, (f x).mk_continuous (C * \u2225x\u2225) (hC x),\n    map_add' := \u03bb x y, by { ext z, simp },\n    map_smul' := \u03bb c x, by { ext z, simp } }\n  (max C 0) $ \u03bb 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\u2082_apply (f : E \u2192\u209b\u2097[\u03c3\u2081\u2083] F \u2192\u209b\u2097[\u03c3\u2082\u2083] G) {C : \u211d}\n  (hC : \u2200 x y, \u2225f x y\u2225 \u2264 C * \u2225x\u2225 * \u2225y\u2225) (x : E) (y : F) :\n  f.mk_continuous\u2082 C hC x y = f x y :=\nrfl\n\nlemma mk_continuous\u2082_norm_le' (f : E \u2192\u209b\u2097[\u03c3\u2081\u2083] F \u2192\u209b\u2097[\u03c3\u2082\u2083] G) {C : \u211d}\n  (hC : \u2200 x y, \u2225f x y\u2225 \u2264 C * \u2225x\u2225 * \u2225y\u2225) :\n  \u2225f.mk_continuous\u2082 C hC\u2225 \u2264 max C 0 :=\nmk_continuous_norm_le _ (le_max_iff.2 $ or.inr le_rfl) _\n\nlemma mk_continuous\u2082_norm_le (f : E \u2192\u209b\u2097[\u03c3\u2081\u2083] F \u2192\u209b\u2097[\u03c3\u2082\u2083] G) {C : \u211d} (h0 : 0 \u2264 C)\n  (hC : \u2200 x y, \u2225f x y\u2225 \u2264 C * \u2225x\u2225 * \u2225y\u2225) :\n  \u2225f.mk_continuous\u2082 C hC\u2225 \u2264 C :=\n(f.mk_continuous\u2082_norm_le' hC).trans_eq $ max_eq_left h0\n\nend linear_map\n\nnamespace continuous_linear_map\n\nvariables [ring_hom_isometric \u03c3\u2082\u2083] [ring_hom_isometric \u03c3\u2081\u2083]\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 \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) : F \u2192SL[\u03c3\u2082\u2083] E \u2192SL[\u03c3\u2081\u2083] G :=\nlinear_map.mk_continuous\u2082\n  (linear_map.mk\u2082'\u209b\u2097 \u03c3\u2082\u2083 \u03c3\u2081\u2083 (\u03bb y x, f x y)\n    (\u03bb x y z, (f z).map_add x y)\n    (\u03bb c y x, (f x).map_smul\u209b\u2097 c y)\n    (\u03bb z x y, by rw [f.map_add, add_apply])\n    (\u03bb c y x, by rw [map_smul\u209b\u2097, smul_apply]))\n  \u2225f\u2225\n  (\u03bb y x, (f.le_op_norm\u2082 x y).trans_eq $ by rw mul_right_comm)\n\nprivate lemma le_norm_flip (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) : \u2225f\u2225 \u2264 \u2225flip f\u2225 :=\nf.op_norm_le_bound\u2082 (norm_nonneg _) $ \u03bb x y,\n  by { rw mul_right_comm, exact (flip f).le_op_norm\u2082 y x }\n\n@[simp] lemma flip_apply (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) (x : E) (y : F) : f.flip y x = f x y := rfl\n\n@[simp] lemma flip_flip (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) :\n  f.flip.flip = f :=\nby { ext, refl }\n\n@[simp] lemma op_norm_flip (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) :\n  \u2225f.flip\u2225 = \u2225f\u2225 :=\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 \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) :\n  (f + g).flip = f.flip + g.flip :=\nrfl\n\n@[simp] lemma flip_smul (c : \ud835\udd5c\u2083) (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) :\n  (c \u2022 f).flip = c \u2022 f.flip :=\nrfl\n\nvariables (E F G \u03c3\u2081\u2083 \u03c3\u2082\u2083)\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\u2097\u1d62' : (E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) \u2243\u2097\u1d62[\ud835\udd5c\u2083] (F \u2192SL[\u03c3\u2082\u2083] E \u2192SL[\u03c3\u2081\u2083] 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 \u03c3\u2081\u2083 \u03c3\u2082\u2083}\n\n@[simp] lemma flip\u2097\u1d62'_symm : (flip\u2097\u1d62' E F G \u03c3\u2082\u2083 \u03c3\u2081\u2083).symm = flip\u2097\u1d62' F E G \u03c3\u2081\u2083 \u03c3\u2082\u2083 := rfl\n\n@[simp] lemma coe_flip\u2097\u1d62' : \u21d1(flip\u2097\u1d62' E F G \u03c3\u2082\u2083 \u03c3\u2081\u2083) = flip := rfl\n\nvariables (\ud835\udd5c E F\u2097 G\u2097)\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\u2097\u1d62 : (E \u2192L[\ud835\udd5c] F\u2097 \u2192L[\ud835\udd5c] G\u2097) \u2243\u2097\u1d62[\ud835\udd5c] (F\u2097 \u2192L[\ud835\udd5c] E \u2192L[\ud835\udd5c] G\u2097) :=\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 {\ud835\udd5c E F\u2097 G\u2097}\n\n@[simp] lemma flip\u2097\u1d62_symm : (flip\u2097\u1d62 \ud835\udd5c E F\u2097 G\u2097).symm = flip\u2097\u1d62 \ud835\udd5c F\u2097 E G\u2097 := rfl\n\n@[simp] lemma coe_flip\u2097\u1d62 : \u21d1(flip\u2097\u1d62 \ud835\udd5c E F\u2097 G\u2097) = flip := rfl\n\nvariables (F \u03c3\u2081\u2082) [ring_hom_isometric \u03c3\u2081\u2082]\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\u2097`. -/\ndef apply' : E \u2192SL[\u03c3\u2081\u2082] (E \u2192SL[\u03c3\u2081\u2082] F) \u2192L[\ud835\udd5c\u2082] F := flip (id \ud835\udd5c\u2082 (E \u2192SL[\u03c3\u2081\u2082] F))\n\nvariables {F \u03c3\u2081\u2082}\n\n@[simp] lemma apply_apply' (v : E) (f : E \u2192SL[\u03c3\u2081\u2082] F) : apply' F \u03c3\u2081\u2082 v f = f v := rfl\n\nvariables (\ud835\udd5c F\u2097)\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\u2097`. -/\ndef apply : E \u2192L[\ud835\udd5c] (E \u2192L[\ud835\udd5c] F\u2097) \u2192L[\ud835\udd5c] F\u2097 := flip (id \ud835\udd5c (E \u2192L[\ud835\udd5c] F\u2097))\n\nvariables {\ud835\udd5c F\u2097}\n\n@[simp] lemma apply_apply (v : E) (f : E \u2192L[\ud835\udd5c] F\u2097) : apply \ud835\udd5c F\u2097 v f = f v := rfl\n\nvariables (\u03c3\u2081\u2082 \u03c3\u2082\u2083 E F G)\n\n/-- Composition of continuous semilinear maps as a continuous semibilinear map. -/\ndef compSL : (F \u2192SL[\u03c3\u2082\u2083] G) \u2192L[\ud835\udd5c\u2083] (E \u2192SL[\u03c3\u2081\u2082] F) \u2192SL[\u03c3\u2082\u2083] (E \u2192SL[\u03c3\u2081\u2083] G) :=\nlinear_map.mk_continuous\u2082\n  (linear_map.mk\u2082'\u209b\u2097 (ring_hom.id \ud835\udd5c\u2083) \u03c3\u2082\u2083 comp add_comp smul_comp comp_add\n    (\u03bb c f g, by { ext, simp only [map_smul\u209b\u2097, coe_smul', coe_comp',\n                                   function.comp_app, pi.smul_apply] }))\n  1 $ \u03bb f g, by simpa only [one_mul] using op_norm_comp_le f g\n\nvariables {\ud835\udd5c E F G}\n\ninclude \u03c3\u2081\u2083\n\n@[simp] lemma compSL_apply (f : F \u2192SL[\u03c3\u2082\u2083] G) (g : E \u2192SL[\u03c3\u2081\u2082] F) :\n  compSL E F G \u03c3\u2081\u2082 \u03c3\u2082\u2083 f g = f.comp g := rfl\n\nomit \u03c3\u2081\u2083\nvariables (\ud835\udd5c E F\u2097 G\u2097)\n\n/-- Composition of continuous linear maps as a continuous bilinear map. -/\ndef compL : (F\u2097 \u2192L[\ud835\udd5c] G\u2097) \u2192L[\ud835\udd5c] (E \u2192L[\ud835\udd5c] F\u2097) \u2192L[\ud835\udd5c] (E \u2192L[\ud835\udd5c] G\u2097) :=\n  compSL E F\u2097 G\u2097 (ring_hom.id \ud835\udd5c) (ring_hom.id \ud835\udd5c)\n\n@[simp] lemma compL_apply (f : F\u2097 \u2192L[\ud835\udd5c] G\u2097) (g : E \u2192L[\ud835\udd5c] F\u2097) : compL \ud835\udd5c E F\u2097 G\u2097 f g = f.comp g := rfl\n\nuniverses u\u2081 u\u2082 u\u2083 u\u2084\nvariables (M\u2081 : Type u\u2081) [normed_group M\u2081] [normed_space \ud835\udd5c M\u2081]\n          (M\u2082 : Type u\u2082) [normed_group M\u2082] [normed_space \ud835\udd5c M\u2082]\n          (M\u2083 : Type u\u2083) [normed_group M\u2083] [normed_space \ud835\udd5c M\u2083]\n          (M\u2084 : Type u\u2084) [normed_group M\u2084] [normed_space \ud835\udd5c M\u2084]\n\n/-- `continuous_linear_map.prod_map` as a continuous linear map. -/\ndef prod_mapL : ((M\u2081 \u2192L[\ud835\udd5c] M\u2082) \u00d7 (M\u2083 \u2192L[\ud835\udd5c] M\u2084)) \u2192L[\ud835\udd5c] ((M\u2081 \u00d7 M\u2083) \u2192L[\ud835\udd5c] (M\u2082 \u00d7 M\u2084)) :=\ncontinuous_linear_map.copy\n(have \u03a6\u2081 : (M\u2081 \u2192L[\ud835\udd5c] M\u2082) \u2192L[\ud835\udd5c] (M\u2081 \u2192L[\ud835\udd5c] M\u2082 \u00d7 M\u2084), from\n  continuous_linear_map.compL \ud835\udd5c M\u2081 M\u2082 (M\u2082 \u00d7 M\u2084) (continuous_linear_map.inl \ud835\udd5c M\u2082 M\u2084),\nhave \u03a6\u2082 : (M\u2083 \u2192L[\ud835\udd5c] M\u2084) \u2192L[\ud835\udd5c] (M\u2083 \u2192L[\ud835\udd5c] M\u2082 \u00d7 M\u2084), from\n  continuous_linear_map.compL \ud835\udd5c M\u2083 M\u2084 (M\u2082 \u00d7 M\u2084) (continuous_linear_map.inr \ud835\udd5c M\u2082 M\u2084),\nhave \u03a6\u2081' : _, from (continuous_linear_map.compL \ud835\udd5c (M\u2081 \u00d7 M\u2083) M\u2081 (M\u2082 \u00d7 M\u2084)).flip\n  (continuous_linear_map.fst \ud835\udd5c M\u2081 M\u2083),\nhave \u03a6\u2082' : _ , from (continuous_linear_map.compL \ud835\udd5c (M\u2081 \u00d7 M\u2083) M\u2083 (M\u2082 \u00d7 M\u2084)).flip\n  (continuous_linear_map.snd \ud835\udd5c M\u2081 M\u2083),\nhave \u03a8\u2081 : ((M\u2081 \u2192L[\ud835\udd5c] M\u2082) \u00d7 (M\u2083 \u2192L[\ud835\udd5c] M\u2084)) \u2192L[\ud835\udd5c] (M\u2081 \u2192L[\ud835\udd5c] M\u2082), from\n  continuous_linear_map.fst \ud835\udd5c (M\u2081 \u2192L[\ud835\udd5c] M\u2082) (M\u2083 \u2192L[\ud835\udd5c] M\u2084),\nhave \u03a8\u2082 : ((M\u2081 \u2192L[\ud835\udd5c] M\u2082) \u00d7 (M\u2083 \u2192L[\ud835\udd5c] M\u2084)) \u2192L[\ud835\udd5c] (M\u2083 \u2192L[\ud835\udd5c] M\u2084), from\n    continuous_linear_map.snd \ud835\udd5c (M\u2081 \u2192L[\ud835\udd5c] M\u2082) (M\u2083 \u2192L[\ud835\udd5c] M\u2084),\n\u03a6\u2081' \u2218L \u03a6\u2081 \u2218L \u03a8\u2081 + \u03a6\u2082' \u2218L \u03a6\u2082 \u2218L \u03a8\u2082)\n(\u03bb p : (M\u2081 \u2192L[\ud835\udd5c] M\u2082) \u00d7 (M\u2083 \u2192L[\ud835\udd5c] M\u2084), p.1.prod_map p.2)\n(begin\n  apply funext,\n  rintros \u27e8\u03c6, \u03c8\u27e9,\n  apply continuous_linear_map.ext (\u03bb 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\u2081 M\u2082 M\u2083 M\u2084}\n\n@[simp] lemma prod_mapL_apply (p : (M\u2081 \u2192L[\ud835\udd5c] M\u2082) \u00d7 (M\u2083 \u2192L[\ud835\udd5c] M\u2084)) :\n  continuous_linear_map.prod_mapL \ud835\udd5c M\u2081 M\u2082 M\u2083 M\u2084 p = p.1.prod_map p.2 :=\nrfl\n\nvariables {X : Type*} [topological_space X]\n\nlemma _root_.continuous.prod_mapL {f : X \u2192 M\u2081 \u2192L[\ud835\udd5c] M\u2082} {g : X \u2192 M\u2083 \u2192L[\ud835\udd5c] M\u2084}\n  (hf : continuous f) (hg : continuous g) : continuous (\u03bb x, (f x).prod_map (g x)) :=\n(prod_mapL \ud835\udd5c M\u2081 M\u2082 M\u2083 M\u2084).continuous.comp (hf.prod_mk hg)\n\nlemma _root_.continuous.prod_map_equivL {f : X \u2192 M\u2081 \u2243L[\ud835\udd5c] M\u2082} {g : X \u2192 M\u2083 \u2243L[\ud835\udd5c] M\u2084}\n  (hf : continuous (\u03bb x, (f x : M\u2081 \u2192L[\ud835\udd5c] M\u2082))) (hg : continuous (\u03bb x, (g x : M\u2083 \u2192L[\ud835\udd5c] M\u2084))) :\n  continuous (\u03bb x, ((f x).prod (g x) : M\u2081 \u00d7 M\u2083 \u2192L[\ud835\udd5c] M\u2082 \u00d7 M\u2084)) :=\n(prod_mapL \ud835\udd5c M\u2081 M\u2082 M\u2083 M\u2084).continuous.comp (hf.prod_mk hg)\n\nlemma _root_.continuous_on.prod_mapL {f : X \u2192 M\u2081 \u2192L[\ud835\udd5c] M\u2082} {g : X \u2192 M\u2083 \u2192L[\ud835\udd5c] M\u2084} {s : set X}\n  (hf : continuous_on f s) (hg : continuous_on g s) :\n  continuous_on (\u03bb x, (f x).prod_map (g x)) s :=\n((prod_mapL \ud835\udd5c M\u2081 M\u2082 M\u2083 M\u2084).continuous.comp_continuous_on (hf.prod hg) : _)\n\nlemma _root_.continuous_on.prod_map_equivL {f : X \u2192 M\u2081 \u2243L[\ud835\udd5c] M\u2082} {g : X \u2192 M\u2083 \u2243L[\ud835\udd5c] M\u2084} {s : set X}\n  (hf : continuous_on (\u03bb x, (f x : M\u2081 \u2192L[\ud835\udd5c] M\u2082)) s)\n  (hg : continuous_on (\u03bb x, (g x : M\u2083 \u2192L[\ud835\udd5c] M\u2084)) s) :\n  continuous_on (\u03bb x, ((f x).prod (g x) : M\u2081 \u00d7 M\u2083 \u2192L[\ud835\udd5c] M\u2082 \u00d7 M\u2084)) s :=\n(prod_mapL \ud835\udd5c M\u2081 M\u2082 M\u2083 M\u2084).continuous.comp_continuous_on (hf.prod hg)\n\nvariables {\ud835\udd5c E F\u2097 G\u2097}\n\nsection multiplication_linear\nvariables (\ud835\udd5c) (\ud835\udd5c' : Type*) [normed_ring \ud835\udd5c'] [normed_algebra \ud835\udd5c \ud835\udd5c']\n\n/-- Left multiplication in a normed algebra as a linear isometry to the space of\ncontinuous linear maps. -/\ndef lmul\u2097\u1d62 : \ud835\udd5c' \u2192\u2097\u1d62[\ud835\udd5c] \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' :=\n{ to_linear_map := (algebra.lmul \ud835\udd5c \ud835\udd5c').to_linear_map.mk_continuous\u2082 1 $\n    \u03bb x y, by simpa using norm_mul_le x y,\n  norm_map' := \u03bb x, le_antisymm\n    (op_norm_le_bound _ (norm_nonneg x) (norm_mul_le x))\n    (by { convert ratio_le_op_norm _ (1 : \ud835\udd5c'), simp [normed_algebra.norm_one \ud835\udd5c \ud835\udd5c'],\n          apply_instance }) }\n\n/-- Left multiplication in a normed algebra as a continuous bilinear map. -/\ndef lmul : \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' :=\n(lmul\u2097\u1d62 \ud835\udd5c \ud835\udd5c').to_continuous_linear_map\n\n@[simp] lemma lmul_apply (x y : \ud835\udd5c') : lmul \ud835\udd5c \ud835\udd5c' x y = x * y := rfl\n\n@[simp] lemma coe_lmul\u2097\u1d62 : \u21d1(lmul\u2097\u1d62 \ud835\udd5c \ud835\udd5c') = lmul \ud835\udd5c \ud835\udd5c' := rfl\n\n@[simp] lemma op_norm_lmul_apply (x : \ud835\udd5c') : \u2225lmul \ud835\udd5c \ud835\udd5c' x\u2225 = \u2225x\u2225 :=\n(lmul\u2097\u1d62 \ud835\udd5c \ud835\udd5c').norm_map x\n\n/-- Right-multiplication in a normed algebra, considered as a continuous linear map. -/\ndef lmul_right : \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' := (lmul \ud835\udd5c \ud835\udd5c').flip\n\n@[simp] lemma lmul_right_apply (x y : \ud835\udd5c') : lmul_right \ud835\udd5c \ud835\udd5c' x y = y * x := rfl\n\n@[simp] lemma op_norm_lmul_right_apply (x : \ud835\udd5c') : \u2225lmul_right \ud835\udd5c \ud835\udd5c' x\u2225 = \u2225x\u2225 :=\nle_antisymm\n  (op_norm_le_bound _ (norm_nonneg x) (\u03bb y, (norm_mul_le y x).trans_eq (mul_comm _ _)))\n  (by { convert ratio_le_op_norm _ (1 : \ud835\udd5c'), simp [normed_algebra.norm_one \ud835\udd5c \ud835\udd5c'],\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\u2097\u1d62 : \ud835\udd5c' \u2192\u2097\u1d62[\ud835\udd5c] \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' :=\n{ to_linear_map := lmul_right \ud835\udd5c \ud835\udd5c',\n  norm_map' := op_norm_lmul_right_apply \ud835\udd5c \ud835\udd5c' }\n\n@[simp] lemma coe_lmul_right\u2097\u1d62 : \u21d1(lmul_right\u2097\u1d62 \ud835\udd5c \ud835\udd5c') = lmul_right \ud835\udd5c \ud835\udd5c' := rfl\n\n/-- Simultaneous left- and right-multiplication in a normed algebra, considered as a continuous\ntrilinear map. -/\ndef lmul_left_right : \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' \u2192L[\ud835\udd5c] \ud835\udd5c' :=\n((compL \ud835\udd5c \ud835\udd5c' \ud835\udd5c' \ud835\udd5c').comp (lmul_right \ud835\udd5c \ud835\udd5c')).flip.comp (lmul \ud835\udd5c \ud835\udd5c')\n\n@[simp] lemma lmul_left_right_apply (x y z : \ud835\udd5c') :\n  lmul_left_right \ud835\udd5c \ud835\udd5c' x y z = x * z * y := rfl\n\nlemma op_norm_lmul_left_right_apply_apply_le (x y : \ud835\udd5c') :\n  \u2225lmul_left_right \ud835\udd5c \ud835\udd5c' x y\u2225 \u2264 \u2225x\u2225 * \u2225y\u2225 :=\n(op_norm_comp_le _ _).trans_eq $ by simp [mul_comm]\n\nlemma op_norm_lmul_left_right_apply_le (x : \ud835\udd5c') :\n  \u2225lmul_left_right \ud835\udd5c \ud835\udd5c' x\u2225 \u2264 \u2225x\u2225 :=\nop_norm_le_bound _ (norm_nonneg x) (op_norm_lmul_left_right_apply_apply_le \ud835\udd5c \ud835\udd5c' x)\n\nlemma op_norm_lmul_left_right_le :\n  \u2225lmul_left_right \ud835\udd5c \ud835\udd5c'\u2225 \u2264 1 :=\nop_norm_le_bound _ zero_le_one (\u03bb x, (one_mul \u2225x\u2225).symm \u25b8 op_norm_lmul_left_right_apply_le \ud835\udd5c \ud835\udd5c' x)\n\nend multiplication_linear\n\nsection smul_linear\n\nvariables (\ud835\udd5c) (\ud835\udd5c' : Type*) [normed_field \ud835\udd5c'] [normed_algebra \ud835\udd5c \ud835\udd5c']\n  [normed_space \ud835\udd5c' E] [is_scalar_tower \ud835\udd5c \ud835\udd5c' E]\n\n/-- Scalar multiplication as a continuous bilinear map. -/\ndef lsmul : \ud835\udd5c' \u2192L[\ud835\udd5c] E \u2192L[\ud835\udd5c] E :=\n((algebra.lsmul \ud835\udd5c E).to_linear_map : \ud835\udd5c' \u2192\u2097[\ud835\udd5c] E \u2192\u2097[\ud835\udd5c] E).mk_continuous\u2082 1 $\n  \u03bb c x, by simpa only [one_mul] using (norm_smul c x).le\n\n@[simp] lemma lsmul_apply (c : \ud835\udd5c') (x : E) : lsmul \ud835\udd5c \ud835\udd5c' c x = c \u2022 x := rfl\n\nvariables {\ud835\udd5c'}\n\nlemma norm_to_span_singleton (x : E) : \u2225to_span_singleton \ud835\udd5c x\u2225 = \u2225x\u2225 :=\nbegin\n  refine op_norm_eq_of_bounds (norm_nonneg _) (\u03bb x, _) (\u03bb 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 {\ud835\udd5c' : Type*} [nondiscrete_normed_field \ud835\udd5c'] [normed_algebra \ud835\udd5c' \ud835\udd5c]\nvariables [normed_space \ud835\udd5c' E] [is_scalar_tower \ud835\udd5c' \ud835\udd5c E]\nvariables [normed_space \ud835\udd5c' F\u2097] [is_scalar_tower \ud835\udd5c' \ud835\udd5c F\u2097]\n\n@[simp] lemma norm_restrict_scalars (f : E \u2192L[\ud835\udd5c] F\u2097) : \u2225f.restrict_scalars \ud835\udd5c'\u2225 = \u2225f\u2225 :=\nle_antisymm (op_norm_le_bound _ (norm_nonneg _) $ \u03bb x, f.le_op_norm x)\n  (op_norm_le_bound _ (norm_nonneg _) $ \u03bb x, f.le_op_norm x)\n\nvariables (\ud835\udd5c E F\u2097 \ud835\udd5c') (\ud835\udd5c'' : Type*) [ring \ud835\udd5c''] [module \ud835\udd5c'' F\u2097]\n  [has_continuous_const_smul \ud835\udd5c'' F\u2097] [smul_comm_class \ud835\udd5c \ud835\udd5c'' F\u2097] [smul_comm_class \ud835\udd5c' \ud835\udd5c'' F\u2097]\n\n/-- `continuous_linear_map.restrict_scalars` as a `linear_isometry`. -/\ndef restrict_scalars_isometry : (E \u2192L[\ud835\udd5c] F\u2097) \u2192\u2097\u1d62[\ud835\udd5c''] (E \u2192L[\ud835\udd5c'] F\u2097) :=\n\u27e8restrict_scalars\u2097 \ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c'', norm_restrict_scalars\u27e9\n\nvariables {\ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c''}\n\n@[simp] lemma coe_restrict_scalars_isometry :\n  \u21d1(restrict_scalars_isometry \ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c'') = restrict_scalars \ud835\udd5c' :=\nrfl\n\n@[simp] lemma restrict_scalars_isometry_to_linear_map :\n  (restrict_scalars_isometry \ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c'').to_linear_map = restrict_scalars\u2097 \ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c'' :=\nrfl\n\nvariables (\ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c'')\n\n/-- `continuous_linear_map.restrict_scalars` as a `continuous_linear_map`. -/\ndef restrict_scalarsL : (E \u2192L[\ud835\udd5c] F\u2097) \u2192L[\ud835\udd5c''] (E \u2192L[\ud835\udd5c'] F\u2097) :=\n(restrict_scalars_isometry \ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c'').to_continuous_linear_map\n\nvariables {\ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c''}\n\n@[simp] lemma coe_restrict_scalarsL :\n  (restrict_scalarsL \ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c'' : (E \u2192L[\ud835\udd5c] F\u2097) \u2192\u2097[\ud835\udd5c''] (E \u2192L[\ud835\udd5c'] F\u2097)) =\n    restrict_scalars\u2097 \ud835\udd5c E F\u2097 \ud835\udd5c' \ud835\udd5c'' :=\nrfl\n\n@[simp] \n\nend restrict_scalars\n\nend continuous_linear_map\n\nnamespace submodule\n\nlemma norm_subtypeL_le (K : submodule \ud835\udd5c E) : \u2225K.subtypeL\u2225 \u2264 1 :=\nK.subtype\u2097\u1d62.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 {\u03b9 R R\u2082 M M\u2082 : Type*} [semiring R] [semiring R\u2082] [add_comm_monoid M] [module R M]\n  [add_comm_monoid M\u2082] [module R\u2082 M\u2082] [topological_space M] [topological_space M\u2082]\n  {\u03c3 : R \u2192+* R\u2082} {\u03c3' : R\u2082 \u2192+* R} [ring_hom_inv_pair \u03c3 \u03c3'] [ring_hom_inv_pair \u03c3' \u03c3]\n\n/-- Applying a continuous linear map commutes with taking an (infinite) sum. -/\nprotected lemma continuous_linear_map.has_sum {f : \u03b9 \u2192 M} (\u03c6 : M \u2192SL[\u03c3] M\u2082) {x : M}\n  (hf : has_sum f x) :\n  has_sum (\u03bb (b:\u03b9), \u03c6 (f b)) (\u03c6 x) :=\nby simpa only using hf.map \u03c6.to_linear_map.to_add_monoid_hom \u03c6.continuous\n\nalias continuous_linear_map.has_sum \u2190 has_sum.mapL\n\nprotected lemma continuous_linear_map.summable {f : \u03b9 \u2192 M} (\u03c6 : M \u2192SL[\u03c3] M\u2082) (hf : summable f) :\n  summable (\u03bb b:\u03b9, \u03c6 (f b)) :=\n(hf.has_sum.mapL \u03c6).summable\n\nalias continuous_linear_map.summable \u2190 summable.mapL\n\nprotected lemma continuous_linear_map.map_tsum [t2_space M\u2082] {f : \u03b9 \u2192 M}\n  (\u03c6 : M \u2192SL[\u03c3] M\u2082) (hf : summable f) : \u03c6 (\u2211' z, f z) = \u2211' z, \u03c6 (f z) :=\n(hf.has_sum.mapL \u03c6).tsum_eq.symm\n\ninclude \u03c3'\n/-- Applying a continuous linear map commutes with taking an (infinite) sum. -/\nprotected lemma continuous_linear_equiv.has_sum {f : \u03b9 \u2192 M} (e : M \u2243SL[\u03c3] M\u2082) {y : M\u2082} :\n  has_sum (\u03bb (b:\u03b9), e (f b)) y \u2194 has_sum f (e.symm y) :=\n\u27e8\u03bb h, by simpa only [e.symm.coe_coe, e.symm_apply_apply] using h.mapL (e.symm : M\u2082 \u2192SL[\u03c3'] M),\n  \u03bb h, by simpa only [e.coe_coe, e.apply_symm_apply] using (e : M \u2192SL[\u03c3] M\u2082).has_sum h\u27e9\n\n\nprotected lemma continuous_linear_equiv.summable {f : \u03b9 \u2192 M} (e : M \u2243SL[\u03c3] M\u2082) :\n  summable (\u03bb b:\u03b9, e (f b)) \u2194 summable f :=\n\u27e8\u03bb hf, (e.has_sum.1 hf.has_sum).summable, (e : M \u2192SL[\u03c3] M\u2082).summable\u27e9\n\n\nlemma continuous_linear_equiv.tsum_eq_iff [t2_space M] [t2_space M\u2082] {f : \u03b9 \u2192 M}\n  (e : M \u2243SL[\u03c3] M\u2082) {y : M\u2082} : \u2211' z, e (f z) = y \u2194 \u2211' z, f z = e.symm y :=\nbegin\n  by_cases hf : summable f,\n  { exact \u27e8\u03bb h, (e.has_sum.mp ((e.summable.mpr hf).has_sum_iff.mpr h)).tsum_eq,\n      \u03bb h, (e.has_sum.mpr (hf.has_sum_iff.mpr h)).tsum_eq\u27e9 },\n  { have hf' : \u00acsummable (\u03bb z, e (f z)) := \u03bb h, hf (e.summable.mp h),\n    rw [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable hf'],\n    exact \u27e8by { rintro rfl, simp }, \u03bb H, by simpa using (congr_arg (\u03bb z, e z) H)\u27e9 }\nend\n\nprotected lemma continuous_linear_equiv.map_tsum [t2_space M] [t2_space M\u2082] {f : \u03b9 \u2192 M}\n  (e : M \u2243SL[\u03c3] M\u2082) : e (\u2211' z, f z) = \u2211' 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 {\u03c3\u2082\u2081 : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c} [ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081] [ring_hom_inv_pair \u03c3\u2082\u2081 \u03c3\u2081\u2082]\n  [ring_hom_isometric \u03c3\u2081\u2082]\nvariables (e : E \u2243SL[\u03c3\u2081\u2082] F)\n\ninclude \u03c3\u2082\u2081\nprotected lemma lipschitz : lipschitz_with (\u2225(e : E \u2192SL[\u03c3\u2081\u2082] F)\u2225\u208a) e :=\n(e : E \u2192SL[\u03c3\u2081\u2082] F).lipschitz\n\ntheorem is_O_comp {\u03b1 : Type*} (f : \u03b1 \u2192 E) (l : filter \u03b1) :\n  asymptotics.is_O (\u03bb x', e (f x')) f l :=\n(e : E \u2192SL[\u03c3\u2081\u2082] F).is_O_comp f l\n\ntheorem is_O_sub (l : filter E) (x : E) :\n  asymptotics.is_O (\u03bb x', e (x' - x)) (\u03bb x', x' - x) l :=\n(e : E \u2192SL[\u03c3\u2081\u2082] F).is_O_sub l x\n\nend\n\nvariables {\u03c3\u2082\u2081 : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c} [ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081] [ring_hom_inv_pair \u03c3\u2082\u2081 \u03c3\u2081\u2082]\n\ninclude \u03c3\u2082\u2081\nlemma homothety_inverse (a : \u211d) (ha : 0 < a) (f : E \u2243\u209b\u2097[\u03c3\u2081\u2082] F) :\n  (\u2200 (x : E), \u2225f x\u2225 = a * \u2225x\u2225) \u2192 (\u2200 (y : F), \u2225f.symm y\u2225 = a\u207b\u00b9 * \u2225y\u2225) :=\nbegin\n  intros hf y,\n  calc \u2225(f.symm) y\u2225 = a\u207b\u00b9 * (a * \u2225 (f.symm) y\u2225) : _\n  ... =  a\u207b\u00b9 * \u2225f ((f.symm) y)\u2225 : by rw hf\n  ... = a\u207b\u00b9 * \u2225y\u2225 : by simp,\n  rw [\u2190 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 \u2243\u209b\u2097[\u03c3\u2081\u2082] F) (a : \u211d) (ha : 0 < a) (hf : \u2200x, \u2225f x\u2225 = a * \u2225x\u2225) :\n  E \u2243SL[\u03c3\u2081\u2082] F :=\n{ to_linear_equiv := f,\n  continuous_to_fun := f.to_linear_map.continuous_of_bound a (\u03bb x, le_of_eq (hf x)),\n  continuous_inv_fun := f.symm.to_linear_map.continuous_of_bound a\u207b\u00b9\n    (\u03bb x, le_of_eq (homothety_inverse a ha f hf x)) }\n\nvariables [ring_hom_isometric \u03c3\u2082\u2081] (e : E \u2243SL[\u03c3\u2081\u2082] F)\n\ntheorem is_O_comp_rev {\u03b1 : Type*} (f : \u03b1 \u2192 E) (l : filter \u03b1) :\n  asymptotics.is_O f (\u03bb x', e (f x')) l :=\n(e.symm.is_O_comp _ l).congr_left $ \u03bb _, e.symm_apply_apply _\n\ntheorem is_O_sub_rev (l : filter E) (x : E) :\n  asymptotics.is_O (\u03bb x', x' - x) (\u03bb x', e (x' - x)) l :=\ne.is_O_comp_rev _ _\n\nomit \u03c3\u2082\u2081\n\nvariable (\ud835\udd5c)\n\nlemma to_span_nonzero_singleton_homothety (x : E) (h : x \u2260 0) (c : \ud835\udd5c) :\n  \u2225linear_equiv.to_span_nonzero_singleton \ud835\udd5c E x h c\u2225 = \u2225x\u2225 * \u2225c\u2225 :=\ncontinuous_linear_map.to_span_singleton_homothety _ _ _\n\nend continuous_linear_equiv\n\nvariables {\u03c3\u2082\u2081 : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c} [ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081] [ring_hom_inv_pair \u03c3\u2082\u2081 \u03c3\u2081\u2082]\ninclude \u03c3\u2082\u2081\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 \u2243\u209b\u2097[\u03c3\u2081\u2082] F) (C_to C_inv : \u211d)\n  (h_to : \u2200 x, \u2225e x\u2225 \u2264 C_to * \u2225x\u2225) (h_inv : \u2200 x : F, \u2225e.symm x\u2225 \u2264 C_inv * \u2225x\u2225) : E \u2243SL[\u03c3\u2081\u2082] 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 \u03c3\u2082\u2081\n\nnamespace continuous_linear_map\nvariables {E' F' : Type*} [semi_normed_group E'] [semi_normed_group F']\n\nvariables {\ud835\udd5c\u2081' : Type*} {\ud835\udd5c\u2082' : Type*} [nondiscrete_normed_field \ud835\udd5c\u2081'] [nondiscrete_normed_field \ud835\udd5c\u2082']\n  [normed_space \ud835\udd5c\u2081' E'] [normed_space \ud835\udd5c\u2082' F']\n  {\u03c3\u2081' : \ud835\udd5c\u2081' \u2192+* \ud835\udd5c} {\u03c3\u2081\u2083' : \ud835\udd5c\u2081' \u2192+* \ud835\udd5c\u2083} {\u03c3\u2082' : \ud835\udd5c\u2082' \u2192+* \ud835\udd5c\u2082} {\u03c3\u2082\u2083' : \ud835\udd5c\u2082' \u2192+* \ud835\udd5c\u2083}\n  [ring_hom_comp_triple \u03c3\u2081' \u03c3\u2081\u2083 \u03c3\u2081\u2083'] [ring_hom_comp_triple \u03c3\u2082' \u03c3\u2082\u2083 \u03c3\u2082\u2083']\n  [ring_hom_isometric \u03c3\u2082\u2083] [ring_hom_isometric \u03c3\u2081\u2083'] [ring_hom_isometric \u03c3\u2082\u2083']\n\n/--\nCompose a bilinear map `E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G` with two linear maps\n`E' \u2192SL[\u03c3\u2081'] E` and `F' \u2192SL[\u03c3\u2082'] F`.  -/\ndef bilinear_comp (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) (gE : E' \u2192SL[\u03c3\u2081'] E) (gF : F' \u2192SL[\u03c3\u2082'] F) :\n  E' \u2192SL[\u03c3\u2081\u2083'] F' \u2192SL[\u03c3\u2082\u2083'] G :=\n((f.comp gE).flip.comp gF).flip\n\ninclude \u03c3\u2081\u2083' \u03c3\u2082\u2083'\n@[simp] lemma bilinear_comp_apply (f : E \u2192SL[\u03c3\u2081\u2083] F \u2192SL[\u03c3\u2082\u2083] G) (gE : E' \u2192SL[\u03c3\u2081'] E)\n  (gF : F' \u2192SL[\u03c3\u2082'] F) (x : E') (y : F') : f.bilinear_comp gE gF x y = f (gE x) (gF y) :=\nrfl\n\nomit \u03c3\u2081\u2083' \u03c3\u2082\u2083'\n\nvariables [ring_hom_isometric \u03c3\u2081\u2083] [ring_hom_isometric \u03c3\u2081'] [ring_hom_isometric \u03c3\u2082']\n\n/-- Derivative of a continuous bilinear map `f : E \u2192L[\ud835\udd5c] F \u2192L[\ud835\udd5c] G` interpreted as a map `E \u00d7 F \u2192 G`\nat point `p : E \u00d7 F` evaluated at `q : E \u00d7 F`, as a continuous bilinear map. -/\ndef deriv\u2082 (f : E \u2192L[\ud835\udd5c] F\u2097 \u2192L[\ud835\udd5c] G\u2097) : (E \u00d7 F\u2097) \u2192L[\ud835\udd5c] (E \u00d7 F\u2097) \u2192L[\ud835\udd5c] G\u2097 :=\nf.bilinear_comp (fst _ _ _) (snd _ _ _) + f.flip.bilinear_comp (snd _ _ _) (fst _ _ _)\n\n@[simp] lemma coe_deriv\u2082 (f : E \u2192L[\ud835\udd5c] F\u2097 \u2192L[\ud835\udd5c] G\u2097) (p : E \u00d7 F\u2097) :\n  \u21d1(f.deriv\u2082 p) = \u03bb q : E \u00d7 F\u2097, f p.1 q.2 + f q.1 p.2 := rfl\n\nlemma map_add\u2082 (f : E \u2192L[\ud835\udd5c] F\u2097 \u2192L[\ud835\udd5c] G\u2097) (x x' : E) (y y' : F\u2097) :\n  f (x + x') (y + y') = f x y + f.deriv\u2082 (x, y) (x', y') + f x' y' :=\nby simp only [map_add, add_apply, coe_deriv\u2082, 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\u2097]\n\nopen metric continuous_linear_map\n\nsection normed_field\n\nvariables [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c F] (f : E \u2192\u2097[\ud835\udd5c] F)\n\nlemma linear_map.continuous_iff_is_closed_ker {f : E \u2192\u2097[\ud835\udd5c] \ud835\udd5c} :\n  continuous f \u2194 is_closed (f.ker : set E) :=\nbegin\n  -- the continuity of f obviously implies that its kernel is closed\n  refine \u27e8\u03bbh, (t1_space.t1 (0 : \ud835\udd5c)).preimage h, \u03bbh, _\u27e9,\n  -- for the other direction, we assume that the kernel is closed\n  by_cases hf : \u2200x, x \u2208 f.ker,\n  { -- if `f = 0`, its continuity is obvious\n    have : (f : E \u2192 \ud835\udd5c) = (\u03bbx, 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\u2080 \u2209 ker f` such that `\u2225x\u2080\u2225 \u2264 2 \u2225x\u2080 - y\u2225` for all\n    `y \u2208 ker f`, given by Riesz's lemma, and prove that `2 \u2225f x\u2080\u2225 / \u2225x\u2080\u2225` gives a bound on the\n    operator norm of `f`. For this, start from an arbitrary `x` and note that\n    `y = x\u2080 - (f x\u2080 / f x) x` belongs to the kernel of `f`. Applying the above inequality to `x\u2080`\n    and `y` readily gives the conclusion. -/\n    push_neg at hf,\n    let r : \u211d := (2 : \u211d)\u207b\u00b9,\n    have : 0 \u2264 r, by norm_num [r],\n    have : r < 1, by norm_num [r],\n    obtain \u27e8x\u2080, x\u2080ker, h\u2080\u27e9 : \u2203 (x\u2080 : E), x\u2080 \u2209 f.ker \u2227 \u2200 y \u2208 linear_map.ker f,\n      r * \u2225x\u2080\u2225 \u2264 \u2225x\u2080 - y\u2225, from riesz_lemma h hf this,\n    have : x\u2080 \u2260 0,\n    { assume h,\n      have : x\u2080 \u2208 f.ker, by { rw h, exact (linear_map.ker f).zero_mem },\n      exact x\u2080ker this },\n    have rx\u2080_ne_zero : r * \u2225x\u2080\u2225 \u2260 0, by { simp [norm_eq_zero, this], },\n    have : \u2200x, \u2225f x\u2225 \u2264 (((r * \u2225x\u2080\u2225)\u207b\u00b9) * \u2225f x\u2080\u2225) * \u2225x\u2225,\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\u2080 - (f x\u2080 * (f x)\u207b\u00b9 ) \u2022 x,\n        have fy_zero : f y = 0, by calc\n          f y = f x\u2080 - (f x\u2080 * (f x)\u207b\u00b9 ) * 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 * \u2225x\u2080\u2225 \u2264 \u2225f x\u2080\u2225 * \u2225f x\u2225\u207b\u00b9 * \u2225x\u2225, from calc\n          r * \u2225x\u2080\u2225 \u2264 \u2225x\u2080 - y\u2225 : h\u2080 _ (linear_map.mem_ker.2 fy_zero)\n          ... = \u2225(f x\u2080 * (f x)\u207b\u00b9 ) \u2022 x\u2225 : by { dsimp [y], congr, abel }\n          ... = \u2225f x\u2080\u2225 * \u2225f x\u2225\u207b\u00b9 * \u2225x\u2225 :\n            by rw [norm_smul, norm_mul, norm_inv],\n        calc\n          \u2225f x\u2225 = (r * \u2225x\u2080\u2225)\u207b\u00b9 * (r * \u2225x\u2080\u2225) * \u2225f x\u2225 : by rwa [inv_mul_cancel, one_mul]\n          ... \u2264 (r * \u2225x\u2080\u2225)\u207b\u00b9 * (\u2225f x\u2080\u2225 * \u2225f x\u2225\u207b\u00b9 * \u2225x\u2225) * \u2225f x\u2225 : 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          ... = (\u2225f x\u2225 \u207b\u00b9 * \u2225f x\u2225) * (((r * \u2225x\u2080\u2225)\u207b\u00b9) * \u2225f x\u2080\u2225) * \u2225x\u2225 : by ring\n          ... = (((r * \u2225x\u2080\u2225)\u207b\u00b9) * \u2225f x\u2080\u2225) * \u2225x\u2225 :\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 \ud835\udd5c] [nondiscrete_normed_field \ud835\udd5c\u2082] [nondiscrete_normed_field \ud835\udd5c\u2083]\n  [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c\u2082 F] [normed_space \ud835\udd5c\u2083 G] [normed_space \ud835\udd5c F\u2097] (c : \ud835\udd5c)\n  {\u03c3\u2081\u2082 : \ud835\udd5c \u2192+* \ud835\udd5c\u2082} {\u03c3\u2082\u2083 : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c\u2083}\n  [ring_hom_isometric \u03c3\u2081\u2082] (f g : E \u2192SL[\u03c3\u2081\u2082] F) (x y z : E)\n\nlemma linear_map.bound_of_shell (f : E \u2192\u209b\u2097[\u03c3\u2081\u2082] F) {\u03b5 C : \u211d} (\u03b5_pos : 0 < \u03b5) {c : \ud835\udd5c}\n  (hc : 1 < \u2225c\u2225) (hf : \u2200 x, \u03b5 / \u2225c\u2225 \u2264 \u2225x\u2225 \u2192 \u2225x\u2225 < \u03b5 \u2192 \u2225f x\u2225 \u2264 C * \u2225x\u2225) (x : E) :\n  \u2225f x\u2225 \u2264 C * \u2225x\u2225 :=\nbegin\n  by_cases hx : x = 0, { simp [hx] },\n  exact linear_map.bound_of_shell_semi_normed f \u03b5_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 : \u211d} (r_pos : 0 < r) (c : \u211d) (f : E \u2192\u2097[\ud835\udd5c] F\u2097)\n  (h : \u2200 z \u2208 metric.ball (0 : E) r, \u2225f z\u2225 \u2264 c) :\n  \u2203 C, \u2200 (z : E), \u2225f z\u2225 \u2264 C * \u2225z\u2225 :=\nbegin\n  cases @nondiscrete_normed_field.non_trivial \ud835\udd5c _ with k hk,\n  use c * (\u2225k\u2225 / r),\n  intro z,\n  refine linear_map.bound_of_shell _ r_pos hk (\u03bb x hko hxo, _) _,\n  calc \u2225f x\u2225 \u2264 c : h _ (mem_ball_zero_iff.mpr hxo)\n         ... \u2264 c * ((\u2225x\u2225 * \u2225k\u2225) / 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 : \u2225f\u2225 = 0 \u2194 f = 0 :=\niff.intro\n  (\u03bb hn, continuous_linear_map.ext (\u03bb x, norm_le_zero_iff.1\n    (calc _ \u2264 \u2225f\u2225 * \u2225x\u2225 : le_op_norm _ _\n     ...     = _ : by rw [hn, zero_mul])))\n  (\u03bb hf, le_antisymm (cInf_le bounds_bdd_below\n    \u27e8le_rfl, \u03bb _, le_of_eq (by { rw [zero_mul, hf], exact norm_zero })\u27e9)\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] : \u2225id \ud835\udd5c E\u2225 = 1 :=\nbegin\n  refine norm_id_of_nontrivial_seminorm _,\n  obtain \u27e8x, hx\u27e9 := exists_ne (0 : E),\n  exact \u27e8x, ne_of_gt (norm_pos_iff.2 hx)\u27e9,\nend\n\ninstance norm_one_class [nontrivial E] : norm_one_class (E \u2192L[\ud835\udd5c] E) := \u27e8norm_id\u27e9\n\n/-- Continuous linear maps themselves form a normed space with respect to\n    the operator norm. -/\ninstance to_normed_group : normed_group (E \u2192SL[\u03c3\u2081\u2082] F) :=\nnormed_group.of_core _ \u27e8op_norm_zero_iff, op_norm_add_le, op_norm_neg\u27e9\n\n/-- Continuous linear maps form a normed ring with respect to the operator norm. -/\ninstance to_normed_ring : normed_ring (E \u2192L[\ud835\udd5c] 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 \ud835\udd5c (E \u2192L[\ud835\udd5c] E) :=\n{ norm_algebra_map_eq := \u03bb c, show \u2225c \u2022 id \ud835\udd5c E\u2225 = \u2225c\u2225,\n    by {rw [norm_smul, norm_id], simp},\n  .. continuous_linear_map.algebra }\n\nvariable {f}\n\nlemma homothety_norm [nontrivial E] (f : E \u2192SL[\u03c3\u2081\u2082] F) {a : \u211d} (hf : \u2200x, \u2225f x\u2225 = a * \u2225x\u2225) :\n  \u2225f\u2225 = a :=\nbegin\n  obtain \u27e8x, hx\u27e9 : \u2203 (x : E), x \u2260 0 := exists_ne 0,\n  rw \u2190 norm_pos_iff at hx,\n  have ha : 0 \u2264 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 (\u03bb 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) : \u2225to_span_singleton \ud835\udd5c x\u2225 = \u2225x\u2225 :=\nhomothety_norm _ (to_span_singleton_homothety \ud835\udd5c x)\n\nvariable (f)\n\ntheorem uniform_embedding_of_bound {K : \u211d\u22650} (hf : \u2200 x, \u2225x\u2225 \u2264 K * \u2225f x\u2225) :\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 \u2192L[\ud835\udd5c] F\u2097) (hf : uniform_embedding f) :\n  \u2203 K, antilipschitz_with K f :=\nbegin\n  obtain \u27e8\u03b5, \u03b5pos, h\u03b5\u27e9 : \u2203 (\u03b5 : \u211d) (H : \u03b5 > 0), \u2200 {x y : E}, dist (f x) (f y) < \u03b5 \u2192 dist x y < 1,\n    from (uniform_embedding_iff.1 hf).2.2 1 zero_lt_one,\n  let \u03b4 := \u03b5/2,\n  have \u03b4_pos : \u03b4 > 0 := half_pos \u03b5pos,\n  have H : \u2200{x}, \u2225f x\u2225 \u2264 \u03b4 \u2192 \u2225x\u2225 \u2264 1,\n  { assume x hx,\n    have : dist x 0 \u2264 1,\n    { refine (h\u03b5 _).le,\n      rw [f.map_zero, dist_zero_right],\n      exact hx.trans_lt (half_lt_self \u03b5pos) },\n    simpa using this },\n  rcases normed_field.exists_one_lt_norm \ud835\udd5c with \u27e8c, hc\u27e9,\n  refine \u27e8\u27e8\u03b4\u207b\u00b9, _\u27e9 * nnnorm c, f.to_linear_map.antilipschitz_of_bound $ \u03bbx, _\u27e9,\n  exact inv_nonneg.2 (le_of_lt \u03b4_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 \u03b4_pos hx with \u27e8d, hd, dxlt, ledx, dinv\u27e9,\n    rw [\u2190 f.map_smul d] at dxlt,\n    have : \u2225d \u2022 x\u2225 \u2264 1 := H dxlt.le,\n    calc \u2225x\u2225 = \u2225d\u2225\u207b\u00b9 * \u2225d \u2022 x\u2225 :\n      by rwa [\u2190 norm_inv, \u2190 norm_smul, \u2190 mul_smul, inv_mul_cancel, one_smul]\n    ... \u2264 \u2225d\u2225\u207b\u00b9 * 1 :\n      mul_le_mul_of_nonneg_left this (inv_nonneg.2 (norm_nonneg _))\n    ... \u2264 \u03b4\u207b\u00b9 * \u2225c\u2225 * \u2225f x\u2225 :\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 \ud835\udd5c E']\n\n/-- Construct a bundled continuous (semi)linear map from a map `f : E \u2192 F` and a proof of the fact\nthat it belongs to the closure of the image of a bounded set `s : set (E \u2192SL[\u03c3\u2081\u2082] 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' \u2192 F) {s : set (E' \u2192SL[\u03c3\u2081\u2082] F)} (hs : bounded s)\n  (hf : f \u2208 closure ((\u03bb g x, g x : (E' \u2192SL[\u03c3\u2081\u2082] F) \u2192 E' \u2192 F) '' s)) :\n  E' \u2192SL[\u03c3\u2081\u2082] 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 $ \u03bb g hg, _) hf, exact \u27e8g, rfl\u27e9 },\n  { -- We need to show that `f` has bounded norm. Choose `C` such that `\u2225g\u2225 \u2264 C` for all `g \u2208 s`.\n    rcases bounded_iff_forall_norm_le.1 hs with \u27e8C, hC\u27e9,\n    -- Then `\u2225g x\u2225 \u2264 C * \u2225x\u2225` for all `g \u2208 s`, `x : E`, hence `\u2225f x\u2225 \u2264 C * \u2225x\u2225` for all `x`.\n    have : \u2200 x, is_closed {g : E' \u2192 F | \u2225g x\u2225 \u2264 C * \u2225x\u2225},\n      from \u03bb x, is_closed_Iic.preimage (@continuous_apply E' (\u03bb _, F) _ x).norm,\n    refine \u27e8C, \u03bb x, (this x).closure_subset_iff.2 (image_subset_iff.2 $ \u03bb g hg, _) hf\u27e9,\n    exact g.le_of_op_norm_le (hC _ hg) _ }\nend\n\n/-- Let `f : E \u2192 F` be a map, let `g : \u03b1 \u2192 E \u2192SL[\u03c3\u2081\u2082] 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 {\u03b1 : Type*} {l : filter \u03b1} [l.ne_bot] (f : E' \u2192 F)\n  (g : \u03b1 \u2192 E' \u2192SL[\u03c3\u2081\u2082] F) (hf : tendsto (\u03bb a x, g a x) l (\ud835\udcdd f)) (hg : bounded (set.range g)) :\n  E' \u2192SL[\u03c3\u2081\u2082] F :=\nof_mem_closure_image_coe_bounded f hg $ mem_closure_of_tendsto hf $\n  eventually_of_forall $ \u03bb 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 : \u2115 \u2192 E' \u2192SL[\u03c3\u2081\u2082] F} {g : E' \u2192SL[\u03c3\u2081\u2082] F}\n  (hg : tendsto (\u03bb n x, f n x) at_top (\ud835\udcdd g)) (hf : cauchy_seq f) :\n  tendsto f at_top (\ud835\udcdd g) :=\nbegin\n  /- Since `f` is a Cauchy sequence, there exists `b \u2192 0` such that `\u2225f n - f m\u2225 \u2264 b N` for any\n  `m, n \u2265 N`. -/\n  rcases cauchy_seq_iff_le_tendsto_0.1 hf with \u27e8b, hb\u2080, hfb, hb_lim\u27e9,\n  -- Since `b \u2192 0`, it suffices to show that `\u2225f n x - g x\u2225 \u2264 b n * \u2225x\u2225` for all `n` and `x`.\n  suffices : \u2200 n x, \u2225f n x - g x\u2225 \u2264 b n * \u2225x\u2225,\n    from tendsto_iff_norm_tendsto_zero.2 (squeeze_zero (\u03bb n, norm_nonneg _)\n      (\u03bb n, op_norm_le_bound _ (hb\u2080 n) (this n)) hb_lim),\n  intros n x,\n  -- Note that `f m x \u2192 g x`, hence `\u2225f n x - f m x\u2225 \u2192 \u2225f n x - g x\u2225` as `m \u2192 \u221e`\n  have : tendsto (\u03bb m, \u2225f n x - f m x\u2225) at_top (\ud835\udcdd (\u2225f n x - g x\u2225)),\n    from (tendsto_const_nhds.sub $ tendsto_pi_nhds.1 hg _).norm,\n  -- Thus it suffices to verify `\u2225f n x - f m x\u2225 \u2264 b n * \u2225x\u2225` for `m \u2265 n`.\n  refine le_of_tendsto this (eventually_at_top.2 \u27e8n, \u03bb m hm, _\u27e9),\n  -- This inequality follows from `\u2225f n - f m\u2225 \u2264 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' \u2192SL[\u03c3\u2081\u2082] F) :=\nbegin\n  -- We show that every Cauchy sequence converges.\n  refine metric.complete_of_cauchy_seq_tendsto (\u03bb f hf, _),\n  -- The evaluation at any point `v : E` is Cauchy.\n  have cau : \u2200 v, cauchy_seq (\u03bb n, f n v),\n    from \u03bb 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 \u03bbv, 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' \u2192SL[\u03c3\u2081\u2082] 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 \u27e8Glin, tendsto_of_tendsto_pointwise_of_cauchy_seq (tendsto_pi_nhds.2 hG) hf\u27e9\nend\n\nend completeness\n\nsection uniformly_extend\n\nvariables [complete_space F] (e : E \u2192L[\ud835\udd5c] F\u2097) (h_dense : dense_range e)\n\nsection\nvariables (h_e : uniform_inducing e)\n\n/-- Extension of a continuous linear map `f : E \u2192SL[\u03c3\u2081\u2082] F`, with `E` a normed space and `F` a\ncomplete normed space, along a uniform and dense embedding `e : E \u2192L[\ud835\udd5c] F\u2097`.  -/\ndef extend : F\u2097 \u2192SL[\u03c3\u2081\u2082] 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\u2082 _ _,\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, \u2190 e.map_add], exact f.map_add _ _ },\n  end,\n  map_smul' := \u03bbk,\n  begin\n    refine (\u03bb 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 \u2190 map_smul, simp only [eq], exact map_smul\u209b\u2097 _ _ _ },\n  end,\n  cont := cont }\n\nlemma extend_unique (g : F\u2097 \u2192SL[\u03c3\u2081\u2082] 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 \u2192SL[\u03c3\u2081\u2082] F) e h_dense h_e = 0 :=\nextend_unique _ _ _ _ _ (zero_comp _)\n\nend\n\nsection\nvariables {N : \u211d\u22650} (h_e : \u2200x, \u2225x\u2225 \u2264 N * \u2225e x\u2225)\n\nlocal notation `\u03c8` := f.extend e h_dense (uniform_embedding_of_bound _ h_e).to_uniform_inducing\n\n/-- If a dense embedding `e : E \u2192L[\ud835\udd5c] G` expands the norm by a constant factor `N\u207b\u00b9`, then the\nnorm of the extension of `f` along `e` is bounded by `N * \u2225f\u2225`. -/\nlemma op_norm_extend_le : \u2225\u03c8\u2225 \u2264 N * \u2225f\u2225 :=\nbegin\n  have uni : uniform_inducing e := (uniform_embedding_of_bound _ h_e).to_uniform_inducing,\n  have eq : \u2200x, \u03c8 (e x) = f x := uniformly_extend_of_ind uni h_dense f.uniform_continuous,\n  by_cases N0 : 0 \u2264 N,\n  { refine op_norm_le_bound \u03c8 _ (is_closed_property h_dense (is_closed_le _ _) _),\n    { exact mul_nonneg N0 (norm_nonneg _) },\n    { exact continuous_norm.comp (cont \u03c8) },\n    { exact continuous_const.mul continuous_norm },\n    { assume x,\n      rw eq,\n      calc \u2225f x\u2225 \u2264 \u2225f\u2225 * \u2225x\u2225 : le_op_norm _ _\n        ... \u2264 \u2225f\u2225 * (N * \u2225e x\u2225) : mul_le_mul_of_nonneg_left (h_e x) (norm_nonneg _)\n        ... \u2264 N * \u2225f\u2225 * \u2225e x\u2225 : by rw [mul_comm \u2191N \u2225f\u2225, mul_assoc] } },\n  { have he : \u2200 x : E, x = 0,\n    { assume x,\n      have N0 : N \u2264 0 := le_of_lt (lt_of_not_ge N0),\n      rw \u2190 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\u03c8 : \u03c8 = 0, { rw hf, apply extend_zero },\n    rw [h\u03c8, 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 \u2192\u209b\u2097\u1d62[\u03c3\u2081\u2082] F) :\n  \u2225f.to_continuous_linear_map\u2225 = 1 :=\nf.to_continuous_linear_map.homothety_norm $ by simp\n\nvariables {\u03c3\u2081\u2083 : \ud835\udd5c \u2192+* \ud835\udd5c\u2083} [ring_hom_comp_triple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083]\n\ninclude \u03c3\u2081\u2083\n/-- Postcomposition of a continuous linear map with a linear isometry preserves\nthe operator norm. -/\nlemma norm_to_continuous_linear_map_comp (f : F \u2192\u209b\u2097\u1d62[\u03c3\u2082\u2083] G) {g : E \u2192SL[\u03c3\u2081\u2082] F} :\n  \u2225f.to_continuous_linear_map.comp g\u2225 = \u2225g\u2225 :=\nop_norm_ext (f.to_continuous_linear_map.comp g) g\n  (\u03bb x, by simp only [norm_map, coe_to_continuous_linear_map, coe_comp'])\nomit \u03c3\u2081\u2083\n\nend linear_isometry\n\nend\n\nnamespace continuous_linear_map\n\nvariables [nondiscrete_normed_field \ud835\udd5c] [nondiscrete_normed_field \ud835\udd5c\u2082] [nondiscrete_normed_field \ud835\udd5c\u2083]\n  [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c\u2082 F] [normed_space \ud835\udd5c\u2083 G] [normed_space \ud835\udd5c F\u2097] (c : \ud835\udd5c)\n  {\u03c3\u2081\u2082 : \ud835\udd5c \u2192+* \ud835\udd5c\u2082} {\u03c3\u2082\u2083 : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c\u2083}\n\nvariables {\ud835\udd5c\u2082' : Type*} [nondiscrete_normed_field \ud835\udd5c\u2082'] {F' : Type*} [normed_group F']\n  [normed_space \ud835\udd5c\u2082' F'] {\u03c3\u2082' : \ud835\udd5c\u2082' \u2192+* \ud835\udd5c\u2082} {\u03c3\u2082'' : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c\u2082'}\n  {\u03c3\u2082\u2083' : \ud835\udd5c\u2082' \u2192+* \ud835\udd5c\u2083}\n  [ring_hom_inv_pair \u03c3\u2082' \u03c3\u2082''] [ring_hom_inv_pair \u03c3\u2082'' \u03c3\u2082']\n  [ring_hom_comp_triple \u03c3\u2082' \u03c3\u2082\u2083 \u03c3\u2082\u2083'] [ring_hom_comp_triple \u03c3\u2082'' \u03c3\u2082\u2083' \u03c3\u2082\u2083]\n  [ring_hom_isometric \u03c3\u2082\u2083]\n  [ring_hom_isometric \u03c3\u2082'] [ring_hom_isometric \u03c3\u2082''] [ring_hom_isometric \u03c3\u2082\u2083']\n\ninclude \u03c3\u2082'' \u03c3\u2082\u2083'\n/-- Precomposition with a linear isometry preserves the operator norm. -/\nlemma op_norm_comp_linear_isometry_equiv (f : F \u2192SL[\u03c3\u2082\u2083] G) (g : F' \u2243\u209b\u2097\u1d62[\u03c3\u2082'] F) :\n  \u2225f.comp g.to_linear_isometry.to_continuous_linear_map\u2225 = \u2225f\u2225 :=\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 \u03c3\u2082'' \u03c3\u2082\u2083'\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 \u2192L[\ud835\udd5c] \ud835\udd5c) (f : F\u2097) :\n  \u2225smul_right c f\u2225 = \u2225c\u2225 * \u2225f\u2225 :=\nbegin\n  refine le_antisymm _ _,\n  { apply op_norm_le_bound _ (mul_nonneg (norm_nonneg _) (norm_nonneg _)) (\u03bbx, _),\n    calc\n     \u2225(c x) \u2022 f\u2225 = \u2225c x\u2225 * \u2225f\u2225 : norm_smul _ _\n     ... \u2264 (\u2225c\u2225 * \u2225x\u2225) * \u2225f\u2225 :\n       mul_le_mul_of_nonneg_right (le_op_norm _ _) (norm_nonneg _)\n     ... = \u2225c\u2225 * \u2225f\u2225 * \u2225x\u2225 : by ring },\n  { by_cases h : f = 0,\n    { simp [h] },\n    { have : 0 < \u2225f\u2225 := norm_pos_iff.2 h,\n      rw \u2190 le_div_iff this,\n      apply op_norm_le_bound _ (div_nonneg (norm_nonneg _) (norm_nonneg f)) (\u03bbx, _),\n      rw [div_mul_eq_mul_div, le_div_iff this],\n      calc \u2225c x\u2225 * \u2225f\u2225 = \u2225c x \u2022 f\u2225 : (norm_smul _ _).symm\n      ... = \u2225smul_right c f x\u2225 : rfl\n      ... \u2264 \u2225smul_right c f\u2225 * \u2225x\u2225 : 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 \u2192L[\ud835\udd5c] \ud835\udd5c) (f : F\u2097) :\n  \u2225smul_right c f\u2225\u208a = \u2225c\u2225\u208a * \u2225f\u2225\u208a :=\nnnreal.eq $ c.norm_smul_right_apply f\n\nvariables (\ud835\udd5c E F\u2097)\n\n/-- `continuous_linear_map.smul_right` as a continuous trilinear map:\n`smul_rightL (c : E \u2192L[\ud835\udd5c] \ud835\udd5c) (f : F) (x : E) = c x \u2022 f`. -/\ndef smul_rightL : (E \u2192L[\ud835\udd5c] \ud835\udd5c) \u2192L[\ud835\udd5c] F\u2097 \u2192L[\ud835\udd5c] E \u2192L[\ud835\udd5c] F\u2097 :=\nlinear_map.mk_continuous\u2082\n  { to_fun := smul_right\u2097,\n    map_add' := \u03bb c\u2081 c\u2082, by { ext x, simp only [add_smul, coe_smul_right\u2097, add_apply,\n                                               smul_right_apply, linear_map.add_apply] },\n    map_smul' := \u03bb m c, by { ext x, simp only [smul_smul, coe_smul_right\u2097, 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 $ \u03bb c x, by simp only [coe_smul_right\u2097, one_mul, norm_smul_right_apply, linear_map.coe_mk]\n\nvariables {\ud835\udd5c E F\u2097}\n\n@[simp] lemma norm_smul_rightL_apply (c : E \u2192L[\ud835\udd5c] \ud835\udd5c) (f : F\u2097) :\n  \u2225smul_rightL \ud835\udd5c E F\u2097 c f\u2225 = \u2225c\u2225 * \u2225f\u2225 :=\nnorm_smul_right_apply c f\n\n@[simp] lemma norm_smul_rightL (c : E \u2192L[\ud835\udd5c] \ud835\udd5c) [nontrivial F\u2097] :\n  \u2225smul_rightL \ud835\udd5c E F\u2097 c\u2225 = \u2225c\u2225 :=\ncontinuous_linear_map.homothety_norm _ c.norm_smul_right_apply\n\nvariables (\ud835\udd5c) (\ud835\udd5c' : Type*) [normed_ring \ud835\udd5c'] [normed_algebra \ud835\udd5c \ud835\udd5c']\n\n@[simp] lemma op_norm_lmul : \u2225lmul \ud835\udd5c \ud835\udd5c'\u2225 = 1 :=\nby haveI := normed_algebra.nontrivial \ud835\udd5c \ud835\udd5c'; exact (lmul\u2097\u1d62 \ud835\udd5c \ud835\udd5c').norm_to_continuous_linear_map\n\n@[simp] lemma op_norm_lmul_right : \u2225lmul_right \ud835\udd5c \ud835\udd5c'\u2225 = 1 :=\n(op_norm_flip (@lmul \ud835\udd5c _ \ud835\udd5c' _ _)).trans (op_norm_lmul _ _)\n\nend continuous_linear_map\n\nnamespace submodule\nvariables [nondiscrete_normed_field \ud835\udd5c] [nondiscrete_normed_field \ud835\udd5c\u2082] [nondiscrete_normed_field \ud835\udd5c\u2083]\n  [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c\u2082 F] {\u03c3\u2081\u2082 : \ud835\udd5c \u2192+* \ud835\udd5c\u2082}\n\nlemma norm_subtypeL (K : submodule \ud835\udd5c E) [nontrivial K] : \u2225K.subtypeL\u2225 = 1 :=\nK.subtype\u2097\u1d62.norm_to_continuous_linear_map\n\nend submodule\n\nnamespace continuous_linear_equiv\nvariables [nondiscrete_normed_field \ud835\udd5c] [nondiscrete_normed_field \ud835\udd5c\u2082] [nondiscrete_normed_field \ud835\udd5c\u2083]\n  [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c\u2082 F] {\u03c3\u2081\u2082 : \ud835\udd5c \u2192+* \ud835\udd5c\u2082} {\u03c3\u2082\u2081 : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c}\n  [ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081] [ring_hom_inv_pair \u03c3\u2082\u2081 \u03c3\u2081\u2082]\n\nsection\nvariables [ring_hom_isometric \u03c3\u2082\u2081]\n\nprotected lemma antilipschitz (e : E \u2243SL[\u03c3\u2081\u2082] F) :\n  antilipschitz_with (nnnorm (e.symm : F \u2192SL[\u03c3\u2082\u2081] E)) e :=\ne.symm.lipschitz.to_right_inverse e.left_inv\n\ninclude \u03c3\u2082\u2081\n/-- A continuous linear equiv is a uniform embedding. -/\nlemma uniform_embedding [ring_hom_isometric \u03c3\u2081\u2082] (e : E \u2243SL[\u03c3\u2081\u2082] F) : uniform_embedding e :=\ne.antilipschitz.uniform_embedding e.lipschitz.uniform_continuous\nomit \u03c3\u2082\u2081\n\nlemma one_le_norm_mul_norm_symm [ring_hom_isometric \u03c3\u2081\u2082] [nontrivial E] (e : E \u2243SL[\u03c3\u2081\u2082] F) :\n  1 \u2264 \u2225(e : E \u2192SL[\u03c3\u2081\u2082] F)\u2225 * \u2225(e.symm : F \u2192SL[\u03c3\u2082\u2081] E)\u2225 :=\nbegin\n  rw [mul_comm],\n  convert (e.symm : F \u2192SL[\u03c3\u2082\u2081] E).op_norm_comp_le (e : E \u2192SL[\u03c3\u2081\u2082] F),\n  rw [e.coe_symm_comp_coe, continuous_linear_map.norm_id]\nend\n\ninclude \u03c3\u2082\u2081\nlemma norm_pos [ring_hom_isometric \u03c3\u2081\u2082] [nontrivial E] (e : E \u2243SL[\u03c3\u2081\u2082] F) :\n  0 < \u2225(e : E \u2192SL[\u03c3\u2081\u2082] F)\u2225 :=\npos_of_mul_pos_right (lt_of_lt_of_le zero_lt_one e.one_le_norm_mul_norm_symm) (norm_nonneg _)\nomit \u03c3\u2082\u2081\n\nlemma norm_symm_pos [ring_hom_isometric \u03c3\u2081\u2082] [nontrivial E] (e : E \u2243SL[\u03c3\u2081\u2082] F) :\n  0 < \u2225(e.symm : F \u2192SL[\u03c3\u2082\u2081] E)\u2225 :=\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 \u03c3\u2081\u2082] [nontrivial E] (e : E \u2243SL[\u03c3\u2081\u2082] F) :\n  0 < nnnorm (e.symm : F \u2192SL[\u03c3\u2082\u2081] E) :=\ne.norm_symm_pos\n\nlemma subsingleton_or_norm_symm_pos [ring_hom_isometric \u03c3\u2081\u2082] (e : E \u2243SL[\u03c3\u2081\u2082] F) :\n  subsingleton E \u2228 0 < \u2225(e.symm : F \u2192SL[\u03c3\u2082\u2081] E)\u2225 :=\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 \u03c3\u2081\u2082] (e : E \u2243SL[\u03c3\u2081\u2082] F) :\n  subsingleton E \u2228 0 < (nnnorm $ (e.symm : F \u2192SL[\u03c3\u2082\u2081] E)) :=\nsubsingleton_or_norm_symm_pos e\n\nvariable (\ud835\udd5c)\n\n/-- Given a nonzero element `x` of a normed space `E\u2081` over a field `\ud835\udd5c`, the natural\n    continuous linear equivalence from `E\u2081` to the span of `x`.-/\ndef to_span_nonzero_singleton (x : E) (h : x \u2260 0) : \ud835\udd5c \u2243L[\ud835\udd5c] (\ud835\udd5c \u2219 x) :=\nof_homothety\n  (linear_equiv.to_span_nonzero_singleton \ud835\udd5c E x h)\n  \u2225x\u2225\n  (norm_pos_iff.mpr h)\n  (to_span_nonzero_singleton_homothety \ud835\udd5c x h)\n\n/-- Given a nonzero element `x` of a normed space `E\u2081` over a field `\ud835\udd5c`, the natural continuous\n    linear map from the span of `x` to `\ud835\udd5c`.-/\ndef coord (x : E) (h : x \u2260 0) : (\ud835\udd5c \u2219 x) \u2192L[\ud835\udd5c] \ud835\udd5c := (to_span_nonzero_singleton \ud835\udd5c x h).symm\n\n@[simp] lemma coe_to_span_nonzero_singleton_symm {x : E} (h : x \u2260 0) :\n  \u21d1(to_span_nonzero_singleton \ud835\udd5c x h).symm = coord \ud835\udd5c x h := rfl\n\n@[simp] lemma coord_to_span_nonzero_singleton {x : E} (h : x \u2260 0) (c : \ud835\udd5c) :\n  coord \ud835\udd5c x h (to_span_nonzero_singleton \ud835\udd5c x h c) = c :=\n(to_span_nonzero_singleton \ud835\udd5c x h).symm_apply_apply c\n\n@[simp] lemma to_span_nonzero_singleton_coord {x : E} (h : x \u2260 0) (y : \ud835\udd5c \u2219 x) :\n  to_span_nonzero_singleton \ud835\udd5c x h (coord \ud835\udd5c x h y) = y :=\n(to_span_nonzero_singleton \ud835\udd5c x h).apply_symm_apply y\n\n@[simp] lemma coord_norm (x : E) (h : x \u2260 0) : \u2225coord \ud835\udd5c x h\u2225 = \u2225x\u2225\u207b\u00b9 :=\nbegin\n  have hx : 0 < \u2225x\u2225 := (norm_pos_iff.mpr h),\n  haveI : nontrivial (\ud835\udd5c \u2219 x) := submodule.nontrivial_span_singleton h,\n  exact continuous_linear_map.homothety_norm _\n        (\u03bb y, homothety_inverse _ hx _ (to_span_nonzero_singleton_homothety \ud835\udd5c x h) _)\nend\n\n@[simp] lemma coord_self (x : E) (h : x \u2260 0) :\n  (coord \ud835\udd5c x h) (\u27e8x, submodule.mem_span_singleton_self x\u27e9 : \ud835\udd5c \u2219 x) = 1 :=\nlinear_equiv.coord_self \ud835\udd5c E x h\n\nend\n\nend continuous_linear_equiv\n\nvariables [nondiscrete_normed_field \ud835\udd5c] [nondiscrete_normed_field \ud835\udd5c\u2082]\n  [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c\u2082 F] {\u03c3\u2081\u2082 : \ud835\udd5c \u2192+* \ud835\udd5c\u2082} {\u03c3\u2082\u2081 : \ud835\udd5c\u2082 \u2192+* \ud835\udd5c}\n  [ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081] [ring_hom_inv_pair \u03c3\u2082\u2081 \u03c3\u2081\u2082]\n  [ring_hom_isometric \u03c3\u2081\u2082] [ring_hom_isometric \u03c3\u2082\u2081]\n\ninclude \u03c3\u2082\u2081\nlemma linear_equiv.uniform_embedding (e : E \u2243\u209b\u2097[\u03c3\u2081\u2082] F) (h\u2081 : continuous e)\n  (h\u2082 : continuous e.symm) : uniform_embedding e :=\ncontinuous_linear_equiv.uniform_embedding\n({ continuous_to_fun := h\u2081,\n  continuous_inv_fun := h\u2082,\n  .. e } : E \u2243SL[\u03c3\u2081\u2082] F)\n\nomit \u03c3\u2082\u2081\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 * \u2225u\u2225 * \u2225u\u2225 \u2264 B u u`.\n-/\ndef is_coercive\n  [normed_group E] [normed_space \u211d E]\n  (B : E \u2192L[\u211d] E \u2192L[\u211d] \u211d) : Prop :=\n\u2203 C, (0 < C) \u2227 \u2200 u, C * \u2225u\u2225 * \u2225u\u2225 \u2264 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 : \u2115) (\u03b1 : Type) :=\n  (g  : dep_vec_grid \u03b1 m n)\n\nprivate lemma matrix_of_f_ {x : \u2124} {m} (h : x < \u2191m) (h\u2081 : 0 \u2264 x) : |x| < m :=\n  by rwa [\u2190 int.coe_nat_lt_coe_nat_iff, int.nat_abs_of_nonneg h\u2081]\n\ndef matrix_of_f {m n} {\u03b1} (h : m * n > 0) (f : fin m \u2192 fin n \u2192 \u03b1) : matrix m n \u03b1 :=\n  \u27e8\u27e8h, \u27e8\u2118(fgrid\u2080.mk m n h \u27e80, 0\u27e9\n    (\u03bbx y, f \n      \u27e8|x.1|,\n         begin\n           rcases x with \u27e8x, \u27e8hx\u2081, hx\u2082\u27e9\u27e9, simp at hx\u2081 hx\u2082 \u22a2, \n           exact matrix_of_f_ hx\u2082 hx\u2081\n         end\n       \u27e9\n      \u27e8|y.1|,\n         begin\n           rcases y with \u27e8y, \u27e8hy\u2081, hy\u2082\u27e9\u27e9, simp at hy\u2081 hy\u2082 \u22a2, \n           exact matrix_of_f_ hy\u2082 hy\u2081\n         end\n      \u27e9)), by simpa [length_generate_eq_size, size]\u27e9\u27e9\u27e9\n\nprivate lemma matrix_at_ {m n} {\u03b1} (m\u2081 : matrix m n \u03b1) (i : fin m) :\n  (grid.bl (vec_grid_of_dep_vec_grid (m\u2081.g))).y \u2264 \u2191(i.val) \u2227\n  \u2191(i.val) < (gtr (vec_grid_of_dep_vec_grid (m\u2081.g))).y :=\nbegin\n  rcases m\u2081 with \u27e8\u27e8h, \u27e8d, hd\u27e9\u27e9\u27e9,\n  simp [grid.bl, expand_gtr, relative_grid.rows, vec_grid_of_dep_vec_grid],\n  norm_cast,\n  exact \u27e8zero_le _, i.2\u27e9\nend\n\nprivate lemma matrix_at_ {m n} {\u03b1} (m\u2081 : matrix m n \u03b1) (j : fin n) :\n  (grid.bl (vec_grid_of_dep_vec_grid (m\u2081.g))).x \u2264 \u2191(j.val) \u2227\n  \u2191(j.val) < (gtr (vec_grid_of_dep_vec_grid (m\u2081.g))).x :=\nbegin\n  rcases m\u2081 with \u27e8\u27e8h, \u27e8d, hd\u27e9\u27e9\u27e9,\n  simp [grid.bl, expand_gtr, relative_grid.rows, vec_grid_of_dep_vec_grid],\n  norm_cast,\n  exact \u27e8zero_le _, j.2\u27e9\nend\n\ndef matrix_at {m n} {\u03b1} (m\u2081 : matrix m n \u03b1) (i : fin m) (j : fin n) : \u03b1 :=\n  abs_data (vec_grid_of_dep_vec_grid m\u2081.1)\n    \u27e8\u27e8i.1, matrix_at_ m\u2081 i\u27e9, \u27e8j.1, matrix_at_ m\u2081 j\u27e9\u27e9\n\n@[simp]\nlemma matrix_get_mk {\u03b1} {m n} (h : m * n > 0)\n  (f : fin m \u2192 fin n \u2192 \u03b1) (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\u2080, 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 : \u2200x, 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 : \u2191i + -int.zero = \u2191i, by ring, simp [this, intzero_add],\n      unfold_coes, simp [fin.val],\n      rw [\u2190 int.coe_nat_eq_coe_nat_iff, int.coe_nat_div, int.coe_nat_add], simp,\n      have h\u2081 : int.of_nat i + -int.zero = \u2191i, by ring,\n      have : int.of_nat i + -int.zero \u2265 (0 : \u2124), by norm_cast,\n      rw int.nat_abs_of_nonneg, swap 2, exact this,\n      have : \u2191n \u2260 (0 : \u2124), by simp; clear_except h; intros contra; subst contra; linarith,\n      rw int.add_mul_div_right _ _ this,\n      have : \u2191i / \u2191n = (0 : \u2124), 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 \u2190 int.coe_nat_eq_coe_nat_iff,\n      have : int.of_nat i % int.of_nat n \u2265 (0 : \u2124), by norm_cast,\n      rw int.nat_abs_of_nonneg this, repeat { rw int.of_nat_eq_coe },\n      rw [\u2190 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 : \u2115} {\u03b1 : Type} {m\u2081 m\u2082 : matrix m n \u03b1}\n\ntheorem ext_iff : m\u2081.g = m\u2082.g \u2194 m\u2081 = m\u2082 :=\n  by cases m\u2081; rcases m\u2082; simp\n\n@[extensionality] theorem ext : m\u2081.g = m\u2082.g \u2192 m\u2081 = m\u2082 := ext_iff.1\n\n@[extensionality]\nlemma m_ext {m\u2081 m\u2082 : matrix m n \u03b1}\n  (h : \u2200i j, matrix_at m\u2081 i j = matrix_at m\u2082 i j) : m\u2081 = m\u2082 :=\nbegin\n  let m\u2081' := @matrix_of_f m n _ m\u2081.1.1\n    (\u03bbx y, abs_data (vec_grid_of_dep_vec_grid m\u2081.1) \u27e8\u27e8x.1, \u27e8_, _\u27e9\u27e9, \u27e8y.1, \u27e8_, _\u27e9\u27e9\u27e9),\n  let m\u2082' := @matrix_of_f m n _ m\u2082.1.1\n    (\u03bbx y, abs_data (vec_grid_of_dep_vec_grid m\u2082.1) \u27e8\u27e8x.1, \u27e8_, _\u27e9\u27e9, \u27e8y.1, \u27e8_, _\u27e9\u27e9\u27e9),\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\u2081 : m\u2081 = m\u2081',\n    {\n      rcases m\u2081 with \u27e8\u27e8h, \u27e8d, hd\u27e9\u27e9\u27e9,\n      simp [m\u2081', 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\u2081 h\u2082, 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            \u2190 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 \u2265 (0 : \u2124), 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\u2081 at h,\n  have heq\u2082 : m\u2082 = m\u2082',\n    {\n      rcases m\u2082 with \u27e8\u27e8h, \u27e8d, hd\u27e9\u27e9\u27e9,\n      simp [m\u2082', 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\u2081 h\u2082, 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            \u2190 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 \u2265 (0 : \u2124), 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\u2082 at h,\n  simp [m\u2081', m\u2082'] at h,\n  delta vec_grid_of_dep_vec_grid at h,\n  rcases m\u2081 with \u27e8\u27e8h\u2081, \u27e8d\u2081, hd\u2081\u27e9\u27e9\u27e9, rcases m\u2082 with \u27e8\u27e8h\u2082, \u27e8d\u2082, hd\u2082\u27e9\u27e9\u27e9, 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\u2081, hd\u2082]},\n    {\n      intros k hk\u2081 hk\u2082,\n      have eq\u2081 : k % n < n, by\n        apply nat.mod_lt; exact (gt_and_gt_of_mul_gt h\u2081).2,\n      have eq\u2082 : k / n < m, {\n        rw hd\u2081 at hk\u2081, rw nat.div_lt_iff_lt_mul, exact hk\u2081,\n        exact (gt_and_gt_of_mul_gt h\u2081).2\n      },\n      specialize h \u27e8k / n, eq\u2082\u27e9 \u27e8k % n, eq\u2081\u27e9,\n      revert h, rw \u2190 option.some_inj, intros h,\n      repeat { rw \u2190 list.nth_le_nth at h }, simp at h,\n      rw \u2190 option.some_inj, repeat { rw \u2190 list.nth_le_nth },\n      have : k % n + k / n * n = k,\n        {\n          rw [\n            mul_comm,\n            \u2190 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 : \u2115} {\u03b1 \u03b2 \u03b3 \u03b4 : Type}\n\nopen relative_grid grid\n\nlemma matrix_nonempty {m\u2081 : matrix m n \u03b1} : m * n > 0 := m\u2081.1.1\n\ndef matrix_string [has_to_string \u03b1] (m : matrix m n \u03b1) :=\n  grid_str (vec_grid_of_dep_vec_grid m.g)\n\ninstance matrix_repr [has_to_string \u03b1] : has_repr (matrix m n \u03b1) :=\n  \u27e8matrix_string\u27e9\n\ninstance matrix_to_string [has_to_string \u03b1] : has_to_string (matrix m n \u03b1) :=\n  \u27e8matrix_string\u27e9\n\ninstance matrix_functor : functor (matrix m n) := {\n  map := \u03bb\u03b1 \u03b2 f m, \u27e8f <$> m.g\u27e9\n}\n\ninstance matrix_functor_law : is_lawful_functor (matrix m n) := {\n  id_map := \u03bb\u03b1 \u27e8\u27e8r, c, h\u27e9\u27e9, by simp [(<$>), vector.map_id],\n  comp_map := \u03bb\u03b1 \u03b2 \u03b3 f h \u27e8\u27e8r, c, h\u27e9\u27e9, by simp [(<$>)]\n}\n\ndef m\u2081 : matrix 5 2 \u2115 :=\n  matrix.mk\n    (@dep_vec_grid.mk _ 5 2 dec_trivial\n                       \u27e8[1, 3, 4, 5, 7, 8, 9, 10, 11, 12], dec_trivial\u27e9)\n\ndef m\u2082 : matrix 2 3 \u2115 :=\n  matrix.mk\n    (@dep_vec_grid.mk _ 2 3 dec_trivial\n                      \u27e8[2, 2, 2, 2, 2, 2], dec_trivial\u27e9)\n\ninstance [has_add \u03b1] : has_add (matrix m n \u03b1) := {\n  add := \u03bbm\u2081 m\u2082, \u27e8\n    @dep_vec_grid.mk _ m n m\u2081.1.1 (vector.zip_with (+) m\u2081.1.2 m\u2082.1.2)\n  \u27e9\n}\n\ndef transpose {\u03b1} {m n} (m\u2081 : matrix m n \u03b1) : matrix n m \u03b1 :=\n  matrix_of_f (by rw mul_comm; exact m\u2081.1.1) $ \u03bbi j, matrix_at m\u2081 j i\n\ntheorem transpose_transpose_eq_self (A : matrix m n \u03b1) :\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 : \u00ac 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\u00f6lich, *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\u2070`. -/\ntheorem IsIntegralClosure.isLocalization [IsSeparable K L] [NoZeroSMulDivisors A L] :\n    IsLocalization (Algebra.algebraMapSubmonoid C A\u2070) 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' \u27e8_, fun z => _, fun x y => \u27e8fun h => \u27e81, _\u27e9, _\u27e9\u27e9\n  \u00b7 rintro \u27e8_, x, hx, rfl\u27e9\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  \u00b7 obtain \u27e8m, hm\u27e9 :=\n      IsIntegral.exists_multiple_integral_of_isLocalization A\u2070 z (IsSeparable.isIntegral K z)\n    obtain \u27e8x, hx\u27e9 : \u2203 x, algebraMap C L x = m \u2022 z := is_integral_closure.is_integral_iff.mp hm\n    refine' \u27e8\u27e8x, algebraMap A C m, m, SetLike.coe_mem m, rfl\u27e9, _\u27e9\n    rw [Subtype.coe_mk, \u2190 IsScalarTower.algebraMap_apply, hx, mul_comm, Submonoid.smul_def,\n      smul_def]\n  \u00b7 simp only [IsIntegralClosure.algebraMap_injective C A L h]\n  \u00b7 rintro \u27e8\u27e8_, m, hm, rfl\u27e9, h\u27e9\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] {\u03b9 : Type _} [Fintype \u03b9]\n    [DecidableEq \u03b9] (b : Basis \u03b9 K L) (hb_int : \u2200 i, IsIntegral A (b i)) [IsIntegrallyClosed A] :\n    ((Algebra.linearMap C L).restrictScalars A).range \u2264\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 _ \u27e8x, rfl\u27e9\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 \u27e8c, x_eq\u27e9 : \u2203 c : \u03b9 \u2192 A, algebraMap C L x = \u2211 i, c i \u2022 db i\n  \u00b7 rw [x_eq]\n    refine' Submodule.sum_mem _ fun i _ => Submodule.smul_mem _ _ (Submodule.subset_span _)\n    rw [Set.mem_range]\n    exact \u27e8i, rfl\u27e9\n  suffices \u2203 c : \u03b9 \u2192 K, (\u2200 i, IsIntegral A (c i)) \u2227 algebraMap C L x = \u2211 i, c i \u2022 db i\n    by\n    obtain \u27e8c, hc, hx\u27e9 := this\n    have hc' : \u2200 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 [\u2190 Classical.choose_spec (hc' i)]\n    rw [\u2190 IsScalarTower.algebraMap_smul K (Classical.choose (hc' i)) (db i)]\n  refine' \u27e8fun i => db.repr (algebraMap C L x) i, fun i => _, (db.sum_repr _).symm\u27e9\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] {\u03b9 : Type _} [Fintype \u03b9] [DecidableEq \u03b9]\n    (b : Basis \u03b9 K L) (hb_int : \u2200 i, IsIntegral A (b i)) [IsIntegrallyClosed A] :\n    (integralClosure A L).toSubmodule \u2264\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 \u27e8\u27e8x, hx\u27e9, rfl\u27e9\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 \u00abexpr \u2260 \u00bb (0 : A)) -/\n/-- Send a set of `x`'es in a finite extension `L` of the fraction field of `R`\nto `(y : R) \u2022 x \u2208 integral_closure R L`. -/\ntheorem exists_integral_multiples (s : Finset L) :\n    \u2203 (y : _)(_ : y \u2260 (0 : A)), \u2200 x \u2208 s, IsIntegral A (y \u2022 x) :=\n  by\n  haveI := Classical.decEq L\n  refine' s.induction _ _\n  \u00b7 use 1, one_ne_zero\n    rintro x \u27e8\u27e9\n  \u00b7 rintro x s hx \u27e8y, hy, hs\u27e9\n    obtain \u27e8x', y', hy', hx'\u27e9 :=\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' \u27e8y * y', mul_ne_zero hy hy', fun x'' hx'' => _\u27e9\n    rcases finset.mem_insert.mp hx'' with (rfl | hx'')\n    \u00b7 rw [mul_smul, Algebra.smul_def, Algebra.smul_def, mul_comm _ x'', hx']\n      exact isIntegral_mul isIntegral_algebraMap x'.2\n    \u00b7 rw [mul_comm, mul_smul, Algebra.smul_def]\n      exact isIntegral_mul isIntegral_algebraMap (hs _ hx'')\n    \u00b7 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    \u2203 (s : Finset L)(b : Basis s K L), \u2200 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 \u27e8y, hy, his'\u27e9 := exists_integral_multiples A K (finset.univ.image bs')\n  have hy' : algebraMap A L y \u2260 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    \u27e8s',\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)\u207b\u00b9 * x\n          left_inv := _\n          right_inv := _ },\n      _\u27e9\n  \u00b7 intro x\n    simp only [inv_mul_cancel_left\u2080 hy']\n  \u00b7 intro x\n    simp only [mul_inv_cancel_left\u2080 hy']\n  \u00b7 rintro \u27e8x', hx'\u27e9\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' _ \u27e8_, rfl\u27e9\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 \u27e8s, b, hb_int\u27e9 := 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 \u2192\u2097[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\u2070) L :=\n    IsIntegralClosure.isLocalization A K L C\n  let b := Basis.localizationLocalization K A\u2070 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  \u27e8IsIntegralClosure.isNoetherianRing A K L C, h.dimension_le_one.is_integral_closure _ L _,\n    (isIntegrallyClosed_iff L).mpr fun x hx =>\n      \u27e8IsIntegralClosure.mk' C x (isIntegral_trans (IsIntegralClosure.isIntegral_algebra A L) _ hx),\n        IsIntegralClosure.algebraMap_mk' _ _ _\u27e9\u27e9\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": "import .dlo_qelim .to_fm \n\nopen tactic\n\nmeta def to_idx : expr \u2192 tactic nat \n| (expr.var n) := return n \n| _ := failed\n\nmeta def to_adlo (\u03b2 : Type) [reflected \u03b2] (i : nat) : expr \u2192 tactic (adlo \u00d7 list \u03b2)\n| `(%%(expr.var m) = %%(expr.var n)) := return ((m =' n), [])\n| `(%%(expr.var m) = %%ne) := \n  do bn \u2190 eval_expr \u03b2 ne,\n     return ((m =' i), [bn])\n| `(%%me = %%(expr.var n)) := \n  do bm \u2190 eval_expr \u03b2 me,\n     return ((i =' n), [bm])\n| `(%%me = %%ne) := \n  do bm \u2190 eval_expr \u03b2 me,\n     bn \u2190 eval_expr \u03b2 ne,\n     return ((i =' i+1), [bm,bn])\n| `(%%(expr.var m) < %%(expr.var n)) := return ((m <' n), [])\n| `(%%(expr.var m) < %%ne) := \n  do bn \u2190 eval_expr \u03b2 ne,\n     return ((m <' i), [bn])\n| `(%%me < %%(expr.var n)) := \n  do bm \u2190 eval_expr \u03b2 me,\n     return ((i <' n), [bm])\n| `(%%me < %%ne) := \n  do bm \u2190 eval_expr \u03b2 me,\n     bn \u2190 eval_expr \u03b2 ne,\n     return ((i <' i+1), [bm,bn])\n| _ := failed\n\nmeta def dec_dlo_nat : tactic unit := \ndo (p,ns) \u2190 target >>= to_fm adlo nat (to_adlo nat) 0, \n   trace p, trace \"\\n\", trace ns \n\nexample : \u00ac \u2203 (n : nat), \u00ac (n = 0 \u2228 0 < n) := by dec_dlo_nat \n", "meta": {"author": "avigad", "repo": "qelim", "sha": "b7d22864f1f0a2d21adad0f4fb3fc7ba665f8e60", "save_path": "github-repos/lean/avigad-qelim", "path": "github-repos/lean/avigad-qelim/qelim-b7d22864f1f0a2d21adad0f4fb3fc7ba665f8e60/dlo/dlo_main.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8198933447152498, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4920904413330074}}
{"text": "import topology.instances.real \n\nopen filter real\nopen_locale topological_space \n\ntheorem problem_5 (a : \u211d) (f : \u2115 \u2192 \u211d) :\n  (\u2203 N, \u2200 \u03b5 > 0, \u2200 n \u2265 N, abs (f n - a) < \u03b5) \u2194 (\u2203 N, \u2200 n \u2265 N, f n = a) :=\nbegin \n  sorry \nend \n", "meta": {"author": "ImperialCollegeLondon", "repo": "m1fexplained_lean3", "sha": "570c9a3ff8cfc3805047f2796864516a49f51510", "save_path": "github-repos/lean/ImperialCollegeLondon-m1fexplained_lean3", "path": "github-repos/lean/ImperialCollegeLondon-m1fexplained_lean3/m1fexplained_lean3-570c9a3ff8cfc3805047f2796864516a49f51510/src/chapter23/exercises/exercise05.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8577681049901036, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4920830404342797}}
{"text": "example (P Q : Prop) (p : P) (q : Q) : P \u2227 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 \u2228 (0xdfff < n \u2227 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 \u2264 b.val\n\ninstance : LT Char := \u27e8Char.lt\u27e9\ninstance : LE Char := \u27e8Char.le\u27e9\n\ninstance (a b : Char) :  Decidable (a < b) :=\n  UInt32.decLt _ _\n\ninstance (a b : Char) : Decidable (a \u2264 b) :=\n  UInt32.decLe _ _\n\nabbrev isValidCharNat (n : Nat) : Prop :=\n  n < 0xd800 \u2228 (0xdfff < n \u2227 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 \u27e8h\u2081, h\u2082\u27e9 =>\n    apply Nat.ltTrans h\u2082\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 \u27e8h\u2081, h\u2082\u27e9 => Or.inr \u27e8h\u2081, h\u2082\u27e9\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 \u2265 65 && c.val \u2264 90\n\ndef isLower (c : Char) : Bool :=\n  c.val \u2265 97 && c.val \u2264 122\n\ndef isAlpha (c : Char) : Bool :=\n  c.isUpper || c.isLower\n\ndef isDigit (c : Char) : Bool :=\n  c.val \u2265 48 && c.val \u2264 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 \u2227 n <= 90 then ofNat (n + 32) else c\n\ndef toUpper (c : Char) : Char :=\n  let n := toNat c;\n  if n >= 97 \u2227 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  \u2200 (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) (\ud835\udca5\u2081 : DecidableEq J) (\ud835\udca5\u2082 : 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  \u2200 (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) (\ud835\udca5\u2081 : DecidableEq J) (\ud835\udca5\u2082 : 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  \u00ac a \u2194 a \u2192 false :=\nby refl\n\n@[simp] lemma not_not_iff (a : Prop) [decidable a] :\n  \u00ac\u00ac a \u2194 a :=\nby by_cases a; simp [h]\n\n@[simp] lemma and_imp_distrib (a b c : Prop) :\n  (a \u2227 b \u2192 c) \u2194 (a \u2192 b \u2192 c) :=\niff.intro\n  (assume h ha hb, h \u27e8ha, hb\u27e9)\n  (assume h \u27e8ha, hb\u27e9, h ha hb)\n\n@[simp] lemma or_imp_distrib {a b c : Prop} :\n  a \u2228 b \u2192 c \u2194 (a \u2192 c) \u2227 (b \u2192 c) :=\niff.intro\n  (assume h,\n   \u27e8assume ha, h (or.intro_left _ ha), assume hb, h (or.intro_right _ hb)\u27e9)\n  (assume \u27e8ha, hb\u27e9 h, match h with or.inl h := ha h | or.inr h := hb h end)\n\n@[simp] lemma exists_imp_distrib {\u03b1 : Sort*} {p : \u03b1 \u2192 Prop} {a : Prop} :\n  ((\u2203x, p x) \u2192 a) \u2194 (\u2200x, p x \u2192 a) :=\niff.intro\n  (assume h hp ha, h \u27e8hp, ha\u27e9)\n  (assume h \u27e8hp, ha\u27e9, h hp ha)\n\nlemma and_exists {\u03b1 : Sort*} {p : \u03b1 \u2192 Prop} {a : Prop} :\n  (a \u2227 (\u2203x, p x)) \u2194 (\u2203x, a \u2227 p x) :=\niff.intro\n  (assume \u27e8ha, x, hp\u27e9, \u27e8x, ha, hp\u27e9)\n  (assume \u27e8x, ha, hp\u27e9, \u27e8ha, x, hp\u27e9)\n\n@[simp] lemma exists_false {\u03b1 : Sort*} :\n  (\u2203x : \u03b1, false) \u2194 false :=\niff.intro (assume \u27e8a, f\u27e9, 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 \u2218 int.neg = id :=\nbegin\n  apply funext,\n  apply neg_neg\nend\n\n\n/- ## Reflexive Transitive Closure -/\n\nnamespace rtc\n\ninductive star {\u03b1 : Sort*} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : \u03b1 \u2192 Prop\n| refl {}    : star a\n| tail {b c} : star b \u2192 r b c \u2192 star c\n\nattribute [refl] star.refl\n\nnamespace star\n\nvariables {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a b c d : \u03b1}\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 {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {b : \u03b1}\n  {P : \u2200a : \u03b1, star r a b \u2192 Prop} {a : \u03b1} (h : star r a b)\n  (refl : P b refl)\n  (head : \u2200{a c} (h' : r a c) (h : star r c b), P c h \u2192 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 \u2200a a', r a a' \u2192 star r a' b \u2192 P a' _ \u2192 P a _, from\n      assume a a' hab hbc, head hab _ }\nend\n\nlemma trans_induction_on {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {p : \u2200{a b : \u03b1}, star r a b \u2192 Prop} {a b : \u03b1} (h : star r a b)\n    (ih\u2081 : \u2200a, @p a a refl) (ih\u2082 : \u2200{a b} (h : r a b), p (single h))\n    (ih\u2083 : \u2200{a b c} (h\u2081 : star r a b) (h\u2082 : star r b c), p h\u2081 \u2192\n       p h\u2082 \u2192 p (h\u2081.trans h\u2082)) :\n  p h :=\nbegin\n  induction' h,\n  case refl {\n    exact ih\u2081 a },\n  case tail : b c hab hbc ih {\n    exact ih\u2083 hab (single hbc) (ih ih\u2081 @ih\u2082 @ih\u2083) (ih\u2082 hbc) }\nend\n\nlemma lift {\u03b2 : Sort*} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (h : \u2200a b, r a b \u2192 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 \u2218 h _ _)\n  (assume a b c _ _, trans)\n\nlemma mono {p : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n  (\u2200a b, r a b \u2192 p a b) \u2192 star r a b \u2192 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 \u2192 \u2115\n\ndef state.update (name : string) (val : \u2115) (s : state) : state :=\n\u03bbname', if name' = name then val else s name'\n\nnotation s `{` name ` \u21a6 ` val `}` := state.update name val s\n\ninstance : has_emptyc state :=\n{ emptyc := \u03bb_, 0 }\n\n@[simp] lemma update_apply (name : string) (val : \u2115) (s : state) :\n  s{name \u21a6 val} name = val :=\nif_pos rfl\n\n@[simp] lemma update_apply_ne (name name' : string) (val : \u2115) (s : state)\n    (h : name' \u2260 name . tactic.dec_trivial) :\n  s{name \u21a6 val} name' = s name' :=\nif_neg h\n\n@[simp] lemma update_override (name : string) (val\u2081 val\u2082 : \u2115) (s : state) :\n  s{name \u21a6 val\u2082}{name \u21a6 val\u2081} = s{name \u21a6 val\u2081} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp [h]\nend\n\n@[simp] lemma update_swap (name\u2081 name\u2082 : string) (val\u2081 val\u2082 : \u2115) (s : state)\n    (h : name\u2081 \u2260 name\u2082 . tactic.dec_trivial) :\n  s{name\u2082 \u21a6 val\u2082}{name\u2081 \u21a6 val\u2081} = s{name\u2081 \u21a6 val\u2081}{name\u2082 \u21a6 val\u2082} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name\u2081;\n    by_cases name' = name\u2082;\n    simp * at *\nend\n\n@[simp] lemma update_id (name : string) (s : state) :\n  s{name \u21a6 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\" \u21a6 0}{\"a\" \u21a6 2} = s{\"a\" \u21a6 2} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" \u21a6 0}{\"b\" \u21a6 2} = s{\"b\" \u21a6 2}{\"a\" \u21a6 0} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" \u21a6 s \"a\"}{\"b\" \u21a6 0} = s{\"b\" \u21a6 0} :=\nby simp\n\n\n/- ## Relations -/\n\ndef Id {\u03b1 : Type} : set (\u03b1 \u00d7 \u03b1) :=\n{ab | prod.snd ab = prod.fst ab}\n\n@[simp] lemma mem_Id {\u03b1 : Type} (a b : \u03b1) :\n  (a, b) \u2208 @Id \u03b1 \u2194 b = a :=\nby refl\n\ndef comp {\u03b1 : Type} (r\u2081 r\u2082 : set (\u03b1 \u00d7 \u03b1)) : set (\u03b1 \u00d7 \u03b1) :=\n{ac | \u2203b, (prod.fst ac, b) \u2208 r\u2081 \u2227 (b, prod.snd ac) \u2208 r\u2082}\n\ninfixl ` \u25ef ` : 90 := comp\n\n@[simp] lemma mem_comp {\u03b1 : Type} (r\u2081 r\u2082 : set (\u03b1 \u00d7 \u03b1))\n    (a b : \u03b1) :\n  (a, b) \u2208 r\u2081 \u25ef r\u2082 \u2194 (\u2203c, (a, c) \u2208 r\u2081 \u2227 (c, b) \u2208 r\u2082) :=\nby refl\n\ndef restrict {\u03b1 : Type} (r : set (\u03b1 \u00d7 \u03b1)) (p : \u03b1 \u2192 Prop) :\n  set (\u03b1 \u00d7 \u03b1) :=\n{ab | p (prod.fst ab) \u2227 ab \u2208 r}\n\ninfixl ` \u21c3 ` : 90 := restrict\n\n@[simp] lemma mem_restrict {\u03b1 : Type} (r : set (\u03b1 \u00d7 \u03b1))\n    (p : \u03b1 \u2192 Prop) (a b : \u03b1) :\n  (a, b) \u2208 r \u21c3 p \u2194 p a \u2227 (a, b) \u2208 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' := \u03bb x y h, by { cases x, cases y, congr' } }\n\ninstance : submonoid_class (center_submonoid R A) A :=\n{ one_mem := \u03bb S, S.to_submonoid.one_mem,\n  mul_mem := \u03bb S _ _, S.to_submonoid.mul_mem, }\n\ninstance : nonempty S.to_sub_mul_action := \u27e8\u27e81, S.to_submonoid.one_mem\u27e9\u27e9\n\ninstance : zero_mem_class (center_submonoid R A) A :=\n{ zero_mem := \u03bb S,  S.to_sub_mul_action.zero_mem \u27e81, S.to_submonoid.one_mem\u27e9, }\n\nlemma smul_mem (r : R) {a : A} : a \u2208 S \u2192 r \u2022 a \u2208 S := S.to_sub_mul_action.smul_mem r\nprotected lemma mul_mem {a b : A} : a \u2208 S \u2192 b \u2208 S \u2192 a * b \u2208 S := S.to_submonoid.mul_mem\nprotected lemma one_mem : (1 : A) \u2208 S := S.to_submonoid.one_mem\nprotected lemma zero_mem : (0 : A) \u2208 S := S.to_sub_mul_action.zero_mem \u27e81, S.one_mem\u27e9\n\n@[simp] lemma algebra_map_mem (r : R) : algebra_map R A r \u2208 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) \u222a s) in\n{ smul_mem' := \u03bb 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 \u2286 closure R s :=\n\u03bb 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) \u222a 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 := \u03bb v, subtype.eq $ zero_mul \u2191v,\n  mul_zero := \u03bb v, subtype.eq $ mul_zero \u2191v,\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) : (\u2191(k \u2022 v) : A) = k \u2022 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 \u2208 S \u2192 -v \u2208 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) : (\u2191-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 \u2192 E} {\u03bc : measure X}\n\nnamespace measure_theory\n\n/-- A function `f : X \u2192 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 \u2192 E) (\u03bc : measure X . volume_tac) : Prop :=\n\u2200 \u2983K\u2984, is_compact K \u2192 integrable_on f K \u03bc\n\nlemma integrable.locally_integrable (hf : integrable f \u03bc) : locally_integrable f \u03bc :=\n\u03bb K hK, hf.integrable_on\n\nlemma locally_integrable.ae_strongly_measurable [sigma_compact_space X]\n  (hf : locally_integrable f \u03bc) :\n  ae_strongly_measurable f \u03bc :=\nbegin\n  rw [\u2190 @restrict_univ _ _ \u03bc, \u2190 Union_compact_covering, ae_strongly_measurable_Union_iff],\n  exact \u03bb 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 \u2192 \u211d}\n\nlemma integrable_on.mul_continuous_on_of_subset\n  (hg : integrable_on g A \u03bc) (hg' : continuous_on g' K)\n  (hA : measurable_set A) (hK : is_compact K) (hAK : A \u2286 K) :\n  integrable_on (\u03bb x, g x * g' x) A \u03bc :=\nbegin\n  rcases is_compact.exists_bound_of_continuous_on hK hg' with \u27e8C, hC\u27e9,\n  rw [integrable_on, \u2190 mem_\u2112p_one_iff_integrable] at hg \u22a2,\n  have : \u2200\u1d50 x \u2202(\u03bc.restrict A), \u2225g x * g' x\u2225 \u2264 C * \u2225g x\u2225,\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_\u2112p.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 \u03bc) (hg' : continuous_on g' K) (hK : is_compact K) :\n  integrable_on (\u03bb x, g x * g' x) K \u03bc :=\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 \u03bc)\n  (hK : is_compact K) (hA : measurable_set A) (hAK : A \u2286 K) :\n  integrable_on (\u03bb x, g x * g' x) A \u03bc :=\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 \u03bc) (hK : is_compact K) :\n  integrable_on (\u03bb x, g x * g' x) K \u03bc :=\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 `\ud835\udcdd[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 : \u2200 x \u2208 K, integrable_at_filter f (\ud835\udcdd[K] x) \u03bc) : integrable_on f K \u03bc :=\nis_compact.induction_on hK integrable_on_empty (\u03bb s t hst ht, ht.mono_set hst)\n  (\u03bb s t hs ht, hs.union ht) hf\n\nsection borel\n\nvariables [opens_measurable_space X] [metrizable_space X] [is_locally_finite_measure \u03bc]\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 \u03bc :=\nbegin\n  letI := metrizable_space_metric X,\n  apply hK.integrable_on_of_nhds_within (\u03bb 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 \u03bc :=\n\u03bb 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) \u03bc :=\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) \u03bc :=\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) \u03bc :=\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] \u03bc :=\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] \u03bc :=\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 (\u0399 a b) \u03bc :=\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 \u03bc :=\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 \u03bc] {s : set X}\n\nlemma monotone_on.integrable_on_compact (hs : is_compact s) (hmono : monotone_on f s) :\n  integrable_on f s \u03bc :=\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    \u27e8f (Inf s), \u03bb x \u27e8y, hy, hyx\u27e9, hyx \u25b8 hmono (hs.Inf_mem h) hy (cInf_le hs.bdd_below hy)\u27e9,\n  have habove : bdd_above (f '' s) :=\n    \u27e8f (Sup s), \u03bb x \u27e8y, hy, hyx\u27e9, hyx \u25b8 hmono hy (hs.Sup_mem h) (le_cSup hs.bdd_above hy)\u27e9,\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 \u27e8C, hC\u27e9,\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      \u03bb 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 \u03bc :=\n@monotone_on.integrable_on_compact X (order_dual E) _ _ _ _ _ _ _ _ _ _ _ _ _ _ hs hanti\n\nlemma monotone.locally_integrable (hmono : monotone f) : locally_integrable f \u03bc :=\n\u03bb s hs, monotone_on.integrable_on_compact hs (\u03bb x y _ _ hxy, hmono hxy)\n\nlemma antitone.locally_integrable (hanti : antitone f) : locally_integrable f \u03bc :=\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 \u2264 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 : \u2115) : (n : R) \u2208 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 := \u27e8_, one_mem s\u27e9\n    natCast := fun n => \u27e8n, natCast_mem s n\u27e9\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 \u2286 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 : \u2115) : (n : R) \u2208 s := by\n  rw [\u2190 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 (\u2191) 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 \u2192+* R :=\n  { SubmonoidClass.Subtype s, AddSubmonoidClass.Subtype s with toFun := (\u2191) }\n#align subsemiring_class.subtype SubsemiringClass.subtype\n\n@[simp]\ntheorem coe_subtype : (subtype s : s \u2192 R) = ((\u2191) : s \u2192 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 (\u2191) 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 : \u2115) :\n    ((x ^ n : s) : R) = (x : R) ^ n := by\n  induction' n with n ih\n  \u00b7 simp\n  \u00b7 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 \u2208 s.toSubmonoid \u2194 x \u2208 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 \u2208 s.carrier \u2194 x \u2208 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 : \u2200 x, x \u2208 S \u2194 x \u2208 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 = \u2191S) : 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 = \u2191S) : (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 = \u2191S) : 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 \u2192 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 \u2192 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 \u2192 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 \u2192 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 \u2192 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 \u2192 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 \u2208 s \u2194 x \u2208 sm \u2194 x \u2208 sa`. -/\nprotected def mk' (s : Set R) (sm : Submonoid R) (hm : \u2191sm = s) (sa : AddSubmonoid R)\n    (ha : \u2191sa = s) : Subsemiring R where\n  carrier := s\n  zero_mem' := by exact ha \u25b8 sa.zero_mem\n  one_mem' := by exact hm \u25b8 sm.one_mem\n  add_mem' {x y} := by simpa only [\u2190 ha] using sa.add_mem\n  mul_mem' {x y} := by simpa only [\u2190 hm] using sm.mul_mem\n#align subsemiring.mk' Subsemiring.mk'\n\n@[simp]\ntheorem coe_mk' {s : Set R} {sm : Submonoid R} (hm : \u2191sm = s) {sa : AddSubmonoid R} (ha : \u2191sa = 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 : \u2191sm = s) {sa : AddSubmonoid R} (ha : \u2191sa = s)\n    {x : R} : x \u2208 Subsemiring.mk' s sm hm sa ha \u2194 x \u2208 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 : \u2191sm = s) {sa : AddSubmonoid R}\n    (ha : \u2191sa = 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 : \u2191sm = s) {sa : AddSubmonoid R}\n    (ha : \u2191sa = 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) \u2208 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) \u2208 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 \u2208 s \u2192 y \u2208 s \u2192 x * y \u2208 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 \u2208 s \u2192 y \u2208 s \u2192 x + y \u2208 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    (\u2200 x \u2208 l, x \u2208 s) \u2192 l.prod \u2208 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} : (\u2200 x \u2208 l, x \u2208 s) \u2192 l.sum \u2208 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    (\u2200 a \u2208 m, a \u2208 s) \u2192 m.prod \u2208 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) : (\u2200 a \u2208 m, a \u2208 s) \u2192 m.sum \u2208 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) {\u03b9 : Type _}\n    {t : Finset \u03b9} {f : \u03b9 \u2192 R} (h : \u2200 c \u2208 t, f c \u2208 s) : (\u220f i in t, f i) \u2208 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) {\u03b9 : Type _} {t : Finset \u03b9} {f : \u03b9 \u2192 R}\n    (h : \u2200 c \u2208 t, f c \u2208 s) : (\u2211 i in t, f i) \u2208 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 \u2208 s)\n    (n : \u2115) : x ^ n \u2208 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 : \u2115) :\n    ((x ^ n : s) : R) = (x : R) ^ n := by\n  induction' n with n ih\n  \u00b7 simp\n  \u00b7 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 \u2192+* R :=\n  { s.toSubmonoid.subtype, s.toAddSubmonoid.subtype with toFun := (\u2191) }\n#align subsemiring.subtype Subsemiring.subtype\n\n@[simp]\ntheorem coe_subtype : \u21d1s.subtype = ((\u2191) : s \u2192 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 (\u2191) 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 \u2208 s) (n : \u2115) : n \u2022 x \u2208 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 \u2208 s.toAddSubmonoid \u2194 x \u2208 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  \u27e8{ (\u22a4 : Submonoid R), (\u22a4 : AddSubmonoid R) with }\u27e9\n\n@[simp]\ntheorem mem_top (x : R) : x \u2208 (\u22a4 : Subsemiring R) :=\n  Set.mem_univ x\n#align subsemiring.mem_top Subsemiring.mem_top\n\n@[simp]\ntheorem coe_top : ((\u22a4 : 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 : (\u22a4 : Subsemiring R) \u2243+* R where\n  toFun r := r\n  invFun r := \u27e8r, Subsemiring.mem_top r\u27e9\n  left_inv _ := rfl\n  right_inv _ := rfl\n  map_mul' := (\u22a4 : Subsemiring R).coe_mul\n  map_add' := (\u22a4 : 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 \u2192+* S) (s : Subsemiring S) : Subsemiring R :=\n  { s.toSubmonoid.comap (f : R \u2192* S), s.toAddSubmonoid.comap (f : R \u2192+ S) with carrier := f \u207b\u00b9' s }\n#align subsemiring.comap Subsemiring.comap\n\n@[simp]\ntheorem coe_comap (s : Subsemiring S) (f : R \u2192+* S) : (s.comap f : Set R) = f \u207b\u00b9' s :=\n  rfl\n#align subsemiring.coe_comap Subsemiring.coe_comap\n\n@[simp]\ntheorem mem_comap {s : Subsemiring S} {f : R \u2192+* S} {x : R} : x \u2208 s.comap f \u2194 f x \u2208 s :=\n  Iff.rfl\n#align subsemiring.mem_comap Subsemiring.mem_comap\n\ntheorem comap_comap (s : Subsemiring T) (g : S \u2192+* T) (f : R \u2192+* 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 \u2192+* S) (s : Subsemiring R) : Subsemiring S :=\n  { s.toSubmonoid.map (f : R \u2192* S), s.toAddSubmonoid.map (f : R \u2192+ S) with carrier := f '' s }\n#align subsemiring.map Subsemiring.map\n\n@[simp]\ntheorem coe_map (f : R \u2192+* 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 \u2192+* S} {s : Subsemiring R} {y : S} : y \u2208 s.map f \u2194 \u2203 x \u2208 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 \u2192+* T) (f : R \u2192+* 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 \u2192+* S} {s : Subsemiring R} {t : Subsemiring S} :\n    s.map f \u2264 t \u2194 s \u2264 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 \u2192+* 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 \u2192+* S) (hf : Function.Injective f) : s \u2243+* 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 \u2192+* 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 \u2192+* T) (f : R \u2192+* S)\n\n/-- The range of a ring homomorphism is a subsemiring. See Note [range copy pattern]. -/\ndef rangeS : Subsemiring S :=\n  ((\u22a4 : 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 \u2192+* S} {y : S} : y \u2208 f.rangeS \u2194 \u2203 x, f x = y :=\n  Iff.rfl\n#align ring_hom.mem_srange RingHom.mem_rangeS\n\ntheorem rangeS_eq_map (f : R \u2192+* S) : f.rangeS = (\u22a4 : 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 \u2192+* S) (x : R) : f x \u2208 f.rangeS :=\n  mem_rangeS.mpr \u27e8x, rfl\u27e9\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 (\u22a4 : 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 \u2192+* 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  \u27e8(Nat.castRingHom R).rangeS\u27e9\n\ninstance : Inhabited (Subsemiring R) :=\n  \u27e8\u22a5\u27e9\n\ntheorem coe_bot : ((\u22a5 : Subsemiring R) : Set R) = Set.range ((\u2191) : \u2115 \u2192 R) :=\n  (Nat.castRingHom R).coe_rangeS\n#align subsemiring.coe_bot Subsemiring.coe_bot\n\ntheorem mem_bot {x : R} : x \u2208 (\u22a5 : Subsemiring R) \u2194 \u2203 n : \u2115, \u2191n = 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  \u27e8fun s t =>\n    { s.toSubmonoid \u2293 t.toSubmonoid, s.toAddSubmonoid \u2293 t.toAddSubmonoid with carrier := s \u2229 t }\u27e9\n\n@[simp]\ntheorem coe_inf (p p' : Subsemiring R) : ((p \u2293 p' : Subsemiring R) : Set R) = (p : Set R) \u2229 p' :=\n  rfl\n#align subsemiring.coe_inf Subsemiring.coe_inf\n\n@[simp]\ntheorem mem_inf {p p' : Subsemiring R} {x : R} : x \u2208 p \u2293 p' \u2194 x \u2208 p \u2227 x \u2208 p' :=\n  Iff.rfl\n#align subsemiring.mem_inf Subsemiring.mem_inf\n\ninstance : InfSet (Subsemiring R) :=\n  \u27e8fun s =>\n    Subsemiring.mk' (\u22c2 t \u2208 s, \u2191t) (\u2a05 t \u2208 s, Subsemiring.toSubmonoid t) (by simp)\n      (\u2a05 t \u2208 s, Subsemiring.toAddSubmonoid t)\n      (by simp)\u27e9\n\n@[simp, norm_cast]\ntheorem coe_inf\u209b (S : Set (Subsemiring R)) : ((inf\u209b S : Subsemiring R) : Set R) = \u22c2 s \u2208 S, \u2191s :=\n  rfl\n#align subsemiring.coe_Inf Subsemiring.coe_inf\u209b\n\ntheorem mem_inf\u209b {S : Set (Subsemiring R)} {x : R} : x \u2208 inf\u209b S \u2194 \u2200 p \u2208 S, x \u2208 p :=\n  Set.mem_inter\u1d62\u2082\n#align subsemiring.mem_Inf Subsemiring.mem_inf\u209b\n\n@[simp]\ntheorem inf\u209b_toSubmonoid (s : Set (Subsemiring R)) :\n    (inf\u209b s).toSubmonoid = \u2a05 t \u2208 s, Subsemiring.toSubmonoid t :=\n  mk'_toSubmonoid _ _\n#align subsemiring.Inf_to_submonoid Subsemiring.inf\u209b_toSubmonoid\n\n@[simp]\ntheorem inf\u209b_toAddSubmonoid (s : Set (Subsemiring R)) :\n    (inf\u209b s).toAddSubmonoid = \u2a05 t \u2208 s, Subsemiring.toAddSubmonoid t :=\n  mk'_toAddSubmonoid _ _\n#align subsemiring.Inf_to_add_submonoid Subsemiring.inf\u209b_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) \u2286 t \u2194 s \u2264 t from SetLike.coe_subset_coe)\n        isGLB_binf\u1d62 with\n    bot := \u22a5\n    bot_le := fun s _ hx =>\n      let \u27e8n, hn\u27e9 := mem_bot.1 hx\n      hn \u25b8 coe_nat_mem s n\n    top := \u22a4\n    le_top := fun _ _ _ => trivial\n    inf := (\u00b7 \u2293 \u00b7)\n    inf_le_left := fun _ _ _ => And.left\n    inf_le_right := fun _ _ _ => And.right\n    le_inf := fun _ _ _ h\u2081 h\u2082 _ hx => \u27e8h\u2081 hx, h\u2082 hx\u27e9 }\n\ntheorem eq_top_iff' (A : Subsemiring R) : A = \u22a4 \u2194 \u2200 x : R, x \u2208 A :=\n  eq_top_iff.trans \u27e8fun h m => h <| mem_top m, fun h m _ => h m\u27e9\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] : \u2191(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 \u2208 center R \u2194 \u2200 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 (\u00b7 \u2208 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 = \u22a4 :=\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 \u2208 centralizer s \u2194 \u2200 g \u2208 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 \u2286 t) : centralizer t \u2264 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\u209b { S | s \u2286 S }\n#align subsemiring.closure Subsemiring.closure\n\ntheorem mem_closure {x : R} {s : Set R} : x \u2208 closure s \u2194 \u2200 S : Subsemiring R, s \u2286 S \u2192 x \u2208 S :=\n  mem_inf\u209b\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 \u2286 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 \u2209 closure s) : P \u2209 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 \u2264 t \u2194 s \u2286 t :=\n  \u27e8Set.Subset.trans subset_closure, fun h => inf\u209b_le h\u27e9\n#align subsemiring.closure_le Subsemiring.closure_le\n\n/-- Subsemiring closure of a set is monotone in its argument: if `s \u2286 t`,\nthen `closure s \u2264 closure t`. -/\ntheorem closure_mono \u2983s t : Set R\u2984 (h : s \u2286 t) : closure s \u2264 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\u2081 : s \u2286 t) (h\u2082 : t \u2264 closure s) :\n    closure s = t :=\n  le_antisymm (closure_le.2 h\u2081) h\u2082\n#align subsemiring.closure_eq_of_le Subsemiring.closure_eq_of_le\n\ntheorem mem_map_equiv {f : R \u2243+* S} {K : Subsemiring R} {x : S} :\n    x \u2208 K.map (f : R \u2192+* S) \u2194 f.symm x \u2208 K := by\n  convert @Set.mem_image_equiv _ _ (\u2191K) f.toEquiv x using 1\n#align subsemiring.mem_map_equiv Subsemiring.mem_map_equiv\n\ntheorem map_equiv_eq_comap_symm (f : R \u2243+* S) (K : Subsemiring R) :\n    K.map (f : R \u2192+* 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 \u2243+* S) (K : Subsemiring S) :\n    K.comap (f : R \u2192+* 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    \u27e8fun hx => _, fun hx =>\n      (Subsemiring.mem_closure.mp hx) M.subsemiringClosure fun s sM => _\u27e9\n  <;> rintro - \u27e8H1, rfl\u27e9\n  <;> rintro - \u27e8H2, rfl\u27e9\n  \u00b7 exact AddSubmonoid.mem_closure.mp hx H1.toAddSubmonoid H2\n  \u00b7 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 \u2191(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 [\u2190 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 \u2208 closure s \u2194 x \u2208 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 \u2191(AddSubmonoid.closure s) = closure s :=\n  by\n  ext x\n  refine' \u27e8fun hx => _, fun hx => closure_mono AddSubmonoid.subset_closure hx\u27e9\n  rintro - \u27e8H, rfl\u27e9\n  rintro - \u27e8J, rfl\u27e9\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 \u2192 Prop} {x} (h : x \u2208 closure s) (Hs : \u2200 x \u2208 s, p x)\n    (H0 : p 0) (H1 : p 1) (Hadd : \u2200 x y, p x \u2192 p y \u2192 p (x + y))\n    (Hmul : \u2200 x y, p x \u2192 p y \u2192 p (x * y)) : p x :=\n  (@closure_le _ _ _ \u27e8\u27e8\u27e8p, @Hmul\u27e9, H1\u27e9, @Hadd, H0\u27e9).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\u2082 {s : Set R} {p : R \u2192 R \u2192 Prop} {x} {y : R} (hx : x \u2208 closure s)\n    (hy : y \u2208 closure s) (Hs : \u2200 x \u2208 s, \u2200 y \u2208 s, p x y) (H0_left : \u2200 x, p 0 x)\n    (H0_right : \u2200 x, p x 0) (H1_left : \u2200 x, p 1 x) (H1_right : \u2200 x, p x 1)\n    (Hadd_left : \u2200 x\u2081 x\u2082 y, p x\u2081 y \u2192 p x\u2082 y \u2192 p (x\u2081 + x\u2082) y)\n    (Hadd_right : \u2200 x y\u2081 y\u2082, p x y\u2081 \u2192 p x y\u2082 \u2192 p x (y\u2081 + y\u2082))\n    (Hmul_left : \u2200 x\u2081 x\u2082 y, p x\u2081 y \u2192 p x\u2082 y \u2192 p (x\u2081 * x\u2082) y)\n    (Hmul_right : \u2200 x y\u2081 y\u2082, p x y\u2081 \u2192 p x y\u2082 \u2192 p x (y\u2081 * y\u2082)) : p x y :=\n  closure_induction hx\n    (fun x\u2081 x\u2081s =>\n      closure_induction hy (Hs x\u2081 x\u2081s) (H0_right x\u2081) (H1_right x\u2081) (Hadd_right x\u2081) (Hmul_right x\u2081))\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\u2082 Subsemiring.closure_induction\u2082\n\ntheorem mem_closure_iff_exists_list {R} [Semiring R] {s : Set R} {x} :\n    x \u2208 closure s \u2194 \u2203 L : List (List R), (\u2200 t \u2208 L, \u2200 y \u2208 t, y \u2208 s) \u2227 (L.map List.prod).sum = x := by\n  constructor\n  \u00b7 intro hx\n    -- Porting note: needed explicit `p`\n    let p : R \u2192 Prop := fun x =>\n      \u2203 (L : List (List R)),\n        (\u2200 (t : List R), t \u2208 L \u2192 \u2200 (y : R), y \u2208 t \u2192 y \u2208 s) \u2227 (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 \u2203 t : List R, (\u2200 y \u2208 t, y \u2208 s) \u2227 t.prod = x from\n          let \u27e8t, ht1, ht2\u27e9 := this\n          \u27e8[t], List.forall_mem_singleton.2 ht1, by\n            rw [List.map_singleton, List.sum_singleton, ht2]\u27e9\n        Submonoid.closure_induction hx\n          (fun x hx => \u27e8[x], List.forall_mem_singleton.2 hx, one_mul x\u27e9)\n          \u27e8[], List.forall_mem_nil _, rfl\u27e9 fun x y \u27e8t, ht1, ht2\u27e9 \u27e8u, hu1, hu2\u27e9 =>\n          \u27e8t ++ u, List.forall_mem_append.2 \u27e8ht1, hu1\u27e9, by rw [List.prod_append, ht2, hu2]\u27e9)\n      \u27e8[], List.forall_mem_nil _, rfl\u27e9 fun x y \u27e8L, HL1, HL2\u27e9 \u27e8M, HM1, HM2\u27e9 =>\n      \u27e8L ++ M, List.forall_mem_append.2 \u27e8HL1, HM1\u27e9, by\n        rw [List.map_append, List.sum_append, HL2, HM2]\u27e9\n  \u00b7 rintro \u27e8L, HL1, HL2\u27e9\n    exact HL2 \u25b8\n      list_sum_mem fun r hr =>\n        let \u27e8t, ht1, ht2\u27e9 := List.mem_map.1 hr\n        ht2 \u25b8 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 _) (\u2191)\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 (\u2205 : Set R) = \u22a5 :=\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) = \u22a4 :=\n  @coe_top R _ \u25b8 closure_eq \u22a4\n#align subsemiring.closure_univ Subsemiring.closure_univ\n\ntheorem closure_union (s t : Set R) : closure (s \u222a t) = closure s \u2294 closure t :=\n  (Subsemiring.gi R).gc.l_sup\n#align subsemiring.closure_union Subsemiring.closure_union\n\ntheorem closure_union\u1d62 {\u03b9} (s : \u03b9 \u2192 Set R) : closure (\u22c3 i, s i) = \u2a06 i, closure (s i) :=\n  (Subsemiring.gi R).gc.l_sup\u1d62\n#align subsemiring.closure_Union Subsemiring.closure_union\u1d62\n\ntheorem closure_union\u209b (s : Set (Set R)) : closure (\u22c3\u2080 s) = \u2a06 t \u2208 s, closure t :=\n  (Subsemiring.gi R).gc.l_sup\u209b\n#align subsemiring.closure_sUnion Subsemiring.closure_union\u209b\n\ntheorem map_sup (s t : Subsemiring R) (f : R \u2192+* S) : (s \u2294 t).map f = s.map f \u2294 t.map f :=\n  (gc_map_comap f).l_sup\n#align subsemiring.map_sup Subsemiring.map_sup\n\ntheorem map_sup\u1d62 {\u03b9 : Sort _} (f : R \u2192+* S) (s : \u03b9 \u2192 Subsemiring R) :\n    (sup\u1d62 s).map f = \u2a06 i, (s i).map f :=\n  (gc_map_comap f).l_sup\u1d62\n#align subsemiring.map_supr Subsemiring.map_sup\u1d62\n\ntheorem comap_inf (s t : Subsemiring S) (f : R \u2192+* S) : (s \u2293 t).comap f = s.comap f \u2293 t.comap f :=\n  (gc_map_comap f).u_inf\n#align subsemiring.comap_inf Subsemiring.comap_inf\n\ntheorem comap_inf\u1d62 {\u03b9 : Sort _} (f : R \u2192+* S) (s : \u03b9 \u2192 Subsemiring S) :\n    (inf\u1d62 s).comap f = \u2a05 i, (s i).comap f :=\n  (gc_map_comap f).u_inf\u1d62\n#align subsemiring.comap_infi Subsemiring.comap_inf\u1d62\n\n@[simp]\ntheorem map_bot (f : R \u2192+* S) : (\u22a5 : Subsemiring R).map f = \u22a5 :=\n  (gc_map_comap f).l_bot\n#align subsemiring.map_bot Subsemiring.map_bot\n\n@[simp]\ntheorem comap_top (f : R \u2192+* S) : (\u22a4 : Subsemiring S).comap f = \u22a4 :=\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 \u00d7 t`\nas a subsemiring of `R \u00d7 S`. -/\ndef prod (s : Subsemiring R) (t : Subsemiring S) : Subsemiring (R \u00d7 S) :=\n  { s.toSubmonoid.prod t.toSubmonoid, s.toAddSubmonoid.prod t.toAddSubmonoid with\n    carrier := s \u00d7\u02e2 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 \u00d7 S)) = s \u00d7\u02e2 t :=\n  rfl\n#align subsemiring.coe_prod Subsemiring.coe_prod\n\ntheorem mem_prod {s : Subsemiring R} {t : Subsemiring S} {p : R \u00d7 S} :\n    p \u2208 s.prod t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t :=\n  Iff.rfl\n#align subsemiring.mem_prod Subsemiring.mem_prod\n\n@[mono]\ntheorem prod_mono \u2983s\u2081 s\u2082 : Subsemiring R\u2984 (hs : s\u2081 \u2264 s\u2082) \u2983t\u2081 t\u2082 : Subsemiring S\u2984 (ht : t\u2081 \u2264 t\u2082) :\n    s\u2081.prod t\u2081 \u2264 s\u2082.prod t\u2082 :=\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 (\u22a4 : 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) : (\u22a4 : 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 : (\u22a4 : Subsemiring R).prod (\u22a4 : Subsemiring S) = \u22a4 :=\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 \u2243+* s \u00d7 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\u1d62_of_directed {\u03b9} [h\u03b9 : Nonempty \u03b9] {S : \u03b9 \u2192 Subsemiring R} (hS : Directed (\u00b7 \u2264 \u00b7) S)\n    {x : R} : (x \u2208 \u2a06 i, S i) \u2194 \u2203 i, x \u2208 S i := by\n  refine' \u27e8_, fun \u27e8i, hi\u27e9 => (SetLike.le_def.1 <| le_sup\u1d62 S i) hi\u27e9\n  let U : Subsemiring R :=\n    Subsemiring.mk' (\u22c3 i, (S i : Set R)) (\u2a06 i, (S i).toSubmonoid)\n      (Submonoid.coe_sup\u1d62_of_directed <| hS.mono_comp _ fun _ _ => id) (\u2a06 i, (S i).toAddSubmonoid)\n      (AddSubmonoid.coe_sup\u1d62_of_directed <| hS.mono_comp _ fun _ _ => id)\n  -- Porting note: gave the hypothesis an explicit name because `@this` doesn't work\n  suffices h : (\u2a06 i, S i) \u2264 U by simpa using @h x\n  exact sup\u1d62_le fun i x hx => Set.mem_union\u1d62.2 \u27e8i, hx\u27e9\n#align subsemiring.mem_supr_of_directed Subsemiring.mem_sup\u1d62_of_directed\n\ntheorem coe_sup\u1d62_of_directed {\u03b9} [h\u03b9 : Nonempty \u03b9] {S : \u03b9 \u2192 Subsemiring R}\n    (hS : Directed (\u00b7 \u2264 \u00b7) S) : ((\u2a06 i, S i : Subsemiring R) : Set R) = \u22c3 i, \u2191(S i) :=\n  Set.ext fun x => by simp [mem_sup\u1d62_of_directed hS]\n#align subsemiring.coe_supr_of_directed Subsemiring.coe_sup\u1d62_of_directed\n\ntheorem mem_sup\u209b_of_directedOn {S : Set (Subsemiring R)} (Sne : S.Nonempty)\n    (hS : DirectedOn (\u00b7 \u2264 \u00b7) S) {x : R} : x \u2208 sup\u209b S \u2194 \u2203 s \u2208 S, x \u2208 s := by\n  haveI : Nonempty S := Sne.to_subtype\n  simp only [sup\u209b_eq_sup\u1d62', mem_sup\u1d62_of_directed hS.directed_val, SetCoe.exists, Subtype.coe_mk,\n    exists_prop]\n#align subsemiring.mem_Sup_of_directed_on Subsemiring.mem_sup\u209b_of_directedOn\n\ntheorem coe_sup\u209b_of_directedOn {S : Set (Subsemiring R)} (Sne : S.Nonempty)\n    (hS : DirectedOn (\u00b7 \u2264 \u00b7) S) : (\u2191(sup\u209b S) : Set R) = \u22c3 s \u2208 S, \u2191s :=\n  Set.ext fun x => by simp [mem_sup\u209b_of_directedOn Sne hS]\n#align subsemiring.coe_Sup_of_directed_on Subsemiring.coe_sup\u209b_of_directedOn\n\nend Subsemiring\n\nnamespace RingHom\n\nvariable [NonAssocSemiring T] {s : Subsemiring R}\n\nvariable {\u03c3R \u03c3S : Type _}\n\nvariable [SetLike \u03c3R R] [SetLike \u03c3S S] [SubsemiringClass \u03c3R R] [SubsemiringClass \u03c3S S]\n\nopen Subsemiring\n\n/-- Restriction of a ring homomorphism to a subsemiring of the domain. -/\ndef domRestrict (f : R \u2192+* S) (s : \u03c3R) : s \u2192+* S :=\n  f.comp <| SubsemiringClass.subtype s\n#align ring_hom.dom_restrict RingHom.domRestrict\n\n@[simp]\ntheorem restrict_apply (f : R \u2192+* S) {s : \u03c3R} (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 \u2192+* S) (s : \u03c3S) (h : \u2200 x, f x \u2208 s) : R \u2192+* s :=\n  { (f : R \u2192* S).codRestrict s h, (f : R \u2192+ S).codRestrict s h with toFun := fun n => \u27e8f n, h n\u27e9 }\n#align ring_hom.cod_restrict RingHom.codRestrict\n\n/-- The ring homomorphism from the preimage of `s` to `s`. -/\ndef restrict (f : R \u2192+* S) (s' : \u03c3R) (s : \u03c3S) (h : \u2200 x \u2208 s', f x \u2208 s) : s' \u2192+* 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 \u2192+* S) (s' : \u03c3R) (s : \u03c3S) (h : \u2200 x \u2208 s', f x \u2208 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 \u2192+* S) (s' : \u03c3R) (s : \u03c3S) (h : \u2200 x \u2208 s', f x \u2208 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 \u2192+* S) : R \u2192+* f.rangeS :=\n  f.codRestrict (R := R) (S := S) (\u03c3S := Subsemiring S) f.rangeS f.mem_rangeS_self\n#align ring_hom.srange_restrict RingHom.rangeSRestrict\n\n@[simp]\ntheorem coe_rangeSRestrict (f : R \u2192+* 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 \u2192+* S) : Function.Surjective f.rangeSRestrict :=\n  fun \u27e8_, hy\u27e9 =>\n  let \u27e8x, hx\u27e9 := mem_rangeS.mp hy\n  \u27e8x, Subtype.ext hx\u27e9\n#align ring_hom.srange_restrict_surjective RingHom.rangeSRestrict_surjective\n\ntheorem rangeS_top_iff_surjective {f : R \u2192+* S} :\n    f.rangeS = (\u22a4 : Subsemiring S) \u2194 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 \u2192+* S) (hf : Function.Surjective f) :\n    f.rangeS = (\u22a4 : 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 \u2192+* S) : Subsemiring R :=\n  { (f : R \u2192* S).eqLocusM g, (f : R \u2192+ 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 \u2192+* S) : f.eqLocusS f = \u22a4 :=\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 \u2192+* S} (h : Set.EqOn f g (\u22a4 : 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 = \u22a4) {f g : R \u2192+* S} (h : s.EqOn f g) :\n    f = g :=\n  eq_of_eqOn_stop <| hs \u25b8 eqOn_sclosure h\n#align ring_hom.eq_of_eq_on_sdense RingHom.eq_of_eqOn_sdense\n\ntheorem sclosure_preimage_le (f : R \u2192+* S) (s : Set S) : closure (f \u207b\u00b9' s) \u2264 (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 \u2192+* 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 \u2264 T) : S \u2192+* 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 = \u22a4 :=\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 = \u22a4 :=\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 \u22a5 \u2294 prod \u22a5 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 \u25b8\n      mul_mem\n        ((le_sup_left : s.prod \u22a5 \u2264 s.prod \u22a5 \u2294 prod \u22a5 t) \u27e8hp.1, SetLike.mem_coe.2 <| one_mem \u22a5\u27e9)\n        ((le_sup_right : prod \u22a5 t \u2264 s.prod \u22a5 \u2294 prod \u22a5 t) \u27e8SetLike.mem_coe.2 <| one_mem \u22a5, hp.2\u27e9)\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 \u2243+* 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 \u2192 R} {f : R \u2192+* S} (h : Function.LeftInverse g f) : R \u2243+* f.rangeS :=\n  { f.rangeSRestrict with\n    toFun := fun x => f.rangeSRestrict x\n    invFun := fun x => (g \u2218 f.rangeS.subtype) x\n    left_inv := h\n    right_inv := fun x =>\n      Subtype.ext <|\n        let \u27e8x', hx'\u27e9 := RingHom.mem_rangeS.mp x.prop\n        show f (g x) = x by rw [\u2190 hx', h x'] }\n#align ring_equiv.sof_left_inverse RingEquiv.ofLeftInverseS\n\n@[simp]\ntheorem ofLeftInverseS_apply {g : S \u2192 R} {f : R \u2192+* S} (h : Function.LeftInverse g f) (x : R) :\n    \u2191(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 \u2192 R} {f : R \u2192+* 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 \u2243+* 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 \u2243+* S) (s : Subsemiring R) : s \u2243+* 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' \u03b1 \u03b2 : 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' \u03b1] (S : Subsemiring R') : SMul S \u03b1 :=\n  S.toSubmonoid.smul\n\ntheorem smul_def [SMul R' \u03b1] {S : Subsemiring R'} (g : S) (m : \u03b1) : g \u2022 m = (g : R') \u2022 m :=\n  rfl\n#align subsemiring.smul_def Subsemiring.smul_def\n\ninstance smulCommClass_left [SMul R' \u03b2] [SMul \u03b1 \u03b2] [SMulCommClass R' \u03b1 \u03b2] (S : Subsemiring R') :\n    SMulCommClass S \u03b1 \u03b2 :=\n  S.toSubmonoid.smulCommClass_left\n#align subsemiring.smul_comm_class_left Subsemiring.smulCommClass_left\n\ninstance smulCommClass_right [SMul \u03b1 \u03b2] [SMul R' \u03b2] [SMulCommClass \u03b1 R' \u03b2] (S : Subsemiring R') :\n    SMulCommClass \u03b1 S \u03b2 :=\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 \u03b1 \u03b2] [SMul R' \u03b1] [SMul R' \u03b2] [IsScalarTower R' \u03b1 \u03b2]\n    (S : Subsemiring R') :\n    IsScalarTower S \u03b1 \u03b2 :=\n  S.toSubmonoid.isScalarTower\n\ninstance faithfulSMul [SMul R' \u03b1] [FaithfulSMul R' \u03b1] (S : Subsemiring R') : FaithfulSMul S \u03b1 :=\n  S.toSubmonoid.faithfulSMul\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Zero \u03b1] [SMulWithZero R' \u03b1] (S : Subsemiring R') : SMulWithZero S \u03b1 :=\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' \u03b1] (S : Subsemiring R') : MulAction S \u03b1 :=\n  S.toSubmonoid.mulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance distribMulAction [AddMonoid \u03b1] [DistribMulAction R' \u03b1] (S : Subsemiring R') :\n    DistribMulAction S \u03b1 :=\n  S.toSubmonoid.distribMulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance mulDistribMulAction [Monoid \u03b1] [MulDistribMulAction R' \u03b1] (S : Subsemiring R') :\n    MulDistribMulAction S \u03b1 :=\n  S.toSubmonoid.mulDistribMulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance mulActionWithZero [Zero \u03b1] [MulActionWithZero R' \u03b1] (S : Subsemiring R') :\n    MulActionWithZero S \u03b1 :=\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 \u03b1] [Module R' \u03b1] (S : Subsemiring R') : Module S \u03b1 :=\n  -- Porting note: copying over the `smul` field causes a timeout\n  -- { Module.compHom _ S.subtype with smul := (\u00b7 \u2022 \u00b7) }\n  Module.compHom _ S.subtype\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Semiring \u03b1] [MulSemiringAction R' \u03b1] (S : Subsemiring R') : MulSemiringAction S \u03b1 :=\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 : \u2200 a \u2208 s, \u2200 b \u2208 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\u2082 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\u2081 h\u2082 => by simp only [add_mul, mul_add, h\u2081, h\u2082])\n          (fun x y z h\u2081 h\u2082 => by simp only [add_mul, mul_add, h\u2081, h\u2082])\n          (fun x y z h\u2081 h\u2082 => by rw [mul_assoc, h\u2082, \u2190 mul_assoc, h\u2081, mul_assoc]) fun x y z h\u2081 h\u2082 =>\n          by rw [\u2190 mul_assoc, h\u2081, mul_assoc, h\u2082, \u2190 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\u02e3) :\n    \u2191u \u2208 posSubmonoid R \u2194 (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\u2080 [ContinuousMul K] {a : K} (ha : a \u2260 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\u2080 Filter.tendsto_cocompact_mul_left\u2080\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\u2080 [ContinuousMul K] {a : K} (ha : a \u2260 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\u2080 Filter.tendsto_cocompact_mul_right\u2080\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\u2080 K : Prop\n#align topological_division_ring TopologicalDivisionRing\n\nsection Subfield\n\nvariable {\u03b1 : Type _} [Field \u03b1] [TopologicalSpace \u03b1] [TopologicalDivisionRing \u03b1]\n\n/-- The (topological-space) closure of a subfield of a topological field is\nitself a subfield. -/\ndef Subfield.topologicalClosure (K : Subfield \u03b1) : Subfield \u03b1 :=\n  { K.toSubring.topologicalClosure with\n    carrier := _root_.closure (K : Set \u03b1)\n    inv_mem' := fun x hx => by\n      dsimp only at hx \u22a2\n      rcases eq_or_ne x 0 with (rfl | h)\n      \u00b7 rwa [inv_zero]\n      \u00b7 -- porting note: todo: Lean fails to find InvMemClass instance\n        rw [\u2190 @inv_coe_set \u03b1 (Subfield \u03b1) _ _ SubfieldClass.toInvMemClass K, \u2190 Set.image_inv]\n        exact mem_closure_image (continuousAt_inv\u2080 h) hx }\n#align subfield.topological_closure Subfield.topologicalClosure\n\ntheorem Subfield.le_topologicalClosure (s : Subfield \u03b1) : s \u2264 s.topologicalClosure :=\n  _root_.subset_closure\n#align subfield.le_topological_closure Subfield.le_topologicalClosure\n\ntheorem Subfield.isClosed_topologicalClosure (s : Subfield \u03b1) :\n    IsClosed (s.topologicalClosure : Set \u03b1) :=\n  isClosed_closure\n#align subfield.is_closed_topological_closure Subfield.isClosed_topologicalClosure\n\ntheorem Subfield.topologicalClosure_minimal (s : Subfield \u03b1) {t : Subfield \u03b1} (h : s \u2264 t)\n    (ht : IsClosed (t : Set \u03b1)) : s.topologicalClosure \u2264 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 `\ud835\udd5c` to itself.\nTechnically it does not require `\ud835\udd5c` to be a topological field, a topological ring that\nhappens to be a field is enough.\n-/\n\n\nvariable {\ud835\udd5c : Type _} [Field \ud835\udd5c] [TopologicalSpace \ud835\udd5c] [TopologicalRing \ud835\udd5c]\n\n/--\nThe map `fun x => a * x + b`, as a homeomorphism from `\ud835\udd5c` (a topological field) to itself,\nwhen `a \u2260 0`.\n-/\n@[simps]\ndef affineHomeomorph (a b : \ud835\udd5c) (h : a \u2260 0) : \ud835\udd5c \u2243\u209c \ud835\udd5c 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 {\u03b1 \u03b2 : Type _} [TopologicalSpace \u03b1] [LinearOrderedSemifield \u03b2] {a : \u03b1}\n\nopen Topology\n\ntheorem IsLocalMin.inv {f : \u03b1 \u2192 \u03b2} {a : \u03b1} (h1 : IsLocalMin f a) (h2 : \u2200\u1da0 z in \ud835\udcdd a, 0 < f z) :\n    IsLocalMax f\u207b\u00b9 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 {\u03b1 \ud835\udd5c : Type _} {f g : \u03b1 \u2192 \ud835\udd5c} {S : Set \u03b1} [TopologicalSpace \u03b1] [TopologicalSpace \ud835\udd5c]\n  [T1Space \ud835\udd5c]\n\n/-- If `f` is a function `\u03b1 \u2192 \ud835\udd5c` 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 \ud835\udd5c] [NoZeroDivisors \ud835\udd5c]\n    (hS : IsPreconnected S) (hf : ContinuousOn f S) (hsq : EqOn (f ^ 2) 1 S) :\n    EqOn f 1 S \u2228 EqOn f (-1) S := by\n  have : DiscreteTopology ({1, -1} : Set \ud835\udd5c) := discrete_of_t1_of_finite\n  have hmaps : MapsTo f S {1, -1}\n  \u00b7 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 `\u03b1 \u2192 \ud835\udd5c`, both continuous on a preconnected set `S`, with\n`f ^ 2 = g ^ 2` on `S`, and `g z \u2260 0` all `z \u2208 S`, then either `f = g` or `f = -g` on\n`S`. -/\ntheorem IsPreconnected.eq_or_eq_neg_of_sq_eq [Field \ud835\udd5c] [HasContinuousInv\u2080 \ud835\udd5c] [ContinuousMul \ud835\udd5c]\n    (hS : IsPreconnected S) (hf : ContinuousOn f S) (hg : ContinuousOn g S)\n    (hsq : EqOn (f ^ 2) (g ^ 2) S) (hg_ne : \u2200 {x : \u03b1}, x \u2208 S \u2192 g x \u2260 0) :\n    EqOn f g S \u2228 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 `\u03b1 \u2192 \ud835\udd5c`, both continuous on a preconnected set `S`, with\n`f ^ 2 = g ^ 2` on `S`, and `g z \u2260 0` all `z \u2208 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 \ud835\udd5c] [HasContinuousInv\u2080 \ud835\udd5c] [ContinuousMul \ud835\udd5c]\n    (hS : IsPreconnected S) (hf : ContinuousOn f S) (hg : ContinuousOn g S)\n    (hsq : EqOn (f ^ 2) (g ^ 2) S) (hg_ne : \u2200 {x : \u03b1}, x \u2208 S \u2192 g x \u2260 0) {y : \u03b1} (hy : y \u2208 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  \u00b7 exact h hx\n  \u00b7 rw [h _, Pi.neg_apply, neg_eq_iff_add_eq_zero, \u2190 two_mul, mul_eq_zero,\n      iff_false_iff.2 (hg_ne _)] at hy' \u22a2 <;> 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 (\u03ba : \u211d\u22650) : \u211d\u22650 \u2964 \u211d\u22650 :=\n{ obj := \u03bb c, \u03ba * c,\n  map := \u03bb c\u2081 c\u2082 h, hom_of_le $ mul_le_mul' le_rfl (le_of_hom h) }\n\ndef MulRight (\u03ba : \u211d\u22650) : \u211d\u22650 \u2964 \u211d\u22650 :=\n{ obj := \u03bb c, c * \u03ba,\n  map := \u03bb c\u2081 c\u2082 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 : \u211d\u22650) [fact (0 < r)] : system_of_complexes.{u} \u2964 system_of_complexes.{u} :=\n(whiskering_right _ _ _).obj $ (SemiNormedGroup.rescale r).map_homological_complex _\n\nlemma rescale_obj (r c : \u211d\u22650) [fact (0 < r)] (C : system_of_complexes) (i : \u2115) :\n  \u21a5(((rescale r).obj C) c i) = _root_.rescale r (C c i) := rfl\n\nlemma rescale_d (r c : \u211d\u22650) [fact (0 < r)] (C : system_of_complexes) (i j : \u2115)\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 : \u211d\u22650) [fact (0 < r)] : (rescale r).additive :=\n{ map_add' := \u03bb X Y f g, by { ext, refl } } -- a heavy refl\n.\n\n-- can we golf this? speed it up?\ndef to_rescale (r : \u211d\u22650) [fact (0 < r)] : \ud835\udfed system_of_complexes \u27f6 rescale r :=\n{ app := \u03bb C,\n  { app := \u03bb c,\n    { f := \u03bb _, (SemiNormedGroup.to_rescale r).app _,\n      comm' := by { intros, exact ((SemiNormedGroup.to_rescale r).naturality _).symm } },\n    naturality' := by { intros c\u2081 c\u2082 h, ext i : 2, refl } },\n  naturality' := \u03bb C\u2081 C\u2082 f, by { ext, refl } }\n.\n\ndef scale (i j : \u211d\u22650) [fact (0 < i)] [fact (0 < j)] : rescale i \u27f6 rescale j :=\n(whiskering_right _ _ _).map $ nat_trans.map_homological_complex (SemiNormedGroup.scale i j) _\n\nsection exact_and_admissible\n\nvariables {k K : \u211d\u22650} [fact (1 \u2264 k)] {m : \u2115} {c\u2080 : \u211d\u22650}\n\nlemma rescale_is_weak_bounded_exact (r : \u211d\u22650) [hr : fact (0 < r)] (C : system_of_complexes)\n  (hC : C.is_weak_bounded_exact k K m c\u2080) :\n  ((rescale r).obj C).is_weak_bounded_exact k K m c\u2080 :=\nbegin\n  intros c hc i hi x \u03b5 h\u03b5,\n  obtain \u27e8_, _, rfl, rfl, y, hy\u27e9 := hC c hc i hi ((@rescale.of r _).symm x) (\u03b5 * r) _,\n  swap, { exact mul_pos h\u03b5 hr.out },\n  refine \u27e8_, _, rfl, rfl, (@rescale.of r _) y, _\u27e9,\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 : \u211d\u22650) [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 := \u03bb 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 : \u2115) : fact (0 < m!) :=\n\u27e8nat.factorial_pos _\u27e9\n\ndef rescale_functor : \u2115 \u2192 (system_of_complexes \u2964 system_of_complexes)\n| 0     := \ud835\udfed _\n| 1     := \ud835\udfed _\n| (m+2) := rescale (m+2)!\n\ninstance rescale_functor.additive : \u03a0 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 : \u03a0 i j, rescale_functor i \u27f6 rescale_functor j\n| 0     1     := \ud835\udfd9 _\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 (\u03ba : \u211d\u22650) : system_of_complexes \u2964 system_of_complexes :=\n(whiskering_left _ _ _).obj (nnreal.MulLeft \u03ba).op\n\n@[simp] lemma ScaleIndexLeft_apply (C : system_of_complexes) (\u03ba c : \u211d\u22650) (i : \u2115) :\n  (ScaleIndexLeft \u03ba).obj C c i = C (\u03ba * c) i := rfl\n\ndef scale_index_left (C : system_of_complexes) (\u03ba : \u211d\u22650) := (ScaleIndexLeft \u03ba).obj C\n\nlemma admissible.scale_index_left {C : system_of_complexes} (hC : C.admissible) (\u03ba : \u211d\u22650) :\n  (C.scale_index_left \u03ba).admissible :=\n{ d_norm_noninc' := \u03bb c i j hij, (by { apply admissible.d_norm_noninc C hC (\u03ba * c) i j, }),\n  res_norm_noninc := \u03bb c\u2081 c\u2082 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 :\u211d\u22650} {m : \u2115} (c\u2080 c\u2081: \u211d\u22650) [fact (1 \u2264 k)]\n  (hC : C.is_weak_bounded_exact k K m c\u2080) (\u03ba : \u211d\u22650) [h\u03ba : fact (c\u2080 \u2264 \u03ba * c\u2081)]\n  (C_adm : C.admissible) :\n  (C.scale_index_left \u03ba).is_weak_bounded_exact k K m c\u2081 :=\nbegin\n  intros c hc i hi x \u03b5 h\u03b5,\n  dsimp [scale_index_left, ScaleIndexLeft_apply] at x,\n  haveI aux1 : fact (k * (\u03ba * c) \u2264 \u03ba * (k * c)) := \u27e8(mul_left_comm _ _ _).le\u27e9,\n  obtain \u27e8i\u2080, j, hi\u2080, hj, y, hy\u27e9 := hC (\u03ba * c) _ i hi (res x) \u03b5 h\u03b5,\n  swap, { exact \u27e8h\u03ba.1.trans $ fact.out _\u27e9, },\n  refine \u27e8i\u2080, j, hi\u2080, hj, y, _\u27e9,\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 (\u03ba : \u211d\u22650) : system_of_complexes \u2964 system_of_complexes :=\n(whiskering_left _ _ _).obj (nnreal.MulRight \u03ba).op\n\n@[simp] lemma ScaleIndexRight_apply (C : system_of_complexes) (\u03ba c : \u211d\u22650) (i : \u2115) :\n  (ScaleIndexRight \u03ba).obj C c i = C (c * \u03ba) i := rfl\n\ndef scale_index_right (C : system_of_complexes) (\u03ba : \u211d\u22650) := (ScaleIndexRight \u03ba).obj C\n\nlemma admissible.scale_index_right {C : system_of_complexes} (hC : C.admissible) (\u03ba : \u211d\u22650) :\n  (C.scale_index_right \u03ba).admissible :=\n{ d_norm_noninc' := \u03bb c i j hij, (by { apply admissible.d_norm_noninc C hC (c * \u03ba) i j, }),\n  res_norm_noninc := \u03bb c\u2081 c\u2082 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 :\u211d\u22650} {m : \u2115} (c\u2080 c\u2081 : \u211d\u22650) [fact (1 \u2264 k)]\n  (hC : C.is_weak_bounded_exact k K m c\u2080) (\u03ba : \u211d\u22650) [h\u03ba : fact (c\u2080 \u2264 \u03ba * c\u2081)]\n  (C_adm : C.admissible) :\n  (C.scale_index_right \u03ba).is_weak_bounded_exact k K m c\u2081 :=\nbegin\n  intros c hc i hi x \u03b5 h\u03b5,\n  dsimp [scale_index_right, ScaleIndexRight_apply] at x,\n  haveI aux1 : fact (k * (c * \u03ba) \u2264 k * c * \u03ba) := \u27e8(mul_assoc _ _ _).ge\u27e9,\n  obtain \u27e8i\u2080, j, hi\u2080, hj, y, hy\u27e9 := hC (c * \u03ba) _ i hi (res x) \u03b5 h\u03b5,\n  swap, { rw mul_comm, exact \u27e8h\u03ba.1.trans $ fact.out _\u27e9, },\n  refine \u27e8i\u2080, j, hi\u2080, hj, y, _\u27e9,\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' : \u2115 \u2192 ((\u211d\u22650\u1d52\u1d56 \u2964 SemiNormedGroup) \u2964 (\u211d\u22650\u1d52\u1d56 \u2964 SemiNormedGroup))\n| 0     := \ud835\udfed _\n| 1     := \ud835\udfed _\n| (m+2) := (whiskering_right _ _ _).obj (SemiNormedGroup.rescale (m+2)!)\n\ninstance rescale_functor'.additive : \u03a0 m, (rescale_functor' m).additive\n| 0     := functor.id.additive\n| 1     := functor.id.additive\n| (m+2) := {}\n\ndef to_rescale' (r : \u211d\u22650) [fact (0 < r)] :\n  \ud835\udfed (\u211d\u22650\u1d52\u1d56 \u2964 SemiNormedGroup) \u27f6 ((whiskering_right _ _ _).obj (SemiNormedGroup.rescale r)) :=\n{ app := \u03bb V,\n  { app := \u03bb c, (SemiNormedGroup.to_rescale r).app _,\n    naturality' := by { intros c\u2081 c\u2082 h, dsimp, ext i : 2, refl } },\n  naturality' := \u03bb C\u2081 C\u2082 f, by { ext, refl } }\n\n@[simps app]\ndef scale' (i j : \u211d\u22650) [fact (0 < i)] [fact (0 < j)] :\n  ((whiskering_right \u211d\u22650\u1d52\u1d56 _ _).obj (SemiNormedGroup.rescale i)) \u27f6\n  ((whiskering_right \u211d\u22650\u1d52\u1d56 _ _).obj (SemiNormedGroup.rescale j)) :=\n(whiskering_right \u211d\u22650\u1d52\u1d56 _ _).map $ SemiNormedGroup.scale i j\n\ndef rescale_nat_trans' : \u03a0 i j, rescale_functor' i \u27f6 rescale_functor' j\n| 0     1     := \ud835\udfd9 _\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) \u2293 (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 := \u03bb 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 : \u22a4 = 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 (\u03bb i_pos, r.eval_body i_pos i_neg) :=\n      \u03bb 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 := \u27e8@list.mem Rule\u27e9 \nnamespace Program\n  structure reduct_model (self : Program) (i_pos i_neg : I) : Prop :=\n    (p : \u2200r \u2208 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 : \u2200ii < i, \u00ac(self.reduct_model ii i))\n\n  def atoms (p : Program) : set atom := {\n    a : atom | \u2203 (r : Rule) (m : r \u2208 p), a = r.head \u2228 a \u2208 r.pbody \u2228 a \u2208 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 \u2286 p') : p.atoms \u2286 p'.atoms := \u03bb 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 \u2208 p.atoms \u2194 a \u2208 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 \u2208 ((r.pbody ++ r.nbody) ++ (atoms_list p_tl)),     rw list.mem_append_eq, left, rw list.mem_append_eq, left,     exact acond,     change a \u2208 ((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 \u2208 ((p_hd.pbody ++ p_hd.nbody) ++ (atoms_list p_tl)),     change r \u2208 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 \u2208 ((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 \u2208 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 \u2208 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 (\u2200 a \u2208 p.atoms, prop a) := begin\n    by_cases \u2200 a \u2208 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 (\u2203 a \u2208 p.atoms, prop a) := begin\n    by_cases \u2200 a \u2208 p.atoms, \u00acprop 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 := \u03bb a, if a \u2208 p.atoms then i a else vfalse\nlemma localize.monotone {p : Program} : monotone $ localize p := \u03bb _ _ c, I.less_than_or_equal.mk (\u03bb a, by {unfold localize, split_ifs, exact c.p a, exact rfl.le})\ndef Program.localize (p : Program) : I \u2192o I := \u27e8localize p, localize.monotone\u27e9\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 (\u03bb _, I) := \u27e8\u03bb pi, p.localize pi.val\u27e9\n@[ext] lemma Program.I.ext {p : Program} {i ii : p.I} : (\u2200 a : atom, i a = ii a) \u2194 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 \u2209 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 \u2200 a \u2208 p.atoms, i1 a = i2 a,\n  apply decidable.is_true,\n  apply Program.I.ext.mp, intro a,\n  by_cases h2 : a \u2208 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 \u2208 (@construct_all_interps p) := sorry\n\ninstance {p : Program} : fintype p.I := fintype.mk ((@construct_all_interps p).to_finset) (\u03bb 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 (\u03bb 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\u1d9c,\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 (\u03bb x, x),\n--   let interps := finset.map (\u03bb 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 \u2208 p) (a : atom) : a \u2208 r.pbody -> a \u2208 p.atoms := \u03bb 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 \u2208 p) (a : atom) : a \u2208 r.nbody -> a \u2208 p.atoms := \u03bb 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 (\u03b1 : Type u) := (wedge : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n\nlocalized \"infix \u2227: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 \u2115 := {\n  wedge := (*)\n}\n\nlemma dummy : 2 \u2227 3 = 6 := rfl\n\n/-\nfailed to synthesize type class instance for\n\u22a2 has_wedge Prop\n-/\n-- lemma dummy' : (2 \u2227 3 = 6) \u2227 (2 \u2227 9 = 18) := sorry\n\nend userland\n\n-- \\curlywedge \u22cf\n-- \\curlyvee \u22ce\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\u27e8\u03bb M N [monoid M] [monoid N], by exactI @monoid_hom.to_fun M N _ _,\n \u03bb M [monoid M], by exactI @monoid_hom.id M _,\n \u03bb M N P [monoid M] [monoid N] [monoid P], by exactI @monoid_hom.comp M N P _ _ _,\n \u03bb M N [monoid M] [monoid N], by exactI @monoid_hom.coe_inj M N _ _\u27e9\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 \u2192* Y) :\n  of X \u27f6 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 \u2192* 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\u27e8@of punit $ @group.to_monoid _ $ @comm_group.to_group _ punit.comm_group\u27e9\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 := \u27e8\u27e9\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\u27e8@of punit $ @comm_group.to_comm_monoid _ punit.comm_group\u27e9\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\u2082 CommMon Mon := bundled_hom.forget\u2082 _ _\n\nend CommMon\n\n-- We verify that the coercions of morphisms to functions work correctly:\nexample {R S : Mon}     (f : R \u27f6 S) : (R : Type) \u2192 (S : Type) := f\nexample {R S : CommMon} (f : R \u27f6 S) : (R : Type) \u2192 (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 `\u21a5R`,\n-- rather than `R.\u03b1` or (as we used to have) `\u21a5(bundled.map comm_monoid.to_monoid R)`.\nexample (R : CommMon.{u}) : R \u27f6 R :=\n{ to_fun := \u03bb 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' := \u03bb x y,\n  begin rw [mul_assoc x y (x * y), \u2190mul_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 \u2243* Y) : Mon.of X \u2245 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 \u2243* Y) : CommMon.of X \u2245 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 \u2245 Y) : X \u2243* 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 \u2245 Y) : X \u2243* 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 \u2243* Y) \u2245 (Mon.of X \u2245 Mon.of Y) :=\n{ hom := \u03bb e, e.to_Mon_iso,\n  inv := \u03bb 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 \u2243* Y) \u2245 (CommMon.of X \u2245 CommMon.of Y) :=\n{ hom := \u03bb e, e.to_CommMon_iso,\n  inv := \u03bb i, i.CommMon_iso_to_mul_equiv, }\n\n@[to_additive]\ninstance Mon.forget_reflects_isos : reflects_isomorphisms (forget Mon.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Mon).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Mon_iso).1\u27e9,\n  end }\n\n@[to_additive]\ninstance CommMon.forget_reflects_isos : reflects_isomorphisms (forget CommMon.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommMon).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommMon_iso).1\u27e9,\n  end }\n\n/-!\nOnce we've shown that the forgetful functors to type reflect isomorphisms,\nwe automatically obtain that the `forget\u2082` functors between our concrete categories\nreflect isomorphisms.\n-/\nexample : reflects_isomorphisms (forget\u2082 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 : \u211d} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) :=\nbegin\n  have h1 : (a + b + c) / (b + c) + (a + b + c) / (a + c) + (a + b + c) / (a + b) \u2265 9 / 2, from sorry,\n  have h2 : (a + b + c) / (b + c) + (a + b + c) / (a + c) + (a + b + c) / (a + b) \u2265 3 / ((b + c) + (a + c) + (a + b)), from sorry,\n  have h3 : (1 / (b + c) + 1 / (a + c) + 1 / (a + b)) / 3 \u2265 3 / ((b + c) + (a + c) + (a + b)), from sorry,\n  show (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2), from sorry,\nend\n\n--OUTPUT 2\ntheorem nesbitt_inequality {a b c : \u211d} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) :=\nbegin\n  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                    calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                      calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                        calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                          calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                            calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                              calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                                calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) : by {\n                                                                                                  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (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 : \u211d} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (3 / 2) :=\nbegin\n  calc (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (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    ... \u2265 (9 * (a + b + c)) / ((b + c) + (a + c) + (a + b)) : by sorry\n    ... \u2265 (3 / ((b + c) + (a + c) + (a + b))) : by sorry\n    ... \u2265 (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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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 : \u211d} (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : (a / (b + c)) + (b / (a + c)) + (c / (a + b)) \u2265 (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:\u211d  \u2192 \u211d)(hf0:\u2200(x:\u211d), (0<x) \u2192 (0 <f x))\n(hf: \u2200(x y z w :\u211d), (0<x\u22270<z\u22270<y\u22270<w) \u2192 ((f w^2)+(f x^2))/ (f (y^2)+(f (z^2))) = (w^2+x^2)/(y^2+z^2)):\n(\u2200 (x:\u211d), 0<x\u2192 f x = x)\u2228(\u2200 (x:\u211d),0<x \u2192 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(`\u03c1`,`\u03c3`)` := 1/2 * \u2225\u03c1 - \u03c3\u2225\u2081\nnotation \u03c1`^\u2297`n := tpow \u03c1 n\n\nvariables {\u210b : Type} [complex_hilbert_space \u210b]\n{\u03c1 \u03c1' : module.End \u2102 \u210b} [quantum_state \u03c1]\n[H(\u03c1) \u2264 H(\u03c1')]\n\ndef dephasing_channel_in_eigenbasis (\u03c1 : module.End \u2102 \u210b) [quantum_state \u03c1] : quantum_channel := sorry\n\nnotation `\ud835\udc9f ` \u03c1 := dephasing_channel_in_eigenbasis \u03c1\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\u00d7d Hermitian matrix its vector \nof eigenvalues \u03bb majorizes the vector of diagonal elements in every \northonormal basis. Conversely, every vector that is majorized by \u03bb \nmay be obtained as the diagonal elements in a suitable orthonormal \nbasis.\"\n-/\nlemma basic_lemma : \n\u2200 \u03b5 > 0, \u2203 (n : \u2115), \u2203 (U : module.End \u2102 \u210b) [unitary U], \u2200 k \u2264 n,\nD(\u03c1', \ud835\udc9f(pTr_{1,..,n}\\{k} (U * \u03c1^\u2297n * U\u2020))) \u2264 \u03b5 := \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 (\u00ac* p)) \u2192 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 \u2190 prove_unsats (dnf (\u00ac* 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 \u2192 tactic exprterm\n    |\n        q( - $ ( x ) )\n        =>\n        ( do let z \u2190 eval_expr' Int x return ( exprterm.cst ( - z : Int ) ) )\n          <|>\n          ( return <| exprterm.exp ( - 1 : Int ) x )\n      | q( $ ( mx ) * $ ( zx ) ) => do let z \u2190 eval_expr' Int zx return ( exprterm.exp z mx )\n      |\n        q( $ ( t1x ) + $ ( t2x ) )\n        =>\n        do let t1 \u2190 to_exprterm t1x let t2 \u2190 to_exprterm t2x return ( exprterm.add t1 t2 )\n      |\n        x\n        =>\n        ( do let z \u2190 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 \u2192 tactic exprform\n    |\n        q( $ ( tx1 ) = $ ( tx2 ) )\n        =>\n        do let t1 \u2190 to_exprterm tx1 let t2 \u2190 to_exprterm tx2 return ( exprform.eq t1 t2 )\n      |\n        q( $ ( tx1 ) \u2264 $ ( tx2 ) )\n        =>\n        do let t1 \u2190 to_exprterm tx1 let t2 \u2190 to_exprterm tx2 return ( exprform.le t1 t2 )\n      | q( \u00ac $ ( px ) ) => do let p \u2190 to_exprform px return ( exprform.not p )\n      |\n        q( $ ( px ) \u2228 $ ( qx ) )\n        =>\n        do let p \u2190 to_exprform px let q \u2190 to_exprform qx return ( exprform.or p q )\n      |\n        q( $ ( px ) \u2227 $ ( qx ) )\n        =>\n        do let p \u2190 to_exprform px let q \u2190 to_exprform qx return ( exprform.and p q )\n      | q( _ \u2192 $ ( 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 \u2192 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 \u2192 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 \u2192 tactic Preterm\n  | exprterm.cst k => return (&k)\n  | exprterm.exp k x =>\n    let m := xs.indexOf\u2093 x\n    if m < xs.length then return (k ** m) else failed\n  | exprterm.add xa xb => do\n    let a \u2190 xa.to_preterm\n    let b \u2190 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 \u2192 tactic Preform\n  | exprform.eq xa xb => do\n    let a \u2190 xa.to_preterm xs\n    let b \u2190 xb.to_preterm xs\n    return (a =* b)\n  | exprform.le xa xb => do\n    let a \u2190 xa.to_preterm xs\n    let b \u2190 xb.to_preterm xs\n    return (a \u2264* b)\n  | exprform.not xp => do\n    let p \u2190 xp.to_preform\n    return (\u00ac* p)\n  | exprform.or xp xq => do\n    let p \u2190 xp.to_preform\n    let q \u2190 xq.to_preform\n    return (p \u2228* q)\n  | exprform.and xp xq => do\n    let p \u2190 xp.to_preform\n    let q \u2190 xq.to_preform\n    return (p \u2227* 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 \u00d7 Nat) := do\n  let xf \u2190 to_exprform x\n  let xs := xf.exprs\n  let f \u2190 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) \u2190 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 \u2124 -/\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 \u2192 tactic Unit\n    | q( \u00ac $ ( px ) ) => wff px\n      | q( $ ( px ) \u2228 $ ( qx ) ) => wff px >> wff qx\n      | q( $ ( px ) \u2227 $ ( qx ) ) => wff px >> wff qx\n      | q( $ ( px ) \u2194 $ ( 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 \u2124 -/\nunsafe def intro_ints_core : tactic Unit := do\n  let x \u2190 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) _ \u2190 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 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\n-- This file tests the builtin rules that destruct hypotheses with product-like\n-- types.\n\nimport Aesop\n\nset_option aesop.check.all true\n\n@[aesop safe constructors]\ninductive Ex (\u03b1 : Sort u) (\u03b2 : \u03b1 \u2192 Prop) : Prop\n  | intro (fst : \u03b1) (snd : \u03b2 fst)\n\n@[aesop safe constructors]\nstructure Sig (\u03b1 : Sort u) (\u03b2 : \u03b1 \u2192 Sort v) : Sort _ where\n  fst : \u03b1\n  snd : \u03b2 fst\n\nexample (h : \u03b1 \u2227 \u03b2) : Sig \u03b1 (\u03bb _ => \u03b2) := by\n  aesop\n\nexample (h : \u03b1 \u00d7 \u03b2) : Sig \u03b1 (\u03bb _ => \u03b2) := by\n  aesop\n\nexample (h : PProd \u03b1 \u03b2) : Sig \u03b1 (\u03bb _ => \u03b2) := by\n  aesop\n\nexample (h : MProd \u03b1 \u03b2) : Sig \u03b1 (\u03bb _ => \u03b2) := by\n  aesop\n\nexample {p : \u03b1 \u2192 Prop} (h : \u2203 a, p a) : Ex \u03b1 p := by\n  aesop\n\nexample {p : \u03b1 \u2192 Prop} (h : { a // p a }) : Sig \u03b1 p := by\n  aesop\n\nexample {p : \u03b1 \u2192 Type} (h : \u03a3 a, p a) : Sig \u03b1 p := by\n  aesop\n\nexample {p : \u03b1 \u2192 Type} (h : \u03a3' a, p a) : Sig \u03b1 p := by\n  aesop\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/DestructProducts.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149978955811, "lm_q2_score": 0.6513548714339144, "lm_q1q2_score": 0.49171756139781}}
{"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 {\u03b9 M : Type _} [DecidableEq \u03b9]\n\n/- warning: list.support_sum_subset -> List.support_sum_subset is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddMonoid.{u2} M] (l : List.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))), HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (List.sum.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finsupp.add.{u1, u2} \u03b9 M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (Finsupp.zero.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) l)) (List.foldr.{max u1 u2, u1} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} \u03b9) (Function.comp.{max (succ u1) (succ u2), succ u1, succ u1} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} \u03b9) ((Finset.{u1} \u03b9) -> (Finset.{u1} \u03b9)) (Sup.sup.{u1} (Finset.{u1} \u03b9) (SemilatticeSup.toHasSup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))))) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b9) (Finset.hasEmptyc.{u1} \u03b9)) l)\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddMonoid.{u2} M] (l : List.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2))), HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.instHasSubsetFinset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2) (List.sum.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) (Finsupp.add.{u1, u2} \u03b9 M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (Finsupp.zero.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) l)) (List.foldr.{max u2 u1, u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} \u03b9) (Function.comp.{succ (max u2 u1), succ u1, succ u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} \u03b9) ((Finset.{u1} \u03b9) -> (Finset.{u1} \u03b9)) (fun (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.45 : Finset.{u1} \u03b9) (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.47 : Finset.{u1} \u03b9) => Sup.sup.{u1} (Finset.{u1} \u03b9) (SemilatticeSup.toSup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)))) x._@.Mathlib.Data.Finsupp.BigOperators._hyg.45 x._@.Mathlib.Data.Finsupp.BigOperators._hyg.47) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b9) (Finset.instEmptyCollectionFinset.{u1} \u03b9)) l)\nCase conversion may be inaccurate. Consider using '#align list.support_sum_subset List.support_sum_subset\u2093'. -/\ntheorem List.support_sum_subset [AddMonoid M] (l : List (\u03b9 \u2192\u2080 M)) :\n    l.Sum.support \u2286 l.foldr ((\u00b7 \u2294 \u00b7) \u2218 Finsupp.support) \u2205 :=\n  by\n  induction' l with hd tl IH\n  \u00b7 simp\n  \u00b7 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddCommMonoid.{u2} M] (s : Multiset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))), HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Multiset.sum.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.addCommMonoid.{u1, u2} \u03b9 M _inst_2) s)) (Multiset.sup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.orderBot.{u1} \u03b9) (Multiset.map.{max u1 u2, u1} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) s))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddCommMonoid.{u2} M] (s : Multiset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))), HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.instHasSubsetFinset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)) (Multiset.sum.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.addCommMonoid.{u1, u2} \u03b9 M _inst_2) s)) (Multiset.sup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9) (Multiset.map.{max u2 u1, u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 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\u2093'. -/\ntheorem Multiset.support_sum_subset [AddCommMonoid M] (s : Multiset (\u03b9 \u2192\u2080 M)) :\n    s.Sum.support \u2286 (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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddCommMonoid.{u2} M] (s : Finset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))), HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 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} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.addCommMonoid.{u1, u2} \u03b9 M _inst_2) s (id.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))))) (Finset.sup.{u1, max u1 u2} (Finset.{u1} \u03b9) (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.orderBot.{u1} \u03b9) s (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddCommMonoid.{u2} M] (s : Finset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))), HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.instHasSubsetFinset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)) (Finset.sum.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.addCommMonoid.{u1, u2} \u03b9 M _inst_2) s (id.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))))) (Finset.sup.{u1, max u1 u2} (Finset.{u1} \u03b9) (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9) s (Finsupp.support.{u1, u2} \u03b9 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\u2093'. -/\ntheorem Finset.support_sum_subset [AddCommMonoid M] (s : Finset (\u03b9 \u2192\u2080 M)) :\n    (s.Sum id).support \u2286 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : Zero.{u2} M] {l : List.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)} {x : \u03b9}, Iff (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) x (List.foldr.{max u1 u2, u1} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{u1} \u03b9) (Function.comp.{max (succ u1) (succ u2), succ u1, succ u1} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{u1} \u03b9) ((Finset.{u1} \u03b9) -> (Finset.{u1} \u03b9)) (Sup.sup.{u1} (Finset.{u1} \u03b9) (SemilatticeSup.toHasSup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))))) (Finsupp.support.{u1, u2} \u03b9 M _inst_2)) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b9) (Finset.hasEmptyc.{u1} \u03b9)) l)) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M _inst_2) (fun (f : Finsupp.{u1, u2} \u03b9 M _inst_2) => Exists.{0} (Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (List.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (List.hasMem.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f l) (fun (hf : Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (List.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (List.hasMem.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f l) => Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) x (Finsupp.support.{u1, u2} \u03b9 M _inst_2 f))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : Zero.{u2} M] {l : List.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)} {x : \u03b9}, Iff (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) x (List.foldr.{max u2 u1, u1} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{u1} \u03b9) (Function.comp.{succ (max u2 u1), succ u1, succ u1} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{u1} \u03b9) ((Finset.{u1} \u03b9) -> (Finset.{u1} \u03b9)) (fun (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.336 : Finset.{u1} \u03b9) (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.338 : Finset.{u1} \u03b9) => Sup.sup.{u1} (Finset.{u1} \u03b9) (SemilatticeSup.toSup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)))) x._@.Mathlib.Data.Finsupp.BigOperators._hyg.336 x._@.Mathlib.Data.Finsupp.BigOperators._hyg.338) (Finsupp.support.{u1, u2} \u03b9 M _inst_2)) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b9) (Finset.instEmptyCollectionFinset.{u1} \u03b9)) l)) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M _inst_2) (fun (f : Finsupp.{u1, u2} \u03b9 M _inst_2) => Exists.{0} (Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (List.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (List.instMembershipList.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f l) (fun (hf : Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (List.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (List.instMembershipList.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f l) => Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) x (Finsupp.support.{u1, u2} \u03b9 M _inst_2 f))))\nCase conversion may be inaccurate. Consider using '#align list.mem_foldr_sup_support_iff List.mem_foldr_sup_support_iff\u2093'. -/\ntheorem List.mem_foldr_sup_support_iff [Zero M] {l : List (\u03b9 \u2192\u2080 M)} {x : \u03b9} :\n    x \u2208 l.foldr ((\u00b7 \u2294 \u00b7) \u2218 Finsupp.support) \u2205 \u2194 \u2203 (f : \u03b9 \u2192\u2080 M)(hf : f \u2208 l), x \u2208 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  \u00b7 simp\n  \u00b7 simp only [IH, List.foldr_cons, Finset.mem_union, Finsupp.mem_support_iff, List.mem_cons]\n    constructor\n    \u00b7 rintro (h | h)\n      \u00b7 exact \u27e8hd, Or.inl rfl, h\u27e9\n      \u00b7 exact h.imp fun f hf => hf.imp_left Or.inr\n    \u00b7 rintro \u27e8f, rfl | hf, h\u27e9\n      \u00b7 exact Or.inl h\n      \u00b7 exact Or.inr \u27e8f, hf, h\u27e9\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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : Zero.{u2} M] {s : Multiset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)} {x : \u03b9}, Iff (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) x (Multiset.sup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.orderBot.{u1} \u03b9) (Multiset.map.{max u1 u2, u1} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M _inst_2) s))) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M _inst_2) (fun (f : Finsupp.{u1, u2} \u03b9 M _inst_2) => Exists.{0} (Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Multiset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (Multiset.hasMem.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f s) (fun (hf : Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Multiset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (Multiset.hasMem.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f s) => Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) x (Finsupp.support.{u1, u2} \u03b9 M _inst_2 f))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : Zero.{u2} M] {s : Multiset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)} {x : \u03b9}, Iff (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) x (Multiset.sup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9) (Multiset.map.{max u2 u1, u1} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M _inst_2) s))) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M _inst_2) (fun (f : Finsupp.{u1, u2} \u03b9 M _inst_2) => Exists.{0} (Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Multiset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (Multiset.instMembershipMultiset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f s) (fun (hf : Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Multiset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (Multiset.instMembershipMultiset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f s) => Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) x (Finsupp.support.{u1, u2} \u03b9 M _inst_2 f))))\nCase conversion may be inaccurate. Consider using '#align multiset.mem_sup_map_support_iff Multiset.mem_sup_map_support_iff\u2093'. -/\ntheorem Multiset.mem_sup_map_support_iff [Zero M] {s : Multiset (\u03b9 \u2192\u2080 M)} {x : \u03b9} :\n    x \u2208 (s.map Finsupp.support).sup \u2194 \u2203 (f : \u03b9 \u2192\u2080 M)(hf : f \u2208 s), x \u2208 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : Zero.{u2} M] {s : Finset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)} {x : \u03b9}, Iff (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) x (Finset.sup.{u1, max u1 u2} (Finset.{u1} \u03b9) (Finsupp.{u1, u2} \u03b9 M _inst_2) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.orderBot.{u1} \u03b9) s (Finsupp.support.{u1, u2} \u03b9 M _inst_2))) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M _inst_2) (fun (f : Finsupp.{u1, u2} \u03b9 M _inst_2) => Exists.{0} (Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (Finset.hasMem.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f s) (fun (hf : Membership.Mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (Finset.hasMem.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f s) => Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) x (Finsupp.support.{u1, u2} \u03b9 M _inst_2 f))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : Zero.{u2} M] {s : Finset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)} {x : \u03b9}, Iff (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) x (Finset.sup.{u1, max u1 u2} (Finset.{u1} \u03b9) (Finsupp.{u1, u2} \u03b9 M _inst_2) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9) s (Finsupp.support.{u1, u2} \u03b9 M _inst_2))) (Exists.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M _inst_2) (fun (f : Finsupp.{u1, u2} \u03b9 M _inst_2) => Exists.{0} (Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (Finset.instMembershipFinset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f s) (fun (hf : Membership.mem.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2) (Finset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M _inst_2)) (Finset.instMembershipFinset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M _inst_2)) f s) => Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) x (Finsupp.support.{u1, u2} \u03b9 M _inst_2 f))))\nCase conversion may be inaccurate. Consider using '#align finset.mem_sup_support_iff Finset.mem_sup_support_iff\u2093'. -/\ntheorem Finset.mem_sup_support_iff [Zero M] {s : Finset (\u03b9 \u2192\u2080 M)} {x : \u03b9} :\n    x \u2208 s.sup Finsupp.support \u2194 \u2203 (f : \u03b9 \u2192\u2080 M)(hf : f \u2208 s), x \u2208 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddMonoid.{u2} M] (l : List.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))), (List.Pairwise.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Function.onFun.{succ (max u1 u2), succ u1, 1} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} \u03b9) Prop (Disjoint.{u1} (Finset.{u1} \u03b9) (Finset.partialOrder.{u1} \u03b9) (Finset.orderBot.{u1} \u03b9)) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))) l) -> (Eq.{succ u1} (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (List.sum.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finsupp.add.{u1, u2} \u03b9 M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (Finsupp.zero.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) l)) (List.foldr.{max u1 u2, u1} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} \u03b9) (Function.comp.{max (succ u1) (succ u2), succ u1, succ u1} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2))) (Finset.{u1} \u03b9) ((Finset.{u1} \u03b9) -> (Finset.{u1} \u03b9)) (Sup.sup.{u1} (Finset.{u1} \u03b9) (SemilatticeSup.toHasSup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))))) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M _inst_2)))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b9) (Finset.hasEmptyc.{u1} \u03b9)) l))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddMonoid.{u2} M] (l : List.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2))), (List.Pairwise.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) (Function.onFun.{succ (max u2 u1), succ u1, 1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} \u03b9) Prop (Disjoint.{u1} (Finset.{u1} \u03b9) (Finset.partialOrder.{u1} \u03b9) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9)) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2))) l) -> (Eq.{succ u1} (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2) (List.sum.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) (Finsupp.add.{u1, u2} \u03b9 M (AddMonoid.toAddZeroClass.{u2} M _inst_2)) (Finsupp.zero.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) l)) (List.foldr.{max u2 u1, u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} \u03b9) (Function.comp.{succ (max u2 u1), succ u1, succ u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2)) (Finset.{u1} \u03b9) ((Finset.{u1} \u03b9) -> (Finset.{u1} \u03b9)) (fun (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.585 : Finset.{u1} \u03b9) (x._@.Mathlib.Data.Finsupp.BigOperators._hyg.587 : Finset.{u1} \u03b9) => Sup.sup.{u1} (Finset.{u1} \u03b9) (SemilatticeSup.toSup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b)))) x._@.Mathlib.Data.Finsupp.BigOperators._hyg.585 x._@.Mathlib.Data.Finsupp.BigOperators._hyg.587) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M _inst_2))) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b9) (Finset.instEmptyCollectionFinset.{u1} \u03b9)) l))\nCase conversion may be inaccurate. Consider using '#align list.support_sum_eq List.support_sum_eq\u2093'. -/\ntheorem List.support_sum_eq [AddMonoid M] (l : List (\u03b9 \u2192\u2080 M))\n    (hl : l.Pairwise (Disjoint on Finsupp.support)) :\n    l.Sum.support = l.foldr ((\u00b7 \u2294 \u00b7) \u2218 Finsupp.support) \u2205 :=\n  by\n  induction' l with hd tl IH\n  \u00b7 simp\n  \u00b7 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 ((\u00b7 \u2294 \u00b7) \u2218 Finsupp.support) \u2205) by\n      exact Finset.disjoint_of_subset_right (List.support_sum_subset _) this\n    \u00b7 rw [\u2190 List.foldr_map, \u2190 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 \u27e8f, hf, rfl\u27e9 := 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddCommMonoid.{u2} M] (s : Multiset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))), (Multiset.Pairwise.{max u1 u2} (Finsupp.{u1, u2} \u03b9 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} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finset.{u1} \u03b9) Prop (Disjoint.{u1} (Finset.{u1} \u03b9) (Finset.partialOrder.{u1} \u03b9) (Finset.orderBot.{u1} \u03b9)) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) s) -> (Eq.{succ u1} (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Multiset.sum.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.addCommMonoid.{u1, u2} \u03b9 M _inst_2) s)) (Multiset.sup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.orderBot.{u1} \u03b9) (Multiset.map.{max u1 u2, u1} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) s)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddCommMonoid.{u2} M] (s : Multiset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))), (Multiset.Pairwise.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Function.onFun.{succ (max u2 u1), succ u1, 1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.{u1} \u03b9) Prop (Disjoint.{u1} (Finset.{u1} \u03b9) (Finset.partialOrder.{u1} \u03b9) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9)) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) s) -> (Eq.{succ u1} (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)) (Multiset.sum.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.addCommMonoid.{u1, u2} \u03b9 M _inst_2) s)) (Multiset.sup.{u1} (Finset.{u1} \u03b9) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9) (Multiset.map.{max u2 u1, u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 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\u2093'. -/\ntheorem Multiset.support_sum_eq [AddCommMonoid M] (s : Multiset (\u03b9 \u2192\u2080 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 \u27e8l, hl, hd\u27e9 := hs\n  convert List.support_sum_eq _ _\n  \u00b7 simp\n  \u00b7 simp\n  \u00b7 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddCommMonoid.{u2} M] (s : Finset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))), (Set.PairwiseDisjoint.{u1, max u1 u2} (Finset.{u1} \u03b9) (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finset.partialOrder.{u1} \u03b9) (Finset.orderBot.{u1} \u03b9) ((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} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (Set.{max u1 u2} (Finsupp.{u1, u2} \u03b9 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} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (Set.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (CoeTC\u2093.coe.{succ (max u1 u2), succ (max u1 u2)} (Finset.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (Set.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) (Finset.Set.hasCoeT.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))))) s) (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))) -> (Eq.{succ u1} (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 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} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Finsupp.addCommMonoid.{u1, u2} \u03b9 M _inst_2) s (id.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))))) (Finset.sup.{u1, max u1 u2} (Finset.{u1} \u03b9) (Finsupp.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.lattice.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.orderBot.{u1} \u03b9) s (Finsupp.support.{u1, u2} \u03b9 M (AddZeroClass.toHasZero.{u2} M (AddMonoid.toAddZeroClass.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : AddCommMonoid.{u2} M] (s : Finset.{max u2 u1} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))), (Set.PairwiseDisjoint.{u1, max u1 u2} (Finset.{u1} \u03b9) (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finset.partialOrder.{u1} \u03b9) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9) (Finset.toSet.{max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) s) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))) -> (Eq.{succ u1} (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)) (Finset.sum.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Finsupp.addCommMonoid.{u1, u2} \u03b9 M _inst_2) s (id.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2)))))) (Finset.sup.{u1, max u1 u2} (Finset.{u1} \u03b9) (Finsupp.{u1, u2} \u03b9 M (AddMonoid.toZero.{u2} M (AddCommMonoid.toAddMonoid.{u2} M _inst_2))) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b9) (Finset.instLatticeFinset.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b9) s (Finsupp.support.{u1, u2} \u03b9 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\u2093'. -/\ntheorem Finset.support_sum_eq [AddCommMonoid M] (s : Finset (\u03b9 \u2192\u2080 M))\n    (hs : (s : Set (\u03b9 \u2192\u2080 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    \u00b7 exact (Finset.sum_val _).symm\n    \u00b7 obtain \u27e8l, hl, hn\u27e9 : \u2203 l : List (\u03b9 \u2192\u2080 M), l.toFinset = s \u2227 l.Nodup :=\n        by\n        refine' \u27e8s.to_list, _, Finset.nodup_toList _\u27e9\n        simp\n      subst hl\n      rwa [List.toFinset_val, list.dedup_eq_self.mpr hn, Multiset.pairwise_coe_iff_pairwise, \u2190\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 \u2192 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 : \u2200 s : S, L s \u2192 S \u2192 Prop)\n  (t : trace (sigma L)) : Prop :=\n  \u2200 n : \u2115, 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 \u2192 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 \u2192 Prop} [decP : decidable_pred P] :\n  decidable_pred (@inState Prop P) :=\nbegin\nintros x, apply decP,\nend\n\nparameter (LTS : \u2200 s : S, L s \u2192 S \u2192 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 \u2192 Prop}\n  {Q : S \u2192 Prop}\n  (H : \u2200 s l s', LTS s l s' \u2192 P \u27e8 s, l \u27e9 \u2192 Q s')\n  : \u22a9 valid_trace\n    => now P => \u25ef (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 : \u22a9 valid_trace => \u25ef 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 : \u22a9 valid_trace => \u25a1 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 : \u22a9 valid_trace => P)\n  : \u22a9 valid_trace => \u25a1 P\n:= begin\nintros tr validtr n,\napply H, apply valid_trace_always, assumption\nend\n\nlemma prove_always {P : sigma L \u2192 Prop}\n  {Q : S \u2192 Prop}\n  (H : \u2200 s l s', LTS s l s' \u2192 P \u27e8 s, l \u27e9 \u2192 Q s')\n  : \u22a9 valid_trace\n    => \u25a1 (now P => \u25ef (now (inState Q)))\n:= begin\napply (global_always _ _),\napply prove_next, assumption\nend\n\n\nlemma invariant_always (P : S \u2192 Prop)\n  (H : \u2200 s l s', P s \u2192 LTS s l s' \u2192 P s')\n  : \u22a9 valid_trace => now (inState P) => \u25a1 (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 \u2192 Prop} {Q : sigma L \u2192 Prop}\n  [decidable_pred Q]\n  (H : \u2200 s l s', LTS s l s' \u2192 \u00ac Q \u27e8s, l\u27e9 \u2192 P s \u2192 P s')\n  : \u22a9 valid_trace => now (inState P)\n    => \u25ef (now (inState P)) \ud835\udce6 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 \u2192 Prop) (P Q : sigma L \u2192 Prop)\n  (H : \u2200 s l s', LTS s l s' \u2192 P \u27e8 _, l\u27e9 \u2192 P' s' \u2228 Q \u27e8 _, l \u27e9)\n  : \u22a9 valid_trace\n    => now P\n    => ( \u25ef (now (inState P')) \u222a 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 \u2192 Type v) (s : S) : Type v := option (L s)\n\nparameters {S : Type u} {L : S \u2192 Type v}\nparameter (LTS : \u2200 s : S, L s \u2192 S \u2192 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 \u2192 Prop) : sigma (WithSkip L) \u2192 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 (\u03bb _, true)))\n\nlemma SkipLTS_next_state\n  (P Q : S \u2192 Prop)\n  (W : sigma L \u2192 Prop)\n  (HLTS : \u2200 s l s', LTS s l s' \u2192 P s \u2192 W \u27e8 _, l \u27e9 \u2192 Q s')\n   : \u22a9 valid_trace SkipLTS\n   => now (inState P)\n   => now (inSkipLabel W)\n   => \u25ef (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 \u2192 Prop) (P Q : sigma (WithSkip L) \u2192 Prop)\n  (H : \u2200 s l s', LTS s l s' \u2192 P \u27e8 _, some l\u27e9 \u2192 P' s' \u2228 Q \u27e8 _, some l \u27e9)\n  : \u22a9 valid_trace SkipLTS\n    => now P => now (inSkipLabel (\u03bb _, true))\n    => ( \u25ef (now (inState P')) \u222a 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 \u2192 Prop) :\n  \u22a9  valid_trace SkipLTS\n  => \u25a1 (now (inState P)\n  => ((\u25ef (now (inState P)))\n       \ud835\udce6\n       now (inSkipLabel (\u03bb _, 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' \u2192 Type v'}\nparameter (LTS' : \u2200 s : S', L' s \u2192 S' \u2192 Prop)\n\nstructure Refinement :=\n  (S_refine : S \u2192 S')\n  (L_refine : \u2200 {s}, L s \u2192 L' (S_refine s))\n  (refines : \u2200 s l s', LTS s l s' \u2192 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 \u2192 Type v} {L' : S' \u2192 Type v'}\n  {LTS : \u2200 s : S, L s \u2192 S \u2192 Prop}\n  {LTS' : \u2200 s : S', L' s \u2192 S' \u2192 Prop}\n\ndef SL_refine' (r : Refinement LTS LTS')\n  : sigma L \u2192 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 : \u22a9 valid_trace LTS' => P)\n  : \u22a9 valid_trace LTS => (P \u2218 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 ` \u22b9 `:59 := nat.mul\nlocal infix ` \u2193 `:59 := pow\nlocal infix ` \u2296 `:59 := pow\nexample : 2 \u22b9 3 = 6 := rfl\nexample : 2 \u2193 3 = 8 := rfl\nexample : 2 \u2296 3 = 8 := rfl\nexample {n m : \u2115} (h : n < m) : n \u2264 m := by { success_if_fail { simp [h] }, exact le_of_lt h }\nsection\nlocalized \"infix ` \u22b9 `:59 := nat.add\" in nat\nlocalized \"infix ` \u2193 `:59 := nat.mul\" in nat\nlocalized \"infix ` \u2296 `:59 := nat.mul\" in nat.mul\nlocalized \"attribute [simp] le_of_lt\" in le\nexample : 2 \u22b9 3 = 5 := rfl\nexample : 2 \u2193 3 = 6 := rfl\nexample : 2 \u2296 3 = 6 := rfl\nexample {n m : \u2115} (h : n < m) : n \u2264 m := by { simp [h] }\nend\n\nsection\nexample : 2 \u22b9 3 = 6 := rfl\nexample : 2 \u2193 3 = 8 := rfl\nexample : 2 \u2296 3 = 8 := rfl\nexample {n m : \u2115} (h : n < m) : n \u2264 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 \u22b9 3 = 5 := rfl\nexample : 2 \u2193 3 = 6 := rfl\nexample : 2 \u2296 3 = 8 := rfl\n\nopen_locale nat.mul\nexample : 2 \u22b9 3 = 5 := rfl\nexample : 2 \u2193 3 = 6 := rfl\nexample : 2 \u2296 3 = 6 := rfl\nend\n\nsection\nopen_locale nat.mul nat nat.mul le\nexample : 2 \u22b9 3 = 5 := rfl\nexample : 2 \u2193 3 = 6 := rfl\nexample : 2 \u2296 3 = 6 := rfl\nexample {n m : \u2115} (h : n < m) : n \u2264 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 soundness.soundnessCLK\nimport completeness.canonicalCL\nimport syntax.axiomsCLK\nimport tactic.induction\n-- import data.finset.basic\n\nlocal attribute [instance] classical.prop_decidable\n\nopen set list formCLK\n\nnamespace canonical\n\n\n\n\ndef canonical_model_CLK {agents : Type} [hN : fintype agents] (ha : nonempty agents) : \n  modelCLK agents :=\n{ f := canonical_CLK ha (formCLK agents) (nprfalseCLK ha),\n  -- V is as usual, such that s \u2208 V (p) iff p \u2208 s\n  v := \u03bb  n, {s | (formCLK.var n) \u2208 s.1} }\n\n----------------------------------------------------------\n-- Filtration\n----------------------------------------------------------\n\ndef cl {agents : Type} [hN : fintype agents] (ha : nonempty agents) : \n  formCLK agents \u2192 set (formCLK agents)\n  |  bot          := {bot, \u00ac bot}\n  | (var n)       := {var n, \u00ac var n}\n  | (imp \u03c6 \u03c8)     := cl \u03c6 \u222a cl \u03c8 \u222a \n                     match \u03c8 with\n                     | bot := {(imp \u03c6 \u03c8)}\n                     | _   := {(imp \u03c6 \u03c8), \u00ac (imp \u03c6 \u03c8)} \n                     end\n  | (and \u03c6 \u03c8)     := cl \u03c6 \u222a cl \u03c8 \u222a {(and \u03c6 \u03c8), \u00ac (and \u03c6 \u03c8)}\n  | ([G] \u03c6)       := cl \u03c6 \u222a {([G] \u03c6), \u00ac [G] \u03c6}\n  | _ := sorry\n\n----------------------------------------------------------\n-- Truth Lemma\n----------------------------------------------------------\nlemma truth_lemma_CL {agents : Type} (ha : nonempty agents) [hN : fintype agents] (\u03c6 : formCLK agents) \n(s : (canonical_model_CLK ha).f.states) : (s_entails_CLK (canonical_model_CLK ha) s \u03c6) \u2194 (\u03c6 \u2208 s.1) :=\nbegin\n  -- This proof is by induction on \u03c6.\n  induction' \u03c6 with n \u03c6 \u03c8 _ _ \u03c6 \u03c8 _ _,\n\n  { -- case bot\n    simp [s_entails_CLK],\n    exact @bot_not_mem_of_ax_consistent (formCLK agents) formulaCLK s.1 s.2.1, },\n\n  { -- case var\n    simpa, },\n\n  { -- case and\n    simp [s_entails_CLK, ih_\u03c6, ih_\u03c8],\n    split,\n\n    { intro h,\n      exact max_ax_contains_by_set_proof_2h s.2 h.left h.right axCLK.Prop4, },\n\n    { intro h,\n      split,\n      exact max_ax_contains_by_set_proof s.2 h axCLK.Prop5,\n      exact max_ax_contains_by_set_proof s.2 h axCLK.Prop6, }, },\n\n  { -- case imp\n    simp [s_entails_CLK, ih_\u03c6, ih_\u03c8],\n    split,\n\n    { intro h,\n      exact max_ax_contains_imp_by_proof s.2 h, },\n\n    { intros h h\u03c6,\n      exact max_ax_contains_by_set_proof_2h s.2 h\u03c6 h likemp, }, },\n\n  { -- case E\n    let states := {\u0393 : (set (formCLK agents)) // (max_ax_consistent \u0393)},\n    have hE : (canonical_model_CLK ha).f.E.E = \u03bb s, \u03bb G : set agents, {X | ite (G = univ) \n      -- condition G = N\n      (\u2200 \u03c6, ({t : (canonical_model_CLK ha).f.states | \u03c6 \u2208 (t.val)} \u2286 X\u1d9c) \u2192 ([(\u2205)] \u03c6) \u2209 s.val)      \n      -- condition G \u2260 N\n      (\u2203 \u03c6, {t : (canonical_model_CLK ha).f.states | \u03c6 \u2208 (t.val)} \u2286 X \u2227 ( [G] \u03c6) \u2208 s.val)},\n      from rfl,\n\n    specialize ih ha,\n    \n    -- It is sufficient to consider the case when G \u2282 N, because \u22a2 [N]\u03c6 \u2194 \u00ac[\u2205]\u00ac\u03c6\n    cases set.eq_or_ssubset_of_subset (set.subset_univ G) with hG hG,\n    -- Case G = N \n\n    { -- \u22a2 [N]\u03c6 \u2194 \u00ac[\u2205]\u00ac\u03c6\n      have hempty : axCLK (([univ]\u03c6) \u2194 \u00ac([\u2205](\u00ac\u03c6))), from \n        @univ_iff_empty agents (formCLK agents) _ _ _,\n      simp [hG] at *, clear hG,\n\n      split,\n\n      { -- M s \u22a8 [N] \u03c6 \u21d2 [N] \u03c6 \u2208 s\n        intro h,\n        simp[s_entails_CLK, hE] at h,\n        have hnin : ([\u2205] (\u00ac\u03c6)) \u2209 s.val, from\n        begin\n          apply h (\u00ac \u03c6),\n          apply @eq.subset _ _ {t | s_entails_CLK (canonical_model_CLK ha) t \u03c6}\u1d9c,\n          simp[ih],\n          exact complement_from_contra,\n        end,\n        simp at hnin,\n        \n        have hin :  (\u00ac[\u2205]\u00ac\u03c6) \u2208 s.val, from not_in_from_notin s.2 hnin,\n        simp at hin,\n\n        exact max_ax_contains_by_set_proof s.2 hin (axCLK.MP (axCLK.Prop6) hempty), },\n\n      { -- [N] \u03c6 \u2208 s \u21d2 M s \u22a8 [N] \u03c6\n        intro h,\n        simp[s_entails_CLK, hE, ih],\n        intros \u03c8 hsubseteq hf,\n  \n        simp[set.subset_def] at hsubseteq,\n\n        have himp : \u2200 (x : (canonical_model_CLK ha).f.states), \u03c8 \u2208 x.1 \u2192 (\u00ac \u03c6) \u2208 x.1, from\n          \u03bb t ht, not_in_from_notin t.2 (hsubseteq t ht),\n      \n        have hin : (\u00ac [\u2205] \u00ac\u03c6) \u2208 s.val, \n          from max_ax_contains_by_set_proof s.2 h (axCLK.MP (axCLK.Prop5) hempty),\n\n        have hnin : ([\u2205] \u00ac\u03c6) \u2209 s.val, from \n          \u03bb hf, contra_containts_pr_false s.2 hf hin, \n\n        have hax : axCLK (\u03c8 ~> (\u00ac \u03c6)), from\n          ax_imp_from_ex himp,\n\n        have hin' : ([\u2205] \u00ac \u03c6) \u2208 s.val,\n        { apply max_ax_contains_by_set_proof s.2 hf,\n          apply @derived_monoticity_rule agents (formCLK agents),\n          exact hax, },\n\n        exact hnin hin', }, },\n\n    { -- Case G \u2282 N\n      split,\n      -- M, s \u22a8 [G]\u03c6 \u21d2 [G]\u03c6 \u2208 s, when G \u2282 N\n\n      { -- Assume M, s \u22a8 [G]\u03c6\n        intro h,\n        -- {s \u2208 S| M, s \u22a8 \u03c6} \u2208 E(s)(G), from h, by definition \u22a8\n        simp[s_entails_CLK] at h,\n        -- \u2203\u03c8\u02dc \u2286 {t \u2208 S| M, t \u22a8 \u03c6} : [G]\u03c8 \u2208 s, from above, by definition E\n        have huniv : G \u2260 univ, from (set.ssubset_iff_subset_ne.mp hG).right,\n        simp[hE, huniv] at h, clear huniv,\n        -- \u2203\u03c8\u02dc \u2286 {t \u2208 S| M, \u03c6 \u2208 t} : [G]\u03c8 \u2208 s, from above, by IH\n        cases h with \u03c8 h\u03c8, \n        have h\u03c8ih : \u2200 (a : (canonical_model_CLK ha).f.states), \u03c8 \u2208 \u2191a \u2192 \u03c6 \u2208 a.val, from\n          begin\n            intros t ht, \n            apply (ih t).mp, \n            apply h\u03c8.left, \n            exact ht,\n          end,\n        -- \u2203\u03c8\u02dc \u2286 \u03c6\u02dc : [G]\u03c8 \u2208 s, from hih, by definition \u03c8\u02dc\n        have hG\u03c8 : ([G]\u03c8) \u2208 s.val, from h\u03c8.right,\n        -- \u22a2 \u03c8 \u2192 \u03c6, since \u03c8\u02dc \u2286 \u03c6\u02dc in h\u03c8ih \n        have himp : axCLK (\u03c8 ~> \u03c6), from ax_imp_from_ex h\u03c8ih,\n        -- \u22a2 [G]\u03c8 \u2192 [G]\u03c6, from himp, by the derived monoticity rule\n        have hGimp : axCLK (([G] \u03c8) ~> ([G] \u03c6)), from \n          @derived_monoticity_rule agents (formCLK agents) formulaCLK CLformulaCLK _ _ _ himp,\n        -- [G]\u03c6 \u2208 s, from hGimp and hG\u03c8\n        exact max_ax_contains_by_set_proof s.2 hG\u03c8 hGimp, },\n      -- [G]\u03c6 \u2208 s \u21d2 M, s \u22a8 [G]\u03c6, when G \u2282 N\n\n      { -- Assume [G]\u03c6 \u2208 s\n        intro h,\n        -- \u02dc\u03c6 \u2286 {t \u2208 S| \u03c6 \u2208 t} : [G]\u03c6 \u2208 s, from 4.1\n        simp[s_entails_CLK],\n        -- {t \u2208 S| \u03c6 \u2208 t} \u2208 E (s)(G), from 4.2, by definition E(s)(G).\n        simp[hE, (set.ssubset_iff_subset_ne.mp hG).right],\n        apply exists.intro \u03c6,\n        -- {t \u2208 S | M, t \u22a8 \u03c6} \u2208 E(s)(G), from 4.3, by IH\n        split,\n\n        { intros t ht,\n          simp[ih t],\n          exact ht, },\n\n        { exact h, }, }, }, },\n  -- case K\n  { have hK : (canonical_model_CLK ha).f.rel = \u03bb i s, {t | {\u03c6 | (K' i \u03c6) \u2208 s.1} = {\u03c6 | (K' i \u03c6) \u2208 t.1}},\n      from rfl,\n    split,\n    -- \u21d2\n    { intro h,\n      simp at *, \n      simp [s_entails_CLK] at h,\n      simp [hK] at *,\n      have h\u03c6 : \u03c6 \u2208 s.1, \n      { simp [\u2190(ih a s)],\n        apply h,\n        simp, },\n      have hkj : \u2200 t : (canonical_model_CLK ha).f.to_frameCL.states, \n        {\u03c6 : formCLK agents | K' a \u03c6 \u2208 \u2191s} = {\u03c6 : formCLK agents | K' a \u03c6 \u2208 \u2191t} \u2192 \u03c6 \u2208 t.1,\n      {\n        intros t ht,\n        simp [\u2190(ih a t)],\n        apply h,\n        exact ht,\n      },\n      dsimp at *,\n      -- have (K' i \u03c6) \u2208 s,\n      \n      -- simp [ih] at h,\n      sorry,\n      -- simp [(ih i)] at h,\n\n    },\n    { intro h,\n      simp[s_entails_CLK, ih, hK],\n      intros t ht,\n      have hKt: K' a \u03c6 \u2208 t.val, from\n      begin \n        simp[set.ext_iff] at ht,\n        specialize ht \u03c6,\n        simp[\u2190ht],\n        exact h,\n      end,\n      exact max_ax_contains_by_set_proof t.2 hKt axCLK.T, }, },\nend\n\n\n\n\n----------------------------------------------------------\n-- Completeness\n----------------------------------------------------------\n\n-- Completeness\n----------------------------------------------------------\n-- theorem completenessCLK (\u03c6 : formCLK agents) [hN : fintype agents] (ha : nonempty agents) : \n--   global_valid \u03c6 \u2192 axCLK \u03c6 :=\n-- begin\n--   -- rw from contrapositive\n--   rw \u2190not_imp_not, \n--   -- assume \u00ac \u22a2 \u03c6\n--   intro hnax,\n--   -- from \u00ac \u22a2 \u03c6, have that {\u00ac \u03c6} is a consistent set\n--   have hax := @comphelper agents (formCLK agents) formulaCLK \u03c6 (nprfalseCLK ha) hnax,\n--   -- with Lindenbaum, extend {\u00ac \u03c6} into a maximally consistent set\n--   have hmax := lindenbaum {\u00ac\u03c6} hax,\n--   simp at *, \n--   cases hmax with s hmax, \n--   cases hmax with hmax hn\u03c6,\n--   -- show that \u03c6 is not globally valid, \n--   -- by showing that there exists some model where \u03c6 is not valid.\n--   simp[global_valid],\n--   -- let that model be the canonical model\n--   apply exists.intro (canonical_model_CLK ha),\n--   -- in the canonical model (M) there exists some state (s) where \u00ac M s \u22a8 \u03c6\n--   simp[valid_m],\n--   -- let that state (s) be the maximally consistent set extended from {\u00ac \u03c6}\n--   apply exists.intro (subtype.mk s hmax),\n--   -- assume by contradiction that M s \u22a8 \u03c6\n--   intro hf,\n--   -- by the truth lemma \u03c6 \u2208 s\n--   have h\u03c6, from (truth_lemma_CL ha \u03c6 (subtype.mk s hmax)).mp hf,\n--   -- in that state (s), \u03c6 \u2208 s, so we do not have \u00ac \u03c6 \u2208 s (by consistency)\n--   -- contradiction with hn\u03c6\n--   apply contra_containts_pr_false hmax h\u03c6 hn\u03c6,\n-- end\n\nend canonical", "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/completeness/completenessCLK.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.651354857898194, "lm_q1q2_score": 0.491717543996381}}
{"text": "import algebra.camera.option\n\nuniverse u\n\ninductive sum_camera (\u03b1 \u03b2 : Type u)\n| cinl : \u03b1 \u2192 sum_camera\n| cinr : \u03b2 \u2192 sum_camera\n| invalid : sum_camera\n\nnamespace sum_camera\n\ninfixr ` \u2295\u2096 `:30 := sum_camera\n\nlemma cinl_injective {\u03b1 \u03b2 : Type u} : function.injective (cinl : \u03b1 \u2192 sum_camera \u03b1 \u03b2) :=\nby intros x y h; cases h; refl\n\nlemma cinr_injective {\u03b1 \u03b2 : Type u} : function.injective (cinr : \u03b2 \u2192 sum_camera \u03b1 \u03b2) :=\nby intros x y h; cases h; refl\n\ninductive eq_at_prop {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] (n : \u2115) : \u03b1 \u2295\u2096 \u03b2 \u2192 \u03b1 \u2295\u2096 \u03b2 \u2192 Prop\n| cinl : \u03a0 {a b : \u03b1}, a =[n] b \u2192 eq_at_prop (cinl a) (cinl b)\n| cinr : \u03a0 {a b : \u03b2}, a =[n] b \u2192 eq_at_prop (cinr a) (cinr b)\n| invalid : eq_at_prop invalid invalid\n\ninstance ofe {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] : ofe (\u03b1 \u2295\u2096 \u03b2) := {\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\u2081 b\u2081 hab\u2081 a\u2082 b\u2082 hab\u2082,\n    { cases c; cases hbc with hbc,\n      refine eq_at_prop.cinl _, transitivity b\u2081; assumption, },\n    { cases c; cases hbc with hbc,\n      refine eq_at_prop.cinr _, transitivity b\u2082; 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 {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] :\n  is_nonexpansive (cinl : \u03b1 \u2192 \u03b1 \u2295\u2096 \u03b2) :=\n\u03bb m a b, eq_at_prop.cinl\n\nlemma cinr_is_nonexpansive {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] :\n  is_nonexpansive (cinr : \u03b2 \u2192 \u03b1 \u2295\u2096 \u03b2) :=\n\u03bb m a b, eq_at_prop.cinr\n\n@[simp] lemma cinl_eq_at_cinl {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] {n : \u2115} {a b : \u03b1} :\n  (cinl a : \u03b1 \u2295\u2096 \u03b2) =[n] cinl b \u2194 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 {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] {n : \u2115} {a b : \u03b2} :\n  (cinr a : \u03b1 \u2295\u2096 \u03b2) =[n] cinr b \u2194 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 {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] {n : \u2115} {a : \u03b1} {b : \u03b1 \u2295\u2096 \u03b2} :\n  cinl a =[n] b \u2192 \u2203 b', b = cinl b' :=\nbegin\n  rintro (h | h | h),\n  exact \u27e8_, rfl\u27e9,\nend\n\nlemma cinr_eq_at {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] {n : \u2115} {a : \u03b2} {b : \u03b1 \u2295\u2096 \u03b2} :\n  cinr a =[n] b \u2192 \u2203 b', b = cinr b' :=\nbegin\n  rintro (h | h | h),\n  exact \u27e8_, rfl\u27e9,\nend\n\nlemma invalid_eq_at {\u03b1 \u03b2 : Type u} [ofe \u03b1] [ofe \u03b2] {n : \u2115} {b : \u03b1 \u2295\u2096 \u03b2} :\n  invalid =[n] b \u2192 b = invalid :=\nbegin\n  rintro (h | h | h),\n  refl,\nend\n\ndef mul {\u03b1 \u03b2 : Type u} [comm_semigroup \u03b1] [comm_semigroup \u03b2] : \u03b1 \u2295\u2096 \u03b2 \u2192 \u03b1 \u2295\u2096 \u03b2 \u2192 \u03b1 \u2295\u2096 \u03b2\n| (cinl a) (cinl b) := cinl (a * b)\n| (cinr a) (cinr b) := cinr (a * b)\n| _ _ := invalid\n\ninstance comm_semigroup {\u03b1 \u03b2 : Type u} [comm_semigroup \u03b1] [comm_semigroup \u03b2] :\n  comm_semigroup (\u03b1 \u2295\u2096 \u03b2) := {\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 {\u03b1 \u03b2 : Type u} [comm_semigroup \u03b1] [comm_semigroup \u03b2] {a b : \u03b1} :\n  (cinl a : \u03b1 \u2295\u2096 \u03b2) * cinl b = cinl (a * b) := rfl\n\nlemma cinr_mul_cinr {\u03b1 \u03b2 : Type u} [comm_semigroup \u03b1] [comm_semigroup \u03b2] {a b : \u03b2} :\n  (cinr a : \u03b1 \u2295\u2096 \u03b2) * cinr b = cinr (a * b) := rfl\n\nlemma cinl_eq_mul {\u03b1 \u03b2 : Type u} [comm_semigroup \u03b1] [comm_semigroup \u03b2] {a : \u03b1} {b c : \u03b1 \u2295\u2096 \u03b2} :\n  cinl a = b * c \u2192 \u2203 b' c', b = cinl b' \u2227 c = cinl c' :=\nbegin\n  cases b; cases c,\n  repeat { intro h, cases h, },\n  exact \u27e8b, c, rfl, rfl\u27e9,\nend\n\nlemma cinr_eq_mul {\u03b1 \u03b2 : Type u} [comm_semigroup \u03b1] [comm_semigroup \u03b2] {a : \u03b2} {b c : \u03b1 \u2295\u2096 \u03b2} :\n  cinr a = b * c \u2192 \u2203 b' c', b = cinr b' \u2227 c = cinr c' :=\nbegin\n  cases b; cases c,\n  repeat { intro h, cases h, },\n  exact \u27e8b, c, rfl, rfl\u27e9,\nend\n\ndef validn {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] : \u03b1 \u2295\u2096 \u03b2 \u2192 sprop\n| (cinl a) := camera.validn a\n| (cinr a) := camera.validn a\n| invalid := \u22a5\n\ndef core {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] : \u03b1 \u2295\u2096 \u03b2 \u2192 option (\u03b1 \u2295\u2096 \u03b2)\n| (cinl a) := (camera.core a).map cinl\n| (cinr a) := (camera.core a).map cinr\n| invalid := some invalid\n\ndef extend {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] {n : \u2115} : \u03a0 {a b\u2081 b\u2082 : \u03b1 \u2295\u2096 \u03b2},\n  validn a n \u2192 a =[n] b\u2081 * b\u2082 \u2192 (\u03b1 \u2295\u2096 \u03b2) \u00d7 (\u03b1 \u2295\u2096 \u03b2)\n| (cinl a) (cinl b\u2081) (cinl b\u2082) 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\u2081) (cinr b\u2082) 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\u2081) (cinr b\u2082) va hab := by exfalso; cases hab\n| (cinl a) (cinl b\u2081) invalid va hab := by exfalso; cases hab\n| (cinl a) (cinr b\u2081) b\u2082 va hab := by exfalso; cases b\u2082; cases hab\n| (cinl a) invalid b\u2082 va hab := by exfalso; cases hab\n| (cinr a) (cinr b\u2081) (cinl b\u2082) va hab := by exfalso; cases hab\n| (cinr a) (cinr b\u2081) invalid va hab := by exfalso; cases hab\n| (cinr a) (cinl b\u2081) b\u2082 va hab := by exfalso; cases b\u2082; cases hab\n| (cinr a) invalid b\u2082 va hab := by exfalso; cases hab\n| invalid _ b\u2082 va hab := by exfalso; cases va\n\nprivate lemma mul_is_nonexpansive {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] :\n  is_nonexpansive (function.uncurry ((*) : \u03b1 \u2295\u2096 \u03b2 \u2192 \u03b1 \u2295\u2096 \u03b2 \u2192 \u03b1 \u2295\u2096 \u03b2)) :=\nbegin\n  rintros n \u27e8a, b\u27e9 \u27e8c, d\u27e9 \u27e8h\u2081, h\u2082\u27e9,\n  cases h\u2081,\n  case invalid { refl, },\n  { cases h\u2082,\n    case cinr { refl, },\n    case invalid { refl, },\n    refine cinl_is_nonexpansive _,\n    refine camera.mul_eq_at _ _; assumption, },\n  { cases h\u2082,\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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] {a : \u03b1} {ca : \u03b1 \u2295\u2096 \u03b2} :\n  (cinl a : \u03b1 \u2295\u2096 \u03b2).core = some ca \u2192 \u2203 ca', ca = cinl ca' \u2227 camera.core a = some ca' :=\nbegin\n  intro h,\n  cases ca,\n  { refine \u27e8ca, rfl, _\u27e9,\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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] {a : \u03b2} {ca : \u03b1 \u2295\u2096 \u03b2} :\n  (cinr a : \u03b1 \u2295\u2096 \u03b2).core = some ca \u2192 \u2203 ca', ca = cinr ca' \u2227 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 \u27e8ca, rfl, _\u27e9,\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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2]\n  (a : \u03b1 \u2295\u2096 \u03b2) {ca : \u03b1 \u2295\u2096 \u03b2} : core a = some ca \u2192 ca * a = a :=\nbegin\n  intro h,\n  cases a,\n  { obtain \u27e8ca, rfl, hca\u27e9 := cinl_core_eq_some h,\n    exact congr_arg cinl (camera.core_mul_self _ hca), },\n  { obtain \u27e8ca, rfl, hca\u27e9 := 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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2]\n  (a : \u03b1 \u2295\u2096 \u03b2) {ca : \u03b1 \u2295\u2096 \u03b2} : core a = some ca \u2192 core ca = some ca :=\nbegin\n  intro h,\n  cases a,\n  { obtain \u27e8ca, rfl, hca\u27e9 := cinl_core_eq_some h,\n    simp only [core, option.map_eq_some', exists_eq_right],\n    exact camera.core_core _ hca, },\n  { obtain \u27e8ca, rfl, hca\u27e9 := 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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2]\n  (a b : \u03b1 \u2295\u2096 \u03b2) {ca : \u03b1 \u2295\u2096 \u03b2} : core a = some ca \u2192 a \u227c b \u2192\n    \u2203 cb : \u03b1 \u2295\u2096 \u03b2, core b = some cb :=\nbegin\n  rintros h \u27e8c, hc\u27e9,\n  cases a,\n  { obtain \u27e8ca, rfl, hca\u27e9 := cinl_core_eq_some h,\n    cases c; cases hc,\n    { obtain \u27e8d, hd\u27e9 := camera.core_mono_some a (a * c) hca \u27e8c, rfl\u27e9,\n      refine \u27e8cinl d, _\u27e9,\n      simp only [core, option.map_eq_some', exists_eq_right],\n      exact hd, },\n    { exact \u27e8invalid, rfl\u27e9, },\n    { exact \u27e8invalid, rfl\u27e9, }, },\n  { obtain \u27e8ca, rfl, hca\u27e9 := cinr_core_eq_some h,\n    cases c; cases hc,\n    { exact \u27e8invalid, rfl\u27e9, },\n    { obtain \u27e8d, hd\u27e9 := camera.core_mono_some a (a * c) hca \u27e8c, rfl\u27e9,\n      refine \u27e8cinr d, _\u27e9,\n      simp only [core, option.map_eq_some', exists_eq_right],\n      exact hd, },\n    { exact \u27e8invalid, rfl\u27e9, }, },\n  { cases hc,\n    exact \u27e8invalid, rfl\u27e9, },\nend\n\nprivate lemma core_mono {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2]\n  (a b : \u03b1 \u2295\u2096 \u03b2) {ca : \u03b1 \u2295\u2096 \u03b2} : core a = some ca \u2192 a \u227c b \u2192 core a \u227c core b :=\nbegin\n  rintros h \u27e8c, hc\u27e9,\n  cases a,\n  { obtain \u27e8ca, rfl, hca\u27e9 := cinl_core_eq_some h,\n    cases c; cases hc,\n    { obtain \u27e8d, hd\u27e9 := camera.core_mono a (a * c) hca \u27e8c, rfl\u27e9,\n      refine \u27e8d.map cinl, _\u27e9,\n      simp only [core, option.map_eq_some', exists_eq_right, \u2190 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 \u27e8some invalid, _\u27e9,\n      cases (cinl a).core, refl, cases val; refl, },\n    { refine \u27e8some invalid, _\u27e9,\n      cases (cinl a).core, refl, cases val; refl, }, },\n  { obtain \u27e8ca, rfl, hca\u27e9 := cinr_core_eq_some h,\n    cases c; cases hc,\n    { refine \u27e8some invalid, _\u27e9,\n      cases (cinr a).core, refl, cases val; refl, },\n    { obtain \u27e8d, hd\u27e9 := camera.core_mono a (a * c) hca \u27e8c, rfl\u27e9,\n      refine \u27e8d.map cinr, _\u27e9,\n      simp only [core, option.map_eq_some', exists_eq_right, \u2190 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 \u27e8some invalid, _\u27e9,\n      cases (cinr a).core, refl, cases val; refl, }, },\n  { cases hc, exact \u27e8some invalid, rfl\u27e9, },\nend\n\nprivate lemma validn_mul {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] (a b : \u03b1 \u2295\u2096 \u03b2) :\n  validn (a * b) \u2264 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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] (n : \u2115)\n  (a b\u2081 b\u2082 : \u03b1 \u2295\u2096 \u03b2) (ha : validn a n) (hb : a =[n] b\u2081 * b\u2082) :\n  a = (extend ha hb).1 * (extend ha hb).2 :=\nbegin\n  cases a,\n  { obtain \u27e8b, hb'\u27e9 := cinl_eq_at hb,\n    obtain \u27e8b\u2081, b\u2082, rfl, rfl\u27e9 := 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 \u27e8b, hb'\u27e9 := cinr_eq_at hb,\n    obtain \u27e8b\u2081, b\u2082, rfl, rfl\u27e9 := 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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] (n : \u2115)\n  (a b\u2081 b\u2082 : \u03b1 \u2295\u2096 \u03b2) (ha : validn a n) (hb : a =[n] b\u2081 * b\u2082) :\n  (extend ha hb).1 =[n] b\u2081 :=\nbegin\n  cases a,\n  { obtain \u27e8b, hb'\u27e9 := cinl_eq_at hb,\n    obtain \u27e8b\u2081, b\u2082, rfl, rfl\u27e9 := 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 \u27e8b, hb'\u27e9 := cinr_eq_at hb,\n    obtain \u27e8b\u2081, b\u2082, rfl, rfl\u27e9 := 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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] (n : \u2115)\n  (a b\u2081 b\u2082 : \u03b1 \u2295\u2096 \u03b2) (ha : validn a n) (hb : a =[n] b\u2081 * b\u2082) :\n  (extend ha hb).2 =[n] b\u2082 :=\nbegin\n  cases a,\n  { obtain \u27e8b, hb'\u27e9 := cinl_eq_at hb,\n    obtain \u27e8b\u2081, b\u2082, rfl, rfl\u27e9 := 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 \u27e8b, hb'\u27e9 := cinr_eq_at hb,\n    obtain \u27e8b\u2081, b\u2082, rfl, rfl\u27e9 := 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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] : camera (\u03b1 \u2295\u2096 \u03b2) := {\n  validn := \u27e8validn, 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\u27e9,\n  core := \u27e8core, 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\u27e9,\n  extend := @extend \u03b1 \u03b2 _ _,\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 {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] {a : \u03b1} {b : \u03b1 \u2295\u2096 \u03b2} {n : \u2115} :\n  \u2713[n] b * cinl a \u2192 \u2203 b', b = cinl b' :=\nbegin\n  intro h,\n  cases b,\n  exact \u27e8b, rfl\u27e9,\n  cases h,\n  cases h,\nend\n\nlemma mul_cinr_valid {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] {a : \u03b2} {b : \u03b1 \u2295\u2096 \u03b2} {n : \u2115} :\n  \u2713[n] b * cinr a \u2192 \u2203 b', b = cinr b' :=\nbegin\n  intro h,\n  cases b,\n  cases h,\n  exact \u27e8b, rfl\u27e9,\n  cases h,\nend\n\nlemma can_update_cinl {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] {a : \u03b1} {A : set \u03b1} :\n  a \u219d A \u2192 (cinl a : \u03b1 \u2295\u2096 \u03b2) \u219d cinl '' A :=\nbegin\n  rintros h n \u27e8c, hc\u27e9,\n  obtain \u27e8c, rfl\u27e9 := mul_cinl_valid hc,\n  obtain \u27e8f, hf\u27e9 := h n \u27e8c, hc\u27e9,\n  exact \u27e8\u27e8cinl f.val, f.prop\u27e9, f.val, hf, rfl\u27e9,\nend\n\nlemma can_update_cinr {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] {b : \u03b2} {B : set \u03b2} :\n  b \u219d B \u2192 (cinr b : \u03b1 \u2295\u2096 \u03b2) \u219d cinr '' B :=\nbegin\n  rintros h n \u27e8c, hc\u27e9,\n  obtain \u27e8c, rfl\u27e9 := mul_cinr_valid hc,\n  obtain \u27e8f, hf\u27e9 := h n \u27e8c, hc\u27e9,\n  exact \u27e8\u27e8cinr f.val, f.prop\u27e9, f.val, hf, rfl\u27e9,\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 `\u2713 b` assumption? -/\nlemma can_update_swap {\u03b1 \u03b2 : Type u} [camera \u03b1] [camera \u03b2] (a : \u03b1) (b : \u03b2) :\n  (\u2200 n, is_empty (time_frame a n)) \u2192 \u2713 b \u2192 (cinl a : \u03b1 \u2295\u2096 \u03b2) \u219d {cinr b} :=\nbegin\n  rintros ha hb n \u27e8c, hc\u27e9,\n  obtain \u27e8c, rfl\u27e9 := mul_cinl_valid hc,\n  cases (ha n).false \u27e8c, hc\u27e9,\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 {\u03b1 \u03b2 : Type*}\n  [topological_space \u03b1] [topological_space \u03b2] (h1 : connected_space \u03b1) (h2 : \u00ac connected_space \u03b2)\n  : \u00ac \u2203 (r : C(\u03b1, \u03b2)), function.surjective r :=\nbegin\n  rintros \u27e8r, h\u27e9,\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 _ _ \u27e8this.right\u27e9 (set.nonempty_iff_univ_nonempty.mpr this.left)\nend\n\nlemma ball_to_sphere_retraction_nogo (n : \u2115)\n  : \u00ac \u2203 (r : C(metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1,\n               metric.sphere (0 : euclidean_space \u211d (fin n)) 1)),\n      \u2200 x h, (r \u27e8x, metric.sphere_subset_closed_ball h\u27e9 : euclidean_space \u211d (fin n)) = x :=\nbegin\n  rw not_exists,\n  intros r H,\n  let i : C(metric.sphere (0 : euclidean_space \u211d (fin n)) 1,\n            metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1)\n        := \u27e8_, continuous_inclusion metric.sphere_subset_closed_ball\u27e9,\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 \u211d (fin n)) 1)\n          \u27f6 Top.of (metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1)\n        := i,\n    let r' : Top.of (metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1)\n          \u27f6 Top.of (metric.sphere (0 : euclidean_space \u211d (fin n)) 1)\n        := r,\n    cases n, { exact lt_irrefl 0 h },\n    by_cases n > 0,\n    { change i' \u226b r' = \ud835\udfd9 (Top.of (metric.sphere (0 : euclidean_space \u211d (fin (n + 1))) 1)) at this,\n      replace this := congr_arg (@category_theory.functor.map _ _ _ _ (singular_homology \u2124 n) _ _) this,\n      simp at this,\n      have H : category_theory.limits.is_zero ((singular_homology \u2124 n).obj (Top.of (metric.closed_ball (0 : euclidean_space \u211d (fin (n + 1))) 1))),\n      { obtain \u27e8P\u27e9 := homology_of_contractible_space \u2124 (Top.of (metric.closed_ball (0 : euclidean_space \u211d (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 \u211d _ _).convex \n                                        \u27e80, metric.mem_closed_ball_self zero_le_one\u27e9 },\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 \u27e8P\u27e9 := @nth_homology_of_n_sphere \u2124 _ _ 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''' : (\ud835\udfd9 (Module.of \u2124 \u2124) : \u2124 \u2192 \u2124) 1 = 0, { rw H'', refl },\n        exact @one_ne_zero \u2124 _ _ H''' } },\n    { simp at h, subst h,\n      refine connected_to_disconnected_surjection_nogo _ _ \u27e8r, _\u27e9,\n      { rw \u2190 is_connected_iff_connected_space,\n        refine convex.is_connected (strict_convex_closed_ball \u211d _ _).convex\n                                   \u27e80, metric.mem_closed_ball_self zero_le_one\u27e9 },\n      { let x0 : (metric.sphere (0 : euclidean_space \u211d (fin 1)) 1) := \u27e8(\u03bb _, (-1) : fin 1 \u2192 \u211d), _\u27e9,\n        swap, { simp [euclidean_space.norm_eq] },\n        let x1 : (metric.sphere (0 : euclidean_space \u211d (fin 1)) 1) := \u27e8(\u03bb _, 1 : fin 1 \u2192 \u211d), _\u27e9,\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 \u27e8t, _, ht\u27e9 := h',\n            have := @set.mem_univ (punit.{1} \u2295 punit.{1}), rw ht at this,\n            specialize this (sum.inr ()), cases this with _ h'', simp at h'', exact h'' },\n          { obtain \u27e8t, _, ht\u27e9 := h',\n            have := @set.mem_univ (punit.{1} \u2295 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 \u27e8x, hx\u27e9, 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 [\u2190 continuous_map.comp_apply, this], refl } } },\n  { simp at h, subst h, \n    suffices : is_empty \u21a5(metric.sphere (0 : euclidean_space \u211d (fin 0)) 1),\n    { obtain \u27e8h\u27e9 := this, exact h (r \u27e80, metric.mem_closed_ball_self zero_le_one\u27e9) },\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 `\u27ea`x`, `y`\u27eb` := @inner \u211d _ _ x y\n\nnoncomputable\ndef time_to_boundary (n : \u2115) (p q : euclidean_space \u211d (fin n)) : \u211d :=\n  (2 * \u27eaq - p, q\u27eb - real.sqrt (4 * \u27eaq - p, q\u27eb^2 + 4 * \u2225p - q\u2225^2 * (1 - \u2225q\u2225^2))) / (2 * \u2225p - q\u2225^2)\n\nnoncomputable\ndef time_to_boundary_aux (x : { tuple : \u211d \u00d7 \u211d \u00d7 \u211d // tuple.snd.fst > 0 \u2227 tuple.snd.snd \u2264 1 }) : \u211d :=\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 : \u2115) (pair : { x : metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1\n                                           \u00d7 metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1\n                                           // x.fst \u2260 x.snd })\n  := time_to_boundary n pair.val.fst pair.val.snd\n\nnoncomputable\ndef time_to_boundary'_aux (n : \u2115) (pair : { x : metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1\n                                              \u00d7 metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1\n                                              // x.fst \u2260 x.snd })\n  : { tuple : \u211d \u00d7 \u211d \u00d7 \u211d // tuple.snd.fst > 0 \u2227 tuple.snd.snd \u2264 1 } := {\n    val := \u27e8\u27eapair.val.snd.val - pair.val.fst.val, pair.val.snd\u27eb,\n            \u2225pair.val.fst.val - pair.val.snd.val\u2225,\n            \u2225pair.val.snd.val\u2225\u27e9,\n    property := by { split; simp, { rw [sub_eq_zero, \u2190 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 : \u2115)\n  : time_to_boundary' n  = time_to_boundary_aux \u2218 time_to_boundary'_aux n :=\nbegin\n  ext x, rcases x with \u27e8\u27e8\u27e8x1, h1\u27e9, \u27e8x2, h2\u27e9\u27e9, h\u27e9, refl\nend.\n\nlemma time_to_boundary'_continuous (n : \u2115) : continuous (time_to_boundary' n) :=\nbegin\n  rw time_to_boundary'_fact,\n  refine continuous.comp _ _,\n  { refine continuous.div _ _ _, { continuity }, { continuity },\n    { rintro \u27e8\u27e8a, b, c\u27e9, h1, h2\u27e9, 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 : \u211d} (ha : a \u2260 0) (h : discrim a b c \u2265 0) (x : \u211d) :\n  a * x * x + b * x + c = 0\n  \u2194 x = (-b + real.sqrt (discrim a b c)) / (2 * a) \u2228 x = (-b - real.sqrt (discrim a b c)) / (2 * a) :=\n  quadratic_eq_zero_iff ha (by { rw [\u2190 pow_two, real.sq_sqrt h] }) x\n\nlemma real.AM_GM2 (a b : \u211d) : 2 * a * b \u2264 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 : \u2115) (pair)\n  : time_to_boundary' n pair \u2022 pair.val.fst.val + (1 - time_to_boundary' n pair) \u2022 pair.val.snd.val\n  \u2208 metric.sphere (0 : euclidean_space \u211d (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, \u2190 mul_neg, \u2190 mul_add, \u2190 mul_add, mul_assoc, mul_assoc, \u2190 mul_sub],\n    symmetry,\n    rw [mul_comm t _, mul_comm, pow_two, \u2190 mul_assoc, \u2190 sub_eq_zero, add_sub_assoc],\n    rw real.quadratic_eq_zero_iff,\n    { right,\n      rw \u2190 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 [\u2190 real_inner_self_eq_norm_sq, real_inner_sub_sub_self, inner_sub_left], \n        rw [\u2190 neg_sq, neg_sub, \u2190 sub_mul, mul_pow, mul_comm],\n        congr, norm_cast,\n        rw [\u2190 mul_neg, neg_sub, \u2190 real_inner_self_eq_norm_sq,\n            sub_eq_add_neg, add_assoc, mul_comm (2 : \u211d)], refl },\n      { rw [\u2190 real_inner_self_eq_norm_sq, real_inner_sub_sub_self,\n            sub_eq_add_neg, add_assoc, mul_comm (2 : \u211d)], 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 [\u2190 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 : \u211d),\n      { rw [\u2190 neg_nonneg, \u2190 mul_neg, neg_sub],\n        refine mul_nonneg (mul_nonneg zero_le_four _) _,\n        { rw [\u2190 sub_eq_neg_add, add_sub_left_comm, add_comm, mul_comm, \u2190 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              \u2190 mem_closed_ball_zero_iff],\n          exact subtype.mem _ } },\n      { rw [add_comm, \u2190 add_sub_assoc, sub_nonneg, add_comm], apply real.AM_GM2 } } },\n  { ring_nf SOP,\n    rw [mul_assoc, \u2190 mul_neg, \u2190 mul_add, \u2190 mul_add, mul_assoc, mul_assoc, \u2190 mul_sub],\n    rw [\u2190 sub_eq_neg_add, add_sub_left_comm, add_comm _ (_ - _), mul_comm _ (2 : \u211d),\n        \u2190 real_inner_sub_sub_self, real_inner_self_eq_norm_sq],\n    rw [mul_comm _ (2 : \u211d), \u2190 mul_sub, \u2190 inner_sub_left, add_right_comm,\n        \u2190 sub_neg_eq_add, sub_nonneg],\n    refine le_trans (neg_le_abs_self _) _,\n    rw [\u2190 real_inner_smul_left, \u2190 real_inner_smul_left, smul_smul, mul_comm, \u2190 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 : \u211d) \u2264 (2 : \u211d))],\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 \u27e8\u27e8\u27e8p, hp\u27e9, \u27e8q, hq\u27e9\u27e9, h\u27e9,\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 : \u2115) (p q : euclidean_space \u211d (fin n)) \n  (h1 : p \u2208 metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1)\n  (h2 : q \u2208 metric.sphere (0 : euclidean_space \u211d (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 : \u2115)\n  (f : C(metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1,\n         metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1))\n  : \u2203 x : metric.closed_ball (0 : euclidean_space \u211d (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 \u211d (fin n)) 1\n              \u2192 { x : metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1\n                    \u00d7 metric.closed_ball (0 : euclidean_space \u211d (fin n)) 1\n                    // x.fst \u2260 x.snd } := \u03bb p, \u27e8\u27e8f p, p\u27e9, h p\u27e9,\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 \u211d (fin n)) 1,\n             metric.sphere (0 : euclidean_space \u211d (fin n)) 1) :=\n    continuous_map.comp \u27e8(\u03bb p, \u27e8time_to_boundary' n p \u2022 p.val.fst.val\n                                + (1 - time_to_boundary' n p) \u2022 p.val.snd.val,\n                                time_to_boundary'_lands_in_sphere n p\u27e9), _\u27e9\n                        \u27e8mk_pair, mk_pair_cont\u27e9,\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 \u27e8r, _\u27e9,\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 \u211d V] [finite_dimensional \u211d V]\n  : \u2200 (s : set V), convex \u211d s \u2192 is_compact s \u2192 set.nonempty s \u2192 \n    \u2200 (f : C(s, s)), \u2203 x, f x = x :=\nbegin\n  intros s h1 h2 h3,\n  have : affine_dim \u211d s < cardinal.aleph_0, \n  { apply @lt_of_le_of_lt _ _ _ (module.rank \u211d V),\n    { dsimp [affine_dim],\n      rw [\u2190 finite_dimensional.finrank_eq_dim, \u2190 finite_dimensional.finrank_eq_dim],\n      norm_cast,\n      apply submodule.finrank_le },\n    { rw \u2190 finite_dimensional.finrank_eq_dim, exact cardinal.nat_lt_aleph_0 _ } },\n  rw cardinal.lt_aleph_0 at this, \n  obtain \u27e8n, hn\u27e9 := this,\n  obtain \u27e8F\u27e9 := 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 \u27e8y, hy\u27e9 := brouwer_fixed_point_for_sphere n g,\n  refine \u27e8F.symm y, _\u27e9,\n  rw [\u2190 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 \u2228 (0xdfff < n \u2227 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\u2081 : 0xdfff < n) (h\u2082 : n < 0x110000) : is_valid_char n :=\nor.inr \u27e8h\u2081, h\u2082\u27e9\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\u27e8\u03bb c, c.val\u27e9\n\nnamespace char\nprotected def lt (a b : char) : Prop := a.val < b.val\nprotected def le (a b : char) : Prop := a.val \u2264 b.val\n\ninstance : has_lt char := \u27e8char.lt\u27e9\ninstance : has_le char := \u27e8char.le\u27e9\n\ninstance decidable_lt (a b : char) :  decidable (a < b) :=\nnat.decidable_lt _ _\n\ninstance decidable_le (a b : char) : decidable (a \u2264 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 : \u2200 {c d : char}, c.val = d.val \u2192 c = d\n| \u27e8v, h\u27e9 \u27e8_, _\u27e9 rfl := rfl\n\nlemma veq_of_eq : \u2200 {c d : char}, c = d \u2192 c.val = d.val\n| _ _ rfl := rfl\n\nlemma ne_of_vne {c d : char} (h : c.val \u2260 d.val) : c \u2260 d :=\n\u03bb h', absurd (veq_of_eq h') h\n\nlemma vne_of_ne {c d : char} (h : c \u2260 d) : c.val \u2260 d.val :=\n\u03bb h', absurd (eq_of_veq h') h\n\nend char\n\ninstance : decidable_eq char :=\n\u03bb i j, decidable_of_decidable_of_iff\n  (nat.decidable_eq i.val j.val) \u27e8char.eq_of_veq, char.veq_of_eq\u27e9\n\ninstance : inhabited char :=\n\u27e8'A'\u27e9\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\u2081 w\u2082 v\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} D]\n\nsection has_zero_morphisms\nvariables [has_zero_morphisms C] [has_zero_morphisms D]\n\nnamespace functor\n\nsection map\nvariables (F : C \u2964 D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type w\u2081}\n\n/-- The image of a bicone under a functor. -/\n@[simps]\ndef map_bicone {f : J \u2192 C} (b : bicone f) : bicone (F.obj \u2218 f) :=\n{ X := F.obj b.X,\n  \u03c0 := \u03bb j, F.map (b.\u03c0 j),\n  \u03b9 := \u03bb j, F.map (b.\u03b9 j),\n  \u03b9_\u03c0 := \u03bb j j',\n  begin\n    rw \u2190 F.map_comp,\n    split_ifs,\n    { subst h,\n      simp only [bicone_\u03b9_\u03c0_self, category_theory.functor.map_id, eq_to_hom_refl] },\n    { rw [bicone_\u03b9_\u03c0_ne _ h, F.map_zero] }\n  end }\n\nlemma map_bicone_whisker {K : Type w\u2082} {g : K \u2243 J} {f : J \u2192 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 [\u2190 F.map_comp, b.inl_fst, F.map_id],\n  inl_snd' := by rw [\u2190 F.map_comp, b.inl_snd, F.map_zero],\n  inr_fst' := by rw [\u2190 F.map_comp, b.inr_fst, F.map_zero],\n  inr_snd' := by rw [\u2190 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\u2081} {K : Type w\u2082}\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 \u2218 f`. -/\nclass preserves_biproduct (f : J \u2192 C) (F : C \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {b : bicone f}, b.is_bilimit \u2192 (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 \u2218 f`. -/\ndef is_bilimit_of_preserves {f : J \u2192 C} (F : C \u2964 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 \u2192 C`. -/\nclass preserves_biproducts_of_shape (F : C \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {f : J \u2192 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {J : Type w\u2081}, 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 \u2964 D) [preserves_zero_morphisms F]\n  [hp : preserves_biproducts.{max w\u2081 w\u2082} F] : preserves_biproducts.{w\u2081} F :=\n\u27e8\u03bb J, \u27e8\u03bb f, \u27e8\u03bb 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\u2082}).inv_fun ib))\u27e9\u27e9\u27e9\n\n@[priority 100]\ninstance preserves_finite_biproducts_of_preserves_biproducts (F : C \u2964 D)\n  [preserves_zero_morphisms F] [preserves_biproducts.{w\u2081} F] : preserves_finite_biproducts F :=\n{ preserves := \u03bb 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {b : binary_bicone X Y}, b.is_bilimit \u2192 (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 \u2964 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D) [preserves_zero_morphisms F]\n  (X Y : C) [preserves_biproduct (pair_function X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, tidy, }) } }\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_biproducts (F : C \u2964 D)\n  [preserves_zero_morphisms F] [preserves_biproducts_of_shape walking_pair F] :\n  preserves_binary_biproducts F :=\n{ preserves := \u03bb 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\u2081} (F : C \u2964 D) [preserves_zero_morphisms F] (f : J \u2192 C)\n  [has_biproduct f] [preserves_biproduct f F]\n\ninstance has_biproduct_of_preserves : has_biproduct (F.obj \u2218 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 (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f)`. -/\n@[simp]\ndef map_biproduct : F.obj (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f) :=\nbiproduct.unique_up_to_iso _ (preserves_biproduct.preserves (biproduct.is_bilimit _))\n\nlemma map_biproduct_hom : (map_biproduct F f).hom = biproduct.lift (\u03bb j, F.map (biproduct.\u03c0 f j)) :=\nrfl\n\nlemma map_biproduct_inv : (map_biproduct F f).inv = biproduct.desc (\u03bb j, F.map (biproduct.\u03b9 f j)) :=\nrfl\n\nend bicone\n\nvariables (F : C \u2964 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 \u229e Y) \u2245 F.obj X \u229e F.obj Y`. -/\n@[simp]\ndef map_biprod : F.obj (X \u229e Y) \u2245 F.obj X \u229e 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 \u2964 D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type w\u2081} (f : J \u2192 C) [has_biproduct f] [preserves_biproduct f F]\n  {W : C}\n\nlemma biproduct.map_lift_map_biprod (g : \u03a0 j, W \u27f6 f j) :\n  F.map (biproduct.lift g) \u226b (F.map_biproduct f).hom = biproduct.lift (\u03bb j, F.map (g j)) :=\nby { ext, simp [\u2190 F.map_comp] }\n\nlemma biproduct.map_biproduct_inv_map_desc (g : \u03a0 j, f j \u27f6 W) :\n  (F.map_biproduct f).inv \u226b F.map (biproduct.desc g) = biproduct.desc (\u03bb j, F.map (g j)) :=\nby { ext, simp [\u2190 F.map_comp] }\n\nlemma biproduct.map_biproduct_hom_desc (g : \u03a0 j, f j \u27f6 W) :\n  (F.map_biproduct f).hom \u226b biproduct.desc (\u03bb j, F.map (g j)) = F.map (biproduct.desc g) :=\nby rw [\u2190 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 \u27f6 X) (g : W \u27f6 Y) :\n  F.map (biprod.lift f g) \u226b (F.map_biprod X Y).hom = biprod.lift (F.map f) (F.map g) :=\nby ext; simp [\u2190 F.map_comp]\n\nlemma biprod.lift_map_biprod (f : W \u27f6 X) (g : W \u27f6 Y) :\n  biprod.lift (F.map f) (F.map g) \u226b (F.map_biprod X Y).inv = F.map (biprod.lift f g) :=\nby rw [\u2190 biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n\nlemma biprod.map_biprod_inv_map_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n  (F.map_biprod X Y).inv \u226b F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) :=\nby ext; simp [\u2190 F.map_comp]\n\nlemma biprod.map_biprod_hom_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n (F.map_biprod X Y).hom \u226b biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) :=\nby rw [\u2190 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 \u2964 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 \u2192 C} [preserves_biproduct f F] :\n  preserves_limit (discrete.functor f) F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C} [preserves_limit (discrete.functor f) F] :\n  preserves_biproduct f F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C} [preserves_biproduct f F] :\n  preserves_colimit (discrete.functor f) F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C}\n  [preserves_colimit (discrete.functor f) F] : preserves_biproduct f F :=\n{ preserves := \u03bb 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 := \u03bb 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 := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 := \u03bb 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 := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 := \u03bb 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 := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 := \u03bb 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 := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 := \u03bb 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 \u2194 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 \u22a4 x y :=\n  iff.mpr (submodule.quotient.eq \u22a4) 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 \u22a5 x y \u2194 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\u2081 : submodule R M} {U\u2082 : submodule R M} {x : M} {y : M} (HU : U\u2081 \u2264 U\u2082) (hxy : smodeq U\u2081 x y) :\n    smodeq U\u2082 x y :=\n  iff.mpr (submodule.quotient.eq U\u2082) (HU (iff.mp (submodule.quotient.eq U\u2081) 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\u2081 : M} {x\u2082 : M} {y\u2081 : M} {y\u2082 : M} (hxy\u2081 : smodeq U x\u2081 y\u2081)\n    (hxy\u2082 : smodeq U x\u2082 y\u2082) : smodeq U (x\u2081 + x\u2082) (y\u2081 + y\u2082) :=\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 \u2022 x) (c \u2022 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 \u2194 x \u2208 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) \u2208 V) => this)\n      (Eq.symm (linear_map.map_sub f x y) \u25b8 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 {\u03b1} [comm_semiring \u03b1] (a x : \u03b1) (n : \u2115) (b : \u03b1) := a * x ^ n + b\n\nmeta structure cache :=\n(\u03b1 : expr)\n(univ : level)\n(comm_semiring_inst : expr)\n\nmeta def mk_cache (e : expr) : tactic cache :=\ndo \u03b1 \u2190 infer_type e,\n   c \u2190 mk_app ``comm_semiring [\u03b1] >>= mk_instance,\n   u \u2190 mk_meta_univ,\n   infer_type \u03b1 >>= unify (expr.sort (level.succ u)),\n   u \u2190 get_univ_assignment u,\n   return \u27e8\u03b1, u, c\u27e9\n\nmeta def cache.cs_app (c : cache) (n : name) : list expr \u2192 expr :=\n(@expr.const tt n [c.univ] c.\u03b1 c.comm_semiring_inst).mk_app\n\nmeta def cache.mk_app (c : cache) (n inst : name) (l : list expr) : tactic expr :=\ndo m \u2190 mk_instance ((expr.const inst [c.univ] : expr) c.\u03b1),\n   return $ (@expr.const tt n [c.univ] c.\u03b1 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 \u00d7 \u2115) (b : horner_expr) : horner_expr\n\nmeta def horner_expr.e : horner_expr \u2192 expr\n| (horner_expr.const e) := e\n| (horner_expr.xadd e _ _ _ _) := e\n\nmeta instance : has_coe horner_expr expr := \u27e8horner_expr.e\u27e9\n\nmeta def horner_expr.xadd' (c : cache) (a : horner_expr) (x : expr) (n : expr \u00d7 \u2115) (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 \u2192 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 \u2192 tactic format\n| (const e) := pp e\n| (xadd e a x (_, n) b) := do\n  pa \u2190 a.pp, pb \u2190 b.pp, px \u2190 pp x,\n  return $ \"(\" ++ pa ++ \") * (\" ++ px ++ \")^\" ++ to_string n ++ \" + \" ++ pb\n\nmeta instance : has_to_tactic_format horner_expr := \u27e8horner_expr.pp\u27e9\n\nmeta def horner_expr.refl_conv (e : horner_expr) : tactic (horner_expr \u00d7 expr) :=\ndo p \u2190 mk_eq_refl e, return (e, p)\n\ntheorem zero_horner {\u03b1} [comm_semiring \u03b1] (x n b) :\n  @horner \u03b1 _ 0 x n b = b :=\nby simp [horner]\n\ntheorem horner_horner {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 n\u2082 b n')\n  (h : n\u2081 + n\u2082 = n') :\n  @horner \u03b1 _ (horner a\u2081 x n\u2081 0) x n\u2082 b = horner a\u2081 x n' b :=\nby simp [h.symm, horner, pow_add, mul_assoc]\n\nmeta def eval_horner (c : cache) : horner_expr \u2192 expr \u2192 expr \u00d7 \u2115 \u2192 horner_expr \u2192 tactic (horner_expr \u00d7 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\u2081 x\u2081 n\u2081 b\u2081) x n b :=\n  if x\u2081 = x \u2227 b\u2081.e.to_nat = some 0 then do\n    (n', h) \u2190 mk_app ``has_add.add [n\u2081.1, n.1] >>= norm_num,\n    return (xadd' c a\u2081 x (n', n\u2081.2 + n.2) b,\n      c.cs_app ``horner_horner [a\u2081, x, n\u2081.1, n.1, b, n', h])\n  else (xadd' c ha x n b).refl_conv\n\ntheorem const_add_horner {\u03b1} [comm_semiring \u03b1] (k a x n b b') (h : k + b = b') :\n  k + @horner \u03b1 _ a x n b = horner a x n b' :=\nby simp [h.symm, horner]\n\ntheorem horner_add_const {\u03b1} [comm_semiring \u03b1] (a x n b k b') (h : b + k = b') :\n  @horner \u03b1 _ a x n b + k = horner a x n b' :=\nby simp [h.symm, horner]\n\ntheorem horner_add_horner_lt {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 k a' b')\n  (h\u2081 : n\u2081 + k = n\u2082) (h\u2082 : (a\u2081 + horner a\u2082 x k 0 : \u03b1) = a') (h\u2083 : b\u2081 + b\u2082 = b') :\n  @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2081 b' :=\nby simp [h\u2082.symm, h\u2083.symm, h\u2081.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]\n\ntheorem horner_add_horner_gt {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 k a' b')\n  (h\u2081 : n\u2082 + k = n\u2081) (h\u2082 : (horner a\u2081 x k 0 + a\u2082 : \u03b1) = a') (h\u2083 : b\u2081 + b\u2082 = b') :\n  @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2082 b' :=\nby simp [h\u2082.symm, h\u2083.symm, h\u2081.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]\n\ntheorem horner_add_horner_eq {\u03b1} [comm_semiring \u03b1] (a\u2081 x n b\u2081 a\u2082 b\u2082 a' b' t)\n  (h\u2081 : a\u2081 + a\u2082 = a') (h\u2082 : b\u2081 + b\u2082 = b') (h\u2083 : horner a' x n b' = t) :\n  @horner \u03b1 _ a\u2081 x n b\u2081 + horner a\u2082 x n b\u2082 = t :=\nby simp [h\u2083.symm, h\u2082.symm, h\u2081.symm, horner, add_mul, mul_comm]\n\nmeta def eval_add (c : cache) : horner_expr \u2192 horner_expr \u2192 tactic (horner_expr \u00d7 expr)\n| (const e\u2081) (const e\u2082) := do\n  (e, p) \u2190 mk_app ``has_add.add [e\u2081, e\u2082] >>= norm_num,\n  return (const e, p)\n| he\u2081@(const e\u2081) he\u2082@(xadd e\u2082 a x n b) :=\n  if e\u2081.to_nat = some 0 then  do\n    p \u2190 mk_app ``zero_add [e\u2082],\n    return (he\u2082, p)\n  else do\n    (b', h) \u2190 eval_add he\u2081 b,\n    return (xadd' c a x n b',\n      c.cs_app ``const_add_horner [e\u2081, a, x, n.1, b, b', h])\n| he\u2081@(xadd e\u2081 a x n b) he\u2082@(const e\u2082) :=\n  if e\u2082.to_nat = some 0 then do\n    p \u2190 mk_app ``add_zero [e\u2081],\n    return (he\u2081, p)\n  else do\n    (b', h) \u2190 eval_add b he\u2082,\n    return (xadd' c a x n b',\n      c.cs_app ``horner_add_const [a, x, n.1, b, e\u2082, b', h])\n| he\u2081@(xadd e\u2081 a\u2081 x\u2081 n\u2081 b\u2081) he\u2082@(xadd e\u2082 a\u2082 x\u2082 n\u2082 b\u2082) :=\n  if expr.lex_lt x\u2081 x\u2082 then do\n    (b', h) \u2190 eval_add b\u2081 he\u2082,\n    return (xadd' c a\u2081 x\u2081 n\u2081 b',\n      c.cs_app ``horner_add_const [a\u2081, x\u2081, n\u2081.1, b\u2081, e\u2082, b', h])\n  else if x\u2081 \u2260 x\u2082 then do\n    (b', h) \u2190 eval_add he\u2081 b\u2082,\n    return (xadd' c a\u2082 x\u2082 n\u2082 b',\n      c.cs_app ``const_add_horner [e\u2081, a\u2082, x\u2082, n\u2082.1, b\u2082, b', h])\n  else if n\u2081.2 < n\u2082.2 then do\n    let k := n\u2082.2 - n\u2081.2,\n    ek \u2190 expr.of_nat (expr.const `nat []) k,\n    (_, h\u2081) \u2190 mk_app ``has_add.add [n\u2081.1, ek] >>= norm_num,\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    (a', h\u2082) \u2190 eval_add a\u2081 (xadd' c a\u2082 x\u2081 (ek, k) (const \u03b10)),\n    (b', h\u2083) \u2190 eval_add b\u2081 b\u2082,\n    return (xadd' c a' x\u2081 n\u2081 b',\n      c.cs_app ``horner_add_horner_lt [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, ek, a', b', h\u2081, h\u2082, h\u2083])\n  else if n\u2081 \u2260 n\u2082 then do\n    let k := n\u2081.2 - n\u2082.2,\n    ek \u2190 expr.of_nat (expr.const `nat []) k,\n    (_, h\u2081) \u2190 mk_app ``has_add.add [n\u2082.1, ek] >>= norm_num,\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    (a', h\u2082) \u2190 eval_add (xadd' c a\u2081 x\u2081 (ek, k) (const \u03b10)) a\u2082,\n    (b', h\u2083) \u2190 eval_add b\u2081 b\u2082,\n    return (xadd' c a' x\u2081 n\u2082 b',\n      c.cs_app ``horner_add_horner_gt [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, ek, a', b', h\u2081, h\u2082, h\u2083])\n  else do\n    (a', h\u2081) \u2190 eval_add a\u2081 a\u2082,\n    (b', h\u2082) \u2190 eval_add b\u2081 b\u2082,\n    (t, h\u2083) \u2190 eval_horner c a' x\u2081 n\u2081 b',\n    return (t, c.cs_app ``horner_add_horner_eq\n      [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, b\u2082, a', b', t, h\u2081, h\u2082, h\u2083])\n\ntheorem horner_neg {\u03b1} [comm_ring \u03b1] (a x n b a' b')\n  (h\u2081 : -a = a') (h\u2082 : -b = b') :\n  -@horner \u03b1 _ a x n b = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.symm, horner]\n\nmeta def eval_neg (c : cache) : horner_expr \u2192 tactic (horner_expr \u00d7 expr)\n| (const e) := do\n  (e', p) \u2190 mk_app ``has_neg.neg [e] >>= norm_num,\n  return (const e', p)\n| (xadd e a x n b) := do\n  (a', h\u2081) \u2190 eval_neg a,\n  (b', h\u2082) \u2190 eval_neg b,\n  p \u2190 c.mk_app ``horner_neg ``comm_ring [a, x, n.1, b, a', b', h\u2081, h\u2082],\n  return (xadd' c a' x n b', p)\n\ntheorem horner_const_mul {\u03b1} [comm_semiring \u03b1] (c a x n b a' b')\n  (h\u2081 : c * a = a') (h\u2082 : c * b = b') :\n  c * @horner \u03b1 _ a x n b = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.symm, horner, mul_add, mul_assoc]\n\ntheorem horner_mul_const {\u03b1} [comm_semiring \u03b1] (a x n b c a' b')\n  (h\u2081 : a * c = a') (h\u2082 : b * c = b') :\n  @horner \u03b1 _ a x n b * c = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.symm, horner, add_mul, mul_right_comm]\n\nmeta def eval_const_mul (c : cache) (k : expr) :\n  horner_expr \u2192 tactic (horner_expr \u00d7 expr)\n| (const e) := do\n  (e', p) \u2190 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\u2081) \u2190 eval_const_mul a,\n  (b', h\u2082) \u2190 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\u2081, h\u2082])\n\ntheorem horner_mul_horner_zero {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 aa t)\n  (h\u2081 : @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 * a\u2082 = aa)\n  (h\u2082 : horner aa x n\u2082 0 = t) :\n  horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 0 = t :=\nby rw [\u2190 h\u2082, \u2190 h\u2081];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\ntheorem horner_mul_horner {\u03b1} [comm_semiring \u03b1]\n  (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 aa haa ab bb t)\n  (h\u2081 : @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 * a\u2082 = aa)\n  (h\u2082 : horner aa x n\u2082 0 = haa)\n  (h\u2083 : a\u2081 * b\u2082 = ab) (h\u2084 : b\u2081 * b\u2082 = bb)\n  (H : haa + horner ab x n\u2081 bb = t) :\n  horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 b\u2082 = t :=\nby rw [\u2190 H, \u2190 h\u2082, \u2190 h\u2081, \u2190 h\u2083, \u2190 h\u2084];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\nmeta def eval_mul (c : cache) : horner_expr \u2192 horner_expr \u2192 tactic (horner_expr \u00d7 expr)\n| (const e\u2081) (const e\u2082) := do\n  (e', p) \u2190 mk_app ``has_mul.mul [e\u2081, e\u2082] >>= norm_num,\n  return (const e', p)\n| (const e\u2081) e\u2082 :=\n  match e\u2081.to_nat with\n  | (some 0) := do\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    p \u2190 mk_app ``zero_mul [e\u2082],\n    return (const \u03b10, p)\n  | (some 1) := do\n    p \u2190 mk_app ``one_mul [e\u2082],\n    return (e\u2082, p)\n  | _ := eval_const_mul c e\u2081 e\u2082\n  end\n| e\u2081 he\u2082@(const e\u2082) := do\n  p\u2081 \u2190 mk_app ``mul_comm [e\u2081, e\u2082],\n  (e', p\u2082) \u2190 eval_mul he\u2082 e\u2081,\n  p \u2190 mk_eq_trans p\u2081 p\u2082, return (e', p)\n| he\u2081@(xadd e\u2081 a\u2081 x\u2081 n\u2081 b\u2081) he\u2082@(xadd e\u2082 a\u2082 x\u2082 n\u2082 b\u2082) :=\n  if expr.lex_lt x\u2081 x\u2082 then do\n    (a', h\u2081) \u2190 eval_mul a\u2081 he\u2082,\n    (b', h\u2082) \u2190 eval_mul b\u2081 he\u2082,\n    return (xadd' c a' x\u2081 n\u2081 b',\n      c.cs_app ``horner_mul_const [a\u2081, x\u2081, n\u2081.1, b\u2081, e\u2082, a', b', h\u2081, h\u2082])\n  else if x\u2081 \u2260 x\u2082 then do\n    (a', h\u2081) \u2190 eval_mul he\u2081 a\u2082,\n    (b', h\u2082) \u2190 eval_mul he\u2081 b\u2082,\n    return (xadd' c a' x\u2082 n\u2082 b',\n      c.cs_app ``horner_const_mul [e\u2081, a\u2082, x\u2082, n\u2082.1, b\u2082, a', b', h\u2081, h\u2082])\n  else do\n    (aa, h\u2081) \u2190 eval_mul he\u2081 a\u2082,\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    (haa, h\u2082) \u2190 eval_horner c aa x\u2081 n\u2082 (const \u03b10),\n    if b\u2082.e.to_nat = some 0 then\n      return (haa, c.cs_app ``horner_mul_horner_zero\n        [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, n\u2082.1, aa, haa, h\u2081, h\u2082])\n    else do\n      (ab, h\u2083) \u2190 eval_mul a\u2081 b\u2082,\n      (bb, h\u2084) \u2190 eval_mul b\u2081 b\u2082,\n      (t, H) \u2190 eval_add c haa (xadd' c ab x\u2081 n\u2081 bb),\n      return (t, c.cs_app ``horner_mul_horner\n        [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, aa, haa, ab, bb, t, h\u2081, h\u2082, h\u2083, h\u2084, H])\n\ntheorem horner_pow {\u03b1} [comm_semiring \u03b1] (a x n m n' a')\n  (h\u2081 : n * m = n') (h\u2082 : a ^ m = a') :\n  @horner \u03b1 _ a x n 0 ^ m = horner a' x n' 0 :=\nby simp [h\u2081.symm, h\u2082.symm, horner, mul_pow, pow_mul]\n\nmeta def eval_pow (c : cache) : horner_expr \u2192 expr \u00d7 \u2115 \u2192 tactic (horner_expr \u00d7 expr)\n| e (_, 0) := do\n  \u03b11 \u2190 expr.of_nat c.\u03b1 1,\n  p \u2190 mk_app ``pow_zero [e],\n  return (const \u03b11, p)\n| e (_, 1) := do\n  p \u2190 mk_app ``pow_one [e],\n  return (e, p)\n| (const e) (e\u2082, m) := do\n  (e', p) \u2190 mk_app ``monoid.pow [e, e\u2082] >>= 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\u2081) \u2190 mk_app ``has_mul.mul [n.1, m.1] >>= norm_num,\n    (a', h\u2082) \u2190 eval_pow a m,\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    return (xadd' c a' x (n', n.2 * m.2) (const \u03b10),\n      c.cs_app ``horner_pow [a, x, n.1, m.1, n', a', h\u2081, h\u2082])\n  | _ := do\n    e\u2082 \u2190 expr.of_nat N (m.2-1),\n    l \u2190 mk_app ``monoid.pow [e, e\u2082],\n    (tl, hl) \u2190 eval_pow he (e\u2082, m.2-1),\n    (t, p\u2082) \u2190 eval_mul c tl he,\n    hr \u2190 mk_eq_refl e,\n    p\u2082 \u2190 c.mk_app ``norm_num.subst_into_prod ``has_mul [l, e, tl, e, t, hl, hr, p\u2082],\n    p\u2081 \u2190 mk_app ``pow_succ' [e, e\u2082],\n    p \u2190 mk_eq_trans p\u2081 p\u2082,\n    return (t, p)\n  end\n\ntheorem horner_atom {\u03b1} [comm_semiring \u03b1] (x : \u03b1) : x = horner 1 x 1 0 :=\nby simp [horner]\n\nmeta def eval_atom (c : cache) (e : expr) : tactic (horner_expr \u00d7 expr) :=\ndo \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n   \u03b11 \u2190 expr.of_nat c.\u03b1 1,\n   n1 \u2190 expr.of_nat (expr.const `nat []) 1,\n   return (xadd' c (const \u03b11) e (n1, 1) (const \u03b10), c.cs_app ``horner_atom [e])\n\nlemma subst_into_pow {\u03b1} [monoid \u03b1] (l r tl tr t)\n  (prl : (l : \u03b1) = tl) (prr : (r : \u2115) = tr) (prt : tl ^ tr = t) : l ^ r = t :=\nby simp [prl, prr, prt]\n\nlemma unfold_sub {\u03b1} [add_group \u03b1] (a b c : \u03b1)\n  (h : a + -b = c) : a - b = c := h\n\nlemma unfold_div {\u03b1} [division_ring \u03b1] (a b c : \u03b1)\n  (h : a * b\u207b\u00b9 = c) : a / b = c := h\n\nmeta def eval (c : cache) : expr \u2192 tactic (horner_expr \u00d7 expr)\n| `(%%e\u2081 + %%e\u2082) := do\n  (e\u2081', p\u2081) \u2190 eval e\u2081,\n  (e\u2082', p\u2082) \u2190 eval e\u2082,\n  (e', p') \u2190 eval_add c e\u2081' e\u2082',\n  p \u2190 c.mk_app ``norm_num.subst_into_sum ``has_add [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n  return (e', p)\n| `(%%e\u2081 - %%e\u2082) := do\n  e\u2082' \u2190 mk_app ``has_neg.neg [e\u2082],\n  e \u2190 mk_app ``has_add.add [e\u2081, e\u2082'],\n  (e', p) \u2190 eval e,\n  p' \u2190 c.mk_app ``unfold_sub ``add_group [e\u2081, e\u2082, e', p],\n  return (e', p')\n| `(- %%e) := do\n  (e\u2081, p\u2081) \u2190 eval e,\n  (e\u2082, p\u2082) \u2190 eval_neg c e\u2081,\n  p \u2190 c.mk_app ``norm_num.subst_into_neg ``has_neg [e, e\u2081, e\u2082, p\u2081, p\u2082],\n  return (e\u2082, p)\n| `(%%e\u2081 * %%e\u2082) := do\n  (e\u2081', p\u2081) \u2190 eval e\u2081,\n  (e\u2082', p\u2082) \u2190 eval e\u2082,\n  (e', p') \u2190 eval_mul c e\u2081' e\u2082',\n  p \u2190 c.mk_app ``norm_num.subst_into_prod ``has_mul [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n  return (e', p)\n| e@`(has_inv.inv %%_) := (do\n    (e', p) \u2190 norm_num.derive e,\n    e'.to_rat,\n    return (const e', p)) <|> eval_atom c e\n| `(%%e\u2081 / %%e\u2082) := do\n  e\u2082' \u2190 mk_app ``has_inv.inv [e\u2082],\n  e \u2190 mk_app ``has_mul.mul [e\u2081, e\u2082'],\n  (e', p) \u2190 eval e,\n  p' \u2190 c.mk_app ``unfold_div ``division_ring [e\u2081, e\u2082, e', p],\n  return (e', p')\n| e@`(@has_pow.pow _ _ %%P %%e\u2081 %%e\u2082) := do\n  (e\u2082', p\u2082) \u2190 eval e\u2082,\n  match e\u2082'.e.to_nat, P with\n  | some k, `(monoid.has_pow) := do\n    (e\u2081', p\u2081) \u2190 eval e\u2081,\n    (e', p') \u2190 eval_pow c e\u2081' (e\u2082, k),\n    p \u2190 c.mk_app ``subst_into_pow ``monoid [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n    return (e', p)\n  | some k, `(nat.has_pow) := do\n    (e\u2081', p\u2081) \u2190 eval e\u2081,\n    (e', p') \u2190 eval_pow c e\u2081' (e\u2082, k),\n    p\u2083 \u2190 c.mk_app ``subst_into_pow ``monoid [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n    p\u2084 \u2190 mk_app ``nat.pow_eq_pow [e\u2081, e\u2082] >>= mk_eq_symm,\n    p \u2190 mk_eq_trans p\u2084 p\u2083,\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 \u00d7 expr) :=\ndo (e', p) \u2190 eval c e, return (e', p)\n\ntheorem horner_def' {\u03b1} [comm_semiring \u03b1] (a x n b) : @horner \u03b1 _ a x n b = x ^ n * a + b :=\nby simp [horner, mul_comm]\n\ntheorem mul_assoc_rev {\u03b1} [semigroup \u03b1] (a b c : \u03b1) : a * (b * c) = a * b * c :=\nby simp [mul_assoc]\n\ntheorem pow_add_rev {\u03b1} [monoid \u03b1] (a b : \u03b1) (m n : \u2115) : a ^ m * a ^ n = a ^ (m + n) :=\nby simp [pow_add]\n\ntheorem pow_add_rev_right {\u03b1} [monoid \u03b1] (a b : \u03b1) (m n : \u2115) : b * a ^ m * a ^ n = b * a ^ (m + n) :=\nby simp [pow_add, mul_assoc]\n\ntheorem add_neg_eq_sub {\u03b1} [add_group \u03b1] (a b : \u03b1) : 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 \u00d7 expr) := do\npow_lemma \u2190 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 \u2190 lemmas.mfoldl simp_lemmas.add_simp simp_lemmas.mk,\n(_, e', pr) \u2190 ext_simplify_core () {}\n  simp_lemmas.mk (\u03bb _, failed) (\u03bb _ _ _ _ e, do\n    c \u2190 mk_cache e,\n    (new_e, pr) \u2190 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' (\u03bb e, norm_num e <|> pow_lemma.rewrite e)\n    end e,\n    guard (\u00ac new_e =\u2090 e),\n    return ((), new_e, some pr, ff))\n   (\u03bb _ _ _ _ _, 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\u2081 = %%e\u2082) \u2190 target,\n  c \u2190 mk_cache e\u2081,\n  (e\u2081', p\u2081) \u2190 eval c e\u2081,\n  (e\u2082', p\u2082) \u2190 eval c e\u2082,\n  is_def_eq e\u2081' e\u2082',\n  p \u2190 mk_eq_symm p\u2082 >>= mk_eq_trans p\u2081,\n  tactic.exact p\n\nmeta def ring.mode : lean.parser ring.normalize_mode :=\nwith_desc \"(SOP|raw|horner)?\" $\ndo mode \u2190 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 \u2190 loc.get_locals,\n   tt \u2190 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 (\u211a, 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 {\u03b1 : Type*} [linear_ordered_field \u03b1]\nparameters {\u03b2 : Type*} [comm_ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv]\n\ndef Cauchy := @quotient (cau_seq _ abv) cau_seq.equiv\n\ndef mk : cau_seq _ abv \u2192 Cauchy := quotient.mk\n\n@[simp] theorem mk_eq_mk (f) : @eq Cauchy \u27e6f\u27e7 (mk f) := rfl\n\ntheorem mk_eq {f g} : mk f = mk g \u2194 f \u2248 g := quotient.eq\n\ndef of_rat (x : \u03b2) : Cauchy := mk (const abv x)\n\ninstance : has_zero Cauchy := \u27e8of_rat 0\u27e9\ninstance : has_one Cauchy := \u27e8of_rat 1\u27e9\ninstance : inhabited Cauchy := \u27e80\u27e9\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 \u2194 lim_zero f :=\nby have : mk f = 0 \u2194 lim_zero (f - 0) := quotient.eq;\n   rwa sub_zero at this\n\ninstance : has_add Cauchy :=\n\u27e8\u03bb x y, quotient.lift_on\u2082 x y (\u03bb f g, mk (f + g)) $\n  \u03bb f\u2081 g\u2081 f\u2082 g\u2082 hf hg, quotient.sound $\n  by simpa [(\u2248), setoid.r, sub_eq_add_neg, add_comm, add_left_comm, add_assoc]\n    using add_lim_zero hf hg\u27e9\n\n@[simp] theorem mk_add (f g : cau_seq \u03b2 abv) : mk f + mk g = mk (f + g) := rfl\n\ninstance : has_neg Cauchy :=\n\u27e8\u03bb x, quotient.lift_on x (\u03bb f, mk (-f)) $\n  \u03bb f\u2081 f\u2082 hf, quotient.sound $\n  by simpa [(\u2248), setoid.r] using neg_lim_zero hf\u27e9\n\n@[simp] theorem mk_neg (f : cau_seq \u03b2 abv) : -mk f = mk (-f) := rfl\n\ninstance : has_mul Cauchy :=\n\u27e8\u03bb x y, quotient.lift_on\u2082 x y (\u03bb f g, mk (f * g)) $\n  \u03bb f\u2081 g\u2081 f\u2082 g\u2082 hf hg, quotient.sound $\n  by simpa [(\u2248), setoid.r, mul_add, mul_comm, add_assoc, sub_eq_add_neg] using\n    add_lim_zero (mul_lim_zero_right g\u2081 hf) (mul_lim_zero_right f\u2082 hg)\u27e9\n\n@[simp] theorem mk_mul (f g : cau_seq \u03b2 abv) : mk f * mk g = mk (f * g) := rfl\n\ninstance : has_sub Cauchy :=\n\u27e8\u03bb x y, quotient.lift_on\u2082 x y (\u03bb f g, mk (f - g)) $\n  \u03bb f\u2081 g\u2081 f\u2082 g\u2082 hf hg, quotient.sound $ show ((f\u2081 - g\u2081) - (f\u2082 - g\u2082)).lim_zero,\n    by simpa [sub_eq_add_neg, add_assoc, add_comm, add_left_comm] using sub_lim_zero hf hg\u27e9\n\n@[simp] theorem mk_sub (f g : cau_seq \u03b2 abv) : mk f - mk g = mk (f - g) := rfl\n\ntheorem of_rat_add (x y : \u03b2) : of_rat (x + y) = of_rat x + of_rat y :=\ncongr_arg mk (const_add _ _)\n\ntheorem of_rat_neg (x : \u03b2) : of_rat (-x) = -of_rat x :=\ncongr_arg mk (const_neg _)\n\ntheorem of_rat_mul (x y : \u03b2) : 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 \u03bb a, quotient.induction_on a (\u03bb _, _)},\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 : \u03b2) : of_rat (x - y) = of_rat x - of_rat y :=\ncongr_arg mk (const_sub _ _)\n\nend\n\nopen_locale classical\nsection\n\nparameters {\u03b1 : Type*} [linear_ordered_field \u03b1]\nparameters {\u03b2 : Type*} [field \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv]\nlocal notation `Cauchy` := @Cauchy _ _ _ _ abv _\n\nnoncomputable instance : has_inv Cauchy :=\n\u27e8\u03bb x, quotient.lift_on x\n  (\u03bb f, mk $ if h : lim_zero f then 0 else inv f h) $\n\u03bb 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, \u2190 Ig] at If,\n    rw mul_comm at Ig,\n    rw [\u2190 mul_one (mk (inv f hf)), \u2190 Ig, \u2190 mul_assoc, If,\n        mul_assoc, Ig, mul_one] }\nend\u27e9\n\n@[simp] theorem inv_zero : (0 : Cauchy)\u207b\u00b9 = 0 :=\ncongr_arg mk $ by rw dif_pos; [refl, exact zero_lim_zero]\n\n@[simp] theorem inv_mk {f} (hf) : (@mk \u03b1 _ \u03b2 _ abv _ f)\u207b\u00b9 = mk (inv f hf) :=\ncongr_arg mk $ by rw dif_neg\n\nlemma cau_seq_zero_ne_one : \u00ac (0 : cau_seq _ abv) \u2248 1 := \u03bb 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) \u2260 1 :=\n\u03bb h, cau_seq_zero_ne_one $ mk_eq.1 h\n\nprotected theorem inv_mul_cancel {x : Cauchy} : x \u2260 0 \u2192 x\u207b\u00b9 * x = 1 :=\nquotient.induction_on x $ \u03bb 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   := \u03bb x x0, by rw [mul_comm, cau_seq.completion.inv_mul_cancel x0],\n  exists_pair_ne   := \u27e80, 1, zero_ne_one\u27e9,\n  inv_zero         := inv_zero,\n  .. Cauchy.comm_ring }\n\nlocal attribute [instance] field\n\ntheorem of_rat_inv (x : \u03b2) : of_rat (x\u207b\u00b9) = ((of_rat x)\u207b\u00b9 : Cauchy) :=\ncongr_arg mk $ by split_ifs with h; [simp [const_lim_zero.1 h], refl]\n\ntheorem of_rat_div (x y : \u03b2) : 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 {\u03b1 : Type*} [linear_ordered_field \u03b1]\nnamespace cau_seq\nsection\n\nvariables (\u03b2 : Type*) [ring \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv]\n\nclass is_complete :=\n(is_complete : \u2200 s : cau_seq \u03b2 abv, \u2203 b : \u03b2, s \u2248 const abv b)\nend\n\nsection\n\nvariables {\u03b2 : Type*} [ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv]\nvariable [is_complete \u03b2 abv]\n\nlemma complete : \u2200 s : cau_seq \u03b2 abv, \u2203 b : \u03b2, s \u2248 const abv b :=\nis_complete.is_complete\n\nnoncomputable def lim (s : cau_seq \u03b2 abv) := classical.some (complete s)\n\nlemma equiv_lim (s : cau_seq \u03b2 abv) : s \u2248 const abv (lim s) :=\nclassical.some_spec (complete s)\n\nlemma eq_lim_of_const_equiv {f : cau_seq \u03b2 abv} {x : \u03b2} (h : cau_seq.const abv x \u2248 f) : x = lim f :=\nconst_equiv.mp $ setoid.trans h $ equiv_lim f\n\nlemma lim_eq_of_equiv_const {f : cau_seq \u03b2 abv} {x : \u03b2} (h : f \u2248 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 \u03b2 abv} (h : f \u2248 g) : lim f = lim g :=\nlim_eq_of_equiv_const $ setoid.trans h $ equiv_lim g\n\n@[simp] lemma lim_const (x : \u03b2) : lim (const abv x) = x :=\nlim_eq_of_equiv_const $ setoid.refl _\n\nlemma lim_add (f g : cau_seq \u03b2 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 \u03b2 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 \u03b2 abv) (x : \u03b2) : lim f * x = lim (f * const abv x) :=\nby rw [\u2190 lim_mul_lim, lim_const]\n\nlemma lim_neg (f : cau_seq \u03b2 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, \u2190 sub_eq_add_neg];\n  exact setoid.symm (equiv_lim f))\n\nlemma lim_eq_zero_iff (f : cau_seq \u03b2 abv) : lim f = 0 \u2194 lim_zero f :=\n\u27e8assume 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\u2081 : f = (f - const abv 0) := ext (\u03bb n, by simp [sub_apply, const_apply]),\n  by rw h\u2081 at h; exact lim_eq_of_equiv_const h \u27e9\n\nend\n\nsection\nvariables {\u03b2 : Type*} [field \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv] [is_complete \u03b2 abv]\n\nlemma lim_inv {f : cau_seq \u03b2 abv} (hf : \u00ac lim_zero f) : lim (inv f hf) = (lim f)\u207b\u00b9 :=\nhave hl : lim f \u2260 0 := by rwa \u2190 lim_eq_zero_iff at hf,\nlim_eq_of_equiv_const $ show lim_zero (inv f hf - const abv (lim f)\u207b\u00b9),\n  from have h\u2081 : \u2200 (g f : cau_seq \u03b2 abv) (hf : \u00ac lim_zero f), lim_zero (g - f * inv f hf * g) :=\n    \u03bb g f hf, by rw [\u2190 one_mul g, \u2190 mul_assoc, \u2190 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\u2082 : lim_zero ((inv f hf - const abv (lim f)\u207b\u00b9) - (const abv (lim f) - f) *\n      (inv f hf * const abv (lim f)\u207b\u00b9)) :=\n    by rw [sub_mul, \u2190 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)\u207b\u00b9)\n      - (const abv (lim f)\u207b\u00b9 - f * (inv f hf * const abv (lim f)\u207b\u00b9))),\n    from sub_lim_zero\n      (by rw [\u2190 mul_assoc, mul_right_comm, const_inv hl]; exact h\u2081 _ _ _)\n      (by rw [\u2190 mul_assoc]; exact h\u2081 _ _ _),\n  (lim_zero_congr h\u2082).mpr $ mul_lim_zero_left _ (setoid.symm (equiv_lim f))\n\nend\n\nsection\nvariables [is_complete \u03b1 abs]\n\nlemma lim_le {f : cau_seq \u03b1 abs} {x : \u03b1}\n  (h : f \u2264 cau_seq.const abs x) : lim f \u2264 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 \u03b1 abs} {x : \u03b1}\n  (h : cau_seq.const abs x \u2264 f) : x \u2264 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 \u03b1 abs} {x : \u03b1}\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 \u03b1 abs} {x : \u03b1}\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] (\u03b1 : m \u2192 n \u2192 Type v) :\n  Type (max u u' v) :=\n\u03a0 i j, \u03b1 i j\n\nvariables {l m n o : Type*} [fintype l] [fintype m] [fintype n] [fintype o]\nvariables {\u03b1 : m \u2192 n \u2192 Type v}\n\nnamespace dmatrix\n\nsection ext\nvariables {M N : dmatrix m n \u03b1}\n\ntheorem ext_iff : (\u2200 i j, M i j = N i j) \u2194 M = N :=\n\u27e8\u03bb h, funext $ \u03bb i, funext $ h i, \u03bb h, by simp [h]\u27e9\n\n@[ext] theorem ext : (\u2200 i j, M i j = N i j) \u2192 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 \u03b1) {\u03b2 : m \u2192 n \u2192 Type w} (f : \u03a0 \u2983i j\u2984, \u03b1 i j \u2192 \u03b2 i j) :\n  dmatrix m n \u03b2 := \u03bb i j, f (M i j)\n\n@[simp]\nlemma map_apply {M : dmatrix m n \u03b1} {\u03b2 : m \u2192 n \u2192 Type w} {f : \u03a0 \u2983i j\u2984, \u03b1 i j \u2192 \u03b2 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 \u03b1} {\u03b2 : m \u2192 n \u2192 Type w} {\u03b3 : m \u2192 n \u2192 Type z}\n  {f : \u03a0 \u2983i j\u2984, \u03b1 i j \u2192 \u03b2 i j} {g : \u03a0 \u2983i j\u2984, \u03b2 i j \u2192 \u03b3 i j} :\n  (M.map f).map g = M.map (\u03bb i j x, g (f x)) :=\nby { ext, simp, }\n\n/-- The transpose of a dmatrix. -/\ndef transpose (M : dmatrix m n \u03b1) : dmatrix n m (\u03bb j i, \u03b1 i j)\n| x y := M y x\n\nlocalized \"postfix (name := dmatrix.transpose) `\u1d40`:1500 := dmatrix.transpose\" in dmatrix\n\n/-- `dmatrix.col u` is the column matrix whose entries are given by `u`. -/\ndef col {\u03b1 : m \u2192 Type v} (w : \u03a0 i, \u03b1 i) : dmatrix m unit (\u03bb i j, \u03b1 i)\n| x y := w x\n\n/-- `dmatrix.row u` is the row matrix whose entries are given by `u`. -/\ndef row {\u03b1 : n \u2192 Type v} (v : \u03a0 j, \u03b1 j) : dmatrix unit n (\u03bb i j, \u03b1 j)\n| x y := v y\n\ninstance [\u2200 i j, inhabited (\u03b1 i j)] : inhabited (dmatrix m n \u03b1) := pi.inhabited _\ninstance [\u2200 i j, has_add (\u03b1 i j)] : has_add (dmatrix m n \u03b1) := pi.has_add\ninstance [\u2200 i j, add_semigroup (\u03b1 i j)] : add_semigroup (dmatrix m n \u03b1) := pi.add_semigroup\ninstance [\u2200 i j, add_comm_semigroup (\u03b1 i j)] : add_comm_semigroup (dmatrix m n \u03b1) :=\npi.add_comm_semigroup\ninstance [\u2200 i j, has_zero (\u03b1 i j)] : has_zero (dmatrix m n \u03b1) := pi.has_zero\ninstance [\u2200 i j, add_monoid (\u03b1 i j)] : add_monoid (dmatrix m n \u03b1) := pi.add_monoid\ninstance [\u2200 i j, add_comm_monoid (\u03b1 i j)] : add_comm_monoid (dmatrix m n \u03b1) := pi.add_comm_monoid\ninstance [\u2200 i j, has_neg (\u03b1 i j)] : has_neg (dmatrix m n \u03b1) := pi.has_neg\ninstance [\u2200 i j, has_sub (\u03b1 i j)] : has_sub (dmatrix m n \u03b1) := pi.has_sub\ninstance [\u2200 i j, add_group (\u03b1 i j)] : add_group (dmatrix m n \u03b1) := pi.add_group\ninstance [\u2200 i j, add_comm_group (\u03b1 i j)] : add_comm_group (dmatrix m n \u03b1) := pi.add_comm_group\ninstance [\u2200 i j, unique (\u03b1 i j)] : unique (dmatrix m n \u03b1) := pi.unique\ninstance [\u2200 i j, subsingleton (\u03b1 i j)] : subsingleton (dmatrix m n \u03b1) := pi.subsingleton\n\n@[simp] theorem zero_apply [\u2200 i j, has_zero (\u03b1 i j)] (i j) : (0 : dmatrix m n \u03b1) i j = 0 := rfl\n@[simp] theorem neg_apply [\u2200 i j, has_neg (\u03b1 i j)] (M : dmatrix m n \u03b1) (i j) :\n  (- M) i j = - M i j :=\nrfl\n@[simp] theorem add_apply [\u2200 i j, has_add (\u03b1 i j)] (M N : dmatrix m n \u03b1) (i j) :\n  (M + N) i j = M i j + N i j :=\nrfl\n@[simp] theorem sub_apply [\u2200 i j, has_sub (\u03b1 i j)] (M N : dmatrix m n \u03b1) (i j) :\n  (M - N) i j = M i j - N i j :=\nrfl\n\n@[simp] lemma map_zero [\u2200 i j, has_zero (\u03b1 i j)] {\u03b2 : m \u2192 n \u2192 Type w} [\u2200 i j, has_zero (\u03b2 i j)]\n  {f : \u03a0 \u2983i j\u2984, \u03b1 i j \u2192 \u03b2 i j} (h : \u2200 i j, f (0 : \u03b1 i j) = 0) :\n  (0 : dmatrix m n \u03b1).map f = 0 :=\nby { ext, simp [h], }\n\nlemma map_add [\u2200 i j, add_monoid (\u03b1 i j)] {\u03b2 : m \u2192 n \u2192 Type w} [\u2200 i j, add_monoid (\u03b2 i j)]\n  (f : \u03a0 \u2983i j\u2984, \u03b1 i j \u2192+ \u03b2 i j) (M N : dmatrix m n \u03b1) :\n  (M + N).map (\u03bb i j, @f i j) = M.map (\u03bb i j, @f i j) + N.map (\u03bb i j, @f i j) :=\nby { ext, simp, }\n\nlemma map_sub [\u2200 i j, add_group (\u03b1 i j)] {\u03b2 : m \u2192 n \u2192 Type w} [\u2200 i j, add_group (\u03b2 i j)]\n  (f : \u03a0 \u2983i j\u2984, \u03b1 i j \u2192+ \u03b2 i j) (M N : dmatrix m n \u03b1) :\n  (M - N).map (\u03bb i j, @f i j) = M.map (\u03bb i j, @f i j) - N.map (\u03bb i j, @f i j) :=\nby { ext, simp }\n\ninstance subsingleton_of_empty_left [is_empty m] : subsingleton (dmatrix m n \u03b1) :=\n\u27e8\u03bb M N, by { ext, exact is_empty_elim i }\u27e9\n\ninstance subsingleton_of_empty_right [is_empty n] : subsingleton (dmatrix m n \u03b1) :=\n\u27e8\u03bb M N, by { ext, exact is_empty_elim j }\u27e9\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  [\u2200 i j, add_monoid (\u03b1 i j)] {\u03b2 : m \u2192 n \u2192 Type w} [\u2200 i j, add_monoid (\u03b2 i j)]\n  (f : \u03a0 \u2983i j\u2984, \u03b1 i j \u2192+ \u03b2 i j) :\n  dmatrix m n \u03b1 \u2192+ dmatrix m n \u03b2 :=\n{ to_fun := \u03bb M, M.map (\u03bb 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  [\u2200 i j, add_monoid (\u03b1 i j)] {\u03b2 : m \u2192 n \u2192 Type w} [\u2200 i j, add_monoid (\u03b2 i j)]\n  (f : \u03a0 \u2983i j\u2984, \u03b1 i j \u2192+ \u03b2 i j) (M : dmatrix m n \u03b1) :\n  add_monoid_hom.map_dmatrix f M = M.map (\u03bb 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 \u2192\u2097[R] p`, `\u2200 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 \u2293 q = \u22a5`, `p \u2294 q = \u22a4`. 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 {\ud835\udd5c : Type u_1}\n    [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3}\n    [normed_group F] [normed_space \ud835\udd5c F] [complete_space \ud835\udd5c] (f : continuous_linear_map \ud835\udd5c E F)\n    [finite_dimensional \ud835\udd5c \u21a5(range f)] : submodule.closed_complemented (ker f) :=\n  sorry\n\n/-- If `f : E \u2192L[R] F` and `g : E \u2192L[R] G` are two surjective linear maps and\ntheir kernels are complement of each other, then `x \u21a6 (f x, g x)` defines\na linear equivalence `E \u2243L[R] F \u00d7 G`. -/\ndef equiv_prod_of_surjective_of_is_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] [complete_space E] [complete_space (F \u00d7 G)]\n    (f : continuous_linear_map \ud835\udd5c E F) (g : continuous_linear_map \ud835\udd5c E G) (hf : range f = \u22a4)\n    (hg : range g = \u22a4) (hfg : is_compl (ker f) (ker g)) : continuous_linear_equiv \ud835\udd5c E (F \u00d7 G) :=\n  linear_equiv.to_continuous_linear_equiv_of_continuous\n    (linear_map.equiv_prod_of_surjective_of_is_compl (\u2191f) (\u2191g) hf hg hfg) sorry\n\n@[simp] theorem coe_equiv_prod_of_surjective_of_is_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F]\n    [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] [complete_space E]\n    [complete_space (F \u00d7 G)] {f : continuous_linear_map \ud835\udd5c E F} {g : continuous_linear_map \ud835\udd5c E G}\n    (hf : range f = \u22a4) (hg : range g = \u22a4) (hfg : is_compl (ker f) (ker g)) :\n    \u2191(equiv_prod_of_surjective_of_is_compl f g hf hg hfg) = \u2191(continuous_linear_map.prod f g) :=\n  rfl\n\n@[simp] theorem equiv_prod_of_surjective_of_is_compl_to_linear_equiv {\ud835\udd5c : Type u_1}\n    [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3}\n    [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G]\n    [complete_space E] [complete_space (F \u00d7 G)] {f : continuous_linear_map \ud835\udd5c E F}\n    {g : continuous_linear_map \ud835\udd5c E G} (hf : range f = \u22a4) (hg : range g = \u22a4)\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 (\u2191f) (\u2191g) hf hg hfg :=\n  rfl\n\n@[simp] theorem equiv_prod_of_surjective_of_is_compl_apply {\ud835\udd5c : Type u_1}\n    [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3}\n    [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G]\n    [complete_space E] [complete_space (F \u00d7 G)] {f : continuous_linear_map \ud835\udd5c E F}\n    {g : continuous_linear_map \ud835\udd5c E G} (hf : range f = \u22a4) (hg : range g = \u22a4)\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 \u00d7 q` is continuously\nisomorphic to `E`. -/\ndef prod_equiv_of_closed_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] (p : subspace \ud835\udd5c E) (q : subspace \ud835\udd5c E)\n    (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) :\n    continuous_linear_equiv \ud835\udd5c (\u21a5p \u00d7 \u21a5q) 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] (p : subspace \ud835\udd5c E) (q : subspace \ud835\udd5c E)\n    (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) : continuous_linear_map \ud835\udd5c E \u21a5p :=\n  continuous_linear_map.comp (continuous_linear_map.fst \ud835\udd5c \u21a5p \u21a5q)\n    \u2191(continuous_linear_equiv.symm (prod_equiv_of_closed_compl p q h hp hq))\n\n@[simp] theorem coe_prod_equiv_of_closed_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E}\n    {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) :\n    \u21d1(prod_equiv_of_closed_compl p q h hp hq) = \u21d1(submodule.prod_equiv_of_is_compl p q h) :=\n  rfl\n\n@[simp] theorem coe_prod_equiv_of_closed_compl_symm {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E}\n    {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) :\n    \u21d1(continuous_linear_equiv.symm (prod_equiv_of_closed_compl p q h hp hq)) =\n        \u21d1(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 {\ud835\udd5c : Type u_1}\n    [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E]\n    [complete_space E] {p : subspace \ud835\udd5c E} {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p)\n    (hq : is_closed \u2191q) :\n    \u2191(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' {\ud835\udd5c : Type u_1}\n    [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E]\n    [complete_space E] {p : subspace \ud835\udd5c E} {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p)\n    (hq : is_closed \u2191q) :\n    \u21d1(linear_proj_of_closed_compl p q h hp hq) = \u21d1(submodule.linear_proj_of_is_compl p q h) :=\n  rfl\n\ntheorem closed_complemented_of_closed_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E}\n    {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) :\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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E} :\n    submodule.closed_complemented p \u2194\n        is_closed \u2191p \u2227 \u2203 (q : subspace \ud835\udd5c E), \u2203 (hq : is_closed \u2191q), is_compl p q :=\n  sorry\n\ntheorem closed_complemented_of_quotient_finite_dimensional {\ud835\udd5c : Type u_1}\n    [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E]\n    [complete_space E] {p : subspace \ud835\udd5c E} [complete_space \ud835\udd5c]\n    [finite_dimensional \ud835\udd5c (submodule.quotient p)] (hp : is_closed \u2191p) :\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 \u27f6 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\u2081 \u226b f\u2082` to the kernel pair of `f\u2081`.\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 \u226b f = b \u226b f`\nand the square\n  R \u2192 X\n  \u2193   \u2193\n  X \u2192 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 \u27f6 Y) (a : R \u27f6 X)\n    (b : R \u27f6 X)\n    where\n  comm : a \u226b f = b \u226b 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 \u27f6 Y}\n    {a : R \u27f6 X} {b : R \u27f6 X} (c : is_kernel_pair f a b) {X' : C} (f' : Y \u27f6 X') :\n    a \u226b f \u226b f' = b \u226b f \u226b 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 \u27f6 Y)\n    (a : R \u27f6 X) (b : R \u27f6 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 \u226b f = b \u226b 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 \u226b f = b \u226b f)\n              (Q_is_limit : limits.is_limit (limits.pullback_cone.mk a b Q_comm)) =>\n              (fun {f : X \u27f6 Y} {a b : R \u27f6 X} (comm comm_1 : a \u226b f = b \u226b 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 \u27f6 Y} {a b : R \u27f6 X} (comm : a \u226b f = b \u226b 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 `(\ud835\udfd9 _, \ud835\udfd9 _)`  is a kernel pair for `f`. -/\ndef id_of_mono {C : Type u} [category C] {X : C} {Y : C} (f : X \u27f6 Y) [mono f] :\n    is_kernel_pair f \ud835\udfd9 \ud835\udfd9 :=\n  mk sorry\n    (limits.pullback_cone.is_limit_aux' (limits.pullback_cone.mk \ud835\udfd9 \ud835\udfd9 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 \u27f6 Y) [mono f] :\n    Inhabited (is_kernel_pair f \ud835\udfd9 \ud835\udfd9) :=\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 \u27f6 Y} {a : R \u27f6 X} {b : R \u27f6 X}\n    {S : C} (k : is_kernel_pair f a b) (p : S \u27f6 X) (q : S \u27f6 X) (w : p \u226b f = q \u226b f) :\n    Subtype fun (t : S \u27f6 R) => t \u226b a = p \u2227 t \u226b 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\u2081 \u226b f\u2082` and `a \u226b f\u2081 = b \u226b f\u2081`, then `(a,b)` is a kernel pair for\njust `f\u2081`.\nThat is, to show that `(a,b)` is a kernel pair for `f\u2081` 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 \u27f6 X} {b : R \u27f6 X}\n    {f\u2081 : X \u27f6 Y} {f\u2082 : Y \u27f6 Z} (comm : a \u226b f\u2081 = b \u226b f\u2081) (big_k : is_kernel_pair (f\u2081 \u226b f\u2082) a b) :\n    is_kernel_pair f\u2081 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\u2081 f\u2081) =>\n        let s' : limits.pullback_cone (f\u2081 \u226b f\u2082) (f\u2081 \u226b f\u2082) :=\n          limits.pullback_cone.mk (limits.pullback_cone.fst s) (limits.pullback_cone.snd s)\n            (limits.pullback_cone.condition_assoc s f\u2082);\n        { val := limits.is_limit.lift (is_limit big_k) s', property := sorry })\n\n/--\nIf `(a,b)` is a kernel pair for `f\u2081 \u226b f\u2082` and `f\u2082` is mono, then `(a,b)` is a kernel pair for\njust `f\u2081`.\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 \u27f6 X}\n    {b : R \u27f6 X} {f\u2081 : X \u27f6 Y} {f\u2082 : Y \u27f6 Z} [mono f\u2082] (big_k : is_kernel_pair (f\u2081 \u226b f\u2082) a b) :\n    is_kernel_pair f\u2081 a b :=\n  cancel_right sorry big_k\n\n/--\nIf `(a,b)` is a kernel pair for `f\u2081` and `f\u2082` is mono, then `(a,b)` is a kernel pair for `f\u2081 \u226b f\u2082`.\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 \u27f6 X} {b : R \u27f6 X}\n    {f\u2081 : X \u27f6 Y} {f\u2082 : Y \u27f6 Z} [mono f\u2082] (small_k : is_kernel_pair f\u2081 a b) :\n    is_kernel_pair (f\u2081 \u226b f\u2082) 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\u2081 \u226b f\u2082) (f\u2081 \u226b f\u2082)) =>\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 \u27f6 Y} {a : R \u27f6 X}\n    {b : R \u27f6 X} (k : is_kernel_pair f a b) [r : regular_epi f] :\n    limits.is_colimit (limits.cofork.of_\u03c0 f (comm k)) :=\n  limits.cofork.is_colimit.mk (limits.cofork.of_\u03c0 f (comm k))\n    (fun (s : limits.cofork a b) =>\n      subtype.val (limits.cofork.is_colimit.desc' regular_epi.is_colimit (limits.cofork.\u03c0 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 \u2192 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\u00fcrer, 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 {\u03b1} (A : set \u03b1) : set (F \u03b1) :=\n{ x | \u2200 \u03b2 (f g : \u03b1 \u2192 \u03b2), (\u2200 a \u2208 A, f a = g a) \u2192 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' {\u03b1} (x : F \u03b1) : set \u03b1 :=\n\u22c2 A \u2208 { A : set \u03b1 | x \u2208 box F A}, A\n\n/--\nAlternate notion of predicate lifting based on `box`.\nTaken from the QBNF paper\n-/\ndef liftp' {\u03b1} (x : F \u03b1) (p : \u03b1 \u2192 Prop) : Prop :=\n\u2200 a \u2208 supp' x, p a\n\nend box\n\nend qpf\n\n\nnamespace ex\n\n/-- polynomial functor isomorph to `\u03b1 \u00d7 _` for some `\u03b1` -/\ndef prod.pfunctor (\u03b1 : Type) : pfunctor :=\n\u27e8 \u03b1, \u03bb _, unit \u27e9\n\ninstance {\u03b1} : qpf (prod \u03b1) :=\n{ P := prod.pfunctor \u03b1,\n  abs := \u03bb \u03b2 \u27e8a,f\u27e9, (a, f ()),\n  repr := \u03bb \u03b2 \u27e8x,y\u27e9, \u27e8x, \u03bb _, y\u27e9,\n  abs_repr := \u03bb \u03b2 \u27e8x,y\u27e9, rfl,\n  abs_map := \u03bb \u03b2 \u03b3 f \u27e8a,g\u27e9, rfl }\n\n/-- example relation for products -/\ndef foo.R (\u03b1 : Type) (x y : bool \u00d7 \u03b1) : Prop :=\nx.1 = y.1 \u2227 (x.1 \u2192 x.2 = y.2)\n\nlemma equivalence_foo.R (\u03b1) : equivalence (foo.R \u03b1) :=\nbegin\n  refine \u27e8_,_,_\u27e9,\n  { intro, exact \u27e8rfl,\u03bb _, rfl\u27e9 },\n  { intros x y h, refine \u27e8h.1.symm, \u03bb _, (h.2 _).symm\u27e9,\n    rwa h.1 },\n  { rintros x y z \u27e8ha,ha'\u27e9 \u27e8hb,hb'\u27e9,\n    refine \u27e8ha.trans hb, \u03bb hh, _\u27e9,\n    refine (ha' hh).trans (hb' _),\n    rwa \u2190 ha }\nend\n\n/-- example of a qpf -/\ndef foo (\u03b1 : Type) :=\nquot $ foo.R \u03b1\n\ninstance {\u03b1} [inhabited \u03b1] : inhabited (foo \u03b1) := \u27e8 quot.mk _ (default _) \u27e9\n\n/-- functor operation of `foo` -/\ndef foo.map {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (x : foo \u03b1) : foo \u03b2 :=\nquot.lift_on x (\u03bb x : bool \u00d7 \u03b1, quot.mk (foo.R \u03b2) $ f <$> x)\n  (\u03bb \u27e8a\u2080,a\u2081\u27e9 \u27e8b\u2080,b\u2081\u27e9 h, quot.sound \u27e8h.1,\u03bb h', show f a\u2081 = f b\u2081, from congr_arg f (h.2 h')\u27e9)\n\ninstance : functor foo :=\n{ map := @foo.map }\n\n@[simp]\nlemma foo.map_mk {\u03b1 \u03b2 : Type} (f : \u03b1 \u2192 \u03b2) (x : bool \u00d7 \u03b1) :\n  (f <$> quot.mk _ x : foo \u03b2) = 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 _ (\u03bb \u03b1, quot.mk _) (\u03bb \u03b1, quot.out)\n  (by simp)\n  (by intros; simp)\n\n/-- constructor for `foo` -/\ndef foo.mk {\u03b1} (b : bool) (x : \u03b1) : foo \u03b1 := quot.mk _ (b, x)\n\n@[simp]\nlemma foo.map_mk' {\u03b1 \u03b2 : Type} (f : \u03b1 \u2192 \u03b2) (b : bool) (x : \u03b1) :\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 {\u03b1 : Type} (x y : \u03b1) :\n  foo.mk tt x = foo.mk tt y \u2194 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 `\u03b1`, then the support of `foo.mk ff x` is empty -/\nlemma supp_mk_ff\u2080 {\u03b1} (x y : \u03b1) (h : \u00ac 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 (\u03bb a, \u00ac z = a), subst z,\n    dsimp [functor.liftp],\n    simp, refine \u27e8foo.mk ff \u27e8y,h\u27e9,_\u27e9,\n    simp, apply quot.sound, simp [foo.R] },\n  { use (\u03bb a, x = a),\n    dsimp [functor.liftp],\n    simp [h], use foo.mk ff \u27e8x,rfl\u27e9,\n    simp }\nend\n\n/-- consequence of original definition of `supp`. If there exists only\none value of type `\u03b1`, then the support of `foo.mk ff x` contains that value -/\nlemma supp_mk_ff\u2081 {\u03b1} (x : \u03b1) (h : \u2200 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 \u27e8x,rfl\u27e9, refl },\n  { introv hp, simp [functor.liftp] at hp,\n    rcases hp with \u27e8\u27e8z,z',hz\u27e9,hp\u27e9,\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 : \u00ac @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,\u03bb a : unit, tt,\u03bb 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 \u03bb h, h () }\nend\n\n/-- intuitive consequence of original definition of `supp`. -/\nlemma supp_mk_tt {\u03b1} (x : \u03b1) : 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 \u27e8x,rfl\u27e9, refl },\n  { introv hp, simp [functor.liftp] at hp,\n    rcases hp with \u27e8\u27e8z,z',hz\u27e9,hp\u27e9,\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 \u27e8\u27e8\u27e9,hp\u27e9, 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' {\u03b1} (x : \u03b1) : qpf.supp' (foo.mk ff x) = {} :=\nbegin\n  dsimp [qpf.supp'], ext, simp, dsimp [qpf.box],\n  use \u2205, simp [foo.mk], intros, apply quot.sound,\n  dsimp [foo.R], split, refl, rintro \u27e8 \u27e9\nend\n\n/-- simple consequence of the definition of `supp` from the QBNF paper -/\nlemma supp_mk_tt' {\u03b1} (x : \u03b1) : 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 : \u03b1 \u2192 \u03b1 \u2295 bool := \u03bb x, if x \u2208 i then sum.inl x else sum.inr tt,\n    let g : \u03b1 \u2192 \u03b1 \u2295 bool := \u03bb x, if x \u2208 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": "open set function\n\ntheorem least_seq_at_n {S : set (\u2115 \u2192 \u2115)} (H : S \u2260 \u2205) (n : \u2115) : \n\u2203 f : \u2115 \u2192 \u2115, f \u2208 S \u2227 \u2200 g : \u2115 \u2192 \u2115, g \u2208 S \u2192 f n \u2264 g n :=\nsorry\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/kruskal_final/temp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6584175072643413, "lm_q1q2_score": 0.49127097586403295}}
{"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 \u2260 0 \u2192 |x| >0)\n- ne pas ajouter l'in\u00e9galit\u00e9 au contexte si elle y est d\u00e9j\u00e0 !\n- 'dsimp only at h' effectue les beta-r\u00e9duction : (\u03bb x, f x) 37 = f 37\n- max : def et propri\u00e9t\u00e9s\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 (\u03b1 : Type) := \n-- (subgroup : ((\u03b1 = \u2115) \u2228 (\u03b1 = \u2124) \u2228 (\u03b1 = \u211a) \u2228 (\u03b1 = \u211d)) )\n\n-- lemma real_number_subgroup_nat : (nat = \u2115) \u2228 (nat = \u2124) \u2228 (nat = \u211a) \u2228 (nat = \u211d) :=\n-- begin\n--   left, refl,\n-- end\n\n-- instance : real_number_subgroup nat := \u27e8real_number_subgroup_nat\u27e9 \n\n\nlocal attribute [instance] classical.prop_decidable\n\n\n/-- `l` is the limit of the sequence `a` of reals -/\ndefinition limit (u : \u2115 \u2192 \u211d) (l : \u211d) : Prop :=\n\u2200 \u03b5 > 0, \u2203 N, \u2200 n \u2265 N, | u n - l | < \u03b5\n\ndefinition converging_seq (u : \u2115 \u2192 \u211d) : Prop :=\n\u2203 l, limit u l\n\ndefinition limit_plus_infinity (u : \u2115 \u2192 \u211d) : Prop :=\n\u2200 M:\u211d, \u2203 N:\u2115, \u2200 n \u2265 N, u n \u2265 M\n\ndefinition increasing_seq (u : \u2115 \u2192 \u211d) : Prop :=\n\u2200 p q , p \u2264 q \u2192 u p \u2264 u q\n\ndefinition bounded_above (u : \u2115 \u2192 \u211d) : Prop :=\n\u2203 M:\u211d, \u2200 n, u n \u2264 M\n\ndefinition bounded_below (u : \u2115 \u2192 \u211d) : Prop :=\n\u2203 m:\u211d, \u2200 n, u n \u2265 m\n\ndefinition bounded_sequence (u : \u2115 \u2192 \u211d) : Prop :=\n\u2203 M>0, \u2200 n, | u n | \u2264 M\n\ndefinition even (n:\u2115) : Prop := \u2203 n', n=2 * n'\n\ndefinition limit_function (f : \u211d \u2192 \u211d) (a : \u211d) (l : \u211d) : Prop :=\n\u2200 \u03b5 > 0, \u2203 \u03b4>0, \u2200 x: \u211d, ( | x-a | < \u03b4 \u2192 | f x  - l | < \u03b5 )\n\ndefinition continuous_at (f : \u211d \u2192 \u211d) (a : \u211d) : Prop :=\nlimit_function (\u03bb x, f x) a (f a)\n\ndefinition continuous (f: \u211d \u2192 \u211d) : Prop :=\n\u2200 a, continuous_at f a\n\ndefinition cauchy (u: \u2115 \u2192 \u211d) : Prop :=\n\u2200 \u03b5>0, \u2203 N: \u2115, \u2200 p\u2265N, \u2200 q\u2265N, |u p - u q | < \u03b5\n\ndefinition uniformly_continuous (f: \u211d \u2192 \u211d) : Prop :=\n\u2200 \u03b5>0, \u2203 \u03b4>0, \u2200 x y: \u211d,\n(|x - y| < \u03b4 \u2192 |f x - f y | < \u03b5)\n\nsection course\nopen tactic.interactive\n-- notation `|` x `|` := abs x\n\n-----------------\n-- definitions --\n-----------------\nnamespace definitions\n/- dEAduction\nPrettyName\n  D\u00e9finitions\n-/\n\n\nnamespace generalites\n/- dEAduction\nPrettyName\n  G\u00e9n\u00e9ralit\u00e9s\n-/\n\n/-\nabs_pos : 0 < |a| \u2194 a \u2260 0\nabs_mul x y : |x * y| = |x| * |y|\nabs_add x y : |x + y| \u2264 |x| + |y|\n-/\n\n/-\nMax :\ndef\nmax \u2265 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 \u2264 max A B` and\n`le_max-right A B : B \u2264 max A B`.\nThere are other cool functions in the `max` API, for example\n`max_le : A \u2264 C \u2192 B \u2264 C \u2192 max A B \u2264 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 \u2194 A < C \u2227 B < C` is called?\n-/\n\n\n\n----------------------------------\nnamespace maximum\n-- The name RealSubGroup will be replaced by \u211d in d\u2203\u2200duction, \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\u2200 a b : RealSubGroup, a \u2264 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\u2200 a b : RealSubGroup,  b \u2264 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 \u2264 c) (Hb: b \u2264 c) :\nmax a b \u2264 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\u2200 x : RealSubGroup,\n((0:RealSubGroup) \u2264 x) \u2192 (abs x = x) and ((x \u2264 0) \u2192 (abs x = -x)) :=\nbegin\n  intro x, split, exact abs_of_nonneg, exact abs_of_nonpos,\nend\n\nlemma theorem.majoration_valeur_absolue :\n\u2200 x r : RealSubGroup, (abs x < r) \u2194 ((-r < x) \u2227 (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\u2200 x y : RealSubGroup, |x + y| \u2264 |x| + |y|\n:= \n/- dEAduction\nPrettyName\n  In\u00e9galit\u00e9 triangulaire\n-/\nbegin\n  intros x y, exact abs_add x y \nend\n\nlemma theorem.valeur_absolue_produit :\n\u2200 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\u00e9finitions de la limite --\n------------------------------\n\nlemma definition.limit \n{u : \u2115 \u2192 \u211d} {l : \u211d} :\n(limit u l) \u2194 \n\u2200 \u03b5 > 0, \u2203 N, \u2200 n \u2265 N, | u n - l | < \u03b5\n:= \n/- dEAduction\nPrettyName\n  Limite d'une suite\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nlemma definition.converging_seq\n{u : \u2115 \u2192 \u211d} :\n(converging_seq u) \u2194 \n\u2203 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 : \u2115 \u2192 \u211d} :\n(limit_plus_infinity u) \u2194 \u2200 M:\u211d, \u2203 N:\u2115, \u2200 n \u2265 N, u n \u2265 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 : \u2115 \u2192 \u211d} :\n(increasing_seq u) \u2194 \n\u2200 p q, p \u2264 q \u2192 u p \u2264 u q\n:= \n/- dEAduction\nPrettyName\n  Suite croissante\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nlemma definition.bounded_above \n{u : \u2115 \u2192 \u211d} :\n(bounded_above u) \u2194 \n\u2203 M:\u211d, \u2200 n,  u n \u2264 M\n:= \n/- dEAduction\nPrettyName\n  Suite major\u00e9e\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\n-- lemma definition.bounded_below \n-- {u : \u2115 \u2192 \u211d} :\n-- (bounded_below_sequence u) \u2194 \n-- \u2203 M:\u211d, \u2200 n,  u n \u2265 M\n-- := \n-- /- dEAduction\n-- PrettyName\n--   Suite minor\u00e9e\n-- ImplicitUse\n--   True\n-- -/\n-- begin\n--   refl\n-- end\n\nlemma definition.bounded \n{u : \u2115 \u2192 \u211d} :\n(bounded_sequence u) \u2194 \n\u2203 M>0, \u2200 n, | u n | \u2264 M\n:= \n/- dEAduction\nPrettyName\n  Suite born\u00e9e\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nend suites\n\nnamespace fonctions\n\nlemma definition.composition {X Y Z: Type} {f: X \u2192 Y} {g:Y \u2192 Z} {x:X}:\nset.composition g f x = g (f x)\n:=\nbegin\n    todo,\nend\n\nlemma definition.limit_function (f : \u211d \u2192 \u211d) (a : \u211d) (l : \u211d) : \nlimit_function f a l \u2194 \n( \u2200 \u03b5 > 0, \u2203 \u03b4>0, \u2200 x: \u211d, ( | x-a | < \u03b4 \u2192 | f x  - l | < \u03b5 ) ):=\n/- dEAduction\nPrettyName\n  Limite d'une fonction\nImplicitUse\n  True\n-/\nbegin\n  refl\nend\n\nlemma definition.continuous_at (f : \u211d \u2192 \u211d) (a : \u211d) :\n(continuous_at f a) \u2194 (limit_function f a (f a)) :=\n/- dEAduction\nPrettyName\n  Continuit\u00e9 en un point\n-/\nbegin\n  refl\nend\n\nlemma definition.continuous (f: \u211d \u2192 \u211d) :\n(continuous f) \u2194 \u2200 a, continuous_at f a :=\n/- dEAduction\nPrettyName\n  Continuit\u00e9\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 : \u2115 \u2192 \u211d) (c : \u211d) (H : \u2200 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\u00e9montrer, dans un cas tr\u00e8s simple,\n  l'existence d'une limite.\n-/\nbegin\n--   rw definition.limit,\n--   intros \u03b5 H\u03b5,\n--   use 0,\n--   intros n H1,\n--   rw H,\n-- `[ solve1 {norm_num at * }, trace \"EFFECTIVE CODE n\u00b04.0\"] <|> `[ `[ norm_num at *, trace \"EFFECTIVE CODE n\u00b05.0\"] <|> `[ skip, trace \"EFFECTIVE CODE n\u00b05.1\"], compute_n 10, trace \"EFFECTIVE CODE n\u00b04.1\"],\n  todo,\nend\n\nlemma exercise.croissante_non_majoree\n(u: \u2115 \u2192 \u211d) (H1: increasing_seq u) (H2: not (bounded_above u)) :\nlimit_plus_infinity u :=\n/- dEAduction\nPrettyName\n  Une suite croissante non major\u00e9e tend vers plus l'infini\nDescription\n  Dans ce deuxi\u00e8me exercice,\n  il s'agit \u00e0 nouveau de d\u00e9montrer une limite, mais infinie.\n-/\nbegin\n  todo,\nend\n\n\nlemma exercise.limite_positive\n(u : \u2115 \u2192 \u211d) (l : \u211d) (H : limit u l)\n(H' : l >0) :\n\u2203 N, \u2200 n \u2265 N, u n > 0\n:=\n/- dEAduction\nPrettyName\n  Suite dont la limite est strictement positive\nDescription\n  Dans ce troisi\u00e8me exercice,\n  il s'agit d'utiliser une hypoth\u00e8se 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: \u2115 \u2192 \u211d) (l l' : \u211d) (H : limit u l)\n(H' : limit v l'):\n(\u2200n, u n \u2264 v n ) \u2192 l \u2264 l'\n:=\n/- dEAduction\nPrettyName\n  Passage \u00e0 la limite dans une in\u00e9galit\u00e9 (*)\nDescription\n  Comment d\u00e9marrer ??\n  Comment avoir un epsilon pertinent auquel appliquer nos\n  d\u00e9finitions 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:\u211d) > 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'':\u2115) \u2265 n, rotate, have H10 := H6 n'' H9, rotate 1, solve1 {norm_num at *, tautology }, rotate,\n  -- have H11: (n'':\u2115) \u2265 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 : \u2115 \u2192 \u211d) (l : \u211d) :\n(limit u l) \u2194 \n\u2200 \u03b5 > 0, \u2203 N, \u2200 n \u2265 N, | u n - l | < 2*\u03b5\n:=\n/- dEAduction\nPrettyName\n  Couper les epsilons en deux\nDescription\n  Nous avons maintenant une limite dans les hypoth\u00e8ses,\n  et une limite dans la conclusion !\n-/\nbegin\n  todo,\nend\n\n\nlemma exercise.couper_epsilon_en_100\n(u : \u2115 \u2192 \u211d) (l : \u211d) :\n(limit u l) \u2194 \n\u2200 \u03b5 > 0, \u2203 N, \u2200 n \u2265 N, | u n - l | < 100*\u03b5\n:=\n/- dEAduction\nPrettyName\n  Couper les epsilons en cent !\nDescription\n  Simple variante du pr\u00e9c\u00e9dent,\n  pour voir si vous avez compris...\n-/\nbegin\n  todo,\nend\n\nlemma exercise.limite_somme\n(u v: \u2115 \u2192 \u211d) (l l' : \u211d) (H : limit u l)\n(H' : limit v l') :\nlimit (\u03bbn, u n + v n) (l+l')\n:=\n/- dEAduction\nPrettyName\n  Limite d'une somme\nDescription\n  Aide : il peut \u00eatre judicieux d'utiliser le r\u00e9sultat\n  d'un exercice pr\u00e9c\u00e9dent...\n-/\nbegin\n--   rw definitions.definition.limit,\n-- rw definitions.definition.limit at H H',\n-- intro \u03b5, 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 \u03b5, intro H1,\n  -- rw limit at H H',\n  -- have H2: ((\u03b5/2):\u211d) > 0, rotate, have H3 := H (\u03b5/2) H2, rotate 1, solve1 {linarith only [H1] }, rotate,\n  -- have H4: ((\u03b5/2):\u211d) > 0, rotate, have H5 := H' (\u03b5/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'':\u2115) \u2265 n, rotate, have H10 := H6 n'' H9, rotate 1, solve1 {norm_num at *, tautology }, rotate,\n  -- have H11: (n'':\u2115) \u2265 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 : \u2115 \u2192 \u211d) (l : \u211d)(l' : \u211d) (H : limit u l) (H' : limit u l') :\nl = l' \n:=\n/- dEAduction\nPrettyName\n  (*) Unicit\u00e9 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 \u03b5 := (l'-l)/2 with Heps,\n  -- have Hpos: \u03b5 >0, rotate, -- by compute1,\n  -- specialize H \u03b5 Hpos, rotate 2,\n  -- rotate,\n  \n  -- cases H with N1,\n  -- specialize H' \u03b5 Hpos, cases H' with N2,\n  -- set n := max N1 N2 with Hn,\n  -- have HnsuppN1: n \u2265 N1, from le_max_left N1 N2,\n  -- have ineq1 := H_h n HnsuppN1,\n  -- have HnsuppN2: n \u2265 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  : \u2115 \u2192 \u211d) (l : \u211d) \n(H : limit u l) (H' : limit w l)\n(H'' : \u2200n, (((u n) \u2264 v n) and ((v n) \u2264 w n))) :\nlimit v l\n:=\n/- dEAduction\nPrettyName\n  (**) Th\u00e9or\u00e8me des gendarmes\n-/\nbegin\n  todo,\nend\n\n\nlemma exercise.borne_fois_zero\n(u v: \u2115 \u2192 \u211d) (H : limit u 0)\n(H' : bounded_sequence v) :\nlimit (\u03bbn, (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\u00e9, born\u00e9 x 0\n-/\nlemma limite_produit\n(u u': \u2115 \u2192 \u211d) (l l' : \u211d) (H : limit u l)\n(H' : limit u' l') :\nlimit (\u03bbn, (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: \u211d \u2192 \u211d)\n(H0: continuous f) (H1: f(0) = 1):\n\u2203 \u03b4>(0:\u211d), \u2200 x, |x| < \u03b4 \u2192 f(x) >0 :=\n/- dEAduction\nPrettyName\n  Limite positive\nDescription\n  Deux limites en hypoth\u00e8se, une en conclusion...\n-/\nbegin\n  todo,\n  -- have H2 := (H0 0) 1 _,\n  -- rcases H2 with \u27e8\u03b4, H3, H4\u27e9,\n  -- norm_num at H4,\n  -- rw H1 at H4,\n  -- use \u03b4, 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: \u211d \u2192 \u211d) (g: \u211d \u2192 \u211d) (a b c : \u211d)\n(H0: limit_function (\u03bb x, f x) a b)\n(H1: limit_function (\u03bb y, g y) b c):\nlimit_function (\u03bb x, g ( f ( x)) ) a c :=\n/- dEAduction\nPrettyName\n  Limite et composition\nDescription\n  Deux limites en hypoth\u00e8se, une en conclusion...\n-/\nbegin\n  todo,\nend\n\n\nlemma exercise.composition_continuite (f: \u211d \u2192 \u211d) (g: \u211d \u2192 \u211d)\n(H: continuous f) (H': continuous g):\ncontinuous (composition g f) :=\n/- dEAduction\nPrettyName\n  Continuit\u00e9 et composition\n-/\nbegin \n  todo,\nend\n\n\nlemma exercise.image_convergente (u: \u2115 \u2192 \u211d) (l : \u211d) (f: \u211d \u2192 \u211d)\n(H: limit u l) (H': continuous f):\nlimit (\u03bb n, f (u n)) (f l) :=\n/- dEAduction\nPrettyName\n  Image d'une suite convergente\nDescription\n  Deux limites en hypoth\u00e8se, 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: \u2115 \u2192 \u211d) :\ncauchy u \u2194 \u2200 \u03b5>0, \u2203 N: \u2115, \u2200 p\u2265N, \u2200 q\u2265N, |u p - u q | < \u03b5\n:=\n/- dEAduction\nPrettyName\n  Suites de Cauchy\nImplicitUse\n  True\n-/\nbegin\n  refl,\nend\n\n-- definition increasing (k: \u2115 \u2192 \u2115) : Prop := \n-- \u2200 n, (k n) > (k (n+1)) \n\n-- definition limit_value (u: \u2115 \u2192 \u211d) (a: \u211d) : Prop :=\n-- \u2203 k: \u2115 \u2192 \u2115, increasing k \u2227 limit (\u03bb n, (u (k n))) a\n\n-- lemma definition.increasing (k: \u2115 \u2192 \u2115): (increasing k) \u2194\n-- \u2200 n, (k n) > (k (n+1)) :=\n-- begin\n--   refl,\n-- end\n\n-- lemma theorem.increasing_limit (k: \u2115 \u2192 \u2115) (H: increasing k):\n-- limit_plus_infinity (coe k) :=\n-- begin\n--   todo,\n-- end\n\n-- lemma definition.limit_value (u: \u2115 \u2192 \u211d) (a: \u211d) :\n-- limit_value u a \u2194\n-- \u2203 k: \u2115 \u2192 \u2115, increasing k \u2227 limit (\u03bb n, (u (k n))) a :=\n-- begin\n--   refl,\n-- end\n\n-- lemma exercise.limit_limit_value\n--  (u: \u2115 \u2192 \u211d) (a b: \u211d) (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\u00e9rence\n-- -/\n-- begin\n--   todo,\n-- end\n\nlemma exercise.convergente_implique_cauchy (u: \u2115 \u2192 \u211d): \nconverging_seq u \u2192 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 (\u03bb n, (u n)^2)  (x^2)\nend\n\n-- lemma theorem.cauchy_bounded (u: \u2115 \u2192 \u211d): \n-- cauchy u \u2192 bounded_sequence u :=\n-- /- dEAduction\n-- PrettyName\n--   Une suite de Cauchy est born\u00e9e\n-- -/\n-- begin\n--   todo,\n-- end\n\n-- lemma theorem.bounded_limit_value (u: \u2115 \u2192 \u211d): \n-- bounded_sequence u \u2192 \u2203 a, limit_value u a :=\n-- /- dEAduction\n-- PrettyName\n--   Une suite born\u00e9e a une valeur d'adh\u00e9rence\n-- -/\n-- begin\n--   todo,\n-- end\n\n-- lemma exercise.limit_value_cauchy_converge (u: \u2115 \u2192 \u211d)\n-- (H1: cauchy u) (H2: \u2203 a, limit_value u a) :\n-- converging_seq u  :=\n-- /- dEAduction\n-- PrettyName\n--   Une suite de Cauchy ayant une valeur d'adh\u00e9rence converge\n-- -/\n-- begin\n--   todo,\n-- end\n\n-- lemma exercise.cauchy_converge (u: \u2115 \u2192 \u211d)\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\u00e9 uniforme\n-/\n\nlemma definition.uniformly_continuous\n(f: \u211d \u2192 \u211d) : uniformly_continuous f \u2194\n\u2200 \u03b5>0, \u2203 \u03b4>0, \u2200 x y: \u211d,\n(|x - y| < \u03b4 \u2192 |f x - f y | < \u03b5)\n:=\n/- dEAduction\nPrettyName\n  Continuit\u00e9 uniforme\nImplicitUse\n  True\n-/\nbegin\n  refl,\nend\n\nlemma exercise.continue_de_uniformement_continue\n(f: \u211d \u2192 \u211d) (H0: uniformly_continuous f):\ncontinuous f :=\n/- dEAduction\nPrettyName\n  Uniform\u00e9ment continu implique continu\n-/\nbegin\n  todo,\nend\n\nlemma exercise.cauchy_uniformement_continue\n(u: \u2115 \u2192 \u211d) (f: \u211d \u2192 \u211d)\n(H0: cauchy u) (H1: uniformly_continuous f):\ncauchy (\u03bb n:\u2115, f (u n))\n:=\n/- dEAduction\nPrettyName\n  Image d'une suite de Cauchy\n-/\nbegin\n  todo,\nend\n\n-- TODO: cauchy => born\u00e9e, born\u00e9e => valeur d'adh,\n-- Cauchy + va => cv\n\nend continuite_uniforme\n\n-- namespace DL\n-- /- dEAduction\n-- PrettyName\n--   D\u00e9veloppements limit\u00e9s\n-- -/\n\n-- definition DL_order_0 (f: \u211d \u2192 \u211d) : Prop :=\n-- \u2203 (\u03c6 : \u211d \u2192 \u211d), (limit_function \u03c6 0 0) and \n-- (\u2200 h, f h = f 0 + \u03c6 h)\n\n-- definition DL_order_1 (f: \u211d \u2192 \u211d) (a : \u211d) : Prop :=\n-- \u2203 (\u03c6 : \u211d \u2192 \u211d), (limit_function \u03c6 0 0) and \n-- (\u2200 h, f h = f 0 + a * h + (\u03c6 h) * h)\n\n-- lemma definition.DL_order_0\n-- (f: \u211d \u2192 \u211d) (a : \u211d):\n-- (DL_order_0 f) \u2194 (\u2203 (\u03c6 : \u211d \u2192 \u211d), (limit_function \u03c6 0 0) and \n-- (\u2200 h, f h = f 0 + \u03c6 h))\n-- :=\n-- begin\n--   todo\n-- end\n\n-- example \n-- (f: \u211d \u2192 \u211d):\n-- (DL_order_0 f) \u2194 \u2203 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 \u00e0 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 \u00a9 2018 Fran\u00e7ois 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 {\u03b1 : Type*}\n\n@[reducible]\ndefinition bar (f : \u2115 \u2192 \u03b1) (n : \u2115) : fin n \u2192 \u03b1\n| \u27e8i,_\u27e9 := f i\n\n@[simp]\nlemma bar_val (f : \u2115 \u2192 \u03b1) {n : \u2115} : \n\u2200 i, (bar f n)[i] = f i.val\n| \u27e8_,_\u27e9 := rfl\n\nlemma take_bar (f : \u2115 \u2192 \u03b1) {m n : \u2115} (h : m \u2264 n) :\ntake h (bar f n) = bar f m :=\ntup.ext (\u03bb _, by simp)\n\ndefinition extend {n : \u2115} (xs : \u03b1 ^ n) (x : \u03b1) (i : \u2115) : \u03b1 :=\nif h : i < n then xs[\u27e8i,h\u27e9] else x\n\nlemma extend_of_lt {n : \u2115} {xs : \u03b1 ^ n} {x : \u03b1} {i : \u2115} (h : i < n) :\nextend xs x i = xs[\u27e8i,h\u27e9] := dif_pos h\n\nlemma extend_of_ge {n : \u2115} {xs : \u03b1 ^ n} {x : \u03b1} {i : \u2115} (h : i \u2265 n) :\nextend xs x i = x := dif_neg (not_lt_of_ge h)\n\nlemma bar_extend {n : \u2115} {xs : \u03b1 ^ n} {x : \u03b1} :\nbar (extend xs x) n = xs :=\next (\u03bb \u27e8i,h\u27e9, 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 : \u2115) : Type :=\nfin n \u2192 mv_polynomial (fin n) K\n\ndef poly_map {K : Type} [comm_semiring K] {n : \u2115} :\n  poly_map_data K n \u2192 (fin n \u2192 K) \u2192 (fin n \u2192 K) :=\n\u03bb 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 \u2192 A appends x at the end,\n-- then take the image\ndef image_append {A : Type u} [decidable_eq A] {n} :\n  A \u2192 finset (fin n \u2192 A) \u2192 finset (fin n.succ \u2192 A) :=\n\u03bb x, finset.image (\u03bb xs k, dite (\u2191k < n) (\u03bb h, xs \u27e8 k , h \u27e9) (\u03bb _ , x))\n-/\n\ndef list_image_append {A : Type u} [decidable_eq A] {n} :\n  A \u2192 list (fin n \u2192 A) \u2192 list (fin n.succ \u2192 A) :=\n\u03bb x, list.map (\u03bb xs k, dite (\u2191k < n) (\u03bb h, xs \u27e8 k , h \u27e9) (\u03bb _ , x))\n\n/-\ndef homog_basis (n d : \u2115) : set (fin n \u2192 \u2115) :=\n{ f | finset.sum (finset.range n) (\u03bb k, dite (k < n) (\u03bb h, f \u27e8 k , h \u27e9) (\u03bb h, 0)) = d }\n\n-- #check finset.sum_fin_eq_sum_range\ndef homog_basis' (n d : \u2115) : set (fin n \u2192 \u2115) :=\n{ f | finset.univ.sum (\u03bb (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 \u2192 \u2115 | \u03a3\u1d62 f i = d}\n-- for each i : fin n, we read (f i) as the degree of the variable x\u1d62\n-- hence each f represents a monomial of degree d\ndef homog_basis'' : \u03a0 (n d : \u2115), finset (fin n \u2192 \u2115)\n| 0 d := {fin_zero_elim}\n| 1 d := {\u03bb k, d}\n| (n + 2) 0 := {\u03bb k, 0}\n| (n + 2) (d + 1) :=\n  finset.bUnion (finset.range (d + 2)) (\u03bb 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 \u2192 \u2115 | \u03a3\u1d62 f i = d}\n-- for each i : fin n, we read (f i) as the degree of the variable x\u1d62\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 : \u03a0 (n d : \u2115), list (fin n \u2192 \u2115)\n| 0 d := [fin_zero_elim]\n| 1 d := [\u03bb k, d]\n| (n + 2) 0 := [\u03bb k, 0]\n| (n + 2) (d + 1) := list.join $ list.of_fn $\n  \u03bb 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 : \u2115) : list (fin n \u2192 \u2115) :=\nnat.natlist d (\u03bb 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 : \u2115) : \u2115 :=\nlist.length $ homog_basis_list n d\n-- def n_var_monomials_of_deg_lt (n d : \u2115) : \u2115 :=\n-- finset.sum (finset.range d) (\u03bb d', list.length $ homog_basis_list n d')\n\n/-\ndef homog_dim'' (n d : \u2115) : \u2115 := finset.card (homog_basis'' n d)\n\n@[simp] def homog_dim : \u03a0 (n d : \u2115), \u2115\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)) (\u03bb 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 : \u2115) : finset (mv_polynomial (fin n) \u2124) :=\n@finset.image (fin n \u2192 \u2115) (mv_polynomial (fin n) \u2124) _\n  (\u03bb ms : fin n \u2192 \u2115, big_mul (\u03bb 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 : \u2115) : finset (mv_polynomial (fin n) \u2124) :=\nfinset.bUnion (finset.range d) (\u03bb 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 : \u2115) : \u2115 :=\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 : \u2115} (i : \u2115) :\n--   bounded_ring_term (n * monomials_of_bounded_degree n d + 2 * n) :=\n-- finset.sum (homog_basis'' n d)\n--   (\u03bb p, big_mul (\u03bb j : fin n, x_ \u27e8 j , _ \u27e9))\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 {\u03b1 : Type u} (a : \u03b1) : \u03a0 (l : list \u03b1), (a \u2208 l) \u2192 fin (list.length l)\n| [] h :=\nbegin\n  exfalso,\n  rw \u2190 list.mem_nil_iff a,\n  apply h,\nend\n| (hd :: l) h := \u27e8 list.index_of a (hd :: l) , begin rw list.index_of_lt_length, apply h end \u27e9\n\n-- \u03bb a f, \u27e8 list.index_of a f , (by rw list.index_of_lt_length; simp) \u27e9\n\nend list\n\n-- #check nat.succ_le\n\n-- def lemma_idk {\u03b1 : Type u} {n d : \u2115} (l : list \u03b1) (x : \u2115) :\n--  x\n--  \u2264 (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-- \u2211 {f \u2208 n_var_monomials_of_deg n.succ d} x\u208d\u2c7c\u208a\u209b\u208e \u220f {0 \u2264 i < n} x\u208d\u1d62\u208a\u209a\u208e\u1da0\u207d\u2071\u207e 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 : \u2115) (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  (\u03bb f : (fin n.succ \u2192 \u2115),\n    (x_ \u27e8 (list.index_of f (n_var_monomials_of_deg n.succ d) + s) % c , nat.mod_lt _ h \u27e9)\n    *\n    (nat.prod n.succ $ \u03bb i, (x_ \u27e8 (i + p) % c , nat.mod_lt _ h \u27e9) ^ (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--  (\u03bb p, big_mul (\u03bb j : fin n, x_ \u27e8 j , _ \u27e9))\n\nlemma inj_formula_aux {n d : \u2115} :\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 : \u2115} :\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\u2c7c indexed by\n-- their monomial coefficients,\n-- if for all x\u1d62 and all y\u1d62, every polynomial satisfies p\u2c7c x\u1d62 = p\u2c7c y\u1d62\n-- then each x\u1d62 = y\u1d62.\n-- This says the polynomial map formed by the p\u2c7cs is injective\ndef inj_formula (n d : \u2115) :\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\u208b \u2208 K\u207f\u207a\u00b9 and y\u208b \u2208 K\u207f\u207a\u00b9\nbd_alls' (2 * n.succ) _\n$\n-- if at each p\u2c7c\n(bd_big_and n.succ\n-- p\u2c7c x\u1d62 = p\u2c7c y\u1d62\n  (\u03bb j,\n    (poly_indexed_by_monos n.succ d (2 * n.succ + j * monom) 0 _ inj_formula_aux)\n    \u2243\n    (poly_indexed_by_monos n.succ d (2 * n.succ + j * monom) (n.succ) _ inj_formula_aux)\n  )\n)\n-- then\n\u27f9\n-- at each 0 \u2264 i < n.succ,\n(bd_big_and n.succ $\n-- x\u1d62 = y\u1d62 (where y\u1d62 is written as x\u1d62\u208a\u2099\u208a\u2081)\n  \u03bb i, x_ \u27e8 i % c , nat.mod_lt _ inj_formula_aux \u27e9\n  \u2243\n  x_ \u27e8 (i + n.succ) % c , nat.mod_lt _ inj_formula_aux \u27e9\n)\n\ndef surj_formula (n d : \u2115) :\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\u208b \u2208 K\u207f\u207a\u00b9 in the codomain\nbd_alls' n.succ _\n$\n-- there exists x\u208b \u2208 K\u207f\u207a\u00b9 in the domain such that\nbd_exs' n.succ _\n$\n-- at each 0 \u2264 j < n.succ\nbd_big_and n.succ\n$\n-- z\u2c7c = p\u2c7c x\u208b\n\u03bb j, x_ j \u2243 poly_indexed_by_monos n.succ d (n.succ + n.succ + j * monom) 0 _ inj_formula_aux'\n\ndef Ax_Groth_Formula {n d : \u2115} : 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 \u27f9 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 : \u2115}\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\n\nType of functions with finite support.\n\nFunctions with finite support provide the basis for the following concrete instances:\n\n * \u2115 \u2192\u2080 \u03b1: Polynomials (where \u03b1 is a ring)\n * (\u03c3 \u2192\u2080 \u2115) \u2192\u2080 \u03b1: Multivariate Polynomials (again \u03b1 is a ring, and \u03c3 are variable names)\n * \u03b1 \u2192\u2080 \u2115: Multisets\n * \u03b1 \u2192\u2080 \u2124: Abelian groups freely generated by \u03b1\n * \u03b2 \u2192\u2080 \u03b1: Linear combinations over \u03b2 where \u03b1 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 \u03b1 \u2192\u2080 \u03b2 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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*} {\u03b9 : Type*}\n  {\u03b1\u2081 : Type*} {\u03b1\u2082 : Type*} {\u03b2\u2081 : Type*} {\u03b2\u2082 : Type*}\n\nreserve infix ` \u2192\u2080 `:25\n\n/-- `finsupp \u03b1 \u03b2`, denoted `\u03b1 \u2192\u2080 \u03b2`, is the type of functions `f : \u03b1 \u2192 \u03b2` such that\n  `f x = 0` for all but finitely many `x`. -/\nstructure finsupp (\u03b1 : Type*) (\u03b2 : Type*) [has_zero \u03b2] :=\n(support            : finset \u03b1)\n(to_fun             : \u03b1 \u2192 \u03b2)\n(mem_support_to_fun : \u2200a, a \u2208 support \u2194 to_fun a \u2260 0)\n\ninfix \u2192\u2080 := finsupp\n\nnamespace finsupp\n\nsection basic\nvariable [has_zero \u03b2]\n\ninstance : has_coe_to_fun (\u03b1 \u2192\u2080 \u03b2) := \u27e8\u03bb_, \u03b1 \u2192 \u03b2, finsupp.to_fun\u27e9\n\ninstance : has_zero (\u03b1 \u2192\u2080 \u03b2) := \u27e8\u27e8\u2205, (\u03bb_, 0), by simp\u27e9\u27e9\n\n@[simp] lemma zero_apply {a : \u03b1} : (0 : \u03b1 \u2192\u2080 \u03b2) a = 0 := rfl\n\n@[simp] lemma support_zero : (0 : \u03b1 \u2192\u2080 \u03b2).support = \u2205 := rfl\n\ninstance : inhabited (\u03b1 \u2192\u2080 \u03b2) := \u27e80\u27e9\n\n@[simp] lemma mem_support_iff (f : \u03b1 \u2192\u2080 \u03b2) : \u2200a:\u03b1, a \u2208 f.support \u2194 f a \u2260 0 :=\nf.mem_support_to_fun\n\n@[extensionality]\nlemma ext : \u2200{f g : \u03b1 \u2192\u2080 \u03b2}, (\u2200a, f a = g a) \u2192 f = g\n| \u27e8s, f, hf\u27e9 \u27e8t, g, hg\u27e9 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 \u03b2] {f : \u03b1 \u2192\u2080 \u03b2} : f.support = \u2205 \u2194 f = 0 :=\n\u27e8assume h, ext $ assume a, by simp [finset.ext] at h; exact h a, by simp {contextual:=tt}\u27e9\n\ninstance [decidable_eq \u03b1] [decidable_eq \u03b2] : decidable_eq (\u03b1 \u2192\u2080 \u03b2) :=\nassume f g, decidable_of_iff (f.support = g.support \u2227 (\u2200a\u2208f.support, f a = g a))\n  \u27e8assume \u27e8h\u2081, h\u2082\u27e9, ext $ assume a,\n      if h : a \u2208 f.support then h\u2082 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\u2081, g.mem_support_iff, not_not] at h,\n        by rw [hf, hg],\n    by intro h; subst h; simp\u27e9\n\nlemma finite_supp (f : \u03b1 \u2192\u2080 \u03b2) : set.finite {a | f a \u2260 0} :=\n\u27e8set.fintype_of_finset f.support f.mem_support_iff\u27e9\n\nlemma support_subset_iff {s : set \u03b1} {f : \u03b1 \u2192\u2080 \u03b2} [decidable_eq \u03b1] :\n  \u2191f.support \u2286 s \u2194 (\u2200a\u2209s, 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 \u03b1] [decidable_eq \u03b2] [has_zero \u03b2] {a a' : \u03b1} {b : \u03b2}\n\n/-- `single a b` is the finitely supported function which has\n  value `b` at `a` and zero otherwise. -/\ndef single (a : \u03b1) (b : \u03b2) : \u03b1 \u2192\u2080 \u03b2 :=\n\u27e8(if b = 0 then \u2205 else {a}), (\u03bba', 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\u27e9\n\nlemma single_apply : (single a b : \u03b1 \u2192\u2080 \u03b2) a' = (if a = a' then b else 0) :=\nrfl\n\n@[simp] lemma single_eq_same : (single a b : \u03b1 \u2192\u2080 \u03b2) a = b :=\nby simp [single_apply]\n\n@[simp] lemma single_eq_of_ne (h : a \u2260 a') : (single a b : \u03b1 \u2192\u2080 \u03b2) a' = 0 :=\nby simp [single_apply, h]\n\n@[simp] lemma single_zero : (single a 0 : \u03b1 \u2192\u2080 \u03b2) = 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 \u2260 0) : (single a b).support = {a} :=\nif_neg hb\n\nlemma support_single_subset : (single a b).support \u2286 {a} :=\nby by_cases b = 0; simp [support_single_ne_zero, h]\n\nend single\n\nsection on_finset\nvariables [decidable_eq \u03b2] [has_zero \u03b2]\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 \u03b1) (f : \u03b1 \u2192 \u03b2) (hf : \u2200a, f a \u2260 0 \u2192 a \u2208 s) : \u03b1 \u2192\u2080 \u03b2 :=\n\u27e8s.filter (\u03bba, f a \u2260 0), f,\n  assume a, classical.by_cases\n    (assume h : f a = 0, by simp [h])\n    (assume h : f a \u2260 0, by simp [h, hf])\u27e9\n\n@[simp] lemma on_finset_apply {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} {hf a} :\n  (on_finset s f hf : \u03b1 \u2192\u2080 \u03b2) a = f a :=\nrfl\n\n@[simp] lemma support_on_finset_subset {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} {hf} :\n  (on_finset s f hf).support \u2286 s :=\nby simp [on_finset]\n\nend on_finset\n\nsection map_range\nvariables [has_zero \u03b2\u2081] [has_zero \u03b2\u2082] [decidable_eq \u03b2\u2082]\n\n/-- The composition of `f : \u03b2\u2081 \u2192 \u03b2\u2082` and `g : \u03b1 \u2192\u2080 \u03b2\u2081` is\n  `map_range f hf g : \u03b1 \u2192\u2080 \u03b2\u2082`, well defined when `f 0 = 0`. -/\ndef map_range (f : \u03b2\u2081 \u2192 \u03b2\u2082) (hf : f 0 = 0) (g : \u03b1 \u2192\u2080 \u03b2\u2081) : \u03b1 \u2192\u2080 \u03b2\u2082 :=\non_finset g.support (f \u2218 g) $\n  assume a, by rw [mem_support_iff, not_imp_not]; simp [hf] {contextual := tt}\n\n@[simp] lemma map_range_apply {f : \u03b2\u2081 \u2192 \u03b2\u2082} {hf : f 0 = 0} {g : \u03b1 \u2192\u2080 \u03b2\u2081} {a : \u03b1} :\n  map_range f hf g a = f (g a) :=\nrfl\n\nlemma support_map_range {f : \u03b2\u2081 \u2192 \u03b2\u2082} {hf : f 0 = 0} {g : \u03b1 \u2192\u2080 \u03b2\u2081} :\n  (map_range f hf g).support \u2286 g.support :=\nsupport_on_finset_subset\n\nvariables [decidable_eq \u03b1] [decidable_eq \u03b2\u2081]\n@[simp] lemma map_range_single {f : \u03b2\u2081 \u2192 \u03b2\u2082} {hf : f 0 = 0} {a : \u03b1} {b : \u03b2\u2081} :\n  map_range f hf (single a b) = single a (f b) :=\nfinsupp.ext $ \u03bb a', by by_cases a = a'; [{subst a', simp}, simp [h, hf]]\n\nend map_range\n\nsection zip_with\nvariables [has_zero \u03b2] [has_zero \u03b2\u2081] [has_zero \u03b2\u2082] [decidable_eq \u03b1] [decidable_eq \u03b2]\n\n/-- `zip_with f hf g\u2081 g\u2082` is the finitely supported function satisfying\n  `zip_with f hf g\u2081 g\u2082 a = f (g\u2081 a) (g\u2082 a)`, and well defined when `f 0 0 = 0`. -/\ndef zip_with (f : \u03b2\u2081 \u2192 \u03b2\u2082 \u2192 \u03b2) (hf : f 0 0 = 0) (g\u2081 : \u03b1 \u2192\u2080 \u03b2\u2081) (g\u2082 : \u03b1 \u2192\u2080 \u03b2\u2082) : (\u03b1 \u2192\u2080 \u03b2) :=\non_finset (g\u2081.support \u222a g\u2082.support) (\u03bba, f (g\u2081 a) (g\u2082 a)) $\n  assume a, classical.by_cases\n    (assume h : g\u2081 a = 0, by simp [h]; rw [not_imp_not]; simp [hf] {contextual := tt})\n    (assume h : g\u2081 a \u2260 0, by simp [h])\n\n@[simp] lemma zip_with_apply\n  {f : \u03b2\u2081 \u2192 \u03b2\u2082 \u2192 \u03b2} {hf : f 0 0 = 0} {g\u2081 : \u03b1 \u2192\u2080 \u03b2\u2081} {g\u2082 : \u03b1 \u2192\u2080 \u03b2\u2082} {a : \u03b1} :\n  zip_with f hf g\u2081 g\u2082 a = f (g\u2081 a) (g\u2082 a) :=\nrfl\n\nlemma support_zip_with {f : \u03b2\u2081 \u2192 \u03b2\u2082 \u2192 \u03b2} {hf : f 0 0 = 0} {g\u2081 : \u03b1 \u2192\u2080 \u03b2\u2081} {g\u2082 : \u03b1 \u2192\u2080 \u03b2\u2082} :\n  (zip_with f hf g\u2081 g\u2082).support \u2286 g\u2081.support \u222a g\u2082.support :=\nsupport_on_finset_subset\n\nend zip_with\n\nsection erase\nvariables [decidable_eq \u03b1] [decidable_eq \u03b2]\n\ndef erase [has_zero \u03b2] (a : \u03b1) (f : \u03b1 \u2192\u2080 \u03b2) : \u03b1 \u2192\u2080 \u03b2 :=\n\u27e8f.support.erase a, (\u03bba', if a' = a then 0 else f a'),\n  assume a', by by_cases a' = a; simp [h]\u27e9\n\n@[simp] lemma support_erase [has_zero \u03b2] {a : \u03b1} {f : \u03b1 \u2192\u2080 \u03b2} :\n  (f.erase a).support = f.support.erase a :=\nrfl\n\n@[simp] lemma erase_same [has_zero \u03b2] {a : \u03b1} {f : \u03b1 \u2192\u2080 \u03b2} : (f.erase a) a = 0 :=\nif_pos rfl\n\n@[simp] lemma erase_ne [has_zero \u03b2] {a a' : \u03b1} {f : \u03b1 \u2192\u2080 \u03b2} (h : a' \u2260 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 \u03b2] [add_comm_monoid \u03b3] (f : \u03b1 \u2192\u2080 \u03b2) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u03b3 :=\nf.support.sum (\u03bba, 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 \u03b2] [comm_monoid \u03b3] (f : \u03b1 \u2192\u2080 \u03b2) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u03b3 :=\nf.support.prod (\u03bba, 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 \u03b2\u2081] [has_zero \u03b2\u2082] [comm_monoid \u03b3] [decidable_eq \u03b2\u2082]\n  {f : \u03b2\u2081 \u2192 \u03b2\u2082} {hf : f 0 = 0} {g : \u03b1 \u2192\u2080 \u03b2\u2081} {h : \u03b1 \u2192 \u03b2\u2082 \u2192 \u03b3} (h0 : \u2200a, h a 0 = 1) :\n  (map_range f hf g).prod h = g.prod (\u03bba 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 \u03b2] [comm_monoid \u03b3] {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  (0 : \u03b1 \u2192\u2080 \u03b2).prod h = 1 :=\nby simp [finsupp.prod]\n\nsection decidable\nvariables [decidable_eq \u03b1] [decidable_eq \u03b2]\n\nsection add_monoid\nvariables [add_monoid \u03b2]\n\n@[to_additive finsupp.sum_single_index]\nlemma prod_single_index [comm_monoid \u03b3] {a : \u03b1} {b : \u03b2} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (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 (\u03b1 \u2192\u2080 \u03b2) := \u27e8zip_with (+) (add_zero 0)\u27e9\n\n@[simp] lemma add_apply {g\u2081 g\u2082 : \u03b1 \u2192\u2080 \u03b2} {a : \u03b1} : (g\u2081 + g\u2082) a = g\u2081 a + g\u2082 a :=\nrfl\n\nlemma support_add {g\u2081 g\u2082 : \u03b1 \u2192\u2080 \u03b2} : (g\u2081 + g\u2082).support \u2286 g\u2081.support \u222a g\u2082.support :=\nsupport_zip_with\n\nlemma support_add_eq {g\u2081 g\u2082 : \u03b1 \u2192\u2080 \u03b2} (h : disjoint g\u2081.support g\u2082.support):\n  (g\u2081 + g\u2082).support = g\u2081.support \u222a g\u2082.support :=\nle_antisymm support_zip_with $ assume a ha,\n(finset.mem_union.1 ha).elim\n  (assume ha, have a \u2209 g\u2082.support, from disjoint_left.1 h ha, by simp * at *)\n  (assume ha, have a \u2209 g\u2081.support, from disjoint_right.1 h ha, by simp * at *)\n\n@[simp] lemma single_add {a : \u03b1} {b\u2081 b\u2082 : \u03b2} : single a (b\u2081 + b\u2082) = single a b\u2081 + single a b\u2082 :=\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 (\u03b1 \u2192\u2080 \u03b2) :=\n{ add_monoid .\n  zero      := 0,\n  add       := (+),\n  add_assoc := assume \u27e8s, f, hf\u27e9 \u27e8t, g, hg\u27e9 \u27e8u, h, hh\u27e9, ext $ assume a, add_assoc _ _ _,\n  zero_add  := assume \u27e8s, f, hf\u27e9, ext $ assume a, zero_add _,\n  add_zero  := assume \u27e8s, f, hf\u27e9, ext $ assume a, add_zero _ }\n\nlemma single_add_erase {a : \u03b1} {f : \u03b1 \u2192\u2080 \u03b2} : single a (f a) + f.erase a = f :=\next $ \u03bb a',\nif h : a = a' then by subst h; simp\nelse by simp [ne.symm h, h]\n\nlemma erase_add_single {a : \u03b1} {f : \u03b1 \u2192\u2080 \u03b2} : f.erase a + single a (f a) = f :=\next $ \u03bb a',\nif h : a = a' then by subst h; simp\nelse by simp [ne.symm h, h]\n\nprotected theorem induction {p : (\u03b1 \u2192\u2080 \u03b2) \u2192 Prop} (f : \u03b1 \u2192\u2080 \u03b2)\n  (h0 : p 0) (ha : \u2200a b (f : \u03b1 \u2192\u2080 \u03b2), a \u2209 f.support \u2192 b \u2260 0 \u2192 p f \u2192 p (single a b + f)) :\n  p f :=\nsuffices \u2200s (f : \u03b1 \u2192\u2080 \u03b2), f.support = s \u2192 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 [\u2190 mem_support_iff _ a, hf], simp },\n  { apply ih _ _,\n    simp [hf, has, finset.erase_insert] }\nend\n\nlemma induction\u2082 {p : (\u03b1 \u2192\u2080 \u03b2) \u2192 Prop} (f : \u03b1 \u2192\u2080 \u03b2)\n  (h0 : p 0) (ha : \u2200a b (f : \u03b1 \u2192\u2080 \u03b2), a \u2209 f.support \u2192 b \u2260 0 \u2192 p f \u2192 p (f + single a b)) :\n  p f :=\nsuffices \u2200s (f : \u03b1 \u2192\u2080 \u03b2), f.support = s \u2192 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 [\u2190 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 \u03b2] : add_comm_monoid (\u03b1 \u2192\u2080 \u03b2) :=\n{ add_comm := assume \u27e8s, f, _\u27e9 \u27e8t, g, _\u27e9, ext $ assume a, add_comm _ _,\n  .. finsupp.add_monoid }\n\ninstance [add_group \u03b2] : add_group (\u03b1 \u2192\u2080 \u03b2) :=\n{ neg          := map_range (has_neg.neg) neg_zero,\n  add_left_neg := assume \u27e8s, f, _\u27e9, ext $ assume x, add_left_neg _,\n  .. finsupp.add_monoid }\n\nlemma single_multiset_sum [add_comm_monoid \u03b2] [decidable_eq \u03b1] [decidable_eq \u03b2]\n  (s : multiset \u03b2) (a : \u03b1) : 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 \u03b2] [decidable_eq \u03b1] [decidable_eq \u03b2]\n  (s : finset \u03b3) (f : \u03b3 \u2192 \u03b2) (a : \u03b1) : single a (s.sum f) = s.sum (\u03bbb, 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 \u03b3] [add_comm_monoid \u03b2] [decidable_eq \u03b1] [decidable_eq \u03b2]\n  (s : \u03b4 \u2192\u2080 \u03b3) (f : \u03b4 \u2192 \u03b3 \u2192 \u03b2) (a : \u03b1) : single a (s.sum f) = s.sum (\u03bbd c, single a (f d c)) :=\nsingle_finset_sum _ _ _\n\n\n@[to_additive finsupp.sum_neg_index]\nlemma prod_neg_index [add_group \u03b2] [comm_monoid \u03b3]\n  {g : \u03b1 \u2192\u2080 \u03b2} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (h0 : \u2200a, h a 0 = 1) :\n  (-g).prod h = g.prod (\u03bba b, h a (- b)) :=\nprod_map_range_index h0\n\n@[simp] lemma neg_apply [add_group \u03b2] {g : \u03b1 \u2192\u2080 \u03b2} {a : \u03b1} : (- g) a = - g a := rfl\n\n@[simp] lemma sub_apply [add_group \u03b2] {g\u2081 g\u2082 : \u03b1 \u2192\u2080 \u03b2} {a : \u03b1} : (g\u2081 - g\u2082) a = g\u2081 a - g\u2082 a := rfl\n\n@[simp] lemma support_neg [add_group \u03b2] {f : \u03b1 \u2192\u2080 \u03b2} : support (-f) = support f :=\nfinset.subset.antisymm\n  support_map_range\n  (calc support f = support (- (- f)) : by simp\n     ... \u2286 support (- f) : support_map_range)\n\ninstance [add_comm_group \u03b2] : add_comm_group (\u03b1 \u2192\u2080 \u03b2) :=\n{ add_comm := add_comm, ..finsupp.add_group }\n\n@[simp] lemma sum_apply [has_zero \u03b2\u2081] [add_comm_monoid \u03b2]\n  {f : \u03b1\u2081 \u2192\u2080 \u03b2\u2081} {g : \u03b1\u2081 \u2192 \u03b2\u2081 \u2192 \u03b1 \u2192\u2080 \u03b2} {a\u2082 : \u03b1} :\n  (f.sum g) a\u2082 = f.sum (\u03bba\u2081 b, g a\u2081 b a\u2082) :=\n(finset.sum_hom (\u03bbf : \u03b1 \u2192\u2080 \u03b2, f a\u2082) rfl (assume a b, rfl)).symm\n\nlemma support_sum [has_zero \u03b2\u2081] [add_comm_monoid \u03b2]\n  {f : \u03b1\u2081 \u2192\u2080 \u03b2\u2081} {g : \u03b1\u2081 \u2192 \u03b2\u2081 \u2192 (\u03b1 \u2192\u2080 \u03b2)} :\n  (f.sum g).support \u2286 f.support.bind (\u03bba, (g a (f a)).support) :=\nhave \u2200a\u2081 : \u03b1, f.sum (\u03bb (a : \u03b1\u2081) (b : \u03b2\u2081), (g a b) a\u2081) \u2260 0 \u2192\n    (\u2203 (a : \u03b1\u2081), f a \u2260 0 \u2227 \u00ac (g a (f a)) a\u2081 = 0),\n  from assume a\u2081 h,\n  let \u27e8a, ha, ne\u27e9 := finset.exists_ne_zero_of_sum_ne_zero h in\n  \u27e8a, (f.mem_support_iff a).mp ha, ne\u27e9,\nby simpa [finset.subset_iff, mem_support_iff, finset.mem_bind, sum_apply] using this\n\n@[simp] lemma sum_zero [add_comm_monoid \u03b2] [add_comm_monoid \u03b3] {f : \u03b1 \u2192\u2080 \u03b2} :\n  f.sum (\u03bba b, (0 : \u03b3)) = 0 :=\nfinset.sum_const_zero\n\n@[simp] lemma sum_add  [add_comm_monoid \u03b2] [add_comm_monoid \u03b3] {f : \u03b1 \u2192\u2080 \u03b2}\n  {h\u2081 h\u2082 : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  f.sum (\u03bba b, h\u2081 a b + h\u2082 a b) = f.sum h\u2081 + f.sum h\u2082 :=\nfinset.sum_add_distrib\n\n@[simp] lemma sum_neg [add_comm_monoid \u03b2] [add_comm_group \u03b3] {f : \u03b1 \u2192\u2080 \u03b2}\n  {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} : f.sum (\u03bba b, - h a b) = - f.sum h :=\nfinset.sum_hom (@has_neg.neg \u03b3 _) neg_zero (assume a b, neg_add _ _)\n\n@[simp] lemma sum_single [add_comm_monoid \u03b2] {f : \u03b1 \u2192\u2080 \u03b2} :\n  f.sum single = f :=\nhave \u2200a:\u03b1, f.sum (\u03bba' b, ite (a' = a) b 0) =\n    ({a} : finset \u03b1).sum (\u03bba', ite (a' = a) (f a') 0),\nbegin\n  intro a,\n  by_cases h : a \u2208 f.support,\n  { have : (finset.singleton a : finset \u03b1) \u2286 f.support,\n      { simp [finset.subset_iff, *] at * },\n    refine (finset.sum_subset this _).symm,\n    simp {contextual := tt} },\n  { transitivity (f.support.sum (\u03bba, (0 : \u03b2))),\n    { refine (finset.sum_congr rfl _),\n      intros a' ha',\n      have h: a' \u2260 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 \u03b2] [comm_monoid \u03b3] {f g : \u03b1 \u2192\u2080 \u03b2}\n  {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (h_zero : \u2200a, h a 0 = 1) (h_add : \u2200a b\u2081 b\u2082, h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082) :\n  (f + g).prod h = f.prod h * g.prod h :=\nhave f_eq : (f.support \u222a g.support).prod (\u03bba, 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 \u222a g.support).prod (\u03bba, 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 (\u03bba, h a ((f + g) a)) =\n      (f.support \u222a g.support).prod (\u03bba, h a ((f + g) a)) :\n    finset.prod_subset support_add $\n      by simp [mem_support_iff, h_zero] {contextual := tt}\n  ... = (f.support \u222a g.support).prod (\u03bba, h a (f a)) *\n      (f.support \u222a g.support).prod (\u03bba, 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 \u03b2] [add_comm_group \u03b3] {f g : \u03b1 \u2192\u2080 \u03b2}\n  {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (h_sub : \u2200a b\u2081 b\u2082, h a (b\u2081 - b\u2082) = h a b\u2081 - h a b\u2082) :\n  (f - g).sum h = f.sum h - g.sum h :=\nhave h_zero : \u2200a, 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 : \u2200a 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 : \u2200a b\u2081 b\u2082, h a (b\u2081 + b\u2082) = h a b\u2081 + h a b\u2082,\n  from assume a b\u2081 b\u2082,\n  have h a (b\u2081 - (- b\u2082)) = h a b\u2081 - h a (- b\u2082), from h_sub a b\u2081 (-b\u2082),\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 \u03b2] [comm_monoid \u03b3] [decidable_eq \u03b9]\n  {s : finset \u03b9} {g : \u03b9 \u2192 \u03b1 \u2192\u2080 \u03b2}\n  {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (h_zero : \u2200a, h a 0 = 1) (h_add : \u2200a b\u2081 b\u2082, h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082):\n  s.prod (\u03bbi, (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 \u03b1\u2081] [add_comm_monoid \u03b2\u2081] [add_comm_monoid \u03b2] [comm_monoid \u03b3]\n  {f : \u03b1\u2081 \u2192\u2080 \u03b2\u2081} {g : \u03b1\u2081 \u2192 \u03b2\u2081 \u2192 \u03b1 \u2192\u2080 \u03b2}\n  {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (h_zero : \u2200a, h a 0 = 1) (h_add : \u2200a b\u2081 b\u2082, h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082):\n  (f.sum g).prod h = f.prod (\u03bba 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 \u03b1] [decidable_eq \u03b2] [add_comm_monoid \u03b2] [add_comm_monoid \u03b3]\n  (f : multiset (\u03b1 \u2192\u2080 \u03b2)) (h : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (h\u2080 : \u2200a, h a 0 = 0) (h\u2081 : \u2200 (a : \u03b1) (b\u2081 b\u2082 : \u03b2), h a (b\u2081 + b\u2082) = h a b\u2081 + h a b\u2082) :\n  (f.sum.sum h) = (f.map $ \u03bbg:\u03b1 \u2192\u2080 \u03b2, 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\u2080 h\u2081, ih] {contextual := tt})\n\nlemma multiset_map_sum [has_zero \u03b2] {f : \u03b1 \u2192\u2080 \u03b2} {m : \u03b3 \u2192 \u03b4} {h : \u03b1 \u2192 \u03b2 \u2192 multiset \u03b3} :\n  multiset.map m (f.sum h) = f.sum (\u03bba 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 \u03b2] [add_comm_monoid \u03b3] {f : \u03b1 \u2192\u2080 \u03b2} {h : \u03b1 \u2192 \u03b2 \u2192 multiset \u03b3} :\n  multiset.sum (f.sum h) = f.sum (\u03bba 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 \u03b1\u2081] [decidable_eq \u03b1\u2082] [add_comm_monoid \u03b2] {v v\u2081 v\u2082 : \u03b1 \u2192\u2080 \u03b2}\n\n/-- Given `f : \u03b1\u2081 \u2192 \u03b1\u2082` and `v : \u03b1\u2081 \u2192\u2080 \u03b2`, `map_domain f v : \u03b1\u2082 \u2192\u2080 \u03b2`\n  is the finitely supported function whose value at `a : \u03b1\u2082` is the sum\n  of `v x` over all `x` such that `f x = a`. -/\ndef map_domain (f : \u03b1\u2081 \u2192 \u03b1\u2082) (v : \u03b1\u2081 \u2192\u2080 \u03b2) : \u03b1\u2082 \u2192\u2080 \u03b2 :=\nv.sum $ \u03bba, single (f a)\n\nlemma map_domain_id : map_domain id v = v :=\nsum_single\n\nlemma map_domain_comp {f : \u03b1 \u2192 \u03b1\u2081} {g : \u03b1\u2081 \u2192 \u03b1\u2082} :\n  map_domain (g \u2218 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 : \u03b1 \u2192 \u03b1\u2081} {a : \u03b1} {b : \u03b2} : map_domain f (single a b) = single (f a) b :=\nsum_single_index (by simp)\n\nlemma map_domain_zero {f : \u03b1 \u2192 \u03b1\u2082} : map_domain f 0 = (0 : \u03b1\u2082 \u2192\u2080 \u03b2) :=\nsum_zero_index\n\nlemma map_domain_congr {f g : \u03b1 \u2192 \u03b1\u2082} (h : \u2200x\u2208v.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 : \u03b1 \u2192 \u03b1\u2082} : map_domain f (v\u2081 + v\u2082) = map_domain f v\u2081 + map_domain f v\u2082 :=\nsum_add_index (by simp) (by simp)\n\nlemma map_domain_finset_sum [decidable_eq \u03b9] {f : \u03b1 \u2192 \u03b1\u2082} {s : finset \u03b9} {v : \u03b9 \u2192 \u03b1 \u2192\u2080 \u03b2} :\n  map_domain f (s.sum v) = s.sum (\u03bbi, map_domain f (v i)) :=\nby refine (sum_finset_sum_index _ _).symm; simp\n\nlemma map_domain_sum [has_zero \u03b2\u2081] {f : \u03b1 \u2192 \u03b1\u2082} {s : \u03b1 \u2192\u2080 \u03b2\u2081} {v : \u03b1 \u2192 \u03b2\u2081 \u2192 \u03b1 \u2192\u2080 \u03b2} :\n  map_domain f (s.sum v) = s.sum (\u03bba b, map_domain f (v a b)) :=\nby refine (sum_finset_sum_index _ _).symm; simp\n\nlemma map_domain_support {f : \u03b1 \u2192 \u03b1\u2082} {s : \u03b1 \u2192\u2080 \u03b2} :\n  (s.map_domain f).support \u2286 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 \u03b3] {f : \u03b1 \u2192 \u03b1\u2082} {s : \u03b1 \u2192\u2080 \u03b2}\n  {h : \u03b1\u2082 \u2192 \u03b2 \u2192 \u03b3} (h_zero : \u2200a, h a 0 = 1) (h_add : \u2200a b\u2081 b\u2082, h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082) :\n  (s.map_domain f).prod h = s.prod (\u03bba 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 : \u03b1 \u2192\u2080 \u03b2` 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 `\u03b1` is the monoid of monomial exponents.) -/\ninstance [has_add \u03b1] [semiring \u03b2] : has_mul (\u03b1 \u2192\u2080 \u03b2) :=\n\u27e8\u03bbf g, f.sum $ \u03bba\u2081 b\u2081, g.sum $ \u03bba\u2082 b\u2082, single (a\u2081 + a\u2082) (b\u2081 * b\u2082)\u27e9\n\nlemma mul_def [has_add \u03b1] [semiring \u03b2] {f g : \u03b1 \u2192\u2080 \u03b2} :\n  f * g = (f.sum $ \u03bba\u2081 b\u2081, g.sum $ \u03bba\u2082 b\u2082, single (a\u2081 + a\u2082) (b\u2081 * b\u2082)) := 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 \u03b1] [has_zero \u03b2] [has_one \u03b2] : has_one (\u03b1 \u2192\u2080 \u03b2) :=\n\u27e8single 0 1\u27e9\n\nlemma one_def [has_zero \u03b1] [has_zero \u03b2] [has_one \u03b2] : 1 = (single 0 1 : \u03b1 \u2192\u2080 \u03b2) := rfl\n\nsection filter -- TODO: remove filter? build upon subtype_domain?\nsection has_zero\nvariables [has_zero \u03b2] {p : \u03b1 \u2192 Prop} [decidable_pred p] {f : \u03b1 \u2192\u2080 \u03b2}\n\n/-- `filter p f` is the function which is `f a` if `p a` is true and 0 otherwise. -/\ndef filter (p : \u03b1 \u2192 Prop) [decidable_pred p] (f : \u03b1 \u2192\u2080 \u03b2) : \u03b1 \u2192\u2080 \u03b2 :=\non_finset f.support (\u03bba, 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 : \u03b1} (h : p a) : f.filter p a = f a :=\nif_pos h\n\n@[simp] lemma filter_apply_neg {a : \u03b1} (h : \u00ac 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 \u03b2] {f : \u03b1 \u2192\u2080 \u03b2} {p : \u03b1 \u2192 Prop}\n  [decidable_pred p] [decidable_pred (\u03bba, \u00ac p a)] :\n  f.filter p + f.filter (\u03bba, \u00ac p a) = f :=\nfinsupp.ext $ assume a, by by_cases p a; simp *\n\nend filter\n\nsection subtype_domain\n\nvariables {\u03b1' : Type*} [has_zero \u03b4] {p : \u03b1 \u2192 Prop} [decidable_pred p]\n\nsection zero\nvariables [has_zero \u03b2] {v v' : \u03b1' \u2192\u2080 \u03b2}\n\n/-- `subtype_domain p f` is the restriction of the finitely supported function\n  `f` to the subtype `p`. -/\ndef subtype_domain (p : \u03b1 \u2192 Prop) [decidable_pred p] (f : \u03b1 \u2192\u2080 \u03b2) : (subtype p \u2192\u2080 \u03b2) :=\n\u27e8f.support.subtype p, f \u2218 subtype.val, by simp\u27e9\n\n@[simp] lemma support_subtype_domain {f : \u03b1 \u2192\u2080 \u03b2} :\n  (subtype_domain p f).support = f.support.subtype p :=\nrfl\n\n@[simp] lemma subtype_domain_apply {a : subtype p} {v : \u03b1 \u2192\u2080 \u03b2} :\n  (subtype_domain p v) a = v (a.val) :=\nrfl\n\n@[simp] lemma subtype_domain_zero : subtype_domain p (0 : \u03b1 \u2192\u2080 \u03b2) = 0 :=\nrfl\n\n@[to_additive finsupp.sum_subtype_domain_index]\nlemma prod_subtype_domain_index [comm_monoid \u03b3] {v : \u03b1 \u2192\u2080 \u03b2}\n  {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hp : \u2200x\u2208v.support, p x) :\n  (v.subtype_domain p).prod (\u03bba b, h a.1 b) = v.prod h :=\nprod_bij (\u03bbp _, p.val)\n  (by simp)\n  (by simp)\n  (assume \u27e8a\u2080, ha\u2080\u27e9 \u27e8a\u2081, ha\u2081\u27e9, by simp)\n  (begin simp; exact assume b hb, \u27e8b, hp _ (by simp [hb]), by simp [hb]\u27e9 end)\n\nend zero\n\nsection monoid\nvariables [add_monoid \u03b2] {v v' : \u03b1' \u2192\u2080 \u03b2}\n\n@[simp] lemma subtype_domain_add {v v' : \u03b1 \u2192\u2080 \u03b2} :\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 \u03b2]\n\nlemma subtype_domain_sum {s : finset \u03b3} {h : \u03b3 \u2192 \u03b1 \u2192\u2080 \u03b2} :\n  (s.sum h).subtype_domain p = s.sum (\u03bbc, (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 : \u03b3 \u2192\u2080 \u03b4} {h : \u03b3 \u2192 \u03b4 \u2192 \u03b1 \u2192\u2080 \u03b2} :\n  (s.sum h).subtype_domain p = s.sum (\u03bbc d, (h c d).subtype_domain p) :=\nsubtype_domain_sum\n\nend comm_monoid\n\nsection group\nvariables [add_group \u03b2] {v v' : \u03b1' \u2192\u2080 \u03b2}\n\n@[simp] lemma subtype_domain_neg {v : \u03b1 \u2192\u2080 \u03b2} :\n  (- v).subtype_domain p = - v.subtype_domain p :=\next $ by simp\n\n@[simp] lemma subtype_domain_sub {v v' : \u03b1 \u2192\u2080 \u03b2} :\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 : \u03b1 \u2192\u2080 \u2115) : multiset \u03b1 :=\nf.sum (\u03bba n, add_monoid.smul n {a})\n\n@[simp] lemma count_to_multiset [decidable_eq \u03b1] (f : \u03b1 \u2192\u2080 \u2115) (a : \u03b1) :\n  f.to_multiset.count a = f a :=\ncalc f.to_multiset.count a = f.sum (\u03bbx n, (add_monoid.smul n {x} : multiset \u03b1).count a) :\n    (finset.sum_hom _ (multiset.count_zero a) (multiset.count_add a)).symm\n  ... = f.sum (\u03bbx n, n * ({x} : multiset \u03b1).count a) : by simp\n  ... = f.sum (\u03bbx n, n * (x :: 0 : multiset \u03b1).count a) : rfl\n  ... = f a * (a :: 0 : multiset \u03b1).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 \u03b1] (m : multiset \u03b1) : \u03b1 \u2192\u2080 \u2115 :=\non_finset m.to_finset (\u03bba, m.count a) $ by simp [multiset.count_eq_zero]\n\n@[simp] lemma of_multiset_apply [decidable_eq \u03b1] (m : multiset \u03b1) (a : \u03b1) :\n  of_multiset m a = m.count a :=\nrfl\n\ndef equiv_multiset [decidable_eq \u03b1] : (\u03b1 \u2192\u2080 \u2115) \u2243 (multiset \u03b1) :=\n\u27e8 to_multiset, of_multiset, assume f, finsupp.ext $ by simp, assume m, multiset.ext.2 $ by simp \u27e9\n\nlemma mem_support_multiset_sum [decidable_eq \u03b1] [decidable_eq \u03b2] [add_comm_monoid \u03b2]\n  {s : multiset (\u03b1 \u2192\u2080 \u03b2)} (a : \u03b1) :\n  a \u2208 s.sum.support \u2192 \u2203f\u2208s, a \u2208 (f : \u03b1 \u2192\u2080 \u03b2).support :=\nmultiset.induction_on s (by simp)\n  begin\n    assume f s ih ha,\n    by_cases a \u2208 f.support,\n    { exact \u27e8f, multiset.mem_cons_self _ _, h\u27e9 },\n    { simp at h,\n      simp [h] at ha,\n      simp [ha] at ih,\n      rcases ih with \u27e8f', h\u2080, h\u2081\u27e9,\n      exact \u27e8f', multiset.mem_cons_of_mem h\u2080, by simpa using h\u2081\u27e9 }\n  end\n\nlemma mem_support_finset_sum [decidable_eq \u03b1] [decidable_eq \u03b2] [add_comm_monoid \u03b2]\n  {s : finset \u03b3} {h : \u03b3 \u2192 \u03b1 \u2192\u2080 \u03b2} (a : \u03b1) (ha : a \u2208 (s.sum h).support) : \u2203c\u2208s, a \u2208 (h c).support :=\nlet \u27e8f, hf, hfa\u27e9 := mem_support_multiset_sum a ha in\nlet \u27e8c, hc, eq\u27e9 := multiset.mem_map.1 hf in\n\u27e8c, hc, eq.symm \u25b8 hfa\u27e9\n\nlemma mem_support_single [decidable_eq \u03b1] [decidable_eq \u03b2] [has_zero \u03b2] (a a' : \u03b1) (b : \u03b2) :\n  a \u2208 (single a' b).support \u2194 a = a' \u2227 b \u2260 0 :=\nclassical.by_cases\n  (assume : b = 0, by simp [this])\n  (assume : b \u2260 0, by simp [this, -mem_support_iff, support_single_ne_zero])\n\nend multiset\n\nsection curry_uncurry\n\nprotected def curry [decidable_eq \u03b1] [decidable_eq \u03b2] [decidable_eq \u03b3] [add_comm_monoid \u03b3]\n  (f : (\u03b1 \u00d7 \u03b2) \u2192\u2080 \u03b3) : \u03b1 \u2192\u2080 (\u03b2 \u2192\u2080 \u03b3) :=\nf.sum $ \u03bbp c, single p.1 (single p.2 c)\n\nlemma sum_curry_index\n  [decidable_eq \u03b1] [decidable_eq \u03b2] [decidable_eq \u03b3] [add_comm_monoid \u03b3] [add_comm_monoid \u03b4]\n  (f : (\u03b1 \u00d7 \u03b2) \u2192\u2080 \u03b3) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4)\n  (hg\u2080 : \u2200 a b, g a b 0 = 0) (hg\u2081 : \u2200a b c\u2080 c\u2081, g a b (c\u2080 + c\u2081) = g a b c\u2080 + g a b c\u2081) :\n  f.curry.sum (\u03bba f, f.sum (g a)) = f.sum (\u03bbp 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\u2080 b\u2081, sum_add_index (assume a, hg\u2080 _ _) (assume c d\u2080 d\u2081, hg\u2081 _ _ _ _)) },\n  congr, funext p c,\n  transitivity,\n  { exact sum_single_index sum_zero_index },\n  exact sum_single_index (hg\u2080 _ _)\nend\n\nprotected def uncurry [decidable_eq \u03b1] [decidable_eq \u03b2] [decidable_eq \u03b3] [add_comm_monoid \u03b3]\n  (f : \u03b1 \u2192\u2080 (\u03b2 \u2192\u2080 \u03b3)) : (\u03b1 \u00d7 \u03b2) \u2192\u2080 \u03b3 :=\nf.sum $ \u03bba g, g.sum $ \u03bbb c, single (a, b) c\n\ndef finsupp_prod_equiv [add_comm_monoid \u03b3] [decidable_eq \u03b1] [decidable_eq \u03b2] [decidable_eq \u03b3] :\n  ((\u03b1 \u00d7 \u03b2) \u2192\u2080 \u03b3) \u2243 (\u03b1 \u2192\u2080 (\u03b2 \u2192\u2080 \u03b3)) :=\n\u27e8 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] \u27e9\n\nend curry_uncurry\n\nsection\nvariables [add_monoid \u03b1] [semiring \u03b2]\n\n-- TODO: the simplifier unfolds 0 in the instance proof!\nprivate lemma zero_mul (f : \u03b1 \u2192\u2080 \u03b2) : 0 * f = 0 := by simp [mul_def, sum_zero_index]\nprivate lemma mul_zero (f : \u03b1 \u2192\u2080 \u03b2) : f * 0 = 0 := by simp [mul_def, sum_zero_index]\nprivate lemma left_distrib (a b c : \u03b1 \u2192\u2080 \u03b2) : a * (b + c) = a * b + a * c :=\nby simp [mul_def, sum_add_index, mul_add]\nprivate lemma right_distrib (a b c : \u03b1 \u2192\u2080 \u03b2) : (a + b) * c = a * c + b * c :=\nby simp [mul_def, sum_add_index, add_mul]\n\ndef to_semiring : semiring (\u03b1 \u2192\u2080 \u03b2) :=\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 \u03b1] [comm_semiring \u03b2] : comm_semiring (\u03b1 \u2192\u2080 \u03b2) :=\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 \u03b1] [ring \u03b2] : ring (\u03b1 \u2192\u2080 \u03b2) :=\n{ neg := has_neg.neg,\n  add_left_neg := add_left_neg,\n  .. finsupp.to_semiring }\n\ndef to_comm_ring [add_comm_monoid \u03b1] [comm_ring \u03b2] : comm_ring (\u03b1 \u2192\u2080 \u03b2) :=\n{ mul_comm := mul_comm, .. finsupp.to_ring}\n\nlemma single_mul_single [has_add \u03b1] [semiring \u03b2] {a\u2081 a\u2082 : \u03b1} {b\u2081 b\u2082 : \u03b2}:\n  single a\u2081 b\u2081 * single a\u2082 b\u2082 = single (a\u2081 + a\u2082) (b\u2081 * b\u2082) :=\nby simp [mul_def, sum_single_index]\n\nlemma prod_single [decidable_eq \u03b9] [add_comm_monoid \u03b1] [comm_semiring \u03b2]\n  {s : finset \u03b9} {a : \u03b9 \u2192 \u03b1} {b : \u03b9 \u2192 \u03b2} :\n  s.prod (\u03bbi, 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 (\u03b2)\n\ndef to_has_scalar' [ring \u03b3] [module \u03b3 \u03b2] : has_scalar \u03b3 (\u03b1 \u2192\u2080 \u03b2) := \u27e8\u03bba v, v.map_range ((\u2022) a) (smul_zero)\u27e9\nlocal attribute [instance] to_has_scalar'\n\n@[simp] lemma smul_apply' [ring \u03b3] [module \u03b3 \u03b2] {a : \u03b1} {b : \u03b3} {v : \u03b1 \u2192\u2080 \u03b2} :\n  (b \u2022 v) a = b \u2022 (v a) := rfl\n\ndef to_module [ring \u03b3] [module \u03b3 \u03b2] : module \u03b3 (\u03b1 \u2192\u2080 \u03b2) :=\n{ smul     := (\u2022),\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 \u03b2] : has_scalar \u03b2 (\u03b1 \u2192\u2080 \u03b2) := to_has_scalar' \u03b2\nlocal attribute [instance] to_has_scalar\n\n@[simp] lemma smul_apply [ring \u03b2] {a : \u03b1} {b : \u03b2} {v : \u03b1 \u2192\u2080 \u03b2} :\n  (b \u2022 v) a = b \u2022 (v a) := rfl\n\nlemma sum_smul_index [ring \u03b2] [add_comm_monoid \u03b3] {g : \u03b1 \u2192\u2080 \u03b2} {b : \u03b2} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n  (h0 : \u2200i, h i 0 = 0) : (b \u2022 g).sum h = g.sum (\u03bbi a, h i (b * a)) :=\nfinsupp.sum_map_range_index h0\n\nend decidable\n\nsection\nvariables [semiring \u03b2] [semiring \u03b3]\n\nlemma sum_mul (b : \u03b3) (s : \u03b1 \u2192\u2080 \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  (s.sum f) * b = s.sum (\u03bb a c, (f a (s a)) * b) :=\nby simp [finsupp.sum, finset.sum_mul]\n\nlemma mul_sum [semiring \u03b2] [semiring \u03b3] (b : \u03b3) (s : \u03b1 \u2192\u2080 \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  b * (s.sum f) = s.sum (\u03bb 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 \u00a9 2020 Nicol\u00f2 Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicol\u00f2 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 `\u03b1` to `\u03b2`.\n\nWhen possible, instead of parametrizing results over `(f : C(\u03b1, \u03b2))`,\nyou should parametrize over `{F : Type*} [continuous_map_class F \u03b1 \u03b2] (f : F)`.\n\nWhen you extend this structure, make sure to extend `continuous_map_class`. -/\n@[protect_proj]\nstructure continuous_map (\u03b1 \u03b2 : Type*) [topological_space \u03b1] [topological_space \u03b2] :=\n(to_fun             : \u03b1 \u2192 \u03b2)\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n\nnotation `C(` \u03b1 `, ` \u03b2 `)` := continuous_map \u03b1 \u03b2\n\n/-- `continuous_map_class F \u03b1 \u03b2` 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*) (\u03b1 \u03b2 : out_param $ Type*) [topological_space \u03b1]\n  [topological_space \u03b2]\n  extends fun_like F \u03b1 (\u03bb _, \u03b2) :=\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 \u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2] [continuous_map_class F \u03b1 \u03b2]\ninclude \u03b2\n\nlemma map_continuous_at (f : F) (a : \u03b1) : continuous_at f a := (map_continuous f).continuous_at\n\nlemma map_continuous_within_at (f : F) (s : set \u03b1) (a : \u03b1) : continuous_within_at f s a :=\n(map_continuous f).continuous_within_at\n\ninstance : has_coe_t F C(\u03b1, \u03b2) := \u27e8\u03bb f, { to_fun := f, continuous_to_fun := map_continuous f }\u27e9\n\nend continuous_map_class\n\n/-! ### Continuous maps-/\n\nnamespace continuous_map\nvariables {\u03b1 \u03b2 \u03b3 \u03b4 : Type*} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3]\n  [topological_space \u03b4]\n\ninstance : continuous_map_class C(\u03b1, \u03b2) \u03b1 \u03b2 :=\n{ coe := continuous_map.to_fun,\n  coe_injective' := \u03bb 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(\u03b1, \u03b2)) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : C(\u03b1, \u03b2)} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := 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(\u03b1, \u03b2)) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : C(\u03b1, \u03b2) :=\n{ to_fun := f',\n  continuous_to_fun := h.symm \u25b8 f.continuous_to_fun }\n\nvariables {\u03b1 \u03b2} {f g : C(\u03b1, \u03b2)}\n\n/-- Deprecated. Use `map_continuous` instead. -/\nprotected lemma continuous (f : C(\u03b1, \u03b2)) : continuous f := f.continuous_to_fun\n@[continuity] lemma continuous_set_coe (s : set C(\u03b1, \u03b2)) (f : s) : continuous f := f.1.continuous\n\n/-- Deprecated. Use `map_continuous_at` instead. -/\nprotected lemma continuous_at (f : C(\u03b1, \u03b2)) (x : \u03b1) : continuous_at f x :=\nf.continuous.continuous_at\n\n/-- Deprecated. Use `fun_like.congr_fun` instead. -/\nprotected lemma congr_fun {f g : C(\u03b1, \u03b2)} (H : f = g) (x : \u03b1) : f x = g x := H \u25b8 rfl\n/-- Deprecated. Use `fun_like.congr_arg` instead. -/\nprotected lemma congr_arg (f : C(\u03b1, \u03b2)) {x y : \u03b1} (h : x = y) : f x = f y := h \u25b8 rfl\n\ninstance [inhabited \u03b2] : inhabited C(\u03b1, \u03b2) :=\n\u27e8{ to_fun := \u03bb _, default, }\u27e9\n\nlemma coe_injective : @function.injective (C(\u03b1, \u03b2)) (\u03b1 \u2192 \u03b2) coe_fn :=\n\u03bb f g h, by cases f; cases g; congr'\n\n@[simp] lemma coe_mk (f : \u03b1 \u2192 \u03b2) (h : continuous f) :\n  \u21d1(\u27e8f, h\u27e9 : C(\u03b1, \u03b2)) = f := rfl\n\nsection\nvariables (\u03b1 \u03b2)\n\n/--\nThe continuous functions from `\u03b1` to `\u03b2` are the same as the plain functions when `\u03b1` is discrete.\n-/\n@[simps]\ndef equiv_fn_of_discrete [discrete_topology \u03b1] : C(\u03b1, \u03b2) \u2243 (\u03b1 \u2192 \u03b2) :=\n\u27e8(\u03bb f, f), (\u03bb f, \u27e8f, continuous_of_discrete_topology\u27e9),\n  \u03bb f, by { ext, refl, }, \u03bb f, by { ext, refl, }\u27e9\n\nend\n\nvariables (\u03b1)\n\n/-- The identity as a continuous map. -/\nprotected def id : C(\u03b1, \u03b1) := \u27e8id\u27e9\n\n@[simp] lemma coe_id : \u21d1(continuous_map.id \u03b1) = id := rfl\n\n/-- The constant map as a continuous map. -/\ndef const (b : \u03b2) : C(\u03b1, \u03b2) := \u27e8const \u03b1 b\u27e9\n\n@[simp] lemma coe_const (b : \u03b2) : \u21d1(const \u03b1 b) = function.const \u03b1 b := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : continuous_map.id \u03b1 a = a := rfl\n@[simp] lemma const_apply (b : \u03b2) (a : \u03b1) : const \u03b1 b a = b := rfl\n\n/-- The composition of continuous maps, as a continuous map. -/\ndef comp (f : C(\u03b2, \u03b3)) (g : C(\u03b1, \u03b2)) : C(\u03b1, \u03b3) := \u27e8f \u2218 g\u27e9\n\n@[simp] lemma coe_comp (f : C(\u03b2, \u03b3)) (g : C(\u03b1, \u03b2)) : \u21d1(comp f g) = f \u2218 g := rfl\n@[simp] lemma comp_apply (f : C(\u03b2, \u03b3)) (g : C(\u03b1, \u03b2)) (a : \u03b1) : comp f g a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : C(\u03b3, \u03b4)) (g : C(\u03b2, \u03b3)) (h : C(\u03b1, \u03b2)) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma id_comp (f : C(\u03b1, \u03b2)) : (continuous_map.id _).comp f = f := ext $ \u03bb _, rfl\n@[simp] lemma comp_id (f : C(\u03b1, \u03b2)) : f.comp (continuous_map.id _) = f := ext $ \u03bb _, rfl\n@[simp] lemma const_comp (c : \u03b3) (f : C(\u03b1, \u03b2)) : (const \u03b2 c).comp f = const \u03b1 c := ext $ \u03bb _, rfl\n@[simp] lemma comp_const (f : C(\u03b2, \u03b3)) (b : \u03b2) : f.comp (const \u03b1 b) = const \u03b1 (f b) :=\next $ \u03bb _, rfl\n\nlemma cancel_right {f\u2081 f\u2082 : C(\u03b2, \u03b3)} {g : C(\u03b1, \u03b2)} (hg : surjective g) :\n  f\u2081.comp g = f\u2082.comp g \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, ext $ hg.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {f : C(\u03b2, \u03b3)} {g\u2081 g\u2082 : C(\u03b1, \u03b2)} (hf : injective f) :\n  f.comp g\u2081 = f.comp g\u2082 \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, ext $ \u03bb a, hf $ by rw [\u2190comp_apply, h, comp_apply], congr_arg _\u27e9\n\ninstance [nonempty \u03b1] [nontrivial \u03b2] : nontrivial C(\u03b1, \u03b2) :=\n\u27e8let \u27e8b\u2081, b\u2082, hb\u27e9 := exists_pair_ne \u03b2 in\n    \u27e8const _ b\u2081, const _ b\u2082, \u03bb h, hb $ fun_like.congr_fun h $ classical.arbitrary \u03b1\u27e9\u27e9\n\nsection prod\n\nvariables {\u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 : Type*}\n          [topological_space \u03b1\u2081] [topological_space \u03b1\u2082]\n          [topological_space \u03b2\u2081] [topological_space \u03b2\u2082]\n\n/-- Given two continuous maps `f` and `g`, this is the continuous map `x \u21a6 (f x, g x)`. -/\ndef prod_mk (f : C(\u03b1, \u03b2\u2081)) (g : C(\u03b1, \u03b2\u2082)) :\n  C(\u03b1, \u03b2\u2081 \u00d7 \u03b2\u2082) :=\n{ to_fun := (\u03bb 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) \u21a6 (f x, g y)`. -/\ndef prod_map (f : C(\u03b1\u2081, \u03b1\u2082)) (g : C(\u03b2\u2081, \u03b2\u2082)) :\n  C(\u03b1\u2081 \u00d7 \u03b2\u2081, \u03b1\u2082 \u00d7 \u03b2\u2082) :=\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(\u03b1, \u03b2\u2081)) (g : C(\u03b1, \u03b2\u2082)) (a : \u03b1) :\n  (prod_mk f g) a = (f a, g a) := rfl\n\nend prod\n\nsection pi\n\nvariables {I A : Type*} {X : I \u2192 Type*}\n          [topological_space A] [\u2200 i, topological_space (X i)]\n\n/-- Abbreviation for product of continuous maps, which is continuous -/\ndef pi (f : \u03a0 i, C(A, X i)) : C(A, \u03a0 i, X i) :=\n{ to_fun := \u03bb (a : A) (i : I), f i a, }\n\n@[simp] lemma pi_eval (f : \u03a0 i, C(A, X i)) (a : A) :\n  (pi f) a = \u03bb i : I, (f i) a := rfl\n\nend pi\n\nsection restrict\n\nvariables (s : set \u03b1)\n\n/-- The restriction of a continuous function `\u03b1 \u2192 \u03b2` to a subset `s` of `\u03b1`. -/\ndef restrict (f : C(\u03b1, \u03b2)) : C(s, \u03b2) := \u27e8f \u2218 coe\u27e9\n\n@[simp] lemma coe_restrict (f : C(\u03b1, \u03b2)) : \u21d1(f.restrict s) = f \u2218 coe := rfl\n\nend restrict\n\nsection gluing\n\nvariables {\u03b9 : Type*}\n  (S : \u03b9 \u2192 set \u03b1)\n  (\u03c6 : \u03a0 i : \u03b9, C(S i, \u03b2))\n  (h\u03c6 : \u2200 i j (x : \u03b1) (hxi : x \u2208 S i) (hxj : x \u2208 S j), \u03c6 i \u27e8x, hxi\u27e9 = \u03c6 j \u27e8x, hxj\u27e9)\n  (hS : \u2200 x : \u03b1, \u2203 i, S i \u2208 nhds x)\n\ninclude h\u03c6 hS\n\n/-- A family `\u03c6 i` of continuous maps `C(S i, \u03b2)`, where the domains `S i` contain a neighbourhood\nof each point in `\u03b1` and the functions `\u03c6 i` agree pairwise on intersections, can be glued to\nconstruct a continuous map in `C(\u03b1, \u03b2)`. -/\nnoncomputable def lift_cover : C(\u03b1, \u03b2) :=\nbegin\n  have H : (\u22c3 i, S i) = set.univ,\n  { rw set.eq_univ_iff_forall,\n    intros x,\n    rw set.mem_Union,\n    obtain \u27e8i, hi\u27e9 := hS x,\n    exact \u27e8i, mem_of_mem_nhds hi\u27e9 },\n  refine \u27e8set.lift_cover S (\u03bb i, \u03c6 i) h\u03c6 H, continuous_subtype_nhds_cover hS _\u27e9,\n  intros i,\n  convert (\u03c6 i).continuous,\n  ext x,\n  exact set.lift_cover_coe x,\nend\n\nvariables {S \u03c6 h\u03c6 hS}\n\n@[simp] lemma lift_cover_coe {i : \u03b9} (x : S i) : lift_cover S \u03c6 h\u03c6 hS x = \u03c6 i x :=\nset.lift_cover_coe _\n\n@[simp] lemma lift_cover_restrict {i : \u03b9} : (lift_cover S \u03c6 h\u03c6 hS).restrict (S i) = \u03c6 i :=\next $ lift_cover_coe\n\nomit h\u03c6 hS\n\nvariables (A : set (set \u03b1))\n  (F : \u03a0 (s : set \u03b1) (hi : s \u2208 A), C(s, \u03b2))\n  (hF : \u2200 s (hs : s \u2208 A) t (ht : t \u2208 A) (x : \u03b1) (hxi : x \u2208 s) (hxj : x \u2208 t),\n    F s hs \u27e8x, hxi\u27e9 = F t ht \u27e8x, hxj\u27e9)\n  (hA : \u2200 x : \u03b1, \u2203 i \u2208 A, i \u2208 nhds x)\n\ninclude hF hA\n\n/-- A family `F s` of continuous maps `C(s, \u03b2)`, where (1) the domains `s` are taken from a set `A`\nof sets in `\u03b1` which contain a neighbourhood of each point in `\u03b1` and (2) the functions `F s` agree\npairwise on intersections, can be glued to construct a continuous map in `C(\u03b1, \u03b2)`. -/\nnoncomputable def lift_cover' : C(\u03b1, \u03b2) :=\nbegin\n  let S : A \u2192 set \u03b1 := coe,\n  let F : \u03a0 i : A, C(i, \u03b2) := \u03bb i, F i i.prop,\n  refine lift_cover S F (\u03bb i j, hF i i.prop j j.prop) _,\n  intros x,\n  obtain \u27e8s, hs, hsx\u27e9 := hA x,\n  exact \u27e8\u27e8s, hs\u27e9, hsx\u27e9\nend\n\nvariables {A F hF hA}\n\n@[simp] lemma lift_cover_coe' {s : set \u03b1} {hs : s \u2208 A} (x : s) :\n  lift_cover' A F hF hA x = F s hs x :=\nlet x' : (coe : A \u2192 set \u03b1) \u27e8s, hs\u27e9 := x in lift_cover_coe x'\n\n@[simp] lemma lift_cover_restrict' {s : set \u03b1} {hs : s \u2208 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 {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n  (e : \u03b1 \u2243\u209c \u03b2) : C(\u03b1, \u03b2) := \u27e8e\u27e9\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u03b1`: The topological space `t` has a countable, dense subset.\n* `first_countable_topology \u03b1`: A topology in which `\ud835\udcdd x` is countably generated for every `x`.\n* `second_countable_topology \u03b1`: 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 : \u03b1 \u2192 set \u03b1` with the property that\n  `f x \u2208 \ud835\udcdd 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 {\u03b1 : Type u} [t : topological_space \u03b1]\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 \u03b1)) : Prop :=\n(exists_subset_inter : \u2200t\u2081\u2208s, \u2200t\u2082\u2208s, \u2200 x \u2208 t\u2081 \u2229 t\u2082, \u2203 t\u2083\u2208s, x \u2208 t\u2083 \u2227 t\u2083 \u2286 t\u2081 \u2229 t\u2082)\n(sUnion_eq : (\u22c3\u2080 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 \u03b1)} (hs : t = generate_from s) :\n  is_topological_basis ((\u03bb f, \u22c2\u2080 f) '' {f : set (set \u03b1) | finite f \u2227 f \u2286 s \u2227 (\u22c2\u2080 f).nonempty}) :=\nbegin\n  refine \u27e8_, _, _\u27e9,\n  { rintro _ \u27e8t\u2081, \u27e8hft\u2081, ht\u2081b, ht\u2081\u27e9, rfl\u27e9 _ \u27e8t\u2082, \u27e8hft\u2082, ht\u2082b, ht\u2082\u27e9, rfl\u27e9 x h,\n    have : \u22c2\u2080 (t\u2081 \u222a t\u2082) = \u22c2\u2080 t\u2081 \u2229 \u22c2\u2080 t\u2082 := sInter_union t\u2081 t\u2082,\n    exact \u27e8_, \u27e8t\u2081 \u222a t\u2082, \u27e8hft\u2081.union hft\u2082, union_subset ht\u2081b ht\u2082b, this.symm \u25b8 \u27e8x, h\u27e9\u27e9, this\u27e9, h,\n      subset.rfl\u27e9 },\n  { rw [sUnion_image, bUnion_eq_univ_iff],\n    intro x, have : x \u2208 \u22c2\u2080 \u2205, { rw sInter_empty, exact mem_univ x },\n    exact \u27e8\u2205, \u27e8finite_empty, empty_subset _, x, this\u27e9, this\u27e9 },\n  { rw hs,\n    apply le_antisymm; apply le_generate_from,\n    { rintro _ \u27e8t, \u27e8hft, htb, ht\u27e9, rfl\u27e9,\n      exact @is_open_sInter _ (generate_from s) _ hft (\u03bb 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 \u2190 sInter_singleton t at hne \u22a2,\n      exact generate_open.basic _ \u27e8{t}, \u27e8finite_singleton t, singleton_subset_iff.2 ht, hne\u27e9,\n        rfl\u27e9 } }\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 \u03b1)}\n  (h_open : \u2200 u \u2208 s, is_open u)\n  (h_nhds : \u2200(a:\u03b1) (u : set \u03b1), a \u2208 u \u2192 is_open u \u2192 \u2203v \u2208 s, a \u2208 v \u2227 v \u2286 u) :\n  is_topological_basis s :=\nbegin\n  refine \u27e8\u03bb t\u2081 ht\u2081 t\u2082 ht\u2082 x hx, h_nhds _ _ hx (is_open_inter (h_open _ ht\u2081) (h_open _ ht\u2082)), _, _\u27e9,\n  { refine sUnion_eq_univ_iff.2 (\u03bb a, _),\n    rcases h_nhds a univ trivial is_open_univ with \u27e8u, h\u2081, h\u2082, -\u27e9,\n    exact \u27e8u, h\u2081, h\u2082\u27e9 },\n  { refine (le_generate_from h_open).antisymm (\u03bb u hu, _),\n    refine (@is_open_iff_nhds \u03b1 (generate_from s) u).mpr (\u03bb a ha, _),\n    rcases h_nhds a u ha hu with \u27e8v, hvs, hav, hvu\u27e9,\n    rw nhds_generate_from,\n    exact binfi_le_of_le v \u27e8hav, hvs\u27e9 (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 : \u03b1} {s : set \u03b1} {b : set (set \u03b1)}\n  (hb : is_topological_basis b) : s \u2208 \ud835\udcdd a \u2194 \u2203t\u2208b, a \u2208 t \u2227 t \u2286 s :=\nbegin\n  change s \u2208 (\ud835\udcdd a).sets \u2194 \u2203t\u2208b, a \u2208 t \u2227 t \u2286 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 \u27e8hs\u2081, hs\u2082\u27e9 t \u27e8ht\u2081, ht\u2082\u27e9,\n      have a \u2208 s \u2229 t, from \u27e8hs\u2081, ht\u2081\u27e9,\n      let \u27e8u, hu\u2081, hu\u2082, hu\u2083\u27e9 := hb.1 _ hs\u2082 _ ht\u2082 _ this in\n      \u27e8u, \u27e8hu\u2082, hu\u2081\u27e9, le_principal_iff.2 (subset.trans hu\u2083 (inter_subset_left _ _)),\n        le_principal_iff.2 (subset.trans hu\u2083 (inter_subset_right _ _))\u27e9 },\n  { rcases eq_univ_iff_forall.1 hb.sUnion_eq a with \u27e8i, h1, h2\u27e9,\n    exact \u27e8i, h2, h1\u27e9 }\nend\n\nlemma is_topological_basis.nhds_has_basis {b : set (set \u03b1)} (hb : is_topological_basis b) {a : \u03b1} :\n  (\ud835\udcdd a).has_basis (\u03bb t : set \u03b1, t \u2208 b \u2227 a \u2208 t) (\u03bb t, t) :=\n\u27e8\u03bb s, hb.mem_nhds_iff.trans $ by simp only [exists_prop, and_assoc]\u27e9\n\nprotected lemma is_topological_basis.is_open {s : set \u03b1} {b : set (set \u03b1)}\n  (hb : is_topological_basis b) (hs : s \u2208 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 \u03b1)}\n  (hb : is_topological_basis b) {a:\u03b1} {u : set \u03b1} (au : a \u2208 u)\n  (ou : is_open u) : \u2203v \u2208 b, a \u2208 v \u2227 v \u2286 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 \u03b1)}\n  (hB : is_topological_basis B) {u : set \u03b1} (ou : is_open u) :\n  u = \u22c3\u2080 {s \u2208 B | s \u2286 u} :=\next $ \u03bb a,\n\u27e8\u03bb ha, let \u27e8b, hb, ab, bu\u27e9 := hB.exists_subset_of_mem_open ha ou in \u27e8b, \u27e8hb, bu\u27e9, ab\u27e9,\n  \u03bb \u27e8b, \u27e8hb, bu\u27e9, ab\u27e9, bu ab\u27e9\n\nlemma is_topological_basis.open_eq_sUnion {B : set (set \u03b1)}\n  (hB : is_topological_basis B) {u : set \u03b1} (ou : is_open u) :\n  \u2203 S \u2286 B, u = \u22c3\u2080 S :=\n\u27e8{s \u2208 B | s \u2286 u}, \u03bb s h, h.1, hB.open_eq_sUnion' ou\u27e9\n\nlemma is_topological_basis.open_eq_Union {B : set (set \u03b1)}\n  (hB : is_topological_basis B) {u : set \u03b1} (ou : is_open u) :\n  \u2203 (\u03b2 : Type u) (f : \u03b2 \u2192 set \u03b1), u = (\u22c3 i, f i) \u2227 \u2200 i, f i \u2208 B :=\n\u27e8\u21a5{s \u2208 B | s \u2286 u}, coe, by { rw \u2190 sUnion_eq_Union, apply hB.open_eq_sUnion' ou }, \u03bb s, and.left s.2\u27e9\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 \u03b1)} (hb : is_topological_basis b)\n  {s : set \u03b1} {a : \u03b1} :\n  a \u2208 closure s \u2194 \u2200 o \u2208 b, a \u2208 o \u2192 (o \u2229 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 \u03b1)} (hb : is_topological_basis b) {s : set \u03b1} :\n  dense s \u2194 \u2200 o \u2208 b, set.nonempty o \u2192 (o \u2229 s).nonempty :=\nbegin\n  simp only [dense, hb.mem_closure_iff],\n  exact \u27e8\u03bb h o hb \u27e8a, ha\u27e9, h a o hb ha, \u03bb h a o hb ha, h o hb \u27e8a, ha\u27e9\u27e9\nend\n\nprotected lemma is_topological_basis.prod {\u03b2} [topological_space \u03b2] {B\u2081 : set (set \u03b1)}\n  {B\u2082 : set (set \u03b2)} (h\u2081 : is_topological_basis B\u2081) (h\u2082 : is_topological_basis B\u2082) :\n  is_topological_basis (image2 set.prod B\u2081 B\u2082) :=\nbegin\n  refine is_topological_basis_of_open_of_nhds _ _,\n  { rintro _ \u27e8u\u2081, u\u2082, hu\u2081, hu\u2082, rfl\u27e9,\n    exact (h\u2081.is_open hu\u2081).prod (h\u2082.is_open hu\u2082) },\n  { rintro \u27e8a, b\u27e9 u hu uo,\n    rcases (h\u2081.nhds_has_basis.prod_nhds h\u2082.nhds_has_basis).mem_iff.1 (mem_nhds_sets uo hu)\n      with \u27e8\u27e8s, t\u27e9, \u27e8\u27e8hs, ha\u27e9, ht, hb\u27e9, hu\u27e9,\n    exact \u27e8s.prod t, mem_image2_of_mem hs ht, \u27e8ha, hb\u27e9, hu\u27e9 }\nend\n\nlemma is_topological_basis_of_cover {\u03b9} {U  : \u03b9 \u2192 set \u03b1} (Uo : \u2200 i, is_open (U i))\n  (Uc : (\u22c3 i, U i) = univ) {b : \u03a0 i, set (set (U i))} (hb : \u2200 i, is_topological_basis (b i)) :\n  is_topological_basis (\u22c3 i : \u03b9, image (coe : U i \u2192 \u03b1) '' (b i)) :=\nbegin\n  refine is_topological_basis_of_open_of_nhds (\u03bb u hu, _) _,\n  { simp only [mem_Union, mem_image] at hu,\n    rcases hu with \u27e8i, s, sb, rfl\u27e9,\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 \u27e8i, hi\u27e9,\n    lift a to \u21a5(U i) using hi,\n    rcases (hb i).exists_subset_of_mem_open (by exact ha) (uo.preimage continuous_subtype_coe)\n      with \u27e8v, hvb, hav, hvu\u27e9,\n    exact \u27e8coe '' v, mem_Union.2 \u27e8i, mem_image_of_mem _ hvb\u27e9, mem_image_of_mem _ hav,\n      image_subset_iff.2 hvu\u27e9 }\nend\n\nvariables (\u03b1)\n\n/-- A separable space is one with a countable dense subset, available through\n`topological_space.exists_countable_dense`. If `\u03b1` is also known to be nonempty, then\n`topological_space.dense_seq` provides a sequence `\u2115 \u2192 \u03b1` with dense range, see\n`topological_space.dense_range_dense_seq`.\n\nIf `\u03b1` 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 \u03b1`. 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 : \u2203s:set \u03b1, countable s \u2227 dense s)\n\nlemma exists_countable_dense [separable_space \u03b1] :\n  \u2203 s : set \u03b1, countable s \u2227 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 `\u03b1` might be empty, then `exists_countable_dense` is the main way to use separability of `\u03b1`. -/\nlemma exists_dense_seq [separable_space \u03b1] [nonempty \u03b1] : \u2203 u : \u2115 \u2192 \u03b1, dense_range u :=\nbegin\n  obtain \u27e8s : set \u03b1, hs, s_dense\u27e9 := exists_countable_dense \u03b1,\n  cases countable_iff_exists_surjective.mp hs with u hu,\n  exact \u27e8u, s_dense.mono hu\u27e9,\nend\n\n/-- A dense sequence in a non-empty separable topological space.\n\nIf `\u03b1` might be empty, then `exists_countable_dense` is the main way to use separability of `\u03b1`. -/\ndef dense_seq [separable_space \u03b1] [nonempty \u03b1] : \u2115 \u2192 \u03b1 := classical.some (exists_dense_seq \u03b1)\n\n/-- The sequence `dense_seq \u03b1` has dense range. -/\n@[simp] lemma dense_range_dense_seq [separable_space \u03b1] [nonempty \u03b1] :\n  dense_range (dense_seq \u03b1) := classical.some_spec (exists_dense_seq \u03b1)\n\nend topological_space\n\nopen topological_space\n\n/-- If `\u03b1` is a separable space and `f : \u03b1 \u2192 \u03b2` is a continuous map with dense range, then `\u03b2` is\na separable space as well. E.g., the completion of a separable uniform space is separable. -/\nprotected lemma dense_range.separable_space {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [separable_space \u03b1]\n  [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} (h : dense_range f) (h' : continuous f) :\n  separable_space \u03b2 :=\nlet \u27e8s, s_cnt, s_dense\u27e9 := exists_countable_dense \u03b1 in\n\u27e8\u27e8f '' s, countable.image s_cnt f, h.dense_image h' s_dense\u27e9\u27e9\n\nnamespace topological_space\nuniverse u\nvariables (\u03b1 : Type u) [t : topological_space \u03b1]\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 : \u2200a:\u03b1, (\ud835\udcdd a).is_countably_generated)\n\nnamespace first_countable_topology\nvariable {\u03b1}\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 \u03b1] {u : \u2115 \u2192 \u03b1} {x : \u03b1}\n  (hx : map_cluster_pt x at_top u) :\n  \u2203 (\u03c8 : \u2115 \u2192 \u2115), (strict_mono \u03c8) \u2227 (tendsto (u \u2218 \u03c8) at_top (\ud835\udcdd x)) :=\n(nhds_generated_countable x).subseq_tendsto hx\n\nend first_countable_topology\n\nvariables {\u03b1}\n\nlemma is_countably_generated_nhds [first_countable_topology \u03b1] (x : \u03b1) :\n  is_countably_generated (\ud835\udcdd x) :=\nfirst_countable_topology.nhds_generated_countable x\n\nlemma is_countably_generated_nhds_within [first_countable_topology \u03b1] (x : \u03b1) (s : set \u03b1) :\n  is_countably_generated (\ud835\udcdd[s] x) :=\n(is_countably_generated_nhds x).inf_principal s\n\nvariable (\u03b1)\n\n/-- A second-countable space is one with a countable basis. -/\nclass second_countable_topology : Prop :=\n(is_open_generated_countable [] :\n  \u2203 b : set (set \u03b1), countable b \u2227 t = topological_space.generate_from b)\n\nvariable {\u03b1}\n\nprotected lemma is_topological_basis.second_countable_topology\n  {b : set (set \u03b1)} (hb : is_topological_basis b) (hc : countable b) :\n  second_countable_topology \u03b1 :=\n\u27e8\u27e8b, hc, hb.eq_generate_from\u27e9\u27e9\n\nvariable (\u03b1)\n\nlemma exists_countable_basis [second_countable_topology \u03b1] :\n  \u2203b:set (set \u03b1), countable b \u2227 \u2205 \u2209 b \u2227 is_topological_basis b :=\nlet \u27e8b, hb\u2081, hb\u2082\u27e9 := second_countable_topology.is_open_generated_countable \u03b1 in\nlet b' := (\u03bbs, \u22c2\u2080 s) '' {s:set (set \u03b1) | finite s \u2227 s \u2286 b \u2227 (\u22c2\u2080 s).nonempty} in\n\u27e8b',\n  ((countable_set_of_finite_subset hb\u2081).mono\n    (by { simp only [\u2190 and_assoc], apply inter_subset_left })).image _,\n  assume \u27e8s, \u27e8_, _, hn\u27e9, hp\u27e9, absurd hn (not_nonempty_iff_eq_empty.2 hp),\n  is_topological_basis_of_subbasis hb\u2082\u27e9\n\n/-- A countable topological basis of `\u03b1`. -/\ndef countable_basis [second_countable_topology \u03b1] : set (set \u03b1) :=\n(exists_countable_basis \u03b1).some\n\nlemma countable_countable_basis [second_countable_topology \u03b1] : countable (countable_basis \u03b1) :=\n(exists_countable_basis \u03b1).some_spec.1\n\ninstance encodable_countable_basis [second_countable_topology \u03b1] :\n  encodable (countable_basis \u03b1) :=\n(countable_countable_basis \u03b1).to_encodable\n\nlemma empty_nmem_countable_basis [second_countable_topology \u03b1] : \u2205 \u2209 countable_basis \u03b1 :=\n(exists_countable_basis \u03b1).some_spec.2.1\n\nlemma is_basis_countable_basis [second_countable_topology \u03b1] :\n  is_topological_basis (countable_basis \u03b1) :=\n(exists_countable_basis \u03b1).some_spec.2.2\n\nlemma eq_generate_from_countable_basis [second_countable_topology \u03b1] :\n  \u2039topological_space \u03b1\u203a = generate_from (countable_basis \u03b1) :=\n(is_basis_countable_basis \u03b1).eq_generate_from\n\nvariable {\u03b1}\n\nlemma is_open_of_mem_countable_basis [second_countable_topology \u03b1] {s : set \u03b1}\n  (hs : s \u2208 countable_basis \u03b1) : is_open s :=\n(is_basis_countable_basis \u03b1).is_open hs\n\nlemma nonempty_of_mem_countable_basis [second_countable_topology \u03b1] {s : set \u03b1}\n  (hs : s \u2208 countable_basis \u03b1) : s.nonempty :=\nne_empty_iff_nonempty.1 $ ne_of_mem_of_not_mem hs $ empty_nmem_countable_basis \u03b1\n\nvariable (\u03b1)\n\n@[priority 100] -- see Note [lower instance priority]\ninstance second_countable_topology.to_first_countable_topology\n  [second_countable_topology \u03b1] : first_countable_topology \u03b1 :=\n\u27e8\u03bb x, has_countable_basis.is_countably_generated $\n  \u27e8(is_basis_countable_basis \u03b1).nhds_has_basis, (countable_countable_basis \u03b1).mono $\n    inter_subset_left _ _\u27e9\u27e9\n\n/-- If `\u03b2` is a second-countable space, then its induced topology\nvia `f` on `\u03b1` is also second-countable. -/\nlemma second_countable_topology_induced (\u03b2)\n  [t : topological_space \u03b2] [second_countable_topology \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  @second_countable_topology \u03b1 (t.induced f) :=\nbegin\n  rcases second_countable_topology.is_open_generated_countable \u03b2 with \u27e8b, hb, eq\u27e9,\n  refine { is_open_generated_countable := \u27e8preimage f '' b, hb.image _, _\u27e9 },\n  rw [eq, induced_generate_from_eq]\nend\n\ninstance subtype.second_countable_topology (s : set \u03b1) [second_countable_topology \u03b1] :\n  second_countable_topology s :=\nsecond_countable_topology_induced s \u03b1 coe\n\n/- TODO: more fine grained instances for first_countable_topology, separable_space, t2_space, ... -/\ninstance {\u03b2 : Type*} [topological_space \u03b2]\n  [second_countable_topology \u03b1] [second_countable_topology \u03b2] : second_countable_topology (\u03b1 \u00d7 \u03b2) :=\n((is_basis_countable_basis \u03b1).prod (is_basis_countable_basis \u03b2)).second_countable_topology $\n  (countable_countable_basis \u03b1).image2 (countable_countable_basis \u03b2) _\n\ninstance second_countable_topology_fintype {\u03b9 : Type*} {\u03c0 : \u03b9 \u2192 Type*}\n  [fintype \u03b9] [t : \u2200a, topological_space (\u03c0 a)] [sc : \u2200a, second_countable_topology (\u03c0 a)] :\n  second_countable_topology (\u2200a, \u03c0 a) :=\nbegin\n  have : t = (\u03bba, generate_from (countable_basis (\u03c0 a))),\n    from funext (assume a, (is_basis_countable_basis (\u03c0 a)).eq_generate_from),\n  rw this,\n  constructor,\n  refine \u27e8pi univ '' pi univ (\u03bb a, countable_basis (\u03c0 a)), countable.image _ _, _\u27e9,\n  { suffices : countable {f : \u03a0a, set (\u03c0 a) | \u2200a, f a \u2208 countable_basis (\u03c0 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 (\u03c0 a)).sUnion_eq\nend\n\n@[priority 100] -- see Note [lower instance priority]\ninstance second_countable_topology.to_separable_space\n  [second_countable_topology \u03b1] : separable_space \u03b1 :=\nbegin\n  choose p hp using \u03bb s : countable_basis \u03b1, nonempty_of_mem_countable_basis s.2,\n  exact \u27e8\u27e8range p, countable_range _,\n    (is_basis_countable_basis \u03b1).dense_iff.2 $ \u03bb o ho _, \u27e8p \u27e8o, ho\u27e9, hp _, mem_range_self _\u27e9\u27e9\u27e9\nend\n\nvariables {\u03b1}\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 {\u03b9} [encodable \u03b9] {U : \u03b9 \u2192 set \u03b1}\n  [\u2200 i, second_countable_topology (U i)] (Uo : \u2200 i, is_open (U i))  (hc : (\u22c3 i, U i) = univ) :\n  second_countable_topology \u03b1 :=\nbegin\n  have : is_topological_basis (\u22c3 i, image (coe : U i \u2192 \u03b1) '' (countable_basis (U i))),\n    from is_topological_basis_of_cover Uo hc (\u03bb i, is_basis_countable_basis (U i)),\n  exact this.second_countable_topology\n    (countable_Union $ \u03bb 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 \u03b1]\n  {\u03b9} (s : \u03b9 \u2192 set \u03b1) (H : \u2200 i, is_open (s i)) :\n  \u2203 T : set \u03b9, countable T \u2227 (\u22c3 i \u2208 T, s i) = \u22c3 i, s i :=\nbegin\n  let B := {b \u2208 countable_basis \u03b1 | \u2203 i, b \u2286 s i},\n  choose f hf using \u03bb b : B, b.2.2,\n  haveI : encodable B := ((countable_countable_basis \u03b1).mono (sep_subset _ _)).to_encodable,\n  refine \u27e8_, countable_range f,\n    subset.antisymm (bUnion_subset_Union _ _) (sUnion_subset _)\u27e9,\n  rintro _ \u27e8i, rfl\u27e9 x xs,\n  rcases (is_basis_countable_basis \u03b1).exists_subset_of_mem_open xs (H _) with \u27e8b, hb, xb, bs\u27e9,\n  exact \u27e8_, \u27e8_, rfl\u27e9, _, \u27e8\u27e8\u27e8_, hb, _, bs\u27e9, rfl\u27e9, rfl\u27e9, hf _ (by exact xb)\u27e9\nend\n\nlemma is_open_sUnion_countable [second_countable_topology \u03b1]\n  (S : set (set \u03b1)) (H : \u2200 s \u2208 S, is_open s) :\n  \u2203 T : set (set \u03b1), countable T \u2227 T \u2286 S \u2227 \u22c3\u2080 T = \u22c3\u2080 S :=\nlet \u27e8T, cT, hT\u27e9 := is_open_Union_countable (\u03bb s:S, s.1) (\u03bb s, H s.1 s.2) in\n\u27e8subtype.val '' T, cT.image _,\n  image_subset_iff.2 $ \u03bb \u27e8x, xs\u27e9 xt, xs,\n  by rwa [sUnion_image, sUnion_eq_Union]\u27e9\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 \u2208 s`, cover the whole space. -/\nlemma countable_cover_nhds [second_countable_topology \u03b1] {f : \u03b1 \u2192 set \u03b1}\n  (hf : \u2200 x, f x \u2208 \ud835\udcdd x) : \u2203 s : set \u03b1, countable s \u2227 (\u22c3 x \u2208 s, f x) = univ :=\nbegin\n  rcases is_open_Union_countable (\u03bb x, interior (f x)) (\u03bb x, is_open_interior) with \u27e8s, hsc, hsU\u27e9,\n  suffices : (\u22c3 x \u2208 s, interior (f x)) = univ,\n    from \u27e8s, hsc, flip eq_univ_of_subset this (bUnion_mono $ \u03bb _ _, interior_subset)\u27e9,\n  simp only [hsU, eq_univ_iff_forall, mem_Union],\n  exact \u03bb x, \u27e8x, mem_interior_iff_mem_nhds.2 (hf x)\u27e9\nend\n\nend topological_space\n\nopen topological_space\n\nvariables {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2}\n\nprotected lemma inducing.second_countable_topology [second_countable_topology \u03b2]\n  (hf : inducing f) : second_countable_topology \u03b1 :=\nby { rw hf.1, exact second_countable_topology_induced \u03b1 \u03b2 f }\n\nprotected lemma embedding.second_countable_topology [second_countable_topology \u03b2]\n  (hf : embedding f) : second_countable_topology \u03b1 :=\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 \u2964 discrete punit` sending everything to `punit.star`,\nshow that any two functors to `discrete punit` are naturally isomorphic,\nand construct the equivalence `(discrete punit \u2964 C) \u224c 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 \u2964 Discrete PUnit :=\n  (Functor.const _).obj \u27e8\u27e8\u27e9\u27e9\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 \u2964 Discrete PUnit) : F \u2245 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'\u2093'. -/\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 \u2964 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} \u2964 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\u2093'. -/\n/-- Functors from `discrete punit` are equivalent to the category itself. -/\n@[simps]\ndef equiv : Discrete PUnit \u2964 C \u224c C\n    where\n  Functor :=\n    { obj := fun F => F.obj \u27e8\u27e8\u27e9\u27e9\n      map := fun F G \u03b8 => \u03b8.app \u27e8\u27e8\u27e9\u27e9 }\n  inverse := Functor.const _\n  unitIso := by\n    apply nat_iso.of_components _ _\n    intro X\n    apply discrete.nat_iso\n    rintro \u27e8\u27e8\u27e9\u27e9\n    apply iso.refl _\n    intros\n    ext \u27e8\u27e8\u27e9\u27e9\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\u2093'. -/\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 \u224c Discrete PUnit) \u2194 Nonempty C \u2227 \u2200 x y : C, Nonempty <| Unique (x \u27f6 y) :=\n  by\n  constructor\n  \u00b7 rintro \u27e8h\u27e9\n    refine' \u27e8\u27e8h.inverse.obj \u27e8\u27e8\u27e9\u27e9\u27e9, fun x y => Nonempty.intro _\u27e9\n    apply uniqueOfSubsingleton _\n    swap\n    \u00b7 have hx : x \u27f6 h.inverse.obj \u27e8\u27e8\u27e9\u27e9 := by convert h.unit.app x\n      have hy : h.inverse.obj \u27e8\u27e8\u27e9\u27e9 \u27f6 y := by convert h.unit_inv.app y\n      exact hx \u226b hy\n    have : \u2200 z, z = h.unit.app x \u226b (h.functor \u22d9 h.inverse).map z \u226b h.unit_inv.app y :=\n      by\n      intro z\n      simpa using congr_arg (\u00b7 \u226b 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  \u00b7 rintro \u27e8\u27e8p\u27e9, h\u27e9\n    haveI := fun x y => (h x y).some\n    refine'\n      Nonempty.intro\n        (CategoryTheory.Equivalence.mk ((Functor.Const _).obj \u27e8\u27e8\u27e9\u27e9) ((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 \u27f6 B` and `g : B \u27f6 C` satisfy `w : f \u226b g = 0`,\nwe have `image_le_kernel f g w : image_subobject f \u2264 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 {\u03b9 : 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 \u27f6 B) [HasImage f] (g : B \u27f6 C) [HasKernel g]\n\ntheorem image_le_kernel (w : f \u226b g = 0) : imageSubobject f \u2264 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 \u27f6 kernel_subobject g` when `f \u226b g = 0`.\n-/\ndef imageToKernel (w : f \u226b g = 0) : (imageSubobject f : V) \u27f6 (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 \u226b 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 \u226b g = 0) :\n    imageToKernel f g w \u226b (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 \u226b g = 0) :\n    factorThruImageSubobject f \u226b 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 \u27f6 B) (g : B \u27f6 C)\n\n@[simp]\ntheorem imageToKernel_zero_left [HasKernels V] [HasZeroObject V] {w} :\n    imageToKernel (0 : A \u27f6 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 \u27f6 C) w =\n      (imageSubobject f).arrow \u226b inv (kernelSubobject (0 : B \u27f6 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 \u27f6 D) (w : f \u226b g = 0) :\n    imageToKernel f (g \u226b h) (by simp [reassoc_of w]) =\n      imageToKernel f g w \u226b 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 \u27f6 A) (w : f \u226b g = 0) :\n    imageToKernel (h \u226b f) g (by simp [w]) =\n      Subobject.ofLe _ _ (imageSubobject_comp_le h f) \u226b 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 \u27f6 D) [Mono h] (w) :\n    imageToKernel f (g \u226b h) w =\n      imageToKernel f g ((cancel_mono h).mp (by simpa using w : (f \u226b g) \u226b h = 0 \u226b h)) \u226b\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 \u27f6 A) [Epi h] (w) :\n    imageToKernel (h \u226b f) g w =\n      Subobject.ofLe _ _ (imageSubobject_comp_le h f) \u226b\n        imageToKernel f g ((cancel_epi h).mp (by simpa using w : h \u226b f \u226b g = h \u226b 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 \u2245 Z} (w) :\n    imageToKernel (f \u226b i.Hom) (i.inv \u226b g) w =\n      (imageSubobjectCompIso _ _).Hom \u226b\n        imageToKernel f g (by simpa using w) \u226b (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 \u27f6 B) g (by simp)) :=\n  epi_of_target_iso_zero _ (kernelSubobjectIso g \u226a\u226b 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 \u27f6 C) (by simp)) :=\n  by\n  simp only [imageToKernel_zero_right]\n  haveI := epi_image_of_epi f\n  rw [\u2190 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 \u27f6 B) [HasImage f] (g : B \u27f6 C) [HasKernel g]\n\n/-- The homology of a pair of morphisms `f : A \u27f6 B` and `g : B \u27f6 C` satisfying `f \u226b g = 0`\nis the cokernel of the `image_to_kernel` morphism for `f` and `g`.\n-/\ndef homology {A B C : V} (f : A \u27f6 B) [HasImage f] (g : B \u27f6 C) [HasKernel g] (w : f \u226b 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 \u226b g = 0) [HasCokernel (imageToKernel f g w)]\n\n/-- The morphism from cycles to homology. -/\ndef homology.\u03c0 : (kernelSubobject g : V) \u27f6 homology f g w :=\n  cokernel.\u03c0 _\n#align homology.\u03c0 homology.\u03c0\n\n@[simp]\ntheorem homology.condition : imageToKernel f g w \u226b homology.\u03c0 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) \u27f6 D) (p : imageToKernel f g w \u226b k = 0) :\n    homology f g w \u27f6 D :=\n  cokernel.desc _ k p\n#align homology.desc homology.desc\n\n@[simp, reassoc.1, elementwise]\ntheorem homology.\u03c0_desc {D : V} (k : (kernelSubobject g : V) \u27f6 D)\n    (p : imageToKernel f g w \u226b k = 0) : homology.\u03c0 f g w \u226b homology.desc f g w k p = k := by\n  simp [homology.\u03c0, homology.desc]\n#align homology.\u03c0_desc homology.\u03c0_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 \u27f6 D}\n    (p : homology.\u03c0 f g w \u226b k = homology.\u03c0 f g w \u226b 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 \u27f6 Ker 0` is isomorphic to the cokernel of `f.` -/\ndef homologyOfZeroRight [HasCokernel (imageToKernel f (0 : B \u27f6 C) comp_zero)] [HasCokernel f]\n    [HasCokernel (image.\u03b9 f)] [Epi (factorThruImage f)] :\n    homology f (0 : B \u27f6 C) comp_zero \u2245 cokernel f :=\n  (cokernel.mapIso _ _ (imageSubobjectIso _) ((kernelSubobjectIso 0).trans kernelZeroIsoSource)\n        (by simp)).trans\n    (cokernelImage\u03b9 _)\n#align homology_of_zero_right homologyOfZeroRight\n\n/-- The kernel of the map `Im 0 \u27f6 Ker f` is isomorphic to the kernel of `f.` -/\ndef homologyOfZeroLeft [HasZeroObject V] [HasKernels V] [HasImage (0 : A \u27f6 B)]\n    [HasCokernel (imageToKernel (0 : A \u27f6 B) g zero_comp)] :\n    homology (0 : A \u27f6 B) g zero_comp \u2245 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 \u27f6 B)]\n    [HasCokernel (imageToKernel (0 : A \u27f6 B) (0 : B \u27f6 C) (by simp))] :\n    homology (0 : A \u27f6 B) (0 : B \u27f6 C) (by simp) \u2245 B\n    where\n  Hom := homology.desc (0 : A \u27f6 B) (0 : B \u27f6 C) (by simp) (kernelSubobject 0).arrow (by simp)\n  inv := inv (kernelSubobject 0).arrow \u226b homology.\u03c0 _ _ _\n#align homology_zero_zero homologyZeroZero\n\nend\n\nsection\n\nvariable {f g} (w : f \u226b g = 0) {A' B' C' : V} {f' : A' \u27f6 B'} [HasImage f'] {g' : B' \u27f6 C'}\n  [HasKernel g'] (w' : f' \u226b g' = 0) (\u03b1 : Arrow.mk f \u27f6 Arrow.mk f') [HasImageMap \u03b1]\n  (\u03b2 : Arrow.mk g \u27f6 Arrow.mk g') {A\u2081 B\u2081 C\u2081 : V} {f\u2081 : A\u2081 \u27f6 B\u2081} [HasImage f\u2081] {g\u2081 : B\u2081 \u27f6 C\u2081}\n  [HasKernel g\u2081] (w\u2081 : f\u2081 \u226b g\u2081 = 0) {A\u2082 B\u2082 C\u2082 : V} {f\u2082 : A\u2082 \u27f6 B\u2082} [HasImage f\u2082] {g\u2082 : B\u2082 \u27f6 C\u2082}\n  [HasKernel g\u2082] (w\u2082 : f\u2082 \u226b g\u2082 = 0) {A\u2083 B\u2083 C\u2083 : V} {f\u2083 : A\u2083 \u27f6 B\u2083} [HasImage f\u2083] {g\u2083 : B\u2083 \u27f6 C\u2083}\n  [HasKernel g\u2083] (w\u2083 : f\u2083 \u226b g\u2083 = 0) (\u03b1\u2081 : Arrow.mk f\u2081 \u27f6 Arrow.mk f\u2082) [HasImageMap \u03b1\u2081]\n  (\u03b2\u2081 : Arrow.mk g\u2081 \u27f6 Arrow.mk g\u2082) (\u03b1\u2082 : Arrow.mk f\u2082 \u27f6 Arrow.mk f\u2083) [HasImageMap \u03b1\u2082]\n  (\u03b2\u2082 : Arrow.mk g\u2082 \u27f6 Arrow.mk g\u2083)\n\n/-- Given compatible commutative squares between\na pair `f g` and a pair `f' g'` satisfying `f \u226b g = 0` and `f' \u226b 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 : \u03b1.right = \u03b2.left) :\n    imageToKernel f g w \u226b kernelSubobjectMap \u03b2 = imageSubobjectMap \u03b1 \u226b 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\u2081 g\u2081 w\u2081)]\n\nvariable [HasCokernel (imageToKernel f\u2082 g\u2082 w\u2082)]\n\nvariable [HasCokernel (imageToKernel f\u2083 g\u2083 w\u2083)]\n\n/-- Given compatible commutative squares between\na pair `f g` and a pair `f' g'` satisfying `f \u226b g = 0` and `f' \u226b g' = 0`,\nwe get a morphism on homology.\n-/\ndef homology.map (p : \u03b1.right = \u03b2.left) : homology f g w \u27f6 homology f' g' w' :=\n  cokernel.desc _ (kernelSubobjectMap \u03b2 \u226b cokernel.\u03c0 _)\n    (by\n      rw [imageSubobjectMap_comp_imageToKernel_assoc w w' \u03b1 \u03b2 p]\n      simp only [cokernel.condition, comp_zero])\n#align homology.map homology.map\n\n@[simp, reassoc.1, elementwise]\ntheorem homology.\u03c0_map (p : \u03b1.right = \u03b2.left) :\n    homology.\u03c0 f g w \u226b homology.map w w' \u03b1 \u03b2 p = kernelSubobjectMap \u03b2 \u226b homology.\u03c0 f' g' w' := by\n  simp only [homology.\u03c0, homology.map, cokernel.\u03c0_desc]\n#align homology.\u03c0_map homology.\u03c0_map\n\n@[simp, reassoc.1, elementwise]\ntheorem homology.map_desc (p : \u03b1.right = \u03b2.left) {D : V} (k : (kernelSubobject g' : V) \u27f6 D)\n    (z : imageToKernel f' g' w' \u226b k = 0) :\n    homology.map w w' \u03b1 \u03b2 p \u226b homology.desc f' g' w' k z =\n      homology.desc f g w (kernelSubobjectMap \u03b2 \u226b k)\n        (by simp only [imageSubobjectMap_comp_imageToKernel_assoc w w' \u03b1 \u03b2 p, z, comp_zero]) :=\n  by ext <;> simp only [homology.\u03c0_desc, homology.\u03c0_map_assoc]\n#align homology.map_desc homology.map_desc\n\n@[simp]\ntheorem homology.map_id : homology.map w w (\ud835\udfd9 _) (\ud835\udfd9 _) rfl = \ud835\udfd9 _ := by\n  ext <;> simp only [homology.\u03c0_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\u2081 B\u2081 C\u2081 A\u2082 B\u2082 C\u2082 A\u2083 B\u2083 C\u2083 : V}\n    {f\u2081 : A\u2081 \u27f6 B\u2081} {g\u2081 : B\u2081 \u27f6 C\u2081} {f\u2082 : A\u2082 \u27f6 B\u2082} {g\u2082 : B\u2082 \u27f6 C\u2082} {f\u2083 : A\u2083 \u27f6 B\u2083} {g\u2083 : B\u2083 \u27f6 C\u2083}\n    {\u03b1\u2081 : Arrow.mk f\u2081 \u27f6 Arrow.mk f\u2082} {\u03b2\u2081 : Arrow.mk g\u2081 \u27f6 Arrow.mk g\u2082}\n    {\u03b1\u2082 : Arrow.mk f\u2082 \u27f6 Arrow.mk f\u2083} {\u03b2\u2082 : Arrow.mk g\u2082 \u27f6 Arrow.mk g\u2083} (p\u2081 : \u03b1\u2081.right = \u03b2\u2081.left)\n    (p\u2082 : \u03b1\u2082.right = \u03b2\u2082.left) : (\u03b1\u2081 \u226b \u03b1\u2082).right = (\u03b2\u2081 \u226b \u03b2\u2082).left := by\n  simp only [comma.comp_left, comma.comp_right, p\u2081, p\u2082]\n#align homology.comp_right_eq_comp_left homology.comp_right_eq_comp_left\n\n@[reassoc.1]\ntheorem homology.map_comp (p\u2081 : \u03b1\u2081.right = \u03b2\u2081.left) (p\u2082 : \u03b1\u2082.right = \u03b2\u2082.left) :\n    homology.map w\u2081 w\u2082 \u03b1\u2081 \u03b2\u2081 p\u2081 \u226b homology.map w\u2082 w\u2083 \u03b1\u2082 \u03b2\u2082 p\u2082 =\n      homology.map w\u2081 w\u2083 (\u03b1\u2081 \u226b \u03b1\u2082) (\u03b2\u2081 \u226b \u03b2\u2082) (homology.comp_right_eq_comp_left p\u2081 p\u2082) :=\n  by\n  ext <;>\n    simp only [kernel_subobject_map_comp, homology.\u03c0_map_assoc, homology.\u03c0_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 (\u03b1 : Arrow.mk f\u2081 \u2245 Arrow.mk f\u2082) (\u03b2 : Arrow.mk g\u2081 \u2245 Arrow.mk g\u2082)\n    (p : \u03b1.Hom.right = \u03b2.Hom.left) : homology f\u2081 g\u2081 w\u2081 \u2245 homology f\u2082 g\u2082 w\u2082\n    where\n  Hom := homology.map w\u2081 w\u2082 \u03b1.Hom \u03b2.Hom p\n  inv :=\n    homology.map w\u2082 w\u2081 \u03b1.inv \u03b2.inv\n      (by\n        rw [\u2190 cancel_mono \u03b1.hom.right, \u2190 comma.comp_right, \u03b1.inv_hom_id, comma.id_right, p, \u2190\n          comma.comp_left, \u03b2.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 \u27f6 B} {g : B \u27f6 C} (w : f \u226b g = 0) {f' : A \u27f6 B} {g' : B \u27f6 C}\n  (w' : f' \u226b 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 \u2245 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 \u2245 homology f' g' w'\n    where\n  Hom :=\n    homology.map w w'\n      \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by\n        run_tac\n          aux_tac\u27e9\n      \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by\n        run_tac\n          aux_tac\u27e9\n      rfl\n  inv :=\n    homology.map w' w\n      \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by\n        run_tac\n          aux_tac\u27e9\n      \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by\n        run_tac\n          aux_tac\u27e9\n      rfl\n  hom_inv_id' := by\n    cases pf; cases pg; rw [homology.map_comp, \u2190 homology.map_id]\n    congr 1 <;> exact category.comp_id _\n  inv_hom_id' := by\n    cases pf; cases pg; rw [homology.map_comp, \u2190 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 \u27f6 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 \u27f6 B) (g : B \u27f6 C) (w : f \u226b g = 0) [HasKernels V] [HasImages V]\n\n/-- While `image_to_kernel f g w` provides a morphism\n`image_subobject f \u27f6 kernel_subobject g`\nin terms of the subobject API,\nthis variant provides a morphism\n`image f \u27f6 kernel g`,\nwhich is sometimes more convenient.\n-/\ndef imageToKernel' (w : f \u226b g = 0) : image f \u27f6 kernel g :=\n  kernel.lift g (image.\u03b9 f)\n    (by\n      ext\n      simpa using w)\n#align image_to_kernel' imageToKernel'\n\n@[simp]\ntheorem imageSubobjectIso_imageToKernel' (w : f \u226b g = 0) :\n    (imageSubobjectIso f).Hom \u226b imageToKernel' f g w =\n      imageToKernel f g w \u226b (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 \u226b g = 0) :\n    imageToKernel' f g w \u226b (kernelSubobjectIso g).inv =\n      (imageSubobjectIso f).inv \u226b 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 \u226b g = 0) :\n    homology f g w \u2245 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.\u03c0_desc, cokernel.\u03c0_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.\u03c0_desc, category.comp_id, cokernel.\u03c0_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 \u226b g = 0) : homology f g w \u2245 cokernel (kernel.lift g f w) :=\n  by\n  refine' homologyIsoCokernelImageToKernel' f g w \u226a\u226b _\n  have p : factor_thru_image f \u226b imageToKernel' f g w = kernel.lift g f w :=\n    by\n    ext\n    simp [imageToKernel']\n  exact (cokernel_epi_comp _ _).symm \u226a\u226b 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\u2081 w\u2082 w\u2083\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 `\u03c7 : L \u2192 R` is the simultaneous generalized eigenspace of the action of all `x : L` on `M`,\nwith eigenvalues `\u03c7 x`.\n\nSee also `lie_module.weight_space`. -/\ndef pre_weight_space (\u03c7 : L \u2192 R) : submodule R M :=\n\u2a05 (x : L), (to_endomorphism R L M x).maximal_generalized_eigenspace (\u03c7 x)\n\nlemma mem_pre_weight_space (\u03c7 : L \u2192 R) (m : M) :\n  m \u2208 pre_weight_space M \u03c7 \u2194 \u2200 x, \u2203 (k : \u2115), ((to_endomorphism R L M x - (\u03c7 x) \u2022 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  \u2203 (k : \u2115), pre_weight_space M (0 : L \u2192 R) \u2264 ((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 [\u2190 module.End.generalized_eigenspace_zero, pre_weight_space, pi.zero_apply, infi_le,\n    \u2190 (to_endomorphism R L M x).maximal_generalized_eigenspace_eq],\nend\n\nvariables {R} (L)\n\n/-- See also `bourbaki1975b` Chapter VII \u00a71.1, Proposition 2 (ii). -/\nprotected lemma weight_vector_multiplication (M\u2081 : Type w\u2081) (M\u2082 : Type w\u2082) (M\u2083 : Type w\u2083)\n  [add_comm_group M\u2081] [module R M\u2081] [lie_ring_module L M\u2081] [lie_module R L M\u2081]\n  [add_comm_group M\u2082] [module R M\u2082] [lie_ring_module L M\u2082] [lie_module R L M\u2082]\n  [add_comm_group M\u2083] [module R M\u2083] [lie_ring_module L M\u2083] [lie_module R L M\u2083]\n (g : M\u2081 \u2297[R] M\u2082 \u2192\u2097\u2045R,L\u2046 M\u2083) (\u03c7\u2081 \u03c7\u2082 : L \u2192 R) :\n  ((g : M\u2081 \u2297[R] M\u2082 \u2192\u2097[R] M\u2083).comp\n  (map_incl (pre_weight_space M\u2081 \u03c7\u2081) (pre_weight_space M\u2082 \u03c7\u2082))).range \u2264\n    pre_weight_space M\u2083 (\u03c7\u2081 + \u03c7\u2082) :=\nbegin\n  /- Unpack the statement of the goal. -/\n  intros m\u2083,\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\u2083 := (to_endomorphism R L M\u2083 x) - (\u03c7\u2081 x + \u03c7\u2082 x) \u2022 1,\n  change \u2203 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\u2081 t\u2082 \u27e8k\u2081, hk\u2081\u27e9 \u27e8k\u2082, hk\u2082\u27e9, use max k\u2081 k\u2082,\n    simp only [lie_module_hom.map_add, linear_map.map_add,\n      linear_map.pow_map_zero_of_le (le_max_left k\u2081 k\u2082) hk\u2081,\n      linear_map.pow_map_zero_of_le (le_max_right k\u2081 k\u2082) hk\u2082, add_zero], },\n\n  /- Now the main argument: pure tensors. -/\n  rintros \u27e8m\u2081, hm\u2081\u27e9 \u27e8m\u2082, hm\u2082\u27e9,\n  change \u2203 k, (F^k) ((g : M\u2081 \u2297[R] M\u2082 \u2192\u2097[R] M\u2083) (m\u2081 \u2297\u209c m\u2082)) = 0,\n\n  /- Eliminate `g` from the picture. -/\n  let f\u2081 : module.End R (M\u2081 \u2297[R] M\u2082) := (to_endomorphism R L M\u2081 x - (\u03c7\u2081 x) \u2022 1).rtensor M\u2082,\n  let f\u2082 : module.End R (M\u2081 \u2297[R] M\u2082) := (to_endomorphism R L M\u2082 x - (\u03c7\u2082 x) \u2022 1).ltensor M\u2081,\n  have h_comm_square : F \u2218\u2097 \u2191g = (g : M\u2081 \u2297[R] M\u2082 \u2192\u2097[R] M\u2083).comp (f\u2081 + f\u2082),\n  { ext m\u2081 m\u2082, simp only [\u2190 g.map_lie x (m\u2081 \u2297\u209c m\u2082), 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 \u27e8k, hk\u27e9 : \u2203 k, ((f\u2081 + f\u2082)^k) (m\u2081 \u2297\u209c m\u2082) = 0,\n  { use k,\n    rw [\u2190 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\u2081`, `m\u2082`. -/\n  simp only [mem_pre_weight_space] at hm\u2081 hm\u2082,\n  obtain \u27e8k\u2081, hk\u2081\u27e9 := hm\u2081 x,\n  obtain \u27e8k\u2082, hk\u2082\u27e9 := hm\u2082 x,\n  have hf\u2081 : (f\u2081^k\u2081) (m\u2081 \u2297\u209c m\u2082) = 0,\n  { simp only [hk\u2081, zero_tmul, linear_map.rtensor_tmul, linear_map.rtensor_pow], },\n  have hf\u2082 : (f\u2082^k\u2082) (m\u2081 \u2297\u209c m\u2082) = 0,\n  { simp only [hk\u2082, 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\u2081 + k\u2082 - 1,\n  have hf_comm : commute f\u2081 f\u2082,\n  { ext m\u2081 m\u2082, 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 \u27e8i, j\u27e9 hij,\n\n  /- Eliminate the binomial coefficients from the picture. -/\n  suffices : (f\u2081^i * f\u2082^j) (m\u2081 \u2297\u209c m\u2082) = 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\u2081,\n    linear_map.map_zero], },\n  { rw [linear_map.mul_apply, linear_map.pow_map_zero_of_le hj hf\u2082, linear_map.map_zero], },\nend\n\nvariables {L M}\n\nlemma lie_mem_pre_weight_space_of_mem_pre_weight_space {\u03c7\u2081 \u03c7\u2082 : L \u2192 R} {x : L} {m : M}\n  (hx : x \u2208 pre_weight_space L \u03c7\u2081) (hm : m \u2208 pre_weight_space M \u03c7\u2082) :\n  \u2045x, m\u2046 \u2208 pre_weight_space M (\u03c7\u2081 + \u03c7\u2082) :=\nbegin\n  apply lie_module.weight_vector_multiplication L L M M (to_module_hom R L M) \u03c7\u2081 \u03c7\u2082,\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 [\u27e8x, hx\u27e9 \u2297\u209c \u27e8m, hm\u27e9],\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] (\u03c7 : L \u2192 R) : lie_submodule R L M :=\n{ lie_mem := \u03bb x m hm,\n  begin\n    rw \u2190 zero_add \u03c7,\n    refine lie_mem_pre_weight_space_of_mem_pre_weight_space _ hm,\n    suffices : pre_weight_space L (0 : L \u2192 R) = \u22a4, { 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 \u03c7 }\n\nlemma mem_weight_space [lie_algebra.is_nilpotent R L] (\u03c7 : L \u2192 R) (m : M) :\n  m \u2208 weight_space M \u03c7 \u2194 m \u2208 pre_weight_space M \u03c7 :=\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 \u2192 R) = \u22a4 :=\nbegin\n  rw [\u2190 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] (\u03c7 : L \u2192 R) :\n  (weight_space M (\u03c7 \u2218 (\u22a4 : lie_subalgebra R L).incl) : submodule R M) = weight_space M \u03c7 :=\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 \u27e8k, hk\u27e9 := h \u27e8x, set.mem_univ x\u27e9, use k, exact hk, },\n  { obtain \u27e8k, hk\u27e9 := 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 : (\u22a4 : lie_subalgebra R L) \u2192 R) = \u22a4 :=\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 (\u22a4 : lie_subalgebra R L) M` is equivalent to `is_nilpotent R L M`. -/\n  have h\u2080 : (0 : L \u2192 R) \u2218 (\u22a4 : lie_subalgebra R L).incl = 0, { ext, refl, },\n  rw [\u2190 lie_submodule.coe_to_submodule_eq_iff, lie_submodule.top_coe_submodule, \u2190 h\u2080,\n    coe_weight_space_of_top, \u2190 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 \u2286 L` is a Lie character whose corresponding weight space is non-empty. -/\ndef is_weight (\u03c7 : lie_character R H) : Prop := weight_space M \u03c7 \u2260 \u22a5\n\n/-- For a non-trivial nilpotent Lie module over a nilpotent Lie algebra, the zero character is a\nweight with respect to the `\u22a4` 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 (\u22a4 : 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 \u2192 R)) x :=\nbegin\n  obtain \u27e8k, hk\u27e9 := exists_pre_weight_space_zero_le_ker_of_is_noetherian R M x,\n  use k,\n  ext \u27e8m, hm\u27e9,\n  rw [linear_map.zero_apply, lie_submodule.coe_zero, submodule.coe_eq_zero,\n    \u2190 lie_submodule.to_endomorphism_restrict_eq_to_endomorphism, linear_map.pow_restrict,\n    \u2190 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 \u2192 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 \u2286 L`, the root space of a map `\u03c7 : H \u2192 R` is the weight\nspace of `L` regarded as a module of `H` via the adjoint action. -/\nabbreviation root_space (\u03c7 : H \u2192 R) : lie_submodule R H L := weight_space L \u03c7\n\n@[simp] \n\n/-- A root of a Lie algebra `L` with respect to a nilpotent subalgebra `H \u2286 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 (\u03c7 : H \u2192 R) :\n  (root_space H \u03c7).comap H.incl' = weight_space H \u03c7 :=\nbegin\n  ext x,\n  let f : H \u2192 module.End R L := \u03bb y, to_endomorphism R H L y - (\u03c7 y) \u2022 1,\n  let g : H \u2192 module.End R H := \u03bb y, to_endomorphism R H H y - (\u03c7 y) \u2022 1,\n  suffices : (\u2200 (y : H), \u2203 (k : \u2115), ((f y)^k).comp (H.incl : H \u2192\u2097[R] L) x = 0) \u2194\n              \u2200 (y : H), \u2203 (k : \u2115), (H.incl : H \u2192\u2097[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 : \u2200 (y : H), (f y).comp (H.incl : H \u2192\u2097[R] L) = (H.incl : H \u2192\u2097[R] L).comp (g y),\n  { rintros \u27e8y, hy\u27e9, ext \u27e8z, hz\u27e9,\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 {\u03c7\u2081 \u03c7\u2082 : H \u2192 R} {x : L} {m : M}\n  (hx : x \u2208 root_space H \u03c7\u2081) (hm : m \u2208 weight_space M \u03c7\u2082) : \u2045x, m\u2046 \u2208 weight_space M (\u03c7\u2081 + \u03c7\u2082) :=\nbegin\n  apply lie_module.weight_vector_multiplication\n    H L M M ((to_module_hom R L M).restrict_lie H) \u03c7\u2081 \u03c7\u2082,\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 [\u27e8x, hx\u27e9 \u2297\u209c \u27e8m, hm\u27e9],\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 {\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R} (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) :\n  (root_space H \u03c7\u2081) \u2192\u2097[R] (weight_space M \u03c7\u2082) \u2192\u2097[R] (weight_space M \u03c7\u2083) :=\n{ to_fun    := \u03bb x,\n  { to_fun    :=\n      \u03bb m, \u27e8\u2045(x : L), (m : M)\u2046,\n            h\u03c7 \u25b8 (lie_mem_weight_space_of_mem_weight_space x.property m.property) \u27e9,\n    map_add'  := \u03bb m n, by { simp only [lie_submodule.coe_add, lie_add], refl, },\n    map_smul' := \u03bb t m, by { conv_lhs { congr, rw [lie_submodule.coe_smul, lie_smul], }, refl, }, },\n  map_add'  := \u03bb 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' := \u03bb 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 \u2286 L` together with `\u03c7\u2081 \u03c7\u2082 : H \u2192 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 (\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R) (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) :\n  (root_space H \u03c7\u2081) \u2297[R] (weight_space M \u03c7\u2082) \u2192\u2097\u2045R,H\u2046 weight_space M \u03c7\u2083 :=\nlift_lie R H (root_space H \u03c7\u2081) (weight_space M \u03c7\u2082) (weight_space M \u03c7\u2083)\n{ to_linear_map := root_space_weight_space_product_aux R L H M h\u03c7,\n  map_lie' := \u03bb 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  (\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R) (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) (x : root_space H \u03c7\u2081) (m : weight_space M \u03c7\u2082) :\n  (root_space_weight_space_product R L H M \u03c7\u2081 \u03c7\u2082 \u03c7\u2083 h\u03c7 (x \u2297\u209c m) : M) = \u2045(x : L), (m : M)\u2046 :=\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 \u2286 L` together with `\u03c7\u2081 \u03c7\u2082 : H \u2192 R`, there is a natural\n`R`-bilinear product of root vectors, compatible with the actions of `H`. -/\ndef root_space_product (\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R) (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) :\n  (root_space H \u03c7\u2081) \u2297[R] (root_space H \u03c7\u2082) \u2192\u2097\u2045R,H\u2046 root_space H \u03c7\u2083 :=\nroot_space_weight_space_product R L H L \u03c7\u2081 \u03c7\u2082 \u03c7\u2083 h\u03c7\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  (\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R) (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) (x : root_space H \u03c7\u2081) (y : root_space H \u03c7\u2082) :\n  (root_space_product R L H \u03c7\u2081 \u03c7\u2082 \u03c7\u2083 h\u03c7 (x \u2297\u209c y) : L) = \u2045(x : L), (y : L)\u2046 :=\nby simp only [root_space_product_def, coe_root_space_weight_space_product_tmul]\n\n/-- Given a nilpotent Lie subalgebra `H \u2286 L`, the root space of the zero map `0 : H \u2192 R` is a Lie\nsubalgebra of `L`. -/\ndef zero_root_subalgebra : lie_subalgebra R L :=\n{ lie_mem' := \u03bb x y hx hy, by\n  { let xy : (root_space H 0) \u2297[R] (root_space H 0) := \u27e8x, hx\u27e9 \u2297\u209c \u27e8y, hy\u27e9,\n    suffices : (root_space_product R L H 0 0 0 (add_zero 0) xy : L) \u2208 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 \u2208 zero_root_subalgebra R L H \u2194 \u2200 (y : H), \u2203 (k : \u2115), ((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 \u2264 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 \u27e8k, hk\u27e9 := (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 \u27e8x, hx\u27e9 = 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 \u27e8x, hx\u27e9 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 \u2264 zero_root_subalgebra R L H :=\nbegin\n  rw [\u2190 lie_subalgebra.coe_submodule_le_coe_submodule, \u2190 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 \u27e8y, hy\u27e9,\n  specialize hx y (le_zero_root_subalgebra R L H hy),\n  rw mem_zero_root_subalgebra at hx,\n  obtain \u27e8k, hk\u27e9 := hx \u27e8y, hy\u27e9,\n  rw [\u2190 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 \u2190 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 \u2264 H.to_lie_submodule, { exact \u03bb x hx, this hx, },\n  obtain \u27e8k, hk\u27e9 := (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 \u2194 H.is_cartan_subalgebra :=\n\u27e8is_cartan_of_zero_root_subalgebra_eq R L H, by { introsI, simp, }\u27e9\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' (\u03c7 : H \u2192 R) : lie_submodule R (zero_root_subalgebra R L H) M :=\n{ lie_mem := \u03bb x m hm, by\n  { have hx : (x : L) \u2208 root_space H 0,\n    { rw [\u2190 lie_submodule.mem_coe_submodule, \u2190 coe_zero_root_subalgebra], exact x.property, },\n    rw \u2190 zero_add \u03c7,\n    exact lie_mem_weight_space_of_mem_weight_space hx hm, },\n  .. (weight_space M \u03c7 : submodule R M) }\n\n@[simp] lemma coe_weight_space' (\u03c7 : H \u2192 R) :\n  (weight_space' M \u03c7 : submodule R M) = weight_space M \u03c7 :=\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 Std.Util.ExtendedBinder\nimport Std.Tactic.GuardExpr\nimport Mathlib.Tactic.Choose\n\n/-!\n# Tests for the `choose` tactic\n-/\n\nexample {\u03b1 : Type} (h : \u2200 n m : \u03b1, \u2200 (h : n = m), \u2203 i j : \u03b1, i \u2260 j \u2227 h = h) : True := by\n  choose! i j _x _y using h\n  trivial\n\nexample (h : \u2200 n m : Nat, \u2203 i j, m = n + i \u2228 m + j = n) : True := by\n  choose i j h using h\n  guard_hyp i : Nat \u2192 Nat \u2192 Nat\n  guard_hyp j : Nat \u2192 Nat \u2192 Nat\n  guard_hyp h : \u2200 (n m : Nat), m = n + i n m \u2228 m + j n m = n\n  trivial\n\nexample (h : \u2200 i : Nat, i < 7 \u2192 \u2203 j, i < j \u2227 j < i+i) : True := by\n  choose! f h h' using h\n  guard_hyp f : Nat \u2192 Nat\n  guard_hyp h : \u2200 (i : Nat), i < 7 \u2192 i < f i\n  guard_hyp h' : \u2200 (i : Nat), i < 7 \u2192 f i < i + i\n  trivial\n\n/- choice -/\nexample (h : \u2200 n m : Nat, n < m \u2192 \u2203 i j, m = n + i \u2228 m + j = n) : True := by\n  choose i j h using h\n  guard_hyp i : \u2200 n m : Nat, n < m \u2192 Nat\n  guard_hyp j : \u2200 n m : Nat, n < m \u2192 Nat\n  guard_hyp h : \u2200 (n m : Nat) (h : n < m), m = n + i n m h \u2228 m + j n m h = n\n  trivial\n\n-- `choose!` eliminates dependencies on props, whenever possible\nexample (h : \u2200 n m : Nat, n < m \u2192 \u2203 i j, m = n + i \u2228 m + j = n) : True := by\n  choose! i j h using h\n  guard_hyp i : Nat \u2192 Nat \u2192 Nat\n  guard_hyp j : Nat \u2192 Nat \u2192 Nat\n  guard_hyp h : \u2200 (n m : Nat), n < m \u2192 m = n + i n m \u2228 m + j n m = n\n  trivial\n\n-- without the `using hyp` syntax, `choose` will intro the hyp first\nexample : (\u2200 m : Nat, \u2203 i, \u2200 n : Nat, \u2203 j, m = n + i \u2228 m + j = n) \u2192 True := by\n  choose i j h\n  guard_hyp i : Nat \u2192 Nat\n  guard_hyp j : Nat \u2192 Nat \u2192 Nat\n  guard_hyp h : \u2200 (m k : Nat), m = k + i m \u2228 m + j m k = k\n  trivial\n\nexample (h : \u2200 _n m : Nat, \u2203 i, \u2200 n:Nat, \u2203 j, m = n + i \u2228 m + j = n) : True := by\n  choose i j h using h\n  guard_hyp i : Nat \u2192 Nat \u2192 Nat\n  guard_hyp j : Nat \u2192 Nat \u2192 Nat \u2192 Nat\n  guard_hyp h : \u2200 (n m k : Nat), m = k + i n m \u2228 m + j n m k = k\n  trivial\n\n-- Test `simp only [exists_prop]` gets applied after choosing.\n-- Because of this simp, we need a non-rfl goal\nexample (h : \u2200 n, \u2203 k \u2265 0, n = k) : \u2200 _ : Nat, 1 = 1 := by\n  choose u hu using h\n  guard_hyp hu : \u2200 n, u n \u2265 0 \u2227 n = u n\n  intro; rfl\n\n-- test choose with conjunction\nexample (h : \u2200 i : Nat, \u2203 j, i < j \u2227 j < i+i) : True := by\n  choose f h h' using h\n  guard_hyp f : Nat \u2192 Nat\n  guard_hyp h : \u2200 (i : Nat), i < f i\n  guard_hyp h' : \u2200 (i : Nat), f i < i + i\n  trivial\n\ninstance : \u2200 [Nonempty \u03b1], Nonempty (\u03b1 \u00d7 \u03b1) := @fun \u27e8a\u27e9 => \u27e8(a, a)\u27e9\n\n-- test choose with nonempty instances\ninstance : \u2200 [Nonempty \u03b1] [Nonempty \u03b2], Nonempty (\u03b1 \u00d7 \u03b2)\n  | \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8(a, b)\u27e9\n\nexample {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) (h : \u2200 i : \u03b1, p i \u2192 \u2203 j : \u03b1 \u00d7 \u03b1, p j.1) : True := by\n  choose! f h using h\n  guard_hyp f : \u03b1 \u2192 \u03b1 \u00d7 \u03b1\n  guard_hyp h : \u2200 (i : \u03b1), p i \u2192 p (f i).1\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/choose.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6959583250334526, "lm_q2_score": 0.7057850278370112, "lm_q1q2_score": 0.49119696580713507}}
{"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 \u27f6 Y be a morphism. Show that f is an epimorphism\nif and only if the diagram\n\nX --f--\u2192 Y\n|        |\nf        \ud835\udfd9\n|        |\n\u2193        \u2193\nY --\ud835\udfd9--\u2192 Y\n\nis a pushout.\n-/\n\nvariables {C : Type*} [category C]\n\ndef pushout_of_epi {X Y : C} (f : X \u27f6 Y) [epi f] :\n  is_colimit (pushout_cocone.mk (\ud835\udfd9 Y) (\ud835\udfd9 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 \u27f6 Y)\n  (is_colim : is_colimit (pushout_cocone.mk (\ud835\udfd9 Y) (\ud835\udfd9 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 `\ud835\udfd9 X \u226b 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\u00e4rn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David W\u00e4rn\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\u2081 u u\u2081\n\nnamespace category_theory\n\nvariables {C : Type u} [category.{v} C]\n          (r : \u03a0 \u2983a b : C\u2984, (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 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) := \u27e8 { as := default C } \u27e9\n\nnamespace quotient\n\n/-- Generates the closure of a family of relations w.r.t. composition from left and right. -/\ninductive comp_closure \u2983s t : C\u2984 : (s \u27f6 t) \u2192 (s \u27f6 t) \u2192 Prop\n| intro {a b} (f : s \u27f6 a) (m\u2081 m\u2082 : a \u27f6 b) (g : b \u27f6 t) (h : r m\u2081 m\u2082) :\n  comp_closure (f \u226b m\u2081 \u226b g) (f \u226b m\u2082 \u226b g)\n\nlemma comp_left {a b c : C} (f : a \u27f6 b) : \u03a0 (g\u2081 g\u2082 : b \u27f6 c) (h : comp_closure r g\u2081 g\u2082),\n  comp_closure r (f \u226b g\u2081) (f \u226b g\u2082)\n| _ _ \u27e8x, m\u2081, m\u2082, y, h\u27e9 := by simpa using comp_closure.intro (f \u226b x) m\u2081 m\u2082 y h\n\nlemma comp_right {a b c : C} (g : b \u27f6 c) : \u03a0 (f\u2081 f\u2082 : a \u27f6 b) (h : comp_closure r f\u2081 f\u2082),\n  comp_closure r (f\u2081 \u226b g) (f\u2082 \u226b g)\n| _ _ \u27e8x, m\u2081, m\u2082, y, h\u27e9 := by simpa using comp_closure.intro x m\u2081 m\u2082 (y \u226b 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) := \u27e8quot.mk _ (\ud835\udfd9 a.as)\u27e9\n\n/-- Composition in the quotient category. -/\ndef comp \u2983a b c : quotient r\u2984 : hom r a b \u2192 hom r b c \u2192 hom r a c :=\n\u03bb hf hg, quot.lift_on hf ( \u03bb f, quot.lift_on hg (\u03bb g, quot.mk _ (f \u226b g))\n  (\u03bb g\u2081 g\u2082 h, quot.sound $ comp_left r f g\u2081 g\u2082 h) )\n  (\u03bb f\u2081 f\u2082 h, quot.induction_on hg $ \u03bb g, quot.sound $ comp_right r g f\u2081 f\u2082 h)\n\n@[simp]\nlemma comp_mk {a b c : quotient r} (f : a.as \u27f6 b.as) (g : b.as \u27f6 c.as) :\n  comp r (quot.mk _ f) (quot.mk _ g) = quot.mk _ (f \u226b g) := rfl\n\ninstance category : category (quotient r) :=\n{ hom := hom r,\n  id := \u03bb a, quot.mk _ (\ud835\udfd9 a.as),\n  comp := comp r }\n\n/-- The functor from a category to its quotient. -/\n@[simps]\ndef functor : C \u2964 quotient r :=\n{ obj := \u03bb a, { as := a },\n  map := \u03bb _ _ f, quot.mk _ f }\n\nprotected lemma induction {P : \u03a0 {a b : quotient r}, (a \u27f6 b) \u2192 Prop}\n  (h : \u2200 {x y : C} (f : x \u27f6 y), P ((functor r).map f)) :\n  \u2200 {a b : quotient r} (f : a \u27f6 b), P f :=\nby { rintros \u27e8x\u27e9 \u27e8y\u27e9 \u27e8f\u27e9, exact h f, }\n\nprotected lemma sound {a b : C} {f\u2081 f\u2082 : a \u27f6 b} (h : r f\u2081 f\u2082) :\n  (functor r).map f\u2081 = (functor r).map f\u2082 :=\nby simpa using quot.sound (comp_closure.intro (\ud835\udfd9 a) f\u2081 f\u2082 (\ud835\udfd9 b) h)\n\nvariables {D : Type*} [category D]\n  (F : C \u2964 D)\n  (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 F.map f\u2081 = F.map f\u2082)\ninclude H\n\n/-- The induced functor on the quotient category. -/\n@[simps]\ndef lift : quotient r \u2964 D :=\n{ obj := \u03bb a, F.obj a.as,\n  map := \u03bb a b hf, quot.lift_on hf (\u03bb f, F.map f)\n    (by { rintros _ _ \u27e8_, _, _, _, _, _, h\u27e9, simp [H _ _ _ _ h], }),\n  map_id' := \u03bb a, F.map_id a.as,\n  map_comp' := by { rintros a b c \u27e8f\u27e9 \u27e8g\u27e9, exact F.map_comp f g, } }\n\n/-- The original functor factors through the induced functor. -/\ndef lift.is_lift : (functor r) \u22d9 lift r F H \u2245 F :=\nnat_iso.of_components (\u03bb X, iso.refl _) (by tidy)\n\n@[simp]\nlemma lift.is_lift_hom (X : C) : (lift.is_lift r F H).hom.app X = \ud835\udfd9 (F.obj X) :=\nrfl\n@[simp]\nlemma lift.is_lift_inv (X : C) : (lift.is_lift r F H).inv.app X = \ud835\udfd9 (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 {\ud835\udd5c V W : Type*} [nondiscrete_normed_field \ud835\udd5c]\nvariables [normed_group V] [normed_space \ud835\udd5c V]\nvariables [normed_group W] [normed_space \ud835\udd5c W]\n\n/-- A continuous affine map between normed vector spaces is smooth. -/\nlemma cont_diff {n : with_top \u2115} (f : V \u2192A[\ud835\udd5c] W) :\n  cont_diff \ud835\udd5c 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} \u2983m\u2081 m\u2082 : monoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\nbegin\n  have h\u2081 : (@monoid.to_mul_one_class _ m\u2081).one = (@monoid.to_mul_one_class _ m\u2082).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\u2081) (@monoid.to_mul_one_class _ m\u2082) :=\n    { to_fun := id, map_one' := h\u2081, map_mul' := \u03bb x y, congr_fun (congr_fun h_mul x) y },\n  have hpow : m\u2081.npow = m\u2082.npow, by { ext n x, exact @monoid_hom.map_pow M M m\u2081 m\u2082 f x n },\n  unfreezingI { cases m\u2081, cases m\u2082 },\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma comm_monoid.ext {M : Type*} \u2983m\u2081 m\u2082 : comm_monoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma left_cancel_monoid.ext {M : Type u} \u2983m\u2081 m\u2082 : left_cancel_monoid M\u2984\n  (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma right_cancel_monoid.ext {M : Type u} \u2983m\u2081 m\u2082 : right_cancel_monoid M\u2984\n  (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma cancel_monoid.ext {M : Type*} \u2983m\u2081 m\u2082 : cancel_monoid M\u2984\n  (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma cancel_comm_monoid.ext {M : Type*} \u2983m\u2081 m\u2082 : cancel_comm_monoid M\u2984\n  (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\ncancel_comm_monoid.to_comm_monoid_injective $ comm_monoid.ext h_mul\n\n@[ext, to_additive]\nlemma div_inv_monoid.ext {M : Type*} \u2983m\u2081 m\u2082 : div_inv_monoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul)\n  (h_inv : m\u2081.inv = m\u2082.inv) : m\u2081 = m\u2082 :=\nbegin\n  have h\u2081 : (@div_inv_monoid.to_monoid _ m\u2081).one = (@div_inv_monoid.to_monoid _ m\u2082).one,\n    from congr_arg (@monoid.one M) (monoid.ext h_mul),\n  set f : @monoid_hom M M (by letI := m\u2081; apply_instance) (by letI := m\u2082; apply_instance) :=\n    { to_fun := id, map_one' := h\u2081, map_mul' := \u03bb x y, congr_fun (congr_fun h_mul x) y },\n  have hpow : (@div_inv_monoid.to_monoid _ m\u2081).npow = (@div_inv_monoid.to_monoid _ m\u2082).npow :=\n    congr_arg (@monoid.npow M) (monoid.ext h_mul),\n  have hzpow : m\u2081.zpow = m\u2082.zpow,\n  { ext m x,\n    exact @monoid_hom.map_zpow' M M m\u2081 m\u2082 f (congr_fun h_inv) x m },\n  have hdiv : m\u2081.div = m\u2082.div,\n  { ext a b,\n    exact @monoid_hom.map_div' M M m\u2081 m\u2082 f (congr_fun h_inv) a b },\n  unfreezingI { cases m\u2081, cases m\u2082 },\n  congr, exacts [h_mul, h\u2081, hpow, h_inv, hdiv, hzpow]\nend\n\n@[ext, to_additive]\nlemma group.ext {G : Type*} \u2983g\u2081 g\u2082 : group G\u2984 (h_mul : g\u2081.mul = g\u2082.mul) : g\u2081 = g\u2082 :=\nbegin\n  set f := @monoid_hom.mk' G G (by letI := g\u2081; apply_instance) g\u2082 id\n    (\u03bb 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\u2081 g\u2082 f))\nend\n\n@[ext, to_additive]\nlemma comm_group.ext {G : Type*} \u2983g\u2081 g\u2082 : comm_group G\u2984\n  (h_mul : g\u2081.mul = g\u2082.mul) : g\u2081 = g\u2082 :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, S\u00e9bastien Gou\u00ebzel, 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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n          [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3]\nuniverse u\n\n/-- A map `f : \u03b1 \u2192 \u03b2` between uniform spaces is called *uniform inducing* if the uniformity filter\non `\u03b1` is the pullback of the uniformity filter on `\u03b2` under `prod.map f f`. If `\u03b1` is a separated\nspace, then this implies that `f` is injective, hence it is a `uniform_embedding`. -/\nstructure uniform_inducing (f : \u03b1 \u2192 \u03b2) : Prop :=\n(comap_uniformity : comap (\u03bbx:\u03b1\u00d7\u03b1, (f x.1, f x.2)) (\ud835\udce4 \u03b2) = \ud835\udce4 \u03b1)\n\nlemma uniform_inducing.mk' {f : \u03b1 \u2192 \u03b2} (h : \u2200 s, s \u2208 \ud835\udce4 \u03b1 \u2194\n    \u2203 t \u2208 \ud835\udce4 \u03b2, \u2200 x y : \u03b1, (f x, f y) \u2208 t \u2192 (x, y) \u2208 s) : uniform_inducing f :=\n\u27e8by simp [eq_comm, filter.ext_iff, subset_def, h]\u27e9\n\nlemma uniform_inducing.comp {g : \u03b2 \u2192 \u03b3} (hg : uniform_inducing g)\n  {f : \u03b1 \u2192 \u03b2} (hf : uniform_inducing f) : uniform_inducing (g \u2218 f) :=\n\u27e8 by rw [show (\u03bb (x : \u03b1 \u00d7 \u03b1), ((g \u2218 f) x.1, (g \u2218 f) x.2)) =\n         (\u03bb y : \u03b2 \u00d7 \u03b2, (g y.1, g y.2)) \u2218 (\u03bb x : \u03b1 \u00d7 \u03b1, (f x.1, f x.2)), by ext ; simp,\n        \u2190 filter.comap_comap, hg.1, hf.1]\u27e9\n\nlemma uniform_inducing.basis_uniformity {f : \u03b1 \u2192 \u03b2} (hf : uniform_inducing f)\n  {\u03b9 : Sort*} {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set (\u03b2 \u00d7 \u03b2)} (H : (\ud835\udce4 \u03b2).has_basis p s) :\n  (\ud835\udce4 \u03b1).has_basis p (\u03bb i, prod.map f f \u207b\u00b9' s i) :=\nhf.1 \u25b8 H.comap _\n\n/-- A map `f : \u03b1 \u2192 \u03b2` between uniform spaces is a *uniform embedding* if it is uniform inducing and\ninjective. If `\u03b1` is a separated space, then the latter assumption follows from the former. -/\nstructure uniform_embedding (f : \u03b1 \u2192 \u03b2) extends uniform_inducing f : Prop :=\n(inj : function.injective f)\n\nlemma uniform_embedding_subtype_val {p : \u03b1 \u2192 Prop} :\n  uniform_embedding (subtype.val : subtype p \u2192 \u03b1) :=\n{ comap_uniformity := rfl,\n  inj := subtype.val_injective }\n\nlemma uniform_embedding_subtype_coe {p : \u03b1 \u2192 Prop} :\n  uniform_embedding (coe : subtype p \u2192 \u03b1) :=\nuniform_embedding_subtype_val\n\nlemma uniform_embedding_set_inclusion {s t : set \u03b1} (hst : s \u2286 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 : \u03b2 \u2192 \u03b3} (hg : uniform_embedding g)\n  {f : \u03b1 \u2192 \u03b2} (hf : uniform_embedding f) : uniform_embedding (g \u2218 f) :=\n{ inj := hg.inj.comp hf.inj,\n  ..hg.to_uniform_inducing.comp hf.to_uniform_inducing }\n\ntheorem uniform_embedding_def {f : \u03b1 \u2192 \u03b2} :\n  uniform_embedding f \u2194 function.injective f \u2227 \u2200 s, s \u2208 \ud835\udce4 \u03b1 \u2194\n    \u2203 t \u2208 \ud835\udce4 \u03b2, \u2200 x y : \u03b1, (f x, f y) \u2208 t \u2192 (x, y) \u2208 s :=\nbegin\n  split,\n  { rintro \u27e8\u27e8h\u27e9, h'\u27e9,\n    rw [eq_comm, filter.ext_iff] at h,\n    simp [*, subset_def] },\n  { rintro \u27e8h, h'\u27e9,\n    refine uniform_embedding.mk \u27e8_\u27e9 h,\n    rw [eq_comm, filter.ext_iff],\n    simp [*, subset_def] }\nend\n\ntheorem uniform_embedding_def' {f : \u03b1 \u2192 \u03b2} :\n  uniform_embedding f \u2194 function.injective f \u2227 uniform_continuous f \u2227\n    \u2200 s, s \u2208 \ud835\udce4 \u03b1 \u2192\n      \u2203 t \u2208 \ud835\udce4 \u03b2, \u2200 x y : \u03b1, (f x, f y) \u2208 t \u2192 (x, y) \u2208 s :=\nby simp only [uniform_embedding_def, uniform_continuous_def]; exact\n\u27e8\u03bb \u27e8I, H\u27e9, \u27e8I, \u03bb s su, (H _).2 \u27e8s, su, \u03bb x y, id\u27e9, \u03bb s, (H s).1\u27e9,\n \u03bb \u27e8I, H\u2081, H\u2082\u27e9, \u27e8I, \u03bb s, \u27e8H\u2082 s,\n   \u03bb \u27e8t, tu, h\u27e9, mem_of_superset (H\u2081 t tu) (\u03bb \u27e8a, b\u27e9, h a b)\u27e9\u27e9\u27e9\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 \u03b1] {f : \u03b1 \u2192 \u03b2}\n  (hf : uniform_inducing f) :\n  uniform_embedding f :=\n\u27e8hf, \u03bb x y h, eq_of_uniformity_basis (hf.basis_uniformity (\ud835\udce4 \u03b2).basis_sets) $\n  \u03bb s hs, mem_preimage.2 $ mem_uniformity_of_eq hs h\u27e9\n\n/-- If a map `f : \u03b1 \u2192 \u03b2` sends any two distinct points to point that are **not** related by a fixed\n`s \u2208 \ud835\udce4 \u03b2`, then `f` is uniform inducing with respect to the discrete uniformity on `\u03b1`:\nthe preimage of `\ud835\udce4 \u03b2` under `prod.map f f` is the principal filter generated by the diagonal in\n`\u03b1 \u00d7 \u03b1`. -/\nlemma comap_uniformity_of_spaced_out {\u03b1} {f : \u03b1 \u2192 \u03b2} {s : set (\u03b2 \u00d7 \u03b2)} (hs : s \u2208 \ud835\udce4 \u03b2)\n  (hf : pairwise (\u03bb x y, (f x, f y) \u2209 s)) :\n  comap (prod.map f f) (\ud835\udce4 \u03b2) = \ud835\udcdf id_rel :=\nbegin\n  refine le_antisymm _ (@refl_le_uniformity \u03b1 (uniform_space.comap f \u2039_\u203a)),\n  calc comap (prod.map f f) (\ud835\udce4 \u03b2) \u2264 comap (prod.map f f) (\ud835\udcdf s) : comap_mono (le_principal_iff.2 hs)\n  ... = \ud835\udcdf (prod.map f f \u207b\u00b9' s) : comap_principal\n  ... \u2264 \ud835\udcdf id_rel : principal_mono.2 _,\n  rintro \u27e8x, y\u27e9, simpa [not_imp_not] using hf x y\nend\n\n/-- If a map `f : \u03b1 \u2192 \u03b2` sends any two distinct points to point that are **not** related by a fixed\n`s \u2208 \ud835\udce4 \u03b2`, then `f` is a uniform embedding with respect to the discrete uniformity on `\u03b1`. -/\nlemma uniform_embedding_of_spaced_out {\u03b1} {f : \u03b1 \u2192 \u03b2} {s : set (\u03b2 \u00d7 \u03b2)} (hs : s \u2208 \ud835\udce4 \u03b2)\n  (hf : pairwise (\u03bb x y, (f x, f y) \u2209 s)) :\n  @uniform_embedding \u03b1 \u03b2 \u22a5 \u2039_\u203a f :=\nbegin\n  letI : uniform_space \u03b1 := \u22a5, haveI : separated_space \u03b1 := separated_iff_t2.2 infer_instance,\n  exact uniform_inducing.uniform_embedding \u27e8comap_uniformity_of_spaced_out hs hf\u27e9\nend\n\nlemma uniform_inducing.uniform_continuous {f : \u03b1 \u2192 \u03b2}\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 : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hg : uniform_inducing g) :\n  uniform_continuous f \u2194 uniform_continuous (g \u2218 f) :=\nby { dsimp only [uniform_continuous, tendsto],\n  rw [\u2190 hg.comap_uniformity, \u2190 map_le_iff_le_comap, filter.map_map] }\n\nlemma uniform_inducing.inducing {f : \u03b1 \u2192 \u03b2} (h : uniform_inducing f) : inducing f :=\nbegin\n  refine \u27e8eq_of_nhds_eq_nhds $ assume a, _ \u27e9,\n  rw [nhds_induced, nhds_eq_uniformity, nhds_eq_uniformity, \u2190 h.comap_uniformity,\n    comap_lift'_eq, comap_lift'_eq2];\n    { refl <|> exact monotone_preimage }\nend\n\nlemma uniform_inducing.prod {\u03b1' : Type*} {\u03b2' : Type*} [uniform_space \u03b1'] [uniform_space \u03b2']\n  {e\u2081 : \u03b1 \u2192 \u03b1'} {e\u2082 : \u03b2 \u2192 \u03b2'} (h\u2081 : uniform_inducing e\u2081) (h\u2082 : uniform_inducing e\u2082) :\n  uniform_inducing (\u03bbp:\u03b1\u00d7\u03b2, (e\u2081 p.1, e\u2082 p.2)) :=\n\u27e8by simp [(\u2218), uniformity_prod, h\u2081.comap_uniformity.symm, h\u2082.comap_uniformity.symm,\n           comap_inf, comap_comap]\u27e9\n\nlemma uniform_inducing.dense_inducing {f : \u03b1 \u2192 \u03b2} (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 : \u03b1 \u2192 \u03b2} (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 : \u03b1 \u2192 \u03b2} (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 {\u03b1} [topological_space \u03b1] [discrete_topology \u03b1]\n  [separated_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set (\u03b2 \u00d7 \u03b2)} (hs : s \u2208 \ud835\udce4 \u03b2)\n  (hf : pairwise (\u03bb x y, (f x, f y) \u2209 s)) :\n  closed_embedding f :=\nbegin\n  unfreezingI { rcases (discrete_topology.eq_bot \u03b1) with rfl }, letI : uniform_space \u03b1 := \u22a5,\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 (\u03b1\u00d7\u03b1)} {e : \u03b1 \u2192 \u03b2} (b : \u03b2)\n  (he\u2081 : uniform_inducing e) (he\u2082 : dense_inducing e) (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203a, closure (e '' {a' | (a, a') \u2208 s}) \u2208 \ud835\udcdd b :=\nhave s \u2208 comap (\u03bbp:\u03b1\u00d7\u03b1, (e p.1, e p.2)) (\ud835\udce4 \u03b2),\n  from he\u2081.comap_uniformity.symm \u25b8 hs,\nlet \u27e8t\u2081, ht\u2081u, ht\u2081\u27e9 := this in\nhave ht\u2081 : \u2200p:\u03b1\u00d7\u03b1, (e p.1, e p.2) \u2208 t\u2081 \u2192 p \u2208 s, from ht\u2081,\nlet \u27e8t\u2082, ht\u2082u, ht\u2082s, ht\u2082c\u27e9 := comp_symm_of_uniformity ht\u2081u in\nlet \u27e8t, htu, hts, htc\u27e9 := comp_symm_of_uniformity ht\u2082u in\nhave preimage e {b' | (b, b') \u2208 t\u2082} \u2208 comap e (\ud835\udcdd b),\n  from preimage_mem_comap $ mem_nhds_left b ht\u2082u,\nlet \u27e8a, (ha : (b, e a) \u2208 t\u2082)\u27e9 := (he\u2082.comap_nhds_ne_bot _).nonempty_of_mem this in\nhave \u2200b' (s' : set (\u03b2 \u00d7 \u03b2)), (b, b') \u2208 t \u2192 s' \u2208 \ud835\udce4 \u03b2 \u2192\n  ({y : \u03b2 | (b', y) \u2208 s'} \u2229 e '' {a' : \u03b1 | (a, a') \u2208 s}).nonempty,\n  from assume b' s' hb' hs',\n  have preimage e {b'' | (b', b'') \u2208 s' \u2229 t} \u2208 comap e (\ud835\udcdd b'),\n    from preimage_mem_comap $ mem_nhds_left b' $ inter_mem hs' htu,\n  let \u27e8a\u2082, ha\u2082s', ha\u2082t\u27e9 := (he\u2082.comap_nhds_ne_bot _).nonempty_of_mem this in\n  have (e a, e a\u2082) \u2208 t\u2081,\n    from ht\u2082c $ prod_mk_mem_comp_rel (ht\u2082s ha) $ htc $ prod_mk_mem_comp_rel hb' ha\u2082t,\n  have e a\u2082 \u2208 {b'':\u03b2 | (b', b'') \u2208 s'} \u2229 e '' {a' | (a, a') \u2208 s},\n    from \u27e8ha\u2082s', mem_image_of_mem _ $ ht\u2081 (a, a\u2082) this\u27e9,\n  \u27e8_, this\u27e9,\nhave \u2200b', (b, b') \u2208 t \u2192 ne_bot (\ud835\udcdd b' \u2293 \ud835\udcdf (e '' {a' | (a, a') \u2208 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 \u2200b', (b, b') \u2208 t \u2192 b' \u2208 closure (e '' {a' | (a, a') \u2208 s}),\n  from assume b' hb', by rw [closure_eq_cluster_pts]; exact this b' hb',\n\u27e8a, (\ud835\udcdd b).sets_of_superset (mem_nhds_left b htu) this\u27e9\n\nlemma uniform_embedding_subtype_emb (p : \u03b1 \u2192 Prop) {e : \u03b1 \u2192 \u03b2} (ue : uniform_embedding e)\n  (de : dense_embedding e) : uniform_embedding (dense_embedding.subtype_emb p e) :=\n{ comap_uniformity := by simp [comap_comap, (\u2218), dense_embedding.subtype_emb,\n           uniformity_subtype, ue.comap_uniformity.symm],\n  inj := (de.subtype p).inj }\n\nlemma uniform_embedding.prod {\u03b1' : Type*} {\u03b2' : Type*} [uniform_space \u03b1'] [uniform_space \u03b2']\n  {e\u2081 : \u03b1 \u2192 \u03b1'} {e\u2082 : \u03b2 \u2192 \u03b2'} (h\u2081 : uniform_embedding e\u2081) (h\u2082 : uniform_embedding e\u2082) :\n  uniform_embedding (\u03bbp:\u03b1\u00d7\u03b2, (e\u2081 p.1, e\u2082 p.2)) :=\n{ inj := h\u2081.inj.prod_map h\u2082.inj,\n  ..h\u2081.to_uniform_inducing.prod h\u2082.to_uniform_inducing }\n\nlemma is_complete_of_complete_image {m : \u03b1 \u2192 \u03b2} {s : set \u03b1} (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 \u27e8_, \u27e8x, hx, rfl\u27e9, hyf\u27e9 : \u2203 y \u2208 m '' s, map m f \u2264 \ud835\udcdd 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, \u2190 nhds_induced, \u2190 hm.inducing.induced] at hyf,\n  exact \u27e8x, hx, hyf\u27e9\nend\n\nlemma is_complete.complete_space_coe {s : set \u03b1} (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 : \u03b1 \u2192 \u03b2} {s : set \u03b1} (hm : uniform_inducing m) :\n  is_complete (m '' s) \u2194 is_complete s :=\nbegin\n  refine \u27e8is_complete_of_complete_image hm, \u03bb c, _\u27e9,\n  haveI : complete_space s := c.complete_space_coe,\n  set m' : s \u2192 \u03b2 := m \u2218 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 \u27e8x, hx\u27e9,\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 : \u03b1 \u2192 \u03b2} (hf : uniform_inducing f) :\n  complete_space \u03b1 \u2194 is_complete (range f) :=\nby rw [complete_space_iff_is_complete_univ, \u2190 is_complete_image_iff hf, image_univ]\n\nlemma uniform_inducing.is_complete_range [complete_space \u03b1] {f : \u03b1 \u2192 \u03b2}\n  (hf : uniform_inducing f) :\n  is_complete (range f) :=\n(complete_space_iff_is_complete_range hf).1 \u2039_\u203a\n\nlemma complete_space_congr {e : \u03b1 \u2243 \u03b2} (he : uniform_embedding e) :\n  complete_space \u03b1 \u2194 complete_space \u03b2 :=\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 \u03b1} :\n  complete_space s \u2194 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 \u03b1] {s : set \u03b1} (hs : is_closed s) :\n  complete_space s :=\nhs.is_complete.complete_space_coe\n\nlemma complete_space_extension {m : \u03b2 \u2192 \u03b1} (hm : uniform_inducing m) (dense : dense_range m)\n  (h : \u2200f:filter \u03b2, cauchy f \u2192 \u2203x:\u03b1, map m f \u2264 \ud835\udcdd x) : complete_space \u03b1 :=\n\u27e8assume (f : filter \u03b1), assume hf : cauchy f,\nlet\n  p : set (\u03b1 \u00d7 \u03b1) \u2192 set \u03b1 \u2192 set \u03b1 := \u03bbs t, {y : \u03b1| \u2203x:\u03b1, x \u2208 t \u2227 (x, y) \u2208 s},\n  g := (\ud835\udce4 \u03b1).lift (\u03bbs, f.lift' (p s))\nin\nhave mp\u2080 : monotone p,\n  from assume a b h t s \u27e8x, xs, xa\u27e9, \u27e8x, xs, h xa\u27e9,\nhave mp\u2081 : \u2200{s}, monotone (p s),\n  from assume s a b h x \u27e8y, ya, yxs\u27e9, \u27e8y, h ya, yxs\u27e9,\n\nhave f \u2264 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, \u27e8x, hx, refl_mem_uniformity hs\u27e9,\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 \u27e8t', ht', ht_mem\u27e9 := (mem_lift_sets $ monotone_lift' monotone_const mp\u2080).mp ht in\n  let \u27e8t'', ht'', ht'_sub\u27e9 := (mem_lift'_sets mp\u2081).mp ht_mem in\n  let \u27e8x, (hx : x \u2208 t'')\u27e9 := hf.left.nonempty_of_mem ht'' in\n  have h\u2080 : ne_bot (\ud835\udcdd[range m] x),\n    from dense.nhds_within_ne_bot x,\n  have h\u2081 : {y | (x, y) \u2208 t'} \u2208 \ud835\udcdd[range m] x,\n    from @mem_inf_of_left \u03b1 (\ud835\udcdd x) (\ud835\udcdf (range m)) _ $ mem_nhds_left x ht',\n  have h\u2082 : range m \u2208 \ud835\udcdd[range m] x,\n    from @mem_inf_of_right \u03b1 (\ud835\udcdd x) (\ud835\udcdf (range m)) _ $ subset.refl _,\n  have {y | (x, y) \u2208 t'} \u2229 range m \u2208 \ud835\udcdd[range m] x,\n    from @inter_mem \u03b1 (\ud835\udcdd[range m] x) _ _ h\u2081 h\u2082,\n  let \u27e8y, xyt', b, b_eq\u27e9 := h\u2080.nonempty_of_mem this in\n  \u27e8b, b_eq.symm \u25b8 ht'_sub \u27e8x, hx, xyt'\u27e9\u27e9,\n\nhave cauchy g, from\n  \u27e8\u2039ne_bot g\u203a, assume s hs,\n  let\n    \u27e8s\u2081, hs\u2081, (comp_s\u2081 : comp_rel s\u2081 s\u2081 \u2286 s)\u27e9 := comp_mem_uniformity_sets hs,\n    \u27e8s\u2082, hs\u2082, (comp_s\u2082 : comp_rel s\u2082 s\u2082 \u2286 s\u2081)\u27e9 := comp_mem_uniformity_sets hs\u2081,\n    \u27e8t, ht, (prod_t : set.prod t t \u2286 s\u2082)\u27e9 := mem_prod_same_iff.mp (hf.right hs\u2082)\n  in\n  have hg\u2081 : p (preimage prod.swap s\u2081) t \u2208 g,\n    from mem_lift (symm_le_uniformity hs\u2081) $ @mem_lift' \u03b1 \u03b1 f _ t ht,\n  have hg\u2082 : p s\u2082 t \u2208 g,\n    from mem_lift hs\u2082 $ @mem_lift' \u03b1 \u03b1 f _ t ht,\n  have hg : set.prod (p (preimage prod.swap s\u2081) t) (p s\u2082 t) \u2208 g \u00d7\u1da0 g,\n    from @prod_mem_prod \u03b1 \u03b1 _ _ g g hg\u2081 hg\u2082,\n  (g \u00d7\u1da0 g).sets_of_superset hg\n    (assume \u27e8a, b\u27e9 \u27e8\u27e8c\u2081, c\u2081t, hc\u2081\u27e9, \u27e8c\u2082, c\u2082t, hc\u2082\u27e9\u27e9,\n      have (c\u2081, c\u2082) \u2208 set.prod t t, from \u27e8c\u2081t, c\u2082t\u27e9,\n      comp_s\u2081 $ prod_mk_mem_comp_rel hc\u2081 $\n      comp_s\u2082 $ prod_mk_mem_comp_rel (prod_t this) hc\u2082)\u27e9,\n\nhave cauchy (filter.comap m g),\n  from \u2039cauchy g\u203a.comap' (le_of_eq hm.comap_uniformity) \u2039_\u203a,\n\nlet \u27e8x, (hx : map m (filter.comap m g) \u2264 \ud835\udcdd x)\u27e9 := 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\u27e8x, calc f \u2264 g : by assumption\n  ... \u2264 \ud835\udcdd x : le_nhds_of_cauchy_adhp \u2039cauchy g\u203a this\u27e9\u27e9\n\nlemma totally_bounded_preimage {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} (hf : uniform_embedding f)\n  (hs : totally_bounded s) : totally_bounded (f \u207b\u00b9' s) :=\n\u03bb t ht, begin\n  rw \u2190 hf.comap_uniformity at ht,\n  rcases mem_comap.2 ht with \u27e8t', ht', ts\u27e9,\n  rcases totally_bounded_iff_subset.1\n    (totally_bounded_subset (image_preimage_subset f s) hs) _ ht' with \u27e8c, cs, hfc, hct\u27e9,\n  refine \u27e8f \u207b\u00b9' c, hfc.preimage (hf.inj.inj_on _), \u03bb x h, _\u27e9,\n  have := hct (mem_image_of_mem f h), simp at this \u22a2,\n  rcases this with \u27e8z, zc, zt\u27e9,\n  rcases cs zc with \u27e8y, yc, rfl\u27e9,\n  exact \u27e8y, zc, ts (by exact zt)\u27e9\nend\n\nend\n\nlemma uniform_embedding_comap {\u03b1 : Type*} {\u03b2 : Type*} {f : \u03b1 \u2192 \u03b2} [u : uniform_space \u03b2]\n  (hf : function.injective f) : @uniform_embedding \u03b1 \u03b2 (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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n          [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3]\n          {e : \u03b2 \u2192 \u03b1}\n          (h_e : uniform_inducing e)\n          (h_dense : dense_range e)\n          {f : \u03b2 \u2192 \u03b3}\n          (h_f : uniform_continuous f)\n\nlocal notation `\u03c8` := (h_e.dense_inducing h_dense).extend f\n\nlemma uniformly_extend_exists [complete_space \u03b3] (a : \u03b1) :\n  \u2203c, tendsto f (comap e (\ud835\udcdd a)) (\ud835\udcdd c) :=\nlet de := (h_e.dense_inducing h_dense) in\nhave cauchy (\ud835\udcdd a), from cauchy_nhds,\nhave cauchy (comap e (\ud835\udcdd a)), from\n  this.comap' (le_of_eq h_e.comap_uniformity) (de.comap_nhds_ne_bot _),\nhave cauchy (map f (comap e (\ud835\udcdd a))), from this.map h_f,\ncomplete_space.complete this\n\nlemma uniform_extend_subtype [complete_space \u03b3]\n  {p : \u03b1 \u2192 Prop} {e : \u03b1 \u2192 \u03b2} {f : \u03b1 \u2192 \u03b3} {b : \u03b2} {s : set \u03b1}\n  (hf : uniform_continuous (\u03bbx:subtype p, f x.val))\n  (he : uniform_embedding e) (hd : \u2200x:\u03b2, x \u2208 closure (range e))\n  (hb : closure (e '' s) \u2208 \ud835\udcdd b) (hs : is_closed s) (hp : \u2200x\u2208s, p x) :\n  \u2203c, tendsto f (comap e (\ud835\udcdd b)) (\ud835\udcdd 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 \u2208 closure (e '' {x | p x}),\n  from (closure_mono $ monotone_image $ hp) (mem_of_mem_nhds hb),\nlet \u27e8c, (hc : tendsto (f \u2218 subtype.val)\n     (comap (dense_embedding.subtype_emb p e) (\ud835\udcdd \u27e8b, this\u27e9)) (\ud835\udcdd c))\u27e9 :=\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 \u2218 @subtype.val \u03b1 p) (comap (e \u2218 @subtype.val \u03b1 p) (\ud835\udcdd b)) (\ud835\udcdd c)) at hc,\n  rw [\u2190comap_comap, tendsto_comap'_iff] at hc,\n  exact \u27e8c, hc\u27e9,\n  exact \u27e8_, hb, assume x,\n    begin\n      change e x \u2208 (closure (e '' s)) \u2192 x \u2208 range subtype.val,\n      rw [\u2190 closure_induced, mem_closure_iff_cluster_pt, cluster_pt, ne_bot_iff,\n          nhds_induced, \u2190 de.to_dense_inducing.nhds_eq_comap,\n          \u2190 mem_closure_iff_nhds_ne_bot, hs.closure_eq],\n      exact assume hxs, \u27e8\u27e8x, hp x hxs\u27e9, rfl\u27e9,\n    end\u27e9\nend\n\ninclude h_f\n\nlemma uniformly_extend_spec [complete_space \u03b3] (a : \u03b1) :\n  tendsto f (comap e (\ud835\udcdd a)) (\ud835\udcdd (\u03c8 a)) :=\nby simpa only [dense_inducing.extend] using tendsto_nhds_lim (uniformly_extend_exists h_e \u2039_\u203a h_f _)\n\nlemma uniform_continuous_uniformly_extend [c\u03b3 : complete_space \u03b3] : uniform_continuous \u03c8 :=\nassume d hd,\nlet \u27e8s, hs, hs_comp\u27e9 := (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 : \u2200{a m}, m \u2208 \ud835\udcdd a \u2192 \u2203c, c \u2208 f '' preimage e m \u2227 (c, \u03c8 a) \u2208 s \u2227 (\u03c8 a, c) \u2208 s,\n  from assume a m hm,\n  have nb : ne_bot (map f (comap e (\ud835\udcdd a))),\n    from ((h_e.dense_inducing h_dense).comap_nhds_ne_bot _).map _,\n  have (f '' preimage e m) \u2229 ({c | (c, \u03c8 a) \u2208 s } \u2229 {c | (\u03c8 a, c) \u2208 s }) \u2208 map f (comap e (\ud835\udcdd 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 (\u03bbp:\u03b2\u00d7\u03b2, (f p.1, f p.2)) s \u2208 \ud835\udce4 \u03b2,\n  from h_f hs,\nhave preimage (\u03bbp:\u03b2\u00d7\u03b2, (f p.1, f p.2)) s \u2208 comap (\u03bbx:\u03b2\u00d7\u03b2, (e x.1, e x.2)) (\ud835\udce4 \u03b1),\n  by rwa [h_e.comap_uniformity.symm] at this,\nlet \u27e8t, ht, ts\u27e9 := this in\nshow preimage (\u03bbp:(\u03b1\u00d7\u03b1), (\u03c8 p.1, \u03c8 p.2)) d \u2208 \ud835\udce4 \u03b1,\n  from (\ud835\udce4 \u03b1).sets_of_superset (interior_mem_uniformity ht) $\n  assume \u27e8x\u2081, x\u2082\u27e9 hx_t,\n  have \ud835\udcdd (x\u2081, x\u2082) \u2264 \ud835\udcdf (interior t),\n    from is_open_iff_nhds.mp is_open_interior (x\u2081, x\u2082) hx_t,\n  have interior t \u2208 \ud835\udcdd x\u2081 \u00d7\u1da0 \ud835\udcdd x\u2082,\n    by rwa [nhds_prod_eq, le_principal_iff] at this,\n  let \u27e8m\u2081, hm\u2081, m\u2082, hm\u2082, (hm : set.prod m\u2081 m\u2082 \u2286 interior t)\u27e9 := mem_prod_iff.mp this in\n  let \u27e8a, ha\u2081, _, ha\u2082\u27e9 := h_pnt hm\u2081 in\n  let \u27e8b, hb\u2081, hb\u2082, _\u27e9 := h_pnt hm\u2082 in\n  have set.prod (preimage e m\u2081) (preimage e m\u2082) \u2286 preimage (\u03bbp:(\u03b2\u00d7\u03b2), (f p.1, f p.2)) s,\n    from calc _ \u2286 preimage (\u03bbp:(\u03b2\u00d7\u03b2), (e p.1, e p.2)) (interior t) : preimage_mono hm\n    ... \u2286 preimage (\u03bbp:(\u03b2\u00d7\u03b2), (e p.1, e p.2)) t : preimage_mono interior_subset\n    ... \u2286 preimage (\u03bbp:(\u03b2\u00d7\u03b2), (f p.1, f p.2)) s : ts,\n  have set.prod (f '' preimage e m\u2081) (f '' preimage e m\u2082) \u2286 s,\n    from calc set.prod (f '' preimage e m\u2081) (f '' preimage e m\u2082) =\n      (\u03bbp:(\u03b2\u00d7\u03b2), (f p.1, f p.2)) '' (set.prod (preimage e m\u2081) (preimage e m\u2082)) : prod_image_image_eq\n    ... \u2286 (\u03bbp:(\u03b2\u00d7\u03b2), (f p.1, f p.2)) '' preimage (\u03bbp:(\u03b2\u00d7\u03b2), (f p.1, f p.2)) s : monotone_image this\n    ... \u2286 s : image_subset_iff.mpr $ subset.refl _,\n  have (a, b) \u2208 s, from @this (a, b) \u27e8ha\u2081, hb\u2081\u27e9,\n  hs_comp $ show (\u03c8 x\u2081, \u03c8 x\u2082) \u2208 comp_rel s (comp_rel s s),\n    from \u27e8a, ha\u2082, \u27e8b, this, hb\u2082\u27e9\u27e9\n\nomit h_f\n\nvariables [separated_space \u03b3]\n\nlemma uniformly_extend_of_ind (b : \u03b2) : \u03c8 (e b) = f b :=\ndense_inducing.extend_eq_at _ h_f.continuous.continuous_at\n\nlemma uniformly_extend_unique {g : \u03b1 \u2192 \u03b3} (hg : \u2200 b, g (e b) = f b)\n  (hc : continuous g) :\n  \u03c8 = 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\u1d62 u\u1d62\n\nopen classical\n\nnamespace category\n\ndef is_product {C : Type u} [category.{v} C] {I : Type u\u1d62} (f : I \u2192 C) : \n  (\u03a3 p : C, \u03a0 i : I, Mor p (f i)) \u2192 Prop \n| \u27e8p,j\u27e9 := \u2200 pair : (\u03a3 p : C, \u03a0 i : I, Mor p (f i)), \u2203! \u03c6 : Mor pair.1 p, \u2200 i : I, pair.2 i = (j i) \u2218\u2098 \u03c6\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\u1d62} {f : I \u2192 C} \n  {prod :\u03a3 p : C, \u03a0 i : I, Mor p (f i)} : is_product f prod \u2192 \n  \u2200 pair : (\u03a3 p : C, \u03a0 i : I, Mor p (f i)), \u2203! \u03c6 : Mor pair.1 prod.1, \n  \u2200 i : I, pair.2 i = (prod.2 i) \u2218\u2098 \u03c6 :=\nbegin\n  intro hprod,\n  have hrw : prod = \u27e8prod.1,prod.2\u27e9,\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} {\u03b2 : I \u2192 Type u} \n  : is_product \u03b2 \u27e8\u03a0 i, \u03b2 i, \u03bb i f, f i\u27e9 :=\nbegin\n  intro pair,\n  cases pair with p' j',\n  dsimp,\n  existsi  \u03bb x : p', \u03bb i : I, j' i x,\n  dsimp,\n  split,\n  intro i,\n  refl,\n  intros \u03c8 h\u03c8,\n  apply funext,\n  intro a,\n  apply funext,\n  intro i,\n  rw h\u03c8,\n  rw set_comp_app,\nend\n\ntheorem product_essentially_unquie {C : Type u} [category.{v} C] {I : Type u\u1d62} {f : I \u2192 C} \n  {p\u2081 p\u2082 :(\u03a3 p : C, \u03a0 i : I, Mor p (f i))} : is_product f p\u2081 \u2192 is_product f p\u2082 \n  \u2192 \u2203! \u03c6 : Mor p\u2081.1 p\u2082.1, isomorphism \u03c6 \u2227 (\u2200 i : I, p\u2081.2 i = (p\u2082.2 i) \u2218\u2098 \u03c6 ):=\nbegin\n  intros hp\u2081 hp\u2082,\n  cases p\u2081 with p\u2081 j\u2081,\n  cases p\u2082 with p\u2082 j\u2082,\n  cases hp\u2082 \u27e8p\u2081,j\u2081\u27e9 with \u03c6\u2081 h\u03c6\u2081,\n  cases hp\u2081 \u27e8p\u2082,j\u2082\u27e9 with \u03c6\u2082 h\u03c6\u2082,\n  cases hp\u2081 \u27e8p\u2081, \u03bb i, (j\u2082 i) \u2218\u2098 \u03c6\u2081\u27e9 with id\u2081 hid\u2081,\n  cases hp\u2082 \u27e8p\u2082, \u03bb i, (j\u2081 i) \u2218\u2098 \u03c6\u2082\u27e9 with id\u2082 hid\u2082,\n  dsimp at h\u03c6\u2081,\n  dsimp at h\u03c6\u2082,\n  dsimp at hid\u2081,\n  dsimp at hid\u2082,\n  cases h\u03c6\u2081 with h\u03c6\u2081 u\u03c6\u2081,\n  cases h\u03c6\u2082 with h\u03c6\u2082 u\u03c6\u2082,\n  cases hid\u2081 with hid\u2081 uid\u2081,\n  cases hid\u2082 with hid\u2082 uid\u2082,\n  have hrw\u2081 : id\u2098 p\u2081 = id\u2081,\n    apply uid\u2081,\n    simp [id_comp_right,\u2190 h\u03c6\u2081],\n  have hrw\u2082 : id\u2098 p\u2082 = id\u2082,\n    apply uid\u2082,\n    simp [id_comp_right,\u2190 h\u03c6\u2082],\n  existsi \u03c6\u2081,\n  dsimp,\n  split,\n  split,\n  existsi \u03c6\u2082,\n  rw [hrw\u2081,hrw\u2082],\n  split,\n  apply uid\u2082,\n  simp [comp_assoc,h\u03c6\u2081],\n  apply uid\u2081,\n  simp [comp_assoc,h\u03c6\u2082],\n  exact h\u03c6\u2081,\n  intros \u03c6 h\u03c6,\n  apply u\u03c6\u2081,\n  exact h\u03c6.2,\nend\n\nnoncomputable def prod_can_iso {C : Type u} [category.{v} C] {I : Type u\u1d62} {f : I \u2192 C} \n  {p\u2081 p\u2082 :(\u03a3 p : C, \u03a0 i : I, Mor p (f i))} : is_product f p\u2081 \u2192 is_product f p\u2082 \n  \u2192 Mor p\u2081.1 p\u2082.1 := \u03bb hp\u2081 hp\u2082, some (product_essentially_unquie hp\u2081 hp\u2082)\n\ntheorem prod_can_iso_property {C : Type u} [category.{v} C] {I : Type u\u1d62} {f : I \u2192 C} \n  {p\u2081 p\u2082 : (\u03a3 p : C, \u03a0 i : I, Mor p (f i))} : \u03a0 (hp\u2081 : is_product f p\u2081) (hp\u2082 : is_product f p\u2082),\n  (isomorphism (prod_can_iso hp\u2081 hp\u2082) \u2227 ( \u03a0 i : I, p\u2081.2 i = p\u2082.2 i \u2218\u2098 (prod_can_iso hp\u2081 hp\u2082))) \n  \u2227 (\u2200 \u03c6 : Mor p\u2081.1 p\u2082.1, ((isomorphism \u03c6 \u2227 ( \u03a0 i : I, p\u2081.2 i = p\u2082.2 i \u2218\u2098 \u03c6)) \n  \u2192 \u03c6 = prod_can_iso hp\u2081 hp\u2082)) := \u03bb hp\u2081 hp\u2082, some_spec (product_essentially_unquie hp\u2081 hp\u2082)\n\nclass has_products (C : Type u) [category.{v} C] :=\n(all_products_exist : \u2200 {I : Type u\u1d62} (f : I \u2192 C) , \u2203 p : (\u03a3 p : C, \u03a0 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\u1d62} C] {I : Type u\u1d62} \n  (f : I \u2192 C) : (\u03a3 p : C, \u03a0 i : I, Mor p (f i)) := some (has_products.all_products_exist f) \n\nprefix `\u03a0\u2080`:110 := product\n\ntheorem has_product_prod_is_prod {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] {I : Type u\u1d62} \n  (f : I \u2192 C) : is_product f (\u03a0\u2080 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\u1d62} C] {I : Type u\u1d62} \n  {f : I \u2192 C} {A : C} (g : \u03a0 i : I, Mor A (f i)) \n  : Mor A (\u03a0\u2080 f).1 := some (is_product_fn (has_product_prod_is_prod f) \u27e8A,g\u27e9)\n\ntheorem into_product_property {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] {I : Type u\u1d62} \n  {f : I \u2192 C} {A : C} (g : \u03a0 i : I, Mor A (f i)) : (\u2200 i : I, g i = ((\u03a0\u2080f).2 i) \u2218\u2098 (into_product g)) \u2227 \n  \u2200 \u03c6 : Mor A (\u03a0\u2080f).1, (\u2200 i, g i = ((\u03a0\u2080f).2 i) \u2218\u2098 \u03c6) \u2192 \u03c6 = into_product g \n  := some_spec (is_product_fn (has_product_prod_is_prod f) \u27e8A,g\u27e9)\n\ntheorem into_product_property_comp {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] {I : Type u\u1d62} \n  {f : I \u2192 C} {A : C} (g : \u03a0 i : I, Mor A (f i)) : \u2200 i : I, g i = ((\u03a0\u2080f).2 i) \u2218\u2098 (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\u1d62} C] \n  {I : Type u\u1d62} {f : I \u2192 C} {A : C} (g : \u03a0 i : I, Mor A (f i)) \n  : \u2200 \u03c6 : Mor A (\u03a0\u2080f).1, (\u2200 i, g i = ((\u03a0\u2080f).2 i) \u2218\u2098 \u03c6) \u2192 \u03c6 = 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\u1d62} C] {I J : Type u\u1d62} \n  (f : I \u2192 J \u2192 C) : is_product (function.uncurry f) \u27e8(\u03a0\u2080 (\u03bb i : I,(\u03a0\u2080 (\u03bb j : J,f i j)).1)).1, \n  \u03bb ij : I \u00d7 J, (\u03a0\u2080 (\u03bb k : J, f ij.1 k)).2 ij.2 \u2218\u2098 (\u03a0\u2080 (\u03bb i : I,(\u03a0\u2080 (\u03bb j : J,f i j)).1)).2 ij.1\u27e9 := \nbegin\n  simp[is_product],\n  intro,\n  cases pair with p g,\n  let \u03c6 : Mor p (\u03a0\u2080 (\u03bb i : I,(\u03a0\u2080 (\u03bb 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 \u03c6,\n  simp[\u03c6],\n  split,\n  intro ij,\n  cases ij with i j,\n  rw \u2190 comp_assoc,\n  simp[\u2190 into_product_property_comp],\n  intros \u03c8 h\u03c8,\n  apply into_product_property_up,\n  intro i,\n  symmetry,\n  apply into_product_property_up,\n  intro j,\n  rw h\u03c8 (i,j),\n  rw comp_assoc,\nend\n\ntheorem double_prod_prod_right {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] {I J : Type u\u1d62} \n  (f : I \u2192 J \u2192 C) : is_product (function.uncurry f) \u27e8(\u03a0\u2080 (\u03bb j : J ,(\u03a0\u2080 (\u03bb i : I,f i j)).1)).1, \n  \u03bb ij : I \u00d7 J, (\u03a0\u2080 (\u03bb k : I, f k ij.2)).2 ij.1 \u2218\u2098 (\u03a0\u2080 (\u03bb j : J ,(\u03a0\u2080 (\u03bb i : I,f i j)).1)).2 ij.2\u27e9 := \nbegin\n  simp[is_product],\n  intro,\n  cases pair with p g,\n  let \u03c6 : Mor p (\u03a0\u2080 (\u03bb j : J,(\u03a0\u2080 (\u03bb 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 \u03c6,\n  simp[\u03c6],\n  split,\n  intro ij,\n  cases ij with i j,\n  rw \u2190 comp_assoc,\n  simp[\u2190 into_product_property_comp],\n  intros \u03c8 h\u03c8,\n  apply into_product_property_up,\n  intro j,\n  symmetry,\n  apply into_product_property_up,\n  intro i,\n  rw h\u03c8 (i,j),\n  rw comp_assoc,\nend\n\ntheorem product_of_morphisms_exist {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] {I : Type u\u1d62} \n  {f\u2081 f\u2082 : I \u2192 C} (\u03c6 : \u03a0 i : I, Mor (f\u2081 i) (f\u2082 i)) : \u2203! \u03c8 : Mor (\u03a0\u2080 f\u2081).1 (\u03a0\u2080 f\u2082).1, \u2200 i : I,\n  (\u03a0\u2080 f\u2082).2 i \u2218\u2098 \u03c8 = \u03c6 i \u2218\u2098 (\u03a0\u2080 f\u2081).2 i :=\nbegin\n  let \u03c8 : Mor (\u03a0\u2080 f\u2081).1 (\u03a0\u2080 f\u2082).1,\n    apply into_product,\n    intro i,\n    exact \u03c6 i \u2218\u2098 (\u03a0\u2080 f\u2081).2 i,\n  existsi \u03c8,\n  simp[\u03c8], \n  split,\n  simp[\u2190 into_product_property_comp],\n  intros \u03d5 h\u03d5,\n  apply into_product_property_up,\n  simp [h\u03d5],\nend\n\nnoncomputable def product_of_morphisms {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] \n  {I : Type u\u1d62} {f\u2081 f\u2082 : I \u2192 C} (\u03c6 : \u03a0 i : I, Mor (f\u2081 i) (f\u2082 i)) : Mor (\u03a0\u2080f\u2081).1 (\u03a0\u2080f\u2082).1 := \n  some (product_of_morphisms_exist \u03c6)\n\nprefix `\u03a0\u2098`:110 := product_of_morphisms\n\ntheorem product_of_morphisms_property {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] \n  {I : Type u\u1d62} {f\u2081 f\u2082 : I \u2192 C} (\u03c6 : \u03a0 i : I, Mor (f\u2081 i) (f\u2082 i))\n  : (\u2200 i : I, (\u03a0\u2080 f\u2082).2 i \u2218\u2098 \u03a0\u2098 \u03c6 = \u03c6 i \u2218\u2098 (\u03a0\u2080 f\u2081).2 i) \u2227 (\u2200 \u03c8 : Mor (\u03a0\u2080f\u2081).1 (\u03a0\u2080f\u2082).1,\n  (\u2200 i : I, (\u03a0\u2080 f\u2082).2 i \u2218\u2098 \u03c8  = \u03c6 i \u2218\u2098 (\u03a0\u2080 f\u2081).2 i) \u2192 \u03c8 = \u03a0\u2098 \u03c6) \n  := some_spec (product_of_morphisms_exist \u03c6)\n\ntheorem product_of_morphisms_property_comp {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] \n  {I : Type u\u1d62} {f\u2081 f\u2082 : I \u2192 C} (\u03c6 : \u03a0 i : I, Mor (f\u2081 i) (f\u2082 i))\n  : \u2200 i : I, (\u03a0\u2080 f\u2082).2 i \u2218\u2098 \u03a0\u2098 \u03c6 = \u03c6 i \u2218\u2098 (\u03a0\u2080 f\u2081).2 i := (product_of_morphisms_property \u03c6).1\n\ntheorem product_of_morphisms_property_up {C : Type u} [category.{v} C] [has_products.{v u u\u1d62} C] \n  {I : Type u\u1d62} {f\u2081 f\u2082 : I \u2192 C} (\u03c6 : \u03a0 i : I, Mor (f\u2081 i) (f\u2082 i))\n  : \u2200 \u03c8 : Mor (\u03a0\u2080f\u2081).1 (\u03a0\u2080f\u2082).1, (\u2200 i : I, (\u03a0\u2080 f\u2082).2 i \u2218\u2098 \u03c8  = \u03c6 i \u2218\u2098 (\u03a0\u2080 f\u2081).2 i) \n  \u2192 \u03c8 = \u03a0\u2098 \u03c6 := (product_of_morphisms_property \u03c6).2\n\ndef is_equaliser {C : Type u} [category.{v} C] {A B : C} (f\u2081 f\u2082 : Mor A B) : (\u03a3 E, Mor E A) \u2192 Prop \n| \u27e8E,f\u27e9 := f\u2081 \u2218\u2098 f = f\u2082 \u2218\u2098 f \u2227 \u2200 p : (\u03a3 E, Mor E A), f\u2081 \u2218\u2098 p.2 = f\u2082 \u2218\u2098 p.2 \n  \u2192 \u2203! \u03c6 : Mor p.1 E, p.2 = f \u2218\u2098 \u03c6\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  \u2203E: Class, \u2200z: Class,\n    (z \u2208 E \u2194 \u2203x y: Class, \u2203_: Set x, \u2203_: Set y,\n      \u2203_:x \u2208 y,\n        z \uff1d \uff1cx, y\uff1e)\n\n-- class E\nnoncomputable def E: Class := choose AxiomMembership\nnoncomputable def E_def:\n  \u2200z: Class,\n    (z \u2208 E \u2194 \u2203x y: Class, \u2203_: Set x, \u2203_: Set y,\n      \u2203_:x \u2208 y,\n        z \uff1d \uff1cx, y\uff1e) :=\n  choose_spec AxiomMembership\n\ntheorem EIsRelation:\n  isRelation E := by {\n  intro z h;\n  have \u27e8x,y,hx,hy,_,heq\u27e9 := (E_def z).1 h;\n  exact \u27e8x,y,hx,hy,heq\u27e9;\n}\n\ntheorem DomEEqUniv : (Dom E) \uff1d 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 \uff1d x := choose_spec h4;\n    exact ClassEqMenberImpMenber heq set_x.2;\n  }\n  {\n    intro h;\n    have set_z := Set.mk\u2082 h;\n    let y := Singleton_mk z;\n    have hy :=Singleton_def z;\n    have set_y := Set.mk\u2082 hy.1;\n    have z_in_y : z \u2208 y := (hy.2 z).2 (ClassEq.refl _);\n    have hin := (E_def \uff1cz,y\uff1e).2 \u27e8z,y,set_z,set_y,z_in_y,ClassEq.refl _\u27e9\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  \u2203Im: Class.{u}, \u2200z: Class,\n    ((z \u2208 Im)\n      \u2194 (\u2203x y: Class, \u2203_: Set y, \u2203(hx:x \u2208 X), \u2203(_:(@OrdPair_mk x y (Set.mk\u2081 hx) _)\u2208 R),\n        z \uff1d y)) := by {\n  have : Relation (R \u2229 (X \u2715 U)) :=\n    \u27e8fun z h => (hR.1 z) ((IntersectionClass_def R (X \u2715 U) z).1 h).1\u27e9;\n  let im := Rng (R \u2229 (X \u2715 U));\n  let im_def := Rng_def (R \u2229 (X \u2715 U));\n  have inter_def := IntersectionClass_def R (X \u2715 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 \u27e8x,y,set_x,set_y,hin,heq\u27e9 := (im_def z).1 h;\n    have h1 := (inter_def \uff1cx, y\uff1e).1 hin;\n    have \u27e8x2,y2,set_x2,set_y2,heq2\u27e9 := (rel_def \uff1cx, y\uff1e) h1.1;\n    have \u27e8x3,y3,hx3,hy3,heq3\u27e9 := (prod_def \uff1cx, y\uff1e).1 h1.2;\n    have set_x3 := Set.mk\u2081 hx3;\n    have set_y3 := Set.mk\u2081 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 \u27e8ClassEq.refl _,ClassEq.refl _\u27e9) h1.1;\n  }\n  {\n    intro \u27e8x,y,set_y,x_in_X,xy_in_R,heq\u27e9;\n    have set_x := Set.mk\u2081 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 \uff1cx,y\uff1e).2 \u27e8x,y,x_in_X,set_y.2,(OrdPairEq.2 \u27e8ClassEq.refl _,ClassEq.refl _\u27e9)\u27e9;\n    have h3 := (inter_def \uff1cx,y\uff1e).2 \u27e8xy_in_R,h2\u27e9;\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  \u2200z: Class,\n      ((z \u2208 (Im R X))\n        \u2194 (\u2203x y: Class, \u2203_: Set y, \u2203(hx:x \u2208 X), \u2203(_:(@OrdPair_mk x y (Set.mk\u2081 hx) _)\u2208 R),\n          z \uff1d y)) :=\n  choose_spec (ImageClassExists R X)\n\ntheorem PreImageClassExists (R X: Class) [Relation R]:\n  \u2203PreIm: Class, \u2200z: Class,\n    ((z \u2208 PreIm)\n      \u2194 (\u2203x y: Class, \u2203_: Set y, \u2203(hx:x \u2208 X), \u2203(_:(@OrdPair_mk x y (Set.mk\u2081 hx) _) \u2208 (RelInv R)),\n        z \uff1d y)) :=\n  @ImageClassExists (RelInv R) X \u27e8RelInvRelationIsRelation\u27e9\n\n\nnoncomputable def Apply (F x: Class) {h: x \u2208 (Dom F)} : Class :=\n  choose (choose_spec ((Dom_def F x).1 h))\nnoncomputable def Apply_def (F x: Class) {h: x \u2208 (Dom F)} :=\n  choose_spec ((Dom_def F x).1 h)\nnoncomputable def TargetIsSet (F x: Class) {h: x \u2208 (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 \u2208 (Dom F)} :\n  (@OrdPair_mk x (@Apply F x h) (Set.mk\u2081 h) (TargetIsSet F x)) \u2208 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 : \uff1cu,v\uff1e \u2208 F := choose h4;\n  have heq_x : x \uff1d u := choose_spec h4;\n  let y := @Apply F x h;\n  have heq_y: y \uff1d v := ClassEq.refl _;\n  have set_x := Set.mk\u2081 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 \u27e8heq_x,heq_y\u27e9;\n}\ntheorem ApplyFunctionUniqueTarget (F x x': Class) [set_x:Set x] [set_x':Set x']\n    {hx: x \u2208 (Dom F)} {hx': x' \u2208 (Dom F)} [hF: Function F]:\n      x \uff1d x' \u2192  @Apply F x hx \uff1d @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: \uff1cx, y\uff1e \u2208 F \u2192 \uff1cx', y'\uff1e \u2208 F\n    \u2192 x \uff1d x' \u2192 y \uff1d y' :=\n    hF.2 x x' y y' set_x set_x' set_y set_y';\n  have hxy: \uff1cx, y\uff1e \u2208 F := @SourceTargetPairIsIn F x hx;\n  have hxy': \uff1cx', y'\uff1e \u2208 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 \u2208 Dom F}: Class := by\nexact (@Apply F x h)\nnotation F\"\u3010\"x\"\u3011\" => 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 \u2208 (Dom F)} [hF: Function F]:\n  Im F x \uff1d @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 \u2229 (X \u2715 U)\ninfix:50 \" \u21be \"  => Restriction\n\n-- UnionAll\nnoncomputable def UnionAll_mk' (X : Class) :=\n  Dom (E \u2229 (U \u2715 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\u2082 E) \u2229 (U \u2715 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) \u2229 (U \u2715 (Diff U X))))\n\ntheorem PowerClassExists (X : Class):\n  \u2203PX: Class,\n    \u2200z: Class, \u2200_: Set z,\n      z \u2208 PX \u2194 (z \u2282 X) := by {\n  let px := Diff U (Dom ((RelInv E) \u2229 (U \u2715 (Diff U X))));\n  have px_def := Diff_def U (Dom ((RelInv E) \u2229 (U \u2715 (Diff U X))));\n  have dom_def := Dom_def ((RelInv E) \u2229 (U \u2715 (Diff U X)));\n  have inter_def := IntersectionClass_def (RelInv E) (U \u2715 (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\u2081 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 \uff1cz,u\uff1e)).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 \uff1cz,u\uff1e)).2 h3) u) z) set_u) set_z)) (IffNotNot.symm.2 (ClassEq.refl _));\n      have := (E_def \uff1cu,z\uff1e).2;\n      have h5 := (\n        ExistsIffNotForall.1 (\n          ExistsIffNotForall.1 (\n            ExistsIffNotForall.1 (\n              ExistsIffNotForall.1 (\n                ExistsIffNotForall.1 (\n                  (IffIffNotIffNot.1 (E_def \uff1cu,z\uff1e)).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 \u2208 Diff U X) (\u00ac\uff1cz,u\uff1e \uff1d \uff1cz,u\uff1e)).1 (\n        ExistsIffNotForall.1 (\n          ExistsIffNotForall.1 (\n            ExistsIffNotForall.1 (\n              ExistsIffNotForall.1 (\n                (IffIffNotIffNot.1 (prod_def \uff1cz,u\uff1e)).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 \u27e8z1,u,set_z1,set_u,hin1,heq1\u27e9 := (dom_def z).1 hn;\n      have h1 := (inter_def \uff1cz1,u\uff1e).1 hin1;\n      have \u27e8u2,z2,set_u2,set_z2,hin2,heq2\u27e9 := (rel_inv_def \uff1cz1,u\uff1e).1 h1.1;\n      have \u27e8u3,z3,hu3,hz3,hin3,heq3\u27e9 := (E_def \uff1cu2,z2\uff1e).1 hin2;\n\n      have \u27e8z4,u4,hz4,hu4,heq4\u27e9 := (prod_def \uff1cz1,u\uff1e).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\u2082 hz4;\n      have set_u4 := Set.mk\u2081 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 \u2208 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 : \u00ac u \u2208 X := @RewiteClass (fun u => \u00ac u \u2208 X) u u4 \u27e8heq4.2,h3.2\u27e9;\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  \u2200z: Class, \u2200_: Set z,\n    z \u2208 \ud835\udcab X \u2194 (z \u2282 X) :=\n  choose_spec (PowerClassExists X)\ndef isPowerClass (PX : Class) :=\n  \u2203(X: Class), \u2200(Y: Class), \u2200(_: Set Y), Y \u2208 PX \u2194 Y \u2282 X\nclass PowerClass (PX : Class) where\n  isPowerClass: isPowerClass PX\n\ntheorem PowerClass_def'_is_PowerClass {X: Class}:\n  isPowerClass (\ud835\udcab X) := \u27e8X, PowerClass_def X\u27e9\n\ntheorem UnivIsClosedPowerSet:\n  U \uff1d \ud835\udcab U := by {\n  rw [AxiomExtensionality];\n  intro z;\n  apply Iff.intro;\n  {\n    intro h;\n    rw [PowerClass_def U z (Set.mk\u2081 h)];\n    exact AllSetSubsetU z;\n  }\n  {exact fun h => (Set.mk\u2081 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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) :=\n  \u2200 (s : finset \u03b9) (w : \u03b9 \u2192 k),\n    (finset.sum s fun (i : \u03b9) => w i) = 0 \u2192 coe_fn (finset.weighted_vsub s p) w = 0 \u2192 \u2200 (i : \u03b9), i \u2208 s \u2192 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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) : affine_independent k p \u2194\n  \u2200 (s : finset \u03b9) (w : \u03b9 \u2192 k),\n    (finset.sum s fun (i : \u03b9) => w i) = 0 \u2192 coe_fn (finset.weighted_vsub s p) w = 0 \u2192 \u2200 (i : \u03b9), i \u2208 s \u2192 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] {\u03b9 : Type u_4} [subsingleton \u03b9] (p : \u03b9 \u2192 P) : affine_independent k p :=\n  fun (s : finset \u03b9) (w : \u03b9 \u2192 k) (h : (finset.sum s fun (i : \u03b9) => w i) = 0)\n    (hs : coe_fn (finset.weighted_vsub s p) w = 0) (i : \u03b9) (hi : i \u2208 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] {\u03b9 : Type u_4} [fintype \u03b9] (p : \u03b9 \u2192 P) : affine_independent k p \u2194\n  \u2200 (w : \u03b9 \u2192 k),\n    (finset.sum finset.univ fun (i : \u03b9) => w i) = 0 \u2192\n      coe_fn (finset.weighted_vsub finset.univ p) w = 0 \u2192 \u2200 (i : \u03b9), 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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) (i1 : \u03b9) : affine_independent k p \u2194 linear_independent k fun (i : Subtype fun (x : \u03b9) => x \u2260 i1) => p \u2191i -\u1d65 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\u2081 : P} (hp\u2081 : p\u2081 \u2208 s) : (affine_independent k fun (p : \u21a5s) => \u2191p) \u2194\n  linear_independent k fun (v : \u21a5((fun (p : P) => p -\u1d65 p\u2081) '' (s \\ singleton p\u2081))) => \u2191v := sorry\n\n/-- A set of nonzero vectors is linearly independent if and only if,\ngiven a point `p\u2081`, the vectors added to `p\u2081` and `p\u2081` 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 : \u2200 (v : V), v \u2208 s \u2192 v \u2260 0) (p\u2081 : P) : (linear_independent k fun (v : \u21a5s) => \u2191v) \u2194\n  affine_independent k fun (p : \u21a5(singleton p\u2081 \u222a (fun (v : V) => v +\u1d65 p\u2081) '' s)) => \u2191p := 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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) : affine_independent k p \u2194\n  \u2200 (s1 s2 : finset \u03b9) (w1 w2 : \u03b9 \u2192 k),\n    (finset.sum s1 fun (i : \u03b9) => w1 i) = 1 \u2192\n      (finset.sum s2 fun (i : \u03b9) => w2 i) = 1 \u2192\n        coe_fn (finset.affine_combination s1 p) w1 = coe_fn (finset.affine_combination s2 p) w2 \u2192\n          set.indicator (\u2191s1) w1 = set.indicator (\u2191s2) 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] {\u03b9 : Type u_4} [nontrivial k] {p : \u03b9 \u2192 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] {\u03b9 : Type u_4} {\u03b92 : Type u_5} (f : \u03b92 \u21aa \u03b9) {p : \u03b9 \u2192 P} (ha : affine_independent k p) : affine_independent k (p \u2218 \u21d1f) := 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] {\u03b9 : Type u_4} {p : \u03b9 \u2192 P} (ha : affine_independent k p) (s : set \u03b9) : affine_independent k fun (i : \u21a5s) => p \u2191i :=\n  affine_independent_embedding_of_affine_independent (function.embedding.subtype fun (x : \u03b9) => x \u2208 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] {\u03b9 : Type u_4} {p : \u03b9 \u2192 P} (ha : affine_independent k p) : affine_independent k fun (x : \u21a5(set.range p)) => \u2191x := 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 : \u21a5t) => \u2191x) (hs : s \u2286 t) : affine_independent k fun (x : \u21a5s) => \u2191x :=\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] {\u03b9 : Type u_4} {p : \u03b9 \u2192 P} (ha : affine_independent k fun (x : \u21a5(set.range p)) => \u2191x) (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] {\u03b9 : Type u_4} [nontrivial k] {p : \u03b9 \u2192 P} (ha : affine_independent k p) {s1 : set \u03b9} {s2 : set \u03b9} {p0 : P} (hp0s1 : p0 \u2208 affine_span k (p '' s1)) (hp0s2 : p0 \u2208 affine_span k (p '' s2)) : \u2203 (i : \u03b9), i \u2208 s1 \u2229 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] {\u03b9 : Type u_4} [nontrivial k] {p : \u03b9 \u2192 P} (ha : affine_independent k p) {s1 : set \u03b9} {s2 : set \u03b9} (hd : s1 \u2229 s2 = \u2205) : \u2191(affine_span k (p '' s1)) \u2229 \u2191(affine_span k (p '' s2)) = \u2205 := 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] {\u03b9 : Type u_4} [nontrivial k] {p : \u03b9 \u2192 P} (ha : affine_independent k p) (i : \u03b9) (s : set \u03b9) : p i \u2208 affine_span k (p '' s) \u2194 i \u2208 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] {\u03b9 : Type u_4} [nontrivial k] {p : \u03b9 \u2192 P} (ha : affine_independent k p) (i : \u03b9) (s : set \u03b9) : \u00acp i \u2208 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 : \u21a5s) => \u2191p) : \u2203 (t : set P), s \u2286 t \u2227 (affine_independent k fun (p : \u21a5t) => \u2191p) \u2227 affine_span k t = \u22a4 := 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\u2081 : P} {p\u2082 : P} (h : p\u2081 \u2260 p\u2082) : affine_independent k (matrix.vec_cons p\u2081 (matrix.vec_cons p\u2082 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 : \u2115) \nwhere\n  points : fin (n + 1) \u2192 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 : \u2115} {s1 : simplex k P n} {s2 : simplex k P n} (h : \u2200 (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 : \u2115} (s1 : simplex k P n) (s2 : simplex k P n) : s1 = s2 \u2194 \u2200 (i : fin (n + 1)), points s1 i = points s2 i :=\n  { mp := fun (h : s1 = s2) (_x : fin (n + 1)) => h \u25b8 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 : \u2115} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : \u2115} (h : finset.card fs = m + 1) : simplex k P m :=\n  mk (points s \u2218 \u21d1(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 : \u2115} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : \u2115} (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 : \u2115} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : \u2115} (h : finset.card fs = m + 1) : points (face s h) = points s \u2218 \u21d1(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 : \u2115} (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 : \u2115} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : \u2115} (h : finset.card fs = m + 1) : set.range (points (face s h)) = points s '' \u2191fs := 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 : \u2115} (s : simplex k P n) {fs : finset (fin (n + 1))} {m : \u2115} (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 : \u2115} (s : simplex k P n) {fs\u2081 : finset (fin (n + 1))} {fs\u2082 : finset (fin (n + 1))} {m\u2081 : \u2115} {m\u2082 : \u2115} (h\u2081 : finset.card fs\u2081 = m\u2081 + 1) (h\u2082 : finset.card fs\u2082 = m\u2082 + 1) : finset.centroid k fs\u2081 (points s) = finset.centroid k fs\u2082 (points s) \u2194 fs\u2081 = fs\u2082 := 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 : \u2115} (s : simplex k P n) {fs\u2081 : finset (fin (n + 1))} {fs\u2082 : finset (fin (n + 1))} {m\u2081 : \u2115} {m\u2082 : \u2115} (h\u2081 : finset.card fs\u2081 = m\u2081 + 1) (h\u2082 : finset.card fs\u2082 = m\u2082 + 1) : finset.centroid k finset.univ (points (face s h\u2081)) = finset.centroid k finset.univ (points (face s h\u2082)) \u2194 fs\u2081 = fs\u2082 := 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 : \u2115} {s\u2081 : simplex k P n} {s\u2082 : simplex k P n} (h : set.range (points s\u2081) = set.range (points s\u2082)) : finset.centroid k finset.univ (points s\u2081) = finset.centroid k finset.univ (points s\u2082) := 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 `\u03b1 \u2295 \u03b2`\n    and the sigma-type `\u03a3 b : bool, cond b \u03b1 \u03b2`;\n\n  - `equiv.prod_sum_distrib : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243 (\u03b1 \u00d7 \u03b2) \u2295 (\u03b1 \u00d7 \u03b3)` 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 : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082`: combine two equivalences `ea : \u03b1\u2081 \u2243 \u03b1\u2082` and\n    `eb : \u03b2\u2081 \u2243 \u03b2\u2082` 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 {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w}\n\nnamespace equiv\n\n/-- `pprod \u03b1 \u03b2` is equivalent to `\u03b1 \u00d7 \u03b2` -/\n@[simps apply symm_apply]\ndef pprod_equiv_prod {\u03b1 \u03b2 : Type*} : pprod \u03b1 \u03b2 \u2243 \u03b1 \u00d7 \u03b2 :=\n{ to_fun := \u03bb x, (x.1, x.2),\n  inv_fun := \u03bb x, \u27e8x.1, x.2\u27e9,\n  left_inv := \u03bb \u27e8x, y\u27e9, rfl,\n  right_inv := \u03bb \u27e8x, y\u27e9, rfl }\n\n/-- Product of two equivalences, in terms of `pprod`. If `\u03b1 \u2243 \u03b2` and `\u03b3 \u2243 \u03b4`, then\n`pprod \u03b1 \u03b3 \u2243 pprod \u03b2 \u03b4`. -/\n@[congr, simps apply]\ndef pprod_congr {\u03b4 : Sort z} (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b3 \u2243 \u03b4) : pprod \u03b1 \u03b3 \u2243 pprod \u03b2 \u03b4 :=\n{ to_fun := \u03bb x, \u27e8e\u2081 x.1, e\u2082 x.2\u27e9,\n  inv_fun := \u03bb x, \u27e8e\u2081.symm x.1, e\u2082.symm x.2\u27e9,\n  left_inv := \u03bb \u27e8x, y\u27e9, by simp,\n  right_inv := \u03bb \u27e8x, y\u27e9, 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 {\u03b1\u2081 \u03b2\u2081 : Sort*} {\u03b1\u2082 \u03b2\u2082 : Type*} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) :\n  pprod \u03b1\u2081 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082 :=\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 {\u03b1\u2081 \u03b2\u2081 : Type*} {\u03b1\u2082 \u03b2\u2082 : Sort*} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) :\n  \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 pprod \u03b1\u2082 \u03b2\u2082 :=\n(ea.symm.pprod_prod eb.symm).symm\n\n/-- `pprod \u03b1 \u03b2` is equivalent to `plift \u03b1 \u00d7 plift \u03b2` -/\n@[simps apply symm_apply]\ndef pprod_equiv_prod_plift {\u03b1 \u03b2 : Sort*} : pprod \u03b1 \u03b2 \u2243 plift \u03b1 \u00d7 plift \u03b2 :=\nequiv.plift.symm.pprod_prod equiv.plift.symm\n\n/-- Product of two equivalences. If `\u03b1\u2081 \u2243 \u03b1\u2082` and `\u03b2\u2081 \u2243 \u03b2\u2082`, then `\u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082`. This is\n`prod.map` as an equivalence. -/\n@[congr, simps apply { fully_applied := ff }]\ndef prod_congr {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Type*} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082 :=\n\u27e8prod.map e\u2081 e\u2082, prod.map e\u2081.symm e\u2082.symm, \u03bb \u27e8a, b\u27e9, by simp, \u03bb \u27e8a, b\u27e9, by simp\u27e9\n\n@[simp] theorem prod_congr_symm {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Type*} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) :\n  (prod_congr e\u2081 e\u2082).symm = prod_congr e\u2081.symm e\u2082.symm :=\nrfl\n\n/-- Type product is commutative up to an equivalence: `\u03b1 \u00d7 \u03b2 \u2243 \u03b2 \u00d7 \u03b1`. This is `prod.swap` as an\nequivalence.-/\ndef prod_comm (\u03b1 \u03b2 : Type*) : \u03b1 \u00d7 \u03b2 \u2243 \u03b2 \u00d7 \u03b1 :=\n\u27e8prod.swap, prod.swap, prod.swap_swap, prod.swap_swap\u27e9\n\n@[simp] lemma coe_prod_comm (\u03b1 \u03b2 : Type*) : \u21d1(prod_comm \u03b1 \u03b2) = prod.swap := rfl\n@[simp] lemma prod_comm_apply {\u03b1 \u03b2 : Type*} (x : \u03b1 \u00d7 \u03b2) : prod_comm \u03b1 \u03b2 x = x.swap := rfl\n\n@[simp] lemma prod_comm_symm (\u03b1 \u03b2) : (prod_comm \u03b1 \u03b2).symm = prod_comm \u03b2 \u03b1 := rfl\n\n/-- Type product is associative up to an equivalence. -/\n@[simps] def prod_assoc (\u03b1 \u03b2 \u03b3 : Sort*) : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243 \u03b1 \u00d7 (\u03b2 \u00d7 \u03b3) :=\n\u27e8\u03bb p, (p.1.1, p.1.2, p.2), \u03bb p, ((p.1, p.2.1), p.2.2), \u03bb \u27e8\u27e8a, b\u27e9, c\u27e9, rfl, \u03bb \u27e8a, \u27e8b, c\u27e9\u27e9, rfl\u27e9\n\n/-- Functions on `\u03b1 \u00d7 \u03b2` are equivalent to functions `\u03b1 \u2192 \u03b2 \u2192 \u03b3`. -/\n@[simps {fully_applied := ff}] def curry (\u03b1 \u03b2 \u03b3 : Type*) :\n  (\u03b1 \u00d7 \u03b2 \u2192 \u03b3) \u2243 (\u03b1 \u2192 \u03b2 \u2192 \u03b3) :=\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 (\u03b1 : Type*) : \u03b1 \u00d7 punit.{u+1} \u2243 \u03b1 :=\n\u27e8\u03bb p, p.1, \u03bb a, (a, punit.star), \u03bb \u27e8_, punit.star\u27e9, rfl, \u03bb a, rfl\u27e9\n\n/-- `punit` is a left identity for type product up to an equivalence. -/\n@[simps] def punit_prod (\u03b1 : Type*) : punit.{u+1} \u00d7 \u03b1 \u2243 \u03b1 :=\ncalc punit \u00d7 \u03b1 \u2243 \u03b1 \u00d7 punit : prod_comm _ _\n           ... \u2243 \u03b1         : prod_punit _\n\n/-- Any `unique` type is a right identity for type product up to equivalence. -/\ndef prod_unique (\u03b1 \u03b2 : Type*) [unique \u03b2] : \u03b1 \u00d7 \u03b2 \u2243 \u03b1 :=\n((equiv.refl \u03b1).prod_congr $ equiv_punit \u03b2).trans $ prod_punit \u03b1\n\n@[simp] lemma coe_prod_unique {\u03b1 \u03b2 : Type*} [unique \u03b2] :\n  \u21d1(prod_unique \u03b1 \u03b2) = prod.fst := rfl\n\nlemma prod_unique_apply {\u03b1 \u03b2 : Type*} [unique \u03b2] (x : \u03b1 \u00d7 \u03b2) :\n  prod_unique \u03b1 \u03b2 x = x.1 := rfl\n\n@[simp] lemma prod_unique_symm_apply {\u03b1 \u03b2 : Type*} [unique \u03b2] (x : \u03b1) :\n  (prod_unique \u03b1 \u03b2).symm x = (x, default) := rfl\n\n/-- Any `unique` type is a left identity for type product up to equivalence. -/\ndef unique_prod (\u03b1 \u03b2 : Type*) [unique \u03b2] : \u03b2 \u00d7 \u03b1 \u2243 \u03b1 :=\n((equiv_punit \u03b2).prod_congr $ equiv.refl \u03b1).trans $ punit_prod \u03b1\n\n@[simp] lemma coe_unique_prod {\u03b1 \u03b2 : Type*} [unique \u03b2] :\n  \u21d1(unique_prod \u03b1 \u03b2) = prod.snd := rfl\n\nlemma unique_prod_apply {\u03b1 \u03b2 : Type*} [unique \u03b2] (x : \u03b2 \u00d7 \u03b1) :\n  unique_prod \u03b1 \u03b2 x = x.2 := rfl\n\n@[simp] lemma unique_prod_symm_apply {\u03b1 \u03b2 : Type*} [unique \u03b2] (x : \u03b1) :\n  (unique_prod \u03b1 \u03b2).symm x = (default, x) := rfl\n\n/-- `empty` type is a right absorbing element for type product up to an equivalence. -/\ndef prod_empty (\u03b1 : Type*) : \u03b1 \u00d7 empty \u2243 empty :=\nequiv_empty _\n\n/-- `empty` type is a left absorbing element for type product up to an equivalence. -/\ndef empty_prod (\u03b1 : Type*) : empty \u00d7 \u03b1 \u2243 empty :=\nequiv_empty _\n\n/-- `pempty` type is a right absorbing element for type product up to an equivalence. -/\ndef prod_pempty (\u03b1 : Type*) : \u03b1 \u00d7 pempty \u2243 pempty :=\nequiv_pempty _\n\n/-- `pempty` type is a left absorbing element for type product up to an equivalence. -/\ndef pempty_prod (\u03b1 : Type*) : pempty \u00d7 \u03b1 \u2243 pempty :=\nequiv_pempty _\nend\n\nsection\nopen sum\n\n/-- `psum` is equivalent to `sum`. -/\ndef psum_equiv_sum (\u03b1 \u03b2 : Type*) : psum \u03b1 \u03b2 \u2243 \u03b1 \u2295 \u03b2 :=\n{ to_fun := \u03bb s, psum.cases_on s inl inr,\n  inv_fun := sum.elim psum.inl psum.inr,\n  left_inv := \u03bb s, by cases s; refl,\n  right_inv := \u03bb s, by cases s; refl }\n\n/-- If `\u03b1 \u2243 \u03b1'` and `\u03b2 \u2243 \u03b2'`, then `\u03b1 \u2295 \u03b2 \u2243 \u03b1' \u2295 \u03b2'`. This is `sum.map` as an equivalence. -/\n@[simps apply]\ndef sum_congr {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Type*} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) : \u03b1\u2081 \u2295 \u03b2\u2081 \u2243 \u03b1\u2082 \u2295 \u03b2\u2082 :=\n\u27e8sum.map ea eb, sum.map ea.symm eb.symm, \u03bb x, by simp, \u03bb x, by simp\u27e9\n\n/-- If `\u03b1 \u2243 \u03b1'` and `\u03b2 \u2243 \u03b2'`, then `psum \u03b1 \u03b2 \u2243 psum \u03b1' \u03b2'`. -/\ndef psum_congr {\u03b4 : Sort z} (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b3 \u2243 \u03b4) : psum \u03b1 \u03b3 \u2243 psum \u03b2 \u03b4 :=\n{ to_fun := \u03bb x, psum.cases_on x (psum.inl \u2218 e\u2081) (psum.inr \u2218 e\u2082),\n  inv_fun := \u03bb x, psum.cases_on x (psum.inl \u2218 e\u2081.symm) (psum.inr \u2218 e\u2082.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 {\u03b1\u2081 \u03b2\u2081 : Sort*} {\u03b1\u2082 \u03b2\u2082 : Type*} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) : psum \u03b1\u2081 \u03b2\u2081 \u2243 \u03b1\u2082 \u2295 \u03b2\u2082 :=\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 {\u03b1\u2081 \u03b2\u2081 : Type*} {\u03b1\u2082 \u03b2\u2082 : Sort*} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) : \u03b1\u2081 \u2295 \u03b2\u2081 \u2243 psum \u03b1\u2082 \u03b2\u2082 :=\n(ea.symm.psum_sum eb.symm).symm\n\n@[simp] lemma sum_congr_trans {\u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 \u03b3\u2081 \u03b3\u2082 : Sort*}\n  (e : \u03b1\u2081 \u2243 \u03b2\u2081) (f : \u03b1\u2082 \u2243 \u03b2\u2082) (g : \u03b2\u2081 \u2243 \u03b3\u2081) (h : \u03b2\u2082 \u2243 \u03b3\u2082) :\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 {\u03b1 \u03b2 \u03b3 \u03b4 : Sort*} (e : \u03b1 \u2243 \u03b2) (f : \u03b3 \u2243 \u03b4) :\n  (equiv.sum_congr e f).symm = (equiv.sum_congr (e.symm) (f.symm)) :=\nrfl\n\n@[simp] lemma sum_congr_refl {\u03b1 \u03b2 : Sort*} :\n  equiv.sum_congr (equiv.refl \u03b1) (equiv.refl \u03b2) = equiv.refl (\u03b1 \u2295 \u03b2) :=\nby { ext i, cases i; refl }\n\nnamespace perm\n\n/-- Combine a permutation of `\u03b1` and of `\u03b2` into a permutation of `\u03b1 \u2295 \u03b2`. -/\n@[reducible]\ndef sum_congr {\u03b1 \u03b2 : Type*} (ea : equiv.perm \u03b1) (eb : equiv.perm \u03b2) : equiv.perm (\u03b1 \u2295 \u03b2) :=\nequiv.sum_congr ea eb\n\n@[simp] lemma sum_congr_apply {\u03b1 \u03b2 : Type*} (ea : equiv.perm \u03b1) (eb : equiv.perm \u03b2) (x : \u03b1 \u2295 \u03b2) :\n  sum_congr ea eb x = sum.map \u21d1ea \u21d1eb x := equiv.sum_congr_apply ea eb x\n\n@[simp] lemma sum_congr_trans {\u03b1 \u03b2 : Sort*}\n  (e : equiv.perm \u03b1) (f : equiv.perm \u03b2) (g : equiv.perm \u03b1) (h : equiv.perm \u03b2) :\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 {\u03b1 \u03b2 : Sort*} (e : equiv.perm \u03b1) (f : equiv.perm \u03b2) :\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 {\u03b1 \u03b2 : Sort*} :\n  sum_congr (equiv.refl \u03b1) (equiv.refl \u03b2) = equiv.refl (\u03b1 \u2295 \u03b2) :=\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 \u2243 punit.{u+1} \u2295 punit.{v+1} :=\n\u27e8\u03bb b, cond b (inr punit.star) (inl punit.star),\n sum.elim (\u03bb _, ff) (\u03bb _, tt),\n \u03bb b, by cases b; refl,\n \u03bb s, by rcases s with \u27e8\u27e8\u27e9\u27e9 | \u27e8\u27e8\u27e9\u27e9; refl\u27e9\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 (\u03b1 \u03b2 : Type*) : \u03b1 \u2295 \u03b2 \u2243 \u03b2 \u2295 \u03b1 :=\n\u27e8sum.swap, sum.swap, sum.swap_swap, sum.swap_swap\u27e9\n\n@[simp] lemma sum_comm_symm (\u03b1 \u03b2) : (sum_comm \u03b1 \u03b2).symm = sum_comm \u03b2 \u03b1 := rfl\n\n/-- Sum of types is associative up to an equivalence. -/\ndef sum_assoc (\u03b1 \u03b2 \u03b3 : Type*) : (\u03b1 \u2295 \u03b2) \u2295 \u03b3 \u2243 \u03b1 \u2295 (\u03b2 \u2295 \u03b3) :=\n\u27e8sum.elim (sum.elim sum.inl (sum.inr \u2218 sum.inl)) (sum.inr \u2218 sum.inr),\n  sum.elim (sum.inl \u2218 sum.inl) $ sum.elim (sum.inl \u2218 sum.inr) sum.inr,\n  by rintros (\u27e8_ | _\u27e9 | _); refl,\n  by rintros (_ | \u27e8_ | _\u27e9); refl\u27e9\n\n@[simp] lemma sum_assoc_apply_inl_inl {\u03b1 \u03b2 \u03b3} (a) : sum_assoc \u03b1 \u03b2 \u03b3 (inl (inl a)) = inl a := rfl\n\n@[simp] lemma sum_assoc_apply_inl_inr {\u03b1 \u03b2 \u03b3} (b) : sum_assoc \u03b1 \u03b2 \u03b3 (inl (inr b)) = inr (inl b) :=\nrfl\n\n@[simp] lemma sum_assoc_apply_inr {\u03b1 \u03b2 \u03b3} (c) : sum_assoc \u03b1 \u03b2 \u03b3 (inr c) = inr (inr c) := rfl\n\n@[simp] lemma sum_assoc_symm_apply_inl {\u03b1 \u03b2 \u03b3} (a) : (sum_assoc \u03b1 \u03b2 \u03b3).symm (inl a) = inl (inl a) :=\nrfl\n\n@[simp] lemma sum_assoc_symm_apply_inr_inl {\u03b1 \u03b2 \u03b3} (b) :\n  (sum_assoc \u03b1 \u03b2 \u03b3).symm (inr (inl b)) = inl (inr b) := rfl\n\n@[simp] lemma sum_assoc_symm_apply_inr_inr {\u03b1 \u03b2 \u03b3} (c) :\n  (sum_assoc \u03b1 \u03b2 \u03b3).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 (\u03b1 \u03b2 : Type*) [is_empty \u03b2] : \u03b1 \u2295 \u03b2 \u2243 \u03b1 :=\n\u27e8sum.elim id is_empty_elim,\n inl,\n \u03bb s, by { rcases s with _ | x, refl, exact is_empty_elim x },\n \u03bb a, rfl\u27e9\n\n@[simp] lemma sum_empty_apply_inl {\u03b1 \u03b2 : Type*} [is_empty \u03b2] (a : \u03b1) :\n  sum_empty \u03b1 \u03b2 (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 (\u03b1 \u03b2 : Type*) [is_empty \u03b1] : \u03b1 \u2295 \u03b2 \u2243 \u03b2 :=\n(sum_comm _ _).trans $ sum_empty _ _\n\n@[simp] lemma empty_sum_apply_inr {\u03b1 \u03b2 : Type*} [is_empty \u03b1] (b : \u03b2) :\n  empty_sum \u03b1 \u03b2 (sum.inr b) = b := rfl\n\n/-- `option \u03b1` is equivalent to `\u03b1 \u2295 punit` -/\ndef option_equiv_sum_punit (\u03b1 : Type*) : option \u03b1 \u2243 \u03b1 \u2295 punit.{u+1} :=\n\u27e8\u03bb o, o.elim (inr punit.star) inl,\n \u03bb s, s.elim some (\u03bb _, none),\n \u03bb o, by cases o; refl,\n \u03bb s, by rcases s with _ | \u27e8\u27e8\u27e9\u27e9; refl\u27e9\n\n@[simp] lemma option_equiv_sum_punit_none {\u03b1} :\n  option_equiv_sum_punit \u03b1 none = sum.inr punit.star := rfl\n@[simp] lemma option_equiv_sum_punit_some {\u03b1} (a) :\n  option_equiv_sum_punit \u03b1 (some a) = sum.inl a := rfl\n\n@[simp] lemma option_equiv_sum_punit_coe {\u03b1} (a : \u03b1) :\n  option_equiv_sum_punit \u03b1 a = sum.inl a := rfl\n\n@[simp] lemma option_equiv_sum_punit_symm_inl {\u03b1} (a) :\n  (option_equiv_sum_punit \u03b1).symm (sum.inl a) = a :=\nrfl\n\n@[simp] lemma option_equiv_sum_punit_symm_inr {\u03b1} (a) :\n  (option_equiv_sum_punit \u03b1).symm (sum.inr a) = none :=\nrfl\n\n/-- The set of `x : option \u03b1` such that `is_some x` is equivalent to `\u03b1`. -/\n@[simps] def option_is_some_equiv (\u03b1 : Type*) : {x : option \u03b1 // x.is_some} \u2243 \u03b1 :=\n{ to_fun := \u03bb o, option.get o.2,\n  inv_fun := \u03bb x, \u27e8some x, dec_trivial\u27e9,\n  left_inv := \u03bb o, subtype.eq $ option.some_get _,\n  right_inv := \u03bb x, option.get_some _ _ }\n\n/-- The product over `option \u03b1` of `\u03b2 a` is the binary product of the\nproduct over `\u03b1` of `\u03b2 (some \u03b1)` and `\u03b2 none` -/\n@[simps] def pi_option_equiv_prod {\u03b1 : Type*} {\u03b2 : option \u03b1 \u2192 Type*} :\n  (\u03a0 a : option \u03b1, \u03b2 a) \u2243 (\u03b2 none \u00d7 \u03a0 a : \u03b1, \u03b2 (some a)) :=\n{ to_fun := \u03bb f, (f none, \u03bb a, f (some a)),\n  inv_fun := \u03bb x a, option.cases_on a x.fst x.snd,\n  left_inv := \u03bb f, funext $ \u03bb a, by cases a; refl,\n  right_inv := \u03bb x, by simp }\n\n/-- `\u03b1 \u2295 \u03b2` is equivalent to a `sigma`-type over `bool`. Note that this definition assumes `\u03b1` and\n`\u03b2` 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 (\u03b1 \u03b2 : Type u) : \u03b1 \u2295 \u03b2 \u2243 (\u03a3 b: bool, cond b \u03b1 \u03b2) :=\n\u27e8\u03bb s, s.elim (\u03bb x, \u27e8tt, x\u27e9) (\u03bb x, \u27e8ff, x\u27e9),\n \u03bb s, match s with \u27e8tt, a\u27e9 := inl a | \u27e8ff, b\u27e9 := inr b end,\n \u03bb s, by cases s; refl,\n \u03bb s, by rcases s with \u27e8_|_, _\u27e9; refl\u27e9\n\n/-- `sigma_fiber_equiv f` for `f : \u03b1 \u2192 \u03b2` is the natural equivalence between\nthe type of all fibres of `f` and the total space `\u03b1`. -/\n-- See also `equiv.sigma_preimage_equiv`.\n@[simps]\ndef sigma_fiber_equiv {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) :\n  (\u03a3 y : \u03b2, {x // f x = y}) \u2243 \u03b1 :=\n\u27e8\u03bb x, \u2191x.2, \u03bb x, \u27e8f x, x, rfl\u27e9, \u03bb \u27e8y, x, rfl\u27e9, rfl, \u03bb x, rfl\u27e9\n\nend\n\nsection sum_compl\n\n/-- For any predicate `p` on `\u03b1`,\nthe sum of the two subtypes `{a // p a}` and its complement `{a // \u00ac p a}`\nis naturally equivalent to `\u03b1`.\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 {\u03b1 : Type*} (p : \u03b1 \u2192 Prop) [decidable_pred p] :\n  {a // p a} \u2295 {a // \u00ac p a} \u2243 \u03b1 :=\n{ to_fun := sum.elim coe coe,\n  inv_fun := \u03bb a, if h : p a then sum.inl \u27e8a, h\u27e9 else sum.inr \u27e8a, h\u27e9,\n  left_inv := by { rintros (\u27e8x,hx\u27e9|\u27e8x,hx\u27e9); dsimp; [rw dif_pos, rw dif_neg], },\n  right_inv := \u03bb a, by { dsimp, split_ifs; refl } }\n\n@[simp] lemma sum_compl_apply_inl {\u03b1 : Type*} (p : \u03b1 \u2192 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 {\u03b1 : Type*} (p : \u03b1 \u2192 Prop) [decidable_pred p]\n  (x : {a // \u00ac p a}) :\n  sum_compl p (sum.inr x) = x := rfl\n\n@[simp] lemma sum_compl_apply_symm_of_pos {\u03b1 : Type*} (p : \u03b1 \u2192 Prop) [decidable_pred p]\n  (a : \u03b1) (h : p a) :\n  (sum_compl p).symm a = sum.inl \u27e8a, h\u27e9 := dif_pos h\n\n@[simp] lemma sum_compl_apply_symm_of_neg {\u03b1 : Type*} (p : \u03b1 \u2192 Prop) [decidable_pred p]\n  (a : \u03b1) (h : \u00ac p a) :\n  (sum_compl p).symm a = sum.inr \u27e8a, h\u27e9 := 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 {\u03b1 : Type*} {p q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q]\n  (e : {x // p x} \u2243 {x // q x}) (f : {x // \u00acp x} \u2243 {x // \u00acq x}) : perm \u03b1 :=\n(sum_compl p).symm.trans ((sum_congr e f).trans\n  (sum_compl q))\n\nopen equiv\n\nvariables {\u03b5 : Type*} {p : \u03b5 \u2192 Prop} [decidable_pred p]\nvariables (ep ep' : perm {a // p a}) (en en' : perm {a // \u00ac p a})\n\n/-- Combining permutations on `\u03b5` that permute only inside or outside the subtype\nsplit induced by `p : \u03b5 \u2192 Prop` constructs a permutation on `\u03b5`. -/\ndef perm.subtype_congr : equiv.perm \u03b5 :=\nperm_congr (sum_compl p) (sum_congr ep en)\n\nlemma perm.subtype_congr.apply (a : \u03b5) :\n  ep.subtype_congr en a = if h : p a then ep \u27e8a, h\u27e9 else en \u27e8a, h\u27e9 :=\nby { by_cases h : p a; simp [perm.subtype_congr, h] }\n\n@[simp] lemma perm.subtype_congr.left_apply {a : \u03b5} (h : p a) :\n  ep.subtype_congr en a = ep \u27e8a, h\u27e9 :=\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 : \u03b5} (h : \u00ac p a) :\n  ep.subtype_congr en a = en \u27e8a, h\u27e9 :=\nby simp [perm.subtype_congr.apply, h]\n\n@[simp] lemma perm.subtype_congr.right_apply_subtype (a : {a // \u00ac 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 \u27e8x, h\u27e9) := subtype.property _,\n    simp [perm.subtype_congr.apply, h, symm_apply_eq, this] },\n  { have : \u00ac p (en.symm \u27e8x, h\u27e9) := 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 \u27e8x, h\u27e9) := subtype.property _,\n    simp [perm.subtype_congr.apply, h, this] },\n  { have : \u00ac p (en \u27e8x, h\u27e9) := 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 : \u03b1 \u2192 Prop) [decidable_pred p] (x\u2080 : {a // p a} \u2192 \u03b2)\n\n/-- For a fixed function `x\u2080 : {a // p a} \u2192 \u03b2` defined on a subtype of `\u03b1`,\nthe subtype of functions `x : \u03b1 \u2192 \u03b2` that agree with `x\u2080` on the subtype `{a // p a}`\nis naturally equivalent to the type of functions `{a // \u00ac p a} \u2192 \u03b2`. -/\n@[simps]\ndef subtype_preimage :\n  {x : \u03b1 \u2192 \u03b2 // x \u2218 coe = x\u2080} \u2243 ({a // \u00ac p a} \u2192 \u03b2) :=\n{ to_fun := \u03bb (x : {x : \u03b1 \u2192 \u03b2 // x \u2218 coe = x\u2080}) a, (x : \u03b1 \u2192 \u03b2) a,\n  inv_fun := \u03bb x, \u27e8\u03bb a, if h : p a then x\u2080 \u27e8a, h\u27e9 else x \u27e8a, h\u27e9,\n    funext $ \u03bb \u27e8a, h\u27e9, dif_pos h\u27e9,\n  left_inv := \u03bb \u27e8x, hx\u27e9, subtype.val_injective $ funext $ \u03bb a,\n    (by { dsimp, split_ifs; [ rw \u2190 hx, skip ]; refl }),\n  right_inv := \u03bb x, funext $ \u03bb \u27e8a, h\u27e9,\n    show dite (p a) _ _ = _, by { dsimp, rw [dif_neg h] } }\n\nlemma subtype_preimage_symm_apply_coe_pos (x : {a // \u00ac p a} \u2192 \u03b2) (a : \u03b1) (h : p a) :\n  ((subtype_preimage p x\u2080).symm x : \u03b1 \u2192 \u03b2) a = x\u2080 \u27e8a, h\u27e9 :=\ndif_pos h\n\nlemma subtype_preimage_symm_apply_coe_neg (x : {a // \u00ac p a} \u2192 \u03b2) (a : \u03b1) (h : \u00ac p a) :\n  ((subtype_preimage p x\u2080).symm x : \u03b1 \u2192 \u03b2) a = x \u27e8a, h\u27e9 :=\ndif_neg h\n\nend subtype_preimage\n\nsection\n\n/-- A family of equivalences `\u03a0 a, \u03b2\u2081 a \u2243 \u03b2\u2082 a` generates an equivalence between `\u03a0 a, \u03b2\u2081 a` and\n`\u03a0 a, \u03b2\u2082 a`. -/\ndef Pi_congr_right {\u03b1} {\u03b2\u2081 \u03b2\u2082 : \u03b1 \u2192 Sort*} (F : \u03a0 a, \u03b2\u2081 a \u2243 \u03b2\u2082 a) : (\u03a0 a, \u03b2\u2081 a) \u2243 (\u03a0 a, \u03b2\u2082 a) :=\n\u27e8\u03bb H a, F a (H a), \u03bb H a, (F a).symm (H a),\n \u03bb H, funext $ by simp, \u03bb H, funext $ by simp\u27e9\n\n/-- Given `\u03c6 : \u03b1 \u2192 \u03b2 \u2192 Sort*`, we have an equivalence between `\u03a0 a b, \u03c6 a b` and `\u03a0 b a, \u03c6 a b`.\nThis is `function.swap` as an `equiv`. -/\n@[simps apply]\ndef Pi_comm {\u03b1 \u03b2} (\u03c6 : \u03b1 \u2192 \u03b2 \u2192 Sort*) : (\u03a0 a b, \u03c6 a b) \u2243 (\u03a0 b a, \u03c6 a b) :=\n\u27e8swap, swap, \u03bb x, rfl, \u03bb y, rfl\u27e9\n\n@[simp] lemma Pi_comm_symm {\u03b1 \u03b2} {\u03c6 : \u03b1 \u2192 \u03b2 \u2192 Sort*} :\n  (Pi_comm \u03c6).symm = (Pi_comm $ swap \u03c6) :=\nrfl\n\n/-- Dependent `curry` equivalence: the type of dependent functions on `\u03a3 i, \u03b2 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 {\u03b1} {\u03b2 : \u03b1 \u2192 Sort*} (\u03b3 : \u03a0 a, \u03b2 a \u2192 Sort*) :\n  (\u03a0 x : \u03a3 i, \u03b2 i, \u03b3 x.1 x.2) \u2243 (\u03a0 a b, \u03b3 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 {\u03b1\u2081 \u03b2\u2081 \u03b2\u2082 : Type*} (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082)\n\n/-- A family of equivalences `\u03a0 (a : \u03b1\u2081), \u03b2\u2081 \u2243 \u03b2\u2082` generates an equivalence\nbetween `\u03b2\u2081 \u00d7 \u03b1\u2081` and `\u03b2\u2082 \u00d7 \u03b1\u2081`. -/\ndef prod_congr_left : \u03b2\u2081 \u00d7 \u03b1\u2081 \u2243 \u03b2\u2082 \u00d7 \u03b1\u2081 :=\n{ to_fun := \u03bb ab, \u27e8e ab.2 ab.1, ab.2\u27e9,\n  inv_fun := \u03bb ab, \u27e8(e ab.2).symm ab.1, ab.2\u27e9,\n  left_inv := by { rintros \u27e8a, b\u27e9, simp },\n  right_inv := by { rintros \u27e8a, b\u27e9, simp } }\n\n@[simp] lemma prod_congr_left_apply (b : \u03b2\u2081) (a : \u03b1\u2081) :\nprod_congr_left e (b, a) = (e a b, a) := rfl\n\nlemma prod_congr_refl_right (e : \u03b2\u2081 \u2243 \u03b2\u2082) :\n  prod_congr e (equiv.refl \u03b1\u2081) = prod_congr_left (\u03bb _, e) :=\nby { ext \u27e8a, b\u27e9 : 1, simp }\n\n/-- A family of equivalences `\u03a0 (a : \u03b1\u2081), \u03b2\u2081 \u2243 \u03b2\u2082` generates an equivalence\nbetween `\u03b1\u2081 \u00d7 \u03b2\u2081` and `\u03b1\u2081 \u00d7 \u03b2\u2082`. -/\ndef prod_congr_right : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2081 \u00d7 \u03b2\u2082 :=\n{ to_fun := \u03bb ab, \u27e8ab.1, e ab.1 ab.2\u27e9,\n  inv_fun := \u03bb ab, \u27e8ab.1, (e ab.1).symm ab.2\u27e9,\n  left_inv := by { rintros \u27e8a, b\u27e9, simp },\n  right_inv := by { rintros \u27e8a, b\u27e9, simp } }\n\n@[simp] lemma prod_congr_right_apply (a : \u03b1\u2081) (b : \u03b2\u2081) :\n  prod_congr_right e (a, b) = (a, e a b) := rfl\n\nlemma prod_congr_refl_left (e : \u03b2\u2081 \u2243 \u03b2\u2082) :\n  prod_congr (equiv.refl \u03b1\u2081) e = prod_congr_right (\u03bb _, e) :=\nby { ext \u27e8a, b\u27e9 : 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 \u27e8a, b\u27e9 : 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 \u27e8a, b\u27e9 : 1, simp }\n\nlemma sigma_congr_right_sigma_equiv_prod :\n  (sigma_congr_right e).trans (sigma_equiv_prod \u03b1\u2081 \u03b2\u2082) =\n    (sigma_equiv_prod \u03b1\u2081 \u03b2\u2081).trans (prod_congr_right e) :=\nby { ext \u27e8a, b\u27e9 : 1, simp }\n\nlemma sigma_equiv_prod_sigma_congr_right :\n  (sigma_equiv_prod \u03b1\u2081 \u03b2\u2081).symm.trans (sigma_congr_right e) =\n    (prod_congr_right e).trans (sigma_equiv_prod \u03b1\u2081 \u03b2\u2082).symm :=\nby { ext \u27e8a, b\u27e9 : 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 {\u03b1 \u03b2 \u03b3 : Type*} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3}\n  (e : \u03a0 c, {a // f a = c} \u2243 {b // g b = c}) :\n  \u03b1 \u2243 \u03b2 :=\n(sigma_fiber_equiv f).symm.trans $ (equiv.sigma_congr_right e).trans (sigma_fiber_equiv g)\n\nlemma of_fiber_equiv_map {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3}\n  (e : \u03a0 c, {a // f a = c} \u2243 {b // g b = c}) (a : \u03b1) : 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 {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Type*} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082 :=\n{ to_fun := \u03bb x : \u03b1\u2081 \u00d7 \u03b2\u2081, (e\u2081 x.1, e\u2082 x.1 x.2),\n  inv_fun := \u03bb y : \u03b1\u2082 \u00d7 \u03b2\u2082, (e\u2081.symm y.1, (e\u2082 $ e\u2081.symm y.1).symm y.2),\n  left_inv := by { rintro \u27e8x\u2081, y\u2081\u27e9, simp only [symm_apply_apply] },\n  right_inv := by { rintro \u27e8x\u2081, y\u2081\u27e9, simp only [apply_symm_apply] } }\n\nend prod_congr\n\nnamespace perm\n\nvariables {\u03b1\u2081 \u03b2\u2081 \u03b2\u2082 : Type*} [decidable_eq \u03b1\u2081] (a : \u03b1\u2081) (e : perm \u03b2\u2081)\n\n/-- `prod_extend_right a e` extends `e : perm \u03b2` to `perm (\u03b1 \u00d7 \u03b2)` by sending `(a, b)` to\n`(a, e b)` and keeping the other `(a', b)` fixed. -/\ndef prod_extend_right : perm (\u03b1\u2081 \u00d7 \u03b2\u2081) :=\n{ to_fun := \u03bb ab, if ab.fst = a then (a, e ab.snd) else ab,\n  inv_fun := \u03bb ab, if ab.fst = a then (a, e.symm ab.snd) else ab,\n  left_inv := by { rintros \u27e8k', x\u27e9, dsimp only, split_ifs with h; simp [h] },\n  right_inv := by { rintros \u27e8k', x\u27e9, dsimp only, split_ifs with h; simp [h] } }\n\n@[simp] lemma prod_extend_right_apply_eq (b : \u03b2\u2081) :\n  prod_extend_right a e (a, b) = (a, e b) := if_pos rfl\n\nlemma prod_extend_right_apply_ne {a a' : \u03b1\u2081} (h : a' \u2260 a) (b : \u03b2\u2081) :\n  prod_extend_right a e (a', b) = (a', b) := if_neg h\n\nlemma eq_of_prod_extend_right_ne {e : perm \u03b2\u2081} {a a' : \u03b1\u2081} {b : \u03b2\u2081}\n  (h : prod_extend_right a e (a', b) \u2260 (a', b)) : a' = a :=\nby { contrapose! h, exact prod_extend_right_apply_ne _ h _ }\n\n@[simp] lemma fst_prod_extend_right (ab : \u03b1\u2081 \u00d7 \u03b2\u2081) :\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 `\u03b1 \u00d7 \u03b2` is equivalent to the type of pairs of functions\n`\u03b3 \u2192 \u03b1` and `\u03b3 \u2192 \u03b2`. -/\ndef arrow_prod_equiv_prod_arrow (\u03b1 \u03b2 \u03b3 : Type*) : (\u03b3 \u2192 \u03b1 \u00d7 \u03b2) \u2243 (\u03b3 \u2192 \u03b1) \u00d7 (\u03b3 \u2192 \u03b2) :=\n\u27e8\u03bb f, (\u03bb c, (f c).1, \u03bb c, (f c).2),\n \u03bb p c, (p.1 c, p.2 c),\n \u03bb f, funext $ \u03bb c, prod.mk.eta,\n \u03bb p, by { cases p, refl }\u27e9\n\nopen sum\n/-- The type of functions on a sum type `\u03b1 \u2295 \u03b2` is equivalent to the type of pairs of functions\non `\u03b1` and on `\u03b2`. -/\ndef sum_arrow_equiv_prod_arrow (\u03b1 \u03b2 \u03b3 : Type*) : ((\u03b1 \u2295 \u03b2) \u2192 \u03b3) \u2243 (\u03b1 \u2192 \u03b3) \u00d7 (\u03b2 \u2192 \u03b3) :=\n\u27e8\u03bb f, (f \u2218 inl, f \u2218 inr),\n \u03bb p, sum.elim p.1 p.2,\n \u03bb f, by { ext \u27e8\u27e9; refl },\n \u03bb p, by { cases p, refl }\u27e9\n\n@[simp] lemma sum_arrow_equiv_prod_arrow_apply_fst {\u03b1 \u03b2 \u03b3} (f : (\u03b1 \u2295 \u03b2) \u2192 \u03b3) (a : \u03b1) :\n  (sum_arrow_equiv_prod_arrow \u03b1 \u03b2 \u03b3 f).1 a = f (inl a) := rfl\n@[simp] lemma sum_arrow_equiv_prod_arrow_apply_snd {\u03b1 \u03b2 \u03b3} (f : (\u03b1 \u2295 \u03b2) \u2192 \u03b3) (b : \u03b2) :\n  (sum_arrow_equiv_prod_arrow \u03b1 \u03b2 \u03b3 f).2 b = f (inr b) := rfl\n@[simp] lemma sum_arrow_equiv_prod_arrow_symm_apply_inl {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) (a : \u03b1) :\n  ((sum_arrow_equiv_prod_arrow \u03b1 \u03b2 \u03b3).symm (f, g)) (inl a) = f a := rfl\n@[simp] lemma sum_arrow_equiv_prod_arrow_symm_apply_inr {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) (b : \u03b2) :\n  ((sum_arrow_equiv_prod_arrow \u03b1 \u03b2 \u03b3).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 (\u03b1 \u03b2 \u03b3 : Sort*) : (\u03b1 \u2295 \u03b2) \u00d7 \u03b3 \u2243 (\u03b1 \u00d7 \u03b3) \u2295 (\u03b2 \u00d7 \u03b3) :=\n\u27e8\u03bb p, p.1.map (\u03bb x, (x, p.2)) (\u03bb x, (x, p.2)),\n \u03bb s, s.elim (prod.map inl id) (prod.map inr id),\n by rintro \u27e8_ | _, _\u27e9; refl,\n by rintro (\u27e8_, _\u27e9 | \u27e8_, _\u27e9); refl\u27e9\n\n@[simp] theorem sum_prod_distrib_apply_left {\u03b1 \u03b2 \u03b3} (a : \u03b1) (c : \u03b3) :\n   sum_prod_distrib \u03b1 \u03b2 \u03b3 (sum.inl a, c) = sum.inl (a, c) := rfl\n@[simp] theorem sum_prod_distrib_apply_right {\u03b1 \u03b2 \u03b3} (b : \u03b2) (c : \u03b3) :\n   sum_prod_distrib \u03b1 \u03b2 \u03b3 (sum.inr b, c) = sum.inr (b, c) := rfl\n@[simp] theorem sum_prod_distrib_symm_apply_left {\u03b1 \u03b2 \u03b3} (a : \u03b1 \u00d7 \u03b3) :\n  (sum_prod_distrib \u03b1 \u03b2 \u03b3).symm (inl a) = (inl a.1, a.2) := rfl\n@[simp] theorem sum_prod_distrib_symm_apply_right {\u03b1 \u03b2 \u03b3} (b : \u03b2 \u00d7 \u03b3) :\n  (sum_prod_distrib \u03b1 \u03b2 \u03b3).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 (\u03b1 \u03b2 \u03b3 : Sort*) : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243 (\u03b1 \u00d7 \u03b2) \u2295 (\u03b1 \u00d7 \u03b3) :=\ncalc \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243 (\u03b2 \u2295 \u03b3) \u00d7 \u03b1       : prod_comm _ _\n            ...   \u2243 (\u03b2 \u00d7 \u03b1) \u2295 (\u03b3 \u00d7 \u03b1) : sum_prod_distrib _ _ _\n            ...   \u2243 (\u03b1 \u00d7 \u03b2) \u2295 (\u03b1 \u00d7 \u03b3) : sum_congr (prod_comm _ _) (prod_comm _ _)\n\n@[simp] theorem prod_sum_distrib_apply_left {\u03b1 \u03b2 \u03b3} (a : \u03b1) (b : \u03b2) :\n   prod_sum_distrib \u03b1 \u03b2 \u03b3 (a, sum.inl b) = sum.inl (a, b) := rfl\n@[simp] theorem prod_sum_distrib_apply_right {\u03b1 \u03b2 \u03b3} (a : \u03b1) (c : \u03b3) :\n   prod_sum_distrib \u03b1 \u03b2 \u03b3 (a, sum.inr c) = sum.inr (a, c) := rfl\n@[simp] theorem prod_sum_distrib_symm_apply_left {\u03b1 \u03b2 \u03b3} (a : \u03b1 \u00d7 \u03b2) :\n  (prod_sum_distrib \u03b1 \u03b2 \u03b3).symm (inl a) = (a.1, inl a.2) := rfl\n@[simp] theorem prod_sum_distrib_symm_apply_right {\u03b1 \u03b2 \u03b3} (a : \u03b1 \u00d7 \u03b3) :\n  (prod_sum_distrib \u03b1 \u03b2 \u03b3).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 {\u03b9 : Type*} (\u03b1 \u03b2 : \u03b9 \u2192 Type*) :\n  (\u03a3 i, \u03b1 i \u2295 \u03b2 i) \u2243 (\u03a3 i, \u03b1 i) \u2295 \u03a3 i, \u03b2 i :=\n\u27e8\u03bb p, p.2.map (sigma.mk p.1) (sigma.mk p.1),\n  sum.elim (sigma.map id (\u03bb _, sum.inl)) (sigma.map id (\u03bb _, sum.inr)),\n  \u03bb p, by { rcases p with \u27e8i, (a | b)\u27e9; refl },\n  \u03bb p, by { rcases p with (\u27e8i, a\u27e9 | \u27e8i, b\u27e9); refl }\u27e9\n\n/-- The product of an indexed sum of types (formally, a `sigma`-type `\u03a3 i, \u03b1 i`) by a type `\u03b2` is\nequivalent to the sum of products `\u03a3 i, (\u03b1 i \u00d7 \u03b2)`. -/\ndef sigma_prod_distrib {\u03b9 : Type*} (\u03b1 : \u03b9 \u2192 Type*) (\u03b2 : Type*) :\n  ((\u03a3 i, \u03b1 i) \u00d7 \u03b2) \u2243 (\u03a3 i, (\u03b1 i \u00d7 \u03b2)) :=\n\u27e8\u03bb p, \u27e8p.1.1, (p.1.2, p.2)\u27e9,\n \u03bb p, (\u27e8p.1, p.2.1\u27e9, p.2.2),\n \u03bb p, by { rcases p with \u27e8\u27e8_, _\u27e9, _\u27e9, refl },\n \u03bb p, by { rcases p with \u27e8_, \u27e8_, _\u27e9\u27e9, refl }\u27e9\n\n/-- An equivalence that separates out the 0th fiber of `(\u03a3 (n : \u2115), f n)`. -/\ndef sigma_nat_succ (f : \u2115 \u2192 Type u) :\n  (\u03a3 n, f n) \u2243 f 0 \u2295 \u03a3 n, f (n + 1) :=\n\u27e8\u03bb x, @sigma.cases_on \u2115 f (\u03bb _, f 0 \u2295 \u03a3 n, f (n + 1)) x (\u03bb n, @nat.cases_on (\u03bb i, f i \u2192 (f 0 \u2295\n  \u03a3 (n : \u2115), f (n + 1))) n (\u03bb (x : f 0), sum.inl x) (\u03bb (n : \u2115) (x : f n.succ), sum.inr \u27e8n, x\u27e9)),\n  sum.elim (sigma.mk 0) (sigma.map nat.succ (\u03bb _, id)),\n  by { rintro \u27e8(n | n), x\u27e9; refl }, by { rintro (x | \u27e8n, x\u27e9); refl }\u27e9\n\n/-- The product `bool \u00d7 \u03b1` is equivalent to `\u03b1 \u2295 \u03b1`. -/\n@[simps] def bool_prod_equiv_sum (\u03b1 : Type u) : bool \u00d7 \u03b1 \u2243 \u03b1 \u2295 \u03b1 :=\n{ to_fun := \u03bb 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 \u27e8(_|_), _\u27e9; refl,\n  right_inv := by rintro (_|_); refl }\n\n/-- The function type `bool \u2192 \u03b1` is equivalent to `\u03b1 \u00d7 \u03b1`. -/\n@[simps] def bool_arrow_equiv_prod (\u03b1 : Type u) : (bool \u2192 \u03b1) \u2243 \u03b1 \u00d7 \u03b1 :=\n{ to_fun := \u03bb f, (f tt, f ff),\n  inv_fun := \u03bb p b, cond b p.1 p.2,\n  left_inv := \u03bb f, funext $ bool.forall_bool.2 \u27e8rfl, rfl\u27e9,\n  right_inv := \u03bb \u27e8x, y\u27e9, rfl }\n\nend\n\nsection\nopen sum nat\n/-- The set of natural numbers is equivalent to `\u2115 \u2295 punit`. -/\ndef nat_equiv_nat_sum_punit : \u2115 \u2243 \u2115 \u2295 punit.{u+1} :=\n{ to_fun := \u03bb n, nat.cases_on n (inr punit.star) inl,\n  inv_fun := sum.elim nat.succ (\u03bb _, 0),\n  left_inv := \u03bb n, by cases n; refl,\n  right_inv := by rintro (_|_|_); refl }\n\n/-- `\u2115 \u2295 punit` is equivalent to `\u2115`. -/\ndef nat_sum_punit_equiv_nat : \u2115 \u2295 punit.{u+1} \u2243 \u2115 :=\nnat_equiv_nat_sum_punit.symm\n\n/-- The type of integer numbers is equivalent to `\u2115 \u2295 \u2115`. -/\ndef int_equiv_nat_sum_nat : \u2124 \u2243 \u2115 \u2295 \u2115 :=\n{ to_fun := \u03bb 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 `\u03b1` and `\u03b2` generates an equivalence between `list \u03b1` and `list \u03b2`. -/\ndef list_equiv_of_equiv {\u03b1 \u03b2 : Type*} (e : \u03b1 \u2243 \u03b2) : list \u03b1 \u2243 list \u03b2 :=\n{ to_fun := list.map e,\n  inv_fun := list.map e.symm,\n  left_inv := \u03bb l, by rw [list.map_map, e.symm_comp_self, list.map_id],\n  right_inv := \u03bb l, by rw [list.map_map, e.self_comp_symm, list.map_id] }\n\n/-- If `\u03b1` is equivalent to `\u03b2`, then `unique \u03b1` is equivalent to `unique \u03b2`. -/\ndef unique_congr (e : \u03b1 \u2243 \u03b2) : unique \u03b1 \u2243 unique \u03b2 :=\n{ to_fun := \u03bb h, @equiv.unique _ _ h e.symm,\n  inv_fun := \u03bb h, @equiv.unique _ _ h e,\n  left_inv := \u03bb _, subsingleton.elim _ _,\n  right_inv := \u03bb _, subsingleton.elim _ _ }\n\n/-- If `\u03b1` is equivalent to `\u03b2`, then `is_empty \u03b1` is equivalent to `is_empty \u03b2`. -/\nlemma is_empty_congr (e : \u03b1 \u2243 \u03b2) : is_empty \u03b1 \u2194 is_empty \u03b2 :=\n\u27e8\u03bb h, @function.is_empty _ _ h e.symm, \u03bb h, @function.is_empty _ _ h e\u27e9\n\nprotected lemma is_empty (e : \u03b1 \u2243 \u03b2) [is_empty \u03b2] : is_empty \u03b1 :=\ne.is_empty_congr.mpr \u2039_\u203a\n\nsection\nopen subtype\n\n/-- If `\u03b1` is equivalent to `\u03b2` and the predicates `p : \u03b1 \u2192 Prop` and `q : \u03b2 \u2192 Prop` are equivalent\nat corresponding points, then `{a // p a}` is equivalent to `{b // q b}`.\nFor the statement where `\u03b1 = \u03b2`, that is, `e : perm \u03b1`, see `perm.subtype_perm`. -/\ndef subtype_equiv {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop}\n  (e : \u03b1 \u2243 \u03b2) (h : \u2200 a, p a \u2194 q (e a)) : {a : \u03b1 // p a} \u2243 {b : \u03b2 // q b} :=\n{ to_fun    := \u03bb a, \u27e8e a, (h _).mp a.prop\u27e9,\n  inv_fun   := \u03bb b, \u27e8e.symm b, (h _).mpr ((e.apply_symm_apply b).symm \u25b8 b.prop)\u27e9,\n  left_inv  := \u03bb a, subtype.ext $ by simp,\n  right_inv := \u03bb b, subtype.ext $ by simp }\n\n@[simp] lemma subtype_equiv_refl {p : \u03b1 \u2192 Prop}\n  (h : \u2200 a, p a \u2194 p (equiv.refl _ a) := \u03bb a, iff.rfl) :\n  (equiv.refl \u03b1).subtype_equiv h = equiv.refl {a : \u03b1 // p a} :=\nby { ext, refl }\n\n@[simp] lemma subtype_equiv_symm {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2)\n  (h : \u2200 (a : \u03b1), p a \u2194 q (e a)) :\n  (e.subtype_equiv h).symm = e.symm.subtype_equiv (\u03bb 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 : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop}\n  (e : \u03b1 \u2243 \u03b2) (f : \u03b2 \u2243 \u03b3)\n  (h : \u2200 (a : \u03b1), p a \u2194 q (e a)) (h' : \u2200 (b : \u03b2), q b \u2194 r (f b)):\n  (e.subtype_equiv h).trans (f.subtype_equiv h') =\n    (e.trans f).subtype_equiv (\u03bb a, (h a).trans (h' $ e a)) :=\nrfl\n\n@[simp] lemma subtype_equiv_apply {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2)\n  (h : \u2200 (a : \u03b1), p a \u2194 q (e a)) (x : {x // p x}) :\n  e.subtype_equiv h x = \u27e8e x, (h _).1 x.2\u27e9 :=\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 : \u03b1 \u2192 Prop} (e : \u2200x, p x \u2194 q x) : {x // p x} \u2243 {x // q x} :=\nsubtype_equiv (equiv.refl _) e\n\n/-- If `\u03b1 \u2243 \u03b2`, then for any predicate `p : \u03b2 \u2192 Prop` the subtype `{a // p (e a)}` is equivalent\nto the subtype `{b // p b}`. -/\ndef subtype_equiv_of_subtype {p : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) :\n  {a : \u03b1 // p (e a)} \u2243 {b : \u03b2 // p b} :=\nsubtype_equiv e $ by simp\n\n/-- If `\u03b1 \u2243 \u03b2`, then for any predicate `p : \u03b1 \u2192 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 : \u03b1 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) :\n  {a : \u03b1 // p a} \u2243 {b : \u03b2 // 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 {\u03b1 : Sort*} {p q : \u03b1 \u2192 Prop} (h : p = q) : subtype p \u2243 subtype q :=\nsubtype_equiv (equiv.refl \u03b1) (assume a, h \u25b8 iff.rfl)\n\n/-- A subtype of a subtype is equivalent to the subtype of elements satisfying both predicates. This\nversion allows the \u201cinner\u201d predicate to depend on `h : p a`. -/\n@[simps]\ndef subtype_subtype_equiv_subtype_exists {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) (q : subtype p \u2192 Prop) :\n  subtype q \u2243 {a : \u03b1 // \u2203h:p a, q \u27e8a, h\u27e9 } :=\n\u27e8\u03bb a, \u27e8a, a.1.2, by { rcases a with \u27e8\u27e8a, hap\u27e9, haq\u27e9, exact haq }\u27e9,\n  \u03bb a, \u27e8\u27e8a, a.2.fst\u27e9, a.2.snd\u27e9,\n  assume \u27e8\u27e8a, ha\u27e9, h\u27e9, rfl, assume \u27e8a, h\u2081, h\u2082\u27e9, rfl\u27e9\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 {\u03b1 : Sort u} (p q : \u03b1 \u2192 Prop) :\n  {x : subtype p // q x.1} \u2243 subtype (\u03bb x, p x \u2227 q x) :=\n(subtype_subtype_equiv_subtype_exists p _).trans $\nsubtype_equiv_right $ \u03bb 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 {\u03b1 : Type u} {p q : \u03b1 \u2192 Prop} (h : \u2200 {x}, q x \u2192 p x) :\n  {x : subtype p // q x.1} \u2243 subtype q :=\n(subtype_subtype_equiv_subtype_inter p _).trans $\nsubtype_equiv_right $ \u03bb 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 {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} (h : \u2200 x, p x) :\n  subtype p \u2243 \u03b1 :=\n\u27e8\u03bb x, x, \u03bb x, \u27e8x, h x\u27e9, \u03bb x, subtype.eq rfl, \u03bb x, rfl\u27e9\n\n/-- A subtype of a sigma-type is a sigma-type over a subtype. -/\ndef subtype_sigma_equiv {\u03b1 : Type u} (p : \u03b1 \u2192 Type v) (q : \u03b1 \u2192 Prop) :\n  { y : sigma p // q y.1 } \u2243 \u03a3(x : subtype q), p x.1 :=\n\u27e8\u03bb x, \u27e8\u27e8x.1.1, x.2\u27e9, x.1.2\u27e9,\n \u03bb x, \u27e8\u27e8x.1.1, x.2\u27e9, x.1.2\u27e9,\n \u03bb \u27e8\u27e8x, h\u27e9, y\u27e9, rfl,\n \u03bb \u27e8\u27e8x, y\u27e9, h\u27e9, rfl\u27e9\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 {\u03b1 : Type u} (p : \u03b1 \u2192 Type v) (q : \u03b1 \u2192 Prop)\n  (h : \u2200 x, p x \u2192 q x) :\n  (\u03a3 x : subtype q, p x) \u2243 \u03a3 x : \u03b1, p x :=\n(subtype_sigma_equiv p q).symm.trans $ subtype_univ_equiv $ \u03bb x, h x.1 x.2\n\n/-- If a predicate `p : \u03b2 \u2192 Prop` is true on the range of a map `f : \u03b1 \u2192 \u03b2`, then\n`\u03a3 y : {y // p y}, {x // f x = y}` is equivalent to `\u03b1`. -/\ndef sigma_subtype_fiber_equiv {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (p : \u03b2 \u2192 Prop)\n  (h : \u2200 x, p (f x)) :\n  (\u03a3 y : subtype p, {x : \u03b1 // f x = y}) \u2243 \u03b1 :=\ncalc _ \u2243 \u03a3 y : \u03b2, {x : \u03b1 // f x = y} : sigma_subtype_equiv_of_subset _ p (\u03bb y \u27e8x, h'\u27e9, h' \u25b8 h x)\n   ... \u2243 \u03b1                           : sigma_fiber_equiv f\n\n/-- If for each `x` we have `p x \u2194 q (f x)`, then `\u03a3 y : {y // q y}, f \u207b\u00b9' {y}` is equivalent\nto `{x // p x}`. -/\ndef sigma_subtype_fiber_equiv_subtype {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2)\n  {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (h : \u2200 x, p x \u2194 q (f x)) :\n  (\u03a3 y : subtype q, {x : \u03b1 // f x = y}) \u2243 subtype p :=\ncalc (\u03a3 y : subtype q, {x : \u03b1 // f x = y}) \u2243\n  \u03a3 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 \u27e8\u03bb \u27e8hp, h'\u27e9, congr_arg subtype.val h', \u03bb h', \u27e8(h x).2 (h'.symm \u25b8 y.2), subtype.eq h'\u27e9\u27e9\n  end\n   ... \u2243 subtype p : sigma_fiber_equiv (\u03bb x : subtype p, (\u27e8f x, (h x).1 x.property\u27e9 : 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 {\u03b1 : Type u} (p : option \u03b1 \u2192 Type v) (h : p none \u2192 false) :\n  (\u03a3 x : option \u03b1, p x) \u2243 (\u03a3 x : \u03b1, p (some x)) :=\nbegin\n  have h' : \u2200 x, p x \u2192 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 \u03b1)),\nend\n\n/-- The `pi`-type `\u03a0 i, \u03c0 i` is equivalent to the type of sections `f : \u03b9 \u2192 \u03a3 i, \u03c0 i` of the\n`sigma` type such that for all `i` we have `(f i).fst = i`. -/\ndef pi_equiv_subtype_sigma (\u03b9 : Type*) (\u03c0 : \u03b9 \u2192 Type*) :\n  (\u03a0 i, \u03c0 i) \u2243 {f : \u03b9 \u2192 \u03a3 i, \u03c0 i // \u2200 i, (f i).1 = i } :=\n\u27e8 \u03bbf, \u27e8\u03bbi, \u27e8i, f i\u27e9, assume i, rfl\u27e9, \u03bbf i, begin rw \u2190 f.2 i, exact (f.1 i).2 end,\n  assume f, funext $ assume i, rfl,\n  assume \u27e8f, hf\u27e9, subtype.eq $ funext $ assume i, sigma.eq (hf i).symm $\n    eq_of_heq $ rec_heq_of_heq _ $ rec_heq_of_heq _ $ heq.refl _\u27e9\n\n/-- The set of functions `f : \u03a0 a, \u03b2 a` such that for all `a` we have `p a (f a)` is equivalent\nto the set of functions `\u03a0 a, {b : \u03b2 a // p a b}`. -/\ndef subtype_pi_equiv_pi {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {p : \u03a0a, \u03b2 a \u2192 Prop} :\n  {f : \u03a0a, \u03b2 a // \u2200a, p a (f a) } \u2243 \u03a0a, { b : \u03b2 a // p a b } :=\n\u27e8\u03bbf a, \u27e8f.1 a, f.2 a\u27e9, \u03bbf, \u27e8\u03bba, (f a).1, \u03bba, (f a).2\u27e9,\n  by { rintro \u27e8f, h\u27e9, refl },\n  by { rintro f, funext a, exact subtype.ext_val rfl }\u27e9\n\n/-- A subtype of a product defined by componentwise conditions\nis equivalent to a product of subtypes. -/\ndef subtype_prod_equiv_prod {\u03b1 : Type u} {\u03b2 : Type v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} :\n  {c : \u03b1 \u00d7 \u03b2 // p c.1 \u2227 q c.2} \u2243 ({a // p a} \u00d7 {b // q b}) :=\n\u27e8\u03bb x, \u27e8\u27e8x.1.1, x.2.1\u27e9, \u27e8x.1.2, x.2.2\u27e9\u27e9,\n \u03bb x, \u27e8\u27e8x.1.1, x.2.1\u27e9, \u27e8x.1.2, x.2.2\u27e9\u27e9,\n \u03bb \u27e8\u27e8_, _\u27e9, \u27e8_, _\u27e9\u27e9, rfl,\n \u03bb \u27e8\u27e8_, _\u27e9, \u27e8_, _\u27e9\u27e9, rfl\u27e9\n\n/-- A subtype of a `prod` is equivalent to a sigma type whose fibers are subtypes. -/\ndef subtype_prod_equiv_sigma_subtype {\u03b1 \u03b2 : Type*} (p : \u03b1 \u2192 \u03b2 \u2192 Prop) :\n  {x : \u03b1 \u00d7 \u03b2 // p x.1 x.2} \u2243 \u03a3 a, {b : \u03b2 // p a b} :=\n{ to_fun := \u03bb x, \u27e8x.1.1, x.1.2, x.prop\u27e9,\n  inv_fun := \u03bb x, \u27e8\u27e8x.1, x.2\u27e9, x.2.prop\u27e9,\n  left_inv := \u03bb x, by ext; refl,\n  right_inv := \u03bb \u27e8a, b, pab\u27e9, rfl }\n\n/-- The type `\u03a0 (i : \u03b1), \u03b2 i` can be split as a product by separating the indices in `\u03b1`\ndepending on whether they satisfy a predicate `p` or not. -/\n@[simps] def pi_equiv_pi_subtype_prod\n  {\u03b1 : Type*} (p : \u03b1 \u2192 Prop) (\u03b2 : \u03b1 \u2192 Type*) [decidable_pred p] :\n  (\u03a0 (i : \u03b1), \u03b2 i) \u2243 (\u03a0 (i : {x // p x}), \u03b2 i) \u00d7 (\u03a0 (i : {x // \u00ac p x}), \u03b2 i) :=\n{ to_fun := \u03bb f, (\u03bb x, f x, \u03bb x, f x),\n  inv_fun := \u03bb f x, if h : p x then f.1 \u27e8x, h\u27e9 else f.2 \u27e8x, h\u27e9,\n  right_inv := begin\n    rintros \u27e8f, g\u27e9,\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 := \u03bb 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 {\u03b1 : Type*} [decidable_eq \u03b1] (i : \u03b1) (\u03b2 : \u03b1 \u2192 Type*) :\n  (\u03a0 j, \u03b2 j) \u2243 \u03b2 i \u00d7 \u03a0 j : {j // j \u2260 i}, \u03b2 j :=\n{ to_fun := \u03bb f, \u27e8f i, \u03bb j, f j\u27e9,\n  inv_fun := \u03bb f j, if h : j = i then h.symm.rec f.1 else f.2 \u27e8j, h\u27e9,\n  right_inv := \u03bb f, by { ext, exacts [dif_pos rfl, (dif_neg x.2).trans (by cases x; refl)] },\n  left_inv := \u03bb 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 {\u03b1 : Type*} [decidable_eq \u03b1] (i : \u03b1) (\u03b2 : Type*) :\n  (\u03b1 \u2192 \u03b2) \u2243 \u03b2 \u00d7 ({j // j \u2260 i} \u2192 \u03b2) := 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 \u2192 Y` with prescribed values for all `x' \u2260 x`\nis equivalent to the codomain `Y`. -/\ndef subtype_equiv_codomain (f : {x' // x' \u2260 x} \u2192 Y) : {g : X \u2192 Y // g \u2218 coe = f} \u2243 Y :=\n(subtype_preimage _ f).trans $\n@fun_unique {x' // \u00ac x' \u2260 x} _ $\nshow unique {x' // \u00ac x' \u2260 x}, from @equiv.unique _ _\n  (show unique {x' // x' = x}, from\n    { default := \u27e8x, rfl\u27e9, uniq := \u03bb \u27e8x', h\u27e9, subtype.val_injective h })\n  (subtype_equiv_right $ \u03bb a, not_not)\n\n@[simp] lemma coe_subtype_equiv_codomain (f : {x' // x' \u2260 x} \u2192 Y) :\n  (subtype_equiv_codomain f : {g : X \u2192 Y // g \u2218 coe = f} \u2192 Y) = \u03bb g, (g : X \u2192 Y) x := rfl\n\n@[simp] lemma subtype_equiv_codomain_apply (f : {x' // x' \u2260 x} \u2192 Y)\n  (g : {g : X \u2192 Y // g \u2218 coe = f}) :\n  subtype_equiv_codomain f g = (g : X \u2192 Y) x := rfl\n\nlemma coe_subtype_equiv_codomain_symm (f : {x' // x' \u2260 x} \u2192 Y) :\n  ((subtype_equiv_codomain f).symm : Y \u2192 {g : X \u2192 Y // g \u2218 coe = f}) =\n  \u03bb y, \u27e8\u03bb x', if h : x' \u2260 x then f \u27e8x', h\u27e9 else y,\n    by { funext x', dsimp, erw [dif_pos x'.2, subtype.coe_eta] }\u27e9 := rfl\n\n@[simp] lemma subtype_equiv_codomain_symm_apply (f : {x' // x' \u2260 x} \u2192 Y) (y : Y) (x' : X) :\n  ((subtype_equiv_codomain f).symm y : X \u2192 Y) x' = if h : x' \u2260 x then f \u27e8x', h\u27e9 else y :=\nrfl\n\n@[simp] lemma subtype_equiv_codomain_symm_apply_eq (f : {x' // x' \u2260 x} \u2192 Y) (y : Y) :\n  ((subtype_equiv_codomain f).symm y : X \u2192 Y) x = y :=\ndif_neg (not_not.mpr rfl)\n\nlemma subtype_equiv_codomain_symm_apply_ne (f : {x' // x' \u2260 x} \u2192 Y) (y : Y) (x' : X) (h : x' \u2260 x) :\n  ((subtype_equiv_codomain f).symm y : X \u2192 Y) x' = f \u27e8x', h\u27e9 :=\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 : \u03b1 \u2192 \u03b2) (hf : bijective f) : \u03b1 \u2243 \u03b2 :=\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 : \u03b1 \u2192 \u03b2) (hf : bijective f) (x : \u03b2) :\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 : \u03b1 \u2192 \u03b2) (hf : bijective f) (x : \u03b1) :\n  (of_bijective f hf).symm (f x) = x :=\n(of_bijective f hf).symm_apply_apply x\n\ninstance : can_lift (\u03b1 \u2192 \u03b2) (\u03b1 \u2243 \u03b2) coe_fn bijective :=\n{ prf := \u03bb f hf, \u27e8of_bijective f hf, rfl\u27e9 }\n\nsection\n\nvariables {\u03b1' \u03b2' : Type*} (e : perm \u03b1') {p : \u03b2' \u2192 Prop} [decidable_pred p]\n  (f : \u03b1' \u2243 subtype p)\n\n/--\nExtend the domain of `e : equiv.perm \u03b1` to one that is over `\u03b2` via `f : \u03b1 \u2192 subtype p`,\nwhere `p : \u03b2 \u2192 Prop`, permuting only the `b : \u03b2` that satisfy `p b`.\nThis can be used to extend the domain across a function `f : \u03b1 \u2192 \u03b2`,\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 \u03b2' :=\n(perm_congr f e).subtype_congr (equiv.refl _)\n\n@[simp] lemma perm.extend_domain_apply_image (a : \u03b1') :\n  e.extend_domain f (f a) = f (e a) :=\nby simp [perm.extend_domain]\n\nlemma perm.extend_domain_apply_subtype {b : \u03b2'} (h : p b) :\n  e.extend_domain f b = f (e (f.symm \u27e8b, h\u27e9)) :=\nby simp [perm.extend_domain, h]\n\nlemma perm.extend_domain_apply_not_subtype {b : \u03b2'} (h : \u00ac 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 \u03b1') :\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 `\u03b1` be a setoid with\nequivalence relation `~`. Let `p\u2082` be a predicate on the quotient type `\u03b1/~`, and `p\u2081` be the lift\nof this predicate to `\u03b1`: `p\u2081 a \u2194 p\u2082 \u27e6a\u27e7`. Let `~\u2082` be the restriction of `~` to `{x // p\u2081 x}`.\nThen `{x // p\u2082 x}` is equivalent to the quotient of `{x // p\u2081 x}` by `~\u2082`. -/\ndef subtype_quotient_equiv_quotient_subtype (p\u2081 : \u03b1 \u2192 Prop) [s\u2081 : setoid \u03b1]\n  [s\u2082 : setoid (subtype p\u2081)] (p\u2082 : quotient s\u2081 \u2192 Prop) (hp\u2082 : \u2200 a, p\u2081 a \u2194 p\u2082 \u27e6a\u27e7)\n  (h : \u2200 x y : subtype p\u2081, @setoid.r _ s\u2082 x y \u2194 (x : \u03b1) \u2248 y) :\n  {x // p\u2082 x} \u2243 quotient s\u2082 :=\n{ to_fun := \u03bb a, quotient.hrec_on a.1 (\u03bb a h, \u27e6\u27e8a, (hp\u2082 _).2 h\u27e9\u27e7)\n    (\u03bb a b hab, hfunext (by rw quotient.sound hab)\n    (\u03bb h\u2081 h\u2082 _, heq_of_eq (quotient.sound ((h _ _).2 hab)))) a.2,\n  inv_fun := \u03bb a, quotient.lift_on a (\u03bb a, (\u27e8\u27e6a.1\u27e7, (hp\u2082 _).1 a.2\u27e9 : {x // p\u2082 x}))\n    (\u03bb a b hab, subtype.ext_val (quotient.sound ((h _ _).1 hab))),\n  left_inv := \u03bb \u27e8a, ha\u27e9, quotient.induction_on a (\u03bb a ha, rfl) ha,\n  right_inv := \u03bb a, quotient.induction_on a (\u03bb \u27e8a, ha\u27e9, rfl) }\n\n@[simp] lemma subtype_quotient_equiv_quotient_subtype_mk (p\u2081 : \u03b1 \u2192 Prop) [s\u2081 : setoid \u03b1]\n  [s\u2082 : setoid (subtype p\u2081)] (p\u2082 : quotient s\u2081 \u2192 Prop) (hp\u2082 : \u2200 a, p\u2081 a \u2194 p\u2082 \u27e6a\u27e7)\n  (h : \u2200 x y : subtype p\u2081, @setoid.r _ s\u2082 x y \u2194 (x : \u03b1) \u2248 y) (x hx) :\n  subtype_quotient_equiv_quotient_subtype p\u2081 p\u2082 hp\u2082 h \u27e8\u27e6x\u27e7, hx\u27e9 = \u27e6\u27e8x, (hp\u2082 _).2 hx\u27e9\u27e7 := rfl\n\n@[simp] lemma subtype_quotient_equiv_quotient_subtype_symm_mk (p\u2081 : \u03b1 \u2192 Prop) [s\u2081 : setoid \u03b1]\n  [s\u2082 : setoid (subtype p\u2081)] (p\u2082 : quotient s\u2081 \u2192 Prop) (hp\u2082 : \u2200 a, p\u2081 a \u2194 p\u2082 \u27e6a\u27e7)\n  (h : \u2200 x y : subtype p\u2081, @setoid.r _ s\u2082 x y \u2194 (x : \u03b1) \u2248 y) (x) :\n  (subtype_quotient_equiv_quotient_subtype p\u2081 p\u2082 hp\u2082 h).symm \u27e6x\u27e7 = \u27e8\u27e6x\u27e7, (hp\u2082 _).1 x.prop\u27e9 := rfl\n\nsection swap\nvariable [decidable_eq \u03b1]\n\n/-- A helper function for `equiv.swap`. -/\ndef swap_core (a b r : \u03b1) : \u03b1 :=\nif r = a then b\nelse if r = b then a\nelse r\n\ntheorem swap_core_self (r a : \u03b1) : swap_core a a r = r :=\nby { unfold swap_core, split_ifs; cc }\n\ntheorem swap_core_swap_core (r a b : \u03b1) : 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 : \u03b1) : 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 : \u03b1) : perm \u03b1 :=\n\u27e8swap_core a b, swap_core a b, \u03bbr, swap_core_swap_core r a b, \u03bbr, swap_core_swap_core r a b\u27e9\n\n@[simp] theorem swap_self (a : \u03b1) : swap a a = equiv.refl _ :=\next $ \u03bb r, swap_core_self r a\n\ntheorem swap_comm (a b : \u03b1) : swap a b = swap b a :=\next $ \u03bb r, swap_core_comm r _ _\n\ntheorem swap_apply_def (a b x : \u03b1) : 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 : \u03b1) : swap a b a = b :=\nif_pos rfl\n\n@[simp] theorem swap_apply_right (a b : \u03b1) : 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 : \u03b1} : x \u2260 a \u2192 x \u2260 b \u2192 swap a b x = x :=\nby simp [swap_apply_def] {contextual := tt}\n\n@[simp] theorem swap_swap (a b : \u03b1) : (swap a b).trans (swap a b) = equiv.refl _ :=\next $ \u03bb x, swap_core_swap_core _ _ _\n\n@[simp] lemma symm_swap (a b : \u03b1) : (swap a b).symm = swap a b := rfl\n\n@[simp] lemma swap_eq_refl_iff {x y : \u03b1} : swap x y = equiv.refl _ \u2194 x = y :=\nbegin\n  refine \u27e8\u03bb h, (equiv.refl _).injective _, \u03bb h, h \u25b8 (swap_self _)\u27e9,\n  rw [\u2190h, swap_apply_left, h, refl_apply]\nend\n\ntheorem swap_comp_apply {a b x : \u03b1} (\u03c0 : perm \u03b1) :\n  \u03c0.trans (swap a b) x = if \u03c0 x = a then b else if \u03c0 x = b then a else \u03c0 x :=\nby { cases \u03c0, refl }\n\nlemma swap_eq_update (i j : \u03b1) :\n  (equiv.swap i j : \u03b1 \u2192 \u03b1) = update (update id j i) i j :=\nfunext $ \u03bb 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 : \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  f \u2218 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 \u03b2] (a b : \u03b1) (e : \u03b1 \u2243 \u03b2) :\n  (e.symm.trans (swap a b)).trans e = swap (e a) (e b) :=\nequiv.ext (\u03bb x, begin\n  have : \u2200 a, e.symm x = a \u2194 x = e a :=\n    \u03bb 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 \u03b2] (a b : \u03b2)\n  (e : \u03b1 \u2243 \u03b2) : (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 : \u03b1) :\n  swap i j (swap i j a) = a :=\nby rw [\u2190 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 : \u03b1 \u2192 \u03b2} {i j : \u03b1} (hv : v i = v j) (k : \u03b1) : 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 : \u03b1} :\n  swap x y z = w \u2194 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 : \u03b1} : swap a b x \u2260 x \u2194 a \u2260 b \u2227 (x = a \u2228 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 {\u03b1 \u03b2 : Sort*} [decidable_eq \u03b1] [decidable_eq \u03b2] (i j : \u03b1) :\n  equiv.perm.sum_congr (equiv.swap i j) (equiv.refl \u03b2) = 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 {\u03b1 \u03b2 : Sort*} [decidable_eq \u03b1] [decidable_eq \u03b2] (i j : \u03b2) :\n  equiv.perm.sum_congr (equiv.refl \u03b1) (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 : \u03b1 \u2243 \u03b2) (a : \u03b1) (b : \u03b2) : \u03b1 \u2243 \u03b2 :=\n(swap a (f.symm b)).trans f\n\n@[simp] theorem set_value_eq (f : \u03b1 \u2243 \u03b2) (a : \u03b1) (b : \u03b2) : 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 : \u03b1 \u2192 \u03b1) (h : involutive f) : equiv.perm \u03b1 :=\n\u27e8f, f, h.left_inverse, h.right_inverse\u27e9\n\n@[simp] lemma coe_to_perm {f : \u03b1 \u2192 \u03b1} (h : involutive f) : (h.to_perm f : \u03b1 \u2192 \u03b1) = f := rfl\n\n@[simp] lemma to_perm_symm {f : \u03b1 \u2192 \u03b1} (h : involutive f) : (h.to_perm f).symm = h.to_perm f := rfl\n\nlemma to_perm_involutive {f : \u03b1 \u2192 \u03b1} (h : involutive f) : involutive (h.to_perm f) := h\n\nend function.involutive\n\nlemma plift.eq_up_iff_down_eq {x : plift \u03b1} {y : \u03b1} : x = plift.up y \u2194 x.down = y :=\nequiv.plift.eq_symm_apply\n\nlemma function.injective.map_swap {\u03b1 \u03b2 : Sort*} [decidable_eq \u03b1] [decidable_eq \u03b2]\n  {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) (x y z : \u03b1) :\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\u2081 h\u2082,\n  { rw [hf h\u2081, equiv.swap_apply_left] },\n  { rw [hf h\u2082, equiv.swap_apply_right] },\n  { rw [equiv.swap_apply_of_ne_of_ne (mt (congr_arg f) h\u2081) (mt (congr_arg f) h\u2082)] }\nend\n\nnamespace equiv\n\nsection\nvariables (P : \u03b1 \u2192 Sort w) (e : \u03b1 \u2243 \u03b2)\n\n/--\nTransport dependent functions through an equivalence of the base space.\n-/\n@[simps] def Pi_congr_left' : (\u03a0 a, P a) \u2243 (\u03a0 b, P (e.symm b)) :=\n{ to_fun := \u03bb f x, f (e.symm x),\n  inv_fun := \u03bb f x, begin rw [\u2190 e.symm_apply_apply x], exact f (e x)  end,\n  left_inv := \u03bb f, funext $ \u03bb x, eq_of_heq ((eq_rec_heq _ _).trans\n    (by { dsimp, rw e.symm_apply_apply })),\n  right_inv := \u03bb f, funext $ \u03bb x, eq_of_heq ((eq_rec_heq _ _).trans\n    (by { rw e.apply_symm_apply })) }\n\nend\n\nsection\nvariables (P : \u03b2 \u2192 Sort w) (e : \u03b1 \u2243 \u03b2)\n\n/--\nTransporting dependent functions through an equivalence of the base,\nexpressed as a \"simplification\".\n-/\ndef Pi_congr_left : (\u03a0 a, P (e a)) \u2243 (\u03a0 b, P b) :=\n(Pi_congr_left' P e.symm).symm\nend\n\nsection\nvariables\n  {W : \u03b1 \u2192 Sort w} {Z : \u03b2 \u2192 Sort z} (h\u2081 : \u03b1 \u2243 \u03b2) (h\u2082 : \u03a0 a : \u03b1, (W a \u2243 Z (h\u2081 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 : (\u03a0 a, W a) \u2243 (\u03a0 b, Z b) :=\n(equiv.Pi_congr_right h\u2082).trans (equiv.Pi_congr_left _ h\u2081)\n\n@[simp] lemma coe_Pi_congr_symm :\n  ((h\u2081.Pi_congr h\u2082).symm : (\u03a0 b, Z b) \u2192 (\u03a0 a, W a)) = \u03bb f a, (h\u2082 a).symm (f (h\u2081 a)) :=\nrfl\n\nlemma Pi_congr_symm_apply (f : \u03a0 b, Z b) :\n  (h\u2081.Pi_congr h\u2082).symm f = \u03bb a, (h\u2082 a).symm (f (h\u2081 a)) :=\nrfl\n\n@[simp] lemma Pi_congr_apply_apply (f : \u03a0 a, W a) (a : \u03b1) :\n  h\u2081.Pi_congr h\u2082 f (h\u2081 a) = h\u2082 a (f a) :=\nbegin\n  change cast _ ((h\u2082 (h\u2081.symm (h\u2081 a))) (f (h\u2081.symm (h\u2081 a)))) = (h\u2082 a) (f a),\n  generalize_proofs hZa,\n  revert hZa,\n  rw h\u2081.symm_apply_apply a,\n  simp,\nend\n\nend\n\nsection\nvariables\n  {W : \u03b1 \u2192 Sort w} {Z : \u03b2 \u2192 Sort z} (h\u2081 : \u03b1 \u2243 \u03b2) (h\u2082 : \u03a0 b : \u03b2, (W (h\u2081.symm b) \u2243 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' : (\u03a0 a, W a) \u2243 (\u03a0 b, Z b) :=\n(Pi_congr h\u2081.symm (\u03bb b, (h\u2082 b).symm)).symm\n\n@[simp] lemma coe_Pi_congr' :\n  (h\u2081.Pi_congr' h\u2082 : (\u03a0 a, W a) \u2192 (\u03a0 b, Z b)) = \u03bb f b, h\u2082 b $ f $ h\u2081.symm b :=\nrfl\n\nlemma Pi_congr'_apply (f : \u03a0 a, W a) :\n  h\u2081.Pi_congr' h\u2082 f = \u03bb b, h\u2082 b $ f $ h\u2081.symm b :=\nrfl\n\n@[simp] lemma Pi_congr'_symm_apply_symm_apply (f : \u03a0 b, Z b) (b : \u03b2) :\n  (h\u2081.Pi_congr' h\u2082).symm f (h\u2081.symm b) = (h\u2082 b).symm (f b) :=\nbegin\n  change cast _ ((h\u2082 (h\u2081 (h\u2081.symm b))).symm (f (h\u2081 (h\u2081.symm b)))) = (h\u2082 b).symm (f b),\n  generalize_proofs hWb,\n  revert hWb,\n  generalize hb : h\u2081 (h\u2081.symm b) = b',\n  rw h\u2081.apply_symm_apply b at hb,\n  subst hb,\n  simp,\nend\n\nend\n\nsection binary_op\n\nvariables {\u03b1\u2081 \u03b2\u2081 : Type*} (e : \u03b1\u2081 \u2243 \u03b2\u2081) (f : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 \u03b1\u2081)\n\nlemma semiconj_conj (f : \u03b1\u2081 \u2192 \u03b1\u2081) : semiconj e f (e.conj f) := \u03bb x, by simp\n\nlemma semiconj\u2082_conj : semiconj\u2082 e f (e.arrow_congr e.conj f) := \u03bb x y, by simp\n\ninstance [is_associative \u03b1\u2081 f] :\n  is_associative \u03b2\u2081 (e.arrow_congr (e.arrow_congr e) f) :=\n(e.semiconj\u2082_conj f).is_associative_right e.surjective\n\ninstance [is_idempotent \u03b1\u2081 f] :\n  is_idempotent \u03b2\u2081 (e.arrow_congr (e.arrow_congr e) f) :=\n(e.semiconj\u2082_conj f).is_idempotent_right e.surjective\n\ninstance [is_left_cancel \u03b1\u2081 f] :\n  is_left_cancel \u03b2\u2081 (e.arrow_congr (e.arrow_congr e) f) :=\n\u27e8e.surjective.forall\u2083.2 $ \u03bb x y z, by simpa using @is_left_cancel.left_cancel _ f _ x y z\u27e9\n\ninstance [is_right_cancel \u03b1\u2081 f] :\n  is_right_cancel \u03b2\u2081 (e.arrow_congr (e.arrow_congr e) f) :=\n\u27e8e.surjective.forall\u2083.2 $ \u03bb x y z, by simpa using @is_right_cancel.right_cancel _ f _ x y z\u27e9\n\nend binary_op\n\nend equiv\n\nlemma function.injective.swap_apply [decidable_eq \u03b1] [decidable_eq \u03b2] {f : \u03b1 \u2192 \u03b2}\n  (hf : function.injective f) (x y z : \u03b1) :\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 \u03b1] [decidable_eq \u03b2] {f : \u03b1 \u2192 \u03b2}\n  (hf : function.injective f) (x y : \u03b1) :\n  equiv.swap (f x) (f y) \u2218 f = f \u2218 equiv.swap x y :=\nfunext $ \u03bb z, hf.swap_apply _ _ _\n\n/-- If `\u03b1` is a subsingleton, then it is equivalent to `\u03b1 \u00d7 \u03b1`. -/\ndef subsingleton_prod_self_equiv {\u03b1 : Type*} [subsingleton \u03b1] : \u03b1 \u00d7 \u03b1 \u2243 \u03b1 :=\n{ to_fun := \u03bb p, p.1,\n  inv_fun := \u03bb a, (a, a),\n  left_inv := \u03bb p, subsingleton.elim _ _,\n  right_inv := \u03bb 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 \u03b1] [subsingleton \u03b2]\n  (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) : \u03b1 \u2243 \u03b2 :=\n{ to_fun := f,\n  inv_fun := g,\n  left_inv := \u03bb _, subsingleton.elim _ _,\n  right_inv := \u03bb _, subsingleton.elim _ _ }\n\n/-- A nonempty subsingleton type is (noncomputably) equivalent to `punit`. -/\nnoncomputable\ndef equiv.punit_of_nonempty_of_subsingleton {\u03b1 : Sort*} [h : nonempty \u03b1] [subsingleton \u03b1] :\n  \u03b1 \u2243 punit.{v} :=\nequiv_of_subsingleton_of_subsingleton\n (\u03bb _, punit.star) (\u03bb _, h.some)\n\n/-- `unique (unique \u03b1)` is equivalent to `unique \u03b1`. -/\ndef unique_unique_equiv : unique (unique \u03b1) \u2243 unique \u03b1 :=\nequiv_of_subsingleton_of_subsingleton (\u03bb h, h.default)\n  (\u03bb h, { default := h, uniq := \u03bb _, subsingleton.elim _ _ })\n\nnamespace function\n\nlemma update_comp_equiv {\u03b1 \u03b2 \u03b1' : Sort*} [decidable_eq \u03b1'] [decidable_eq \u03b1] (f : \u03b1 \u2192 \u03b2) (g : \u03b1' \u2243 \u03b1)\n  (a : \u03b1) (v : \u03b2) :\n  update f a v \u2218 g = update (f \u2218 g) (g.symm a) v :=\nby rw [\u2190 update_comp_eq_of_injective _ g.injective, g.apply_symm_apply]\n\nlemma update_apply_equiv_apply {\u03b1 \u03b2 \u03b1' : Sort*} [decidable_eq \u03b1'] [decidable_eq \u03b1]\n  (f : \u03b1 \u2192 \u03b2) (g : \u03b1' \u2243 \u03b1) (a : \u03b1) (v : \u03b2) (a' : \u03b1') :\n  update f a v (g a') = update (f \u2218 g) (g.symm a) v a' :=\ncongr_fun (update_comp_equiv f g a v) a'\n\nlemma Pi_congr_left'_update [decidable_eq \u03b1] [decidable_eq \u03b2]\n  (P : \u03b1 \u2192 Sort*) (e : \u03b1 \u2243 \u03b2) (f : \u03a0 a, P a) (b : \u03b2) (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 \u03b1] [decidable_eq \u03b2]\n  (P : \u03b1 \u2192 Sort*) (e : \u03b1 \u2243 \u03b2) (f : \u03a0 b, P (e.symm b)) (b : \u03b2) (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\u2082\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, \u03c0 := 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, \u03b9 := 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 \u27f6 Y`. -/\ndef is_terminal.of_unique (Y : C) [h : \u03a0 X : C, unique (X \u27f6 Y)] : is_terminal Y :=\n{ lift := \u03bb s, (h s.X).default }\n\n/-- If `\u03b1` is a preorder with top, then `\u22a4` is a terminal object. -/\ndef is_terminal_top {\u03b1 : Type*} [preorder \u03b1] [order_top \u03b1] : is_terminal (\u22a4 : \u03b1) :=\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 \u2245 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 \u27f6 Y`. -/\ndef is_initial.of_unique (X : C) [h : \u03a0 Y : C, unique (X \u27f6 Y)] : is_initial X :=\n{ desc := \u03bb s, (h s.X).default }\n\n/-- If `\u03b1` is a preorder with bot, then `\u22a5` is an initial object. -/\ndef is_initial_bot {\u03b1 : Type*} [preorder \u03b1] [order_bot \u03b1] : is_initial (\u22a5 : \u03b1) :=\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 \u2245 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 \u27f6 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 \u27f6 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 \u27f6 Y) :\n  f \u226b 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 = \ud835\udfd9 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 \u27f6 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 \u27f6 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 \u27f6 Z) :\n  t.to Y \u226b f = t.to Z :=\nt.hom_ext _ _\n\n@[simp] lemma is_initial.to_self {X : C} (t : is_initial X) : t.to X = \ud835\udfd9 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 \u27f6 Y) : split_mono f :=\n\u27e8t.from _, t.hom_ext _ _\u27e9\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 \u27f6 X) : split_epi f :=\n\u27e8t.to _, t.hom_ext _ _\u27e9\n\n/-- Any morphism from a terminal object is mono. -/\nlemma is_terminal.mono_from {X Y : C} (t : is_terminal X) (f : X \u27f6 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 \u27f6 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 \u2245 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 \u2245 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 `\u22a4_ 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 `\u22a5_ 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 `\u22a4_ ` C:20 := terminal C\nnotation `\u22a5_ ` 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 : \u03a0 Y : C, unique (Y \u27f6 X)] : has_terminal C :=\n{ has_limit := \u03bb F, has_limit.mk\n  { cone     := { X := X, \u03c0 := { app := pempty.rec _ } },\n    is_limit := { lift := \u03bb 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 : \u03a0 Y : C, unique (X \u27f6 Y)] : has_initial C :=\n{ has_colimit := \u03bb F, has_colimit.mk\n  { cocone     := { X := X, \u03b9 := { app := pempty.rec _ } },\n    is_colimit := { desc := \u03bb 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 \u27f6 \u22a4_ 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) : \u22a5_ C \u27f6 P :=\ncolimit.desc (functor.empty C) (as_empty_cocone P)\n\ninstance unique_to_terminal [has_terminal C] (P : C) : unique (P \u27f6 \u22a4_ C) :=\n{ default := terminal.from P,\n  uniq := \u03bb m, by { apply limit.hom_ext, rintro \u27e8\u27e9 } }\n\ninstance unique_from_initial [has_initial C] (P : C) : unique (\u22a5_ C \u27f6 P) :=\n{ default := initial.to P,\n  uniq := \u03bb m, by { apply colimit.hom_ext, rintro \u27e8\u27e9 } }\n\n@[simp] lemma terminal.comp_from [has_terminal C] {P Q : C} (f : P \u27f6 Q) :\n  f \u226b terminal.from Q = terminal.from P :=\nby tidy\n@[simp] lemma initial.to_comp [has_initial C] {P Q : C} (f : P \u27f6 Q) :\n  initial.to P \u226b f = initial.to Q :=\nby tidy\n\n/-- A terminal object is terminal. -/\ndef terminal_is_terminal [has_terminal C] : is_terminal (\u22a4_ C) :=\n{ lift := \u03bb s, terminal.from _ }\n\n/-- An initial object is initial. -/\ndef initial_is_initial [has_initial C] : is_initial (\u22a5_ C) :=\n{ desc := \u03bb 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 : \u22a4_ C \u27f6 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 \u27f6 \u22a5_ 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 := \u03bb s, (t.to s.X.unop).op,\n  uniq' := \u03bb 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\u1d52\u1d56} (t : is_initial X) : is_terminal X.unop :=\n{ lift := \u03bb s, (t.to (opposite.op s.X)).unop,\n  uniq' := \u03bb 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 := \u03bb s, (t.from s.X.unop).op,\n  uniq' := \u03bb 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\u1d52\u1d56} (t : is_terminal X) : is_initial X.unop :=\n{ desc := \u03bb s, (t.from (opposite.op s.X)).unop,\n  uniq' := \u03bb 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 : \u2200 {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 \u27f6 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 : \u22a5_ C \u27f6 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 : \u2200 X, mono (hI.to X)) :\n  initial_mono_class C :=\n{ is_initial_mono_from := \u03bb I' X hI',\n  begin\n    rw hI'.hom_ext (hI'.to X) ((hI'.unique_up_to_iso hI).hom \u226b 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 : \u2200 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 (\u03bb X, mono_of_mono_fac (hI.hom_ext (_ \u226b 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 (\u22a4_ 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\u2082} [category.{v} D] (G : C \u2964 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 (\u22a4_ C) \u27f6 \u22a4_ 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  \u22a5_ D \u27f6 G.obj (\u22a5_ C) :=\ninitial.to _\n\nend comparison\n\nvariables {J : Type v} [small_category J]\n\n/-- From a functor `F : J \u2964 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 \u2964 C) : cone F :=\n{ X := F.obj X,\n  \u03c0 :=\n  { app := \u03bb j, F.map (tX.to j),\n    naturality' := \u03bb j j' k,\n    begin\n      dsimp,\n      rw [\u2190 F.map_comp, category.id_comp, tX.hom_ext (tX.to j \u226b k) (tX.to j')],\n    end } }\n\n/-- From a functor `F : J \u2964 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 \u2964 C) :\nis_limit (cone_of_diagram_initial tX F) :=\n{ lift := \u03bb s, s.\u03c0.app X,\n  uniq' := \u03bb s m w,\n    begin\n      rw [\u2190 w X, cone_of_diagram_initial_\u03c0_app, tX.hom_ext (tX.to X) (\ud835\udfd9 _)],\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 \u2964 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 \u2964 C)\n  [has_initial J] [has_limit F] :\nlimit F \u2245 F.obj (\u22a5_ 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 \u2964 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 \u2964 C) [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : cone F :=\n{ X := F.obj X,\n  \u03c0 :=\n  { app := \u03bb 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        \u2190 F.map_comp, hX.hom_ext (hX.from i) (f \u226b hX.from j)],\n    end } }\n\n/-- From a functor `F : J \u2964 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 \u2964 C) [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] :\n  is_limit (cone_of_diagram_terminal hX F) :=\n{ lift := \u03bb S, S.\u03c0.app _ }\n\n-- This is reducible to allow usage of lemmas about `cone_point_unique_up_to_iso`.\n/-- For a functor `F : J \u2964 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 \u2964 C)\n  [has_terminal J] [has_limit F] [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] :\nlimit F \u2245 F.obj (\u22a4_ 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 \u2964 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 \u2964 C) : cocone F :=\n{ X := F.obj X,\n  \u03b9 :=\n  { app := \u03bb j, F.map (tX.from j),\n    naturality' := \u03bb j j' k,\n    begin\n      dsimp,\n      rw [\u2190 F.map_comp, category.comp_id, tX.hom_ext (k \u226b tX.from j') (tX.from j)],\n    end } }\n\n/-- From a functor `F : J \u2964 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 \u2964 C) :\nis_colimit (cocone_of_diagram_terminal tX F) :=\n{ desc := \u03bb s, s.\u03b9.app X,\n  uniq' := \u03bb s m w,\n    by { rw [\u2190 w X, cocone_of_diagram_terminal_\u03b9_app, tX.hom_ext (tX.from X) (\ud835\udfd9 _)], simp } }\n\n-- This is reducible to allow usage of lemmas about `cocone_point_unique_up_to_iso`.\n/-- For a functor `F : J \u2964 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 \u2964 C)\n  [has_terminal J] [has_colimit F] :\ncolimit F \u2245 F.obj (\u22a4_ 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 \u2964 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 \u2964 C)\n  [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : cocone F :=\n{ X := F.obj X,\n  \u03b9 :=\n  { app := \u03bb 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        \u2190 F.map_comp, hX.hom_ext (hX.to i \u226b f) (hX.to j)],\n    end } }\n\n/-- From a functor `F : J \u2964 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 \u2964 C)\n  [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_colimit (cocone_of_diagram_initial hX F) :=\n{ desc := \u03bb S, S.\u03b9.app _ }\n\n-- This is reducible to allow usage of lemmas about `cocone_point_unique_up_to_iso`.\n/-- For a functor `F : J \u2964 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 \u2964 C)\n  [has_initial J] [has_colimit F] [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] :\ncolimit F \u2245 F.obj (\u22a5_ 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.\u03c0 F j` is an isomorphism.\n-/\nlemma is_iso_\u03c0_of_is_initial {j : J} (I : is_initial j) (F : J \u2964 C) [has_limit F] :\n  is_iso (limit.\u03c0 F j) :=\n\u27e8\u27e8limit.lift _ (cone_of_diagram_initial I F), \u27e8by { ext, simp }, by simp\u27e9\u27e9\u27e9\n\ninstance is_iso_\u03c0_initial [has_initial J] (F : J \u2964 C) [has_limit F] :\n  is_iso (limit.\u03c0 F (\u22a5_ J)) :=\nis_iso_\u03c0_of_is_initial (initial_is_initial) F\n\nlemma is_iso_\u03c0_of_is_terminal {j : J} (I : is_terminal j) (F : J \u2964 C)\n  [has_limit F] [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_iso (limit.\u03c0 F j) :=\n\u27e8\u27e8limit.lift _ (cone_of_diagram_terminal I F), by { ext, simp }, by simp \u27e9\u27e9\n\ninstance is_iso_\u03c0_terminal [has_terminal J] (F : J \u2964 C) [has_limit F]\n  [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_iso (limit.\u03c0 F (\u22a4_ J)) :=\nis_iso_\u03c0_of_is_terminal terminal_is_terminal F\n\n/--\nIf `j` is terminal in the index category, then the map `colimit.\u03b9 F j` is an isomorphism.\n-/\nlemma is_iso_\u03b9_of_is_terminal {j : J} (I : is_terminal j) (F : J \u2964 C) [has_colimit F] :\n  is_iso (colimit.\u03b9 F j) :=\n\u27e8\u27e8colimit.desc _ (cocone_of_diagram_terminal I F), \u27e8by simp, by { ext, simp }\u27e9\u27e9\u27e9\n\ninstance is_iso_\u03b9_terminal [has_terminal J] (F : J \u2964 C) [has_colimit F] :\n  is_iso (colimit.\u03b9 F (\u22a4_ J)) :=\nis_iso_\u03b9_of_is_terminal (terminal_is_terminal) F\n\nlemma is_iso_\u03b9_of_is_initial {j : J} (I : is_initial j) (F : J \u2964 C)\n  [has_colimit F] [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_iso (colimit.\u03b9 F j) :=\n\u27e8\u27e8colimit.desc _ (cocone_of_diagram_initial I F), \u27e8by tidy, by { ext, simp }\u27e9\u27e9\u27e9\n\ninstance is_iso_\u03b9_initial [has_initial J] (F : J \u2964 C) [has_colimit F]\n  [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_iso (colimit.\u03b9 F (\u22a5_ J)) :=\nis_iso_\u03b9_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 : \u211d\u22650}\n\n/--  This is the same `r` as before. -/\n-- def r : \u211d\u22650 := 2\u207b\u00b9 ^ (p:\u211d)\n\n-- lemma r_pos : 0 < r :=\n-- suffices 0 < (2 : \u211d\u22650)\u207b\u00b9 ^ (p : \u211d), 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 : \u211d\u22650} [fact (0 < r)] [fact (r < 1)]\n\nlocal notation `\u2112` := laurent_measures r\n\nvariables {S : Fintype}\n\n-- /--  Let `F : \u2112 S` be a Laurent measure.  `laurent_measures.d` chooses a bound `d \u2208 \u2124` 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 : \u2112 S) : \u2124 :=\n-- (exists_bdd_filtration (fact.out _ : 0 < r) (fact.out _ : r < 1) F).some\n\n-- lemma lt_d_eq_zero (F : \u2112 S) (s : S) (n : \u2124) :\n--   n < F.d \u2192 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 : \u211d\u22650) (S : Fintype) :=\n(to_fun    : S \u2192 \u2124 \u2192 \u2124)\n(d         : \u2124)\n(summable' : \u2200 s, summable (\u03bb n : \u2115, \u2225to_fun s n\u2225\u208a * r ^ n))\n(zero_lt_d : \u2200 s n, n < d \u2192 to_fun s n = 0)\n\n/--  A \"usual\" Laurent Measure `F : \u2112 S` gives rise to a Simple Laurent Measure of type `slm S`. -/\ndef _root_.laurent_measures.to_slm (F : \u2112 S) : slm r S :=\n{ to_fun    := F.to_fun,\n  d         := F.d,\n  zero_lt_d := \u03bb n s, lt_d_eq_zero F _ _,\n  summable' := begin\n    refine \u03bb s, summable_coe.mp _,\n    convert ((@int_summable_iff _ _ _ _ _ (\u03bb (n : \u2124), \u2225F.to_fun s n\u2225 * 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 `\u2112 S`. -/\n--  The \"main\" input is `int_summable_iff`, proving that a series over `\u2124` is summable if and only\n--  if both its restrictions to `\u2115` and to \"`-\u2115`\" are summable.\ndef slm.to_laurent_measures {r : \u211d\u22650} (F : slm r S) : laurent_measures r S :=\n{ to_fun := F.to_fun,\n  summable' := begin\n    refine \u03bb s, summable_coe.mp _,\n    convert ((@int_summable_iff _ _ _ _ _ (\u03bb (n : \u2124), \u2225F.to_fun s n\u2225 * r ^ n)).mpr _),\n    refine \u27e8_, summable_of_eventually_zero (\u03bb (n : \u2124), \u2225F.to_fun s n\u2225 * \u2191r ^ n) F.d (\u03bb n nd, _)\u27e9,\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 : \u211d\u22650} (F : slm r S) : F.to_fun = F.to_laurent_measures.to_fun := rfl\n\nlemma lm_slm_to_fun_eq (F : \u2112 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 \u2192 Prop) (a b: A) (pa: p a) (pb: p b) : (\u27e8a, pa\u27e9: {a//p a}) = (\u27e8b, pb\u27e9: {b//p b}) \u2192 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' : \u2200 {x : X}, x \u2208 carrier \u2192 sorry \u2208 carrier)\n\nnamespace my_subobject\n\nvariables {X : Type*} [object_typeclass X] {x : X}\n\ninstance : set_like (my_subobject X) X :=\n\u27e8my_subobject.carrier, \u03bb p q h, by cases p; cases q; congr'\u27e9\n\n@[simp] lemma mem_carrier {p : my_subobject X} : x \u2208 p.carrier \u2194 x \u2208 (p : set X) := iff.rfl\n\n@[ext] theorem ext {p q : my_subobject X} (h : \u2200 x, x \u2208 p \u2194 x \u2208 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 = \u2191p) : my_subobject X :=\n{ carrier := s,\n  op_mem' := hs.symm \u25b8 p.op_mem' }\n\n@[simp] lemma coe_copy (p : my_subobject X) (s : set X) (hs : s = \u2191p) :\n  (p.copy s hs : set X) = s := rfl\n\nlemma copy_eq (p : my_subobject X) (s : set X) (hs : s = \u2191p) : 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 (\u03b1 : out_param $ Type u) (\u03b2 : Type v) extends has_mem \u03b1 \u03b2 :=\n(ext_iff : \u2200 {s t : \u03b2}, s = t \u2194 \u2200 (x : \u03b1), x \u2208 s \u2194 x \u2208 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 \u2208 p.carrier \u2194 x \u2208 (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 \u2192 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) := \u27e8set_like.coe\u27e9\n\n@[priority 100]\ninstance : has_mem B A := \u27e8\u03bb x p, x \u2208 (p : set B)\u27e9\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* := \u27e8\u03bb p, {x : B // x \u2208 p}\u27e9\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 \u00abexists\u00bb {q : p \u2192 Prop} :\n  (\u2203 x, q x) \u2194 (\u2203 x \u2208 p, q \u27e8x, \u2039_\u203a\u27e9) := set_coe.exists\n\nprotected theorem \u00abforall\u00bb {q : p \u2192 Prop} :\n  (\u2200 x, q x) \u2194 (\u2200 x \u2208 p, q \u27e8x, \u2039_\u203a\u27e9) := set_coe.forall\n\ntheorem coe_injective : function.injective (coe : A \u2192 set B) :=\n\u03bb 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 \u2194 (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 : \u2200 x, x \u2208 p \u2194 x \u2208 q) : p = q := coe_injective $ set.ext h\n\ntheorem ext_iff : p = q \u2194 (\u2200 x, x \u2208 p \u2194 x \u2208 q) := coe_injective.eq_iff.symm.trans set.ext_iff\n\n@[simp] theorem mem_coe {x : B} : x \u2208 (p : set B) \u2194 x \u2208 p := iff.rfl\n\n@[simp, norm_cast] lemma coe_eq_coe {x y : p} : (x : B) = y \u2194 x = y := subtype.ext_iff_val.symm\n\n@[simp, norm_cast] lemma coe_mk (x : B) (hx : x \u2208 p) : ((\u27e8x, hx\u27e9 : p) : B) = x := rfl\n@[simp] lemma coe_mem (x : p) : (x : B) \u2208 p := x.2\n\n@[simp] protected lemma eta (x : p) (hx : (x : B) \u2208 p) : (\u27e8x, hx\u27e9 : 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 := \u03bb H K, \u2200 \u2983x\u2984, x \u2208 H \u2192 x \u2208 K,\n  .. partial_order.lift (coe : A \u2192 set B) coe_injective }\n\nlemma le_def {S T : A} : S \u2264 T \u2194 \u2200 \u2983x : B\u2984, x \u2208 S \u2192 x \u2208 T := iff.rfl\n\n@[simp, norm_cast]\nlemma coe_subset_coe {S T : A} : (S : set B) \u2286 T \u2194 S \u2264 T := iff.rfl\n\n@[mono] lemma coe_mono : monotone (coe : A \u2192 set B) := \u03bb a b, coe_subset_coe.mpr\n\n@[simp, norm_cast]\nlemma coe_ssubset_coe {S T : A} : (S : set B) \u2282 T \u2194 S < T := iff.rfl\n\n@[mono] lemma coe_strict_mono : strict_mono (coe : A \u2192 set B) := \u03bb a b, coe_ssubset_coe.mpr\n\nlemma not_le_iff_exists : \u00ac(p \u2264 q) \u2194 \u2203 x \u2208 p, x \u2209 q := set.not_subset\n\nlemma exists_of_lt : p < q \u2192 \u2203 x \u2208 q, x \u2209 p := set.exists_of_ssubset\n\nlemma lt_iff_le_and_exists : p < q \u2194 p \u2264 q \u2227 \u2203 x \u2208 q, x \u2209 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 `\u03b1 \u00d7 \u03b2` but where the type of the second component\ndepends on the first component. This can be seen as a generalization of the sum type `\u03b1 \u2295 \u03b2`:\n* `\u03b1 \u2295 \u03b2` is made of stuff which is either of type `\u03b1` or `\u03b2`.\n* Given `\u03b1 : \u03b9 \u2192 Type*`, `sigma \u03b1` is made of stuff which is of type `\u03b1 i` for some `i : \u03b9`. One\n  effectively recovers a type isomorphic to `\u03b1 \u2295 \u03b2` by taking a `\u03b9` with exactly two elements. See\n  `equiv.sum_equiv_sigma_bool`.\n\n`\u03a3 x, A x` is notation for `sigma A` (note the difference with the big operator `\u2211`).\n`\u03a3 x y z ..., A x y z ...` is notation for `\u03a3 x, \u03a3 y, \u03a3 z, ..., A x y z ...`. Here we have\n`\u03b1 : Type*`, `\u03b2 : \u03b1 \u2192 Type*`, `\u03b3 : \u03a0 a : \u03b1, \u03b2 a \u2192 Type*`, ...,\n`A : \u03a0 (a : \u03b1) (b : \u03b2 a) (c : \u03b3 a b) ..., Type*`  with `x : \u03b1` `y : \u03b2 x`, `z : \u03b3 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 {\u03b1 \u03b1\u2081 \u03b1\u2082 : Type*} {\u03b2 : \u03b1 \u2192 Type*} {\u03b2\u2081 : \u03b1\u2081 \u2192 Type*} {\u03b2\u2082 : \u03b1\u2082 \u2192 Type*}\n\nnamespace sigma\n\ninstance [inhabited \u03b1] [inhabited (\u03b2 default)] : inhabited (sigma \u03b2) :=\n\u27e8\u27e8default, default\u27e9\u27e9\n\ninstance [h\u2081 : decidable_eq \u03b1] [h\u2082 : \u2200a, decidable_eq (\u03b2 a)] : decidable_eq (sigma \u03b2)\n| \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 := match a\u2081, b\u2081, a\u2082, b\u2082, h\u2081 a\u2081 a\u2082 with\n  | _, b\u2081, _, b\u2082, is_true (eq.refl a) :=\n    match b\u2081, b\u2082, h\u2082 a b\u2081 b\u2082 with\n    | _, _, is_true (eq.refl b) := is_true rfl\n    | b\u2081, b\u2082, is_false n := is_false (assume h, sigma.no_confusion h (\u03bbe\u2081 e\u2082, n $ eq_of_heq e\u2082))\n    end\n  | a\u2081, _, a\u2082, _, is_false n := is_false (assume h, sigma.no_confusion h (\u03bbe\u2081 e\u2082, n e\u2081))\n  end\n\n@[simp, nolint simp_nf] -- sometimes the built-in injectivity support does not work\ntheorem mk.inj_iff {a\u2081 a\u2082 : \u03b1} {b\u2081 : \u03b2 a\u2081} {b\u2082 : \u03b2 a\u2082} :\n  sigma.mk a\u2081 b\u2081 = \u27e8a\u2082, b\u2082\u27e9 \u2194 (a\u2081 = a\u2082 \u2227 b\u2081 == b\u2082) :=\nby simp\n\n@[simp] theorem eta : \u2200 x : \u03a3 a, \u03b2 a, sigma.mk x.1 x.2 = x\n| \u27e8i, x\u27e9 := rfl\n\n@[ext]\nlemma ext {x\u2080 x\u2081 : sigma \u03b2} (h\u2080 : x\u2080.1 = x\u2081.1) (h\u2081 : x\u2080.2 == x\u2081.2) : x\u2080 = x\u2081 :=\nby { cases x\u2080, cases x\u2081, cases h\u2080, cases h\u2081, refl }\n\nlemma ext_iff {x\u2080 x\u2081 : sigma \u03b2} : x\u2080 = x\u2081 \u2194 x\u2080.1 = x\u2081.1 \u2227 x\u2080.2 == x\u2081.2 :=\nby { cases x\u2080, cases x\u2081, 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 {\u03b2 : Type*} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  \u2200 {x\u2080 x\u2081 : \u03a3 a, subtype (p a)}, x\u2080.fst = x\u2081.fst \u2192 (x\u2080.snd : \u03b2) = x\u2081.snd \u2192 x\u2080 = x\u2081\n| \u27e8a\u2080, b\u2080, hb\u2080\u27e9 \u27e8a\u2081, b\u2081, hb\u2081\u27e9 rfl rfl := rfl\n\nlemma subtype_ext_iff {\u03b2 : Type*} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} {x\u2080 x\u2081 : \u03a3 a, subtype (p a)} :\n  x\u2080 = x\u2081 \u2194 x\u2080.fst = x\u2081.fst \u2227 (x\u2080.snd : \u03b2) = x\u2081.snd :=\n\u27e8\u03bb h, h \u25b8 \u27e8rfl, rfl\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, subtype_ext h\u2081 h\u2082\u27e9\n\n@[simp] theorem \u00abforall\u00bb {p : (\u03a3 a, \u03b2 a) \u2192 Prop} :\n  (\u2200 x, p x) \u2194 (\u2200 a b, p \u27e8a, b\u27e9) :=\n\u27e8assume h a b, h \u27e8a, b\u27e9, assume h \u27e8a, b\u27e9, h a b\u27e9\n\n@[simp] theorem \u00abexists\u00bb {p : (\u03a3 a, \u03b2 a) \u2192 Prop} :\n  (\u2203 x, p x) \u2194 (\u2203 a b, p \u27e8a, b\u27e9) :=\n\u27e8assume \u27e8\u27e8a, b\u27e9, h\u27e9, \u27e8a, b, h\u27e9, assume \u27e8a, b, h\u27e9, \u27e8\u27e8a, b\u27e9, h\u27e9\u27e9\n\n/-- Map the left and right components of a sigma -/\ndef map (f\u2081 : \u03b1\u2081 \u2192 \u03b1\u2082) (f\u2082 : \u03a0a, \u03b2\u2081 a \u2192 \u03b2\u2082 (f\u2081 a)) (x : sigma \u03b2\u2081) : sigma \u03b2\u2082 :=\n\u27e8f\u2081 x.1, f\u2082 x.1 x.2\u27e9\n\nend sigma\n\nlemma sigma_mk_injective {i : \u03b1} : function.injective (@sigma.mk \u03b1 \u03b2 i)\n| _ _ rfl := rfl\n\nlemma function.injective.sigma_map {f\u2081 : \u03b1\u2081 \u2192 \u03b1\u2082} {f\u2082 : \u03a0a, \u03b2\u2081 a \u2192 \u03b2\u2082 (f\u2081 a)}\n  (h\u2081 : function.injective f\u2081) (h\u2082 : \u2200 a, function.injective (f\u2082 a)) :\n  function.injective (sigma.map f\u2081 f\u2082)\n| \u27e8i, x\u27e9 \u27e8j, y\u27e9 h :=\nbegin\n  have : i = j, from h\u2081 (sigma.mk.inj_iff.mp h).1,\n  subst j,\n  have : x = y, from h\u2082 i (eq_of_heq (sigma.mk.inj_iff.mp h).2),\n  subst y\nend\n\nlemma function.surjective.sigma_map {f\u2081 : \u03b1\u2081 \u2192 \u03b1\u2082} {f\u2082 : \u03a0a, \u03b2\u2081 a \u2192 \u03b2\u2082 (f\u2081 a)}\n  (h\u2081 : function.surjective f\u2081) (h\u2082 : \u2200 a, function.surjective (f\u2082 a)) :\n  function.surjective (sigma.map f\u2081 f\u2082) :=\nbegin\n  intros y,\n  cases y with j y,\n  cases h\u2081 j with i hi,\n  subst j,\n  cases h\u2082 i y with x hx,\n  subst y,\n  exact \u27e8\u27e8i, x\u27e9, rfl\u27e9\nend\n\n/-- Interpret a function on `\u03a3 x : \u03b1, \u03b2 x` as a dependent function with two arguments.\n\nThis also exists as an `equiv` as `equiv.Pi_curry \u03b3`. -/\ndef sigma.curry {\u03b3 : \u03a0 a, \u03b2 a \u2192 Type*} (f : \u03a0 x : sigma \u03b2, \u03b3 x.1 x.2) (x : \u03b1) (y : \u03b2 x) : \u03b3 x y :=\nf \u27e8x,y\u27e9\n\n/-- Interpret a dependent function with two arguments as a function on `\u03a3 x : \u03b1, \u03b2 x`.\n\nThis also exists as an `equiv` as `(equiv.Pi_curry \u03b3).symm`. -/\ndef sigma.uncurry {\u03b3 : \u03a0 a, \u03b2 a \u2192 Type*} (f : \u03a0 x (y : \u03b2 x), \u03b3 x y) (x : sigma \u03b2) : \u03b3 x.1 x.2 :=\nf x.1 x.2\n\n@[simp]\nlemma sigma.uncurry_curry {\u03b3 : \u03a0 a, \u03b2 a \u2192 Type*} (f : \u03a0 x : sigma \u03b2, \u03b3 x.1 x.2) :\n  sigma.uncurry (sigma.curry f) = f :=\nfunext $ \u03bb \u27e8i, j\u27e9, rfl\n\n@[simp]\nlemma sigma.curry_uncurry {\u03b3 : \u03a0 a, \u03b2 a \u2192 Type*} (f : \u03a0 x (y : \u03b2 x), \u03b3 x y) :\n  sigma.curry (sigma.uncurry f) = f :=\nrfl\n\n/-- Convert a product type to a \u03a3-type. -/\n@[simp]\ndef prod.to_sigma {\u03b1 \u03b2} : \u03b1 \u00d7 \u03b2 \u2192 \u03a3 _ : \u03b1, \u03b2\n| \u27e8x,y\u27e9 := \u27e8x,y\u27e9\n\n@[simp]\nlemma prod.fst_to_sigma {\u03b1 \u03b2} (x : \u03b1 \u00d7 \u03b2) : (prod.to_sigma x).fst = x.fst :=\nby cases x; refl\n\n@[simp]\nlemma prod.snd_to_sigma {\u03b1 \u03b2} (x : \u03b1 \u00d7 \u03b2) : (prod.to_sigma x).snd = x.snd :=\nby cases x; refl\n\nend sigma\n\nsection psigma\nvariables {\u03b1 : Sort*} {\u03b2 : \u03b1 \u2192 Sort*}\n\nnamespace psigma\n\n/-- Nondependent eliminator for `psigma`. -/\ndef elim {\u03b3} (f : \u2200 a, \u03b2 a \u2192 \u03b3) (a : psigma \u03b2) : \u03b3 :=\npsigma.cases_on a f\n\n@[simp] theorem elim_val {\u03b3} (f : \u2200 a, \u03b2 a \u2192 \u03b3) (a b) : psigma.elim f \u27e8a, b\u27e9 = f a b := rfl\n\ninstance [inhabited \u03b1] [inhabited (\u03b2 default)] : inhabited (psigma \u03b2) :=\n\u27e8\u27e8default, default\u27e9\u27e9\n\ninstance [h\u2081 : decidable_eq \u03b1] [h\u2082 : \u2200a, decidable_eq (\u03b2 a)] : decidable_eq (psigma \u03b2)\n| \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 := match a\u2081, b\u2081, a\u2082, b\u2082, h\u2081 a\u2081 a\u2082 with\n  | _, b\u2081, _, b\u2082, is_true (eq.refl a) :=\n    match b\u2081, b\u2082, h\u2082 a b\u2081 b\u2082 with\n    | _, _, is_true (eq.refl b) := is_true rfl\n    | b\u2081, b\u2082, is_false n := is_false (assume h, psigma.no_confusion h (\u03bbe\u2081 e\u2082, n $ eq_of_heq e\u2082))\n    end\n  | a\u2081, _, a\u2082, _, is_false n := is_false (assume h, psigma.no_confusion h (\u03bbe\u2081 e\u2082, n e\u2081))\n  end\n\ntheorem mk.inj_iff {a\u2081 a\u2082 : \u03b1} {b\u2081 : \u03b2 a\u2081} {b\u2082 : \u03b2 a\u2082} :\n  @psigma.mk \u03b1 \u03b2 a\u2081 b\u2081 = @psigma.mk \u03b1 \u03b2 a\u2082 b\u2082 \u2194 (a\u2081 = a\u2082 \u2227 b\u2081 == b\u2082) :=\niff.intro psigma.mk.inj $\n  assume \u27e8h\u2081, h\u2082\u27e9, match a\u2081, a\u2082, b\u2081, b\u2082, h\u2081, h\u2082 with _, _, _, _, eq.refl a, heq.refl b := rfl end\n\n@[ext]\nlemma ext {x\u2080 x\u2081 : psigma \u03b2} (h\u2080 : x\u2080.1 = x\u2081.1) (h\u2081 : x\u2080.2 == x\u2081.2) : x\u2080 = x\u2081 :=\nby { cases x\u2080, cases x\u2081, cases h\u2080, cases h\u2081, refl }\n\nlemma ext_iff {x\u2080 x\u2081 : psigma \u03b2} : x\u2080 = x\u2081 \u2194 x\u2080.1 = x\u2081.1 \u2227 x\u2080.2 == x\u2081.2 :=\nby { cases x\u2080, cases x\u2081, 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 {\u03b2 : Sort*} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  \u2200 {x\u2080 x\u2081 : \u03a3' a, subtype (p a)}, x\u2080.fst = x\u2081.fst \u2192 (x\u2080.snd : \u03b2) = x\u2081.snd \u2192 x\u2080 = x\u2081\n| \u27e8a\u2080, b\u2080, hb\u2080\u27e9 \u27e8a\u2081, b\u2081, hb\u2081\u27e9 rfl rfl := rfl\n\nlemma subtype_ext_iff {\u03b2 : Sort*} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} {x\u2080 x\u2081 : \u03a3' a, subtype (p a)} :\n  x\u2080 = x\u2081 \u2194 x\u2080.fst = x\u2081.fst \u2227 (x\u2080.snd : \u03b2) = x\u2081.snd :=\n\u27e8\u03bb h, h \u25b8 \u27e8rfl, rfl\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, subtype_ext h\u2081 h\u2082\u27e9\n\nvariables {\u03b1\u2081 : Sort*} {\u03b1\u2082 : Sort*} {\u03b2\u2081 : \u03b1\u2081 \u2192 Sort*} {\u03b2\u2082 : \u03b1\u2082 \u2192 Sort*}\n\n/-- Map the left and right components of a sigma -/\ndef map (f\u2081 : \u03b1\u2081 \u2192 \u03b1\u2082) (f\u2082 : \u03a0a, \u03b2\u2081 a \u2192 \u03b2\u2082 (f\u2081 a)) : psigma \u03b2\u2081 \u2192 psigma \u03b2\u2082\n| \u27e8a, b\u27e9 := \u27e8f\u2081 a, f\u2082 a b\u27e9\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 : \u2203 (S : Type w) (_ : small_category S), by exactI nonempty (C \u224c 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 \u224c 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 \u224c D) : essentially_small.{w} C \u2194 essentially_small.{w} D :=\nbegin\n  fsplit,\n  { rintro \u27e8S, \ud835\udcae, \u27e8f\u27e9\u27e9,\n    resetI,\n    exact essentially_small.mk' (e.symm.trans f), },\n  { rintro \u27e8S, \ud835\udcae, \u27e8f\u27e9\u27e9,\n    resetI,\n    exact essentially_small.mk' (e.trans f), },\nend\n\nlemma discrete.essentially_small_of_small {\u03b1 : Type u} [small.{w} \u03b1] :\n  essentially_small.{w} (discrete \u03b1) :=\n\u27e8\u27e8discrete (shrink \u03b1), \u27e8infer_instance, \u27e8discrete.equivalence (equiv_shrink _)\u27e9\u27e9\u27e9\u27e9\n\nlemma essentially_small_self : essentially_small.{max w v u} C :=\nessentially_small.mk' (as_small.equiv : C \u224c 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 : \u2200 X Y : C, small.{w} (X \u27f6 Y) . tactic.apply_instance)\n\ninstance (C : Type u) [category.{v} C] [locally_small.{w} C] (X Y : C) :\n  small (X \u27f6 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 \u224c D) : locally_small.{w} C \u2194 locally_small.{w} D :=\nbegin\n  fsplit,\n  { rintro \u27e8L\u27e9,\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 \u27e8L\u27e9,\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 := \u03bb X Y, shrink (from_shrink_homs X \u27f6 from_shrink_homs Y),\n  id := \u03bb X, equiv_shrink _ (\ud835\udfd9 (from_shrink_homs X)),\n  comp := \u03bb X Y Z f g,\n    equiv_shrink _ (((equiv_shrink _).symm f) \u226b ((equiv_shrink _).symm g)), }.\n\n/-- Implementation of `shrink_homs.equivalence`. -/\n@[simps]\nnoncomputable\ndef functor : C \u2964 shrink_homs C :=\n{ obj := \u03bb X, to_shrink_homs X,\n  map := \u03bb X Y f, equiv_shrink (X \u27f6 Y) f, }\n\n/-- Implementation of `shrink_homs.equivalence`. -/\n@[simps]\nnoncomputable\ndef inverse : shrink_homs C \u2964 C :=\n{ obj := \u03bb X, from_shrink_homs X,\n  map := \u03bb X Y f, (equiv_shrink (from_shrink_homs X \u27f6 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 \u224c shrink_homs C :=\nequivalence.mk (functor C) (inverse C)\n  (nat_iso.of_components (\u03bb X, iso.refl X) (by tidy))\n  (nat_iso.of_components (\u03bb 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 \u2194 small.{w} (skeleton C) \u2227 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 \u27e8S, \ud835\udcae, \u27e8e\u27e9\u27e9,\n      resetI,\n      refine \u27e8\u27e8skeleton S, \u27e8_\u27e9\u27e9\u27e9,\n      exact e.skeleton_equiv, },\n    { resetI, apply_instance, }, },\n  { rintro \u27e8\u27e8S, \u27e8e\u27e9\u27e9, L\u27e9,\n    resetI,\n    let e' := (shrink_homs.equivalence C).skeleton_equiv.symm,\n    refine \u27e8\u27e8S, _, \u27e8_\u27e9\u27e9\u27e9,\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 \u2194 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 {\u03b9 : Type*} [fintype \u03b9]\nvariables {\ud835\udd5c : Type*} [is_R_or_C \ud835\udd5c] {E : Type*} [inner_product_space \ud835\udd5c E]\nvariables {E' : Type*} [inner_product_space \ud835\udd5c E']\n\nvariables {m n : \u2115}\n\nlocal notation `\u27ea`x`, `y`\u27eb` := @inner \ud835\udd5c (euclidean_space \ud835\udd5c (fin m)) _ x y\n\nopen_locale matrix\n\nlemma inner_matrix_row_row (A : matrix (fin n) (fin m) \ud835\udd5c) (i j : (fin n)) :\n  \u27eaA i, A j\u27eb = (A \u2b1d A\u1d34) 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\u2093'. -/\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 \u2194 \u2203 e : R, IsIdempotentElem e \u2227 I = R \u2219 e :=\n  by\n  constructor\n  \u00b7 intro e\n    obtain \u27e8r, hr, hr'\u27e9 :=\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' \u27e8r, hr' r hr, antisymm _ ((Submodule.span_singleton_le_iff_mem _ _).mpr hr)\u27e9\n    intro x hx\n    rw [\u2190 hr' x hx]\n    exact ideal.mem_span_singleton'.mpr \u27e8_, mul_comm _ _\u27e9\n  \u00b7 rintro \u27e8e, he, rfl\u27e9\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\u2093'. -/\ntheorem isIdempotentElem_iff_eq_bot_or_top {R : Type _} [CommRing R] [IsDomain R] (I : Ideal R)\n    (h : I.Fg) : IsIdempotentElem I \u2194 I = \u22a5 \u2228 I = \u22a4 :=\n  by\n  constructor\n  \u00b7 intro H\n    obtain \u27e8e, he, rfl\u27e9 := (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  \u00b7 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\u2080 C\u2081 C\u2082 : A) -- object of objects, object of morphisms, object of composable pairs (i.e (f,g) where f \u2218 g makes sense)\n(trg src : C\u2081 \u27f6 C\u2080) -- get codomain and domain of morphisms\n(ident : C\u2080 \u27f6 C\u2081) -- get identity morphism on object\n(first_hom comp second_hom : C\u2082 \u27f6 C\u2081) -- decompose composite\n(comp_comm : first_hom \u226b src = second_hom \u226b trg)\n(comp_pb : is_limit (pullback_cone.mk _ _ comp_comm))\n(ident_trg : ident \u226b trg = \ud835\udfd9 C\u2080)\n(ident_src : ident \u226b src = \ud835\udfd9 C\u2080)\n(comp_trg : comp \u226b trg = first_hom \u226b trg)\n(comp_src : comp \u226b src = second_hom \u226b 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 \u27f6 Z) (g : Y \u27f6 Z)\n@[simp] lemma mk_fst {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n  (pullback_cone.mk fst snd eq).fst = fst := rfl\n@[simp] lemma mk_snd {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b 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 \u2218 g or g \u226b f makes sense), form the composable pair (f,g)\n\ndef make_pair {Q : A} (f g : Q \u27f6 c.C\u2081)\n  (composable : f \u226b c.src = g \u226b c.trg) :\nQ \u27f6 c.C\u2082 :=\n(pullback_cone.is_limit.lift' c.comp_pb _ _ composable).1\n\n@[simp, reassoc]\nlemma compose_l {Q : A} (f g : Q \u27f6 c.C\u2081)\n  (cmp : f \u226b c.src = g \u226b c.trg) :\nmake_pair c f g cmp \u226b 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 \u27f6 c.C\u2081)\n  (cmp : f \u226b c.src = g \u226b c.trg) :\nmake_pair c f g cmp \u226b 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 \u27f6 c.C\u2081) (h : Q \u27f6 R) (composable : f \u226b c.src = g \u226b c.trg) :\n  h \u226b make_pair c f g composable = make_pair c (h \u226b f) (h \u226b 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 \u2218 (g \u2218 h) makes sense\n(as should (f \u2218 g) \u2218 h)\nconstructed as the pullback of (f,g\u2081) and (g\u2082,h) where g\u2081 = g\u2082\n-/\ndef internal_category_struct.C\u2083 : A :=\npullback c.second_hom c.first_hom\n\nopen limits.pullback\n\n/-- The first pair `(f, g\u2081)` of the triple `(f, g\u2081 = g\u2082, h)` -/\nabbreviation internal_category_struct.left_pair : c.C\u2083 \u27f6 c.C\u2082 := fst\n/-- The second pair `(g\u2082, h)` of the triple `(f, g\u2081 = g\u2082, h)` -/\nabbreviation internal_category_struct.right_pair : c.C\u2083 \u27f6 c.C\u2082 := snd\n\n/-- The first homomorphism `f` of the triple `(f, g, h)` -/\nabbreviation internal_category_struct.trip_first_hom : c.C\u2083 \u27f6 c.C\u2081 := c.left_pair \u226b c.first_hom\n/-- The first homomorphism `h` of the triple `(f, g, h)` -/\nabbreviation internal_category_struct.trip_third_hom : c.C\u2083 \u27f6 c.C\u2081 := c.right_pair \u226b c.second_hom\n\n/-- Prove `g\u2081 = g\u2082` in the triple `(f, g\u2081 = g\u2082, h)` -/\n@[reassoc] lemma trip_snd_eq : c.left_pair \u226b c.second_hom = c.right_pair \u226b c.first_hom := condition\n\n/-- Map `(f, g, h)` to `(f \u2218 g, h)` -/\nabbreviation internal_category_struct.comp_left_pair : c.C\u2083 \u27f6 c.C\u2082 :=\nmake_pair c (c.left_pair \u226b 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 \u2218 h)` -/\nabbreviation internal_category_struct.comp_right_pair : c.C\u2083 \u27f6 c.C\u2082 :=\nmake_pair c c.trip_first_hom (c.right_pair \u226b c.comp) $\nby rw [assoc, assoc, c.comp_trg, c.comp_comm, trip_snd_eq_assoc]\n\nend\n-- def element {X : Type u} : (\u22a4_ (Type u) \u27f6 X) \u2243 X :=\n-- { to_fun := \u03bb f, f _,\n\n-- }\n-- -- { to_fun := \u03bb f, f \u27e8\u03bb t, t.elim, \u03bb t, t.elim\u27e9,\n-- --   inv_fun := \u03bb x _, x,\n-- --   left_inv := \u03bb f,\n-- --   begin\n-- --     ext1 \u27e8_, _\u27e9,\n-- --     dsimp,\n-- --     congr,\n-- --     ext \u27e8\u27e9,\n-- --   end,\n-- --   right_inv := \u03bb x, rfl }\n\n-- @[simp] lemma element_natural {X Y : Type u} (f : \u22a4_ _ \u27f6 X) (g : X \u27f6 Y) : element (f \u226b 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\u2080 :=\n-- { hom := \u03bb X Y, {h : c.C\u2081 // c.src h = Y \u2227 c.trg h = X},\n--   id := \u03bb X, \u27e8c.ident X, congr_fun c.ident_src X, congr_fun c.ident_trg X\u27e9,\n--   comp := \u03bb X Y Z f g,\n--   begin\n--     refine \u27e8_, _, _\u27e9,\n--     { refine element (make_pair c (element.symm \u2191f) (element.symm \u2191g) _ \u226b c.comp),\n--       rw \u2190 element.apply_eq_iff_eq,\n--       dsimp, rw [f.prop.1, g.prop.2] },\n--     { change (make_pair _ _ _ _ \u226b c.comp \u226b c.src) _ = Z,\n--       rw [c.comp_src, compose_r_assoc],\n--       exact g.prop.1 },\n--     { change (make_pair _ _ _ _ \u226b c.comp \u226b 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 _ \u226b comp = internal_category_struct.comp_right_pair _ \u226b comp)\n-- (id_comp : make_pair _ (\ud835\udfd9 _) (src \u226b ident) (by simp) \u226b comp = \ud835\udfd9 C\u2081)\n-- (comp_id : make_pair _ (trg \u226b ident) (\ud835\udfd9 _) (by simp) \u226b comp = \ud835\udfd9 C\u2081)\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\u2080 := C,\n--   C\u2081 := \u03a3 (X Y : C), X \u27f6 Y,\n--   C\u2082 := \u03a3 (X Y Z : C), (X \u27f6 Y) \u00d7 (Y \u27f6 Z),\n--   src := \u03bb f, f.1,\n--   trg := \u03bb f, f.2.1,\n--   ident := \u03bb x, \u27e8x, x, \ud835\udfd9 _\u27e9,\n--   first_hom := \u03bb x, \u27e8x.2.1, x.2.2.1, x.2.2.2.2\u27e9,\n--   comp := \u03bb x, \u27e8x.1, x.2.2.1, x.2.2.2.1 \u226b x.2.2.2.2\u27e9,\n--   second_hom := \u03bb x, \u27e8x.1, x.2.1, x.2.2.2.1\u27e9,\n--   comp_comm := rfl,\n--   comp_pb :=\n--   begin\n--     refine construct_type_pb _ _,\n--     rintros \u27e8Y, X, f\u27e9 \u27e8Z, Y, g\u27e9 _,\n--     dsimp at a, subst a,\n--     refine \u27e8\u27e8Z, Y, X, g, f\u27e9, rfl, rfl, _\u27e9,\n--     rintro \u27e8Z', Y', X', g', f'\u27e9 h\u2081 h\u2082,\n--     dsimp at h\u2081 h\u2082,\n--     cases h\u2081,\n--     cases h\u2082,\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 (\u03b1 : Type*) (n : \u2115) (t : \u03b1) := t\n\n-- def alt_pb (C : Type u) [category_struct.{u} C] := \u03a3 (W X Y Z : C), (W \u27f6 X) \u00d7 (X \u27f6 Y) \u00d7 (Y \u27f6 Z)\n-- def alt_\u03c0\u2081 (C : Type u) [category_struct.{u} C] :\n--   alt_pb C \u27f6 (internal_category_struct_type_of_category_struct C).C\u2082 :=\n-- begin\n--   intro x,\n--   refine \u27e8x.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\u27e9,\n-- end\n-- def alt_\u03c0\u2082 (C : Type u) [category_struct.{u} C] :\n--   alt_pb C \u27f6 (internal_category_struct_type_of_category_struct C).C\u2082 :=\n-- begin\n--   intro x,\n--   refine \u27e8x.1, x.2.1, x.2.2.1, x.2.2.2.2.1, x.2.2.2.2.2.1\u27e9,\n-- end\n\n-- lemma alt_comm (C : Type u) [category_struct.{u} C] :\n--   alt_\u03c0\u2081 C \u226b (internal_category_struct_type_of_category_struct C).second_hom = alt_\u03c0\u2082 C \u226b (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 \u27e8X, Y, Z, f, g\u27e9 \u27e8W, X, Y, h, f\u27e9 _,\n--   dsimp [internal_category_struct_type_of_category_struct] at a,\n--   injection a with a\u2081 a\u2082,\n--   subst a\u2081,\n--   rw heq_iff_eq at a\u2082,\n--   injection a\u2082 with a\u2083 a\u2084,\n--   subst a\u2083,\n--   rw heq_iff_eq at a\u2084,\n--   subst a\u2084,\n--   refine \u27e8\u27e8_, _, _, _, h, f, g\u27e9, _, _, _\u27e9,\n--   refl,\n--   refl,\n--   rintro \u27e8_, _, _, _, _, _, _\u27e9 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\u2083 (C : Type u) [category_struct.{u} C] : alt_pb C \u2245 (internal_category_struct_type_of_category_struct C).C\u2083 :=\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 \u27e8X, Y, f\u27e9,\n--     change (\u27e8_, _, _\u27e9 : \u03a3 (X Y : C), X \u27f6 Y) = _,\n--     congr' 2,\n--     apply id_comp,\n--   end,\n--   comp_id :=\n--   begin\n--     ext1 \u27e8X, Y, f\u27e9,\n--     change (\u27e8X, Y, f \u226b \ud835\udfd9 _\u27e9 : \u03a3 (X Y : C), X \u27f6 Y) = (\u27e8X, Y, f\u27e9 : \u03a3 (X Y : C), X \u27f6 Y),\n--     congr' 2,\n--     apply comp_id,\n--   end,\n--   assoc :=\n--   begin\n--     haveI := is_iso.of_iso (to_C\u2083 C),\n--     rw [\u2190 cancel_epi (to_C\u2083 C).hom, compose_natural_assoc, compose_natural_assoc],\n--     change make_pair _ (pullback.lift _ _ _ \u226b pullback.fst \u226b _) (pullback.lift _ _ _ \u226b pullback.snd \u226b _) _ \u226b _ =\n--            make_pair _ (pullback.lift _ _ _ \u226b pullback.fst \u226b _) (pullback.lift _ _ _ \u226b pullback.snd \u226b _) _ \u226b _,\n--     simp_rw [pullback.lift_fst_assoc, pullback.lift_snd_assoc],\n--     ext1 \u27e8W, X, Y, Z, f, g, h\u27e9,\n--     change (\u27e8W, Z, f \u226b g \u226b h\u27e9 : \u03a3 (X Y : C), X \u27f6 Y) = (\u27e8W, Z, (f \u226b g) \u226b h\u27e9 : \u03a3 (X Y : C), X \u27f6 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\u2080 :=\n-- { comp_id' :=\n--   begin\n--     rintros X Y \u27e8f, rfl, rfl\u27e9,\n--     ext1,\n--     change element (make_pair _ (element.symm f) _ _ \u226b c.comp) = f,\n--     equiv_rw (@element c.C\u2081).symm at f,\n--     rw equiv.apply_eq_iff_eq,\n--     change make_pair c.to_internal_category_struct f (element.symm (element ((f \u226b c.src) \u226b c.ident))) _ \u226b c.comp = _,\n--     simp_rw [equiv.symm_apply_apply, assoc],\n--     have := f \u226b= 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 \u27e8f, rfl, rfl\u27e9,\n--     ext1,\n--     change element (make_pair _ _ (element.symm f) _ \u226b c.comp) = f,\n--     equiv_rw (@element c.C\u2081).symm at f,\n--     rw equiv.apply_eq_iff_eq,\n--     change make_pair c.to_internal_category_struct (element.symm (element ((f \u226b c.trg) \u226b c.ident))) f _ \u226b c.comp = _,\n--     simp_rw [equiv.symm_apply_apply, assoc],\n--     have := f \u226b= 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 \u27e8f, rfl, rfl\u27e9 \u27e8g, rfl, fg\u27e9 \u27e8h, rfl, gh\u27e9,\n--     ext1,\n--     equiv_rw (@element c.C\u2081).symm at f,\n--     equiv_rw (@element c.C\u2081).symm at g,\n--     equiv_rw (@element c.C\u2081).symm at h,\n--     change element (make_pair _ _ _ _ \u226b c.comp) = element (make_pair _ _ _ _ \u226b 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)) _ \u226b c.comp))) (element.symm (element h)) _ \u226b c.comp =\n--            make_pair _ (element.symm (element f)) (element.symm (element (make_pair _ (element.symm (element g)) (element.symm (element h)) _ \u226b c.comp))) _ \u226b c.comp,\n--     simp_rw [equiv.symm_apply_apply],\n--     change make_pair _ (make_pair _ f g _ \u226b c.comp) h _ \u226b c.comp = make_pair _ f (make_pair _ g h _ \u226b c.comp) _ \u226b c.comp,\n--     have := pullback.lift (make_pair _ f g _) (make_pair _ g h _) _ \u226b= c.assoc,\n--       rotate,\n--       { rw [equiv.symm_symm, \u2190 element_natural _ c.trg, \u2190 element_natural _ c.src, equiv.apply_eq_iff_eq] at fg,\n--         rw fg },\n--       { rw [equiv.symm_symm, \u2190 element_natural _ c.trg, \u2190 element_natural _ c.src, equiv.apply_eq_iff_eq] at gh,\n--         rw gh },\n--       { rw [compose_l, compose_r] },\n--     rw [\u2190 assoc, \u2190 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\u2080 \u27f6 d.C\u2080)\n-- (map : c.C\u2081 \u27f6 d.C\u2081)\n-- (map_src : map \u226b d.src = c.src \u226b obj)\n-- (map_trg : map \u226b d.trg = c.trg \u226b obj)\n-- (ident_map : c.ident \u226b map = obj \u226b d.ident)\n-- (comp_map : make_pair _ (first_hom _ \u226b map) (second_hom _ \u226b map) (by simp [map_src, map_trg]) \u226b d.comp = c.comp \u226b 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 := \ud835\udfd9 _,\n--   map := \ud835\udfd9 _,\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 \u226b G.obj,\n--   map := F.map \u226b G.map,\n--   map_src := by simp,\n--   map_trg := by simp,\n--   ident_map := by simp,\n--   comp_map :=\n--   begin\n--     rw [\u2190 F.comp_map_assoc, \u2190 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\u2081 : F.obj = G.obj) (h\u2082 : 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\u2080 \u2964 d.C\u2080 :=\n-- { obj := F.obj,\n--   map := \u03bb X Y f,\n--   begin\n--     refine \u27e8F.map f.1, _, _\u27e9,\n--     { change (F.map \u226b d.src) _ = _,\n--       rw F.map_src,\n--       dsimp,\n--       rw f.prop.1 },\n--     { change (F.map \u226b d.trg) _ = _,\n--       rw F.map_trg,\n--       dsimp,\n--       rw f.prop.2 },\n--   end,\n--   map_id' := \u03bb X,\n--   begin\n--     ext1,\n--     change (c.ident \u226b F.map) X = (F.obj \u226b d.ident) X,\n--     rw F.ident_map,\n--   end,\n--   map_comp' :=\n--   begin\n--     rintros _ _ Z \u27e8f, rfl, rfl\u27e9 \u27e8g, rfl, fg\u27e9,\n--     ext1,\n--     change F.map (element (make_pair _ (element.symm f) (element.symm g) _ \u226b c.comp)) = element (make_pair _ (element.symm (F.map f)) (element.symm (F.map g)) _ \u226b d.comp),\n--     equiv_rw (@element c.C\u2081).symm at f,\n--     equiv_rw (@element c.C\u2081).symm at g,\n--     have : g \u226b c.trg = f \u226b c.src,\n--       rw \u2190 element.apply_eq_iff_eq,\n--       simpa using fg,\n--     simp_rw [\u2190 element_natural _ F.map, equiv.symm_apply_apply],\n--     rw [element.apply_eq_iff_eq, assoc, \u2190 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 \u2964 D) :\n--   internal_functor (internal_category_type_of_category C) (internal_category_type_of_category D) :=\n-- { obj := F.obj,\n--   map := \u03bb XYf, \u27e8F.obj XYf.1, F.obj XYf.2.1, F.map XYf.2.2\u27e9,\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 \u27e8X, Y, Z, f, g\u27e9,\n--     dsimp [internal_category_struct_type_of_category_struct],\n--     change (\u27e8F.obj X, \u27e8F.obj Z, F.map f \u226b F.map g\u27e9\u27e9 : \u03a3 (X Y : D), X \u27f6 Y) = (\u27e8F.obj X, \u27e8F.obj Z, F.map (f \u226b g)\u27e9\u27e9 : \u03a3 (X Y : D), X \u27f6 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 := \u03bb X Y Z, internal_comp,\n--   id_comp' := \u03bb X Y f,\n--   begin\n--     apply internal_functor_ext;\n--     apply id_comp,\n--   end,\n--   comp_id' := \u03bb X Y f,\n--   begin\n--     apply internal_functor_ext;\n--     apply comp_id,\n--   end,\n--   assoc' := \u03bb c\u2081 c\u2082 c\u2083 c\u2084 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) \u2964 Cat :=\n-- { obj := \u03bb c, Cat.of c.C\u2080,\n--   map := make_functor,\n--   map_id' := \u03bb c,\n--   begin\n--     refine functor.ext (\u03bb X, rfl) _,\n--     intros,\n--     apply subtype.ext,\n--     dsimp [make_functor],\n--     simpa only [id_comp, comp_id],\n--   end,\n--   map_comp' := \u03bb c d e f g,\n--   begin\n--     refine functor.ext (\u03bb X, rfl) _,\n--     intros,\n--     apply subtype.ext,\n--     dsimp,\n--     simpa,\n--   end }\n\n-- @[simps]\n-- def internal_inv : Cat.{u} \u2964 internal_category (Type u) :=\n-- { obj := \u03bb c, internal_category_type_of_category c.\u03b1,\n--   map := \u03bb c d f, internalise_functor _ _ f }\n\n-- -- -- set_option pp.all true\n-- -- def internal_equivalence : internal_category.{u} (Type u) \u224c Cat.{u u} :=\n-- -- { functor :=\n-- --   { obj := \u03bb c, Cat.of c.C\u2080,\n-- --     map := make_functor,\n-- --     map_id' := \u03bb c,\n-- --     begin\n-- --       refine functor.ext (\u03bb X, rfl) _,\n-- --       intros,\n-- --       apply subtype.ext,\n-- --       dsimp [make_functor],\n-- --       simpa only [id_comp, comp_id],\n-- --     end,\n-- --     map_comp' := \u03bb c d e f g,\n-- --     begin\n-- --       refine functor.ext (\u03bb X, rfl) _,\n-- --       intros,\n-- --       apply subtype.ext,\n-- --       dsimp,\n-- --       simpa,\n-- --     end },\n-- --   inverse :=\n-- --   { obj := \u03bb c, internal_category_type_of_category c.\u03b1,\n-- --     map := \u03bb 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 \u2245 _,\n-- --     -- dsimp [Cat.of, bundled.of, Cat.str, category_theory.category_of_internal_category_type, internal_category_type_of_category],\n-- --     -- refine \u27e8_, _, _, _\u27e9,\n-- --     -- refine \u27e8\ud835\udfd9 _, \u03bb x, \u27e8X.src x, X.trg x, sorry\u27e9, rfl, rfl, _, _\u27e9,\n-- --     -- ext1,\n-- --     -- dsimp [internal_category_struct_type_of_category_struct],\n-- --     -- change (\u27e8(X.ident \u226b X.src) x, (X.ident \u226b X.trg) x, _\u27e9 : \u03a3 (X\u2081 Y\u2081 : X.to_internal_category_struct.C\u2080), X\u2081 \u27f6 Y\u2081) = _,\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 \u2192 nat) : nat \u2192 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 \u2260 k \u2192 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 \u2192 option (preterm \u00d7 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 \u2192 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 \u2227 y = s then (1 ** k)\n  else x.sub_subst -* y.sub_subst\n\nlemma val_sub_subst {k x y v} :\n  \u2200 {t : preterm}, t.fresh_idx \u2264 k \u2192 \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 \u2227 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 \u2192 option (preterm \u00d7 preterm)\n| (t =* s) := t.sub_terms <|> s.sub_terms\n| (t \u2264* s) := t.sub_terms <|> s.sub_terms\n| (\u00ac* p)   := p.sub_terms\n| (p \u2228* q) := p.sub_terms <|> q.sub_terms\n| (p \u2227* q) := p.sub_terms <|> q.sub_terms\n\n@[omega] def sub_subst (x y : preterm) (k : nat) : form \u2192 form \n| (t =* s) := preterm.sub_subst x y k t =* preterm.sub_subst x y k s\n| (t \u2264* s) := preterm.sub_subst x y k t \u2264* preterm.sub_subst x y k s\n| (\u00ac* p)   := \u00ac* p.sub_subst\n| (p \u2228* q) := p.sub_subst \u2228* q.sub_subst\n| (p \u2227* q) := p.sub_subst \u2227* q.sub_subst\n\nend form\n\ndef is_diff (t s k) : form := \n((t =* (s +* (1 ** k))) \u2228* (t \u2264* s \u2227* ((1 ** k) =* &0))) \n\nlemma holds_is_diff {t s : preterm} {k} {v : nat \u2192 nat} :\n  v k = t.val v - s.val v \u2192 (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 \u2264 s.val v, \n  { right, refine \u27e8h2,_\u27e9, \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) \u2227* (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  \u2200 p : form, p.fresh_idx \u2264 k \u2192 ((form.sub_subst x y k p).holds \n    (update k (x.val v - y.val v) v) \u2194 (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 \u2264* 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| (\u00ac* p) h1 :=  \n  by { apply not_iff_not_of_iff, apply sub_subst_equiv p h1 } \n| (p \u2228* 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 \u2227* 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 \u2192 (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 \u27e8update (sub_fresh_idx t s p) (t.val v - s.val v) v, _\u27e9, \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 \u2192 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[\u03b1]` for some `\u03b1` 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 = \u27e8I, G(\u03b1)\u27e9` 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: \u00abexpr < >\u00bb\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 | \u2200 b : S, a * b \u2208 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) \u2286 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 \u2208 conductor R x \u2194 \u2200 b : S, y * b \u2208 R<x> :=\n  \u27e8fun h => h, fun h => h\u27e9\n#align mem_conductor_iff mem_conductor_iff\n\ntheorem conductor_eq_top_of_adjoin_eq_top (h : R<x> = \u22a4) : conductor R x = \u22a4 := 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 = \u22a4 :=\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) \u2286 I * R<x>` for any `p` in `C \u2229 R` -/\ntheorem prod_mem_ideal_map_of_mem_conductor {p : R} {z : S}\n    (hp : p \u2208 Ideal.comap (algebraMap R S) (conductor R x)) (hz' : z \u2208 I.map (algebraMap R S)) :\n    algebraMap R S p * z \u2208 algebraMap R<x> S '' \u2191(I.map (algebraMap R R<x>)) :=\n  by\n  rw [Ideal.map, Ideal.span, Finsupp.mem_span_image_iff_total] at hz'\n  obtain \u27e8l, H, H'\u27e9 := hz'\n  rw [Finsupp.total_apply] at H'\n  rw [\u2190 H', mul_comm, Finsupp.sum_mul]\n  have lem :\n    \u2200 {a : R},\n      a \u2208 I \u2192\n        l a \u2022 algebraMap R S a * algebraMap R S p \u2208\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 * \u27e8l a * algebraMap R S p, show l a * algebraMap R S p \u2208 R<x> from _\u27e9)\n        _\n    \u00b7 rw [mul_comm]\n      exact mem_conductor_iff.mp (ideal.mem_comap.mp hp) _\n    refine' \u27e8_, by simpa only [RingHom.map_mul, mul_comm (algebraMap R S p) (l a)] \u27e9\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 \u2208 algebraMap R<x> S '' I.map (algebraMap R R<x>))\n      (fun a b => _) _ _\n  rintro \u27e8z, hz, rfl\u27e9 \u27e8y, hy, rfl\u27e9\n  rw [\u2190 RingHom.map_add]\n  exact \u27e8z + y, Ideal.add_mem _ (set_like.mem_coe.mp hz) hy, rfl\u27e9\n  \u00b7 refine' \u27e80, set_like.mem_coe.mpr <| Ideal.zero_mem _, RingHom.map_zero _\u27e9\n  \u00b7 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) \u2229 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) \u2294 I = \u22a4)\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  \u00b7 -- This is adapted from [Neukirch1992]. Let `C = (conductor R x)`. The idea of the proof\n    -- is that since `I` and `C \u2229 R` are coprime, we have\n    -- `(I * S) \u2229 R<x> \u2286 (I + C) * ((I * S) \u2229 R<x>) \u2286 I * R<x> + I * C * S \u2286 I * R<x>`.\n    intro y hy\n    obtain \u27e8z, hz\u27e9 := y\n    obtain \u27e8p, hp, q, hq, hpq\u27e9 := 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 [\u2190 add_mul, \u2190 RingHom.map_add (algebraMap R S), hpq, map_one, one_mul]\n    suffices\n      z \u2208 algebraMap R<x> S '' I.map (algebraMap R R<x>) \u2194\n        (\u27e8z, hz\u27e9 : R<x>) \u2208 I.map (algebraMap R R<x>)\n      by\n      rw [\u2190 this, \u2190 temp]\n      obtain \u27e8a, ha\u27e9 :=\n        (Set.mem_image _ _ _).mp\n          (prod_mem_ideal_map_of_mem_conductor hp\n            (show z \u2208 I.map (algebraMap R S) by rwa [Ideal.mem_comap] at hy))\n      use a + algebraMap R R<x> q * \u27e8z, hz\u27e9\n      refine'\n        \u27e8Ideal.add_mem (I.map (algebraMap R R<x>)) ha.left _, by\n          simpa only [ha.right, map_add, AlgHom.map_mul, add_right_inj] \u27e9\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      \u27e8fun h => _, fun h => (Set.mem_image _ _ _).mpr (Exists.intro \u27e8z, hz\u27e9 \u27e8by simp [h], rfl\u27e9)\u27e9\n    \u00b7 obtain \u27e8x\u2081, hx\u2081, hx\u2082\u27e9 := (Set.mem_image _ _ _).mp h\n      have : x\u2081 = \u27e8z, hz\u27e9 := by\n        apply h_alg\n        simpa [hx\u2082]\n      rwa [\u2190 this]\n  \u00b7 -- 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, \u2190 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> \u29f8 (I*R<x>)` to `S \u29f8 (I*S)` is an isomorphism\n    when `I` and `(conductor R x) \u2229 R` are coprime. -/\nnoncomputable def quotAdjoinEquivQuotMap (hx : (conductor R x).comap (algebraMap R S) \u2294 I = \u22a4)\n    (h_alg : Function.Injective (algebraMap R<x> S)) :\n    R<x> \u29f8 I.map (algebraMap R R<x>) \u2243+* S \u29f8 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, \u2190 Ideal.map_map]\n      exact Ideal.mem_map_of_mem _ hr)\n    (by\n      constructor\n      \u00b7 --the kernel of the map is clearly `(I * S) \u2229 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, \u2190 Ideal.mem_comap,\n          comap_map_eq_map_adjoin_of_coprime_conductor hx h_alg] at hu\n      \u00b7 -- Surjectivity follows from the surjectivity of the canonical map `R<x> \u2192 S \u29f8 (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 \u27e8z, hz\u27e9 := Ideal.Quotient.mk_surjective y\n        have : z \u2208 conductor R x \u2294 I.map (algebraMap R S) :=\n          by\n          suffices conductor R x \u2294 I.map (algebraMap R S) = \u22a4 by simp only [this]\n          rw [Ideal.eq_top_iff_one] at hx\u22a2\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) \u2264 conductor R x\n                  from Ideal.map_comap_le)\n                (le_refl (I.map (algebraMap R S))))\n              hx\n        rw [\u2190 Ideal.mem_quotient_iff_mem_sup, hz, Ideal.mem_map_iff_of_surjective] at this\n        obtain \u27e8u, hu, hu'\u27e9 := this\n        use \u27e8u, conductor_subset_adjoin hu\u27e9\n        simpa only [\u2190 hu']\n        \u00b7 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) \u2294 I = \u22a4)\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 \u2191a :=\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 \u2260 \u22a5) (hx : (conductor R x).comap (algebraMap R S) \u2294 I = \u22a4) (hx' : IsIntegral R x) :\n    { J : Ideal S | J \u2208 normalizedFactors (I.map (algebraMap R S)) } \u2243\n      { d : (R \u29f8 I)[X] | d \u2208 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` \u2260 \u22a5\n        show I.map (algebraMap R S) \u2260 \u22a5 by\n          rwa [Ne.def, map_eq_bot_iff_of_injective (NoZeroSMulDivisors.algebraMap_injective R S), \u2190\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) \u2260 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) \u2260 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 \u2260 \u22a5)\n    (hx : (conductor R x).comap (algebraMap R S) \u2294 I = \u22a4) (hx' : IsIntegral R x) {J : Ideal S}\n    (hJ : J \u2208 normalizedFactors (I.map (algebraMap R S))) :\n    multiplicity J (I.map (algebraMap R S)) =\n      multiplicity (\u2191(normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx' \u27e8J, hJ\u27e9))\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 \u2260 \u22a5) (hx : (conductor R x).comap (algebraMap R S) \u2294 I = \u22a4) (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 \u2208 normalized_factors (I.map (algebraMap R S))\n  swap\n  \u00b7 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') \u27e8J, hJ\u27e9 = 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 [\u2190 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  \u00b7 exact subtype.coe_injective.comp (Equiv.injective _)\n  \u00b7 exact (normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx' _).Prop\n  \u00b7\n    exact\n      irreducible_of_normalized_factor _\n        (normalized_factors_map_equiv_normalized_factors_min_poly_mk hI hI' hx hx' _).Prop\n  \u00b7 exact Polynomial.map_monic_ne_zero (minpoly.monic hx')\n  \u00b7 exact irreducible_of_normalized_factor _ hJ\n  \u00b7\n    rwa [\u2190 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 \u2260 \u22a5)\n    (hx : (conductor R x).comap (algebraMap R S) \u2294 I = \u22a4) (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)) \u2208\n      normalized_factors (map I.Quotient.mk (minpoly R x)) :=\n    by simp [normalized_factors_irreducible hf]\n  suffices \u2203 y, normalized_factors (I.map (algebraMap R S)) = {y}\n    by\n    obtain \u27e8y, hy\u27e9 := this\n    have h :=\n      normalized_factors_prod\n        (show I.map (algebraMap R S) \u2260 0 by\n          rwa [\u2190 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 [\u2190 h]\n    exact\n      irreducible_of_normalized_factor y\n        (show y \u2208 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        \u27e8normalize (map I.Quotient.mk (minpoly R x)), mem_norm_factors\u27e9 :\n      Ideal S)\n  rw [Multiset.map_eq_singleton]\n  use \u27e8normalize (map I.Quotient.mk (minpoly R x)), mem_norm_factors\u27e9\n  refine' \u27e8_, rfl\u27e9\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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* `(\u2264)` with `zorn_partial_order`\n* `(\u2286)` with `zorn_subset`\n* `(\u2287)` with `zorn_superset`\n\nLemma names carry modifiers:\n* `\u2080`: 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 : \u2203 m, \u2200 a, m \u227a a \u2192 a \u227a 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 \u03b1 := {x | whatever x},\n  suffices : \u2203 x \u2208 s, \u2200 y \u2208 s, y \u2286 x \u2192 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 \u27e8edge_case_construction,\n      proof_that_edge_case_construction_respects_whatever,\n      proof_that_edge_case_construction_contains_all_stuff_in_c\u27e9 },\n  exact \u27e8construction,\n    proof_that_construction_respects_whatever,\n    proof_that_construction_contains_all_stuff_in_c\u27e9,\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 {\u03b1 \u03b2 : Type _} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {c : Set \u03b1}\n\n-- mathport name: \u00abexpr \u227a \u00bb\nlocal infixl:50 \" \u227a \" => 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 : \u2200 c, IsChain r c \u2192 \u2203 ub, \u2200 a \u2208 c, a \u227a ub)\n    (trans : \u2200 {a b c}, a \u227a b \u2192 b \u227a c \u2192 a \u227a c) : \u2203 m, \u2200 a, m \u227a a \u2192 a \u227a m :=\n  have : \u2203 ub, \u2200 a \u2208 maxChain r, a \u227a ub := h _ <| maxChain_spec.left\n  let \u27e8ub, (hub : \u2200 a \u2208 maxChain r, a \u227a ub)\u27e9 := this\n  \u27e8ub, 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 _ _\u27e9\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 \u03b1]\n    (h : \u2200 c, IsChain r c \u2192 c.Nonempty \u2192 \u2203 ub, \u2200 a \u2208 c, a \u227a ub)\n    (trans : \u2200 {a b c}, a \u227a b \u2192 b \u227a c \u2192 a \u227a c) : \u2203 m, \u2200 a, m \u227a a \u2192 a \u227a m :=\n  exists_maximal_of_chains_bounded\n    (fun c hc =>\n      (eq_empty_or_nonempty c).elim\n        (fun h => \u27e8Classical.arbitrary \u03b1, fun x hx => (h \u25b8 hx : x \u2208 (\u2205 : Set \u03b1)).elim\u27e9) (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 \u03b1]\n\n#print zorn_preorder /-\ntheorem zorn_preorder (h : \u2200 c : Set \u03b1, IsChain (\u00b7 \u2264 \u00b7) c \u2192 BddAbove c) :\n    \u2203 m : \u03b1, \u2200 a, m \u2264 a \u2192 a \u2264 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 \u03b1]\n    (h : \u2200 c : Set \u03b1, IsChain (\u00b7 \u2264 \u00b7) c \u2192 c.Nonempty \u2192 BddAbove c) : \u2203 m : \u03b1, \u2200 a, m \u2264 a \u2192 a \u2264 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\u2080 -> zorn_preorder\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Preorder.{u1} \u03b1] (s : Set.{u1} \u03b1), (forall (c : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) c s) -> (IsChain.{u1} \u03b1 (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1)) c) -> (Exists.{succ u1} \u03b1 (fun (ub : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) ub s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) ub s) => forall (z : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) z ub))))) -> (Exists.{succ u1} \u03b1 (fun (m : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) m s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) m s) => forall (z : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) m z) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) z m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Preorder.{u1} \u03b1] (s : Set.{u1} \u03b1), (forall (c : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) c s) -> (IsChain.{u1} \u03b1 (fun (x._@.Mathlib.Order.Zorn._hyg.862 : \u03b1) (x._@.Mathlib.Order.Zorn._hyg.864 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) x._@.Mathlib.Order.Zorn._hyg.862 x._@.Mathlib.Order.Zorn._hyg.864) c) -> (Exists.{succ u1} \u03b1 (fun (ub : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) ub s) (forall (z : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) z ub))))) -> (Exists.{succ u1} \u03b1 (fun (m : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) m s) (forall (z : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) m z) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) z m))))\nCase conversion may be inaccurate. Consider using '#align zorn_preorder\u2080 zorn_preorder\u2080\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb s) -/\ntheorem zorn_preorder\u2080 (s : Set \u03b1)\n    (ih : \u2200 (c) (_ : c \u2286 s), IsChain (\u00b7 \u2264 \u00b7) c \u2192 \u2203 ub \u2208 s, \u2200 z \u2208 c, z \u2264 ub) :\n    \u2203 m \u2208 s, \u2200 z \u2208 s, m \u2264 z \u2192 z \u2264 m :=\n  let \u27e8\u27e8m, hms\u27e9, h\u27e9 :=\n    @zorn_preorder s _ fun c hc =>\n      let \u27e8ub, hubs, hub\u27e9 :=\n        ih (Subtype.val '' c) (fun _ \u27e8\u27e8x, hx\u27e9, _, h\u27e9 => h \u25b8 hx)\n          (by\n            rintro _ \u27e8p, hpc, rfl\u27e9 _ \u27e8q, hqc, rfl\u27e9 hpq <;>\n              refine' hc hpc hqc fun t => hpq (Subtype.ext_iff.1 t))\n      \u27e8\u27e8ub, hubs\u27e9, fun \u27e8y, hy\u27e9 hc => hub _ \u27e8_, hc, rfl\u27e9\u27e9\n  \u27e8m, hms, fun z hzs hmz => h \u27e8z, hzs\u27e9 hmz\u27e9\n#align zorn_preorder\u2080 zorn_preorder\u2080\n\n/- warning: zorn_nonempty_preorder\u2080 -> zorn_nonempty_preorder\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Preorder.{u1} \u03b1] (s : Set.{u1} \u03b1), (forall (c : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) c s) -> (IsChain.{u1} \u03b1 (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1)) c) -> (forall (y : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y c) -> (Exists.{succ u1} \u03b1 (fun (ub : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) ub s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) ub s) => forall (z : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) z ub)))))) -> (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (Exists.{succ u1} \u03b1 (fun (m : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) m s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) m s) => And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) x m) (forall (z : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) m z) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) z m))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Preorder.{u1} \u03b1] (s : Set.{u1} \u03b1), (forall (c : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) c s) -> (IsChain.{u1} \u03b1 (fun (x._@.Mathlib.Order.Zorn._hyg.1178 : \u03b1) (x._@.Mathlib.Order.Zorn._hyg.1180 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) x._@.Mathlib.Order.Zorn._hyg.1178 x._@.Mathlib.Order.Zorn._hyg.1180) c) -> (forall (y : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y c) -> (Exists.{succ u1} \u03b1 (fun (ub : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) ub s) (forall (z : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) z ub)))))) -> (forall (x : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) -> (Exists.{succ u1} \u03b1 (fun (m : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) m s) (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) x m) (forall (z : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) m z) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) z m))))))\nCase conversion may be inaccurate. Consider using '#align zorn_nonempty_preorder\u2080 zorn_nonempty_preorder\u2080\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb s) -/\ntheorem zorn_nonempty_preorder\u2080 (s : Set \u03b1)\n    (ih : \u2200 (c) (_ : c \u2286 s), IsChain (\u00b7 \u2264 \u00b7) c \u2192 \u2200 y \u2208 c, \u2203 ub \u2208 s, \u2200 z \u2208 c, z \u2264 ub) (x : \u03b1)\n    (hxs : x \u2208 s) : \u2203 m \u2208 s, x \u2264 m \u2227 \u2200 z \u2208 s, m \u2264 z \u2192 z \u2264 m :=\n  by\n  rcases zorn_preorder\u2080 ({ y \u2208 s | x \u2264 y }) fun c hcs hc => _ with \u27e8m, \u27e8hms, hxm\u27e9, hm\u27e9\n  \u00b7 exact \u27e8m, hms, hxm, fun z hzs hmz => hm _ \u27e8hzs, hxm.trans hmz\u27e9 hmz\u27e9\n  \u00b7 rcases c.eq_empty_or_nonempty with (rfl | \u27e8y, hy\u27e9)\n    \u00b7 exact \u27e8x, \u27e8hxs, le_rfl\u27e9, fun z => False.elim\u27e9\n    \u00b7 rcases ih c (fun z hz => (hcs hz).1) hc y hy with \u27e8z, hzs, hz\u27e9\n      exact \u27e8z, \u27e8hzs, (hcs hy).2.trans <| hz _ hy\u27e9, hz\u27e9\n#align zorn_nonempty_preorder\u2080 zorn_nonempty_preorder\u2080\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb Ici[set.Ici] a) -/\n#print zorn_nonempty_Ici\u2080 /-\ntheorem zorn_nonempty_Ici\u2080 (a : \u03b1)\n    (ih : \u2200 (c) (_ : c \u2286 Ici a), IsChain (\u00b7 \u2264 \u00b7) c \u2192 \u2200 y \u2208 c, \u2203 ub, a \u2264 ub \u2227 \u2200 z \u2208 c, z \u2264 ub)\n    (x : \u03b1) (hax : a \u2264 x) : \u2203 m, x \u2264 m \u2227 \u2200 z, m \u2264 z \u2192 z \u2264 m :=\n  let \u27e8m, hma, hxm, hm\u27e9 := zorn_nonempty_preorder\u2080 (Ici a) (by simpa using ih) x hax\n  \u27e8m, hxm, fun z hmz => hm _ (hax.trans <| hxm.trans hmz) hmz\u27e9\n#align zorn_nonempty_Ici\u2080 zorn_nonempty_Ici\u2080\n-/\n\nend Preorder\n\nsection PartialOrder\n\nvariable [PartialOrder \u03b1]\n\n#print zorn_partialOrder /-\ntheorem zorn_partialOrder (h : \u2200 c : Set \u03b1, IsChain (\u00b7 \u2264 \u00b7) c \u2192 BddAbove c) :\n    \u2203 m : \u03b1, \u2200 a, m \u2264 a \u2192 a = m :=\n  let \u27e8m, hm\u27e9 := zorn_preorder h\n  \u27e8m, fun a ha => le_antisymm (hm a ha) ha\u27e9\n#align zorn_partial_order zorn_partialOrder\n-/\n\n#print zorn_nonempty_partialOrder /-\ntheorem zorn_nonempty_partialOrder [Nonempty \u03b1]\n    (h : \u2200 c : Set \u03b1, IsChain (\u00b7 \u2264 \u00b7) c \u2192 c.Nonempty \u2192 BddAbove c) : \u2203 m : \u03b1, \u2200 a, m \u2264 a \u2192 a = m :=\n  let \u27e8m, hm\u27e9 := zorn_nonempty_preorder h\n  \u27e8m, fun a ha => le_antisymm (hm a ha) ha\u27e9\n#align zorn_nonempty_partial_order zorn_nonempty_partialOrder\n-/\n\n/- warning: zorn_partial_order\u2080 -> zorn_partialOrder\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] (s : Set.{u1} \u03b1), (forall (c : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) c s) -> (IsChain.{u1} \u03b1 (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1))) c) -> (Exists.{succ u1} \u03b1 (fun (ub : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) ub s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) ub s) => forall (z : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) z ub))))) -> (Exists.{succ u1} \u03b1 (fun (m : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) m s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) m s) => forall (z : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) m z) -> (Eq.{succ u1} \u03b1 z m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] (s : Set.{u1} \u03b1), (forall (c : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) c s) -> (IsChain.{u1} \u03b1 (fun (x._@.Mathlib.Order.Zorn._hyg.1874 : \u03b1) (x._@.Mathlib.Order.Zorn._hyg.1876 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) x._@.Mathlib.Order.Zorn._hyg.1874 x._@.Mathlib.Order.Zorn._hyg.1876) c) -> (Exists.{succ u1} \u03b1 (fun (ub : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) ub s) (forall (z : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) z ub))))) -> (Exists.{succ u1} \u03b1 (fun (m : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) m s) (forall (z : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) m z) -> (Eq.{succ u1} \u03b1 z m))))\nCase conversion may be inaccurate. Consider using '#align zorn_partial_order\u2080 zorn_partialOrder\u2080\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb s) -/\ntheorem zorn_partialOrder\u2080 (s : Set \u03b1)\n    (ih : \u2200 (c) (_ : c \u2286 s), IsChain (\u00b7 \u2264 \u00b7) c \u2192 \u2203 ub \u2208 s, \u2200 z \u2208 c, z \u2264 ub) :\n    \u2203 m \u2208 s, \u2200 z \u2208 s, m \u2264 z \u2192 z = m :=\n  let \u27e8m, hms, hm\u27e9 := zorn_preorder\u2080 s ih\n  \u27e8m, hms, fun z hzs hmz => (hm z hzs hmz).antisymm hmz\u27e9\n#align zorn_partial_order\u2080 zorn_partialOrder\u2080\n\n/- warning: zorn_nonempty_partial_order\u2080 -> zorn_nonempty_partialOrder\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] (s : Set.{u1} \u03b1), (forall (c : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) c s) -> (IsChain.{u1} \u03b1 (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1))) c) -> (forall (y : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y c) -> (Exists.{succ u1} \u03b1 (fun (ub : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) ub s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) ub s) => forall (z : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) z ub)))))) -> (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (Exists.{succ u1} \u03b1 (fun (m : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) m s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) m s) => And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) x m) (forall (z : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) m z) -> (Eq.{succ u1} \u03b1 z m))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] (s : Set.{u1} \u03b1), (forall (c : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) c s) -> (IsChain.{u1} \u03b1 (fun (x._@.Mathlib.Order.Zorn._hyg.2042 : \u03b1) (x._@.Mathlib.Order.Zorn._hyg.2044 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) x._@.Mathlib.Order.Zorn._hyg.2042 x._@.Mathlib.Order.Zorn._hyg.2044) c) -> (forall (y : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y c) -> (Exists.{succ u1} \u03b1 (fun (ub : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) ub s) (forall (z : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) z ub)))))) -> (forall (x : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) -> (Exists.{succ u1} \u03b1 (fun (m : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) m s) (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) x m) (forall (z : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)) m z) -> (Eq.{succ u1} \u03b1 z m))))))\nCase conversion may be inaccurate. Consider using '#align zorn_nonempty_partial_order\u2080 zorn_nonempty_partialOrder\u2080\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb s) -/\ntheorem zorn_nonempty_partialOrder\u2080 (s : Set \u03b1)\n    (ih : \u2200 (c) (_ : c \u2286 s), IsChain (\u00b7 \u2264 \u00b7) c \u2192 \u2200 y \u2208 c, \u2203 ub \u2208 s, \u2200 z \u2208 c, z \u2264 ub) (x : \u03b1)\n    (hxs : x \u2208 s) : \u2203 m \u2208 s, x \u2264 m \u2227 \u2200 z \u2208 s, m \u2264 z \u2192 z = m :=\n  let \u27e8m, hms, hxm, hm\u27e9 := zorn_nonempty_preorder\u2080 s ih x hxs\n  \u27e8m, hms, hxm, fun z hzs hmz => (hm z hzs hmz).antisymm hmz\u27e9\n#align zorn_nonempty_partial_order\u2080 zorn_nonempty_partialOrder\u2080\n\nend PartialOrder\n\n/- warning: zorn_subset -> zorn_subset is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} (S : Set.{u1} (Set.{u1} \u03b1)), (forall (c : Set.{u1} (Set.{u1} \u03b1)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} \u03b1)) (Set.hasSubset.{u1} (Set.{u1} \u03b1)) c S) -> (IsChain.{u1} (Set.{u1} \u03b1) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1)) c) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (ub : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) ub S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) ub S) => forall (s : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s ub))))) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (m : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) m S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) m S) => forall (a : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) m a) -> (Eq.{succ u1} (Set.{u1} \u03b1) a m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (S : Set.{u1} (Set.{u1} \u03b1)), (forall (c : Set.{u1} (Set.{u1} \u03b1)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} \u03b1)) (Set.instHasSubsetSet.{u1} (Set.{u1} \u03b1)) c S) -> (IsChain.{u1} (Set.{u1} \u03b1) (fun (x._@.Mathlib.Order.Zorn._hyg.2249 : Set.{u1} \u03b1) (x._@.Mathlib.Order.Zorn._hyg.2251 : Set.{u1} \u03b1) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) x._@.Mathlib.Order.Zorn._hyg.2249 x._@.Mathlib.Order.Zorn._hyg.2251) c) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (ub : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) ub S) (forall (s : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s ub))))) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (m : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) m S) (forall (a : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) m a) -> (Eq.{succ u1} (Set.{u1} \u03b1) a m))))\nCase conversion may be inaccurate. Consider using '#align zorn_subset zorn_subset\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb S) -/\ntheorem zorn_subset (S : Set (Set \u03b1))\n    (h : \u2200 (c) (_ : c \u2286 S), IsChain (\u00b7 \u2286 \u00b7) c \u2192 \u2203 ub \u2208 S, \u2200 s \u2208 c, s \u2286 ub) :\n    \u2203 m \u2208 S, \u2200 a \u2208 S, m \u2286 a \u2192 a = m :=\n  zorn_partialOrder\u2080 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 {\u03b1 : Type.{u1}} (S : Set.{u1} (Set.{u1} \u03b1)), (forall (c : Set.{u1} (Set.{u1} \u03b1)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} \u03b1)) (Set.hasSubset.{u1} (Set.{u1} \u03b1)) c S) -> (IsChain.{u1} (Set.{u1} \u03b1) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1)) c) -> (Set.Nonempty.{u1} (Set.{u1} \u03b1) c) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (ub : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) ub S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) ub S) => forall (s : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s ub))))) -> (forall (x : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) x S) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (m : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) m S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) m S) => And (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) x m) (forall (a : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) m a) -> (Eq.{succ u1} (Set.{u1} \u03b1) a m))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (S : Set.{u1} (Set.{u1} \u03b1)), (forall (c : Set.{u1} (Set.{u1} \u03b1)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} \u03b1)) (Set.instHasSubsetSet.{u1} (Set.{u1} \u03b1)) c S) -> (IsChain.{u1} (Set.{u1} \u03b1) (fun (x._@.Mathlib.Order.Zorn._hyg.2373 : Set.{u1} \u03b1) (x._@.Mathlib.Order.Zorn._hyg.2375 : Set.{u1} \u03b1) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) x._@.Mathlib.Order.Zorn._hyg.2373 x._@.Mathlib.Order.Zorn._hyg.2375) c) -> (Set.Nonempty.{u1} (Set.{u1} \u03b1) c) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (ub : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) ub S) (forall (s : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s ub))))) -> (forall (x : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) x S) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (m : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) m S) (And (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) x m) (forall (a : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) m a) -> (Eq.{succ u1} (Set.{u1} \u03b1) a m))))))\nCase conversion may be inaccurate. Consider using '#align zorn_subset_nonempty zorn_subset_nonempty\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb S) -/\ntheorem zorn_subset_nonempty (S : Set (Set \u03b1))\n    (H : \u2200 (c) (_ : c \u2286 S), IsChain (\u00b7 \u2286 \u00b7) c \u2192 c.Nonempty \u2192 \u2203 ub \u2208 S, \u2200 s \u2208 c, s \u2286 ub) (x)\n    (hx : x \u2208 S) : \u2203 m \u2208 S, x \u2286 m \u2227 \u2200 a \u2208 S, m \u2286 a \u2192 a = m :=\n  zorn_nonempty_partialOrder\u2080 _ (fun c cS hc y yc => H _ cS hc \u27e8y, yc\u27e9) _ 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 {\u03b1 : Type.{u1}} (S : Set.{u1} (Set.{u1} \u03b1)), (forall (c : Set.{u1} (Set.{u1} \u03b1)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} \u03b1)) (Set.hasSubset.{u1} (Set.{u1} \u03b1)) c S) -> (IsChain.{u1} (Set.{u1} \u03b1) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1)) c) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (lb : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) lb S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) lb S) => forall (s : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) lb s))))) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (m : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) m S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) m S) => forall (a : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) a m) -> (Eq.{succ u1} (Set.{u1} \u03b1) a m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (S : Set.{u1} (Set.{u1} \u03b1)), (forall (c : Set.{u1} (Set.{u1} \u03b1)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} \u03b1)) (Set.instHasSubsetSet.{u1} (Set.{u1} \u03b1)) c S) -> (IsChain.{u1} (Set.{u1} \u03b1) (fun (x._@.Mathlib.Order.Zorn._hyg.2532 : Set.{u1} \u03b1) (x._@.Mathlib.Order.Zorn._hyg.2534 : Set.{u1} \u03b1) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) x._@.Mathlib.Order.Zorn._hyg.2532 x._@.Mathlib.Order.Zorn._hyg.2534) c) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (lb : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) lb S) (forall (s : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) lb s))))) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (m : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) m S) (forall (a : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) a m) -> (Eq.{succ u1} (Set.{u1} \u03b1) a m))))\nCase conversion may be inaccurate. Consider using '#align zorn_superset zorn_superset\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb S) -/\ntheorem zorn_superset (S : Set (Set \u03b1))\n    (h : \u2200 (c) (_ : c \u2286 S), IsChain (\u00b7 \u2286 \u00b7) c \u2192 \u2203 lb \u2208 S, \u2200 s \u2208 c, lb \u2286 s) :\n    \u2203 m \u2208 S, \u2200 a \u2208 S, a \u2286 m \u2192 a = m :=\n  @zorn_partialOrder\u2080 (Set \u03b1)\u1d52\u1d48 _ 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 {\u03b1 : Type.{u1}} (S : Set.{u1} (Set.{u1} \u03b1)), (forall (c : Set.{u1} (Set.{u1} \u03b1)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} \u03b1)) (Set.hasSubset.{u1} (Set.{u1} \u03b1)) c S) -> (IsChain.{u1} (Set.{u1} \u03b1) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1)) c) -> (Set.Nonempty.{u1} (Set.{u1} \u03b1) c) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (lb : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) lb S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) lb S) => forall (s : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) lb s))))) -> (forall (x : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) x S) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (m : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) m S) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) m S) => And (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) m x) (forall (a : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) a m) -> (Eq.{succ u1} (Set.{u1} \u03b1) a m))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (S : Set.{u1} (Set.{u1} \u03b1)), (forall (c : Set.{u1} (Set.{u1} \u03b1)), (HasSubset.Subset.{u1} (Set.{u1} (Set.{u1} \u03b1)) (Set.instHasSubsetSet.{u1} (Set.{u1} \u03b1)) c S) -> (IsChain.{u1} (Set.{u1} \u03b1) (fun (x._@.Mathlib.Order.Zorn._hyg.2674 : Set.{u1} \u03b1) (x._@.Mathlib.Order.Zorn._hyg.2676 : Set.{u1} \u03b1) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) x._@.Mathlib.Order.Zorn._hyg.2674 x._@.Mathlib.Order.Zorn._hyg.2676) c) -> (Set.Nonempty.{u1} (Set.{u1} \u03b1) c) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (lb : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) lb S) (forall (s : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s c) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) lb s))))) -> (forall (x : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) x S) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (m : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) m S) (And (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) m x) (forall (a : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) a S) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) a m) -> (Eq.{succ u1} (Set.{u1} \u03b1) a m))))))\nCase conversion may be inaccurate. Consider using '#align zorn_superset_nonempty zorn_superset_nonempty\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (c \u00abexpr \u2286 \u00bb S) -/\ntheorem zorn_superset_nonempty (S : Set (Set \u03b1))\n    (H : \u2200 (c) (_ : c \u2286 S), IsChain (\u00b7 \u2286 \u00b7) c \u2192 c.Nonempty \u2192 \u2203 lb \u2208 S, \u2200 s \u2208 c, lb \u2286 s) (x)\n    (hx : x \u2208 S) : \u2203 m \u2208 S, m \u2286 x \u2227 \u2200 a \u2208 S, a \u2286 m \u2192 a = m :=\n  @zorn_nonempty_partialOrder\u2080 (Set \u03b1)\u1d52\u1d48 _ S (fun c cS hc y yc => H _ cS hc.symm \u27e8y, yc\u27e9) _ 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) : \u2203 M, @IsMaxChain _ r M \u2227 c \u2286 M :=\n  by\n  obtain \u27e8M, \u27e8_, hM\u2080\u27e9, hM\u2081, hM\u2082\u27e9 :=\n    zorn_subset_nonempty { s | c \u2286 s \u2227 IsChain r s } _ c \u27e8subset.rfl, hc\u27e9\n  \u00b7 exact \u27e8M, \u27e8hM\u2080, fun d hd hMd => (hM\u2082 _ \u27e8hM\u2081.trans hMd, hd\u27e9 hMd).symm\u27e9, hM\u2081\u27e9\n  rintro cs hcs\u2080 hcs\u2081 \u27e8s, hs\u27e9\n  refine'\n    \u27e8\u22c3\u2080 cs, \u27e8fun _ ha => Set.mem_union\u209b_of_mem ((hcs\u2080 hs).left ha) hs, _\u27e9, fun _ =>\n      Set.subset_union\u209b_of_mem\u27e9\n  rintro y \u27e8sy, hsy, hysy\u27e9 z \u27e8sz, hsz, hzsz\u27e9 hyz\n  obtain rfl | hsseq := eq_or_ne sy sz\n  \u00b7 exact (hcs\u2080 hsy).right hysy hzsz hyz\n  cases' hcs\u2081 hsy hsz hsseq with h h\n  \u00b7 exact (hcs\u2080 hsz).right (h hysy) hzsz hyz\n  \u00b7 exact (hcs\u2080 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\u2081 and SemiNormedGroup\n\nWe show that `SemiNormedGroup\u2081` has cokernels\n(for which of course the `cokernel.\u03c0 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.\u03c0 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.\u03c0 f` arbitrarily large in norm), obtaining another categorical cokernel.\n\n-/\n\nopen category_theory category_theory.limits\n\nuniverse u\n\nnamespace SemiNormedGroup\u2081\n\nnoncomputable theory\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup\u2081`. -/\ndef cokernel_cocone {X Y : SemiNormedGroup\u2081.{u}} (f : X \u27f6 Y) : cofork f 0 :=\ncofork.of_\u03c0\n  (@SemiNormedGroup\u2081.mk_hom\n    _ (SemiNormedGroup.of (Y \u29f8 (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\u2081.mk_hom_apply, SemiNormedGroup\u2081.zero_apply, \u2190normed_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\u2081`. -/\ndef cokernel_lift {X Y : SemiNormedGroup\u2081.{u}} (f : X \u27f6 Y) (s : cokernel_cofork f) :\n  (cokernel_cocone f).X \u27f6 s.X :=\nbegin\n  fsplit,\n  -- The lift itself:\n  { apply normed_group_hom.lift _ s.\u03c0.1,\n    rintro _ \u27e8b, rfl\u27e9,\n    change (f \u226b s.\u03c0) b = 0,\n    simp, },\n  -- The lift has norm at most one:\n  exact normed_group_hom.lift_norm_noninc _ _ _ s.\u03c0.2,\nend\n\ninstance : has_cokernels SemiNormedGroup\u2081.{u} :=\n{ has_colimit := \u03bb X Y f, has_colimit.mk\n  { cocone := cokernel_cocone f,\n    is_colimit := is_colimit_aux _\n      (cokernel_lift f)\n      (\u03bb s, begin\n        ext,\n        apply normed_group_hom.lift_mk f.1.range,\n        rintro _ \u27e8b, rfl\u27e9,\n        change (f \u226b s.\u03c0) b = 0,\n        simp,\n      end)\n      (\u03bb 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\u2081 := by apply_instance\n\nend SemiNormedGroup\u2081\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 \u27f6 W) :\n  cone (parallel_pair f g) :=\n@fork.of_\u03b9 _ _ _ _ _ _ (of (f - g).ker) (normed_group_hom.incl (f - g).ker) $\nbegin\n  ext v,\n  have : v.1 \u2208 (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 \u27f6 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      (\u03bb c, normed_group_hom.ker.lift (fork.\u03b9 c) _ $\n      show normed_group_hom.comp_hom (f - g) c.\u03b9 = 0,\n      by { rw [add_monoid_hom.map_sub, add_monoid_hom.sub_apply, sub_eq_zero], exact c.condition })\n      (\u03bb c, normed_group_hom.ker.incl_comp_lift _ _ _)\n      (\u03bb c g h, by { ext x, dsimp, rw \u2190 h, refl }) } }\n\ninstance : limits.has_equalizers.{u (u+1)} SemiNormedGroup :=\n@has_equalizers_of_has_limit_parallel_pair SemiNormedGroup _ $ \u03bb 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\u2081` 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 \u27f6 Y) : cofork f 0 :=\n@cofork.of_\u03c0 _ _ _ _ _ _\n  (SemiNormedGroup.of (Y \u29f8 (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      \u2190normed_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 \u27f6 Y) (s : cokernel_cofork f) :\n  (cokernel_cocone f).X \u27f6 s.X := normed_group_hom.lift _ s.\u03c0\nbegin\n  rintro _ \u27e8b, rfl\u27e9,\n  change (f \u226b s.\u03c0) b = 0,\n  simp,\nend\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/\ndef is_colimit_cokernel_cocone {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  is_colimit (cokernel_cocone f) :=\nis_colimit_aux _ (cokernel_lift f)\n(\u03bb s, begin\n  ext,\n  apply normed_group_hom.lift_mk f.range,\n  rintro _ \u27e8b, rfl\u27e9,\n  change (f \u226b s.\u03c0) b = 0,\n  simp,\nend)\n(\u03bb s m w, normed_group_hom.lift_unique f.range _ _ _ w)\n\ninstance : has_cokernels SemiNormedGroup.{u} :=\n{ has_colimit := \u03bb 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 \u27f6 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 \u27f6 Y} {g : Y \u27f6 Z}\n  (w : f \u226b g = 0) : explicit_cokernel f \u27f6 Z :=\n(is_colimit_cokernel_cocone f).desc (cofork.of_\u03c0 g (by simp [w]))\n\n/-- The projection from `Y` to the explicit cokernel of `X \u27f6 Y`. -/\ndef explicit_cokernel_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) : Y \u27f6 explicit_cokernel f :=\n(cokernel_cocone f).\u03b9.app walking_parallel_pair.one\n\nlemma explicit_cokernel_\u03c0_surjective {X Y : SemiNormedGroup.{u}} {f : X \u27f6 Y} :\n  function.surjective (explicit_cokernel_\u03c0 f) :=\nsurjective_quot_mk _\n\n@[simp, reassoc]\nlemma comp_explicit_cokernel_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  f \u226b explicit_cokernel_\u03c0 f = 0 :=\nbegin\n  convert (cokernel_cocone f).w walking_parallel_pair_hom.left,\n  simp,\nend\n\n@[simp]\nlemma explicit_cokernel_\u03c0_apply_dom_eq_zero {X Y : SemiNormedGroup.{u}} {f : X \u27f6 Y} (x : X) :\n  (explicit_cokernel_\u03c0 f) (f x) = 0 :=\nshow (f \u226b (explicit_cokernel_\u03c0 f)) x = 0, by { rw [comp_explicit_cokernel_\u03c0], refl }\n\n@[simp, reassoc]\nlemma explicit_cokernel_\u03c0_desc {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (w : f \u226b g = 0) : explicit_cokernel_\u03c0 f \u226b explicit_cokernel_desc w = g :=\n(is_colimit_cokernel_cocone f).fac _ _\n\n@[simp]\nlemma explicit_cokernel_\u03c0_desc_apply {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  {cond : f \u226b g = 0} (x : Y) : explicit_cokernel_desc cond (explicit_cokernel_\u03c0 f x) = g x :=\nshow (explicit_cokernel_\u03c0 f \u226b explicit_cokernel_desc cond) x = g x, by rw explicit_cokernel_\u03c0_desc\n\nlemma explicit_cokernel_desc_unique {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (w : f \u226b g = 0) (e : explicit_cokernel f \u27f6 Z) (he : explicit_cokernel_\u03c0 f \u226b e = g) :\n  e = explicit_cokernel_desc w :=\nbegin\n  apply (is_colimit_cokernel_cocone f).uniq (cofork.of_\u03c0 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 \u27f6 Y} {g : Y \u27f6 Z}\n  {h : Z \u27f6 W} {cond : f \u226b g = 0} :\n  explicit_cokernel_desc cond \u226b h = explicit_cokernel_desc (show f \u226b (g \u226b h) = 0,\n  by rw [\u2190 category_theory.category.assoc, cond, limits.zero_comp]) :=\nbegin\n  refine explicit_cokernel_desc_unique _ _ _,\n  rw [\u2190 category_theory.category.assoc, explicit_cokernel_\u03c0_desc]\nend\n\n@[simp]\nlemma explicit_cokernel_desc_zero {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} :\n  explicit_cokernel_desc (show f \u226b (0 : Y \u27f6 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 \u27f6 Y}\n  (e\u2081 e\u2082 : explicit_cokernel f \u27f6 Z)\n  (h : explicit_cokernel_\u03c0 f \u226b e\u2081 = explicit_cokernel_\u03c0 f \u226b e\u2082) : e\u2081 = e\u2082 :=\nbegin\n  let g : Y \u27f6 Z := explicit_cokernel_\u03c0 f \u226b e\u2082,\n  have w : f \u226b g = 0, by simp,\n  have : e\u2082 = 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_\u03c0.epi {X Y : SemiNormedGroup.{u}} {f : X \u27f6 Y} :\n  epi (explicit_cokernel_\u03c0 f) :=\nbegin\n  constructor,\n  intros Z g h H,\n  ext x,\n  obtain \u27e8x, hx\u27e9 := explicit_cokernel_\u03c0_surjective (explicit_cokernel_\u03c0 f x),\n  change (explicit_cokernel_\u03c0 f \u226b g) _ = _,\n  rw [H]\nend\n\nlemma is_quotient_explicit_cokernel_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\nnormed_group_hom.is_quotient (explicit_cokernel_\u03c0 f) :=\nnormed_group_hom.is_quotient_quotient _\n\nlemma norm_noninc_explicit_cokernel_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  (explicit_cokernel_\u03c0 f).norm_noninc :=\n(is_quotient_explicit_cokernel_\u03c0 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 \u27f6 Y} {g : Y \u27f6 Z} (w : f \u226b g = 0) (c : \u211d\u22650) (h : \u2225 g \u2225 \u2264 c) :\n  \u2225 explicit_cokernel_desc w \u2225 \u2264 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 \u27f6 Y} {g : Y \u27f6 Z}\n  {h : Z \u27f6 W} (cond : f \u226b g = 0) (cond2 : g \u226b h = 0) :\n  explicit_cokernel_desc cond \u226b h = 0 :=\nbegin\n  rw [\u2190 cancel_epi (explicit_cokernel_\u03c0 f), \u2190 category.assoc, explicit_cokernel_\u03c0_desc],\n  simp [cond2]\nend\n\nlemma explicit_cokernel_desc_norm_le {X Y Z : SemiNormedGroup.{u}}\n  {f : X \u27f6 Y} {g : Y \u27f6 Z} (w : f \u226b g = 0) : \u2225 explicit_cokernel_desc w \u2225 \u2264 \u2225 g \u2225 :=\nexplicit_cokernel_desc_norm_le_of_norm_le w \u2225 g \u2225\u208a (le_refl _)\n\n/-- The explicit cokernel is isomorphic to the usual cokernel. -/\ndef explicit_cokernel_iso {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  explicit_cokernel f \u2245 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_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  explicit_cokernel_\u03c0 f \u226b (explicit_cokernel_iso f).hom = cokernel.\u03c0 _ :=\nby simp [explicit_cokernel_\u03c0, explicit_cokernel_iso]\n\n@[simp]\nlemma explicit_cokernel_iso_inv_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  cokernel.\u03c0 f \u226b (explicit_cokernel_iso f).inv = explicit_cokernel_\u03c0 f :=\nby simp [explicit_cokernel_\u03c0, explicit_cokernel_iso]\n\n@[simp]\nlemma explicit_cokernel_iso_hom_desc {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (w : f \u226b g = 0) :\n  (explicit_cokernel_iso f).hom \u226b cokernel.desc f g w = explicit_cokernel_desc w :=\nbegin\n  ext1,\n  simp [explicit_cokernel_desc, explicit_cokernel_\u03c0, 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 \u27f6 B}\n  {fbd : B \u27f6 D} {fac : A \u27f6 C} {fcd : C \u27f6 D} (h : fab \u226b fbd = fac \u226b fcd) :\n  explicit_cokernel fab \u27f6 explicit_cokernel fcd :=\n@explicit_cokernel_desc _ _ _ fab (fbd \u226b explicit_cokernel_\u03c0 _) $ 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 \u27f6 B} {fbd : B \u27f6 D} {fac : A \u27f6 C} {fcd : C \u27f6 D}\n  {h : fab \u226b fbd = fac \u226b fcd} {fbb' : B \u27f6 B'} {fdd' : D \u27f6 D'}\n  {condb : fab \u226b fbb' = 0} {condd : fcd \u226b fdd' = 0} {g : B' \u27f6 D'}\n  (h' : fbb' \u226b g = fbd \u226b fdd'):\n  explicit_cokernel_desc condb \u226b g = explicit_cokernel.map h \u226b explicit_cokernel_desc condd :=\nbegin\n  delta explicit_cokernel.map,\n  simp [\u2190 cancel_epi (explicit_cokernel_\u03c0 fab), category.assoc, explicit_cokernel_\u03c0_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 \u03b1` 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 \u03b1 :=\n  \u27e8source, trace\u27e9\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\u2081 \u2190\n      div? a b\n      |>.withContext lazy_s!\"cannot compute `{a}/{b} + {c}/{d}`\"\n    let d\u2082 \u2190\n      div? c d\n      |>.withContext lazy_s!\"cannot compute `{a}/{b} + {c}/{d}\"\n    return d\u2081 + d\u2082\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\u2081 \u2190\n      div? a b\n      |>.withContext\n        lazy_s!\"that's unexpected :/\"\n      |>.withContext\n        lazy_s!\"cannot compute `d\u2081` as `{a}/{b}`\"\n      |> ErrStateT.unwrap?\n\n    let d\u2082 \u2190\n      div? c d\n      |>.withContext\n        lazy_s!\"that's unexpected :/\"\n      |>.withContext\n        lazy_s!\"cannot compute `d\u2082` as `{c}/{d}`\"\n      |> ErrStateT.unwrap?\n\n    ErrStateT.withContext\n      lazy_s!\"while computing `d\u2081` and `d\u2082`\"\n\n    if let (some d\u2081, some d\u2082) := (d\u2081, d\u2082)\n    then\n      d\u2081 + d\u2082 |> some |> pure\n    else\n      ErrStateT.errgister\n        \"failed to compute d\u2081 and/or d\u2082, 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 \u27e8_, _, trees\u27e9 =>\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": "import Smt\n\ntheorem exists' : \u2203 p : Bool, p := by\n  smt\n  exact Exists.intro true rfl\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/Exists'.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8128673359709796, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4909164607888884}}
{"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 = \u2115` (polynomials) or `G = \u03c3 \u2192\u2080 \u2115` (multivariate\npolynomials).\n\nIn order to apply in maximal generality (such as for `laurent_polynomial`s), this uses\n`\u2203 d, g' = g + d` in many places instead of `g \u2264 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`\u2203 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 \u2223 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 `\u2124` when used for `laurent_polynomial`, then no discarding occurs.\n    @Finsupp.comapDomain.addMonoidHom\n    _ _ _ _ ((\u00b7 + \u00b7) g) (add_right_injective g) x\n#align add_monoid_algebra.div_of AddMonoidAlgebra.divOf\n-/\n\n-- mathport name: \u00abexpr /\u1d52\u1da0 \u00bb\nlocal infixl:70 \" /\u1d52\u1da0 \" => 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\u2093'. -/\n@[simp]\ntheorem divOf_apply (g : G) (x : AddMonoidAlgebra k G) (g' : G) : (x /\u1d52\u1da0 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\u2093.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\u2093'. -/\n@[simp]\ntheorem support_divOf (g : G) (x : AddMonoidAlgebra k G) :\n    (x /\u1d52\u1da0 g).support =\n      x.support.Preimage ((\u00b7 + \u00b7) 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\u2093'. -/\n@[simp]\ntheorem zero_divOf (g : G) : (0 : AddMonoidAlgebra k G) /\u1d52\u1da0 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\u2093'. -/\n@[simp]\ntheorem divOf_zero (x : AddMonoidAlgebra k G) : x /\u1d52\u1da0 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\u2093'. -/\ntheorem add_divOf (x y : AddMonoidAlgebra k G) (g : G) : (x + y) /\u1d52\u1da0 g = x /\u1d52\u1da0 g + y /\u1d52\u1da0 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\u2093'. -/\ntheorem divOf_add (x : AddMonoidAlgebra k G) (a b : G) : x /\u1d52\u1da0 (a + b) = x /\u1d52\u1da0 a /\u1d52\u1da0 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\u2093'. -/\n/-- A bundled version of `add_monoid_algebra.div_of`. -/\n@[simps]\nnoncomputable def divOfHom : Multiplicative G \u2192* 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\u2081 g\u2082 :=\n    AddMonoidHom.ext fun x => (congr_arg _ (add_comm g\u2081.toAdd g\u2082.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\u2093'. -/\ntheorem of'_mul_divOf (a : G) (x : AddMonoidAlgebra k G) : of' k G a * x /\u1d52\u1da0 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\u2093'. -/\ntheorem mul_of'_divOf (x : AddMonoidAlgebra k G) (a : G) : x * of' k G a /\u1d52\u1da0 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\u2093'. -/\ntheorem of'_divOf (a : G) : of' k G a /\u1d52\u1da0 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\u2093 fun g\u2081 => \u00ac\u2203 g\u2082, g\u2081 = g + g\u2082\n#align add_monoid_algebra.mod_of AddMonoidAlgebra.modOf\n-/\n\n-- mathport name: \u00abexpr %\u1d52\u1da0 \u00bb\nlocal infixl:70 \" %\u1d52\u1da0 \" => 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\u2093'. -/\n@[simp]\ntheorem modOf_apply_of_not_exists_add (x : AddMonoidAlgebra k G) (g : G) (g' : G)\n    (h : \u00ac\u2203 d, g' = g + d) : (x %\u1d52\u1da0 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\u2093'. -/\n@[simp]\ntheorem modOf_apply_of_exists_add (x : AddMonoidAlgebra k G) (g : G) (g' : G)\n    (h : \u2203 d, g' = g + d) : (x %\u1d52\u1da0 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\u2093'. -/\n@[simp]\ntheorem modOf_apply_add_self (x : AddMonoidAlgebra k G) (g : G) (d : G) : (x %\u1d52\u1da0 g) (d + g) = 0 :=\n  modOf_apply_of_exists_add _ _ _ \u27e8_, add_comm _ _\u27e9\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\u2093'. -/\n@[simp]\ntheorem modOf_apply_self_add (x : AddMonoidAlgebra k G) (g : G) (d : G) : (x %\u1d52\u1da0 g) (g + d) = 0 :=\n  modOf_apply_of_exists_add _ _ _ \u27e8_, rfl\u27e9\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\u2093'. -/\ntheorem of'_mul_modOf (g : G) (x : AddMonoidAlgebra k G) : of' k G g * x %\u1d52\u1da0 g = 0 :=\n  by\n  ext g'\n  rw [Finsupp.zero_apply]\n  obtain \u27e8d, rfl\u27e9 | h := em (\u2203 d, g' = g + d)\n  \u00b7 rw [mod_of_apply_self_add]\n  \u00b7 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\u2093'. -/\ntheorem mul_of'_modOf (x : AddMonoidAlgebra k G) (g : G) : x * of' k G g %\u1d52\u1da0 g = 0 :=\n  by\n  ext g'\n  rw [Finsupp.zero_apply]\n  obtain \u27e8d, rfl\u27e9 | h := em (\u2203 d, g' = g + d)\n  \u00b7 rw [mod_of_apply_self_add]\n  \u00b7 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\u2093'. -/\ntheorem of'_modOf (g : G) : of' k G g %\u1d52\u1da0 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\u2093'. -/\ntheorem divOf_add_modOf (x : AddMonoidAlgebra k G) (g : G) : of' k G g * (x /\u1d52\u1da0 g) + x %\u1d52\u1da0 g = x :=\n  by\n  ext g'\n  simp_rw [Finsupp.add_apply]\n  obtain \u27e8d, rfl\u27e9 | h := em (\u2203 d, g' = g + d)\n  swap\n  \u00b7\n    rw [mod_of_apply_of_not_exists_add _ _ _ h, of'_apply, single_mul_apply_of_not_exists_add _ _ h,\n      zero_add]\n  \u00b7 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\u2093'. -/\ntheorem modOf_add_divOf (x : AddMonoidAlgebra k G) (g : G) : x %\u1d52\u1da0 g + of' k G g * (x /\u1d52\u1da0 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\u2093'. -/\ntheorem of'_dvd_iff_modOf_eq_zero {x : AddMonoidAlgebra k G} {g : G} :\n    of' k G g \u2223 x \u2194 x %\u1d52\u1da0 g = 0 := by\n  constructor\n  \u00b7 rintro \u27e8x, rfl\u27e9\n    rw [of'_mul_mod_of]\n  \u00b7 intro h\n    rw [\u2190 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 \u2192 Prop // \u2200 a b, a \u2264 b \u2192 s b \u2192 s a }\n\nvariables {A B}\n\nnamespace presheaf\n\ninstance : has_coe_to_fun (presheaf B) (\u03bb _, B \u2192 Prop) :=\n\u27e8subtype.val\u27e9\n\n@[simp] lemma coe_mk (s : B \u2192 Prop) (hs : \u2200 a b, a \u2264 b \u2192 s b \u2192 s a) :\n  @coe_fn (presheaf B) _ _ (\u27e8s, hs\u27e9 : presheaf B) = s := rfl\n\ninstance : partial_order (presheaf B) :=\n{ le := \u03bb a b, \u2200 x, a x \u2192 b x,\n  le_trans := \u03bb a b c hab hbc x hax, hbc _ (hab _ hax),\n  le_refl := \u03bb _ _, id,\n  le_antisymm := \u03bb a b hab hba, subtype.val_injective (funext $ \u03bb x, propext \u27e8hab _, hba _\u27e9) }\n\nlemma le_def {a b : presheaf B} : a \u2264 b = \u2200 x, a x \u2192 b x := rfl\n\ninstance : has_Inf (presheaf B) :=\n{ Inf := \u03bb s, \u27e8\u03bb p, \u2200 B : presheaf B, B \u2208 s \u2192 B p, \n     \u03bb a b hab h B hBs, B.2 _ _ hab (h _ hBs)\u27e9 }\n\ninstance : complete_lattice (presheaf B) :=\ncomplete_lattice_of_Inf _\n  (\u03bb 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 {\u03b9 : Sort*} (a : \u03b9 \u2192 presheaf B) : \n  infi a = \u27e8\u03bb p, \u2200 i, a i p, \u03bb x y hxy h i, (a i).2 _ y hxy (h i)\u27e9 :=\nle_antisymm \n  (infi_le_iff.2 (\u03bb B h p hBp i, h i _ hBp)) \n  (le_infi (\u03bb i p h, h _))\n\nlemma supr_def {\u03b9 : Sort*} (a : \u03b9 \u2192 presheaf B) : \n  supr a = \u27e8\u03bb p, \u2203 i, a i p, \u03bb x y hxy \u27e8i, hi\u27e9, \u27e8i, (a i).2 x y hxy hi\u27e9\u27e9 :=\nle_antisymm \n  (supr_le_iff.2 (\u03bb i p h, \u27e8i, h\u27e9)) \n  (le_supr_iff.2 (\u03bb B h p \u27e8i, hi\u27e9, h i _ hi))\n\ndef yoneda (a : B) : presheaf B :=\n\u27e8\u03bb b, b \u2264 a, \u03bb b c, le_trans\u27e9\n\ndef yoneda_le_iff (a : presheaf B) (p : B) : yoneda p \u2264 a \u2194 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 \u2264 yoneda b \u2194 a \u2264 b :=\nbegin\n  rw yoneda_le_iff, refl,\nend\n\nlemma eq_supr (a : presheaf B) : a = \u2a06 (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 \u03bb _, id }\nend\n\ndef extend {B : Type*} [complete_lattice B] (f : A \u2192 B) : presheaf A \u2192 B :=\n\u03bb a, \u2a06 (p : A) (h : a p), f p\n\nlemma extend_yoneda {B : Type*} [complete_lattice B] (f : A \u2192 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 (\u03bb b, supr_le (\u03bb h, hf h)) },\n  { refine le_supr_iff.2 (\u03bb b hb, _),\n    refine le_trans _ (hb a),\n    refine le_supr_iff.2 (\u03bb b hb, hb le_rfl) }\nend\n\nlemma extend_supr {B : Type*} {\u03b9 : Sort*} [complete_lattice B] (f : A \u2192 B) (a : \u03b9 \u2192 presheaf A) :\n  extend f (supr a) = \u2a06 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) \u2192o presheaf A :=\n{ to_fun := \u03bb F, \u27e8\u03bb X, F (yoneda X), begin\n    intros B C hBC x,\n    exact F.2 _ _ (yoneda_mono.2 hBC) x\n  end\u27e9,\n  monotone' := \u03bb F G hFG a hF, hFG _ hF }\n\ndef map (f : A \u2192 B) : presheaf A \u2192 presheaf B :=\nextend (\u03bb a, yoneda (f a))\n\ndef map_total (f : A \u2192 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 \u2192o B) : presheaf B \u2192 presheaf A :=\n\u03bb b, \u27e8\u03bb a, b (f a), \u03bb x y hxy, b.2 _ _ $ f.monotone hxy\u27e9\n\nexample (f : A \u2192o 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 \u2192 A') (j : B \u2192 B') (hi : monotone i) (hj : monotone j)\ninclude hi hj\n\nexample (f : A \u2192 B) (hf : monotone f) (g : presheaf B \u2192 presheaf A)\n  (h : galois_connection (map f) g)\n  (f' : A' \u2192 B') (g' : B' \u2192 A') (gc : galois_connection f' g')\n  (hfij : \u2200 x, f' (i x) = j (f x)) :\n  g' \u2218 extend j = extend i \u2218 g :=\n-- have hg : g = (\u03bb b, \u2a06 (c : presheaf A) (h : map f c \u2264 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 (\u03bb c, supr_le (\u03bb hc, h.le_iff_le.1 hc)) },\n--   end,\nhave hg : g = comp \u27e8f, hf\u27e9 := \n  begin\n    apply le_antisymm,\n    intro x,\n    swap,\n    intro x,\n    rw [\u2190 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 [\u2190 yoneda_le_iff, \u2190 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' = (\u03bb b, \u2a06 (c : A') (h : f' c \u2264 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 (\u03bb c, supr_le (\u03bb 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 \u22a4 _)) _,\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 \u2192 B) (hf : monotone f) (g : presheaf B \u2192 presheaf A)\n  (h : galois_connection (map f) g)\n  (f' : A' \u2192 B') (g' : B' \u2192 A') (gc : galois_connection f' g')\n  (hfij : \u2200 x, f' (i x) \u2264 j (f x)) :\n  extend i \u2218 g \u2264 g' \u2218 extend j :=\nhave hg : g = comp \u27e8f, hf\u27e9 := sorry,\nhave hg' : g' = (\u03bb b, \u2a06 (c : A') (h : f' c \u2264 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 (\u03bb c, supr_le (\u03bb 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 \u2115 \u2115 _ _,\n\nend\n\nexample (f : A \u2192 B) (hf : monotone f) (g : presheaf B \u2192 presheaf A) \n  (h : galois_connection g (map f))\n  (f' : A' \u2192 B') (g' : B' \u2192 A') (gc : galois_connection g' f') \n  (hfij : f' \u2218 i = j \u2218 f) : \n  g' \u2218 extend j = extend i \u2218 g :=\n-- have hg : g = (\u03bb b, \u2a06 (c : presheaf A) (h : map f c \u2264 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 (\u03bb c, supr_le (\u03bb hc, h.le_iff_le.1 hc)) },\n--   end,\nhave hfij' : f' \u2218 extend i = extend j \u2218 map f :=\nbegin\n  funext x,\n  dsimp [extend, gc.l_supr],\nend,\nhave hg : g = comp \u27e8f, hf\u27e9 := sorry,\nhave hg' : g' = (\u03bb b, \u2a06 (c : A') (h : f' c \u2264 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 (\u03bb c, supr_le (\u03bb 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 \u2192 Prop // \u2200 a b, a \u2264 b \u2192 s a \u2192 s b }\n\nvariable {B}\n\nnamespace copresheaf\n\ninstance : has_coe_to_fun (copresheaf B) (\u03bb _, B \u2192 Prop) :=\n\u27e8subtype.val\u27e9\n\n@[simp] lemma coe_mk (s : B \u2192 Prop) (hs : \u2200 a b, a \u2264 b \u2192 s a \u2192 s b) :\n  @coe_fn (copresheaf B) _ _ (\u27e8s, hs\u27e9 : copresheaf B) = s := rfl\n\ninstance : partial_order (copresheaf B) :=\n{ le := \u03bb a b, \u2200 x, b x \u2192 a x,\n  le_trans := \u03bb a b c hab hbc x hcx, hab _ (hbc _ hcx),\n  le_refl := \u03bb _ _, id,\n  le_antisymm := \u03bb a b hab hba, subtype.val_injective (funext $ \u03bb x, propext \u27e8hba _, hab _\u27e9) }\n\nlemma le_def {a b : copresheaf B} : a \u2264 b = \u2200 x, b x \u2192 a x := rfl\n\ninstance : has_Sup (copresheaf B) :=\n{ Sup := \u03bb s, \u27e8\u03bb p, \u2200 B : copresheaf B, B \u2208 s \u2192 B p, \n     \u03bb a b hab h B hBs, B.2 _ _ hab (h _ hBs)\u27e9 }\n\ninstance : complete_lattice (copresheaf B) :=\ncomplete_lattice_of_Sup _\n  (\u03bb 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 {\u03b9 : Sort*} (a : \u03b9 \u2192 copresheaf B) : \n  infi a = \u27e8\u03bb p, \u2203 i, a i p, \u03bb x y hxy \u27e8i, hi\u27e9, \u27e8i, (a i).2 x y hxy hi\u27e9\u27e9 :=\nle_antisymm \n  (infi_le_iff.2 (\u03bb B h p \u27e8i, hi\u27e9, h i _ hi)) \n  (le_infi_iff.2 (\u03bb i p h, \u27e8i, h\u27e9))\n\nlemma supr_def {\u03b9 : Sort*} (a : \u03b9 \u2192 copresheaf B) : \n  supr a = \u27e8\u03bb p, \u2200 i, a i p, \u03bb x y hxy h i, (a i).2 _ y hxy (h i)\u27e9 :=\nle_antisymm \n  (supr_le_iff.2 (\u03bb i p h, h _)) \n  (le_supr_iff.2 (\u03bb B h p hBp i, h i _ hBp))\n\ndef coyoneda (a : B) : copresheaf B :=\n\u27e8\u03bb b, a \u2264 b, \u03bb b c, function.swap le_trans\u27e9\n\ndef le_coyoneda_iff (a : copresheaf B) (p : B) : a \u2264 coyoneda p \u2194 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 \u2264 coyoneda b \u2194 a \u2264 b :=\nbegin\n  rw le_coyoneda_iff, refl\nend\n\nlemma eq_infi (a : copresheaf B) : a = \u2a05 (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 \u03bb _, id },\n  { intros B hB p,\n    exact hB p }\nend\n\ndef extend {B : Type*} [complete_lattice B] (f : A \u2192 B) : copresheaf A \u2192 B :=\n\u03bb a, \u2a05 (p : A) (h : a p), f p\n\ndef blah1 (M : copresheaf (A \u00d7 order_dual B)) : A \u2192o presheaf B :=\n{ to_fun := \u03bb a, \u27e8\u03bb b, M (a, order_dual.to_dual b), \n    \u03bb x y hxy hM, M.2 (a, order_dual.to_dual y) _ \u27e8le_rfl, hxy\u27e9 hM\u27e9,\n  monotone' := \u03bb 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 \u00d7 order_dual B)) : B \u2192o copresheaf A :=\n{ to_fun := \u03bb b, \u27e8\u03bb a, M (a, order_dual.to_dual b), \n    \u03bb x y hxy hM, M.2 (x, order_dual.to_dual b) _ \u27e8hxy, le_rfl\u27e9 hM\u27e9,\n  monotone' := \u03bb 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 \u00d7 order_dual B))\n  (f : A' \u2192 B') (g : B' \u2192 A') \n  (gc : galois_connection g f)\n  (i : A \u2192 A') (j : B \u2192 B') (hi : monotone i) (hj : monotone j)\n  (hf : \u2200 x, f (i x) = presheaf.extend j (blah1 M x)) : \n  \u2200 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 \u00d7 order_dual B))\n  (f : A' \u2192 B') (g : B' \u2192 A') \n  (gc : galois_connection f g)\n  (i : A \u2192 A') (j : B \u2192 B') (hi : monotone i) (hj : monotone j)\n  (hf : \u2200 x, f (i x) = presheaf.extend j (blah1 M x)) : \n  \u2200 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 [\u2190 gc.le_iff_le],\n     }\n\nend\n  \n\nexample {A' B' : Type} [complete_lattice A'] [complete_lattice B'] \n  (f : A \u2192 B) (hf : monotone f) \n  (f' : A' \u2192 B') (g' : B' \u2192 A') (gc : galois_connection f' g') \n  (h1 : ) :\n\nend copresheaf\n\nopen presheaf copresheaf\n\nvariables (f : A \u21aao B) (hf : \u2200 b, { s : set A // is_glb (f '' s) b})\n\nnamespace presheaf\n\ndef u (a : presheaf B) : copresheaf B :=\n\u27e8\u03bb p, coyoneda a (yoneda p), \u03bb a b hab h x hxA, le_trans (h _ hxA) hab\u27e9\n\nlemma u_mono : monotone (@u B _):=\n\u03bb A B h p hp q hAq, hp _ (h _ hAq)\n\ninclude hf\n\ndef d (a : copresheaf B) : presheaf B :=\n\u27e8\u03bb q, \u2200 (x : A), a (f x) \u2192 q \u2264 f x, \u03bb a b hab h x hxA, le_trans hab (h _ hxA)\u27e9\n\nlemma d_mono : monotone (d f hf) :=\n\u03bb 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 \u27e8z, hz, rfl\u27e9,\n    apply h,\n    assumption,\n    rw [\u2190 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 \u2264 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) \u2264 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\u2082],\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\u27e8d f hf (u a), by simp *\u27e9\n\ninstance : partial_order (pscompletion f hf) :=\npartial_order.lift pscompletion.to_presheaf \n  begin\n    rintros \u27e8_, _\u27e9 \u27e8_, _\u27e9,\n    simp\n  end\n\nlemma le_def {a b : pscompletion f hf} : a \u2264 b \u2194 a.to_presheaf \u2264 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 [\u2190 y.fixed, \u2190 (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 {\u03b9 : Sort*} (a : \u03b9 \u2192 pscompletion f hf) : \n  (supr a).to_presheaf = d f hf (\u2a06 i, (a i).to_presheaf).u :=\nbegin \n  rw \u2190 (gi f hf).l_supr_u, refl,\nend\n\n@[simps] def of_partial_order (a : B) : pscompletion f hf :=\n\u27e8yoneda a, by rw [u_yoneda, d_coyoneda f hf]\u27e9\n\n@[simp] lemma of_partial_order_mono {a b : B} : of_partial_order f hf a \u2264 of_partial_order f hf b \u2194 a \u2264 b :=\nyoneda_mono\n\nlemma of_partial_order_le_iff (a : B) (x : pscompletion f hf) : \n  of_partial_order f hf a \u2264 x \u2194 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\u2082, 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\u2082,\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 [\u2190 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 \u2192o C)\n\ndef ump : pscompletion f hf \u2192 C :=\n\u03bb x, \u2a06 (b : B) (h : x.to_presheaf b), i b\n\nlemma ump_supr {\u03b9 : Sort*} (a : \u03b9 \u2192 pscompletion f hf) : ump f hf i (supr a) = \u2a06 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\u2081 b h\u2082,\n    simp [d, u, coyoneda, yoneda, le_def, presheaf.le_def, presheaf.supr_def] at h\u2082,\n    apply h\u2081,\n    apply h\u2082,\n    intros i, admit,  admit},\n  { intros c h\u2081 j b h\u2082,\n    apply h\u2081,\n    intros x h,\n    refine h j _ _,\n    exact h\u2082 }\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 \u00d7 Nat\nderiving Repr, Inhabited\n\ndef Tree.visibleOutside : List Tree \u2192 List Tree\n  | [] => []\n  | t :: ts =>\n    t :: loop t ts\n  where\n  loop (tMax:Tree) : List Tree \u2192 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  -- \ud83c\udf89 finally, just took a rewrite of Tree.visibleOutside\n\ndef Tree.treeHouseVisible (acc:List (Tree \u00d7 List Tree)) : List Tree \u2192 List (Tree \u00d7 List Tree)\n  | [] => acc.reverse\n  | t\u2081 :: ts\u2081 =>\n    let rec visible (acc:List Tree) : List Tree \u2192 List Tree\n      | [] => acc.reverse\n      | t\u2082 :: ts\u2082 =>\n        let acc := t\u2082 :: acc\n        if t\u2082.size < t\u2081.size then\n          visible acc ts\u2082\n        else\n          acc |>.reverse\n    Tree.treeHouseVisible ((t\u2081, visible [] ts\u2081) :: acc) ts\u2081\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 (\u00b7*\u00b7) 1 \u2218 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\u00e9compose en premier caract\u00e8re, reste  INUTILISE-/\ndef un_car : string \u2192 string \u00d7 string\n| \u27e8(x :: xs)\u27e9  := ( \u27e8 [x] \u27e9 , \u27e8 xs \u27e9 )\n| _ := (\"\",\"\")\n\ndef deux_car : string \u2192 string\n| \u27e8(x ::  y :: xs)\u27e9  := \u27e8 [x,y] \u27e9 \n| _ := \"\"\n\ndef trois_car : string \u2192 string\n| \u27e8(x ::  y :: z ::xs)\u27e9  := \u27e8 [x,y,z] \u27e9 \n| _ := \"\"\n\n/- d\u00e9compose une chaine de caract\u00e8res selon la premi\u00e8re parenth\u00e8se ouvrante\nLe premier terme ne sert qu'\u00e0 la r\u00e9cursivit\u00e9  INUTILISE-/\nmeta def debut_chaine : string \u00d7 string \u2192 string \u00d7 string\n| (s , t ) := do\n    let d := un_car t,\n    match d  with\n        | (\"(\",reste) :=  (s,t)\n        | ( \u27e8(x)\u27e9, 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\u00e9, ou bien tout est Prop ??\n-- meta def is_prop : expr \u2192  bool\n--     | `(%%e : Prop) := tt\n   --  | _             := ff\n    \n\n-- d\u00e9termine si l'expression est une propri\u00e9t\u00e9\n-- bas\u00e9 sur le fait (peut-\u00eatre optimiste) que si on \u00e9choue \u00e0 trouver le type, \n-- c'est qu'il y a des variables libres,\n-- et donc que c'est une propri\u00e9t\u00e9\nmeta def is_prop : expr \u2192  tactic bool\n| e := do {\n    expr_t \u2190  infer_type e,\n    -- expr_tt \u2190 infer_type expr_t,\n    if expr_t = `(Prop) then return tt else return ff\n        } <|> return tt\n\n\n/- D\u00e9compose 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 \u00d7 (list expr)) := \ndo  S \u2190  (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 \u2192 binder_info \u2192 expr \u2192 expr \u2192 expr\n------------------------- LOGIQUE -------------------------\n| `(%%p \u2227 %%q) := return (\"PROP_AND\", [p,q])\n| `(%%p \u2228 %%q) := return (\"PROP_OR\", [p,q])\n| `(%%p \u2194 %%q) := return (\"PROP_IFF\", [p,q])\n| `(\u00ac %%p) := return (\"PROP_NOT\", [p])\n| `(%%p \u2192 false)  := return (\"PROP_NOT\", [p])\n| `(%%p \u2192 %%q) :=   if deux_car(to_string e) = \"Pi\" then do match e with -- solution merdique\n                        | (pi name binder type body) :=  return (\"QUANT_\u2200[\" ++ 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 \u2190 infer_type p,\n                         --if t = `(Prop) then return (\"IMPLIQUE\", [p,q])\n                         do bool \u2190 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\u00e9liorer : 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\u00e9t\u00e9\n        -- d'abord, si `body` contient des variables libres, c'est une propri\u00e9t\u00e9\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 \u2190 infer_type type,\n            -- if type_type = `(Prop) \n            do bool \u2190 is_prop p, if bool\n                then return (\"PROP_\u2203[\" ++ to_string name ++ \"]\", [type,body])\n                else return (\"QUANT_\u2203[\" ++ to_string name ++ \"]\", [type,body])\n    |  _ := return (\"ERROR\", [])\n    end \n------------------------- THEORIE DES ENSEMBLES -------------------------\n| `(%%A \u2229 %%B) := return (\"SET_INTER\", [A,B])\n| `(%%A \u222a %%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 \u2286 %%B) := return (\"PROP_INCLUDED\", [A,B])\n| `(%%a \u2208 %%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  \u207b\u00b9' %%A) := return (\"SET_INVERSE\", [f,A])\n| `(\u2205) := 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 \u2260 %%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:\u211d) := return (\"NUMBER[0]\",[])               -- OK, mais peut-\u00eatre faut-il garder l'info 0 : r\u00e9el\n| `(0:\u2115) := return (\"NUMBER[0]\",[])               -- non test\u00e9\n| `(0:\u2124) := return (\"NUMBER[0]\",[])               -- non test\u00e9\n| `(1:\u211d) := return (\"NUMBER[1]\",[])               \n| `(1:\u2115) := return (\"NUMBER[1]\",[])               -- non test\u00e9\n| `(1:\u2124) := return (\"NUMBER[1]\",[])               -- non test\u00e9\n-- | `(0 < %%b) := return (\"POSITIF\", [b]) \n| `(%%a < %%b) := return (\"PROP_<\", [a,b]) \n| `(%%a \u2264 %%b) := return (\"PROP_\u2264\", [a,b])\n-- | `(%%a > 0) := return (\"POSITIF\", [a])\n| `(%%a > %%b) := return (\"PROP_>\", [a,b]) \n| `(%%a \u2265 %%b) := return (\"PROP_\u2265\", [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\u00e9cup\u00e9rer le type ?\n    if is_numeral e\n        then return (\"NUMBER[\"++e_joli ++\"]\",[]) \n    -- d\u00e9tecter 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| `(\u211d) := return (\"TYPE_NUMBER[\u211d]\",[])\n| `(\u2115) := return (\"TYPE_NUMBER[\u2115]\",[])\n| (const name list_level)   := return (\"CONSTANT[name:\"++ e_joli ++ \"/\" ++ to_string name ++\"]\", []) -- name \u2192 list level \u2192 expr\n| (var nat)       := return (\"VAR[\"++ to_string nat ++ \"]\", []) --  nat \u2192 expr\n| (sort level)      := return (\"TYPE\", [])  -- level \u2192 expr\n| (mvar name pretty_name type)        := return (\"METAVAR[\" ++ to_string pretty_name ++ \"]\", []) -- name \u2192 name \u2192 expr \u2192 expr\n| (local_const name pretty_name bi type) := return (\"LOCAL_CONSTANT[name:\"++ to_string pretty_name++\"/identifier:\"++ to_string name ++ \"]\", []) -- name \u2192 name \u2192 binder_info \u2192 expr \u2192 expr\n| (elet name_var type_var expr body)        := return (\"LET[\"++ to_string name_var ++\"]\", [type_var,expr,body]) --name \u2192 expr \u2192 expr \u2192 expr \u2192 expr\n| (macro liste pas_compris)       := return (\"MACRO\", []) -- macro_def \u2192 list expr \u2192 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 := \"\u00bf, \"\ndef separateur_egale := \" \u00bf= \"\ndef open_paren := \"\u00bf(\"\ndef closed_paren := \"\u00bf)\"\n/- Analyse r\u00e9cursivement une expression \u00e0 l'aide de analyse_expr_step, \nrenvoie le r\u00e9sultat sous forme de chaine bien parenth\u00e9s\u00e9e-/\nprivate meta def analyse_rec : expr \u2192  tactic string \n| e := \ndo \u27e8string, liste_expr\u27e9 \u2190  analyse_expr_step(e), \n--    bool \u2190 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\u00e9\n    -- \u00e0 remplacer par un list.map\n    |[e1] :=  do \n       string1 \u2190 analyse_rec e1,\n       return(string ++ open_paren ++ string1 ++ closed_paren)\n    |[e1,e2] :=  do \n        string1 \u2190 analyse_rec e1,\n        string2 \u2190 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\u00e9\n        string1 \u2190 analyse_rec e1,\n        string2 \u2190 analyse_rec e2,\n        string3 \u2190 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 \u2192  tactic string\n| e := do\n    expr_t \u2190  infer_type e,\n    bool \u2190 is_prop expr_t,\n    -- expr_tt \u2190 infer_type expr_t,\n    if bool then do\n            -- S \u2190  (tactic.pp expr_t), \n            -- let S1 := to_string S,\n            S \u2190  (tactic.pp expr_t), let et_joli := to_string S, \n            S1b \u2190 analyse_rec e,\n            S2 \u2190 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 \u2190 analyse_rec e,\n            S2 \u2190 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\u00e9par\u00e9s par des retour chariots \nformat :  \"OBJET\" ou \"PROPRIETE\" : affichage Lean : structure -/\nmeta def analyse_contexte : tactic unit :=\ndo liste_expr \u2190 local_context,\n    trace \"context:\",\n    liste_expr.mmap (\u03bb h, analyse_expr h >>= trace),\n    return ()\n\n\n/- Affiche la liste des buts, m\u00eame format que analyse_contexte\n(except\u00e9 qu'il n'y a que des PROPRIETES) -/ \nmeta def analyse_buts : tactic unit :=\ndo liste_expr \u2190 get_goals,\n    trace \"goals:\", \n    liste_expr.mmap (\u03bb h, analyse_expr h >>= trace),\n    return ()\n\n\n\n---------------------------------------------------------\n--------- NON UTILISES (debuggage) ----------------------------------\n---------------------------------------------------------\n\n\n/- Appelle l'analyse r\u00e9cursive sur le but ou sur une hypoth\u00e8se. Non utilis\u00e9 par la suite. -/\nmeta def analyse (names : parse ident*) : tactic unit := \nmatch names with\n    | [] := do goal \u2190 tactic.target,\n                trace (analyse_rec goal)\n    | [nom] := do expr \u2190 get_local nom,\n                expr_t \u2190  infer_type expr,\n                expr_tt \u2190 infer_type expr_t,\n                -- la suite diff\u00e9rencie selon la s\u00e9mantique, \n                -- ie les objets (\u00e9l\u00e9ments, ensembles, fonctions)\n                -- vs les propri\u00e9t\u00e9s\n                if expr_tt = `(Prop) then  \n                    trace (analyse_rec expr_t)\n                else  do S1 \u2190 (analyse_rec expr), \n                        S2 \u2190 (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\u00e8se. Non utilis\u00e9 par la suite. -/\nmeta def analyse1 (names : parse ident*) : tactic unit := \nmatch names with\n    | [] := do goal \u2190 tactic.target,\n                trace (analyse_expr_step goal)\n    | [nom] := do expr \u2190 get_local nom,\n                expr_t \u2190  infer_type expr,\n                trace (analyse_expr_step expr_t)\n    | _ := skip\n    end\n\n\n-- non utilis\u00e9\nprivate meta def analyse_expr2 : expr \u2192  tactic string\n| e := do\n    expr_t \u2190  infer_type e,\n    expr_tt \u2190 infer_type expr_t,\n    if expr_tt = `(Prop) then do\n            S \u2190  (tactic.pp expr_t), \n            let S1 := to_string S,\n            S2 \u2190 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 \u2190 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\u00e9cider si on met des prenth\u00e8ses-/\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 \u2192  tactic string \n| e := do\n    \u27e8string, liste_expr\u27e9 \u2190  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 \u2190 latex_expr e1,\n        S2 \u2190 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 \u2190 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 \u2190 get_goals,\n    trace \"Buts :\", \n    -- liste_buts \u2190 tactic.get_goals,\n    -- types \u2190 list.mmap tactic.infer_type liste_buts, \n    -- trace types,\n    liste_expr.mmap (\u03bb h, latex_expr h >>= trace),\n    return ()\n\nmeta def latex_but : tactic unit :=\ndo expr \u2190 target,\n    trace \"But :\", \n    -- liste_buts \u2190 tactic.get_goals,\n    -- types \u2190 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 \u00d7 (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 \u2192 list level \u2192 expr\n| (var nat)       := return (\"var_\"++ to_string nat, []) --  nat \u2192 expr\n| (sort level)      := return (\"sort\", [])  -- level \u2192 expr\n| (mvar name pretty_name type)        := return (\"metavar\", []) -- name \u2192 name \u2192 expr \u2192 expr\n| (local_const name pretty_name bi type) := return (\"constante_locale :\" ++ to_string pretty_name, []) -- name \u2192 name \u2192 binder_info \u2192 expr \u2192 expr\n| (lam name binder type body)          := return (\"lambda (nom : \" ++ to_string name ++ \")\", [type,body]) -- name \u2192 binder_info \u2192 expr \u2192 expr \u2192 expr\n| (elet name_var type_var expr body)        := return (\"let\", []) --name \u2192 expr \u2192 expr \u2192 expr \u2192 expr\n| (macro liste pas_compris)       := return (\"macro\", []) -- macro_def \u2192 list expr \u2192 expr\nend\n\n/-  Debug -/\nprivate meta def analyse_rec_brut : expr \u2192  tactic string \n| e := \ndo \u27e8string, liste_expr\u27e9 \u2190  analyse_expr_step_brut e, \n    match liste_expr with\n    -- ATTENTION, cas de plus de trois arguiments non trait\u00e9\n    -- \u00e0 remplacer par un list.map\n    |[e1] :=  do \n       string1 \u2190 analyse_rec_brut e1,\n       return(string ++ \"(\" ++ string1 ++ \")\")\n    |[e1,e2] :=  do \n        string1 \u2190 analyse_rec_brut e1,\n        string2 \u2190 analyse_rec_brut e2,\n        if  string = \"APPLICATION\" then do \n            { type2 \u2190 infer_type e2,\n            let string_type2 := to_string type2, -- trace string_type2, \n            if (string_type2 = \"Type\" ) \u2228 (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\u00e9\n        string1 \u2190 analyse_rec_brut e1,\n        string2 \u2190 analyse_rec_brut e2,\n        string3 \u2190 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 \u2190 tactic.target,\n                trace (analyse_rec_brut goal)\n    | [nom] := do expr \u2190 get_local nom,\n                expr_t \u2190  infer_type expr,\n                expr_tt \u2190 infer_type expr_t,\n                -- la suite diff\u00e9rencie selon la s\u00e9mantique, \n                -- ie les objets (\u00e9l\u00e9ments, ensembles, fonctions)\n                -- vs les propri\u00e9t\u00e9s\n                if expr_tt = `(Prop) then  \n                    trace (analyse_rec_brut expr_t)\n                else  do S1 \u2190 (analyse_rec_brut expr), \n                        S2 \u2190 (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\u00e9bug    \nprivate meta def analyse_expr_brut : expr \u2192  tactic string\n| e := do\n    expr_t \u2190  infer_type e,\n    expr_tt \u2190 infer_type expr_t,\n    if expr_tt = `(Prop) then do\n            S \u2190  (tactic.pp expr_t), \n            let S1 := to_string S,\n            S2 \u2190 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 \u2190 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\u00e9par\u00e9s par des retour chariots \nformat :  \"OBJET\" ou \"PROPRIETE\" : affichage Lean : structure -/\nmeta def analyse_contexte_brut : tactic unit :=\ndo liste_expr \u2190 local_context,\n    trace \"Contexte :\",\n    liste_expr.mmap (\u03bb 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 \u2190 tactic.target,\n                trace $ to_raw_fmt goal\n    | [nom] := do expr \u2190 get_local nom,\n                expr_t \u2190  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:\u211d) :  x^2 \u2265 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 \u2192 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) $ \u03bb 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 | \u2203 L : list G, (\u2200 x \u2208 L, \u2203 p \u2208 S, \u2203 q \u2208 S, x = p * q * p\u207b\u00b9 * q\u207b\u00b9) \u2227 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 := \u03bb x y \u27e8L1, h1, h2\u27e9 \u27e8L2, h3, h4\u27e9, \u27e8L1 ++ L2,\n    list.forall_mem_append.2 \u27e8h1, h3\u27e9,\n    by simp [h2, h4]\u27e9,\n  one_mem := \u27e8[], by simp\u27e9,\n  inv_mem := \u03bb x \u27e8L, h1, h2\u27e9, \u27e8L.reverse.map has_inv.inv,\n    \u03bb x hx, let \u27e8y, h3, h4\u27e9 := list.exists_of_mem_map hx in\n      let \u27e8p, hp, q, hq, h5\u27e9 := h1 y (list.mem_reverse.1 h3) in\n      \u27e8q, hq, p, hp, by rw [\u2190 h4, h5]; simp [mul_assoc]\u27e9,\n    by rw \u2190 h2; from list.rec_on L (by simp) (\u03bb hd tl ih,\n      by rw [list.reverse_cons, list.map_append, list.prod_append, ih]; simp)\u27e9 }\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 := \u03bb x \u27e8L, h1, h2\u27e9 g, \u27e8L.map $ \u03bb z, g * z * g\u207b\u00b9,\n    \u03bb x hx, let \u27e8y, h3, h4\u27e9 := list.exists_of_mem_map hx in\n      let \u27e8p, hp, q, hq, h5\u27e9 := h1 y h3 in\n      \u27e8g * p * g\u207b\u00b9, normal_subgroup.normal _ hp _,\n      g * q * g\u207b\u00b9, normal_subgroup.normal _ hq _,\n      by rw [\u2190 h4, h5]; simp [mul_assoc]\u27e9,\n    by rw \u2190 h2; from list.rec_on L (by simp) (\u03bb hd tl ih,\n      by rw [list.map_cons, list.prod_cons, ih]; simp [mul_assoc])\u27e9 }\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 := \u03bb x y, quotient_group.induction_on x $ \u03bb m,\n    quotient_group.induction_on y $ \u03bb n, quotient_group.eq.2 $\n    subset_closure \u27e8[n\u207b\u00b9*m\u207b\u00b9*n*m], list.forall_mem_singleton.2\n      \u27e8n\u207b\u00b9, trivial, m\u207b\u00b9, trivial, by rw [inv_inv, inv_inv]\u27e9,\n    by rw [list.prod_cons, list.prod_nil, mul_one, mul_inv_rev, \u2190 mul_assoc]\u27e9,\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 \u2192 H) [hf : is_topological_group_hom f] :\n  Hausdorff_abelianization G \u2192 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\u03bb x \u27e8L, hL, hLx\u27e9, subset_closure \u27e8L.map f,\n  \u03bb c hcfL, let \u27e8b, hbL, hfbc\u27e9 := list.exists_of_mem_map hcfL in\n    let \u27e8p, _, q, _, hb\u27e9 := hL b hbL in\n    \u27e8f p, trivial, f q, trivial, by rw [\u2190 hfbc, hb];\n      simp only [is_group_hom.mul f, is_group_hom.inv f]\u27e9,\n  by rw [list.prod_map f, hLx]\u27e9\n\nset_option class.instance_max_depth 100\ntheorem Hausdorff_abelianization.induced.is_topological_group_hom\n  (f : G \u2192 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 \u2218 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 \u2964 PresheafedSpace C`,\nwe first build the colimit of the underlying topological spaces,\nas `colimit (F \u22d9 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.\u03b9 (F \u22d9 PresheafedSpace.forget C) j` to `X`.\nSince pushforward is functorial, we obtain a diagram `J \u2964 (presheaf C X)\u1d52\u1d56`\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 \u2964 PresheafedSpace C) (j) (U) :\n  (F.map (\ud835\udfd9 j)).c.app (op U) =\n    (pushforward.id (F.obj j).presheaf).inv.app (op U) \u226b\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)\u1d52\u1d56`.\n-/\n@[simps]\ndef pushforward_diagram_to_colimit (F : J \u2964 PresheafedSpace C) :\n  J \u2964 (presheaf C (colimit (F \u22d9 PresheafedSpace.forget C)))\u1d52\u1d56 :=\n{ obj := \u03bb j, op ((colimit.\u03b9 (F \u22d9 PresheafedSpace.forget C) j) _* (F.obj j).presheaf),\n  map := \u03bb j j' f,\n  (pushforward_map (colimit.\u03b9 (F \u22d9 PresheafedSpace.forget C) j') (F.map f).c \u226b\n    (pushforward.comp (F.obj j).presheaf ((F \u22d9 PresheafedSpace.forget C).map f)\n      (colimit.\u03b9 (F \u22d9 PresheafedSpace.forget C) j')).inv \u226b\n    (pushforward_eq (colimit.w (F \u22d9 PresheafedSpace.forget C) f) (F.obj j).presheaf).hom).op,\n  map_id' := \u03bb 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' := \u03bb j\u2081 j\u2082 j\u2083 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.\u03b9 (F \u22d9 PresheafedSpace.forget C) j\u2082)).obj (unop U)),\n    -- Now we show the open sets are equal.\n    swap 2,\n    { apply unop_injective,\n      rw \u2190opens.map_comp_obj,\n      congr,\n      exact colimit.w (F \u22d9 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 \u2964 PresheafedSpace C) : PresheafedSpace C :=\n{ carrier := colimit (F \u22d9 PresheafedSpace.forget C),\n  presheaf := limit (pushforward_diagram_to_colimit F).left_op, }\n\n@[simp] lemma colimit_carrier (F : J \u2964 PresheafedSpace C) :\n  (colimit F).carrier = limits.colimit (F \u22d9 PresheafedSpace.forget C) := rfl\n\n@[simp] lemma colimit_presheaf (F : J \u2964 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 \u2964 PresheafedSpace C) : cocone F :=\n{ X := colimit F,\n  \u03b9 :=\n  { app := \u03bb j,\n    { base := colimit.\u03b9 (F \u22d9 PresheafedSpace.forget C) j,\n      c := limit.\u03c0 _ (op j), },\n    naturality' := \u03bb j j' f,\n    begin\n      fapply PresheafedSpace.ext,\n      { ext x,\n        exact colimit.w_apply (F \u22d9 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 \u2190 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 \u2964 PresheafedSpace C) (s : cocone F) (U : (opens \u21a5(s.X.carrier))\u1d52\u1d56) :\n  s.X.presheaf.obj U \u27f6\n    (colimit.desc (F \u22d9 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, \u03c0 := { app := \u03bb j, _, naturality' := \u03bb j j' f, _, }} \u226b\n      (limit_obj_iso_limit_comp_evaluation _ _).inv,\n  -- We still need to construct the `app` and `naturality'` fields omitted above.\n  { refine (s.\u03b9.app (unop j)).c.app U \u226b (F.obj (unop j)).presheaf.map (eq_to_hom _),\n    dsimp,\n    rw \u2190opens.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.\u03b9_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 \u2964 PresheafedSpace C) (s : cocone F)\n  {U V : (opens \u21a5(s.X.carrier))\u1d52\u1d56} (i : U \u27f6 V) :\n  s.X.presheaf.map i \u226b desc_c_app F s V =\n  desc_c_app F s U \u226b (colimit.desc (F \u22d9 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_\u03c0, nat_trans.naturality, limit.lift_\u03c0_assoc, eq_to_hom_map, assoc,\n    pushforward_obj_map, nat_trans.naturality_assoc, op_map,\n    limit_obj_iso_limit_comp_evaluation_inv_\u03c0_app_assoc,\n    limit_obj_iso_limit_comp_evaluation_inv_\u03c0_app],\n  dsimp,\n  have w := functor.congr_hom (congr_arg opens.map\n    (colimit.\u03b9_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 \u2964 PresheafedSpace C) (s : cocone F) : colimit F \u27f6 s.X :=\n{ base := colimit.desc (F \u22d9 PresheafedSpace.forget C) ((PresheafedSpace.forget C).map_cocone s),\n  c :=\n  { app := \u03bb U, desc_c_app F s U,\n    naturality' := \u03bb U V i, desc_c_naturality F s i } }\n\nlemma desc_fac  (F : J \u2964 PresheafedSpace C) (s : cocone F) (j : J) :\n  (colimit_cocone F).\u03b9.app j \u226b desc F s = s.\u03b9.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 \u2964 PresheafedSpace C) : is_colimit (colimit_cocone F) :=\n{ desc := \u03bb s, desc F s,\n  fac' := \u03bb s, desc_fac F s,\n  uniq' := \u03bb 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 \u22d9 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.\u03b9_desc_apply, map_cocone_\u03b9_app],\n      rw \u2190 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_\u03c0, eq_to_hom_op, eq_to_hom_map, assoc,\n        limit_obj_iso_limit_comp_evaluation_inv_\u03c0_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.\u03c0 (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 := \u03bb J \ud835\udca5, by exactI\n  { has_colimit := \u03bb 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 := \u03bb J \ud835\udca5, by exactI\n  { preserves_colimit := \u03bb 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 \u2964 PresheafedSpace C)\n  (U : opens (limits.colimit F).carrier) : J\u1d52\u1d56 \u2964 C :=\n{ obj := \u03bb j, (F.obj (unop j)).presheaf.obj (op ((opens.map (colimit.\u03b9 F (unop j)).base).obj U)),\n  map := \u03bb j k f, (F.map f.unop).c.app _ \u226b (F.obj (unop k)).presheaf.map\n    (eq_to_hom (by { rw [\u2190 colimit.w F f.unop, comp_base], refl })),\n  map_comp' := \u03bb 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, \u2190 (F.obj (unop k)).presheaf.map_comp],\n    erw \u2190 (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 \u2964 PresheafedSpace C)\n  (U : opens (limits.colimit F).carrier) :\n  (limits.colimit F).presheaf.obj (op U) \u2245 limit (componentwise_diagram F U) :=\nbegin\n  refine ((sheaf_iso_of_iso (colimit.iso_colimit_cocone\n    \u27e8_, colimit_cocone_is_colimit F\u27e9).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 \u2190 comp_app,\n    congr' 2,\n    exact \u03b9_preserves_colimits_iso_inv (forget C) F (unop X) },\n  { intros X Y f,\n    change ((F.map f.unop).c.app _ \u226b _ \u226b _) \u226b (F.obj (unop Y)).presheaf.map _ = _ \u226b _,\n    rw Top.presheaf.pushforward.comp_inv_app,\n    erw category.id_comp,\n    rw category.assoc,\n    erw [\u2190 (F.obj (unop Y)).presheaf.map_comp, (F.map f.unop).c.naturality_assoc,\n      \u2190 (F.obj (unop Y)).presheaf.map_comp],\n    congr }\nend\n\n@[simp]\nlemma colimit_presheaf_obj_iso_componentwise_limit_inv_\u03b9_app (F : J \u2964 PresheafedSpace C)\n  (U : opens (limits.colimit F).carrier) (j : J) :\n  (colimit_presheaf_obj_iso_componentwise_limit F U).inv \u226b (colimit.\u03b9 F j).c.app (op U) =\n    limit.\u03c0 _ (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 [\u2190 functor.map_comp_assoc, nat_trans.naturality],\n  erw \u2190 comp_c_app_assoc,\n  rw congr_app (colimit.iso_colimit_cocone_\u03b9_hom _ _),\n  simp_rw category.assoc,\n  erw [limit_obj_iso_limit_comp_evaluation_inv_\u03c0_app_assoc, lim_map_\u03c0_assoc],\n  convert category.comp_id _,\n  erw \u2190 (F.obj j).presheaf.map_id,\n  iterate 2 { erw \u2190 (F.obj j).presheaf.map_comp },\n  congr\nend\n\n@[simp]\nlemma colimit_presheaf_obj_iso_componentwise_limit_hom_\u03c0 (F : J \u2964 PresheafedSpace C)\n  (U : opens (limits.colimit F).carrier) (j : J) :\n    (colimit_presheaf_obj_iso_componentwise_limit F U).hom \u226b limit.\u03c0 _ (op j) =\n      (colimit.\u03b9 F j).c.app (op U) :=\nby rw [\u2190 iso.eq_inv_comp, colimit_presheaf_obj_iso_componentwise_limit_inv_\u03b9_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 {\u03b1 \u03b2 \u03b3 : Type}\nvariable {X Y Z : Type} [Hilbert X] [Hilbert Y] [Hilbert Z]\nvariable {\u03b9 \u03ba : Type} [Enumtype \u03b9] [Enumtype \u03ba]\n\nvariable {n : Nat} [NonZero n]\n\n-- set_option trace.Meta.Tactic.simp true in\nexample\n  : \ud835\udcd1 (\u03bb x : Fin n \u2192 Fin 3 \u2192 \u211d => \u2211 i j, \u2225x i - x j\u2225\u00b2)\n    = \n    0 := \nby\n  simp\n  simp\n  admit\n\n\ninstance (x y : X) : HasAdjoint \u03bb dx => \u2202 (\u03bb x y : X => x - y) x dx y := \nby \n  simp infer_instance done\n\ninstance (x y : X) : HasAdjoint \u03bb dy => \u2202 (\u03bb y : X => x - y) y dy := \nby \n  simp\n  infer_instance done\n\n\nvariable (f : (\u03b1 \u2192 (\u03b2\u00d7(\u03b2\u2192\u03b1))))\n\n@[simp]\ntheorem reverse_comp_id {\u03b1 \u03b2 : Type} (f : (\u03b1 \u2192 (\u03b2\u00d7(\u03b2\u2192\u03b1)))) \n  : f \u2022 (\u03bb x => (x, \u03bb 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 {\u03b1 \u03b2 : Type} (f : (\u03b1 \u2192 (\u03b2\u00d7(\u03b2\u2192\u03b1)))) \n  : (\u03bb x => (x, \u03bb dx => dx)) \u2022 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  : (\ud835\udcd1 fun (x : Fin n \u2192 X) => x i - x j)\n    =\n    (fun x : X\u00d7X => (x.1 - x.2, fun dx : X => (dx, -dx))) \u2022\n      ReverseDiff.reverse_lmap \n        (fun fx : Fin n \u2192 X => (fx i, fun (dv : X) k => kron i k * dv)) \n        (fun fx : Fin n \u2192 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\u2080 X\u2081 X\u2082 X\u2083 : Type} [Hilbert X\u2080] [Hilbert X\u2081] [Hilbert X\u2082] [Hilbert X\u2083]\n  variable {W\u2081 W\u2082 : Type} [Hilbert W\u2081] [Hilbert W\u2082] [Hilbert W\u2083]\n  variable (f\u2081 : W\u2081 \u2192 X\u2080 \u2192 X\u2081) [IsSmooth f\u2081] [\u2200 w, IsSmooth (f\u2081 w)]\n     [\u2200 w x, HasAdjoint \u03bb dw => \u2202 f\u2081 w dw x]\n     [\u2200 w x, HasAdjoint \u03bb dx => \u2202 (f\u2081 w) x dx]\n  variable (f\u2082 : W\u2082 \u2192 X\u2081 \u2192 X\u2082) [IsSmooth f\u2082] [\u2200 w, IsSmooth (f\u2082 w)]\n     [\u2200 w x, HasAdjoint \u03bb dw => \u2202 f\u2082 w dw x]\n     [\u2200 w x, HasAdjoint \u03bb dx => \u2202 (f\u2082 w) x dx]\n  variable (f\u2083 : W\u2083 \u2192 X\u2082 \u2192 X\u2083) [IsSmooth f\u2083] [\u2200 w, IsSmooth (f\u2083 w)]\n     [\u2200 w x, HasAdjoint \u03bb dw => \u2202 f\u2083 w dw x]\n     [\u2200 w x, HasAdjoint \u03bb dx => \u2202 (f\u2083 w) x dx]\n\n     -- [\u2200 x\u2080 (x : W\u2081 \u00d7 W\u2082), SciLean.HasAdjoint (SciLean.differential (fun x => f\u2081 x.1 x\u2080) x)]\n     -- [\u2200 (x\u2080 : X\u2080) (x : W\u2081 \u00d7 W\u2082), SciLean.HasAdjoint (SciLean.differential (fun x => x\u2080) x)]\n\n  instance (x : W\u2081 \u00d7 W\u2082) : SciLean.HasAdjoint (\u2202 (fun x => x.1) x) := sorry\n  instance (x : W\u2081 \u00d7 W\u2082) : SciLean.HasAdjoint (\u2202 (fun x => x.2) x) := sorry\n\n\n  instance (f : X \u2192 W\u2081\u00d7W\u2082) [IsSmooth f] [HasAdjoint (\u2202 f x)] : SciLean.HasAdjoint (\u2202 (fun x => (f x).1) x) := by simp admit\n  instance (f : X \u2192 W\u2081\u00d7W\u2082) [IsSmooth f] [HasAdjoint (\u2202 f x)] : SciLean.HasAdjoint (\u2202 (fun x => (f x).2) x) := by simp admit\n\n\n  -- instance : \u2200 (x : W\u2081 \u00d7 W\u2082 \u00d7 W\u2083), 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 (\u03bb ((w\u2081,w\u2082,w\u2083) : W\u2081 \u00d7 W\u2082 \u00d7 W\u2083) => w\u2083) := by  infer_instance \n\n  @[simp]\n  theorem reverse_diff_of_id\n    : \ud835\udcd1 (\u03bb x : X => x) = \u03bb x => (x, \u03bb dx => dx) := by simp[reverse_diff, adjoint_differential] done\n\n  @[simp]\n  theorem reverse_diff_of_const (y : Y)\n    : \ud835\udcd1 (\u03bb x : X => y) = \u03bb x => (y, \u03bb dy : Y => (0:X)) := by simp[reverse_diff, adjoint_differential] done\n\n  @[simp]\n  theorem reverse_diff_of_fst\n    : \ud835\udcd1 (\u03bb xy : X\u00d7Y => xy.1) = \u03bb xy => (xy.1, \u03bb dx => (dx, (0:Y))) := by simp[reverse_diff, adjoint_differential] done\n\n  @[simp]\n  theorem reverse_diff_of_snd\n    : \ud835\udcd1 (\u03bb xy : X\u00d7Y => xy.2) = \u03bb xy => (xy.2, \u03bb dy => ((0:X), dy)) := by simp[reverse_diff, adjoint_differential] done\n\n  @[simp]\n  theorem reverse_diff_of_fst_comp (f : X \u2192 Y\u00d7Z) [IsSmooth f] [\u2200 x, HasAdjoint (\u2202 f x)]\n    : \ud835\udcd1 (\u03bb x : X => (f x).1) = (\u03bb yz => (yz.1, \u03bb dy => (dy, (0:Z)))) \u2022 \ud835\udcd1 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 \u2192 Y\u00d7Z) [IsSmooth f] [\u2200 x, HasAdjoint (\u2202 f x)]\n    : \ud835\udcd1 (\u03bb x : X => (f x).2) = (\u03bb yz => (yz.2, \u03bb dz => ((0:Y), dz))) \u2022 \ud835\udcd1 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\u2082 x.2.1 (f\u2081 x.1 x\u2080)\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\u2080 : X\u2080)\n    -- : \ud835\udcd1 (\u03bb (w\u2081,w\u2082,w\u2083) => x\u2080 |> f\u2081 w\u2081 |> f\u2082 w\u2082 |> f\u2083 w\u2083) = 0 :=\n    : \ud835\udcd1 (\u03bb (w\u2081,w\u2082,w\u2083) => x\u2080 |> f\u2081 w\u2081 |> f\u2082 w\u2082 |> f\u2083 w\u2083) = 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 (\u03bb T : Type => T))\n  h_len : Ts.length = data.size\n  typed : \u2200 i : Fin Ts.length, (data.get (h_len \u25b8 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 \u25b8 (u.data.get (u.h_len \u25b8 i)).2\n\n  def getOp (self : HArray Ts) (idx : Fin Ts.length) : Ts.get idx\n    := self.typed idx \u25b8 (self.data.get (self.h_len \u25b8 idx)).2\n\n  def set (u : HArray Ts) (i : Fin Ts.length) (x : Ts.get i) : HArray Ts\n    := \u27e8u.data.set (u.h_len \u25b8 i) (\u27e8_, x\u27e9), sorry, sorry\u27e9\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 \u2192 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 : \u2200 j, i + j < Xs.length \u2192 Xs'.get \u27e8j, sorry\u27e9 = Xs.get \u27e8i + j, sorry\u27e9\n  G : Type\n  uncurry : G \u2192 (HArray Xs \u2192 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 := \u03bb 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' \u2192 c.G\n  uncurry := \u03bb f xs => \n    let h : (Xs.get \u27e8i,sorry\u27e9 = X') := sorry\n    let xi : X' := (h \u25b8 xs[\u27e8i,sorry\u27e9])\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 \u25b8 f)\n\n-- example : huncurry 3 (\u03bb (i j k : Nat) => i + j) \n--           = \n--           \u03bb xs => xs[\u27e80, by decide\u27e9] + xs[\u27e81, by decide\u27e9] := 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 {\u03b9 : Type _} {c : ComplexShape \u03b9} {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 \u27f6 M} {g : M \u27f6 N} (w : f \u226b g = 0)\n    {h k : homology f g w \u27f6 K}\n    (w :\n      \u2200 x : LinearMap.ker g,\n        h (cokernel.\u03c0 (imageToKernel _ _ w) (toKernelSubobject x)) =\n          k (cokernel.\u03c0 (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 `\u2243`.\n  equiv_rw(kernel_subobject_iso g \u226a\u226b 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 : \u03b9}\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 : \u03b9} {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 \u27f6 D) {i : \u03b9} (x : LinearMap.ker (C.dFrom i)) :\n    (cyclesMap f i) (toCycles x) = toCycles \u27e8f.f i x.1, by simp [x.2]\u27e9 :=\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 : \u03b9}\n    (x : LinearMap.ker (C.dFrom i)) : C.homology i :=\n  homology.\u03c0 (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 : \u03b9) {h k : C.homology i \u27f6 M}\n    (w : \u2200 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 \u27f6 D) (h : Homotopy f g) (i : \u03b9) :\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.\u03c0_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 `\ud835\udcd0`, a graded `A`-module `M` is expressed as\n`direct_sum.decomposition \ud835\udcdc` and `set_like.has_graded_smul \ud835\udcd0 \ud835\udcdc`.\nThen `\u2a01 i, \ud835\udcdc 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 {\u03b9 : Type _} (A : \u03b9 \u2192 Type _) (M : \u03b9 \u2192 Type _)\n\nnamespace DirectSum\n\nopen GradedMonoid\n\n/-- A graded version of `distrib_mul_action`. -/\nclass GdistribMulAction [AddMonoid \u03b9] [GMonoid A] [\u2200 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 \u03b9] [\u2200 i, AddMonoid (A i)] [\u2200 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 \u03b9] [AddMonoid \u03b9] [\u2200 i : \u03b9, 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 \u03b9] [\u2200 i : \u03b9, AddCommMonoid (A i)] [\u2200 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 \u2192+ M j \u2192+ 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\u2081 a\u2082 := 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`\u2a01\u1d62 A\u1d62`-scalar multiplication on `\u2a01\u1d62 M\u1d62` induced by `gsmul_hom`. -/\ndef smulAddMonoidHom [DecidableEq \u03b9] [GMonoid A] [Gmodule A M] :\n    (\u2a01 i, A i) \u2192+ (\u2a01 i, M i) \u2192+ \u2a01 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 \u03b9] [GMonoid A] [Gmodule A M] : SMul (\u2a01 i, A i) (\u2a01 i, M i)\n    where smul x y := smulAddMonoidHom A M x y\n\n@[simp]\ntheorem smul_def [DecidableEq \u03b9] [GMonoid A] [Gmodule A M] (x : \u2a01 i, A i) (y : \u2a01 i, M i) :\n    x \u2022 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 \u03b9] [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 \u03b9] [GMonoid A] [Gmodule A M] {i j} (x : A i) (y : M j) :\n    DirectSum.of A i x \u2022 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 \u03b9] [GMonoid A] [Gmodule A M] (x : \u2a01 i, M i) :\n    (1 : \u2a01 i, A i) \u2022 x = x :=\n  by\n  suffices smulAddMonoidHom A M 1 = AddMonoidHom.id (\u2a01 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 \u03b9] [Gsemiring A] [Gmodule A M] (a b : \u2a01 i, A i)\n    (c : \u2a01 i, M i) : (a * b) \u2022 c = a \u2022 b \u2022 c :=\n  by\n  suffices\n    (-- `\u03bb a b c, (a * b) \u2022 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-- `\u03bb a b c, a \u2022 (b \u2022 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 \u03b9] [Gsemiring A] [Gmodule A M] : Module (\u2a01 i, A i) (\u2a01 i, M i)\n    where\n  smul := (\u00b7 \u2022 \u00b7)\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 {\u03b9 R A M \u03c3 \u03c3' : Type _}\n\nvariable [AddMonoid \u03b9] [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable (\ud835\udcd0 : \u03b9 \u2192 \u03c3') [SetLike \u03c3' A]\n\nvariable (\ud835\udcdc : \u03b9 \u2192 \u03c3)\n\nnamespace SetLike\n\ninclude \u03c3' A \u03c3 M\n\ninstance gmulAction [AddMonoid M] [DistribMulAction A M] [SetLike \u03c3 M] [SetLike.GradedMonoid \ud835\udcd0]\n    [SetLike.GradedSmul \ud835\udcd0 \ud835\udcdc] : GradedMonoid.GMulAction (fun i => \ud835\udcd0 i) fun i => \ud835\udcdc i :=\n  {\n    SetLike.toGSmul \ud835\udcd0\n      \ud835\udcdc with\n    one_smul := fun \u27e8i, m\u27e9 => Sigma.subtype_ext (zero_add _) (one_smul _ _)\n    mul_smul := fun \u27e8i, a\u27e9 \u27e8j, a'\u27e9 \u27e8k, b\u27e9 => Sigma.subtype_ext (add_assoc _ _ _) (mul_smul _ _ _) }\n#align set_like.gmul_action SetLike.gmulAction\n\ninstance gdistribMulAction [AddMonoid M] [DistribMulAction A M] [SetLike \u03c3 M]\n    [AddSubmonoidClass \u03c3 M] [SetLike.GradedMonoid \ud835\udcd0] [SetLike.GradedSmul \ud835\udcd0 \ud835\udcdc] :\n    DirectSum.GdistribMulAction (fun i => \ud835\udcd0 i) fun i => \ud835\udcdc i :=\n  {\n    SetLike.gmulAction \ud835\udcd0\n      \ud835\udcdc 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 \u03c3 M] [AddSubmonoidClass \u03c3' A]\n  [AddSubmonoidClass \u03c3 M] [SetLike.GradedMonoid \ud835\udcd0] [SetLike.GradedSmul \ud835\udcd0 \ud835\udcdc]\n\n/-- `[set_like.graded_monoid \ud835\udcd0] [set_like.has_graded_smul \ud835\udcd0 \ud835\udcdc]` 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 => \ud835\udcd0 i) fun i => \ud835\udcdc i :=\n  {\n    SetLike.gdistribMulAction \ud835\udcd0\n      \ud835\udcdc with\n    smul := fun i j x y => \u27e8(x : A) \u2022 (y : M), SetLike.GradedSmul.smul_mem x.2 y.2\u27e9\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 \u03c3' A \u03c3 M\n\nvariable [AddCommMonoid M] [Module A M] [SetLike \u03c3 M] [AddSubmonoidClass \u03c3' A]\n  [AddSubmonoidClass \u03c3 M] [SetLike.GradedMonoid \ud835\udcd0] [SetLike.GradedSmul \ud835\udcd0 \ud835\udcdc]\n\n/-- The smul multiplication of `A` on `\u2a01 i, \ud835\udcdc i` from `(\u2a01 i, \ud835\udcd0 i) \u2192+ (\u2a01 i, \ud835\udcdc i) \u2192+ \u2a01 i, \ud835\udcdc i`\nturns `\u2a01 i, \ud835\udcdc i` into an `A`-module\n-/\ndef isModule [DecidableEq \u03b9] [GradedRing \ud835\udcd0] : Module A (\u2a01 i, \ud835\udcdc i) :=\n  { Module.compHom _ (DirectSum.decomposeRingEquiv \ud835\udcd0 : A \u2243+* \u2a01 i, \ud835\udcd0 i).toRingHom with\n    smul := fun a b => DirectSum.decompose \ud835\udcd0 a \u2022 b }\n#align graded_module.is_module GradedModule.isModule\n\nattribute [local instance] GradedModule.isModule\n\n/-- `\u2a01 i, \ud835\udcdc 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 \u03b9] [GradedRing \ud835\udcd0] [DirectSum.Decomposition \ud835\udcdc] : M \u2243\u2097[A] \u2a01 i, \ud835\udcdc i :=\n  {\n    DirectSum.decomposeAddEquiv\n      \ud835\udcdc with\n    toFun := DirectSum.decomposeAddEquiv \ud835\udcdc\n    map_smul' := fun x y => by\n      classical\n        rw [\u2190 DirectSum.sum_support_decompose \ud835\udcd0 x, map_sum, Finset.sum_smul, map_sum,\n          Finset.sum_smul, Finset.sum_congr rfl fun i hi => _]\n        rw [RingHom.id_apply, \u2190 DirectSum.sum_support_decompose \ud835\udcdc y, map_sum, Finset.smul_sum,\n          map_sum, Finset.smul_sum, Finset.sum_congr rfl fun j hj => _]\n        simp only [(\u00b7 \u2022 \u00b7), DirectSum.decomposeAddEquiv_apply, DirectSum.decompose_coe,\n          DirectSum.Gmodule.smulAddMonoidHom_apply_of_of]\n        convert DirectSum.decompose_coe \ud835\udcdc _\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 {\u03b1 : Sort u} {a b : \u03b1} (h : a \u2245 b) : a = b :=\nmatch \u03b1, a, b, h with\n| _, _, _, HEq.refl _ => rfl\n\ntheorem ex2 {\u03b1 : Sort u} {a b : \u03b1} (h : a \u2245 b) : a = b :=\nmatch a, b, h with\n| _, _, HEq.refl _ => rfl\n\ntheorem ex3 {\u03b1 : Sort u} {a b : \u03b1} (h : a \u2245 b) : a = b :=\nmatch b, h with\n| _, HEq.refl _ => rfl\n\ntheorem ex4  {\u03b1 \u03b2 : Sort u} {b : \u03b2} {a a' : \u03b1} (h\u2081 : a = a') (h\u2082 : a' \u2245 b) : a \u2245 b :=\nmatch \u03b2, a', b, h\u2081, h\u2082 with\n| _, _, _, rfl, HEq.refl _ => HEq.refl _\n\ntheorem ex5  {\u03b1 \u03b2 : Sort u} {b : \u03b2} {a a' : \u03b1} (h\u2081 : a = a') (h\u2082 : a' \u2245 b) : a \u2245 b :=\nmatch a', h\u2081, h\u2082 with\n| _, rfl, h\u2082 => h\u2082\n\ntheorem ex6  {\u03b1 \u03b2 : Sort u} {b : \u03b2} {a a' : \u03b1} (h\u2081 : a = a') (h\u2082 : a' \u2245 b) : a \u2245 b :=\nby {\n  subst h\u2081;\n  assumption\n}\n\ntheorem ex7 (a : Bool) (p q : Prop) (h\u2081 : a = true \u2192 p) (h\u2082 : a = false \u2192 q) : p \u2228 q :=\n  match (generalizing := false) h:a with\n  | true  => Or.inl $ h\u2081 h\n  | false => Or.inr $ h\u2082 h\n\ntheorem ex7' (a : Bool) (p q : Prop) (h\u2081 : a = true \u2192 p) (h\u2082 : a = false \u2192 q) : p \u2228 q :=\n  match a with\n  | true  => Or.inl $ h\u2081 rfl\n  | false => Or.inr $ h\u2082 rfl\n\ndef head {\u03b1} (xs : List \u03b1) (h : xs = [] \u2192 False) : \u03b1 :=\n  match he:xs with\n  | []   => by contradiction\n  | x::_ => x\n\nvariable {\u03b1 : Type u} {p : \u03b1 \u2192 Prop}\n\ntheorem ex8 {a1 a2 : {x // p x}} (h : a1.val = a2.val) : a1 = a2 :=\nmatch a1, a2, h with\n| \u27e8_, _\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\nuniverses v\nvariable {\u03b2 : \u03b1 \u2192 Type v}\n\ntheorem ex9 {p\u2081 p\u2082 : Sigma (fun a => \u03b2 a)} (h\u2081 : p\u2081.1 = p\u2082.1) (h : p\u2081.2 \u2245 p\u2082.2) : p\u2081 = p\u2082 :=\nmatch p\u2081, p\u2082, h\u2081, h with\n| \u27e8_, _\u27e9, \u27e8_, _\u27e9, rfl, HEq.refl _ => rfl\n\ninductive F : Nat \u2192 Type\n| z : {n : Nat} \u2192 F (n+1)\n| s : {n : Nat} \u2192 F n \u2192 F (n+1)\n\ndef f0 {\u03b1 : Sort u} (x : F 0) : \u03b1 :=\nnomatch x\n\ndef f0' {\u03b1 : Sort u} (x : F 0) : \u03b1 :=\nnomatch id x\n\ndef f1 {\u03b1 : Sort u} (x : F 0 \u00d7 Bool) : \u03b1 :=\nnomatch x\n\ndef f2 {\u03b1 : Sort u} (x : Sum (F 0) (F 0)) : \u03b1 :=\nnomatch x\n\ndef f3 {\u03b1 : Sort u} (x : Bool \u00d7 F 0) : \u03b1 :=\nnomatch x\n\ndef f4 (x : Sum (F 0 \u00d7 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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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\u2081`\nof functors `C \u2964 karoubi D` to functors `karoubi C \u2964 karoubi D`. This results in an\nequivalence `karoubi_universal\u2081 C D : (C \u2964 karoubi D) \u224c (karoubi C \u2964 karoubi D)`.\n\nWe also construct an extension `functor_extension\u2082` of functors\n`(C \u2964 D) \u2964 (karoubi C \u2964 karoubi D)`. Moreover,\nwhen `D` is idempotent complete, we get equivalences\n`karoubi_universal\u2082 C D : C \u2964 D \u224c karoubi C \u2964 karoubi D`\nand `karoubi_universal C D : C \u2964 D \u224c karoubi C \u2964 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 \u2964 D` is determined\nby its value on objects coming from `C`. -/\ntheorem nat_trans_eq {F G : Karoubi C \u2964 D} (\u03c6 : F \u27f6 G) (P : Karoubi C) :\n    \u03c6.app P = F.map (decompIdI P) \u226b \u03c6.app P.pt \u226b G.map (decompIdP P) :=\n  by\n  rw [\u2190 \u03c6.naturality, \u2190 assoc, \u2190 F.map_comp]\n  conv =>\n    lhs\n    rw [\u2190 id_comp (\u03c6.app P), \u2190 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\u2081\n\n/-- The canonical extension of a functor `C \u2964 karoubi D` to a functor\n`karoubi C \u2964 karoubi D` -/\n@[simps]\ndef obj (F : C \u2964 Karoubi D) : Karoubi C \u2964 Karoubi D\n    where\n  obj P :=\n    \u27e8(F.obj P.pt).pt, (F.map P.p).f, by simpa only [F.map_comp, hom_ext] using F.congr_map P.idem\u27e9\n  map P Q f := \u27e8(F.map f.f).f, by simpa only [F.map_comp, hom_ext] using F.congr_map f.comm\u27e9\n#align category_theory.idempotents.functor_extension\u2081.obj CategoryTheory.Idempotents.FunctorExtension\u2081.obj\n\n/-- Extension of a natural transformation `\u03c6` between functors\n`C \u2964 karoubi D` to a natural transformation between the\nextension of these functors to `karoubi C \u2964 karoubi D` -/\n@[simps]\ndef map {F G : C \u2964 Karoubi D} (\u03c6 : F \u27f6 G) : obj F \u27f6 obj G\n    where\n  app P :=\n    { f := (F.map P.p).f \u226b (\u03c6.app P.pt).f\n      comm := by\n        have h := \u03c6.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, \u2190 h]\n        slice_rhs 1 3 => rw [h', h'] }\n  naturality' P Q f := by\n    ext\n    dsimp [obj]\n    have h := \u03c6.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''\u22a2\n    slice_rhs 2 3 => rw [\u2190 h]\n    slice_lhs 1 2 => rw [h']\n    slice_rhs 1 2 => rw [h'']\n#align category_theory.idempotents.functor_extension\u2081.map CategoryTheory.Idempotents.FunctorExtension\u2081.map\n\nend FunctorExtension\u2081\n\nvariable (C D E)\n\n/-- The canonical functor `(C \u2964 karoubi D) \u2964 (karoubi C \u2964 karoubi D)` -/\n@[simps]\ndef functorExtension\u2081 : (C \u2964 Karoubi D) \u2964 Karoubi C \u2964 Karoubi D\n    where\n  obj := FunctorExtension\u2081.obj\n  map F G := FunctorExtension\u2081.map\n  map_id' F := by\n    ext P\n    exact comp_p (F.map P.p)\n  map_comp' F G H \u03c6 \u03c6' := by\n    ext P\n    simp only [comp_f, functor_extension\u2081.map_app_f, nat_trans.comp_app, assoc]\n    have h := \u03c6.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 [\u2190 h]\n    slice_rhs 1 2 => rw [h']\n    simp only [assoc]\n#align category_theory.idempotents.functor_extension\u2081 CategoryTheory.Idempotents.functorExtension\u2081\n\ntheorem functorExtension\u2081_comp_whiskeringLeft_toKaroubi :\n    functorExtension\u2081 C D \u22d9 (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) = \ud835\udfed _ :=\n  by\n  refine' Functor.ext _ _\n  \u00b7 intro F\n    refine' Functor.ext _ _\n    \u00b7 intro X\n      ext\n      \u00b7 dsimp\n        rw [id_comp, comp_id, F.map_id, id_eq]\n      \u00b7 rfl\n    \u00b7 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\u2081.obj_obj_p,\n        to_karoubi_obj_p, comp_f]\n      dsimp\n      simp only [Functor.map_id, id_eq, p_comp]\n  \u00b7 intro F G \u03c6\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\u2081.obj_obj_p, to_karoubi_obj_p, F.map_id X]\n#align category_theory.idempotents.functor_extension\u2081_comp_whiskering_left_to_karoubi CategoryTheory.Idempotents.functorExtension\u2081_comp_whiskeringLeft_toKaroubi\n\n/-- The natural isomorphism expressing that functors `karoubi C \u2964 karoubi D` obtained\nusing `functor_extension\u2081` actually extends the original functors `C \u2964 karoubi D`. -/\n@[simps]\ndef functorExtension\u2081CompWhiskeringLeftToKaroubiIso :\n    functorExtension\u2081 C D \u22d9 (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) \u2245 \ud835\udfed _ :=\n  eqToIso (functorExtension\u2081_comp_whiskeringLeft_toKaroubi C D)\n#align category_theory.idempotents.functor_extension\u2081_comp_whiskering_left_to_karoubi_iso CategoryTheory.Idempotents.functorExtension\u2081CompWhiskeringLeftToKaroubiIso\n\n/-- The counit isomorphism of the equivalence `(C \u2964 karoubi D) \u224c (karoubi C \u2964 karoubi D)`. -/\n@[simps]\ndef KaroubiUniversal\u2081.counitIso :\n    (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) \u22d9 functorExtension\u2081 C D \u2245 \ud835\udfed _ :=\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 \u226b P.decomp_id_p \u226b \ud835\udfd9 _ 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 = \ud835\udfd9 _ \u226b P.decomp_id_i \u226b (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\u2081 G\u2082 \u03c6 => by\n    ext P\n    dsimp\n    simpa only [nat_trans_eq \u03c6 P, comp_f, functor_extension\u2081.map_app_f, functor.comp_map,\n      whisker_left_app, assoc, P.decomp_p, G\u2081.map_comp]\n#align category_theory.idempotents.karoubi_universal\u2081.counit_iso CategoryTheory.Idempotents.KaroubiUniversal\u2081.counitIso\n\n/-- The equivalence of categories `(C \u2964 karoubi D) \u224c (karoubi C \u2964 karoubi D)`. -/\n@[simps]\ndef karoubiUniversal\u2081 : C \u2964 Karoubi D \u224c Karoubi C \u2964 Karoubi D\n    where\n  Functor := functorExtension\u2081 C D\n  inverse := (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C)\n  unitIso := (functorExtension\u2081CompWhiskeringLeftToKaroubiIso C D).symm\n  counitIso := KaroubiUniversal\u2081.counitIso C D\n  functor_unitIso_comp' F := by\n    ext P\n    dsimp [functor_extension\u2081.map, karoubi_universal\u2081.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\u2081 CategoryTheory.Idempotents.karoubiUniversal\u2081\n\ntheorem functorExtension\u2081_comp (F : C \u2964 Karoubi D) (G : D \u2964 Karoubi E) :\n    (functorExtension\u2081 C E).obj (F \u22d9 (functorExtension\u2081 D E).obj G) =\n      (functorExtension\u2081 C D).obj F \u22d9 (functorExtension\u2081 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\u2081_comp CategoryTheory.Idempotents.functorExtension\u2081_comp\n\n/-- The canonical functor `(C \u2964 D) \u2964 (karoubi C \u2964 karoubi D)` -/\n@[simps]\ndef functorExtension\u2082 : (C \u2964 D) \u2964 Karoubi C \u2964 Karoubi D :=\n  (whiskeringRight C D (Karoubi D)).obj (toKaroubi D) \u22d9 functorExtension\u2081 C D\n#align category_theory.idempotents.functor_extension\u2082 CategoryTheory.Idempotents.functorExtension\u2082\n\ntheorem functorExtension\u2082_comp_whiskeringLeft_toKaroubi :\n    functorExtension\u2082 C D \u22d9 (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\u2082, functor.assoc, functor_extension\u2081_comp_whiskering_left_to_karoubi,\n    functor.comp_id]\n#align category_theory.idempotents.functor_extension\u2082_comp_whiskering_left_to_karoubi CategoryTheory.Idempotents.functorExtension\u2082_comp_whiskeringLeft_toKaroubi\n\n/-- The natural isomorphism expressing that functors `karoubi C \u2964 karoubi D` obtained\nusing `functor_extension\u2082` actually extends the original functors `C \u2964 D`. -/\n@[simps]\ndef functorExtension\u2082CompWhiskeringLeftToKaroubiIso :\n    functorExtension\u2082 C D \u22d9 (whiskeringLeft C (Karoubi C) (Karoubi D)).obj (toKaroubi C) \u2245\n      (whiskeringRight C D (Karoubi D)).obj (toKaroubi D) :=\n  eqToIso (functorExtension\u2082_comp_whiskeringLeft_toKaroubi C D)\n#align category_theory.idempotents.functor_extension\u2082_comp_whiskering_left_to_karoubi_iso CategoryTheory.Idempotents.functorExtension\u2082CompWhiskeringLeftToKaroubiIso\n\nsection IsIdempotentComplete\n\nvariable [IsIdempotentComplete D]\n\nnoncomputable instance : IsEquivalence (toKaroubi D) :=\n  toKaroubiIsEquivalence D\n\n/-- The equivalence of categories `(C \u2964 D) \u224c (karoubi C \u2964 karoubi D)` when `D`\nis idempotent complete. -/\n@[simps]\nnoncomputable def karoubiUniversal\u2082 : C \u2964 D \u224c Karoubi C \u2964 Karoubi D :=\n  (Equivalence.congrRight (toKaroubi D).asEquivalence).trans (karoubiUniversal\u2081 C D)\n#align category_theory.idempotents.karoubi_universal\u2082 CategoryTheory.Idempotents.karoubiUniversal\u2082\n\ntheorem karoubiUniversal\u2082_functor_eq : (karoubiUniversal\u2082 C D).Functor = functorExtension\u2082 C D :=\n  rfl\n#align category_theory.idempotents.karoubi_universal\u2082_functor_eq CategoryTheory.Idempotents.karoubiUniversal\u2082_functor_eq\n\nnoncomputable instance : IsEquivalence (functorExtension\u2082 C D) :=\n  by\n  rw [\u2190 karoubi_universal\u2082_functor_eq]\n  infer_instance\n\n/-- The extension of functors functor `(C \u2964 D) \u2964 (karoubi C \u2964 D)`\nwhen `D` is idempotent compltete. -/\n@[simps]\nnoncomputable def functorExtension : (C \u2964 D) \u2964 Karoubi C \u2964 D :=\n  functorExtension\u2082 C D \u22d9\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 \u2964 D) \u224c (karoubi C \u2964 D)` when `D` is idempotent complete. -/\n@[simps]\nnoncomputable def karoubiUniversal : C \u2964 D \u224c Karoubi C \u2964 D :=\n  (karoubiUniversal\u2082 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 [\u2190 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) \u22d9 (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 \u2964 D}\n    (\u03c4 : toKaroubi _ \u22d9 F \u27f6 toKaroubi _ \u22d9 G) (P : Karoubi C) :\n    (((whiskeringLeft _ _ _).obj (toKaroubi _)).preimage \u03c4).app P =\n      F.map P.decompIdI \u226b \u03c4.app P.pt \u226b 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 \u03c4) 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\u2082 morphism.from_irreductible equiv_morphism shur\u2081_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          (\u03c1 : group_representation G \u2102 (X \u2192 \u2102))\n          {Y : Type w} [fintype Y][decidable_eq Y]\n          (\u03b9 : Type v) [fintype \u03b9][decidable_eq \u03b9] (M : \u03b9 \u2192 Type w)\n          [\u03a0 i, fintype(M i)][\u03a0 i,decidable_eq (M i)]\n          (\u03c6 : \u03a0 i,group_representation G \u2102  (M i \u2192 \u2102 )) [\u03a0 i, Irreductible (\u03c6 i) ]\n          {\u03c0  : group_representation G \u2102 (Y \u2192 \u2102)} [Irreductible \u03c0  ]\n#check finset\ndef  is_decomposition := \u03c7 \u03c1 = \u2211 i, \u03c7 (\u03c6 i)  ---- baby decomposition ! \n#check   subtype (\u03bb i : \u03b9 , is_isomorphic \u03c1 (\u03c6 i))\nopen_locale classical\ninstance  : fintype { i : \u03b9 // is_isomorphic \u03c1 (\u03c6 i)  } := begin \n    exact set_fintype (\u03bb (x : \u03b9), nonempty (\u03c1 \u2243\u1d63 \u03c6 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          (\u03c1 : group_representation G \u2102 (X \u2192 \u2102))\n          {Y : Type w} [fintype Y][decidable_eq Y]\n          (\u03b9 : Type v) [fintype \u03b9][decidable_eq \u03b9] (M : \u03b9 \u2192 Type w)\n          [\u03a0 i, fintype(M i)][\u03a0 i,decidable_eq (M i)]\n          (\u03c6 : \u03a0 i,group_representation G \u2102  (M i \u2192 \u2102 )) [\u03a0 i, Irreductible (\u03c6 i) ]\n          {\u03c0  : group_representation G \u2102 (Y \u2192 \u2102)} [Irreductible \u03c0  ]\ntheorem scal (hyp : is_decomposition \u03c1 \u03b9 M \u03c6  ) (hyp' : 0 < fintype.card Y ) (hyp'' : fintype.card Y \u2260 0) : \n    scalar_product G \u2102 (\u03c7 (\u03c0 )) (\u03c7 (\u03c1 )) = (fintype.card { i : \u03b9  | is_isomorphic \u03c0   (\u03c6    i)  }) * \u2191(fintype.card G)  :=\nbegin \n    unfold is_decomposition at *, rw hyp,\n    rw bilin_form.map_sum_right, \n    let g := \u03bb i,  scalar_product_ite  \u03c0 (\u03c6 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 \u2192 Type w)\n          [\u03a0 i, fintype(Mt i)][\u03a0 i,decidable_eq (Mt i)]\n          (\u03c8  : \u03a0 i,group_representation G \u2102  (Mt i \u2192 \u2102 )) [\u03a0 i, Irreductible (\u03c8 i) ]\ntheorem scal_regular  (hyp : is_decomposition (Regular.Regular_representation G \u2102 ) t Mt \u03c8   )(hyp'' :0 < fintype.card Y ) (hyp' : fintype.card Y \u2260 0): \n\n    (\u03c7 \u03c0  1) * \u2191(fintype.card G) = (fintype.card { i : t | is_isomorphic \u03c0   (\u03c8   i)  }) * \u2191(fintype.card G) := \nbegin \n    erw \u2190 scal (Regular.Regular_representation G \u2102 ) t Mt \u03c8 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 {\u03b1 : Type _} [DecidableEq \u03b1] [CommGroup \u03b1] (s : Finset \u03b1) {t : Finset \u03b1}\n\n/- warning: finset.exists_subset_mul_div -> Finset.exists_subset_mul_div is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : CommGroup.{u1} \u03b1] (s : Finset.{u1} \u03b1) {t : Finset.{u1} \u03b1}, (Finset.Nonempty.{u1} \u03b1 t) -> (Exists.{succ u1} (Finset.{u1} \u03b1) (fun (u : Finset.{u1} \u03b1) => And (LE.le.{0} Nat Nat.hasLe (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} \u03b1 u) (Finset.card.{u1} \u03b1 t)) (Finset.card.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (instHMul.{u1} (Finset.{u1} \u03b1) (Finset.mul.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 (CommGroup.toGroup.{u1} \u03b1 _inst_2))))))) s t))) (HasSubset.Subset.{u1} (Finset.{u1} \u03b1) (Finset.hasSubset.{u1} \u03b1) s (HDiv.hDiv.{u1, u1, u1} (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (instHDiv.{u1} (Finset.{u1} \u03b1) (Finset.div.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 (CommGroup.toGroup.{u1} \u03b1 _inst_2))))) (HMul.hMul.{u1, u1, u1} (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (instHMul.{u1} (Finset.{u1} \u03b1) (Finset.mul.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 (CommGroup.toGroup.{u1} \u03b1 _inst_2))))))) u t) t))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : CommGroup.{u1} \u03b1] (s : Finset.{u1} \u03b1) {t : Finset.{u1} \u03b1}, (Finset.Nonempty.{u1} \u03b1 t) -> (Exists.{succ u1} (Finset.{u1} \u03b1) (fun (u : Finset.{u1} \u03b1) => And (LE.le.{0} Nat instLENat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u1} \u03b1 u) (Finset.card.{u1} \u03b1 t)) (Finset.card.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (instHMul.{u1} (Finset.{u1} \u03b1) (Finset.mul.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 (CommGroup.toGroup.{u1} \u03b1 _inst_2))))))) s t))) (HasSubset.Subset.{u1} (Finset.{u1} \u03b1) (Finset.instHasSubsetFinset.{u1} \u03b1) s (HDiv.hDiv.{u1, u1, u1} (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (instHDiv.{u1} (Finset.{u1} \u03b1) (Finset.div.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (DivInvMonoid.toDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 (CommGroup.toGroup.{u1} \u03b1 _inst_2))))) (HMul.hMul.{u1, u1, u1} (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (Finset.{u1} \u03b1) (instHMul.{u1} (Finset.{u1} \u03b1) (Finset.mul.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 (CommGroup.toGroup.{u1} \u03b1 _inst_2))))))) u t) t))))\nCase conversion may be inaccurate. Consider using '#align finset.exists_subset_mul_div Finset.exists_subset_mul_div\u2093'. -/\n/-- **Ruzsa's covering lemma**. -/\n@[to_additive \"**Ruzsa's covering lemma**\"]\ntheorem exists_subset_mul_div (ht : t.Nonempty) :\n    \u2203 u : Finset \u03b1, u.card * t.card \u2264 (s * t).card \u2227 s \u2286 u * t / t :=\n  by\n  haveI : \u2200 u, Decidable ((u : Set \u03b1).PairwiseDisjoint (\u00b7 \u2022 t)) := fun u => Classical.dec _\n  set C := s.powerset.filter fun u => (u : Set \u03b1).PairwiseDisjoint (\u00b7 \u2022 t)\n  obtain \u27e8u, hu, hCmax\u27e9 :=\n    C.exists_maximal (filter_nonempty_iff.2 \u27e8\u2205, empty_mem_powerset _, Set.pairwiseDisjoint_empty\u27e9)\n  rw [mem_filter, mem_powerset] at hu\n  refine'\n    \u27e8u,\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 => _\u27e9\n  rw [mul_div_assoc]\n  by_cases hau : a \u2208 u\n  \u00b7 exact subset_mul_left _ ht.one_mem_div hau\n  by_cases H : \u2200 b \u2208 u, Disjoint (a \u2022 t) (b \u2022 t)\n  \u00b7 refine' (hCmax _ _ <| ssubset_insert hau).elim\n    rw [mem_filter, mem_powerset, insert_subset, coe_insert]\n    exact \u27e8\u27e8ha, hu.1\u27e9, hu.2.insert fun b hb _ => H _ hb\u27e9\n  push_neg  at H\n  simp_rw [not_disjoint_iff, \u2190 inv_smul_mem_iff] at H\n  obtain \u27e8b, hb, c, hc\u2081, hc\u2082\u27e9 := H\n  exact mem_mul.2 \u27e8_, _, hb, mem_div.2 \u27e8_, _, hc\u2082, hc\u2081, by simp [div_eq_mul_inv a b]\u27e9, by simp\u27e9\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u03b1 \u03b2` is an extension of `local_equiv \u03b1 \u03b2`, 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 \u2229 s` or `e.target \u2229 t`, not `s \u2229 e.source` or `t \u2229 e.target`.\n-/\n\nopen function set filter topological_space (second_countable_topology)\nopen_locale topological_space\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\n[topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4]\n\n/-- local homeomorphisms, defined on open subsets of the space -/\n@[nolint has_inhabited_instance]\nstructure local_homeomorph (\u03b1 : Type*) (\u03b2 : Type*) [topological_space \u03b1] [topological_space \u03b2]\n  extends local_equiv \u03b1 \u03b2 :=\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 : \u03b1 \u2243\u209c \u03b2) :\n  local_homeomorph \u03b1 \u03b2 :=\n{ open_source        := is_open_univ,\n  open_target        := is_open_univ,\n  continuous_to_fun  := by { erw \u2190 continuous_iff_continuous_on_univ, exact e.continuous_to_fun },\n  continuous_inv_fun := by { erw \u2190 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 \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3)\n\ninstance : has_coe_to_fun (local_homeomorph \u03b1 \u03b2) := \u27e8_, \u03bb e, e.to_local_equiv.to_fun\u27e9\n\n/-- The inverse of a local homeomorphism -/\nprotected def symm : local_homeomorph \u03b2 \u03b1 :=\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 \u03b1 \u03b2) : \u03b1 \u2192 \u03b2 := e\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (e : local_homeomorph \u03b1 \u03b2) : \u03b2 \u2192 \u03b1 := e.symm\n\ninitialize_simps_projections local_homeomorph\n  (to_local_equiv_to_fun \u2192 apply, to_local_equiv_inv_fun \u2192 symm_apply,\n   to_local_equiv_source \u2192 source, to_local_equiv_target \u2192 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 \u03b1 \u03b2) (a b c d) :\n  (local_homeomorph.mk e a b c d : \u03b1 \u2192 \u03b2) = e := rfl\n\n@[simp, mfld_simps] lemma mk_coe_symm (e : local_equiv \u03b1 \u03b2) (a b c d) :\n  ((local_homeomorph.mk e a b c d).symm : \u03b2 \u2192 \u03b1) = 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 \u03b1 \u03b2) : e.to_fun = e := rfl\n\n@[simp, mfld_simps] lemma inv_fun_eq_coe (e : local_homeomorph \u03b1 \u03b2) : e.inv_fun = e.symm := rfl\n\n@[simp, mfld_simps] lemma coe_coe : (e.to_local_equiv : \u03b1 \u2192 \u03b2) = e := rfl\n\n@[simp, mfld_simps] lemma coe_coe_symm : (e.to_local_equiv.symm : \u03b2 \u2192 \u03b1) = e.symm := rfl\n\n@[simp, mfld_simps] lemma map_source {x : \u03b1} (h : x \u2208 e.source) : e x \u2208 e.target :=\ne.map_source' h\n\n@[simp, mfld_simps] lemma map_target {x : \u03b2} (h : x \u2208 e.target) : e.symm x \u2208 e.source :=\ne.map_target' h\n\n@[simp, mfld_simps] lemma left_inv {x : \u03b1} (h : x \u2208 e.source) : e.symm (e x) = x :=\ne.left_inv' h\n\n@[simp, mfld_simps] lemma right_inv {x : \u03b2} (h : x \u2208 e.target) : e (e.symm x) = x :=\ne.right_inv' h\n\nprotected lemma maps_to : maps_to e e.source e.target := \u03bb 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 := \u03bb x, e.left_inv\nprotected lemma right_inv_on : right_inv_on e.symm e e.target := \u03bb x, e.right_inv\nprotected lemma inv_on : inv_on e.symm e e.source e.target := \u27e8e.left_inv_on, e.right_inv_on\u27e9\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 \u03b1 \u03b2) (e' : local_equiv \u03b1 \u03b2) (h : e.to_local_equiv = e') :\n  local_homeomorph \u03b1 \u03b2 :=\n{ to_local_equiv := e',\n  open_source := h \u25b8 e.open_source,\n  open_target := h \u25b8 e.open_target,\n  continuous_to_fun := h \u25b8 e.continuous_to_fun,\n  continuous_inv_fun := h \u25b8 e.continuous_inv_fun }\n\nlemma replace_equiv_eq_self (e : local_homeomorph \u03b1 \u03b2) (e' : local_equiv \u03b1 \u03b2)\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 \u2286 e \u207b\u00b9' e.target := e.maps_to\n\nlemma eq_of_local_equiv_eq {e e' : local_homeomorph \u03b1 \u03b2}\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 \u03b1 \u03b2) {x} (hx : x \u2208 e.source) :\n  \u2200\u1da0 y in \ud835\udcdd 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 \u03b1 \u03b2) {x} (hx : x \u2208 e.target) :\n  \u2200\u1da0 y in \ud835\udcdd (e.symm x), e.symm (e y) = y :=\ne.eventually_left_inverse (e.map_target hx)\n\nlemma eventually_right_inverse (e : local_homeomorph \u03b1 \u03b2) {x} (hx : x \u2208 e.target) :\n  \u2200\u1da0 y in \ud835\udcdd 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 \u03b1 \u03b2) {x} (hx : x \u2208 e.source) :\n  \u2200\u1da0 y in \ud835\udcdd (e x), e (e.symm y) = y :=\ne.eventually_right_inverse (e.map_source hx)\n\nlemma eventually_ne_nhds_within (e : local_homeomorph \u03b1 \u03b2) {x} (hx : x \u2208 e.source) :\n  \u2200\u1da0 x' in \ud835\udcdd[{x}\u1d9c] x, e x' \u2260 e x :=\neventually_nhds_within_iff.2 $ (e.eventually_left_inverse hx).mono $\n  \u03bb x' hx', mt $ \u03bb h, by rw [mem_singleton_iff, \u2190 e.left_inv hx, \u2190 h, hx']\n\nlemma nhds_within_source_inter {x} (hx : x \u2208 e.source) (s : set \u03b1) :\n  \ud835\udcdd[e.source \u2229 s] x = \ud835\udcdd[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 \u2208 e.target) (s : set \u03b2) :\n  \ud835\udcdd[e.target \u2229 s] x = \ud835\udcdd[s] x :=\ne.symm.nhds_within_source_inter hx s\n\nlemma image_eq_target_inter_inv_preimage {s : set \u03b1} (h : s \u2286 e.source) :\n  e '' s = e.target \u2229 e.symm \u207b\u00b9' s :=\ne.to_local_equiv.image_eq_target_inter_inv_preimage h\n\nlemma image_source_inter_eq' (s : set \u03b1) :\n  e '' (e.source \u2229 s) = e.target \u2229 e.symm \u207b\u00b9' s :=\ne.to_local_equiv.image_source_inter_eq' s\n\nlemma image_source_inter_eq (s : set \u03b1) :\n  e '' (e.source \u2229 s) = e.target \u2229 e.symm \u207b\u00b9' (e.source \u2229 s) :=\ne.to_local_equiv.image_source_inter_eq s\n\nlemma symm_image_eq_source_inter_preimage {s : set \u03b2} (h : s \u2286 e.target) :\n  e.symm '' s = e.source \u2229 e \u207b\u00b9' s :=\ne.symm.image_eq_target_inter_inv_preimage h\n\nlemma symm_image_target_inter_eq (s : set \u03b2) :\n  e.symm '' (e.target \u2229 s) = e.source \u2229 e \u207b\u00b9' (e.target \u2229 s) :=\ne.symm.image_source_inter_eq _\n\nlemma source_inter_preimage_inv_preimage (s : set \u03b1) :\n  e.source \u2229 e \u207b\u00b9' (e.symm \u207b\u00b9' s) = e.source \u2229 s :=\ne.to_local_equiv.source_inter_preimage_inv_preimage s\n\nlemma target_inter_inv_preimage_preimage (s : set \u03b2) :\n  e.target \u2229 e.symm \u207b\u00b9' (e \u207b\u00b9' s) = e.target \u2229 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 \u03b1 \u03b2) (h : \u2200x, e x = e' x)\n  (hinv : \u2200x, 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 : \u03b2} (h : x \u2208 e.target) : continuous_at e.symm x :=\ne.symm.continuous_at h\n\nlemma tendsto_symm {x} (hx : x \u2208 e.source) :\n  tendsto e.symm (\ud835\udcdd (e x)) (\ud835\udcdd 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 \u2208 e.source) : map e (\ud835\udcdd x) = \ud835\udcdd (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 \u2208 e.source) :\n  map e.symm (\ud835\udcdd (e x)) = \ud835\udcdd 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 \u2208 e.source) {s : set \u03b1} (hs : s \u2208 \ud835\udcdd x) :\n  e '' s \u2208 \ud835\udcdd (e x) :=\ne.map_nhds_eq hx \u25b8 filter.image_mem_map hs\n\nlemma map_nhds_within_eq (e : local_homeomorph \u03b1 \u03b2) {x} (hx : x \u2208 e.source) (s : set \u03b1) :\n  map e (\ud835\udcdd[s] x) = \ud835\udcdd[e '' (e.source \u2229 s)] (e x) :=\ncalc map e (\ud835\udcdd[s] x) = map e (\ud835\udcdd[e.source \u2229 s] x) :\n  congr_arg (map e) (e.nhds_within_source_inter hx _).symm\n... = \ud835\udcdd[e '' (e.source \u2229 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 \u03b1 \u03b2) {x} (hx : x \u2208 e.source) (s : set \u03b2) :\n  map e (\ud835\udcdd[e \u207b\u00b9' s] x) = \ud835\udcdd[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 \u03b2} (hs : is_open s) : is_open (e.source \u2229 e \u207b\u00b9' 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 \u03b2` is an image of `s : set \u03b1` under a local homeomorphism `e` if any of the\nfollowing equivalent conditions hold:\n\n* `e '' (e.source \u2229 s) = e.target \u2229 t`;\n* `e.source \u2229 e \u207b\u00b9 t = e.source \u2229 s`;\n* `\u2200 x \u2208 e.source, e x \u2208 t \u2194 x \u2208 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 \u03b2` is an image of `s : set \u03b1` under a local homeomorphism `e` if any of the\nfollowing equivalent conditions hold:\n\n* `e '' (e.source \u2229 s) = e.target \u2229 t`;\n* `e.source \u2229 e \u207b\u00b9 t = e.source \u2229 s`;\n* `\u2200 x \u2208 e.source, e x \u2208 t \u2194 x \u2208 s` (this one is used in the definition).\n-/\ndef is_image (s : set \u03b1) (t : set \u03b2) : Prop := \u2200 \u2983x\u2984, x \u2208 e.source \u2192 (e x \u2208 t \u2194 x \u2208 s)\n\nnamespace is_image\n\nvariables {e} {s : set \u03b1} {t : set \u03b2} {x : \u03b1} {y : \u03b2}\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 \u2208 e.source) : e x \u2208 t \u2194 x \u2208 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 \u2208 e.target) : (e.symm y \u2208 s \u2194 y \u2208 t) :=\nh.symm hy\n\n@[simp] lemma symm_iff : e.symm.is_image t s \u2194 e.is_image s t := \u27e8\u03bb h, h.symm, \u03bb h, h.symm\u27e9\n\nprotected lemma maps_to (h : e.is_image s t) : maps_to e (e.source \u2229 s) (e.target \u2229 t) :=\nh.to_local_equiv.maps_to\n\nlemma symm_maps_to (h : e.is_image s t) : maps_to e.symm (e.target \u2229 t) (e.source \u2229 s) :=\nh.symm.maps_to\n\nlemma image_eq (h : e.is_image s t) : e '' (e.source \u2229 s) = e.target \u2229 t :=\nh.to_local_equiv.image_eq\n\nlemma symm_image_eq (h : e.is_image s t) : e.symm '' (e.target \u2229 t) = e.source \u2229 s :=\nh.symm.image_eq\n\nlemma iff_preimage_eq : e.is_image s t \u2194 e.source \u2229 e \u207b\u00b9' t = e.source \u2229 s :=\nlocal_equiv.is_image.iff_preimage_eq\n\nalias iff_preimage_eq \u2194 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 \u2194 e.target \u2229 e.symm \u207b\u00b9' s = e.target \u2229 t :=\nsymm_iff.symm.trans iff_preimage_eq\n\nalias iff_symm_preimage_eq \u2194 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 \u2194 e.target \u2229 e.symm \u207b\u00b9' (e.source \u2229 s) = e.target \u2229 t :=\nby rw [iff_symm_preimage_eq, \u2190 image_source_inter_eq, \u2190 image_source_inter_eq']\n\nalias iff_symm_preimage_eq' \u2194 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 \u2194 e.source \u2229 e \u207b\u00b9' (e.target \u2229 t) = e.source \u2229 s :=\nsymm_iff.symm.trans iff_symm_preimage_eq'\n\nalias iff_preimage_eq' \u2194 local_homeomorph.is_image.preimage_eq'\n  local_homeomorph.is_image.of_preimage_eq'\n\nlemma of_image_eq (h : e '' (e.source \u2229 s) = e.target \u2229 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 \u2229 t) = e.source \u2229 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\u1d9c t\u1d9c :=\n\u03bb 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 \u2229 s') (t \u2229 t') :=\n\u03bb 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 \u222a s') (t \u222a t') :=\n\u03bb 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 \u03b1 \u03b2} [\u2200 i, decidable (i \u2208 s)]\n  [\u2200 i, decidable (i \u2208 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 \u03b1 \u03b2} (h : e.is_image s t)\n  (h' : e'.is_image s t) (hs : e.source \u2229 s = e'.source \u2229 s) (Heq : eq_on e e' (e.source \u2229 s)) :\n  e.target \u2229 t = e'.target \u2229 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 \u03b1 \u03b2} (h : e.is_image s t)\n  (hs : e.source \u2229 s = e'.source \u2229 s) (Heq : eq_on e e' (e.source \u2229 s)) :\n  eq_on e.symm e'.symm (e.target \u2229 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 \u2208 e.source) :\n  map e (\ud835\udcdd[s] x) = \ud835\udcdd[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\u03bb x hx, by simp only [mem_closure_iff_nhds_within_ne_bot, \u2190 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 \u2229 s) \u2194 is_open (e.target \u2229 t) :=\n\u27e8\u03bb hs, h.symm_preimage_eq' \u25b8 e.symm.preimage_open_of_open hs,\n  \u03bb hs, h.preimage_eq' \u25b8 e.preimage_open_of_open hs\u27e9\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 \u2229 s)) :\n  local_homeomorph \u03b1 \u03b2 :=\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 \u03b1 \u03b2)\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 \u03b2) :\n  e.source \u2229 e \u207b\u00b9' (interior s) = e.source \u2229 interior (e \u207b\u00b9' s) :=\n(is_image.of_preimage_eq rfl).interior.preimage_eq\n\nlemma preimage_closure (s : set \u03b2) :\n  e.source \u2229 e \u207b\u00b9' (closure s) = e.source \u2229 closure (e \u207b\u00b9' s) :=\n(is_image.of_preimage_eq rfl).closure.preimage_eq\n\nlemma preimage_frontier (s : set \u03b2) :\n  e.source \u2229 e \u207b\u00b9' (frontier s) = e.source \u2229 frontier (e \u207b\u00b9' s) :=\n(is_image.of_preimage_eq rfl).frontier.preimage_eq\n\nlemma preimage_open_of_open_symm {s : set \u03b1} (hs : is_open s) :\n  is_open (e.target \u2229 e.symm \u207b\u00b9' 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 \u03b1} (hs : is_open s) (h : s \u2286 e.source) : is_open (e '' s) :=\nbegin\n  have : e '' s = e.target \u2229 e.symm \u207b\u00b9' 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 \u03b1} (hs : is_open s) : is_open (e '' (e.source \u2229 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 \u03b1 \u03b2) (hc : continuous_on e e.source)\n  (ho : is_open_map (e.source.restrict e)) (hs : is_open e.source) :\n  local_homeomorph \u03b1 \u03b2 :=\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 \u25b8\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 \u03b1 \u03b2) (hc : continuous_on e e.source)\n  (ho : is_open_map e) (hs : is_open e.source) :\n  local_homeomorph \u03b1 \u03b2 :=\nof_continuous_open_restrict e hc (ho.restrict hs) hs\n\n/-- Restricting a local homeomorphism `e` to `e.source \u2229 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 \u03b1) (hs : is_open s) :\n  local_homeomorph \u03b1 \u03b2 :=\n(@is_image.of_symm_preimage_eq \u03b1 \u03b2 _ _ e s (e.symm \u207b\u00b9' s) rfl).restr\n  (is_open_inter e.open_source hs)\n\n@[simp, mfld_simps] lemma restr_open_to_local_equiv (s : set \u03b1) (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 \u03b1) (hs : is_open s) :\n  (e.restr_open s hs).source = e.source \u2229 s := rfl\n\n/-- Restricting a local homeomorphism `e` to `e.source \u2229 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 \u03b1) : local_homeomorph \u03b1 \u03b2 :=\ne.restr_open (interior s) is_open_interior\n\n@[simp, mfld_simps] lemma restr_to_local_equiv (s : set \u03b1) :\n  (e.restr s).to_local_equiv = (e.to_local_equiv).restr (interior s) := rfl\n\nlemma restr_source' (s : set \u03b1) (hs : is_open s) : (e.restr s).source = e.source \u2229 s :=\nby rw [e.restr_source, hs.interior_eq]\n\nlemma restr_to_local_equiv' (s : set \u03b1) (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 \u03b1 \u03b2} {s : set \u03b1} (h : e.source \u2286 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 \u03b1 \u03b2} : e.restr univ = e :=\nrestr_eq_of_source_subset (subset_univ _)\n\nlemma restr_source_inter (s : set \u03b1) : e.restr (e.source \u2229 s) = e.restr s :=\nbegin\n  refine local_homeomorph.ext _ _ (\u03bbx, rfl) (\u03bbx, rfl) _,\n  simp [e.open_source.interior_eq, \u2190 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 (\u03b1 : Type*) [topological_space \u03b1] : local_homeomorph \u03b1 \u03b1 :=\n(homeomorph.refl \u03b1).to_local_homeomorph\n\n@[simp, mfld_simps] lemma refl_local_equiv :\n  (local_homeomorph.refl \u03b1).to_local_equiv = local_equiv.refl \u03b1 := rfl\n@[simp, mfld_simps] lemma refl_symm : (local_homeomorph.refl \u03b1).symm = local_homeomorph.refl \u03b1 :=\nrfl\n\nsection\nvariables {s : set \u03b1} (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 \u03b1) (hs : is_open s) : local_homeomorph \u03b1 \u03b1 :=\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 \u03b1 :=\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 \u03b1 \u03b3 :=\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 \u2190 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 \u03b1 \u03b3 :=\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' : \u03b1 \u2192 \u03b3) = e' \u2218 e := rfl\n@[simp, mfld_simps] lemma coe_trans_symm : ((e.trans e').symm : \u03b3 \u2192 \u03b1) = e.symm \u2218 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 \u2229 e \u207b\u00b9' e'.source :=\nlocal_equiv.trans_source e.to_local_equiv e'.to_local_equiv\n\nlemma trans_source' : (e.trans e').source = e.source \u2229 e \u207b\u00b9' (e.target \u2229 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 \u2229 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 \u2229 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 \u2229 e'.symm \u207b\u00b9' e.target := rfl\n\nlemma trans_target' : (e.trans e').target = e'.target \u2229 e'.symm \u207b\u00b9' (e'.source \u2229 e.target) :=\ntrans_source' e'.symm e.symm\n\nlemma trans_target'' : (e.trans e').target = e' '' (e'.source \u2229 e.target) :=\ntrans_source'' e'.symm e.symm\n\nlemma inv_image_trans_target : e'.symm '' (e.trans e').target = e'.source \u2229 e.target :=\nimage_trans_source e'.symm e.symm\n\nlemma trans_assoc (e'' : local_homeomorph \u03b3 \u03b4) :\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 \u03b2) = 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 \u03b1).trans e = e :=\neq_of_local_equiv_eq $ local_equiv.refl_trans e.to_local_equiv\n\nlemma trans_of_set {s : set \u03b2} (hs : is_open s) :\n  e.trans (of_set s hs) = e.restr (e \u207b\u00b9' s) :=\nlocal_homeomorph.ext _ _ (\u03bbx, rfl) (\u03bbx, rfl) $\n  by simp [local_equiv.trans_source, (e.preimage_interior _).symm, hs.interior_eq]\n\nlemma trans_of_set' {s : set \u03b2} (hs : is_open s) :\n  e.trans (of_set s hs) = e.restr (e.source \u2229 e \u207b\u00b9' s) :=\nby rw [trans_of_set, restr_source_inter]\n\nlemma of_set_trans {s : set \u03b1} (hs : is_open s) :\n  (of_set s hs).trans e = e.restr s :=\nlocal_homeomorph.ext _ _ (\u03bbx, rfl) (\u03bbx, rfl) $\n  by simp [local_equiv.trans_source, hs.interior_eq, inter_comm]\n\nlemma of_set_trans' {s : set \u03b1} (hs : is_open s) :\n  (of_set s hs).trans e = e.restr (e.source \u2229 s) :=\nby rw [of_set_trans, restr_source_inter]\n\n@[simp, mfld_simps] lemma of_set_trans_of_set\n  {s : set \u03b1} (hs : is_open s) {s' : set \u03b1} (hs' : is_open s') :\n  (of_set s hs).trans (of_set s' hs') = of_set (s \u2229 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 \u03b1) :\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 \u03b1 \u03b2) : Prop :=\ne.source = e'.source \u2227 (eq_on e e' e.source)\n\nlemma eq_on_source_iff (e e' : local_homeomorph \u03b1 \u03b2) :\neq_on_source e e' \u2194 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 \u03b1 \u03b2) :=\n{ r     := eq_on_source,\n  iseqv := \u27e8\n    \u03bbe, (@local_equiv.eq_on_source_setoid \u03b1 \u03b2).iseqv.1 e.to_local_equiv,\n    \u03bbe e' h, (@local_equiv.eq_on_source_setoid \u03b1 \u03b2).iseqv.2.1 ((eq_on_source_iff e e').1 h),\n    \u03bbe e' e'' h h', (@local_equiv.eq_on_source_setoid \u03b1 \u03b2).iseqv.2.2\n      ((eq_on_source_iff e e').1 h) ((eq_on_source_iff e' e'').1 h')\u27e9 }\n\nlemma eq_on_source_refl : e \u2248 e := setoid.refl _\n\n/-- If two local homeomorphisms are equivalent, so are their inverses -/\nlemma eq_on_source.symm' {e e' : local_homeomorph \u03b1 \u03b2} (h : e \u2248 e') : e.symm \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2} {f f' : local_homeomorph \u03b2 \u03b3}\n  (he : e \u2248 e') (hf : f \u2248 f') : e.trans f \u2248 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 \u03b1 \u03b2} (he : e \u2248 e') (s : set \u03b1) :\n  e.restr s \u2248 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 \u2248 local_homeomorph.of_set e.source e.open_source :=\nlocal_equiv.trans_self_symm _\n\nlemma trans_symm_self :\n  e.symm.trans e \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) :\n  local_homeomorph (\u03b1 \u00d7 \u03b3) (\u03b2 \u00d7 \u03b4) :=\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 \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) :\n  (e.prod e').symm = (e.symm.prod e'.symm) :=\nrfl\n\n@[simp, mfld_simps] lemma prod_trans\n  {\u03b7 : Type*} {\u03b5 : Type*} [topological_space \u03b7] [topological_space \u03b5]\n  (e : local_homeomorph \u03b1 \u03b2) (f : local_homeomorph \u03b2 \u03b3)\n  (e' : local_homeomorph \u03b4 \u03b7) (f' : local_homeomorph \u03b7 \u03b5) :\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 \u2229 s \u222a e'.source \\ s`, and similarly for target.  The\nfunction sends `e.source \u2229 s` to `e.target \u2229 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 \u03b1 \u03b2) (s : set \u03b1) (t : set \u03b2)\n  [\u2200 x, decidable (x \u2208 s)] [\u2200 y, decidable (y \u2208 t)] (H : e.is_image s t) (H' : e'.is_image s t)\n  (Hs : e.source \u2229 frontier s = e'.source \u2229 frontier s)\n  (Heq : eq_on e e' (e.source \u2229 frontier s)) :\n  local_homeomorph \u03b1 \u03b2 :=\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 \u03b1 \u03b2) {s : set \u03b1} {t : set \u03b2}\n  [\u2200 x, decidable (x \u2208 s)] [\u2200 y, decidable (y \u2208 t)] (H : e.is_image s t) (H' : e'.is_image s t)\n  (Hs : e.source \u2229 frontier s = e'.source \u2229 frontier s)\n  (Heq : eq_on e e' (e.source \u2229 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 \u03b1 \u03b2)\n  [\u2200 x, decidable (x \u2208 e.source)] [\u2200 y, decidable (y \u2208 e.target)]\n  (Hs : disjoint e.source e'.source) (Ht : disjoint e.target e'.target) :\n  local_homeomorph \u03b1 \u03b2 :=\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 {\u03b9 : Type*} [fintype \u03b9] {Xi Yi : \u03b9 \u2192 Type*} [\u03a0 i, topological_space (Xi i)]\n  [\u03a0 i, topological_space (Yi i)] (ei : \u03a0 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 (\u03a0 i, Xi i) (\u03a0 i, Yi i) :=\n{ to_local_equiv := local_equiv.pi (\u03bb i, (ei i).to_local_equiv),\n  open_source := is_open_set_pi finite_univ $ \u03bb i hi, (ei i).open_source,\n  open_target := is_open_set_pi finite_univ $ \u03bb i hi, (ei i).open_target,\n  continuous_to_fun := continuous_on_pi.2 $ \u03bb i, (ei i).continuous_on.comp\n    (continuous_apply _).continuous_on (\u03bb f hf, hf i trivial),\n  continuous_inv_fun := continuous_on_pi.2 $ \u03bb i, (ei i).continuous_on_symm.comp\n    (continuous_apply _).continuous_on (\u03bb 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 : \u03b2 \u2192 \u03b3} {s : set \u03b2} {x : \u03b2} (h : x \u2208 e.target) :\n  continuous_within_at f s x \u2194 continuous_within_at (f \u2218 e) (e \u207b\u00b9' s) (e.symm x) :=\nby simp_rw [continuous_within_at, \u2190 @tendsto_map'_iff _ _ _ _ e,\n  e.map_nhds_within_preimage_eq (e.map_target h), (\u2218), 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 : \u03b2 \u2192 \u03b3} {x : \u03b2} (h : x \u2208 e.target) :\n  continuous_at f x \u2194 continuous_at (f \u2218 e) (e.symm x) :=\nby rw [\u2190 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 : \u03b2 \u2192 \u03b3} {s : set \u03b2} (h : s \u2286 e.target) :\n  continuous_on f s \u2194 continuous_on (f \u2218 e) (e.source \u2229 e \u207b\u00b9' s) :=\nbegin\n  simp only [\u2190 e.symm_image_eq_source_inter_preimage h, continuous_on, ball_image_iff],\n  refine forall_congr (\u03bb x, forall_congr $ \u03bb 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 : \u03b3 \u2192 \u03b1} {s : set \u03b3} {x : \u03b3} (hx : f x \u2208 e.source) (h : f \u207b\u00b9' e.source \u2208 \ud835\udcdd[s] x) :\n  continuous_within_at f s x \u2194 continuous_within_at (e \u2218 f) s x :=\nbegin\n  refine \u27e8(e.continuous_at hx).tendsto.comp, \u03bb fe_cont, _\u27e9,\n  rw [\u2190 continuous_within_at_inter' h] at fe_cont \u22a2,\n  have : continuous_within_at (e.symm \u2218 (e \u2218 f)) (s \u2229 f \u207b\u00b9' 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 (\u03bby 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 : \u03b3 \u2192 \u03b1} {x : \u03b3} (h : f \u207b\u00b9' e.source \u2208 \ud835\udcdd x) :\n  continuous_at f x \u2194 continuous_at (e \u2218 f) x :=\nbegin\n  have hx : f x \u2208 e.source := (mem_of_nhds h : _),\n  have h' : f \u207b\u00b9' e.source \u2208 \ud835\udcdd[univ] x, by rwa nhds_within_univ,\n  rw [\u2190 continuous_within_at_univ, \u2190 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 : \u03b3 \u2192 \u03b1} {s : set \u03b3} (h : s \u2286 f \u207b\u00b9' e.source) :\n  continuous_on f s \u2194 continuous_on (e \u2218 f) s :=\nforall_congr $ \u03bb x, forall_congr $ \u03bb 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 \u2243\u209c e.target :=\n{ to_fun := e.maps_to.restrict _ _ _,\n  inv_fun := e.symm_maps_to.restrict _ _ _,\n  left_inv := \u03bb x, subtype.eq $ e.left_inv x.2,\n  right_inv := \u03bb 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 \u03b2]\n  (e : local_homeomorph \u03b1 \u03b2) :\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 \u03b1))\n  (h' : e.target = univ) : \u03b1 \u2243\u209c \u03b2 :=\n{ to_fun := e,\n  inv_fun := e.symm,\n  left_inv := \u03bbx, e.left_inv $ by { rw h, exact mem_univ _ },\n  right_inv := \u03bbx, 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 `\u03b1` defines an open embedding of `\u03b1` into `\u03b2`.  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 \u2190 h,\n    exact e.continuous_to_fun },\n  { apply set.injective_iff_inj_on_univ.mpr,\n    rw \u2190 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 : \u03b1 \u2243\u209c \u03b2) (e' : \u03b2 \u2243\u209c \u03b3)\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 : \u03b2 \u2192 \u03b1) = e.symm := rfl\n@[simp, mfld_simps] lemma refl_to_local_homeomorph :\n  (homeomorph.refl \u03b1).to_local_homeomorph = local_homeomorph.refl \u03b1 := 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 : \u03b1 \u2192 \u03b2) (h : open_embedding f)\n\n/-- An open embedding of `\u03b1` into `\u03b2`, with `\u03b1` nonempty, defines a local homeomorphism whose source\nis all of `\u03b1`.  The converse is also true; see `local_homeomorph.to_open_embedding`. -/\n@[simps apply source target (mfld_cfg)]\nnoncomputable def to_local_homeomorph [nonempty \u03b1] : local_homeomorph \u03b1 \u03b2 :=\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 : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hf : open_embedding f) {x : \u03b1} :\n  continuous_at (g \u2218 f) x \u2194 continuous_at g (f x) :=\nbegin\n  haveI : nonempty \u03b1 := \u27e8x\u27e9,\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 \u03b1) [nonempty s]\n\n/-- The inclusion of an open subset `s` of a space `\u03b1` into `\u03b1` is a local homeomorphism from the\nsubtype `s` to `\u03b1`. -/\nnoncomputable def local_homeomorph_subtype_coe : local_homeomorph s \u03b1 :=\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 \u2192 \u03b1) = 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 \u03b1 \u03b2)\nvariables (s : opens \u03b1) [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 \u03b2 := 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 \u03b2) : s \u2192 \u03b2)\n  = set.restrict (e : \u03b1 \u2192 \u03b2) s := rfl\n\n@[simp, mfld_simps] lemma subtype_restr_source : (e.subtype_restr s).source = coe \u207b\u00b9' 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 \u03b1 \u03b2) :\n  (f.subtype_restr s).symm.trans (f'.subtype_restr s)\n  \u2248 (f.symm.trans f').restr (f.target \u2229 (f.symm) \u207b\u00b9' s) :=\nbegin\n  simp only [subtype_restr_def, trans_symm_eq_symm_trans_symm],\n  have openness\u2081 : is_open (f.target \u2229 f.symm \u207b\u00b9' s) := f.preimage_open_of_open_symm s.2,\n  rw [\u2190 of_set_trans _ openness\u2081, \u2190 trans_assoc, \u2190 trans_assoc],\n  refine eq_on_source.trans' _ (eq_on_source_refl _),\n  -- f' has been eliminated !!!\n  have sets_identity : f.symm.source \u2229 (f.target \u2229 (f.symm) \u207b\u00b9' s) = f.symm.source \u2229 f.symm \u207b\u00b9' s,\n  { mfld_set_tac },\n  have openness\u2082 : is_open (s : set \u03b1) := s.2,\n  rw [of_set_trans', sets_identity, \u2190 trans_of_set' _ openness\u2082, 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\u2013Smith-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\u20132019:\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\u2014find\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 \u2227 b = 4}`\n    `{b \u2265 5} b := b + 1 {b \u2265 6}`\n    `{false} skip {b = 100}`\n    `{true} while i \u2260 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    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Skip\n    {P} skip {P}\n\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn\n    {Q[a/x]} x := a {Q}\n\n    {P} S {R}   {R} S' {Q}\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Seq\n    {P} S; S' {Q}\n\n    {P \u2227 b} S {Q}   {P \u2227 \u00acb} S' {Q}\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 If\n    {P} if b then S else S' {Q}\n\n    {I \u2227 b} S {I}\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 While\n    {I} while b do S {I \u2227 \u00acb}\n\n    P' \u2192 P   {P} S {Q}   Q \u2192 Q'\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 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    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn   \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn\n    {a = 2} b := a {b = 2}       {b = 2} c := b {c = 2}\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Seq\n    {a = 2} b := a; c := b {c = 2}\n\n\n                     \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn\n    x > 10 \u2192 x > 5   {x > 5} y := x {y > 5}   y > 5 \u2192 y > 0\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 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 \u2192 Q\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Skip'\n    {P} skip {Q}\n\n    P \u2192 Q[a/x]\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 Asn'\n    {P} x := a {Q}\n\n    {P \u2227 b} S {P}   P \u2227 \u00acb \u2192 Q\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 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 \u2192 Prop`) to represent pre- and\npostconditions, following the shallow embedding style. -/\n\ndef partial_hoare (P : state \u2192 Prop) (S : stmt)\n  (Q : state \u2192 Prop) : Prop :=\n\u2200s t, P s \u2192 (S, s) \u27f9 t \u2192 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 \u2192 Prop) {x} {a : state \u2192 \u2115} :\n  {* \u03bbs, P (s{x \u21a6 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 \u2192 Prop} {S T}\n    (hS : {* \u03bbs, P s \u2227 b s *} S {* Q *})\n    (hT : {* \u03bbs, P s \u2227 \u00ac 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 \u2192 Prop) {b : state \u2192 Prop} {S}\n    (h : {* \u03bbs, P s \u2227 b s *} S {* P *}) :\n  {* P *} stmt.while b S {* \u03bbs, P s \u2227 \u00ac 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 \u2192 Prop} {S}\n    (h : {* P *} S {* Q *}) (hp : \u2200s, P' s \u2192 P s)\n    (hq : \u2200s, Q s \u2192 Q' s) :\n  {* P' *} S {* Q' *} :=\nfix s t,\nassume hs : P' s,\nassume hst : (S, s) \u27f9 t,\nshow Q' t, from\n  hq _ (h s t (hp s hs) hst)\n\nlemma consequence_left (P' : state \u2192 Prop) {P Q S}\n    (h : {* P *} S {* Q *}) (hp : \u2200s, P' s \u2192 P s) :\n  {* P' *} S {* Q *} :=\nconsequence h hp (by cc)\n\nlemma consequence_right (Q) {Q' : state \u2192 Prop} {P S}\n    (h : {* P *} S {* Q *}) (hq : \u2200s, Q s \u2192 Q' s) :\n  {* P *} S {* Q' *} :=\nconsequence h (by cc) hq\n\nlemma skip_intro' {P Q : state \u2192 Prop} (h : \u2200s, P s \u2192 Q s) :\n  {* P *} stmt.skip {* Q *} :=\nconsequence skip_intro h (by cc)\n\nlemma assign_intro' {P Q : state \u2192 Prop} {x} {a : state \u2192 \u2115}\n    (h : \u2200s, P s \u2192 Q (s{x \u21a6 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 \u2192 Prop} {S}\n    (I : state \u2192 Prop)\n    (hS : {* \u03bbs, I s \u2227 b s *} S {* I *})\n    (hP : \u2200s, P s \u2192 I s)\n    (hQ : \u2200s, \u00ac b s \u2192 I s \u2192 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  {* \u03bbs, \u2203n\u2080, P (s{x \u21a6 n\u2080}) \u2227 s x = a (s{x \u21a6 n\u2080}) *} :=\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 \u2192 Prop) {x}\n    {a : state \u2192 \u2115} :\n  {* \u03bbs, \u2203n', Q (s{x \u21a6 n'}) \u2227 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\" (\u03bbs, s \"a\") ;;\nstmt.assign \"a\" (\u03bbs, s \"b\") ;;\nstmt.assign \"b\" (\u03bbs, s \"t\")\n\nlemma SWAP_correct (a\u2080 b\u2080 : \u2115) :\n  {* \u03bbs, s \"a\" = a\u2080 \u2227 s \"b\" = b\u2080 *}\n  SWAP\n  {* \u03bbs, s \"a\" = b\u2080 \u2227 s \"b\" = a\u2080 *} :=\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\u2082 (a\u2080 b\u2080 : \u2115) :\n  {* \u03bbs, s \"a\" = a\u2080 \u2227 s \"b\" = b\u2080 *}\n  SWAP\n  {* \u03bbs, s \"a\" = b\u2080 \u2227 s \"b\" = a\u2080 *} :=\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 (\u03bbs, s \"n\" \u2260 0)\n  (stmt.assign \"n\" (\u03bbs, s \"n\" - 1) ;;\n   stmt.assign \"m\" (\u03bbs, s \"m\" + 1))\n\nlemma ADD_correct (n\u2080 m\u2080 : \u2115) :\n  {* \u03bbs, s \"n\" = n\u2080 \u2227 s \"m\" = m\u2080 *}\n  ADD\n  {* \u03bbs, s \"n\" = 0 \u2227 s \"m\" = n\u2080 + m\u2080 *} :=\npartial_hoare.while_intro' (\u03bbs, s \"n\" + s \"m\" = n\u2080 + m\u2080)\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 \u2190hnm,\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\u2080 + m\u2080`.\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 \u2192 Prop) (S : stmt) : stmt :=\nstmt.while b S\n\nnamespace partial_hoare\n\nlemma while_inv_intro {b I Q : state \u2192 Prop} {S}\n    (hS : {* \u03bbs, I s \u2227 b s *} S {* I *})\n    (hQ : \u2200s, \u00ac b s \u2192 I s \u2192 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 \u2192 Prop} {S}\n    (hS : {* \u03bbs, I s \u2227 b s *} S {* I *})\n    (hP : \u2200s, P s \u2192 I s) (hQ : \u2200s, \u00ac b s \u2192 I s \u2192 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 \u2190 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\u2082 (n\u2080 m\u2080 : \u2115) :\n  {* \u03bbs, s \"n\" = n\u2080 \u2227 s \"m\" = m\u2080 *}\n  ADD\n  {* \u03bbs, s \"n\" = 0 \u2227 s \"m\" = n\u2080 + m\u2080 *} :=\nshow {* \u03bbs, s \"n\" = n\u2080 \u2227 s \"m\" = m\u2080 *}\n     stmt.while_inv (\u03bbs, s \"n\" + s \"m\" = n\u2080 + m\u2080)\n       (\u03bbs, s \"n\" \u2260 0)\n       (stmt.assign \"n\" (\u03bbs, s \"n\" - 1) ;;\n        stmt.assign \"m\" (\u03bbs, s \"m\" + 1))\n     {* \u03bbs, s \"n\" = 0 \u2227 s \"m\" = n\u2080 + m\u2080 *}, from\n  begin\n    vcg; simp { contextual := tt },\n    intros s hnm hnz,\n    rw \u2190hnm,\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 \u2264 100] while i \u2260 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 \u2227 b \u2227 V = v\u2080] S [I \u2227 V < v\u2080]\n    \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014 While-Var\n    [I] while b do S [I \u2227 \u00acb]\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 := \u03bb \u03b1 S, \u2200 x : \u03b1, S (\u03bb _ : punit, x),\n  top_mem' := \u03bb \u03b1 x, trivial,\n  pullback_stable' := \u03bb \u03b1 \u03b2 S f hs x, hs (f x),\n  transitive' := \u03bb \u03b1 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 (\u03b1 : Type u) : sieve \u03b1 :=\n{ arrows := \u03bb \u03b2 f, \u2203 x, \u2200 y, f y = x,\n  downward_closed' := \u03bb \u03b2 \u03b3 f \u27e8x, hx\u27e9 g, \u27e8x, \u03bb y, hx $ g y\u27e9 }\n\nlemma discrete_sieve_mem (\u03b1 : Type u) : discrete_sieve \u03b1 \u2208 types_grothendieck_topology \u03b1 :=\n\u03bb x, \u27e8x, \u03bb y, rfl\u27e9\n\n/-- The discrete presieve on a type, which only includes arrows whose domain is a singleton. -/\ndef discrete_presieve (\u03b1 : Type u) : presieve \u03b1 :=\n\u03bb \u03b2 f, \u2203 x : \u03b2, \u2200 y : \u03b2, y = x\n\nlemma generate_discrete_presieve_mem (\u03b1 : Type u) :\n  sieve.generate (discrete_presieve \u03b1) \u2208 types_grothendieck_topology \u03b1 :=\n\u03bb x, \u27e8punit, id, \u03bb _, x, \u27e8punit.star, \u03bb _, subsingleton.elim _ _\u27e9, rfl\u27e9\n\nopen presieve\n\ntheorem is_sheaf_yoneda' {\u03b1 : Type u} : is_sheaf types_grothendieck_topology (yoneda.obj \u03b1) :=\n\u03bb \u03b2 S hs x hx, \u27e8\u03bb y, x _ (hs y) punit.star,\n\u03bb \u03b3 f h, funext $ \u03bb z,\n  have _ := congr_fun (hx (\ud835\udfd9 _) (\u03bb _, z) (hs $ f z) h rfl) punit.star,\n  by { convert this, exact rfl },\n\u03bb f hf, funext $ \u03bb y, by convert congr_fun (hf _ (hs y)) punit.star\u27e9\n\n/-- The yoneda functor that sends a type to a sheaf over the category of types -/\n@[simps] def yoneda' : Type u \u2964 SheafOfTypes types_grothendieck_topology :=\n{ obj := \u03bb \u03b1, \u27e8yoneda.obj \u03b1, is_sheaf_yoneda'\u27e9,\n  map := \u03bb \u03b1 \u03b2 f, \u27e8yoneda.map f\u27e9 }\n\n@[simp] lemma yoneda'_comp : yoneda'.{u} \u22d9 SheafOfTypes_to_presheaf _ = yoneda := rfl\n\nopen opposite\n\n/-- Given a presheaf `P` on the category of types, construct\na map `P(\u03b1) \u2192 (\u03b1 \u2192 P(*))` for all type `\u03b1`. -/\ndef eval (P : (Type u)\u1d52\u1d56 \u2964 Type u) (\u03b1 : Type u) (s : P.obj (op \u03b1)) (x : \u03b1) : P.obj (op punit) :=\nP.map (\u21be\u03bb _, x).op s\n\n/-- Given a sheaf `S` on the category of types, construct a map\n`(\u03b1 \u2192 S(*)) \u2192 S(\u03b1)` that is inverse to `eval`. -/\nnoncomputable def types_glue (S : (Type u)\u1d52\u1d56 \u2964 Type u)\n  (hs : is_sheaf types_grothendieck_topology S)\n  (\u03b1 : Type u) (f : \u03b1 \u2192 S.obj (op punit)) : S.obj (op \u03b1) :=\n(hs.is_sheaf_for _ _ (generate_discrete_presieve_mem \u03b1)).amalgamate\n  (\u03bb \u03b2 g hg, S.map (\u21be\u03bb x, punit.star).op $ f $ g $ classical.some hg)\n  (\u03bb \u03b2 \u03b3 \u03b4 g\u2081 g\u2082 f\u2081 f\u2082 hf\u2081 hf\u2082 h,\n    (hs.is_sheaf_for _ _ (generate_discrete_presieve_mem \u03b4)).is_separated_for.ext $\n    \u03bb \u03b5 g \u27e8x, hx\u27e9, have f\u2081 (classical.some hf\u2081) = f\u2082 (classical.some hf\u2082),\n      from classical.some_spec hf\u2081 (g\u2081 $ g x) \u25b8 classical.some_spec hf\u2082 (g\u2082 $ g x) \u25b8 congr_fun h _,\n      by { simp_rw [\u2190 functor_to_types.map_comp_apply, this, \u2190 op_comp], refl })\n\nlemma eval_types_glue {S hs \u03b1} (f) : eval.{u} S \u03b1 (types_glue S hs \u03b1 f) = f :=\nfunext $ \u03bb x, (is_sheaf_for.valid_glue _ _ _ $\n  by exact \u27e8punit.star, \u03bb _, subsingleton.elim _ _\u27e9).trans $\nby { convert functor_to_types.map_id_apply _ _, rw \u2190 op_id, congr }\n\nlemma types_glue_eval {S hs \u03b1} (s) : types_glue.{u} S hs \u03b1 (eval S \u03b1 s) = s :=\n(hs.is_sheaf_for _ _ (generate_discrete_presieve_mem \u03b1)).is_separated_for.ext $ \u03bb \u03b2 f hf,\n(is_sheaf_for.valid_glue _ _ _ hf).trans $ (functor_to_types.map_comp_apply _ _ _ _).symm.trans $\nby { rw \u2190 op_comp, congr' 2, exact funext (\u03bb x, congr_arg f (classical.some_spec hf x).symm) }\n\n/-- Given a sheaf `S`, construct an equivalence `S(\u03b1) \u2243 (\u03b1 \u2192 S(*))`. -/\n@[simps] noncomputable def eval_equiv (S : (Type u)\u1d52\u1d56 \u2964 Type u)\n  (hs : is_sheaf types_grothendieck_topology S)\n  (\u03b1 : Type u) : S.obj (op \u03b1) \u2243 (\u03b1 \u2192 S.obj (op punit)) :=\n{ to_fun := eval S \u03b1,\n  inv_fun := types_glue S hs \u03b1,\n  left_inv := types_glue_eval,\n  right_inv := eval_types_glue }\n\nlemma eval_map (S : (Type u)\u1d52\u1d56 \u2964 Type u) (\u03b1 \u03b2) (f : \u03b2 \u27f6 \u03b1) (s x) :\n  eval S \u03b2 (S.map f.op s) x = eval S \u03b1 s (f x) :=\nby { simp_rw [eval, \u2190 functor_to_types.map_comp_apply, \u2190 op_comp], refl }\n\n/-- Given a sheaf `S`, construct an isomorphism `S \u2245 [-, S(*)]`. -/\n@[simps] noncomputable def equiv_yoneda (S : (Type u)\u1d52\u1d56 \u2964 Type u)\n  (hs : is_sheaf types_grothendieck_topology S) :\n  S \u2245 yoneda.obj (S.obj (op punit)) :=\nnat_iso.of_components (\u03bb \u03b1, equiv.to_iso $ eval_equiv S hs $ unop \u03b1) $ \u03bb \u03b1 \u03b2 f,\nfunext $ \u03bb s, funext $ \u03bb x, eval_map S (unop \u03b1) (unop \u03b2) f.unop _ _\n\n/-- Given a sheaf `S`, construct an isomorphism `S \u2245 [-, S(*)]`. -/\n@[simps] noncomputable def equiv_yoneda'\n  (S : SheafOfTypes types_grothendieck_topology) :\n  S \u2245 yoneda'.obj (S.1.obj (op punit)) :=\n{ hom := \u27e8(equiv_yoneda S.1 S.2).hom\u27e9,\n  inv := \u27e8(equiv_yoneda S.1 S.2).inv\u27e9,\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 \u224c SheafOfTypes types_grothendieck_topology :=\nequivalence.mk\n  yoneda'\n  (SheafOfTypes_to_presheaf _ \u22d9 (evaluation _ _).obj (op punit))\n  (nat_iso.of_components\n    (\u03bb \u03b1, /- \u03b1 \u2245 punit \u27f6 \u03b1 -/\n      { hom := \u03bb x _, x,\n        inv := \u03bb f, f punit.star,\n        hom_inv_id' := funext $ \u03bb x, rfl,\n        inv_hom_id' := funext $ \u03bb f, funext $ \u03bb y, punit.cases_on y rfl })\n    (\u03bb \u03b1 \u03b2 f, rfl))\n  (iso.symm $ nat_iso.of_components\n    (\u03bb S, equiv_yoneda' S)\n    (\u03bb S\u2081 S\u2082 f, SheafOfTypes.hom.ext _ _ $\n      nat_trans.ext _ _ $ funext $ \u03bb \u03b1, funext $ \u03bb s, funext $ \u03bb x,\n      eval_app S\u2081 S\u2082 f (unop \u03b1) s x))\n\nlemma subcanonical_types_grothendieck_topology :\n  sheaf.subcanonical types_grothendieck_topology.{u} :=\nsheaf.subcanonical.of_yoneda_is_sheaf _ (\u03bb 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 \u27e8yoneda.obj (ulift bool), \u27e8_, rfl\u27e9,\ngrothendieck_topology.ext $ funext $ \u03bb \u03b1, set.ext $ \u03bb S,\n\u27e8\u03bb hs x, classical.by_contradiction $ \u03bb hsx,\n  have (\u03bb _, ulift.up tt : (yoneda.obj (ulift bool)).obj (op punit)) = \u03bb _, ulift.up ff :=\n    (hs punit (\u03bb _, x)).is_separated_for.ext $ \u03bb \u03b2 f hf, funext $ \u03bb y, hsx.elim $ S.2 hf $ \u03bb _, y,\n  bool.no_confusion $ ulift.up.inj $ (congr_fun this punit.star : _),\n\u03bb hs \u03b2 f, is_sheaf_yoneda' _ $ \u03bb y, hs _\u27e9\u27e9\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes H\u00f6lzl\n\nLinear structures on function with finit support `\u03b1 \u2192\u2080 \u03b2` 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] (\u03b1) [fintype \u03b1] : fintype (matrix m n \u03b1) :=\nby unfold matrix; apply_instance\n\nsection ring\nvariables {\u03b1 : Type v} [comm_ring \u03b1]\n\ndef eval : (matrix m n \u03b1) \u2192\u2097[\u03b1] ((n \u2192 \u03b1) \u2192\u2097[\u03b1] (m \u2192 \u03b1)) :=\nbegin\n  refine linear_map.mk\u2082 \u03b1 mul_vec _ _ _ _,\n  { assume M N v, funext x,\n    change finset.univ.sum (\u03bby: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 (\u03bby: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 (\u03bby: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 (\u03bby:n, M x y * (c * v y)) = _,\n    rw [show (\u03bby:n, M x y * (c * v y)) = (\u03bby:n, c * (M x y * v y)), { funext n, ac_refl },\n      \u2190 finset.mul_sum],\n    refl }\nend\n\ndef to_lin : matrix m n \u03b1 \u2192 (n \u2192 \u03b1) \u2192\u2097[\u03b1] (m \u2192 \u03b1) := eval.to_fun\n\nlemma to_lin_add (M N : matrix m n \u03b1) : (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 \u03b1).to_lin = 0 :=\nmatrix.eval.map_zero\n\ninstance to_lin.is_linear_map :\n  @is_linear_map \u03b1 (matrix m n \u03b1) ((n \u2192 \u03b1) \u2192\u2097[\u03b1] (m \u2192 \u03b1)) _ _ _ _ _ to_lin :=\nmatrix.eval.is_linear\n\ninstance to_lin.is_add_monoid_hom :\n  @is_add_monoid_hom (matrix m n \u03b1) ((n \u2192 \u03b1) \u2192\u2097[\u03b1] (m \u2192 \u03b1)) _ _ to_lin :=\n{ map_zero := to_lin_zero, map_add := to_lin_add }\n\n@[simp] lemma to_lin_apply (M : matrix m n \u03b1) (v : n \u2192 \u03b1) :\n  (M.to_lin : (n \u2192 \u03b1) \u2192 (m \u2192 \u03b1)) v = mul_vec M v := rfl\n\nlemma mul_to_lin [decidable_eq l] (M : matrix m n \u03b1) (N : matrix n l \u03b1) :\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 \u2192 \u03b1) :\n  (proj i).comp (to_lin (diagonal w)) = (w i) \u2022 proj i :=\nby ext j; simp [mul_vec_diagonal]\n\nlemma diagonal_comp_std_basis [decidable_eq n] (w : n \u2192 \u03b1) (i : n) :\n  (diagonal w).to_lin.comp (std_basis \u03b1 (\u03bb_:n, \u03b1) i) = (w i) \u2022 std_basis \u03b1 (\u03bb_:n, \u03b1) 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 \u03b1 (\u03bb_:n, \u03b1) _ _ (ne.symm h), _root_.mul_zero, _root_.mul_zero] }\nend\nend\n\nend ring\n\nsection vector_space\nvariables {\u03b1 : Type u} [discrete_field \u03b1] -- maybe try to relax the universe constraint\n\nopen linear_map\n\nlemma rank_vec_mul_vec [decidable_eq n] (w : m \u2192 \u03b1) (v : n \u2192 \u03b1) :\n  rank (vec_mul_vec w v).to_lin \u2264 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', \u2190 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 \u2192 \u03b1) :\n  (diagonal w).to_lin = linear_map.pi (\u03bbi, w i \u2022 linear_map.proj i) :=\nby ext v j; simp [mul_vec_diagonal]\n\nlemma ker_diagonal_to_lin [decidable_eq m] (w : m \u2192 \u03b1) :\n  ker (diagonal w).to_lin = (\u2a06i\u2208{i | w i = 0 }, range (std_basis \u03b1 (\u03bbi, \u03b1) i)) :=\nbegin\n  rw [\u2190 comap_bot, \u2190 infi_ker_proj],\n  simp only [comap_infi, (ker_comp _ _).symm, proj_diagonal, ker_smul'],\n  have : univ \u2286 {i : m | w i = 0} \u222a -{i : m | w i = 0}, { rw set.union_compl_self },\n  exact (supr_range_std_basis_eq_infi_ker_proj \u03b1 (\u03bbi:m, \u03b1)\n    (disjoint_compl {i | w i = 0}) this (finite.of_fintype _)).symm\nend\n\nlemma range_diagonal [decidable_eq m] (w : m \u2192 \u03b1) :\n  (diagonal w).to_lin.range = (\u2a06 i \u2208 {i | w i \u2260 0}, (std_basis \u03b1 (\u03bbi, \u03b1) i).range) :=\nbegin\n  dsimp only [mem_set_of_eq],\n  rw [\u2190 map_top, \u2190 supr_range_std_basis, map_supr],\n  congr, funext i,\n  rw [\u2190 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 \u03b1] (w : m \u2192 \u03b1) :\n  rank (diagonal w).to_lin = fintype.card { i // w i \u2260 0 } :=\nbegin\n  have hu : univ \u2286 - {i : m | w i = 0} \u222a {i : m | w i = 0}, { rw set.compl_union_self },\n  have hd : disjoint {i : m | w i \u2260 0} {i : m | w i = 0} := (disjoint_compl {i | w i = 0}).symm,\n  have h\u2081 := supr_range_std_basis_eq_infi_ker_proj \u03b1 (\u03bbi:m, \u03b1) hd hu (finite.of_fintype _),\n  have h\u2082 := infi_ker_proj_equiv \u03b1 (\u03bbi:m, \u03b1) hd hu,\n  rw [rank, range_diagonal, h\u2081, (linear_equiv.dim_eq.{u u} h\u2082)],\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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u03b1 \u03b2 \ud835\udd5c E : Type*}\n\nsection salem_spencer\n\nopen set\n\nsection monoid\nvariables [monoid \u03b1] [monoid \u03b2] (s t : set \u03b1)\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 := \u2200 \u2983a b c\u2984, a \u2208 s \u2192 b \u2208 s \u2192 c \u2208 s \u2192 a * b = c * c \u2192 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 {\u03b1 : Type*} [decidable_eq \u03b1] [monoid \u03b1] {s : finset \u03b1} :\n  decidable (mul_salem_spencer (s : set \u03b1)) :=\ndecidable_of_iff (\u2200 a \u2208 s, \u2200 b \u2208 s, \u2200 c \u2208 s, a * b = c * c \u2192 a = b)\n  \u27e8\u03bb h a b c ha hb hc, h a ha b hb c hc, \u03bb h a ha b hb c hc, h ha hb hc\u27e9\n\nvariables {s t}\n\n@[to_additive]\nlemma mul_salem_spencer.mono (h : t \u2286 s) (hs : mul_salem_spencer s) : mul_salem_spencer t :=\n\u03bb 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 (\u2205 : set \u03b1) := \u03bb a _ _ ha, ha.elim\n\n@[to_additive]\nlemma set.subsingleton.mul_salem_spencer (hs : s.subsingleton) : mul_salem_spencer s :=\n\u03bb a b _ ha hb _ _, hs ha hb\n\n@[simp, to_additive]\nlemma mul_salem_spencer_singleton (a : \u03b1) : mul_salem_spencer ({a} : set \u03b1) :=\nsubsingleton_singleton.mul_salem_spencer\n\n@[to_additive add_salem_spencer.prod]\nlemma mul_salem_spencer.prod {t : set \u03b2} (hs : mul_salem_spencer s) (ht : mul_salem_spencer t) :\n  mul_salem_spencer (s \u00d7\u02e2 t) :=\n\u03bb 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 {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u03a0 i, monoid (\u03b1 i)] {s : \u03a0 i, set (\u03b1 i)}\n  (hs : \u2200 i, mul_salem_spencer (s i)) :\n  mul_salem_spencer ((univ : set \u03b9).pi s) :=\n\u03bb a b c ha hb hc h, funext $ \u03bb 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 \u03b1] [comm_monoid \u03b2] {s : set \u03b1} {a : \u03b1}\n\n@[to_additive]\nlemma mul_salem_spencer.of_image [fun_like F \u03b1 (\u03bb _, \u03b2)] [freiman_hom_class F s \u03b2 2] (f : F)\n  (hf : s.inj_on f) (h : mul_salem_spencer (f '' s)) :\n  mul_salem_spencer s :=\n\u03bb 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 \u03b1 \u03b2] (f : F) (hf : (s * s).inj_on f)\n  (h : mul_salem_spencer s) :\n  mul_salem_spencer (f '' s) :=\nbegin\n  rintro _ _ _ \u27e8a, ha, rfl\u27e9 \u27e8b, hb, rfl\u27e9 \u27e8c, hc, rfl\u27e9 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 \u03b1] {s : set \u03b1} {a : \u03b1}\n\n@[to_additive]\nlemma mul_salem_spencer_insert :\n  mul_salem_spencer (insert a s) \u2194 mul_salem_spencer s \u2227\n    (\u2200 \u2983b c\u2984, b \u2208 s \u2192 c \u2208 s \u2192 a * b = c * c \u2192 a = b) \u2227\n    \u2200 \u2983b c\u2984, b \u2208 s \u2192 c \u2208 s \u2192 b * c = a * a \u2192 b = c :=\nbegin\n  refine \u27e8\u03bb hs, \u27e8hs.mono (subset_insert _ _),\n    \u03bb b c hb hc, hs (or.inl rfl) (or.inr hb) (or.inr hc),\n    \u03bb b c hb hc, hs (or.inr hb) (or.inr hc) (or.inl rfl)\u27e9, _\u27e9,\n  rintro \u27e8hs, ha, ha'\u27e9 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 : \u03b1) : mul_salem_spencer ({a, b} : set \u03b1) :=\nbegin\n  rw mul_salem_spencer_insert,\n  refine \u27e8mul_salem_spencer_singleton _, _, _\u27e9,\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 _ _ _ \u27e8b, hb, rfl\u27e9 \u27e8c, hc, rfl\u27e9 \u27e8d, hd, rfl\u27e9 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 _ _ _ \u27e8b, hb, rfl\u27e9 \u27e8c, hc, rfl\u27e9 \u27e8d, hd, rfl\u27e9 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) \u2194 mul_salem_spencer s :=\n\u27e8\u03bb 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\u27e9\n\n@[to_additive]\nlemma mul_salem_spencer_mul_right_iff :\n  mul_salem_spencer ((* a) '' s) \u2194 mul_salem_spencer s :=\n\u27e8\u03bb 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\u27e9\n\nend cancel_comm_monoid\n\nsection ordered_cancel_comm_monoid\nvariables [ordered_cancel_comm_monoid \u03b1] {s : set \u03b1} {a : \u03b1}\n\n@[to_additive]\nlemma mul_salem_spencer_insert_of_lt (hs : \u2200 i \u2208 s, i < a) :\n  mul_salem_spencer (insert a s) \u2194 mul_salem_spencer s \u2227\n    \u2200 \u2983b c\u2984, b \u2208 s \u2192 c \u2208 s \u2192 a * b = c * c \u2192 a = b :=\nbegin\n  refine mul_salem_spencer_insert.trans _,\n  rw \u2190and_assoc,\n  exact and_iff_left (\u03bb 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 \u03b1] [no_zero_divisors \u03b1] {s : set \u03b1} {a : \u03b1}\n\nlemma mul_salem_spencer.mul_left\u2080 (hs : mul_salem_spencer s) (ha : a \u2260 0) :\n  mul_salem_spencer ((*) a '' s) :=\nbegin\n  rintro _ _ _ \u27e8b, hb, rfl\u27e9 \u27e8c, hc, rfl\u27e9 \u27e8d, hd, rfl\u27e9 h,\n  rw [mul_mul_mul_comm, mul_mul_mul_comm a d] at h,\n  rw hs hb hc hd (mul_left_cancel\u2080 (mul_ne_zero ha ha) h),\nend\n\nlemma mul_salem_spencer.mul_right\u2080 (hs : mul_salem_spencer s) (ha : a \u2260 0) :\n  mul_salem_spencer ((* a) '' s) :=\nbegin\n  rintro _ _ _ \u27e8b, hb, rfl\u27e9 \u27e8c, hc, rfl\u27e9 \u27e8d, hd, rfl\u27e9 h,\n  rw [mul_mul_mul_comm, mul_mul_mul_comm d] at h,\n  rw hs hb hc hd (mul_right_cancel\u2080 (mul_ne_zero ha ha) h),\nend\n\nlemma mul_salem_spencer_mul_left_iff\u2080 (ha : a \u2260 0) :\n  mul_salem_spencer ((*) a '' s) \u2194 mul_salem_spencer s :=\n\u27e8\u03bb hs b c d hb hc hd h, mul_left_cancel\u2080 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  \u03bb hs, hs.mul_left\u2080 ha\u27e9\n\nlemma mul_salem_spencer_mul_right_iff\u2080 (ha : a \u2260 0) :\n  mul_salem_spencer ((* a) '' s) \u2194 mul_salem_spencer s :=\n\u27e8\u03bb hs b c d hb hc hd h, mul_right_cancel\u2080 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  \u03bb hs, hs.mul_right\u2080 ha\u27e9\n\nend cancel_comm_monoid_with_zero\n\nsection nat\n\nlemma add_salem_spencer_iff_eq_right {s : set \u2115} :\n  add_salem_spencer s \u2194 \u2200 \u2983a b c\u2984, a \u2208 s \u2192 b \u2208 s \u2192 c \u2208 s \u2192 a + b = c + c \u2192 a = c :=\nbegin\n  refine forall\u2084_congr (\u03bb a b c _, forall\u2083_congr $ \u03bb _ _ habc, \u27e8_, _\u27e9),\n  { rintro rfl,\n    simp_rw \u2190two_mul at habc,\n    exact mul_left_cancel\u2080 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 \ud835\udd5c] [topological_space E] [add_comm_monoid E]\n  [module \ud835\udd5c E] {s : set E} (hs\u2080 : is_closed s) (hs\u2081 : strict_convex \ud835\udd5c s) :\n  add_salem_spencer (frontier s) :=\nbegin\n  intros a b c ha hb hc habc,\n  obtain rfl : (1 / 2 : \ud835\udd5c) \u2022 a + (1 / 2 : \ud835\udd5c) \u2022 b = c,\n  { rwa [\u2190smul_add, one_div, inv_smul_eq_iff\u2080 (show (2 : \ud835\udd5c) \u2260 0, by norm_num), two_smul] },\n  exact hs\u2081.eq (hs\u2080.frontier_subset ha) (hs\u2080.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 \u211d E]\n  [strict_convex_space \u211d E] (x : E) (r : \u211d) : 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 \u211d x r),\n    exact (frontier_closed_ball _ hr).symm }\nend\n\nend salem_spencer\n\nopen finset\n\nsection roth_number\nvariables [decidable_eq \u03b1]\n\nsection monoid\nvariables [monoid \u03b1] [decidable_eq \u03b2] [monoid \u03b2] (s t : finset \u03b1)\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 \u03b1 \u2192o \u2115 :=\n\u27e8\u03bb s, nat.find_greatest (\u03bb m, \u2203 t \u2286 s, t.card = m \u2227 mul_salem_spencer (t : set \u03b1)) s.card,\nbegin\n  rintro t u htu,\n  refine nat.find_greatest_mono (\u03bb m, _) (card_le_of_subset htu),\n  rintro \u27e8v, hvt, hv\u27e9,\n  exact \u27e8v, hvt.trans htu, hv\u27e9,\nend\u27e9\n\n@[to_additive]\nlemma mul_roth_number_le : mul_roth_number s \u2264 s.card := by convert nat.find_greatest_le s.card\n\n@[to_additive]\nlemma mul_roth_number_spec : \u2203 t \u2286 s, t.card = mul_roth_number s \u2227 mul_salem_spencer (t : set \u03b1) :=\n@nat.find_greatest_spec _ _ (\u03bb m, \u2203 t \u2286 s, t.card = m \u2227 mul_salem_spencer (t : set \u03b1)) _\n  (nat.zero_le _) \u27e8\u2205, empty_subset _, card_empty, mul_salem_spencer_empty\u27e9\n\nvariables {s t} {n : \u2115}\n\n@[to_additive]\nlemma mul_salem_spencer.le_mul_roth_number (hs : mul_salem_spencer (s : set \u03b1)) (h : s \u2286 t) :\n  s.card \u2264 mul_roth_number t :=\nle_find_greatest (card_le_of_subset h) \u27e8s, h, rfl, hs\u27e9\n\n@[to_additive]\nlemma mul_salem_spencer.roth_number_eq (hs : mul_salem_spencer (s : set \u03b1)) :\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 (\u2205 : finset \u03b1) = 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 : \u03b1) : mul_roth_number ({a} : finset \u03b1) = 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 \u03b1) :\n  mul_roth_number (s \u222a t) \u2264 mul_roth_number s + mul_roth_number t :=\nlet \u27e8u, hus, hcard, hu\u27e9 := mul_roth_number_spec (s \u222a t) in\ncalc\n  mul_roth_number (s \u222a t)\n      = u.card : hcard.symm\n  ... = (u \u2229 s \u222a u \u2229 t).card\n      : by rw [\u2190inter_distrib_left, (inter_eq_left_iff_subset _ _).2 hus]\n  ... \u2264 (u \u2229 s).card + (u \u2229 t).card : card_union_le _ _\n  ... \u2264 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 \u03b1) (t : finset \u03b2) :\n  mul_roth_number s * mul_roth_number t \u2264 mul_roth_number (s \u00d7\u02e2 t) :=\nbegin\n  obtain \u27e8u, hus, hucard, hu\u27e9 := mul_roth_number_spec s,\n  obtain \u27e8v, hvt, hvcard, hv\u27e9 := mul_roth_number_spec t,\n  rw [\u2190hucard, \u2190hvcard, \u2190card_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 : \u2200 t \u2208 powerset_len n s, \u00acmul_salem_spencer ((t : finset \u03b1) : set \u03b1)) :\n  mul_roth_number s < n :=\nbegin\n  obtain \u27e8t, hts, hcard, ht\u27e9 := mul_roth_number_spec s,\n  rw [\u2190hcard, \u2190not_le],\n  intro hn,\n  obtain \u27e8u, hut, rfl\u27e9 := exists_smaller_set t n hn,\n  exact h _ (mem_powerset_len.2 \u27e8hut.trans hts, rfl\u27e9) (ht.mono hut),\nend\n\nend monoid\n\nsection cancel_comm_monoid\nvariables [cancel_comm_monoid \u03b1] (s : finset \u03b1) (a : \u03b1)\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 \u27e8u, hus, hcard, hu\u27e9 := mul_roth_number_spec (s.map $ mul_left_embedding a),\n    rw subset_map_iff at hus,\n    obtain \u27e8u, hus, rfl\u27e9 := hus,\n    rw coe_map at hu,\n    rw [\u2190hcard, card_map],\n    exact (mul_salem_spencer_mul_left_iff.1 hu).le_mul_roth_number hus },\n  { obtain \u27e8u, hus, hcard, hu\u27e9 := mul_roth_number_spec s,\n    have h : mul_salem_spencer (u.map $ mul_left_embedding a : set \u03b1),\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 [\u2190mul_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 \u2115} {k n : \u2115}\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 \u2264 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))) \u2264 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 : \u2115 \u2192o \u2115 :=\n\u27e8\u03bb n, add_roth_number (range n), add_roth_number.mono.comp range_mono\u27e9\n\nlemma roth_number_nat_def (n : \u2115) : roth_number_nat n = add_roth_number (range n) := rfl\n\nlemma roth_number_nat_le (N : \u2115) : roth_number_nat N \u2264 N :=\n(add_roth_number_le _).trans (card_range _).le\n\nlemma roth_number_nat_spec (n : \u2115) :\n  \u2203 t \u2286 range n, t.card = roth_number_nat n \u2227 add_salem_spencer (t : set \u2115) :=\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 \u2115) (hs : add_salem_spencer (s : set \u2115))\n  (hsn : \u2200 x \u2208 s, x < n) (hsk : s.card = k) :\n  k \u2264 roth_number_nat n :=\nhsk.ge.trans $ hs.le_add_roth_number $ \u03bb 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 : \u2115) :\n  roth_number_nat (M + N) \u2264 roth_number_nat M + roth_number_nat N :=\nbegin\n  simp_rw roth_number_nat_def,\n  rw [range_add_eq_union, \u2190add_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 : \u2115) : 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 (\u03bb N, (roth_number_nat N : \u211d)) (\u03bb N, (N : \u211d)) :=\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 : (\u03bb N, (roth_number_nat N : \u211d)) =O[at_top] (\u03bb N, (N : \u211d)) :=\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 \u2227 R b c \u2227 R c d ...) -/\n\ntheorem chain_iff {\u03b1 : Type u} (R : \u03b1 \u2192 \u03b1 \u2192 Prop) :\n    \u2200 (\u1fb0 : \u03b1) (\u1fb0_1 : List \u03b1),\n        chain R \u1fb0 \u1fb0_1 \u2194\n          \u1fb0_1 = [] \u2228\n            Exists fun {b : \u03b1} => Exists fun {l : List \u03b1} => R \u1fb0 b \u2227 chain R b l \u2227 \u1fb0_1 = b :: l :=\n  sorry\n\ntheorem rel_of_chain_cons {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {l : List \u03b1}\n    (p : chain R a (b :: l)) : R a b :=\n  and.left (iff.mp chain_cons p)\n\ntheorem chain_of_chain_cons {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {l : List \u03b1}\n    (p : chain R a (b :: l)) : chain R b l :=\n  and.right (iff.mp chain_cons p)\n\ntheorem chain.imp' {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (HRS : \u2200 {a b : \u03b1}, R a b \u2192 S a b) {a : \u03b1} {b : \u03b1} (Hab : \u2200 {c : \u03b1}, R a c \u2192 S b c) {l : List \u03b1}\n    (p : chain R a l) : chain S b l :=\n  sorry\n\ntheorem chain.imp {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (H : \u2200 (a b : \u03b1), R a b \u2192 S a b) {a : \u03b1} {l : List \u03b1} (p : chain R a l) : chain S a l :=\n  chain.imp' H (H a) p\n\ntheorem chain.iff {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (H : \u2200 (a b : \u03b1), R a b \u2194 S a b) {a : \u03b1} {l : List \u03b1} : chain R a l \u2194 chain S a l :=\n  { mp := chain.imp fun (a b : \u03b1) => iff.mp (H a b),\n    mpr := chain.imp fun (a b : \u03b1) => iff.mpr (H a b) }\n\ntheorem chain.iff_mem {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1} :\n    chain R a l \u2194 chain (fun (x y : \u03b1) => x \u2208 a :: l \u2227 y \u2208 l \u2227 R x y) a l :=\n  sorry\n\ntheorem chain_singleton {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} : chain R a [b] \u2194 R a b :=\n  sorry\n\ntheorem chain_split {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {l\u2081 : List \u03b1} {l\u2082 : List \u03b1} :\n    chain R a (l\u2081 ++ b :: l\u2082) \u2194 chain R a (l\u2081 ++ [b]) \u2227 chain R b l\u2082 :=\n  sorry\n\ntheorem chain_map {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (f : \u03b2 \u2192 \u03b1) {b : \u03b2} {l : List \u03b2} :\n    chain R (f b) (map f l) \u2194 chain (fun (a b : \u03b2) => R (f a) (f b)) b l :=\n  sorry\n\ntheorem chain_of_chain_map {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2192 \u03b2) (H : \u2200 (a b : \u03b1), S (f a) (f b) \u2192 R a b) {a : \u03b1} {l : List \u03b1}\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 {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2192 \u03b2) (H : \u2200 (a b : \u03b1), R a b \u2192 S (f a) (f b)) {a : \u03b1} {l : List \u03b1} (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 {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    {p : \u03b1 \u2192 Prop} {f : (a : \u03b1) \u2192 p a \u2192 \u03b2}\n    (H : \u2200 (a b : \u03b1) (ha : p a) (hb : p b), R a b \u2192 S (f a ha) (f b hb)) {a : \u03b1} {l : List \u03b1}\n    (hl\u2081 : chain R a l) (ha : p a) (hl\u2082 : \u2200 (a : \u03b1), a \u2208 l \u2192 p a) :\n    chain S (f a ha) (pmap f l hl\u2082) :=\n  sorry\n\ntheorem chain_of_chain_pmap {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    {p : \u03b1 \u2192 Prop} (f : (a : \u03b1) \u2192 p a \u2192 \u03b2) {l : List \u03b1} (hl\u2081 : \u2200 (a : \u03b1), a \u2208 l \u2192 p a) {a : \u03b1}\n    (ha : p a) (hl\u2082 : chain S (f a ha) (pmap f l hl\u2081))\n    (H : \u2200 (a b : \u03b1) (ha : p a) (hb : p b), S (f a ha) (f b hb) \u2192 R a b) : chain R a l :=\n  sorry\n\ntheorem chain_of_pairwise {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1}\n    (p : pairwise R (a :: l)) : chain R a l :=\n  sorry\n\ntheorem chain_iff_pairwise {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (tr : transitive R) {a : \u03b1}\n    {l : List \u03b1} : chain R a l \u2194 pairwise R (a :: l) :=\n  sorry\n\ntheorem chain_iff_nth_le {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1} :\n    chain R a l \u2194\n        (\u2200 (h : 0 < length l), R a (nth_le l 0 h)) \u2227\n          \u2200 (i : \u2115) (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 {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (H : \u2200 (a b : \u03b1), R a b \u2192 S a b) {l : List \u03b1} (p : chain' R l) : chain' S l :=\n  list.cases_on l (fun (p : chain' R []) => trivial)\n    (fun (l_hd : \u03b1) (l_tl : List \u03b1) (p : chain' R (l_hd :: l_tl)) => chain.imp H p) p\n\ntheorem chain'.iff {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (H : \u2200 (a b : \u03b1), R a b \u2194 S a b) {l : List \u03b1} : chain' R l \u2194 chain' S l :=\n  { mp := chain'.imp fun (a b : \u03b1) => iff.mp (H a b),\n    mpr := chain'.imp fun (a b : \u03b1) => iff.mpr (H a b) }\n\ntheorem chain'.iff_mem {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    chain' R l \u2194 chain' (fun (x y : \u03b1) => x \u2208 l \u2227 y \u2208 l \u2227 R x y) l :=\n  sorry\n\n@[simp] theorem chain'_nil {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} : chain' R [] := trivial\n\n@[simp] theorem chain'_singleton {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (a : \u03b1) : chain' R [a] := chain.nil\n\ntheorem chain'_split {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {l\u2081 : List \u03b1} {l\u2082 : List \u03b1} :\n    chain' R (l\u2081 ++ a :: l\u2082) \u2194 chain' R (l\u2081 ++ [a]) \u2227 chain' R (a :: l\u2082) :=\n  sorry\n\ntheorem chain'_map {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (f : \u03b2 \u2192 \u03b1) {l : List \u03b2} :\n    chain' R (map f l) \u2194 chain' (fun (a b : \u03b2) => R (f a) (f b)) l :=\n  list.cases_on l (iff.refl (chain' R (map f []))) fun (l_hd : \u03b2) (l_tl : List \u03b2) => chain_map f\n\ntheorem chain'_of_chain'_map {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2192 \u03b2) (H : \u2200 (a b : \u03b1), S (f a) (f b) \u2192 R a b) {l : List \u03b1} (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' {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2192 \u03b2) (H : \u2200 (a b : \u03b1), R a b \u2192 S (f a) (f b)) {l : List \u03b1} (p : chain' R l) :\n    chain' S (map f l) :=\n  iff.mpr (chain'_map f) (chain'.imp H p)\n\ntheorem pairwise.chain' {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} : pairwise R l \u2192 chain' R l :=\n  sorry\n\ntheorem chain'_iff_pairwise {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (tr : transitive R) {l : List \u03b1} :\n    chain' R l \u2194 pairwise R l :=\n  list.cases_on l (idRhs (True \u2194 pairwise R []) (iff.symm (iff_true_intro pairwise.nil)))\n    fun (l_hd : \u03b1) (l_tl : List \u03b1) =>\n      idRhs (chain R l_hd l_tl \u2194 pairwise R (l_hd :: l_tl)) (chain_iff_pairwise tr)\n\n@[simp] theorem chain'_cons {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {x : \u03b1} {y : \u03b1} {l : List \u03b1} :\n    chain' R (x :: y :: l) \u2194 R x y \u2227 chain' R (y :: l) :=\n  chain_cons\n\ntheorem chain'.cons {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {x : \u03b1} {y : \u03b1} {l : List \u03b1} (h\u2081 : R x y)\n    (h\u2082 : chain' R (y :: l)) : chain' R (x :: y :: l) :=\n  iff.mpr chain'_cons { left := h\u2081, right := h\u2082 }\n\ntheorem chain'.tail {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} (h : chain' R l) :\n    chain' R (tail l) :=\n  sorry\n\ntheorem chain'.rel_head {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {x : \u03b1} {y : \u03b1} {l : List \u03b1}\n    (h : chain' R (x :: y :: l)) : R x y :=\n  rel_of_chain_cons h\n\ntheorem chain'.rel_head' {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {x : \u03b1} {l : List \u03b1}\n    (h : chain' R (x :: l)) {y : \u03b1} (hy : y \u2208 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' {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {x : \u03b1} {l : List \u03b1} :\n    chain' R l \u2192 (\u2200 (y : \u03b1), y \u2208 head' l \u2192 R x y) \u2192 chain' R (x :: l) :=\n  sorry\n\ntheorem chain'_cons' {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {x : \u03b1} {l : List \u03b1} :\n    chain' R (x :: l) \u2194 (\u2200 (y : \u03b1), y \u2208 head' l \u2192 R x y) \u2227 chain' R l :=\n  sorry\n\ntheorem chain'.append {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l\u2081 : List \u03b1} {l\u2082 : List \u03b1} (h\u2081 : chain' R l\u2081)\n    (h\u2082 : chain' R l\u2082) (h : \u2200 (x : \u03b1), x \u2208 last' l\u2081 \u2192 \u2200 (y : \u03b1), y \u2208 head' l\u2082 \u2192 R x y) :\n    chain' R (l\u2081 ++ l\u2082) :=\n  sorry\n\ntheorem chain'_pair {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {x : \u03b1} {y : \u03b1} : chain' R [x, y] \u2194 R x y :=\n  sorry\n\ntheorem chain'.imp_head {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {x : \u03b1} {y : \u03b1}\n    (h : \u2200 {z : \u03b1}, R x z \u2192 R y z) {l : List \u03b1} (hl : chain' R (x :: l)) : chain' R (y :: l) :=\n  chain'.cons' (chain'.tail hl)\n    fun (z : \u03b1) (hz : z \u2208 head' (tail (x :: l))) => h (chain'.rel_head' hl hz)\n\ntheorem chain'_reverse {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    chain' R (reverse l) \u2194 chain' (flip R) l :=\n  sorry\n\ntheorem chain'_iff_nth_le {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    chain' R l \u2194\n        \u2200 (i : \u2115) (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\u2081 l\u2082` and `l\u2083` are lists and `l\u2081 ++ l\u2082` and `l\u2082 ++ l\u2083` both satisfy\n  `chain' R`, then so does `l\u2081 ++ l\u2082 ++ l\u2083` provided `l\u2082 \u2260 []` -/\ntheorem chain'.append_overlap {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l\u2081 : List \u03b1} {l\u2082 : List \u03b1}\n    {l\u2083 : List \u03b1} (h\u2081 : chain' R (l\u2081 ++ l\u2082)) (h\u2082 : chain' R (l\u2082 ++ l\u2083)) (hn : l\u2082 \u2260 []) :\n    chain' R (l\u2081 ++ l\u2082 ++ l\u2083) :=\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 {\u03b1 : Type u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1}\n    (h : relation.refl_trans_gen r a b) :\n    \u2203 (l : List \u03b1), chain r a l \u2227 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 \u2192 p y \u2192 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 {\u03b1 : Type u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} (p : \u03b1 \u2192 Prop) (l : List \u03b1)\n    (h : chain r a l) (hb : last (a :: l) (cons_ne_nil a l) = b)\n    (carries : \u2200 {x y : \u03b1}, r x y \u2192 p y \u2192 p x) (final : p b) (i : \u03b1) (H : i \u2208 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 \u2192 p y \u2192 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 {\u03b1 : Type u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} (p : \u03b1 \u2192 Prop)\n    (l : List \u03b1) (h : chain r a l) (hb : last (a :: l) (cons_ne_nil a l) = b)\n    (carries : \u2200 {x y : \u03b1}, r x y \u2192 p y \u2192 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 {\u03b1 : Type u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1}\n    (l : List \u03b1) (hl\u2081 : chain r a l) (hl\u2082 : last (a :: l) (cons_ne_nil a l) = b) :\n    relation.refl_trans_gen r a b :=\n  chain.induction_head (fun (_x : \u03b1) => relation.refl_trans_gen r _x b) l hl\u2081 hl\u2082\n    (fun (x y : \u03b1) => 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  \u2964 Set  := \n{\n  obj :=  \u03bb A : Ring ,   R \u27f6  A,\n  map :=  \u03bb A B : Ring, \u03bb \u03c8 : A \u27f6 B, \u03bb \u03b6 :  R \u27f6 A,  \u03b6 \u226b \u03c8,  \n}\nlemma Spec.obj.ext (A : Ring) : (Spec R).obj A = (R \u27f6 A) := rfl\nlemma Spec.map.ext (A B : Ring)(\u03c8 : A \u27f6 B) (\u03b6 : R \u27f6 A): (Spec R).map \u03c8 \u03b6 =  ring_hom.comp \u03c8  \u03b6  := 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 \u2192 foo\n| two : \u2200 x : fin 3, bar x \u2192 foo\n```\n\nThe list of elements that we generate is\n```\n{foo.zero}\n\u222a (finset.univ : bool).map (\u03bb b, finset.one b)\n\u222a (finset.univ : \u03a3' x : fin 3, bar x).map (\u03bb \u27e8x, y\u27e9, finset.two x y)\n```\nexcept that instead of `\u222a`, 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 \u2192 \u2115\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 \u2260 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 \u2208 s` have `n \u2264 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 `\u03bb 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 \u2208 {foo.zero}\n  \u222a (finset.univ : bool).map (\u03bb b, finset.one b)\n  \u222a (finset.univ : \u03a3' x : fin 3, bar x).map (\u03bb \u27e8x, y\u27e9, 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 `\u0393` 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 `\u2200 a, enum (f a) = k`\n* `mk_finset` constructs the finset `S = {foo.zero} \u222a ...` by recursion on the variants\n* `mk_finset_total` constructs the proof `|- foo.zero \u2208 S; |- foo.one a \u2208 S; |- foo.two a b \u2208 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 (\u03b1) (enum : \u03b1 \u2192 \u2115) (n : \u2115) :=\n  { s : Finset \u03b1 // \u2200 x \u2208 s, n \u2264 enum x }\n#align derive_fintype.finset_above DeriveFintype.FinsetAbove\n\n/-- Construct a fintype instance from a completed `finset_above`. -/\ndef mkFintype {\u03b1} (enum : \u03b1 \u2192 \u2115) (s : FinsetAbove \u03b1 enum 0) (H : \u2200 x, x \u2208 s.1) : Fintype \u03b1 :=\n  \u27e8s.1, H\u27e9\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 {\u03b1} {enum : \u03b1 \u2192 \u2115} (n) (a : \u03b1) (h : enum a = n)\n    (s : FinsetAbove \u03b1 enum (n + 1)) : FinsetAbove \u03b1 enum n :=\n  by\n  refine' \u27e8Finset.cons a s.1 _, _\u27e9\n  \u00b7 intro h'\n    have := s.2 _ h'\n    rw [h] at this\n    exact Nat.not_succ_le_self n this\n  \u00b7 intro x h'\n    rcases Finset.mem_cons.1 h' with (rfl | h')\n    \u00b7 exact ge_of_eq h\n    \u00b7 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 {\u03b1} {enum : \u03b1 \u2192 \u2115} {n a h s} :\n    a \u2208 (@FinsetAbove.cons \u03b1 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 {\u03b1} {enum : \u03b1 \u2192 \u2115} {n a h s b} :\n    b \u2208 (s : FinsetAbove _ _ _).1 \u2192 b \u2208 (@FinsetAbove.cons \u03b1 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 {\u03b1} {enum : \u03b1 \u2192 \u2115} (n) : FinsetAbove \u03b1 enum n :=\n  \u27e8\u2205, by rintro _ \u27e8\u27e9\u27e9\n#align derive_fintype.finset_above.nil DeriveFintype.FinsetAbove.nil\n\ninstance (\u03b1 enum n) : Inhabited (FinsetAbove \u03b1 enum n) :=\n  \u27e8FinsetAbove.nil _\u27e9\n\n/-- This is a finset covering a nontrivial variant (with one or more constructor arguments).\nThe property `P` here is `\u03bb a, enum a = n` where `n` is the discriminant for the current\nvariant. -/\n@[nolint has_nonempty_instance]\ndef FinsetIn {\u03b1} (P : \u03b1 \u2192 Prop) :=\n  { s : Finset \u03b1 // \u2200 x \u2208 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 `\u0393`, which will be the\nsigma over all constructor arguments. We use sigma instances and existing fintype instances\nto prove that `\u0393` is a fintype, and construct the function `f` that maps `\u27e8a, b, c, ...\u27e9`\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 {\u03b1} {P : \u03b1 \u2192 Prop} (\u0393) [Fintype \u0393] (f : \u0393 \u2192 \u03b1) (inj : Function.Injective f)\n    (mem : \u2200 x, P (f x)) : FinsetIn P :=\n  \u27e8Finset.univ.map \u27e8f, inj\u27e9, fun x h => by\n    rcases Finset.mem_map.1 h with \u27e8x, _, rfl\u27e9 <;> exact mem x\u27e9\n#align derive_fintype.finset_in.mk DeriveFintype.FinsetIn.mk\n\ntheorem FinsetIn.mem_mk {\u03b1} {P : \u03b1 \u2192 Prop} {\u0393} {s : Fintype \u0393} {f : \u0393 \u2192 \u03b1} {inj mem a} (b)\n    (H : f b = a) : a \u2208 (@FinsetIn.mk \u03b1 P \u0393 s f inj mem).1 :=\n  Finset.mem_map.2 \u27e8_, Finset.mem_univ _, H\u27e9\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 {\u03b1} {enum : \u03b1 \u2192 \u2115} (n) (s : FinsetIn fun a => enum a = n)\n    (t : FinsetAbove \u03b1 enum (n + 1)) : FinsetAbove \u03b1 enum n :=\n  by\n  refine' \u27e8Finset.disjUnion s.1 t.1 _, _\u27e9\n  \u00b7 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  \u00b7 intro x h'\n    rcases Finset.mem_disjUnion.1 h' with (h' | h')\n    \u00b7 exact ge_of_eq (s.2 _ h')\n    \u00b7 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 {\u03b1} {enum : \u03b1 \u2192 \u2115} {n s t a} (H : a \u2208 (s : FinsetIn _).1) :\n    a \u2208 (@FinsetAbove.union \u03b1 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 {\u03b1} {enum : \u03b1 \u2192 \u2115} {n s t a}\n    (H : a \u2208 (t : FinsetAbove _ _ _).1) : a \u2208 (@FinsetAbove.union \u03b1 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 `\u03a3' (a:A) (b:B a) (c:C a b), unit` from\n`\u03a0 (a:A) (b:B a), C a b \u2192 T` (the type of a constructor). -/\nunsafe def mk_sigma : expr \u2192 tactic expr\n  | expr.pi n bi d b => do\n    let p \u2190 mk_local' n bi d\n    let e \u2190 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 `(\u03a3' (a:A) (b:B a) (c:C a b), unit) \u2192 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 \u2192 expr \u2192 tactic \u2115\n  | expr.pi n bi d b, c => do\n    refine ``(@PSigma.elim $(d) _ _ _)\n    let i \u2190 intro_fresh n\n    (\u00b7 + 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 \u2192 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 \u2192 \u27e8a1, ..., am\u27e9 = \u27e8b1, ..., bm\u27e9`, 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 : \u2115 \u2192 expr \u2192 expr \u2192 tactic Unit\n  | m + 1, x, y => do\n    let [(_, [x1, x2])] \u2190 cases x\n    let [(_, [y1, y2])] \u2190 cases y\n    mk_sigma_elim_inj m x2 y2\n  | 0, x, y => do\n    cases x\n    cases y\n    let is \u2190 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 : \u2115 \u2192 expr \u2192 tactic Unit\n  | n + 1, x => do\n    let [(_, [x1, x2])] \u2190 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) : \u2115 \u2192 List Name \u2192 tactic Unit\n  | k, c :: cs => do\n    let e := (expr.const c ls).mk_app args\n    let t \u2190 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 \u0393 \u2190 mk_sigma t\n        to_expr ``(FinsetIn.mk $(\u0393)) tt ff >>= fun c => apply c { NewGoals := new_goals.all }\n        let n \u2190 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 \u2190 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 `|- \u03a3' (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 \u2192 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 \u2208 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 \u2192 List (Name \u00d7 List expr) \u2192 tactic Unit\n  | tac, [] => done\n  | tac, (_, xs) :: gs => do\n    tac\n    let b \u2190 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)) \u2190 target >>= whnf\n  let (const I ls, args) \u2190 pure (get_app_fn_args e)\n  let env \u2190 get_env\n  let cs := env.constructors_of I\n  guard (env I = 0) <|> fail \"@[derive fintype]: inductive indices are not supported\"\n  guard \u00acenv 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 \u27e8i, _\u27e9 => 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 : \u2115)\n| zero : foo\n| one : bool \u2192 foo\n| two : fin n \u2192 fin m \u2192 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 `\u03b1`, then the generated instance will have an\nargument `fintype \u03b1`, 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 `\u2115`)\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 `\u03b1`.\n  We swap out operations for the base ring `\u03b1` with those for the exponent ring `\u2115`\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 `\u03b1` will have a universe level `u`.\n-- We do not introduce `\u03b1` 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 : \u2115` 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 : \u2115)\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 := \u27e8\u03bb x, \"(atom \" ++ repr x.2 ++ \")\"\u27e9\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 : \u211a)\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 \u2192 expr \u2192 tactic unit`.)\n-/\nmeta inductive ex : ex_type \u2192 Type\n| zero  (info : ex_info) : ex sum\n| sum   (info : ex_info) : ex prod \u2192 ex sum \u2192 ex sum\n| coeff (info : ex_info) : coeff \u2192 ex prod\n| prod  (info : ex_info) : ex exp \u2192 ex prod \u2192 ex prod\n| var   (info : ex_info) : atom \u2192 ex base\n| sum_b (info : ex_info) : ex sum \u2192 ex base\n| exp   (info : ex_info) : ex base \u2192 ex prod \u2192 ex exp\n\n/--\nReturn the proof information associated to the `ex`.\n-/\nmeta def ex.info : \u03a0 {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 : \u03a0 {et : ex_type} (ps : ex et), option expr \u2192 option expr \u2192 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 := \u27e8\u03bb x, repr x.1\u27e9\n\n/-- Convert an `ex` to a `string`. -/\nmeta def ex.repr : \u03a0 {et : ex_type}, ex et \u2192 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) := \u27e8ex.repr\u27e9\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 : \u03a0 {et : ex_type}, ex et \u2192 ex et \u2192 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 : \u03a0 {et : ex_type}, ex et \u2192 ex et \u2192 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 \u03b1.\n-/\nvariables {\u03b1 : Type u} [comm_semiring \u03b1]\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(\u03b1 : 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 `\u03b1`) and another for the exponent (always `\u2115`).\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 (\u03b1 : Type) : Type := reader_t context (state_t (list atom) tactic) \u03b1\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 {\u03b1} (m : tactic \u03b1) : ring_exp_m \u03b1 := 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 {\u03b1} (mx : ring_exp_m \u03b1) : ring_exp_m \u03b1 := do\n  ctx \u2190 get_context,\n  reader_t.lift $ mx.run \u27e8ctx.info_e, ctx.info_e, ctx.transp\u27e9\n\n/--\nSpecialized version of `mk_app` where the first two arguments are `{\u03b1}` `[some_class \u03b1]`.\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 \u2190 get_context,\n  pure $ (@expr.const tt f [ctx.info_b.univ] ctx.info_b.\u03b1 inst).mk_app args\n\n/--\nSpecialized version of `mk_app` where the first two arguments are `{\u03b1}` `[comm_semiring \u03b1]`.\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 \u2190 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 \u2190 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 \u2190 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 \u2190 get_context,\n  pure $ (@expr.const tt ``has_pow.pow\n    [ctx.info_b.univ, ctx.info_e.univ]\n    ctx.info_b.\u03b1 ctx.info_e.\u03b1\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 \u2192 ring_exp_m (option (list expr))\n| [] := pure none\n| (x :: xs) := do\n  xs_pfs \u2190 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 \u2190 traverse ex_info.proof_term xs,\n    pure (some (x_pf :: xs_pfs))\n  | (_, some xs_pfs) := do\n    x_pf \u2190 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' \u2190 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 \u2190 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' : \u03b1} : p = p' \u2192 ps = ps' \u2192 p + ps = p' + ps' := by cc\n\n/-- Congruence lemma for constructing `ex.prod`. -/\nlemma prod_congr {p p' ps ps' : \u03b1} : p = p' \u2192 ps = ps' \u2192 p * ps = p' * ps' := by cc\n\n/-- Congruence lemma for constructing `ex.exp`. -/\nlemma exp_congr {p p' : \u03b1} {ps ps' : \u2115} : p = p' \u2192 ps = ps' \u2192 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 \u2190 get_context,\n  pure $ ex.zero \u27e8ctx.info_b.zero, ctx.info_b.zero, none\u27e9\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 \u2190 add_orig p ps,\n  pps_p \u2190 mk_add [p.pretty, ps.pretty],\n  pps_pf \u2190 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 \u27e8pps_o, pps_p, pps_pf\u27e9 (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 \u2190 get_context,\n  x_p \u2190 lift $ expr.of_rat ctx.info_b.\u03b1 x,\n  pure (ex.coeff \u27e8x_p, x_p, none\u27e9 \u27e8x\u27e9)\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 \u2190 get_context,\n  pure $ ex.coeff \u27e8ctx.info_b.one, ctx.info_b.one, none\u27e9 \u27e81\u27e9\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 \u2190 mul_orig p ps,\n  pps_p \u2190 mk_mul [p.pretty, ps.pretty],\n  pps_pf \u2190 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 \u27e8pps_o, pps_p, pps_pf\u27e9 (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 \u27e8p.1, p.1, none\u27e9 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 \u2190 get_context,\n  pps_o \u2190 pow_orig p ps,\n  pps_p \u2190 mk_pow [p.pretty, ps.pretty],\n  pps_pf \u2190 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 \u27e8pps_o, pps_p, pps_pf\u27e9 (p.set_info none none) (ps.set_info none none))\n\nlemma base_to_exp_pf {p p' : \u03b1} : p = p' \u2192 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 \u2190 in_exponent $ ex_one,\n  ps \u2190 ex_exp p o,\n  pf \u2190 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' : \u03b1} : p = p' \u2192 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 \u2190 ex_one,\n  ps \u2190 ex_prod p o,\n  pf \u2190 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' : \u03b1} : p = p' \u2192 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 \u2190 ex_zero,\n  ps \u2190 ex_sum p z,\n  pf \u2190 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 : \u03b1) : 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' \u2190 ex_var p,\n  o \u2190 in_exponent $ ex_one,\n  p' \u2190 ex_exp p' o,\n  o \u2190 ex_one,\n  p' \u2190 ex_prod p' o,\n  z \u2190 ex_zero,\n  p' \u2190 ex_sum p' z,\n  pf \u2190 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 \u2190 get_context,\n  pq_o \u2190 mk_add [p_p, q_p],\n  (pq_p, pq_pf) \u2190 lift $ norm_num.eval_field pq_o,\n  pure $ ex.coeff \u27e8pq_o, pq_p, pq_pf\u27e9 \u27e8p.1 + q.1\u27e9\n\nlemma mul_coeff_pf_one_mul (q : \u03b1) : 1 * q = q := one_mul q\nlemma mul_coeff_pf_mul_one (p : \u03b1) : 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| \u27e81, 1, _, _\u27e9, _ := do\n  ctx \u2190 get_context,\n  pq_o \u2190 mk_mul [p_p, q_p],\n  pf \u2190 mk_app_csr ``mul_coeff_pf_one_mul [q_p],\n  pure $ ex.coeff \u27e8pq_o, q_p, pf\u27e9 \u27e8q.1\u27e9\n| _, \u27e81, 1, _, _\u27e9 := do\n  ctx \u2190 get_context,\n  pq_o \u2190 mk_mul [p_p, q_p],\n  pf \u2190 mk_app_csr ``mul_coeff_pf_mul_one [p_p],\n  pure $ ex.coeff \u27e8pq_o, p_p, pf\u27e9 \u27e8p.1\u27e9\n| _, _ := do\n  ctx \u2190 get_context,\n  pq' \u2190 mk_mul [p_p, q_p],\n  (pq_p, pq_pf) \u2190 lift $ norm_num.eval_field pq',\n  pure $ ex.coeff \u27e8pq_p, pq_p, pq_pf\u27e9 \u27e8p.1 * q.1\u27e9\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' \u2190 eval `(%%p_o + 1),\n  pf \u2190 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 \u2190 ps'.info.proof_term,\n  pf \u2190 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 \u2192 overlap\n| zero : ex sum \u2192 overlap\n\nlemma add_overlap_pf {ps qs pq} (p : \u03b1) : ps + qs = pq \u2192 p * ps + p * qs = p * pq := \u03bb 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 : \u03b1) : ps + qs = 0 \u2192 p * ps + p * qs = 0 := \u03bb 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 \u2192 ex prod \u2192 ring_exp_m overlap\n| (ex.coeff x_i x) (ex.coeff y_i y) := do\n  xy@(ex.coeff _ xy_c) \u2190 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 \u2190 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 \u2190 add_overlap ps qs,\n    pqs_o \u2190 add_orig pps qqs,\n    match pq_ol with\n    | overlap.none := pure overlap.none\n    | (overlap.nonzero pq) := do\n      pqs \u2190 ex_prod p pq,\n      pf \u2190 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 \u2190 ex_zero,\n      pf \u2190 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' : \u03b1} : ps = 0 \u2192 qs = qs' \u2192 ps + qs = qs' := \u03bb 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 : \u03b1} : ps = ps' \u2192 qs = 0 \u2192 ps + qs = ps' := \u03bb 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 : \u03b1} :\n  pps = p + ps \u2192 qqs = q + qs \u2192 p + q = pq \u2192 ps + qs = pqs \u2192 pps + qqs = pq + pqs := by cc\n\nlemma add_pf_sum_overlap_zero {pps p ps qqs q qs pqs : \u03b1} :\n  pps = p + ps \u2192 qqs = q + qs \u2192 p + q = 0 \u2192 ps + qs = pqs \u2192 pps + qqs = pqs :=\n\u03bb 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 : \u03b1} :\n  pps = p + ps \u2192 ps + qqs = pqs \u2192 pps + qqs = p + pqs := by cc\n\nlemma add_pf_sum_gt {pps qqs q qs pqs : \u03b1} :\n  qqs = q + qs \u2192 pps + qs = pqs \u2192 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 \u2192 ex sum \u2192 ring_exp_m (ex sum)\n| ps@(ex.zero ps_i) qs := do\n  pf \u2190 mk_proof ``add_pf_z_sum [ps.orig, qs.orig, qs.pretty] [ps.info, qs.info],\n  pqs_o \u2190 add_orig ps qs,\n  pure $ qs.set_info pqs_o pf\n| ps qs@(ex.zero qs_i) := do\n  pf \u2190 mk_proof ``add_pf_sum_z [ps.orig, ps.pretty, qs.orig] [ps.info, qs.info],\n  pqs_o \u2190 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 \u2190 add_overlap p q,\n  ppqqs_o \u2190 add_orig pps qqs,\n  match ol with\n  | (overlap.nonzero pq) := do\n    pqs \u2190 add ps qs,\n    pqqs \u2190 ex_sum pq pqs,\n    qqs_pf \u2190 qqs.proof_term,\n    pf \u2190 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 \u2190 add ps qs,\n    pf \u2190 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 \u2190 add ps qqs,\n    ppqs \u2190 ex_sum p pqs,\n    pf \u2190 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 \u2190 add pps qs,\n    pqqs \u2190 ex_sum q pqs,\n    pf \u2190 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 : \u03b1} :\n  ps = ps' \u2192 qs = qs' \u2192 ps' * qs' = pq \u2192 ps * qs = pq := by cc\n\nlemma mul_pf_c_prod {ps qqs q qs pqs : \u03b1} :\n  qqs = q * qs \u2192 ps * qs = pqs \u2192 ps * qqs = q * pqs := by cc\n\nlemma mul_pf_prod_c {pps p ps qs pqs : \u03b1} :\n  pps = p * ps \u2192 ps * qs = pqs \u2192 pps * qs = p * pqs := by cc\n\nlemma mul_pp_pf_overlap {pps p_b ps qqs qs psqs : \u03b1} {p_e q_e : \u2115} :\n  pps = p_b ^ p_e * ps \u2192 qqs = p_b ^ q_e * qs \u2192\n  p_b ^ (p_e + q_e) * (ps * qs) = psqs \u2192 pps * qqs = psqs\n:= \u03bb 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 : \u03b1} :\n  pps = p * ps \u2192 ps * qqs = pqs \u2192 pps * qqs = p * pqs := by cc\n\nlemma mul_pp_pf_prod_gt {pps qqs q qs pqs : \u03b1} :\n  qqs = q * qs \u2192 pps * qs = pqs \u2192 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 \u2192 ex prod \u2192 ring_exp_m (ex prod)\n| ps@(ex.coeff _ x) qs@(ex.coeff _ y) := do\n  pq \u2190 mul_coeff ps.pretty qs.pretty x y,\n  pq_o \u2190 mul_orig ps qs,\n  pf \u2190 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 \u2190 mul_pp ps qs,\n  pqqs \u2190 ex_prod q pqs,\n  pqqs_o \u2190 mul_orig ps qqs,\n  pf \u2190 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 \u2190 mul_pp ps qs,\n  ppqs \u2190 ex_prod p pqs,\n  ppqs_o \u2190 mul_orig pps qs,\n  pf \u2190 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 \u2190 mul_orig pps qqs,\n  pq_ol \u2190 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 \u2190 mul_pp ps qs,\n    pq \u2190 ex_exp p_b pq_e,\n    ppsqqs \u2190 ex_prod pq psqs,\n    pf \u2190 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 \u2190 mul_pp ps qqs,\n    ppqs \u2190 ex_prod p pqs,\n    pf \u2190 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 \u2190 mul_pp pps qs,\n    pqqs \u2190 ex_prod q pqs,\n    pf \u2190 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 : \u03b1} : ps = 0 \u2192 ps * qs = 0 :=\n\u03bb ps_pf, by rw [ps_pf, zero_mul]\n\nlemma mul_p_pf_sum {pps p ps qs ppsqs : \u03b1} : pps = p + ps \u2192\n  p * qs + ps * qs = ppsqs \u2192 pps * qs = ppsqs := \u03bb 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 \u2192 ex prod \u2192 ring_exp_m (ex sum)\n| ps@(ex.zero ps_i) qs := do\n  z \u2190 ex_zero,\n  z_o \u2190 mul_orig ps qs,\n  pf \u2190 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 \u2190 mul_pp p qs >>= prod_to_sum,\n  psqs \u2190 mul_p ps qs,\n  ppsqs \u2190 add pqs psqs,\n  pps_pf \u2190 pps.proof_term,\n  ppsqs_o \u2190 mul_orig pps qs,\n  ppsqs_pf \u2190 ppsqs.proof_term,\n  pf \u2190 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 : \u03b1} : qs = 0 \u2192 ps * qs = 0 :=\n\u03bb qs_pf, by rw [qs_pf, mul_zero]\n\nlemma mul_pf_sum {ps qqs q qs psqqs : \u03b1} : qqs = q + qs \u2192 ps * q + ps * qs = psqqs \u2192\n  ps * qqs = psqqs := \u03bb 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 \u2192 ex sum \u2192 ring_exp_m (ex sum)\n| ps qs@(ex.zero qs_i) := do\n  z \u2190 ex_zero,\n  z_o \u2190 mul_orig ps qs,\n  pf \u2190 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 \u2190 mul_p ps q,\n  psqs \u2190 mul ps qs,\n  psqqs \u2190 add psq psqs,\n  psqqs_o \u2190 mul_orig ps qqs,\n  pf \u2190 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 : \u03b1} {ps qs psqs : \u2115} :\n  pps = p ^ ps \u2192 ps * qs = psqs \u2192 pps ^ qs = p ^ psqs :=\n\u03bb 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 \u2190 get_context,\n  pq' \u2190 mk_pow [p_p, q_p],\n  (pq_p, pq_pf) \u2190 lift $ norm_num.eval_pow pq',\n  if q.value.denom \u2260 1 then lift $ fail!\"Only integer powers are supported, not {q.value}.\"\n  else pure $ ex.coeff \u27e8pq_p, pq_p, pq_pf\u27e9 \u27e8p.1 ^ q.value.num\u27e9\n\n/--\nExponentiate two expressions.\n\n* `(p ^ ps) ^ qs = p ^ (ps * qs)`\n-/\nmeta def pow_e : ex exp \u2192 ex prod \u2192 ring_exp_m (ex exp)\n| pps@(ex.exp pps_i p ps) qs := do\n  psqs \u2190 in_exponent $ mul_pp ps qs,\n  ppsqs \u2190 ex_exp p psqs,\n  ppsqs_o \u2190 pow_orig pps qs,\n  pf \u2190 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 : \u03b1} {qs qs' : \u2115} :\n  ps = ps' \u2192 qs = qs' \u2192 ps' ^ qs' = pq \u2192 ps ^ qs = pq := by cc\n\nlemma pow_pp_pf_c {ps ps' pqs : \u03b1} {qs qs' : \u2115} :\n  ps = ps' \u2192 qs = qs' \u2192 ps' ^ qs' = pqs \u2192 ps ^ qs = pqs * 1 :=\nby simp; cc\n\nlemma pow_pp_pf_prod {pps p ps pqs psqs : \u03b1} {qs : \u2115} : pps = p * ps \u2192\n  p ^ qs = pqs \u2192 ps ^ qs = psqs \u2192 pps ^ qs = pqs * psqs :=\n\u03bb 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 \u2192 ex prod \u2192 ring_exp_m (ex prod)\n| ps@(ex.coeff ps_i \u27e8\u27e81, 1, _, _\u27e9\u27e9) qs := do\n  o \u2190 ex_one,\n  o_o \u2190 pow_orig ps qs,\n  pf \u2190 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 \u2190 pow_coeff ps.pretty qs.pretty x y,\n  pq_o \u2190 pow_orig ps qs,\n  pf \u2190 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'' \u2190 pure ps >>= prod_to_sum >>= ex_sum_b,\n  pqs \u2190 ex_exp ps'' qs,\n  pqs_o \u2190 pow_orig ps qs,\n  pf \u2190 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' \u2190 exp_to_prod pqs,\n  pure $ pqs'.set_info pqs_o pf\n| pps@(ex.prod pps_i p ps) qs := do\n  pqs \u2190 pow_e p qs,\n  psqs \u2190 pow_pp ps qs,\n  ppsqs \u2190 ex_prod pqs psqs,\n  ppsqs_o \u2190 pow_orig pps qs,\n  pf \u2190 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' : \u03b1} {qs : \u2115} : ps = ps' \u2192 qs = succ zero \u2192 ps ^ qs = ps' :=\n\u03bb 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 : \u03b1} {qs qs' : \u2115} : ps = 0 \u2192 qs = succ qs' \u2192 ps ^ qs = 0 :=\n\u03bb 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 : \u03b1} {qs qs' : \u2115} :\n  qs = succ qs' \u2192 ps * ps ^ qs' = pqqs \u2192 ps ^ qs = pqqs :=\n\u03bb 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 : \u03b1} {qs : \u2115} :\n  pps = p + 0 \u2192 p ^ qs = pqs \u2192 pps ^ qs = pqs :=\n\u03bb pps_pf pqs_pf, by rw [pps_pf, add_zero, pqs_pf]\n\nlemma pow_p_pf_cons {ps ps' : \u03b1} {qs qs' : \u2115} :\n  ps = ps' \u2192 qs = qs' \u2192 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 \u2192 ex prod \u2192 ring_exp_m (ex sum)\n| ps qs@(ex.coeff qs_i \u27e8\u27e81, 1, _, _\u27e9\u27e9) := do\n  ps_o \u2190 pow_orig ps qs,\n  pf \u2190 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 \u27e8\u27e8succ y, 1, _, _\u27e9\u27e9) := do\n  ctx \u2190 get_context,\n  z \u2190 ex_zero,\n  qs_pred \u2190 lift $ expr.of_nat ctx.info_e.\u03b1 y,\n  pf \u2190 mk_proof ``pow_p_pf_zero [ps.orig, qs.orig, qs_pred] [ps.info, qs.info],\n  z_o \u2190 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 \u2190 pow_pp p qqs,\n  pqs_o \u2190 pow_orig pps qqs,\n  pf \u2190 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 \u27e8\u27e8int.of_nat (succ n), 1, den_pos, _\u27e9\u27e9) := do\n  qs' \u2190 in_exponent $ ex_coeff \u27e8int.of_nat n, 1, den_pos, coprime_one_right _\u27e9,\n  pqs \u2190 pow_p ps qs',\n  pqqs \u2190 mul ps pqs,\n  pqqs_o \u2190 pow_orig ps qs,\n  pf \u2190 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' \u2190 ex_sum_b pps,\n  psqs \u2190 ex_exp pps' qqs,\n  psqs_o \u2190 pow_orig pps qqs,\n  pf \u2190 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 : \u03b1} {qs : \u2115} : qs = 0 \u2192 ps ^ qs = 1 := \u03bb qs_pf, calc\n  ps ^ qs = ps ^ 0 : by rw [qs_pf]\n  ... = 1 : pow_zero _\n\nlemma pow_pf_sum {ps psqqs : \u03b1} {qqs q qs : \u2115} : qqs = q + qs \u2192\n  ps ^ q * ps ^ qs = psqqs \u2192 ps ^ qqs = psqqs := \u03bb 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 \u2192 ex sum \u2192 ring_exp_m (ex sum)\n| ps qs@(ex.zero qs_i) := do\n  o \u2190 ex_one,\n  o_o \u2190 pow_orig ps qs,\n  pf \u2190 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 \u2190 pow_p ps q,\n  psqs \u2190 pow ps qs,\n  psqqs \u2190 mul psq psqs,\n  psqqs_o \u2190 pow_orig ps qqs,\n  pf \u2190 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' : \u03b1} : p = p' \u2192 p + 0 = p' := by simp\n\nlemma simple_pf_prod_one {p p' : \u03b1} : p = p' \u2192 p * 1 = p' := by simp\n\nlemma simple_pf_prod_neg_one {\u03b1} [ring \u03b1] {p p' : \u03b1} : p = p' \u2192 p * -1 = - p' := by simp\n\nlemma simple_pf_var_one (p : \u03b1) : p ^ 1 = p := by simp\n\nlemma simple_pf_exp_one {p p' : \u03b1} : p = p' \u2192 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 : \u03a0 {et : ex_type}, ex et \u2192 ring_exp_m (expr \u00d7 expr)\n| sum pps@(ex.sum pps_i p (ex.zero _)) := do\n  (p_p, p_pf) \u2190 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) \u2190 p.simple,\n  (ps_p, ps_pf) \u2190 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 _ \u27e8\u27e81, 1, _, _\u27e9\u27e9)) := do\n  (p_p, p_pf) \u2190 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 _ \u27e8\u27e8-1, 1, _, _\u27e9\u27e9)) := do\n  ctx \u2190 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) \u2190 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) \u2190 p.simple,\n  (ps_p, ps_pf) \u2190 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 _ \u27e8\u27e81, 1, _, _\u27e9\u27e9)) := do\n  (p_p, p_pf) \u2190 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) \u2190 p.simple,\n  (ps_p, ps_pf) \u2190 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 \u2192 \u2115 \u2192 ring_exp_m (atom \u00d7 list atom)\n| [] n := let atm : atom := \u27e8a, n\u27e9 in pure (atm, [atm])\n| bas@(b :: as) n := do\n  ctx \u2190 get_context,\n  (lift $ is_def_eq a b.value ctx.transp >> pure (b , bas)) <|> do\n  (atm, as') \u2190 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 \u2190 reader_t.lift $ state_t.get,\n  (atm, atoms') \u2190 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 \u27e80, 1, _, _\u27e9 := ex_zero\n| some x := ex_coeff x >>= prod_to_sum\n| none := do\n  a \u2190 resolve_atom ps,\n  atom_to_sum a\nend\n\nlemma negate_pf {\u03b1} [ring \u03b1] {ps ps' : \u03b1} : (-1) * ps = ps' \u2192 -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 \u2190 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 \u2190 ex_coeff (-1) >>= prod_to_sum,\n    ps' \u2190 mul minus_one ps,\n    ps_pf \u2190 ps'.proof_term,\n    pf \u2190 mk_app_class ``negate_pf ring_instance [ps.orig, ps'.pretty, ps_pf],\n    ps'_o \u2190 lift $ mk_app ``has_neg.neg [ps.orig],\n    pure $ ps'.set_info ps'_o pf\n  end\n\nlemma inverse_pf {\u03b1} [division_ring \u03b1] {ps ps_u ps_p e' e'' : \u03b1} :\n  ps = ps_u \u2192 ps_u = ps_p \u2192 ps_p \u207b\u00b9 = e' \u2192 e' = e'' \u2192 ps \u207b\u00b9 = 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 \u2190 get_context,\n  dri \u2190 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) \u2190 ps.simple,\n  e \u2190 lift $ mk_app ``has_inv.inv [ps_simple],\n  (e', e_pf) \u2190 lift (norm_num.derive e) <|> ((\u03bb e_pf, (e, e_pf)) <$> lift (mk_eq_refl e)),\n  e'' \u2190 eval_base e',\n  ps_pf \u2190 ps.proof_term,\n  e''_pf \u2190 e''.proof_term,\n  pf \u2190 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 \u2190 lift $ mk_app ``has_inv.inv [ps.orig],\n  pure $ e''.set_info e''_o pf\n\nlemma sub_pf {\u03b1} [ring \u03b1] {ps qs psqs : \u03b1} (h : ps + -qs = psqs) : ps - qs = psqs :=\nby rwa sub_eq_add_neg\n\nlemma div_pf {\u03b1} [division_ring \u03b1] {ps qs psqs : \u03b1} (h : ps * qs\u207b\u00b9 = 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 \u2192 ring_exp_m (ex sum)\n| e@`(%%ps + %%qs) := do\n  ps' \u2190 eval ps,\n  qs' \u2190 eval qs,\n  add ps' qs'\n| ps_o@`(nat.succ %%p_o) := do\n  ps' \u2190 eval `(%%p_o + 1),\n  pf \u2190 lift $ mk_app ``nat.succ_eq_add_one [p_o],\n  rewrite ps_o ps' pf\n| e@`(%%ps - %%qs) := (do\n  ctx \u2190 get_context,\n  ri \u2190 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' \u2190 eval ps,\n  qs' \u2190 eval qs >>= negate,\n  psqs \u2190 add ps' qs',\n  psqs_pf \u2190 psqs.proof_term,\n  pf \u2190 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' \u2190 eval ps,\n  negate ps' <|> eval_base e\n| e@`(%%ps * %%qs) := do\n  ps' \u2190 eval ps,\n  qs' \u2190 eval qs,\n  mul ps' qs'\n| e@`(has_inv.inv %%ps) := do\n  ps' \u2190 eval ps,\n  inverse ps' <|> eval_base e\n| e@`(%%ps / %%qs) := do\n  ctx \u2190 get_context,\n  dri \u2190 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' \u2190 eval ps,\n  qs' \u2190 eval qs,\n  (do qs'' \u2190 inverse qs',\n  psqs \u2190 mul ps' qs'',\n  psqs_pf \u2190 psqs.proof_term,\n  pf \u2190 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 \u2190 get_context,\n  ps' \u2190 eval ps,\n  qs' \u2190 in_exponent $ eval qs,\n  psqs \u2190 pow ps' qs',\n  psqs_pf \u2190 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 \u2190 lift $ mk_eq_refl e,\n    pf \u2190 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 \u00d7 expr) := do\n  e' \u2190 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 \u00d7 expr) := do\n  (complicated, complicated_pf) \u2190 eval_with_proof e,\n  (simple, simple_pf) \u2190 complicated.simple,\n  prod.mk simple <$> lift (mk_eq_trans complicated_pf simple_pf)\n\n/-- Compute the `eval_info` for a given type `\u03b1`. -/\nmeta def make_eval_info (\u03b1 : expr) : tactic eval_info := do\n  u \u2190 mk_meta_univ,\n  infer_type \u03b1 >>= unify (expr.sort (level.succ u)),\n  u \u2190 get_univ_assignment u,\n  csr_instance \u2190 mk_app ``comm_semiring [\u03b1] >>= mk_instance,\n  ring_instance \u2190 (some <$> (mk_app ``ring [\u03b1] >>= mk_instance) <|> pure none),\n  dr_instance \u2190 (some <$> (mk_app ``division_ring [\u03b1] >>= mk_instance) <|> pure none),\n  ha_instance \u2190 mk_app ``has_add [\u03b1] >>= mk_instance,\n  hm_instance \u2190 mk_app ``has_mul [\u03b1] >>= mk_instance,\n  hp_instance \u2190 mk_mapp ``monoid.has_pow [some \u03b1, none],\n  z \u2190 mk_mapp ``has_zero.zero [\u03b1, none],\n  o \u2190 mk_mapp ``has_one.one [\u03b1, none],\n  pure \u27e8\u03b1, u, csr_instance, ha_instance, hm_instance, hp_instance, ring_instance, dr_instance, z, o\u27e9\n\n/-- Use `e` to build the context for running `mx`. -/\nmeta def run_ring_exp {\u03b1} (transp : transparency) (e : expr) (mx : ring_exp_m \u03b1) : tactic \u03b1 := do\n  info_b \u2190 infer_type e >>= make_eval_info,\n  info_e \u2190 mk_const ``nat >>= make_eval_info,\n  (\u03bb x : (_ \u00d7 _), x.1) <$> (state_t.run (reader_t.run mx \u27e8info_b, info_e, transp\u27e9) [])\n\n/-- Repeatedly apply `eval_simple` on (sub)expressions. -/\nmeta def normalize (transp : transparency) (e : expr) : tactic (expr \u00d7 expr) := do\n  (_, e', pf') \u2190 ext_simplify_core () {}\n  simp_lemmas.mk (\u03bb _, failed) (\u03bb _ _ _ _ e, do\n    (e'', pf) \u2190 run_ring_exp transp e $ eval_simple e,\n    guard (\u00ac e'' =\u2090 e),\n    return ((), e'', some pf, ff))\n  (\u03bb _ _ _ _ _, 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) \u2190 target >>= whnf,\n\n  let transp := if red.is_some then semireducible else reducible,\n\n  ((ps', ps_pf), (qs', qs_pf)) \u2190 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 \u2190 mk_eq_symm qs_pf,\n    pf \u2190 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 : \u2115) (m : \u2124) : 2^(n+1) * m = 2 * 2^n * m := by ring_exp\nexample (a b : \u2124) (n : \u2115) : (a + b)^(n + 2) = (a^2 + b^2 + a * b + b * a) * (a + b)^n := by ring_exp\nexample (x y : \u2115) : 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 \u2190 loc.get_locals,\n  let transp := if red.is_some then semireducible else reducible,\n  tt \u2190 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 {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : 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 {\u03b1 : Type.{u1}} [_inst_1 : CommMonoid.{u1} \u03b1] (f : Bool -> \u03b1), Eq.{succ u1} \u03b1 (Finset.prod.{u1, 0} \u03b1 Bool _inst_1 (Finset.univ.{0} Bool Bool.fintype) (fun (b : Bool) => f b)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (CommMonoid.toMonoid.{u1} \u03b1 _inst_1)))) (f Bool.true) (f Bool.false))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CommMonoid.{u1} \u03b1] (f : Bool -> \u03b1), Eq.{succ u1} \u03b1 (Finset.prod.{u1, 0} \u03b1 Bool _inst_1 (Finset.univ.{0} Bool Bool.fintype) (fun (b : Bool) => f b)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (CommMonoid.toMonoid.{u1} \u03b1 _inst_1)))) (f Bool.true) (f Bool.false))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_bool Fintype.prod_bool\u2093'. -/\n@[to_additive]\ntheorem prod_bool [CommMonoid \u03b1] (f : Bool \u2192 \u03b1) : (\u220f 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 {\u03b1} [Fintype \u03b1] : Fintype.card \u03b1 = \u2211 a : \u03b1, 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 {\u03b9 : Type _} [DecidableEq \u03b9] [Fintype \u03b9]\n\n/- warning: fintype.prod_extend_by_one -> Fintype.prod_extend_by_one is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b9] [_inst_2 : Fintype.{u2} \u03b9] [_inst_3 : CommMonoid.{u1} \u03b1] (s : Finset.{u2} \u03b9) (f : \u03b9 -> \u03b1), Eq.{succ u1} \u03b1 (Finset.prod.{u1, u2} \u03b1 \u03b9 _inst_3 (Finset.univ.{u2} \u03b9 _inst_2) (fun (i : \u03b9) => ite.{succ u1} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.hasMem.{u2} \u03b9) i s) (Finset.decidableMem.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) i s) (f i) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (CommMonoid.toMonoid.{u1} \u03b1 _inst_3)))))))) (Finset.prod.{u1, u2} \u03b1 \u03b9 _inst_3 s (fun (i : \u03b9) => f i))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b9] [_inst_2 : Fintype.{u1} \u03b9] [_inst_3 : CommMonoid.{u2} \u03b1] (s : Finset.{u1} \u03b9) (f : \u03b9 -> \u03b1), Eq.{succ u2} \u03b1 (Finset.prod.{u2, u1} \u03b1 \u03b9 _inst_3 (Finset.univ.{u1} \u03b9 _inst_2) (fun (i : \u03b9) => ite.{succ u2} \u03b1 (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) i s) (Finset.decidableMem.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_1 a b) i s) (f i) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (Monoid.toOne.{u2} \u03b1 (CommMonoid.toMonoid.{u2} \u03b1 _inst_3)))))) (Finset.prod.{u2, u1} \u03b1 \u03b9 _inst_3 s (fun (i : \u03b9) => f i))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_extend_by_one Fintype.prod_extend_by_one\u2093'. -/\n@[to_additive]\ntheorem prod_extend_by_one [CommMonoid \u03b1] (s : Finset \u03b9) (f : \u03b9 \u2192 \u03b1) :\n    (\u220f i, if i \u2208 s then f i else 1) = \u220f i in s, f i := by\n  rw [\u2190 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 \u03b1] [CommMonoid M]\n\n/- warning: fintype.prod_eq_one -> Fintype.prod_eq_one is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : CommMonoid.{u2} M] (f : \u03b1 -> M), (forall (a : \u03b1), 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 \u03b1 _inst_2 (Finset.univ.{u1} \u03b1 _inst_1) (fun (a : \u03b1) => 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : CommMonoid.{u2} M] (f : \u03b1 -> M), (forall (a : \u03b1), 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 \u03b1 _inst_2 (Finset.univ.{u1} \u03b1 _inst_1) (fun (a : \u03b1) => 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\u2093'. -/\n@[to_additive]\ntheorem prod_eq_one (f : \u03b1 \u2192 M) (h : \u2200 a, f a = 1) : (\u220f 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 : \u03b1 \u2192 M) (h : \u2200 a, f a = g a) : (\u220f a, f a) = \u220f 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : CommMonoid.{u2} M] {f : \u03b1 -> M} (a : \u03b1), (forall (x : \u03b1), (Ne.{succ u1} \u03b1 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 \u03b1 _inst_2 (Finset.univ.{u1} \u03b1 _inst_1) (fun (x : \u03b1) => f x)) (f a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : CommMonoid.{u1} M] {f : \u03b1 -> M} (a : \u03b1), (forall (x : \u03b1), (Ne.{succ u2} \u03b1 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 \u03b1 _inst_2 (Finset.univ.{u2} \u03b1 _inst_1) (fun (x : \u03b1) => f x)) (f a))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_eq_single Fintype.prod_eq_single\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x \u00abexpr \u2260 \u00bb a) -/\n@[to_additive]\ntheorem prod_eq_single {f : \u03b1 \u2192 M} (a : \u03b1) (h : \u2200 (x) (_ : x \u2260 a), f x = 1) : (\u220f 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : CommMonoid.{u2} M] {f : \u03b1 -> M} (a : \u03b1) (b : \u03b1), (Ne.{succ u1} \u03b1 a b) -> (forall (x : \u03b1), (And (Ne.{succ u1} \u03b1 x a) (Ne.{succ u1} \u03b1 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 \u03b1 _inst_2 (Finset.univ.{u1} \u03b1 _inst_1) (fun (x : \u03b1) => 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 {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : CommMonoid.{u1} M] {f : \u03b1 -> M} (a : \u03b1) (b : \u03b1), (Ne.{succ u2} \u03b1 a b) -> (forall (x : \u03b1), (And (Ne.{succ u2} \u03b1 x a) (Ne.{succ u2} \u03b1 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 \u03b1 _inst_2 (Finset.univ.{u2} \u03b1 _inst_1) (fun (x : \u03b1) => 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\u2093'. -/\n@[to_additive]\ntheorem prod_eq_mul {f : \u03b1 \u2192 M} (a b : \u03b1) (h\u2081 : a \u2260 b) (h\u2082 : \u2200 x, x \u2260 a \u2227 x \u2260 b \u2192 f x = 1) :\n    (\u220f x, f x) = f a * f b := by\n  apply Finset.prod_eq_mul a b h\u2081 fun x _ hx => h\u2082 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 {\u03b9 : Type _} [Subsingleton \u03b9] {s : Finset \u03b9} {f : \u03b9 \u2192 M}\n    {b : M} (h : (\u220f i in s, f i) = b) : \u2200 i \u2208 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 \u03b1] [CommMonoid M]\n\n/- warning: fintype.prod_option -> Fintype.prod_option is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : CommMonoid.{u2} M] (f : (Option.{u1} \u03b1) -> M), Eq.{succ u2} M (Finset.prod.{u2, u1} M (Option.{u1} \u03b1) _inst_2 (Finset.univ.{u1} (Option.{u1} \u03b1) (Option.fintype.{u1} \u03b1 _inst_1)) (fun (i : Option.{u1} \u03b1) => 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} \u03b1)) (Finset.prod.{u2, u1} M \u03b1 _inst_2 (Finset.univ.{u1} \u03b1 _inst_1) (fun (i : \u03b1) => f (Option.some.{u1} \u03b1 i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : CommMonoid.{u1} M] (f : (Option.{u2} \u03b1) -> M), Eq.{succ u1} M (Finset.prod.{u1, u2} M (Option.{u2} \u03b1) _inst_2 (Finset.univ.{u2} (Option.{u2} \u03b1) (instFintypeOption.{u2} \u03b1 _inst_1)) (fun (i : Option.{u2} \u03b1) => 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} \u03b1)) (Finset.prod.{u1, u2} M \u03b1 _inst_2 (Finset.univ.{u2} \u03b1 _inst_1) (fun (i : \u03b1) => f (Option.some.{u2} \u03b1 i))))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_option Fintype.prod_option\u2093'. -/\n@[simp, to_additive]\ntheorem Fintype.prod_option (f : Option \u03b1 \u2192 M) : (\u220f i, f i) = f none * \u220f 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 {\u03b1 : Type.{u1}} (\u03b2 : \u03b1 -> Type.{u2}) [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : forall (a : \u03b1), Fintype.{u2} (\u03b2 a)], Eq.{1} Nat (Fintype.card.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2) (Sigma.fintype.{u1, u2} \u03b1 \u03b2 _inst_1 (fun (a : \u03b1) => _inst_2 a))) (Finset.sum.{0, u1} Nat \u03b1 Nat.addCommMonoid (Finset.univ.{u1} \u03b1 _inst_1) (fun (a : \u03b1) => Fintype.card.{u2} (\u03b2 a) (_inst_2 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (\u03b2 : \u03b1 -> Type.{u1}) [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : forall (a : \u03b1), Fintype.{u1} (\u03b2 a)], Eq.{1} Nat (Fintype.card.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2) (instFintypeSigma.{u2, u1} \u03b1 \u03b2 _inst_1 (fun (a : \u03b1) => _inst_2 a))) (Finset.sum.{0, u2} Nat \u03b1 Nat.addCommMonoid (Finset.univ.{u2} \u03b1 _inst_1) (fun (a : \u03b1) => Fintype.card.{u1} (\u03b2 a) (_inst_2 a)))\nCase conversion may be inaccurate. Consider using '#align fintype.card_sigma Fintype.card_sigma\u2093'. -/\n@[simp]\ntheorem Fintype.card_sigma {\u03b1 : Type _} (\u03b2 : \u03b1 \u2192 Type _) [Fintype \u03b1] [\u2200 a, Fintype (\u03b2 a)] :\n    Fintype.card (Sigma \u03b2) = \u2211 a, Fintype.card (\u03b2 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {\u03b4 : \u03b1 -> Type.{u2}} (s : Finset.{u1} \u03b1) (t : forall (a : \u03b1), Finset.{u2} (\u03b4 a)), Eq.{1} Nat (Finset.card.{max u1 u2} (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) -> (\u03b4 a)) (Finset.pi.{u1, u2} \u03b1 (fun (a : \u03b1) => \u03b4 a) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s t)) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid s (fun (a : \u03b1) => Finset.card.{u2} (\u03b4 a) (t a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b1] {\u03b4 : \u03b1 -> Type.{u1}} (s : Finset.{u2} \u03b1) (t : forall (a : \u03b1), Finset.{u1} (\u03b4 a)), Eq.{1} Nat (Finset.card.{max u2 u1} (forall (a : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) a s) -> (\u03b4 a)) (Finset.pi.{u1, u2} \u03b1 (fun (a : \u03b1) => \u03b4 a) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s t)) (Finset.prod.{0, u2} Nat \u03b1 Nat.commMonoid s (fun (a : \u03b1) => Finset.card.{u1} (\u03b4 a) (t a)))\nCase conversion may be inaccurate. Consider using '#align finset.card_pi Finset.card_pi\u2093'. -/\n@[simp]\ntheorem Finset.card_pi [DecidableEq \u03b1] {\u03b4 : \u03b1 \u2192 Type _} (s : Finset \u03b1) (t : \u2200 a, Finset (\u03b4 a)) :\n    (s.pi t).card = \u220f 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} \u03b1] {\u03b4 : \u03b1 -> Type.{u2}} (t : forall (a : \u03b1), Finset.{u2} (\u03b4 a)), Eq.{1} Nat (Finset.card.{max u1 u2} (forall (a : \u03b1), \u03b4 a) (Fintype.piFinset.{u1, u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => \u03b4 a) t)) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Finset.univ.{u1} \u03b1 _inst_2) (fun (a : \u03b1) => Finset.card.{u2} (\u03b4 a) (t a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : Fintype.{u2} \u03b1] {\u03b4 : \u03b1 -> Type.{u1}} (t : forall (a : \u03b1), Finset.{u1} (\u03b4 a)), Eq.{1} Nat (Finset.card.{max u2 u1} (forall (a : \u03b1), \u03b4 a) (Fintype.piFinset.{u2, u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => \u03b4 a) t)) (Finset.prod.{0, u2} Nat \u03b1 Nat.commMonoid (Finset.univ.{u2} \u03b1 _inst_2) (fun (a : \u03b1) => Finset.card.{u1} (\u03b4 a) (t a)))\nCase conversion may be inaccurate. Consider using '#align fintype.card_pi_finset Fintype.card_piFinset\u2093'. -/\n@[simp]\ntheorem Fintype.card_piFinset [DecidableEq \u03b1] [Fintype \u03b1] {\u03b4 : \u03b1 \u2192 Type _} (t : \u2200 a, Finset (\u03b4 a)) :\n    (Fintype.piFinset t).card = \u220f 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 {\u03b2 : \u03b1 \u2192 Type _} [DecidableEq \u03b1] [Fintype \u03b1] [f : \u2200 a, Fintype (\u03b2 a)] :\n    Fintype.card (\u2200 a, \u03b2 a) = \u220f a, Fintype.card (\u03b2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} \u03b1] [_inst_3 : Fintype.{u2} \u03b2], Eq.{1} Nat (Fintype.card.{max u1 u2} (\u03b1 -> \u03b2) (Pi.fintype.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => _inst_3))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) (Fintype.card.{u2} \u03b2 _inst_3) (Fintype.card.{u1} \u03b1 _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : Fintype.{u2} \u03b1] [_inst_3 : Fintype.{u1} \u03b2], Eq.{1} Nat (Fintype.card.{max u2 u1} (\u03b1 -> \u03b2) (Pi.fintype.{u2, u1} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => _inst_3))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) (Fintype.card.{u1} \u03b2 _inst_3) (Fintype.card.{u2} \u03b1 _inst_2))\nCase conversion may be inaccurate. Consider using '#align fintype.card_fun Fintype.card_fun\u2093'. -/\n-- FIXME ouch, this should be in the main file.\n@[simp]\ntheorem Fintype.card_fun [DecidableEq \u03b1] [Fintype \u03b1] [Fintype \u03b2] :\n    Fintype.card (\u03b1 \u2192 \u03b2) = Fintype.card \u03b2 ^ Fintype.card \u03b1 := 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 \u03b1] (n : \u2115) : Fintype.card (Vector \u03b1 n) = Fintype.card \u03b1 ^ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : CommMonoid.{u2} \u03b2] (f : (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a (Finset.univ.{u1} \u03b1 _inst_1))) -> \u03b2), Eq.{succ u2} \u03b2 (Finset.prod.{u2, u1} \u03b2 (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) x (Finset.univ.{u1} \u03b1 _inst_1))) _inst_2 (Finset.attach.{u1} \u03b1 (Finset.univ.{u1} \u03b1 _inst_1)) (fun (x : Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) x (Finset.univ.{u1} \u03b1 _inst_1))) => f x)) (Finset.prod.{u2, u1} \u03b2 \u03b1 _inst_2 (Finset.univ.{u1} \u03b1 _inst_1) (fun (x : \u03b1) => f (Subtype.mk.{succ u1} \u03b1 (fun (a : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a (Finset.univ.{u1} \u03b1 _inst_1)) x (Finset.mem_univ.{u1} \u03b1 _inst_1 x))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : CommMonoid.{u1} \u03b2] (f : (Subtype.{succ u2} \u03b1 (fun (a : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) a (Finset.univ.{u2} \u03b1 _inst_1))) -> \u03b2), Eq.{succ u1} \u03b2 (Finset.prod.{u1, u2} \u03b2 (Subtype.{succ u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) x (Finset.univ.{u2} \u03b1 _inst_1))) _inst_2 (Finset.attach.{u2} \u03b1 (Finset.univ.{u2} \u03b1 _inst_1)) (fun (x : Subtype.{succ u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) x (Finset.univ.{u2} \u03b1 _inst_1))) => f x)) (Finset.prod.{u1, u2} \u03b2 \u03b1 _inst_2 (Finset.univ.{u2} \u03b1 _inst_1) (fun (x : \u03b1) => f (Subtype.mk.{succ u2} \u03b1 (fun (a : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) a (Finset.univ.{u2} \u03b1 _inst_1)) x (Finset.mem_univ.{u2} \u03b1 _inst_1 x))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_attach_univ Finset.prod_attach_univ\u2093'. -/\n@[simp, to_additive]\ntheorem Finset.prod_attach_univ [Fintype \u03b1] [CommMonoid \u03b2] (f : { a : \u03b1 // a \u2208 @univ \u03b1 _ } \u2192 \u03b2) :\n    (\u220f x in univ.attach, f x) = \u220f x, f \u27e8x, mem_univ _\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} \u03b1] [_inst_3 : CommMonoid.{u2} \u03b2] {\u03b4 : \u03b1 -> Type.{u3}} {t : forall (a : \u03b1), Finset.{u3} (\u03b4 a)} (f : (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a (Finset.univ.{u1} \u03b1 _inst_2)) -> (\u03b4 a)) -> \u03b2), Eq.{succ u2} \u03b2 (Finset.prod.{u2, max u1 u3} \u03b2 (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a (Finset.univ.{u1} \u03b1 _inst_2)) -> (\u03b4 a)) _inst_3 (Finset.pi.{u1, u3} \u03b1 (fun (a : \u03b1) => \u03b4 a) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Finset.univ.{u1} \u03b1 _inst_2) t) (fun (x : forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a (Finset.univ.{u1} \u03b1 _inst_2)) -> (\u03b4 a)) => f x)) (Finset.prod.{u2, max u1 u3} \u03b2 (forall (a : \u03b1), \u03b4 a) _inst_3 (Fintype.piFinset.{u1, u3} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => \u03b4 a) t) (fun (x : forall (a : \u03b1), \u03b4 a) => f (fun (a : \u03b1) (_x : Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a (Finset.univ.{u1} \u03b1 _inst_2)) => x a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u3} \u03b1] [_inst_2 : Fintype.{u3} \u03b1] [_inst_3 : CommMonoid.{u2} \u03b2] {\u03b4 : \u03b1 -> Type.{u1}} {t : forall (a : \u03b1), Finset.{u1} (\u03b4 a)} (f : (forall (a : \u03b1), (Membership.mem.{u3, u3} \u03b1 (Finset.{u3} \u03b1) (Finset.instMembershipFinset.{u3} \u03b1) a (Finset.univ.{u3} \u03b1 _inst_2)) -> (\u03b4 a)) -> \u03b2), Eq.{succ u2} \u03b2 (Finset.prod.{u2, max u3 u1} \u03b2 (forall (a : \u03b1), (Membership.mem.{u3, u3} \u03b1 (Finset.{u3} \u03b1) (Finset.instMembershipFinset.{u3} \u03b1) a (Finset.univ.{u3} \u03b1 _inst_2)) -> (\u03b4 a)) _inst_3 (Finset.pi.{u1, u3} \u03b1 (fun (a : \u03b1) => \u03b4 a) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Finset.univ.{u3} \u03b1 _inst_2) t) (fun (x : forall (a : \u03b1), (Membership.mem.{u3, u3} \u03b1 (Finset.{u3} \u03b1) (Finset.instMembershipFinset.{u3} \u03b1) a (Finset.univ.{u3} \u03b1 _inst_2)) -> (\u03b4 a)) => f x)) (Finset.prod.{u2, max u1 u3} \u03b2 (forall (a : \u03b1), \u03b4 a) _inst_3 (Fintype.piFinset.{u3, u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => \u03b4 a) t) (fun (x : forall (a : \u03b1), \u03b4 a) => f (fun (a : \u03b1) (_x : Membership.mem.{u3, u3} \u03b1 (Finset.{u3} \u03b1) (Finset.instMembershipFinset.{u3} \u03b1) a (Finset.univ.{u3} \u03b1 _inst_2)) => x a)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_univ_pi Finset.prod_univ_pi\u2093'. -/\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 (\u03a0 a \u2208 univ, t a)` and\n  `fintype.pi_finset t` is a `finset (\u03a0 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 (\u03a0 a \u2208 univ, t a)` and\\n  `fintype.pi_finset t` is a `finset (\u03a0 a, t a)`.\"]\ntheorem Finset.prod_univ_pi [DecidableEq \u03b1] [Fintype \u03b1] [CommMonoid \u03b2] {\u03b4 : \u03b1 \u2192 Type _}\n    {t : \u2200 a : \u03b1, Finset (\u03b4 a)} (f : (\u2200 a : \u03b1, a \u2208 (univ : Finset \u03b1) \u2192 \u03b4 a) \u2192 \u03b2) :\n    (\u220f x in univ.pi t, f x) = \u220f 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    \u27e8fun a _ => x a, by simp_all\u27e9\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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} [_inst_1 : DecidableEq.{succ u_1} \u03b1] [_inst_2 : Fintype.{u_1} \u03b1] [_inst_3 : CommSemiring.{u_2} \u03b2] {\u03b4 : \u03b1 -> Type.{u_1}} [_inst_4 : forall (a : \u03b1), DecidableEq.{succ u_1} (\u03b4 a)] {t : forall (a : \u03b1), Finset.{u_1} (\u03b4 a)} {f : forall (a : \u03b1), (\u03b4 a) -> \u03b2}, Eq.{succ u_2} \u03b2 (Finset.prod.{u_2, u_1} \u03b2 \u03b1 (CommSemiring.toCommMonoid.{u_2} \u03b2 _inst_3) (Finset.univ.{u_1} \u03b1 _inst_2) (fun (a : \u03b1) => Finset.sum.{u_2, u_1} \u03b2 (\u03b4 a) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u_2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u_2} \u03b2 (Semiring.toNonAssocSemiring.{u_2} \u03b2 (CommSemiring.toSemiring.{u_2} \u03b2 _inst_3)))) (t a) (fun (b : \u03b4 a) => f a b))) (Finset.sum.{u_2, u_1} \u03b2 (forall (a : \u03b1), \u03b4 a) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u_2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u_2} \u03b2 (Semiring.toNonAssocSemiring.{u_2} \u03b2 (CommSemiring.toSemiring.{u_2} \u03b2 _inst_3)))) (Fintype.piFinset.{u_1, u_1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => \u03b4 a) t) (fun (p : forall (a : \u03b1), \u03b4 a) => Finset.prod.{u_2, u_1} \u03b2 \u03b1 (CommSemiring.toCommMonoid.{u_2} \u03b2 _inst_3) (Finset.univ.{u_1} \u03b1 _inst_2) (fun (x : \u03b1) => f x (p x))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_2}} {\u03b2 : Type.{u_3}} [_inst_1 : DecidableEq.{succ u_2} \u03b1] [_inst_2 : Fintype.{u_2} \u03b1] [_inst_3 : CommSemiring.{u_3} \u03b2] {\u03b4 : \u03b1 -> Type.{u_1}} [_inst_4 : forall (a : \u03b1), DecidableEq.{succ u_1} (\u03b4 a)] {t : forall (a : \u03b1), Finset.{u_1} (\u03b4 a)} {f : forall (a : \u03b1), (\u03b4 a) -> \u03b2}, Eq.{succ u_3} \u03b2 (Finset.prod.{u_3, u_2} \u03b2 \u03b1 (CommSemiring.toCommMonoid.{u_3} \u03b2 _inst_3) (Finset.univ.{u_2} \u03b1 _inst_2) (fun (a : \u03b1) => Finset.sum.{u_3, u_1} \u03b2 (\u03b4 a) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u_3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u_3} \u03b2 (Semiring.toNonAssocSemiring.{u_3} \u03b2 (CommSemiring.toSemiring.{u_3} \u03b2 _inst_3)))) (t a) (fun (b : \u03b4 a) => f a b))) (Finset.sum.{u_3, max u_1 u_2} \u03b2 (forall (a : \u03b1), \u03b4 a) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u_3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u_3} \u03b2 (Semiring.toNonAssocSemiring.{u_3} \u03b2 (CommSemiring.toSemiring.{u_3} \u03b2 _inst_3)))) (Fintype.piFinset.{u_2, u_1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 (fun (a : \u03b1) => \u03b4 a) t) (fun (p : forall (a : \u03b1), \u03b4 a) => Finset.prod.{u_3, u_2} \u03b2 \u03b1 (CommSemiring.toCommMonoid.{u_3} \u03b2 _inst_3) (Finset.univ.{u_2} \u03b1 _inst_2) (fun (x : \u03b1) => f x (p x))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_univ_sum Finset.prod_univ_sum\u2093'. -/\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 \u03b1] [Fintype \u03b1] [CommSemiring \u03b2] {\u03b4 : \u03b1 \u2192 Type u_1}\n    [\u2200 a : \u03b1, DecidableEq (\u03b4 a)] {t : \u2200 a : \u03b1, Finset (\u03b4 a)} {f : \u2200 a : \u03b1, \u03b4 a \u2192 \u03b2} :\n    (\u220f a, \u2211 b in t a, f a b) = \u2211 p in Fintype.piFinset t, \u220f 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 (\u03b1 : Type.{u1}) [_inst_1 : Fintype.{u1} \u03b1] {R : Type.{u2}} [_inst_2 : CommSemiring.{u2} R] (a : R) (b : R), Eq.{succ u2} R (Finset.sum.{u2, u1} R (Finset.{u1} \u03b1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R (CommSemiring.toSemiring.{u2} R _inst_2)))) (Finset.univ.{u1} (Finset.{u1} \u03b1) (Finset.fintype.{u1} \u03b1 _inst_1)) (fun (s : Finset.{u1} \u03b1) => 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} \u03b1 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} \u03b1 _inst_1) (Finset.card.{u1} \u03b1 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} \u03b1 _inst_1))\nbut is expected to have type\n  forall (\u03b1 : Type.{u2}) [_inst_1 : Fintype.{u2} \u03b1] {R : Type.{u1}} [_inst_2 : CommSemiring.{u1} R] (a : R) (b : R), Eq.{succ u1} R (Finset.sum.{u1, u2} R (Finset.{u2} \u03b1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_2)))) (Finset.univ.{u2} (Finset.{u2} \u03b1) (Finset.fintype.{u2} \u03b1 _inst_1)) (fun (s : Finset.{u2} \u03b1) => 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} \u03b1 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} \u03b1 _inst_1) (Finset.card.{u2} \u03b1 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} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align fintype.sum_pow_mul_eq_add_pow Fintype.sum_pow_mul_eq_add_pow\u2093'. -/\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 (\u03b1 : Type _) [Fintype \u03b1] {R : Type _} [CommSemiring R]\n    (a b : R) :\n    (\u2211 s : Finset \u03b1, a ^ s.card * b ^ (Fintype.card \u03b1 - s.card)) = (a + b) ^ Fintype.card \u03b1 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : Fintype.{u2} \u03b2] [_inst_3 : CommMonoid.{u3} \u03b3] {f : \u03b1 -> \u03b2}, (Function.Bijective.{succ u1, succ u2} \u03b1 \u03b2 f) -> (forall (g : \u03b2 -> \u03b3), Eq.{succ u3} \u03b3 (Finset.prod.{u3, u1} \u03b3 \u03b1 _inst_3 (Finset.univ.{u1} \u03b1 _inst_1) (fun (i : \u03b1) => g (f i))) (Finset.prod.{u3, u2} \u03b3 \u03b2 _inst_3 (Finset.univ.{u2} \u03b2 _inst_2) (fun (i : \u03b2) => g i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : Fintype.{u3} \u03b1] [_inst_2 : Fintype.{u2} \u03b2] [_inst_3 : CommMonoid.{u1} \u03b3] {f : \u03b1 -> \u03b2}, (Function.Bijective.{succ u3, succ u2} \u03b1 \u03b2 f) -> (forall (g : \u03b2 -> \u03b3), Eq.{succ u1} \u03b3 (Finset.prod.{u1, u3} \u03b3 \u03b1 _inst_3 (Finset.univ.{u3} \u03b1 _inst_1) (fun (i : \u03b1) => g (f i))) (Finset.prod.{u1, u2} \u03b3 \u03b2 _inst_3 (Finset.univ.{u2} \u03b2 _inst_2) (fun (i : \u03b2) => g i)))\nCase conversion may be inaccurate. Consider using '#align function.bijective.prod_comp Function.Bijective.prod_comp\u2093'. -/\n@[to_additive]\ntheorem Function.Bijective.prod_comp [Fintype \u03b1] [Fintype \u03b2] [CommMonoid \u03b3] {f : \u03b1 \u2192 \u03b2}\n    (hf : Function.Bijective f) (g : \u03b2 \u2192 \u03b3) : (\u220f i, g (f i)) = \u220f 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : Fintype.{u2} \u03b2] [_inst_3 : CommMonoid.{u3} \u03b3] (e : Equiv.{succ u1, succ u2} \u03b1 \u03b2) (f : \u03b2 -> \u03b3), Eq.{succ u3} \u03b3 (Finset.prod.{u3, u1} \u03b3 \u03b1 _inst_3 (Finset.univ.{u1} \u03b1 _inst_1) (fun (i : \u03b1) => f (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Equiv.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) e i))) (Finset.prod.{u3, u2} \u03b3 \u03b2 _inst_3 (Finset.univ.{u2} \u03b2 _inst_2) (fun (i : \u03b2) => f i))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : Fintype.{u3} \u03b1] [_inst_2 : Fintype.{u2} \u03b2] [_inst_3 : CommMonoid.{u1} \u03b3] (e : Equiv.{succ u3, succ u2} \u03b1 \u03b2) (f : \u03b2 -> \u03b3), Eq.{succ u1} \u03b3 (Finset.prod.{u1, u3} \u03b3 \u03b1 _inst_3 (Finset.univ.{u3} \u03b1 _inst_1) (fun (i : \u03b1) => f (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (Equiv.{succ u3, succ u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u3, succ u2} \u03b1 \u03b2) e i))) (Finset.prod.{u1, u2} \u03b3 \u03b2 _inst_3 (Finset.univ.{u2} \u03b2 _inst_2) (fun (i : \u03b2) => f i))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_comp Equiv.prod_comp\u2093'. -/\n@[to_additive]\ntheorem Equiv.prod_comp [Fintype \u03b1] [Fintype \u03b2] [CommMonoid \u03b3] (e : \u03b1 \u2243 \u03b2) (f : \u03b2 \u2192 \u03b3) :\n    (\u220f i, f (e i)) = \u220f 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : Fintype.{u2} \u03b2] [_inst_3 : CommMonoid.{u3} \u03b3] (e : Equiv.{succ u1, succ u2} \u03b1 \u03b2) (f : \u03b1 -> \u03b3) (g : \u03b2 -> \u03b3), (forall (i : \u03b1), Eq.{succ u3} \u03b3 (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} \u03b1 \u03b2) (fun (_x : Equiv.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) e i))) -> (Eq.{succ u3} \u03b3 (Finset.prod.{u3, u1} \u03b3 \u03b1 _inst_3 (Finset.univ.{u1} \u03b1 _inst_1) (fun (i : \u03b1) => f i)) (Finset.prod.{u3, u2} \u03b3 \u03b2 _inst_3 (Finset.univ.{u2} \u03b2 _inst_2) (fun (i : \u03b2) => g i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : Fintype.{u3} \u03b1] [_inst_2 : Fintype.{u2} \u03b2] [_inst_3 : CommMonoid.{u1} \u03b3] (e : Equiv.{succ u3, succ u2} \u03b1 \u03b2) (f : \u03b1 -> \u03b3) (g : \u03b2 -> \u03b3), (forall (i : \u03b1), Eq.{succ u1} \u03b3 (f i) (g (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (Equiv.{succ u3, succ u2} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u3, succ u2} \u03b1 \u03b2) e i))) -> (Eq.{succ u1} \u03b3 (Finset.prod.{u1, u3} \u03b3 \u03b1 _inst_3 (Finset.univ.{u3} \u03b1 _inst_1) (fun (i : \u03b1) => f i)) (Finset.prod.{u1, u2} \u03b3 \u03b2 _inst_3 (Finset.univ.{u2} \u03b2 _inst_2) (fun (i : \u03b2) => g i)))\nCase conversion may be inaccurate. Consider using '#align equiv.prod_comp' Equiv.prod_comp'\u2093'. -/\n@[to_additive]\ntheorem Equiv.prod_comp' [Fintype \u03b1] [Fintype \u03b2] [CommMonoid \u03b3] (e : \u03b1 \u2243 \u03b2) (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3)\n    (h : \u2200 i, f i = g (e i)) : (\u220f i, f i) = \u220f i, g i :=\n  (show f = g \u2218 e from funext h).symm \u25b8 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 \u03b1] (f : \u2115 \u2192 \u03b1) (n : \u2115) :\n    (\u220f i : Fin n, f i) = \u220f i in range n, f i :=\n  calc\n    (\u220f i : Fin n, f i) = \u220f i : { x // x \u2208 range n }, f i :=\n      (Fin.equivSubtype.trans (Equiv.subtypeEquivRight (by simp))).prod_comp' _ _ (by simp)\n    _ = \u220f i in range n, f i := by rw [\u2190 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 {\u03b2 : Type.{u1}} [_inst_1 : CommMonoid.{u1} \u03b2] {n : Nat} (c : (Fin n) -> \u03b2), Eq.{succ u1} \u03b2 (Finset.prod.{u1, 0} \u03b2 (Fin n) _inst_1 (Finset.univ.{0} (Fin n) (Fin.fintype n)) (fun (i : Fin n) => c i)) (Finset.prod.{u1, 0} \u03b2 Nat _inst_1 (Finset.range n) (fun (i : Nat) => dite.{succ u1} \u03b2 (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} \u03b2 1 (OfNat.mk.{u1} \u03b2 1 (One.one.{u1} \u03b2 (MulOneClass.toHasOne.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (CommMonoid.toMonoid.{u1} \u03b2 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} [_inst_1 : CommMonoid.{u1} \u03b2] {n : Nat} (c : (Fin n) -> \u03b2), Eq.{succ u1} \u03b2 (Finset.prod.{u1, 0} \u03b2 (Fin n) _inst_1 (Finset.univ.{0} (Fin n) (Fin.fintype n)) (fun (i : Fin n) => c i)) (Finset.prod.{u1, 0} \u03b2 Nat _inst_1 (Finset.range n) (fun (i : Nat) => dite.{succ u1} \u03b2 (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} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (Monoid.toOne.{u1} \u03b2 (CommMonoid.toMonoid.{u1} \u03b2 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_fin_eq_prod_range Finset.prod_fin_eq_prod_range\u2093'. -/\n@[to_additive]\ntheorem Finset.prod_fin_eq_prod_range [CommMonoid \u03b2] {n : \u2115} (c : Fin n \u2192 \u03b2) :\n    (\u220f i, c i) = \u220f i in Finset.range n, if h : i < n then c \u27e8i, h\u27e9 else 1 :=\n  by\n  rw [\u2190 Fin.prod_univ_eq_prod_range, Finset.prod_congr rfl]\n  rintro \u27e8i, hi\u27e9 _\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 \u03b1] (p : \u03b1 \u2192 Prop)\n    [DecidablePred p] (f : \u03b1 \u2192 M) : (\u220f a in { x | p x }.toFinset, f a) = \u220f a : Subtype p, f a :=\n  by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : DecidableEq.{succ u2} \u03b2] [_inst_2 : Fintype.{u2} \u03b2] [_inst_3 : CommMonoid.{u3} \u03b3] (s : Finset.{u1} \u03b1) (f : \u03b1 -> \u03b2) (g : \u03b1 -> \u03b3), Eq.{succ u3} \u03b3 (Finset.prod.{u3, u2} \u03b3 \u03b2 _inst_3 (Finset.univ.{u2} \u03b2 _inst_2) (fun (b : \u03b2) => Finset.prod.{u3, u1} \u03b3 \u03b1 _inst_3 (Finset.filter.{u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b) (fun (a : \u03b1) => _inst_1 (f a) b) s) (fun (a : \u03b1) => g a))) (Finset.prod.{u3, u1} \u03b3 \u03b1 _inst_3 s (fun (a : \u03b1) => g a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : DecidableEq.{succ u3} \u03b2] [_inst_2 : Fintype.{u3} \u03b2] [_inst_3 : CommMonoid.{u2} \u03b3] (s : Finset.{u1} \u03b1) (f : \u03b1 -> \u03b2) (g : \u03b1 -> \u03b3), Eq.{succ u2} \u03b3 (Finset.prod.{u2, u3} \u03b3 \u03b2 _inst_3 (Finset.univ.{u3} \u03b2 _inst_2) (fun (b : \u03b2) => Finset.prod.{u2, u1} \u03b3 \u03b1 _inst_3 (Finset.filter.{u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u3} \u03b2 (f a) b) (fun (a : \u03b1) => _inst_1 (f a) b) s) (fun (a : \u03b1) => g a))) (Finset.prod.{u2, u1} \u03b3 \u03b1 _inst_3 s (fun (a : \u03b1) => g a))\nCase conversion may be inaccurate. Consider using '#align finset.prod_fiberwise Finset.prod_fiberwise\u2093'. -/\n@[to_additive]\ntheorem Finset.prod_fiberwise [DecidableEq \u03b2] [Fintype \u03b2] [CommMonoid \u03b3] (s : Finset \u03b1) (f : \u03b1 \u2192 \u03b2)\n    (g : \u03b1 \u2192 \u03b3) : (\u220f b : \u03b2, \u220f a in s.filter\u2093 fun a => f a = b, g a) = \u220f 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] [_inst_3 : Fintype.{u2} \u03b2] [_inst_4 : CommMonoid.{u3} \u03b3] (f : \u03b1 -> \u03b2) (g : \u03b1 -> \u03b3), Eq.{succ u3} \u03b3 (Finset.prod.{u3, u2} \u03b3 \u03b2 _inst_4 (Finset.univ.{u2} \u03b2 _inst_3) (fun (b : \u03b2) => Finset.prod.{u3, u1} \u03b3 (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) _inst_4 (Finset.univ.{u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) (Subtype.fintype.{u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b) (fun (a : \u03b1) => _inst_2 (f a) b) _inst_1)) (fun (a : Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) => g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) \u03b1 (coeBase.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b))))) a)))) (Finset.prod.{u3, u1} \u03b3 \u03b1 _inst_4 (Finset.univ.{u1} \u03b1 _inst_1) (fun (a : \u03b1) => g a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : Fintype.{u3} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] [_inst_3 : Fintype.{u2} \u03b2] [_inst_4 : CommMonoid.{u1} \u03b3] (f : \u03b1 -> \u03b2) (g : \u03b1 -> \u03b3), Eq.{succ u1} \u03b3 (Finset.prod.{u1, u2} \u03b3 \u03b2 _inst_4 (Finset.univ.{u2} \u03b2 _inst_3) (fun (b : \u03b2) => Finset.prod.{u1, u3} \u03b3 (Subtype.{succ u3} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) _inst_4 (Finset.univ.{u3} (Subtype.{succ u3} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) (Subtype.fintype.{u3} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b) (fun (a : \u03b1) => _inst_2 (f a) b) _inst_1)) (fun (a : Subtype.{succ u3} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b)) => g (Subtype.val.{succ u3} \u03b1 (fun (a : \u03b1) => Eq.{succ u2} \u03b2 (f a) b) a)))) (Finset.prod.{u1, u3} \u03b3 \u03b1 _inst_4 (Finset.univ.{u3} \u03b1 _inst_1) (fun (a : \u03b1) => g a))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_fiberwise Fintype.prod_fiberwise\u2093'. -/\n@[to_additive]\ntheorem Fintype.prod_fiberwise [Fintype \u03b1] [DecidableEq \u03b2] [Fintype \u03b2] [CommMonoid \u03b3] (f : \u03b1 \u2192 \u03b2)\n    (g : \u03b1 \u2192 \u03b3) : (\u220f b : \u03b2, \u220f a : { a // f a = b }, g (a : \u03b1)) = \u220f a, g a :=\n  by\n  rw [\u2190 (Equiv.sigmaFiberEquiv f).prod_comp, \u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] {p : \u03b1 -> Prop} [_inst_2 : DecidablePred.{succ u1} \u03b1 p] [_inst_3 : CommMonoid.{u2} \u03b2] (f : forall (a : \u03b1), (p a) -> \u03b2) (g : forall (a : \u03b1), (Not (p a)) -> \u03b2), Eq.{succ u2} \u03b2 (Finset.prod.{u2, u1} \u03b2 \u03b1 _inst_3 (Finset.univ.{u1} \u03b1 _inst_1) (fun (a : \u03b1) => dite.{succ u2} \u03b2 (p a) (_inst_2 a) (f a) (g a))) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (CommMonoid.toMonoid.{u2} \u03b2 _inst_3)))) (Finset.prod.{u2, u1} \u03b2 (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => p a)) _inst_3 (Finset.univ.{u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.fintype.{u1} \u03b1 (fun (a : \u03b1) => p a) (fun (a : \u03b1) => _inst_2 a) _inst_1)) (fun (a : Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => p a)) => f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeBase.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => p a)) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (a : \u03b1) => p a))))) a) (Subtype.property.{succ u1} \u03b1 (fun (a : \u03b1) => p a) a))) (Finset.prod.{u2, u1} \u03b2 (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a))) _inst_3 (Finset.univ.{u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a))) (Subtype.fintype.{u1} \u03b1 (fun (a : \u03b1) => Not (p a)) (fun (a : \u03b1) => Not.decidable (p a) (_inst_2 a)) _inst_1)) (fun (a : Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a))) => g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a))) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a))) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a))) \u03b1 (coeBase.{succ u1, succ u1} (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a))) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a)))))) a) (Subtype.property.{succ u1} \u03b1 (fun (a : \u03b1) => Not (p a)) a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] {p : \u03b1 -> Prop} [_inst_2 : DecidablePred.{succ u2} \u03b1 p] [_inst_3 : CommMonoid.{u1} \u03b2] (f : forall (a : \u03b1), (p a) -> \u03b2) (g : forall (a : \u03b1), (Not (p a)) -> \u03b2), Eq.{succ u1} \u03b2 (Finset.prod.{u1, u2} \u03b2 \u03b1 _inst_3 (Finset.univ.{u2} \u03b1 _inst_1) (fun (a : \u03b1) => dite.{succ u1} \u03b2 (p a) (_inst_2 a) (f a) (g a))) (HMul.hMul.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (CommMonoid.toMonoid.{u1} \u03b2 _inst_3)))) (Finset.prod.{u1, u2} \u03b2 (Subtype.{succ u2} \u03b1 (fun (a : \u03b1) => p a)) _inst_3 (Finset.univ.{u2} (Subtype.{succ u2} \u03b1 (fun (a : \u03b1) => p a)) (Subtype.fintype.{u2} \u03b1 (fun (a : \u03b1) => p a) (fun (a : \u03b1) => _inst_2 a) _inst_1)) (fun (a : Subtype.{succ u2} \u03b1 (fun (a : \u03b1) => p a)) => f (Subtype.val.{succ u2} \u03b1 (fun (a : \u03b1) => p a) a) (Subtype.property.{succ u2} \u03b1 (fun (a : \u03b1) => p a) a))) (Finset.prod.{u1, u2} \u03b2 (Subtype.{succ u2} \u03b1 (fun (a : \u03b1) => Not (p a))) _inst_3 (Finset.univ.{u2} (Subtype.{succ u2} \u03b1 (fun (a : \u03b1) => Not (p a))) (Subtype.fintype.{u2} \u03b1 (fun (a : \u03b1) => Not (p a)) (fun (a : \u03b1) => instDecidableNot (p a) (_inst_2 a)) _inst_1)) (fun (a : Subtype.{succ u2} \u03b1 (fun (a : \u03b1) => Not (p a))) => g (Subtype.val.{succ u2} \u03b1 (fun (a : \u03b1) => Not (p a)) a) (Subtype.property.{succ u2} \u03b1 (fun (a : \u03b1) => Not (p a)) a))))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_dite Fintype.prod_dite\u2093'. -/\ntheorem Fintype.prod_dite [Fintype \u03b1] {p : \u03b1 \u2192 Prop} [DecidablePred p] [CommMonoid \u03b2]\n    (f : \u2200 (a : \u03b1) (ha : p a), \u03b2) (g : \u2200 (a : \u03b1) (ha : \u00acp a), \u03b2) :\n    (\u220f a, dite (p a) (f a) (g a)) = (\u220f a : { a // p a }, f a a.2) * \u220f a : { a // \u00acp a }, g a a.2 :=\n  by\n  simp only [prod_dite, attach_eq_univ]\n  congr 1\n  \u00b7 convert(Equiv.subtypeEquivRight _).prod_comp fun x : { x // p x } => f x x.2\n    simp\n  \u00b7 convert(Equiv.subtypeEquivRight _).prod_comp fun x : { x // \u00acp x } => g x x.2\n    simp\n#align fintype.prod_dite Fintype.prod_dite\n\nsection\n\nopen Finset\n\nvariable {\u03b1\u2081 : Type _} {\u03b1\u2082 : Type _} {M : Type _} [Fintype \u03b1\u2081] [Fintype \u03b1\u2082] [CommMonoid M]\n\n/- warning: fintype.prod_sum_elim -> Fintype.prod_sum_elim is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1\u2081 : Type.{u1}} {\u03b1\u2082 : Type.{u2}} {M : Type.{u3}} [_inst_1 : Fintype.{u1} \u03b1\u2081] [_inst_2 : Fintype.{u2} \u03b1\u2082] [_inst_3 : CommMonoid.{u3} M] (f : \u03b1\u2081 -> M) (g : \u03b1\u2082 -> M), Eq.{succ u3} M (Finset.prod.{u3, max u1 u2} M (Sum.{u1, u2} \u03b1\u2081 \u03b1\u2082) _inst_3 (Finset.univ.{max u1 u2} (Sum.{u1, u2} \u03b1\u2081 \u03b1\u2082) (Sum.fintype.{u1, u2} \u03b1\u2081 \u03b1\u2082 _inst_1 _inst_2)) (fun (x : Sum.{u1, u2} \u03b1\u2081 \u03b1\u2082) => Sum.elim.{u1, u2, succ u3} \u03b1\u2081 \u03b1\u2082 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 \u03b1\u2081 _inst_3 (Finset.univ.{u1} \u03b1\u2081 _inst_1) (fun (a\u2081 : \u03b1\u2081) => f a\u2081)) (Finset.prod.{u3, u2} M \u03b1\u2082 _inst_3 (Finset.univ.{u2} \u03b1\u2082 _inst_2) (fun (a\u2082 : \u03b1\u2082) => g a\u2082)))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u2}} {\u03b1\u2082 : Type.{u1}} {M : Type.{u3}} [_inst_1 : Fintype.{u2} \u03b1\u2081] [_inst_2 : Fintype.{u1} \u03b1\u2082] [_inst_3 : CommMonoid.{u3} M] (f : \u03b1\u2081 -> M) (g : \u03b1\u2082 -> M), Eq.{succ u3} M (Finset.prod.{u3, max u2 u1} M (Sum.{u2, u1} \u03b1\u2081 \u03b1\u2082) _inst_3 (Finset.univ.{max u2 u1} (Sum.{u2, u1} \u03b1\u2081 \u03b1\u2082) (instFintypeSum.{u2, u1} \u03b1\u2081 \u03b1\u2082 _inst_1 _inst_2)) (fun (x : Sum.{u2, u1} \u03b1\u2081 \u03b1\u2082) => Sum.elim.{u2, u1, succ u3} \u03b1\u2081 \u03b1\u2082 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 \u03b1\u2081 _inst_3 (Finset.univ.{u2} \u03b1\u2081 _inst_1) (fun (a\u2081 : \u03b1\u2081) => f a\u2081)) (Finset.prod.{u3, u1} M \u03b1\u2082 _inst_3 (Finset.univ.{u1} \u03b1\u2082 _inst_2) (fun (a\u2082 : \u03b1\u2082) => g a\u2082)))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_sum_elim Fintype.prod_sum_elim\u2093'. -/\n@[to_additive]\ntheorem Fintype.prod_sum_elim (f : \u03b1\u2081 \u2192 M) (g : \u03b1\u2082 \u2192 M) :\n    (\u220f x, Sum.elim f g x) = (\u220f a\u2081, f a\u2081) * \u220f a\u2082, g a\u2082 :=\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 {\u03b1\u2081 : Type.{u1}} {\u03b1\u2082 : Type.{u2}} {M : Type.{u3}} [_inst_1 : Fintype.{u1} \u03b1\u2081] [_inst_2 : Fintype.{u2} \u03b1\u2082] [_inst_3 : CommMonoid.{u3} M] (f : (Sum.{u1, u2} \u03b1\u2081 \u03b1\u2082) -> M), Eq.{succ u3} M (Finset.prod.{u3, max u1 u2} M (Sum.{u1, u2} \u03b1\u2081 \u03b1\u2082) _inst_3 (Finset.univ.{max u1 u2} (Sum.{u1, u2} \u03b1\u2081 \u03b1\u2082) (Sum.fintype.{u1, u2} \u03b1\u2081 \u03b1\u2082 _inst_1 _inst_2)) (fun (x : Sum.{u1, u2} \u03b1\u2081 \u03b1\u2082) => 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 \u03b1\u2081 _inst_3 (Finset.univ.{u1} \u03b1\u2081 _inst_1) (fun (a\u2081 : \u03b1\u2081) => f (Sum.inl.{u1, u2} \u03b1\u2081 \u03b1\u2082 a\u2081))) (Finset.prod.{u3, u2} M \u03b1\u2082 _inst_3 (Finset.univ.{u2} \u03b1\u2082 _inst_2) (fun (a\u2082 : \u03b1\u2082) => f (Sum.inr.{u1, u2} \u03b1\u2081 \u03b1\u2082 a\u2082))))\nbut is expected to have type\n  forall {\u03b1\u2081 : Type.{u3}} {\u03b1\u2082 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Fintype.{u3} \u03b1\u2081] [_inst_2 : Fintype.{u2} \u03b1\u2082] [_inst_3 : CommMonoid.{u1} M] (f : (Sum.{u3, u2} \u03b1\u2081 \u03b1\u2082) -> M), Eq.{succ u1} M (Finset.prod.{u1, max u3 u2} M (Sum.{u3, u2} \u03b1\u2081 \u03b1\u2082) _inst_3 (Finset.univ.{max u3 u2} (Sum.{u3, u2} \u03b1\u2081 \u03b1\u2082) (instFintypeSum.{u3, u2} \u03b1\u2081 \u03b1\u2082 _inst_1 _inst_2)) (fun (x : Sum.{u3, u2} \u03b1\u2081 \u03b1\u2082) => 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 \u03b1\u2081 _inst_3 (Finset.univ.{u3} \u03b1\u2081 _inst_1) (fun (a\u2081 : \u03b1\u2081) => f (Sum.inl.{u3, u2} \u03b1\u2081 \u03b1\u2082 a\u2081))) (Finset.prod.{u1, u2} M \u03b1\u2082 _inst_3 (Finset.univ.{u2} \u03b1\u2082 _inst_2) (fun (a\u2082 : \u03b1\u2082) => f (Sum.inr.{u3, u2} \u03b1\u2081 \u03b1\u2082 a\u2082))))\nCase conversion may be inaccurate. Consider using '#align fintype.prod_sum_type Fintype.prod_sum_type\u2093'. -/\n@[simp, to_additive]\ntheorem Fintype.prod_sum_type (f : Sum \u03b1\u2081 \u03b1\u2082 \u2192 M) :\n    (\u220f x, f x) = (\u220f a\u2081, f (Sum.inl a\u2081)) * \u220f a\u2082, f (Sum.inr a\u2082) :=\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 : \u03b1`.\n-/\nunsafe structure context where\n  red : Transparency\n  \u03b1 : expr\n  univ : level\n  \u03b10 : 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 \u03b1 \u2190 infer_type e\n  let c \u2190 mk_app `` AddCommMonoid [\u03b1] >>= mk_instance\n  let cg \u2190 try_core (mk_app `` AddCommGroup [\u03b1] >>= mk_instance)\n  let u \u2190 mk_meta_univ\n  infer_type \u03b1 >>= unify (expr.sort (level.succ u))\n  let u \u2190 get_univ_assignment u\n  let \u03b10 \u2190 expr.of_nat \u03b1 0\n  match cg with\n    | some cg => return \u27e8red, \u03b1, u, \u03b10, tt, cg\u27e9\n    | _ => return \u27e8red, \u03b1, u, \u03b10, ff, c\u27e9\n#align tactic.abel.mk_context tactic.abel.mk_context\n\n/-- Apply the function `n : \u2200 {\u03b1} [inst : add_whatever \u03b1], _` 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 \u2192 expr :=\n  (@expr.const true n [c.univ] c.\u03b1 inst).mk_app\n#align tactic.abel.context.app tactic.abel.context.app\n\n/-- Apply the function `n : \u2200 {\u03b1} [inst \u03b1], _` 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 \u2190 mk_instance ((expr.const inst [c.univ] : expr) c.\u03b1)\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 \u2192 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 : \u2200 {\u03b1} [add_comm_{monoid,group} \u03b1]` 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 \u2192 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 {\u03b1} [AddCommMonoid \u03b1] (n : \u2115) (x a : \u03b1) : \u03b1 :=\n  n \u2022 x + a\n#align tactic.abel.term Tactic.Abel.term\n\ndef termg {\u03b1} [AddCommGroup \u03b1] (n : \u2124) (x a : \u03b1) : \u03b1 :=\n  n \u2022 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 : \u2124) : tactic expr :=\n  expr.of_int (if c.is_group then q(\u2124) else q(\u2115)) 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 \u00d7 \u2124) (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 \u2192 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  \u27e8normal_expr.e\u27e9\n\nunsafe instance : CoeFun normal_expr fun _ => expr \u2192 expr :=\n  \u27e8fun e => \u21d1(e : expr)\u27e9\n\nunsafe def normal_expr.term' (c : context) (n : expr \u00d7 \u2124) (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.\u03b10\n#align tactic.abel.normal_expr.zero' tactic.abel.normal_expr.zero'\n\nunsafe def normal_expr.to_list : normal_expr \u2192 List (\u2124 \u00d7 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 \u27e8n, e\u27e9 => toString n ++ \" \u2022 (\" ++ 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 \u2190\n    (to_list e).mapM fun \u27e8n, e\u27e9 => do\n        let pe \u2190 pp e\n        return (to_fmt n ++ \" \u2022 (\" ++ pe ++ \")\")\n  return <| format.join <| l \u2191\" + \"\n#align tactic.abel.normal_expr.pp tactic.abel.normal_expr.pp\n\nunsafe instance : has_to_tactic_format normal_expr :=\n  \u27e8normal_expr.pp\u27e9\n\nunsafe def normal_expr.refl_conv (e : normal_expr) : tactic (normal_expr \u00d7 expr) := do\n  let p \u2190 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 {\u03b1} [AddCommMonoid \u03b1] (k n x a a') (h : k + a = a') :\n    k + @term \u03b1 _ 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 {\u03b1} [AddCommGroup \u03b1] (k n x a a') (h : k + a = a') :\n    k + @termg \u03b1 _ 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 {\u03b1} [AddCommMonoid \u03b1] (n x a k a') (h : a + k = a') :\n    @term \u03b1 _ 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 {\u03b1} [AddCommGroup \u03b1] (n x a k a') (h : a + k = a') :\n    @termg \u03b1 _ 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 {\u03b1} [AddCommMonoid \u03b1] (n\u2081 x a\u2081 n\u2082 a\u2082 n' a') (h\u2081 : n\u2081 + n\u2082 = n')\n    (h\u2082 : a\u2081 + a\u2082 = a') : @term \u03b1 _ n\u2081 x a\u2081 + @term \u03b1 _ n\u2082 x a\u2082 = term n' x a' := by\n  simp [h\u2081.symm, h\u2082.symm, term, add_nsmul] <;> ac_rfl\n#align tactic.abel.term_add_term Tactic.Abel.term_add_term\n\ntheorem term_add_termg {\u03b1} [AddCommGroup \u03b1] (n\u2081 x a\u2081 n\u2082 a\u2082 n' a') (h\u2081 : n\u2081 + n\u2082 = n')\n    (h\u2082 : a\u2081 + a\u2082 = a') : @termg \u03b1 _ n\u2081 x a\u2081 + @termg \u03b1 _ n\u2082 x a\u2082 = termg n' x a' := by\n  simp [h\u2081.symm, h\u2082.symm, termg, add_zsmul] <;> ac_rfl\n#align tactic.abel.term_add_termg Tactic.Abel.term_add_termg\n\ntheorem zero_term {\u03b1} [AddCommMonoid \u03b1] (x a) : @term \u03b1 _ 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 {\u03b1} [AddCommGroup \u03b1] (x a) : @termg \u03b1 _ 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 \u2192 normal_expr \u2192 tactic (normal_expr \u00d7 expr)\n  | zero _, e\u2082 => do\n    let p \u2190 mk_app `` zero_add [e\u2082]\n    return (e\u2082, p)\n  | e\u2081, zero _ => do\n    let p \u2190 mk_app `` add_zero [e\u2081]\n    return (e\u2081, p)\n  | he\u2081@(nterm e\u2081 n\u2081 x\u2081 a\u2081), he\u2082@(nterm e\u2082 n\u2082 x\u2082 a\u2082) =>\n    (do\n        is_def_eq x\u2081 x\u2082 c\n        let (n', h\u2081) \u2190 mk_app `` Add.add [n\u2081.1, n\u2082.1] >>= norm_num.eval_field\n        let (a', h\u2082) \u2190 eval_add a\u2081 a\u2082\n        let k := n\u2081.2 + n\u2082.2\n        let p\u2081 := c.iapp `` term_add_term [n\u2081.1, x\u2081, a\u2081, n\u2082.1, a\u2082, n', a', h\u2081, h\u2082]\n        if k = 0 then do\n            let p \u2190 mk_eq_trans p\u2081 (c `` zero_term [x\u2081, a'])\n            return (a', p)\n          else return (term' c (n', k) x\u2081 a', p\u2081)) <|>\n      if expr.lex_lt x\u2081 x\u2082 then do\n        let (a', h) \u2190 eval_add a\u2081 he\u2082\n        return (term' c n\u2081 x\u2081 a', c `` term_add_const [n\u2081.1, x\u2081, a\u2081, e\u2082, a', h])\n      else do\n        let (a', h) \u2190 eval_add he\u2081 a\u2082\n        return (term' c n\u2082 x\u2082 a', c `` const_add_term [e\u2081, n\u2082.1, x\u2082, a\u2082, a', h])\n#align tactic.abel.eval_add tactic.abel.eval_add\n\ntheorem term_neg {\u03b1} [AddCommGroup \u03b1] (n x a n' a') (h\u2081 : -n = n') (h\u2082 : -a = a') :\n    -@termg \u03b1 _ n x a = termg n' x a' := by simp [h\u2082.symm, h\u2081.symm, termg] <;> ac_rfl\n#align tactic.abel.term_neg Tactic.Abel.term_neg\n\nunsafe def eval_neg (c : context) : normal_expr \u2192 tactic (normal_expr \u00d7 expr)\n  | zero e => do\n    let p \u2190 c.mk_app `` neg_zero `` NegZeroClass []\n    return (zero' c, p)\n  | nterm e n x a => do\n    let (n', h\u2081) \u2190 mk_app `` Neg.neg [n.1] >>= norm_num.eval_field\n    let (a', h\u2082) \u2190 eval_neg a\n    return (term' c (n', -n.2) x a', c `` term_neg c [n.1, x, a, n', a', h\u2081, h\u2082])\n#align tactic.abel.eval_neg tactic.abel.eval_neg\n\ndef natSmulInst {\u03b1} [AddCommMonoid \u03b1] : SMul \u2115 \u03b1 := by infer_instance\n#align tactic.abel.nat_smul_inst Tactic.Abel.natSmulInst\n\ndef natSmulInstg {\u03b1} [AddCommGroup \u03b1] : SMul \u2115 \u03b1 := by infer_instance\n#align tactic.abel.nat_smul_instg Tactic.Abel.natSmulInstg\n\ndef intSmulInstg {\u03b1} [AddCommGroup \u03b1] : SMul \u2124 \u03b1 := by infer_instance\n#align tactic.abel.int_smul_instg Tactic.Abel.intSmulInstg\n\ndef smul {\u03b1} [AddCommMonoid \u03b1] (n : \u2115) (x : \u03b1) : \u03b1 :=\n  n \u2022 x\n#align tactic.abel.smul Tactic.Abel.smul\n\ndef smulg {\u03b1} [AddCommGroup \u03b1] (n : \u2124) (x : \u03b1) : \u03b1 :=\n  n \u2022 x\n#align tactic.abel.smulg Tactic.Abel.smulg\n\ntheorem zero_smul {\u03b1} [AddCommMonoid \u03b1] (c) : smul c (0 : \u03b1) = 0 := by simp [smul, nsmul_zero]\n#align tactic.abel.zero_smul Tactic.Abel.zero_smul\n\ntheorem zero_smulg {\u03b1} [AddCommGroup \u03b1] (c) : smulg c (0 : \u03b1) = 0 := by simp [smulg, zsmul_zero]\n#align tactic.abel.zero_smulg Tactic.Abel.zero_smulg\n\ntheorem term_smul {\u03b1} [AddCommMonoid \u03b1] (c n x a n' a') (h\u2081 : c * n = n') (h\u2082 : smul c a = a') :\n    smul c (@term \u03b1 _ n x a) = term n' x a' := by\n  simp [h\u2082.symm, h\u2081.symm, term, smul, nsmul_add, mul_nsmul']\n#align tactic.abel.term_smul Tactic.Abel.term_smul\n\ntheorem term_smulg {\u03b1} [AddCommGroup \u03b1] (c n x a n' a') (h\u2081 : c * n = n') (h\u2082 : smulg c a = a') :\n    smulg c (@termg \u03b1 _ n x a) = termg n' x a' := by\n  simp [h\u2082.symm, h\u2081.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 \u00d7 \u2124) : normal_expr \u2192 tactic (normal_expr \u00d7 expr)\n  | zero _ => return (zero' c, c.iapp `` zero_smul [k.1])\n  | nterm e n x a => do\n    let (n', h\u2081) \u2190 mk_app `` Mul.mul [k.1, n.1] >>= norm_num.eval_field\n    let (a', h\u2082) \u2190 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\u2081, h\u2082])\n#align tactic.abel.eval_smul tactic.abel.eval_smul\n\ntheorem term_atom {\u03b1} [AddCommMonoid \u03b1] (x : \u03b1) : x = term 1 x 0 := by simp [term]\n#align tactic.abel.term_atom Tactic.Abel.term_atom\n\ntheorem term_atomg {\u03b1} [AddCommGroup \u03b1] (x : \u03b1) : 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 \u00d7 expr) := do\n  let n1 \u2190 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 {\u03b1} [SubtractionMonoid \u03b1] (a b c : \u03b1) (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 {\u03b1} [AddCommMonoid \u03b1] (n) (x y : \u03b1) (h : smul n x = y) : n \u2022 x = y :=\n  h\n#align tactic.abel.unfold_smul Tactic.Abel.unfold_smul\n\ntheorem unfold_smulg {\u03b1} [AddCommGroup \u03b1] (n : \u2115) (x y : \u03b1) (h : smulg (Int.ofNat n) x = y) :\n    (n : \u2124) \u2022 x = y :=\n  h\n#align tactic.abel.unfold_smulg Tactic.Abel.unfold_smulg\n\ntheorem unfold_zsmul {\u03b1} [AddCommGroup \u03b1] (n : \u2124) (x y : \u03b1) (h : smulg n x = y) : n \u2022 x = y :=\n  h\n#align tactic.abel.unfold_zsmul Tactic.Abel.unfold_zsmul\n\ntheorem subst_into_smul {\u03b1} [AddCommMonoid \u03b1] (l r tl tr t) (prl : l = tl) (prr : r = tr)\n    (prt : @smul \u03b1 _ 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 {\u03b1} [AddCommGroup \u03b1] (l r tl tr t) (prl : l = tl) (prr : r = tr)\n    (prt : @smulg \u03b1 _ 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 {\u03b1} [AddCommGroup \u03b1] (l r tl zl tr t) (prl\u2081 : l = tl)\n    (prl\u2082 : \u2191tl = zl) (prr : r = tr) (prt : @smulg \u03b1 _ zl tr = t) : smul l r = t := by\n  simp [\u2190 prt, prl\u2081, \u2190 prl\u2082, 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\u2081 e\u2082` or `smulg e\u2081 e\u2082`.\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 \u2191a 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 \u2192 tactic (normal_expr \u00d7 expr)) (is_smulg : Bool)\n    (orig e\u2081 e\u2082 : expr) : tactic (normal_expr \u00d7 expr) := do\n  let (e\u2081', p\u2081) \u2190 norm_num.derive e\u2081 <|> refl_conv e\u2081\n  match if is_smulg then e\u2081' else coe <$> e\u2081' with\n    | some n => do\n      let (e\u2082', p\u2082) \u2190 eval e\u2082\n      if c = is_smulg then do\n          let (e', p) \u2190 eval_smul c (e\u2081', n) e\u2082'\n          return (e', c `` subst_into_smul [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p])\n        else do\n          guardb c\n          let ic \u2190 mk_instance_cache q(\u2124)\n          let nc \u2190 mk_instance_cache q(\u2115)\n          let (ic, zl) \u2190 ic n\n          let (_, _, _, p\u2081') \u2190 norm_num.prove_nat_uncast ic nc zl\n          let (e', p) \u2190 eval_smul c (zl, n) e\u2082'\n          return (e', c `` subst_into_smul_upcast c [e\u2081, e\u2082, e\u2081', zl, e\u2082', e', p\u2081, p\u2081', p\u2082, 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 \u2192 tactic ( normal_expr \u00d7 expr )\n    |\n        q( $ ( e\u2081 ) + $ ( e\u2082 ) )\n        =>\n        do\n          let ( e\u2081' , p\u2081 ) \u2190 eval e\u2081\n            let ( e\u2082' , p\u2082 ) \u2190 eval e\u2082\n            let ( e' , p' ) \u2190 eval_add c e\u2081' e\u2082'\n            let\n              p\n                \u2190\n                c . mk_app\n                  ` ` NormNum.subst_into_add ` ` Add [ e\u2081 , e\u2082 , e\u2081' , e\u2082' , e' , p\u2081 , p\u2082 , p' ]\n            return ( e' , p )\n      |\n        q( $ ( e\u2081 ) - $ ( e\u2082 ) )\n        =>\n        do\n          let e\u2082' \u2190 mk_app ` ` Neg.neg [ e\u2082 ]\n            let e \u2190 mk_app ` ` Add.add [ e\u2081 , e\u2082' ]\n            let ( e' , p ) \u2190 eval e\n            let p' \u2190 c . mk_app ` ` unfold_sub ` ` SubtractionMonoid [ e\u2081 , e\u2082 , e' , p ]\n            return ( e' , p' )\n      |\n        q( - $ ( e ) )\n        =>\n        do\n          let ( e\u2081 , p\u2081 ) \u2190 eval e\n            let ( e\u2082 , p\u2082 ) \u2190 eval_neg c e\u2081\n            let p \u2190 c . mk_app ` ` NormNum.subst_into_neg ` ` Neg [ e , e\u2081 , e\u2082 , p\u2081 , p\u2082 ]\n            return ( e\u2082 , p )\n      |\n        q( AddMonoid.nsmul $ ( e\u2081 ) $ ( e\u2082 ) )\n        =>\n        do\n          let n \u2190 if c . is_group then mk_app ` ` Int.ofNat [ e\u2081 ] else return e\u2081\n            let ( e' , p ) \u2190 eval <| c . iapp ` ` smul [ n , e\u2082 ]\n            return ( e' , c ` ` unfold_smul [ e\u2081 , e\u2082 , e' , p ] )\n      |\n        q( SubNegMonoid.zsmul $ ( e\u2081 ) $ ( e\u2082 ) )\n        =>\n        do\n          guardb c\n            let ( e' , p ) \u2190 eval <| c . iapp ` ` smul [ e\u2081 , e\u2082 ]\n            return ( e' , c ` ` unfold_zsmul c [ e\u2081 , e\u2082 , e' , p ] )\n      |\n        e @ q( @ SMul.smul Nat $ ( \u03b1 ) $ ( inst ) $ ( e\u2081 ) $ ( e\u2082 ) )\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\u2081 e\u2082 )\n                ( eval_atom c e )\n      |\n        e @ q( @ SMul.smul Int $ ( \u03b1 ) $ ( inst ) $ ( e\u2081 ) $ ( e\u2082 ) )\n        =>\n        do\n          let tt \u2190 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\u2081 e\u2082 )\n                ( eval_atom c e )\n      | e @ q( smul $ ( e\u2081 ) $ ( e\u2082 ) ) => eval_smul' c eval false e e\u2081 e\u2082\n      | e @ q( smulg $ ( e\u2081 ) $ ( e\u2082 ) ) => eval_smul' c eval true e e\u2081 e\u2082\n      |\n        e @ q( @ Zero.zero _ _ )\n        =>\n        condM\n          ( succeeds ( is_def_eq e c . \u03b10 ) )\n            ( mk_eq_refl c . \u03b10 >>= 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 \u00d7 expr) := do\n  let (e', p) \u2190 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  \u27e8NormalizeMode.term\u27e9\n\nunsafe def normalize (red : Transparency) (mode := NormalizeMode.term) (e : expr) :\n    tactic (expr \u00d7 expr) := do\n  let pow_lemma \u2190 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 \u2190 lemmas.foldlM simp_lemmas.add_simp simp_lemmas.mk\n  let (_, e', pr) \u2190\n    ext_simplify_core () { } simp_lemmas.mk (fun _ => failed)\n        (fun _ _ _ _ e => do\n          let c \u2190 mk_context red e\n          let (new_e, pr) \u2190\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, _) \u2190 simplify lemmas [] e\n                    return (e', prf))\n                e\n          guard \u00acnew_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\u2081 ) = $ ( e\u2082 ) ) \u2190 target\n          let c \u2190 mk_context ( if red . isSome then semireducible else reducible ) e\u2081\n          let ( e\u2081' , p\u2081 ) \u2190 eval c e\u2081\n          let ( e\u2082' , p\u2082 ) \u2190 eval c e\u2082\n          is_def_eq e\u2081' e\u2082'\n          let p \u2190 mk_eq_symm p\u2082 >>= mk_eq_trans p\u2081\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 \u2190 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 {\u03b1 : Type*} {a b : \u03b1} [add_comm_monoid \u03b1] : a + (b + a) = a + a + b := by abel\nexample {\u03b1 : Type*} {a b : \u03b1} [add_comm_group \u03b1] : (a + b) - ((b + a) + a) = -a := by abel\nexample {\u03b1 : Type*} {a b : \u03b1} [add_comm_group \u03b1] (hyp : a + a - a = b - b) : a = 0 :=\nby { abel at hyp, exact hyp }\nexample {\u03b1 : Type*} {a b : \u03b1} [add_comm_group \u03b1] : (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 \u2190 loc.get_locals\n    let red := if red.isSome then semireducible else reducible\n    let tt \u2190 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 \ud835\udd42`\nin a Banach algebra `\ud835\udd38` over a field `\ud835\udd42`. 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 `\ud835\udd42`, and then specialize to `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102`.\n\n### General case\n\n- `has_strict_fderiv_at_exp_zero_of_radius_pos` : `exp \ud835\udd42` has strict Fr\u00e9chet-derivative\n  `1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` 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 `\ud835\udd38 = \ud835\udd42`)\n- `has_strict_fderiv_at_exp_of_lt_radius` : if `\ud835\udd42` has characteristic zero and `\ud835\udd38` is commutative,\n  then given a point `x` in the disk of convergence, `exp \ud835\udd42` as strict Fr\u00e9chet-derivative\n  `exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at x (see also `has_strict_deriv_at_exp_of_lt_radius` for the case\n  `\ud835\udd38 = \ud835\udd42`)\n\n### `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102`\n\n- `has_strict_fderiv_at_exp_zero` : `exp \ud835\udd42` has strict Fr\u00e9chet-derivative `1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at zero\n  (see also `has_strict_deriv_at_exp_zero` for the case `\ud835\udd38 = \ud835\udd42`)\n- `has_strict_fderiv_at_exp` : if `\ud835\udd38` is commutative, then given any point `x`, `exp \ud835\udd42` as strict\n  Fr\u00e9chet-derivative `exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at x (see also `has_strict_deriv_at_exp` for the\n  case `\ud835\udd38 = \ud835\udd42`)\n\n### Compatibilty with `real.exp` and `complex.exp`\n\n- `complex.exp_eq_exp_\u2102` : `complex.exp = exp \u2102 \u2102`\n- `real.exp_eq_exp_\u211d` : `real.exp = exp \u211d \u211d`\n\n-/\n\n\nopen Filter IsROrC ContinuousMultilinearMap NormedField Asymptotics\n\nopen Nat Topology BigOperators ENNReal\n\nsection AnyFieldAnyAlgebra\n\nvariable {\ud835\udd42 \ud835\udd38 : Type _} [NontriviallyNormedField \ud835\udd42] [NormedRing \ud835\udd38] [NormedAlgebra \ud835\udd42 \ud835\udd38]\n  [CompleteSpace \ud835\udd38]\n\n/-- The exponential in a Banach-algebra `\ud835\udd38` over a normed field `\ud835\udd42` has strict Fr\u00e9chet-derivative\n`1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at zero, as long as it converges on a neighborhood of zero. -/\ntheorem hasStrictFderivAt_exp_zero_of_radius_pos (h : 0 < (expSeries \ud835\udd42 \ud835\udd38).radius) :\n    HasStrictFderivAt (exp \ud835\udd42) (1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38) 0 :=\n  by\n  convert(hasFpowerSeriesAtExpZeroOfRadiusPos h).HasStrictFderivAt\n  ext x\n  change x = expSeries \ud835\udd42 \ud835\udd38 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 `\ud835\udd38` over a normed field `\ud835\udd42` has Fr\u00e9chet-derivative\n`1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at zero, as long as it converges on a neighborhood of zero. -/\ntheorem hasFderivAt_exp_zero_of_radius_pos (h : 0 < (expSeries \ud835\udd42 \ud835\udd38).radius) :\n    HasFderivAt (exp \ud835\udd42) (1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38) 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 {\ud835\udd42 \ud835\udd38 : Type _} [NontriviallyNormedField \ud835\udd42] [NormedCommRing \ud835\udd38] [NormedAlgebra \ud835\udd42 \ud835\udd38]\n  [CompleteSpace \ud835\udd38]\n\n/-- The exponential map in a commutative Banach-algebra `\ud835\udd38` over a normed field `\ud835\udd42` of\ncharacteristic zero has Fr\u00e9chet-derivative `exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at any point `x` in the\ndisk of convergence. -/\ntheorem hasFderivAt_exp_of_mem_ball [CharZero \ud835\udd42] {x : \ud835\udd38}\n    (hx : x \u2208 EMetric.ball (0 : \ud835\udd38) (expSeries \ud835\udd42 \ud835\udd38).radius) :\n    HasFderivAt (exp \ud835\udd42) (exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38) x :=\n  by\n  have hpos : 0 < (expSeries \ud835\udd42 \ud835\udd38).radius := (zero_le _).trans_lt hx\n  rw [hasFderivAt_iff_isOCat_nhds_zero]\n  suffices\n    (fun h => exp \ud835\udd42 x * (exp \ud835\udd42 (0 + h) - exp \ud835\udd42 0 - ContinuousLinearMap.id \ud835\udd42 \ud835\udd38 h)) =\u1da0[\ud835\udcdd 0] fun h =>\n      exp \ud835\udd42 (x + h) - exp \ud835\udd42 x - exp \ud835\udd42 x \u2022 ContinuousLinearMap.id \ud835\udd42 \ud835\udd38 h\n    by\n    refine' (is_o.const_mul_left _ _).congr' this (eventually_eq.refl _ _)\n    rw [\u2190 hasFderivAt_iff_isOCat_nhds_zero]\n    exact hasFderivAt_exp_zero_of_radius_pos hpos\n  have : \u2200\u1da0 h in \ud835\udcdd (0 : \ud835\udd38), h \u2208 EMetric.ball (0 : \ud835\udd38) (expSeries \ud835\udd42 \ud835\udd38).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 `\ud835\udd38` over a normed field `\ud835\udd42` of\ncharacteristic zero has strict Fr\u00e9chet-derivative `exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at any point `x` in\nthe disk of convergence. -/\ntheorem hasStrictFderivAt_exp_of_mem_ball [CharZero \ud835\udd42] {x : \ud835\udd38}\n    (hx : x \u2208 EMetric.ball (0 : \ud835\udd38) (expSeries \ud835\udd42 \ud835\udd38).radius) :\n    HasStrictFderivAt (exp \ud835\udd42) (exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38) x :=\n  let \u27e8p, hp\u27e9 := analyticAt_exp_of_mem_ball x hx\n  hp.HasFderivAt.unique (hasFderivAt_exp_of_mem_ball hx) \u25b8 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 {\ud835\udd42 : Type _} [NontriviallyNormedField \ud835\udd42] [CompleteSpace \ud835\udd42]\n\n/-- The exponential map in a complete normed field `\ud835\udd42` of characteristic zero has strict derivative\n`exp \ud835\udd42 x` at any point `x` in the disk of convergence. -/\ntheorem hasStrictDerivAt_exp_of_mem_ball [CharZero \ud835\udd42] {x : \ud835\udd42}\n    (hx : x \u2208 EMetric.ball (0 : \ud835\udd42) (expSeries \ud835\udd42 \ud835\udd42).radius) : HasStrictDerivAt (exp \ud835\udd42) (exp \ud835\udd42 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 `\ud835\udd42` of characteristic zero has derivative\n`exp \ud835\udd42 x` at any point `x` in the disk of convergence. -/\ntheorem hasDerivAt_exp_of_mem_ball [CharZero \ud835\udd42] {x : \ud835\udd42}\n    (hx : x \u2208 EMetric.ball (0 : \ud835\udd42) (expSeries \ud835\udd42 \ud835\udd42).radius) : HasDerivAt (exp \ud835\udd42) (exp \ud835\udd42 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 `\ud835\udd42` 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 \ud835\udd42 \ud835\udd42).radius) :\n    HasStrictDerivAt (exp \ud835\udd42) (1 : \ud835\udd42) 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 `\ud835\udd42` 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 \ud835\udd42 \ud835\udd42).radius) :\n    HasDerivAt (exp \ud835\udd42) (1 : \ud835\udd42) 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 {\ud835\udd42 \ud835\udd38 : Type _} [IsROrC \ud835\udd42] [NormedRing \ud835\udd38] [NormedAlgebra \ud835\udd42 \ud835\udd38] [CompleteSpace \ud835\udd38]\n\n/-- The exponential in a Banach-algebra `\ud835\udd38` over `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102` has strict Fr\u00e9chet-derivative\n`1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at zero. -/\ntheorem hasStrictFderivAt_exp_zero : HasStrictFderivAt (exp \ud835\udd42) (1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38) 0 :=\n  hasStrictFderivAt_exp_zero_of_radius_pos (expSeries_radius_pos \ud835\udd42 \ud835\udd38)\n#align has_strict_fderiv_at_exp_zero hasStrictFderivAt_exp_zero\n\n/-- The exponential in a Banach-algebra `\ud835\udd38` over `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102` has Fr\u00e9chet-derivative\n`1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at zero. -/\ntheorem hasFderivAt_exp_zero : HasFderivAt (exp \ud835\udd42) (1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38) 0 :=\n  hasStrictFderivAt_exp_zero.HasFderivAt\n#align has_fderiv_at_exp_zero hasFderivAt_exp_zero\n\nend IsROrCAnyAlgebra\n\nsection IsROrCCommAlgebra\n\nvariable {\ud835\udd42 \ud835\udd38 : Type _} [IsROrC \ud835\udd42] [NormedCommRing \ud835\udd38] [NormedAlgebra \ud835\udd42 \ud835\udd38] [CompleteSpace \ud835\udd38]\n\n/-- The exponential map in a commutative Banach-algebra `\ud835\udd38` over `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102` has strict\nFr\u00e9chet-derivative `exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at any point `x`. -/\ntheorem hasStrictFderivAt_exp {x : \ud835\udd38} : HasStrictFderivAt (exp \ud835\udd42) (exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38) x :=\n  hasStrictFderivAt_exp_of_mem_ball ((expSeries_radius_eq_top \ud835\udd42 \ud835\udd38).symm \u25b8 edist_lt_top _ _)\n#align has_strict_fderiv_at_exp hasStrictFderivAt_exp\n\n/-- The exponential map in a commutative Banach-algebra `\ud835\udd38` over `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102` has\nFr\u00e9chet-derivative `exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38` at any point `x`. -/\ntheorem hasFderivAt_exp {x : \ud835\udd38} : HasFderivAt (exp \ud835\udd42) (exp \ud835\udd42 x \u2022 1 : \ud835\udd38 \u2192L[\ud835\udd42] \ud835\udd38) x :=\n  hasStrictFderivAt_exp.HasFderivAt\n#align has_fderiv_at_exp hasFderivAt_exp\n\nend IsROrCCommAlgebra\n\nsection DerivROrC\n\nvariable {\ud835\udd42 : Type _} [IsROrC \ud835\udd42]\n\n/-- The exponential map in `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102` has strict derivative `exp \ud835\udd42 x` at any point\n`x`. -/\ntheorem hasStrictDerivAt_exp {x : \ud835\udd42} : HasStrictDerivAt (exp \ud835\udd42) (exp \ud835\udd42 x) x :=\n  hasStrictDerivAt_exp_of_mem_ball ((expSeries_radius_eq_top \ud835\udd42 \ud835\udd42).symm \u25b8 edist_lt_top _ _)\n#align has_strict_deriv_at_exp hasStrictDerivAt_exp\n\n/-- The exponential map in `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102` has derivative `exp \ud835\udd42 x` at any point `x`. -/\ntheorem hasDerivAt_exp {x : \ud835\udd42} : HasDerivAt (exp \ud835\udd42) (exp \ud835\udd42 x) x :=\n  hasStrictDerivAt_exp.HasDerivAt\n#align has_deriv_at_exp hasDerivAt_exp\n\n/-- The exponential map in `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102` has strict derivative `1` at zero. -/\ntheorem hasStrictDerivAt_exp_zero : HasStrictDerivAt (exp \ud835\udd42) (1 : \ud835\udd42) 0 :=\n  hasStrictDerivAt_exp_zero_of_radius_pos (expSeries_radius_pos \ud835\udd42 \ud835\udd42)\n#align has_strict_deriv_at_exp_zero hasStrictDerivAt_exp_zero\n\n/-- The exponential map in `\ud835\udd42 = \u211d` or `\ud835\udd42 = \u2102` has derivative `1` at zero. -/\ntheorem hasDerivAt_exp_zero : HasDerivAt (exp \ud835\udd42) (1 : \ud835\udd42) 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_\u2102 : Complex.exp = exp \u2102 :=\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 \u211d x).HasSum.tendsto_sum_nat\n#align complex.exp_eq_exp_\u2102 Complex.exp_eq_exp_\u2102\n\ntheorem Real.exp_eq_exp_\u211d : Real.exp = exp \u211d :=\n  by\n  ext x\n  exact_mod_cast congr_fun Complex.exp_eq_exp_\u2102 x\n#align real.exp_eq_exp_\u211d Real.exp_eq_exp_\u211d\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 \u03b1`, the partial values of a type.\n\n`o : part \u03b1` carries a proposition `o.dom`, its domain, along with a function `get : o.dom \u2192 \u03b1`, 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 \u03b1` behaves the same as `option \u03b1` except that `o : option \u03b1` is decidably `none` or `some a`\nfor some `a : \u03b1`, while the domain of `o : part \u03b1` 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 \u03b1` and `part \u03b1` are classically equivalent. In general, `part \u03b1` is bigger than `option \u03b1`.\n\nIn current mathlib, `part \u2115`, aka `enat`, is used to move decidability of the order to decidability\nof `enat.find` (which is the smallest natural satisfying a predicate, or `\u221e` 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 \u03b1` to a `part \u03b1` by sending `none` to `none` and `some a` to\n  `some a`.\n* `part.to_option`: Converts a `part \u03b1` with a decidable domain to an `option \u03b1`.\n* `part.equiv_option`: Classical equivalence between `part \u03b1` and `option \u03b1`.\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 \u03b1` by `p : Prop` so long as\n  `p \u2192 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 : \u03b1`, `o : part \u03b1`, `a \u2208 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 \u03b1` is the type of \"partial values\" of type `\u03b1`. It\n  is similar to `option \u03b1` except the domain condition can be an\n  arbitrary proposition, not necessarily decidable. -/\nstructure {u} part (\u03b1 : Type u) : Type u :=\n(dom : Prop)\n(get : dom \u2192 \u03b1)\n\nnamespace part\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n\n/-- Convert a `part \u03b1` with a decidable domain to an option -/\ndef to_option (o : part \u03b1) [decidable o.dom] : option \u03b1 :=\nif h : dom o then some (o.get h) else none\n\n/-- `part` extensionality -/\ntheorem ext' : \u2200 {o p : part \u03b1}\n  (H1 : o.dom \u2194 p.dom)\n  (H2 : \u2200h\u2081 h\u2082, o.get h\u2081 = p.get h\u2082), o = p\n| \u27e8od, o\u27e9 \u27e8pd, p\u27e9 H1 H2 := have t : od = pd, from propext H1,\n  by cases t; rw [show o = p, from funext $ \u03bbp, H2 p p]\n\n/-- `part` eta expansion -/\n@[simp] theorem eta : \u03a0 (o : part \u03b1), (\u27e8o.dom, \u03bb h, o.get h\u27e9 : part \u03b1) = o\n| \u27e8h, f\u27e9 := rfl\n\n/-- `a \u2208 o` means that `o` is defined and equal to `a` -/\nprotected def mem (a : \u03b1) (o : part \u03b1) : Prop := \u2203 h, o.get h = a\n\ninstance : has_mem \u03b1 (part \u03b1) := \u27e8part.mem\u27e9\n\ntheorem mem_eq (a : \u03b1) (o : part \u03b1) : (a \u2208 o) = (\u2203 h, o.get h = a) :=\nrfl\n\ntheorem dom_iff_mem : \u2200 {o : part \u03b1}, o.dom \u2194 \u2203 y, y \u2208 o\n| \u27e8p, f\u27e9 := \u27e8\u03bbh, \u27e8f h, h, rfl\u27e9, \u03bb\u27e8_, h, rfl\u27e9, h\u27e9\n\ntheorem get_mem {o : part \u03b1} (h) : get o h \u2208 o := \u27e8_, rfl\u27e9\n\n@[simp] lemma mem_mk_iff {p : Prop} {o : p \u2192 \u03b1} {a : \u03b1} : a \u2208 part.mk p o \u2194 \u2203 h, o h = a := iff.rfl\n\n/-- `part` extensionality -/\n@[ext]\ntheorem ext {o p : part \u03b1} (H : \u2200 a, a \u2208 o \u2194 a \u2208 p) : o = p :=\next' \u27e8\u03bb h, ((H _).1 \u27e8h, rfl\u27e9).fst,\n     \u03bb h, ((H _).2 \u27e8h, rfl\u27e9).fst\u27e9 $\n\u03bb a b, ((H _).2 \u27e8_, rfl\u27e9).snd\n\n/-- The `none` value in `part` has a `false` domain and an empty function. -/\ndef none : part \u03b1 := \u27e8false, false.rec _\u27e9\n\ninstance : inhabited (part \u03b1) := \u27e8none\u27e9\n\n@[simp] theorem not_mem_none (a : \u03b1) : a \u2209 @none \u03b1 := \u03bb h, h.fst\n\n/-- The `some a` value in `part` has a `true` domain and the\n  function returns `a`. -/\ndef some (a : \u03b1) : part \u03b1 := \u27e8true, \u03bb_, a\u27e9\n\ntheorem mem_unique : \u2200 {a b : \u03b1} {o : part \u03b1}, a \u2208 o \u2192 b \u2208 o \u2192 a = b\n| _ _ \u27e8p, f\u27e9 \u27e8h\u2081, rfl\u27e9 \u27e8h\u2082, rfl\u27e9 := rfl\n\ntheorem mem.left_unique : relator.left_unique ((\u2208) : \u03b1 \u2192 part \u03b1 \u2192 Prop) :=\n\u03bb a o b, mem_unique\n\ntheorem get_eq_of_mem {o : part \u03b1} {a} (h : a \u2208 o) (h') : get o h' = a :=\nmem_unique \u27e8_, rfl\u27e9 h\n\nprotected theorem subsingleton (o : part \u03b1) : set.subsingleton {a | a \u2208 o} :=\n\u03bb a ha b hb, mem_unique ha hb\n\n@[simp] theorem get_some {a : \u03b1} (ha : (some a).dom) : get (some a) ha = a := rfl\n\ntheorem mem_some (a : \u03b1) : a \u2208 some a := \u27e8trivial, rfl\u27e9\n\n@[simp] theorem mem_some_iff {a b} : b \u2208 (some a : part \u03b1) \u2194 b = a :=\n\u27e8\u03bb\u27e8h, e\u27e9, e.symm, \u03bb e, \u27e8trivial, e.symm\u27e9\u27e9\n\ntheorem eq_some_iff {a : \u03b1} {o : part \u03b1} : o = some a \u2194 a \u2208 o :=\n\u27e8\u03bb e, e.symm \u25b8 mem_some _,\n \u03bb \u27e8h, e\u27e9, e \u25b8 ext' (iff_true_intro h) (\u03bb _ _, rfl)\u27e9\n\ntheorem eq_none_iff {o : part \u03b1} : o = none \u2194 \u2200 a, a \u2209 o :=\n\u27e8\u03bb e, e.symm \u25b8 not_mem_none, \u03bb h, ext (by simpa)\u27e9\n\ntheorem eq_none_iff' {o : part \u03b1} : o = none \u2194 \u00ac o.dom :=\n\u27e8\u03bb e, e.symm \u25b8 id, \u03bb h, eq_none_iff.2 (\u03bb a h', h h'.fst)\u27e9\n\n@[simp] lemma some_ne_none (x : \u03b1) : some x \u2260 none :=\nby { intro h, change none.dom, rw [\u2190 h], trivial }\n\n@[simp] lemma none_ne_some (x : \u03b1) : none \u2260 some x :=\n(some_ne_none x).symm\n\nlemma ne_none_iff {o : part \u03b1} : o \u2260 none \u2194 \u2203 x, o = some x :=\nbegin\n  split,\n  { rw [ne, eq_none_iff', not_not], exact \u03bb h, \u27e8o.get h, eq_some_iff.2 (get_mem h)\u27e9 },\n  { rintro \u27e8x, rfl\u27e9, apply some_ne_none }\nend\n\nlemma eq_none_or_eq_some (o : part \u03b1) : o = none \u2228 \u2203 x, o = some x :=\nor_iff_not_imp_left.2 ne_none_iff.1\n\nlemma some_injective : injective (@part.some \u03b1) :=\n\u03bb a b h, congr_fun (eq_of_heq (part.mk.inj h).2) trivial\n\n@[simp] lemma some_inj {a b : \u03b1} : part.some a = some b \u2194 a = b := some_injective.eq_iff\n\n@[simp] lemma some_get {a : part \u03b1} (ha : a.dom) :\n  part.some (part.get a ha) = a :=\neq.symm (eq_some_iff.2 \u27e8ha, rfl\u27e9)\n\nlemma get_eq_iff_eq_some {a : part \u03b1} {ha : a.dom} {b : \u03b1} :\n  a.get ha = b \u2194 a = some b :=\n\u27e8\u03bb h, by simp [h.symm], \u03bb h, by simp [h]\u27e9\n\nlemma get_eq_get_of_eq (a : part \u03b1) (ha : a.dom) {b : part \u03b1} (h : a = b) :\n  a.get ha = b.get (h \u25b8 ha) :=\nby { congr, exact h }\n\nlemma get_eq_iff_mem {o : part \u03b1} {a : \u03b1} (h : o.dom) : o.get h = a \u2194 a \u2208 o :=\n\u27e8\u03bb H, \u27e8h, H\u27e9, \u03bb \u27e8h', H\u27e9, H\u27e9\n\nlemma eq_get_iff_mem {o : part \u03b1} {a : \u03b1} (h : o.dom) : a = o.get h \u2194 a \u2208 o :=\neq_comm.trans (get_eq_iff_mem h)\n\n@[simp] lemma none_to_option [decidable (@none \u03b1).dom] : (none : part \u03b1).to_option = option.none :=\ndif_neg id\n\n@[simp] lemma some_to_option (a : \u03b1) [decidable (some a).dom] :\n  (some a).to_option = option.some a :=\ndif_pos trivial\n\ninstance none_decidable : decidable (@none \u03b1).dom := decidable.false\ninstance some_decidable (a : \u03b1) : decidable (some a).dom := decidable.true\n\n/-- Retrieves the value of `a : part \u03b1` if it exists, and return the provided default value\notherwise. -/\ndef get_or_else (a : part \u03b1) [decidable a.dom] (d : \u03b1) :=\nif ha : a.dom then a.get ha else d\n\n@[simp] lemma get_or_else_none (d : \u03b1) [decidable (none : part \u03b1).dom] : get_or_else none d = d :=\ndif_neg id\n\n@[simp] lemma get_or_else_some (a : \u03b1) (d : \u03b1) [decidable (some a).dom] :\n  get_or_else (some a) d = a :=\ndif_pos trivial\n\n@[simp] theorem mem_to_option {o : part \u03b1} [decidable o.dom] {a : \u03b1} :\n  a \u2208 to_option o \u2194 a \u2208 o :=\nbegin\n  unfold to_option,\n  by_cases h : o.dom; simp [h],\n  { exact \u27e8\u03bb h, \u27e8_, h\u27e9, \u03bb \u27e8_, h\u27e9, h\u27e9 },\n  { exact mt Exists.fst h }\nend\n\nprotected lemma dom.to_option {o : part \u03b1} [decidable o.dom] (h : o.dom) : o.to_option = o.get h :=\ndif_pos h\n\nlemma to_option_eq_none_iff {a : part \u03b1} [decidable a.dom] : a.to_option = option.none \u2194 \u00ac a.dom :=\nne.dite_eq_right_iff $ \u03bb h, option.some_ne_none _\n\n@[simp] lemma elim_to_option {\u03b1 \u03b2 : Type*} (a : part \u03b1) [decidable a.dom] (b : \u03b2) (f : \u03b1 \u2192 \u03b2) :\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 \u03b1` into a `part \u03b1`. -/\ndef of_option : option \u03b1 \u2192 part \u03b1\n| option.none     := none\n| (option.some a) := some a\n\n@[simp] theorem mem_of_option {a : \u03b1} : \u2200 {o : option \u03b1}, a \u2208 of_option o \u2194 a \u2208 o\n| option.none     := \u27e8\u03bb h, h.fst.elim, \u03bb h, option.no_confusion h\u27e9\n| (option.some b) := \u27e8\u03bb h, congr_arg option.some h.snd,\n  \u03bb h, \u27e8trivial, option.some.inj h\u27e9\u27e9\n\n@[simp] theorem of_option_dom {\u03b1} : \u2200 (o : option \u03b1), (of_option o).dom \u2194 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 {\u03b1} (o : option \u03b1) : of_option o = \u27e8_, @option.get _ o\u27e9 :=\npart.ext' (of_option_dom o) $ \u03bb h\u2081 h\u2082, by cases o; [cases h\u2081, refl]\n\ninstance : has_coe (option \u03b1) (part \u03b1) := \u27e8of_option\u27e9\n\n@[simp] theorem mem_coe {a : \u03b1} {o : option \u03b1} :\n  a \u2208 (o : part \u03b1) \u2194 a \u2208 o := mem_of_option\n\n@[simp] theorem coe_none : (@option.none \u03b1 : part \u03b1) = none := rfl\n@[simp] theorem coe_some (a : \u03b1) : (option.some a : part \u03b1) = some a := rfl\n\n@[elab_as_eliminator] protected lemma induction_on {P : part \u03b1 \u2192 Prop}\n  (a : part \u03b1) (hnone : P none) (hsome : \u2200 a : \u03b1, P (some a)) : P a :=\n(classical.em a.dom).elim\n  (\u03bb h, part.some_get h \u25b8 hsome _)\n  (\u03bb h, (eq_none_iff'.2 h).symm \u25b8 hnone)\n\ninstance of_option_decidable : \u2200 o : option \u03b1, 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 \u03b1) : to_option (of_option o) = o :=\nby cases o; refl\n\n@[simp] theorem of_to_option (o : part \u03b1) [decidable o.dom] : of_option (to_option o) = o :=\next $ \u03bb a, mem_of_option.trans mem_to_option\n\n/-- `part \u03b1` is (classically) equivalent to `option \u03b1`. -/\nnoncomputable def equiv_option : part \u03b1 \u2243 option \u03b1 :=\nby haveI := classical.dec; exact\n\u27e8\u03bb o, to_option o, of_option, \u03bb o, of_to_option o,\n \u03bb o, eq.trans (by dsimp; congr) (to_of_option o)\u27e9\n\n/-- We give `part \u03b1` the order where everything is greater than `none`. -/\ninstance : partial_order (part \u03b1) :=\n{ le := \u03bb x y, \u2200 i, i \u2208 x \u2192 i \u2208 y,\n  le_refl := \u03bb x y, id,\n  le_trans := \u03bb x y z f g i, g _ \u2218 f _,\n  le_antisymm := \u03bb x y f g, part.ext $ \u03bb z, \u27e8f _, g _\u27e9 }\n\ninstance : order_bot (part \u03b1) :=\n{ bot := none,\n  bot_le := by { introv x, rintro \u27e8\u27e8_\u27e9,_\u27e9, } }\n\nlemma le_total_of_le_of_le {x y : part \u03b1} (z : part \u03b1) (hx : x \u2264 z) (hy : y \u2264 z) :\n  x \u2264 y \u2228 y \u2264 x :=\nbegin\n  rcases part.eq_none_or_eq_some x with h | \u27e8b, h\u2080\u27e9,\n  { rw h, left, apply order_bot.bot_le _ },\n  right, intros b' h\u2081,\n  rw part.eq_some_iff at h\u2080,\n  replace hx := hx _ h\u2080, replace hy := hy _ h\u2081,\n  replace hx := part.mem_unique hx hy, subst hx,\n  exact h\u2080\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 \u2192 part \u03b1) : part \u03b1 :=\n\u27e8\u2203 h : p, (f h).dom, \u03bbha, (f ha.fst).get ha.snd\u27e9\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 \u03b1) (g : \u03b1 \u2192 part \u03b2) : part \u03b2 :=\nassert (dom f) (\u03bbb, 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 : \u03b1 \u2192 \u03b2) (o : part \u03b1) : part \u03b2 :=\n\u27e8o.dom, f \u2218 o.get\u27e9\n\ntheorem mem_map (f : \u03b1 \u2192 \u03b2) {o : part \u03b1} :\n  \u2200 {a}, a \u2208 o \u2192 f a \u2208 map f o\n| _ \u27e8h, rfl\u27e9 := \u27e8_, rfl\u27e9\n\n@[simp] theorem mem_map_iff (f : \u03b1 \u2192 \u03b2) {o : part \u03b1} {b} :\n  b \u2208 map f o \u2194 \u2203 a \u2208 o, f a = b :=\n\u27e8match b with _, \u27e8h, rfl\u27e9 := \u27e8_, \u27e8_, rfl\u27e9, rfl\u27e9 end,\n \u03bb \u27e8a, h\u2081, h\u2082\u27e9, h\u2082 \u25b8 mem_map f h\u2081\u27e9\n\n@[simp] theorem map_none (f : \u03b1 \u2192 \u03b2) :\n  map f none = none := eq_none_iff.2 $ \u03bb a, by simp\n\n@[simp] theorem map_some (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : map f (some a) = some (f a) :=\neq_some_iff.2 $ mem_map f $ mem_some _\n\ntheorem mem_assert {p : Prop} {f : p \u2192 part \u03b1}\n  : \u2200 {a} (h : p), a \u2208 f h \u2192 a \u2208 assert p f\n| _ x \u27e8h, rfl\u27e9 := \u27e8\u27e8x, h\u27e9, rfl\u27e9\n\n@[simp] theorem mem_assert_iff {p : Prop} {f : p \u2192 part \u03b1} {a} :\n  a \u2208 assert p f \u2194 \u2203 h : p, a \u2208 f h :=\n\u27e8match a with _, \u27e8h, rfl\u27e9 := \u27e8_, \u27e8_, rfl\u27e9\u27e9 end,\n \u03bb \u27e8a, h\u27e9, mem_assert _ h\u27e9\n\nlemma assert_pos {p : Prop} {f : p \u2192 part \u03b1} (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 \u2192 part \u03b1} (h : \u00ac 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 \u03b1} {g : \u03b1 \u2192 part \u03b2} :\n  \u2200 {a b}, a \u2208 f \u2192 b \u2208 g a \u2192 b \u2208 f.bind g\n| _ _ \u27e8h, rfl\u27e9 \u27e8h\u2082, rfl\u27e9 := \u27e8\u27e8h, h\u2082\u27e9, rfl\u27e9\n\n@[simp] theorem mem_bind_iff {f : part \u03b1} {g : \u03b1 \u2192 part \u03b2} {b} :\n  b \u2208 f.bind g \u2194 \u2203 a \u2208 f, b \u2208 g a :=\n\u27e8match b with _, \u27e8\u27e8h\u2081, h\u2082\u27e9, rfl\u27e9 := \u27e8_, \u27e8_, rfl\u27e9, \u27e8_, rfl\u27e9\u27e9 end,\n \u03bb \u27e8a, h\u2081, h\u2082\u27e9, mem_bind h\u2081 h\u2082\u27e9\n\nprotected lemma dom.bind {o : part \u03b1} (h : o.dom) (f : \u03b1 \u2192 part \u03b2) : o.bind f = f (o.get h) :=\nbegin\n  ext b,\n  simp only [part.mem_bind_iff, exists_prop],\n  refine \u27e8_, \u03bb hb, \u27e8o.get h, part.get_mem _, hb\u27e9\u27e9,\n  rintro \u27e8a, ha, hb\u27e9,\n  rwa part.get_eq_of_mem ha,\nend\n\nlemma dom.of_bind {f : \u03b1 \u2192 part \u03b2} {a : part \u03b1} (h : (a.bind f).dom) : a.dom := h.some\n\n@[simp] theorem bind_none (f : \u03b1 \u2192 part \u03b2) :\n  none.bind f = none := eq_none_iff.2 $ \u03bb a, by simp\n\n@[simp] theorem bind_some (a : \u03b1) (f : \u03b1 \u2192 part \u03b2) :\n  (some a).bind f = f a := ext $ by simp\n\ntheorem bind_of_mem {o : part \u03b1} {a : \u03b1} (h : a \u2208 o) (f : \u03b1 \u2192 part \u03b2) :\n  o.bind f = f a :=\nby rw [eq_some_iff.2 h, bind_some]\n\ntheorem bind_some_eq_map (f : \u03b1 \u2192 \u03b2) (x : part \u03b1) :\n  x.bind (some \u2218 f) = map f x :=\next $ by simp [eq_comm]\n\nlemma bind_to_option (f : \u03b1 \u2192 part \u03b2) (o : part \u03b1) [decidable o.dom] [\u03a0 a, decidable (f a).dom]\n  [decidable (o.bind f).dom] :\n  (o.bind f).to_option = o.to_option.elim option.none (\u03bb 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 (\u03bb ho, h ho.of_bind) }\nend\n\ntheorem bind_assoc {\u03b3} (f : part \u03b1) (g : \u03b1 \u2192 part \u03b2) (k : \u03b2 \u2192 part \u03b3) :\n  (f.bind g).bind k = f.bind (\u03bb x, (g x).bind k) :=\next $ \u03bb a, by simp; exact\n \u27e8\u03bb \u27e8_, \u27e8_, h\u2081, h\u2082\u27e9, h\u2083\u27e9, \u27e8_, h\u2081, _, h\u2082, h\u2083\u27e9,\n  \u03bb \u27e8_, h\u2081, _, h\u2082, h\u2083\u27e9, \u27e8_, \u27e8_, h\u2081, h\u2082\u27e9, h\u2083\u27e9\u27e9\n\n@[simp] theorem bind_map {\u03b3} (f : \u03b1 \u2192 \u03b2) (x) (g : \u03b2 \u2192 part \u03b3) :\n  (map f x).bind g = x.bind (\u03bb y, g (f y)) :=\nby rw [\u2190 bind_some_eq_map, bind_assoc]; simp\n\n@[simp] theorem map_bind {\u03b3} (f : \u03b1 \u2192 part \u03b2) (x : part \u03b1) (g : \u03b2 \u2192 \u03b3) :\n  map g (x.bind f) = x.bind (\u03bb y, map g (f y)) :=\nby rw [\u2190 bind_some_eq_map, bind_assoc]; simp [bind_some_eq_map]\n\ntheorem map_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) (o : part \u03b1) :\n  map g (map f o) = map (g \u2218 f) o :=\nby rw [\u2190 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 := \u03bb \u03b2 f, by cases f; refl,\n  pure_bind := @bind_some,\n  bind_assoc := @bind_assoc }\n\ntheorem map_id' {f : \u03b1 \u2192 \u03b1} (H : \u2200 (x : \u03b1), 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 \u03b1) : x.bind some = x :=\nby rw [bind_some_eq_map]; simp [map_id']\n\n@[simp] theorem pure_eq_some (a : \u03b1) : pure a = some a := rfl\n@[simp] theorem ret_eq_some (a : \u03b1) : return a = some a := rfl\n\n@[simp] theorem map_eq_map {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (o : part \u03b1) :\n  f <$> o = map f o := rfl\n\n@[simp] theorem bind_eq_bind {\u03b1 \u03b2} (f : part \u03b1) (g : \u03b1 \u2192 part \u03b2) :\n  f >>= g = f.bind g := rfl\n\nlemma bind_le {\u03b1} (x : part \u03b1) (f : \u03b1 \u2192 part \u03b2) (y : part \u03b2) :\n  x >>= f \u2264 y \u2194 (\u2200 a, a \u2208 x \u2192 f a \u2264 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 \u27e8a,h\u2080,h\u2081\u27e9, apply h _ h\u2080 _ h\u2081 },\nend\n\ninstance : monad_fail part :=\n{ fail := \u03bb_ _, 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 \u03b1) (H : p \u2192 o.dom) : part \u03b1 :=\n\u27e8p, \u03bbh, o.get (H h)\u27e9\n\n@[simp]\ntheorem mem_restrict (p : Prop) (o : part \u03b1) (h : p \u2192 o.dom) (a : \u03b1) :\n  a \u2208 restrict p o h \u2194 p \u2227 a \u2208 o :=\nbegin\n  dsimp [restrict, mem_eq], split,\n  { rintro \u27e8h\u2080, h\u2081\u27e9, exact \u27e8h\u2080, \u27e8_, h\u2081\u27e9\u27e9 },\n  rintro \u27e8h\u2080, h\u2081, h\u2082\u27e9, exact \u27e8h\u2080, h\u2082\u27e9\nend\n\n/-- `unwrap o` gets the value at `o`, ignoring the condition. This function is unsound. -/\nmeta def unwrap (o : part \u03b1) : \u03b1 := o.get undefined\n\ntheorem assert_defined {p : Prop} {f : p \u2192 part \u03b1} :\n  \u2200 (h : p), (f h).dom \u2192 (assert p f).dom := exists.intro\n\ntheorem bind_defined {f : part \u03b1} {g : \u03b1 \u2192 part \u03b2} :\n  \u2200 (h : f.dom), (g (f.get h)).dom \u2192 (f.bind g).dom := assert_defined\n\n@[simp] theorem bind_dom {f : part \u03b1} {g : \u03b1 \u2192 part \u03b2} :\n  (f.bind g).dom \u2194 \u2203 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 \u03b1` inherited from `\u03b1`. -/\n\n@[to_additive] instance [has_one \u03b1] : has_one (part \u03b1) := { one := pure 1 }\n@[to_additive] instance [has_mul \u03b1] : has_mul (part \u03b1) := { mul := \u03bb a b, (*) <$> a <*> b }\n@[to_additive] instance [has_inv \u03b1] : has_inv (part \u03b1) := { inv := map has_inv.inv }\n@[to_additive] instance [has_div \u03b1] : has_div (part \u03b1) := { div := \u03bb a b, (/) <$> a <*> b }\ninstance [has_mod \u03b1] : has_mod (part \u03b1) := { mod := \u03bb a b, (%) <$> a <*> b }\ninstance [has_append \u03b1] : has_append (part \u03b1) := { append := \u03bb a b, (++) <$> a <*> b }\ninstance [has_inter \u03b1] : has_inter (part \u03b1) := { inter := \u03bb a b, (\u2229) <$> a <*> b }\ninstance [has_union \u03b1] : has_union (part \u03b1) := { union := \u03bb a b, (\u222a) <$> a <*> b }\ninstance [has_sdiff \u03b1] : has_sdiff (part \u03b1) := { sdiff := \u03bb a b, (\\) <$> a <*> b }\n\n@[to_additive]\nlemma one_mem_one [has_one \u03b1] : (1 : \u03b1) \u2208 (1 : part \u03b1) := \u27e8trivial, rfl\u27e9\n\n@[to_additive]\nlemma mul_mem_mul [has_mul \u03b1] (a b : part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n  ma * mb \u2208 a * b := by tidy\n\n@[to_additive]\nlemma left_dom_of_mul_dom [has_mul \u03b1] {a b : part \u03b1} (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 \u03b1] (a b : part \u03b1) (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 \u03b1] (a b : \u03b1) : some a * some b = some (a * b) := by tidy\n\n@[to_additive]\nlemma inv_mem_inv [has_inv \u03b1] (a : part \u03b1) (ma : \u03b1) (ha : ma \u2208 a) : ma\u207b\u00b9 \u2208 a\u207b\u00b9 := by tidy\n\n@[to_additive]\nlemma inv_some [has_inv \u03b1] (a : \u03b1) : (some a)\u207b\u00b9 = some (a\u207b\u00b9) := rfl\n\n@[to_additive]\nlemma div_mem_div [has_div \u03b1] (a b : part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n  ma / mb \u2208 a / b := by tidy\n\n@[to_additive]\nlemma left_dom_of_div_dom [has_div \u03b1] {a b : part \u03b1} (hab : dom (a / b)) :\n  a.dom := by tidy\n\n@[to_additive]\nlemma right_dom_of_div_dom [has_div \u03b1] {a b : part \u03b1} (hab : dom (a / b)) :\n  b.dom := by tidy\n\n@[simp, to_additive]\nlemma div_get_eq [has_div \u03b1] (a b : part \u03b1) (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 \u03b1] (a b : \u03b1) : some a / some b = some (a / b) := by tidy\n\nlemma mod_mem_mod [has_mod \u03b1] (a b : part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n  ma % mb \u2208 a % b := by tidy\n\nlemma left_dom_of_mod_dom [has_mod \u03b1] {a b : part \u03b1} (hab : dom (a % b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_mod_dom [has_mod \u03b1] {a b : part \u03b1} (hab : dom (a % b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma mod_get_eq [has_mod \u03b1] (a b : part \u03b1) (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 \u03b1] (a b : \u03b1) : some a % some b = some (a % b) := by tidy\n\nlemma append_mem_append [has_append \u03b1] (a b : part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n  ma ++ mb \u2208 a ++ b := by tidy\n\nlemma left_dom_of_append_dom [has_append \u03b1] {a b : part \u03b1} (hab : dom (a ++ b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_append_dom [has_append \u03b1] {a b : part \u03b1} (hab : dom (a ++ b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma append_get_eq [has_append \u03b1] (a b : part \u03b1) (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 \u03b1] (a b : \u03b1) : some a ++ some b = some (a ++ b) := by tidy\n\nlemma inter_mem_inter [has_inter \u03b1] (a b : part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n  ma \u2229 mb \u2208 a \u2229 b := by tidy\n\nlemma left_dom_of_inter_dom [has_inter \u03b1] {a b : part \u03b1} (hab : dom (a \u2229 b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_inter_dom [has_inter \u03b1] {a b : part \u03b1} (hab : dom (a \u2229 b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma inter_get_eq [has_inter \u03b1] (a b : part \u03b1) (hab : dom (a \u2229 b)) :\n  (a \u2229 b).get hab = a.get (left_dom_of_inter_dom hab) \u2229 b.get (right_dom_of_inter_dom hab) :=\nby tidy\n\nlemma some_inter_some [has_inter \u03b1] (a b : \u03b1) : some a \u2229 some b = some (a \u2229 b) := by tidy\n\nlemma union_mem_union [has_union \u03b1] (a b : part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n  ma \u222a mb \u2208 a \u222a b := by tidy\n\nlemma left_dom_of_union_dom [has_union \u03b1] {a b : part \u03b1} (hab : dom (a \u222a b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_union_dom [has_union \u03b1] {a b : part \u03b1} (hab : dom (a \u222a b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma union_get_eq [has_union \u03b1] (a b : part \u03b1) (hab : dom (a \u222a b)) :\n  (a \u222a b).get hab = a.get (left_dom_of_union_dom hab) \u222a b.get (right_dom_of_union_dom hab) :=\nby tidy\n\nlemma some_union_some [has_union \u03b1] (a b : \u03b1) : some a \u222a some b = some (a \u222a b) := by tidy\n\nlemma sdiff_mem_sdiff [has_sdiff \u03b1] (a b : part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n  ma \\ mb \u2208 a \\ b := by tidy\n\nlemma left_dom_of_sdiff_dom [has_sdiff \u03b1] {a b : part \u03b1} (hab : dom (a \\ b)) :\n  a.dom := by tidy\n\nlemma right_dom_of_sdiff_dom [has_sdiff \u03b1] {a b : part \u03b1} (hab : dom (a \\ b)) :\n  b.dom := by tidy\n\n@[simp]\nlemma sdiff_get_eq [has_sdiff \u03b1] (a b : part \u03b1) (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 \u03b1] (a b : \u03b1) : 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\u2081\n\nnamespace DirectSum\n\nopen Dfinsupp\n\nopen DirectSum\n\nvariable {R : Type u} {\u03b9 : 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\u2081} {M : \u03b9 \u2192 Type w}\n\nvariable [LieRing L] [LieAlgebra R L]\n\nvariable [\u2200 i, AddCommGroup (M i)] [\u2200 i, Module R (M i)]\n\nvariable [\u2200 i, LieRingModule L (M i)] [\u2200 i, LieModule R L (M i)]\n\ninstance : LieRingModule L (\u2a01 i, M i)\n    where\n  bracket x m := m.mapRange (fun i m' => \u2045x, m'\u2046) 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 : \u2a01 i, M i) (i : \u03b9) : \u2045x, m\u2046 i = \u2045x, m i\u2046 :=\n  mapRange_apply _ _ m i\n#align direct_sum.lie_module_bracket_apply DirectSum.lie_module_bracket_apply\n\ninstance : LieModule R L (\u2a01 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 \u03b9 L M)\n\n/-- The inclusion of each component into a direct sum as a morphism of Lie modules. -/\ndef lieModuleOf [DecidableEq \u03b9] (j : \u03b9) : M j \u2192\u2097\u2045R,L\u2046 \u2a01 i, M i :=\n  { lof R \u03b9 M j with\n    map_lie' := fun x m => by\n      ext i; by_cases h : j = i\n      \u00b7 rw [\u2190 h]\n        simp\n      \u00b7 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 : \u03b9) : (\u2a01 i, M i) \u2192\u2097\u2045R,L\u2046 M j :=\n  { component R \u03b9 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 : \u03b9 \u2192 Type w)\n\nvariable [\u2200 i, LieRing (L i)] [\u2200 i, LieAlgebra R (L i)]\n\ninstance lieRing : LieRing (\u2a01 i, L i) :=\n  {\n    (inferInstance :\n      AddCommGroup\n        _) with\n    bracket := zipWith (fun i => fun x y => \u2045x, y\u2046) 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 : \u2a01 i, L i) (i : \u03b9) : \u2045x, y\u2046 i = \u2045x i, y i\u2046 :=\n  zipWith_apply _ _ x y i\n#align direct_sum.bracket_apply DirectSum.bracket_apply\n\ninstance lieAlgebra : LieAlgebra R (\u2a01 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 \u03b9 L)\n\n/-- The inclusion of each component into the direct sum as morphism of Lie algebras. -/\n@[simps]\ndef lieAlgebraOf [DecidableEq \u03b9] (j : \u03b9) : L j \u2192\u2097\u2045R\u2046 \u2a01 i, L i :=\n  { lof R \u03b9 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      \u00b7 rw [\u2190 h]\n        simp [of]\n      \u00b7 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 : \u03b9) : (\u2a01 i, L i) \u2192\u2097\u2045R\u2046 L j :=\n  { component R \u03b9 L j with\n    toFun := component R \u03b9 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 : \u2a01 i, L i}\n    (h : \u2200 i, lieAlgebraComponent R \u03b9 L i x = lieAlgebraComponent R \u03b9 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 \u03b9] {i j : \u03b9} (hij : j \u2260 i) (x : L i) (y : L j) :\n    \u2045of L i x, of L j y\u2046 = 0 := by\n  apply lie_algebra_ext R \u03b9 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  \u00b7 simp only [dif_neg, not_false_iff, lie_zero, hik.symm, hij]\n  \u00b7 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 \u03b9] {i j : \u03b9} (hij : j = i) (x : L i) (y : L j) :\n    \u2045of L i x, of L j y\u2046 = of L i \u2045x, hij.recOn y\u2046 :=\n  by\n  have : of L j y = of L i (hij.rec_on y) := Eq.drec (Eq.refl _) hij\n  rw [this, \u2190 lie_algebra_of_apply R \u03b9 L i \u2045x, hij.rec_on y\u2046, 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 \u03b9] {i j : \u03b9} (x : L i) (y : L j) :\n    \u2045of L i x, of L j y\u2046 = if hij : j = i then lieAlgebraOf R \u03b9 L i \u2045x, hij.recOn y\u2046 else 0 :=\n  by\n  by_cases hij : j = i\n  \u00b7 simp only [lie_of_of_eq R \u03b9 L hij x y, hij, dif_pos, not_false_iff, lie_algebra_of_apply]\n  \u00b7 simp only [lie_of_of_ne R \u03b9 L hij x y, hij, dif_neg, not_false_iff]\n#align direct_sum.lie_of DirectSum.lie_of\n\nvariable {R L \u03b9}\n\n/-- Given a family of Lie algebras `L i`, together with a family of morphisms of Lie algebras\n`f i : L i \u2192\u2097\u2045R\u2046 L'` into a fixed Lie algebra `L'`, we have a natural linear map:\n`(\u2a01 i, L i) \u2192\u2097[R] L'`. If in addition `\u2045f i x, f j y\u2046 = 0` for any `x \u2208 L i` and `y \u2208 L j` (`i \u2260 j`)\nthen this map is a morphism of Lie algebras. -/\n@[simps]\ndef toLieAlgebra [DecidableEq \u03b9] (L' : Type w\u2081) [LieRing L'] [LieAlgebra R L']\n    (f : \u2200 i, L i \u2192\u2097\u2045R\u2046 L') (hf : \u2200 i j : \u03b9, i \u2260 j \u2192 \u2200 (x : L i) (y : L j), \u2045f i x, f j y\u2046 = 0) :\n    (\u2a01 i, L i) \u2192\u2097\u2045R\u2046 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 \u03b9 L' fun i =>\n      (f i : L i \u2192\u2097[R]\n          L') with\n    toFun := toModule R \u03b9 L' fun i => (f i : L i \u2192\u2097[R] L')\n    map_lie' := fun x y => by\n      let f' i := (f i : L i \u2192\u2097[R] L')\n      suffices\n        \u2200 (i : \u03b9) (y : L i),\n          to_module R \u03b9 L' f' \u2045x, of L i y\u2046 =\n            \u2045to_module R \u03b9 L' f' x, to_module R \u03b9 L' f' (of L i y)\u2046\n        by\n        simp only [\u2190 LieAlgebra.ad_apply R]\n        rw [\u2190 LinearMap.comp_apply, \u2190 LinearMap.comp_apply]\n        congr\n        clear y\n        ext (i y)\n        exact this i y\n      suffices\n        \u2200 (i j) (y : L i) (x : L j),\n          to_module R \u03b9 L' f' \u2045of L j x, of L i y\u2046 =\n            \u2045to_module R \u03b9 L' f' (of L j x), to_module R \u03b9 L' f' (of L i y)\u2046\n        by\n        intro i y\n        rw [\u2190 lie_skew x, \u2190 lie_skew (to_module R \u03b9 L' f' x)]\n        simp only [LinearMap.map_neg, neg_inj, \u2190 LieAlgebra.ad_apply R]\n        rw [\u2190 LinearMap.comp_apply, \u2190 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      \u00b7 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      \u00b7 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 : \u03b9 \u2192 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 (\u2a01 i, I i) :=\n  DirectSum.lieRing fun i => \u21a5(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 (\u2a01 i, I i) :=\n  DirectSum.lieAlgebra fun i => \u21a5(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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u211a 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, \u211a, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\nnamespace rat\nvariable {\u03b1 : Type*}\nopen_locale rat\n\nsection with_div_ring\nvariable [division_ring \u03b1]\n\n/-- Construct the canonical injection from `\u211a` 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 \u211a \u03b1 := \u27e8\u03bb r, r.1 / r.2\u27e9\n\ntheorem cast_def (r : \u211a) : (r : \u03b1) = r.num / r.denom := rfl\n\n@[simp] theorem cast_of_int (n : \u2124) : (of_int n : \u03b1) = n :=\nshow (n / (1:\u2115) : \u03b1) = n, by rw [nat.cast_one, div_one]\n\n@[simp, norm_cast] theorem cast_coe_int (n : \u2124) : ((n : \u211a) : \u03b1) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp, norm_cast] theorem cast_coe_nat (n : \u2115) : ((n : \u211a) : \u03b1) = n := cast_coe_int n\n\n@[simp, norm_cast] theorem cast_zero : ((0 : \u211a) : \u03b1) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp, norm_cast] theorem cast_one : ((1 : \u211a) : \u03b1) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem cast_commute (r : \u211a) (a : \u03b1) : commute \u2191r a :=\n(r.1.cast_commute a).div_left (r.2.cast_commute a)\n\ntheorem cast_comm (r : \u211a) (a : \u03b1) : (r : \u03b1) * a = a * r :=\n(cast_commute r a).eq\n\ntheorem commute_cast (a : \u03b1) (r : \u211a) : commute a r :=\n(r.cast_commute a).symm\n\n@[norm_cast] theorem cast_mk_of_ne_zero (a b : \u2124)\n  (b0 : (b:\u03b1) \u2260 0) : (a /. b : \u03b1) = a / b :=\nbegin\n  have b0' : b \u2260 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:\u03b1) \u2260 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:\u2124) \u2223 b, by rwa e at dd) with k ke,\n    have : (b:\u03b1) = (d:\u03b1) * (k:\u03b1), {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 : \u2124 \u2192 \u03b1) ((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 : \u03b1) = n / d,\n  rw [div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq,\n      \u2190 mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\n@[norm_cast] theorem cast_add_of_ne_zero : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m + n : \u211a) : \u03b1) = m + n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', add_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * (d\u2082 * (d\u2082\u207b\u00b9 * d\u2081\u207b\u00b9)) +\n    n\u2082 * (d\u2081 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9 : \u03b1) = n\u2081 * d\u2081\u207b\u00b9 + n\u2082 * d\u2082\u207b\u00b9,\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\u2080, d\u20810, d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820]} },\n  rw [\u2190 mul_assoc (d\u2082:\u03b1), mul_inv_cancel d\u20820, one_mul,\n      (nat.cast_commute _ _).eq], simp [d\u20810, mul_assoc]\nend\n\n@[simp, norm_cast] theorem cast_neg : \u2200 n, ((-n : \u211a) : \u03b1) = -n\n| \u27e8n, d, h, c\u27e9 := show (\u2191-n / d : \u03b1) = -(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 : \u211a}\n  (m0 : (m.denom : \u03b1) \u2260 0) (n0 : (n.denom : \u03b1) \u2260 0) : ((m - n : \u211a) : \u03b1) = m - n :=\nhave ((-n).denom : \u03b1) \u2260 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 : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m * n : \u211a) : \u03b1) = m * n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', mul_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * ((n\u2082 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9) : \u03b1) = n\u2081 * (d\u2081\u207b\u00b9 * (n\u2082 * d\u2082\u207b\u00b9)),\n  { rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero],\n    { simpa [division_def, mul_inv_rev\u2080, d\u20810, d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820]} },\n  rw [(d\u2081.commute_cast (_:\u03b1)).inv_right\u2080.eq]\nend\n\n@[simp] theorem cast_inv_nat (n : \u2115) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\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 : \u2124) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\nbegin\n  cases n,\n  { exact cast_inv_nat _ },\n  { simp only [int.cast_neg_succ_of_nat, \u2190 nat.cast_succ, cast_neg, inv_neg, cast_inv_nat] }\nend\n\n@[norm_cast] theorem cast_inv_of_ne_zero : \u2200 {n : \u211a},\n  (n.num : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9\n| \u27e8n, d, h, c\u27e9 := \u03bb (n0 : (n:\u03b1) \u2260 0) (d0 : (d:\u03b1) \u2260 0), begin\n  have n0' : (n:\u2124) \u2260 0 := \u03bb e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb 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 : \u211a} (md : (m.denom : \u03b1) \u2260 0)\n  (nn : (n.num : \u03b1) \u2260 0) (nd : (n.denom : \u03b1) \u2260 0) : ((m / n : \u211a) : \u03b1) = m / n :=\nhave (n\u207b\u00b9.denom : \u2124) \u2223 n.num,\nby conv in n\u207b\u00b9.denom { rw [\u2190(@num_denom n), inv_def] };\n   apply denom_dvd,\nhave (n\u207b\u00b9.denom : \u03b1) = 0 \u2192 (n.num : \u03b1) = 0, from\n\u03bb h, let \u27e8k, e\u27e9 := this in\n  by have := congr_arg (coe : \u2124 \u2192 \u03b1) 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 \u03b1] : \u2200 {m n : \u211a}, (m : \u03b1) = n \u2194 m = n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := begin\n  refine \u27e8\u03bb h, _, congr_arg _\u27e9,\n  have d\u20810 : d\u2081 \u2260 0 := ne_of_gt h\u2081,\n  have d\u20820 : d\u2082 \u2260 0 := ne_of_gt h\u2082,\n  have d\u2081a : (d\u2081:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20810,\n  have d\u2082a : (d\u2082:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20820,\n  rw [num_denom', num_denom'] at h \u22a2,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d\u20810, d\u20820] at h \u22a2,\n  rwa [eq_div_iff_mul_eq d\u2082a, division_def, mul_assoc, (d\u2081.cast_commute (d\u2082:\u03b1)).inv_left\u2080.eq,\n    \u2190 mul_assoc, \u2190 division_def, eq_comm, eq_div_iff_mul_eq d\u2081a, eq_comm,\n    \u2190 int.cast_coe_nat, \u2190 int.cast_mul, \u2190 int.cast_coe_nat, \u2190 int.cast_mul,\n    int.cast_inj, \u2190 mk_eq (int.coe_nat_ne_zero.2 d\u20810) (int.coe_nat_ne_zero.2 d\u20820)] at h\nend\n\ntheorem cast_injective [char_zero \u03b1] : function.injective (coe : \u211a \u2192 \u03b1)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) = 0 \u2194 n = 0 :=\nby rw [\u2190 cast_zero, cast_inj]\n\ntheorem cast_ne_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) \u2260 0 \u2194 n \u2260 0 :=\nnot_congr cast_eq_zero\n\n@[simp, norm_cast] theorem cast_add [char_zero \u03b1] (m n) :\n  ((m + n : \u211a) : \u03b1) = 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 \u03b1] (m n) :\n  ((m - n : \u211a) : \u03b1) = 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 \u03b1] (m n) :\n  ((m * n : \u211a) : \u03b1) = 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 \u03b1] (n : \u211a) :\n  ((bit0 n : \u211a) : \u03b1) = bit0 n :=\ncast_add _ _\n\n@[simp, norm_cast] theorem cast_bit1 [char_zero \u03b1] (n : \u211a) :\n  ((bit1 n : \u211a) : \u03b1) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\nvariable (\u03b1)\n\n/-- Coercion `\u211a \u2192 \u03b1` as a `ring_hom`. -/\ndef cast_hom [char_zero \u03b1] : \u211a \u2192+* \u03b1 := \u27e8coe, cast_one, cast_mul, cast_zero, cast_add\u27e9\n\nvariable {\u03b1}\n\n@[simp] lemma coe_cast_hom [char_zero \u03b1] : \u21d1(cast_hom \u03b1) = coe := rfl\n\n@[simp, norm_cast] theorem cast_inv [char_zero \u03b1] (n) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\n(cast_hom \u03b1).map_inv _\n\n@[simp, norm_cast] theorem cast_div [char_zero \u03b1] (m n) :\n  ((m / n : \u211a) : \u03b1) = m / n :=\n(cast_hom \u03b1).map_div _ _\n\n@[norm_cast] theorem cast_mk [char_zero \u03b1] (a b : \u2124) : ((a /. b) : \u03b1) = a / b :=\nby simp only [mk_eq_div, cast_div, cast_coe_int]\n\n@[simp, norm_cast] theorem cast_pow [char_zero \u03b1] (q) (k : \u2115) :\n  ((q ^ k : \u211a) : \u03b1) = q ^ k :=\n(cast_hom \u03b1).map_pow q k\n\nend with_div_ring\n\n@[simp, norm_cast] theorem cast_nonneg [linear_ordered_field \u03b1] : \u2200 {n : \u211a}, 0 \u2264 (n : \u03b1) \u2194 0 \u2264 n\n| \u27e8n, d, h, c\u27e9 :=\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 \u03b1] {m n : \u211a} : (m : \u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw [\u2190 sub_nonneg, \u2190 cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp, norm_cast] theorem cast_lt [linear_ordered_field \u03b1] {m n : \u211a} : (m : \u03b1) < n \u2194 m < n :=\nby simpa [-cast_le] using not_congr (@cast_le \u03b1 _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) \u2264 0 \u2194 n \u2264 0 :=\nby rw [\u2190 cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field \u03b1] {n : \u211a} : (0 : \u03b1) < n \u2194 0 < n :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) < 0 \u2194 n < 0 :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp, norm_cast] theorem cast_id : \u2200 n : \u211a, \u2191n = n\n| \u27e8n, d, h, c\u27e9 := by rw [num_denom', cast_mk, mk_eq_div]\n\n@[simp, norm_cast] theorem cast_min [linear_ordered_field \u03b1] {a b : \u211a} :\n  (\u2191(min a b) : \u03b1) = min a b :=\nby by_cases a \u2264 b; simp [h, min_def]\n\n@[simp, norm_cast] theorem cast_max [linear_ordered_field \u03b1] {a b : \u211a} :\n  (\u2191(max a b) : \u03b1) = max a b :=\nby by_cases b \u2264 a; simp [h, max_def]\n\n@[simp, norm_cast] theorem cast_abs [linear_ordered_field \u03b1] {q : \u211a} :\n  ((|q| : \u211a) : \u03b1) = |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 : \u211a \u2192+* k) (r : \u211a) : f r = r :=\ncalc f r = f (r.1 / r.2) : by rw [\u2190 int.cast_coe_nat, \u2190 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 \u2192+* k') (r : \u211a) :\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 : \u211a \u2192+* R) : f = g :=\nbegin\n  ext r,\n  refine rat.num_denom_cases_on' r _,\n  intros a b b0,\n  let \u03c6 : \u2124 \u2192+* R := f.comp (int.cast_ring_hom \u211a),\n  let \u03c8 : \u2124 \u2192+* R := g.comp (int.cast_ring_hom \u211a),\n  rw [rat.mk_eq_div, int.cast_coe_nat],\n  have b0' : (b:\u211a) \u2260 0 := nat.cast_ne_zero.2 b0,\n  have : \u2200 n : \u2124, f n = g n := \u03bb n, show \u03c6 n = \u03c8 n, by rw [\u03c6.ext_int \u03c8],\n  calc f (a * b\u207b\u00b9)\n      = f a * f b\u207b\u00b9 * (g (b:\u2124) * g b\u207b\u00b9) :\n        by rw [int.cast_coe_nat, \u2190 g.map_mul, mul_inv_cancel b0', g.map_one, mul_one, f.map_mul]\n  ... = g a * f b\u207b\u00b9 * (f (b:\u2124) * g b\u207b\u00b9) : by rw [this a, \u2190 this b]\n  ... = g (a * b\u207b\u00b9) :\n        by rw [int.cast_coe_nat, mul_assoc, \u2190 mul_assoc (f b\u207b\u00b9),\n              \u2190 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 (\u211a \u2192+* R) :=\n\u27e8ring_hom.ext_rat\u27e9\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 `\u03c6`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : monoid_with_zero_hom \u211a M}\n  (same_on_int : f.comp (int.cast_ring_hom \u211a).to_monoid_with_zero_hom =\n    g.comp (int.cast_ring_hom \u211a).to_monoid_with_zero_hom) : f = g :=\nbegin\n  have same_on_int' : \u2200 k : \u2124, f k = g k := congr_fun same_on_int,\n  ext x,\n  rw [\u2190 @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 `\u03c6` and its value on `-1` completely determine `\u03c6`. -/\ntheorem ext_rat_on_pnat {f g : monoid_with_zero_hom \u211a M}\n  (same_on_neg_one : f (-1) = g (-1)) (same_on_pnat : \u2200 n : \u2115, 0 < n \u2192 f n = g n) : f = g :=\next_rat $ ext_int' (by simpa) \u2039_\u203a\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 : \u03b1 \u21a0 \u03b2` is *epi* iff for any two morphisms `g\u2081 g\u2082 : \u03b2 \u21a0 \u03b3`, we have\n`g\u2081\u2218f \u2248 g\u2082\u2218f \u2192 g\u2081 \u2248 g\u2082`.\n-/\nsection epi\n  variable\n    {\u2102 : Fam.Cat}\n    {\u03b1 \u03b2 : \u2102.Obj}\n\n  @[simp]\n  abbrev Fam.Cat.Epic.law'\n    (\u2102 : Cat)\n    {\u03b1 \u03b2 : \u2102.Obj}\n    (f : \u03b1 \u21a0 \u03b2)\n  : Prop :=\n    {\u03b3 : \u2102.Obj}\n    \u2192 (g\u2081 g\u2082 : \u03b2 \u21a0 \u03b3)\n    \u2192 (g\u2081 \u229a f) \u2248 (g\u2082 \u229a f)\n    \u2192 g\u2081 \u2248 g\u2082\n\n  class Fam.Cat.Epic\n    (f : \u03b1 \u21a0 \u03b2)\n  where\n    law : Epic.law' \u2102 f\n\n\n  /-- `True` iff `f` is epic. -/\n  def Fam.Cat.isEpic\n    (f : \u03b1 \u21a0 \u03b2)\n    [Epic f]\n  : Prop :=\n    true\nend epi\n\n\n\n/-! ## Monomorphisms\n\nA morphism `f : \u03b2 \u2192 \u03b3` is *monic* iff for any two morphisms `g\u2081 g\u2082 : \u03b1 \u2192 \u03b2`, we have\n`f\u2218g\u2081 \u2248 f\u2218g\u2082 \u2192 g\u2081 \u2248 g\u2082`.\n-/\nsection monic\n  variable\n    {\u2102 : Fam.Cat}\n    {\u03b2 \u03b3 : \u2102.Obj}\n\n  @[simp]\n  abbrev Fam.Cat.Monic.law'\n    (\u2102 : Fam.Cat)\n    {\u03b2 \u03b3 : \u2102.Obj}\n    (f : \u03b2 \u21a0 \u03b3)\n  : Prop :=\n    {\u03b1 : \u2102.Obj}\n    \u2192 (g\u2081 g\u2082 : \u03b1 \u21a0 \u03b2)\n    \u2192 f \u229a g\u2081 \u2248 f \u229a g\u2082\n    \u2192 g\u2081 \u2248 g\u2082\n\n  class Fam.Cat.Monic\n    (f : \u03b1 \u21a0 \u03b2)\n  : Type where\n    law : Monic.law' \u2102 f\n\n  /-- `True` iff `f` is monic. -/\n  def Fam.Cat.isMonic\n    (f : \u03b1 \u21a0 \u03b2)\n    [Monic f]\n  : Prop :=\n    true\nend monic\n\n\n\n/-! ## Isomorphisms\n\nA morphism `f : \u03b1 \u2192 \u03b2` is *iso* iff there is a morphism `f\u207b\u00b9 : \u03b2 \u2192 \u03b1` such that `f\u207b\u00b9 \u2218 f \u2248 id' \u03b2`\nand `f \u2218 f\u207b\u00b9 \u2248 id' \u03b1`.\n-/\nsection iso\n  variable\n    {\u2102 : Fam.Cat}\n    {\u03b1 \u03b2 : \u2102.Obj}\n\n  -- @[simp]\n  -- abbrev Fam.Cat.Iso.law'\n  --   (f : \u03b1 \u21a0 \u03b2)\n  --   (g : \u03b2 \u21a0 \u03b1)\n  -- : Prop :=\n  --   g \u229a f \u2248 \u2102.id\n\n  class Fam.Cat.Iso\n    (f : \u03b1 \u21a0 \u03b2)\n  where\n    inv :\n      \u03b2 \u21a0 \u03b1\n    law_left :\n      f \u229a inv \u2248 \u2102.id\n    law_right :\n      inv \u229a f \u2248 \u2102.id\n\n  abbrev Fam.Cat.isoInv\n    (f : \u03b1 \u21a0 \u03b2)\n    [inst : Iso f]\n  : \u03b2 \u21a0 \u03b1 :=\n    inst.inv\n\n  /-- Turns a `Iso f` into a `Iso inv`. -/\n  instance instIsoSelfInv\n    (f : \u03b1 \u21a0 \u03b2)\n    [inst : Fam.Cat.Iso f]\n  : Fam.Cat.Iso (\u2102.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 : \u03b1 \u21a0 \u03b2)\n    [Iso f]\n  : Prop :=\n    true\nend iso\n\n\n\n/-! Isomorphic objects (`\u2245`, `\\~==`).\n\nTwo objects `\u03b1` and `\u03b2` are *isomorphic* if they are connected by an *iso*-arrow.\n-/\nsection iso_obj\n  variable\n    {\u2102 : Fam.Cat}\n    {\u03b1 \u03b2 : \u2102.Obj}\n\n  /-- Packages the isomorphism. -/\n  class Fam.Cat.IsoObj\n    (\u03b1 \u03b2 : \u2102.Obj)\n  where rawMk ::\n    iso : \u03b1 \u21a0 \u03b2\n    instIso : Iso iso\n\n  /-- Bring `Iso i.iso` whenever we manipulate `i : IsoObj \u03b1 \u03b2`. -/\n  @[simp]\n  instance instIso_of_IsoObj\n    [inst : Fam.Cat.IsoObj \u03b1 \u03b2]\n  : Fam.Cat.Iso (inst.iso) :=\n    inst.instIso\n\n  abbrev Fam.Cat.IsoObj.mk\n    (iso : \u03b1 \u21a0 \u03b2)\n    [instIso : Iso iso]\n  : IsoObj \u03b1 \u03b2 :=\n    \u27e8iso, instIso\u27e9\n\n  /-- `True` iff `\u03b1` and `\u03b2` are isomorphic. -/\n  def Fam.Cat.isIsoObj\n    (\u03b1 \u03b2 : \u2102.Obj)\n    [IsoObj \u03b1 \u03b2]\n  : Prop :=\n    true\n\n  infix:10 \" \u2245 \" =>\n    Fam.Cat.IsoObj\nend iso_obj\n\n\n\n/-! ## Initial objects\n\nAn object `\u03b1` is *initial* iff for any `\u03b2` there exists a **unique** arrow in `\u03b1 \u21a0 \u03b2`.\n-/\nsection initial_obj\n  variable\n    {\u2102 : Fam.Cat}\n\n  class Fam.Cat.Initial\n    (\u03b1 : \u2102.Obj)\n  where\n    arrow {\u03b2 : \u2102.Obj} :\n      \u03b1 \u21a0 \u03b2\n    unique {\u03b2 : \u2102.Obj} (f : \u03b1 \u21a0 \u03b2) :\n      arrow \u2248 f\n\n  /-- If `\u03b1` is initial, then any `\u03b1 \u2192 \u03b1` is actually `id`. -/\n  theorem Fam.Cat.Initial.equivId\n    [inst\u03b1 : Initial \u03b1]\n    (f : \u03b1 \u21a0 \u03b1)\n  : f \u2248 \u2102.id :=\n    let h\u2081 : f \u2248 arrow :=\n      inst\u03b1.unique f\n      |> Setoid.symm\n    let h\u2082 : arrow \u2248 \u2102.id :=\n      inst\u03b1.unique \u2102.id\n    Setoid.trans h\u2081 h\u2082\n\n  /-- `True` iff `\u03b1` is initial. -/\n  def Fam.Cat.isInitial\n    (\u03b1 : \u2102.Obj)\n    [Initial \u03b1]\n  : Prop :=\n    true\nend initial_obj\n\n\n\n/-! ## Terminal objects\n\nAn object `\u03b2` is *terminal* iff for any `\u03b1` there existst a **unique** arrow in `\u03b1 \u21a0 \u03b2`.\n-/\nsection terminal_obj\n  variable\n    {\u2102: Fam.Cat}\n\n  class Fam.Cat.Terminal\n    (\u03b2 : \u2102.Obj)\n  where\n    arrow {\u03b1 : \u2102.Obj} :\n      \u03b1 \u21a0 \u03b2\n    unique {\u03b1 : \u2102.Obj} (f : \u03b1 \u21a0 \u03b2) :\n      arrow \u2248 f\n\n  /-- If `\u03b1` is terminal, then any `\u03b1 \u2192 \u03b1` is actually `id`. -/\n  theorem Fam.Cat.Terminal.equivId\n    [inst\u03b1 : Terminal \u03b1]\n    (f : \u03b1 \u21a0 \u03b1)\n  : f \u2248 \u2102.id :=\n    let h\u2081 : f \u2248 arrow :=\n      inst\u03b1.unique f\n      |> Setoid.symm\n    let h\u2082 : arrow \u2248 \u2102.id :=\n      inst\u03b1.unique \u2102.id\n    Setoid.trans h\u2081 h\u2082\n\n  /-- `True` iff `\u03b2` is terminal. -/\n  def Fam.Cat.isTerminal\n    (\u03b2 : \u2102.Obj)\n    [Terminal \u03b2]\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 \u2227 q \u2192 q \u2227 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 \u2227 q \u2192 q \u2227 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\u2081 u\u2082 u\u2083 v\u2081 v\u2082 v\u2083 u\u2084 v\u2084 u\u2085 v\u2085 \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/--\nIf `\u03b1 : G \u27f6 H` then\n`whisker_left F \u03b1 : (F \u22d9 G) \u27f6 (F \u22d9 H)` has components `\u03b1.app (F.obj X)`.\n-/\n@[simp] theorem whisker_left_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u27f6 H) (X : C) :\n    nat_trans.app (whisker_left F \u03b1) X = nat_trans.app \u03b1 (functor.obj F X) :=\n  Eq.refl (nat_trans.app (whisker_left F \u03b1) X)\n\n/--\nIf `\u03b1 : G \u27f6 H` then\n`whisker_right \u03b1 F : (G \u22d9 F) \u27f6 (G \u22d9 F)` has components `F.map (\u03b1.app X)`.\n-/\ndef whisker_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E]\n    {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u27f6 H) (F : D \u2964 E) : G \u22d9 F \u27f6 H \u22d9 F :=\n  nat_trans.mk fun (X : C) => functor.map F (nat_trans.app \u03b1 X)\n\n/--\nLeft-composition gives a functor `(C \u2964 D) \u2964 ((D \u2964 E) \u2964 (C \u2964 E))`.\n\n`(whiskering_lift.obj F).obj G` is `F \u22d9 G`, and\n`(whiskering_lift.obj F).map \u03b1` is `whisker_left F \u03b1`.\n-/\ndef whiskering_left (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (E : Type u\u2083)\n    [category E] : (C \u2964 D) \u2964 (D \u2964 E) \u2964 C \u2964 E :=\n  functor.mk\n    (fun (F : C \u2964 D) =>\n      functor.mk (fun (G : D \u2964 E) => F \u22d9 G) fun (G H : D \u2964 E) (\u03b1 : G \u27f6 H) => whisker_left F \u03b1)\n    fun (F G : C \u2964 D) (\u03c4 : F \u27f6 G) =>\n      nat_trans.mk fun (H : D \u2964 E) => nat_trans.mk fun (c : C) => functor.map H (nat_trans.app \u03c4 c)\n\n/--\nRight-composition gives a functor `(D \u2964 E) \u2964 ((C \u2964 D) \u2964 (C \u2964 E))`.\n\n`(whiskering_right.obj H).obj F` is `F \u22d9 H`, and\n`(whiskering_right.obj H).map \u03b1` is `whisker_right \u03b1 H`.\n-/\n@[simp] theorem whiskering_right_obj_map (C : Type u\u2081) [category C] (D : Type u\u2082) [category D]\n    (E : Type u\u2083) [category E] (H : D \u2964 E) (_x : C \u2964 D) :\n    \u2200 (_x_1 : C \u2964 D) (\u03b1 : _x \u27f6 _x_1),\n        functor.map (functor.obj (whiskering_right C D E) H) \u03b1 = whisker_right \u03b1 H :=\n  fun (_x_1 : C \u2964 D) (\u03b1 : _x \u27f6 _x_1) =>\n    Eq.refl (functor.map (functor.obj (whiskering_right C D E) H) \u03b1)\n\n@[simp] theorem whisker_left_id {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] (F : C \u2964 D) {G : D \u2964 E} : whisker_left F (nat_trans.id G) = nat_trans.id (F \u22d9 G) :=\n  rfl\n\n@[simp] theorem whisker_left_id' {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] (F : C \u2964 D) {G : D \u2964 E} : whisker_left F \ud835\udfd9 = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem whisker_right_id {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] {G : C \u2964 D} (F : D \u2964 E) :\n    whisker_right (nat_trans.id G) F = nat_trans.id (G \u22d9 F) :=\n  functor.map_id (functor.obj (whiskering_right C D E) F) G\n\n@[simp] theorem whisker_right_id' {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] {G : C \u2964 D} (F : D \u2964 E) : whisker_right \ud835\udfd9 F = \ud835\udfd9 :=\n  functor.map_id (functor.obj (whiskering_right C D E) F) G\n\n@[simp] theorem whisker_left_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} {K : D \u2964 E} (\u03b1 : G \u27f6 H)\n    (\u03b2 : H \u27f6 K) : whisker_left F (\u03b1 \u226b \u03b2) = whisker_left F \u03b1 \u226b whisker_left F \u03b2 :=\n  rfl\n\n@[simp] theorem whisker_right_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} {K : C \u2964 D} (\u03b1 : G \u27f6 H) (\u03b2 : H \u27f6 K)\n    (F : D \u2964 E) : whisker_right (\u03b1 \u226b \u03b2) F = whisker_right \u03b1 F \u226b whisker_right \u03b2 F :=\n  functor.map_comp (functor.obj (whiskering_right C D E) F) \u03b1 \u03b2\n\n/--\nIf `\u03b1 : G \u2245 H` is a natural isomorphism then\n`iso_whisker_left F \u03b1 : (F \u22d9 G) \u2245 (F \u22d9 H)` has components `\u03b1.app (F.obj X)`.\n-/\ndef iso_whisker_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u2245 H) : F \u22d9 G \u2245 F \u22d9 H :=\n  functor.map_iso (functor.obj (whiskering_left C D E) F) \u03b1\n\n@[simp] theorem iso_whisker_left_hom {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u2245 H) :\n    iso.hom (iso_whisker_left F \u03b1) = whisker_left F (iso.hom \u03b1) :=\n  rfl\n\n@[simp] theorem iso_whisker_left_inv {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u2245 H) :\n    iso.inv (iso_whisker_left F \u03b1) = whisker_left F (iso.inv \u03b1) :=\n  rfl\n\n/--\nIf `\u03b1 : G \u2245 H` then\n`iso_whisker_right \u03b1 F : (G \u22d9 F) \u2245 (G \u22d9 F)` has components `F.map_iso (\u03b1.app X)`.\n-/\ndef iso_whisker_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) : G \u22d9 F \u2245 H \u22d9 F :=\n  functor.map_iso (functor.obj (whiskering_right C D E) F) \u03b1\n\n@[simp] theorem iso_whisker_right_hom {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) :\n    iso.hom (iso_whisker_right \u03b1 F) = whisker_right (iso.hom \u03b1) F :=\n  rfl\n\n@[simp] theorem iso_whisker_right_inv {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) :\n    iso.inv (iso_whisker_right \u03b1 F) = whisker_right (iso.inv \u03b1) F :=\n  rfl\n\nprotected instance is_iso_whisker_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u27f6 H) [is_iso \u03b1] :\n    is_iso (whisker_left F \u03b1) :=\n  is_iso.mk (iso.inv (iso_whisker_left F (as_iso \u03b1)))\n\nprotected instance is_iso_whisker_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u27f6 H) (F : D \u2964 E) [is_iso \u03b1] :\n    is_iso (whisker_right \u03b1 F) :=\n  is_iso.mk (iso.inv (iso_whisker_right (as_iso \u03b1) F))\n\n@[simp] theorem whisker_left_twice {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] {B : Type u\u2084} [category B] (F : B \u2964 C) (G : C \u2964 D) {H : D \u2964 E}\n    {K : D \u2964 E} (\u03b1 : H \u27f6 K) : whisker_left F (whisker_left G \u03b1) = whisker_left (F \u22d9 G) \u03b1 :=\n  rfl\n\n@[simp] theorem whisker_right_twice {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {E : Type u\u2083} [category E] {B : Type u\u2084} [category B] {H : B \u2964 C} {K : B \u2964 C} (F : C \u2964 D)\n    (G : D \u2964 E) (\u03b1 : H \u27f6 K) : whisker_right (whisker_right \u03b1 F) G = whisker_right \u03b1 (F \u22d9 G) :=\n  rfl\n\ntheorem whisker_right_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] {B : Type u\u2084} [category B] (F : B \u2964 C) {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u27f6 H)\n    (K : D \u2964 E) : whisker_right (whisker_left F \u03b1) K = whisker_left F (whisker_right \u03b1 K) :=\n  rfl\n\nnamespace functor\n\n\n/--\nThe left unitor, a natural isomorphism `((\ud835\udfed _) \u22d9 F) \u2245 F`.\n-/\n@[simp] theorem left_unitor_hom_app {A : Type u\u2081} [category A] {B : Type u\u2082} [category B]\n    (F : A \u2964 B) (X : A) : nat_trans.app (iso.hom (left_unitor F)) X = \ud835\udfd9 :=\n  Eq.refl (nat_trans.app (iso.hom (left_unitor F)) X)\n\n/--\nThe right unitor, a natural isomorphism `(F \u22d9 (\ud835\udfed B)) \u2245 F`.\n-/\n@[simp] theorem right_unitor_hom_app {A : Type u\u2081} [category A] {B : Type u\u2082} [category B]\n    (F : A \u2964 B) (X : A) : nat_trans.app (iso.hom (right_unitor F)) X = \ud835\udfd9 :=\n  Eq.refl (nat_trans.app (iso.hom (right_unitor F)) X)\n\n/--\nThe associator for functors, a natural isomorphism `((F \u22d9 G) \u22d9 H) \u2245 (F \u22d9 (G \u22d9 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\u2081} [category A] {B : Type u\u2082} [category B]\n    {C : Type u\u2083} [category C] {D : Type u\u2084} [category D] (F : A \u2964 B) (G : B \u2964 C) (H : C \u2964 D)\n    (_x : A) : nat_trans.app (iso.inv (associator F G H)) _x = \ud835\udfd9 :=\n  Eq.refl (nat_trans.app (iso.inv (associator F G H)) _x)\n\ntheorem triangle {A : Type u\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083} [category C]\n    (F : A \u2964 B) (G : B \u2964 C) :\n    iso.hom (associator F \ud835\udfed G) \u226b 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\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083} [category C]\n    {D : Type u\u2084} [category D] {E : Type u\u2085} [category E] (F : A \u2964 B) (G : B \u2964 C) (H : C \u2964 D)\n    (K : D \u2964 E) :\n    whisker_right (iso.hom (associator F G H)) K \u226b\n          iso.hom (associator F (G \u22d9 H) K) \u226b whisker_left F (iso.hom (associator G H K)) =\n        iso.hom (associator (F \u22d9 G) H K) \u226b iso.hom (associator F G (H \u22d9 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 \u03b1 \u03c3` is a realization of a topology (basis) on `\u03b1`,\n  represented by a type `\u03c3` together with operations for the top element and\n  the intersection operation. -/\nstructure ctop (\u03b1 \u03c3 : Type*) :=\n(f : \u03c3 \u2192 set \u03b1)\n(top : \u03b1 \u2192 \u03c3)\n(top_mem : \u2200 x : \u03b1, x \u2208 f (top x))\n(inter : \u03a0 a b (x : \u03b1), x \u2208 f a \u2229 f b \u2192 \u03c3)\n(inter_mem : \u2200 a b x h, x \u2208 f (inter a b x h))\n(inter_sub : \u2200 a b x h, f (inter a b x h) \u2286 f a \u2229 f b)\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03c3 : Type*} {\u03c4 : Type*}\n\nnamespace ctop\nsection\nvariables (F : ctop \u03b1 \u03c3)\n\ninstance : has_coe_to_fun (ctop \u03b1 \u03c3) (\u03bb _, \u03c3 \u2192 set \u03b1) := \u27e8ctop.f\u27e9\n\n@[simp] theorem coe_mk (f T h\u2081 I h\u2082 h\u2083 a) : (@ctop.mk \u03b1 \u03c3 f T h\u2081 I h\u2082 h\u2083) a = f a := rfl\n\n/-- Map a ctop to an equivalent representation type. -/\ndef of_equiv (E : \u03c3 \u2243 \u03c4) : ctop \u03b1 \u03c3 \u2192 ctop \u03b1 \u03c4\n| \u27e8f, T, h\u2081, I, h\u2082, h\u2083\u27e9 :=\n  { f         := \u03bb a, f (E.symm a),\n    top       := \u03bb x, E (T x),\n    top_mem   := \u03bb x, by simpa using h\u2081 x,\n    inter     := \u03bb a b x h, E (I (E.symm a) (E.symm b) x h),\n    inter_mem := \u03bb a b x h, by simpa using h\u2082 (E.symm a) (E.symm b) x h,\n    inter_sub := \u03bb a b x h, by simpa using h\u2083 (E.symm a) (E.symm b) x h }\n\n@[simp] theorem of_equiv_val (E : \u03c3 \u2243 \u03c4) (F : ctop \u03b1 \u03c3) (a : \u03c4) :\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 \u03b1 \u03c3) : topological_space \u03b1 :=\ntopological_space.generate_from (set.range F.f)\n\ntheorem to_topsp_is_topological_basis (F : ctop \u03b1 \u03c3) :\n  @topological_space.is_topological_basis _ F.to_topsp (set.range F.f) :=\nby letI := F.to_topsp; exact\n\u27e8\u03bb u \u27e8a, e\u2081\u27e9 v \u27e8b, e\u2082\u27e9, e\u2081 \u25b8 e\u2082 \u25b8\n   \u03bb x h, \u27e8_, \u27e8_, rfl\u27e9, F.inter_mem a b x h, F.inter_sub a b x h\u27e9,\neq_univ_iff_forall.2 $ \u03bb x, \u27e8_, \u27e8_, rfl\u27e9, F.top_mem x\u27e9, rfl\u27e9\n\n@[simp] theorem mem_nhds_to_topsp (F : ctop \u03b1 \u03c3) {s : set \u03b1} {a : \u03b1} :\n  s \u2208 @nhds _ F.to_topsp a \u2194 \u2203 b, a \u2208 F b \u2227 F b \u2286 s :=\n(@topological_space.is_topological_basis.mem_nhds_iff\n  _ F.to_topsp _ _ _ F.to_topsp_is_topological_basis).trans $\n\u27e8\u03bb \u27e8_, \u27e8x, rfl\u27e9, h\u27e9, \u27e8x, h\u27e9, \u03bb \u27e8x, h\u27e9, \u27e8_, \u27e8x, rfl\u27e9, h\u27e9\u27e9\n\nend ctop\n\n/-- A `ctop` realizer for the topological space `T` is a `ctop`\n  which generates `T`. -/\nstructure ctop.realizer (\u03b1) [T : topological_space \u03b1] :=\n(\u03c3 : Type*)\n(F : ctop \u03b1 \u03c3)\n(eq : F.to_topsp = T)\nopen ctop\n\nprotected def ctop.to_realizer (F : ctop \u03b1 \u03c3) : @ctop.realizer _ F.to_topsp :=\n@ctop.realizer.mk _ F.to_topsp \u03c3 F rfl\n\nnamespace ctop.realizer\n\nprotected theorem is_basis [T : topological_space \u03b1] (F : realizer \u03b1) :\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 \u03b1] (F : realizer \u03b1) {s : set \u03b1} {a : \u03b1} :\n  s \u2208 \ud835\udcdd a \u2194 \u2203 b, a \u2208 F.F b \u2227 F.F b \u2286 s :=\nby have := mem_nhds_to_topsp F.F; rwa F.eq at this\n\ntheorem is_open_iff [topological_space \u03b1] (F : realizer \u03b1) {s : set \u03b1} :\n  is_open s \u2194 \u2200 a \u2208 s, \u2203 b, a \u2208 F.F b \u2227 F.F b \u2286 s :=\nis_open_iff_mem_nhds.trans $ ball_congr $ \u03bb a h, F.mem_nhds\n\ntheorem is_closed_iff [topological_space \u03b1] (F : realizer \u03b1) {s : set \u03b1} :\n  is_closed s \u2194 \u2200 a, (\u2200 b, a \u2208 F.F b \u2192 \u2203 z, z \u2208 F.F b \u2229 s) \u2192 a \u2208 s :=\nis_open_compl_iff.symm.trans $ F.is_open_iff.trans $ forall_congr $ \u03bb a,\nshow (a \u2209 s \u2192 (\u2203 (b : F.\u03c3), a \u2208 F.F b \u2227 \u2200 z \u2208 F.F b, z \u2209 s)) \u2194 _,\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 \u03b1] (F : realizer \u03b1) {s : set \u03b1} {a : \u03b1} :\n  a \u2208 interior s \u2194 \u2203 b, a \u2208 F.F b \u2227 F.F b \u2286 s :=\nmem_interior_iff_mem_nhds.trans F.mem_nhds\n\nprotected theorem is_open [topological_space \u03b1] (F : realizer \u03b1) (s : F.\u03c3) : is_open (F.F s) :=\nis_open_iff_nhds.2 $ \u03bb a m, by simpa using F.mem_nhds.2 \u27e8s, m, subset.refl _\u27e9\n\n\n\ntheorem ext [T : topological_space \u03b1] {\u03c3 : Type*} {F : ctop \u03b1 \u03c3}\n  (H\u2081 : \u2200 a, is_open (F a))\n  (H\u2082 : \u2200 a s, s \u2208 \ud835\udcdd a \u2192 \u2203 b, a \u2208 F b \u2227 F b \u2286 s) :\n  F.to_topsp = T :=\next' $ \u03bb a s, \u27e8H\u2082 a s, \u03bb \u27e8b, h\u2081, h\u2082\u27e9, mem_nhds_iff.2 \u27e8_, h\u2082, H\u2081 _, h\u2081\u27e9\u27e9\n\nvariable [topological_space \u03b1]\n\nprotected def id : realizer \u03b1 := \u27e8{x:set \u03b1 // is_open x},\n{ f            := subtype.val,\n  top          := \u03bb _, \u27e8univ, is_open_univ\u27e9,\n  top_mem      := mem_univ,\n  inter        := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a h\u2083, \u27e8_, h\u2081.inter h\u2082\u27e9,\n  inter_mem    := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a, id,\n  inter_sub    := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a h\u2083, subset.refl _ },\next subtype.property $ \u03bb x s h,\n  let \u27e8t, h, o, m\u27e9 := mem_nhds_iff.1 h in \u27e8\u27e8t, o\u27e9, m, h\u27e9\u27e9\n\ndef of_equiv (F : realizer \u03b1) (E : F.\u03c3 \u2243 \u03c4) : realizer \u03b1 :=\n\u27e8\u03c4, F.F.of_equiv E, ext' (\u03bb a s, F.mem_nhds.trans $\n \u27e8\u03bb \u27e8s, h\u27e9, \u27e8E s, by simpa using h\u27e9, \u03bb \u27e8t, h\u27e9, \u27e8E.symm t, by simpa using h\u27e9\u27e9)\u27e9\n\n@[simp] theorem of_equiv_\u03c3 (F : realizer \u03b1) (E : F.\u03c3 \u2243 \u03c4) : (F.of_equiv E).\u03c3 = \u03c4 := rfl\n@[simp] theorem of_equiv_F (F : realizer \u03b1) (E : F.\u03c3 \u2243 \u03c4) (s : \u03c4) :\n  (F.of_equiv E).F s = F.F (E.symm s) := by delta of_equiv; simp\n\nprotected def nhds (F : realizer \u03b1) (a : \u03b1) : (\ud835\udcdd a).realizer :=\n\u27e8{s : F.\u03c3 // a \u2208 F.F s},\n{ f            := \u03bb s, F.F s.1,\n  pt           := \u27e8_, F.F.top_mem a\u27e9,\n  inf          := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9, \u27e8_, F.F.inter_mem x y a \u27e8h\u2081, h\u2082\u27e9\u27e9,\n  inf_le_left  := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 z h, (F.F.inter_sub x y a \u27e8h\u2081, h\u2082\u27e9 h).1,\n  inf_le_right := \u03bb \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 z h, (F.F.inter_sub x y a \u27e8h\u2081, h\u2082\u27e9 h).2 },\nfilter_eq $ set.ext $ \u03bb x,\n\u27e8\u03bb \u27e8\u27e8s, as\u27e9, h\u27e9, mem_nhds_iff.2 \u27e8_, h, F.is_open _, as\u27e9,\n \u03bb h, let \u27e8s, h, as\u27e9 := F.mem_nhds.1 h in \u27e8\u27e8s, h\u27e9, as\u27e9\u27e9\u27e9\n\n@[simp] theorem nhds_\u03c3 (m : \u03b1 \u2192 \u03b2) (F : realizer \u03b1) (a : \u03b1) :\n  (F.nhds a).\u03c3 = {s : F.\u03c3 // a \u2208 F.F s} := rfl\n@[simp] theorem nhds_F (m : \u03b1 \u2192 \u03b2) (F : realizer \u03b1) (a : \u03b1) (s) :\n  (F.nhds a).F s = F.F s.1 := rfl\n\ntheorem tendsto_nhds_iff {m : \u03b2 \u2192 \u03b1} {f : filter \u03b2} (F : f.realizer) (R : realizer \u03b1) {a : \u03b1} :\n  tendsto m f (\ud835\udcdd a) \u2194 \u2200 t, a \u2208 R.F t \u2192 \u2203 s, \u2200 x \u2208 F.F s, m x \u2208 R.F t :=\n(F.tendsto_iff _ (R.nhds a)).trans subtype.forall\n\nend ctop.realizer\n\nstructure locally_finite.realizer [topological_space \u03b1] (F : realizer \u03b1) (f : \u03b2 \u2192 set \u03b1) :=\n(bas : \u2200 a, {s // a \u2208 F.F s})\n(sets : \u2200 x:\u03b1, fintype {i | (f i \u2229 F.F (bas x)).nonempty})\n\ntheorem locally_finite.realizer.to_locally_finite [topological_space \u03b1]\n  {F : realizer \u03b1} {f : \u03b2 \u2192 set \u03b1} (R : locally_finite.realizer F f) :\n  locally_finite f :=\n\u03bb a, \u27e8_, F.mem_nhds.2\n  \u27e8(R.bas a).1, (R.bas a).2, subset.refl _\u27e9, \u27e8R.sets a\u27e9\u27e9\n\ntheorem locally_finite_iff_exists_realizer [topological_space \u03b1]\n  (F : realizer \u03b1) {f : \u03b2 \u2192 set \u03b1} : locally_finite f \u2194 nonempty (locally_finite.realizer F f) :=\n\u27e8\u03bb h, let \u27e8g, h\u2081\u27e9 := classical.axiom_of_choice h,\n    \u27e8g\u2082, h\u2082\u27e9 := classical.axiom_of_choice (\u03bb x,\n       show \u2203 (b : F.\u03c3), x \u2208 (F.F) b \u2227 (F.F) b \u2286 g x, from\n       let \u27e8h, h'\u27e9 := h\u2081 x in F.mem_nhds.1 h) in\n  \u27e8\u27e8\u03bb x, \u27e8g\u2082 x, (h\u2082 x).1\u27e9, \u03bb x, finite.fintype $\n    let \u27e8h, h'\u27e9 := h\u2081 x in h'.subset $ \u03bb i hi,\n    hi.mono (inter_subset_inter_right _ (h\u2082 x).2)\u27e9\u27e9,\n \u03bb \u27e8R\u27e9, R.to_locally_finite\u27e9\n\ndef compact.realizer [topological_space \u03b1] (R : realizer \u03b1) (s : set \u03b1) :=\n\u2200 {f : filter \u03b1} (F : f.realizer) (x : F.\u03c3), f \u2260 \u22a5 \u2192\n  F.F x \u2286 s \u2192 {a // a\u2208s \u2227 \ud835\udcdd a \u2293 f \u2260 \u22a5}\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 {\u03b9 : Type*}\nvariables {V : Type u} [category.{v} V] [preadditive V]\n\nvariables {c : complex_shape \u03b9} {C D E : homological_complex V c}\nvariables (f g : C \u27f6 D) (h k : D \u27f6 E) (i : \u03b9)\n\nsection\n\n/-- The composition of `C.d i i' \u226b f i' i` if there is some `i'` coming after `i`,\nand `0` otherwise. -/\ndef d_next (i : \u03b9) : (\u03a0 i j, C.X i \u27f6 D.X j) \u2192+ (C.X i \u27f6 D.X i) :=\nadd_monoid_hom.mk' (\u03bb f, C.d i (c.next i) \u226b f (c.next i) i) $\n\u03bb 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 : \u03b9) : (\u03a0 i j, C.X i \u27f6 D.X j) \u2192+ (C.X_next i \u27f6 D.X i) :=\nadd_monoid_hom.mk' (\u03bb f, f (c.next i) i) $ \u03bb f g, rfl\n\n@[simp]\nlemma d_next_eq_d_from_from_next (f : \u03a0 i j, C.X i \u27f6 D.X j) (i : \u03b9) :\n  d_next i f = C.d_from i \u226b from_next i f := rfl\n\nlemma d_next_eq (f : \u03a0 i j, C.X i \u27f6 D.X j) {i i' : \u03b9} (w : c.rel i i') :\n  d_next i f = C.d i i' \u226b f i' i :=\nby { obtain rfl := c.next_eq' w, refl }\n\n@[simp] lemma d_next_comp_left (f : C \u27f6 D) (g : \u03a0 i j, D.X i \u27f6 E.X j) (i : \u03b9) :\n  d_next i (\u03bb i j, f.f i \u226b g i j) = f.f i \u226b d_next i g :=\n(f.comm_assoc _ _ _).symm\n\n@[simp] lemma d_next_comp_right (f : \u03a0 i j, C.X i \u27f6 D.X j) (g : D \u27f6 E) (i : \u03b9) :\n  d_next i (\u03bb i j, f i j \u226b g.f j) = d_next i f \u226b g.f i :=\n(category.assoc _ _ _).symm\n\n/-- The composition of `f j j' \u226b D.d j' j` if there is some `j'` coming before `j`,\nand `0` otherwise. -/\ndef prev_d (j : \u03b9) : (\u03a0 i j, C.X i \u27f6 D.X j) \u2192+ (C.X j \u27f6 D.X j) :=\nadd_monoid_hom.mk' (\u03bb f, f j (c.prev j) \u226b D.d (c.prev j) j) $\n\u03bb 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 : \u03b9) : (\u03a0 i j, C.X i \u27f6 D.X j) \u2192+ (C.X j \u27f6 D.X_prev j) :=\nadd_monoid_hom.mk' (\u03bb f, f j (c.prev j)) $ \u03bb f g, rfl\n\n@[simp]\nlemma prev_d_eq_to_prev_d_to (f : \u03a0 i j, C.X i \u27f6 D.X j) (j : \u03b9) :\n  prev_d j f = to_prev j f \u226b D.d_to j := rfl\n\nlemma prev_d_eq (f : \u03a0 i j, C.X i \u27f6 D.X j) {j j' : \u03b9} (w : c.rel j' j) :\n  prev_d j f = f j j' \u226b D.d j' j :=\nby { obtain rfl := c.prev_eq' w, refl }\n\n@[simp] lemma prev_d_comp_left (f : C \u27f6 D) (g : \u03a0 i j, D.X i \u27f6 E.X j) (j : \u03b9) :\n  prev_d j (\u03bb i j, f.f i \u226b g i j) = f.f j \u226b prev_d j g :=\ncategory.assoc _ _ _\n\n@[simp] lemma prev_d_comp_right (f : \u03a0 i j, C.X i \u27f6 D.X j) (g : D \u27f6 E) (j : \u03b9) :\n  prev_d j (\u03bb i j, f i j \u226b g.f j) = prev_d j f \u226b g.f j :=\nby { dsimp [prev_d], simp only [category.assoc, g.comm] }\n\nlemma d_next_nat (C D : chain_complex V \u2115) (i : \u2115) (f : \u03a0 i j, C.X i \u27f6 D.X j) :\n  d_next i f = C.d i (i-1) \u226b 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 \u2115).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 \u2115) (i : \u2115) (f : \u03a0 i j, C.X i \u27f6 D.X j) :\n  prev_d i f = f i (i-1) \u226b 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 \u2115).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 \u27f6 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 \u27f6 D) :=\n(hom : \u03a0 i j, C.X i \u27f6 D.X j)\n(zero' : \u2200 i j, \u00ac c.rel j i \u2192 hom i j = 0 . obviously)\n(comm : \u2200 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 \u2243 homotopy (f - g) 0 :=\n{ to_fun := \u03bb h,\n  { hom := \u03bb i j, h.hom i j,\n    zero' := \u03bb i j w, h.zero _ _ w,\n    comm := \u03bb i, by simp [h.comm] },\n  inv_fun := \u03bb h,\n  { hom := \u03bb i j, h.hom i j,\n    zero' := \u03bb i j w, h.zero _ _ w,\n    comm := \u03bb 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' := \u03bb _ _ _, rfl,\n  comm := \u03bb _, 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 \u27f6 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 \u27f6 D} (h : homotopy f g) : homotopy g f :=\n{ hom := -h.hom,\n  zero' := \u03bb i j w, by rw [pi.neg_apply, pi.neg_apply, h.zero i j w, neg_zero],\n  comm := \u03bb i, by rw [add_monoid_hom.map_neg, add_monoid_hom.map_neg, h.comm, \u2190 neg_add,\n      \u2190 add_assoc, neg_add_self, zero_add] }\n\n/-- homotopy is a transitive relation. -/\n@[simps, trans]\ndef trans {e f g : C \u27f6 D} (h : homotopy e f) (k : homotopy f g) : homotopy e g :=\n{ hom := h.hom + k.hom,\n  zero' := \u03bb 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 := \u03bb 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\u2081 g\u2081 f\u2082 g\u2082 : C \u27f6 D}\n  (h\u2081 : homotopy f\u2081 g\u2081) (h\u2082 : homotopy f\u2082 g\u2082) : homotopy (f\u2081+f\u2082) (g\u2081+g\u2082) :=\n{ hom := h\u2081.hom + h\u2082.hom,\n  zero' := \u03bb i j hij, by\n    rw [pi.add_apply, pi.add_apply, h\u2081.zero' i j hij, h\u2082.zero' i j hij, add_zero],\n  comm := \u03bb i, by\n    { simp only [homological_complex.add_f_apply, h\u2081.comm, h\u2082.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 \u27f6 D} (h : homotopy e f) (g : D \u27f6 E) : homotopy (e \u226b g) (f \u226b g) :=\n{ hom := \u03bb i j, h.hom i j \u226b g.f j,\n  zero' := \u03bb i j w, by rw [h.zero i j w, zero_comp],\n  comm := \u03bb 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 \u27f6 E} (h : homotopy f g) (e : C \u27f6 D) : homotopy (e \u226b f) (e \u226b g) :=\n{ hom := \u03bb i j, e.f i \u226b h.hom i j,\n  zero' := \u03bb i j w, by rw [h.zero i j w, comp_zero],\n  comm := \u03bb 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\u2081 C\u2082 C\u2083 : homological_complex V c} {f\u2081 g\u2081 : C\u2081 \u27f6 C\u2082} {f\u2082 g\u2082 : C\u2082 \u27f6 C\u2083}\n  (h\u2081 : homotopy f\u2081 g\u2081) (h\u2082 : homotopy f\u2082 g\u2082) : homotopy (f\u2081 \u226b f\u2082) (g\u2081 \u226b g\u2082) :=\n(h\u2081.comp_right _).trans (h\u2082.comp_left _)\n\n/-- a variant of `homotopy.comp_right` useful for dealing with homotopy equivalences. -/\n@[simps]\ndef comp_right_id {f : C \u27f6 C} (h : homotopy f (\ud835\udfd9 C)) (g : C \u27f6 D) : homotopy (f \u226b 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 \u27f6 D} (h : homotopy f (\ud835\udfd9 D)) (g : C \u27f6 D) : homotopy (g \u226b 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 \u27f6 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 \u27f6 C_j` when `c.rel j i`. -/\ndef null_homotopic_map (hom : \u03a0 i j, C.X i \u27f6 D.X j) : C \u27f6 D :=\n{ f      := \u03bb i, d_next i hom + prev_d i hom,\n  comm'  := \u03bb i j hij,\n  begin\n    have eq1 : prev_d i hom \u226b 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 \u226b 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 \u27f6 D_j` such that `c.rel j i`. -/\ndef null_homotopic_map' (h : \u03a0 i j, c.rel j i \u2192 (C.X i \u27f6 D.X j)) : C \u27f6 D :=\nnull_homotopic_map (\u03bb i j, dite (c.rel j i) (h i j) (\u03bb _, 0))\n\n/-- Compatibility of `null_homotopic_map` with the postcomposition by a morphism\nof complexes. -/\nlemma null_homotopic_map_comp (hom : \u03a0 i j, C.X i \u27f6 D.X j) (g : D \u27f6 E) :\nnull_homotopic_map hom \u226b g = null_homotopic_map (\u03bb i j, hom i j \u226b 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 : \u03a0 i j, c.rel j i \u2192 (C.X i \u27f6 D.X j)) (g : D \u27f6 E) :\nnull_homotopic_map' hom \u226b g = null_homotopic_map' (\u03bb i j hij, hom i j hij \u226b 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 \u27f6 D) (hom : \u03a0 i j, D.X i \u27f6 E.X j) :\nf \u226b null_homotopic_map hom = null_homotopic_map (\u03bb i j, f.f i \u226b 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 \u27f6 D) (hom : \u03a0 i j, c.rel j i \u2192 (D.X i \u27f6 E.X j)) :\nf \u226b null_homotopic_map' hom = null_homotopic_map' (\u03bb i j hij, f.f i \u226b 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 \u2964 W) [G.additive] (hom : \u03a0 i j, C.X i \u27f6 D.X j) :\n  (G.map_homological_complex c).map (null_homotopic_map hom) =\n  null_homotopic_map (\u03bb 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 \u2964 W) [G.additive] (hom : \u03a0 i j, c.rel j i \u2192 (C.X i \u27f6 D.X j)) :\n  (G.map_homological_complex c).map (null_homotopic_map' hom) =\n  null_homotopic_map' (\u03bb 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 : \u03a0 i j, C.X i \u27f6 D.X j) (zero' : \u2200 i j, \u00ac c.rel j i \u2192 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 : \u03a0 i j, c.rel j i \u2192 (C.X i \u27f6 D.X j)) :\n  homotopy (null_homotopic_map' h) 0 :=\nbegin\n  apply null_homotopy (\u03bb i j, dite (c.rel j i) (h i j) (\u03bb _, 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\u2082 k\u2081 k\u2080 : \u03b9} (r\u2082\u2081 : c.rel k\u2082 k\u2081) (r\u2081\u2080 : c.rel k\u2081 k\u2080)\n  (hom : \u03a0 i j, C.X i \u27f6 D.X j) :\n  (null_homotopic_map hom).f k\u2081 = C.d k\u2081 k\u2080 \u226b hom k\u2080 k\u2081 + hom k\u2081 k\u2082 \u226b D.d k\u2082 k\u2081 :=\nby { dsimp only [null_homotopic_map], rw [d_next_eq hom r\u2081\u2080, prev_d_eq hom r\u2082\u2081], }\n\n@[simp]\nlemma null_homotopic_map'_f {k\u2082 k\u2081 k\u2080  : \u03b9} (r\u2082\u2081 : c.rel k\u2082 k\u2081) (r\u2081\u2080 : c.rel k\u2081 k\u2080)\n  (h : \u03a0 i j, c.rel j i \u2192 (C.X i \u27f6 D.X j)) :\n  (null_homotopic_map' h).f k\u2081 = C.d k\u2081 k\u2080 \u226b h k\u2080 k\u2081 r\u2081\u2080 + h k\u2081 k\u2082 r\u2082\u2081 \u226b D.d k\u2082 k\u2081 :=\nbegin\n  simp only [\u2190 null_homotopic_map'],\n  rw null_homotopic_map_f r\u2082\u2081 r\u2081\u2080 (\u03bb i j, dite (c.rel j i) (h i j) (\u03bb _, 0)),\n  dsimp,\n  split_ifs,\n  refl,\nend\n\n@[simp]\nlemma null_homotopic_map_f_of_not_rel_left {k\u2081 k\u2080 : \u03b9} (r\u2081\u2080 : c.rel k\u2081 k\u2080)\n  (hk\u2080 : \u2200 l : \u03b9, \u00acc.rel k\u2080 l)\n  (hom : \u03a0 i j, C.X i \u27f6 D.X j) :\n  (null_homotopic_map hom).f k\u2080 = hom k\u2080 k\u2081 \u226b D.d k\u2081 k\u2080 :=\nbegin\n  dsimp only [null_homotopic_map],\n  rw [prev_d_eq hom r\u2081\u2080, d_next, add_monoid_hom.mk'_apply, C.shape, zero_comp, zero_add],\n  exact hk\u2080 _\nend\n\n@[simp]\nlemma null_homotopic_map'_f_of_not_rel_left {k\u2081 k\u2080 : \u03b9} (r\u2081\u2080 : c.rel k\u2081 k\u2080)\n  (hk\u2080 : \u2200 l : \u03b9, \u00acc.rel k\u2080 l)\n  (h : \u03a0 i j, c.rel j i \u2192 (C.X i \u27f6 D.X j)) :\n  (null_homotopic_map' h).f k\u2080 = h k\u2080 k\u2081 r\u2081\u2080 \u226b D.d k\u2081 k\u2080 :=\nbegin\n  simp only [\u2190 null_homotopic_map'],\n  rw null_homotopic_map_f_of_not_rel_left r\u2081\u2080 hk\u2080 (\u03bb i j, dite (c.rel j i) (h i j) (\u03bb _, 0)),\n  dsimp,\n  split_ifs,\n  refl,\nend\n\n@[simp]\nlemma null_homotopic_map_f_of_not_rel_right {k\u2081 k\u2080 : \u03b9} (r\u2081\u2080 : c.rel k\u2081 k\u2080)\n  (hk\u2081 : \u2200 l : \u03b9, \u00acc.rel l k\u2081)\n  (hom : \u03a0 i j, C.X i \u27f6 D.X j) :\n  (null_homotopic_map hom).f k\u2081 = C.d k\u2081 k\u2080 \u226b hom k\u2080 k\u2081 :=\nbegin\n  dsimp only [null_homotopic_map],\n  rw [d_next_eq hom r\u2081\u2080, prev_d, add_monoid_hom.mk'_apply, D.shape, comp_zero, add_zero],\n  exact hk\u2081 _,\nend\n\n@[simp]\nlemma null_homotopic_map'_f_of_not_rel_right {k\u2081 k\u2080 : \u03b9} (r\u2081\u2080 : c.rel k\u2081 k\u2080)\n  (hk\u2081 : \u2200 l : \u03b9, \u00acc.rel l k\u2081)\n  (h : \u03a0 i j, c.rel j i \u2192 (C.X i \u27f6 D.X j)) :\n  (null_homotopic_map' h).f k\u2081 = C.d k\u2081 k\u2080 \u226b h k\u2080 k\u2081 r\u2081\u2080 :=\nbegin\n  simp only [\u2190 null_homotopic_map'],\n  rw null_homotopic_map_f_of_not_rel_right r\u2081\u2080 hk\u2081 (\u03bb i j, dite (c.rel j i) (h i j) (\u03bb _, 0)),\n  dsimp,\n  split_ifs,\n  refl,\nend\n\n@[simp]\nlemma null_homotopic_map_f_eq_zero {k\u2080 : \u03b9}\n  (hk\u2080 : \u2200 l : \u03b9, \u00acc.rel k\u2080 l) (hk\u2080' : \u2200 l : \u03b9, \u00acc.rel l k\u2080)\n  (hom : \u03a0 i j, C.X i \u27f6 D.X j) :\n  (null_homotopic_map hom).f k\u2080 = 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\u2080 : \u03b9}\n  (hk\u2080 : \u2200 l : \u03b9, \u00acc.rel k\u2080 l) (hk\u2080' : \u2200 l : \u03b9, \u00acc.rel l k\u2080)\n  (h : \u03a0 i j, c.rel j i \u2192 (C.X i \u27f6 D.X j)) :\n  (null_homotopic_map' h).f k\u2080 = 0 :=\nbegin\n  simp only [\u2190 null_homotopic_map'],\n  exact null_homotopic_map_f_eq_zero hk\u2080 hk\u2080'\n    (\u03bb i j, dite (c.rel j i) (h i j) (\u03bb _, 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 \u2115}\n\n@[simp] lemma prev_d_chain_complex (f : \u03a0 i j, P.X i \u27f6 Q.X j) (j : \u2115) :\n  prev_d j f = f j (j+1) \u226b Q.d _ _ :=\nbegin\n  dsimp [prev_d],\n  have : (complex_shape.down \u2115).prev j = j + 1 := chain_complex.prev \u2115 j,\n  congr' 2,\nend\n\n@[simp] lemma d_next_succ_chain_complex (f : \u03a0 i j, P.X i \u27f6 Q.X j) (i : \u2115) :\n  d_next (i+1) f = P.d _ _ \u226b f i (i+1) :=\nbegin\n  dsimp [d_next],\n  have : (complex_shape.down \u2115).next (i + 1) = i := chain_complex.next_nat_succ _,\n  congr' 2,\nend\n\n@[simp] lemma d_next_zero_chain_complex (f : \u03a0 i j, P.X i \u27f6 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 \u27f6 Q)\n  (zero : P.X 0 \u27f6 Q.X 1)\n  (comm_zero : e.f 0 = zero \u226b Q.d 1 0)\n  (one : P.X 1 \u27f6 Q.X 2)\n  (comm_one : e.f 1 = P.d 1 0 \u226b zero + one \u226b Q.d 2 1)\n  (succ : \u2200 (n : \u2115)\n    (p : \u03a3' (f : P.X n \u27f6 Q.X (n+1)) (f' : P.X (n+1) \u27f6 Q.X (n+2)),\n      e.f (n+1) = P.d (n+1) n \u226b f + f' \u226b Q.d (n+2) (n+1)),\n    \u03a3' f'' : P.X (n+2) \u27f6 Q.X (n+3), e.f (n+2) = P.d (n+2) (n+1) \u226b p.2.1 + f'' \u226b 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\u2082`.\n-/\n@[simp, nolint unused_arguments]\ndef mk_inductive_aux\u2081 :\n  \u03a0 n, \u03a3' (f : P.X n \u27f6 Q.X (n+1)) (f' : P.X (n+1) \u27f6 Q.X (n+2)),\n    e.f (n+1) = P.d (n+1) n \u226b f + f' \u226b Q.d (n+2) (n+1)\n| 0 := \u27e8zero, one, comm_one\u27e9\n| 1 := \u27e8one, (succ 0 \u27e8zero, one, comm_one\u27e9).1, (succ 0 \u27e8zero, one, comm_one\u27e9).2\u27e9\n| (n+2) :=\n  \u27e8(mk_inductive_aux\u2081 (n+1)).2.1,\n    (succ (n+1) (mk_inductive_aux\u2081 (n+1))).1,\n    (succ (n+1) (mk_inductive_aux\u2081 (n+1))).2\u27e9\n\nsection\n\n/--\nAn auxiliary construction for `mk_inductive`.\n-/\n@[simp]\ndef mk_inductive_aux\u2082 :\n  \u03a0 n, \u03a3' (f : P.X_next n \u27f6 Q.X n) (f' : P.X n \u27f6 Q.X_prev n), e.f n = P.d_from n \u226b f + f' \u226b Q.d_to n\n| 0 := \u27e80, zero \u226b (Q.X_prev_iso rfl).inv, by simpa using comm_zero\u27e9\n| (n+1) := let I := mk_inductive_aux\u2081 e zero comm_zero one comm_one succ n in\n  \u27e8(P.X_next_iso rfl).hom \u226b I.1, I.2.1 \u226b (Q.X_prev_iso rfl).inv, by simpa using I.2.2\u27e9\n\nlemma mk_inductive_aux\u2083 (i j : \u2115) (h : i+1 = j) :\n  (mk_inductive_aux\u2082 e zero comm_zero one comm_one succ i).2.1 \u226b (Q.X_prev_iso h).hom\n    = (P.X_next_iso h).inv \u226b (mk_inductive_aux\u2082 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 `\u2115`-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 := \u03bb i j, if h : i + 1 = j then\n    (mk_inductive_aux\u2082 e zero comm_zero one comm_one succ i).2.1 \u226b (Q.X_prev_iso h).hom\n  else\n    0,\n  zero' := \u03bb i j w, by rwa dif_neg,\n  comm := \u03bb i, begin\n    dsimp, simp only [add_zero],\n    convert (mk_inductive_aux\u2082 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 \u2115).next i.succ = i := chain_complex.next_nat_succ i,\n        rw mk_inductive_aux\u2083 e zero comm_zero one comm_one succ\n          ((complex_shape.down \u2115).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 \u2115}\n\n@[simp] lemma d_next_cochain_complex (f : \u03a0 i j, P.X i \u27f6 Q.X j) (j : \u2115) :\n  d_next j f = P.d _ _ \u226b f (j+1) j :=\nbegin\n  dsimp [d_next],\n  have : (complex_shape.up \u2115).next j = j + 1 := cochain_complex.next \u2115 j,\n  congr' 2,\nend\n\n@[simp] lemma prev_d_succ_cochain_complex (f : \u03a0 i j, P.X i \u27f6 Q.X j) (i : \u2115) :\n  prev_d (i+1) f = f (i+1) _ \u226b Q.d i (i+1) :=\nbegin\n  dsimp [prev_d],\n  have : (complex_shape.up \u2115).prev (i+1) = i := cochain_complex.prev_nat_succ i,\n  congr' 2,\nend\n\n@[simp] lemma prev_d_zero_cochain_complex (f : \u03a0 i j, P.X i \u27f6 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 \u27f6 Q)\n  (zero : P.X 1 \u27f6 Q.X 0)\n  (comm_zero : e.f 0 = P.d 0 1 \u226b zero)\n  (one : P.X 2 \u27f6 Q.X 1)\n  (comm_one : e.f 1 = zero \u226b Q.d 0 1 + P.d 1 2 \u226b one)\n  (succ : \u2200 (n : \u2115)\n    (p : \u03a3' (f : P.X (n+1) \u27f6 Q.X n) (f' : P.X (n+2) \u27f6 Q.X (n+1)),\n      e.f (n+1) = f \u226b Q.d n (n+1) + P.d (n+1) (n+2) \u226b f'),\n    \u03a3' f'' : P.X (n+3) \u27f6 Q.X (n+2), e.f (n+2) = p.2.1 \u226b Q.d (n+1) (n+2) + P.d (n+2) (n+3) \u226b 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\u2082`.\n-/\n@[simp, nolint unused_arguments]\ndef mk_coinductive_aux\u2081 :\n  \u03a0 n, \u03a3' (f : P.X (n+1) \u27f6 Q.X n) (f' : P.X (n+2) \u27f6 Q.X (n+1)),\n    e.f (n+1) = f \u226b Q.d n (n+1) + P.d (n+1) (n+2) \u226b f'\n| 0 := \u27e8zero, one, comm_one\u27e9\n| 1 := \u27e8one, (succ 0 \u27e8zero, one, comm_one\u27e9).1, (succ 0 \u27e8zero, one, comm_one\u27e9).2\u27e9\n| (n+2) :=\n  \u27e8(mk_coinductive_aux\u2081 (n+1)).2.1,\n    (succ (n+1) (mk_coinductive_aux\u2081 (n+1))).1,\n    (succ (n+1) (mk_coinductive_aux\u2081 (n+1))).2\u27e9\n\nsection\n\n/--\nAn auxiliary construction for `mk_inductive`.\n-/\n@[simp]\ndef mk_coinductive_aux\u2082 :\n  \u03a0 n, \u03a3' (f : P.X n \u27f6 Q.X_prev n) (f' : P.X_next n \u27f6 Q.X n),\n    e.f n = f \u226b Q.d_to n + P.d_from n \u226b f'\n| 0 := \u27e80, (P.X_next_iso rfl).hom \u226b zero, by simpa using comm_zero\u27e9\n| (n+1) := let I := mk_coinductive_aux\u2081 e zero comm_zero one comm_one succ n in\n  \u27e8I.1 \u226b (Q.X_prev_iso rfl).inv, (P.X_next_iso rfl).hom \u226b I.2.1, by simpa using I.2.2\u27e9\n\nlemma mk_coinductive_aux\u2083 (i j : \u2115) (h : i + 1 = j) :\n  (P.X_next_iso h).inv \u226b (mk_coinductive_aux\u2082 e zero comm_zero one comm_one succ i).2.1\n    = (mk_coinductive_aux\u2082 e zero comm_zero one comm_one succ j).1 \u226b (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 `\u2115`-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 := \u03bb i j, if h : j + 1 = i then\n    (P.X_next_iso h).inv \u226b (mk_coinductive_aux\u2082 e zero comm_zero one comm_one succ j).2.1\n  else\n    0,\n  zero' := \u03bb i j w, by rwa dif_neg,\n  comm := \u03bb i, begin\n    dsimp,\n    rw [add_zero, add_comm],\n    convert (mk_coinductive_aux\u2082 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 \u2115).prev i.succ = i := cochain_complex.prev_nat_succ i,\n        rw mk_coinductive_aux\u2083 e zero comm_zero one comm_one succ\n          ((complex_shape.up \u2115).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 \u27f6 D)\n(inv : D \u27f6 C)\n(homotopy_hom_inv_id : homotopy (hom \u226b inv) (\ud835\udfd9 C))\n(homotopy_inv_hom_id : homotopy (inv \u226b hom) (\ud835\udfd9 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 := \ud835\udfd9 C,\n  inv := \ud835\udfd9 C,\n  homotopy_hom_inv_id := by simp,\n  homotopy_inv_hom_id := by simp, }\n\ninstance : inhabited (homotopy_equiv C C) := \u27e8refl C\u27e9\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 \u226b g.hom,\n  inv := g.inv \u226b 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 {\u03b9 : Type*} {V : Type u} [category.{v} V] [preadditive V]\n  {c : complex_shape \u03b9} {C D : homological_complex V c} (f : C \u2245 D) :\n  homotopy_equiv C D :=\n\u27e8f.hom, f.inv, homotopy.of_eq f.3, homotopy.of_eq f.4\u27e9\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 : \u03b9) :\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.\u03c0_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 [\u2190preadditive.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, \u2190category.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 : \u03b9) :\n  (homology_functor V c i).obj C \u2245 (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 [\u2190functor.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 [\u2190functor.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 \u2964 W) [F.additive] {f g : C \u27f6 D} (h : homotopy f g) :\n  homotopy ((F.map_homological_complex c).map f) ((F.map_homological_complex c).map g) :=\n{ hom := \u03bb i j, F.map (h.hom i j),\n  zero' := \u03bb i j w, by { rw [h.zero i j w, F.map_zero], },\n  comm := \u03bb i, begin\n    dsimp [d_next, prev_d] at *,\n    rw h.comm i,\n    simp only [F.map_add, \u2190 F.map_comp],\n    refl\n  end, }\n\n/-- An additive functor preserves homotopy equivalences. -/\n@[simps]\ndef functor.map_homotopy_equiv (F : V \u2964 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 [\u2190(F.map_homological_complex c).map_comp, \u2190(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 [\u2190(F.map_homological_complex c).map_comp, \u2190(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 \u2964 D` is an additive right exact functor between abelian categories, where `C` has enough\nprojectives, we provide the natural isomorphism `F.left_derived 0 \u2245 F`.\n\n## Main definitions\n\n* `category_theory.abelian.functor.left_derived_zero_iso_self`: the natural isomorphism\n  `(F.left_derived 0) \u2245 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 \u2964 D) {X Y Z : C} {f : X \u27f6 Y} {g : Y \u27f6 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 [\u2190 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 \u2115)).obj P.complex).d_to 0)\n  (F.map (P.\u03c0.f 0)) :=\npreadditive.exact_of_iso_of_exact' (F.map (P.complex.d 1 0)) (F.map (P.\u03c0.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\u2080))\n\n/-- Given `P : ProjectiveResolution X`, a morphism `(F.left_derived 0).obj X \u27f6 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 \u27f6 F.obj X :=\n(left_derived_obj_iso F 0 P).hom \u226b homology.desc' _ _ _ (kernel.\u03b9 _ \u226b (F.map (P.\u03c0.f 0)))\nbegin\n  rw [kernel.lift_\u03b9_assoc, homological_complex.d_to_eq _ (by simp : (complex_shape.down \u2115).rel 1 0),\n    map_homological_complex_obj_d, category.assoc, \u2190 functor.map_comp],\n  simp\nend\n\n/-- Given `P : ProjectiveResolution X`, a morphism `F.obj X \u27f6 (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 \u27f6 (F.left_derived 0).obj X :=\nbegin\n  refine ((as_iso (cokernel.desc _ _ (exact_of_map_projective_resolution F P).w)).inv) \u226b _ \u226b\n    (homology_iso_cokernel_lift _ _ _).inv \u226b (left_derived_obj_iso F 0 P).inv,\n  exact cokernel.map _ _ (\ud835\udfd9 _) (kernel.lift _ (\ud835\udfd9 _) (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 \u226b\n  left_derived_zero_to_self_app_inv F P = \ud835\udfd9 _ :=\nbegin\n  dsimp [left_derived_zero_to_self_app, left_derived_zero_to_self_app_inv],\n  rw [\u2190 category.assoc, \u2190 category.assoc, \u2190 category.assoc, iso.comp_inv_eq, category.id_comp,\n    category.assoc, category.assoc, category.assoc],\n  convert category.comp_id _,\n  rw [\u2190 category.assoc, \u2190 category.assoc, iso.comp_inv_eq, category.id_comp],\n  ext,\n  rw [\u2190 category.assoc, \u2190 category.assoc, homology.\u03c0'_desc', category.assoc, category.assoc,\n    \u2190 category.assoc (F.map _), abelian.cokernel.desc.inv, cokernel.\u03c0_desc, homology.\u03c0',\n    category.assoc, iso.inv_hom_id, category.comp_id, \u2190 category.assoc],\n  convert category.id_comp _ using 2,\n  ext,\n  rw [category.id_comp, category.assoc, equalizer_as_kernel, kernel.lift_\u03b9, 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 \u226b\n  left_derived_zero_to_self_app F P = \ud835\udfd9 _ :=\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    \u2190 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.\u03c0_desc_assoc, category.assoc, cokernel.\u03c0_desc, homology.desc'],\n  rw [\u2190 category.assoc, \u2190 category.assoc (homology_iso_cokernel_lift _ _ _).inv, iso.inv_hom_id,\n    category.id_comp],\n  simp only [category.assoc, cokernel.\u03c0_desc, kernel.lift_\u03b9_assoc, category.id_comp],\nend\n\n/-- Given `P : ProjectiveResolution X`, the isomorphism `(F.left_derived 0).obj X \u2245 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 \u2245 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 \u27f6 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 \u27f6 Y)\n  (P : ProjectiveResolution X) (Q : ProjectiveResolution Y) :\n  (F.left_derived 0).map f \u226b left_derived_zero_to_self_app F Q =\n  left_derived_zero_to_self_app F P \u226b 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, \u2190 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.\u03c0'_map_assoc, homology.\u03c0'_desc', kernel.lift_\u03b9_assoc, category.assoc,\n    homology.\u03c0'_desc'_assoc, \u2190 map_comp, show (ProjectiveResolution.lift f P Q).f 0 \u226b _ = _ \u226b 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) \u2245 F`. -/\ndef left_derived_zero_iso_self [enough_projectives C] [preserves_finite_colimits F] :\n  (F.left_derived 0) \u2245 F :=\nnat_iso.of_components (\u03bb X, left_derived_zero_to_self_app_iso _ (ProjectiveResolution.of X))\n  (\u03bb 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 (\u03c9 : ontology)\n\n  abbreviation observable (\u03b1 : Sort*) \n                [topological_space \u03b1] \n                [has_none \u03b1]\n                := \u03c9.world \u2192 \u03b1\n\n  abbreviation event' := \u03c9.observable Prop\n\n  @[simp]\n  lemma event'_eq_event : \u03c9.event' = \u03c9.event := \n  by simp [ontology.event, set]\n\n  abbreviation quantity := \u03c9.observable (option \u211d)\n\nsection observables\n\n  variables {\u03c9} {\u03b1 : Type*} [topological_space \u03b1] \n            [has_none \u03b1] (o : \u03c9.observable \u03b1)\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 (\u03c9.observable \u03b1) \u03c9.event := \u27e8\u03bb f x, f x \u2260 has_none.none\u27e9\n\nend observables\n\n  -- We now talk about analogical (fuzzy) events, or \"aevents\" TODO: revise this comment.\n  abbreviation aevent :=  \u03c9.observable fuzzy\n\nnamespace aevent\n\n  variables {\u03c9} (ae : \u03c9.aevent)\n\n  abbreviation aevent.possible := (\u2191ae : \u03c9.event).possible \n\n  /-- Use `\u22c4ae` for \"`ae` is possible\" -/\n  instance has_diamond_aevent : has_diamond \u03c9.aevent := \u27e8aevent.possible\u27e9\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 `\u03c6` from\n`\u03c6` from `G` to the automorphism group of `N` is the product of sets with the group\n`\u27e8n\u2081, g\u2081\u27e9 * \u27e8n\u2082, g\u2082\u27e9 = \u27e8n\u2081 * \u03c6 g\u2081 n\u2082, g\u2081 * g\u2082\u27e9`\n\n## Key definitions\n\nThere are two homs into the semidirect product `inl : N \u2192* N \u22ca[\u03c6] G` and\n`inr : G \u2192* N \u22ca[\u03c6] G`, and `lift` can be used to define maps `N \u22ca[\u03c6] G \u2192* H`\nout of the semidirect product given maps `f\u2081 : N \u2192* H` and `f\u2082 : G \u2192* H` that satisfy the\ncondition `\u2200 n g, f\u2081 (\u03c6 g n) = f\u2082 g * f\u2081 n * f\u2082 g\u207b\u00b9`\n\n## Notation\n\nThis file introduces the global notation `N \u22ca[\u03c6] G` for `semidirect_product N G \u03c6`\n\n## Tags\ngroup, semidirect product\n-/\n\n/-- The semidirect product of groups `N` and `G`, given a map `\u03c6` from `G` to the automorphism\n  group of `N`. It the product of sets with the group operation\n  `\u27e8n\u2081, g\u2081\u27e9 * \u27e8n\u2082, g\u2082\u27e9 = \u27e8n\u2081 * \u03c6 g\u2081 n\u2082, g\u2081 * g\u2082\u27e9` -/\nstructure semidirect_product (N : Type u_1) (G : Type u_2) [group N] [group G] (\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* mul_aut N} : group (semidirect_product N G \u03c6) :=\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] {\u03c6 : G \u2192* mul_aut N} : Inhabited (semidirect_product N G \u03c6) :=\n  { default := 1 }\n\n@[simp] theorem one_left {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* mul_aut N} (a : semidirect_product N G \u03c6) : left (a\u207b\u00b9) = coe_fn (coe_fn \u03c6 (right a\u207b\u00b9)) (left a\u207b\u00b9) :=\n  rfl\n\n@[simp] theorem inv_right {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} (a : semidirect_product N G \u03c6) : right (a\u207b\u00b9) = (right a\u207b\u00b9) :=\n  rfl\n\n@[simp] theorem mul_left {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} (a : semidirect_product N G \u03c6) (b : semidirect_product N G \u03c6) : left (a * b) = left a * coe_fn (coe_fn \u03c6 (right a)) (left b) :=\n  rfl\n\n@[simp] theorem mul_right {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} (a : semidirect_product N G \u03c6) (b : semidirect_product N G \u03c6) : right (a * b) = right a * right b :=\n  rfl\n\n/-- The canonical map `N \u2192* N \u22ca[\u03c6] G` sending `n` to `\u27e8n, 1\u27e9` -/\ndef inl {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} : N \u2192* semidirect_product N G \u03c6 :=\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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* mul_aut N} : function.injective \u21d1inl :=\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] {\u03c6 : G \u2192* mul_aut N} {n\u2081 : N} {n\u2082 : N} : coe_fn inl n\u2081 = coe_fn inl n\u2082 \u2194 n\u2081 = n\u2082 :=\n  function.injective.eq_iff inl_injective\n\n/-- The canonical map `G \u2192* N \u22ca[\u03c6] G` sending `g` to `\u27e81, g\u27e9` -/\ndef inr {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} : G \u2192* semidirect_product N G \u03c6 :=\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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* mul_aut N} : function.injective \u21d1inr :=\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] {\u03c6 : G \u2192* mul_aut N} {g\u2081 : G} {g\u2082 : G} : coe_fn inr g\u2081 = coe_fn inr g\u2082 \u2194 g\u2081 = g\u2082 :=\n  function.injective.eq_iff inr_injective\n\ntheorem inl_aut {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} (g : G) (n : N) : coe_fn inl (coe_fn (coe_fn \u03c6 g) n) = coe_fn inr g * coe_fn inl n * coe_fn inr (g\u207b\u00b9) := sorry\n\ntheorem inl_aut_inv {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} (g : G) (n : N) : coe_fn inl (coe_fn (coe_fn \u03c6 g\u207b\u00b9) n) = coe_fn inr (g\u207b\u00b9) * 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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* mul_aut N} (x : semidirect_product N G \u03c6) : coe_fn inl (left x) * coe_fn inr (right x) = x := sorry\n\n/-- The canonical projection map `N \u22ca[\u03c6] G \u2192* G`, as a group hom. -/\ndef right_hom {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} : semidirect_product N G \u03c6 \u2192* 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] {\u03c6 : G \u2192* mul_aut N} : \u21d1right_hom = right :=\n  rfl\n\n@[simp] theorem right_hom_comp_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* 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] {\u03c6 : G \u2192* mul_aut N} : function.surjective \u21d1right_hom :=\n  iff.mpr function.surjective_iff_has_right_inverse (Exists.intro (\u21d1inr) right_hom_inr)\n\ntheorem range_inl_eq_ker_right_hom {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} : monoid_hom.range inl = monoid_hom.ker right_hom := sorry\n\n/-- Define a group hom `N \u22ca[\u03c6] G \u2192* H`, by defining maps `N \u2192* H` and `G \u2192* H`  -/\ndef lift {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {\u03c6 : G \u2192* mul_aut N} (f\u2081 : N \u2192* H) (f\u2082 : G \u2192* H) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f\u2082 g))) f\u2081) : semidirect_product N G \u03c6 \u2192* H :=\n  monoid_hom.mk (fun (a : semidirect_product N G \u03c6) => coe_fn f\u2081 (left a) * coe_fn f\u2082 (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] {\u03c6 : G \u2192* mul_aut N} (f\u2081 : N \u2192* H) (f\u2082 : G \u2192* H) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f\u2082 g))) f\u2081) (n : N) : coe_fn (lift f\u2081 f\u2082 h) (coe_fn inl n) = coe_fn f\u2081 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] {\u03c6 : G \u2192* mul_aut N} (f\u2081 : N \u2192* H) (f\u2082 : G \u2192* H) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f\u2082 g))) f\u2081) : monoid_hom.comp (lift f\u2081 f\u2082 h) inl = f\u2081 := 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] {\u03c6 : G \u2192* mul_aut N} (f\u2081 : N \u2192* H) (f\u2082 : G \u2192* H) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f\u2082 g))) f\u2081) (g : G) : coe_fn (lift f\u2081 f\u2082 h) (coe_fn inr g) = coe_fn f\u2082 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] {\u03c6 : G \u2192* mul_aut N} (f\u2081 : N \u2192* H) (f\u2082 : G \u2192* H) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn f\u2082 g))) f\u2081) : monoid_hom.comp (lift f\u2081 f\u2082 h) inr = f\u2082 := sorry\n\ntheorem lift_unique {N : Type u_1} {G : Type u_2} {H : Type u_3} [group N] [group G] [group H] {\u03c6 : G \u2192* mul_aut N} (F : semidirect_product N G \u03c6 \u2192* 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) (\u1fb0 \u1fb0_1 : H) (e_2 : \u1fb0 = \u1fb0_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 \u03c6 _x))) x)\n                      (coe_fn F (coe_fn inr _x) * coe_fn F (coe_fn inl x) * (coe_fn F (coe_fn inr _x)\u207b\u00b9))\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 \u03c6 _x)))\n                                    x)\n                                  ((fun (f f_1 : N \u2192 H) (e_1 : f = f_1) (g g_1 : N \u2192 N) (e_2 : g = g_1) (\u1fb0 \u1fb0_1 : N)\n                                      (e_3 : \u1fb0 = \u1fb0_1) => congr (congr (congr_arg function.comp e_1) e_2) e_3)\n                                    (\u21d1(monoid_hom.comp F inl)) (\u21d1F \u2218 \u21d1inl) (monoid_hom.coe_comp F inl)\n                                    (\u21d1(mul_equiv.to_monoid_hom (coe_fn \u03c6 _x))) (\u21d1(coe_fn \u03c6 _x))\n                                    (mul_equiv.coe_to_monoid_hom (coe_fn \u03c6 _x)) x x (Eq.refl x)))\n                                (function.comp_app (\u21d1F \u2218 \u21d1inl) (\u21d1(coe_fn \u03c6 _x)) x))\n                              (function.comp_app (\u21d1F) (\u21d1inl) (coe_fn (coe_fn \u03c6 _x) x)))\n                            ((fun (x x_1 : semidirect_product N G \u03c6 \u2192* H) (e_1 : x = x_1)\n                                (\u1fb0 \u1fb0_1 : semidirect_product N G \u03c6) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg coe_fn e_1) e_2)\n                              F F (Eq.refl F) (coe_fn inl (coe_fn (coe_fn \u03c6 _x) x))\n                              (coe_fn inr _x * coe_fn inl x * (coe_fn inr _x\u207b\u00b9))\n                              (Eq.trans (inl_aut _x x)\n                                ((fun (\u1fb0 \u1fb0_1 : semidirect_product N G \u03c6) (e_2 : \u1fb0 = \u1fb0_1)\n                                    (\u1fb0_2 \u1fb0_3 : semidirect_product N G \u03c6) (e_3 : \u1fb0_2 = \u1fb0_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\u207b\u00b9)) (coe_fn inr _x\u207b\u00b9)\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 (\u1fb0 \u1fb0_1 : H) (e_2 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : H) (e_3 : \u1fb0_2 = \u1fb0_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)\u207b\u00b9)\n                          (coe_fn F (coe_fn inr _x)\u207b\u00b9) (Eq.refl (coe_fn F (coe_fn inr _x)\u207b\u00b9))))\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)\u207b\u00b9))\n                      (Eq.trans\n                        (Eq.trans\n                          (Eq.trans\n                            (Eq.trans\n                              (Eq.trans\n                                ((fun (x x_1 : N \u2192* H) (e_1 : x = x_1) (\u1fb0 \u1fb0_1 : N) (e_2 : \u1fb0 = \u1fb0_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 \u2192* H) (e_1 : hnp = hnp_1) (hmn hmn_1 : N \u2192* 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 \u2243* 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 \u2192* mul_aut H) (e_1 : x = x_1) (\u1fb0 \u1fb0_1 : H) (e_2 : \u1fb0 = \u1fb0_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 (\u21d1F) (\u21d1inr) _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 \u2192 H) (e_1 : f = f_1) (g g_1 : N \u2192 H) (e_2 : g = g_1) (\u1fb0 \u1fb0_1 : N)\n                                  (e_3 : \u1fb0 = \u1fb0_1) => congr (congr (congr_arg function.comp e_1) e_2) e_3)\n                                (\u21d1(mul_equiv.to_monoid_hom (coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x)))))\n                                (\u21d1(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                                (\u21d1(monoid_hom.comp F inl)) (\u21d1F \u2218 \u21d1inl) (monoid_hom.coe_comp F inl) x x (Eq.refl x)))\n                            (function.comp_app (\u21d1(coe_fn mul_aut.conj (coe_fn F (coe_fn inr _x)))) (\u21d1F \u2218 \u21d1inl) x))\n                          ((fun (x x_1 : H \u2243* H) (e_1 : x = x_1) (\u1fb0 \u1fb0_1 : H) (e_2 : \u1fb0 = \u1fb0_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 (\u21d1F) (\u21d1inl) x)\n                            (coe_fn F (coe_fn inl x)) (function.comp_app (\u21d1F) (\u21d1inl) 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)\u207b\u00b9))))\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] {\u03c6 : G \u2192* mul_aut N} {f : semidirect_product N G \u03c6 \u2192* H} {g : semidirect_product N G \u03c6 \u2192* 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 \u22ca[\u03c6] G` to `N\u2081 \u22ca[\u03c6\u2081] G\u2081` given maps `N \u2192* N\u2081` and `G \u2192* G\u2081` that\n  satisfy a commutativity condition `\u2200 n g, f\u2081 (\u03c6 g n) = \u03c6\u2081 (f\u2082 g) (f\u2081 n)`.  -/\ndef map {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} {N\u2081 : Type u_4} {G\u2081 : Type u_5} [group N\u2081] [group G\u2081] {\u03c6\u2081 : G\u2081 \u2192* mul_aut N\u2081} (f\u2081 : N \u2192* N\u2081) (f\u2082 : G \u2192* G\u2081) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn \u03c6\u2081 (coe_fn f\u2082 g))) f\u2081) : semidirect_product N G \u03c6 \u2192* semidirect_product N\u2081 G\u2081 \u03c6\u2081 :=\n  monoid_hom.mk (fun (x : semidirect_product N G \u03c6) => mk (coe_fn f\u2081 (left x)) (coe_fn f\u2082 (right x))) sorry sorry\n\n@[simp] theorem map_left {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} {N\u2081 : Type u_4} {G\u2081 : Type u_5} [group N\u2081] [group G\u2081] {\u03c6\u2081 : G\u2081 \u2192* mul_aut N\u2081} (f\u2081 : N \u2192* N\u2081) (f\u2082 : G \u2192* G\u2081) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn \u03c6\u2081 (coe_fn f\u2082 g))) f\u2081) (g : semidirect_product N G \u03c6) : left (coe_fn (map f\u2081 f\u2082 h) g) = coe_fn f\u2081 (left g) :=\n  rfl\n\n@[simp] theorem map_right {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} {N\u2081 : Type u_4} {G\u2081 : Type u_5} [group N\u2081] [group G\u2081] {\u03c6\u2081 : G\u2081 \u2192* mul_aut N\u2081} (f\u2081 : N \u2192* N\u2081) (f\u2082 : G \u2192* G\u2081) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn \u03c6\u2081 (coe_fn f\u2082 g))) f\u2081) (g : semidirect_product N G \u03c6) : right (coe_fn (map f\u2081 f\u2082 h) g) = coe_fn f\u2082 (right g) :=\n  rfl\n\n@[simp] theorem right_hom_comp_map {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} {N\u2081 : Type u_4} {G\u2081 : Type u_5} [group N\u2081] [group G\u2081] {\u03c6\u2081 : G\u2081 \u2192* mul_aut N\u2081} (f\u2081 : N \u2192* N\u2081) (f\u2082 : G \u2192* G\u2081) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn \u03c6\u2081 (coe_fn f\u2082 g))) f\u2081) : monoid_hom.comp right_hom (map f\u2081 f\u2082 h) = monoid_hom.comp f\u2082 right_hom :=\n  rfl\n\n@[simp] theorem map_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} {N\u2081 : Type u_4} {G\u2081 : Type u_5} [group N\u2081] [group G\u2081] {\u03c6\u2081 : G\u2081 \u2192* mul_aut N\u2081} (f\u2081 : N \u2192* N\u2081) (f\u2082 : G \u2192* G\u2081) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn \u03c6\u2081 (coe_fn f\u2082 g))) f\u2081) (n : N) : coe_fn (map f\u2081 f\u2082 h) (coe_fn inl n) = coe_fn inl (coe_fn f\u2081 n) := sorry\n\n@[simp] theorem map_comp_inl {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} {N\u2081 : Type u_4} {G\u2081 : Type u_5} [group N\u2081] [group G\u2081] {\u03c6\u2081 : G\u2081 \u2192* mul_aut N\u2081} (f\u2081 : N \u2192* N\u2081) (f\u2082 : G \u2192* G\u2081) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn \u03c6\u2081 (coe_fn f\u2082 g))) f\u2081) : monoid_hom.comp (map f\u2081 f\u2082 h) inl = monoid_hom.comp inl f\u2081 := sorry\n\n@[simp] theorem map_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} {N\u2081 : Type u_4} {G\u2081 : Type u_5} [group N\u2081] [group G\u2081] {\u03c6\u2081 : G\u2081 \u2192* mul_aut N\u2081} (f\u2081 : N \u2192* N\u2081) (f\u2082 : G \u2192* G\u2081) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn \u03c6\u2081 (coe_fn f\u2082 g))) f\u2081) (g : G) : coe_fn (map f\u2081 f\u2082 h) (coe_fn inr g) = coe_fn inr (coe_fn f\u2082 g) := sorry\n\n@[simp] theorem map_comp_inr {N : Type u_1} {G : Type u_2} [group N] [group G] {\u03c6 : G \u2192* mul_aut N} {N\u2081 : Type u_4} {G\u2081 : Type u_5} [group N\u2081] [group G\u2081] {\u03c6\u2081 : G\u2081 \u2192* mul_aut N\u2081} (f\u2081 : N \u2192* N\u2081) (f\u2082 : G \u2192* G\u2081) (h : \u2200 (g : G),\n  monoid_hom.comp f\u2081 (mul_equiv.to_monoid_hom (coe_fn \u03c6 g)) =\n    monoid_hom.comp (mul_equiv.to_monoid_hom (coe_fn \u03c6\u2081 (coe_fn f\u2082 g))) f\u2081) : monoid_hom.comp (map f\u2081 f\u2082 h) inr = monoid_hom.comp inr f\u2082 := 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 : \u2203 x : Nat, x = x := by use 42\n\nexample : \u2203 x : Nat, \u2203 y : Nat, x = y := by use 42, 42\n\nexample : \u2203 x : String \u00d7 String, x.1 = x.2 := by use (\"a\", \"a\")\n\nexample : \u2203 x : Nat, x = x := by\n  use ?_\n  exact 42\n  rfl\n\nexample (\u03b1 : Type) : \u2203 S : List \u03b1, S = S := by use \u2205\n\nexample : \u2203 x : Int, x = x := by use 42\n\nexample : \u2203 a b c : Int, a + b + c = 6 := by\n  use 1, 2, 3\n  rfl\n\nexample : \u2203 p : Int \u00d7 Int, p.1 = 1 := by use \u27e81, 42\u27e9\n\nexample : \u2203 n : Int, n * 3 = 3 * 2 := by\n  use 2\n  rfl\n\n-- FIXME Failing tests ported from mathlib3\n\n-- example : \u2203 (n : Nat) (h : n > 0), n = n :=\n-- by\n--   use 1\n--   -- goal should now be `1 > 0 \u2227 1 = 1`, whereas it would be `\u2203 (H : 1 > 0), 1 = 1` after existsi 1.\n--   guard_target = 1 > 0 \u2227 1 = 1\n--   exact \u27e8Nat.zero_lt_one, rfl\u27e9\n\n-- example : \u03a3 x y : Int, (Int \u00d7 Int) \u00d7 Int :=\n-- by use 1, 2, 3, 4, 5\n\n-- inductive foo\n-- | mk : Nat \u2192 Bool \u00d7 Nat \u2192 Nat \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 (\u03b1 : Type u_1) extends filter \u03b1 where\n  ne_bot' : filter.ne_bot _to_filter\n  le_of_le : \u2200 (g : filter \u03b1), filter.ne_bot g \u2192 g \u2264 _to_filter \u2192 _to_filter \u2264 g\n\nnamespace ultrafilter\n\n\nprotected instance filter.has_coe_t {\u03b1 : Type u} : has_coe_t (ultrafilter \u03b1) (filter \u03b1) :=\n  has_coe_t.mk ultrafilter.to_filter\n\nprotected instance has_mem {\u03b1 : Type u} : has_mem (set \u03b1) (ultrafilter \u03b1) :=\n  has_mem.mk fun (s : set \u03b1) (f : ultrafilter \u03b1) => s \u2208 \u2191f\n\ntheorem unique {\u03b1 : Type u} (f : ultrafilter \u03b1) {g : filter \u03b1} (h : g \u2264 \u2191f)\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 = \u2191f :=\n  le_antisymm h (ultrafilter.le_of_le f g hne h)\n\nprotected instance ne_bot {\u03b1 : Type u} (f : ultrafilter \u03b1) : filter.ne_bot \u2191f :=\n  ultrafilter.ne_bot' f\n\n@[simp] theorem mem_coe {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} : s \u2208 \u2191f \u2194 s \u2208 f := iff.rfl\n\ntheorem coe_injective {\u03b1 : Type u} : function.injective coe := sorry\n\n@[simp] theorem coe_le_coe {\u03b1 : Type u} {f : ultrafilter \u03b1} {g : ultrafilter \u03b1} : \u2191f \u2264 \u2191g \u2194 f = g :=\n  { mp := fun (h : \u2191f \u2264 \u2191g) => coe_injective (unique g h), mpr := fun (h : f = g) => h \u25b8 le_rfl }\n\n@[simp] theorem coe_inj {\u03b1 : Type u} {f : ultrafilter \u03b1} {g : ultrafilter \u03b1} : \u2191f = \u2191g \u2194 f = g :=\n  function.injective.eq_iff coe_injective\n\ntheorem ext {\u03b1 : Type u} {f : ultrafilter \u03b1} {g : ultrafilter \u03b1}\n    (h : \u2200 (s : set \u03b1), s \u2208 f \u2194 s \u2208 g) : f = g :=\n  coe_injective (filter.ext h)\n\ntheorem le_of_inf_ne_bot {\u03b1 : Type u} (f : ultrafilter \u03b1) {g : filter \u03b1}\n    (hg : filter.ne_bot (\u2191f \u2293 g)) : \u2191f \u2264 g :=\n  le_of_inf_eq (unique f inf_le_left)\n\ntheorem le_of_inf_ne_bot' {\u03b1 : Type u} (f : ultrafilter \u03b1) {g : filter \u03b1}\n    (hg : filter.ne_bot (g \u2293 \u2191f)) : \u2191f \u2264 g :=\n  le_of_inf_ne_bot f (eq.mpr (id (Eq._oldrec (Eq.refl (filter.ne_bot (\u2191f \u2293 g))) inf_comm)) hg)\n\n@[simp] theorem compl_not_mem_iff {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} : \u00acs\u1d9c \u2208 f \u2194 s \u2208 f :=\n  sorry\n\n@[simp] theorem frequently_iff_eventually {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} :\n    filter.frequently (fun (x : \u03b1) => p x) \u2191f \u2194 filter.eventually (fun (x : \u03b1) => p x) \u2191f :=\n  compl_not_mem_iff\n\ntheorem Mathlib.filter.frequently.eventually {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} :\n    filter.frequently (fun (x : \u03b1) => p x) \u2191f \u2192 filter.eventually (fun (x : \u03b1) => p x) \u2191f :=\n  iff.mp frequently_iff_eventually\n\ntheorem compl_mem_iff_not_mem {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} : s\u1d9c \u2208 f \u2194 \u00acs \u2208 f :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s\u1d9c \u2208 f \u2194 \u00acs \u2208 f)) (Eq.symm (propext compl_not_mem_iff))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u00acs\u1d9c\u1d9c \u2208 f \u2194 \u00acs \u2208 f)) (compl_compl s))) (iff.refl (\u00acs \u2208 f)))\n\n/-- If `s\u1d9c \u2209 f \u2194 s \u2208 f`, then `f` is an ultrafilter. The other implication is given by\n`ultrafilter.compl_not_mem_iff`.  -/\ndef of_compl_not_mem_iff {\u03b1 : Type u} (f : filter \u03b1) (h : \u2200 (s : set \u03b1), \u00acs\u1d9c \u2208 f \u2194 s \u2208 f) :\n    ultrafilter \u03b1 :=\n  mk f sorry sorry\n\ntheorem nonempty_of_mem {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} (hs : s \u2208 f) :\n    set.nonempty s :=\n  filter.nonempty_of_mem_sets hs\n\ntheorem ne_empty_of_mem {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} (hs : s \u2208 f) : s \u2260 \u2205 :=\n  set.nonempty.ne_empty (nonempty_of_mem hs)\n\n@[simp] theorem empty_not_mem {\u03b1 : Type u} {f : ultrafilter \u03b1} : \u00ac\u2205 \u2208 f := filter.empty_nmem_sets \u2191f\n\ntheorem mem_or_compl_mem {\u03b1 : Type u} (f : ultrafilter \u03b1) (s : set \u03b1) : s \u2208 f \u2228 s\u1d9c \u2208 f :=\n  iff.mpr or_iff_not_imp_left (iff.mpr compl_mem_iff_not_mem)\n\nprotected theorem em {\u03b1 : Type u} (f : ultrafilter \u03b1) (p : \u03b1 \u2192 Prop) :\n    filter.eventually (fun (x : \u03b1) => p x) \u2191f \u2228 filter.eventually (fun (x : \u03b1) => \u00acp x) \u2191f :=\n  mem_or_compl_mem f (set_of fun (x : \u03b1) => p x)\n\ntheorem eventually_or {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} :\n    filter.eventually (fun (x : \u03b1) => p x \u2228 q x) \u2191f \u2194\n        filter.eventually (fun (x : \u03b1) => p x) \u2191f \u2228 filter.eventually (fun (x : \u03b1) => q x) \u2191f :=\n  sorry\n\ntheorem union_mem_iff {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} {t : set \u03b1} :\n    s \u222a t \u2208 f \u2194 s \u2208 f \u2228 t \u2208 f :=\n  eventually_or\n\ntheorem eventually_not {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} :\n    filter.eventually (fun (x : \u03b1) => \u00acp x) \u2191f \u2194 \u00acfilter.eventually (fun (x : \u03b1) => p x) \u2191f :=\n  compl_mem_iff_not_mem\n\ntheorem eventually_imp {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} :\n    filter.eventually (fun (x : \u03b1) => p x \u2192 q x) \u2191f \u2194\n        filter.eventually (fun (x : \u03b1) => p x) \u2191f \u2192 filter.eventually (fun (x : \u03b1) => q x) \u2191f :=\n  sorry\n\ntheorem finite_sUnion_mem_iff {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set (set \u03b1)}\n    (hs : set.finite s) : \u22c3\u2080s \u2208 f \u2194 \u2203 (t : set \u03b1), \u2203 (H : t \u2208 s), t \u2208 f :=\n  sorry\n\ntheorem finite_bUnion_mem_iff {\u03b1 : Type u} {\u03b2 : Type v} {f : ultrafilter \u03b1} {is : set \u03b2}\n    {s : \u03b2 \u2192 set \u03b1} (his : set.finite is) :\n    (set.Union fun (i : \u03b2) => set.Union fun (H : i \u2208 is) => s i) \u2208 f \u2194\n        \u2203 (i : \u03b2), \u2203 (H : i \u2208 is), s i \u2208 f :=\n  sorry\n\n/-- Pushforward for ultrafilters. -/\ndef map {\u03b1 : Type u} {\u03b2 : Type v} (m : \u03b1 \u2192 \u03b2) (f : ultrafilter \u03b1) : ultrafilter \u03b2 :=\n  of_compl_not_mem_iff (filter.map m \u2191f) sorry\n\n@[simp] theorem coe_map {\u03b1 : Type u} {\u03b2 : Type v} (m : \u03b1 \u2192 \u03b2) (f : ultrafilter \u03b1) :\n    \u2191(map m f) = filter.map m \u2191f :=\n  rfl\n\n@[simp] theorem mem_map {\u03b1 : Type u} {\u03b2 : Type v} {m : \u03b1 \u2192 \u03b2} {f : ultrafilter \u03b1} {s : set \u03b2} :\n    s \u2208 map m f \u2194 m \u207b\u00b9' s \u2208 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 {\u03b1 : Type u} {\u03b2 : Type v} {m : \u03b1 \u2192 \u03b2} (u : ultrafilter \u03b2) (inj : function.injective m)\n    (large : set.range m \u2208 u) : ultrafilter \u03b1 :=\n  mk (filter.comap m \u2191u) sorry sorry\n\n/-- The principal ultrafilter associated to a point `x`. -/\nprotected instance has_pure : Pure ultrafilter :=\n  { pure := fun (\u03b1 : Type u_1) (a : \u03b1) => of_compl_not_mem_iff (pure a) sorry }\n\n@[simp] theorem mem_pure_sets {\u03b1 : Type u} {a : \u03b1} {s : set \u03b1} : s \u2208 pure a \u2194 a \u2208 s := iff.rfl\n\nprotected instance inhabited {\u03b1 : Type u} [Inhabited \u03b1] : Inhabited (ultrafilter \u03b1) :=\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 {\u03b1 : Type u} {\u03b2 : Type v} (f : ultrafilter \u03b1) (m : \u03b1 \u2192 ultrafilter \u03b2) : ultrafilter \u03b2 :=\n  of_compl_not_mem_iff (filter.bind \u2191f fun (x : \u03b1) => \u2191(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 (\u03b1 \u03b2 : Type u_1) => map \u2218 function.const \u03b2 }\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 (\u03b1 \u03b2 : Type u_1) (a : \u03b1) (f : \u03b1 \u2192 ultrafilter \u03b2) =>\n      coe_injective (filter.pure_bind a (coe \u2218 f)))\n    fun (\u03b1 \u03b2 \u03b3 : Type u_1) (f : ultrafilter \u03b1) (m\u2081 : \u03b1 \u2192 ultrafilter \u03b2) (m\u2082 : \u03b2 \u2192 ultrafilter \u03b3) =>\n      coe_injective (filter.filter_eq rfl)\n\n/-- The ultrafilter lemma: Any proper filter is contained in an ultrafilter. -/\ntheorem exists_le {\u03b1 : Type u} (f : filter \u03b1) [h : filter.ne_bot f] :\n    \u2203 (u : ultrafilter \u03b1), \u2191u \u2264 f :=\n  sorry\n\ntheorem Mathlib.filter.exists_ultrafilter_le {\u03b1 : Type u} (f : filter \u03b1) [h : filter.ne_bot f] :\n    \u2203 (u : ultrafilter \u03b1), \u2191u \u2264 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 {\u03b1 : Type u} (f : filter \u03b1) [filter.ne_bot f] : ultrafilter \u03b1 := classical.some (exists_le f)\n\ntheorem of_le {\u03b1 : Type u} (f : filter \u03b1) [filter.ne_bot f] : \u2191(of f) \u2264 f :=\n  classical.some_spec (exists_le f)\n\ntheorem of_coe {\u03b1 : Type u} (f : ultrafilter \u03b1) : of \u2191f = f := iff.mp coe_inj (unique f (of_le \u2191f))\n\ntheorem exists_ultrafilter_of_finite_inter_nonempty {\u03b1 : Type u} (S : set (set \u03b1))\n    (cond : \u2200 (T : finset (set \u03b1)), \u2191T \u2286 S \u2192 set.nonempty (\u22c2\u2080\u2191T)) :\n    \u2203 (F : ultrafilter \u03b1), S \u2286 filter.sets (ultrafilter.to_filter F) :=\n  sorry\n\nend ultrafilter\n\n\nnamespace filter\n\n\ntheorem mem_iff_ultrafilter {\u03b1 : Type u} {s : set \u03b1} {f : filter \u03b1} :\n    s \u2208 f \u2194 \u2200 (g : ultrafilter \u03b1), \u2191g \u2264 f \u2192 s \u2208 g :=\n  sorry\n\ntheorem le_iff_ultrafilter {\u03b1 : Type u} {f\u2081 : filter \u03b1} {f\u2082 : filter \u03b1} :\n    f\u2081 \u2264 f\u2082 \u2194 \u2200 (g : ultrafilter \u03b1), \u2191g \u2264 f\u2081 \u2192 \u2191g \u2264 f\u2082 :=\n  sorry\n\n/-- A filter equals the intersection of all the ultrafilters which contain it. -/\ntheorem supr_ultrafilter_le_eq {\u03b1 : Type u} (f : filter \u03b1) :\n    (supr fun (g : ultrafilter \u03b1) => supr fun (hg : \u2191g \u2264 f) => \u2191g) = f :=\n  sorry\n\n/-- The `tendsto` relation can be checked on ultrafilters. -/\ntheorem tendsto_iff_ultrafilter {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (l\u2081 : filter \u03b1)\n    (l\u2082 : filter \u03b2) : tendsto f l\u2081 l\u2082 \u2194 \u2200 (g : ultrafilter \u03b1), \u2191g \u2264 l\u2081 \u2192 tendsto f (\u2191g) l\u2082 :=\n  sorry\n\ntheorem exists_ultrafilter_iff {\u03b1 : Type u} {f : filter \u03b1} :\n    (\u2203 (u : ultrafilter \u03b1), \u2191u \u2264 f) \u2194 ne_bot f :=\n  sorry\n\ntheorem forall_ne_bot_le_iff {\u03b1 : Type u} {g : filter \u03b1} {p : filter \u03b1 \u2192 Prop} (hp : monotone p) :\n    (\u2200 (f : filter \u03b1), ne_bot f \u2192 f \u2264 g \u2192 p f) \u2194 \u2200 (f : ultrafilter \u03b1), \u2191f \u2264 g \u2192 p \u2191f :=\n  sorry\n\n/-- The ultrafilter extending the cofinite filter. -/\ndef hyperfilter (\u03b1 : Type u) [infinite \u03b1] : ultrafilter \u03b1 := ultrafilter.of cofinite\n\ntheorem hyperfilter_le_cofinite {\u03b1 : Type u} [infinite \u03b1] : \u2191(hyperfilter \u03b1) \u2264 cofinite :=\n  ultrafilter.of_le cofinite\n\n@[simp] theorem bot_ne_hyperfilter {\u03b1 : Type u} [infinite \u03b1] : \u22a5 \u2260 \u2191(hyperfilter \u03b1) :=\n  ne.symm ((fun (this : ne_bot \u2191(hyperfilter \u03b1)) => this) (ultrafilter.ne_bot (hyperfilter \u03b1)))\n\ntheorem nmem_hyperfilter_of_finite {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1} (hf : set.finite s) :\n    \u00acs \u2208 hyperfilter \u03b1 :=\n  fun (hy : s \u2208 hyperfilter \u03b1) =>\n    compl_not_mem_sets hy (hyperfilter_le_cofinite (set.finite.compl_mem_cofinite hf))\n\ntheorem Mathlib.set.finite.nmem_hyperfilter {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1}\n    (hf : set.finite s) : \u00acs \u2208 hyperfilter \u03b1 :=\n  nmem_hyperfilter_of_finite\n\ntheorem compl_mem_hyperfilter_of_finite {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1} (hf : set.finite s) :\n    s\u1d9c \u2208 hyperfilter \u03b1 :=\n  iff.mpr ultrafilter.compl_mem_iff_not_mem (set.finite.nmem_hyperfilter hf)\n\ntheorem Mathlib.set.finite.compl_mem_hyperfilter {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1}\n    (hf : set.finite s) : s\u1d9c \u2208 hyperfilter \u03b1 :=\n  compl_mem_hyperfilter_of_finite\n\ntheorem mem_hyperfilter_of_finite_compl {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1}\n    (hf : set.finite (s\u1d9c)) : s \u2208 hyperfilter \u03b1 :=\n  compl_compl s \u25b8 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 \u27f6 Y`, then\n`\u2200 x \u2208 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 `\u2200 a, f a = 0 \u2192 f = 0`.\n* A sequence `f, g` of morphisms is exact if and only if\n  `\u2200 a, g (f a) = 0` and `\u2200 b, g b = 0 \u2192 \u2203 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 \u2192 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 \u27f6 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 \u27f6 Q) (a : over P) : over Q :=\n  \u2191(comma.hom a \u226b f)\n\n@[simp] theorem app_hom {C : Type u} [category C] {P : C} {Q : C} (f : P \u27f6 Q) (a : over P) :\n    comma.hom (app f a) = comma.hom a \u226b f :=\n  rfl\n\n/-- Two arrows `f : X \u27f6 P` and `g : Y \u27f6 P are called pseudo-equal if there is some object\n    `R` and epimorphisms `p : R \u27f6 X` and `q : R \u27f6 Y` such that `p \u226b f = q \u226b g`. -/\ndef pseudo_equal {C : Type u} [category C] (P : C) (f : over P) (g : over P) :=\n  \u2203 (R : C),\n    \u2203 (p : R \u27f6 comma.left f),\n      \u2203 (q : R \u27f6 comma.left g), Exists (Exists (p \u226b comma.hom f = q \u226b 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 \u27f6 P) :\n    \u2191a = quotient.mk \u2191a :=\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 \u27f6 Q)\n    (a : over P) (b : over P) : a \u2248 b \u2192 app f a \u2248 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 \u27f6 Q) : \u21a5P \u2192 \u21a5Q :=\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 \u27f6 Q) :=\n  has_coe_to_fun.mk (fun (x : P \u27f6 Q) => \u21a5P \u2192 \u21a5Q) pseudo_apply\n\ntheorem pseudo_apply_mk {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P \u27f6 Q)\n    (a : over P) : coe_fn f (quotient.mk a) = quotient.mk \u2191(comma.hom a \u226b 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 \u27f6 Q)\n    (g : Q \u27f6 R) (a : \u21a5P) : coe_fn (f \u226b 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 \u27f6 Q)\n    (g : Q \u27f6 R) : \u21d1g \u2218 \u21d1f = \u21d1(f \u226b g) :=\n  funext fun (x : \u21a5P) => 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 \u2248 \u21910 \u2194 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 \u21910 = quotient.mk \u21910 :=\n  quotient.sound (iff.mpr (pseudo_zero_aux R \u21910) 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} : \u21a5P := quotient.mk \u21910\n\nprotected instance has_zero {C : Type u} [category C] [abelian C] {P : C} : HasZero \u21a5P :=\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 \u21910 := rfl\n\n@[simp] theorem zero_eq_zero {C : Type u} [category C] [abelian C] {P : C} {Q : C} :\n    quotient.mk \u21910 = 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    \u2191a = 0 \u2194 comma.hom a = 0 :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (\u2191a = 0 \u2194 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 \u27f6 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 : \u21a5P) :\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 \u27f6 Q) :\n    (\u2200 (a : \u21a5P), coe_fn f a = 0) \u2192 f = 0 :=\n  fun (h : \u2200 (a : \u21a5P), 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 \u2191(\ud835\udfd9 \u226b f)) (h \u2191\ud835\udfd9))\n\ntheorem zero_morphism_ext' {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P \u27f6 Q) :\n    (\u2200 (a : \u21a5P), coe_fn f a = 0) \u2192 0 = f :=\n  Eq.symm \u2218 zero_morphism_ext f\n\ntheorem eq_zero_iff {C : Type u} [category C] [abelian C] {P : C} {Q : C} (f : P \u27f6 Q) :\n    f = 0 \u2194 \u2200 (a : \u21a5P), 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 \u27f6 Q)\n    [mono f] : function.injective \u21d1f :=\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 \u27f6 Q) :\n    function.injective \u21d1f \u2192 \u2200 (a : \u21a5P), coe_fn f a = 0 \u2192 a = 0 :=\n  fun (h : function.injective \u21d1f) (a : \u21a5P) (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 \u27f6 Q) :\n    (\u2200 (a : \u21a5P), coe_fn f a = 0 \u2192 a = 0) \u2192 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 \u27f6 Q)\n    [epi f] : function.surjective \u21d1f :=\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 \u27f6 Q) :\n    function.surjective \u21d1f \u2192 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 \u27f6 Q} {g : Q \u27f6 R} [exact f g] :\n    (\u2200 (a : \u21a5P), coe_fn g (coe_fn f a) = 0) \u2227\n        \u2200 (b : \u21a5Q), coe_fn g b = 0 \u2192 \u2203 (a : \u21a5P), 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 \u27f6 R) (a : P \u27f6 Q) : a \u226b f = 0 \u2192 coe_fn f \u2191a = 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 \u27f6 Q) (g : Q \u27f6 R) :\n    ((\u2200 (a : \u21a5P), coe_fn g (coe_fn f a) = 0) \u2227\n          \u2200 (b : \u21a5Q), coe_fn g b = 0 \u2192 \u2203 (a : \u21a5P), coe_fn f a = b) \u2192\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 \u27f6 Q) (x : \u21a5P)\n    (y : \u21a5P) :\n    coe_fn f x = coe_fn f y \u2192\n        \u2203 (z : \u21a5P),\n          coe_fn f z = 0 \u2227 \u2200 (R : C) (g : P \u27f6 R), coe_fn g y = 0 \u2192 coe_fn g z = coe_fn g x :=\n  sorry\n\n/-- If `f : P \u27f6 R` and `g : Q \u27f6 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 \u27f6 R} {g : Q \u27f6 R} {p : \u21a5P} {q : \u21a5Q} :\n    coe_fn f p = coe_fn g q \u2192\n        \u2203 (s : \u21a5(limits.pullback f g)),\n          coe_fn limits.pullback.fst s = p \u2227 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 [] (\u03bb 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 [] $ (\u03bb 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) $ (\u03bb 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 \u2190 get_env,\n   let l := list_all_decls' e,\n   let k := l.to_list,\n   let m := list.map (\u03bb h:name, h.get_prefix) k,\n   let f := k.filter (\u03bb 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 \u2190 ident,\n    resolved \u2190 resolve_constant given_name,\n    d \u2190 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 \u2190 get_env,\n    l \u2190 get_decl n,\n    if is_structure env n then\n    do fields \u2190 returnopt $ structure_fields env n,\n        let res := map (\u03bb h, name.append n h) fields,\n        k \u2190 mmap (\u03bb h, do l \u2190 get_decl h, pure $ list_names l.type) res,\n        let clean := list.erase_dup (list.join k),\n        let final := list.filter (\u03bb h, \u00ac 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 \u2190 get_env,\n    l \u2190 get_decl n,\n    if is_structure env n then\n    do fields \u2190 returnopt $ structure_fields env n,\n        let res := map (\u03bb h, name.append n h) fields,\n        k \u2190 mmap (\u03bb h, do l \u2190 get_decl h, pure $ list_names l.value) res,\n        let clean := list.erase_dup (list.join k),\n        let final := list.filter (\u03bb h, \u00ac 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) : \u2115 \u2192 tactic(list name)\n| 0 := name_dir_deps n\n| (succ m) :=\n do l \u2190 name_dir_deps_depth m <|> name_dir_deps n,\n    l' \u2190 mmap (\u03bb 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) : \u2115 \u2192 tactic(list name)\n| 0 := name_dir_deps_val n\n| (succ m) :=\n do l \u2190 name_dir_deps_depth_val m <|> name_dir_deps_val n,\n    l' \u2190 mmap (\u03bb 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 {\u03b1} : (xs : List \u03b1) \u2192 Decidable (xs = [])\n| [] => isTrue rfl\n| _::_ => isFalse List.noConfusion\n\ninstance {\u03b1} : (xs : List \u03b1) \u2192 Decidable ([] = xs)\n| [] => isTrue rfl\n| _::_ => isFalse List.noConfusion\n\nprotected def ext'Aux {\u03b1} : (as\u2081 as\u2082 : List \u03b1) \u2192 List Prop\n| [], [] => []\n| [], _::_ => [False]\n| _::_, [] => [False]\n| a\u2081::as\u2081, a\u2082::as\u2082 => (a\u2081 = a\u2082) :: List.ext'Aux as\u2081 as\u2082\n\nprotected theorem ext' {\u03b1} : (as\u2081 as\u2082 : List \u03b1) \u2192 All (List.ext'Aux as\u2081 as\u2082) \u2192 as\u2081 = as\u2082\n| [], [], _ => rfl\n| [], _::_, All.cons h _ => False.elim h\n| _::_\u2081, [], All.cons h _ => False.elim h\n| _::as\u2081, _::as\u2082, All.cons h hs => h \u25b8 List.ext' as\u2081 as\u2082 hs \u25b8 rfl\n\nprotected theorem ext'Iff {\u03b1} (as\u2081 as\u2082 : List \u03b1) : All (List.ext'Aux as\u2081 as\u2082) \u2194 as\u2081 = as\u2082 := by\n  constr\n  exact List.ext' as\u2081 as\u2082\n  intro h\n  cases h\n  induction as\u2081 with\n  | nil => exact All.nil\n  | cons _ _ H => exact All.cons rfl H\n\nprotected theorem ext'Eq {\u03b1} (as\u2081 as\u2082 : List \u03b1) : All (List.ext'Aux as\u2081 as\u2082) = (as\u2081 = as\u2082) :=\n  propext (List.ext'Iff as\u2081 as\u2082)\n\ninstance (x : \u03b1) (xs : List \u03b1) : Nat.IsPos (List.length (x :: xs)) := \u27e8Nat.zero_lt_succ _\u27e9\n\nlemma map_pure {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : [a].map f = [f a] := rfl\n\nlemma map_comp {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (as : List \u03b1) : as.map (g \u2218 f) = (as.map f).map g := by\n  symmetry\n  exact map_map ..\n\n@[simp] lemma pure_bind {\u03b1 \u03b2} (f : \u03b1 \u2192 List \u03b2) (a : \u03b1) : [a].bind f = f a := by rw [cons_bind, nil_bind, append_nil]\n\nlemma bind_assoc {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 List \u03b2) (g : \u03b2 \u2192 List \u03b3) (as : List \u03b1) : (as.bind f).bind g = as.bind (\u03bb 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 {\u03b1} (p : \u03b1 \u2192 Bool) (xs : List \u03b1) : xs.all p = true \u2194 All (xs.map \u03bb 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, \u2190H, Bool.and_eq_true_iff]\n\nlemma all_eq_false_iff_any_false {\u03b1} (p : \u03b1 \u2192 Bool) (xs : List \u03b1) : xs.all p = false \u2194 Any (xs.map \u03bb 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, \u2190H, Bool.and_eq_false_iff]\n\nlemma any_eq_true_iff_any_true {\u03b1} (p : \u03b1 \u2192 Bool) (xs : List \u03b1) : xs.any p = true \u2194 Any (xs.map \u03bb 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, \u2190H, Bool.or_eq_true_iff]\n\nlemma any_eq_false_iff_all_false {\u03b1} (p : \u03b1 \u2192 Bool) (xs : List \u03b1) : xs.any p = false \u2194 All (xs.map \u03bb 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, \u2190H, Bool.or_eq_false_iff]\n\n/- take -/\n\ntheorem take_nil {\u03b1} (n : Nat) : take n [] = ([] : List \u03b1) := by cases n <;> rfl\n\ntheorem take_cons {\u03b1} (a : \u03b1) (as : List \u03b1) (n : Nat) : take (n+1) (a :: as) = a :: take n as := rfl\n\ntheorem take_zero {\u03b1} (as : List \u03b1) : take 0 as = [] := rfl\n\ntheorem take_all {\u03b1} (as : List \u03b1) : 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 {\u03b1} (a : \u03b1) (as : List \u03b1) (n : Nat) : drop (n+1) (a :: as) = drop n as := rfl\n\ntheorem drop_zero {\u03b1} (as : List \u03b1) : drop 0 as = as := rfl\n\ntheorem drop_all {\u03b1} (as : List \u03b1) : 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 {\u03b1} (as : List \u03b1) (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 [\u2190getElem_eq_get]\n      exact ih ..\n\n/- extract -/\n\ndef extract (as : List \u03b1) (start stop : Nat) := (as.drop start).take (stop - start)\n\ntheorem extract_stop (as : List \u03b1) (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 \u03b1) (start stop : Nat) (hstart : start < stop) (hstop : stop \u2264 as.length) :\n  as.extract start stop = as.get \u27e8start, Nat.lt_of_lt_of_le hstart hstop\u27e9 :: 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 \u03b1) : 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 {\u03b1} (a : \u03b1) : replicate 0 a = [] := rfl\n\ntheorem replicate_add {\u03b1} (a : \u03b1) : (m n : Nat) \u2192 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 \u03b1) : as.dropLast.length = as.length - 1 := by\n  cases as <;> simp\n\nprivate theorem get_dropLast.aux {as : List \u03b1} {i : Nat} : i < as.dropLast.length \u2192 i < as.length :=\n  fun h => Nat.lt_of_lt_of_le h (length_dropLast as \u25b8 Nat.pred_le as.length)\n\ntheorem get_dropLast (as : List \u03b1) (i : Fin as.dropLast.length) :\n  as.dropLast.get i = as.get \u27e8i.val, get_dropLast.aux i.isLt\u27e9 := 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    | _ :: _, \u27e80, _\u27e9 => simp [dropLast]\n    | _ :: _, \u27e8i+1, hi\u27e9 => simp [dropLast, ih]\n\n/- all/any -/\n\n@[specialize] def allTR : List \u03b1 \u2192 (\u03b1 \u2192 Bool) \u2192 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 \u03b1 xs p\n  induction xs with\n  | nil => rfl\n  | cons _ _ ih => exact congrArg _ ih\n\n@[specialize] def anyTR : List \u03b1 \u2192 (\u03b1 \u2192 Bool) \u2192 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 \u03b1 xs p\n  induction xs with\n  | nil => rfl\n  | cons _ _ ih => exact congrArg _ ih\n\ntheorem not_all_eq_any_not (p : \u03b1 \u2192 Bool) (as : List \u03b1) : (!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 : \u03b1 \u2192 Bool) (as : List \u03b1) : (!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 : \u03b1 \u2192 Bool) (q : Bool) (as : List \u03b1) : (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 : \u03b1 \u2192 Bool) (q : Bool) (as : List \u03b1) : (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 : \u03b1 \u2192 Bool) (q : Bool) (as : List \u03b1) : (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 : \u03b1 \u2192 Bool) (q : Bool) (as : List \u03b1) : (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 {\u03b1 n} (f : Fin n \u2192 \u03b1) : List \u03b1 :=\n  let rec loop : Fin (n+1) \u2192 List \u03b1 \u2192 List \u03b1\n  | \u27e80, _\u27e9, xs => xs\n  | \u27e8i+1, hi\u27e9, xs => loop \u27e8i, Nat.lt_trans (Nat.lt_succ_self i) hi\u27e9 (f \u27e8i, Nat.lt_of_succ_lt_succ hi\u27e9 :: xs)\n  loop \u27e8n, Nat.lt_succ_self n\u27e9 []\n\n@[implemented_by List.ofFunTR]\nprotected def ofFun {\u03b1} : {n : Nat} \u2192 (f : Fin n \u2192 \u03b1) \u2192 List \u03b1\n| 0, _ => []\n| n+1, f => f \u27e80, Nat.zero_lt_succ n\u27e9 :: List.ofFun fun i => f i.succ\n\ntheorem ofFun_length {\u03b1 n} (f : Fin n \u2192 \u03b1) : (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 {\u03b1 n} (f : Fin n \u2192 \u03b1) (i : Fin (List.ofFun f).length) : (List.ofFun f).get i = f (ofFun_length f \u25b8 i) := by\n  induction n with\n  | zero =>\n    match i with\n    | \u27e8_,_\u27e9 => contradiction\n  | succ n ih =>\n    match i with\n    | \u27e80, _\u27e9 =>\n      transitivity (f \u27e80, Nat.zero_lt_succ n\u27e9)\n      \u00b7 simp only [List.ofFun]\n        rfl\n      \u00b7 congr 1\n        apply Fin.eq\n        rw [Fin.val_ndrec]\n    | \u27e8i+1, hi\u27e9 =>\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 -> \u2115\n\ndef state.update : string -> \u2115 -> state -> state\n| name val \u03c3 := (\u03bb name', if name' = name then val else \u03c3 name')\n\nnotation s `{` name ` \u21a6 ` val `}` := state.update name val s\n\n@[simp] lemma state.update_apply (name : string) (val : \u2115) (s : state) :\n  s{name \u21a6 val} name = val :=\nbegin\n  unfold state.update,\n  finish,\nend\n\n@[simp] lemma state.update_apply_ne (name name' : string) (val : \u2115) (s : state)\n    (h : name' \u2260 name) :\n  s{name \u21a6 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\u2081 val\u2082 : \u2115) (s : state) :\n  s{name \u21a6 val\u2082}{name \u21a6 val\u2081} = s{name \u21a6 val\u2081} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp [h]\nend\n\n@[simp] lemma state.update_swap (name\u2081 name\u2082 : string) (val\u2081 val\u2082 : \u2115) (s : state)\n    (h : name\u2081 \u2260 name\u2082 . tactic.dec_trivial) :\n  s{name\u2082 \u21a6 val\u2082}{name\u2081 \u21a6 val\u2081} = s{name\u2081 \u21a6 val\u2081}{name\u2082 \u21a6 val\u2082} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name\u2081;\n    by_cases name' = name\u2082;\n    simp * at *\nend\n\n@[simp] lemma state.update_id (name : string) (s : state) :\n  s{name \u21a6 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 : \u2115) :\n  (\u03bb_, val){name \u21a6 val} = (\u03bb_, val) :=\nby apply funext; simp\n\n/-! # Propositions -/\n\ndef prop: Type := state -> Prop\n\n/-! # Expression -/\n\ndef expression: Type := state -> \u2115\n\n/-! ## Language -/\n\ninductive stmt : Type\n| skip            : stmt\n| assign          : string \u2192 expression \u2192 stmt\n| non_det_assign  : string \u2192 stmt\n| seq             : stmt \u2192 stmt \u2192 stmt\n| choice          : stmt \u2192 stmt \u2192 stmt\n| star            : stmt \u2192 stmt\n-- | local_var       : string \u2192 stmt \u2192 stmt\n| error           : stmt\n| assumes         : prop \u2192 stmt\n\n-- Language notation\n\ninfixr ` ;; ` : 90 := stmt.seq\n\ninfixr ` <+> ` : 90 := stmt.choice\n\npostfix `**` : 90 := stmt.star\n\nnotation `[` x ` \u21a3 ` 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': \u2115) (x: string) : IncLoLang.state -> Prop :=\n  -- \u03bb \u03c3', \u2203 \u03c3, P \u03c3 \u2227 \u03c3' = \u03c3{x \u21a6 x'}\n  -- This is the definition given int he paper but it is wrong\n  \u03bb \u03c3', P (\u03c3'{x \u21a6 x'})\n-- ie, True for \u03c3 if P(\u03c3{x \u21a6 x'})\n\nnotation P `{` name ` \u21a3 ` val `}` := P.update_val val name\n\n/-! # Language semantics -/\n\ninductive LogicType : Type\n| er\n| ok\n\ndef repeat: IncLoLang.stmt \u2192 \u2115 \u2192 IncLoLang.stmt \n| C nat.zero := IncLoLang.stmt.skip\n| C (nat.succ i) := (repeat C (i)) ;; C\n\ninductive lang_semantics: IncLoLang.stmt \u2192 LogicType \u2192 IncLoLang.state \u2192 IncLoLang.state \u2192 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 \u21a3 e] LogicType.ok s (s{x \u21a6 (e s)})\n| non_det_assign {x s} (v: \u2115) :\n  lang_semantics (IncLoLang.stmt.non_det_assign x) LogicType.ok s (s{x \u21a6 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\u2081 C\u2082 ty s\u2081 s\u2082} (h: (lang_semantics C\u2081 ty s\u2081 s\u2082)): \n  lang_semantics (C\u2081 <+> C\u2082) ty s\u2081 s\u2082\n| choice_right {C\u2081 C\u2082 ty s\u2081 s\u2082} (h: (lang_semantics C\u2082 ty s\u2081 s\u2082)): \n  lang_semantics (C\u2081 <+> C\u2082) ty s\u2081 s\u2082\n| star {C s\u2081 s\u2082 ty} (i: \u2115) (h: lang_semantics (repeat C i) ty s\u2081 s\u2082):\n  lang_semantics (C**) ty s\u2081 s\u2082\n-- | local_var {C s\u2081 s\u2082 ty} (x: string) (v: \u2115) (h: lang_semantics C ty s\u2081 s\u2082):\n--   lang_semantics ([loc x . C]) ty (s\u2081{x \u21a6 v}) (s\u2082{x \u21a6 v})\n\n/-! # Free-/\n\n-- Perhaps invert\ndef prop.Free (P: prop): set string :=\n  \u03bb x, \u2203 \u03c3 v, (P \u03c3 \u2227 \u00ac(P (\u03c3{x \u21a6 v})))\n\n-- def expression.Free (e: expression): set string := \n--   \u03bb x, \u2203 \u03c3 v, e \u03c3 \u2260 e (\u03c3{x \u21a6 v})\n\n-- Set of variables x such that if \u2200 x, \u03c3 x = \u03c3' x, then e \u03c3 = e \u03c3' \ndef expression.FreeProp (e: expression): set string \u2192 Prop := \n  (\u03bb F, \u2200 \u03c3 \u03c3': state, (\u2200 f: F, \u03c3 f = \u03c3' f) \u2192 e \u03c3 = e \u03c3' )\n\ndef expression.Free (e: expression): set string := \n  \u22c2\u2080 (\u03bb 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} \u2192 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 \u2208 expression.Free e \u2194 \u2203 \u03c3 v, e \u03c3 \u2260 e (\u03c3{x \u21a6 v}) := \n  -- \u03bb x, \u2203 \u03c3 v, e \u03c3 \u2260 e (\u03c3{x \u21a6 v})\nbegin\n  split,\n  {\n    intro hx,\n    by_contra,\n    push_neg at h,\n    specialize hx (\u03bb y : string, y \u2260 x),\n    have H: e.FreeProp (\u03bb (y : string), y \u2260 x), {\n      intros \u03c3 \u03c3' hf,\n      have H: \u2203 v, \u03c3' = \u03c3{x \u21a6 v}, {\n        use \u03c3' 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 \u03c3 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 \u03c3 h,\n    cases h with v,\n    by_contra,\n    specialize hF \u03c3 (\u03c3{x \u21a6 v}), \n    simp at hF,\n    have H: (\u2200 (y : string), y \u2208 F \u2192 \u03c3 y = \u03c3{x \u21a6 v} y), {\n      intros y hy,\n      have H: y \u2260 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 \u2192 set string \n| stmt.skip                 := {}\n| ([z \u21a3 e\u2082])                := {z} \u222a e\u2082.Free\n| (stmt.non_det_assign z)   := {z}\n| (C\u2081 ;; C\u2082)                := (stmt.Free C\u2081) \u222a (stmt.Free C\u2082)\n| (C\u2081 <+> C\u2082)               := (stmt.Free C\u2081) \u222a (stmt.Free C\u2082)\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 \u2192 string \u2192 state \u2192 state\n-- | y x := \u03bb \u03c3, \u03c3{y \u21a6 \u03c3 x}\n| y x := \u03bb \u03c3, \u03c3{y \u21a6 \u03c3 x}{x \u21a6 0}\n\nnotation \u03c3 `\u27e8` vto `//` vfrom `\u27e9` :=  state.substitute vto vfrom \u03c3\n\ndef prop.substitute : string \u2192 string \u2192 prop \u2192 prop\n| x s P := \u03bb \u03c3, P (\u03c3\u27e8 x // s\u27e9)\n\nnotation P `[` val `//` name `]` :=  prop.substitute name val P\n\ndef expression.substitute : string \u2192 string \u2192 expression \u2192 expression\n| x y e := \u03bb \u03c3, e (\u03c3\u27e8 x // y \u27e9)\n\ndef stmt.substitute : string \u2192 string \u2192 stmt \u2192 stmt\n| x y stmt.skip                 := stmt.skip\n| x y ([z \u21a3 e\u2082])                := if x = z then [y \u21a3 \u03bb \u03c3, ((expression.substitute x y e\u2082) \u03c3)] else [z \u21a3 \u03bb \u03c3, ((expression.substitute x y e\u2082) \u03c3)]  -- 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\u2081 ;; C\u2082)                := (stmt.substitute x y C\u2081) ;; (stmt.substitute x y C\u2082)\n| x y (C\u2081 <+> C\u2082)               := (stmt.substitute x y C\u2081) <+> (stmt.substitute x y C\u2082)\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 \u2192 set string\n| (C\u2081 ;; C\u2082) := (C\u2081.Mod) \u222a (C\u2082.Mod)\n| (C\u2081 <+> C\u2082) := (C\u2081.Mod) \u222a (C\u2082.Mod)\n| (C**) := (C.Mod)\n| ([x \u21a3 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\u2081 C\u2082: stmt):\n   C\u2081.Mod \u2286 (C\u2081 ;; C\u2082).Mod :=\nbegin \n  intro h,\n  rw stmt.Mod,\n  finish,\nend\n\nlemma mod_elem_right_elem_seq (C\u2081 C\u2082: stmt):\n   C\u2082.Mod \u2286 (C\u2081 ;; C\u2082).Mod :=\nbegin \n  intro h,\n  rw stmt.Mod,\n  finish,\nend\n\nlemma mod_elem_left_elem_choice (C\u2081 C\u2082: stmt):\n   C\u2081.Mod \u2286 (C\u2081 <+> C\u2082).Mod :=\nbegin \n  intro h,\n  rw stmt.Mod,\n  finish,\nend\n\nlemma mod_elem_right_elem_choice (C\u2081 C\u2082: stmt):\n   C\u2082.Mod \u2286 (C\u2081 <+> C\u2082).Mod :=\nbegin \n  intro h,\n  rw stmt.Mod,\n  finish,\nend\n\nlemma start_seq {C: stmt} {\u03c3 \u03c3': state} {ty: LogicType}:\n  IncLoLang.lang_semantics (C** ;; C) ty \u03c3 \u03c3' \u2192 IncLoLang.lang_semantics (C**) ty \u03c3 \u03c3' :=\nbegin\n  intro h,\n  cases h,\n  {\n    have H: \u2203 N, lang_semantics (repeat C N) ty \u03c3 \u03c3',\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 \u2286 C.Free :=\nbegin\n  induction C with v r _ C\u2081 C\u2082 hC\u2081 hC\u2082 C\u2081 C\u2082 hC\u2081 hC\u2082 _ 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\u2081 hC\u2082,\n  },\n  case stmt.choice {\n    rw stmt.Mod,\n    rw stmt.Free,\n    exact set.union_subset_union hC\u2081 hC\u2082,\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  (\u00ace.Free x) \u2192 \u2200 \u03c3 v, e \u03c3 = e (\u03c3{x \u21a6 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  (\u00ace.Free x) \u2192 \u2200 \u03c3 v, e \u03c3 \u2194 e (\u03c3{x \u21a6 v}) :=\nbegin\n  intro h,\n  unfold prop.Free at h,\n  push_neg at h,\n  intros \u03c3 v,\n  split,\n  { exact h \u03c3 v, },\n  {\n    specialize h (\u03c3{x \u21a6 v}) (\u03c3 x),\n    have H: \u03c3{x \u21a6 v}{x \u21a6 \u03c3 x} = \u03c3, {\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  (\u00acC.Free x) \u2192 (\u2200 \u03c3 \u03c3' ty v, lang_semantics C ty \u03c3 \u03c3' \u2192 lang_semantics C ty (\u03c3{x \u21a6 v}) (\u03c3'{x \u21a6 v})) :=\nbegin\n  induction C with \n    y \n    e y \n    C\u2081 C\u2082 C\u2081h C\u2082h \n    C\u2081 C\u2082 C\u2081h C\u2082h\n    C Ch\n    z C,\n  case stmt.skip {\n    intros h\u2081 \u03c3 \u03c3' ty v h,\n    cases h,\n    exact lang_semantics.skip,\n  },\n  case stmt.assign {\n    intros h\u2081 \u03c3 \u03c3' ty v h\u2082,\n    cases h\u2082,\n    by_cases x = y,\n    {\n      exfalso,\n      rw stmt.Free at h\u2081,\n      apply h\u2081,\n      left,\n      exact set.mem_singleton_iff.mpr h,\n    },\n    {\n      rw \u2190 state.update,\n      rw state.update_swap _ _ _ _ _ (h),\n      -- have H: (\u03bb (name' : string), \u03c3 name') = \u03c3, {exact rfl}\n      rw stmt.Free at h\u2081,\n      have H: e \u03c3 = e (\u03c3{x \u21a6 v}), {\n        by_contra,\n        have H2: x \u2208 e.Free, {\n          rw expression.Free.semantics e,\n          use \u03c3,\n          use v,\n        },\n        apply h\u2081,\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\u2081 \u03c3 \u03c3' ty v h\u2082,\n    cases h\u2082,\n    by_cases x = y,\n    {\n      exfalso,\n      rw stmt.Free at h\u2081,\n      apply h\u2081,\n      exact set.mem_singleton_iff.mpr h,\n    },\n    {\n      rw \u2190 state.update,\n      rw state.update_swap _ _ _ _ _ h,\n      -- have H: (\u03bb (name' : string), \u03c3 name') = \u03c3, {exact rfl}\n      rw stmt.Free at h\u2081,\n\n      exact lang_semantics.non_det_assign h\u2082_v,\n    }\n  },\n  case stmt.seq {\n    intros h\u2081 \u03c3 \u03c3' ty v h\u2082,\n    rw stmt.Free at h\u2081,\n    specialize C\u2081h (by {\n      by_contra,\n      apply h\u2081,\n      left,\n      exact h,\n    }),\n    specialize C\u2082h (by {\n      by_contra,\n      apply h\u2081,\n      right,\n      exact h,\n    }),\n    cases h\u2082,\n    {\n      specialize C\u2081h \u03c3 h\u2082_t LogicType.ok v h\u2082_H1,\n      specialize C\u2082h h\u2082_t \u03c3' ty v h\u2082_H2,\n      exact lang_semantics.seq_ty C\u2081h C\u2082h,\n    },\n    {\n      specialize C\u2081h \u03c3 \u03c3' LogicType.er v h\u2082_H1,\n      exact lang_semantics.seq_er_1 C\u2081h,\n    },\n  },\n  case stmt.choice {\n    intros h\u2081 \u03c3 \u03c3' ty v h\u2082,\n    rw stmt.Free at h\u2081,\n\n    cases h\u2082,\n    {\n      specialize C\u2081h (by {\n        by_contra,\n        apply h\u2081,\n        left,\n        exact h,\n      }) \u03c3 \u03c3' ty v h\u2082_h,\n      exact lang_semantics.choice_left C\u2081h,\n    },\n    {\n      specialize C\u2082h (by {\n        by_contra,\n        apply h\u2081,\n        right,\n        exact h,\n      }) \u03c3 \u03c3' ty v h\u2082_h,\n      exact lang_semantics.choice_right C\u2082h,\n    },\n  },\n  case stmt.star {\n    intros h\u2081 \u03c3 \u03c3' ty v h\u2082,\n    rw stmt.Free at h\u2081,\n    specialize Ch h\u2081,\n    cases h\u2082,\n    use h\u2082_i,\n    revert \u03c3 \u03c3' ty,\n    induction h\u2082_i,\n    {\n      intros \u03c3 \u03c3' ty h,\n      rw repeat at h,\n      cases h,\n      rw repeat,\n      exact lang_semantics.skip,\n    },\n    {\n      intros \u03c3 \u03c3' ty h,\n      rw repeat,\n      rw repeat at h,\n      cases h,\n      {\n        exact lang_semantics.seq_ty \n          (h\u2082_i_ih \u03c3 h_t LogicType.ok h_H1)\n          (Ch h_t \u03c3' ty v h_H2),\n      },\n      { exact lang_semantics.seq_er_1 ( h\u2082_i_ih \u03c3 \u03c3' LogicType.er h_H1 ), }\n    }\n  },\n  -- case stmt.local_var {\n  --   intros h\u2081 \u03c3 \u03c3' ty v,\n  --   rw stmt.Free at h\u2081,\n  --   by_cases H: x = z,\n  --   {\n  --     cases H,\n  --     intro h,\n  --     cases h,\n  --     rw \u2190 state.update,\n  --     rw \u2190 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\u2082: x \u2209 C.Free, {\n  --       by_contra,\n  --       apply h\u2081,\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\u2082,\n  --     intro h,\n  --     cases h,\n  --     rw \u2190 state.update,\n  --     rw \u2190 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\u2081 h_s\u2082 ty v h_h)\n  --   },\n  -- },\n  case stmt.error {\n    intros h\u2081 \u03c3 \u03c3' ty v h,\n    cases h,\n    exact lang_semantics.error,\n  },\n  case stmt.assumes {\n    intros h\u2081 \u03c3 \u03c3' ty v h,\n    cases h,\n    rw stmt.Free at h\u2081,\n    rw prop.Free at h\u2081,\n    push_neg at h\u2081,\n    exact lang_semantics.assumes_ok (h\u2081 \u03c3 v h_h),\n  },\nend\n\nlemma assign_semantics {x \u03c3 \u03c3' ty} {e: expression}: \n  lang_semantics ([x \u21a3 e]) ty \u03c3 \u03c3' \u2192 \u03c3{x \u21a6 e \u03c3} = \u03c3' \u2227 ty = LogicType.ok:=\nbegin\n  intro h,\n  cases h,\n  split,\n  repeat { refl },\nend\n\nlemma non_det_assign_semantics {x \u03c3 \u03c3' ty}: \n  lang_semantics (stmt.non_det_assign x) ty \u03c3 \u03c3' \u2192 \u2203 v, \u03c3' = \u03c3{x \u21a6 v} \u2227 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: \u2115} {P: prop} :\n  prop.Free (P{ x \u21a3 v }) \u2286 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 \u03c3,\n  use \u03c3{x \u21a6 v},\n  have Hxy: x \u2260 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) \u222a {x} \u2286 (stmt.Free ([x \u21a3 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 \u27e8 x, y \u27e9, \n    cases hy,\n    {\n      -- rcases hy with \u27e8\u03c3, \u27e8v, h\u03c3\u27e9\u27e9,\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} {\u03c3 \u03c3' : state} (Hyx: y \u2260 x) (Hfreey: y \u2209 ([z \u21a3 e].Free)):\n  lang_semantics ([z \u21a3 e]) ty (\u03c3) (\u03c3') \u2192  \n    lang_semantics ([z \u21a3 e]{y // x}) ty (\u03c3\u27e8 y // x\u27e9) (\u03c3'\u27e8 y // x \u27e9) :=\nbegin\n  have H := (set.compl_subset_compl.mpr free_assign) Hfreey,\n  have H\u2081 : y \u2209 e.Free, { by_contra, finish, },\n  have H\u2081 := not_free_expression H\u2081,\n\n  have H\u2082 : y \u2260 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 \u2190 state.update,\n    rw expression.substitute,\n    simp,\n\n    have H: \u03c3{x \u21a6 e \u03c3}\u27e8y//x\u27e9= \u03c3\u27e8y//x\u27e9{y \u21a6 (\u03bb (\u03c3 : state), e (\u03c3\u27e8x//y\u27e9)) (\u03c3\u27e8y//x\u27e9)}, \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 \u2190 state.update,\n    rw state.substitute,\n    simp,\n    rw state.update_swap _ _ _ _ _ H\u2082,\n    rw state.update_swap _ _ _ _ _ hx,\n    have H: \u03c3{z \u21a6 e \u03c3} x = \u03c3 x, {\n      funext, finish,\n    },\n    rw H,\n    rw expression.substitute,\n    have H: e \u03c3 = (\u03bb (\u03c3 : state), e (\u03c3\u27e8x//y\u27e9)) (\u03c3{y \u21a6 \u03c3 x}{x \u21a6 0}), {\n      simp,\n      rw state.substitute,\n      simp,\n      rw \u2190 state.update_swap _ _ _ _ _ Hyx,\n      rw state.update_override,\n      have H: \u03c3{x \u21a6 \u03c3{y \u21a6 \u03c3 x}{x \u21a6 0} y} = \u03c3, {\n        funext, finish,\n      },\n      rw H,\n      exact H\u2081 \u03c3 0,\n    },\n    rw H,\n    exact lang_semantics.assign,\n  },\nend\n\nlemma substitution_rule {ty C y x} {\u03c3 \u03c3' : state} (Hyx: y \u2260 x) (Hfreey: y \u2209 stmt.Free C):\n  lang_semantics C ty (\u03c3) (\u03c3') \u2192 \n    -- If C can take \u03c3 to \u03c3'\n    lang_semantics (C{y // x}) ty (\u03c3\u27e8 y // x\u27e9) (\u03c3'\u27e8 y // x \u27e9) :=\n    -- Then C(y/x) can take \u03c3 with y set to x's value in \u03c3 to \u03c3' with y set to x's value in \u03c3' \nbegin\n  revert ty \u03c3 \u03c3',\n\n  induction C with z e z \n    C\u2081 C\u2082 hC\u2081 hC\u2082\n    C\u2081 C\u2082 hC\u2081 hC\u2082\n    C hC,\n    -- z C hC,\n  case stmt.skip {\n    -- Skip case is trivial as \u03c3 = \u03c3'\n    intros _ \u03c3 _ h,\n    cases h,\n    exact lang_semantics.skip,\n  },\n  case stmt.assign {\n    intros ty \u03c3 \u03c3' hls,\n    exact assign_case Hyx Hfreey hls,\n  },\n  case stmt.non_det_assign {\n    intros ty \u03c3 \u03c3' 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 \u2190 state.update,\n      rw state.update_swap _ _ _ _ _ Hyx,\n      rw if_pos (rfl),\n      simp,\n      rw \u2190 state.update_swap _ _ _ _ _ Hyx,\n      rw \u2190 state.update_swap _ _ _ _ _ Hyx,\n      have H: \u03c3{x \u21a6 0}{y \u21a6 hls_v} = \u03c3{x \u21a6 0}{y \u21a6 \u03c3 x}{y \u21a6 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 \u2190 state.update,\n      rw if_neg h,\n      by_cases H\u2082: z = y,\n      {\n        cases H\u2082,\n        rw state.update_override,\n        rw state.update_swap _ _ _ _ _ h,\n        have H: \u03c3{x \u21a6 0}{y \u21a6 \u03c3 x} = \u03c3{x \u21a6 0}{y \u21a6 \u03c3 x}{y \u21a6 \u03c3 x}, { rw state.update_override, },\n        nth_rewrite 1 H,\n        exact lang_semantics.non_det_assign (\u03c3 x),\n      },\n      {\n        rw state.update_swap _ _ _ _ _ (ne.symm H\u2082),\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 \u03c3 \u03c3' hls,\n    cases hls,\n    {\n      specialize hC\u2081 (by {\n        by_contra,\n        apply Hfreey,\n        left,\n        exact h,\n      }) hls_H1,\n      specialize hC\u2082 (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\u2081 hC\u2082,\n    },\n    {\n      specialize hC\u2081 (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\u2081,\n    }\n  },\n  case stmt.choice {\n    intros ty \u03c3 \u03c3' hls,\n    cases hls,\n    {\n      specialize hC\u2081 (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\u2081,\n    },\n    {\n      specialize hC\u2082 (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\u2082,\n    }\n  },\n  case stmt.star {\n    intros ty \u03c3 \u03c3' hls,\n    cases hls,\n    rw stmt.substitute,\n    use hls_i,\n    revert ty \u03c3 \u03c3' ,\n    induction hls_i,\n    {\n      intros ty \u03c3 \u03c3' 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 \u03c3 \u03c3' 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 \u03c3 \u03c3' 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 \u2209 C.Free, { finish, },\n  --     rw \u2190 state.update,\n  --     rw \u2190 state.update,\n  --     rw state.substitute,\n  --     simp,\n  --     have H\u2082 := free_language_semantics C y H,\n  --     rw \u2190 assign_order Hyx,\n  --     rw \u2190 assign_order Hyx,\n  --     rw assign_order_eq,\n  --     rw assign_order_eq,\n  --     specialize H\u2082 hls_s\u2081 hls_s\u2082 ty hls_v hls_h, \n  --     exact lang_semantics.local_var _ _ H\u2082,\n  --   },\n  --   {\n  --     rw if_neg h,\n  --     rw stmt.Free at Hfreey,\n  --     by_cases y = z,\n  --     {\n  --       cases h,\n  --       rw \u2190 state.update,\n  --       rw state.substitute,\n  --       rw \u2190 state.update,\n  --       simp,\n  --       have H1: hls_s\u2081{y \u21a6 hls_v} x = hls_s\u2081 x, { unfold state.update, finish, },\n  --       have H2: hls_s\u2082{y \u21a6 hls_v} x = hls_s\u2082 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 \u2260 b (\u03c31, \u03c32) \u2208 \u27e6local x . C\u27e7 and y \u2209 Free C \u21d2 (\u03c31(y/b), \u03c32(y/b)) \u2208 \u27e6local x . C(y/b)\u27e7\n  --       -- ({b = 1}, {b = 2}) \u2208 \u27e6local y . b = 2\u27e7 \u21d2 ({y = 1}, {y = 2}) \u2208 \u27e6local y . y = 2\u27e7\n  --     },\n  --     {\n  --       have H: y \u2209 C.Free, { by_contra, finish, },\n  --       specialize hC H hls_h,\n  --       rw \u2190 state.update,\n  --       rw \u2190 state.update,\n  --       simp,\n  --       have H1: \u2200 \u03c3, ((\u03c3{z \u21a6 hls_v})\u27e8y//x\u27e9) = ((\u03c3\u27e8y//x\u27e9){z \u21a6 hls_v}), {\n  --         intro \u03c3,\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\u2081),\n  --       rw (H1 hls_s\u2082),\n  --       exact lang_semantics.local_var _ _ hC,\n  --     },\n  --   },\n  -- },\n  {\n    intros ty \u03c3 \u03c3' hls,\n    cases hls,\n    rw stmt.substitute,\n    exact lang_semantics.error,  \n  },\n  {\n    intros ty \u03c3 \u03c3' hls,\n    cases hls,\n    rw stmt.substitute,\n    have H: (C[y//x]) (\u03c3\u27e8y//x\u27e9), { \n      unfold prop.substitute,\n      unfold state.substitute,\n      rw state.update_override,\n      have H: \u03c3{y \u21a6 \u03c3 x}{x \u21a6 \u03c3{y \u21a6 \u03c3 x}{x \u21a6 0} y} = \u03c3{y \u21a6 \u03c3 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 \u03c3 (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} {\u03c3 \u03c3': state} {ty: LogicType}: \n  (lang_semantics C ty \u03c3 \u03c3') \u2227 (x \u2209 C.Free) \u2192 \u03c3 x = \u03c3' x :=\nbegin \n  revert \u03c3 \u03c3' ty,\n  induction C with \n    y e\n    y\n    C\u2081 C\u2082 hC\u2081 hC\u2082\n    C\u2081 C\u2082 hC\u2081 hC\u2082\n    C Ch,\n  case stmt.skip {\n    rintros \u03c3 \u03c3' ty \u27e8 hls, hxFree \u27e9,\n    cases hls,\n    refl,\n  },\n  case stmt.assign {\n    rintros \u03c3 \u03c3' ty \u27e8 hls, hxFree \u27e9,\n    cases hls,\n    unfold stmt.Free at hxFree,\n    have H: x \u2260 y, { finish, },\n    simp,\n    rw if_neg H,\n  },\n  case stmt.non_det_assign {\n    rintros \u03c3 \u03c3' ty \u27e8 hls, hxFree \u27e9,\n    cases hls,\n    unfold stmt.Free at hxFree,\n    have H: x \u2260 y, { finish, },\n    simp,\n    rw if_neg H,\n  },\n  case stmt.seq {\n    rintros \u03c3 \u03c3' ty \u27e8 hls, hxFree \u27e9,\n    have H\u2081: x \u2209 C\u2081.Free, {by_contra, apply hxFree, left, exact h,},\n    have H\u2082: x \u2209 C\u2082.Free, {by_contra, apply hxFree, right, exact h,},\n    cases hls,\n    {\n      specialize hC\u2081 (\u27e8hls_H1, H\u2081\u27e9),\n      specialize hC\u2082 (\u27e8hls_H2, H\u2082\u27e9),\n      rw hC\u2081,\n      exact hC\u2082,\n    },\n    { exact hC\u2081 (\u27e8hls_H1, H\u2081\u27e9), },\n  },\n  case stmt.choice {\n    rintros \u03c3 \u03c3' ty \u27e8 hls, hxFree \u27e9,\n    have H\u2081: x \u2209 C\u2081.Free, {by_contra, apply hxFree, left, exact h,},\n    have H\u2082: x \u2209 C\u2082.Free, {by_contra, apply hxFree, right, exact h,},\n    cases hls,\n    {\n      specialize hC\u2081 (\u27e8hls_h, H\u2081\u27e9),\n      exact hC\u2081,\n    },\n    {\n      specialize hC\u2082 (\u27e8hls_h, H\u2082\u27e9),\n      exact hC\u2082,\n    },\n  },\n  case stmt.star {\n    rintros \u03c3 \u03c3' ty \u27e8 hls, hxFree \u27e9,\n    cases hls,\n    revert ty \u03c3 \u03c3', \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 \u03c3 \u03c3' hls,\n      rw repeat at hls,\n      rw stmt.Free at hxFree,\n      cases hls,\n      {\n        specialize Ch (\u27e8hls_H2, hxFree\u27e9),\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 \u03c3 \u03c3' ty \u27e8 hls, hxFree \u27e9,\n    cases hls,\n    refl,\n  },\n  case stmt.assumes {\n    rintros \u03c3 \u03c3' ty \u27e8 hls, hxFree \u27e9,\n    cases hls,\n    refl,\n  },\nend\n\nlemma expression.substitute.x_free {x y} (e: expression) (H: x \u2260 y) : \n  x \u2209 (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 \u03c3 h,\n  rcases h with \u27e8v, h\u27e9,\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 \u2260 y) : \n  x \u2209 (prop.substitute x y P).Free :=\nbegin\n  unfold prop.Free,\n  by_contra,\n  cases h with \u03c3 h,\n  rcases h with \u27e8v, \u27e8hp, hnp\u27e9\u27e9,\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 \u2260 y): x \u2209 (C{y // x}).Free :=\nbegin\n  -- sorry,\n  induction C with \n    z e \n    z\n    C\u2081 C\u2082 hC\u2081 hC\u2082\n    C\u2081 C\u2082 hC\u2081 hC\u2082\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\u2081 h, },\n    { exact hC\u2082 h, },\n  },\n  case stmt.choice {\n    rw stmt.substitute,\n    rw stmt.Free,\n    by_contra,\n    cases h,\n    { exact hC\u2081 h, },\n    { exact hC\u2082 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 \u2227 e.FreeProp B \u2192 e.FreeProp (A \u2229 B) := \nbegin\n  rintro \u27e8 hA, hB \u27e9,\n  unfold expression.FreeProp,\n  intros \u03c3\u2081 \u03c3\u2083 h,  \n  classical,\n  let \u03c3\u2082: state := \u03bb s, if s \u2208 A then \u03c3\u2081 s else \u03c3\u2083 s,\n  have H\u2081\u2082: e \u03c3\u2081 = e \u03c3\u2082, {\n    specialize hA \u03c3\u2081 \u03c3\u2082,\n    apply hA,\n    intro a,\n    simp[\u03c3\u2082],\n    simp,\n  },\n  have H\u2082\u2083: e \u03c3\u2082 = e \u03c3\u2083, {\n    specialize hB \u03c3\u2082 \u03c3\u2083,\n    apply hB,\n    intro b,\n    simp,\n    intro hb,\n    have H: \u2191b \u2208 A \u2229 B, { finish, },\n    simp at h,\n    exact h b (hb) (subtype.mem b),\n  },\n  rw H\u2081\u2082,\n  exact H\u2082\u2083,\nend\n\n-- lemma finite_powerset (B: set string) : B.finite \u2192 (\ud835\udcab 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 (\u27e8coe, finset.coe_injective\u27e9)),\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 {\u03b1} {s : set \u03b1} (h : s.finite) : (\ud835\udcab s).finite :=\nbegin\n  obtain \u27e8s', hs'\u27e9 := set.finite.exists_finset_coe h,\n  refine set.finite.of_finset (s'.powerset.map (\u27e8_, finset.coe_injective\u27e9)) _,\n  simp_rw [\u2190finset.mem_coe, \u2190set.ext_iff, finset.coe_map, finset.coe_powerset,\n    function.embedding.coe_fn_mk, \u2190hs', set.image_preimage_eq_iff],\n  intros x hx,\n  rw set.mem_powerset_iff at hx,\n  classical,\n  refine \u27e8s'.filter (\u2208 x), _\u27e9,\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  (\u2203 B: set string,(e.FreeProp B) \u2227 B.finite) \u2192 (e.FreeProp e.Free) :=\nbegin\n  -- Argument:\n  -- B \u2208 A so \u22c2\u2080 A \u2286 B\n  intros h\u2081,\n  cases h\u2081 with B h\u2081,\n\n  -- so \u22c2\u2080 A = \u22c2\u2080 (a \u22c2 B, a \u2208 A)\n  let AB : set (set string) := (\u03bb (x: set string), (\u2203 (a: set string), (e.FreeProp a) \u2227 x = B \u2229 a)),\n  have AB_finite: AB.finite,\n  {\n    let Bp : set (set string) := B.powerset,\n\n    have H1: AB \u2286 Bp, {\n      intros x hx,\n      rcases hx with \u27e8 a, \u27e8 b, c \u27e9 \u27e9,\n      rw c,\n      simp,\n    },\n    have H2 := finite_powerset h\u2081.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 = \u22c2\u2080 AB, {\n    have H\u2081: e.Free \u2286 \u22c2\u2080 AB, {\n      intros a ha t ht, \n      apply ha,\n      rcases ht with \u27e8 s, \u27e8 hs, ht\u27e9\u27e9,\n      rw ht,\n      exact expression.FreeProp.intersection (\u27e8 h\u2081.1, hs \u27e9),\n    },\n    have H\u2082: \u22c2\u2080 AB \u2286 e.Free, {\n      intros a ha t ht, \n      have H: t \u2229 B \u2208 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 \u2229 B) H),\n    },\n    exact subset_antisymm H\u2081 H\u2082,\n  },\n  rw H,\n\n  let prop : set (set string) \u2192 Prop := \u03bb A, e.FreeProp (\u22c2\u2080 A),\n  have H\u2080: prop \u2205, {\n    intros \u03c3 \u03c3' h,\n    simp at h,\n    have H: \u03c3 = \u03c3', { 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\u2080) (by {\n    intros s A hs hA hs' hAi,\n    have H: \u22c2\u2080 insert s A = \u22c2\u2080 A \u2229 s, {\n      ext,\n      split,\n      { finish, },\n      { finish, }\n    },\n    rw H,\n    rcases hs with \u27e8 t, \u27e8 ht, hs \u27e9 \u27e9,\n    exact expression.FreeProp.intersection (\u27e8 hAi, \n      (by { rw hs, exact expression.FreeProp.intersection (\u27e8h\u2081.1, ht\u27e9) }) \n    \u27e9),\n  }),\nend\n\nlemma for_all_free_expression {e: expression} {\u03c3 \u03c3': state } \n  (H: \u2200 x \u2208 e.Free, \u03c3 x = \u03c3' x) (H\u2082: \u2203 A, e.FreeProp A \u2227 A.finite): e \u03c3 = e \u03c3' :=\nbegin \n  -- if e \u03c3 \u2260 e \u03c3'\n  -- then must show \u2203 x \u2208 e.Free st \u03c3 x \u2260 \u03c3' x \n  -- ?\n\n  -- freeprop {x, y} freeprop {x, z} \u2192 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\u2082: e.FreeProp e.Free, {\n    unfold expression.Free,\n    exact expression.FreeProp.infIntersection e H\u2082, \n  },\n  \n  unfold expression.FreeProp at H\u2082,\n  specialize H\u2082 \u03c3 \u03c3',\n  simp at H\u2082,\n  exact H\u2082 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 ;; \u0393 \u22a2 (A \u22c0 B \u27f9 B) := \n  let p\u2081 : e ;; \u0393 \u22a2 (A \u22c0 B \u27f9 B \u22c0 A) := permConj\n  let p\u2082 : e ;; \u0393 \u22a2 (B \u22c0 A \u27f9 B) := weakConj\n  syllogism p\u2081 p\u2082\n\ntheorem t20 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : e ;; \u0393 \u22a2 (B \u27f9 A \u22c1 B) := \n  let p\u2081 : e ;; \u0393 \u22a2 (B \u27f9 B \u22c1 A) := weakDisj \n  let p\u2082 : e ;; \u0393 \u22a2 (B \u22c1 A \u27f9 A \u22c1 B) := permDisj \n  syllogism p\u2081 p\u2082\n\ntheorem t21 (A : Formula) (_ : WellFormed e A := by autowf) : e ;; \u0393 \u22a2 A \u27f9 A :=\n  let p\u2081 : e ;; \u0393 \u22a2 A \u27f9 A \u22c0 A := contrConj \n  let p\u2082 : e ;; \u0393 \u22a2 A \u22c0 A \u27f9 A := weakConj \n  syllogism p\u2081 p\u2082\n\ntheorem t18 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : e ;; \u0393 \u22a2 (\u223cA \u22c0 A \u27f9 B) :=\n  let p\u2081 : e ;; \u0393 \u22a2 (falsum \u27f9 B) := exFalso\n  let p\u2082 : e ;; \u0393 \u22a2 \u223c(\u223cA \u22c0 A) := importation (t21 \u223cA)\n  syllogism p\u2082 p\u2081\n\ntheorem t22 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 A \u27f9 (B \u27f9 (A \u22c0 B)) :=\n  let p\u2081 : e ;; \u0393 \u22a2 (A \u22c0 B) \u27f9 (A \u22c0 B) := t21 _\n  exportation p\u2081\n\ntheorem t23 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 A \u27f9 (B \u27f9 A) :=\n  let p\u2081 : e ;; \u0393 \u22a2 (A \u22c0 B) \u27f9 A := weakConj\n  exportation p\u2081 \n\ntheorem t24 (A : Formula) (_ : WellFormed e A := by autowf) : \n  e ;; \u0393 \u22a2 (A \u27f9 \u223c\u223cA) :=\n  let p\u2081 : e ;; \u0393 \u22a2 (A \u22c0 \u223cA \u27f9 \u223cA \u22c0 A) := permConj \n  let p\u2082 : e ;; \u0393 \u22a2 \u223c(A \u22c0 \u223cA) := syllogism p\u2081 (t18 A falsum)\n  exportation p\u2082\n\ntheorem t26a (A : Formula) (_ : WellFormed e A := by autowf) : \n  e ;; \u0393 \u22a2 \u223cA \u27f9 \u223c\u223c\u223cA :=\n  t24 \u223cA\n\ntheorem t26b (A : Formula) (_ : WellFormed e A := by autowf) : \n  e ;; \u0393 \u22a2 \u223c\u223c\u223cA \u27f9 \u223cA :=\n  let p\u2081 : e ;; \u0393 \u22a2 A \u27f9 \u223c\u223c\u223c\u223cA := syllogism (t24 _) (t24 _)\n  let p\u2082 : e ;; \u0393 \u22a2 \u223c\u223c\u223cA \u22c0 A \u27f9 falsum := syllogism (permConj) (importation p\u2081)\n  exportation p\u2082\n\ntheorem t28a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 \u223c\u223c(A \u27f9 B) \u27f9 (\u223c\u223cA \u27f9 \u223c\u223cB) :=\n  sorry\n\ntheorem t28b (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 (\u223c\u223cA \u27f9 \u223c\u223cB) \u27f9 \u223c\u223c(A \u27f9 B) :=\n  let p\u2081 : e ;; \u0393 \u22a2 (A \u27f9 B) \u27f9 \u223c\u223cA \u27f9 (A \u27f9 B) := t23 _ _\n  let p\u2082 : e ;; \u0393 \u22a2 (A \u27f9 B) \u22c0 \u223c\u223cA \u22c0 A \u27f9 \u223c\u223cB := syllogism (importation (importation p\u2081)) (t24 B)\n  let p\u2083 : e ;; \u0393 \u22a2 (A \u27f9 B) \u22c0 \u223c\u223cA \u27f9 (A \u27f9 B) \u22c0 \u223c\u223cA \u22c0 A := sorry\n  let p\u2084 : e ;; \u0393 \u22a2 (A \u27f9 B) \u22c0 \u223c\u223cA \u27f9 \u223c\u223cB := syllogism p\u2083 p\u2082\n  -- let p\u2085 (h\u2081: \u0393 \u22a2 A \u27f9 B) : \u0393 \u22a2 \u223cA \u27f9 \u223cB := sorry\n  let p\u2086 : e ;; \u0393 \u22a2 (A \u27f9 B) \u27f9 (\u223c\u223cA \u27f9 \u223c\u223cB) := exportation p\u2084\n  let p\u2087 : e ;; \u0393 \u22a2 \u223c(A \u27f9 B) \u27f9 \u223c(\u223c\u223cA \u27f9 \u223c\u223cB) := sorry\n  sorry\n\ntheorem t27a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 \u223c\u223c(A \u27f9 B) \u27f9 (A \u27f9 \u223c\u223cB) :=\n  let p\u2080 : e ;; \u0393 \u22a2 (\u223c\u223c(A \u27f9 B)) \u22c0 \u223c\u223cA \u27f9 \u223c\u223cB := importation (t28a _ _)\n  let p\u2081 : e ;; \u0393 \u22a2 \u223c\u223cA \u22c0 (\u223c\u223c(A \u27f9 B)) \u27f9 (\u223c\u223c(A \u27f9 B)) \u22c0 \u223c\u223cA := permConj\n  let p\u2082 : e ;; \u0393 \u22a2 \u223c\u223cA \u22c0 (\u223c\u223c(A \u27f9 B)) \u27f9 \u223c\u223cB := syllogism p\u2081 p\u2080\n  let p\u2083 : e ;; \u0393 \u22a2 \u223c\u223cA \u27f9 \u223c\u223c(A \u27f9 B) \u27f9 \u223c\u223cB := exportation p\u2082\n  let p\u2084 : e ;; \u0393 \u22a2 A \u27f9 \u223c\u223c(A \u27f9 B) \u27f9 \u223c\u223cB := syllogism (t24 _) p\u2083\n  exportation (syllogism (permConj) (importation p\u2084))\n\n-- theorem t27b (A B : Formula) : \u0393 \u22a2 (A \u27f9 \u223c\u223cB) \u27f9 \u223c\u223c(A \u27f9 B) :=\n--   sorry\n\ntheorem t29a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 (A \u27f9 \u223cB) \u27f9 (\u223c\u223cA \u27f9 \u223cB) :=\n  let p\u2081 : e ;; \u0393 \u22a2 (A \u27f9 \u223cB) \u27f9 (\u223c\u223cA \u27f9 \u223c\u223c\u223cB) := syllogism (t24 _) (t28a _ _)\n  let p\u2082 : e ;; \u0393 \u22a2 (\u223c\u223cA \u27f9 \u223c\u223c\u223cB) \u27f9 (\u223c\u223cA \u27f9 \u223cB) := exportation (syllogism (importation (t21 _)) (t26b _))\n  syllogism p\u2081 p\u2082\n\n-- theorem t29b (A B : Formula) : \u0393 \u22a2 (\u223c\u223cA \u27f9 \u223cB) \u27f9 (A \u27f9 \u223cB) :=\n--   sorry\n\n-- theorem t30a (A B : Formula) : \u0393 \u22a2 \u223c\u223c(A \u22c0 B) \u27f9 (\u223c\u223cA \u22c0 \u223c\u223cB) :=\n--   sorry\n\n-- theorem t30b (A B : Formula) : \u0393 \u22a2 (\u223c\u223cA \u22c0 \u223c\u223cB) \u27f9 \u223c\u223c(A \u22c0 B) :=\n--   sorry\n\n-- theorem t31 (A B : Formula) : \u0393 \u22a2 \u223c\u223c(A \u22c1 B) \u27f9 \u223c\u223cA \u27f9 \u223c\u223cB :=\n--   sorry\n\n-- theorem t32a (A B : Formula) : \u0393 \u22a2 \u223c\u223c(A \u22c1 B) \u27f9 \u223c\u223c(\u223cA \u22c0 \u223cB) :=\n--   sorry\n\ntheorem t32b (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 \u223c(\u223cA \u22c0 \u223cB) \u27f9 \u223c\u223c(A \u22c1 B) :=\n  sorry\n\ntheorem t25 (A : Formula) (_ : WellFormed e A := by autowf) : \n  e ;; \u0393 \u22a2 \u223c\u223c(A \u22c1 \u223cA) := \n  let p\u2081 : e ;; \u0393 \u22a2 \u223c(\u223cA \u22c0 \u223c\u223cA) := syllogism (permConj) (t18 _ _)\n  mpon p\u2081 (t32b _ _)\n\ntheorem t33a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 \u223c(A \u22c0 B) \u27f9 A \u27f9 \u223cB :=\n  let p\u2081 : e ;; \u0393 \u22a2 \u223c(A \u22c0 B) \u22c0 (A \u22c0 B) \u27f9 falsum := t18 _ _\n  let p\u2082 : e ;; \u0393 \u22a2 (B \u27f9 \u223c\u223c(A \u22c0 B)) \u27f9 \u223c(A \u22c0 B) \u27f9 \u223cB := sorry\n  sorry\n\ntheorem t33b (A B : Formula) : e ;; \u0393 \u22a2 (A \u27f9 \u223cB) \u27f9 \u223c(A \u22c0 B) :=\n  sorry\n\ntheorem t35 (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) :\n  e ;; \u0393 \u22a2 A \u22c1 B \u27f9 \u223cA \u27f9 B :=\n  let p\u2081 : e ;; \u0393 \u22a2 \u223cA \u22c0 A \u27f9 B := t18 _ _\n  let p\u2082 : e ;; \u0393 \u22a2 A \u27f9 \u223cA \u27f9 B := exportation (syllogism (permConj) p\u2081)\n  let p\u2083 : e ;; \u0393 \u22a2 B \u27f9 \u223cA \u27f9 B := t23 _ _\n  r49 p\u2082 p\u2083\n\ntheorem t40a (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 \u223c(A \u22c1 B) \u27f9 (\u223cA \u22c0 \u223cB) :=\n  let p\u2083 : e ;; \u0393 \u22a2 A \u27f9 \u223c\u223c (A \u22c1 B) := syllogism (weakDisj) (t24 (A \u22c1 B))\n  let p\u2084 : e ;; \u0393 \u22a2 \u223c(A \u22c1 B) \u22c0 A \u27f9 falsum := syllogism (permConj) (importation p\u2083)\n  let p\u2081 : e ;; \u0393 \u22a2 \u223c(A \u22c1 B) \u27f9 \u223cA := exportation p\u2084\n  let p\u2085 : e ;; \u0393 \u22a2 B \u27f9 \u223c\u223c (A \u22c1 B) := syllogism (t20 A B) (t24 (A \u22c1 B))\n  let p\u2086 : e ;; \u0393 \u22a2 \u223c(A \u22c1 B) \u22c0 B \u27f9 falsum := syllogism (permConj) (importation p\u2085)\n  let p\u2082 : e ;; \u0393 \u22a2 \u223c(A \u22c1 B) \u27f9 \u223cB := exportation p\u2086\n  r45 p\u2081 p\u2082\n\ntheorem t40b (A B : Formula) (_ : WellFormed e A := by autowf) (_ : WellFormed e B := by autowf) : \n  e ;; \u0393 \u22a2 (\u223cA \u22c0 \u223cB) \u27f9 \u223c(A \u22c1 B) :=\n  let p\u2081 : e ;; \u0393 \u22a2 A \u27f9 \u223cA \u27f9 \u223c\u223cB := exportation (syllogism (permConj) (t18 _ _))\n  let p\u2082 : e ;; \u0393 \u22a2 B \u27f9 \u223cA \u27f9 \u223c\u223cB := exportation (syllogism (permConj) (importation (r44 (t24 _))))\n  let p\u2083 : e ;; \u0393 \u22a2 A \u22c1 B \u27f9 \u223cA \u27f9 \u223c\u223cB := r49 p\u2081 p\u2082\n  let p\u2084 : e ;; \u0393 \u22a2 (\u223cA \u27f9 \u223c\u223cB) \u27f9 \u223c(\u223cA \u22c0 \u223cB) := t33b _ _\n  let p\u2085 : e ;; \u0393 \u22a2 A \u22c1 B \u27f9 \u223c(\u223cA \u22c0 \u223cB) := syllogism p\u2083 p\u2084\n  exportation (syllogism (permConj) (importation p\u2085))", "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\u27e8\u03bb J \ud835\udca5, by { resetI, apply_instance }\u27e9\n\ninstance has_fintype_products [has_finite_products C] (\u03b9 : Type w) [fintype \u03b9] :\n  has_limits_of_shape (discrete \u03b9) C :=\nhas_limits_of_shape_of_equivalence\n  (discrete.equivalence\n    ((show ulift.{0} (fin (fintype.card \u03b9)) \u2243 fin (fintype.card \u03b9), by tidy).trans\n      (fintype.equiv_fin \u03b9).symm))\n\n/-- We can now write this for powers. -/\nnoncomputable example [has_finite_products C] (X : C) : C := \u220f (\u03bb (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\u27e8\u03bb J _, has_limits_of_shape_of_equivalence (discrete.equivalence (equiv.ulift.{w}))\u27e9\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\u27e8\u03bb J \ud835\udca5, by { resetI, apply_instance }\u27e9\n\ninstance has_fintype_coproducts [has_finite_coproducts C] (\u03b9 : Type w) [fintype \u03b9] :\n  has_colimits_of_shape (discrete \u03b9) C :=\nhas_colimits_of_shape_of_equivalence\n  (discrete.equivalence\n    ((show ulift.{0} (fin (fintype.card \u03b9)) \u2243 fin (fintype.card \u03b9), by tidy).trans\n      (fintype.equiv_fin \u03b9).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\u27e8\u03bb J _, has_colimits_of_shape_of_equivalence (discrete.equivalence (equiv.ulift.{w}))\u27e9\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 \u2192 Q)\n(i : Q \u2192 R)\n(j : Q \u2192 T)\n(k : S \u2192 T)\n(l : T \u2192 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 {\u03b1 \u03b2 : Type*} [decidable_eq \u03b2]\n\nlemma image_subtype_ne_univ_eq_image_erase [fintype \u03b1] (k : \u03b2) (b : \u03b1 \u2192 \u03b2) :\n  image (\u03bb i : {a // b a \u2260 k}, b \u2191i) 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 \u27e8a, _, ha\u27e9,\n    subst ha,\n    exact \u27e8\u27e8a, ne_of_mem_erase hi\u27e9, mem_univ _, rfl\u27e9 }\nend\n\nlemma image_subtype_univ_ssubset_image_univ [fintype \u03b1] (k : \u03b2) (b : \u03b1 \u2192 \u03b2)\n  (hk : k \u2208 image b univ) (p : \u03b2 \u2192 Prop) [decidable_pred p] (hp : \u00ac p k) :\n  image (\u03bb i : {a // p (b a)}, b \u2191i) univ \u2282 image b univ :=\nbegin\n  split,\n  { intros x hx,\n    rcases mem_image.1 hx with \u27e8y, _, hy\u27e9,\n    exact hy \u25b8 mem_image_of_mem b (mem_univ y) },\n  { intros h,\n    rw mem_image at hk,\n    rcases hk with \u27e8k', _, hk'\u27e9, subst hk',\n    have := h (mem_image_of_mem b (mem_univ k')),\n    rw mem_image at this,\n    rcases this with \u27e8j, hj, hj'\u27e9,\n    exact hp (hj' \u25b8 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": "import algebra.module.basic\nimport algebra.module.linear_map\nimport linear_algebra.basic\nimport linear_algebra.prod\nimport linear_algebra.projection\nimport order.bounded_lattice\n\ntheorem cpge_reduction_1 (R : Type*) (M : Type*) \n[semiring R] [add_comm_monoid M] [module R M] (u : linear_map R M M) (E : submodule R M) :  \nu '' u.ker = u.ker \u2227 (u '' E) = E := 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/reduction/cpge_reduction_001.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8962513675912912, "lm_q2_score": 0.5467381519846138, "lm_q1q2_score": 0.4900148164305454}}
{"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 \u03b9 I M s` is a collection of\n`smooth_bump_function`s `f i` indexed by `i : \u03b9` 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 \u2208 s`, there exists `i : \u03b9` such that `f i =\u1da0[\ud835\udcdd x] 1`.\nIn the same settings, a `smooth_partition_of_unity \u03b9 I M s` is a collection of smooth nonnegative\nfunctions `f i : C^\u221e\u27eeI, M; \ud835\udcd8(\u211d), \u211d\u27ef`, `i : \u03b9`, such that\n\n* the family of sets `support (f i)` is locally finite;\n* for each `x \u2208 s`, the sum `\u2211\u1da0 i, f i x` equals one;\n* for each `x`, the sum `\u2211\u1da0 i, f i x` is less than or equal to one.\n\nWe say that `f : smooth_bump_covering \u03b9 I M s` is *subordinate* to a map `U : M \u2192 set M` if for each\nindex `i`, we have `closure (support (f i)) \u2286 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 `\u03c3`-compact Hausdorff topology,\nfor any `U : M \u2192 set M` such that `\u2200 x \u2208 s, U x \u2208 \ud835\udcdd x` there exists a `smooth_bump_covering \u03b9 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\u03b9 uE uH uM\n\nopen function filter finite_dimensional set\nopen_locale topological_space manifold classical filter big_operators\n\nnoncomputable theory\n\nvariables {\u03b9 : Type u\u03b9}\n{E : Type uE} [normed_group E] [normed_space \u211d E] [finite_dimensional \u211d E]\n{H : Type uH} [topological_space H] (I : model_with_corners \u211d 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 \u03b9 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\u2208 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 `\u03c3`-compact Hausdorff topology, for\nany `U : M \u2192 set M` such that `\u2200 x \u2208 s, U x \u2208 \ud835\udcdd x` there exists a `smooth_bump_covering \u03b9 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 `\u211d^n` for large enough `n`.  -/\n\nvariables (\u03b9 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 \u2208 s` for all `i`;\n* the family `\u03bb i, support (f i)` is locally finite;\n* for each point `x \u2208 s` there exists `i` such that `f i =\u1da0[\ud835\udcdd 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 \u2192 set M`, `\u2200 x, U x \u2208 \ud835\udcdd 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 : \u03b9 \u2192 M)\n(to_fun : \u03a0 i, smooth_bump_function I (c i))\n(c_mem' : \u2200 i, c i \u2208 s)\n(locally_finite' : locally_finite (\u03bb i, support (to_fun i)))\n(eventually_eq_one' : \u2200 x \u2208 s, \u2203 i, to_fun i =\u1da0[\ud835\udcdd 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 `\u03bb i, support (f i)` is locally finite;\n* for all `x \u2208 s` the sum `\u2211\u1da0 i, f i x` equals one;\n* for all `x`, the sum `\u2211\u1da0 i, f i x` is less than or equal to one. -/\nstructure smooth_partition_of_unity (s : set M := univ) :=\n(to_fun : \u03b9 \u2192 C^\u221e\u27eeI, M; \ud835\udcd8(\u211d), \u211d\u27ef)\n(locally_finite' : locally_finite (\u03bb i, support (to_fun i)))\n(nonneg' : \u2200 i x, 0 \u2264 to_fun i x)\n(sum_eq_one' : \u2200 x \u2208 s, \u2211\u1da0 i, to_fun i x = 1)\n(sum_le_one' : \u2200 x, \u2211\u1da0 i, to_fun i x \u2264 1)\n\nvariables {\u03b9 I M}\n\nnamespace smooth_partition_of_unity\n\nvariables {s : set M} (f : smooth_partition_of_unity \u03b9 I M s)\n\ninstance {s : set M} : has_coe_to_fun (smooth_partition_of_unity \u03b9 I M s)\n  (\u03bb _, \u03b9 \u2192 C^\u221e\u27eeI, M; \ud835\udcd8(\u211d), \u211d\u27ef) :=\n\u27e8smooth_partition_of_unity.to_fun\u27e9\n\nprotected lemma locally_finite : locally_finite (\u03bb i, support (f i)) :=\nf.locally_finite'\n\nlemma nonneg (i : \u03b9) (x : M) : 0 \u2264 f i x := f.nonneg' i x\n\nlemma sum_eq_one {x} (hx : x \u2208 s) : \u2211\u1da0 i, f i x = 1 := f.sum_eq_one' x hx\n\nlemma sum_le_one (x : M) : \u2211\u1da0 i, f i x \u2264 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 \u03b9 M s :=\n{ to_fun := \u03bb i, f i, .. f }\n\nlemma smooth_sum : smooth I \ud835\udcd8(\u211d) (\u03bb x, \u2211\u1da0 i, f i x) :=\nsmooth_finsum (\u03bb i, (f i).smooth) f.locally_finite\n\nlemma le_one (i : \u03b9) (x : M) : f i x \u2264 1 := f.to_partition_of_unity.le_one i x\n\nlemma sum_nonneg (x : M) : 0 \u2264 \u2211\u1da0 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 \u03b9 I M s) (U : \u03b9 \u2192 set M) :=\n\u2200 i, closure (support (f i)) \u2286 U i\n\n@[simp] lemma is_subordinate_to_partition_of_unity {f : smooth_partition_of_unity \u03b9 I M s}\n  {U : \u03b9 \u2192 set M} :\n  f.to_partition_of_unity.is_subordinate U \u2194 f.is_subordinate U :=\niff.rfl\n\nalias is_subordinate_to_partition_of_unity \u2194\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 \u211d E] and [smooth_manifold_with_corners I M]\nlemma smooth_to_partition_of_unity {E : Type uE} [normed_group E] [normed_space \u211d E]\n  {H : Type uH} [topological_space H] {I : model_with_corners \u211d E H}\n  {M : Type uM} [topological_space M] [charted_space H M] {s : set M}\n  (f : bump_covering \u03b9 M s) (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (f i)) (i : \u03b9) :\n  smooth I \ud835\udcd8(\u211d) (f.to_partition_of_unity i) :=\n(hf i).mul $ smooth_finprod_cond (\u03bb 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 \u03b9 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 \u03b9 M s) (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (f i)) :\n  smooth_partition_of_unity \u03b9 I M s :=\n{ to_fun := \u03bb i, \u27e8f.to_partition_of_unity i, f.smooth_to_partition_of_unity hf i\u27e9,\n  .. f.to_partition_of_unity }\n\n@[simp] lemma to_smooth_partition_of_unity_to_partition_of_unity (f : bump_covering \u03b9 M s)\n  (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (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 \u03b9 M s)\n  (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (f i)) (i : \u03b9) :\n  \u21d1(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 \u03b9 M s}\n  {U : \u03b9 \u2192 set M} (h : f.is_subordinate U) (hf : \u2200 i, smooth I \ud835\udcd8(\u211d) (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 \u2192 set M} (fs : smooth_bump_covering \u03b9 I M s) {I}\n\ninstance : has_coe_to_fun (smooth_bump_covering \u03b9 I M s)\n  (\u03bb x, \u03a0 (i : \u03b9), smooth_bump_function I (x.c i)) :=\n\u27e8to_fun\u27e9\n\n@[simp] lemma coe_mk (c : \u03b9 \u2192 M) (to_fun : \u03a0 i, smooth_bump_function I (c i))\n  (h\u2081 h\u2082 h\u2083) : \u21d1(mk c to_fun h\u2081 h\u2082 h\u2083 : smooth_bump_covering \u03b9 I M s) = to_fun :=\nrfl\n\n/--\nWe say that `f : smooth_bump_covering \u03b9 I M s` is *subordinate* to a map `U : M \u2192 set M` if for each\nindex `i`, we have `closure (support (f i)) \u2286 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 \u03b9 I M s) (U : M \u2192 set M) :=\n\u2200 i, closure (support $ f i) \u2286 U (f.c i)\n\nlemma is_subordinate.support_subset {fs : smooth_bump_covering \u03b9 I M s} {U : M \u2192 set M}\n  (h : fs.is_subordinate U) (i : \u03b9) :\n  support (fs i) \u2286 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 `\u03c3`-compact topological space. Let `s` be a closed set\nin `M` and `U : M \u2192 set M` be a collection of sets such that `U x \u2208 \ud835\udcdd x` for every `x \u2208 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 : \u2200 x \u2208 s, U x \u2208 \ud835\udcdd x) :\n  \u2203 (\u03b9 : Type uM) (f : smooth_bump_covering \u03b9 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 := \u03bb 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 \u27e8\u03b9, c, f, hf, hsub', hfin\u27e9, 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 (\u03bb i, (f i).open_support)\n    (\u03bb x hx, hfin.point_finite x) hsub' with \u27e8V, hsV, hVc, hVf\u27e9,\n  choose r hrR hr using \u03bb i, (f i).exists_r_pos_lt_subset_ball (hVc i) (hVf i),\n  refine \u27e8\u03b9, \u27e8c, \u03bb i, (f i).update_r (r i) (hrR i), hcs, _, \u03bb x hx, _\u27e9, \u03bb i, _\u27e9,\n  { simpa only [smooth_bump_function.support_update_r] },\n  { refine (mem_Union.1 $ hsV hx).imp (\u03bb 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 (\u03bb i, support (fs i)) := fs.locally_finite'\n\nprotected lemma point_finite (x : M) : {i | fs i x \u2260 0}.finite :=\nfs.locally_finite.point_finite x\n\nlemma mem_chart_at_source_of_eq_one {i : \u03b9} {x : M} (h : fs i x = 1) :\n  x \u2208 (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 : \u03b9} {x : M} (h : fs i x = 1) :\n  x \u2208 (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 =\u1da0[\ud835\udcdd x] 1`. -/\ndef ind (x : M) (hx : x \u2208 s) : \u03b9 := (fs.eventually_eq_one' x hx).some\n\nlemma eventually_eq_one (x : M) (hx : x \u2208 s) : fs (fs.ind x hx) =\u1da0[\ud835\udcdd x] 1 :=\n(fs.eventually_eq_one' x hx).some_spec\n\nlemma apply_ind (x : M) (hx : x \u2208 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 \u2208 s) : x \u2208 support (fs $ fs.ind x hx) :=\nby simp [fs.apply_ind x hx]\n\nlemma mem_chart_at_ind_source (x : M) (hx : x \u2208 s) :\n  x \u2208 (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 \u2208 s) :\n  x \u2208 (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 \u03b9 :=\nfs.locally_finite.fintype_of_compact $ \u03bb 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 \u03b9 M s` with smooth functions `f i` is a `smooth_bump_covering`. -/\ndef to_bump_covering : bump_covering \u03b9 M s :=\n{ to_fun := \u03bb i, \u27e8fs i, (fs i).continuous\u27e9,\n  locally_finite' := fs.locally_finite,\n  nonneg' := \u03bb i x, (fs i).nonneg,\n  le_one' := \u03bb 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 \u03b9 I M s} {U : M \u2192 set M} :\n  f.to_bump_covering.is_subordinate (\u03bb i, U (f.c i)) \u2194 f.is_subordinate U :=\niff.rfl\n\nalias is_subordinate_to_bump_covering \u2194\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 \u03b9 I M s :=\nfs.to_bump_covering.to_smooth_partition_of_unity (\u03bb i, (fs i).smooth)\n\nlemma to_smooth_partition_of_unity_apply (i : \u03b9) (x : M) :\n  fs.to_smooth_partition_of_unity i x = fs i x * \u220f\u1da0 j (hj : well_ordering_rel j i), (1 - fs j x) :=\nrfl\n\nlemma to_smooth_partition_of_unity_eq_mul_prod (i : \u03b9) (x : M) (t : finset \u03b9)\n  (ht : \u2200 j, well_ordering_rel j i \u2192 fs j x \u2260 0 \u2192 j \u2208 t) :\n  fs.to_smooth_partition_of_unity i x =\n    fs i x * \u220f j in t.filter (\u03bb 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 : \u03b9) (x : M) :\n  \u2203 t : finset \u03b9, fs.to_smooth_partition_of_unity i =\u1da0[\ud835\udcdd x]\n    fs i * \u220f j in t.filter (\u03bb 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 : \u03b9} {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 : \u03b9) :\n  support (fs.to_smooth_partition_of_unity i) \u2286 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 \u03b9 I M s} {U : M \u2192 set M}\n  (h : f.is_subordinate U) :\n  f.to_smooth_partition_of_unity.is_subordinate (\u03bb 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  \u2211\u1da0 i, fs.to_smooth_partition_of_unity i x = 1 - \u220f\u1da0 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 \u03c3-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  \u2203 f : C^\u221e\u27eeI, M; \ud835\udcd8(\u211d), \u211d\u27ef, eq_on f 0 s \u2227 eq_on f 1 t \u2227 \u2200 x, f x \u2208 Icc (0 : \u211d) 1 :=\nbegin\n  have : \u2200 x \u2208 t, s\u1d9c \u2208 \ud835\udcdd x, from \u03bb 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 \u27e8\u03b9, f, hf\u27e9,\n  set g := f.to_smooth_partition_of_unity,\n  refine \u27e8\u27e8_, g.smooth_sum\u27e9, \u03bb x hx, _, \u03bb x, g.sum_eq_one, \u03bb x, \u27e8g.sum_nonneg x, g.sum_le_one x\u27e9\u27e9,\n  suffices : \u2200 i, g i x = 0,\n    by simp only [this, times_cont_mdiff_map.coe_fn_mk, finsum_zero, pi.zero_apply],\n  refine \u03bb 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 : \u03b9) (s : set M) : smooth_partition_of_unity \u03b9 I M s :=\n(bump_covering.single i s).to_smooth_partition_of_unity $ \u03bb 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 \u03b9] (s : set M) : inhabited (smooth_partition_of_unity \u03b9 I M s) :=\n\u27e8single (default \u03b9) s\u27e9\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 \u03b9 X s` that is subordinate to `U`. -/\nlemma exists_is_subordinate {s : set M} (hs : is_closed s) (U : \u03b9 \u2192 set M) (ho : \u2200 i, is_open (U i))\n  (hU : s \u2286 \u22c3 i, U i) :\n  \u2203 f : smooth_partition_of_unity \u03b9 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 \ud835\udcd8(\u211d)) _ hs U ho hU\n    with \u27e8f, hf, hfU\u27e9,\n  { exact \u27e8f.to_smooth_partition_of_unity hf, hfU.to_smooth_partition_of_unity hf\u27e9 },\n  { intros s t hs ht hd,\n    rcases exists_smooth_zero_one_of_closed I hs ht hd with \u27e8f, hf\u27e9,\n    exact \u27e8f, f.smooth, hf\u27e9 }\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": "import Mt.Utils.Nat\n\nnamespace Mt\n\n/-- Class to represent 'reservations'\n\n  Reservations are the main method for reasoning about inter-thread behaviour.\n  \n  Basic idea: Only threads with a certain reservation are allowed to do certain\n  things. In many cases, some operation cannot be done atomically. Instead,\n  a thread needs to do several steps. Using reservations, the thread can keep\n  track about how many of those steps it has already accomplished. Other\n  threads have no way to manipulate each other's reservation, only their own.\n\n  For reasoning, the reservations of all threads have to be taken into account.\n  However, we want:\n  * The order of the other threads should not matter\n  * It should not matter if there are 10 other threads, or only one which\n    achieved those reservations\n  \n  As a consequence, we require an addition operator for reservations. Invariants\n  used for reasoning may use both the shared state and the sum of all\n  reservations, but not individual reservations. Each thread has to guarantee the\n  invariant, but it only knows about its own reservation, i.e. it has a lower\n  bound on the reservation, but nothing more. Therefore, it's actions are limited\n  by the reservation it has already achieved on its own.\n\n  ### Example:\n  * There is one shared `Nat` variable `x`\n  * Each thread performs the following three steps:\n    - generate a random variable `n : Nat`\n    - increase `x` by `n + 1` atomically\n    - decrease `x` by `n` atomically\n  * We want to reason that - in the end - `x` is never zero.\n\n    Solution: We introduce a `reservation : Nat` reservation which keeps track of how much\n    we have increased `x`. Therefore, the have the invariant \u2211reservation = x.\n    Now, we can easily reason about the thread:\n  * Step 1: Generating the random number has no effect on the shared variable\n  * Step 2: We increase `x` by `n + 1` and assign `reservation :=n + 1`. Since the\n    reservations of the other threads have not changed, the invariant still holds\n  * Step 3: Since no other thread can affect our reservation, we still know that\n    `reservation = n + 1`. Because of our invariant, we also know\n    `x = \u2211reservation \u2265 reservation = n + 1`. Therefore, we can safely decrease both `x`\n    and `reservation` by `n` and we still have `x > 0`\n-/\nclass IsReservation (T : Type)\n  extends\n    Add T,\n    Lean.IsAssociative (@HAdd.hAdd T T T _),\n    Lean.IsCommutative (@HAdd.hAdd T T T _)\n  where\n    empty : T\n    empty_add : \u2200 t : T, empty + t = t\n\n/-- Specification for a multithreading system\n\n  This specification specifies the context for threads but not the\n  threads itself. Threads encode a specification in their type. Only\n  threads with the same specification can be executed in parallel\n-/\nstructure Spec where\n  State : Type\n  Reservation : Type\n  [is_reservation : IsReservation Reservation]\n  validate : Reservation -> State -> Prop\n\nend Mt\n\nnamespace Mt\ninstance : IsReservation Nat where\n  assoc     := Nat.add_assoc\n  comm      := Nat.add_comm\n  empty     := 0\n  empty_add := Nat.zero_add\n\ndef LowerBound :=Nat\n\ninstance : Add LowerBound :=\u27e8Nat.max\u27e9\n\ninstance LowerBound.instance : IsReservation LowerBound where\n  assoc :=Utils.Nat.max_assoc\n  comm :=Utils.Nat.max_comm\n  empty :=(0 : Nat)\n  empty_add :=Utils.Nat.zero_max\n\nstructure UnitReservation\n\ninstance : IsReservation UnitReservation where\n  add := \u03bb _ _ => \u27e8\u27e9\n  assoc :=by intros ; rfl\n  comm :=by intros ; rfl\n  empty :=\u27e8\u27e9\n  empty_add :=by intros ; rfl\n\ninductive Lock (T : Type) where\n| Unlocked\n| Locked : T -> Lock T\n| Invalid\n\ndef Lock.is_locked {T : Type} : Lock T -> Bool\n| Locked _ => true\n| _ => false\n\ndef Lock.is_locked_and_valid {T : Type} (valid : T -> Prop) : Lock T -> Prop\n| Locked s => valid s\n| _ => False\n\ndef Lock.is_unlocked {T : Type} : Lock T -> Bool\n| Unlocked => true\n| _ => false\n\ndef Lock.add {T : Type} : Lock T -> Lock T -> Lock T\n| Unlocked, a => a\n| a, Unlocked => a\n| _, _ => Invalid\n\ntheorem Lock.eq_of_is_unlocked {T : Type} {r : Lock T} :\n  r.is_unlocked \u2192 r = Lock.Unlocked :=by\n  cases r\n  . intros ; rfl\n  . intros ; contradiction\n  . intros ; contradiction\n\ninstance {T : Type} : Add (Lock T) :=\u27e8Lock.add\u27e9\n\ntheorem Lock.unlocked_add {T : Type} : \u2200 a : Lock T, Unlocked + a = a :=by\n  intro a ; cases a <;> rfl\n\ntheorem Lock.add_unlocked {T : Type} : \u2200 a : Lock T, a + Unlocked = a :=by\n  intro a ; cases a <;> rfl\n\ntheorem Lock.invalid_add {T : Type} : \u2200 a : Lock T, Invalid + a = Invalid :=by\n  intro a ; cases a <;> rfl\n\ntheorem Lock.add_comm {T : Type} : \u2200 a b : Lock T, a + b = b + a :=by\n  intro a b\n  cases a <;> cases b <;> rfl\n\ntheorem Lock.add_assoc {T : Type} : \u2200 a b c : Lock T,\n  a + b + c = a + (b + c) :=by\n  intro a b c\n  cases a <;> cases b <;> cases c <;> rfl\n\ninstance {T : Type} : IsReservation (Lock T) where\n  assoc :=Lock.add_assoc\n  comm :=Lock.add_comm\n  empty :=Lock.Unlocked\n  empty_add :=Lock.unlocked_add\n\nend Mt\n", "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/Reservation.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8267117940706734, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.48996446813379513}}
{"text": "import tactic.suggest\nimport analysis.special_functions.exp_log\n\nopen real\n\n/- Turn off trace messages so they don't pollute the test build: -/\nset_option trace.silence_library_search true\n\nexample {a b : \u211d} (h: a \u2264 b) : exp a \u2264 exp b := by library_search\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/library_search/exp_le_exp.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7401743735019594, "lm_q2_score": 0.6619228758499942, "lm_q1q2_score": 0.4899383499388847}}
{"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 : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R) : witt_vector p R :=\n  mk p fun (n : \u2115) => ite (n = 0) 0 (coeff x (n - 1))\n\ntheorem verschiebung_fun_coeff {p : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : \u2115) :\n    coeff (verschiebung_fun x) n = ite (n = 0) 0 (coeff x (n - 1)) :=\n  sorry\n\ntheorem verschiebung_fun_coeff_zero {p : \u2115} {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 : \u2115} {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (n : \u2115) : coeff (verschiebung_fun x) (Nat.succ n) = coeff x n :=\n  rfl\n\ntheorem ghost_component_zero_verschiebung_fun {p : \u2115} {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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)]\n    [comm_ring R] (x : witt_vector p R) (n : \u2115) :\n    coe_fn (ghost_component (n + 1)) (verschiebung_fun x) = \u2191p * 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 : \u2115) : mv_polynomial \u2115 \u2124 := 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 : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R)\n    (n : \u2115) :\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 : \u2115) :\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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] :\n    witt_vector p R \u2192+ 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 : \u2115} [hp : fact (nat.prime p)] :\n    is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => \u21d1verschiebung :=\n  verschiebung_fun_is_poly p\n\n/-- verschiebung is a natural transformation -/\n@[simp] theorem map_verschiebung {p : \u2115} {R : Type u_1} {S : Type u_2} [hp : fact (nat.prime p)]\n    [comm_ring R] [comm_ring S] (f : R \u2192+* 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 : \u2115} {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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R]\n    (x : witt_vector p R) (n : \u2115) :\n    coe_fn (ghost_component (n + 1)) (coe_fn verschiebung x) = \u2191p * coe_fn (ghost_component n) x :=\n  ghost_component_verschiebung_fun x n\n\n@[simp] theorem verschiebung_coeff_zero {p : \u2115} {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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R]\n    (x : witt_vector p R) (n : \u2115) : coeff (coe_fn verschiebung x) (n + 1) = coeff x n :=\n  rfl\n\n@[simp] theorem verschiebung_coeff_succ {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)]\n    [comm_ring R] (x : witt_vector p R) (n : \u2115) :\n    coeff (coe_fn verschiebung x) (Nat.succ n) = coeff x n :=\n  rfl\n\ntheorem aeval_verschiebung_poly {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R]\n    (x : witt_vector p R) (n : \u2115) :\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\u2081_verschiebung_poly_witt_polynomial {p : \u2115} [hp : fact (nat.prime p)] (n : \u2115) :\n    coe_fn (mv_polynomial.bind\u2081 verschiebung_poly) (witt_polynomial p \u2124 n) =\n        ite (n = 0) 0 (\u2191p * witt_polynomial p \u2124 (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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 {\u03b9 : Type*} {V : Type*} [category V] [preadditive V]\nvariable {c : complex_shape \u03b9}\n\nnamespace homological_complex\n\nvariables (X Y : homological_complex V c) [\u2200 i, has_binary_biproduct (X.X i) (Y.X i)]\nvariables {Z Z': homological_complex V c} (f\u2081 : X \u27f6 Z) (f\u2082 : Y \u27f6 Z) (g\u2081 : Z' \u27f6 X) (g\u2082 : Z' \u27f6 Y)\n\n@[simps]\ndef biprod : homological_complex V c :=\n{ X := \u03bb i, X.X i \u229e Y.X i,\n  d := \u03bb i j, biprod.desc (biprod.lift (X.d i j) 0) (biprod.lift 0 (Y.d i j)),\n  shape' := \u03bb 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 \u27f6 biprod X Y := { f := \u03bb i, biprod.inl, }\n@[simps] def inr : Y \u27f6 biprod X Y := { f := \u03bb i, biprod.inr, }\n@[simps] def fst : biprod X Y \u27f6 X := { f := \u03bb i, biprod.fst, }\n@[simps] def snd : biprod X Y \u27f6 Y := { f := \u03bb i, biprod.snd, }\n\n@[simp, reassoc] def inl_fst : (inl : X \u27f6 biprod X Y) \u226b fst = \ud835\udfd9 _ := by tidy\n@[simp, reassoc] def inl_snd : (inl : X \u27f6 biprod X Y) \u226b snd = 0   := by tidy\n@[simp, reassoc] def inr_fst : (inr : Y \u27f6 biprod X Y) \u226b fst = 0   := by tidy\n@[simp, reassoc] def inr_snd : (inr : Y \u27f6 biprod X Y) \u226b snd = \ud835\udfd9 _ := by tidy\n\n@[simps] def desc : biprod X Y \u27f6 Z := { f := \u03bb i, biprod.desc (f\u2081.f i) (f\u2082.f i), }\n@[simp, reassoc] lemma inl_desc : inl \u226b desc f\u2081 f\u2082 = f\u2081 := by tidy\n@[simp, reassoc] lemma inr_desc : inr \u226b desc f\u2081 f\u2082 = f\u2082 := by tidy\n\n@[simps] def lift : Z' \u27f6 biprod X Y := { f := \u03bb i, biprod.lift (g\u2081.f i) (g\u2082.f i), }\n@[simp, reassoc] lemma lift_fst : lift g\u2081 g\u2082 \u226b fst = g\u2081 := by tidy\n@[simp, reassoc] lemma lift_snd : lift g\u2081 g\u2082 \u226b snd = g\u2082 := by tidy\n\n@[ext]\nlemma hom_ext (f\u2081 f\u2082 : Z' \u27f6 biprod X Y) (h\u2081 : f\u2081 \u226b biprod.fst = f\u2082 \u226b biprod.fst)\n  (h\u2082 : f\u2081 \u226b biprod.snd = f\u2082 \u226b biprod.snd ) : f\u2081 = f\u2082 :=\nby { ext i, exacts [congr_hom h\u2081 i, congr_hom h\u2082 i], }\n\n@[ext]\nlemma hom_ext' (f\u2081 f\u2082 : biprod X Y \u27f6 Z) (h\u2081 : biprod.inl \u226b f\u2081= biprod.inl \u226b f\u2082)\n  (h\u2082 : biprod.inr \u226b f\u2081 = biprod.inr \u226b f\u2082) : f\u2081 = f\u2082 :=\nby { ext i, exacts [congr_hom h\u2081 i, congr_hom h\u2082 i], }\n\n@[simp, reassoc]\nlemma lift_desc : lift g\u2081 g\u2082 \u226b desc f\u2081 f\u2082 = g\u2081 \u226b f\u2081 + g\u2082 \u226b f\u2082 := by tidy\n\nlemma total : fst \u226b inl + snd \u226b inr = \ud835\udfd9 (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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {n : \u2115}\n\nnamespace roption\n\ndef compatible (o\u2081 o\u2082 : roption \u03b1) : Prop := \u2200{{x y}}, x \u2208 o\u2081 \u2192 y \u2208 o\u2082 \u2192 x = y\n\nnamespace compatible\n  variables {o\u2081 o\u2082 o\u2083 : roption \u03b1}\n  infix ` =. `:50 := roption.compatible\n  protected lemma compatible_of_eq {x y : \u03b1} (h : x = y) :\n    compatible (roption.some x) (roption.some y) :=\n  omitted\n  protected lemma symm (h : o\u2081 =. o\u2082) : o\u2082 =. o\u2081 := \u03bbx 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 (\u03b1 \u03b2 : Type*) : \u03b1 \u2192. \u03b2 := \u03bbx, roption.none\nprotected def id : \u03b1 \u2192. \u03b1 := pfun.lift id\nprotected def comp (g : \u03b2 \u2192. \u03b3) (f : \u03b1 \u2192. \u03b2) : \u03b1 \u2192. \u03b3 := \u03bbx, roption.bind (f x) g\ninfix ` \u2218. `:90 := pfun.comp\n\ndef to_subtype (p : \u03b1 \u2192 Prop) : \u03b1 \u2192. subtype p := \u03bbx, \u27e8p x, \u03bb h, \u27e8x, h\u27e9\u27e9\n\ndef compatible (f g : \u03b1 \u2192. \u03b2) : Prop := \u2200x, f x =. g x\n\nnamespace compatible\n  variables {f g h : \u03b1 \u2192. \u03b2}\n  infix ` ~. `:50 := pfun.compatible\n  protected lemma symm (h : f ~. g) : g ~. f := \u03bbx, (h x).symm\n  -- note: it is not transitive, probably good to use different notation\nend compatible\n\ndef restrict' (f : \u03b1 \u2192. \u03b2) (p : set \u03b1) : \u03b1 \u2192. \u03b2 :=\npfun.restrict f (inter_subset_right p (dom f))\n\nend pfun\n\n/- a partial equivalence -/\nopen pfun\nstructure pequiv (\u03b1 : Type*) (\u03b2 : Type*) :=\n(to_fun    : \u03b1 \u2192. \u03b2)\n(inv_fun   : \u03b2 \u2192. \u03b1)\n(dom_inv_fun : \u2200{{x}} (hx : x \u2208 dom to_fun), to_fun.fn x hx \u2208 dom inv_fun)\n(dom_to_fun : \u2200{{y}} (hy : y \u2208 dom inv_fun), inv_fun.fn y hy \u2208 dom to_fun)\n(left_inv  : inv_fun \u2218. to_fun ~. pfun.id)\n(right_inv : to_fun \u2218. inv_fun ~. pfun.id)\n\ninfixr ` \u2243. `:25 := pequiv\n\nnamespace equiv\ndef to_pequiv (e : \u03b1 \u2243 \u03b2) : \u03b1 \u2243. \u03b2 :=\n\u27e8e.to_fun, e.inv_fun, \u03bbx hx, trivial, \u03bby hy, trivial, omitted, omitted\u27e9\n\ndef rfl : \u03b1 \u2243 \u03b1 := equiv.refl \u03b1\nend equiv\n\nnamespace pequiv\n\ninstance : has_coe (\u03b1 \u2243. \u03b2) (\u03b1 \u2192. \u03b2) := \u27e8pequiv.to_fun\u27e9\nprotected def rfl : \u03b1 \u2243. \u03b1 := equiv.rfl.to_pequiv\nprotected def refl (\u03b1) : \u03b1 \u2243. \u03b1 := pequiv.rfl\nprotected def symm (e : \u03b1 \u2243. \u03b2) : \u03b2 \u2243. \u03b1 :=\n\u27e8e.inv_fun, e.to_fun, e.dom_to_fun, e.dom_inv_fun, e.right_inv, e.left_inv\u27e9\nprotected def trans (e\u2081 : \u03b1 \u2243. \u03b2) (e\u2082 : \u03b2 \u2243. \u03b3) : \u03b1 \u2243. \u03b3 :=\n\u27e8e\u2082.to_fun \u2218. e\u2081.to_fun, e\u2081.inv_fun \u2218. e\u2082.inv_fun, omitted, omitted, omitted, omitted\u27e9\n\ndef restrict' (e : \u03b1 \u2243. \u03b2) (p : set \u03b1) : \u03b1 \u2243. \u03b2 :=\n\u27e8e.to_fun.restrict' p, e.inv_fun.restrict' (e.to_fun.image p), omitted, omitted, omitted, omitted\u27e9\n\ndef subtype_pequiv (p : \u03b1 \u2192 Prop) : subtype p \u2243. \u03b1 :=\n\u27e8pfun.lift subtype.val, to_subtype p, omitted, omitted, omitted, omitted\u27e9\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 {\u03b1 : Sort _} {\u03b2 : \u03b1 \u2192 Sort _} {\u03b3 : \u03a0 a (b : \u03b2 a), Sort _} (f : \u03a0 a (b : \u03b2 a), \u03b3 a b) : \u03a0 (x : sigma \u03b2), \u03b3 x.fst x.snd :=\n  \u03bb x, f x.fst x.snd\n\n--- Dependent analogue of `uncurry`\ndefinition duncurry {\u03b1 : Sort _} {\u03b2 : \u03b1 \u2192 Sort _} {\u03b3 : \u03a0 (x : sigma \u03b2), Sort _} (f : \u03a0 (x : sigma \u03b2), \u03b3 x) : \u03a0 a (b : \u03b2 a), \u03b3 \u27e8a,b\u27e9 :=\n  \u03bb a b, f \u27e8a,b\u27e9\n\n--- Composition of retractions is again a retraction.\nlemma left_inverse_comp {\u03b1 \u03b2 \u03b3 : Sort _} {gr : \u03b3 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} {fr : \u03b2 \u2192 \u03b1} {f : \u03b1 \u2192 \u03b2} : left_inverse gr g \u2192 left_inverse fr f \u2192 left_inverse (fr\u2218 gr) (g\u2218f) :=\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 {\u03b1 \u03b2 \u03b3 : Sort _} {gr : \u03b3 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} {fr : \u03b2 \u2192 \u03b1} {f : \u03b1 \u2192 \u03b2} : right_inverse gr g \u2192 right_inverse fr f \u2192 right_inverse (fr\u2218 gr) (g\u2218f) :=\n  \u03bb hg hf, left_inverse_comp hf hg\n\n\ndefinition has_inverse {\u03b1 \u03b2 : Sort _} (f : \u03b1 \u2192 \u03b2) : Prop :=\n  \u2203 (g : \u03b2 \u2192 \u03b1), left_inverse g f \u2227 right_inverse g f\n\ntheorem has_inverse_of_twosided_invertible {\u03b1 \u03b2 : Sort _} {f : \u03b1 \u2192 \u03b2} : has_left_inverse f \u2192 has_right_inverse f \u2192 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 \u2200 a, gl (f a) = a, { exact hgl },\n    show \u2200 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 {\u03b1 \u03b2 : Sort _} {f : \u03b1 \u2192 \u03b2} : has_inverse f \u2192 function.has_left_inverse f :=\n  begin\n    intros hinv; cases hinv with g hg,\n    exact \u27e8g,hg.left\u27e9\n  end\n\nlemma has_right_inverse {\u03b1 \u03b2 : Sort _} {f : \u03b1 \u2192 \u03b2} : has_inverse f \u2192 function.has_right_inverse f :=\n  begin\n    intros hinv; cases hinv with g hg,\n    exact \u27e8g,hg.right\u27e9\n  end\n\nlemma bijective {\u03b1 \u03b2 : Sort _} {f : \u03b1 \u2192 \u03b2} : has_inverse f \u2192 bijective f\n| \u27e8g, h\u27e9 := \u27e8has_left_inverse.injective \u27e8g, h.left\u27e9, has_right_inverse.surjective \u27e8g, h.right\u27e9\u27e9\n\nend has_inverse\n\n--- Analogue of `congr` for functions with dependent domain.\ndefinition dcongr {\u03b1 : Sort _} {C : \u03b1 \u2192 Sort _} {\u03b2 : Sort _} : \u2200 {a b : \u03b1} {f : C a \u2192 \u03b2} {g : C b \u2192 \u03b2} {x : C a} {y : C b}, a = b \u2192 f == g \u2192 x == y \u2192 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 {\u03b1 : Sort _} {C : \u03b1 \u2192 Sort _} (f : \u03a0 a, C a) : \u2200 {x y : \u03b1}, x=y \u2192 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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v}\n\n/- keys -/\n\n/-- List of keys from a list of key-value pairs -/\ndef keys : list (sigma \u03b2) \u2192 list \u03b1 :=\nmap sigma.fst\n\n@[simp] theorem keys_nil : @keys \u03b1 \u03b2 [] = [] :=\nrfl\n\n@[simp] theorem keys_cons {s} {l : list (sigma \u03b2)} : (s :: l).keys = s.1 :: l.keys :=\nrfl\n\ntheorem mem_keys_of_mem {s : sigma \u03b2} {l : list (sigma \u03b2)} : s \u2208 l \u2192 s.1 \u2208 l.keys :=\nmem_map_of_mem sigma.fst\n\ntheorem exists_of_mem_keys {a} {l : list (sigma \u03b2)} (h : a \u2208 l.keys) :\n  \u2203 (b : \u03b2 a), sigma.mk a b \u2208 l :=\nlet \u27e8\u27e8a', b'\u27e9, m, e\u27e9 := exists_of_mem_map h in\neq.rec_on e (exists.intro b' m)\n\ntheorem mem_keys {a} {l : list (sigma \u03b2)} : a \u2208 l.keys \u2194 \u2203 (b : \u03b2 a), sigma.mk a b \u2208 l :=\n\u27e8exists_of_mem_keys, \u03bb \u27e8b, h\u27e9, mem_keys_of_mem h\u27e9\n\ntheorem not_mem_keys {a} {l : list (sigma \u03b2)} : a \u2209 l.keys \u2194 \u2200 b : \u03b2 a, sigma.mk a b \u2209 l :=\n(not_iff_not_of_iff mem_keys).trans not_exists\n\ntheorem not_eq_key {a} {l : list (sigma \u03b2)} : a \u2209 l.keys \u2194 \u2200 s : sigma \u03b2, s \u2208 l \u2192 a \u2260 s.1 :=\niff.intro\n  (\u03bb h\u2081 s h\u2082 e, absurd (mem_keys_of_mem h\u2082) (by rwa e at h\u2081))\n  (\u03bb f h\u2081, let \u27e8b, h\u2082\u27e9 := exists_of_mem_keys h\u2081 in f _ h\u2082 rfl)\n\n/- nodupkeys -/\n\ndef nodupkeys (l : list (sigma \u03b2)) : Prop :=\nl.keys.nodup\n\ntheorem nodupkeys_iff_pairwise {l} : nodupkeys l \u2194\n  pairwise (\u03bb s s' : sigma \u03b2, s.1 \u2260 s'.1) l := pairwise_map _\n\n@[simp] theorem nodupkeys_nil : @nodupkeys \u03b1 \u03b2 [] := pairwise.nil\n\n@[simp] theorem nodupkeys_cons {s : sigma \u03b2} {l : list (sigma \u03b2)} :\n  nodupkeys (s::l) \u2194 s.1 \u2209 l.keys \u2227 nodupkeys l :=\nby simp [keys, nodupkeys]\n\ntheorem nodupkeys.eq_of_fst_eq {l : list (sigma \u03b2)}\n  (nd : nodupkeys l) {s s' : sigma \u03b2} (h : s \u2208 l) (h' : s' \u2208 l) :\n  s.1 = s'.1 \u2192 s = s' :=\n@forall_of_forall_of_pairwise _\n  (\u03bb s s' : sigma \u03b2, s.1 = s'.1 \u2192 s = s')\n  (\u03bb s s' H h, (H h.symm).symm) _ (\u03bb x h _, rfl)\n  ((nodupkeys_iff_pairwise.1 nd).imp (\u03bb s s' h h', (h h').elim)) _ h _ h'\n\ntheorem nodupkeys.eq_of_mk_mem {a : \u03b1} {b b' : \u03b2 a} {l : list (sigma \u03b2)}\n  (nd : nodupkeys l) (h : sigma.mk a b \u2208 l) (h' : sigma.mk a b' \u2208 l) : b = b' :=\nby cases nd.eq_of_fst_eq h h' rfl; refl\n\ntheorem nodupkeys_singleton (s : sigma \u03b2) : nodupkeys [s] := nodup_singleton _\n\ntheorem nodupkeys_of_sublist {l\u2081 l\u2082 : list (sigma \u03b2)} (h : l\u2081 <+ l\u2082) : nodupkeys l\u2082 \u2192 nodupkeys l\u2081 :=\nnodup_of_sublist (map_sublist_map _ h)\n\ntheorem nodup_of_nodupkeys {l : list (sigma \u03b2)} : nodupkeys l \u2192 nodup l :=\nnodup_of_nodup_map _\n\ntheorem perm_nodupkeys {l\u2081 l\u2082 : list (sigma \u03b2)} (h : l\u2081 ~ l\u2082) : nodupkeys l\u2081 \u2194 nodupkeys l\u2082 :=\nperm_nodup $ perm_map _ h\n\ntheorem nodupkeys_join {L : list (list (sigma \u03b2))} :\n  nodupkeys (join L) \u2194 (\u2200 l \u2208 L, nodupkeys l) \u2227 pairwise disjoint (L.map keys) :=\nbegin\n  rw [nodupkeys_iff_pairwise, pairwise_join, pairwise_map],\n  refine and_congr (ball_congr $ \u03bb l h, by simp [nodupkeys_iff_pairwise]) _,\n  apply iff_of_eq, congr', ext l\u2081 l\u2082,\n  simp [keys, disjoint_iff_ne]\nend\n\ntheorem nodup_enum_map_fst (l : list \u03b1) : (l.enum.map prod.fst).nodup :=\nby simp [list.nodup_range]\n\nvariables [decidable_eq \u03b1]\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 : \u03b1) : list (sigma \u03b2) \u2192 option (\u03b2 a)\n| []             := none\n| (\u27e8a', b\u27e9 :: l) := if h : a' = a then some (eq.rec_on h b) else lookup l\n\n@[simp] theorem lookup_nil (a : \u03b1) : lookup a [] = @none (\u03b2 a) := rfl\n\n@[simp] theorem lookup_cons_eq (l) (a : \u03b1) (b : \u03b2 a) : lookup a (\u27e8a, b\u27e9::l) = some b :=\ndif_pos rfl\n\n@[simp] theorem lookup_cons_ne (l) {a} :\n  \u2200 s : sigma \u03b2, a \u2260 s.1 \u2192 lookup a (s::l) = lookup a l\n| \u27e8a', b\u27e9 h := dif_neg h.symm\n\ntheorem lookup_is_some {a : \u03b1} : \u2200 {l : list (sigma \u03b2)},\n  (lookup a l).is_some \u2194 a \u2208 l.keys\n| []             := by simp\n| (\u27e8a', b\u27e9 :: 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 : \u03b1} {l : list (sigma \u03b2)} :\n  lookup a l = none \u2194 a \u2209 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 : \u03b1} {b : \u03b2 a} : \u2200 {l : list (sigma \u03b2)}, b \u2208 lookup a l \u2192 sigma.mk a b \u2208 l\n| (\u27e8a', b'\u27e9 :: 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 : \u03b2 a} {l : list (sigma \u03b2)} (nd : l.nodupkeys)\n  (h : sigma.mk a b \u2208 l) : b \u2208 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 : \u03b1) : \u2200 l : list (sigma \u03b2),\n  (lookup a l).map (sigma.mk a) = find (\u03bb s, a = s.1) l\n| [] := rfl\n| (\u27e8a', b'\u27e9 :: 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 : \u03b1} {b : \u03b2 a} {l : list (sigma \u03b2)} (nd : l.nodupkeys) :\n  b \u2208 lookup a l \u2194 sigma.mk a b \u2208 l :=\n\u27e8of_mem_lookup, mem_lookup nd\u27e9\n\ntheorem perm_lookup (a : \u03b1) {l\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd\u2081 : l\u2081.nodupkeys) (nd\u2082 : l\u2082.nodupkeys) (p : l\u2081 ~ l\u2082) : lookup a l\u2081 = lookup a l\u2082 :=\nby ext b; simp [mem_lookup_iff, nd\u2081, nd\u2082]; 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 : \u03b1) : list (sigma \u03b2) \u2192 list (\u03b2 a)\n| []             := []\n| (\u27e8a', b\u27e9 :: 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 : \u03b1) (b : \u03b2 a) :\n  lookup_all a (\u27e8a, b\u27e9::l) = b :: lookup_all a l :=\ndif_pos rfl\n\n@[simp] theorem lookup_all_cons_ne (l) {a} :\n  \u2200 s : sigma \u03b2, a \u2260 s.1 \u2192 lookup_all a (s::l) = lookup_all a l\n| \u27e8a', b\u27e9 h := dif_neg h.symm\n\ntheorem lookup_all_eq_nil {a : \u03b1} : \u2200 {l : list (sigma \u03b2)},\n  lookup_all a l = [] \u2194 \u2200 b : \u03b2 a, sigma.mk a b \u2209 l\n| []             := by simp\n| (\u27e8a', b\u27e9 :: l) := begin\n  by_cases h : a = a',\n  { subst a', simp, exact \u03bb H, H b (or.inl rfl) },\n  { simp [h, lookup_all_eq_nil] },\nend\n\ntheorem head_lookup_all (a : \u03b1) : \u2200 l : list (sigma \u03b2),\n  head' (lookup_all a l) = lookup a l\n| []             := by simp\n| (\u27e8a', b\u27e9 :: l) := by by_cases h : a = a'; [{subst h, simp}, simp *]\n\ntheorem mem_lookup_all {a : \u03b1} {b : \u03b2 a} :\n  \u2200 {l : list (sigma \u03b2)}, b \u2208 lookup_all a l \u2194 sigma.mk a b \u2208 l\n| []              := by simp\n| (\u27e8a', b'\u27e9 :: l) := by by_cases h : a = a'; [{subst h, simp *}, simp *]\n\ntheorem lookup_all_sublist (a : \u03b1) :\n  \u2200 l : list (sigma \u03b2), (lookup_all a l).map (sigma.mk a) <+ l\n| []              := by simp\n| (\u27e8a', b'\u27e9 :: 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 : \u03b1) {l : list (sigma \u03b2)} (h : l.nodupkeys) :\n  length (lookup_all a l) \u2264 1 :=\nby have := nodup_of_sublist (map_sublist_map _ $ lookup_all_sublist a l) h;\n   rw map_map at this; rwa [\u2190 nodup_repeat, \u2190 map_const _ a]\n\ntheorem lookup_all_eq_lookup (a : \u03b1) {l : list (sigma \u03b2)} (h : l.nodupkeys) :\n  lookup_all a l = (lookup a l).to_list :=\nbegin\n  rw \u2190 head_lookup_all,\n  have := lookup_all_length_le_one a h, revert this,\n  rcases lookup_all a l with _|\u27e8b, _|\u27e8c, l\u27e9\u27e9; intro; try {refl},\n  exact absurd this dec_trivial\nend\n\ntheorem lookup_all_nodup (a : \u03b1) {l : list (sigma \u03b2)} (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 : \u03b1) {l\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd\u2081 : l\u2081.nodupkeys) (nd\u2082 : l\u2082.nodupkeys) (p : l\u2081 ~ l\u2082) : lookup_all a l\u2081 = lookup_all a l\u2082 :=\nby simp [lookup_all_eq_lookup, nd\u2081, nd\u2082, perm_lookup a nd\u2081 nd\u2082 p]\n\n/- kreplace -/\n\ndef kreplace (a : \u03b1) (b : \u03b2 a) : list (sigma \u03b2) \u2192 list (sigma \u03b2) :=\nlookmap $ \u03bb s, if h : a = s.1 then some \u27e8a, b\u27e9 else none\n\ntheorem kreplace_of_forall_not (a : \u03b1) (b : \u03b2 a) {l : list (sigma \u03b2)}\n  (H : \u2200 b : \u03b2 a, sigma.mk a b \u2209 l) : kreplace a b l = l :=\nlookmap_of_forall_not _ $ begin\n  rintro \u27e8a', b'\u27e9 h, dsimp, split_ifs,\n  { subst a', exact H _ h }, {refl}\nend\n\ntheorem kreplace_self {a : \u03b1} {b : \u03b2 a} {l : list (sigma \u03b2)}\n  (nd : nodupkeys l) (h : sigma.mk a b \u2208 l) : kreplace a b l = l :=\nbegin\n  refine (lookmap_congr _).trans\n    (lookmap_id' (option.guard (\u03bb s, a = s.1)) _ _),\n  { rintro \u27e8a', b'\u27e9 h', dsimp [option.guard], split_ifs,\n    { subst a', exact \u27e8rfl, heq_of_eq $ nd.eq_of_mk_mem h h'\u27e9 },\n    { refl } },\n  { rintro \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9, dsimp [option.guard], split_ifs,\n    { subst a\u2081, rintro \u27e8\u27e9, simp }, { rintro \u27e8\u27e9 } },\nend\n\ntheorem keys_kreplace (a : \u03b1) (b : \u03b2 a) : \u2200 l : list (sigma \u03b2),\n  (kreplace a b l).keys = l.keys :=\nlookmap_map_eq _ _ $ by rintro \u27e8a\u2081, b\u2082\u27e9 \u27e8a\u2082, b\u2082\u27e9;\n  dsimp; split_ifs; simp [h] {contextual := tt}\n\ntheorem kreplace_nodupkeys (a : \u03b1) (b : \u03b2 a) {l : list (sigma \u03b2)} :\n  (kreplace a b l).nodupkeys \u2194 l.nodupkeys :=\nby simp [nodupkeys, keys_kreplace]\n\ntheorem perm_kreplace {a : \u03b1} {b : \u03b2 a} {l\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd : l\u2081.nodupkeys) : l\u2081 ~ l\u2082 \u2192\n  kreplace a b l\u2081 ~ kreplace a b l\u2082 :=\nperm_lookmap _ $ begin\n  refine (nodupkeys_iff_pairwise.1 nd).imp _,\n  intros x y h z h\u2081 w h\u2082,\n  split_ifs at h\u2081 h\u2082; cases h\u2081; cases h\u2082,\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 : \u03b1) : list (sigma \u03b2) \u2192 list (sigma \u03b2) :=\nerasep $ \u03bb s, a = s.1\n\n@[simp] theorem kerase_nil {a} : @kerase _ \u03b2 _ a [] = [] :=\nrfl\n\n@[simp] theorem kerase_cons_eq {a} {s : sigma \u03b2} {l : list (sigma \u03b2)} (h : a = s.1) :\n  kerase a (s :: l) = l :=\nby simp [kerase, h]\n\n@[simp] theorem kerase_cons_ne {a} {s : sigma \u03b2} {l : list (sigma \u03b2)} (h : a \u2260 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 \u03b2)} (h : a \u2209 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 : \u03b1) (l : list (sigma \u03b2)) : kerase a l <+ l :=\nerasep_sublist _\n\ntheorem kerase_keys_subset (a) (l : list (sigma \u03b2)) :\n  (kerase a l).keys \u2286 l.keys :=\nsubset_of_sublist (map_sublist_map _ (kerase_sublist a l))\n\ntheorem mem_keys_of_mem_keys_kerase {a\u2081 a\u2082} {l : list (sigma \u03b2)} :\n  a\u2081 \u2208 (kerase a\u2082 l).keys \u2192 a\u2081 \u2208 l.keys :=\n@kerase_keys_subset _ _ _ _ _ _\n\ntheorem exists_of_kerase {a : \u03b1} {l : list (sigma \u03b2)} (h : a \u2208 l.keys) :\n  \u2203 (b : \u03b2 a) (l\u2081 l\u2082 : list (sigma \u03b2)),\n    a \u2209 l\u2081.keys \u2227\n    l = l\u2081 ++ \u27e8a, b\u27e9 :: l\u2082 \u2227\n    kerase a l = l\u2081 ++ l\u2082 :=\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 \u27e8hd.2, [], tl, by simp, by cases hd; refl, by simp\u27e9 },\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 \u27e8b, tl\u2081, tl\u2082, h\u2081, h\u2082, h\u2083\u27e9,\n        exact \u27e8b, hd :: tl\u2081, tl\u2082, not_mem_cons_of_ne_of_not_mem e h\u2081,\n               by rw h\u2082; refl, by simp [e, h\u2083]\u27e9 } } }\nend\n\n@[simp] theorem mem_keys_kerase_of_ne {a\u2081 a\u2082} {l : list (sigma \u03b2)} (h : a\u2081 \u2260 a\u2082) :\n  a\u2081 \u2208 (kerase a\u2082 l).keys \u2194 a\u2081 \u2208 l.keys :=\niff.intro mem_keys_of_mem_keys_kerase $ \u03bb p,\n  if q : a\u2082 \u2208 l.keys then\n    match l, kerase a\u2082 l, exists_of_kerase q, p with\n    | _, _, \u27e8_, _, _, _, rfl, rfl\u27e9, p := by simpa [keys, h] using p\n    end\n  else\n    by simp [q, p]\n\ntheorem keys_kerase {a} {l : list (sigma \u03b2)} : (kerase a l).keys = l.keys.erase a :=\nby rw [keys, kerase, \u2190erasep_map sigma.fst l, erase_eq_erasep]\n\ntheorem kerase_nodupkeys (a : \u03b1) {l : list (sigma \u03b2)} : nodupkeys l \u2192 (kerase a l).nodupkeys :=\nnodupkeys_of_sublist $ kerase_sublist _ _\n\ntheorem perm_kerase {a : \u03b1} {l\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd : l\u2081.nodupkeys) : l\u2081 ~ l\u2082 \u2192 kerase a l\u2081 ~ kerase a l\u2082 :=\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 \u03b2)} (nd : l.nodupkeys) :\n  a \u2209 (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 \u03b2)} (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 \u03b2)} (h : a \u2260 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\u2081 : a = ah; by_cases h\u2082 : a' = ah,\n    { substs h\u2081 h\u2082, cases ne.irrefl h },\n    { subst h\u2081, simp [h\u2082] },\n    { subst h\u2082, simp [h] },\n    { simp [h\u2081, h\u2082, ih] }\n  }\nend\n\ntheorem kerase_append_left {a} : \u2200 {l\u2081 l\u2082 : list (sigma \u03b2)},\n  a \u2208 l\u2081.keys \u2192 kerase a (l\u2081 ++ l\u2082) = kerase a l\u2081 ++ l\u2082\n| []        _  h  := by cases h\n| (s :: l\u2081) l\u2082 h\u2081 :=\n  if h\u2082 : a = s.1 then\n    by simp [h\u2082]\n  else\n    by simp at h\u2081;\n       cases h\u2081;\n       [exact absurd h\u2081 h\u2082, simp [h\u2082, kerase_append_left h\u2081]]\n\ntheorem kerase_append_right {a} : \u2200 {l\u2081 l\u2082 : list (sigma \u03b2)},\n  a \u2209 l\u2081.keys \u2192 kerase a (l\u2081 ++ l\u2082) = l\u2081 ++ kerase a l\u2082\n| []        _  h := rfl\n| (_ :: l\u2081) l\u2082 h := by simp [not_or_distrib] at h;\n                       simp [h.1, kerase_append_right h.2]\n\ntheorem kerase_comm (a\u2081 a\u2082) (l : list (sigma \u03b2)) :\n  kerase a\u2082 (kerase a\u2081 l) = kerase a\u2081 (kerase a\u2082 l) :=\nif h : a\u2081 = a\u2082 then\n  by simp [h]\nelse if ha\u2081 : a\u2081 \u2208 l.keys then\n  if ha\u2082 : a\u2082 \u2208 l.keys then\n    match l, kerase a\u2081 l, exists_of_kerase ha\u2081, ha\u2082 with\n    | _, _, \u27e8b\u2081, l\u2081, l\u2082, a\u2081_nin_l\u2081, rfl, rfl\u27e9, a\u2082_in_l\u2081_app_l\u2082 :=\n      if h' : a\u2082 \u2208 l\u2081.keys then\n        by simp [kerase_append_left h',\n                 kerase_append_right (mt (mem_keys_kerase_of_ne h).mp a\u2081_nin_l\u2081)]\n      else\n        by simp [kerase_append_right h', kerase_append_right a\u2081_nin_l\u2081,\n                 @kerase_cons_ne _ _ _ a\u2082 \u27e8a\u2081, b\u2081\u27e9 _ (ne.symm h)]\n    end\n  else\n    by simp [ha\u2082, mt mem_keys_of_mem_keys_kerase ha\u2082]\nelse\n  by simp [ha\u2081, mt mem_keys_of_mem_keys_kerase ha\u2081]\n\n/- kinsert -/\n\n/-- Insert the pair `\u27e8a, b\u27e9` and erase the first pair with the key `a`. -/\ndef kinsert (a : \u03b1) (b : \u03b2 a) (l : list (sigma \u03b2)) : list (sigma \u03b2) :=\n\u27e8a, b\u27e9 :: kerase a l\n\n@[simp] theorem kinsert_def {a} {b : \u03b2 a} {l : list (sigma \u03b2)} :\n  kinsert a b l = \u27e8a, b\u27e9 :: kerase a l := rfl\n\n@[simp] theorem mem_keys_kinsert {a a'} {b' : \u03b2 a'} {l : list (sigma \u03b2)} :\n  a \u2208 (kinsert a' b' l).keys \u2194 a = a' \u2228 a \u2208 l.keys :=\nby by_cases h : a = a'; simp [h]\n\ntheorem kinsert_nodupkeys (a) (b : \u03b2 a) {l : list (sigma \u03b2)} (nd : l.nodupkeys) :\n  (kinsert a b l).nodupkeys :=\nnodupkeys_cons.mpr \u27e8not_mem_keys_kerase a nd, kerase_nodupkeys a nd\u27e9\n\ntheorem perm_kinsert {a} {b : \u03b2 a} {l\u2081 l\u2082 : list (sigma \u03b2)} (nd\u2081 : l\u2081.nodupkeys)\n  (p : l\u2081 ~ l\u2082) : kinsert a b l\u2081 ~ kinsert a b l\u2082 :=\nperm.skip \u27e8a, b\u27e9 $ perm_kerase nd\u2081 p\n\n@[simp] theorem lookup_kinsert {a} {b : \u03b2 a} (l : list (sigma \u03b2)) :\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' : \u03b2 a'} {l : list (sigma \u03b2)} (h : a \u2260 a') :\n  lookup a (kinsert a' b' l) = lookup a l :=\nby simp [h, lookup_cons_ne _ \u27e8a', b'\u27e9 h]\n\n/- kextract -/\n\ndef kextract (a : \u03b1) : list (sigma \u03b2) \u2192 option (\u03b2 a) \u00d7 list (sigma \u03b2)\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 : \u03b1) :\n  \u2200 l : list (sigma \u03b2), kextract a l = (lookup a l, kerase a l)\n| []     := rfl\n| (\u27e8a', b\u27e9::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\u2081 l\u2082` is the append to l\u2081 of l\u2082 after, for each key in l\u2081, the\nfirst matching pair in l\u2082 is erased. -/\ndef kunion : list (sigma \u03b2) \u2192 list (sigma \u03b2) \u2192 list (sigma \u03b2)\n| []        l\u2082 := l\u2082\n| (s :: l\u2081) l\u2082 := s :: kunion l\u2081 (kerase s.1 l\u2082)\n\n@[simp] theorem nil_kunion {l : list (sigma \u03b2)} : kunion [] l = l :=\nrfl\n\n@[simp] theorem kunion_nil : \u2200 {l : list (sigma \u03b2)}, kunion l [] = l\n| []       := rfl\n| (_ :: l) := by rw [kunion, kerase_nil, kunion_nil]\n\n@[simp] theorem kunion_cons {s} {l\u2081 l\u2082 : list (sigma \u03b2)} :\n  kunion (s :: l\u2081) l\u2082 = s :: kunion l\u2081 (kerase s.1 l\u2082) :=\nrfl\n\n@[simp] theorem mem_keys_kunion {a} {l\u2081 l\u2082 : list (sigma \u03b2)} :\n  a \u2208 (kunion l\u2081 l\u2082).keys \u2194 a \u2208 l\u2081.keys \u2228 a \u2208 l\u2082.keys :=\nbegin\n  induction l\u2081 generalizing l\u2082,\n  case list.nil { simp },\n  case list.cons : s l\u2081 ih { by_cases h : a = s.1; [simp [h], simp [h, ih]] }\nend\n\n@[simp] theorem kunion_kerase {a} : \u2200 {l\u2081 l\u2082 : list (sigma \u03b2)},\n  kunion (kerase a l\u2081) (kerase a l\u2082) = kerase a (kunion l\u2081 l\u2082)\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\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd\u2081 : l\u2081.nodupkeys) (nd\u2082 : l\u2082.nodupkeys) : (kunion l\u2081 l\u2082).nodupkeys :=\nbegin\n  induction l\u2081 generalizing l\u2082,\n  case list.nil { simp only [nil_kunion, nd\u2082] },\n  case list.cons : s l\u2081 ih {\n    simp at nd\u2081,\n    simp [not_or_distrib, nd\u2081.1, nd\u2082, ih nd\u2081.2 (kerase_nodupkeys s.1 nd\u2082)] }\nend\n\ntheorem perm_kunion_left {l\u2081 l\u2082 : list (sigma \u03b2)} (p : l\u2081 ~ l\u2082) (l) :\n  kunion l\u2081 l ~ kunion l\u2082 l :=\nbegin\n  induction p generalizing l,\n  case list.perm.nil { refl },\n  case list.perm.skip : hd tl\u2081 tl\u2082 p ih {\n    simp [ih (kerase hd.1 l), perm.skip] },\n  case list.perm.swap : s\u2081 s\u2082 l {\n    simp [kerase_comm, perm.swap] },\n  case list.perm.trans : l\u2081 l\u2082 l\u2083 p\u2081\u2082 p\u2082\u2083 ih\u2081\u2082 ih\u2082\u2083 {\n    exact perm.trans (ih\u2081\u2082 l) (ih\u2082\u2083 l) }\nend\n\ntheorem perm_kunion_right : \u2200 l {l\u2081 l\u2082 : list (sigma \u03b2)},\n  l\u2081.nodupkeys \u2192 l\u2081 ~ l\u2082 \u2192 kunion l l\u2081 ~ kunion l l\u2082\n| []       _  _  _   p := p\n| (s :: l) l\u2081 l\u2082 nd\u2081 p :=\n  by simp [perm.skip s\n    (perm_kunion_right l (kerase_nodupkeys s.1 nd\u2081) (perm_kerase nd\u2081 p))]\n\ntheorem perm_kunion {l\u2081 l\u2082 l\u2083 l\u2084 : list (sigma \u03b2)} (nd\u2083 : l\u2083.nodupkeys)\n  (p\u2081\u2082 : l\u2081 ~ l\u2082) (p\u2083\u2084 : l\u2083 ~ l\u2084) : kunion l\u2081 l\u2083 ~ kunion l\u2082 l\u2084 :=\nperm.trans (perm_kunion_left p\u2081\u2082 l\u2083) (perm_kunion_right l\u2082 nd\u2083 p\u2083\u2084)\n\n@[simp] theorem lookup_kunion_left {a} {l\u2081 l\u2082 : list (sigma \u03b2)} (h : a \u2208 l\u2081.keys) :\n  lookup a (kunion l\u2081 l\u2082) = lookup a l\u2081 :=\nbegin\n  induction l\u2081 with s _ ih generalizing l\u2082; 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\u2081 l\u2082 : list (sigma \u03b2)} (h : a \u2209 l\u2081.keys) :\n  lookup a (kunion l\u2081 l\u2082) = lookup a l\u2082 :=\nbegin\n  induction l\u2081 generalizing l\u2082,\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 : \u03b2 a} {l\u2081 l\u2082 : list (sigma \u03b2)} :\n  b \u2208 lookup a (kunion l\u2081 l\u2082) \u2194 b \u2208 lookup a l\u2081 \u2228 a \u2209 l\u2081.keys \u2227 b \u2208 lookup a l\u2082 :=\nbegin\n  induction l\u2081 generalizing l\u2082,\n  case list.nil { simp },\n  case list.cons : s _ ih {\n    cases s with a',\n    by_cases h\u2081 : a = a',\n    { subst h\u2081, simp },\n    { let h\u2082 := @ih (kerase a' l\u2082), simp [h\u2081] at h\u2082, simp [h\u2081, h\u2082] } }\nend\n\ntheorem mem_lookup_kunion_middle {a} {b : \u03b2 a} {l\u2081 l\u2082 l\u2083 : list (sigma \u03b2)}\n  (h\u2081 : b \u2208 lookup a (kunion l\u2081 l\u2083)) (h\u2082 : a \u2209 keys l\u2082) :\n  b \u2208 lookup a (kunion (kunion l\u2081 l\u2082) l\u2083) :=\nmatch mem_lookup_kunion.mp h\u2081 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 \u27e8mt mem_keys_kunion.mp (not_or_distrib.mpr \u27e8h.1, h\u2082\u27e9), h.2\u27e9\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 `\u03b1 \u2192 \u03b2` with the topologies / uniform structures of\n- uniform convergence on `\u03b1` (in the `uniform_convergence` namespace)\n- uniform convergence on a specified family `\ud835\udd16` of sets of `\u03b1`\n  (in the `uniform_convergence_on` namespace), also called `\ud835\udd16`-convergence\n\nUsual examples of the second construction include :\n- the topology of compact convergence, when `\ud835\udd16` is the set of compacts of `\u03b1`\n- the strong topology on the dual of a TVS `E`, when `\ud835\udd16` is the set of Von Neuman bounded subsets\n  of `E`\n- the weak-* topology on the dual of a TVS `E`, when `\ud835\udd16` 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 \ud835\udd16-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 `\u03b1 \u2192 \u03b2` is T2 if\n  `\u03b2` 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 `\ud835\udd16` is uniformly continuous\n* `uniform_convergence.t2_space` : the topology of `\ud835\udd16`-convergence on `\u03b1 \u2192 \u03b2` is T2 if\n  `\u03b2` is T2 and `\ud835\udd16` covers `\u03b1`\n* `uniform_convergence_on.tendsto_iff_tendsto_uniformly_on` :\n  `uniform_convergence_on.uniform_space` is indeed the uniform structure of `\ud835\udd16`-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 `\ud835\udd16`-convergence is exactly the structure of `\ud835\udd16'`-convergence,\n  where `\ud835\udd16'` is the bornology generated by `\ud835\udd16`.\n* Add a type synonym for `\u03b1 \u2192 \u03b2` 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 (\u03b1 \u03b2 : Type*) {\u03b3 \u03b9 : Type*}\nvariables {F : \u03b9 \u2192 \u03b1 \u2192 \u03b2} {f : \u03b1 \u2192 \u03b2} {s s' : set \u03b1} {x : \u03b1} {p : filter \u03b9} {g : \u03b9 \u2192 \u03b1}\n\n/-- Basis sets for the uniformity of uniform convergence -/\nprotected def gen (V : set (\u03b2 \u00d7 \u03b2)) : set ((\u03b1 \u2192 \u03b2) \u00d7 (\u03b1 \u2192 \u03b2)) :=\n  {uv : (\u03b1 \u2192 \u03b2) \u00d7 (\u03b1 \u2192 \u03b2) | \u2200 x, (uv.1 x, uv.2 x) \u2208 V}\n\nvariables [uniform_space \u03b2]\n\nprotected lemma is_basis_gen :\n  is_basis (\u03bb V : set (\u03b2 \u00d7 \u03b2), V \u2208 \ud835\udce4 \u03b2) (uniform_convergence.gen \u03b1 \u03b2) :=\n\u27e8\u27e8univ, univ_mem\u27e9, \u03bb U V hU hV, \u27e8U \u2229 V, inter_mem hU hV, \u03bb uv huv,\n  \u27e8\u03bb x, (huv x).left, \u03bb x, (huv x).right\u27e9\u27e9\u27e9\n\n/-- Filter basis for the uniformity of uniform convergence -/\nprotected def uniformity_basis : filter_basis ((\u03b1 \u2192 \u03b2) \u00d7 (\u03b1 \u2192 \u03b2)) :=\n(uniform_convergence.is_basis_gen \u03b1 \u03b2).filter_basis\n\n/-- Core of the uniform structure of uniform convergence -/\nprotected def uniform_core : uniform_space.core (\u03b1 \u2192 \u03b2) :=\nuniform_space.core.mk_of_basis (uniform_convergence.uniformity_basis \u03b1 \u03b2)\n  (\u03bb U \u27e8V, hV, hVU\u27e9 f, hVU \u25b8 \u03bb x, refl_mem_uniformity hV)\n  (\u03bb U \u27e8V, hV, hVU\u27e9, hVU \u25b8 \u27e8uniform_convergence.gen \u03b1 \u03b2 (prod.swap \u207b\u00b9' V),\n    \u27e8prod.swap \u207b\u00b9' V, tendsto_swap_uniformity hV, rfl\u27e9, \u03bb uv huv x, huv x\u27e9)\n  (\u03bb U \u27e8V, hV, hVU\u27e9, hVU \u25b8 let \u27e8W, hW, hWV\u27e9 := comp_mem_uniformity_sets hV in\n    \u27e8uniform_convergence.gen \u03b1 \u03b2 W, \u27e8W, hW, rfl\u27e9, \u03bb uv \u27e8w, huw, hwv\u27e9 x, hWV\n      \u27e8w x, by exact \u27e8huw x, hwv x\u27e9\u27e9\u27e9)\n\n/-- Uniform structure of uniform convergence -/\nprotected def uniform_space : uniform_space (\u03b1 \u2192 \u03b2) :=\nuniform_space.of_core (uniform_convergence.uniform_core \u03b1 \u03b2)\n\nprotected lemma has_basis_uniformity :\n  (@uniformity (\u03b1 \u2192 \u03b2) (uniform_convergence.uniform_space \u03b1 \u03b2)).has_basis (\u03bb V, V \u2208 \ud835\udce4 \u03b2)\n  (uniform_convergence.gen \u03b1 \u03b2) :=\n(uniform_convergence.is_basis_gen \u03b1 \u03b2).has_basis\n\n/-- Topology of uniform convergence -/\nprotected def topological_space : topological_space (\u03b1 \u2192 \u03b2) :=\n(uniform_convergence.uniform_space \u03b1 \u03b2).to_topological_space\n\nprotected lemma has_basis_nhds :\n  (@nhds (\u03b1 \u2192 \u03b2) (uniform_convergence.topological_space \u03b1 \u03b2) f).has_basis (\u03bb V, V \u2208 \ud835\udce4 \u03b2)\n  (\u03bb V, {g | (g, f) \u2208 uniform_convergence.gen \u03b1 \u03b2 V}) :=\nbegin\n  letI : uniform_space (\u03b1 \u2192 \u03b2) := uniform_convergence.uniform_space \u03b1 \u03b2,\n  exact nhds_basis_uniformity (uniform_convergence.has_basis_uniformity \u03b1 \u03b2)\nend\n\nvariables {\u03b1}\n\nlemma uniform_continuous_eval (x : \u03b1) : @uniform_continuous _ _\n  (uniform_convergence.uniform_space \u03b1 \u03b2) _ (function.eval x) :=\nbegin\n  change _ \u2264 _,\n  rw [map_le_iff_le_comap,\n      (uniform_convergence.has_basis_uniformity \u03b1 \u03b2).le_basis_iff ((\ud835\udce4 _).basis_sets.comap _)],\n  exact \u03bb U hU, \u27e8U, hU, \u03bb uv huv, huv x\u27e9\nend\n\nvariables {\u03b2}\n\nlemma t2_space [t2_space \u03b2] : @t2_space _ (uniform_convergence.topological_space \u03b1 \u03b2) :=\n{ t2 :=\n  begin\n    letI : uniform_space (\u03b1 \u2192 \u03b2) := uniform_convergence.uniform_space \u03b1 \u03b2,\n    letI : topological_space (\u03b1 \u2192 \u03b2) := uniform_convergence.topological_space \u03b1 \u03b2,\n    intros f g h,\n    obtain \u27e8x, hx\u27e9 := not_forall.mp (mt funext h),\n    exact separated_by_continuous (uniform_continuous_eval \u03b2 x).continuous hx\n  end }\n\nprotected lemma le_Pi : uniform_convergence.uniform_space \u03b1 \u03b2 \u2264 Pi.uniform_space (\u03bb _, \u03b2) :=\nbegin\n  rw [le_iff_uniform_continuous_id, uniform_continuous_pi],\n  intros x,\n  exact uniform_continuous_eval \u03b2 x\nend\n\nprotected lemma tendsto_iff_tendsto_uniformly :\n  tendsto F p (@nhds _ (uniform_convergence.topological_space \u03b1 \u03b2) f) \u2194\n  tendsto_uniformly F f p :=\nbegin\n  letI : uniform_space (\u03b1 \u2192 \u03b2) := uniform_convergence.uniform_space \u03b1 \u03b2,\n  rw [(uniform_convergence.has_basis_nhds \u03b1 \u03b2).tendsto_right_iff, tendsto_uniformly],\n  split;\n  { intros h U hU,\n    filter_upwards [h (prod.swap \u207b\u00b9' U) (tendsto_swap_uniformity hU)],\n    exact \u03bb n, id }\nend\n\nvariable {\u03b1}\n\nend uniform_convergence\n\nnamespace uniform_convergence_on\n\nvariables (\u03b1 \u03b2 : Type*) {\u03b3 \u03b9 : Type*} [uniform_space \u03b2] (\ud835\udd16 : set (set \u03b1))\nvariables {F : \u03b9 \u2192 \u03b1 \u2192 \u03b2} {f : \u03b1 \u2192 \u03b2} {s s' : set \u03b1} {x : \u03b1} {p : filter \u03b9} {g : \u03b9 \u2192 \u03b1}\n\n/-- Uniform structure of uniform convergence on the sets of `\ud835\udd16`. -/\nprotected def uniform_space : uniform_space (\u03b1 \u2192 \u03b2) :=\n\u2a05 (s : set \u03b1) (hs : s \u2208 \ud835\udd16), uniform_space.comap (\u03bb f, s.restrict f)\n  (uniform_convergence.uniform_space s \u03b2)\n\n/-- Topology of uniform convergence on the sets of `\ud835\udd16`. -/\nprotected def topological_space : topological_space (\u03b1 \u2192 \u03b2) :=\n(uniform_convergence_on.uniform_space \u03b1 \u03b2 \ud835\udd16).to_topological_space\n\nprotected lemma topological_space_eq :\n  uniform_convergence_on.topological_space \u03b1 \u03b2 \ud835\udd16 = \u2a05 (s : set \u03b1) (hs : s \u2208 \ud835\udd16),\n  topological_space.induced (\u03bb f, s.restrict f) (uniform_convergence.topological_space s \u03b2) :=\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 \u2208 \ud835\udd16) :\n  @uniform_continuous _ _ (uniform_convergence_on.uniform_space \u03b1 \u03b2 \ud835\udd16)\n  (uniform_convergence.uniform_space s \u03b2) s.restrict :=\nbegin\n  change _ \u2264 _,\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 \u03b1 \u03b2) :=\n\u03bb \ud835\udd16\u2081 \ud835\udd16\u2082 h\u2081\u2082, infi_le_infi_of_subset h\u2081\u2082\n\nvariables {\u03b1}\n\nlemma uniform_continuous_eval_of_mem {x : \u03b1} (hxs : x \u2208 s) (hs : s \u2208 \ud835\udd16) :\n  @uniform_continuous _ _ (uniform_convergence_on.uniform_space \u03b1 \u03b2 \ud835\udd16) _ (function.eval x) :=\nbegin\n  change _ \u2264 _,\n  rw [map_le_iff_le_comap, ((\ud835\udce4 _).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    \u27e8 uniform_convergence.gen s \u03b2 U,\n      (uniform_convergence.has_basis_uniformity s \u03b2).mem_of_mem hU,\n      \u03bb uv huv, huv \u27e8x, hxs\u27e9 \u27e9)\nend\n\nvariables {\u03b2}\n\nlemma t2_space_of_covering [t2_space \u03b2] (h : \u22c3\u2080 \ud835\udd16 = univ) :\n  @t2_space _ (uniform_convergence_on.topological_space \u03b1 \u03b2 \ud835\udd16) :=\n{ t2 :=\n  begin\n    letI : uniform_space (\u03b1 \u2192 \u03b2) := uniform_convergence_on.uniform_space \u03b1 \u03b2 \ud835\udd16,\n    letI : topological_space (\u03b1 \u2192 \u03b2) := uniform_convergence_on.topological_space \u03b1 \u03b2 \ud835\udd16,\n    intros f g hfg,\n    obtain \u27e8x, hx\u27e9 := not_forall.mp (mt funext hfg),\n    obtain \u27e8s, hs, hxs\u27e9 : \u2203 s \u2208 \ud835\udd16, x \u2208 s := mem_sUnion.mp (h.symm \u25b8 true.intro),\n    exact separated_by_continuous (uniform_continuous_eval_of_mem \u03b2 \ud835\udd16 hxs hs).continuous hx\n  end }\n\nprotected lemma le_Pi_of_covering (h : \u22c3\u2080 \ud835\udd16 = univ) :\n  uniform_convergence_on.uniform_space \u03b1 \u03b2 \ud835\udd16 \u2264 Pi.uniform_space (\u03bb _, \u03b2) :=\nbegin\n  rw [le_iff_uniform_continuous_id, uniform_continuous_pi],\n  intros x,\n  obtain \u27e8s, hs, hxs\u27e9 : \u2203 s \u2208 \ud835\udd16, x \u2208 s := mem_sUnion.mp (h.symm \u25b8 true.intro),\n  exact uniform_continuous_eval_of_mem \u03b2 \ud835\udd16 hxs hs\nend\n\nprotected lemma tendsto_iff_tendsto_uniformly_on :\n  tendsto F p (@nhds _ (uniform_convergence_on.topological_space \u03b1 \u03b2 \ud835\udd16) f) \u2194\n  \u2200 s \u2208 \ud835\udd16, tendsto_uniformly_on F f p s :=\nbegin\n  letI : uniform_space (\u03b1 \u2192 \u03b2) := uniform_convergence_on.uniform_space \u03b1 \u03b2 \ud835\udd16,\n  rw [uniform_convergence_on.topological_space_eq, nhds_infi, tendsto_infi],\n  refine forall_congr (\u03bb s, _),\n  rw [nhds_infi, tendsto_infi],\n  refine forall_congr (\u03bb 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 \u2192 A \u2192 Prop \n| of {n} {t1 t2 : L.gen n} {as : ftuple A n} : R t1 t2 \u2192 rel (applyt t1 as) (applyt t2 as)\n| refl (a) : rel a a\n| symm (a b) : rel a b \u2192 rel b a\n| trans (a b c) : rel a b \u2192 rel b c \u2192 rel a c\n| compat {n} {t : L n} {as bs : ftuple A n} : \n    (\u2200 i, rel (as i) (bs i)) \u2192 rel (applyo t as) (applyo t bs) \n\ndef setoid : setoid A := \u27e8rel R A, rel.refl, rel.symm, rel.trans\u27e9\nend add\n\ndef add := quotient (add.setoid R A)\n\nnamespace add\n\ninstance : has_app L (R.add A) := \n{ app := \u03bb n t, by letI := add.setoid R A; exact ftuple.quotient_lift \n    (\u03bb as, \u27e6applyo t as\u27e7) (\u03bb as bs hyp, quotient.sound (rel.compat hyp)) }\n\ndef univ : A \u2192$[L] (R.add A) := \n{ to_fn := by letI := add.setoid R A; exact \u03bb a, \u27e6a\u27e7,\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 \u27e8as,rfl\u27e9,\n    have : as.map (\u03bb a, \u27e6a\u27e7) = 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 \u2192$[L] B) : R.add A \u2192$[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 \u2190ralg_hom.applyt_map,\n      apply ualg.cond_eq, \n      assumption },\n    repeat { cc },\n    { dsimp only [] at h_ih,\n      simp_rw \u2190ralg_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 \u27e8as,rfl\u27e9,\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 \u2190ralg_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 \u2192$[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 \u2192$[L] B) (g : (R.add A) \u2192$[L] B) :\n  (univ R A).comp g = f \u2192 g = lift R f := \u03bb hyp,\nbegin\n  ext,\n  rcases quot.exists_rep x with \u27e8x,rfl\u27e9,\n  letI := add.setoid R A,\n  change g \u27e6x\u27e7 = ((univ R A).comp (lift R f)) x,\n  rw univ_comp_lift,\n  rw \u2190hyp,\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 {\u03b1 : Type*} (s : set \u03b1) (P : \u03b1 \u2192 Prop) :\n  {x \u2208 s | P x} = s \u2229 {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\u1d62 }` of `X`, if there\nexist fibred products `U\u1d62 \u00d7[Z] Y` for each `i`, then there exists a fibred product `X \u00d7[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}} (\ud835\udcb0 : OpenCover.{u} X) (f : X \u27f6 Z) (g : Y \u27f6 Z)\n\nvariable [\u2200 i, HasPullback (\ud835\udcb0.map i \u226b f) g]\n\n/-- The intersection of `U\u1d62 \u00d7[Z] Y` and `U\u2c7c \u00d7[Z] Y` is given by (U\u1d62 \u00d7[Z] Y) \u00d7[X] U\u2c7c -/\ndef v (i j : \ud835\udcb0.J) : Scheme :=\n  pullback ((pullback.fst : pullback (\ud835\udcb0.map i \u226b f) g \u27f6 _) \u226b \ud835\udcb0.map i) (\ud835\udcb0.map j)\n#align algebraic_geometry.Scheme.pullback.V AlgebraicGeometry.Scheme.Pullback.v\n\n/-- The canonical transition map `(U\u1d62 \u00d7[Z] Y) \u00d7[X] U\u2c7c \u27f6 (U\u2c7c \u00d7[Z] Y) \u00d7[X] U\u1d62` given by the fact\nthat pullbacks are associative and symmetric. -/\ndef t (i j : \ud835\udcb0.J) : v \ud835\udcb0 f g i j \u27f6 v \ud835\udcb0 f g j i :=\n  by\n  haveI : has_pullback (pullback.snd \u226b \ud835\udcb0.map i \u226b f) g :=\n    has_pullback_assoc_symm (\ud835\udcb0.map j) (\ud835\udcb0.map i) (\ud835\udcb0.map i \u226b f) g\n  haveI : has_pullback (pullback.snd \u226b \ud835\udcb0.map j \u226b f) g :=\n    has_pullback_assoc_symm (\ud835\udcb0.map i) (\ud835\udcb0.map j) (\ud835\udcb0.map j \u226b f) g\n  refine' (pullback_symmetry _ _).Hom \u226b _\n  refine' (pullback_assoc _ _ _ _).inv \u226b _\n  change pullback _ _ \u27f6 pullback _ _\n  refine' _ \u226b (pullback_symmetry _ _).Hom\n  refine' _ \u226b (pullback_assoc _ _ _ _).Hom\n  refine' pullback.map _ _ _ _ (pullback_symmetry _ _).Hom (\ud835\udfd9 _) (\ud835\udfd9 _) _ _\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 : \ud835\udcb0.J) : t \ud835\udcb0 f g i j \u226b pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t \ud835\udcb0 f g i j \u226b pullback.fst \u226b pullback.snd = pullback.fst \u226b 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 : \ud835\udcb0.J) : t \ud835\udcb0 f g i j \u226b pullback.snd = pullback.fst \u226b 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 : \ud835\udcb0.J) : t \ud835\udcb0 f g i i = \ud835\udfd9 _ :=\n  by\n  apply pullback.hom_ext <;> rw [category.id_comp]\n  apply pullback.hom_ext\n  \u00b7 rw [\u2190 cancel_mono (\ud835\udcb0.map i)]\n    simp only [pullback.condition, category.assoc, t_fst_fst]\n  \u00b7 simp only [category.assoc, t_fst_snd]\n  \u00b7 rw [\u2190 cancel_mono (\ud835\udcb0.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\u1d62 \u00d7[Z] Y) \u00d7[X] U\u2c7c \u27f6 U\u1d62 \u00d7[Z] Y`-/\nabbrev fV (i j : \ud835\udcb0.J) : v \ud835\udcb0 f g i j \u27f6 pullback (\ud835\udcb0.map i \u226b f) g :=\n  pullback.fst\n#align algebraic_geometry.Scheme.pullback.fV AlgebraicGeometry.Scheme.Pullback.fV\n\n/-- The map `((X\u1d62 \u00d7[Z] Y) \u00d7[X] X\u2c7c) \u00d7[X\u1d62 \u00d7[Z] Y] ((X\u1d62 \u00d7[Z] Y) \u00d7[X] X\u2096)` \u27f6\n  `((X\u2c7c \u00d7[Z] Y) \u00d7[X] X\u2096) \u00d7[X\u2c7c \u00d7[Z] Y] ((X\u2c7c \u00d7[Z] Y) \u00d7[X] X\u1d62)` needed for gluing   -/\ndef t' (i j k : \ud835\udcb0.J) :\n    pullback (fV \ud835\udcb0 f g i j) (fV \ud835\udcb0 f g i k) \u27f6 pullback (fV \ud835\udcb0 f g j k) (fV \ud835\udcb0 f g j i) :=\n  by\n  refine' (pullback_right_pullback_fst_iso _ _ _).Hom \u226b _\n  refine' _ \u226b (pullback_symmetry _ _).Hom\n  refine' _ \u226b (pullback_right_pullback_fst_iso _ _ _).inv\n  refine' pullback.map _ _ _ _ (t \ud835\udcb0 f g i j) (\ud835\udfd9 _) (\ud835\udfd9 _) _ _\n  \u00b7 simp only [\u2190 pullback.condition, category.comp_id, t_fst_fst_assoc]\n  \u00b7 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b pullback.fst \u226b pullback.fst \u226b pullback.fst = pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b pullback.fst \u226b pullback.fst \u226b pullback.snd =\n      pullback.fst \u226b pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b pullback.fst \u226b pullback.snd = pullback.snd \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b pullback.snd \u226b pullback.fst \u226b pullback.fst = pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b pullback.snd \u226b pullback.fst \u226b pullback.snd =\n      pullback.fst \u226b pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b pullback.snd \u226b pullback.snd = pullback.fst \u226b pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b t' \ud835\udcb0 f g j k i \u226b t' \ud835\udcb0 f g k i j \u226b pullback.fst \u226b pullback.fst \u226b pullback.fst =\n      pullback.fst \u226b pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b t' \ud835\udcb0 f g j k i \u226b t' \ud835\udcb0 f g k i j \u226b pullback.fst \u226b pullback.fst \u226b pullback.snd =\n      pullback.fst \u226b pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b t' \ud835\udcb0 f g j k i \u226b t' \ud835\udcb0 f g k i j \u226b pullback.fst \u226b pullback.snd =\n      pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b t' \ud835\udcb0 f g j k i \u226b t' \ud835\udcb0 f g k i j \u226b pullback.snd \u226b pullback.fst \u226b pullback.fst =\n      pullback.snd \u226b pullback.fst \u226b pullback.fst :=\n  by\n  rw [\u2190 cancel_mono (\ud835\udcb0.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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b t' \ud835\udcb0 f g j k i \u226b t' \ud835\udcb0 f g k i j \u226b pullback.snd \u226b pullback.fst \u226b pullback.snd =\n      pullback.snd \u226b pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    t' \ud835\udcb0 f g i j k \u226b t' \ud835\udcb0 f g j k i \u226b t' \ud835\udcb0 f g k i j \u226b pullback.snd \u226b pullback.snd =\n      pullback.snd \u226b 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 : \ud835\udcb0.J) : t' \ud835\udcb0 f g i j k \u226b t' \ud835\udcb0 f g j k i \u226b t' \ud835\udcb0 f g k i j = \ud835\udfd9 _ :=\n  by\n  apply pullback.hom_ext <;> rw [category.id_comp]\n  \u00b7 apply pullback.hom_ext\n    \u00b7 apply pullback.hom_ext\n      \u00b7 simp_rw [category.assoc]\n        exact cocycle_fst_fst_fst \ud835\udcb0 f g i j k\n      \u00b7 simp_rw [category.assoc]\n        exact cocycle_fst_fst_snd \ud835\udcb0 f g i j k\n    \u00b7 simp_rw [category.assoc]\n      exact cocycle_fst_snd \ud835\udcb0 f g i j k\n  \u00b7 apply pullback.hom_ext\n    \u00b7 apply pullback.hom_ext\n      \u00b7 simp_rw [category.assoc]\n        exact cocycle_snd_fst_fst \ud835\udcb0 f g i j k\n      \u00b7 simp_rw [category.assoc]\n        exact cocycle_snd_fst_snd \ud835\udcb0 f g i j k\n    \u00b7 simp_rw [category.assoc]\n      exact cocycle_snd_snd \ud835\udcb0 f g i j k\n#align algebraic_geometry.Scheme.pullback.cocycle AlgebraicGeometry.Scheme.Pullback.cocycle\n\n/-- Given `U\u1d62 \u00d7[Z] Y`, this is the glued fibered product `X \u00d7[Z] Y`. -/\n@[simps]\ndef gluing : Scheme.GlueData.{u} where\n  J := \ud835\udcb0.J\n  U i := pullback (\ud835\udcb0.map i \u226b f) g\n  V := fun \u27e8i, j\u27e9 => v \ud835\udcb0 f g i j\n  -- `p\u207b\u00b9(U\u1d62 \u2229 U\u2c7c)` where `p : U\u1d62 \u00d7[Z] Y \u27f6 U\u1d62 \u27f6 X`.\n  f i j := pullback.fst\n  f_id i := inferInstance\n  f_open := inferInstance\n  t i j := t \ud835\udcb0 f g i j\n  t_id i := t_id \ud835\udcb0 f g i\n  t' i j k := t' \ud835\udcb0 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 \ud835\udcb0 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 \ud835\udcb0 f g).glued \u27f6 X :=\n  by\n  fapply multicoequalizer.desc\n  exact fun i => pullback.fst \u226b \ud835\udcb0.map i\n  rintro \u27e8i, j\u27e9\n  change pullback.fst \u226b _ \u226b \ud835\udcb0.map i = (_ \u226b _) \u226b _ \u226b \ud835\udcb0.map j\n  rw [pullback.condition]\n  rw [\u2190 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 \ud835\udcb0 f g).glued \u27f6 Y :=\n  by\n  fapply multicoequalizer.desc\n  exact fun i => pullback.snd\n  rintro \u27e8i, j\u27e9\n  change pullback.fst \u226b _ = (_ \u226b _) \u226b _\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 \ud835\udcb0 f g \u226b f = p2 \ud835\udcb0 f g \u226b g :=\n  by\n  apply multicoequalizer.hom_ext\n  intro i\n  erw [multicoequalizer.\u03c0_desc_assoc, multicoequalizer.\u03c0_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 \u00d7[X] U\u1d62) \u00d7[s.X] (s.X \u00d7[X] U\u2c7c) \u27f6 (U\u1d62 \u00d7[Z] Y) \u00d7[X] U\u2c7c`\n\nThis is used in `glued_lift`. -/\ndef gluedLiftPullbackMap (i j : \ud835\udcb0.J) :\n    pullback ((\ud835\udcb0.pullbackCover s.fst).map i) ((\ud835\udcb0.pullbackCover s.fst).map j) \u27f6\n      (gluing \ud835\udcb0 f g).V \u27e8i, j\u27e9 :=\n  by\n  change pullback pullback.fst pullback.fst \u27f6 pullback _ _\n  refine' (pullback_right_pullback_fst_iso _ _ _).Hom \u226b _\n  refine' pullback.map _ _ _ _ _ (\ud835\udfd9 _) (\ud835\udfd9 _) _ _\n  \u00b7\n    exact\n      (pullback_symmetry _ _).Hom \u226b\n        pullback.map _ _ _ _ (\ud835\udfd9 _) s.snd f (category.id_comp _).symm s.condition\n  \u00b7 simpa using pullback.condition\n  \u00b7 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 : \ud835\udcb0.J) :\n    gluedLiftPullbackMap \ud835\udcb0 f g s i j \u226b pullback.fst =\n      pullback.fst \u226b\n        (pullbackSymmetry _ _).Hom \u226b\n          pullback.map _ _ _ _ (\ud835\udfd9 _) 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 : \ud835\udcb0.J) :\n    gluedLiftPullbackMap \ud835\udcb0 f g s i j \u226b pullback.snd = pullback.snd \u226b 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 \u27f6 (gluing \ud835\udcb0 f g).glued` in order to show that `(gluing \ud835\udcb0 f g).glued` is\nindeed the pullback.\n\nGiven a pullback cone `s`, we have the maps `s.fst \u207b\u00b9' U\u1d62 \u27f6 U\u1d62` and\n`s.fst \u207b\u00b9' U\u1d62 \u27f6 s.X \u27f6 Y` that we may lift to a map `s.fst \u207b\u00b9' U\u1d62 \u27f6 U\u1d62 \u00d7[Z] Y`.\n\nto glue these into a map `s.X \u27f6 U\u1d62 \u00d7[Z] Y`, we need to show that the maps agree on\n`(s.fst \u207b\u00b9' U\u1d62) \u00d7[s.X] (s.fst \u207b\u00b9' U\u2c7c) \u27f6 U\u1d62 \u00d7[Z] Y`. This is achieved by showing that both of these\nmaps factors through `glued_lift_pullback_map`.\n-/\ndef gluedLift : s.pt \u27f6 (gluing \ud835\udcb0 f g).glued :=\n  by\n  fapply (\ud835\udcb0.pullback_cover s.fst).glueMorphisms\n  \u00b7\n    exact fun i =>\n      (pullback_symmetry _ _).Hom \u226b\n        pullback.map _ _ _ _ (\ud835\udfd9 _) s.snd f (category.id_comp _).symm s.condition \u226b\n          (gluing \ud835\udcb0 f g).\u03b9 i\n  intro i j\n  rw [\u2190 glued_lift_pullback_map_fst_assoc]\n  have : _ = pullback.fst \u226b _ := (gluing \ud835\udcb0 f g).glue_condition i j\n  rw [\u2190 this, gluing_to_glue_data_t, gluing_to_glue_data_f]\n  simp_rw [\u2190 category.assoc]\n  congr 1\n  apply pullback.hom_ext <;> simp_rw [category.assoc]\n  \u00b7 rw [t_fst_fst, glued_lift_pullback_map_snd]\n    congr 1\n    rw [\u2190 iso.inv_comp_eq, pullback_symmetry_inv_comp_snd]\n    erw [pullback.lift_fst]\n    rw [category.comp_id]\n  \u00b7 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 \ud835\udcb0 f g s \u226b p1 \ud835\udcb0 f g = s.fst :=\n  by\n  rw [\u2190 cancel_epi (\ud835\udcb0.pullback_cover s.fst).fromGlued]\n  apply multicoequalizer.hom_ext\n  intro b\n  erw [multicoequalizer.\u03c0_desc_assoc, multicoequalizer.\u03c0_desc_assoc]\n  delta glued_lift\n  simp_rw [\u2190 category.assoc]\n  rw [(\ud835\udcb0.pullback_cover s.fst).\u03b9_glueMorphisms]\n  simp_rw [category.assoc]\n  erw [multicoequalizer.\u03c0_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 \ud835\udcb0 f g s \u226b p2 \ud835\udcb0 f g = s.snd :=\n  by\n  rw [\u2190 cancel_epi (\ud835\udcb0.pullback_cover s.fst).fromGlued]\n  apply multicoequalizer.hom_ext\n  intro b\n  erw [multicoequalizer.\u03c0_desc_assoc, multicoequalizer.\u03c0_desc_assoc]\n  delta glued_lift\n  simp_rw [\u2190 category.assoc]\n  rw [(\ud835\udcb0.pullback_cover s.fst).\u03b9_glueMorphisms]\n  simp_rw [category.assoc]\n  erw [multicoequalizer.\u03c0_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 \u00d7[X] U\u1d62) \u00d7[W] (U\u2c7c \u00d7[Z] Y) \u27f6 (U\u2c7c \u00d7[Z] Y) \u00d7[X] U\u1d62 = V j i` where `W` is\nthe glued fibred product.\n\nThis is used in `lift_comp_\u03b9`. -/\ndef pullbackFst\u03b9ToV (i j : \ud835\udcb0.J) :\n    pullback (pullback.fst : pullback (p1 \ud835\udcb0 f g) (\ud835\udcb0.map i) \u27f6 _) ((gluing \ud835\udcb0 f g).\u03b9 j) \u27f6\n      v \ud835\udcb0 f g j i :=\n  (pullbackSymmetry _ _ \u226a\u226b pullbackRightPullbackFstIso (p1 \ud835\udcb0 f g) (\ud835\udcb0.map i) _).Hom \u226b\n    (pullback.congrHom (Multicoequalizer.\u03c0_desc _ _ _ _ _) rfl).Hom\n#align algebraic_geometry.Scheme.pullback.pullback_fst_\u03b9_to_V AlgebraicGeometry.Scheme.Pullback.pullbackFst\u03b9ToV\n\n@[simp, reassoc.1]\ntheorem pullbackFst\u03b9ToV_fst (i j : \ud835\udcb0.J) : pullbackFst\u03b9ToV \ud835\udcb0 f g i j \u226b pullback.fst = pullback.snd :=\n  by\n  delta pullback_fst_\u03b9_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_\u03b9_to_V_fst AlgebraicGeometry.Scheme.Pullback.pullbackFst\u03b9ToV_fst\n\n@[simp, reassoc.1]\ntheorem pullbackFst\u03b9ToV_snd (i j : \ud835\udcb0.J) :\n    pullbackFst\u03b9ToV \ud835\udcb0 f g i j \u226b pullback.snd = pullback.fst \u226b pullback.snd :=\n  by\n  delta pullback_fst_\u03b9_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_\u03b9_to_V_snd AlgebraicGeometry.Scheme.Pullback.pullbackFst\u03b9ToV_snd\n\n/-- We show that the map `W \u00d7[X] U\u1d62 \u27f6 U\u1d62 \u00d7[Z] Y \u27f6 W` is the first projection, where the\nfirst map is given by the lift of `W \u00d7[X] U\u1d62 \u27f6 U\u1d62` and `W \u00d7[X] U\u1d62 \u27f6 W \u27f6 Y`.\n\nIt suffices to show that the two map agrees when restricted onto `U\u2c7c \u00d7[Z] Y`. In this case,\nboth maps factor through `V j i` via `pullback_fst_\u03b9_to_V` -/\ntheorem lift_comp_\u03b9 (i : \ud835\udcb0.J) :\n    pullback.lift pullback.snd (pullback.fst \u226b p2 \ud835\udcb0 f g)\n          (by rw [\u2190 pullback.condition_assoc, category.assoc, p_comm]) \u226b\n        (gluing \ud835\udcb0 f g).\u03b9 i =\n      (pullback.fst : pullback (p1 \ud835\udcb0 f g) (\ud835\udcb0.map i) \u27f6 _) :=\n  by\n  apply ((gluing \ud835\udcb0 f g).OpenCover.pullbackCover pullback.fst).hom_ext\n  intro j\n  dsimp only [open_cover.pullback_cover]\n  trans pullback_fst_\u03b9_to_V \ud835\udcb0 f g i j \u226b fV \ud835\udcb0 f g j i \u226b (gluing \ud835\udcb0 f g).\u03b9 _\n  \u00b7 rw [\u2190 show _ = fV \ud835\udcb0 f g j i \u226b _ from (gluing \ud835\udcb0 f g).glue_condition j i]\n    simp_rw [\u2190 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    \u00b7 rw [t_fst_fst, pullback.lift_fst, pullback_fst_\u03b9_to_V_snd]\n    \u00b7 rw [t_fst_snd, pullback.lift_snd, pullback_fst_\u03b9_to_V_fst_assoc, pullback.condition_assoc]\n      erw [multicoequalizer.\u03c0_desc]\n  \u00b7 rw [pullback.condition, \u2190 category.assoc]\n    congr 1\n    apply pullback.hom_ext\n    \u00b7 simp only [pullback_fst_\u03b9_to_V_fst]\n    \u00b7 simp only [pullback_fst_\u03b9_to_V_fst]\n#align algebraic_geometry.Scheme.pullback.lift_comp_\u03b9 AlgebraicGeometry.Scheme.Pullback.lift_comp_\u03b9\n\n/-- The canonical isomorphism between `W \u00d7[X] U\u1d62` and `U\u1d62 \u00d7[X] Y`. That is, the preimage of `U\u1d62` in\n`W` along `p1` is indeed `U\u1d62 \u00d7[X] Y`. -/\ndef pullbackP1Iso (i : \ud835\udcb0.J) : pullback (p1 \ud835\udcb0 f g) (\ud835\udcb0.map i) \u2245 pullback (\ud835\udcb0.map i \u226b f) g :=\n  by\n  fconstructor\n  exact\n    pullback.lift pullback.snd (pullback.fst \u226b p2 \ud835\udcb0 f g)\n      (by rw [\u2190 pullback.condition_assoc, category.assoc, p_comm])\n  refine' pullback.lift ((gluing \ud835\udcb0 f g).\u03b9 i) pullback.fst (by erw [multicoequalizer.\u03c0_desc])\n  \u00b7 apply pullback.hom_ext\n    \u00b7 simpa using lift_comp_\u03b9 \ud835\udcb0 f g i\n    \u00b7 simp only [category.assoc, pullback.lift_snd, pullback.lift_fst, category.id_comp]\n  \u00b7 apply pullback.hom_ext\n    \u00b7 simp only [category.assoc, pullback.lift_fst, pullback.lift_snd, category.id_comp]\n    \u00b7 simp only [category.assoc, pullback.lift_snd, pullback.lift_fst_assoc, category.id_comp]\n      erw [multicoequalizer.\u03c0_desc]\n#align algebraic_geometry.Scheme.pullback.pullback_p1_iso AlgebraicGeometry.Scheme.Pullback.pullbackP1Iso\n\n@[simp, reassoc.1]\ntheorem pullbackP1Iso_hom_fst (i : \ud835\udcb0.J) :\n    (pullbackP1Iso \ud835\udcb0 f g i).Hom \u226b 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 : \ud835\udcb0.J) :\n    (pullbackP1Iso \ud835\udcb0 f g i).Hom \u226b pullback.snd = pullback.fst \u226b p2 \ud835\udcb0 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 : \ud835\udcb0.J) :\n    (pullbackP1Iso \ud835\udcb0 f g i).inv \u226b pullback.fst = (gluing \ud835\udcb0 f g).\u03b9 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 : \ud835\udcb0.J) :\n    (pullbackP1Iso \ud835\udcb0 f g i).inv \u226b 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_\u03b9 (i : \ud835\udcb0.J) :\n    (pullbackP1Iso \ud835\udcb0 f g i).Hom \u226b (gluing \ud835\udcb0 f g).\u03b9 i = pullback.fst := by\n  rw [\u2190 pullback_p1_iso_inv_fst, iso.hom_inv_id_assoc]\n#align algebraic_geometry.Scheme.pullback.pullback_p1_iso_hom_\u03b9 AlgebraicGeometry.Scheme.Pullback.pullbackP1Iso_hom_\u03b9\n\n/-- The glued scheme (`(gluing \ud835\udcb0 f g).glued`) is indeed the pullback of `f` and `g`. -/\ndef gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm \ud835\udcb0 f g)) :=\n  by\n  apply pullback_cone.is_limit_aux'\n  intro s\n  refine' \u27e8glued_lift \ud835\udcb0 f g s, glued_lift_p1 \ud835\udcb0 f g s, glued_lift_p2 \ud835\udcb0 f g s, _\u27e9\n  intro m h\u2081 h\u2082\n  change m \u226b p1 \ud835\udcb0 f g = _ at h\u2081\n  change m \u226b p2 \ud835\udcb0 f g = _ at h\u2082\n  apply (\ud835\udcb0.pullback_cover s.fst).hom_ext\n  intro i\n  rw [open_cover.pullback_cover_map]\n  have := pullback_right_pullback_fst_iso (p1 \ud835\udcb0 f g) (\ud835\udcb0.map i) m \u226a\u226b pullback.congr_hom h\u2081 rfl\n  erw [(\ud835\udcb0.pullback_cover s.fst).\u03b9_glueMorphisms]\n  rw [\u2190\n    cancel_epi\n      (pullback_right_pullback_fst_iso (p1 \ud835\udcb0 f g) (\ud835\udcb0.map i) m \u226a\u226b pullback.congr_hom h\u2081 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 \u226b (pullback_p1_iso \ud835\udcb0 f g _).Hom \u226b (gluing \ud835\udcb0 f g).\u03b9 _\n  \u00b7 congr 1\n    rw [\u2190 pullback_p1_iso_hom_\u03b9]\n  simp_rw [\u2190 category.assoc]\n  congr 1\n  apply pullback.hom_ext\n  \u00b7\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  \u00b7 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 [\u2190 pullback.condition_assoc, h\u2082]\n#align algebraic_geometry.Scheme.pullback.glued_is_limit AlgebraicGeometry.Scheme.Pullback.gluedIsLimit\n\ntheorem hasPullback_of_cover : HasPullback f g :=\n  \u27e8\u27e8\u27e8_, gluedIsLimit \ud835\udcb0 f g\u27e9\u27e9\u27e9\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) \u27f6 spec.obj (Opposite.op C))\n    (g : spec.obj (Opposite.op B) \u27f6 spec.obj (Opposite.op C)) : HasPullback f g :=\n  by\n  rw [\u2190 Spec.image_preimage f, \u2190 Spec.image_preimage g]\n  exact\n    \u27e8\u27e8\u27e8_, is_limit_of_has_pullback_of_preserves_limit Spec (Spec.preimage f) (Spec.preimage g)\u27e9\u27e9\u27e9\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 \u27f6 spec.obj (Opposite.op C)) (g : spec.obj (Opposite.op B) \u27f6 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 \u27f6 spec.obj (Opposite.op C))\n    (g : Y \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z)\n    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i \u226b f) g :=\n  by\n  let X\u1d62 := pullback f (Z.affine_cover.map i)\n  let Y\u1d62 := pullback g (Z.affine_cover.map i)\n  let W := pullback (pullback.snd : Y\u1d62 \u27f6 _) (pullback.snd : X\u1d62 \u27f6 _)\n  have :=\n    big_square_is_pullback (pullback.fst : W \u27f6 _) (pullback.fst : Y\u1d62 \u27f6 _) (pullback.snd : X\u1d62 \u27f6 _)\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 \u226b Z.affine_cover.map i : X\u1d62 \u27f6 _) g := \u27e8\u27e8\u27e8_, this\u27e9\u27e9\u27e9\n  rw [\u2190 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z) [IsAffine X] [IsAffine Y] [IsAffine Z] :\n    IsAffine (pullback f g) :=\n  isAffineOfIso\n    (pullback.map f g (spec.map (\u0393.map f.op).op) (spec.map (\u0393.map g.op).op)\n        (\u0393Spec.adjunction.Unit.app X) (\u0393Spec.adjunction.Unit.app Y) (\u0393Spec.adjunction.Unit.app Z)\n        (\u0393Spec.adjunction.Unit.naturality f) (\u0393Spec.adjunction.Unit.naturality g) \u226b\n      (PreservesPullback.iso spec _ _).inv)\n\n/-- Given an open cover `{ X\u1d62 }` of `X`, then `X \u00d7[Z] Y` is covered by `X\u1d62 \u00d7[Z] Y`. -/\n@[simps J obj map]\ndef openCoverOfLeft (\ud835\udcb0 : OpenCover X) (f : X \u27f6 Z) (g : Y \u27f6 Z) : OpenCover (pullback f g) :=\n  by\n  fapply\n    ((gluing \ud835\udcb0 f g).OpenCover.pushforwardIso\n          (limit.iso_limit_cone \u27e8_, glued_is_limit \ud835\udcb0 f g\u27e9).inv).copy\n      \ud835\udcb0.J (fun i => pullback (\ud835\udcb0.map i \u226b f) g)\n      (fun i => pullback.map _ _ _ _ (\ud835\udcb0.map i) (\ud835\udfd9 _) (\ud835\udfd9 _) (category.comp_id _) (by simp))\n      (Equiv.refl \ud835\udcb0.J) fun _ => iso.refl _\n  rintro (i : \ud835\udcb0.J)\n  change pullback.map _ _ _ _ _ _ _ _ _ = \ud835\udfd9 _ \u226b (gluing \ud835\udcb0 f g).\u03b9 i \u226b _\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_\u03c0, pullback_cone.mk_\u03c0_app_left, category.comp_id,\n      pullback_cone.mk_\u03c0_app_right, category.assoc, pullback.lift_fst, pullback.lift_snd]\n    symm\n    exact multicoequalizer.\u03c0_desc _ _ _ _ _\n#align algebraic_geometry.Scheme.pullback.open_cover_of_left AlgebraicGeometry.Scheme.Pullback.openCoverOfLeft\n\n/-- Given an open cover `{ Y\u1d62 }` of `Y`, then `X \u00d7[Z] Y` is covered by `X \u00d7[Z] Y\u1d62`. -/\n@[simps J obj map]\ndef openCoverOfRight (\ud835\udcb0 : OpenCover Y) (f : X \u27f6 Z) (g : Y \u27f6 Z) : OpenCover (pullback f g) :=\n  by\n  fapply\n    ((open_cover_of_left \ud835\udcb0 g f).pushforwardIso (pullback_symmetry _ _).Hom).copy \ud835\udcb0.J\n      (fun i => pullback f (\ud835\udcb0.map i \u226b g))\n      (fun i => pullback.map _ _ _ _ (\ud835\udfd9 _) (\ud835\udcb0.map i) (\ud835\udfd9 _) (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\u1d62 }` of `X` and an open cover `{ Y\u2c7c }` of `Y`, then\n`X \u00d7[Z] Y` is covered by `X\u1d62 \u00d7[Z] Y\u2c7c`. -/\n@[simps J obj map]\ndef openCoverOfLeftRight (\ud835\udcb0X : X.OpenCover) (\ud835\udcb0Y : Y.OpenCover) (f : X \u27f6 Z) (g : Y \u27f6 Z) :\n    (pullback f g).OpenCover :=\n  by\n  fapply\n    ((open_cover_of_left \ud835\udcb0X f g).bind fun x => open_cover_of_right \ud835\udcb0Y (\ud835\udcb0X.map x \u226b f) g).copy\n      (\ud835\udcb0X.J \u00d7 \ud835\udcb0Y.J) (fun ij => pullback (\ud835\udcb0X.map ij.1 \u226b f) (\ud835\udcb0Y.map ij.2 \u226b g))\n      (fun ij =>\n        pullback.map _ _ _ _ (\ud835\udcb0X.map ij.1) (\ud835\udcb0Y.map ij.2) (\ud835\udfd9 _) (category.comp_id _)\n          (category.comp_id _))\n      (Equiv.sigmaEquivProd _ _).symm fun _ => iso.refl _\n  rintro \u27e8i, j\u27e9\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' (\ud835\udcb0 : OpenCover Z) (f : X \u27f6 Z) (g : Y \u27f6 Z) : OpenCover (pullback f g) :=\n  by\n  apply (open_cover_of_left (\ud835\udcb0.pullback_cover f) f g).bind\n  intro i\n  let X\u1d62 := pullback f (\ud835\udcb0.map i)\n  let Y\u1d62 := pullback g (\ud835\udcb0.map i)\n  let W := pullback (pullback.snd : Y\u1d62 \u27f6 _) (pullback.snd : X\u1d62 \u27f6 _)\n  have :=\n    big_square_is_pullback (pullback.fst : W \u27f6 _) (pullback.fst : Y\u1d62 \u27f6 _) (pullback.snd : X\u1d62 \u27f6 _)\n      (\ud835\udcb0.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 \u226b\n        (limit.iso_limit_cone \u27e8_, this\u27e9).inv \u226b pullback.map _ _ _ _ (\ud835\udfd9 _) (\ud835\udfd9 _) (\ud835\udfd9 _) _ _)\n  \u00b7 simpa only [category.comp_id, category.id_comp, \u2190 pullback.condition]\n  \u00b7 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\u1d62 }` of `Z`, then `X \u00d7[Z] Y` is covered by `X\u1d62 \u00d7[Z\u1d62] Y\u1d62`, where\n  `X\u1d62 = X \u00d7[Z] Z\u1d62` and `Y\u1d62 = Y \u00d7[Z] Z\u1d62` is the preimage of `Z\u1d62` in `X` and `Y`. -/\n@[simps J obj map]\ndef openCoverOfBase (\ud835\udcb0 : OpenCover Z) (f : X \u27f6 Z) (g : Y \u27f6 Z) : OpenCover (pullback f g) :=\n  by\n  apply\n    (open_cover_of_base' \ud835\udcb0 f g).copy \ud835\udcb0.J\n      (fun i =>\n        pullback (pullback.snd : pullback f (\ud835\udcb0.map i) \u27f6 _)\n          (pullback.snd : pullback g (\ud835\udcb0.map i) \u27f6 _))\n      (fun i =>\n        pullback.map _ _ _ _ pullback.fst pullback.fst (\ud835\udcb0.map i) pullback.condition.symm\n          pullback.condition.symm)\n      ((Equiv.prodPUnit \ud835\udcb0.J).symm.trans (Equiv.sigmaEquivProd \ud835\udcb0.J PUnit).symm) fun _ => iso.refl _\n  intro i\n  change _ = _ \u226b _ \u226b _\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_\u03c0_app_left, open_cover_of_is_iso_map, limit.iso_limit_cone_inv_\u03c0_assoc,\n      category.assoc, pullback.lift_fst_assoc, pullback_symmetry_hom_comp_snd_assoc,\n      pullback.lift_fst, limit.iso_limit_cone_inv_\u03c0, pullback_cone.mk_\u03c0_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 \u27f6 S) (g : Y \u27f6 S) (f' : X' \u27f6 S') (g' : Y' \u27f6 S')\n    (i\u2081 : X \u27f6 X') (i\u2082 : Y \u27f6 Y') (i\u2083 : S \u27f6 S') (e\u2081 : f \u226b i\u2083 = i\u2081 \u226b f') (e\u2082 : g \u226b i\u2083 = i\u2082 \u226b g')\n    [IsOpenImmersion i\u2081] [IsOpenImmersion i\u2082] [Mono i\u2083] :\n    IsOpenImmersion (pullback.map f g f' g' i\u2081 i\u2082 i\u2083 e\u2081 e\u2082) :=\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 {\u03b1 \u03b2 \u03b3 : 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 : \u03b1) (i : spec.\u03b9) (t : spec.domain i)\n  (oa oa' : oracle_comp spec \u03b1) (ob ob' : \u03b1 \u2192 oracle_comp spec \u03b2) (s : S) (s' : S') (f : \u03b1 \u2192 \u03b2)\n\nlemma simulate_eq_default_simulate [subsingleton S] :\n  simulate so oa s = default_simulate so oa := subsingleton.elim so.default_state s \u25b8 rfl\n\nlemma simulate'_eq_default_simulate' [subsingleton S] :\n  simulate' so oa s = default_simulate' so oa := subsingleton.elim so.default_state s \u25b8 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 : \u2200 i t, prod.fst '' (so i (t, so.default_state)).support = \u22a4) :\n  (simulate' so oa s).support = oa.support :=\nsupport_simulate'_eq_support so oa s (\u03bb i t s, subsingleton.elim so.default_state s \u25b8 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 \u207b\u00b9' (default_simulate' so oa).support :=\nbegin\n  rw [support_simulate', subsingleton.elim so.default_state s],\n  exact (set.ext $ \u03bb x, \u27e8\u03bb h, \u27e8x, h, rfl\u27e9, \u03bb h, let \u27e8y, h, h'\u27e9 := h in\n    (prod.eq_iff_fst_eq_snd_eq.2 \u27e8h', subsingleton.elim y.2 x.2\u27e9) \u25b8 h\u27e9),\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 \u2208 (simulate' so oa s).support} :=\nbegin\n  refine set.ext (\u03bb x, _),\n  rw [set.mem_set_of, support_simulate', set.mem_image],\n  refine \u27e8\u03bb h, \u27e8x, h, rfl\u27e9, \u03bb h, _\u27e9,\n  obtain \u27e8y, hy, h\u27e9 := h,\n  rwa [\u2190 @prod.mk.eta _ _ x, \u2190 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 : \u03b1 \u00d7 S) [subsingleton S] :\n  x \u2208 (simulate so oa s).support \u2194 x.fst \u2208 (simulate' so oa s).support :=\nbegin\n  refine subsingleton.elim so.default_state s \u25b8 _,\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 : \u2200 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  \u2045simulate so oa s\u2046 = \u2045simulate' so oa s\u2046.map (\u03bb x, (x, s)) :=\nbegin\n  have : (\u03bb (x : \u03b1), (x, s)) \u2218 prod.fst = id,\n  from funext (\u03bb x, prod.eq_iff_fst_eq_snd_eq.2 \u27e8rfl, subsingleton.elim _ _\u27e9),\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 : \u03b1 \u00d7 S) : \u2045simulate so oa s\u2046 x = \u2045simulate' so oa s\u2046 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 $ \u03bb 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 (\u03b1 \u00d7 S)) : \u2045e | simulate so oa s\u2046 = \u2045prod.fst '' e | simulate' so oa s\u2046 :=\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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  {\n    assume h1 : G.colorable 2,\n    have h2 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from sorry,\n    show (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)), from sorry,\n  },\n  {\n    assume h1 : (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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": "\nimport test.slim_check.tactics\n\nnamespace slim_check.examples\n\nexample : \u2200 n : \u2115, n > n+1 :=\nby expect_failure { slim_check }\n\nopen slim_check\n\nrun_cmd tactic.unsafe_run_io $ @testable.check (\u2200 n : \u2115, n > n+1) _ 100\nrun_cmd tactic.unsafe_run_io $ @testable.check (\u2200 n m : \u2115, n \u2264 m)  _ 100\nrun_cmd tactic.unsafe_run_io $ @testable.check (\u2200 n m : \u2115, 2*m + n < 100)  _ 100\nrun_cmd tactic.unsafe_run_io $ @testable.check (\u2200 n m : \u2115, 0 \u2264 m + n)  _ 100\nrun_cmd tactic.unsafe_run_io $ @testable.check\n                     (\u2200 (n : \u2124) (xs : list \u2124) x,\n                                 x \u2208 xs \u2192 x < n)  _ 100\n\nexample : \u2200 n : \u2115, n < n+1 :=\nby slim_check\n\nexample : 1 < (2 : \u2115) :=\nby slim_check\n\ndef even (n : \u2115) : bool :=\nn % 2 = 0\n\nsection\nvariables (\u03b1 : Type)\n\nvariables [has_add \u03b1] [has_one \u03b1] [decidable_eq \u03b1]\n\nexample : (\u2200 (xs : list \u03b1), 10 \u2208 xs \u2192 xs \u2260 [] \u2192 \u2203 (x \u2208 xs), x = (10 : \u03b1)) :=\nby slim_check\n\nexample : (\u2200 (xs : list \u03b1), xs \u2260 [] \u2192 \u2203 (x \u2208 xs), x = (10 : \u03b1)) :=\nby expect_failure { slim_check, }\n\nexample : (\u2200 (xs : list \u03b1), \u2203 (x \u2208 xs), \u2203 y \u2208 xs, x \u2260 y) :=\nby expect_failure { slim_check } -- remaining meta variables\n\nend\n\nexample : (\u2200 (x \u2208 [1,2,3,4]), x \u2260 10) :=\nby slim_check -- no error message or warning:\n              -- slim_check actually proves the statement\n\nexample : (\u2203 (x \u2208 [1,2,3,9]), x = 10) :=\nby expect_failure { slim_check }\n\nexample : (\u2200 (\u03b1 : Type) (xs : list \u03b1), xs.length < 10) :=\nby expect_failure { slim_check }\n\nexample : (\u2200 n m : \u2115, 2*m + n < 100) :=\nby expect_failure { slim_check }\n\nexample : (\u2200 (n : \u2124) (xs : list \u2124) x, x \u2208 xs \u2192 x \u2264 n) :=\nby expect_failure { slim_check }\n\nexample : (\u2200 (xs : list \u2124), \u2203 x \u2208 xs, \u2200 y \u2208 xs, x \u2264 y) :=\nby expect_failure { slim_check }\n\nexample : (\u2200 (xs : list \u2124), xs = [] \u2228 \u2203 x \u2208 xs, \u2200 y \u2208 xs, x \u2264 y) :=\nby slim_check\n\nexample : (\u2200 (xs : list \u2124), xs \u2260 [] \u2192 \u2203 x \u2208 xs, \u2200 y \u2208 xs, x \u2264 y) :=\nby slim_check\n\nexample : (\u2200 n m : \u2115, even m \u2192 \u00ac even n \u2192 \u00ac even (m+n)) :=\nby slim_check\n\nvariables n m : \u2115\n\nexample : (false \u2192 even m \u2192 \u00ac even n \u2192 even (m+n)) :=\nby expect_failure { slim_check }\n\nend slim_check.examples\n", "meta": {"author": "cipher1024", "repo": "slim_check", "sha": "5969b7f72e01fdd46f2502ed0cbf69c0699061d4", "save_path": "github-repos/lean/cipher1024-slim_check", "path": "github-repos/lean/cipher1024-slim_check/slim_check-5969b7f72e01fdd46f2502ed0cbf69c0699061d4/test/examples.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.6370307875894139, "lm_q1q2_score": 0.4899277823973066}}
{"text": "/-\nCopyright (c) 2019 Johannes H\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u211a 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, \u211a, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\nopen_locale big_operators\n\nvariables {F \u03b9 \u03b1 \u03b2 : Type*}\n\nnamespace rat\nopen_locale rat\n\nsection with_div_ring\nvariable [division_ring \u03b1]\n\n/-- Construct the canonical injection from `\u211a` 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 \u211a \u03b1 := \u27e8\u03bb r, r.1 / r.2\u27e9\n\ntheorem cast_def (r : \u211a) : (r : \u03b1) = r.num / r.denom := rfl\n\n@[simp] theorem cast_of_int (n : \u2124) : (of_int n : \u03b1) = n :=\nshow (n / (1:\u2115) : \u03b1) = n, by rw [nat.cast_one, div_one]\n\n@[simp, norm_cast] theorem cast_coe_int (n : \u2124) : ((n : \u211a) : \u03b1) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp, norm_cast] theorem cast_coe_nat (n : \u2115) : ((n : \u211a) : \u03b1) = n :=\nby rw [\u2190 int.cast_coe_nat, cast_coe_int, int.cast_coe_nat]\n\n@[simp, norm_cast] theorem cast_zero : ((0 : \u211a) : \u03b1) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp, norm_cast] theorem cast_one : ((1 : \u211a) : \u03b1) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem cast_commute (r : \u211a) (a : \u03b1) : commute \u2191r a :=\n(r.1.cast_commute a).div_left (r.2.cast_commute a)\n\ntheorem cast_comm (r : \u211a) (a : \u03b1) : (r : \u03b1) * a = a * r :=\n(cast_commute r a).eq\n\ntheorem commute_cast (a : \u03b1) (r : \u211a) : commute a r :=\n(r.cast_commute a).symm\n\n@[norm_cast] theorem cast_mk_of_ne_zero (a b : \u2124)\n  (b0 : (b:\u03b1) \u2260 0) : (a /. b : \u03b1) = a / b :=\nbegin\n  have b0' : b \u2260 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:\u03b1) \u2260 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:\u2124) \u2223 b, by rwa e at dd) with k ke,\n    have : (b:\u03b1) = (d:\u03b1) * (k:\u03b1), {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 : \u2124 \u2192 \u03b1) ((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 : \u03b1) = n / d,\n  rw [div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq,\n      \u2190 mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\n@[norm_cast] theorem cast_add_of_ne_zero : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m + n : \u211a) : \u03b1) = m + n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 nat.cast_zero),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 nat.cast_zero),\n  rw [num_denom', num_denom', add_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * (d\u2082 * (d\u2082\u207b\u00b9 * d\u2081\u207b\u00b9)) +\n    n\u2082 * (d\u2081 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9 : \u03b1) = n\u2081 * d\u2081\u207b\u00b9 + n\u2082 * d\u2082\u207b\u00b9,\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\u20810, d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820]} },\n  rw [\u2190 mul_assoc (d\u2082:\u03b1), mul_inv_cancel d\u20820, one_mul,\n      (nat.cast_commute _ _).eq], simp [d\u20810, mul_assoc]\nend\n\n@[simp, norm_cast] theorem cast_neg : \u2200 n, ((-n : \u211a) : \u03b1) = -n\n| \u27e8n, d, h, c\u27e9 := show (\u2191-n / d : \u03b1) = -(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 : \u211a}\n  (m0 : (m.denom : \u03b1) \u2260 0) (n0 : (n.denom : \u03b1) \u2260 0) : ((m - n : \u211a) : \u03b1) = m - n :=\nhave ((-n).denom : \u03b1) \u2260 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 : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m * n : \u211a) : \u03b1) = m * n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 nat.cast_zero),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 nat.cast_zero),\n  rw [num_denom', num_denom', mul_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * ((n\u2082 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9) : \u03b1) = n\u2081 * (d\u2081\u207b\u00b9 * (n\u2082 * d\u2082\u207b\u00b9)),\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\u20810, d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820]} },\n  rw [(d\u2081.commute_cast (_:\u03b1)).inv_right\u2080.eq]\nend\n\n@[simp] theorem cast_inv_nat (n : \u2115) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\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 : \u2124) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\nbegin\n  cases n,\n  { simp [cast_inv_nat] },\n  { simp only [int.cast_neg_succ_of_nat, \u2190 nat.cast_succ, cast_neg, inv_neg, cast_inv_nat] }\nend\n\n@[norm_cast] theorem cast_inv_of_ne_zero : \u2200 {n : \u211a},\n  (n.num : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9\n| \u27e8n, d, h, c\u27e9 := \u03bb (n0 : (n:\u03b1) \u2260 0) (d0 : (d:\u03b1) \u2260 0), begin\n  have n0' : (n:\u2124) \u2260 0 := \u03bb e, by rw e at n0; exact n0 int.cast_zero,\n  have d0' : (d:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb 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 : \u211a} (md : (m.denom : \u03b1) \u2260 0)\n  (nn : (n.num : \u03b1) \u2260 0) (nd : (n.denom : \u03b1) \u2260 0) : ((m / n : \u211a) : \u03b1) = m / n :=\nhave (n\u207b\u00b9.denom : \u2124) \u2223 n.num,\nby conv in n\u207b\u00b9.denom { rw [\u2190(@num_denom n), inv_def] };\n   apply denom_dvd,\nhave (n\u207b\u00b9.denom : \u03b1) = 0 \u2192 (n.num : \u03b1) = 0, from\n\u03bb h, let \u27e8k, e\u27e9 := this in\n  by have := congr_arg (coe : \u2124 \u2192 \u03b1) 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 \u03b1] : \u2200 {m n : \u211a}, (m : \u03b1) = n \u2194 m = n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := begin\n  refine \u27e8\u03bb h, _, congr_arg _\u27e9,\n  have d\u20810 : d\u2081 \u2260 0 := ne_of_gt h\u2081,\n  have d\u20820 : d\u2082 \u2260 0 := ne_of_gt h\u2082,\n  have d\u2081a : (d\u2081:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20810,\n  have d\u2082a : (d\u2082:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20820,\n  rw [num_denom', num_denom'] at h \u22a2,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d\u20810, d\u20820] at h \u22a2,\n  rwa [eq_div_iff_mul_eq d\u2082a, division_def, mul_assoc, (d\u2081.cast_commute (d\u2082:\u03b1)).inv_left\u2080.eq,\n    \u2190 mul_assoc, \u2190 division_def, eq_comm, eq_div_iff_mul_eq d\u2081a, eq_comm,\n    \u2190 int.cast_coe_nat d\u2081, \u2190 int.cast_mul, \u2190 int.cast_coe_nat d\u2082, \u2190 int.cast_mul,\n    int.cast_inj, \u2190 mk_eq (int.coe_nat_ne_zero.2 d\u20810) (int.coe_nat_ne_zero.2 d\u20820)] at h\nend\n\ntheorem cast_injective [char_zero \u03b1] : function.injective (coe : \u211a \u2192 \u03b1)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) = 0 \u2194 n = 0 :=\nby rw [\u2190 cast_zero, cast_inj]\n\ntheorem cast_ne_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) \u2260 0 \u2194 n \u2260 0 :=\nnot_congr cast_eq_zero\n\n@[simp, norm_cast] theorem cast_add [char_zero \u03b1] (m n) :\n  ((m + n : \u211a) : \u03b1) = 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 \u03b1] (m n) :\n  ((m - n : \u211a) : \u03b1) = 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 \u03b1] (m n) :\n  ((m * n : \u211a) : \u03b1) = 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 \u03b1] (n : \u211a) :\n  ((bit0 n : \u211a) : \u03b1) = bit0 n :=\ncast_add _ _\n\n@[simp, norm_cast] theorem cast_bit1 [char_zero \u03b1] (n : \u211a) :\n  ((bit1 n : \u211a) : \u03b1) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\nvariables (\u03b1) [char_zero \u03b1]\n\n/-- Coercion `\u211a \u2192 \u03b1` as a `ring_hom`. -/\ndef cast_hom : \u211a \u2192+* \u03b1 := \u27e8coe, cast_one, cast_mul, cast_zero, cast_add\u27e9\n\nvariable {\u03b1}\n\n@[simp] lemma coe_cast_hom : \u21d1(cast_hom \u03b1) = coe := rfl\n\n@[simp, norm_cast] theorem cast_inv (n) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 := (cast_hom \u03b1).map_inv _\n@[simp, norm_cast] theorem cast_div (m n) : ((m / n : \u211a) : \u03b1) = m / n := (cast_hom \u03b1).map_div _ _\n\n@[norm_cast] theorem cast_mk (a b : \u2124) : ((a /. b) : \u03b1) = a / b :=\nby simp only [mk_eq_div, cast_div, cast_coe_int]\n\n@[simp, norm_cast] theorem cast_pow (q) (k : \u2115) : ((q ^ k : \u211a) : \u03b1) = q ^ k :=\n(cast_hom \u03b1).map_pow q k\n\n@[simp, norm_cast] lemma cast_list_sum (s : list \u211a) : (\u2191(s.sum) : \u03b1) = (s.map coe).sum :=\nmap_list_sum (rat.cast_hom \u03b1) _\n\n@[simp, norm_cast] lemma cast_multiset_sum (s : multiset \u211a) : (\u2191(s.sum) : \u03b1) = (s.map coe).sum :=\nmap_multiset_sum (rat.cast_hom \u03b1) _\n\n@[simp, norm_cast] lemma cast_sum (s : finset \u03b9) (f : \u03b9 \u2192 \u211a) :\n  (\u2191(\u2211 i in s, f i) : \u03b1) = \u2211 i in s, f i :=\nmap_sum (rat.cast_hom \u03b1) _ _\n\n@[simp, norm_cast] lemma cast_list_prod (s : list \u211a) : (\u2191(s.prod) : \u03b1) = (s.map coe).prod :=\nmap_list_prod (rat.cast_hom \u03b1) _\n\nend with_div_ring\n\nsection field\nvariables [field \u03b1] [char_zero \u03b1]\n\n@[simp, norm_cast] lemma cast_multiset_prod (s : multiset \u211a) : (\u2191(s.prod) : \u03b1) = (s.map coe).prod :=\nmap_multiset_prod (rat.cast_hom \u03b1) _\n\n@[simp, norm_cast] lemma cast_prod (s : finset \u03b9) (f : \u03b9 \u2192 \u211a) :\n  (\u2191(\u220f i in s, f i) : \u03b1) = \u220f i in s, f i :=\nmap_prod (rat.cast_hom \u03b1) _ _\n\nend field\n\n@[simp, norm_cast] theorem cast_nonneg [linear_ordered_field \u03b1] : \u2200 {n : \u211a}, 0 \u2264 (n : \u03b1) \u2194 0 \u2264 n\n| \u27e8n, d, h, c\u27e9 :=\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 \u03b1] {m n : \u211a} : (m : \u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw [\u2190 sub_nonneg, \u2190 cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp, norm_cast] theorem cast_lt [linear_ordered_field \u03b1] {m n : \u211a} : (m : \u03b1) < n \u2194 m < n :=\nby simpa [-cast_le] using not_congr (@cast_le \u03b1 _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) \u2264 0 \u2194 n \u2264 0 :=\nby rw [\u2190 cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field \u03b1] {n : \u211a} : (0 : \u03b1) < n \u2194 0 < n :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) < 0 \u2194 n < 0 :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp, norm_cast] theorem cast_id : \u2200 n : \u211a, \u2191n = n\n| \u27e8n, d, h, c\u27e9 := by rw [num_denom', cast_mk, mk_eq_div]\n\n@[simp] lemma cast_hom_rat : cast_hom \u211a = ring_hom.id \u211a :=\nring_hom.ext cast_id\n\n@[simp, norm_cast] theorem cast_min [linear_ordered_field \u03b1] {a b : \u211a} :\n  (\u2191(min a b) : \u03b1) = min a b :=\nby by_cases a \u2264 b; simp [h, min_def]\n\n@[simp, norm_cast] theorem cast_max [linear_ordered_field \u03b1] {a b : \u211a} :\n  (\u2191(max a b) : \u03b1) = max a b :=\nby by_cases b \u2264 a; simp [h, max_def]\n\n@[simp, norm_cast] theorem cast_abs [linear_ordered_field \u03b1] {q : \u211a} :\n  ((|q| : \u211a) : \u03b1) = |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 : \u211a \u2192+* k) (r : \u211a) : f r = r :=\ncalc f r = f (r.1 / r.2) : by rw [\u2190 int.cast_coe_nat, \u2190 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 \u03b1] [division_ring \u03b2] [char_zero \u03b1] [ring_hom_class F \u03b1 \u03b2]\n  (f : F) (q : \u211a) : f q = q :=\n((f : \u03b1 \u2192+* \u03b2).comp $ cast_hom \u03b1).eq_rat_cast q\n\nlemma ring_hom.ext_rat {R : Type*} [semiring R] (f g : \u211a \u2192+* R) : f = g :=\nbegin\n  ext r,\n  refine rat.num_denom_cases_on' r _,\n  intros a b b0,\n  let \u03c6 : \u2124 \u2192+* R := f.comp (int.cast_ring_hom \u211a),\n  let \u03c8 : \u2124 \u2192+* R := g.comp (int.cast_ring_hom \u211a),\n  rw [rat.mk_eq_div, int.cast_coe_nat],\n  have b0' : (b:\u211a) \u2260 0 := nat.cast_ne_zero.2 b0,\n  have : \u2200 n : \u2124, f n = g n := \u03bb n, show \u03c6 n = \u03c8 n, by rw [\u03c6.ext_int \u03c8],\n  calc f (a * b\u207b\u00b9)\n      = f a * f b\u207b\u00b9 * (g (b:\u2124) * g b\u207b\u00b9) :\n        by rw [int.cast_coe_nat, \u2190 g.map_mul, mul_inv_cancel b0', g.map_one, mul_one, f.map_mul]\n  ... = g a * f b\u207b\u00b9 * (f (b:\u2124) * g b\u207b\u00b9) : by rw [this a, \u2190 this b]\n  ... = g (a * b\u207b\u00b9) :\n        by rw [int.cast_coe_nat, mul_assoc, \u2190 mul_assoc (f b\u207b\u00b9),\n              \u2190 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 (\u211a \u2192+* R) :=\n\u27e8ring_hom.ext_rat\u27e9\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 `\u03c6`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : \u211a \u2192*\u2080 M}\n  (same_on_int : f.comp (int.cast_ring_hom \u211a).to_monoid_with_zero_hom =\n    g.comp (int.cast_ring_hom \u211a).to_monoid_with_zero_hom) : f = g :=\nbegin\n  have same_on_int' : \u2200 k : \u2124, f k = g k := congr_fun same_on_int,\n  ext x,\n  rw [\u2190 @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 `\u03c6` and its value on `-1` completely determine `\u03c6`. -/\ntheorem ext_rat_on_pnat {f g : \u211a \u2192*\u2080 M}\n  (same_on_neg_one : f (-1) = g (-1)) (same_on_pnat : \u2200 n : \u2115, 0 < n \u2192 f n = g n) : f = g :=\next_rat $ ext_int' (by simpa) \u2039_\u203a\n\nend monoid_with_zero_hom\n\nnamespace mul_opposite\n\nvariables [division_ring \u03b1]\n\n@[simp, norm_cast] lemma op_rat_cast (r : \u211a) : op (r : \u03b1) = (\u2191r : \u03b1\u1d50\u1d52\u1d56) :=\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 : \u211a) : unop (r : \u03b1\u1d50\u1d52\u1d56) = 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 \u27f6 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 \u27f6 Y`, then `P` holds for `f \u2223_ Y.basic_open r` for any\n  global section `r`.\n3. If `P` holds for `f \u2223_ 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 \u27f6 Y`, then `P` holds for `f \u2223_ U` for any `U`.\n3. If `P` holds for `f \u2223_ 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\u1d62 }` of `Y`\n  such that `P` holds for `f \u2223_ U\u1d62`.\n- `algebraic_geometry.affine_target_morphism_property.is_local_of_open_cover_imply`:\n  If the existance of an affine cover `{ U\u1d62 }` of `Y` such that `P` holds for `f \u2223_ U\u1d62` 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 \u27f6 Y`, then `target_affine_locally P f \u2194 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\u1d62 }` of `Y`\n  such that `P` holds for `f \u2223_ U\u1d62`.\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  \u2200 \u2983X Y : Scheme\u2984 (f : X \u27f6 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  \u27e8Scheme.affineTargetIsIso\u27e9\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 => \u2203 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 \u27f6 Y) [IsAffine Y] : P.toProperty f \u2194 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 \u27f6 Y) (g : Y \u27f6 Z) [IsIso f] [IsAffine Z] : P (f \u226b g) \u2194 P g := by\n  rw [\u2190 P.to_property_apply, \u2190 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 \u27f6 Y) (g : Y \u27f6 Z) [IsIso g] [IsAffine Z] [IsAffine Y] :\n    P (f \u226b g) \u2194 P f := by rw [\u2190 P.to_property_apply, \u2190 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\u2081 : \u2200 {X Y Z} (e : X \u2245 Y) (f : Y \u27f6 Z) [IsAffine Z], P f \u2192 P (e.hom \u226b f))\n    (h\u2082 :\n      \u2200 {X Y Z} (e : Y \u2245 Z) (f : X \u27f6 Y) [h : IsAffine Y],\n        P f \u2192 @P (f \u226b e.hom) (is_affine_of_iso e.inv)) :\n    P.toProperty.RespectsIso := by\n  constructor\n  \u00b7 rintro X Y Z e f \u27e8a, h\u27e9\n    exact \u27e8a, h\u2081 e f h\u27e9\n  \u00b7 rintro X Y Z e f \u27e8a, h\u27e9\n    exact \u27e8is_affine_of_iso e.inv, h\u2082 e f h\u27e9\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 \u27f6 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 \u27f6 Y) => \u2200 U : Y.affineOpens, @P (f \u2223_ 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 \u27f6 Y) [IsIso f] : IsAffineOpen ((Opens.map f.1.base).obj U) :=\n  haveI : is_affine _ := hU\n  is_affine_of_iso (f \u2223_ 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  \u00b7 introv H U\n    rw [morphism_restrict_comp, affine_cancel_left_is_iso hP]\n    exact H U\n  \u00b7 introv H\n    rintro \u27e8U, hU : is_affine_open U\u27e9\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 \u27e8(opens.map e.hom.val.base).obj U, hU.map_is_iso e.hom\u27e9\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 \u27f6 Y`, then `P` holds for `f \u2223_ Y.basic_open r` for any\n  global section `r`.\n3. If `P` holds for `f \u2223_ 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    \u2200 {X Y : Scheme} [IsAffine Y] (f : X \u27f6 Y) (r : Y.Presheaf.obj <| op \u22a4),\n      P f \u2192 @P (f \u2223_ Y.basic_open r) ((top_is_affine_open Y).basicOpen_is_affine _)\n  ofBasicOpenCover :\n    \u2200 {X Y : Scheme} [IsAffine Y] (f : X \u27f6 Y) (s : Finset (Y.Presheaf.obj <| op \u22a4))\n      (hs : Ideal.span (s : Set (Y.Presheaf.obj <| op \u22a4)) = \u22a4),\n      (\u2200 r : s, @P (f \u2223_ Y.basic_open r.1) ((top_is_affine_open Y).basicOpen_is_affine _)) \u2192 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 \u27f6 Y) (\ud835\udcb0 : Y.OpenCover) [\u2200 i, IsAffine (\ud835\udcb0.obj i)]\n    (h\ud835\udcb0 : \u2200 i, P (pullback.snd : (\ud835\udcb0.pullbackCover f).obj i \u27f6 \ud835\udcb0.obj i)) : targetAffineLocally P f :=\n  by\n  classical\n    let S i :=\n      (\u27e8\u27e8Set.range (\ud835\udcb0.map i).1.base, (\ud835\udcb0.is_open i).base_open.open_range\u27e9,\n          range_is_affine_open_of_open_immersion (\ud835\udcb0.map i)\u27e9 :\n        Y.affine_opens)\n    intro U\n    apply of_affine_open_cover U (Set.range S)\n    \u00b7 intro U r h\n      haveI : is_affine _ := U.2\n      have := hP.2 (f \u2223_ U.1)\n      replace this := this (Y.presheaf.map (eq_to_hom U.1.openEmbedding_obj_top).op r) h\n      rw [\u2190 P.to_property_apply] at this\u22a2\n      exact (hP.1.arrow_mk_iso_iff (morphism_restrict_restrict_basic_open f _ r)).mp this\n    \u00b7 intro U s hs H\n      haveI : is_affine _ := U.2\n      apply hP.3 (f \u2223_ U.1) (s.image (Y.presheaf.map (eq_to_hom U.1.openEmbedding_obj_top).op))\n      \u00b7 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 [\u2190 hs]\n        simp only [eq_to_hom_op, eq_to_hom_map, Finset.coe_image]\n        have :\n          \u2200 {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      \u00b7 rintro \u27e8r, hr\u27e9\n        obtain \u27e8r, hr', rfl\u27e9 := finset.mem_image.mp hr\n        simp_rw [\u2190 P.to_property_apply] at H\u22a2\n        exact (hP.1.arrow_mk_iso_iff (morphism_restrict_restrict_basic_open f _ r)).mpr (H \u27e8r, hr'\u27e9)\n    \u00b7 rw [Set.eq_univ_iff_forall]\n      simp only [Set.mem_union\u1d62]\n      intro x\n      exact \u27e8\u27e8_, \u27e8\ud835\udcb0.f x, rfl\u27e9\u27e9, \ud835\udcb0.covers x\u27e9\n    \u00b7 rintro \u27e8_, i, rfl\u27e9\n      simp_rw [\u2190 P.to_property_apply] at h\ud835\udcb0\u22a2\n      exact (hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)).mpr (h\ud835\udcb0 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 \u27f6 Y) :\n    TFAE\n      [targetAffineLocally P f,\n        \u2203 (\ud835\udcb0 : Scheme.OpenCover.{u} Y)(_ : \u2200 i, IsAffine (\ud835\udcb0.obj i)),\n          \u2200 i : \ud835\udcb0.J, P (pullback.snd : (\ud835\udcb0.pullback_cover f).obj i \u27f6 \ud835\udcb0.obj i),\n        \u2200 (\ud835\udcb0 : Scheme.OpenCover.{u} Y) [\u2200 i, IsAffine (\ud835\udcb0.obj i)] (i : \ud835\udcb0.J),\n          P (pullback.snd : (\ud835\udcb0.pullback_cover f).obj i \u27f6 \ud835\udcb0.obj i),\n        \u2200 {U : Scheme} (g : U \u27f6 Y) [IsAffine U] [IsOpenImmersion g],\n          P (pullback.snd : pullback f g \u27f6 U),\n        \u2203 (\u03b9 : Type u)(U : \u03b9 \u2192 Opens Y.carrier)(hU : sup\u1d62 U = \u22a4)(hU' : \u2200 i, IsAffineOpen (U i)),\n          \u2200 i, @P (f \u2223_ U i) (hU' i)] :=\n  by\n  tfae_have 1 \u2192 4\n  \u00b7 intro H U g h\u2081 h\u2082\n    skip\n    replace H := H \u27e8\u27e8_, h\u2082.base_open.open_range\u27e9, range_is_affine_open_of_open_immersion g\u27e9\n    rw [\u2190 P.to_property_apply] at H\u22a2\n    rwa [\u2190 hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n  tfae_have 4 \u2192 3\n  \u00b7 intro H \ud835\udcb0 h\ud835\udcb0 i\n    skip\n    apply H\n  tfae_have 3 \u2192 2\n  \u00b7 exact fun H => \u27e8Y.affine_cover, inferInstance, H Y.affine_cover\u27e9\n  tfae_have 2 \u2192 1\n  \u00b7 rintro \u27e8\ud835\udcb0, h\ud835\udcb0, H\u27e9\n    exact target_affine_locally_of_open_cover hP f \ud835\udcb0 H\n  tfae_have 5 \u2192 2\n  \u00b7 rintro \u27e8\u03b9, U, hU, hU', H\u27e9\n    refine' \u27e8Y.open_cover_of_supr_eq_top U hU, hU', _\u27e9\n    intro i\n    specialize H i\n    rw [\u2190 P.to_property_apply, \u2190 hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n    rw [\u2190 P.to_property_apply] at H\n    convert H\n    all_goals ext1; exact Subtype.range_coe\n  tfae_have 1 \u2192 5\n  \u00b7 intro H\n    refine'\n      \u27e8Y.carrier, fun x => (Y.affine_cover.map x).opensRange, _, fun i =>\n        range_is_affine_open_of_open_immersion _, _\u27e9\n    \u00b7 rw [eq_top_iff]\n      intro x _\n      erw [opens.mem_supr]\n      exact \u27e8x, Y.affine_cover.covers x\u27e9\n    \u00b7 intro i\n      exact H \u27e8_, range_is_affine_open_of_open_immersion _\u27e9\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      \u2200 {X Y : Scheme.{u}} (f : X \u27f6 Y),\n        (\u2203 (\ud835\udcb0 : Scheme.OpenCover.{u} Y)(_ : \u2200 i, IsAffine (\ud835\udcb0.obj i)),\n            \u2200 i : \ud835\udcb0.J, P (pullback.snd : (\ud835\udcb0.pullback_cover f).obj i \u27f6 \ud835\udcb0.obj i)) \u2192\n          \u2200 {U : Scheme} (g : U \u27f6 Y) [IsAffine U] [IsOpenImmersion g],\n            P (pullback.snd : pullback f g \u27f6 U)) :\n    P.IsLocal := by\n  refine' \u27e8hP, _, _\u27e9\n  \u00b7 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 \u27e8Scheme.open_cover_of_is_iso (\ud835\udfd9 Y), _, _\u27e9 (Y.of_restrict _) _inst _\n    \u00b7 intro i\n      dsimp\n      infer_instance\n    \u00b7 intro i\n      dsimp\n      rwa [\u2190 category.comp_id pullback.snd, \u2190 pullback.condition, affine_cancel_left_is_iso hP]\n  \u00b7 introv hs hs'\n    skip\n    replace hs := ((top_is_affine_open Y).basicOpen_union_eq_self_iff _).mpr hs\n    have := H f \u27e8Y.open_cover_of_supr_eq_top _ hs, _, _\u27e9 (\ud835\udfd9 _)\n    rwa [\u2190 category.comp_id pullback.snd, \u2190 pullback.condition, affine_cancel_left_is_iso hP] at\n      this\n    \u00b7 intro i\n      exact (top_is_affine_open Y).basicOpen_is_affine _\n    \u00b7 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 \u27f6 Y) (\ud835\udcb0 : Scheme.OpenCover.{u} Y)\n    [h\ud835\udcb0 : \u2200 i, IsAffine (\ud835\udcb0.obj i)] :\n    targetAffineLocally P f \u2194 \u2200 i, @P (pullback.snd : pullback f (\ud835\udcb0.map i) \u27f6 _) (h\ud835\udcb0 i) :=\n  \u27e8fun H =>\n    let h := ((hP.affine_openCover_tFAE f).out 0 2).mp H\n    h \ud835\udcb0,\n    fun H =>\n    let h := ((hP.affine_openCover_tFAE f).out 1 0).mp\n    h \u27e8\ud835\udcb0, inferInstance, H\u27e9\u27e9\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 \u27f6 Y) [IsAffine Y] : targetAffineLocally P f \u2194 P f :=\n  by\n  rw [hP.affine_open_cover_iff f _]\n  swap; \u00b7 exact Scheme.open_cover_of_is_iso (\ud835\udfd9 Y)\n  swap;\n  \u00b7 intro\n    dsimp\n    infer_instance\n  trans P (pullback.snd : pullback f (\ud835\udfd9 _) \u27f6 _)\n  \u00b7 exact \u27e8fun H => H PUnit.unit, fun H _ => H\u27e9\n  rw [\u2190 category.comp_id pullback.snd, \u2190 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 \u27f6 Y`, then `P` holds for `f \u2223_ U` for any `U`.\n3. If `P` holds for `f \u2223_ 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 : \u2200 {X Y : Scheme} (f : X \u27f6 Y) (U : Opens Y.carrier), P f \u2192 P (f \u2223_ U)\n  of_open_cover :\n    \u2200 {X Y : Scheme.{u}} (f : X \u27f6 Y) (\ud835\udcb0 : Scheme.OpenCover.{u} Y),\n      (\u2200 i : \ud835\udcb0.J, P (pullback.snd : (\ud835\udcb0.pullbackCover f).obj i \u27f6 \ud835\udcb0.obj i)) \u2192 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  \u00b7 exact target_affine_locally_respects_iso hP.1\n  \u00b7 intro X Y f U H V\n    rw [\u2190 P.to_property_apply, hP.1.arrow_mk_iso_iff (morphism_restrict_restrict f _ _)]\n    convert H \u27e8_, is_affine_open.image_is_open_immersion V.2 (Y.of_restrict _)\u27e9\n    rw [\u2190 P.to_property_apply]\n    rfl\n  \u00b7 rintro X Y f \ud835\udcb0 h\ud835\udcb0\n    rw [(hP.affine_open_cover_tfae f).out 0 1]\n    refine' \u27e8\ud835\udcb0.bind fun _ => Scheme.affine_cover _, _, _\u27e9\n    \u00b7 intro i\n      dsimp [Scheme.open_cover.bind]\n      infer_instance\n    \u00b7 intro i\n      specialize h\ud835\udcb0 i.1\n      rw [(hP.affine_open_cover_tfae (pullback.snd : pullback f (\ud835\udcb0.map i.fst) \u27f6 _)).out 0 2] at h\ud835\udcb0\n      specialize h\ud835\udcb0 (Scheme.affine_cover _) i.2\n      let e :\n        pullback f ((\ud835\udcb0.obj i.fst).affineCover.map i.snd \u226b \ud835\udcb0.map i.fst) \u27f6\n          pullback (pullback.snd : pullback f (\ud835\udcb0.map i.fst) \u27f6 _)\n            ((\ud835\udcb0.obj i.fst).affineCover.map i.snd) :=\n        by\n        refine' (pullback_symmetry _ _).Hom \u226b _\n        refine' (pullback_right_pullback_fst_iso _ _ _).inv \u226b _\n        refine' (pullback_symmetry _ _).Hom \u226b _\n        refine' pullback.map _ _ _ _ (pullback_symmetry _ _).Hom (\ud835\udfd9 _) (\ud835\udfd9 _) _ _ <;>\n          simp only [category.comp_id, category.id_comp, pullback_symmetry_hom_comp_snd]\n      rw [\u2190 affine_cancel_left_is_iso hP.1 e] at h\ud835\udcb0\n      convert h\ud835\udcb0\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 \u27f6 Y) :\n    TFAE\n      [P f,\n        \u2203 \ud835\udcb0 : Scheme.OpenCover.{u} Y,\n          \u2200 i : \ud835\udcb0.J, P (pullback.snd : (\ud835\udcb0.pullbackCover f).obj i \u27f6 \ud835\udcb0.obj i),\n        \u2200 (\ud835\udcb0 : Scheme.OpenCover.{u} Y) (i : \ud835\udcb0.J),\n          P (pullback.snd : (\ud835\udcb0.pullbackCover f).obj i \u27f6 \ud835\udcb0.obj i),\n        \u2200 U : Opens Y.carrier, P (f \u2223_ U),\n        \u2200 {U : Scheme} (g : U \u27f6 Y) [IsOpenImmersion g], P (pullback.snd : pullback f g \u27f6 U),\n        \u2203 (\u03b9 : Type u)(U : \u03b9 \u2192 Opens Y.carrier)(hU : sup\u1d62 U = \u22a4), \u2200 i, P (f \u2223_ U i)] :=\n  by\n  tfae_have 2 \u2192 1\n  \u00b7 rintro \u27e8\ud835\udcb0, H\u27e9\n    exact hP.3 f \ud835\udcb0 H\n  tfae_have 1 \u2192 4\n  \u00b7 intro H U\n    exact hP.2 f U H\n  tfae_have 4 \u2192 3\n  \u00b7 intro H \ud835\udcb0 i\n    rw [\u2190 hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n    exact H (\ud835\udcb0.map i).opensRange\n  tfae_have 3 \u2192 2\n  \u00b7 exact fun H => \u27e8Y.affine_cover, H Y.affine_cover\u27e9\n  tfae_have 4 \u2192 5\n  \u00b7 intro H U g hg\n    skip\n    rw [\u2190 hP.1.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n    apply H\n  tfae_have 5 \u2192 4\n  \u00b7 intro H U\n    erw [hP.1.cancel_left_isIso]\n    apply H\n  tfae_have 4 \u2192 6\n  \u00b7 intro H\n    exact \u27e8PUnit, fun _ => \u22a4, csup\u1d62_const, fun _ => H _\u27e9\n  tfae_have 6 \u2192 2\n  \u00b7 rintro \u27e8\u03b9, U, hU, H\u27e9\n    refine' \u27e8Y.open_cover_of_supr_eq_top U hU, _\u27e9\n    intro i\n    rw [\u2190 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 \u27f6 Y) (\ud835\udcb0 : Scheme.OpenCover.{u} Y) :\n    P f \u2194 \u2200 i, P (pullback.snd : pullback f (\ud835\udcb0.map i) \u27f6 _) :=\n  \u27e8fun H =>\n    let h := ((hP.openCover_tFAE f).out 0 2).mp H\n    h \ud835\udcb0,\n    fun H =>\n    let h := ((hP.openCover_tFAE f).out 1 0).mp\n    h \u27e8\ud835\udcb0, H\u27e9\u27e9\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 \u27f6 S`\nimplies that `P` holds for `X \u00d7\u209b Y \u27f6 X` with `X` and `S` affine schemes. -/\ndef StableUnderBaseChange (P : AffineTargetMorphismProperty) : Prop :=\n  \u2200 \u2983X Y S : Scheme\u2984 [IsAffine S] [IsAffine X] (f : X \u27f6 S) (g : Y \u27f6 S),\n    P g \u2192 P (pullback.fst : pullback f g \u27f6 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 \u27f6 S) (g : Y \u27f6 S) [IsAffine S] (H : P g) :\n    targetAffineLocally P (pullback.fst : pullback f g \u27f6 X) :=\n  by\n  rw [(hP.affine_open_cover_tfae (pullback.fst : pullback f g \u27f6 X)).out 0 1]\n  use X.affine_cover, inferInstance\n  intro i\n  let e := pullback_symmetry _ _ \u226a\u226b pullback_right_pullback_fst_iso f g (X.affine_cover.map i)\n  have : e.hom \u226b pullback.fst = pullback.snd := by simp\n  rw [\u2190 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 \u27f6 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 \u27f6 _) ((S.affine_cover.pullback_cover f).map i) \u2245 _ :=\n        by\n        refine'\n          pullback_symmetry _ _ \u226a\u226b\n            pullback_right_pullback_fst_iso f g _ \u226a\u226b\n              _ \u226a\u226b\n                (pullback_right_pullback_fst_iso (S.affine_cover.map i) g\n                    (pullback.snd : pullback f (S.affine_cover.map i) \u27f6 _)).symm\n        exact\n          as_iso\n            (pullback.map _ _ _ _ (\ud835\udfd9 _) (\ud835\udfd9 _) (\ud835\udfd9 _) (by simpa using pullback.condition) (by simp))\n      have : e.hom \u226b pullback.fst = pullback.snd := by simp\n      rw [\u2190 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 [\u2190 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  \u2200 {U\u2081 U\u2082 : Scheme} (f\u2081 : U\u2081 \u27f6 X) (f\u2082 : U\u2082 \u27f6 X) [IsAffine U\u2081] [IsAffine U\u2082] [IsOpenImmersion f\u2081]\n    [IsOpenImmersion f\u2082], P (pullback.map_desc f\u2081 f\u2082 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  \u00b7 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  \u00b7 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 \u27f6 Y) (\ud835\udcb0 : Scheme.OpenCover.{u} Y) [\u2200 i, IsAffine (\ud835\udcb0.obj i)]\n    (\ud835\udcb0' : \u2200 i, Scheme.OpenCover.{u} (pullback f (\ud835\udcb0.map i))) [\u2200 i j, IsAffine ((\ud835\udcb0' i).obj j)]\n    (h\ud835\udcb0' : \u2200 i j k, P (pullback.mapDesc ((\ud835\udcb0' i).map j) ((\ud835\udcb0' i).map k) pullback.snd)) :\n    (targetAffineLocally P).diagonal f :=\n  by\n  refine' (hP.affine_open_cover_iff _ _).mpr _\n  \u00b7\n    exact\n      (Scheme.pullback.open_cover_of_base \ud835\udcb0 f f).bind fun i =>\n        Scheme.Pullback.openCoverOfLeftRight.{u, u} (\ud835\udcb0' i) (\ud835\udcb0' i) pullback.snd pullback.snd\n  \u00b7 intro i\n    dsimp at *\n    infer_instance\n  \u00b7 rintro \u27e8i, j, k\u27e9\n    dsimp\n    convert(affine_cancel_left_is_iso hP.1\n            (pullback_diagonal_map_iso _ _ ((\ud835\udcb0' i).map j) ((\ud835\udcb0' i).map k)).inv pullback.snd).mp\n        _\n    pick_goal 3\n    \u00b7 convert h\ud835\udcb0' 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 \u27f6 Y) (g : U \u27f6 Y)\n    [IsAffine U] [IsOpenImmersion g] (H : (targetAffineLocally P).diagonal f) :\n    P.diagonal (pullback.snd : pullback f g \u27f6 _) :=\n  by\n  rintro U V f\u2081 f\u2082 _ _ _ _\n  skip\n  replace H := ((hP.affine_open_cover_tfae (pullback.diagonal f)).out 0 3).mp H\n  let g\u2081 :=\n    pullback.map (f\u2081 \u226b pullback.snd) (f\u2082 \u226b pullback.snd) f f (f\u2081 \u226b pullback.fst) (f\u2082 \u226b pullback.fst)\n      g (by rw [category.assoc, category.assoc, pullback.condition])\n      (by rw [category.assoc, category.assoc, pullback.condition])\n  let g\u2082 : pullback f\u2081 f\u2082 \u27f6 pullback f g := pullback.fst \u226b f\u2081\n  specialize H g\u2081\n  rw [\u2190 affine_cancel_left_is_iso hP.1 (pullback_diagonal_map_iso f _ f\u2081 f\u2082).Hom]\n  convert H\n  \u00b7\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 \u27f6 Y) :\n    TFAE\n      [(targetAffineLocally P).diagonal f,\n        \u2203 (\ud835\udcb0 : Scheme.OpenCover.{u} Y)(_ : \u2200 i, IsAffine (\ud835\udcb0.obj i)),\n          \u2200 i : \ud835\udcb0.J, P.diagonal (pullback.snd : pullback f (\ud835\udcb0.map i) \u27f6 _),\n        \u2200 (\ud835\udcb0 : Scheme.OpenCover.{u} Y) [\u2200 i, IsAffine (\ud835\udcb0.obj i)] (i : \ud835\udcb0.J),\n          P.diagonal (pullback.snd : pullback f (\ud835\udcb0.map i) \u27f6 _),\n        \u2200 {U : Scheme} (g : U \u27f6 Y) [IsAffine U] [IsOpenImmersion g],\n          P.diagonal (pullback.snd : pullback f g \u27f6 _),\n        \u2203 (\ud835\udcb0 : Scheme.OpenCover.{u} Y)(_ : \u2200 i, IsAffine (\ud835\udcb0.obj i))(\ud835\udcb0' :\n          \u2200 i, Scheme.OpenCover.{u} (pullback f (\ud835\udcb0.map i)))(_ : \u2200 i j, IsAffine ((\ud835\udcb0' i).obj j)),\n          \u2200 i j k, P (pullback.map_desc ((\ud835\udcb0' i).map j) ((\ud835\udcb0' i).map k) pullback.snd)] :=\n  by\n  tfae_have 1 \u2192 4\n  \u00b7 introv H hU hg _ _\n    skip\n    apply P.diagonal_of_target_affine_locally <;> assumption\n  tfae_have 4 \u2192 3\n  \u00b7 introv H h\ud835\udcb0\n    skip\n    apply H\n  tfae_have 3 \u2192 2\n  \u00b7 exact fun H => \u27e8Y.affine_cover, inferInstance, H Y.affine_cover\u27e9\n  tfae_have 2 \u2192 5\n  \u00b7 rintro \u27e8\ud835\udcb0, h\ud835\udcb0, H\u27e9\n    skip\n    refine' \u27e8\ud835\udcb0, inferInstance, fun _ => Scheme.affine_cover _, inferInstance, _\u27e9\n    intro i j k\n    apply H\n  tfae_have 5 \u2192 1\n  \u00b7 rintro \u27e8\ud835\udcb0, _, \ud835\udcb0', _, H\u27e9\n    exact diagonal_target_affine_locally_of_open_cover P hP f \ud835\udcb0 \ud835\udcb0' 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      \u2200 {X Y : Scheme.{u}} (f : X \u27f6 Y) (\ud835\udcb0 : Scheme.OpenCover.{u} Y),\n        (\u2200 i : \ud835\udcb0.J, P (pullback.snd : (\ud835\udcb0.pullbackCover f).obj i \u27f6 \ud835\udcb0.obj i)) \u2192 P f) :\n    PropertyIsLocalAtTarget P.universally :=\n  by\n  refine'\n    \u27e8P.universally_respects_iso, fun X Y f U =>\n      P.universally_stable_under_base_change (is_pullback_morphism_restrict f U).flip, _\u27e9\n  intro X Y f \ud835\udcb0 h X' Y' i\u2081 i\u2082 f' H\n  apply hP _ (\ud835\udcb0.pullback_cover i\u2082)\n  intro i\n  dsimp\n  apply h i (pullback.lift (pullback.fst \u226b i\u2081) (pullback.snd \u226b pullback.snd) _) pullback.snd\n  swap\n  \u00b7 rw [category.assoc, category.assoc, \u2190 pullback.condition, \u2190 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, \u2190 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\u2081 : P.RespectsIso)\n    (hP\u2082 :\n      \u2200 {X Y : Scheme.{u}} (f : X \u27f6 Y) {\u03b9 : Type u} (U : \u03b9 \u2192 Opens Y.carrier) (hU : sup\u1d62 U = \u22a4),\n        (\u2200 i, P (f \u2223_ U i)) \u2192 P f) :\n    PropertyIsLocalAtTarget P.universally :=\n  universallyIsLocalAtTarget P\n    (by\n      intro X Y f \ud835\udcb0 h\ud835\udcb0\n      apply hP\u2082 f (fun i : \ud835\udcb0.J => (\ud835\udcb0.map i).opensRange) \ud835\udcb0.supr_opens_range\n      simp_rw [hP\u2081.arrow_mk_iso_iff (morphism_restrict_opens_range f _)]\n      exact h\ud835\udcb0)\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 : \u2200 {\u03b1 \u03b2 : Type u} [TopologicalSpace \u03b1] [TopologicalSpace \u03b2] (f : \u03b1 \u2192 \u03b2), 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 = \u22a5`.  -/\nlemma eq_smul_of_le_smul_of_le_jacobson {I J : ideal R} {N : submodule R M}\n  (hN : N.fg) (hIN : N \u2264 I \u2022 N) (hIjac : I \u2264 jacobson J) : N = J \u2022 N :=\nbegin\n  refine le_antisymm _ (submodule.smul_le.2 (\u03bb _ _ _, 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) \u2022 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 \u2264 I \u2022 N) (hIjac : I \u2264 jacobson \u22a5) : N = \u22a5 :=\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 = \u22a5`.  -/\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 \u2264 jacobson J)\n  (hNN : N \u2294 N' \u2264 N \u2294 I \u2022 N') : N \u2294 I \u2022 N' = N \u2294 J \u2022 N' :=\nbegin\n  have hNN' : N \u2294 N' = N \u2294 I \u2022 N',\n    from le_antisymm hNN\n      (sup_le_sup_left (submodule.smul_le.2 (\u03bb _ _ _, submodule.smul_mem _ _)) _),\n  have h_comap := submodule.comap_injective_of_surjective (linear_map.range_eq_top.1 (N.range_mkq)),\n  have : (I \u2022 N').map N.mkq = N'.map N.mkq,\n  { rw \u2190h_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 [\u2190 map_smul'', this]; exact le_rfl)\n    hIJ,\n  rw [\u2190 map_smul'', \u2190h_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 \u2211 and \u220f notation\nopen filter finset real\nopen nat (coprime)\n\nopen_locale arithmetic_function\nopen_locale classical\nnoncomputable theory\n\nlemma good_d (N : \u2115) (M \u03b4 : \u211d) (A : finset \u2115) (hA\u2081 : A \u2286 finset.range (N + 1)) (hM : 0 < M)\n  (hAM : \u2200 n \u2208 A, M \u2264 (n : \u211d)) (hAq : \u2200 q \u2208 ppowers_in_set A, (2 : \u211d) * \u03b4 \u2264 rec_sum_local A q)\n  (I : finset \u2124) (q : \u2115) (hq : q \u2208 interval_rare_ppowers I A (M * \u03b4)) :\n  \u03b4 \u2264 rec_sum_local (A.filter (\u03bb n, \u2203 x \u2208 I, \u2191n \u2223 x)) q :=\nbegin\n  rw [interval_rare_ppowers, finset.mem_filter] at hq,\n  set nA : finset \u2115 := A.filter (\u03bb n, \u2200 x \u2208 I, \u00ac (\u2191n \u2223 x)),\n  have hnA : nA = A.filter (\u03bb n, \u00ac \u2203 x \u2208 I, \u2191n \u2223 x),\n  { apply finset.filter_congr,\n    simp },\n  have h1 : (rec_sum_local nA q : \u211d) \u2264 \u03b4,\n  { rw [rec_sum_local, local_part, finset.filter_comm, \u2190local_part, rat.cast_sum],\n    refine (finset.sum_le_card_nsmul _ _ ((q : \u211d) / 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 (\u03bb n, \u2203 x \u2208 I, \u2191n \u2223 x)) q + rec_sum_local nA q,\n  { rw [hnA, \u2190rec_sum_local_disjoint (finset.disjoint_filter_filter_neg _ _),\n      finset.filter_union_filter_neg_eq] },\n  have h4 : 2 * \u03b4 \u2264 (rec_sum_local (A.filter (\u03bb n, \u2203 x \u2208 I, \u2191n \u2223 x)) q) + (rec_sum_local nA q),\n  { rw_mod_cast \u2190 h2, exact hAq _ hq.1, },\n  linarith,\nend\n\nlemma explicit_mertens2 :\n  \u2200\u1da0 N : \u2115 in at_top,\n    ((\u2211 q in (finset.range (N + 1)).filter is_prime_pow, 1 / q) : \u211d) \u2264 (501/500) * log (log N) :=\nbegin\n  obtain \u27e8b, hb\u27e9 := prime_power_reciprocal,\n  obtain \u27e8c, hc\u2080, hc\u27e9 := 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 : \u211d)), (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\u2081 hN\u2082 hN\u2083,\n  dsimp at hN\u2081 hN\u2082,\n  have hN\u2084 : 0 < log N := hc\u2080.trans_le hN\u2081,\n  simp_rw [norm_inv, \u2190div_eq_mul_inv, \u2190one_div, norm_eq_abs, abs_of_nonneg hN\u2084.le,\n    nat.floor_coe] at hN\u2083,\n  have : c / log N \u2264 1 := div_le_one_of_le hN\u2081 hN\u2084.le,\n  have := sub_le_iff_le_add.1 (sub_le_of_abs_sub_le_right (hN\u2083.trans this)),\n  convert this.trans (show log (log N) + b + 1 \u2264 (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    \u03bb h _, (is_prime_pow.one_lt h).le,\nend\n\nlemma rec_sum_split (A B C E : finset \u2115) (h : 0 \u2209 B) (hC : C = A.filter(\u03bb n : \u2115, n \u2208 B \u2227\n   (\u2200 q \u2208 ppowers_in_set A, n \u2208 local_part B q \u2192 q \u2208 E))):\nrec_sum ((A\\C)\u2229B) \u2264 \u2211 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 _ \u2264 \u2211 (x : \u2115) in ppowers_in_set A \\ E, \u2211 (x_1 : \u2115) in local_part B x, (1:\u211a) / x_1 :_\n    ... \u2264 _ :_,\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 \u27e8q,hq\u27e9,\n rw [not_imp, not_imp] at hq, rw [mem_bUnion], refine \u27e8q,_,hq.2.1\u27e9,\n rw mem_sdiff, refine \u27e8hq.1,hq.2.2\u27e9,\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  \u2200\u1da0 (N : \u2115) in at_top, \u2200 M : \u211d, \u2200 A \u2286 finset.range(N+1),\n  (0 < M) \u2192 (M \u2264 N) \u2192 ((N : \u211d) \u2264 M^2) \u2192 (0 \u2209 A) \u2192\n  (\u2200 n \u2208 A, M \u2264 (n:\u211d)) \u2192 arith_regular N A \u2192\n  ( (log N)^(-(1/101 : \u211d)) \u2264 rec_sum A ) \u2192\n  (\u2200 q \u2208 ppowers_in_set A,\n    ((log N)^(-(1/100 : \u211d)) \u2264 rec_sum_local A q )) \u2192 (\n  (\u2203 B \u2286 A, ((rec_sum A) \u2264 3*rec_sum B) \u2227\n  ((ppower_rec_sum B : \u211d) \u2264 (2/3)* log(log N)))\n  \u2228 good_condition A (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) ((M : \u211d)/log N)\n  (M / (2*(log N)^(1/100 : \u211d))) ) :=\nbegin\n  let c := (35 : \u211d)/100,\n  have hthirdpos : (0 : \u211d) < 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 : \u211d)),\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:\u211d)/(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 \u2264 M*(N)^(-(2 : \u211d)/log(log N)), {\n    rw [neg_eq_neg_one_mul, \u2190 mul_div, \u2190 neg_eq_neg_one_mul, rpow_neg, \u2190 one_div,\n         \u2190 div_eq_mul_one_div, one_le_div],\n    calc _ \u2264 (N:\u211d)^((1:\u211d)/2) : _\n       ... \u2264 M :_,\n    apply rpow_le_rpow_of_exponent_le, exact_mod_cast le_of_lt hlarge,\n    rw [div_le_iff, \u2190 div_le_iff'], exact hlarge4, exact one_half_pos,\n    exact hlarge3, rw [\u2190 sqrt_eq_rpow, sqrt_le_iff],\n    refine \u27e8le_of_lt h0M, hNM\u27e9, 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)) \u2264 N, {\n    calc _ \u2264 M : _\n       ... \u2264 N : hMN,\n    nth_rewrite 1 \u2190 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 (\u03bb hP, _),\n  by_cases hzI : (0:\u2124) \u2208 I,\n  use (0:\u2124), refine \u27e8hzI,_\u27e9, intros q hq, refine dvd_zero _,\n  have hIcard0 : (I.card : \u2124) = \u230at + (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2\u230b + 1 - \u2308t - (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2\u2309, {\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 \u2260 0, {\n    rw [\u2190 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 [\u2190 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:\u2124):\u211d) \u2264 M*(N : \u211d)^(-(2 : \u211d)/log(log N))+1, {\n    rw hIcard0, push_cast,\n    calc _ \u2264  t + (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2 + 1 - \u2308t - (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2\u2309 : _\n       ... \u2264  t + (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2 + 1 - (t - (M*(N : \u211d)^(-(2 : \u211d)/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:\u211d) \u2264 M*(N : \u211d)^(-(2 : \u211d)/log(log N))+1, { exact_mod_cast hIcard, },\n  have hIcard'' : (I.card:\u211d) \u2264 2*M*(N : \u211d)^(-(2 : \u211d)/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:\u211d)^(2 * log 2 / log (log N) * (1 + 1/3)) <  M*((log N)^(-(1/101 : \u211d))/6)/(I.card : \u211d), {\n    rw [lt_div_iff, mul_comm, \u2190 lt_div_iff], refine lt_of_le_of_lt hIcard'' _,\n    rw [lt_div_iff, mul_comm (2:\u211d), mul_assoc, mul_assoc, mul_lt_mul_left, \u2190 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' :  \u2200 x y \u2208 I, (|x-y|:\u211d) \u2264 N, {\n    intros x hx y hy, refine le_trans (two_in_Icc' I hI hx hy) _,\n    calc _ \u2264  t + (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2 - \u2308t - (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2\u2309 : _\n       ... \u2264  t + (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2 - (t - (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) / 2) :_\n       ... = (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) :_\n       ... \u2264 _ : 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 : \u2200 x y \u2208 I, (int.nat_abs (x-y)) \u2264 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((\u03bb (n : \u2115), \u2203 (x \u2208 I), (n:\u2124) \u2223 x)),\n  let D := interval_rare_ppowers I A (M / (2 * log N ^ ((1 : \u211d) / 100))),\n  let E := (ppowers_in_set A).filter(\u03bb q : \u2115,\n    1 / (2 * log N ^ ((1:\u211d) / 100)) \u2264 rec_sum_local A_I q),\n  let K := (M / (2 * log N ^ ((1 : \u211d) / 100))),\n  by_cases hDne : D.nonempty,\n  rcases hDne with \u27e8x1,hx1\u27e9,\n  have hDE : D \u2286 E, {\n    intros q hq, rw mem_filter, refine \u27e8interval_rare_ppowers_subset I K hq,_\u27e9,\n    refine good_d N M (1 / (2 * log N ^ ((1:\u211d) / 100))) A hA h0M hMA _ I q _,\n    intros q hq, rw [two_mul, one_div, \u2190 inv_div_left, add_halves, \u2190 rpow_neg],\n    exact hreclocal q hq, exact le_of_lt hlarge0, rw \u2190 div_eq_mul_one_div, exact hq,\n  },\n  have hlocal : \u2200 q \u2208 E, \u2203 x \u2208 I, ((q:\u2124) \u2223x) \u2227\n   c*log(log N) \u2264 \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223x)), 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 \u27e8hf.1,_\u27e9, intros x2 hx2, specialize hfcopy2 x2 (hDE hx2),\n  have hclose : \u2200 x y \u2208 E, |(f x : \u211d)-(f y)| \u2264 N, {\n    intros q hq r hr, have hfcopy' := hfcopy,\n    specialize hfcopy q hq, specialize hfcopy' r hr,\n    apply @le_trans _ _ _ ((\u230at + M * N ^ ((-2) / log (log N)) / 2\u230b : \u211d)-\u2308t - M * N ^ ((-2) / log (log N)) / 2\u2309) N,\n    apply two_in_Icc, rw \u2190 hI, exact hfcopy.1, rw \u2190 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 : \u211d) t, rw \u2190 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:\u211d) \u2264 (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 \u27e8a,ha,hr\u27e9, rw mem_filter at hr,\n    refine \u27e8_,hr.2.1\u27e9,\n    calc _ \u2264 a : _\n       ... < N+1 :_,\n    exact nat.divisor_le hr.1, rw \u2190 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 : \u2200 x \u2208 E, f x = f x1 \u2228 f x = f x2,\n  clear hfcopy3, exfalso,\n  let A1 := A.filter( \u03bb n : \u2115, (n:\u2124) \u2223 (f x1) ),\n  let A2 := A.filter( \u03bb n : \u2115, (n:\u2124) \u2223 (f x2) ),\n  let A0 := A\\(A1\u222aA2),\n  have h3rec : rec_sum A \u2264 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 \u2208 A1 \u222a A2, left, exact htemp,\n    right, rw mem_sdiff, refine \u27e8hn,htemp\u27e9,\n  },\n  by_cases hAlarge : (rec_sum A \u2264 3*rec_sum A1) \u2228 (rec_sum A \u2264 3*rec_sum A2),\n  apply hnoB,\n  have hnum : (502:\u211d) / 500 - 35 / 100 \u2264 2 / 3, by norm_num1,\n  have hrecAs : \u2211 q in (ppowers_in_set A).filter(\u03bb n : \u2115, (n:\u2124) \u2223 (f x1)), (1:\u211d)/q\n    + \u2211 q in (ppowers_in_set A).filter(\u03bb n : \u2115, (n:\u2124) \u2223 (f x2)), (1:\u211d)/q \u2264\n    (502/500)*log(log N), {\n      calc _ \u2264 (ppower_rec_sum A:\u211d) + \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x2 \u2227 (n:\u2124)\u2223f x1)), (1:\u211d)/r :_\n         ... \u2264 (ppower_rec_sum A:\u211d) + (1/500)*log(log N) :_\n         ... \u2264 (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 \u27e8m,hm1,hm2\u27e9,\n      rw finset.mem_filter at hm2, refine \u27e8_,hm2.2.1,hr.2\u27e9, rw finset.mem_range,\n      apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw \u2190 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 \u2190 add_mul, norm_num1, refl,\n     },\n  cases hAlarge with hA1large hA2large,\n  refine \u27e8A1,filter_subset _ _,hA1large,_\u27e9,\n  rw ppower_rec_sum, push_cast,\n  calc _ \u2264 \u2211 q in (ppowers_in_set A).filter(\u03bb n : \u2115, (n:\u2124) \u2223 (f x1)), (1:\u211d)/q :_\n     ... \u2264 (502/500)*log(log N) - \u2211 q in (ppowers_in_set A).filter(\u03bb n : \u2115, (n:\u2124) \u2223f x2 ), (1:\u211d)/q :_\n     ... \u2264 (502/500)*log(log N) - (35/100)*log(log N) :_\n     ... \u2264 (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 \u27e8a,ha,hq\u27e9, use a, refine \u27e8mem_of_mem_filter a ha,hq,\u27e9, 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 [\u2190 sub_mul, mul_le_mul_right], exact hnum, exact hlarge3,\n  refine \u27e8A2,filter_subset _ _,hA2large,_\u27e9,\n  rw ppower_rec_sum, push_cast,\n  calc _ \u2264 \u2211 q in (ppowers_in_set A).filter(\u03bb n : \u2115, (n:\u2124) \u2223 (f x2)), (1:\u211d)/q :_\n     ... \u2264 (502/500)*log(log N) - \u2211 q in (ppowers_in_set A).filter(\u03bb n : \u2115, (n:\u2124) \u2223f x1 ), (1:\u211d)/q :_\n     ... \u2264 (502/500)*log(log N) - (35/100)*log(log N) :_\n     ... \u2264 (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 \u27e8a,ha,hq\u27e9, use a, refine \u27e8mem_of_mem_filter a ha,hq,\u27e9, 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 [\u2190 sub_mul, mul_le_mul_right], exact hnum, exact hlarge3,\n  let A' := A0.filter(\u03bb n : \u2115, n \u2208 A_I \u2227\n   (\u2200 q \u2208 ppowers_in_set A0, n \u2208 local_part A_I q \u2192 q \u2208 E)),\n  have hrecaux' : 1/log N + rec_sum ((A0\\A')\u2229A_I) \u2264 (log N)^(-(1/101 : \u211d))/6, {\n    calc _ \u2264 1/log N + \u2211 q in (ppowers_in_set A0)\\E, (rec_sum_local (A_I) q)/q :_\n       ... \u2264 1/log N + (1 / (2 * log N ^ ((1:\u211d) / 100)))*\u2211 q in (ppowers_in_set A0)\\E, 1/q :_\n       ... \u2264 1/log N + (1 / (2 * log N ^ ((1:\u211d) / 100)))*((501/500)*log(log N)) :_\n       ... \u2264 _ : 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 [\u2190 div_eq_mul_one_div], refine div_le_div_of_le_of_nonneg _ _, rw \u2190 not_lt,\n    intro nlt, rw mem_sdiff at hq, apply hq.2, rw mem_filter,\n    refine \u27e8(ppowers_in_set_subset (sdiff_subset _ _)) hq.1,le_of_lt nlt\u27e9,\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 : \u211d))/3 \u2264 rec_sum A0, {\n    calc _ \u2264 (rec_sum A :\u211d)/3 :_\n       ... \u2264 _ :_,\n    rw [div_le_div_right], exact hrecA, exact zero_lt_three,\n    rw [div_le_iff', \u2190 add_le_add_iff_left ((3:\u211d)*(rec_sum A2)),\n      \u2190 add_le_add_iff_left ((3:\u211d)*(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') :\u211d) \u2264 (log N)^(-(1/101 : \u211d))/6, {\n    calc _ = (rec_sum ((A0\\A')\\A_I) :\u211d) + rec_sum ((A0\\A')\u2229A_I) :_\n       ... \u2264 (rec_sum (A\\A_I) :\u211d) + rec_sum ((A0\\A')\u2229A_I) :_\n       ... \u2264 ((A\\A_I).card:\u211d)/M + rec_sum ((A0\\A')\u2229A_I) :_\n       ... \u2264 1/log N + rec_sum ((A0\\A')\u2229A_I) :_\n       ... \u2264 _ : hrecaux',\n    norm_cast, rw [\u2190 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', \u2190 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 \u27e8hn.1,_\u27e9,\n    intros x hx hnx, apply hn.2, rw mem_filter, refine \u27e8hn.1,x,hx,hnx\u27e9, exact h0M,\n  },\n\n  have hrecA' : (log N)^(-(1/101 : \u211d))/6 \u2264 rec_sum A', {\n    calc _ \u2264 (log N)^(-(1/101 : \u211d))/3 - (log N)^(-(1/101 : \u211d))/6 :_\n       ... \u2264 (rec_sum A0:\u211d) - (log N)^(-(1/101 : \u211d))/6 :_\n       ... \u2264 (rec_sum A0:\u211d) - rec_sum (A0\\A') :_\n       ... = _ :_,\n    rw [le_sub_iff_add_le, div_add_div_same, \u2190 mul_two, \u2190 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 [\u2190 rec_sum_disjoint, union_sdiff_of_subset], refine filter_subset _ _,\n    exact disjoint_sdiff,\n   },\n  have hA'size : M*((log N)^(-(1/101 : \u211d))/6) \u2264 (A').card, {\n    rw \u2190 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 : \u2203 x \u2208 I,  M*((log N)^(-(1/101 : \u211d))/6)/(I.card : \u211d) \u2264\n     (A'.filter(\u03bb n : \u2115, (n:\u2124) \u2223 x )).card, {\n       by_contra, rw \u2190 not_lt at hA'size, apply hA'size,\n       have hA'union : A' = I.bUnion( \u03bb x : \u2124, A'.filter( \u03bb n : \u2115, (n:\u2124) \u2223 x)), {\n         ext, refine \u27e8_,_\u27e9, intro hn, have hn' := hn, rw mem_bUnion,\n         rw [mem_filter, mem_filter] at hn, rcases hn.2.1.2 with \u27e8x,hx1,hx2\u27e9,\n         refine \u27e8x,hx1,_\u27e9, rw mem_filter, refine \u27e8hn',hx2\u27e9,\n         intro hn, rw mem_bUnion at hn, rcases hn with \u27e8x,hx1,hx2\u27e9, 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 : \u211d))/6)/(I.card : \u211d)) _ _) _,\n       intros x hx, rw \u2190 not_le, intro hnle, apply h, use x, refine \u27e8hx,hnle\u27e9,\n       rw [\u2190 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 \u27e8x, hx1, hx2\u27e9,\n  let m := nat.gcd (int.nat_abs x) (int.nat_abs ((f x1)*(f x2))),\n\n  have hmsmall : m \u2264 N^2, {\n      have hbadx' : \u2203 n \u2208 A', (n:\u2124) \u2223 x, {\n        have hA'temp : (A'.filter(\u03bb n : \u2115, (n:\u2124) \u2223 x )).nonempty, {\n          rw [\u2190 finset.card_pos, pos_iff_ne_zero], intro hz, rw hz at hx2, rw \u2190 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 \u27e8n,hn\u27e9, rw mem_filter at hn,\n      refine \u27e8n,hn.1,hn.2\u27e9,\n      },\n    rcases hbadx' with \u27e8ns,hns1,hns2\u27e9, 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 \u27e8hns3.1,hns2\u27e9,\n    intro hnetemp, rw hnetemp at hns2, apply hns3.2.2, refine \u27e8hns3.1,hns2\u27e9,\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(\u03bb n : \u2115, (n:\u2124) \u2223 x )).card \u2264 (\u03c3 0 m), {\n    rw divisor_function_eq_card_divisors, refine card_le_of_subset _,\n    intros n hn, rw nat.mem_divisors, refine \u27e8_,_\u27e9,\n    rw dvd_iff_ppowers_dvd', intros q hq1 hq2, rw nat.dvd_gcd_iff,\n    rw mem_filter at hn, refine \u27e8_,_\u27e9,\n    refine dvd_trans hq1 _, rw \u2190 int.coe_nat_dvd_left, exact hn.2,\n    specialize hfcopy q, rw \u2190 int.coe_nat_dvd_left, rw mem_filter at hn,\n    have : q \u2208 E, {\n      refine hn.1.2.2 q _ _, rw [ppowers_in_set, mem_bUnion],\n      use n, rw mem_filter,  refine \u27e8hn.1.1,_,hq2.1,hq2.2\u27e9, rw nat.mem_divisors,\n      refine \u27e8hq1,_\u27e9, 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 \u27e8hn.1.2.1,hq1,hq2.2\u27e9,\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(\u03bb n : \u2115, (n:\u2124) \u2223 x ) \u2286 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 \u2190 not_lt at hdiv, apply hdiv,\n  calc _ < M*((log N)^(-(1/101 : \u211d))/6)/(I.card : \u211d) : hlarge9\n    ... \u2264 ((A'.filter(\u03bb n : \u2115, (n:\u2124) \u2223 x )).card : \u211d) : hx2\n    ... \u2264 _ :_,\n  exact_mod_cast hdivm,\n  rw not_forall at hthreexs, rcases hthreexs with \u27e8x3,hx3\u27e9,\n  rw [not_imp, not_or_distrib] at hx3, specialize hfcopy3 x3 hx3.1, exfalso,\n  let S1 := \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x1)), (1:\u211d)/r,\n  let S2 := \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x2)), (1:\u211d)/r,\n  let S3 := \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x3)), (1:\u211d)/r,\n  have hsum1 :  3*c*log(log N) \u2264 S1 + S2 + S3, {\n      calc _ = c*log(log N) + c*log(log N) + c*log(log N) :_\n         ... \u2264 _ :_,\n      rw [\u2190 add_mul, \u2190 add_mul, mul_eq_mul_right_iff], left,\n      rw [\u2190 two_mul, \u2190 sub_eq_iff_eq_add', \u2190 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 := \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x2 \u2227 (n:\u2124)\u2223f x1)), (1:\u211d)/r,\n  let S23 := \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x3 \u2227 (n:\u2124)\u2223f x2)), (1:\u211d)/r,\n  let S13 := \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x3 \u2227 (n:\u2124)\u2223f x1)), (1:\u211d)/r,\n\n  have hsum2 : (S1+S2+S3) - (S12 + S23 + S13) \u2264 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,  \u2190 sub_sub, \u2190 sub_sub, add_tsub_cancel_right, sub_add_cancel,\n       sub_add_cancel, sub_le_iff_le_add],\n    calc _ \u2264 (ppower_rec_sum A : \u211d) :_\n       ... \u2264 _ :_,\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 \u2264 ((1:\u211d)/500+(1:\u211d)/500+(1:\u211d)/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 \u27e8m,hm1,hm2\u27e9,\n    rw finset.mem_filter at hm2,  refine \u27e8_,hm2.2.1,hr.2\u27e9, rw finset.mem_range,\n    apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw \u2190 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 \u27e8m,hm1,hm2\u27e9,\n    rw finset.mem_filter at hm2, refine \u27e8_,hm2.2.1,hr.2\u27e9, rw finset.mem_range,\n    apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw \u2190 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 \u27e8m,hm1,hm2\u27e9,\n    rw finset.mem_filter at hm2, refine \u27e8_,hm2.2.1,hr.2\u27e9, rw finset.mem_range,\n    apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw \u2190 finset.mem_range,\n    exact hA hm1, intros i hi1 hi2, rw one_div_nonneg, exact nat.cast_nonneg i,\n  },\n  have hsum5 : \u00ac  (501/500)*log(log N) < ((102:\u211d)/100)*log(log N) , {\n    rw not_lt,\n    calc _ \u2264 3*c*log(log N) - ((1:\u211d)/500+(1:\u211d)/500+(1:\u211d)/500)*log(log N) :_\n       ... \u2264 (S1+S2+S3) - (S12 + S23 + S13) :_\n       ... \u2264 (ppower_rec_sum A:\u211d) : hsum2\n       ... \u2264 _ : hsum4,\n    rw [\u2190 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,\u2190 sub_add, \u2190 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 \u27e8x,hx\u27e9, refine \u27e8x,hx,_\u27e9,\n  intros q hq, exfalso, apply hDne, use q, exact hq,\nend\n\n-- Proposition 6.4\ntheorem force_good_properties2 :\n  \u2200\u1da0 (N : \u2115) in at_top, \u2200 M : \u211d, \u2200 A \u2286 finset.range(N+1),\n  (0 < M) \u2192  (M \u2264 N) \u2192 ((N : \u211d) \u2264 M^2) \u2192 (0 \u2209 A) \u2192\n  (\u2200 n \u2208 A, M \u2264 (n:\u211d)) \u2192 arith_regular N A \u2192\n  (\u2200 q \u2208 ppowers_in_set A,\n    ((log N)^(-(1/100 : \u211d)) \u2264 rec_sum_local A q )) \u2192\n  ((ppower_rec_sum A : \u211d) \u2264 (2/3)* log(log N)) \u2192\n  good_condition A (M*(N : \u211d)^(-(2 : \u211d)/log(log N))) ((M : \u211d)/log N)\n  (M / (2*(log N)^(1/100 : \u211d)))\n :=\nbegin\n  let c := (35 : \u211d)/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 : \u211d)),\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:\u211d)/(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 \u2264 M*(N)^(-(2 : \u211d)/log(log N)), {\n    rw [neg_eq_neg_one_mul, \u2190 mul_div, \u2190 neg_eq_neg_one_mul, rpow_neg, \u2190 one_div,\n         \u2190 div_eq_mul_one_div, one_le_div],\n    calc _ \u2264 (N:\u211d)^((1:\u211d)/2) : _\n       ... \u2264 M :_,\n    apply rpow_le_rpow_of_exponent_le, exact_mod_cast le_of_lt hlarge,\n    rw [div_le_iff, \u2190 div_le_iff'], exact hlarge4, exact one_half_pos,\n    exact hlarge3, rw [\u2190 sqrt_eq_rpow, sqrt_le_iff],\n    refine \u27e8le_of_lt h0M, hNM\u27e9, 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)) \u2264 N, {\n    calc _ \u2264 M : _\n       ... \u2264 N : hMN,\n    nth_rewrite 1 \u2190 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 (\u03bb hP, _),\n  let A_I := A.filter((\u03bb (n : \u2115), \u2203 (x : \u2124), (n:\u2124) \u2223 x)),\n  let D := interval_rare_ppowers I A (M / (2 * log N ^ ((1 : \u211d) / 100))),\n  let K := (M / (2 * log N ^ ((1 : \u211d) / 100))),\n  by_cases hDne : D.nonempty,\n  rcases hDne with \u27e8x1,hx1\u27e9,\n  have hlocal : \u2200 q \u2208 D, \u2203 x \u2208 I, ((q:\u2124) \u2223x) \u2227\n   c*log(log N) \u2264 \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223x)), 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:\u211d) / 100))) A hA h0M hMA _ I q _,\n    intros q hq, rw [two_mul, one_div, \u2190 inv_div_left, add_halves, \u2190 rpow_neg],\n    exact hreclocal q hq, exact le_of_lt hlarge0, rw \u2190 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 \u27e8hf.1,_\u27e9, 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) \u2264 \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x1)), 1/r\n    +  \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f q)), 1/r, {\n      rw [two_mul, add_mul], apply add_le_add hf.2.2 hfcopy.2.2,\n     },\n  have hsum2 :\n       \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x1)), (1 : \u211d)/r\n    +  \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f q)), (1 : \u211d)/r\n    -  \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f q \u2227 (n:\u2124)\u2223f x1)), (1 : \u211d)/r\n    \u2264 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, \u2190 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    \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x1)), (1 : \u211d)/r\n    + \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f q)), (1 : \u211d)/r  - ppower_rec_sum A \u2264\n    \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f q \u2227 (n:\u2124)\u2223f x1)), (1 : \u211d)/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 : \u211d)/500)*log(log N) \u2264\n      \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f q \u2227 (n:\u2124)\u2223f x1)), (1 : \u211d)/r,\n    { refine le_trans _ hsum3, clear hsum3,\n      calc _ \u2264 2*c*log(log N) - ((2 : \u211d)/3)*log(log N) :_\n           ... \u2264 \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f x1)), (1 : \u211d)/r\n    +  \u2211 r in ((ppowers_in_set A).filter(\u03bb n, (n:\u2124)\u2223f q)), (1 : \u211d)/r  - ((2 : \u211d)/3)*log(log N) :_\n         ... \u2264 _ :_,\n      have hsilly : c = 35/100, { refl, },\n      rw [le_sub_iff_add_le, \u2190 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 : \u211d)-(f x1)| \u2264 N, {\n    apply @le_trans _ _ _ ((\u230at + M * N ^ ((-2) / log (log N)) / 2\u230b : \u211d)-\u2308t - M * N ^ ((-2) / log (log N)) / 2\u2309) N,\n    apply two_in_Icc, rw \u2190 hI, exact hfcopy.1, rw \u2190 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 : \u211d) t, rw \u2190 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 \u27e8m,hm1,hm2\u27e9,\n  rw finset.mem_filter at hm2,  refine \u27e8_,hm2.2.1,hr.2\u27e9, rw finset.mem_range,\n  apply @lt_of_le_of_lt _ _ r m _, apply nat.divisor_le hm2.1, rw \u2190 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,\u2190 sub_add, \u2190 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 \u27e8x,hx\u27e9, refine \u27e8x,hx,_\u27e9,\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 \u2115) (\u03b5 : \u211d) (i : \u2115) :\n  \u2203 A_i \u2286 A, \u2203 Q_i \u2286 ppowers_in_set A,\n  (disjoint Q_i (ppowers_in_set A_i)) \u2227\n  ((rec_sum A : \u211d) - \u03b5 * rec_sum Q_i \u2264 rec_sum A_i) \u2227\n  (i \u2264 (A \\ A_i).card \u2228 \u2200 q \u2208 ppowers_in_set A_i, \u03b5 < rec_sum_local A_i q) :=\nbegin\n  induction i with i ih,\n  { exact \u27e8A, finset.subset.rfl, \u2205, by simp\u27e9 },\n  obtain \u27e8A', hA', Q', hQ', hQA', hr, ih\u27e9 := ih,\n  by_cases hq : \u2200 q \u2208 ppowers_in_set A', \u03b5 < rec_sum_local A' q,\n  { exact \u27e8A', hA', Q', hQ', hQA', hr, or.inr hq\u27e9 },\n  obtain \u27e8q', hq', h4\u27e9 := not_ball.mp hq,\n  have hq'zero : q' \u2260 0 := ne_of_mem_of_not_mem hq' zero_not_mem_ppowers_in_set,\n  have hq'zero' : (q' : \u211a) \u2260 0 := by exact_mod_cast hq'zero,\n  let A'' := A'.filter (\u03bb n, \u00ac (q' \u2223 n \u2227 coprime q' (n / q'))),\n  refine \u27e8A'', (A'.filter_subset _).trans hA', _\u27e9,\n  let Q'' := insert q' Q',\n  have hq'' : q' \u2209 Q' := finset.disjoint_right.1 hQA' hq',\n  refine \u27e8Q'', _, _, _, _\u27e9,\n  { exact finset.insert_subset.2 \u27e8ppowers_in_set_subset hA' hq', hQ'\u27e9 },\n  { refine finset.disjoint_insert_left.2 \u27e8_, _\u27e9,\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'' : \u211d) = 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' : \u211a)],\n      rw [\u2190finset.mul_sum, mul_div_cancel_left _ hq'zero', add_comm, \u2190finset.sum_union, local_part,\n        finset.filter_union_filter_neg_eq],\n      exact finset.disjoint_filter_filter_neg _ _ },\n    have hrs3 : (rec_sum A' : \u211d) \u2264 rec_sum A'' + \u03b5 * (1 / q'),\n    { rw [\u2190hrs2a, 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 \u27e8x, hx\u2081, hx\u2082, hx\u2083, -, hx\u2085\u27e9 := hq',\n  refine \u27e8x, _\u27e9,\n  simp [hx\u2081, hx\u2082, hx\u2085, hA' hx\u2081],\nend\n\n\n\n-- Lemma 5.5\nlemma pruning_lemma_one :\n  \u2200\u1da0 (N : \u2115) in at_top, \u2200 A \u2286 finset.range (N + 1), \u2200 \u03b5 : \u211d, 0 < \u03b5 \u2192\n    \u2203 B \u2286 A,\n      ((rec_sum A : \u211d) - \u03b5 * 2 * log (log N) \u2264 rec_sum B) \u2227\n      (\u2200 q \u2208 ppowers_in_set B, \u03b5 < rec_sum_local B q) :=\nbegin\n  filter_upwards [explicit_mertens] with N hN A hA \u03b5 h\u03b5,\n  obtain \u27e8B, hB, Q, hQ, haux, h_recsums, h_local\u27e9 := pruning_lemma_one_prec A \u03b5 (A.card + 1),\n  refine \u27e8B, hB, _, _\u27e9,\n  { have hQu : Q \u2286 (finset.range (N + 1)).filter is_prime_pow,\n    { intros q hq,\n      rw [finset.mem_filter, finset.mem_range],\n      have hqA : q \u2208 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 \u27e8a, ha, hqa, hq', hq''\u27e9 := hqA,\n      exact \u27e8(nat.divisor_le hqa).trans_lt (finset.mem_range.1 (hA ha)), hq'\u27e9 },\n    have hQt : (rec_sum Q : \u211d) \u2264 \u2211 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  \u2200\u1da0 (N : \u2115) in at_top, \u2200 M \u03b1 \u03b5 : \u211d, \u2200 A \u2286 finset.range (N + 1),\n  0 < M \u2192 M < N \u2192 0 < \u03b5 \u2192 4 * \u03b5 * log (log N) < \u03b1 \u2192 (\u2200 n \u2208 A, M \u2264 \u2191n) \u2192 \u03b1 \u2264 rec_sum A \u2192\n  (\u2200 q \u2208 ppowers_in_set A, (q : \u211d) \u2264 \u03b5 * M \u2227 \u03b5 < rec_sum_local A q) \u2192\n  (\u2200 i : \u2115, \u2203 A_i \u2286 A,\n      (\u03b1 - 1 / M \u2264 rec_sum A_i) \u2227\n      (\u2200 q \u2208 ppowers_in_set A_i, \u03b5 < rec_sum_local A_i q) \u2227\n      (i \u2264 (A \\ A_i).card \u2228 (rec_sum A_i : \u211d) < \u03b1) )\n  :=\nbegin\n  filter_upwards [pruning_lemma_one] with N hN M \u03b1 \u03b5 A hA hM hMN h\u03b5 h\u03b5\u03b1 hMA hrec hsmooth i,\n  induction i with i ih,\n  { refine \u27e8A, subset.rfl, _, \u03bb q hq, (hsmooth _ hq).2, or.inl zero_le'\u27e9,\n    exact (sub_le_self _ (by simp only [hM.le, one_div, inv_nonneg])).trans hrec },\n  obtain \u27e8A_i, hA_i, ih1, ih2, ih3\u27e9 := ih,\n  by_cases hr : (rec_sum A_i : \u211d) < \u03b1,\n  { exact \u27e8A_i, hA_i, ih1, ih2, or.inr hr\u27e9 },\n  have hA_ir : A_i \u2286 finset.range (N + 1) := hA_i.trans hA,\n  let \u03b5' := 2 * \u03b5,\n  obtain \u27e8B, hB, hN1, hN2\u27e9 := hN A_i hA_ir \u03b5' (mul_pos zero_lt_two h\u03b5),\n  have ht0 : \u03b1 \u2264 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 * \u03b5 * log (log N) < \u03b5' * 2 * log (log N),\n    { exact h\u03b5\u03b1.trans_le (ht0.trans hN1), },\n    rw [mul_right_comm 2 \u03b5] at ht1,\n    linarith only [ht1] },\n  cases hBexists with x hx,\n  have hxA1 : x \u2208 A_i := hB hx,\n  have hxA2 : x \u2208 A := hA_i hxA1,\n  let A_i' := A_i.erase x,\n  have h3 : A_i' \u2286 A_i := erase_subset _ _,\n  refine \u27e8A_i', h3.trans hA_i, _, _, _\u27e9,\n  { have hrs2 : (rec_sum A_i : \u211d) - 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 \u2223 x \u2227 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 \u27e8hB hx, hxq\u27e9 },\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 \u2190 hlocal2,\n      push_cast,\n      have hppB : q \u2208 ppowers_in_set B,\n      { rw [ppowers_in_set, finset.mem_bUnion],\n        refine \u27e8x, hx, mem_filter.2 \u27e8nat.mem_divisors.2 \u27e8hxq.1, _\u27e9, (mem_ppowers_in_set.1 hq).1,\n          hxq.2\u27e9\u27e9,\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 : \u211d) \u2264 rec_sum_local A_i q :=\n        rat.cast_le.2 (rec_sum_local_mono hB),\n      have hll : \u03b5 + \u03b5 < rec_sum_local A_i q,\n      { rw \u2190two_mul \u03b5,\n        exact (hN2 q hppB).trans_le hlocal3 },\n      have hll2 : (q : \u211d) / x \u2264 \u03b5,\n      { rw (div_le_iff (hM.trans_le (hMA x hxA2))),\n        have hppA : ppowers_in_set A_i' \u2286 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\u03b5.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 \u2190hrecl,\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 \u2264 (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  \u2200\u1da0 (N : \u2115) in at_top, \u2200 M \u03b1 \u03b5: \u211d, \u2200 A \u2286 finset.range(N+1),\n  (0 < M) \u2192 (M < N) \u2192 (\u03b5 > 0) \u2192 (4*\u03b5*log(log N) < \u03b1 ) \u2192\n  (\u2200 n \u2208 A, M \u2264 (n: \u211d)) \u2192\n  (\u03b1 + 2*\u03b5*log(log N) \u2264 rec_sum A ) \u2192\n  (\u2200 q \u2208 ppowers_in_set A, (q : \u211d) \u2264 \u03b5*M) \u2192\n  \u2203 B \u2286 A, ( (rec_sum B : \u211d) < \u03b1) \u2227 ( \u03b1 - 1/M \u2264 rec_sum B) \u2227\n  (\u2200 q \u2208 ppowers_in_set B, \u03b5 <\n    rec_sum_local B q)\n  :=\nbegin\n  filter_upwards [pruning_lemma_one, pruning_lemma_two_ind],\n  intros N h h2 M \u03b1 \u03b5 A hA hMz hMN h\u03b5 h\u03b5\u03b1 hMA hrecA hsmooth,\n  rcases h A hA \u03b5 h\u03b5 with \u27e8A', hA', hA'1, hA'3\u27e9,\n  have hA'2 : A' \u2286 finset.range (N + 1) := hA'.trans hA,\n  have hMA' : \u2200 n \u2208 A', M \u2264 (n : \u211d) := \u03bb n hn, hMA n (hA' hn),\n  have hrecA' : \u03b1 \u2264 rec_sum A',\n  { refine (le_sub_right_of_add_le _).trans hA'1, rwa mul_comm \u03b5 2, },\n  have hsmooth2 : \u2200 q \u2208 ppowers_in_set A', \u2191q \u2264 \u03b5 * M \u2227 \u03b5 < rec_sum_local A' q :=\n    \u03bb q hq, \u27e8hsmooth q ((ppowers_in_set_subset hA') hq), hA'3 q hq\u27e9,\n  let i := A'.card + 1,\n  rcases h2 M \u03b1 \u03b5 A' hA'2 hMz hMN h\u03b5 h\u03b5\u03b1 hMA' hrecA' hsmooth2 i with \u27e8B, hB, h2, h3, ha\u27e9,\n  refine \u27e8B, hB.trans hA', ha.resolve_left (\u03bb ha1, _), h2, h3\u27e9,\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  \u2200\u1da0 (N : \u2115) in at_top, \u2200 M \u03b5 y w : \u211d, \u2200 A \u2286 finset.range (N + 1),\n    0 < M \u2192 M < N \u2192 0 < \u03b5 \u2192 w < 2 * M \u2192 1 / M < \u03b5 * log (log N) \u2192\n    1 \u2264 y \u2192 2 \u2264 w \u2192 \u2308y\u2309\u208a \u2264 \u230aw\u230b\u208a \u2192\n    (3 * \u03b5 * log (log N) \u2264 2 / w ^ 2) \u2192 (\u2200 n \u2208 A, M \u2264 (n : \u211d)) \u2192\n    (2 / y + 2 * \u03b5 * log (log N) \u2264 rec_sum A) \u2192\n    (\u2200 q \u2208 ppowers_in_set A, (q : \u211d) \u2264 \u03b5 * M) \u2192\n    (\u2200 n \u2208 A, \u2203 d : \u2115, y \u2264 d \u2227 (d : \u211d) \u2264 w \u2227 d \u2223 n) \u2192\n    (\u2200 i : \u2115, \u2203 A_i \u2286 A, \u2203 d_i : \u2115,\n      y \u2264 d_i \u2227 d_i \u2264 \u2308y\u2309\u208a + i \u2227 d_i \u2264 \u230aw\u230b\u208a \u2227\n      rec_sum A_i < 2 / d_i \u2227 (2 : \u211d) / d_i - 1 / M \u2264 rec_sum A_i \u2227\n      (\u2200 q \u2208 ppowers_in_set A_i, \u03b5 < rec_sum_local A_i q) \u2227\n      (\u2200 n \u2208 A_i, \u2200 k, k \u2223 n \u2192 k < d_i \u2192 (k : \u211d) < y) \u2227\n      ((\u2203 n \u2208 A_i, d_i \u2223 n) \u2228 (\u2200 n \u2208 A_i, \u2200 k, k \u2223 n \u2192 k \u2264 \u2308y\u2309\u208a + i \u2192 k \u2264 \u230aw\u230b\u208a \u2192 (k : \u211d) < y))) :=\nbegin\n  have : tendsto (\u03bb N : \u2115, 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 \u03b5 y w A hA hM hMN h\u03b5 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 \u2264 y + 1 := add_le_add_right hy 1,\n  have hobvaux : (\u2308y\u2309\u208a : \u211d) < 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 : (\u230aw\u230b\u208a : \u211d) \u2264 w := nat.floor_le hwzero.le,\n  have h\u03b5Naux : 4 * \u03b5 * log(log N) < 2 * (3 * \u03b5 * log (log N)),\n  { have h\u2081 : (4 : \u211d) < 2 * 3 := by norm_num1,\n    simpa only [mul_assoc] using (mul_lt_mul_right (mul_pos h\u03b5 h_largeN)).2 h\u2081 },\n  have h\u03b5Naux2 : 2 * (3 * \u03b5 * log (log N)) \u2264 2 * (2 / w ^ 2) := (mul_le_mul_left zero_lt_two).2 hNw,\n  have hwaux : 2 * w \u2264 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 \u03b1 := (2 : \u211a) / \u2308y\u2309\u208a,\n    have h\u03b1aux : (\u03b1 : \u211d) = 2 / \u2308y\u2309\u208a,\n    { rw [rat.cast_div, rat.cast_bit0, rat.cast_one, rat.cast_coe_nat] },\n    have h\u03b1 : 4 * \u03b5 * log (log N) < \u03b1,\n    { have h\u03b11 : 2 * ((2 : \u211d) / w ^ 2) \u2264 2 / \u2308y\u2309\u208a,\n      { rw [\u2190mul_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\u03b5Naux.trans_le (h\u03b5Naux2.trans h\u03b11) },\n    have hrec2 : (\u03b1 : \u211d) + 2 * \u03b5 * log (log N) \u2264 rec_sum A,\n    { rw h\u03b1aux,\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 \u03b1 \u03b5 A hA hM hMN h\u03b5 h\u03b1 hMA hrec2 hsmooth with \u27e8B, hB, hB', hB'', hN\u27e9,\n    refine \u27e8B, hB, _, nat.le_ceil y, le_rfl, hyw2, rat.cast_lt.1 hB', by rwa \u2190h\u03b1aux, hN,\n      \u03bb n hn k hk1 hk2, by rwa \u2190nat.lt_ceil, _\u27e9,\n    rw or_iff_not_imp_left,\n    intros hp n hn k hk1 hk2 hk3,\n    rw \u2190 nat.lt_ceil,\n    refine lt_of_le_of_ne hk2 _,\n    rintro rfl,\n    exact hp \u27e8n, hn, hk1\u27e9 },\n  -- The inductive case\n  rcases i_ih with \u27e8A_i, hA_i, d_i, hstock\u27e9,\n  obtain hstock1 := hstock.2.2.2.2.2.2.1,\n  by_cases hdiv2 : \u2203 n \u2208 A_i, d_i \u2223 n,\n  { exact \u27e8A_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\u27e9 },\n  let d_i' := min (\u2308y\u2309\u208a + i_n + 1) \u230aw\u230b\u208a,\n  have hd_i' : d_i + 1 \u2264 d_i',\n  { rw le_min_iff,\n    refine \u27e8add_le_add_right hstock.2.1 _, lt_of_le_of_ne hstock.2.2.1 _\u27e9,\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 \u27e8x, hx\u27e9 := 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 \u27e8x, hx, hdiv.2.2\u27e9 },\n  let \u03b1' := (2 : \u211a) / d_i',\n  have h\u03b1'aux : (\u03b1' : \u211d) = 2 / d_i', by push_cast,\n  have hqaux' : (d_i' : \u211d) \u2264 \u230aw\u230b\u208a := nat.cast_le.2 (min_le_right _ _),\n  have hqaux'' : (d_i' : \u211d) \u2264 w := hqaux'.trans hqaux,\n  have hrec5'''aux : (0 : \u211d) < d_i := hy01.trans_le hstock.1,\n  have hrec5''' : 0 < d_i := nat.cast_pos.1 hrec5'''aux,\n  have hqauxx : (1 : \u211d) < d_i' := nat.one_lt_cast.2 ((nat.succ_lt_succ hrec5''').trans_le hd_i'),\n  have h\u03b1' : 4 * \u03b5 * log (log N) < \u03b1',\n  { have h\u03b1'1 : 2 * ((2 : \u211d) / w ^ 2) \u2264 2 / d_i',\n    { rw [\u2190mul_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\u03b1'aux,\n    exact h\u03b5Naux.trans_le (h\u03b5Naux2.trans h\u03b1'1) },\n  have hrec2 : (\u03b1' : \u211d) + 2 * \u03b5 * log (log N) \u2264 rec_sum A_i,\n  { rw h\u03b1'aux,\n    have hrec3p : (d_i : \u211d) \u2264 d_i' - 1,\n    { rwa [le_sub_iff_add_le, \u2190nat.cast_add_one, nat.cast_le] },\n    have hrec3 : (2 : \u211d) / (d_i' - 1) - 1 / M \u2264 rec_sum A_i,\n    { have hrec3' : (2 : \u211d) / (d_i' - 1) \u2264 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 : \u211d)/d_i'^2 \u2264 2/(d_i'-1) - 2/d_i',\n    { rw div_sub_div,\n      have hrec5'' : ((d_i' : \u211d) - 1) * d_i' = d_i' ^ 2 - d_i',\n      { rw [sub_mul, sq, one_mul] },\n      have hrec5' : (2 : \u211d) * 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 \u2190 pow_one (d_i' : \u211d),\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 : \u211d)/w^2 \u2264 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 \u2286 finset.range(N+1),\n  { exact finset.subset.trans hA_i hA, },\n  have hMA' : (\u2200 (n : \u2115), n \u2208 A_i \u2192 M \u2264 n), {\n    intros n hn, have haux9 : n \u2208 A, { exact hA_i hn, },\n    exact hMA n haux9,\n      },\n  have hsmooth' : (\u2200 q \u2208 ppowers_in_set A_i, (q : \u211d) \u2264 \u03b5*M), {\n    intros q hq,\n    have hpp' : ppowers_in_set A_i \u2286 ppowers_in_set A,\n    { exact ppowers_in_set_subset hA_i, },\n    have hq' : q \u2208 ppowers_in_set A, { exact hpp' hq, },\n    exact hsmooth q hq',},\n  specialize hN M \u03b1' \u03b5 A_i hA_i' hM hMN h\u03b5 h\u03b1' hMA' hrec2 hsmooth',\n  rcases hN with \u27e8B, hB, hN\u27e9,\n  use B, split, exact finset.subset.trans hB hA_i,\n  use d_i', split, rw \u2190 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 \u2190 h\u03b1'aux, exact hN.2.1, split, exact hN.2.2,\n  split,\n  intros n hn k hk1 hk2,\n  have hn2 : n \u2208 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 \u2264 \u2308y\u2309\u208a + i_n, { rw lt_min_iff at hk2,\n  apply nat.le_of_lt_succ hk2.1, },\n  have hk2'' : k \u2264 \u230aw\u230b\u208a, { 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 : (\u2203 (n : \u2115) (H : n \u2208 B), d_i' \u2223 n),\n  left, exact hd_i'div, right,\n  intros n hn k hk1 hk2 hk3,\n  have hn2 : n \u2208 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 \u2264 d_i', { rw le_min_iff, split,\n   exact hk2, exact hk3, },\n  have hk2'' : k < d_i', {\n   rw \u2190 ne.le_iff_lt, exact hk2', intro hkaux4,\n   apply hd_i'div, use n, split, exact hn,\n   rw \u2190 hkaux4, exact hk1, },\n  have hk2''' : k \u2264 \u2308y\u2309\u208a + i_n, { rw lt_min_iff at hk2'',\n    apply nat.le_of_lt_succ hk2''.1, },\n  have hk2'''' : k \u2264 \u230aw\u230b\u208a, {\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  \u2200\u1da0 (N : \u2115) in at_top, \u2200 M \u03b5 y w : \u211d, \u2200 A \u2286 finset.range(N+1),\n  (0 < M) \u2192 (M < N) \u2192 (0 < \u03b5) \u2192 (2*M > w) \u2192 (1/M < \u03b5*log(log N)) \u2192\n  (1 \u2264 y) \u2192 (2 \u2264 w) \u2192 (\u2308y\u2309\u208a \u2264 \u230aw\u230b\u208a) \u2192\n  (3*\u03b5*log(log N) \u2264 2/(w^2)) \u2192 (\u2200 n \u2208 A, M \u2264 (n: \u211d)) \u2192\n  (2/y + 2*\u03b5*log(log N) \u2264 rec_sum A ) \u2192\n  (\u2200 q \u2208 ppowers_in_set A, (q : \u211d) \u2264 \u03b5*M) \u2192\n  (\u2200 n \u2208 A, \u2203 d : \u2115, (y \u2264 d) \u2227 ((d : \u211d) \u2264 w) \u2227 d \u2223 n) \u2192\n  (\u2203 A' \u2286 A, \u2203 d : \u2115, A' \u2260 \u2205 \u2227 (y \u2264 d) \u2227 ((d : \u211d) \u2264 w) \u2227 rec_sum A' < 2/d \u2227\n  (2 : \u211d)/d-1/M \u2264 rec_sum A' \u2227 (\u2200 q \u2208 ppowers_in_set A', \u03b5 < rec_sum_local A' q)\n  \u2227 (\u2203 n \u2208 A', d \u2223 n) \u2227 (\u2200 n \u2208 A', \u2200 k : \u2115, k \u2223 n \u2192 k < d \u2192 (k : \u211d) < y))\n  :=\nbegin\n  have : tendsto (\u03bb N : \u2115, 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 \u03b5 y w A hA hM hMN h\u03b5 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 \u2264 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 := \u230aw\u230b\u208a - \u2308y\u2309\u208a,\n specialize hN M \u03b5 y w A hA hM hMN h\u03b5 hMw hMN2 hy h2w hyw hNw hAM hrec hsmooth hdiv i,\n rcases hN with \u27e8A', hA', d, hN\u27e9,\n use A', split, exact hA', use d,\n have hdw : (d : \u211d) \u2264 w, {\n   have hauxw : (\u230aw\u230b\u208a : \u211d) \u2264 w, { apply nat.floor_le (le_of_lt hwzero), },\n  have hauxw2 : (d : \u211d) \u2264 (\u230aw\u230b\u208a : \u211d), {exact nat.cast_le.mpr hN.2.2.1, },\n  exact hauxw2.trans hauxw,\n  },\n have hA'ne : A' \u2260 \u2205, {\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 : \u211d)/d \u2264 1/M, { apply sub_nonpos.mp hN.2.2.2.2.1, },\n have haux2 : (2 : \u211d)/w \u2264 2/d,\n { refine div_le_div_of_le_left zero_le_two _ _,\n   apply @lt_of_lt_of_le _ _ 0 y (d : \u211d), exact hy01, exact hN.1, exact hdw,\n   },\n have haux3 : (2 : \u211d)/w^2 \u2264 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*\u03b5*log(log N) < \u03b5*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\u03b5, 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 : \u2203 (x : \u2115), x \u2208 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 \u2208 A, {exact hA' hx,},\n specialize hdiv x hx2, cases hdiv with m hdiv,\n have htempw : m \u2264 \u230aw\u230b\u208a, {\n   apply nat.le_floor, exact hdiv.2.1,\n  },\n have htemp : m \u2264 \u2308y\u2309\u208a + i, {\n   have hobvious : \u2308y\u2309\u208a + i = \u230aw\u230b\u208a, {\n     rw \u2190 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 : (\u2200\u1da0 (N : \u2115) in at_top,\n  (N : \u211d) ^ (1 - (8 : \u211d) / log (log N)) \u2264\n   ((N : \u211d) ^ (1 - (1 : \u211d) / log (log N)) / (2 * log N ^ ((1 : \u211d) / 100))) *\n     (((N : \u211d) ^ (1 - (3 : \u211d)/ log (log N)))) ^ 2 / (16 * N ^ 2 * log N ^ 2)) :=\nbegin\n  have haux4: asymptotics.is_O_with ((1 : \u211d) / (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 : \u211d) / ((2 * (2 + 1 / 100)) ^ ((1 : \u211d) / 2))) at_top log\n     (\u03bb x, x^((1 : \u211d) / 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 : \u211d))),\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 : \u211d) < N, { rw nat.one_lt_cast, refine le_trans _ hN3, norm_num1, },\n  have hN6 : (0 : \u211d) < 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) \u2264 log N,\n  { rwa [norm_of_nonneg hN7.le, id.def, norm_of_nonneg hN8.le, mul_comm,\n      \u2190div_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 : \u211d) / 2) * log (log N) \u2264 log N ^ ((1 : \u211d) / 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, \u2190 le_div_iff (rpow_pos_of_pos _ _)],\n    exact hN3new5,\n    norm_num1 },\n  rw le_div_iff,\n  convert_to 16 * ((N : \u211d)^(1 - (8 : \u211d)/(log(log N))) * (N ^ 2)) * (log N) ^ 2 \u2264\n    ((\u2191N ^ (1 - 3 / log (log \u2191N))) ^ 2 * (N : \u211d)^(1 - (1 : \u211d)/(log(log N)))) /\n    (2 * (log N)^((1/100 : \u211d)))\n    using 0,\n    { ring_nf, },\n  rw [le_div_iff, \u2190 rpow_two, \u2190 rpow_two, \u2190 rpow_two, \u2190 rpow_add, \u2190 rpow_mul, \u2190 rpow_add],\n  convert_to (2 * 16) * (log N ^ (2 : \u211d) * log N ^ (1 / 100 : \u211d)) * (N : \u211d) ^ (1 - 8 / log (log N) + 2)\n    \u2264 (N : \u211d) ^ ((1 - 3 / log (log N)) * 2 + (1 - 1 / log (log N))) using 0,\n    { ring_nf,},\n  rw [\u2190 le_div_iff, \u2190 rpow_sub, \u2190 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, \u2190 log_le_log, log_rpow, log_mul, log_rpow],\n  nth_rewrite 2 mul_comm,\n  rw [\u2190 div_eq_mul_one_div, le_div_iff, add_mul, mul_assoc, \u2190 sq],\n  apply @le_trans _ _ _ ((1/2)*(log N)+(1/2)*(log N)) _,\n  apply add_le_add,\n  rwa [\u2190 mul_le_mul_left (zero_lt_two : (0 : \u211d) < 2), \u2190 mul_assoc, \u2190 mul_assoc, mul_one_div_cancel,\n    one_mul],\n  exact two_ne_zero,\n  rw [\u2190 mul_le_mul_left (@zero_lt_two \u211d _ _), \u2190 mul_assoc, \u2190 mul_assoc, mul_one_div_cancel,\n   one_mul, \u2190 rpow_two, \u2190 real.sqrt_le_sqrt_iff, real.sqrt_eq_rpow, real.sqrt_eq_rpow,\n   real.mul_rpow, \u2190 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 : \u2200 (c: \u211d), (c > 0) \u2192 \u2200\u1da0 (N : \u2115) in at_top,\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 c*(N : \u211d)^(1 - (1 : \u211d)/(log(log N)))/(log N)^((1/500 : \u211d)) \u2227\n  (log N)^(-(1/101 : \u211d)) \u2264 (2 : \u211d)/((log N)^(1/500 : \u211d)/4) - 1/ (N : \u211d)^(1 - (1 : \u211d)/(log(log N)))\n  :=\nbegin\n  intros c hc,\n  have haux: asymptotics.is_O_with ((1 : \u211d)) at_top (\u03bb (x : \u211d), (log x))\n     (\u03bb (x : \u211d), x^((1 : \u211d)/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 : \u211d)) at_top (\u03bb (x : \u211d), (log x))\n     (\u03bb (x : \u211d), x^((1 : \u211d))), {\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 : \u211d)), 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 : \u211d) < N, { norm_cast, refine le_trans _ hN3, norm_num1, },\n  have hN6 : (0 : \u211d) < 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) \u2264 (log N)^((1 : \u211d)/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 \u2264 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, \u2190 le_div_iff, \u2190 mul_div, \u2190 rpow_sub],\n  have : 1 - 1 / log (log N) - (1 - 8 / log (log N)) = 7/log(log N) := by ring,\n  rw [this, \u2190 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) \u2264 log c, {\n    rw [neg_mul, \u2190 neg_le, \u2190 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, \u2190 add_mul, add_sub, add_comm,\n    \u2190 add_sub, sub_self, add_zero], nth_rewrite 1 mul_comm,\n  rw [\u2190 mul_div, mul_le_mul_left, le_div_iff, \u2190 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 : \u211d)/((log N)^(1/500 : \u211d))) _,\n  rw [le_div_iff, \u2190 rpow_add], apply @le_trans _ _ _ (1 : \u211d) _,\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 : \u211d)^(((1 : \u211d)/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  :  \u2200 (c: \u211d), (c > 0) \u2192 \u2200\u1da0 (N : \u2115) in at_top,\nlet M := (N : \u211d)^(1 - (1 : \u211d)/(log(log N))), L := M / (2 * log N ^ ((1 : \u211d)/100)),\n    T := M / log N, \u03b5 := (N : \u211d)^(-(5 : \u211d)/(log(log N))),\n    \u03b5' := (log N)^(-(1/100 : \u211d)), K := (N : \u211d)^(1 - (3 : \u211d)/(log(log N)))  in\n  (\u03b5 \u2264 \u03b5') \u2192\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264  \u03b5'*M \u2227\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 (L * K ^ 2 / (16 * N ^ 2 * log N ^ 2)) \u2227\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 (T * K ^ 2 / (N ^ 2 * log N)) \u2227\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 c*M/(log N)^((1/500 : \u211d)) \u2227\n  (log N)^(-(1/101 : \u211d)) \u2264 (2 : \u211d)/((log N)^(1/500 : \u211d)/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 : \u211d))), 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 : \u211d) < N, { norm_cast, refine le_trans _ hN3, norm_num1, },\n  have hN6 : (0 : \u211d) < 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 [\u2190 div_le_iff, \u2190 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) \u2264 (-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 \u2191N ^ ((1 : \u211d)/100)),div_eq_mul_inv _ (log N)],\n  convert_to (((N : \u211d)^(1 - (1 : \u211d)/log(log N)))*((N : \u211d)^(1 - (3 : \u211d)/log(log N)))^2*(N : \u211d)^2)*((2*(log N)^((1 : \u211d)/100))\u207b\u00b9*(log N))\n       \u2264  (((N : \u211d)^(1 - (1 : \u211d)/log(log N)))*((N : \u211d)^(1 - (3 : \u211d)/log(log N)))^2*(N : \u211d)^2)*((log N)\u207b\u00b9*16*(log N)^2) using 0,\n       { ring_nf, },\n  rw [mul_le_mul_left, \u2190 rpow_neg_one, \u2190 rpow_neg_one,\n      mul_comm ((log N)^(-(1 : \u211d))) 16, mul_assoc, \u2190 rpow_two, \u2190 rpow_add], norm_num1,\n  rw [rpow_one, mul_le_mul_right, rpow_neg_one, inv_le],\n  apply @le_trans _ _ _ (2 : \u211d) _, norm_num1,\n  rw [\u2190 mul_one (2 : \u211d), 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  :  \u2200 (c: \u211d), (c > 0) \u2192 \u2200\u1da0 (N : \u2115) in at_top,\nlet M := (N : \u211d)^(1 - (1 : \u211d)/(log(log N))), L := M / (2 * log N ^ ((1 : \u211d)/100)),\n    T := M / log N, \u03b5 := (N : \u211d)^(-(5 : \u211d)/(log(log N))),\n    \u03b5' := (log N)^(-(1/100 : \u211d)), K := (N : \u211d)^(1 - (3 : \u211d)/(log(log N)))  in\n 1/M < \u03b5*log(log N) \u2227 0 < \u03b5 \u2227 (N : \u211d) \u2264 M^(2 : \u211d) \u2227 M < N \u2227 0 < M \u2227 (0 : \u211d) < log N \u2227\n 8 \u2264 K \u2227 K < M \u2227 (log N)^((1/500 : \u211d)) < 2*M \u2227\n  2*\u03b5*log(log N) \u2264 (log N)^(-(1/200 : \u211d)) \u2227\n  3*\u03b5*log(log N) \u2264 2 / ((log N)^((1/500 : \u211d)))^2 \u2227\n  3 * (2 * \u03b5' * log (log \u2191N)) + 1 / M \u2264 (1/(2*(log N)^((1/500 : \u211d)))) \u2227\n  (log N)^((1/500 : \u211d)) \u2264 M/192  \u2227 1/M < \u03b5'*log(log N) \u2227\n  3*\u03b5'*log(log N) \u2264 2/((log N)^((1/500 : \u211d)))^2 \u2227\n   2*\u03b5'*log(log N) \u2264 (log N)^(-(1/200 : \u211d)) \u2227\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264  \u03b5'*M \u2227\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 (L * K ^ 2 / (16 * N ^ 2 * log N ^ 2)) \u2227\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 (T * K ^ 2 / (N ^ 2 * log N)) \u2227\n  (N : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 c*M/(log N)^((1/500 : \u211d)) \u2227\n  (log N)^(-(1/101 : \u211d)) \u2264 (2 : \u211d)/((log N)^(1/500 : \u211d)/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 : \u211d)/24) at_top (\u03bb (x : \u211d), (log x))\n     (\u03bb (x : \u211d), x^((1 : \u211d)/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 : \u211d)/3) at_top (\u03bb (x : \u211d), (log x))\n     (\u03bb (x : \u211d), x^((3 : \u211d)/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 : \u211d)/2) at_top (\u03bb (x : \u211d), (log x))\n     (\u03bb (x : \u211d), x^((1 : \u211d)/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 : \u211d))), 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 : \u211d) < N, { norm_cast, refine le_trans _ hN3, norm_num1, },\n  have hN6 : (0 : \u211d) < 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) \u2264 (log N)^(1/125 : \u211d), {\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, \u2190 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) \u2264 (2/3)*(log N)^(3/500 : \u211d), {\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) \u2264 (log N)^(1/200 : \u211d), {\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, \u2190 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 : \u211d) < 500 := by norm_num1,\n  have h5002 : (0 : \u211d) < 500/2 := by norm_num1,\n    have hTp : 192*(log N)^((1/500 : \u211d)) < (N : \u211d)^(1 - (1 : \u211d)/(log(log N))),\n  { have : 192*(log N)^((1/500 : \u211d)) \u2264 (log N)^((1/500 : \u211d))*(log N)^((1/500 : \u211d)),\n    { apply mul_le_mul, rw \u2190 (real.rpow_le_rpow_iff _ _ h500), rw \u2190 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 \u2190 rpow_add, rw \u2190 (real.rpow_lt_rpow_iff _ _ h5002),\n   rw \u2190 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 : \u211d)), rw \u2190 rpow_mul, nth_rewrite 0 \u2190 (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,\u2190 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 : \u211d) < (N : \u211d)^(1 - (1 : \u211d)/(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 : \u211d) < (N : \u211d)^(1 - (1 : \u211d)/(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, \u2190 mul_assoc],\n  apply one_lt_mul, rw \u2190 real.rpow_add, apply real.one_le_rpow (le_of_lt hN5),\n  rw [sub_add, \u2190 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 \u2190 rpow_mul, nth_rewrite 0 \u2190 (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 \u2190 (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 : \u211d)^((1 : \u211d)/2)) _,\n  rw \u2190 (real.rpow_le_rpow_iff _ _ zero_lt_two), rw \u2190 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 \u03b5 := (N : \u211d)^(-(5 : \u211d)/(log(log N))),\n  let \u03b5' := (log N)^(-(1/100 : \u211d)),\n have hT1 :   3*\u03b5'*log(log N) \u2264 2/((log N)^((1/500 : \u211d)))^2, {\n  rw [le_div_iff, \u2190 real.rpow_two, \u2190 rpow_mul, mul_comm, \u2190 mul_assoc,\n    \u2190 mul_assoc, mul_comm ((log N)^((1/500 : \u211d)*2)),\n    mul_assoc 3 ((log N)^((1/500 : \u211d)*2)), \u2190 rpow_add], norm_num1,\n    rw [mul_comm, \u2190 mul_assoc, \u2190 le_div_iff, mul_comm, div_eq_mul_one_div, one_div,\n      \u2190 real.rpow_neg, neg_neg, \u2190 le_div_iff', div_eq_mul_one_div, mul_comm, \u2190 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*\u03b5'*log(log N) \u2264 (log N)^(-(1/200 : \u211d)), {\n   rw [real.rpow_neg, \u2190 one_div, le_div_iff, mul_comm, \u2190 mul_assoc,\n   \u2190 mul_assoc, mul_comm ((log N)^((1/200 : \u211d))),\n   mul_assoc 2 ((log N)^((1/200 : \u211d))), \u2190 rpow_add], norm_num1,\n   rw [mul_comm, \u2190 mul_assoc, \u2190 le_div_iff, one_div,\n      \u2190 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 : \u03b5 \u2264 \u03b5', {\n   rw [\u2190 one_div_le_one_div, one_div, one_div, \u2190 rpow_neg, neg_neg, \u2190 rpow_neg,\n     \u2190 neg_div, neg_neg, \u2190 log_le_log, log_rpow, log_rpow],\n     nth_rewrite 1 mul_comm, rw [mul_div, mul_comm, \u2190 div_eq_mul_one_div,\n    div_le_div_iff],\n    apply @le_trans _ _ _ ((2/3)*(log N)^((3/500 : \u211d))*(2/3)*(log N)^((3/500 : \u211d))) _,\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 : \u211d)))*((log N)^((3/500 : \u211d))))*((2/3)*(2/3)) \u2264\n     (log N)*(5*100) using 0,\n     { ring_nf, },\n    apply mul_le_mul, rw \u2190 rpow_add, nth_rewrite 1 \u2190 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 : \u211d)))+(1/(4*(log N)^((1/500 : \u211d)))))) _,\n apply add_le_add, rw [le_div_iff],\n convert_to (3 * 2 * 4) * (\u03b5' * (log N)^((1/500 : \u211d))) *  log (log N) \u2264 1 using 0,\n   { ring_nf, }, norm_num1, rw \u2190 rpow_add, norm_num1, rw [mul_comm, \u2190 mul_assoc],\n   rw \u2190  le_div_iff, nth_rewrite 0 one_div,\n   rw [\u2190 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 [\u2190 two_mul, mul_div, div_le_div_iff, mul_one, one_mul, \u2190 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 : \u211d)) < (N : \u211d)^(1 - (1 : \u211d)/(log(log N))),\n  { have : (0 : \u211d) < 100 := by norm_num1,\n   rw \u2190 (real.rpow_lt_rpow_iff _ _ this),\n   rw \u2190 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 : \u211d)), rw \u2190 rpow_mul, nth_rewrite 0 \u2190 (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,\u2190 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, \u2190 div_lt_iff'], nth_rewrite 0 one_div,\n   rw [\u2190 real.rpow_neg_one, \u2190 rpow_mul], norm_num1, apply lt_trans hTq,\n   nth_rewrite 0 \u2190 one_mul ((N : \u211d)^(1 - (1 : \u211d)/(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 \u27e8hT1, hT2, hotheraux hT3\u27e9,\nend\n\n-- Proposition 6.6\ntheorem technical_prop :\n  \u2200\u1da0 (N : \u2115) in at_top, \u2200 (A \u2286 finset.range (N+1)) (y z : \u211d),\n  (1 \u2264 y) \u2192 (4*y + 4 \u2264 z) \u2192 (z \u2264 (log N)^((1/500 : \u211d))) \u2192 (0 \u2209 A)\n  \u2192 (\u2200 n \u2208 A, ( (N : \u211d)^(1 - (1 : \u211d)/(log(log N))) \u2264 n ))\n  \u2192 2 / y + (log N)^(-(1/200 : \u211d)) \u2264 rec_sum A\n  \u2192 (\u2200 n \u2208 A, \u2203 d\u2081 d\u2082 : \u2115, (d\u2081 \u2223 n) \u2227 (d\u2082 \u2223 n) \u2227 (y \u2264 d\u2081) \u2227 (4*d\u2081 \u2264 d\u2082) \u2227 ((d\u2082 : \u211d) \u2264 z) )\n  \u2192 (\u2200 n \u2208 A, is_smooth ((N : \u211d)^(1 - (8 : \u211d)/(log(log N)))) n)\n  \u2192 arith_regular N A\n  \u2192 \u2203 S \u2286 A, \u2203 d : \u2115, (y \u2264 d) \u2227 ((d : \u211d) \u2264 z) \u2227\n    rec_sum S = 1/d\n  :=\nbegin\n  obtain \u27e8c,hc,circle_method\u27e9 := 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 : \u211d)^(1 - (1 : \u211d)/(log(log N))),\n  let \u03b5 := (N : \u211d)^(-(5 : \u211d)/(log(log N))),\n  let K := (N : \u211d)^(1 - (3 : \u211d)/(log(log N))),\n  let \u03b7 := (1 : \u211d)/(2*(log N)^((1 : \u211d)/100)),\n  let L := M / (2 * log N ^ ((1 : \u211d)/100)),\n  let T := M / log N,\n  rcases hlargeN with \u27e8hM\u03b5, h\u03b5, hM3, hM2, hM1, hlogN3, heK, hKM, hlogN4,\n     hlogN5, hlogN6, hlargeNnew, hlargenew2, h\u03b5'M, hlarge3, hlarge4, h\u03b5\u03b5'M,\n     hUhelper, hUhelper2, hUhelper3, hlarge7\u27e9,\n  have hNMcast : (N:\u211d) \u2264 M^2, { rw \u2190 rpow_nat_cast, exact_mod_cast hM3, },\n  have hM2aux : M \u2264 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 : \u211d)^(1 - (1 : \u211d)/(log(log N)))*(N : \u211d)^(-(2 : \u211d)/(log(log N))) = K, {\n    rw \u2190 rpow_add,\n    have : 1 - (1 : \u211d)/(log(log N))+(-(2 : \u211d)/(log(log N))) = 1 - (3 : \u211d)/(log(log N)),\n     { rw [sub_add_eq_add_sub, \u2190 add_sub, div_sub_div_same, sub_eq_add_neg,\n           sub_eq_add_neg, \u2190 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 \u2264 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 \u2264 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 \u2264 z/4, { rw le_div_iff, norm_num1,\n     exact h8z, exact zero_lt_four,  },\n  have hyz' : \u2308y\u2309\u208a \u2264 \u230az/4\u230b\u208a, {\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) (\u230az/4\u230b\u208a.succ) _,\n    apply le_of_lt, apply nat.lt_succ_floor, rw nat.succ_eq_add_one,\n    push_cast,\n   },\n  let \u03b5' := (log N)^(-(1/100 : \u211d)),\n  have h0\u03b5' : 0 < \u03b5' := by apply rpow_pos_of_pos hlogN3,\n  have h\u03b5'w2 : 3*\u03b5'*log(log N) \u2264 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\u03b5'z : 3*\u03b5'*log(log N) \u2264 2/((z/4)^2), {\n    have h\u03b5zaux : (z/4)^2 \u2264 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\u03b5zaux2 : 0 < (log N)^((1/500 : \u211d)), {\n      apply rpow_pos_of_pos hlogN3, },\n    apply le_trans h\u03b5'w2, rw div_le_div_iff, rw mul_le_mul_left,\n    apply le_trans h\u03b5zaux, 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*\u03b5'*log(log N) \u2264 rec_sum A, {\n    apply le_trans _ hrec, apply add_le_add, refl, exact hlarge4, },\n  have hsmooth' : \u2200 q \u2208 ppowers_in_set A, (q : \u211d) \u2264 \u03b5'*M, {\n    intros q hq, rw [ppowers_in_set,finset.mem_bUnion] at hq,\n    rcases hq with \u27e8a,ha,hq\u27e9, 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\u03b5\u03b5'M,\n    apply hsmooth (nat.dvd_of_mem_divisors hq.1),\n      },\n  have hdiv' : (\u2200 n \u2208 A, \u2203 d : \u2115, (y \u2264 d) \u2227 ((d : \u211d) \u2264 (z/4)) \u2227 d \u2223 n),\n   { intros n hn, specialize hdiv n hn, rcases hdiv with \u27e8d_1,d_2,hdiv\u27e9,\n     refine \u27e8d_1,hdiv.2.2.1,_,hdiv.1\u27e9, 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 \u03b5' y (z/4) A hA hM1 hM2 h0\u03b5' hwM h\u03b5'M h1y h2z hyz' h\u03b5'z\n      hA2 hrec' hsmooth' hdiv',\n  rcases htechlemma with \u27e8A',hA',d,htech\u27e9,\n  have hzd : d \u2260 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 : (\u2203 B \u2286 A', ((rec_sum A') \u2264 3*rec_sum B) \u2227\n    ((ppower_rec_sum B : \u211d) \u2264 (2/3)* log(log N))),\n  -- The first case\n  clear hforce1,\n  rcases hgoodsubset with \u27e8B, hB, hrecB, hppB\u27e9,\n  have hB2 : B \u2286 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 \u2264 ((4 : \u211d)*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 \u2264 z, { apply le_trans _ h8z, norm_num1, },\n  have hdz : \u2308(4 : \u211d)*d\u2309\u208a \u2264 \u230az\u230b\u208a, {\n    rw nat.ceil_le, norm_cast, rw nat.le_floor_iff',\n    have : (4 : \u211d)*d \u2264 z, {\n      rw \u2190 le_div_iff', exact htech.2.2.1, exact zero_lt_four,},\n    exact_mod_cast this, refine ne_of_gt _,\n    have : (0 : \u211d) < 4*d , { apply lt_of_lt_of_le zero_lt_one h14d, },\n    exact_mod_cast this,\n   },\n  have hB3 : \u2200 (n:\u2115), n \u2208 B \u2192 M \u2264 n, { intros n hn,\n  specialize hA2 n, apply hA2 (hA' (hB hn)), },\n  have hrecB : 2/((4 : \u211d)*d) + 2*\u03b5'*log(log N) \u2264 rec_sum B, {\n    have : (3 : \u211d)*(2/(4*d)) = (3/2)/d, {\n        rw [div_mul_eq_div_mul_one_div, \u2190 mul_assoc],\n        rw div_eq_mul_one_div ((3 : \u211d)/2) d, norm_num1, refl,\n     },\n    refine (mul_le_mul_left zero_lt_three).mp _,\n    apply @le_trans _ _ _ (rec_sum A' : \u211d) (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 : \u211d)/(2*z)) ((2-3/2)/d),\n    apply @le_trans _ _ _ (1/(2*(log N)^((1/500 : \u211d)))) ((1 : \u211d)/(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 \u2190 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 : \u2200 q \u2208 ppowers_in_set B, (q : \u211d) \u2264 \u03b5'*M, {\n    intros q hq, specialize hsmooth' q,\n    apply hsmooth' ((ppowers_in_set_subset (subset_trans hB hA')) hq),\n  },\n  have hdivB : (\u2200 (n : \u2115), n \u2208 B \u2192 (\u2203 (d_1 : \u2115), (4 : \u211d)*d \u2264 d_1 \u2227 (d_1 : \u211d) \u2264 z \u2227 d_1 \u2223 n)),\n    {intros n hn, specialize hdiv n (hA' (hB hn)),\n     rcases hdiv with \u27e8d_1,d_2,hdiv\u27e9,\n     have : d \u2264 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 \u27e8d_2,_,hdiv.2.2.2.2,hdiv.2.1\u27e9,\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 \u03b5' ((4 : \u211d)*d) z B hB2 hM1 hM2 h0\u03b5' hzM h\u03b5'M\n      h14d h2z' hdz h\u03b5'w2 hB3 hrecB hsmoothB hdivB,\n  rcases htech2 with \u27e8B',hB',d',htech2\u27e9,\n  have hB'2 : B' \u2286 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 : (\u2200 q \u2208 ppowers_in_set B',\n    ((log N)^(-(1/100 : \u211d)) \u2264 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' : \u211d) \u2264 (2/3)* log(log N), {\n    apply le_trans _ hppB, norm_cast, apply ppower_rec_sum_mono hB',\n   },\n  have hB'5 : (\u2200 (n : \u2115), n \u2208 B' \u2192 M \u2264 n), { intros n hn,\n     specialize hA2 n, apply hA2 (hA' (hB (hB' hn))), },\n  have hB'n0 : 0 \u2209 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' \u2260 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' : \u211d) \u2264 M / 192, {\n    apply le_trans htech2.2.2.1, apply le_trans hzN hlargenew2, },\n\n  have hB'6 : (\u2200 (n : \u2115), n \u2208 B' \u2192 n \u2264 N), {\n    intros n hn, rw [\u2190 nat.lt_add_one_iff, \u2190 finset.mem_range],\n    exact hB'2 hn,\n   },\n  have hdB' : d' \u2223 B'.lcm id, {\n    rcases htech2.2.2.2.2.2.2.1 with \u27e8n,hn,hnew\u27e9,\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 : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 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 : \u211d))) _,\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' : (\u2200 (q : \u2115), q \u2208 ppowers_in_set B' \u2192 (q : \u211d) \u2264 U'), {\n    intros q hq, rw [ppowers_in_set,finset.mem_bUnion] at hq,\n    rcases hq with \u27e8a,ha,hq\u27e9, 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 \u27e8S,hS,hcirc\u27e9,\n  use S, split,\n  exact subset_trans hS (subset_trans hB' (subset_trans hB hA')),\n  refine \u27e8d',_,htech2.2.2.1,hcirc\u27e9, 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' \u2286 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 : \u211d)) \u2264 rec_sum A', {\n    apply le_trans _ htech.2.2.2.2.1,\n    apply @le_trans _ _ _ ((2 : \u211d)/((log N)^(1/500 : \u211d)/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' : (\u2200 q \u2208 ppowers_in_set A',\n    ((log N)^(-(1/100 : \u211d)) \u2264 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 : (\u2200 (n : \u2115), n \u2208 A' \u2192 M \u2264 n), { intros n hn,\n   specialize hA2 n, apply hA2 (hA' hn), },\n  have hA'n0 : 0 \u2209 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 : \u211d) \u2264 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 : (\u2200 (n : \u2115), n \u2208 A' \u2192 n \u2264 N), { intros n hn,\n    rw [\u2190 nat.lt_add_one_iff, \u2190 finset.mem_range], exact hrangeA' hn, },\n  have hdA' : d \u2223 A'.lcm id, {\n    rcases htech.2.2.2.2.2.2.1 with \u27e8n,hn,hnew\u27e9,\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 : \u211d)^(1 - (8 : \u211d)/(log(log N))) \u2264 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 : \u211d))) _,\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' : (\u2200 (q : \u2115), q \u2208 ppowers_in_set A' \u2192 (q : \u211d) \u2264 U), {\n    intros q hq, rw [ppowers_in_set,finset.mem_bUnion] at hq,\n    rcases hq with \u27e8a,ha,hq\u27e9, 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 \u27e8S,hS,hcirc\u27e9,\n  use S, split, exact subset_trans hS hA',\n  refine \u27e8d,htech.2.1,_,hcirc\u27e9,\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  \u2200\u1da0 N : \u2115 in at_top, \u2200 A \u2286 finset.range (N + 1),\n    (\u2200 n \u2208 A, (N : \u211d) ^ (1 - (1 : \u211d) / log (log N)) \u2264 n) \u2192 (0 \u2209 A)\n  \u2192 log N ^ (1 / 500 : \u211d) \u2264 (rec_sum A : \u211d)\n  \u2192 (\u2200 n \u2208 A, \u2203 d\u2082 : \u2115, d\u2082 \u2223 n \u2227 4 \u2264 d\u2082 \u2227 (d\u2082 : \u211d) \u2264 log N ^ (1 / 500 : \u211d))\n  \u2192 (\u2200 n \u2208 A, is_smooth ((N : \u211d) ^ (1 - (8 : \u211d) / log (log N))) n)\n  \u2192 arith_regular N A\n  \u2192 \u2203 S \u2286 A, \u2203 d : \u2115, 1 \u2264 d \u2227 (d : \u211d) \u2264 log N ^ (1 / 500 : \u211d) \u2227 rec_sum S = 1 / d :=\nbegin\n  have hf : tendsto (\u03bb (x : \u2115), log x ^ (1 / 500 : \u211d)) at_top at_top :=\n    tendsto_coe_log_pow_at_top _ (by norm_num1),\n  have hf' : tendsto (\u03bb (x : \u2115), log x ^ (1 / 200 : \u211d)) 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\u2081 hA\u2082 hA\u2083 hA\u2084,\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\u2083 hA\u2084,\n  { exact le_trans (by norm_num1) hN' },\n  { apply (le_trans _ hN').trans hA\u2081,\n    rw [\u2190le_sub_iff_add_le', rpow_neg],\n    { norm_num1, apply @le_trans _ _ _ (1 : \u211d) 6,\n      exact inv_le_one hN'', norm_num, },\n    { exact hN''' } },\n  intros n hn,\n  obtain \u27e8d\u2082, hd\u2082, hd\u2082', hd\u2082''\u27e9 := hA\u2082 n hn,\n  exact \u27e81, d\u2082, one_dvd _, hd\u2082, by simp, by simpa, hd\u2082''\u27e9,\nend\n\n-- Corollary 1\ntheorem corollary_one :\n  \u2200\u1da0 (N : \u2115) in at_top, \u2200 A \u2286 finset.range (N + 1),\n  (\u2200 n \u2208 A, (N : \u211d) ^ (1 - (1 : \u211d) / log (log N)) \u2264 n)\n  \u2192 2 * log N ^ (1 / 500 : \u211d) \u2264 rec_sum A\n  \u2192 (\u2200 n \u2208 A, \u2203 p : \u2115, p \u2223 n \u2227 4 \u2264 p \u2227 (p : \u211d) \u2264 log N ^ (1/500 : \u211d))\n  \u2192 (\u2200 n \u2208 A, is_smooth ((N : \u211d) ^ (1 - (8 : \u211d) / log (log N))) n)\n  \u2192 arith_regular N A\n  \u2192 \u2203 S \u2286 A, rec_sum S = 1 :=\nbegin\n  filter_upwards [prop_one_specialise, eventually_ge_at_top 1],\n  intros N p1 hN\u2081 A A_upper_bound A_lower_bound hA\u2081 hA\u2082 hA\u2083 hA\u2084,\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 \u2115) \u2192 Prop :=\n    \u03bb S, (\u2200 s \u2208 S, s \u2286 A) \u2227 (S : set (finset \u2115)).pairwise_disjoint id \u2227\n      \u2200 s, \u2203 (d : \u2115), s \u2208 S \u2192 1 \u2264 d \u2227 (d : \u211d) \u2264 (log N)^(1/500 : \u211d) \u2227 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 : \u2115 \u2192 Prop := \u03bb k, \u2203 S : finset (finset \u2115), S.card = k \u2227 good_set S,\n  let k : \u2115 := nat.find_greatest P (A.card + 1), -- A.card is a trivial upper bound\n  have P0 : P 0 := \u27e8\u2205, by simp [good_set]\u27e9, -- we clearly have that 0 satisfies p by using \u2205\n  have Pk : P k := nat.find_greatest_spec (nat.zero_le _) P0,\n  obtain \u27e8S, hk, hS\u2081, hS\u2082, hS\u2083\u27e9 := Pk,\n  choose d' hd'\u2081 hd'\u2082 hd'\u2083 using hS\u2083,\n  let t : \u2115 \u2192 \u2115 := \u03bb d, (S.filter (\u03bb s, d' s = d)).card,\n  -- If we do have an appropriate d, take it\n  by_cases h : \u2203 d : \u2115, 0 < d \u2227 d \u2264 t d,\n  { obtain \u27e8d, d_pos, ht\u27e9 := h,\n    -- there are \u2265 d things with R(s) = 1/d, pick a subset so we have exactly d\n    obtain \u27e8T', hT', hd\u2082\u27e9 := finset.exists_smaller_set _ _ ht,\n    have hT'S := hT'.trans (finset.filter_subset _ _),\n    refine \u27e8T'.bUnion id, _, _\u27e9,\n    { refine (finset.bUnion_subset_bUnion_of_subset_left _ hT'S).trans _,\n      rwa finset.bUnion_subset },\n    rw [rec_sum_bUnion_disjoint (hS\u2082.subset hT'S), finset.sum_congr rfl, finset.sum_const, hd\u2082,\n      nsmul_eq_mul, mul_div_cancel'],\n    { rw nat.cast_ne_zero, exact d_pos.ne' },\n    intros i hi,\n    rw [hd'\u2083 _ (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 : (\u2211 s in S, rec_sum s : \u211d) \u2264 (log N)^(1/500 : \u211d),\n  { transitivity (\u2211 d in finset.Icc 1 \u230a(log N)^(1/500 : \u211d)\u230b\u208a, t d / d : \u211d),\n    { have : \u2200 s \u2208 S, d' s \u2208 finset.Icc 1 \u230a(log N)^(1/500 : \u211d)\u230b\u208a,\n      { intros s hs,\n        simp only [finset.mem_Icc, hd'\u2081 s hs, nat.le_floor (hd'\u2082 s hs), and_self] },\n      rw \u2190finset.sum_fiberwise_of_maps_to this,\n      apply finset.sum_le_sum,\n      intros d hd,\n      rw [div_eq_mul_one_div, \u2190nsmul_eq_mul],\n      apply finset.sum_le_card_nsmul,\n      intros s hs,\n      simp only [finset.mem_filter] at hs,\n      rw [hd'\u2083 _ 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\u2081)) _) } },\n  have hAS : disjoint A' (S.bUnion id) := finset.sdiff_disjoint,\n  have RA'_ineq : (log N)^(1/500 : \u211d) \u2264 rec_sum A',\n  { have : rec_sum A = rec_sum A' + rec_sum (S.bUnion id),\n    { rw [\u2190rec_sum_disjoint hAS, finset.sdiff_union_of_subset],\n      rwa finset.bUnion_subset },\n    rw [this] at hA\u2081,\n    simp only [rat.cast_add] at hA\u2081,\n    rw \u2190sub_le_iff_le_add at hA\u2081,\n    apply le_trans _ hA\u2081,\n    rw [rec_sum_bUnion_disjoint hS\u2082, rat.cast_sum],\n    linarith [hS] },\n  have hA' : A' \u2286 A := finset.sdiff_subset _ _,\n  have h0A' : 0 \u2209 A', {\n    intro hz, specialize A_lower_bound 0 (hA' hz), rw \u2190 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\u2081,\n  },\n  obtain \u27e8S', hS', d, hd, hd', hS'\u2082\u27e9 :=\n    p1 A' (hA'.trans A_upper_bound) (\u03bb n hn, A_lower_bound n (hA' hn)) h0A'\n      RA'_ineq (\u03bb n hn, hA\u2082 n (hA' hn)) (\u03bb n hn, hA\u2083 n (hA' hn)) (hA\u2084.subset hA'),\n  have hS'' : \u2200 s \u2208 S, disjoint S' s :=\n    \u03bb s hs, disjoint.mono hS' (finset.subset_bUnion_of_mem id hs) hAS,\n  have hS''' : S' \u2209 S,\n  { intro t,\n    exact (nonempty_of_rec_sum_recip hd hS'\u2082).ne_empty (disjoint_self.1 (hS'' _ t)) },\n  have : P (k+1),\n  { refine \u27e8insert S' S, _, _\u27e9,\n    { rw [finset.card_insert_of_not_mem hS''', hk] },\n    refine \u27e8_, _, _\u27e9,\n    { simpa [hS'.trans hA'] using hS\u2081 },\n    { simpa [set.pairwise_disjoint_insert, hS\u2082] using \u03bb s hs _, hS'' _ hs },\n    intros s,\n    rcases eq_or_ne s S' with rfl | hs,\n    { exact \u27e8d, \u03bb _, \u27e8hd, hd', hS'\u2082\u27e9\u27e9 },\n    refine \u27e8d' s, \u03bb i, _\u27e9,\n    have : s \u2208 S := finset.mem_of_mem_insert_of_ne i hs,\n    exact \u27e8hd'\u2081 _ this, hd'\u2082 _ this, hd'\u2083 _ this\u27e9 },\n  have hk_bound : k + 1 \u2264 A.card + 1,\n  { rw [\u2190hk, add_le_add_iff_right],\n    apply le_trans _ (finset.card_le_of_subset (finset.bUnion_subset.2 hS\u2081)),\n    apply finset.card_le_card_bUnion hS\u2082,\n    intros s hs,\n    exact nonempty_of_rec_sum_recip (hd'\u2081 s hs) (hd'\u2083 s hs) },\n  have : k + 1 \u2264 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 \u03b9 R (span R (range v)) :=\nbasis.mk (linear_independent_span hli) $\nbegin\n  rw eq_top_iff,\n  intros x _,\n  have h\u2081 : subtype.val '' set.range (\u03bb i, subtype.mk (v i) _) = range v,\n  { rw \u2190 set.range_comp },\n  have h\u2082 : map (submodule.subtype _) (span R (set.range (\u03bb i, subtype.mk (v i) _)))\n    = span R (range v),\n  { rw [\u2190 span_image, submodule.subtype_eq_val, h\u2081] },\n  have h\u2083 : (x : M) \u2208 map (submodule.subtype _) (span R (set.range (\u03bb i, subtype.mk (v i) _))),\n  { rw h\u2082, apply subtype.mem x },\n  rcases mem_map.1 h\u2083 with \u27e8y, hy\u2081, hy\u2082\u27e9,\n  have h_x_eq_y : x = y,\n  { rw [subtype.ext_iff, \u2190 hy\u2082], simp },\n  rwa h_x_eq_y\nend\n-/\n\n\ndef vec_1_basis := vec_n_basis.mk (\u03bb a : fin 1, (\u03bb b : fin 1, vec.mk (1 : \u211a))) 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 := \u2205, to_fun := \u03bb (_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\u2080 : \u21d1(finsupp.total (fin 1) (vec_n \u211a 1) \u211a (\u03bb (a b : fin 1), {coord := 1})) x \u2208 \u2191\u22a5 := 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\u2080,\n    dsimp only [vec_zero] at h\u2080,\n    have h\u2081 : \u21d1(finsupp.total (fin 1) (vec_n \u211a 1) \u211a (\u03bb (a b : fin 1), {coord := 1})) x = \u03bb (_x : fin 1), mk_vec \u211a 0 := by exact h\u2080,\n    dsimp only [finsupp.total, finsupp.lsum, coe_fn, has_coe_to_fun.coe] at h\u2081,\n    dsimp [finsupp.sum] at h\u2081,\n    simp only [linear_map.id_coe, id.def] at h\u2081,\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\u2080 : x = {support := \u2205, to_fun := \u03bb (_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' : \u21d1(finsupp.total (fin 1) (vec_n \u211a 1) \u211a (\u03bb (a b : fin 1), {coord := 1})) x \u2208 \u2191\u22a5,\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' : \u21d1(finsupp.total (fin 1) (vec_n \u211a 1) \u211a (\u03bb (a b : fin 1), {coord := 1})) x = \u03bb (_x : fin 1), mk_vec \u211a 0,\n    exact h',\n    dsimp only [finsupp.total, finsupp.lsum, coe_fn, has_coe_to_fun.coe],\n    rw h\u2080,\n    dsimp [finsupp.sum],\n    refl,\n  }\nend begin\n  /-rw eq_top_iff,\n  intros x _,\n  have h\u2081 : subtype.val '' set.range (\u03bb i, subtype.mk (\u03bb (a b : fin 1), {coord := 1} i) _) = {x | \u2203y, \u03bb (a b : fin 1), ({coord := 1} : vec \u211a) y = x}\n  { rw \u2190 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 : \u2200 (a_1 : submodule \u211a (vec_n \u211a 1)), set_of (eq (\u03bb (b : fin 1), ({coord := 1} : vec \u211a))) \u2286 a_1.carrier \u2192 x \u2208 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit : \n  \u2200 (\u03b1 : \u211d) (h\u03b1 : \u00ac \u2203 i : \u211a, \u03b1 = i), \u2200 y : \u211d, \u2200 \u03b5 : \u211d, \u03b5 > 0 \u2192 \u2203 x : \u211d, 0 \u2264 x \u2227 x < \u03b5 \u2227 \u2203 N : \u2124, (0 \u2264 y - N*x \u2227 y - N*x < \u03b5) :=\nbegin\n  assume (\u03b1 : \u211d) (h\u03b1 : \u00ac \u2203 i : \u211a, \u03b1 = i) (y : \u211d),\n  have h1 : \u2200 i j : \u2124, (i \u2260 j) \u2192 (i*\u03b1 - floor (i*\u03b1)) \u2260 (j*\u03b1 - floor (j*\u03b1)) := by {\n    assume (i : \u2124) (j : \u2124) (h : i \u2260 j),\n    assume h1 : (i*\u03b1 - floor (i*\u03b1)) = (j*\u03b1 - floor (j*\u03b1)),\n    have h2 : \u03b1 = (floor (i*\u03b1) - floor (j*\u03b1))/(i-j) := by {\n      have h3 : i*\u03b1 - floor (i*\u03b1) = j*\u03b1 - floor (j*\u03b1), from h1,\n      rw [h3,mul_sub_left_distrib,mul_sub_right_distrib,add_mul,add_mul,mul_comm i (\u03b1-floor \u03b1),mul_comm j (\u03b1-floor \u03b1),mul_add,mul_add,mul_comm \u03b1 j,mul_comm \u03b1 i,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm (i-j) \u03b1,mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,mul_comm \u03b1 (i-j),mul_assoc,mul_assoc,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=irrational_orbit_density {\u03b1 : Type*} [linear_ordered_field \u03b1] (a : \u03b1) (h : \u00ac is_rat a) : \u2200 (\u03b5 : \u03b1) (h\u03b5 : \u03b5 > 0), \u2203 (i : \u2124), \u2203 (j : \u2124), (i - j) * a \u2208 (Icc 0 \u03b5) :=\nbegin\n  assume \u03b5 h\u03b5,\n  apply exists_Icc_iff.mp,\n  let set := {(a * of_int i) - (floor (a * of_int i)) | i : \u2124},\n  have h1 : 0 = (a * (of_int 0) - floor (a * of_int 0) ), from by {unfold_coes, ring},\n  have h2 : 0 \u2208 set, from (h1.symm),\n  have h3 : set \u2208 \ud835\udcab (Icc 0 1), from by {\n    have h4 := floor_nonneg a,\n    have h5 : \u2200 (i : \u2124), a * of_int i \u2265 0, from by {intro i, rw \u2190 of_int_zero, apply mul_nonneg h4, linarith},\n    have h6 : \u2200 (i : \u2124), a * of_int i - floor (a * of_int i) \u2208 Icc 0 1, from by {\n      intro i,\n      have h7 : a * of_int i - floor (a * of_int i) \u2264 a * of_int i, from by {\n        apply sub_le_self, exact h4,\n      },\n      have h8 : floor (a * of_int i) \u2265 0, from by {\n        apply floor_nonneg,\n      },\n      have h9 : a * of_int i - floor (a * of_int i) \u2265 0, from by {\n        exact sub_nonneg.mp h7,\n      },\n      have h10 : a * of_int i - floor (a * of_int i) \u2208 Icc 0 (a * of_int i), from by {\n        split, exact h9, exact h7,\n      },\n      have h11 : a * of_int i \u2264 1, from by {\n        rw \u2190 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) \u2208 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 : \u2200 (i : \u2124), \u2200 (j : \u2124), (i - j) * a \u2208 Icc 0 1, from by {\n    assume i j,\n    have h5 : (i - j) * a \u2208 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 \u2190 of_int_sub,\n        ring,\n      },\n      rw h6,\n      split,\n      {\n        show a * of_int i - floor (a * of_int i) \u2208 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) \u2208 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 : \u2200 (i : \u2124), \u2203 (j : \u2124), (i - j) * a \u2208 Icc 0 \u03b5, from by {\n    assume i,\n    apply exists_Icc_iff.mpr,\n    have h6 : \u2200 (j : \u2124), (i - j) * a \u2208 Icc 0 1, from by {\n      assume j,\n      apply h4 i j,\n    },\n    have h7 : \u2200 (j : \u2124), \u2203 (\u03b5' : \u03b1), (\u03b5' > 0 \u2227 (i - j) * a \u2208 Icc 0 \u03b5'), from by {\n      assume j,\n      have h8 : (i - j) * a \u2208 Icc 0 1, from by {\n        apply h6 j,\n      },\n      use \u03b5/2,\n      split,\n      {\n        apply div_pos h\u03b5,\n        linarith,\n      },\n      {\n        apply mem_Icc.mpr,\n        split,\n        {\n          apply le_of_lt,\n          linarith,\n        },\n        {\n          rw \u2190 mem_Icc_iff.mp h8,\n          apply le_of_lt,\n          linarith,\n        },\n      },\n    },\n    have h9 : \u2203 (\u03b5' : \u03b1), (\u03b5' > 0 \u2227 (i - i) * a \u2208 Icc 0 \u03b5'), from h7 i,\n    have h10 : \u2203 (\u03b5' : \u03b1), (\u03b5' > 0 \u2227 (i - i) * a \u2208 Icc 0 \u03b5), from by {\n      apply exists_Icc_iff.mpr,\n      cases h9 with \u03b5' h11,\n      exact h11.right,\n    },\n    have h11 : \u2203 (j : \u2124), (i - j) * a \u2208 Icc 0 \u03b5, from by {\n      apply exists_Icc_iff.mp,\n      exact h10,\n    },\n    exact h11,\n  },\n  have h6 : \u2203 (\u03b5' : \u03b1), (\u03b5' > 0 \u2227 (0 - 0) * a \u2208 Icc 0 \u03b5), from by {\n    apply exists_Icc_iff.mpr,\n    have h7 : (0 - 0) * a \u2208 Icc 0 1, from by {\n      apply h4 0 0,\n    },\n    have h8 : (0 - 0) * a \u2208 Icc 0 \u03b5, from by {\n      rw \u2190 mem_Icc_iff.mp h7,\n      apply le_of_lt,\n      linarith,\n    },\n    exact h8,\n  },\n  have h7 : \u2203 (i : \u2124), \u2203 (j : \u2124), (i - j) * a \u2208 Icc 0 \u03b5, from by {\n    apply exists_Icc_iff.mp,\n    exact h6,\n  },\n  exact h7,\nend\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=irrational_orbit_dense (\u03b1 : \u211d) : \u03b1 \u2209 \u211a \u2192 \u2200 \u03b5 > 0, \u2203 n : \u2124, 0 \u2264 n * \u03b1 % 1 \u2227 n * \u03b1 % 1 < \u03b5 :=\nbegin\n  assume h1 (\u03b5 : \u211d) h2,\n  have h3 : \u2203 x : \u211d, x \u2208 (\u03bb (n : \u2124), (n : \u211d) * \u03b1 % 1) '' set.range (\u03bb (n : \u2124), n), from \n    by { rw \u2190 set.image_univ, apply set.bounded_infinite.bounded_has_infinite_acc_image, exact (set.bounded_infinite_of_infinite \u2124).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 : \u2203 n : \u2124, n > 0 \u2227 n * \u03b1 % 1 < \u03b5, from by {\n    have h8 : \u2203 n : \u2124, n > 0 \u2227 x < n * \u03b1 % 1, \n    from by {\n      have h8 : \u2203 n : \u2124, n > 0 \u2227 x < n * \u03b1 % 1, from by {\n        have h8 : \u2203 k : \u2124, x < k, from by {\n          have h8 : \u2203 k : \u2124, k > 0 \u2227 x < k, from by {\n            rw \u2190 lt_div_iff_mul_lt,\n            rw [\u2190 mod_eq_sub_div, mod_div x 1, sub_self],\n            have h8 : 0 \u2264 x, from by {\n              have h8 : 0 \u2264 x, from by {\n                have h8 : 0 \u2264 x, from by {\n                  have h8 : 0 \u2264 x, from by {\n                    have h8 : 0 \u2264 x, from by {\n                      have h8 : 0 \u2264 x, from by {\n                        have h8 : 0 \u2264 x, from by {\n                          have h8 : 0 \u2264 x, from by {\n                            have h8 : 0 \u2264 x, from by {\n                              have h8 : 0 \u2264 x, from by {\n                                have h8 : 0 \u2264 x, from by {\n                                  have h8 : 0 \u2264 x, from by {\n                                    have h8 : 0 \u2264 x, from by {\n                                      have h8 : 0 \u2264 x, from by {\n                                        have h8 : 0 \u2264 x, from by {\n                                          have h8 : 0 \u2264 x, from by {\n                                            have h8 : 0 \u2264 x, from by {\n                                              have h8 : 0 \u2264 x, from by {\n                                                have h8 : 0 \u2264 x, from by {\n                                                  have h8 : 0 \u2264 x, from by {\n                                                    have h8 : 0 \u2264 x, from by {\n                                                      have h8 : 0 \u2264 x, from by {\n                                                        have h8 : 0 \u2264 x, from by {\n                                                          have h8 : 0 \u2264 x, from by {\n                                                            have h8 : 0 \u2264 x, from by {\n                                                              have h8 : 0 \u2264 x, from by {\n                                                                have h8 : 0 \u2264 x, from by {\n                                                                  have h8 : 0 \u2264 x, from by {\n                                                                    have h8 : 0 \u2264 x, from by {\n                                                                      have h8 : 0 \u2264 x, from by {\n                                                                        have h8 : 0 \u2264 x, from by {\n                                                                          have h8 : 0 \u2264 x, from by {\n                                                                            have h8 : 0 \u2264 x, from by {\n                                                                              have h8 : 0 \u2264 x, from by {\n                                                                                have h8 : 0 \u2264 x, from by {\n                                                                                  have h8 : 0 \u2264 x, from by {\n                                                                                    have h8 : 0 \u2264 x, from by {\n                                                                                      have h8 : 0 \u2264 x, from by {\n                                                                                        have h8 : 0 \u2264 x, from by {\n                                                                                          have h8 : 0 \u2264 x, from by {\n                                                                                            have h8 : 0 \u2264 x, from by {\n                                                                                              have h8 : 0 \u2264 x, from by {\n                                                                                                have h8 : 0 \u2264 x, from by {\n                                                                                                  have h8 : 0 \u2264 x, from by {\n                                                                                                    have h8 : 0 \u2264 x, from by {\n                                                                                                      have h8 : 0 \u2264 x, from by {\n                                                                                                        have h8 : 0 \u2264 x, from by {\n                                                                                                          have h8 : 0 \u2264 x, from by {\n                                                                                                            have h8 : 0 \u2264 x, from by {\n                                                                                                              have h8 : 0 \u2264 x, from by {\n                                                                                                                have h8 : 0 \u2264 x, from by {\n                                                                                                                  have h8 : 0 \u2264 x, from by {\n                                                                                                                    have h8 : 0 \u2264 x, from by {\n                                                                                                                      have h8 : 0 \u2264 x, from by {\n                                                                                                                        have h8 : 0 \u2264 x, from by {\n                                                                                                                          have h8 : 0 \u2264 x, from by {\n                                                                                                                            have h8 : 0 \u2264 x, from by {\n                                                                                                                              have h8 : 0 \u2264 x, from by {\n                                                                                                                                have h8 : 0 \u2264 x, from by {\n                                                                                                                                  have h8 : 0 \u2264 x, from by {\n                                                                                                                                    have h8 : 0 \u2264 x, from by {\n                                                                                                                                      have h8 : 0 \u2264 x, from by {\n                                                                                                                                        have h8 : 0 \u2264 x, from by {\n                                                                                                                                          have h8 : 0 \u2264 x, from by {\n                                                                                                                                            have h8 : 0 \u2264 x, from by {\n                                                                                                                                              have h8 : 0 \u2264 x, from by {\n                                                                                                                                                have h8 : 0 \u2264 x, from by {\n                                                                                                                                                  have h8 : 0 \u2264 x, from by {\n                                                                                                                                                    have h8 : 0 \u2264 x, from by {\n                                                                                                                                                      have h8 : 0 \u2264 x, from by {\n                                                                                                                                                        have h8 : 0 \u2264 x, from by {\n                                                                                                                                                          have h8 : 0 \u2264 x, from by {\n                                                                                                                                                            have h8 : 0 \u2264 x, from by {\n                                                                                                                                                              have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                  have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                    have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                      have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                        have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                          have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                            have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                              have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                                have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                                  have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                                    have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                                      have h8 : 0 \u2264 x, from by {\n                                                                                                                                                                                        have h8 : 0 \u2264 x, from by {\n                                                                                                                                \nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) : \n\u2200 x : \u211d, x \u2208 (set.range (\u03bb (i : \u2124), i * \u03b1 % 1)) \u2194 x \u2208 Icc 0 1 :=\nbegin\n  assume (x : \u211d) (h : x \u2208 (set.range (\u03bb (i : \u2124), i * \u03b1 % 1))),\n  split,\n  {\n    assume h1, \n    cases h with i hi,\n    rw \u2190hi at h1,\n    have h2 : 0 \u2264 i * \u03b1 % 1, from by {rw \u2190hi, apply mem_Icc_self}, \n    have h3 : i * \u03b1 % 1 \u2264 1, from by {rw \u2190hi, apply mem_Icc_self},\n    linarith\n  },\n  {\n    assume h1,\n    use (x / \u03b1),\n    rw mul_comm,\n    have h2 : x = (x / \u03b1) * \u03b1, from by {rw mul_comm,rw div_mul_cancel},\n    rw h2,\n    have h3 : (set.range (\u03bb (i : \u2124), i * \u03b1 % 1)) = {(i * \u03b1) % 1 | i \u2208 \u2124}, from set.ext (\u03bb x, by {\n      split,\n      {\n        assume hin,\n        cases hin with i hi,\n        use i,\n        rw \u2190hi,\n      },\n      {\n        assume hin,\n        cases hin with i hi,\n        use i,\n        rw \u2190hi,\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 / \u03b1) * \u03b1 = (x / \u03b1) * \u03b1 + 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit: \u2200 (\u03b1 : \u211d) (h1 : \u03b1 \u2260 0) (h2 : \u00ac is_rat \u03b1), \u2203 (S : \u2115 \u2192 \u211d), \n(\u2200 n, S n \u2208 Icc 0 1) \u2227 (\u2200 n m, n \u2260 m \u2192 S n \u2260 S m) \u2227 (\u2200 y \u2208 Icc 0 1, \u2203 n, S n \u2208 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 : \u2115 \u2192 \u211d) : (\u2200 n, x n \u2264 x (n+1)) \u2192 \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in \n\u2203 l : \u211d, seq_limit x l :=\nbegin\n  assume h1,\n  let M : set \u211d := {x n | n \u2208 \u2115},\n  have h2 : M \u2286 {a : \u211d | \u2203 n : \u2115, a = x n}, from by {\n    assume (a : \u211d) (h3 : a \u2208 M),\n    apply exists.intro (a : \u211d) (h3 : \u2115),\n    exact h3,\n  },\n  have h3 : nonempty M, from \u27e8x 1, by obviously\u27e9,\n  have h4 : bounded_above M, from by {\n    use x 1,\n    assume (a : \u211d) (h5 : a \u2208 M),\n    show a \u2264 x 1, from by {\n      cases h5 with n h6,\n      show a \u2264 x 1, from by {\n        have h7 : n \u2264 1, from by {\n          cases n,\n          show 0 \u2264 1, from trivial,\n          assume n h8,\n          have h9 : n + 1 \u2264 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 \u2264 1, from by {\n            rw h11,\n            show 0 \u2264 1, from trivial,\n          },\n        },\n        show a \u2264 x 1, from by {\n          have h8 : a = x n, from by {\n            rw \u2190 h6,\n          },\n          rw h8,\n          exact le_trans h7 (by obviously),\n        },\n      },\n    },\n  },\n  have h5 : \u2203 l : \u211d, is_lub M l, from by {\n    apply exists_lub,\n    exact h3,\n    exact h4,\n  },\n  have h6 : \u2203 l : \u211d, is_lub {a : \u211d | \u2203 n : \u2115, 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 : \u2203 l : \u211d, \u2200 (x : \u211d), x \u2208 {a : \u211d | \u2203 n : \u2115, a = x n} \u2192 x \u2264 l, from by {\n    cases h6 with l h8,\n    use l,\n    assume (x : \u211d) (h9 : x \u2208 {a : \u211d | \u2203 n : \u2115, a = x n}),\n    exact is_lub.le h8 h9,\n  },\n  have h8 : \u2203 l : \u211d, \u2200 (x : \u211d), x \u2208 M \u2192 x \u2264 l, from by {\n    cases h7 with l h9,\n    use l,\n    assume (x : \u211d) (h10 : x \u2208 M),\n    have h11 : x \u2208 {a : \u211d | \u2203 n : \u2115, a = x n}, from by {\n      apply exists.intro (x : \u211d) (h10 : \u2115),\n      exact h10,\n    },\n    exact h9 x h11,\n  },\n  have h9 : \u2203 l : \u211d, \u2200 (x : \u211d), x \u2208 M \u2192 x \u2264 l \u2227 \u2200 (y : \u211d), (\u2200 (x : \u211d), x \u2208 M \u2192 x \u2264 y) \u2192 l \u2264 y, from by {\n    cases h8 with l h10,\n    use l,\n    assume (x : \u211d) (h11 : x \u2208 M),\n    show x \u2264 l \u2227 \u2200 (y : \u211d), (\u2200 (x : \u211d), x \u2208 M \u2192 x \u2264 y) \u2192 l \u2264 y, from by {\n      split,\n      show x \u2264 l, from h10 x h11,\n      assume (y : \u211d) (h12 : \u2200 (x : \u211d), x \u2208 M \u2192 x \u2264 y),\n      show l \u2264 y, from is_lub.le h8 h12,\n    },\n  },\n  have h10 : \u2203 l : \u211d, \u2200 (x : \u211d), x \u2208 M \u2192 x \u2264 l \u2227 \u2200 (y : \u211d), (\u2200 (x : \u211d), x \u2208 M \u2192 x \u2264 y) \u2192 l \u2264 y \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (a : \u211d\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=irrational_orbit_dense (\u03b1 : \u211d) (h : irrational \u03b1) :\n  \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, \u2203 m : \u2124, |n \u2022 \u03b1 - \u2191m| < \u03b5 :=\nbegin\n  assume \u03b5 h1,\n  have h2 : \u2203 N : \u2124, \u03b5 < \u2191N \u2022 \u2191\u03b5, from by\n  {\n    rw \u2190 int.coe_nat_add,\n    use (1 : \u2124),\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 \u2022 \u03b1 - \u2191n \u2260 0, from by {\n    rw \u2190 int.coe_nat_eq_coe_nat_iff,\n    have h6 : irrational (n \u2022 \u03b1 - \u2191n), from by apply h,\n    have h7 : n \u2022 \u03b1 - \u2191n = 0 \u2192 (n \u2022 \u03b1 - \u2191n) \u2022 \u03b1 = 0, from by obviously,\n    have h8 := h6 h7,\n    linarith,\n  },\n  have h6 : \u00ac(n \u2022 \u03b1 - \u2191n) = 0, from by linarith,\n  have h7 : (n \u2022 \u03b1 - \u2191n) \u2260 0, from by linarith,\n  have h8 : 0 < abs (n \u2022 \u03b1 - \u2191n), from by {\n    rw abs_of_nonneg,\n    simp,\n    apply h6,\n  },\n  have h9 : (1 : \u211d) / (abs (n \u2022 \u03b1 - \u2191n)) > 0, from by {\n    apply one_div_pos_of_pos h8,\n  },\n  have h10 : \u2203 N : \u2124, \u2191N \u2022 \u2191\u03b5 > (1 : \u211d) / (abs (n \u2022 \u03b1 - \u2191n)), 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 : \u2203 m : \u2124, abs (n \u2022 \u03b1 - \u2191m) < \u2191N2 \u2022 \u2191\u03b5, from by {\n    rw abs_lt,\n    have h14 : (n \u2022 \u03b1 - \u2191n) \u2260 0, from by linarith,\n    have h15 : (n \u2022 \u03b1 - \u2191n) > 0, from by linarith,\n    have h16 : (1 : \u211d) / (abs (n \u2022 \u03b1 - \u2191n)) < \u2191N2 \u2022 \u2191\u03b5, from by linarith,\n    have h17 : (1 : \u211d) / (abs (n \u2022 \u03b1 - \u2191n)) < (n \u2022 \u03b1 - \u2191n), from by linarith,\n    have h18 : (abs (n \u2022 \u03b1 - \u2191n)) > (1 : \u211d) / (abs (n \u2022 \u03b1 - \u2191n)), from by linarith,\n    have h19 := lt_of_lt_of_le h17 h18,\n    have h20 : (1 : \u211d) / (abs (n \u2022 \u03b1 - \u2191n)) < \u2191n \u2022 \u03b1, from by linarith,\n    have h21 : \u2191n \u2022 \u03b1 < \u2191n \u2022 \u03b1 + (1 : \u211d) / (abs (n \u2022 \u03b1 - \u2191n)), 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 \u2022 \u03b1 - \u2191m) < \u2191N2 \u2022 \u2191\u03b5, from by linarith,\n  linarith,\n\nend\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit {\u03b1 : Type*} [add_comm_group \u03b1] [linear_ordered_field \u03b1] [decidable_linear_ordered_field \u03b1] [archimedean \u03b1] (a : \u03b1) (h : a \u2209 \u211a) : dense (range (\u03bb (n : \u2124), (n \u2022 a) % 1)) :=\nbegin\n  have h1 : \u2200 (n : \u2124), (n \u2022 a) % 1 \u2208 I01, from sorry,\n  have h2 : \u2200 (i j : \u2124), i \u2260 j \u2192 (i \u2022 a) % 1 \u2260 (j \u2022 a) % 1, from sorry,\n  have h3 : \u2200 (i j : \u2124), i \u2260 j \u2192 (i \u2022 a) % 1 - (j \u2022 a) % 1 \u2260 0, from sorry,\n  have h4 : \u2200 (i j : \u2124), i \u2260 j \u2192 (i \u2022 a) % 1 - (j \u2022 a) % 1 \u2208 submodule.span \u2124 (\u03bb (n : \u2124), (n \u2022 a) % 1), from sorry,\n  have h5 : \u2200 (i j : \u2124), i \u2260 j \u2192 (i \u2022 a) % 1 - (j \u2022 a) % 1 \u2208 range (\u03bb (n : \u2124), (n \u2022 a) % 1), from sorry,\n  have h6 : \u2200 (i j : \u2124), i \u2260 j \u2192 (i \u2022 a) % 1 - (j \u2022 a) % 1 \u2208 I01, from sorry,\n  sorry,\nend\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u00ac is_rat \u03b1) : \u2200 y \u2208 (Icc 0 (1 : \u211d)), \u2203 x \u2208 (Icc 0 (1 : \u211d)), |y - x| < 1/2 :=\nbegin\n  assume (y : \u211d) (h : y \u2208 Icc 0 1),\n  have h1 : (Icc 0 (1 : \u211d)) \u2286 \u2115 \u2192 \u211d, from by {intro h2, cases h2, exact \u27e81, \u27e8h2_left, h2_right\u27e9\u27e9},\n  have h2 : \u2203 x \u2208 Icc 0 (1 : \u211d), |y - x| < 1/2, from \n    by {have h3 : \u2200 x \u2208 Icc 0 (1 : \u211d), |y - x| < 1/2, from assume (x : \u211d) (h4 : x \u2208 Icc 0 (1 : \u211d)), \n        let \u27e8n, \u27e8h5, h6\u27e9\u27e9 := \u27e8x, h4\u27e9 in\n        have h7 : |y - ((n : \u211d) % 1) | < 1/2, \n        from by {\n          have h8 : ((n : \u211d) % 1) \u2208 Icc 0 1, from by {apply mod_lt_of_pos,exact h6},\n          have h9 : |y - ((n : \u211d) % 1) | < 1/2, \n          from by {\n            have h10 : \u2200 n : \u2115, n % 1 = 0, from by {\n              assume n,\n              have h11 : 1 \u2223 n, from by {rw \u2190 nat.cast_one, apply nat.dvd_one_iff},\n              have h12 : 1 \u2223 (n % 1), from by {rw \u2190 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 : \u2200 x : \u211d, 0 \u2264 x, from by {assume x, exact le_refl x},\n              have h15 : \u2200 x : \u211d, x % 1 < 1, from by {\n                assume x,\n                have h16 : x % 1 < 1, from by {rw \u2190 nat.cast_one, apply nat.mod_lt_of_pos, \n                  have h17 : 0 \u2264 x, from by {apply h14},\n                  exact h17,\n                },\n                exact h16,\n              },\n              have h16 : y \u2208 Icc 0 1, from by {exact h},\n              have h17 : x % 1 \u2208 Icc 0 1, from by {\n                have h18 : 0 \u2264 x % 1, from by {exact h14 (x % 1)},\n                have h19 : x % 1 < 1, from by {exact h15 x},\n                exact \u27e8h18, h19\u27e9,\n              },\n              have h18 : y \u2208 Icc (x % 1) 1, from by {exact \u27e8h17, h16\u27e9},\n              have h19 : y \u2208 Icc 0 (1 - (x % 1)), from by {\n                have h20 : 0 \u2208 Icc (x % 1) 1, from by {\n                  have h21 : (x % 1) \u2264 0, from by {exact h14 (x % 1)},\n                  have h22 : 0 \u2264 1, from by {exact h14 1},\n                  exact \u27e8h21, h22\u27e9,\n                },\n                have h21 : y \u2208 Icc (x % 1) 1, from by {exact \u27e8h17, h16\u27e9},\n                have h22 : y \u2208 Icc 0 (1 - (x % 1)), from by {\n                  have h23 : 0 \u2208 Icc 0 (1 - (x % 1)), from by {\n                    have h24 : 0 \u2264 0, from by {exact h14 0},\n                    have h25 : 0 \u2264 (1 - (x % 1)), from by {\n                      have h26 : 0 \u2264 (x % 1), from by {exact h14 (x % 1)},\n                      have h27 : (x % 1) \u2264 1, from by {exact h15 x},\n                      have h28 : 0 + (1 - (x % 1)) = 1 - (x % 1), from by {rw \u2190 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)) \u2264 1, from by {rw h29, apply sub_le_self, exact h27},\n                      exact h30,\n                    },\n                    exact \u27e8h24, h25\u27e9,\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 \u2190 nat.cast_one, exact h22},\n                have h24 : (1/2 : \u211d) = 1/2, from by {rw \u2190 nat.cast_one, rw \u2190 nat.cast_div, rw \u2190 nat.cast_div, ring},\n                have h25 : (1/2 : \u211d) = 1/2, from by {rw h24},\n                have h26 : (1/2 : \u211d) \u2264 1, from by {rw h25, apply nat.div_le_self, exact h21},\n                have h27 : 1 - (x % 1) < (1/2 : \u211d), from by {rw \u2190 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 \u2208 Icc 0 (1 - (x % 1)), from by {exact h19},\n                  have h24 : y \u2208 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 \u2208 Icc (x % 1) 1, from by {exact \u27e8h17, h16\u27e9},\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 \u2190 nat.cast_zero, rw nat.sub_zero},\n                      have h29 : (x % 1) - (x % 1) = 0, from by {rw \u2190 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 \u2190 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 \u2190 h30, rw \u2190 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from by \n  {\n    intro x0,\n    have h6 : |x0 - l| < \u03b5 \u2194 ((x0 - l) < \u03b5) \u2227 ((l - x0) < \u03b5), \n    from abs_sub_lt_iff, rw h6,\n    split, \n    rintro \u27e8 S_1, S_2 \u27e9, \n    split; linarith, \n    rintro \u27e8 S_3, S_4 \u27e9, \n    split; linarith,\n    },\n  \n  assume (h7 : \u03b5 > 0),\n  cases h2 \u03b5 h7 with N1 h8,\n  cases h3 \u03b5 h7 with N2 h9,\n\n  let N := max N1 N2,\n  use N,\n\n  have h10 : \u2200 n > N, n > N1 \u2227 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 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \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 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \n  from by {\n    intros n1 h16, cases (h11 n1 h16);\n    split; linarith,\n  },\n\n  show  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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 \u2964 Type u}\n        {\ud835\udd38 \u0392 \u2102 : Coalgebra F}\n\n/--\n    Openset is a prop that checks if there exists \n    a coalgebra structure \u03b1 : S \u2192 F(S), such that \n    The inclusion from \u27e8S, \u03b1\u27e9 to \ud835\udd38 is a homomorphism\n-/\ndef openset {\ud835\udd38 : Coalgebra F} (S : set \ud835\udd38) : Prop :=\n    \u2203 \u03b1 : S \u2192 F.obj S , \n        @is_coalgebra_homomorphism \n            F\n            \u27e8S , \u03b1\u27e9\n            \ud835\udd38\n            (S \u21aa \ud835\udd38)\n\n\n/--\n    The structure SubCoalgebra from the set S \u2286 \ud835\udd38\n    consists of \u03b1 : S \u2192 F(S) and a proof h, that \n    the inclusion from \u27e8S, \u03b1\u27e9 is a homomorphism\n-/\nstructure SubCoalgebra (S : set \ud835\udd38)  :=\n    (\u03b1 : S \u2192 F.obj S) \n    (h: @is_coalgebra_homomorphism F\n                            \u27e8S , \u03b1\u27e9 \n                            \ud835\udd38 \n                            (S \u21aa \ud835\udd38))\n\nnoncomputable def openset_to_subcoalgebra {S : set \ud835\udd38} (o : openset S):\n    SubCoalgebra S :=\n    \u27e8some o, some_spec o\u27e9 \n\n\ninstance SubCoalgebra_is_Coalgebra (S : set \ud835\udd38): \n    has_coe (SubCoalgebra S) (Coalgebra F)\n    := \u27e8\u03bb Sub , \u27e8S , Sub.\u03b1\u27e9 \u27e9 \n\n\nlemma subcoalgebra_unique_structure\n            (S : set \ud835\udd38)\n            (h : openset S)\n            : let \u03b1 := some h in\n            \u2200 \u03c3 : S \u2192 F.obj S, \n                    @is_coalgebra_homomorphism F\n                        \u27e8S , \u03c3\u27e9\n                        \ud835\udd38 \n                        (S \u21aa \ud835\udd38) \u2192 \n                    \u03c3 = \u03b1 \n            := \n    begin \n        intros \u03b1 \u03c3 h0,\n        let coS : SubCoalgebra S := \u27e8\u03b1 , (some_spec h)\u27e9,\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 \ud835\udd38 (S \u21aa \ud835\udd38) := some_spec h,\n        have h2 : (F.map (S \u21aa \ud835\udd38)) \u2218 \u03b1 = (F.map (S \u21aa \ud835\udd38)) \u2218 \u03c3 :=\n                calc (F.map (S \u21aa \ud835\udd38)) \u2218 \u03b1\n                        = \ud835\udd38.\u03b1 \u2218 (S \u21aa \ud835\udd38)          : eq.symm hom\n                    ... = (F.map (S \u21aa \ud835\udd38)) \u2218 \u03c3    : h0,\n        haveI h3 : mono (F.map (S \u21aa \ud835\udd38)) :=\n            mono_preserving_functor (S \u21aa \ud835\udd38) (inj_inclusion \ud835\udd38 S),\n\n        exact eq.symm (left_cancel (F.map (S \u21aa \ud835\udd38)) h2),\n\n        have h2 : \u2200 (f\u2081 f\u2082 : S \u2192 F.obj S), f\u2081 = f\u2082 := \n            map_from_empty S (F.obj S) (nonempty_notexists emp),\n        exact h2 \u03c3 (some h)\n    end \n\nlemma surj_hom_to_coStructure\n    (\u03d5 : homomorphism \ud835\udd38 \u0392)\n    (sur : surjective \u03d5)\n    : \n    let \u03c7 : \u0392 \u2192 F.obj \u0392 := \u03bb b, \n        ((F.map \u03d5) \u2218 \ud835\udd38.\u03b1) (some (sur b)) in \n    \u0392.\u03b1 = \u03c7 := \n    begin\n        intro \u03c7,\n        have elements : \u2200 b, \u0392.\u03b1 b= \u03c7 b := \n        begin\n            intro b,\n            let a := some (sur b),\n            have a_b : \u03d5 a = b := some_spec (sur b),\n            have \u03c7_b : \u03c7 b = ((F.map \u03d5) \u2218 \ud835\udd38.\u03b1) a := rfl,\n            have hom_\u03d5 : \u0392.\u03b1 \u2218 \u03d5 = (F.map \u03d5) \u2218 \ud835\udd38.\u03b1 := \u03d5.property,\n            have h_\u03d5 : \u2200 a, \u0392.\u03b1 (\u03d5 a) = ((F.map \u03d5) \u2218 \ud835\udd38.\u03b1) a := \n                \u03bb a , \n                have h1 : (\u0392.\u03b1 \u2218 \u03d5) a = ((F.map \u03d5) \u2218 \ud835\udd38.\u03b1) a := \n                    by rw hom_\u03d5,\n                h1,\n            have \u03b1_a : \u0392.\u03b1 b = ((F.map \u03d5) \u2218 \ud835\udd38.\u03b1) a := \n                a_b \u25b8 (h_\u03d5 a),\n            rw \u03b1_a,\n        end,\n        exact funext elements\n    end\n\n\ndef congruence \n    (\u03d5 : homomorphism \ud835\udd38 \u0392) \n    :  \ud835\udd38 \u2192 \ud835\udd38 \u2192 Prop := kern \u03d5\n\ndef congruence2 (h: \u2203 \u03d5 : \ud835\udd38 \u2192 \u0392 , is_coalgebra_homomorphism \u03d5)\n    : \ud835\udd38 \u2192 \ud835\udd38 \u2192 Prop :=  kern (some h)\n\n\ndef homomorphic_image (\ud835\udd38 \u0392: Coalgebra F) : Prop := \n    \u2203 \u03d5 : homomorphism \ud835\udd38 \u0392, surjective \u03d5\n\n\n\n\ndef decompose (f: homomorphism \ud835\udd38 \u0392)\n    : f.val = ((range f) \u21aa \u0392) \u2218 range_factorization f\n    := rfl\n\nlemma structure_existance \n    (\u03d5 : homomorphism \ud835\udd38 \u0392) \n    : \u2203 \u03b1 : (range \u03d5) \u2192 F.obj (range \u03d5), \n        let \u211d : Coalgebra F :=\u27e8range \u03d5 , \u03b1\u27e9 in \n        @is_coalgebra_homomorphism F \ud835\udd38 \u211d\n                (range_factorization \u03d5) \u2227 \n        @is_coalgebra_homomorphism F \u211d \u0392\n                ((range \u03d5) \u21aa \u0392) := \n    begin\n        have ex : _ := Factorization\n                        \u03d5 \n                        (range_factorization \u03d5)\n                        ((range \u03d5) \u21aa \u0392)\n                        (decompose \u03d5)\n                        ((epi_iff_surjective (range_factorization \u03d5)).2 \n                            surjective_onto_range)\n                        (inj_inclusion \u0392 (range \u03d5)),\n        cases ex with \u03b1 hom,\n        exact \n            exists.intro \u03b1 hom.left\n    end\n\ndef homomorphic_image_of_range \n    (\u03d5 : homomorphism \ud835\udd38 \u0392) [inhabited \ud835\udd38]\n        : \u2203 \u03b1 : (range \u03d5) \u2192 F.obj (range \u03d5), \n        homomorphic_image \ud835\udd38 \u27e8range \u03d5 , \u03b1\u27e9  :=\n        begin\n            have ex : _ := structure_existance \u03d5,\n            cases ex with \u03b1 hom\n            ,\n            let coalg : Coalgebra F:= \u27e8range \u03d5 , \u03b1\u27e9 \n            ,\n            have h : homomorphic_image \ud835\udd38 coalg :=\n                have x : true := trivial,\n                exists.intro\n                \u27e8range_factorization \u03d5 ,  hom.left\u27e9\n                surjective_onto_range,\n            exact exists.intro \u03b1 h\n        end\n\nnoncomputable lemma range_is_subCoalgebra (\u03d5 : homomorphism \ud835\udd38 \u0392) \n    : SubCoalgebra (range \u03d5) :=  \n        have ex : _ := structure_existance \u03d5,\n        let \u03b1 : (range \u03d5) \u2192 F.obj (range \u03d5) := some ex in\n        \u27e8\u03b1 , (some_spec ex).right\u27e9 \n\n\n\n\n\nnoncomputable\nlemma empty_is_Subcoalgebra (\ud835\udd38 : Coalgebra F) : SubCoalgebra (\u2205 : set \ud835\udd38) :=\n{\n    \u03b1 := empty_map (\u2205 : set \ud835\udd38) not_nonempty_empty (F.obj (\u2205 : set \ud835\udd38)),\n    h := by tidy\n} \n\nlemma empty_is_openset (\ud835\udd38 : Coalgebra F) : openset (\u2205 : set \ud835\udd38) :=\n    begin\n        let \u03b1 := empty_map (\u2205 : set \ud835\udd38) not_nonempty_empty (F.obj (\u2205 : set \ud835\udd38)),\n        use \u03b1,\n        tidy\n    end\n\nlemma empty_openset {S: set \ud835\udd38} (emp : \u00ac nonempty S): openset S :=\n    begin\n        let \u03b1 : S \u2192 F.obj S := empty_map S emp (F.obj S),\n        use \u03b1,\n        exact empty_hom_dom (inclusion S) emp\n    end\n\ndef is_largest_coalgebra {S : set \ud835\udd38} (P : set S): Prop :=\n    (\u2203 \u03b1 : P \u2192 F.obj P , \n        @is_coalgebra_homomorphism F \u27e8P, \u03b1\u27e9 \ud835\udd38 \n                        ((S \u21aa \ud835\udd38) \u2218 (P \u21aa S))) \u2227 \n        \u2200 P\u2081 : set S, \n    (\u2203 \u03b1 : P\u2081 \u2192 F.obj P\u2081 , \n    @is_coalgebra_homomorphism F \u27e8P\u2081, \u03b1\u27e9 \ud835\udd38 \n                    ((S \u21aa \ud835\udd38) \u2218 (P\u2081 \u21aa S))) \u2192 P\u2081 \u2286 P\n\nnoncomputable def largest_Coalgebra {S : set \ud835\udd38} {P : set S} \n                        (lar : is_largest_coalgebra P):\n    Coalgebra F := \u27e8P , some lar.1\u27e9 \n\n-- lemma largest_subcoalgebra_exists (S : set \ud835\udd38) :\n--     \u2203 P \u2286 S, is_largest_subcoalgebra S P H := \n--         begin\n--             let emp : set \ud835\udd38 := \u2205,\n--             have h : emp \u2286 S := by tidy,\n--             use emp,\n--             use h,\n--             split,\n--             exact empty_is_openset \ud835\udd38,\n--             intros p h op,\n            \n--         end\n\n-- def largest_subcoalgebra_set (S : set \ud835\udd38):\n--     set \ud835\udd38 := some (largest_subcoalgebra_exists S)\n\n-- noncomputable def largest_subcoalgebra (S : set \ud835\udd38): \n--     SubCoalgebra (largest_subcoalgebra_set S) :=\n--     begin\n--         let P : set \ud835\udd38 := some (largest_subcoalgebra_exists S),\n--         have op : openset P := (some_spec (some_spec (largest_subcoalgebra_exists S))).1,\n\n--         let \u03b1 : P \u2192 F.obj P := some op,\n--         have hom : _ := some_spec op,\n\n--         exact \u27e8\u03b1 ,hom\u27e9 \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 \u2192 K)\n\ndef FinVect_K_2: FinVect K := \u27e8\n  K_2 K,\n  by change finite_dimensional K (fin 2 \u2192 K); apply_instance,\n\u27e9\n\n@[simp] def FinVect_dual (V: FinVect K): FinVect K := \u27e8\n  Module.of K (module.dual K V),\n  by change finite_dimensional K (module.dual K V); apply_instance\n\u27e9\n\n@[simp] def FinVect_tensor (X Y: FinVect K): FinVect K := \u27e8\n  Module.of K (tensor_product K X Y),\n  by change finite_dimensional K (tensor_product K X Y); apply_instance\n\u27e9\n\nnamespace Tangle\n\n@[simp] def toFinVect: Tangle \u2192 FinVect K\n  | id := \u27e8Module.of K K, finite_dimensional.finite_dimensional_self K\u27e9\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): \u03a0 {X Y: Tangle}, (X \u27f6\u1d50 Y) \u2192 (X.toFinVect K \u27f6 Y.toFinVect K)\n  | _ _ (\ud835\udfd9 a) := linear_map.id\n  | _ _ (f \u226b g) := functor_map g \u2218\u2097 functor_map f\n  | _ _ (f \u2297\u1d50 g) := tensor_product.map (functor_map f) (functor_map g)\n  | _ _ (\u03b1 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  | _ _ (\u03b1\u207b\u00b9 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  | _ _ (\u2113 a) := begin\n    have f := tensor_product.lid K (a.toFinVect K),\n    exact Module.of_hom f.to_linear_map,\n  end\n  | _ _ (\u2113\u207b\u00b9 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  | _ _ (\u03c1 a) := begin\n    have f := tensor_product.rid K (a.toFinVect K),\n    exact Module.of_hom f.to_linear_map,\n  end\n  | _ _ (\u03c1\u207b\u00b9 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 \u2218\u2097 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 := (\u2193 \u2297\u1d57 \u2193).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 \u2964 FinVect K := {\n  obj := Tangle.toFinVect K,\n  map := begin\n    rintro X Y f, \n  end --by rintro X Y \u27e8f\u27e9; exact functor_map K f,\n}\n\nnamespace test\n\nopen_locale matrix\n\ndef f: fin 3 \u2192 rat := \u03bb i, i + 2 -- (2, 3, 4)\n\n@[simp] def iota (n: \u2115): fin n \u2192 \u2124 := \u03bb 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 _ _ \u27e8i_val_n, h'\u27e9, \nend\n\n@[simp] def mat_id (n: nat): matrix (fin n) (fin n) rat\n  := \u03bb 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]] \u2b1d ![![1, 0], ![0, 1]] = ![![1, 0], ![0, 1]] := begin\n  simp,\nend\n\nexample (n: nat): mat_id n \u2b1d 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\u00f6lzl, 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 : \u2115}\n\nsection CommSemiring\n\nvariable [CommSemiring R]\n\ntheorem X_dvd_iff {f : R[X]} : X \u2223 f \u2194 f.coeff 0 = 0 :=\n  \u27e8fun \u27e8g, hfg\u27e9 => by rw [hfg, mul_comm, coeff_mul_X_zero], fun hf =>\n    \u27e8f.divX, by rw [mul_comm, \u2190 add_zero (f.divX * X), \u2190 C_0, \u2190 hf, divX_mul_X_add]\u27e9\u27e9\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 : \u2115} : X ^ n \u2223 f \u2194 \u2200 d < n, f.coeff d = 0 :=\n  \u27e8fun \u27e8g, hgf\u27e9 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    \u00b7 simp [pow_zero, one_dvd]\n    \u00b7 obtain \u27e8g, hgf\u27e9 := hn fun d : \u2115 => fun H : d < n => hd _ (Nat.lt_succ_of_lt H)\n      have := coeff_X_pow_mul g n 0\n      rw [zero_add, \u2190 hgf, hd n (Nat.lt_succ_self n)] at this\n      obtain \u27e8k, hgk\u27e9 := Polynomial.X_dvd_iff.mpr this.symm\n      use k\n      rwa [pow_succ, mul_comm X _, mul_assoc, \u2190 hgk]\u27e9\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 \u2115) < degree p) (hmp : Monic p)\n    (hq : q \u2260 0) : multiplicity.Finite p q :=\n  have zn0 : (0 : R) \u2260 1 :=\n    haveI := Nontrivial.of_polynomial_ne hq\n    zero_ne_one\n  \u27e8natDegree q, fun \u27e8r, hr\u27e9 => by\n    have hp0 : p \u2260 0 := fun hp0 => by simp [hp0] at hp\n    have hr0 : r \u2260 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) \u2260 0 := hpn1.symm \u25b8 zn0.symm\n    have hpnr0 : leadingCoeff (p ^ (natDegree q + 1)) * leadingCoeff r \u2260 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 [\u2190 WithBot.coe_lt_coe, \u2190 Nat.cast_withBot, \u2190 Nat.cast_withBot,\n        \u2190 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\u27e9\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 \u2264 degree p \u2227 p \u2260 0) (hq : Monic q) :\n    degree (p - C (leadingCoeff p) * X ^ (natDegree p - natDegree q) * q) < degree p :=\n  have hp : leadingCoeff p \u2260 0 := mt leadingCoeff_eq_zero.1 h.2\n  have hq0 : q \u2260 0 := hq.ne_zero_of_polynomial_ne h.2\n  have hlt : natDegree q \u2264 natDegree p :=\n    WithBot.coe_le_coe.1\n      (by rw [\u2190 Nat.cast_withBot, \u2190 Nat.cast_withBot, \u2190 degree_eq_natDegree h.2,\n        \u2190 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, \u2190 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 : \u2200 (_p : R[X]) {q : R[X]}, Monic q \u2192 R[X] \u00d7 R[X]\n  | p, q, hq =>\n    if h : degree q \u2264 degree p \u2227 p \u2260 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      \u27e8z + dm.1, dm.2\u27e9\n    else \u27e80, p\u27e9\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 \" /\u2098 \" => divByMonic\n\n@[inherit_doc]\ninfixl:70 \" %\u2098 \" => modByMonic\n\ntheorem degree_modByMonic_lt [Nontrivial R] :\n    \u2200 (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %\u2098 q) < degree q\n  | p, q, hq =>\n    if h : degree q \u2264 degree p \u2227 p \u2260 0 then by\n      have _wf := div_wf_lemma \u27e8h.1, h.2\u27e9 hq\n      have :\n        degree ((p - C (leadingCoeff p) * X ^ (natDegree p - natDegree q) * q) %\u2098 q) < degree q :=\n        degree_modByMonic_lt (p - C (leadingCoeff p) * X ^ (natDegree p - natDegree q) * q) hq\n      unfold modByMonic at this \u22a2\n      unfold divModByMonicAux\n      dsimp\n      rw [dif_pos hq] at this \u22a2\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 %\u2098 p = 0 := by\n  unfold modByMonic divModByMonicAux\n  dsimp\n  by_cases hp : Monic p\n  \u00b7 rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]\n  \u00b7 rw [dif_neg hp]\n#align polynomial.zero_mod_by_monic Polynomial.zero_modByMonic\n\n@[simp]\ntheorem zero_divByMonic (p : R[X]) : 0 /\u2098 p = 0 := by\n  unfold divByMonic divModByMonicAux\n  dsimp\n  by_cases hp : Monic p\n  \u00b7 rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]\n  \u00b7 rw [dif_neg hp]\n#align polynomial.zero_div_by_monic Polynomial.zero_divByMonic\n\n@[simp]\ntheorem modByMonic_zero (p : R[X]) : p %\u2098 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 /\u2098 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 : \u00acMonic q) : p /\u2098 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 : \u00acMonic q) : p %\u2098 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 %\u2098 q = p \u2194 degree p < degree q :=\n  \u27e8fun h => h \u25b8 degree_modByMonic_lt _ hq, fun h => by\n    have : \u00acdegree q \u2264 degree p := not_le_of_gt h\n    unfold modByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]\u27e9\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 %\u2098 q) \u2264 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    \u2200 (p : R[X]) {q : R[X]} (_hq : Monic q), p %\u2098 q = p - q * (p /\u2098 q)\n  | p, q, hq =>\n    if h : degree q \u2264 degree p \u2227 p \u2260 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 %\u2098 q + q * (p /\u2098 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 /\u2098 q = 0 \u2194 degree p < degree q :=\n  \u27e8fun 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 : \u00acdegree q \u2264 degree p := not_le_of_gt h\n    unfold divByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]\u27e9\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 \u2264 degree p) :\n    degree q + degree (p /\u2098 q) = degree p := by\n  nontriviality R\n  have hdiv0 : p /\u2098 q \u2260 0 := by rwa [Ne.def, divByMonic_eq_zero_iff hq, not_lt]\n  have hlc : leadingCoeff q * leadingCoeff (p /\u2098 q) \u2260 0 := by\n    rwa [Monic.def.1 hq, one_mul, Ne.def, leadingCoeff_eq_zero]\n  have hmod : degree (p %\u2098 q) < degree (q * (p /\u2098 q)) :=\n    calc\n      degree (p %\u2098 q) < degree q := degree_modByMonic_lt _ hq\n      _ \u2264 _ := by\n        rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero, degree_eq_natDegree hdiv0, \u2190\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 /\u2098 q) = degree (q * (p /\u2098 q)) := Eq.symm (degree_mul' hlc)\n    _ = degree (p %\u2098 q + q * (p /\u2098 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 /\u2098 q) \u2264 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 \u2264 degree p then by\n        haveI := Nontrivial.of_polynomial_ne hp0;\n            rw [\u2190 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 \u25b8 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 \u2260 0)\n    (h0q : 0 < degree q) : degree (p /\u2098 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 [\u2190 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 /\u2098 g) = natDegree f - natDegree g := by\n  nontriviality R\n  by_cases hfg : f /\u2098 g = 0\n  \u00b7 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 \u2260 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    \u2190 WithBot.coe_add, WithBot.coe_eq_coe] at this\n  rw [\u2190 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 \u2227 degree r < degree g) : f /\u2098 g = q \u2227 f %\u2098 g = r := by\n  nontriviality R\n  have h\u2081 : r - f %\u2098 g = -g * (q - f /\u2098 g) :=\n    eq_of_sub_eq_zero\n      (by\n        rw [\u2190 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\u2082 : degree (r - f %\u2098 g) = degree (g * (q - f /\u2098 g)) := by simp [h\u2081]\n  have h\u2084 : degree (r - f %\u2098 g) < degree g :=\n    calc\n      degree (r - f %\u2098 g) \u2264 max (degree r) (degree (f %\u2098 g)) := degree_sub_le _ _\n      _ < degree g := max_lt_iff.2 \u27e8h.2, degree_modByMonic_lt _ hg\u27e9\n  have h\u2085 : q - f /\u2098 g = 0 :=\n    _root_.by_contradiction fun hqf =>\n      not_le_of_gt h\u2084 <|\n        calc\n          degree g \u2264 degree g + degree (q - f /\u2098 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 %\u2098 g) := by rw [h\u2082, degree_mul']; simpa [Monic.def.1 hg]\n  exact \u27e8Eq.symm <| eq_of_sub_eq_zero h\u2085, Eq.symm <| eq_of_sub_eq_zero <| by simpa [h\u2085] using h\u2081\u27e9\n#align polynomial.div_mod_by_monic_unique Polynomial.div_modByMonic_unique\n\ntheorem map_mod_divByMonic [CommRing S] (f : R \u2192+* S) (hq : Monic q) :\n    (p /\u2098 q).map f = p.map f /\u2098 q.map f \u2227 (p %\u2098 q).map f = p.map f %\u2098 q.map f := by\n  nontriviality S\n  haveI : Nontrivial R := f.domain_nontrivial\n  have : map f p /\u2098 map f q = map f (p /\u2098 q) \u2227 map f p %\u2098 map f q = map f (p %\u2098 q) :=\n    div_modByMonic_unique ((p /\u2098 q).map f) _ (hq.map f)\n      \u27e8Eq.symm <| by rw [\u2190 Polynomial.map_mul, \u2190 Polynomial.map_add, modByMonic_add_div _ hq],\n        calc\n          _ \u2264 degree (p %\u2098 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)\u27e9\n  exact \u27e8this.1.symm, this.2.symm\u27e9\n#align polynomial.map_mod_div_by_monic Polynomial.map_mod_divByMonic\n\ntheorem map_divByMonic [CommRing S] (f : R \u2192+* S) (hq : Monic q) :\n    (p /\u2098 q).map f = p.map f /\u2098 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 \u2192+* S) (hq : Monic q) :\n    (p %\u2098 q).map f = p.map f %\u2098 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 %\u2098 q = 0 \u2194 q \u2223 p :=\n  \u27e8fun h => by rw [\u2190 modByMonic_add_div p hq, h, zero_add]; exact dvd_mul_right _ _, fun h => by\n    nontriviality R\n    obtain \u27e8r, hr\u27e9 := exists_eq_mul_right_of_dvd h\n    by_contra hpq0\n    have hmod : p %\u2098 q = q * (r - p /\u2098 q) := by rw [modByMonic_eq_sub_mul_div _ hq, mul_sub, \u2190 hr]\n    have : degree (q * (r - p /\u2098 q)) < degree q := hmod \u25b8 degree_modByMonic_lt _ hq\n    have hrpq0 : leadingCoeff (r - p /\u2098 q) \u2260 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 /\u2098 q) \u2260 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)\u27e9\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 \u2192+* S) (hf : Function.Injective f) {x y : R[X]}\n    (hx : x.Monic) : x.map f \u2223 y.map f \u2194 x \u2223 y := by\n  rw [\u2190 dvd_iff_modByMonic_eq_zero hx, \u2190 dvd_iff_modByMonic_eq_zero (hx.map f), \u2190\n    map_modByMonic f hx]\n  exact\n    \u27e8fun H => map_injective f hf <| by rw [H, Polynomial.map_zero], fun H => by\n      rw [H, Polynomial.map_zero]\u27e9\n#align polynomial.map_dvd_map Polynomial.map_dvd_map\n\n@[simp]\ntheorem modByMonic_one (p : R[X]) : p %\u2098 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 /\u2098 1 = p := by\n  conv_rhs => rw [\u2190 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 %\u2098 (X - C a) = C (p.eval a) := by\n  nontriviality R\n  have h : (p %\u2098 (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 %\u2098 (X - C a)) < 1 :=\n    degree_X_sub_C a \u25b8 degree_modByMonic_lt p (monic_X_sub_C a)\n  have : degree (p %\u2098 (X - C a)) \u2264 0 :=\n    by\n    revert this\n    cases degree (p %\u2098 (X - C a))\n    \u00b7 exact fun _ => bot_le\n    \u00b7 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 /\u2098 (X - C a)) = p \u2194 IsRoot p a :=\n  \u27e8fun h => by\n    rw [\u2190 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 [\u2190 modByMonic_add_div p (monic_X_sub_C a)]\n        rw [modByMonic_X_sub_C_eq_C_eval, h, C_0, zero_add]\u27e9\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 \u2223 p \u2194 IsRoot p a :=\n  \u27e8fun h => by\n    rwa [\u2190 dvd_iff_modByMonic_eq_zero (monic_X_sub_C _), modByMonic_X_sub_C_eq_C_eval, \u2190 C_0,\n      C_inj] at h,\n    fun h => \u27e8p /\u2098 (X - C a), by rw [mul_divByMonic_eq_iff_isRoot.2 h]\u27e9\u27e9\n#align polynomial.dvd_iff_is_root Polynomial.dvd_iff_isRoot\n\ntheorem modByMonic_X (p : R[X]) : p %\u2098 X = C (p.eval 0) := by\n  rw [\u2190 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\u2082_modByMonic_eq_self_of_root [CommRing S] {f : R \u2192+* S} {p q : R[X]} (hq : q.Monic)\n    {x : S} (hx : q.eval\u2082 f x = 0) : (p %\u2098 q).eval\u2082 f x = p.eval\u2082 f x := by\n  rw [modByMonic_eq_sub_mul_div p hq, eval\u2082_sub, eval\u2082_mul, hx, MulZeroClass.zero_mul, sub_zero]\n#align polynomial.eval\u2082_mod_by_monic_eq_self_of_root Polynomial.eval\u2082_modByMonic_eq_self_of_root\n\ntheorem sum_modByMonic_coeff (hq : q.Monic) {n : \u2115} (hn : q.degree \u2264 n) :\n    (\u2211 i : Fin n, monomial i ((p %\u2098 q).coeff i)) = p %\u2098 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 \u2223 p.eval a - p.eval b := by\n  suffices X - C b \u2223 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 /\u2098 q = p := by\n  nontriviality R\n  refine' (div_modByMonic_unique _ 0 hmo \u27e8by rw [zero_add], _\u27e9).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 : \u00acIsField 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  \u00b7 rw [bot_lt_iff_ne_bot, Ne.def, Ideal.span_singleton_eq_bot]\n    exact Polynomial.X_ne_zero\n  \u00b7 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 %\u2098 q` and compare to `0`\".\nSee `polynomial.modByMonic` for the algorithm that computes `%\u2098`.\n-/\ndef decidableDvdMonic (p : R[X]) (hq : Monic q) : Decidable (q \u2223 p) :=\n  decidable_of_iff (p %\u2098 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 \u2260 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]) : \u2115 :=\n  if h0 : p = 0 then 0\n  else\n    let _ : DecidablePred fun n : \u2115 => \u00ac(X - C a) ^ (n + 1) \u2223 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 \u2260 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 \u2194 IsRoot p x \u2192 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 : \u00acIsRoot 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 \u2194 p \u2260 0 \u2227 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 \u2260 0) {x : R} :\n    0 < rootMultiplicity x p \u2194 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 \u2223 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 /\u2098 (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 [\u2190 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 \u2260 0) :\n    eval a (p /\u2098 (X - C a) ^ rootMultiplicity a p) \u2260 0 := by\n  haveI : Nontrivial R := Nontrivial.of_polynomial_ne hp\n  rw [Ne.def, \u2190 IsRoot.def, \u2190 dvd_iff_isRoot]\n  rintro \u27e8q, hq\u27e9\n  have := divByMonic_mul_pow_rootMultiplicity_eq p a\n  rw [mul_comm, hq, \u2190 mul_assoc, \u2190 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 \u2115) < 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\u2081 w\u2082 v\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable section\n\nopen CategoryTheory\n\nnamespace CategoryTheory.Limits\n\nvariable (J : Type u\u2082) [Category.{v\u2082} J] (C : Type u\u2081) [Category.{v\u2081} C]\n\n#print CategoryTheory.Limits.hasLimitsOfShape_of_essentiallySmall /-\ntheorem hasLimitsOfShape_of_essentiallySmall [EssentiallySmall.{w\u2081} J]\n    [HasLimitsOfSize.{w\u2081, w\u2081} C] : HasLimitsOfShape J C :=\n  hasLimitsOfShape_of_equivalence <| Equivalence.symm <| equivSmallModel.{w\u2081} 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\u2081} J]\n    [HasColimitsOfSize.{w\u2081, w\u2081} C] : HasColimitsOfShape J C :=\n  hasColimitsOfShape_of_equivalence <| Equivalence.symm <| equivSmallModel.{w\u2081} 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 (\u03b2 : Type w\u2082) [Small.{w\u2081} \u03b2] [HasProducts.{w\u2081} C] :\n    HasProductsOfShape \u03b2 C :=\n  hasLimitsOfShape_of_equivalence <| Discrete.equivalence <| Equiv.symm <| equivShrink \u03b2\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 (\u03b2 : Type w\u2082) [Small.{w\u2081} \u03b2] [HasCoproducts.{w\u2081} C] :\n    HasCoproductsOfShape \u03b2 C :=\n  hasColimitsOfShape_of_equivalence <| Discrete.equivalence <| Equiv.symm <| equivShrink \u03b2\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": "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 `\u00ac P` for some proposition `P`.\nIt should use this contradiction to close the goal.\n\nBonus: handle `P \u2192 false` as well as `\u00ac 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 :=\nadmit -- change this\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hnq : \u00ac Q) : false :=\nby contr\n\n\nexample (P Q R : Prop) (hnq : \u00ac Q) (hp : P) (hq : Q) (hr : \u00ac R) : 0 = 1 :=\nby contr\n\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hnq : Q \u2192 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 `\u2115`\n(presumably with some arguments), e.g. `nat.add : \u2115 \u2192 \u2115 \u2192 \u2115`\nor `list.length : \u03a0 \u03b1 : Type, list \u03b1 \u2192 \u2115`.\nIt should add a new declaration to the environment which proves all applications\nof this function are nonnegative,\ne.g. `nat.add_nonneg : \u2200 m n : \u2115, 0 \u2264 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 : \u211a) (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 : \u211a) (h : q / (3 / 4) > 0) : false :=\nbegin\n  -- cancel_denoms at h,\n  sorry\nend\n\nexample (p q : \u211a) (h : q / 2 / 3 < q) : false :=\nbegin\n  -- cancel_denoms at h,\n  sorry\nend\n\nexample (p q : \u211a) (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 : \u211a) (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": "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/monday/metaprogramming.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6039318337259583, "lm_q2_score": 0.8104789132480439, "lm_q1q2_score": 0.489474016274113}}
{"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\u00f6lzl\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 (\u03b1 : Type u_1) [ring \u03b1] [uniform_space \u03b1] : HasOne (completion \u03b1) :=\n  { one := \u21911 }\n\nprotected instance has_mul (\u03b1 : Type u_1) [ring \u03b1] [uniform_space \u03b1] : Mul (completion \u03b1) :=\n  { mul := function.curry (dense_inducing.extend sorry (coe \u2218 function.uncurry Mul.mul)) }\n\ntheorem coe_one (\u03b1 : Type u_1) [ring \u03b1] [uniform_space \u03b1] : \u21911 = 1 :=\n  rfl\n\ntheorem coe_mul {\u03b1 : Type u_1} [ring \u03b1] [uniform_space \u03b1] [topological_ring \u03b1] (a : \u03b1) (b : \u03b1) : \u2191(a * b) = \u2191a * \u2191b :=\n  Eq.symm\n    (dense_inducing.extend_eq (dense_inducing.prod dense_inducing_coe dense_inducing_coe)\n      (continuous.comp (continuous_coe \u03b1) continuous_mul) (a, b))\n\ntheorem continuous_mul {\u03b1 : Type u_1} [ring \u03b1] [uniform_space \u03b1] [topological_ring \u03b1] [uniform_add_group \u03b1] : continuous fun (p : completion \u03b1 \u00d7 completion \u03b1) => prod.fst p * prod.snd p := sorry\n\ntheorem continuous.mul {\u03b1 : Type u_1} [ring \u03b1] [uniform_space \u03b1] [topological_ring \u03b1] [uniform_add_group \u03b1] {\u03b2 : Type u_2} [topological_space \u03b2] {f : \u03b2 \u2192 completion \u03b1} {g : \u03b2 \u2192 completion \u03b1} (hf : continuous f) (hg : continuous g) : continuous fun (b : \u03b2) => f b * g b :=\n  continuous.comp continuous_mul (continuous.prod_mk hf hg)\n\nprotected instance ring {\u03b1 : Type u_1} [ring \u03b1] [uniform_space \u03b1] [topological_ring \u03b1] [uniform_add_group \u03b1] : ring (completion \u03b1) :=\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 {\u03b1 : Type u_1} [ring \u03b1] [uniform_space \u03b1] [topological_ring \u03b1] [uniform_add_group \u03b1] : \u03b1 \u2192+* completion \u03b1 :=\n  ring_hom.mk coe (coe_one \u03b1) sorry sorry sorry\n\n/-- The completion extension as a ring morphism. -/\ndef extension_hom {\u03b1 : Type u_1} [ring \u03b1] [uniform_space \u03b1] [topological_ring \u03b1] [uniform_add_group \u03b1] {\u03b2 : Type u} [uniform_space \u03b2] [ring \u03b2] [uniform_add_group \u03b2] [topological_ring \u03b2] (f : \u03b1 \u2192+* \u03b2) (hf : continuous \u21d1f) [complete_space \u03b2] [separated_space \u03b2] : completion \u03b1 \u2192+* \u03b2 :=\n  (fun (hf : uniform_continuous \u21d1f) => ring_hom.mk (completion.extension \u21d1f) sorry sorry sorry sorry) sorry\n\nprotected instance top_ring_compl {\u03b1 : Type u_1} [ring \u03b1] [uniform_space \u03b1] [topological_ring \u03b1] [uniform_add_group \u03b1] : topological_ring (completion \u03b1) :=\n  topological_ring.mk continuous_neg\n\n/-- The completion map as a ring morphism. -/\ndef map_ring_hom {\u03b1 : Type u_1} [ring \u03b1] [uniform_space \u03b1] [topological_ring \u03b1] [uniform_add_group \u03b1] {\u03b2 : Type u} [uniform_space \u03b2] [ring \u03b2] [uniform_add_group \u03b2] [topological_ring \u03b2] (f : \u03b1 \u2192+* \u03b2) (hf : continuous \u21d1f) : completion \u03b1 \u2192+* completion \u03b2 :=\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 (\u03b1 : Type u_1) [comm_ring \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [topological_ring \u03b1] : separation_setoid \u03b1 = submodule.quotient_rel (ideal.closure \u22a5) :=\n  setoid.ext fun (x y : \u03b1) => group_separation_rel x y\n\ntheorem ring_sep_quot (\u03b1 : Type u_1) [r : comm_ring \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [topological_ring \u03b1] : quotient (separation_setoid \u03b1) = ideal.quotient (ideal.closure \u22a5) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (quotient (separation_setoid \u03b1) = ideal.quotient (ideal.closure \u22a5))) (ring_sep_rel \u03b1)))\n    (Eq.refl (quotient (submodule.quotient_rel (ideal.closure \u22a5))))\n\n/-- Given a topological ring `\u03b1` equipped with a uniform structure that makes subtraction uniformly\ncontinuous, get an equivalence between the separated quotient of `\u03b1` and the quotient ring\ncorresponding to the closure of zero. -/\ndef sep_quot_equiv_ring_quot (\u03b1 : Type u_1) [r : comm_ring \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [topological_ring \u03b1] : quotient (separation_setoid \u03b1) \u2243 ideal.quotient (ideal.closure \u22a5) :=\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 {\u03b1 : Type u_1} [comm_ring \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [topological_ring \u03b1] : comm_ring (quotient (separation_setoid \u03b1)) :=\n  eq.mpr sorry (ideal.quotient.comm_ring (ideal.closure \u22a5))\n\nprotected instance topological_ring {\u03b1 : Type u_1} [comm_ring \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [topological_ring \u03b1] : topological_ring (quotient (separation_setoid \u03b1)) := 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 (\ud835\udd5c : Type*) {E : Type*} [is_R_or_C \ud835\udd5c] [inner_product_space \ud835\udd5c E]\nvariables {\u03b9 : Type*} [linear_order \u03b9] [locally_finite_order_bot \u03b9] [is_well_order \u03b9 (<)]\n\nlocal attribute [instance] is_well_order.to_has_well_founded\n\nlocal notation `\u27ea`x`, `y`\u27eb` := @inner \ud835\udd5c _ _ x y\n\nlemma repr_gram_schmidt_diagonal {i : \u03b9} (b : basis \u03b9 \ud835\udd5c E) :\n  b.repr (gram_schmidt \ud835\udd5c 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 \ud835\udd5c 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 \u03b1) \u03c3`).\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 \u03b1 \u03c3` is a realization of a filter (base) on `\u03b1`,\n  represented by a type `\u03c3` together with operations for the top element and\n  the binary `inf` operation. -/\nstructure CFilter (\u03b1 \u03c3 : Type _) [PartialOrder \u03b1] where\n  f : \u03c3 \u2192 \u03b1\n  pt : \u03c3\n  inf : \u03c3 \u2192 \u03c3 \u2192 \u03c3\n  inf_le_left : \u2200 a b : \u03c3, f (inf a b) \u2264 f a\n  inf_le_right : \u2200 a b : \u03c3, f (inf a b) \u2264 f b\n#align cfilter CFilter\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03c3 : Type _} {\u03c4 : Type _}\n\ninstance [Inhabited \u03b1] [SemilatticeInf \u03b1] : Inhabited (CFilter \u03b1 \u03b1) :=\n  \u27e8{  f := id\n      pt := default\n      inf := (\u00b7 \u2293 \u00b7)\n      inf_le_left := fun _ _ \u21a6 inf_le_left\n      inf_le_right := fun _ _ \u21a6 inf_le_right }\u27e9\n\nnamespace CFilter\n\nsection\n\nvariable [PartialOrder \u03b1] (F : CFilter \u03b1 \u03c3)\n\ninstance : CoeFun (CFilter \u03b1 \u03c3) fun _ \u21a6 \u03c3 \u2192 \u03b1 :=\n  \u27e8CFilter.f\u27e9\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\u2081 h\u2082 a) : (@CFilter.mk \u03b1 \u03c3 _ f pt inf h\u2081 h\u2082) 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 : \u03c3 \u2243 \u03c4) : CFilter \u03b1 \u03c3 \u2192 CFilter \u03b1 \u03c4\n  | \u27e8f, p, g, h\u2081, h\u2082\u27e9 =>\n    { f := fun a \u21a6 f (E.symm a)\n      pt := E p\n      inf := fun a b \u21a6 E (g (E.symm a) (E.symm b))\n      inf_le_left := fun a b \u21a6 by simpa using h\u2081 (E.symm a) (E.symm b)\n      inf_le_right := fun a b \u21a6 by simpa using h\u2082 (E.symm a) (E.symm b) }\n#align cfilter.of_equiv CFilter.ofEquiv\n\n@[simp]\ntheorem ofEquiv_val (E : \u03c3 \u2243 \u03c4) (F : CFilter \u03b1 \u03c3) (a : \u03c4) : 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 \u03b1) \u03c3) : Filter \u03b1 where\n  sets := { a | \u2203 b, F b \u2286 a }\n  univ_sets := \u27e8F.pt, subset_univ _\u27e9\n  sets_of_superset := fun \u27e8b, h\u27e9 s \u21a6 \u27e8b, Subset.trans h s\u27e9\n  inter_sets := fun \u27e8a, h\u2081\u27e9 \u27e8b, h\u2082\u27e9 \u21a6 \u27e8F.inf a b,\n    subset_inter (Subset.trans (F.inf_le_left _ _) h\u2081) (Subset.trans (F.inf_le_right _ _) h\u2082)\u27e9\n#align cfilter.to_filter CFilter.toFilter\n\n@[simp]\ntheorem mem_toFilter_sets (F : CFilter (Set \u03b1) \u03c3) {a : Set \u03b1} : a \u2208 F.toFilter \u2194 \u2203 b, F b \u2286 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 \u03b1) where\n  \u03c3 : Type _\n  F : CFilter (Set \u03b1) \u03c3\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 \u03b1) \u03c3) : F.toFilter.Realizer :=\n  \u27e8\u03c3, F, rfl\u27e9\n#align cfilter.to_realizer CFilter.toRealizer\n\nnamespace Filter.Realizer\n\ntheorem mem_sets {f : Filter \u03b1} (F : f.Realizer) {a : Set \u03b1} : a \u2208 f \u2194 \u2203 b, F.F b \u2286 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 \u03b1} (e : f = g) (F : f.Realizer) : g.Realizer :=\n  \u27e8F.\u03c3, F.F, F.eq.trans e\u27e9\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 \u03b1) : f.Realizer :=\n  \u27e8f.sets,\n    { f := Subtype.val\n      pt := \u27e8univ, univ_mem\u27e9\n      inf := fun \u27e8_, h\u2081\u27e9 \u27e8_, h\u2082\u27e9 \u21a6 \u27e8_, inter_mem h\u2081 h\u2082\u27e9\n      inf_le_left := fun \u27e8x, _\u27e9 \u27e8y, _\u27e9 \u21a6 inter_subset_left x y\n      inf_le_right := fun \u27e8x, _\u27e9 \u27e8y, _\u27e9 \u21a6 inter_subset_right x y },\n    filter_eq <| Set.ext fun _ \u21a6 by simp [exists_mem_subset_iff]\u27e9\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 \u03b1} (F : f.Realizer) (E : F.\u03c3 \u2243 \u03c4) : f.Realizer :=\n  \u27e8\u03c4, F.F.ofEquiv E, by\n    refine' Eq.trans _ F.eq\n    exact filter_eq (Set.ext fun _ \u21a6\n      \u27e8fun \u27e8s, h\u27e9 \u21a6 \u27e8E.symm s, by simpa using h\u27e9, fun \u27e8t, h\u27e9 \u21a6 \u27e8E t, by simp [h]\u27e9\u27e9)\u27e9\n#align filter.realizer.of_equiv Filter.Realizer.ofEquiv\n\n@[simp]\ntheorem ofEquiv_\u03c3 {f : Filter \u03b1} (F : f.Realizer) (E : F.\u03c3 \u2243 \u03c4) : (F.ofEquiv E).\u03c3 = \u03c4 :=\n  rfl\n#align filter.realizer.of_equiv_\u03c3 Filter.Realizer.ofEquiv_\u03c3\n\n@[simp]\ntheorem ofEquiv_F {f : Filter \u03b1} (F : f.Realizer) (E : F.\u03c3 \u2243 \u03c4) (s : \u03c4) :\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 \u03b1) : (principal s).Realizer :=\n  \u27e8Unit,\n    { f := fun _ \u21a6 s\n      pt := ()\n      inf := fun _ _ \u21a6 ()\n      inf_le_left := fun _ _ \u21a6 le_rfl\n      inf_le_right := fun _ _ \u21a6 le_rfl },\n    filter_eq <| Set.ext fun _ \u21a6 \u27e8fun \u27e8_, s\u27e9 \u21a6 s, fun h \u21a6 \u27e8(), h\u27e9\u27e9\u27e9\n#align filter.realizer.principal Filter.Realizer.principal\n\n@[simp]\n\n\n@[simp]\ntheorem principal_F (s : Set \u03b1) (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 \u03b1) : Inhabited (principal s).Realizer :=\n  \u27e8Realizer.principal s\u27e9\n\n/-- `Unit` is a realizer for the top filter -/\nprotected def top : (\u22a4 : Filter \u03b1).Realizer :=\n  (Realizer.principal _).ofEq principal_univ\n#align filter.realizer.top Filter.Realizer.top\n\n@[simp]\ntheorem top_\u03c3 : (@Realizer.top \u03b1).\u03c3 = Unit :=\n  rfl\n#align filter.realizer.top_\u03c3 Filter.Realizer.top_\u03c3\n\n@[simp]\ntheorem top_F (u : Unit) : (@Realizer.top \u03b1).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 : (\u22a5 : Filter \u03b1).Realizer :=\n  (Realizer.principal _).ofEq principal_empty\n#align filter.realizer.bot Filter.Realizer.bot\n\n@[simp]\ntheorem bot_\u03c3 : (@Realizer.bot \u03b1).\u03c3 = Unit :=\n  rfl\n#align filter.realizer.bot_\u03c3 Filter.Realizer.bot_\u03c3\n\n@[simp]\ntheorem bot_F (u : Unit) : (@Realizer.bot \u03b1).F u = \u2205 :=\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 : \u03b1 \u2192 \u03b2) {f : Filter \u03b1} (F : f.Realizer) : (map m f).Realizer :=\n  \u27e8F.\u03c3,\n    { f := fun s \u21a6 image m (F.F s)\n      pt := F.F.pt\n      inf := F.F.inf\n      inf_le_left := fun _ _ \u21a6 image_subset _ (F.F.inf_le_left _ _)\n      inf_le_right := fun _ _ \u21a6 image_subset _ (F.F.inf_le_right _ _) },\n    filter_eq <| Set.ext fun _ \u21a6 by\n      simp only [CFilter.toFilter, image_subset_iff, mem_setOf_eq, Filter.mem_sets, mem_map]\n      rw [F.mem_sets]\u27e9\n#align filter.realizer.map Filter.Realizer.map\n\n@[simp]\ntheorem map_\u03c3 (m : \u03b1 \u2192 \u03b2) {f : Filter \u03b1} (F : f.Realizer) : (F.map m).\u03c3 = F.\u03c3 :=\n  rfl\n#align filter.realizer.map_\u03c3 Filter.Realizer.map_\u03c3\n\n@[simp]\ntheorem map_F (m : \u03b1 \u2192 \u03b2) {f : Filter \u03b1} (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 : \u03b1 \u2192 \u03b2) {f : Filter \u03b2} (F : f.Realizer) : (comap m f).Realizer :=\n  \u27e8F.\u03c3,\n    { f := fun s \u21a6 preimage m (F.F s)\n      pt := F.F.pt\n      inf := F.F.inf\n      inf_le_left := fun _ _ \u21a6 preimage_mono (F.F.inf_le_left _ _)\n      inf_le_right := fun _ _ \u21a6 preimage_mono (F.F.inf_le_right _ _) },\n    filter_eq <| Set.ext fun _ \u21a6 by\n      cases F ; subst f\n      exact \u27e8fun \u27e8s, h\u27e9 \u21a6 \u27e8_, \u27e8s, Subset.refl _\u27e9, h\u27e9,\n        fun \u27e8_, \u27e8s, h\u27e9, h\u2082\u27e9 \u21a6 \u27e8s, Subset.trans (preimage_mono h) h\u2082\u27e9\u27e9\u27e9\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 \u03b1} (F : f.Realizer) (G : g.Realizer) : (f \u2294 g).Realizer :=\n  \u27e8F.\u03c3 \u00d7 G.\u03c3,\n    { f := fun \u27e8s, t\u27e9 \u21a6 F.F s \u222a G.F t\n      pt := (F.F.pt, G.F.pt)\n      inf := fun \u27e8a, a'\u27e9 \u27e8b, b'\u27e9 \u21a6 (F.F.inf a b, G.F.inf a' b')\n      inf_le_left := fun _ _ \u21a6 union_subset_union (F.F.inf_le_left _ _) (G.F.inf_le_left _ _)\n      inf_le_right := fun _ _ \u21a6 union_subset_union (F.F.inf_le_right _ _) (G.F.inf_le_right _ _) },\n    filter_eq <| Set.ext fun _ \u21a6 by cases F ; cases G ; substs f g ; simp [CFilter.toFilter]\u27e9\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 \u03b1} (F : f.Realizer) (G : g.Realizer) : (f \u2293 g).Realizer :=\n  \u27e8F.\u03c3 \u00d7 G.\u03c3,\n    { f := fun \u27e8s, t\u27e9 \u21a6 F.F s \u2229 G.F t\n      pt := (F.F.pt, G.F.pt)\n      inf := fun \u27e8a, a'\u27e9 \u27e8b, b'\u27e9 \u21a6 (F.F.inf a b, G.F.inf a' b')\n      inf_le_left := fun _ _ \u21a6 inter_subset_inter (F.F.inf_le_left _ _) (G.F.inf_le_left _ _)\n      inf_le_right := fun _ _ \u21a6 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    \u00b7 rintro \u27e8s, t, h\u27e9\n      apply mem_inf_of_inter _ _ h\n      use s\n      use t\n    \u00b7 rintro \u27e8_, \u27e8a, ha\u27e9, _, \u27e8b, hb\u27e9, rfl\u27e9\n      exact \u27e8a, b, inter_subset_inter ha hb\u27e9\u27e9\n#align filter.realizer.inf Filter.Realizer.inf\n\n/-- Construct a realizer for the cofinite filter -/\nprotected def cofinite [DecidableEq \u03b1] : (@cofinite \u03b1).Realizer :=\n  \u27e8Finset \u03b1,\n    { f := fun s \u21a6 { a | a \u2209 s }\n      pt := \u2205\n      inf := (\u00b7 \u222a \u00b7)\n      inf_le_left := fun _ _ _ \u21a6 mt (Finset.mem_union_left _)\n      inf_le_right := fun _ _ _ \u21a6 mt (Finset.mem_union_right _) },\n    filter_eq <|\n      Set.ext fun _ \u21a6\n        \u27e8fun \u27e8s, h\u27e9 \u21a6 s.finite_toSet.subset (compl_subset_comm.1 h), fun h \u21a6\n          \u27e8h.toFinset, by simp [Subset.rfl]\u27e9\u27e9\u27e9\n#align filter.realizer.cofinite Filter.Realizer.cofinite\n\n/-- Construct a realizer for filter bind -/\nprotected def bind {f : Filter \u03b1} {m : \u03b1 \u2192 Filter \u03b2} (F : f.Realizer) (G : \u2200 i, (m i).Realizer) :\n    (f.bind m).Realizer :=\n  \u27e8\u03a3s : F.\u03c3, \u2200 i \u2208 F.F s, (G i).\u03c3,\n    { f := fun \u27e8s, f\u27e9 \u21a6 \u22c3 i \u2208 F.F s, (G i).F (f i (by assumption))\n      pt := \u27e8F.F.pt, fun i _ \u21a6 (G i).F.pt\u27e9\n      inf := fun \u27e8a, f\u27e9 \u27e8b, f'\u27e9 \u21a6\n        \u27e8F.F.inf a b, fun i h \u21a6\n          (G i).F.inf (f i (F.F.inf_le_left _ _ h)) (f' i (F.F.inf_le_right _ _ h))\u27e9\n      inf_le_left := fun _ _ _ \u21a6 by\n        simp only [mem_union\u1d62, forall_exists_index]\n        exact fun i h\u2081 h\u2082 \u21a6 \u27e8i, F.F.inf_le_left _ _ h\u2081, (G i).F.inf_le_left _ _ h\u2082\u27e9\n      inf_le_right := fun _ _ _ \u21a6 by\n        simp only [mem_union\u1d62, forall_exists_index]\n        exact fun i h\u2081 h\u2082 \u21a6 \u27e8i, F.F.inf_le_right _ _ h\u2081, (G i).F.inf_le_right _ _ h\u2082\u27e9 },\n    filter_eq <| Set.ext fun _ \u21a6 by\n      cases' F with _ F _ ; subst f\n      simp only [CFilter.toFilter, union\u1d62_subset_iff, Sigma.exists, Filter.mem_sets, mem_bind]\n      exact\n        \u27e8fun \u27e8s, f, h\u27e9 \u21a6\n          \u27e8F s, \u27e8s, Subset.refl _\u27e9, fun i H \u21a6 (G i).mem_sets.2 \u27e8f i H, fun _ h' \u21a6 h i H h'\u27e9\u27e9,\n          fun \u27e8_, \u27e8s, h\u27e9, f\u27e9 \u21a6\n          let \u27e8f', h'\u27e9 := Classical.axiom_of_choice fun i : F s \u21a6 (G i).mem_sets.1 (f i (h i.2))\n          \u27e8s, fun i h \u21a6 f' \u27e8i, h\u27e9, fun _ H _ m \u21a6 h' \u27e8_, H\u27e9 m\u27e9\u27e9\u27e9\n#align filter.realizer.bind Filter.Realizer.bind\n\n-- Porting note: `sup\u1d62` had a long dubious translation message. I added `\u2093` to be safe.\n/-- Construct a realizer for indexed supremum -/\nprotected def sup\u1d62 {f : \u03b1 \u2192 Filter \u03b2} (F : \u2200 i, (f i).Realizer) : (\u2a06 i, f i).Realizer :=\n  let F' : (\u2a06 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\u1d62_sets_eq]\n  F'.ofEquiv <|\n    show (\u03a3_ : Unit, \u2200 i : \u03b1, True \u2192 (F i).\u03c3) \u2243 \u2200 i, (F i).\u03c3 from\n      \u27e8fun \u27e8_, f\u27e9 i \u21a6 f i \u27e8\u27e9, fun f \u21a6 \u27e8(), fun i _ \u21a6 f i\u27e9, fun _ \u21a6 rfl, fun _ \u21a6 rfl\u27e9\n#align filter.realizer.Sup Filter.Realizer.sup\u1d62\u2093\n\n/-- Construct a realizer for the product of filters -/\nprotected def prod {f g : Filter \u03b1} (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 \u03b1} (F : f.Realizer) (G : g.Realizer) :\n    f \u2264 g \u2194 \u2200 b : G.\u03c3, \u2203 a : F.\u03c3, F.F a \u2264 G.F b :=\n  \u27e8fun H t \u21a6 F.mem_sets.1 (H (G.mem_sets.2 \u27e8t, Subset.refl _\u27e9)), fun H _ h \u21a6\n    F.mem_sets.2 <|\n      let \u27e8s, h\u2081\u27e9 := G.mem_sets.1 h\n      let \u27e8t, h\u2082\u27e9 := H s\n      \u27e8t, Subset.trans h\u2082 h\u2081\u27e9\u27e9\n#align filter.realizer.le_iff Filter.Realizer.le_iff\n\ntheorem tendsto_iff (f : \u03b1 \u2192 \u03b2) {l\u2081 : Filter \u03b1} {l\u2082 : Filter \u03b2} (L\u2081 : l\u2081.Realizer)\n    (L\u2082 : l\u2082.Realizer) : Tendsto f l\u2081 l\u2082 \u2194 \u2200 b, \u2203 a, \u2200 x \u2208 L\u2081.F a, f x \u2208 L\u2082.F b :=\n  (le_iff (L\u2081.map f) L\u2082).trans <| forall_congr' fun _ \u21a6 exists_congr fun _ \u21a6 image_subset_iff\n#align filter.realizer.tendsto_iff Filter.Realizer.tendsto_iff\n\ntheorem ne_bot_iff {f : Filter \u03b1} (F : f.Realizer) : f \u2260 \u22a5 \u2194 \u2200 a : F.\u03c3, (F.F a).Nonempty := by\n  rw [not_iff_comm, \u2190 le_bot_iff, F.le_iff Realizer.bot, not_forall]\n  simp only [Set.not_nonempty_iff_eq_empty]\n  exact \u27e8fun \u27e8x, e\u27e9 _ \u21a6 \u27e8x, le_of_eq e\u27e9, fun h \u21a6\n    let \u27e8x, h\u27e9 := h ()\n    \u27e8x, le_bot_iff.1 h\u27e9\u27e9\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 `\u2200 x, ...`,\n`\u2203 x, ...` and `\u03bb 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 `\u2200 x, ...`, `\u2203 x, ...` and `\u03bb 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 `\u2190` is applied in the reverse direction.\n  - `simp_rw [lemma_1, ..., lemma_n] at h\u2081 ... h\u2099` will rewrite the given hypotheses.\n  - `simp_rw [...] at \u22a2 h\u2081 ... h\u2099` 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 {\u03b1 \u03b2 : Type} {f : \u03b1 \u2192 \u03b2} {t : set \u03b2} : (\u2200 s, f '' s \u2286 t) = \u2200 s : set \u03b1, \u2200 x \u2208 s, x \u2208 f \u207b\u00b9' 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 `\u211d`\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 `\u211d`, 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 : \u2124} (h : 0 \u2264 d) : \u2124\u221ad \u2192+* \u211d :=\nlift \u27e8real.sqrt d, real.mul_self_sqrt (int.cast_nonneg.mpr h)\u27e9\n\nlemma to_real_injective {d : \u2124} (h0d : 0 \u2264 d) (hd : \u2200 n : \u2124, d \u2260 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} [\ud835\udc9e : category.{v} C] {X Y : C}\ninclude \ud835\udc9e\n\ndef sub' (X : C) := {f : over X // mono f.hom}\ndef le : sub' X \u2192 sub' X \u2192 Prop := \u03bb f g, \u2203 (h : f.1.left \u27f6 g.1.left), f.1.hom = h \u226b g.1.hom\nlemma le_refl : reflexive (@le _ _ X) := \u03bb f, \u27e8\ud835\udfd9 _, (category.id_comp _ _).symm\u27e9\nlemma le_trans : transitive (@le _ _ X) :=\nbegin\n  rintros f g h \u27e8k, r\u27e9 \u27e8l, s\u27e9,\n  refine \u27e8k \u226b l, r.trans _\u27e9,\n  rw s, simp\nend\n\n@[simps]\ndef pullback_sub' [has_pullbacks.{v} C] (f : X \u27f6 Y) (g : sub' Y) : sub' X :=\n\u27e8over.mk (pullback.snd : pullback g.1.hom f \u27f6 X), @pullback.snd_of_mono _ _ _ _ _ _ _ _ g.2\u27e9\n\nlemma pullback_preserves_le' [has_pullbacks.{v} C] (f : X \u27f6 Y) {g\u2081 g\u2082 : sub' Y} (h : le g\u2081 g\u2082) :\n  le (pullback_sub' f g\u2081) (pullback_sub' f g\u2082) :=\nbegin\n  cases h,\n  refine \u27e8_, _\u27e9,\n  refine pullback.lift (pullback.fst \u226b h_w) pullback.snd _,\n  slice_lhs 2 3 {rw \u2190 h_h},\n  apply pullback.condition,\n  dsimp, simp,\nend\n\n@[simps]\ndef postcompose_sub' (f : X \u27f6 Y) [mono f] (g : sub' X) : sub' Y :=\n\u27e8over.mk (g.1.hom \u226b f), begin haveI := g.2, dsimp, apply_instance end\u27e9\n\nlemma postcompose_preserves_le' (f : X \u27f6 Y) [mono f] {g\u2081 g\u2082 : sub' X} (h : le g\u2081 g\u2082) :\n  le (postcompose_sub' f g\u2081) (postcompose_sub' f g\u2082) :=\nbegin\n  cases h with h k,\n  use h,\n  dsimp, simp [k]\nend\n\ndef equiv (X : C) : sub' X \u2192 sub' X \u2192 Prop := \u03bb f g, le f g \u2227 le g f\nlemma equiv_is_equivalence : _root_.equivalence (@equiv _ _ X) :=\nbegin\n  refine \u27e8\u03bb f, \u27e8le_refl _, le_refl _\u27e9, \u03bb f g \u27e8k, l\u27e9, \u27e8l, k\u27e9, \u03bb f g h, _\u27e9,\n  rintro \u27e8a, b\u27e9 \u27e8c, d\u27e9,\n  refine \u27e8le_trans a c, le_trans d b\u27e9,\nend\n\ninstance : setoid (sub' X) := \u27e8equiv X, equiv_is_equivalence\u27e9\ndef sub (X : C) := quotient \u27e8equiv X, equiv_is_equivalence\u27e9\n\ninstance : has_le (sub X) :=\nbegin\n  split,\n  refine quotient.lift\u2082 _ _,\n  exact le,\n  rintros _ _ _ _ \u27e8a\u2081b\u2081, b\u2081a\u2081\u27e9 \u27e8a\u2082b\u2082, b\u2082a\u2082\u27e9,\n  rw eq_iff_iff,\n  split,\n    intro a\u2081a\u2082, apply le_trans b\u2081a\u2081 (le_trans a\u2081a\u2082 a\u2082b\u2082),\n    intro b\u2081b\u2082, apply le_trans a\u2081b\u2081 (le_trans b\u2081b\u2082 b\u2082a\u2082)\nend\n\ninstance : preorder (sub X) :=\n{ le := has_le.le,\n  le_refl := \u03bb Y, quotient.ind le_refl Y,\n  le_trans := \u03bb A B C, begin apply quotient.induction_on\u2083 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\u2082 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 \u27f6 Y) : sub Y \u2192 sub X :=\nbegin\n  refine quotient.lift (\u03bb g, quotient.mk (pullback_sub' f g)) _,\n  rintros a b \u27e8k, l\u27e9,\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 (\ud835\udfd9 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 \u27e8pullback.fst, _\u27e9, dsimp, rw pullback.condition, simp },\n  { dsimp [pullback_sub'],\n    refine \u27e8pullback.lift (\ud835\udfd9 _) a.val.hom _, _\u27e9, dsimp,\n    simp, simp }\nend\nlemma sub_map_comp [has_pullbacks.{v} C] {Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) (x : sub Z) : sub_map (f \u226b 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 \u27e8pullback.lift (pullback.lift pullback.fst (pullback.snd \u226b f) _) pullback.snd _, _\u27e9,\n  rw pullback.condition, simp,\n  simp, simp },\n  { dsimp [pullback_sub'],\n  refine \u27e8pullback.lift (pullback.fst \u226b pullback.fst) pullback.snd _, _\u27e9,\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\u1d52\u1d56 \u2964 Type (max u v) :=\n{ obj := \u03bb X, sub (X.unop),\n  map := \u03bb X Y f, sub_map f.unop,\n  map_id' := \u03bb X,\n  begin\n    ext, apply sub_map_id\n  end,\n  map_comp' := \u03bb 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 \u27f6 Y) [mono f] : sub X \u2192 sub Y :=\nbegin\n  refine quotient.lift (\u03bb g, quotient.mk (postcompose_sub' f g)) _,\n  intros a b k,\n  apply quotient.sound,\n  exact \u27e8postcompose_preserves_le' f k.1, postcompose_preserves_le' f k.2\u27e9,\nend\n-- quotient.map (postcompose_sub' f) (\u03bb a b k, \u27e8postcompose_preserves_le' f k.1, postcompose_preserves_le' f k.2\u27e9)\n\nlemma postcompose_map_id (g : sub X) : postcompose (\ud835\udfd9 X) g = g :=\nbegin\n  apply quotient.induction_on g,\n  intro a,\n  dsimp [postcompose],\n  apply quotient.sound,\n  split,\n  use \ud835\udfd9 _,\n  dsimp [postcompose_sub'], simp,\n  use (\ud835\udfd9 _),\n  dsimp [postcompose_sub'], simp,\nend\n\nlemma postcompose_map_comp {Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) [mono f] [mono g] (h : sub X) : postcompose (f \u226b 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 \u27e8\ud835\udfd9 _, _\u27e9,\n  dsimp, simp,\n  refine \u27e8\ud835\udfd9 _, _\u27e9, dsimp, simp\nend\n\ndef sub_iso_compose (e : X \u2245 Y) : sub X \u2243 sub Y :=\n{ to_fun := postcompose e.hom,\n  inv_fun := postcompose e.inv,\n  left_inv :=\n  begin\n    intro g,\n    rw \u2190 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 \u2190 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 \u27f6 Y) (g : X \u27f6 Z) (h : Y \u27f6 W) (k : Z \u27f6 W) [mono h] [mono g] (comm : f \u226b h = g \u226b 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 \u27e8_, _\u27e9,\n  apply pullback.lift pullback.fst (pullback.snd \u226b g) _,\n  slice_rhs 2 3 {rw \u2190 comm},\n  dsimp [postcompose_sub'],\n  slice_lhs 1 2 {rw pullback.condition}, rw category.assoc,\n  dsimp, rw limit.lift_\u03c0,\n  refl,\n  apply pullback.lift pullback.fst _ _,\n  apply t.lift (pullback_cone.mk (pullback.fst \u226b a.val.hom) pullback.snd _),\n  rw \u2190 pullback.condition,\n  rw category.assoc, refl,\n  erw t.fac (pullback_cone.mk (pullback.fst \u226b a.val.hom) pullback.snd _) walking_cospan.left, refl,\n  dsimp,\n  rw \u2190 category.assoc,\n  rw limit.lift_\u03c0, 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 : \u2115) (x : \u2115) (h : coprime p x) : is_unit (x : \u2124_[p]) :=\nbegin\n  -- prove the contrapositive\n  have h1 : \u00ac is_unit (x : \u2124_[p]) \u2192 \u00ac 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 : \u00ac is_unit (x : \u2124_[p]) \u2192 \u00ac (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 : \u00ac is_unit (x : \u2124_[p]) \u2192 norm_p x < 1, from sorry,\n  -- but this must imply that $p | x$\n  have h4 : \u00ac is_unit (x : \u2124_[p]) \u2192 p \u2223 x, from sorry,\n  -- this completes our proof.\n  show is_unit (x : \u2124_[p]), from sorry,\nend\n\n--OUTPUT 2\ntheorem p_adic_units (p : \u2115) (x : \u2115) : coprime p x \u2192 is_unit (x : \u2124_[p]) :=\nbegin\n  -- prove the contrapositive\n  assume h1 : \u00ac is_unit (x : \u2124_[p]),\n  have h2 : \u00ac coprime p x, from sorry,\n  show coprime p x \u2192 is_unit (x : \u2124_[p]), from sorry,\nend\n\n--OUTPUT 3\ntheorem p_adic_units (p : \u2115) (x : \u2115) (h : coprime p x) : x \u2208 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 : (\u2200 (x : p_adic_int p), x \u2208 units (p_adic_int p) \u2194 x.val = 1) \u2227 (\u2200 (x : p_adic_int p), x.val \u2264 1), from sorry,\n  have h2 : x \u2209 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 : \u2203 (k : \u2115), k * p = x, from sorry,\n  have h5 : p \u2223 x, from sorry,\n\n  -- This completes our proof.\n  show x \u2208 units (p_adic_int p), from sorry,\nend\n\n--OUTPUT 4\ntheorem p_adic_units (p : \u2115) (x : \u2115) (h : coprime p x) : x \u2208 units (\u2124 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 \u2209 units (\u2124 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 \u2260 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 \u2223 x, from sorry,\n  -- This completes our proof.\n  show false, from sorry,\nend\n\n--OUTPUT 5\ntheorem p_adic_units (p : \u2115) (x : \u2115) (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 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac coprime p x, from sorry,\n  have h2 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h3 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h4 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h5 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h6 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h7 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h8 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h9 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h10 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h11 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h12 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h13 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h14 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h15 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h16 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h17 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h18 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h19 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h20 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h21 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h22 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h23 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h24 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h25 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h26 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h27 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h28 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h29 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h30 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h31 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h32 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h33 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h34 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h35 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h36 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h37 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h38 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115, a \u2223 b \u2192 a \u2223 p \u2192 a \u2223 1), from sorry,\n  have h39 : \u00ac is_unit (int.nat_abs x) \u2192 \u00ac (\u2200 a b : \u2115,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem p_adic_units (p : \u2115) (x : \u2115) (h : x.coprime p) : x \u2208 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 : \u00ac (x \u2208 units (padic_int p)) \u2192 \u00ac x.coprime p, from sorry,\n  have h2 : \u00ac x.coprime p, from sorry,\n  have h3 : \u00ac (x \u2208 units (padic_int p)), from sorry,\n  show x \u2208 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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 : \u211d} (hk\u2080 : 0 \u2264 k) (hk\u2081 : k < 1) :\n  (* k) \u2264\u1da0[at_top] (\u03bb x, x - 1) :=\nbegin\n  rw [eventually_le, eventually_at_top],\n  refine \u27e8(1 - k)\u207b\u00b9, \u03bb b hb, _\u27e9,\n  suffices : b * k \u2264 b * 1 - 1,\n  { rwa mul_one at this },\n  rw [\u2190 sub_nonneg, sub_sub, sub_add_eq_sub_sub_swap, \u2190 mul_sub, sub_nonneg],\n  refine (inv_pos_le_iff_one_le_mul _).mp hb,\n  linarith,\nend\n\nexample {k : \u211d} (hk\u2080 : 0 \u2264 k) (hk\u2081 : k < 1) :\n  (* k) \u2264\u1da0[at_top] (\u03bb x, \u230ax\u230b) :=\neventually_le.trans (l1 hk\u2080 hk\u2081) $ \n  eventually_of_forall (\u03bb 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 \u2192 Prop} [decidable_pred is_quorum]\n          [quorum_assumption is_quorum] {vals : pid_t \u2192 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  \u2203 (possible_voters : finset pid_t), is_quorum possible_voters \u2227\n     \u2200 voter \u2208 possible_voters, voted_ballot s voter b \u2228 (s.procs voter).curr \u2264 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  \u2203 (voters : finset pid_t), is_quorum voters \u2227\n     \u2200 voter \u2208 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  \u2203 (b : ballot pid_t), proposed s b v \u2227 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  \u2200 (v v' : value_t), chosen s v \u2192 chosen s v' \u2192 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 \u2192 choosable s b :=\nbegin\nrintros \u27e8voters, quorum, all_voted\u27e9,\nexact \u27e8voters, quorum, by { intros voter hyp_voter, left, exact all_voted voter hyp_voter }\u27e9\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 \u2192 choosable w b \u2192 choosable u b :=\nbegin\nintro u_pn_w,\nrcases (show _, by exact u_pn_w) with \u27e8receiver, sender, e, he, deliverable, proc_change, ntwk_change, proc_same, ntwk_same\u27e9,\nrintros \u27e8possible_voter, quorum, may_vote_at_w\u27e9,\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 \u27e8v, hv, v_is_vote\u27e9,\ncases decidable.em (voter = receiver),\nswap,\n{ rw ntwk_same voter h at hv,\n  left, exact \u27e8v, hv, v_is_vote\u27e9 },\nclear proc_same ntwk_same,\nrw \u2190 h at proc_change ntwk_change deliverable,\nclear h receiver,\nrw ntwk_change at hv,\ncases hv,\n{ left, exact \u27e8v, hv, v_is_vote\u27e9 },\ncases p2b_emitted v_is_vote hv with proposal_step acceptor_step,\n{ right, apply le_of_eq,\n  rcases proposal_step with \u27e8_, _, _, _, _, v_is\u27e9,\n  rw v_is at v_is_vote,\n  injection v_is_vote },\nright,\nrcases acceptor_step with \u27e8p, e_is_proposal, prop_bal_larger\u27e9,\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  (\u03bb (s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t)),\n    \u2200 (b : ballot pid_t) (v : value_t),\n      chosen_ballot s b \u2192 proposed s b v \u2192\n      \u2200 (b' > b) (v' : value_t),\n        proposed s b' v' \u2192 v = v') :=\nbegin\nsuffices fact : \u2200 (b\u2081 : ballot pid_t) (v\u2081 : value_t), predicate.invariant\n    (\u03bb (s : sys_state pid_t (server pid_t value_t is_quorum vals) (message pid_t value_t)),\n      choosable s b\u2081 \u2192\n        proposed s b\u2081 v\u2081 \u2192\n         \u2200 (b\u2082 : ballot pid_t), b\u2082 > b\u2081 \u2192 \u2200 (v\u2082 : value_t), proposed s b\u2082 v\u2082 \u2192 v\u2081 = v\u2082),\nby { intros s s_r b\u2081 v\u2081 cond, exact fact b\u2081 v\u2081 s s_r (chosen_imp_choosable cond) },\nintros b\u2081 v\u2081,\nrw predicate.use_any_invariant,\nsplit,\n{ intros s hs __,\n  rintros \u27e8proposer, proposed_by_proposer\u27e9,\n  exfalso,\n  exact none_proposed_at_init s hs b\u2081 proposer \u27e8v\u2081, proposed_by_proposer\u27e9 },\nintros u w u_r hu u_pn_w w_r b\u2081_choosable_w b\u2081_v\u2081_proposed_w b\u2082 ballot_order v\u2082 b\u2082_v\u2082_proposed_w,\nrcases (show _, by exact u_pn_w) with\n  \u27e8receiver, sender, e, he, deliverable, proc_change, ntwk_change, procs_same, ntwks_same\u27e9,\nhave b\u2081_choosable : choosable u b\u2081 := choosable_reverse_stable u_pn_w b\u2081_choosable_w,\nhave already_proposed_or_currently_proposed : proposed u b\u2082 v\u2082 \u2228 \u2203 e' \u2208 (protocol.handler receiver (u.procs receiver) e.msg sender).snd, (envelope.msg e') = message.p2a {bal := b\u2082, val := v\u2082},\nby {\n  rcases b\u2082_v\u2082_proposed_w with \u27e8proposer, e', he', e'_msg_is\u27e9,\n  cases decidable.em (proposer = receiver),\n  swap,\n  { left, rw ntwks_same proposer h at he',\n    exact \u27e8proposer, e', he', e'_msg_is\u27e9 },\n  rw h at he', clear h proposer,\n  rw ntwk_change at he',\n  cases he',\n  { left, exact \u27e8receiver, e', he', e'_msg_is\u27e9 },\n  right, exact \u27e8e', he', e'_msg_is\u27e9,\n},\ncases already_proposed_or_currently_proposed with b\u2082_v\u2082_proposed just_emitted,\n{ clear proc_change ntwk_change procs_same ntwks_same he deliverable e,\n  suffices b\u2081_v\u2081_proposed : proposed u b\u2081 v\u2081,\n  by { exact hu b\u2081_choosable b\u2081_v\u2081_proposed b\u2082 ballot_order v\u2082 b\u2082_v\u2082_proposed },\n  rcases proposed_imp_majority_sent_p1b u u_r b\u2082 v\u2082 b\u2082_v\u2082_proposed\n    with \u27e8promisers, promisers_are_quorum, promisers_made_promise\u27e9,\n  rcases b\u2081_choosable\n    with \u27e8possible_voters, possible_voters_are_quorum, possible_voters_may_vote\u27e9,\n  rcases quorum_assumption.intersect promisers possible_voters promisers_are_quorum possible_voters_are_quorum with \u27e8a, a_in_inter\u27e9,\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\u2081 u u_r possible_voters_may_vote with \u27e8v', v'_proposed_u\u27e9,\n    rw proposals_unique w w_r b\u2081 v\u2081 v' b\u2081_v\u2081_proposed_w (proposed_stable b\u2081 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\u2082 \u2264 (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\u2082 b\u2082.address,\n    rcases b\u2082_v\u2082_proposed with \u27e8p, proposed_by_p\u27e9,\n    rw proposer_is_ballot_address u u_r b\u2082 p \u27e8v\u2082, proposed_by_p\u27e9,\n    exact \u27e8v\u2082, proposed_by_p\u27e9 },\n  have fact : \u2203 (e \u2208 u.network a) p_or, envelope.msg e = message.p1b b\u2082 p_or, by {\n    cases promisers_made_promise,\n    { rcases promisers_made_promise with \u27e8e, he, e_is\u27e9,\n      exact \u27e8e, he, none, e_is\u27e9 },\n    rcases promisers_made_promise with \u27e8e, he, prop, e_is, _\u27e9,\n    exact \u27e8e, he, some prop, e_is\u27e9 },\n  rcases fact with \u27e8e, he, p_or, e_promises_p_or\u27e9,\n  exact ballot_ge_any_promised a b\u2082 p_or u u_r \u27e8e, he, e_promises_p_or\u27e9 },\nrcases just_emitted with \u27e8ep, h_ep, ep_is_proposal\u27e9,\nrcases p2a_emitted ep_is_proposal h_ep with \u27e8acked_p_or, e_msg_eq, active, __, v_has_quorum, ep_is\u27e9, clear __,\nhave b\u2081_v\u2081_proposed : proposed u b\u2081 v\u2081,\nby {\n  rcases b\u2081_v\u2081_proposed_w with \u27e8proposer, ep1, h_ep1, ep1_is_prop\u27e9,\n  cases decidable.em (proposer = receiver) with cond cond,\n  swap,\n  { rw ntwks_same proposer cond at h_ep1,\n    exact \u27e8proposer, ep1, h_ep1, ep1_is_prop\u27e9 },\n  rw cond at h_ep1, clear cond proposer,\n  rw ntwk_change at h_ep1,\n  cases h_ep1,\n  { exact \u27e8receiver, ep1, h_ep1, ep1_is_prop\u27e9 },\n  rcases p2a_emitted ep1_is_prop h_ep1 with \u27e8acked_p1_or, p1_or_cond, _, _, _, ep1_is\u27e9,\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\u2081 = 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 : \u2203 stored, (proposal.merge (u.procs receiver).accepted acked_p_or) = some stored \u2227 stored.val = v\u2081,\nby {\n  rcases this with \u27e8stored, merge_eq, merged_val\u27e9,\n  rw merge_eq,\n  unfold proposal.value_or_default,\n  exact eq.symm merged_val\n},\nsuffices : \u2203 stored, (proposal.merge (u.procs receiver).accepted acked_p_or) = some stored \u2227 stored.bal \u2265 b\u2081,\nby {\n  rcases this with \u27e8stored, merge_eq, stored_bal_larger\u27e9,\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\u2081_choosable b\u2081_v\u2081_proposed stored.bal h stored.val stored_proposed_at_u,\n      exact eq.symm hu },\n    rw h at b\u2081_v\u2081_proposed_w,\n    exact proposals_unique w w_r stored.bal stored.val v\u2081 (proposed_stable stored.bal stored.val u w stored_proposed_at_u u_pn_w) b\u2081_v\u2081_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\u2081_choosable b\u2081_v\u2081_proposed stored.bal h stored.val stored_proposed_at_u,\n    exact eq.symm hu },\n  rw h at b\u2081_v\u2081_proposed_w,\n  exact proposals_unique w w_r stored.bal stored.val v\u2081 (proposed_stable stored.bal stored.val u w stored_proposed_at_u u_pn_w) b\u2081_v\u2081_proposed_w\n},\nhave u_curr_ballot_is_b\u2082: (u.procs receiver).curr = b\u2082, 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\u2081_choosable with \u27e8poss_voters, poss_voters_quorum, all_voted_or_may_vote\u27e9,\nrcases quorum_assumption.intersect poss_voters ((u.procs receiver).followers \u222a {sender}) poss_voters_quorum v_has_quorum with \u27e8a, a_in_both\u27e9,\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 \u2190 a_is_follower at he,\n    cases none_voted_between_p1b u u_r a b\u2081 (u.procs receiver).curr acked_p_or voted\n                                 \u27e8e, he, e_msg_eq\u27e9,\n    { rw u_curr_ballot_is_b\u2082 at h, exact (not_le_of_lt ballot_order h).elim, },\n    rcases h with \u27e8p, ack_eq, p_bal_ge\u27e9,\n    rw ack_eq,\n    rcases proposal.merge_ballot_ge_right (u.procs receiver).accepted p\n      with \u27e8stored, stored_eq, stored_ge\u27e9,\n    exact \u27e8stored, stored_eq, le_trans p_bal_ge stored_ge\u27e9 },\n  exfalso,\n  have key := ballot_ge_any_promised sender (u.procs receiver).curr acked_p_or u u_r \u27e8e, he, e_msg_eq\u27e9,\n  rw a_is_follower at impossible,\n  rw u_curr_ballot_is_b\u2082 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\u2081 u u_r voted\n      with \u27e8old_stored, old_stored_eq, old_stored_ge\u27e9,\n    rw old_stored_eq, clear old_stored_eq,\n    rcases proposal.merge_ballot_ge_left old_stored acked_p_or\n      with \u27e8stored, stored_eq, stored_ge\u27e9,\n    exact \u27e8stored, stored_eq, le_trans old_stored_ge stored_ge\u27e9 },\n  rw u_curr_ballot_is_b\u2082 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\u2081 (u.procs receiver).curr none impossible fact,\n    { rw u_curr_ballot_is_b\u2082 at h,\n      exact not_le_of_lt ballot_order h },\n    rcases h with \u27e8_, bad, _\u27e9, 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\u2082 at key,\n  exact not_le_of_lt ballot_order (le_trans key impossible) },\nrcases fact with \u27e8e', he', prop, e'_msg_eq, old_stored, accepted_eq_old_stored, old_stored_ge\u27e9,\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\u2081 (u.procs receiver).curr (some prop) voted \u27e8e', he', e'_msg_eq\u27e9,\n  { rw u_curr_ballot_is_b\u2082 at h,\n    exact (not_le_of_lt ballot_order h).elim },\n  rcases h with \u27e8p, p_eq_prop_tmp, p_ge_bal\u27e9,\n  have p_eq_prop : prop = p, by { injection p_eq_prop_tmp },\n  rw \u2190 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 \u27e8stored, stored_eq, ge_old_stored\u27e9,\n  exact \u27e8stored, stored_eq, le_trans p_ge_bal (le_trans old_stored_ge ge_old_stored)\u27e9 },\nexfalso,\nhave key := ballot_ge_any_promised a (u.procs receiver).curr (some prop) u u_r \u27e8e', he', e'_msg_eq\u27e9,\nrw u_curr_ballot_is_b\u2082 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  (\u03bb 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 \u27e8b, proposed_b_v, chosen_b\u27e9,\nrintros \u27e8b', proposed_b'_v', chosen_b'\u27e9,\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 algebra.group.basic\nimport group_theory.order_of_element\nimport group_theory.subgroup.basic\n\nopen_locale big_operators \n\n\ntheorem df_3_2_16 (p : \u2115) (hp : prime p) (a : \u2115) :\n  a ^ p \u2261 a [MOD p]\n:= \nbegin \n  sorry, \nend \n", "meta": {"author": "wudcscheme", "repo": "lean-challenges", "sha": "dfaf3f6f71148b60db75479e7b09c68012f354c1", "save_path": "github-repos/lean/wudcscheme-lean-challenges", "path": "github-repos/lean/wudcscheme-lean-challenges/lean-challenges-dfaf3f6f71148b60db75479e7b09c68012f354c1/src/group_theory/df_chapter3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8887587875995482, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.4893571346364815}}
{"text": "import Src.Prover.Logic\n\nnamespace prover\nnoncomputable section\n\naxiom some {\u03b1 : Type} [Inhabited \u03b1] (P : \u03b1 \u2192 Prop) : \u03b1\naxiom some_spec {\u03b1 : Type} [Inhabited \u03b1] {P : \u03b1 \u2192 Prop}\n  (h : \u2203 (x : \u03b1), P x) : P (some P)\n\ndef someu {\u03b1 : Type} [Inhabited \u03b1] (P : \u03b1 \u2192 Prop) : \u03b1 :=\nsome # \u03bb a => P a \u2227 \u2200 b, P b \u2192 b = a\n\ndef some' {\u03b1 : Type} [Inhabited \u03b1] {P : \u03b1 \u2192 Prop} (h : \u2203 (x : \u03b1), P x) : \u03b1 :=\nsome P\n\ndef someu' {\u03b1 : Type} [Inhabited \u03b1] {P : \u03b1 \u2192 Prop} (h : \u2203! (x : \u03b1), P x) : \u03b1 :=\nsomeu P\n\ntheorem someu_spec {\u03b1 : Type} [Inhabited \u03b1] {P : \u03b1 \u2192 Prop}\n  (h : \u2203! (x : \u03b1), P x) : P (someu P) :=\nand_left # !some_spec # mp exiu_iff h\n\nsection Conditional\n\ntheorem exi_ite_val {\u03b1 : Type} (P : Prop) (x y : \u03b1) :\n  \u2203 (z : \u03b1), (P \u2192 z = x) \u2227 (\u00acP \u2192 z = y) :=\nprop_rec (\u03bb m => \u2203 (z : \u03b1), (m \u2192 z = x) \u2227 (\u00acm \u2192 z = y))\n(exi_intro x # and_intro (\u03bb _ => rfl) (\u03bb h => exfalso # h trivial))\n(exi_intro y # and_intro exfalso (\u03bb _ => rfl))\n\ndef ite {\u03b1 : Type} [Inhabited \u03b1] (P : Prop) (x y : \u03b1) : \u03b1 :=\nsome' # exi_ite_val P x y\n\ntheorem if_pos {\u03b1 : Type} [Inhabited \u03b1] {P : Prop} {x y : \u03b1} (h : P) : ite P x y = x :=\nand_left (!some_spec # exi_ite_val P x y) h\n\ntheorem if_neg {\u03b1 : Type} [Inhabited \u03b1] {P : Prop} {x y : \u03b1} (h : \u00acP) : ite P x y = y :=\nand_right (!some_spec # exi_ite_val P x y) h\n\ntheorem split_ifs {\u03b1 : Type} [Inhabited \u03b1] (F : \u03b1 \u2192 Prop) {P : Prop} {x y : \u03b1}\n  (h\u2081 : P \u2192 F x) (h\u2082 : \u00acP \u2192 F y) : F (ite P x y) :=\nor_elim (@em P)\n(\u03bb h\u2083 => eq_rec' F (if_pos h\u2083) # h\u2081 h\u2083)\n(\u03bb h\u2083 => eq_rec' F (if_neg h\u2083) # h\u2082 h\u2083)\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 \u2115`, whose length is called the dimension\nof the holor.\n\nThe tensor product of `x\u2081 : holor \u03b1 ds\u2081` and `x\u2082 : holor \u03b1 ds\u2082` is the\nholor given by `(x\u2081 \u2297 x\u2082) (i\u2081 ++ i\u2082) = x\u2081 i\u2081 * x\u2082 i\u2082`. 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 \u2115) :=\n  Subtype fun (is : List \u2115) => list.forall\u2082 Less is ds\n\nnamespace holor_index\n\n\ndef take {ds\u2082 : List \u2115} {ds\u2081 : List \u2115} : holor_index (ds\u2081 ++ ds\u2082) \u2192 holor_index ds\u2081 :=\n  sorry\n\ndef drop {ds\u2082 : List \u2115} {ds\u2081 : List \u2115} : holor_index (ds\u2081 ++ ds\u2082) \u2192 holor_index ds\u2082 :=\n  sorry\n\ntheorem cast_type {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} (is : List \u2115) (eq : ds\u2081 = ds\u2082) (h : list.forall\u2082 Less is ds\u2081) : 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\u2081)) { val := is, property := h }))) eq\n\ndef assoc_right {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} : holor_index (ds\u2081 ++ ds\u2082 ++ ds\u2083) \u2192 holor_index (ds\u2081 ++ (ds\u2082 ++ ds\u2083)) :=\n  cast sorry\n\ndef assoc_left {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} : holor_index (ds\u2081 ++ (ds\u2082 ++ ds\u2083)) \u2192 holor_index (ds\u2081 ++ ds\u2082 ++ ds\u2083) :=\n  cast sorry\n\ntheorem take_take {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} (t : holor_index (ds\u2081 ++ ds\u2082 ++ ds\u2083)) : take (assoc_right t) = take (take t) := sorry\n\ntheorem drop_take {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} (t : holor_index (ds\u2081 ++ ds\u2082 ++ ds\u2083)) : take (drop (assoc_right t)) = drop (take t) := sorry\n\ntheorem drop_drop {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} (t : holor_index (ds\u2081 ++ ds\u2082 ++ ds\u2083)) : drop (drop (assoc_right t)) = drop t := sorry\n\nend holor_index\n\n\n/-- Holor (indexed collections of tensor coefficients) -/\ndef holor (\u03b1 : Type u) (ds : List \u2115) :=\n  holor_index ds \u2192 \u03b1\n\nnamespace holor\n\n\nprotected instance inhabited {\u03b1 : Type} {ds : List \u2115} [Inhabited \u03b1] : Inhabited (holor \u03b1 ds) :=\n  { default := fun (t : holor_index ds) => Inhabited.default }\n\nprotected instance has_zero {\u03b1 : Type} {ds : List \u2115} [HasZero \u03b1] : HasZero (holor \u03b1 ds) :=\n  { zero := fun (t : holor_index ds) => 0 }\n\nprotected instance has_add {\u03b1 : Type} {ds : List \u2115} [Add \u03b1] : Add (holor \u03b1 ds) :=\n  { add := fun (x y : holor \u03b1 ds) (t : holor_index ds) => x t + y t }\n\nprotected instance has_neg {\u03b1 : Type} {ds : List \u2115} [Neg \u03b1] : Neg (holor \u03b1 ds) :=\n  { neg := fun (a : holor \u03b1 ds) (t : holor_index ds) => -a t }\n\nprotected instance add_semigroup {\u03b1 : Type} {ds : List \u2115} [add_semigroup \u03b1] : add_semigroup (holor \u03b1 ds) :=\n  add_semigroup.mk (fun (\u1fb0 \u1fb0_1 : holor \u03b1 ds) => id fun (\u1fb0_2 : holor_index ds) => add_semigroup.add (\u1fb0 \u1fb0_2) (\u1fb0_1 \u1fb0_2))\n    sorry\n\nprotected instance add_comm_semigroup {\u03b1 : Type} {ds : List \u2115} [add_comm_semigroup \u03b1] : add_comm_semigroup (holor \u03b1 ds) :=\n  add_comm_semigroup.mk\n    (fun (\u1fb0 \u1fb0_1 : holor \u03b1 ds) => id fun (\u1fb0_2 : holor_index ds) => add_comm_semigroup.add (\u1fb0 \u1fb0_2) (\u1fb0_1 \u1fb0_2)) sorry sorry\n\nprotected instance add_monoid {\u03b1 : Type} {ds : List \u2115} [add_monoid \u03b1] : add_monoid (holor \u03b1 ds) :=\n  add_monoid.mk (fun (\u1fb0 \u1fb0_1 : holor \u03b1 ds) => id fun (\u1fb0_2 : holor_index ds) => add_monoid.add (\u1fb0 \u1fb0_2) (\u1fb0_1 \u1fb0_2)) sorry\n    (id fun (\u1fb0 : holor_index ds) => add_monoid.zero) sorry sorry\n\nprotected instance add_comm_monoid {\u03b1 : Type} {ds : List \u2115} [add_comm_monoid \u03b1] : add_comm_monoid (holor \u03b1 ds) :=\n  add_comm_monoid.mk (fun (\u1fb0 \u1fb0_1 : holor \u03b1 ds) => id fun (\u1fb0_2 : holor_index ds) => add_comm_monoid.add (\u1fb0 \u1fb0_2) (\u1fb0_1 \u1fb0_2))\n    sorry (id fun (\u1fb0 : holor_index ds) => add_comm_monoid.zero) sorry sorry sorry\n\nprotected instance add_group {\u03b1 : Type} {ds : List \u2115} [add_group \u03b1] : add_group (holor \u03b1 ds) :=\n  add_group.mk (fun (\u1fb0 \u1fb0_1 : holor \u03b1 ds) => id fun (\u1fb0_2 : holor_index ds) => add_group.add (\u1fb0 \u1fb0_2) (\u1fb0_1 \u1fb0_2)) sorry\n    (id fun (\u1fb0 : holor_index ds) => add_group.zero) sorry sorry\n    (fun (\u1fb0 : holor \u03b1 ds) => id fun (\u1fb0_1 : holor_index ds) => add_group.neg (\u1fb0 \u1fb0_1))\n    (fun (\u1fb0 \u1fb0_1 : holor \u03b1 ds) => id fun (\u1fb0_2 : holor_index ds) => add_group.sub (\u1fb0 \u1fb0_2) (\u1fb0_1 \u1fb0_2)) sorry\n\nprotected instance add_comm_group {\u03b1 : Type} {ds : List \u2115} [add_comm_group \u03b1] : add_comm_group (holor \u03b1 ds) :=\n  add_comm_group.mk (fun (\u1fb0 \u1fb0_1 : holor \u03b1 ds) => id fun (\u1fb0_2 : holor_index ds) => add_comm_group.add (\u1fb0 \u1fb0_2) (\u1fb0_1 \u1fb0_2))\n    sorry (id fun (\u1fb0 : holor_index ds) => add_comm_group.zero) sorry sorry\n    (fun (\u1fb0 : holor \u03b1 ds) => id fun (\u1fb0_1 : holor_index ds) => add_comm_group.neg (\u1fb0 \u1fb0_1))\n    (fun (\u1fb0 \u1fb0_1 : holor \u03b1 ds) => id fun (\u1fb0_2 : holor_index ds) => add_comm_group.sub (\u1fb0 \u1fb0_2) (\u1fb0_1 \u1fb0_2)) sorry sorry\n\n/- scalar product -/\n\nprotected instance has_scalar {\u03b1 : Type} {ds : List \u2115} [Mul \u03b1] : has_scalar \u03b1 (holor \u03b1 ds) :=\n  has_scalar.mk fun (a : \u03b1) (x : holor \u03b1 ds) (t : holor_index ds) => a * x t\n\nprotected instance semimodule {\u03b1 : Type} {ds : List \u2115} [semiring \u03b1] : semimodule \u03b1 (holor \u03b1 ds) :=\n  pi.semimodule (holor_index ds) (fun (\u1fb0 : holor_index ds) => \u03b1) \u03b1\n\n/-- The tensor product of two holors. -/\ndef mul {\u03b1 : Type} {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} [s : Mul \u03b1] (x : holor \u03b1 ds\u2081) (y : holor \u03b1 ds\u2082) : holor \u03b1 (ds\u2081 ++ ds\u2082) :=\n  fun (t : holor_index (ds\u2081 ++ ds\u2082)) => x (holor_index.take t) * y (holor_index.drop t)\n\ntheorem cast_type {\u03b1 : Type} {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} (eq : ds\u2081 = ds\u2082) (a : holor \u03b1 ds\u2081) : cast (congr_arg (holor \u03b1) eq) a = fun (t : holor_index ds\u2082) => a (cast (congr_arg holor_index (Eq.symm eq)) t) :=\n  eq.drec (Eq.refl (cast (congr_arg (holor \u03b1) (Eq.refl ds\u2081)) a)) eq\n\ndef assoc_right {\u03b1 : Type} {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} : holor \u03b1 (ds\u2081 ++ ds\u2082 ++ ds\u2083) \u2192 holor \u03b1 (ds\u2081 ++ (ds\u2082 ++ ds\u2083)) :=\n  cast sorry\n\ndef assoc_left {\u03b1 : Type} {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} : holor \u03b1 (ds\u2081 ++ (ds\u2082 ++ ds\u2083)) \u2192 holor \u03b1 (ds\u2081 ++ ds\u2082 ++ ds\u2083) :=\n  cast sorry\n\ntheorem mul_assoc0 {\u03b1 : Type} {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} [semigroup \u03b1] (x : holor \u03b1 ds\u2081) (y : holor \u03b1 ds\u2082) (z : holor \u03b1 ds\u2083) : mul (mul x y) z = assoc_left (mul x (mul y z)) := sorry\n\ntheorem mul_assoc {\u03b1 : Type} {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {ds\u2083 : List \u2115} [semigroup \u03b1] (x : holor \u03b1 ds\u2081) (y : holor \u03b1 ds\u2082) (z : holor \u03b1 ds\u2083) : mul (mul x y) z == mul x (mul y z) := sorry\n\ntheorem mul_left_distrib {\u03b1 : Type} {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} [distrib \u03b1] (x : holor \u03b1 ds\u2081) (y : holor \u03b1 ds\u2082) (z : holor \u03b1 ds\u2082) : mul x (y + z) = mul x y + mul x z :=\n  funext\n    fun (t : holor_index (ds\u2081 ++ ds\u2082)) =>\n      left_distrib (x (holor_index.take t)) (y (holor_index.drop t)) (z (holor_index.drop t))\n\ntheorem mul_right_distrib {\u03b1 : Type} {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} [distrib \u03b1] (x : holor \u03b1 ds\u2081) (y : holor \u03b1 ds\u2081) (z : holor \u03b1 ds\u2082) : mul (x + y) z = mul x z + mul y z :=\n  funext\n    fun (t : holor_index (ds\u2081 ++ ds\u2082)) =>\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\u2081 : List \u2115} {ds\u2082 : List \u2115} {\u03b1 : Type} [ring \u03b1] (x : holor \u03b1 ds\u2082) : mul 0 x = 0 :=\n  funext fun (t : holor_index (ds\u2081 ++ ds\u2082)) => zero_mul (x (holor_index.drop t))\n\n@[simp] theorem mul_zero {ds\u2081 : List \u2115} {ds\u2082 : List \u2115} {\u03b1 : Type} [ring \u03b1] (x : holor \u03b1 ds\u2081) : mul x 0 = 0 :=\n  funext fun (t : holor_index (ds\u2081 ++ ds\u2082)) => mul_zero (x (holor_index.take t))\n\ntheorem mul_scalar_mul {\u03b1 : Type} {ds : List \u2115} [monoid \u03b1] (x : holor \u03b1 []) (y : holor \u03b1 ds) : mul x y = x { val := [], property := list.forall\u2082.nil } \u2022 y := sorry\n\n/- holor slices -/\n\n/-- A slice is a subholor consisting of all entries with initial index i. -/\ndef slice {\u03b1 : Type} {d : \u2115} {ds : List \u2115} (x : holor \u03b1 (d :: ds)) (i : \u2115) (h : i < d) : holor \u03b1 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 {\u03b1 : Type} [monoid \u03b1] [add_monoid \u03b1] (d : \u2115) (j : \u2115) : holor \u03b1 [d] :=\n  fun (ti : holor_index [d]) => ite (subtype.val ti = [j]) 1 0\n\ntheorem holor_index_cons_decomp {d : \u2115} {ds : List \u2115} (p : holor_index (d :: ds) \u2192 Prop) (t : holor_index (d :: ds)) : (\u2200 (i : \u2115) (is : List \u2115) (h : subtype.val t = i :: is),\n    p\n      { val := i :: is,\n        property :=\n          eq.mpr (id (Eq._oldrec (Eq.refl (list.forall\u2082 Less (i :: is) (d :: ds))) (Eq.symm h)))\n            (subtype.property t) }) \u2192\n  p t := sorry\n\n/-- Two holors are equal if all their slices are equal. -/\ntheorem slice_eq {\u03b1 : Type} {d : \u2115} {ds : List \u2115} (x : holor \u03b1 (d :: ds)) (y : holor \u03b1 (d :: ds)) (h : slice x = slice y) : x = y := sorry\n\ntheorem slice_unit_vec_mul {\u03b1 : Type} {d : \u2115} {ds : List \u2115} [ring \u03b1] {i : \u2115} {j : \u2115} (hid : i < d) (x : holor \u03b1 ds) : slice (mul (unit_vec d j) x) i hid = ite (i = j) x 0 := sorry\n\ntheorem slice_add {\u03b1 : Type} {d : \u2115} {ds : List \u2115} [Add \u03b1] (i : \u2115) (hid : i < d) (x : holor \u03b1 (d :: ds)) (y : holor \u03b1 (d :: ds)) : slice x i hid + slice y i hid = slice (x + y) i hid := sorry\n\ntheorem slice_zero {\u03b1 : Type} {d : \u2115} {ds : List \u2115} [HasZero \u03b1] (i : \u2115) (hid : i < d) : slice 0 i hid = 0 :=\n  rfl\n\ntheorem slice_sum {\u03b1 : Type} {d : \u2115} {ds : List \u2115} [add_comm_monoid \u03b1] {\u03b2 : Type} (i : \u2115) (hid : i < d) (s : finset \u03b2) (f : \u03b2 \u2192 holor \u03b1 (d :: ds)) : (finset.sum s fun (x : \u03b2) => slice (f x) i hid) = slice (finset.sum s fun (x : \u03b2) => 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 {\u03b1 : Type} {d : \u2115} {ds : List \u2115} [ring \u03b1] (x : holor \u03b1 (d :: ds)) : (finset.sum (finset.attach (finset.range d))\n    fun (i : Subtype fun (x : \u2115) => x \u2208 finset.range d) =>\n      mul (unit_vec d \u2191i) (slice x (\u2191i) (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 {\u03b1 : Type} [Mul \u03b1] : {ds : List \u2115} \u2192 holor \u03b1 ds \u2192 Prop\nwhere\n| nil : \u2200 (x : holor \u03b1 []), cprank_max1 x\n| cons : \u2200 {d : \u2115} {ds : List \u2115} (x : holor \u03b1 [d]) (y : holor \u03b1 ds), cprank_max1 y \u2192 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 {\u03b1 : Type} [Mul \u03b1] [add_monoid \u03b1] : \u2115 \u2192 {ds : List \u2115} \u2192 holor \u03b1 ds \u2192 Prop\nwhere\n| zero : \u2200 {ds : List \u2115}, cprank_max 0 0\n| succ : \u2200 (n : \u2115) {ds : List \u2115} (x y : holor \u03b1 ds), cprank_max1 x \u2192 cprank_max n y \u2192 cprank_max (n + 1) (x + y)\n\ntheorem cprank_max_nil {\u03b1 : Type} [monoid \u03b1] [add_monoid \u03b1] (x : holor \u03b1 []) : cprank_max 1 x := sorry\n\ntheorem cprank_max_1 {\u03b1 : Type} {ds : List \u2115} [monoid \u03b1] [add_monoid \u03b1] {x : holor \u03b1 ds} (h : cprank_max1 x) : cprank_max 1 x := sorry\n\ntheorem cprank_max_add {\u03b1 : Type} {ds : List \u2115} [monoid \u03b1] [add_monoid \u03b1] {m : \u2115} {n : \u2115} {x : holor \u03b1 ds} {y : holor \u03b1 ds} : cprank_max m x \u2192 cprank_max n y \u2192 cprank_max (m + n) (x + y) := sorry\n\ntheorem cprank_max_mul {\u03b1 : Type} {d : \u2115} {ds : List \u2115} [ring \u03b1] (n : \u2115) (x : holor \u03b1 [d]) (y : holor \u03b1 ds) : cprank_max n y \u2192 cprank_max n (mul x y) := sorry\n\ntheorem cprank_max_sum {\u03b1 : Type} {ds : List \u2115} [ring \u03b1] {\u03b2 : Type u_1} {n : \u2115} (s : finset \u03b2) (f : \u03b2 \u2192 holor \u03b1 ds) : (\u2200 (x : \u03b2), x \u2208 s \u2192 cprank_max n (f x)) \u2192 cprank_max (finset.card s * n) (finset.sum s fun (x : \u03b2) => f x) := sorry\n\ntheorem cprank_max_upper_bound {\u03b1 : Type} [ring \u03b1] {ds : List \u2115} (x : holor \u03b1 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 {\u03b1 : Type} {ds : List \u2115} [ring \u03b1] (x : holor \u03b1 ds) : \u2115 :=\n  nat.find sorry\n\ntheorem cprank_upper_bound {\u03b1 : Type} [ring \u03b1] {ds : List \u2115} (x : holor \u03b1 ds) : cprank x \u2264 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 : \u2115 \u2192 \u211d := \u03bb n, nat.rec 0 (\u03bb k x, x + 1/(2 : \u211d)^(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 : \u2115) : T n = 1- (1/(2: \u211d))^n :=\nbegin\n  have : T n = \u2211 k in finset.range n, 1/(2: \u211d)^(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, \u2190 one_div_pow, pow_succ, \u2190 finset.mul_sum, geom_sum_eq (by norm_num : 1/(2:\u211d) \u2260 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 : \u2115) : T n < 1 :=\nbegin\n  rw T_eq,\n  have : (0 : \u211d) < (1 / 2) ^ n, by positivity,\n  linarith\nend\n\nprivate lemma T_lt_succ (n : \u2115) : 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 : \u2115) : T n \u2264 T (n+1) := (T_lt_succ n).le\n\nprivate lemma T_succ_sub (n : \u2115) : 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 : \u2115) : 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 : \u2115) : \u00ac T (n + 1) \u2264 0 :=\nbegin\n  rw [T_eq, not_le],\n  have : (1 / (2 : \u211d)) ^ (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 : \u2115} {U K : index_type N \u2192 set X}\n  (P\u2080 P\u2081 : \u03a0 x : X, germ (\ud835\udcdd x) Y \u2192 Prop) (P\u2082 : \u03a0 p : \u211d \u00d7 X, germ (\ud835\udcdd p) Y \u2192 Prop)\n  (hP\u2082 : \u2200 a b (p : \u211d \u00d7 X) (f : \u211d \u00d7 X \u2192 Y), P\u2082 (a*p.1+b, p.2) f \u2192 P\u2082 p (\u03bb p : \u211d \u00d7 X, f (a*p.1+b, p.2)))\n  {f\u2080 : X \u2192 Y} (init : \u2200 x, P\u2080 x f\u2080)\n  (ind : \u2200 (i : index_type N) (f : X \u2192 Y), (\u2200 x, P\u2080 x f) \u2192 (\u2200\u1da0 x near \u22c3 j < i, K j, P\u2081 x f) \u2192\n    \u2203 F : \u211d \u2192 X \u2192 Y, (\u2200 t, \u2200 x, P\u2080 x $ F t) \u2227 (\u2200\u1da0 x near \u22c3 j \u2264 i, K j, P\u2081 x $ F 1) \u2227\n                     (\u2200 p, P\u2082 p \u21bfF) \u2227 (\u2200 t, \u2200 x \u2209 U i, F t x = f x) \u2227\n                     (\u2200\u1da0 t near Iic 0, F t = f) \u2227 (\u2200\u1da0 t near Ici 1, F t = F 1)) :\n  \u2203 f : \u2115 \u2192 \u211d \u00d7 X \u2192 Y, \u2200 n,\n    ((\u2200 p : \u211d \u00d7 X, P\u2080 p.2 (filter.germ.slice_right (f n)) \u2227 P\u2082 p (f n)) \u2227\n    (\u2200\u1da0 x near (\u22c3 i \u2264 (n : index_type N) , K i), P\u2081 x (filter.germ.slice_right (f n : (\ud835\udcdd (T (n+1), x)).germ Y))) \u2227\n    (\u2200 t \u2265 T (n+1), \u2200 x, f n (t, x) = f n (T (n+1), x)) \u2227 (\u2200 x, f n (0, x) = f\u2080 x) \u2227\n    (\u2200\u1da0 t in \ud835\udcdd (T $ n+1), \u2200 x, f n (t, x) = f n (T (n+1), x))) \u2227\n    ((((n+1:\u2115) : index_type N) = n \u2192 f (n+1) = f n) \u2227\n      \u2200 x \u2209 U (n + 1 : \u2115), \u2200 t, f (n+1) (t, x) = f n (t, x))\n   :=\nbegin\n  let P\u2080' : \u03a0 p : \u211d \u00d7 X, germ (\ud835\udcdd p) Y \u2192 Prop := \u03bb p \u03c6, P\u2080 p.2 \u03c6.slice_right \u2227 P\u2082 p \u03c6,\n  let P\u2081' : \u03a0 p : \u211d \u00d7 X, germ (\ud835\udcdd p) Y \u2192 Prop := \u03bb p \u03c6, P\u2081 p.2 \u03c6.slice_right,\n  let P : \u2115 \u2192 (\u211d \u00d7 X \u2192 Y) \u2192 Prop :=\n    \u03bb n f, (\u2200 p, P\u2080' p f) \u2227 (\u2200\u1da0 x near (\u22c3 i \u2264 (n : index_type N) , K i), P\u2081' (T (n+1), x) f) \u2227\n           (\u2200 t \u2265 T (n+1), \u2200 x, f (t, x) = f (T (n+1), x)) \u2227 (\u2200 x, f (0, x) = f\u2080 x) \u2227\n           (\u2200\u1da0 t in \ud835\udcdd (T $ n+1), \u2200 x, f (t, x) = f (T (n+1), x)),\n  let Q : \u2115 \u2192 (\u211d \u00d7 X \u2192 Y) \u2192 (\u211d \u00d7 X \u2192 Y) \u2192 Prop :=\n    \u03bb n f f', ((((n+1:\u2115) : index_type N) = n) \u2192 f' = f) \u2227\n              (\u2200 x \u2209 U (n + 1 : \u2115), \u2200 t, f' (t, x) = f (t, x)),\n  change \u2203 f : \u2115 \u2192 \u211d \u00d7 X \u2192 Y, \u2200 n, P n (f n) \u2227 Q n (f n) (f $ n + 1),\n  apply exists_by_induction',\n  { dsimp only [P],\n    rcases ind 0 f\u2080 init _ with \u27e8f', h\u2080f', h\u2081f', hf'\u2082, hf'not, hf'0, hf'1\u27e9,\n    refine \u27e8\u03bb p, f' (2*p.1) p.2, \u03bb p, \u27e8_, _\u27e9, _, _, _, _\u27e9,\n    { exact h\u2080f' (2*p.1) p.2 },\n    { simpa using hP\u2082 2 0 p \u21bff' (hf'\u2082 _) },\n    { apply h\u2081f'.mono,\n      intros x hx,\n      change P\u2081 x (\u03bb 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 \u2190 hf'1.on_set (2*t) _,\n      change 1 \u2264 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 : \ud835\udcdd (1 : \u211d) \u2264 \ud835\udcdd\u02e2 (Ici 1),\n            { exact nhds_le_nhds_set left_mem_Ici },\n      have : f' =\u1da0[\ud835\udcdd 1] \u03bb t, f' 1 := hf'1.filter_mono this,\n      have lim : tendsto (\u03bb t : \u211d, 2*t) (\ud835\udcdd $ T 1) (\ud835\udcdd 1),\n      { rw [T_one],\n        convert tendsto_id.const_mul (2 : \u211d),\n        simp },\n      apply (this.comp_fun lim).mono (\u03bb t ht, _),\n      intro x',\n      apply congr_fun ht },\n    { simp [index_type.not_lt_zero] } },\n  { rintros n f \u27e8h\u2080'f, h\u2081f, hinvf, hf0, hfTn1\u27e9,\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\u2081f,\n      rcases ind (n+1 : \u2115) (\u03bb x, f (T (n+1), x)) (\u03bb x, (h\u2080'f (T (n+1), x)).1) h\u2081f with\n        \u27e8f', h\u2080f', h\u2081f', hf'\u2082, hf'not, hf'0, hf'1\u27e9,\n      refine \u27e8\u03bb p, if p.1 \u2265 T (n+1) then f' (2^(n+2)*(p.1 - T (n+1))) p.2 else f p, \u27e8\u03bb p, \u27e8_, _\u27e9, _, _, _, _\u27e9, _, _\u27e9,\n      { by_cases ht : (T $ n+1) \u2264 p.1,\n        { convert h\u2080f' (2^(n+2)*(p.1-T (n+1))) p.2 using 1,\n          apply quotient.sound,\n          simp [ht] },\n        { convert (h\u2080'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\u2082 (2^(n+2)) (-2^(n+2)*T (n+1)) p \u21bff' (hf'\u2082 _) using 1,\n          apply quotient.sound,\n          have hp : \u2200\u1da0 (q : \u211d \u00d7 X) in \ud835\udcdd p, T (n+1) \u2264 q.1,\n          { cases p with t x,\n            apply mem_of_superset (prod_mem_nhds (Ioi_mem_nhds ht) univ_mem),\n            rintros \u27e8t', x'\u27e9 \u27e8ht', hx'\u27e9,\n            exact le_of_lt ht' },\n          apply hp.mono (\u03bb q hq, _),\n          simp [if_pos hq, mul_sub, neg_mul],\n          refl },\n        { let g : \u211d \u00d7 X \u2192 Y := \u03bb p, f' (2 ^ (n + 2) * (p.fst - T (n + 1))) p.snd,\n          have hg : P\u2082 p g,\n          { convert hP\u2082 (2^(n+2)) (-2^(n+2)*T (n+1)) p \u21bff' (hf'\u2082 _) 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 =\u1da0[\ud835\udcdd (t, x)] \u03bb q : \u211d \u00d7 X, f (T (n + 1), q.2),\n          { change T (n+1) = t at ht,\n            rw \u2190 ht,\n            apply mem_of_superset (prod_mem_nhds hfTn1 univ_mem),\n            rintros \u27e8t', x'\u27e9 \u27e8ht', hx'\u27e9,\n            exact ht' x' },\n          replace hf'0 : \u21bff' =\u1da0[\ud835\udcdd (0, x)] \u03bb q : \u211d \u00d7 X, f (T (n + 1), q.2),\n          { have : \ud835\udcdd (0 : \u211d) \u2264 \ud835\udcdd\u02e2 (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 \u27e8t', x'\u27e9 \u27e8ht', hx'\u27e9,\n            exact (congr_fun ht' x' : _) },\n          have : tendsto (\u03bb (x : \u211d \u00d7 X), (2 ^ (n + 2) * (x.1 - T (n + 1)), x.2)) (\ud835\udcdd (t, x)) (\ud835\udcdd (0, x)),\n          { rw [nhds_prod_eq, nhds_prod_eq],\n            have limt : tendsto (\u03bb t, 2 ^ (n + 2) * (t - T (n + 1))) (\ud835\udcdd t) (\ud835\udcdd 0),\n            { rw [show (0 : \u211d) = 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 (\u03bb (q : \u211d \u00d7 X), f (T (n + 1), q.2)) \u2218\n            (\u03bb (x : \u211d \u00d7 X), (2 ^ (n + 2) * (x.1 - T (n + 1)), x.2)) =\n            \u03bb q : \u211d \u00d7 X, f (T (n + 1), q.2),\n          by { ext, refl } at this,\n          exact this.trans hf.symm },\n        { have hp : \u2200\u1da0 (q : \u211d \u00d7 X) in \ud835\udcdd p, \u00ac T (n+1) \u2264 q.1,\n          { cases p with t x,\n            apply mem_of_superset (prod_mem_nhds (Iio_mem_nhds ht) univ_mem),\n            rintros \u27e8t', x'\u27e9 \u27e8ht', hx'\u27e9,\n            simpa using ht' },\n          convert (h\u2080'f p).2 using 1,\n          apply quotient.sound,\n          apply hp.mono (\u03bb q hq, _),\n          simp [if_neg hq] } },\n      { apply h\u2081f'.mono,\n        intros x hx,\n        change P\u2081 x (\u03bb x', if T (n+2) \u2265 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) \u2264 t - T (n+1) := le_sub_iff_add_le'.mpr ht,\n        rw \u2190 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 : (\u03bb t x, f' (2 ^ (n + 2) * (t - T (n + 1))) x) =\u1da0[\ud835\udcdd (T (n + 2))] (\u03bb t x, f' (2 ^ (n + 2) * (T (n+2) - T (n + 1))) x),\n        { have hle : \u2200\u1da0 (t : \u211d) in \ud835\udcdd (T (n + 1 + 1)), t \u2265 T (n+1),\n            from eventually_ge_of_tendsto_gt (T_lt_succ _) tendsto_id,\n          apply (hle.and this).mono,\n          rintros t \u27e8ht, ht'\u27e9 x,\n          dsimp only,\n          rw [if_pos ht, if_pos (T_le_succ _)],\n          apply congr_fun ht' },\n        have : \ud835\udcdd (1 : \u211d) \u2264 \ud835\udcdd\u02e2 (Ici 1),\n            { exact nhds_le_nhds_set left_mem_Ici },\n        rw mul_T_succ_sub,\n        have : f' =\u1da0[\ud835\udcdd 1] \u03bb t, f' 1 := hf'1.filter_mono this,\n        apply this.comp_fun,\n        conv { congr, congr, skip, rw \u2190 mul_T_succ_sub (n+1) },\n        exact (tendsto_id.sub_const _).const_mul _ },\n      { exact \u03bb 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\u2081f,\n      refine \u27e8f, \u27e8h\u2080'f, _, _, hf0, _\u27e9, _, _\u27e9,\n      { apply h\u2081f.mono,\n        intros x hx,\n        change P\u2081 x (\u03bb 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 : \u2200\u1da0 (t : \u211d) in \ud835\udcdd (T (n + 1 + 1)), t \u2265 T (n+1),\n            from eventually_ge_of_tendsto_gt (T_lt_succ _) tendsto_id,\n        apply hle.mono (\u03bb 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 `\u2200 x \u2208 \u22c3 j < i, K j, P\u2081 x f` should be something more general. -/\nlemma inductive_htpy_construction {X Y : Type*} [topological_space X]\n  {N : \u2115} {U K : index_type N \u2192 set X}\n  (P\u2080 P\u2081 : \u03a0 x : X, germ (\ud835\udcdd x) Y \u2192 Prop) (P\u2082 : \u03a0 p : \u211d \u00d7 X, germ (\ud835\udcdd p) Y \u2192 Prop)\n  (hP\u2082 : \u2200 a b (p : \u211d \u00d7 X) (f : \u211d \u00d7 X \u2192 Y), P\u2082 (a*p.1+b, p.2) f \u2192 P\u2082 p (\u03bb p : \u211d \u00d7 X, f (a*p.1+b, p.2)))\n  (U_fin : locally_finite U) (K_cover : (\u22c3 i, K i) = univ)\n  {f\u2080 : X \u2192 Y} (init : \u2200 x, P\u2080 x f\u2080)\n  (ind : \u2200 (i : index_type N) (f : X \u2192 Y), (\u2200 x, P\u2080 x f) \u2192 (\u2200\u1da0 x near \u22c3 j < i, K j, P\u2081 x f) \u2192\n    \u2203 F : \u211d \u2192 X \u2192 Y, (\u2200 t, \u2200 x, P\u2080 x $ F t) \u2227 (\u2200\u1da0 x near \u22c3 j \u2264 i, K j, P\u2081 x $ F 1) \u2227\n                     (\u2200 p, P\u2082 p \u21bfF) \u2227 (\u2200 t, \u2200 x \u2209 U i, F t x = f x) \u2227\n                     (\u2200\u1da0 t near Iic 0, F t = f) \u2227 (\u2200\u1da0 t near Ici 1, F t = F 1)) :\n  \u2203 F : \u211d \u2192 X \u2192 Y, F 0 = f\u2080 \u2227 (\u2200 t x, P\u2080 x (F t)) \u2227 (\u2200 x, P\u2081 x (F 1)) \u2227 (\u2200 p, P\u2082 p \u21bfF) :=\nbegin\n  let P\u2080' : \u03a0 p : \u211d \u00d7 X, germ (\ud835\udcdd p) Y \u2192 Prop := \u03bb p \u03c6, P\u2080 p.2 \u03c6.slice_right \u2227 P\u2082 p \u03c6,\n  let P\u2081' : \u03a0 p : \u211d \u00d7 X, germ (\ud835\udcdd p) Y \u2192 Prop := \u03bb p \u03c6, P\u2081 p.2 \u03c6.slice_right,\n  let P : \u2115 \u2192 (\u211d \u00d7 X \u2192 Y) \u2192 Prop :=\n    \u03bb n f, (\u2200 p, P\u2080' p f) \u2227 (\u2200\u1da0 x near (\u22c3 i \u2264 (n : index_type N) , K i), P\u2081' (T (n+1), x) f) \u2227\n           (\u2200 t \u2265 T (n+1), \u2200 x, f (t, x) = f (T (n+1), x)) \u2227 (\u2200 x, f (0, x) = f\u2080 x) \u2227\n           (\u2200\u1da0 t in \ud835\udcdd (T $ n+1), \u2200 x, f (t, x) = f (T (n+1), x)),\n  let Q : \u2115 \u2192 (\u211d \u00d7 X \u2192 Y) \u2192 (\u211d \u00d7 X \u2192 Y) \u2192 Prop :=\n    \u03bb n f f', ((((n+1:\u2115) : index_type N) = n) \u2192 f' = f) \u2227\n              (\u2200 x \u2209 U (n + 1 : \u2115), \u2200 t, f' (t, x) = f (t, x)),\n  obtain \u27e8f, hf\u27e9 : \u2203 f : \u2115 \u2192 \u211d \u00d7 X \u2192 Y, \u2200 n, P n (f n) \u2227 Q n (f n) (f $ n + 1),\n  { apply inductive_htpy_construction_aux; assumption },\n  simp only [P, Q, forall_and_distrib, forall\u2082_and_distrib] at hf,\n  rcases hf with \u27e8\u27e8\u27e8h\u2080f, h\u2082f\u27e9, h\u2081f, hinvf, hf0, hfTsucc\u27e9, hf\u2081, hf\u2083\u27e9,\n  choose W W_in hW using U_fin,\n  choose i\u2080 hi\u2080 using \u03bb x, (hW x).bdd_above,\n  have : \u2200 x, \u2203 n : \u2115, x \u2208 K n,\n  { intros x,\n    rcases eq_univ_iff_forall.mp K_cover x with \u27e8-, \u27e8i, rfl\u27e9, hi\u27e9,\n    use indexing.to_nat i,\n    simpa using hi },\n  choose nK hnK using this,\n  let n\u2080 : X \u2192 \u2115 := \u03bb x, max (nK x) (indexing.to_nat (i\u2080 x)),\n  have key : \u2200 {x : X} {n}, n \u2265 n\u2080 x \u2192 \u2200 {q : \u211d \u00d7 X}, q.2 \u2208 W x \u2192 f n q = f (n\u2080 x) q,\n  { intros x\u2080 n hn,\n    rcases le_iff_exists_add.mp hn with \u27e8k, rfl\u27e9, clear hn,\n    rintros \u27e8t, x\u27e9 (hx : x \u2208 _),\n    induction k with k hk,\n    { rw add_zero },\n    rw \u2190 hk, clear hk,\n    let \u03c0 :  \u2115 \u2192 index_type N := indexing.from_nat,\n    have : \u2200 n, \u03c0 n < \u03c0 (n+1) \u2228 \u03c0 n = \u03c0 (n+1),\n    exact \u03bb n, lt_or_eq_of_le (indexing.mono_from n.le_succ),\n    rcases this (n\u2080 x\u2080 + k) with H | H ; clear this,\n    { have ineq : i\u2080 x\u2080 < \u03c0 (n\u2080 x\u2080 + k + 1),\n      { suffices : i\u2080 x\u2080 \u2264 \u03c0 (n\u2080 x\u2080 + k), from lt_of_le_of_lt this H,\n        rw \u2190 indexing.from_to (i\u2080 x\u2080),\n        exact indexing.mono_from ((le_max_right _ _).trans le_self_add) },\n      apply hf\u2083,\n      intros hx',\n      exact lt_irrefl _ (ineq.trans_le $ hi\u2080 x\u2080 \u27e8x, \u27e8hx', hx\u27e9\u27e9) },\n    { rw [\u2190 nat.add_one, \u2190 add_assoc, hf\u2081 _ H.symm] } },\n  have key' : \u2200 p : \u211d \u00d7 X, \u2200 n \u2265 n\u2080 p.2, f n =\u1da0[\ud835\udcdd p] \u03bb q, f (n\u2080 q.2) q,\n  { rintros \u27e8t, x\u27e9 n hn,\n    apply mem_of_superset (prod_mem_nhds univ_mem $ W_in x) (\u03bb p hp, _),\n    dsimp only [mem_set_of],\n    calc f n p = f (n\u2080 x) p : key hn hp.2\n    ... = f (max (n\u2080 x) (n\u2080 p.2)) p : (key (le_max_left (n\u2080 x) _) hp.2).symm\n    ... = f (n\u2080 p.2) p : key (le_max_right _ _) (mem_of_mem_nhds $ W_in _) },\n  have key'' : \u2200 p : \u211d \u00d7 X, \u2200\u1da0 (n : \u2115) in at_top, f n =\u1da0[\ud835\udcdd p] \u03bb q, f (n\u2080 q.2) q,\n  { exact \u03bb p, (eventually_ge_at_top (n\u2080 p.2)).mono (\u03bb n hn, key' p n hn) },\n  refine \u27e8\u03bb t x, f (n\u2080 x) (t, x), _, _, _, _\u27e9,\n  { ext x,\n    rw hf0 },\n  { intros t x,\n    convert h\u2080f (n\u2080 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\u2081f (n\u2080 x)).on_set x (mem_Union\u2082_of_mem (indexing.coe_mono $ le_max_left _ _) $ hnK x) using 1,\n    apply quotient.sound,\n    change (\u03bb x', f (n\u2080 x') (1, x')) =\u1da0[\ud835\udcdd x] \u03bb (x' : X), f (n\u2080 x) (T (n\u2080 x + 1), x'),\n    simp_rw \u2190 hinvf (n\u2080 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\u2082f (n\u2080 p.2) p using 1,\n    apply quotient.sound,\n    rw show \u21bf(\u03bb t x, f (n\u2080 x) (t, x)) = \u03bb p : \u211d \u00d7 X, f (n\u2080 p.2) p, by ext \u27e8s, y\u27e9 ; 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.\u03b9 F i xi = colimit.\u03b9 F j xj \u2194 \u2203 k (f : i \u27f6 k) (g : j \u27f6 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 \u2964 Type (max v u)) : cone F :=\n{ X := F.sections,\n  \u03c0 := { app := \u03bb 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 \u2964 Type (max v u)) : is_limit (limit_cone F) :=\n{ lift := \u03bb s v, \u27e8\u03bb j, s.\u03c0.app j v, \u03bb j j' f, congr_fun (cone.w s f) _\u27e9,\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 := \u03bb J \ud835\udca5, by exactI\n  { has_limit := \u03bb 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 \u2964 Type (max v u)} {c : cone F} (t : is_limit c) :\n  c.X \u2243 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 \u2964 Type (max v u)} {c : cone F} (t : is_limit c) (j : J) (x : c.X) :\n  (((is_limit_equiv_sections t) x) : \u03a0 j, F.obj j) j = c.\u03c0.app j x :=\nrfl\n\n@[simp]\nlemma is_limit_equiv_sections_symm_apply\n  {F : J \u2964 Type (max v u)} {c : cone F} (t : is_limit c) (x : F.sections) (j : J) :\n  c.\u03c0.app j ((is_limit_equiv_sections t).symm x) = (x : \u03a0 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 \u2964 Type (max v u)) : (limit F : Type (max v u)) \u2243 F.sections :=\nis_limit_equiv_sections (limit.is_limit _)\n\n@[simp]\nlemma limit_equiv_sections_apply (F : J \u2964 Type (max v u)) (x : limit F) (j : J) :\n  (((limit_equiv_sections F) x) : \u03a0 j, F.obj j) j = limit.\u03c0 F j x :=\nrfl\n\n@[simp]\nlemma limit_equiv_sections_symm_apply (F : J \u2964 Type (max v u)) (x : F.sections) (j : J) :\n  limit.\u03c0 F j ((limit_equiv_sections F).symm x) = (x : \u03a0 j, F.obj j) j :=\nis_limit_equiv_sections_symm_apply _ _ _\n\n@[simp]\nlemma limit_equiv_sections_symm_apply' (F : J \u2964 Type v) (x : F.sections) (j : J) :\n  limit.\u03c0 F j ((limit_equiv_sections.{v v} F).symm x) = (x : \u03a0 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 : \u03a0 j, F.obj j`\nwhich are \"coherent\": `\u2200 (j j') (f : j \u27f6 j'), F.map f (x j) = x j'`.\n-/\n@[ext]\nnoncomputable\ndef limit.mk (F : J \u2964 Type (max v u)) (x : \u03a0 j, F.obj j)\n  (h : \u2200 (j j') (f : j \u27f6 j'), F.map f (x j) = x j') : (limit F : Type (max v u)) :=\n(limit_equiv_sections F).symm \u27e8x, h\u27e9\n\n@[simp]\nlemma limit.\u03c0_mk (F : J \u2964 Type (max v u)) (x : \u03a0 j, F.obj j)\n  (h : \u2200 (j j') (f : j \u27f6 j'), F.map f (x j) = x j') (j) : limit.\u03c0 F j (limit.mk F x h) = x j :=\nby { dsimp [limit.mk], simp, }\n\n@[simp]\nlemma limit.\u03c0_mk' (F : J \u2964 Type v) (x : \u03a0 j, F.obj j)\n  (h : \u2200 (j j') (f : j \u27f6 j'), F.map f (x j) = x j') (j) :\n  limit.\u03c0 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 \u2964 Type (max v u)) (x y : limit F) (w : \u2200 j, limit.\u03c0 F j x = limit.\u03c0 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 \u2964 Type v) (x y : limit F) (w : \u2200 j, limit.\u03c0 F j x = limit.\u03c0 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 \u2964 Type (max v u)) (x y : limit F) :\n  x = y \u2194 (\u2200 j, limit.\u03c0 F j x = limit.\u03c0 F j y) :=\n\u27e8\u03bb t _, t \u25b8 rfl, limit_ext _ _ _\u27e9\n\nlemma limit_ext_iff' (F : J \u2964 Type v) (x y : limit F) :\n  x = y \u2194 (\u2200 j, limit.\u03c0 F j x = limit.\u03c0 F j y) :=\n\u27e8\u03bb t _, t \u25b8 rfl, limit_ext _ _ _\u27e9\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 \u2964 Type (max v u)} {j j' : J} {x : limit F} (f : j \u27f6 j') :\n  F.map f (limit.\u03c0 F j x) = limit.\u03c0 F j' x :=\ncongr_fun (limit.w F f) x\n\n@[simp]\nlemma limit.lift_\u03c0_apply (F : J \u2964 Type (max v u)) (s : cone F) (j : J) (x : s.X) :\n  limit.\u03c0 F j (limit.lift F s x) = s.\u03c0.app j x :=\ncongr_fun (limit.lift_\u03c0 s j) x\n\n@[simp]\nlemma limit.map_\u03c0_apply {F G : J \u2964 Type (max v u)} (\u03b1 : F \u27f6 G) (j : J) (x) :\n  limit.\u03c0 G j (lim_map \u03b1 x) = \u03b1.app j (limit.\u03c0 F j x) :=\ncongr_fun (lim_map_\u03c0 \u03b1 j) x\n\n@[simp]\nlemma limit.w_apply' {F : J \u2964 Type v} {j j' : J} {x : limit F} (f : j \u27f6 j') :\n  F.map f (limit.\u03c0 F j x) = limit.\u03c0 F j' x :=\ncongr_fun (limit.w F f) x\n\n@[simp]\nlemma limit.lift_\u03c0_apply' (F : J \u2964 Type v) (s : cone F) (j : J) (x : s.X) :\n  limit.\u03c0 F j (limit.lift F s x) = s.\u03c0.app j x :=\ncongr_fun (limit.lift_\u03c0 s j) x\n\n@[simp]\nlemma limit.map_\u03c0_apply' {F G : J \u2964 Type v} (\u03b1 : F \u27f6 G) (j : J) (x) :\n  limit.\u03c0 G j (lim_map \u03b1 x) = \u03b1.app j (limit.\u03c0 F j x) :=\ncongr_fun (lim_map_\u03c0 \u03b1 j) x\n\n/--\nThe relation defining the quotient type which implements the colimit of a functor `F : J \u2964 Type u`.\nSee `category_theory.limits.types.quot`.\n-/\ndef quot.rel (F : J \u2964 Type (max v u)) : (\u03a3 j, F.obj j) \u2192 (\u03a3 j, F.obj j) \u2192 Prop :=\n(\u03bb p p', \u2203 f : p.1 \u27f6 p'.1, p'.2 = F.map f p.2)\n\n/--\nA quotient type implementing the colimit of a functor `F : J \u2964 Type u`,\nas pairs `\u27e8j, x\u27e9` where `x : F.obj j`, modulo the equivalence relation generated by\n`\u27e8j, x\u27e9 ~ \u27e8j', x'\u27e9` whenever there is a morphism `f : j \u27f6 j'` so `F.map f x = x'`.\n-/\n@[nolint has_inhabited_instance]\ndef quot (F : J \u2964 Type (max v u)) : Type (max v u) :=\n@quot (\u03a3 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 \u2964 Type (max v u)) : cocone F :=\n{ X := quot F,\n  \u03b9 :=\n  { app := \u03bb j x, quot.mk _ \u27e8j, x\u27e9,\n    naturality' := \u03bb j j' f, funext $ \u03bb x, eq.symm (quot.sound \u27e8f, rfl\u27e9) } }\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 \u2964 Type (max v u)) : is_colimit (colimit_cocone F) :=\n{ desc := \u03bb s, quot.lift (\u03bb (p : \u03a3 j, F.obj j), s.\u03b9.app p.1 p.2)\n    (assume \u27e8j, x\u27e9 \u27e8j', x'\u27e9 \u27e8f, hf\u27e9, 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 := \u03bb J \ud835\udca5, by exactI\n  { has_colimit := \u03bb 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 \u2964 Type (max v u)) : (colimit F : Type (max v u)) \u2243 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 \u2964 Type (max v u)) (j : J) (x : F.obj j) :\n  (colimit_equiv_quot F).symm (quot.mk _ \u27e8j, x\u27e9) = colimit.\u03b9 F j x :=\nrfl\n\n@[simp]\nlemma colimit_equiv_quot_apply (F : J \u2964 Type (max v u)) (j : J) (x : F.obj j) :\n  (colimit_equiv_quot F) (colimit.\u03b9 F j x) = quot.mk _ \u27e8j, x\u27e9 :=\nbegin\n  apply (colimit_equiv_quot F).symm.injective,\n  simp,\nend\n\n@[simp]\nlemma colimit.w_apply {F : J \u2964 Type (max v u)} {j j' : J} {x : F.obj j} (f : j \u27f6 j') :\n  colimit.\u03b9 F j' (F.map f x) = colimit.\u03b9 F j x :=\ncongr_fun (colimit.w F f) x\n\n@[simp]\nlemma colimit.\u03b9_desc_apply (F : J \u2964 Type (max v u)) (s : cocone F) (j : J) (x : F.obj j) :\n  colimit.desc F s (colimit.\u03b9 F j x) = s.\u03b9.app j x :=\ncongr_fun (colimit.\u03b9_desc s j) x\n\n@[simp]\nlemma colimit.\u03b9_map_apply {F G : J \u2964 Type (max v u)} (\u03b1 : F \u27f6 G) (j : J) (x) :\n  colim.map \u03b1 (colimit.\u03b9 F j x) = colimit.\u03b9 G j (\u03b1.app j x) :=\ncongr_fun (colimit.\u03b9_map \u03b1 j) x\n\n@[simp]\nlemma colimit.w_apply' {F : J \u2964 Type v} {j j' : J} {x : F.obj j} (f : j \u27f6 j') :\n  colimit.\u03b9 F j' (F.map f x) = colimit.\u03b9 F j x :=\ncongr_fun (colimit.w F f) x\n\n@[simp]\nlemma colimit.\u03b9_desc_apply' (F : J \u2964 Type v) (s : cocone F) (j : J) (x : F.obj j) :\n  colimit.desc F s (colimit.\u03b9 F j x) = s.\u03b9.app j x :=\ncongr_fun (colimit.\u03b9_desc s j) x\n\n@[simp]\nlemma colimit.\u03b9_map_apply' {F G : J \u2964 Type v} (\u03b1 : F \u27f6 G) (j : J) (x) :\n  colim.map \u03b1 (colimit.\u03b9 F j x) = colimit.\u03b9 G j (\u03b1.app j x) :=\ncongr_fun (colimit.\u03b9_map \u03b1 j) x\n\nlemma colimit_sound\n  {F : J \u2964 Type (max v u)} {j j' : J} {x : F.obj j} {x' : F.obj j'}\n  (f : j \u27f6 j') (w : F.map f x = x') : colimit.\u03b9 F j x = colimit.\u03b9 F j' x' :=\nbegin\n  rw [\u2190w],\n  simp,\nend\n\nlemma colimit_sound'\n  {F : J \u2964 Type (max v u)} {j j' : J} {x : F.obj j} {x' : F.obj j'} {j'' : J}\n  (f : j \u27f6 j'') (f' : j' \u27f6 j'') (w : F.map f x = F.map f' x') :\n  colimit.\u03b9 F j x = colimit.\u03b9 F j' x' :=\nbegin\n  rw [\u2190colimit.w _ f, \u2190colimit.w _ f'],\n  rw [types_comp_apply, types_comp_apply, w],\nend\n\nlemma colimit_eq {F : J \u2964 Type (max v u)} {j j' : J} {x : F.obj j} {x' : F.obj j'}\n  (w : colimit.\u03b9 F j x = colimit.\u03b9 F j' x') : eqv_gen (quot.rel F) \u27e8j, x\u27e9 \u27e8j', x'\u27e9 :=\nbegin\n  apply quot.eq.1,\n  simpa using congr_arg (colimit_equiv_quot F) w,\nend\n\nlemma jointly_surjective (F : J \u2964 Type (max v u)) {t : cocone F} (h : is_colimit t)\n  (x : t.X) : \u2203 j y, t.\u03b9.app j y = x :=\nbegin\n  suffices : (\u03bb (x : t.X), ulift.up (\u2203 j y, t.\u03b9.app j y = x)) = (\u03bb _, 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 \u27e8j, y, rfl\u27e9\nend\n\n/-- A variant of `jointly_surjective` for `x : colimit F`. -/\nlemma jointly_surjective' {F : J \u2964 Type (max v u)}\n  (x : colimit F) : \u2203 j y, colimit.\u03b9 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 \u2964 Type (max v u))\n\n/--\nAn alternative relation on `\u03a3 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 : \u03a3 j, F.obj j) : Prop :=\n\u2203 k (f : x.1 \u27f6 k) (g : y.1 \u27f6 k), F.map f x.2 = F.map g y.2\n\n\n\nlemma eqv_gen_quot_rel_of_rel (x y : \u03a3 j, F.obj j) :\n  filtered_colimit.rel F x y \u2192 eqv_gen (quot.rel F) x y :=\n\u03bb \u27e8k, f, g, h\u27e9, eqv_gen.trans _ \u27e8k, F.map f x.2\u27e9 _ (eqv_gen.rel _ _ \u27e8f, rfl\u27e9)\n  (eqv_gen.symm _ _ (eqv_gen.rel _ _ \u27e8g, h\u27e9))\n\nlocal attribute [elab_simple] nat_trans.app\n\n/-- Recognizing filtered colimits of types. -/\nnoncomputable def is_colimit_of (t : cocone F) (hsurj : \u2200 (x : t.X), \u2203 i xi, x = t.\u03b9.app i xi)\n  (hinj : \u2200 i j xi xj, t.\u03b9.app i xi = t.\u03b9.app j xj \u2192\n   \u2203 k (f : i \u27f6 k) (g : j \u27f6 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 \u27e8i, xi, rfl\u27e9,\n      rcases jointly_surjective F (colimit.is_colimit F) b with \u27e8j, xj, rfl\u27e9,\n      change (colimit.\u03b9 F i \u226b colimit.desc F t) xi = (colimit.\u03b9 F j \u226b colimit.desc F t) xj at h,\n      rw [colimit.\u03b9_desc, colimit.\u03b9_desc] at h,\n      rcases hinj i j xi xj h with \u27e8k, f, g, h'\u27e9,\n      change colimit.\u03b9 F i xi = colimit.\u03b9 F j xj,\n      rw [\u2190colimit.w F f, \u2190colimit.w F g],\n      change colimit.\u03b9 F k (F.map f xi) = colimit.\u03b9 F k (F.map g xj),\n      rw h' },\n    { show function.surjective _,\n      intro x,\n      rcases hsurj x with \u27e8i, xi, rfl\u27e9,\n      use colimit.\u03b9 F i xi,\n      simp } },\n  { intro j, apply colimit.\u03b9_desc }\nend\n\nvariables [is_filtered_or_empty J]\n\nprotected lemma rel_equiv : equivalence (filtered_colimit.rel F) :=\n\u27e8\u03bb x, \u27e8x.1, \ud835\udfd9 x.1, \ud835\udfd9 x.1, rfl\u27e9,\n \u03bb x y \u27e8k, f, g, h\u27e9, \u27e8k, g, f, h.symm\u27e9,\n \u03bb x y z \u27e8k, f, g, h\u27e9 \u27e8k', f', g', h'\u27e9,\n   let \u27e8l, fl, gl, _\u27e9 := is_filtered_or_empty.cocone_objs k k',\n       \u27e8m, n, hn\u27e9 := is_filtered_or_empty.cocone_maps (g \u226b fl) (f' \u226b gl) in\n   \u27e8m, f \u226b fl \u226b n, g' \u226b gl \u226b n, calc\n      F.map (f \u226b fl \u226b n) x.2\n          = F.map (fl \u226b n) (F.map f x.2)  : by simp\n      ... = F.map (fl \u226b n) (F.map g y.2)  : by rw h\n      ... = F.map ((g \u226b fl) \u226b n) y.2      : by simp\n      ... = F.map ((f' \u226b gl) \u226b n) y.2     : by rw hn\n      ... = F.map (gl \u226b n) (F.map f' y.2) : by simp\n      ... = F.map (gl \u226b n) (F.map g' z.2) : by rw h'\n      ... = F.map (g' \u226b gl \u226b n) z.2       : by simp\u27e9\u27e9\n\nprotected lemma rel_eq_eqv_gen_quot_rel :\n  filtered_colimit.rel F = eqv_gen (quot.rel F) :=\nbegin\n  ext \u27e8j, x\u27e9 \u27e8j', y\u27e9,\n  split,\n  { apply eqv_gen_quot_rel_of_rel },\n  { rw \u2190(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).\u03b9.app i xi = (colimit_cocone F).\u03b9.app j xj \u2194\n    filtered_colimit.rel F \u27e8i, xi\u27e9 \u27e8j, xj\u27e9 :=\nbegin\n  change quot.mk _ _ = quot.mk _ _ \u2194 _,\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.\u03b9.app i xi = t.\u03b9.app j xj \u2194 \u2203 k (f : i \u27f6 k) (g : j \u27f6 k), F.map f xi = F.map g xj :=\nlet t' := colimit_cocone F,\n    e : t' \u2245 t := is_colimit.unique_up_to_iso (colimit_cocone_is_colimit F) ht,\n    e' : t'.X \u2245 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 \u2190e.hom.w; refl\nend\n\nlemma colimit_eq_iff {i j : J} {xi : F.obj i} {xj : F.obj j} :\n  colimit.\u03b9 F i xi = colimit.\u03b9 F j xj \u2194 \u2203 k (f : i \u27f6 k) (g : j \u27f6 k), F.map f xi = F.map g xj :=\nis_colimit_eq_iff _ (colimit.is_colimit F)\n\nend filtered_colimit\n\nvariables {\u03b1 \u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2)\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 \u03b1] : inhabited (image f) :=\n{ default := \u27e8f default, \u27e8_, rfl\u27e9\u27e9 }\n\n/-- the inclusion of `image f` into the target -/\ndef image.\u03b9 : image f \u27f6 \u03b2 := subtype.val\n\ninstance : mono (image.\u03b9 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 \u27f6 F'.I :=\n(\u03bb x, F'.e (classical.indefinite_description _ x.2).1 : image f \u2192 F'.I)\n\nlemma image.lift_fac (F' : mono_factorisation f) : image.lift F' \u226b F'.m = image.\u03b9 f :=\nbegin\n  ext x,\n  change (F'.e \u226b 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.\u03b9 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 \u27e8_, is_image f\u27e9\n\ninstance : has_images (Type u) :=\n{ has_image := by apply_instance }\n\ninstance : has_image_maps (Type u) :=\n{ has_image_map := \u03bb f g st, has_image_map.transport st (mono_factorisation f.hom) (is_image g.hom)\n    (\u03bb x, \u27e8st.right x.1, \u27e8st.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\u27e9\u27e9) 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 (\u0393 :  set form) := \n\u2200 {p : form}, (\u0393 \u22a2\u1d62 p) \u2192 p \u2208 \u0393\n\ndef has_disj (\u0393 :  set form) := \n\u2200 {p q : form}, ((p \u2228 q) \u2208 \u0393) \u2192 ((p \u2208 \u0393) \u2228 (q \u2208 \u0393))\n\ndef is_max (\u0393 :  set form) := \nis_closed \u0393 \u2227 has_disj \u0393\n\n/-- extension -/\n\ndef insert_form (\u0393 :  set form) (p q r : form) :  set form :=\nif (\u0393 \u2e34 p \u22a2\u1d62 r) then \u0393 \u2e34 q else \u0393 \u2e34 p\n\n@[simp]\ndef insert_code (\u0393 :  set form) (r : form) (n : nat) :  set form :=\nmatch encodable.decode (form) n with\n| none := \u0393\n| some (p \u2228 q) := if \u0393 \u22a2\u1d62 p \u2228 q then insert_form \u0393 p q r else \u0393\n| some _ := \u0393\nend\n\n@[simp]\ndef insertn (\u0393 :  set form) (r : form) : nat \u2192  set form\n| 0     := \u0393 \n| (n+1) := insert_code (insertn n) r n \n\n@[simp]\ndef maxn (\u0393 :  set form) (r : form) : nat \u2192  set form\n| 0     := \u0393\n| (n+1) := \u22c3 i, insertn (maxn n) r i \n\n@[simp]\ndef max (\u0393 :  set form) (r : form) :  set form := \n\u22c3 n, maxn \u0393 r n\n\n/- max extends the original set -/\n\nlemma subset_insert_code {\u0393 :  set form} {r : form} (n) :\n  \u0393 \u2286 insert_code \u0393 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 {\u0393 :  set form} {r : form} (n) :\n  maxn \u0393 r n \u2286 max \u0393 r :=\nsubset_Union _ _\n\nlemma subset_insertn {\u0393 :  set form} {r : form} {n} :\n  \u0393 \u2286 insertn \u0393 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 {\u0393 :  set form} {r : form} :\n  \u0393 \u2286 max \u0393 r :=\nmaxn_subset_max 0\n\nlemma insertn_sub_maxn {\u0393 :  set form} {r : form} {n m : nat} :\n  insertn (maxn \u0393 r n) r m \u2286 maxn \u0393 r (n+1) :=\nsubset_Union _ _\n\nlemma insertn_to_max {\u0393 :  set form} {r : form} {n m : nat} :\n  insertn (maxn \u0393 r n) r m \u2286 max \u0393 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 {\u0393 :  set form} {p r : form} :\n  (p \u2208 max \u0393 r ) \u2192 \u2203 n, p \u2208 maxn \u0393 r n :=\nmem_Union.1\n\nlemma in_maxn_in_insertn {\u0393 :  set form} {p r : form} {n} :\n  (p \u2208 maxn \u0393 r (n+1) ) \u2192 \u2203 i, p \u2208 insertn (maxn \u0393 r n) r i :=\nmem_Union.1\n\nlemma maxn_subset_succ {\u0393 :  set form} {r : form} {n : nat} :\n  maxn \u0393 r n \u2286 maxn \u0393 r (n+1) :=\nbegin\n  apply subset.trans,\n  { apply subset_insertn,\n    repeat {assumption} },\n  { exact subset_Union _ _}\nend\n\nlemma maxn_mono {\u0393 :  set form} {r : form} {m n : nat} (h : n \u2264 m) :\n  maxn \u0393 r n \u2286 maxn \u0393 r m :=\nby induction h; [refl, exact subset.trans h_ih maxn_subset_succ ]\n\nlemma insertn_mono {\u0393 :  set form} {r : form} {m n : nat} (h : n \u2264 m) :\n  insertn \u0393 r n \u2286 insertn \u0393 r m :=\nby induction h; [refl, exact subset.trans h_ih (subset_insert_code _)]\n\ndef maxn_sub_prf {\u0393 :  set form} {p r : form} : \n  (max \u0393 r \u22a2\u1d62 p) \u2192 \u2203 n, maxn \u0393 r n \u22a2\u1d62 p :=\nbegin\n  generalize eq : max \u0393 r = \u0393',\n  intro h, induction h; subst eq,\n  { cases in_max_in_maxn h_h with n hpq,\n    exact \u27e8n, prf.ax hpq\u27e9 }, \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 \u2264 j)),\n    { have hn: j \u2264 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 {\u0393 :  set form} {p r : form} {n} :\n  (maxn \u0393 r (n+1) \u22a2\u1d62 p) \u2192 \u2203 i, insertn (maxn \u0393 r n) r i \u22a2\u1d62 p :=\nbegin\n  generalize eq : maxn \u0393 r (n+1) = \u0393',\n  intro h, induction h; subst eq,\n  { cases in_maxn_in_insertn h_h with n hpq,\n    exact \u27e8n, prf.ax hpq\u27e9 },\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 \u2264 j)),\n      { have hn: j \u2264 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 {\u0393 :  set form} {p q r : form} (h : (p \u2228 q) \u2208 max \u0393 r) : \n  \u2203 n, p \u2208 (insertn (maxn \u0393 r n) r (encodable.encode (p \u2228 q)+1)) \u2228 \n       q \u2208 (insertn (maxn \u0393 r n) r (encodable.encode (p \u2228 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 \u2228 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 {\u0393 :  set form} {p q r : form} : \n  ((p \u2228 q) \u2208 max \u0393 r) \u2192 p \u2208 max \u0393 r \u2228 q \u2208 max \u0393 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 {\u0393 :  set form} {p r : form} : \n  (max \u0393 r \u22a2\u1d62 r \u2228 p) \u2192 \u2203 n, p \u2208 (insertn (maxn \u0393 r n) r (encodable.encode (r \u2228 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 \u2228 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 {\u0393 :  set form} {p q r : form} : \n  (max \u0393 r \u22a2\u1d62 p) \u2192 p \u2208 max \u0393 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 {\u0393 :  set form} {p : form} {i} : \n  (insertn \u0393 p i \u22a2\u1d62 p) \u2192 (\u0393 \u22a2\u1d62 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 {\u0393 :  set form} {p : form} {n} : \n  (maxn \u0393 p n \u22a2\u1d62 p) \u2192 (\u0393 \u22a2\u1d62 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 {\u0393 :  set form} {p : form} : \n  (max \u0393 p \u22a2\u1d62 p) \u2192 (\u0393 \u22a2\u1d62 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 {\u0393 :  set form} {r : form} : \n ctx.is_max (ctx.max \u0393 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 {\u0393 :  set form} {r : form} (h : \u0393 \u22ac\u1d62 r) : \n ctx.max \u0393 r \u22ac\u1d62 r :=\n\u03bb hm, h (ctx.max_not_prf hm)\n\n/- the canonical model construction -/\n\n-- domain\n\nnamespace canonical\n\ndef is_consist (\u0393 :  set form) := \u0393 \u22ac\u1d62 \u22a5\n\ndef domain : set (wrld) := {w | is_consist w \u2227  ctx.is_max w}\n\n-- accessibility\n\ndef access : wrld \u2192 wrld \u2192 Prop :=\n\u03bb w v, w \u2286 v\n\n-- valuation\n\ndef val : \u2115 \u2192 wrld \u2192 Prop :=\n\u03bb q w, w \u2208 domain \u2227 (#q) \u2208 w\n\n-- reflexivity\n\nlemma access.refl :\n  \u2200 w \u2208 domain, access w w :=\nbegin\n  intros, unfold access\nend\n\n-- transitivity\n\nlemma access.trans : \u2200 w \u2208 domain, \u2200 v \u2208 domain, \u2200 u \u2208 domain,\n  access w v \u2192 access v u \u2192 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 {\u0393 :  set form} {p : form} : \n  (\u0393 \u22ac\u1d62 p) \u2192 is_consist \u0393 :=\n\u03bb 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  \u2200 (w \u2208 domain), (w \u22a9\u2983model\u2984 p) \u2194 (w \u22a2\u1d62 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  -- \u22a5\n  { simp [forces_form],\n    intros w H hn, exact H.1 hn },\n  -- \u2283\n  intros,\n  split,\n  { intro Hw,\n    cases (em _),\n    { assumption },\n    { have hd : ctx.max (w \u2e34 p) q \u2208 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 \u2e34 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 \u2e34 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    -- \u2228 \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 {\u0393 :  set form} (wm : \u0393 \u2208 domain) : \n  (\u0393 \u22a9\u2983model\u2984 \u0393) :=\nby { intros p hp, apply (model_tt_iff_prf \u0393 wm).2, apply prf.ax, assumption }\n\n/- the completeness theorem -/\n\ntheorem completeness {\u0393 :  set form} {p : form} : \n  (\u0393 \u22a8\u1d62 p) \u2192 (\u0393 \u22a2\u1d62 p) :=\nbegin\n  apply (@not_imp_not (\u0393 \u22a2\u1d62 p) (\u0393 \u22a8\u1d62 p) (prop_decidable _)).1,\n  intros nhp hp,\n  have hd: ctx.max \u0393 p \u2208 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 \u0393 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 \u27f6 Y) (g : Y \u27f6 Z) (H : C) (w : f \u226b 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 \u27f6 Y` and `g : Y \u27f6 Z`.\nWhen `0 \u27f6 K \u27f6 Y \u27f6 Z` and `X \u27f6 K \u27f6 Q \u27f6 0` are exact, this\nwill give a `h : homology_iso_datum f g H` and there shall\nbe an isomorphism `h.iso : H \u2245 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 \u27f6 Z` and\n`H` can be any choice of cokernel for `X \u27f6 K`. -/\n@[nolint has_inhabited_instance]\nstructure homology_iso_predatum :=\n(w : f \u226b g = 0)\n(K : C) (\u03b9 : K \u27f6 Y) (f' : X \u27f6 K) (fac' : f' \u226b \u03b9 = f) (zero\u2081' : \u03b9 \u226b g = 0)\n(\u03c0 : K \u27f6 H) (zero\u2082' : f' \u226b \u03c0 = 0)\n\nnamespace homology_iso_predatum\n\nrestate_axiom fac'\nrestate_axiom zero\u2081'\nrestate_axiom zero\u2082'\nattribute [simp, reassoc] fac zero\u2081 zero\u2082\n\n@[simps]\ndef tautological : homology_iso_predatum f g (cokernel (kernel.lift g f w)) :=\n{ w := w,\n  K := kernel g,\n  \u03b9 := kernel.\u03b9 _,\n  f' := kernel.lift g f w,\n  fac' := kernel.lift_\u03b9 _ _ _,\n  zero\u2081' := kernel.condition _,\n  \u03c0 := cokernel.\u03c0 _,\n  zero\u2082' := cokernel.condition _, }\n\n@[simps]\ndef tautological' : homology_iso_predatum f g (homology f g w):=\n{ w := w,\n  K := kernel g,\n  \u03b9 := kernel.\u03b9 _,\n  f' := kernel.lift g f w,\n  fac' := kernel.lift_\u03b9 _ _ _,\n  zero\u2081' := kernel.condition _,\n  \u03c0 := homology.\u03c0' f g w,\n  zero\u2082' := homology.condition_\u03c0' _ _ _, }\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_\u03b9 h.\u03b9 h.zero\u2081\n\n@[simps]\ndef cofork : cokernel_cofork h.f' := cokernel_cofork.of_\u03c0 h.\u03c0 h.zero\u2082\n\n@[simps]\ndef apply_functor {D : Type*} [category D] [abelian D] (F : C \u2964 D) [F.additive] :\n  homology_iso_predatum (F.map f) (F.map g) (F.obj H):=\n{ w := by rw [\u2190 F.map_comp, h.w, F.map_zero],\n  K := F.obj h.K,\n  \u03b9 := F.map h.\u03b9,\n  f' := F.map h.f',\n  fac' := by rw [\u2190 F.map_comp, h.fac],\n  zero\u2081' := by simp only [\u2190 F.map_comp, zero\u2081, F.map_zero],\n  \u03c0 := F.map h.\u03c0,\n  zero\u2082' := by simp only [\u2190 F.map_comp, zero\u2082, F.map_zero], }\n\ninclude h\n\n@[simps]\ndef map_iso {X' Y' Z' : C} (f' : X' \u27f6 Y') (g' : Y' \u27f6 Z') (e\u2081 : arrow.mk f \u2245 arrow.mk f')\n  (e\u2082 : arrow.mk g \u2245 arrow.mk g') (eq : e\u2081.hom.right = e\u2082.hom.left) :\n  homology_iso_predatum f' g' H :=\nbegin\n  have comm\u2081 : e\u2081.hom.left \u226b f' = f \u226b e\u2081.hom.right := arrow.w e\u2081.hom,\n  have comm\u2082 : e\u2082.hom.left \u226b g' = g \u226b e\u2082.hom.right := arrow.w e\u2082.hom,\n  have h\u2081 : e\u2081.inv.left \u226b e\u2081.hom.left = \ud835\udfd9 X',\n  { rw [\u2190 comma.comp_left, e\u2081.inv_hom_id, arrow.id_left], refl, },\n  exact\n  { w := by { rw [\u2190 cancel_epi e\u2081.hom.left, \u2190 category.assoc, comm\u2081, eq, category.assoc, comm\u2082,\n      \u2190 category.assoc, h.w, zero_comp, comp_zero], },\n    K := h.K,\n    \u03b9 := h.\u03b9 \u226b e\u2081.hom.right,\n    f' := e\u2081.inv.left \u226b h.f',\n    fac' := begin\n      slice_lhs 2 3 { rw h.fac', },\n      rw [\u2190 comm\u2081, \u2190 category.assoc, h\u2081, category.id_comp],\n    end,\n    zero\u2081' := by rw [eq, category.assoc, comm\u2082, \u2190 category.assoc, h.zero\u2081', zero_comp],\n    \u03c0 := h.\u03c0,\n    zero\u2082' := by rw [category.assoc, h.zero\u2082', 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' \u27f6 Y') (g' : Y' \u27f6 Z') (e\u2081 : arrow.mk f \u2245 arrow.mk f')\n  (e\u2082 : arrow.mk g \u2245 arrow.mk g') (eq : e\u2081.hom.right = e\u2082.hom.left) :\n  homology_iso_datum f' g' H :=\n{ to_homology_iso_predatum := h.to_homology_iso_predatum.map_iso f' g' e\u2081 e\u2082 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\u2081) (arrow.right_func.map_iso e\u2082)\n       _ (by simp),\n      have h\u2082 := arrow.w e\u2082.hom,\n      dsimp at h\u2082 \u22a2,\n      rw [eq, h\u2082], },\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\u2081)) (iso.refl _) _ (by tidy),\n      { dsimp,\n        have h\u2081 : e\u2081.hom.left \u226b e\u2081.inv.left = \ud835\udfd9 X,\n        { rw [\u2190 comma.comp_left, e\u2081.hom_inv_id, arrow.id_left], refl, },\n        rw [category.comp_id, \u2190 category.assoc, h\u2081, category.id_comp], }, },\n    { refine cocones.ext (iso.refl _) _,\n      rintro (_|_),\n      tidy, },\n  end, }\n\ndef iso\u2081 : h.K \u2245 kernel g :=\nis_limit.cone_point_unique_up_to_iso h.fork_is_limit (limit_cone.is_limit _)\n\n@[simp, reassoc]\nlemma iso\u2081_hom_kernel_\u03b9 : h.iso\u2081.hom \u226b kernel.\u03b9 g = h.\u03b9 :=\nis_limit.cone_point_unique_up_to_iso_hom_comp _ _ _\n\ninstance : mono h.\u03b9 := by { rw \u2190 h.iso\u2081_hom_kernel_\u03b9, apply_instance, }\n\n@[simp, reassoc]\nlemma f'_iso\u2081_hom : h.f' \u226b h.iso\u2081.hom = kernel.lift g f h.w :=\nbegin\n  ext,\n  simp only [category.assoc, iso\u2081_hom_kernel_\u03b9, homology_iso_predatum.fac, kernel.lift_\u03b9],\nend\n\ndef iso\u2082 : H \u2245 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_\u03c0_iso\u2082_inv : cokernel.\u03c0 h.f' \u226b h.iso\u2082.inv = h.\u03c0 :=\nis_colimit.comp_cocone_point_unique_up_to_iso_inv _ _ _\n\n@[reassoc]\nlemma cokernel_f'_eq_\u03c0_iso\u2082_hom : cokernel.\u03c0 h.f' = h.\u03c0 \u226b h.iso\u2082.hom :=\nby rw [\u2190 cokernel_\u03c0_iso\u2082_inv, category.assoc, h.iso\u2082.inv_hom_id, category.comp_id]\n\ninstance : epi h.\u03c0 := by { rw \u2190 h.cokernel_\u03c0_iso\u2082_inv, apply epi_comp, }\n\ndef iso\u2083 : cokernel h.f' \u2245 cokernel (kernel.lift g f h.w) :=\ncokernel.map_iso _ _ (iso.refl _) h.iso\u2081\n  (by simp only [f'_iso\u2081_hom, iso.refl_hom, category.id_comp])\n\n@[simp, reassoc]\nlemma cokernel_\u03c0_iso\u2083_hom :\n  cokernel.\u03c0 h.f' \u226b h.iso\u2083.hom = h.iso\u2081.hom \u226b cokernel.\u03c0 (kernel.lift g f h.w) :=\nbegin\n  dsimp only [iso\u2083],\n  simp only [cokernel.map_iso_hom, cokernel.\u03c0_desc],\nend\n\nvariables (f g)\n\n@[simp]\nlemma tautological_iso\u2081 : (tautological f g w).iso\u2081 = iso.refl _ :=\nbegin\n  ext,\n  dsimp only [iso\u2081],\n  simp only [equalizer_as_kernel, iso.refl_hom, category.id_comp],\n  change kernel.lift _ _ _ \u226b _ = _,\n  simpa only [equalizer_as_kernel, kernel.lift_\u03b9],\nend\n\n@[simp]\nlemma tautological'_iso\u2081 : (tautological' f g w).iso\u2081 = iso.refl _ :=\nbegin\n  ext,\n  dsimp only [iso\u2081],\n  simp only [equalizer_as_kernel, iso.refl_hom, category.id_comp],\n  change kernel.lift _ _ _ \u226b _ = _,\n  simpa only [equalizer_as_kernel, kernel.lift_\u03b9],\nend\n\n@[simp]\nlemma tautological_iso\u2082 : (tautological f g w).iso\u2082 = iso.refl _ :=\nbegin\n  suffices : (tautological f g w).iso\u2082.symm = iso.refl _,\n  { change (tautological f g w).iso\u2082.symm.symm = _,\n    simpa only [this], },\n  ext,\n  simpa only [iso.symm_hom, cokernel_\u03c0_iso\u2082_inv, iso.refl_hom, category.comp_id],\nend\n\n@[simp]\nlemma tautological_iso\u2083 : (tautological f g w).iso\u2083 = iso.refl _ :=\nbegin\n  ext,\n  simpa only [cokernel_\u03c0_iso\u2083_hom, tautological_iso\u2081, iso.refl_hom, category.id_comp, category.comp_id],\nend\n\nvariables {f g}\n\ndef iso : H \u2245 homology f g h.w :=\nh.iso\u2082 \u226a\u226b h.iso\u2083 \u226a\u226b (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\u2082, tautological_iso\u2083, 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\u2081 H\u2082 : C} (h\u2081 : homology_iso_datum f g H\u2081)\n  (h\u2082 : homology_iso_datum f g H\u2082) :=\n(\u03ba : h\u2081.K \u27f6 h\u2082.K) (fac\u2081' : h\u2081.f' \u226b \u03ba = h\u2082.f') (fac\u2082' : \u03ba \u226b h\u2082.\u03b9 = h\u2081.\u03b9)\n(\u03b7 : H\u2081 \u27f6 H\u2082) (fac\u2083' : h\u2081.\u03c0 \u226b \u03b7 = \u03ba \u226b h\u2082.\u03c0)\n\nnamespace change\n\nrestate_axiom fac\u2081'\nrestate_axiom fac\u2082'\nrestate_axiom fac\u2083'\nattribute [simp, reassoc] fac\u2081 fac\u2082\nattribute [reassoc] fac\u2083\n\nvariables {H\u2081 H\u2082 : C} {h\u2081 : homology_iso_datum f g H\u2081}\n  {h\u2082 : homology_iso_datum f g H\u2082} (c : change h\u2081 h\u2082)\n\n@[simp, reassoc]\nlemma fac_iso\u2081 : c.\u03ba \u226b h\u2082.iso\u2081.hom = h\u2081.iso\u2081.hom :=\nby { ext, simp only [category.assoc, iso\u2081_hom_kernel_\u03b9, fac\u2082], }\n\ninstance : is_iso c.\u03ba := is_iso.of_is_iso_fac_right (c.fac_iso\u2081)\n\ndef coker_iso : cokernel h\u2081.f' \u2245 cokernel h\u2082.f' :=\ncokernel.map_iso _ _ (iso.refl _) (as_iso c.\u03ba)\n(by simp only [as_iso_hom, fac\u2081, iso.refl_hom, category.id_comp])\n\n@[simp, reassoc]\nlemma coker_iso_comm : cokernel.\u03c0 h\u2081.f' \u226b c.coker_iso.hom = c.\u03ba \u226b cokernel.\u03c0 h\u2082.f' :=\nbegin\n  dsimp only [coker_iso],\n  simp only [as_iso_hom, cokernel.map_iso_hom, cokernel.\u03c0_desc],\nend\n\n@[reassoc]\nlemma fac_iso\u2082 : c.coker_iso.hom \u226b h\u2082.iso\u2082.inv = h\u2081.iso\u2082.inv \u226b c.\u03b7 :=\nbegin\n  ext,\n  simp only [coker_iso_comm_assoc, cokernel_\u03c0_iso\u2082_inv, cokernel_\u03c0_iso\u2082_inv_assoc,\n    fac\u2083],\nend\n\ninstance : is_iso c.\u03b7 :=\nbegin\n  haveI : is_iso (h\u2081.iso\u2082.inv \u226b c.\u03b7) := by { rw \u2190 fac_iso\u2082, apply_instance, },\n  apply is_iso.of_is_iso_comp_left (h\u2081.iso\u2082.inv),\nend\n\n@[simp, reassoc]\nlemma coker_iso_iso\u2083_hom : c.coker_iso.hom \u226b h\u2082.iso\u2083.hom = h\u2081.iso\u2083.hom :=\nbegin\n  ext,\n  simp only [coker_iso_comm_assoc, cokernel_\u03c0_iso\u2083_hom, fac_iso\u2081_assoc],\nend\n\n@[simp, reassoc]\nlemma \u03b7_iso\u2082_hom_iso\u2083_hom : c.\u03b7 \u226b h\u2082.iso\u2082.hom \u226b h\u2082.iso\u2083.hom = h\u2081.iso\u2082.hom \u226b h\u2081.iso\u2083.hom :=\nby rw [\u2190 cancel_epi h\u2081.iso\u2082.inv, iso.inv_hom_id_assoc, \u2190 c.coker_iso_iso\u2083_hom,\n  \u2190 fac_iso\u2082_assoc, iso.inv_hom_id_assoc]\n\n@[simp, reassoc]\nlemma \u03b7_iso_hom : c.\u03b7 \u226b h\u2082.iso.hom = h\u2081.iso.hom :=\nbegin\n  dsimp only [iso],\n  simp only [iso.trans_hom, \u03b7_iso\u2082_hom_iso\u2083_hom_assoc],\nend\n\nlemma \u03b7_iso : as_iso c.\u03b7 \u226a\u226b h\u2082.iso = h\u2081.iso :=\nby { ext, simp only [iso.trans_hom, as_iso_hom, \u03b7_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{ \u03ba := \ud835\udfd9 _,\n  \u03b7 := (homology_iso_cokernel_lift f g w).hom,\n  fac\u2081' := category.comp_id _,\n  fac\u2082' := category.id_comp _,\n  fac\u2083' := begin\n    dsimp [homology.\u03c0', homology_iso_cokernel_lift, homology_iso_cokernel_image_to_kernel'],\n    simp only [cokernel_iso_of_eq_inv_comp_desc, cokernel.\u03c0_desc_assoc, category.assoc,\n      \u03c0_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 \u2190 (change.tautological f g w).\u03b7_iso_hom,\n  simp only [\u2190 (change.tautological f g w).\u03b7_iso_hom, change.tautological_\u03b7,\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 \u2964 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 \u22d9 F \u2245 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 \u22d9 F \u2245 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_\u03b9 :\n  (homology_iso_cokernel_lift f g w).inv \u226b homology.\u03b9 f g w =\n  cokernel.map _ _ (\ud835\udfd9 X) (kernel.\u03b9 g) (by simp only [kernel.lift_\u03b9, category.id_comp]) :=\nbegin\n  ext,\n  dsimp [homology_iso_cokernel_lift, homology.\u03b9,\n    homology_iso_cokernel_image_to_kernel', homology_iso_kernel_desc],\n  simp only [cokernel_iso_of_eq_inv_comp_desc, category.assoc, cokernel.\u03c0_desc_assoc, cokernel.\u03c0_desc,\n    cokernel_iso_of_eq_hom_comp_desc_assoc, kernel.lift_\u03b9, kernel_subobject_arrow_assoc,\n    kernel_subobject_arrow'_assoc],\nend\n\nlemma homology_\u03b9_eq :\n  homology.\u03b9 f g w = (homology_iso_cokernel_lift f g w).hom \u226b\n    cokernel.map _ _ (\ud835\udfd9 X) (kernel.\u03b9 g) (by simp only [kernel.lift_\u03b9, category.id_comp]) :=\nby simp only [\u2190 homology_iso_cokernel_lift_comp_\u03b9, iso.hom_inv_id_assoc]\n\nvariables {f g}\n\nlemma iso_hom_homology_\u03b9_eq_iso\u2082_hom_cokernel_map :\n  h.iso.hom \u226b homology.\u03b9 f g h.w = h.iso\u2082.hom \u226b cokernel.map h.f' f (\ud835\udfd9 X) h.\u03b9 (by simp) :=\nbegin\n  dsimp only [iso, iso\u2082, iso\u2083],\n  simp only [homology_\u03b9_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.\u03c0_desc_assoc, category.assoc, cokernel.\u03c0_desc, iso\u2081_hom_kernel_\u03b9_assoc],\nend\n\nlemma homology_\u03c0'_eq :\n  homology.\u03c0' f g h.w = h.iso\u2081.inv \u226b h.\u03c0 \u226b h.iso.hom :=\nbegin\n  rw \u2190 cancel_mono (homology.\u03b9 f g h.w),\n  dsimp only [iso],\n  simp only [homology.\u03c0'_\u03b9, category.assoc, iso.trans_hom, iso.symm_hom,\n    homology_iso_cokernel_lift_comp_\u03b9, \u2190 cokernel_\u03c0_iso\u2082_inv, iso.inv_hom_id_assoc,\n    cokernel_\u03c0_iso\u2083_hom_assoc, cokernel.\u03c0_desc],\nend\n\nlemma iso_inv : h.iso.inv = homology.desc' f g h.w (h.iso\u2081.inv \u226b h.\u03c0)\n  (by simp only [\u2190 h.f'_iso\u2081_hom, category.assoc, h.iso\u2081.hom_inv_id_assoc,\n    homology_iso_predatum.zero\u2082]) :=\nby rw [\u2190 cancel_epi (homology.\u03c0' f g h.w), homology.\u03c0'_desc', homology_\u03c0'_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\u2082.hom \u226b cokernel.map h.f' f (\ud835\udfd9 X) h.\u03b9 (by simp))\n  begin\n    rw \u2190 cancel_epi h.iso\u2082.inv,\n    ext,\n    simp only [category.assoc, iso.inv_hom_id_assoc, cokernel.\u03c0_desc_assoc,\n      cokernel.\u03c0_desc, homology_iso_predatum.zero\u2081, comp_zero],\n  end :=\nbegin\n  rw [\u2190 cancel_epi h.iso.inv, h.iso.inv_hom_id, h.iso_inv,\n    \u2190 cancel_mono (homology.\u03b9 f g h.w), \u2190 cancel_epi (homology.\u03c0' f g h.w),\n    \u2190 cancel_epi h.iso\u2081.hom],\n  simp only [category.assoc, category.id_comp, homology.\u03c0'_\u03b9, homology.lift_\u03b9,\n    homology.\u03c0'_desc'_assoc, h.iso\u2081.hom_inv_id_assoc, h.iso\u2081_hom_kernel_\u03b9_assoc,\n    \u2190 cokernel_\u03c0_iso\u2082_inv, h.iso\u2082.inv_hom_id_assoc, cokernel.\u03c0_desc],\nend\n\n@[simps]\ndef has_homology : has_homology f g H :=\n{ w := h.w,\n  \u03c0 := h.iso\u2081.inv \u226b h.\u03c0,\n  \u03b9 := h.iso\u2082.hom \u226b cokernel.map h.f' f (\ud835\udfd9 X) h.\u03b9 (by simp),\n  \u03c0_\u03b9 := by simp only [category.assoc, \u2190 cokernel_\u03c0_iso\u2082_inv_assoc, iso.inv_hom_id_assoc,\n      cokernel.\u03c0_desc, \u2190 h.iso\u2081_hom_kernel_\u03b9],\n  ex_\u03c0 := begin\n    refine preadditive.exact_of_iso_of_exact (kernel.lift g f h.w)\n      (cokernel.\u03c0 (kernel.lift g f h.w)) _ _ (iso.refl _) _ _ (abelian.exact_cokernel _),\n    { refine arrow.iso_mk (iso.refl _) (h.iso\u2083.symm \u226a\u226b h.iso\u2082.symm) _,\n      dsimp,\n      simp only [\u2190 cancel_mono h.iso\u2082.hom, \u2190 cancel_mono h.iso\u2083.hom,\n        category.id_comp, category.assoc, \u2190 cokernel_\u03c0_iso\u2082_inv,\n        iso.inv_hom_id_assoc, cokernel_\u03c0_iso\u2083_hom,\n        iso.inv_hom_id, category.comp_id], },\n    { refl, },\n  end,\n  \u03b9_ex := begin\n    refine preadditive.exact_of_iso_of_exact (homology.\u03b9 f g h.w) (cokernel.desc f g h.w)\n      _ _ _ (iso.refl _) _ (homology.has f g h.w).\u03b9_ex,\n    { refine arrow.iso_mk h.iso.symm (iso.refl _) _,\n      dsimp,\n      simp only [\u2190 h.iso_hom_homology_\u03b9_eq_iso\u2082_hom_cokernel_map,\n        iso.inv_hom_id_assoc, category.comp_id], },\n    { refl, },\n  end,\n  epi_\u03c0 := epi_comp _ _,\n  mono_\u03b9 := begin\n    rw \u2190 iso_hom_homology_\u03b9_eq_iso\u2082_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  \u03b9 := kernel.\u03b9 g,\n  f' := 0,\n  fac' := by rw [hf, zero_comp],\n  zero\u2081' := kernel.condition g,\n  \u03c0 := \ud835\udfd9 _,\n  zero\u2082' := by rw zero_comp,\n  fork_is_limit := kernel_is_kernel g,\n  cofork_is_colimit := is_colimit_aux _ (\u03bb s, s.\u03c0) (\u03bb s, by apply category.id_comp)\n    (\u03bb s m hm, begin rw [\u2190 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  \u03b9 := \ud835\udfd9 Y,\n  f' := f,\n  fac' := category.comp_id _,\n  zero\u2081' := by rw [hg, comp_zero],\n  \u03c0 := cokernel.\u03c0 f,\n  zero\u2082' := cokernel.condition f,\n  fork_is_limit := is_limit_aux _ (\u03bb s, s.\u03b9) (\u03bb s, by apply category.comp_id)\n    (\u03bb s m hm, begin rw [\u2190 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  \u03b9 := \ud835\udfd9 Y,\n  f' := 0,\n  fac' := by rw [hf, zero_comp] ,\n  zero\u2081' := by rw [hg, comp_zero],\n  \u03c0 := \ud835\udfd9 Y,\n  zero\u2082' := zero_comp,\n  fork_is_limit := is_limit_aux _ (\u03bb s, s.\u03b9) (\u03bb s, by apply category.comp_id)\n    (\u03bb s m hm, begin rw [\u2190 hm], symmetry, apply category.comp_id, end),\n  cofork_is_colimit := is_colimit_aux _ (\u03bb s, s.\u03c0) (\u03bb s, by apply category.id_comp)\n    (\u03bb s m hm, begin rw [\u2190 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 {\u03b1 : Sort*} : injective (eq : \u03b1 \u2192 \u03b1 \u2192 Prop) :=\n\u03bb _ _ h, h.symm \u25b8 rfl\n\nsection minimal_polynomial\n/- To be moved -/\nvariables {\u03b1 : Type u} {\u03b2 : Type v} [discrete_field \u03b1] [discrete_field \u03b2] [algebra \u03b1 \u03b2]\n\ndef minimal_polynomial {x : \u03b2} (hx : is_integral \u03b1 x) : polynomial \u03b1 := sorry\n\nlemma minimal_polynomial_irreducible {x : \u03b2} (hx : is_integral \u03b1 x) :\n  irreducible (minimal_polynomial hx) := sorry\n\nlemma minimal_polynomial_monic {x : \u03b2} (hx : is_integral \u03b1 x) : monic (minimal_polynomial hx) := sorry\n\n@[simp] lemma aeval_minimal_polynomial {x : \u03b2} (hx : is_integral \u03b1 x) :\n  aeval \u03b1 \u03b2 x (minimal_polynomial hx) = 0 := sorry\n\nlemma root_minimal_polynomial {x : \u03b2} (hx : is_integral \u03b1 x) {y : \u03b1}\n  (h : (minimal_polynomial hx).eval y = 0) : algebra_map \u03b2 y = x := sorry\n\nend minimal_polynomial\n\n@[instance] lemma equiv.is_ring_hom {\u03b1 \u03b2 : Type*} [ring \u03b2] (e : \u03b1 \u2243 \u03b2) :\n  @is_ring_hom \u03b2 \u03b1 _ (equiv.ring e) e.symm :=\nby split; simp [equiv.mul_def, equiv.add_def, equiv.one_def]\n\ninstance equiv.is_ring_hom.symm {\u03b1 \u03b2 : Type*} [ring \u03b2] (e : \u03b1 \u2243 \u03b2) :\n  @is_ring_hom \u03b1 \u03b2 (equiv.ring e) _ e :=\nby split; simp [equiv.mul_def, equiv.add_def, equiv.one_def]\n\ndef equiv.ring_equiv {\u03b1 \u03b2 : Type*} [ring \u03b2] (e : \u03b1 \u2243 \u03b2) :\n  @ring_equiv \u03b1 \u03b2 (equiv.ring e) _ :=\n{ hom := by apply_instance, ..e }\n\nlemma exists_root_of_equiv {\u03b1 \u03b2 : Type*} [comm_ring \u03b1] [comm_ring \u03b2] [decidable_eq \u03b1]\n  [decidable_eq \u03b2] (e : \u03b1 \u2243r \u03b2) {f : polynomial \u03b1} {x : \u03b2} (hx : f.eval\u2082 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 [\u2190 e.to_equiv.injective.eq_iff,\n    \u2190 eval\u2082_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 (\u03b1 \u03b2 \u03b3 : Type*) [comm_ring \u03b1] [ring \u03b2] [ring \u03b3]\n  [algebra \u03b1 \u03b2] [algebra \u03b1 \u03b3] extends alg_hom \u03b1 \u03b2 \u03b3, equiv \u03b2 \u03b3\n\nset_option old_structure_cmd false\n\ninfix ` \u2243\u2090 `:25 := alg_equiv _\nnotation A ` \u2243\u2090[`:25 R `] ` B := alg_equiv R A B\n\nnamespace alg_equiv\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} [comm_ring \u03b1] [ring \u03b2] [ring \u03b3]\n  [algebra \u03b1 \u03b2] [algebra \u03b1 \u03b3]\n\nprotected def symm (e : \u03b2 \u2243\u2090[\u03b1] \u03b3) : \u03b3 \u2243\u2090[\u03b1] \u03b2 := 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 \u21aa Y) (fxz : X \u21aa Z)\n  (hYZ : (Z \u21aa Y) \u2192 false) : \u21a5-range fxy.1 \u21aa \u21a5-range fxz.1 :=\nclassical.choice $ or.resolve_left embedding.total $\n  \u03bb \u27e8f\u27e9, hYZ $\n    calc Z \u21aa range fxz \u2295 \u21a5-range fxz :\n      (equiv.set.sum_compl _).symm.to_embedding\n    ... \u21aa range fxy \u2295 \u21a5-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    ... \u21aa Y : (equiv.set.sum_compl _).to_embedding\n\nprivate def thing {X : Type u} {Y : Type v} {Z : Type w} (fxy : X \u21aa Y) (fxz : X \u21aa Z)\n  (hYZ : (Z \u21aa Y) \u2192 false) : Y \u21aa Z :=\ncalc Y \u21aa range fxy \u2295 \u21a5-range fxy : (equiv.set.sum_compl _).symm.to_embedding\n... \u21aa range fxz \u2295 \u21a5-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... \u21aa Z : (equiv.set.sum_compl _).to_embedding\n\nprivate lemma thing_commutes {X : Type u} {Y : Type v} {Z : Type w}  (fxy : X \u21aa Y) (fxz : X \u21aa Z)\n  (hYZ : (Z \u21aa Y) \u2192 false) (x : X) : thing fxy fxz hYZ (fxy x) = fxz x :=\nhave (\u27e8fxy x, mem_range_self _\u27e9 : 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 : \u2200 f : polynomial K, 0 < degree f \u2192 \u2203 x, is_root f x)\n\nsection is_algebraically_closed\n\nlemma is_algebraically_closed_of_irreducible_has_root\n  (h : \u2200 f : polynomial K, irreducible f \u2192 \u2203 x, is_root f x) :\n  is_algebraically_closed K :=\n\u27e8\u03bb f hf0, let \u27e8g, hg\u27e9 := is_noetherian_ring.exists_irreducible_factor\n  (show \u00ac is_unit f, from \u03bb h, by rw [is_unit_iff_degree_eq_zero] at h;\n    rw h at hf0; exact lt_irrefl _ hf0)\n  (\u03bb h, by rw \u2190 degree_eq_bot at h;\n    rw h at hf0; exact absurd hf0 dec_trivial) in\n  let \u27e8x, hx\u27e9 := h g hg.1 in\n  let \u27e8i, hi\u27e9 := hg.2 in\n  \u27e8x, by rw [hi, is_root.def, eval_mul, show _ = _, from hx, zero_mul]\u27e9\u27e9\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 (\u2115 \u00d7 polynomial K)\n\nprivate def algebraic_embedding_aux {L : Type*} [discrete_field L] [algebra K L]\n  (h : \u2200 l : L, is_integral K l) (x : L) : \u2115 \u00d7 polynomial K :=\nlet f := classical.some (h x) in\n\u27e8list.index_of x (quotient.out ((f.map (algebra_map L)).roots.1)), f\u27e9\n\nprivate lemma algebraic_embedding_aux_injective\n  {L : Type*} [discrete_field L] [algebra K L]\n  (h : \u2200 l : L, is_integral K l) : injective (algebraic_embedding_aux h) :=\n\u03bb x y hxy,\nlet f := classical.some (h x) in\nlet g := classical.some (h y) in\nhave hf : monic f \u2227 aeval K L x f = 0, from classical.some_spec (h x),\nhave hg : monic g \u2227 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 \u25b8 rfl),\nhave hx : x \u2208 quotient.out ((f.map (algebra_map L)).roots.1),\n  from multiset.mem_coe.1 begin\n    show x \u2208 quotient.mk _,\n    rw [quotient.out_eq, \u2190 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, \u2190 aeval_def, hf.2],\n  end,\nhave hy : y \u2208 quotient.out ((g.map (algebra_map L)).roots.1),\n  from multiset.mem_coe.1 begin\n    show y \u2208 quotient.mk _,\n    rw [quotient.out_eq, \u2190 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, \u2190 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 : \u2200 l : L, is_integral K l) : L \u21aa big_type K :=\n\u27e8_, injective_comp injective_eq $ algebraic_embedding_aux_injective h\u27e9\n\nprivate def algebraic_embedding {L : Type*} [discrete_field L] [algebra K L]\n  (h : \u2200 l : L, is_integral K l) : L \u21aa \u2115 \u00d7 polynomial K :=\n\u27e8_, algebraic_embedding_aux_injective h\u27e9\n\nprivate def bembedding (K : Type u) [discrete_field K] : K \u21aa big_type K :=\n\u27e8\u03bb a, show set _, from {(0, X - C a)}, \u03bb a b, by simp [C_inj]\u27e9\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 \u21a5carrier]\n[algebra : algebra K \u21a5carrier]\n(algebraic : \u2200 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 : \u2200 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 := \u03bb L M, \u2203 hLM : L.carrier \u2286 M.carrier, is_ring_hom (inclusion hLM),\n  le_refl := \u03bb _, \u27e8set.subset.refl _, by convert is_ring_hom.id; ext; simp\u27e9,\n  le_trans := \u03bb L M N \u27e8hLM\u2081, hLM\u2082\u27e9 \u27e8hMN\u2081, hMN\u2082\u27e9, \u27e8set.subset.trans hLM\u2081 hMN\u2081,\n    by resetI; convert is_ring_hom.comp (inclusion hLM\u2081) (inclusion hMN\u2081)\u27e9 }\n\nprivate structure chain' (c : set (extension K)) : Prop :=\n(chain : chain (\u2264) c)\n\nlocal attribute [class] chain'\n\nprivate lemma is_chain (c : set (extension K)) [chain' c]: chain (\u2264) 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\u27e8\u03bb \u27e8i, hi\u27e9 \u27e8j, hj\u27e9, let \u27e8k, hkc, hk\u27e9 := chain.directed_on\n  (is_chain c) i hi j hj in \u27e8\u27e8k, hkc\u27e9, hk\u27e9\u27e9\n\nprivate def chain_map (i j : c) (hij : i \u2264 j) : i.1.carrier \u2192 j.1.carrier :=\ninclusion (exists.elim hij (\u03bb h _, h))\n\ninstance chain_field_hom (i j : c) (hij : i \u2264 j) : is_field_hom (chain_map c i j hij) :=\nexists.elim hij (\u03bb _, id)\n\ninstance chain_directed_system : directed_system (\u03bb i : c, i.1.carrier) (chain_map c) :=\nby split; intros; simp [chain_map]\n\nprivate def chain_limit : Type u := ring.direct_limit (\u03bb i : c, i.1.carrier) (chain_map c)\n\nprivate lemma of_eq_of (x : big_type K) (i j : c) (hi : x \u2208 i.1.carrier) (hj : x \u2208 j.1.carrier) :\n  ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map c) i \u27e8x, hi\u27e9 =\n  ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map c) j \u27e8x, hj\u27e9 :=\nhave hij : i \u2264 j \u2228 j \u2264 i,\n  from show i.1 \u2264 j.1 \u2228 j.1 \u2264 i.1, from chain.total (is_chain c) i.2 j.2,\nhij.elim\n  (\u03bb hij, begin\n    rw \u2190 @ring.direct_limit.of_f c _ _ _ (\u03bb i : c, i.1.carrier) _ _ (chain_map c) _\n      _ _ _ hij,\n    simp [chain_map, inclusion]\n  end)\n  (\u03bb hij, begin\n    rw \u2190 @ring.direct_limit.of_f c _ _ _ (\u03bb 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 : \u22c3 i : c, i.1.carrier) (hx : x.1 \u2208 i.1.carrier) (hy : y.1 \u2208 j.1.carrier) :\n  ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map c) i \u27e8x, hx\u27e9 =\n  ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map c) j \u27e8y, hy\u27e9 \u2192\n  x = y :=\nhave hij : i \u2264 j \u2228 j \u2264 i,\n  from show i.1 \u2264 j.1 \u2228 j.1 \u2264 i.1, from chain.total (is_chain c) i.2 j.2,\nhave hinj : \u2200 (i j : c) (hij : i \u2264 j), injective (chain_map c i j hij),\n  from \u03bb _ _ _, is_field_hom.injective _,\nhij.elim\n  (\u03bb hij h, begin\n    rw \u2190 @ring.direct_limit.of_f c _ _ _ (\u03bb 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  (\u03bb hji h, begin\n    rw \u2190 @ring.direct_limit.of_f c _ _ _ (\u03bb 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 : (\u22c3 (i : c), i.1.carrier) \u2243\n  ring.direct_limit (\u03bb i : c, i.1.carrier) (chain_map c) :=\n@equiv.of_bijective (\u22c3 i : c, i.1.carrier)\n  (ring.direct_limit (\u03bb i : c, i.1.carrier) (chain_map c))\n  (\u03bb x, ring.direct_limit.of _ _ (classical.some (set.mem_Union.1 x.2))\n    \u27e8_, classical.some_spec (set.mem_Union.1 x.2)\u27e9)\n  \u27e8\u03bb x y, injective_aux _ _ _ _ _ _ _,\n    \u03bb x, let \u27e8i, \u27e8y, hy\u27e9, hy'\u27e9 := ring.direct_limit.exists_of x in\n      \u27e8\u27e8y, _, \u27e8i, rfl\u27e9, hy\u27e9, begin\n        convert hy',\n        exact of_eq_of _ _ _ _ _ _\n      end\u27e9\u27e9\n\ninstance Union_field : discrete_field (\u22c3 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 (\u03bb i : c, i.1.carrier) i)) :=\nsuffices inclusion (set.subset_Union (\u03bb i : c, i.1.carrier) i) =\n    ((equiv_direct_limit c).symm \u2218\n    ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map c) i),\n  by rw this; exact is_ring_hom.comp _ _,\nfunext $ \u03bb \u27e8_, _\u27e9,\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 (\u2264) c) : extension K :=\n\nprivate def maximal_extension_chain (c : set (extension K)) (hc : chain (\u2264) c) :\n  { ub : extension K // \u2200 L, L \u2208 c \u2192 L \u2264 ub } :=\nif h : nonempty c\n  then by letI : chain' c := \u27e8hc\u27e9; exact\n    \u27e8{ carrier := \u22c3 (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    \u03bb e he, \u27e8by convert subset_Union _ (\u27e8e, he\u27e9 : c); refl,\n      algebraic_closure.is_field_hom_Union c \u27e8e, he\u27e9\u27e9\u27e9\n  else \u27e8base_extension K, \u03bb a ha, (h \u27e8\u27e8a, ha\u27e9\u27e9).elim\u27e9\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 \u21aa adjoin_root f :=\n\u27e8adjoin_root.of, @is_field_hom.injective _ _ _ _ _ $ by apply_instance\u27e9\n\n/- TODO: move -/\ninstance adjoin_root.algebra : algebra K (adjoin_root f) :=\nalgebra.of_ring_hom (adjoin_root.of \u2218 algebra_map _) (is_ring_hom.comp _ _)\n\nvariable (K)\n\nprivate def adjoin_root_extension_map : adjoin_root f \u21aa big_type K :=\nthing (adjoin_root.of_embedding f) \u27e8subtype.val, subtype.val_injective\u27e9\n  (\u03bb i, let e : big_type K \u21aa \u2115 \u00d7 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 \u2218\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 \u2286 (adjoin_root_extension K f).carrier :=\n\u03bb x h, \u27e8adjoin_root.of_embedding f \u27e8x, h\u27e9, thing_commutes _ _ _ _\u27e9\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 \u2218 adjoin_root.of_embedding f) :=\nfunext $ \u03bb \u27e8_, _\u27e9, subtype.eq $ eq.symm $ adjoin_root_extension_map_apply _ _ _\n\nprivate lemma le_adjoin_root_extension : L \u2264 adjoin_root_extension K f :=\n\u27e8subset_adjoin_root_extension K f,\n  by rw [adjoin_root_inclusion_eq]; dsimp [adjoin_root.of_embedding]; exact is_ring_hom.comp _ _\u27e9\n\nprivate def equiv_adjoin_root_of_le (h : adjoin_root_extension K f \u2264 L) :\n  L.carrier \u2243r adjoin_root f :=\nhave left_inv : left_inverse (inclusion h.fst \u2218 (equiv.set.range _\n    (adjoin_root_extension_map K f).2)) adjoin_root.of,\n  from \u03bb _, by simp [adjoin_root_extension_map_apply, inclusion],\n{ to_fun := coe,\n  inv_fun := inclusion h.fst \u2218 (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 \u2243r (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  \u2203 m : extension K, \u2200 a, m \u2264 a \u2192 a \u2264 m :=\nzorn (\u03bb c hc, (maximal_extension_chain c hc).exists_of_subtype) (\u03bb _ _ _, 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 \u2243r 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 {\u03b1 \u03b2 : Type*} [ring \u03b1] [ring \u03b2] (e : \u03b1 \u2243r \u03b2) :\n  is_semiring_hom (e.to_equiv : \u03b1 \u2192 \u03b2) :=\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\u03bb f hf, let e := by exactI algebraic_closure_equiv_adjoin_root K f in\n\u27e8_, exists_root_of_equiv e (adjoin_root.eval\u2082_root f)\u27e9\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 : \u2200 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 : \u2200 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 \u2192\u2090[K] M )\n( to_field : carrier \u2192\u2090[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 (\u2264) c) :\n  \u2203 ub : subfield_and_hom K L M hL, \u2200 N, N \u2208 c \u2192 N \u2264 ub :=\nlet ub := (maximal_extension_chain (subfield_and_hom.to_extension '' c) (chain.image (\u2264) _ _ (\u03bb _ _, id) hc)) in\n\u27e8{ 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   \u03bb n hN, ub.2 _ (mem_image_of_mem _ hN)\u27e9\n\nprivate lemma exists_maximal_subfield_and_hom : \u2203 N : subfield_and_hom K L M hL,\n  \u2200 O, N \u2264 O \u2192 O \u2264 N :=\nzorn (maximal_subfield_and_hom_chain _) (\u03bb _ _ _, 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\u2082 (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 \u2264\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\u03bb x, let hx := is_integral_over_maximal M hL x in\nby letI := minimal_polynomial_irreducible hx; exact\n\u27e8_, 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\u2082_root _))\u27e9\n\nprivate def equiv_maximal_subfield_and_hom :\n  (maximal_subfield_and_hom M hL).carrier \u2243\u2090[K] L :=\n{ ..(maximal_subfield_and_hom M hL).to_field,\n  ..equiv.of_bijective\n    \u27e8is_field_hom.injective _, surjective_maximal_subfield_and_hom_to_field _ _\u27e9 }\n\n/-- The hom from an algebraic extension of K into an algebraic closure -/\ndef lift : L \u2192\u2090[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 \"\u211d\" => Real\n@[instance] axiom Real.linearOrderedRing : LinearOrderedField \u211d\n\naxiom Complex : Type\nnotation \"\u2102\" => Complex\n@[instance] axiom Complex.field : Field \u2102\n@[instance] axiom Complex.charZero : CharZero \u2102\n\nexample : 43 \u2264 74 + (33 : \u2124) := by norm_num1\n-- example : 374 + (32 - (2 * 8123) : \u2124) - 61 * 50 = 86 + 32 * 32 - 4 * 5000\n--       \u2227 43 \u2264 74 + (33 : \u2124) := by norm_num1\n\nexample : \u00ac (7-2)/(2*3) \u2265 (1:\u211d) + 2/(3^2) := by norm_num1\nexample : (6:\u211d) + 9 = 15 := by norm_num1\nexample : (2:\u211d)/4 + 4 = 3*3/2 := by norm_num1\nexample : (((3:\u211d)/4)-12)<6 := by norm_num1\nexample : (5:\u211d) \u2260 8 := by norm_num1\nexample : (10:\u211d) > 7 := by norm_num1\nexample : (2:\u211d) * 2 + 3 = 7 := by norm_num1\nexample : (6:\u211d) < 10 := by norm_num1\nexample : (7:\u211d)/2 > 3 := by norm_num1\nexample : (4:\u211d)\u207b\u00b9 < 1 := by norm_num1\nexample : ((1:\u211d) / 2)\u207b\u00b9 = 2 := by norm_num1\n-- example : 2 ^ 17 - 1 = 131071 := by norm_num1\n-- example : (3 : \u211d) ^ (-2 : \u2124) = 1/9 := by norm_num1\n-- example : (3 : \u211d) ^ (-2 : \u2124) = 1/9 := by norm_num1\n-- example : (-3 : \u211d) ^ (0 : \u2124) = 1 := by norm_num1\n-- example : (-3 : \u211d) ^ (-1 : \u2124) = -1/3 := by norm_num1\n-- example : (-3 : \u211d) ^ (2 : \u2124) = 9 := by norm_num1\n\nsection InvLit\n\nvariable [DivisionRing \u03b1]\n\nexample : (0 : \u03b1)\u207b\u00b9 = 0 := by norm_num1\nexample : (1 : \u03b1)\u207b\u00b9 = 1 := by norm_num1\nexample : (-1 : \u03b1)\u207b\u00b9 = -1 := by norm_num1\n\nend InvLit\n\nexample (h : x = 1) : x = (1/5 + 4/5 : \u211a) := by norm_num1; exact h\nexample (h : x = 1) : x = (5 * 5\u207b\u00b9 : \u211a) := by norm_num1; exact h\nexample (h : x = 1) : x = (6/5 - 1/5 : \u211a) := by norm_num1; exact h\nexample (h : x = 1) : x = ((6/5) ^ 0 : \u211a) := by norm_num1; exact h\n\n/-\n# `=` and `\u2260`\n-/\n\nsection Equality\n\nsection Bool\n\nexample : True := by norm_num1\nexample (h : False) : \u00acTrue := by norm_num1; guard_target =\u209b False; exact h\nexample : \u00ac\u00ac\u00ac\u00acTrue := by norm_num1\nexample : \u00acFalse := by norm_num1\n\nend Bool\n\nsection Nat\n\nvariable [AddMonoidWithOne \u03b1] [CharZero \u03b1]\n\n-- Normalize to True\nexample : 1 = 1 := by norm_num1\nexample : 1 \u2260 2 := by norm_num1\n\nexample : (1 : \u03b1) \u2260 2 := by norm_num1\n\n-- Normalize to False\nexample : \u00ac(1 = 2) := by norm_num1\nexample : \u00ac((1 : \u03b1) = 2) := by norm_num1\n\nexample : \u00ac((1 : \u03b1) \u2260 1) := by norm_num1\n\nend Nat\n\nsection Semiring\n\nvariable [Semiring \u03b1] [CharZero \u03b1]\n\nexample : (1 : \u03b1) \u2260 2 := by norm_num1\n\nend Semiring\n\nsection Int\n\nvariable [Ring \u03b1] [CharZero \u03b1]\n\n-- Normalize to True\nexample : (1 : \u2124) = 1 := by norm_num1\nexample : (-1 : \u2124) = -1 := by norm_num1\nexample : (1 : \u03b1) = 1 := by norm_num1\nexample : (-1 : \u03b1) = -1 := by norm_num1\n\nexample : (1 : \u2124) \u2260 2 := by norm_num1\nexample : (1 : \u2124) \u2260 -2 := by norm_num1\nexample : (-1 : \u2124) \u2260 -2 := by norm_num1\nexample : (1 : \u03b1) \u2260 2 := by norm_num1\nexample : (-1 : \u03b1) \u2260 2 := by norm_num1\nexample : (-1 : \u03b1) \u2260 -2 := by norm_num1\n\n-- Normalize to False\nexample : ((1 : \u2124) = 2) = False := by norm_num1\nexample : ((-1 : \u2124) = 2) = False := by norm_num1\nexample : ((1 : \u03b1) = 2) = False := by norm_num1\nexample : ((-1 : \u03b1) = 2) = False := by norm_num1\n\nexample : ((1 : \u2124) \u2260 1) = False := by norm_num1\nexample : ((-1 : \u2124) \u2260 -1) = False := by norm_num1\nexample : ((1 : \u03b1) \u2260 1) = False := by norm_num1\nexample : ((-1 : \u03b1) = 2) = False := by norm_num1\n\nend Int\n\nsection Rat\n\nvariable [DivisionRing \u03b1] [CharZero \u03b1]\n\n-- Normalize to True\nexample : (1 : \u211a) = 1 := by norm_num1\nexample : (-1 : \u211a) = -1 := by norm_num1\nexample : (1/2 : \u211a) = 1/2 := by norm_num1\nexample : (-1/2 : \u211a) = -1/2 := by norm_num1\nexample : (-1/(-2) : \u211a) = -1/(-2) := by norm_num1\nexample : (1 : \u03b1) = 1 := by norm_num1\nexample : (-1 : \u03b1) = -1 := by norm_num1\nexample : (1/2 : \u03b1) = 1/2 := by norm_num1\nexample : (-1/2 : \u03b1) = -1/2 := by norm_num1\nexample : (-1/(-2) : \u03b1) = -1/(-2) := by norm_num1\n\nexample : (1 : \u211a) \u2260 2 := by norm_num1\nexample : (1 : \u211a) \u2260 -2 := by norm_num1\nexample : (-1 : \u211a) \u2260 -2 := by norm_num1\nexample : (1/2 : \u211a) \u2260 1 := by norm_num1\nexample : (1/2 : \u211a) \u2260 -1 := by norm_num1\nexample : (1/2 : \u211a) \u2260 1/3 := by norm_num1\nexample : (1/2 : \u211a) \u2260 5/2 := by norm_num1\nexample : (1/2 : \u03b1) \u2260 1/3 := by norm_num1\nexample : (1/2 : \u03b1) \u2260 5/2 := by norm_num1\nexample : (1/2 : \u03b1) \u2260 -2 := by norm_num1\nexample : (-1 : \u03b1) \u2260 2 := by norm_num1\nexample : (1 : \u03b1) / 3 \u2260 0 := by norm_num1\nexample : (1 : \u03b1) / 3 \u2260 2 / 7 := by norm_num1\n\n-- Normalize to False\nexample : ((1 : \u211a) = 2) = False := by norm_num1\nexample : ((-1 : \u211a) = 2) = False := by norm_num1\nexample : ((1/2 : \u211a) = 2) = False := by norm_num1\nexample : ((1 : \u03b1) = 2) = False := by norm_num1\nexample : ((-1 : \u03b1) = 2) = False := by norm_num1\nexample : ((1/2 : \u03b1) = 2) = False := by norm_num1\n\nexample : ((1 : \u211a) \u2260 1) = False := by norm_num1\nexample : ((-1 : \u211a) \u2260 -1) = False := by norm_num1\nexample : ((1/2 : \u211a) \u2260 1/2) = False := by norm_num1\nexample : ((1/2 : \u03b1) \u2260 1/2) = False := by norm_num1\n\nend Rat\n\nend Equality\n\n/-\n# `<` and `\u2264`\n-/\n\nsection Order\n\nsection Nat\n\nvariable [OrderedSemiring \u03b1] [CharZero \u03b1]\n\n-- Normalize to True\nexample : 1 \u2264 1 := by norm_num1\nexample : (1 : \u03b1) \u2264 2 := by norm_num1\n\nexample : 1 < 2 := by norm_num1\nexample : (1 : \u03b1) < 2 := by norm_num1\n\n-- Normalize to False\nexample : \u00ac(2 \u2264 1) := by norm_num1\nexample : \u00ac((2 : \u03b1) \u2264 1) := by norm_num1\n\nexample : \u00ac(1 < 1) := by norm_num1\nexample : \u00ac((2 : \u03b1) < 2) := by norm_num1\n\nend Nat\n\nsection Int\n\nvariable [OrderedRing \u03b1] [Nontrivial \u03b1]\n\n-- Normalize to True\nexample : (1 : \u2124) \u2264 1 := by norm_num1\nexample : (-1 : \u2124) \u2264 -1 := by norm_num1\nexample : (-1 : \u2124) \u2264 1 := by norm_num1\nexample : (1 : \u03b1) \u2264 1 := by norm_num1\nexample : (-1 : \u03b1) \u2264 -1 := by norm_num1\nexample : (-1 : \u03b1) \u2264 1 := by norm_num1\n\nexample : (1 : \u2124) < 2 := by norm_num1\nexample : (-2 : \u2124) < 1 := by norm_num1\nexample : (-1 : \u2124) < 1 := by norm_num1\nexample : (1 : \u03b1) < 2 := by norm_num1\nexample : (-1 : \u03b1) < 2 := by norm_num1\nexample : (-1 : \u03b1) < 1 := by norm_num1\n\n-- Normalize to False\nexample : \u00ac((2 : \u2124) \u2264 1) := by norm_num1\nexample : \u00ac((2 : \u2124) \u2264 -1) := by norm_num1\nexample : \u00ac((2 : \u03b1) \u2264 1) := by norm_num1\nexample : \u00ac((2 : \u03b1) \u2264 -1) := by norm_num1\n\nexample : \u00ac((2 : \u2124) < 1) := by norm_num1\nexample : \u00ac((2 : \u2124) < -1) := by norm_num1\nexample : \u00ac((2 : \u03b1) < 1) := by norm_num1\nexample : \u00ac((2 : \u03b1) < -1) := by norm_num1\n\nend Int\n\nsection OrderedCharZeroRing\n\nvariable [OrderedRing \u03b1] [CharZero \u03b1]\n\nexample : (-1 : \u03b1) < 2 := by norm_num1\n\nend OrderedCharZeroRing\n\nsection LinearOrderedRing\n\nvariable [LinearOrderedRing \u03b1]\n\nexample : (1 : \u03b1) \u2264 1 := by norm_num1\nexample : (-1 : \u03b1) \u2264 -1 := by norm_num1\nexample : (-1 : \u03b1) \u2264 1 := by norm_num1\n\nexample : (1 : \u03b1) < 2 := by norm_num1\nexample : (-1 : \u03b1) < 2 := by norm_num1\nexample : (-1 : \u03b1) < 1 := by norm_num1\n\nend LinearOrderedRing\n\nsection Rat\n\nvariable [LinearOrderedField \u03b1] [Nontrivial \u03b1]\n\n-- Normalize to True\nexample : (1 : \u211a) \u2264 1 := by norm_num1\nexample : (-1 : \u211a) \u2264 -1 := by norm_num1\nexample : (-1 : \u211a) \u2264 1 := by norm_num1\nexample : (-1/2 : \u211a) \u2264 1 := by norm_num1\nexample : (1/2 : \u211a) \u2264 5/4 := by norm_num1\nexample : (1 : \u03b1) \u2264 1 := by norm_num1\nexample : (-1 : \u03b1) \u2264 -1 := by norm_num1\nexample : (-1 : \u03b1) \u2264 1 := by norm_num1\nexample : (-1/2 : \u03b1) \u2264 1 := by norm_num1\nexample : (1/2 : \u03b1) \u2264 5/4 := by norm_num1\n\nexample : (1 : \u2124) < 2 := by norm_num1\nexample : (-2 : \u2124) < 1 := by norm_num1\nexample : (-1 : \u2124) < 1 := by norm_num1\nexample : (-1/2 : \u211a) < 1 := by norm_num1\nexample : (1/2 : \u211a) < 5/4 := by norm_num1\nexample : (1 : \u03b1) < 2 := by norm_num1\nexample : (-1 : \u03b1) < 2 := by norm_num1\nexample : (-1 : \u03b1) < 1 := by norm_num1\nexample : (-1/2 : \u03b1) < 1 := by norm_num1\nexample : (1/2 : \u03b1) < 5/4 := by norm_num1\n\n-- Normalize to False\nexample : \u00ac((2 : \u211a) \u2264 1) := by norm_num1\nexample : \u00ac((2 : \u211a) \u2264 -1) := by norm_num1\nexample : \u00ac((1/2 : \u211a) \u2264 -1) := by norm_num1\nexample : \u00ac((2 : \u03b1) \u2264 1) := by norm_num1\nexample : \u00ac((2 : \u03b1) \u2264 -1) := by norm_num1\nexample : \u00ac((1/2 : \u03b1) \u2264 -1) := by norm_num1\n\nexample : \u00ac((2 : \u211a) < 1) := by norm_num1\nexample : \u00ac((2 : \u211a) < -1) := by norm_num1\nexample : \u00ac((1/2 : \u211a) < -1) := by norm_num1\nexample : \u00ac((2 : \u03b1) < 1) := by norm_num1\nexample : \u00ac((2 : \u03b1) < -1) := by norm_num1\nexample : \u00ac((1/2 : \u03b1) < -1) := by norm_num1\n\nend Rat\n\nend Order\n\nexample : (1:\u2102) \u2260 2 := by norm_num1\nexample : (1:\u2102) / 3 \u2260 2 / 7 := by norm_num1\n\nexample : (1:\u211d) \u2260 2 := by norm_num1\n\n-- example : (5 / 2:\u2115) = 2 := by norm_num1\n-- example : (5 / -2:\u2124) < -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 : \u2124) % 11 := by norm_num1 -- [fixme] \u22a2 False ???\nexample : (12321 - 2 : \u2124) = 12319 := by norm_num1\nexample : (63:\u211a) \u2265 5 := by norm_num1\n\nexample (x : \u2124) (h : 1000 + 2000 < x) : 100 * 30 < x :=\nby norm_num at *; exact h\n\nexample : (1103 : \u2124) \u2264 (2102 : \u2124) := by norm_num1\nexample : (110474 : \u2124) \u2264 (210485 : \u2124) := by norm_num1\nexample : (11047462383473829263 : \u2124) \u2264 (21048574677772382462 : \u2124) := by norm_num1\nexample : (210485742382937847263 : \u2124) \u2264 (1104857462382937847262 : \u2124) := by norm_num1\nexample : (210485987642382937847263 : \u2115) \u2264 (11048512347462382937847262 : \u2115) := by norm_num1\nexample : (210485987642382937847263 : \u211a) \u2264 (11048512347462382937847262 : \u211a) := by norm_num1\nexample : (2 * 12868 + 25705) * 11621 ^ 2 \u2264 23235 ^ 2 * 12868 := by norm_num1\n\n-- example (x : \u2115) : \u2115 := by\n--   let n : \u2115 := by apply_normed (2^32 - 71)\n--   exact n\n\nexample (a : \u211a) (h : 3\u207b\u00b9 * a = a) : True := by\n  norm_num1 at h\n  guard_hyp h : 1 / 3 * a = a\n  trivial\n\n-- example (h : (5 : \u2124) \u2223 2) : False := by norm_num1 at h\nexample (h : False) : False := by norm_num1 at h\nexample : True := by norm_num1\n-- example : True \u2227 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 : \u211d := 1\n\n-- example : foo = 1 := by norm_num [foo]\n\nsection\n  variable [AddMonoidWithOne \u03b1]\n  example : (1 + 0 : \u03b1) = (0 + 1 : \u03b1) := by norm_num1\n  example : (0 + (2 + 3) + 1 : \u03b1) = 6 := by norm_num1\nend\n\nsection\n  variable [Semiring \u03b1]\n  example : (70 * (33 + 2) : \u03b1) = 2450 := by norm_num1\n  example : (8 + 2 ^ 2 * 3 : \u03b1) = 20 := by norm_num1\n  example : ((2 * 1 + 1) ^ 2 : \u03b1) = (3 * 3 : \u03b1) := by norm_num1\nend\nsection\n  variable [Ring \u03b1]\n\n  example : (-1 : \u03b1) * 1 = -1 := by norm_num1\n  example : (-2 : \u03b1) * 1 = -2 := by norm_num1\n  example : (-2 : \u03b1) * -1 = 2 := by norm_num1\n  example : (-2 : \u03b1) * -2 = 4 := by norm_num1\n  example : (1 : \u03b1) * 0 = 0 := by norm_num1\n\n  example : ((1 : \u03b1) + 1) * 5 = 6 + 4 := by norm_num1\n\n  example : (1 : \u03b1) = 0 + 1 := by norm_num1\n  example : (1 : \u03b1) = 1 + 0 := by norm_num1\n  example : (2 : \u03b1) = 1 + 1 := by norm_num1\n  example : (2 : \u03b1) = 0 + 2 := by norm_num1\n  example : (3 : \u03b1) = 1 + 2 := by norm_num1\n  example : (3 : \u03b1) = 2 + 1 := by norm_num1\n  example : (4 : \u03b1) = 3 + 1 := by norm_num1\n  example : (4 : \u03b1) = 2 + 2 := by norm_num1\n  example : (5 : \u03b1) = 4 + 1 := by norm_num1\n  example : (5 : \u03b1) = 3 + 2 := by norm_num1\n  example : (5 : \u03b1) = 2 + 3 := by norm_num1\n  example : (6 : \u03b1) = 0 + 6 := by norm_num1\n  example : (6 : \u03b1) = 3 + 3 := by norm_num1\n  example : (6 : \u03b1) = 4 + 2 := by norm_num1\n  example : (6 : \u03b1) = 5 + 1 := by norm_num1\n  example : (7 : \u03b1) = 4 + 3 := by norm_num1\n  example : (7 : \u03b1) = 1 + 6 := by norm_num1\n  example : (7 : \u03b1) = 6 + 1 := by norm_num1\n  example : 33 = 5 + (28 : \u03b1) := by norm_num1\n\n  example : (12 : \u03b1) = 0 + (2 + 3) + 7 := by norm_num1\n  example : (105 : \u03b1) = 70 + (33 + 2) := by norm_num1\n\n  example : (45000000000 : \u03b1) = 23000000000 + 22000000000 := by norm_num1\n\n  example : (0 : \u03b1) - 3 = -3 := by norm_num1\n  example : (0 : \u03b1) - 2 = -2 := by norm_num1\n  example : (1 : \u03b1) - 3 = -2 := by norm_num1\n  example : (1 : \u03b1) - 1 = 0 := by norm_num1\n  example : (0 : \u03b1) - 3 = -3 := by norm_num1\n  example : (0 : \u03b1) - 3 = -3 := by norm_num1\n  example : (12 : \u03b1) - 4 - (5 + -2) = 5 := by norm_num1\n  example : (12 : \u03b1) - 4 - (5 + -2) - 20 = -15 := by norm_num1\n\n  example : (0 : \u03b1) * 0 = 0 := by norm_num1\n  example : (0 : \u03b1) * 1 = 0 := by norm_num1\n  example : (0 : \u03b1) * 2 = 0 := by norm_num1\n  example : (2 : \u03b1) * 0 = 0 := by norm_num1\n  example : (1 : \u03b1) * 0 = 0 := by norm_num1\n  example : (1 : \u03b1) * 1 = 1 := by norm_num1\n  example : (2 : \u03b1) * 1 = 2 := by norm_num1\n  example : (1 : \u03b1) * 2 = 2 := by norm_num1\n  example : (2 : \u03b1) * 2 = 4 := by norm_num1\n  example : (3 : \u03b1) * 2 = 6 := by norm_num1\n  example : (2 : \u03b1) * 3 = 6 := by norm_num1\n  example : (4 : \u03b1) * 1 = 4 := by norm_num1\n  example : (1 : \u03b1) * 4 = 4 := by norm_num1\n  example : (3 : \u03b1) * 3 = 9 := by norm_num1\n  example : (3 : \u03b1) * 4 = 12 := by norm_num1\n  example : (4 : \u03b1) * 4 = 16 := by norm_num1\n  example : (11 : \u03b1) * 2 = 22 := by norm_num1\n  example : (15 : \u03b1) * 6 = 90 := by norm_num1\n  example : (123456 : \u03b1) * 123456 = 15241383936 := by norm_num1\nend\n\nsection\n  variable [LinearOrderedField \u03b1]\n  example : (4 : \u03b1) / 2 = 2 := by norm_num1\n  example : (4 : \u03b1) / 1 = 4 := by norm_num1\n  example : (4 : \u03b1) / 3 = 4 / 3 := by norm_num1\n  example : (50 : \u03b1) / 5 = 10 := by norm_num1\n  example : (1056 : \u03b1) / 1 = 1056 := by norm_num1\n  example : (6 : \u03b1) / 4 = 3/2 := by norm_num1\n  example : (0 : \u03b1) / 3 = 0 := by norm_num1\n  example : (3 : \u03b1) / 0 = 0 := by norm_num1\n  example : (9 * 9 * 9) * (12 : \u03b1) / 27 = 81 * (2 + 2) := by norm_num1\n  example : (-2 : \u03b1) * 4 / 3 = -8 / 3 := by norm_num1\n  example : - (-4 / 3) = 1 / (3 / (4 : \u03b1)) := 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 : \u211a) = 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 \u2223 2^16-1\n-- example : 2^4-1 \u2223 2^16-1 := by norm_num1\n-- #norm_num (3 : Real) ^ (-2 : \u2124) = 1/9\n-- example : (3 : Real) ^ (-2 : \u2124) = 1/9 := by norm_num1\n\nsection norm_num_cmd_variable\n\n-- [fixme] obsolete?\n-- variables (x y : \u2115)\n-- #norm_num bit0 x < bit0 (y + x) \u2194 0 < y\n-- example : bit0 x < bit0 (y + x) \u2194 0 < y := by norm_num1\n-- #norm_num bit0 x < bit0 (y + (2^10%11 - 1) + x) \u2194 0 < y\n-- example : bit0 x < bit0 (y + (2^10%11 - 1) + x) \u2194 0 < y := by norm_num1\n-- #norm_num bit0 x < bit0 (y + (2^10%11 - 1) + x) + 3*2-6 \u2194 0 < y\n-- example : bit0 x < bit0 (y + (2^10%11 - 1) + x) + 3*2-6 \u2194 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 =\u209b 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 \u03b1]\nexample : ((25 * (1 / 1)) + (30 - 16)) = (39 : \u03b1) := by norm_num1\nexample : ((19 * (- 2 - 3)) / 6) = (-95/6 : \u03b1) := by norm_num1\nexample : - (3 * 28) = (-84 : \u03b1) := by norm_num1\nexample : - - (16 / ((11 / (- - (6 * 19) + 12)) * 21)) = (96/11 : \u03b1) := by norm_num1\nexample : (- (- 21 + 24) - - (- - (28 + (- 21 / - (16 / ((1 * 26) * ((0 * - 11) + 13))))) * 21)) =\n  (79209/8 : \u03b1) := by norm_num1\nexample : (27 * (((16 + - (12 + 4)) + (22 - - 19)) - 23)) = (486 : \u03b1) := by norm_num1\nexample : - (13 * (- 30 / ((7 / 24) + - 7))) = (-9360/161 : \u03b1) := by norm_num1\nexample : - (0 + 20) = (-20 : \u03b1) := by norm_num1\nexample : (- 2 - (27 + (((2 / 14) - (7 + 21)) + (16 - - - 14)))) = (-22/7 : \u03b1) := by norm_num1\nexample : (25 + ((8 - 2) + 16)) = (47 : \u03b1) := by norm_num1\nexample : (- - 26 / 27) = (26/27 : \u03b1) := by norm_num1\nexample : ((((16 * (22 / 14)) - 18) / 11) + 30) = (2360/77 : \u03b1) := by norm_num1\nexample : (((- 28 * 28) / (29 - 24)) * 24) = (-18816/5 : \u03b1) := by norm_num1\nexample : ((- (18 - ((- - (10 + - 2) - - (23 / 5)) / 5)) - (21 * 22)) -\n  (((20 / - ((((19 + 18) + 15) + 3) + - 22)) + 14) / 17)) = (-394571/825 : \u03b1) := by norm_num1\nexample : ((3 + 25) - - 4) = (32 : \u03b1) := by norm_num1\nexample : ((1 - 0) - 22) = (-21 : \u03b1) := by norm_num1\nexample : (((- (8 / 7) / 14) + 20) + 22) = (2054/49 : \u03b1) := by norm_num1\nexample : ((21 / 20) - 29) = (-559/20 : \u03b1) := by norm_num1\nexample : - - 20 = (20 : \u03b1) := by norm_num1\nexample : (24 - (- 9 / 4)) = (105/4 : \u03b1) := by norm_num1\nexample : (((7 / ((23 * 19) + (27 * 10))) - ((28 - - 15) * 24)) + (9 / - (10 * - 3))) =\n  (-1042007/1010 : \u03b1) := by norm_num1\nexample : (26 - (- 29 + (12 / 25))) = (1363/25 : \u03b1) := by norm_num1\nexample : ((11 * 27) / (4 - 5)) = (-297 : \u03b1) := by norm_num1\nexample : (24 - (9 + 15)) = (0 : \u03b1) := by norm_num1\nexample : (- 9 - - 0) = (-9 : \u03b1) := by norm_num1\nexample : (- 10 / (30 + 10)) = (-1/4 : \u03b1) := by norm_num1\nexample : (22 - (6 * (28 * - 8))) = (1366 : \u03b1) := by norm_num1\nexample : ((- - 2 * (9 * - 3)) + (22 / 30)) = (-799/15 : \u03b1) := by norm_num1\nexample : - (26 / ((3 + 7) / - (27 * (12 / - 16)))) = (-1053/20 : \u03b1) := by norm_num1\nexample : ((- 29 / 1) + 28) = (-1 : \u03b1) := by norm_num1\nexample : ((21 * ((10 - (((17 + 28) - - 0) + 20)) + 26)) + ((17 + - 16) * 7)) = (-602 : \u03b1) :=\nby norm_num1\nexample : (((- 5 - ((24 + - - 8) + 3)) + 20) + - 23) = (-43 : \u03b1) := by norm_num1\nexample : ((- ((14 - 15) * (14 + 8)) + ((- (18 - 27) - 0) + 12)) - 11) = (32 : \u03b1) := by norm_num1\nexample : (((15 / 17) * (26 / 27)) + 28) = (4414/153 : \u03b1) := by norm_num1\nexample : (14 - ((- 16 - 3) * - (20 * 19))) = (-7206 : \u03b1) := by norm_num1\nexample : (21 - - - (28 - (12 * 11))) = (125 : \u03b1) := by norm_num1\nexample : ((0 + (7 + (25 + 8))) * - (11 * 27)) = (-11880 : \u03b1) := by norm_num1\nexample : (19 * - 5) = (-95 : \u03b1) := by norm_num1\nexample : (29 * - 8) = (-232 : \u03b1) := by norm_num1\nexample : ((22 / 9) - 29) = (-239/9 : \u03b1) := by norm_num1\nexample : (3 + (19 / 12)) = (55/12 : \u03b1) := by norm_num1\nexample : - (13 + 30) = (-43 : \u03b1) := by norm_num1\nexample : - - - (((21 * - - ((- 25 - (- (30 - 5) / (- 5 - 5))) /\n  (((6 + ((25 * - 13) + 22)) - 3) / 2))) / (- 3 / 10)) * (- 8 - 0)) = (-308/3 : \u03b1) := by norm_num1\nexample : - (2 * - (- 24 * 22)) = (-1056 : \u03b1) := by norm_num1\nexample : - - (((28 / - ((- 13 * - 5) / - (((7 - 30) / 16) + 6))) * 0) - 24) = (-24 : \u03b1) :=\nby norm_num1\nexample : ((13 + 24) - (27 / (21 * 13))) = (3358/91 : \u03b1) := by norm_num1\nexample : ((3 / - 21) * 25) = (-25/7 : \u03b1) := by norm_num1\nexample : (17 - (29 - 18)) = (6 : \u03b1) := by norm_num1\nexample : ((28 / 20) * 15) = (21 : \u03b1) := by norm_num1\nexample : ((((26 * (- (23 - 13) - 3)) / 20) / (14 - (10 + 20))) / ((16 / 6) / (16 * - (3 / 28)))) =\n(-1521/2240 : \u03b1) := by norm_num1\n\nexample : (46 / (- ((- 17 * 28) - 77) + 87)) = (23/320 : \u03b1) := by norm_num1\nexample : (73 * - (67 - (74 * - - 11))) = (54531 : \u03b1) := by norm_num1\nexample : ((8 * (25 / 9)) + 59) = (731/9 : \u03b1) := by norm_num1\nexample : - ((59 + 85) * - 70) = (10080 : \u03b1) := by norm_num1\nexample : (66 + (70 * 58)) = (4126 : \u03b1) := by norm_num1\nexample : (- - 49 * 0) = (0 : \u03b1) := by norm_num1\nexample : ((- 78 - 69) * 9) = (-1323 : \u03b1) := by norm_num1\nexample : - - (7 - - (50 * 79)) = (3957 : \u03b1) := by norm_num1\nexample : - (85 * (((4 * 93) * 19) * - 31)) = (18624180 : \u03b1) := by norm_num1\nexample : (21 + (- 5 / ((74 * 85) / 45))) = (26373/1258 : \u03b1) := by norm_num1\nexample : (42 - ((27 + 64) + 26)) = (-75 : \u03b1) := by norm_num1\nexample : (- ((38 - - 17) + 86) - (74 + 58)) = (-273 : \u03b1) := by norm_num1\nexample : ((29 * - (75 + - 68)) + (- 41 / 28)) = (-5725/28 : \u03b1) := by norm_num1\nexample : (- - (40 - 11) - (68 * 86)) = (-5819 : \u03b1) := by norm_num1\nexample : (6 + ((65 - 14) + - 89)) = (-32 : \u03b1) := by norm_num1\nexample : (97 * - (29 * 35)) = (-98455 : \u03b1) := by norm_num1\nexample : - (66 / 33) = (-2 : \u03b1) := by norm_num1\nexample : - ((94 * 89) + (79 - (23 - (((- 1 / 55) + 95) * (28 - (54 / - - - 22)))))) =\n(-1369070/121 : \u03b1) := by norm_num1\nexample : (- 23 + 61) = (38 : \u03b1) := by norm_num1\nexample : - (93 / 69) = (-31/23 : \u03b1) := by norm_num1\nexample : (- - ((68 / (39 + (((45 * - (59 - (37 + 35))) / (53 - 75)) -\n - (100 + - (50 / (- 30 - 59)))))) - (69 - (23 * 30))) / (57 + 17)) = (137496481/16368578 : \u03b1) :=\nby norm_num1\nexample : (- 19 * - - (75 * - - 41)) = (-58425 : \u03b1) := by norm_num1\nexample : ((3 / ((- 28 * 45) * (19 + ((- (- 88 - (- (- 1 + 90) + 8)) + 87) * 48)))) + 1) =\n  (1903019/1903020 : \u03b1) := by norm_num1\nexample : ((- - (28 + 48) / 75) + ((- 59 - 14) - 0)) = (-5399/75 : \u03b1) := by norm_num1\nexample : (- ((- (((66 - 86) - 36) / 94) - 3) / - - (77 / (56 - - - 79))) + 87) =\n  (312254/3619 : \u03b1) := 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 `\u03bb x, x\u207b\u00b9` is integrable on `a..b` if and only if `a = b` or\n`0 \u2209 [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 `\ud835\udcdd[\u2260] c` and `f' = O(g)` along the same filter, then `g` is not interval integrable on any\n  nontrivial integral `a..b`, `c \u2208 [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 \u2192 c`, `x \u2260 c`,\n  then `f` is not interval integrable on any nontrivial interval `a..b`, `c \u2208 [a, b]`;\n\n* `interval_integrable_sub_inv_iff`, `interval_integrable_inv_iff`: integrability conditions for\n  `(x - c)\u207b\u00b9` and `x\u207b\u00b9`.\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 \u211d E] [SecondCountableTopology E]\n  [CompleteSpace E] [NormedAddCommGroup F]\n\n/-- If `f` is eventually differentiable along a nontrivial filter `l : filter \u211d` 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] \u2208 l`. -/\ntheorem not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_filter {f : \u211d \u2192 E} {g : \u211d \u2192 F}\n    {a b : \u211d} (l : Filter \u211d) [NeBot l] [TendstoIxxClass Icc l l] (hl : [a, b] \u2208 l)\n    (hd : \u2200\u1da0 x in l, DifferentiableAt \u211d f x) (hf : Tendsto (fun x => \u2016f x\u2016) l atTop)\n    (hfg : deriv f =O[l] g) : \u00acIntervalIntegrable g volume a b :=\n  by\n  intro hgi\n  obtain \u27e8C, hC\u2080, s, hsl, hsub, hfd, hg\u27e9 :\n    \u2203 (C : \u211d)(hC\u2080 : 0 \u2264 C),\n      \u2203 s \u2208 l,\n        (\u2200 x \u2208 s, \u2200 y \u2208 s, [x, y] \u2286 [a, b]) \u2227\n          (\u2200 x \u2208 s, \u2200 y \u2208 s, \u2200 z \u2208 [x, y], DifferentiableAt \u211d f z) \u2227\n            \u2200 x \u2208 s, \u2200 y \u2208 s, \u2200 z \u2208 [x, y], \u2016deriv f z\u2016 \u2264 C * \u2016g z\u2016 :=\n    by\n    rcases hfg.exists_nonneg with \u27e8C, C\u2080, hC\u27e9\n    have h :\n      \u2200\u1da0 x : \u211d \u00d7 \u211d in l.prod l,\n        \u2200 y \u2208 [x.1, x.2], (DifferentiableAt \u211d f y \u2227 \u2016deriv f y\u2016 \u2264 C * \u2016g y\u2016) \u2227 y \u2208 [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 \u27e8s, hsl, hs\u27e9\n    simp only [prod_subset_iff, mem_set_of_eq] at hs\n    exact\n      \u27e8C, C\u2080, 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\u27e9\n  replace hgi : IntervalIntegrable (fun x => C * \u2016g x\u2016) volume a b\n  \u00b7 convert hgi.norm.smul C\n  obtain \u27e8c, hc, d, hd, hlt\u27e9 : \u2203 c \u2208 s, \u2203 d \u2208 s, (\u2016f c\u2016 + \u222b y in \u0399 a b, C * \u2016g y\u2016) < \u2016f d\u2016 :=\n    by\n    rcases Filter.nonempty_of_mem hsl with \u27e8c, hc\u27e9\n    have : \u2200\u1da0 x in l, (\u2016f c\u2016 + \u222b y in \u0399 a b, C * \u2016g y\u2016) < \u2016f x\u2016 :=\n      hf.eventually (eventually_gt_at_top _)\n    exact \u27e8c, hc, (this.and hsl).exists.imp fun d hd => \u27e8hd.2, hd.1\u27e9\u27e9\n  specialize hsub c hc d hd\n  specialize hfd c hc d hd\n  replace hg : \u2200 x \u2208 \u0399 c d, \u2016deriv f x\u2016 \u2264 C * \u2016g x\u2016\n  exact fun z hz => hg c hc d hd z \u27e8hz.1.le, hz.2\u27e9\n  have hg_ae : \u2200\u1d50 x \u2202volume.restrict (\u0399 c d), \u2016deriv f x\u2016 \u2264 C * \u2016g x\u2016 :=\n    (ae_restrict_mem measurableSet_uIoc).mono hg\n  have hsub' : \u0399 c d \u2286 \u0399 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    \u2016f d\u2016 - \u2016f c\u2016 \u2264 \u2016f d - f c\u2016 := norm_sub_norm_le _ _\n    _ = \u2016\u222b x in c..d, deriv f x\u2016 := (congr_arg _ (integral_deriv_eq_sub hfd hfi).symm)\n    _ = \u2016\u222b x in \u0399 c d, deriv f x\u2016 := (norm_integral_eq_norm_integral_Ioc _)\n    _ \u2264 \u222b x in \u0399 c d, \u2016deriv f x\u2016 := (norm_integral_le_integral_norm _)\n    _ \u2264 \u222b x in \u0399 c d, C * \u2016g x\u2016 :=\n      (set_integral_mono_on hfi.norm.def (hgi.def.mono_set hsub') measurableSet_uIoc hg)\n    _ \u2264 \u222b x in \u0399 a b, C * \u2016g x\u2016 :=\n      set_integral_mono_set hgi.def (ae_of_all _ fun x => mul_nonneg hC\u2080 (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 \u2260 b`, `c \u2208 [a, b]`, `f` is differentiable in the neighborhood of `c` within\n`[a, b] \\ {c}`, `\u2016f x\u2016 \u2192 \u221e` as `x \u2192 c` within `[a, b] \\ {c}`, and `f' = O(g)` along\n`\ud835\udcdd[[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 : \u211d \u2192 E}\n    {g : \u211d \u2192 F} {a b c : \u211d} (hne : a \u2260 b) (hc : c \u2208 [a, b])\n    (h_deriv : \u2200\u1da0 x in \ud835\udcdd[[a, b] \\ {c}] c, DifferentiableAt \u211d f x)\n    (h_infty : Tendsto (fun x => \u2016f x\u2016) (\ud835\udcdd[[a, b] \\ {c}] c) atTop)\n    (hg : deriv f =O[\ud835\udcdd[[a, b] \\ {c}] c] g) : \u00acIntervalIntegrable g volume a b :=\n  by\n  obtain \u27e8l, hl, hl', hle, hmem\u27e9 :\n    \u2203 l : Filter \u211d, tendsto_Ixx_class Icc l l \u2227 l.ne_bot \u2227 l \u2264 \ud835\udcdd c \u2227 [a, b] \\ {c} \u2208 l :=\n    by\n    cases' (min_lt_max.2 hne).lt_or_lt c with hlt hlt\n    \u00b7 refine' \u27e8\ud835\udcdd[<] c, inferInstance, inferInstance, inf_le_left, _\u27e9\n      rw [\u2190 Iic_diff_right]\n      exact diff_mem_nhdsWithin_diff (Icc_mem_nhdsWithin_Iic \u27e8hlt, hc.2\u27e9) _\n    \u00b7 refine' \u27e8\ud835\udcdd[>] c, inferInstance, inferInstance, inf_le_left, _\u27e9\n      rw [\u2190 Ici_diff_left]\n      exact diff_mem_nhdsWithin_diff (Icc_mem_nhdsWithin_Ici \u27e8hc.1, hlt\u27e9) _\n  skip\n  have : l \u2264 \ud835\udcdd[[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`, `\u2016f x\u2016 \u2192 \u221e` as `x \u2192 c` (more\nformally, along the filter `\ud835\udcdd[\u2260] c`), and `f' = O(g)` along `\ud835\udcdd[\u2260] c`, where `f'` is the derivative\nof `f`, then `g` is not interval integrable on any nontrivial interval `a..b` such that\n`c \u2208 [a, b]`. -/\ntheorem not_intervalIntegrable_of_tendsto_norm_atTop_of_deriv_isO_punctured {f : \u211d \u2192 E} {g : \u211d \u2192 F}\n    {a b c : \u211d} (h_deriv : \u2200\u1da0 x in \ud835\udcdd[\u2260] c, DifferentiableAt \u211d f x)\n    (h_infty : Tendsto (fun x => \u2016f x\u2016) (\ud835\udcdd[\u2260] c) atTop) (hg : deriv f =O[\ud835\udcdd[\u2260] c] g) (hne : a \u2260 b)\n    (hc : c \u2208 [a, b]) : \u00acIntervalIntegrable g volume a b :=\n  have : \ud835\udcdd[[a, b] \\ {c}] c \u2264 \ud835\udcdd[\u2260] 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 : \u211d` at least as fast as `1 / (x - c)`,\nthen it is not interval integrable on any nontrivial interval `a..b`, `c \u2208 [a, b]`. -/\ntheorem not_intervalIntegrable_of_sub_inv_isO_punctured {f : \u211d \u2192 F} {a b c : \u211d}\n    (hf : (fun x => (x - c)\u207b\u00b9) =O[\ud835\udcdd[\u2260] c] f) (hne : a \u2260 b) (hc : c \u2208 [a, b]) :\n    \u00acIntervalIntegrable f volume a b :=\n  by\n  have A : \u2200\u1da0 x in \ud835\udcdd[\u2260] c, HasDerivAt (fun x => Real.log (x - c)) (x - c)\u207b\u00b9 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 => \u2016Real.log (x - c)\u2016) (\ud835\udcdd[\u2260] c) at_top :=\n    by\n    refine' tendsto_abs_at_bot_at_top.comp (real.tendsto_log_nhds_within_zero.comp _)\n    rw [\u2190 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 `\u03bb x, (x - c)\u207b\u00b9` is integrable on `a..b` if and only if `a = b` or `c \u2209 [a, b]`. -/\n@[simp]\ntheorem intervalIntegrable_sub_inv_iff {a b c : \u211d} :\n    IntervalIntegrable (fun x => (x - c)\u207b\u00b9) volume a b \u2194 a = b \u2228 c \u2209 [a, b] :=\n  by\n  constructor\n  \u00b7 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  \u00b7 rintro (rfl | h\u2080)\n    exacts[IntervalIntegrable.refl,\n      interval_integrable_inv (fun x hx => sub_ne_zero.2 <| ne_of_mem_of_not_mem hx h\u2080)\n        (continuous_on_id.sub continuousOn_const)]\n#align interval_integrable_sub_inv_iff intervalIntegrable_sub_inv_iff\n\n/-- The function `\u03bb x, x\u207b\u00b9` is integrable on `a..b` if and only if `a = b` or `0 \u2209 [a, b]`. -/\n@[simp]\ntheorem intervalIntegrable_inv_iff {a b : \u211d} :\n    IntervalIntegrable (fun x => x\u207b\u00b9) volume a b \u2194 a = b \u2228 (0 : \u211d) \u2209 [a, b] := by\n  simp only [\u2190 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 : \u2124} : 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 : \u2124} (h : a \u2264 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 : \u2124} (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, \u2190le_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 : \u2124} (h : a < b) :\n  finset.Ioc (a+1) b = (finset.Ioc a b).erase (a+1) :=\nbegin\n  rw [\u2190@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 : \u2124} (h : a \u2264 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 : \u2115} : finset.Icc x y \u2286 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 : \u2115} (h\u2081 : x \u2264 y) (h\u2082 : y \u2264 z) :\n  finset.Ico x y \u222a finset.Icc y z = finset.Icc x z :=\nby rw [\u2190finset.coe_inj, finset.coe_union, finset.coe_Ico, finset.coe_Icc, finset.coe_Icc,\n    set.Ico_union_Icc_eq_Icc h\u2081 h\u2082]\n\n@[simp] lemma Ico_inter_Icc_consecutive {\u03b1 : Type*} [linear_order \u03b1]\n  [locally_finite_order \u03b1] (a b c : \u03b1) : finset.Ico a b \u2229 finset.Icc b c = \u2205 :=\nbegin\n  refine finset.eq_empty_of_forall_not_mem (\u03bb 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 {\u03b1 : Type*} [linear_order \u03b1]\n  [locally_finite_order \u03b1] (a b c : \u03b1) : 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 : \u2115} (h\u2081 : x \u2264 y) (h\u2082 : y \u2264 z) :\n  finset.Icc x z \\ finset.Icc y z = finset.Ico x y :=\nbegin\n  rw \u2190finset.Ico_union_Icc_eq_Icc h\u2081 h\u2082,\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 : \u2115} (h\u2081 : z \u2264 y) (h\u2082 : x \u2264 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 \u27e8\u03bb h, \u27e8h.2 h.1.1, h.1.2\u27e9, \u03bb h, \u27e8\u27e8h\u2082.trans h.1.le, h.2\u27e9, \u03bb _, h.1\u27e9\u27e9,\nend\n\nlemma range_sdiff_Icc {x y : \u2115} (h : x \u2264 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 : \u211d} (hab : a \u2264 b) : set.Ici a \\ set.Icc a b = set.Ioi b :=\nbegin\n  rw [\u2190set.Icc_union_Ioi_eq_Ici hab, set.union_diff_left, set.diff_eq_self],\n  rintro x \u27e8\u27e8_, hx\u27e9, hx'\u27e9,\n  exact not_le_of_lt hx' hx,\nend\n\nlemma Ioi_diff_Icc {a b : \u211d} (hab : a \u2264 b) : set.Ioi a \\ set.Ioc a b = set.Ioi b :=\nbegin\n  rw [\u2190set.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 {\u03b1 \u03b2 : Type*} [division_ring \u03b2] [char_zero \u03b2] (s : finset \u03b1)\n  (f : \u03b1 \u2192 \u211a) :\n  \u2191(\u2211 x in s, f x : \u211a) = (\u2211 x in s, (f x : \u03b2)) :=\n(rat.cast_hom \u03b2).map_sum f s\n\nlemma finset.prod_rpow {\u03b9 : Type*} {s : finset \u03b9} {f : \u03b9 \u2192 \u211d}\n  (c : \u211d) (hf : \u2200 x \u2208 s, 0 \u2264 f x) :\n  (\u220f i in s, f i) ^ c = \u220f 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 {\u03b9 R : Type*} [ordered_comm_semiring R] {f : \u03b9 \u2192 R} {s : finset \u03b9}\n  (h1 : \u2200 i \u2208 s, 1 \u2264 f i) : 1 \u2264 \u220f i in s, f i :=\n(finset.prod_le_prod (\u03bb _ _, zero_le_one) h1).trans' (by simp)\n\nlemma finset.filter_comm {\u03b1 : Type*} (p q : \u03b1 \u2192 Prop) [decidable_eq \u03b1]\n  [decidable_pred p] [decidable_pred q] (s : finset \u03b1) :\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 : \u211d} (hx : 1 \u2264 x) (hr : 1 \u2264 r) :\n  x \u2264 x ^ r :=\nby simpa using real.rpow_le_rpow_of_exponent_le hx hr\n\nlemma real.le_rpow_self_of {x : \u211d} {r : \u211d} (hx\u2080 : 0 \u2264 x) (hx\u2081 : x \u2264 1) (h_one_le : r \u2264 1) :\n  x \u2264 x ^ r :=\nbegin\n  rcases eq_or_ne r 0 with rfl | hr,\n  { simp [hx\u2081] },\n  rcases eq_or_lt_of_le hx\u2080 with rfl | hx\u2080,\n  { rw real.zero_rpow hr },\n  simpa using real.rpow_le_rpow_of_exponent_ge hx\u2080 hx\u2081 h_one_le\nend\n\n@[to_additive]\nlemma prod_powerset_compl {\u03b1 \u03b2 : Type*} [decidable_eq \u03b1] [comm_monoid \u03b2]\n  (s : finset \u03b1) (f : finset \u03b1 \u2192 \u03b2) :\n  \u220f x in s.powerset, f (s \\ x) = \u220f x in s.powerset, f x :=\nbegin\n  refine finset.prod_bij' (\u03bb x _, s \\ x) (by simp) (\u03bb _ _, rfl) (\u03bb 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 ` \u2243 `:55 := C  -- \\ equiv == equivalence/congruence\nlocal infix `\u2b1d`: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\u2b1dy \u2243 y\u2b1dx\n@[tidy] axiom C_iden (x y z : Point) :  x\u2b1dy \u2243 z\u2b1dz \u2192 x = y\n@[trans] axiom C_trans (u v w x y z : Point) : (u\u2b1dv \u2243 z\u2b1dw) \u2192 (u\u2b1dv \u2243 x\u2b1dy) \u2192 z\u2b1dw \u2243 x\u2b1dy\n-- used to be (u\u2b1dv \u2243 z\u2b1dw) \u2227 (u\u2b1dv \u2243 x\u2b1dy) \u2192 z\u2b1dw \u2243 x\u2b1dy\n\n--- Equivalence relations: (~ means is related to)\n-- 1. Reflexive x ~ x\n-- 2. Symmetric x ~ y \u2192 y ~ x\n-- 3. Transitive x ~ y \u2227 y ~ z \u2192 x ~ z\n--- Example : Equality =\n--- Non-example : Less-than-or-equal relation \"\u2264\"\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 \u2243 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 \u2243 s2 \u2192 s2 \u2243 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 \u2243 s2 \u2192 s2 \u2243 s3 \u2192 s1 \u2243 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\u2b1dy \u2243 z\u2b1dw \u2192 x\u2b1dy \u2243 w\u2b1dz :=\nbegin\n  intro H,\n  transitivity,\n    apply H,  -- this means use z\u2b1dw for the unknown variable.\n    exact C_swap z w,\nend\n\n@[symm] lemma C_swap_left (x y w z : Point) : x\u2b1dy \u2243 z\u2b1dw \u2192 y\u2b1dx \u2243 z\u2b1dw :=\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\u2b1dy \u2243 z\u2b1dw \u2192 y\u2b1dx \u2243 w\u2b1dz :=\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 \u2192 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) \u2192 (B y v z) \u2192 \u2203 (a : Point), B u a y \u2227 B v a x \n\n-- Defining the axiom schema\n-- Phi and Psi are just some \"properties\"\naxiom dedekind_cut (\u03c6 \u03c8 : Point \u2192 Prop) :\n    \u2203 (a : Point), \u2200 (x y : Point), \u03c6 x \u2227 \u03c8 y \u2192 B a x y\n  \u2192 \u2203 (b : Point), \u2200 (x y : Point), \u03c6 x \u2227 \u03c8 y \u2192 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 : \u2203 (a b c : Point),\n  (\u00ac B a b c) \u2227 (\u00ac B b a a) \u2227 (\u00ac 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\u2b1du \u2243 x\u2b1dv) \u2192 (y\u2b1du \u2243 z\u2b1dv) \u2192 (z\u2b1du \u2243 z\u2b1dv) \u2192 (u \u2260 v)\n  \u2192 (B x y z) \u2228 (B y z x) \u2228 (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 \u2192 x\u2b1dy \u2243 y\u2b1dw\n  \u2192 B x u v \u2192 x\u2b1du \u2243 u\u2b1dv\n  \u2192 B y u z \u2192 y\u2b1du \u2243 z\u2b1du\n  \u2192 y\u2b1dz \u2243 v\u2b1dw\n\n\n\nlemma euclid_b (x y z : Point) :\n  (B x y z) \u2228 (B y z x) \u2228 (B z x y) \u2228 (\u2203 a : Point, (x\u2b1da \u2243 y\u2b1da) \u2227 (x\u2b1da \u2243 z\u2b1da)) :=\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 \u2192 B y u z \u2192  x \u2260 u\n  \u2192 \u2203 (a b : Point), (B x y a \u2227 B x z b \u2227 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 \u2260 y) \u2192 (B x y z) \u2192 (B x' y' z')\n  \u2192 (x\u2b1dy \u2243 x'\u2b1dy') \u2192 (y\u2b1dz \u2243 y'\u2b1dz') \u2192 (x\u2b1du \u2243 x'\u2b1du') \u2192 (y\u2b1du \u2243 y'\u2b1du')\n  \u2192 (z\u2b1du \u2243 z'\u2b1du')\n\n\n-- Axiom of segment construction\naxiom segment_construct (x y a b : Point) :\n  \u2203 z : Point, (B x y z) \u2227 (y\u2b1dz \u2243 a\u2b1db)\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 \u2192 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 \u2192 B y z w \u2192 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 \u2192 B x z w \u2192 B x y z \u2228 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\u2b1dy \u2243 v\u2b1dv :=\nbegin\n  have h := segment_construct v y v y,\n  choose x h using h,\n  cases h with h\u2081 h\u2082,\n  have h\u2083 : v\u2b1dy \u2243 y\u2b1dx,\n    {exact C_symm (y\u2b1dx) (v\u2b1dy) h\u2082},\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 \u2192 2 \u2192 3 \u2192 1, or show 1 \u2192 3 \u2192 2 \u2192 1.\ntheorem extend_identity (x y z : Point): tfae [(x\u2b1dy \u2243 z\u2b1dz), (x=y), (B x y x)] :=\nbegin\n  tfae_have: 1 \u2192 2,\n    apply C_iden,\n  tfae_have: 2 \u2192 3,\n    intro H,\n    rw H,\n    fapply B_includes_end1,\n  tfae_have: 3 \u2192 2,\n    apply B_id,\n  tfae_have: 2 \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `(-\u221e, a)` and `(b, +\u221e)`). We define it as `preorder.topology \u03b1`.\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 \u03b1`). Instead,\nwe introduce a class `order_topology \u03b1` (which is a `Prop`, also known as a mixin) saying that on\nthe type `\u03b1` 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 \u03b1` saying that the set of points\n`(x, y)` with `x \u2264 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 \u2264 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 \u2264 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 \u2208 (x, y]`, and any neighborhood\n  of `y` includes an interval `(z, y]` for some `z \u2208 [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 \u2264 g x`, then `a \u2264 b`\n* `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x \u2264 b`\n  (resp., `b \u2264 f x`), then `a \u2264 b` (resp., `b \u2264 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 \u2264 f x \u2264 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 `\u2115` or `\u2124`, or `\u211d` that could inherit a topology as the completion of `\u211a`),\nand is in general not defeq to the one generated by the intervals. We make it available as a\ndefinition `preorder.topology \u03b1` 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : 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 \u2264 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 (\u03b1 : Type _) [TopologicalSpace \u03b1] [Preorder \u03b1] : Prop where\n  isClosed_le' : IsClosed { p : \u03b1 \u00d7 \u03b1 | p.1 \u2264 p.2 }\n#align order_closed_topology OrderClosedTopology\n-/\n\ninstance [TopologicalSpace \u03b1] [h : FirstCountableTopology \u03b1] : FirstCountableTopology \u03b1\u1d52\u1d48 :=\n  h\n\ninstance [TopologicalSpace \u03b1] [h : SecondCountableTopology \u03b1] : SecondCountableTopology \u03b1\u1d52\u1d48 :=\n  h\n\n#print Dense.orderDual /-\ntheorem Dense.orderDual [TopologicalSpace \u03b1] {s : Set \u03b1} (hs : Dense s) :\n    Dense (OrderDual.ofDual \u207b\u00b9' s) :=\n  hs\n#align dense.order_dual Dense.orderDual\n-/\n\nsection OrderClosedTopology\n\nsection Preorder\n\nvariable [TopologicalSpace \u03b1] [Preorder \u03b1] [t : OrderClosedTopology \u03b1]\n\ninclude t\n\nnamespace Subtype\n\ninstance {p : \u03b1 \u2192 Prop} : OrderClosedTopology (Subtype p) :=\n  have this : Continuous fun p : Subtype p \u00d7 Subtype p => ((p.fst : \u03b1), (p.snd : \u03b1)) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderClosedTopology.{u1} \u03b1 _inst_1 _inst_2], IsClosed.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderClosedTopology.{u1} \u03b1 _inst_1 _inst_2], IsClosed.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p)))\nCase conversion may be inaccurate. Consider using '#align is_closed_le_prod isClosed_le_prod\u2093'. -/\ntheorem isClosed_le_prod : IsClosed { p : \u03b1 \u00d7 \u03b1 | p.1 \u2264 p.2 } :=\n  t.isClosed_le'\n#align is_closed_le_prod isClosed_le_prod\n\n#print isClosed_le /-\ntheorem isClosed_le [TopologicalSpace \u03b2] {f g : \u03b2 \u2192 \u03b1} (hf : Continuous f) (hg : Continuous g) :\n    IsClosed { b | f b \u2264 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 : \u03b1) : IsClosed { b | b \u2264 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 : \u03b1} : IsClosed (Iic a) :=\n  isClosed_le' a\n#align is_closed_Iic isClosed_Iic\n-/\n\n#print isClosed_ge' /-\ntheorem isClosed_ge' (a : \u03b1) : IsClosed { b | a \u2264 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 : \u03b1} : IsClosed (Ici a) :=\n  isClosed_ge' a\n#align is_closed_Ici isClosed_Ici\n-/\n\ninstance : OrderClosedTopology \u03b1\u1d52\u1d48 :=\n  \u27e8(@OrderClosedTopology.isClosed_le' \u03b1 _ _ _).Preimage continuous_swap\u27e9\n\n#print isClosed_Icc /-\ntheorem isClosed_Icc {a b : \u03b1} : 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 : \u03b1) : 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 : \u03b1) : 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 : \u03b1) : 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 : \u03b2 \u2192 \u03b1} {b : Filter \u03b2} {a\u2081 a\u2082 : \u03b1} [NeBot b]\n    (hf : Tendsto f b (\ud835\udcdd a\u2081)) (hg : Tendsto g b (\ud835\udcdd a\u2082)) (h : f \u2264\u1da0[b] g) : a\u2081 \u2264 a\u2082 :=\n  have : Tendsto (fun b => (f b, g b)) b (\ud835\udcdd (a\u2081, a\u2082)) := by\n    rw [nhds_prod_eq] <;> exact hf.prod_mk hg\n  show (a\u2081, a\u2082) \u2208 { p : \u03b1 \u00d7 \u03b1 | p.1 \u2264 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 \u2190 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 : \u03b2 \u2192 \u03b1} {b : Filter \u03b2} {a\u2081 a\u2082 : \u03b1} [NeBot b]\n    (hf : Tendsto f b (\ud835\udcdd a\u2081)) (hg : Tendsto g b (\ud835\udcdd a\u2082)) (h : \u2200 x, f x \u2264 g x) : a\u2081 \u2264 a\u2082 :=\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 : \u03b2 \u2192 \u03b1} {a b : \u03b1} {x : Filter \u03b2} [NeBot x] (lim : Tendsto f x (\ud835\udcdd a))\n    (h : \u2200\u1da0 c in x, f c \u2264 b) : a \u2264 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 : \u03b2 \u2192 \u03b1} {a b : \u03b1} {x : Filter \u03b2} [NeBot x] (lim : Tendsto f x (\ud835\udcdd a))\n    (h : \u2200 c, f c \u2264 b) : a \u2264 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 : \u03b2 \u2192 \u03b1} {a b : \u03b1} {x : Filter \u03b2} [NeBot x] (lim : Tendsto f x (\ud835\udcdd a))\n    (h : \u2200\u1da0 c in x, b \u2264 f c) : b \u2264 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 : \u03b2 \u2192 \u03b1} {a b : \u03b1} {x : Filter \u03b2} [NeBot x] (lim : Tendsto f x (\ud835\udcdd a))\n    (h : \u2200 c, b \u2264 f c) : b \u2264 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 \u03b2] {f g : \u03b2 \u2192 \u03b1} (hf : Continuous f) (hg : Continuous g) :\n    closure { b | f b \u2264 g b } = { b | f b \u2264 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 \u03b2] {f g : \u03b2 \u2192 \u03b1} (hf : Continuous f)\n    (hg : Continuous g) : closure { b | f b < g b } \u2286 { b | f b \u2264 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 \u03b2] {f g : \u03b2 \u2192 \u03b1} {s : Set \u03b2} {x : \u03b2}\n    (hx : x \u2208 closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x)\n    (h : \u2200 y \u2208 s, f y \u2264 g y) : f x \u2264 g x :=\n  show (f x, g x) \u2208 { p : \u03b1 \u00d7 \u03b1 | p.1 \u2264 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 \u2208 s | f x \u2264 g x}` is a closed set. -/\ntheorem IsClosed.isClosed_le [TopologicalSpace \u03b2] {f g : \u03b2 \u2192 \u03b1} {s : Set \u03b2} (hs : IsClosed s)\n    (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x \u2208 s | f x \u2264 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 \u03b2] {f g : \u03b2 \u2192 \u03b1} {s : Set \u03b2} (h : \u2200 x \u2208 s, f x \u2264 g x)\n    (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) \u2983x\u2984 (hx : x \u2208 closure s) :\n    f x \u2264 g x :=\n  have : s \u2286 { y \u2208 closure s | f y \u2264 g y } := fun y hy => \u27e8subset_closure hy, h y hy\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderClosedTopology.{u1} \u03b1 _inst_1 _inst_2] [_inst_3 : TopologicalSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {s : Set.{u2} \u03b2}, (IsClosed.{u2} \u03b2 _inst_3 s) -> (ContinuousOn.{u2, u1} \u03b2 \u03b1 _inst_3 _inst_1 f s) -> (IsClosed.{max u2 u1} (Prod.{u2, u1} \u03b2 \u03b1) (Prod.topologicalSpace.{u2, u1} \u03b2 \u03b1 _inst_3 _inst_1) (setOf.{max u2 u1} (Prod.{u2, u1} \u03b2 \u03b1) (fun (p : Prod.{u2, u1} \u03b2 \u03b1) => And (Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) (Prod.fst.{u2, u1} \u03b2 \u03b1 p) s) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) (f (Prod.fst.{u2, u1} \u03b2 \u03b1 p)) (Prod.snd.{u2, u1} \u03b2 \u03b1 p)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderClosedTopology.{u1} \u03b1 _inst_1 _inst_2] [_inst_3 : TopologicalSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {s : Set.{u2} \u03b2}, (IsClosed.{u2} \u03b2 _inst_3 s) -> (ContinuousOn.{u2, u1} \u03b2 \u03b1 _inst_3 _inst_1 f s) -> (IsClosed.{max u1 u2} (Prod.{u2, u1} \u03b2 \u03b1) (instTopologicalSpaceProd.{u2, u1} \u03b2 \u03b1 _inst_3 _inst_1) (setOf.{max u1 u2} (Prod.{u2, u1} \u03b2 \u03b1) (fun (p : Prod.{u2, u1} \u03b2 \u03b1) => And (Membership.mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.instMembershipSet.{u2} \u03b2) (Prod.fst.{u2, u1} \u03b2 \u03b1 p) s) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) (f (Prod.fst.{u2, u1} \u03b2 \u03b1 p)) (Prod.snd.{u2, u1} \u03b2 \u03b1 p)))))\nCase conversion may be inaccurate. Consider using '#align is_closed.epigraph IsClosed.epigraph\u2093'. -/\ntheorem IsClosed.epigraph [TopologicalSpace \u03b2] {f : \u03b2 \u2192 \u03b1} {s : Set \u03b2} (hs : IsClosed s)\n    (hf : ContinuousOn f s) : IsClosed { p : \u03b2 \u00d7 \u03b1 | p.1 \u2208 s \u2227 f p.1 \u2264 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderClosedTopology.{u1} \u03b1 _inst_1 _inst_2] [_inst_3 : TopologicalSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {s : Set.{u2} \u03b2}, (IsClosed.{u2} \u03b2 _inst_3 s) -> (ContinuousOn.{u2, u1} \u03b2 \u03b1 _inst_3 _inst_1 f s) -> (IsClosed.{max u2 u1} (Prod.{u2, u1} \u03b2 \u03b1) (Prod.topologicalSpace.{u2, u1} \u03b2 \u03b1 _inst_3 _inst_1) (setOf.{max u2 u1} (Prod.{u2, u1} \u03b2 \u03b1) (fun (p : Prod.{u2, u1} \u03b2 \u03b1) => And (Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) (Prod.fst.{u2, u1} \u03b2 \u03b1 p) s) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) (Prod.snd.{u2, u1} \u03b2 \u03b1 p) (f (Prod.fst.{u2, u1} \u03b2 \u03b1 p))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderClosedTopology.{u1} \u03b1 _inst_1 _inst_2] [_inst_3 : TopologicalSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {s : Set.{u2} \u03b2}, (IsClosed.{u2} \u03b2 _inst_3 s) -> (ContinuousOn.{u2, u1} \u03b2 \u03b1 _inst_3 _inst_1 f s) -> (IsClosed.{max u1 u2} (Prod.{u2, u1} \u03b2 \u03b1) (instTopologicalSpaceProd.{u2, u1} \u03b2 \u03b1 _inst_3 _inst_1) (setOf.{max u1 u2} (Prod.{u2, u1} \u03b2 \u03b1) (fun (p : Prod.{u2, u1} \u03b2 \u03b1) => And (Membership.mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.instMembershipSet.{u2} \u03b2) (Prod.fst.{u2, u1} \u03b2 \u03b1 p) s) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) (Prod.snd.{u2, u1} \u03b2 \u03b1 p) (f (Prod.fst.{u2, u1} \u03b2 \u03b1 p))))))\nCase conversion may be inaccurate. Consider using '#align is_closed.hypograph IsClosed.hypograph\u2093'. -/\ntheorem IsClosed.hypograph [TopologicalSpace \u03b2] {f : \u03b2 \u2192 \u03b1} {s : Set \u03b2} (hs : IsClosed s)\n    (hf : ContinuousOn f s) : IsClosed { p : \u03b2 \u00d7 \u03b1 | p.1 \u2208 s \u2227 p.2 \u2264 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 : \u03b1} (H\u2082 : a \u2264 b) : NeBot (\ud835\udcdd[Ici a] b) :=\n  nhdsWithin_neBot_of_mem H\u2082\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 : \u03b1) : NeBot (\ud835\udcdd[\u2265] 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 : \u03b1} (H : a \u2264 b) : NeBot (\ud835\udcdd[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 : \u03b1) : NeBot (\ud835\udcdd[\u2264] 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 \u03b1] [PartialOrder \u03b1] [t : OrderClosedTopology \u03b1]\n\ninclude t\n\n#print OrderClosedTopology.to_t2Space /-\n-- see Note [lower instance priority]\ninstance (priority := 90) OrderClosedTopology.to_t2Space : T2Space \u03b1 :=\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 \u03b1] [LinearOrder \u03b1] [OrderClosedTopology \u03b1]\n\n/- warning: is_open_lt_prod -> isOpen_lt_prod is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))], IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))], IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p)))\nCase conversion may be inaccurate. Consider using '#align is_open_lt_prod isOpen_lt_prod\u2093'. -/\ntheorem isOpen_lt_prod : IsOpen { p : \u03b1 \u00d7 \u03b1 | p.1 < p.2 } :=\n  by\n  simp_rw [\u2190 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 \u03b2] {f g : \u03b2 \u2192 \u03b1} (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 : \u03b1}\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 \u2286 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 : \u03b1} (h : a < b) : Iio b \u2208 \ud835\udcdd 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 : \u03b1} (h : a < b) : Ioi a \u2208 \ud835\udcdd 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 : \u03b1} (h : a < b) : Iic b \u2208 \ud835\udcdd 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 : \u03b1} (h : a < b) : Ici a \u2208 \ud835\udcdd 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 : \u03b1} (ha : a < x) (hb : x < b) : Ioo a b \u2208 \ud835\udcdd x :=\n  IsOpen.mem_nhds isOpen_Ioo \u27e8ha, hb\u27e9\n#align Ioo_mem_nhds Ioo_mem_nhds\n-/\n\n#print Ioc_mem_nhds /-\ntheorem Ioc_mem_nhds {a b x : \u03b1} (ha : a < x) (hb : x < b) : Ioc a b \u2208 \ud835\udcdd 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 : \u03b1} (ha : a < x) (hb : x < b) : Ico a b \u2208 \ud835\udcdd 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 : \u03b1} (ha : a < x) (hb : x < b) : Icc a b \u2208 \ud835\udcdd 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 \u03b3} {f : \u03b3 \u2192 \u03b1} {u v : \u03b1} (hv : v < u)\n    (h : Filter.Tendsto f l (\ud835\udcdd v)) : \u2200\u1da0 a in l, f a < u :=\n  tendsto_nhds.1 h (\u00b7 < 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 \u03b3} {f : \u03b3 \u2192 \u03b1} {u v : \u03b1} (hv : u < v)\n    (h : Filter.Tendsto f l (\ud835\udcdd v)) : \u2200\u1da0 a in l, u < f a :=\n  tendsto_nhds.1 h (\u00b7 > 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 \u03b3} {f : \u03b3 \u2192 \u03b1} {u v : \u03b1} (hv : v < u)\n    (h : Tendsto f l (\ud835\udcdd v)) : \u2200\u1da0 a in l, f a \u2264 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 \u03b3} {f : \u03b3 \u2192 \u03b1} {u v : \u03b1} (hv : u < v)\n    (h : Tendsto f l (\ud835\udcdd v)) : \u2200\u1da0 a in l, u \u2264 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 \u03b3]\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 `\ud835\udcdd[>] a` and\n`\ud835\udcdd[\u2265] 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 \u03b1` -/\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 : \u03b1} (H : b \u2208 Ico a c) : Ioo a c \u2208 \ud835\udcdd[>] b :=\n  mem_nhdsWithin.2\n    \u27e8Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio] <;> exact Ioo_subset_Ioo_left H.1\u27e9\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 : \u03b1} (H : b \u2208 Ico a c) : Ioc a c \u2208 \ud835\udcdd[>] 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 : \u03b1} (H : b \u2208 Ico a c) : Ico a c \u2208 \ud835\udcdd[>] 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 : \u03b1} (H : b \u2208 Ico a c) : Icc a c \u2208 \ud835\udcdd[>] 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 : \u03b1} (h : a < b) : \ud835\udcdd[Ioc a b] a = \ud835\udcdd[>] 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 : \u03b1} (h : a < b) : \ud835\udcdd[Ioo a b] a = \ud835\udcdd[>] 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 \u03b2] {a b : \u03b1} {f : \u03b1 \u2192 \u03b2} (h : a < b) :\n    ContinuousWithinAt f (Ioc a b) a \u2194 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 \u03b2] {a b : \u03b1} {f : \u03b1 \u2192 \u03b2} (h : a < b) :\n    ContinuousWithinAt f (Ioo a b) a \u2194 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 : \u03b1} (H : b \u2208 Ioc a c) : Ioo a c \u2208 \ud835\udcdd[<] b := by\n  simpa only [dual_Ioo] using\n    Ioo_mem_nhdsWithin_Ioi (show to_dual b \u2208 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 : \u03b1} (H : b \u2208 Ioc a c) : Ico a c \u2208 \ud835\udcdd[<] 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 : \u03b1} (H : b \u2208 Ioc a c) : Ioc a c \u2208 \ud835\udcdd[<] 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 : \u03b1} (H : b \u2208 Ioc a c) : Icc a c \u2208 \ud835\udcdd[<] 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 : \u03b1} (h : a < b) : \ud835\udcdd[Ico a b] b = \ud835\udcdd[<] 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 : \u03b1} (h : a < b) : \ud835\udcdd[Ioo a b] b = \ud835\udcdd[<] 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 : \u03b1} {f : \u03b1 \u2192 \u03b3} (h : a < b) :\n    ContinuousWithinAt f (Ico a b) b \u2194 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 : \u03b1} {f : \u03b1 \u2192 \u03b3} (h : a < b) :\n    ContinuousWithinAt f (Ioo a b) b \u2194 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 : \u03b1} (H : b \u2208 Ioo a c) : Ioo a c \u2208 \ud835\udcdd[\u2265] 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 : \u03b1} (H : b \u2208 Ioo a c) : Ioc a c \u2208 \ud835\udcdd[\u2265] 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 : \u03b1} (H : b \u2208 Ico a c) : Ico a c \u2208 \ud835\udcdd[\u2265] b :=\n  mem_nhdsWithin.2\n    \u27e8Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]\u27e9\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 : \u03b1} (H : b \u2208 Ico a c) : Icc a c \u2208 \ud835\udcdd[\u2265] 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 : \u03b1} (h : a < b) : \ud835\udcdd[Icc a b] a = \ud835\udcdd[\u2265] 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 : \u03b1} (h : a < b) : \ud835\udcdd[Ico a b] a = \ud835\udcdd[\u2265] 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 \u03b2] {a b : \u03b1} {f : \u03b1 \u2192 \u03b2} (h : a < b) :\n    ContinuousWithinAt f (Icc a b) a \u2194 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 \u03b2] {a b : \u03b1} {f : \u03b1 \u2192 \u03b2} (h : a < b) :\n    ContinuousWithinAt f (Ico a b) a \u2194 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 : \u03b1} (H : b \u2208 Ioo a c) : Ioo a c \u2208 \ud835\udcdd[\u2264] 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 : \u03b1} (H : b \u2208 Ioo a c) : Ico a c \u2208 \ud835\udcdd[\u2264] 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 : \u03b1} (H : b \u2208 Ioc a c) : Ioc a c \u2208 \ud835\udcdd[\u2264] b := by\n  simpa only [dual_Ico] using\n    Ico_mem_nhdsWithin_Ici (show to_dual b \u2208 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 : \u03b1} (H : b \u2208 Ioc a c) : Icc a c \u2208 \ud835\udcdd[\u2264] 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 : \u03b1} (h : a < b) : \ud835\udcdd[Icc a b] b = \ud835\udcdd[\u2264] 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 : \u03b1} (h : a < b) : \ud835\udcdd[Ioc a b] b = \ud835\udcdd[\u2264] 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 \u03b2] {a b : \u03b1} {f : \u03b1 \u2192 \u03b2} (h : a < b) :\n    ContinuousWithinAt f (Icc a b) b \u2194 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 \u03b2] {a b : \u03b1} {f : \u03b1 \u2192 \u03b2} (h : a < b) :\n    ContinuousWithinAt f (Ioc a b) b \u2194 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 \u03b1] [LinearOrder \u03b1] [OrderClosedTopology \u03b1] {f g : \u03b2 \u2192 \u03b1}\n\nsection\n\nvariable [TopologicalSpace \u03b2]\n\n#print lt_subset_interior_le /-\ntheorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) :\n    { b | f b < g b } \u2286 interior { b | f b \u2264 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 \u2264 g b } \u2286 { b | f b = g b } :=\n  by\n  rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg]\n  rintro b \u27e8hb\u2081, hb\u2082\u27e9\n  refine' le_antisymm hb\u2081 (closure_lt_subset_le hg hf _)\n  convert hb\u2082 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 : \u03b1) : frontier (Iic a) \u2286 {a} :=\n  frontier_le_subset_eq (@continuous_id \u03b1 _) continuous_const\n#align frontier_Iic_subset frontier_Iic_subset\n-/\n\n#print frontier_Ici_subset /-\ntheorem frontier_Ici_subset (a : \u03b1) : frontier (Ici a) \u2286 {a} :=\n  @frontier_Iic_subset \u03b1\u1d52\u1d48 _ _ _ _\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 } \u2286 { b | f b = g b } := by\n  rw [\u2190 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 \u03b3] [\u2200 x, Decidable (f x \u2264 g x)] {f' g' : \u03b2 \u2192 \u03b3}\n    (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x \u2264 g x })\n    (hg' : ContinuousOn g' { x | g x \u2264 f x }) (hfg : \u2200 x, f x = g x \u2192 f' x = g' x) :\n    Continuous fun x => if f x \u2264 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  \u00b7 rwa [(isClosed_le hf hg).closure_eq]\n  \u00b7 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 \u03b3] [\u2200 x, Decidable (f x \u2264 g x)] {f' g' : \u03b2 \u2192 \u03b3}\n    (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g)\n    (hfg : \u2200 x, f x = g x \u2192 f' x = g' x) : Continuous fun x => if f x \u2264 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 \u03b3} {f g : \u03b3 \u2192 \u03b1} {y z : \u03b1} (hf : Tendsto f l (\ud835\udcdd y))\n    (hg : Tendsto g l (\ud835\udcdd z)) (hyz : y < z) : \u2200\u1da0 x in l, f x < g x :=\n  by\n  by_cases h : y \u22d6 z\n  \u00b7 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  \u00b7 obtain \u27e8w, hyw, hwz\u27e9 := (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\u2080 : \u03b2} (hf : ContinuousAt f x\u2080) (hg : ContinuousAt g x\u2080)\n    (hfg : f x\u2080 < g x\u2080) : \u2200\u1da0 x in \ud835\udcdd x\u2080, 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} [_inst_4 : TopologicalSpace.{u2} \u03b2], (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 g) -> (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (b : \u03b2) => LinearOrder.min.{u1} \u03b1 _inst_2 (f b) (g b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} [_inst_4 : TopologicalSpace.{u2} \u03b2], (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 g) -> (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (b : \u03b2) => Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_2) (f b) (g b)))\nCase conversion may be inaccurate. Consider using '#align continuous.min Continuous.min\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} [_inst_4 : TopologicalSpace.{u2} \u03b2], (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 g) -> (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (b : \u03b2) => LinearOrder.max.{u1} \u03b1 _inst_2 (f b) (g b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} [_inst_4 : TopologicalSpace.{u2} \u03b2], (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 g) -> (Continuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (b : \u03b2) => Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_2) (f b) (g b)))\nCase conversion may be inaccurate. Consider using '#align continuous.max Continuous.max\u2093'. -/\n@[continuity]\ntheorem Continuous.max (hf : Continuous f) (hg : Continuous g) :\n    Continuous fun b => max (f b) (g b) :=\n  @Continuous.min \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))], Continuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => LinearOrder.min.{u1} \u03b1 _inst_2 (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))], Continuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_2) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))\nCase conversion may be inaccurate. Consider using '#align continuous_min continuous_min\u2093'. -/\ntheorem continuous_min : Continuous fun p : \u03b1 \u00d7 \u03b1 => 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))], Continuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => LinearOrder.max.{u1} \u03b1 _inst_2 (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))], Continuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_2) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))\nCase conversion may be inaccurate. Consider using '#align continuous_max continuous_max\u2093'. -/\ntheorem continuous_max : Continuous fun p : \u03b1 \u00d7 \u03b1 => 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {b : Filter.{u2} \u03b2} {a\u2081 : \u03b1} {a\u2082 : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f b (nhds.{u1} \u03b1 _inst_1 a\u2081)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g b (nhds.{u1} \u03b1 _inst_1 a\u2082)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (b : \u03b2) => LinearOrder.max.{u1} \u03b1 _inst_2 (f b) (g b)) b (nhds.{u1} \u03b1 _inst_1 (LinearOrder.max.{u1} \u03b1 _inst_2 a\u2081 a\u2082)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {b : Filter.{u2} \u03b2} {a\u2081 : \u03b1} {a\u2082 : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f b (nhds.{u1} \u03b1 _inst_1 a\u2081)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g b (nhds.{u1} \u03b1 _inst_1 a\u2082)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (b : \u03b2) => Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_2) (f b) (g b)) b (nhds.{u1} \u03b1 _inst_1 (Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_2) a\u2081 a\u2082)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.max Filter.Tendsto.max\u2093'. -/\ntheorem Filter.Tendsto.max {b : Filter \u03b2} {a\u2081 a\u2082 : \u03b1} (hf : Tendsto f b (\ud835\udcdd a\u2081))\n    (hg : Tendsto g b (\ud835\udcdd a\u2082)) : Tendsto (fun b => max (f b) (g b)) b (\ud835\udcdd (max a\u2081 a\u2082)) :=\n  (continuous_max.Tendsto (a\u2081, a\u2082)).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {b : Filter.{u2} \u03b2} {a\u2081 : \u03b1} {a\u2082 : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f b (nhds.{u1} \u03b1 _inst_1 a\u2081)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g b (nhds.{u1} \u03b1 _inst_1 a\u2082)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (b : \u03b2) => LinearOrder.min.{u1} \u03b1 _inst_2 (f b) (g b)) b (nhds.{u1} \u03b1 _inst_1 (LinearOrder.min.{u1} \u03b1 _inst_2 a\u2081 a\u2082)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {b : Filter.{u2} \u03b2} {a\u2081 : \u03b1} {a\u2082 : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f b (nhds.{u1} \u03b1 _inst_1 a\u2081)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g b (nhds.{u1} \u03b1 _inst_1 a\u2082)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (b : \u03b2) => Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_2) (f b) (g b)) b (nhds.{u1} \u03b1 _inst_1 (Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_2) a\u2081 a\u2082)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.min Filter.Tendsto.min\u2093'. -/\ntheorem Filter.Tendsto.min {b : Filter \u03b2} {a\u2081 a\u2082 : \u03b1} (hf : Tendsto f b (\ud835\udcdd a\u2081))\n    (hg : Tendsto g b (\ud835\udcdd a\u2082)) : Tendsto (fun b => min (f b) (g b)) b (\ud835\udcdd (min a\u2081 a\u2082)) :=\n  (continuous_min.Tendsto (a\u2081, a\u2082)).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 a)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => LinearOrder.max.{u1} \u03b1 _inst_2 a (f i)) l (nhds.{u1} \u03b1 _inst_1 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 a)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_2) a (f i)) l (nhds.{u1} \u03b1 _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.max_right Filter.Tendsto.max_right\u2093'. -/\ntheorem Filter.Tendsto.max_right {l : Filter \u03b2} {a : \u03b1} (h : Tendsto f l (\ud835\udcdd a)) :\n    Tendsto (fun i => max a (f i)) l (\ud835\udcdd a) :=\n  by\n  convert((continuous_max.comp (@Continuous.Prod.mk \u03b1 \u03b1 _ _ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 a)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => LinearOrder.max.{u1} \u03b1 _inst_2 (f i) a) l (nhds.{u1} \u03b1 _inst_1 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 a)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_2) (f i) a) l (nhds.{u1} \u03b1 _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.max_left Filter.Tendsto.max_left\u2093'. -/\ntheorem Filter.Tendsto.max_left {l : Filter \u03b2} {a : \u03b1} (h : Tendsto f l (\ud835\udcdd a)) :\n    Tendsto (fun i => max (f i) a) l (\ud835\udcdd 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => LinearOrder.max.{u1} \u03b1 _inst_2 a (f i)) l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_2) a (f i)) l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right\u2093'. -/\ntheorem Filter.tendsto_nhds_max_right {l : Filter \u03b2} {a : \u03b1} (h : Tendsto f l (\ud835\udcdd[>] a)) :\n    Tendsto (fun i => max a (f i)) l (\ud835\udcdd[>] a) :=\n  by\n  obtain \u27e8h\u2081 : tendsto f l (\ud835\udcdd a), h\u2082 : \u2200\u1da0 i in l, f i \u2208 Ioi a\u27e9 := tendsto_nhds_within_iff.mp h\n  exact tendsto_nhds_within_iff.mpr \u27e8h\u2081.max_right, h\u2082.mono fun i hi => lt_max_of_lt_right hi\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => LinearOrder.max.{u1} \u03b1 _inst_2 (f i) a) l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_2) (f i) a) l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left\u2093'. -/\ntheorem Filter.tendsto_nhds_max_left {l : Filter \u03b2} {a : \u03b1} (h : Tendsto f l (\ud835\udcdd[>] a)) :\n    Tendsto (fun i => max (f i) a) l (\ud835\udcdd[>] 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 a)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => LinearOrder.min.{u1} \u03b1 _inst_2 a (f i)) l (nhds.{u1} \u03b1 _inst_1 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 a)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_2) a (f i)) l (nhds.{u1} \u03b1 _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.min_right Filter.Tendsto.min_right\u2093'. -/\ntheorem Filter.Tendsto.min_right {l : Filter \u03b2} {a : \u03b1} (h : Tendsto f l (\ud835\udcdd a)) :\n    Tendsto (fun i => min a (f i)) l (\ud835\udcdd a) :=\n  @Filter.Tendsto.max_right \u03b1\u1d52\u1d48 \u03b2 _ _ _ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 a)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => LinearOrder.min.{u1} \u03b1 _inst_2 (f i) a) l (nhds.{u1} \u03b1 _inst_1 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 a)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_2) (f i) a) l (nhds.{u1} \u03b1 _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.min_left Filter.Tendsto.min_left\u2093'. -/\ntheorem Filter.Tendsto.min_left {l : Filter \u03b2} {a : \u03b1} (h : Tendsto f l (\ud835\udcdd a)) :\n    Tendsto (fun i => min (f i) a) l (\ud835\udcdd a) :=\n  @Filter.Tendsto.max_left \u03b1\u1d52\u1d48 \u03b2 _ _ _ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => LinearOrder.min.{u1} \u03b1 _inst_2 a (f i)) l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_2) a (f i)) l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right\u2093'. -/\ntheorem Filter.tendsto_nhds_min_right {l : Filter \u03b2} {a : \u03b1} (h : Tendsto f l (\ud835\udcdd[<] a)) :\n    Tendsto (fun i => min a (f i)) l (\ud835\udcdd[<] a) :=\n  @Filter.tendsto_nhds_max_right \u03b1\u1d52\u1d48 \u03b2 _ _ _ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => LinearOrder.min.{u1} \u03b1 _inst_2 (f i) a) l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {f : \u03b2 -> \u03b1} {l : Filter.{u2} \u03b2} {a : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (i : \u03b2) => Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_2) (f i) a) l (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left\u2093'. -/\ntheorem Filter.tendsto_nhds_min_left {l : Filter \u03b2} {a : \u03b1} (h : Tendsto f l (\ud835\udcdd[<] a)) :\n    Tendsto (fun i => min (f i) a) l (\ud835\udcdd[<] a) :=\n  @Filter.tendsto_nhds_max_left \u03b1\u1d52\u1d48 \u03b2 _ _ _ 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) y x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y s) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) y x)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_lt Dense.exists_lt\u2093'. -/\ntheorem Dense.exists_lt [NoMinOrder \u03b1] {s : Set \u03b1} (hs : Dense s) (x : \u03b1) : \u2203 y \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x y)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y s) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x y)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_gt Dense.exists_gt\u2093'. -/\ntheorem Dense.exists_gt [NoMaxOrder \u03b1] {s : Set \u03b1} (hs : Dense s) (x : \u03b1) : \u2203 y \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) y x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y s) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) y x)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_le Dense.exists_le\u2093'. -/\ntheorem Dense.exists_le [NoMinOrder \u03b1] {s : Set \u03b1} (hs : Dense s) (x : \u03b1) : \u2203 y \u2208 s, y \u2264 x :=\n  (hs.exists_lt x).imp fun y hy => \u27e8hy.fst, hy.snd.le\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x y)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y s) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x y)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_ge Dense.exists_ge\u2093'. -/\ntheorem Dense.exists_ge [NoMaxOrder \u03b1] {s : Set \u03b1} (hs : Dense s) (x : \u03b1) : \u2203 y \u2208 s, x \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), (IsBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) y x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), (IsBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y s) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) y x)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_le' Dense.exists_le'\u2093'. -/\ntheorem Dense.exists_le' {s : Set \u03b1} (hs : Dense s) (hbot : \u2200 x, IsBot x \u2192 x \u2208 s) (x : \u03b1) :\n    \u2203 y \u2208 s, y \u2264 x := by\n  by_cases hx : IsBot x\n  \u00b7 exact \u27e8x, hbot x hx, le_rfl\u27e9\n  \u00b7 simp only [IsBot, not_forall, not_le] at hx\n    rcases hs.exists_mem_open isOpen_Iio hx with \u27e8y, hys, hy : y < x\u27e9\n    exact \u27e8y, hys, hy.le\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), (IsTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y s) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x y)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall (x : \u03b1), (IsTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) -> (forall (x : \u03b1), Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y s) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x y)))\nCase conversion may be inaccurate. Consider using '#align dense.exists_ge' Dense.exists_ge'\u2093'. -/\ntheorem Dense.exists_ge' {s : Set \u03b1} (hs : Dense s) (htop : \u2200 x, IsTop x \u2192 x \u2208 s) (x : \u03b1) :\n    \u2203 y \u2208 s, x \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall {x : \u03b1} {y : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x y) -> (Exists.{succ u1} \u03b1 (fun (z : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z s) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) x y)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderClosedTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {s : Set.{u1} \u03b1}, (Dense.{u1} \u03b1 _inst_1 s) -> (forall {x : \u03b1} {y : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x y) -> (Exists.{succ u1} \u03b1 (fun (z : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z s) (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) z (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) x y)))))\nCase conversion may be inaccurate. Consider using '#align dense.exists_between Dense.exists_between\u2093'. -/\ntheorem Dense.exists_between [DenselyOrdered \u03b1] {s : Set \u03b1} (hs : Dense s) {x y : \u03b1} (h : x < y) :\n    \u2203 z \u2208 s, z \u2208 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 \u03b1] [TopologicalSpace \u03b2]\n\n#print IsCompact.bddBelow /-\n/-- A compact set is bounded below -/\ntheorem IsCompact.bddBelow {s : Set \u03b1} (hs : IsCompact s) : BddBelow s :=\n  by\n  by_contra H\n  rcases hs.elim_finite_subcover_image (fun x (_ : x \u2208 s) => @isOpen_Ioi _ _ _ _ x) _ with\n    \u27e8t, st, ft, ht\u27e9\n  \u00b7 refine' H (ft.bdd_below.imp fun C hC y hy => _)\n    rcases mem_Union\u2082.1 (ht hy) with \u27e8x, hx, xy\u27e9\n    exact le_trans (hC hx) (le_of_lt xy)\n  \u00b7 refine' fun x hx => mem_Union\u2082.2 (not_imp_comm.1 _ H)\n    exact fun h => \u27e8x, fun y hy => le_of_not_lt (h.imp fun ys => \u27e8_, hy, ys\u27e9)\u27e9\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 \u03b1} (hs : IsCompact s) : BddAbove s :=\n  @IsCompact.bddBelow \u03b1\u1d52\u1d48 _ _ _ _ _ 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 : \u03b2 \u2192 \u03b1} {K : Set \u03b2} (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 : \u03b2 \u2192 \u03b1} {K : Set \u03b2} (hK : IsCompact K)\n    (hf : ContinuousOn f K) : BddAbove (f '' K) :=\n  @IsCompact.bddBelow_image \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ 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 \u03b1] {f : \u03b2 \u2192 \u03b1} (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 \u03b1] {f : \u03b2 \u2192 \u03b1} (hf : Continuous f)\n    (h : HasCompactMulSupport f) : BddAbove (range f) :=\n  @Continuous.bddBelow_range_of_hasCompactMulSupport \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ 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 \u03b1] [TopologicalSpace \u03b1] [OrderClosedTopology \u03b1] [Preorder \u03b2] [TopologicalSpace \u03b2]\n    [OrderClosedTopology \u03b2] : OrderClosedTopology (\u03b1 \u00d7 \u03b2) :=\n  \u27e8(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))\u27e9\n\ninstance {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Preorder (\u03b1 i)] [\u2200 i, TopologicalSpace (\u03b1 i)]\n    [\u2200 i, OrderClosedTopology (\u03b1 i)] : OrderClosedTopology (\u2200 i, \u03b1 i) :=\n  by\n  constructor\n  simp only [Pi.le_def, set_of_forall]\n  exact\n    isClosed_inter\u1d62 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 \u03b2] [TopologicalSpace \u03b2] [OrderClosedTopology \u03b2] :\n    OrderClosedTopology (\u03b1 \u2192 \u03b2) :=\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 (\u03b1 : Type _) [t : TopologicalSpace \u03b1] [Preorder \u03b1] : Prop where\n  topology_eq_generate_intervals : t = generateFrom { s | \u2203 a, s = Ioi a \u2228 s = Iio a }\n#align order_topology OrderTopology\n-/\n\n#print Preorder.topology /-\n/-- (Order) topology on a partial order `\u03b1` generated by the subbase of open intervals\n`(a, \u221e) = { x \u2223 a < x }, (-\u221e , b) = {x \u2223 x < b}` for all `a, b` in `\u03b1`. 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 (\u03b1 : Type _) [Preorder \u03b1] : TopologicalSpace \u03b1 :=\n  generateFrom { s : Set \u03b1 | \u2203 a : \u03b1, s = { b : \u03b1 | a < b } \u2228 s = { b : \u03b1 | b < a } }\n#align preorder.topology Preorder.topology\n-/\n\nsection OrderTopology\n\nsection Preorder\n\nvariable [TopologicalSpace \u03b1] [Preorder \u03b1] [t : OrderTopology \u03b1]\n\ninclude t\n\ninstance : OrderTopology \u03b1\u1d52\u1d48 :=\n  \u27e8by\n    convert@OrderTopology.topology_eq_generate_intervals \u03b1 _ _ _ <;>\n        conv in _ \u2228 _ => rw [or_comm] <;>\n      rfl\u27e9\n\n#print isOpen_iff_generate_intervals /-\ntheorem isOpen_iff_generate_intervals {s : Set \u03b1} :\n    IsOpen s \u2194 GenerateOpen { s | \u2203 a, s = Ioi a \u2228 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 : \u03b1) : IsOpen { b : \u03b1 | a < b } := by\n  rw [@isOpen_iff_generate_intervals \u03b1 _ _ t] <;> exact generate_open.basic _ \u27e8a, Or.inl rfl\u27e9\n#align is_open_lt' isOpen_lt'\n-/\n\n#print isOpen_gt' /-\ntheorem isOpen_gt' (a : \u03b1) : IsOpen { b : \u03b1 | b < a } := by\n  rw [@isOpen_iff_generate_intervals \u03b1 _ _ t] <;> exact generate_open.basic _ \u27e8a, Or.inr rfl\u27e9\n#align is_open_gt' isOpen_gt'\n-/\n\n#print lt_mem_nhds /-\ntheorem lt_mem_nhds {a b : \u03b1} (h : a < b) : \u2200\u1da0 x in \ud835\udcdd 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 : \u03b1} (h : a < b) : \u2200\u1da0 x in \ud835\udcdd b, a \u2264 x :=\n  (\ud835\udcdd 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 : \u03b1} (h : a < b) : \u2200\u1da0 x in \ud835\udcdd 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 : \u03b1} (h : a < b) : \u2200\u1da0 x in \ud835\udcdd a, x \u2264 b :=\n  (\ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 a) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (b : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) b (Set.Iio.{u1} \u03b1 _inst_2 a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) b (Set.Iio.{u1} \u03b1 _inst_2 a)) => Filter.principal.{u1} \u03b1 (Set.Ioi.{u1} \u03b1 _inst_2 b)))) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (b : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) b (Set.Ioi.{u1} \u03b1 _inst_2 a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) b (Set.Ioi.{u1} \u03b1 _inst_2 a)) => Filter.principal.{u1} \u03b1 (Set.Iio.{u1} \u03b1 _inst_2 b)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 a) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (b : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) b (Set.Iio.{u1} \u03b1 _inst_2 a)) (fun (H : Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) b (Set.Iio.{u1} \u03b1 _inst_2 a)) => Filter.principal.{u1} \u03b1 (Set.Ioi.{u1} \u03b1 _inst_2 b)))) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (b : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) b (Set.Ioi.{u1} \u03b1 _inst_2 a)) (fun (H : Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) b (Set.Ioi.{u1} \u03b1 _inst_2 a)) => Filter.principal.{u1} \u03b1 (Set.Iio.{u1} \u03b1 _inst_2 b)))))\nCase conversion may be inaccurate. Consider using '#align nhds_eq_order nhds_eq_order\u2093'. -/\ntheorem nhds_eq_order (a : \u03b1) : \ud835\udcdd a = (\u2a05 b \u2208 Iio a, \ud835\udcdf (Ioi b)) \u2293 \u2a05 b \u2208 Ioi a, \ud835\udcdf (Iio b) := by\n  rw [t.topology_eq_generate_intervals, nhds_generate_from] <;>\n    exact\n      le_antisymm\n        (le_inf\n          (le_inf\u1d62\u2082 fun b hb => inf\u1d62_le_of_le { c : \u03b1 | b < c } <| inf\u1d62_le _ \u27e8hb, b, Or.inl rfl\u27e9)\n          (le_inf\u1d62\u2082 fun b hb => inf\u1d62_le_of_le { c : \u03b1 | c < b } <| inf\u1d62_le _ \u27e8hb, b, Or.inr rfl\u27e9))\n        (le_inf\u1d62 fun s =>\n          le_inf\u1d62 fun \u27e8ha, b, hs\u27e9 =>\n            match s, ha, hs with\n            | _, h, Or.inl rfl => inf_le_of_left_le <| inf\u1d62_le_of_le b <| inf\u1d62_le _ h\n            | _, h, Or.inr rfl => inf_le_of_right_le <| inf\u1d62_le_of_le b <| inf\u1d62_le _ h)\n#align nhds_eq_order nhds_eq_order\n\n#print tendsto_order /-\ntheorem tendsto_order {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {x : Filter \u03b2} :\n    Tendsto f x (\ud835\udcdd a) \u2194 (\u2200 a' < a, \u2200\u1da0 b in x, a' < f b) \u2227 \u2200 a' > a, \u2200\u1da0 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 : \u03b1) : TendstoIxxClass Icc (\ud835\udcdd a) (\ud835\udcdd a) :=\n  by\n  simp only [nhds_eq_order, inf\u1d62_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 : \u03b1) : TendstoIxxClass Ico (\ud835\udcdd a) (\ud835\udcdd 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 : \u03b1) : TendstoIxxClass Ioc (\ud835\udcdd a) (\ud835\udcdd 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 : \u03b1) : TendstoIxxClass Ioo (\ud835\udcdd a) (\ud835\udcdd 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 : \u03b2 \u2192 \u03b1} {b : Filter \u03b2} {a : \u03b1}\n    (hg : Tendsto g b (\ud835\udcdd a)) (hh : Tendsto h b (\ud835\udcdd a)) (hgf : \u2200\u1da0 b in b, g b \u2264 f b)\n    (hfh : \u2200\u1da0 b in b, f b \u2264 h b) : Tendsto f b (\ud835\udcdd 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 : \u03b2 \u2192 \u03b1} {b : Filter \u03b2} {a : \u03b1}\n    (hg : Tendsto g b (\ud835\udcdd a)) (hh : Tendsto h b (\ud835\udcdd a)) (hgf : g \u2264 f) (hfh : f \u2264 h) :\n    Tendsto f b (\ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] {a : \u03b1}, (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u)) -> (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a)) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 a) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) (fun (h\u2082 : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) => inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (u : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) (fun (h\u2082 : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) => Filter.principal.{u1} \u03b1 (Set.Ioo.{u1} \u03b1 _inst_2 l u)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [t : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] {a : \u03b1}, (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u)) -> (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a)) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 a) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) (fun (h\u2082 : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) => inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (u : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) (fun (h\u2082 : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) => Filter.principal.{u1} \u03b1 (Set.Ioo.{u1} \u03b1 _inst_2 l u)))))))\nCase conversion may be inaccurate. Consider using '#align nhds_order_unbounded nhds_order_unbounded\u2093'. -/\ntheorem nhds_order_unbounded {a : \u03b1} (hu : \u2203 u, a < u) (hl : \u2203 l, l < a) :\n    \ud835\udcdd a = \u2a05 (l) (h\u2082 : l < a) (u) (h\u2082 : a < u), \ud835\udcdf (Ioo l u) :=\n  by\n  have : \u2203 u, u \u2208 Ioi a := hu\n  have : \u2203 l, l \u2208 Iio a := hl\n  simp only [nhds_eq_order, inf_binf\u1d62, binf\u1d62_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 : \u03b2 \u2192 \u03b1} {a : \u03b1} {x : Filter \u03b2} (hu : \u2203 u, a < u)\n    (hl : \u2203 l, l < a) (h : \u2200 l u, l < a \u2192 a < u \u2192 \u2200\u1da0 b in x, l < f b \u2227 f b < u) :\n    Tendsto f x (\ud835\udcdd 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 {\u03b1 : Type _} [Preorder \u03b1] [TopologicalSpace \u03b1] (a : \u03b1) {s t : Set \u03b1}\n    {Ixx} [TendstoIxxClass Ixx (\ud835\udcdd a) (\ud835\udcdd a)] [TendstoIxxClass Ixx (\ud835\udcdf s) (\ud835\udcdf t)] :\n    TendstoIxxClass Ixx (\ud835\udcdd[s] a) (\ud835\udcdd[t] a) :=\n  Filter.tendstoIxxClass_inf\n#align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin\n-/\n\n#print tendstoIccClassNhdsPi /-\ninstance tendstoIccClassNhdsPi {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Preorder (\u03b1 i)]\n    [\u2200 i, TopologicalSpace (\u03b1 i)] [\u2200 i, OrderTopology (\u03b1 i)] (f : \u2200 i, \u03b1 i) :\n    TendstoIxxClass Icc (\ud835\udcdd f) (\ud835\udcdd f) := by\n  constructor\n  conv in (\ud835\udcdd f).smallSets => rw [nhds_pi, Filter.pi]\n  simp only [small_sets_infi, small_sets_comap, tendsto_infi, tendsto_lift', (\u00b7 \u2218 \u00b7),\n    mem_powerset_iff]\n  intro i s hs\n  have : tendsto (fun g : \u2200 i, \u03b1 i => g i) (\ud835\udcdd f) (\ud835\udcdd (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 \u27e8hg.1 _, hg.2 _\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [ta : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderTopology.{u2} \u03b2 ta _inst_2] (f : \u03b1 -> \u03b2), (forall {x : \u03b1} {y : \u03b1}, Iff (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 _inst_2) (f x) (f y)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_1) x y)) -> (forall {a : \u03b1} {x : \u03b2}, (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 _inst_2) x (f a)) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => Exists.{0} (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_1) b a) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_1) b a) => LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) x (f b))))) -> (forall {a : \u03b1} {x : \u03b2}, (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 _inst_2) (f a) x) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => Exists.{0} (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_1) b a) (fun (H : GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_1) b a) => LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) (f b) x)))) -> (OrderTopology.{u1} \u03b1 (TopologicalSpace.induced.{u1, u2} \u03b1 \u03b2 f ta) _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [ta : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderTopology.{u2} \u03b2 ta _inst_2] (f : \u03b1 -> \u03b2), (forall {x : \u03b1} {y : \u03b1}, Iff (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 _inst_2) (f x) (f y)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_1) x y)) -> (forall {a : \u03b1} {x : \u03b2}, (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 _inst_2) x (f a)) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_1) b a) (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) x (f b))))) -> (forall {a : \u03b1} {x : \u03b2}, (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 _inst_2) (f a) x) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_1) b a) (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) (f b) x)))) -> (OrderTopology.{u1} \u03b1 (TopologicalSpace.induced.{u1, u2} \u03b1 \u03b2 f ta) _inst_1)\nCase conversion may be inaccurate. Consider using '#align induced_order_topology' induced_orderTopology'\u2093'. -/\ntheorem induced_orderTopology' {\u03b1 : Type u} {\u03b2 : Type v} [Preorder \u03b1] [ta : TopologicalSpace \u03b2]\n    [Preorder \u03b2] [OrderTopology \u03b2] (f : \u03b1 \u2192 \u03b2) (hf : \u2200 {x y}, f x < f y \u2194 x < y)\n    (H\u2081 : \u2200 {a x}, x < f a \u2192 \u2203 b < a, x \u2264 f b) (H\u2082 : \u2200 {a x}, f a < x \u2192 \u2203 b > a, f b \u2264 x) :\n    @OrderTopology _ (induced f ta) _ :=\n  by\n  letI := induced f ta\n  refine' \u27e8eq_of_nhds_eq_nhds fun a => _\u27e9\n  rw [nhds_induced, nhds_generate_from, nhds_eq_order (f a)]\n  apply le_antisymm\n  \u00b7 refine' le_inf\u1d62 fun s => le_inf\u1d62 fun hs => le_principal_iff.2 _\n    rcases hs with \u27e8ab, b, rfl | rfl\u27e9\n    \u00b7\n      exact\n        mem_comap.2\n          \u27e8{ 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\u27e9\n    \u00b7\n      exact\n        mem_comap.2\n          \u27e8{ 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\u27e9\n  \u00b7 rw [\u2190 map_le_iff_le_comap]\n    refine' le_inf _ _ <;> refine' le_inf\u1d62 fun x => le_inf\u1d62 fun h => le_principal_iff.2 _ <;> simp\n    \u00b7 rcases H\u2081 h with \u27e8b, ab, xb\u27e9\n      refine' mem_infi_of_mem _ (mem_infi_of_mem \u27e8ab, b, Or.inl rfl\u27e9 (mem_principal.2 _))\n      exact fun c hc => lt_of_le_of_lt xb (hf.2 hc)\n    \u00b7 rcases H\u2082 h with \u27e8b, ab, xb\u27e9\n      refine' mem_infi_of_mem _ (mem_infi_of_mem \u27e8ab, b, Or.inr rfl\u27e9 (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 {\u03b1 : Type u} {\u03b2 : Type v} [Preorder \u03b1] [ta : TopologicalSpace \u03b2]\n    [Preorder \u03b2] [OrderTopology \u03b2] (f : \u03b1 \u2192 \u03b2) (hf : \u2200 {x y}, f x < f y \u2194 x < y)\n    (H : \u2200 {x y}, x < y \u2192 \u2203 a, x < f a \u2227 f a < y) : @OrderTopology _ (induced f ta) _ :=\n  induced_orderTopology' f (@hf)\n    (fun a x xa =>\n      let \u27e8b, xb, ba\u27e9 := H xa\n      \u27e8b, hf.1 ba, le_of_lt xb\u27e9)\n    fun a x ax =>\n    let \u27e8b, ab, bx\u27e9 := H ax\n    \u27e8b, hf.1 ab, le_of_lt bx\u27e9\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 {\u03b1 : Type u} [ta : TopologicalSpace \u03b1] [LinearOrder \u03b1]\n    [OrderTopology \u03b1] {t : Set \u03b1} [ht : OrdConnected t] : OrderTopology t :=\n  by\n  letI := induced (coe : t \u2192 \u03b1) ta\n  refine' \u27e8eq_of_nhds_eq_nhds fun a => _\u27e9\n  rw [nhds_induced, nhds_generate_from, nhds_eq_order (a : \u03b1)]\n  apply le_antisymm\n  \u00b7 refine' le_inf\u1d62 fun s => le_inf\u1d62 fun hs => le_principal_iff.2 _\n    rcases hs with \u27e8ab, b, rfl | rfl\u27e9\n    \u00b7 refine' \u27e8Ioi b, _, fun _ => id\u27e9\n      refine' mem_inf_of_left (mem_infi_of_mem b _)\n      exact mem_infi_of_mem ab (mem_principal_self (Ioi \u2191b))\n    \u00b7 refine' \u27e8Iio b, _, fun _ => id\u27e9\n      refine' mem_inf_of_right (mem_infi_of_mem b _)\n      exact mem_infi_of_mem ab (mem_principal_self (Iio b))\n  \u00b7 rw [\u2190 map_le_iff_le_comap]\n    refine' le_inf _ _\n    \u00b7 refine' le_inf\u1d62 fun x => le_inf\u1d62 fun h => le_principal_iff.2 _\n      by_cases hx : x \u2208 t\n      \u00b7 refine' mem_infi_of_mem (Ioi \u27e8x, hx\u27e9) (mem_infi_of_mem \u27e8h, \u27e8\u27e8x, hx\u27e9, Or.inl rfl\u27e9\u27e9 _)\n        exact fun _ => id\n      simp only [SetCoe.exists, mem_set_of_eq, mem_map']\n      convert univ_sets _\n      suffices hx' : \u2200 y : t, \u2191y \u2208 Ioi x\n      \u00b7 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 \u27e8le_of_not_gt hx, le_of_lt h\u27e9\n    \u00b7 refine' le_inf\u1d62 fun x => le_inf\u1d62 fun h => le_principal_iff.2 _\n      by_cases hx : x \u2208 t\n      \u00b7 refine' mem_infi_of_mem (Iio \u27e8x, hx\u27e9) (mem_infi_of_mem \u27e8h, \u27e8\u27e8x, hx\u27e9, Or.inr rfl\u27e9\u27e9 _)\n        exact fun _ => id\n      simp only [SetCoe.exists, mem_set_of_eq, mem_map']\n      convert univ_sets _\n      suffices hx' : \u2200 y : t, \u2191y \u2208 Iio x\n      \u00b7 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 \u27e8le_of_lt h, le_of_not_gt hx\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 _inst_2 a)) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (u : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) (fun (hu : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) => Filter.principal.{u1} \u03b1 (Set.Iio.{u1} \u03b1 _inst_2 u)))) (Filter.principal.{u1} \u03b1 (Set.Ici.{u1} \u03b1 _inst_2 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 _inst_2 a)) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (u : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) (fun (hu : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) => Filter.principal.{u1} \u03b1 (Set.Iio.{u1} \u03b1 _inst_2 u)))) (Filter.principal.{u1} \u03b1 (Set.Ici.{u1} \u03b1 _inst_2 a)))\nCase conversion may be inaccurate. Consider using '#align nhds_within_Ici_eq'' nhdsWithin_Ici_eq''\u2093'. -/\ntheorem nhdsWithin_Ici_eq'' [TopologicalSpace \u03b1] [Preorder \u03b1] [OrderTopology \u03b1] (a : \u03b1) :\n    \ud835\udcdd[\u2265] a = (\u2a05 (u) (hu : a < u), \ud835\udcdf (Iio u)) \u2293 \ud835\udcdf (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\u1d62\u2082 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 _inst_2 a)) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) => Filter.principal.{u1} \u03b1 (Set.Ioi.{u1} \u03b1 _inst_2 l)))) (Filter.principal.{u1} \u03b1 (Set.Iic.{u1} \u03b1 _inst_2 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 _inst_2 a)) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) => Filter.principal.{u1} \u03b1 (Set.Ioi.{u1} \u03b1 _inst_2 l)))) (Filter.principal.{u1} \u03b1 (Set.Iic.{u1} \u03b1 _inst_2 a)))\nCase conversion may be inaccurate. Consider using '#align nhds_within_Iic_eq'' nhdsWithin_Iic_eq''\u2093'. -/\ntheorem nhdsWithin_Iic_eq'' [TopologicalSpace \u03b1] [Preorder \u03b1] [OrderTopology \u03b1] (a : \u03b1) :\n    \ud835\udcdd[\u2264] a = (\u2a05 l < a, \ud835\udcdf (Ioi l)) \u2293 \ud835\udcdf (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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] {a : \u03b1}, (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u)) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 _inst_2 a)) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (u : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) (fun (hu : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) => Filter.principal.{u1} \u03b1 (Set.Ico.{u1} \u03b1 _inst_2 a u)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] {a : \u03b1}, (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u)) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 _inst_2 a)) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (u : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) (fun (hu : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a u) => Filter.principal.{u1} \u03b1 (Set.Ico.{u1} \u03b1 _inst_2 a u)))))\nCase conversion may be inaccurate. Consider using '#align nhds_within_Ici_eq' nhdsWithin_Ici_eq'\u2093'. -/\ntheorem nhdsWithin_Ici_eq' [TopologicalSpace \u03b1] [Preorder \u03b1] [OrderTopology \u03b1] {a : \u03b1}\n    (ha : \u2203 u, a < u) : \ud835\udcdd[\u2265] a = \u2a05 (u) (hu : a < u), \ud835\udcdf (Ico a u) := by\n  simp only [nhdsWithin_Ici_eq'', binf\u1d62_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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] {a : \u03b1}, (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a)) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 _inst_2 a)) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) => Filter.principal.{u1} \u03b1 (Set.Ioc.{u1} \u03b1 _inst_2 l a)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2] {a : \u03b1}, (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a)) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 _inst_2 a)) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l a) => Filter.principal.{u1} \u03b1 (Set.Ioc.{u1} \u03b1 _inst_2 l a)))))\nCase conversion may be inaccurate. Consider using '#align nhds_within_Iic_eq' nhdsWithin_Iic_eq'\u2093'. -/\ntheorem nhdsWithin_Iic_eq' [TopologicalSpace \u03b1] [Preorder \u03b1] [OrderTopology \u03b1] {a : \u03b1}\n    (ha : \u2203 l, l < a) : \ud835\udcdd[\u2264] a = \u2a05 l < a, \ud835\udcdf (Ioc l a) := by\n  simp only [nhdsWithin_Iic_eq'', binf\u1d62_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 \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] {a : \u03b1}\n    (ha : \u2203 u, a < u) : (\ud835\udcdd[\u2265] a).HasBasis (fun u => a < u) fun u => Ico a u :=\n  (nhdsWithin_Ici_eq' ha).symm \u25b8\n    hasBasis_binf\u1d62_principal\n      (fun b hb c hc =>\n        \u27e8min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _),\n          Ico_subset_Ico_right (min_le_right _ _)\u27e9)\n      ha\n#align nhds_within_Ici_basis' nhdsWithin_Ici_basis'\n-/\n\n#print nhdsWithin_Iic_basis' /-\ntheorem nhdsWithin_Iic_basis' [TopologicalSpace \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] {a : \u03b1}\n    (ha : \u2203 l, l < a) : (\ud835\udcdd[\u2264] a).HasBasis (fun l => l < a) fun l => Ioc l a :=\n  by\n  convert@nhdsWithin_Ici_basis' \u03b1\u1d52\u1d48 _ _ _ (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 \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [NoMaxOrder \u03b1]\n    (a : \u03b1) : (\ud835\udcdd[\u2265] 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 \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [NoMinOrder \u03b1]\n    (a : \u03b1) : (\ud835\udcdd[\u2264] 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2)] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 (Top.top.{u1} \u03b1 (OrderTop.toHasTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3))) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l (Top.top.{u1} \u03b1 (OrderTop.toHasTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3))) (fun (h\u2082 : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l (Top.top.{u1} \u03b1 (OrderTop.toHasTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3))) => Filter.principal.{u1} \u03b1 (Set.Ioi.{u1} \u03b1 _inst_2 l))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2)] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 (Top.top.{u1} \u03b1 (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3))) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l (Top.top.{u1} \u03b1 (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3))) (fun (h\u2082 : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) l (Top.top.{u1} \u03b1 (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3))) => Filter.principal.{u1} \u03b1 (Set.Ioi.{u1} \u03b1 _inst_2 l))))\nCase conversion may be inaccurate. Consider using '#align nhds_top_order nhds_top_order\u2093'. -/\ntheorem nhds_top_order [TopologicalSpace \u03b1] [Preorder \u03b1] [OrderTop \u03b1] [OrderTopology \u03b1] :\n    \ud835\udcdd (\u22a4 : \u03b1) = \u2a05 (l) (h\u2082 : l < \u22a4), \ud835\udcdf (Ioi l) := by simp [nhds_eq_order (\u22a4 : \u03b1)]\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2)] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 (Bot.bot.{u1} \u03b1 (OrderBot.toHasBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3))) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) (Bot.bot.{u1} \u03b1 (OrderBot.toHasBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3)) l) (fun (h\u2082 : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) (Bot.bot.{u1} \u03b1 (OrderBot.toHasBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3)) l) => Filter.principal.{u1} \u03b1 (Set.Iio.{u1} \u03b1 _inst_2 l))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : OrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2)] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 (Bot.bot.{u1} \u03b1 (OrderBot.toBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3))) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (l : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) (Bot.bot.{u1} \u03b1 (OrderBot.toBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3)) l) (fun (h\u2082 : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) (Bot.bot.{u1} \u03b1 (OrderBot.toBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) _inst_3)) l) => Filter.principal.{u1} \u03b1 (Set.Iio.{u1} \u03b1 _inst_2 l))))\nCase conversion may be inaccurate. Consider using '#align nhds_bot_order nhds_bot_order\u2093'. -/\ntheorem nhds_bot_order [TopologicalSpace \u03b1] [Preorder \u03b1] [OrderBot \u03b1] [OrderTopology \u03b1] :\n    \ud835\udcdd (\u22a5 : \u03b1) = \u2a05 (l) (h\u2082 : \u22a5 < l), \ud835\udcdf (Iio l) := by simp [nhds_eq_order (\u22a5 : \u03b1)]\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_5 : Nontrivial.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (Top.top.{u1} \u03b1 (OrderTop.toHasTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) _inst_3))) (fun (a : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a (Top.top.{u1} \u03b1 (OrderTop.toHasTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) _inst_3))) (fun (a : \u03b1) => Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : Nontrivial.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (Top.top.{u1} \u03b1 (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) _inst_3))) (fun (a : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a (Top.top.{u1} \u03b1 (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) _inst_3))) (fun (a : \u03b1) => Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)\nCase conversion may be inaccurate. Consider using '#align nhds_top_basis nhds_top_basis\u2093'. -/\ntheorem nhds_top_basis [TopologicalSpace \u03b1] [LinearOrder \u03b1] [OrderTop \u03b1] [OrderTopology \u03b1]\n    [Nontrivial \u03b1] : (\ud835\udcdd \u22a4).HasBasis (fun a : \u03b1 => a < \u22a4) fun a : \u03b1 => Ioi a :=\n  by\n  have : \u2203 x : \u03b1, x < \u22a4 := (exists_ne \u22a4).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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_5 : Nontrivial.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (Bot.bot.{u1} \u03b1 (OrderBot.toHasBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) _inst_3))) (fun (a : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (Bot.bot.{u1} \u03b1 (OrderBot.toHasBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) _inst_3)) a) (fun (a : \u03b1) => Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : Nontrivial.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (Bot.bot.{u1} \u03b1 (OrderBot.toBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) _inst_3))) (fun (a : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) (Bot.bot.{u1} \u03b1 (OrderBot.toBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) _inst_3)) a) (fun (a : \u03b1) => Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)\nCase conversion may be inaccurate. Consider using '#align nhds_bot_basis nhds_bot_basis\u2093'. -/\ntheorem nhds_bot_basis [TopologicalSpace \u03b1] [LinearOrder \u03b1] [OrderBot \u03b1] [OrderTopology \u03b1]\n    [Nontrivial \u03b1] : (\ud835\udcdd \u22a5).HasBasis (fun a : \u03b1 => \u22a5 < a) fun a : \u03b1 => Iio a :=\n  @nhds_top_basis \u03b1\u1d52\u1d48 _ _ _ _ _\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_5 : Nontrivial.{u1} \u03b1] [_inst_6 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (Top.top.{u1} \u03b1 (OrderTop.toHasTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) _inst_3))) (fun (a : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a (Top.top.{u1} \u03b1 (OrderTop.toHasTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) _inst_3))) (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : Nontrivial.{u1} \u03b1] [_inst_6 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (Top.top.{u1} \u03b1 (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) _inst_3))) (fun (a : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a (Top.top.{u1} \u03b1 (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) _inst_3))) (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align nhds_top_basis_Ici nhds_top_basis_Ici\u2093'. -/\ntheorem nhds_top_basis_Ici [TopologicalSpace \u03b1] [LinearOrder \u03b1] [OrderTop \u03b1] [OrderTopology \u03b1]\n    [Nontrivial \u03b1] [DenselyOrdered \u03b1] : (\ud835\udcdd \u22a4).HasBasis (fun a : \u03b1 => a < \u22a4) Ici :=\n  nhds_top_basis.to_hasBasis\n    (fun a ha =>\n      let \u27e8b, hab, hb\u27e9 := exists_between ha\n      \u27e8b, hb, Ici_subset_Ioi.mpr hab\u27e9)\n    fun a ha => \u27e8a, ha, Ioi_subset_Ici_self\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_5 : Nontrivial.{u1} \u03b1] [_inst_6 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (Bot.bot.{u1} \u03b1 (OrderBot.toHasBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) _inst_3))) (fun (a : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (Bot.bot.{u1} \u03b1 (OrderBot.toHasBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) _inst_3)) a) (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : Nontrivial.{u1} \u03b1] [_inst_6 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (Bot.bot.{u1} \u03b1 (OrderBot.toBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) _inst_3))) (fun (a : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) (Bot.bot.{u1} \u03b1 (OrderBot.toBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) _inst_3)) a) (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align nhds_bot_basis_Iic nhds_bot_basis_Iic\u2093'. -/\ntheorem nhds_bot_basis_Iic [TopologicalSpace \u03b1] [LinearOrder \u03b1] [OrderBot \u03b1] [OrderTopology \u03b1]\n    [Nontrivial \u03b1] [DenselyOrdered \u03b1] : (\ud835\udcdd \u22a5).HasBasis (fun a : \u03b1 => \u22a5 < a) Iic :=\n  @nhds_top_basis_Ici \u03b1\u1d52\u1d48 _ _ _ _ _ _\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)] [_inst_4 : OrderTopology.{u2} \u03b2 _inst_1 _inst_2] {l : Filter.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 _inst_1 (Top.top.{u2} \u03b2 (OrderTop.toHasTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3)))) -> (Filter.EventuallyLE.{u1, u2} \u03b1 \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) l f g) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 _inst_1 (Top.top.{u2} \u03b2 (OrderTop.toHasTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)] [_inst_4 : OrderTopology.{u2} \u03b2 _inst_1 _inst_2] {l : Filter.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 _inst_1 (Top.top.{u2} \u03b2 (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3)))) -> (Filter.EventuallyLE.{u1, u2} \u03b1 \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) l f g) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 _inst_1 (Top.top.{u2} \u03b2 (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align tendsto_nhds_top_mono tendsto_nhds_top_mono\u2093'. -/\ntheorem tendsto_nhds_top_mono [TopologicalSpace \u03b2] [Preorder \u03b2] [OrderTop \u03b2] [OrderTopology \u03b2]\n    {l : Filter \u03b1} {f g : \u03b1 \u2192 \u03b2} (hf : Tendsto f l (\ud835\udcdd \u22a4)) (hg : f \u2264\u1da0[l] g) : Tendsto g l (\ud835\udcdd \u22a4) :=\n  by\n  simp only [nhds_top_order, tendsto_infi, tendsto_principal] at hf\u22a2\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)] [_inst_4 : OrderTopology.{u2} \u03b2 _inst_1 _inst_2] {l : Filter.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 _inst_1 (Bot.bot.{u2} \u03b2 (OrderBot.toHasBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3)))) -> (Filter.EventuallyLE.{u1, u2} \u03b1 \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) l g f) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 _inst_1 (Bot.bot.{u2} \u03b2 (OrderBot.toHasBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)] [_inst_4 : OrderTopology.{u2} \u03b2 _inst_1 _inst_2] {l : Filter.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 _inst_1 (Bot.bot.{u2} \u03b2 (OrderBot.toBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3)))) -> (Filter.EventuallyLE.{u1, u2} \u03b1 \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) l g f) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 _inst_1 (Bot.bot.{u2} \u03b2 (OrderBot.toBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align tendsto_nhds_bot_mono tendsto_nhds_bot_mono\u2093'. -/\ntheorem tendsto_nhds_bot_mono [TopologicalSpace \u03b2] [Preorder \u03b2] [OrderBot \u03b2] [OrderTopology \u03b2]\n    {l : Filter \u03b1} {f g : \u03b1 \u2192 \u03b2} (hf : Tendsto f l (\ud835\udcdd \u22a5)) (hg : g \u2264\u1da0[l] f) : Tendsto g l (\ud835\udcdd \u22a5) :=\n  @tendsto_nhds_top_mono \u03b1 \u03b2\u1d52\u1d48 _ _ _ _ _ _ _ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)] [_inst_4 : OrderTopology.{u2} \u03b2 _inst_1 _inst_2] {l : Filter.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 _inst_1 (Top.top.{u2} \u03b2 (OrderTop.toHasTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3)))) -> (LE.le.{max u1 u2} (\u03b1 -> \u03b2) (Pi.hasLe.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (i : \u03b1) => Preorder.toLE.{u2} \u03b2 _inst_2)) f g) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 _inst_1 (Top.top.{u2} \u03b2 (OrderTop.toHasTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)] [_inst_4 : OrderTopology.{u2} \u03b2 _inst_1 _inst_2] {l : Filter.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 _inst_1 (Top.top.{u2} \u03b2 (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3)))) -> (LE.le.{max u1 u2} (\u03b1 -> \u03b2) (Pi.hasLe.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (i : \u03b1) => Preorder.toLE.{u2} \u03b2 _inst_2)) f g) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 _inst_1 (Top.top.{u2} \u03b2 (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align tendsto_nhds_top_mono' tendsto_nhds_top_mono'\u2093'. -/\ntheorem tendsto_nhds_top_mono' [TopologicalSpace \u03b2] [Preorder \u03b2] [OrderTop \u03b2] [OrderTopology \u03b2]\n    {l : Filter \u03b1} {f g : \u03b1 \u2192 \u03b2} (hf : Tendsto f l (\ud835\udcdd \u22a4)) (hg : f \u2264 g) : Tendsto g l (\ud835\udcdd \u22a4) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)] [_inst_4 : OrderTopology.{u2} \u03b2 _inst_1 _inst_2] {l : Filter.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 _inst_1 (Bot.bot.{u2} \u03b2 (OrderBot.toHasBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3)))) -> (LE.le.{max u1 u2} (\u03b1 -> \u03b2) (Pi.hasLe.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (i : \u03b1) => Preorder.toLE.{u2} \u03b2 _inst_2)) g f) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 _inst_1 (Bot.bot.{u2} \u03b2 (OrderBot.toHasBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b2] [_inst_2 : Preorder.{u2} \u03b2] [_inst_3 : OrderBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)] [_inst_4 : OrderTopology.{u2} \u03b2 _inst_1 _inst_2] {l : Filter.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 _inst_1 (Bot.bot.{u2} \u03b2 (OrderBot.toBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3)))) -> (LE.le.{max u1 u2} (\u03b1 -> \u03b2) (Pi.hasLe.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (i : \u03b1) => Preorder.toLE.{u2} \u03b2 _inst_2)) g f) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 _inst_1 (Bot.bot.{u2} \u03b2 (OrderBot.toBot.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) _inst_3))))\nCase conversion may be inaccurate. Consider using '#align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono'\u2093'. -/\ntheorem tendsto_nhds_bot_mono' [TopologicalSpace \u03b2] [Preorder \u03b2] [OrderBot \u03b2] [OrderTopology \u03b2]\n    {l : Filter \u03b1} {f g : \u03b1 \u2192 \u03b2} (hf : Tendsto f l (\ud835\udcdd \u22a5)) (hg : g \u2264 f) : Tendsto g l (\ud835\udcdd \u22a5) :=\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 \u03b1] [LinearOrder \u03b1]\n\nsection OrderClosedTopology\n\nvariable [OrderClosedTopology \u03b1] {a b : \u03b1}\n\n#print eventually_le_nhds /-\ntheorem eventually_le_nhds (hab : a < b) : \u2200\u1da0 x in \ud835\udcdd a, x \u2264 b :=\n  eventually_iff.mpr (mem_nhds_iff.mpr \u27e8Iio b, Iio_subset_Iic_self, isOpen_Iio, hab\u27e9)\n#align eventually_le_nhds eventually_le_nhds\n-/\n\n#print eventually_lt_nhds /-\ntheorem eventually_lt_nhds (hab : a < b) : \u2200\u1da0 x in \ud835\udcdd a, x < b :=\n  eventually_iff.mpr (mem_nhds_iff.mpr \u27e8Iio b, rfl.Subset, isOpen_Iio, hab\u27e9)\n#align eventually_lt_nhds eventually_lt_nhds\n-/\n\n#print eventually_ge_nhds /-\ntheorem eventually_ge_nhds (hab : b < a) : \u2200\u1da0 x in \ud835\udcdd a, b \u2264 x :=\n  eventually_iff.mpr (mem_nhds_iff.mpr \u27e8Ioi b, Ioi_subset_Ici_self, isOpen_Ioi, hab\u27e9)\n#align eventually_ge_nhds eventually_ge_nhds\n-/\n\n#print eventually_gt_nhds /-\ntheorem eventually_gt_nhds (hab : b < a) : \u2200\u1da0 x in \ud835\udcdd a, b < x :=\n  eventually_iff.mpr (mem_nhds_iff.mpr \u27e8Ioi b, rfl.Subset, isOpen_Ioi, hab\u27e9)\n#align eventually_gt_nhds eventually_gt_nhds\n-/\n\nend OrderClosedTopology\n\nsection OrderTopology\n\nvariable [OrderTopology \u03b1]\n\n#print order_separated /-\ntheorem order_separated {a\u2081 a\u2082 : \u03b1} (h : a\u2081 < a\u2082) :\n    \u2203 u v : Set \u03b1, IsOpen u \u2227 IsOpen v \u2227 a\u2081 \u2208 u \u2227 a\u2082 \u2208 v \u2227 \u2200 b\u2081 \u2208 u, \u2200 b\u2082 \u2208 v, b\u2081 < b\u2082 :=\n  match dense_or_discrete a\u2081 a\u2082 with\n  | Or.inl \u27e8a, ha\u2081, ha\u2082\u27e9 =>\n    \u27e8{ a' | a' < a }, { a' | a < a' }, isOpen_gt' a, isOpen_lt' a, ha\u2081, ha\u2082, fun b\u2081 h\u2081 b\u2082 h\u2082 =>\n      lt_trans h\u2081 h\u2082\u27e9\n  | Or.inr \u27e8h\u2081, h\u2082\u27e9 =>\n    \u27e8{ a | a < a\u2082 }, { a | a\u2081 < a }, isOpen_gt' a\u2082, isOpen_lt' a\u2081, h, h, fun b\u2081 hb\u2081 b\u2082 hb\u2082 =>\n      calc\n        b\u2081 \u2264 a\u2081 := h\u2082 _ hb\u2081\n        _ < a\u2082 := h\n        _ \u2264 b\u2082 := h\u2081 _ hb\u2082\n        \u27e9\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 \u03b1\n    where isClosed_le' :=\n    isOpen_compl_iff.1 <|\n      isOpen_prod_iff.mpr fun a\u2081 a\u2082 (h : \u00aca\u2081 \u2264 a\u2082) =>\n        have h : a\u2082 < a\u2081 := lt_of_not_ge h\n        let \u27e8u, v, hu, hv, ha\u2081, ha\u2082, h\u27e9 := order_separated h\n        \u27e8v, u, hv, hu, ha\u2082, ha\u2081, fun \u27e8b\u2081, b\u2082\u27e9 \u27e8h\u2081, h\u2082\u27e9 => not_le_of_gt <| h b\u2082 h\u2082 b\u2081 h\u2081\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 _inst_1 a)) -> (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) l a)) -> (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) l a) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) l a) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhds.{u1} \u03b1 _inst_1 a)) -> (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) l a)) -> (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) l a) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\ntheorem exists_Ioc_subset_of_mem_nhds {a : \u03b1} {s : Set \u03b1} (hs : s \u2208 \ud835\udcdd a) (h : \u2203 l, l < a) :\n    \u2203 l < a, Ioc l a \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 _inst_1 a)) -> (forall {l : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) l a) -> (Exists.{succ u1} \u03b1 (fun (l' : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l' (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l' (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l' a) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhds.{u1} \u03b1 _inst_1 a)) -> (forall {l : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) l a) -> (Exists.{succ u1} \u03b1 (fun (l' : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l' (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) l a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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'\u2093'. -/\ntheorem exists_Ioc_subset_of_mem_nhds' {a : \u03b1} {s : Set \u03b1} (hs : s \u2208 \ud835\udcdd a) {l : \u03b1} (hl : l < a) :\n    \u2203 l' \u2208 Ico l a, Ioc l' a \u2286 s :=\n  let \u27e8l', hl'a, hl's\u27e9 := exists_Ioc_subset_of_mem_nhds hs \u27e8l, hl\u27e9\n  \u27e8max l l', \u27e8le_max_left _ _, max_lt hl hl'a\u27e9,\n    (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 _inst_1 a)) -> (forall {u : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a u) -> (Exists.{succ u1} \u03b1 (fun (u' : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u' (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u' (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u') s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhds.{u1} \u03b1 _inst_1 a)) -> (forall {u : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a u) -> (Exists.{succ u1} \u03b1 (fun (u' : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u' (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a u)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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'\u2093'. -/\ntheorem exists_Ico_subset_of_mem_nhds' {a : \u03b1} {s : Set \u03b1} (hs : s \u2208 \ud835\udcdd a) {u : \u03b1} (hu : a < u) :\n    \u2203 u' \u2208 Ioc a u, Ico a u' \u2286 s := by\n  simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using\n    exists_Ioc_subset_of_mem_nhds' (show of_dual \u207b\u00b9' s \u2208 \ud835\udcdd (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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 _inst_1 a)) -> (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a u)) -> (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a u) (fun (_x : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a u) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhds.{u1} \u03b1 _inst_1 a)) -> (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a u)) -> (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a u) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\ntheorem exists_Ico_subset_of_mem_nhds {a : \u03b1} {s : Set \u03b1} (hs : s \u2208 \ud835\udcdd a) (h : \u2203 u, a < u) :\n    \u2203 (u : _)(_ : a < u), Ico a u \u2286 s :=\n  let \u27e8l', hl'\u27e9 := h\n  let \u27e8l, hl\u27e9 := exists_Ico_subset_of_mem_nhds' hs hl'\n  \u27e8l, hl.fst.1, hl.snd\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => Exists.{0} (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) (fun (_x : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) => And (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) (And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\ntheorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : \u03b1} {s : Set \u03b1} (hs : s \u2208 \ud835\udcdd[\u2265] a) :\n    \u2203 (b : _)(_ : a \u2264 b), Icc a b \u2208 \ud835\udcdd[\u2265] a \u2227 Icc a b \u2286 s :=\n  by\n  rcases(em (IsMax a)).imp_right not_is_max_iff.mp with (ha | ha)\n  \u00b7 use a\n    simpa [ha.Ici_eq] using hs\n  \u00b7 rcases(nhdsWithin_Ici_basis' ha).mem_iff.mp hs with \u27e8b, hab, hbs\u27e9\n    rcases eq_empty_or_nonempty (Ioo a b) with (H | \u27e8c, hac, hcb\u27e9)\n    \u00b7 have : Ico a b = Icc a a := by rw [\u2190 Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty]\n      exact \u27e8a, le_rfl, this \u25b8 \u27e8Ico_mem_nhdsWithin_Ici <| left_mem_Ico.2 hab, hbs\u27e9\u27e9\n    \u00b7 refine' \u27e8c, hac.le, Icc_mem_nhdsWithin_Ici <| left_mem_Ico.mpr hac, _\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => Exists.{0} (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) (fun (H : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) => And (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b a) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b a) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) b a) (And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b a) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\ntheorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : \u03b1} {s : Set \u03b1} (hs : s \u2208 \ud835\udcdd[\u2264] a) :\n    \u2203 b \u2264 a, Icc b a \u2208 \ud835\udcdd[\u2264] a \u2227 Icc b a \u2286 s := by\n  simpa only [dual_Icc, to_dual.surjective.exists] using\n    @exists_Icc_mem_subset_of_mem_nhdsWithin_Ici \u03b1\u1d52\u1d48 _ _ _ (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 : \u03b1} {s : Set \u03b1} (hs : s \u2208 \ud835\udcdd a) :\n    \u2203 b c, a \u2208 Icc b c \u2227 Icc b c \u2208 \ud835\udcdd a \u2227 Icc b c \u2286 s :=\n  by\n  rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with\n    \u27e8b, hba, hb_nhds, hbs\u27e9\n  rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with\n    \u27e8c, hac, hc_nhds, hcs\u27e9\n  refine' \u27e8b, c, \u27e8hba, hac\u27e9, _\u27e9\n  rw [\u2190 Icc_union_Icc_eq_Icc hba hac, \u2190 nhds_left_sup_nhds_right]\n  exact \u27e8union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs\u27e9\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 \u03b1] {s : Set \u03b1} (hs : IsOpen s) (h : s.Nonempty) :\n    \u2203 a b, a < b \u2227 Ioo a b \u2286 s :=\n  by\n  obtain \u27e8x, hx\u27e9 : \u2203 x, x \u2208 s := h\n  obtain \u27e8y, hy\u27e9 : \u2203 y, y \u2260 x := exists_ne x\n  rcases lt_trichotomy x y with (H | rfl | H)\n  \u00b7 obtain \u27e8u, xu, hu\u27e9 : \u2203 (u : \u03b1)(hu : x < u), Ico x u \u2286 s :=\n      exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) \u27e8y, H\u27e9\n    exact \u27e8x, u, xu, Ioo_subset_Ico_self.trans hu\u27e9\n  \u00b7 exact (hy rfl).elim\n  \u00b7 obtain \u27e8l, lx, hl\u27e9 : \u2203 (l : \u03b1)(hl : l < x), Ioc l x \u2286 s :=\n      exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) \u27e8y, H\u27e9\n    exact \u27e8l, x, lx, Ioo_subset_Ioc_self.trans hl\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : Nontrivial.{u1} \u03b1] {s : Set.{u1} \u03b1}, (forall {{a : \u03b1}} {{b : \u03b1}}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) -> (Exists.{succ u1} \u03b1 (fun (c : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) c s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) c s) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) c b))))) -> (Dense.{u1} \u03b1 _inst_1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : Nontrivial.{u1} \u03b1] {s : Set.{u1} \u03b1}, (forall {{a : \u03b1}} {{b : \u03b1}}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) -> (Exists.{succ u1} \u03b1 (fun (c : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) c s) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) c b))))) -> (Dense.{u1} \u03b1 _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align dense_of_exists_between dense_of_exists_between\u2093'. -/\ntheorem dense_of_exists_between [Nontrivial \u03b1] {s : Set \u03b1}\n    (h : \u2200 \u2983a b\u2984, a < b \u2192 \u2203 c \u2208 s, a < c \u2227 c < b) : Dense s :=\n  by\n  apply dense_iff_inter_open.2 fun U U_open U_nonempty => _\n  obtain \u27e8a, b, hab, H\u27e9 : \u2203 a b : \u03b1, a < b \u2227 Ioo a b \u2286 U := U_open.exists_Ioo_subset U_nonempty\n  obtain \u27e8x, xs, hx\u27e9 : \u2203 (x : \u03b1)(H : x \u2208 s), a < x \u2227 x < b := h hab\n  exact \u27e8x, \u27e8H hx, xs\u27e9\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : Nontrivial.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (Dense.{u1} \u03b1 _inst_1 s) (forall (a : \u03b1) (b : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) -> (Exists.{succ u1} \u03b1 (fun (c : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) c s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) c s) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) c b)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_5 : Nontrivial.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (Dense.{u1} \u03b1 _inst_1 s) (forall (a : \u03b1) (b : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) -> (Exists.{succ u1} \u03b1 (fun (c : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) c s) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) c b)))))\nCase conversion may be inaccurate. Consider using '#align dense_iff_exists_between dense_iff_exists_between\u2093'. -/\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 \u2208 s`, `a < c < b`. Each implication requires less typeclass\nassumptions. -/\ntheorem dense_iff_exists_between [DenselyOrdered \u03b1] [Nontrivial \u03b1] {s : Set \u03b1} :\n    Dense s \u2194 \u2200 a b, a < b \u2192 \u2203 c \u2208 s, a < c \u2227 c < b :=\n  \u27e8fun h a b hab => h.exists_between hab, dense_of_exists_between\u27e9\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 : \u03b1} {s : Set \u03b1} (hl : \u2203 l, l < a) (hu : \u2203 u, a < u) :\n    s \u2208 \ud835\udcdd a \u2194 \u2203 l u, a \u2208 Ioo l u \u2227 Ioo l u \u2286 s :=\n  by\n  constructor\n  \u00b7 intro h\n    rcases exists_Ico_subset_of_mem_nhds h hu with \u27e8u, au, hu\u27e9\n    rcases exists_Ioc_subset_of_mem_nhds h hl with \u27e8l, la, hl\u27e9\n    exact \u27e8l, u, \u27e8la, au\u27e9, Ioc_union_Ico_eq_Ioo la au \u25b8 union_subset hl hu\u27e9\n  \u00b7 rintro \u27e8l, u, ha, h\u27e9\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 \u03b1] [NoMinOrder \u03b1] {a : \u03b1} {s : Set \u03b1} :\n    s \u2208 \ud835\udcdd a \u2194 \u2203 l u, a \u2208 Ioo l u \u2227 Ioo l u \u2286 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 : \u03b1} (hl : \u2203 l, l < a) (hu : \u2203 u, a < u) :\n    (\ud835\udcdd a).HasBasis (fun b : \u03b1 \u00d7 \u03b1 => b.1 < a \u2227 a < b.2) fun b => Ioo b.1 b.2 :=\n  \u27e8fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp\u27e9\n#align nhds_basis_Ioo' nhds_basis_Ioo'\n-/\n\n#print nhds_basis_Ioo /-\ntheorem nhds_basis_Ioo [NoMaxOrder \u03b1] [NoMinOrder \u03b1] (a : \u03b1) :\n    (\ud835\udcdd a).HasBasis (fun b : \u03b1 \u00d7 \u03b1 => b.1 < a \u2227 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 \u03b1] [NoMinOrder \u03b1] {a : \u03b1} {p : \u03b1 \u2192 Prop}\n    (hp : \u2200\u1da0 x in \ud835\udcdd a, p x) : \u2203 l u, a \u2208 Ioo l u \u2227 Ioo l u \u2286 { 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 \u03b1] :\n    Set.Countable { x : \u03b1 | \u2203 y, x < y \u2227 Ioo x y = \u2205 } :=\n  by\n  nontriviality \u03b1\n  let s := { x : \u03b1 | \u2203 y, x < y \u2227 Ioo x y = \u2205 }\n  have : \u2200 x \u2208 s, \u2203 y, x < y \u2227 Ioo x y = \u2205 := fun x => id\n  choose! y hy h'y using this\n  have Hy : \u2200 x z, x \u2208 s \u2192 z < y x \u2192 z \u2264 x :=\n    by\n    intro x z xs hz\n    have A : Ioo x (y x) = \u2205 := h'y _ xs\n    contrapose! A\n    exact nonempty.ne_empty \u27e8z, A, hz\u27e9\n  suffices H : \u2200 a : Set \u03b1, IsOpen a \u2192 Set.Countable { x | x \u2208 s \u2227 x \u2208 a \u2227 y x \u2209 a }\n  \u00b7 have : s \u2286 \u22c3 a \u2208 countable_basis \u03b1, { x | x \u2208 s \u2227 x \u2208 a \u2227 y x \u2209 a } :=\n      by\n      intro x hx\n      rcases(is_basis_countable_basis \u03b1).exists_mem_of_ne (hy x hx).Ne with \u27e8a, ab, xa, ya\u27e9\n      simp only [mem_set_of_eq, mem_Union]\n      exact \u27e8a, ab, hx, xa, ya\u27e9\n    apply countable.mono this\n    refine' countable.bUnion (countable_countable_basis \u03b1) fun a ha => H _ _\n    exact is_open_of_mem_countable_basis ha\n  intro a ha\n  suffices H : Set.Countable { x | x \u2208 s \u2227 x \u2208 a \u2227 y x \u2209 a \u2227 \u00acIsBot x }\n  \u00b7 have :\n      { x | x \u2208 s \u2227 x \u2208 a \u2227 y x \u2209 a } \u2286\n        { x | x \u2208 s \u2227 x \u2208 a \u2227 y x \u2209 a \u2227 \u00acIsBot x } \u222a { x | IsBot x } :=\n      by\n      intro x hx\n      by_cases h'x : IsBot x\n      \u00b7 simp only [h'x, mem_set_of_eq, mem_union, not_true, and_false_iff, false_or_iff]\n      \u00b7\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 \u03b1).Countable)\n  let t := { x | x \u2208 s \u2227 x \u2208 a \u2227 y x \u2209 a \u2227 \u00acIsBot x }\n  have : \u2200 x \u2208 t, \u2203 z < x, Ioc z x \u2286 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    \u00b7 refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _\n      refine' h'z x' x't \u27e8ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _\u27e9\n      by_contra' H\n      exact False.elim (lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h'))\n    \u00b7 refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _\n      refine' h'z x xt \u27e8ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _\u27e9\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 => \u27e8x, hz x hx, le_rfl\u27e9\n  suffices H : Ioc (z x) x = Ioo (z x) (y x)\n  \u00b7 rw [H]\n    exact isOpen_Ioo\n  exact subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1)) fun u hu => \u27e8hu.1, Hy _ _ hx.1 hu.2\u27e9\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 \u03b1] :\n    Set.Countable { x : \u03b1 | \u2203 y, y < x \u2227 Ioo y x = \u2205 } :=\n  by\n  convert@countable_of_isolated_right' \u03b1\u1d52\u1d48 _ _ _ _\n  have : \u2200 x y : \u03b1, Ioo x y = { z | z < y \u2227 x < z } :=\n    by\n    simp_rw [and_comm', Ioo]\n    simp only [eq_self_iff_true, forall\u2082_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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : TopologicalSpace.SecondCountableTopology.{u1} \u03b1 _inst_1] {y : \u03b1 -> \u03b1} {s : Set.{u1} \u03b1}, (Set.PairwiseDisjoint.{u1, u1} (Set.{u1} \u03b1) \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) s (fun (x : \u03b1) => Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) x (y x))) -> (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x (y x))) -> (Set.Countable.{u1} \u03b1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : TopologicalSpace.SecondCountableTopology.{u1} \u03b1 _inst_1] {y : \u03b1 -> \u03b1} {s : Set.{u1} \u03b1}, (Set.PairwiseDisjoint.{u1, u1} (Set.{u1} \u03b1) \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b1) (Preorder.toLE.{u1} (Set.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) s (fun (x : \u03b1) => Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) x (y x))) -> (forall (x : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x (y x))) -> (Set.Countable.{u1} \u03b1 s)\nCase conversion may be inaccurate. Consider using '#align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo\u2093'. -/\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 \u03b1] {y : \u03b1 \u2192 \u03b1} {s : Set \u03b1}\n    (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : \u2200 x \u2208 s, x < y x) : s.Countable :=\n  by\n  let t := { x | x \u2208 s \u2227 (Ioo x (y x)).Nonempty }\n  have t_count : t.countable :=\n    haveI : t \u2286 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 \u2286 t \u222a { x : \u03b1 | \u2203 x', x < x' \u2227 Ioo x x' = \u2205 } :=\n    by\n    intro x hx\n    by_cases h'x : (Ioo x (y x)).Nonempty\n    \u00b7 exact Or.inl \u27e8hx, h'x\u27e9\n    \u00b7 exact Or.inr \u27e8y x, h' x hx, not_nonempty_iff_eq_empty.1 h'x\u27e9\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 `\u03a0 i, \u03c0 i` belong to `\ud835\udcdd 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., `\u03b9 \u2192 \u211d`.\n-/\n\n\nvariable {\u03b9 : Type _} {\u03c0 : \u03b9 \u2192 Type _} [Finite \u03b9] [\u2200 i, LinearOrder (\u03c0 i)]\n  [\u2200 i, TopologicalSpace (\u03c0 i)] [\u2200 i, OrderTopology (\u03c0 i)] {a b x : \u2200 i, \u03c0 i} {a' b' x' : \u03b9 \u2192 \u03b1}\n\n#print pi_Iic_mem_nhds /-\ntheorem pi_Iic_mem_nhds (ha : \u2200 i, x i < a i) : Iic a \u2208 \ud835\udcdd x :=\n  pi_univ_Iic a \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {\u03b9 : Type.{u2}} [_inst_4 : Finite.{succ u2} \u03b9] {a' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1}, (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (x' i) (a' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.hasMem.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Iic.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : LinearOrder.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))] {\u03b9 : Type.{u1}} [_inst_4 : Finite.{succ u1} \u03b9] {a' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1}, (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (x' i) (a' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (instMembershipSetFilter.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Iic.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) a') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Iic_mem_nhds' pi_Iic_mem_nhds'\u2093'. -/\ntheorem pi_Iic_mem_nhds' (ha : \u2200 i, x' i < a' i) : Iic a' \u2208 \ud835\udcdd 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 : \u2200 i, a i < x i) : Ici a \u2208 \ud835\udcdd x :=\n  pi_univ_Ici a \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {\u03b9 : Type.{u2}} [_inst_4 : Finite.{succ u2} \u03b9] {a' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1}, (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (a' i) (x' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.hasMem.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ici.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : LinearOrder.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))] {\u03b9 : Type.{u1}} [_inst_4 : Finite.{succ u1} \u03b9] {a' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1}, (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (a' i) (x' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (instMembershipSetFilter.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ici.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) a') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ici_mem_nhds' pi_Ici_mem_nhds'\u2093'. -/\ntheorem pi_Ici_mem_nhds' (ha : \u2200 i, a' i < x' i) : Ici a' \u2208 \ud835\udcdd 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 : \u2200 i, a i < x i) (hb : \u2200 i, x i < b i) : Icc a b \u2208 \ud835\udcdd x :=\n  pi_univ_Icc a b \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {\u03b9 : Type.{u2}} [_inst_4 : Finite.{succ u2} \u03b9] {a' : \u03b9 -> \u03b1} {b' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1}, (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (a' i) (x' i)) -> (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (x' i) (b' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.hasMem.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Icc.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a' b') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : LinearOrder.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))] {\u03b9 : Type.{u1}} [_inst_4 : Finite.{succ u1} \u03b9] {a' : \u03b9 -> \u03b1} {b' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1}, (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (a' i) (x' i)) -> (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (x' i) (b' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (instMembershipSetFilter.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Icc.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) a' b') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Icc_mem_nhds' pi_Icc_mem_nhds'\u2093'. -/\ntheorem pi_Icc_mem_nhds' (ha : \u2200 i, a' i < x' i) (hb : \u2200 i, x' i < b' i) : Icc a' b' \u2208 \ud835\udcdd x' :=\n  pi_Icc_mem_nhds ha hb\n#align pi_Icc_mem_nhds' pi_Icc_mem_nhds'\n\nvariable [Nonempty \u03b9]\n\n#print pi_Iio_mem_nhds /-\ntheorem pi_Iio_mem_nhds (ha : \u2200 i, x i < a i) : Iio a \u2208 \ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {\u03b9 : Type.{u2}} [_inst_4 : Finite.{succ u2} \u03b9] {a' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u2} \u03b9], (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (x' i) (a' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.hasMem.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Iio.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : LinearOrder.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))] {\u03b9 : Type.{u1}} [_inst_4 : Finite.{succ u1} \u03b9] {a' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u1} \u03b9], (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (x' i) (a' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (instMembershipSetFilter.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Iio.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) a') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Iio_mem_nhds' pi_Iio_mem_nhds'\u2093'. -/\ntheorem pi_Iio_mem_nhds' (ha : \u2200 i, x' i < a' i) : Iio a' \u2208 \ud835\udcdd 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 : \u2200 i, a i < x i) : Ioi a \u2208 \ud835\udcdd x :=\n  @pi_Iio_mem_nhds \u03b9 (fun i => (\u03c0 i)\u1d52\u1d48) _ _ _ _ _ _ _ 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {\u03b9 : Type.{u2}} [_inst_4 : Finite.{succ u2} \u03b9] {a' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u2} \u03b9], (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (a' i) (x' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.hasMem.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ioi.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : LinearOrder.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))] {\u03b9 : Type.{u1}} [_inst_4 : Finite.{succ u1} \u03b9] {a' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u1} \u03b9], (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (a' i) (x' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (instMembershipSetFilter.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ioi.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) a') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds'\u2093'. -/\ntheorem pi_Ioi_mem_nhds' (ha : \u2200 i, a' i < x' i) : Ioi a' \u2208 \ud835\udcdd 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 : \u2200 i, a i < x i) (hb : \u2200 i, x i < b i) : Ioc a b \u2208 \ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {\u03b9 : Type.{u2}} [_inst_4 : Finite.{succ u2} \u03b9] {a' : \u03b9 -> \u03b1} {b' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u2} \u03b9], (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (a' i) (x' i)) -> (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (x' i) (b' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.hasMem.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ioc.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a' b') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : LinearOrder.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))] {\u03b9 : Type.{u1}} [_inst_4 : Finite.{succ u1} \u03b9] {a' : \u03b9 -> \u03b1} {b' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u1} \u03b9], (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (a' i) (x' i)) -> (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (x' i) (b' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (instMembershipSetFilter.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ioc.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) a' b') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds'\u2093'. -/\ntheorem pi_Ioc_mem_nhds' (ha : \u2200 i, a' i < x' i) (hb : \u2200 i, x' i < b' i) : Ioc a' b' \u2208 \ud835\udcdd 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 : \u2200 i, a i < x i) (hb : \u2200 i, x i < b i) : Ico a b \u2208 \ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {\u03b9 : Type.{u2}} [_inst_4 : Finite.{succ u2} \u03b9] {a' : \u03b9 -> \u03b1} {b' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u2} \u03b9], (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (a' i) (x' i)) -> (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (x' i) (b' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.hasMem.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ico.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a' b') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : LinearOrder.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))] {\u03b9 : Type.{u1}} [_inst_4 : Finite.{succ u1} \u03b9] {a' : \u03b9 -> \u03b1} {b' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u1} \u03b9], (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (a' i) (x' i)) -> (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (x' i) (b' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (instMembershipSetFilter.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ico.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) a' b') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ico_mem_nhds' pi_Ico_mem_nhds'\u2093'. -/\ntheorem pi_Ico_mem_nhds' (ha : \u2200 i, a' i < x' i) (hb : \u2200 i, x' i < b' i) : Ico a' b' \u2208 \ud835\udcdd 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 : \u2200 i, a i < x i) (hb : \u2200 i, x i < b i) : Ioo a b \u2208 \ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {\u03b9 : Type.{u2}} [_inst_4 : Finite.{succ u2} \u03b9] {a' : \u03b9 -> \u03b1} {b' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u2} \u03b9], (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (a' i) (x' i)) -> (forall (i : \u03b9), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) (x' i) (b' i)) -> (Membership.Mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.hasMem.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ioo.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a' b') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : LinearOrder.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))] {\u03b9 : Type.{u1}} [_inst_4 : Finite.{succ u1} \u03b9] {a' : \u03b9 -> \u03b1} {b' : \u03b9 -> \u03b1} {x' : \u03b9 -> \u03b1} [_inst_8 : Nonempty.{succ u1} \u03b9], (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (a' i) (x' i)) -> (forall (i : \u03b9), LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) (x' i) (b' i)) -> (Membership.mem.{max u2 u1, max u2 u1} (Set.{max u2 u1} (\u03b9 -> \u03b1)) (Filter.{max u2 u1} (\u03b9 -> \u03b1)) (instMembershipSetFilter.{max u2 u1} (\u03b9 -> \u03b1)) (Set.Ioo.{max u2 u1} (\u03b9 -> \u03b1) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_2)))))) a' b') (nhds.{max u2 u1} (\u03b9 -> \u03b1) (Pi.topologicalSpace.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (a : \u03b9) => _inst_1)) x'))\nCase conversion may be inaccurate. Consider using '#align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds'\u2093'. -/\ntheorem pi_Ioo_mem_nhds' (ha : \u2200 i, a' i < x' i) (hb : \u2200 i, x' i < b' i) : Ioo a' b' \u2208 \ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] (x : \u03b1), Disjoint.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (nhds.{u1} \u03b1 _inst_1 x) (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] (x : \u03b1), Disjoint.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (nhds.{u1} \u03b1 _inst_1 x) (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align disjoint_nhds_at_top disjoint_nhds_atTop\u2093'. -/\ntheorem disjoint_nhds_atTop [NoMaxOrder \u03b1] (x : \u03b1) : Disjoint (\ud835\udcdd x) atTop :=\n  by\n  rcases exists_gt x with \u27e8y, hy : x < y\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] (x : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 x) (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] (x : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 x) (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toBot.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align inf_nhds_at_top inf_nhds_atTop\u2093'. -/\n@[simp]\ntheorem inf_nhds_atTop [NoMaxOrder \u03b1] (x : \u03b1) : \ud835\udcdd x \u2293 atTop = \u22a5 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] (x : \u03b1), Disjoint.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (nhds.{u1} \u03b1 _inst_1 x) (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] (x : \u03b1), Disjoint.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (nhds.{u1} \u03b1 _inst_1 x) (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align disjoint_nhds_at_bot disjoint_nhds_atBot\u2093'. -/\ntheorem disjoint_nhds_atBot [NoMinOrder \u03b1] (x : \u03b1) : Disjoint (\ud835\udcdd x) atBot :=\n  @disjoint_nhds_atTop \u03b1\u1d52\u1d48 _ _ _ _ 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] (x : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 x) (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] (x : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 x) (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toBot.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align inf_nhds_at_bot inf_nhds_atBot\u2093'. -/\n@[simp]\ntheorem inf_nhds_atBot [NoMinOrder \u03b1] (x : \u03b1) : \ud835\udcdd x \u2293 atBot = \u22a5 :=\n  @inf_nhds_atTop \u03b1\u1d52\u1d48 _ _ _ _ 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 \u03b1] {F : Filter \u03b2} [NeBot F] {f : \u03b2 \u2192 \u03b1}\n    (hf : Tendsto f F atTop) (x : \u03b1) : \u00acTendsto f F (\ud835\udcdd 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 \u03b1] {F : Filter \u03b2} [NeBot F] {f : \u03b2 \u2192 \u03b1}\n    {x : \u03b1} (hf : Tendsto f F (\ud835\udcdd x)) : \u00acTendsto 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 \u03b1] {F : Filter \u03b2} [NeBot F] {f : \u03b2 \u2192 \u03b1}\n    (hf : Tendsto f F atBot) (x : \u03b1) : \u00acTendsto f F (\ud835\udcdd 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 \u03b1] {F : Filter \u03b2} [NeBot F] {f : \u03b2 \u2192 \u03b1}\n    {x : \u03b1} (hf : Tendsto f F (\ud835\udcdd x)) : \u00acTendsto 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) -> (forall (s : Set.{u1} \u03b1), List.TFAE (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s))) (List.nil.{0} Prop)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) -> (forall (s : Set.{u1} \u03b1), List.TFAE (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a u) s))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\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, +\u221e)`\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 \u2208 (a, b]`\n4. `s` includes `(a, u)` for some `u > a` -/\ntheorem TFAE_mem_nhdsWithin_Ioi {a b : \u03b1} (hab : a < b) (s : Set \u03b1) :\n    TFAE\n      [s \u2208 \ud835\udcdd[>] a,-- 0 : `s` is a neighborhood of `a` within `(a, +\u221e)`\n          s \u2208\n          \ud835\udcdd[Ioc a b] a,-- 1 : `s` is a neighborhood of `a` within `(a, b]`\n          s \u2208\n          \ud835\udcdd[Ioo a b] a,-- 2 : `s` is a neighborhood of `a` within `(a, b)`\n        \u2203 u \u2208 Ioc a b, Ioo a u \u2286 s,-- 3 : `s` includes `(a, u)` for some `u \u2208 (a, b]`\n        \u2203 u \u2208 Ioi a, Ioo a u \u2286 s] :=\n  by\n  -- 4 : `s` includes `(a, u)` for some `u > a`\n  tfae_have 1 \u2194 2;\n  \u00b7 rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab]\n  tfae_have 1 \u2194 3; \u00b7 rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab]\n  tfae_have 4 \u2192 5; exact fun \u27e8u, umem, hu\u27e9 => \u27e8u, umem.1, hu\u27e9\n  tfae_have 5 \u2192 1\n  \u00b7 rintro \u27e8u, hau, hu\u27e9\n    exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi \u27e8le_refl a, hau\u27e9) hu\n  tfae_have 1 \u2192 4\n  \u00b7 intro h\n    rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with \u27e8v, va, hv\u27e9\n    rcases exists_Ico_subset_of_mem_nhds' va hab with \u27e8u, au, hu\u27e9\n    refine' \u27e8u, au, fun x hx => _\u27e9\n    refine' hv \u27e8hu \u27e8le_of_lt hx.1, hx.2\u27e9, _\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {u' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a u') -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u')) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u')) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {u' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a u') -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a u')) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\ntheorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : \u03b1} {s : Set \u03b1} (hu' : a < u') :\n    s \u2208 \ud835\udcdd[>] a \u2194 \u2203 u \u2208 Ioc a u', Ioo a u \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {u' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a u') -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {u' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a u') -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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'\u2093'. -/\n/-- A set is a neighborhood of `a` within `(a, +\u221e)` 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' : \u03b1} {s : Set \u03b1} (hu' : a < u') :\n    s \u2208 \ud835\udcdd[>] a \u2194 \u2203 u \u2208 Ioi a, Ioo a u \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- A set is a neighborhood of `a` within `(a, +\u221e)` if and only if it contains an interval `(a, u)`\nwith `a < u`. -/\ntheorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder \u03b1] {a : \u03b1} {s : Set \u03b1} :\n    s \u2208 \ud835\udcdd[>] a \u2194 \u2203 u \u2208 Ioi a, Ioo a u \u2286 s :=\n  let \u27e8u', hu'\u27e9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_5 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- A set is a neighborhood of `a` within `(a, +\u221e)` if and only if it contains an interval `(a, u]`\nwith `a < u`. -/\ntheorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder \u03b1] [DenselyOrdered \u03b1] {a : \u03b1}\n    {s : Set \u03b1} : s \u2208 \ud835\udcdd[>] a \u2194 \u2203 u \u2208 Ioi a, Ioc a u \u2286 s :=\n  by\n  rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset]\n  constructor\n  \u00b7 rintro \u27e8u, au, as\u27e9\n    rcases exists_between au with \u27e8v, hv\u27e9\n    exact \u27e8v, hv.1, fun x hx => as \u27e8hx.1, lt_of_le_of_lt hx.2 hv.2\u27e9\u27e9\n  \u00b7 rintro \u27e8u, au, as\u27e9\n    exact \u27e8u, au, subset.trans Ioo_subset_Ioc_self as\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) -> (forall (s : Set.{u1} \u03b1), List.TFAE (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l b) s))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l b) s))) (List.nil.{0} Prop)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) -> (forall (s : Set.{u1} \u03b1), List.TFAE (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) l b) s))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- The following statements are equivalent:\n\n0. `s` is a neighborhood of `b` within `(-\u221e, 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 \u2208 [a, b)`\n4. `s` includes `(l, b)` for some `l < b` -/\ntheorem TFAE_mem_nhdsWithin_Iio {a b : \u03b1} (h : a < b) (s : Set \u03b1) :\n    TFAE\n      [s \u2208 \ud835\udcdd[<] b,-- 0 : `s` is a neighborhood of `b` within `(-\u221e, b)`\n          s \u2208\n          \ud835\udcdd[Ico a b] b,-- 1 : `s` is a neighborhood of `b` within `[a, b)`\n          s \u2208\n          \ud835\udcdd[Ioo a b] b,-- 2 : `s` is a neighborhood of `b` within `(a, b)`\n        \u2203 l \u2208 Ico a b, Ioo l b \u2286 s,-- 3 : `s` includes `(l, b)` for some `l \u2208 [a, b)`\n        \u2203 l \u2208 Iio b, Ioo l b \u2286 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 \u207b\u00b9' 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {l' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) l' a) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l' a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l' a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {l' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) l' a) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) l' a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\ntheorem mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subset {a l' : \u03b1} {s : Set \u03b1} (hl' : l' < a) :\n    s \u2208 \ud835\udcdd[<] a \u2194 \u2203 l \u2208 Ico l' a, Ioo l a \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {l' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) l' a) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {l' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) l' a) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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'\u2093'. -/\n/-- A set is a neighborhood of `a` within `(-\u221e, 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' : \u03b1} {s : Set \u03b1} (hl' : l' < a) :\n    s \u2208 \ud835\udcdd[<] a \u2194 \u2203 l \u2208 Iio a, Ioo l a \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- A set is a neighborhood of `a` within `(-\u221e, a)` if and only if it contains an interval `(l, a)`\nwith `l < a`. -/\ntheorem mem_nhdsWithin_Iio_iff_exists_Ioo_subset [NoMinOrder \u03b1] {a : \u03b1} {s : Set \u03b1} :\n    s \u2208 \ud835\udcdd[<] a \u2194 \u2203 l \u2208 Iio a, Ioo l a \u2286 s :=\n  let \u27e8l', hl'\u27e9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_5 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- A set is a neighborhood of `a` within `(-\u221e, a)` if and only if it contains an interval `[l, a)`\nwith `l < a`. -/\ntheorem mem_nhdsWithin_Iio_iff_exists_Ico_subset [NoMinOrder \u03b1] [DenselyOrdered \u03b1] {a : \u03b1}\n    {s : Set \u03b1} : s \u2208 \ud835\udcdd[<] a \u2194 \u2203 l \u2208 Iio a, Ico l a \u2286 s :=\n  by\n  have : of_dual \u207b\u00b9' s \u2208 \ud835\udcdd[>] to_dual a \u2194 _ := 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) -> (forall (s : Set.{u1} \u03b1), List.TFAE (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s))) (List.nil.{0} Prop)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) -> (forall (s : Set.{u1} \u03b1), List.TFAE (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a u) s))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- The following statements are equivalent:\n\n0. `s` is a neighborhood of `a` within `[a, +\u221e)`\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 \u2208 (a, b]`\n4. `s` includes `[a, u)` for some `u > a` -/\ntheorem TFAE_mem_nhdsWithin_Ici {a b : \u03b1} (hab : a < b) (s : Set \u03b1) :\n    TFAE\n      [s \u2208 \ud835\udcdd[\u2265] a,-- 0 : `s` is a neighborhood of `a` within `[a, +\u221e)`\n          s \u2208\n          \ud835\udcdd[Icc a b] a,-- 1 : `s` is a neighborhood of `a` within `[a, b]`\n          s \u2208\n          \ud835\udcdd[Ico a b] a,-- 2 : `s` is a neighborhood of `a` within `[a, b)`\n        \u2203 u \u2208 Ioc a b, Ico a u \u2286 s,-- 3 : `s` includes `[a, u)` for some `u \u2208 (a, b]`\n        \u2203 u \u2208 Ioi a, Ico a u \u2286 s] :=\n  by\n  -- 4 : `s` includes `[a, u)` for some `u > a`\n  tfae_have 1 \u2194 2;\n  \u00b7 rw [nhdsWithin_Icc_eq_nhdsWithin_Ici hab]\n  tfae_have 1 \u2194 3; \u00b7 rw [nhdsWithin_Ico_eq_nhdsWithin_Ici hab]\n  tfae_have 1 \u2194 5; exact (nhdsWithin_Ici_basis' \u27e8b, hab\u27e9).mem_iff\n  tfae_have 4 \u2192 5; exact fun \u27e8u, umem, hu\u27e9 => \u27e8u, umem.1, hu\u27e9\n  tfae_have 5 \u2192 4\n  \u00b7 rintro \u27e8u, hua, hus\u27e9\n    exact\n      \u27e8min u b, \u27e8lt_min hua hab, min_le_right _ _\u27e9,\n        (Ico_subset_Ico_right <| min_le_left _ _).trans hus\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {u' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a u') -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u')) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u')) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {u' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a u') -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a u')) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\ntheorem mem_nhdsWithin_Ici_iff_exists_mem_Ioc_Ico_subset {a u' : \u03b1} {s : Set \u03b1} (hu' : a < u') :\n    s \u2208 \ud835\udcdd[\u2265] a \u2194 \u2203 u \u2208 Ioc a u', Ico a u \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {u' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a u') -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {u' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a u') -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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'\u2093'. -/\n/-- A set is a neighborhood of `a` within `[a, +\u221e)` 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' : \u03b1} {s : Set \u03b1} (hu' : a < u') :\n    s \u2208 \ud835\udcdd[\u2265] a \u2194 \u2203 u \u2208 Ioi a, Ico a u \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a u) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ici.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (u : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) u (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- A set is a neighborhood of `a` within `[a, +\u221e)` if and only if it contains an interval `[a, u)`\nwith `a < u`. -/\ntheorem mem_nhdsWithin_Ici_iff_exists_Ico_subset [NoMaxOrder \u03b1] {a : \u03b1} {s : Set \u03b1} :\n    s \u2208 \ud835\udcdd[\u2265] a \u2194 \u2203 u \u2208 Ioi a, Ico a u \u2286 s :=\n  let \u27e8u', hu'\u27e9 := 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 \u03b1] (a : \u03b1) :\n    (\ud835\udcdd[\u2265] a).HasBasis (fun u => a < u) (Ico a) :=\n  \u27e8fun s => mem_nhdsWithin_Ici_iff_exists_Ico_subset\u27e9\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, +\u221e)` if and only if it contains an interval `[a, u]`\nwith `a < u`. -/\ntheorem mem_nhdsWithin_Ici_iff_exists_Icc_subset [NoMaxOrder \u03b1] [DenselyOrdered \u03b1] {a : \u03b1}\n    {s : Set \u03b1} : s \u2208 \ud835\udcdd[\u2265] a \u2194 \u2203 u, a < u \u2227 Icc a u \u2286 s :=\n  by\n  rw [mem_nhdsWithin_Ici_iff_exists_Ico_subset]\n  constructor\n  \u00b7 rintro \u27e8u, au, as\u27e9\n    rcases exists_between au with \u27e8v, hv\u27e9\n    exact \u27e8v, hv.1, fun x hx => as \u27e8hx.1, lt_of_le_of_lt hx.2 hv.2\u27e9\u27e9\n  \u00b7 rintro \u27e8u, au, as\u27e9\n    exact \u27e8u, au, subset.trans Ico_subset_Icc_self as\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) -> (forall (s : Set.{u1} \u03b1), List.TFAE (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b))) (List.cons.{0} Prop (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l b) s))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l b) s))) (List.nil.{0} Prop)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) -> (forall (s : Set.{u1} \u03b1), List.TFAE (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b))) (List.cons.{0} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) l b) s))) (List.cons.{0} Prop (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- The following statements are equivalent:\n\n0. `s` is a neighborhood of `b` within `(-\u221e, 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 \u2208 [a, b)`\n4. `s` includes `(l, b]` for some `l < b` -/\ntheorem TFAE_mem_nhdsWithin_Iic {a b : \u03b1} (h : a < b) (s : Set \u03b1) :\n    TFAE\n      [s \u2208 \ud835\udcdd[\u2264] b,-- 0 : `s` is a neighborhood of `b` within `(-\u221e, b]`\n          s \u2208\n          \ud835\udcdd[Icc a b] b,-- 1 : `s` is a neighborhood of `b` within `[a, b]`\n          s \u2208\n          \ud835\udcdd[Ioc a b] b,-- 2 : `s` is a neighborhood of `b` within `(a, b]`\n        \u2203 l \u2208 Ico a b, Ioc l b \u2286 s,-- 3 : `s` includes `(l, b]` for some `l \u2208 [a, b)`\n        \u2203 l \u2208 Iio b, Ioc l b \u2286 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 \u207b\u00b9' 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {l' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) l' a) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l' a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l' a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {l' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) l' a) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) l' a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\ntheorem mem_nhdsWithin_Iic_iff_exists_mem_Ico_Ioc_subset {a l' : \u03b1} {s : Set \u03b1} (hl' : l' < a) :\n    s \u2208 \ud835\udcdd[\u2264] a \u2194 \u2203 l \u2208 Ico l' a, Ioc l a \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] {a : \u03b1} {l' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) l' a) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {l' : \u03b1} {s : Set.{u1} \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) l' a) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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'\u2093'. -/\n/-- A set is a neighborhood of `a` within `(-\u221e, 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' : \u03b1} {s : Set \u03b1} (hl' : l' < a) :\n    s \u2208 \ud835\udcdd[\u2264] a \u2194 \u2203 l \u2208 Iio a, Ioc l a \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) l a) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Iic.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Exists.{succ u1} \u03b1 (fun (l : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) l (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _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\u2093'. -/\n/-- A set is a neighborhood of `a` within `(-\u221e, a]` if and only if it contains an interval `(l, a]`\nwith `l < a`. -/\ntheorem mem_nhdsWithin_Iic_iff_exists_Ioc_subset [NoMinOrder \u03b1] {a : \u03b1} {s : Set \u03b1} :\n    s \u2208 \ud835\udcdd[\u2264] a \u2194 \u2203 l \u2208 Iio a, Ioc l a \u2286 s :=\n  let \u27e8l', hl'\u27e9 := 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 `(-\u221e, a]` if and only if it contains an interval `[l, a]`\nwith `l < a`. -/\ntheorem mem_nhdsWithin_Iic_iff_exists_Icc_subset [NoMinOrder \u03b1] [DenselyOrdered \u03b1] {a : \u03b1}\n    {s : Set \u03b1} : s \u2208 \ud835\udcdd[\u2264] a \u2194 \u2203 l, l < a \u2227 Icc l a \u2286 s :=\n  by\n  convert@mem_nhdsWithin_Ici_iff_exists_Icc_subset \u03b1\u1d52\u1d48 _ _ _ _ _ _ _\n  simp_rw [show \u2200 u : \u03b1\u1d52\u1d48, @Icc \u03b1\u1d52\u1d48 _ a u = @Icc \u03b1 _ 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 \u03b1] [LinearOrderedAddCommGroup \u03b1] [OrderTopology \u03b1]\n\nvariable {l : Filter \u03b2} {f g : \u03b2 \u2192 \u03b1}\n\n/- warning: nhds_eq_infi_abs_sub -> nhds_eq_inf\u1d62_abs_sub is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 a) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (r : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) r (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))))) (fun (H : GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) r (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))))) => Filter.principal.{u1} \u03b1 (setOf.{u1} \u03b1 (fun (b : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) a b)) r)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_1 a) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (r : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) r (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) (fun (H : GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) r (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) => Filter.principal.{u1} \u03b1 (setOf.{u1} \u03b1 (fun (b : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) a b)) r)))))\nCase conversion may be inaccurate. Consider using '#align nhds_eq_infi_abs_sub nhds_eq_inf\u1d62_abs_sub\u2093'. -/\ntheorem nhds_eq_inf\u1d62_abs_sub (a : \u03b1) : \ud835\udcdd a = \u2a05 r > 0, \ud835\udcdf { b | |a - b| < r } :=\n  by\n  simp only [le_antisymm_iff, nhds_eq_order, le_inf_iff, le_inf\u1d62_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' \u27e8_, _, _\u27e9\n  \u00b7 intro \u03b5 \u03b50\n    exact\n      inter_mem_inf\n        (mem_infi_of_mem (a - \u03b5) <| mem_infi_of_mem (sub_lt_self a \u03b50) (mem_principal_self _))\n        (mem_infi_of_mem (\u03b5 + a) <| mem_infi_of_mem (by simpa) (mem_principal_self _))\n  \u00b7 intro b hb\n    exact mem_infi_of_mem (a - b) (mem_infi_of_mem (sub_pos.2 hb) (by simp [Ioi]))\n  \u00b7 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\u1d62_abs_sub\n\n/- warning: order_topology_of_nhds_abs -> orderTopology_of_nhds_abs is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_4 : TopologicalSpace.{u1} \u03b1] [_inst_5 : LinearOrderedAddCommGroup.{u1} \u03b1], (forall (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_4 a) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) \u03b1 (fun (r : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))) r (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5))))))))))) (fun (H : GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))) r (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5))))))))))) => Filter.principal.{u1} \u03b1 (setOf.{u1} \u03b1 (fun (b : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_5))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))))) a b)) r)))))) -> (OrderTopology.{u1} \u03b1 _inst_4 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_4 : TopologicalSpace.{u1} \u03b1] [_inst_5 : LinearOrderedAddCommGroup.{u1} \u03b1], (forall (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (nhds.{u1} \u03b1 _inst_4 a) (inf\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) \u03b1 (fun (r : \u03b1) => inf\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))) r (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))))))))) (fun (H : GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))) r (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))))))))) => Filter.principal.{u1} \u03b1 (setOf.{u1} \u03b1 (fun (b : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5))))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_5)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5)))))) a b)) r)))))) -> (OrderTopology.{u1} \u03b1 _inst_4 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_5))))\nCase conversion may be inaccurate. Consider using '#align order_topology_of_nhds_abs orderTopology_of_nhds_abs\u2093'. -/\ntheorem orderTopology_of_nhds_abs {\u03b1 : Type _} [TopologicalSpace \u03b1] [LinearOrderedAddCommGroup \u03b1]\n    (h_nhds : \u2200 a : \u03b1, \ud835\udcdd a = \u2a05 r > 0, \ud835\udcdf { b | |a - b| < r }) : OrderTopology \u03b1 :=\n  by\n  refine' \u27e8eq_of_nhds_eq_nhds fun a => _\u27e9\n  rw [h_nhds]\n  letI := Preorder.topology \u03b1; letI : OrderTopology \u03b1 := \u27e8rfl\u27e9\n  exact (nhds_eq_inf\u1d62_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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {f : \u03b2 -> \u03b1} {x : Filter.{u2} \u03b2} {a : \u03b1}, Iff (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f x (nhds.{u1} \u03b1 _inst_1 a)) (forall (\u03b5 : \u03b1), (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) \u03b5 (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))))) -> (Filter.Eventually.{u2} \u03b2 (fun (b : \u03b2) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) (f b) a)) \u03b5) x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {f : \u03b2 -> \u03b1} {x : Filter.{u2} \u03b2} {a : \u03b1}, Iff (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f x (nhds.{u1} \u03b1 _inst_1 a)) (forall (\u03b5 : \u03b1), (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) \u03b5 (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) -> (Filter.Eventually.{u2} \u03b2 (fun (b : \u03b2) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) (f b) a)) \u03b5) x))\nCase conversion may be inaccurate. Consider using '#align linear_ordered_add_comm_group.tendsto_nhds LinearOrderedAddCommGroup.tendsto_nhds\u2093'. -/\ntheorem LinearOrderedAddCommGroup.tendsto_nhds {x : Filter \u03b2} {a : \u03b1} :\n    Tendsto f x (\ud835\udcdd a) \u2194 \u2200 \u03b5 > (0 : \u03b1), \u2200\u1da0 b in x, |f b - a| < \u03b5 := by\n  simp [nhds_eq_inf\u1d62_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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] (a : \u03b1) {\u03b5 : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) \u03b5) -> (Filter.Eventually.{u1} \u03b1 (fun (x : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) x a)) \u03b5) (nhds.{u1} \u03b1 _inst_1 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] (a : \u03b1) {\u03b5 : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))) \u03b5) -> (Filter.Eventually.{u1} \u03b1 (fun (x : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) x a)) \u03b5) (nhds.{u1} \u03b1 _inst_1 a))\nCase conversion may be inaccurate. Consider using '#align eventually_abs_sub_lt eventually_abs_sub_lt\u2093'. -/\ntheorem eventually_abs_sub_lt (a : \u03b1) {\u03b5 : \u03b1} (h\u03b5 : 0 < \u03b5) : \u2200\u1da0 x in \ud835\udcdd a, |x - a| < \u03b5 :=\n  (nhds_eq_inf\u1d62_abs_sub a).symm \u25b8\n    mem_inf\u1d62_of_mem \u03b5 (mem_inf\u1d62_of_mem h\u03b5 <| 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {l : Filter.{u2} \u03b2} {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {C : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 C)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g l (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (x : \u03b2) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) (f x) (g x)) l (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {l : Filter.{u2} \u03b2} {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {C : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 C)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g l (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (x : \u03b2) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) (f x) (g x)) l (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.add_at_top Filter.Tendsto.add_atTop\u2093'. -/\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 : \u03b1} (hf : Tendsto f l (\ud835\udcdd C)) (hg : Tendsto g l atTop) :\n    Tendsto (fun x => f x + g x) l atTop :=\n  by\n  nontriviality \u03b1\n  obtain \u27e8C', hC'\u27e9 : \u2203 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {l : Filter.{u2} \u03b2} {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {C : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 C)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g l (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (x : \u03b2) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) (f x) (g x)) l (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {l : Filter.{u2} \u03b2} {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {C : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (nhds.{u1} \u03b1 _inst_1 C)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g l (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (x : \u03b2) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) (f x) (g x)) l (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.add_at_bot Filter.Tendsto.add_atBot\u2093'. -/\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 : \u03b1} (hf : Tendsto f l (\ud835\udcdd C)) (hg : Tendsto g l atBot) :\n    Tendsto (fun x => f x + g x) l atBot :=\n  @Filter.Tendsto.add_atTop \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {l : Filter.{u2} \u03b2} {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {C : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g l (nhds.{u1} \u03b1 _inst_1 C)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (x : \u03b2) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) (f x) (g x)) l (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {l : Filter.{u2} \u03b2} {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {C : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g l (nhds.{u1} \u03b1 _inst_1 C)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (x : \u03b2) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) (f x) (g x)) l (Filter.atTop.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.at_top_add Filter.Tendsto.atTop_add\u2093'. -/\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 : \u03b1} (hf : Tendsto f l atTop) (hg : Tendsto g l (\ud835\udcdd 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {l : Filter.{u2} \u03b2} {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {C : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g l (nhds.{u1} \u03b1 _inst_1 C)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (x : \u03b2) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) (f x) (g x)) l (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] {l : Filter.{u2} \u03b2} {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {C : \u03b1}, (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 f l (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 g l (nhds.{u1} \u03b1 _inst_1 C)) -> (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 (fun (x : \u03b2) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) (f x) (g x)) l (Filter.atBot.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.at_bot_add Filter.Tendsto.atBot_add\u2093'. -/\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 : \u03b1} (hf : Tendsto f l atBot) (hg : Tendsto g l (\ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] [_inst_5 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] (a : \u03b1), Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (fun (\u03b5 : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) \u03b5) (fun (\u03b5 : \u03b1) => Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) a \u03b5) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) a \u03b5))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] (_inst_5 : \u03b1), Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 _inst_5) (fun (\u03b5 : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))) \u03b5) (fun (\u03b5 : \u03b1) => Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) _inst_5 \u03b5) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) _inst_5 \u03b5))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_Ioo_pos nhds_basis_Ioo_pos\u2093'. -/\ntheorem nhds_basis_Ioo_pos [NoMinOrder \u03b1] [NoMaxOrder \u03b1] (a : \u03b1) :\n    (\ud835\udcdd a).HasBasis (fun \u03b5 : \u03b1 => (0 : \u03b1) < \u03b5) fun \u03b5 => Ioo (a - \u03b5) (a + \u03b5) :=\n  \u27e8by\n    refine' fun t => (nhds_basis_Ioo a).mem_iff.trans \u27e8_, _\u27e9\n    \u00b7 rintro \u27e8\u27e8l, u\u27e9, \u27e8hl : l < a, hu : a < u\u27e9, h' : Ioo l u \u2286 t\u27e9\n      refine' \u27e8min (a - l) (u - a), by apply lt_min <;> rwa [sub_pos], _\u27e9\n      rintro x \u27e8hx, hx'\u27e9\n      apply h'\n      rw [sub_lt_comm, lt_min_iff, sub_lt_sub_iff_left] at hx\n      rw [\u2190 sub_lt_iff_lt_add', lt_min_iff, sub_lt_sub_iff_right] at hx'\n      exact \u27e8hx.1, hx'.2\u27e9\n    \u00b7 rintro \u27e8\u03b5, \u03b5_pos, h\u27e9\n      exact \u27e8(a - \u03b5, a + \u03b5), by simp [\u03b5_pos], h\u27e9\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] [_inst_5 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] (a : \u03b1), Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (fun (\u03b5 : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) \u03b5) (fun (\u03b5 : \u03b1) => setOf.{u1} \u03b1 (fun (b : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) b a)) \u03b5))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] (_inst_5 : \u03b1), Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 _inst_5) (fun (\u03b5 : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))) \u03b5) (fun (\u03b5 : \u03b1) => setOf.{u1} \u03b1 (fun (b : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) b _inst_5)) \u03b5))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_abs_sub_lt nhds_basis_abs_sub_lt\u2093'. -/\ntheorem nhds_basis_abs_sub_lt [NoMinOrder \u03b1] [NoMaxOrder \u03b1] (a : \u03b1) :\n    (\ud835\udcdd a).HasBasis (fun \u03b5 : \u03b1 => (0 : \u03b1) < \u03b5) fun \u03b5 => { b | |b - a| < \u03b5 } :=\n  by\n  convert nhds_basis_Ioo_pos a\n  \u00b7 ext \u03b5\n    change |x - a| < \u03b5 \u2194 a - \u03b5 < x \u2227 x < a + \u03b5\n    simp [abs_lt, sub_lt_iff_lt_add, add_comm \u03b5 a, add_comm x \u03b5]\n#align nhds_basis_abs_sub_lt nhds_basis_abs_sub_lt\n\nvariable (\u03b1)\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 (\u03b1 : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] [_inst_5 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))))) (fun (\u03b5 : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) \u03b5) (fun (\u03b5 : \u03b1) => setOf.{u1} \u03b1 (fun (b : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2))))) b) \u03b5))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))], Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) (fun (\u03b5 : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))) \u03b5) (fun (\u03b5 : \u03b1) => setOf.{u1} \u03b1 (fun (b : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedAddCommGroup.toLinearOrder.{u1} \u03b1 _inst_2)))))) b) \u03b5))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_zero_abs_sub_lt nhds_basis_zero_abs_sub_lt\u2093'. -/\ntheorem nhds_basis_zero_abs_sub_lt [NoMinOrder \u03b1] [NoMaxOrder \u03b1] :\n    (\ud835\udcdd (0 : \u03b1)).HasBasis (fun \u03b5 : \u03b1 => (0 : \u03b1) < \u03b5) fun \u03b5 => { b | |b| < \u03b5 } := by\n  simpa using nhds_basis_abs_sub_lt (0 : \u03b1)\n#align nhds_basis_zero_abs_sub_lt nhds_basis_zero_abs_sub_lt\n\nvariable {\u03b1}\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] [_inst_4 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] [_inst_5 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) a) -> (Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (fun (\u03b5 : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))))) \u03b5) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) \u03b5 a)) (fun (\u03b5 : \u03b1) => Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) a \u03b5) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) a \u03b5)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrderedAddCommGroup.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))] [_inst_4 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))] {_inst_5 : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))) _inst_5) -> (Filter.HasBasis.{u1, succ u1} \u03b1 \u03b1 (nhds.{u1} \u03b1 _inst_1 _inst_5) (fun (\u03b5 : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (NegZeroClass.toZero.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (SubtractionCommMonoid.toSubtractionMonoid.{u1} \u03b1 (AddCommGroup.toDivisionAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))))))))) \u03b5) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))) \u03b5 _inst_5)) (fun (\u03b5 : \u03b1) => Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))) _inst_5 \u03b5) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u1} \u03b1 _inst_2)))))))) _inst_5 \u03b5)))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_Ioo_pos_of_pos nhds_basis_Ioo_pos_of_pos\u2093'. -/\n/-- If `a` is positive we can form a basis from only nonnegative `Ioo` intervals -/\ntheorem nhds_basis_Ioo_pos_of_pos [NoMinOrder \u03b1] [NoMaxOrder \u03b1] {a : \u03b1} (ha : 0 < a) :\n    (\ud835\udcdd a).HasBasis (fun \u03b5 : \u03b1 => (0 : \u03b1) < \u03b5 \u2227 \u03b5 \u2264 a) fun \u03b5 => Ioo (a - \u03b5) (a + \u03b5) :=\n  \u27e8fun t =>\n    (nhds_basis_Ioo_pos a).mem_iff.trans\n      \u27e8fun h =>\n        let \u27e8i, hi, hit\u27e9 := h\n        \u27e8min i a, \u27e8lt_min hi ha, min_le_right i a\u27e9,\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\u27e9,\n        fun h =>\n        let \u27e8i, hi, hit\u27e9 := h\n        \u27e8i, hi.1, hit\u27e9\u27e9\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : AddGroup.{u1} \u03b1], Eq.{succ u1} ((Set.{u1} \u03b1) -> (Set.{u1} \u03b1)) (Set.preimage.{u1, u1} \u03b1 \u03b1 (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 _inst_1)))) (Set.image.{u1, u1} \u03b1 \u03b1 (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : AddGroup.{u1} \u03b1], Eq.{succ u1} ((Set.{u1} \u03b1) -> (Set.{u1} \u03b1)) (Set.preimage.{u1, u1} \u03b1 \u03b1 (Neg.neg.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (AddGroup.toSubtractionMonoid.{u1} \u03b1 _inst_1)))))) (Set.image.{u1, u1} \u03b1 \u03b1 (Neg.neg.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (AddGroup.toSubtractionMonoid.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align preimage_neg preimage_neg\u2093'. -/\ntheorem preimage_neg [AddGroup \u03b1] : preimage (Neg.neg : \u03b1 \u2192 \u03b1) = image (Neg.neg : \u03b1 \u2192 \u03b1) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : AddGroup.{u1} \u03b1], Eq.{succ u1} ((Filter.{u1} \u03b1) -> (Filter.{u1} \u03b1)) (Filter.map.{u1, u1} \u03b1 \u03b1 (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 _inst_1)))) (Filter.comap.{u1, u1} \u03b1 \u03b1 (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : AddGroup.{u1} \u03b1], Eq.{succ u1} ((Filter.{u1} \u03b1) -> (Filter.{u1} \u03b1)) (Filter.map.{u1, u1} \u03b1 \u03b1 (Neg.neg.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (AddGroup.toSubtractionMonoid.{u1} \u03b1 _inst_1)))))) (Filter.comap.{u1, u1} \u03b1 \u03b1 (Neg.neg.{u1} \u03b1 (NegZeroClass.toNeg.{u1} \u03b1 (SubNegZeroMonoid.toNegZeroClass.{u1} \u03b1 (SubtractionMonoid.toSubNegZeroMonoid.{u1} \u03b1 (AddGroup.toSubtractionMonoid.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align filter.map_neg_eq_comap_neg Filter.map_neg_eq_comap_neg\u2093'. -/\ntheorem Filter.map_neg_eq_comap_neg [AddGroup \u03b1] :\n    map (Neg.neg : \u03b1 \u2192 \u03b1) = comap (Neg.neg : \u03b1 \u2192 \u03b1) :=\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 \u03b1] [TopologicalSpace \u03b2] [LinearOrder \u03b1] [LinearOrder \u03b2] [OrderTopology \u03b1]\n  [OrderTopology \u03b2]\n\n#print IsLUB.frequently_mem /-\ntheorem IsLUB.frequently_mem {a : \u03b1} {s : Set \u03b1} (ha : IsLUB s a) (hs : s.Nonempty) :\n    \u2203\u1da0 x in \ud835\udcdd[\u2264] a, x \u2208 s := by\n  rcases hs with \u27e8a', ha'\u27e9\n  intro h\n  rcases(ha.1 ha').eq_or_lt with (rfl | ha'a)\n  \u00b7 exact h.self_of_nhds_within le_rfl ha'\n  \u00b7 rcases(mem_nhdsWithin_Iic_iff_exists_Ioc_subset' ha'a).1 h with \u27e8b, hba, hb\u27e9\n    rcases ha.exists_between hba with \u27e8b', hb's, hb'\u27e9\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 : \u03b1} {s : Set \u03b1} (ha : IsLUB s a) (hs : s.Nonempty) :\n    \u2203\u1da0 x in \ud835\udcdd a, x \u2208 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 : \u03b1} {s : Set \u03b1} (ha : IsGLB s a) (hs : s.Nonempty) :\n    \u2203\u1da0 x in \ud835\udcdd[\u2265] a, x \u2208 s :=\n  @IsLUB.frequently_mem \u03b1\u1d52\u1d48 _ _ _ _ _ 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 : \u03b1} {s : Set \u03b1} (ha : IsGLB s a) (hs : s.Nonempty) :\n    \u2203\u1da0 x in \ud835\udcdd a, x \u2208 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 : \u03b1} {s : Set \u03b1} (ha : IsLUB s a) (hs : s.Nonempty) : a \u2208 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 : \u03b1} {s : Set \u03b1} (ha : IsGLB s a) (hs : s.Nonempty) : a \u2208 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 : \u03b1} {s : Set \u03b1} (ha : IsLUB s a) (hs : s.Nonempty) :\n    NeBot (\ud835\udcdd[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 : \u2200 {a : \u03b1} {s : Set \u03b1}, IsGLB s a \u2192 s.Nonempty \u2192 NeBot (\ud835\udcdd[s] a) :=\n  @IsLUB.nhdsWithin_neBot \u03b1\u1d52\u1d48 _ _ _\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_3 : LinearOrder.{u1} \u03b1] [_inst_5 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_3))))] {s : Set.{u1} \u03b1} {a : \u03b1} {f : Filter.{u1} \u03b1}, (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (upperBounds.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_3)))) s)) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s f) -> (forall [_inst_7 : Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) f (nhds.{u1} \u03b1 _inst_1 a))], IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_3)))) s a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_3 : LinearOrder.{u1} \u03b1] [_inst_5 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_3)))))] {s : Set.{u1} \u03b1} {a : \u03b1} {f : Filter.{u1} \u03b1}, (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) a (upperBounds.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_3))))) s)) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s f) -> (forall [_inst_7 : Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) f (nhds.{u1} \u03b1 _inst_1 a))], IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_3))))) s a)\nCase conversion may be inaccurate. Consider using '#align is_lub_of_mem_nhds isLUB_of_mem_nhds\u2093'. -/\ntheorem isLUB_of_mem_nhds {s : Set \u03b1} {a : \u03b1} {f : Filter \u03b1} (hsa : a \u2208 upperBounds s) (hsf : s \u2208 f)\n    [NeBot (f \u2293 \ud835\udcdd a)] : IsLUB s a :=\n  \u27e8hsa, fun b hb =>\n    not_lt.1 fun hba =>\n      have : s \u2229 { a | b < a } \u2208 f \u2293 \ud835\udcdd a := inter_mem_inf hsf (IsOpen.mem_nhds (isOpen_lt' _) hba)\n      let \u27e8x, \u27e8hxs, hxb\u27e9\u27e9 := Filter.nonempty_of_mem this\n      have : b < b := lt_of_lt_of_le hxb <| hb hxs\n      lt_irrefl b this\u27e9\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 \u03b1} {a : \u03b1} (hsa : a \u2208 upperBounds s) (hsf : a \u2208 closure s) :\n    IsLUB s a := by\n  rw [mem_closure_iff_clusterPt, ClusterPt, inf_comm] at hsf\n  haveI : (\ud835\udcdf s \u2293 \ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_3 : LinearOrder.{u1} \u03b1] [_inst_5 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_3))))] {s : Set.{u1} \u03b1} {a : \u03b1} {f : Filter.{u1} \u03b1}, (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (lowerBounds.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_3)))) s)) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s f) -> (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) f (nhds.{u1} \u03b1 _inst_1 a))) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_3)))) s a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_3 : LinearOrder.{u1} \u03b1] [_inst_5 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_3)))))] {s : Set.{u1} \u03b1} {a : \u03b1} {f : Filter.{u1} \u03b1}, (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) a (lowerBounds.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_3))))) s)) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s f) -> (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) f (nhds.{u1} \u03b1 _inst_1 a))) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_3))))) s a)\nCase conversion may be inaccurate. Consider using '#align is_glb_of_mem_nhds isGLB_of_mem_nhds\u2093'. -/\ntheorem isGLB_of_mem_nhds :\n    \u2200 {s : Set \u03b1} {a : \u03b1} {f : Filter \u03b1}, a \u2208 lowerBounds s \u2192 s \u2208 f \u2192 NeBot (f \u2293 \ud835\udcdd a) \u2192 IsGLB s a :=\n  @isLUB_of_mem_nhds \u03b1\u1d52\u1d48 _ _ _\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 \u03b1} {a : \u03b1} (hsa : a \u2208 lowerBounds s) (hsf : a \u2208 closure s) :\n    IsGLB s a :=\n  @isLUB_of_mem_closure \u03b1\u1d52\u1d48 _ _ _ 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 \u03b3] [TopologicalSpace \u03b3] [OrderClosedTopology \u03b3]\n    {f : \u03b1 \u2192 \u03b3} {s : Set \u03b1} {a : \u03b1} {b : \u03b3} (hf : MonotoneOn f s) (ha : IsLUB s a)\n    (hb : Tendsto f (\ud835\udcdd[s] a) (\ud835\udcdd b)) : b \u2208 upperBounds (f '' s) :=\n  by\n  rintro _ \u27e8x, hx, rfl\u27e9\n  replace ha := ha.inter_Ici_of_mem hx\n  haveI := ha.nhds_within_ne_bot \u27e8x, hx, le_rfl\u27e9\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 `\u03b1` is as `x : \u03b1`\n-- tends to infinity, rather than tending to a point `x` in `\u03b1`, see `is_lub_of_tendsto_at_top`\ntheorem IsLUB.isLUB_of_tendsto [Preorder \u03b3] [TopologicalSpace \u03b3] [OrderClosedTopology \u03b3] {f : \u03b1 \u2192 \u03b3}\n    {s : Set \u03b1} {a : \u03b1} {b : \u03b3} (hf : MonotoneOn f s) (ha : IsLUB s a) (hs : s.Nonempty)\n    (hb : Tendsto f (\ud835\udcdd[s] a) (\ud835\udcdd b)) : IsLUB (f '' s) b :=\n  haveI := ha.nhds_within_ne_bot hs\n  \u27e8ha.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)\u27e9\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 \u03b3] [TopologicalSpace \u03b3] [OrderClosedTopology \u03b3]\n    {f : \u03b1 \u2192 \u03b3} {s : Set \u03b1} {a : \u03b1} {b : \u03b3} (hf : MonotoneOn f s) (ha : IsGLB s a)\n    (hb : Tendsto f (\ud835\udcdd[s] a) (\ud835\udcdd b)) : b \u2208 lowerBounds (f '' s) :=\n  @IsLUB.mem_upperBounds_of_tendsto \u03b1\u1d52\u1d48 \u03b3\u1d52\u1d48 _ _ _ _ _ _ _ _ _ _ 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 `\u03b1` is as\n-- `x : \u03b1` tends to negative infinity, rather than tending to a point `x` in `\u03b1`, see\n-- `is_glb_of_tendsto_at_bot`\ntheorem IsGLB.isGLB_of_tendsto [Preorder \u03b3] [TopologicalSpace \u03b3] [OrderClosedTopology \u03b3] {f : \u03b1 \u2192 \u03b3}\n    {s : Set \u03b1} {a : \u03b1} {b : \u03b3} (hf : MonotoneOn f s) :\n    IsGLB s a \u2192 s.Nonempty \u2192 Tendsto f (\ud835\udcdd[s] a) (\ud835\udcdd b) \u2192 IsGLB (f '' s) b :=\n  @IsLUB.isLUB_of_tendsto \u03b1\u1d52\u1d48 \u03b3\u1d52\u1d48 _ _ _ _ _ _ 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 \u03b3] [TopologicalSpace \u03b3] [OrderClosedTopology \u03b3]\n    {f : \u03b1 \u2192 \u03b3} {s : Set \u03b1} {a : \u03b1} {b : \u03b3} (hf : AntitoneOn f s) (ha : IsLUB s a)\n    (hb : Tendsto f (\ud835\udcdd[s] a) (\ud835\udcdd b)) : b \u2208 lowerBounds (f '' s) :=\n  @IsLUB.mem_upperBounds_of_tendsto \u03b1 \u03b3\u1d52\u1d48 _ _ _ _ _ _ _ _ _ _ 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 \u03b3] [TopologicalSpace \u03b3] [OrderClosedTopology \u03b3] :\n    \u2200 {f : \u03b1 \u2192 \u03b3} {s : Set \u03b1} {a : \u03b1} {b : \u03b3},\n      AntitoneOn f s \u2192 IsLUB s a \u2192 s.Nonempty \u2192 Tendsto f (\ud835\udcdd[s] a) (\ud835\udcdd b) \u2192 IsGLB (f '' s) b :=\n  @IsLUB.isLUB_of_tendsto \u03b1 \u03b3\u1d52\u1d48 _ _ _ _ _ _\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 \u03b3] [TopologicalSpace \u03b3] [OrderClosedTopology \u03b3]\n    {f : \u03b1 \u2192 \u03b3} {s : Set \u03b1} {a : \u03b1} {b : \u03b3} (hf : AntitoneOn f s) (ha : IsGLB s a)\n    (hb : Tendsto f (\ud835\udcdd[s] a) (\ud835\udcdd b)) : b \u2208 upperBounds (f '' s) :=\n  @IsGLB.mem_lowerBounds_of_tendsto \u03b1 \u03b3\u1d52\u1d48 _ _ _ _ _ _ _ _ _ _ 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 \u03b3] [TopologicalSpace \u03b3] [OrderClosedTopology \u03b3] :\n    \u2200 {f : \u03b1 \u2192 \u03b3} {s : Set \u03b1} {a : \u03b1} {b : \u03b3},\n      AntitoneOn f s \u2192 IsGLB s a \u2192 s.Nonempty \u2192 Tendsto f (\ud835\udcdd[s] a) (\ud835\udcdd b) \u2192 IsLUB (f '' s) b :=\n  @IsGLB.isGLB_of_tendsto \u03b1 \u03b3\u1d52\u1d48 _ _ _ _ _ _\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 : \u03b1} {s : Set \u03b1} (ha : IsLUB s a) (hs : s.Nonempty)\n    (sc : IsClosed s) : a \u2208 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 \u2190 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 : \u03b1} {s : Set \u03b1} (ha : IsGLB s a) (hs : s.Nonempty)\n    (sc : IsClosed s) : a \u2208 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 \u2190 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 \u03b1} {x : \u03b1}\n    [IsCountablyGenerated (\ud835\udcdd x)] (htx : IsLUB t x) (not_mem : x \u2209 t) (ht : t.Nonempty) :\n    \u2203 u : \u2115 \u2192 \u03b1, StrictMono u \u2227 (\u2200 n, u n < x) \u2227 Tendsto u atTop (\ud835\udcdd x) \u2227 \u2200 n, u n \u2208 t :=\n  by\n  rcases ht with \u27e8l, hl\u27e9\n  have hl : l < x := (htx.1 hl).eq_or_lt.resolve_left fun h => (not_mem <| h \u25b8 hl).elim\n  obtain \u27e8s, hs\u27e9 : \u2203 s : \u2115 \u2192 Set \u03b1, (\ud835\udcdd x).HasBasis (fun _x : \u2115 => True) s :=\n    let \u27e8s, hs\u27e9 := (\ud835\udcdd x).exists_antitone_basis\n    \u27e8s, hs.to_hasBasis\u27e9\n  have : \u2200 n k, k < x \u2192 \u2203 y, Icc y x \u2286 s n \u2227 k < y \u2227 y < x \u2227 y \u2208 t :=\n    by\n    intro n k hk\n    obtain \u27e8L, hL, h\u27e9 : \u2203 (L : \u03b1)(hL : L \u2208 Ico k x), Ioc L x \u2286 s n :=\n      exists_Ioc_subset_of_mem_nhds' (hs.mem_of_mem trivial) hk\n    obtain \u27e8y, hy\u27e9 : \u2203 y : \u03b1, L < y \u2227 y < x \u2227 y \u2208 t :=\n      by\n      rcases htx.exists_between' not_mem hL.2 with \u27e8y, yt, hy\u27e9\n      refine' \u27e8y, hy.1, hy.2, yt\u27e9\n    exact \u27e8y, fun z hz => h \u27e8hy.1.trans_le hz.1, hz.2\u27e9, hL.1.trans_lt hy.1, hy.2\u27e9\n  choose! f hf using this\n  let u : \u2115 \u2192 \u03b1 := fun n => Nat.recOn n (f 0 l) fun n h => f n.succ h\n  have I : \u2200 n, u n < x := by\n    intro n\n    induction' n with n IH\n    \u00b7 exact (hf 0 l hl).2.2.1\n    \u00b7 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' \u27e8u, S, I, hs.tendsto_right_iff.2 fun n _ => _, fun n => _\u27e9\n  \u00b7 simp only [ge_iff_le, eventually_at_top]\n    refine' \u27e8n, fun p hp => _\u27e9\n    have up : u p \u2208 Icc (u n) x := \u27e8S.monotone hp, (I p).le\u27e9\n    have : Icc (u n) x \u2286 s n := by\n      cases n\n      \u00b7 exact (hf 0 l hl).1\n      \u00b7 exact (hf n.succ (u n) (I n)).1\n    exact this up\n  \u00b7 cases n\n    \u00b7 exact (hf 0 l hl).2.2.2\n    \u00b7 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 \u03b1} {x : \u03b1} [IsCountablyGenerated (\ud835\udcdd x)]\n    (htx : IsLUB t x) (ht : t.Nonempty) :\n    \u2203 u : \u2115 \u2192 \u03b1, Monotone u \u2227 (\u2200 n, u n \u2264 x) \u2227 Tendsto u atTop (\ud835\udcdd x) \u2227 \u2200 n, u n \u2208 t :=\n  by\n  by_cases h : x \u2208 t\n  \u00b7 exact \u27e8fun n => x, monotone_const, fun n => le_rfl, tendsto_const_nhds, fun n => h\u27e9\n  \u00b7 rcases htx.exists_seq_strict_mono_tendsto_of_not_mem h ht with \u27e8u, hu\u27e9\n    exact \u27e8u, hu.1.Monotone, fun n => (hu.2.1 n).le, hu.2.2\u27e9\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' {\u03b1 : Type _} [LinearOrder \u03b1] [TopologicalSpace \u03b1]\n    [DenselyOrdered \u03b1] [OrderTopology \u03b1] [FirstCountableTopology \u03b1] {x y : \u03b1} (hy : y < x) :\n    \u2203 u : \u2115 \u2192 \u03b1, StrictMono u \u2227 (\u2200 n, u n \u2208 Ioo y x) \u2227 Tendsto u atTop (\ud835\udcdd x) :=\n  by\n  have hx : x \u2209 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 \u27e8u, hu\u27e9\n  exact \u27e8u, hu.1, hu.2.2.symm\u27e9\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 \u03b1] [NoMinOrder \u03b1] [FirstCountableTopology \u03b1]\n    (x : \u03b1) : \u2203 u : \u2115 \u2192 \u03b1, StrictMono u \u2227 (\u2200 n, u n < x) \u2227 Tendsto u atTop (\ud835\udcdd x) :=\n  by\n  obtain \u27e8y, hy\u27e9 : \u2203 y, y < x := exists_lt x\n  rcases exists_seq_strictMono_tendsto' hy with \u27e8u, hu_mono, hu_mem, hux\u27e9\n  exact \u27e8u, hu_mono, fun n => (hu_mem n).2, hux\u27e9\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 \u03b1] [NoMinOrder \u03b1]\n    [FirstCountableTopology \u03b1] (x : \u03b1) :\n    \u2203 u : \u2115 \u2192 \u03b1, StrictMono u \u2227 (\u2200 n, u n < x) \u2227 Tendsto u atTop (\ud835\udcdd[<] x) :=\n  let \u27e8u, hu, hx, h\u27e9 := exists_seq_strictMono_tendsto x\n  \u27e8u, hu, hx, tendsto_nhdsWithin_mono_right (range_subset_iff.2 hx) <| tendsto_nhdsWithin_range.2 h\u27e9\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\u209b is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_7 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7)))))] [_inst_10 : TopologicalSpace.FirstCountableTopology.{u1} \u03b1 _inst_8] {S : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 S) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7))))) S) -> (Exists.{succ u1} (Nat -> \u03b1) (fun (u : Nat -> \u03b1) => And (Monotone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7))))) u) (And (Filter.Tendsto.{0, u1} Nat \u03b1 u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (nhds.{u1} \u03b1 _inst_8 (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7)) S))) (forall (n : Nat), Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (u n) S))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_7 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7)))))] [_inst_10 : TopologicalSpace.FirstCountableTopology.{u1} \u03b1 _inst_8] {S : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 S) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7))))) S) -> (Exists.{succ u1} (Nat -> \u03b1) (fun (u : Nat -> \u03b1) => And (Monotone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7))))) u) (And (Filter.Tendsto.{0, u1} Nat \u03b1 u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (nhds.{u1} \u03b1 _inst_8 (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7)) S))) (forall (n : Nat), Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (u n) S))))\nCase conversion may be inaccurate. Consider using '#align exists_seq_tendsto_Sup exists_seq_tendsto_sup\u209b\u2093'. -/\ntheorem exists_seq_tendsto_sup\u209b {\u03b1 : Type _} [ConditionallyCompleteLinearOrder \u03b1]\n    [TopologicalSpace \u03b1] [OrderTopology \u03b1] [FirstCountableTopology \u03b1] {S : Set \u03b1} (hS : S.Nonempty)\n    (hS' : BddAbove S) : \u2203 u : \u2115 \u2192 \u03b1, Monotone u \u2227 Tendsto u atTop (\ud835\udcdd (sup\u209b S)) \u2227 \u2200 n, u n \u2208 S :=\n  by\n  rcases(isLUB_csup\u209b hS hS').exists_seq_monotone_tendsto hS with \u27e8u, hu\u27e9\n  exact \u27e8u, hu.1, hu.2.2\u27e9\n#align exists_seq_tendsto_Sup exists_seq_tendsto_sup\u209b\n\n#print IsGLB.exists_seq_strictAnti_tendsto_of_not_mem /-\ntheorem IsGLB.exists_seq_strictAnti_tendsto_of_not_mem {t : Set \u03b1} {x : \u03b1}\n    [IsCountablyGenerated (\ud835\udcdd x)] (htx : IsGLB t x) (not_mem : x \u2209 t) (ht : t.Nonempty) :\n    \u2203 u : \u2115 \u2192 \u03b1, StrictAnti u \u2227 (\u2200 n, x < u n) \u2227 Tendsto u atTop (\ud835\udcdd x) \u2227 \u2200 n, u n \u2208 t :=\n  @IsLUB.exists_seq_strictMono_tendsto_of_not_mem \u03b1\u1d52\u1d48 _ _ _ 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 \u03b1} {x : \u03b1} [IsCountablyGenerated (\ud835\udcdd x)]\n    (htx : IsGLB t x) (ht : t.Nonempty) :\n    \u2203 u : \u2115 \u2192 \u03b1, Antitone u \u2227 (\u2200 n, x \u2264 u n) \u2227 Tendsto u atTop (\ud835\udcdd x) \u2227 \u2200 n, u n \u2208 t :=\n  @IsLUB.exists_seq_monotone_tendsto \u03b1\u1d52\u1d48 _ _ _ 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 \u03b1] [FirstCountableTopology \u03b1] {x y : \u03b1}\n    (hy : x < y) : \u2203 u : \u2115 \u2192 \u03b1, StrictAnti u \u2227 (\u2200 n, u n \u2208 Ioo x y) \u2227 Tendsto u atTop (\ud835\udcdd 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 \u03b1] [NoMaxOrder \u03b1] [FirstCountableTopology \u03b1]\n    (x : \u03b1) : \u2203 u : \u2115 \u2192 \u03b1, StrictAnti u \u2227 (\u2200 n, x < u n) \u2227 Tendsto u atTop (\ud835\udcdd x) :=\n  @exists_seq_strictMono_tendsto \u03b1\u1d52\u1d48 _ _ _ _ _ _ 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 \u03b1] [NoMaxOrder \u03b1]\n    [FirstCountableTopology \u03b1] (x : \u03b1) :\n    \u2203 u : \u2115 \u2192 \u03b1, StrictAnti u \u2227 (\u2200 n, x < u n) \u2227 Tendsto u atTop (\ud835\udcdd[>] x) :=\n  @exists_seq_strictMono_tendsto_nhdsWithin \u03b1\u1d52\u1d48 _ _ _ _ _ _ _\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 \u03b1] [FirstCountableTopology \u03b1]\n    {x y : \u03b1} (h : x < y) :\n    \u2203 u v : \u2115 \u2192 \u03b1,\n      StrictAnti u \u2227\n        StrictMono v \u2227\n          (\u2200 k, u k \u2208 Ioo x y) \u2227\n            (\u2200 l, v l \u2208 Ioo x y) \u2227\n              (\u2200 k l, u k < v l) \u2227 Tendsto u atTop (\ud835\udcdd x) \u2227 Tendsto v atTop (\ud835\udcdd y) :=\n  by\n  rcases exists_seq_strictAnti_tendsto' h with \u27e8u, hu_anti, hu_mem, hux\u27e9\n  rcases exists_seq_strictMono_tendsto' (hu_mem 0).2 with \u27e8v, hv_mono, hv_mem, hvy\u27e9\n  exact\n    \u27e8u, v, hu_anti, hv_mono, hu_mem, fun l => \u27e8(hu_mem 0).1.trans (hv_mem l).1, (hv_mem l).2\u27e9,\n      fun k l => (hu_anti.antitone (zero_le k)).trans_lt (hv_mem l).1, hux, hvy\u27e9\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\u209b is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_7 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7)))))] [_inst_10 : TopologicalSpace.FirstCountableTopology.{u1} \u03b1 _inst_8] {S : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 S) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7))))) S) -> (Exists.{succ u1} (Nat -> \u03b1) (fun (u : Nat -> \u03b1) => And (Antitone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7))))) u) (And (Filter.Tendsto.{0, u1} Nat \u03b1 u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (nhds.{u1} \u03b1 _inst_8 (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7)) S))) (forall (n : Nat), Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (u n) S))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_7 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7)))))] [_inst_10 : TopologicalSpace.FirstCountableTopology.{u1} \u03b1 _inst_8] {S : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 S) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7))))) S) -> (Exists.{succ u1} (Nat -> \u03b1) (fun (u : Nat -> \u03b1) => And (Antitone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7))))) u) (And (Filter.Tendsto.{0, u1} Nat \u03b1 u (Filter.atTop.{0} Nat (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (nhds.{u1} \u03b1 _inst_8 (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_7)) S))) (forall (n : Nat), Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (u n) S))))\nCase conversion may be inaccurate. Consider using '#align exists_seq_tendsto_Inf exists_seq_tendsto_inf\u209b\u2093'. -/\ntheorem exists_seq_tendsto_inf\u209b {\u03b1 : Type _} [ConditionallyCompleteLinearOrder \u03b1]\n    [TopologicalSpace \u03b1] [OrderTopology \u03b1] [FirstCountableTopology \u03b1] {S : Set \u03b1} (hS : S.Nonempty)\n    (hS' : BddBelow S) : \u2203 u : \u2115 \u2192 \u03b1, Antitone u \u2227 Tendsto u atTop (\ud835\udcdd (inf\u209b S)) \u2227 \u2200 n, u n \u2208 S :=\n  @exists_seq_tendsto_sup\u209b \u03b1\u1d52\u1d48 _ _ _ _ S hS hS'\n#align exists_seq_tendsto_Inf exists_seq_tendsto_inf\u209b\n\nend OrderTopology\n\nsection DenselyOrdered\n\nvariable [TopologicalSpace \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [DenselyOrdered \u03b1] {a b : \u03b1}\n  {s : Set \u03b1}\n\n#print closure_Ioi' /-\n/-- The closure of the interval `(a, +\u221e)` is the closed interval `[a, +\u221e)`, unless `a` is a top\nelement. -/\ntheorem closure_Ioi' {a : \u03b1} (h : (Ioi a).Nonempty) : closure (Ioi a) = Ici a :=\n  by\n  apply subset.antisymm\n  \u00b7 exact closure_minimal Ioi_subset_Ici_self isClosed_Ici\n  \u00b7 rw [\u2190 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, +\u221e)` is the closed interval `[a, +\u221e)`. -/\n@[simp]\ntheorem closure_Ioi (a : \u03b1) [NoMaxOrder \u03b1] : 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 `(-\u221e, a)` is the closed interval `(-\u221e, a]`, unless `a` is a bottom\nelement. -/\ntheorem closure_Iio' (h : (Iio a).Nonempty) : closure (Iio a) = Iic a :=\n  @closure_Ioi' \u03b1\u1d52\u1d48 _ _ _ _ _ h\n#align closure_Iio' closure_Iio'\n-/\n\n#print closure_Iio /-\n/-- The closure of the interval `(-\u221e, a)` is the interval `(-\u221e, a]`. -/\n@[simp]\ntheorem closure_Iio (a : \u03b1) [NoMinOrder \u03b1] : 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 : \u03b1} (hab : a \u2260 b) : closure (Ioo a b) = Icc a b :=\n  by\n  apply subset.antisymm\n  \u00b7 exact closure_minimal Ioo_subset_Icc_self isClosed_Icc\n  \u00b7 cases' hab.lt_or_lt with hab hab\n    \u00b7 rw [\u2190 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 \u27e8(isGLB_Ioo hab).mem_closure hab', (isLUB_Ioo hab).mem_closure hab'\u27e9\n    \u00b7 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 : \u03b1} (hab : a \u2260 b) : closure (Ioc a b) = Icc a b :=\n  by\n  apply subset.antisymm\n  \u00b7 exact closure_minimal Ioc_subset_Icc_self isClosed_Icc\n  \u00b7 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 : \u03b1} (hab : a \u2260 b) : closure (Ico a b) = Icc a b :=\n  by\n  apply subset.antisymm\n  \u00b7 exact closure_minimal Ico_subset_Icc_self isClosed_Icc\n  \u00b7 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 : \u03b1} (ha : (Iio a).Nonempty) : interior (Ici a) = Ioi a := by\n  rw [\u2190 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 \u03b1] {a : \u03b1} : 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 : \u03b1} (ha : (Ioi a).Nonempty) : interior (Iic a) = Iio a :=\n  @interior_Ici' \u03b1\u1d52\u1d48 _ _ _ _ _ ha\n#align interior_Iic' interior_Iic'\n-/\n\n#print interior_Iic /-\ntheorem interior_Iic [NoMaxOrder \u03b1] {a : \u03b1} : 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 \u03b1] [NoMaxOrder \u03b1] {a b : \u03b1} : interior (Icc a b) = Ioo a b := by\n  rw [\u2190 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 \u03b1] {a b : \u03b1} : interior (Ico a b) = Ioo a b := by\n  rw [\u2190 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 \u03b1] {a b : \u03b1} : interior (Ioc a b) = Ioo a b := by\n  rw [\u2190 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 : \u03b1} (h : a \u2260 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      _ \u2286 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 : \u03b1) : Ioc a b \u2286 closure (interior (Ioc a b)) :=\n  by\n  rcases eq_or_ne a b with (rfl | h)\n  \u00b7 simp\n  \u00b7\n    calc\n      Ioc a b \u2286 Icc a b := Ioc_subset_Icc_self\n      _ = closure (Ioo a b) := (closure_Ioo h).symm\n      _ \u2286 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 : \u03b1) : Ico a b \u2286 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 : \u03b1} (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 \u03b1] {a : \u03b1} : 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 : \u03b1} (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 \u03b1] {a : \u03b1} : 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 : \u03b1} (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 \u03b1] {a : \u03b1} : 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 : \u03b1} (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 \u03b1] {a : \u03b1} : 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 \u03b1] [NoMaxOrder \u03b1] {a b : \u03b1} (h : a \u2264 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 : \u03b1} (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 \u03b1] {a b : \u03b1} (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 \u03b1] {a b : \u03b1} (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 : \u03b1} (H\u2081 : (Ioi a).Nonempty) (H\u2082 : a \u2264 b) : NeBot (\ud835\udcdd[Ioi a] b) :=\n  mem_closure_iff_nhdsWithin_neBot.1 <| by rwa [closure_Ioi' H\u2081]\n#align nhds_within_Ioi_ne_bot' nhdsWithin_Ioi_neBot'\n-/\n\n#print nhdsWithin_Ioi_neBot /-\ntheorem nhdsWithin_Ioi_neBot [NoMaxOrder \u03b1] {a b : \u03b1} (H : a \u2264 b) : NeBot (\ud835\udcdd[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 : \u03b1} (H : (Ioi a).Nonempty) : NeBot (\ud835\udcdd[>] 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 \u03b1] (a : \u03b1) : NeBot (\ud835\udcdd[>] 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {p : \u03b1 -> Prop}, (Filter.Eventually.{u1} \u03b1 (fun (x : \u03b1) => p x) (nhds.{u1} \u03b1 _inst_1 a)) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => Exists.{0} (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) (fun (H : GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) => p b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_5 : NoMaxOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {p : \u03b1 -> Prop}, (Filter.Eventually.{u1} \u03b1 (fun (x : \u03b1) => p x) (nhds.{u1} \u03b1 _inst_1 a)) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) b a) (p b)))\nCase conversion may be inaccurate. Consider using '#align filter.eventually.exists_gt Filter.Eventually.exists_gt\u2093'. -/\ntheorem Filter.Eventually.exists_gt [NoMaxOrder \u03b1] {a : \u03b1} {p : \u03b1 \u2192 Prop} (h : \u2200\u1da0 x in \ud835\udcdd a, p x) :\n    \u2203 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 : \u03b1} (H\u2081 : (Iio c).Nonempty) (H\u2082 : b \u2264 c) : NeBot (\ud835\udcdd[Iio c] b) :=\n  mem_closure_iff_nhdsWithin_neBot.1 <| by rwa [closure_Iio' H\u2081]\n#align nhds_within_Iio_ne_bot' nhdsWithin_Iio_neBot'\n-/\n\n#print nhdsWithin_Iio_neBot /-\ntheorem nhdsWithin_Iio_neBot [NoMinOrder \u03b1] {a b : \u03b1} (H : a \u2264 b) : NeBot (\ud835\udcdd[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 : \u03b1} (H : (Iio b).Nonempty) : NeBot (\ud835\udcdd[<] 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 \u03b1] (a : \u03b1) : NeBot (\ud835\udcdd[<] 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {p : \u03b1 -> Prop}, (Filter.Eventually.{u1} \u03b1 (fun (x : \u03b1) => p x) (nhds.{u1} \u03b1 _inst_1 a)) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => Exists.{0} (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) => p b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_5 : NoMinOrder.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {p : \u03b1 -> Prop}, (Filter.Eventually.{u1} \u03b1 (fun (x : \u03b1) => p x) (nhds.{u1} \u03b1 _inst_1 a)) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) b a) (p b)))\nCase conversion may be inaccurate. Consider using '#align filter.eventually.exists_lt Filter.Eventually.exists_lt\u2093'. -/\ntheorem Filter.Eventually.exists_lt [NoMinOrder \u03b1] {a : \u03b1} {p : \u03b1 \u2192 Prop} (h : \u2200\u1da0 x in \ud835\udcdd a, p x) :\n    \u2203 b < a, p b :=\n  @Filter.Eventually.exists_gt \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ 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 : \u03b1} (H : a < b) : NeBot (\ud835\udcdd[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 : \u03b1} (H : a < b) : NeBot (\ud835\udcdd[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 : \u03b1} (H : a < b) : NeBot (\ud835\udcdd[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 : \u03b1} (H : a < b) : NeBot (\ud835\udcdd[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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {b : \u03b1} {s : Set.{u1} \u03b1}, (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b)) -> ((Set.Nonempty.{u1} \u03b1 s) -> (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Exists.{0} (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)) (Filter.comap.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 ((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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))))) (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b))) (Filter.atTop.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {b : \u03b1} {s : Set.{u1} \u03b1}, (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b)) -> ((Set.Nonempty.{u1} \u03b1 s) -> (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s))) (Filter.comap.{u1, u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) \u03b1 (Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b))) (Filter.atTop.{u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) 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\u2093'. -/\ntheorem comap_coe_nhdsWithin_Iio_of_Ioo_subset (hb : s \u2286 Iio b)\n    (hs : s.Nonempty \u2192 \u2203 a < b, Ioo a b \u2286 s) : comap (coe : s \u2192 \u03b1) (\ud835\udcdd[<] b) = atTop :=\n  by\n  nontriviality\n  haveI : Nonempty s := nontrivial_iff_nonempty.1 \u2039_\u203a\n  rcases hs (nonempty_subtype.1 \u2039_\u203a) with \u27e8a, h, hs\u27e9\n  ext u; constructor\n  \u00b7 rintro \u27e8t, ht, hts\u27e9\n    obtain \u27e8x, \u27e8hxa : a \u2264 x, hxb : x < b\u27e9, hxt : Ioo x b \u2286 t\u27e9 :=\n      (mem_nhdsWithin_Iio_iff_exists_mem_Ico_Ioo_subset h).mp ht\n    obtain \u27e8y, hxy, hyb\u27e9 := exists_between hxb\n    refine' mem_of_superset (mem_at_top \u27e8y, hs \u27e8hxa.trans_lt hxy, hyb\u27e9\u27e9) _\n    rintro \u27e8z, hzs\u27e9 (hyz : y \u2264 z)\n    refine' hts (hxt \u27e8hxy.trans_le _, hb _\u27e9) <;> assumption\n  \u00b7 intro hu\n    obtain \u27e8x : s, hx : \u2200 z, x \u2264 z \u2192 z \u2208 u\u27e9 := mem_at_top_sets.1 hu\n    exact \u27e8Ioo x b, Ioo_mem_nhdsWithin_Iio (right_mem_Ioc.2 <| hb x.2), fun z hz => hx _ hz.1.le\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) -> ((Set.Nonempty.{u1} \u03b1 s) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => Exists.{0} (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) (fun (H : GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)) (Filter.comap.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 ((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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))))) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a))) (Filter.atBot.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) -> ((Set.Nonempty.{u1} \u03b1 s) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) b a) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s))) (Filter.comap.{u1, u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) \u03b1 (Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a))) (Filter.atBot.{u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) 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\u2093'. -/\ntheorem comap_coe_nhdsWithin_Ioi_of_Ioo_subset (ha : s \u2286 Ioi a)\n    (hs : s.Nonempty \u2192 \u2203 b > a, Ioo a b \u2286 s) : comap (coe : s \u2192 \u03b1) (\ud835\udcdd[>] a) = atBot :=\n  comap_coe_nhdsWithin_Iio_of_Ioo_subset (show ofDual \u207b\u00b9' s \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {b : \u03b1} {s : Set.{u1} \u03b1}, (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b)) -> (forall (a' : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a' b) -> (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Exists.{0} (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) (fun (H : LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) a b) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (Filter.map.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 ((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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))))) (Filter.atTop.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))) (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {b : \u03b1} {s : Set.{u1} \u03b1}, (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b)) -> (forall (a' : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a' b) -> (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) a b) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (Filter.map.{u1, u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) \u03b1 (Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) (Filter.atTop.{u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)))) (nhdsWithin.{u1} \u03b1 _inst_1 b (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) b)))\nCase conversion may be inaccurate. Consider using '#align map_coe_at_top_of_Ioo_subset map_coe_atTop_of_Ioo_subset\u2093'. -/\ntheorem map_coe_atTop_of_Ioo_subset (hb : s \u2286 Iio b) (hs : \u2200 a' < b, \u2203 a < b, Ioo a b \u2286 s) :\n    map (coe : s \u2192 \u03b1) atTop = \ud835\udcdd[<] b :=\n  by\n  rcases eq_empty_or_nonempty (Iio b) with (hb' | \u27e8a, ha\u27e9)\n  \u00b7 rw [filter_eq_bot_of_is_empty at_top, Filter.map_bot, hb', nhdsWithin_empty]\n    exact \u27e8fun x => hb'.subset (hb x.2)\u27e9\n  \u00b7 rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)) -> (forall (b' : \u03b1), (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b' a) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => Exists.{0} (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) (fun (H : GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) b a) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (Filter.map.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 ((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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))))) (Filter.atBot.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] {a : \u03b1} {s : Set.{u1} \u03b1}, (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)) -> (forall (b' : \u03b1), (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) b' a) -> (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) b a) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a b) s)))) -> (Eq.{succ u1} (Filter.{u1} \u03b1) (Filter.map.{u1, u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) \u03b1 (Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) (Filter.atBot.{u1} (Subtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)))) (nhdsWithin.{u1} \u03b1 _inst_1 a (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))) a)))\nCase conversion may be inaccurate. Consider using '#align map_coe_at_bot_of_Ioo_subset map_coe_atBot_of_Ioo_subset\u2093'. -/\ntheorem map_coe_atBot_of_Ioo_subset (ha : s \u2286 Ioi a) (hs : \u2200 b' > a, \u2203 b > a, Ioo a b \u2286 s) :\n    map (coe : s \u2192 \u03b1) atBot = \ud835\udcdd[>] a :=\n  by\n  -- the elaborator gets stuck without `(... : _)`\n  refine'\n    (map_coe_atTop_of_Ioo_subset (show of_dual \u207b\u00b9' s \u2286 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 : \u03b1) : comap (coe : Ioo a b \u2192 \u03b1) (\ud835\udcdd[<] b) = atTop :=\n  comap_coe_nhdsWithin_Iio_of_Ioo_subset Ioo_subset_Iio_self fun h =>\n    \u27e8a, nonempty_Ioo.1 h, Subset.refl _\u27e9\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 : \u03b1) : comap (coe : Ioo a b \u2192 \u03b1) (\ud835\udcdd[>] a) = atBot :=\n  comap_coe_nhdsWithin_Ioi_of_Ioo_subset Ioo_subset_Ioi_self fun h =>\n    \u27e8b, nonempty_Ioo.1 h, Subset.refl _\u27e9\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 : \u03b1) : comap (coe : Ioi a \u2192 \u03b1) (\ud835\udcdd[>] a) = atBot :=\n  comap_coe_nhdsWithin_Ioi_of_Ioo_subset (Subset.refl _) fun \u27e8x, hx\u27e9 => \u27e8x, hx, Ioo_subset_Ioi_self\u27e9\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 : \u03b1) : comap (coe : Iio a \u2192 \u03b1) (\ud835\udcdd[<] a) = atTop :=\n  @comap_coe_Ioi_nhdsWithin_Ioi \u03b1\u1d52\u1d48 _ _ _ _ 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 : \u03b1} (h : a < b) : map (coe : Ioo a b \u2192 \u03b1) atTop = \ud835\udcdd[<] b :=\n  map_coe_atTop_of_Ioo_subset Ioo_subset_Iio_self fun _ _ => \u27e8_, h, Subset.refl _\u27e9\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 : \u03b1} (h : a < b) : map (coe : Ioo a b \u2192 \u03b1) atBot = \ud835\udcdd[>] a :=\n  map_coe_atBot_of_Ioo_subset Ioo_subset_Ioi_self fun _ _ => \u27e8_, h, Subset.refl _\u27e9\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 : \u03b1) : map (coe : Ioi a \u2192 \u03b1) atBot = \ud835\udcdd[>] a :=\n  map_coe_atBot_of_Ioo_subset (Subset.refl _) fun b hb => \u27e8b, hb, Ioo_subset_Ioi_self\u27e9\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 : \u03b1) : map (coe : Iio a \u2192 \u03b1) atTop = \ud835\udcdd[<] a :=\n  @map_coe_Ioi_atBot \u03b1\u1d52\u1d48 _ _ _ _ _\n#align map_coe_Iio_at_top map_coe_Iio_atTop\n-/\n\nvariable {l : Filter \u03b2} {f : \u03b1 \u2192 \u03b2}\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 \u2194 Tendsto f (\ud835\udcdd[<] b) l := by\n  rw [\u2190 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 \u2194 Tendsto f (\ud835\udcdd[>] a) l := by\n  rw [\u2190 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 \u2194 Tendsto f (\ud835\udcdd[>] a) l := by\n  rw [\u2190 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 \u2194 Tendsto f (\ud835\udcdd[<] a) l := by\n  rw [\u2190 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 : \u03b2 \u2192 Ioo a b} :\n    Tendsto f l atTop \u2194 Tendsto (fun x => (f x : \u03b1)) l (\ud835\udcdd[<] b) := by\n  rw [\u2190 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 : \u03b2 \u2192 Ioo a b} :\n    Tendsto f l atBot \u2194 Tendsto (fun x => (f x : \u03b1)) l (\ud835\udcdd[>] a) := by\n  rw [\u2190 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 : \u03b2 \u2192 Ioi a} :\n    Tendsto f l atBot \u2194 Tendsto (fun x => (f x : \u03b1)) l (\ud835\udcdd[>] a) := by\n  rw [\u2190 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 : \u03b2 \u2192 Iio a} :\n    Tendsto f l atTop \u2194 Tendsto (fun x => (f x : \u03b1)) l (\ud835\udcdd[<] a) := by\n  rw [\u2190 comap_coe_Iio_nhdsWithin_Iio, tendsto_comap_iff]\n#align tendsto_Iio_at_top tendsto_Iio_atTop\n-/\n\ninstance (x : \u03b1) [Nontrivial \u03b1] : NeBot (\ud835\udcdd[\u2260] x) :=\n  by\n  apply forall_mem_nonempty_iff_ne_bot.1 fun s hs => _\n  obtain \u27e8u, u_open, xu, us\u27e9 : \u2203 u : Set \u03b1, IsOpen u \u2227 x \u2208 u \u2227 u \u2229 {x}\u1d9c \u2286 s := mem_nhdsWithin.1 hs\n  obtain \u27e8a, b, a_lt_b, hab\u27e9 : \u2203 a b : \u03b1, a < b \u2227 Ioo a b \u2286 u := u_open.exists_Ioo_subset \u27e8x, xu\u27e9\n  obtain \u27e8y, hy\u27e9 : \u2203 y, a < y \u2227 y < b := exists_between a_lt_b\n  rcases ne_or_eq x y with (xy | rfl)\n  \u00b7 exact \u27e8y, us \u27e8hab hy, xy.symm\u27e9\u27e9\n  obtain \u27e8z, hz\u27e9 : \u2203 z, a < z \u2227 z < x := exists_between hy.1\n  exact \u27e8z, us \u27e8hab \u27e8hz.1, hz.2.trans hy.2\u27e9, hz.2.Ne\u27e9\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2)))))] [_inst_5 : Nontrivial.{u1} \u03b1] {s : Set.{u1} \u03b1} [_inst_6 : TopologicalSpace.SeparableSpace.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.topologicalSpace.{u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) _inst_1)], (Dense.{u1} \u03b1 _inst_1 s) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (t : Set.{u1} \u03b1) => Exists.{0} (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) t s) (fun (H : HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) t s) => And (Set.Countable.{u1} \u03b1 t) (And (Dense.{u1} \u03b1 _inst_1 t) (And (forall (x : \u03b1), (IsBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x) -> (Not (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x t))) (forall (x : \u03b1), (IsTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_2))))) x) -> (Not (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x t))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : LinearOrder.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))] [_inst_4 : DenselyOrdered.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2))))))] [_inst_5 : Nontrivial.{u1} \u03b1] {s : Set.{u1} \u03b1} [_inst_6 : TopologicalSpace.SeparableSpace.{u1} (Set.Elem.{u1} \u03b1 s) (instTopologicalSpaceSubtype.{u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) _inst_1)], (Dense.{u1} \u03b1 _inst_1 s) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (t : Set.{u1} \u03b1) => And (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) t s) (And (Set.Countable.{u1} \u03b1 t) (And (Dense.{u1} \u03b1 _inst_1 t) (And (forall (x : \u03b1), (IsBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x) -> (Not (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x t))) (forall (x : \u03b1), (IsTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_2)))))) x) -> (Not (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) 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\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t \u00abexpr \u2286 \u00bb s) -/\n/-- Let `s` be a dense set in a nontrivial dense linear order `\u03b1`. If `s` is a\nseparable space (e.g., if `\u03b1` has a second countable topology), then there exists a countable\ndense subset `t \u2286 s` such that `t` does not contain bottom/top elements of `\u03b1`. -/\ntheorem Dense.exists_countable_dense_subset_no_bot_top [Nontrivial \u03b1] {s : Set \u03b1} [SeparableSpace s]\n    (hs : Dense s) :\n    \u2203 (t : _)(_ : t \u2286 s), t.Countable \u2227 Dense t \u2227 (\u2200 x, IsBot x \u2192 x \u2209 t) \u2227 \u2200 x, IsTop x \u2192 x \u2209 t :=\n  by\n  rcases hs.exists_countable_dense_subset with \u27e8t, hts, htc, htd\u27e9\n  refine' \u27e8t \\ ({ x | IsBot x } \u222a { x | IsTop x }), _, _, _, _, _\u27e9\n  \u00b7 exact (diff_subset _ _).trans hts\n  \u00b7 exact htc.mono (diff_subset _ _)\n  \u00b7 exact htd.diff_finite ((subsingleton_is_bot \u03b1).Finite.union (subsingleton_is_top \u03b1).Finite)\n  \u00b7 intro x hx\n    simp [hx]\n  \u00b7 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 (\u03b1)\n\n#print exists_countable_dense_no_bot_top /-\n/-- If `\u03b1` is a nontrivial separable dense linear order, then there exists a\ncountable dense set `s : set \u03b1` that contains neither top nor bottom elements of `\u03b1`.\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 \u03b1] [Nontrivial \u03b1] :\n    \u2203 s : Set \u03b1, s.Countable \u2227 Dense s \u2227 (\u2200 x, IsBot x \u2192 x \u2209 s) \u2227 \u2200 x, IsTop x \u2192 x \u2209 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 \u03b1] [TopologicalSpace \u03b1] [OrderTopology \u03b1] [CompleteLinearOrder \u03b2]\n  [TopologicalSpace \u03b2] [OrderClosedTopology \u03b2] [Nonempty \u03b3]\n\n/- warning: Sup_mem_closure -> sup\u209b_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : CompleteLinearOrder.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))) s) (closure.{u1} \u03b1 _inst_8 s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : CompleteLinearOrder.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_9)))) s) (closure.{u1} \u03b1 _inst_8 s))\nCase conversion may be inaccurate. Consider using '#align Sup_mem_closure sup\u209b_mem_closure\u2093'. -/\ntheorem sup\u209b_mem_closure {\u03b1 : Type u} [TopologicalSpace \u03b1] [CompleteLinearOrder \u03b1] [OrderTopology \u03b1]\n    {s : Set \u03b1} (hs : s.Nonempty) : sup\u209b s \u2208 closure s :=\n  (isLUB_sup\u209b s).mem_closure hs\n#align Sup_mem_closure sup\u209b_mem_closure\n\n/- warning: Inf_mem_closure -> inf\u209b_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : CompleteLinearOrder.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))) s) (closure.{u1} \u03b1 _inst_8 s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : CompleteLinearOrder.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_9)))) s) (closure.{u1} \u03b1 _inst_8 s))\nCase conversion may be inaccurate. Consider using '#align Inf_mem_closure inf\u209b_mem_closure\u2093'. -/\ntheorem inf\u209b_mem_closure {\u03b1 : Type u} [TopologicalSpace \u03b1] [CompleteLinearOrder \u03b1] [OrderTopology \u03b1]\n    {s : Set \u03b1} (hs : s.Nonempty) : inf\u209b s \u2208 closure s :=\n  (isGLB_inf\u209b s).mem_closure hs\n#align Inf_mem_closure inf\u209b_mem_closure\n\n/- warning: is_closed.Sup_mem -> IsClosed.sup\u209b_mem is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : CompleteLinearOrder.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (IsClosed.{u1} \u03b1 _inst_8 s) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))) s) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : CompleteLinearOrder.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (IsClosed.{u1} \u03b1 _inst_8 s) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_9)))) s) s)\nCase conversion may be inaccurate. Consider using '#align is_closed.Sup_mem IsClosed.sup\u209b_mem\u2093'. -/\ntheorem IsClosed.sup\u209b_mem {\u03b1 : Type u} [TopologicalSpace \u03b1] [CompleteLinearOrder \u03b1]\n    [OrderTopology \u03b1] {s : Set \u03b1} (hs : s.Nonempty) (hc : IsClosed s) : sup\u209b s \u2208 s :=\n  (isLUB_sup\u209b s).mem_of_isClosed hs hc\n#align is_closed.Sup_mem IsClosed.sup\u209b_mem\n\n/- warning: is_closed.Inf_mem -> IsClosed.inf\u209b_mem is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : CompleteLinearOrder.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (IsClosed.{u1} \u03b1 _inst_8 s) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))) s) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_8 : TopologicalSpace.{u1} \u03b1] [_inst_9 : CompleteLinearOrder.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_8 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_9))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (IsClosed.{u1} \u03b1 _inst_8 s) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_9)))) s) s)\nCase conversion may be inaccurate. Consider using '#align is_closed.Inf_mem IsClosed.inf\u209b_mem\u2093'. -/\ntheorem IsClosed.inf\u209b_mem {\u03b1 : Type u} [TopologicalSpace \u03b1] [CompleteLinearOrder \u03b1]\n    [OrderTopology \u03b1] {s : Set \u03b1} (hs : s.Nonempty) (hc : IsClosed s) : inf\u209b s \u2208 s :=\n  (isGLB_inf\u209b s).mem_of_isClosed hs hc\n#align is_closed.Inf_mem IsClosed.inf\u209b_mem\n\n/- warning: monotone.map_Sup_of_continuous_at' -> Monotone.map_sup\u209b_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_Sup_of_continuous_at' Monotone.map_sup\u209b_of_continuousAt'\u2093'. -/\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\u209b_of_continuousAt' {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (sup\u209b s))\n    (Mf : Monotone f) (hs : s.Nonempty) : f (sup\u209b s) = sup\u209b (f '' s) :=\n  ((--This is a particular case of the more general is_lub.is_lub_of_tendsto\n              isLUB_sup\u209b\n              _).isLUB_of_tendsto\n          (fun x hx y hy xy => Mf xy) hs <|\n        Cf.mono_left inf_le_left).sup\u209b_eq.symm\n#align monotone.map_Sup_of_continuous_at' Monotone.map_sup\u209b_of_continuousAt'\n\n/- warning: monotone.map_Sup_of_continuous_at -> Monotone.map_sup\u209b_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Bot.bot.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toHasBot.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) (Bot.bot.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toHasBot.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Bot.bot.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toBot.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) (Bot.bot.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toBot.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_Sup_of_continuous_at Monotone.map_sup\u209b_of_continuousAt\u2093'. -/\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\u209b_of_continuousAt {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (sup\u209b s))\n    (Mf : Monotone f) (fbot : f \u22a5 = \u22a5) : f (sup\u209b s) = sup\u209b (f '' s) :=\n  by\n  cases' s.eq_empty_or_nonempty with h h\n  \u00b7 simp [h, fbot]\n  \u00b7 exact Mf.map_Sup_of_continuous_at' Cf h\n#align monotone.map_Sup_of_continuous_at Monotone.map_sup\u209b_of_continuousAt\n\n/- warning: monotone.map_supr_of_continuous_at' -> Monotone.map_sup\u1d62_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {\u03b9 : Sort.{u3}} [_inst_8 : Nonempty.{u3} \u03b9] {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 (fun (i : \u03b9) => g i))) (sup\u1d62.{u2, u3} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) \u03b9 (fun (i : \u03b9) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} \u03b2] [_inst_5 : TopologicalSpace.{u3} \u03b2] [_inst_6 : OrderClosedTopology.{u3} \u03b2 _inst_5 (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4))))] {\u03b9 : Sort.{u1}} [_inst_8 : Nonempty.{u1} \u03b9] {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u2, u3} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) -> (Monotone.{u2, u3} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) f) -> (Eq.{succ u3} \u03b2 (f (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 (fun (i : \u03b9) => g i))) (sup\u1d62.{u3, u1} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u3} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) \u03b9 (fun (i : \u03b9) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_supr_of_continuous_at' Monotone.map_sup\u1d62_of_continuousAt'\u2093'. -/\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\u1d62_of_continuousAt' {\u03b9 : Sort _} [Nonempty \u03b9] {f : \u03b1 \u2192 \u03b2} {g : \u03b9 \u2192 \u03b1}\n    (Cf : ContinuousAt f (sup\u1d62 g)) (Mf : Monotone f) : f (\u2a06 i, g i) = \u2a06 i, f (g i) := by\n  rw [sup\u1d62, Mf.map_Sup_of_continuous_at' Cf (range_nonempty g), \u2190 range_comp, sup\u1d62]\n#align monotone.map_supr_of_continuous_at' Monotone.map_sup\u1d62_of_continuousAt'\n\n/- warning: monotone.map_supr_of_continuous_at -> Monotone.map_sup\u1d62_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {\u03b9 : Sort.{u3}} {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Bot.bot.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toHasBot.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) (Bot.bot.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toHasBot.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 (fun (i : \u03b9) => g i))) (sup\u1d62.{u2, u3} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) \u03b9 (fun (i : \u03b9) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} \u03b2] [_inst_5 : TopologicalSpace.{u3} \u03b2] [_inst_6 : OrderClosedTopology.{u3} \u03b2 _inst_5 (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4))))] {\u03b9 : Sort.{u1}} {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u2, u3} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) -> (Monotone.{u2, u3} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) f) -> (Eq.{succ u3} \u03b2 (f (Bot.bot.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toBot.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) (Bot.bot.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toBot.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) -> (Eq.{succ u3} \u03b2 (f (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 (fun (i : \u03b9) => g i))) (sup\u1d62.{u3, u1} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u3} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) \u03b9 (fun (i : \u03b9) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_supr_of_continuous_at Monotone.map_sup\u1d62_of_continuousAt\u2093'. -/\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\u1d62_of_continuousAt {\u03b9 : Sort _} {f : \u03b1 \u2192 \u03b2} {g : \u03b9 \u2192 \u03b1}\n    (Cf : ContinuousAt f (sup\u1d62 g)) (Mf : Monotone f) (fbot : f \u22a5 = \u22a5) :\n    f (\u2a06 i, g i) = \u2a06 i, f (g i) := by\n  rw [sup\u1d62, Mf.map_Sup_of_continuous_at Cf fbot, \u2190 range_comp, sup\u1d62]\n#align monotone.map_supr_of_continuous_at Monotone.map_sup\u1d62_of_continuousAt\n\n/- warning: monotone.map_Inf_of_continuous_at' -> Monotone.map_inf\u209b_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_Inf_of_continuous_at' Monotone.map_inf\u209b_of_continuousAt'\u2093'. -/\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\u209b_of_continuousAt' {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (inf\u209b s))\n    (Mf : Monotone f) (hs : s.Nonempty) : f (inf\u209b s) = inf\u209b (f '' s) :=\n  @Monotone.map_sup\u209b_of_continuousAt' \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 _ _ _ _ _ _ f s Cf Mf.dual hs\n#align monotone.map_Inf_of_continuous_at' Monotone.map_inf\u209b_of_continuousAt'\n\n/- warning: monotone.map_Inf_of_continuous_at -> Monotone.map_inf\u209b_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Top.top.{u1} \u03b1 (CompleteLattice.toHasTop.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (Top.top.{u2} \u03b2 (CompleteLattice.toHasTop.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Top.top.{u1} \u03b1 (CompleteLattice.toTop.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (Top.top.{u2} \u03b2 (CompleteLattice.toTop.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_Inf_of_continuous_at Monotone.map_inf\u209b_of_continuousAt\u2093'. -/\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\u209b_of_continuousAt {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (inf\u209b s))\n    (Mf : Monotone f) (ftop : f \u22a4 = \u22a4) : f (inf\u209b s) = inf\u209b (f '' s) :=\n  @Monotone.map_sup\u209b_of_continuousAt \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 _ _ _ _ _ _ f s Cf Mf.dual ftop\n#align monotone.map_Inf_of_continuous_at Monotone.map_inf\u209b_of_continuousAt\n\n/- warning: monotone.map_infi_of_continuous_at' -> Monotone.map_inf\u1d62_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {\u03b9 : Sort.{u3}} [_inst_8 : Nonempty.{u3} \u03b9] {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 (fun (i : \u03b9) => g i))) (inf\u1d62.{u2, u3} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) \u03b9 (fun (i : \u03b9) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} \u03b2] [_inst_5 : TopologicalSpace.{u3} \u03b2] [_inst_6 : OrderClosedTopology.{u3} \u03b2 _inst_5 (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4))))] {\u03b9 : Sort.{u1}} [_inst_8 : Nonempty.{u1} \u03b9] {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u2, u3} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) -> (Monotone.{u2, u3} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) f) -> (Eq.{succ u3} \u03b2 (f (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 (fun (i : \u03b9) => g i))) (inf\u1d62.{u3, u1} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u3} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) \u03b9 (fun (i : \u03b9) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_infi_of_continuous_at' Monotone.map_inf\u1d62_of_continuousAt'\u2093'. -/\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\u1d62_of_continuousAt' {\u03b9 : Sort _} [Nonempty \u03b9] {f : \u03b1 \u2192 \u03b2} {g : \u03b9 \u2192 \u03b1}\n    (Cf : ContinuousAt f (inf\u1d62 g)) (Mf : Monotone f) : f (\u2a05 i, g i) = \u2a05 i, f (g i) :=\n  @Monotone.map_sup\u1d62_of_continuousAt' \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 _ _ _ _ _ _ \u03b9 _ f g Cf Mf.dual\n#align monotone.map_infi_of_continuous_at' Monotone.map_inf\u1d62_of_continuousAt'\n\n/- warning: monotone.map_infi_of_continuous_at -> Monotone.map_inf\u1d62_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {\u03b9 : Sort.{u3}} {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Top.top.{u1} \u03b1 (CompleteLattice.toHasTop.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (Top.top.{u2} \u03b2 (CompleteLattice.toHasTop.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) (inf\u1d62.{u2, u3} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) \u03b9 (Function.comp.{u3, succ u1, succ u2} \u03b9 \u03b1 \u03b2 f g)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} \u03b2] [_inst_5 : TopologicalSpace.{u3} \u03b2] [_inst_6 : OrderClosedTopology.{u3} \u03b2 _inst_5 (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4))))] {\u03b9 : Sort.{u1}} {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u2, u3} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) -> (Monotone.{u2, u3} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) f) -> (Eq.{succ u3} \u03b2 (f (Top.top.{u2} \u03b1 (CompleteLattice.toTop.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (Top.top.{u3} \u03b2 (CompleteLattice.toTop.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) -> (Eq.{succ u3} \u03b2 (f (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) (inf\u1d62.{u3, u1} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u3} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) \u03b9 (Function.comp.{u1, succ u2, succ u3} \u03b9 \u03b1 \u03b2 f g)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_infi_of_continuous_at Monotone.map_inf\u1d62_of_continuousAt\u2093'. -/\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\u1d62_of_continuousAt {\u03b9 : Sort _} {f : \u03b1 \u2192 \u03b2} {g : \u03b9 \u2192 \u03b1}\n    (Cf : ContinuousAt f (inf\u1d62 g)) (Mf : Monotone f) (ftop : f \u22a4 = \u22a4) : f (inf\u1d62 g) = inf\u1d62 (f \u2218 g) :=\n  @Monotone.map_sup\u1d62_of_continuousAt \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 _ _ _ _ _ _ \u03b9 f g Cf Mf.dual ftop\n#align monotone.map_infi_of_continuous_at Monotone.map_inf\u1d62_of_continuousAt\n\n/- warning: antitone.map_Sup_of_continuous_at' -> Antitone.map_sup\u209b_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_Sup_of_continuous_at' Antitone.map_sup\u209b_of_continuousAt'\u2093'. -/\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\u209b_of_continuousAt' {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (sup\u209b s))\n    (Af : Antitone f) (hs : s.Nonempty) : f (sup\u209b s) = inf\u209b (f '' s) :=\n  Monotone.map_sup\u209b_of_continuousAt' (show ContinuousAt (OrderDual.toDual \u2218 f) (sup\u209b s) from Cf) Af\n    hs\n#align antitone.map_Sup_of_continuous_at' Antitone.map_sup\u209b_of_continuousAt'\n\n/- warning: antitone.map_Sup_of_continuous_at -> Antitone.map_sup\u209b_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Bot.bot.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toHasBot.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) (Top.top.{u2} \u03b2 (CompleteLattice.toHasTop.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Bot.bot.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toBot.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) (Top.top.{u2} \u03b2 (CompleteLattice.toTop.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_Sup_of_continuous_at Antitone.map_sup\u209b_of_continuousAt\u2093'. -/\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\u209b_of_continuousAt {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (sup\u209b s))\n    (Af : Antitone f) (fbot : f \u22a5 = \u22a4) : f (sup\u209b s) = inf\u209b (f '' s) :=\n  Monotone.map_sup\u209b_of_continuousAt (show ContinuousAt (OrderDual.toDual \u2218 f) (sup\u209b s) from Cf) Af\n    fbot\n#align antitone.map_Sup_of_continuous_at Antitone.map_sup\u209b_of_continuousAt\n\n/- warning: antitone.map_supr_of_continuous_at' -> Antitone.map_sup\u1d62_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {\u03b9 : Sort.{u3}} [_inst_8 : Nonempty.{u3} \u03b9] {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 (fun (i : \u03b9) => g i))) (inf\u1d62.{u2, u3} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) \u03b9 (fun (i : \u03b9) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} \u03b2] [_inst_5 : TopologicalSpace.{u3} \u03b2] [_inst_6 : OrderClosedTopology.{u3} \u03b2 _inst_5 (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4))))] {\u03b9 : Sort.{u1}} [_inst_8 : Nonempty.{u1} \u03b9] {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u2, u3} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) -> (Antitone.{u2, u3} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) f) -> (Eq.{succ u3} \u03b2 (f (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 (fun (i : \u03b9) => g i))) (inf\u1d62.{u3, u1} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u3} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) \u03b9 (fun (i : \u03b9) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_supr_of_continuous_at' Antitone.map_sup\u1d62_of_continuousAt'\u2093'. -/\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\u1d62_of_continuousAt' {\u03b9 : Sort _} [Nonempty \u03b9] {f : \u03b1 \u2192 \u03b2} {g : \u03b9 \u2192 \u03b1}\n    (Cf : ContinuousAt f (sup\u1d62 g)) (Af : Antitone f) : f (\u2a06 i, g i) = \u2a05 i, f (g i) :=\n  Monotone.map_sup\u1d62_of_continuousAt' (show ContinuousAt (OrderDual.toDual \u2218 f) (sup\u1d62 g) from Cf) Af\n#align antitone.map_supr_of_continuous_at' Antitone.map_sup\u1d62_of_continuousAt'\n\n/- warning: antitone.map_supr_of_continuous_at -> Antitone.map_sup\u1d62_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {\u03b9 : Sort.{u3}} {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Bot.bot.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toHasBot.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) (Top.top.{u2} \u03b2 (CompleteLattice.toHasTop.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 (fun (i : \u03b9) => g i))) (inf\u1d62.{u2, u3} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) \u03b9 (fun (i : \u03b9) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} \u03b2] [_inst_5 : TopologicalSpace.{u3} \u03b2] [_inst_6 : OrderClosedTopology.{u3} \u03b2 _inst_5 (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4))))] {\u03b9 : Sort.{u1}} {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u2, u3} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) -> (Antitone.{u2, u3} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) f) -> (Eq.{succ u3} \u03b2 (f (Bot.bot.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toBot.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) (Top.top.{u3} \u03b2 (CompleteLattice.toTop.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) -> (Eq.{succ u3} \u03b2 (f (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 (fun (i : \u03b9) => g i))) (inf\u1d62.{u3, u1} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u3} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) \u03b9 (fun (i : \u03b9) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_supr_of_continuous_at Antitone.map_sup\u1d62_of_continuousAt\u2093'. -/\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\u1d62_of_continuousAt {\u03b9 : Sort _} {f : \u03b1 \u2192 \u03b2} {g : \u03b9 \u2192 \u03b1}\n    (Cf : ContinuousAt f (sup\u1d62 g)) (Af : Antitone f) (fbot : f \u22a5 = \u22a4) :\n    f (\u2a06 i, g i) = \u2a05 i, f (g i) :=\n  Monotone.map_sup\u1d62_of_continuousAt (show ContinuousAt (OrderDual.toDual \u2218 f) (sup\u1d62 g) from Cf) Af\n    fbot\n#align antitone.map_supr_of_continuous_at Antitone.map_sup\u1d62_of_continuousAt\n\n/- warning: antitone.map_Inf_of_continuous_at' -> Antitone.map_inf\u209b_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_Inf_of_continuous_at' Antitone.map_inf\u209b_of_continuousAt'\u2093'. -/\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\u209b_of_continuousAt' {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (inf\u209b s))\n    (Af : Antitone f) (hs : s.Nonempty) : f (inf\u209b s) = sup\u209b (f '' s) :=\n  Monotone.map_inf\u209b_of_continuousAt' (show ContinuousAt (OrderDual.toDual \u2218 f) (inf\u209b s) from Cf) Af\n    hs\n#align antitone.map_Inf_of_continuous_at' Antitone.map_inf\u209b_of_continuousAt'\n\n/- warning: antitone.map_Inf_of_continuous_at -> Antitone.map_inf\u209b_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Top.top.{u1} \u03b1 (CompleteLattice.toHasTop.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (Bot.bot.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toHasBot.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Top.top.{u1} \u03b1 (CompleteLattice.toTop.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (Bot.bot.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toBot.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u1} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u1} \u03b1 _inst_1)))) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_Inf_of_continuous_at Antitone.map_inf\u209b_of_continuousAt\u2093'. -/\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\u209b_of_continuousAt {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (inf\u209b s))\n    (Af : Antitone f) (ftop : f \u22a4 = \u22a5) : f (inf\u209b s) = sup\u209b (f '' s) :=\n  Monotone.map_inf\u209b_of_continuousAt (show ContinuousAt (OrderDual.toDual \u2218 f) (inf\u209b s) from Cf) Af\n    ftop\n#align antitone.map_Inf_of_continuous_at Antitone.map_inf\u209b_of_continuousAt\n\n/- warning: antitone.map_infi_of_continuous_at' -> Antitone.map_inf\u1d62_of_continuousAt' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {\u03b9 : Sort.{u3}} [_inst_8 : Nonempty.{u3} \u03b9] {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 (fun (i : \u03b9) => g i))) (sup\u1d62.{u2, u3} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) \u03b9 (fun (i : \u03b9) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} \u03b2] [_inst_5 : TopologicalSpace.{u3} \u03b2] [_inst_6 : OrderClosedTopology.{u3} \u03b2 _inst_5 (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4))))] {\u03b9 : Sort.{u1}} [_inst_8 : Nonempty.{u1} \u03b9] {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u2, u3} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) -> (Antitone.{u2, u3} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) f) -> (Eq.{succ u3} \u03b2 (f (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 (fun (i : \u03b9) => g i))) (sup\u1d62.{u3, u1} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u3} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) \u03b9 (fun (i : \u03b9) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_infi_of_continuous_at' Antitone.map_inf\u1d62_of_continuousAt'\u2093'. -/\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\u1d62_of_continuousAt' {\u03b9 : Sort _} [Nonempty \u03b9] {f : \u03b1 \u2192 \u03b2} {g : \u03b9 \u2192 \u03b1}\n    (Cf : ContinuousAt f (inf\u1d62 g)) (Af : Antitone f) : f (\u2a05 i, g i) = \u2a06 i, f (g i) :=\n  Monotone.map_inf\u1d62_of_continuousAt' (show ContinuousAt (OrderDual.toDual \u2218 f) (inf\u1d62 g) from Cf) Af\n#align antitone.map_infi_of_continuous_at' Antitone.map_inf\u1d62_of_continuousAt'\n\n/- warning: antitone.map_infi_of_continuous_at -> Antitone.map_inf\u1d62_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))))] {\u03b9 : Sort.{u3}} {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4)))) f) -> (Eq.{succ u2} \u03b2 (f (Top.top.{u1} \u03b1 (CompleteLattice.toHasTop.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1)))) (Bot.bot.{u2} \u03b2 (ConditionallyCompleteLinearOrderBot.toHasBot.{u2} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b2 _inst_4)))) -> (Eq.{succ u2} \u03b2 (f (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u1} \u03b1 _inst_1))) \u03b9 g)) (sup\u1d62.{u2, u3} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (CompleteLattice.toConditionallyCompleteLattice.{u2} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b2 _inst_4))) \u03b9 (Function.comp.{u3, succ u1, succ u2} \u03b9 \u03b1 \u03b2 f g)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CompleteLinearOrder.{u2} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b1] [_inst_3 : OrderTopology.{u2} \u03b1 _inst_2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1))))] [_inst_4 : CompleteLinearOrder.{u3} \u03b2] [_inst_5 : TopologicalSpace.{u3} \u03b2] [_inst_6 : OrderClosedTopology.{u3} \u03b2 _inst_5 (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4))))] {\u03b9 : Sort.{u1}} {f : \u03b1 -> \u03b2} {g : \u03b9 -> \u03b1}, (ContinuousAt.{u2, u3} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) -> (Antitone.{u2, u3} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u2} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u3} \u03b2 (CompleteSemilatticeInf.toPartialOrder.{u3} \u03b2 (CompleteLattice.toCompleteSemilatticeInf.{u3} \u03b2 (CompleteLinearOrder.toCompleteLattice.{u3} \u03b2 _inst_4)))) f) -> (Eq.{succ u3} \u03b2 (f (Top.top.{u2} \u03b1 (CompleteLattice.toTop.{u2} \u03b1 (CompleteLinearOrder.toCompleteLattice.{u2} \u03b1 _inst_1)))) (Bot.bot.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toBot.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) -> (Eq.{succ u3} \u03b2 (f (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b1 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u2} \u03b1 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u2} \u03b1 _inst_1)))) \u03b9 g)) (sup\u1d62.{u3, u1} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u3} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u3} \u03b2 (ConditionallyCompleteLinearOrderBot.toConditionallyCompleteLinearOrder.{u3} \u03b2 (CompleteLinearOrder.toConditionallyCompleteLinearOrderBot.{u3} \u03b2 _inst_4)))) \u03b9 (Function.comp.{u1, succ u2, succ u3} \u03b9 \u03b1 \u03b2 f g)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_infi_of_continuous_at Antitone.map_inf\u1d62_of_continuousAt\u2093'. -/\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\u1d62_of_continuousAt {\u03b9 : Sort _} {f : \u03b1 \u2192 \u03b2} {g : \u03b9 \u2192 \u03b1}\n    (Cf : ContinuousAt f (inf\u1d62 g)) (Af : Antitone f) (ftop : f \u22a4 = \u22a5) : f (inf\u1d62 g) = sup\u1d62 (f \u2218 g) :=\n  Monotone.map_inf\u1d62_of_continuousAt (show ContinuousAt (OrderDual.toDual \u2218 f) (inf\u1d62 g) from Cf) Af\n    ftop\n#align antitone.map_infi_of_continuous_at Antitone.map_inf\u1d62_of_continuousAt\n\nend CompleteLinearOrder\n\nsection ConditionallyCompleteLinearOrder\n\nvariable [ConditionallyCompleteLinearOrder \u03b1] [TopologicalSpace \u03b1] [OrderTopology \u03b1]\n  [ConditionallyCompleteLinearOrder \u03b2] [TopologicalSpace \u03b2] [OrderClosedTopology \u03b2] [Nonempty \u03b3]\n\n/- warning: cSup_mem_closure -> csup\u209b_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s) (closure.{u1} \u03b1 _inst_2 s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s) (closure.{u1} \u03b1 _inst_2 s))\nCase conversion may be inaccurate. Consider using '#align cSup_mem_closure csup\u209b_mem_closure\u2093'. -/\ntheorem csup\u209b_mem_closure {s : Set \u03b1} (hs : s.Nonempty) (B : BddAbove s) : sup\u209b s \u2208 closure s :=\n  (isLUB_csup\u209b hs B).mem_closure hs\n#align cSup_mem_closure csup\u209b_mem_closure\n\n/- warning: cInf_mem_closure -> cinf\u209b_mem_closure is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s) (closure.{u1} \u03b1 _inst_2 s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] {s : Set.{u1} \u03b1}, (Set.Nonempty.{u1} \u03b1 s) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s) (closure.{u1} \u03b1 _inst_2 s))\nCase conversion may be inaccurate. Consider using '#align cInf_mem_closure cinf\u209b_mem_closure\u2093'. -/\ntheorem cinf\u209b_mem_closure {s : Set \u03b1} (hs : s.Nonempty) (B : BddBelow s) : inf\u209b s \u2208 closure s :=\n  (isGLB_cinf\u209b hs B).mem_closure hs\n#align cInf_mem_closure cinf\u209b_mem_closure\n\n/- warning: is_closed.cSup_mem -> IsClosed.csup\u209b_mem is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] {s : Set.{u1} \u03b1}, (IsClosed.{u1} \u03b1 _inst_2 s) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] {s : Set.{u1} \u03b1}, (IsClosed.{u1} \u03b1 _inst_2 s) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s) s)\nCase conversion may be inaccurate. Consider using '#align is_closed.cSup_mem IsClosed.csup\u209b_mem\u2093'. -/\ntheorem IsClosed.csup\u209b_mem {s : Set \u03b1} (hc : IsClosed s) (hs : s.Nonempty) (B : BddAbove s) :\n    sup\u209b s \u2208 s :=\n  (isLUB_csup\u209b hs B).mem_of_isClosed hs hc\n#align is_closed.cSup_mem IsClosed.csup\u209b_mem\n\n/- warning: is_closed.cInf_mem -> IsClosed.cinf\u209b_mem is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] {s : Set.{u1} \u03b1}, (IsClosed.{u1} \u03b1 _inst_2 s) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] {s : Set.{u1} \u03b1}, (IsClosed.{u1} \u03b1 _inst_2 s) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s) s)\nCase conversion may be inaccurate. Consider using '#align is_closed.cInf_mem IsClosed.cinf\u209b_mem\u2093'. -/\ntheorem IsClosed.cinf\u209b_mem {s : Set \u03b1} (hc : IsClosed s) (hs : s.Nonempty) (B : BddBelow s) :\n    inf\u209b s \u2208 s :=\n  (isGLB_cinf\u209b hs B).mem_of_isClosed hs hc\n#align is_closed.cInf_mem IsClosed.cinf\u209b_mem\n\n/- warning: monotone.map_cSup_of_continuous_at -> Monotone.map_csup\u209b_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_cSup_of_continuous_at Monotone.map_csup\u209b_of_continuousAt\u2093'. -/\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\u209b_of_continuousAt {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (sup\u209b s))\n    (Mf : Monotone f) (ne : s.Nonempty) (H : BddAbove s) : f (sup\u209b s) = sup\u209b (f '' s) :=\n  by\n  refine' ((isLUB_csup\u209b (ne.image f) (Mf.map_bdd_above H)).unique _).symm\n  refine' (isLUB_csup\u209b 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\u209b_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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] [_inst_7 : Nonempty.{succ u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (Set.range.{u1, succ u3} \u03b1 \u03b3 g)) -> (Eq.{succ u2} \u03b2 (f (sup\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) (sup\u1d62.{u2, succ u3} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) \u03b3 (fun (i : \u03b3) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] [_inst_7 : Nonempty.{succ u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (Set.range.{u1, succ u3} \u03b1 \u03b3 g)) -> (Eq.{succ u2} \u03b2 (f (sup\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) (sup\u1d62.{u2, succ u3} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) \u03b3 (fun (i : \u03b3) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_csupr_of_continuous_at Monotone.map_csupr_of_continuousAt\u2093'. -/\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 : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b1} (Cf : ContinuousAt f (\u2a06 i, g i))\n    (Mf : Monotone f) (H : BddAbove (range g)) : f (\u2a06 i, g i) = \u2a06 i, f (g i) := by\n  rw [sup\u1d62, Mf.map_cSup_of_continuous_at Cf (range_nonempty _) H, \u2190 range_comp, sup\u1d62]\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\u209b_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align monotone.map_cInf_of_continuous_at Monotone.map_cinf\u209b_of_continuousAt\u2093'. -/\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\u209b_of_continuousAt {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (inf\u209b s))\n    (Mf : Monotone f) (ne : s.Nonempty) (H : BddBelow s) : f (inf\u209b s) = inf\u209b (f '' s) :=\n  @Monotone.map_csup\u209b_of_continuousAt \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 _ _ _ _ _ _ f s Cf Mf.dual Ne H\n#align monotone.map_cInf_of_continuous_at Monotone.map_cinf\u209b_of_continuousAt\n\n/- warning: monotone.map_cinfi_of_continuous_at -> Monotone.map_cinf\u1d62_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] [_inst_7 : Nonempty.{succ u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (Set.range.{u1, succ u3} \u03b1 \u03b3 g)) -> (Eq.{succ u2} \u03b2 (f (inf\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) (inf\u1d62.{u2, succ u3} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) \u03b3 (fun (i : \u03b3) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] [_inst_7 : Nonempty.{succ u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) -> (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (Set.range.{u1, succ u3} \u03b1 \u03b3 g)) -> (Eq.{succ u2} \u03b2 (f (inf\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) (inf\u1d62.{u2, succ u3} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) \u03b3 (fun (i : \u03b3) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align monotone.map_cinfi_of_continuous_at Monotone.map_cinf\u1d62_of_continuousAt\u2093'. -/\n/-- A continuous monotone function sends indexed infimum to indexed infimum in conditionally\ncomplete linear order, under a boundedness assumption. -/\ntheorem Monotone.map_cinf\u1d62_of_continuousAt {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b1} (Cf : ContinuousAt f (\u2a05 i, g i))\n    (Mf : Monotone f) (H : BddBelow (range g)) : f (\u2a05 i, g i) = \u2a05 i, f (g i) :=\n  @Monotone.map_csupr_of_continuousAt \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 _ _ _ _ _ _ _ _ _ _ Cf Mf.dual H\n#align monotone.map_cinfi_of_continuous_at Monotone.map_cinf\u1d62_of_continuousAt\n\n/- warning: antitone.map_cSup_of_continuous_at -> Antitone.map_csup\u209b_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Eq.{succ u2} \u03b2 (f (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_cSup_of_continuous_at Antitone.map_csup\u209b_of_continuousAt\u2093'. -/\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\u209b_of_continuousAt {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (sup\u209b s))\n    (Af : Antitone f) (ne : s.Nonempty) (H : BddAbove s) : f (sup\u209b s) = inf\u209b (f '' s) :=\n  Monotone.map_csup\u209b_of_continuousAt (show ContinuousAt (OrderDual.toDual \u2218 f) (sup\u209b s) from Cf) Af\n    Ne H\n#align antitone.map_cSup_of_continuous_at Antitone.map_csup\u209b_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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] [_inst_7 : Nonempty.{succ u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (Set.range.{u1, succ u3} \u03b1 \u03b3 g)) -> (Eq.{succ u2} \u03b2 (f (sup\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) (inf\u1d62.{u2, succ u3} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) \u03b3 (fun (i : \u03b3) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] [_inst_7 : Nonempty.{succ u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (sup\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (BddAbove.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (Set.range.{u1, succ u3} \u03b1 \u03b3 g)) -> (Eq.{succ u2} \u03b2 (f (sup\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) (inf\u1d62.{u2, succ u3} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) \u03b3 (fun (i : \u03b3) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_csupr_of_continuous_at Antitone.map_csupr_of_continuousAt\u2093'. -/\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 : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b1} (Cf : ContinuousAt f (\u2a06 i, g i))\n    (Af : Antitone f) (H : BddAbove (range g)) : f (\u2a06 i, g i) = \u2a05 i, f (g i) :=\n  Monotone.map_csupr_of_continuousAt (show ContinuousAt (OrderDual.toDual \u2218 f) (\u2a06 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\u209b_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (Set.Nonempty.{u1} \u03b1 s) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s) -> (Eq.{succ u2} \u03b2 (f (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) s)) (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align antitone.map_cInf_of_continuous_at Antitone.map_cinf\u209b_of_continuousAt\u2093'. -/\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\u209b_of_continuousAt {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} (Cf : ContinuousAt f (inf\u209b s))\n    (Af : Antitone f) (ne : s.Nonempty) (H : BddBelow s) : f (inf\u209b s) = sup\u209b (f '' s) :=\n  Monotone.map_cinf\u209b_of_continuousAt (show ContinuousAt (OrderDual.toDual \u2218 f) (inf\u209b s) from Cf) Af\n    Ne H\n#align antitone.map_cInf_of_continuous_at Antitone.map_cinf\u209b_of_continuousAt\n\n/- warning: antitone.map_cinfi_of_continuous_at -> Antitone.map_cinf\u1d62_of_continuousAt is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] [_inst_7 : Nonempty.{succ u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (Set.range.{u1, succ u3} \u03b1 \u03b3 g)) -> (Eq.{succ u2} \u03b2 (f (inf\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) (sup\u1d62.{u2, succ u3} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) \u03b3 (fun (i : \u03b3) => f (g i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)))))] [_inst_4 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_5 : TopologicalSpace.{u2} \u03b2] [_inst_6 : OrderClosedTopology.{u2} \u03b2 _inst_5 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)))))] [_inst_7 : Nonempty.{succ u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b1}, (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_5 f (inf\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) -> (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4))))) f) -> (BddBelow.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (Set.range.{u1, succ u3} \u03b1 \u03b3 g)) -> (Eq.{succ u2} \u03b2 (f (inf\u1d62.{u1, succ u3} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) \u03b3 (fun (i : \u03b3) => g i))) (sup\u1d62.{u2, succ u3} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_4)) \u03b3 (fun (i : \u03b3) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align antitone.map_cinfi_of_continuous_at Antitone.map_cinf\u1d62_of_continuousAt\u2093'. -/\n/-- A continuous antitone function sends indexed infimum to indexed supremum in conditionally\ncomplete linear order, under a boundedness assumption. -/\ntheorem Antitone.map_cinf\u1d62_of_continuousAt {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b1} (Cf : ContinuousAt f (\u2a05 i, g i))\n    (Af : Antitone f) (H : BddBelow (range g)) : f (\u2a05 i, g i) = \u2a06 i, f (g i) :=\n  Monotone.map_cinf\u1d62_of_continuousAt (show ContinuousAt (OrderDual.toDual \u2218 f) (\u2a05 i, g i) from Cf)\n    Af H\n#align antitone.map_cinfi_of_continuous_at Antitone.map_cinf\u1d62_of_continuousAt\n\n/- warning: monotone.tendsto_nhds_within_Iio -> Monotone.tendsto_nhdsWithin_Iio is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_8 : LinearOrder.{u1} \u03b1] [_inst_9 : TopologicalSpace.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_9 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_8))))] [_inst_11 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_12 : TopologicalSpace.{u2} \u03b2] [_inst_13 : OrderTopology.{u2} \u03b2 _inst_12 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_11)))))] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_8)))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_11))))) f) -> (forall (x : \u03b1), Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f (nhdsWithin.{u1} \u03b1 _inst_9 x (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_8)))) x)) (nhds.{u2} \u03b2 _inst_12 (SupSet.sup\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasSup.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_11)) (Set.image.{u1, u2} \u03b1 \u03b2 f (Set.Iio.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_8)))) x)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_8 : LinearOrder.{u2} \u03b1] [_inst_9 : TopologicalSpace.{u2} \u03b1] [_inst_10 : OrderTopology.{u2} \u03b1 _inst_9 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_8)))))] [_inst_11 : ConditionallyCompleteLinearOrder.{u1} \u03b2] [_inst_12 : TopologicalSpace.{u1} \u03b2] [_inst_13 : OrderTopology.{u1} \u03b2 _inst_12 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_11)))))] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_8))))) (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_11))))) f) -> (forall (x : \u03b1), Filter.Tendsto.{u2, u1} \u03b1 \u03b2 f (nhdsWithin.{u2} \u03b1 _inst_9 x (Set.Iio.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_8))))) x)) (nhds.{u1} \u03b2 _inst_12 (SupSet.sup\u209b.{u1} \u03b2 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_11)) (Set.image.{u2, u1} \u03b1 \u03b2 f (Set.Iio.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_8))))) x)))))\nCase conversion may be inaccurate. Consider using '#align monotone.tendsto_nhds_within_Iio Monotone.tendsto_nhdsWithin_Iio\u2093'. -/\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 {\u03b1 \u03b2 : Type _} [LinearOrder \u03b1] [TopologicalSpace \u03b1]\n    [OrderTopology \u03b1] [ConditionallyCompleteLinearOrder \u03b2] [TopologicalSpace \u03b2] [OrderTopology \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (Mf : Monotone f) (x : \u03b1) : Tendsto f (\ud835\udcdd[<] x) (\ud835\udcdd (sup\u209b (f '' Iio x))) :=\n  by\n  rcases eq_empty_or_nonempty (Iio x) with (h | h); \u00b7 simp [h]\n  refine' tendsto_order.2 \u27e8fun l hl => _, fun m hm => _\u27e9\n  \u00b7 obtain \u27e8z, zx, lz\u27e9 : \u2203 a : \u03b1, a < x \u2227 l < f a := by\n      simpa only [mem_image, exists_prop, exists_exists_and_eq_and] using\n        exists_lt_of_lt_csup\u209b (nonempty_image_iff.2 h) hl\n    exact\n      (mem_nhdsWithin_Iio_iff_exists_Ioo_subset' zx).2 \u27e8z, zx, fun y hy => lz.trans_le (Mf hy.1.le)\u27e9\n  \u00b7 filter_upwards [self_mem_nhdsWithin]with _ hy\n    apply lt_of_le_of_lt _ hm\n    exact le_csup\u209b (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_8 : LinearOrder.{u1} \u03b1] [_inst_9 : TopologicalSpace.{u1} \u03b1] [_inst_10 : OrderTopology.{u1} \u03b1 _inst_9 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_8))))] [_inst_11 : ConditionallyCompleteLinearOrder.{u2} \u03b2] [_inst_12 : TopologicalSpace.{u2} \u03b2] [_inst_13 : OrderTopology.{u2} \u03b2 _inst_12 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_11)))))] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_8)))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_11))))) f) -> (forall (x : \u03b1), Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f (nhdsWithin.{u1} \u03b1 _inst_9 x (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_8)))) x)) (nhds.{u2} \u03b2 _inst_12 (InfSet.inf\u209b.{u2} \u03b2 (ConditionallyCompleteLattice.toHasInf.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_11)) (Set.image.{u1, u2} \u03b1 \u03b2 f (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_8)))) x)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_8 : LinearOrder.{u2} \u03b1] [_inst_9 : TopologicalSpace.{u2} \u03b1] [_inst_10 : OrderTopology.{u2} \u03b1 _inst_9 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_8)))))] [_inst_11 : ConditionallyCompleteLinearOrder.{u1} \u03b2] [_inst_12 : TopologicalSpace.{u1} \u03b2] [_inst_13 : OrderTopology.{u1} \u03b2 _inst_12 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_11)))))] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_8))))) (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_11))))) f) -> (forall (x : \u03b1), Filter.Tendsto.{u2, u1} \u03b1 \u03b2 f (nhdsWithin.{u2} \u03b1 _inst_9 x (Set.Ioi.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_8))))) x)) (nhds.{u1} \u03b2 _inst_12 (InfSet.inf\u209b.{u1} \u03b2 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_11)) (Set.image.{u2, u1} \u03b1 \u03b2 f (Set.Ioi.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_8))))) x)))))\nCase conversion may be inaccurate. Consider using '#align monotone.tendsto_nhds_within_Ioi Monotone.tendsto_nhdsWithin_Ioi\u2093'. -/\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 {\u03b1 \u03b2 : Type _} [LinearOrder \u03b1] [TopologicalSpace \u03b1]\n    [OrderTopology \u03b1] [ConditionallyCompleteLinearOrder \u03b2] [TopologicalSpace \u03b2] [OrderTopology \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (Mf : Monotone f) (x : \u03b1) : Tendsto f (\ud835\udcdd[>] x) (\ud835\udcdd (inf\u209b (f '' Ioi x))) :=\n  @Monotone.tendsto_nhdsWithin_Iio \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 _ _ _ _ _ _ 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 \u03b1] [Zero \u03b1] [TopologicalSpace \u03b1] [OrderTopology \u03b1]\n\n#print eventually_nhdsWithin_pos_mem_Ioo /-\ntheorem eventually_nhdsWithin_pos_mem_Ioo {\u03b5 : \u03b1} (h : 0 < \u03b5) : \u2200\u1da0 x in \ud835\udcdd[>] 0, x \u2208 Ioo 0 \u03b5 :=\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 {\u03b5 : \u03b1} (h : 0 < \u03b5) : \u2200\u1da0 x in \ud835\udcdd[>] 0, x \u2208 Ioc 0 \u03b5 :=\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 \u2a2f Y)\n    (fun (_x _x_1 _x_2 _x_3 : C) (f : _x \u27f6 _x_1) (g : _x_2 \u27f6 _x_3) => limits.prod.map f g) (\u22a4_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    \u03b2_ = limits.prod.braiding X Y :=\n  Eq.refl \u03b2_\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 \u2297 Y = (X \u2a2f 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 \u27f6 X) (g : Y \u27f6 Z) :\n    f \u2297 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 \u03bb_ = 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 \u03bb_ = limits.prod.lift (limits.terminal.from X) \ud835\udfd9 :=\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 \u03c1_ = 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 \u03c1_ = limits.prod.lift \ud835\udfd9 (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 \u03b1_ =\n        limits.prod.lift (limits.prod.fst \u226b limits.prod.fst)\n          (limits.prod.lift (limits.prod.fst \u226b 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 \u2a3f Y)\n    (fun (_x _x_1 _x_2 _x_3 : C) (f : _x \u27f6 _x_1) (g : _x_2 \u27f6 _x_3) => limits.coprod.map f g) (\u22a5_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 \u2297 Y = (X \u2a3f 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 \u27f6 X) (g : Y \u27f6 Z) :\n    f \u2297 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 \u03bb_ = limits.coprod.desc (limits.initial.to X) \ud835\udfd9 :=\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 \u03c1_ = limits.coprod.desc \ud835\udfd9 (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 \u03bb_ = 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 \u03c1_ = 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 \u03b1_ =\n        limits.coprod.desc\n          (limits.coprod.desc limits.coprod.inl (limits.coprod.inl \u226b limits.coprod.inr))\n          (limits.coprod.inr \u226b 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 `\u22a4`.\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 \u2115`, with theorems that it plays well\nwith `+` and `\u2264`.\n\n* `with_top_add_equiv : enat \u2243+ with_top \u2115`\n* `with_top_order_iso : enat \u2243o with_top \u2115`\n\n## Implementation details\n\n`enat` is defined to be `roption \u2115`.\n\n`+` and `\u2264` are defined on `enat`, but there is an issue with `*` because it's not\nclear what `0 * \u22a4` should be. `mul` is hence left undefined. Similarly `\u22a4 - \u22a4` 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 \u2115\n-/\n\n/-- Type of natural numbers with infinity (`\u22a4`) -/\ndef enat :=\n  roption \u2115\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 \u2227 roption.dom y)\n          fun (h : roption.dom x \u2227 roption.dom y) => roption.get x sorry + roption.get y sorry }\n\nprotected instance has_coe : has_coe \u2115 enat :=\n  has_coe.mk roption.some\n\nprotected instance dom.decidable (n : \u2115) : Decidable (roption.dom \u2191n) :=\n  is_true trivial\n\n@[simp] theorem coe_inj {x : \u2115} {y : \u2115} : \u2191x = \u2191y \u2194 x = y :=\n  roption.some_inj\n\n@[simp] theorem dom_coe (x : \u2115) : roption.dom \u2191x :=\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        \u2203 (h : roption.dom y \u2192 roption.dom x), \u2200 (hy : roption.dom y), roption.get x (h hy) \u2264 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 \u2227 roption.dom y)\n        fun (h : roption.dom x \u2227 roption.dom y) => roption.get x sorry \u2294 roption.get y sorry\n\ntheorem le_def (x : enat) (y : enat) : x \u2264 y \u2194 \u2203 (h : roption.dom y \u2192 roption.dom x), \u2200 (hy : roption.dom y), roption.get x (h hy) \u2264 roption.get y hy :=\n  iff.rfl\n\nprotected theorem cases_on {P : enat \u2192 Prop} (a : enat) : P \u22a4 \u2192 (\u2200 (n : \u2115), P \u2191n) \u2192 P a :=\n  roption.induction_on\n\n@[simp] theorem top_add (x : enat) : \u22a4 + x = \u22a4 :=\n  roption.ext' (false_and (roption.dom x)) fun (h : roption.dom (\u22a4 + x)) => false.elim (and.left h)\n\n@[simp] theorem add_top (x : enat) : x + \u22a4 = \u22a4 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (x + \u22a4 = \u22a4)) (add_comm x \u22a4)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u22a4 + x = \u22a4)) (top_add x))) (Eq.refl \u22a4))\n\n@[simp] theorem coe_zero : \u21910 = 0 :=\n  rfl\n\n@[simp] theorem coe_one : \u21911 = 1 :=\n  rfl\n\n@[simp] theorem coe_add (x : \u2115) (y : \u2115) : \u2191(x + y) = \u2191x + \u2191y :=\n  roption.ext' (iff.symm (and_true (roption.dom \u2191(x + y))))\n    fun (_x : roption.dom \u2191(x + y)) (_x_1 : roption.dom (\u2191x + \u2191y)) => rfl\n\ntheorem get_coe {x : \u2115} : roption.get (\u2191x) True.intro = x :=\n  rfl\n\n@[simp] theorem get_coe' (x : \u2115) (h : roption.dom \u2191x) : roption.get (\u2191x) h = x :=\n  rfl\n\ntheorem coe_add_get {x : \u2115} {y : enat} (h : roption.dom (\u2191x + y)) : roption.get (\u2191x + 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) : \u2191(roption.get x h) = x :=\n  roption.ext' (iff_of_true trivial h) fun (_x : roption.dom \u2191(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 \u2264 y \u2192 roption.dom y \u2192 roption.dom x := sorry\n\ntheorem dom_of_le_some {x : enat} {y : \u2115} (h : x \u2264 \u2191y) : 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 \u2264 y) :=\n  dite (roption.dom x)\n    (fun (hx : roption.dom x) =>\n      decidable_of_decidable_of_iff\n        ((fun (this : Decidable (\u2200 (hy : roption.dom y), roption.get x hx \u2264 roption.get y hy)) => this)\n          (Mathlib.forall_prop_decidable fun (hy : roption.dom y) => roption.get x hx \u2264 roption.get y hy))\n        sorry)\n    fun (hx : \u00acroption.dom x) =>\n      dite (roption.dom y) (fun (hy : roption.dom y) => isFalse sorry) fun (hy : \u00acroption.dom y) => is_true sorry\n\n/-- The coercion `\u2115 \u2192 enat` preserves `0` and addition. -/\ndef coe_hom : \u2115 \u2192+ 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 \u2194 \u2203 (hx : roption.dom x), \u2200 (hy : roption.dom y), roption.get x hx < roption.get y hy := sorry\n\n@[simp] theorem coe_le_coe {x : \u2115} {y : \u2115} : \u2191x \u2264 \u2191y \u2194 x \u2264 y := sorry\n\n@[simp] theorem coe_lt_coe {x : \u2115} {y : \u2115} : \u2191x < \u2191y \u2194 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 \u2264 roption.get y hy \u2194 x \u2264 y := sorry\n\ntheorem le_coe_iff (x : enat) (n : \u2115) : x \u2264 \u2191n \u2194 \u2203 (h : roption.dom x), roption.get x h \u2264 n := sorry\n\ntheorem lt_coe_iff (x : enat) (n : \u2115) : x < \u2191n \u2194 \u2203 (h : roption.dom x), roption.get x h < n := sorry\n\ntheorem coe_le_iff (n : \u2115) (x : enat) : \u2191n \u2264 x \u2194 \u2200 (h : roption.dom x), n \u2264 roption.get x h := sorry\n\ntheorem coe_lt_iff (n : \u2115) (x : enat) : \u2191n < x \u2194 \u2200 (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 \u22a5 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 \u22a4 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 \u2192 roption.dom x :=\n  enat.cases_on x not_top_lt fun (_x : \u2115) (_x : \u2191_x < y) => trivial\n\ntheorem top_eq_none : \u22a4 = roption.none :=\n  rfl\n\n@[simp] theorem coe_lt_top (x : \u2115) : \u2191x < \u22a4 :=\n  lt_of_le_of_ne le_top fun (h : \u2191x = \u22a4) => absurd (congr_arg roption.dom h) true_ne_false\n\n@[simp] theorem coe_ne_top (x : \u2115) : \u2191x \u2260 \u22a4 :=\n  ne_of_lt (coe_lt_top x)\n\ntheorem ne_top_iff {x : enat} : x \u2260 \u22a4 \u2194 \u2203 (n : \u2115), x = \u2191n :=\n  roption.ne_none_iff\n\ntheorem ne_top_iff_dom {x : enat} : x \u2260 \u22a4 \u2194 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 \u2260 \u22a4 :=\n  ne_of_lt (lt_of_lt_of_le h le_top)\n\ntheorem eq_top_iff_forall_lt (x : enat) : x = \u22a4 \u2194 \u2200 (n : \u2115), \u2191n < x := sorry\n\ntheorem eq_top_iff_forall_le (x : enat) : x = \u22a4 \u2194 \u2200 (n : \u2115), \u2191n \u2264 x :=\n  iff.trans (eq_top_iff_forall_lt x)\n    { mp := fun (h : \u2200 (n : \u2115), \u2191n < x) (n : \u2115) => has_lt.lt.le (h n),\n      mpr := fun (h : \u2200 (n : \u2115), \u2191n \u2264 x) (n : \u2115) => 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 \u2194 1 \u2264 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 \u2294 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 \u2293 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 \u2260 \u22a4) : x + z < y + z := sorry\n\nprotected theorem add_lt_add_iff_right {x : enat} {y : enat} {z : enat} (hz : z \u2260 \u22a4) : x + z < y + z \u2194 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 \u2260 \u22a4) : z + x < z + y \u2194 x < y := sorry\n\nprotected theorem lt_add_iff_pos_right {x : enat} {y : enat} (hx : x \u2260 \u22a4) : x < x + y \u2194 0 < y := sorry\n\ntheorem lt_add_one {x : enat} (hx : x \u2260 \u22a4) : x < x + 1 := sorry\n\ntheorem le_of_lt_add_one {x : enat} {y : enat} (h : x < y + 1) : x \u2264 y := sorry\n\ntheorem add_one_le_of_lt {x : enat} {y : enat} (h : x < y) : x + 1 \u2264 y := sorry\n\ntheorem add_one_le_iff_lt {x : enat} {y : enat} (hx : x \u2260 \u22a4) : x + 1 \u2264 y \u2194 x < y := sorry\n\ntheorem lt_add_one_iff_lt {x : enat} {y : enat} (hx : x \u2260 \u22a4) : x < y + 1 \u2194 x \u2264 y := sorry\n\ntheorem add_eq_top_iff {a : enat} {b : enat} : a + b = \u22a4 \u2194 a = \u22a4 \u2228 b = \u22a4 := sorry\n\nprotected theorem add_right_cancel_iff {a : enat} {b : enat} {c : enat} (hc : c \u2260 \u22a4) : a + c = b + c \u2194 a = b := sorry\n\nprotected theorem add_left_cancel_iff {a : enat} {b : enat} {c : enat} (ha : a \u2260 \u22a4) : a + b = a + c \u2194 b = c := sorry\n\n/-- Computably converts an `enat` to a `with_top \u2115`. -/\ndef to_with_top (x : enat) [Decidable (roption.dom x)] : with_top \u2115 :=\n  roption.to_option x\n\ntheorem to_with_top_top : to_with_top \u22a4 = \u22a4 :=\n  rfl\n\n@[simp] theorem to_with_top_top' {h : Decidable (roption.dom \u22a4)} : to_with_top \u22a4 = \u22a4 := 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 : \u2115) : to_with_top \u2191n = \u2191n :=\n  rfl\n\n@[simp] theorem to_with_top_coe' (n : \u2115) {h : Decidable (roption.dom \u2191n)} : to_with_top \u2191n = \u2191n := 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 \u2264 to_with_top y \u2194 x \u2264 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 \u2194 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 \u2115` (for the order isomorphism see `with_top_order_iso`). -/\ndef with_top_equiv : enat \u2243 with_top \u2115 :=\n  equiv.mk (fun (x : enat) => to_with_top x) (fun (x : with_top \u2115) => sorry) sorry sorry\n\n@[simp] theorem with_top_equiv_top : coe_fn with_top_equiv \u22a4 = \u22a4 :=\n  to_with_top_top'\n\n@[simp] theorem with_top_equiv_coe (n : \u2115) : coe_fn with_top_equiv \u2191n = \u2191n :=\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 \u2264 coe_fn with_top_equiv y \u2194 x \u2264 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 \u2194 x < y :=\n  to_with_top_lt\n\n/-- `to_with_top` induces an order isomorphism between `enat` and `with_top \u2115`. -/\ndef with_top_order_iso : enat \u2243o with_top \u2115 :=\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) \u22a4 = \u22a4 :=\n  rfl\n\n@[simp] theorem with_top_equiv_symm_coe (n : \u2115) : coe_fn (equiv.symm with_top_equiv) \u2191n = \u2191n :=\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 \u2115} {y : with_top \u2115} : coe_fn (equiv.symm with_top_equiv) x \u2264 coe_fn (equiv.symm with_top_equiv) y \u2194 x \u2264 y := sorry\n\n@[simp] theorem with_top_equiv_symm_lt {x : with_top \u2115} {y : with_top \u2115} : coe_fn (equiv.symm with_top_equiv) x < coe_fn (equiv.symm with_top_equiv) y \u2194 x < y := sorry\n\n/-- `to_with_top` induces an additive monoid isomorphism between `enat` and `with_top \u2115`. -/\ndef with_top_add_equiv : enat \u2243+ with_top \u2115 :=\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 : \u2115 \u2192 Prop` -/\ndef find (P : \u2115 \u2192 Prop) [decidable_pred P] : enat :=\n  roption.mk (\u2203 (n : \u2115), P n) nat.find\n\n@[simp] theorem find_get (P : \u2115 \u2192 Prop) [decidable_pred P] (h : roption.dom (find P)) : roption.get (find P) h = nat.find h :=\n  rfl\n\ntheorem find_dom (P : \u2115 \u2192 Prop) [decidable_pred P] (h : \u2203 (n : \u2115), P n) : roption.dom (find P) :=\n  h\n\ntheorem lt_find (P : \u2115 \u2192 Prop) [decidable_pred P] (n : \u2115) (h : \u2200 (m : \u2115), m \u2264 n \u2192 \u00acP m) : \u2191n < find P := sorry\n\ntheorem lt_find_iff (P : \u2115 \u2192 Prop) [decidable_pred P] (n : \u2115) : \u2191n < find P \u2194 \u2200 (m : \u2115), m \u2264 n \u2192 \u00acP m := sorry\n\ntheorem find_le (P : \u2115 \u2192 Prop) [decidable_pred P] (n : \u2115) (h : P n) : find P \u2264 \u2191n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (find P \u2264 \u2191n)) (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 : \u2115 \u2192 Prop) [decidable_pred P] : find P = \u22a4 \u2194 \u2200 (n : \u2115), \u00acP n :=\n  iff.trans (eq_top_iff_forall_lt (find P))\n    { mp := fun (h : \u2200 (n : \u2115), \u2191n < find P) (n : \u2115) => iff.mp (lt_find_iff P n) (h n) n le_rfl,\n      mpr := fun (h : \u2200 (n : \u2115), \u00acP n) (n : \u2115) => lt_find P n fun (_x : \u2115) (_x_1 : _x \u2264 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\u00ebl 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 \u2022 s \u2286 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 \u2022 s \u2286 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 {\ud835\udd5c \ud835\udd5d E : Type _} {\u03b9 : Sort _} {\u03ba : \u03b9 \u2192 Sort _}\n\nsection SeminormedRing\n\nvariable [SeminormedRing \ud835\udd5c]\n\nsection SMul\n\nvariable (\ud835\udd5c) [SMul \ud835\udd5c 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  \u2203 r, 0 < r \u2227 \u2200 a : \ud835\udd5c, r \u2264 \u2016a\u2016 \u2192 B \u2286 a \u2022 A\n#align absorbs Absorbs\n\nvariable {\ud835\udd5c} {s t u v A B : Set E}\n\n@[simp]\ntheorem absorbs_empty {s : Set E} : Absorbs \ud835\udd5c s (\u2205 : Set E) :=\n  \u27e81, one_pos, fun a ha => Set.empty_subset _\u27e9\n#align absorbs_empty absorbs_empty\n\ntheorem Absorbs.mono (hs : Absorbs \ud835\udd5c s u) (hst : s \u2286 t) (hvu : v \u2286 u) : Absorbs \ud835\udd5c t v :=\n  let \u27e8r, hr, h\u27e9 := hs\n  \u27e8r, hr, fun a ha => hvu.trans <| (h _ ha).trans <| smul_set_mono hst\u27e9\n#align absorbs.mono Absorbs.mono\n\ntheorem Absorbs.mono_left (hs : Absorbs \ud835\udd5c s u) (h : s \u2286 t) : Absorbs \ud835\udd5c t u :=\n  hs.mono h Subset.rfl\n#align absorbs.mono_left Absorbs.mono_left\n\ntheorem Absorbs.mono_right (hs : Absorbs \ud835\udd5c s u) (h : v \u2286 u) : Absorbs \ud835\udd5c s v :=\n  hs.mono Subset.rfl h\n#align absorbs.mono_right Absorbs.mono_right\n\ntheorem Absorbs.union (hu : Absorbs \ud835\udd5c s u) (hv : Absorbs \ud835\udd5c s v) : Absorbs \ud835\udd5c s (u \u222a v) :=\n  by\n  obtain \u27e8a, ha, hu\u27e9 := hu\n  obtain \u27e8b, hb, hv\u27e9 := hv\n  exact\n    \u27e8max 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)\u27e9\n#align absorbs.union Absorbs.union\n\n@[simp]\ntheorem absorbs_union : Absorbs \ud835\udd5c s (u \u222a v) \u2194 Absorbs \ud835\udd5c s u \u2227 Absorbs \ud835\udd5c s v :=\n  \u27e8fun h => \u27e8h.mono_right <| subset_union_left _ _, h.mono_right <| subset_union_right _ _\u27e9,\n    fun h => h.1.union h.2\u27e9\n#align absorbs_union absorbs_union\n\ntheorem absorbs_union\u1d62_finset {\u03b9 : Type _} {t : Finset \u03b9} {f : \u03b9 \u2192 Set E} :\n    Absorbs \ud835\udd5c s (\u22c3 i \u2208 t, f i) \u2194 \u2200 i \u2208 t, Absorbs \ud835\udd5c s (f i) := by\n  classical\n    induction' t using Finset.induction_on with i t ht hi\n    \u00b7\n      simp only [Finset.not_mem_empty, Set.union\u1d62_false, Set.union\u1d62_empty, absorbs_empty,\n        IsEmpty.forall_iff, imp_true_iff]\n    rw [Finset.set_bunion\u1d62_insert, absorbs_union, hi]\n    constructor <;> intro h\n    \u00b7 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 \u27e8h i (Finset.mem_insert_self i t), fun i' hi' => h i' (Finset.mem_insert_of_mem hi')\u27e9\n#align absorbs_Union_finset absorbs_union\u1d62_finset\n\ntheorem Set.Finite.absorbs_union\u1d62 {\u03b9 : Type _} {s : Set E} {t : Set \u03b9} {f : \u03b9 \u2192 Set E}\n    (hi : t.Finite) : Absorbs \ud835\udd5c s (\u22c3 i \u2208 t, f i) \u2194 \u2200 i \u2208 t, Absorbs \ud835\udd5c s (f i) :=\n  by\n  lift t to Finset \u03b9 using hi\n  simp only [Finset.mem_coe]\n  exact absorbs_union\u1d62_finset\n#align set.finite.absorbs_Union Set.Finite.absorbs_union\u1d62\n\nvariable (\ud835\udd5c)\n\n/-- A set is absorbent if it absorbs every singleton. -/\ndef Absorbent (A : Set E) :=\n  \u2200 x, \u2203 r, 0 < r \u2227 \u2200 a : \ud835\udd5c, r \u2264 \u2016a\u2016 \u2192 x \u2208 a \u2022 A\n#align absorbent Absorbent\n\nvariable {\ud835\udd5c}\n\ntheorem Absorbent.subset (hA : Absorbent \ud835\udd5c A) (hAB : A \u2286 B) : Absorbent \ud835\udd5c B :=\n  by\n  refine' forall_imp (fun x => _) hA\n  exact Exists.imp fun r => And.imp_right <| forall\u2082_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 \ud835\udd5c A \u2194 \u2200 x, Absorbs \ud835\udd5c 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 \ud835\udd5c s) {x : E} : Absorbs \ud835\udd5c s {x} :=\n  absorbent_iff_forall_absorbs_singleton.1 hs _\n#align absorbent.absorbs Absorbent.absorbs\n\ntheorem absorbent_iff_nonneg_lt :\n    Absorbent \ud835\udd5c A \u2194 \u2200 x, \u2203 r, 0 \u2264 r \u2227 \u2200 \u2983a : \ud835\udd5c\u2984, r < \u2016a\u2016 \u2192 x \u2208 a \u2022 A :=\n  forall_congr' fun x =>\n    \u27e8fun \u27e8r, hr, hx\u27e9 => \u27e8r, hr.le, fun a ha => hx a ha.le\u27e9, fun \u27e8r, hr, hx\u27e9 =>\n      \u27e8r + 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)\u27e9\u27e9\n#align absorbent_iff_nonneg_lt absorbent_iff_nonneg_lt\n\ntheorem Absorbent.absorbs_finite {s : Set E} (hs : Absorbent \ud835\udd5c s) {v : Set E} (hv : v.Finite) :\n    Absorbs \ud835\udd5c s v := by\n  rw [\u2190 Set.bunion\u1d62_of_singleton v]\n  exact hv.absorbs_Union.mpr fun _ _ => hs.absorbs\n#align absorbent.absorbs_finite Absorbent.absorbs_finite\n\nvariable (\ud835\udd5c)\n\n/-- A set `A` is balanced if `a \u2022 A` is contained in `A` whenever `a` has norm at most `1`. -/\ndef Balanced (A : Set E) :=\n  \u2200 a : \ud835\udd5c, \u2016a\u2016 \u2264 1 \u2192 a \u2022 A \u2286 A\n#align balanced Balanced\n\nvariable {\ud835\udd5c}\n\ntheorem balanced_iff_smul_mem : Balanced \ud835\udd5c s \u2194 \u2200 \u2983a : \ud835\udd5c\u2984, \u2016a\u2016 \u2264 1 \u2192 \u2200 \u2983x : E\u2984, x \u2208 s \u2192 a \u2022 x \u2208 s :=\n  forall\u2082_congr fun a ha => smul_set_subset_iff\n#align balanced_iff_smul_mem balanced_iff_smul_mem\n\nalias balanced_iff_smul_mem \u2194 Balanced.smul_mem _\n#align balanced.smul_mem Balanced.smul_mem\n\n@[simp]\ntheorem balanced_empty : Balanced \ud835\udd5c (\u2205 : Set E) := fun _ _ => by rw [smul_set_empty]\n#align balanced_empty balanced_empty\n\n@[simp]\ntheorem balanced_univ : Balanced \ud835\udd5c (univ : Set E) := fun a ha => subset_univ _\n#align balanced_univ balanced_univ\n\ntheorem Balanced.union (hA : Balanced \ud835\udd5c A) (hB : Balanced \ud835\udd5c B) : Balanced \ud835\udd5c (A \u222a 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 \ud835\udd5c A) (hB : Balanced \ud835\udd5c B) : Balanced \ud835\udd5c (A \u2229 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\u1d62 {f : \u03b9 \u2192 Set E} (h : \u2200 i, Balanced \ud835\udd5c (f i)) : Balanced \ud835\udd5c (\u22c3 i, f i) :=\n  fun a ha => (smul_set_Union _ _).Subset.trans <| union\u1d62_mono fun _ => h _ _ ha\n#align balanced_Union balanced_union\u1d62\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/\ntheorem balanced_Union\u2082 {f : \u2200 i, \u03ba i \u2192 Set E} (h : \u2200 i j, Balanced \ud835\udd5c (f i j)) :\n    Balanced \ud835\udd5c (\u22c3 (i) (j), f i j) :=\n  balanced_union\u1d62 fun _ => balanced_union\u1d62 <| h _\n#align balanced_Union\u2082 balanced_Union\u2082\n\ntheorem balanced_inter\u1d62 {f : \u03b9 \u2192 Set E} (h : \u2200 i, Balanced \ud835\udd5c (f i)) : Balanced \ud835\udd5c (\u22c2 i, f i) :=\n  fun a ha => (smul_set_inter\u1d62_subset _ _).trans <| inter\u1d62_mono fun _ => h _ _ ha\n#align balanced_Inter balanced_inter\u1d62\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/\ntheorem balanced_Inter\u2082 {f : \u2200 i, \u03ba i \u2192 Set E} (h : \u2200 i j, Balanced \ud835\udd5c (f i j)) :\n    Balanced \ud835\udd5c (\u22c2 (i) (j), f i j) :=\n  balanced_inter\u1d62 fun _ => balanced_inter\u1d62 <| h _\n#align balanced_Inter\u2082 balanced_Inter\u2082\n\nvariable [SMul \ud835\udd5d E] [SMulCommClass \ud835\udd5c \ud835\udd5d E]\n\ntheorem Balanced.smul (a : \ud835\udd5d) (hs : Balanced \ud835\udd5c s) : Balanced \ud835\udd5c (a \u2022 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 \ud835\udd5c E] {s s\u2081 s\u2082 t t\u2081 t\u2082 : Set E}\n\ntheorem Absorbs.neg : Absorbs \ud835\udd5c s t \u2192 Absorbs \ud835\udd5c (-s) (-t) :=\n  Exists.imp fun r =>\n    And.imp_right <| forall\u2082_imp fun _ _ h => (neg_subset_neg.2 h).trans (smul_set_neg _ _).Superset\n#align absorbs.neg Absorbs.neg\n\ntheorem Balanced.neg : Balanced \ud835\udd5c s \u2192 Balanced \ud835\udd5c (-s) :=\n  forall\u2082_imp fun _ _ h => (smul_set_neg _ _).Subset.trans <| neg_subset_neg.2 h\n#align balanced.neg Balanced.neg\n\ntheorem Absorbs.add : Absorbs \ud835\udd5c s\u2081 t\u2081 \u2192 Absorbs \ud835\udd5c s\u2082 t\u2082 \u2192 Absorbs \ud835\udd5c (s\u2081 + s\u2082) (t\u2081 + t\u2082) :=\n  fun \u27e8r\u2081, hr\u2081, h\u2081\u27e9 \u27e8r\u2082, hr\u2082, h\u2082\u27e9 =>\n  \u27e8max r\u2081 r\u2082, lt_max_of_lt_left hr\u2081, fun a ha =>\n    (add_subset_add (h\u2081 _ <| le_of_max_le_left ha) <| h\u2082 _ <| le_of_max_le_right ha).trans\n      (smul_add _ _ _).Superset\u27e9\n#align absorbs.add Absorbs.add\n\ntheorem Balanced.add (hs : Balanced \ud835\udd5c s) (ht : Balanced \ud835\udd5c t) : Balanced \ud835\udd5c (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\u2081 : Absorbs \ud835\udd5c s\u2081 t\u2081) (h\u2082 : Absorbs \ud835\udd5c s\u2082 t\u2082) : Absorbs \ud835\udd5c (s\u2081 - s\u2082) (t\u2081 - t\u2082) :=\n  by\n  simp_rw [sub_eq_add_neg]\n  exact h\u2081.add h\u2082.neg\n#align absorbs.sub Absorbs.sub\n\ntheorem Balanced.sub (hs : Balanced \ud835\udd5c s) (ht : Balanced \ud835\udd5c t) : Balanced \ud835\udd5c (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 \ud835\udd5c (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 \ud835\udd5c] [NormedRing \ud835\udd5d] [NormedSpace \ud835\udd5c \ud835\udd5d] [AddCommGroup E] [Module \ud835\udd5c E]\n  [SMulWithZero \ud835\udd5d E] [IsScalarTower \ud835\udd5c \ud835\udd5d E] {s t u v A B : Set E} {x : E} {a b : \ud835\udd5c}\n\n/-- Scalar multiplication (by possibly different types) of a balanced set is monotone. -/\ntheorem Balanced.smul_mono (hs : Balanced \ud835\udd5d s) {a : \ud835\udd5d} {b : \ud835\udd5c} (h : \u2016a\u2016 \u2264 \u2016b\u2016) : a \u2022 s \u2286 b \u2022 s :=\n  by\n  obtain rfl | hb := eq_or_ne b 0\n  \u00b7 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    \u00b7 simp_rw [smul_set_empty]\n    \u00b7 simp_rw [zero_smul_set h]\n  rintro _ \u27e8x, hx, rfl\u27e9\n  refine' \u27e8b\u207b\u00b9 \u2022 a \u2022 x, _, smul_inv_smul\u2080 hb _\u27e9\n  rw [\u2190 smul_assoc]\n  refine' hs _ _ (smul_mem_smul_set hx)\n  rw [norm_smul, norm_inv, \u2190 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 \ud835\udd5c A) : Absorbs \ud835\udd5c A A :=\n  by\n  refine' \u27e81, zero_lt_one, fun a ha x hx => _\u27e9\n  rw [mem_smul_set_iff_inv_smul_mem\u2080 (norm_pos_iff.1 <| zero_lt_one.trans_le ha)]\n  refine' hA a\u207b\u00b9 _ (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 \ud835\udd5c A) (ha : 1 \u2264 \u2016a\u2016) : A \u2286 a \u2022 A :=\n  by\n  refine' (subset_set_smul_iff\u2080 _).2 (hA a\u207b\u00b9 _)\n  \u00b7 rintro rfl\n    rw [norm_zero] at ha\n    exact zero_lt_one.not_le ha\n  \u00b7 rw [norm_inv]\n    exact inv_le_one ha\n#align balanced.subset_smul Balanced.subset_smul\n\ntheorem Balanced.smul_eq (hA : Balanced \ud835\udd5c A) (ha : \u2016a\u2016 = 1) : a \u2022 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 \ud835\udd5c s) (h : \u2016a\u2016 = \u2016b\u2016) : a \u2022 x \u2208 s \u2194 b \u2022 x \u2208 s :=\n  by\n  obtain rfl | hb := eq_or_ne b 0\n  \u00b7 rw [norm_zero, norm_eq_zero] at h\n    rw [h]\n  have ha : a \u2260 0 := norm_ne_zero_iff.1 (ne_of_eq_of_ne h <| norm_ne_zero_iff.2 hb)\n  constructor <;> intro h' <;> [rw [\u2190 inv_mul_cancel_right\u2080 ha b],\n      rw [\u2190 inv_mul_cancel_right\u2080 hb a]] <;>\n    \u00b7 rw [\u2190 smul_eq_mul, smul_assoc]\n      refine' hs.smul_mem _ h'\n      simp [\u2190 h, ha]\n#align balanced.mem_smul_iff Balanced.mem_smul_iff\n\ntheorem Balanced.neg_mem_iff (hs : Balanced \ud835\udd5c s) : -x \u2208 s \u2194 x \u2208 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 \ud835\udd5c s u) (ht : Absorbs \ud835\udd5c t u) : Absorbs \ud835\udd5c (s \u2229 t) u :=\n  by\n  obtain \u27e8a, ha, hs\u27e9 := hs\n  obtain \u27e8b, hb, ht\u27e9 := ht\n  have h : 0 < max a b := lt_max_of_lt_left ha\n  refine' \u27e8max a b, lt_max_of_lt_left ha, fun c hc => _\u27e9\n  rw [smul_set_inter\u2080 (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 \ud835\udd5c (s \u2229 t) u \u2194 Absorbs \ud835\udd5c s u \u2227 Absorbs \ud835\udd5c t u :=\n  \u27e8fun h => \u27e8h.mono_left <| inter_subset_left _ _, h.mono_left <| inter_subset_right _ _\u27e9, fun h =>\n    h.1.inter h.2\u27e9\n#align absorbs_inter absorbs_inter\n\ntheorem absorbent_univ : Absorbent \ud835\udd5c (univ : Set E) :=\n  by\n  refine' fun x => \u27e81, zero_lt_one, fun a ha => _\u27e9\n  rw [smul_set_univ\u2080 (norm_pos_iff.1 <| zero_lt_one.trans_le ha)]\n  exact trivial\n#align absorbent_univ absorbent_univ\n\nvariable [TopologicalSpace E] [ContinuousSMul \ud835\udd5c E]\n\n/-- Every neighbourhood of the origin is absorbent. -/\ntheorem absorbent_nhds_zero (hA : A \u2208 \ud835\udcdd (0 : E)) : Absorbent \ud835\udd5c A :=\n  by\n  intro x\n  obtain \u27e8w, hw\u2081, hw\u2082, hw\u2083\u27e9 := mem_nhds_iff.mp hA\n  have hc : Continuous fun t : \ud835\udd5c => t \u2022 x := continuous_id.smul continuous_const\n  obtain \u27e8r, hr\u2081, hr\u2082\u27e9 :=\n    metric.is_open_iff.mp (hw\u2082.preimage hc) 0 (by rwa [mem_preimage, zero_smul])\n  have hr\u2083 := inv_pos.mpr (half_pos hr\u2081)\n  refine' \u27e8(r / 2)\u207b\u00b9, hr\u2083, fun a ha\u2081 => _\u27e9\n  have ha\u2082 : 0 < \u2016a\u2016 := hr\u2083.trans_le ha\u2081\n  refine' (mem_smul_set_iff_inv_smul_mem\u2080 (norm_pos_iff.mp ha\u2082) _ _).2 (hw\u2081 <| hr\u2082 _)\n  rw [Metric.mem_ball, dist_zero_right, norm_inv]\n  calc\n    \u2016a\u2016\u207b\u00b9 \u2264 r / 2 := (inv_le (half_pos hr\u2081) ha\u2082).mp ha\u2081\n    _ < r := half_lt_self hr\u2081\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 \ud835\udd5c A) : Balanced \ud835\udd5c ((0 : Set E) \u222a interior A) :=\n  by\n  intro a ha\n  obtain rfl | h := eq_or_ne a 0\n  \u00b7 rw [zero_smul_set]\n    exacts[subset_union_left _ _, \u27e80, Or.inl rfl\u27e9]\n  \u00b7 rw [\u2190 image_smul, image_union]\n    apply union_subset_union\n    \u00b7 rw [image_zero, smul_zero]\n      rfl\n    \u00b7\n      calc\n        a \u2022 interior A \u2286 interior (a \u2022 A) := (isOpenMap_smul\u2080 h).image_interior_subset A\n        _ \u2286 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 \ud835\udd5c A) (h : (0 : E) \u2208 interior A) :\n    Balanced \ud835\udd5c (interior A) :=\n  by\n  rw [\u2190 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 \ud835\udd5c A) : Balanced \ud835\udd5c (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 \ud835\udd5c] [AddCommGroup E] [Module \ud835\udd5c E] {s : Set E}\n\ntheorem absorbs_zero_iff : Absorbs \ud835\udd5c s 0 \u2194 (0 : E) \u2208 s :=\n  by\n  refine' \u27e8_, fun h => \u27e81, zero_lt_one, fun a _ => zero_subset.2 <| zero_mem_smul_set h\u27e9\u27e9\n  rintro \u27e8r, hr, h\u27e9\n  obtain \u27e8a, ha\u27e9 := NormedSpace.exists_lt_norm \ud835\udd5c \ud835\udd5c 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 \ud835\udd5c s) : (0 : E) \u2208 s :=\n  absorbs_zero_iff.1 <| absorbent_iff_forall_absorbs_singleton.1 hs _\n#align absorbent.zero_mem Absorbent.zero_mem\n\nvariable [Module \u211d E] [SMulCommClass \u211d \ud835\udd5c E]\n\ntheorem balanced_convexHull_of_balanced (hs : Balanced \ud835\udd5c s) : Balanced \ud835\udd5c (convexHull \u211d s) :=\n  by\n  suffices Convex \u211d { x | \u2200 a : \ud835\udd5c, \u2016a\u2016 \u2264 1 \u2192 a \u2022 x \u2208 convexHull \u211d s }\n    by\n    rw [balanced_iff_smul_mem] at hs\u22a2\n    refine' fun a ha x hx => convexHull_min _ this hx a ha\n    exact fun y hy a ha => subset_convexHull \u211d s (hs ha hy)\n  intro x hx y hy u v hu hv huv a ha\n  simp only [smul_add, \u2190 smul_comm]\n  exact convex_convexHull \u211d 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 \u211d E] {s : Set E}\n\ntheorem balanced_iff_neg_mem (hs : Convex \u211d s) : Balanced \u211d s \u2194 \u2200 \u2983x\u2984, x \u2208 s \u2192 -x \u2208 s :=\n  by\n  refine' \u27e8fun h x => h.neg_mem_iff.2, fun h a ha => smul_set_subset_iff.2 fun x hx => _\u27e9\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, \u2190 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 \u03b1`\n * `W_rec_eq` - defining equation for `W_rec`\n * `W_ind`    - induction principle for `P.W \u03b1`\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 \u03b1` is made of a dataless tree and a function from\nits valid paths to values of `\u03b1`\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 : \u2115} (P : mvpfunctor (n + 1)) : pfunctor.W (last P) \u2192 fin2 n \u2192 Type u\nwhere\n| root : (a : A P) \u2192\n  (f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)) \u2192 (i : fin2 n) \u2192 B (drop P) a i \u2192 W_path P (W_type.mk a f) i\n| child : (a : A P) \u2192\n  (f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)) \u2192\n    (i : fin2 n) \u2192 (j : pfunctor.B (last P) a) \u2192 W_path P (f j) i \u2192 W_path P (W_type.mk a f) i\n\nprotected instance W_path.inhabited {n : \u2115} (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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {a : A P} {f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)} (g' : typevec.arrow (B (drop P) a) \u03b1) (g : (j : pfunctor.B (last P) a) \u2192 typevec.arrow (W_path P (f j)) \u03b1) : typevec.arrow (W_path P (W_type.mk a f)) \u03b1 := sorry\n\n/-- Specialized destructor on `W_path` -/\ndef W_path_dest_left {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {a : A P} {f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)} (h : typevec.arrow (W_path P (W_type.mk a f)) \u03b1) : typevec.arrow (B (drop P) a) \u03b1 :=\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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {a : A P} {f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)} (h : typevec.arrow (W_path P (W_type.mk a f)) \u03b1) (j : pfunctor.B (last P) a) : typevec.arrow (W_path P (f j)) \u03b1 :=\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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {a : A P} {f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)} (g' : typevec.arrow (B (drop P) a) \u03b1) (g : (j : pfunctor.B (last P) a) \u2192 typevec.arrow (W_path P (f j)) \u03b1) : 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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {a : A P} {f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)} (g' : typevec.arrow (B (drop P) a) \u03b1) (g : (j : pfunctor.B (last P) a) \u2192 typevec.arrow (W_path P (f j)) \u03b1) : W_path_dest_right P (W_path_cases_on P g' g) = g :=\n  rfl\n\ntheorem W_path_cases_on_eta {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {a : A P} {f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)} (h : typevec.arrow (W_path P (W_type.mk a f)) \u03b1) : 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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {\u03b2 : typevec n} (h : typevec.arrow \u03b1 \u03b2) {a : A P} {f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)} (g' : typevec.arrow (B (drop P) a) \u03b1) (g : (j : pfunctor.B (last P) a) \u2192 typevec.arrow (W_path P (f j)) \u03b1) : 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 \u03b1` is made of a tree and a function from its valid paths to\nthe values it contains  -/\ndef Wp {n : \u2115} (P : mvpfunctor (n + 1)) : mvpfunctor n :=\n  mk (pfunctor.W (last P)) (W_path P)\n\n/-- W-type of `P` -/\ndef W {n : \u2115} (P : mvpfunctor (n + 1)) (\u03b1 : typevec n) :=\n  obj (Wp P) \u03b1\n\nprotected instance mvfunctor_W {n : \u2115} (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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} (a : A P) (f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)) (f' : typevec.arrow (W_path P (W_type.mk a f)) \u03b1) : W P \u03b1 :=\n  sigma.mk (W_type.mk a f) f'\n\n/-- Recursor for `Wp` -/\ndef Wp_rec {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {C : Type u_2} (g : (a : A P) \u2192\n  (f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)) \u2192\n    typevec.arrow (W_path P (W_type.mk a f)) \u03b1 \u2192 (pfunctor.B (last P) a \u2192 C) \u2192 C) (x : pfunctor.W (last P)) (f' : typevec.arrow (W_path P x) \u03b1) : C :=\n  sorry\n\ntheorem Wp_rec_eq {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {C : Type u_2} (g : (a : A P) \u2192\n  (f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)) \u2192\n    typevec.arrow (W_path P (W_type.mk a f)) \u03b1 \u2192 (pfunctor.B (last P) a \u2192 C) \u2192 C) (a : A P) (f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)) (f' : typevec.arrow (W_path P (W_type.mk a f)) \u03b1) : 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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {C : (x : pfunctor.W (last P)) \u2192 typevec.arrow (W_path P x) \u03b1 \u2192 Prop} (ih : \u2200 (a : A P) (f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)) (f' : typevec.arrow (W_path P (W_type.mk a f)) \u03b1),\n  (\u2200 (i : pfunctor.B (last P) a), C (f i) (W_path_dest_right P f' i)) \u2192 C (W_type.mk a f) f') (x : pfunctor.W (last P)) (f' : typevec.arrow (W_path P x) \u03b1) : C x f' := sorry\n\n/-!\nNow think of W as defined inductively by the data \u27e8a, f', f\u27e9 where\n- `a  : P.A` is the shape of the top node\n- `f' : P.drop.B a \u27f9 \u03b1` is the contents of the top node\n- `f  : P.last.B a \u2192 P.last.W` are the subtrees\n -/\n\n/-- Constructor for `W` -/\ndef W_mk {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1) : W P \u03b1 :=\n  let g : pfunctor.B (last P) a \u2192 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)) \u03b1 :=\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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {C : Type u_1} (g : (a : A P) \u2192 typevec.arrow (B (drop P) a) \u03b1 \u2192 (pfunctor.B (last P) a \u2192 W P \u03b1) \u2192 (pfunctor.B (last P) a \u2192 C) \u2192 C) : W P \u03b1 \u2192 C :=\n  sorry\n\n/-- Defining equation for the recursor of `W` -/\ntheorem W_rec_eq {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {C : Type u_1} (g : (a : A P) \u2192 typevec.arrow (B (drop P) a) \u03b1 \u2192 (pfunctor.B (last P) a \u2192 W P \u03b1) \u2192 (pfunctor.B (last P) a \u2192 C) \u2192 C) (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1) : 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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {C : W P \u03b1 \u2192 Prop} (ih : \u2200 (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1),\n  (\u2200 (i : pfunctor.B (last P) a), C (f i)) \u2192 C (W_mk P a f' f)) (x : W P \u03b1) : C x := sorry\n\ntheorem W_cases {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {C : W P \u03b1 \u2192 Prop} (ih : \u2200 (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1), C (W_mk P a f' f)) (x : W P \u03b1) : C x :=\n  W_ind P\n    fun (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1)\n      (ih' : \u2200 (i : pfunctor.B (last P) a), C (f i)) => ih a f' f\n\n/-- W-types are functorial -/\ndef W_map {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {\u03b2 : typevec n} (g : typevec.arrow \u03b1 \u03b2) : W P \u03b1 \u2192 W P \u03b2 :=\n  fun (x : W P \u03b1) => mvfunctor.map g x\n\ntheorem W_mk_eq {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} (a : A P) (f : pfunctor.B (last P) a \u2192 pfunctor.W (last P)) (g' : typevec.arrow (B (drop P) a) \u03b1) (g : (j : pfunctor.B (last P) a) \u2192 typevec.arrow (W_path P (f j)) \u03b1) : (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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {\u03b2 : typevec n} (g : typevec.arrow \u03b1 \u03b2) (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1) : 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 (\u03b1 ::: \u03b2)` from components.\nUseful to avoid complicated type annotation -/\ndef obj_append1 {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {\u03b2 : Type u} (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 \u03b2) : obj P (\u03b1 ::: \u03b2) :=\n  sigma.mk a (typevec.split_fun f' f)\n\ntheorem map_obj_append1 {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {\u03b3 : typevec n} (g : typevec.arrow \u03b1 \u03b3) (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1) : 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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} : obj P (\u03b1 ::: W P \u03b1) \u2192 W P \u03b1 :=\n  sorry\n\n/-- Destructor for the W-type of `P` -/\ndef W_dest' {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} : W P \u03b1 \u2192 obj P (\u03b1 ::: W P \u03b1) :=\n  W_rec P\n    fun (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1)\n      (_x : pfunctor.B (last P) a \u2192 obj P (\u03b1 ::: W P \u03b1)) => sigma.mk a (typevec.split_fun f' f)\n\ntheorem W_dest'_W_mk {n : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} (a : A P) (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 W P \u03b1) : 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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} (x : obj P (\u03b1 ::: W P \u03b1)) : 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 \u2228 b = c \u2228 c = a :=\nbegin\n    cases a; cases b; cases c; repeat {refl <|> {left, refl} <|> right },\nend\n\nexample : two \u2260 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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 X)\n  (k : W \u27f6 Y) (H\u2081 : is_terminal Z)\n  (H\u2082 : is_limit (pullback_cone.mk _ _ (show h \u226b f = k \u226b g, from H\u2081.hom_ext _ _))) :\n  is_limit (binary_fan.mk h k) :=\n{ lift := \u03bb c, H\u2082.lift (pullback_cone.mk\n    (c.\u03c0.app \u27e8walking_pair.left\u27e9) (c.\u03c0.app \u27e8walking_pair.right\u27e9) (H\u2081.hom_ext _ _)),\n  fac' := \u03bb c j,\n  begin\n    cases j,\n    convert H\u2082.fac (pullback_cone.mk (c.\u03c0.app \u27e8walking_pair.left\u27e9)\n      (c.\u03c0.app \u27e8walking_pair.right\u27e9) (H\u2081.hom_ext _ _)) (some j) using 1,\n    rcases j; refl,\n  end,\n  uniq' := \u03bb c m hm,\n  begin\n    apply pullback_cone.is_limit.hom_ext H\u2082,\n    { exact (hm \u27e8walking_pair.left\u27e9).trans (H\u2082.fac (pullback_cone.mk (c.\u03c0.app \u27e8walking_pair.left\u27e9)\n        (c.\u03c0.app \u27e8walking_pair.right\u27e9) (H\u2081.hom_ext _ _)) walking_cospan.left).symm },\n    { exact (hm \u27e8walking_pair.right\u27e9).trans (H\u2082.fac (pullback_cone.mk (c.\u03c0.app \u27e8walking_pair.left\u27e9)\n        (c.\u03c0.app \u27e8walking_pair.right\u27e9) (H\u2081.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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 X)\n  (k : W \u27f6 Y) (H\u2081 : is_terminal Z)\n  (H\u2082 : is_limit (binary_fan.mk h k)) :\n  is_limit (pullback_cone.mk _ _ (show h \u226b f = k \u226b g, from H\u2081.hom_ext _ _)) :=\nbegin\n  apply pullback_cone.is_limit_aux',\n  intro s,\n  use H\u2082.lift (binary_fan.mk s.fst s.snd),\n  use H\u2082.fac (binary_fan.mk s.fst s.snd) \u27e8walking_pair.left\u27e9,\n  use H\u2082.fac (binary_fan.mk s.fst s.snd) \u27e8walking_pair.right\u27e9,\n  intros m h\u2081 h\u2082,\n  apply H\u2082.hom_ext,\n  rintro \u27e8\u27e8\u27e9\u27e9,\n  { exact h\u2081.trans (H\u2082.fac (binary_fan.mk s.fst s.snd) \u27e8walking_pair.left\u27e9).symm },\n  { exact h\u2082.trans (H\u2082.fac (binary_fan.mk s.fst s.snd) \u27e8walking_pair.right\u27e9).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 \u2964 C) : limit_cone F :=\n{ cone :=\n  { X := pullback (terminal.from (F.obj \u27e8walking_pair.left\u27e9))\n                  (terminal.from (F.obj \u27e8walking_pair.right\u27e9)),\n    \u03c0 := discrete.nat_trans (\u03bb x, discrete.cases_on x\n      (\u03bb x, walking_pair.cases_on x pullback.fst pullback.snd)) },\n  is_limit :=\n  { lift := \u03bb c, pullback.lift ((c.\u03c0).app \u27e8walking_pair.left\u27e9)\n                                ((c.\u03c0).app \u27e8walking_pair.right\u27e9)\n                                (subsingleton.elim _ _),\n    fac' := \u03bb s c, discrete.cases_on c\n      (\u03bb c, walking_pair.cases_on c (limit.lift_\u03c0 _ _) (limit.lift_\u03c0 _ _)),\n    uniq' := \u03bb s m J,\n              begin\n                rw [\u2190J, \u2190J],\n                ext;\n                rw limit.lift_\u03c0;\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 := \u03bb 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 \u2a2f Y \u2245 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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 X)\n  (k : W \u27f6 Y) (H\u2081 : is_initial W)\n  (H\u2082 : is_colimit (pushout_cocone.mk _ _ (show h \u226b f = k \u226b g, from H\u2081.hom_ext _ _))) :\n  is_colimit (binary_cofan.mk f g) :=\n{ desc := \u03bb c, H\u2082.desc (pushout_cocone.mk\n    (c.\u03b9.app \u27e8walking_pair.left\u27e9) (c.\u03b9.app \u27e8walking_pair.right\u27e9) (H\u2081.hom_ext _ _)),\n  fac' := \u03bb c j,\n  begin\n    cases j,\n    convert H\u2082.fac (pushout_cocone.mk (c.\u03b9.app \u27e8walking_pair.left\u27e9) (c.\u03b9.app \u27e8walking_pair.right\u27e9)\n      (H\u2081.hom_ext _ _)) (some j) using 1,\n    cases j; refl\n  end,\n  uniq' := \u03bb c m hm,\n  begin\n    apply pushout_cocone.is_colimit.hom_ext H\u2082,\n    { exact (hm \u27e8walking_pair.left\u27e9).trans (H\u2082.fac (pushout_cocone.mk (c.\u03b9.app \u27e8walking_pair.left\u27e9)\n        (c.\u03b9.app \u27e8walking_pair.right\u27e9) (H\u2081.hom_ext _ _)) walking_cospan.left).symm },\n    { exact (hm \u27e8walking_pair.right\u27e9).trans (H\u2082.fac (pushout_cocone.mk (c.\u03b9.app \u27e8walking_pair.left\u27e9)\n        (c.\u03b9.app \u27e8walking_pair.right\u27e9) (H\u2081.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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 X)\n  (k : W \u27f6 Y) (H\u2081 : is_initial W)\n  (H\u2082 : is_colimit (binary_cofan.mk f g)) :\n  is_colimit (pushout_cocone.mk _ _ (show h \u226b f = k \u226b g, from H\u2081.hom_ext _ _)) :=\nbegin\n  apply pushout_cocone.is_colimit_aux',\n  intro s,\n  use H\u2082.desc (binary_cofan.mk s.inl s.inr),\n  use H\u2082.fac (binary_cofan.mk s.inl s.inr) \u27e8walking_pair.left\u27e9,\n  use H\u2082.fac (binary_cofan.mk s.inl s.inr) \u27e8walking_pair.right\u27e9,\n  intros m h\u2081 h\u2082,\n  apply H\u2082.hom_ext,\n  rintro \u27e8\u27e8\u27e9\u27e9,\n  { exact h\u2081.trans (H\u2082.fac (binary_cofan.mk s.inl s.inr) \u27e8walking_pair.left\u27e9).symm },\n  { exact h\u2082.trans (H\u2082.fac (binary_cofan.mk s.inl s.inr) \u27e8walking_pair.right\u27e9).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 \u2964 C) : colimit_cocone F :=\n{ cocone :=\n  { X := pushout (initial.to (F.obj \u27e8walking_pair.left\u27e9))\n                  (initial.to (F.obj \u27e8walking_pair.right\u27e9)),\n    \u03b9 := discrete.nat_trans (\u03bb x, discrete.cases_on x\n      (\u03bb x, walking_pair.cases_on x pushout.inl pushout.inr)) },\n  is_colimit :=\n  { desc := \u03bb c, pushout.desc (c.\u03b9.app \u27e8walking_pair.left\u27e9)\n                              (c.\u03b9.app \u27e8walking_pair.right\u27e9)\n                              (subsingleton.elim _ _),\n    fac' := \u03bb s c, discrete.cases_on c\n      (\u03bb c, walking_pair.cases_on c (colimit.\u03b9_desc _ _) (colimit.\u03b9_desc _ _)),\n    uniq' := \u03bb s m J,\n              begin\n                rw [\u2190J, \u2190J],\n                ext;\n                rw colimit.\u03b9_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 := \u03bb 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 \u2a3f Y \u2245 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 {\ud835\udd5c \ud835\udd5d E F \u03b2 : Type*}\n\nopen function set\nopen_locale convex\n\nsection ordered_semiring\nvariables [ordered_semiring \ud835\udd5c] [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 (\ud835\udd5c) [has_scalar \ud835\udd5c E] [has_scalar \ud835\udd5c 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 $ \u03bb x y, \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192 a \u2022 x + b \u2022 y \u2208 interior s\n\nvariables {\ud835\udd5c s} {x y : E}\n\nlemma strict_convex_iff_open_segment_subset :\n  strict_convex \ud835\udd5c s \u2194 s.pairwise (\u03bb x y, open_segment \ud835\udd5c x y \u2286 interior s) :=\nforall\u2085_congr $ \u03bb x hx y hy hxy, (open_segment_subset_iff \ud835\udd5c).symm\n\nlemma strict_convex.open_segment_subset (hs : strict_convex \ud835\udd5c s) (hx : x \u2208 s) (hy : y \u2208 s)\n  (h : x \u2260 y) :\n  open_segment \ud835\udd5c x y \u2286 interior s :=\nstrict_convex_iff_open_segment_subset.1 hs hx hy h\n\nlemma strict_convex_empty : strict_convex \ud835\udd5c (\u2205 : set E) := pairwise_empty _\n\nlemma strict_convex_univ : strict_convex \ud835\udd5c (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 \ud835\udd5c s) (ht : strict_convex \ud835\udd5c t) :\n  strict_convex \ud835\udd5c (s \u2229 t) :=\nbegin\n  intros x hx y hy hxy a b ha hb hab,\n  rw interior_inter,\n  exact \u27e8hs hx.1 hy.1 hxy ha hb hab, ht hx.2 hy.2 hxy ha hb hab\u27e9,\nend\n\nlemma directed.strict_convex_Union {\u03b9 : Sort*} {s : \u03b9 \u2192 set E} (hdir : directed (\u2286) s)\n  (hs : \u2200 \u2983i : \u03b9\u2984, strict_convex \ud835\udd5c (s i)) :\n  strict_convex \ud835\udd5c (\u22c3 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 \u27e8i, hx\u27e9 := hx,\n  obtain \u27e8j, hy\u27e9 := hy,\n  obtain \u27e8k, hik, hjk\u27e9 := 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 (\u2286) S)\n  (hS : \u2200 s \u2208 S, strict_convex \ud835\udd5c s) :\n  strict_convex \ud835\udd5c (\u22c3\u2080 S) :=\nbegin\n  rw sUnion_eq_Union,\n  exact (directed_on_iff_directed.1 hdir).strict_convex_Union (\u03bb s, hS _ s.2),\nend\n\nend has_scalar\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c F] {s : set E}\n\nprotected lemma strict_convex.convex (hs : strict_convex \ud835\udd5c s) : convex \ud835\udd5c s :=\nconvex_iff_pairwise_pos.2 $ \u03bb 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 \ud835\udd5c s) : strict_convex \ud835\udd5c s :=\n\u03bb x hx y hy _ a b ha hb hab, h.interior_eq.symm \u25b8 hs hx hy ha.le hb.le hab\n\nlemma is_open.strict_convex_iff (h : is_open s) : strict_convex \ud835\udd5c s \u2194 convex \ud835\udd5c s :=\n\u27e8strict_convex.convex, convex.strict_convex h\u27e9\n\nlemma strict_convex_singleton (c : E) : strict_convex \ud835\udd5c ({c} : set E) := pairwise_singleton _ _\n\nlemma set.subsingleton.strict_convex (hs : s.subsingleton) : strict_convex \ud835\udd5c s := hs.pairwise _\n\nlemma strict_convex.linear_image [semiring \ud835\udd5d] [module \ud835\udd5d E] [module \ud835\udd5d F]\n  [linear_map.compatible_smul E F \ud835\udd5c \ud835\udd5d] (hs : strict_convex \ud835\udd5c s) (f : E \u2192\u2097[\ud835\udd5d] F)\n  (hf : is_open_map f) :\n  strict_convex \ud835\udd5c (f '' s) :=\nbegin\n  rintro _ \u27e8x, hx, rfl\u27e9 _ \u27e8y, hy, rfl\u27e9 hxy a b ha hb hab,\n  refine hf.image_interior_subset _ \u27e8a \u2022 x + b \u2022 y, hs hx hy (ne_of_apply_ne _ hxy) ha hb hab, _\u27e9,\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 \ud835\udd5c s) {f : E \u2192 F} (h : is_linear_map \ud835\udd5c f)\n  (hf : is_open_map f) :\n  strict_convex \ud835\udd5c (f '' s) :=\nhs.linear_image (h.mk' f) hf\n\nlemma strict_convex.linear_preimage {s : set F} (hs : strict_convex \ud835\udd5c s) (f : E \u2192\u2097[\ud835\udd5c] F)\n  (hf : continuous f) (hfinj : injective f) :\n  strict_convex \ud835\udd5c (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 \ud835\udd5c s) {f : E \u2192 F}\n  (h : is_linear_map \ud835\udd5c f) (hf : continuous f) (hfinj : injective f) :\n  strict_convex \ud835\udd5c (s.preimage f) :=\nhs.linear_preimage (h.mk' f) hf hfinj\n\nsection linear_ordered_cancel_add_comm_monoid\nvariables [topological_space \u03b2] [linear_ordered_cancel_add_comm_monoid \u03b2] [order_topology \u03b2]\n  [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2]\n\nlemma strict_convex_Iic (r : \u03b2) : strict_convex \ud835\udd5c (Iic r) :=\nbegin\n  rintro x (hx : x \u2264 r) y (hy : y \u2264 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 \u2190convex.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 : \u03b2) : strict_convex \ud835\udd5c (Ici r) :=\n@strict_convex_Iic \ud835\udd5c (order_dual \u03b2) _ _ _ _ _ _ r\n\nlemma strict_convex_Icc (r s : \u03b2) : strict_convex \ud835\udd5c (Icc r s) :=\n(strict_convex_Ici r).inter $ strict_convex_Iic s\n\nlemma strict_convex_Iio (r : \u03b2) : strict_convex \ud835\udd5c (Iio r) :=\n(convex_Iio r).strict_convex is_open_Iio\n\nlemma strict_convex_Ioi (r : \u03b2) : strict_convex \ud835\udd5c (Ioi r) :=\n(convex_Ioi r).strict_convex is_open_Ioi\n\nlemma strict_convex_Ioo (r s : \u03b2) : strict_convex \ud835\udd5c (Ioo r s) :=\n(strict_convex_Ioi r).inter $ strict_convex_Iio s\n\nlemma strict_convex_Ico (r s : \u03b2) : strict_convex \ud835\udd5c (Ico r s) :=\n(strict_convex_Ici r).inter $ strict_convex_Iio s\n\nlemma strict_convex_Ioc (r s : \u03b2) : strict_convex \ud835\udd5c (Ioc r s) :=\n(strict_convex_Ioi r).inter $ strict_convex_Iic s\n\nlemma strict_convex_interval (r s : \u03b2) : strict_convex \ud835\udd5c (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 \ud835\udd5c 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 \ud835\udd5c s) (z : E) :\n  strict_convex \ud835\udd5c ((\u03bb x, z + x) \u207b\u00b9' 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, \u2190add_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 \ud835\udd5c s) (z : E) :\n  strict_convex \ud835\udd5c ((\u03bb x, x + z) \u207b\u00b9' 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 \ud835\udd5c E] [module \ud835\udd5c F]\n\nsection continuous_add\nvariables [has_continuous_add E] {s t : set E}\n\nlemma strict_convex.add (hs : strict_convex \ud835\udd5c s) (ht : strict_convex \ud835\udd5c t) :\n  strict_convex \ud835\udd5c (s + t) :=\nbegin\n  rintro _ \u27e8v, w, hv, hw, rfl\u27e9 _ \u27e8x, y, hx, hy, rfl\u27e9 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 \ud835\udd5c s) (z : E) :\n  strict_convex \ud835\udd5c ((\u03bb 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 \ud835\udd5c s) (z : E) :\n  strict_convex \ud835\udd5c ((\u03bb 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 \ud835\udd5c s) (x : E) : strict_convex \ud835\udd5c (x +\u1d65 s) :=\nhs.add_left x\n\nend continuous_add\n\nsection continuous_smul\nvariables [linear_ordered_field \ud835\udd5d] [module \ud835\udd5d E] [has_continuous_const_smul \ud835\udd5d E]\n  [linear_map.compatible_smul E E \ud835\udd5c \ud835\udd5d] {s : set E} {x : E}\n\nlemma strict_convex.smul (hs : strict_convex \ud835\udd5c s) (c : \ud835\udd5d) : strict_convex \ud835\udd5c (c \u2022 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\u2080 hc) }\nend\n\nlemma strict_convex.affinity [has_continuous_add E] (hs : strict_convex \ud835\udd5c s) (z : E) (c : \ud835\udd5d) :\n  strict_convex \ud835\udd5c (z +\u1d65 c \u2022 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 \ud835\udd5c] [topological_space E]\n\nsection add_comm_group\nvariables [add_comm_group E] [module \ud835\udd5c E] [no_zero_smul_divisors \ud835\udd5c E]\n  [has_continuous_const_smul \ud835\udd5c E] {s : set E}\n\nlemma strict_convex.preimage_smul (hs : strict_convex \ud835\udd5c s) (c : \ud835\udd5c) :\n  strict_convex \ud835\udd5c ((\u03bb z, c \u2022 z) \u207b\u00b9' 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\u2082 linear_map.mk\u2082' linear_map.mk\u2082'\u209b\u2097,\n  exact continuous_const_smul _,\nend\n\nend add_comm_group\nend ordered_comm_semiring\n\nsection ordered_ring\nvariables [ordered_ring \ud835\udd5c] [topological_space E] [topological_space F]\n\nsection add_comm_group\nvariables [add_comm_group E] [add_comm_group F] [module \ud835\udd5c E] [module \ud835\udd5c F] {s : set E} {x y : E}\n\nlemma strict_convex.eq_of_open_segment_subset_frontier [nontrivial \ud835\udd5c] [densely_ordered \ud835\udd5c]\n  (hs : strict_convex \ud835\udd5c s) (hx : x \u2208 s) (hy : y \u2208 s) (h : open_segment \ud835\udd5c x y \u2286 frontier s) :\n  x = y :=\nbegin\n  obtain \u27e8a, ha\u2080, ha\u2081\u27e9 := densely_ordered.dense (0 : \ud835\udd5c) 1 zero_lt_one,\n  classical,\n  by_contra hxy,\n  exact (h \u27e8a, 1 - a, ha\u2080, sub_pos_of_lt ha\u2081, add_sub_cancel'_right _ _, rfl\u27e9).2\n    (hs hx hy hxy ha\u2080 (sub_pos_of_lt ha\u2081) $ add_sub_cancel'_right _ _),\nend\n\nlemma strict_convex.add_smul_mem (hs : strict_convex \ud835\udd5c s) (hx : x \u2208 s) (hxy : x + y \u2208 s)\n  (hy : y \u2260 0) {t : \ud835\udd5c} (ht\u2080 : 0 < t) (ht\u2081 : t < 1) :\n  x + t \u2022 y \u2208 interior s :=\nbegin\n  have h : x + t \u2022 y = (1 - t) \u2022 x + t \u2022 (x + y),\n  { rw [smul_add, \u2190add_assoc, \u2190add_smul, sub_add_cancel, one_smul] },\n  rw h,\n  refine hs hx hxy (\u03bb h, hy $ add_left_cancel _) (sub_pos_of_lt ht\u2081) ht\u2080 (sub_add_cancel _ _),\n  exact x,\n  rw [\u2190h, add_zero],\nend\n\nlemma strict_convex.smul_mem_of_zero_mem (hs : strict_convex \ud835\udd5c s) (zero_mem : (0 : E) \u2208 s)\n  (hx : x \u2208 s) (hx\u2080 : x \u2260 0) {t : \ud835\udd5c} (ht\u2080 : 0 < t) (ht\u2081 : t < 1) :\n  t \u2022 x \u2208 interior s :=\nby simpa using hs.add_smul_mem zero_mem (by simpa using hx) hx\u2080 ht\u2080 ht\u2081\n\nlemma strict_convex.add_smul_sub_mem (h : strict_convex \ud835\udd5c s) (hx : x \u2208 s) (hy : y \u2208 s) (hxy : x \u2260 y)\n  {t : \ud835\udd5c} (ht\u2080 : 0 < t) (ht\u2081 : t < 1) : x + t \u2022 (y - x) \u2208 interior s :=\nbegin\n  apply h.open_segment_subset hx hy hxy,\n  rw open_segment_eq_image',\n  exact mem_image_of_mem _ \u27e8ht\u2080, ht\u2081\u27e9,\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 \ud835\udd5c s) {f : E \u2192\u1d43[\ud835\udd5c] F}\n  (hf : continuous f) (hfinj : injective f) :\n  strict_convex \ud835\udd5c (f \u207b\u00b9' 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 \ud835\udd5c s) {f : E \u2192\u1d43[\ud835\udd5c] F} (hf : is_open_map f) :\n  strict_convex \ud835\udd5c (f '' s) :=\nbegin\n  rintro _ \u27e8x, hx, rfl\u27e9 _ \u27e8y, hy, rfl\u27e9 hxy a b ha hb hab,\n  exact hf.image_interior_subset _ \u27e8a \u2022 x + b \u2022 y, \u27e8hs hx hy (ne_of_apply_ne _ hxy) ha hb hab,\n    convex.combo_affine_apply hab\u27e9\u27e9,\nend\n\nlemma strict_convex.neg [topological_add_group E] (hs : strict_convex \ud835\udd5c s) :\n  strict_convex \ud835\udd5c ((\u03bb 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 \ud835\udd5c s) :\n  strict_convex \ud835\udd5c ((\u03bb z, -z) \u207b\u00b9' 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 \ud835\udd5c] [topological_space E]\n\nsection add_comm_group\nvariables [add_comm_group E] [add_comm_group F] [module \ud835\udd5c E] [module \ud835\udd5c F] {s : set E} {x : E}\n\n/-- Alternative definition of set strict convexity, using division. -/\nlemma strict_convex_iff_div :\n  strict_convex \ud835\udd5c s \u2194 s.pairwise\n    (\u03bb x y, \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 (a / (a + b)) \u2022 x + (b / (a + b)) \u2022 y \u2208 interior s) :=\n\u27e8\u03bb 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 \u2190add_div,\n  exact div_self (add_pos ha hb).ne',\nend, \u03bb h x hx y hy hxy a b ha hb hab, by convert h hx hy hxy ha hb; rw [hab, div_one] \u27e9\n\nlemma strict_convex.mem_smul_of_zero_mem (hs : strict_convex \ud835\udd5c s) (zero_mem : (0 : E) \u2208 s)\n  (hx : x \u2208 s) (hx\u2080 : x \u2260 0) {t : \ud835\udd5c} (ht : 1 < t) :\n  x \u2208 t \u2022 interior s :=\nbegin\n  rw mem_smul_set_iff_inv_smul_mem\u2080 (zero_lt_one.trans ht).ne',\n  exact hs.smul_mem_of_zero_mem zero_mem hx hx\u2080 (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 \ud835\udd5c] [topological_space \ud835\udd5c]\n  [order_topology \ud835\udd5c] {s : set \ud835\udd5c} :\n  strict_convex \ud835\udd5c s \u2194 convex \ud835\udd5c s :=\nbegin\n  refine \u27e8strict_convex.convex, \u03bb hs, strict_convex_iff_open_segment_subset.2 (\u03bb x hx y hy hxy, _)\u27e9,\n  obtain h | h := hxy.lt_or_lt,\n  { refine (open_segment_subset_Ioo h).trans _,\n    rw \u2190interior_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 \u2190interior_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 \ud835\udd5c] [topological_space \ud835\udd5c]\n  [order_topology \ud835\udd5c] {s : set \ud835\udd5c} :\n  strict_convex \ud835\udd5c s \u2194 s.ord_connected :=\nstrict_convex_iff_convex.trans convex_iff_ord_connected\n\nalias strict_convex_iff_ord_connected \u2194 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 {\u03b1 : Sort u} : Nonempty \u03b1 \u2192 \u03b1theorem indefinite_description {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) (h : \u2203 (x : \u03b1), p x) : Subtype fun (x : \u03b1) => p x := sorry\n\ndef some {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (h : \u2203 (x : \u03b1), p x) : \u03b1 :=\n  subtype.val (indefinite_description p h)\n\ntheorem some_spec {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (h : \u2203 (x : \u03b1), 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 \u2228 \u00acp :=\n  or.elim (not_uv_or_p p) (fun (hne : u p \u2260 v p) => Or.inr (mt (p_implies_uv p) hne)) Or.inl\n\ntheorem exists_true_of_nonempty {\u03b1 : Sort u} : Nonempty \u03b1 \u2192 \u2203 (x : \u03b1), True :=\n  fun (\u1fb0 : Nonempty \u03b1) => nonempty.dcases_on \u1fb0 fun (\u1fb0 : \u03b1) => idRhs (\u2203 (x : \u03b1), True) (Exists.intro \u1fb0 trivial)\n\ndef inhabited_of_nonempty {\u03b1 : Sort u} (h : Nonempty \u03b1) : Inhabited \u03b1 :=\n  { default := Classical.choice h }\n\ndef inhabited_of_exists {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (h : \u2203 (x : \u03b1), p x) : Inhabited \u03b1 :=\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 (\u03b1 : Sort u) : DecidableEq \u03b1 :=\n  fun (x y : \u03b1) => prop_decidable (x = y)\n\ndef type_decidable (\u03b1 : Sort u) : psum \u03b1 (\u03b1 \u2192 False) :=\n  sorry\n\ntheorem strong_indefinite_description {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) (h : Nonempty \u03b1) : Subtype fun (x : \u03b1) => (\u2203 (y : \u03b1), p y) \u2192 p x := sorry\n\n/- the Hilbert epsilon function -/\n\ndef epsilon {\u03b1 : Sort u} [h : Nonempty \u03b1] (p : \u03b1 \u2192 Prop) : \u03b1 :=\n  subtype.val (strong_indefinite_description p h)\n\ntheorem epsilon_spec_aux {\u03b1 : Sort u} (h : Nonempty \u03b1) (p : \u03b1 \u2192 Prop) : (\u2203 (y : \u03b1), p y) \u2192 p (epsilon p) :=\n  subtype.property (strong_indefinite_description p h)\n\ntheorem epsilon_spec {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (hex : \u2203 (y : \u03b1), p y) : p (epsilon p) :=\n  epsilon_spec_aux (nonempty_of_exists hex) p hex\n\ntheorem epsilon_singleton {\u03b1 : Sort u} (x : \u03b1) : (epsilon fun (y : \u03b1) => y = x) = x :=\n  epsilon_spec (Exists.intro x rfl)\n\n/- the axiom of choice -/\n\ntheorem axiom_of_choice {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {r : (x : \u03b1) \u2192 \u03b2 x \u2192 Prop} (h : \u2200 (x : \u03b1), \u2203 (y : \u03b2 x), r x y) : \u2203 (f : (x : \u03b1) \u2192 \u03b2 x), \u2200 (x : \u03b1), r x (f x) :=\n  Exists.intro (fun (x : \u03b1) => some (h x)) fun (x : \u03b1) => some_spec (h x)\n\ntheorem skolem {\u03b1 : Sort u} {b : \u03b1 \u2192 Sort v} {p : (x : \u03b1) \u2192 b x \u2192 Prop} : (\u2200 (x : \u03b1), \u2203 (y : b x), p x y) \u2194 \u2203 (f : (x : \u03b1) \u2192 b x), \u2200 (x : \u03b1), p x (f x) := sorry\n\ntheorem prop_complete (a : Prop) : a = True \u2228 a = False :=\n  or.elim (em a) (fun (t : a) => Or.inl (eq_true_intro t)) fun (f : \u00aca) => Or.inr (eq_false_intro f)\n\ndef eq_true_or_eq_false (a : Prop) : a = True \u2228 a = False :=\n  prop_complete\n\ntheorem cases_true_false (p : Prop \u2192 Prop) (h1 : p True) (h2 : p False) (a : Prop) : p a :=\n  or.elim (prop_complete a) (fun (ht : a = True) => Eq.symm ht \u25b8 h1) fun (hf : a = False) => Eq.symm hf \u25b8 h2\n\ntheorem cases_on (a : Prop) {p : Prop \u2192 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 \u2192 q) (hnpq : \u00acp \u2192 q) : q :=\n  decidable.by_cases hpq hnpq\n\n-- this supercedes by_contradiction in decidable\n\ntheorem by_contradiction {p : Prop} (h : \u00acp \u2192 False) : p :=\n  decidable.by_contradiction h\n\ntheorem eq_false_or_eq_true (a : Prop) : a = False \u2228 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\u00e7ois 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 \u2192 \u03b2` is `convex_on` a set `s` if `s` is itself a convex set, and for any two\npoints `x y \u2208 s`, the segment joining `(x, f x)` to `(y, f y)` is above the graph of `f`.\nEquivalently, `convex_on \ud835\udd5c f s` means that the epigraph `{p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2}` is\na convex set.\n\n## Main declarations\n\n* `convex_on \ud835\udd5c s f`: The function `f` is convex on `s` with scalars `\ud835\udd5c`.\n* `concave_on \ud835\udd5c s f`: The function `f` is concave on `s` with scalars `\ud835\udd5c`.\n* `strict_convex_on \ud835\udd5c s f`: The function `f` is strictly convex on `s` with scalars `\ud835\udd5c`.\n* `strict_concave_on \ud835\udd5c s f`: The function `f` is strictly concave on `s` with scalars `\ud835\udd5c`.\n-/\n\nopen finset linear_map set\nopen_locale big_operators classical convex pointwise\n\nvariables {\ud835\udd5c E F \u03b2 \u03b9 : Type*}\n\nsection ordered_semiring\nvariables [ordered_semiring \ud835\udd5c]\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 \u03b2]\n\nsection has_smul\nvariables (\ud835\udd5c) [has_smul \ud835\udd5c E] [has_smul \ud835\udd5c \u03b2] (s : set E) (f : E \u2192 \u03b2)\n\n/-- Convexity of functions -/\ndef convex_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y\n\n/-- Concavity of functions -/\ndef concave_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 a + b = 1 \u2192\n    a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)\n\n/-- Strict convexity of functions -/\ndef strict_convex_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y\n\n/-- Strict concavity of functions -/\ndef strict_concave_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    a \u2022 f x + b \u2022 f y < f (a \u2022 x + b \u2022 y)\n\nvariables {\ud835\udd5c s f}\n\nopen order_dual (to_dual of_dual)\n\nlemma convex_on.dual (hf : convex_on \ud835\udd5c s f) : concave_on \ud835\udd5c s (to_dual \u2218 f) := hf\n\nlemma concave_on.dual (hf : concave_on \ud835\udd5c s f) : convex_on \ud835\udd5c s (to_dual \u2218 f) := hf\n\nlemma strict_convex_on.dual (hf : strict_convex_on \ud835\udd5c s f) : strict_concave_on \ud835\udd5c s (to_dual \u2218 f) :=\nhf\n\nlemma strict_concave_on.dual (hf : strict_concave_on \ud835\udd5c s f) : strict_convex_on \ud835\udd5c s (to_dual \u2218 f) :=\nhf\n\nlemma convex_on_id {s : set \u03b2} (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s id := \u27e8hs, by { intros, refl }\u27e9\n\nlemma concave_on_id {s : set \u03b2} (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s id := \u27e8hs, by { intros, refl }\u27e9\n\nlemma convex_on.subset {t : set E} (hf : convex_on \ud835\udd5c t f) (hst : s \u2286 t) (hs : convex \ud835\udd5c s) :\n  convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma concave_on.subset {t : set E} (hf : concave_on \ud835\udd5c t f) (hst : s \u2286 t) (hs : convex \ud835\udd5c s) :\n  concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma strict_convex_on.subset {t : set E} (hf : strict_convex_on \ud835\udd5c t f) (hst : s \u2286 t)\n  (hs : convex \ud835\udd5c s) :\n  strict_convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma strict_concave_on.subset {t : set E} (hf : strict_concave_on \ud835\udd5c t f) (hst : s \u2286 t)\n  (hs : convex \ud835\udd5c s) :\n  strict_concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nend has_smul\n\nsection distrib_mul_action\nvariables [has_smul \ud835\udd5c E] [distrib_mul_action \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma convex_on.add (hf : convex_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  convex_on \ud835\udd5c s (f + g) :=\n\u27e8hf.1, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) + g (a \u2022 x + b \u2022 y) \u2264 (a \u2022 f x + b \u2022 f y) + (a \u2022 g x + b \u2022 g y)\n      : add_le_add (hf.2 hx hy ha hb hab) (hg.2 hx hy ha hb hab)\n    ... = a \u2022 (f x + g x) + b \u2022 (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]\u27e9\n\nlemma concave_on.add (hf : concave_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [has_smul \ud835\udd5c E] [module \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on_const (c : \u03b2) (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s (\u03bb x:E, c) :=\n\u27e8hs, \u03bb x y _ _ a b _ _ hab, (convex.combo_self hab c).ge\u27e9\n\nlemma concave_on_const (c : \u03b2) (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s (\u03bb x:E, c) :=\n@convex_on_const _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ c hs\n\nlemma convex_on_of_convex_epigraph (h : convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2}) :\n  convex_on \ud835\udd5c s f :=\n\u27e8\u03bb x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) \u27e8hx, le_rfl\u27e9 \u27e8hy, le_rfl\u27e9 a b ha hb hab).1,\n  \u03bb x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) \u27e8hx, le_rfl\u27e9 \u27e8hy, le_rfl\u27e9 a b ha hb hab).2\u27e9\n\nlemma concave_on_of_convex_hypograph (h : convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 p.2 \u2264 f p.1}) :\n  concave_on \ud835\udd5c s f :=\n@convex_on_of_convex_epigraph \ud835\udd5c  E \u03b2\u1d52\u1d48 _ _ _ _ _ _ _ h\n\nend module\n\nsection ordered_smul\nvariables [has_smul \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.convex_le (hf : convex_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | f x \u2264 r} :=\n\u03bb x y hx hy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 ha hb hab\n                  ... \u2264 a \u2022 r + b \u2022 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\u27e9\n\nlemma concave_on.convex_ge (hf : concave_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | r \u2264 f x} :=\nhf.dual.convex_le r\n\nlemma convex_on.convex_epigraph (hf : convex_on \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2} :=\nbegin\n  rintro \u27e8x, r\u27e9 \u27e8y, t\u27e9 \u27e8hx, hr\u27e9 \u27e8hy, ht\u27e9 a b ha hb hab,\n  refine \u27e8hf.1 hx hy ha hb hab, _\u27e9,\n  calc f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha hb hab\n  ... \u2264 a \u2022 r + b \u2022 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 \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 p.2 \u2264 f p.1} :=\nhf.dual.convex_epigraph\n\nlemma convex_on_iff_convex_epigraph :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2} :=\n\u27e8convex_on.convex_epigraph, convex_on_of_convex_epigraph\u27e9\n\nlemma concave_on_iff_convex_hypograph :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 p.2 \u2264 f p.1} :=\n@convex_on_iff_convex_epigraph \ud835\udd5c E \u03b2\u1d52\u1d48 _ _ _ _ _ _ _ f\n\nend ordered_smul\n\nsection module\nvariables [module \ud835\udd5c E] [has_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\n/-- Right translation preserves convexity. -/\nlemma convex_on.translate_right (hf : convex_on \ud835\udd5c s f) (c : E) :\n  convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\n\u27e8hf.1.translate_preimage_right _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (c + (a \u2022 x + b \u2022 y)) = f (a \u2022 (c + x) + b \u2022 (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... \u2264 a \u2022 f (c + x) + b \u2022 f (c + y) : hf.2 hx hy ha hb hab\u27e9\n\n/-- Right translation preserves concavity. -/\nlemma concave_on.translate_right (hf : concave_on \ud835\udd5c s f) (c : E) :\n  concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves convexity. -/\nlemma convex_on.translate_left (hf : convex_on \ud835\udd5c s f) (c : E) :\n  convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c s f) (c : E) :\n  concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, z + c)) :=\nhf.dual.translate_left _\n\nend module\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2]\n\nlemma convex_on_iff_forall_pos {s : set E} {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y :=\nbegin\n  refine and_congr_right' \u27e8\u03bb h x y hx hy a b ha hb hab, h hx hy ha.le hb.le hab,\n    \u03bb h x y hx hy a b ha hb hab, _\u27e9,\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 \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y) :=\n@convex_on_iff_forall_pos \ud835\udd5c E \u03b2\u1d52\u1d48 _ _ _ _ _ _ _\n\nlemma convex_on_iff_pairwise_pos {s : set E} {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    s.pairwise (\u03bb x y, \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y) :=\nbegin\n  rw convex_on_iff_forall_pos,\n  refine and_congr_right' \u27e8\u03bb h x hx y hy _ a b ha hb hab, h hx hy ha hb hab,\n    \u03bb h x y hx hy a b ha hb hab, _\u27e9,\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 \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n   s.pairwise (\u03bb x y, \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)) :=\n@convex_on_iff_pairwise_pos \ud835\udd5c E \u03b2\u1d52\u1d48 _ _ _ _ _ _ _\n\n/-- A linear map is convex. -/\nlemma linear_map.convex_on (f : E \u2192\u2097[\ud835\udd5c] \u03b2) {s : set E} (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]\u27e9\n\n/-- A linear map is concave. -/\nlemma linear_map.concave_on (f : E \u2192\u2097[\ud835\udd5c] \u03b2) {s : set E} (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]\u27e9\n\nlemma strict_convex_on.convex_on {s : set E} {f : E \u2192 \u03b2} (hf : strict_convex_on \ud835\udd5c s f) :\n  convex_on \ud835\udd5c s f :=\nconvex_on_iff_pairwise_pos.mpr \u27e8hf.1, \u03bb x hx y hy hxy a b ha hb hab, (hf.2 hx hy hxy ha hb hab).le\u27e9\n\nlemma strict_concave_on.concave_on {s : set E} {f : E \u2192 \u03b2} (hf : strict_concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c s f :=\nhf.dual.convex_on\n\nsection ordered_smul\nvariables [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma strict_convex_on.convex_lt (hf : strict_convex_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | f x < r} :=\nconvex_iff_pairwise_pos.2 $ \u03bb x hx y hy hxy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 hxy ha hb hab\n                  ... \u2264 a \u2022 r + b \u2022 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\u27e9\n\nlemma strict_concave_on.convex_gt (hf : strict_concave_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 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 \u2192 \u03b2}\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 \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y` only for `x < y` and positive `a`,\n`b`. The main use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order.\n-/\nlemma linear_order.convex_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y) : convex_on \ud835\udd5c s f :=\nbegin\n  refine convex_on_iff_pairwise_pos.2 \u27e8hs, \u03bb x hx y hy hxy a b ha hb hab, _\u27e9,\n  wlog h : x \u2264 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 \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \u211d` however one can apply it, e.g., to `\u211d^n` with lexicographic order. -/\nlemma linear_order.concave_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n     a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)) : concave_on \ud835\udd5c s f :=\n@linear_order.convex_on_of_lt _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ 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 \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order. -/\nlemma linear_order.strict_convex_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y) : strict_convex_on \ud835\udd5c s f :=\nbegin\n  refine \u27e8hs, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n  wlog h : x \u2264 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 \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order. -/\nlemma linear_order.strict_concave_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n     a \u2022 f x + b \u2022 f y < f (a \u2022 x + b \u2022 y)) : strict_concave_on \ud835\udd5c s f :=\n@linear_order.strict_convex_on_of_lt _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ _ _ hs hf\n\nend linear_order\nend module\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c F] [has_smul \ud835\udd5c \u03b2]\n\n/-- If `g` is convex on `s`, so is `(f \u2218 g)` on `f \u207b\u00b9' s` for a linear `f`. -/\nlemma convex_on.comp_linear_map {f : F \u2192 \u03b2} {s : set F} (hf : convex_on \ud835\udd5c s f) (g : E \u2192\u2097[\ud835\udd5c] F) :\n  convex_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 g) :=\n\u27e8hf.1.linear_preimage _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (g (a \u2022 x + b \u2022 y)) = f (a \u2022 (g x) + b \u2022 (g y)) : by rw [g.map_add, g.map_smul, g.map_smul]\n                      ... \u2264 a \u2022 f (g x) + b \u2022 f (g y) : hf.2 hx hy ha hb hab\u27e9\n\n/-- If `g` is concave on `s`, so is `(g \u2218 f)` on `f \u207b\u00b9' s` for a linear `f`. -/\nlemma concave_on.comp_linear_map {f : F \u2192 \u03b2} {s : set F} (hf : concave_on \ud835\udd5c s f) (g : E \u2192\u2097[\ud835\udd5c] F) :\n  concave_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 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 \u03b2]\n\nsection distrib_mul_action\nvariables [has_smul \ud835\udd5c E] [distrib_mul_action \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma strict_convex_on.add_convex_on (hf : strict_convex_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f + g) :=\n\u27e8hf.1, \u03bb x y hx hy hxy a b ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) + g (a \u2022 x + b \u2022 y) < (a \u2022 f x + b \u2022 f y) + (a \u2022 g x + b \u2022 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 \u2022 (f x + g x) + b \u2022 (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]\u27e9\n\nlemma convex_on.add_strict_convex_on (hf : convex_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f + g) :=\n(add_comm g f) \u25b8 hg.add_convex_on hf\n\nlemma strict_convex_on.add (hf : strict_convex_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f + g) :=\n\u27e8hf.1, \u03bb x y hx hy hxy a b ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) + g (a \u2022 x + b \u2022 y) < (a \u2022 f x + b \u2022 f y) + (a \u2022 g x + b \u2022 g y)\n      : add_lt_add (hf.2 hx hy hxy ha hb hab) (hg.2 hx hy hxy ha hb hab)\n    ... = a \u2022 (f x + g x) + b \u2022 (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]\u27e9\n\nlemma strict_concave_on.add_concave_on (hf : strict_concave_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add_convex_on hg.dual\n\nlemma concave_on.add_strict_concave_on (hf : concave_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add_strict_convex_on hg.dual\n\nlemma strict_concave_on.add (hf : strict_concave_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.convex_lt (hf : convex_on \ud835\udd5c s f) (r : \u03b2) : convex \ud835\udd5c {x \u2208 s | f x < r} :=\nconvex_iff_forall_pos.2 $ \u03bb x y hx hy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a \u2022 x + b \u2022 y)\n        \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 ha.le hb.le hab\n    ... < a \u2022 r + b \u2022 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 _\u27e9\n\nlemma concave_on.convex_gt (hf : concave_on \ud835\udd5c s f) (r : \u03b2) : convex \ud835\udd5c {x \u2208 s | r < f x} :=\nhf.dual.convex_lt r\n\nlemma convex_on.open_segment_subset_strict_epigraph (hf : convex_on \ud835\udd5c s f) (p q : E \u00d7 \u03b2)\n  (hp : p.1 \u2208 s \u2227 f p.1 < p.2) (hq : q.1 \u2208 s \u2227 f q.1 \u2264 q.2) :\n  open_segment \ud835\udd5c p q \u2286 {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 < p.2} :=\nbegin\n  rintro _ \u27e8a, b, ha, hb, hab, rfl\u27e9,\n  refine \u27e8hf.1 hp.1 hq.1 ha.le hb.le hab, _\u27e9,\n  calc f (a \u2022 p.1 + b \u2022 q.1) \u2264 a \u2022 f p.1 + b \u2022 f q.1 : hf.2 hp.1 hq.1 ha.le hb.le hab\n  ... < a \u2022 p.2 + b \u2022 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 \ud835\udd5c s f) (p q : E \u00d7 \u03b2)\n  (hp : p.1 \u2208 s \u2227 p.2 < f p.1) (hq : q.1 \u2208 s \u2227 q.2 \u2264 f q.1) :\n  open_segment \ud835\udd5c p q \u2286 {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 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 \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 < p.2} :=\nconvex_iff_open_segment_subset.mpr $\n  \u03bb p q hp hq, hf.open_segment_subset_strict_epigraph p q hp \u27e8hq.1, hq.2.le\u27e9\n\nlemma concave_on.convex_strict_hypograph (hf : concave_on \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 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 \u03b2] [has_smul \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2]\n  {s : set E} {f g : E \u2192 \u03b2}\n\n/-- The pointwise maximum of convex functions is convex. -/\nlemma convex_on.sup (hf : convex_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  convex_on \ud835\udd5c s (f \u2294 g) :=\nbegin\n  refine \u27e8hf.left, \u03bb x y hx hy a b ha hb hab, sup_le _ _\u27e9,\n  { calc f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.right hx hy ha hb hab\n     ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \u2022 x + b \u2022 y) \u2264 a \u2022 g x + b \u2022 g y : hg.right hx hy ha hb hab\n     ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  concave_on \ud835\udd5c s (f \u2293 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 \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f \u2294 g) :=\n\u27e8hf.left, \u03bb x y hx hy hxy a b ha hb hab, max_lt\n  (calc f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx hy hxy ha hb hab\n    ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \u2022 x + b \u2022 y) < a \u2022 g x + b \u2022 g y : hg.2 hx hy hxy ha hb hab\n    ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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))\u27e9\n\n/-- The pointwise minimum of strictly concave functions is strictly concave. -/\nlemma strict_concave_on.inf (hf : strict_concave_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n   strict_concave_on \ud835\udd5c s (f \u2293 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 \u2264 a) (hb : 0 \u2264 b) (hab : a + b = 1) :\n  f (a \u2022 x + b \u2022 y) \u2264 max (f x) (f y) :=\ncalc\n  f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha hb hab\n  ... \u2264 a \u2022 max (f x) (f y) + b \u2022 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 \u2264 a) (hb : 0 \u2264 b) (hab : a + b = 1) :\n  min (f x) (f y) \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  (hz : z \u2208 [x -[\ud835\udd5c] y]) :\n  f z \u2264 max (f x) (f y) :=\nlet \u27e8a, b, ha, hb, hab, hz\u27e9 := hz in hz \u25b8 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  (hz : z \u2208 [x -[\ud835\udd5c] y]) :\n  min (f x) (f y) \u2264 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  f (a \u2022 x + b \u2022 y) < max (f x) (f y) :=\ncalc\n  f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx hy hxy ha hb hab\n  ... \u2264 a \u2022 max (f x) (f y) + b \u2022 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  min (f x) (f y) < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) (hz : z \u2208 open_segment \ud835\udd5c x y) :\n  f z < max (f x) (f y) :=\nlet \u27e8a, b, ha, hb, hab, hz\u27e9 := hz in hz \u25b8 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) (hz : z \u2208 open_segment \ud835\udd5c 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 \u03b2]\n\nsection ordered_smul\nvariables [has_smul \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma convex_on.le_left_of_right_le' (hf : convex_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 \u2264 b) (hab : a + b = 1) (hfy : f y \u2264 f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) \u2264 f x :=\nle_of_not_lt $ \u03bb h, lt_irrefl (f (a \u2022 x + b \u2022 y)) $\n  calc\n    f (a \u2022 x + b \u2022 y)\n        \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha.le hb hab\n    ... < a \u2022 f (a \u2022 x + b \u2022 y) + b \u2022 f (a \u2022 x + b \u2022 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 \u2022 x + b \u2022 y) : convex.combo_self hab _\n\nlemma concave_on.left_le_of_le_right' (hf : concave_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 \u2264 b) (hab : a + b = 1) (hfy : f (a \u2022 x + b \u2022 y) \u2264 f y) :\n  f x \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 \u2264 a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x \u2264 f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) \u2264 f y :=\nbegin\n  rw add_comm at \u22a2 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 \u2264 a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a \u2022 x + b \u2022 y) \u2264 f x) :\n  f y \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f y \u2264 f z) :\n  f z \u2264 f x :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f z \u2264 f y) :\n  f x \u2264 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f x \u2264 f z) :\n  f z \u2264 f y :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f z \u2264 f x) :\n  f y \u2264 f z :=\nhf.dual.le_right_of_left_le hx hy hz hxz\n\nend ordered_smul\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\n/- The following lemmas don't require `module \ud835\udd5c E` if you add the hypothesis `x \u2260 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f y < f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) < f x :=\nnot_le.1 $ \u03bb h, lt_irrefl (f (a \u2022 x + b \u2022 y)) $\n  calc\n    f (a \u2022 x + b \u2022 y)\n        < a \u2022 f x + b \u2022 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 \u2022 f (a \u2022 x + b \u2022 y) + b \u2022 f (a \u2022 x + b \u2022 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 \u2022 x + b \u2022 y) : convex.combo_self hab _\n\nlemma strict_concave_on.left_lt_of_lt_right' (hf : strict_concave_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f (a \u2022 x + b \u2022 y) < f y) :\n  f x < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x < f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) < f y :=\nbegin\n  rw add_comm at \u22a2 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a \u2022 x + b \u2022 y) < f x) :\n  f y < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f y < f z) :\n  f z < f x :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f x < f z) :\n  f z < f y :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c 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 \u03b2] [has_smul \ud835\udd5c E] [module \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\n/-- A function `-f` is convex iff `f` is concave. -/\n@[simp] lemma neg_convex_on_iff : convex_on \ud835\udd5c s (-f) \u2194 concave_on \ud835\udd5c s f :=\nbegin\n  split,\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy a b ha hb hab, _\u27e9,\n    simp [neg_apply, neg_le, add_comm] at h,\n    exact h hx hy ha hb hab },\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy a b ha hb hab, _\u27e9,\n    rw \u2190neg_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 \ud835\udd5c s (-f) \u2194 convex_on \ud835\udd5c s f:=\nby rw [\u2190 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 \ud835\udd5c s (-f) \u2194 strict_concave_on \ud835\udd5c s f :=\nbegin\n  split,\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n    simp [neg_apply, neg_lt, add_comm] at h,\n    exact h hx hy hxy ha hb hab },\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n    rw \u2190neg_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 \ud835\udd5c s (-f) \u2194 strict_convex_on \ud835\udd5c s f :=\nby rw [\u2190 neg_strict_convex_on_iff, neg_neg f]\n\nalias neg_convex_on_iff \u2194 _ concave_on.neg\nalias neg_concave_on_iff \u2194 _ convex_on.neg\nalias neg_strict_convex_on_iff \u2194 _ strict_concave_on.neg\nalias neg_strict_concave_on_iff \u2194 _ strict_convex_on.neg\n\nlemma convex_on.sub (hf : convex_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) : convex_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add hg.neg\n\nlemma concave_on.sub (hf : concave_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) : concave_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add hg.neg\n\nlemma strict_convex_on.sub (hf : strict_convex_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add hg.neg\n\nlemma strict_concave_on.sub (hf : strict_concave_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add hg.neg\n\nlemma convex_on.sub_strict_concave_on (hf : convex_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add_strict_convex_on hg.neg\n\nlemma concave_on.sub_strict_convex_on (hf : concave_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add_strict_concave_on hg.neg\n\nlemma strict_convex_on.sub_concave_on (hf : strict_convex_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 hf.add_convex_on hg.neg\n\nlemma strict_concave_on.sub_convex_on (hf : strict_concave_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f - g) :=\n(sub_eq_add_neg f g).symm \u25b8 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 \u03b2] [module \ud835\udd5c E] [has_smul \ud835\udd5c \u03b2]\n  {s : set E} {f : E \u2192 \u03b2}\n\n/-- Right translation preserves strict convexity. -/\nlemma strict_convex_on.translate_right (hf : strict_convex_on \ud835\udd5c s f) (c : E) :\n  strict_convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\n\u27e8hf.1.translate_preimage_right _, \u03bb x y hx hy hxy a b ha hb hab,\n  calc\n    f (c + (a \u2022 x + b \u2022 y)) = f (a \u2022 (c + x) + b \u2022 (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... < a \u2022 f (c + x) + b \u2022 f (c + y) : hf.2 hx hy ((add_right_injective c).ne hxy) ha hb hab\u27e9\n\n/-- Right translation preserves strict concavity. -/\nlemma strict_concave_on.translate_right (hf : strict_concave_on \ud835\udd5c s f) (c : E) :\n  strict_concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves strict convexity. -/\nlemma strict_convex_on.translate_left (hf : strict_convex_on \ud835\udd5c s f) (c : E) :\n  strict_convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c s f) (c : E) :\n  strict_concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection module\nvariables [has_smul \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.smul {c : \ud835\udd5c} (hc : 0 \u2264 c) (hf : convex_on \ud835\udd5c s f) : convex_on \ud835\udd5c s (\u03bb x, c \u2022 f x) :=\n\u27e8hf.1, \u03bb x y hx hy a b ha hb hab,\n  calc\n    c \u2022 f (a \u2022 x + b \u2022 y) \u2264 c \u2022 (a \u2022 f x + b \u2022 f y)\n      : smul_le_smul_of_nonneg (hf.2 hx hy ha hb hab) hc\n    ... = a \u2022 (c \u2022 f x) + b \u2022 (c \u2022 f y)\n      : by rw [smul_add, smul_comm c, smul_comm c]; apply_instance\u27e9\n\nlemma concave_on.smul {c : \ud835\udd5c} (hc : 0 \u2264 c) (hf : concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c s (\u03bb x, c \u2022 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 \ud835\udd5c] [add_comm_group E] [add_comm_group F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c F] [has_smul \ud835\udd5c \u03b2]\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 \u2192 \u03b2} (g : E \u2192\u1d43[\ud835\udd5c] F) {s : set F} (hf : convex_on \ud835\udd5c s f) :\n  convex_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 g) :=\n\u27e8hf.1.affine_preimage _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    (f \u2218 g) (a \u2022 x + b \u2022 y) = f (g (a \u2022 x + b \u2022 y))         : rfl\n                       ...  = f (a \u2022 (g x) + b \u2022 (g y))     : by rw [convex.combo_affine_apply hab]\n                       ...  \u2264 a \u2022 f (g x) + b \u2022 f (g y)     : hf.2 hx hy ha hb hab\u27e9\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 \u2192 \u03b2} (g : E \u2192\u1d43[\ud835\udd5c] F) {s : set F} (hf : concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 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 \ud835\udd5c] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection has_smul\nvariables [has_smul \ud835\udd5c E] [has_smul \ud835\udd5c \u03b2] {s : set E}\n\nlemma convex_on_iff_div {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 0 < a + b\n  \u2192 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) \u2264 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y :=\nand_congr iff.rfl\n\u27e8begin\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 [\u2190add_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\u27e9\n\nlemma concave_on_iff_div {f : E \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b\n  \u2192 0 < a + b \u2192 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y \u2264 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) :=\n@convex_on_iff_div _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ _\n\nlemma strict_convex_on_iff_div {f : E \u2192 \u03b2} :\n  strict_convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a\n    \u2192 0 < b \u2192 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) < (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y :=\nand_congr iff.rfl\n\u27e8begin\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 [\u2190add_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\u27e9\n\nlemma strict_concave_on_iff_div {f : E \u2192 \u03b2} :\n  strict_concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a\n    \u2192 0 < b \u2192 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y < f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) :=\n@strict_convex_on_iff_div _ _ \u03b2\u1d52\u1d48 _ _ _ _ _ _ _\n\nend has_smul\nend ordered_add_comm_monoid\nend linear_ordered_field\n\nsection\n\nvariables [linear_ordered_field \ud835\udd5c] [linear_ordered_cancel_add_comm_monoid \u03b2] [module \ud835\udd5c \u03b2]\n  [ordered_smul \ud835\udd5c \u03b2] {x y z : \ud835\udd5c} {s : set \ud835\udd5c} {f : \ud835\udd5c \u2192 \u03b2}\n\nlemma convex_on.le_right_of_left_le'' (hf : convex_on \ud835\udd5c s f) (hx : x \u2208 s) (hz : z \u2208 s)\n  (hxy : x < y) (hyz : y \u2264 z) (h : f x \u2264 f y) : f y \u2264 f z :=\nhyz.eq_or_lt.elim (\u03bb hyz, (congr_arg f hyz).le)\n  (\u03bb hyz, hf.le_right_of_left_le hx hz (Ioo_subset_open_segment \u27e8hxy, hyz\u27e9) h)\n\nlemma convex_on.le_left_of_right_le'' (hf : convex_on \ud835\udd5c s f) (hx : x \u2208 s) (hz : z \u2208 s)\n  (hxy : x \u2264 y) (hyz : y < z) (h : f z \u2264 f y) : f y \u2264 f x :=\nhxy.eq_or_lt.elim (\u03bb hxy, (congr_arg f hxy).ge)\n  (\u03bb hxy, hf.le_left_of_right_le hx hz (Ioo_subset_open_segment \u27e8hxy, hyz\u27e9) h)\n\nlemma concave_on.right_le_of_le_left'' (hf : concave_on \ud835\udd5c s f) (hx : x \u2208 s) (hz : z \u2208 s)\n  (hxy : x < y) (hyz : y \u2264 z) (h : f y \u2264 f x) : f z \u2264 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 \ud835\udd5c s f) (hx : x \u2208 s) (hz : z \u2208 s)\n  (hxy : x \u2264 y) (hyz : y < z) (h : f y \u2264 f z) : f x \u2264 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 \u2192 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 \u2192 finset formula\n| (true_) := \u2205 \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 \u222a Q.atomic_set\n| (forall_ x P) := {forall_ x P}\n\n\ndef formula.subst_atomic (\u03c3 : formula \u2192 formula) : formula \u2192 formula\n| (true_) := true_\n| (pred_ name args) := \u03c3 (pred_ name args)\n| (eq_ x y) := \u03c3 (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) := \u03c3 (forall_ x P)\n\n\n@[derive inhabited]\ndef valuation : Type := formula \u2192 bool\n\ndef formula.eval_atomic (val : valuation) : formula \u2192 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  \u2200 (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 : \u2200 (Q : formula), Q \u2208 P.atomic_set \u2192 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  (\u03c3 : formula \u2192 formula)\n  (val : valuation) :\n  (P.subst_atomic \u03c3).eval_atomic val =\n    P.eval_atomic (fun (Q : formula), (\u03c3 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  (\u03c3 : formula \u2192 formula) :\n  (formula.subst_atomic \u03c3 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 \u03c3 val],\n  apply h1,\nend\n\n\nexample\n  (P Q R S : formula)\n  (val : valuation)\n  (\u03c3 : formula \u2192 formula)\n  (h1 : P.eval_atomic val = Q.eval_atomic val) :\n  (S.subst_atomic (function.update_ite \u03c3 R P)).eval_atomic val =\n    (S.subst_atomic (function.update_ite \u03c3 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  (\u0394 : set formula)\n  (h1 : is_deduct (\u0394 \u222a {P}) Q) :\n  is_deduct \u0394 (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  (\u0394 : set formula)\n  (h1 : is_deduct \u0394 Q) :\n  \u2200 (\u0393 : set formula), is_deduct (\u0394 \u222a \u0393) Q :=\nbegin\n  intros \u0393,\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  (\u0394 : set formula)\n  (h1 : is_deduct \u0394 (P.imp_ Q)) :\n  is_deduct (\u0394 \u222a {P}) Q :=\nbegin\n  have s1 : is_deduct (\u0394 \u222a {P}) (P.imp_ Q),\n  exact T_14_10 (P.imp_ Q) \u0394 h1 {P},\n\n  have s2 : is_deduct (\u0394 \u222a {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  \u2200 (\u0393 : set formula), is_deduct \u0393 Q :=\nbegin\n  unfold is_proof at h1,\n\n  intros \u0393,\n  rewrite <- set.union_empty \u0393,\n  rewrite set.union_comm,\n  exact T_14_10 Q \u2205 h1 \u0393,\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  (\u0394 \u0393 : set formula)\n  (h1 : is_deduct \u0394 P)\n  (h2 : is_deduct \u0393 (P.imp_ Q)) :\n  is_deduct (\u0394 \u222a \u0393) Q :=\nbegin\n  have s1 : is_deduct (\u0394 \u222a \u0393) P,\n  apply T_14_10,\n  exact h1,\n\n  have s2 : is_deduct (\u0394 \u222a \u0393) (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  (\u0394 : set formula)\n  (h1 : is_deduct \u0394 P)\n  (h2 : is_deduct \u0394 (P.imp_ Q)) :\n  is_deduct \u0394 Q :=\nbegin\n  have s1 : is_deduct (\u0394 \u222a \u0394) Q, \n  exact T_14_12 P Q \u0394 \u0394 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  (\u0394 : set formula)\n  (h1 : is_deduct \u0394 P)\n  (h2 : is_deduct \u0394 (P.imp_ Q)) :\n  is_deduct \u0394 Q :=\nbegin\n  exact is_deduct.mp_ P Q h2 h1,\nend\n\n\ntheorem C_14_14\n  (P Q : formula)\n  (\u0393 : set formula)\n  (h1 : is_proof P)\n  (h2 : is_deduct \u0393 (P.imp_ Q)) :\n  is_deduct \u0393 Q :=\nbegin\n  have s1 : is_deduct \u0393 P,\n  exact C_14_11 P h1 \u0393,\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  (\u0394 : set formula)\n  (h1 : is_deduct \u0394 P)\n  (h2 : is_proof (P.imp_ Q)) :\n  is_deduct \u0394 Q :=\nbegin\n  have s1 : is_deduct \u0394 (P.imp_ Q),\n  exact C_14_11 (P.imp_ Q) h2 \u0394,\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  (\u0394 \u0393 : set formula)\n  (h1 : is_deduct \u0393 Q)\n  (h2 : \u2200 (P : formula), P \u2208 \u0393 \u2192 is_deduct \u0394 P) :\n  is_deduct \u0394 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  (\u0393 : set formula)\n  (h1 : is_deduct \u0393 Q)\n  (h2 : \u2200 (P : formula), P \u2208 \u0393 \u2192 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 \u2205 \u0393 h1 h2,\nend\n\n\ntheorem eval_not\n  (P : formula)\n  (val : valuation) :\n  formula.eval_atomic val (not_ P) = bool.tt \u2194\n    \u00ac (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 \u2194\n    ((formula.eval_atomic val P = bool.tt) \u2192 (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' \u2208 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 \u2194 \u00ac 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  (\u0394_U : set formula)\n  (val : valuation)\n  (\u0394_U' : set formula)\n  (h1 : coe P.atomic_set \u2286 \u0394_U)\n  (h2 : \u0394_U' = \u0394_U.image (eval_atomic_ff_to_not val))\n  (h3 : P' = eval_atomic_ff_to_not val P) :\n  is_deduct \u0394_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  (\u0394 : set formula)\n  (h1 : is_deduct (\u0394 \u222a {U}) P)\n  (h2 : is_deduct (\u0394 \u222a {U.not_}) P) :\n  is_deduct \u0394 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  (\u0394 : set formula)\n  (val : valuation)\n  (b : bool)\n  (h1_\u0394: \u2200 (U' : formula), (U' \u2208 \u0394) \u2192 U'.is_atomic)\n  (h1_U: U.is_atomic)\n  (h2: U \u2209 \u0394) :\n  \u0394.image (eval_atomic_ff_to_not (function.update_ite val U b)) =\n    \u0394.image (eval_atomic_ff_to_not val) :=\nbegin\n  apply set.image_congr,\n  intros U' a1,\n  specialize h1_\u0394 U' a1,\n  cases b,\n  {\n    simp only [eval_atomic_ff_to_not_of_function_update_ite_ff U' U val h1_\u0394],\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_\u0394],\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  (\u0394 : set formula)\n  (h1_\u0394 : \u2200 (U' : formula), U' \u2208 \u0394 \u2192 U'.is_atomic)\n  (h1_U : U.is_atomic)\n  (h2 : U \u2209 \u0394)\n  (h3 : \u2200 (val : valuation), is_deduct ((\u0394.image (eval_atomic_ff_to_not val)) \u222a {eval_atomic_ff_to_not val U}) P) :\n  \u2200 (val : valuation), is_deduct (\u0394.image (eval_atomic_ff_to_not val)) P :=\nbegin\n  intros val,\n  apply T_14_9_deduct P U (\u0394.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 \u0394 val bool.tt h1_\u0394 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 \u0394 val bool.ff h1_\u0394 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  (\u0394_U : finset formula)\n  (h1 : P.is_tauto_atomic)\n  (h2 : \u0394_U \u2286 P.atomic_set)\n  (h3 : \u2200 (val : valuation), is_deduct (\u0394_U.image (eval_atomic_ff_to_not val)) P) :\n  is_deduct \u2205 P :=\nbegin\n  induction \u0394_U using finset.induction_on,\n  case h\u2081\n  {\n    simp only [finset.image_empty, finset.coe_empty, forall_const] at h3,\n\n    exact h3,\n  },\n  case h\u2082 : U \u0394_U \u0394_U_1 \u0394_U_2\n  {\n    apply \u0394_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 \u0394_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 \u0394_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 : \u2115}\n\nvariables (\ud835\udd5c : Type*)\n[is_R_or_C \ud835\udd5c]\n\nopen_locale big_operators complex_conjugate matrix topological_space\n\nlocal notation `\ud835\udd5c^n` := (euclidean_space \ud835\udd5c (fin n))\n\nlocal notation `M_n` := (matrix (fin n) (fin n) \ud835\udd5c)\n\nlocal notation `U_n` := matrix.unitary_group (fin n) \ud835\udd5c\n\nvariables (A B : \u2115 \u2192 M_n) (L : M_n)\n\n\n/-\nmatrix_SVD should look like this:\n-/\nnoncomputable def matrix_SVD (M : M_n) : (fin 3) \u2192 M_n := sorry\n\n\ntheorem limit_svd_is_svd (h_lim : filter.tendsto A filter.at_top (\ud835\udcdd 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 {\u03b1 : Type*} [linear_order \u03b1] (C : config \u03b1)\n\nlemma config.join_n2_n2_case_ff\n  (S : finset \u03b1) (n : \u2115) (a x b : \u03b1) (c1 c2 : list \u03b1) (lab : C.label S)\n  (a_in_S : a \u2208 S) (x_in_S : x \u2208 S) (b_in_S : b \u2208 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 : \u00aclab.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 \u2260 [] := by simp,\n  rcases list.take_last h_b_c2 with \u27e8c, c3, eq_c2\u27e9,\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 \u2208 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 \u27e8\u27e8_, _\u27e9, _, _\u27e9; try {simp}; try {tauto},\n    split, tauto, split, dec_trivial,\n    rw \u2190eq_c2, rw \u2190eq_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 \u03b1) (n : \u2115) (a x b : \u03b1) (c1 c2 : list \u03b1) (lab : C.label S)\n  (a_in_S : a \u2208 S) (x_in_S : x \u2208 S) (b_in_S : b \u2208 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 \u2190finset.mem_mirror at a_in_S x_in_S b_in_S,\n  rw \u2190mirror.ncup at hc1 hc2,\n  rw \u2190list.mirror_in at c1_in_S c2_in_S,\n  simp at hc1 hc2,\n  have hba := hab, rw \u2190mirror_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 \u03b1)\n  {n : \u2115} \n  (cap4_free : \u00acC.has_ncap 4 S)\n  {c1 : list \u03b1} (hc1 : C.ncup (n+2) c1) (c1_in_S : c1.in S)\n  {c2 : list \u03b1} (hc2 : C.ncup (n+2) c2) (c2_in_S : c2.in S)\n  (x : \u03b1) (hx1 : x \u2208 c1.last') (hx2 : x \u2208 c2.head') : C.has_ngon (n+3) S :=\nbegin\n  -- Introduce variables\n  have c1_size2 : 2 \u2264 c1.length := by cases hc1; linarith,\n  rcases list.take_last2 c1_size2 with \u27e8a, x, c1', eq_c1\u27e9, \n  subst eq_c1, simp at hx1, subst hx1,\n  have c2_size2 : 2 \u2264 c2.length := by cases hc2; linarith,\n  rcases list.take_head2 c2_size2 with \u27e8x, b, c2', eq_c2\u27e9,\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 := \u0394 0\ndef Y := \u0394 1\ndef Z := \u0394 2\ndef W := \u0394 0  -- W and X are the same variable\n\n-- an interpretation\n\ndef init : var \u2192 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 := \u27e8 X \u27e9   -- []: \"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 \u2192 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 \u2192 Q) \u2192 ((Q \u2192 F) \u2192 (P \u2192 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) 2020 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\n\nuniverses u v w\n\n@[inline] def id {\u03b1 : Sort u} (a : \u03b1) : \u03b1 := a\n\n/- `idRhs` is an auxiliary declaration used to implement \"smart unfolding\". It is used as a marker. -/\n@[macroInline, reducible] def idRhs (\u03b1 : Sort u) (a : \u03b1) : \u03b1 := a\n\nabbrev Function.comp {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b4 : Sort w} (f : \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b4 :=\n  fun x => f (g x)\n\nabbrev Function.const {\u03b1 : Sort u} (\u03b2 : Sort v) (a : \u03b1) : \u03b2 \u2192 \u03b1 :=\n  fun x => a\n\nset_option checkBinderAnnotations false in\n@[reducible] def inferInstance {\u03b1 : Sort u} [i : \u03b1] : \u03b1 := i\nset_option checkBinderAnnotations false in\n@[reducible] def inferInstanceAs (\u03b1 : Sort u) [i : \u03b1] : \u03b1 := i\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\ninductive PUnit : Sort u where\n  | unit : PUnit\n\n/-- An abbreviation for `PUnit.{0}`, its most common instantiation.\n    This Type should be preferred over `PUnit` where possible to avoid\n    unnecessary universe parameters. -/\nabbrev Unit : Type := PUnit\n\n@[matchPattern] abbrev Unit.unit : Unit := PUnit.unit\n\n/-- Auxiliary unsafe constant used by the Compiler when erasing proofs from code. -/\nunsafe axiom lcProof {\u03b1 : Prop} : \u03b1\n\n/-- Auxiliary unsafe constant used by the Compiler to mark unreachable code. -/\nunsafe axiom lcUnreachable {\u03b1 : Sort u} : \u03b1\n\ninductive True : Prop where\n  | intro : True\n\ninductive False : Prop\n\ninductive Empty : Type\n\ndef Not (a : Prop) : Prop := a \u2192 False\n\n@[macroInline] def False.elim {C : Sort u} (h : False) : C :=\n  False.rec (fun _ => C) h\n\n@[macroInline] def absurd {a : Prop} {b : Sort v} (h\u2081 : a) (h\u2082 : Not a) : b :=\n  False.elim (h\u2082 h\u2081)\n\ninductive Eq {\u03b1 : Sort u} (a : \u03b1) : \u03b1 \u2192 Prop where\n  | refl {} : Eq a a\n\n@[simp] abbrev Eq.ndrec.{u1, u2} {\u03b1 : Sort u2} {a : \u03b1} {motive : \u03b1 \u2192 Sort u1} (m : motive a) {b : \u03b1} (h : Eq a b) : motive b :=\n  Eq.rec (motive := fun \u03b1 _ => motive \u03b1) m h\n\n@[matchPattern] def rfl {\u03b1 : Sort u} {a : \u03b1} : Eq a a := Eq.refl a\n\n@[simp] theorem id_eq (a : \u03b1) : Eq (id a) a := rfl\n\ntheorem Eq.subst {\u03b1 : Sort u} {motive : \u03b1 \u2192 Prop} {a b : \u03b1} (h\u2081 : Eq a b) (h\u2082 : motive a) : motive b :=\n  Eq.ndrec h\u2082 h\u2081\n\ntheorem Eq.symm {\u03b1 : Sort u} {a b : \u03b1} (h : Eq a b) : Eq b a :=\n  h \u25b8 rfl\n\ntheorem Eq.trans {\u03b1 : Sort u} {a b c : \u03b1} (h\u2081 : Eq a b) (h\u2082 : Eq b c) : Eq a c :=\n  h\u2082 \u25b8 h\u2081\n\n@[macroInline] def cast {\u03b1 \u03b2 : Sort u} (h : Eq \u03b1 \u03b2) (a : \u03b1) : \u03b2 :=\n  Eq.rec (motive := fun \u03b1 _ => \u03b1) a h\n\ntheorem congrArg {\u03b1 : Sort u} {\u03b2 : Sort v} {a\u2081 a\u2082 : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : Eq a\u2081 a\u2082) : Eq (f a\u2081) (f a\u2082) :=\n  h \u25b8 rfl\n\ntheorem congr {\u03b1 : Sort u} {\u03b2 : Sort v} {f\u2081 f\u2082 : \u03b1 \u2192 \u03b2} {a\u2081 a\u2082 : \u03b1} (h\u2081 : Eq f\u2081 f\u2082) (h\u2082 : Eq a\u2081 a\u2082) : Eq (f\u2081 a\u2081) (f\u2082 a\u2082) :=\n  h\u2081 \u25b8 h\u2082 \u25b8 rfl\n\ntheorem congrFun {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {f g : (x : \u03b1) \u2192  \u03b2 x} (h : Eq f g) (a : \u03b1) : Eq (f a) (g a) :=\n  h \u25b8 rfl\n\n/-\nInitialize the Quotient Module, which effectively adds the following definitions:\n\nconstant Quot {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Sort u\n\nconstant Quot.mk {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : Quot r\n\nconstant Quot.lift {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) :\n  (\u2200 a b : \u03b1, r a b \u2192 Eq (f a) (f b)) \u2192 Quot r \u2192 \u03b2\n\nconstant Quot.ind {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Quot r \u2192 Prop} :\n  (\u2200 a : \u03b1, \u03b2 (Quot.mk r a)) \u2192 \u2200 q : Quot r, \u03b2 q\n-/\ninit_quot\n\ninductive HEq {\u03b1 : Sort u} (a : \u03b1) : {\u03b2 : Sort u} \u2192 \u03b2 \u2192 Prop where\n  | refl {} : HEq a a\n\n@[matchPattern] def HEq.rfl {\u03b1 : Sort u} {a : \u03b1} : HEq a a :=\n  HEq.refl a\n\ntheorem eqOfHEq {\u03b1 : Sort u} {a a' : \u03b1} (h : HEq a a') : Eq a a' :=\n  have : (\u03b1 \u03b2 : Sort u) \u2192 (a : \u03b1) \u2192 (b : \u03b2) \u2192 HEq a b \u2192 (h : Eq \u03b1 \u03b2) \u2192 Eq (cast h a) b :=\n    fun \u03b1 \u03b2 a b h\u2081 =>\n      HEq.rec (motive := fun {\u03b2} (b : \u03b2) (h : HEq a b) => (h\u2082 : Eq \u03b1 \u03b2) \u2192 Eq (cast h\u2082 a) b)\n        (fun (h\u2082 : Eq \u03b1 \u03b1) => rfl)\n        h\u2081\n  this \u03b1 \u03b1 a a' h rfl\n\nstructure Prod (\u03b1 : Type u) (\u03b2 : Type v) where\n  fst : \u03b1\n  snd : \u03b2\n\nattribute [unbox] Prod\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` can be propositions.\n   We use this Type internally to automatically generate the brecOn recursor. -/\nstructure PProd (\u03b1 : Sort u) (\u03b2 : Sort v) where\n  fst : \u03b1\n  snd : \u03b2\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` are in the same universe. -/\nstructure MProd (\u03b1 \u03b2 : Type u) where\n  fst : \u03b1\n  snd : \u03b2\n\nstructure And (a b : Prop) : Prop where\n  intro :: (left : a) (right : b)\n\ninductive Or (a b : Prop) : Prop where\n  | inl (h : a) : Or a b\n  | inr (h : b) : Or a b\n\ninductive Bool : Type where\n  | false : Bool\n  | true : Bool\n\nexport Bool (false true)\n\n/- Remark: Subtype must take a Sort instead of Type because of the axiom strongIndefiniteDescription. -/\nstructure Subtype {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) where\n  val : \u03b1\n  property : p val\n\n/-- Gadget for optional parameter support. -/\n@[reducible] def optParam (\u03b1 : Sort u) (default : \u03b1) : Sort u := \u03b1\n\n/-- Gadget for marking output parameters in type classes. -/\n@[reducible] def outParam (\u03b1 : Sort u) : Sort u := \u03b1\n\n/-- Auxiliary Declaration used to implement the notation (a : \u03b1) -/\n@[reducible] def typedExpr (\u03b1 : Sort u) (a : \u03b1) : \u03b1 := a\n\n/-- Auxiliary Declaration used to implement the named patterns `x@p` -/\n@[reducible] def namedPattern {\u03b1 : Sort u} (x a : \u03b1) : \u03b1 := a\n\n/- Auxiliary axiom used to implement `sorry`. -/\n@[extern \"lean_sorry\", neverExtract]\naxiom sorryAx (\u03b1 : Sort u) (synthetic := true) : \u03b1\n\ntheorem eqFalseOfNeTrue : {b : Bool} \u2192 Not (Eq b true) \u2192 Eq b false\n  | true, h => False.elim (h rfl)\n  | false, h => rfl\n\ntheorem eqTrueOfNeFalse : {b : Bool} \u2192 Not (Eq b false) \u2192 Eq b true\n  | true, h => rfl\n  | false, h => False.elim (h rfl)\n\ntheorem neFalseOfEqTrue : {b : Bool} \u2192 Eq b true \u2192 Not (Eq b false)\n  | true, _  => fun h => Bool.noConfusion h\n  | false, h => Bool.noConfusion h\n\ntheorem neTrueOfEqFalse : {b : Bool} \u2192 Eq b false \u2192 Not (Eq b true)\n  | true, h  => Bool.noConfusion h\n  | false, _ => fun h => Bool.noConfusion h\n\nclass Inhabited (\u03b1 : Sort u) where\n  mk {} :: (default : \u03b1)\n\nconstant arbitrary [Inhabited \u03b1] : \u03b1 :=\n  Inhabited.default\n\ninstance : Inhabited (Sort u) where\n  default := PUnit\n\ninstance (\u03b1 : Sort u) {\u03b2 : Sort v} [Inhabited \u03b2] : Inhabited (\u03b1 \u2192 \u03b2) where\n  default := fun _ => arbitrary\n\ninstance (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(a : \u03b1) \u2192 Inhabited (\u03b2 a)] : Inhabited ((a : \u03b1) \u2192 \u03b2 a) where\n  default := fun _ => arbitrary\n\nderiving instance Inhabited for Bool\n\n/-- Universe lifting operation from Sort to Type -/\nstructure PLift (\u03b1 : Sort u) : Type u where\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and PLift \u03b1 -/\ntheorem PLift.upDown {\u03b1 : Sort u} : \u2200 (b : PLift \u03b1), Eq (up (down b)) b\n  | up a => rfl\n\ntheorem PLift.downUp {\u03b1 : Sort u} (a : \u03b1) : Eq (down (up a)) a :=\n  rfl\n\n/- Pointed types -/\nstructure PointedType where\n  (type : Type u)\n  (val : type)\n\ninstance : Inhabited PointedType.{u} where\n  default := { type := PUnit.{u+1}, val := \u27e8\u27e9 }\n\n/-- Universe lifting operation -/\nstructure ULift.{r, s} (\u03b1 : Type s) : Type (max s r) where\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and ULift.{v} \u03b1 -/\ntheorem ULift.upDown {\u03b1 : Type u} : \u2200 (b : ULift.{v} \u03b1), Eq (up (down b)) b\n  | up a => rfl\n\ntheorem ULift.downUp {\u03b1 : Type u} (a : \u03b1) : Eq (down (up.{v} a)) a :=\n  rfl\n\nclass inductive Decidable (p : Prop) where\n  | isFalse (h : Not p) : Decidable p\n  | isTrue  (h : p) : Decidable p\n\n@[inlineIfReduce, nospecialize] def Decidable.decide (p : Prop) [h : Decidable p] : Bool :=\n  Decidable.casesOn (motive := fun _ => Bool) h (fun _ => false) (fun _ => true)\n\nexport Decidable (isTrue isFalse decide)\n\nabbrev DecidablePred {\u03b1 : Sort u} (r : \u03b1 \u2192 Prop) :=\n  (a : \u03b1) \u2192 Decidable (r a)\n\nabbrev DecidableRel {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :=\n  (a b : \u03b1) \u2192 Decidable (r a b)\n\nabbrev DecidableEq (\u03b1 : Sort u) :=\n  (a b : \u03b1) \u2192 Decidable (Eq a b)\n\ndef decEq {\u03b1 : Sort u} [s : DecidableEq \u03b1] (a b : \u03b1) : Decidable (Eq a b) :=\n  s a b\n\ntheorem decideEqTrue : [s : Decidable p] \u2192 p \u2192 Eq (decide p) true\n  | isTrue  _, _   => rfl\n  | isFalse h\u2081, h\u2082 => absurd h\u2082 h\u2081\n\ntheorem decideEqFalse : [s : Decidable p] \u2192 Not p \u2192 Eq (decide p) false\n  | isTrue  h\u2081, h\u2082 => absurd h\u2081 h\u2082\n  | isFalse h, _   => rfl\n\ntheorem ofDecideEqTrue [s : Decidable p] : Eq (decide p) true \u2192 p := fun h =>\n  match (generalizing := false) s with\n  | isTrue  h\u2081 => h\u2081\n  | isFalse h\u2081 => absurd h (neTrueOfEqFalse (decideEqFalse h\u2081))\n\ntheorem ofDecideEqFalse [s : Decidable p] : Eq (decide p) false \u2192 Not p := fun h =>\n  match (generalizing := false) s with\n  | isTrue  h\u2081 => absurd h (neFalseOfEqTrue (decideEqTrue h\u2081))\n  | isFalse h\u2081 => h\u2081\n\n@[inline] instance : DecidableEq Bool :=\n  fun a b => match a, b with\n   | false, false => isTrue rfl\n   | false, true  => isFalse (fun h => Bool.noConfusion h)\n   | true, false  => isFalse (fun h => Bool.noConfusion h)\n   | true, true   => isTrue rfl\n\nclass BEq (\u03b1 : Type u) where\n  beq : \u03b1 \u2192 \u03b1 \u2192 Bool\n\nopen BEq (beq)\n\ninstance [DecidableEq \u03b1] : BEq \u03b1 where\n  beq a b := decide (Eq a b)\n\n-- We use \"dependent\" if-then-else to be able to communicate the if-then-else condition\n-- to the branches\n@[macroInline] def dite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t : c \u2192 \u03b1) (e : Not c \u2192 \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h e t\n\n/- if-then-else -/\n\n@[macroInline] def ite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t e : \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h (fun _ => e) (fun _ => t)\n\n@[macroInline] instance {p q} [dp : Decidable p] [dq : Decidable q] : Decidable (And p q) :=\n  match dp with\n  | isTrue  hp =>\n    match dq with\n    | isTrue hq  => isTrue \u27e8hp, hq\u27e9\n    | isFalse hq => isFalse (fun h => hq (And.right h))\n  | isFalse hp =>\n    isFalse (fun h => hp (And.left h))\n\n@[macroInline] instance [dp : Decidable p] [dq : Decidable q] : Decidable (Or p q) :=\n  match dp with\n  | isTrue  hp => isTrue (Or.inl hp)\n  | isFalse hp =>\n    match dq with\n    | isTrue hq  => isTrue (Or.inr hq)\n    | isFalse hq =>\n      isFalse fun h => match h with\n        | Or.inl h => hp h\n        | Or.inr h => hq h\n\ninstance [dp : Decidable p] : Decidable (Not p) :=\n  match dp with\n  | isTrue hp  => isFalse (absurd hp)\n  | isFalse hp => isTrue hp\n\n/- Boolean operators -/\n\n@[macroInline] def cond {\u03b1 : Type u} (c : Bool) (x y : \u03b1) : \u03b1 :=\n  match c with\n  | true  => x\n  | false => y\n\n@[macroInline] def or (x y : Bool) : Bool :=\n  match x with\n  | true  => true\n  | false => y\n\n@[macroInline] def and (x y : Bool) : Bool :=\n  match x with\n  | false => false\n  | true  => y\n\n@[inline] def not : Bool \u2192 Bool\n  | true  => false\n  | false => true\n\ninductive Nat where\n  | zero : Nat\n  | succ (n : Nat) : Nat\n\ninstance : Inhabited Nat where\n  default := Nat.zero\n\n/- For numeric literals notation -/\nclass OfNat (\u03b1 : Type u) (n : Nat) where\n  ofNat : \u03b1\n\n@[defaultInstance 100] /- low prio -/\ninstance (n : Nat) : OfNat Nat n where\n  ofNat := n\n\nclass LE (\u03b1 : Type u) where le : \u03b1 \u2192 \u03b1 \u2192 Prop\nclass LT (\u03b1 : Type u) where lt : \u03b1 \u2192 \u03b1 \u2192 Prop\n\n@[reducible] def GE.ge {\u03b1 : Type u} [LE \u03b1] (a b : \u03b1) : Prop := LE.le b a\n@[reducible] def GT.gt {\u03b1 : Type u} [LT \u03b1] (a b : \u03b1) : Prop := LT.lt b a\n\nclass HAdd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAdd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HSub (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hSub : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HMul (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hMul : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HDiv (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hDiv : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HMod (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hMod : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HPow (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hPow : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HAppend (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAppend : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HOrElse (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hOrElse : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HAndThen (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAndThen : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HAnd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAnd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HXor (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hXor : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HOr (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hOr : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HShiftLeft (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hShiftLeft : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HShiftRight (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hShiftRight : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass Add (\u03b1 : Type u) where\n  add : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Sub (\u03b1 : Type u) where\n  sub : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Mul (\u03b1 : Type u) where\n  mul : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Neg (\u03b1 : Type u) where\n  neg : \u03b1 \u2192 \u03b1\n\nclass Div (\u03b1 : Type u) where\n  div : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Mod (\u03b1 : Type u) where\n  mod : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Pow (\u03b1 : Type u) where\n  pow : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Append (\u03b1 : Type u) where\n  append : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass OrElse (\u03b1 : Type u) where\n  orElse  : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass AndThen (\u03b1 : Type u) where\n  andThen : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass AndOp (\u03b1 : Type u) where\n  and : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Xor (\u03b1 : Type u) where\n  xor : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass OrOp (\u03b1 : Type u) where\n  or : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Complement (\u03b1 : Type u) where\n  complement : \u03b1 \u2192 \u03b1\n\nclass ShiftLeft (\u03b1 : Type u) where\n  shiftLeft : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass ShiftRight (\u03b1 : Type u) where\n  shiftRight : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n@[defaultInstance]\ninstance [Add \u03b1] : HAdd \u03b1 \u03b1 \u03b1 where\n  hAdd a b := Add.add a b\n\n@[defaultInstance]\ninstance [Sub \u03b1] : HSub \u03b1 \u03b1 \u03b1 where\n  hSub a b := Sub.sub a b\n\n@[defaultInstance]\ninstance [Mul \u03b1] : HMul \u03b1 \u03b1 \u03b1 where\n  hMul a b := Mul.mul a b\n\n@[defaultInstance]\ninstance [Div \u03b1] : HDiv \u03b1 \u03b1 \u03b1 where\n  hDiv a b := Div.div a b\n\n@[defaultInstance]\ninstance [Mod \u03b1] : HMod \u03b1 \u03b1 \u03b1 where\n  hMod a b := Mod.mod a b\n\n@[defaultInstance]\ninstance [Pow \u03b1] : HPow \u03b1 \u03b1 \u03b1 where\n  hPow a b := Pow.pow a b\n\n@[defaultInstance]\ninstance [Append \u03b1] : HAppend \u03b1 \u03b1 \u03b1 where\n  hAppend a b := Append.append a b\n\n@[defaultInstance]\ninstance [OrElse \u03b1] : HOrElse \u03b1 \u03b1 \u03b1 where\n  hOrElse a b := OrElse.orElse a b\n\n@[defaultInstance]\ninstance [AndThen \u03b1] : HAndThen \u03b1 \u03b1 \u03b1 where\n  hAndThen a b := AndThen.andThen a b\n\n@[defaultInstance]\ninstance [AndOp \u03b1] : HAnd \u03b1 \u03b1 \u03b1 where\n  hAnd a b := AndOp.and a b\n\n@[defaultInstance]\ninstance [Xor \u03b1] : HXor \u03b1 \u03b1 \u03b1 where\n  hXor a b := Xor.xor a b\n\n@[defaultInstance]\ninstance [OrOp \u03b1] : HOr \u03b1 \u03b1 \u03b1 where\n  hOr a b := OrOp.or a b\n\n@[defaultInstance]\ninstance [ShiftLeft \u03b1] : HShiftLeft \u03b1 \u03b1 \u03b1 where\n  hShiftLeft a b := ShiftLeft.shiftLeft a b\n\n@[defaultInstance]\ninstance [ShiftRight \u03b1] : HShiftRight \u03b1 \u03b1 \u03b1 where\n  hShiftRight a b := ShiftRight.shiftRight a b\n\nopen HAdd (hAdd)\nopen HMul (hMul)\nopen HPow (hPow)\nopen HAppend (hAppend)\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_add\"]\nprotected def Nat.add : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, Nat.zero   => a\n  | a, Nat.succ b => Nat.succ (Nat.add a b)\n\ninstance : Add Nat where\n  add := Nat.add\n\n/- We mark the following definitions as pattern to make sure they can be used in recursive equations,\n   and reduced by the equation Compiler. -/\nattribute [matchPattern] Nat.add Add.add HAdd.hAdd Neg.neg\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_mul\"]\nprotected def Nat.mul : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0          => 0\n  | a, Nat.succ b => Nat.add (Nat.mul a b) a\n\ninstance : Mul Nat where\n  mul := Nat.mul\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_pow\"]\nprotected def Nat.pow (m : @& Nat) : (@& Nat) \u2192 Nat\n  | 0      => 1\n  | succ n => Nat.mul (Nat.pow m n) m\n\ninstance : Pow Nat where\n  pow := Nat.pow\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_dec_eq\"]\ndef Nat.beq : (@& Nat) \u2192 (@& Nat) \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => false\n  | succ n, zero   => false\n  | succ n, succ m => beq n m\n\ntheorem Nat.eqOfBeqEqTrue : {n m : Nat} \u2192 Eq (beq n m) true \u2192 Eq n m\n  | zero,   zero,   h => rfl\n  | zero,   succ m, h => Bool.noConfusion h\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : Eq (beq n m) true := h\n    have : Eq n m := eqOfBeqEqTrue this\n    this \u25b8 rfl\n\ntheorem Nat.neOfBeqEqFalse : {n m : Nat} \u2192 Eq (beq n m) false \u2192 Not (Eq n m)\n  | zero,   zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | zero,   succ m, h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, zero,   h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have : Eq (beq n m) false := h\u2081\n    Nat.noConfusion h\u2082 (fun h\u2082 => absurd h\u2082 (neOfBeqEqFalse this))\n\n@[extern \"lean_nat_dec_eq\"]\nprotected def Nat.decEq (n m : @& Nat) : Decidable (Eq n m) :=\n  match h:beq n m with\n  | true  => isTrue (eqOfBeqEqTrue h)\n  | false => isFalse (neOfBeqEqFalse h)\n\n@[inline] instance : DecidableEq Nat := Nat.decEq\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_dec_le\"]\ndef Nat.ble : @& Nat \u2192 @& Nat \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => true\n  | succ n, zero   => false\n  | succ n, succ m => ble n m\n\nprotected def Nat.le (n m : Nat) : Prop :=\n  Eq (ble n m) true\n\ninstance : LE Nat where\n  le := Nat.le\n\nprotected def Nat.lt (n m : Nat) : Prop :=\n  Nat.le (succ n) m\n\ninstance : LT Nat where\n  lt := Nat.lt\n\ntheorem Nat.notSuccLeZero : \u2200 (n : Nat), LE.le (succ n) 0 \u2192 False\n  | 0,      h => nomatch h\n  | succ n, h => nomatch h\n\ntheorem Nat.notLtZero (n : Nat) : Not (LT.lt n 0) :=\n  notSuccLeZero n\n\n@[extern \"lean_nat_dec_le\"]\ninstance Nat.decLe (n m : @& Nat) : Decidable (LE.le n m) :=\n  decEq (Nat.ble n m) true\n\n@[extern \"lean_nat_dec_lt\"]\ninstance Nat.decLt (n m : @& Nat) : Decidable (LT.lt n m) :=\n  decLe (succ n) m\n\ntheorem Nat.zeroLe : (n : Nat) \u2192 LE.le 0 n\n  | zero   => rfl\n  | succ n => rfl\n\ntheorem Nat.succLeSucc {n m : Nat} (h : LE.le n m) : LE.le (succ n) (succ m) :=\n  h\n\ntheorem Nat.zeroLtSucc (n : Nat) : LT.lt 0 (succ n) :=\n  succLeSucc (zeroLe n)\n\ntheorem Nat.leStep : {n m : Nat} \u2192 LE.le n m \u2192 LE.le n (succ m)\n  | zero,   zero,   h => rfl\n  | zero,   succ n, h => rfl\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : LE.le n m := h\n    have : LE.le n (succ m) := leStep this\n    succLeSucc this\n\nprotected theorem Nat.leTrans : {n m k : Nat} \u2192 LE.le n m \u2192 LE.le m k \u2192 LE.le n k\n  | zero,   m,      k,      h\u2081, h\u2082 => zeroLe _\n  | succ n, zero,   k,      h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | succ n, succ m, zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2082\n  | succ n, succ m, succ k, h\u2081, h\u2082 =>\n    have h\u2081' : LE.le n m := h\u2081\n    have h\u2082' : LE.le m k := h\u2082\n    show LE.le n k from\n    Nat.leTrans h\u2081' h\u2082'\n\nprotected theorem Nat.ltTrans {n m k : Nat} (h\u2081 : LT.lt n m) : LT.lt m k \u2192 LT.lt n k :=\n  Nat.leTrans (leStep h\u2081)\n\ntheorem Nat.leSucc : (n : Nat) \u2192 LE.le n (succ n)\n  | zero   => rfl\n  | succ n => leSucc n\n\ntheorem Nat.leSuccOfLe {n m : Nat} (h : LE.le n m) : LE.le n (succ m) :=\n  Nat.leTrans h (leSucc m)\n\nprotected theorem Nat.eqOrLtOfLe : {n m: Nat} \u2192 LE.le n m \u2192 Or (Eq n m) (LT.lt n m)\n  | zero,   zero,   h => Or.inl rfl\n  | zero,   succ n, h => Or.inr (zeroLe n)\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : LE.le n m := h\n    match Nat.eqOrLtOfLe this with\n    | Or.inl h => Or.inl (h \u25b8 rfl)\n    | Or.inr h => Or.inr (succLeSucc h)\n\nprotected def Nat.leRefl : (n : Nat) \u2192 LE.le n n\n  | zero   => rfl\n  | succ n => Nat.leRefl n\n\nprotected theorem Nat.ltOrGe (n m : Nat) : Or (LT.lt n m) (GE.ge n m) :=\n  match m with\n  | zero   => Or.inr (zeroLe n)\n  | succ m =>\n    match Nat.ltOrGe n m with\n    | Or.inl h => Or.inl (leSuccOfLe h)\n    | Or.inr h =>\n      match Nat.eqOrLtOfLe h with\n      | Or.inl h1 => Or.inl (h1 \u25b8 Nat.leRefl _)\n      | Or.inr h1 => Or.inr h1\n\nprotected theorem Nat.leAntisymm : {n m : Nat} \u2192 LE.le n m \u2192 LE.le m n \u2192 Eq n m\n  | zero,   zero,   h\u2081, h\u2082 => rfl\n  | succ n, zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | zero,   succ m, h\u2081, h\u2082 => Bool.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have h\u2081' : LE.le n m := h\u2081\n    have h\u2082' : LE.le m n := h\u2082\n    (Nat.leAntisymm h\u2081' h\u2082') \u25b8 rfl\n\nprotected theorem Nat.ltOfLeOfNe {n m : Nat} (h\u2081 : LE.le n m) (h\u2082 : Not (Eq n m)) : LT.lt n m :=\n  match Nat.ltOrGe n m with\n  | Or.inl h\u2083 => h\u2083\n  | Or.inr h\u2083 => absurd (Nat.leAntisymm h\u2081 h\u2083) h\u2082\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"lean_nat_sub(#1, lean_box(1))\"]\ndef Nat.pred : (@& Nat) \u2192 Nat\n  | 0      => 0\n  | succ a => a\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_sub\"]\nprotected def Nat.sub : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0      => a\n  | a, succ b => pred (Nat.sub a b)\n\ninstance : Sub Nat where\n  sub := Nat.sub\n\ntheorem Nat.predLePred : {n m : Nat} \u2192 LE.le n m \u2192 LE.le (pred n) (pred m)\n  | zero,   zero,   h => rfl\n  | zero,   succ n, h => zeroLe n\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h => h\n\ntheorem Nat.leOfSuccLeSucc {n m : Nat} : LE.le (succ n) (succ m) \u2192 LE.le n m :=\n  predLePred\n\ntheorem Nat.leOfLtSucc {m n : Nat} : LT.lt m (succ n) \u2192 LE.le m n :=\n  leOfSuccLeSucc\n\n@[extern \"lean_system_platform_nbits\"] constant System.Platform.getNumBits : Unit \u2192 Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=\n  fun _ => \u27e864, Or.inr rfl\u27e9 -- inhabitant\n\ndef System.Platform.numBits : Nat :=\n  (getNumBits ()).val\n\ntheorem System.Platform.numBitsEq : Or (Eq numBits 32) (Eq numBits 64) :=\n  (getNumBits ()).property\n\nstructure Fin (n : Nat) where\n  val  : Nat\n  isLt : LT.lt val n\n\ntheorem Fin.eqOfVeq {n} : \u2200 {i j : Fin n}, Eq i.val j.val \u2192 Eq i j\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Fin.veqOfEq {n} {i j : Fin n} (h : Eq i j) : Eq i.val j.val :=\n  h \u25b8 rfl\n\ntheorem Fin.neOfVne {n} {i j : Fin n} (h : Not (Eq i.val j.val)) : Not (Eq i j) :=\n  fun h' => absurd (veqOfEq h') h\n\ninstance (n : Nat) : DecidableEq (Fin n) :=\n  fun i j =>\n    match decEq i.val j.val with\n    | isTrue h  => isTrue (Fin.eqOfVeq h)\n    | isFalse h => isFalse (Fin.neOfVne h)\n\ninstance {n} : LT (Fin n) where\n  lt a b := LT.lt a.val b.val\n\ninstance {n} : LE (Fin n) where\n  le a b := LE.le a.val b.val\n\ninstance Fin.decLt {n} (a b : Fin n) :  Decidable (LT.lt a b)  := Nat.decLt ..\ninstance Fin.decLe {n} (a b : Fin n) : Decidable (LE.le a b) := Nat.decLe ..\n\ndef UInt8.size : Nat := 256\nstructure UInt8 where\n  val : Fin UInt8.size\n\nattribute [extern \"lean_uint8_of_nat_mk\"] UInt8.mk\nattribute [extern \"lean_uint8_to_nat\"] UInt8.val\n\n@[extern \"lean_uint8_of_nat\"]\ndef UInt8.ofNatCore (n : @& Nat) (h : LT.lt n UInt8.size) : UInt8 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt8.decEq (a b : UInt8) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt8.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt8 := UInt8.decEq\n\ninstance : Inhabited UInt8 where\n  default := UInt8.ofNatCore 0 (by decide)\n\ndef UInt16.size : Nat := 65536\nstructure UInt16 where\n  val : Fin UInt16.size\n\nattribute [extern \"lean_uint16_of_nat_mk\"] UInt16.mk\nattribute [extern \"lean_uint16_to_nat\"] UInt16.val\n\n@[extern \"lean_uint16_of_nat\"]\ndef UInt16.ofNatCore (n : @& Nat) (h : LT.lt n UInt16.size) : UInt16 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt16.decEq (a b : UInt16) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt16.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt16 := UInt16.decEq\n\ninstance : Inhabited UInt16 where\n  default := UInt16.ofNatCore 0 (by decide)\n\ndef UInt32.size : Nat := 4294967296\nstructure UInt32 where\n  val : Fin UInt32.size\n\nattribute [extern \"lean_uint32_of_nat_mk\"] UInt32.mk\nattribute [extern \"lean_uint32_to_nat\"] UInt32.val\n\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNatCore (n : @& Nat) (h : LT.lt n UInt32.size) : UInt32 := {\n  val := { val := n, isLt := h }\n}\n\n@[extern \"lean_uint32_to_nat\"]\ndef UInt32.toNat (n : UInt32) : Nat := n.val.val\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt32.decEq (a b : UInt32) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt32.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt32 := UInt32.decEq\n\ninstance : Inhabited UInt32 where\n  default := UInt32.ofNatCore 0 (by decide)\n\ninstance : LT UInt32 where\n  lt a b := LT.lt a.val b.val\n\ninstance : LE UInt32 where\n  le a b := LE.le a.val b.val\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 < #2\"]\ndef UInt32.decLt (a b : UInt32) : Decidable (LT.lt a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LT.lt n m))\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 <= #2\"]\ndef UInt32.decLe (a b : UInt32) : Decidable (LE.le a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LE.le n m))\n\ninstance (a b : UInt32) : Decidable (LT.lt a b) := UInt32.decLt a b\ninstance (a b : UInt32) : Decidable (LE.le a b) := UInt32.decLe a b\n\ndef UInt64.size : Nat := 18446744073709551616\nstructure UInt64 where\n  val : Fin UInt64.size\n\nattribute [extern \"lean_uint64_of_nat_mk\"] UInt64.mk\nattribute [extern \"lean_uint64_to_nat\"] UInt64.val\n\n@[extern \"lean_uint64_of_nat\"]\ndef UInt64.ofNatCore (n : @& Nat) (h : LT.lt n UInt64.size) : UInt64 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt64.decEq (a b : UInt64) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt64.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt64 := UInt64.decEq\n\ninstance : Inhabited UInt64 where\n  default := UInt64.ofNatCore 0 (by decide)\n\ndef USize.size : Nat := hPow 2 System.Platform.numBits\n\ntheorem usizeSzEq : Or (Eq USize.size 4294967296) (Eq USize.size 18446744073709551616) :=\n  show Or (Eq (hPow 2 System.Platform.numBits) 4294967296) (Eq (hPow 2 System.Platform.numBits) 18446744073709551616) from\n  match System.Platform.numBits, System.Platform.numBitsEq with\n  | _, Or.inl rfl => Or.inl (by decide)\n  | _, Or.inr rfl => Or.inr (by decide)\n\nstructure USize where\n  val : Fin USize.size\n\nattribute [extern \"lean_usize_of_nat_mk\"] USize.mk\nattribute [extern \"lean_usize_to_nat\"] USize.val\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNatCore (n : @& Nat) (h : LT.lt n USize.size) : USize := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef USize.decEq (a b : USize) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h =>isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => USize.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq USize := USize.decEq\n\ninstance : Inhabited USize where\n  default := USize.ofNatCore 0 (match USize.size, usizeSzEq with\n    | _, Or.inl rfl => by decide\n    | _, Or.inr rfl => by decide)\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNat32 (n : @& Nat) (h : LT.lt n 4294967296) : USize := {\n  val := {\n    val  := n\n    isLt := match USize.size, usizeSzEq with\n      | _, Or.inl rfl => h\n      | _, Or.inr rfl => Nat.ltTrans h (by decide)\n  }\n}\n\nabbrev Nat.isValidChar (n : Nat) : Prop :=\n  Or (LT.lt n 0xd800) (And (LT.lt 0xdfff n) (LT.lt n 0x110000))\n\nabbrev UInt32.isValidChar (n : UInt32) : Prop :=\n  n.toNat.isValidChar\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   : UInt32\n  valid : val.isValidChar\n\nprivate theorem validCharIsUInt32 {n : Nat} (h : n.isValidChar) : LT.lt n UInt32.size :=\n  match h with\n  | Or.inl h      => Nat.ltTrans h (by decide)\n  | Or.inr \u27e8_, h\u27e9 => Nat.ltTrans h (by decide)\n\n@[extern \"lean_uint32_of_nat\"]\nprivate def Char.ofNatAux (n : @& Nat) (h : n.isValidChar) : Char :=\n  { val := \u27e8{ val := n, isLt := validCharIsUInt32 h }\u27e9, valid := h }\n\n@[noinline, matchPattern]\ndef Char.ofNat (n : Nat) : Char :=\n  dite (n.isValidChar)\n    (fun h => Char.ofNatAux n h)\n    (fun _ => { val := \u27e8{ val := 0, isLt := by decide }\u27e9, valid := Or.inl (by decide) })\n\ntheorem Char.eqOfVeq : \u2200 {c d : Char}, Eq c.val d.val \u2192 Eq c d\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Char.veqOfEq : \u2200 {c d : Char}, Eq c d \u2192 Eq c.val d.val\n  | _, _, rfl => rfl\n\ntheorem Char.neOfVne {c d : Char} (h : Not (Eq c.val d.val)) : Not (Eq c d) :=\n  fun h' => absurd (veqOfEq h') h\n\ntheorem Char.vneOfNe {c d : Char} (h : Not (Eq c d)) : Not (Eq c.val d.val) :=\n  fun h' => absurd (eqOfVeq h') h\n\ninstance : DecidableEq Char :=\n  fun c d =>\n    match decEq c.val d.val with\n    | isTrue h  => isTrue (Char.eqOfVeq h)\n    | isFalse h => isFalse (Char.neOfVne h)\n\ndef Char.utf8Size (c : Char) : UInt32 :=\n  let v := c.val\n  ite (LE.le v (UInt32.ofNatCore 0x7F (by decide)))\n    (UInt32.ofNatCore 1 (by decide))\n    (ite (LE.le v (UInt32.ofNatCore 0x7FF (by decide)))\n      (UInt32.ofNatCore 2 (by decide))\n      (ite (LE.le v (UInt32.ofNatCore 0xFFFF (by decide)))\n        (UInt32.ofNatCore 3 (by decide))\n        (UInt32.ofNatCore 4 (by decide))))\n\ninductive Option (\u03b1 : Type u) where\n  | none : Option \u03b1\n  | some (val : \u03b1) : Option \u03b1\n\nattribute [unbox] Option\n\nexport Option (none some)\n\ninstance {\u03b1} : Inhabited (Option \u03b1) where\n  default := none\n\n@[macroInline] def Option.getD : Option \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  | some x, _ => x\n  | none,   e => e\n\ninductive List (\u03b1 : Type u) where\n  | nil : List \u03b1\n  | cons (head : \u03b1) (tail : List \u03b1) : List \u03b1\n\ninstance {\u03b1} : Inhabited (List \u03b1) where\n  default := List.nil\n\nprotected def List.hasDecEq {\u03b1: Type u} [DecidableEq \u03b1] : (a b : List \u03b1) \u2192 Decidable (Eq a b)\n  | nil,       nil       => isTrue rfl\n  | cons a as, nil       => isFalse (fun h => List.noConfusion h)\n  | nil,       cons b bs => isFalse (fun h => List.noConfusion h)\n  | cons a as, cons b bs =>\n    match decEq a b with\n    | isTrue hab  =>\n      match List.hasDecEq as bs with\n      | isTrue habs  => isTrue (hab \u25b8 habs \u25b8 rfl)\n      | isFalse nabs => isFalse (fun h => List.noConfusion h (fun _ habs => absurd habs nabs))\n    | isFalse nab => isFalse (fun h => List.noConfusion h (fun hab _ => absurd hab nab))\n\ninstance {\u03b1 : Type u} [DecidableEq \u03b1] : DecidableEq (List \u03b1) := List.hasDecEq\n\n@[specialize]\ndef List.foldl {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) : (init : \u03b1) \u2192 List \u03b2 \u2192 \u03b1\n  | a, nil      => a\n  | a, cons b l => foldl f (f a b) l\n\ndef List.set : List \u03b1 \u2192 Nat \u2192 \u03b1 \u2192 List \u03b1\n  | cons a as, 0,          b => cons b as\n  | cons a as, Nat.succ n, b => cons a (set as n b)\n  | nil,       _,          _ => nil\n\ndef List.lengthAux {\u03b1 : Type u} : List \u03b1 \u2192 Nat \u2192 Nat\n  | nil,       n => n\n  | cons a as, n => lengthAux as (Nat.succ n)\n\ndef List.length {\u03b1 : Type u} (as : List \u03b1) : Nat :=\n  lengthAux as 0\n\n@[simp] theorem List.length_cons {\u03b1} (a : \u03b1) (as : List \u03b1) : Eq (cons a as).length as.length.succ :=\n  let rec aux (a : \u03b1) (as : List \u03b1) : (n : Nat) \u2192 Eq ((cons a as).lengthAux n) (as.lengthAux n).succ :=\n    match as with\n    | nil       => fun _ => rfl\n    | cons a as => fun n => aux a as n.succ\n  aux a as 0\n\ndef List.concat {\u03b1 : Type u} : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1\n  | nil,       b => cons b nil\n  | cons a as, b => cons a (concat as b)\n\ndef List.get {\u03b1 : Type u} : (as : List \u03b1) \u2192 (i : Nat) \u2192 LT.lt i as.length \u2192 \u03b1\n  | nil,       i,          h => absurd h (Nat.notLtZero _)\n  | cons a as, 0,          h => a\n  | cons a as, Nat.succ i, h =>\n    have : LT.lt i.succ as.length.succ := length_cons .. \u25b8 h\n    get as i (Nat.leOfSuccLeSucc this)\n\nstructure String where\n  data : List Char\n\nattribute [extern \"lean_string_mk\"] String.mk\nattribute [extern \"lean_string_data\"] String.data\n\n@[extern \"lean_string_dec_eq\"]\ndef String.decEq (s\u2081 s\u2082 : @& String) : Decidable (Eq s\u2081 s\u2082) :=\n  match s\u2081, s\u2082 with\n  | \u27e8s\u2081\u27e9, \u27e8s\u2082\u27e9 =>\n    dite (Eq s\u2081 s\u2082) (fun h => isTrue (congrArg _ h)) (fun h => isFalse (fun h' => String.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq String := String.decEq\n\n/-- A byte position in a `String`. Internally, `String`s are UTF-8 encoded.\nCodepoint positions (counting the Unicode codepoints rather than bytes)\nare represented by plain `Nat`s instead.\nIndexing a `String` by a byte position is constant-time, while codepoint\npositions need to be translated internally to byte positions in linear-time. -/\nabbrev String.Pos := Nat\n\nstructure Substring where\n  str : String\n  startPos : String.Pos\n  stopPos : String.Pos\n\n@[inline] def Substring.bsize : Substring \u2192 Nat\n  | \u27e8_, b, e\u27e9 => e.sub b\n\ndef String.csize (c : Char) : Nat :=\n  c.utf8Size.toNat\n\nprivate def String.utf8ByteSizeAux : List Char \u2192 Nat \u2192 Nat\n  | List.nil,       r => r\n  | List.cons c cs, r => utf8ByteSizeAux cs (hAdd r (csize c))\n\n@[extern \"lean_string_utf8_byte_size\"]\ndef String.utf8ByteSize : (@& String) \u2192 Nat\n  | \u27e8s\u27e9 => utf8ByteSizeAux s 0\n\n@[inline] def String.bsize (s : String) : Nat :=\n  utf8ByteSize s\n\n@[inline] def String.toSubstring (s : String) : Substring := {\n  str      := s\n  startPos := 0\n  stopPos  := s.bsize\n}\n\n@[extern c inline \"#3\"]\nunsafe def unsafeCast {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) : \u03b2 :=\n  cast lcProof (PUnit.{v})\n\n@[neverExtract, extern \"lean_panic_fn\"]\nconstant panic {\u03b1 : Type u} [Inhabited \u03b1] (msg : String) : \u03b1\n\n/-\nThe Compiler has special support for arrays.\nThey are implemented using dynamic arrays: https://en.wikipedia.org/wiki/Dynamic_array\n-/\nstructure Array (\u03b1 : Type u) where\n  data : List \u03b1\n\nattribute [extern \"lean_array_data\"] Array.data\nattribute [extern \"lean_array_mk\"] Array.mk\n\n/- The parameter `c` is the initial capacity -/\n@[extern \"lean_mk_empty_array_with_capacity\"]\ndef Array.mkEmpty {\u03b1 : Type u} (c : @& Nat) : Array \u03b1 := {\n  data := List.nil\n}\n\ndef Array.empty {\u03b1 : Type u} : Array \u03b1 :=\n  mkEmpty 0\n\n@[reducible, extern \"lean_array_get_size\"]\ndef Array.size {\u03b1 : Type u} (a : @& Array \u03b1) : Nat :=\n a.data.length\n\n@[extern \"lean_array_fget\"]\ndef Array.get {\u03b1 : Type u} (a : @& Array \u03b1) (i : @& Fin a.size) : \u03b1 :=\n  a.data.get i.val i.isLt\n\n@[inline] def Array.getD (a : Array \u03b1) (i : Nat) (v\u2080 : \u03b1) : \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.get \u27e8i, h\u27e9) (fun _ => v\u2080)\n\n/- \"Comfortable\" version of `fget`. It performs a bound check at runtime. -/\n@[extern \"lean_array_get\"]\ndef Array.get! {\u03b1 : Type u} [Inhabited \u03b1] (a : @& Array \u03b1) (i : @& Nat) : \u03b1 :=\n  Array.getD a i arbitrary\n\ndef Array.getOp {\u03b1 : Type u} [Inhabited \u03b1] (self : Array \u03b1) (idx : Nat) : \u03b1 :=\n  self.get! idx\n\n@[extern \"lean_array_push\"]\ndef Array.push {\u03b1 : Type u} (a : Array \u03b1) (v : \u03b1) : Array \u03b1 := {\n  data := List.concat a.data v\n}\n\n@[extern \"lean_array_fset\"]\ndef Array.set (a : Array \u03b1) (i : @& Fin a.size) (v : \u03b1) : Array \u03b1 := {\n  data := a.data.set i.val v\n}\n\n@[inline] def Array.setD (a : Array \u03b1) (i : Nat) (v : \u03b1) : Array \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.set \u27e8i, h\u27e9 v) (fun _ => a)\n\n@[extern \"lean_array_set\"]\ndef Array.set! (a : Array \u03b1) (i : @& Nat) (v : \u03b1) : Array \u03b1 :=\n  Array.setD a i v\n\n-- Slower `Array.append` used in quotations.\nprotected def Array.appendCore {\u03b1 : Type u}  (as : Array \u03b1) (bs : Array \u03b1) : Array \u03b1 :=\n  let rec loop (i : Nat) (j : Nat) (as : Array \u03b1) : Array \u03b1 :=\n    dite (LT.lt j bs.size)\n      (fun hlt =>\n        match i with\n        | 0           => as\n        | Nat.succ i' => loop i' (hAdd j 1) (as.push (bs.get \u27e8j, hlt\u27e9)))\n      (fun _ => as)\n  loop bs.size 0 as\n\n@[inlineIfReduce]\ndef List.toArrayAux : List \u03b1 \u2192 Array \u03b1 \u2192 Array \u03b1\n  | nil,       r => r\n  | cons a as, r => toArrayAux as (r.push a)\n\n@[inlineIfReduce]\ndef List.redLength : List \u03b1 \u2192 Nat\n  | nil       => 0\n  | cons _ as => as.redLength.succ\n\n@[inline, matchPattern, export lean_list_to_array]\ndef List.toArray (as : List \u03b1) : Array \u03b1 :=\n  as.toArrayAux (Array.mkEmpty as.redLength)\n\nclass Bind (m : Type u \u2192 Type v) where\n  bind : {\u03b1 \u03b2 : Type u} \u2192 m \u03b1 \u2192 (\u03b1 \u2192 m \u03b2) \u2192 m \u03b2\n\nexport Bind (bind)\n\nclass Pure (f : Type u \u2192 Type v) where\n  pure {\u03b1 : Type u} : \u03b1 \u2192 f \u03b1\n\nexport Pure (pure)\n\nclass Functor (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  map      : {\u03b1 \u03b2 : Type u} \u2192 (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n  mapConst : {\u03b1 \u03b2 : Type u} \u2192 \u03b1 \u2192 f \u03b2 \u2192 f \u03b1 := Function.comp map (Function.const _)\n\nclass Seq (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seq  : {\u03b1 \u03b2 : Type u} \u2192 f (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n\nclass SeqLeft (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seqLeft : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 f \u03b2 \u2192 f \u03b1\n\nclass SeqRight (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seqRight : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 f \u03b2 \u2192 f \u03b2\n\nclass Applicative (f : Type u \u2192 Type v) extends Functor f, Pure f, Seq f, SeqLeft f, SeqRight f where\n  map      := fun x y => Seq.seq (pure x) y\n  seqLeft  := fun a b => Seq.seq (Functor.map (Function.const _) a) b\n  seqRight := fun a b => Seq.seq (Functor.map (Function.const _ id) a) b\n\nclass Monad (m : Type u \u2192 Type v) extends Applicative m, Bind m : Type (max (u+1) v) where\n  map      f x := bind x (Function.comp pure f)\n  seq      f x := bind f fun y => Functor.map y x\n  seqLeft  x y := bind x fun a => bind y (fun _ => pure a)\n  seqRight x y := bind x fun _ => y\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] : Inhabited (\u03b1 \u2192 m \u03b1) where\n  default := pure\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] [Inhabited \u03b1] : Inhabited (m \u03b1) where\n  default := pure arbitrary\n\n-- A fusion of Haskell's `sequence` and `map`\ndef Array.sequenceMap {\u03b1 : Type u} {\u03b2 : Type v} {m : Type v \u2192 Type w} [Monad m] (as : Array \u03b1) (f : \u03b1 \u2192 m \u03b2) : m (Array \u03b2) :=\n  let rec loop (i : Nat) (j : Nat) (bs : Array \u03b2) : m (Array \u03b2) :=\n    dite (LT.lt j as.size)\n      (fun hlt =>\n        match i with\n        | 0           => pure bs\n        | Nat.succ i' => Bind.bind (f (as.get \u27e8j, hlt\u27e9)) fun b => loop i' (hAdd j 1) (bs.push b))\n      (fun _ => bs)\n  loop as.size 0 Array.empty\n\n/-- A Function for lifting a computation from an inner Monad to an outer Monad.\n    Like [MonadTrans](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Class.html),\n    but `n` does not have to be a monad transformer.\n    Alternatively, an implementation of [MonadLayer](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLayer) without `layerInvmap` (so far). -/\nclass MonadLift (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadLift`.\n    `monadLift` is used to transitively lift monadic computations such as `StateT.get` or `StateT.put s`.\n    Corresponds to [MonadLift](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLift). -/\nclass MonadLiftT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\nexport MonadLiftT (monadLift)\n\nabbrev liftM := @monadLift\n\ninstance (m n o) [MonadLift n o] [MonadLiftT m n] : MonadLiftT m o where\n  monadLift x := MonadLift.monadLift (m := n) (monadLift x)\n\ninstance (m) : MonadLiftT m m where\n  monadLift x := x\n\n/-- A functor in the category of monads. Can be used to lift monad-transforming functions.\n    Based on pipes' [MFunctor](https://hackage.haskell.org/package/pipes-2.4.0/docs/Control-MFunctor.html),\n    but not restricted to monad transformers.\n    Alternatively, an implementation of [MonadTransFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadTransFunctor). -/\nclass MonadFunctor (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadFunctor`.\n    `monadMap` is used to transitively lift Monad morphisms -/\nclass MonadFunctorT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\nexport MonadFunctorT (monadMap)\n\ninstance (m n o) [MonadFunctor n o] [MonadFunctorT m n] : MonadFunctorT m o where\n  monadMap f := MonadFunctor.monadMap (m := n) (monadMap (m := m) f)\n\ninstance monadFunctorRefl (m) : MonadFunctorT m m where\n  monadMap f := f\n\ninductive Except (\u03b5 : Type u) (\u03b1 : Type v) where\n  | error : \u03b5 \u2192 Except \u03b5 \u03b1\n  | ok    : \u03b1 \u2192 Except \u03b5 \u03b1\n\nattribute [unbox] Except\n\ninstance {\u03b5 : Type u} {\u03b1 : Type v} [Inhabited \u03b5] : Inhabited (Except \u03b5 \u03b1) where\n  default := Except.error arbitrary\n\n/-- An implementation of [MonadError](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Except.html#t:MonadError) -/\nclass MonadExceptOf (\u03b5 : Type u) (m : Type v \u2192 Type w) where\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\nabbrev throwThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (e : \u03b5) : m \u03b1 :=\n  MonadExceptOf.throw e\n\nabbrev tryCatchThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (x : m \u03b1) (handle : \u03b5 \u2192 m \u03b1) : m \u03b1 :=\n  MonadExceptOf.tryCatch x handle\n\n/-- Similar to `MonadExceptOf`, but `\u03b5` is an outParam for convenience -/\nclass MonadExcept (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) where\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\nexport MonadExcept (throw tryCatch)\n\ninstance (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) [MonadExceptOf \u03b5 m] : MonadExcept \u03b5 m where\n  throw    := throwThe \u03b5\n  tryCatch := tryCatchThe \u03b5\n\nnamespace MonadExcept\nvariable {\u03b5 : Type u} {m : Type v \u2192 Type w}\n\n@[inline] protected def orelse [MonadExcept \u03b5 m] {\u03b1 : Type v} (t\u2081 t\u2082 : m \u03b1) : m \u03b1 :=\n  tryCatch t\u2081 fun _ => t\u2082\n\ninstance [MonadExcept \u03b5 m] {\u03b1 : Type v} : OrElse (m \u03b1) where\n  orElse := MonadExcept.orelse\n\nend MonadExcept\n\n/-- An implementation of [ReaderT](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Reader.html#t:ReaderT) -/\ndef ReaderT (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) : Type (max u v) :=\n  \u03c1 \u2192 m \u03b1\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) [Inhabited (m \u03b1)] : Inhabited (ReaderT \u03c1 m \u03b1) where\n  default := fun _ => arbitrary\n\n@[inline] def ReaderT.run {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u} (x : ReaderT \u03c1 m \u03b1) (r : \u03c1) : m \u03b1 :=\n  x r\n\nnamespace ReaderT\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u}\n\ninstance  : MonadLift m (ReaderT \u03c1 m) where\n  monadLift x := fun _ => x\n\ninstance (\u03b5) [MonadExceptOf \u03b5 m] : MonadExceptOf \u03b5 (ReaderT \u03c1 m) where\n  throw e  := liftM (m := m) (throw e)\n  tryCatch := fun x c r => tryCatchThe \u03b5 (x r) (fun e => (c e) r)\n\nend\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] {\u03b1 \u03b2 : Type u}\n\n@[inline] protected def read : ReaderT \u03c1 m \u03c1 :=\n  pure\n\n@[inline] protected def pure (a : \u03b1) : ReaderT \u03c1 m \u03b1 :=\n  fun r => pure a\n\n@[inline] protected def bind (x : ReaderT \u03c1 m \u03b1) (f : \u03b1 \u2192 ReaderT \u03c1 m \u03b2) : ReaderT \u03c1 m \u03b2 :=\n  fun r => bind (x r) fun a => f a r\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : ReaderT \u03c1 m \u03b1) : ReaderT \u03c1 m \u03b2 :=\n  fun r => Functor.map f (x r)\n\ninstance : Monad (ReaderT \u03c1 m) where\n  pure := ReaderT.pure\n  bind := ReaderT.bind\n  map  := ReaderT.map\n\ninstance (\u03c1 m) [Monad m] : MonadFunctor m (ReaderT \u03c1 m) where\n  monadMap f x := fun ctx => f (x ctx)\n\n@[inline] protected def adapt {\u03c1' : Type u} [Monad m] {\u03b1 : Type u} (f : \u03c1' \u2192 \u03c1) : ReaderT \u03c1 m \u03b1 \u2192 ReaderT \u03c1' m \u03b1 :=\n  fun x r => x (f r)\n\nend\nend ReaderT\n\n/-- An implementation of [MonadReader](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Reader-Class.html#t:MonadReader).\n    It does not contain `local` because this Function cannot be lifted using `monadLift`.\n    Instead, the `MonadReaderAdapter` class provides the more general `adaptReader` Function.\n\n    Note: This class can be seen as a simplification of the more \"principled\" definition\n    ```\n    class MonadReader (\u03c1 : outParam (Type u)) (n : Type u \u2192 Type u) where\n      lift {\u03b1 : Type u} : ({m : Type u \u2192 Type u} \u2192 [Monad m] \u2192 ReaderT \u03c1 m \u03b1) \u2192 n \u03b1\n    ```\n    -/\nclass MonadReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  read : m \u03c1\n\n@[inline] def readThe (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadReaderOf \u03c1 m] : m \u03c1 :=\n  MonadReaderOf.read\n\n/-- Similar to `MonadReaderOf`, but `\u03c1` is an outParam for convenience -/\nclass MonadReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  read : m \u03c1\n\nexport MonadReader (read)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadReaderOf \u03c1 m] : MonadReader \u03c1 m where\n  read := readThe \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadReaderOf \u03c1 m] : MonadReaderOf \u03c1 n where\n  read := liftM (m := m) read\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadReaderOf \u03c1 (ReaderT \u03c1 m) where\n  read := ReaderT.read\n\nclass MonadWithReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\n@[inline] def withTheReader (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadWithReaderOf \u03c1 m] {\u03b1 : Type u} (f : \u03c1 \u2192 \u03c1) (x : m \u03b1) : m \u03b1 :=\n  MonadWithReaderOf.withReader f x\n\nclass MonadWithReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadWithReader (withReader)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadWithReaderOf \u03c1 m] : MonadWithReader \u03c1 m where\n  withReader := withTheReader \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type v} [MonadFunctor m n] [MonadWithReaderOf \u03c1 m] : MonadWithReaderOf \u03c1 n where\n  withReader f := monadMap (m := m) (withTheReader \u03c1 f)\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadWithReaderOf \u03c1 (ReaderT \u03c1 m) where\n  withReader f x := fun ctx => x (f ctx)\n\n/-- An implementation of [MonadState](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-State-Class.html).\n    In contrast to the Haskell implementation, we use overlapping instances to derive instances\n    automatically from `monadLift`. -/\nclass MonadStateOf (\u03c3 : Type u) (m : Type u \u2192 Type v) where\n  /- Obtain the top-most State of a Monad stack. -/\n  get : m \u03c3\n  /- Set the top-most State of a Monad stack. -/\n  set : \u03c3 \u2192 m PUnit\n  /- Map the top-most State of a Monad stack.\n\n     Note: `modifyGet f` may be preferable to `do s <- get; let (a, s) := f s; put s; pure a`\n     because the latter does not use the State linearly (without sufficient inlining). -/\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadStateOf (set)\n\nabbrev getThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] : m \u03c3 :=\n  MonadStateOf.get\n\n@[inline] abbrev modifyThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  MonadStateOf.modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] abbrev modifyGetThe {\u03b1 : Type u} (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : m \u03b1 :=\n  MonadStateOf.modifyGet f\n\n/-- Similar to `MonadStateOf`, but `\u03c3` is an outParam for convenience -/\nclass MonadState (\u03c3 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  get : m \u03c3\n  set : \u03c3 \u2192 m PUnit\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadState (get modifyGet)\n\ninstance (\u03c3 : Type u) (m : Type u \u2192 Type v) [MonadStateOf \u03c3 m] : MonadState \u03c3 m where\n  set         := MonadStateOf.set\n  get         := getThe \u03c3\n  modifyGet f := MonadStateOf.modifyGet f\n\n@[inline] def modify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] def getModify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] [Monad m] (f : \u03c3 \u2192 \u03c3) : m \u03c3 :=\n  modifyGet fun s => (s, f s)\n\n-- NOTE: The Ordering of the following two instances determines that the top-most `StateT` Monad layer\n-- will be picked first\ninstance {\u03c3 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadStateOf \u03c3 m] : MonadStateOf \u03c3 n where\n  get         := liftM (m := m) MonadStateOf.get\n  set       s := liftM (m := m) (MonadStateOf.set s)\n  modifyGet f := monadLift (m := m) (MonadState.modifyGet f)\n\nnamespace EStateM\n\ninductive Result (\u03b5 \u03c3 \u03b1 : Type u) where\n  | ok    : \u03b1 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n  | error : \u03b5 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nvariable {\u03b5 \u03c3 \u03b1 : Type u}\n\ninstance [Inhabited \u03b5] [Inhabited \u03c3] : Inhabited (Result \u03b5 \u03c3 \u03b1) where\n  default := Result.error arbitrary arbitrary\n\nend EStateM\n\nopen EStateM (Result) in\ndef EStateM (\u03b5 \u03c3 \u03b1 : Type u) := \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nnamespace EStateM\n\nvariable {\u03b5 \u03c3 \u03b1 \u03b2 : Type u}\n\ninstance [Inhabited \u03b5] : Inhabited (EStateM \u03b5 \u03c3 \u03b1) where\n  default := fun s => Result.error arbitrary s\n\n@[inline] protected def pure (a : \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.ok a s\n\n@[inline] protected def set (s : \u03c3) : EStateM \u03b5 \u03c3 PUnit := fun _ =>\n  Result.ok \u27e8\u27e9 s\n\n@[inline] protected def get : EStateM \u03b5 \u03c3 \u03c3 := fun s =>\n  Result.ok s s\n\n@[inline] protected def modifyGet (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  match f s with\n  | (a, s) => Result.ok a s\n\n@[inline] protected def throw (e : \u03b5) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.error e s\n\n/-- Auxiliary instance for saving/restoring the \"backtrackable\" part of the state. -/\nclass Backtrackable (\u03b4 : outParam (Type u)) (\u03c3 : Type u) where\n  save    : \u03c3 \u2192 \u03b4\n  restore : \u03c3 \u2192 \u03b4 \u2192 \u03c3\n\n@[inline] protected def tryCatch {\u03b4} [Backtrackable \u03b4 \u03c3] {\u03b1} (x : EStateM \u03b5 \u03c3 \u03b1) (handle : \u03b5 \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s\n  match x s with\n  | Result.error e s => handle e (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] protected def orElse {\u03b4} [Backtrackable \u03b4 \u03c3] (x\u2081 x\u2082 : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s;\n  match x\u2081 s with\n  | Result.error _ s => x\u2082 (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] def adaptExcept {\u03b5' : Type u} (f : \u03b5 \u2192 \u03b5') (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5' \u03c3 \u03b1 := fun s =>\n  match x s with\n  | Result.error e s => Result.error (f e) s\n  | Result.ok a s    => Result.ok a s\n\n@[inline] protected def bind (x : EStateM \u03b5 \u03c3 \u03b1) (f : \u03b1 \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => f a s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => Result.ok (f a) s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def seqRight (x : EStateM \u03b5 \u03c3 \u03b1) (y : EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok _ s    => y s\n  | Result.error e s => Result.error e s\n\ninstance : Monad (EStateM \u03b5 \u03c3) where\n  bind     := EStateM.bind\n  pure     := EStateM.pure\n  map      := EStateM.map\n  seqRight := EStateM.seqRight\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : OrElse (EStateM \u03b5 \u03c3 \u03b1) where\n  orElse := EStateM.orElse\n\ninstance : MonadStateOf \u03c3 (EStateM \u03b5 \u03c3) where\n  set       := EStateM.set\n  get       := EStateM.get\n  modifyGet := EStateM.modifyGet\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : MonadExceptOf \u03b5 (EStateM \u03b5 \u03c3) where\n  throw    := EStateM.throw\n  tryCatch := EStateM.tryCatch\n\n@[inline] def run (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Result \u03b5 \u03c3 \u03b1 :=\n  x s\n\n@[inline] def run' (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Option \u03b1 :=\n  match run x s with\n  | Result.ok v _   => some v\n  | Result.error .. => none\n\n@[inline] def dummySave : \u03c3 \u2192 PUnit := fun _ => \u27e8\u27e9\n\n@[inline] def dummyRestore : \u03c3 \u2192 PUnit \u2192 \u03c3 := fun s _ => s\n\n/- Dummy default instance -/\ninstance nonBacktrackable : Backtrackable PUnit \u03c3 where\n  save    := dummySave\n  restore := dummyRestore\n\nend EStateM\n\nclass Hashable (\u03b1 : Sort u) where\n  hash : \u03b1 \u2192 USize\n\nexport Hashable (hash)\n\n@[extern \"lean_usize_mix_hash\"]\nconstant mixHash (u\u2081 u\u2082 : USize) : USize\n\n@[extern \"lean_string_hash\"]\nprotected constant String.hash (s : @& String) : USize\n\ninstance : Hashable String where\n  hash := String.hash\n\nnamespace Lean\n\n/- Hierarchical names -/\ninductive Name where\n  | anonymous : Name\n  | str : Name \u2192 String \u2192 USize \u2192 Name\n  | num : Name \u2192 Nat \u2192 USize \u2192 Name\n\ninstance : Inhabited Name where\n  default := Name.anonymous\n\nprotected def Name.hash : Name \u2192 USize\n  | Name.anonymous => USize.ofNat32 1723 (by decide)\n  | Name.str p s h => h\n  | Name.num p v h => h\n\ninstance : Hashable Name where\n  hash := Name.hash\n\nnamespace Name\n\n@[export lean_name_mk_string]\ndef mkStr (p : Name) (s : String) : Name :=\n  Name.str p s (mixHash (hash p) (hash s))\n\n@[export lean_name_mk_numeral]\ndef mkNum (p : Name) (v : Nat) : Name :=\n  Name.num p v (mixHash (hash p) (dite (LT.lt v USize.size) (fun h => USize.ofNatCore v h) (fun _ => USize.ofNat32 17 (by decide))))\n\ndef mkSimple (s : String) : Name :=\n  mkStr Name.anonymous s\n\n@[extern \"lean_name_eq\"]\nprotected def beq : (@& Name) \u2192 (@& Name) \u2192 Bool\n  | anonymous,   anonymous   => true\n  | str p\u2081 s\u2081 _, str p\u2082 s\u2082 _ => and (BEq.beq s\u2081 s\u2082) (Name.beq p\u2081 p\u2082)\n  | num p\u2081 n\u2081 _, num p\u2082 n\u2082 _ => and (BEq.beq n\u2081 n\u2082) (Name.beq p\u2081 p\u2082)\n  | _,           _           => false\n\ninstance : BEq Name where\n  beq := Name.beq\n\nprotected def append : Name \u2192 Name \u2192 Name\n  | n, anonymous => n\n  | n, str p s _ => Name.mkStr (Name.append n p) s\n  | n, num p d _ => Name.mkNum (Name.append n p) d\n\ninstance : Append Name where\n  append := Name.append\n\nend Name\n\n/- Syntax -/\n\n/-- Source information of tokens. -/\ninductive SourceInfo where\n  /-\n    Token from original input with whitespace and position information.\n    `leading` will be inferred after parsing by `Syntax.updateLeading`. During parsing,\n    it is not at all clear what the preceding token was, especially with backtracking. -/\n  | original (leading : Substring) (pos : String.Pos) (trailing : Substring) (endPos : String.Pos)\n  /-\n    Synthesized token (e.g. from a quotation) annotated with a span from the original source.\n    In the delaborator, we \"misuse\" this constructor to store synthetic positions identifying\n    subterms. -/\n  | synthetic (pos : String.Pos) (endPos : String.Pos)\n  /- Synthesized token without position information. -/\n  | protected none\n\ninstance : Inhabited SourceInfo := \u27e8SourceInfo.none\u27e9\n\nnamespace SourceInfo\n\ndef getPos? (info : SourceInfo) (originalOnly := false) : Option String.Pos :=\n  match info, originalOnly with\n  | original (pos := pos) ..,  _     => some pos\n  | synthetic (pos := pos) .., false => some pos\n  | _,                         _     => none\n\nend SourceInfo\n\nabbrev SyntaxNodeKind := Name\n\n/- Syntax AST -/\n\ninductive Syntax where\n  | missing : Syntax\n  | node   (kind : SyntaxNodeKind) (args : Array Syntax) : Syntax\n  | atom   (info : SourceInfo) (val : String) : Syntax\n  | ident  (info : SourceInfo) (rawVal : Substring) (val : Name) (preresolved : List (Prod Name (List String))) : Syntax\n\ninstance : Inhabited Syntax where\n  default := Syntax.missing\n\n/- Builtin kinds -/\ndef choiceKind : SyntaxNodeKind := `choice\ndef nullKind : SyntaxNodeKind := `null\ndef groupKind : SyntaxNodeKind := `group\ndef identKind : SyntaxNodeKind := `ident\ndef strLitKind : SyntaxNodeKind := `strLit\ndef charLitKind : SyntaxNodeKind := `charLit\ndef numLitKind : SyntaxNodeKind := `numLit\ndef scientificLitKind : SyntaxNodeKind := `scientificLit\ndef nameLitKind : SyntaxNodeKind := `nameLit\ndef fieldIdxKind : SyntaxNodeKind := `fieldIdx\ndef interpolatedStrLitKind : SyntaxNodeKind := `interpolatedStrLitKind\ndef interpolatedStrKind : SyntaxNodeKind := `interpolatedStrKind\n\nnamespace Syntax\n\ndef getKind (stx : Syntax) : SyntaxNodeKind :=\n  match stx with\n  | Syntax.node k args => k\n  -- We use these \"pseudo kinds\" for antiquotation kinds.\n  -- For example, an antiquotation `$id:ident` (using Lean.Parser.Term.ident)\n  -- is compiled to ``if stx.isOfKind `ident ...``\n  | Syntax.missing     => `missing\n  | Syntax.atom _ v    => Name.mkSimple v\n  | Syntax.ident ..    => identKind\n\ndef setKind (stx : Syntax) (k : SyntaxNodeKind) : Syntax :=\n  match stx with\n  | Syntax.node _ args => Syntax.node k args\n  | _                  => stx\n\ndef isOfKind (stx : Syntax) (k : SyntaxNodeKind) : Bool :=\n  beq stx.getKind k\n\ndef getArg (stx : Syntax) (i : Nat) : Syntax :=\n  match stx with\n  | Syntax.node _ args => args.getD i Syntax.missing\n  | _                  => Syntax.missing\n\n-- Add `stx[i]` as sugar for `stx.getArg i`\n@[inline] def getOp (self : Syntax) (idx : Nat) : Syntax :=\n  self.getArg idx\n\ndef getArgs (stx : Syntax) : Array Syntax :=\n  match stx with\n  | Syntax.node _ args => args\n  | _                  => Array.empty\n\ndef getNumArgs (stx : Syntax) : Nat :=\n  match stx with\n  | Syntax.node _ args => args.size\n  | _                  => 0\n\ndef isMissing : Syntax \u2192 Bool\n  | Syntax.missing => true\n  | _ => false\n\ndef isNodeOf (stx : Syntax) (k : SyntaxNodeKind) (n : Nat) : Bool :=\n  and (stx.isOfKind k) (beq stx.getNumArgs n)\n\ndef isIdent : Syntax \u2192 Bool\n  | ident _ _ _ _ => true\n  | _             => false\n\ndef getId : Syntax \u2192 Name\n  | ident _ _ val _ => val\n  | _               => Name.anonymous\n\ndef matchesNull (stx : Syntax) (n : Nat) : Bool :=\n  isNodeOf stx nullKind n\n\ndef matchesIdent (stx : Syntax) (id : Name) : Bool :=\n  and stx.isIdent (beq stx.getId id)\n\ndef setArgs (stx : Syntax) (args : Array Syntax) : Syntax :=\n  match stx with\n  | node k _ => node k args\n  | stx      => stx\n\ndef setArg (stx : Syntax) (i : Nat) (arg : Syntax) : Syntax :=\n  match stx with\n  | node k args => node k (args.setD i arg)\n  | stx         => stx\n\n/-- Retrieve the left-most leaf's info in the Syntax tree. -/\npartial def getHeadInfo? : Syntax \u2192 Option SourceInfo\n  | atom info _   => some info\n  | ident info .. => some info\n  | node _ args   =>\n    let rec loop (i : Nat) : Option SourceInfo :=\n      match decide (LT.lt i args.size) with\n      | true => match getHeadInfo? (args.get! i) with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | _             => none\n\n/-- Retrieve the left-most leaf's info in the Syntax tree, or `none` if there is no token. -/\npartial def getHeadInfo (stx : Syntax) : SourceInfo :=\n  match stx.getHeadInfo? with\n  | some info => info\n  | none      => SourceInfo.none\n\ndef getPos? (stx : Syntax) (originalOnly := false) : Option String.Pos :=\n  stx.getHeadInfo.getPos? originalOnly\n\npartial def getTailPos? (stx : Syntax) (originalOnly := false) : Option String.Pos :=\n  match stx, originalOnly with\n  | atom (SourceInfo.original (endPos := pos) ..) ..,    _    => some pos\n  | atom (SourceInfo.synthetic (endPos := pos) ..) _,  false  => some pos\n  | ident (SourceInfo.original (endPos := pos) ..) .., _      => some pos\n  | ident (SourceInfo.synthetic (endPos := pos) ..) .., false => some pos\n  | node _ args,                                        _     =>\n    let rec loop (i : Nat) : Option String.Pos :=\n      match decide (LT.lt i args.size) with\n      | true => match getTailPos? (args.get! ((args.size.sub i).sub 1)) originalOnly with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | _, _ => none\n\n/--\n  An array of syntax elements interspersed with separators. Can be coerced to/from `Array Syntax` to automatically\n  remove/insert the separators. -/\nstructure SepArray (sep : String) where\n  elemsAndSeps : Array Syntax\n\nend Syntax\n\ndef SourceInfo.fromRef (ref : Syntax) : SourceInfo :=\n  match ref.getPos?, ref.getTailPos? with\n  | some pos, some tailPos => SourceInfo.synthetic pos tailPos\n  | _,        _            => SourceInfo.none\n\ndef mkAtom (val : String) : Syntax :=\n  Syntax.atom SourceInfo.none val\n\ndef mkAtomFrom (src : Syntax) (val : String) : Syntax :=\n  Syntax.atom src.getHeadInfo val\n\n/- Parser descriptions -/\n\ninductive ParserDescr where\n  | const  (name : Name)\n  | unary  (name : Name) (p : ParserDescr)\n  | binary (name : Name) (p\u2081 p\u2082 : ParserDescr)\n  | node (kind : SyntaxNodeKind) (prec : Nat) (p : ParserDescr)\n  | trailingNode (kind : SyntaxNodeKind) (prec lhsPrec : Nat) (p : ParserDescr)\n  | symbol (val : String)\n  | nonReservedSymbol (val : String) (includeIdent : Bool)\n  | cat (catName : Name) (rbp : Nat)\n  | parser (declName : Name)\n  | nodeWithAntiquot (name : String) (kind : SyntaxNodeKind) (p : ParserDescr)\n  | sepBy  (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n  | sepBy1 (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n\ninstance : Inhabited ParserDescr where\n  default := ParserDescr.symbol \"\"\n\nabbrev TrailingParserDescr := ParserDescr\n\n/-\nRuntime support for making quotation terms auto-hygienic, by mangling identifiers\nintroduced by them with a \"macro scope\" supplied by the context. Details to appear in a\npaper soon.\n-/\n\nabbrev MacroScope := Nat\n/-- Macro scope used internally. It is not available for our frontend. -/\ndef reservedMacroScope := 0\n/-- First macro scope available for our frontend -/\ndef firstFrontendMacroScope := hAdd reservedMacroScope 1\n\nclass MonadRef (m : Type \u2192 Type) where\n  getRef      : m Syntax\n  withRef {\u03b1} : Syntax \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadRef (getRef)\n\ninstance (m n : Type \u2192 Type) [MonadLift m n] [MonadFunctor m n] [MonadRef m] : MonadRef n where\n  getRef        := liftM (getRef : m _)\n  withRef ref x := monadMap (m := m) (MonadRef.withRef ref) x\n\ndef replaceRef (ref : Syntax) (oldRef : Syntax) : Syntax :=\n  match ref.getPos? with\n  | some _ => ref\n  | _      => oldRef\n\n@[inline] def withRef {m : Type \u2192 Type} [Monad m] [MonadRef m] {\u03b1} (ref : Syntax) (x : m \u03b1) : m \u03b1 :=\n  bind getRef fun oldRef =>\n  let ref := replaceRef ref oldRef\n  MonadRef.withRef ref x\n\n/-- A monad that supports syntax quotations. Syntax quotations (in term\n    position) are monadic values that when executed retrieve the current \"macro\n    scope\" from the monad and apply it to every identifier they introduce\n    (independent of whether this identifier turns out to be a reference to an\n    existing declaration, or an actually fresh binding during further\n    elaboration). We also apply the position of the result of `getRef` to each\n    introduced symbol, which results in better error positions than not applying\n    any position. -/\nclass MonadQuotation (m : Type \u2192 Type) extends MonadRef m where\n  -- Get the fresh scope of the current macro invocation\n  getCurrMacroScope : m MacroScope\n  getMainModule     : m Name\n  /- Execute action in a new macro invocation context. This transformer should be\n     used at all places that morally qualify as the beginning of a \"macro call\",\n     e.g. `elabCommand` and `elabTerm` in the case of the elaborator. However, it\n     can also be used internally inside a \"macro\" if identifiers introduced by\n     e.g. different recursive calls should be independent and not collide. While\n     returning an intermediate syntax tree that will recursively be expanded by\n     the elaborator can be used for the same effect, doing direct recursion inside\n     the macro guarded by this transformer is often easier because one is not\n     restricted to passing a single syntax tree. Modelling this helper as a\n     transformer and not just a monadic action ensures that the current macro\n     scope before the recursive call is restored after it, as expected. -/\n  withFreshMacroScope {\u03b1 : Type} : m \u03b1 \u2192 m \u03b1\n\nexport MonadQuotation (getCurrMacroScope getMainModule withFreshMacroScope)\n\ndef MonadRef.mkInfoFromRefPos [Monad m] [MonadRef m] : m SourceInfo := do\n  SourceInfo.fromRef (\u2190 getRef)\n\ninstance {m n : Type \u2192 Type} [MonadFunctor m n] [MonadLift m n] [MonadQuotation m] : MonadQuotation n where\n  getCurrMacroScope   := liftM (m := m) getCurrMacroScope\n  getMainModule       := liftM (m := m) getMainModule\n  withFreshMacroScope := monadMap (m := m) withFreshMacroScope\n\n/-\nWe represent a name with macro scopes as\n```\n<actual name>._@.(<module_name>.<scopes>)*.<module_name>._hyg.<scopes>\n```\nExample: suppose the module name is `Init.Data.List.Basic`, and name is `foo.bla`, and macroscopes [2, 5]\n```\nfoo.bla._@.Init.Data.List.Basic._hyg.2.5\n```\n\nWe may have to combine scopes from different files/modules.\nThe main modules being processed is always the right most one.\nThis situation may happen when we execute a macro generated in\nan imported file in the current file.\n```\nfoo.bla._@.Init.Data.List.Basic.2.1.Init.Lean.Expr_hyg.4\n```\n\nThe delimiter `_hyg` is used just to improve the `hasMacroScopes` performance.\n-/\n\ndef Name.hasMacroScopes : Name \u2192 Bool\n  | str _ s _   => beq s \"_hyg\"\n  | num p _   _ => hasMacroScopes p\n  | _           => false\n\nprivate def eraseMacroScopesAux : Name \u2192 Name\n  | Name.str p s _   => match beq s \"_@\" with\n    | true  => p\n    | false => eraseMacroScopesAux p\n  | Name.num p _ _   => eraseMacroScopesAux p\n  | Name.anonymous   => Name.anonymous\n\n@[export lean_erase_macro_scopes]\ndef Name.eraseMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => eraseMacroScopesAux n\n  | false => n\n\nprivate def simpMacroScopesAux : Name \u2192 Name\n  | Name.num p i _ => Name.mkNum (simpMacroScopesAux p) i\n  | n              => eraseMacroScopesAux n\n\n/- Helper function we use to create binder names that do not need to be unique. -/\n@[export lean_simp_macro_scopes]\ndef Name.simpMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => simpMacroScopesAux n\n  | false => n\n\nstructure MacroScopesView where\n  name       : Name\n  imported   : Name\n  mainModule : Name\n  scopes     : List MacroScope\n\ninstance : Inhabited MacroScopesView where\n  default := \u27e8arbitrary, arbitrary, arbitrary, arbitrary\u27e9\n\ndef MacroScopesView.review (view : MacroScopesView) : Name :=\n  match view.scopes with\n  | List.nil      => view.name\n  | List.cons _ _ =>\n    let base := (Name.mkStr (hAppend (hAppend (Name.mkStr view.name \"_@\") view.imported) view.mainModule) \"_hyg\")\n    view.scopes.foldl Name.mkNum base\n\nprivate def assembleParts : List Name \u2192 Name \u2192 Name\n  | List.nil,                      acc => acc\n  | List.cons (Name.str _ s _) ps, acc => assembleParts ps (Name.mkStr acc s)\n  | List.cons (Name.num _ n _) ps, acc => assembleParts ps (Name.mkNum acc n)\n  | _,                             acc => panic \"Error: unreachable @ assembleParts\"\n\nprivate def extractImported (scps : List MacroScope) (mainModule : Name) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := mainModule, imported := assembleParts parts Name.anonymous, scopes := scps }\n    | false => extractImported scps mainModule p (List.cons n parts)\n  | n@(Name.num p str _), parts => extractImported scps mainModule p (List.cons n parts)\n  | _,                    _     => panic \"Error: unreachable @ extractImported\"\n\nprivate def extractMainModule (scps : List MacroScope) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := assembleParts parts Name.anonymous, imported := Name.anonymous, scopes := scps }\n    | false => extractMainModule scps p (List.cons n parts)\n  | n@(Name.num p num _), acc => extractImported scps (assembleParts acc Name.anonymous) n List.nil\n  | _,                    _   => panic \"Error: unreachable @ extractMainModule\"\n\nprivate def extractMacroScopesAux : Name \u2192 List MacroScope \u2192 MacroScopesView\n  | Name.num p scp _, acc => extractMacroScopesAux p (List.cons scp acc)\n  | Name.str p str _, acc => extractMainModule acc p List.nil -- str must be \"_hyg\"\n  | _,                _   => panic \"Error: unreachable @ extractMacroScopesAux\"\n\n/--\n  Revert all `addMacroScope` calls. `v = extractMacroScopes n \u2192 n = v.review`.\n  This operation is useful for analyzing/transforming the original identifiers, then adding back\n  the scopes (via `MacroScopesView.review`). -/\ndef extractMacroScopes (n : Name) : MacroScopesView :=\n  match n.hasMacroScopes with\n  | true  => extractMacroScopesAux n List.nil\n  | false => { name := n, scopes := List.nil, imported := Name.anonymous, mainModule := Name.anonymous }\n\ndef addMacroScope (mainModule : Name) (n : Name) (scp : MacroScope) : Name :=\n  match n.hasMacroScopes with\n  | true =>\n    let view := extractMacroScopes n\n    match beq view.mainModule mainModule with\n    | true  => Name.mkNum n scp\n    | false =>\n      { view with\n        imported   := view.scopes.foldl Name.mkNum (hAppend view.imported view.mainModule)\n        mainModule := mainModule\n        scopes     := List.cons scp List.nil\n      }.review\n  | false =>\n    Name.mkNum (Name.mkStr (hAppend (Name.mkStr n \"_@\") mainModule) \"_hyg\") scp\n\n@[inline] def MonadQuotation.addMacroScope {m : Type \u2192 Type} [MonadQuotation m] [Monad m] (n : Name) : m Name :=\n  bind getMainModule     fun mainModule =>\n  bind getCurrMacroScope fun scp =>\n  pure (Lean.addMacroScope mainModule n scp)\n\ndef defaultMaxRecDepth := 512\n\ndef maxRecDepthErrorMessage : String :=\n  \"maximum recursion depth has been reached (use `set_option maxRecDepth <num>` to increase limit)\"\n\nnamespace Macro\n\n/- References -/\nprivate constant MethodsRefPointed : PointedType.{0}\n\nprivate def MethodsRef : Type := MethodsRefPointed.type\n\nstructure Context where\n  methods        : MethodsRef\n  mainModule     : Name\n  currMacroScope : MacroScope\n  currRecDepth   : Nat := 0\n  maxRecDepth    : Nat := defaultMaxRecDepth\n  ref            : Syntax\n\ninductive Exception where\n  | error             : Syntax \u2192 String \u2192 Exception\n  | unsupportedSyntax : Exception\n\nstructure State where\n  macroScope : MacroScope\n  traceMsgs  : List (Prod Name String) := List.nil\n  deriving Inhabited\n\nend Macro\n\nabbrev MacroM := ReaderT Macro.Context (EStateM Macro.Exception Macro.State)\n\nabbrev Macro := Syntax \u2192 MacroM Syntax\n\nnamespace Macro\n\ninstance : MonadRef MacroM where\n  getRef     := bind read fun ctx => pure ctx.ref\n  withRef    := fun ref x => withReader (fun ctx => { ctx with ref := ref }) x\n\ndef addMacroScope (n : Name) : MacroM Name :=\n  bind read fun ctx =>\n  pure (Lean.addMacroScope ctx.mainModule n ctx.currMacroScope)\n\ndef throwUnsupported {\u03b1} : MacroM \u03b1 :=\n  throw Exception.unsupportedSyntax\n\ndef throwError {\u03b1} (msg : String) : MacroM \u03b1 :=\n  bind getRef fun ref =>\n  throw (Exception.error ref msg)\n\ndef throwErrorAt {\u03b1} (ref : Syntax) (msg : String) : MacroM \u03b1 :=\n  withRef ref (throwError msg)\n\n@[inline] protected def withFreshMacroScope {\u03b1} (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind (modifyGet (fun s => (s.macroScope, { s with macroScope := hAdd s.macroScope 1 }))) fun fresh =>\n  withReader (fun ctx => { ctx with currMacroScope := fresh }) x\n\n@[inline] def withIncRecDepth {\u03b1} (ref : Syntax) (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind read fun ctx =>\n  match beq ctx.currRecDepth ctx.maxRecDepth with\n  | true  => throw (Exception.error ref maxRecDepthErrorMessage)\n  | false => withReader (fun ctx => { ctx with currRecDepth := hAdd ctx.currRecDepth 1 }) x\n\ninstance : MonadQuotation MacroM where\n  getCurrMacroScope ctx := pure ctx.currMacroScope\n  getMainModule     ctx := pure ctx.mainModule\n  withFreshMacroScope   := Macro.withFreshMacroScope\n\nstructure Methods where\n  expandMacro?      : Syntax \u2192 MacroM (Option Syntax)\n  getCurrNamespace  : MacroM Name\n  hasDecl           : Name \u2192 MacroM Bool\n  resolveNamespace? : Name \u2192 MacroM (Option Name)\n  resolveGlobalName : Name \u2192 MacroM (List (Prod Name (List String)))\n  deriving Inhabited\n\nunsafe def mkMethodsImp (methods : Methods) : MethodsRef :=\n  unsafeCast methods\n\n@[implementedBy mkMethodsImp]\nconstant mkMethods (methods : Methods) : MethodsRef := MethodsRefPointed.val\n\ninstance : Inhabited MethodsRef where\n  default := mkMethods arbitrary\n\nunsafe def getMethodsImp : MacroM Methods :=\n  bind read fun ctx => pure (unsafeCast (ctx.methods))\n\n@[implementedBy getMethodsImp] constant getMethods : MacroM Methods\n\n/-- `expandMacro? stx` return `some stxNew` if `stx` is a macro, and `stxNew` is its expansion. -/\ndef expandMacro? (stx : Syntax) : MacroM (Option Syntax) := do\n  (\u2190 getMethods).expandMacro? stx\n\n/-- Return `true` if the environment contains a declaration with name `declName` -/\ndef hasDecl (declName : Name) : MacroM Bool := do\n  (\u2190 getMethods).hasDecl declName\n\ndef getCurrNamespace : MacroM Name := do\n  (\u2190 getMethods).getCurrNamespace\n\ndef resolveNamespace? (n : Name) : MacroM (Option Name) := do\n  (\u2190 getMethods).resolveNamespace? n\n\ndef resolveGlobalName (n : Name) : MacroM (List (Prod Name (List String))) := do\n  (\u2190 getMethods).resolveGlobalName n\n\ndef trace (clsName : Name) (msg : String) : MacroM Unit := do\n  modify fun s => { s with traceMsgs := List.cons (Prod.mk clsName msg) s.traceMsgs }\n\nend Macro\n\nexport Macro (expandMacro?)\n\nnamespace PrettyPrinter\n\nabbrev UnexpandM := EStateM Unit Unit\n\n/--\n  Function that tries to reverse macro expansions as a post-processing step of delaboration.\n  While less general than an arbitrary delaborator, it can be declared without importing `Lean`.\n  Used by the `[appUnexpander]` attribute. -/\n-- a `kindUnexpander` could reasonably be added later\nabbrev Unexpander := Syntax \u2192 UnexpandM Syntax\n\n-- unexpanders should not need to introduce new names\ninstance : MonadQuotation UnexpandM where\n  getRef              := pure Syntax.missing\n  withRef             := fun _ => id\n  getCurrMacroScope   := pure 0\n  getMainModule       := pure `_fakeMod\n  withFreshMacroScope := id\n\nend PrettyPrinter\n\nend Lean\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/Prelude.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850932, "lm_q2_score": 0.6893056167854461, "lm_q1q2_score": 0.4887308713264164}}
{"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 `\u03b1 \u2192 \u03b1 \u2192 ... \u2192 \u03b1`. -/\ndef arity (\u03b1 : Type u) : nat \u2192 Type u\n| 0     := \u03b1\n| (n+1) := \u03b1 \u2192 arity n\n\nnamespace arity\n\n/-- Constant `n`-ary function with value `a`. -/\ndef const {\u03b1 : Type u} (a : \u03b1) : \u2200 n, arity \u03b1 n\n| 0 := a\n| (n+1) := \u03bb _, const n\n\ninstance arity.inhabited {\u03b1 n} [inhabited \u03b1] : inhabited (arity \u03b1 n) :=\n\u27e8const (default _) _\u27e9\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 (\u03b1 : Type u) (A : \u03b1 \u2192 pSet) : pSet\n\nnamespace pSet\n\n/-- The underlying type of a pre-set -/\ndef type : pSet \u2192 Type u\n| \u27e8\u03b1, A\u27e9 := \u03b1\n\n/-- The underlying pre-set family of a pre-set -/\ndef func : \u03a0 (x : pSet), x.type \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := A\n\ntheorem mk_type_func : \u03a0 (x : pSet), mk x.type x.func = x\n| \u27e8\u03b1, A\u27e9 := 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 (\u03bb\u03b1 z m \u27e8\u03b2, B\u27e9, (\u2200a, \u2203b, m a (B b)) \u2227 (\u2200b, \u2203a, m a (B b))) x y\n\ntheorem equiv.refl (x) : equiv x x :=\npSet.rec_on x $ \u03bb\u03b1 A IH, \u27e8\u03bba, \u27e8a, IH a\u27e9, \u03bba, \u27e8a, IH a\u27e9\u27e9\n\ntheorem equiv.euc {x} : \u03a0 {y z}, equiv x y \u2192 equiv z y \u2192 equiv x z :=\npSet.rec_on x $ \u03bb\u03b1 A IH y, pSet.cases_on y $ \u03bb\u03b2 B \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 \u27e8\u03b3\u03b2, \u03b2\u03b3\u27e9,\n\u27e8\u03bba, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a, \u27e8c, bc\u27e9 := \u03b2\u03b3 b in \u27e8c, IH a ab bc\u27e9,\n  \u03bbc, let \u27e8b, cb\u27e9 := \u03b3\u03b2 c, \u27e8a, ba\u27e9 := \u03b2\u03b1 b in \u27e8a, IH a ba cb\u27e9\u27e9\n\ntheorem equiv.symm {x y} : equiv x y \u2192 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\u27e8pSet.equiv, equiv.refl, \u03bbx y, equiv.symm, \u03bbx y z, equiv.trans\u27e9\n\nprotected def subset : pSet \u2192 pSet \u2192 Prop\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u2200a, \u2203b, equiv (A a) (B b)\n\ninstance : has_subset pSet := \u27e8pSet.subset\u27e9\n\ntheorem equiv.ext : \u03a0 (x y : pSet), equiv x y \u2194 (x \u2286 y \u2227 y \u2286 x)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 :=\n  \u27e8\u03bb\u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9, \u27e8\u03b1\u03b2, \u03bbb, let \u27e8a, h\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.symm h\u27e9\u27e9,\n    \u03bb\u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9, \u27e8\u03b1\u03b2, \u03bbb, let \u27e8a, h\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.symm h\u27e9\u27e9\u27e9\n\ntheorem subset.congr_left : \u03a0 {x y z : pSet}, equiv x y \u2192 (x \u2286 z \u2194 y \u2286 z)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 :=\n  \u27e8\u03bb\u03b1\u03b3 b, let \u27e8a, ba\u27e9 := \u03b2\u03b1 b, \u27e8c, ac\u27e9 := \u03b1\u03b3 a in \u27e8c, equiv.trans (equiv.symm ba) ac\u27e9,\n    \u03bb\u03b2\u03b3 a, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a, \u27e8c, bc\u27e9 := \u03b2\u03b3 b in \u27e8c, equiv.trans ab bc\u27e9\u27e9\n\ntheorem subset.congr_right : \u03a0 {x y z : pSet}, equiv x y \u2192 (z \u2286 x \u2194 z \u2286 y)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 :=\n  \u27e8\u03bb\u03b3\u03b1 c, let \u27e8a, ca\u27e9 := \u03b3\u03b1 c, \u27e8b, ab\u27e9 := \u03b1\u03b2 a in \u27e8b, equiv.trans ca ab\u27e9,\n    \u03bb\u03b3\u03b2 c, let \u27e8b, cb\u27e9 := \u03b3\u03b2 c, \u27e8a, ab\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.trans cb (equiv.symm ab)\u27e9\u27e9\n\n/-- `x \u2208 y` as pre-sets if `x` is extensionally equivalent to a member\n  of the family `y`. -/\ndef mem : pSet \u2192 pSet \u2192 Prop\n| x \u27e8\u03b2, B\u27e9 := \u2203b, equiv x (B b)\ninstance : has_mem pSet.{u} pSet.{u} := \u27e8mem\u27e9\n\ntheorem mem.mk {\u03b1: Type u} (A : \u03b1 \u2192 pSet) (a : \u03b1) : A a \u2208 mk \u03b1 A :=\nshow mem (A a) \u27e8\u03b1, A\u27e9, from \u27e8a, equiv.refl (A a)\u27e9\n\ntheorem mem.ext : \u03a0 {x y : pSet.{u}}, (\u2200w:pSet.{u}, w \u2208 x \u2194 w \u2208 y) \u2192 equiv x y\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 h := \u27e8\u03bba, (h (A a)).1 (mem.mk A a),\n    \u03bbb, let \u27e8a, ha\u27e9 := (h (B b)).2 (mem.mk B b) in \u27e8a, equiv.symm ha\u27e9\u27e9\n\ntheorem mem.congr_right : \u03a0 {x y : pSet.{u}}, equiv x y \u2192 (\u2200{w:pSet.{u}}, w \u2208 x \u2194 w \u2208 y)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 w :=\n  \u27e8\u03bb\u27e8a, ha\u27e9, let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8b, equiv.trans ha hb\u27e9,\n    \u03bb\u27e8b, hb\u27e9, let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.euc hb ha\u27e9\u27e9\n\ntheorem equiv_iff_mem {x y : pSet.{u}} : equiv x y \u2194 (\u2200{w:pSet.{u}}, w \u2208 x \u2194 w \u2208 y) :=\n\u27e8mem.congr_right, match x, y with\n| \u27e8\u03b1, A\u27e9, \u27e8\u03b2, B\u27e9, h := \u27e8\u03bb a, h.1 (mem.mk A a), \u03bb b,\n  let \u27e8a, h\u27e9 := h.2 (mem.mk B b) in \u27e8a, h.symm\u27e9\u27e9\nend\u27e9\n\ntheorem mem.congr_left : \u03a0 {x y : pSet.{u}}, equiv x y \u2192 (\u2200{w : pSet.{u}}, x \u2208 w \u2194 y \u2208 w)\n| x y h \u27e8\u03b1, A\u27e9 := \u27e8\u03bb\u27e8a, ha\u27e9, \u27e8a, equiv.trans (equiv.symm h) ha\u27e9, \u03bb\u27e8a, ha\u27e9, \u27e8a, equiv.trans h ha\u27e9\u27e9\n\n/-- Convert a pre-set to a `set` of pre-sets. -/\ndef to_set (u : pSet.{u}) : set pSet.{u} := {x | x \u2208 u}\n\n/-- Two pre-sets are equivalent iff they have the same members. -/\ntheorem equiv.eq {x y : pSet} : equiv x y \u2194 to_set x = to_set y :=\nequiv_iff_mem.trans set.ext_iff.symm\n\ninstance : has_coe pSet (set pSet) := \u27e8to_set\u27e9\n\n/-- The empty pre-set -/\nprotected def empty : pSet := \u27e8ulift empty, \u03bbe, match e with end\u27e9\n\ninstance : has_emptyc pSet := \u27e8pSet.empty\u27e9\n\ninstance : inhabited pSet := \u27e8\u2205\u27e9\n\ntheorem mem_empty (x : pSet.{u}) : x \u2209 (\u2205:pSet.{u}) := \u03bbe, match e with end\n\n/-- Insert an element into a pre-set -/\nprotected def insert : pSet \u2192 pSet \u2192 pSet\n| u \u27e8\u03b1, A\u27e9 := \u27e8option \u03b1, \u03bbo, option.rec u A o\u27e9\n\ninstance : has_insert pSet pSet := \u27e8pSet.insert\u27e9\n\ninstance : has_singleton pSet pSet := \u27e8\u03bb s, insert s \u2205\u27e9\n\ninstance : is_lawful_singleton pSet pSet := \u27e8\u03bb _, rfl\u27e9\n\n/-- The n-th von Neumann ordinal -/\ndef of_nat : \u2115 \u2192 pSet\n| 0     := \u2205\n| (n+1) := pSet.insert (of_nat n) (of_nat n)\n\n/-- The von Neumann ordinal \u03c9 -/\ndef omega : pSet := \u27e8ulift \u2115, \u03bbn, of_nat n.down\u27e9\n\n/-- The separation operation `{x \u2208 a | p x}` -/\nprotected def sep (p : set pSet) : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8{a // p (A a)}, \u03bbx, A x.1\u27e9\n\ninstance : has_sep pSet pSet := \u27e8pSet.sep\u27e9\n\n/-- The powerset operator -/\ndef powerset : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8set \u03b1, \u03bbp, \u27e8{a // p a}, \u03bbx, A x.1\u27e9\u27e9\n\ntheorem mem_powerset : \u03a0 {x y : pSet}, y \u2208 powerset x \u2194 y \u2286 x\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u27e8\u03bb\u27e8p, e\u27e9, (subset.congr_left e).2 $ \u03bb\u27e8a, pa\u27e9, \u27e8a, equiv.refl (A a)\u27e9,\n  \u03bb\u03b2\u03b1, \u27e8{a | \u2203b, equiv (B b) (A a)}, \u03bbb, let \u27e8a, ba\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, b, ba\u27e9, ba\u27e9,\n    \u03bb\u27e8a, b, ba\u27e9, \u27e8b, ba\u27e9\u27e9\u27e9\n\n/-- The set union operator -/\ndef Union : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8\u03a3x, (A x).type, \u03bb\u27e8x, y\u27e9, (A x).func y\u27e9\n\ntheorem mem_Union : \u03a0 {x y : pSet.{u}}, y \u2208 Union x \u2194 \u2203 z:pSet.{u}, \u2203_:z \u2208 x, y \u2208 z\n| \u27e8\u03b1, A\u27e9 y :=\n  \u27e8\u03bb\u27e8\u27e8a, c\u27e9, (e : equiv y ((A a).func c))\u27e9,\n    have func (A a) c \u2208 mk (A a).type (A a).func, from mem.mk (A a).func c,\n    \u27e8_, mem.mk _ _, (mem.congr_left e).2 (by rwa mk_type_func at this)\u27e9,\n  \u03bb\u27e8\u27e8\u03b2, B\u27e9, \u27e8a, (e:equiv (mk \u03b2 B) (A a))\u27e9, \u27e8b, yb\u27e9\u27e9,\n    by rw \u2190(mk_type_func (A a)) at e; exact\n    let \u27e8\u03b2t, t\u03b2\u27e9 := e, \u27e8c, bc\u27e9 := \u03b2t b in \u27e8\u27e8a, c\u27e9, equiv.trans yb bc\u27e9\u27e9\n\n/-- The image of a function -/\ndef image (f : pSet.{u} \u2192 pSet.{u}) : pSet.{u} \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8\u03b1, \u03bba, f (A a)\u27e9\n\ntheorem mem_image {f : pSet.{u} \u2192 pSet.{u}} (H : \u2200{x y}, equiv x y \u2192 equiv (f x) (f y)) :\n  \u03a0 {x y : pSet.{u}}, y \u2208 image f x \u2194 \u2203z \u2208 x, equiv y (f z)\n| \u27e8\u03b1, A\u27e9 y := \u27e8\u03bb\u27e8a, ya\u27e9, \u27e8A a, mem.mk A a, ya\u27e9, \u03bb\u27e8z, \u27e8a, za\u27e9, yz\u27e9, \u27e8a, equiv.trans yz (H za)\u27e9\u27e9\n\n/-- Universe lift operation -/\nprotected def lift : pSet.{u} \u2192 pSet.{max u v}\n| \u27e8\u03b1, A\u27e9 := \u27e8ulift \u03b1, \u03bb\u27e8x\u27e9, lift (A x)\u27e9\n\n/-- Embedding of one universe in another -/\ndef embed : pSet.{max (u+1) v} := \u27e8ulift.{v u+1} pSet, \u03bb\u27e8x\u27e9, pSet.lift.{u (max (u+1) v)} x\u27e9\n\ntheorem lift_mem_embed : \u03a0 (x : pSet.{u}), pSet.lift.{u (max (u+1) v)} x \u2208 embed.{u v} :=\n\u03bbx, \u27e8\u27e8x\u27e9, equiv.refl _\u27e9\n\n/-- Function equivalence is defined so that `f ~ g` iff\n  `\u2200 x y, x ~ y \u2192 f x ~ g y`. This extends to equivalence of n-ary\n  functions. -/\ndef arity.equiv : \u03a0 {n}, arity pSet.{u} n \u2192 arity pSet.{u} n \u2192 Prop\n| 0     a b := equiv a b\n| (n+1) a b := \u2200 x y, equiv x y \u2192 arity.equiv (a x) (b y)\n\nlemma arity.equiv_const {a : pSet.{u}} : \u2200 n, arity.equiv (arity.const a n) (arity.const a n)\n| 0 := equiv.refl _\n| (n+1) := \u03bb 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\u27e8\u27e8arity.const (default _) _, arity.equiv_const _\u27e9\u27e9\n\ndef resp.f {n} (f : resp (n+1)) (x : pSet) : resp n :=\n\u27e8f.1 x, f.2 _ _ $ equiv.refl x\u27e9\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 : \u03a0 {n} {a b c : resp n}, resp.equiv a b \u2192 resp.equiv c b \u2192 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 \u03bbx 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\u27e8resp.equiv, resp.refl, \u03bbx y h, resp.euc (resp.refl y) h,\n  \u03bbx y z h1 h2, resp.euc h1 $ resp.euc (resp.refl z) h2\u27e9\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 : \u03a0 {n}, {f : resp n \u2192 arity Set.{u} n // \u2200 (a b : resp n), resp.equiv a b \u2192 f a = f b}\n| 0     := \u27e8\u03bba, \u27e6a.1\u27e7, \u03bba b h, quotient.sound h\u27e9\n| (n+1) := let F : resp (n + 1) \u2192 arity Set (n + 1) := \u03bba, @quotient.lift _ _ pSet.setoid\n    (\u03bbx, eval_aux.1 (a.f x)) (\u03bbb c h, eval_aux.2 _ _ (a.2 _ _ h)) in\n  \u27e8F, \u03bbb c h, funext $ @quotient.ind _ _ (\u03bbq, F b q = F c q) $ \u03bbz,\n  eval_aux.2 (resp.f b z) (resp.f c z) (h _ _ (equiv.refl z))\u27e9\n\n/-- An equivalence-respecting function yields an n-ary Set function. -/\ndef eval (n) : resp n \u2192 arity Set.{u} n := eval_aux.1\n\ntheorem eval_val {n f x} : (@eval (n+1) f : Set \u2192 arity Set n) \u27e6x\u27e7 = 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 \u2192 Type (u+1)\n| mk (f) : definable (resp.eval _ f)\nattribute [instance] definable.mk\n\ndef definable.eq_mk {n} (f) : \u03a0 {s : arity Set.{u} n} (H : resp.eval _ f = s), definable n s\n| ._ rfl := \u27e8f\u27e9\n\ndef definable.resp {n} : \u03a0 (s : arity Set.{u} n) [definable n s], resp n\n| ._ \u27e8f\u27e9 := f\n\ntheorem definable.eq {n} :\n  \u03a0 (s : arity Set.{u} n) [H : definable n s], (@definable.resp n s H).eval _ = s\n| ._ \u27e8f\u27e9 := rfl\n\nend pSet\n\nnamespace classical\nopen pSet\n\nnoncomputable def all_definable : \u03a0 {n} (F : arity Set.{u} n), definable n F\n| 0     F := let p := @quotient.exists_rep pSet _ F in\n              definable.eq_mk \u27e8some p, equiv.refl _\u27e9 (some_spec p)\n| (n+1) (F : arity Set.{u} (n + 1)) := begin\n    have I := \u03bbx, (all_definable (F x)),\n    refine definable.eq_mk \u27e8\u03bbx:pSet, (@definable.resp _ _ (I \u27e6x\u27e7)).1, _\u27e9 _,\n    { dsimp [arity.equiv],\n      introsI x y h,\n      rw @quotient.sound pSet _ _ _ h,\n      exact (definable.resp (F \u27e6y\u27e7)).2 },\n    exact funext (\u03bbq, quotient.induction_on q $ \u03bbx,\n      by simp [resp.eval_val, resp.f]; exact @definable.eq _ (F \u27e6x\u27e7) (I \u27e6x\u27e7))\n  end\n\nend classical\n\nnamespace Set\nopen pSet\n\ndef mk : pSet \u2192 Set := quotient.mk\n\n@[simp] theorem mk_eq (x : pSet) : @eq Set \u27e6x\u27e7 (mk x) := rfl\n\n@[simp] lemma eval_mk {n f x} :\n  (@resp.eval (n+1) f : Set \u2192 arity Set n) (mk x) = resp.eval n (resp.f f x) :=\nrfl\n\ndef mem : Set \u2192 Set \u2192 Prop :=\nquotient.lift\u2082 pSet.mem\n  (\u03bbx y x' y' hx hy, propext (iff.trans (mem.congr_left hx) (mem.congr_right hy)))\n\ninstance : has_mem Set Set := \u27e8mem\u27e9\n\n/-- Convert a ZFC set into a `set` of sets -/\ndef to_set (u : Set.{u}) : set Set.{u} := {x | x \u2208 u}\n\nprotected def subset (x y : Set.{u}) :=\n\u2200 \u2983z\u2984, z \u2208 x \u2192 z \u2208 y\n\ninstance has_subset : has_subset Set :=\n\u27e8Set.subset\u27e9\n\nlemma subset_def {x y : Set.{u}} : x \u2286 y \u2194 \u2200 \u2983z\u2984, z \u2208 x \u2192 z \u2208 y := iff.rfl\n\ntheorem subset_iff : \u03a0 (x y : pSet), mk x \u2286 mk y \u2194 x \u2286 y\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u27e8\u03bbh a, @h \u27e6A a\u27e7 (mem.mk A a),\n  \u03bbh z, quotient.induction_on z (\u03bbz \u27e8a, za\u27e9, let \u27e8b, ab\u27e9 := h a in \u27e8b, equiv.trans za ab\u27e9)\u27e9\n\ntheorem ext {x y : Set.{u}} : (\u2200z:Set.{u}, z \u2208 x \u2194 z \u2208 y) \u2192 x = y :=\nquotient.induction_on\u2082 x y (\u03bbu v h, quotient.sound (mem.ext (\u03bbw, h \u27e6w\u27e7)))\n\ntheorem ext_iff {x y : Set.{u}} : (\u2200z:Set.{u}, z \u2208 x \u2194 z \u2208 y) \u2194 x = y :=\n\u27e8ext, \u03bbh, by simp [h]\u27e9\n\n/-- The empty set -/\ndef empty : Set := mk \u2205\ninstance : has_emptyc Set := \u27e8empty\u27e9\ninstance : inhabited Set := \u27e8\u2205\u27e9\n\n@[simp] theorem mem_empty (x) : x \u2209 (\u2205:Set.{u}) :=\nquotient.induction_on x pSet.mem_empty\n\ntheorem eq_empty (x : Set.{u}) : x = \u2205 \u2194 \u2200y:Set.{u}, y \u2209 x :=\n\u27e8\u03bbh, by rw h; exact mem_empty,\n\u03bbh, ext (\u03bby, \u27e8\u03bbyx, absurd yx (h y), \u03bby0, absurd y0 (mem_empty _)\u27e9)\u27e9\n\n/-- `insert x y` is the set `{x} \u222a y` -/\nprotected def insert : Set \u2192 Set \u2192 Set :=\nresp.eval 2 \u27e8pSet.insert, \u03bbu v uv \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bbo, match o with\n   | some a := let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8some b, hb\u27e9\n   | none := \u27e8none, uv\u27e9\n   end, \u03bbo, match o with\n   | some b := let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8some a, ha\u27e9\n   | none := \u27e8none, uv\u27e9\n   end\u27e9\u27e9\n\ninstance : has_insert Set Set := \u27e8Set.insert\u27e9\n\ninstance : has_singleton Set Set := \u27e8\u03bb x, insert x \u2205\u27e9\n\ninstance : is_lawful_singleton Set Set := \u27e8\u03bb x, rfl\u27e9\n\n@[simp] theorem mem_insert {x y z : Set.{u}} : x \u2208 insert y z \u2194 x = y \u2228 x \u2208 z :=\nquotient.induction_on\u2083 x y z\n (\u03bbx y \u27e8\u03b1, A\u27e9, show x \u2208 pSet.mk (option \u03b1) (\u03bbo, option.rec y A o) \u2194\n    mk x = mk y \u2228 x \u2208 pSet.mk \u03b1 A, from\n  \u27e8\u03bbm, match m with\n  | \u27e8some a, ha\u27e9 := or.inr \u27e8a, ha\u27e9\n  | \u27e8none, h\u27e9 := or.inl (quotient.sound h)\n  end, \u03bbm, match m with\n  | or.inr \u27e8a, ha\u27e9 := \u27e8some a, ha\u27e9\n  | or.inl h := \u27e8none, quotient.exact h\u27e9\n  end\u27e9)\n\n@[simp] theorem mem_singleton {x y : Set.{u}} : x \u2208 @singleton Set.{u} Set.{u} _ y \u2194 x = y :=\niff.trans mem_insert \u27e8\u03bbo, or.rec (\u03bbh, h) (\u03bbn, absurd n (mem_empty _)) o, or.inl\u27e9\n\n@[simp] theorem mem_pair {x y z : Set.{u}} : x \u2208 ({y, z} : Set) \u2194 x = y \u2228 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 : \u2205 \u2208 omega :=\nshow pSet.mem \u2205 pSet.omega, from \u27e8\u27e80\u27e9, equiv.refl _\u27e9\n\n@[simp] theorem omega_succ {n} : n \u2208 omega.{u} \u2192 insert n n \u2208 omega.{u} :=\nquotient.induction_on n (\u03bbx \u27e8\u27e8n\u27e9, h\u27e9, \u27e8\u27e8n+1\u27e9,\n  have Set.insert \u27e6x\u27e7 \u27e6x\u27e7 = Set.insert \u27e6of_nat n\u27e7 \u27e6of_nat n\u27e7, by rw (@quotient.sound pSet _ _ _ h),\n  quotient.exact this\u27e9)\n\n/-- `{x \u2208 a | p x}` is the set of elements in `a` satisfying `p` -/\nprotected def sep (p : Set \u2192 Prop) : Set \u2192 Set :=\nresp.eval 1 \u27e8pSet.sep (\u03bby, p \u27e6y\u27e7), \u03bb\u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bb\u27e8a, pa\u27e9, let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8\u27e8b, by rwa \u2190(@quotient.sound pSet _ _ _ hb)\u27e9, hb\u27e9,\n   \u03bb\u27e8b, pb\u27e9, let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, by rwa (@quotient.sound pSet _ _ _ ha)\u27e9, ha\u27e9\u27e9\u27e9\n\ninstance : has_sep Set Set := \u27e8Set.sep\u27e9\n\n@[simp] theorem mem_sep {p : Set.{u} \u2192 Prop} {x y : Set.{u}} : y \u2208 {y \u2208 x | p y} \u2194 y \u2208 x \u2227 p y :=\nquotient.induction_on\u2082 x y (\u03bb\u27e8\u03b1, A\u27e9 y,\n  \u27e8\u03bb\u27e8\u27e8a, pa\u27e9, h\u27e9, \u27e8\u27e8a, h\u27e9, by rw (@quotient.sound pSet _ _ _ h); exact pa\u27e9,\n  \u03bb\u27e8\u27e8a, h\u27e9, pa\u27e9, \u27e8\u27e8a, by rw \u2190(@quotient.sound pSet _ _ _ h); exact pa\u27e9, h\u27e9\u27e9)\n\n/-- The powerset operation, the collection of subsets of a set -/\ndef powerset : Set \u2192 Set :=\nresp.eval 1 \u27e8powerset, \u03bb\u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bbp, \u27e8{b | \u2203a, p a \u2227 equiv (A a) (B b)},\n    \u03bb\u27e8a, pa\u27e9, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a in \u27e8\u27e8b, a, pa, ab\u27e9, ab\u27e9,\n    \u03bb\u27e8b, a, pa, ab\u27e9, \u27e8\u27e8a, pa\u27e9, ab\u27e9\u27e9,\n   \u03bbq, \u27e8{a | \u2203b, q b \u2227 equiv (A a) (B b)},\n    \u03bb\u27e8a, b, qb, ab\u27e9, \u27e8\u27e8b, qb\u27e9, ab\u27e9,\n    \u03bb\u27e8b, qb\u27e9, let \u27e8a, ab\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, b, qb, ab\u27e9, ab\u27e9\u27e9\u27e9\u27e9\n\n@[simp] theorem mem_powerset {x y : Set} : y \u2208 powerset x \u2194 y \u2286 x :=\nquotient.induction_on\u2082 x y (\u03bb\u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9,\n  show (\u27e8\u03b2, B\u27e9 : pSet) \u2208 (pSet.powerset \u27e8\u03b1, A\u27e9) \u2194 _,\n    by simp [mem_powerset, subset_iff])\n\ntheorem Union_lem {\u03b1 \u03b2 : Type u} (A : \u03b1 \u2192 pSet) (B : \u03b2 \u2192 pSet)\n  (\u03b1\u03b2 : \u2200a, \u2203b, equiv (A a) (B b)) : \u2200a, \u2203b, (equiv ((Union \u27e8\u03b1, A\u27e9).func a) ((Union \u27e8\u03b2, B\u27e9).func b))\n| \u27e8a, c\u27e9 := let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in\n  begin\n    induction ea : A a with \u03b3 \u0393,\n    induction eb : B b with \u03b4 \u0394,\n    rw [ea, eb] at hb,\n    cases hb with \u03b3\u03b4 \u03b4\u03b3,\n    exact\n    let c : type (A a) := c, \u27e8d, hd\u27e9 := \u03b3\u03b4 (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    \u27e8\u27e8b, eq.rec d (eq.symm eb)\u27e9, this\u27e9\n  end\n\n/-- The union operator, the collection of elements of elements of a set -/\ndef Union : Set \u2192 Set :=\nresp.eval 1 \u27e8pSet.Union, \u03bb\u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8Union_lem A B \u03b1\u03b2, \u03bba, exists.elim (Union_lem B A (\u03bbb,\n    exists.elim (\u03b2\u03b1 b) (\u03bbc hc, \u27e8c, equiv.symm hc\u27e9)) a) (\u03bbb hb, \u27e8b, equiv.symm hb\u27e9)\u27e9\u27e9\n\nnotation `\u22c3` := Union\n\n@[simp] theorem mem_Union {x y : Set.{u}} : y \u2208 Union x \u2194 \u2203 z \u2208 x, y \u2208 z :=\nquotient.induction_on\u2082 x y (\u03bbx y, iff.trans mem_Union\n  \u27e8\u03bb\u27e8z, h\u27e9, \u27e8\u27e6z\u27e7, h\u27e9, \u03bb\u27e8z, h\u27e9, quotient.induction_on z (\u03bbz h, \u27e8z, h\u27e9) h\u27e9)\n\n@[simp] theorem Union_singleton {x : Set.{u}} : Union {x} = x :=\next $ \u03bby, by simp; exact \u27e8\u03bb\u27e8z, zx, yz\u27e9, by subst z; exact yz, \u03bbyx, \u27e8x, by simp, yx\u27e9\u27e9\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} := \u22c3 {x, y}\n\n/-- The binary intersection operation -/\nprotected def inter (x y : Set.{u}) : Set.{u} := {z \u2208 x | z \u2208 y}\n\n/-- The set difference operation -/\nprotected def diff (x y : Set.{u}) : Set.{u} := {z \u2208 x | z \u2209 y}\n\ninstance : has_union Set := \u27e8Set.union\u27e9\ninstance : has_inter Set := \u27e8Set.inter\u27e9\ninstance : has_sdiff Set := \u27e8Set.diff\u27e9\n\n@[simp] theorem mem_union {x y z : Set.{u}} : z \u2208 x \u222a y \u2194 z \u2208 x \u2228 z \u2208 y :=\niff.trans mem_Union\n \u27e8\u03bb\u27e8w, wxy, zw\u27e9, match mem_pair.1 wxy with\n  | or.inl wx := or.inl (by rwa \u2190wx)\n  | or.inr wy := or.inr (by rwa \u2190wy)\n  end, \u03bbzxy, match zxy with\n  | or.inl zx := \u27e8x, mem_pair.2 (or.inl rfl), zx\u27e9\n  | or.inr zy := \u27e8y, mem_pair.2 (or.inr rfl), zy\u27e9\n  end\u27e9\n\n@[simp] theorem mem_inter {x y z : Set.{u}} : z \u2208 x \u2229 y \u2194 z \u2208 x \u2227 z \u2208 y :=\n@@mem_sep (\u03bbz:Set.{u}, z \u2208 y)\n\n@[simp] theorem mem_diff {x y z : Set.{u}} : z \u2208 x \\ y \u2194 z \u2208 x \u2227 z \u2209 y :=\n@@mem_sep (\u03bbz:Set.{u}, z \u2209 y)\n\ntheorem induction_on {p : Set \u2192 Prop} (x) (h : \u2200x, (\u2200y \u2208 x, p y) \u2192 p x) : p x :=\nquotient.induction_on x $ \u03bbu, pSet.rec_on u $ \u03bb\u03b1 A IH, h _ $ \u03bby,\nshow @has_mem.mem _ _ Set.has_mem y \u27e6\u27e8\u03b1, A\u27e9\u27e7 \u2192 p y, from\nquotient.induction_on y (\u03bbv \u27e8a, ha\u27e9, by rw (@quotient.sound pSet _ _ _ ha); exact IH a)\n\ntheorem regularity (x : Set.{u}) (h : x \u2260 \u2205) : \u2203 y \u2208 x, x \u2229 y = \u2205 :=\nclassical.by_contradiction $ \u03bbne, h $ (eq_empty x).2 $ \u03bby,\ninduction_on y $ \u03bbz (IH : \u2200w:Set.{u}, w \u2208 z \u2192 w \u2209 x), show z \u2209 x, from \u03bbzx,\nne \u27e8z, zx, (eq_empty _).2 (\u03bbw wxz, let \u27e8wx, wz\u27e9 := mem_inter.1 wxz in IH w wz wx)\u27e9\n\n/-- The image of a (definable) set function -/\ndef image (f : Set \u2192 Set) [H : definable 1 f] : Set \u2192 Set :=\nlet r := @definable.resp 1 f _ in\nresp.eval 1 \u27e8image r.1, \u03bbx y e, mem.ext $ \u03bbz,\n  iff.trans (mem_image r.2) $ iff.trans (by exact\n   \u27e8\u03bb\u27e8w, h1, h2\u27e9, \u27e8w, (mem.congr_right e).1 h1, h2\u27e9,\n    \u03bb\u27e8w, h1, h2\u27e9, \u27e8w, (mem.congr_right e).2 h1, h2\u27e9\u27e9) $\n  iff.symm (mem_image r.2)\u27e9\n\ntheorem image.mk :\n  \u03a0 (f : Set.{u} \u2192 Set.{u}) [H : definable 1 f] (x) {y} (h : y \u2208 x), f y \u2208 @image f H x\n| ._ \u27e8F\u27e9 x y := quotient.induction_on\u2082 x y $ \u03bb\u27e8\u03b1, A\u27e9 y \u27e8a, ya\u27e9, \u27e8a, F.2 _ _ ya\u27e9\n\n@[simp] theorem mem_image :\n  \u03a0 {f : Set.{u} \u2192 Set.{u}} [H : definable 1 f] {x y : Set.{u}}, y \u2208 @image f H x \u2194 \u2203z \u2208 x, f z = y\n| ._ \u27e8F\u27e9 x y := quotient.induction_on\u2082 x y $ \u03bb\u27e8\u03b1, A\u27e9 y,\n  \u27e8\u03bb\u27e8a, ya\u27e9, \u27e8\u27e6A a\u27e7, mem.mk A a, eq.symm $ quotient.sound ya\u27e9,\n  \u03bb\u27e8z, hz, e\u27e9, e \u25b8 image.mk _ _ hz\u27e9\n\n/-- Kuratowski ordered pair -/\ndef pair (x y : Set.{u}) : Set.{u} := {{x}, {x, y}}\n\n/-- A subset of pairs `{(a, b) \u2208 x \u00d7 y | p a b}` -/\ndef pair_sep (p : Set.{u} \u2192 Set.{u} \u2192 Prop) (x y : Set.{u}) : Set.{u} :=\n{z \u2208 powerset (powerset (x \u222a y)) | \u2203a \u2208 x, \u2203b \u2208 y, z = pair a b \u2227 p a b}\n\n@[simp] theorem mem_pair_sep {p} {x y z : Set.{u}} :\n  z \u2208 pair_sep p x y \u2194 \u2203a \u2208 x, \u2203b \u2208 y, z = pair a b \u2227 p a b :=\nbegin\n  refine mem_sep.trans \u27e8and.right, \u03bbe, \u27e8_, e\u27e9\u27e9,\n  rcases e with \u27e8a, ax, b, bY, rfl, pab\u27e9,\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' \u2227 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' \u2208 ({x} : Set),\n      { rw h, simp },\n      simp at m, simp [*] } },\n  subst x',\n  have he : y = x \u2192 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' \u2208 ({x} : Set) := by rw \u2190 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 \u2208 x, b \u2208 y}` -/\ndef prod : Set.{u} \u2192 Set.{u} \u2192 Set.{u} := pair_sep (\u03bba b, true)\n\n@[simp] theorem mem_prod {x y z : Set.{u}} : z \u2208 prod x y \u2194 \u2203a \u2208 x, \u2203b \u2208 y, z = pair a b :=\nby simp [prod]\n\n@[simp] theorem pair_mem_prod {x y a b : Set.{u}} : pair a b \u2208 prod x y \u2194 a \u2208 x \u2227 b \u2208 y :=\n\u27e8\u03bbh, let \u27e8a', a'x, b', b'y, e\u27e9 := mem_prod.1 h in\n  match a', b', pair_inj e, a'x, b'y with ._, ._, \u27e8rfl, rfl\u27e9, ax, bY := \u27e8ax, bY\u27e9 end,\n\u03bb\u27e8ax, bY\u27e9, by simp; exact \u27e8a, ax, b, bY, rfl\u27e9\u27e9\n\n/-- `is_func x y f` is the assertion `f : x \u2192 y` where `f` is a ZFC function\n  (a set of ordered pairs) -/\ndef is_func (x y f : Set.{u}) : Prop :=\nf \u2286 prod x y \u2227 \u2200z:Set.{u}, z \u2208 x \u2192 \u2203! w, pair z w \u2208 f\n\n/-- `funs x y` is `y ^ x`, the set of all set functions `x \u2192 y` -/\ndef funs (x y : Set.{u}) : Set.{u} :=\n{f \u2208 powerset (prod x y) | is_func x y f}\n\n@[simp] theorem mem_funs {x y f : Set.{u}} : f \u2208 funs x y \u2194 is_func x y f :=\nby simp [funs, is_func]\n\n-- TODO(Mario): Prove this computably\nnoncomputable instance map_definable_aux (f : Set \u2192 Set) [H : definable 1 f] :\n  definable 1 (\u03bby, 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 \u2208 x` to `f a` -/\nnoncomputable def map (f : Set \u2192 Set) [H : definable 1 f] : Set \u2192 Set :=\nimage (\u03bby, pair y (f y))\n\n@[simp] theorem mem_map {f : Set \u2192 Set} [H : definable 1 f] {x y : Set} :\n  y \u2208 map f x \u2194 \u2203z \u2208 x, pair z (f z) = y :=\nmem_image\n\ntheorem map_unique {f : Set.{u} \u2192 Set.{u}} [H : definable 1 f] {x z : Set.{u}} (zx : z \u2208 x) :\n  \u2203! w, pair z w \u2208 map f x :=\n\u27e8f z, image.mk _ _ zx, \u03bby yx, let \u27e8w, wx, we\u27e9 := mem_image.1 yx, \u27e8wz, fy\u27e9 := pair_inj we in\n  by rw[\u2190fy, wz]\u27e9\n\n@[simp] theorem map_is_func {f : Set \u2192 Set} [H : definable 1 f] {x y : Set} :\n  is_func x y (map f x) \u2194 \u2200z \u2208 x, f z \u2208 y :=\n\u27e8\u03bb\u27e8ss, h\u27e9 z zx, let \u27e8t, t1, t2\u27e9 := h z zx in by rw (t2 (f z) (image.mk _ _ zx));\n  exact (pair_mem_prod.1 (ss t1)).right,\n\u03bbh, \u27e8\u03bby yx, let \u27e8z, zx, ze\u27e9 := mem_image.1 yx in by rw \u2190ze; exact pair_mem_prod.2 \u27e8zx, h z zx\u27e9,\n     \u03bbz, map_unique\u27e9\u27e9\n\nend Set\n\ndef Class := set Set\n\nnamespace Class\n\ninstance : has_subset Class     := \u27e8set.subset\u27e9\ninstance : has_sep Set Class    := \u27e8set.sep\u27e9\ninstance : has_emptyc Class     := \u27e8\u03bb a, false\u27e9\ninstance : inhabited Class      := \u27e8\u2205\u27e9\ninstance : has_insert Set Class := \u27e8set.insert\u27e9\ninstance : has_union Class      := \u27e8set.union\u27e9\ninstance : has_inter Class      := \u27e8set.inter\u27e9\ninstance : has_neg Class        := \u27e8set.compl\u27e9\ninstance : has_sdiff Class      := \u27e8set.diff\u27e9\n\n/-- Coerce a set into a class -/\ndef of_Set (x : Set.{u}) : Class.{u} := {y | y \u2208 x}\ninstance : has_coe Set Class := \u27e8of_Set\u27e9\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} \u2192 Prop) (A : Class.{u}) : Prop := \u2203x, \u2191x = A \u2227 p x\n\n/-- `A \u2208 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 := \u27e8Class.mem\u27e9\n\ntheorem mem_univ {A : Class.{u}} : A \u2208 univ.{u} \u2194 \u2203 x : Set.{u}, \u2191x = A :=\nexists_congr $ \u03bbx, 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 | \u2191y \u2208 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 \u2208 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 `\u22c3` := Union\n\ntheorem of_Set.inj {x y : Set.{u}} (h : (x : Class.{u}) = y) : x = y :=\nSet.ext $ \u03bbz, by change (x : Class.{u}) z \u2194 (y : Class.{u}) z; simp [*]\n\n@[simp] theorem to_Set_of_Set (p : Set.{u} \u2192 Prop) (x : Set.{u}) : to_Set p x \u2194 p x :=\n\u27e8\u03bb\u27e8y, yx, py\u27e9, by rwa of_Set.inj yx at py, \u03bbpx, \u27e8x, rfl, px\u27e9\u27e9\n\n@[simp] theorem mem_hom_left (x : Set.{u}) (A : Class.{u}) : (x : Class.{u}) \u2208 A \u2194 A x :=\nto_Set_of_Set _ _\n\n@[simp] theorem mem_hom_right (x y : Set.{u}) : (y : Class.{u}) x \u2194 x \u2208 y := iff.rfl\n\n@[simp] theorem subset_hom (x y : Set.{u}) : (x : Class.{u}) \u2286 y \u2194 x \u2286 y := iff.rfl\n\n@[simp] theorem sep_hom (p : Set.{u} \u2192 Prop) (x : Set.{u}) :\n  (\u2191{y \u2208 x | p y} : Class.{u}) = {y \u2208 x | p y} :=\nset.ext $ \u03bby, Set.mem_sep\n\n@[simp] theorem empty_hom : \u2191(\u2205 : Set.{u}) = (\u2205 : Class.{u}) :=\nset.ext $ \u03bby, show _ \u2194 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) = \u2191(insert x y) :=\nset.ext $ \u03bbz, iff.symm Set.mem_insert\n\n@[simp] theorem union_hom (x y : Set.{u}) : (x : Class.{u}) \u222a y = (x \u222a y : Set.{u}) :=\nset.ext $ \u03bbz, iff.symm Set.mem_union\n\n@[simp] theorem inter_hom (x y : Set.{u}) : (x : Class.{u}) \u2229 y = (x \u2229 y : Set.{u}) :=\nset.ext $ \u03bbz, 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 $ \u03bbz, iff.symm Set.mem_diff\n\n@[simp] theorem powerset_hom (x : Set.{u}) : powerset.{u} x = Set.powerset x :=\nset.ext $ \u03bbz, iff.symm Set.mem_powerset\n\n@[simp] theorem Union_hom (x : Set.{u}) : Union.{u} x = Set.Union x :=\nset.ext $ \u03bbz, by refine iff.trans _ (iff.symm Set.mem_Union); exact\n\u27e8\u03bb\u27e8._, \u27e8a, rfl, ax\u27e9, za\u27e9, \u27e8a, ax, za\u27e9, \u03bb\u27e8a, ax, za\u27e9, \u27e8_, \u27e8a, rfl, ax\u27e9, za\u27e9\u27e9\n\n/-- The definite description operator, which is {x} if `{a | p a} = {x}`\n  and \u2205 otherwise -/\ndef iota (p : Set \u2192 Prop) : Class := Union {x | \u2200y, p y \u2194 y = x}\n\ntheorem iota_val (p : Set \u2192 Prop) (x : Set) (H : \u2200y, p y \u2194 y = x) : iota p = \u2191x :=\nset.ext $ \u03bby, \u27e8\u03bb\u27e8._, \u27e8x', rfl, h\u27e9, yx'\u27e9, by rwa \u2190((H x').1 $ (h x').2 rfl),\n  \u03bbyx, \u27e8_, \u27e8x, rfl, H\u27e9, yx\u27e9\u27e9\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 \u2192 Prop) \u2192 Set` function. -/\ntheorem iota_ex (p) : iota.{u} p \u2208 univ.{u} :=\nmem_univ.2 $ or.elim (classical.em $ \u2203x, \u2200y, p y \u2194 y = x)\n (\u03bb\u27e8x, h\u27e9, \u27e8x, eq.symm $ iota_val p x h\u27e9)\n (\u03bbhn, \u27e8\u2205, by simp; exact set.ext (\u03bbz, \u27e8false.rec _, \u03bb\u27e8._, \u27e8x, rfl, H\u27e9, zA\u27e9, hn \u27e8x, H\u27e9\u27e9)\u27e9)\n\n/-- Function value -/\ndef fval (F A : Class.{u}) : Class.{u} := iota (\u03bby, to_Set (\u03bbx, F (Set.pair x y)) A)\ninfixl `\u2032`:100 := fval\n\ntheorem fval_ex (F A : Class.{u}) : F \u2032 A \u2208 univ.{u} := iota_ex _\n\nend Class\n\nnamespace Set\n\n@[simp] theorem map_fval {f : Set.{u} \u2192 Set.{u}} [H : pSet.definable 1 f]\n  {x y : Set.{u}} (h : y \u2208 x) :\n  (Set.map f x \u2032 y : Class.{u}) = f y :=\nClass.iota_val _ _ (\u03bbz, by simp; exact\n  \u27e8\u03bb\u27e8w, wz, pr\u27e9, let \u27e8wy, fw\u27e9 := Set.pair_inj pr in by rw[\u2190fw, wy],\n  \u03bbe, by cases e; exact \u27e8_, h, rfl\u27e9\u27e9)\n\nvariables (x : Set.{u}) (h : \u2205 \u2209 x)\n\n/-- A choice function on the set of nonempty sets `x` -/\nnoncomputable def choice : Set :=\n@map (\u03bby, classical.epsilon (\u03bbz, z \u2208 y)) (classical.all_definable _) x\n\ninclude h\ntheorem choice_mem_aux (y : Set.{u}) (yx : y \u2208 x) : classical.epsilon (\u03bbz:Set.{u}, z \u2208 y) \u2208 y :=\n@classical.epsilon_spec _ (\u03bbz:Set.{u}, z \u2208 y) $ classical.by_contradiction $ \u03bbn, h $\nby rwa \u2190((eq_empty y).2 $ \u03bbz zx, n \u27e8z, zx\u27e9)\n\ntheorem choice_is_func : is_func x (Union x) (choice x) :=\n(@map_is_func _ (classical.all_definable _) _ _).2 $\n  \u03bby yx, by simp; exact \u27e8y, yx, choice_mem_aux x h y yx\u27e9\n\ntheorem choice_mem (y : Set.{u}) (yx : y \u2208 x) : (choice x \u2032 y : Class.{u}) \u2208 (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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u2192 name \u2192 expr\n| (local_const n _ bi d) pp := local_const n pp bi d\n| e n := e\n\nprivate meta def elim_or : \u2115 \u2192 expr \u2192 tactic (list expr)\n| 0       h := fail \"zero cases\"\n| 1       h := return [h]\n| (n + 1) h := do\n  [(_, [hl], []), (_, [hr], [])] \u2190 induction h, -- there should be no dependent terms\n  [gl, gr] \u2190 get_goals,\n  set_goals [gr],\n  hsr \u2190 elim_or n hr,\n  gsr \u2190 get_goals,\n  set_goals (gl :: gsr),\n  return (hl :: hsr)\n\nprivate meta def dest_or : expr \u2192 tactic (list expr) | e := do\n  `(%%a \u2228 %%b) \u2190 whnf e | return [e],\n  lb \u2190 dest_or b,\n  return (a :: lb)\n\nprivate meta def match_perms (pat : pattern) : expr \u2192 tactic (list $ list expr) | t :=\n  (do\n    m \u2190 match_pattern pat t,\n    guard (m.2.all expr.is_local_constant),\n    return [m.2]) <|>\n  (do\n    `(%%l \u2228 %%r) \u2190 whnf t,\n    m \u2190 match_pattern pat l,\n    rs \u2190 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 \u0393 \u2b1d vars \u2b1d cases \u22a2 \u2200deps, \u2026\n  nr \u2190 revert_lst (vars' ++ [h_cases]),\n  vars \u2190 intron' vars'.length,\n  h_cases \u2190 intro h_cases.local_pp_name,\n\n  cases \u2190 infer_type h_cases,\n  h_fst_case \u2190\n    mk_local_def h_cases.local_pp_name\n      (fst_case.instantiate_locals $ (vars'.zip vars).map $ \u03bb\u27e8o, n\u27e9, (o.local_uniq_name, n)),\n  ((), pr) \u2190 solve_aux cases (repeat $ exact h_fst_case <|> left >> skip),\n\n  t \u2190 target,\n  fixed_vars \u2190 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]) \u2190 local_proof `this t' (do\n    clear h_cases,\n    vars.mmap clear,\n    intron nr),\n\n  h\u2080 :: hs \u2190 elim_or perms.length h_cases,\n\n  solve1 (do\n    exact (h.mk_app $ vars ++ [h\u2080])),\n\n  focus ((hs.zip perms.tail).map $ \u03bb\u27e8h_case, perm\u27e9, do\n    let p_v := (vars'.zip vars).map (\u03bb\u27e8p, v\u27e9, (p.local_uniq_name, v)),\n    let p := perm.map (\u03bbp, p.instantiate_locals p_v),\n    note `this none (h.mk_app $ p ++ [h_case]),\n    clear h,\n    return ()),\n  gs \u2190 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)) \u2192 tactic (list (list expr))\n| none                    := return []\n| (some [])               := return []\n| (some perms@(p\u2080 :: ps)) := do\n  (guard p\u2080.nodup <|>\n    fail \"No permutation `xs_i` in `using [xs_1, \u2026, xs_n]` should contain the same variable twice.\"),\n  (guard (perms.all $ \u03bbp, p.perm p\u2080) <|>\n    fail \"The permutations `xs_i` in `using [xs_1, \u2026, xs_n]` must be permutations of the same variables.\"),\n  perms.mmap (\u03bbp, 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  `\u22a2 p xs_0 \u2228 \u22ef \u2228 p xs_n`\nThe main goal, i.e. the goal reduced to `xs_0`:\n  `(h : p xs_0) \u22a2 g xs_0`\nThe invariant goals, i.e. `g` is invariant under `xs_i`:\n  `(h : p xs_i) (this : g xs_0) \u22a2 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\u2080 \u2228 (p\u2081 \u2228 p\u2082)`. In many cases\nthe invariant goals can be solved by AC rewriting using `cc` etc.\n\nExample:\n  On a state `(n m : \u2115) \u22a2 p n m` the tactic `wlog h : n \u2264 m using [n m, m n]` produces the following\n  states:\n    `(n m : \u2115) \u22a2 n \u2264 m \u2228 m \u2264 n`\n    `(n m : \u2115) (h : n \u2264 m) \u22a2 p n m`\n    `(n m : \u2115) (h : m \u2264 n) (this : p n m) \u22a2 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, \u2026, xsn]`\n  Results in the case goal `p xs0 \u2228 \u22ef \u2228 ps xsn`, the main goal `(case : p xs0) \u22a2 g xs0` and the\n  invariance goals `(case : p xsi) (this : g xs0) \u22a2 g xsi`.\n\n(2) `wlog : p xs0 := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 \u2228 \u22ef \u2228 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 \u2228 \u22ef \u2228 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 \u2228 R y x`. If `R` is \u2264, 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*) <|> (\u03bbx, [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 \u2190 parse_permutations perms,\n(pat, cases_pr, cases_goal, vars, perms) \u2190 (match cases with\n| some r := do\n  vars::_ \u2190 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 \u2190 to_expr r,\n  cases_pr \u2190 (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 \u2190 infer_type cases_pr,\n  (pat, perms') \u2190 match pat with\n  | some pat := do\n    pat \u2190 to_expr pat,\n    let vars' := vars.filter $ \u03bbv, v.occurs pat,\n    case_pat \u2190 mk_pattern [] vars' pat [] vars',\n    perms' \u2190 match_perms case_pat cases,\n    return (pat, perms')\n  | none := do\n    (p :: ps) \u2190 dest_or cases,\n    let vars' := vars.filter $ \u03bbv, v.occurs p,\n    case_pat \u2190 mk_pattern [] vars' p [] vars',\n    perms' \u2190 (p :: ps).mmap (\u03bbp, do m \u2190 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 $ \u03bbp, p.all $ \u03bbv, v.is_local_constant \u2227 v.local_uniq_name \u2208 vars_name) <|>\n    fail \"Cases contains variables not declared in `using x y z`\",\n  perms \u2190 (if perms.length = 1\n    then do\n      return (perms'.map $ \u03bbp, p ++ vars.filter (\u03bbv, p.all (\u03bbv', v'.local_uniq_name \u2260 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 \u2190 return pat | fail \"Either specify cases or a pattern with permutations\",\n  pat \u2190 to_expr pat,\n  (do\n    [x, y] \u2190 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' \u2264 %%y') \u2190 return pat,\n      (cases_pr, []) \u2190 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]) \u2190 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 \u2265 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') \u2190 return perms,\n    let names := vars.map local_uniq_name,\n    let cases := mk_or_lst (pat :: perms'.map (\u03bbp, pat.instantiate_locals (names.zip p))),\n    (cases_pr, [g]) \u2190 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 \u03bbi, `invariant else \u03bbi, mk_simple_name (\"invariant_\" ++ to_string (i + 1))),\nwith_enable_tags $ tactic.focus1 $ do\n  t \u2190 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 (\u03bbi, 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 \u2190 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* `\u03a0\u2097 i, \u03b1 i`: Pi type equipped with the lexicographic order. Type synonym of `\u03a0 i, \u03b1 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 `\u03a3\u2097 i, \u03b1 i`.\n* `data.psigma.order`: Lexicographic order on `\u03a3\u2097' i, \u03b1 i`.\n* `data.prod.lex`: Lexicographic order on `\u03b1 \u00d7 \u03b2`.\n-/\n\nvariables {\u03b9 : Type*} {\u03b2 : \u03b9 \u2192 Type*} (r : \u03b9 \u2192 \u03b9 \u2192 Prop)\n  (s : \u03a0 {i}, \u03b2 i \u2192 \u03b2 i \u2192 Prop)\n\nnamespace pi\n\ninstance {\u03b1 : Type*} : \u03a0 [inhabited \u03b1], inhabited (lex \u03b1) := id\n\n/-- The lexicographic relation on `\u03a0 i : \u03b9, \u03b2 i`, where `\u03b9` is ordered by `r`,\n  and each `\u03b2 i` is ordered by `s`. -/\nprotected def lex (x y : \u03a0 i, \u03b2 i) : Prop :=\n\u2203 i, (\u2200 j, r j i \u2192 x j = y j) \u2227 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 `\u03a0\u2097` binders `, ` r:(scoped p, lex (\u03a0 i, p i)) := r\n\n@[simp] lemma to_lex_apply (x : \u03a0 i, \u03b2 i) (i : \u03b9) : to_lex x i = x i := rfl\n@[simp] lemma of_lex_apply (x : lex (\u03a0 i, \u03b2 i)) (i : \u03b9) : of_lex x i = x i := rfl\n\nlemma lex_lt_of_lt_of_preorder [\u03a0 i, preorder (\u03b2 i)] {r} (hwf : well_founded r)\n  {x y : \u03a0 i, \u03b2 i} (hlt : x < y) : \u2203 i, (\u2200 j, r j i \u2192 x j \u2264 y j \u2227 y j \u2264 x j) \u2227 x i < y i :=\nlet h' := pi.lt_def.1 hlt, \u27e8i, hi, hl\u27e9 := hwf.has_min _ h'.2 in\n  \u27e8i, \u03bb j hj, \u27e8h'.1 j, not_not.1 $ \u03bb h, hl j (lt_of_le_not_le (h'.1 j) h) hj\u27e9, hi\u27e9\n\nlemma lex_lt_of_lt [\u03a0 i, partial_order (\u03b2 i)] {r} (hwf : well_founded r)\n  {x y : \u03a0 i, \u03b2 i} (hlt : x < y) : pi.lex r (\u03bb 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 [\u2200 i, is_trichotomous (\u03b2 i) s] (wf : well_founded r) :\n  is_trichotomous (\u03a0 i, \u03b2 i) (pi.lex r @s) :=\n{ trichotomous := \u03bb 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 : \u2200 j, r j i \u2192 a j = b j,\n        { intro j, rw \u2190 not_imp_not,\n          exact \u03bb h', wf.not_lt_min _ _ h' },\n        have hne : a i \u2260 b i, from wf.min_mem _ hab,\n        cases trichotomous_of s (a i) (b i) with hi hi,\n        exacts [or.inl \u27e8i, hri, hi\u27e9,\n          or.inr $ or.inr $ \u27e8i, \u03bb j hj, (hri j hj).symm, hi.resolve_left hne\u27e9] },\n    end }\n\ninstance [has_lt \u03b9] [\u03a0 a, has_lt (\u03b2 a)] : has_lt (lex (\u03a0 i, \u03b2 i)) := \u27e8pi.lex (<) (\u03bb _, (<))\u27e9\n\ninstance lex.is_strict_order [linear_order \u03b9] [\u2200 a, partial_order (\u03b2 a)] :\n  is_strict_order (lex (\u03a0 i, \u03b2 i)) (<) :=\n{ irrefl := \u03bb a \u27e8k, hk\u2081, hk\u2082\u27e9, lt_irrefl (a k) hk\u2082,\n  trans :=\n    begin\n      rintro a b c \u27e8N\u2081, lt_N\u2081, a_lt_b\u27e9 \u27e8N\u2082, lt_N\u2082, b_lt_c\u27e9,\n      rcases lt_trichotomy N\u2081 N\u2082 with (H|rfl|H),\n      exacts [\u27e8N\u2081, \u03bb j hj, (lt_N\u2081 _ hj).trans (lt_N\u2082 _ $ hj.trans H), lt_N\u2082 _ H \u25b8 a_lt_b\u27e9,\n        \u27e8N\u2081, \u03bb j hj, (lt_N\u2081 _ hj).trans (lt_N\u2082 _ hj), a_lt_b.trans b_lt_c\u27e9,\n        \u27e8N\u2082, \u03bb j hj, (lt_N\u2081 _ (hj.trans H)).trans (lt_N\u2082 _ hj), (lt_N\u2081 _ H).symm \u25b8 b_lt_c\u27e9]\n    end }\n\ninstance [linear_order \u03b9] [\u03a0 a, partial_order (\u03b2 a)] : partial_order (lex (\u03a0 i, \u03b2 i)) :=\npartial_order_of_SO (<)\n\n/-- `\u03a0\u2097 i, \u03b1 i` is a linear order if the original order is well-founded. -/\nnoncomputable instance [linear_order \u03b9] [is_well_order \u03b9 (<)] [\u2200 a, linear_order (\u03b2 a)] :\n  linear_order (lex (\u03a0 i, \u03b2 i)) :=\n@linear_order_of_STO (\u03a0\u2097 i, \u03b2 i) (<)\n  { to_is_trichotomous := is_trichotomous_lex _ _ is_well_founded.wf } (classical.dec_rel _)\n\nsection partial_order\nvariables [linear_order \u03b9] [is_well_order \u03b9 (<)] [\u03a0 i, partial_order (\u03b2 i)] {x y : \u03a0 i, \u03b2 i} {i : \u03b9}\n  {a b : \u03b2 i}\n\nopen function\n\nlemma to_lex_monotone : monotone (@to_lex (\u03a0 i, \u03b2 i)) :=\n\u03bb a b h, or_iff_not_imp_left.2 $ \u03bb hne,\n  let \u27e8i, hi, hl\u27e9 := is_well_founded.wf.has_min {i | a i \u2260 b i} (function.ne_iff.1 hne) in\n  \u27e8i, \u03bb j hj, by { contrapose! hl, exact \u27e8j, hl, hj\u27e9 }, (h i).lt_of_ne hi\u27e9\n\nlemma to_lex_strict_mono : strict_mono (@to_lex (\u03a0 i, \u03b2 i)) :=\n\u03bb a b h, let \u27e8i, hi, hl\u27e9 := is_well_founded.wf.has_min {i | a i \u2260 b i} (function.ne_iff.1 h.ne) in\n  \u27e8i, \u03bb j hj, by { contrapose! hl, exact \u27e8j, hl, hj\u27e9 }, (h.le i).lt_of_ne hi\u27e9\n\n@[simp] lemma lt_to_lex_update_self_iff : to_lex x < to_lex (update x i a) \u2194 x i < a :=\nbegin\n  refine \u27e8_, \u03bb h, to_lex_strict_mono $ lt_update_self_iff.2 h\u27e9,\n  rintro \u27e8j, hj, h\u27e9,\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 \u2194 a < x i :=\nbegin\n  refine \u27e8_, \u03bb h, to_lex_strict_mono $ update_lt_self_iff.2 h\u27e9,\n  rintro \u27e8j, hj, h\u27e9,\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 \u2264 to_lex (update x i a) \u2194 x i \u2264 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) \u2264 to_lex x \u2194 a \u2264 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 \u03b9] [is_well_order \u03b9 (<)] [\u03a0 a, partial_order (\u03b2 a)]\n  [\u03a0 a, order_bot (\u03b2 a)] : order_bot (lex (\u03a0 a, \u03b2 a)) :=\n{ bot := to_lex \u22a5,\n  bot_le := \u03bb f, to_lex_monotone bot_le }\n\ninstance [linear_order \u03b9] [is_well_order \u03b9 (<)] [\u03a0 a, partial_order (\u03b2 a)]\n  [\u03a0 a, order_top (\u03b2 a)] : order_top (lex (\u03a0 a, \u03b2 a)) :=\n{ top := to_lex \u22a4,\n  le_top := \u03bb f, to_lex_monotone le_top }\n\ninstance [linear_order \u03b9] [is_well_order \u03b9 (<)] [\u03a0 a, partial_order (\u03b2 a)]\n  [\u03a0 a, bounded_order (\u03b2 a)] : bounded_order (lex (\u03a0 a, \u03b2 a)) :=\n{ .. pi.lex.order_bot, .. pi.lex.order_top }\n\ninstance [preorder \u03b9] [\u03a0 i, has_lt (\u03b2 i)] [\u03a0 i, densely_ordered (\u03b2 i)] :\n  densely_ordered (lex (\u03a0 i, \u03b2 i)) :=\n\u27e8begin\n  rintro _ _ \u27e8i, h, hi\u27e9,\n  obtain \u27e8a, ha\u2081, ha\u2082\u27e9 := exists_between hi,\n  classical,\n  refine \u27e8a\u2082.update _ a, \u27e8i, \u03bb j hj, _, _\u27e9, i, \u03bb j hj, _, _\u27e9,\n  rw h j hj,\n  iterate 2 { { rw a\u2082.update_noteq hj.ne a }, { rwa a\u2082.update_same i a } },\nend\u27e9\n\nlemma lex.no_max_order' [preorder \u03b9] [\u03a0 i, has_lt (\u03b2 i)] (i : \u03b9) [no_max_order (\u03b2 i)] :\n  no_max_order (lex (\u03a0 i, \u03b2 i)) :=\n\u27e8\u03bb a, begin\n  classical,\n  obtain \u27e8b, hb\u27e9 := exists_gt (a i),\n  exact \u27e8a.update i b, i, \u03bb j hj, (a.update_noteq hj.ne b).symm, by rwa a.update_same i b\u27e9\nend\u27e9\n\ninstance [linear_order \u03b9] [is_well_order \u03b9 (<)] [nonempty \u03b9] [\u03a0 i, partial_order (\u03b2 i)]\n  [\u03a0 i, no_max_order (\u03b2 i)] :\n  no_max_order (lex (\u03a0 i, \u03b2 i)) :=\n\u27e8\u03bb a, let \u27e8b, hb\u27e9 := exists_gt (of_lex a) in \u27e8_, to_lex_strict_mono hb\u27e9\u27e9\n\ninstance [linear_order \u03b9] [is_well_order \u03b9 (<)] [nonempty \u03b9] [\u03a0 i, partial_order (\u03b2 i)]\n  [\u03a0 i, no_min_order (\u03b2 i)] :\n  no_min_order (lex (\u03a0 i, \u03b2 i)) :=\n\u27e8\u03bb a, let \u27e8b, hb\u27e9 := exists_lt (of_lex a) in \u27e8_, to_lex_strict_mono hb\u27e9\u27e9\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 \u03b9] [\u2200 a, ordered_comm_group (\u03b2 a)] :\n  ordered_comm_group (lex (\u03a0 i, \u03b2 i)) :=\n{ mul_le_mul_left := \u03bb x y hxy z,\n    hxy.elim\n      (\u03bb hxyz, hxyz \u25b8 le_rfl)\n      (\u03bb \u27e8i, hi\u27e9,\n        or.inr \u27e8i, \u03bb j hji, show z j * x j = z j * y j, by rw hi.1 j hji,\n          mul_lt_mul_left' hi.2 _\u27e9),\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 {\u03b1} [preorder \u03b9] [decidable_eq \u03b9] [preorder \u03b1] {f : \u03b9 \u2192 \u03b1} {i j : \u03b9}\n  (h\u2081 : i < j) (h\u2082 : f j < f i) :\n  to_lex (f \u2218 equiv.swap i j) < to_lex f :=\n\u27e8i, \u03bb k hik, congr_arg f (equiv.swap_apply_of_ne_of_ne hik.ne (hik.trans h\u2081).ne),\n  by simpa only [pi.to_lex_apply, function.comp_app, equiv.swap_apply_left] using h\u2082\u27e9\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\u00f4pital'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 `\ud835\udcdd a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `\u211d`.\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\u00f4pital's rule, L'Hopital's rule\n-/\n\nopen filter set\nopen_locale filter topology pointwise\n\nvariables {a b : \u211d} (hab : a < b) {l : filter \u211d} {f f' g g' : \u211d \u2192 \u211d}\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' \u2260 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[>] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[>] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  have sub : \u2200 x \u2208 Ioo a b, Ioo a x \u2286 Ioo a b := \u03bb x hx, Ioo_subset_Ioo (le_refl a) (le_of_lt hx.2),\n  have hg : \u2200 x \u2208 (Ioo a b), g x \u2260 0,\n  { intros x hx h,\n    have : tendsto g (\ud835\udcdd[<] x) (\ud835\udcdd 0),\n    { rw [\u2190 h, \u2190 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 \u27e8y, hyx, hy\u27e9 : \u2203 c \u2208 Ioo a x, g' c = 0,\n      from exists_has_deriv_at_eq_zero' hx.1 hga this (\u03bb y hy, hgg' y $ sub x hx hy),\n    exact hg' y (sub x hx hyx) hy },\n  have : \u2200 x \u2208 Ioo a b, \u2203 c \u2208 Ioo a x, (f x) * (g' c) = (g x) * (f' c),\n  { intros x hx,\n    rw [\u2190 sub_zero (f x), \u2190 sub_zero (g x)],\n    exact exists_ratio_has_deriv_at_eq_ratio_slope' g g' hx.1 f f'\n      (\u03bb y hy, hgg' y $ sub x hx hy) (\u03bb 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 : \u2200 x \u2208 Ioo a b, ((\u03bb x', (f' x') / (g' x')) \u2218 c) x = f x / g x,\n  { intros x hx,\n    rcases hc x hx with \u27e8h\u2081, h\u2082\u27e9,\n    field_simp [hg x hx, hg' (c x) ((sub x hx) h\u2081)],\n    simp only [h\u2082],\n    rwa mul_comm },\n  have cmp : \u2200 x \u2208 Ioo a b, a < c x \u2227 c x < x,\n    from \u03bb x hx, (hc x hx).1,\n  rw \u2190 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 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' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  refine lhopital_zero_right_on_Ioo hab hff' hgg' hg' _ _ hdiv,\n  { rw [\u2190 hfa, \u2190 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 [\u2190 hga, \u2190 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfb : tendsto f (\ud835\udcdd[<] b) (\ud835\udcdd 0)) (hgb : tendsto g (\ud835\udcdd[<] b) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[<] b) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[<] b) l :=\nbegin\n  -- Here, we essentially compose by `has_neg.neg`. The following is mostly technical details.\n  have hdnf : \u2200 x \u2208 -Ioo a b, has_deriv_at (f \u2218 has_neg.neg) (f' (-x) * (-1)) x,\n    from \u03bb x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : \u2200 x \u2208 -Ioo a b, has_deriv_at (g \u2218 has_neg.neg) (g' (-x) * (-1)) x,\n    from \u03bb 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 \u2190 preimage_neg_Ioo at hx, exact hx}),\n          rwa [mul_comm, \u2190 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 $ \u03bb 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 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' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfb : f b = 0) (hgb : g b = 0)\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[<] b) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[<] b) l :=\nbegin\n  refine lhopital_zero_left_on_Ioo hab hff' hgg' hg' _ _ hdiv,\n  { rw [\u2190 hfb, \u2190 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 [\u2190 hgb, \u2190 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' : \u2200 x \u2208 Ioi a, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioi a, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioi a, g' x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  obtain \u27e8 a', haa', ha'\u27e9 : \u2203 a', a < a' \u2227 0 < a' :=\n    \u27e81 + max a 0, \u27e8lt_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 _)\u27e9\u27e9,\n  have fact1 : \u2200 (x:\u211d), x \u2208 Ioo 0 a'\u207b\u00b9 \u2192 x \u2260 0 := \u03bb _ hx, (ne_of_lt hx.1).symm,\n  have fact2 : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, a < x\u207b\u00b9,\n    from \u03bb _ hx, lt_trans haa' ((lt_inv ha' hx.1).mpr hx.2),\n  have hdnf : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, has_deriv_at (f \u2218 has_inv.inv) (f' (x\u207b\u00b9) * (-(x^2)\u207b\u00b9)) x,\n    from \u03bb x hx, comp x (hff' (x\u207b\u00b9) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have hdng : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, has_deriv_at (g \u2218 has_inv.inv) (g' (x\u207b\u00b9) * (-(x^2)\u207b\u00b9)) x,\n    from \u03bb x hx, comp x (hgg' (x\u207b\u00b9) $ 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' : \u2200 x \u2208 Iio a, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Iio a, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Iio a, g' x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_bot l) :\n  tendsto (\u03bb 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 : \u2200 x \u2208 -Iio a, has_deriv_at (f \u2218 has_neg.neg) (f' (-x) * (-1)) x,\n    from \u03bb x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : \u2200 x \u2208 -Iio a, has_deriv_at (g \u2218 has_neg.neg) (g' (-x) * (-1)) x,\n    from \u03bb 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 \u2190 preimage_neg_Iio at hx, exact hx}),\n          rwa [mul_comm, \u2190 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 $ \u03bb 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 \u211d f (Ioo a b)) (hg' : \u2200 x \u2208 Ioo a b, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[>] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[>] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioo a b, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : \u2200 x \u2208 Ioo a b, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_right_on_Ioo hab (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb x hx, (hdg x hx).has_deriv_at) hg' hfa hga hdiv\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hdf : differentiable_on \u211d f (Ioo a b))\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : \u2200 x \u2208 (Ioo a b), (deriv g) x \u2260 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  refine lhopital_zero_right_on_Ioo hab hdf hg' _ _ hdiv,\n  { rw [\u2190 hfa, \u2190 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 [\u2190 hga, \u2190 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 \u211d f (Ioo a b))\n  (hg' : \u2200 x \u2208 (Ioo a b), (deriv g) x \u2260 0)\n  (hfb : tendsto f (\ud835\udcdd[<] b) (\ud835\udcdd 0)) (hgb : tendsto g (\ud835\udcdd[<] b) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[<] b) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[<] b) l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioo a b, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : \u2200 x \u2208 Ioo a b, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_left_on_Ioo hab (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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 \u211d f (Ioi a))\n  (hg' : \u2200 x \u2208 (Ioi a), (deriv g) x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioi a, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioi_mem_nhds hx),\n  have hdg : \u2200 x \u2208 Ioi a, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_top_on_Ioi (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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 \u211d f (Iio a))\n  (hg' : \u2200 x \u2208 (Iio a), (deriv g) x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdf : \u2200 x \u2208 Iio a, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Iio_mem_nhds hx),\n  have hdg : \u2200 x \u2208 Iio a, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_bot_on_Iio (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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\u00f4pital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right\n  (hff' : \u2200\u1da0 x in \ud835\udcdd[>] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[>] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[>] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[>] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[>] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 \ud835\udcdd[>] a := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_nhds_within_Ioi_iff_exists_Ioo_subset at hs,\n  rcases hs with \u27e8u, hau, hu\u27e9,\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\u00f4pital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left\n  (hff' : \u2200\u1da0 x in \ud835\udcdd[<] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[<] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[<] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[<] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[<] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[<] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[<] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 \ud835\udcdd[<] a := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_nhds_within_Iio_iff_exists_Ioo_subset at hs,\n  rcases hs with \u27e8l, hal, hl\u27e9,\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\u00f4pital'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' : \u2200\u1da0 x in \ud835\udcdd[\u2260] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[\u2260] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[\u2260] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[\u2260] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[\u2260] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[\u2260] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[\u2260] a) l :=\nbegin\n  simp only [\u2190Iio_union_Ioi, nhds_within_union, tendsto_sup, eventually_sup] at *,\n  exact \u27e8lhopital_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\u27e9\nend\n\n/-- **L'H\u00f4pital's rule** for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds\n  (hff' : \u2200\u1da0 x in \ud835\udcdd a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, f' x / g' x) (\ud835\udcdd a) l) :\n  tendsto (\u03bb x, f x / g x) (\ud835\udcdd[\u2260] 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\u00f4pital's rule for approaching +\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top\n  (hff' : \u2200\u1da0 x in at_top, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in at_top, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in at_top, g' x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 at_top := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_at_top_sets at hs,\n  rcases hs with \u27e8l, hl\u27e9,\n  have hl' : Ioi l \u2286 s := \u03bb x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_top_on_Ioi _ _ (\u03bb 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\u00f4pital's rule for approaching -\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot\n  (hff' : \u2200\u1da0 x in at_bot, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in at_bot, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in at_bot, g' x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 at_bot := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_at_bot_sets at hs,\n  rcases hs with \u27e8l, hl\u27e9,\n  have hl' : Iio l \u2286 s := \u03bb x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_bot_on_Iio _ _ (\u03bb 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\u00f4pital's rule** for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right\n  (hdf : \u2200\u1da0 x in \ud835\udcdd[>] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[>] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[>] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[>] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  have hdg : \u2200\u1da0 x in \ud835\udcdd[>] a, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in \ud835\udcdd[>] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in \ud835\udcdd[>] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital's rule** for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left\n  (hdf : \u2200\u1da0 x in \ud835\udcdd[<] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[<] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[<] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[<] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[<] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[<] a) l :=\nbegin\n  have hdg : \u2200\u1da0 x in \ud835\udcdd[<] a, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in \ud835\udcdd[<] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in \ud835\udcdd[<] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital'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 : \u2200\u1da0 x in \ud835\udcdd[\u2260] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[\u2260] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[\u2260] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[\u2260] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[\u2260] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[\u2260] a) l :=\nbegin\n  simp only [\u2190Iio_union_Ioi, nhds_within_union, tendsto_sup, eventually_sup] at *,\n  exact \u27e8lhopital_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\u27e9,\nend\n\n/-- **L'H\u00f4pital's rule** for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds\n  (hdf : \u2200\u1da0 x in \ud835\udcdd a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[\u2260] 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\u00f4pital's rule** for approaching +\u221e, `deriv` version -/\ntheorem lhopital_zero_at_top\n  (hdf : \u2200\u1da0 (x : \u211d) in at_top, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 (x : \u211d) in at_top, deriv g x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  have hdg : \u2200\u1da0 x in at_top, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in at_top, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in at_top, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital's rule** for approaching -\u221e, `deriv` version -/\ntheorem lhopital_zero_at_bot\n  (hdf : \u2200\u1da0 (x : \u211d) in at_bot, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 (x : \u211d) in at_bot, deriv g x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdg : \u2200\u1da0 x in at_bot, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in at_bot, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in at_bot, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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": "import evaluation\nimport backends.bfs.baseline\n\n\nimport all\nopen baseline\n\nexample {p q : Prop} (h\u2081 : p) (h\u2082 : q) : p \u2227 q :=\nbegin\n tidy\nend\n\nuniverse u\nexample {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : list \u03b1) :\n  list.partition p l = (list.filter p l, list.filter (not \u2218 p) l) :=\nbegin\n  simp at *\nend\n\n-- example : \u2200 (b : bool) (n : \u2115), (nat.bit b n).bodd = b :=\n-- begin\n--   -- simp at *\n--   tidy_bfs_proof_search 25 tt 1\n-- end\n\n\n", "meta": {"author": "jesse-michael-han", "repo": "lean-tpe-public", "sha": "87c7bb8dfb8271d8fcf917aae0e731600c4f4c6c", "save_path": "github-repos/lean/jesse-michael-han-lean-tpe-public", "path": "github-repos/lean/jesse-michael-han-lean-tpe-public/lean-tpe-public-87c7bb8dfb8271d8fcf917aae0e731600c4f4c6c/src/tests/test_bfs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.6548947223065754, "lm_q1q2_score": 0.4886424886429816}}
{"text": "-- Introducci\u00f3n del condicional en Lean\n-- ====================================\n\n-- ----------------------------------------------------\n-- Ej. 1. (p. 9) Demostrar que\n--    P \u2192 P\n-- ----------------------------------------------------\n\nimport tactic\nvariable (P : Prop)\n\n-- 1\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nassume h : P,\nshow P, from h\n\n-- 2\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nassume : P,\nshow P, from this\n\n-- 3\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nassume : P,\nshow P, from \u2039P\u203a\n\n-- 4\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nassume h : P, h\n\n-- 5\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\n\u03bb h, h\n\n-- 6\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\n-- by library_search\nid\n\n-- 7\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nbegin\n  intro h,\n  exact h,\nend\n\n-- 8\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nbegin\n  intro,\n  exact \u2039P\u203a,\nend\n\n-- 9\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nbegin\n  intro h,\n  assumption,\nend\n\n-- 10\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nbegin\n  intro,\n  assumption,\nend\n\n-- 11\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\n-- by hint\nby tauto\n\n-- 12\u00aa demostraci\u00f3n\nexample : P \u2192 P :=\nby finish\n\n-- 13\u00aa demostraci\u00f3n\nexample : P \u2192 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  {\u03a9:Type*} {P:probability_space \u03a9} {A:event P} {f : \u2115 \u2192 event P}:\n                           (\u2200 (i:\u2115), (f i.succ).val \u2286 (f i).val) \u2192  \n   (\u2200 (i:\u2115), independent_event_pair A (f i)) \u2192\n   (independent_event_pair A (\u2200\u1d63 i, f i)) := begin\n  intros h1 h2,\n  unfold independent_event_pair,\n  rw Pr_forall_eq_infi h1,\n  have h3:(A\u2227\u2200\u1d63 (i : \u2115), f i) = (\u2200\u1d63 (i : \u2115), A \u2227 f i),\n  { apply event.eq, simp, ext \u03c9, 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:(\u03bb i, Pr[A \u2227 (f i)]) = (\u03bb 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  {\u03a9:Type*} {P:probability_space \u03a9} {A:event P} {f : \u2115 \u2192 event P}:\n                           monotone (\u03bb (i:\u2115), (f i).val) \u2192  \n   (\u2200 (i:\u2115), independent_event_pair A (f i)) \u2192\n   (independent_event_pair A (\u2203\u1d63 i, f i)) := begin\n  intros h1 h2,\n  unfold independent_event_pair,\n  rw Pr_exists_eq_supr h1,\n  have h3:(A\u2227\u2203\u1d63 (i : \u2115), f i) = (\u2203\u1d63 (i : \u2115), A \u2227 f i),\n  { apply event.eq, simp, ext \u03c9, 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:(\u03bb i, Pr[A \u2227 (f i)]) = (\u03bb 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 {\u03a9 \u03b1\u2081 \u03b1\u2082:Type*} (s\u2081: set (set \u03b1\u2081)) (s\u2082:set (set \u03b1\u2082))\n  (A\u2081:s\u2081.is_algebra) (A\u2082:s\u2082.is_algebra)\n  {P:probability_space \u03a9}\n  {X\u2081:P \u2192\u1d63 (measurable_space.generate_from s\u2081)}\n  {X\u2082:P \u2192\u1d63 (measurable_space.generate_from s\u2082)}:\n  (\u2200 (T\u2081:measurable_setB (measurable_space.generate_from s\u2081))\n     (T\u2082:measurable_setB (measurable_space.generate_from s\u2082)),\n     T\u2081.val \u2208 s\u2081 \u2192 T\u2082.val \u2208 s\u2082 \n     \u2192 independent_event_pair (X\u2081 \u2208\u1d63 T\u2081) (X\u2082 \u2208\u1d63 T\u2082)) \u2192 \n  random_variable_independent_pair X\u2081 X\u2082 := begin\n  intros h1 U\u2081,\n  cases U\u2081,\n  have AM\u2081 := A\u2081.monotone_class,\n  have AM\u2082 := A\u2082.monotone_class,\n\n  have h_meas\u2081:\u2200 {T':set \u03b1\u2081}, s\u2081.monotone_class T' \u2192\n          (measurable_space.generate_from s\u2081).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\u2081 },\n  have h_meas\u2082:\u2200 {T':set \u03b1\u2082}, s\u2082.monotone_class T' \u2192\n          (measurable_space.generate_from s\u2082).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\u2082 },\n  have h_mono_1:s\u2081.monotone_class U\u2081_val,\n  { rw measurable_space.generate_from_monotone_class,\n    simp [measurable_space.generate_from] at U\u2081_property,\n    apply U\u2081_property, apply A\u2081 },\n  induction h_mono_1 with U\u2081' h_U\u2081' f\u2081 h_rec\u2081 h_mono\u2081 h_ind\u2081 f\u2081 h_rec\u2081 h_mono\u2081 h_ind\u2081,\n  -- The base case for U\u2081, solved by induction on U\u2082.\n  intros U\u2082, cases U\u2082, \n  have h_mono_2:s\u2082.monotone_class U\u2082_val,\n  { rw measurable_space.generate_from_monotone_class,\n    simp [measurable_space.generate_from] at U\u2082_property,\n    apply U\u2082_property, apply A\u2082 },\n  induction h_mono_2 with U\u2082' h_U\u2082' f\u2082 h_rec\u2082 h_mono\u2082 h_ind\u2082 f\u2082 h_rec\u2082 h_mono\u2082 h_ind\u2082,\n  -- The base base case.\n  { apply h1, apply h_U\u2081', apply h_U\u2082' },\n  { have h_Inter:(X\u2082 \u2208\u1d63 \u27e8set.Inter f\u2082, U\u2082_property\u27e9)\n                 = (\u2200\u1d63 i, (X\u2082 \u2208\u1d63 \u27e8f\u2082 i, h_meas\u2082 (h_rec\u2082 i)\u27e9)), \n    { apply event.eq, ext1 \u03c9, 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\u2082 i,\n      simp, intros \u03c9, apply h_mono_i },\n    { intros i, have h_ind_i := h_ind\u2082 i,\n      apply h_ind_i } },\n  { have h_Union: (X\u2082 \u2208\u1d63 \u27e8set.Union f\u2082, U\u2082_property\u27e9)\n                  = (\u2203\u1d63 i, (X\u2082 \u2208\u1d63 \u27e8f\u2082 i, h_meas\u2082 (h_rec\u2082 i)\u27e9)),\n    { apply event.eq, ext1 \u03c9, 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\u2082 h_le,\n      simp, intros \u03c9, apply h_mono_i },\n    { intros i, have h_ind_i := h_ind\u2082 i,\n      apply h_ind_i } },\n  -- The base case of T\u2081 is resolved. Now we continue...     \n  { intros T\u2081, apply independent_event_pair.symm,\n    have h_Inter:(X\u2081 \u2208\u1d63 \u27e8set.Inter f\u2081, U\u2081_property\u27e9)\n                 = (\u2200\u1d63 i, (X\u2081 \u2208\u1d63 \u27e8f\u2081 i, h_meas\u2081 (h_rec\u2081 i)\u27e9)), \n    { apply event.eq, ext1 \u03c9, 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\u2081 i,\n      simp, intros \u03c9, apply h_mono_i },\n    { intros i, apply independent_event_pair.symm,\n      have h_ind_i := h_ind\u2081 i,\n      apply h_ind_i } },  \n  { intros T\u2081, apply independent_event_pair.symm,\n    have h_Union: (X\u2081 \u2208\u1d63 \u27e8set.Union f\u2081, U\u2081_property\u27e9)\n                  = (\u2203\u1d63 i, (X\u2081 \u2208\u1d63 \u27e8f\u2081 i, h_meas\u2081 (h_rec\u2081 i)\u27e9)),\n    { apply event.eq, ext1 \u03c9, 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\u2081 h_le,\n      simp, intros \u03c9, apply h_mono_i },\n    { intros i, apply independent_event_pair.symm,\n      have h_ind_i := h_ind\u2081 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' {\u03a9 \u03b1\u2081 \u03b1\u2082:Type*} (s\u2081: set (set \u03b1\u2081)) (s\u2082:set (set \u03b1\u2082))\n  (A\u2081:s\u2081.is_algebra) (A\u2082:s\u2082.is_algebra)\n  (M\u2081:measurable_space \u03b1\u2081)\n  (M\u2082:measurable_space \u03b1\u2082)\n  {P:probability_space \u03a9}\n  {X\u2081:P \u2192\u1d63 M\u2081}\n  {X\u2082:P \u2192\u1d63 M\u2082}:\n  (M\u2081 = measurable_space.generate_from s\u2081) \u2192\n  (M\u2082 = measurable_space.generate_from s\u2082) \u2192\n  (\u2200 (T\u2081:measurable_setB M\u2081)\n     (T\u2082:measurable_setB M\u2082),\n     T\u2081.val \u2208 s\u2081 \u2192 T\u2082.val \u2208 s\u2082 \n     \u2192 independent_event_pair (X\u2081 \u2208\u1d63 T\u2081) (X\u2082 \u2208\u1d63 T\u2082)) \u2192 \n  random_variable_independent_pair X\u2081 X\u2082 := begin\n  intros h1 h2 h3 T\u2081 T\u2082,\n  tactic.unfreeze_local_instances,\n  subst M\u2081,\n  subst M\u2082,\n  apply random_variable_independent_pair_on_algebra,\n  apply A\u2081,\n  apply A\u2082,\n  apply h3,\nend\n\nlemma measurable_space.generate_from_disjoint_union_closure {\u03b1:Type*}\n  {s:set (set \u03b1)}:\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 {\u03a9 \u03b1\u2081 \u03b1\u2082:Type*} (s\u2081: set (set \u03b1\u2081)) \n  (s\u2082:set (set \u03b1\u2082))\n  (A\u2081:s\u2081.is_semialgebra) (A\u2082:s\u2082.is_semialgebra)\n  {P:probability_space \u03a9}\n  {X\u2081:P \u2192\u1d63 (measurable_space.generate_from s\u2081)}\n  {X\u2082:P \u2192\u1d63 (measurable_space.generate_from s\u2082)}:\n  (\u2200 (T\u2081:measurable_setB (measurable_space.generate_from s\u2081))\n     (T\u2082:measurable_setB (measurable_space.generate_from s\u2082)),\n     T\u2081.val \u2208 s\u2081 \u2192 T\u2082.val \u2208 s\u2082 \n     \u2192 independent_event_pair (X\u2081 \u2208\u1d63 T\u2081) (X\u2082 \u2208\u1d63 T\u2082)) \u2192 \n  random_variable_independent_pair X\u2081 X\u2082 := begin\n  intros h1,\n  have CA\u2081 := A\u2081.disjoint_union_closure,\n  have CA\u2082 := A\u2082.disjoint_union_closure,\n  apply random_variable_independent_pair_on_algebra' (s\u2081.disjoint_union_closure)\n    (s\u2082.disjoint_union_closure) (A\u2081.disjoint_union_closure) (A\u2082.disjoint_union_closure),\n  apply measurable_space.generate_from_disjoint_union_closure,\n  apply measurable_space.generate_from_disjoint_union_closure,\n  intros T\u2081 T\u2082 h_T\u2081 h_T\u2082,\n  rw set.mem_disjoint_union_closure_iff at h_T\u2081,\n  cases h_T\u2081 with m\u2081 h_T\u2081,\n  cases h_T\u2081 with f\u2081 h_T\u2081,\n  cases h_T\u2081 with h_f\u2081_in_s h_T\u2081,\n  cases h_T\u2081 with h_pairwise\u2081 h_def\u2081,\n  rw set.mem_disjoint_union_closure_iff at h_T\u2082,\n  cases h_T\u2082 with m\u2082 h_T\u2082,\n  cases h_T\u2082 with f\u2082 h_T\u2082,\n  cases h_T\u2082 with h_f\u2082_in_s h_T\u2082,\n  cases h_T\u2082 with h_pairwise\u2082 h_def\u2082,\n  cases T\u2081,\n  cases T\u2082,\n  simp at h_def\u2081,\n  simp at h_def\u2082,\n  subst T\u2081_val,\n  subst T\u2082_val,\n  have h_meas\u2081:\u2200 (i:fin m\u2081), (measurable_space.generate_from s\u2081).measurable_set' (f\u2081 i),\n  { intros i, apply measurable_space.measurable_set_generate_from, apply h_f\u2081_in_s },\n  have h_meas\u2082:\u2200 (i:fin m\u2082), (measurable_space.generate_from s\u2082).measurable_set' (f\u2082 i),\n  { intros i, apply measurable_space.measurable_set_generate_from, apply h_f\u2082_in_s },\n  have h_union1: (X\u2081 \u2208\u1d63 \u27e8set.Union f\u2081, T\u2081_property\u27e9) = (\u2203\u1d63 i, X\u2081 \u2208\u1d63 \u27e8f\u2081 i, h_meas\u2081 i\u27e9),\n  { apply event.eq, ext \u03c9, split; intros h_union1_1; simp at h_union1_1; simp [h_union1_1] },\n  have h_union2: (X\u2082 \u2208\u1d63 \u27e8set.Union f\u2082, T\u2082_property\u27e9) = (\u2203\u1d63 i, X\u2082 \u2208\u1d63 \u27e8f\u2082 i, h_meas\u2082 i\u27e9),\n  { apply event.eq, ext \u03c9, 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\u2081_in_s },\n  { simp, apply h_f\u2082_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\u2081 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 \u2190 set.subset_empty_iff, rw set.subset_def,\n    intros \u03c9 h_\u03c9, simp at h_\u03c9, rw \u2190 set.subset_empty_iff at h_pairwise_ij, rw set.subset_def\n    at h_pairwise_ij, have h_X := h_pairwise_ij (X\u2081.val \u03c9), simp at h_X, exfalso, apply h_X,\n    simp [h_\u03c9], simp [h_\u03c9] },\n  { intros i h_i_univ j h_j_univ h_ne, simp [function.on_fun],\n    have h_pairwise_ij := h_pairwise\u2082 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 \u2190 set.subset_empty_iff, rw set.subset_def,\n    intros \u03c9 h_\u03c9, simp at h_\u03c9, rw \u2190 set.subset_empty_iff at h_pairwise_ij, rw set.subset_def\n    at h_pairwise_ij, have h_X := h_pairwise_ij (X\u2082.val \u03c9), simp at h_X, exfalso, apply h_X,\n    simp [h_\u03c9], simp [h_\u03c9] },\nend\n\n\nlemma random_variable_independent_pair_on_semialgebra' {\u03a9 \u03b1\u2081 \u03b1\u2082:Type*} (s\u2081: set (set \u03b1\u2081)) \n  (s\u2082:set (set \u03b1\u2082))\n  (A\u2081:s\u2081.is_semialgebra) (A\u2082:s\u2082.is_semialgebra)\n  (M\u2081:measurable_space \u03b1\u2081)\n  (M\u2082:measurable_space \u03b1\u2082)\n  {P:probability_space \u03a9}\n  {X\u2081:P \u2192\u1d63 M\u2081}\n  {X\u2082:P \u2192\u1d63 M\u2082}:\n  (M\u2081 = measurable_space.generate_from s\u2081) \u2192\n  (M\u2082 = measurable_space.generate_from s\u2082) \u2192\n  (\u2200 (T\u2081:measurable_setB M\u2081)\n     (T\u2082:measurable_setB M\u2082),\n     T\u2081.val \u2208 s\u2081 \u2192 T\u2082.val \u2208 s\u2082 \n     \u2192 independent_event_pair (X\u2081 \u2208\u1d63 T\u2081) (X\u2082 \u2208\u1d63 T\u2082)) \u2192 \n  random_variable_independent_pair X\u2081 X\u2082 := begin\n  intros h1 h2 h3 T\u2081 T\u2082,\n  tactic.unfreeze_local_instances,\n  subst M\u2081,\n  subst M\u2082,\n  apply random_variable_independent_pair_on_semialgebra,\n  apply A\u2081,\n  apply A\u2082,\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 \u03b1 \u03b2 : Type*}\n\nnamespace prod\n\nsection\n\nvariables [has_scalar M \u03b1] [has_scalar M \u03b2] [has_scalar N \u03b1] [has_scalar N \u03b2] (a : M) (x : \u03b1 \u00d7 \u03b2)\n\n@[to_additive prod.has_vadd] instance : has_scalar M (\u03b1 \u00d7 \u03b2) := \u27e8\u03bba p, (a \u2022 p.1, a \u2022 p.2)\u27e9\n\n@[simp, to_additive] theorem smul_fst : (a \u2022 x).1 = a \u2022 x.1 := rfl\n@[simp, to_additive] theorem smul_snd : (a \u2022 x).2 = a \u2022 x.2 := rfl\n@[simp, to_additive] theorem smul_mk (a : M) (b : \u03b1) (c : \u03b2) : a \u2022 (b, c) = (a \u2022 b, a \u2022 c) := rfl\n\ninstance [has_scalar M N] [is_scalar_tower M N \u03b1] [is_scalar_tower M N \u03b2] :\n  is_scalar_tower M N (\u03b1 \u00d7 \u03b2) :=\n\u27e8\u03bb x y z, mk.inj_iff.mpr \u27e8smul_assoc _ _ _, smul_assoc _ _ _\u27e9\u27e9\n\n@[to_additive] instance [smul_comm_class M N \u03b1] [smul_comm_class M N \u03b2] :\n  smul_comm_class M N (\u03b1 \u00d7 \u03b2) :=\n{ smul_comm := \u03bb r s x, mk.inj_iff.mpr \u27e8smul_comm _ _ _, smul_comm _ _ _\u27e9 }\n\nend\n\n@[to_additive] instance {m : monoid M} [mul_action M \u03b1] [mul_action M \u03b2] : mul_action M (\u03b1 \u00d7 \u03b2) :=\n{ mul_smul  := \u03bb a\u2081 a\u2082 p, mk.inj_iff.mpr \u27e8mul_smul _ _ _, mul_smul _ _ _\u27e9,\n  one_smul  := \u03bb \u27e8b, c\u27e9, mk.inj_iff.mpr \u27e8one_smul _ _, one_smul _ _\u27e9 }\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 \u00d7 N) :=\n{ smul_add  := \u03bb a p\u2081 p\u2082, mk.inj_iff.mpr \u27e8smul_add _ _ _, smul_add _ _ _\u27e9,\n  smul_zero := \u03bb a, mk.inj_iff.mpr \u27e8smul_zero _, smul_zero _\u27e9 }\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} \u2192 a < b \u2192 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 \u03b1 \u03b2} [Monad m] (as : Array \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) : m \u03b2 := do\nlet rec loop : (i : Nat) \u2192 i \u2264 as.size \u2192 \u03b2 \u2192 m \u03b2\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 \u2190 f (as.get \u27e8as.size - 1 - i, this\u27e9) 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 $ \u00b7 + \u00b7)\n\ntheorem ex : (Id.run $ fold #[1, 2, 3, 4] 0 (pure $ \u00b7 + \u00b7)) = 10 :=\nrfl\n\ndef fold2 {m \u03b1 \u03b2} [Monad m] (as : Array \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) : m \u03b2 :=\nlet rec loop (i : Nat) (h : i \u2264 as.size) (b : \u03b2) : m \u03b2 := 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 \u2190 f (as.get \u27e8as.size - 1 - i, this\u27e9) 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 \u2190 ref.get\nIO.println x\nreturn x + 1\n\ndef fTest : IO Unit := do\nunless (\u2190 f 0 (\u2190 IO.mkRef 10)) == 11 do throw $ IO.userError \"unexpected\"\nunless (\u2190 f 1 (\u2190 IO.mkRef 10)) == 2 do throw $ IO.userError \"unexpected\"\n\ndef g (x y : Nat) (ref : IO.Ref (Nat \u00d7 Nat)) : IO (Nat \u00d7 Nat) := do\n  let mut (x, y) := (x, y)\n  if x == 0 then\n    (x, y) \u2190 ref.get\n  IO.println (\"x: \" ++ toString x ++ \", y: \" ++ toString y)\n  return (x, y)\n\ndef gTest : IO Unit := do\nunless (\u2190 g 2 1 (\u2190 IO.mkRef (10, 20))) == (2, 1)   do throw $ IO.userError \"unexpected\"\nunless (\u2190 g 0 1 (\u2190 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 \"\u2190\" reverses the direction.\n-/\nprivate meta def rws_parser : lean.parser (pexpr \u00d7 bool) :=\ndo flipped \u2190 optional $ tk \"\u2190\",\n   pexp \u2190 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 \u2190 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 \u2190 collect_rules,\n  explicit_rules \u2190 (rs.get_or_else []).mmap (\u03bb \u27e8pe, dir\u27e9, do e \u2190 to_expr' pe, return (e, dir)),\n  let rules := implicit_rules ++ explicit_rules,\n  g \u2190 mk_graph cfg rules t,\n  (_, proof, steps) \u2190 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, `\u2205` is bounded). In the literature the\ncobounded filter is generally referred to as the *filter at infinity*.\n\n## Main definitions\n\n- `bornology \u03b1`: a class consisting of `cobounded : filter \u03b1` 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 \u03b1` filter. For\n  `s : set \u03b1`, one should prefer `bornology.is_cobounded s` over `s \u2208 cobounded \u03b1`.\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\u1d9c \u2208 cobounded \u03b1`.\n- `bounded_space \u03b1`: a class extending `bornology \u03b1` with the condition\n  `bornology.is_bounded (set.univ : set \u03b1)`\n\nAlthough use of `cobounded \u03b1` is discouraged for indicating the (co)boundedness of individual sets,\nit is intended for regular use as a filter on `\u03b1`.\n-/\n\n\nopen Set Filter\n\nvariable {\u03b9 \u03b1 \u03b2 : 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 `\u03b1` 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 (\u03b1 : Type _) where\n  cobounded : Filter \u03b1\n  le_cofinite : cobounded \u2264 cofinite\n#align bornology Bornology\n-/\n\n/- warning: bornology.of_bounded -> Bornology.ofBounded is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} (B : Set.{u1} (Set.{u1} \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.hasEmptyc.{u1} \u03b1)) B) -> (forall (s\u2081 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s\u2082 s\u2081) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2082 B))) -> (forall (s\u2081 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2082 B) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s\u2081 s\u2082) B))) -> (forall (x : \u03b1), Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (Singleton.singleton.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasSingleton.{u1} \u03b1) x) B) -> (Bornology.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (B : Set.{u1} (Set.{u1} \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.instEmptyCollectionSet.{u1} \u03b1)) B) -> (forall (s\u2081 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s\u2082 s\u2081) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2082 B))) -> (forall (s\u2081 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2082 B) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s\u2081 s\u2082) B))) -> (forall (x : \u03b1), Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (Singleton.singleton.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instSingletonSet.{u1} \u03b1) x) B) -> (Bornology.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align bornology.of_bounded Bornology.ofBounded\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (s\u2081 s\u2082 \u00abexpr \u2208 \u00bb B) -/\n/-- A constructor for bornologies by specifying the bounded sets,\nand showing that they satisfy the appropriate conditions. -/\n@[simps]\ndef Bornology.ofBounded {\u03b1 : Type _} (B : Set (Set \u03b1)) (empty_mem : \u2205 \u2208 B)\n    (subset_mem : \u2200 s\u2081 \u2208 B, \u2200 s\u2082 : Set \u03b1, s\u2082 \u2286 s\u2081 \u2192 s\u2082 \u2208 B)\n    (union_mem : \u2200 (s\u2081) (_ : s\u2081 \u2208 B) (s\u2082) (_ : s\u2082 \u2208 B), s\u2081 \u222a s\u2082 \u2208 B)\n    (singleton_mem : \u2200 x, {x} \u2208 B) : Bornology \u03b1\n    where\n  cobounded :=\n    { sets := { s : Set \u03b1 | s\u1d9c \u2208 B }\n      univ_sets := by rwa [\u2190 compl_univ] at empty_mem\n      sets_of_superset := fun x y hx hy => subset_mem (x\u1d9c) hx (y\u1d9c) (compl_subset_compl.mpr hy)\n      inter_sets := fun x y hx hy => by simpa [compl_inter] using union_mem (x\u1d9c) hx (y\u1d9c) hy }\n  le_cofinite := by\n    rw [le_cofinite_iff_compl_singleton_mem]\n    intro x\n    change {x}\u1d9c\u1d9c \u2208 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 {\u03b1 : Type.{u1}} (B : Set.{u1} (Set.{u1} \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.hasEmptyc.{u1} \u03b1)) B) -> (forall (s\u2081 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s\u2082 s\u2081) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2082 B))) -> (forall (s\u2081 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2082 B) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s\u2081 s\u2082) B))) -> (Eq.{succ u1} (Set.{u1} \u03b1) (Set.union\u209b.{u1} \u03b1 B) (Set.univ.{u1} \u03b1)) -> (Bornology.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (B : Set.{u1} (Set.{u1} \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.instEmptyCollectionSet.{u1} \u03b1)) B) -> (forall (s\u2081 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s\u2082 s\u2081) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2082 B))) -> (forall (s\u2081 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2082 B) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s\u2081 s\u2082) B))) -> (Eq.{succ u1} (Set.{u1} \u03b1) (Set.union\u209b.{u1} \u03b1 B) (Set.univ.{u1} \u03b1)) -> (Bornology.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align bornology.of_bounded' Bornology.ofBounded'\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (s\u2081 s\u2082 \u00abexpr \u2208 \u00bb B) -/\n/-- A constructor for bornologies by specifying the bounded sets,\nand showing that they satisfy the appropriate conditions. -/\n@[simps]\ndef Bornology.ofBounded' {\u03b1 : Type _} (B : Set (Set \u03b1)) (empty_mem : \u2205 \u2208 B)\n    (subset_mem : \u2200 s\u2081 \u2208 B, \u2200 s\u2082 : Set \u03b1, s\u2082 \u2286 s\u2081 \u2192 s\u2082 \u2208 B)\n    (union_mem : \u2200 (s\u2081) (_ : s\u2081 \u2208 B) (s\u2082) (_ : s\u2082 \u2208 B), s\u2081 \u222a s\u2082 \u2208 B) (sUnion_univ : \u22c3\u2080 B = univ) :\n    Bornology \u03b1 :=\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 \u27e8s, hs, hxs\u27e9\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 \u03b1] {s t : Set \u03b1} {x : \u03b1}\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 `\u03b1` -/\ndef IsCobounded (s : Set \u03b1) : Prop :=\n  s \u2208 cobounded \u03b1\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 `\u03b1`. -/\ndef IsBounded (s : Set \u03b1) : Prop :=\n  IsCobounded (s\u1d9c)\n#align bornology.is_bounded Bornology.IsBounded\n-/\n\n#print Bornology.isCobounded_def /-\ntheorem isCobounded_def {s : Set \u03b1} : IsCobounded s \u2194 s \u2208 cobounded \u03b1 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) (Bornology.cobounded.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) (Bornology.cobounded.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_def Bornology.isBounded_def\u2093'. -/\ntheorem isBounded_def {s : Set \u03b1} : IsBounded s \u2194 s\u1d9c \u2208 cobounded \u03b1 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s)) (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s)) (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_compl_iff Bornology.isBounded_compl_iff\u2093'. -/\n@[simp]\ntheorem isBounded_compl_iff : IsBounded (s\u1d9c) \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s)) (Bornology.IsBounded.{u1} \u03b1 _inst_1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s)) (Bornology.IsBounded.{u1} \u03b1 _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_compl_iff Bornology.isCobounded_compl_iff\u2093'. -/\n@[simp]\ntheorem isCobounded_compl_iff : IsCobounded (s\u1d9c) \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, (Bornology.IsBounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s)) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, (Bornology.IsBounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s)) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded.of_compl Bornology.IsBounded.of_compl\u2093'. -/\n/- warning: bornology.is_cobounded.compl -> Bornology.IsCobounded.compl is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded.compl Bornology.IsCobounded.compl\u2093'. -/\nalias is_bounded_compl_iff \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s)) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s)) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 s)\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded.of_compl Bornology.IsCobounded.of_compl\u2093'. -/\n/- warning: bornology.is_bounded.compl -> Bornology.IsBounded.compl is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1}, (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded.compl Bornology.IsBounded.compl\u2093'. -/\nalias is_cobounded_compl_iff \u2194 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 (\u2205 : Set \u03b1) :=\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 \u03b1) :=\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 \u03b1) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, Iff (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) s t)) (And (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s) (Bornology.IsCobounded.{u1} \u03b1 _inst_1 t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, Iff (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.instInterSet.{u1} \u03b1) s t)) (And (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s) (Bornology.IsCobounded.{u1} \u03b1 _inst_1 t))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_inter Bornology.isCobounded_inter\u2093'. -/\n@[simp]\ntheorem isCobounded_inter : IsCobounded (s \u2229 t) \u2194 IsCobounded s \u2227 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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 t) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, (Bornology.IsCobounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 t) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.instInterSet.{u1} \u03b1) s t))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded.inter Bornology.IsCobounded.inter\u2093'. -/\ntheorem IsCobounded.inter (hs : IsCobounded s) (ht : IsCobounded t) : IsCobounded (s \u2229 t) :=\n  isCobounded_inter.2 \u27e8hs, ht\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s t)) (And (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) (Bornology.IsBounded.{u1} \u03b1 _inst_1 t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s t)) (And (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) (Bornology.IsBounded.{u1} \u03b1 _inst_1 t))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_union Bornology.isBounded_union\u2093'. -/\n@[simp]\ntheorem isBounded_union : IsBounded (s \u222a t) \u2194 IsBounded s \u2227 IsBounded t := by\n  simp only [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 t) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 t) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s t))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded.union Bornology.IsBounded.union\u2093'. -/\ntheorem IsBounded.union (hs : IsBounded s) (ht : IsBounded t) : IsBounded (s \u222a t) :=\n  isBounded_union.2 \u27e8hs, ht\u27e9\n#align bornology.is_bounded.union Bornology.IsBounded.union\n\n#print Bornology.IsCobounded.superset /-\ntheorem IsCobounded.superset (hs : IsCobounded s) (ht : s \u2286 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 \u2286 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\u209b_bounded_univ /-\n@[simp]\ntheorem union\u209b_bounded_univ : \u22c3\u2080 { s : Set \u03b1 | IsBounded s } = univ :=\n  union\u209b_eq_univ_iff.2 fun a => \u27e8{a}, isBounded_singleton, mem_singleton a\u27e9\n#align bornology.sUnion_bounded_univ Bornology.union\u209b_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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Bornology.{u1} \u03b1] [_inst_2 : Bornology.{u2} \u03b2] {f : \u03b1 -> \u03b2}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) (Filter.comap.{u1, u2} \u03b1 \u03b2 f (Bornology.cobounded.{u2} \u03b2 _inst_2)) (Bornology.cobounded.{u1} \u03b1 _inst_1)) (forall {{s : Set.{u1} \u03b1}}, (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsBounded.{u2} \u03b2 _inst_2 (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Bornology.{u1} \u03b1] [_inst_2 : Bornology.{u2} \u03b2] {f : \u03b1 -> \u03b2}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Filter.comap.{u1, u2} \u03b1 \u03b2 f (Bornology.cobounded.{u2} \u03b2 _inst_2)) (Bornology.cobounded.{u1} \u03b1 _inst_1)) (forall {{s : Set.{u1} \u03b1}}, (Bornology.IsBounded.{u1} \u03b1 _inst_1 s) -> (Bornology.IsBounded.{u2} \u03b2 _inst_2 (Set.image.{u1, u2} \u03b1 \u03b2 f s)))\nCase conversion may be inaccurate. Consider using '#align bornology.comap_cobounded_le_iff Bornology.comap_cobounded_le_iff\u2093'. -/\ntheorem comap_cobounded_le_iff [Bornology \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    (cobounded \u03b2).comap f \u2264 cobounded \u03b1 \u2194 \u2200 \u2983s\u2984, IsBounded s \u2192 IsBounded (f '' s) :=\n  by\n  refine'\n    \u27e8fun h s hs => _, fun h t ht =>\n      \u27e8(f '' t\u1d9c)\u1d9c, h <| is_cobounded.compl ht, compl_subset_comm.1 <| subset_preimage_image _ _\u27e9\u27e9\n  obtain \u27e8t, ht, hts\u27e9 := h hs.compl\n  rw [subset_compl_comm, \u2190 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 \u03b1} :\n    t = t' \u2194 \u2200 s, (@cobounded \u03b1 t).sets s \u2194 (@cobounded \u03b1 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 \u03b1} :\n    t = t' \u2194 \u2200 s, @IsBounded \u03b1 t s \u2194 @IsBounded \u03b1 t' s :=\n  \u27e8fun h s => h \u25b8 Iff.rfl, fun h => by\n    ext\n    simpa only [is_bounded_def, compl_compl] using h (s\u1d9c)\u27e9\n#align bornology.ext_iff_is_bounded Bornology.ext_iff_isBounded\n-/\n\nvariable {s : Set \u03b1}\n\n/- warning: bornology.is_cobounded_of_bounded_iff -> Bornology.isCobounded_ofBounded_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} (B : Set.{u1} (Set.{u1} \u03b1)) {empty_mem : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.hasEmptyc.{u1} \u03b1)) B} {subset_mem : forall (s\u2081 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s\u2082 s\u2081) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2082 B))} {union_mem : forall (s\u2081 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2082 B) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s\u2081 s\u2082) B))} {sUnion_univ : forall (x : \u03b1), Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (Singleton.singleton.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasSingleton.{u1} \u03b1) x) B}, Iff (Bornology.IsCobounded.{u1} \u03b1 (Bornology.ofBounded.{u1} \u03b1 B empty_mem subset_mem union_mem sUnion_univ) s) (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) B)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} (B : Set.{u1} (Set.{u1} \u03b1)) {empty_mem : Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.instEmptyCollectionSet.{u1} \u03b1)) B} {subset_mem : forall (s\u2081 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s\u2082 s\u2081) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2082 B))} {union_mem : forall (s\u2081 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2082 B) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s\u2081 s\u2082) B))} {sUnion_univ : forall (x : \u03b1), Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (Singleton.singleton.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instSingletonSet.{u1} \u03b1) x) B}, Iff (Bornology.IsCobounded.{u1} \u03b1 (Bornology.ofBounded.{u1} \u03b1 B empty_mem subset_mem union_mem sUnion_univ) s) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) B)\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_of_bounded_iff Bornology.isCobounded_ofBounded_iff\u2093'. -/\ntheorem isCobounded_ofBounded_iff (B : Set (Set \u03b1)) {empty_mem subset_mem union_mem sUnion_univ} :\n    @IsCobounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s \u2194 s\u1d9c \u2208 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 {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} (B : Set.{u1} (Set.{u1} \u03b1)) {empty_mem : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.hasEmptyc.{u1} \u03b1)) B} {subset_mem : forall (s\u2081 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s\u2082 s\u2081) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2082 B))} {union_mem : forall (s\u2081 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s\u2082 B) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s\u2081 s\u2082) B))} {sUnion_univ : forall (x : \u03b1), Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) (Singleton.singleton.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasSingleton.{u1} \u03b1) x) B}, Iff (Bornology.IsBounded.{u1} \u03b1 (Bornology.ofBounded.{u1} \u03b1 B empty_mem subset_mem union_mem sUnion_univ) s) (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) s B)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} (B : Set.{u1} (Set.{u1} \u03b1)) {empty_mem : Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.instEmptyCollectionSet.{u1} \u03b1)) B} {subset_mem : forall (s\u2081 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s\u2082 s\u2081) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2082 B))} {union_mem : forall (s\u2081 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2081 B) -> (forall (s\u2082 : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s\u2082 B) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s\u2081 s\u2082) B))} {sUnion_univ : forall (x : \u03b1), Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) (Singleton.singleton.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instSingletonSet.{u1} \u03b1) x) B}, Iff (Bornology.IsBounded.{u1} \u03b1 (Bornology.ofBounded.{u1} \u03b1 B empty_mem subset_mem union_mem sUnion_univ) s) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) s B)\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_of_bounded_iff Bornology.isBounded_ofBounded_iff\u2093'. -/\ntheorem isBounded_ofBounded_iff (B : Set (Set \u03b1)) {empty_mem subset_mem union_mem sUnion_univ} :\n    @IsBounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s \u2194 s \u2208 B := by\n  rw [is_bounded_def, \u2190 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 \u03b1]\n\n/- warning: bornology.is_cobounded_bInter -> Bornology.isCobounded_binter\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Bornology.{u2} \u03b1] {s : Set.{u1} \u03b9} {f : \u03b9 -> (Set.{u2} \u03b1)}, (Set.Finite.{u1} \u03b9 s) -> (Iff (Bornology.IsCobounded.{u2} \u03b1 _inst_1 (Set.inter\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (i : \u03b9) => Set.inter\u1d62.{u2, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.hasMem.{u1} \u03b9) i s) => f i)))) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.hasMem.{u1} \u03b9) i s) -> (Bornology.IsCobounded.{u2} \u03b1 _inst_1 (f i))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u2} \u03b9} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Set.Finite.{u2} \u03b9 s) -> (Iff (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (Set.inter\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.inter\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) => f i)))) (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (f i))))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_bInter Bornology.isCobounded_binter\u1d62\u2093'. -/\ntheorem isCobounded_binter\u1d62 {s : Set \u03b9} {f : \u03b9 \u2192 Set \u03b1} (hs : s.Finite) :\n    IsCobounded (\u22c2 i \u2208 s, f i) \u2194 \u2200 i \u2208 s, IsCobounded (f i) :=\n  binter\u1d62_mem hs\n#align bornology.is_cobounded_bInter Bornology.isCobounded_binter\u1d62\n\n/- warning: bornology.is_cobounded_bInter_finset -> Bornology.isCobounded_binter\u1d62_finset is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Bornology.{u2} \u03b1] (s : Finset.{u1} \u03b9) {f : \u03b9 -> (Set.{u2} \u03b1)}, Iff (Bornology.IsCobounded.{u2} \u03b1 _inst_1 (Set.inter\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (i : \u03b9) => Set.inter\u1d62.{u2, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) => f i)))) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) -> (Bornology.IsCobounded.{u2} \u03b1 _inst_1 (f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] (s : Finset.{u2} \u03b9) {f : \u03b9 -> (Set.{u1} \u03b1)}, Iff (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (Set.inter\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.inter\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) (fun (H : Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) => f i)))) (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) -> (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (f i)))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_bInter_finset Bornology.isCobounded_binter\u1d62_finset\u2093'. -/\n@[simp]\ntheorem isCobounded_binter\u1d62_finset (s : Finset \u03b9) {f : \u03b9 \u2192 Set \u03b1} :\n    IsCobounded (\u22c2 i \u2208 s, f i) \u2194 \u2200 i \u2208 s, IsCobounded (f i) :=\n  binter\u1d62_finset_mem s\n#align bornology.is_cobounded_bInter_finset Bornology.isCobounded_binter\u1d62_finset\n\n/- warning: bornology.is_cobounded_Inter -> Bornology.isCobounded_inter\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Bornology.{u2} \u03b1] [_inst_2 : Finite.{succ u1} \u03b9] {f : \u03b9 -> (Set.{u2} \u03b1)}, Iff (Bornology.IsCobounded.{u2} \u03b1 _inst_1 (Set.inter\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (i : \u03b9) => f i))) (forall (i : \u03b9), Bornology.IsCobounded.{u2} \u03b1 _inst_1 (f i))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] [_inst_2 : Finite.{succ u2} \u03b9] {f : \u03b9 -> (Set.{u1} \u03b1)}, Iff (Bornology.IsCobounded.{u1} \u03b1 _inst_1 (Set.inter\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => f i))) (forall (i : \u03b9), Bornology.IsCobounded.{u1} \u03b1 _inst_1 (f i))\nCase conversion may be inaccurate. Consider using '#align bornology.is_cobounded_Inter Bornology.isCobounded_inter\u1d62\u2093'. -/\n@[simp]\ntheorem isCobounded_inter\u1d62 [Finite \u03b9] {f : \u03b9 \u2192 Set \u03b1} :\n    IsCobounded (\u22c2 i, f i) \u2194 \u2200 i, IsCobounded (f i) :=\n  inter\u1d62_mem\n#align bornology.is_cobounded_Inter Bornology.isCobounded_inter\u1d62\n\n#print Bornology.isCobounded_inter\u209b /-\ntheorem isCobounded_inter\u209b {S : Set (Set \u03b1)} (hs : S.Finite) :\n    IsCobounded (\u22c2\u2080 S) \u2194 \u2200 s \u2208 S, IsCobounded s :=\n  inter\u209b_mem hs\n#align bornology.is_cobounded_sInter Bornology.isCobounded_inter\u209b\n-/\n\n/- warning: bornology.is_bounded_bUnion -> Bornology.isBounded_bunion\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Bornology.{u2} \u03b1] {s : Set.{u1} \u03b9} {f : \u03b9 -> (Set.{u2} \u03b1)}, (Set.Finite.{u1} \u03b9 s) -> (Iff (Bornology.IsBounded.{u2} \u03b1 _inst_1 (Set.union\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.hasMem.{u1} \u03b9) i s) => f i)))) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.hasMem.{u1} \u03b9) i s) -> (Bornology.IsBounded.{u2} \u03b1 _inst_1 (f i))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] {s : Set.{u2} \u03b9} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Set.Finite.{u2} \u03b9 s) -> (Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) => f i)))) (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 (f i))))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_bUnion Bornology.isBounded_bunion\u1d62\u2093'. -/\ntheorem isBounded_bunion\u1d62 {s : Set \u03b9} {f : \u03b9 \u2192 Set \u03b1} (hs : s.Finite) :\n    IsBounded (\u22c3 i \u2208 s, f i) \u2194 \u2200 i \u2208 s, IsBounded (f i) := by\n  simp only [\u2190 is_cobounded_compl_iff, compl_Union, is_cobounded_bInter hs]\n#align bornology.is_bounded_bUnion Bornology.isBounded_bunion\u1d62\n\n/- warning: bornology.is_bounded_bUnion_finset -> Bornology.isBounded_bunion\u1d62_finset is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Bornology.{u2} \u03b1] (s : Finset.{u1} \u03b9) {f : \u03b9 -> (Set.{u2} \u03b1)}, Iff (Bornology.IsBounded.{u2} \u03b1 _inst_1 (Set.union\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) => f i)))) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) -> (Bornology.IsBounded.{u2} \u03b1 _inst_1 (f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] (s : Finset.{u2} \u03b9) {f : \u03b9 -> (Set.{u1} \u03b1)}, Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) (fun (H : Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) => f i)))) (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) -> (Bornology.IsBounded.{u1} \u03b1 _inst_1 (f i)))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_bUnion_finset Bornology.isBounded_bunion\u1d62_finset\u2093'. -/\ntheorem isBounded_bunion\u1d62_finset (s : Finset \u03b9) {f : \u03b9 \u2192 Set \u03b1} :\n    IsBounded (\u22c3 i \u2208 s, f i) \u2194 \u2200 i \u2208 s, IsBounded (f i) :=\n  isBounded_bunion\u1d62 s.finite_toSet\n#align bornology.is_bounded_bUnion_finset Bornology.isBounded_bunion\u1d62_finset\n\n#print Bornology.isBounded_union\u209b /-\ntheorem isBounded_union\u209b {S : Set (Set \u03b1)} (hs : S.Finite) :\n    IsBounded (\u22c3\u2080 S) \u2194 \u2200 s \u2208 S, IsBounded s := by rw [sUnion_eq_bUnion, is_bounded_bUnion hs]\n#align bornology.is_bounded_sUnion Bornology.isBounded_union\u209b\n-/\n\n/- warning: bornology.is_bounded_Union -> Bornology.isBounded_union\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Bornology.{u2} \u03b1] [_inst_2 : Finite.{succ u1} \u03b9] {s : \u03b9 -> (Set.{u2} \u03b1)}, Iff (Bornology.IsBounded.{u2} \u03b1 _inst_1 (Set.union\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (i : \u03b9) => s i))) (forall (i : \u03b9), Bornology.IsBounded.{u2} \u03b1 _inst_1 (s i))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1] [_inst_2 : Finite.{succ u2} \u03b9] {s : \u03b9 -> (Set.{u1} \u03b1)}, Iff (Bornology.IsBounded.{u1} \u03b1 _inst_1 (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => s i))) (forall (i : \u03b9), Bornology.IsBounded.{u1} \u03b1 _inst_1 (s i))\nCase conversion may be inaccurate. Consider using '#align bornology.is_bounded_Union Bornology.isBounded_union\u1d62\u2093'. -/\n@[simp]\ntheorem isBounded_union\u1d62 [Finite \u03b9] {s : \u03b9 \u2192 Set \u03b1} : IsBounded (\u22c3 i, s i) \u2194 \u2200 i, IsBounded (s i) :=\n  by rw [\u2190 sUnion_range, is_bounded_sUnion (finite_range s), forall_range_iff]\n#align bornology.is_bounded_Union Bornology.isBounded_union\u1d62\n\nend Bornology\n\nopen Bornology\n\n#print Set.Finite.isBounded /-\ntheorem Set.Finite.isBounded [Bornology \u03b1] {s : Set \u03b1} (hs : s.Finite) : IsBounded s :=\n  Bornology.le_cofinite \u03b1 hs.compl_mem_cofinite\n#align set.finite.is_bounded Set.Finite.isBounded\n-/\n\ninstance : Bornology PUnit :=\n  \u27e8\u22a5, bot_le\u27e9\n\n#print Bornology.cofinite /-\n/-- The cofinite filter as a bornology -/\n@[reducible]\ndef Bornology.cofinite : Bornology \u03b1\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 \u03b1` is bounded. -/\nclass BoundedSpace (\u03b1 : Type _) [Bornology \u03b1] : Prop where\n  bounded_univ : Bornology.IsBounded (univ : Set \u03b1)\n#align bounded_space BoundedSpace\n-/\n\nnamespace Bornology\n\nvariable [Bornology \u03b1]\n\n#print Bornology.isBounded_univ /-\ntheorem isBounded_univ : IsBounded (univ : Set \u03b1) \u2194 BoundedSpace \u03b1 :=\n  \u27e8fun h => \u27e8h\u27e9, fun h => h.1\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1], Iff (Eq.{succ u1} (Filter.{u1} \u03b1) (Bornology.cobounded.{u1} \u03b1 _inst_1) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1)))) (BoundedSpace.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Bornology.{u1} \u03b1], Iff (Eq.{succ u1} (Filter.{u1} \u03b1) (Bornology.cobounded.{u1} \u03b1 _inst_1) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toBot.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1)))) (BoundedSpace.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align bornology.cobounded_eq_bot_iff Bornology.cobounded_eq_bot_iff\u2093'. -/\ntheorem cobounded_eq_bot_iff : cobounded \u03b1 = \u22a5 \u2194 BoundedSpace \u03b1 := by\n  rw [\u2190 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 \u03b1]\n\n#print Bornology.IsBounded.all /-\ntheorem IsBounded.all (s : Set \u03b1) : 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 \u03b1) : IsCobounded s :=\n  compl_compl s \u25b8 IsBounded.all (s\u1d9c)\n#align bornology.is_cobounded.all Bornology.IsCobounded.all\n-/\n\nvariable (\u03b1)\n\n/- warning: bornology.cobounded_eq_bot -> Bornology.cobounded_eq_bot is a dubious translation:\nlean 3 declaration is\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Bornology.{u1} \u03b1] [_inst_2 : BoundedSpace.{u1} \u03b1 _inst_1], Eq.{succ u1} (Filter.{u1} \u03b1) (Bornology.cobounded.{u1} \u03b1 _inst_1) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1)))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Bornology.{u1} \u03b1] [_inst_2 : BoundedSpace.{u1} \u03b1 _inst_1], Eq.{succ u1} (Filter.{u1} \u03b1) (Bornology.cobounded.{u1} \u03b1 _inst_1) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toBot.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align bornology.cobounded_eq_bot Bornology.cobounded_eq_bot\u2093'. -/\n@[simp]\ntheorem cobounded_eq_bot : cobounded \u03b1 = \u22a5 :=\n  cobounded_eq_bot_iff.2 \u2039_\u203a\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 {\u03b1 : Type u}\n\ntheorem directed.finset_le {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_trans \u03b1 r]\n  {\u03b9} [h\u03b9 : nonempty \u03b9] {f : \u03b9 \u2192 \u03b1} (D : directed r f) (s : finset \u03b9) :\n  \u2203 z, \u2200 i \u2208 s, r (f i) (f z) :=\nshow \u2203 z, \u2200 i \u2208 s.1, r (f i) (f z), from\nmultiset.induction_on s.1 (let \u27e8z\u27e9 := h\u03b9 in \u27e8z, \u03bb _, false.elim\u27e9) $\n\u03bb i s \u27e8j, H\u27e9, let \u27e8k, h\u2081, h\u2082\u27e9 := D i j in\n\u27e8k, \u03bb a h, or.cases_on (multiset.mem_cons.1 h)\n  (\u03bb h, h.symm \u25b8 h\u2081)\n  (\u03bb h, trans (H _ h) h\u2082)\u27e9\n\ntheorem finset.exists_le {\u03b1 : Type u} [nonempty \u03b1] [directed_order \u03b1] (s : finset \u03b1) :\n  \u2203 M, \u2200 i \u2208 s, i \u2264 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 \u2194 b) = b :=\n  h.symm \u25b8 propext true_iff_iff\n\ntheorem iff_eq_of_eq_true_right {a b : Prop} (h : b = True) : (a \u2194 b) = a :=\n  h.symm \u25b8 propext iff_true_iff\n\ntheorem iff_eq_true_of_eq {a b : Prop} (h : a = b) : (a \u2194 b) = True :=\n  h \u25b8 propext (iff_self_iff _)\n\ntheorem and_eq_of_eq_true_left {a b : Prop} (h : a = True) : (a \u2227 b) = b :=\n  h.symm \u25b8 propext (true_and_iff _)\n\ntheorem and_eq_of_eq_true_right {a b : Prop} (h : b = True) : (a \u2227 b) = a :=\n  h.symm \u25b8 propext (and_true_iff _)\n\ntheorem and_eq_of_eq_false_left {a b : Prop} (h : a = False) : (a \u2227 b) = False :=\n  h.symm \u25b8 propext (false_and_iff _)\n\ntheorem and_eq_of_eq_false_right {a b : Prop} (h : b = False) : (a \u2227 b) = False :=\n  h.symm \u25b8 propext (and_false_iff _)\n\ntheorem and_eq_of_eq {a b : Prop} (h : a = b) : (a \u2227 b) = a :=\n  h \u25b8 propext (and_self_iff _)\n\ntheorem or_eq_of_eq_true_left {a b : Prop} (h : a = True) : (a \u2228 b) = True :=\n  h.symm \u25b8 propext (true_or_iff _)\n\ntheorem or_eq_of_eq_true_right {a b : Prop} (h : b = True) : (a \u2228 b) = True :=\n  h.symm \u25b8 propext (or_true_iff _)\n\ntheorem or_eq_of_eq_false_left {a b : Prop} (h : a = False) : (a \u2228 b) = b :=\n  h.symm \u25b8 propext (false_or_iff _)\n\ntheorem or_eq_of_eq_false_right {a b : Prop} (h : b = False) : (a \u2228 b) = a :=\n  h.symm \u25b8 propext (or_false_iff _)\n\ntheorem or_eq_of_eq {a b : Prop} (h : a = b) : (a \u2228 b) = a :=\n  h \u25b8 propext (or_self_iff _)\n\ntheorem imp_eq_of_eq_true_left {a b : Prop} (h : a = True) : (a \u2192 b) = b :=\n  h.symm \u25b8 propext \u27e8fun h \u21a6 h trivial, fun h\u2081 _ \u21a6 h\u2081\u27e9\n\ntheorem imp_eq_of_eq_true_right {a b : Prop} (h : b = True) : (a \u2192 b) = True :=\n  h.symm \u25b8 propext \u27e8fun _ \u21a6 trivial, fun h\u2081 _ \u21a6 h\u2081\u27e9\n\ntheorem imp_eq_of_eq_false_left {a b : Prop} (h : a = False) : (a \u2192 b) = True :=\n  h.symm \u25b8 propext \u27e8fun _ \u21a6 trivial, fun _ h\u2082 \u21a6 False.elim h\u2082\u27e9\n\ntheorem imp_eq_of_eq_false_right {a b : Prop} (h : b = False) : (a \u2192 b) = Not a :=\n  h.symm \u25b8 propext \u27e8fun h \u21a6 h, fun hna ha \u21a6 hna ha\u27e9\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 \u2192 b) = a :=\n  h.symm \u25b8 propext (Iff.intro (\n    fun h' \u21a6 Classical.byContradiction fun hna \u21a6 h' hna) fun ha hna \u21a6 hna ha)\n\ntheorem imp_eq_true_of_eq {a b : Prop} (h : a = b) : (a \u2192 b) = True :=\n  h \u25b8 propext \u27e8fun _ \u21a6 trivial, fun _ ha \u21a6 ha\u27e9\n\ntheorem not_eq_of_eq_true {a : Prop} (h : a = True) : Not a = False :=\n  h.symm \u25b8 propext not_true\n\ntheorem not_eq_of_eq_false {a : Prop} (h : a = False) : Not a = True :=\n  h.symm \u25b8 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 \u21a6 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] {\u03b1 : Sort u} (t e : \u03b1) (h : c = True) :\n  @ite \u03b1 c d t e = t :=\n  if_pos (of_eq_true h)\n\ntheorem if_eq_of_eq_false {c : Prop} [d : Decidable c] {\u03b1 : Sort u} (t e : \u03b1) (h : c = False) :\n  @ite \u03b1 c d t e = e :=\n  if_neg (not_of_eq_false h)\n\ntheorem if_eq_of_eq (c : Prop) [d : Decidable c] {\u03b1 : Sort u} {t e : \u03b1} (h : t = e) :\n  @ite \u03b1 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 \u2227 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 \u2227 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 \u2228 b) = False) : a = False :=\n  eq_false fun ha \u21a6 False.elim (Eq.mp h (Or.inl ha))\n\ntheorem eq_false_of_or_eq_false_right {a b : Prop} (h : (a \u2228 b) = False) : b = False :=\n  eq_false fun hb \u21a6 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 \u21a6 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 \u21a6 Eq.mp h hna)\n\ntheorem ne_of_eq_of_ne {\u03b1 : Sort u} {a b c : \u03b1} (h\u2081 : a = b) (h\u2082 : b \u2260 c) : a \u2260 c :=\n  h\u2081.symm \u25b8 h\u2082\n\nalias ne_of_eq_of_ne \u2190 Eq.trans_ne\n#align eq.trans_ne Eq.trans_ne\n\ntheorem ne_of_ne_of_eq {\u03b1 : Sort u} {a b c : \u03b1} (h\u2081 : a \u2260 b) (h\u2082 : b = c) : a \u2260 c :=\n  h\u2082 \u25b8 h\u2081\n\nalias ne_of_ne_of_eq \u2190 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": "import data.real.basic\nimport data.set.lattice\nimport topology.basic\nimport game.topology.union_open_sets\n\nopen set\n\n--begin hide\nnamespace xena\n-- Work in progress\n-- end hide\n\n\n-- begin hide\n-- Checking mathlib definitions\nvariable \u03b2 : Type*  \nvariable [fintype \u03b2]\n-- end hide\n\n/- Lemma\nFinite intersection of open sets is open -- WIP, to do.\n-/\nlemma is_open_fin_inter_of_open (X : \u03b2 \u2192 set \u211d ) ( hj : \u2200 j, is_open (X j) )\n    : is_open (Inter X) :=\nbegin\n    sorry,\nend\n\nend xena -- hide\n", "meta": {"author": "ImperialCollegeLondon", "repo": "real-number-game", "sha": "f9dcb7d9255a79b57e62038228a23346c2dc301b", "save_path": "github-repos/lean/ImperialCollegeLondon-real-number-game", "path": "github-repos/lean/ImperialCollegeLondon-real-number-game/real-number-game-f9dcb7d9255a79b57e62038228a23346c2dc301b/src/game/topology/inter_open_sets.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8807970779778824, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4883759653621822}}
{"text": "\nlemma notFalse: \u00acfalse :=\nbegin\n  assume pfFalse,\n  assumption,\nend\n\nlemma falseImpliesAnything{anything: Prop}:\n  false \u2192 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 ` \u27f9 `:65 := lattice.imp\n\nlocal infix ` \u21d4 `: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 {\ud835\udd39 : Type*} [complete_boolean_algebra \ud835\udd39]\n\nlemma supr_imp_eq {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {b : \ud835\udd39} :\n  (\u2a06(i:\u03b9), s i) \u27f9 b = (\u2a05(i:\u03b9), s i \u27f9 b) :=\nby {unfold imp, rw[neg_supr, infi_sup_eq]}\n\nlemma imp_infi_eq {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {b : \ud835\udd39} :\n  (b \u27f9 (\u2a05i, s i)) = (\u2a05i, b \u27f9 s i) :=\nby {unfold imp, rw[sup_infi_eq]}\n\nlemma bv_Or_elim  {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {c : \ud835\udd39} :\n(\u2200 i : \u03b9, (s i \u2264 c)) \u2192 ((\u2a06(i:\u03b9), s i) \u2264 c) :=\n\u03bb H, by apply supr_le; from H\n\nlemma bv_And_intro {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {b c : \ud835\udd39} :\n(\u2200 i : \u03b9, (c \u2264 s i)) \u2192 (c \u2264 \u2a05(i:\u03b9), s i) :=\n\u03bb H, by {apply le_infi, from H} -- this is superceded by tactic.interactive.bv_intro\n\nlemma bv_or_elim {b\u2081 b\u2082 c : \ud835\udd39} {h : b\u2081 \u2264 c} {h' : b\u2082 \u2264 c} : b\u2081 \u2294 b\u2082 \u2264 c :=\n  by apply sup_le; assumption\n\nlemma bv_or_elim_left {b\u2081 b\u2082 c d : \ud835\udd39} {h\u2081 : b\u2081 \u2293 d \u2264 c} {h\u2082 : b\u2082 \u2293 d \u2264 c} : (b\u2081 \u2294 b\u2082) \u2293 d \u2264 c :=\n  by {rw[deduction], apply bv_or_elim; rw[<-deduction]; from \u2039_\u203a}\n\nlemma bv_or_elim_right {b\u2081 b\u2082 c d : \ud835\udd39} {h\u2081 : d \u2293 b\u2081 \u2264 c} {h\u2082 : d \u2293 b\u2082 \u2264 c} : d \u2293 (b\u2081 \u2294 b\u2082) \u2264 c :=\n  by {rw[inf_comm] at \u22a2 h\u2081 h\u2082; apply bv_or_elim_left; assumption}\n\nlemma bv_exfalso {a b : \ud835\udd39} (h : a \u2264 \u22a5) : a \u2264 b :=\nle_trans h bot_le\n\nlemma bv_cases_left {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {c b : \ud835\udd39} {h : \u2200 i : \u03b9, (s i \u2293 c \u2264 b)} :\n  ((\u2a06(i:\u03b9), s i) \u2293 c) \u2264 b :=\nby {rw[deduction], apply supr_le, intro i, rw[<-deduction], revert i, from \u2039_\u203a}\n\nlemma bv_cases_right {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {c b : \ud835\udd39} {h : \u2200 i : \u03b9, (c \u2293 s i \u2264 b)} :\n  (c \u2293 (\u2a06(i:\u03b9), s i)) \u2264 b :=\nby {rw[inf_comm], apply bv_cases_left, simpa only [inf_comm]}\n\nlemma bv_specialize {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} (i : \u03b9) {b : \ud835\udd39} {h : s i \u2264 b} :\n(\u2a05(i:\u03b9), s i) \u2264 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 {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} (i j : \u03b9) {b : \ud835\udd39} {h : s i \u2293 s j \u2264 b} :\n(\u2a05(i:\u03b9), s i) \u2264 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 {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {c b : \ud835\udd39} (i : \u03b9)\n  {h : s i \u2293 c \u2264 b} : (\u2a05(i:\u03b9), s i) \u2293 c \u2264 b :=\nby {rw[deduction], apply bv_specialize i, rwa[<-deduction]}\n\nlemma bv_specialize_left_twice {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {c b : \ud835\udd39} (i j : \u03b9)\n  {h : s i \u2293 s j \u2293 c \u2264 b} : (\u2a05(i:\u03b9), s i) \u2293 c \u2264 b :=\nbegin\n  rw[deduction], apply bv_specialize_twice i j, rwa[<-deduction]\nend\n\nlemma bv_specialize_right {\u03b9 : Type*} {s :\u03b9 \u2192 \ud835\udd39} {c b : \ud835\udd39} (i : \u03b9)\n  {h : c \u2293 s i \u2264 b} : c \u2293 (\u2a05(i:\u03b9), s i) \u2264 b :=\nby {rw[inf_comm], apply bv_specialize_left i, rwa[inf_comm]}\n\nlemma bv_specialize_right_twice {\u03b9 : Type*} {s : \u03b9 \u2192 \ud835\udd39} {c b : \ud835\udd39} (i j : \u03b9)\n  {h : c \u2293 (s i \u2293 s j) \u2264 b} : c \u2293 (\u2a05(i:\u03b9), s i) \u2264 b :=\nbegin\n  rw[inf_comm], apply bv_specialize_left_twice i j, rwa[<-inf_comm]\nend\n\nlemma bv_imp_elim {a b : \ud835\udd39} : (a \u27f9 b) \u2293 a \u2264 b :=\nby simp[imp, inf_sup_right]\n\nlemma bv_imp_elim' {a b : \ud835\udd39} : (a \u27f9 b) \u2293 a \u2264 a \u2293 b :=\nby {simp[imp, inf_sup_right]}\n\nlemma bv_cancel_antecedent {a b c : \ud835\udd39} (h : b \u2264 c) : a \u27f9 b \u2264 a \u27f9 c :=\nby {rw[<-deduction], apply le_trans, apply bv_imp_elim, from \u2039_\u203a}\n\nlemma bv_imp_iff {\u0393 b\u2081 b\u2082 : \ud835\udd39} : \u0393 \u2264 b\u2081 \u27f9 b\u2082 \u2194 (\u2200 {\u0393'} (H_le : \u0393' \u2264 \u0393), \u0393' \u2264 b\u2081 \u2192 \u0393' \u2264 b\u2082) :=\nbegin\n  refine \u27e8_,_\u27e9; intro H,\n    { intros \u0393' H_le H', rw \u2190deduction at H,\n      exact le_trans (le_inf \u2039_\u203a \u2039_\u203a) H },\n    { bv_imp_intro H', apply H,\n      { dsimp[\u0393_1], from inf_le_right },\n      { from \u2039_\u203a } }\nend\n\nlemma bv_biimp_iff {b\u2081 b\u2082 : \ud835\udd39} {\u0393 : \ud835\udd39} : (\u0393 \u2264 (b\u2081 \u21d4 b\u2082)) \u2194 (\u2200 {\u0393'} (H_le : \u0393' \u2264 \u0393), \u0393' \u2264 b\u2081 \u2194 \u0393' \u2264 b\u2082) :=\nbegin\n  refine \u27e8_,_\u27e9; intro H,\n    { bv_split_at H,\n      intros \u0393' H_le, refine \u27e8_,_\u27e9,\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 \u2039_\u203a).mp \u2039_\u203a },\n      { rw bv_imp_iff, intros, exact (H \u2039_\u203a).mpr \u2039_\u203a }}\nend\n\n-- example {a b c : \ud835\udd39} (h : b \u2264 c) : a \u27f9 b \u2264 a \u27f9 c :=\n-- by {tidy_context, bv_imp_intro, apply (poset_yoneda_inv _ h), from a_1 \u2039_\u203a}\n\nlemma bv_and_intro {a b\u2081 b\u2082 : \ud835\udd39} (h\u2081 : a \u2264 b\u2081) (h\u2082 : a \u2264 b\u2082) : a \u2264 b\u2081 \u2293 b\u2082 := le_inf h\u2081 h\u2082\n\nlemma bv_or_left {a b\u2081 b\u2082 : \ud835\udd39} (h\u2081 : a \u2264 b\u2081) : a \u2264 b\u2081 \u2294 b\u2082 := le_sup_left_of_le h\u2081\n\nlemma bv_or_right {a b\u2081 b\u2082 : \ud835\udd39} (h\u2082 : a \u2264 b\u2082) : a \u2264 b\u2081 \u2294 b\u2082 := le_sup_right_of_le h\u2082\n\nlemma bv_and.left {a b : \ud835\udd39} {\u0393} (H : \u0393 \u2264 a \u2293 b) : \u0393 \u2264 a :=\nle_trans H inf_le_left\n\nlemma bv_and.right {a b : \ud835\udd39} {\u0393} (H : \u0393 \u2264 a \u2293 b) : \u0393 \u2264 b :=\nle_trans H inf_le_right\n\nlemma from_empty_context {a b : \ud835\udd39} (h : \u22a4 \u2264 b) : a \u2264 b :=\n  by refine le_trans _ h; apply le_top\n\nlemma bv_imp_intro {a b c : \ud835\udd39} {h : a \u2293 b \u2264 c} :\n  a \u2264 b \u27f9 c := by rwa[deduction] at h\n\nlemma bv_have {a b c : \ud835\udd39} (h : a \u2264 b) {h' : a \u2293 b \u2264 c} : a \u2264 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 : \ud835\udd39} (h\u2081 : \u22a4 \u2264 b) (h\u2082 : a \u2293 b \u2264 c) : a \u2264 c :=\nby {rw[top_le_iff] at h\u2081, rw[h\u2081] at h\u2082, from le_trans (by rw[inf_top_eq]) h\u2082}\n\nlemma bv_use {\u03b9} (i : \u03b9) {s : \u03b9 \u2192 \ud835\udd39} {b : \ud835\udd39}  {h : b \u2264 s i} : b \u2264 \u2a06(j:\u03b9), s j :=\n  le_supr_of_le i h\n\nlemma bv_context_apply {\u03b2 : Type*} [complete_boolean_algebra \u03b2] {\u0393 a\u2081 a\u2082 : \u03b2}\n  (h\u2081 : \u0393 \u2264 a\u2081 \u27f9 a\u2082) (h\u2082 : \u0393 \u2264 a\u2081) : \u0393 \u2264 a\u2082 := h\u2081 \u2039_\u203a\n\nlemma bv_Or_imp {\u0393 : \ud835\udd39} {\u03b9} {\u03d5\u2081 \u03d5\u2082 : \u03b9 \u2192 \ud835\udd39} (H_sub : \u0393 \u2264 \u2a05 x, \u03d5\u2081 x \u27f9 \u03d5\u2082 x) (H : \u0393 \u2264 \u2a06x, \u03d5\u2081 x)  : \u0393 \u2264 \u2a06x, \u03d5\u2082 x :=\nby {bv_cases_at H x, apply bv_use x, from H_sub x \u2039_\u203a}\n\nlemma bv_iff.neg {b\u2081 b\u2082 : \ud835\udd39} (H : \u2200{\u0393}, \u0393 \u2264 b\u2081 \u2194 \u0393 \u2264 b\u2082) : \u2200 {\u0393}, \u0393 \u2264 -(b\u2081) \u2194 \u0393 \u2264 -(b\u2082) :=\nbegin\n  intro \u0393, refine \u27e8_,_\u27e9; intro H',\n    { apply bv_by_contra, bv_imp_intro H_contra, rw lattice.neg_neg at H_contra, rw \u2190imp_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 \u2190imp_bot at H',\n      refine H' _, rwa \u2190H }\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 : \u00ac pSet.equiv x y) :\n  (\u2203 a : x.type, \u2200 a' : y.type, \u00ac pSet.equiv (x.func a) (y.func a')) \u2228\n  (\u2203 a' : y.type, \u2200 a : x.type, \u00ac pSet.equiv (x.func a) (y.func a')) :=\nbegin\n  cases x, cases y, unfold equiv, safe,\n  suffices : equiv (mk x_\u03b1 x_A) (mk y_\u03b1 y_A), by contradiction,\n  constructor; assumption\nend\n\nend pSet\n\n\n/- A \ud835\udd39-valued model of ZFC -/\n\n-- \u03c4 is a B-name if and only if \u03c4 is a set of pairs of the form \u27e8\u03c3, b\u27e9, where \u03c3 is\n-- a B-name and b \u2208 B.\ninductive bSet (\ud835\udd39 : Type u) [complete_boolean_algebra \ud835\udd39] : Type (u+1)\n| mk (\u03b1 : Type u) (A : \u03b1 \u2192 bSet) (B : \u03b1 \u2192 \ud835\udd39) : bSet\n\nnamespace bSet\nvariables {\ud835\udd39 : Type u} [nontrivial_complete_boolean_algebra \ud835\udd39]\n\nnoncomputable instance decidable_eq_\ud835\udd39 : decidable_eq \ud835\udd39 := \u03bb _ _, classical.prop_decidable _\n\nrun_cmd mk_simp_attr `cleanup\n\n/-- The underlying type of a bSet -/\n@[simp, cleanup]def type : bSet \ud835\udd39 \u2192 Type u\n| \u27e8\u03b1, _, _\u27e9 := \u03b1\n\n@[simp, cleanup]lemma type_infi {\u03b1 : Type*} {A : \u03b1 \u2192 bSet \ud835\udd39} {B C : \u03b1 \u2192 \ud835\udd39} : (\u2a05(a : type (mk \u03b1 A B)), C a) = \u2a05(a : \u03b1), C a := rfl\n\n@[simp, cleanup]lemma type_supr {\u03b1 : Type*} {A : \u03b1 \u2192 bSet \ud835\udd39} {B C : \u03b1 \u2192 \ud835\udd39} : (\u2a06(a : type (mk \u03b1 A B)), C a) = \u2a06(a : \u03b1), C a := rfl\n\n/-- The indexing function of a bSet -/\n@[simp, cleanup]def func : \u2200 x : bSet \ud835\udd39, x.type \u2192 bSet \ud835\udd39\n| \u27e8_, A, _\u27e9 := A\n\n/-- The boolean truth-value function of a bSet -/\n@[simp, cleanup]def bval : \u2200 x : bSet \ud835\udd39, x.type \u2192 \ud835\udd39\n| \u27e8_, _, B\u27e9 := B\n\n@[simp, cleanup]def mk_type_func_bval : \u2200 x : bSet \ud835\udd39, mk x.type x.func x.bval = x :=\n  \u03bb x, by cases x; refl\n\ndef empty : bSet \ud835\udd39 :=\n  \u27e8ulift empty, empty.elim \u2218 ulift.down, empty.elim \u2218 ulift.down\u27e9\n\ninstance nonempty_bSet : nonempty $ @bSet \ud835\udd39 _ :=\n  \u27e8empty\u27e9\n\ninstance has_empty_bSet : has_emptyc (bSet \ud835\udd39) := \u27e8empty\u27e9\n\n@[simp]lemma forall_over_empty (\u03d5 : (type (\u2205 : bSet \ud835\udd39)) \u2192 \ud835\udd39) : (\u2a05a, \u03d5 a) = \u22a4 :=\n  by {apply top_unique, bv_intro a, repeat{cases a}}\n\n@[simp]lemma exists_over_empty (\u03d5 : (type (\u2205 : bSet \ud835\udd39)) \u2192 \ud835\udd39) : (\u2a06a, \u03d5 a) = \u22a5 :=\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 : \u2200 (x y : bSet \ud835\udd39), \ud835\udd39\n| \u27e8\u03b1, A, B\u27e9 \u27e8\u03b1', A', B'\u27e9 :=\n             (\u2a05a : \u03b1, B a \u27f9 \u2a06a', B' a' \u2293 bv_eq (A a) (A' a')) \u2293\n               (\u2a05a' : \u03b1', B' a' \u27f9 \u2a06a, B a \u2293 bv_eq (A a) (A' a'))\n\ninfix ` =\u1d2e `:79 := bv_eq\n\n-- note: for every \u0393 : \ud835\udd39, \u03bb x y, \u0393 \u2264 x =\u1d2e y is an equivalence relation\n\ndef bv_eq' (\u0393 : \ud835\udd39) : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 Prop := \u03bb x y, \u0393 \u2264 x=\u1d2e y\n\nexample : (@bv_eq \ud835\udd39 _) (empty) (empty) = \u22a4 :=\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 : \u2200 x, @bv_eq \ud835\udd39 _ x x = \u22a4 :=\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 {\u0393 : \ud835\udd39} {x} : \u0393 \u2264 x =\u1d2e x := le_trans le_top (by simp)\n\n@[simp]lemma bv_eq_top_of_eq {x y : bSet \ud835\udd39} (h_eq : x = y) : x =\u1d2e y = \u22a4 :=\nby simp*\n\n/- empty' is the singleton bSet {\u27e8\u2205, \u22a5\u27e9}, i.e. a set whose only member is \u2205 which has\n   a zero probability of actually being an element. It should be equivalent to \u2205. -/\n@[reducible]def empty' : bSet \ud835\udd39 := mk punit (\u03bb _, \u2205) (\u03bb _, \u22a5)\n\nexample : empty =\u1d2e empty = (\u22a4 : \ud835\udd39) := by simp\n\nexample : \u22a4 \u2264 empty =\u1d2e (empty' : bSet \ud835\udd39) :=\nby simp[empty, empty', bv_eq]; exact dec_trivial\n\n/-- `x \u2208 y` as Boolean-valued pre-sets if `x` is extensionally equivalent to a member\n  of the family `y`. -/\ndef mem : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 \ud835\udd39\n| a (mk \u03b1' A' B') := \u2a06a', B' a' \u2293 a =\u1d2e A' a'\n\n@[reducible]def empty'' : bSet \ud835\udd39 :=\n  mk (ulift bool) (\u03bb x, \u2205) (\u03bb x, by {repeat{cases x}, exact \u22a5, exact \u22a4})\n\ninfix ` \u2208\u1d2e `:80 := mem\n\nlemma mem_unfold {u v : bSet \ud835\udd39} : u \u2208\u1d2e v = \u2a06(i : v.type), v.bval i \u2293 u =\u1d2e v.func i :=\nby cases v; simp[mem,bv_eq]\n\n/-- \u2205 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 : \u2205 \u2208\u1d2e empty'' = (\u22a4 : \ud835\udd39) :=\n  by {apply top_unique, apply le_supr_of_le \u22a4, swap, exact \u27e8\u27e8(tt)\u27e9\u27e9, simp}\n\ntheorem mem.mk {\u03b1 : Type*} (A : \u03b1 \u2192 bSet \ud835\udd39) (B : \u03b1 \u2192 \ud835\udd39) (a : \u03b1) : B a \u2264 A a \u2208\u1d2e mk \u03b1 A B :=\n  le_supr_of_le a $ by simp\n\ntheorem mem.mk' (x : bSet \ud835\udd39) (a : x.type) : x.bval a \u2264 x.func a \u2208\u1d2e x :=\nby cases x; from mem.mk _ _ _\n\n-- the \u0393-generalized version of mem.mk uses two primes because mem.mk' already existed\n@[simp]theorem mem.mk'' {x : bSet \ud835\udd39} {a : x.type} {\u0393} : \u0393 \u2264 x.bval a \u2192 \u0393 \u2264 x.func a \u2208\u1d2e x :=\nposet_yoneda_inv \u0393 (mem.mk' x a)\n\n@[reducible]protected def subset : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 \ud835\udd39\n| (mk \u03b1 A B) b := \u2a05a:\u03b1, B a \u27f9 (A a \u2208\u1d2e b)\n\ninfix ` \u2286\u1d2e `:80 := bSet.subset\n\nlemma subset_unfold {x u : bSet \ud835\udd39} : x \u2286\u1d2e u = (\u2a05(j : x.type), x.bval j \u27f9 x.func j \u2208\u1d2e u) :=\nby induction x; dsimp[bSet.subset]; congr\n\n@[simp]protected def insert : bSet \ud835\udd39 \u2192 \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 bSet \ud835\udd39\n| u b \u27e8\u03b1, A, B\u27e9 := \u27e8option \u03b1, \u03bbo, option.rec u A o, \u03bbo, option.rec b B o\u27e9\n\nprotected def insert' : bSet \ud835\udd39 \u2192 \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 bSet \ud835\udd39\n| u b \u27e8\u03b1, A, B\u27e9 := \u27e8unit \u2295 \u03b1, \u03bb o, sum.rec (\u03bb_, u) A o, \u03bb o, sum.rec (\u03bb_, b) B o\u27e9\n\n@[reducible]protected def insert1 : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 bSet \ud835\udd39\n| u v := bSet.insert u \u22a4 v\n\nlemma insert1_unfold {u v : bSet \ud835\udd39} :\n  bSet.insert1 u v = \u27e8option v.type, \u03bbo, option.rec u v.func o, \u03bb o, option.rec \u22a4 v.bval o\u27e9 :=\nby {induction v, simp[bSet.insert1]}\n\n-- @[simp]lemma insert1_type {u v : bSet \ud835\udd39} : (bSet.insert1 u v).type = option v.type := by simp[insert1_unfold]\n\ninstance insert_bSet : has_insert (bSet \ud835\udd39) (bSet \ud835\udd39) :=\n  \u27e8\u03bb u v, bSet.insert1 u v\u27e9\n\n@[simp]lemma insert_unfold {y z : bSet \ud835\udd39} : insert y z = bSet.insert y \u22a4 z :=\n  by refl\n\n@[simp]theorem mem_insert {x y z : bSet \ud835\udd39} {b : \ud835\udd39} :\n  x \u2208\u1d2e bSet.insert y b z = (b \u2293 x =\u1d2e y) \u2294 x \u2208\u1d2e z :=\n  by induction y; induction z; simp[bv_eq,mem]\n\n@[simp]theorem mem_insert1 {x y z : bSet \ud835\udd39} : x \u2208\u1d2e insert y z = x =\u1d2e y \u2294 x \u2208\u1d2e z :=\n  by simp\n\n@[simp]theorem mem_insert1' { x y z : bSet \ud835\udd39 } { \u0393 : \ud835\udd39 } : \u0393 \u2264 x \u2208\u1d2e insert y z \u2194 \u0393 \u2264 x =\u1d2e y \u2294 x \u2208\u1d2e z :=\nby simp\n\n-- example : {\u2205} =\u1d2e empty'' = (\u22a4 : \ud835\udd39) :=\n-- begin\n--   simp[empty'', singleton, insert, has_insert.insert,mem,bv_eq],\n--   simp[has_emptyc.emptyc, empty,bSet.insert1],\n--   refine \u27e8_, by intro i; repeat{cases i}\u27e9, apply top_unique,\n--  have : \u22a4 = (ulift.rec (bool.rec \u22a5 \u22a4) : ulift bool \u2192 \ud835\udd39) (ulift.up tt),\n--    by refl,\n--  rw[this], apply le_supr\n-- end\n\ntheorem bv_eq_symm {x y : bSet \ud835\udd39} : x =\u1d2e y = y =\u1d2e x :=\nbegin\n  induction x with \u03b1 A B generalizing y, induction y with \u03b1' A' B',\n  suffices : \u2200 a : \u03b1, \u2200 a' : \u03b1', A' a' =\u1d2e A a = A a =\u1d2e A' a',\n    by {simp[bv_eq, this, inf_comm]}, from \u03bb _ _, by simp[x_ih \u2039\u03b1\u203a]\nend\n\ntheorem bv_eq_unfold (x y : bSet \ud835\udd39) :\n  x =\u1d2e y = (\u2a05(a : x.type), x.bval a \u27f9 (x.func a \u2208\u1d2e y))\n          \u2293 (\u2a05(a' : y.type), (y.bval a' \u27f9 (y.func a' \u2208\u1d2e x))) :=\n by induction x; induction y; simp[mem,bv_eq,bv_eq_symm]\n\ntheorem bSet_axiom_of_extensionality (x y : bSet \ud835\udd39) :\n(\u2a05(z : bSet \ud835\udd39), (z \u2208\u1d2e x \u27f9 z \u2208\u1d2e y) \u2293 (z \u2208\u1d2e y \u27f9 z \u2208\u1d2e x)) \u2264 x =\u1d2e 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 \ud835\udd39) : x \u2286\u1d2e y \u2293 y \u2286\u1d2e x \u2264 x =\u1d2e 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 \ud835\udd39) : x =\u1d2e y \u2264 x \u2286\u1d2e y \u2293 y \u2286\u1d2e 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 \ud835\udd39} : x =\u1d2e y = x \u2286\u1d2e y \u2293 y \u2286\u1d2e x :=\nby apply le_antisymm; [apply subset_subset_of_eq, apply eq_of_subset_subset]\n\nlemma subset_subset_of_eq' {x y : bSet \ud835\udd39} {\u0393} (H : \u0393 \u2264 x =\u1d2e y) : \u0393 \u2264 x \u2286\u1d2e y \u2227 \u0393 \u2264 y \u2286\u1d2e x :=\nby {rw[eq_iff_subset_subset] at H, bv_split, exact \u27e8\u2039_\u203a,\u2039_\u203a\u27e9}\n\nlemma subset_of_eq {x y} {\u0393 : \ud835\udd39} (H : \u0393 \u2264 x =\u1d2e y) : \u0393 \u2264 x \u2286\u1d2e y :=\n(subset_subset_of_eq' H).left\n\n@[simp]lemma subset_self {x : bSet \ud835\udd39} {\u0393 : \ud835\udd39} : \u0393 \u2264 x \u2286\u1d2e x :=\nby { apply le_trans, apply le_top,\n     rw[show \u22a4 = x =\u1d2e x, by simp[bv_eq_refl]], rw[eq_iff_subset_subset], exact inf_le_left }\n\ntheorem subset_ext {x y : bSet \ud835\udd39} {\u0393 : \ud835\udd39} (h\u2081 : \u0393 \u2264 x \u2286\u1d2e y) (h\u2082 : \u0393 \u2264 y \u2286\u1d2e x) : \u0393 \u2264 x =\u1d2e y :=\nbegin\n  apply bv_have h\u2082, rw[deduction], apply bv_have h\u2081, rw[<-deduction],\n  ac_change \u0393 \u2293 (x \u2286\u1d2e y \u2293 y \u2286\u1d2e x) \u2264 x =\u1d2e y, apply inf_le_right_of_le,\n  apply eq_of_subset_subset\nend\n\ntheorem bv_eq_trans {x y z : bSet \ud835\udd39} : (x =\u1d2e y \u2293 y =\u1d2e z) \u2264 x =\u1d2e z :=\nbegin\n    induction x with \u03b1 A B generalizing y z,\n    cases y with \u03b1' A' B',\n    induction z with \u03b1'' A'' B'',\n    have H1 : \u2200 a : \u03b1, \u2200 a' : \u03b1', \u2200 a'' : \u03b1'',\n           (((A a =\u1d2e A' a') \u2293 (A' a' =\u1d2e A'' a'')) \u2293 B'' a'') \u2264 (A a =\u1d2e A'' a'' \u2293 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 : \u2200 i'' : \u03b1'', \u2200 a' : \u03b1', \u2200 a : \u03b1,\n           A'' i'' =\u1d2e A' a' \u2293 A' a' =\u1d2e A a \u2293 B a \u2264 A'' i'' =\u1d2e A a \u2293 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 _ \u2264 (A i) \u2208\u1d2e \u27e8\u03b1'', A'', B''\u27e9,\n       have this1 : \u27e8\u03b1, A, B\u27e9 =\u1d2e \u27e8\u03b1', A', B'\u27e9 \u2293 B i \u2264 A i \u2208\u1d2e \u27e8\u03b1', A', B'\u27e9,\n       by  {rw[deduction], from inf_le_left_of_le (infi_le _ _)},\n       suffices : A i \u2208\u1d2e \u27e8\u03b1', A', B'\u27e9 \u2293 \u27e8\u03b1', A', B'\u27e9 =\u1d2e \u27e8\u03b1'', A'', B''\u27e9 \u2264 A i \u2208\u1d2e \u27e8\u03b1'', A'', B''\u27e9,\n         by {have := le_trans (inf_le_inf this1 (by refl)) this,\n              convert this using 1, ac_refl },\n       suffices : \u2200 a', \u27e8\u03b1', A', B'\u27e9 =\u1d2e \u27e8\u03b1'', A'', B''\u27e9 \u2293 A i =\u1d2e A' a' \u2293 B' a' \u2264 A i \u2208\u1d2e \u27e8\u03b1'', A'', B''\u27e9,\n         by {convert (supr_le this) using 1, simp[mem, inf_comm, inf_supr_eq],\n            congr, ext, ac_refl},\n       have this2 : \u2200 a', \u27e8\u03b1', A', B'\u27e9 =\u1d2e \u27e8\u03b1'', A'', B''\u27e9 \u2293 B' a' \u2264 A' a' \u2208\u1d2e \u27e8\u03b1'', A'', B''\u27e9,\n         by {intro a', rw[deduction], apply inf_le_left_of_le, apply infi_le},\n       suffices : \u2200 a', A i =\u1d2e A' a' \u2293 A' a' \u2208\u1d2e \u27e8\u03b1'', A'', B''\u27e9 \u2264 A i \u2208\u1d2e \u27e8\u03b1'', A'', B''\u27e9,\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 =\u1d2e A' a' \u2293 (A' a' =\u1d2e A'' a'' \u2293 B'' a'')\n         = A i =\u1d2e A' a' \u2293 A' a' =\u1d2e A'' a'' \u2293 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 _ \u2264 (A'' i'') \u2208\u1d2e \u27e8\u03b1, A, B\u27e9,\n        have this1 : \u27e8\u03b1'', A'', B''\u27e9 =\u1d2e \u27e8\u03b1', A', B'\u27e9 \u2293 B'' i'' \u2264 A'' i'' \u2208\u1d2e \u27e8\u03b1', A', B'\u27e9,\n          by {rw[deduction], apply inf_le_left_of_le, apply infi_le},\n        suffices : A'' i'' \u2208\u1d2e \u27e8\u03b1', A', B'\u27e9 \u2293 \u27e8\u03b1', A', B'\u27e9 =\u1d2e \u27e8\u03b1, A, B\u27e9 \u2264 A'' i'' \u2208\u1d2e \u27e8\u03b1, A, B\u27e9,\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 : \u2200 a', \u27e8\u03b1', A', B'\u27e9 =\u1d2e \u27e8\u03b1, A, B\u27e9 \u2293 A'' i'' =\u1d2e A' a' \u2293 B' a' \u2264 A'' i'' \u2208\u1d2e \u27e8\u03b1, A, B\u27e9,\n          by {convert (supr_le this) using 1, simp[mem, inf_comm, inf_supr_eq],\n            congr, ext, ac_refl},\n        have this2 : \u2200 a', \u27e8\u03b1', A', B'\u27e9 =\u1d2e \u27e8\u03b1, A, B\u27e9 \u2293 B' a' \u2264 A' a' \u2208\u1d2e \u27e8\u03b1, A, B\u27e9,\n          by {intro a', rw[deduction], apply inf_le_left_of_le, apply infi_le},\n        suffices : \u2200 a', A'' i'' =\u1d2e A' a' \u2293 A' a' \u2208\u1d2e \u27e8\u03b1, A, B\u27e9 \u2264 A'' i'' \u2208\u1d2e \u27e8\u03b1, A, B\u27e9,\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'' =\u1d2e A' a' \u2293 (A' a' =\u1d2e A a \u2293 B a)\n          = A'' i'' =\u1d2e A' a' \u2293 A' a' =\u1d2e A a \u2293 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 {\u0393 : \ud835\udd39} {a\u2081 a\u2082 a\u2083 : bSet \ud835\udd39} (H\u2081 : \u0393 \u2264 a\u2081 =\u1d2e a\u2082) (H\u2082 : \u0393 \u2264 a\u2082 =\u1d2e a\u2083) :\n  \u0393 \u2264 a\u2081 =\u1d2e a\u2083 :=\nle_trans (le_inf_iff.mpr \u27e8H\u2081,H\u2082\u27e9) bv_eq_trans\n\n@[symm]lemma bv_symm {\u0393} {x y : bSet \ud835\udd39} (H : \u0393 \u2264 x =\u1d2e y) : \u0393 \u2264 y =\u1d2e x := by rwa[bv_eq_symm]\n\nlemma bv_rw {x y : bSet \ud835\udd39} (H : x =\u1d2e y = \u22a4) (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) {h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y} : \u03d5 y = \u03d5 x :=\nbegin\n  apply le_antisymm, swap, rw[show \u03d5 x = \u03d5 x \u2293 \u22a4, by simp], rw[<-H, inf_comm], apply h_congr,\n  rw[show \u03d5 y = \u03d5 y \u2293 \u22a4, by simp], rw[<-H, inf_comm, bv_eq_symm], apply h_congr\nend\n\n/-- If u = v and u \u2208 w, then this implies that v \u2208 w -/\nlemma subst_congr_mem_left {u v w : bSet \ud835\udd39} : u =\u1d2e v \u2293 u \u2208\u1d2e w \u2264 v \u2208\u1d2e 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 \u2039_\u203a (bv_trans (bv_symm \u2039_\u203a) \u2039_\u203a)\nend\n\n-- to derive primed versions of lemmas, use poset_yoneda_inv\n@[simp]lemma subst_congr_mem_left' {\u0393 : \ud835\udd39} {u v w : bSet \ud835\udd39} : \u0393 \u2264 u =\u1d2e v \u2192 \u0393 \u2264 u \u2208\u1d2e w \u2192 \u0393 \u2264 v \u2208\u1d2e w :=\n  \u03bb _ _, poset_yoneda_inv _ subst_congr_mem_left $ le_inf \u2039_\u203a \u2039_\u203a\n\n-- example {u v w : bSet \ud835\udd39} : u =\u1d2e v \u2293 u \u2208\u1d2e w \u2264 v \u2208\u1d2e 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 \u2039_\u203a _,\n--   from bv_trans (bv_symm a_left) \u2039_\u203a\n-- end\n\n/-- If v = w and u \u2208 v, then this implies that u \u2208 w -/\nlemma subst_congr_mem_right {u v w : bSet \ud835\udd39} : (v =\u1d2e w \u2293 u \u2208\u1d2e v) \u2264 u \u2208\u1d2e w :=\nbegin\n  induction v, erw[inf_supr_eq], apply supr_le, intro i,\n  suffices : mk v_\u03b1 \u2039_\u203a \u2039_\u203a =\u1d2e w \u2293 v_B i \u2264 v_A i \u2208\u1d2e w,\n  have := le_trans (inf_le_inf this (by refl : u =\u1d2e v_A i \u2264 u =\u1d2e 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' {\u0393 : \ud835\udd39} {u v w : bSet \ud835\udd39} : \u0393 \u2264 w =\u1d2e v \u2192 \u0393 \u2264 u \u2208\u1d2e w \u2192 \u0393 \u2264 u \u2208\u1d2e v :=\n  \u03bb _ _, poset_yoneda_inv _ subst_congr_mem_right $ le_inf \u2039_\u203a \u2039_\u203a\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 \ud835\udd39} {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39 } {h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y} :\n  (\u2a05(i_x : v.type), (v.bval i_x \u27f9 \u03d5 (v.func i_x))) = (\u2a05(x : bSet \ud835\udd39), x \u2208\u1d2e v \u27f9 \u03d5 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 \ud835\udd39} {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} {h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y} :\n  (\u2a06(i_x : v.type), (v.bval i_x \u2293 \u03d5(v.func i_x))) = (\u2a06(x : bSet \ud835\udd39), x \u2208\u1d2e v \u2293 \u03d5 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 \u2293 (x =\u1d2e func v i_x \u2293 \u03d5 x) \u2264 bval v i_x \u2293 \u03d5 (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 \ud835\udd39} : u \u2208\u1d2e v = \u2a06z, z \u2208\u1d2e v \u2293 u =\u1d2e z :=\nby {rw[<-bounded_exists, mem_unfold], intros x y,\n    ac_change y =\u1d2e x \u2293 x =\u1d2e u \u2264 y =\u1d2e u,\n    simp[bv_eq_symm], exact bv_eq_symm, exact bv_eq_trans }\n\nlemma subset_unfold' {x u : bSet \ud835\udd39} : x \u2286\u1d2e u = \u2a05(w : bSet \ud835\udd39), w \u2208\u1d2e x \u27f9 w \u2208\u1d2e u :=\nbegin\n  simp only [subset_unfold], have := @bounded_forall \ud835\udd39 _ x (\u03bb y, y\u2208\u1d2e u),\n  dsimp at this, rw[this], intros, apply subst_congr_mem_left\nend\n\nlemma bv_eq_unfold' {x y : bSet \ud835\udd39} : x =\u1d2e y = (\u2a05 z, z \u2208\u1d2e x \u27f9 z \u2208\u1d2e y) \u2293 (\u2a05 z, z \u2208\u1d2e y \u27f9 z \u2208\u1d2e x) :=\nbegin\n  rw eq_iff_subset_subset, rw [subset_unfold', subset_unfold']\nend\n\ntheorem mem_ext {x y : bSet \ud835\udd39} {\u0393 : \ud835\udd39} (h\u2081 : \u0393 \u2264 \u2a05z, z \u2208\u1d2e x \u27f9 z \u2208\u1d2e y) (h\u2082 : \u0393 \u2264 \u2a05z, z \u2208\u1d2e y \u27f9 z \u2208\u1d2e x) : \u0393 \u2264 x =\u1d2e y :=\nby {[smt] eblast_using [subset_ext, subset_unfold']}\n\n@[simp]lemma subset_self_eq_top {x : bSet \ud835\udd39} : x \u2286\u1d2e x = \u22a4 :=\ntop_unique subset_self\n\nlemma subset_trans {x y z : bSet \ud835\udd39} : x \u2286\u1d2e y \u2293 y \u2286\u1d2e z \u2264 x \u2286\u1d2e 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 \u2208\u1d2e x \u27f9 i_z \u2208\u1d2e y)  \u2293 i_z \u2208\u1d2e x \u2293 (i_z \u2208\u1d2e y \u27f9 i_z \u2208\u1d2e z) \u2264 i_z \u2208\u1d2e z,\n  rw[deduction], let H := _, change ((H \u27f9 _) \u2293 H : \ud835\udd39) \u2264 _,\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 \ud835\udd39} {\u0393 : \ud835\udd39} (H\u2081 : \u0393 \u2264 x \u2286\u1d2e y) (H\u2082 : \u0393 \u2264 y \u2286\u1d2e z) : \u0393 \u2264 x \u2286\u1d2e z :=\nposet_yoneda_inv \u0393 subset_trans $ le_inf \u2039_\u203a \u2039_\u203a\n\n-- lemma subset_trans_context {x y z : bSet \ud835\udd39} {c : \ud835\udd39} {h\u2081 : c \u2264 x \u2286\u1d2e y} {h\u2082 : c \u2264 y \u2286\u1d2e z} : c \u2264 x \u2286\u1d2e z :=\n-- begin\n--   apply bv_have h\u2082, rw[deduction], apply bv_have h\u2081, rw[<-deduction],\n--   ac_change c \u2293 (x \u2286\u1d2e y \u2293 y \u2286\u1d2e z) \u2264 x \u2286\u1d2e 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 \ud835\udd39} {\u0393} (H\u2082 : \u0393 \u2264 y \u2286\u1d2e z) (H\u2081 : \u0393 \u2264 x \u2208\u1d2e y) : \u0393 \u2264 x \u2208\u1d2e z :=\nby {rw[subset_unfold'] at H\u2082, from H\u2082 x \u2039_\u203a}\n\n-- lemma bounded_forall' {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39 } {h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y} {v : bSet \ud835\udd39} :\n--   (\u2a05(i_x : v.type), (v.bval i_x \u27f9 \u03d5 (v.func i_x))) = (\u2a05(x : bSet \ud835\udd39), x \u2208\u1d2e v \u27f9 \u03d5 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 \u2286\u1d2e u) \u2293 (x =\u1d2e v) : \ud835\udd39) \u2264 (x \u2286\u1d2e u) :=\nbegin\n  simp only [subset_unfold],\n  have H\u2081 := @bounded_forall _ _ v (\u03bb x, x \u2208\u1d2e u)\n    (by {intros, apply subst_congr_mem_left}),\n  have H\u2082 := @bounded_forall _ _ x (\u03bb x, x \u2208\u1d2e u)\n    (by {intros, apply subst_congr_mem_left}),\n  rw[H\u2081, H\u2082], 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 \u2286\u1d2e u) \u2293 (u =\u1d2e x) : \ud835\udd39) \u2264 (v \u2286\u1d2e x) :=\nbegin\n  simp only [subset_unfold], bv_intro j, apply bv_specialize_left j,\n  rw[<-deduction], ac_change ((bval v j \u27f9 func v j \u2208\u1d2e u) \u2293 bval v j) \u2293  u =\u1d2e x \u2264 func v j \u2208\u1d2e 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 : \u0393 \u2264 x =\u1d2e 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'\u2080 {x y : bSet \ud835\udd39} {\u0393 : \ud835\udd39} (H : \u0393 \u2264 x =\u1d2e y) {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} {h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y} {H_new : \u0393 \u2264 \u03d5 y} : \u0393 \u2264 \u03d5 x :=\nbegin\n  have : \u0393 \u2264 y =\u1d2e x \u2293 \u03d5 y,\n    by {apply le_inf, rw[bv_eq_symm], from \u2039_\u203a, from \u2039_\u203a},\n  from (poset_yoneda_inv _ (h_congr _ _) this)\nend\n\n-- TODO(jesse) maybe replace this with typeclasses instead?\n@[reducible]def B_ext (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) : Prop :=\n  \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y\n\n-- use `apply bv_rw' (H : \u0393 \u2264 x =\u1d2e 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 \ud835\udd39} {\u0393 : \ud835\udd39} (H : \u0393 \u2264 x =\u1d2e y) {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} {h_congr : B_ext \u03d5} {H_new : \u0393 \u2264 \u03d5 y} : \u0393 \u2264 \u03d5 x :=\nby apply bv_rw'\u2080; from \u2039_\u203a\n\n@[simp]lemma B_ext_bv_eq_left {y : bSet \ud835\udd39} : B_ext (\u03bb x, x =\u1d2e 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 \ud835\udd39} : B_ext (\u03bb y, x =\u1d2e y) :=\nby {unfold B_ext, intros, rw[inf_comm], apply bv_eq_trans}\n\n@[simp]lemma B_ext_mem_left {y : bSet \ud835\udd39} : B_ext (\u03bb x, x \u2208\u1d2e y) :=\nby unfold B_ext; intros; apply subst_congr_mem_left\n\n@[simp]lemma B_ext_mem_right {x : bSet \ud835\udd39} : B_ext (\u03bb y, x \u2208\u1d2e y) :=\nby unfold B_ext; intros; apply subst_congr_mem_right\n\n@[simp]lemma B_ext_subset_left {y : bSet \ud835\udd39} : B_ext (\u03bb x, x \u2286\u1d2e 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 \ud835\udd39} : B_ext (\u03bb y, x \u2286\u1d2e y) :=\nby {unfold B_ext, intros, rw[inf_comm], apply subst_congr_subset_right}\n\n@[simp]lemma B_ext_sup {\u03d5\u2081 \u03d5\u2082 : bSet \ud835\udd39 \u2192 \ud835\udd39} {h\u2081 : B_ext \u03d5\u2081} {h\u2082 : B_ext \u03d5\u2082} :\n  B_ext (\u03bb x, \u03d5\u2081 x \u2294 \u03d5\u2082 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\u2081, apply h\u2082]\nend\n\n@[simp]lemma B_ext_inf {\u03d5\u2081 \u03d5\u2082 : bSet \ud835\udd39 \u2192 \ud835\udd39} (h\u2081 : B_ext \u03d5\u2081) (h\u2082 : B_ext \u03d5\u2082) :\n  B_ext (\u03bb x, \u03d5\u2081 x \u2293 \u03d5\u2082 x) :=\nbegin\n  intros x y, tidy_context, refine \u27e8_,_\u27e9,\n    { apply bv_rw' (bv_symm a_left); from \u2039_\u203a },\n    { apply bv_rw' (bv_symm a_left); from \u2039_\u203a }\nend\n\n@[simp]lemma B_ext_imp {\u03d5\u2081 \u03d5\u2082 : bSet \ud835\udd39 \u2192 \ud835\udd39} {h\u2081 : B_ext \u03d5\u2081} {h\u2082 : B_ext \u03d5\u2082} :\n  B_ext (\u03bb x, \u03d5\u2081 x \u27f9 \u03d5\u2082 x) :=\nbegin\n  intros x y, rw[<-deduction],\n  tidy_context, apply bv_rw' (bv_symm a_left_left), from \u2039_\u203a,\n  refine a_left_right _, apply bv_rw' a_left_left; from \u2039_\u203a\nend\n\n@[simp]lemma B_ext_const {b : \ud835\udd39} : B_ext (\u03bb x, b) :=\nby tidy\n\n@[simp]lemma B_ext_neg {\u03d5\u2081 : bSet \ud835\udd39 \u2192 \ud835\udd39} {h : B_ext \u03d5\u2081} : B_ext (\u03bb x, - \u03d5\u2081 x) :=\nby {simp only [imp_bot.symm], apply B_ext_imp, simpa, from B_ext_const}\n\n@[simp]lemma B_ext_infi {\u03b9 : Type*} {\u03a8 : \u03b9 \u2192 (bSet \ud835\udd39 \u2192 \ud835\udd39)} {h : \u2200 i, B_ext $ \u03a8 i} : B_ext (\u03bb x, \u2a05i, \u03a8 i x) :=\nby {intros x y, dsimp, bv_intro i, apply bv_specialize_right i, apply h}\n\n@[simp]lemma B_ext_supr {\u03b9 : Type*} {\u03c8 : \u03b9 \u2192 (bSet \ud835\udd39 \u2192 \ud835\udd39)} {h : \u2200i, B_ext $ \u03c8 i} : B_ext (\u03bb x, \u2a06i, \u03c8 i x) :=\nby {intros x y, dsimp, apply bv_cases_right, intro i, apply bv_use i, apply h}\n\nexample {y : bSet \ud835\udd39} : B_ext (\u03bb x : bSet \ud835\udd39, x \u2208\u1d2e y \u2294 y \u2208\u1d2e x) := by change B_ext _; simp\n\n@[reducible]def B_congr (t : bSet \ud835\udd39 \u2192 bSet \ud835\udd39) : Prop := \u2200 {x\u2081 x\u2082}, \u2200 {\u0393 : \ud835\udd39}, \u0393 \u2264 x\u2081 =\u1d2e x\u2082 \u2192 \u0393 \u2264 t x\u2081 =\u1d2e t x\u2082\n\nmeta def H_congr_handler : tactic unit := `[simp]\n\n@[simp]lemma B_ext_term (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) (t : bSet \ud835\udd39 \u2192 bSet \ud835\udd39) (H : B_ext \u03d5 . H_congr_handler) (H' : B_congr t . H_congr_handler) :\n  B_ext (\u03bb z, \u03d5 ((\u03bb w, t w) z) ) :=\nbegin\n  intros x y, tidy_context,\n  suffices : \u0393 \u2264 t x =\u1d2e t y,\n    by {apply bv_rw' (bv_symm this), from \u2039_\u203a, from \u2039_\u203a},\n  exact H' \u2039_\u203a\nend\n\n-- use for rewriting in the second argument using the first\nlemma bv_rw'' {x y : bSet \ud835\udd39} {\u0393 : \ud835\udd39} (H : \u0393 \u2264 x =\u1d2e y) {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} (H_new : \u0393 \u2264 \u03d5 x) (h_congr : B_ext \u03d5 . H_congr_handler) : \u0393 \u2264 \u03d5 y :=\nbegin\n  have : \u0393 \u2264 x =\u1d2e y \u2293 \u03d5 x,\n    by {apply le_inf, from \u2039_\u203a, from \u2039_\u203a},\n  from (poset_yoneda_inv _ (h_congr _ _) this)\nend\n\nlemma mem_congr {\u0393 : \ud835\udd39} {x\u2081 x\u2082 y\u2081 y\u2082 : bSet \ud835\udd39} (H\u2081 : \u0393 \u2264 x\u2081 =\u1d2e y\u2081) (H\u2082 : \u0393 \u2264 x\u2082 =\u1d2e y\u2082) (H\u2083 : \u0393 \u2264 x\u2081 \u2208\u1d2e x\u2082) :\n  \u0393 \u2264 y\u2081 \u2208\u1d2e y\u2082 :=\nby {rw[bv_eq_symm] at H\u2081 H\u2082, apply bv_rw' H\u2081, simp, apply bv_rw' H\u2082, simpa}\n\n@[instance]def b_setoid (\u0393 : \ud835\udd39) : setoid (bSet \ud835\udd39) :=\n{ r := bv_eq' \u0393,\n  iseqv := \u27e8\u03bb _, bv_refl, \u03bb _ _, bv_symm, \u03bb _ _ _, bv_trans\u27e9 }\n\nlemma bv_cc.mk_iff {\u0393} {x y : bSet \ud835\udd39} : \u0393 \u2264 x =\u1d2e y \u2194 (@quotient.mk _ (b_setoid \u0393) x) = (@quotient.mk _ (b_setoid \u0393) y) := by rw [quotient.eq]; refl\n\nlemma bv_cc.mk {\u0393} {x y : bSet \ud835\udd39} (H : \u0393 \u2264 x =\u1d2e y) : (@quotient.mk _ (b_setoid \u0393) x) = (@quotient.mk _ (b_setoid \u0393) y) := bv_cc.mk_iff.mp \u2039_\u203a\n\n-- TODO(jesse): automate the generation of these lemmas with typeclasses\ndef b_setoid_mem (\u0393 : \ud835\udd39) : quotient (b_setoid \u0393) \u2192 quotient (b_setoid \u0393) \u2192 Prop :=\n@quotient.lift\u2082 (bSet \ud835\udd39) (bSet \ud835\udd39) Prop (b_setoid \u0393) (b_setoid \u0393) (\u03bb x y, \u0393 \u2264 x \u2208\u1d2e y)\n  begin\n    intros a\u2081 a\u2082 b\u2081 b\u2082 H_eqv\u2081 H_eqv\u2082, dsimp, apply propext,\n    refine \u27e8_,_\u27e9; intro H,\n      all_goals { rw[<-quotient.eq, <-bv_cc.mk_iff] at H_eqv\u2081 H_eqv\u2082},\n      { exact mem_congr \u2039_\u203a \u2039_\u203a \u2039_\u203a },\n      { exact mem_congr (bv_symm H_eqv\u2081) (bv_symm H_eqv\u2082) \u2039_\u203a }\n  end\n\nlemma bv_cc.mk_mem_iff {\u0393} {x y : bSet \ud835\udd39} :\n  \u0393 \u2264 x \u2208\u1d2e y \u2194 b_setoid_mem \u0393 (@quotient.mk _ (b_setoid \u0393) x) (@quotient.mk _ (b_setoid \u0393) y) :=\nby rw b_setoid_mem; refl\n\nlemma bv_cc.mk_mem {\u0393} {x y : bSet \ud835\udd39} (H : \u0393 \u2264 x \u2208\u1d2e y) :\n  b_setoid_mem \u0393 (@quotient.mk _ (b_setoid \u0393) x) (@quotient.mk _ (b_setoid \u0393) y) :=\nbv_cc.mk_mem_iff.mp \u2039_\u203a\n\nexample {x y z : bSet \ud835\udd39} {\u0393 : \ud835\udd39} (H1 : \u0393 \u2264 x =\u1d2e y) (H2 : \u0393 \u2264 y =\u1d2e z) : \u0393 \u2264 x =\u1d2e 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 : \u03b1) F` assumes that F's first explicit argument is of type `\u03b1`\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 {\ud835\udd39} [nontrivial_complete_boolean_algebra \ud835\udd39] {a b c : \ud835\udd39} : ( a \u27f9 b ) \u2293 ( b \u27f9 c ) \u2264 a \u27f9 c :=\nbegin\n  tidy_context, bv_tauto\nend\n\nexample {\u03b1 \u03b2 : Type} (f : \u03b1 \u2192 \u03b2) (P : \u03b1 \u2192 Prop) (Q : \u03b2 \u2192 Prop) {a : \u03b1} (H : P a) (H' : P a) (C : \u2200 {a}, P a \u2192 Q (f a)) : true :=\nbegin\n  apply_at H C,\n  apply_all C, triv\nend\n\nnamespace bSet\n\nvariables {\ud835\udd39 : Type u} [nontrivial_complete_boolean_algebra \ud835\udd39]\n\nexample {x y z x\u2081 y\u2081 z\u2081: bSet \ud835\udd39} {\u0393 : \ud835\udd39} (H1 : \u0393 \u2264 x =\u1d2e y) (H2 : \u0393 \u2264 y =\u1d2e z)\n  (H3 : \u0393 \u2264 z =\u1d2e z\u2081) (H4 : \u0393 \u2264 z\u2081 =\u1d2e y\u2081) (H5 : \u0393 \u2264 y\u2081 =\u1d2e x\u2081)\n: \u0393 \u2264 x =\u1d2e x\u2081 :=\nby bv_cc -- :^)\n\nexample {x\u2081 y\u2081 x\u2082 y\u2082 : bSet \ud835\udd39} {\u0393} (H\u2081 : \u0393 \u2264 x\u2081 \u2208\u1d2e y\u2081) (H\u2082 : \u0393 \u2264 x\u2081 =\u1d2e x\u2082) (H\u2082 : \u0393 \u2264 y\u2081 =\u1d2e y\u2082) : \u0393 \u2264 x\u2082 \u2208\u1d2e y\u2082 :=\nby bv_cc -- :^)\n\nexample {a b c d e : bSet \ud835\udd39} : (a =\u1d2e b) \u2293 (b =\u1d2e c) \u2293 (c =\u1d2e d) \u2293 (d =\u1d2e e) \u2264 a =\u1d2e e :=\nby tidy_context; bv_cc\n\ndef is_definite (u : bSet \ud835\udd39) : Prop := \u2200 i : u.type, u.bval i = \u22a4\n\nlemma eq_empty {u : bSet \ud835\udd39} : u =\u1d2e \u2205 = -\u2a06i, 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 \ud835\udd39} {\u0393 : \ud835\udd39} : \u0393 \u2264 \u2205 \u2286\u1d2e x :=\nby rw[subset_unfold]; bv_intro; repeat{cases i}\n\nlemma empty_spec {x : bSet \ud835\udd39} {\u0393 : \ud835\udd39} : \u0393 \u2264 -(x \u2208\u1d2e \u2205) := by simp[mem_unfold]\n\nlemma bot_of_mem_empty {x : bSet \ud835\udd39} {\u0393 : \ud835\udd39} (H : \u0393 \u2264 x \u2208\u1d2e \u2205) : \u0393 \u2264 \u22a5 :=\nby {have := @empty_spec \ud835\udd39 _ x \u0393, rw[<-imp_bot] at this, from this H}\n\n@[simp]lemma subst_congr_insert1_left {u w v : bSet \ud835\udd39} : u =\u1d2e w \u2264 bSet.insert1 u v =\u1d2e bSet.insert1 w v :=\nbegin\n  rcases v with \u27e8\u03b1,A,B\u27e9, 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 \ud835\udd39} {c : \ud835\udd39} {h : c \u2264 u =\u1d2e w} : c \u2264 bSet.insert1 u v =\u1d2e bSet.insert1 w v :=\nby apply le_trans h; simp\n\n@[simp]lemma subst_congr_insert1_left'' {u w v : bSet \ud835\udd39} {c : \ud835\udd39} {h : c \u2264 u =\u1d2e w} : c \u2264 {v, u} =\u1d2e {v, w} :=\n  by {unfold has_insert.insert, apply subst_congr_insert1_left', from \u2039_\u203a}\n\n@[simp]lemma subst_congr_insert1_right {u w v : bSet \ud835\udd39} : u=\u1d2ew \u2264 bSet.insert1 v u =\u1d2e bSet.insert1 v w :=\nby {rcases u with \u27e8\u03b1,A,B\u27e9, rcases w with \u27e8\u03b1',A',B'\u27e9, 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 _ \u2293 _  \u2264 A i \u2208\u1d2e \u27e8\u03b1',A',B'\u27e9, rw \u2190 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 _ \u2264 A' i \u2208\u1d2e \u27e8\u03b1,A,B\u27e9, rw[\u2190bv_eq, bv_eq_symm], apply subst_congr_mem_right}\n\n@[simp]lemma subst_congr_insert1_right' {u w v : bSet \ud835\udd39} {c : \ud835\udd39} {h : c \u2264 u =\u1d2e w} : c \u2264 bSet.insert1 v u =\u1d2e 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 \ud835\udd39} {c : \ud835\udd39} {h : c \u2264 u =\u1d2e w} : c \u2264 {u,v} =\u1d2e {w,v} :=\n  by {unfold has_insert.insert, apply subst_congr_insert1_right', apply subst_congr_insert1_left', from \u2039_\u203a}\n\n/- some singleton lemmas -/\n\n@[simp]lemma eq_singleton_of_eq {x y : bSet \ud835\udd39} {c : \ud835\udd39} {h : c \u2264 x =\u1d2e y} : c \u2264 {x} =\u1d2e {y} :=\nby {apply subst_congr_insert1_left', from \u2039_\u203a}\n\nlemma eq_of_eq_singleton {x y : bSet \ud835\udd39} {c : \ud835\udd39} {h : c \u2264 {x} =\u1d2e {y}} : c \u2264 x =\u1d2e 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 \ud835\udd39} {c : \ud835\udd39} : c \u2264 {x} =\u1d2e {y} \u2194 c \u2264 x =\u1d2e y :=\nby {split; intros; [apply eq_of_eq_singleton, apply eq_singleton_of_eq]; from \u2039_\u203a}\n\nlemma singleton_unfold {x : bSet \ud835\udd39} : {x} = bSet.insert1 x \u2205 := rfl\n\n@[simp]lemma singleton_type {x : bSet \ud835\udd39} : type ({x} : bSet \ud835\udd39) = option (ulift _root_.empty) := rfl\n\n@[simp]lemma singleton_func {x : bSet \ud835\udd39} {o} : func ({x} : bSet \ud835\udd39) o = option.rec_on o x (empty.elim \u2218 ulift.down) := rfl\n\n@[simp]lemma singleton_bval {x : bSet \ud835\udd39} {o} : bval ({x} : bSet \ud835\udd39) o = option.rec_on o \u22a4 (empty.elim \u2218 ulift.down) := rfl\n\n@[simp]lemma singleton_bval_none {x : bSet \ud835\udd39} : bval ({x} : bSet \ud835\udd39) none = \u22a4 := rfl\n\n-- @[simp]lemma eq_of_eq_insert_right {u w v : bSet \ud835\udd39} {c : \ud835\udd39} {h : c \u2264 bSet.insert1 v u =\u1d2e bSet.insert1 v w} : c \u2264 u =\u1d2e 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/-- \u03d5 (x) is true if and only if the Boolean truth-value of \u03d5(x\u030c) is \u22a4-/\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 {\u03b9 : Type u} (a : \u03b9 \u2192 \ud835\udd39) (u : \u03b9 \u2192 bSet \ud835\udd39) : bSet \ud835\udd39 :=\n  \u27e8\u03a3(i : \u03b9), (u i).type,\n    \u03bbx, (u x.fst).func x.snd,\n      \u03bbx, \u2a06(j:\u03b9), a j \u2293 ((u x.fst).func x.snd) \u2208\u1d2e u j\u27e9\n\n/-- Given a\u2081 a\u2082 : \ud835\udd39, return the canonical map from ulift bool to \ud835\udd39 given by ff \u21a6 a\u2081 and tt \u21a6 a\u2082-/\n@[reducible]def bool.map {\u03b1 : Type*} (a\u2081 a\u2082 : \u03b1) : (ulift bool) \u2192 \u03b1 :=\n  \u03bb x, bool.rec_on (x.down) a\u2081 a\u2082\n\ndef two_term_mixture (a\u2081 a\u2082 : \ud835\udd39) (h_anti : a\u2081 \u2293 a\u2082 = \u22a5) (u\u2081 u\u2082 : bSet \ud835\udd39) : bSet \ud835\udd39 :=\n@mixture \ud835\udd39 _ (ulift bool) (bool.map a\u2081 a\u2082) (bool.map u\u2081 u\u2082)\n\n-- @[simp]lemma two_term_mixture_type (a\u2081 a\u2082 : \ud835\udd39) (h_anti : a\u2081 \u2293 a\u2082 = \u22a5) (u\u2081 u\u2082 : bSet \ud835\udd39) :\n--   (two_term_mixture a\u2081 a\u2082 h_anti u\u2081 u\u2082).type = (\u03a3(i : ulift bool), ((bool.map u\u2081 u\u2082) i).type) := sorry\n\nlemma two_term_mixture_h_star (a\u2081 a\u2082 : \ud835\udd39) (h_anti : a\u2081 \u2293 a\u2082 = \u22a5) (u\u2081 u\u2082 : bSet \ud835\udd39) :\n  \u2200 i j : (ulift bool), (bool.map a\u2081 a\u2082) i \u2293 (bool.map a\u2081 a\u2082) j \u2264 (bool.map u\u2081 u\u2082) i =\u1d2e (bool.map u\u2081 u\u2082) j :=\nbegin\n  intros i j, cases i, cases j, cases i; cases j; try{simp*},\n  change a\u2082 \u2293 a\u2081 \u2264 _, rw[inf_comm, h_anti], apply bot_le\nend\n\n@[simp]lemma bval_mixture {\u03b9 : Type u} {a : \u03b9 \u2192 \ud835\udd39} {u : \u03b9 \u2192 bSet \ud835\udd39} :\n  (mixture a u).bval = \u03bbx, \u2a06(j:\u03b9), a j \u2293 ((u x.fst).func x.snd) \u2208\u1d2e u j :=\n  by refl\n\n@[simp]lemma two_term_mixture_bval (a\u2081 a\u2082 : \ud835\udd39) (h_anti : a\u2081 \u2293 a\u2082 = \u22a5) (u\u2081 u\u2082 : bSet \ud835\udd39) : \u2200 i,\n  (two_term_mixture a\u2081 a\u2082 h_anti u\u2081 u\u2082).bval i = (a\u2081 \u2293 ((two_term_mixture a\u2081 a\u2082 h_anti u\u2081 u\u2082).func i \u2208\u1d2e u\u2081)) \u2294 (a\u2082 \u2293 ((two_term_mixture a\u2081 a\u2082 h_anti u\u2081 u\u2082).func i \u2208\u1d2e u\u2082)) := \u03bb 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 {\u03b9 : Type u} (a : \u03b9 \u2192 \ud835\udd39) (u : \u03b9 \u2192 bSet \ud835\udd39) : bSet \ud835\udd39 :=\n  \u27e8\u03a3(i : \u03b9), (u i).type, \u03bbx, (u x.fst).func x.snd, \u03bbx, a x.fst \u2293 (u x.fst).bval x.snd\u27e9\n\n/-- Mixing lemma, c.f. Bell's book or Lemma 1 of Hamkins-Seabold -/\nlemma mixing_lemma' {\u03b9 : Type u} (a : \u03b9 \u2192 \ud835\udd39) (\u03c4 : \u03b9 \u2192 bSet \ud835\udd39) (h_star : \u2200 i j : \u03b9, a i \u2293 a j \u2264 \u03c4 i =\u1d2e \u03c4 j) : \u2200 i : \u03b9, a i \u2264 (mixture a \u03c4) =\u1d2e \u03c4 i := \u03bb 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 \u2293 a j \u2293 func (\u03c4 (i_z.fst)) (i_z.snd) \u2208\u1d2e \u03c4 j \u2264 (\u03c4 i =\u1d2e \u03c4 j) \u2293 func (\u03c4 (i_z.fst)) (i_z.snd) \u2208\u1d2e \u03c4 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 \u2264 a i) _, dsimp only,\n  cases (\u03c4 i), refine le_supr_of_le i_z _, from le_inf (by refl) (by simp)}\nend\n\nlemma mixing_lemma {\u03b9 : Type u} (a : \u03b9 \u2192 \ud835\udd39) (\u03c4 : \u03b9 \u2192 bSet \ud835\udd39) (h_star : \u2200 i j : \u03b9, a i \u2293 a j \u2264 \u03c4 i =\u1d2e \u03c4 j) : \u2203 x, \u2200 i : \u03b9, a i \u2264 x =\u1d2e \u03c4 i :=\n by refine \u27e8mixture a \u03c4, \u03bb i, _\u27e9; apply mixing_lemma'; assumption\n\nlemma mixing_lemma_two_term (a\u2081 a\u2082 : \ud835\udd39) (h_anti : a\u2081 \u2293 a\u2082 = \u22a5) (u\u2081 u\u2082 : bSet \ud835\udd39) :\n  a\u2081 \u2264 (two_term_mixture a\u2081 a\u2082 h_anti u\u2081 u\u2082 =\u1d2e u\u2081) \u2227 a\u2082 \u2264 (two_term_mixture a\u2081 a\u2082 h_anti u\u2081 u\u2082 =\u1d2e u\u2082) :=\nbegin\n  have := mixing_lemma' (bool.map a\u2081 a\u2082) (bool.map u\u2081 u\u2082)\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 {\u03b9 : Type u} {a : \u03b9 \u2192 \ud835\udd39} {\u03c4 : \u03b9 \u2192 bSet \ud835\udd39} {h_anti : antichain (a '' set.univ)} {h_inj : function.injective a} :\n  \u2200 i j : \u03b9, a i \u2293 a j \u2264 \u03c4 i =\u1d2e \u03c4 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 {\u03b9 : Type u} {a : \u03b9 \u2192 \ud835\udd39} {\u03c4 : \u03b9 \u2192 bSet \ud835\udd39} {h_anti : antichain (a '' set.univ)} {h_index : \u2200 i j : \u03b9, i \u2260 j \u2192 a i \u2293 a j = \u22a5} :\n  \u2200 i j : \u03b9, a i \u2293 a j \u2264 \u03c4 i =\u1d2e \u03c4 j :=\n  \u03bb i j, by {haveI : decidable_eq \u03b9 := \u03bb _ _,\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 \ud835\udd39 : Type u to extract a small set witnessing quantification over all of bSet \ud835\udd39 -/\n\n/- i.e., in bSet \ud835\udd39, any existential quantification is equivalent to a bounded existential quantification. this is one place where it's crucial that \ud835\udd39 lives in the type universe out of which bSet \ud835\udd39 is being built -/\nsection smallness\nvariable {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39}\n\n@[reducible, simp]noncomputable def fiber_lift (b : \u03d5 '' set.univ) :=\nclassical.indefinite_description (\u03bb a : bSet \ud835\udd39, \u03d5 a = b.val) $\n  by {cases b.property, use w, exact h.right}\n\nnoncomputable def B_small_witness : bSet \ud835\udd39 :=\n\u27e8\u03d5 '' set.univ, \u03bb b, (fiber_lift b).val, \u03bb _, \u22a4\u27e9\n\n@[simp]lemma B_small_witness_spec : \u2200 b, \u03d5 ((@B_small_witness _ _ \u03d5).func b) = b.val :=\n  \u03bb b, (fiber_lift b).property\n\nlemma B_small_witness_supr : (\u2a06(x : bSet \ud835\udd39), \u03d5 x) = \u2a06(b : (@B_small_witness _ _ \u03d5).type), \u03d5 (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 \u03d5 x, simp only [set.image_univ, set.mem_range], exact \u27e8x, rfl\u27e9},\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 : \ud835\udd39) : set \ud835\udd39 := \u03bb y, y \u2260 b\n\nsection well_ordering\nvariables {\u03b1 : Type*} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [is_well_order \u03b1 r]\nlocal infix `\u227a`:50 := r\n\ndef down_set (a : \u03b1) : set \u03b1 := {a' | a' \u227a a}\n\ndef down_set' (a : \u03b1) : set \u03b1 := insert a $ down_set r a\n\nlemma down_set_trans {a b} {h : a \u227a b} : down_set r a \u2286 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 _ _ \u03d5) \u2192 type (@B_small_witness _ _ \u03d5) \u2192 Prop)\nvariable [is_well_order _ r]\nlocal infix `\u227a`:50 := r\n\nlemma down_set_mono_supr {a b} {h : a \u227a b} {s : type (@B_small_witness _ _ \u03d5) \u2192 \ud835\udd39} :\n (\u2a06(i \u2208 down_set r a), s i) \u2264 (\u2a06(i \u2208 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 \u227a b} {s : type (@B_small_witness _ _ \u03d5) \u2192 \ud835\udd39} :\n (\u2a06(i \u2208 down_set' r a), s i) \u2264 (\u2a06(i \u2208 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 : _ \u2192 \ud835\udd39 :=\n(\u03bb b : type (@B_small_witness _ _ \u03d5), b.val - (\u2a06(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 \u2260 y \u2192 x \u227a y \u2228 y \u227a x :=\n\u03bb H, by {[smt] eblast_using [trichotomy r x y]}\n\nlemma not_ge_of_in_down_set (a b) : a \u2208 down_set r b \u2192 \u00ac b \u227a a :=\nbegin\n  intros H H', have H'' : a \u227a 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 : \u2200 {i j}, i \u2260 j \u2192 (@witness_antichain _ _ \u03d5 r _) i \u2293 (@witness_antichain _ _ \u03d5 r _) j = \u22a5 :=\n\u03bb 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 \u0393 a,\n    simp only [le_inf_iff] at *, cases a, cases a_right, cases a_left,\n     replace a_right_right := a_right_right \u27e8x,\u2039_\u203a\u27e9, dsimp at a_right_right,\n     bv_contradiction},\n  { /- `tidy_context` says -/ apply poset_yoneda, intros \u0393 a,\n    simp only [le_inf_iff] at *, cases a, cases a_right, cases a_left,\n     replace a_left_right := a_left_right \u27e8y,\u2039_\u203a\u27e9, dsimp at a_left_right,\n     bv_contradiction}\nend\n\nlemma witness_antichain_antichain : antichain ((@witness_antichain _ _ \u03d5 r _) '' set.univ) :=\nbegin\n  intros x h_x y h_y h_neq, simp at h_x h_y, rcases h_y with \u27e8w_y, h_y\u27e9,\n  rcases h_x with \u27e8w_x, h_x\u27e9, rw[<-h_y, <-h_x],\n  apply witness_antichain_index, by_contra, cc\nend\n\nlemma witness_antichain_property : \u2200 b, (@witness_antichain _ _ \u03d5 r _) b \u2264 b.val :=\n  \u03bb b, by simp[witness_antichain, sub_eq]\n\nlemma supr_antichain2_contains : (\u2a06 (b' : type (@B_small_witness _ _ \u03d5)), \u03d5 (func (@B_small_witness _ _ \u03d5) b')) \u2264\n    \u2a06 (b : type (@B_small_witness _ _ \u03d5)), 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 \u22a4 \u2264 (A \u2294 _ : \ud835\udd39), apply le_trans (by simp : \u22a4 \u2264 A \u2294 -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 (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) (h_congr : B_ext \u03d5) : \u2203 u, (\u2a06(x:bSet \ud835\udd39), \u03d5 x) = \u03d5 u :=\nbegin\n  have := classical.indefinite_description _ (@ordinal.well_ordering_thm (type (@B_small_witness _ _ \u03d5))),\n  cases this with r inst_r,\n  haveI : is_well_order _ r := by assumption,\n  let w := @B_small_witness _ _ \u03d5,\n    have from_mixing_lemma := mixing_lemma ((witness_antichain r)) (w.func)\n      (\u03bb i j, by {by_cases i = j, finish, simp[witness_antichain_index r h]}),\n    rcases from_mixing_lemma with \u27e8u, H_w\u27e9,\n    use u, fapply le_antisymm,\n    {rw[B_small_witness_supr],\n     have H1 : (\u2a06(b : type B_small_witness), (witness_antichain r) b) \u2264 \u03d5 u,\n     apply supr_le, intro \u03be,\n    have this'' : \u2200 b, (witness_antichain r) b \u2264 u =\u1d2e func w b \u2293 b.val,\n      by {intro b, apply le_inf, apply H_w b, apply witness_antichain_property},\n    have this''' : \u2200 b, u =\u1d2e func w b \u2293 (\u03d5 (func B_small_witness b)) \u2264 \u03d5 u,\n      intro b, dsimp[w], rw[bv_eq_symm], apply h_congr, apply le_trans,\n      exact this'' \u03be, convert this''' \u03be, apply (B_small_witness_spec _).symm,\n   suffices H2 : (\u2a06(b' : type (@B_small_witness _ _ \u03d5)), \u03d5 (func B_small_witness b')) \u2264 \u2a06(b : type (@B_small_witness _ _ \u03d5)), (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 \ud835\udd39-valued existential -/\nlemma exists_convert {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} {\u0393 : \ud835\udd39} (H : \u0393 \u2264 \u2a06x, \u03d5 x) (H_congr : B_ext \u03d5 . H_congr_handler) : \u2203 u, \u0393 \u2264 \u03d5 u :=\nby {rcases (maximum_principle \u03d5 \u2039_\u203a) with \u27e8u, Hu\u27e9, use u, finish}\n\nlemma maximum_principle_verbose {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} {h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y} {b : \ud835\udd39} (h_eq_top L : (\u2a06(x:bSet \ud835\udd39), \u03d5 x) = b) : \u2203 u, \u03d5 u = b :=\n by cases maximum_principle \u03d5 h_congr with w h; from \u27e8w, by finish\u27e9\n\n/-- \"\u2203 x \u2208 u, \u03d5 x implies \u2203 x : bSet \ud835\udd39, \u03d5 x\", but this time, say it in Boolean -/\nlemma weaken_ex_scope {\u03b1 : Type*} (A : \u03b1 \u2192 bSet \ud835\udd39) (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39)  : (\u2a06(a : \u03b1), \u03d5 (A a)) \u2264 (\u2a06(x : bSet \ud835\udd39), \u03d5 x) :=\nsupr_le $ \u03bb a, le_supr_of_le (A a) (by refl)\n\nlemma maximum_principle_bounded_top {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} {h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y} {\u03b1 : Type*} {A : \u03b1 \u2192 bSet \ud835\udd39} (h_eq_top : (\u2a06(a:\u03b1), \u03d5 (A a)) = \u22a4) : \u2203 u, \u03d5 u = \u22a4 :=\n@maximum_principle_verbose \ud835\udd39 (by apply_instance) \u03d5 h_congr \u22a4 (by {have := weaken_ex_scope A \u03d5, finish}) (by {have := weaken_ex_scope A \u03d5, finish})\n\n/-- Convert a Boolean-valued \u2200\u2203-statement into a Prop-valued \u2200\u2203-statement\n  Given A : \u03b1 \u2192 bSet \ud835\udd39, a binary function \u03d5 : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 \ud835\udd39, a truth-value assignment\n  B : \u03b1 \u2192 \ud835\udd39, \u2200 i : \u03b1, there exists a y_i : bSet \ud835\udd39, such that\n  (B i \u27f9 \u03d5 (A i) y_i) \u2265 \u2a05(i:\u03b1), B i \u27f9 \u2a06(y : bSet \ud835\udd39), \u03d5(A i, bSet \ud835\udd39)\n\n  A more verbose, but maybe clearer way to see this is:\n  if there is an equality (\u2a05i-\u2a06j body i j) = b,\n  then for all i, there exists j, such that body i j \u2265 b\n\n  This is a consequence of the maximum principle.\n-/\nlemma AE_convert {\u03b1 \ud835\udd39 : Type*} [nontrivial_complete_boolean_algebra \ud835\udd39] (A : \u03b1 \u2192 bSet \ud835\udd39)\n  (B : \u03b1 \u2192 \ud835\udd39) (\u03d5 : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 \ud835\udd39) (h_congr : \u2200 z, B_ext (\u03bb x, \u03d5 z x)) :\n  \u2200 i : \u03b1, \u2203 y : bSet \ud835\udd39, (\u2a05(j:\u03b1), (B j \u27f9 \u2a06(z : bSet \ud835\udd39), \u03d5 (A j) z)) \u2264 (B i \u27f9 \u03d5 (A i) y) :=\n\u03bb i,\n  by {have := maximum_principle (\u03bb y, \u03d5 (A i) y)\n                (by {intros x y, apply h_congr}),\n      rcases this with \u27e8u', H'\u27e9, use u', apply infi_le_of_le i,\n      apply imp_le_of_right_le, from le_of_eq H'}\n\nlemma AE_convert' (\u03d5 : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 \ud835\udd39) (h_congr : \u2200 z, B_ext (\u03bb x, \u03d5 z x)) (x : bSet \ud835\udd39) :\n  \u2200 v : bSet \ud835\udd39, \u2203 w : bSet \ud835\udd39, \u2200 {\u0393 : \ud835\udd39}, (\u0393 \u2264 \u2a05 z, z \u2208\u1d2e x \u27f9 \u2a06 w, \u03d5 z w) \u2192 \u0393 \u2264 v \u2208\u1d2e x \u2192 \u0393 \u2264 \u03d5 v w :=\nbegin\n  intro v, have := maximum_principle (\u03bb y, \u03d5 v y) (by simp*),\n  rcases this with \u27e8u, Hu\u27e9, use u, intros \u0393 H_AE H_mem, dsimp at Hu, rw \u2190Hu,\n  change _ \u2264 \u2a06 y, _,\n  exact (H_AE v \u2039_\u203a)\nend\n\nsection mixing_corollaries\n-- The lemmas in this section are corollaries of the mixing lemma\nvariables (X u\u2081 u\u2082 : bSet \ud835\udd39) (a\u2081 a\u2082 : \ud835\udd39) (h_anti : a\u2081 \u2293 a\u2082 = \u22a5) (h_partition : a\u2081 \u2294 a\u2082 = \u22a4)\n\ninclude h_partition\nlemma two_term_mixture_mem_top (h\u2081 : u\u2081 \u2208\u1d2e X = \u22a4) (h\u2082 : u\u2082 \u2208\u1d2e X = \u22a4) :\n  two_term_mixture a\u2081 a\u2082 h_anti u\u2081 u\u2082 \u2208\u1d2e X = \u22a4:=\nbegin\n  let U := _, change U \u2208\u1d2e X= _, apply top_unique,\n  have : \u22a4 \u2264 U =\u1d2e u\u2081 \u2294 U =\u1d2e u\u2082,\n    by {rw[h_partition.symm],\n       have := mixing_lemma_two_term a\u2081 a\u2082 h_anti u\u2081 u\u2082,apply sup_le_sup, tidy},\n  have : \u22a4 \u2264 (U =\u1d2e u\u2081 \u2294 U =\u1d2e u\u2082) \u2293 (u\u2081 \u2208\u1d2e X \u2293 u\u2082 \u2208\u1d2e X),\n    by finish,\n  apply le_trans this, apply bv_or_elim_left;\n    [rw[<-inf_assoc], ac_change (U =\u1d2e u\u2082 \u2293 u\u2082 \u2208\u1d2e X) \u2293 u\u2081 \u2208\u1d2e X \u2264 U \u2208\u1d2e 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\u2081 = u\u2082 \u2286\u1d2e u\u2081) :\n  \u22a4 \u2264 u\u2082 \u2286\u1d2e (two_term_mixture a\u2081 a\u2082 h_anti u\u2081 u\u2082) :=\nbegin\n  let U := _, change _ \u2264 u\u2082 \u2286\u1d2e 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 \u27e8ulift.up tt,i\u27e9, 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\u2082, apply mem.mk},\n  {have : a\u2082 = - a\u2081, by apply eq_neg_of_partition; assumption,\n   conv {to_rhs, congr, skip, rw[this, H]}, rw[sup_comm], change _ \u2264 _ \u27f9 _,\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\u2082, apply mem.mk}\nend\nend mixing_corollaries\n\nlemma core_aux_lemma (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) (h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y) (h_definite : (\u2a06(w : bSet \ud835\udd39), \u03d5 w) = \u22a4) (v : bSet \ud835\udd39) :\n  \u2203 u : bSet \ud835\udd39, \u03d5 u = \u22a4 \u2227 \u03d5 v = u =\u1d2e v :=\nbegin\n  have := maximum_principle \u03d5 h_congr, cases this with w H_w,\n  let b := \u03d5 v, let u := two_term_mixture b (- b) (by simp) v w, use u,\n  have h_partition : b \u2294 (- b) = \u22a4, by simp,\n  have H_max : \u03d5 u = \u22a4,\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 \u03d5 w, rw[<-H_w, h_definite], apply le_top,\n    apply bv_or_elim; rw[bv_eq_symm]; apply h_congr},\n  refine \u27e8H_max, _\u27e9,\n  apply le_antisymm,\n    {apply (mixing_lemma_two_term _ _ _ _ _).left},\n    {suffices : u =\u1d2e v \u2293 \u03d5 u \u2264 \u03d5 v,\n      by {rw[H_max] at this, finish}, by apply h_congr}\nend\n\nlemma core_aux_lemma2 (\u03d5 \u03c8 : bSet \ud835\udd39 \u2192 \ud835\udd39) (h_congr\u03d5 : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y)\n  (h_congr\u03c8 : \u2200 x y, x =\u1d2e y \u2293 \u03c8 x \u2264 \u03c8 y) (h_sub : \u2200 u, \u03d5 u = \u22a4 \u2192 \u03c8 u = \u22a4)\n  (h_definite : (\u2a06(w : bSet \ud835\udd39), \u03d5 w) = \u22a4) :\n  (\u2a05(x : bSet \ud835\udd39), \u03d5 x \u27f9 \u03c8 x) = \u22a4 :=\nbegin\n  simp, intro x, have := core_aux_lemma \u03d5 h_congr\u03d5 h_definite x,\n  rcases this with \u27e8u, \u27e8h\u2081, h\u2082\u27e9\u27e9,\n  have := h_sub u \u2039_\u203a, rw[show \u03d5 x = \u03d5 x \u2293 \u22a4, by simp],\n  rw[<-this, h\u2082], apply h_congr\u03c8\nend\n\nsection smallness'\nvariables {\u03b1 : Type u} (\u03d5 : bSet \ud835\udd39 \u2192 \u03b1)\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 : \u03d5 '' set.univ) : {x : bSet \ud835\udd39 // \u03d5 x = b.val} :=\nclassical.indefinite_description (\u03bb a : bSet \ud835\udd39, \u03d5 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 {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) (E : \u03b2 \u2192 \u03b2 \u2192 Prop) : \u03b1 \u2192 \u03b1 \u2192 Prop :=\n\u03bb a\u2081 a\u2082, E (f a\u2081) (f a\u2082)\n\ndef core {\u03b1 : Type u} (u : bSet \ud835\udd39) (S : \u03b1 \u2192 bSet \ud835\udd39) : Prop :=\n(\u2200 x : \u03b1, S x \u2208\u1d2e u = \u22a4) \u2227 (\u2200 y : bSet \ud835\udd39, y \u2208\u1d2e u = \u22a4 \u2192 \u2203! x_y : \u03b1, y =\u1d2e S x_y = \u22a4)\n\nnoncomputable def core_witness {\u03b1 : Type u} {u : bSet \ud835\udd39} {S : \u03b1 \u2192 bSet \ud835\udd39} (h_core : core u S) (x : bSet \ud835\udd39) (h_X : x \u2208\u1d2e u = \u22a4) :\n  \u03a3' (x_y : \u03b1), x =\u1d2e S x_y = \u22a4 :=\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 {\u03b1 : Type u} (u : bSet \ud835\udd39) (S : \u03b1 \u2192 bSet \ud835\udd39) (h_core : core u S) : function.injective S :=\nbegin\n  intros x y H, cases h_core, have h_left\u2081 := h_core_left x, have h_left\u2082 := h_core_left y,\n  have this_right\u2081 := h_core_right (S x) h_left\u2081,\n  have this_right\u2082:= h_core_right (S y) h_left\u2082,\n  rcases this_right\u2081 with \u27e8w\u2081, \u27e8H\u2081, H\u2082\u27e9\u27e9, rcases this_right\u2082 with \u27e8w\u2082, \u27e8H\u2081', H\u2082'\u27e9\u27e9,\n  have Q\u2082 := H\u2082 y, have Q\u2083 := H\u2082 x (by apply bv_eq_refl), dsimp at *, rw[Q\u2082], swap, simpa[H]\nend\n\n/-- `core_inj` says that if a b : \u03b1 satisfy S a =\u1d2e S b = \u22a4, then a = b -/\nlemma core_inj' {\u03b1 : Type u} {u : bSet \ud835\udd39} {S : \u03b1 \u2192 bSet \ud835\udd39} (h_core : core u S) : \u2200 a b : \u03b1, S a =\u1d2e S b = \u22a4 \u2192 a = b :=\nbegin\n  intros x y H, cases h_core, have h_left\u2081 := h_core_left x, have h_left\u2082 := h_core_left y,\n  have this_right\u2081 := h_core_right (S x) h_left\u2081,\n  have this_right\u2082:= h_core_right (S y) h_left\u2082,\n  rcases this_right\u2081 with \u27e8w\u2081, \u27e8H\u2081, H\u2082\u27e9\u27e9, rcases this_right\u2082 with \u27e8w\u2082, \u27e8H\u2081', H\u2082'\u27e9\u27e9,\n  have Q\u2082 := H\u2082 y H, have Q\u2082 := H\u2082 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_\u03d5 (u : bSet \ud835\udd39) : bSet \ud835\udd39 \u2192 (u.type \u2192 \ud835\udd39) :=\n\u03bb x, (\u03bb a, (u.bval a) \u2293 x =\u1d2e u.func a )\n\nlemma core.mk_\u03d5_inj (u : bSet \ud835\udd39) (x y : bSet \ud835\udd39) : (x \u2208\u1d2e u = \u22a4) \u2192 (y \u2208\u1d2e u = \u22a4) \u2192 core.mk_\u03d5 u x = core.mk_\u03d5 u y \u2192 x =\u1d2e y = \u22a4 :=\nbegin\n  intros h\u2081 h\u2082 H, unfold core.mk_\u03d5 at H, replace H := congr_fun H,\n  apply top_unique,\n  have : \u2200 i_z : u.type, u.bval i_z \u2293 x =\u1d2e u.func i_z \u2293 u.bval i_z \u2293 u.func i_z =\u1d2e y  \u2264 x =\u1d2e y :=\n    \u03bb i_z, by {tidy_context, from bv_trans (\u2039_\u203a : \u0393 \u2264 x =\u1d2e func u i_z) \u2039_\u203a},\n    dsimp at H, simp[H] at this, rw[<-supr_le_iff] at this, rw[eq_top_iff] at h\u2082,\n    refine le_trans _ this, convert h\u2082, rw[mem_unfold], congr' 1, ext,\n    refine le_antisymm _ _; tidy_context, from \u27e8\u27e8\u27e8\u2039_\u203a,\u2039_\u203a\u27e9,\u2039_\u203a\u27e9, bv_symm \u2039_\u203a\u27e9\nend\n\nnoncomputable def core.S' (u : bSet \ud835\udd39) : (core.mk_\u03d5 u '' set.univ) \u2192 bSet \ud835\udd39 :=\n  \u03bb x, (fiber_lift' (core.mk_\u03d5 u) x).val\n\ndef core.\u03b1_S'' (u : bSet \ud835\udd39) : Type u := {i : core.mk_\u03d5 u '' set.univ // core.S' u i \u2208\u1d2e u = \u22a4}\n\nnoncomputable def core.S'' (u : bSet \ud835\udd39) : core.\u03b1_S'' u \u2192 bSet \ud835\udd39 := \u03bb x, core.S' u x.val\n\nlemma core.S'_spec (u : bSet \ud835\udd39) (x : core.mk_\u03d5 u '' set.univ) : core.mk_\u03d5 u (core.S' u x) = x.val :=\n by unfold core.S'; simp[(fiber_lift' (core.mk_\u03d5 u) x).property]\n\ndef core.bv_eq_top : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 Prop :=\n  \u03bb x\u2081 x\u2082, x\u2081 =\u1d2e x\u2082 = \u22a4\n\ndef core.bv_eq_top_setoid : setoid $ bSet \ud835\udd39 :=\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 \u22a4 = x =\u1d2e y \u2293 y =\u1d2e z, by finish],\n   apply bv_eq_trans}\nend}\n\ninstance core.S''_setoid (u : bSet \ud835\udd39) : setoid $ core.\u03b1_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\u2081 H\u2082, apply top_unique,\n  rw[show \u22a4 = (core.S'' u x) =\u1d2e (core.S'' u y) \u2293 (core.S'' u y) =\u1d2e (core.S'' u z), by finish],\n  apply bv_eq_trans\nend}\n\nnoncomputable def core.mk_aux (u : bSet \ud835\udd39) : (quotient (@core.S''_setoid \ud835\udd39 _ u)) \u2192 bSet \ud835\udd39 :=\n  \u03bb x, (core.S'' u) (@quotient.out _ (core.S''_setoid u ) x)\n\n@[reducible]private def image.mk {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192 \u03b2} (a : \u03b1) : f '' set.univ :=\n  \u27e8f a, by tidy\u27e9\n\nlemma core.mk (u : bSet \ud835\udd39) : \u2203 \u03b1 : Type u, \u2203 S : \u03b1 \u2192 bSet \ud835\udd39, core u S :=\nbegin\n  repeat{split}, show _ \u2192 bSet \ud835\udd39, exact core.mk_aux u,\n  {dsimp, intro x,unfold core.mk_aux, let y := _, change core.S'' u y \u2208\u1d2e u = _, apply y.property},\n  {intros y H_y, let y' := (core.S' u (image.mk y)),\n   have H_y' : core.mk_\u03d5 u y = core.mk_\u03d5 u y',\n     by rw[core.S'_spec],\n   have H_y'2 : y' \u2208\u1d2e u = \u22a4,\n     by {unfold core.mk_\u03d5 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 \u27e6by split; exact H_y'2\u27e7),\n   have H_y'' : y'' =\u1d2e y' = \u22a4,\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\u2083 : y =\u1d2e y' = \u22a4,\n     by {apply core.mk_\u03d5_inj, repeat{assumption}},\n   have H\u2081 : y =\u1d2e y'' = \u22a4,\n     by {apply top_unique, apply le_trans, show \ud835\udd39, from y =\u1d2e y' \u2293 y' =\u1d2e y'',\n           apply le_inf,\n             {rw[<-eq_top_iff], exact H\u2083},\n             {rw[<-eq_top_iff], convert H_y'' using 1, apply bv_eq_symm},\n         apply bv_eq_trans},\n   split, refine \u27e8H\u2081, _\u27e9, intros i H_y''',\n   suffices : core.mk_aux u i =\u1d2e y' = \u22a4,\n     by {have : core.mk_aux u i =\u1d2e y'' = \u22a4, 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 : \u27e6quotient.out i\u27e7 = \u27e6quotient.out \u27e6\u27e8image.mk y, H_y'2\u27e9\u27e7\u27e7,\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 \u22a4 = (core.mk_aux u i =\u1d2e y \u2293 y =\u1d2e y'), by {dsimp at H_y''', rw [H\u2083, H_y'''], simp}],\n   apply bv_eq_trans}\nend\n/-- Given a subset C of \u03b1, and an \u03b1-indexed core S, return the bSet whose underlying type is C,\n    such that A is the canonical inclusion and B is always \u22a4. -/\ndef bSet_of_core_set {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} (h : core u S) (C : set \u03b1) : bSet \ud835\udd39 :=\n\u27e8C, \u03bb x, S x, \u03bb x, \u22a4\u27e9\n\ndef bSet_of_core {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} (h : core u S) : bSet \ud835\udd39 :=\n  bSet_of_core_set h set.univ\n\n@[simp]lemma of_core_type {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} {h : core u S} {C : set \u03b1} :\n  (bSet_of_core_set h C).type = C := rfl\n@[simp]lemma of_core_bval {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} {h : core u S} {C : set \u03b1} {i} :\n  (bSet_of_core_set h C).bval i = \u22a4 := rfl\n\nlemma of_core_mem {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} {h : core u S} {C : set \u03b1} {i} :\n  \u22a4 \u2264 (bSet_of_core_set h C).func i \u2208\u1d2e u :=\ntop_le_iff.mpr (h.left _)\n\n/-- Given a core S for u, pull back the ordering -/\ndef subset' {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} (h : core u S) : \u03b1 \u2192 \u03b1 \u2192 Prop :=\n  \u03bb a\u2081 a\u2082, S a\u2081 \u2286\u1d2e S a\u2082 = \u22a4\n\nopen classical zorn\n\ndef subset'_partial_order {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} (h : core u S) : partial_order \u03b1 :=\n{ le := subset' h,\n  lt := \u03bb a\u2081 a\u2082, (subset' h a\u2081 a\u2082) \u2227 a\u2081 \u2260 a\u2082,\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 \u22a2,\n                   from subset_trans' \u2039_\u203a \u2039_\u203a},\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 _ \u27e8h_left, h_right\u27e9 this, contradiction},\n      suffices : a = b, by rw[this]; refl, apply core_inj' \u27e8h_left, h_right\u27e9, dsimp,\n      rw[eq_top_iff] at a_1_left a_1 \u22a2, from subset_ext \u2039_\u203a \u2039_\u203a\n    end,\n  le_antisymm :=\n    begin\n      intros a b H\u2081 H\u2082, apply core_inj' h, unfold subset' at H\u2081 H\u2082, rw[eq_top_iff] at H\u2081 H\u2082 \u22a2,\n      from subset_ext \u2039_\u203a \u2039_\u203a\n    end}\n\nlocal attribute [instance] subset'_partial_order\n\nlemma subset'_trans {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} {h : core u S} : by haveI := subset'_partial_order h; from \u2200 a b c : \u03b1, a \u2264 b \u2192 b \u2264 c \u2192 a \u2264 c :=\n  by apply partial_order.le_trans\n\nlemma subset'_unfold {u : bSet \ud835\udd39} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} {h : core u S} {a\u2081 a\u2082 : \u03b1} :\n  by {haveI := subset'_partial_order h, from a\u2081 \u2264 a\u2082 \u2192 (S a\u2081 \u2286\u1d2e S a\u2082 = \u22a4)} := by tidy\n\n@[reducible]def exists_mem (x : bSet \ud835\udd39) : \ud835\udd39 := \u2a06 (y : bSet \ud835\udd39), y \u2208\u1d2e x\n\n@[reducible]def not_empty (x : bSet \ud835\udd39) : \ud835\udd39 := - (x =\u1d2e \u2205)\n\n-- note: nonempty means \"not empty\"\nlemma exists_mem_of_nonempty (u : bSet \ud835\udd39) {\u0393 : \ud835\udd39} (H : \u0393 \u2264 -(u =\u1d2e \u2205)) : \u0393 \u2264 \u2a06x, x\u2208\u1d2e 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 \ud835\udd39) {\u0393 : \ud835\udd39} (H : \u0393 \u2264 (\u2a06x, x \u2208\u1d2e u)) : \u0393 \u2264 -(u =\u1d2e \u2205) :=\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 \ud835\udd39} {\u0393 : \ud835\udd39} : \u0393 \u2264 -(u =\u1d2e \u2205) \u2194 \u0393 \u2264 \u2a06x, x \u2208\u1d2e u :=\nbegin\n  refine \u27e8_,_\u27e9; intro H,\n    { exact exists_mem_of_nonempty _ \u2039_\u203a },\n    { exact nonempty_of_exists_mem _ \u2039_\u203a }\nend\n\nlemma empty_iff_forall_not_mem {u : bSet \ud835\udd39} {\u0393 : \ud835\udd39} : \u0393 \u2264 u=\u1d2e \u2205 \u2194 \u0393 \u2264 \u2a05 x, -(x \u2208\u1d2e u) :=\nbegin\n  refine \u27e8_,_\u27e9; intro H,\n    { apply bv_by_contra, bv_imp_intro H_contra, simp only with bv_push_neg at H_contra,\n      rw \u2190nonempty_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 \u2190neg_supr at H, bv_contradiction }\nend\n\nlemma core_aux_lemma3 (u : bSet \ud835\udd39) (h_nonempty : -(u =\u1d2e \u2205) = \u22a4) {\u03b1 : Type u} (S : \u03b1 \u2192 bSet \ud835\udd39) (h_core : core u S) : \u2200 x, \u2203 y \u2208 S '' set.univ, x =\u1d2e y = x \u2208\u1d2e u :=\nbegin\n  intro x, have := core_aux_lemma (\u03bb z, z\u2208\u1d2eu) (by intros; apply subst_congr_mem_left)\n    (by {apply top_unique, apply exists_mem_of_nonempty, simpa}) x,\n    rcases this with \u27e8y, \u27e8H\u2081, H\u2082\u27e9\u27e9, cases h_core with H_left H_right,\n    specialize H_right y H\u2081, cases H_right with y' H_y',\n    use S y', specialize H_left y', split, use y', finish,\n    dsimp at H\u2081 H\u2082, rw[H\u2082], cases H_y', have := bv_rw H_y'_left (\u03bb z, x =\u1d2e z),\n    simpa[bv_eq_symm] using this, intros x\u2081 y\u2081, dsimp, rw[inf_comm], exact bv_eq_trans\nend\n\nlemma core_mem_of_mem_image {u y} {\u03b1 : Type u} {S : \u03b1 \u2192 bSet \ud835\udd39} (h_core : core u S) :\n  y \u2208 S '' set.univ \u2192 y \u2208\u1d2e u = \u22a4 := 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}) \u2192 bSet \ud835\udd39\n| \u27e8\u03b1,A\u27e9 := \u27e8\u03b1, \u03bb a, check (A a), \u03bb a, \u22a4\u27e9\n\npostfix `\u030c `:8999 := check\n\n@[simp, cleanup]lemma check_type {\u03b1 : Type u} {A : \u03b1 \u2192 pSet} :\n  bSet.type ((pSet.mk \u03b1 A)\u030c  : bSet \ud835\udd39) = \u03b1 := rfl\n\n@[simp, cleanup]lemma check_type_infi {\u03b1 : Type u} {A : \u03b1 \u2192 pSet} {s : \u03b1 \u2192 \ud835\udd39} :\n  (\u2a05(a : bSet.type ((pSet.mk \u03b1 A)\u030c  : bSet \ud835\udd39)), s a) = (\u2a05(a : \u03b1), s a : \ud835\udd39) :=\nby refl\n\n@[simp, cleanup]lemma check_type_supr {\u03b1 : Type u} {A : \u03b1 \u2192 pSet} {s : \u03b1 \u2192 \ud835\udd39} :\n(\u2a06(a : bSet.type ((pSet.mk \u03b1 A)\u030c   : bSet \ud835\udd39)), s a) = (\u2a06(a : \u03b1), s a : \ud835\udd39) := rfl\n\n@[simp, cleanup]lemma pSet.type_mk {\u03b1 : Type u} {A : \u03b1 \u2192 pSet} : pSet.type (pSet.mk \u03b1 A) = \u03b1\n:= rfl\n\n@[simp, cleanup]lemma check_type' {x : pSet.{u}} : bSet.type (x\u030c : bSet \ud835\udd39) = x.type :=\nby {induction x, simp}\n\n@[simp, cleanup]lemma check_type'_set {x : pSet} : set (bSet.type (x\u030c : bSet \ud835\udd39)) = set (x.type) :=\nby {induction x, simp}\n\n@[reducible, simp]def check_cast {x : pSet} (i : (x\u030c : bSet \ud835\udd39).type) : x.type :=\ncast check_type' i\n\n@[reducible, simp]def check_cast.symm {x : pSet} (i : x.type) : (x\u030c : bSet \ud835\udd39).type :=\ncast check_type'.symm i\n\n@[reducible, simp] def check_cast_set {x : pSet} (S : set (x\u030c : bSet \ud835\udd39).type) : set (x.type) :=\ncast check_type'_set S\n\nlemma check_func {x : pSet} {i} :\n  (x\u030c : bSet \ud835\udd39).func i = (x.func (check_cast i))\u030c  :=\nby induction x; refl\n\nlemma check_unfold {x : pSet.{u}} : (x\u030c : bSet \ud835\udd39) = bSet.mk x.type (\u03bb i, (x.func i)\u030c ) (\u03bb i, \u22a4) :=\nby induction x; refl\n\n@[simp]lemma check_bval_top (x : pSet) {i} : (x\u030c : bSet \ud835\udd39).bval i = \u22a4 := by induction x; refl\n\n@[simp]lemma check_bval_mk {\u03b1 : Type u} {A : \u03b1 \u2192 pSet} {i} : ((pSet.mk \u03b1 A)\u030c ).bval i = (\u22a4 : \ud835\udd39) := rfl\n\n@[simp]lemma check_empty_eq_empty : (\u2205 : pSet)\u030c = (\u2205 : bSet \ud835\udd39) :=\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 \ud835\udd39} {i : u.type} {H_top : u.bval i = \u22a4} : u.func i \u2208\u1d2e u = \u22a4 :=\nby {apply top_unique, rw[<-H_top], apply mem.mk'}\n\n@[simp]lemma check_mem_top {x : pSet} {i : (x\u030c : bSet \ud835\udd39).type} : (x\u030c).func i \u2208\u1d2e x\u030c = \u22a4 :=\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} {\u0393 : \ud835\udd39} : \u0393 \u2264 ((x.func i) \u030c) \u2208\u1d2e (x\u030c) :=\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 \u2192 x\u030c =\u1d2e y\u030c = (\u22a4 : \ud835\udd39) :=\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 \u27e8w, h\u27e9, rcases a_right i with \u27e8w,h\u27e9];\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} {\u0393 : \ud835\udd39}  (H : pSet.equiv x y) :\n    (\u0393 : \ud835\udd39) \u2264 x\u030c =\u1d2e y\u030c :=\nle_trans (le_top) $ by {simp only [top_le_iff], apply check_bv_eq_top_of_equiv \u2039_\u203a}\n\nlemma check_eq {x y : pSet} {\u0393 : \ud835\udd39}  (H : pSet.equiv x y) :\n    (\u0393 : \ud835\udd39) \u2264 x\u030c =\u1d2e y\u030c := check_bv_eq H\n\n-- deprecated, use check_not_eq\nlemma check_bv_eq_bot_of_not_equiv {x y : pSet} :\n  (\u00ac pSet.equiv x y) \u2192 (x\u030c =\u1d2e y\u030c) = (\u22a5 : \ud835\udd39) :=\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\u030c =\u1d2e y\u030c = (\u22a4 : \ud835\udd39)) \u2228 (x\u030c =\u1d2e y\u030c = (\u22a5 : \ud835\udd39)) :=\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 \u2194 x\u030c =\u1d2e y\u030c = (\u22a4 : \ud835\udd39) :=\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 \u27e8w, h\u27e9,  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 \u27e8w, h\u27e9,  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 \u2039x_\u03b1\u203a) (y_A \u2039y_\u03b1\u203a), tidy}\nend\n\nlemma not_check_bv_eq_iff {x y : pSet} : \u00ac pSet.equiv x y \u2194 x\u030c =\u1d2e y\u030c = (\u22a5 : \ud835\udd39) :=\nbegin\n  refine \u27e8_,_\u27e9; intro H,\n    { exact check_bv_eq_bot_of_not_equiv \u2039_\u203a },\n    { intro H_equiv, have := check_bv_eq_top_of_equiv \u2039_\u203a,\n      suffices this : \u22a5 < (\u22a5 : \ud835\udd39), 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 : \u00ac pSet.equiv x y) {\u0393 : \ud835\udd39} : \u0393 \u2264 -(x\u030c =\u1d2e y\u030c) :=\nby {rw[not_check_bv_eq_iff.mp H], simp}\n\nlemma check_bv_eq_nonzero_iff_eq_top {x y : pSet} : (\u22a5 : \ud835\udd39) < x\u030c =\u1d2e y\u030c  \u2194 x\u030c =\u1d2e y\u030c = (\u22a4 : \ud835\udd39) :=\nbegin\n  refine \u27e8_,_\u27e9; intro H,\n    { by_contra, finish[or.resolve_left (check_bv_eq_dichotomy x y) \u2039_\u203a] },\n    { simp* }\nend\n\nlemma check_eq_reflect {x y : pSet} {\u0393 : \ud835\udd39} (H_lt : \u22a5 < \u0393) (H_mem : \u0393 \u2264 x\u030c =\u1d2e y\u030c) : 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 \u2190check_bv_eq_iff at this\nend\n\n@[simp]lemma check_insert (a b : pSet) : (pSet.insert a b)\u030c  = (bSet.insert1 (a\u030c) (b\u030c) : bSet \ud835\udd39) :=\nby {induction a, induction b, simp[pSet.insert, bSet.insert1], split; ext; cases x; simp}\n\nlemma mem_check_witness {y x : pSet.{u}} {\u0393 : \ud835\udd39} (h_nonzero : \u22a5 < \u0393) (H : \u0393 \u2264 y\u030c \u2208\u1d2e (x\u030c)) : \u2203 i : x.type, \u0393 \u2264 y\u030c =\u1d2e (x.func i)\u030c  :=\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 \u03bb a, (y\u030c : bSet \ud835\udd39) =\u1d2e (x.func a)\u030c, from \u0393,\n  from \u2039_\u203a, cases x, from H, swap, from \u2039_\u203a,\n  intros a H, by_contra,\n  cases (@check_bv_eq_dichotomy \ud835\udd39 _ y (pSet.func x a)),\n    { finish },\n    { contradiction }\nend\n\nlemma check_mem_iff {x y : pSet} : x \u2208 y \u2194 x\u030c \u2208\u1d2e y\u030c = (\u22a4 : \ud835\udd39) :=\nbegin\n  refine \u27e8_,_\u27e9; 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 \u27e8b, by rwa[top_le_iff, <-check_bv_eq_iff] at Hb\u27e9}\nend\n\nlemma not_check_mem_iff {x y : pSet} : x \u2209 y \u2194 x\u030c \u2208\u1d2e y\u030c = (\u22a5 : \ud835\udd39) :=\nbegin\n  refine \u27e8_,_\u27e9; 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 : \u22a5 < (\u22a5 : \ud835\udd39), 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 \u0393 \u2264 \u00ac (x\u030c \u2208\u1d2e y\u030c)\nlemma check_not_mem {x y : pSet} : x \u2209 y \u2192 \u2200 {\u0393 : \ud835\udd39}, \u0393 \u2264 x\u030c \u2208\u1d2e y\u030c \u2192 \u0393 \u2264 \u22a5 :=\nby {intro H, replace H := not_check_mem_iff.mp H, intros \u0393 H\u0393, rwa \u2190H}\n\nlemma check_mem_dichotomy (x y : pSet) : (x\u030c \u2208\u1d2e y\u030c = (\u22a4 : \ud835\udd39)) \u2228 (x\u030c \u2208\u1d2e y\u030c = (\u22a5 : \ud835\udd39)) :=\nbegin\n  haveI := classical.prop_decidable, by_cases (x \u2208 y);\n  {[smt] eblast_using [check_mem_iff, not_check_mem_iff]}\nend\n\nlemma check_mem_nonzero_iff_eq_top {x y : pSet} : (\u22a5 : \ud835\udd39) < x\u030c \u2208\u1d2e y\u030c  \u2194 x\u030c \u2208\u1d2e y\u030c = (\u22a4 : \ud835\udd39) :=\nbegin\n  refine \u27e8_,_\u27e9; intro H,\n    { by_contra, finish[or.resolve_left (check_mem_dichotomy x y) \u2039_\u203a] },\n    { simp* }\nend\n\nlemma check_mem_reflect {x y : pSet} {\u0393 : \ud835\udd39} (H_lt : \u22a5 < \u0393) (H_mem : \u0393 \u2264 (x\u030c : bSet \ud835\udd39) \u2208\u1d2e y\u030c) : x \u2208 y :=\nbegin\n  have := check_mem_nonzero_iff_eq_top.mp (lt_of_lt_of_le H_lt H_mem),\n  rwa \u2190check_mem_iff at this\nend\n\n@[simp]lemma check_mem {x y : pSet} {\u0393} (h_mem : x \u2208 y) : (\u0393 : \ud835\udd39) \u2264 x\u030c \u2208\u1d2e y\u030c :=\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 \u2039_\u203a\nend\n\n@[simp]lemma check_subset_of_subset {x y : pSet} (h_subset : x \u2286 y) : (\u22a4 : \ud835\udd39) \u2264 x\u030c \u2286\u1d2e y\u030c :=\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 \u03b1 A, cases y with \u03b2 B,\n  rcases (h_subset \u2039_\u203a) with \u27e8b , Hb\u27e9,\n  apply bv_use b, convert (check_bv_eq \u2039_\u203a), simpa[check_func]\nend\n\nlemma check_subset {x y : pSet} {\u0393 : \ud835\udd39} (h_subset : x \u2286 y) : \u0393 \u2264 x\u030c \u2286\u1d2e y\u030c :=\n  le_trans le_top (check_subset_of_subset \u2039_\u203a)\n\nlemma check_not_subset {x y : pSet} (H : \u00ac x \u2286 y) {\u0393} : (\u0393 : \ud835\udd39) \u2264 -(x\u030c \u2286\u1d2e y\u030c) :=\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 \u27e8z,Hz\u2081,Hz\u2082\u27e9, rw pSet.mem_unfold at Hz\u2081,\n  cases Hz\u2081 with j Hj, apply bv_use (check_cast.symm j),\n  refine le_inf (by simp) _, rw \u2190imp_bot, bv_imp_intro H,\n  apply check_not_mem Hz\u2082, change _ \u2264 (\u03bb w, w \u2208\u1d2e y\u030c) _, 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 : \u2203 z, z \u2208 y ) {\u0393 : \ud835\udd39} : \u0393 \u2264 exists_mem y\u030c :=\nby { rcases H_exists_mem with \u27e8z,Hz\u27e9, apply bv_use z\u030c, 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 \ud835\udd39} (H_definite\u2081 : is_definite x) (H_definite\u2082 : is_definite y) (H_sub : \u2203 z : pSet, \u22a4 \u2264 y \u2286\u1d2e z\u030c)  : \u22a4 \u2264 x \u2208\u1d2e y \u2194 \u2203 j : y.type, \u22a4 \u2264 x =\u1d2e y.func j :=\n-- begin\n--   refine \u27e8_,_\u27e9; 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 : (\u2a06 (i : type y), bval y i \u2293 x =\u1d2e func y i) \u2264 \u22a5,\n--         by {rw[le_bot_iff] at this, rw[this] at H, convert H, simp, },\n--       replace H := (by refl : (\u2a06 (i : type y), bval y i \u2293 x =\u1d2e func y i) \u2264 \u2a06 (i : type y), bval y i \u2293 x =\u1d2e func y i),\n--       bv_cases_at H j, specialize H' j,\n--       suffices this : x =\u1d2e func y j \u2264 \u22a5,\n--         by {transitivity bval y j \u2293 x =\u1d2e func y j, from \u2039_\u203a, 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\u2082, simp* }) (Hj) }\n-- end\n\n-- lemma instantiate_existential_over_check\n-- {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} (H_congr : B_ext \u03d5) (x : pSet) {\u0393} (H_nonzero : \u22a5 < \u0393) (H_ex : \u0393 \u2264 \u2a06y, (y \u2208\u1d2e (x\u030c) \u2293 \u03d5 (y))) :\n--   \u2203 (\u0393' : \ud835\udd39) (H_nonzero : \u22a5 < \u0393') (H : \u0393' \u2264 \u0393) (z) (H_mem : z \u2208 x), \u0393' \u2264 \u03d5 (z\u030c) :=\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 \u27e8_, Hi, _, _, _, _\u27e9,\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 {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} (H_congr : B_ext \u03d5) (x : pSet) {\u0393} (H_nonzero : \u22a5 < \u0393) (H_ex : \u0393 \u2264 \u2a06y, (y \u2208\u1d2e (x\u030c) \u2293 \u03d5 (y))) : \u2203 i : x.type, \u22a5 < (\u03d5 ((x.func i)\u030c ) \u2293 \u0393) :=\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 \u27e8cast check_type' i,_\u27e9, 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{\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} (H_congr : B_ext \u03d5) (x : pSet) {\u0393} (H_nonzero : \u22a5 < \u0393) (H_ex : \u0393 \u2264 \u2a06y, (y \u2208\u1d2e (x\u030c) \u2293 \u03d5 (y))) : x.type :=\nbegin\n  apply @classical.some _ (\u03bb i : x.type, \u22a5 < \u03d5 ((x.func i)\u030c ) \u2293 \u0393),\n  apply instantiate_existential_over_check_aux; from \u2039_\u203a\nend\n\nlemma instantiate_existential_over_check_spec {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} (H_congr : B_ext \u03d5) (x : pSet) {\u0393} (H_nonzero : \u22a5 < \u0393) (H_ex : \u0393 \u2264 \u2a06y, (y \u2208\u1d2e (x\u030c) \u2293 \u03d5 (y))) :\n \u22a5 < (\u03d5 ((x.func $ instantiate_existential_over_check \u2039_\u203a x \u2039_\u203a \u2039_\u203a)\u030c ) \u2293 \u0393) :=\n   by {unfold instantiate_existential_over_check, exact classical.some_spec (instantiate_existential_over_check_aux H_congr x H_nonzero \u2039_\u203a)}\n\nlemma instantiate_existential_over_check_spec\u2082 (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) (H_congr : B_ext \u03d5) (x : pSet) {\u0393} (H_nonzero : \u22a5 < \u0393) (H_ex : \u0393 \u2264 \u2a06y, (y \u2208\u1d2e (x\u030c) \u2293 \u03d5 (y))) :\n  \u22a5 < (\u03d5 ((x.func $ instantiate_existential_over_check \u2039_\u203a x \u2039_\u203a \u2039_\u203a)\u030c )) :=\nbot_lt_resolve_right H_nonzero (instantiate_existential_over_check_spec \u2039_\u203a x \u2039_\u203a \u2039_\u203a)\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 {\u0393 : \ud835\udd39} (h_nonzero : \u22a5 < \u0393) {x : pSet.{u}} {y : bSet \ud835\udd39} (H_mem : \u0393 \u2264 y \u2208\u1d2e x\u030c) :\n  \u2203 (i : x.type) (\u0393' : \ud835\udd39) (H_nonzero : \u22a5 < \u0393') (H_le : \u0393' \u2264 \u0393), \u0393' \u2264 y =\u1d2e (x.func i)\u030c  :=\nbegin\n  let \u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39 := \u03bb z, y =\u1d2e z,\n  let H_congr : B_ext \u03d5 := (by simp),\n  have H_ex : \u0393 \u2264 \u2a06 (y : bSet \ud835\udd39), y \u2208\u1d2e x\u030c  \u2293 \u03d5 y,\n    by {apply bv_use y, from le_inf \u2039_\u203a bv_refl},\n  let i : x.type := instantiate_existential_over_check H_congr x \u2039_\u203a H_ex,\n    refine  \u27e8i,y =\u1d2e (x.func i)\u030c  \u2293 \u0393,_,inf_le_right,inf_le_left\u27e9,\n    { exact instantiate_existential_over_check_spec H_congr _ \u2039_\u203a H_ex }\nend\n\nlemma eq_check_of_mem_check\u2082 {\u0393 : \ud835\udd39} (h_nonzero : \u22a5 < \u0393) (x : pSet.{u}) (y : bSet \ud835\udd39) (H_mem : \u0393 \u2264 y \u2208\u1d2e x\u030c) :\n  \u2203 i : x.type, \u22a5 < y =\u1d2e (x.func i)\u030c  :=\n  -- \u2203 \u0393' (H_le : \u0393' \u2264 \u0393) (z) (H_mem : z \u2208 x), (\u0393' \u2264 y =\u1d2e z\u030c) :=\nbegin\n  rcases (eq_check_of_mem_check \u2039_\u203a \u2039_\u203a) with \u27e8i, \u0393', H\u0393'\u2081, H\u0393'\u2082, H\u0393'\u2083\u27e9,\n  use i, from lt_of_lt_of_le H\u0393'\u2081 \u2039_\u203a\nend\n\nend check_names\n\nsection collect\nvariables\n(\u03d5 : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 \ud835\udd39) (h_congr_right : \u2200 x y z, x =\u1d2e y \u2293 \u03d5 z x \u2264 \u03d5 z y) (h_congr_left : \u2200 x y z, x =\u1d2e y \u2293 \u03d5 x z \u2264 \u03d5 y z) (u : bSet \ud835\udd39)\ninclude \u03d5 h_congr_right h_congr_left u\n\nnoncomputable def collect.func : u.type \u2192 bSet \ud835\udd39 :=\nclassical.some $ (classical.axiom_of_choice (AE_convert u.func u.bval \u03d5 (by { intros z x y, exact h_congr_right x y z })))\n\nlemma collect.func_spec (\u0393 : \ud835\udd39) (H : \u0393 \u2264 \u2a05 (j : type u), bval u j \u27f9 \u2a06 (z : bSet \ud835\udd39), \u03d5 (func u j) z) : \u0393 \u2264 \u2a05 x : u.type, bval u x \u27f9 \u03d5 (func u x) (collect.func \u03d5 h_congr_right h_congr_left u x) :=\nbegin\n  bv_intro i, bv_imp_intro Hi, let p := (collect.func._proof_1 \u03d5 h_congr_right u), have := classical.some_spec p,\n  specialize this i,\n  exact poset_yoneda_inv \u0393_1 this \u2039_\u203a \u2039_\u203a\nend\n\nnoncomputable def collect : bSet \ud835\udd39 := \u27e8u.type, collect.func \u03d5 h_congr_right h_congr_left u, u.bval\u27e9\n\nlemma collect_spec\u2081 {\u0393 : \ud835\udd39} (H_AE : \u0393 \u2264 \u2a05 i : u.type, u.bval i \u27f9 \u2a06 w, \u03d5 (u.func i) w) :\n  \u0393 \u2264 \u2a05 z, z \u2208\u1d2e u \u27f9 \u2a06 w, w \u2208\u1d2e collect \u03d5 h_congr_right h_congr_left u \u2293 \u03d5 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 \u03d5 \u2039_\u203a \u2039_\u203a 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 \u03d5 \u2039_\u203a \u2039_\u203a u \u0393_2 \u2039_\u203a i \u2039_\u203a }\nend\n\nlemma collect_spec\u2082 {\u0393 : \ud835\udd39} (H_AE : \u0393 \u2264 \u2a05 i : u.type, u.bval i \u27f9 \u2a06 w, \u03d5 (u.func i) w) :\n  \u0393 \u2264 \u2a05 w, w \u2208\u1d2e collect \u03d5 h_congr_right h_congr_left u \u27f9 \u2a06 z, z \u2208\u1d2e u \u2293 \u03d5 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 \u2039_\u203a },\n      { exact collect.func_spec \u03d5 \u2039_\u203a \u2039_\u203a u \u0393_2 \u2039_\u203a i \u2039_\u203a }}\nend\nend collect\n\n-- /-- The (strong) axiom of collection says that for every \u03d5(x,y),\n--     for every set u, \u2200 x \u2208 u, \u2203 y \u03d5 (x,y) implies there exists a set v\n--     such that \u2200 x \u2208 u, \u2203 y \u2208 v, \u03d5 (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 (\u03d5 : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 \ud835\udd39)\n  (h_congr_right : \u2200 x y z, x =\u1d2e y \u2293 \u03d5 z x \u2264 \u03d5 z y)\n  (h_congr_left : \u2200 x y z, x =\u1d2e y \u2293 \u03d5 x z \u2264 \u03d5 y z) :\n  \u22a4 \u2264 \u2a05u, (\u2a05x, x \u2208\u1d2e u \u27f9 \u2a06y, \u03d5 x y) \u27f9 \u2a06v, (\u2a05w, w \u2208\u1d2e u \u27f9 \u2a06w', w' \u2208\u1d2e v \u2293 \u03d5 w w') \u2293\n    \u2a05w', w' \u2208\u1d2e v \u27f9 \u2a06w, w \u2208\u1d2e u \u2293 \u03d5 w w' :=\nbegin\n  bv_intro u, bv_imp_intro,\n  refine le_supr_of_le (collect \u03d5 h_congr_right h_congr_left u) _,\n  have : \u0393 \u2264 \u2a05 (i : type u), bval u i \u27f9 \u2a06 (w : bSet \ud835\udd39), \u03d5 (func u i) w,\n  { bv_intro i, bv_imp_intro, exact H (func u i) (mem.mk'' \u2039_\u203a) },\n  apply le_inf,\n  { apply collect_spec\u2081, exact this },\n  { apply collect_spec\u2082, exact this }\nend\n\n/-- The boolean-valued unionset operator -/\ndef bv_union (u : bSet \ud835\udd39) : bSet \ud835\udd39 :=\n  \u27e8\u03a3(i : u.type), (u.func i).type, \u03bb x, (u.func x.1).func x.2,\n       \u03bb x, \u2a06(y : u.type), u.bval y \u2293 (u.func x.1).func x.2 \u2208\u1d2e (u.func y)\u27e9\n\nlemma func_cast {u x : bSet \ud835\udd39} {i_y : u.type} {\u03b1 : Type u} {A : \u03b1 \u2192 bSet \ud835\udd39} {B : \u03b1 \u2192 \ud835\udd39} {h : func u i_y = mk \u03b1 A B} {i_x' : \u03b1} : func (func u i_y) (eq.mpr (by rw[h]; refl) i_x') = A i_x' :=\nbegin\n  change _ = (mk \u03b1 A B).func i_x',\n  have : func (mk \u03b1 A B) (eq.mpr rfl i_x') = func (mk \u03b1 A B) i_x', by refl,\n  convert this\nend\n\nlemma bv_union_spec (u : bSet \ud835\udd39) : \u22a4 \u2264 \u2a05 (x : bSet \ud835\udd39), (x \u2208\u1d2e bv_union u \u27f9 \u2a06 (y : type u), u.bval y \u2293 x \u2208\u1d2e func u y) \u2293\n        ((\u2a06 (y : type u), u.bval y \u2293 x \u2208\u1d2e func u y) \u27f9 x \u2208\u1d2e 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 \u27e8a,i\u27e9, 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 \ud835\udd39) {\u0393} : \u0393 \u2264 \u2a05 (x : bSet \ud835\udd39), (x \u2208\u1d2e bv_union u \u27f9 \u2a06 y, y \u2208\u1d2e u \u2293 x \u2208\u1d2e y) \u2293\n        ((\u2a06 y, y \u2208\u1d2e u \u2293 x \u2208\u1d2e y) \u27f9 x \u2208\u1d2e 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 \u2039_\u203a,\n    bv_cases_at this_left i_y, apply bv_use (u.func i_y), bv_split,\n    from le_inf (mem.mk'' \u2039_\u203a) \u2039_\u203a}),\n  replace this := this x, bv_split_at this,\n  bv_imp_intro, specialize_context_at this_right \u0393_1,\n  replace this_1_1 := this_right _, from \u2039_\u203a,\n  rw[@bounded_exists \ud835\udd39 _ u (\u03bb z, x \u2208\u1d2e z)], from \u2039_\u203a,\n  change B_ext _, simp\nend\n\nlemma bv_union_spec_split (u : bSet \ud835\udd39) {\u0393} (x : bSet \ud835\udd39) : (\u0393 \u2264 x \u2208\u1d2e bv_union u) \u2194 (\u0393 \u2264 \u2a06 y, y \u2208\u1d2e u \u2293 x \u2208\u1d2e y) :=\nbegin\n  have := bv_union_spec' u, show \ud835\udd39, from \u0393, replace this := this x,\n  dsimp at this, bv_split_at this, split; intro, from this_left \u2039_\u203a,\n  from this_right \u2039_\u203a\nend\n\nlemma mem_bv_union_iff {u : bSet \ud835\udd39} {\u0393} {x : bSet \ud835\udd39} : (\u0393 \u2264 x \u2208\u1d2e bv_union u) \u2194 (\u0393 \u2264 \u2a06 y, y \u2208\u1d2e u \u2293 x \u2208\u1d2e y) :=\nby apply bv_union_spec_split\n\n/-- For every x \u2208 u, x \u2286\u1d2e \u22c3 u.-/\nlemma bv_union_spec'' (u : bSet \ud835\udd39) : \u22a4 \u2264 \u2a05(x : bSet \ud835\udd39), (x \u2208\u1d2e u) \u27f9 (x \u2286\u1d2e 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 \u2208\u1d2e bv_union u \u27f9 \u2a06 (y : type u), u.bval y \u2293 func x i_v \u2208\u1d2e func u y) \u2293\n        (((\u2a06 (y : type u), u.bval y \u2293 func x i_v \u2208\u1d2e func u y) \u27f9 func x i_v \u2208\u1d2e bv_union u) \u2293\n      (func x i_v \u2208\u1d2e x \u2293 x \u2208\u1d2e u)) \u2264\n    func x i_v \u2208\u1d2e bv_union u, apply inf_le_right_of_le,\n    suffices : (func x i_v \u2208\u1d2e x \u2293 x \u2208\u1d2e u) \u2264 (\u2a06 (y : type u), bval u y \u2293 func x i_v \u2208\u1d2e func u y),\n      by {apply le_trans, apply inf_le_inf, refl, exact this, apply bv_imp_elim},\n    conv in (x \u2208\u1d2e u) {simp only [mem_unfold]}, apply bv_cases_right, intro y,\n    apply bv_use y,\n    ac_change bval u y \u2293 (func x i_v \u2208\u1d2e x \u2293 x =\u1d2e func u y) \u2264 u.bval y \u2293 (func x i_v \u2208\u1d2e 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 \ud835\udd39} {\u0393} (H_eq : \u0393 \u2264 x =\u1d2e y) : \u0393 \u2264 bv_union x =\u1d2e 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 \u0393_1,\n    specialize_context_at this_right \u0393_1,\n    replace this_left := this_left H,\n    have := bv_union_spec y z, bv_split,\n    specialize_context_at this_left_1 \u0393_1,\n    specialize_context_at this_right_1 \u0393_1,\n    replace this_right_1 := this_right_1 _, from \u2039_\u203a,\n    rw[@bounded_exists \ud835\udd39 _ y (\u03bb w, z \u2208\u1d2e w)],\n    rw[@bounded_exists \ud835\udd39 _ x (\u03bb w, z \u2208\u1d2e 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 \u2039_\u203a,\n    from \u2039_\u203a, change B_ext _, simp, change B_ext _, simp,\n\n    have := bv_union_spec y z, bv_split,\n    specialize_context_at this_left \u0393_1,\n    specialize_context_at this_right \u0393_1,\n    replace this_left := this_left H,\n    have := bv_union_spec x z, bv_split,\n    specialize_context_at this_left_1 \u0393_1,\n    specialize_context_at this_right_1 \u0393_1,\n    replace this_right_1 := this_right_1 _, from \u2039_\u203a,\n    rw[@bounded_exists \ud835\udd39 _ x (\u03bb w, z \u2208\u1d2e w)],\n    rw[@bounded_exists \ud835\udd39 _ y (\u03bb w, z \u2208\u1d2e 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 \u2039_\u203a,\n    from \u2039_\u203a, change B_ext _, simp, change B_ext _, simp\nend\n\n@[simp]lemma B_congr_bv_union : B_congr (bv_union : bSet \ud835\udd39 \u2192 bSet \ud835\udd39) :=\nby apply bv_union_congr\n\ntheorem bSet_axiom_of_union : (\u2a05 (u : bSet \ud835\udd39), (\u2a06v, \u2a05x,\n  (x \u2208\u1d2e v \u21d4 (\u2a06(y : u.type), u.bval y \u2293 x \u2208\u1d2e u.func y)))) = \u22a4 :=\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 \ud835\udd39 _ u\nend\n\n@[simp]def set_of_indicator {u : bSet \ud835\udd39} (f : u.type \u2192 \ud835\udd39) : bSet \ud835\udd39 :=\n  \u27e8u.type, u.func, f\u27e9\n\n@[simp, cleanup]lemma set_of_indicator.type {u} {f} :\n  (@set_of_indicator \ud835\udd39 _ u f).type = u.type := rfl\n\n@[simp, cleanup]lemma set_of_indicator.func {u} {f} {i}:\n  (@set_of_indicator \ud835\udd39 _ u f).func i = u.func i := rfl\n\n@[simp, cleanup]lemma set_of_indicator.bval {u} {f} {i} :\n  (@set_of_indicator \ud835\udd39 _ u f).bval i = f i := rfl\n\n-- @[reducible, simp]def set_of_indicator' {u : bSet \ud835\udd39} (f : u.type \u2192 \ud835\udd39) : bSet \ud835\udd39 :=\n--   \u27e8u.type, u.func, \u03bb i, f i \u2293 u.bval i\u27e9\n\ndef bv_powerset (u : bSet \ud835\udd39) : bSet \ud835\udd39 :=\n\u27e8u.type \u2192 \ud835\udd39, \u03bb f, set_of_indicator f, \u03bb f, set_of_indicator f \u2286\u1d2e u\u27e9\n\nprefix `\ud835\udcab`:80 := bv_powerset\n\n-- def bv_powerset' (u : bSet \ud835\udd39) : bSet \ud835\udd39 :=\n-- \u27e8u.type \u2192 \ud835\udd39, \u03bb f, set_of_indicator' f, \u03bb f, \u22a4\u27e9\n\n--TODO (jesse) try proving bv_powerset and bv_powerset' are equivalent\n\n-- example {u : bSet \ud835\udd39} : bv_powerset u =\u1d2e bv_powerset' u = \u22a4 :=\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) (\u03bb x, x \u2208\u1d2e 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  (\u2a05 (i : type u), f i \u2293 z' =\u1d2e func u i \u27f9 z' \u2208\u1d2e u) \u2293 (z =\u1d2e mk (type u) (func u) f \u2293 z' \u2208\u1d2e z) \u2264 z' \u2208\u1d2e mk (type u) (func u) (\u03bb (i : type u), f i \u2293 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' {\u0393 : \ud835\udd39} (u : bSet \ud835\udd39) : \u0393 \u2264 \u2a05(x : bSet \ud835\udd39), x\u2208\u1d2e \ud835\udcab u \u21d4 \u2a05(y : x.type), x.bval y \u27f9 (x.func y \u2208\u1d2e 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 \u03c7,\n   suffices : ((set_of_indicator \u03c7) \u2286\u1d2e u \u2293 (x =\u1d2e (set_of_indicator \u03c7)) : \ud835\udd39) \u2264 x \u2286\u1d2e 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 (\u03bb y, (y \u2208\u1d2e 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 \u03bb i, u.func i \u2208\u1d2e x,\n  have this' := @bounded_forall _ _ (set_of_indicator (\u03bb y, (u.func y \u2208\u1d2e x))) (\u03bb y, (y \u2208\u1d2e 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 (\u03bb y, \u2a06 (a' :    type u), func u a' \u2208\u1d2e x \u2293 y =\u1d2e func u a'), rw[this], swap,\n  intros a\u2081 a\u2082, dsimp, rw[inf_supr_eq], apply supr_le, intro i,\n\n  apply le_supr_of_le i,\n  ac_change (a\u2082 =\u1d2e a\u2081 \u2293  a\u2081 =\u1d2e func u i) \u2293 func u i \u2208\u1d2e x \u2264 func u i \u2208\u1d2e x \u2293 a\u2082 =\u1d2e 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\u2081, dsimp, apply infi_le_of_le a\u2081, 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\u2081 =\u1d2e func u i \u2293 (bval u i \u2293 a\u2081 \u2208\u1d2e x) \u2264 a\u2081 =\u1d2e func u i,\n   apply inf_le_left_of_le, refl}},\n\n   {have := @bounded_forall _ _ (set_of_indicator (\u03bb y, func _ y \u2208\u1d2e x)) (\u03bb y, y \u2208\u1d2e x),\n   erw[this], swap, simp[subst_congr_mem_left],\n   bv_intro a\u2081, apply infi_le_of_le a\u2081,\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 : (\u2a05(u : bSet \ud835\udd39), \u2a06(v : _), \u2a05(x : bSet \ud835\udd39), x\u2208\u1d2e v \u21d4 \u2a05(y : x.type), x.bval y \u27f9 (x.func y \u2208\u1d2e u)) = \u22a4:=\nbegin\n  apply top_unique, bv_intro u, apply bv_use (\ud835\udcab u),\n  apply bSet_axiom_of_powerset'\nend\n\nlemma bv_powerset_spec {u x : bSet \ud835\udd39} {\u0393 : \ud835\udd39} : \u0393 \u2264 x \u2286\u1d2e u \u2194 \u0393 \u2264 x \u2208\u1d2e \ud835\udcab u :=\nbegin\n  have := bSet_axiom_of_powerset' u, show \ud835\udd39, from \u0393,\n  simp only [lattice.biimp] at this,\n  replace this := this x, bv_split, rw[subset_unfold],\n  fsplit; intro H; [from this_right \u2039_\u203a, from this_left \u2039_\u203a]\nend\n\nlemma mem_powerset_iff {u x : bSet \ud835\udd39} {\u0393 : \ud835\udd39} : \u0393 \u2264 x \u2208\u1d2e (\ud835\udcab u) \u2194 \u0393 \u2264 x \u2286\u1d2e u :=\nbv_powerset_spec.symm\n\nlemma bv_powerset_congr {\u0393 : \ud835\udd39} {x y : bSet \ud835\udd39} : \u0393 \u2264 x =\u1d2e y \u2192 \u0393 \u2264 \ud835\udcab x =\u1d2e \ud835\udcab 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 \ud835\udd39} {i : x.type} {\u03c7 : x.type \u2192 \ud835\udd39} {\u0393} (H_\u0393 : \u0393 \u2264 \u03c7 i) : \u0393 \u2264 (x.func i) \u2208\u1d2e (set_of_indicator \u03c7) :=\nby {rw[mem_unfold], apply bv_use i, exact le_inf H_\u0393 (bv_refl)}\n\n@[simp]lemma set_of_indicator_subset {x : bSet \ud835\udd39} {\u03c7 : x.type \u2192 \ud835\udd39} {\u0393} (H_\u03c7 : \u2200 i, \u03c7 i \u2264 x.bval i) : \u0393 \u2264 set_of_indicator \u03c7 \u2286\u1d2e 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 \ud835\udd39} (\u03c7 : u.type \u2192 \ud835\udd39) : bSet \ud835\udd39 :=\nset_of_indicator (\u03bb i, \u03c7 i \u2293 (u.bval i))\n\n@[simp]lemma subset.mk_subset {u : bSet \ud835\udd39} {\u03c7 : u.type \u2192 \ud835\udd39} {\u0393 : \ud835\udd39} : \u0393 \u2264 subset.mk \u03c7 \u2286\u1d2e u :=\nset_of_indicator_subset $ by simp\n\nlemma check_set_of_indicator_subset {x : pSet} {\u03c7 : x\u030c.type \u2192 \ud835\udd39} {\u0393} :\n  \u0393 \u2264 set_of_indicator \u03c7 \u2286\u1d2e x\u030c :=\nset_of_indicator_subset $ by simp\n\ninstance subset_to_pi {z x y : bSet \ud835\udd39} {\u0393 : \ud835\udd39} : has_coe_to_fun (\u0393 \u2264 x \u2286\u1d2e y) :=\n{ F := \u03bb H, (\u0393 \u2264 z \u2208\u1d2e x \u2192 \u0393 \u2264 z \u2208\u1d2e y),\n  coe := \u03bb H\u2081 H\u2082, mem_of_mem_subset H\u2081 H\u2082 }\n\nlemma mem_set_of_indicator_iff {x : bSet \ud835\udd39} {\u03c7 : x.type \u2192 \ud835\udd39} {z : bSet \ud835\udd39} {\u0393 : \ud835\udd39} (H_\u03c7 : \u2200 i, \u03c7 i \u2264 x.bval i)\n : \u0393 \u2264 z \u2208\u1d2e set_of_indicator \u03c7  \u2194 \u0393 \u2264 \u2a06(i : x.type), z =\u1d2e (x.func i) \u2293 \u03c7 i :=\nbegin\n  refine \u27e8_,_\u27e9; 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 \u2039_\u203a }\nend\n\nlemma mem_subset.mk_iff {x : bSet \ud835\udd39} {\u03c7 : x.type \u2192 \ud835\udd39} {z : bSet \ud835\udd39} {\u0393 : \ud835\udd39}\n  : \u0393 \u2264 z \u2208\u1d2e subset.mk \u03c7 \u2194 \u0393 \u2264 \u2a06 (i : x.type), z =\u1d2e (x.func i) \u2293 (\u03c7 i \u2293 (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\u2082 {x : bSet \ud835\udd39} {\u03c7 : x .type \u2192 \ud835\udd39} {z : bSet \ud835\udd39} {\u0393 : \ud835\udd39}\n  : \u0393 \u2264 z \u2208\u1d2e subset.mk \u03c7 \u2194 \u0393 \u2264 \u2a06 (i : x.type), x.bval i \u2293 (z =\u1d2e (x.func i) \u2293 \u03c7 i) :=\nby { rw mem_subset.mk_iff, congr' 3, ext, ac_refl }\n\n@[simp]lemma mem_of_mem_subset.mk {x : bSet \ud835\udd39} {\u03c7 : x.type \u2192 \ud835\udd39} {z} {\u0393} (Hz : \u0393 \u2264 z \u2208\u1d2e subset.mk \u03c7) : \u0393 \u2264 z \u2208\u1d2e x :=\nmem_of_mem_subset (subset.mk_subset) \u2039_\u203a\n\n/--\n For x an injective pSet and \u03c7 : x\u030c.type \u2192 \ud835\udd39, \u22a4 \u2264 (x.func i) \u2208 set_of_indicator \u03c7 iff \u03c7 i = \u22a4.\n-/\nlemma check_mem_set_of_indicator_iff {x : pSet} (H_inj : \u2200 i\u2081 i\u2082 : x.type, pSet.equiv (x.func i\u2081) (x.func i\u2082) \u2192 i\u2081 = i\u2082) (i : x.type) {\u03c7 : x\u030c.type \u2192 \ud835\udd39} : (\u2200{\u0393}, \u0393 \u2264 (x.func i)\u030c  \u2208\u1d2e set_of_indicator \u03c7) \u2194 (\u2200 {\u0393}, \u0393 \u2264 \u03c7 (cast check_type'.symm i)) :=\nbegin\n  refine \u27e8_,_\u27e9; intro H,\n    { intro \u0393, have H' := @H \u0393, 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)) \u2039_\u203a,\n          have := check_bv_eq_bot_of_not_equiv \u2039_\u203a,\n          transitivity \u22a5,\n            { rw[<-this], convert H'_1_right, cases x, refl },\n            { exact bot_le }}},\n    { intro \u0393, specialize @H \u0393, apply bv_use (cast check_type'.symm i),\n      cases x, exact le_inf \u2039_\u203a bv_refl }\nend\n\nlemma subset_of_pointwise_bounded {\u0393 : \ud835\udd39} {x : bSet \ud835\udd39} {p : x.type \u2192 \ud835\udd39} {p' : x.type \u2192 \ud835\udd39} (H_bd : \u2200 i : x.type, p i \u2264 p' i) : \u0393 \u2264 set_of_indicator p \u2286\u1d2e 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\u2081 p\u2082 : x\u030c.type \u2192 \ud835\udd39} (H_inj : \u2200 i\u2081 i\u2082 : x.type, pSet.equiv (x.func i\u2081) (x.func i\u2082) \u2192 i\u2081 = i\u2082)(H_eq : \u2200 {\u0393}, \u0393 \u2264 (set_of_indicator p\u2081 \u2286\u1d2e set_of_indicator p\u2082)) : \u2200 i, p\u2081 i \u2264 p\u2082 i :=\nbegin\n  intro i, have : (p\u2081 i) \u2264 (set_of_indicator p\u2081 \u2286\u1d2e set_of_indicator p\u2082) := 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 : \u00acpSet.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 \u2039_\u203a; cases x; simp; refl},\n      exact (H_inj (by cases x; from \u2039_\u203a))}\nend\n\nlemma pointwise_eq_of_eq_set_of_indicator {x : pSet} {p\u2081 p\u2082 : x\u030c.type \u2192 \ud835\udd39} (H_inj : \u2200 i\u2081 i\u2082 : x.type, pSet.equiv (x.func i\u2081) (x.func i\u2082) \u2192 i\u2081 = i\u2082) (H_eq : \u2200 {\u0393}, \u0393 \u2264 (set_of_indicator p\u2081 =\u1d2e set_of_indicator p\u2082)) : \u2200 i, p\u2081 i = p\u2082 i :=\nbegin\n  rw[eq_iff_subset_subset] at H_eq, refine (\u03bb i, le_antisymm _ _);\n    { apply pointwise_bounded_of_check_subset_check, from \u2039_\u203a,\n      intro \u0393, specialize @H_eq \u0393, bv_split, from \u2039_\u203a }\nend\n\nlemma set_of_indicator_eq_iff_pointwise_eq {x : pSet} {p\u2081 p\u2082 : x\u030c.type \u2192 \ud835\udd39} (H_inj : \u2200 i\u2081 i\u2082 : x.type, pSet.equiv (x.func i\u2081) (x.func i\u2082) \u2192 i\u2081 = i\u2082) :\n(\u2200 {\u0393}, \u0393 \u2264 (set_of_indicator p\u2081 =\u1d2e set_of_indicator p\u2082)) \u2194 (\u2200i, p\u2081 i = p\u2082 i)  :=\nbegin\n  refine \u27e8_,_\u27e9,\n    { intro H_eq, apply pointwise_eq_of_eq_set_of_indicator; from \u2039_\u203a },\n    { intros H_eq \u0393, rw[show p\u2081 = p\u2082, from funext H_eq], simp }\nend\n\nsection infinity\nlocal notation `\u03c9` := pSet.omega\n\n@[simp]lemma check_omega_type : (\u03c9\u030c : bSet \ud835\udd39).type = ulift \u2115 := rfl\n@[simp]lemma check_omega_func : (\u03c9\u030c: bSet \ud835\udd39).func = \u03bb x, check (pSet.of_nat x.down) := rfl\n\npostfix `\u0303 `:70 := pSet.of_nat -- i'm a bit skeptical of this notation\n\n@[simp, reducible]def axiom_of_infinity_spec (u : bSet \ud835\udd39) : \ud835\udd39 :=\n  (\u2205\u2208\u1d2e u) \u2293 (\u2a05(i_x : u.type), \u2a06(i_y : u.type), (u.func i_x \u2208\u1d2e u.func i_y))\n\n@[reducible]def contains_empty (u : bSet \ud835\udd39) : \ud835\udd39 := \u2205 \u2208\u1d2e u\n\n@[reducible]def contains_succ (u : bSet \ud835\udd39) : \ud835\udd39 := (\u2a05(i_x : u.type), \u2a06(i_y : u.type), (u.func i_x \u2208\u1d2e u.func i_y))\n\nlemma infinity_of_empty_succ {u : bSet \ud835\udd39} {c} (h\u2081 : c \u2264 contains_empty u)\n  (h\u2082 : c \u2264 contains_succ u) : c \u2264 axiom_of_infinity_spec u :=\nle_inf \u2039_\u203a \u2039_\u203a\n\nlemma contains_empty_check_omega : (\u22a4 : \ud835\udd39) \u2264 contains_empty (\u03c9\u030c) :=\nby {dsimp[pSet.omega,check, contains_empty], apply bv_use (ulift.up nat.zero), simp[pSet.of_nat]}\n\nlemma contains_succ_check_omega : (\u22a4 : \ud835\udd39) \u2264 contains_succ (\u03c9\u030c) :=\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 : (\u2a06(u : bSet \ud835\udd39), axiom_of_infinity_spec u) = \u22a4 :=\nbegin\n  apply top_unique, apply bv_use (\u03c9\u030c), apply infinity_of_empty_succ,\n  exacts [contains_empty_check_omega, contains_succ_check_omega]\nend\n\n@[reducible]def omega := (\u03c9\u030c : bSet \ud835\udd39)\n\n@[simp, cleanup]lemma omega_type : (omega : bSet \ud835\udd39).type = ulift \u2115 := rfl\n\n/-- The n-th von Neumann ordinal in bSet \ud835\udd39 is just the check-name of the n-th von Neumann ordinal in pSet -/\n@[reducible]def of_nat : \u2115 \u2192 bSet \ud835\udd39 := \u03bb n, (pSet.of_nat n)\u030c\n\n@[simp, cleanup]lemma omega_func {k} : (omega : bSet \ud835\udd39).func k = of_nat k.down :=\nby refl\n\nlemma omega_definite {n : \u2115} {\u0393 : \ud835\udd39} : \u0393 \u2264 of_nat n \u2208\u1d2e omega :=\nbegin\nsuffices : of_nat n \u2208\u1d2e omega = (\u22a4 : \ud835\udd39), 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 : \u2115} {\u0393 : \ud835\udd39} : \u0393 \u2264 of_nat n \u2208\u1d2e omega := omega_definite\n\ninstance has_zero_bSet : has_zero (bSet \ud835\udd39) := \u27e8of_nat 0\u27e9\n\ninstance has_one_bSet : has_one (bSet \ud835\udd39) := \u27e8of_nat 1\u27e9\n\n@[reducible]def two : bSet \ud835\udd39 := of_nat 2\n\nnotation `\ud835\udfda` := bSet.two\n\nlemma zero_eq_empty {\u0393 : \ud835\udd39} : \u0393 \u2264 0 =\u1d2e \u2205 :=\nbegin\n  unfold has_zero.zero, unfold bSet.of_nat,\n  rw \u2190check_empty_eq_empty, apply check_eq, refl\nend\n\n@[simp]lemma zero_mem_one {\u0393 : \ud835\udd39} : \u0393 \u2264 0 \u2208\u1d2e 1 :=\nby {unfold has_zero.zero, apply bv_use none, simp}\n\nlemma one_eq_singleton_zero {\u0393 : \ud835\udd39} : \u0393 \u2264 1 =\u1d2e {0} :=\nbegin\n  unfold has_one.one,\n  unfold singleton, unfold has_insert.insert,\n  change \u0393 \u2264 (pSet.insert _ _)\u030c  =\u1d2e _,\n  have := check_insert (0\u0303 ) (0\u0303 ),\n  rw this,\n  change _ \u2264 bSet.insert1 0 0 =\u1d2e bSet.insert1 0 \u2205,\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 \ud835\udd39) is the simp normal form of (\u2205\u030c), (of_nat 0), etc\n\nlemma forall_empty {\u0393 : \ud835\udd39} {\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39} : \u0393 \u2264 \u2a05 x, x \u2208\u1d2e \u2205 \u27f9 \u03d5 x :=\nbegin\n  bv_intro x, bv_imp_intro H_mem, refine le_trans _ bot_le,\n  exact bot_of_mem_empty \u2039_\u203a\nend\n\n@[simp, cleanup]lemma omega_bval {k} : (omega : bSet \ud835\udd39).bval k = \u22a4 :=\nby refl\n\ntheorem bSet_axiom_of_infinity' :\n  (\u22a4 : \ud835\udd39) \u2264 (\u2205 \u2208\u1d2e omega) \u2293 (\u2a05x, x \u2208\u1d2e omega \u27f9 \u2a06y, y \u2208\u1d2e omega \u2293 x \u2208\u1d2e y) :=\nbegin\n  apply le_inf, apply contains_empty_check_omega,\n  rw [\u2190bounded_forall],\n  rw [infi_congr], swap,\n  intro n, rw [\u2190bounded_exists, omega_bval, top_imp,\n                @supr_congr _ _ _ (\u03bb m, func omega n \u2208\u1d2e 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 \ud835\udd39} : let \u03d5 := \u03bb x, \u2a05 z, z \u2208\u1d2e w \u2293 z \u2286\u1d2e x \u2293 x \u2286\u1d2e z in B_ext \u03d5 :=\nby simp\n\nend infinity\n\ntheorem bSet_epsilon_induction (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) (h_congr : \u2200 x y, x =\u1d2e y \u2293 \u03d5 x \u2264 \u03d5 y) :\n  (\u2a05(x : bSet \ud835\udd39), ((\u2a05(y : bSet \ud835\udd39), y \u2208\u1d2e x \u27f9 \u03d5 y) \u27f9 \u03d5 x)) \u27f9 (\u2a05(z : bSet \ud835\udd39), \u03d5 z) = \u22a4 :=\nbegin\n  apply top_unique, apply bv_imp_intro, rw[top_inf_eq],\n  bv_intro x, let b := _, change b \u2264 _,\n  induction x with \u03b1 A B ih, dsimp at *,\n  have : b \u2264 \u2a05(i_y:\u03b1), B i_y \u27f9 \u03d5 (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 \u03b1 A B) \u03d5 h_congr,\n  simp only with cleanup at h, rw[h] at this,\n  apply bv_have this,\n  have : b \u2264 (\u2a05 (y : bSet \ud835\udd39), (y) \u2208\u1d2e (mk \u03b1 A B) \u27f9 \u03d5 (y)) \u27f9 \u03d5 (mk \u03b1 A B),\n    by {apply bv_specialize (mk \u03b1 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 \ud835\udd39 will always suffice where regularity/epsilon_induction are required\nlemma epsilon_induction {\u0393} (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) (h_congr : B_ext \u03d5) (H_ih : \u2200 x, \u0393 \u2264 ((\u2a05(y : bSet \ud835\udd39), y \u2208\u1d2e x \u27f9 \u03d5 y) \u27f9 \u03d5 x)) :\n\u2200 z, \u0393 \u2264 \u03d5 z  :=\nbegin\n  have := bSet_epsilon_induction \u03d5 h_congr, rw[eq_top_iff] at this,\n  intro z,\n  have H_a : \u0393 \u2264 (\u2a05 (x : bSet \ud835\udd39), (\u2a05 (y : bSet \ud835\udd39), y \u2208\u1d2e x \u27f9 \u03d5 y) \u27f9 \u03d5 x),\n  bv_intro x, specialize H_ih x, from \u2039_\u203a,\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 \ud835\udd39 \u2192 Sort*} (y : bSet \ud835\udd39) : (\u03a0(x : bSet \ud835\udd39), (\u03a0(a : x.type), C (x.func a)) \u2192 C x) \u2192 C y :=\nby {induction y, intro IH, apply IH, from \u03bb a, y_ih a \u2039_\u203a}\n\n@[elab_as_eliminator]protected lemma rec' {C : bSet \ud835\udd39 \u2192 Sort*} : (\u03a0(x : bSet \ud835\udd39), (\u03a0(a : x.type), C (x.func a)) \u2192 C x) \u2192 \u03a0(y : bSet \ud835\udd39), C y :=\nby {intro H, intro y, induction y with \u03b1 A B, solve_by_elim}\n\nlemma regularity_aux (x : bSet \ud835\udd39) {\u0393 : \ud835\udd39} : \u0393 \u2264 \u2a05u, x \u2208\u1d2e u \u27f9 (\u2a06y, y \u2208\u1d2e u \u2293 (\u2a05z', z' \u2208\u1d2e u \u27f9 (-(z' \u2208\u1d2e 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 \u0393_1 (\u2a05z', z' \u2208\u1d2e u \u27f9 (-(z' \u2208\u1d2e x))),\n    bv_or_elim_at this, apply bv_use x, from le_inf \u2039_\u203a \u2039_\u203a,\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 : \u0393_4 \u2264 (func x a) \u2208\u1d2e u,\n    rw[bv_eq_symm] at this.right_1_right_1_right,\n    apply @bv_rw' \ud835\udd39 _ _ _ _  this.right_1_right_1_right (\u03bb z, z \u2208\u1d2e u) (by simp) _, from \u2039_\u203a,\n    from (le_trans (by {dsimp*, simp[inf_le_right_of_le]} : \u0393_4 \u2264 \u0393) (IH a u)) \u2039_\u203a\nend\n\ntheorem bSet_axiom_of_regularity (x : bSet \ud835\udd39) {\u0393 : \ud835\udd39} (H : \u0393 \u2264 -(x =\u1d2e \u2205)) : \u0393 \u2264 (\u2a06y, y \u2208\u1d2e x \u2293 (\u2a05z', z' \u2208\u1d2e x \u27f9 (-(z' \u2208\u1d2e y)))) :=\nbegin\n  rw nonempty_iff_exists_mem at H,\n  bv_cases_at H u Hu,\n  have : \u0393_1 \u2264 _ := (regularity_aux (u : bSet \ud835\udd39)),\n  exact this x \u2039_\u203a\nend\n\n/-- \u2203! x, \u03d5 x \u2194 \u2203 x \u2200 y, \u03d5(x) \u2293 \u03d5 (y) \u2192 y = x -/\n@[reducible]def bv_exists_unique (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) : \ud835\udd39 :=\n  \u2a06(x:bSet \ud835\udd39), (\u2a05(y : bSet \ud835\udd39), \u03d5 y \u27f9 (y =\u1d2e x))\n\nlocal notation `\u2a06!` 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 \ud835\udd39) : B_ext (\u03bb x, x \u2286\u1d2e y \u2294 y \u2286\u1d2e x) := by simp\n\nlemma B_ext_subset_or_subset_right (x : bSet \ud835\udd39) : B_ext (\u03bb y, x \u2286\u1d2e y \u2294 y \u2286\u1d2e x) := by simp\n\nlemma forall_forall_reindex (\u03d5 : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 \u2192 \ud835\udd39) {h\u2081 : \u2200 x, B_ext (\u03bb y, \u03d5 x y)}\n  {h\u2082 : \u2200 y, B_ext (\u03bb x, \u03d5 x y)} {C : bSet \ud835\udd39} :\n  (\u2a05(i\u2081:C.type), (C.bval i\u2081 \u27f9 \u2a05(i\u2082 : C.type), C.bval i\u2082 \u27f9 \u03d5 (C.func i\u2081) (C.func i\u2082))) =\n  \u2a05(w\u2081 w\u2082 : bSet \ud835\udd39), w\u2081\u2208\u1d2e C \u2293 w\u2082 \u2208\u1d2e C \u27f9 \u03d5 w\u2081 w\u2082 :=\nbegin\n  have := @bounded_forall _ _ C (\u03bb x, \u2a05(i\u2082 : C.type), bval C i\u2082 \u27f9 \u03d5 x (func C i\u2082)),\n  rw[this], dsimp at *, apply le_antisymm,\n  bv_intro w\u2081, bv_intro w\u2082, apply bv_specialize w\u2081, rw[<-deduction],\n  simp only [inf_assoc.symm], rw[deduction], apply le_trans, apply bv_imp_elim,\n  have := @bounded_forall _ _ C (\u03bb z, \u03d5 w\u2081 z), rw[this], apply bv_specialize w\u2082,\n  apply bv_imp_intro, apply le_trans, apply bv_imp_elim, refl,\n  intros w\u2081 w\u2082, apply h\u2081, bv_intro w\u2081, apply infi_le_of_le w\u2081, apply bv_imp_intro,\n  have := @bounded_forall _ _ C (\u03bb z, \u03d5 w\u2081 z), rw[this],\n  bv_intro w\u2082, apply bv_specialize_left w\u2082, apply bv_imp_intro, simp only [inf_assoc],\n  apply le_trans, apply bv_imp_elim, refl, intros w\u2081 w\u2082, apply h\u2081,\n  intros w\u2081 w\u2082, apply B_ext_infi, intro j,\n  apply B_ext_imp; simp*\nend\n\nlemma subset'_inductive (X : bSet \ud835\udd39) (H : \u22a4 \u2264 (\u2a05y, (y \u2286\u1d2e X \u2293 (\u2a05(w\u2081 : bSet \ud835\udd39), \u2a05(w\u2082 : bSet \ud835\udd39),\n  w\u2081 \u2208\u1d2e y \u2293 w\u2082 \u2208\u1d2e y \u27f9 (w\u2081 \u2286\u1d2e w\u2082 \u2294 w\u2082 \u2286\u1d2e w\u2081))) \u27f9 (bv_union y \u2208\u1d2e X))) {\u03b1 : Type*} {S : \u03b1 \u2192 bSet \ud835\udd39} (h_core : core X S) :\n   by {haveI := subset'_partial_order h_core, from \u2200c:set \u03b1, @chain \u03b1 (\u2264) c \u2192 \u2203ub, \u2200a\u2208c, a \u2264 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 : \u22a4 \u2264 \u2a05 i\u2081 : C'.type, C'.bval i\u2081 \u27f9 \u2a05 i\u2082 : C'.type, C'.bval i\u2082 \u27f9 (C'.func i\u2081 \u2286\u1d2e C'.func i\u2082 \u2294 C'.func i\u2082 \u2286\u1d2e C'.func i\u2081),\n  by {simp[subset_unfold], intros i\u2081 i\u2082,\n  simp[chain, set.pairwise_on] at C_chain,\n  cases i\u2081 with i\u2081 H\u2081, cases i\u2082 with i\u2082 H\u2082,\n  specialize C_chain i\u2081 H\u2081 i\u2082 H\u2082,\n  haveI : decidable_eq \u03b1 := \u03bb _ _, prop_decidable _,\n  by_cases i\u2081 = i\u2082,\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 : \u22a4 \u2264 \u2a05(u : C'.type), C'.bval u \u27f9 C'.func u \u2208\u1d2e X,\n    by {bv_intro i_u, rw[of_core_bval, top_imp], apply of_core_mem},\n    /- Show that \u22c3C' is in X -/\n  have H_internal_ub_mem : \u22a4 \u2264 (bv_union C') \u2208\u1d2e 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 (\u03bb z\u2081 z\u2082, ((z\u2081 \u2286\u1d2e z\u2082) \u2294 (z\u2082 \u2286\u1d2e z\u2081) : \ud835\udd39))]; simp}},\n /- Show that \u22c3C' is an upper bound on C' in X -/\n  have H_internal_ub_spec : \u22a4 \u2264 \u2a05(i_w : C'.type), C'.bval i_w \u27f9 C'.func i_w \u2286\u1d2e (bv_union C'),\n    by {have := bv_union_spec'' C', apply le_trans this,\n        have := @bounded_forall \ud835\udd39 _ C' (\u03bb w, w \u2286\u1d2e 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') \u2286\u1d2e S w = \u22a4,\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' =\u1d2e S w, rw[w_property], apply le_top,\n  apply subst_congr_subset_right\nend\n\n/- \u2200 x, x \u2260 \u2205 \u2227 ((\u2200 y, y \u2286 x \u2227 \u2200 w\u2081 w\u2082 \u2208 y, w\u2081 \u2286 w\u2082 \u2228 w\u2082 \u2286 w\u2081) \u2192 (\u22c3y) \u2208 x)\n      \u2192 \u2203 c \u2208 x, \u2200 z \u2208 x, c \u2286 z \u2192 c = z -/\ntheorem bSet_zorns_lemma (X : bSet \ud835\udd39) (H_nonempty : -(X =\u1d2e \u2205) = \u22a4) (H : \u22a4 \u2264 (\u2a05y, (y \u2286\u1d2e X \u2293 (\u2a05(w\u2081 : bSet \ud835\udd39), \u2a05(w\u2082 : bSet \ud835\udd39),\n  w\u2081 \u2208\u1d2e y \u2293 w\u2082 \u2208\u1d2e y \u27f9 (w\u2081 \u2286\u1d2e w\u2082 \u2294 w\u2082 \u2286\u1d2e w\u2081))) \u27f9 (bv_union y \u2208\u1d2e X))) :\n  \u22a4 \u2264 (\u2a06c, c \u2208\u1d2e X \u2293 (\u2a05z, z \u2208\u1d2e X \u27f9 (c \u2286\u1d2e z \u27f9 c =\u1d2e z))) :=\nbegin\n  have := core.mk X, rcases this with \u27e8\u03b1, \u27e8S, h_core\u27e9\u27e9,\n  have H_zorn := exists_maximal_of_chains_bounded (subset'_inductive X H h_core) (by apply subset'_trans),\n  rcases H_zorn with \u27e8c, H_c\u27e9, rcases h_core with \u27e8h_core_l, h_core_r\u27e9,\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 \u27e8h_core_l, h_core_r\u27e9 x,\n  rcases this with \u27e8y, \u27e8H\u2081_y, H\u2082_y\u27e9\u27e9, rw[<-H\u2082_y], apply bv_imp_intro,\n  conv in (S c =\u1d2e _) {rw[bv_eq_symm]},\n  suffices : x =\u1d2e y \u2293 (S c \u2286\u1d2e y) \u2264 x =\u1d2e S c,\n    by {apply le_trans, show \ud835\udd39, from x =\u1d2e y \u2293 S c \u2286\u1d2e y,\n        apply le_inf, apply inf_le_left, apply B_ext_subset_right, from this},\n  suffices : S c \u2286\u1d2e y \u2264 y =\u1d2e S c,\n    by {apply le_trans, apply inf_le_inf, refl, from this, apply bv_eq_trans},\n  let a := S c \u2286\u1d2e y, have h_a_bot : a \u2293 (-a) = \u22a5, by apply inf_neg_eq_bot,\n  have h_a_top : a \u2294 (-a) = \u22a4, 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 \u2208\u1d2e X = \u22a4,\n    by {apply two_term_mixture_mem_top, from h_a_top, apply core_mem_of_mem_image \u27e8\u2039_\u203a,\u2039_\u203a\u27e9 \u2039_\u203a,\n    from \u2039_\u203a},\n  have claim_2 : \u03a3' z : \u03b1, v =\u1d2e S z = \u22a4 := core_witness \u27e8\u2039_\u203a,\u2039_\u203a\u27e9 v claim_1,\n  rcases claim_2 with \u27e8z, H_z\u27e9,\n  have claim_3 : \u22a4 \u2264 S c \u2286\u1d2e v,\n    by {apply two_term_mixture_subset_top, from \u2039_\u203a, refl},\n  have claim_4 : by haveI := subset'_partial_order \u27e8h_core_l,h_core_r\u27e9; from c \u2264 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 =\u1d2e S z = \u22a4,\n    by {have : S z \u2286\u1d2e S c = \u22a4, apply H_c z claim_4,\n        apply top_unique, rw[eq_iff_subset_subset], apply le_inf,\n        rw[top_le_iff], from \u2039_\u203a, rw[<-this]},\n  change a \u2264 _, apply le_trans, apply (mixing_lemma_two_term a (-a) \u2039_\u203a y (S c)).left,\n  change v =\u1d2e _ \u2264 _, rw[bv_eq_symm], apply le_trans', show \ud835\udd39, from v =\u1d2e S z, rw[H_z],\n  apply le_top, apply le_trans, apply bv_eq_trans, apply bv_have (le_top : y =\u1d2e _ \u2264 _),\n  rw[bv_eq_symm] at claim_5, simp[claim_5.symm, bv_eq_trans]\nend\nend zorns_lemma\n\nsection comprehension\nvariables (\u03d5 : bSet \ud835\udd39 \u2192 \ud835\udd39) (x : bSet \ud835\udd39) (H_congr : B_ext \u03d5)\n\n@[reducible]def comprehend : bSet \ud835\udd39 := subset.mk (\u03bb i : x.type, \u03d5 (x.func i))\n\ninclude \u03d5 x H_congr\n\nlemma mem_comprehend_iff : \u2200 {z x : bSet \ud835\udd39} {\u0393}, \u0393 \u2264 z \u2208\u1d2e comprehend \u03d5 x \u2194 \u0393 \u2264 \u2a06 (i : x.type), x.bval i \u2293 (z =\u1d2e (x.func i) \u2293 (\u03bb i : x.type, \u03d5 (x.func i)) i) :=\nby intros; exact mem_subset.mk_iff\u2082\n\nlemma mem_comprehend_iff\u2082 : \u2200 {z : bSet \ud835\udd39} {\u0393}, \u0393 \u2264 z \u2208\u1d2e comprehend \u03d5 x \u2194 \u0393 \u2264 \u2a06 w, w \u2208\u1d2e x \u2293 (z =\u1d2e w \u2293 (\u03bb v, \u03d5 v) w) :=\nbegin\n  intros z \u0393, rw \u2190bounded_exists, apply mem_comprehend_iff, from z, from \u2039_\u203a,\n  change B_ext _, simp*\nend\n\nlemma B_congr_comprehend {\u03d5} {H_congr : B_ext \u03d5} : B_congr (\u03bb x : bSet \ud835\udd39, (comprehend \u03d5 x)) :=\nbegin\n  intros x y \u0393 H_eq, refine mem_ext _ _,\n    { bv_intro z, bv_imp_intro Hz, rw mem_comprehend_iff\u2082 at Hz \u22a2,\n      apply bv_rw' (bv_symm H_eq), simp*, repeat { from \u2039_\u203a }  },\n    { bv_intro z, bv_imp_intro Hz, rw mem_comprehend_iff\u2082 at Hz \u22a2,\n      apply bv_rw' H_eq, simp*, repeat { from \u2039_\u203a }  }\nend\n\nvariables {\u03d5} {H_congr}\nlemma comprehend_subset {\u0393 : \ud835\udd39} : \u0393 \u2264 comprehend \u03d5 x \u2286\u1d2e x :=\nbegin\n  rw subset_unfold', bv_intro z, bv_imp_intro Hz, rw mem_comprehend_iff\u2082 at Hz, bv_cases_at Hz w Hw, bv_split, bv_split, bv_cc, from \u2039_\u203a\nend\n\n/--\nFor any \u03d5 and x, there is a subset y of x such that \u2200 z, z \u2208 y \u2194 z \u2208 x \u2227 \u03d5 z\n-/\n\nvariables (\u03d5) (H_congr)\nlemma bSet_axiom_of_comprehension {\u0393 : \ud835\udd39} : \u0393 \u2264 \u2a06 y, y \u2286\u1d2e x \u2293 \u2a05 z, z \u2208\u1d2e y \u21d4 (z \u2208\u1d2e x \u2293 \u03d5 z) :=\nbegin\n  apply bv_use (comprehend \u03d5 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\u2082],  rw @bounded_exists _ _ _ (\u03bb w, z =\u1d2e w \u2293 \u03d5 w),\n        swap, {change B_ext _, simp* /- nice job, simp! -/ },\n        apply bv_use z, exact le_inf (bv_and.left \u2039_\u203a) (le_inf bv_refl $ bv_and.right \u2039_\u203a) }}\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 \ud835\udd39-valued setting -/\n-- -- \u2200x \u2203\ud835\udc66 \u2200\ud835\udc67 \u2208 \ud835\udc65 (\ud835\udc67 \u2260 \u2205 \u2192 \u2203!\ud835\udc64 \u2208 \ud835\udc67 \u2203\ud835\udc63 \u2208 \ud835\udc66 (\ud835\udc67 \u2208 \ud835\udc63 \u2227 \ud835\udc64 \u2208 \ud835\udc63))\n-- theorem bSet_axiom_of_choice :\n-- (\u2a05(x : bSet \ud835\udd39), \u2a06(y : bSet \ud835\udd39), \u2a05(z : bSet \ud835\udd39),\n--   z \u2208\u1d2e x \u27f9 ((- (z =\u1d2e \u2205)) \u27f9\n--   (\u2a06!(w : bSet \ud835\udd39), w \u2208\u1d2e z \u27f9\n--     \u2a06(v : bSet \ud835\udd39), v \u2208\u1d2e y \u27f9 (z \u2208\u1d2e v \u2293 w \u2208\u1d2e v)))) = \u22a4 := sorry\n\n-- def check_shadow : \u03a0 (x : bSet \ud835\udd39), (bSet \ud835\udd39)\n-- | (bSet.mk \u03b1 A B) := \u27e8\u03b1, \u03bb i, check_shadow (A i), \u03bb _, \u22a4\u27e9\n\n-- lemma check_shadow_check : \u03a0 {x : pSet.{u}}, check_shadow (x\u030c) = (x\u030c : bSet \ud835\udd39)\n-- | \u27e8\u03b1,A\u27e9 := by simp[check, check_shadow,check_shadow_check]\n\ndef dom : \u2200 x : bSet \ud835\udd39, pSet.{u}\n| \u27e8\u03b1,A,B\u27e9 := \u27e8\u03b1, \u03bb i, dom (A i)\u27e9\n\n-- lemma dom_spec : \u03a0 {x : bSet \ud835\udd39}, (dom x)\u030c  = check_shadow x\n-- | \u27e8\u03b1,A,B\u27e9 := by simp[dom, check_shadow, *]\n\n@[reducible]def check_shadow : bSet \ud835\udd39 \u2192 bSet \ud835\udd39 := \u03bb x, (dom x)\u030c\n\nlemma check_shadow_type {x : bSet \ud835\udd39} : (check_shadow x).type = x.type := by cases x; refl\n\n@[reducible]def check_shadow_cast {x : bSet \ud835\udd39} : (check_shadow x).type \u2192 x.type := cast check_shadow_type\n\n@[reducible]def check_shadow_cast_symm {x : bSet \ud835\udd39} : x.type \u2192 (check_shadow x).type := cast (check_shadow_type.symm)\n\n-- bSet \ud835\udd39 retracts onto pSet\nlemma dom_check : \u03a0 {x : pSet.{u}}, dom (x\u030c : bSet \ud835\udd39) = x\n| \u27e8\u03b1,A\u27e9 := by simp[dom,*]\n\nlemma dom_left_inv_check : function.left_inverse dom (check : pSet.{u} \u2192 bSet \ud835\udd39) :=\n\u03bb x, dom_check\n\nlemma check_injective : function.injective (check : pSet.{u} \u2192 bSet \ud835\udd39) :=\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 : \u2200 x y : bSet \ud835\udd39, (\u2200 {\u0393}, \u0393 \u2264 x =\u1d2e y) \u2192 pSet.equiv (dom x) (dom y)\n-- | x@\u27e8\u03b1,A,B\u27e9 x'@\u27e8\u03b1',A',B'\u27e9 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 \ud835\udd39 \u2192 bSet \ud835\udd39)\n-- | x@\u27e8\u03b1,A,B\u27e9 x'@\u27e8\u03b1',A',B'\u27e9 \u0393 H :=\n-- begin\n--   unfold check_shadow, rw[bv_eq_unfold] at H \u22a2, refine le_inf _ _; bv_intro i; simp at \u22a2 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 {\u03b1 : Type u} {\u03b2 \u03b3 : Type v}\n\nnamespace vector_space\nvariables [field \u03b1] [vector_space \u03b1 \u03b2]\n\nvariables (\u03b1 \u03b2)\ndef dim : cardinal :=\ncardinal.min\n  (nonempty_subtype.2 (@exists_is_basis \u03b1 \u03b2 _ _))\n  (\u03bb b, cardinal.mk b.1)\nvariables {\u03b1 \u03b2}\n\ninclude \u03b1\ntheorem basis_le_span (I J : set \u03b2) (h1 : is_basis I) (h2 : \u2200x, x \u2208 span J) : cardinal.mk I \u2264 cardinal.mk J :=\nor.cases_on (le_or_lt cardinal.omega $ cardinal.mk J)\n(assume h4 : cardinal.omega \u2264 cardinal.mk J,\nle_of_not_lt $ assume h3 : cardinal.mk I > cardinal.mk J,\nlet h5 : J \u2192 set \u03b2 := \u03bb j, (h1.1.repr j).support.to_set in\nhave h6 : \u00acI \u2286 \u22c3 j, h5 j,\n  from \u03bb H, @not_lt_of_le _ _ (cardinal.mk I) (cardinal.mk (\u22c3 j, h5 j))\n    (\u27e8set.embedding_of_subset H\u27e9) $\n  calc  cardinal.mk (\u22c3 j, h5 j)\n      \u2264 cardinal.sum (\u03bb j, cardinal.mk (h5 j)) : cardinal.mk_Union_le_sum_mk\n  ... \u2264 cardinal.sum (\u03bb j : J, cardinal.omega.{v}) : cardinal.sum_le_sum _ _ $ \u03bb 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 \u27e8i\u2080, h7\u27e9 := not_forall.1 h6 in\nlet \u27e8h7, h8\u27e9 := not_imp.1 h7 in\nhave h9 : _ := \u03bb j : J, not_exists.1 (mt set.mem_Union.2 h8) j,\nhave h9 : _ := \u03bb j : J, by_contradiction $ mt (finsupp.mem_support_iff (h1.1.repr j) i\u2080).2 $ h9 j,\nlet \u27e8h10, h11, h12\u27e9 := h2 i\u2080 in\nhave h13 : _ := (repr_eq_single h1.1 h7).symm.trans $\n  (congr_arg h1.1.repr h12).trans $\n  repr_finsupp_sum _ $ \u03bb j _, h1.2 _,\nhave h14 : ((finsupp.single i\u2080 (1:\u03b1) : lc \u03b1 \u03b2) : \u03b2 \u2192 \u03b1) i\u2080 = _,\n  from congr_fun (congr_arg finsupp.to_fun h13) i\u2080,\nbegin\n  rw [finsupp.sum_apply, finsupp.single_eq_same, finsupp.sum] at h14,\n  rw [\u2190 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\u2080 = 0 := h9 \u27e8v, h17\u27e9,\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 \u27e8h5, h6\u27e9 := exists_finite_card_le_of_finite_of_linear_independent_of_span\n  (cardinal.lt_omega_iff_finite.1 h4) h1.1 (\u03bb _ _, h2 _) in\nby rwa [\u2190 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 \u03b2} (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 \u03b2} (h : is_basis b) : cardinal.mk b = dim \u03b1 \u03b2 :=\nbegin\n  cases (show \u2203 b', dim \u03b1 \u03b2 = _, 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 \u03b1 \u03b3]\n\ntheorem dim_eq_of_linear_equiv (f : \u03b2 \u2243\u2097 \u03b3) : dim \u03b1 \u03b2 = dim \u03b1 \u03b3 :=\nlet \u27e8b, hb\u27e9 := exists_is_basis \u03b2 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 \u03b1 (\u03b2 \u00d7 \u03b3) = dim \u03b1 \u03b2 + dim \u03b1 \u03b3 :=\nlet \u27e8b, hb\u27e9 := exists_is_basis \u03b2 in\nlet \u27e8c, hc\u27e9 := exists_is_basis \u03b3 in\nhave H1 : _ := prod.is_basis_inl_union_inr hb hc,\nhave H2 : _ := @mk_basis.{u v} _ (\u03b2 \u00d7 \u03b3) _ _ _ H1,\nbegin\n  rw [\u2190 mk_basis hb, \u2190 mk_basis hc, \u2190 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 \u27e8\u27e8x, h1, h2\u27e9, \u27e8y, h3, h4\u27e9\u27e9,\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 \u03b1 _) hb.1 h1\nend\n\ntheorem dim_quotient {s : set \u03b2} [is_submodule s] : dim \u03b1 (quotient_module.quotient \u03b2 s) + dim \u03b1 s = dim \u03b1 \u03b2 :=\nnonempty.rec_on (quotient_module.quotient_prod_linear_equiv s) $ \u03bb 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 \u03b2 \u03b3) : dim \u03b1 f.im + dim \u03b1 f.ker = dim \u03b1 \u03b2 :=\nby rw [\u2190 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 \u2192 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) (\u03b1 : Type u) : KleisliCat m :=\n  \u03b1\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 \u03b1 \u03b2 := \u03b1 \u2192 m \u03b2\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 [(\u00b7 >=> \u00b7), functor_norm]\n  refine' { id_comp := _, comp_id := _, assoc := _ } <;> intros <;> refine funext (fun x => ?_) <;>\n  simp [CategoryStruct.id, CategoryStruct.comp, (\u00b7 >=> \u00b7)]\n#align category_theory.Kleisli.category CategoryTheory.KleisliCat.category\n\n@[simp]\ntheorem KleisliCat.id_def {m} [Monad m] (\u03b1 : KleisliCat m) : \ud835\udfd9 \u03b1 = @pure m _ \u03b1 :=\n  rfl\n#align category_theory.Kleisli.id_def CategoryTheory.KleisliCat.id_def\n\ntheorem KleisliCat.comp_def {m} [Monad m] (\u03b1 \u03b2 \u03b3 : KleisliCat m) (xs : \u03b1 \u27f6 \u03b2) (ys : \u03b2 \u27f6 \u03b3) (a : \u03b1) :\n    (xs \u226b ys) a = xs a >>= ys :=\n  rfl\n#align category_theory.Kleisli.comp_def CategoryTheory.KleisliCat.comp_def\n\ninstance : Inhabited (KleisliCat id) :=\n  \u27e8PUnit\u27e9\n\ninstance {\u03b1 : Type u} [Inhabited \u03b1] : Inhabited (KleisliCat.mk id \u03b1) :=\n  \u27e8show \u03b1 from default\u27e9\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 (_ : \u2200 (\u03b1 : Type) (a : \u03b1), a = a) : Nat := 37\ndef foo2mk (_ : \u2200 {\u03b1 : Type} (a : \u03b1), a = a) : Nat := 37 -- implicit binder\n\nexample (x) : foo1mk x = foo1mk x := rfl -- works\nexample (x : \u2200 {\u03b1 : Type} (a : \u03b1), a = a) : 37 = foo2mk x := rfl -- works\nexample (x) : 37 = foo2mk @x := rfl -- works\nexample (x) : foo1mk x = foo1mk x := rfl -- works\nexample (x : \u2200 {\u03b1 : Type} (a : \u03b1), 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 \u2192 Type v) [Applicative F] [LawfulApplicative F]\n  (G : Type u \u2192 Type w) [Applicative G] [LawfulApplicative G] : Type max (u + 1) v w where\n  app : \u2200 \u03b1 : Type u, F \u03b1 \u2192 G \u03b1\n  preserves_pure' : \u2200 {\u03b1 : Type u} (x : \u03b1), app _ (pure x) = pure x\n  preserves_seq' : \u2200 {\u03b1 \u03b2 : Type u} (x : F (\u03b1 \u2192 \u03b2)) (y : F \u03b1), app _ (x <*> y) = app _ x <*> app _ y\n\nvariable (F : Type u \u2192 Type v) [Applicative F] [LawfulApplicative F]\n\nvariable (G : Type u \u2192 Type w) [Applicative G] [LawfulApplicative G]\n\ninstance : CoeFun (ApplicativeTransformation F G) fun _ => \u2200 {\u03b1}, F \u03b1 \u2192 G \u03b1 :=\n  \u27e8ApplicativeTransformation.app\u27e9\n\nvariable {F G}\n\n@[simp]\ntheorem coe_mk (f : \u2200 (\u03b1 : Type u), F \u03b1 \u2192 G \u03b1) (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 \u2192+* 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' : \u2200 (I : ideal R), I.is_radical \u2192 I.jacobson = I)\n\ntheorem is_jacobson_iff {R} [comm_ring R] :\n  is_jacobson R \u2194 \u2200 (I : ideal R), I.is_radical \u2192 I.jacobson = I :=\n\u27e8\u03bb h, h.1, \u03bb h, \u27e8h\u27e9\u27e9\n\ntheorem is_jacobson.out {R} [comm_ring R] :\n  is_jacobson R \u2192 \u2200 {I : ideal R}, I.is_radical \u2192 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 \u2194 \u2200 P : ideal R, is_prime P \u2192 P.jacobson = P :=\nbegin\n  refine is_jacobson_iff.trans \u27e8\u03bb h I hI, h I hI.is_radical, _\u27e9,\n  refine \u03bb h I hI, le_antisymm (\u03bb x hx, _) (\u03bb x hx, mem_Inf.mpr (\u03bb _ hJ, hJ.left hx)),\n  rw [\u2190 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 [\u2190 h P hP.right, mem_Inf],\n  exact \u03bb J hJ, hx \u27e8le_trans hP.left hJ.left, hJ.right\u27e9\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 \u22a4 in the set `M` of maximal ideals is equivalent, but makes some proofs cleaner. -/\nlemma is_jacobson_iff_Inf_maximal : is_jacobson R \u2194\n  \u2200 {I : ideal R}, I.is_prime \u2192 \u2203 M : set (ideal R), (\u2200 J \u2208 M, is_maximal J \u2228 J = \u22a4) \u2227 I = Inf M :=\n\u27e8\u03bb H I h, eq_jacobson_iff_Inf_maximal.1 (H.out h.is_radical),\n  \u03bb H, is_jacobson_iff_prime_eq.2 (\u03bb P hP, eq_jacobson_iff_Inf_maximal.2 (H hP))\u27e9\n\nlemma is_jacobson_iff_Inf_maximal' : is_jacobson R \u2194\n  \u2200 {I : ideal R}, I.is_prime \u2192 \u2203 M : set (ideal R),\n  (\u2200 (J \u2208 M) (K : ideal R), J < K \u2192 K = \u22a4) \u2227 I = Inf M :=\n\u27e8\u03bb H I h, eq_jacobson_iff_Inf_maximal'.1 (H.out h.is_radical),\n  \u03bb H, is_jacobson_iff_prime_eq.2 (\u03bb P hP, eq_jacobson_iff_Inf_maximal'.2 (H hP))\u27e9\n\nlemma radical_eq_jacobson [H : is_jacobson R] (I : ideal R) : I.radical = I.jacobson :=\nle_antisymm (le_Inf (\u03bb J \u27e8hJ, hJ_max\u27e9, (is_prime.radical_le_iff hJ_max.is_prime).mpr hJ))\n            (H.out (radical_is_radical I) \u25b8 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\u27e8\u03bb I hI, or.rec_on (eq_bot_or_top I)\n(\u03bb h, le_antisymm (Inf_le \u27e8le_rfl, h.symm \u25b8 bot_is_maximal\u27e9) (h.symm \u25b8 bot_le))\n(\u03bb h, by rw [h, jacobson_eq_top_iff])\u27e9\n\ntheorem is_jacobson_of_surjective [H : is_jacobson R] :\n  (\u2203 (f : R \u2192+* S), function.surjective f) \u2192 is_jacobson S :=\nbegin\n  rintros \u27e8f, hf\u27e9,\n  rw is_jacobson_iff_Inf_maximal,\n  intros p hp,\n  use map f '' {J : ideal R | comap f p \u2264 J \u2227 J.is_maximal },\n  use \u03bb j \u27e8J, hJ, hmap\u27e9, hmap \u25b8 (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 \u25b8 (map_comap_of_surjective f hf p).symm,\n  exact this.trans (map_Inf hf (\u03bb J \u27e8hJ, _\u27e9, le_trans (ideal.ker_le_comap f) hJ)),\nend\n\n@[priority 100]\ninstance is_jacobson_quotient [is_jacobson R] : is_jacobson (R \u29f8 I) :=\nis_jacobson_of_surjective \u27e8quotient.mk I, (by rintro \u27e8x\u27e9; use x; refl)\u27e9\n\nlemma is_jacobson_iso (e : R \u2243+* S) : is_jacobson R \u2194 is_jacobson S :=\n\u27e8\u03bb h, @is_jacobson_of_surjective _ _ _ _ h \u27e8(e : R \u2192+* S), e.surjective\u27e9,\n  \u03bb h, @is_jacobson_of_surjective _ _ _ _ h \u27e8(e.symm : S \u2192+* R), e.symm.surjective\u27e9\u27e9\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 = \u22a4,\n  { simp [comap_eq_top_iff.1 hP_top] },\n  { haveI : nontrivial (R \u29f8 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, \u2190 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 (\u03bb 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 \u2192+* 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) \u2191I \u2194 y \u2209 I.1 :=\nbegin\n  refine \u27e8\u03bb h, set.disjoint_left.1 h (mem_powers _), \u03bb h, disjoint_iff.mpr (eq_bot_iff.mpr _)\u27e9,\n  rintros x \u27e8\u27e8n, rfl\u27e9, hx'\u27e9,\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 \u2194 (comap (algebra_map R S) J).is_maximal \u2227 y \u2209 ideal.comap (algebra_map R S) J :=\nbegin\n  split,\n  { refine \u03bb h, \u27e8_, \u03bb hy, h.ne_top (ideal.eq_top_of_is_unit_mem _ hy\n      (map_units _ \u27e8y, submonoid.mem_powers _\u27e9))\u27e9,\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 \u2209 (comap (algebra_map R S) J).1 :=\n      set.disjoint_left.1 hJ.right (submonoid.mem_powers _),\n    erw [\u2190 H.out hJ.left.is_radical, mem_Inf] at this,\n    push_neg at this,\n    rcases this with \u27e8I, hI, hI'\u27e9,\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 \u2264 map (algebra_map R S) I :=\n        (map_comap (submonoid.powers y) S J) \u25b8 (map_mono hI.left),\n      exact absurd (h.1.2 _ (lt_of_le_of_ne this hJ)) hI_p.1 } },\n  { refine \u03bb h, \u27e8\u27e8\u03bb hJ, h.1.ne_top (eq_top_iff.2 _), \u03bb I hI, _\u27e9\u27e9,\n    { rwa [eq_top_iff, \u2190 (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 _ \u27e8comap_mono (le_of_lt hI), _\u27e9),\n      rwa [map_comap (powers y) S I, map_top] at this,\n      refine \u03bb hI', hI.right _,\n      rw [\u2190 map_comap (powers y) S I, \u2190 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 \u2209 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 \u27e8hI, hy\u27e9\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} \u2243o {p : ideal R // p.is_maximal \u2227 y \u2209 p} :=\n{ to_fun := \u03bb p,\n    \u27e8ideal.comap (algebra_map R S) p.1, (is_maximal_iff_is_maximal_disjoint S y p.1).1 p.2\u27e9,\n  inv_fun := \u03bb p,\n    \u27e8ideal.map (algebra_map R S) p.1, is_maximal_of_is_maximal_disjoint y p.1 p.2.1 p.2.2\u27e9,\n  left_inv := \u03bb J, subtype.eq (map_comap (powers y) S J),\n  right_inv := \u03bb 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' := \u03bb I I', \u27e8\u03bb h, (show I.val \u2264 I'.val,\n    from (map_comap (powers y) S I.val) \u25b8 (map_comap (powers y) S I'.val) \u25b8 (ideal.map_mono h)),\n    \u03bb h x hx, h hx\u27e9 }\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 \u03bb P' hP', le_antisymm _ le_jacobson,\n  obtain \u27e8hP', hPM\u27e9 := (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' \u2264 I \u2227 I.is_maximal \u2227 y \u2209 I } \u2264\n    comap (algebra_map R S) P',\n  { intros x hx,\n    have hxy : x * y \u2208 (comap (algebra_map R S) P').jacobson,\n    { rw [ideal.jacobson, mem_Inf],\n      intros J hJ,\n      by_cases y \u2208 J,\n      { exact J.mul_mem_left x h },\n      { exact J.mul_mem_right y ((mem_Inf.1 hx) \u27e8hJ.left, \u27e8hJ.right, h\u27e9\u27e9) } },\n    rw hP at hxy,\n    cases hP'.mem_or_mem hxy with hxy hxy,\n    { exact hxy },\n    { exact (hPM.le_bot \u27e8submonoid.mem_powers _, hxy\u27e9).elim } },\n  refine le_trans _ this,\n  rw [ideal.jacobson, comap_Inf', Inf_eq_infi],\n  refine infi_le_infi_of_subset (\u03bb I hI, \u27e8map (algebra_map R S) I, \u27e8_, _\u27e9\u27e9),\n  { exact \u27e8le_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\u27e9 },\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\u2098 S\u2098 : Type*} [comm_ring R\u2098] [comm_ring S\u2098]\n\n/-- If `I` is a prime ideal of `R[X]` and `pX \u2208 I` is a non-constant polynomial,\n  then the map `R \u2192+* 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 \u2208 P)\n  [algebra (R \u29f8 P.comap (C : R \u2192+* _)) R\u2098]\n  [is_localization.away (pX.map (quotient.mk (P.comap (C : R \u2192+* R[X])))).leading_coeff R\u2098]\n  [algebra (R[X] \u29f8 P) S\u2098]\n  [is_localization ((submonoid.powers (pX.map\n    (quotient.mk (P.comap (C : R \u2192+* R[X])))).leading_coeff).map\n    (quotient_map P C le_rfl) : submonoid (R[X] \u29f8 P)) S\u2098] :\n  (is_localization.map S\u2098 (quotient_map P C le_rfl)\n    ((submonoid.powers\n      (pX.map (quotient.mk (P.comap (C : R \u2192+* R[X])))).leading_coeff).le_comap_map) : R\u2098 \u2192+* _)\n    .is_integral :=\nbegin\n  let P' : ideal R := P.comap C,\n  let M : submonoid (R \u29f8 P') :=\n  submonoid.powers (pX.map (quotient.mk (P.comap (C : R \u2192+* R[X])))).leading_coeff,\n  let M' : submonoid (R[X] \u29f8 P) :=\n  (submonoid.powers (pX.map (quotient.mk (P.comap (C : R \u2192+* R[X])))).leading_coeff).map\n    (quotient_map P C le_rfl),\n  let \u03c6 : R \u29f8 P' \u2192+* R[X] \u29f8 P := quotient_map P C le_rfl,\n  let \u03c6' : R\u2098 \u2192+* S\u2098 := is_localization.map S\u2098 \u03c6 M.le_comap_map,\n  have h\u03c6' : \u03c6.comp (quotient.mk P') = (quotient.mk P).comp C := rfl,\n  intro p,\n  obtain \u27e8\u27e8p', \u27e8q, hq\u27e9\u27e9, hp\u27e9 := is_localization.surj M' p,\n  suffices : \u03c6'.is_integral_elem (algebra_map _ _ p'),\n  { obtain \u27e8q', hq', rfl\u27e9 := hq,\n    obtain \u27e8q'', hq''\u27e9 := is_unit_iff_exists_inv'.1 (is_localization.map_units R\u2098 (\u27e8q', hq'\u27e9 : M)),\n    refine \u03c6'.is_integral_of_is_integral_mul_unit p (algebra_map _ _ (\u03c6 q')) q'' _ (hp.symm \u25b8 this),\n    convert trans (trans (\u03c6'.map_mul _ _).symm (congr_arg \u03c6' hq'')) \u03c6'.map_one using 2,\n    rw [\u2190 \u03c6'.comp_apply, is_localization.map_comp, ring_hom.comp_apply, subtype.coe_mk] },\n  refine is_integral_of_mem_closure''\n    (((algebra_map _ S\u2098).comp (quotient.mk P)) '' (insert X {p | p.degree \u2264 0})) _ _ _,\n  { rintros x \u27e8p, hp, rfl\u27e9,\n    refine hp.rec_on (\u03bb hy, _) (\u03bb hy, _),\n    { refine hy.symm \u25b8 (\u03c6.is_integral_elem_localization_at_leading_coeff ((quotient.mk P) X)\n        (pX.map (quotient.mk P')) _ M \u27e81, pow_one _\u27e9),\n      rwa [eval\u2082_map, h\u03c6', \u2190 hom_eval\u2082, quotient.eq_zero_iff_mem, eval\u2082_C_X] },\n    { rw [set.mem_set_of_eq, degree_le_zero_iff] at hy,\n      refine hy.symm \u25b8 \u27e8X - C (algebra_map _ _ ((quotient.mk P') (p.coeff 0))), monic_X_sub_C _, _\u27e9,\n      simp only [eval\u2082_sub, eval\u2082_C, eval\u2082_X],\n      rw [sub_eq_zero, \u2190 \u03c6'.comp_apply, is_localization.map_comp],\n      refl } },\n  { obtain \u27e8p, rfl\u27e9 := quotient.mk_surjective p',\n    refine polynomial.induction_on p\n      (\u03bb r, subring.subset_closure $ set.mem_image_of_mem _ (or.inr degree_C_le))\n      (\u03bb _ _ h1 h2, _) (\u03bb 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, \u2190 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 \u2192 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\u2098 S\u2098 : Type*) [comm_ring R\u2098] [comm_ring S\u2098]\n  (\u03c6 : R \u2192+* S) (h\u03c6 : function.injective \u03c6) (x : R) (hx : x \u2260 0)\n  [algebra R R\u2098] [is_localization.away x R\u2098]\n  [algebra S S\u2098] [is_localization ((submonoid.powers x).map \u03c6 : submonoid S) S\u2098]\n  (h\u03c6' : ring_hom.is_integral\n    (is_localization.map S\u2098 \u03c6 (submonoid.powers x).le_comap_map : R\u2098 \u2192+* S\u2098)) :\n  (\u22a5 : ideal S).jacobson = (\u22a5 : ideal S) :=\nbegin\n  have hM : ((submonoid.powers x).map \u03c6 : submonoid S) \u2264 non_zero_divisors S :=\n    map_le_non_zero_divisors_of_injective \u03c6 h\u03c6 (powers_le_non_zero_divisors_of_no_zero_divisors hx),\n  letI : is_domain S\u2098 := is_localization.is_domain_of_le_non_zero_divisors _ hM,\n  let \u03c6' : R\u2098 \u2192+* S\u2098 := is_localization.map _ \u03c6 (submonoid.powers x).le_comap_map,\n  suffices : \u2200 I : ideal S\u2098, I.is_maximal \u2192 (I.comap (algebra_map S S\u2098)).is_maximal,\n  { have h\u03d5' : comap (algebra_map S S\u2098) (\u22a5 : ideal S\u2098) = (\u22a5 : ideal S),\n    { rw [\u2190 ring_hom.ker_eq_comap_bot, \u2190 ring_hom.injective_iff_ker_eq_bot],\n      exact is_localization.injective S\u2098 hM },\n    have hS\u2098 : is_jacobson S\u2098 := is_jacobson_of_is_integral' \u03c6' h\u03c6' (is_jacobson_localization x),\n    refine eq_bot_iff.mpr (le_trans _ (le_of_eq h\u03d5')),\n    rw [\u2190 hS\u2098.out is_radical_bot_of_no_zero_divisors, comap_jacobson],\n    exact Inf_le_Inf (\u03bb j hj, \u27e8bot_le, let \u27e8J, hJ\u27e9 := hj in hJ.2 \u25b8 this J hJ.1.2\u27e9) },\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\u2098)).is_prime := comap_is_prime _ I,\n  haveI : (I.comap \u03c6').is_prime := comap_is_prime \u03c6' I,\n  haveI : (\u22a5 : ideal (S \u29f8 I.comap (algebra_map S S\u2098))).is_prime := bot_prime,\n  have hcomm: \u03c6'.comp (algebra_map R R\u2098) = (algebra_map S S\u2098).comp \u03c6 := is_localization.map_comp _,\n  let f := quotient_map (I.comap (algebra_map S S\u2098)) \u03c6 le_rfl,\n  let g := quotient_map I (algebra_map S S\u2098) le_rfl,\n  have := is_maximal_comap_of_is_integral_of_is_maximal' \u03c6' h\u03c6' I hI,\n  have := ((is_maximal_iff_is_maximal_disjoint R\u2098 x _).1 this).left,\n  have : ((I.comap (algebra_map S S\u2098)).comap \u03c6).is_maximal,\n  { rwa [comap_comap, hcomm, \u2190 comap_comap] at this },\n  rw \u2190 bot_quotient_is_maximal_iff at this \u22a2,\n  refine is_maximal_of_is_integral_of_is_maximal_comap' f _ \u22a5\n    ((eq_bot_iff.2 (comap_bot_le_of_injective f quotient_map_injective)).symm \u25b8 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 \u25b8\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\u2098\n      (by rwa [comap_comap, hcomm, \u2190 bot_quotient_is_maximal_iff])))\n      (ring_hom.is_integral_quotient_of_is_integral _ h\u03c6'))),\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 : \u2200 (x : R), C x \u2208 P \u2192 x = 0) :\n  P.jacobson = P :=\nbegin\n  by_cases Pb : P = \u22a5,\n  { exact Pb.symm \u25b8 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 \u2192+* R[X])).is_prime := comap_is_prime C P,\n    obtain \u27e8p, pP, p0\u27e9 := exists_nonzero_mem_of_ne_bot Pb hP,\n    let x := (polynomial.map (quotient.mk (comap (C : R \u2192+* _) P)) p).leading_coeff,\n    have hx : x \u2260 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] \u29f8 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 (\u03bb I, _),\n  introI hI,\n  let R' : subring (R[X] \u29f8 I) := ((quotient.mk I).comp C).range,\n  let i : R \u2192+* R' := ((quotient.mk I).comp C).range_restrict,\n  have hi : function.surjective (i : R \u2192 R') := ((quotient.mk I).comp C).range_restrict_surjective,\n  have hi' : (polynomial.map_ring_hom i : R[X] \u2192+* R'[X]).ker \u2264 I,\n  { refine \u03bb f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (\u03bb n, _),\n    replace hf := congr_arg (\u03bb (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, \u2190 quotient.eq_zero_iff_mem, \u2190 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 [\u2190 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 \u27e8i, hi\u27e9)\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] \u2194 is_jacobson R :=\nbegin\n  refine \u27e8_, is_jacobson_polynomial_of_is_jacobson\u27e9,\n  introI H,\n  exact is_jacobson_of_surjective \u27e8eval\u2082_ring_hom (ring_hom.id _) 1, \u03bb x,\n    \u27e8C x, by simp only [coe_eval\u2082_ring_hom, ring_hom.id_apply, eval\u2082_C]\u27e9\u27e9,\nend\n\ninstance [is_jacobson R] : is_jacobson R[X] :=\nis_jacobson_polynomial_iff_is_jacobson.mpr \u2039is_jacobson R\u203a\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' : \u2200 (x : R), C x \u2208 P \u2192 x = 0) :\n  is_maximal (comap (C : R \u2192+* R[X]) P : ideal R) :=\nbegin\n  haveI hp'_prime : (P.comap (C : R \u2192+* R[X]) : ideal R).is_prime := comap_is_prime C P,\n  obtain \u27e8m, hm\u27e9 := submodule.nonzero_mem_of_bot_lt (bot_lt_of_maximal P polynomial_not_is_field),\n  have : (m : R[X]) \u2260 0, rwa [ne.def, submodule.coe_eq_zero],\n  let \u03c6 : R \u29f8 P.comap (C : R \u2192+* R[X])  \u2192+* R[X] \u29f8 P := quotient_map P (C : R \u2192+* R[X]) le_rfl,\n  let M : submonoid (R \u29f8 P.comap C) :=\n    submonoid.powers ((m : R[X]).map\n      (quotient.mk (P.comap (C : R \u2192+* R[X]) : ideal R))).leading_coeff,\n  rw \u2190 bot_quotient_is_maximal_iff,\n  have hp0 : ((m : R[X]).map\n    (quotient.mk (P.comap (C : R \u2192+* R[X]) : ideal R))).leading_coeff \u2260 0 :=\n    \u03bb hp0', this $ map_injective (quotient.mk (P.comap (C : R \u2192+* R[X]) : ideal R))\n      ((injective_iff_map_eq_zero (quotient.mk (P.comap (C : R \u2192+* R[X]) : ideal R))).2 (\u03bb x hx,\n      by rwa [quotient.eq_zero_iff_mem, (by rwa eq_bot_iff : (P.comap C : ideal R) = \u22a5)] at hx))\n      (by simpa only [leading_coeff_eq_zero, polynomial.map_zero] using hp0'),\n  have hM : (0 : R \u29f8 P.comap C) \u2209 M := \u03bb \u27e8n, hn\u27e9, hp0 (pow_eq_zero hn),\n  suffices : (\u22a5 : ideal (localization M)).is_maximal,\n  { rw \u2190 is_localization.comap_map_of_is_prime_disjoint M (localization M) \u22a5 bot_prime\n        (disjoint_iff_inf_le.mpr $ \u03bb x hx, hM (hx.2 \u25b8 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] \u29f8 P) := M.map \u03c6,\n  have hM' : (0 : R[X] \u29f8 P) \u2209 M' :=\n    \u03bb \u27e8z, hz\u27e9, hM (quotient_map_injective (trans hz.2 \u03c6.map_zero.symm) \u25b8 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 : (\u22a5 : 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' _ _ \u22a5 this,\n    apply is_integral_is_localization_polynomial_quotient P _ (submodule.coe_mem m) },\n  rw (map_bot.symm : (\u22a5 : ideal (localization M')) =\n                     map (algebra_map (R[X] \u29f8 P) (localization M')) \u22a5),\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 [\u2190 quotient.maximal_ideal_iff_is_field_quotient, \u2190 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' : \u2200 (x : R), C x \u2208 P \u2192 x = 0) :\n  ((quotient.mk P).comp C : R \u2192+* R[X] \u29f8 P).is_integral :=\nbegin\n  refine (is_integral_quotient_map_iff _).mp _,\n  let P' : ideal R := P.comap C,\n  obtain \u27e8pX, hpX, hp0\u27e9 :=\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 \u29f8 P') := submonoid.powers (pX.map (quotient.mk P')).leading_coeff,\n  let \u03c6 : R \u29f8 P' \u2192+* R[X] \u29f8 P := quotient_map P C le_rfl,\n  haveI hp'_prime : P'.is_prime := comap_is_prime C P,\n  have hM : (0 : R \u29f8 P') \u2209 M := \u03bb \u27e8n, hn\u27e9, hp0 $ leading_coeff_eq_zero.mp (pow_eq_zero hn),\n  let M' : submonoid (R[X] \u29f8 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' \u2264 _, from le_non_zero_divisors_of_no_zero_divisors (\u03bb hM', hM _)),\n    exact (let \u27e8z, zM, z0\u27e9 := hM' in (quotient_map_injective (trans z0 \u03c6.map_zero.symm)) \u25b8 zM) },\n  { rw \u2190 is_localization.map_comp M.le_comap_map,\n    refine ring_hom.is_integral_trans (algebra_map (R \u29f8 P') (localization M))\n      (is_localization.map (localization M') _ M.le_comap_map) _ _,\n    { exact (algebra_map (R \u29f8 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 \u2192 R[X]/P` is an integral map. -/\nlemma quotient_mk_comp_C_is_integral_of_jacobson :\n  ((quotient.mk P).comp C : R \u2192+* R[X] \u29f8 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] \u2192+* polynomial (R \u29f8 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 \u03bb p hp, polynomial_mem_ideal_of_coeff_mem_ideal P p (\u03bb 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 \u2190 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' _ _ (\u03bb 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    (\u03bb h, absurd (trans (h \u25b8 hPJ : P = comap f \u22a4) comap_top : P = \u22a4) hP.ne_top) id },\n  { apply_instance, },\n  { obtain \u27e8z, rfl\u27e9 := 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 \u2192+* R[X])).is_maximal :=\nbegin\n  rw [\u2190 @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) \u22a5 ((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] \u2192+* 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] \u29f8 f.ker \u2192+* S := ideal.quotient.lift f.ker f (\u03bb _ h, h),\n  have hfg : (g.comp (quotient.mk f.ker)) = f := ring_hom_ext' rfl rfl,\n  rw [\u2190 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 [\u2190 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  \u2200 (n : \u2115), 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 \u2265 I} = Inf {P prime | P \u2265 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] {\u03b9 : Type*} [finite \u03b9] [is_jacobson R] :\n  is_jacobson (mv_polynomial \u03b9 R) :=\nbegin\n  casesI nonempty_fintype \u03b9,\n  haveI := classical.dec_eq \u03b9,\n  let e := fintype.equiv_fin \u03b9,\n  rw is_jacobson_iso (rename_equiv R e).to_ring_equiv,\n  exact is_jacobson_mv_polynomial_fin _\nend\n\nvariables {n : \u2115}\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 \u2192+* mv_polynomial _ R \u29f8 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 [\u2190 fin_succ_equiv_comp_C_eq_C, \u2190 ring_hom.comp_assoc, \u2190 ring_hom.comp_assoc,\n      \u2190 quotient_map_comp_mk le_rfl, ring_hom.comp_assoc (polynomial.C),\n      \u2190 quotient_map_comp_mk le_rfl, ring_hom.comp_assoc, ring_hom.comp_assoc,\n      \u2190 quotient_map_comp_mk le_rfl, \u2190 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 \u2190 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  {\u03c3 : Type*} [finite \u03c3] {S : Type*} [field S] (f : mv_polynomial \u03c3 R \u2192+* S)\n  (hf : function.surjective f) : (f.comp C).is_integral :=\nbegin\n  casesI nonempty_fintype \u03c3,\n  have e := (fintype.equiv_fin \u03c3).symm,\n  let f' : mv_polynomial (fin _) R \u2192+* 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 \u29f8 f'.ker \u2192+* S := ideal.quotient.lift f'.ker f' (\u03bb _ h, h),\n    have hfg : (g.comp (quotient.mk f'.ker)) = f' := ring_hom_ext (\u03bb r, rfl) (\u03bb i, rfl),\n    rw [\u2190 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 \u2190 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 (\u03bb 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 {\u03b1 \u03b2 : Type u} {s : set \u03b1} {f : \u03b1 \u2192 set \u03b2} {g : set (\u03b1 \u2192 \u03b2)}\n\ninstance : monad.{u} set :=\n{ pure       := \u03bb \u03b1 a, {a},\n  bind       := \u03bb \u03b1 \u03b2 s f, \u22c3 i \u2208 s, f i,\n  seq        := \u03bb \u03b1 \u03b2, set.seq,\n  map        := \u03bb \u03b1 \u03b2, set.image }\n\n@[simp] lemma bind_def : s >>= f = \u22c3 i \u2208 s, f i := rfl\n@[simp] lemma fmap_eq_image (f : \u03b1 \u2192 \u03b2) : f <$> s = f '' s := rfl\n@[simp] lemma seq_eq_set_seq (s : set (\u03b1 \u2192 \u03b2)) (t : set \u03b1) : s <*> t = s.seq t := rfl\n@[simp] lemma pure_def (a : \u03b1) : (pure a : set \u03b1) = {a} := rfl\n\ninstance : is_lawful_monad set :=\n{ id_map                := \u03bb \u03b1, image_id,\n  comp_map              := \u03bb \u03b1 \u03b2 \u03b3 f g s, image_comp _ _ _,\n  pure_bind             := \u03bb \u03b1 \u03b2, bUnion_singleton,\n  bind_assoc            := \u03bb \u03b1 \u03b2 \u03b3 s f g, by simp only [bind_def, bUnion_Union],\n  bind_pure_comp_eq_map := \u03bb \u03b1 \u03b2 f s, (image_eq_Union _ _).symm,\n  bind_map_eq_seq       := \u03bb \u03b1 \u03b2 s t, seq_def.symm }\n\ninstance : is_comm_applicative (set : Type u \u2192 Type u) :=\n\u27e8 \u03bb \u03b1 \u03b2 s t, prod_image_seq_comm s t \u27e9\n\ninstance : alternative set :=\n{ orelse := \u03bb \u03b1, (\u222a),\n  failure := \u03bb \u03b1, \u2205,\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 \u03b1` will represent a computation\nusing the oracles of `spec : oracle_spec`, returning values of type `\u03b1`.\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 {\u03b1 \u03b2 \u03b3 : 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 \u2192 Type 1\n| pure' (\u03b1 : Type) (a : \u03b1) : oracle_comp \u03b1\n| bind' (\u03b1 \u03b2 : Type) (oa : oracle_comp \u03b1) (ob : \u03b1 \u2192 oracle_comp \u03b2) : oracle_comp \u03b2\n| query (i : spec.\u03b9) (t : spec.domain i) : oracle_comp (spec.range i)\n\nnamespace oracle_comp\n\ninstance nonempty (spec : oracle_spec) (\u03b1 : Type) [h : nonempty \u03b1] :\n  nonempty (oracle_comp spec \u03b1) := h.elim (\u03bb x, \u27e8pure' \u03b1 x\u27e9)\n\ninstance inhabited (spec : oracle_spec) (\u03b1 : Type) [h : inhabited \u03b1] :\n  inhabited (oracle_comp spec \u03b1) := \u27e8pure' \u03b1 default\u27e9\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 : \u03b1) :\n  (pure' \u03b1 a : oracle_comp spec \u03b1) = return a := rfl\n\n@[simp] lemma pure_eq_return (spec) (a : \u03b1) :\n  (pure a : oracle_comp spec \u03b1) = return a := rfl\n\n@[simp] lemma bind'_eq_bind (oa : oracle_comp spec \u03b1) (ob : \u03b1 \u2192 oracle_comp spec \u03b2) :\n  bind' \u03b1 \u03b2 oa ob = (oa >>= ob) := rfl\n\nlemma map_eq_bind_return_comp (oa : oracle_comp spec \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  f <$> oa = oa >>= return \u2218 f := rfl\n\n/-- Simple computation flipping two coins and returning a value based on them -/\nexample : oracle_comp coin_spec \u2115 :=\ndo { b \u2190 coin, b' \u2190 coin,\n  x \u2190 return (if b && b' then 2 else 3),\n  y \u2190 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 : \u03a0 {\u03b1 : Type}, oracle_comp spec \u03b1 \u2192 Sort*}\n  {\u03b1 : Type} (oa : oracle_comp spec \u03b1)\n  (h_return : \u2200 {\u03b1 : Type} (a : \u03b1), C (return a))\n  (h_bind : \u2200 {\u03b1 \u03b2 : Type} {oa : oracle_comp spec \u03b1} {ob : \u03b1 \u2192 oracle_comp spec \u03b2},\n    C oa \u2192 (\u2200 a, C (ob a)) \u2192 C (oa >>= ob) )\n  (h_query : \u2200 i t, C (query i t)) : C oa :=\nbegin\n  induction oa with \u03b1 a \u03b1 \u03b2 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 \u03b1) : 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 \u03b1) : inhabited \u03b1 :=\nbegin\n  induction oa with \u03b1 a \u03b1 \u03b2 oa ob hoa hob i t,\n  { exact \u27e8a\u27e9 },\n  { exact let \u27e8a\u27e9 := hoa in hob a },\n  { exact \u27e8arbitrary (spec.range i)\u27e9 }\nend\n\n/-- Shorthand for querying the left side of two available oracles. -/\n@[inline, reducible] def query\u2081 {spec spec' : oracle_spec}\n  (i : spec.\u03b9) (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\u2082 {spec spec' : oracle_spec}\n  (i : spec'.\u03b9) (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 : \u03a0 {\u03b1 : Type}, oracle_comp spec \u03b1 \u2192 Type 1\n| decidable_pure' (\u03b1 : Type) (a : \u03b1) (h : decidable_eq \u03b1) : decidable (pure' \u03b1 a)\n| decidable_bind' (\u03b1 \u03b2 : Type) (oa : oracle_comp spec \u03b1) (ob : \u03b1 \u2192 oracle_comp spec \u03b2)\n    (hoa : decidable oa) (hob : \u2200 \u03b1, decidable (ob \u03b1)) : decidable (bind' \u03b1 \u03b2 oa ob)\n| decidable_query (i : spec.\u03b9) (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' : \u03a0 {\u03b1 : Type} {oa : oracle_comp spec \u03b1}\n  (h : decidable oa), decidable_eq \u03b1\n| _ _ (decidable_pure' \u03b1 a h) := h\n| _ _ (decidable_bind' \u03b1 \u03b2 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 \u03b1) [h : oa.decidable] :\n  decidable_eq \u03b1 := decidable_eq_of_decidable' h\n\ninstance decidable_return [h : decidable_eq \u03b1] (a : \u03b1) :\n  decidable (return a : oracle_comp spec \u03b1) := decidable_pure' \u03b1 a h\n\ninstance decidable_pure' [h : decidable_eq \u03b1] (a : \u03b1) :\n  decidable (pure' \u03b1 a : oracle_comp spec \u03b1) := decidable_pure' \u03b1 a h\n\ninstance decidable_pure [h : decidable_eq \u03b1] (a : \u03b1) :\n  decidable (pure a : oracle_comp spec \u03b1) := decidable_pure' \u03b1 a h\n\ninstance decidable_bind (oa : oracle_comp spec \u03b1) (ob : \u03b1 \u2192 oracle_comp spec \u03b2) [h : decidable oa]\n  [h' : \u2200 a, decidable (ob a)] : decidable (oa >>= ob) := decidable_bind' \u03b1 \u03b2 oa ob h h'\n\ninstance decidable_bind' (oa : oracle_comp spec \u03b1) (ob : \u03b1 \u2192 oracle_comp spec \u03b2) [h : decidable oa]\n  [h' : \u2200 a, decidable (ob a)] : decidable (bind' \u03b1 \u03b2 oa ob) := decidable_bind' \u03b1 \u03b2 oa ob h h'\n\ninstance decidable_map [h : decidable_eq \u03b2] (oa : oracle_comp spec \u03b1) [h' : oa.decidable]\n  (f : \u03b1 \u2192 \u03b2) : decidable (f <$> oa) := decidable_bind' \u03b1 \u03b2 oa _ h' (\u03bb a, decidable_pure' \u03b2 _ h)\n\ninstance decidable_query (i : spec.\u03b9) (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 \u03b1} {ob : \u03b1 \u2192 oracle_comp spec \u03b2} :\n  \u03a0 (h : decidable (oa >>= ob)), oa.decidable\n| (decidable_bind' \u03b1 \u03b2 _ _ hoa hob) := hoa\n\ndef decidable_of_decidable_bind_snd {oa : oracle_comp spec \u03b1} {ob : \u03b1 \u2192 oracle_comp spec \u03b2}\n  (a : \u03b1) : \u03a0 (h : decidable (oa >>= ob)), (ob a).decidable\n| (decidable_bind' \u03b1 \u03b2 _ _ hoa hob) := hob a\n\nend decidable\n\n/-- Simple computations should have automatic decidable instances -/\nexample :\ndo {b \u2190 coin, b' \u2190 coin,\n    x \u2190 return (b && b'),\n    y \u2190 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 (\u03b1 : Type u) := \u03a3 n, array n \u03b1\n\ndef mk_buffer {\u03b1 : Type u} : buffer \u03b1 :=\n\u27e80, {data := \u03bb i, fin.elim0 i}\u27e9\n\ndef array.to_buffer {\u03b1 : Type u} {n : nat} (a : array n \u03b1) : buffer \u03b1 :=\n\u27e8n, a\u27e9\n\nnamespace buffer\nvariables {\u03b1 : Type u} {\u03b2 : Type w}\n\ndef nil : buffer \u03b1 :=\nmk_buffer\n\ndef size (b : buffer \u03b1) : nat :=\nb.1\n\ndef to_array (b : buffer \u03b1) : array (b.size) \u03b1 :=\nb.2\n\ndef push_back : buffer \u03b1 \u2192 \u03b1 \u2192 buffer \u03b1\n| \u27e8n, a\u27e9 v := \u27e8n+1, a.push_back v\u27e9\n\ndef pop_back : buffer \u03b1 \u2192 buffer \u03b1\n| \u27e80, a\u27e9   := \u27e80, a\u27e9\n| \u27e8n+1, a\u27e9 := \u27e8n, a.pop_back\u27e9\n\ndef read : \u03a0 (b : buffer \u03b1), fin b.size \u2192 \u03b1\n| \u27e8n, a\u27e9 i := a.read i\n\ndef write : \u03a0 (b : buffer \u03b1), fin b.size \u2192 \u03b1 \u2192 buffer \u03b1\n| \u27e8n, a\u27e9 i v := \u27e8n, a.write i v\u27e9\n\ndef read' [inhabited \u03b1] : buffer \u03b1 \u2192 nat \u2192 \u03b1\n| \u27e8n, a\u27e9 i := a.read' i\n\ndef write' : buffer \u03b1 \u2192 nat \u2192 \u03b1 \u2192 buffer \u03b1\n| \u27e8n, a\u27e9 i v := \u27e8n, a.write' i v\u27e9\n\nlemma read_eq_read' [inhabited \u03b1] (b : buffer \u03b1) (i : nat) (h : i < b.size) :\n  read b \u27e8i, h\u27e9 = read' b i :=\nby cases b; unfold read read'; simp [array.read_eq_read']\n\nlemma write_eq_write' (b : buffer \u03b1) (i : nat) (h : i < b.size) (v : \u03b1) :\n  write b \u27e8i, h\u27e9 v = write' b i v :=\nby cases b; unfold write write'; simp [array.write_eq_write']\n\ndef to_list (b : buffer \u03b1) : list \u03b1 :=\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 {\u03b1 : Type u} : buffer \u03b1 \u2192 list \u03b1 \u2192 buffer \u03b1\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 {\u03b1 : Type u} {n : nat} (nz : 0 < n) :\n  buffer \u03b1 \u2192 array n \u03b1 \u2192 \u2200 i : nat, i < n \u2192 buffer \u03b1\n| \u27e8m, b\u27e9 a 0     _ :=\n  let i : fin n := \u27e8n - 1, lt_aux_2 nz\u27e9 in\n  \u27e8m+1, b.push_back (a.read i)\u27e9\n| \u27e8m, b\u27e9 a (j+1) h :=\n  let i : fin n := \u27e8n - 2 - j, lt_aux_3 h\u27e9 in\n  append_array \u27e8m+1, b.push_back (a.read i)\u27e9 a j (lt_aux_1 h)\n\nprotected def append {\u03b1 : Type u} : buffer \u03b1 \u2192 buffer \u03b1 \u2192 buffer \u03b1\n| b \u27e80, a\u27e9   := b\n| b \u27e8n+1, a\u27e9 := append_array (nat.zero_lt_succ _) b a n (nat.lt_succ_self _)\n\ndef iterate : \u03a0 b : buffer \u03b1, \u03b2 \u2192 (fin b.size \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) \u2192 \u03b2\n| \u27e8_, a\u27e9 b f := a.iterate b f\n\ndef foreach : \u03a0 b : buffer \u03b1, (fin b.size \u2192 \u03b1 \u2192 \u03b1) \u2192 buffer \u03b1\n| \u27e8n, a\u27e9 f := \u27e8n, a.foreach f\u27e9\n\n/-- Monadically map a function over the buffer. -/\n@[inline]\ndef mmap {m} [monad m] (b : buffer \u03b1) (f : \u03b1 \u2192 m \u03b2) : m (buffer \u03b2) :=\ndo b' \u2190 b.2.mmap f, return b'.to_buffer\n\n/-- Map a function over the buffer. -/\n@[inline]\ndef map : buffer \u03b1 \u2192 (\u03b1 \u2192 \u03b2) \u2192 buffer \u03b2\n| \u27e8n, a\u27e9 f := \u27e8n, a.map f\u27e9\n\ndef foldl : buffer \u03b1 \u2192 \u03b2 \u2192 (\u03b1 \u2192 \u03b2 \u2192 \u03b2) \u2192 \u03b2\n| \u27e8_, a\u27e9 b f := a.foldl b f\n\ndef rev_iterate : \u03a0 (b : buffer \u03b1), \u03b2 \u2192 (fin b.size \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) \u2192 \u03b2\n| \u27e8_, a\u27e9 b f := a.rev_iterate b f\n\ndef take (b : buffer \u03b1) (n : nat) : buffer \u03b1 :=\nif h : n \u2264 b.size then \u27e8n, b.to_array.take n h\u27e9 else b\n\ndef take_right (b : buffer \u03b1) (n : nat) : buffer \u03b1 :=\nif h : n \u2264 b.size then \u27e8n, b.to_array.take_right n h\u27e9 else b\n\ndef drop (b : buffer \u03b1) (n : nat) : buffer \u03b1 :=\nif h : n \u2264 b.size then \u27e8_, b.to_array.drop n h\u27e9 else b\n\ndef reverse (b : buffer \u03b1) : buffer \u03b1 :=\n\u27e8b.size, b.to_array.reverse\u27e9\n\nprotected def mem (v : \u03b1) (a : buffer \u03b1) : Prop := \u2203i, read a i = v\n\ninstance : has_mem \u03b1 (buffer \u03b1) := \u27e8buffer.mem\u27e9\n\ninstance : has_append (buffer \u03b1) :=\n\u27e8buffer.append\u27e9\n\ninstance [has_repr \u03b1] : has_repr (buffer \u03b1) :=\n\u27e8repr \u2218 to_list\u27e9\n\nmeta instance [has_to_format \u03b1] : has_to_format (buffer \u03b1) :=\n\u27e8to_fmt \u2218 to_list\u27e9\n\nmeta instance [has_to_tactic_format \u03b1] : has_to_tactic_format (buffer \u03b1) :=\n\u27e8tactic.pp \u2218 to_list\u27e9\n\nend buffer\n\ndef list.to_buffer {\u03b1 : Type u} (l : list \u03b1) : buffer \u03b1 :=\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 \u2192 options \u2192 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\u2081 u\u2082 v\u2081 v\u2082 u\u2083 u\u2084 v\u2083 v\u2084 \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\u2081) [category C] (D : Type u\u2082) [category D] : category (C \u00d7 D) :=\n  category.mk\n\n-- rfl lemmas for category.prod\n\n@[simp] theorem prod_id (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C) (Y : D) : \ud835\udfd9 = (\ud835\udfd9, \ud835\udfd9) :=\n  rfl\n\n@[simp] theorem prod_comp (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] {P : C} {Q : C} {R : C} {S : D} {T : D} {U : D} (f : (P, S) \u27f6 (Q, T)) (g : (Q, T) \u27f6 (R, U)) : f \u226b g = (prod.fst f \u226b prod.fst g, prod.snd f \u226b prod.snd g) :=\n  rfl\n\n@[simp] theorem prod_id_fst (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 D) : prod.fst \ud835\udfd9 = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem prod_id_snd (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 D) : prod.snd \ud835\udfd9 = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem prod_comp_fst (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] {X : C \u00d7 D} {Y : C \u00d7 D} {Z : C \u00d7 D} (f : X \u27f6 Y) (g : Y \u27f6 Z) : prod.fst (f \u226b g) = prod.fst f \u226b prod.fst g :=\n  rfl\n\n@[simp] theorem prod_comp_snd (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] {X : C \u00d7 D} {Y : C \u00d7 D} {Z : C \u00d7 D} (f : X \u27f6 Y) (g : Y \u27f6 Z) : prod.snd (f \u226b g) = prod.snd f \u226b 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\u2081) [category C] (D : Type u\u2081) [category D] : category (C \u00d7 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 \u2964 C \u00d7 D` given by `X \u21a6 (X, Z)`. -/\n@[simp] theorem sectl_obj (C : Type u\u2081) [category C] {D : Type u\u2082} [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 \u2964 C \u00d7 D` given by `Y \u21a6 (Z, Y)` . -/\ndef sectr {C : Type u\u2081} [category C] (Z : C) (D : Type u\u2082) [category D] : D \u2964 C \u00d7 D :=\n  functor.mk (fun (X : D) => (Z, X)) fun (X Y : D) (f : X \u27f6 Y) => (\ud835\udfd9, f)\n\n/-- `fst` is the functor `(X, Y) \u21a6 X`. -/\n@[simp] theorem fst_obj (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 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) \u21a6 Y`. -/\n@[simp] theorem snd_map (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 D) (Y : C \u00d7 D) (f : X \u27f6 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 \u00d7 D \u2964 D \u00d7 C`. -/\n@[simp] theorem swap_map (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (_x : C \u00d7 D) : \u2200 (_x_1 : C \u00d7 D) (f : _x \u27f6 _x_1), functor.map (swap C D) f = (prod.snd f, prod.fst f) :=\n  fun (_x_1 : C \u00d7 D) (f : _x \u27f6 _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\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 D) : nat_trans.app (iso.hom (symmetry C D)) X = \ud835\udfd9 :=\n  Eq.refl (nat_trans.app (iso.hom (symmetry C D)) X)\n\n/--\nThe equivalence, given by swapping factors, between `C \u00d7 D` and `D \u00d7 C`.\n-/\n@[simp] theorem braiding_counit_iso_inv_app (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : D \u00d7 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\u2081) [category C] (D : Type u\u2082) [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\u2081) [category C] (D : Type u\u2082) [category D] : C \u2964 (C \u2964 D) \u2964 D :=\n  functor.mk\n    (fun (X : C) => functor.mk (fun (F : C \u2964 D) => functor.obj F X) fun (F G : C \u2964 D) (\u03b1 : F \u27f6 G) => nat_trans.app \u03b1 X)\n    fun (X Y : C) (f : X \u27f6 Y) => nat_trans.mk fun (F : C \u2964 D) => functor.map F f\n\n/--\nThe \"evaluation of `F` at `X`\" functor,\nas a functor `C \u00d7 (C \u2964 D) \u2964 D`.\n-/\n@[simp] theorem evaluation_uncurried_obj (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (p : C \u00d7 (C \u2964 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\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083} [category C] {D : Type u\u2084} [category D] (F : A \u2964 B) (G : C \u2964 D) (X : A \u00d7 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 \u00d7 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\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083} [category C] {D : Type u\u2084} [category D] {F : A \u2964 B} {G : A \u2964 B} {H : C \u2964 D} {I : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) (X : A \u00d7 C) : app (prod \u03b1 \u03b2) X = (app \u03b1 (prod.fst X), app \u03b2 (prod.snd X)) :=\n  Eq.refl (app (prod \u03b1 \u03b2) 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 \u2260 0`.\n- `associated_primes.eq_singleton_of_is_primary`: In a noetherian ring, `I.radical` is the only\n  associated prime of `R \u29f8 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 \u2227 \u2203 x : M, I = (R \u2219 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 \u2192\u2097[R] M')\n\ntheorem AssociatePrimes.mem_iff : I \u2208 associatedPrimes R M \u2194 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 \u27e8x, rfl\u27e9 := h.2\n  refine' \u27e8h.1, \u27e8f x, _\u27e9\u27e9\n  ext r\n  rw [Submodule.mem_annihilator_span_singleton, Submodule.mem_annihilator_span_singleton, \u2190\n    map_smul, \u2190 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 \u2243\u2097[R] M') :\n    IsAssociatedPrime I M \u2194 IsAssociatedPrime I M' :=\n  \u27e8fun h => h.map_of_injective l l.Injective, fun h => h.map_of_injective l.symm l.symm.Injective\u27e9\n#align linear_equiv.is_associated_prime_iff LinearEquiv.isAssociatedPrime_iff\n\ntheorem not_isAssociatedPrime_of_subsingleton [Subsingleton M] : \u00acIsAssociatedPrime I M :=\n  by\n  rintro \u27e8hI, x, hx\u27e9\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 \u2260 0) : \u2203 P : Ideal R, IsAssociatedPrime P M \u2227 (R \u2219 x).annihilator \u2264 P :=\n  by\n  have : (R \u2219 x).annihilator \u2260 \u22a4 := by\n    rwa [Ne.def, Ideal.eq_top_iff_one, Submodule.mem_annihilator_span_singleton, one_smul]\n  obtain \u27e8P, \u27e8l, h\u2081, y, rfl\u27e9, h\u2083\u27e9 :=\n    set_has_maximal_iff_noetherian.mpr H\n      { P | (R \u2219 x).annihilator \u2264 P \u2227 P \u2260 \u22a4 \u2227 \u2203 y : M, P = (R \u2219 y).annihilator }\n      \u27e8(R \u2219 x).annihilator, rfl.le, this, x, rfl\u27e9\n  refine' \u27e8_, \u27e8\u27e8h\u2081, _\u27e9, y, rfl\u27e9, l\u27e9\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\u2081 : (R \u2219 y).annihilator \u2264 (R \u2219 a \u2022 y).annihilator :=\n    by\n    intro c hc\n    rw [Submodule.mem_annihilator_span_singleton] at hc\u22a2\n    rw [smul_comm, hc, smul_zero]\n  have H\u2082 : (Submodule.span R {a \u2022 y}).annihilator \u2260 \u22a4 := by\n    rwa [Ne.def, Submodule.annihilator_eq_top_iff, Submodule.span_singleton_eq_bot]\n  rwa [\u2190 h\u2083 (R \u2219 a \u2022 y).annihilator \u27e8l.trans H\u2081, H\u2082, _, rfl\u27e9 H\u2081,\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 \u2286 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 \u2243\u2097[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 = \u2205 := 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 \u27e8x, hx\u27e9 := exists_ne (0 : M)\n  obtain \u27e8P, hP, _\u27e9 := exists_le_isAssociatedPrime_of_isNoetherianRing R x hx\n  exact \u27e8P, hP\u27e9\n#align associated_primes.nonempty associatedPrimes.nonempty\n\nvariable {R M}\n\ntheorem IsAssociatedPrime.annihilator_le (h : IsAssociatedPrime I M) :\n    (\u22a4 : Submodule R M).annihilator \u2264 I :=\n  by\n  obtain \u27e8hI, x, rfl\u27e9 := 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 \u29f8 I)) :\n    J = I.radical := by\n  obtain \u27e8hJ, x, e\u27e9 := h\n  have : x \u2260 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 \u27e8x, rfl\u27e9 := Ideal.Quotient.mk\u2090_surjective R _ x\n  replace e : \u2200 {y}, y \u2208 J \u2194 x * y \u2208 I\n  \u00b7 intro y\n    rw [e, Submodule.mem_annihilator_span_singleton, \u2190 map_smul, smul_eq_mul, mul_comm,\n      Ideal.Quotient.mk\u2090_eq_mk, \u2190 Ideal.Quotient.mk_eq_mk, Submodule.Quotient.mk_eq_zero]\n  apply le_antisymm\n  \u00b7 intro y hy\n    exact (hI.2 <| e.mp hy).resolve_left ((Submodule.Quotient.mk_eq_zero I).Not.mp this)\n  \u00b7 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 \u29f8 I) = {I.radical} :=\n  by\n  ext J\n  rw [Set.mem_singleton_iff]\n  refine' \u27e8IsAssociatedPrime.eq_radical hI, _\u27e9\n  rintro rfl\n  haveI : Nontrivial (R \u29f8 I) := \u27e8\u27e8(I.Quotient.mk : _) 1, (I.Quotient.mk : _) 0, _\u27e9\u27e9\n  obtain \u27e8a, ha\u27e9 := associatedPrimes.nonempty R (R \u29f8 I)\n  exact ha.eq_radical hI \u25b8 ha\n  rw [Ne.def, Ideal.Quotient.eq, sub_zero, \u2190 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 : \u2115) extends group G :=\n-- (card_pow_p: \u2203 n : \u2115 , 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 : \u2115) extends subgroup G :=\n-- (card_pow_p: \u2203 n : \u2115 , fincard (carrier) = p^n)\n\ndef is_p_subgroup (H : subgroup G) (p : \u2115) := \u2203 n : \u2115 , fincard H = p ^ n \n\ndef dumb_fun' (H : subgroup G) (g : G) (X : set G) : set G :=\n  {t | \u2203 x \u2208 X , t = g * x}\n\nlemma dumb_fun_lcoset_eq (g h : G) (H : subgroup G) : \n  dumb_fun' H h (g \u22c6 H) = h * g \u22c6 H :=\nbegin\n  ext, split, \n  { rintro \u27e8x, \u27e8h', hh', rfl\u27e9, rfl\u27e9,\n    exact \u27e8h', hh', (group.mul_assoc _ _ _).symm\u27e9 },\n  { rintro \u27e8h', hh', rfl\u27e9,\n    refine \u27e8g * h', \u27e8h', hh', rfl\u27e9, group.mul_assoc _ _ _\u27e9 }\nend\n\ndef dumb_fun (H : subgroup G) (g : G) (X : lcosets H) : lcosets H :=\n\u27e8dumb_fun' H g X.1, \n  begin\n  rcases X with \u27e8g', \u27e8w, rfl\u27e9\u27e9, \n  use g * w, ext, split,\n    { intro hx,\n      rcases hx with \u27e8hx_w, \u27e8h, hh, rfl\u27e9, rfl\u27e9,\n      use h,\n      simpa [group.mul_assoc] },\n    { rintro \u27e8h, hh, rfl\u27e9,\n      use w * h,\n      simpa [group.mul_assoc] }\n  end\u27e9\n\ndef laction.comap {H : Type} [group H] (f : H \u2192* G) (S : Type) (\u03bc : laction G S) :\n  laction H S := \n{ to_fun := \u03bb h s, f h \u2022[\u03bc] s,\n  map_one' := \u03bb s, (map_one f).symm \u25b8 \u03bc.map_one s,\n  map_assoc' := \u03bb g h s, (map_mul f g h).symm \u25b8 \u03bc.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 \u27e8_, g', rfl\u27e9,\n    unfold dumb_fun, unfold dumb_fun',\n    norm_num, ext1, norm_num, split,\n      { rintro \u27e8_, \u27e8t, \u27e8s, \u27e8hs, ht\u27e9\u27e9, rfl\u27e9, rfl\u27e9,\n        use t, split, use [s, hs], exact ht,\n        rw group.mul_assoc },\n      { rintro \u27e8_, \u27e8s, hs, rfl\u27e9, rfl\u27e9,\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 (\ud835\udcbe 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 \u2208 normalizer_of_set H.carrier at hg,\n      rw mem_normalizer_of_set_iff at hg,\n      specialize hg n,\n      rw \u2190 hg,\n      unfold comap at hnorm,\n      rw mem_preimage at hnorm,\n      change n \u2208 H at hnorm,\n      assumption,\n    end,\n  .. comap (\ud835\udcbe (normalizer_of_set H.carrier)) H }\n\ndef to_lcosets (g : G) (H : subgroup G) : lcosets H := \u27e8g \u22c6 H, \u27e8g, rfl\u27e9\u27e9\n\nlemma aux_lemma [fintype G] (H : subgroup G) (g : G) :\n  (H : set G) \u2264 conjugate_subgroup g H \u2194 g \u2208 normalizer H :=\n\u27e8begin\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 \u2190h},\n  apply subset.refl\nend\u27e9\n\nlemma foo [fintype G] (H : subgroup G) (g : G):\nto_lcosets g H  \u2208 (fixed_points (dumb_action' H)) \u2194 g \u2208 normalizer H :=\nbegin\n  rw \u2190aux_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 \u27e8h, hh\u27e9,\n    simp * at *,\n    use g\u207b\u00b9 * h * g,\n    rw ext_iff at h1,\n    specialize h1 (h * g),\n    have h2 : h * g \u2208 g \u22c6 H,\n      rw \u2190h1,\n      use g,\n      use 1,\n      use H.one_mem,\n      rw group.mul_one,\n      rcases h2 with \u27e8j, hj1, hj2\u27e9,\n      rw group.mul_assoc,\n      rw hj2,\n      rw [\u2190 group.mul_assoc, group.mul_left_inv, group.one_mul],\n      use hj1,\n      rw \u2190 hj2,\n      simp [group.mul_assoc] },\n  { rintros h1 \u27e8h, hh\u27e9,\n    ext x, split,\n    { rintro \u27e8_, \u27e8k, hk1, rfl\u27e9, rfl\u27e9,\n      rcases h1 hh with \u27e8w, hw, rfl\u27e9,\n      show g * w * g\u207b\u00b9 * _ \u2208 _,\n      use w * k,\n      use H.mul_mem hw hk1,\n      simp [group.mul_assoc]\n    },\n    { rintro \u27e8j, hx, rfl\u27e9,\n      rw set.mem_set_of_eq,\n      rcases h1 hh with \u27e8w, hw, rfl\u27e9,\n      use g*w\u207b\u00b9*j,\n      split,\n        use w\u207b\u00b9*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 \u2192 fixed_points (dumb_action' H) :=\n\u03bb h, \u27e8to_lcosets h.1 H, (foo H h.1).2 h.2\u27e9\n\nlemma proj_eq_coset [fintype G] (H : subgroup G) (b : fixed_points (dumb_action' H)) :\n  \u2203 g, (\ud835\udcbe (normalizer H)) '' ((projection H) \u207b\u00b9' {b}) = g \u22c6 H :=\nbegin\n  rcases b with \u27e8\u27e8_, g, rfl\u27e9, hg\u27e9,\n  use g,\n  change to_lcosets g H \u2208 _ at hg,\n  rw foo at hg,\n  ext x,\n  split,\n    rintro \u27e8\u27e8k, hk\u27e9, hk2, rfl\u27e9,\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 \u2190hk2,\n    use 1,\n    use H.one_mem,\n    rw group.mul_one,\n    refl,\n  rintro \u27e8a, ha, rfl\u27e9,\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) \u207b\u00b9' {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 (\ud835\udcbe (normalizer H)) injective_\ud835\udcbe,\n  rw \u2190 hg,\n  rw \u2190 h\nend\n\n\nnoncomputable instance boo36 [fintype G] (H : subgroup G) : fintype H := fintype.of_injective (\ud835\udcbe H) injective_\ud835\udcbe\n\ndef ZZZ [fintype G] (H : subgroup G) := fincard.finsum_fibres (projection H)\n\ndef lcosets_to_sets  (H : subgroup G): lcosets H \u2192 { B | \u2203 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 (\u03bb g, to_lcosets g H) begin\n  rintro \u27e8C_val, g, rfl\u27e9,\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 \u2260 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 [\u2190 mem_empty_eq (1 : G), \u2190 h],\n  exact H.one_mem,\nend \n\nlemma index_normalizer_congr_index_modp [fintype G] \n  {p : \u2115} (hp: p.prime) (H : subgroup G) (h: is_p_subgroup H p) :\n  index' (normalizer_of_set (H : set G)) H \u2261 index H [MOD p] := \n  begin\n    have claim: \u2200 g : G, to_lcosets g H \u2208 (fixed_points (dumb_action' H)) \u2194 \n      g \u2208 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 \u2190 fincard.finsum_fibres (projection H),\n        simp_rw proj_fincard,\n        rw \u2190 finsum_in_eq_finsum (\u03bb _, 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 \u2261 (index' (normalizer_of_set (H : set G)) H) [MOD p],\n      rw h3,\n      rw \u2190h2,\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 : \u2115} (hp: p.prime) (h: is_p_subgroup H p):\np \u2223 index H \u2192 p \u2223 (index' (normalizer_of_set (H : set G)) H):=\nbegin\n  intro hH,\n  have h1: index' (normalizer_of_set (H : set G)) H  \u2261 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 : \u2115} (hp: p.prime) (h: is_p_subgroup H p) : \n  p \u2223 index H \u2192 normalizer_of_set (H : set G) \u2260 H := \nbegin\n  intro hH,\n  have h1: index' (normalizer_of_set (H : set G)) H  \u2261 H.index [MOD p],\n    { apply index_normalizer_congr_index_modp hp H h },\n  have h2: p \u2223 (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) \u2260 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)) \u2260 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 /\u2098 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 /\u2098 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 \u2264 K) : normal.comap (\ud835\udcbe K) H \u2243 H := \n{ to_fun := \u03bb g, \u27e8g.1.1, \n    begin\n      rcases g with \u27e8\u27e8g, _\u27e9, hg\u27e9,\n      exact hg\n    end\u27e9,\n  inv_fun := \u03bb g, \u27e8\u27e8g.1, h g.2\u27e9, g.2\u27e9,\n  left_inv := by rintro \u27e8\u27e8_, _\u27e9, _\u27e9; simp,\n  right_inv := by rintro \u27e8_, _\u27e9; simp }\n\ndef equiv_comap_of_sub' (H K : subgroup G)\n  (h : H \u2264 K) : subgroup.comap (\ud835\udcbe K) H \u2243 H := \n{ to_fun := \u03bb g, \u27e8g.1.1, \n    begin\n      rcases g with \u27e8\u27e8g, _\u27e9, hg\u27e9,\n      exact hg\n    end\u27e9,\n  inv_fun := \u03bb g, \u27e8\u27e8g.1, h g.2\u27e9, g.2\u27e9,\n  left_inv := by rintro \u27e8\u27e8_, _\u27e9, _\u27e9; simp,\n  right_inv := by rintro \u27e8_, _\u27e9; simp }\n\ndef equiv_map_of_sub (H : subgroup G) (K : subgroup H) :\n  map (\ud835\udcbe H) K \u2243 K := \n{ to_fun := \u03bb k,\n    begin\n      refine \u27e8\u27e8k.1, _\u27e9, _\u27e9;\n        rcases k with \u27e8k, \u27e8_, hk\u27e9, hk', rfl\u27e9,\n        exact hk,\n        exact hk',\n    end,\n  inv_fun := \u03bb k, \u27e8k.1, k, k.2, rfl\u27e9,\n  left_inv := by rintro \u27e8_, _, _, _\u27e9; simp,\n  right_inv := by rintro \u27e8_, _\u27e9; simp }\n\nlemma index_eq_index' [fintype G] (H K : subgroup G) (h: K \u2264 H):\n  index (comap (\ud835\udcbe 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 (\ud835\udcbe H) K) = fincard (H /\u2098 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 \u2191K),\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: \u2115} {hp : p.prime}{hG : fincard G = p ^ n * m} {hdiv : \u00ac p \u2223 m} : \n  \u2200 (i \u2264 n), \u2203 H : subgroup G, fincard H = p ^ i := \nbegin\n  intros i hin,\n  induction i with i hi,   \n  { use \u22a5 ,\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 \u2264 n,\n    refine le_trans _ hin, simp,\n  specialize hi useful2,\n  cases hi with H hH,\n  \n  have fact0: p \u2223 index H,\n  { unfold index,\n    rw [hG, hH, show n = i + (n - i), by simp [\u2190 nat.add_sub_assoc useful2 _], \n        nat.pow_add, nat.mul_assoc, nat.mul_comm, \n        nat.mul_div_assoc _ (show p ^ i \u2223 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 \u2190 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  \u2261 H.index [MOD p],\n  {  refine index_normalizer_congr_index_modp hp H _ ,\n    use i, exact hH }, \n  have fact2: p \u2223 (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 \u2223 fincard (normalizer_of_set (H : set G) /\u2098 normal_in_normalizer_of_set H),\n    { rw \u2190 index'_eq_card_quotient,\n      cases fact2 with k hk,\n      use k,\n      rw \u2190 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: \u2203 (K : subgroup (normalizer_of_set (H : set G) /\u2098 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 (\ud835\udcbe (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 \u2190 fincard.card_eq_image_of_injective (\ud835\udcbe (normalizer_of_set H.carrier)),\n  change fincard (quotient.comap (normal_in_normalizer_of_set H) K).carrier = p ^ i.succ,\n  rw \u2190  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 \u2190 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 \u2190 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_\ud835\udcbe,  \nend    \n\ndef conjugate_iso (g : G) (H : subgroup G) : H \u2245 conjugate_subgroup g H :=\n{ to_fun := \u03bb (h : H) , \u27e8g * h * g\u207b\u00b9, begin use [h, h.2] end\u27e9,\n  map_mul' := \n    begin\n      rintro \u27e8x, hx\u27e9 \u27e8y, hy\u27e9,\n      congr' 1,\n      change g * (x * y) * g\u207b\u00b9 = _,\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 \u27e8b, h, hh, rfl\u27e9,\n        use \u27e8h, hh\u27e9, \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: \u2115} (hp : p.prime)(hG : fincard G = p ^ n * m)\n (hdiv : \u00ac p \u2223 m) (K : subgroup G): Prop := fincard K = p ^ n\n\ndef dumb_action2 (H K: subgroup G) : laction K (lcosets H) :=\nlaction.comap (\ud835\udcbe K) (lcosets H) (dumb_action H)\n\ntheorem sylow_two [fintype G]{p m n: \u2115} (hp : p.prime)(hG : fincard G = p ^ n * m)\n (hdiv : \u00ac p \u2223 m) (H K : subgroup G) (h\u2081 : is_sylow_p_subgroup hp hG hdiv H)(h\u2082 : is_sylow_p_subgroup hp hG hdiv K) : \n\u2203 (g : G), H = conjugate_subgroup g K  :=\nbegin\n  have claim: \u00ac p \u2223 index H,\n  { unfold index,\n    unfold is_sylow_p_subgroup at h\u2081,\n    rw [hG, h\u2081, 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: \u00ac H.index \u2261 0 [MOD p],\n  { intro h, apply claim,\n    apply nat.modeq.modeq_zero_iff.1, exact h },\n\n  have claim3: H.index \u2261 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\u2082\n    sorry}, \n  sorry\nend    \n\n\n\n-- Consider the action of K on the set X of cosets of H in G \u03bc: K \u00d7 X \u2192 X, (y, xH) \u21a6 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 \u03bc) \u2260 0. We then want to show that xH \u2208 fixed_points \u03bc \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\u207b\u00b9 = 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 : \u2115} (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: \u2115}{hp : p.prime}\n--   {hG : fincard G = p ^ n * m} {hdiv : \u00ac p \u2223 m}:\n-- number_sylow_p G hp \u2261 1 [MOD p] := sorry \n-- theorem sylow_three_part2 [fintype G]{p m n: \u2115} {hp : p.prime}{hG : fincard G = p ^ n * m} {hdiv : \u00ac p \u2223 m}:\n-- number_sylow_p G hp \u2223 m := sorry \n--By Sylow 1 \u2203 a Sylow p-subgroup P, so we set X = Sylp(G) = {Sylow p-groups in G}\n--Then P acts on X by \u03bc : P \u00d7 X \u2192 X, (x, Q) \u21a6 xQx\u207b\u00b9 (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 \u2261 fincard (fixed points \u03bc) [MOD p]. Want to show fincard (fixed points \u03bc) = 1.\n--Let P \u2208 fixed points \u03bc and Q \u2208 fixed points \u03bc. 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 \u2203 x \u2208 normalizer_of_set Q s.t. xQx\u207b\u00b9 = P (Sylow 2)\n--By def of normalizer_of_set Q we have Q = P, so fixed_points \u03bc = {P}, proving the first part of the theorem.end\n--Now if P acts on X by conjugation \u2203 ! orbit such that X = orbit G P (Sylow 2).\n--By orbit-stabilizer number_sylow_p = (fincard X) \u2223 (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 {\u03b1} (xs : List \u03b1) : List (Option \u03b1) := none :: xs.map some\n\nnamespace Index\nvariable {\u03b1} {xs : List \u03b1}\n\ndef option : Option (Index xs) \u2192 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)) \u2192 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)) \u2192 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 \u2194 i = unoption k := by\n  constr\n  \u00b7 intro h; rw [\u2190h, unoption_option]\n  \u00b7 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 \u2194 k = option i := by\n  constr\n  \u00b7 intro h; rw [\u2190h, option_unoption]\n  \u00b7 intro h; rw [h, unoption_option]\n\ndef optionEquiv (xs : List \u03b1) : Equiv (Option (Index xs)) (Index (List.option xs)) where\n  fwd := option\n  rev := unoption\n  spec := by\n    intros\n    constr\n    \u00b7 intro | rfl => exact unoption_option ..\n    \u00b7 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 [\u2190option_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 : \u03b1 \u2192 \u03b2} [DecidablePred p] : DecidablePred (p \u2218 f) :=\n  inferInstanceAs <| DecidablePred fun x => p (f x)\n\n/-! ## not -/\n\ntheorem Not.intro {a : Prop} (h : a \u2192 False) : \u00aca := h\n\n/-- Ex falso for negation. From `\u00aca` 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 {\u03b1 : Sort _} (H1 : \u00aca) (H2 : a) : \u03b1 := absurd H2 H1\n\ntheorem Not.imp {a b : Prop} (H2 : \u00acb) (H1 : a \u2192 b) : \u00aca := mt H1 H2\n\ntheorem not_congr (h : a \u2194 b) : \u00aca \u2194 \u00acb := \u27e8mt h.2, mt h.1\u27e9\n\ntheorem not_not_not : \u00ac\u00ac\u00aca \u2194 \u00aca := \u27e8mt not_not_intro, not_not_intro\u27e9\n\ntheorem not_not_of_not_imp : \u00ac(a \u2192 b) \u2192 \u00ac\u00aca := mt Not.elim\n\ntheorem not_of_not_imp {a : Prop} : \u00ac(a \u2192 b) \u2192 \u00acb := mt fun h _ => h\n\n@[simp] theorem imp_not_self : (a \u2192 \u00aca) \u2194 \u00aca := \u27e8fun h ha => h ha ha, fun h _ => h\u27e9\n\n/-! ## iff -/\n\ntheorem iff_def : (a \u2194 b) \u2194 (a \u2192 b) \u2227 (b \u2192 a) := iff_iff_implies_and_implies ..\n\ntheorem iff_def' : (a \u2194 b) \u2194 (b \u2192 a) \u2227 (a \u2192 b) := iff_def.trans And.comm\n\n/-- Non-dependent eliminator for `Iff`. -/\ndef Iff.elim (f : (a \u2192 b) \u2192 (b \u2192 a) \u2192 \u03b1) (h : a \u2194 b) : \u03b1 := f h.1 h.2\n\ntheorem Eq.to_iff : a = b \u2192 (a \u2194 b) | rfl => Iff.rfl\n\ntheorem iff_of_eq : a = b \u2192 (a \u2194 b) := Eq.to_iff\n\ntheorem neq_of_not_iff : \u00ac(a \u2194 b) \u2192 a \u2260 b := mt Eq.to_iff\n\ntheorem iff_iff_eq : (a \u2194 b) \u2194 a = b := \u27e8propext, iff_of_eq\u27e9\n\n@[simp] theorem eq_iff_iff {p q : Prop} : (p = q) \u2194 (p \u2194 q) := iff_iff_eq.symm\n\ntheorem of_iff_true (h : a \u2194 True) : a := h.2 \u27e8\u27e9\n\ntheorem not_of_iff_false : (a \u2194 False) \u2192 \u00aca := Iff.mp\n\ntheorem iff_of_true (ha : a) (hb : b) : a \u2194 b := \u27e8fun _ => hb, fun _ => ha\u27e9\n\ntheorem iff_of_false (ha : \u00aca) (hb : \u00acb) : a \u2194 b := \u27e8ha.elim, hb.elim\u27e9\n\ntheorem iff_true_left (ha : a) : (a \u2194 b) \u2194 b := \u27e8fun h => h.1 ha, iff_of_true ha\u27e9\n\ntheorem iff_true_right (ha : a) : (b \u2194 a) \u2194 b := Iff.comm.trans (iff_true_left ha)\n\ntheorem iff_false_left (ha : \u00aca) : (a \u2194 b) \u2194 \u00acb := \u27e8fun h => mt h.2 ha, iff_of_false ha\u27e9\n\ntheorem iff_false_right (ha : \u00aca) : (b \u2194 a) \u2194 \u00acb := Iff.comm.trans (iff_false_left ha)\n\ntheorem iff_true_intro (h : a) : a \u2194 True := iff_of_true h \u27e8\u27e9\n\ntheorem iff_false_intro (h : \u00aca) : a \u2194 False := iff_of_false h id\n\ntheorem not_iff_false_intro (h : a) : \u00aca \u2194 False := iff_false_intro (not_not_intro h)\n\ntheorem iff_congr (h\u2081 : a \u2194 c) (h\u2082 : b \u2194 d) : (a \u2194 b) \u2194 (c \u2194 d) :=\n  \u27e8fun h => h\u2081.symm.trans <| h.trans h\u2082, fun h => h\u2081.trans <| h.trans h\u2082.symm\u27e9\n\n@[simp] theorem not_true : (\u00acTrue) \u2194 False := iff_false_intro (not_not_intro \u27e8\u27e9)\n\n@[simp] theorem not_false_iff : (\u00acFalse) \u2194 True := iff_true_intro not_false\n\ntheorem ne_self_iff_false (a : \u03b1) : a \u2260 a \u2194 False := not_iff_false_intro rfl\n\ntheorem eq_self_iff_true (a : \u03b1) : a = a \u2194 True := iff_true_intro rfl\n\ntheorem heq_self_iff_true (a : \u03b1) : HEq a a \u2194 True := iff_true_intro HEq.rfl\n\ntheorem iff_not_self : \u00ac(a \u2194 \u00aca) | H => let f h := H.1 h h; f (H.2 f)\n\n@[simp] theorem not_iff_self : \u00ac(\u00aca \u2194 a) | H => iff_not_self H.symm\n\ntheorem true_iff_false : (True \u2194 False) \u2194 False := iff_false_intro (fun h => h.1 \u27e8\u27e9)\n\ntheorem false_iff_true : (False \u2194 True) \u2194 False := iff_false_intro (fun h => h.2 \u27e8\u27e9)\n\ntheorem false_of_true_iff_false : (True \u2194 False) \u2192 False := fun h => h.1 \u27e8\u27e9\n\ntheorem false_of_true_eq_false : (True = False) \u2192 False := fun h => h \u25b8 trivial\n\ntheorem true_eq_false_of_false : False \u2192 (True = False) := False.elim\n\ntheorem eq_comm {a b : \u03b1} : a = b \u2194 b = a := \u27e8Eq.symm, Eq.symm\u27e9\n\n/-! ## implies -/\n\n@[nolint unusedArguments]\ntheorem imp_intro {\u03b1 \u03b2 : Prop} (h : \u03b1) : \u03b2 \u2192 \u03b1 := fun _ => h\n\ntheorem imp_imp_imp {a b c d : Prop} (h\u2080 : c \u2192 a) (h\u2081 : b \u2192 d) : (a \u2192 b) \u2192 (c \u2192 d) := (h\u2081 \u2218 \u00b7 \u2218 h\u2080)\n\ntheorem imp_iff_right {a : Prop} (ha : a) : (a \u2192 b) \u2194 b := \u27e8fun f => f ha, imp_intro\u27e9\n\n-- This is not marked `@[simp]` because we have `implies_true : (\u03b1 \u2192 True) = True` in core.\ntheorem imp_true_iff (\u03b1 : Sort u) : (\u03b1 \u2192 True) \u2194 True := iff_true_intro fun _ => trivial\n\ntheorem false_imp_iff (a : Prop) : (False \u2192 a) \u2194 True := iff_true_intro False.elim\n\ntheorem true_imp_iff (\u03b1 : Prop) : (True \u2192 \u03b1) \u2194 \u03b1 := \u27e8fun h => h trivial, fun h _ => h\u27e9\n\n@[simp] theorem imp_self : (a \u2192 a) \u2194 True := iff_true_intro id\n\ntheorem imp_false : (a \u2192 False) \u2194 \u00aca := Iff.rfl\n\ntheorem imp.swap : (a \u2192 b \u2192 c) \u2194 (b \u2192 a \u2192 c) := \u27e8flip, flip\u27e9\n\ntheorem imp_not_comm : (a \u2192 \u00acb) \u2194 (b \u2192 \u00aca) := imp.swap\n\ntheorem imp_congr_left (h : a \u2194 b) : (a \u2192 c) \u2194 (b \u2192 c) :=\n  \u27e8fun hac ha => hac (h.2 ha), fun hbc ha => hbc (h.1 ha)\u27e9\n\ntheorem imp_congr_right (h : a \u2192 (b \u2194 c)) : (a \u2192 b) \u2194 (a \u2192 c) :=\n  \u27e8fun hab ha => (h ha).1 (hab ha), fun hcd ha => (h ha).2 (hcd ha)\u27e9\n\ntheorem imp_congr_ctx (h\u2081 : a \u2194 c) (h\u2082 : c \u2192 (b \u2194 d)) : (a \u2192 b) \u2194 (c \u2192 d) :=\n  (imp_congr_left h\u2081).trans (imp_congr_right h\u2082)\n\ntheorem imp_congr (h\u2081 : a \u2194 c) (h\u2082 : b \u2194 d) : (a \u2192 b) \u2194 (c \u2192 d) := imp_congr_ctx h\u2081 fun _ => h\u2082\n\ntheorem imp_iff_not (hb : \u00acb) : a \u2192 b \u2194 \u00aca := imp_congr_right fun _ => iff_false_intro hb\n\n/-! ## and -/\n\n/-- Non-dependent eliminator for `And`. -/\nabbrev And.elim (f : a \u2192 b \u2192 \u03b1) (h : a \u2227 b) : \u03b1 := f h.1 h.2\n\ntheorem And.symm : a \u2227 b \u2192 b \u2227 a | \u27e8ha, hb\u27e9 => \u27e8hb, ha\u27e9\n\ntheorem And.imp (f : a \u2192 c) (g : b \u2192 d) (h : a \u2227 b) : c \u2227 d := \u27e8f h.1, g h.2\u27e9\n\ntheorem And.imp_left (h : a \u2192 b) : a \u2227 c \u2192 b \u2227 c := .imp h id\n\ntheorem And.imp_right (h : a \u2192 b) : c \u2227 a \u2192 c \u2227 b := .imp id h\n\ntheorem and_congr (h\u2081 : a \u2194 c) (h\u2082 : b \u2194 d) : a \u2227 b \u2194 c \u2227 d :=\n  \u27e8And.imp h\u2081.1 h\u2082.1, And.imp h\u2081.2 h\u2082.2\u27e9\n\ntheorem and_comm : a \u2227 b \u2194 b \u2227 a := And.comm\n\ntheorem and_congr_right (h : a \u2192 (b \u2194 c)) : a \u2227 b \u2194 a \u2227 c :=\n\u27e8fun \u27e8ha, hb\u27e9 => \u27e8ha, (h ha).1 hb\u27e9, fun \u27e8ha, hb\u27e9 => \u27e8ha, (h ha).2 hb\u27e9\u27e9\n\ntheorem and_congr_left (h : c \u2192 (a \u2194 b)) : a \u2227 c \u2194 b \u2227 c :=\n  and_comm.trans <| (and_congr_right h).trans and_comm\n\ntheorem and_congr_left' (h : a \u2194 b) : a \u2227 c \u2194 b \u2227 c := and_congr h .rfl\n\ntheorem and_congr_right' (h : b \u2194 c) : a \u2227 b \u2194 a \u2227 c := and_congr .rfl h\n\ntheorem and_congr_right_eq (h : a \u2192 b = c) : (a \u2227 b) = (a \u2227 c) :=\n  propext <| and_congr_right fun hc => h hc \u25b8 .rfl\n\ntheorem and_congr_left_eq (h : c \u2192 a = b) : (a \u2227 c) = (b \u2227 c) :=\n  propext <| and_congr_left fun hc => h hc \u25b8 .rfl\n\ntheorem and_assoc : (a \u2227 b) \u2227 c \u2194 a \u2227 (b \u2227 c) :=\n  \u27e8fun \u27e8\u27e8ha, hb\u27e9, hc\u27e9 => \u27e8ha, hb, hc\u27e9, fun \u27e8ha, hb, hc\u27e9 => \u27e8\u27e8ha, hb\u27e9, hc\u27e9\u27e9\n\ntheorem and_left_comm : a \u2227 (b \u2227 c) \u2194 b \u2227 (a \u2227 c) := by\n  rw [\u2190 and_assoc, \u2190 and_assoc, @and_comm a b]\n\ntheorem and_right_comm : (a \u2227 b) \u2227 c \u2194 (a \u2227 c) \u2227 b := by\n  simp only [and_left_comm, and_comm]\n\ntheorem and_rotate : a \u2227 b \u2227 c \u2194 b \u2227 c \u2227 a := by\n  simp only [and_left_comm, and_comm]\n\ntheorem and_and_and_comm : (a \u2227 b) \u2227 c \u2227 d \u2194 (a \u2227 c) \u2227 b \u2227 d := by\n  rw [\u2190 and_assoc, @and_right_comm a, and_assoc]\n\ntheorem and_and_left : a \u2227 b \u2227 c \u2194 (a \u2227 b) \u2227 a \u2227 c := by\n  rw [and_and_and_comm, and_self]\n\ntheorem and_and_right : (a \u2227 b) \u2227 c \u2194 (a \u2227 c) \u2227 b \u2227 c := by\n  rw [and_and_and_comm, and_self]\n\ntheorem and_iff_left_of_imp (h : a \u2192 b) : (a \u2227 b) \u2194 a :=\n  \u27e8And.left, fun ha => \u27e8ha, h ha\u27e9\u27e9\n\ntheorem and_iff_right_of_imp (h : b \u2192 a) : (a \u2227 b) \u2194 b :=\n  \u27e8And.right, fun hb => \u27e8h hb, hb\u27e9\u27e9\n\ntheorem and_iff_left (hb : b) : a \u2227 b \u2194 a := and_iff_left_of_imp fun _ => hb\n\ntheorem and_iff_right (ha : a) : a \u2227 b \u2194 b := and_iff_right_of_imp fun _ => ha\n\n@[simp] theorem and_iff_left_iff_imp : ((a \u2227 b) \u2194 a) \u2194 (a \u2192 b) :=\n  \u27e8fun h ha => (h.2 ha).2, and_iff_left_of_imp\u27e9\n\n@[simp] theorem and_iff_right_iff_imp : ((a \u2227 b) \u2194 b) \u2194 (b \u2192 a) :=\n  \u27e8fun h ha => (h.2 ha).1, and_iff_right_of_imp\u27e9\n\n@[simp] theorem iff_self_and : (p \u2194 p \u2227 q) \u2194 (p \u2192 q) := by\n  rw [@Iff.comm p, and_iff_left_iff_imp]\n\n@[simp] theorem iff_and_self : (p \u2194 q \u2227 p) \u2194 (p \u2192 q) := by rw [and_comm, iff_self_and]\n\n@[simp] theorem and_congr_right_iff : (a \u2227 b \u2194 a \u2227 c) \u2194 (a \u2192 (b \u2194 c)) :=\n  \u27e8fun h ha => by simp [ha] at h; exact h, and_congr_right\u27e9\n\n@[simp] theorem and_congr_left_iff : (a \u2227 c \u2194 b \u2227 c) \u2194 c \u2192 (a \u2194 b) := by\n  simp only [and_comm, \u2190 and_congr_right_iff]\n\n@[simp] theorem and_self_left : a \u2227 a \u2227 b \u2194 a \u2227 b :=\n  \u27e8fun h => \u27e8h.1, h.2.2\u27e9, fun h => \u27e8h.1, h.1, h.2\u27e9\u27e9\n\n@[simp] theorem and_self_right : (a \u2227 b) \u2227 b \u2194 a \u2227 b :=\n  \u27e8fun h => \u27e8h.1.1, h.2\u27e9, fun h => \u27e8\u27e8h.1, h.2\u27e9, h.2\u27e9\u27e9\n\ntheorem not_and_of_not_left (b : Prop) : \u00aca \u2192 \u00ac(a \u2227 b) := mt And.left\n\ntheorem not_and_of_not_right (a : Prop) {b : Prop} : \u00acb \u2192 \u00ac(a \u2227 b) := mt And.right\n\n@[simp] theorem and_not_self : \u00ac(a \u2227 \u00aca) | \u27e8ha, hn\u27e9 => hn ha\n\n@[simp] theorem not_and_self : \u00ac(\u00aca \u2227 a) | \u27e8hn, ha\u27e9 => hn ha\n\ntheorem and_not_self_iff (a : Prop) : a \u2227 \u00aca \u2194 False := iff_false_intro and_not_self\n\ntheorem not_and_self_iff (a : Prop) : \u00aca \u2227 a \u2194 False := iff_false_intro not_and_self\n\n/-! ## or -/\n\ntheorem not_not_em (a : Prop) : \u00ac\u00ac(a \u2228 \u00aca) := fun h => h (.inr (h \u2218 .inl))\n\ntheorem Or.symm : a \u2228 b \u2192 b \u2228 a := .rec .inr .inl\n\ntheorem Or.imp (f : a \u2192 c) (g : b \u2192 d) (h : a \u2228 b) : c \u2228 d := h.elim (inl \u2218 f) (inr \u2218 g)\n\ntheorem Or.imp_left (f : a \u2192 b) : a \u2228 c \u2192 b \u2228 c := .imp f id\n\ntheorem Or.imp_right (f : b \u2192 c) : a \u2228 b \u2192 a \u2228 c := .imp id f\n\ntheorem or_congr (h\u2081 : a \u2194 c) (h\u2082 : b \u2194 d) : (a \u2228 b) \u2194 (c \u2228 d) := \u27e8.imp h\u2081.1 h\u2082.1, .imp h\u2081.2 h\u2082.2\u27e9\n\ntheorem or_congr_left (h : a \u2194 b) : a \u2228 c \u2194 b \u2228 c := or_congr h .rfl\n\ntheorem or_congr_right (h : b \u2194 c) : a \u2228 b \u2194 a \u2228 c := or_congr .rfl h\n\ntheorem Or.comm : a \u2228 b \u2194 b \u2228 a := \u27e8Or.symm, Or.symm\u27e9\n\ntheorem or_comm : a \u2228 b \u2194 b \u2228 a := Or.comm\n\ntheorem or_assoc : (a \u2228 b) \u2228 c \u2194 a \u2228 (b \u2228 c) :=\n  \u27e8.rec (.imp_right .inl) (.inr \u2218 .inr), .rec (.inl \u2218 .inl) (.imp_left .inr)\u27e9\n\ntheorem Or.resolve_left {a b : Prop} (h: a \u2228 b) (na : \u00aca) : b := h.elim (absurd \u00b7 na) id\n\ntheorem Or.neg_resolve_left (h : \u00aca \u2228 b) (ha : a) : b := h.elim (absurd ha) id\n\ntheorem Or.resolve_right {a b : Prop} (h: a \u2228 b) (nb : \u00acb) : a := h.elim id (absurd \u00b7 nb)\n\ntheorem Or.neg_resolve_right (h : a \u2228 \u00acb) (nb : b) : a := h.elim id (absurd nb)\n\ntheorem or_left_comm : a \u2228 (b \u2228 c) \u2194 b \u2228 (a \u2228 c) := by rw [\u2190 or_assoc, \u2190 or_assoc, @or_comm a b]\n\ntheorem or_right_comm : (a \u2228 b) \u2228 c \u2194 (a \u2228 c) \u2228 b := by rw [or_assoc, or_assoc, @or_comm b]\n\ntheorem or_or_or_comm : (a \u2228 b) \u2228 c \u2228 d \u2194 (a \u2228 c) \u2228 b \u2228 d := by\n  rw [\u2190 or_assoc, @or_right_comm a, or_assoc]\n\ntheorem or_or_distrib_left : a \u2228 b \u2228 c \u2194 (a \u2228 b) \u2228 a \u2228 c := by rw [or_or_or_comm, or_self]\n\ntheorem or_or_distrib_right : (a \u2228 b) \u2228 c \u2194 (a \u2228 c) \u2228 b \u2228 c := by rw [or_or_or_comm, or_self]\n\ntheorem or_rotate : a \u2228 b \u2228 c \u2194 b \u2228 c \u2228 a := by simp only [or_left_comm, Or.comm]\n\ntheorem or_iff_right_of_imp (ha : a \u2192 b) : (a \u2228 b) \u2194 b := \u27e8Or.rec ha id, .inr\u27e9\n\ntheorem or_iff_left_of_imp (hb : b \u2192 a) : (a \u2228 b) \u2194 a := \u27e8Or.rec id hb, .inl\u27e9\n\ntheorem not_or_intro {a b : Prop} (ha : \u00aca) (hb : \u00acb) : \u00ac(a \u2228 b) := (\u00b7.elim ha hb)\n\n@[simp] theorem or_iff_left_iff_imp : (a \u2228 b \u2194 a) \u2194 (b \u2192 a) :=\n  \u27e8fun h hb => h.1 (Or.inr hb), or_iff_left_of_imp\u27e9\n\n@[simp] theorem or_iff_right_iff_imp : (a \u2228 b \u2194 b) \u2194 (a \u2192 b) := by\n  rw [or_comm, or_iff_left_iff_imp]\n\ntheorem or_iff_left (hb : \u00acb) : a \u2228 b \u2194 a := or_iff_left_iff_imp.2 hb.elim\n\ntheorem or_iff_right (ha : \u00aca) : a \u2228 b \u2194 b := or_iff_right_iff_imp.2 ha.elim\n\n/-! ## distributivity -/\n\ntheorem not_imp_of_and_not : a \u2227 \u00acb \u2192 \u00ac(a \u2192 b)\n  | \u27e8ha, hb\u27e9, h => hb <| h ha\n\ntheorem imp_and {\u03b1} : (\u03b1 \u2192 b \u2227 c) \u2194 (\u03b1 \u2192 b) \u2227 (\u03b1 \u2192 c) :=\n  \u27e8fun h => \u27e8fun ha => (h ha).1, fun ha => (h ha).2\u27e9, fun h ha => \u27e8h.1 ha, h.2 ha\u27e9\u27e9\n\n@[simp] theorem and_imp : (a \u2227 b \u2192 c) \u2194 (a \u2192 b \u2192 c) :=\n  \u27e8fun h ha hb => h \u27e8ha, hb\u27e9, fun h \u27e8ha, hb\u27e9 => h ha hb\u27e9\n\n@[simp] theorem not_and : \u00ac(a \u2227 b) \u2194 (a \u2192 \u00acb) := and_imp\n\ntheorem not_and' : \u00ac(a \u2227 b) \u2194 b \u2192 \u00aca := not_and.trans imp_not_comm\n\n/-- `\u2227` distributes over `\u2228` (on the left). -/\ntheorem and_or_left : a \u2227 (b \u2228 c) \u2194 (a \u2227 b) \u2228 (a \u2227 c) :=\n  \u27e8fun \u27e8ha, hbc\u27e9 => hbc.imp (.intro ha) (.intro ha), Or.rec (.imp_right .inl) (.imp_right .inr)\u27e9\n\n/-- `\u2227` distributes over `\u2228` (on the right). -/\ntheorem or_and_right : (a \u2228 b) \u2227 c \u2194 (a \u2227 c) \u2228 (b \u2227 c) := by\n  simp [and_comm, and_or_left]\n\n/-- `\u2228` distributes over `\u2227` (on the left). -/\ntheorem or_and_left : a \u2228 (b \u2227 c) \u2194 (a \u2228 b) \u2227 (a \u2228 c) :=\n  \u27e8Or.rec (fun ha => \u27e8.inl ha, .inl ha\u27e9) (.imp .inr .inr),\n   And.rec <| .rec (fun _ => .inl \u00b7) (.imp_right \u2218 .intro)\u27e9\n\n/-- `\u2228` distributes over `\u2227` (on the right). -/\ntheorem and_or_right : (a \u2227 b) \u2228 c \u2194 (a \u2228 c) \u2227 (b \u2228 c) := by\n  simp [or_comm, or_and_left]\n\ntheorem or_imp : (a \u2228 b \u2192 c) \u2194 (a \u2192 c) \u2227 (b \u2192 c) :=\n  \u27e8fun h => \u27e8h \u2218 .inl, h \u2218 .inr\u27e9, fun \u27e8ha, hb\u27e9 => Or.rec ha hb\u27e9\n\ntheorem not_or : \u00ac(p \u2228 q) \u2194 \u00acp \u2227 \u00acq := or_imp\n\ntheorem not_and_of_not_or_not (h : \u00aca \u2228 \u00acb) : \u00ac(a \u2227 b) := h.elim (mt (\u00b7.1)) (mt (\u00b7.2))\n\n@[simp] theorem or_self_left : a \u2228 a \u2228 b \u2194 a \u2228 b := \u27e8.rec .inl id, .rec .inl (.inr \u2218 .inr)\u27e9\n\n@[simp] theorem or_self_right : (a \u2228 b) \u2228 b \u2194 a \u2228 b := \u27e8.rec id .inr, .rec (.inl \u2218 .inl) .inr\u27e9\n\n/-! ## exists and forall -/\n\nsection quantifiers\nvariable {p q : \u03b1 \u2192 Prop} {b : Prop}\n\ntheorem forall_imp (h : \u2200 a, p a \u2192 q a) : (\u2200 a, p a) \u2192 \u2200 a, q a :=\nfun h' a => h a (h' a)\n\n@[simp] theorem forall_exists_index {q : (\u2203 x, p x) \u2192 Prop} :\n    (\u2200 h, q h) \u2194 \u2200 x (h : p x), q \u27e8x, h\u27e9 :=\n  \u27e8fun h x hpx => h \u27e8x, hpx\u27e9, fun h \u27e8x, hpx\u27e9 => h x hpx\u27e9\n\ntheorem Exists.imp (h : \u2200 a, p a \u2192 q a) : (\u2203 a, p a) \u2192 \u2203 a, q a\n  | \u27e8a, hp\u27e9 => \u27e8a, h a hp\u27e9\n\ntheorem Exists.imp' {\u03b2} {q : \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2) (hpq : \u2200 a, p a \u2192 q (f a)) :\n    (\u2203 a, p a) \u2192 \u2203 b, q b\n  | \u27e8_, hp\u27e9 => \u27e8_, hpq _ hp\u27e9\n\ntheorem exists_imp : ((\u2203 x, p x) \u2192 b) \u2194 \u2200 x, p x \u2192 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 : \u2200 a, p a \u2194 q a) : (\u2200 a, p a) \u2194 \u2200 a, q a :=\n  \u27e8fun H a => (h a).1 (H a), fun H a => (h a).2 (H a)\u27e9\n\ntheorem exists_congr (h : \u2200 a, p a \u2194 q a) : (\u2203 a, p a) \u2194 \u2203 a, q a :=\n  \u27e8Exists.imp fun x => (h x).1, Exists.imp fun x => (h x).2\u27e9\n\nvariable {\u03b2 : \u03b1 \u2192 Sort _}\ntheorem forall\u2082_congr {p q : \u2200 a, \u03b2 a \u2192 Prop} (h : \u2200 a b, p a b \u2194 q a b) :\n    (\u2200 a b, p a b) \u2194 \u2200 a b, q a b :=\n  forall_congr' fun a => forall_congr' <| h a\n\ntheorem exists\u2082_congr {p q : \u2200 a, \u03b2 a \u2192 Prop} (h : \u2200 a b, p a b \u2194 q a b) :\n    (\u2203 a b, p a b) \u2194 \u2203 a b, q a b :=\n  exists_congr fun a => exists_congr <| h a\n\nvariable {\u03b3 : \u2200 a, \u03b2 a \u2192 Sort _}\ntheorem forall\u2083_congr {p q : \u2200 a b, \u03b3 a b \u2192 Prop} (h : \u2200 a b c, p a b c \u2194 q a b c) :\n    (\u2200 a b c, p a b c) \u2194 \u2200 a b c, q a b c :=\n  forall_congr' fun a => forall\u2082_congr <| h a\n\ntheorem exists\u2083_congr {p q : \u2200 a b, \u03b3 a b \u2192 Prop} (h : \u2200 a b c, p a b c \u2194 q a b c) :\n    (\u2203 a b c, p a b c) \u2194 \u2203 a b c, q a b c :=\n  exists_congr fun a => exists\u2082_congr <| h a\n\nvariable {\u03b4 : \u2200 a b, \u03b3 a b \u2192 Sort _}\ntheorem forall\u2084_congr {p q : \u2200 a b c, \u03b4 a b c \u2192 Prop} (h : \u2200 a b c d, p a b c d \u2194 q a b c d) :\n    (\u2200 a b c d, p a b c d) \u2194 \u2200 a b c d, q a b c d :=\n  forall_congr' fun a => forall\u2083_congr <| h a\n\ntheorem exists\u2084_congr {p q : \u2200 a b c, \u03b4 a b c \u2192 Prop} (h : \u2200 a b c d, p a b c d \u2194 q a b c d) :\n    (\u2203 a b c d, p a b c d) \u2194 \u2203 a b c d, q a b c d :=\n  exists_congr fun a => exists\u2083_congr <| h a\n\nvariable {\u03b5 : \u2200 a b c, \u03b4 a b c \u2192 Sort _}\ntheorem forall\u2085_congr {p q : \u2200 a b c d, \u03b5 a b c d \u2192 Prop}\n    (h : \u2200 a b c d e, p a b c d e \u2194 q a b c d e) :\n    (\u2200 a b c d e, p a b c d e) \u2194 \u2200 a b c d e, q a b c d e :=\n  forall_congr' fun a => forall\u2084_congr <| h a\n\ntheorem exists\u2085_congr {p q : \u2200 a b c d, \u03b5 a b c d \u2192 Prop}\n    (h : \u2200 a b c d e, p a b c d e \u2194 q a b c d e) :\n    (\u2203 a b c d e, p a b c d e) \u2194 \u2203 a b c d e, q a b c d e :=\n  exists_congr fun a => exists\u2084_congr <| h a\n\nend forall_congr\n\n@[simp] theorem not_exists : (\u00ac\u2203 x, p x) \u2194 \u2200 x, \u00acp x := exists_imp\n\ntheorem forall_not_of_not_exists (hne : \u00ac\u2203 x, p x) (x) : \u00acp x | hp => hne \u27e8x, hp\u27e9\n\ntheorem forall_and : (\u2200 x, p x \u2227 q x) \u2194 (\u2200 x, p x) \u2227 (\u2200 x, q x) :=\n  \u27e8fun h => \u27e8fun x => (h x).1, fun x => (h x).2\u27e9, fun \u27e8h\u2081, h\u2082\u27e9 x => \u27e8h\u2081 x, h\u2082 x\u27e9\u27e9\n\ntheorem exists_or : (\u2203 x, p x \u2228 q x) \u2194 (\u2203 x, p x) \u2228 \u2203 x, q x :=\n  \u27e8fun | \u27e8x, .inl h\u27e9 => .inl \u27e8x, h\u27e9 | \u27e8x, .inr h\u27e9 => .inr \u27e8x, h\u27e9,\n   fun | .inl \u27e8x, h\u27e9 => \u27e8x, .inl h\u27e9 | .inr \u27e8x, h\u27e9 => \u27e8x, .inr h\u27e9\u27e9\n\n@[simp] theorem exists_false : \u00ac(\u2203 _a : \u03b1, False) := fun \u27e8_, h\u27e9 => h\n\n@[simp] theorem forall_const (\u03b1 : Sort _) [i : Nonempty \u03b1] : (\u03b1 \u2192 b) \u2194 b :=\n  \u27e8i.elim, fun hb _ => hb\u27e9\n\ntheorem Exists.nonempty : (\u2203 x, p x) \u2192 Nonempty \u03b1 | \u27e8x, _\u27e9 => \u27e8x\u27e9\n\n/-- Extract an element from a existential statement, using `Classical.choose`. -/\n-- This enables projection notation.\n@[reducible] noncomputable def Exists.choose (P : \u2203 a, p a) : \u03b1 := Classical.choose P\n\n/-- Show that an element extracted from `P : \u2203 a, p a` using `P.choose` satisfies `p`. -/\ntheorem Exists.choose_spec {p : \u03b1 \u2192 Prop} (P : \u2203 a, p a) : p P.choose := Classical.choose_spec P\n\ntheorem not_forall_of_exists_not {p : \u03b1 \u2192 Prop} : (\u2203 x, \u00acp x) \u2192 \u00ac\u2200 x, p x\n  | \u27e8x, hn\u27e9, h => hn (h x)\n\n@[simp] theorem forall_eq {p : \u03b1 \u2192 Prop} {a' : \u03b1} : (\u2200 a, a = a' \u2192 p a) \u2194 p a' :=\n  \u27e8fun h => h a' rfl, fun h _ e => e.symm \u25b8 h\u27e9\n\n@[simp] theorem forall_eq' {a' : \u03b1} : (\u2200 a, a' = a \u2192 p a) \u2194 p a' := by simp [@eq_comm _ a']\n\n@[simp] theorem exists_eq : \u2203 a, a = a' := \u27e8_, rfl\u27e9\n\n@[simp] theorem exists_eq' : \u2203 a, a' = a := \u27e8_, rfl\u27e9\n\n@[simp] theorem exists_eq_left : (\u2203 a, a = a' \u2227 p a) \u2194 p a' :=\n  \u27e8fun \u27e8_, e, h\u27e9 => e \u25b8 h, fun h => \u27e8_, rfl, h\u27e9\u27e9\n\n@[simp] theorem exists_eq_right : (\u2203 a, p a \u2227 a = a') \u2194 p a' :=\n  (exists_congr <| by exact fun a => And.comm).trans exists_eq_left\n\n@[simp] theorem exists_and_left : (\u2203 x, b \u2227 p x) \u2194 b \u2227 (\u2203 x, p x) :=\n  \u27e8fun \u27e8x, h, hp\u27e9 => \u27e8h, x, hp\u27e9, fun \u27e8h, x, hp\u27e9 => \u27e8x, h, hp\u27e9\u27e9\n\n@[simp] theorem exists_and_right : (\u2203 x, p x \u2227 b) \u2194 (\u2203 x, p x) \u2227 b := by simp [And.comm]\n\n@[simp] theorem exists_eq_left' : (\u2203 a, a' = a \u2227 p a) \u2194 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 : (\u2200 a, a = a' \u2228 q a \u2192 p a) \u2194 p a' \u2227 \u2200 a, q a \u2192 p a := by\n  simp only [or_imp, forall_and, forall_eq]\n\n@[simp] theorem exists_eq_or_imp : (\u2203 a, (a = a' \u2228 q a) \u2227 p a) \u2194 p a' \u2228 \u2203 a, q a \u2227 p a := by\n  simp only [or_and_right, exists_or, exists_eq_left]\n\n@[simp] theorem exists_eq_right_right : (\u2203 (a : \u03b1), p a \u2227 b \u2227 a = a') \u2194 p a' \u2227 b := by\n  simp [\u2190 and_assoc]\n\n@[simp] theorem exists_eq_right_right' : (\u2203 (a : \u03b1), p a \u2227 b \u2227 a' = a) \u2194 p a' \u2227 b := by\n  (conv in _=_ => rw [eq_comm]); simp\n\n@[simp] theorem exists_prop : (\u2203 _h : a, b) \u2194 a \u2227 b :=\n  \u27e8fun \u27e8hp, hq\u27e9 => \u27e8hp, hq\u27e9, fun \u27e8hp, hq\u27e9 => \u27e8hp, hq\u27e9\u27e9\n\n@[simp] theorem exists_apply_eq_apply (f : \u03b1 \u2192 \u03b2) (a' : \u03b1) : \u2203 a, f a = f a' := \u27e8a', rfl\u27e9\n\ntheorem forall_prop_of_true {p : Prop} {q : p \u2192 Prop} (h : p) : (\u2200 h' : p, q h') \u2194 q h :=\n  @forall_const (q h) p \u27e8h\u27e9\n\nend quantifiers\n\n/-! ## decidable -/\n\ntheorem Decidable.not_not [Decidable p] : \u00ac\u00acp \u2194 p := \u27e8of_not_not, not_not_intro\u27e9\n\n/-- Construct a non-Prop by cases on an `Or`, when the left conjunct is decidable. -/\nprotected def Or.by_cases [Decidable p] {\u03b1 : Sort u} (h : p \u2228 q) (h\u2081 : p \u2192 \u03b1) (h\u2082 : q \u2192 \u03b1) : \u03b1 :=\n  if hp : p then h\u2081 hp else h\u2082 (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] {\u03b1 : Sort u} (h : p \u2228 q) (h\u2081 : p \u2192 \u03b1) (h\u2082 : q \u2192 \u03b1) : \u03b1 :=\n  if hq : q then h\u2082 hq else h\u2081 (h.resolve_right hq)\n\ninstance exists_prop_decidable {p} (P : p \u2192 Prop)\n  [Decidable p] [\u2200 h, Decidable (P h)] : Decidable (\u2203 h, P h) :=\nif h : p then\n  decidable_of_decidable_of_iff \u27e8fun h2 => \u27e8h, h2\u27e9, fun \u27e8_, h2\u27e9 => h2\u27e9\nelse isFalse fun \u27e8h', _\u27e9 => h h'\n\ninstance forall_prop_decidable {p} (P : p \u2192 Prop)\n  [Decidable p] [\u2200 h, Decidable (P h)] : Decidable (\u2200 h, P h) :=\nif h : p then\n  decidable_of_decidable_of_iff \u27e8fun h2 _ => h2, fun al => al h\u27e9\nelse isTrue fun h2 => absurd h2 h\n\ntheorem decide_eq_true_iff (p : Prop) [Decidable p] : (decide p = true) \u2194 p := by simp\n\n@[simp] theorem decide_eq_false_iff_not (p : Prop) [Decidable p] : (decide p = false) \u2194 \u00acp :=\n  \u27e8of_decide_eq_false, decide_eq_false\u27e9\n\n@[simp] theorem decide_eq_decide {p q : Prop} [Decidable p] [Decidable q] :\n    decide p = decide q \u2194 (p \u2194 q) :=\n  \u27e8fun h => by rw [\u2190 decide_eq_true_iff p, h, decide_eq_true_iff], fun h => by simp [h]\u27e9\n\ntheorem Decidable.of_not_imp [Decidable a] (h : \u00ac(a \u2192 b)) : a :=\n  byContradiction (not_not_of_not_imp h)\n\ntheorem Decidable.not_imp_symm [Decidable a] (h : \u00aca \u2192 b) (hb : \u00acb) : a :=\n  byContradiction <| hb \u2218 h\n\ntheorem Decidable.not_imp_comm [Decidable a] [Decidable b] : (\u00aca \u2192 b) \u2194 (\u00acb \u2192 a) :=\n  \u27e8not_imp_symm, not_imp_symm\u27e9\n\ntheorem Decidable.not_imp_self [Decidable a] : (\u00aca \u2192 a) \u2194 a := by\n  have := @imp_not_self (\u00aca); rwa [not_not] at this\n\ntheorem Decidable.or_iff_not_imp_left [Decidable a] : a \u2228 b \u2194 (\u00aca \u2192 b) :=\n  \u27e8Or.resolve_left, fun h => dite _ .inl (.inr \u2218 h)\u27e9\n\ntheorem Decidable.or_iff_not_imp_right [Decidable b] : a \u2228 b \u2194 (\u00acb \u2192 a) :=\nor_comm.trans or_iff_not_imp_left\n\ntheorem Decidable.not_imp_not [Decidable a] : (\u00aca \u2192 \u00acb) \u2194 (b \u2192 a) :=\n\u27e8fun h hb => byContradiction (h \u00b7 hb), mt\u27e9\n\ntheorem Decidable.not_or_of_imp [Decidable a] (h : a \u2192 b) : \u00aca \u2228 b :=\n  if ha : a then .inr (h ha) else .inl ha\n\ntheorem Decidable.imp_iff_not_or [Decidable a] : (a \u2192 b) \u2194 (\u00aca \u2228 b) :=\n  \u27e8not_or_of_imp, Or.neg_resolve_left\u27e9\n\ntheorem Decidable.imp_iff_or_not [Decidable b] : b \u2192 a \u2194 a \u2228 \u00acb :=\n  Decidable.imp_iff_not_or.trans or_comm\n\ntheorem Decidable.imp_or [Decidable a] : (a \u2192 b \u2228 c) \u2194 (a \u2192 b) \u2228 (a \u2192 c) := by\n  by_cases a <;> simp_all\n\ntheorem Decidable.imp_or' [Decidable b] : (a \u2192 b \u2228 c) \u2194 (a \u2192 b) \u2228 (a \u2192 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] : \u00ac(a \u2192 b) \u2194 a \u2227 \u00acb :=\n  \u27e8fun h => \u27e8of_not_imp h, not_of_not_imp h\u27e9, not_imp_of_and_not\u27e9\n\ntheorem Decidable.peirce (a b : Prop) [Decidable a] : ((a \u2192 b) \u2192 a) \u2192 a :=\n  if ha : a then fun _ => ha else fun h => h ha.elim\n\ntheorem peirce' {a : Prop} (H : \u2200 b : Prop, (a \u2192 b) \u2192 a) : a := H _ id\n\ntheorem Decidable.not_iff_not [Decidable a] [Decidable b] : (\u00aca \u2194 \u00acb) \u2194 (a \u2194 b) := by\n  rw [@iff_def (\u00aca), @iff_def' a]; exact and_congr not_imp_not not_imp_not\n\ntheorem Decidable.not_iff_comm [Decidable a] [Decidable b] : (\u00aca \u2194 b) \u2194 (\u00acb \u2194 a) := by\n  rw [@iff_def (\u00aca), @iff_def (\u00acb)]; exact and_congr not_imp_comm imp_not_comm\n\ntheorem Decidable.not_iff [Decidable b] : \u00ac(a \u2194 b) \u2194 (\u00aca \u2194 b) := by\n  by_cases h : b <;> simp [h, iff_true, iff_false]\n\ntheorem Decidable.iff_not_comm [Decidable a] [Decidable b] : (a \u2194 \u00acb) \u2194 (b \u2194 \u00aca) := 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 \u2194 b) \u2194 (a \u2227 b) \u2228 (\u00aca \u2227 \u00acb) :=\n  \u27e8fun e => if h : b then .inl \u27e8e.2 h, h\u27e9 else .inr \u27e8mt e.1 h, h\u27e9,\n   Or.rec (And.rec iff_of_true) (And.rec iff_of_false)\u27e9\n\ntheorem Decidable.iff_iff_not_or_and_or_not [Decidable a] [Decidable b] :\n    (a \u2194 b) \u2194 (\u00aca \u2228 b) \u2227 (a \u2228 \u00acb) := 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] : \u00ac(a \u2227 \u00acb) \u2194 (a \u2192 b) :=\n  \u27e8fun h ha => not_imp_symm (And.intro ha) h, fun h \u27e8ha, hb\u27e9 => hb <| h ha\u27e9\n\ntheorem Decidable.not_and [Decidable a] : \u00ac(a \u2227 b) \u2194 \u00aca \u2228 \u00acb :=\n  \u27e8fun h => if ha : a then .inr (h \u27e8ha, \u00b7\u27e9) else .inl ha, not_and_of_not_or_not\u27e9\n\ntheorem Decidable.not_and' [Decidable b] : \u00ac(a \u2227 b) \u2194 \u00aca \u2228 \u00acb :=\n  \u27e8fun h => if hb : b then .inl (h \u27e8\u00b7, hb\u27e9) else .inr hb, not_and_of_not_or_not\u27e9\n\ntheorem Decidable.or_iff_not_and_not [Decidable a] [Decidable b] : a \u2228 b \u2194 \u00ac(\u00aca \u2227 \u00acb) := by\n  rw [\u2190 not_or, not_not]\n\ntheorem Decidable.and_iff_not_or_not [Decidable a] [Decidable b] : a \u2227 b \u2194 \u00ac(\u00aca \u2228 \u00acb) := by\n  rw [\u2190 not_and, not_not]\n\ntheorem Decidable.imp_iff_right_iff [Decidable a] : (a \u2192 b \u2194 b) \u2194 a \u2228 b :=\n  \u27e8fun 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\u27e9\n\ntheorem Decidable.and_or_imp [Decidable a] : a \u2227 b \u2228 (a \u2192 c) \u2194 a \u2192 b \u2228 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 : \u00acc \u2192 (a \u2194 b)) : a \u2228 c \u2194 b \u2228 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 : \u00aca \u2192 (b \u2194 c)) : a \u2228 b \u2194 a \u2228 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 \u2194 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 \u2194 b) [Decidable b] : Decidable a :=\n  decidable_of_decidable_of_iff h.symm\n\ninstance Decidable.predToBool (p : \u03b1 \u2192 Prop) [DecidablePred p] :\n    CoeDep (\u03b1 \u2192 Prop) p (\u03b1 \u2192 Bool) := \u27e8fun b => decide <| p b\u27e9\n\ntheorem Bool.ff_ne_tt : false \u2260 true := fun.\n\n/-- Prove that `a` is decidable by constructing a boolean `b` and a proof that `b \u2194 a`.\n(This is sometimes taken as an alternate definition of decidability.) -/\ndef decidable_of_bool : \u2200 (b : Bool), (b \u2194 a) \u2192 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: `\u00ac\u00acP` 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 : \u00ac\u00aca \u2194 a := Decidable.not_not\n\nend Classical\n\n/-! ## equality -/\n\ntheorem heq_iff_eq : HEq a b \u2194 a = b := \u27e8eq_of_heq, heq_of_eq\u27e9\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 {\u03b1 : Sort _} {a a' : \u03b1} {\u03b2 : Sort _} (y : \u03b2) (h : a = a') :\n    (@Eq.rec \u03b1 a (fun \u03b1 _ => \u03b2) y a' h) = y := by cases h; rfl\n\ntheorem congrArg\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) {x x' : \u03b1} {y y' : \u03b2}\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 \u03b1 \u03b2] {s t : \u03b2} {a b : \u03b1}\n\ntheorem ne_of_mem_of_not_mem (h : a \u2208 s) : b \u2209 s \u2192 a \u2260 b := mt fun e => e \u25b8 h\n\ntheorem ne_of_mem_of_not_mem' (h : a \u2208 s) : a \u2209 t \u2192 s \u2260 t := mt fun e => e \u25b8 h\n\nend Mem\n\n/-! ## if-then-else -/\n\n@[simp] theorem if_true {h : Decidable True} (t e : \u03b1) : ite True t e = t := if_pos trivial\n\n@[simp] theorem if_false {h : Decidable False} (t e : \u03b1) : ite False t e = e := if_neg id\n\ntheorem ite_id [Decidable c] {\u03b1} (t : \u03b1) : (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 : \u03b1 \u2192 \u03b2) (P : Prop) [Decidable P] (x : P \u2192 \u03b1) (y : \u00acP \u2192 \u03b1) :\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 : \u03b1 \u2192 \u03b2) (P : Prop) [Decidable P] (x y : \u03b1) :\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 : \u00acP \u2192 \u03b1) (y : \u00ac\u00acP \u2192 \u03b1) :\n    dite (\u00acP) 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 : \u03b1) : ite (\u00acP) 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 \u2192 C := fun.\n\ninstance : Subsingleton Empty := \u27e8fun a => a.elim\u27e9\n\ninstance : DecidableEq Empty := fun a => a.elim\n\n/-- Ex falso, the nondependent eliminator for the `PEmpty` type. -/\ndef PEmpty.elim : PEmpty \u2192 C := fun.\n\ninstance : Subsingleton PEmpty := \u27e8fun a => a.elim\u27e9\n\ninstance : DecidableEq PEmpty := fun a => a.elim\n\n@[simp] theorem not_nonempty_empty : \u00acNonempty Empty := fun \u27e8h\u27e9 => h.elim\n\n@[simp] theorem not_nonempty_pempty : \u00acNonempty PEmpty := fun \u27e8h\u27e9 => h.elim\n\ninstance [Subsingleton \u03b1] [Subsingleton \u03b2] : Subsingleton (\u03b1 \u00d7 \u03b2) :=\n  \u27e8fun {..} {..} => by congr <;> apply Subsingleton.elim\u27e9\n\ninstance : Inhabited (Sort _) := \u27e8PUnit\u27e9\n\ninstance : Inhabited default := \u27e8PUnit.unit\u27e9\n\ninstance {\u03b1 \u03b2} [Inhabited \u03b1] : Inhabited (PSum \u03b1 \u03b2) := \u27e8PSum.inl default\u27e9\n\ninstance {\u03b1 \u03b2} [Inhabited \u03b2] : Inhabited (PSum \u03b1 \u03b2) := \u27e8PSum.inr default\u27e9\n\n-- TODO(Mario): profile first, this is a dangerous instance\n-- instance (priority := 10) {\u03b1} [Subsingleton \u03b1] : DecidableEq \u03b1\n--   | a, b => isTrue (Subsingleton.elim a b)\n\n-- @[simp] -- TODO(Mario): profile\ntheorem eq_iff_true_of_subsingleton [Subsingleton \u03b1] (x y : \u03b1) : x = y \u2194 True :=\n  iff_true_intro (Subsingleton.elim ..)\n\n/-- If all points are equal to a given point `x`, then `\u03b1` is a subsingleton. -/\ntheorem subsingleton_of_forall_eq (x : \u03b1) (h : \u2200 y, y = x) : Subsingleton \u03b1 :=\n  \u27e8fun a b => h a \u25b8 h b \u25b8 rfl\u27e9\n\ntheorem subsingleton_iff_forall_eq (x : \u03b1) : Subsingleton \u03b1 \u2194 \u2200 y, y = x :=\n  \u27e8fun _ y => Subsingleton.elim y x, subsingleton_of_forall_eq x\u27e9\n\nexample [Subsingleton \u03b1] (p : \u03b1 \u2192 Prop) : Subsingleton (Subtype p) :=\n  \u27e8fun \u27e8x, _\u27e9 \u27e8y, _\u27e9 => by congr; exact Subsingleton.elim x y\u27e9\n\ntheorem false_ne_true : False \u2260 True := fun h => h.symm \u25b8 trivial\n\ntheorem Bool.eq_false_or_eq_true : (b : Bool) \u2192 b = true \u2228 b = false\n  | true => .inl rfl\n  | false => .inr rfl\n\ntheorem Bool.eq_false_iff {b : Bool} : b = false \u2194 b \u2260 true :=\n  \u27e8ne_true_of_eq_false, eq_false_of_ne_true\u27e9\n\ntheorem ne_comm {\u03b1} {a b : \u03b1} : a \u2260 b \u2194 b \u2260 a := \u27e8Ne.symm, Ne.symm\u27e9\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": "/-\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 geometry.euclidean.basic\n\nnoncomputable theory\nopen_locale big_operators\nopen_locale classical\nopen_locale real_inner_product_space\n\n/-!\n# Lines in the plane and decompositions of graphs\n\n## TODO\n  - Theorem 1.\n    - proof\n      - Claim\n  - Theorem 2.\n    - proof\n  Theorem 3.\n    - proof\n  Theorem 4.\n    - proof\n  Appendix: Basic graph concepts\n-/\n\nvariables {V : Type*} {Pl : Type*} [inner_product_space \u211d V] [metric_space Pl]\n    [normed_add_torsor V Pl]\nlocal notation `\u27ea`x`, `y`\u27eb` := @inner \u211d V _ x y\ninclude V\n\ntheorem one (n : \u2115) (P : finset V) (h_card: P.card = n)\n-- a line is given by two points; there is no line that contains all points\n(h: \u00ac (\u2203 (v\u2080 v\u2081 : V), \u2200 (p : P), \u2203 r_p : \u211d, v\u2080 +\u1d65 r_p \u2022 v\u2081 = p )) :\n\u2203 (w\u2080 w\u2081 : V) , \u2203 (p\u2080 p\u2081 \u2208 P), p\u2080 \u2260 p\u2081 \u2227\n(\u2200 (p \u2208 P), \u2203 (r : \u211d), w\u2080 +\u1d65 r \u2022 w\u2081 = p \u2194 (p = p\u2080 \u2228 p = p\u2081)) :=\nbegin\n  sorry,\nend\n", "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/11_Lines_in_the_plane_and_decompositions_of_graphs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6442251133170357, "lm_q1q2_score": 0.48819016470541715}}
{"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 \u222a 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 \u2286 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\u03a0 (n : \u2115) (f : mv_polynomial (fin n) K) (as : fin n \u2192 L),\n(\u03a0 k, as k \u2208 S) \u2192 mv_polynomial.eval as (f : mv_polynomial (fin n) L) = 0 \u2192 f = 0\n\nlemma indep_subset (S T : set L) (hST : S \u2286 T) : indep K T \u2192 indep K S :=\nbegin\n  intros hT _ f as has hf,\n  have has' : \u03a0 k, as k \u2208 T := \u03bb k, hST (has k),\n  exact hT _ f as has' hf,\nend\n\n\nlemma indep_empty : indep K (\u2205 : 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 \u2190 mv_polynomial.C_0,\n  rw (mv_polynomial.C_inj L),\n  rw \u2190 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 \u2190 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 : \u03a0 (S : set L) (hS : S \u2208 c), indep K S) :\n  indep K \u22c3\u2080 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 \u2227 \u03a0 (S : set L), indep K S \u2192 B \u2286 S \u2192 S = B\n\nlemma extend_to_basis_aux (S : set L) (hindS : indep K S) :\n  \u2203 (B : set L) (H : B \u2208 {T : set L | S \u2286 T \u2227 indep K T}),\n  S \u2286 B \u2227 \u03a0 (T : set L), T \u2208 {T : set L | S \u2286 T \u2227 indep K T} \u2192 B \u2286 T \u2192 T = B :=\n(@zorn.zorn_subset_nonempty L { T : set L | S \u2286 T \u2227 indep K T }\n  (\u03bb c hcsub hchain hc0,\n    \u27e8\n      -- the upper bound by taking union\n      \u22c3\u2080 c ,\n      \u27e8\n        let hScup : S \u2286 \u22c3\u2080 c :=\n        begin\n          cases hc0 with T hT,\n          cases hcsub hT with hST hand,\n          have hTcup : T \u2286 \u22c3\u2080 c := \u03bb t ht , \u27e8 T , hT , ht \u27e9,\n          exact set.subset.trans hST hTcup,\n        end in\n        \u27e8 -- the upper bound is in the set\n          hScup ,\n          indep_sUnion_chain K hchain hc0 (\u03bb S hs, (hcsub hs).2)\n        \u27e9 ,\n        (\u03bb S hS s hs, \u27e8 S , hS , hs \u27e9) -- showing the maximal element is in the set\n      \u27e9\n    \u27e9\n  )\n  S -- give U for the set being non-empty\n  \u27e8 set.subset.refl _ , hindS \u27e9)\n\n#check is_algebraic_algebra_map\n\nlemma subfield_mem (a : L) (K : subfield L) (haK : a \u2208 K) :\n  a = algebra_map K L (\u27e8 a , haK \u27e9 : K) := rfl\n\nlemma is_algebraic_subfield {a : L} {K : subfield L} (haK : a \u2208 K) : is_algebraic K a :=\n\u27e8\n  polynomial.X - polynomial.C (\u27e8 a , haK \u27e9 : 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 \u2190 subfield_mem a K haK,\n    simp,\n  end\n\u27e9\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 \u222a {x}),\n  {\n    have hBx := hB.2 (B \u222a {x}) hind (by simp),\n    have hxBx : x \u2208 subfield_generated K B,\n    {apply subfield.subset_closure, left, rw \u2190 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 \u2192 polynomial (subfield_generated K B) :=\n    \u03bb k, @decidable.rec_on (as k \u2208 B) (\u03bb k, polynomial (subfield_generated K B)) _\n      (\u03bb _, polynomial.X)\n      (\u03bb h, polynomial.C (\u27e8 as k , subfield_generated.subset_closure h \u27e9 : subfield_generated K B)),\n\n    -- have p : polynomial (subfield_generated K B) := mv_polynomial.eval\u2082 _ _,\n\n  }\nend\n\nvariables (K) (L)\n\nlemma extend_to_basis (S : set L) (hindS : indep K S) :\n    \u2203 (B : set L), S \u2286 B \u2227 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 \u27e8 set.subset.trans hSB hBT , hindT \u27e9,\n    }\n  }\nend\n\nlemma basis_ex : \u2203 (B : set L), basis K B :=\nbegin\n  cases extend_to_basis K L \u2205 (indep_empty K) with B hB,\n  use B,\n  exact hB.2,\nend\n\nlemma basis_some : set L := @classical.some (set L) (\u03bb 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 \u2192 indep K S1 \u2192 equiv S0 S1 \u2192\n  subfield_generated K S0 \u2243+* 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 \u2243+* K1 \u2192\n  is_algebraic K0 L0 \u2192 is_algebraic K1 L1 \u2192 L0 \u2243+* 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 \u2192 transcendent.basis K B1 \u2192\n  equiv B0 B1\n  \u2192 L0 \u2243+* 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 {\u03b1  : Type*} [topological_space \u03b1 ] \n\n\ndef I01 := {x : \u211d | 0 \u2264 x \u2227 x \u2264 1}\n\n\ninstance : topological_space I01 := by unfold I01; apply_instance\ninstance : has_zero I01 := \u27e8\u27e80, le_refl _, zero_le_one\u27e9\u27e9\ninstance : has_one I01 := \u27e8\u27e81, zero_le_one, le_refl _\u27e9\u27e9\n\n                                                                                                \n\nstructure path (x y : \u03b1) :=\n(to_fun : I01 \u2192 \u03b1)\n(at_zero : to_fun 0 = x)\n(at_one : to_fun 1 = y)\n(cont : continuous to_fun)\n\n\n\ninstance {\u03b1} [topological_space \u03b1] (x y : \u03b1) : has_coe_to_fun (path x y) := \u27e8_, path.to_fun\u27e9 \n\n\n\n----------\n\n--attribute [class] path \n\n\n\n-- PATH INTERFACE\n\n@[simp]\nlemma start_pt_path { x y : \u03b1 } ( f : path x y ) : f.to_fun 0 = x := f.2\n\n@[simp]\nlemma end_pt_path { x y : \u03b1 } ( 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 \u2192 \u03b1 ) : Prop := f 0 = g 0 \u2227 f 1 = g 1\n\ndef equal_of_pts_path { z w x y : \u03b1 } ( g1 : path x y ) ( g2 : path z w) : Prop := equal_of_pts g1 g2\n\ndef check_pts ( x y : \u03b1 ) ( g : I01 \u2192 \u03b1 ) := g 0 = x \u2227 g 1 = y\n\ndef check_pts_of_path ( x y : \u03b1 ) { z w : \u03b1 } ( 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 : \u03b1 } { f g : path x y } : f = g  \u2194  f.to_fun = g.to_fun := \nbegin split, intro h\u2081, rw h\u2081, intro h\u2082, cases f, cases g, cc  end \n\n-- for later paths homotopy\ndef is_path ( x y : \u03b1 ) ( f : I01 \u2192 \u03b1 ) : Prop := f 0 = x \u2227 f 1 = y \u2227 continuous f \n\n\ndef to_path' { x y : \u03b1} ( f : I01 \u2192 \u03b1 ) ( 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 : \u03b1} ( f : I01 \u2192 \u03b1 ) ( 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 : \u03b1 }( g : path z w ) : continuous g.to_fun := g.cont \n\n--- Can Remove\ndef fun_of_path {\u03b1} [topological_space \u03b1 ]  { x1 x2 : \u03b1  } ( g : path x1 x2 ) : I01 \u2192 \u03b1   := 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 : \u211d ) ( Hab : a < b ) : set I01 :=  { x : I01 | a \u2264 x.val \u2227 x.val \u2264 b }  \n\n-- Prove any T r s Hrs is closed in I01\nlemma T_is_closed  { r s : \u211d } ( Hrs : r < s )  : is_closed (T r s Hrs) := \nbegin \n  let R := {x : \u21a5I01 | r \u2264 x.val }, let L := {x : \u21a5I01 |  x.val \u2264 s } , \n  have C1 : is_closed L, \n    { rw is_closed_induced_iff,\n    existsi {x : \u211d | 0 \u2264 x \u2227 x \u2264 (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 \u2264 s \u2194 0 \u2264 x.val \u2227 x.val \u2264 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 : \u211d | (max 0 r) \u2264 x \u2227 x \u2264 1},\n    split, \n      exact is_closed_inter (is_closed_ge' _)  (is_closed_le' 1), \n      apply set.ext, intro x,\n      show r \u2264 x.val \u2194 max 0 r \u2264 x.val \u2227 x.val \u2264 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 : \u211d} (Hrs : r < s) : T r s Hrs \u2192 I01 :=  \n\u03bb x, \u27e8 (x.val - r)/(s - r) , \nbegin \n  have D1 : 0 < (s - r) , by apply sub_pos.2 Hrs, \n  have D2 : 0 < (s - r)\u207b\u00b9, by exact inv_pos D1,   \n  have N1 : 0 \u2264 ((x.val : \u211d ) - r), \n      by exact sub_nonneg.2 (x.property.1), \n  have N2 : (x.val : \u211d )- r \u2264 s - r,\n      { have this : -r \u2264 -r, trivial, \n      show (x.val : \u211d ) + - r \u2264 s + - r,\n      exact add_le_add (x.property.2) this,}, \n  split, \n    show 0 \u2264 ((x.val : \u211d ) - r) * (s - r)\u207b\u00b9, \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 : \u211d ) - r) / (s - r) \u2264 (s - r) / (s - r),\n      by exact @div_le_div_of_le_of_pos _ _ ((x.val : \u211d ) - 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 \u27e9  \n\n\n\n-- Continuity of reparametrisation (later employed in compositions of path/homotopy)\nlemma continuous_par {r s : \u211d} (Hrs : r < s) : continuous ( par Hrs ) := \nbegin \n  unfold par, apply continuous_subtype_mk,\n  show continuous (\u03bb (x :  \u21a5(T r s Hrs)), ((x.1:\u211d ) - r) / (s - r)),\n  show continuous ((\u03bb ( y: \u211d ), (y - r) / (s - r)) \u2218 (\u03bb (x : \u21a5(T r s Hrs)), x.val.val)), \n  have H : continuous (\u03bb (x : \u21a5(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 : \u211d ) := by norm_num\n\nlemma half_lt_one : (1 / 2 : \u211d ) < 1 := by norm_num\n\ndef T1 : set I01 := T 0 ( 1/2: \u211d ) ( zero_lt_half )\n\ndef T2 : set I01 := T ( 1/2: \u211d ) 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) \u2208 T 0 (1/2) zero_lt_half := \nbegin unfold T, rw mem_set_of_eq, show 0 \u2264 (0:\u211d)  \u2227 ( 0:\u211d ) \u2264 1 / 2, norm_num,  end \n\nlemma help_T2 : (1 : I01) \u2208 T (1 / 2) 1 half_lt_one := \nbegin unfold T, rw mem_set_of_eq, split, show 1/2 \u2264 (1:\u211d) , norm_num, show (1:\u211d )\u2264 1, norm_num,  end \n\n\nlemma help_01 : (1 / 2 :\u211d) \u2208 I01 := begin unfold I01, rw mem_set_of_eq, norm_num end\n\nlemma help_02 : (1:I01) \u2209 T1 := \nbegin unfold T1 T,rw mem_set_of_eq, show \u00ac(0 \u2264 (1:\u211d ) \u2227 (1:\u211d) \u2264 1 / 2) , norm_num  end \n\nlemma help_half_T1 : ( \u27e8 1/2, help_01\u27e9 : I01) \u2208 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 : ( \u27e8 1/2, help_01\u27e9  : I01) \u2208 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 \u2228 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 \u222a 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\u2264 x.val \u2227 x.val \u2264 1, exact x.property, simp [or_iff_not_imp_left, -one_div_eq_inv], \n  intro nL, have H2 : (1 / 2 :\u211d )< x.val, exact nL H.1, exact \u27e8 le_of_lt H2, H.2 \u27e9 ,\nend \n\nlemma T2_of_not_T1 { s : I01} : (s \u2209 T1) \u2192 s \u2208 T2 := \nbegin \n  intro H, have H2 : T1 \u222a 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 : \u00acs.val \u2264 1 / 2, exact  H (s.2.1), exact lt_of_not_ge H4,\n  exact \u27e8 le_of_lt H3, s.2.2\u27e9 , \nend\n\n---- Lemmas to simplify evaluations of par \n@[simp]\nlemma eqn_start : par zero_lt_half \u27e80, help_T1\u27e9 = 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 \u27e8\u27e81 / 2, begin unfold I01, rw mem_set_of_eq, norm_num end\u27e9, begin unfold T, rw mem_set_of_eq, show 0 \u2264 (1/2 : \u211d ) \u2227 (1/2 : \u211d ) \u2264 1 / 2 ,  norm_num end \u27e9 \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 \u27e8\u27e81 / 2, help_01  \u27e9, begin unfold T, rw mem_set_of_eq, show 1/2 \u2264 (1/2 : \u211d ) \u2227 (1/2 : \u211d ) \u2264 1  ,  norm_num end\u27e9 \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 \u27e81, help_T2 \u27e9 = 1 :=  \nbegin unfold par, exact subtype.mk_eq_mk.2 ( begin show ( ( 1:\u211d ) - 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 : \u03b1 } {r s : \u211d} (Hrs : r < s) (f : path x y ) : T r s Hrs \u2192 \u03b1 := \n\u03bb t, f.to_fun ( par Hrs t)\n\nlemma pp_cont { x y : \u03b1 }{r s : \u211d} (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 : \u03b1 } (f : path x y ) : T1 \u2192 \u03b1 := \u03bb t, f.to_fun (par zero_lt_half t)\n\nlemma CA { x y : \u03b1 } (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 : \u03b1 } (f : path x y ) : T2 \u2192 \u03b1 := \u03bb t, f.to_fun (par half_lt_one t)\n\nlemma CB { x y : \u03b1 } (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 : \u03b1 } ( 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 \u2208 set.inter T1 T2, exact \u27e8 B1 , B2 \u27e9 , \n  rwa [inter_T] at Int, \n  have V : x.val = 1/2, rwa [mem_set_of_eq] at Int, \n  have xeq : x = (\u27e8 1/2 , help_01 \u27e9 : 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 \u27e8\u27e81 / 2, help_01\u27e9, help_half_T1\u27e9) = \n    g.to_fun (par half_lt_one \u27e8\u27e81 / 2, help_01\u27e9, help_half_T2\u27e9),\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 : \u03b1 } ( f : path x y )( g : path y z ) : path x z :=  \n{   to_fun := \u03bb 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 \u27e81,  help_T2 \u27e9) = 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 \u2208 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 \u2192 I01 :=  \u03bb x, \u27e8 1 - x.val , inv_in_I01 x \u27e9 \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 : \u211d ) : ( 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 ((\u03bb ( y: \u211d ), 1 - y ) \u2218 (\u03bb (x : \u21a5I01), x.val)), \n  refine continuous.comp continuous_subtype_val _, --\n  conv in ( (1:\u211d)-_) \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 : \u03b1 } ( f : path x y ) : path y x :=  \n{   to_fun := \u03bb t , f.to_fun ( par_inv t ) , --  or better f.to_fun \u2218 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 : \u03b1 } ( g : path x y) : Prop := x = y \n\n\ndef loop (x0 : \u03b1) : Type* := path x0 x0 \n\n\ndef loop_const (x0 : \u03b1) : loop x0 := \n{   to_fun:= \u03bb 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b9 \u03b1 : Type _}\n\nnamespace Rat\n\nsection WithDivRing\n\nvariable [DivisionRing \u03b1] [CharZero \u03b1]\n\n/- warning: rat.cast_list_sum -> Rat.cast_list_sum is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DivisionRing.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))))] (s : List.{0} Rat), Eq.{succ u1} \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u1} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Rat \u03b1 (Rat.castCoe.{u1} \u03b1 (DivisionRing.toHasRatCast.{u1} \u03b1 _inst_1)))) (List.sum.{0} Rat Rat.hasAdd Rat.hasZero s)) (List.sum.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))) (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1)))))) (List.map.{0, u1} Rat \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u1} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Rat \u03b1 (Rat.castCoe.{u1} \u03b1 (DivisionRing.toHasRatCast.{u1} \u03b1 _inst_1))))) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DivisionRing.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1)))] (s : List.{0} Rat), Eq.{succ u1} \u03b1 (Rat.cast.{u1} \u03b1 (DivisionRing.toRatCast.{u1} \u03b1 _inst_1) (List.sum.{0} Rat Rat.instAddRat (CommMonoidWithZero.toZero.{0} Rat (CommGroupWithZero.toCommMonoidWithZero.{0} Rat Rat.commGroupWithZero)) s)) (List.sum.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1)))))) (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (DivisionRing.toDivisionSemiring.{u1} \u03b1 _inst_1)))) (List.map.{0, u1} Rat \u03b1 (Rat.cast.{u1} \u03b1 (DivisionRing.toRatCast.{u1} \u03b1 _inst_1)) s))\nCase conversion may be inaccurate. Consider using '#align rat.cast_list_sum Rat.cast_list_sum\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_list_sum (s : List \u211a) : (\u2191s.Sum : \u03b1) = (s.map coe).Sum :=\n  map_list_sum (Rat.castHom \u03b1) _\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 {\u03b1 : Type.{u1}} [_inst_1 : DivisionRing.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))))] (s : Multiset.{0} Rat), Eq.{succ u1} \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u1} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Rat \u03b1 (Rat.castCoe.{u1} \u03b1 (DivisionRing.toHasRatCast.{u1} \u03b1 _inst_1)))) (Multiset.sum.{0} Rat Rat.addCommMonoid s)) (Multiset.sum.{u1} \u03b1 (AddCommGroup.toAddCommMonoid.{u1} \u03b1 (NonUnitalNonAssocRing.toAddCommGroup.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))))) (Multiset.map.{0, u1} Rat \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u1} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Rat \u03b1 (Rat.castCoe.{u1} \u03b1 (DivisionRing.toHasRatCast.{u1} \u03b1 _inst_1))))) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DivisionRing.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1)))] (s : Multiset.{0} Rat), Eq.{succ u1} \u03b1 (Rat.cast.{u1} \u03b1 (DivisionRing.toRatCast.{u1} \u03b1 _inst_1) (Multiset.sum.{0} Rat Rat.addCommMonoid s)) (Multiset.sum.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))))) (Multiset.map.{0, u1} Rat \u03b1 (Rat.cast.{u1} \u03b1 (DivisionRing.toRatCast.{u1} \u03b1 _inst_1)) s))\nCase conversion may be inaccurate. Consider using '#align rat.cast_multiset_sum Rat.cast_multiset_sum\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_multiset_sum (s : Multiset \u211a) : (\u2191s.Sum : \u03b1) = (s.map coe).Sum :=\n  map_multiset_sum (Rat.castHom \u03b1) _\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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : DivisionRing.{u2} \u03b1] [_inst_2 : CharZero.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b1 (Ring.toAddCommGroupWithOne.{u2} \u03b1 (DivisionRing.toRing.{u2} \u03b1 _inst_1))))] (s : Finset.{u1} \u03b9) (f : \u03b9 -> Rat), Eq.{succ u2} \u03b1 ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u2} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u2} Rat \u03b1 (Rat.castCoe.{u2} \u03b1 (DivisionRing.toHasRatCast.{u2} \u03b1 _inst_1)))) (Finset.sum.{0, u1} Rat \u03b9 Rat.addCommMonoid s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} \u03b1 \u03b9 (AddCommGroup.toAddCommMonoid.{u2} \u03b1 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (DivisionRing.toRing.{u2} \u03b1 _inst_1))))) s (fun (i : \u03b9) => (fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u2} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u2} Rat \u03b1 (Rat.castCoe.{u2} \u03b1 (DivisionRing.toHasRatCast.{u2} \u03b1 _inst_1)))) (f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : DivisionRing.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1)))] (s : Finset.{u2} \u03b9) (f : \u03b9 -> Rat), Eq.{succ u1} \u03b1 (Rat.cast.{u1} \u03b1 (DivisionRing.toRatCast.{u1} \u03b1 _inst_1) (Finset.sum.{0, u2} Rat \u03b9 Rat.addCommMonoid s (fun (i : \u03b9) => f i))) (Finset.sum.{u1, u2} \u03b1 \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))))) s (fun (i : \u03b9) => Rat.cast.{u1} \u03b1 (DivisionRing.toRatCast.{u1} \u03b1 _inst_1) (f i)))\nCase conversion may be inaccurate. Consider using '#align rat.cast_sum Rat.cast_sum\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_sum (s : Finset \u03b9) (f : \u03b9 \u2192 \u211a) : (\u2191(\u2211 i in s, f i) : \u03b1) = \u2211 i in s, f i :=\n  map_sum (Rat.castHom \u03b1) _ _\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 {\u03b1 : Type.{u1}} [_inst_1 : DivisionRing.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))))] (s : List.{0} Rat), Eq.{succ u1} \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u1} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Rat \u03b1 (Rat.castCoe.{u1} \u03b1 (DivisionRing.toHasRatCast.{u1} \u03b1 _inst_1)))) (List.prod.{0} Rat Rat.hasMul Rat.hasOne s)) (List.prod.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))) (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))))) (List.map.{0, u1} Rat \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u1} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Rat \u03b1 (Rat.castCoe.{u1} \u03b1 (DivisionRing.toHasRatCast.{u1} \u03b1 _inst_1))))) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DivisionRing.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1)))] (s : List.{0} Rat), Eq.{succ u1} \u03b1 (Rat.cast.{u1} \u03b1 (DivisionRing.toRatCast.{u1} \u03b1 _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} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1)))) (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 _inst_1))) (List.map.{0, u1} Rat \u03b1 (Rat.cast.{u1} \u03b1 (DivisionRing.toRatCast.{u1} \u03b1 _inst_1)) s))\nCase conversion may be inaccurate. Consider using '#align rat.cast_list_prod Rat.cast_list_prod\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_list_prod (s : List \u211a) : (\u2191s.Prod : \u03b1) = (s.map coe).Prod :=\n  map_list_prod (Rat.castHom \u03b1) _\n#align rat.cast_list_prod Rat.cast_list_prod\n\nend WithDivRing\n\nsection Field\n\nvariable [Field \u03b1] [CharZero \u03b1]\n\n/- warning: rat.cast_multiset_prod -> Rat.cast_multiset_prod is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Field.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 _inst_1)))))] (s : Multiset.{0} Rat), Eq.{succ u1} \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u1} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Rat \u03b1 (Rat.castCoe.{u1} \u03b1 (DivisionRing.toHasRatCast.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 _inst_1))))) (Multiset.prod.{0} Rat Rat.commMonoid s)) (Multiset.prod.{u1} \u03b1 (CommRing.toCommMonoid.{u1} \u03b1 (Field.toCommRing.{u1} \u03b1 _inst_1)) (Multiset.map.{0, u1} Rat \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u1} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Rat \u03b1 (Rat.castCoe.{u1} \u03b1 (DivisionRing.toHasRatCast.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 _inst_1)))))) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Field.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 _inst_1))))] (s : Multiset.{0} Rat), Eq.{succ u1} \u03b1 (Rat.cast.{u1} \u03b1 (Field.toRatCast.{u1} \u03b1 _inst_1) (Multiset.prod.{0} Rat Rat.commMonoid s)) (Multiset.prod.{u1} \u03b1 (CommRing.toCommMonoid.{u1} \u03b1 (Field.toCommRing.{u1} \u03b1 _inst_1)) (Multiset.map.{0, u1} Rat \u03b1 (Rat.cast.{u1} \u03b1 (Field.toRatCast.{u1} \u03b1 _inst_1)) s))\nCase conversion may be inaccurate. Consider using '#align rat.cast_multiset_prod Rat.cast_multiset_prod\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_multiset_prod (s : Multiset \u211a) : (\u2191s.Prod : \u03b1) = (s.map coe).Prod :=\n  map_multiset_prod (Rat.castHom \u03b1) _\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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Field.{u2} \u03b1] [_inst_2 : CharZero.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b1 (Ring.toAddCommGroupWithOne.{u2} \u03b1 (DivisionRing.toRing.{u2} \u03b1 (Field.toDivisionRing.{u2} \u03b1 _inst_1)))))] (s : Finset.{u1} \u03b9) (f : \u03b9 -> Rat), Eq.{succ u2} \u03b1 ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u2} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u2} Rat \u03b1 (Rat.castCoe.{u2} \u03b1 (DivisionRing.toHasRatCast.{u2} \u03b1 (Field.toDivisionRing.{u2} \u03b1 _inst_1))))) (Finset.prod.{0, u1} Rat \u03b9 Rat.commMonoid s (fun (i : \u03b9) => f i))) (Finset.prod.{u2, u1} \u03b1 \u03b9 (CommRing.toCommMonoid.{u2} \u03b1 (Field.toCommRing.{u2} \u03b1 _inst_1)) s (fun (i : \u03b9) => (fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Rat \u03b1 (HasLiftT.mk.{1, succ u2} Rat \u03b1 (CoeTC\u2093.coe.{1, succ u2} Rat \u03b1 (Rat.castCoe.{u2} \u03b1 (DivisionRing.toHasRatCast.{u2} \u03b1 (Field.toDivisionRing.{u2} \u03b1 _inst_1))))) (f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Field.{u1} \u03b1] [_inst_2 : CharZero.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 _inst_1))))] (s : Finset.{u2} \u03b9) (f : \u03b9 -> Rat), Eq.{succ u1} \u03b1 (Rat.cast.{u1} \u03b1 (Field.toRatCast.{u1} \u03b1 _inst_1) (Finset.prod.{0, u2} Rat \u03b9 Rat.commMonoid s (fun (i : \u03b9) => f i))) (Finset.prod.{u1, u2} \u03b1 \u03b9 (CommRing.toCommMonoid.{u1} \u03b1 (Field.toCommRing.{u1} \u03b1 _inst_1)) s (fun (i : \u03b9) => Rat.cast.{u1} \u03b1 (Field.toRatCast.{u1} \u03b1 _inst_1) (f i)))\nCase conversion may be inaccurate. Consider using '#align rat.cast_prod Rat.cast_prod\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_prod (s : Finset \u03b9) (f : \u03b9 \u2192 \u211a) : (\u2191(\u220f i in s, f i) : \u03b1) = \u220f i in s, f i :=\n  map_prod (Rat.castHom \u03b1) _ _\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 (\u03b1 : Type u) (\u03b2 : Type u) := { f : \u03b2 \u2192 Term \u03b1 \u03b2 // finite { x : \u03b2 // f x \u2260 Term.Var x } }\n\nprivate theorem comp_carrier {f g : \u03b2 \u2192 Term \u03b1 \u03b2} {x : \u03b2} :\n  ((f * g) x \u2260 Term.Var x) \u2192 f x \u2260 Term.Var x \u2228 g x \u2260 Term.Var x := by\n  rw [\u2190 Decidable.not_and_iff_or_not]\n  apply contrapose\n  exact \u03bb \u27e8 h\u2081, h\u2082 \u27e9 => by simp [HMul.hMul, Mul.mul, comp, map_reduce, h\u2081, h\u2082]\n\nprivate def carriers_arrow (f g : \u03b2 \u2192 Term \u03b1 \u03b2) : ({ x : \u03b2 // (f * g) x \u2260 Term.Var x }) \u2192\n  { x // f x \u2260 Term.Var x } \u2295 { x // g x \u2260 Term.Var x } :=\n  \u03bb \u27e8 x, p \u27e9 =>\n    if hf : f x \u2260 Term.Var x then Sum.inl \u27e8 x, hf \u27e9\n    else if hg : g x \u2260 Term.Var x then Sum.inr \u27e8 x, hg \u27e9\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 : \u03b2 \u2192 Term \u03b1 \u03b2) (x y : {x // (f * g) x \u2260 Term.Var x})\n  (h : carriers_arrow f g x = carriers_arrow f g y) : x = y := by\n  revert x y\n  intro \u27e8 x, hx \u27e9 \u27e8 y, hy \u27e9 h\n  apply Subtype.eq\n  simp [carriers_arrow] at h\n  have x_nontriv : {P : Prop} \u2192 \u00ac f x \u2260 Term.Var x \u2192 \u00ac g x \u2260 Term.Var x \u2192 P :=\n    \u03bb 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} \u2192 \u00ac f y \u2260 Term.Var y \u2192 \u00ac g y \u2260 Term.Var y \u2192 P :=\n    \u03bb p q => False.elim <| match comp_carrier hy with | Or.inl r => p r | Or.inr r => q r\n  by_cases p\u2081 : f x \u2260 Term.Var x <;> by_cases p\u2082 : g x \u2260 Term.Var x\n    <;> by_cases p\u2083 : f y \u2260 Term.Var y <;> by_cases p\u2084 : g y \u2260 Term.Var y\n    <;> simp [dif_pos p\u2081, dif_neg p\u2081, dif_pos p\u2082, dif_neg p\u2082,\n      dif_pos p\u2083, dif_neg p\u2083, dif_pos p\u2084, dif_neg p\u2084] at h\n    <;> first\n      | assumption\n      | apply x_nontriv; assumption; assumption\n      | apply y_nontriv; assumption; assumption\n\ninstance : Monoid (Subst \u03b1 \u03b2) where\n  one := \u27e8 Term.Var, \u27e8 [], \u03bb \u27e8 _, p \u27e9 => False.elim <| p rfl \u27e9 \u27e9\n  mul := \u03bb \u27e8 f, pf \u27e9 \u27e8 g, pg \u27e9 =>\n    \u27e8 f * g, invimage_finite_of_inj (sum_finite pf pg) (carriers_arrow_inj f g) \u27e9\n  one_mul := \u03bb \u27e8 _, _ \u27e9 => rfl\n  mul_one := \u03bb \u27e8 _, _ \u27e9 => Subtype.eq <| fun_monoid.mul_one _\n  mul_assoc := \u03bb \u27e8 _, _ \u27e9 \u27e8 _, _ \u27e9 \u27e8 _, _ \u27e9 => Subtype.eq <| fun_monoid.mul_assoc _ _ _\n\ninstance subst_self_action : RAction (Subst \u03b1 \u03b2) (Subst \u03b1 \u03b2) := self_action _\n\ninstance subst_term_action : RAction (Term \u03b1 \u03b2) (Subst \u03b1 \u03b2) where\n  smul := \u03bb x \u27e8 f, hf \u27e9 => x \u2022 f\n  smul_one := term_action.smul_one\n  smul_mul := \u03bb _ \u27e8 _, _ \u27e9 \u27e8 _, _ \u27e9 => term_action.smul_mul _ _ _\n\ndef Subst.ext {\u03b8 \u03c6 : Subst \u03b1 \u03b2} : \u03b8 = \u03c6\n  \u2194 \u2200 x, (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03b8 = (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03c6 := by\n  apply Iff.intro (by intro h _; rw [h])\n  intro h\n  match \u03b8 with\n  | \u27e8 \u03b8, _ \u27e9 => match \u03c6 with\n    | \u27e8 \u03c6, _ \u27e9 =>\n      apply Subtype.eq\n      funext x\n      exact h x\n\ndef Subst.elementary {x : \u03b2} {u : Term \u03b1 \u03b2} (h : Term.Var x \u2260 u) : Subst \u03b1 \u03b2 :=\n  \u27e8 \u03bb z => if z = x then u else Term.Var z, by\n    apply Exists.intro [\u27e8 x, by simp [h.symm] \u27e9]\n    intro \u27e8 z, hz \u27e9\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 \u27e9\n\ntheorem Subst.elementary_spec\u2081 {x : \u03b2} {u : Term \u03b1 \u03b2} (h : Term.Var x \u2260 u) :\n  (Term.Var x : Term \u03b1 \u03b2) \u2022 (elementary h : Subst \u03b1 \u03b2) = u := by\n  simp [RSMul.smul, elementary, map_reduce]\n\ntheorem Subst.elementary_spec\u2082 {x z : \u03b2} {u : Term \u03b1 \u03b2} (h : Term.Var x \u2260 u) (h' : z \u2260 x) :\n  (Term.Var z : Term \u03b1 \u03b2) \u2022 (elementary h : Subst \u03b1 \u03b2) = Term.Var z := by\n  simp [RSMul.smul, elementary, map_reduce, h']\n\ndef subst_simple (x : \u03b2) (u : Term \u03b1 \u03b2) :=\n  if p : Term.Var x = u then 1\n  else Subst.elementary p\n\n@[simp]\ntheorem subst_simple_spec {x y : \u03b2} {u : Term \u03b1 \u03b2} :\n  Term.Var y \u2022 subst_simple x u =\n    if y = x then u\n    else Term.Var y :=\n  if h\u2081 : Term.Var x = u then\n    if h\u2082 : y = x then by\n      simp [subst_simple, h\u2081, h\u2082, RAction.smul_one]\n    else by\n      simp [subst_simple, h\u2081, h\u2082, RAction.smul_one]\n  else\n    if h\u2082 : y = x then by\n      simp only [h\u2082, subst_simple, h\u2081]\n      exact Subst.elementary_spec\u2081 h\u2081\n    else by\n      simp only [subst_simple, h\u2081, h\u2082]\n      exact Subst.elementary_spec\u2082 h\u2081 h\u2082\n\n@[simp]\ntheorem subst_simple_trivial {x : \u03b2} : subst_simple x (Term.Var x : Term \u03b1 \u03b2) = 1 := by\n  simp [subst_simple]\n\n@[simp]\ntheorem subst_cons {u v : Term \u03b1 \u03b2} {\u03b8 : Subst \u03b1 \u03b2} :\n  Term.Cons u v \u2022 \u03b8 = Term.Cons (u \u2022 \u03b8) (v \u2022 \u03b8) := by\n  cases \u03b8; rfl\n\ndef carrier (\u03b8 : Subst \u03b1 \u03b2) : Fintype \u03b2 :=\n  match \u03b8 with\n  | \u27e8 \u03b8, h \u27e9 =>\n    let \u03c0 : {x // \u03b8 x \u2260 Term.Var x} \u2192 \u03b2 := \u03bb \u27e8 x, _ \u27e9 => x\n    Fintype.mk <| List.map \u03c0 (epsilon <| \u03bb l => \u2200 a, a \u2208 l)\n\ndef carrier_spec {\u03b8 : Subst \u03b1 \u03b2} {y : \u03b2} :\n  y \u2208 carrier \u03b8 \u2194 (Term.Var y : Term \u03b1 \u03b2) \u2022 \u03b8 \u2260 Term.Var y :=\n  match \u03b8 with\n  | \u27e8 \u03b8, h\u03b8 \u27e9 => by\n    apply Iff.intro\n    focus\n      intro h\n      let \u27e8 \u27e8 x, hx \u27e9, \u27e8 _, h\u2082 \u27e9 \u27e9 := List.mem_map_iff_image.1 h\n      exact h\u2082 \u25b8 hx\n    focus\n      let \u03c0 : {x // \u03b8 x \u2260 Term.Var x} \u2192 \u03b2 := \u03bb \u27e8 x, _ \u27e9 => x\n      intro h'\n      rw [show y = \u03c0 \u27e8 y, h' \u27e9 from rfl]\n      apply List.mem_map\n      apply epsilon_spec h\u03b8\n\ntheorem is_one_iff_empty_carrier {\u03b8 : Subst \u03b1 \u03b2} : \u03b8 = 1 \u2194 carrier \u03b8 = \u2205 := by\n  apply Iff.intro\n  focus\n    intro h\n    rw [h, Fintype.ext]\n    intro x\n    apply Iff.intro _ (False.elim \u2218 Fintype.not_mem_empty _)\n    rw [carrier_spec]\n    exact \u03bb 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 [\u2190 h, carrier_spec]\n    exact h'\n\ntheorem carrier_one : carrier (1 : Subst \u03b1 \u03b2) = \u2205 :=\n  is_one_iff_empty_carrier.1 rfl\n\ntheorem is_one_iff_not_modifying (\u03b8 : Subst \u03b1 \u03b2) :\n  \u03b8 = 1 \u2194 \u2200 x, (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03b8 = Term.Var x := Subst.ext\n\ntheorem not_one_iff_modifying (\u03b8 : Subst \u03b1 \u03b2) :\n  \u03b8 \u2260 1 \u2194 \u2203 x, (Term.Var x : Term \u03b1 \u03b2) \u2022 \u03b8 \u2260 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' \u27e8 x, h'' \u27e9\n  focus\n    intro \u27e8 x, h \u27e9 h'\n    rw [is_one_iff_not_modifying] at h'\n    exact h (h' x)\n\ntheorem elementary_carrier {x : \u03b2} {u : Term \u03b1 \u03b2} {h : Term.Var x \u2260 u} :\n  carrier (Subst.elementary h : Subst \u03b1 \u03b2) = 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 \u2218 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\u2081]\n    exact Ne.symm h\n\ntheorem carrier_cons (\u03b8 \u03c6 : Subst \u03b1 \u03b2) : carrier (\u03b8 * \u03c6) \u2286 carrier \u03b8 \u222a carrier \u03c6 := by\n  intro x\n  rw [Fintype.mem_union_iff]\n  simp only [carrier_spec]\n  match \u03b8 with\n  | \u27e8 \u03b8, _ \u27e9 => match \u03c6 with\n    | \u27e8 \u03c6, _ \u27e9 => 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": "def f (x : Nat) : Nat :=\n  x + (set_option trace.Meta.synthInstance true in 1)\n\ndef g (x : Nat) : Nat := 0 + x.succ\n\ntheorem ex : f = g := by\n  simp only [f]\n  set_option trace.Meta.Tactic.simp true in simp only [Nat.add_succ, g]\n  simp only [Nat.zero_add]\n  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/setOptionTermTactic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8397339596505965, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.48813994606387884}}
{"text": "import algebra.module.linear_map\nimport data.real.basic\n\n\ndef f (x y z : \u211d) : \u211d  := x+y+2*z\ntheorem cpge_applin_1_a [module \u211d (prod \u211d (prod \u211d \u211d))] [E : set (prod \u211d \u211d)]: \n\u2203 g : (linear_map  \u211d (prod \u211d (prod \u211d \u211d)) \u211d), \n\u2200 x y z : \u211d , (f x y z) = (g (x, y, z)) := 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/applications_lineaires/cpge_applin_1_a.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8991213826762113, "lm_q2_score": 0.5428632831725052, "lm_q1q2_score": 0.4880999857702105}}
{"text": "import Quiz9\nimport Sets.Basic\nimport Lean.Elab.Print\nimport Lean.Elab.Command\n\nopen Set \n\nvariable {\u03b1 : Type}\nvariable (X Y : Set \u03b1)\n\ntheorem desiredType1 : X \u2229 X\u1d9c = \u2205 := sorry \n\ntheorem desiredType2 : X \u222a X\u1d9c = Univ := sorry \n\ntheorem desiredTyep3 : X\u1d9c \u222a X = Univ := sorry \n\nopen Lean\nopen Lean.Meta\nopen Lean.Elab.Command\n\ndef n : String := \"1\"\n\ndef problem : String := \"problem\"++n\n\ndef desired : String := \"desiredType\"++n\n\ndef collectAxiomsOf (constName : Name) : MetaM (List String) := do\n  let env \u2190 getEnv\n  let (_, s) := ((CollectAxioms.collect constName).run env).run {}\n  let a := s.axioms.toList.map toString\n  return a\n\n#eval isDefEq (Expr.const desired []) (Expr.const problem [])\n#eval collectAxiomsOf problem\n", "meta": {"author": "UofSC-Fall-2022-Math-300-H01", "repo": "quiz9", "sha": "95d0b3fdfbb0190af5e011d7213a55a35fc079ee", "save_path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-quiz9", "path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-quiz9/quiz9-95d0b3fdfbb0190af5e011d7213a55a35fc079ee/_Tests/Problem1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031737963569016, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.48805913502095216}}
{"text": "example : Int \u2192 Nat\n| (_ : Nat)     => 0\n| Int.negSucc n => 0\n\nprotected theorem Int.add_comm : \u2200 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 \u2192 preterm \u2192 form\n| le  : preterm \u2192 preterm \u2192 form\n| not : form \u2192 form\n| or  : form \u2192 form \u2192 form\n| and : form \u2192 form \u2192 form\n\nnotation x `=*` y := form.eq x y\nnotation x `\u2264*` y := form.le x y\nnotation `\u00ac*` p := form.not p\nnotation p `\u2228*` q := form.or p q\nnotation p `\u2227*` q := form.and p q\n\n-- | (t =* s) :=\n-- | (t \u2264* s) :=\n-- | (\u00ac* p)   :=\n-- | (p \u2228* q) := \n-- | (p \u2227* q) := \n\ndef valuation.cons (i : int) (v : nat \u2192 int) : nat \u2192 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 \u2192 int) : form \u2192 Prop \n| (t =* s) := t.val v = s.val v\n| (t \u2264* s) := t.val v \u2264 s.val v\n| (\u00ac* p)   := \u00ac p.holds\n| (p \u2228* q) := p.holds \u2228 q.holds\n| (p \u2227* q) := p.holds \u2227 q.holds\n\nend form\n\n@[omega] def uniclo (p : form) : (nat \u2192 int) \u2192 nat \u2192 Prop \n| v 0     := p.holds v\n| v (k+1) := \u2200 i : int, uniclo (i::v) k \n\nnamespace form\n\ndef fresh_idx : form \u2192 nat \n| (t =* s) := max t.fresh_idx s.fresh_idx\n| (t \u2264* s) := max t.fresh_idx s.fresh_idx\n| (\u00ac* p)   := p.fresh_idx\n| (p \u2228* q) := max p.fresh_idx q.fresh_idx\n| (p \u2227* q) := max p.fresh_idx q.fresh_idx\n\n--def uniclo (p : form) : Prop := \n--uniclo_core p p.fresh_idx (\u03bb _, 0)\n\ndef valid (p : form) : Prop := \n\u2200 v, holds v p\n\ndef sat (p : form) : Prop := \n\u2203 v, holds v p\n\ndef implies (p q : form) : Prop := \n\u2200 v, (holds v p \u2192 holds v q)\n\ndef equiv (p q : form) : Prop := \n\u2200 v, (holds v p \u2194 holds v q)\n\nlemma sat_of_implies_of_sat {p q} :\n  implies p q \u2192 sat p \u2192 sat q :=\nbegin intros h1 h2, apply exists_of_exists h1 h2 end\n\nlemma sat_or {p q : form} :\n  sat (p \u2228* q) \u2194 sat p \u2228 sat q :=\nbegin\n  constructor; intro h1,\n  { cases h1 with v h1, cases h1 with h1 h1;\n    [left,right]; refine \u27e8v,_\u27e9; assumption },\n  { cases h1 with h1 h1; cases h1 with v h1;\n    refine \u27e8v,_\u27e9; [left,right]; assumption }\nend\n\ndef unsat (p : form) : Prop := \u00ac sat p\n\ndef repr : form \u2192 string \n| (t =* s) := \"(\" ++ t.repr ++ \" = \" ++ s.repr ++ \")\"\n| (t \u2264* s) := \"(\" ++ t.repr ++ \" \u2264 \" ++ s.repr ++ \")\"\n| (\u00ac* p)   := \"\u00ac\" ++ p.repr\n| (p \u2228* q) := \"(\" ++ p.repr ++ \" \u2228  \" ++ q.repr ++ \")\"\n| (p \u2227* q) := \"(\" ++ p.repr ++ \" \u2227 \" ++ q.repr ++ \")\"\n\ninstance has_repr : has_repr form := \u27e8repr\u27e9 \nmeta instance has_to_format : has_to_format form := \u27e8\u03bb x, x.repr\u27e9 \n\nend form\n\nlemma uniclo_of_valid {p : form} : \n  \u2200 {m v}, p.valid \u2192 uniclo p v m \n| 0 v h1     := h1 _ \n| (m+1) v h1 := \u03bb 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} : (\u00ac*p).unsat \u2192 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} {\u03b1 : Type u} (r : Set \u03b1) := (a : \u03b1) \u2192 Decidable (a \u2208 r)\ninstance {\u03b1} (s : Set \u03b1) [DecidableSet s] : DecidableSet s.compl := \u03bb _ => show Decidable (\u00ac_) from inferInstance\ninstance {\u03b1} [DecidableEq \u03b1] (j : \u03b1) : DecidableSet {j} := \u03bb _ => show Decidable (_ = _) from inferInstance\n\n\nnoncomputable\ndef Set.size {\u03b1} [i : Fintype \u03b1] [DecidableEq \u03b1] (s : Set \u03b1) [DecidableSet s] : Nat :=\n  (i.elems.filter (decide $ . \u2208 s)).toList.length\n\nstructure SimpleGraph (\u03b1) [Fintype \u03b1] [DecidableEq \u03b1] where\n  isEdge : \u03b1 \u2192 \u03b1 \u2192 Bool\n\nsection\n  variable {\u03b1} [Fintype \u03b1] [DecidableEq \u03b1]\n  -- instance : \u2200 i j, Decidable (graph.isEdge i j) := graph.decidable_isEdge\n  -- instance : \u2200 i, DecidableSet (graph.isEdge i) := graph.decidable_isEdge\n\n  namespace SimpleGraph\n  section\n    variable (graph : SimpleGraph \u03b1)\n    abbrev nodesOutOf (i : \u03b1) : Set \u03b1 := (graph.isEdge i . = true)\n    abbrev nodesInto (j : \u03b1) : Set \u03b1 := (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 \u03b1) [DecidableSet s] : SimpleGraph { x : \u03b1 // x \u2208 s } where\n      isEdge | \u27e8i, _\u27e9, \u27e8j, _\u27e9 => graph.isEdge i j \n  end\n\n  variable (graph : SimpleGraph \u03b1) in\n  inductive Walk : \u03b1 \u2192 \u03b1 \u2192 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 \u03b1) (s : Set \u03b1) [DecidableSet s] (i j : { x : \u03b1 // x \u2208 s }) :=\n    (graph.induce s).Walk i j\n  def WalkNotIn (graph : SimpleGraph \u03b1) (s : Set \u03b1) [DecidableSet s] := graph.WalkIn s.compl\n\n  section\n    variable {graph : SimpleGraph \u03b1}\n    namespace Walk\n    def length {i j} : graph.Walk i j \u2192 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 \u2192 List \u03b1\n      | nil i => [i]\n      | cons i k w j h => j :: w.nodeList\n\n    def nodes {i j} : graph.Walk i j \u2192 Set \u03b1\n      | nil i => {i}\n      | cons i k w j h => w.nodes \u222a {j}\n    \n    theorem first_mem_nodeList {i j} (w : graph.Walk i j) : i \u2208 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 \u2208 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 \u2209 w.nodeList) :=\n      graph.WalkNotIn {a}\n        \u27e8i, \u03bb c => by subst c; exact h w.first_mem_nodeList\u27e9\n        \u27e8j, \u03bb c => by subst c; exact h w.last_mem_nodeList\u27e9\n    def to_WalkNotIn_of_notIn_nodeList {i j} (w : graph.Walk i j) {a} (h : a \u2209 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 \u03bb 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 \u2209 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 \u03bb c => h $ List.mem_cons.mpr $ Or.inr c\n\n    theorem first_mem_nodes {i j} (w : graph.Walk i j) : i \u2208 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 \u2208 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 \u2286 s)\n      : graph.WalkIn s \u27e8i, h w.first_mem_nodes\u27e9 \u27e8j, h w.last_mem_nodes\u27e9 :=\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 \u03bb _ 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 \u2286 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 \u03b1) (i j) := { w : graph.Walk i j // List.Nodup w.nodeList }\n\n  def Path2 (graph : SimpleGraph \u03b1) (i j) := { w : graph.Walk i j // \u2200 i, i \u2208 w.nodes \u2192 False }\n  #exit\n\n  section\n    variable {graph : SimpleGraph \u03b1}\n    namespace Path\n    def cons  {i k : \u03b1} (p : graph.Path i k) {j : \u03b1} (h : graph.isEdge k j = true) (hj : j \u2209 p.val.nodeList)\n      : graph.Path i j :=\n      \u27e8Walk.cons _ _ p.val _ h, List.nodup_cons.mpr \u27e8hj, p.property\u27e9\u27e9\n\n    def to_PathNotIn_of_notIn_nodeList {i j} (p : graph.Path i j) {a} (h : a \u2209 p.val.nodeList)\n      : (graph.induce (Set.compl {a})).Path\n          \u27e8i, \u03bb c => by subst c; exact h p.val.first_mem_nodeList\u27e9\n          \u27e8j, \u03bb c => by subst c; exact h p.val.last_mem_nodeList\u27e9 :=\n      match i, j, p, h with\n      | _, _, \u27e8Walk.nil _, _\u27e9, h => \u27e8Walk.nil _, List.nodup_singleton _\u27e9\n      | i, j, \u27e8Walk.cons _ k w _ hks, hn\u27e9, h =>\n        have hn := List.nodup_cons.mp hn\n        let wr : Walk .. := (w.to_WalkNotIn_of_notIn_nodeList \u03bb 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 .. := \u27e8wr, this\u27e9\n        r.cons hks $ show _ \u2209 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 \u2286 s)\n      : (graph.induce s).Path \u27e8i, h p.val.first_mem_nodes\u27e9 \u27e8j, h p.val.last_mem_nodes\u27e9 :=\n      match i, j, p, h with\n      | _, _, \u27e8Walk.nil _, _\u27e9, h => \u27e8Walk.nil _, List.nodup_singleton _\u27e9\n      | i, j, \u27e8Walk.cons _ k w _ hks, hn\u27e9, h =>\n      sorry\n\n#exit\n\n    end Path\n  end\n  \n  example (a : List \u03b1) (b : List \u03b2) (f : \u03b1 \u2192 \u03b2) (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 \u03b1)\n\n    def Connected := \u2200 i j, Nonempty (graph.Walk i j)\n    def Cycle (i) := { w : graph.Walk i i // w.length \u2260 0 }\n    def Acyclic := \u2200 i, graph.Cycle i \u2192 False\n\n    theorem exists_nil_Walk_iff (i j) : (\u2203 w : graph.Walk i j, w.length = 0) \u2194 i = j :=\n      \u27e8\u03bb \u27e8w, _\u27e9 => match w with | Walk.nil i => rfl, \u03bb h => h \u25b8 \u27e8Walk.nil i, rfl\u27e9\u27e9\n\n    theorem exists_Walk_iff (i j) (m)\n      : (\u2203 w : graph.Walk i j, w.length = m + 1) \u2194 \u2203 k, (\u2203 w : graph.Walk i k, w.length = m) \u2227 graph.isEdge k j :=\n    \u27e8\u03bb \u27e8Walk.cons i k w _ hkj, hw\u27e9 => \u27e8k, \u27e8\u27e8w, Nat.succ.inj hw\u27e9, hkj\u27e9\u27e9\n    , \u03bb \u27e8k, \u27e8\u27e8w, hw\u27e9, hkj\u27e9\u27e9 => \u27e8Walk.cons i k w j hkj, congrArg (. + 1) hw\u27e9\u27e9\n\n    def decidable_exists_nonnil_Walk (i j) (m : Nat) : Decidable (\u2203 w : graph.Walk i j, w.length = m + 1) := by\n        rw [graph.exists_Walk_iff i j m]\n        suffices \u2200 k, Decidable ((\u2203 w : graph.Walk i k, w.length = m) \u2227 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 (\u2203 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) : (\u2203 w : graph.Walk i j, w.length = 0) \u2194 i = j :=\n    --   \u27e8\u03bb \u27e8w, _\u27e9 => match w with | Walk.nil i => rfl, \u03bb h => h \u25b8 \u27e8Walk.nil i, rfl\u27e9\u27e9\n\n    theorem exists_Path_iff (i j) (m)\n      : (\u2203 w : graph.Path i j, w.val.length = m + 1) \u2194 \u2203 k, (\u2203 w : graph.Path i k, j \u2209 w.val.nodeList \u2227 w.val.length = m) \u2227 graph.isEdge k j :=\n    \u27e8\u03bb \u27e8\u27e8Walk.cons i k w _ hkj, pw\u27e9, hw\u27e9 => \n      have pw := List.nodup_cons.mp pw\n      \u27e8k, \u27e8\u27e8\u27e8w, pw.2\u27e9, \u27e8pw.1, Nat.succ.inj hw\u27e9\u27e9, hkj\u27e9\u27e9\n    , \u03bb \u27e8k, \u27e8\u27e8w, \u27e8pw, hw\u27e9\u27e9, hkj\u27e9\u27e9 =>\n      have pw := List.nodup_cons.mpr \u27e8pw, w.prop\u27e9\n      \u27e8\u27e8Walk.cons i k w.val j hkj, pw\u27e9, congrArg (. + 1) hw\u27e9\u27e9\n\n    theorem exists_Path_iff2 (i j) (m)\n      : (\u2203 w : graph.Path i j, w.val.length = m + 1) \u2194 \u2203 k, (\u2203 w : (graph.cutNodes {j}).Path \u27e8i, sorry\u27e9 \u27e8k, sorry\u27e9, w.val.length = m) \u2227 graph.isEdge k j :=\n    \u27e8\u03bb \u27e8\u27e8Walk.cons i k w _ hkj, pw\u27e9, hw\u27e9 => \n      have pw := List.nodup_cons.mp pw\n      \u27e8k, \u27e8\u27e8\u27e8sorry, sorry\u27e9, sorry\u27e9, hkj\u27e9\u27e9,\n    sorry\u27e9\n\n\n\n    def decidable_exists_nonnil_Path {\u03b1} [Fintype \u03b1] [DecidableEq \u03b1] (graph : SimpleGraph \u03b1)\n      (i j) (m : Nat) : Decidable (\u2203 w : graph.Path i j, w.val.length = m + 1) := by\n        rw [graph.exists_Path_iff i j m]\n        suffices \u2200 k, Decidable ((\u2203 w : graph.Path i k, j \u2209 w.val.nodeList \u2227 w.val.length = m) \u2227 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 \u27e8i, sorry\u27e9 \u27e8k, sorry\u27e9 m\n          -- infer_instance\n          sorry\n\n\n\n    -- theorem degreeInto_ge_1_of_Connected_and_ge_2 (hn : n \u2265 2) (hc : graph.Connected) (i : Fin n)\n    --   : graph.degreeInto i \u2265 1 :=\n    --   let j : Fin n := if i = \u27e80, by linarith\u27e9 then \u27e81, by linarith\u27e9 else \u27e80, by linarith\u27e9\n    --   have : i.1 \u2260 j.1 := sorry\n    --   match (hc j i).some with\n    --   | .cons _ k w i h => sorry\n\n    -- def findLeaf (hn : n \u2265 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`\u03b9` is an indexing set of oracles (i.e. `\u03b9 := \u2115` gives a different oracle for each `n : \u2115`).\n`domain range : \u03b9 \u2192 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(\u03b9 : Type)\n(domain range : \u03b9 \u2192 Type)\n(range_inhabited (i : \u03b9) : inhabited $ range i)\n(\u03b9_decidable_eq : decidable_eq \u03b9)\n(domain_decidable_eq (i : \u03b9) : decidable_eq $ domain i)\n(range_decidable_eq (i : \u03b9) : decidable_eq $ range i)\n(range_fintype (i : \u03b9) : fintype $ range i)\n\n/-- Example of a simple `oracle_spec` for a pair of oracles,\neach taking a natural `n : \u2115` 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{ \u03b9 := unit \u2295 unit,\n  domain := \u03bb _, \u2115,\n  range := \u03bb x, match x with | (sum.inl ()) := fin 100 | (sum.inr ()) := bool end,\n  range_inhabited := \u03bb x, match x with\n  | (sum.inl ()) := fin.inhabited\n  | (sum.inr ()) := bool.inhabited\n  end,\n  \u03b9_decidable_eq := sum.decidable_eq unit unit,\n  domain_decidable_eq := \u03bb _, nat.decidable_eq,\n  range_decidable_eq := \u03bb x, match x with\n  | (sum.inl ()) := fin.decidable_eq 100\n  | (sum.inr ()) := bool.decidable_eq\n  end,\n  range_fintype := \u03bb 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.\u03b9) : inhabited (spec.range i) :=\nspec.range_inhabited i\n\nvariables (spec : oracle_spec)\n\ninstance \u03b9.decidable_eq' : decidable_eq spec.\u03b9 := spec.\u03b9_decidable_eq\n\ninstance domain.decidable_eq' (i : spec.\u03b9) :\n  decidable_eq (spec.domain i) := spec.domain_decidable_eq i\n\ninstance range.decidable_eq' (i : spec.\u03b9) :\n  decidable_eq (spec.range i) := spec.range_decidable_eq i\n\ninstance range.fintype' (i : spec.\u03b9) :\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{ \u03b9 := unit,\n  domain := \u03bb _, T,\n  range := \u03bb _, U,\n  range_inhabited := \u03bb _, hU,\n  \u03b9_decidable_eq := punit.decidable_eq,\n  domain_decidable_eq := \u03bb _, hT,\n  range_decidable_eq := \u03bb _, hU',\n  range_fintype := \u03bb _, hU'' }\n\ninfixl` \u21a6\u2092 `:25 := singleton_spec\n\nvariables (T U : Type) [inhabited U] [decidable_eq T] [decidable_eq U] [fintype U]\n\ninstance singleton_spec_\u03b9_subsingleton : subsingleton (T \u21a6\u2092 U).\u03b9 := 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{ \u03b9 := empty,\n  domain := \u03bb _, unit,\n  range := \u03bb _, unit,\n  range_inhabited := \u03bb _, by apply_instance,\n  \u03b9_decidable_eq := empty.decidable_eq,\n  domain_decidable_eq := \u03bb i, i.elim,\n  range_decidable_eq := \u03bb i, i.elim,\n  range_fintype := \u03bb i, i.elim }\n\nnotation `[]\u2092` := empty_spec\n\ninstance empty_spec_\u03b9_subsingleton : subsingleton empty_spec.\u03b9 := empty.subsingleton\n\n-- instance empty_spec_domain_unique (i : empty_spec.\u03b9) : unique (empty_spec.domain i) := punit.unique\n\n-- instance empty_spec_range_unique (i : empty_spec.\u03b9) : unique (empty_spec.range i) := punit.unique\n\nend empty_spec\n\ninstance inhabited : inhabited oracle_spec := \u27e8[]\u2092\u27e9\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 := \u03bb spec spec',\n  { \u03b9 := spec.\u03b9 \u2295 spec'.\u03b9,\n    domain := sum.elim spec.domain spec'.domain,\n    range := sum.elim spec.range spec'.range,\n    range_inhabited := \u03bb i, by induction i; simp; apply_instance,\n    \u03b9_decidable_eq := sum.decidable_eq spec.\u03b9 spec'.\u03b9,\n    domain_decidable_eq := \u03bb i, sum.rec_on i spec.domain_decidable_eq spec'.domain_decidable_eq,\n    range_decidable_eq := \u03bb i, sum.rec_on i spec.range_decidable_eq spec'.range_decidable_eq,\n    range_fintype := \u03bb 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.\u03b9) :\n  (spec ++ spec').domain (sum.inl i) = spec.domain i := rfl\n\n@[simp] lemma append.domain_inr (i : spec'.\u03b9) :\n  (spec ++ spec').domain (sum.inr i) = spec'.domain i := rfl\n\n@[simp] lemma append.range_inl (i : spec.\u03b9) :\n  (spec ++ spec').range (sum.inl i) = spec.range i := rfl\n\n@[simp] lemma append.range_inr (i : spec'.\u03b9) :\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 \u21a6\u2092 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 : \u2115`, 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{ \u03b9 := \u2115,\n  domain := \u03bb n, unit,\n  range := \u03bb n, fin (n + 1),\n  range_inhabited := \u03bb n, \u27e80\u27e9,\n  \u03b9_decidable_eq := nat.decidable_eq,\n  domain_decidable_eq := \u03bb _, punit.decidable_eq,\n  range_decidable_eq := \u03bb n, fin.decidable_eq (n + 1),\n  range_fintype := \u03bb n, fin.fintype (n + 1) }\n\n@[simp] lemma card_range_uniform_selecting (n : \u2115) :\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 \u2192 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\u2080 u\u2081 u\u2082 v\u2080 v\u2081 v\u2082\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 \u03b1 \u2192 f \u03b2` from\nan equivalence `\u03b1 \u2243 \u03b2`, 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\u2080 \u2192 Type u\u2081) :=\n(map : \u03a0 {\u03b1 \u03b2}, (\u03b1 \u2243 \u03b2) \u2192 (f \u03b1 \u2192 f \u03b2))\n(map_refl' : \u03a0 \u03b1, map (equiv.refl \u03b1) = @id (f \u03b1) . obviously)\n(map_trans' : \u03a0 {\u03b1 \u03b2 \u03b3} (k : \u03b1 \u2243 \u03b2) (h : \u03b2 \u2243 \u03b3),\n  map (k.trans h) = (map h) \u2218 (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\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 \u03b2 : Type u\u2080} (e : \u03b1 \u2243 \u03b2)\n\n/-- An `equiv_functor` in fact takes every equiv to an equiv. -/\ndef map_equiv :\n  f \u03b1 \u2243 f \u03b2 :=\n{ to_fun := equiv_functor.map e,\n  inv_fun := equiv_functor.map e.symm,\n  left_inv := \u03bb x, by { convert (congr_fun (equiv_functor.map_trans e e.symm) x).symm, simp, },\n  right_inv := \u03bb y, by { convert (congr_fun (equiv_functor.map_trans e.symm e) y).symm, simp, }, }\n\n@[simp] lemma map_equiv_apply (x : f \u03b1) :\n  map_equiv f e x = equiv_functor.map e x := rfl\n\nlemma map_equiv_symm_apply (y : f \u03b2) :\n  (map_equiv f e).symm y = equiv_functor.map e.symm y := rfl\n\n@[simp] lemma map_equiv_refl (\u03b1) :\n  map_equiv f (equiv.refl \u03b1) = equiv.refl (f \u03b1) :=\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 {\u03b3 : Type u\u2080} (ab : \u03b1 \u2243 \u03b2) (bc : \u03b2 \u2243 \u03b3) :\n  (map_equiv f ab).trans (map_equiv f bc) = map_equiv f (ab.trans bc) :=\nequiv.ext $ \u03bb x, by simp [map_equiv, map_trans']\n\nend\n\n@[priority 100]\ninstance of_is_lawful_functor\n  (f : Type u\u2080 \u2192 Type u\u2081) [functor f] [is_lawful_functor f] : equiv_functor f :=\n{ map := \u03bb \u03b1 \u03b2 e, functor.map e,\n  map_refl' := \u03bb \u03b1, by { ext, apply is_lawful_functor.id_map, },\n  map_trans' := \u03bb \u03b1 \u03b2 \u03b3 k h, by { ext x, apply (is_lawful_functor.comp_map k h x), } }\n\nlemma map_equiv.injective\n  (f : Type u\u2080 \u2192 Type u\u2081) [applicative f] [is_lawful_applicative f] {\u03b1 \u03b2 : Type u\u2080}\n  (h : \u2200 \u03b3, function.injective (pure : \u03b3 \u2192 f \u03b3)) :\n  function.injective (@equiv_functor.map_equiv f _ \u03b1 \u03b2) :=\n\u03bb e\u2081 e\u2082 H, equiv.ext $ \u03bb x, h \u03b2 (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 \u2192 Y) (g : Y \u2192 Z) : surjective (g \u2218 f) \u2192 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\u03bb h b, let \u27e8 a, h \u27e9 := h b in \u27e8 f a, h \u27e9\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 ` \u2243 `: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 : \u2115 \u2192 Type*\n| 0 := ring_consts\n| 1 := ring_unaries\n| 2 := ring_binaries\n| (n + 3) := pempty\n\ninstance : inhabited ring_consts := \u27e8 ring_consts.zero \u27e9\ninstance : inhabited ring_unaries := \u27e8 ring_unaries.neg \u27e9\ninstance : inhabited ring_binaries := \u27e8 ring_binaries.add \u27e9\n\nopen fol\n\n/-- The language of rings -/\ndef ring_signature : Language :=\n(Language.mk) (ring_funcs) (\u03bb n, pempty)\n\n@[reducible] def bounded_ring_formula (n : \u2115) := bounded_formula ring_signature n\n@[reducible] def bounded_ring_term (n : \u2115) := bounded_term ring_signature n\n@[reducible] def bounded_ring_term' (n : \u2115) := 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) := \u27e8 bd_func ring_consts.zero \u27e9\n@[reducible] instance bounded_ring_term_has_zero' {n} :\n  has_zero (bounded_ring_term' n) := \u27e8 bd_func ring_consts.zero \u27e9\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) := \u27e8 bd_func ring_consts.one \u27e9\n@[reducible] instance bounded_ring_term_has_one' {n} :\n  has_one (bounded_ring_term' n) := \u27e8 bd_func ring_consts.one \u27e9\n\n-- @[simp] def neg {n} : bounded_ring_term n \u2192 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\u27e8 bd_app (bd_func ring_unaries.neg) \u27e9\n@[reducible] instance bounded_ring_term_has_neg' {n} : has_neg (bounded_ring_term' n) :=\n\u27e8 bd_app (bd_func ring_unaries.neg) \u27e9\n\n-- @[simp] def add {n} (x : bounded_ring_term n) : bounded_ring_term n \u2192 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\u27e8 \u03bb x, bd_app (bd_app (bd_func ring_binaries.add) x) \u27e9\n@[reducible] instance bounded_ring_term_has_add' {n} : has_add (bounded_ring_term'  n) :=\n\u27e8 \u03bb x, bd_app (bd_app (bd_func ring_binaries.add) x) \u27e9\n\n-- @[simp] def mul {n} (x : bounded_ring_term n) : bounded_ring_term n \u2192 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\u27e8 \u03bb x, bd_app (bd_app (bd_func ring_binaries.mul) x) \u27e9\n@[reducible] instance bounded_ring_term_has_mul' {n} : has_mul (bounded_ring_term' n) :=\n\u27e8 \u03bb x, bd_app (bd_app (bd_func ring_binaries.mul) x) \u27e9\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 \u2208 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 \u2192 Sort*}\n  (cvar : \u03a0 (k : fin n), C (x_ k))\n  (c0 : C 0) (c1 : C 1)\n  (cneg : \u03a0 {t}, C t \u2192 C (- t))\n  (cadd : \u03a0 {s t}, C s \u2192 C t \u2192 C (s + t)) (cmul : \u03a0 {s t}, C s \u2192 C t \u2192 C (s * t)) :\n  \u03a0 {l : \u2115} (f : ring_signature.functions l) (ts : dvector (bounded_term ring_signature n) l),\n  (\u03a0 (t : bounded_ring_term n), dvector.pmem t ts \u2192 C t)\n  \u2192 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 : \u2115} {C : bounded_ring_term n \u2192 Sort*}\n  (cvar : \u03a0 (k : fin n), C (x_ k))\n  (c0 : C 0) (c1 : C 1)\n  (cneg : \u03a0 {t}, C t \u2192 C (- t))\n  (cadd : \u03a0 {s t}, C s \u2192 C t \u2192 C (s + t)) (cmul : \u03a0 {s t}, C s \u2192 C t \u2192 C (s * t))\n  : \u03a0 (t : bounded_ring_term n), C t :=\n@bounded_term.rec ring_signature n C\n(\u03bb k, cvar k)\n(\u03bb l, ring_func_rec cvar c0 c1 @cneg @cadd @cmul)\n\n-- def ring_term_ind {n : \u2115} {C : bounded_ring_term n \u2192 Prop}\n--   (cvar : \u03a0 (k : fin n), C (x_ k))\n--   (c0 : C 0) (c1 : C 1)\n--   (cneg : \u03a0 {t}, C t \u2192 C (- t))\n--   (cadd : \u03a0 {s t}, C s \u2192 C t \u2192 C (s + t)) (cmul : \u03a0 {s t}, C s \u2192 C t \u2192 C (s * t))\n--   : \u03a0 (t : bounded_ring_term n), C t :=\n-- @bounded_term.rec ring_signature n C\n-- (\u03bb k, cvar k)\n-- (\u03bb 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  \u2200' \u2200' \u2200' ( (x_ 0 + x_ 1) + x_ 2 \u2243 x_ 0 + (x_ 1 + x_ 2) )\n\n/-- Identity for addition -/\ndef add_id : sentence ring_signature := \u2200' ( x_ 0 + 0 \u2243 x_ 0 )\n-- def add_id : sentence ring_signature := \u2200' (   &'0 r+ r0 \u2243 &'0   \u2293   r0 r+ &'0 \u2243 &'0   )\n\n/-- Inverse for addition -/\ndef add_inv : sentence ring_signature := \u2200' ( - x_ 0 + x_ 0 \u2243 0 )\n-- def add_inv : sentence ring_signature := \u2200' (  &'0 r+ r- &'0 \u2243 r0  \u2293  r- &'0 r+ &'0 \u2243 r0  )\n\n/-- Commutativity of addition-/\ndef add_comm : sentence ring_signature := \u2200' \u2200' ( x_ 0 + x_ 1 \u2243 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\u2200' \u2200' \u2200' ( (x_ 0 * x_ 1) * x_ 2 \u2243 x_ 0 * (x_ 1 * x_ 2) )\n\n/-- Identity of multiplication -/\ndef mul_id : sentence ring_signature :=  \u2200' ( x_ 0 * 1 \u2243 x_ 0 )\n-- def mul_id : sentence ring_signature :=  \u2200' (   &'0 r\u00d7 r1 \u2243 &'0   )\n\n/-- Commutativity of multiplication -/\ndef mul_comm : sentence ring_signature := \u2200' \u2200' ( x_ 0 * x_ 1 \u2243 x_ 1 * x_ 0   )\n\n/-- Distributibity -/\ndef add_mul : sentence ring_signature := \u2200' \u2200' \u2200' ( (x_ 0 + x_ 1) * x_ 2 \u2243 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 \u2208 ring_theory :=\nbegin unfold ring_theory, left, refl end\n\nlemma add_id_in_ring_theory : add_id \u2208 ring_theory :=\nbegin unfold ring_theory, iterate 1 {right}, left, refl end\n\nlemma add_inv_in_ring_theory : add_inv \u2208 ring_theory :=\nbegin unfold ring_theory, iterate 2 {right}, left, refl end\n\nlemma add_comm_in_ring_theory : add_comm \u2208 ring_theory :=\nbegin unfold ring_theory, iterate 3 {right}, left, refl end\n\nlemma mul_assoc_in_ring_theory : mul_assoc \u2208 ring_theory :=\nbegin unfold ring_theory, iterate 4 {right}, left, refl end\n\nlemma mul_id_in_ring_theory : mul_id \u2208 ring_theory :=\nbegin unfold ring_theory, iterate 5 {right}, left, refl end\n\nlemma mul_comm_in_ring_theory : mul_comm \u2208 ring_theory :=\nbegin unfold ring_theory, iterate 6 {right}, left, refl end\n\nlemma add_mul_in_ring_theory : add_mul \u2208 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 \u2192 (dvector A 0) \u2192 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 \u2192 (dvector A 1) \u2192 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 \u2192 (dvector A 2) \u2192 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 : \u03a0 (n : \u2115), (ring_funcs n) \u2192 (dvector A n) \u2192 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 (\u03bb 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} : \u03a0 {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} : \u03a0 (n : \u2115),\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} : \u03a0 {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 \u2192 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) \u22a8 ring_signature.ring_theory :=\n  begin\n    intros \u03d5 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  \u27e8 struc_to_ring_struc.Structure A ,  realize_ring_theory A \u27e9\n\nend comm_ring_to_model\n\nnamespace mv_polynomial\n\n  variable {\u03c3 : Type}\n\n  open ring_signature\n\n  /-- Terms in the ring_signature are multivariable polynomials over \u2124 -/\n  noncomputable def term {n} :\n    bounded_ring_term n \u2192 mv_polynomial (fin n) \u2124 :=\n  @ring_term_rec n (\u03bb _, mv_polynomial (fin n) \u2124)\n    mv_polynomial.X 0 1\n    (\u03bb _ p, - p)\n    (\u03bb _ _ p q, p + q)\n    (\u03bb _ _ 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  \u03a0 (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 (\u03bb (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\u2080 \u22ef x\u2099 and values a\u2081 \u22ef a\u2099 : A and returns\n    a polynomial in A[X] such that x\u2080 \u21a6 X and otherwise x\u2099 \u21a6 a\u2099 -/\n  @[reducible] noncomputable def term_evaluated_at_coeffs {n} (as : dvector A n)\n    (t : bounded_ring_term n.succ) : polynomial A :=\n  let \u03c3 : fin n.succ \u2192 polynomial A :=\n  @fin.cases n (\u03bb _, polynomial A) polynomial.X (\u03bb i, polynomial.C (dvector.nth' as i)) in\n  mv_polynomial.eval \u03c3 (mv_polynomial.term t)\n\n  /-- Evaluating the polynomial term_evaluated_at_coeffs at a\u2080 : A produces the same\n    term in A as realising the term at a\u2080 a\u2081 \u22ef a\u2099 -/\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_ \u27e8 0 , nat.zero_lt_succ _ \u27e9) = 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_ \u27e8 k.1.succ , nat.succ_lt_succ k.2 \u27e9)\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 : \u2115} : \u03a0 {m : \u2115} {as : dvector A n},\n    polynomial.term_evaluated_at_coeffs as (npow_rec m x_ \u27e8 0 , nat.zero_lt_succ _ \u27e9)\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 : \u2115} {m : \u2115} {as : dvector A n} {k : fin n} :\n    polynomial.term_evaluated_at_coeffs as\n      (x_ \u27e8 k.1.succ , nat.succ_lt_succ k.2 \u27e9 *\n      npow_rec m x_ \u27e8 0 , nat.zero_lt_succ _ \u27e9)\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 : \u2115} {as : dvector A n} (hk : k < n) :\n    polynomial.term_evaluated_at_coeffs as\n      (x_ \u27e8 k.succ , nat.succ_lt_succ hk \u27e9 *\n      npow_rec m x_ \u27e8 0 , nat.zero_lt_succ _ \u27e9)\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_\u27e8k.succ, _\u27e9\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 : \u2115} :\n  \u03a0 {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  (\u03bb {t : bounded_ring_term (n + 1)}, \u03a0 {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 : \u21a5 M := @Structure.fun_map _ M 0 ring_consts.zero dvector.nil\n  def one : \u21a5 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 := \u27e8 zero \u27e9\n  instance : has_one M := \u27e8 one \u27e9\n  instance : has_neg M := \u27e8 neg \u27e9\n  instance : has_add M := \u27e8 add \u27e9\n  instance : has_mul M := \u27e8 mul \u27e9\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} : \u2200 {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  \u03a0 (n : \u2115),\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 \u22a8 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\u2115 : Type* := ulift \u2115\n\ndef nat_ring_consts :\n  ring_consts \u2192 dvector p\u2115 0 \u2192 p\u2115\n| ring_consts.zero as := up 0\n| ring_consts.one as := up 1\n\ndef nat_ring_structure_funcs :\n  \u03a0 {n}, ring_signature.functions n \u2192 dvector p\u2115 n \u2192 p\u2115\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\u27e8 p\u2115 , \u03bb _, nat_ring_structure_funcs , \u03bb _, pempty.elim \u27e9\n\nlemma nat_ring_structure_realize_nat :\n  \u03a0 (n : \u2115) {k : \u2115} (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 : \u2115} :\n  (n : fol.bounded_preterm ring_signature.{u} k 0) = m \u2192 n = m :=\nbegin\n  let v : dvector nat_ring_structure k := dvector.of_fn (\u03bb i, 0),\n  intro hnm,\n  rw [\u2190 down_up n, \u2190 down_up m, \u2190 nat_ring_structure_realize_nat n v,\n    \u2190 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    (\u03bb 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": "/-\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 Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.topology.algebra.polynomial\nimport Mathlib.analysis.special_functions.pow\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# The fundamental theorem of algebra\n\nThis file proves that every nonconstant complex polynomial has a root.\n-/\n\nnamespace complex\n\n\n/- The following proof uses the method given at\n  <https://ncatlab.org/nlab/show/fundamental+theorem+of+algebra#classical_fta_via_advanced_calculus> -/\n\n/-- The fundamental theorem of algebra. Every non constant complex polynomial\n  has a root -/\ntheorem exists_root {f : polynomial \u2102} (hf : 0 < polynomial.degree f) :\n    \u2203 (z : \u2102), polynomial.is_root f z :=\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/complex/polynomial_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8740772417253256, "lm_q2_score": 0.5583269943353744, "lm_q1q2_score": 0.48802091918945556}}
{"text": "\nnoncomputable \ndef Quot.repr {S : \u03b1 \u2192 \u03b1 \u2192 Prop} (a : Quot S) : \u03b1 := Classical.choose a.exists_rep\n\nnamespace SciLean\n\n  abbrev Rel (\u03b1 : Type u) := \u03b1 \u2192 \u03b1 \u2192 Prop\n\n  class IsQHom (S : Rel \u03b1) (R : Rel \u03b2) (f : \u03b1 \u2192 \u03b2) where\n    is_hom : \u2200 a a', S a a' \u2192 R (f a) (f a')\n\n  class IsQHom\u2082 (S : Rel \u03b1) (R : Rel \u03b2) (T : Rel \u03b3) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) where\n    is_hom : \u2200 a a' b b', S a a' \u2192 R b b' \u2192 T (f a b) (f a' b')\n\n  notation \"\u27e6\" x \"\u27e7\" => Quot.mk _ x\n  notation \"\u27e6\" x \", \" S \"\u27e7\" => Quot.mk S x\n\n  def IsQHom.sound {S : Rel \u03b1} {R : Rel \u03b2} (f : \u03b1 \u2192 \u03b2) [IsQHom S R f] \n    : \u2200 a a', S a a' \u2192 \u27e6f a\u27e7 = \u27e6f a', R\u27e7\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\u2082.sound {S : Rel \u03b1} {R : Rel \u03b2} {T : Rel \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) [IsQHom\u2082 S R T f] \n    : \u2200 a a' b b', S a a' \u2192 R b b' \u2192 \u27e6f a b\u27e7 = \u27e6f a' b', T\u27e7\n    :=\n  by\n    intros a a' b b' h h';\n    apply Quot.sound;\n    apply IsQHom\u2082.is_hom a a' b b' h h'\n    done\n\n  notation \"\u27e6\" f \"\u27e7\" => Quot.lift (\u03bb x => Quot.mk _ (f x)) (IsQHom.sound f)\n  notation \"\u27e6\" f \", \" S \", \" R\"\u27e7\" => Quot.lift (r := S) (\u03bb x => Quot.mk R (f x)) (IsQHom.sound f)\n\n  instance : Coe \u03b1 (Quot (Eq : \u03b1 \u2192 \u03b1 \u2192 Prop)) := \n  \u27e8 \u03bb a => Quot.mk _ a \u27e9\n\n  -- This one seem to be dangerous :(\n  -- instance : Coe (Quot (Eq : \u03b1 \u2192 \u03b1 \u2192 Prop)) \u03b1 := \n  -- \u27e8 \u03bb a => Quot.lift id (by intro a b h; apply h; done) a \u27e9\n\n  ---------------------\n\n  instance (f : \u03b1 \u2192 \u03b2) : IsQHom Eq Eq f := sorry\n\n  instance (S : Rel \u03b1) : IsQHom S S (\u03bb x => x) := sorry\n\n  instance (S : Rel \u03b1) (R : Rel \u03b2) (T : Rel \u03b3) \n    (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2)\n    [IsQHom R T f] [IsQHom S R g]\n    : IsQHom S T (f \u2218 g)\n    := sorry\n\n  ---------------------\n\n  @[simp]\n  theorem quot_comp\n    (S : Rel \u03b1) (R : Rel \u03b2) (T : Rel \u03b3) \n    (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) [IsQHom R T f] [IsQHom S R g]\n    :\n    \u27e6f, R, T\u27e7 \u2218 \u27e6g, S, R\u27e7 = \u27e6f \u2218 g, S, T\u27e7\n    := \n    sorry\n\n  @[simp]\n  theorem quot_apply {S : Rel \u03b1} {R : Rel \u03b2} (f : \u03b1 \u2192 \u03b2) [IsQHom S R f] (a : Quot S)\n    : \u27e6f a.repr, R\u27e7 = \u27e6f\u27e7 a\n    := sorry\n\n  ---------------------\n \n  variable {f : \u03b1 \u2192 \u03b2} {S : Rel \u03b1} {R : Rel \u03b2} {a : \u03b1} [IsQHom S R f]\n\n  #check Eq\n\n  #check \u27e6f, Eq, Eq\u27e7 \u27e6a, Eq\u27e7\n  #check \u27e6f, Eq, Eq\u27e7 \u27e6a\u27e7\n  #check \u27e6f, Eq, Eq\u27e7 a\n\n  #check \u27e6f, S, R\u27e7 \u27e6a, S\u27e7\n  #check \u27e6f, S, R\u27e7 \u27e6a\u27e7\n\n  #check \u27e6f, S, R\u27e7\n  #check (\u27e6f\u27e7 \u27e6a\u27e7 : Quot R)\n\n  -- \u27e6f\u27e7 \u2218 \u27e6g\u27e7 = \u27e6f \u2218 g\u27e7\n  -- \u27e6f x.repr\u27e7 = \u27e6f\u27e7 x\n  -- \u27e6f\u27e7 \u27e6x\u27e7 = \u27e6f x\u27e7\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 (\u03b1 : Type u) extends\n  decidable_linear_order \u03b1, has_zero \u03b1, has_add \u03b1, has_mul \u03b1 :=\n(omega : \u03b1)\n(succ : \u03b1 \u2192 \u03b1)\n(zero_le : \u2200 x : \u03b1, 0 \u2264 x)\n(zero_lt_omega : 0 < omega)\n(zero_or_succ_of_lt_omega : \u2200 x : \u03b1, x < omega \u2192 (x = 0 \u2228 \u2203 y, x = succ y))\n(succ_ne_zero : \u2200 x : \u03b1, succ x \u2260 0)\n(succ_ne_omega : \u2200 x : \u03b1, succ x \u2260 omega)\n(lt_succ : \u2200 x : \u03b1, x < succ x)\n(le_of_lt_succ : \u2200 {x y : \u03b1}, x < succ y \u2192 x \u2264 y)\n(add_zero : \u2200 x : \u03b1, x + 0 = x)\n(add_limit_le : \u2200 {x y z : \u03b1}, y \u2260 0 \u2192 (\u2200 w : \u03b1, w < y \u2192 x + w < z) \u2192 x + y \u2264 z)\n(add_limit_gt : \u2200 {x y z u : \u03b1}, u < y \u2192 x + u < z \u2192 x + y \u2264 z)\n(add_lt_add_left : \u2200 {x y : \u03b1}, x < y \u2192 \u2200 z, z + x < z + y)\n(mul_zero : \u2200 x : \u03b1, x * 0 = 0)\n(mul_succ : \u2200 x y : \u03b1, x * succ y = x * y + x)\n(mul_limit : \u2200 {x y z : \u03b1}, y \u2260 0 \u2192 (\u2200 w : \u03b1, w < y \u2192 x * y < z) \u2192 x * y \u2264 z)\n(transfinite_induction : \u2200 (x: \u03b1) (\u03c6 : \u03b1 \u2192 Prop), (\u2200 y : \u03b1, (\u2200 z : \u03b1, z < y \u2192 \u03c6 z) \u2192 \u03c6 y) \u2192 \u03c6 x)\n\nlemma lt_of_lt_of_lt {\u03b1 : Type u} [preorder \u03b1] :\n\u2200 {a b c : \u03b1}, a < b \u2192 b < c \u2192 a < c\n| a b c hab hbc := lt_of_lt_of_le hab $ le_of_lt hbc\n\nnamespace ordinal\n\nvariables {\u03b1 : Type u} [ordinal \u03b1] {x y z u : \u03b1}\n\ndef \u03c9 := omega \u03b1\n\ninstance : has_one \u03b1 := \u27e8succ 0\u27e9\n\ntheorem lt_succ_of_le : x \u2264 y \u2192 x < succ y\n| hxy := lt_of_le_of_lt hxy $ lt_succ y\n\ntheorem le_iff_lt_succ : x \u2264 y \u2194 x < succ y :=\n\u27e8lt_succ_of_le, le_of_lt_succ\u27e9\n\ntheorem lt_of_succ_le : succ y \u2264 x \u2192 y < x\n| hyx := lt_of_lt_of_le (lt_succ y) hyx\n\ntheorem succ_le_of_lt : y < x \u2192 succ y \u2264 x\n| hyx := le_of_not_gt $ \u03bb hxy, not_le_of_gt hyx $ le_of_lt_succ hxy\n\ntheorem lt_iff_succ_le : y < x \u2194 succ y \u2264 x :=\n\u27e8succ_le_of_lt, lt_of_succ_le\u27e9\n\ntheorem succ_lt : x < y \u2192 succ x < succ y\n| hxy := lt_succ_of_le $ succ_le_of_lt hxy\n\ntheorem succ_le : x \u2264 y \u2192 succ x \u2264 succ y\n| hxy := succ_le_of_lt $ lt_succ_of_le hxy\n\ntheorem lt_of_succ_lt : succ x < succ y \u2192 x < y\n| hxy := lt_of_succ_le $ le_of_lt_succ hxy\n\ntheorem le_of_succ_le : succ x \u2264 succ y \u2192 x \u2264 y\n| hxy := le_of_lt_succ $ lt_of_succ_le hxy\n\ntheorem succ_inj : succ x = succ y \u2192 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 : (\u2200 w, succ w \u2260 x) \u2192 y < x \u2192 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 \u2192 x + z \u2264 y + z :=\nbegin\n  intro hxy,\n  apply transfinite_induction z,\n  intros z' hz',\n  cases decidable_linear_order.decidable_eq \u03b1 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 \u03b1 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 \u2264 1 + x :=\n@transfinite_induction \u03b1 _ x (\u03bb x, x \u2264 1 + x) $ \u03bb y hy,\nle_of_not_gt $ \u03bb hy2, not_le_of_gt (add_lt_add_left hy2 1) (hy _ hy2)\n\ntheorem one_add_eq_succ_of_lt_omega : x < \u03c9 \u2192 1 + x = succ x :=\nbegin\n  apply transfinite_induction x (\u03bb x, x < \u03c9 \u2192 1 + x = succ x),\n  intros y hy,\n  intro hy\u03c9,\n  cases zero_or_succ_of_lt_omega _ hy\u03c9,\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 \u2190a_1,\n  exact hy\u03c9\nend\n\ntheorem one_add_omega : (1:\u03b1) + \u03c9 = \u03c9 :=\nbegin\n  apply le_antisymm,\n  apply add_limit_le,\n  apply ne_of_gt,\n  exact zero_lt_omega \u03b1,\n  intro w,\n  apply transfinite_induction w (\u03bb w, w < \u03c9 \u2192 1 + w < \u03c9),\n  intros y hy hy\u03c9,\n  cases zero_or_succ_of_lt_omega _ hy\u03c9,\n  rw [a,add_zero],\n  apply succ_lt_of_lt_of_limit succ_ne_omega,\n  apply zero_lt_omega \u03b1,\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 \u2190a_1, apply hy\u03c9,\n  apply lt_of_lt_of_lt,\n  apply lt_succ,\n  rw \u2190a_1,\n  exact hy\u03c9,\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 \u27f6 Y$$ and $$g : X \u27f6 Y$$ are morphisms such that $$f = g$$, then $$f \u226b h = g \u226b h$$.\n-/\nlemma id_of_comp_right_id' (X : C) (f : X \u27f6 X) (w : \u2200 {Y : C} (g : Y \u27f6 X), g \u226b f = g) : f = \ud835\udfd9 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 : \u211d\u22650\u221e) (h : p \u2264 1) : pmf bool :=\n\u27e8\u03bb b, cond b p (1 - p), by simp [summable.has_sum_iff, tsum_bool, add_comm, h]\u27e9\n\nexample (f : \u211d \u2192 \u211d) (h : \u2200 a, 0 \u2264 f a) (h' : summable (\u03bb (a : \u211d), f a)):\n\u2211' (a : \u211d), ennreal.of_real (f a) = ennreal.of_real \u2211' (a : \u211d), f a :=\nbegin\n  exact (ennreal.of_real_tsum_of_nonneg h h').symm,\nend\n\nexample {l : \u211d} : \u2211' (n : \u2115), l ^ n / \u2191(n.factorial) = real.exp l :=\nbegin\n  rw [real.exp_eq_exp_\u211d, exp_eq_tsum_div],\nend\n\ndef poisson (l : \u211d) (h : 0 < l) : pmf \u2115 :=\n\u27e8 \u03bb k, ennreal.of_real $ (real.exp $ -l) * ((l : \u211d) ^ k) / factorial k,\n  by { simp [summable.has_sum_iff],\n    rw \u2190 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_\u211d, \u2190 exp_add, neg_add_self, exp_zero, ennreal.of_real_one]],\n      congr,\n      suffices : \u2211' (n : \u2115), (\u03bb k, l ^ k / \u2191(factorial k)) n * real.exp (-l)\n                 = real.exp (-l) * real.exp l,\n      { rw \u2190 this, congr, funext, ring_nf, },\n      rw [mul_comm],\n      simp_rw [\u2190 smul_eq_mul],\n      rw [tsum_smul_const, real.exp_eq_exp_\u211d, exp_eq_tsum_div],\n      exact exp_series_div_summable \u211d 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 \u2190 cast_zero,\n      exact cast_le.2 (le_of_lt (factorial_pos n)), },\n    { have : summable (\u03bb (n : \u2115), real.exp (-l) \u2022 (\u03bb i, l ^ i / \u2191(factorial i)) n),\n      { apply summable.const_smul, simp [real.summable_pow_div_factorial l], },\n      simp at this,\n      simp_rw [\u2190 mul_div, this], }, }\u27e9\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 \u2964 presheaf.{v} C X)\n  (H : \u2200 j, (F.obj j).is_sheaf) {c : cone F} (hc : is_limit c) : c.X.is_sheaf :=\nbegin\n  let F' : J \u2964 sheaf C X := { obj := \u03bb j, \u27e8F.obj j, H j\u27e9, map := F.map },\n  let e : F' \u22d9 sheaf.forget C X \u2245 F := nat_iso.of_components (\u03bb _, 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 \u2964 presheaf.{v} C X)\n  (H : \u2200 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  {\u0393: env} {e: exp} (value: val e)\n  (et: has_typ \u0393 e typ.bool)\n  : e = exp.true \u2228 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  {\u0393: env} {e: exp} {\u03c41 \u03c42: typ} (value: val e)\n  (et: has_typ \u0393 e (typ.arrow \u03c41 \u03c42))\n  : \u2203 (x: var) (e': exp), e = exp.fn x \u03c41 e' :=\nbegin\n  cases value,\n  repeat {cases et},\n  existsi [value_x, value_e],\n  refl,\nend\n\ntheorem pair_canonical_forms\n  {\u0393: env} {e: exp} {\u03c41 \u03c42: typ} (value: val e)\n  (et: has_typ \u0393 e (typ.pair \u03c41 \u03c42))\n  : \u2203 (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  {\u0393: env} {e: exp} (value: val e)\n  (et: has_typ \u0393 e typ.never)\n  : false :=\nbegin\n  cases value,\n  repeat {cases et},\nend\n\ntheorem either_canonical_forms\n  {\u0393: env} {e: exp} {\u03c41 \u03c42: typ} (value: val e)\n  (et: has_typ \u0393 e (typ.either \u03c41 \u03c42))\n  : \u2203 (e': exp), (e = exp.either_left \u03c42 e') \u2228 (e = exp.either_right \u03c41 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 `::\u2098` for `multiset.cons`.\n-/\n\nopen list subtype nat\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n\n/-- `multiset \u03b1` is the quotient of `list \u03b1` by list permutation. The result\n  is a type of finite sets with duplicates allowed.  -/\ndef {u} multiset (\u03b1 : Type u) : Type u :=\nquotient (list.is_setoid \u03b1)\n\nnamespace multiset\n\ninstance : has_coe (list \u03b1) (multiset \u03b1) := \u27e8quot.mk _\u27e9\n\n@[simp] theorem quot_mk_to_coe (l : list \u03b1) : @eq (multiset \u03b1) \u27e6l\u27e7 l := rfl\n\n@[simp] theorem quot_mk_to_coe' (l : list \u03b1) : @eq (multiset \u03b1) (quot.mk (\u2248) l) l := rfl\n\n@[simp] theorem quot_mk_to_coe'' (l : list \u03b1) : @eq (multiset \u03b1) (quot.mk setoid.r l) l := rfl\n\n@[simp] theorem coe_eq_coe {l\u2081 l\u2082 : list \u03b1} : (l\u2081 : multiset \u03b1) = l\u2082 \u2194 l\u2081 ~ l\u2082 := quotient.eq\n\ninstance has_decidable_eq [decidable_eq \u03b1] : decidable_eq (multiset \u03b1)\n| s\u2081 s\u2082 := quotient.rec_on_subsingleton\u2082 s\u2081 s\u2082 $ \u03bb l\u2081 l\u2082,\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 \u03b1] (s : multiset \u03b1) : \u2115 :=\nquot.lift_on s sizeof $ \u03bb l\u2081 l\u2082, perm.sizeof_eq_sizeof\n\ninstance has_sizeof [has_sizeof \u03b1] : has_sizeof (multiset \u03b1) := \u27e8multiset.sizeof\u27e9\n\n/-! ### Empty multiset -/\n\n/-- `0 : multiset \u03b1` is the empty set -/\nprotected def zero : multiset \u03b1 := @nil \u03b1\n\ninstance : has_zero (multiset \u03b1)   := \u27e8multiset.zero\u27e9\ninstance : has_emptyc (multiset \u03b1) := \u27e80\u27e9\ninstance inhabited_multiset : inhabited (multiset \u03b1)  := \u27e80\u27e9\n\n@[simp] theorem coe_nil_eq_zero : (@nil \u03b1 : multiset \u03b1) = 0 := rfl\n@[simp] theorem empty_eq_zero : (\u2205 : multiset \u03b1) = 0 := rfl\n\ntheorem coe_eq_zero (l : list \u03b1) : (l : multiset \u03b1) = 0 \u2194 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 : \u03b1) (s : multiset \u03b1) : multiset \u03b1 :=\nquot.lift_on s (\u03bb l, (a :: l : multiset \u03b1))\n  (\u03bb l\u2081 l\u2082 p, quot.sound (p.cons a))\n\ninfixr ` ::\u2098 `:67  := multiset.cons\n\ninstance : has_insert \u03b1 (multiset \u03b1) := \u27e8cons\u27e9\n\n@[simp] theorem insert_eq_cons (a : \u03b1) (s : multiset \u03b1) :\n  insert a s = a ::\u2098 s := rfl\n\n@[simp] theorem cons_coe (a : \u03b1) (l : list \u03b1) :\n  (a ::\u2098 l : multiset \u03b1) = (a::l : list \u03b1) := rfl\n\ntheorem singleton_coe (a : \u03b1) : (a ::\u2098 0 : multiset \u03b1) = ([a] : list \u03b1) := rfl\n\n@[simp] theorem cons_inj_left {a b : \u03b1} (s : multiset \u03b1) :\n  a ::\u2098 s = b ::\u2098 s \u2194 a = b :=\n\u27e8quot.induction_on s $ \u03bb 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 _\u27e9\n\n@[simp] theorem cons_inj_right (a : \u03b1) : \u2200{s t : multiset \u03b1}, a ::\u2098 s = a ::\u2098 t \u2194 s = t :=\nby rintros \u27e8l\u2081\u27e9 \u27e8l\u2082\u27e9; simp\n\n@[recursor 5] protected theorem induction {p : multiset \u03b1 \u2192 Prop}\n  (h\u2081 : p 0) (h\u2082 : \u2200 \u2983a : \u03b1\u2984 {s : multiset \u03b1}, p s \u2192 p (a ::\u2098 s)) : \u2200s, p s :=\nby rintros \u27e8l\u27e9; induction l with _ _ ih; [exact h\u2081, exact h\u2082 ih]\n\n@[elab_as_eliminator] protected theorem induction_on {p : multiset \u03b1 \u2192 Prop}\n  (s : multiset \u03b1) (h\u2081 : p 0) (h\u2082 : \u2200 \u2983a : \u03b1\u2984 {s : multiset \u03b1}, p s \u2192 p (a ::\u2098 s)) : p s :=\nmultiset.induction h\u2081 h\u2082 s\n\ntheorem cons_swap (a b : \u03b1) (s : multiset \u03b1) : a ::\u2098 b ::\u2098 s = b ::\u2098 a ::\u2098 s :=\nquot.induction_on s $ \u03bb l, quotient.sound $ perm.swap _ _ _\n\nsection rec\nvariables {C : multiset \u03b1 \u2192 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 : \u03a0a m, C m \u2192 C (a ::\u2098 m))\n  (C_cons_heq : \u2200 a a' m b, C_cons a (a' ::\u2098 m) (C_cons a' m b) ==\n    C_cons a' (a ::\u2098 m) (C_cons a m b))\n  (m : multiset \u03b1) : C m :=\nquotient.hrec_on m (@list.rec \u03b1 (\u03bbl, C \u27e6l\u27e7) C_0 (\u03bba l b, C_cons a \u27e6l\u27e7 b)) $\n  assume l l' h,\n  h.rec_heq\n    (assume a l l' b b' hl, have \u27e6l\u27e7 = \u27e6l'\u27e7, from quot.sound hl, by cc)\n    (assume a a' l, C_cons_heq a a' \u27e6l\u27e7)\n\n/-- Companion to `multiset.rec` with more convenient argument order. -/\n@[elab_as_eliminator]\nprotected def rec_on (m : multiset \u03b1)\n  (C_0 : C 0)\n  (C_cons : \u03a0a m, C m \u2192 C (a ::\u2098 m))\n  (C_cons_heq : \u2200a a' m b, C_cons a (a' ::\u2098 m) (C_cons a' m b) ==\n      C_cons a' (a ::\u2098 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 : \u03a0a m, C m \u2192 C (a ::\u2098 m)}\n  {C_cons_heq : \u2200a a' m b, C_cons a (a' ::\u2098 m) (C_cons a' m b) ==\n    C_cons a' (a ::\u2098 m) (C_cons a m b)}\n\n@[simp] lemma rec_on_0 : @multiset.rec_on \u03b1 C (0:multiset \u03b1) C_0 C_cons C_cons_heq = C_0 :=\nrfl\n\n@[simp] lemma rec_on_cons (a : \u03b1) (m : multiset \u03b1) :\n  (a ::\u2098 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 \u2208 s` means that `a` has nonzero multiplicity in `s`. -/\ndef mem (a : \u03b1) (s : multiset \u03b1) : Prop :=\nquot.lift_on s (\u03bb l, a \u2208 l) (\u03bb l\u2081 l\u2082 (e : l\u2081 ~ l\u2082), propext $ e.mem_iff)\n\ninstance : has_mem \u03b1 (multiset \u03b1) := \u27e8mem\u27e9\n\n@[simp] lemma mem_coe {a : \u03b1} {l : list \u03b1} : a \u2208 (l : multiset \u03b1) \u2194 a \u2208 l := iff.rfl\n\ninstance decidable_mem [decidable_eq \u03b1] (a : \u03b1) (s : multiset \u03b1) : decidable (a \u2208 s) :=\nquot.rec_on_subsingleton s $ list.decidable_mem a\n\n@[simp] theorem mem_cons {a b : \u03b1} {s : multiset \u03b1} : a \u2208 b ::\u2098 s \u2194 a = b \u2228 a \u2208 s :=\nquot.induction_on s $ \u03bb l, iff.rfl\n\nlemma mem_cons_of_mem {a b : \u03b1} {s : multiset \u03b1} (h : a \u2208 s) : a \u2208 b ::\u2098 s :=\nmem_cons.2 $ or.inr h\n\n@[simp] theorem mem_cons_self (a : \u03b1) (s : multiset \u03b1) : a \u2208 a ::\u2098 s :=\nmem_cons.2 (or.inl rfl)\n\ntheorem forall_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {s : multiset \u03b1} :\n  (\u2200 x \u2208 (a ::\u2098 s), p x) \u2194 p a \u2227 \u2200 x \u2208 s, p x :=\nquotient.induction_on' s $ \u03bb L, list.forall_mem_cons\n\ntheorem exists_cons_of_mem {s : multiset \u03b1} {a : \u03b1} : a \u2208 s \u2192 \u2203 t, s = a ::\u2098 t :=\nquot.induction_on s $ \u03bb l (h : a \u2208 l),\nlet \u27e8l\u2081, l\u2082, e\u27e9 := mem_split h in\ne.symm \u25b8 \u27e8(l\u2081++l\u2082 : list \u03b1), quot.sound perm_middle\u27e9\n\n@[simp] theorem not_mem_zero (a : \u03b1) : a \u2209 (0 : multiset \u03b1) := id\n\ntheorem eq_zero_of_forall_not_mem {s : multiset \u03b1} : (\u2200x, x \u2209 s) \u2192 s = 0 :=\nquot.induction_on s $ \u03bb l H, by rw eq_nil_iff_forall_not_mem.mpr H; refl\n\ntheorem eq_zero_iff_forall_not_mem {s : multiset \u03b1} : s = 0 \u2194 \u2200 a, a \u2209 s :=\n\u27e8\u03bb h, h.symm \u25b8 \u03bb _, not_false, eq_zero_of_forall_not_mem\u27e9\n\ntheorem exists_mem_of_ne_zero {s : multiset \u03b1} : s \u2260 0 \u2192 \u2203 a : \u03b1, a \u2208 s :=\nquot.induction_on s $ assume l hl,\n  match l, hl with\n  | [] := assume h, false.elim $ h rfl\n  | (a :: l) := assume _, \u27e8a, by simp\u27e9\n  end\n\n@[simp] lemma zero_ne_cons {a : \u03b1} {m : multiset \u03b1} : 0 \u2260 a ::\u2098 m :=\nassume h, have a \u2208 (0:multiset \u03b1), from h.symm \u25b8 mem_cons_self _ _, not_mem_zero _ this\n\n@[simp] lemma cons_ne_zero {a : \u03b1} {m : multiset \u03b1} : a ::\u2098 m \u2260 0 := zero_ne_cons.symm\n\nlemma cons_eq_cons {a b : \u03b1} {as bs : multiset \u03b1} :\n  a ::\u2098 as = b ::\u2098 bs \u2194 ((a = b \u2227 as = bs) \u2228 (a \u2260 b \u2227 \u2203cs, as = b ::\u2098 cs \u2227 bs = a ::\u2098 cs)) :=\nbegin\n  haveI : decidable_eq \u03b1 := classical.dec_eq \u03b1,\n  split,\n  { assume eq,\n    by_cases a = b,\n    { subst h, simp * at * },\n    { have : a \u2208 b ::\u2098 bs, from eq \u25b8 mem_cons_self _ _,\n      have : a \u2208 bs, by simpa [h],\n      rcases exists_cons_of_mem this with \u27e8cs, hcs\u27e9,\n      simp [h, hcs],\n      have : a ::\u2098 as = b ::\u2098 a ::\u2098 cs, by simp [eq, hcs],\n      have : a ::\u2098 as = a ::\u2098 b ::\u2098 cs, by rwa [cons_swap],\n      simpa using this } },\n  { assume h,\n    rcases h with \u27e8eq\u2081, eq\u2082\u27e9 | \u27e8h, cs, eq\u2081, eq\u2082\u27e9,\n    { simp * },\n    { simp [*, cons_swap a b] } }\nend\n\nend mem\n\n/-! ### `multiset.subset` -/\nsection subset\n\n/-- `s \u2286 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 \u2264 t` for this relation. -/\nprotected def subset (s t : multiset \u03b1) : Prop := \u2200 \u2983a : \u03b1\u2984, a \u2208 s \u2192 a \u2208 t\n\ninstance : has_subset (multiset \u03b1) := \u27e8multiset.subset\u27e9\n\n@[simp] theorem coe_subset {l\u2081 l\u2082 : list \u03b1} : (l\u2081 : multiset \u03b1) \u2286 l\u2082 \u2194 l\u2081 \u2286 l\u2082 := iff.rfl\n\n@[simp] theorem subset.refl (s : multiset \u03b1) : s \u2286 s := \u03bb a h, h\n\ntheorem subset.trans {s t u : multiset \u03b1} : s \u2286 t \u2192 t \u2286 u \u2192 s \u2286 u :=\n\u03bb h\u2081 h\u2082 a m, h\u2082 (h\u2081 m)\n\ntheorem subset_iff {s t : multiset \u03b1} : s \u2286 t \u2194 (\u2200\u2983x\u2984, x \u2208 s \u2192 x \u2208 t) := iff.rfl\n\ntheorem mem_of_subset {s t : multiset \u03b1} {a : \u03b1} (h : s \u2286 t) : a \u2208 s \u2192 a \u2208 t := @h _\n\n@[simp] theorem zero_subset (s : multiset \u03b1) : 0 \u2286 s :=\n\u03bb a, (not_mem_nil a).elim\n\n@[simp] theorem cons_subset {a : \u03b1} {s t : multiset \u03b1} : (a ::\u2098 s) \u2286 t \u2194 a \u2208 t \u2227 s \u2286 t :=\nby simp [subset_iff, or_imp_distrib, forall_and_distrib]\n\ntheorem eq_zero_of_subset_zero {s : multiset \u03b1} (h : s \u2286 0) : s = 0 :=\neq_zero_of_forall_not_mem h\n\ntheorem subset_zero {s : multiset \u03b1} : s \u2286 0 \u2194 s = 0 :=\n\u27e8eq_zero_of_subset_zero, \u03bb xeq, xeq.symm \u25b8 subset.refl 0\u27e9\n\nlemma induction_on' {p : multiset \u03b1 \u2192 Prop} (S : multiset \u03b1)\n  (h\u2081 : p \u2205) (h\u2082 : \u2200 {a s}, a \u2208 S \u2192 s \u2286 S \u2192 p s \u2192 p (insert a s)) : p S :=\n@multiset.induction_on \u03b1 (\u03bb T, T \u2286 S \u2192 p T) S (\u03bb _, h\u2081) (\u03bb a s hps hs,\n  let \u27e8hS, sS\u27e9 := cons_subset.1 hs in h\u2082 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 {\u03b1 : Type*} (s : multiset \u03b1) :=\nclassical.some (quotient.exists_rep s)\n\n@[simp] lemma to_list_zero {\u03b1 : Type*} : (multiset.to_list 0 : list \u03b1) = [] :=\n(multiset.coe_eq_zero _).1 (classical.some_spec (quotient.exists_rep multiset.zero))\n\n@[simp, norm_cast]\nlemma coe_to_list {\u03b1 : Type*} (s : multiset \u03b1) : (s.to_list : multiset \u03b1) = s :=\nclassical.some_spec (quotient.exists_rep _)\n\n@[simp]\nlemma mem_to_list {\u03b1 : Type*} (a : \u03b1) (s : multiset \u03b1) : a \u2208 s.to_list \u2194 a \u2208 s :=\nby rw [\u2190multiset.mem_coe, multiset.coe_to_list]\n\nend to_list\n\n/-! ### Partial order on `multiset`s -/\n\n/-- `s \u2264 t` means that `s` is a sublist of `t` (up to permutation).\n  Equivalently, `s \u2264 t` means that `count a s \u2264 count a t` for all `a`. -/\nprotected def le (s t : multiset \u03b1) : Prop :=\nquotient.lift_on\u2082 s t (<+~) $ \u03bb v\u2081 v\u2082 w\u2081 w\u2082 p\u2081 p\u2082,\n  propext (p\u2082.subperm_left.trans p\u2081.subperm_right)\n\ninstance : partial_order (multiset \u03b1) :=\n{ le          := multiset.le,\n  le_refl     := by rintros \u27e8l\u27e9; exact subperm.refl _,\n  le_trans    := by rintros \u27e8l\u2081\u27e9 \u27e8l\u2082\u27e9 \u27e8l\u2083\u27e9; exact @subperm.trans _ _ _ _,\n  le_antisymm := by rintros \u27e8l\u2081\u27e9 \u27e8l\u2082\u27e9 h\u2081 h\u2082; exact quot.sound (subperm.antisymm h\u2081 h\u2082) }\n\ntheorem subset_of_le {s t : multiset \u03b1} : s \u2264 t \u2192 s \u2286 t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, subperm.subset\n\ntheorem mem_of_le {s t : multiset \u03b1} {a : \u03b1} (h : s \u2264 t) : a \u2208 s \u2192 a \u2208 t :=\nmem_of_subset (subset_of_le h)\n\n@[simp] theorem coe_le {l\u2081 l\u2082 : list \u03b1} : (l\u2081 : multiset \u03b1) \u2264 l\u2082 \u2194 l\u2081 <+~ l\u2082 := iff.rfl\n\n@[elab_as_eliminator] theorem le_induction_on {C : multiset \u03b1 \u2192 multiset \u03b1 \u2192 Prop}\n  {s t : multiset \u03b1} (h : s \u2264 t)\n  (H : \u2200 {l\u2081 l\u2082 : list \u03b1}, l\u2081 <+ l\u2082 \u2192 C l\u2081 l\u2082) : C s t :=\nquotient.induction_on\u2082 s t (\u03bb l\u2081 l\u2082 \u27e8l, p, s\u27e9,\n  (show \u27e6l\u27e7 = \u27e6l\u2081\u27e7, from quot.sound p) \u25b8 H s) h\n\ntheorem zero_le (s : multiset \u03b1) : 0 \u2264 s :=\nquot.induction_on s $ \u03bb l, (nil_sublist l).subperm\n\ntheorem le_zero {s : multiset \u03b1} : s \u2264 0 \u2194 s = 0 :=\n\u27e8\u03bb h, le_antisymm h (zero_le _), le_of_eq\u27e9\n\ntheorem lt_cons_self (s : multiset \u03b1) (a : \u03b1) : s < a ::\u2098 s :=\nquot.induction_on s $ \u03bb l,\nsuffices l <+~ a :: l \u2227 (\u00acl ~ a :: l),\n  by simpa [lt_iff_le_and_ne],\n\u27e8(sublist_cons _ _).subperm,\n \u03bb p, ne_of_lt (lt_succ_self (length l)) p.length_eq\u27e9\n\ntheorem le_cons_self (s : multiset \u03b1) (a : \u03b1) : s \u2264 a ::\u2098 s :=\nle_of_lt $ lt_cons_self _ _\n\ntheorem cons_le_cons_iff (a : \u03b1) {s t : multiset \u03b1} : a ::\u2098 s \u2264 a ::\u2098 t \u2194 s \u2264 t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, subperm_cons a\n\ntheorem cons_le_cons (a : \u03b1) {s t : multiset \u03b1} : s \u2264 t \u2192 a ::\u2098 s \u2264 a ::\u2098 t :=\n(cons_le_cons_iff a).2\n\ntheorem le_cons_of_not_mem {a : \u03b1} {s t : multiset \u03b1} (m : a \u2209 s) : s \u2264 a ::\u2098 t \u2194 s \u2264 t :=\nbegin\n  refine \u27e8_, \u03bb h, le_trans h $ le_cons_self _ _\u27e9,\n  suffices : \u2200 {t'} (_ : s \u2264 t') (_ : a \u2208 t'), a ::\u2098 s \u2264 t',\n  { exact \u03bb 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\u2081 m\u2082,\n  rcases mem_split m\u2082 with \u27e8r\u2081, r\u2082, rfl\u27e9,\n  exact perm_middle.subperm_left.2 ((subperm_cons _).2 $\n    ((sublist_or_mem_of_sublist s).resolve_right m\u2081).subperm)\nend\n\n/-! ### Singleton -/\ninstance : has_singleton \u03b1 (multiset \u03b1) := \u27e8\u03bb a, a ::\u2098 0\u27e9\n\ninstance : is_lawful_singleton \u03b1 (multiset \u03b1) := \u27e8\u03bb a, rfl\u27e9\n\ntheorem singleton_eq_cons (a : \u03b1) : singleton a = a ::\u2098 0 := rfl\n\n@[simp] theorem mem_singleton {a b : \u03b1} : b \u2208 ({a} : multiset \u03b1) \u2194 b = a :=\nby simp only [singleton_eq_cons, mem_cons, iff_self, or_false, not_mem_zero]\n\ntheorem mem_singleton_self (a : \u03b1) : a \u2208 ({a} : multiset \u03b1) :=\nby { rw singleton_eq_cons, exact mem_cons_self _ _ }\n\ntheorem singleton_inj {a b : \u03b1} : ({a} : multiset \u03b1) = {b} \u2194 a = b :=\nby { simp_rw [singleton_eq_cons], exact cons_inj_left _ }\n\n@[simp] theorem singleton_ne_zero (a : \u03b1) : ({a} : multiset \u03b1) \u2260 0 :=\nne_of_gt (lt_cons_self _ _)\n\n@[simp] theorem singleton_le {a : \u03b1} {s : multiset \u03b1} : {a} \u2264 s \u2194 a \u2208 s :=\n\u27e8\u03bb h, mem_of_le h (mem_singleton_self _),\n \u03bb h, let \u27e8t, e\u27e9 := exists_cons_of_mem h in e.symm \u25b8 cons_le_cons _ (zero_le _)\u27e9\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\u2081 s\u2082 : multiset \u03b1) : multiset \u03b1 :=\nquotient.lift_on\u2082 s\u2081 s\u2082 (\u03bb l\u2081 l\u2082, ((l\u2081 ++ l\u2082 : list \u03b1) : multiset \u03b1)) $\n  \u03bb v\u2081 v\u2082 w\u2081 w\u2082 p\u2081 p\u2082, quot.sound $ p\u2081.append p\u2082\n\ninstance : has_add (multiset \u03b1) := \u27e8multiset.add\u27e9\n\n@[simp] theorem coe_add (s t : list \u03b1) : (s + t : multiset \u03b1) = (s ++ t : list \u03b1) := rfl\n\nprotected theorem add_comm (s t : multiset \u03b1) : s + t = t + s :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, quot.sound perm_append_comm\n\nprotected theorem zero_add (s : multiset \u03b1) : 0 + s = s :=\nquot.induction_on s $ \u03bb l, rfl\n\ntheorem singleton_add (a : \u03b1) (s : multiset \u03b1) : {a} + s = a ::\u2098 s := rfl\n\nprotected theorem add_le_add_left (s) {t u : multiset \u03b1} : s + t \u2264 s + u \u2194 t \u2264 u :=\nquotient.induction_on\u2083 s t u $ \u03bb l\u2081 l\u2082 l\u2083, subperm_append_left _\n\nprotected theorem add_left_cancel (s) {t u : multiset \u03b1} (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 \u03b1) :=\n{ zero                  := 0,\n  add                   := (+),\n  add_comm              := multiset.add_comm,\n  add_assoc             := \u03bb s\u2081 s\u2082 s\u2083, quotient.induction_on\u2083 s\u2081 s\u2082 s\u2083 $ \u03bb l\u2081 l\u2082 l\u2083,\n    congr_arg coe $ append_assoc l\u2081 l\u2082 l\u2083,\n  zero_add              := multiset.zero_add,\n  add_zero              := \u03bb s, by rw [multiset.add_comm, multiset.zero_add],\n  add_left_cancel       := multiset.add_left_cancel,\n  add_le_add_left       := \u03bb s\u2081 s\u2082 h s\u2083, (multiset.add_le_add_left _).2 h,\n  le_of_add_le_add_left := \u03bb s\u2081 s\u2082 s\u2083, (multiset.add_le_add_left _).1,\n  ..@multiset.partial_order \u03b1 }\n\ntheorem le_add_right (s t : multiset \u03b1) : s \u2264 s + t :=\nby simpa using add_le_add_left (zero_le t) s\n\ntheorem le_add_left (s t : multiset \u03b1) : s \u2264 t + s :=\nby simpa using add_le_add_right (zero_le t) s\ntheorem le_iff_exists_add {s t : multiset \u03b1} : s \u2264 t \u2194 \u2203 u, t = s + u :=\n\u27e8\u03bb h, le_induction_on h $ \u03bb l\u2081 l\u2082 s,\n  let \u27e8l, p\u27e9 := s.exists_perm_append in \u27e8l, quot.sound p\u27e9,\n \u03bb \u27e8u, e\u27e9, e.symm \u25b8 le_add_right _ _\u27e9\n\ninstance : order_bot (multiset \u03b1) :=\n{ bot                   := 0,\n  bot_le                := multiset.zero_le }\n\ninstance : canonically_ordered_add_monoid (multiset \u03b1) :=\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 : \u03b1) (s t : multiset \u03b1) : a ::\u2098 s + t = a ::\u2098 (s + t) :=\nby rw [\u2190 singleton_add, \u2190 singleton_add, add_assoc]\n\n@[simp] theorem add_cons (a : \u03b1) (s t : multiset \u03b1) : s + a ::\u2098 t = a ::\u2098 (s + t) :=\nby rw [add_comm, cons_add, add_comm]\n\n@[simp] theorem mem_add {a : \u03b1} {s t : multiset \u03b1} : a \u2208 s + t \u2194 a \u2208 s \u2228 a \u2208 t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, mem_append\n\nlemma mem_of_mem_nsmul {a : \u03b1} {s : multiset \u03b1} {n : \u2115} (h : a \u2208 n \u2022 s) : a \u2208 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 : \u03b1} {s : multiset \u03b1} {n : \u2115} (h0 : n \u2260 0) : a \u2208 n \u2022 s \u2194 a \u2208 s :=\nbegin\n  refine \u27e8mem_of_mem_nsmul, \u03bb h, _\u27e9,\n  obtain \u27e8n, rfl\u27e9 := 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 \u03b1} (n : \u2115) (a : \u03b1) : n \u2022 (a ::\u2098 s) = n \u2022 {a} + n \u2022 s :=\nby rw [\u2190singleton_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 \u03b1 \u2192+ \u2115 :=\n{ to_fun := \u03bb s, quot.lift_on s length $ \u03bb l\u2081 l\u2082, perm.length_eq,\n  map_zero' := rfl,\n  map_add' := \u03bb s t, quotient.induction_on\u2082 s t length_append }\n\n@[simp] theorem coe_card (l : list \u03b1) : card (l : multiset \u03b1) = length l := rfl\n\n@[simp] theorem card_zero : @card \u03b1 0 = 0 := rfl\n\ntheorem card_add (s t : multiset \u03b1) : card (s + t) = card s + card t :=\ncard.map_add s t\n\nlemma card_nsmul (s : multiset \u03b1) (n : \u2115) :\n  (n \u2022 s).card = n * s.card :=\nby rw [card.map_nsmul s n, nat.nsmul_eq_mul]\n\n@[simp] theorem card_cons (a : \u03b1) (s : multiset \u03b1) : card (a ::\u2098 s) = card s + 1 :=\nquot.induction_on s $ \u03bb l, rfl\n\n@[simp] theorem card_singleton (a : \u03b1) : card ({a} : multiset \u03b1) = 1 :=\nby simp only [singleton_eq_cons, card_zero, eq_self_iff_true, zero_add, card_cons]\n\ntheorem card_eq_one {s : multiset \u03b1} : card s = 1 \u2194 \u2203 a, s = {a} :=\n\u27e8quot.induction_on s $ \u03bb l h,\n  (list.length_eq_one.1 h).imp $ \u03bb a, congr_arg coe,\n \u03bb \u27e8a, e\u27e9, e.symm \u25b8 rfl\u27e9\n\ntheorem card_le_of_le {s t : multiset \u03b1} (h : s \u2264 t) : card s \u2264 card t :=\nle_induction_on h $ \u03bb l\u2081 l\u2082, length_le_of_sublist\n\ntheorem eq_of_le_of_card_le {s t : multiset \u03b1} (h : s \u2264 t) : card t \u2264 card s \u2192 s = t :=\nle_induction_on h $ \u03bb l\u2081 l\u2082 s h\u2082, congr_arg coe $ eq_of_sublist_of_length_le s h\u2082\n\ntheorem card_lt_of_lt {s t : multiset \u03b1} (h : s < t) : card s < card t :=\nlt_of_not_ge $ \u03bb h\u2082, ne_of_lt h $ eq_of_le_of_card_le (le_of_lt h) h\u2082\n\ntheorem lt_iff_cons_le {s t : multiset \u03b1} : s < t \u2194 \u2203 a, a ::\u2098 s \u2264 t :=\n\u27e8quotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082 h,\n  subperm.exists_of_length_lt (le_of_lt h) (card_lt_of_lt h),\n\u03bb \u27e8a, h\u27e9, lt_of_lt_of_le (lt_cons_self _ _) h\u27e9\n\n@[simp] theorem card_eq_zero {s : multiset \u03b1} : card s = 0 \u2194 s = 0 :=\n\u27e8\u03bb h, (eq_of_le_of_card_le (zero_le _) (le_of_eq h)).symm, \u03bb e, by simp [e]\u27e9\n\ntheorem card_pos {s : multiset \u03b1} : 0 < card s \u2194 s \u2260 0 :=\npos_iff_ne_zero.trans $ not_congr card_eq_zero\n\ntheorem card_pos_iff_exists_mem {s : multiset \u03b1} : 0 < card s \u2194 \u2203 a, a \u2208 s :=\nquot.induction_on s $ \u03bb l, length_pos_iff_exists_mem\n\nlemma card_eq_two {s : multiset \u03b1} : s.card = 2 \u2194 \u2203 x y, s = {x, y} :=\n\u27e8quot.induction_on s (\u03bb l h, (list.length_eq_two.mp h).imp\n  (\u03bb a, Exists.imp (\u03bb b, congr_arg coe))), \u03bb \u27e8a, b, e\u27e9, e.symm \u25b8 rfl\u27e9\n\nlemma card_eq_three {s : multiset \u03b1} : s.card = 3 \u2194 \u2203 x y z, s = {x, y, z} :=\n\u27e8quot.induction_on s (\u03bb l h, (list.length_eq_three.mp h).imp\n  (\u03bb a, Exists.imp (\u03bb b, Exists.imp (\u03bb c, congr_arg coe)))), \u03bb \u27e8a, b, c, e\u27e9, e.symm \u25b8 rfl\u27e9\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 \u03b1 \u2192 Sort*} :\n  \u2200 (s : multiset \u03b1), (\u2200 s, (\u2200t < s, p t) \u2192 p s) \u2192 p s\n| s := \u03bb ih, ih s $ \u03bb 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 := \u03bb _ _, `[exact \u27e8_, measure_wf card\u27e9]}\n\ntheorem strong_induction_eq {p : multiset \u03b1 \u2192 Sort*}\n  (s : multiset \u03b1) (H) : @strong_induction_on _ p s H =\n    H s (\u03bb t h, @strong_induction_on _ p t H) :=\nby rw [strong_induction_on]\n@[elab_as_eliminator] lemma case_strong_induction_on {p : multiset \u03b1 \u2192 Prop}\n  (s : multiset \u03b1) (h\u2080 : p 0) (h\u2081 : \u2200 a s, (\u2200t \u2264 s, p t) \u2192 p (a ::\u2098 s)) : p s :=\nmultiset.strong_induction_on s $ assume s,\nmultiset.induction_on s (\u03bb _, h\u2080) $ \u03bb a s _ ih, h\u2081 _ _ $\n\u03bb 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 \u03b1 \u2192 Sort*} {n : \u2115} (H : \u2200 t\u2081, (\u2200 {t\u2082 : multiset \u03b1},\n  t\u2082.card \u2264 n \u2192 t\u2081 < t\u2082 \u2192 p t\u2082) \u2192 t\u2081.card \u2264 n \u2192 p t\u2081) :\n  \u2200 (s : multiset \u03b1), s.card \u2264 n \u2192 p s\n| s := H s (\u03bb 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 := \u03bb _ _, `[exact \u27e8_, measure_wf (\u03bb (t : multiset \u03b1), n - t.card)\u27e9]}\n\nlemma strong_downward_induction_eq {p : multiset \u03b1 \u2192 Sort*} {n : \u2115} (H : \u2200 t\u2081, (\u2200 {t\u2082 : multiset \u03b1},\n  t\u2082.card \u2264 n \u2192 t\u2081 < t\u2082 \u2192 p t\u2082) \u2192 t\u2081.card \u2264 n \u2192 p t\u2081) (s : multiset \u03b1) :\n  strong_downward_induction H s = H s (\u03bb 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 \u03b1 \u2192 Sort*} {n : \u2115} :\n  \u2200 (s : multiset \u03b1), (\u2200 t\u2081, (\u2200 {t\u2082 : multiset \u03b1}, t\u2082.card \u2264 n \u2192 t\u2081 < t\u2082 \u2192 p t\u2082) \u2192 t\u2081.card \u2264 n \u2192\n  p t\u2081) \u2192 s.card \u2264 n \u2192 p s :=\n\u03bb s H, strong_downward_induction H s\n\nlemma strong_downward_induction_on_eq {p : multiset \u03b1 \u2192 Sort*} (s : multiset \u03b1) {n : \u2115} (H : \u2200 t\u2081,\n  (\u2200 {t\u2082 : multiset \u03b1}, t\u2082.card \u2264 n \u2192 t\u2081 < t\u2082 \u2192 p t\u2082) \u2192 t\u2081.card \u2264 n \u2192 p t\u2081) :\n  s.strong_downward_induction_on H = H s (\u03bb 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 \u03b1 \u2192 multiset \u03b1 \u2192 Prop) :=\nsubrelation.wf (\u03bb _ _, 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 : \u03b1) (n : \u2115) : multiset \u03b1 := repeat a n\n\n@[simp] lemma repeat_zero (a : \u03b1) : repeat a 0 = 0 := rfl\n\n@[simp] lemma repeat_succ (a : \u03b1) (n) : repeat a (n+1) = a ::\u2098 repeat a n := by simp [repeat]\n\n@[simp] lemma repeat_one (a : \u03b1) : 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 : \u2200 (a : \u03b1) n, card (repeat a n) = n := length_repeat\n\ntheorem eq_of_mem_repeat {a b : \u03b1} {n} : b \u2208 repeat a n \u2192 b = a := eq_of_mem_repeat\n\ntheorem eq_repeat' {a : \u03b1} {s : multiset \u03b1} : s = repeat a s.card \u2194 \u2200 b \u2208 s, b = a :=\nquot.induction_on s $ \u03bb l, iff.trans \u27e8\u03bb h,\n  (perm_repeat.1 $ (quotient.exact h)), congr_arg coe\u27e9 eq_repeat'\n\ntheorem eq_repeat_of_mem {a : \u03b1} {s : multiset \u03b1} : (\u2200 b \u2208 s, b = a) \u2192 s = repeat a s.card :=\neq_repeat'.2\n\ntheorem eq_repeat {a : \u03b1} {n} {s : multiset \u03b1} : s = repeat a n \u2194 card s = n \u2227 \u2200 b \u2208 s, b = a :=\n\u27e8\u03bb h, h.symm \u25b8 \u27e8card_repeat _ _, \u03bb b, eq_of_mem_repeat\u27e9,\n \u03bb \u27e8e, al\u27e9, e \u25b8 eq_repeat_of_mem al\u27e9\n\ntheorem repeat_injective (a : \u03b1) : function.injective (repeat a) :=\n\u03bb m n h, by rw [\u2190 (eq_repeat.1 h).1, card_repeat]\n\ntheorem repeat_subset_singleton : \u2200 (a : \u03b1) n, repeat a n \u2286 {a} := repeat_subset_singleton\n\ntheorem repeat_le_coe {a : \u03b1} {n} {l : list \u03b1} : repeat a n \u2264 l \u2194 list.repeat a n <+ l :=\n\u27e8\u03bb \u27e8l', p, s\u27e9, (perm_repeat.1 p) \u25b8 s, sublist.subperm\u27e9\n\ntheorem nsmul_singleton (a : \u03b1) (n) : n \u2022 ({a} : multiset \u03b1) = repeat a n :=\nbegin\n  refine eq_repeat.mpr \u27e8_, \u03bb b hb, mem_singleton.mp (mem_of_mem_nsmul hb)\u27e9,\n  rw [card_nsmul, card_singleton, mul_one]\nend\n\nlemma nsmul_repeat {a : \u03b1} (n m : \u2115) : n \u2022 (repeat a m) = repeat a (n * m) :=\nbegin\n  rw eq_repeat,\n  split,\n  { rw [card_nsmul, card_repeat] },\n  { exact \u03bb 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 \u03b1] {s t : multiset \u03b1} {a b : \u03b1}\n\n/-- `erase s a` is the multiset that subtracts 1 from the\n  multiplicity of `a`. -/\ndef erase (s : multiset \u03b1) (a : \u03b1) : multiset \u03b1 :=\nquot.lift_on s (\u03bb l, (l.erase a : multiset \u03b1))\n  (\u03bb l\u2081 l\u2082 p, quot.sound (p.erase a))\n\n@[simp] theorem coe_erase (l : list \u03b1) (a : \u03b1) :\n  erase (l : multiset \u03b1) a = l.erase a := rfl\n\n@[simp] theorem erase_zero (a : \u03b1) : (0 : multiset \u03b1).erase a = 0 := rfl\n\n@[simp] theorem erase_cons_head (a : \u03b1) (s : multiset \u03b1) : (a ::\u2098 s).erase a = s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ erase_cons_head a l\n\n@[simp, priority 990]\ntheorem erase_cons_tail {a b : \u03b1} (s : multiset \u03b1) (h : b \u2260 a) :\n  (b ::\u2098 s).erase a = b ::\u2098 s.erase a :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ erase_cons_tail l h\n\n@[simp, priority 980]\ntheorem erase_of_not_mem {a : \u03b1} {s : multiset \u03b1} : a \u2209 s \u2192 s.erase a = s :=\nquot.induction_on s $ \u03bb l h, congr_arg coe $ erase_of_not_mem h\n\n@[simp, priority 980]\ntheorem cons_erase {s : multiset \u03b1} {a : \u03b1} : a \u2208 s \u2192 a ::\u2098 s.erase a = s :=\nquot.induction_on s $ \u03bb l h, quot.sound (perm_cons_erase h).symm\n\ntheorem le_cons_erase (s : multiset \u03b1) (a : \u03b1) : s \u2264 a ::\u2098 s.erase a :=\nif h : a \u2208 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 : \u03b1} {s : multiset \u03b1} (t) : a \u2208 s \u2192 (s + t).erase a = s.erase a + t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082 h, congr_arg coe $ erase_append_left l\u2082 h\n\ntheorem erase_add_right_pos {a : \u03b1} (s) {t : multiset \u03b1} (h : a \u2208 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 : \u03b1} {s : multiset \u03b1} (t) :\n  a \u2209 s \u2192 (s + t).erase a = s + t.erase a :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082 h, congr_arg coe $ erase_append_right l\u2082 h\n\ntheorem erase_add_left_neg {a : \u03b1} (s) {t : multiset \u03b1} (h : a \u2209 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 : \u03b1) (s : multiset \u03b1) : s.erase a \u2264 s :=\nquot.induction_on s $ \u03bb l, (erase_sublist a l).subperm\n\n@[simp] theorem erase_lt {a : \u03b1} {s : multiset \u03b1} : s.erase a < s \u2194 a \u2208 s :=\n\u27e8\u03bb h, not_imp_comm.1 erase_of_not_mem (ne_of_lt h),\n \u03bb h, by simpa [h] using lt_cons_self (s.erase a) a\u27e9\n\ntheorem erase_subset (a : \u03b1) (s : multiset \u03b1) : s.erase a \u2286 s :=\nsubset_of_le (erase_le a s)\n\ntheorem mem_erase_of_ne {a b : \u03b1} {s : multiset \u03b1} (ab : a \u2260 b) : a \u2208 s.erase b \u2194 a \u2208 s :=\nquot.induction_on s $ \u03bb l, list.mem_erase_of_ne ab\n\ntheorem mem_of_mem_erase {a b : \u03b1} {s : multiset \u03b1} : a \u2208 s.erase b \u2192 a \u2208 s :=\nmem_of_subset (erase_subset _ _)\n\ntheorem erase_comm (s : multiset \u03b1) (a b : \u03b1) : (s.erase a).erase b = (s.erase b).erase a :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ l.erase_comm a b\n\ntheorem erase_le_erase {s t : multiset \u03b1} (a : \u03b1) (h : s \u2264 t) : s.erase a \u2264 t.erase a :=\nle_induction_on h $ \u03bb l\u2081 l\u2082 h, (h.erase _).subperm\n\ntheorem erase_le_iff_le_cons {s t : multiset \u03b1} {a : \u03b1} : s.erase a \u2264 t \u2194 s \u2264 a ::\u2098 t :=\n\u27e8\u03bb h, le_trans (le_cons_erase _ _) (cons_le_cons _ h),\n \u03bb h, if m : a \u2208 s\n  then by rw \u2190 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)\u27e9\n\n@[simp] theorem card_erase_of_mem {a : \u03b1} {s : multiset \u03b1} :\n  a \u2208 s \u2192 card (s.erase a) = pred (card s) :=\nquot.induction_on s $ \u03bb l, length_erase_of_mem\n\ntheorem card_erase_lt_of_mem {a : \u03b1} {s : multiset \u03b1} : a \u2208 s \u2192 card (s.erase a) < card s :=\n\u03bb h, card_lt_of_lt (erase_lt.mpr h)\n\ntheorem card_erase_le {a : \u03b1} {s : multiset \u03b1} : card (s.erase a) \u2264 card s :=\ncard_le_of_le (erase_le a s)\n\ntheorem card_erase_eq_ite {a : \u03b1} {s : multiset \u03b1} :\n  card (s.erase a) = if a \u2208 s then pred (card s) else card s :=\nbegin\n  by_cases h : a \u2208 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 \u03b1) : (reverse l : multiset \u03b1) = 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 \u2208 s` (counting multiplicity)\n  such that `f a = b`. -/\ndef map (f : \u03b1 \u2192 \u03b2) (s : multiset \u03b1) : multiset \u03b2 :=\nquot.lift_on s (\u03bb l : list \u03b1, (l.map f : multiset \u03b2))\n  (\u03bb l\u2081 l\u2082 p, quot.sound (p.map f))\n\ntheorem forall_mem_map_iff {f : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} {s : multiset \u03b1} :\n  (\u2200 y \u2208 s.map f, p y) \u2194 (\u2200 x \u2208 s, p (f x)) :=\nquotient.induction_on' s $ \u03bb L, list.forall_mem_map_iff\n\n@[simp] theorem coe_map (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) : map f \u2191l = l.map f := rfl\n\n@[simp] theorem map_zero (f : \u03b1 \u2192 \u03b2) : map f 0 = 0 := rfl\n\n@[simp] theorem map_cons (f : \u03b1 \u2192 \u03b2) (a s) : map f (a ::\u2098 s) = f a ::\u2098 map f s :=\nquot.induction_on s $ \u03bb l, rfl\n\n@[simp] theorem map_singleton (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : ({a} : multiset \u03b1).map f = {f a} := rfl\n\ntheorem map_repeat (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (k : \u2115) : (repeat a k).map f = repeat (f a) k := by\n{ induction k, simp, simpa }\n\n@[simp] theorem map_add (f : \u03b1 \u2192 \u03b2) (s t) : map f (s + t) = map f s + map f t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, congr_arg coe $ map_append _ _ _\n\n/-- If each element of `s : multiset \u03b1` can be lifted to `\u03b2`, then `s` can be lifted to\n`multiset \u03b2`. -/\ninstance [can_lift \u03b1 \u03b2] : can_lift (multiset \u03b1) (multiset \u03b2) :=\n{ cond := \u03bb s, \u2200 x \u2208 s, can_lift.cond \u03b2 x,\n  coe := map can_lift.coe,\n  prf := by { rintro \u27e8l\u27e9 hl, lift l to list \u03b2 using hl, exact \u27e8l, coe_map _ _\u27e9 } }\n\n/-- `multiset.map` as an `add_monoid_hom`. -/\ndef map_add_monoid_hom (f : \u03b1 \u2192 \u03b2) : multiset \u03b1 \u2192+ multiset \u03b2 :=\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 : \u03b1 \u2192 \u03b2) :\n  (map_add_monoid_hom f : multiset \u03b1 \u2192 multiset \u03b2) = map f := rfl\n\ntheorem map_nsmul (f : \u03b1 \u2192 \u03b2) (n : \u2115) (s) : map f (n \u2022 s) = n \u2022 (map f s) :=\n(map_add_monoid_hom f).map_nsmul _ _\n\n@[simp] theorem mem_map {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : multiset \u03b1} :\n  b \u2208 map f s \u2194 \u2203 a, a \u2208 s \u2227 f a = b :=\nquot.induction_on s $ \u03bb l, mem_map\n\n@[simp] theorem card_map (f : \u03b1 \u2192 \u03b2) (s) : card (map f s) = card s :=\nquot.induction_on s $ \u03bb l, length_map _ _\n\n@[simp] theorem map_eq_zero {s : multiset \u03b1} {f : \u03b1 \u2192 \u03b2} : s.map f = 0 \u2194 s = 0 :=\nby rw [\u2190 multiset.card_eq_zero, multiset.card_map, multiset.card_eq_zero]\n\ntheorem mem_map_of_mem (f : \u03b1 \u2192 \u03b2) {a : \u03b1} {s : multiset \u03b1} (h : a \u2208 s) : f a \u2208 map f s :=\nmem_map.2 \u27e8_, h, rfl\u27e9\n\nlemma map_eq_singleton {f : \u03b1 \u2192 \u03b2} {s : multiset \u03b1} {b : \u03b2} :\n  map f s = {b} \u2194 \u2203 a : \u03b1, s = {a} \u2227 f a = b :=\nbegin\n  split,\n  { intro h,\n    obtain \u27e8a, ha\u27e9 : \u2203 a, s = {a},\n    { rw [\u2190card_eq_one, \u2190card_map, h, card_singleton] },\n    refine \u27e8a, ha, _\u27e9,\n    rw [\u2190mem_singleton, \u2190h, ha, map_singleton, mem_singleton] },\n  { rintro \u27e8a, rfl, rfl\u27e9,\n    simp }\nend\n\ntheorem mem_map_of_injective {f : \u03b1 \u2192 \u03b2} (H : function.injective f) {a : \u03b1} {s : multiset \u03b1} :\n  f a \u2208 map f s \u2194 a \u2208 s :=\nquot.induction_on s $ \u03bb l, mem_map_of_injective H\n\n@[simp] theorem map_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) (s : multiset \u03b1) :\n  map g (map f s) = map (g \u2218 f) s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ list.map_map _ _ _\n\ntheorem map_id (s : multiset \u03b1) : map id s = s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ map_id _\n\n@[simp] lemma map_id' (s : multiset \u03b1) : map (\u03bbx, x) s = s := map_id s\n\n@[simp] theorem map_const (s : multiset \u03b1) (b : \u03b2) : map (function.const \u03b1 b) s = repeat b s.card :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ map_const _ _\n\n@[congr] theorem map_congr {f g : \u03b1 \u2192 \u03b2} {s : multiset \u03b1} :\n  (\u2200 x \u2208 s, f x = g x) \u2192 map f s = map g s :=\nquot.induction_on s $ \u03bb l H, congr_arg coe $ map_congr H\n\nlemma map_hcongr {\u03b2' : Type*} {m : multiset \u03b1} {f : \u03b1 \u2192 \u03b2} {f' : \u03b1 \u2192 \u03b2'}\n  (h : \u03b2 = \u03b2') (hf : \u2200a\u2208m, 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\u2081 b\u2082 : \u03b2} {l : list \u03b1} (h : b\u2081 \u2208 map (function.const \u03b1 b\u2082) l) :\n  b\u2081 = b\u2082 :=\neq_of_mem_repeat $ by rwa map_const at h\n\n@[simp] theorem map_le_map {f : \u03b1 \u2192 \u03b2} {s t : multiset \u03b1} (h : s \u2264 t) : map f s \u2264 map f t :=\nle_induction_on h $ \u03bb l\u2081 l\u2082 h, (h.map f).subperm\n\n@[simp] theorem map_subset_map {f : \u03b1 \u2192 \u03b2} {s t : multiset \u03b1} (H : s \u2286 t) : map f s \u2286 map f t :=\n\u03bb b m, let \u27e8a, h, e\u27e9 := mem_map.1 m in mem_map.2 \u27e8a, H h, e\u27e9\n\nlemma map_erase [decidable_eq \u03b1] [decidable_eq \u03b2]\n  (f : \u03b1 \u2192 \u03b2) (hf : function.injective f) (x : \u03b1) (s : multiset \u03b1) :\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\u2081) a\u2082 = f (f b a\u2082) a\u2081`. -/\ndef foldl (f : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (H : right_commutative f) (b : \u03b2) (s : multiset \u03b1) : \u03b2 :=\nquot.lift_on s (\u03bb l, foldl f b l)\n  (\u03bb l\u2081 l\u2082 p, p.foldl_eq H b)\n\n@[simp] theorem foldl_zero (f : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (H b) : foldl f H b 0 = b := rfl\n\n@[simp] theorem foldl_cons (f : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (H b a s) :\n  foldl f H b (a ::\u2098 s) = foldl f H (f b a) s :=\nquot.induction_on s $ \u03bb l, rfl\n\n@[simp] theorem foldl_add (f : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (H b s t) :\n  foldl f H b (s + t) = foldl f H (foldl f H b s) t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, 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\u2081 (f a\u2082 b) = f a\u2082 (f a\u2081 b)`. -/\ndef foldr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H : left_commutative f) (b : \u03b2) (s : multiset \u03b1) : \u03b2 :=\nquot.lift_on s (\u03bb l, foldr f b l)\n  (\u03bb l\u2081 l\u2082 p, p.foldr_eq H b)\n\n@[simp] theorem foldr_zero (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H b) : foldr f H b 0 = b := rfl\n\n@[simp] theorem foldr_cons (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H b a s) :\n  foldr f H b (a ::\u2098 s) = f a (foldr f H b s) :=\nquot.induction_on s $ \u03bb l, rfl\n\n@[simp] theorem foldr_singleton (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H b a) :\n  foldr f H b ({a} : multiset \u03b1) = f a b :=\nrfl\n\n@[simp] theorem foldr_add (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H b s t) :\n  foldr f H b (s + t) = foldr f H (foldr f H b t) s :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, foldr_append _ _ _ _\n\n@[simp] theorem coe_foldr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H : left_commutative f) (b : \u03b2) (l : list \u03b1) :\n  foldr f H b l = l.foldr f b := rfl\n\n@[simp] theorem coe_foldl (f : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (H : right_commutative f) (b : \u03b2) (l : list \u03b1) :\n  foldl f H b l = l.foldl f b := rfl\n\ntheorem coe_foldr_swap (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H : left_commutative f) (b : \u03b2) (l : list \u03b1) :\n  foldr f H b l = l.foldl (\u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H : left_commutative f) (b : \u03b2) (s : multiset \u03b1) :\n  foldr f H b s = foldl (\u03bb x y, f y x) (\u03bb x y z, (H _ _ _).symm) b s :=\nquot.induction_on s $ \u03bb l, coe_foldr_swap _ _ _ _\n\ntheorem foldl_swap (f : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (H : right_commutative f) (b : \u03b2) (s : multiset \u03b1) :\n  foldl f H b s = foldr (\u03bb x y, f y x) (\u03bb x y z, (H _ _ _).symm) b s :=\n(foldr_swap _ _ _ _).symm\n\nlemma foldr_induction' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (H : left_commutative f) (x : \u03b2) (q : \u03b1 \u2192 Prop)\n  (p : \u03b2 \u2192 Prop) (s : multiset \u03b1) (hpqf : \u2200 a b, q a \u2192 p b \u2192 p (f a b)) (px : p x)\n  (q_s : \u2200 a \u2208 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 : \u2200 (x : \u03b1), x \u2208 s \u2192 q x, from \u03bb 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 : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (H : left_commutative f) (x : \u03b1) (p : \u03b1 \u2192 Prop)\n  (s : multiset \u03b1) (p_f : \u2200 a b, p a \u2192 p b \u2192 p (f a b)) (px : p x) (p_s : \u2200 a \u2208 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 : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (H : right_commutative f) (x : \u03b2) (q : \u03b1 \u2192 Prop)\n  (p : \u03b2 \u2192 Prop) (s : multiset \u03b1) (hpqf : \u2200 a b, q a \u2192 p b \u2192 p (f b a)) (px : p x)\n  (q_s : \u2200 a \u2208 s, q a) :\n  p (foldl f H x s) :=\nbegin\n  rw foldl_swap,\n  exact foldr_induction' (\u03bb x y, f y x) (\u03bb x y z, (H _ _ _).symm) x q p s hpqf px q_s,\nend\n\nlemma foldl_induction (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (H : right_commutative f) (x : \u03b1) (p : \u03b1 \u2192 Prop)\n  (s : multiset \u03b1) (p_f : \u2200 a b, p a \u2192 p b \u2192 p (f b a)) (px : p x) (p_s : \u2200 a \u2208 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 `\u03b1`.\n  `prod {a, b, c} = a * b * c` -/\n@[to_additive \"Sum of a multiset given a commutative additive monoid structure on `\u03b1`.\n  `sum {a, b, c} = a + b + c`\"]\ndef prod [comm_monoid \u03b1] : multiset \u03b1 \u2192 \u03b1 :=\nfoldr (*) (\u03bb x y z, by simp [mul_left_comm]) 1\n\n@[to_additive]\ntheorem prod_eq_foldr [comm_monoid \u03b1] (s : multiset \u03b1) :\n  prod s = foldr (*) (\u03bb x y z, by simp [mul_left_comm]) 1 s := rfl\n\n@[to_additive]\ntheorem prod_eq_foldl [comm_monoid \u03b1] (s : multiset \u03b1) :\n  prod s = foldl (*) (\u03bb 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 \u03b1] (l : list \u03b1) : prod \u2191l = l.prod :=\nprod_eq_foldl _\n\n@[simp, to_additive] theorem prod_to_list [comm_monoid \u03b1] (s : multiset \u03b1) :\n  s.to_list.prod = s.prod :=\nbegin\n  conv_rhs { rw \u2190coe_to_list s, },\n  rw coe_prod,\nend\n\n@[simp, to_additive]\ntheorem prod_zero [comm_monoid \u03b1] : @prod \u03b1 _ 0 = 1 := rfl\n\n@[simp, to_additive]\ntheorem prod_cons [comm_monoid \u03b1] (a : \u03b1) (s) : prod (a ::\u2098 s) = a * prod s :=\nfoldr_cons _ _ _ _ _\n\n@[simp, to_additive]\ntheorem prod_singleton [comm_monoid \u03b1] (a : \u03b1) : 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 \u03b1] (s t : multiset \u03b1) : prod (s + t) = prod s * prod t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, 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 \u03b1] : multiset \u03b1 \u2192+ \u03b1 :=\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 \u03b1] :\n  (sum_add_monoid_hom : multiset \u03b1 \u2192 \u03b1) = sum := rfl\n\nlemma prod_nsmul {\u03b1 : Type*} [comm_monoid \u03b1] (m : multiset \u03b1) :\n  \u2200 (n : \u2115), (n \u2022 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 \u03b1] (a : \u03b1) (n : \u2115) :\n  prod (multiset.repeat a n) = a ^ n :=\nby simp [repeat, list.prod_repeat]\n\n@[to_additive]\nlemma prod_map_one [comm_monoid \u03b3] {m : multiset \u03b1} :\n  prod (m.map (\u03bba, (1 : \u03b3))) = (1 : \u03b3) :=\nby simp\n\n@[simp, to_additive]\nlemma prod_map_mul [comm_monoid \u03b3] {m : multiset \u03b1} {f g : \u03b1 \u2192 \u03b3} :\n  prod (m.map $ \u03bba, 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 \u03b3] (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  prod (m.map $ \u03bba, prod $ n.map $ \u03bbb, f a b) = prod (n.map $ \u03bbb, prod $ m.map $ \u03bba, f a b) :=\nmultiset.induction_on m (by simp) (assume a m ih, by simp [ih])\n\nlemma sum_map_mul_left [semiring \u03b2] {b : \u03b2} {s : multiset \u03b1} {f : \u03b1 \u2192 \u03b2} :\n  sum (s.map (\u03bba, 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 \u03b2] {b : \u03b2} {s : multiset \u03b1} {f : \u03b1 \u2192 \u03b2} :\n  sum (s.map (\u03bba, 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\u2080 : Type*} [comm_monoid_with_zero M\u2080] {s : multiset M\u2080} (h : (0 : M\u2080) \u2208 s) :\n  multiset.prod s = 0 :=\nbegin\n  rcases multiset.exists_cons_of_mem h with \u27e8s', hs'\u27e9,\n  simp [hs', multiset.prod_cons]\nend\n\nlemma prod_eq_zero_iff {M\u2080 : Type*} [comm_monoid_with_zero M\u2080] [no_zero_divisors M\u2080] [nontrivial M\u2080]\n  {s : multiset M\u2080} :\n  multiset.prod s = 0 \u2194 (0 : M\u2080) \u2208 s :=\nby { rcases s with \u27e8l\u27e9, simp }\n\ntheorem prod_ne_zero {M\u2080 : Type*} [comm_monoid_with_zero M\u2080] [no_zero_divisors M\u2080] [nontrivial M\u2080]\n  {m : multiset M\u2080} (h : (0 : M\u2080) \u2209 m) : m.prod \u2260 0 :=\nmt prod_eq_zero_iff.1 h\n\n@[to_additive]\nlemma prod_hom [comm_monoid \u03b1] [comm_monoid \u03b2] (s : multiset \u03b1) (f : \u03b1 \u2192* \u03b2) :\n  (s.map f).prod = f s.prod :=\nquotient.induction_on s $ \u03bb 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 \u03b2] [comm_monoid \u03b3] (s : multiset \u03b1) {r : \u03b2 \u2192 \u03b3 \u2192 Prop}\n  {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} (h\u2081 : r 1 1) (h\u2082 : \u2200\u2983a b c\u2984, r b c \u2192 r (f a * b) (g a * c)) :\n  r (s.map f).prod (s.map g).prod :=\nquotient.induction_on s $ \u03bb l,\n  by simp only [l.prod_hom_rel h\u2081 h\u2082, 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 \u2192 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\u207b\u00b9 :=\nm.prod_hom comm_group.inv_monoid_hom\n\nlemma dvd_prod [comm_monoid \u03b1] {a : \u03b1} {s : multiset \u03b1} : a \u2208 s \u2192 a \u2223 s.prod :=\nquotient.induction_on s (\u03bb l a h, by simpa using list.dvd_prod h) a\n\nlemma prod_dvd_prod [comm_monoid \u03b1] {s t : multiset \u03b1} (h : s \u2264 t) :\n  s.prod \u2223 t.prod :=\nbegin\n  rcases multiset.le_iff_exists_add.1 h with \u27e8z, rfl\u27e9,\n  simp,\nend\n\nlemma prod_nonneg [ordered_comm_semiring \u03b1] {m : multiset \u03b1} (h : \u2200 a \u2208 m, (0 : \u03b1) \u2264 a) :\n  0 \u2264 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 (\u03bb 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 \u03b1] {m : multiset \u03b1} :\n  (\u2200 x \u2208 m, (1 : \u03b1) \u2264 x) \u2192 1 \u2264 m.prod :=\nquotient.induction_on m $ \u03bb l hl, by simpa using list.one_le_prod_of_one_le hl\n\n@[to_additive]\nlemma single_le_prod [ordered_comm_monoid \u03b1] {m : multiset \u03b1} :\n  (\u2200 x \u2208 m, (1 : \u03b1) \u2264 x) \u2192 \u2200 x \u2208 m, x \u2264 m.prod :=\nquotient.induction_on m $ \u03bb 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 \u03b1] (l : multiset \u03b1) (n : \u03b1) (h : \u2200 (x \u2208 l), x \u2264 n) :\n  l.prod \u2264 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 \u03b1] {m : multiset \u03b1} :\n  (\u2200 x \u2208 m, (1 : \u03b1) \u2264 x) \u2192 m.prod = 1 \u2192 (\u2200 x \u2208 m, x = (1 : \u03b1)) :=\nbegin\n  apply quotient.induction_on m,\n  simp only [quot_mk_to_coe, coe_prod, mem_coe],\n  exact \u03bb l, all_one_of_le_one_le_of_prod_eq_one,\nend\n\nlemma sum_eq_zero_iff [canonically_ordered_add_monoid \u03b1] {m : multiset \u03b1} :\n  m.sum = 0 \u2194 \u2200 x \u2208 m, x = (0 : \u03b1) :=\nquotient.induction_on m $ \u03bb l, by simpa using list.sum_eq_zero_iff l\n\n@[to_additive]\nlemma prod_induction {M : Type*} [comm_monoid M] (p : M \u2192 Prop) (s : multiset M)\n  (p_mul : \u2200 a b, p a \u2192 p b \u2192 p (a * b)) (p_one : p 1) (p_s : \u2200 a \u2208 s, p a) :\n  p s.prod :=\nbegin\n  rw prod_eq_foldr,\n  exact foldr_induction (*) (\u03bb 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 \u03b1] [ordered_comm_monoid \u03b2]\n  (f : \u03b1 \u2192 \u03b2) (p : \u03b1 \u2192 Prop) (h_one : f 1 = 1) (hp_one : p 1)\n  (h_mul : \u2200 a b, p a \u2192 p b \u2192 f (a * b) \u2264 f a * f b)\n  (hp_mul : \u2200 a b, p a \u2192 p b \u2192 p (a * b)) (s : multiset \u03b1) (hps : \u2200 a, a \u2208 s \u2192 p a) :\n  f s.prod \u2264 (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 : \u2200 x, x \u2208 s \u2192 p x, from \u03bb 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 \u03b1] [ordered_comm_monoid \u03b2]\n  (f : \u03b1 \u2192 \u03b2) (h_one : f 1 = 1) (h_mul : \u2200 a b, f (a * b) \u2264 f a * f b) (s : multiset \u03b1) :\n  f s.prod \u2264 (s.map f).prod :=\nle_prod_of_submultiplicative_on_pred f (\u03bb i, true) h_one trivial (\u03bb 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 \u2192 Prop)\n  (p_mul : \u2200 a b, p a \u2192 p b \u2192 p (a * b)) {s : multiset M} (hs_nonempty : s \u2260 \u2205)\n  (p_s : \u2200 a \u2208 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 = \u2205,\n  { simp [hs_empty, hpsa a], },\n  have hps : \u2200 (x : M), x \u2208 s \u2192 p x, from \u03bb 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 \u03b1] [ordered_comm_monoid \u03b2]\n  (f : \u03b1 \u2192 \u03b2) (p : \u03b1 \u2192 Prop) (h_mul : \u2200 a b, p a \u2192 p b \u2192 f (a * b) \u2264 f a * f b)\n  (hp_mul : \u2200 a b, p a \u2192 p b \u2192 p (a * b)) (s : multiset \u03b1) (hs_nonempty : s \u2260 \u2205)\n  (hs : \u2200 a, a \u2208 s \u2192 p a) :\n  f s.prod \u2264 (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 = \u2205,\n  { simp [hs_empty], },\n  have hsa_restrict : (\u2200 x, x \u2208 s \u2192 p x), from \u03bb 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 \u03b1] [ordered_comm_monoid \u03b2]\n  (f : \u03b1 \u2192 \u03b2) (h_mul : \u2200 a b, f (a * b) \u2264 f a * f b) (s : multiset \u03b1) (hs_nonempty : s \u2260 \u2205) :\n  f s.prod \u2264 (s.map f).prod :=\nle_prod_nonempty_of_submultiplicative_on_pred f (\u03bb i, true) (by simp [h_mul]) (by simp) s\n  hs_nonempty (by simp)\n\ntheorem dvd_sum [comm_semiring \u03b1] {a : \u03b1} {s : multiset \u03b1} : (\u2200 x \u2208 s, a \u2223 x) \u2192 a \u2223 s.sum :=\nmultiset.induction_on s (\u03bb _, dvd_zero _)\n  (\u03bb x s ih h, by rw sum_cons; exact dvd_add\n    (h _ (mem_cons_self _ _)) (ih (\u03bb y hy, h _ (mem_cons.2 (or.inr hy)))))\n\n@[simp] theorem sum_map_singleton (s : multiset \u03b1) : (s.map (\u03bb a, ({a} : multiset \u03b1))).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 \u03b1] {s : multiset \u03b1} :\n  abs s.sum \u2264 (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 \u03b1) \u2192 multiset \u03b1 := sum\n\ntheorem coe_join : \u2200 L : list (list \u03b1),\n  join (L.map (@coe _ (multiset \u03b1) _) : multiset (multiset \u03b1)) = L.join\n| []       := rfl\n| (l :: L) := congr_arg (\u03bb s : multiset \u03b1, \u2191l + s) (coe_join L)\n\n@[simp] theorem join_zero : @join \u03b1 0 = 0 := rfl\n\n@[simp] theorem join_cons (s S) : @join \u03b1 (s ::\u2098 S) = s + join S :=\nsum_cons _ _\n\n@[simp] theorem join_add (S T) : @join \u03b1 (S + T) = join S + join T :=\nsum_add _ _\n\n@[simp] theorem singleton_join (a) : join ({a} : multiset (multiset \u03b1)) = a :=\nsum_singleton _\n\n@[simp] theorem mem_join {a S} : a \u2208 @join \u03b1 S \u2194 \u2203 s \u2208 S, a \u2208 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 \u03b1 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 \u03b1) (f : \u03b1 \u2192 multiset \u03b2) : multiset \u03b2 :=\njoin (map f s)\n\n@[simp] theorem coe_bind (l : list \u03b1) (f : \u03b1 \u2192 list \u03b2) :\n  @bind \u03b1 \u03b2 l (\u03bb a, f a) = l.bind f :=\nby rw [list.bind, \u2190 coe_join, list.map_map]; refl\n\n@[simp] theorem zero_bind (f : \u03b1 \u2192 multiset \u03b2) : bind 0 f = 0 := rfl\n\n@[simp] theorem cons_bind (a s) (f : \u03b1 \u2192 multiset \u03b2) : bind (a ::\u2098 s) f = f a + bind s f :=\nby simp [bind]\n\n@[simp] theorem singleton_bind (a) (f : \u03b1 \u2192 multiset \u03b2) : bind {a} f = f a :=\nby simp [bind]\n\n@[simp] theorem add_bind (s t) (f : \u03b1 \u2192 multiset \u03b2) : bind (s + t) f = bind s f + bind t f :=\nby simp [bind]\n\n@[simp] theorem bind_zero (s : multiset \u03b1) : bind s (\u03bba, 0 : \u03b1 \u2192 multiset \u03b2) = 0 :=\nby simp [bind, join, nsmul_zero]\n\n@[simp] theorem bind_add (s : multiset \u03b1) (f g : \u03b1 \u2192 multiset \u03b2) :\n  bind s (\u03bba, f a + g a) = bind s f + bind s g :=\nby simp [bind, join]\n\n@[simp] theorem bind_cons (s : multiset \u03b1) (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 multiset \u03b2) :\n  bind s (\u03bba, f a ::\u2098 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 \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  bind s (\u03bb x, ({f x} : multiset \u03b2)) = 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 : \u03b1 \u2192 multiset \u03b2} : b \u2208 bind s f \u2194 \u2203 a \u2208 s, b \u2208 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 : \u03b1 \u2192 multiset \u03b2) : card (bind s f) = sum (map (card \u2218 f) s) :=\nby simp [bind]\n\nlemma bind_congr {f g : \u03b1 \u2192 multiset \u03b2} {m : multiset \u03b1} :\n  (\u2200a\u2208m, f a = g a) \u2192 bind m f = bind m g :=\nby simp [bind] {contextual := tt}\n\nlemma bind_hcongr {\u03b2' : Type*} {m : multiset \u03b1} {f : \u03b1 \u2192 multiset \u03b2} {f' : \u03b1 \u2192 multiset \u03b2'}\n  (h : \u03b2 = \u03b2') (hf : \u2200a\u2208m, 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 \u03b1) (n : \u03b1 \u2192 multiset \u03b2) (f : \u03b2 \u2192 \u03b3) :\n  map f (bind m n) = bind m (\u03bba, map f (n a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map (m : multiset \u03b1) (n : \u03b2 \u2192 multiset \u03b3) (f : \u03b1 \u2192 \u03b2) :\n  bind (map f m) n = bind m (\u03bba, n (f a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_assoc {s : multiset \u03b1} {f : \u03b1 \u2192 multiset \u03b2} {g : \u03b2 \u2192 multiset \u03b3} :\n  (s.bind f).bind g = s.bind (\u03bba, (f a).bind g) :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma bind_bind (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 multiset \u03b3} :\n  (bind m $ \u03bba, bind n $ \u03bbb, f a b) = (bind n $ \u03bbb, bind m $ \u03bba, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map_comm (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  (bind m $ \u03bba, n.map $ \u03bbb, f a b) = (bind n $ \u03bbb, m.map $ \u03bba, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\n@[simp, to_additive]\nlemma prod_bind [comm_monoid \u03b2] (s : multiset \u03b1) (t : \u03b1 \u2192 multiset \u03b2) :\n  prod (bind s t) = prod (s.map $ \u03bba, 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 \u03b1) (t : multiset \u03b2) : multiset (\u03b1 \u00d7 \u03b2) :=\ns.bind $ \u03bb a, t.map $ prod.mk a\n\n@[simp] theorem coe_product (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n  @product \u03b1 \u03b2 l\u2081 l\u2082 = l\u2081.product l\u2082 :=\nby rw [product, list.product, \u2190 coe_bind]; simp\n\n@[simp] theorem zero_product (t) : @product \u03b1 \u03b2 0 t = 0 := rfl\n\n@[simp] theorem cons_product (a : \u03b1) (s : multiset \u03b1) (t : multiset \u03b2) :\n  product (a ::\u2098 s) t = map (prod.mk a) t + product s t :=\nby simp [product]\n\n@[simp] theorem product_singleton (a : \u03b1) (b : \u03b2) :\n  product ({a} : multiset \u03b1) ({b} : multiset \u03b2) = {(a,b)} :=\nby simp only [product, bind_singleton, map_singleton]\n\n@[simp] theorem add_product (s t : multiset \u03b1) (u : multiset \u03b2) :\n  product (s + t) u = product s u + product t u :=\nby simp [product]\n\n@[simp] theorem product_add (s : multiset \u03b1) : \u2200 t u : multiset \u03b2,\n  product s (t + u) = product s t + product s u :=\nmultiset.induction_on s (\u03bb t u, rfl) $ \u03bb a s IH t u,\n  by rw [cons_product, IH]; simp; cc\n\n@[simp] theorem mem_product {s t} : \u2200 {p : \u03b1 \u00d7 \u03b2}, p \u2208 @product \u03b1 \u03b2 s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t\n| (a, b) := by simp [product, and.left_comm]\n\n@[simp] theorem card_product (s : multiset \u03b1) (t : multiset \u03b2) :\n  card (product s t) = card s * card t :=\nby simp [product, repeat, (\u2218), mul_comm]\n\n/-! ### Sigma multiset -/\nsection\nvariable {\u03c3 : \u03b1 \u2192 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 \u03b1) (t : \u03a0 a, multiset (\u03c3 a)) : multiset (\u03a3 a, \u03c3 a) :=\ns.bind $ \u03bb a, (t a).map $ sigma.mk a\n\n@[simp] theorem coe_sigma (l\u2081 : list \u03b1) (l\u2082 : \u03a0 a, list (\u03c3 a)) :\n  @multiset.sigma \u03b1 \u03c3 l\u2081 (\u03bb a, l\u2082 a) = l\u2081.sigma l\u2082 :=\nby rw [multiset.sigma, list.sigma, \u2190 coe_bind]; simp\n\n@[simp] theorem zero_sigma (t) : @multiset.sigma \u03b1 \u03c3 0 t = 0 := rfl\n\n@[simp] theorem cons_sigma (a : \u03b1) (s : multiset \u03b1) (t : \u03a0 a, multiset (\u03c3 a)) :\n  (a ::\u2098 s).sigma t = map (sigma.mk a) (t a) + s.sigma t :=\nby simp [multiset.sigma]\n\n@[simp] theorem sigma_singleton (a : \u03b1) (b : \u03b1 \u2192 \u03b2) :\n  ({a} : multiset \u03b1).sigma (\u03bb a, ({b a} : multiset \u03b2)) = {\u27e8a, b a\u27e9} := rfl\n\n@[simp] theorem add_sigma (s t : multiset \u03b1) (u : \u03a0 a, multiset (\u03c3 a)) :\n  (s + t).sigma u = s.sigma u + t.sigma u :=\nby simp [multiset.sigma]\n\n@[simp] theorem sigma_add (s : multiset \u03b1) : \u2200 t u : \u03a0 a, multiset (\u03c3 a),\n  s.sigma (\u03bb a, t a + u a) = s.sigma t + s.sigma u :=\nmultiset.induction_on s (\u03bb t u, rfl) $ \u03bb a s IH t u,\n  by rw [cons_sigma, IH]; simp; cc\n\n@[simp] theorem mem_sigma {s t} : \u2200 {p : \u03a3 a, \u03c3 a},\n  p \u2208 @multiset.sigma \u03b1 \u03c3 s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t p.1\n| \u27e8a, b\u27e9 := by simp [multiset.sigma, and_assoc, and.left_comm]\n\n@[simp] theorem card_sigma (s : multiset \u03b1) (t : \u03a0 a, multiset (\u03c3 a)) :\n  card (s.sigma t) = sum (map (\u03bb a, card (t a)) s) :=\nby simp [multiset.sigma, (\u2218)]\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 : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) (s : multiset \u03b1) : (\u2200 a \u2208 s, p a) \u2192 multiset \u03b2 :=\nquot.rec_on s (\u03bb l H, \u2191(pmap f l H)) $ \u03bb l\u2081 l\u2082 (pp : l\u2081 ~ l\u2082),\nfunext $ \u03bb (H\u2082 : \u2200 a \u2208 l\u2082, p a),\nhave H\u2081 : \u2200 a \u2208 l\u2081, p a, from \u03bb a h, H\u2082 a (pp.subset h),\nhave \u2200 {s\u2082 e H}, @eq.rec (multiset \u03b1) l\u2081\n  (\u03bb s, (\u2200 a \u2208 s, p a) \u2192 multiset \u03b2) (\u03bb _, \u2191(pmap f l\u2081 H\u2081))\n  s\u2082 e H = \u2191(pmap f l\u2081 H\u2081), by intros s\u2082 e _; subst e,\nthis.trans $ quot.sound $ pp.pmap f\n\n@[simp] theorem coe_pmap {p : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2)\n  (l : list \u03b1) (H : \u2200 a \u2208 l, p a) : pmap f l H = l.pmap f H := rfl\n\n@[simp] lemma pmap_zero {p : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) (h : \u2200a\u2208(0:multiset \u03b1), p a) :\n  pmap f 0 h = 0 := rfl\n\n@[simp] lemma pmap_cons {p : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) (a : \u03b1) (m : multiset \u03b1) :\n  \u2200(h : \u2200b\u2208a ::\u2098 m, p b), pmap f (a ::\u2098 m) h =\n    f a (h a (mem_cons_self a m)) ::\u2098 pmap f m (\u03bba ha, h a $ mem_cons_of_mem ha) :=\nquotient.induction_on m $ assume l h, rfl\n\n/-- \"Attach\" a proof that `a \u2208 s` to each element `a` in `s` to produce\n  a multiset on `{x // x \u2208 s}`. -/\ndef attach (s : multiset \u03b1) : multiset {x // x \u2208 s} := pmap subtype.mk s (\u03bb a, id)\n\n@[simp] theorem coe_attach (l : list \u03b1) :\n @eq (multiset {x // x \u2208 l}) (@attach \u03b1 l) l.attach := rfl\n\ntheorem sizeof_lt_sizeof_of_mem [has_sizeof \u03b1] {x : \u03b1} {s : multiset \u03b1} (hx : x \u2208 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 : \u03b1 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) (s : multiset \u03b1) :\n  \u2200 H, @pmap _ _ p (\u03bb a _, f a) s H = map f s :=\nquot.induction_on s $ \u03bb l H, congr_arg coe $ pmap_eq_map p f l H\n\ntheorem pmap_congr {p q : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2} {g : \u03a0 a, q a \u2192 \u03b2}\n  (s : multiset \u03b1) {H\u2081 H\u2082} (h : \u2200 a h\u2081 h\u2082, f a h\u2081 = g a h\u2082) :\n  pmap f s H\u2081 = pmap g s H\u2082 :=\nquot.induction_on s (\u03bb l H\u2081 H\u2082, congr_arg coe $ pmap_congr l h) H\u2081 H\u2082\n\ntheorem map_pmap {p : \u03b1 \u2192 Prop} (g : \u03b2 \u2192 \u03b3) (f : \u03a0 a, p a \u2192 \u03b2)\n  (s) : \u2200 H, map g (pmap f s H) = pmap (\u03bb a h, g (f a h)) s H :=\nquot.induction_on s $ \u03bb l H, congr_arg coe $ map_pmap g f l H\n\ntheorem pmap_eq_map_attach {p : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2)\n  (s) : \u2200 H, pmap f s H = s.attach.map (\u03bb x, f x.1 (H _ x.2)) :=\nquot.induction_on s $ \u03bb l H, congr_arg coe $ pmap_eq_map_attach f l H\n\ntheorem attach_map_val (s : multiset \u03b1) : s.attach.map subtype.val = s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ attach_map_val l\n\n@[simp] theorem mem_attach (s : multiset \u03b1) : \u2200 x, x \u2208 s.attach :=\nquot.induction_on s $ \u03bb l, mem_attach _\n\n@[simp] theorem mem_pmap {p : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2}\n  {s H b} : b \u2208 pmap f s H \u2194 \u2203 a (h : a \u2208 s), f a (H a h) = b :=\nquot.induction_on s (\u03bb l H, mem_pmap) H\n\n@[simp] theorem card_pmap {p : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2)\n  (s H) : card (pmap f s H) = card s :=\nquot.induction_on s (\u03bb l H, length_pmap) H\n\n@[simp] theorem card_attach {m : multiset \u03b1} : card (attach m) = card m := card_pmap _ _ _\n\n@[simp] lemma attach_zero : (0 : multiset \u03b1).attach = 0 := rfl\n\nlemma attach_cons (a : \u03b1) (m : multiset \u03b1) :\n  (a ::\u2098 m).attach = \u27e8a, mem_cons_self a m\u27e9 ::\u2098 (m.attach.map $ \u03bbp, \u27e8p.1, mem_cons_of_mem p.2\u27e9) :=\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\u2081 h\u2082, subtype.eq rfl)\n\nsection decidable_pi_exists\nvariables {m : multiset \u03b1}\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 : \u03b1 \u2192 Prop} [hp : \u2200a, decidable (p a)] :\n  decidable (\u2200a\u2208m, p a) :=\nquotient.rec_on_subsingleton m (\u03bbl, decidable_of_iff (\u2200a\u2208l, p a) $ by simp)\n\ninstance decidable_dforall_multiset {p : \u03a0a\u2208m, Prop} [hp : \u2200a (h : a \u2208 m), decidable (p a h)] :\n  decidable (\u2200a (h : a \u2208 m), p a h) :=\ndecidable_of_decidable_of_iff\n  (@multiset.decidable_forall_multiset {a // a \u2208 m} m.attach (\u03bba, p a.1 a.2) _)\n  (iff.intro (assume h a ha, h \u27e8a, ha\u27e9 (mem_attach _ _)) (assume h \u27e8a, ha\u27e9 _, h _ _))\n\n/-- decidable equality for functions whose domain is bounded by multisets -/\ninstance decidable_eq_pi_multiset {\u03b2 : \u03b1 \u2192 Type*} [h : \u2200a, decidable_eq (\u03b2 a)] :\n  decidable_eq (\u03a0a\u2208m, \u03b2 a) :=\nassume f g, decidable_of_iff (\u2200a (h : a \u2208 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 : \u03b1 \u2192 Prop} [decidable_pred p] :\n  decidable (\u2203 x \u2208 m, p x) :=\nquotient.rec_on_subsingleton m list.decidable_exists_mem\n\ninstance decidable_dexists_multiset {p : \u03a0a\u2208m, Prop} [hp : \u2200a (h : a \u2208 m), decidable (p a h)] :\n  decidable (\u2203a (h : a \u2208 m), p a h) :=\ndecidable_of_decidable_of_iff\n  (@multiset.decidable_exists_multiset {a // a \u2208 m} m.attach (\u03bba, p a.1 a.2) _)\n  (iff.intro (\u03bb \u27e8\u27e8a, ha\u2081\u27e9, _, ha\u2082\u27e9, \u27e8a, ha\u2081, ha\u2082\u27e9)\n    (\u03bb \u27e8a, ha\u2081, ha\u2082\u27e9, \u27e8\u27e8a, ha\u2081\u27e9, mem_attach _ _, ha\u2082\u27e9))\n\nend decidable_pi_exists\n\n/-! ### Subtraction -/\nsection\nvariables [decidable_eq \u03b1] {s t u : multiset \u03b1} {a b : \u03b1}\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 \u2265 count a s`). -/\nprotected def sub (s t : multiset \u03b1) : multiset \u03b1 :=\nquotient.lift_on\u2082 s t (\u03bb l\u2081 l\u2082, (l\u2081.diff l\u2082 : multiset \u03b1)) $ \u03bb v\u2081 v\u2082 w\u2081 w\u2082 p\u2081 p\u2082,\n  quot.sound $ p\u2081.diff p\u2082\n\ninstance : has_sub (multiset \u03b1) := \u27e8multiset.sub\u27e9\n\n@[simp] theorem coe_sub (s t : list \u03b1) : (s - t : multiset \u03b1) = (s.diff t : list \u03b1) := 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 \u03b1)`. -/\nprotected theorem sub_zero (s : multiset \u03b1) : s - 0 = s :=\nquot.induction_on s $ \u03bb l, rfl\n\n@[simp] theorem sub_cons (a : \u03b1) (s t : multiset \u03b1) : s - a ::\u2098 t = s.erase a - t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, 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 \u03b1)`. -/\nprotected theorem sub_le_iff_le_add : s - t \u2264 u \u2194 s \u2264 u + t :=\nby revert s; exact\nmultiset.induction_on t (by simp [multiset.sub_zero])\n  (\u03bb a t IH s, by simp [IH, erase_le_iff_le_cons])\n\ninstance : has_ordered_sub (multiset \u03b1) :=\n\u27e8\u03bb n m k, multiset.sub_le_iff_le_add\u27e9\n\ntheorem sub_eq_fold_erase (s t : multiset \u03b1) : s - t = foldl erase erase_comm s t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082,\nshow \u2191(l\u2081.diff l\u2082) = foldl erase erase_comm \u2191l\u2081 \u2191l\u2082,\nby { rw diff_eq_foldl l\u2081 l\u2082, symmetry, exact foldl_hom _ _ _ _ _ (\u03bb x y, rfl) }\n\n@[simp] theorem card_sub {s t : multiset \u03b1} (h : t \u2264 s) : card (s - t) = card s - card t :=\n(tsub_eq_of_eq_add_rev $ by rw [add_comm, \u2190 card_add, tsub_add_cancel_of_le h]).symm\n\n/-! ### Union -/\n\n/-- `s \u222a t` is the lattice join operation with respect to the\n  multiset `\u2264`. The multiplicity of `a` in `s \u222a t` is the maximum\n  of the multiplicities in `s` and `t`. -/\ndef union (s t : multiset \u03b1) : multiset \u03b1 := s - t + t\n\ninstance : has_union (multiset \u03b1) := \u27e8union\u27e9\n\ntheorem union_def (s t : multiset \u03b1) : s \u222a t = s - t + t := rfl\n\ntheorem le_union_left (s t : multiset \u03b1) : s \u2264 s \u222a t := le_tsub_add\n\ntheorem le_union_right (s t : multiset \u03b1) : t \u2264 s \u222a t := le_add_left _ _\n\ntheorem eq_union_left : t \u2264 s \u2192 s \u222a t = s := tsub_add_cancel_of_le\n\ntheorem union_le_union_right (h : s \u2264 t) (u) : s \u222a u \u2264 t \u222a u :=\nadd_le_add_right (tsub_le_tsub_right h _) u\n\ntheorem union_le (h\u2081 : s \u2264 u) (h\u2082 : t \u2264 u) : s \u222a t \u2264 u :=\nby rw \u2190 eq_union_left h\u2082; exact union_le_union_right h\u2081 t\n\n@[simp] theorem mem_union : a \u2208 s \u222a t \u2194 a \u2208 s \u2228 a \u2208 t :=\n\u27e8\u03bb 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 _ _)\u27e9\n\n@[simp] theorem map_union [decidable_eq \u03b2] {f : \u03b1 \u2192 \u03b2} (finj : function.injective f)\n  {s t : multiset \u03b1} :\n  map f (s \u222a t) = map f s \u222a map f t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082,\ncongr_arg coe (by rw [list.map_append f, list.map_diff finj])\n\n/-! ### Intersection -/\n\n/-- `s \u2229 t` is the lattice meet operation with respect to the\n  multiset `\u2264`. The multiplicity of `a` in `s \u2229 t` is the minimum\n  of the multiplicities in `s` and `t`. -/\ndef inter (s t : multiset \u03b1) : multiset \u03b1 :=\nquotient.lift_on\u2082 s t (\u03bb l\u2081 l\u2082, (l\u2081.bag_inter l\u2082 : multiset \u03b1)) $ \u03bb v\u2081 v\u2082 w\u2081 w\u2082 p\u2081 p\u2082,\n  quot.sound $ p\u2081.bag_inter p\u2082\n\ninstance : has_inter (multiset \u03b1) := \u27e8inter\u27e9\n\n@[simp] theorem inter_zero (s : multiset \u03b1) : s \u2229 0 = 0 :=\nquot.induction_on s $ \u03bb l, congr_arg coe l.bag_inter_nil\n\n@[simp] theorem zero_inter (s : multiset \u03b1) : 0 \u2229 s = 0 :=\nquot.induction_on s $ \u03bb l, congr_arg coe l.nil_bag_inter\n\n@[simp] theorem cons_inter_of_pos {a} (s : multiset \u03b1) {t} :\n  a \u2208 t \u2192 (a ::\u2098 s) \u2229 t = a ::\u2098 s \u2229 t.erase a :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082 h,\ncongr_arg coe $ cons_bag_inter_of_pos _ h\n\n@[simp] theorem cons_inter_of_neg {a} (s : multiset \u03b1) {t} :\n  a \u2209 t \u2192 (a ::\u2098 s) \u2229 t = s \u2229 t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082 h,\ncongr_arg coe $ cons_bag_inter_of_neg _ h\n\ntheorem inter_le_left (s t : multiset \u03b1) : s \u2229 t \u2264 s :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082,\n(bag_inter_sublist_left _ _).subperm\n\ntheorem inter_le_right (s : multiset \u03b1) : \u2200 t, s \u2229 t \u2264 t :=\nmultiset.induction_on s (\u03bb t, (zero_inter t).symm \u25b8 zero_le _) $\n\u03bb a s IH t, if h : a \u2208 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\u2081 : s \u2264 t) (h\u2082 : s \u2264 u) : s \u2264 t \u2229 u :=\nbegin\n  revert s u, refine multiset.induction_on t _ (\u03bb a t IH, _); intros,\n  { simp [h\u2081] },\n  by_cases a \u2208 u,\n  { rw [cons_inter_of_pos _ h, \u2190 erase_le_iff_le_cons],\n    exact IH (erase_le_iff_le_cons.2 h\u2081) (erase_le_erase _ h\u2082) },\n  { rw cons_inter_of_neg _ h,\n    exact IH ((le_cons_of_not_mem $ mt (mem_of_le h\u2082) h).1 h\u2081) h\u2082 }\nend\n\n@[simp] theorem mem_inter : a \u2208 s \u2229 t \u2194 a \u2208 s \u2227 a \u2208 t :=\n\u27e8\u03bb h, \u27e8mem_of_le (inter_le_left _ _) h, mem_of_le (inter_le_right _ _) h\u27e9,\n \u03bb \u27e8h\u2081, h\u2082\u27e9, by rw [\u2190 cons_erase h\u2081, cons_inter_of_pos _ h\u2082]; apply mem_cons_self\u27e9\n\ninstance : lattice (multiset \u03b1) :=\n{ sup          := (\u222a),\n  sup_le       := @union_le _ _,\n  le_sup_left  := le_union_left,\n  le_sup_right := le_union_right,\n  inf          := (\u2229),\n  le_inf       := @le_inter _ _,\n  inf_le_left  := inter_le_left,\n  inf_le_right := inter_le_right,\n  ..@multiset.partial_order \u03b1 }\n\n@[simp] theorem sup_eq_union (s t : multiset \u03b1) : s \u2294 t = s \u222a t := rfl\n@[simp] theorem inf_eq_inter (s t : multiset \u03b1) : s \u2293 t = s \u2229 t := rfl\n\n@[simp] theorem le_inter_iff : s \u2264 t \u2229 u \u2194 s \u2264 t \u2227 s \u2264 u := le_inf_iff\n@[simp] theorem union_le_iff : s \u222a t \u2264 u \u2194 s \u2264 u \u2227 t \u2264 u := sup_le_iff\n\ntheorem union_comm (s t : multiset \u03b1) : s \u222a t = t \u222a s := sup_comm\ntheorem inter_comm (s t : multiset \u03b1) : s \u2229 t = t \u2229 s := inf_comm\n\ntheorem eq_union_right (h : s \u2264 t) : s \u222a t = t :=\nby rw [union_comm, eq_union_left h]\n\ntheorem union_le_union_left (h : s \u2264 t) (u) : u \u222a s \u2264 u \u222a t :=\nsup_le_sup_left h _\n\ntheorem union_le_add (s t : multiset \u03b1) : s \u222a t \u2264 s + t :=\nunion_le (le_add_right _ _) (le_add_left _ _)\n\ntheorem union_add_distrib (s t u : multiset \u03b1) : (s \u222a t) + u = (s + u) \u222a (t + u) :=\nby simpa [(\u222a), 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 \u03b1) : s + (t \u222a u) = (s + t) \u222a (s + u) :=\nby rw [add_comm, union_add_distrib, add_comm s, add_comm s]\n\ntheorem cons_union_distrib (a : \u03b1) (s t : multiset \u03b1) : a ::\u2098 (s \u222a t) = (a ::\u2098 s) \u222a (a ::\u2098 t) :=\nby simpa using add_union_distrib (a ::\u2098 0) s t\n\ntheorem inter_add_distrib (s t u : multiset \u03b1) : (s \u2229 t) + u = (s + u) \u2229 (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 \u2190 cons_add at hl,\n  exact not_le_of_lt (lt_cons_self (s \u2229 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 \u03b1) : s + (t \u2229 u) = (s + t) \u2229 (s + u) :=\nby rw [add_comm, inter_add_distrib, add_comm s, add_comm s]\n\ntheorem cons_inter_distrib (a : \u03b1) (s t : multiset \u03b1) : a ::\u2098 (s \u2229 t) = (a ::\u2098 s) \u2229 (a ::\u2098 t) :=\nby simp\n\ntheorem union_add_inter (s t : multiset \u03b1) : s \u222a t + s \u2229 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 \u03b1) : s - t + s \u2229 t = s :=\nbegin\n  rw [inter_comm],\n  revert s, refine multiset.induction_on t (by simp) (\u03bb a t IH s, _),\n  by_cases a \u2208 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 \u03b1) : s - (s \u2229 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 : \u03b1 \u2192 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 \u03b1) : multiset \u03b1 :=\nquot.lift_on s (\u03bb l, (filter p l : multiset \u03b1))\n  (\u03bb l\u2081 l\u2082 h, quot.sound $ h.filter p)\n\n@[simp] theorem coe_filter (l : list \u03b1) : filter p (\u2191l) = l.filter p := rfl\n\n@[simp] theorem filter_zero : filter p 0 = 0 := rfl\n\nlemma filter_congr {p q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q]\n  {s : multiset \u03b1} : (\u2200 x \u2208 s, p x \u2194 q x) \u2192 filter p s = filter q s :=\nquot.induction_on s $ \u03bb l h, congr_arg coe $ filter_congr h\n\n@[simp] theorem filter_add (s t : multiset \u03b1) : filter p (s + t) = filter p s + filter p t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, congr_arg coe $ filter_append _ _\n\n@[simp] theorem filter_le (s : multiset \u03b1) : filter p s \u2264 s :=\nquot.induction_on s $ \u03bb l, (filter_sublist _).subperm\n\n@[simp] theorem filter_subset (s : multiset \u03b1) : filter p s \u2286 s :=\nsubset_of_le $ filter_le _ _\n\ntheorem filter_le_filter {s t} (h : s \u2264 t) : filter p s \u2264 filter p t :=\nle_induction_on h $ \u03bb l\u2081 l\u2082 h, (h.filter p).subperm\n\nlemma monotone_filter_left :\n  monotone (filter p) :=\n\u03bb s t, filter_le_filter p\n\nlemma monotone_filter_right (s : multiset \u03b1) \u2983p q : \u03b1 \u2192 Prop\u2984\n  [decidable_pred p] [decidable_pred q] (h : p \u2264 q) :\n  s.filter p \u2264 s.filter q :=\nquotient.induction_on s (\u03bb l, (l.monotone_filter_right h).subperm)\n\nvariable {p}\n\n@[simp] theorem filter_cons_of_pos {a : \u03b1} (s) : p a \u2192 filter p (a ::\u2098 s) = a ::\u2098 filter p s :=\nquot.induction_on s $ \u03bb l h, congr_arg coe $ filter_cons_of_pos l h\n\n@[simp] theorem filter_cons_of_neg {a : \u03b1} (s) : \u00ac p a \u2192 filter p (a ::\u2098 s) = filter p s :=\nquot.induction_on s $ \u03bb l h, @congr_arg _ _ _ _ coe $ filter_cons_of_neg l h\n\n@[simp] theorem mem_filter {a : \u03b1} {s} : a \u2208 filter p s \u2194 a \u2208 s \u2227 p a :=\nquot.induction_on s $ \u03bb l, mem_filter\n\ntheorem of_mem_filter {a : \u03b1} {s} (h : a \u2208 filter p s) : p a :=\n(mem_filter.1 h).2\n\ntheorem mem_of_mem_filter {a : \u03b1} {s} (h : a \u2208 filter p s) : a \u2208 s :=\n(mem_filter.1 h).1\n\ntheorem mem_filter_of_mem {a : \u03b1} {l} (m : a \u2208 l) (h : p a) : a \u2208 filter p l :=\nmem_filter.2 \u27e8m, h\u27e9\n\ntheorem filter_eq_self {s} : filter p s = s \u2194 \u2200 a \u2208 s, p a :=\nquot.induction_on s $ \u03bb l, iff.trans \u27e8\u03bb h,\n  eq_of_sublist_of_length_eq (filter_sublist _) (@congr_arg _ _ _ _ card h),\n  congr_arg coe\u27e9 filter_eq_self\n\ntheorem filter_eq_nil {s} : filter p s = 0 \u2194 \u2200 a \u2208 s, \u00acp a :=\nquot.induction_on s $ \u03bb l, iff.trans \u27e8\u03bb h,\n  eq_nil_of_length_eq_zero (@congr_arg _ _ _ _ card h),\n  congr_arg coe\u27e9 filter_eq_nil\n\ntheorem le_filter {s t} : s \u2264 filter p t \u2194 s \u2264 t \u2227 \u2200 a \u2208 s, p a :=\n\u27e8\u03bb h, \u27e8le_trans h (filter_le _ _), \u03bb a m, of_mem_filter (mem_of_le h m)\u27e9,\n \u03bb \u27e8h, al\u27e9, filter_eq_self.2 al \u25b8 filter_le_filter p h\u27e9\n\ntheorem filter_cons {a : \u03b1} (s : multiset \u03b1) :\n  filter p (a ::\u2098 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 \u03b1) (n : \u2115) :\n  filter p (n \u2022 s) = n \u2022 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 \u03b1] (s t : multiset \u03b1) :\n  filter p (s - t) = filter p s - filter p t :=\nbegin\n  revert s, refine multiset.induction_on t (by simp) (\u03bb 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 \u2208 s,\n    { rw [\u2190 cons_inj_right a, \u2190 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 \u2208 s,\n    { rw [(by rw filter_cons_of_neg _ h : filter p (erase s a) = filter p (a ::\u2098 erase s a)),\n          cons_erase m] },\n    { rw [erase_of_not_mem m] } }\nend\n\n@[simp] theorem filter_union [decidable_eq \u03b1] (s t : multiset \u03b1) :\n  filter p (s \u222a t) = filter p s \u222a filter p t :=\nby simp [(\u222a), union]\n\n@[simp] theorem filter_inter [decidable_eq \u03b1] (s t : multiset \u03b1) :\n  filter p (s \u2229 t) = filter p s \u2229 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\u27e8inf_le_inf (filter_le _ _) (filter_le _ _),\n  \u03bb a h, of_mem_filter (mem_of_le (inter_le_left _ _) h)\u27e9\n\n@[simp] theorem filter_filter (q) [decidable_pred q] (s : multiset \u03b1) :\n  filter p (filter q s) = filter (\u03bb a, p a \u2227 q a) s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ filter_filter p q l\n\ntheorem filter_add_filter (q) [decidable_pred q] (s : multiset \u03b1) :\n  filter p s + filter q s = filter (\u03bb a, p a \u2228 q a) s + filter (\u03bb a, p a \u2227 q a) s :=\nmultiset.induction_on s rfl $ \u03bb a s IH,\nby by_cases p a; by_cases q a; simp *\n\ntheorem filter_add_not (s : multiset \u03b1) :\n  filter p s + filter (\u03bb a, \u00ac 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 : \u03b2 \u2192 \u03b1) (s : multiset \u03b2) :\n  filter p (map f s) = map f (filter (p \u2218 f) s) :=\nquot.induction_on s (\u03bb 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 : \u03b1 \u2192 option \u03b2` 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 : \u03b1 \u2192 option \u03b2) (s : multiset \u03b1) : multiset \u03b2 :=\nquot.lift_on s (\u03bb l, (filter_map f l : multiset \u03b2))\n  (\u03bb l\u2081 l\u2082 h, quot.sound $ h.filter_map f)\n\n@[simp] theorem coe_filter_map (f : \u03b1 \u2192 option \u03b2) (l : list \u03b1) :\n  filter_map f l = l.filter_map f := rfl\n\n@[simp] theorem filter_map_zero (f : \u03b1 \u2192 option \u03b2) : filter_map f 0 = 0 := rfl\n\n@[simp] theorem filter_map_cons_none {f : \u03b1 \u2192 option \u03b2} (a : \u03b1) (s : multiset \u03b1) (h : f a = none) :\n  filter_map f (a ::\u2098 s) = filter_map f s :=\nquot.induction_on s $ \u03bb l, @congr_arg _ _ _ _ coe $ filter_map_cons_none a l h\n\n@[simp] theorem filter_map_cons_some (f : \u03b1 \u2192 option \u03b2)\n  (a : \u03b1) (s : multiset \u03b1) {b : \u03b2} (h : f a = some b) :\n  filter_map f (a ::\u2098 s) = b ::\u2098 filter_map f s :=\nquot.induction_on s $ \u03bb l, @congr_arg _ _ _ _ coe $ filter_map_cons_some f a l h\n\ntheorem filter_map_eq_map (f : \u03b1 \u2192 \u03b2) : filter_map (some \u2218 f) = map f :=\nfunext $ \u03bb s, quot.induction_on s $ \u03bb 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 $ \u03bb s, quot.induction_on s $ \u03bb l,\n@congr_arg _ _ _ _ coe $ congr_fun (filter_map_eq_filter p) l\n\ntheorem filter_map_filter_map (f : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 option \u03b3) (s : multiset \u03b1) :\n  filter_map g (filter_map f s) = filter_map (\u03bb x, (f x).bind g) s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ filter_map_filter_map f g l\n\ntheorem map_filter_map (f : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 \u03b3) (s : multiset \u03b1) :\n  map g (filter_map f s) = filter_map (\u03bb x, (f x).map g) s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ map_filter_map f g l\n\ntheorem filter_map_map (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 option \u03b3) (s : multiset \u03b1) :\n  filter_map g (map f s) = filter_map (g \u2218 f) s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ filter_map_map f g l\n\ntheorem filter_filter_map (f : \u03b1 \u2192 option \u03b2) (p : \u03b2 \u2192 Prop) [decidable_pred p] (s : multiset \u03b1) :\n  filter p (filter_map f s) = filter_map (\u03bb x, (f x).filter p) s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ filter_filter_map f p l\n\ntheorem filter_map_filter (f : \u03b1 \u2192 option \u03b2) (s : multiset \u03b1) :\n  filter_map f (filter p s) = filter_map (\u03bb x, if p x then f x else none) s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ filter_map_filter p f l\n\n@[simp] theorem filter_map_some (s : multiset \u03b1) : filter_map some s = s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ filter_map_some l\n\n@[simp] theorem mem_filter_map (f : \u03b1 \u2192 option \u03b2) (s : multiset \u03b1) {b : \u03b2} :\n  b \u2208 filter_map f s \u2194 \u2203 a, a \u2208 s \u2227 f a = some b :=\nquot.induction_on s $ \u03bb l, mem_filter_map f l\n\ntheorem map_filter_map_of_inv (f : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 \u03b1)\n  (H : \u2200 x : \u03b1, (f x).map g = some x) (s : multiset \u03b1) :\n  map g (filter_map f s) = s :=\nquot.induction_on s $ \u03bb l, congr_arg coe $ map_filter_map_of_inv f g H l\n\ntheorem filter_map_le_filter_map (f : \u03b1 \u2192 option \u03b2) {s t : multiset \u03b1}\n  (h : s \u2264 t) : filter_map f s \u2264 filter_map f t :=\nle_induction_on h $ \u03bb l\u2081 l\u2082 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 \u03b1) : \u2115 :=\nquot.lift_on s (countp p) (\u03bb l\u2081 l\u2082, perm.countp_eq p)\n\n@[simp] theorem coe_countp (l : list \u03b1) : 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 : \u03b1} (s) : p a \u2192 countp p (a ::\u2098 s) = countp p s + 1 :=\nquot.induction_on s $ countp_cons_of_pos p\n\n@[simp] theorem countp_cons_of_neg {a : \u03b1} (s) : \u00ac p a \u2192 countp p (a ::\u2098 s) = countp p s :=\nquot.induction_on s $ countp_cons_of_neg p\n\nvariable (p)\n\ntheorem countp_cons (b : \u03b1) (s) : countp p (b ::\u2098 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 $ \u03bb 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 \u03b1 \u2192+ \u2115 :=\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 \u03b1 \u2192 \u2115) = countp p := rfl\n\n@[simp] theorem countp_sub [decidable_eq \u03b1] {s t : multiset \u03b1} (h : t \u2264 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 \u2264 t) : countp p s \u2264 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 \u03b1) :\n  countp p (filter q s) = countp (\u03bb a, p a \u2227 q a) s :=\nby simp [countp_eq_card_filter]\n\ntheorem countp_map (f : \u03b1 \u2192 \u03b2) (s : multiset \u03b1) (p : \u03b2 \u2192 Prop) [decidable_pred p] :\n  countp p (map f s) = (s.filter (\u03bb a, p (f a))).card :=\nbegin\n  refine multiset.induction_on s _ (\u03bb 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 \u2194 \u2203 a \u2208 s, p a :=\nby simp [countp_eq_card_filter, card_pos_iff_exists_mem]\n\ntheorem countp_pos_of_mem {s a} (h : a \u2208 s) (pa : p a) : 0 < countp p s :=\ncountp_pos.2 \u27e8_, h, pa\u27e9\n\nend\n\n/-! ### Multiplicity of an element -/\n\nsection\nvariable [decidable_eq \u03b1]\n\n/-- `count a s` is the multiplicity of `a` in `s`. -/\ndef count (a : \u03b1) : multiset \u03b1 \u2192 \u2115 := countp (eq a)\n\n@[simp] theorem coe_count (a : \u03b1) (l : list \u03b1) : count a (\u2191l) = l.count a := coe_countp _ _\n\n@[simp] theorem count_zero (a : \u03b1) : count a 0 = 0 := rfl\n\n@[simp] theorem count_cons_self (a : \u03b1) (s : multiset \u03b1) : count a (a ::\u2098 s) = succ (count a s) :=\ncountp_cons_of_pos _ rfl\n\n@[simp, priority 990]\ntheorem count_cons_of_ne {a b : \u03b1} (h : a \u2260 b) (s : multiset \u03b1) : count a (b ::\u2098 s) = count a s :=\ncountp_cons_of_neg _ h\n\ntheorem count_le_of_le (a : \u03b1) {s t} : s \u2264 t \u2192 count a s \u2264 count a t :=\ncountp_le_of_le _\n\ntheorem count_le_count_cons (a b : \u03b1) (s : multiset \u03b1) : count a s \u2264 count a (b ::\u2098 s) :=\ncount_le_of_le _ (le_cons_self _ _)\n\ntheorem count_cons (a b : \u03b1) (s : multiset \u03b1) :\n  count a (b ::\u2098 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 : \u03b1) : count a ({a} : multiset \u03b1) = 1 :=\nby simp only [count_cons_self, singleton_eq_cons, eq_self_iff_true, count_zero]\n\ntheorem count_singleton (a b : \u03b1) : count a ({b} : multiset \u03b1) = 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 : \u03b1) : \u2200 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 : \u03b1) : multiset \u03b1 \u2192+ \u2115 := countp_add_monoid_hom (eq a)\n\n@[simp] lemma coe_count_add_monoid_hom {a : \u03b1} :\n  (count_add_monoid_hom a : multiset \u03b1 \u2192 \u2115) = count a := rfl\n\n@[simp] theorem count_nsmul (a : \u03b1) (n s) : count a (n \u2022 s) = n * count a s :=\nby induction n; simp [*, succ_nsmul', succ_mul, zero_nsmul]\n\ntheorem count_pos {a : \u03b1} {s : multiset \u03b1} : 0 < count a s \u2194 a \u2208 s :=\nby simp [count, countp_pos]\n\n@[simp, priority 980]\ntheorem count_eq_zero_of_not_mem {a : \u03b1} {s : multiset \u03b1} (h : a \u2209 s) : count a s = 0 :=\nby_contradiction $ \u03bb h', h $ count_pos.1 (nat.pos_of_ne_zero h')\n\n@[simp] theorem count_eq_zero {a : \u03b1} {s : multiset \u03b1} : count a s = 0 \u2194 a \u2209 s :=\niff_not_comm.1 $ count_pos.symm.trans pos_iff_ne_zero\n\ntheorem count_ne_zero {a : \u03b1} {s : multiset \u03b1} : count a s \u2260 0 \u2194 a \u2208 s :=\nby simp [ne.def, count_eq_zero]\n\n@[simp] theorem count_repeat_self (a : \u03b1) (n : \u2115) : count a (repeat a n) = n :=\nby simp [repeat]\n\ntheorem count_repeat (a b : \u03b1) (n : \u2115)  :\n  count a (repeat b n) = if (a = b) then n else 0 :=\nbegin\n  split_ifs with h\u2081,\n  { rw [h\u2081, count_repeat_self] },\n  { rw [count_eq_zero],\n    apply mt eq_of_mem_repeat h\u2081 },\nend\n\n@[simp] theorem count_erase_self (a : \u03b1) (s : multiset \u03b1) :\n  count a (erase s a) = pred (count a s) :=\nbegin\n  by_cases a \u2208 s,\n  { rw [(by rw cons_erase h : count a s = count a (a ::\u2098 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 : \u03b1} (ab : a \u2260 b) (s : multiset \u03b1) :\n  count a (erase s b) = count a s :=\nbegin\n  by_cases b \u2208 s,\n  { rw [\u2190 count_cons_of_ne ab, cons_erase h] },\n  { rw [erase_of_not_mem h] }\nend\n\n@[simp] theorem count_sub (a : \u03b1) (s t : multiset \u03b1) : count a (s - t) = count a s - count a t :=\nbegin\n  revert s, refine multiset.induction_on t (by simp) (\u03bb 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 : \u03b1) (s t : multiset \u03b1) :\n  count a (s \u222a t) = max (count a s) (count a t) :=\nby simp [(\u222a), union, tsub_add_eq_max, -add_comm]\n\n@[simp] theorem count_inter (a : \u03b1) (s t : multiset \u03b1) :\n  count a (s \u2229 t) = min (count a s) (count a t) :=\nbegin\n  apply @nat.add_left_cancel (count a (s - t)),\n  rw [\u2190 count_add, sub_add_inter, count_sub, tsub_add_min],\nend\n\nlemma count_sum {m : multiset \u03b2} {f : \u03b2 \u2192 multiset \u03b1} {a : \u03b1} :\n  count a (map f m).sum = sum (m.map $ \u03bbb, count a $ f b) :=\nmultiset.induction_on m (by simp) ( by simp)\n\nlemma count_bind {m : multiset \u03b2} {f : \u03b2 \u2192 multiset \u03b1} {a : \u03b1} :\n  count a (bind m f) = sum (m.map $ \u03bbb, count a $ f b) := count_sum\n\ntheorem le_count_iff_repeat_le {a : \u03b1} {s : multiset \u03b1} {n : \u2115} : n \u2264 count a s \u2194 repeat a n \u2264 s :=\nquot.induction_on s $ \u03bb 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 \u03b1} (h : p a) : count a (filter p s) = count a s :=\nquot.induction_on s $ \u03bb l, count_filter h\n\n@[simp] theorem count_filter_of_neg {p} [decidable_pred p]\n  {a} {s : multiset \u03b1} (h : \u00ac p a) : count a (filter p s) = 0 :=\nmultiset.count_eq_zero_of_not_mem (\u03bb t, h (of_mem_filter t))\n\ntheorem ext {s t : multiset \u03b1} : s = t \u2194 \u2200 a, count a s = count a t :=\nquotient.induction_on\u2082 s t $ \u03bb l\u2081 l\u2082, quotient.eq.trans perm_iff_count\n\n@[ext]\ntheorem ext' {s t : multiset \u03b1} : (\u2200 a, count a s = count a t) \u2192 s = t :=\next.2\n\n@[simp] theorem coe_inter (s t : list \u03b1) : (s \u2229 t : multiset \u03b1) = (s.bag_inter t : list \u03b1) :=\nby ext; simp\n\ntheorem le_iff_count {s t : multiset \u03b1} : s \u2264 t \u2194 \u2200 a, count a s \u2264 count a t :=\n\u27e8\u03bb h a, count_le_of_le a h, \u03bb al,\n by rw \u2190 (ext.2 (\u03bb a, by simp [max_eq_right (al a)]) : s \u222a t = t);\n    apply le_union_left\u27e9\n\ninstance : distrib_lattice (multiset \u03b1) :=\n{ le_sup_inf := \u03bb s t u, le_of_eq $ eq.symm $\n    ext.2 $ \u03bb 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 \u03b1) (a : \u03b1) (n : \u2115) :\n  (repeat a n) \u2293 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 \u03b2] (f : \u03b1 \u2192 \u03b2) (s : multiset \u03b1)\n (hf : set.inj_on f {x : \u03b1 | x \u2208 s}) (x \u2208 s) : (s.map f).count (f x) = s.count x :=\nbegin\n  suffices : (filter (\u03bb (a : \u03b1), f x = f a) s).count x = card (filter (\u03bb (a : \u03b1), f x = f a) s),\n  { rw [count, countp_map, \u2190 this],\n    exact count_filter_of_pos rfl },\n  { rw eq_repeat.2 \u27e8rfl, \u03bb b hb, eq_comm.1 ((hf H (mem_filter.1 hb).left) (mem_filter.1 hb).right)\u27e9,\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 : \u03b1 \u2192 \u03b2 \u2192 Prop) : multiset \u03b1 \u2192 multiset \u03b2 \u2192 Prop\n| zero : rel 0 0\n| cons {a b as bs} : r a b \u2192 rel as bs \u2192 rel (a ::\u2098 as) (b ::\u2098 bs)\n\nvariables {\u03b4 : Type*} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 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\u2080 h\u2081 ih, rel.cons h\u2080 ih)\n\nlemma rel_flip {s t} : rel (flip r) s t \u2194 rel r t s :=\n\u27e8rel_flip_aux, rel_flip_aux\u27e9\n\nlemma rel_refl_of_refl_on {m : multiset \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n  (\u2200 x \u2208 m, r x x) \u2192 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 (\u03bb _ ha, h _ (mem_cons_of_mem ha))) }\nend\n\nlemma rel_eq_refl {s : multiset \u03b1} : rel (=) s s :=\nrel_refl_of_refl_on (\u03bb x hx, rfl)\n\nlemma rel_eq {s t : multiset \u03b1} : rel (=) s t \u2194 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 : \u03b1 \u2192 \u03b2 \u2192 Prop} {s t} (hst : rel r s t) (h : \u2200(a \u2208 s) (b \u2208 t), r a b \u2192 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 (\u03bb 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 \u03b1} : rel (\u03bba b, b = a) s t \u2194 s = t :=\nshow rel (flip (=)) s t \u2194 s = t, by rw [rel_flip, rel_eq, eq_comm]\n\n@[simp] lemma rel_zero_left {b : multiset \u03b2} : rel r 0 b \u2194 b = 0 :=\nby rw [rel_iff]; simp\n\n@[simp] lemma rel_zero_right {a : multiset \u03b1} : rel r a 0 \u2194 a = 0 :=\nby rw [rel_iff]; simp\n\nlemma rel_cons_left {a as bs} :\n  rel r (a ::\u2098 as) bs \u2194 (\u2203b bs', r a b \u2227 rel r as bs' \u2227 bs = b ::\u2098 bs') :=\nbegin\n  split,\n  { generalize hm : a ::\u2098 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 \u27e8eq\u2081, eq\u2082\u27e9 | \u27e8h, cs, eq\u2081, eq\u2082\u27e9,\n      { subst eq\u2081, subst eq\u2082, exact \u27e8b, bs, ha'b, h, rfl\u27e9 },\n      { rcases ih eq\u2082.symm with \u27e8b', bs', h\u2081, h\u2082, eq\u27e9,\n        exact \u27e8b', b ::\u2098 bs', h\u2081, eq\u2081.symm \u25b8 rel.cons ha'b h\u2082, eq.symm \u25b8 cons_swap _ _ _\u27e9 } } },\n  { exact assume \u27e8b, bs', hab, h, eq\u27e9, eq.symm \u25b8 rel.cons hab h }\nend\n\nlemma rel_cons_right {as b bs} :\n  rel r as (b ::\u2098 bs) \u2194 (\u2203a as', r a b \u2227 rel r as' bs \u2227 as = a ::\u2098 as') :=\nbegin\n  rw [\u2190 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\u2080 as\u2081} :\n  \u2200{bs}, rel r (as\u2080 + as\u2081) bs \u2194 (\u2203bs\u2080 bs\u2081, rel r as\u2080 bs\u2080 \u2227 rel r as\u2081 bs\u2081 \u2227 bs = bs\u2080 + bs\u2081) :=\nmultiset.induction_on as\u2080 (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 \u27e8b, bs', hab, h, rfl\u27e9,\n      rcases h with \u27e8bs\u2080, bs\u2081, h\u2080, h\u2081, rfl\u27e9,\n      exact \u27e8b ::\u2098 bs\u2080, bs\u2081, \u27e8b, bs\u2080, hab, h\u2080, rfl\u27e9, h\u2081, by simp\u27e9 },\n    { assume h,\n      rcases h with \u27e8bs\u2080, bs\u2081, h, h\u2081, rfl\u27e9,\n      rcases h with \u27e8b, bs, hab, h\u2080, rfl\u27e9,\n      exact \u27e8b, bs + bs\u2081, hab, \u27e8bs, bs\u2081, h\u2080, h\u2081, rfl\u27e9, by simp\u27e9 }\n  end\n\nlemma rel_add_right {as bs\u2080 bs\u2081} :\n  rel r as (bs\u2080 + bs\u2081) \u2194 (\u2203as\u2080 as\u2081, rel r as\u2080 bs\u2080 \u2227 rel r as\u2081 bs\u2081 \u2227 as = as\u2080 + as\u2081) :=\nby rw [\u2190 rel_flip, rel_add_left]; simp [rel_flip]\n\nlemma rel_map_left {s : multiset \u03b3} {f : \u03b3 \u2192 \u03b1} :\n  \u2200{t}, rel r (s.map f) t \u2194 rel (\u03bba 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 \u03b1} {t : multiset \u03b3} {f : \u03b3 \u2192 \u03b2} :\n  rel r s (t.map f) \u2194 rel (\u03bba b, r a (f b)) s t :=\nby rw [\u2190 rel_flip, rel_map_left, \u2190 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 \u03b1} {t : multiset \u03b2} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4} :\n  rel p (s.map f) (t.map g) \u2194 rel (\u03bba b, p (f a) (g b)) s t :=\nrel_map_left.trans rel_map_right\n\nlemma rel_bind {p : \u03b3 \u2192 \u03b4 \u2192 Prop} {s t} {f : \u03b1 \u2192 multiset \u03b3} {g : \u03b2 \u2192 multiset \u03b4}\n  (h : (r \u21d2 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 (\u03bb a ha b hb hr, h hr) }\n\nlemma card_eq_card_of_rel {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {s : multiset \u03b1} {t : multiset \u03b2} (h : rel r s t) :\n  card s = card t :=\nby induction h; simp [*]\n\nlemma exists_mem_of_rel_of_mem {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {s : multiset \u03b1} {t : multiset \u03b2}\n  (h : rel r s t) :\n  \u2200 {a : \u03b1} (ha : a \u2208 s), \u2203 b \u2208 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 \u27e8y, mem_cons_self _ _, ha.symm \u25b8 hxy\u27e9 },\n    { rcases ih ha with \u27e8b, hbt, hab\u27e9,\n      exact \u27e8b, mem_cons.2 (or.inr hbt), hab\u27e9 } }\nend\n\nlemma rel_of_forall {m1 m2 : multiset \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : \u2200 a b, a \u2208 m1 \u2192 b \u2208 m2 \u2192 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, \u2190 card_eq_zero, hc, card_zero] },\n  { intros a t ih m h hc,\n    rw card_cons at hc,\n    obtain \u27e8b, hb\u27e9 := card_pos_iff_exists_mem.1 (show 0 < card m, from hc.symm \u25b8 (nat.succ_pos _)),\n    obtain \u27e8m', rfl\u27e9 := exists_cons_of_mem hb,\n    refine rel_cons_right.mpr \u27e8b, m', h _ _ hb (mem_cons_self _ _), ih _ _, rfl\u27e9,\n    { exact \u03bb _ _ 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 \u03b1} {a : \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {n : \u2115} :\n  (repeat a n).rel r m \u2194 m.card = n \u2227 \u2200 x, x \u2208 m \u2192 r a x :=\n\u27e8\u03bb h, \u27e8(card_eq_card_of_rel h).symm.trans (card_repeat _ _), \u03bb x hx, begin\n    obtain \u27e8b, hb1, hb2\u27e9 := exists_mem_of_rel_of_mem (rel_flip.2 h) hx,\n    rwa eq_of_mem_repeat hb1 at hb2,\n  end\u27e9,\n  \u03bb h, rel_of_forall (\u03bb x y hx hy, (eq_of_mem_repeat hx).symm \u25b8 (h.2 _ hy))\n  (eq.trans (card_repeat _ _) h.1.symm)\u27e9\n\nlemma rel_repeat_right {m : multiset \u03b1} {a : \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {n : \u2115} :\n  m.rel r (repeat a n) \u2194 m.card = n \u2227 \u2200 x, x \u2208 m \u2192 r x a :=\nby { rw [\u2190 rel_flip], exact rel_repeat_left }\n\nlemma sum_le_sum_of_rel_le [ordered_add_comm_monoid \u03b1]\n  {m1 m2 : multiset \u03b1} (h : m1.rel (\u2264) m2) : m1.sum \u2264 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 \u03b1] {m : multiset \u03b1} {a : \u03b1}\n  (h : a \u2208 m) : a \u2264 m.sum :=\nbegin\n  obtain \u27e8m', rfl\u27e9 := 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 \u03b1]\n\nlemma sum_map_le_sum\n  {m : multiset \u03b1} (f : \u03b1 \u2192 \u03b1) (h : \u2200 x, x \u2208 m \u2192 f x \u2264 x) : (m.map f).sum \u2264 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 \u03b1} (f : \u03b1 \u2192 \u03b1) (h : \u2200 x, x \u2208 m \u2192 x \u2264 f x) : m.sum \u2264 (m.map f).sum :=\n@sum_map_le_sum (order_dual \u03b1) _ _ f h\n\nlemma card_nsmul_le_sum {b : \u03b1}\n  {m : multiset \u03b1} (h : \u2200 x, x \u2208 m \u2192 b \u2264 x) : (card m) \u2022 b \u2264 m.sum :=\nbegin\n  rw [\u2190multiset.sum_repeat, \u2190multiset.map_const],\n  exact sum_map_le_sum _ h,\nend\n\nlemma sum_le_card_nsmul {b : \u03b1}\n  {m : multiset \u03b1} (h : \u2200 x, x \u2208 m \u2192 x \u2264 b) : m.sum \u2264 (card m) \u2022 b :=\nbegin\n  rw [\u2190multiset.sum_repeat, \u2190multiset.map_const],\n  exact sum_le_sum_map _ h,\nend\n\nend sum_inequalities\n\nsection map\n\ntheorem map_eq_map {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) {s t : multiset \u03b1} :\n  s.map f = t.map f \u2194 s = t :=\nby { rw [\u2190 rel_eq, \u2190 rel_eq, rel_map], simp only [hf.eq_iff] }\n\ntheorem map_injective {f : \u03b1 \u2192 \u03b2} (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 : \u03b1 \u2192 \u03b1 \u2192 Prop} {s t : multiset \u03b1} (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 : \u03b1 \u2192 \u03b1 \u2192 Prop} (s : multiset (quot r)) :\n  \u2203t:multiset \u03b1, s = t.map (quot.mk r) :=\nmultiset.induction_on s \u27e80, rfl\u27e9 $\n  assume a s \u27e8t, ht\u27e9, quot.induction_on a $ assume a, ht.symm \u25b8 \u27e8a ::\u2098 t, (map_cons _ _ _).symm\u27e9\n\ntheorem induction_on_multiset_quot\n  {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {p : multiset (quot r) \u2192 Prop} (s : multiset (quot r)) :\n  (\u2200s:multiset \u03b1, p (s.map (quot.mk r))) \u2192 p s :=\nmatch s, exists_multiset_eq_map_quot_mk s with _, \u27e8t, rfl\u27e9 := 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 \u03b1) : Prop := \u2200 \u2983a\u2984, a \u2208 s \u2192 a \u2208 t \u2192 false\n\n@[simp] theorem coe_disjoint (l\u2081 l\u2082 : list \u03b1) : @disjoint \u03b1 l\u2081 l\u2082 \u2194 l\u2081.disjoint l\u2082 := iff.rfl\n\ntheorem disjoint.symm {s t : multiset \u03b1} (d : disjoint s t) : disjoint t s\n| a i\u2082 i\u2081 := d i\u2081 i\u2082\n\ntheorem disjoint_comm {s t : multiset \u03b1} : disjoint s t \u2194 disjoint t s :=\n\u27e8disjoint.symm, disjoint.symm\u27e9\n\ntheorem disjoint_left {s t : multiset \u03b1} : disjoint s t \u2194 \u2200 {a}, a \u2208 s \u2192 a \u2209 t := iff.rfl\n\ntheorem disjoint_right {s t : multiset \u03b1} : disjoint s t \u2194 \u2200 {a}, a \u2208 t \u2192 a \u2209 s :=\ndisjoint_comm\n\ntheorem disjoint_iff_ne {s t : multiset \u03b1} : disjoint s t \u2194 \u2200 a \u2208 s, \u2200 b \u2208 t, a \u2260 b :=\nby simp [disjoint_left, imp_not_comm]\n\ntheorem disjoint_of_subset_left {s t u : multiset \u03b1} (h : s \u2286 u) (d : disjoint u t) : disjoint s t\n| x m\u2081 := d (h m\u2081)\n\ntheorem disjoint_of_subset_right {s t u : multiset \u03b1} (h : t \u2286 u) (d : disjoint s u) : disjoint s t\n| x m m\u2081 := d m (h m\u2081)\n\ntheorem disjoint_of_le_left {s t u : multiset \u03b1} (h : s \u2264 u) : disjoint u t \u2192 disjoint s t :=\ndisjoint_of_subset_left (subset_of_le h)\n\ntheorem disjoint_of_le_right {s t u : multiset \u03b1} (h : t \u2264 u) : disjoint s u \u2192 disjoint s t :=\ndisjoint_of_subset_right (subset_of_le h)\n\n@[simp] theorem zero_disjoint (l : multiset \u03b1) : disjoint 0 l\n| a := (not_mem_nil a).elim\n\n@[simp, priority 1100]\ntheorem singleton_disjoint {l : multiset \u03b1} {a : \u03b1} : disjoint {a} l \u2194 a \u2209 l :=\nby simp [disjoint]; refl\n\n@[simp, priority 1100]\ntheorem disjoint_singleton {l : multiset \u03b1} {a : \u03b1} : disjoint l {a} \u2194 a \u2209 l :=\nby rw [disjoint_comm, singleton_disjoint]\n\n@[simp] theorem disjoint_add_left {s t u : multiset \u03b1} :\n  disjoint (s + t) u \u2194 disjoint s u \u2227 disjoint t u :=\nby simp [disjoint, or_imp_distrib, forall_and_distrib]\n\n@[simp] theorem disjoint_add_right {s t u : multiset \u03b1} :\n  disjoint s (t + u) \u2194 disjoint s t \u2227 disjoint s u :=\nby rw [disjoint_comm, disjoint_add_left]; tauto\n\n@[simp] theorem disjoint_cons_left {a : \u03b1} {s t : multiset \u03b1} :\n  disjoint (a ::\u2098 s) t \u2194 a \u2209 t \u2227 disjoint s t :=\n(@disjoint_add_left _ {a} s t).trans $ by rw singleton_disjoint\n\n@[simp] theorem disjoint_cons_right {a : \u03b1} {s t : multiset \u03b1} :\n  disjoint s (a ::\u2098 t) \u2194 a \u2209 s \u2227 disjoint s t :=\nby rw [disjoint_comm, disjoint_cons_left]; tauto\n\ntheorem inter_eq_zero_iff_disjoint [decidable_eq \u03b1] {s t : multiset \u03b1} : s \u2229 t = 0 \u2194 disjoint s t :=\nby rw \u2190 subset_zero; simp [subset_iff, disjoint]\n\n@[simp] theorem disjoint_union_left [decidable_eq \u03b1] {s t u : multiset \u03b1} :\n  disjoint (s \u222a t) u \u2194 disjoint s u \u2227 disjoint t u :=\nby simp [disjoint, or_imp_distrib, forall_and_distrib]\n\n@[simp] theorem disjoint_union_right [decidable_eq \u03b1] {s t u : multiset \u03b1} :\n  disjoint s (t \u222a u) \u2194 disjoint s t \u2227 disjoint s u :=\nby simp [disjoint, or_imp_distrib, forall_and_distrib]\n\nlemma add_eq_union_iff_disjoint [decidable_eq \u03b1] {s t : multiset \u03b1} :\n  s + t = s \u222a t \u2194 disjoint s t :=\nby simp_rw [\u2190inter_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 : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3} {s : multiset \u03b1} {t : multiset \u03b2} :\n  disjoint (s.map f) (t.map g) \u2194 (\u2200a\u2208s, \u2200b\u2208t, f a \u2260 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) (m : multiset \u03b1) : Prop :=\n\u2203l:list \u03b1, m = l \u2227 l.pairwise r\n\nlemma pairwise_coe_iff_pairwise {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (hr : symmetric r) {l : list \u03b1} :\n  multiset.pairwise r l \u2194 l.pairwise r :=\niff.intro\n  (assume \u27e8l', eq, h\u27e9, ((quotient.exact eq).pairwise_iff hr).2 h)\n  (assume h, \u27e8l, rfl, h\u27e9)\n\nend multiset\n\nnamespace multiset\n\nsection choose\nvariables (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : multiset \u03b1)\n\n/-- Given a proof `hp` that there exists a unique `a \u2208 l` such that `p a`, `choose_x p l hp` returns\nthat `a` together with proofs of `a \u2208 l` and `p a`. -/\ndef choose_x : \u03a0 hp : (\u2203! a, a \u2208 l \u2227 p a), { a // a \u2208 l \u2227 p a } :=\nquotient.rec_on l (\u03bb l' ex_unique, list.choose_x p l' (exists_of_exists_unique ex_unique)) begin\n  intros,\n  funext hp,\n  suffices all_equal : \u2200 x y : { t // t \u2208 b \u2227 p t }, x = y,\n  { apply all_equal },\n  { rintros \u27e8x, px\u27e9 \u27e8y, py\u27e9,\n    rcases hp with \u27e8z, \u27e8z_mem_l, pz\u27e9, z_unique\u27e9,\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 \u2208 l` such that `p a`, `choose p l hp` returns\nthat `a`. -/\ndef choose (hp : \u2203! a, a \u2208 l \u2227 p a) : \u03b1 := choose_x p l hp\n\nlemma choose_spec (hp : \u2203! a, a \u2208 l \u2227 p a) : choose p l hp \u2208 l \u2227 p (choose p l hp) :=\n(choose_x p l hp).property\n\nlemma choose_mem (hp : \u2203! a, a \u2208 l \u2227 p a) : choose p l hp \u2208 l := (choose_spec _ _ _).1\n\nlemma choose_property (hp : \u2203! a, a \u2208 l \u2227 p a) : p (choose p l hp) := (choose_spec _ _ _).2\n\nend choose\n\nvariable (\u03b1)\n\n/-- The equivalence between lists and multisets of a subsingleton type. -/\ndef subsingleton_equiv [subsingleton \u03b1] : list \u03b1 \u2243 multiset \u03b1 :=\n{ to_fun := coe,\n  inv_fun := quot.lift id $ \u03bb (a b : list \u03b1) (h : a ~ b),\n    list.ext_le h.length_eq $ \u03bb n h\u2081 h\u2082, subsingleton.elim _ _,\n  left_inv := \u03bb l, rfl,\n  right_inv := \u03bb m, quot.induction_on m $ \u03bb l, rfl }\n\nvariable {\u03b1}\n\n@[simp]\nlemma coe_subsingleton_equiv [subsingleton \u03b1] :\n  (subsingleton_equiv \u03b1 : list \u03b1 \u2192 multiset \u03b1) = coe :=\nrfl\n\nend multiset\n\n@[to_additive]\ntheorem monoid_hom.map_multiset_prod [comm_monoid \u03b1] [comm_monoid \u03b2] (f : \u03b1 \u2192* \u03b2) (s : multiset \u03b1) :\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], \u00a71.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 \u211a :=\n{ .. show linear_order \u211a, by apply_instance }\n\n-- TODO: for_mathlib\n/-- In a DUNLO, a system of constraints L\u1d62 < x, x < U\u2c7c is solvable\nif and only if L\u1d62 < U\u2c7c 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  (\u2203 x, (\u2200 g \u2208 lower, g < x) \u2227 (\u2200 h \u2208 upper, x < h)) \u2194\n  \u2200 (g \u2208 lower) (h \u2208 upper), g < h :=\nbegin\n  split,\n  { rintro \u27e8x, hx\u2081, hx\u2082\u27e9 g Hg h Hh,\n    exact lt_trans (hx\u2081 g Hg) (hx\u2082 h Hh) },\n  { -- TODO: maybe reformulate all this into a useful lemma:\n    -- (s : finset R) : s = \u2205 \u2228 \u2203 max \u2208 s, \u2200 i \u2208 s, i \u2264 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 : \u2200 g \u2208 lower, g \u2264 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 : \u2200 h \u2208 upper, umin \u2264 h,\n         { intros h H, apply finset.min_le_of_mem H hupper } }] },\n    { simp },\n    { suffices : \u2203 (x : R), \u2200 (h : R), h \u2208 upper \u2192 x < h, { simpa },\n      obtain \u27e8x, hx\u27e9 := no_bot umin,\n      exact \u27e8x, \u03bb h H, lt_of_lt_of_le hx (umin_le h H)\u27e9 },\n    { suffices : \u2203 (x : R), \u2200 (g : R), g \u2208 lower \u2192 g < x, { simpa },\n      obtain \u27e8x, hx\u27e9 := no_top lmax,\n      exact \u27e8x, \u03bb g H, lt_of_le_of_lt (le_lmax g H) hx\u27e9 },\n    { intro Hgh,\n      specialize Hgh lmax (finset.mem_of_max hlower) umin (finset.mem_of_min hupper),\n      obtain \u27e8x, hx\u2081, hx\u2082\u27e9 := exists_between Hgh,\n      exact \u27e8x,\n        \u03bb g H, lt_of_le_of_lt (le_lmax g H) hx\u2081,\n        \u03bb h H, lt_of_lt_of_le hx\u2082 (umin_le h H)\u27e9 } }\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 \u2227 Q\nnotation [parsing_only]  P ` \\or ` Q := P \u2228 Q\nnotation [parsing_only]  ` \\not ` P := \u00ac P\nnotation [parsing_only]  P ` \\implies ` Q := P \u2192 Q\nnotation [parsing_only]  P ` \\iff ` Q := P \u2194 Q\n\n\n------------------\n-- COURSE TITLE --\n------------------\nnamespace Logique_propositionnelle\n\nlemma exercise.tautologie :\nP \u2192 P\n:=\n/- dEAduction\nPrettyName\n    La tautologie\nDescription\n    Le bouton \"=>\" permet de d\u00e9montrer 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 \u2227 Q \u2192 P\n:=\n/- dEAduction\nPrettyName\n    P et Q implique P\nDescription\n    Le bouton \"ET\" permet de d\u00e9couper une hypoth\u00e8se\nAvailableLogic\n    and implicate\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.et_commutatif_I :\nP \u2227 Q \u2192 Q \u2227 P\n:=\n/- dEAduction\nPrettyName\n    Le \"ET\" est commutatif (version faible)\nDescription\n    Le bouton \"ET\" permet aussi de d\u00e9couper 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 \u2227 Q \u2194 Q \u2227 P\n:=\n/- dEAduction\nPrettyName\n    Le \"ET\" est commutatif\nDescription\n    Le bouton \"\u2194\" permet de d\u00e9couper le but en deux implications.\n    On peut alors appliquer le r\u00e9sultat de l'exercice pr\u00e9c\u00e9dent en le\n    s\u00e9lectionnant dans la liste...\nAvailableLogic\n    and iff implicate\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.ou_commutatif :\nP \u2228 Q \u2194 Q \u2228 P\n:=\n/- dEAduction\nPrettyName\n    Le \"OU\" est commutatif\nDescription\n    Pour utiliser l'hypoth\u00e8se \"P OU Q\", on s\u00e9pare les cas :\n    dans le premier cas on suppose P, dans le second cas on suppose Q.\n    Pour d\u00e9montrer \"Q OU P\", on doit d\u00e9montrer soit P, soit Q.\nAvailableLogic\n    and or implicate iff\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\nlemma exercise.non_non :\n\u00ac \u00ac P \u2194 P\n:=\n/- dEAduction\nPrettyName\n    Double n\u00e9gation\nDescription\n    Le bouton \"NON\" permet d'utiliser les r\u00e8gles logiques du \"NON\".\n    On peut l'utiliser uniquement sur les propri\u00e9t\u00e9s qui sont des n\u00e9gations,\n    c'est-\u00e0-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\u00ac (P \u2227 Q) \u2194 (\u00ac P) \u2228 (\u00ac Q)\n:=\n/- dEAduction\nPrettyName\n    N\u00e9gation d'un \"ET\"\nDescription\n    En g\u00e9n\u00e9ral, le bouton \"NON\" tente de \"pousser\" la n\u00e9gation le long de la\n    propri\u00e9t\u00e9.\nAvailableLogic\n    and or negate implicate iff\nAvailableMagic\n    assumption\n-/\nbegin\n    sorry\nend\n\n\nlemma exercise.contradiction :\nR \u2228 \u00ac R\n:=\n/- dEAduction\nPrettyName\n    Le tiers exclu : l'une des deux propri\u00e9t\u00e9s \"R\" et \"NON R\" est vraie\nDescription\n    Le m\u00e9canisme de preuve inclus le tiers exclu, de fa\u00e7on un peu cach\u00e9e...\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 \u2192 Q) \u2194 (\u00ac Q \u2192 \u00ac P)\n:=\n/- dEAduction\nPrettyName\n    Contraposition\nDescription\n    Le bouton \"=>\" permet \u00e9galement d'appliquer une implication \"P => Q\" \u00e0 la\n    propri\u00e9t\u00e9 \"P\" pour obtenir la propri\u00e9t\u00e9 \"Q\". Attention, avant de\n    l'actionner il faut s\u00e9lectionner toutes les propri\u00e9t\u00e9s 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 \u2192 Q) \u2194 (\u00ac P \u2228 Q)\n:=\n/- dEAduction\nPrettyName\n    Implication sous forme de \"OU\"\nDescription\n    Cette propri\u00e9t\u00e9 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 \u2228 Q) \u2194 (\u00ac P \u2192 Q)\n:=\n/- dEAduction\nPrettyName\n    \"OU\" sous forme d'implication\nDescription\n    Cette propri\u00e9t\u00e9 est tr\u00e8s proche de la pr\u00e9c\u00e9dente.\n    On peut la red\u00e9montrer enti\u00e8rement, mais on peut aussi tenter d'appliquer\n    le r\u00e9sultat de l'exercice pr\u00e9c\u00e9dent. Pour cela, il faudra introduire\n    un nouvel objet, avant de lui appliquer le r\u00e9sultat pr\u00e9c\u00e9dent...\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 {\u03b1 \u03b2 : Type _} [TopologicalSpace \u03b1] [TopologicalSpace \u03b2] {f : \u03b1 \u2192 \u03b2}\n\nvariable {s : Set \u03b2} {\u03b9 : Type _} {U : \u03b9 \u2192 Opens \u03b2} (hU : sup\u1d62 U = \u22a4)\n\ntheorem Set.restrictPreimage_inducing (s : Set \u03b2) (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, \u2190 @Filter.comap_comap _ _ _ _ coe f] at h\u22a2\n  intro a\n  rw [\u2190 h, \u2190 inducing_coe.nhds_eq_comap]\n#align set.restrict_preimage_inducing Set.restrictPreimage_inducing\n\nalias Set.restrictPreimage_inducing \u2190 Inducing.restrictPreimage\n#align inducing.restrict_preimage Inducing.restrictPreimage\n\ntheorem Set.restrictPreimage_embedding (s : Set \u03b2) (h : Embedding f) :\n    Embedding (s.restrictPreimage f) :=\n  \u27e8h.1.restrictPreimage s, h.2.restrictPreimage s\u27e9\n#align set.restrict_preimage_embedding Set.restrictPreimage_embedding\n\nalias Set.restrictPreimage_embedding \u2190 Embedding.restrictPreimage\n#align embedding.restrict_preimage Embedding.restrictPreimage\n\ntheorem Set.restrictPreimage_openEmbedding (s : Set \u03b2) (h : OpenEmbedding f) :\n    OpenEmbedding (s.restrictPreimage f) :=\n  \u27e8h.1.restrictPreimage s,\n    (s.range_restrictPreimage f).symm \u25b8 continuous_subtype_val.isOpen_preimage _ h.2\u27e9\n#align set.restrict_preimage_open_embedding Set.restrictPreimage_openEmbedding\n\nalias Set.restrictPreimage_openEmbedding \u2190 OpenEmbedding.restrictPreimage\n#align open_embedding.restrict_preimage OpenEmbedding.restrictPreimage\n\ntheorem Set.restrictPreimage_closedEmbedding (s : Set \u03b2) (h : ClosedEmbedding f) :\n    ClosedEmbedding (s.restrictPreimage f) :=\n  \u27e8h.1.restrictPreimage s,\n    (s.range_restrictPreimage f).symm \u25b8 inducing_subtype_val.isClosed_preimage _ h.2\u27e9\n#align set.restrict_preimage_closed_embedding Set.restrictPreimage_closedEmbedding\n\nalias Set.restrictPreimage_closedEmbedding \u2190 ClosedEmbedding.restrictPreimage\n#align closed_embedding.restrict_preimage ClosedEmbedding.restrictPreimage\n\ntheorem Set.restrictPreimage_isClosedMap (s : Set \u03b2) (H : IsClosedMap f) :\n    IsClosedMap (s.restrictPreimage f) :=\n  by\n  rintro t \u27e8u, hu, e\u27e9\n  refine' \u27e8\u27e8_, (H _ (IsOpen.isClosed_compl hu)).1, _\u27e9\u27e9\n  rw [\u2190 (congr_arg HasCompl.compl e).trans (compl_compl t)]\n  simp only [Set.preimage_compl, compl_inj_iff]\n  ext \u27e8x, hx\u27e9\n  suffices (\u2203 y, y \u2209 u \u2227 f y = x) \u2194 \u2203 y, f y \u2208 s \u2227 y \u2209 u \u2227 f y = x by\n    simpa [Set.restrictPreimage, \u2190 Subtype.coe_inj]\n  exact \u27e8fun \u27e8a, b, c\u27e9 => \u27e8a, c.symm \u25b8 hx, b, c\u27e9, fun \u27e8a, _, b, c\u27e9 => \u27e8a, b, c\u27e9\u27e9\n#align set.restrict_preimage_is_closed_map Set.restrictPreimage_isClosedMap\n\ninclude hU\n\ntheorem isOpen_iff_inter_of_sup\u1d62_eq_top (s : Set \u03b2) : IsOpen s \u2194 \u2200 i, IsOpen (s \u2229 U i) :=\n  by\n  constructor\n  \u00b7 exact fun H i => H.inter (U i).2\n  \u00b7 intro H\n    have : (\u22c3 i, (U i : Set \u03b2)) = Set.univ :=\n      by\n      convert congr_arg coe hU\n      simp\n    rw [\u2190 s.inter_univ, \u2190 this, Set.inter_union\u1d62]\n    exact isOpen_union\u1d62 H\n#align is_open_iff_inter_of_supr_eq_top isOpen_iff_inter_of_sup\u1d62_eq_top\n\ntheorem isOpen_iff_coe_preimage_of_sup\u1d62_eq_top (s : Set \u03b2) :\n    IsOpen s \u2194 \u2200 i, IsOpen (coe \u207b\u00b9' 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\u1d62_eq_top\n  assumption\n#align is_open_iff_coe_preimage_of_supr_eq_top isOpen_iff_coe_preimage_of_sup\u1d62_eq_top\n\ntheorem isClosed_iff_coe_preimage_of_sup\u1d62_eq_top (s : Set \u03b2) :\n    IsClosed s \u2194 \u2200 i, IsClosed (coe \u207b\u00b9' s : Set (U i)) := by\n  simpa using isOpen_iff_coe_preimage_of_sup\u1d62_eq_top hU (s\u1d9c)\n#align is_closed_iff_coe_preimage_of_supr_eq_top isClosed_iff_coe_preimage_of_sup\u1d62_eq_top\n\ntheorem isClosedMap_iff_isClosedMap_of_sup\u1d62_eq_top :\n    IsClosedMap f \u2194 \u2200 i, IsClosedMap ((U i).1.restrictPreimage f) :=\n  by\n  refine' \u27e8fun h i => Set.restrictPreimage_isClosedMap _ h, _\u27e9\n  rintro H s hs\n  rw [isClosed_iff_coe_preimage_of_sup\u1d62_eq_top hU]\n  intro i\n  convert H i _ \u27e8\u27e8_, hs.1, eq_compl_comm.mpr rfl\u27e9\u27e9\n  ext \u27e8x, hx\u27e9\n  suffices (\u2203 y, y \u2208 s \u2227 f y = x) \u2194 \u2203 y, f y \u2208 U i \u2227 y \u2208 s \u2227 f y = x by\n    simpa [Set.restrictPreimage, \u2190 Subtype.coe_inj]\n  exact \u27e8fun \u27e8a, b, c\u27e9 => \u27e8a, c.symm \u25b8 hx, b, c\u27e9, fun \u27e8a, _, b, c\u27e9 => \u27e8a, b, c\u27e9\u27e9\n#align is_closed_map_iff_is_closed_map_of_supr_eq_top isClosedMap_iff_isClosedMap_of_sup\u1d62_eq_top\n\ntheorem inducing_iff_inducing_of_sup\u1d62_eq_top (h : Continuous f) :\n    Inducing f \u2194 \u2200 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, \u2190 @Filter.comap_comap _ _ _ _ coe f]\n  constructor\n  \u00b7 intro H i x\n    rw [\u2190 H, \u2190 inducing_coe.nhds_eq_comap]\n  \u00b7 intro H x\n    obtain \u27e8i, hi\u27e9 :=\n      opens.mem_supr.mp\n        (show f x \u2208 sup\u1d62 U by\n          rw [hU]\n          triv)\n    erw [\u2190 OpenEmbedding.map_nhds_eq (h.1 _ (U i).2).openEmbedding_subtype_val \u27e8x, hi\u27e9]\n    rw [(H i) \u27e8x, hi\u27e9, 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\u1d62_eq_top\n\ntheorem embedding_iff_embedding_of_sup\u1d62_eq_top (h : Continuous f) :\n    Embedding f \u2194 \u2200 i, Embedding ((U i).1.restrictPreimage f) :=\n  by\n  simp_rw [embedding_iff]\n  rw [forall_and]\n  apply and_congr\n  \u00b7 apply inducing_iff_inducing_of_sup\u1d62_eq_top <;> assumption\n  \u00b7 apply Set.injective_iff_injective_of_union\u1d62_eq_univ\n    convert congr_arg coe hU\n    simp\n#align embedding_iff_embedding_of_supr_eq_top embedding_iff_embedding_of_sup\u1d62_eq_top\n\ntheorem openEmbedding_iff_openEmbedding_of_sup\u1d62_eq_top (h : Continuous f) :\n    OpenEmbedding f \u2194 \u2200 i, OpenEmbedding ((U i).1.restrictPreimage f) :=\n  by\n  simp_rw [openEmbedding_iff]\n  rw [forall_and]\n  apply and_congr\n  \u00b7 apply embedding_iff_embedding_of_sup\u1d62_eq_top <;> assumption\n  \u00b7 simp_rw [Set.range_restrictPreimage]\n    apply isOpen_iff_coe_preimage_of_sup\u1d62_eq_top hU\n#align open_embedding_iff_open_embedding_of_supr_eq_top openEmbedding_iff_openEmbedding_of_sup\u1d62_eq_top\n\ntheorem closedEmbedding_iff_closedEmbedding_of_sup\u1d62_eq_top (h : Continuous f) :\n    ClosedEmbedding f \u2194 \u2200 i, ClosedEmbedding ((U i).1.restrictPreimage f) :=\n  by\n  simp_rw [closedEmbedding_iff]\n  rw [forall_and]\n  apply and_congr\n  \u00b7 apply embedding_iff_embedding_of_sup\u1d62_eq_top <;> assumption\n  \u00b7 simp_rw [Set.range_restrictPreimage]\n    apply isClosed_iff_coe_preimage_of_sup\u1d62_eq_top hU\n#align closed_embedding_iff_closed_embedding_of_supr_eq_top closedEmbedding_iff_closedEmbedding_of_sup\u1d62_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\u2081 G\u2082 : 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 \u2192 x = y :=\nby { intro h, cases p, refl, contradiction }\n\nlemma mem_edges (h : e \u2208 darts p) : e.fst \u2208 p.support \u2227 e.snd \u2208 p.support :=\n\u27e8p.dart_fst_mem_support_of_mem_darts h, p.dart_snd_mem_support_of_mem_darts h\u27e9\n\nlemma mem_of_edges (h : 0 < p.length) : u \u2208 p.support \u2194 \u2203 e \u2208 darts p, u \u2208 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 \u27e8(u,v),h\u27e9, simp only [eq_self_iff_true, and_self, true_or, sym2.mem_iff] },\n        { obtain \u27e8e,h2,h3\u27e9 := ih.mp h1, exact \u27e8e, or.inr h2, h3\u27e9 } },\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 \u27e8(\u03bb h, or.cases_on h or.inl (\u03bb h, by { subst h, exact or.inr (start_mem_support _) })),\n        (\u03bb e he h1, or.inr (ih.mpr \u27e8e,he,h1\u27e9))\u27e9 } } }\nend\n\nlemma nodup_concat : (append p p').support.nodup \u2194\n  p.support.nodup \u2227 p'.support.nodup \u2227 (\u2200 u, u \u2208 p.support \u2192 u \u2208 p'.support \u2192 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 \u27e8\u27e8h1,h2\u27e9,h3\u27e9, replace ih := ih.mp h3, refine \u27e8\u27e8h1,ih.1\u27e9,ih.2.1,_,\u03bb u h4 h5, _\u27e9,\n      intro, contradiction, exact ih.2.2 u h4 h5 },\n    { rintros \u27e8\u27e8h1,h2\u27e9,h3,h4,h5\u27e9, refine \u27e8\u27e8h1,_\u27e9,_\u27e9,\n      intro h5, apply h1, rw h4 h5, exact end_mem_support _,\n      refine ih.mpr \u27e8h2,h3,_\u27e9, 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 \u201cforgetting\u201d functors: `objects : Groupoid \u2964 Type`\nand `forget_to_Cat : Groupoid \u2964 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 := \u27e8bundled.of (single_obj punit)\u27e9\n\ninstance str (C : Groupoid.{v u}) : groupoid.{v u} C.\u03b1 := 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 := \u03bb C D, C \u2964 D,\n  id := \u03bb C, \ud835\udfed C,\n  comp := \u03bb C D E F G, F \u22d9 G,\n  id_comp' := \u03bb C D F, by cases F; refl,\n  comp_id' := \u03bb 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} \u2964 Type u :=\n{ obj := bundled.\u03b1,\n  map := \u03bb C D F, F.obj }\n\n/-- Forgetting functor to `Cat` -/\ndef forget_to_Cat : Groupoid.{v u} \u2964 Cat.{v u} :=\n{ obj := \u03bb C, Cat.of C,\n  map := \u03bb C D, id }\n\ninstance forget_to_Cat_full : full forget_to_Cat :=\n{ preimage := \u03bb 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 \u27f6 D) (g : D \u27f6 E) : f \u226b g = f \u22d9 g := rfl\n\n/-- Converts identity in the category of groupoids to the functor identity -/\nlemma id_to_functor {C : Groupoid.{v u}} : \ud835\udfed C = \ud835\udfd9 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 \u2983J : Type u\u2984 (F : J \u2192 Groupoid.{u u}) : limits.fan F :=\nlimits.fan.mk (@of (\u03a0 j : J, F j) _) (\u03bb 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 \u2983J : Type u\u2984 (F : J \u2192 Groupoid.{u u}) :\n  limits.is_limit (pi_limit_fan F) :=\nlimits.mk_fan_limit (pi_limit_fan F)\n(\u03bb s, functor.pi' (\u03bb 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 \u2192 Groupoid.{u u}) : @of (\u03a0 j, f j) _ \u2245 \u220f 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_\u03c0 (J : Type u) (f : J \u2192 Groupoid.{u u}) (j : J) :\n  (pi_iso_pi J f).hom \u226b (limits.pi.\u03c0 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\u2019s 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 : \u2115}\n\n/-- u_stmt and u_wit are fin-indexed collections of polynomials from the square span program -/\nparameter {u_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {u_wit : fin n_wit \u2192 (polynomial F) }\nparameter {v_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {v_wit : fin n_wit \u2192 (polynomial F) }\nparameter {w_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {w_wit : fin n_wit \u2192 (polynomial F) }\n\n-- Defined as integers the exponents are:\n-- def \u03b1 := 0 \n-- def \u03b2 := 1\n-- def \u03b3 := \u22126\n-- def \u03b4 := 4\n-- def \u03b7 := \u22121\n\n-- To sidestep the use of Laurent Polynomials, we instead use\ndef \u03b1 : \u2115 := 6 \ndef \u03b2 : \u2115 := 7\ndef \u03b3 : \u2115 := 0\ndef \u03b4 : \u2115 := 10\ndef \u03b7 : \u2115 := 5\n\n\n/-- The roots of the polynomial t -/\nparameter {r : fin n_wit \u2192 F} \n/-- l is the polynomial divisibility by which is used to verify satisfaction of the QAP -/\ndef l : polynomial F := \u220f 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 \u2192 F ) (a_wit : fin n_wit \u2192 F) := \n((\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 u_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 u_wit i))\n  * \n(\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 v_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 v_wit i))\n  -\n(\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 w_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 w_wit i)))\n   %\u2098 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) ^ (\u03b2 - \u03b1 + \u03b4) * C (u_wit i) \n + (X vars.y) ^ (\u03b2 - \u03b1 + \u03b3) * C (v_wit i) \n + (X vars.y) ^ (2 * \u03b2 - \u03b1) * C (w_wit i) \n@[crs]\ndef crs'_P_\u03b1_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b1\n@[crs]\ndef crs'_P_powers_1 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b2 * C (polynomial.X ^ (i : \u2115)) \n@[crs]\ndef crs'_P_l_1 (i : fin (n_var - 1)) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ (2 * \u03b2 - \u03b1) * C l * C (polynomial.X ^ (i : \u2115)) \n-- @[crs]\n-- def crs'_P_\u03b3_1 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ \u03b3\n@[crs]\ndef crs'_P_\u03b4_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b4\n@[crs]\ndef crs'_P_se_\u03b1_z_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b1 * (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) ^ \u03b2 * (X vars.z) * C (polynomial.X ^ (i : \u2115))  -- Only in S_qap^se\n-- @[crs]\n-- def crs'_P_\u03b1_2 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ \u03b1\n@[crs]\ndef crs'_P_powers_2 (i : fin n_var) : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b2 * C (polynomial.X ^ (i : \u2115)) -- 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) ^ (\u03b2 - \u03b7 + \u03b4) * C (u_stmt i) \n + (X vars.y) ^ (\u03b2 - \u03b7 + \u03b3) * C (v_stmt i) \n + (X vars.y) ^ (2 * \u03b2 - \u03b7) * C (w_stmt i) \n-- @[crs]\n-- def crs'_V_\u03b3_1 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ \u03b3 -- Same as crs'_P_\u03b3_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_\u03b1_2 : mv_polynomial vars (polynomial F) := \n--  (X vars.y) ^ \u03b1\n@[crs]\ndef crs'_V_\u03b4_2 : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ \u03b4\n@[crs]\ndef crs'_V_\u03b7_2 : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ \u03b7\n@[crs]\ndef crs'_V_\u03b3_\u03b4_T : mv_polynomial vars (polynomial F) := \n  (X vars.y) ^ (\u03b3 + \u03b4)\n\n-- Elements both prover and verifier use\n\n@[crs]\ndef crs'_\u03b3_1 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b3\n@[crs]\ndef crs'_\u03b1_2 : mv_polynomial vars (polynomial F) := \n (X vars.y) ^ \u03b1\n\n\nparameters {A_comp_crs'_P_all_wit_1 : fin n_wit \u2192 F}\nparameters {A_comp_crs'_P_\u03b1_1 : F}\nparameters {A_comp_crs'_P_powers_1 : fin n_var \u2192 F}\nparameters {A_comp_crs'_P_l_1 : fin (n_var - 1) \u2192 F}\nparameters {A_comp_crs'_\u03b3_1 : F}\nparameters {A_comp_crs'_P_\u03b4_1 : F}\n-- parameters {A_comp_crs'_P_se_\u03b1_z_1 : F}\n-- parameters {A_comp_crs'_P_se_powers_1 : fin n_var \u2192 F}\nparameters {A_comp_crs'_V_all_stmt_1 : fin n_stmt \u2192 F}\n-- parameters {A_comp_crs'_V_\u03b3_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  \u2211 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_\u03b1_1 * C (polynomial.C (A_comp_crs'_P_\u03b1_1))\n  +\n  \u2211 i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (A_comp_crs'_P_powers_1 i))\n  +\n  \u2211 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'_\u03b3_1 * C (polynomial.C (A_comp_crs'_\u03b3_1))\n  +\n  crs'_P_\u03b4_1 * C (polynomial.C (A_comp_crs'_P_\u03b4_1))\n  +\n  \u2211 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'_\u03b1_2 : F}\nparameters {B_comp_crs'_P_powers_2 : fin n_var \u2192 F}\n-- parameters {B_comp_crs'_V_\u03b1_2 : F} -- Same as previous\nparameters {B_comp_crs'_V_\u03b4_2 : F}\nparameters {B_comp_crs'_V_\u03b7_2 : F}\n\n/-- Polynomial form of B in the adversary's proof representation -/\ndef B' : mv_polynomial vars (polynomial F) := \n  crs'_\u03b1_2 * C (polynomial.C (B_comp_crs'_\u03b1_2))\n  +\n  \u2211 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_\u03b4_2 * C (polynomial.C (B_comp_crs'_V_\u03b4_2))\n  +\n  crs'_V_\u03b7_2 * C (polynomial.C (B_comp_crs'_V_\u03b7_2))\n\n\nparameters {C_comp_crs'_P_all_wit_1 : fin n_wit \u2192 F}\nparameters {C_comp_crs'_P_\u03b1_1 : F}\nparameters {C_comp_crs'_P_powers_1 : fin n_var \u2192 F}\nparameters {C_comp_crs'_P_l_1 : fin (n_var - 1) \u2192 F}\nparameters {C_comp_crs'_P_\u03b3_1 : F}\nparameters {C_comp_crs'_P_\u03b4_1 : F}\n-- parameters {C_comp_crs'_P_se_\u03b1_z_1 : F}\n-- parameters {C_comp_crs'_P_se_powers_1 : fin n_var \u2192 F}\nparameters {C_comp_crs'_V_all_stmt_1 : fin n_stmt \u2192 F}\n-- parameters {C_comp_crs'_V_\u03b3_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  \u2211 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_\u03b1_1 * C (polynomial.C (C_comp_crs'_P_\u03b1_1))\n  +\n  \u2211 i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (C_comp_crs'_P_powers_1 i))\n  +\n  \u2211 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'_\u03b3_1 * C (polynomial.C (C_comp_crs'_P_\u03b3_1))\n  +\n  crs'_P_\u03b4_1 * C (polynomial.C (C_comp_crs'_P_\u03b4_1))\n  +\n  \u2211 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 \u2192 F ) : Prop :=\n  (\u2211 i in finset.fin_range n_stmt, C (polynomial.C (a_stmt i)) * crs'_V_all_stmt_1 i ) * crs'_V_\u03b7_2 \n  +\n  C' * crs'_\u03b1_2 \n  =\n  (A' + crs'_\u03b3_1) * (B' + crs'_V_\u03b4_2) - crs'_V_\u03b3_\u03b4_T \n\n-- A, modified to be more like what we see in Baghery et al. - this includes athe extra y^\u03b3 we see \n-- that the verifier adds.\n\ndef A_mod_comp_crs_P_\u03b3_1 := A_comp_crs'_\u03b3_1 + 1\n\nlemma A_mod_transform : \n  A' + crs'_\u03b3_1 =\n   \u2211 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_\u03b1_1 * C (polynomial.C (A_comp_crs'_P_\u03b1_1))\n  +\n  \u2211 i in (finset.fin_range n_var), (crs'_P_powers_1 i) * C (polynomial.C (A_comp_crs'_P_powers_1 i))\n  +\n  \u2211 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'_\u03b3_1 * C (polynomial.C (A_mod_comp_crs_P_\u03b3_1))\n  +\n  crs'_P_\u03b4_1 * C (polynomial.C (A_comp_crs'_P_\u03b4_1))\n  +\n  \u2211 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_\u03b3_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^\u03b3 we see \n-- that the verifier adds. \n\ndef B_mod_comp_crs_V_\u03b4_2 := B_comp_crs'_V_\u03b4_2 + 1\n\nlemma B_mod_transform : \n  B' + crs'_V_\u03b4_2 =\n  crs'_\u03b1_2 * C (polynomial.C (B_comp_crs'_\u03b1_2))\n  +\n  \u2211 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_\u03b4_2 * C (polynomial.C (B_mod_comp_crs_V_\u03b4_2))\n  +\n  crs'_V_\u03b7_2 * C (polynomial.C (B_comp_crs'_V_\u03b7_2)) :=\nbegin\n  rw [B', B_mod_comp_crs_V_\u03b4_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 \u2194 a = 1 :=\ncalc polynomial.C a = 1 \u2194 polynomial.C a = polynomial.C 1 : by rw polynomial.C_1\n         ... \u2194 a = 1 : polynomial.C_inj\n\n\nlemma simplifier1 (x : fin n_stmt) (a_stmt : fin n_stmt \u2192 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 \u2192 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) %\u2098 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_\u03b3_1_mul (p : polynomial F) : p * polynomial.C A_mod_comp_crs_P_\u03b3_1  = polynomial.C A_mod_comp_crs_P_\u03b3_1 * p := by ring\n\nlemma B_mod_comp_crs_V_\u03b4_2_mul (p : polynomial F) : p * polynomial.C B_mod_comp_crs_V_\u03b4_2  = polynomial.C B_mod_comp_crs_V_\u03b4_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 \u2192 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    (\u2211 (i : fin n_stmt) in finset.fin_range n_stmt, u_stmt i * polynomial.C (a_stmt i) + \u2211 (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    (\u2211 (i : fin n_stmt) in finset.fin_range n_stmt, v_stmt i * polynomial.C (a_stmt i) + \u2211 (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    (\u2211 (i : fin n_stmt) in finset.fin_range n_stmt, w_stmt i * polynomial.C (a_stmt i) + \u2211 (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    \u2211 (x : fin (n_var - 1)) in finset.fin_range (n_var - 1), l * polynomial.X ^ (x : \u2115) * polynomial.C (C_comp_crs'_P_l_1 x),\n  {\n    rw <-sub_eq_iff_eq_add' at this,\n    have h := congr_arg (%\u2098 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 [\u03b1, \u03b2, \u03b3, \u03b4, \u03b7, 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 \u03b1 : \u2115 := 26 \n-- def \u03b2 : \u2115 := 27\n-- def \u03b3 : \u2115 := 0\n-- def \u03b4 : \u2115 := 40\n-- def \u03b7 : \u2115 := 24\n\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 1 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 1\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 1 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 1\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 - (\u03b2-\u03b7) * 1 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 1\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2\n  -- -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 0 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 3\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 1 - (\u03b2-\u03b1) * 2\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 1\n  -- #eval 2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 - (\u03b2-\u03b7) * 2 - (\u03b2-\u03b1) * 2,\n\n\n  have h0012 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 1 + (\u03b2-\u03b1) * 0))) eqn',\n  have h0021 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 1))) eqn',\n  have h0022 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n  -- have h0022 := congr_arg (coeff (single vars.y (46))) eqn',\n  have h0112 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 1 + (\u03b2-\u03b1) * 0))) eqn',\n  have h0121 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 1))) eqn',\n  have h0122 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n  have h0212 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 + (\u03b2-\u03b7) * 1 + (\u03b2-\u03b1) * 0))) eqn',\n  have h0221 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 1))) eqn',\n  have h0222 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 0 + (\u03b4-\u03b2) * 2 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n  have h1022 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n  -- have h1023 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 0 + (\u03b2-\u03b7) * 0 - (\u03b2-\u03b1) * 3))) eqn',\n  have h1112 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 1 + (\u03b2-\u03b1) * 0))) eqn',\n  have h1121 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 1))) eqn',\n  have h1122 := congr_arg (coeff (single vars.y (2 * \u03b2 - (\u03b2-\u03b3) * 1 + (\u03b4-\u03b2) * 1 + (\u03b2-\u03b7) * 0 + (\u03b2-\u03b1) * 0))) eqn',\n\n  simp only [\u03b1, \u03b2, \u03b7, \u03b4, \u03b3, 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_\u03b3_1 *\n      \u2211 (x : fin n_var) in finset.fin_range n_var,\n        polynomial.X ^ (x : \u2115) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n      (\u2211 (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_\u03b7_2 +\n    (\u2211 (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'_\u03b1_2 =\n    \u2211 (x : fin n_stmt) in finset.fin_range n_stmt, v_stmt x * polynomial.C (a_stmt x) +\n      \u2211 (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_\u03b4_1 *\n      \u2211 (x : fin n_var) in finset.fin_range n_var,\n        polynomial.X ^ (x : \u2115) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n    (\u2211 (x : fin n_var) in finset.fin_range n_var,\n       polynomial.X ^ (x : \u2115) * polynomial.C (A_comp_crs'_P_powers_1 x)) *\n            polynomial.C B_mod_comp_crs_V_\u03b4_2 +\n    (\u2211 (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_\u03b7_2 +\n    (\u2211 (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'_\u03b1_2  =\n    \u2211 (x : fin n_stmt) in finset.fin_range n_stmt, u_stmt x * polynomial.C (a_stmt x) +\n      \u2211 (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    (\u2211 (x : fin n_var) in finset.fin_range n_var,\n      polynomial.X ^ (x : \u2115) * polynomial.C (A_comp_crs'_P_powers_1 x)) *\n    \u2211 (x : fin n_var) in finset.fin_range n_var,\n      polynomial.X ^ (x : \u2115) * polynomial.C (B_comp_crs'_P_powers_2 x) +\n    (\u2211 (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_\u03b7_2 +\n    polynomial.C B_comp_crs'_\u03b1_2  * \n      ((\u2211 (x : fin n_wit) in finset.fin_range n_wit, w_wit x * polynomial.C (A_comp_crs'_P_all_wit_1 x)) +\n       (\u2211 (x : fin (n_var - 1)) in finset.fin_range (n_var - 1),\n         l * polynomial.X ^ (x : \u2115) * polynomial.C (A_comp_crs'_P_l_1 x)))\n    =\n    \u2211 (x : fin n_stmt) in finset.fin_range n_stmt, w_stmt x * polynomial.C (a_stmt x) +\n        \u2211 (x : fin n_wit) in finset.fin_range n_wit, w_wit x * polynomial.C (C_comp_crs'_P_all_wit_1 x) +\n      \u2211 (x : fin (n_var - 1)) in\n        finset.fin_range (n_var - 1),\n        l * polynomial.X ^ (x : \u2115) * 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\u03b3\u03b7 : (1 + polynomial.C A_comp_crs'_P_\u03b3_1) * polynomial.C B_comp_crs'_V_\u03b7_2 = 0,\n  -- { rw add_mul, rw <-h5, ring, },\n  -- rw mul_eq_zero at h\u03b3\u03b7,\n\n  -- have h\u03b4\u03b4 : polynomial.C A_comp_crs'_P_\u03b4_1 * (1 + polynomial.C B_comp_crs'_V_\u03b4_2) = 0,\n  -- { rw mul_add, rw <-h0222, ring, },\n  -- rw mul_eq_zero at h\u03b4\u03b4,\n\n  -- have h\u03b3\u03b4 : (1 + polynomial.C A_comp_crs'_P_\u03b3_1) * (1 + polynomial.C B_comp_crs'_V_\u03b4_2) = 1,\n  -- { rw <-sub_eq_zero, rw <-h1122, ring, },\n\n  -- have h\u03b2\u03b2 := h14,\n  -- have h\u03b2\u03b3 := h7,\n  -- have h\u03b2\u03b4 := h17,\n  -- have h\u03b3\u03b3 := h0,\n  -- have h\u03b3\u03b4 := 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\u03b2\u03b3,\n  -- rw <-h\u03b2\u03b4,\n  -- rw <-h\u03b2\u03b2,\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_\u03b4_2_mul],\n    simp only [<-mul_assoc],\n    simp only [A_mod_comp_crs_P_\u03b3_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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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, `\u03b9`, `\u03ba`, `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 \u2243\u2097[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 {\u03b9 : Type*} [decidable_eq \u03b9] [fintype \u03b9]\nvariables (e : basis \u03b9 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 \u2192 R) \u2243\u2097[R] (n \u2192 R)) : m \u2243 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) :\n  m \u2243 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 \u2b1d N) = det (N \u2b1d 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 \u2b1d M) = det (M \u2b1d 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) :\n  det (M \u2b1d N) = det (N \u2b1d 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 [\u2190 det_minor_equiv_self e, \u2190 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 \u2b1d N \u2b1d 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) :\n  det (M \u2b1d N \u2b1d M') = det N :=\nby rw [\u2190 det_comm' hM'M hMM', \u2190 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 {\u03ba : Type*} [fintype \u03ba]\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 \u03ba]\n  (b : basis \u03b9 A M) (c : basis \u03ba A M) (f : M \u2192\u2097[A] M) :\n  det (linear_map.to_matrix b b f) = det (linear_map.to_matrix c c f) :=\nby rw [\u2190 linear_map_to_matrix_mul_basis_to_matrix c b c,\n       \u2190 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 \u03b9 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 \u03b9 A M) \u2192 (M \u2192\u2097[A] M) \u2192* A :=\ntrunc.lift\n  (\u03bb b : basis \u03b9 A M,\n    (det_monoid_hom).comp (to_matrix_alg_equiv b : (M \u2192\u2097[A] M) \u2192* matrix \u03b9 \u03b9 A))\n  (\u03bb 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 \u03b9 A M) (f : M \u2192\u2097[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' {\u03b9' : Type*} [fintype \u03b9'] [decidable_eq \u03b9']\n  (tb : trunc $ basis \u03b9 A M) (b' : basis \u03b9' A M) (f : M \u2192\u2097[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 \u03b9 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 \u03b9 A M) (f g : M \u2192\u2097[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 \u2192\u2097[A] M) \u2192* A :=\nif H : \u2203 (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] : \u21d1(linear_map.det : (M \u2192\u2097[A] M) \u2192* A) =\n  if H : \u2203 (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 \u2192\u2097[A] M) :\n  f.det = matrix.det (linear_map.to_matrix b b f) :=\nhave \u2203 (s : finset M), nonempty (basis s A M),\nfrom \u27e8s, \u27e8b\u27e9\u27e9,\nby rw [linear_map.coe_det, dif_pos, det_aux_def' _ b]; assumption\n\n@[simp] lemma det_to_matrix\n  (b : basis \u03b9 A M) (f : M \u2192\u2097[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' {\u03b9 : Type*} [fintype \u03b9] [decidable_eq \u03b9]\n  (f : (\u03b9 \u2192 A) \u2192\u2097[A] (\u03b9 \u2192 A)) :\n  det f.to_matrix' = f.det :=\nby simp [\u2190 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 \u2192 Prop} (f : M \u2192\u2097[A] M)\n  (hb : \u2200 (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 \u2192\u2097[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 \u2192\u2097[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 {\ud835\udd5c : Type*} [field \ud835\udd5c] {M : Type*} [add_comm_group M] [module \ud835\udd5c M]\n  (c : \ud835\udd5c) (f : M \u2192\u2097[\ud835\udd5c] M) :\n  linear_map.det (c \u2022 f) = c ^ (finite_dimensional.finrank \ud835\udd5c M) * linear_map.det f :=\nbegin\n  by_cases H : \u2203 (s : finset M), nonempty (basis s \ud835\udd5c M),\n  { haveI : finite_dimensional \ud835\udd5c M,\n    { rcases H with \u27e8s, \u27e8hs\u27e9\u27e9, exact finite_dimensional.of_finset_basis hs },\n    simp only [\u2190 det_to_matrix (finite_dimensional.fin_basis \ud835\udd5c M), linear_equiv.map_smul,\n              fintype.card_fin, det_smul] },\n  { classical,\n    have : finite_dimensional.finrank \ud835\udd5c M = 0 := finrank_eq_zero_of_not_exists_basis H,\n    simp [coe_det, H, this] }\nend\n\nlemma det_zero' {\u03b9 : Type*} [fintype \u03b9] [nonempty \u03b9] (b : basis \u03b9 A M) :\n  linear_map.det (0 : M \u2192\u2097[A] M) = 0 :=\nby { haveI := classical.dec_eq \u03b9,\n     rw [\u2190 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 {\ud835\udd5c : Type*} [field \ud835\udd5c] {M : Type*} [add_comm_group M] [module \ud835\udd5c M] :\n  linear_map.det (0 : M \u2192\u2097[\ud835\udd5c] M) = (0 : \ud835\udd5c) ^ (finite_dimensional.finrank \ud835\udd5c M) :=\nby simp only [\u2190 zero_smul \ud835\udd5c (1 : M \u2192\u2097[\ud835\udd5c] 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 \u2192\u2097[A] M) (e : M \u2243\u2097[A] N) :\n  linear_map.det ((e : M \u2192\u2097[A] N) \u2218\u2097 (f \u2218\u2097 (e.symm : N \u2192\u2097[A] M))) = linear_map.det f :=\nbegin\n  classical,\n  by_cases H : \u2203 (s : finset M), nonempty (basis s A M),\n  { rcases H with \u27e8s, \u27e8b\u27e9\u27e9,\n    rw [\u2190 det_to_matrix b f, \u2190 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, \u2190 matrix.mul_assoc, matrix.det_conj],\n    { rw [\u2190 to_matrix_comp, linear_equiv.comp_coe, e.symm_trans_self,\n          linear_equiv.refl_to_linear_map, to_matrix_id] },\n    { rw [\u2190 to_matrix_comp, linear_equiv.comp_coe, e.self_trans_symm,\n          linear_equiv.refl_to_linear_map, to_matrix_id] } },\n  { have H' : \u00ac (\u2203 (t : finset N), nonempty (basis t A N)),\n    { contrapose! H,\n      rcases H with \u27e8s, \u27e8b\u27e9\u27e9,\n      exact \u27e8_, \u27e8(b.map e.symm).reindex_finset_range\u27e9\u27e9 },\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 \u2192\u2097[A] M) (hf : is_unit f) : is_unit f.det :=\nbegin\n  obtain \u27e8g, hg\u27e9 : \u2203 g, f.comp g = 1 := hf.exists_right_inv,\n  have : linear_map.det f * linear_map.det g = 1,\n    by simp only [\u2190 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 {\ud835\udd5c : Type*} [field \ud835\udd5c] [module \ud835\udd5c M]\n  {f : M \u2192\u2097[\ud835\udd5c] M} (hf : f.det = 0) : f.range < \u22a4 :=\nbegin\n  haveI : finite_dimensional \ud835\udd5c M, by simp [f.finite_dimensional_of_det_ne_one, hf],\n  contrapose hf,\n  simp only [lt_top_iff_ne_top, not_not, \u2190 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 {\ud835\udd5c : Type*} [field \ud835\udd5c] [module \ud835\udd5c M]\n  {f : M \u2192\u2097[\ud835\udd5c] M} (hf : f.det = 0) : \u22a5 < f.ker :=\nbegin\n  haveI : finite_dimensional \ud835\udd5c M, by simp [f.finite_dimensional_of_det_ne_one, hf],\n  contrapose hf,\n  simp only [bot_lt_iff_ne_bot, not_not, \u2190 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\u02e3`. -/\nprotected def det : (M \u2243\u2097[R] M) \u2192* R\u02e3 :=\n(units.map (linear_map.det : (M \u2192\u2097[R] M) \u2192* 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 \u2243\u2097[R] M) : \u2191f.det = linear_map.det (f : M \u2192\u2097[R] M) := rfl\n@[simp] lemma coe_inv_det (f : M \u2243\u2097[R] M) : \u2191(f.det\u207b\u00b9) = linear_map.det (f.symm : M \u2192\u2097[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 \u2243\u2097[R] M) : (f.trans g).det = g.det * f.det := map_mul _ g f\n\n@[simp] lemma det_symm (f : M \u2243\u2097[R] M) : f.symm.det = f.det\u207b\u00b9 := 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 \u2243\u2097[R] M) (e : M \u2243\u2097[R] M') :\n  ((e.symm.trans f).trans e).det = f.det :=\nby rw [\u2190units.eq_iff, coe_det, coe_det, \u2190comp_coe, \u2190comp_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 \u2243\u2097[A] M) : (f : M \u2192\u2097[A] M).det * (f.symm : M \u2192\u2097[A] M).det = 1 :=\nby simp [\u2190linear_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 \u2243\u2097[A] M) : (f.symm : M \u2192\u2097[A] M).det * (f : M \u2192\u2097[A] M).det = 1 :=\nby simp [\u2190linear_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 \u2243\u2097[R] M') (v : basis \u03b9 R M) (v' : basis \u03b9 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 \u2243\u2097[A] M) : is_unit (linear_map.det (f : M \u2192\u2097[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 {\ud835\udd5c : Type*} [field \ud835\udd5c] [module \ud835\udd5c M]\n  (f : M \u2243\u2097[\ud835\udd5c] M) : (f.symm : M \u2192\u2097[\ud835\udd5c] M).det = (f : M \u2192\u2097[\ud835\udd5c] M).det \u207b\u00b9 :=\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 \u2192\u2097[R] M'} {v : basis \u03b9 R M} {v' : basis \u03b9 R M'}\n  (h : is_unit (linear_map.to_matrix v v' f).det) : M \u2243\u2097[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)\u207b\u00b9,\n  left_inv := \u03bb x,\n    calc to_lin v' v (to_matrix v v' f)\u207b\u00b9 (f x)\n        = to_lin v v ((to_matrix v v' f)\u207b\u00b9 \u2b1d 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 := \u03bb x,\n    calc f (to_lin v' v (to_matrix v v' f)\u207b\u00b9 x)\n        = to_lin v' v' (to_matrix v v' f \u2b1d (to_matrix v v' f)\u207b\u00b9) 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 \u2192\u2097[R] M'} {v : basis \u03b9 R M} {v' : basis \u03b9 R M'}\n  (h : is_unit (linear_map.to_matrix v v' f).det) :\n  (linear_equiv.of_is_unit_det h : M \u2192\u2097[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  {\ud835\udd5c : Type*} [field \ud835\udd5c] {M : Type*} [add_comm_group M] [module \ud835\udd5c M]\n  [finite_dimensional \ud835\udd5c M] (f : M \u2192\u2097[\ud835\udd5c] M) (hf : linear_map.det f \u2260 0) :\n  M \u2243\u2097[\ud835\udd5c] M :=\nhave is_unit (linear_map.to_matrix (finite_dimensional.fin_basis \ud835\udd5c M)\n  (finite_dimensional.fin_basis \ud835\udd5c 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 \u03b9 :=\n{ to_fun := \u03bb 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 [\u2190function.update_eq_self i v, h, \u2190det_transpose, e.to_matrix_update,\n        \u2190update_row_transpose, \u2190e.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 : \u03b9 \u2192 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 \u2260 0 :=\n\u03bb h, by simpa [h] using e.det_self\n\nlemma is_basis_iff_det {v : \u03b9 \u2192 M} :\n  linear_independent R v \u2227 span R (set.range v) = \u22a4 \u2194 is_unit (e.det v) :=\nbegin\n  split,\n  { rintro \u27e8hli, hspan\u27e9,\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 : \u21d1 v' = v,\n    { ext i, rw [v'_def, basis.map_apply, linear_equiv.of_is_unit_det_apply, e.constr_basis] },\n    rw \u2190 this,\n    exact \u27e8v'.linear_independent, v'.span_eq\u27e9 },\nend\n\nlemma basis.is_unit_det (e' : basis \u03b9 R M) : is_unit (e.det e') :=\n(is_basis_iff_det e).mp \u27e8e'.linear_independent, e'.span_eq\u27e9\n\n/-- Any alternating map to `R` where `\u03b9` 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 \u03b9) : f = f e \u2022 e.det :=\nbegin\n  refine basis.ext_alternating e (\u03bb i h, _),\n  let \u03c3 : equiv.perm \u03b9 := equiv.of_bijective i (fintype.injective_iff_bijective.1 h),\n  change f (e \u2218 \u03c3) = (f e \u2022 e.det) (e \u2218 \u03c3),\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 \u03b9) :\n  f e = 0 \u2194 f = 0 :=\n\u27e8\u03bb h, by simpa [h] using f.eq_smul_basis_det e, \u03bb h, h.symm \u25b8 alternating_map.zero_apply _\u27e9\n\nlemma alternating_map.map_basis_ne_zero_iff (f : alternating_map R M R \u03b9) :\n  f e \u2260 0 \u2194 f \u2260 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 \u03b9 A M) (f : M \u2192\u2097[A] M) (v : \u03b9 \u2192 M) :\n  e.det (f \u2218 v) = f.det * e.det v :=\nby { rw [basis.det_apply, basis.det_apply, \u2190 f.det_to_matrix e, \u2190 matrix.det_mul,\n         e.to_matrix_eq_to_matrix_constr (f \u2218 v), e.to_matrix_eq_to_matrix_constr v,\n         \u2190 to_matrix_comp, e.constr_comp] }\n\nlemma basis.det_reindex {\u03b9' : Type*} [fintype \u03b9'] [decidable_eq \u03b9']\n  (b : basis \u03b9 R M) (v : \u03b9' \u2192 M) (e : \u03b9 \u2243 \u03b9') :\n  (b.reindex e).det v = b.det (v \u2218 e) :=\nby rw [basis.det_apply, basis.to_matrix_reindex', det_reindex_alg_equiv, basis.det_apply]\n\nlemma basis.det_reindex_symm {\u03b9' : Type*} [fintype \u03b9'] [decidable_eq \u03b9']\n  (b : basis \u03b9 R M) (v : \u03b9 \u2192 M) (e : \u03b9' \u2243 \u03b9) :\n  (b.reindex e.symm).det (v \u2218 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 \u03b9 R M) (f : M \u2243\u2097[R] M') (v : \u03b9 \u2192 M') :\n  (b.map f).det v = b.det (f.symm \u2218 v) :=\nby { rw [basis.det_apply, basis.to_matrix_map, basis.det_apply] }\n\nlemma basis.det_map' (b : basis \u03b9 R M) (f : M \u2243\u2097[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 \u03b9).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 : \u03b9 \u2192 M}\n  (hli : linear_independent R v) (hsp : span R (range v) = \u22a4) (i : \u03b9) :\n  (e.det v) \u2022 (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 : \u03b9 \u2192 R\u02e3) : e.det (e.units_smul w) = \u220f 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 : \u03b9 \u2192 R} (hw : \u2200 i, is_unit (w i)) :\n  e.det (e.is_unit_smul hw) = \u220f 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\u00e4rn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David W\u00e4rn\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 \u2964 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 \u2964 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 : \u03a0 {a b : is_free_groupoid.generators G}, (a \u27f6 b) \u2192 ((show G, from a) \u27f6 b))\n(unique_lift : \u2200 {X : Type v} [group X] (f : labelling (is_free_groupoid.generators G) X),\n                \u2203! F : G \u2964 single_obj X, \u2200 a b (g : a \u27f6 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 \u2964 single_obj X)\n  (h : \u2200 a b (e : a \u27f6 b), f.map (of e) = g.map (of e)) :\n  f = g :=\nlet \u27e8_, _, u\u27e9 := @unique_lift G _ _ X _ (\u03bb (a b : generators G) (e : a \u27f6 b), g.map (of e)) in\ntrans (u _ h) (u _ (\u03bb _ _ _, 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 := \u27e8\u03bb a b, { e : fgp.generators G // fgp.of e \u2022 a.back = b.back }\u27e9,\n  of := \u03bb a b e, \u27e8fgp.of e, e.property\u27e9,\n  unique_lift := begin\n    introsI X _ f,\n    let f' : fgp.generators G \u2192 (A \u2192 X) \u22ca[mul_aut_arrow] G :=\n      \u03bb e, \u27e8\u03bb b, @f \u27e8(), _\u27e9 \u27e8(), b\u27e9 \u27e8e, smul_inv_smul _ b\u27e9, fgp.of e\u27e9,\n    rcases fgp.unique_lift f' with \u27e8F', hF', uF'\u27e9,\n    refine \u27e8uncurry F' _, _, _\u27e9,\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 \u27e8\u27e8\u27e9, a : A\u27e9 \u27e8\u27e8\u27e9, b\u27e9 \u27e8e, h : fgp.of e \u2022 a = b\u27e9,\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 [\u2190this, 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 : \u03a0 {a : G}, path (root T) a \u2192 (root' T \u27f6 a)\n| _ path.nil := \ud835\udfd9 _\n| a (path.cons p f) := hom_of_path p \u226b sum.rec_on f.val (\u03bb e, of e) (\u03bb 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 \u27f6 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) = \ud835\udfd9 _ :=\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 \u27f6 b) : End (root' T) :=\ntree_hom T a \u226b p \u226b 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 \u2208 wide_subquiver_symmetrify T a b) :\n  loop_of_hom T (of e) = \ud835\udfd9 (root' T) :=\nbegin\n  rw [loop_of_hom, \u2190category.assoc, is_iso.comp_inv_eq, category.id_comp],\n  cases H,\n  { rw [tree_hom_eq T (path.cons (default _) \u27e8sum.inl e, H\u27e9), hom_of_path], refl },\n  { rw [tree_hom_eq T (path.cons (default _) \u27e8sum.inr e, H\u27e9), 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) \u2192* X) :\n  G \u2964 single_obj X :=\n{ obj := \u03bb _, (),\n  map := \u03bb 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, \u2190End.one_def, f.map_one, id_as_one],\n end,\n  map_comp' := begin\n    intros,\n    rw [comp_as_mul, \u2190f.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 := \u03bb e, loop_of_hom T (of e.val.hom),\n  unique_lift' := begin\n    introsI X _ f,\n    let f' : labelling (generators G) X := \u03bb a b e,\n      if h : e \u2208 wide_subquiver_symmetrify T a b then 1\n      else f \u27e8\u27e8a, b, e\u27e9, h\u27e9,\n    rcases unique_lift f' with \u27e8F', hF', uF'\u27e9,\n    refine \u27e8F'.map_End _, _, _\u27e9,\n    { suffices : \u2200 {x y} (q : x \u27f6 y), F'.map (loop_of_hom T q) = (F'.map q : X),\n      { rintro \u27e8\u27e8a, b, e\u27e9, h\u27e9,\n        rw [functor.map_End_apply, this, hF'],\n        exact dif_neg h },\n      intros,\n      suffices : \u2200 {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 \u27e8e | e, eT\u27e9,\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, \u2190End.one_def, E.map_one] },\n      { exact hE \u27e8\u27e8a, b, e\u27e9, h\u27e9 } }\n  end }\n\nend spanning_tree\n\n/-- Another name for the identity function `G \u2192 G`, to help type checking. -/\nprivate def symgen {G : Type u} [groupoid.{v} G] [is_free_groupoid G] :\n  G \u2192 symmetrify (generators G) := id\n\n/-- If there exists a morphism `a \u2192 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 \u27f6 b) \u2192 nonempty (path (symgen a) (symgen b)) :=\nbegin\n  rintro \u27e8p\u27e9,\n  rw [\u2190weakly_connected_component.eq, eq_comm, \u2190free_group.of_injective.eq_iff, \u2190mul_inv_eq_one],\n  let X := free_group (weakly_connected_component $ symmetrify $ generators G),\n  let f : G \u2192 X := \u03bb g, free_group.of \u2191(symgen g),\n  let F : G \u2964 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 \u27e8hom.to_path (sum.inr e)\u27e9,\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\u27e8\u03bb b, path_nonempty_of_hom (category_theory.nonempty_hom_of_connected_groupoid r b)\u27e9\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 test.random\n\nimport system.random\nimport test.slim_check.liftable\n\nuniverses u v\n\n@[reducible]\ndef gen (\u03b1 : Type u) := reader_t (ulift \u2115) rand \u03b1\n\n-- namespace gen\n\n-- variables {\u03b1 \u03b2 \u03b3 : Type u}\n\n-- protected def pure (x : \u03b1) : gen \u03b1 :=\n-- \u03bb _, pure x\n\n-- protected def bind (x : gen \u03b1) (f : \u03b1 \u2192 gen \u03b2) : gen \u03b2\n--  | sz := do\n-- i \u2190 x sz,\n-- f i sz\n\n-- instance : has_bind gen :=\n-- \u27e8 @gen.bind \u27e9\n\n-- instance : has_pure gen :=\n-- \u27e8 @gen.pure \u27e9\n\n-- lemma bind_assoc (x : gen \u03b1) (f : \u03b1 \u2192 gen \u03b2) (g : \u03b2 \u2192 gen \u03b3)\n-- : x >>= f >>= g = x >>= (\u03bb i, f i >>= g) :=\n-- begin\n--   funext sz,\n--   simp [has_bind.bind],\n--   simp [gen.bind,monad.bind_assoc],\n-- end\n\n-- lemma pure_bind (x : \u03b1) (f : \u03b1 \u2192 gen \u03b2)\n-- : pure x >>= f = f x :=\n-- begin\n--   funext i,\n--   simp [has_bind.bind],\n--   simp [gen.bind,monad.pure_bind],\n--   refl\n-- end\n\n-- lemma id_map (x : gen \u03b1)\n-- : x >>= pure \u2218 id = x :=\n-- begin\n--   funext i,\n--   simp [has_bind.bind,function.comp,pure,has_pure.pure],\n--   simp [gen.bind,gen.pure],\n--   rw monad.bind_pure,\n--   exact \u03b1,\n-- end\n\n-- end gen\n\n-- instance : monad gen :=\n-- { pure := @gen.pure\n-- , bind := @gen.bind\n-- , bind_assoc := @gen.bind_assoc\n-- , pure_bind  := @gen.pure_bind\n-- , id_map := @gen.id_map }\n\nvariable (\u03b1 : Type u)\n\nsection random\n\nvariable [random \u03b1]\n\ndef choose_any : gen \u03b1 :=\n\u27e8 \u03bb _, random.random \u03b1 _ \u27e9\n\nvariables {\u03b1}\n\ndef choose (x y : \u03b1) (p : x \u2264 y . check_range) : gen (x .. y) :=\n\u27e8 \u03bb _, random.random_r _ x y p \u27e9\n\nend random\n\nopen nat (hiding choose)\n\ndef choose_nat (x y : \u2115) (p : x \u2264 y . check_range) : gen (x .. y) := do\n\u27e8z,h\u27e9 \u2190 @choose (fin $ succ y) _ \u27e8x,succ_le_succ p\u27e9 \u27e8y,lt_succ_self _\u27e9 p,\nhave h' : x \u2264 z.val \u2227 z.val \u2264 y,\n  by { simp [fin.le_def] at h, apply h },\nreturn \u27e8z.val,h'\u27e9\n\nopen nat\n\nnamespace gen\n\nvariable {\u03b1}\n\ninstance : liftable gen.{u} gen.{v} :=\nreader_t.liftable' (equiv.ulift.trans equiv.ulift.symm)\nset_option pp.universes true\n-- begin\n--    reader_t.liftable\n-- end\n\nend gen\n\nvariable {\u03b1}\n\ndef sized (cmd : \u2115 \u2192 gen \u03b1) : gen \u03b1 :=\n\u27e8 \u03bb \u27e8sz\u27e9, (cmd sz).run \u27e8sz\u27e9 \u27e9\n\ndef vector_of : \u2200 (n : \u2115) (cmd : gen \u03b1), gen (vector \u03b1 n)\n | 0 _ := return vector.nil\n | (succ n) cmd := vector.cons <$> cmd <*> vector_of n cmd\n\ndef list_of (cmd : gen \u03b1) : gen (list \u03b1) :=\nsized $ \u03bb sz, do\ndo \u27e8 n \u27e9 \u2190 liftable.up' $ choose_nat 0 sz,\n   v \u2190 vector_of n.val cmd,\n   return v.to_list\n\nopen ulift\n\ndef one_of (xs : list (gen \u03b1)) (pos : 0 < xs.length) : gen \u03b1 :=\nhave _inst : random _ := random_fin_of_pos _ pos, do\nn \u2190 liftable.up' $ @choose_any (fin xs.length) _inst,\nlist.nth_le xs (down n).val (down n).is_lt\n", "meta": {"author": "cipher1024", "repo": "slim_check", "sha": "5969b7f72e01fdd46f2502ed0cbf69c0699061d4", "save_path": "github-repos/lean/cipher1024-slim_check", "path": "github-repos/lean/cipher1024-slim_check/slim_check-5969b7f72e01fdd46f2502ed0cbf69c0699061d4/src/test/slim_check/gen.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 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(\ud835\udcaa : presheaf CommRing X) \n(\u2131 : presheaf AddCommGroup X)\n[is_module : \u03a0 (U : (opens X)\u1d52\u1d56), module (\ud835\udcaa.obj U) (\u2131.obj U)]\n(res_compatible : \u03a0 (U V : (opens X)\u1d52\u1d56) (h : U \u27f6 V) (r : \ud835\udcaa.obj U) (a: \u2131.obj U),\n  \u2131.map h (r \u2022 a) = \ud835\udcaa.map h r \u2022 \u2131.map h a)\n\n-- Now I believe this is not the correct definition, because for `h : U \u27f6 V`, `\u2131.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 \u2131 \u22d9 BundledModule.forget\n\nIf `h : U \u2286 V`, then `\u2131.map h` is a pair `\u27e8res\u2081, res\u2082\u27e9`, and `res\u2081` is the restriction map of sheaf of ring while `res\u2082` is the restriction map of sheaf of module.\n-/\n\nclass PresheafOfModules2 {X : Top} (\u2131 : @presheaf BundledModule BundledModule.is_cat X):=\n(res_compatible : \u03a0 (U V : (opens X)\u1d52\u1d56) (h : U \u27f6 V) (r : (\u2131.obj U).R) (m : (\u2131.obj U).M), (\u2131.map h).2 (r \u2022 m) = (r \u2022 (\u2131.map h).2 m))\n\nopen ulift\n\n@[reducible] instance int_as_cring.has_add : has_add (ulift \u2124) :=\n\u27e8\u03bb x y, up (down x + down y)\u27e9\n\n@[simp] lemma int_as_cring.add_def (x y : \u2124) : (up x) + (up y) = up (x + y) := rfl\n\n@[reducible] instance int_as_cring.has_neg : has_neg (ulift \u2124) :=\n\u27e8\u03bb x, up (- down x)\u27e9\n\n@[simp] lemma int_as_cring.neg_def (z : \u2124) : -(up z) = up (- z) := rfl\n\n@[reducible] instance int_as_cring.has_mul : has_mul (ulift \u2124) :=\n\u27e8\u03bb x y, up (down x * down y)\u27e9\n\n@[simp] lemma int_as_cring.mul_def (x y : \u2124) : up x * up y = up (x * y) := rfl\n\ndef int_as_cring : CommRing :=\n{ \u03b1 := ulift \u2124,\n  str := { add_assoc := \u03bb 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 := \u03bb a, begin\n             cases a,\n             dsimp only, rw add_zero,\n           end,\n           zero_add := \u03bb a, begin\n             cases a, dsimp only, rw zero_add,\n           end,\n\n           neg := \u03bb r, up (- down r),\n           add_left_neg := \u03bb 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 := \u03bb 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 := \u03bb 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 := \u03bb 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 := \u03bb a, begin\n             cases a, rw [int_as_cring.mul_def, one_mul],\n           end,\n           mul_one := \u03bb a, begin\n             cases a, rw [int_as_cring.mul_def, mul_one],\n           end,\n\n           left_distrib := \u03bb 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 := \u03bb 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 := \u03bb x y, x.1 \u2022 y,\n  one_smul := \u03bb x, by erw one_zsmul,\n  mul_smul := \u03bb x y r, begin \n    cases x, cases y,\n    rw [int_as_cring.mul_def, mul_zsmul],\n  end,\n  smul_add := \u03bb r x y, by rw zsmul_add,\n  smul_zero := \u03bb r, by rw zsmul_zero }\n\n@[simp] lemma lift_int.zsmul (A : AddCommGroup) (r : int_as_cring) (a : A) : r \u2022 a = r.1 \u2022 a := rfl\n\ninstance is_int_module (A : AddCommGroup) : module int_as_cring A :=\n{ add_smul := \u03bb 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 := \u03bb 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 \u2124 A := by apply_instance\n\n-- @[reducible] def psh_m {X : Top} (\ud835\udcaa : presheaf AddCommGroup X) :\n--   @presheaf BundledModule BundledModule.is_cat X :=\n-- { obj := \u03bb U, { R := int_as_cring, M := { carrier := \ud835\udcaa.obj U, is_module := is_int_module (\ud835\udcaa.obj U)} },\n--   map := \u03bb U V h,\n--     \u27e8\ud835\udfd9 _, { to_fun := \u03bb m, \ud835\udcaa.map h m,\n--             map_add' := \u03bb x y, by rw add_monoid_hom.map_add,\n--             map_smul' := \u03bb 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 }\u27e9 }\n\n\n-- instance {X : Top} (\ud835\udcaa : presheaf AddCommGroup X) :\n--   (PresheafOfModules2 (psh_m \ud835\udcaa)) :=\n-- { res_compatible := \u03bb 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) (\u2131 : @presheaf BundledModule BundledModule.is_cat X) [PresheafOfModules2 \u2131]: PresheafOfModules1 X :=\n{ \ud835\udcaa := { obj := \u03bb U, (\u2131.obj U).R,\n         map := \u03bb _ _ h, (\u2131.map h).1 },\n  \u2131 :=\n    { obj := \u03bb U, AddCommGroup.of (\u2131.obj U).M,\n      map := \u03bb U V h, @AddCommGroup.of_hom (AddCommGroup.of (\u2131.obj U).M) (AddCommGroup.of (\u2131.obj V).M) _ _\n        { to_fun := (\u2131.map h).2,\n          map_zero' :=  linear_map.map_zero _,\n          map_add' := \u03bb m m', begin\n            -- rw linear_map.map_add,\n            sorry,\n          end, }, },\n  is_module := \u03bb U, begin\n    dsimp only [AddCommGroup.coe_of], apply_instance,\n  end,\n  res_compatible := \u03bb 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 := \u03bb U,{ R := psofm.\ud835\udcaa.obj U,\n               M := { carrier := psofm.\u2131.obj U,\n               is_module := psofm.is_module U } },\n  map := \u03bb U V h, \u27e8psofm.\ud835\udcaa.map h,\n        { to_fun := \u03bb m, psofm.\u2131.map h m,\n          map_add' := \u03bb m m', begin\n            dsimp only at *,\n            simp only [add_monoid_hom.map_add],\n          end,\n          map_smul' := \u03bb r m, begin\n            dsimp only at *,\n            rw [ring_hom.id_apply, psofm.res_compatible _ _ h],\n            -- erw (smul_def' (psofm.\ud835\udcaa.map h) r { carrier := psofm.\u2131.obj V,\n            --    is_module := psofm.is_module V } (psofm.\u2131.map h m)).symm,\n\n            sorry,\n          end}\u27e9 }\n\ninstance (X : Top) (psofm : PresheafOfModules1 X) : PresheafOfModules2 (convert_to2 X psofm) :=\n{ res_compatible := \u03bb 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\u2080 hp\u2081 : heap) : Prop :=\n\u2203 hp, some hp\u2081 = part (some hp\u2080) hp\n\ninstance : has_le heap :=\n\u27e8 heap.le \u27e9\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\u2080 h\u2080 hp\u2081 h\u2081,\n                   -- have : hp\u2080 ## hp\u2081, admit,\n                   existsi part hp\u2080 hp\u2081,\n                   simp [h\u2081,h\u2080], ac_refl }\n, le_antisymm := by { introv,\n                      simp [has_le.le,heap.le],\n                      intros hp\u2080 h\u2080 hp\u2081 h\u2081,\n                      simp [h\u2080,part_assoc] at h\u2081,\n                      simp [h\u2081.left] at h\u2080,\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 \u2264 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\u2082 := eq_part'_of_some_eq_part _ _ _ h',\n    rw [h\u2082,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 [\u2190eta 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 [\u2190eta_neg l]; simp [h, mk]\n\nend ILit\n\nnamespace PropForm\n\ndef partitioned [DecidableEq \u03bd]: PropForm \u03bd \u2192 Prop\n  | tr         => True\n  | fls        => True\n  | var _      => True\n  | neg \u03c6      => \u03c6.partitioned\n  | disj \u03c6 \u03c8   => \u03c6.partitioned \u2227 \u03c8.partitioned \u2227 \u2200 v, \u00ac (\u03c6.eval v \u2227 \u03c8.eval v)\n  | conj \u03c6 \u03c8   => \u03c6.partitioned \u2227 \u03c8.partitioned \u2227 (\u03c6.vars \u2229 \u03c8.vars = \u2205)\n  | impl _ _   => False\n  | biImpl _ _ => False\n\ndef listConj (\u03c6s : List (PropForm Var)) : PropForm Var :=\n  \u03c6s.foldr (init := .tr) (f := .conj)\n\ndef listConjTerm' (\u03c6s : List (PropForm Var)) : PropTerm Var :=\n  \u03c6s.foldr (init := \u22a4) (f := (\u27e6\u00b7\u27e7 \u2293 \u00b7)) -- fold using the monocle capybara operator\n\ndef listConjTerm (\u03c6s : List (PropTerm Var)) : PropTerm Var :=\n  \u03c6s.foldr (init := \u22a4) (f := (\u00b7 \u2293 \u00b7)) \n\nopen PropTerm in\ntheorem satisfies_listConjTerm (\u03c6s : List (PropTerm Var)) (\u03c4 : PropAssignment Var) :\n    \u03c4 \u22a8 listConjTerm \u03c6s \u2194 \u2200 \u03c6 \u2208 \u03c6s, \u03c4 \u22a8 \u03c6 := by\n  dsimp [listConjTerm]\n  induction \u03c6s <;> simp_all\n  \n@[simp]\ntheorem listConjTerm_nil : listConjTerm [] = \u22a4 := rfl\n\nlemma mem_vars_foldr_conj (\u03c6s : List (PropForm Var)) (x : Var) :\n    x \u2208 (\u03c6s.foldr (init := PropForm.tr) (f := .conj)).vars \u2194\n      \u2203 i : Fin (\u03c6s.length), x \u2208 (\u03c6s.get i).vars := by\n  induction \u03c6s\n  . simp [PropForm.vars]\n  . next \u03c6 \u03c6s ih =>\n    simp [PropForm.vars, ih, Fin.exists_fin_succ]\n    \ntheorem partitioned_listConj (\u03c6s : List (PropForm Var)) :\n    (listConj \u03c6s).partitioned \u2194\n      \u2200 i : Fin \u03c6s.length, (\u03c6s.get i).partitioned \u2227\n      \u2200 j : Fin \u03c6s.length, i \u2260 j \u2192 (\u03c6s.get i).vars \u2229 (\u03c6s.get j).vars = \u2205 := by\n  induction \u03c6s\n  . dsimp [listConj, partitioned]; simp\n  . next \u03c6 \u03c6s 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 \u03c6 \u2229 vars (List.foldr conj tr \u03c6s) = \u2205 \u2194\n        \u2200 i : Fin (List.length \u03c6s), vars \u03c6 \u2229 vars (List.get \u03c6s i) = \u2205 := 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 : \u2200 i : Fin (List.length \u03c6s),\n        vars (List.get \u03c6s i) \u2229 vars \u03c6 = vars \u03c6 \u2229 vars (List.get \u03c6s i) := by\n      intro i; rw [Finset.inter_comm]\n    have aux3 : \u2200 i : Fin (List.length \u03c6s), \u00ac 0 = Fin.succ i := by\n      intro i; apply Ne.symm; apply Fin.succ_ne_zero\n    aesop\n\ndef arrayConj (\u03c6s : Array (PropForm Var)) : PropForm Var := listConj \u03c6s.data\n\ntheorem mem_vars_arrayConj (\u03c6s : Array (PropForm Var)) (x : Var) :\n    x \u2208 (arrayConj \u03c6s).vars \u2194 \u2203 i : Fin \u03c6s.size, x \u2208 \u03c6s[i].vars :=\n  mem_vars_foldr_conj \u03c6s.data x\n\ntheorem partitioned_arrayConj (\u03c6s : Array (PropForm Var)) :\n    (arrayConj \u03c6s).partitioned \u2194\n      \u2200 i : Fin \u03c6s.size, \u03c6s[i].partitioned \u2227\n      \u2200 j : Fin \u03c6s.size, i \u2260 j \u2192 \u03c6s[i].vars \u2229 \u03c6s[j].vars = \u2205 := by\n  dsimp [arrayConj]; rw [partitioned_listConj]; rfl\n\ndef arrayConjTerm (\u03c6s : Array (PropForm Var)) : PropTerm Var :=\n  \u03c6s.data.foldr (init := \u22a4) (f := fun \u03c6 acc => \u27e6\u03c6\u27e7 \u2293 acc)\n  \ntheorem arrayConjTerm_eq_listConjTerm_data (\u03c6s : Array (PropForm Var)) :\n    arrayConjTerm \u03c6s = listConjTerm (\u03c6s.data.map (\u27e6\u00b7\u27e7)) := by\n  dsimp [arrayConjTerm, listConjTerm]\n  induction \u03c6s.data <;> simp_all\n\n@[simp]\ntheorem mk_arrayConj (\u03c6s : Array (PropForm Var)) : \u27e6arrayConj \u03c6s\u27e7 = arrayConjTerm \u03c6s := by\n  dsimp [arrayConj, listConj, arrayConjTerm]\n  induction \u03c6s.data <;> simp_all\n\nopen PropTerm in\ntheorem satisfies_arrayConjTerm (\u03c6s : Array (PropForm Var)) (\u03c4 : PropAssignment Var) :\n    \u03c4 \u22a8 arrayConjTerm \u03c6s \u2194 \u2200 \u03c6 \u2208 \u03c6s.data, \u03c4 \u22a8 \u27e6\u03c6\u27e7 := by\n  dsimp [arrayConjTerm]\n  induction \u03c6s.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 \u2192 PogElt\n  | disj : Var \u2192 ILit \u2192 ILit \u2192 PogElt\n  | conj : Var \u2192 Cube \u2192 PogElt\nderiving Repr, DecidableEq, Inhabited\n\nnamespace PogElt\n\ndef varNum : PogElt \u2192 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 \u2192 Prop\n  | var _             => true\n  | disj n left right => left.var < n \u2227 right.var < n\n  | conj n args       =>  \u2200 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 : \u2200 i : Fin elts.size, elts[i].args_decreasing\n  inv : \u2200 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 \u27e8i, h'\u27e9\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 \u27e8i, h'\u27e9\n    . case inr h' =>\n      dsimp; cases h'; rw [Array.get_push_eq]\n      exact hwf\n  inv := by\n      intro \u27e8i, h'\u27e9\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 \u27e8i, h'\u27e9\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) \u27e8hleft, hright\u27e9 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 : \u2200 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) \u2192 i < pog.elts.size \u2192 PropForm Var\n  | i, h =>\n    match pog.elts[i], pog.wf \u27e8i, h\u27e9, pog.inv \u27e8i, h\u27e9 with\n    | var x, _, _ => PropForm.var x\n    | disj x left right, \u27e8hleft, hright\u27e9, 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) \u2192 (h : i < pog.elts.size) \u2192 (h' : i < (pog.push pogElt hwf hinv).elts.size) \u2192\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 \u2260 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 \u2264 PNat.natPred y :=\n      by rwa [\u2190succPNat_le_succPNat, \u2190hinv, 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 [\u2190succPNat_lt_succPNat, \u2190hinv, 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' \u2192\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 [\u2190h', toPropForm]\n    split\n    . next h'' =>\n      rw [toPropForm.aux]\n      have heq : \u2200 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' \u2192\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' \u2192 x \u2260 y \u2192\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 [\u2190h']\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' \u2192 x \u2260 l.var \u2192\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\u2081 l\u2082 : ILit) (p p' : Pog) :\n    p.addDisj x l\u2081 l\u2082 = .ok p' \u2192\n    p'.toPropForm (.mkPos x) = .disj (p.toPropForm l\u2081) (p.toPropForm l\u2082) := 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 [\u2190h', toPropForm]\n          split\n          . next h'' =>\n            rw [toPropForm.aux]\n            have heq : \u2200 h1 h2,\n                (push p (disj x l\u2081 l\u2082) h1 h2).elts[PNat.natPred (ILit.var (ILit.mkPos x))] =\n                  disj x l\u2081 l\u2082 :=\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\u2081 heq\u2082 heq\u2083\n              cases heq\u2081\n              cases heq\u2082\n              cases heq\u2083\n              simp only [PropForm.withPolarity_mkPos, PropForm.disj.injEq]\n              constructor\n              . rw [toPropForm, dif_pos, toPropForm_push_of_lt.aux]\n                rwa [\u2190succPNat_lt_succPNat, PNat.succPNat_natPred, \u2190h]\n              . rw [toPropForm, dif_pos, toPropForm_push_of_lt.aux]\n                rwa [\u2190succPNat_lt_succPNat, PNat.succPNat_natPred, \u2190h]\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\u2081 l\u2082 : ILit) (p p' : Pog) :\n    p.addDisj x l\u2081 l\u2082 = .ok p' \u2192 x \u2260 y \u2192\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 [\u2190h']\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\u2081 l\u2082 : ILit) (p p' : Pog) :\n    p.addDisj x l\u2081 l\u2082 = .ok p' \u2192 x \u2260 l.var \u2192\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' \u2192\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 [\u2190h', toPropForm]\n        split\n        . next h'' =>\n          rw [toPropForm.aux]\n          have heq : \u2200 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\u2081 heq\u2082\n            cases heq\u2081\n            cases heq\u2082\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\u2081 hj\u2082\n              simp only [getElem_fin, Array.getElem_ofFn, Array.getElem_map]\n              rw [toPropForm, dif_pos, toPropForm_push_of_lt.aux]\n              rw [\u2190succPNat_lt_succPNat, PNat.succPNat_natPred, \u2190h]\n              rw [Array.size_ofFn] at hj\u2081\n              apply hargs \u27e8j, hj\u2081\u27e9\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' \u2192 x \u2260 y \u2192\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 [\u2190h']\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' \u2192 x \u2260 l.var \u2192\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 \u2208 pog.vars \u2194 n \u2264 pog.elts.size := by\n  simp only [Pog.vars, Finset.mem_image, Finset.mem_range]\n  constructor\n  . rintro \u27e8m, hm, rfl\u27e9\n    exact hm\n  . rintro hle\n    use n.natPred\n    rw [lt_iff_add_one_le, \u2190succ_eq_add_one, \u2190succPNat_coe, PNat.succPNat_natPred]\n    exact \u27e8hle, rfl\u27e9\n\ntheorem mem_vars {pog : Pog} {n : Var} :\n    n \u2208 pog.vars \u2194 \u2203 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 [\u2190succPNat_coe, PNat.succPNat_natPred]\n      exact hle\n    use \u27e8n.natPred, this\u27e9\n    rw [\u2190PNat.natPred_inj]\n    symm; apply pog.inv \u27e8n.natPred, this\u27e9\n  . rintro \u27e8i, rfl\u27e9\n    have := congr_arg succPNat (pog.inv i)\n    rw [PNat.succPNat_natPred] at this\n    rw [\u2190this, 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, \u2190Nat.lt_succ, \u2190succ_eq_add_one, \u2190succPNat_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 [\u2190h, 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 [\u2190h, 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 [\u2190h, 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\u00f6lzl, Patrick Massot, S\u00e9bastien Gou\u00ebzel, 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 `\u2243\u209c`.\n\n# Main definitions\n\n* `homeomorph \u03b1 \u03b2`: The type of homeomorphisms from `\u03b1` to `\u03b2`.\n  This type can be denoted using the following notation: `\u03b1 \u2243\u209c \u03b2`.\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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\n\n/-- Homeomorphism between `\u03b1` and `\u03b2`, also called topological isomorphism -/\n@[nolint has_nonempty_instance] -- not all spaces are homeomorphic to each other\nstructure homeomorph (\u03b1 : Type*) (\u03b2 : Type*) [topological_space \u03b1] [topological_space \u03b2]\n  extends \u03b1 \u2243 \u03b2 :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\ninfix ` \u2243\u209c `:25 := homeomorph\n\nnamespace homeomorph\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4]\n\ninstance : has_coe_to_fun (\u03b1 \u2243\u209c \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := \u27e8\u03bbe, e.to_equiv\u27e9\n\n@[simp] lemma homeomorph_mk_coe (a : equiv \u03b1 \u03b2) (b c) :\n  ((homeomorph.mk a b c) : \u03b1 \u2192 \u03b2) = a :=\nrfl\n\n/-- Inverse of a homeomorphism. -/\nprotected def symm (h : \u03b1 \u2243\u209c \u03b2) : \u03b2 \u2243\u209c \u03b1 :=\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 : \u03b1 \u2243\u209c \u03b2) : \u03b1 \u2192 \u03b2 := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : \u03b1 \u2243\u209c \u03b2) : \u03b2 \u2192 \u03b1 := h.symm\n\ninitialize_simps_projections homeomorph\n  (to_equiv_to_fun \u2192 apply, to_equiv_inv_fun \u2192 symm_apply, -to_equiv)\n\n@[simp] lemma coe_to_equiv (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h.to_equiv = h := rfl\n@[simp] lemma coe_symm_to_equiv (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h.to_equiv.symm = h.symm := rfl\n\nlemma to_equiv_injective : function.injective (to_equiv : \u03b1 \u2243\u209c \u03b2 \u2192 \u03b1 \u2243 \u03b2)\n| \u27e8e, h\u2081, h\u2082\u27e9 \u27e8e', h\u2081', h\u2082'\u27e9 rfl := rfl\n\n@[ext] lemma ext {h h' : \u03b1 \u2243\u209c \u03b2} (H : \u2200 x, h x = h' x) : h = h' :=\nto_equiv_injective $ equiv.ext H\n\n@[simp] lemma symm_symm (h : \u03b1 \u2243\u209c \u03b2) : h.symm.symm = h := ext $ \u03bb _, rfl\n\n/-- Identity map as a homeomorphism. -/\n@[simps apply {fully_applied := ff}]\nprotected def refl (\u03b1 : Type*) [topological_space \u03b1] : \u03b1 \u2243\u209c \u03b1 :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  to_equiv := equiv.refl \u03b1 }\n\n/-- Composition of two homeomorphisms. -/\nprotected def trans (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b2 \u2243\u209c \u03b3) : \u03b1 \u2243\u209c \u03b3 :=\n{ continuous_to_fun  := h\u2082.continuous_to_fun.comp h\u2081.continuous_to_fun,\n  continuous_inv_fun := h\u2081.continuous_inv_fun.comp h\u2082.continuous_inv_fun,\n  to_equiv := equiv.trans h\u2081.to_equiv h\u2082.to_equiv }\n\n@[simp] lemma trans_apply (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b2 \u2243\u209c \u03b3) (a : \u03b1) : h\u2081.trans h\u2082 a = h\u2082 (h\u2081 a) := rfl\n\n@[simp] lemma homeomorph_mk_coe_symm (a : equiv \u03b1 \u03b2) (b c) :\n  ((homeomorph.mk a b c).symm : \u03b2 \u2192 \u03b1) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (homeomorph.refl \u03b1).symm = homeomorph.refl \u03b1 := rfl\n\n@[continuity]\nprotected lemma continuous (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : continuous (h.symm) := h.continuous_inv_fun\n\n@[simp] lemma apply_symm_apply (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b2) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\n@[simp] lemma self_trans_symm (h : \u03b1 \u2243\u209c \u03b2) : h.trans h.symm = homeomorph.refl \u03b1 :=\nby { ext, apply symm_apply_apply }\n\n@[simp] lemma symm_trans_self (h : \u03b1 \u2243\u209c \u03b2) : h.symm.trans h = homeomorph.refl \u03b2 :=\nby { ext, apply apply_symm_apply }\n\nprotected lemma bijective (h : \u03b1 \u2243\u209c \u03b2) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : \u03b1 \u2243\u209c \u03b2) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) (g : \u03b2 \u2192 \u03b1) (hg : function.right_inverse g f) : \u03b1 \u2243\u209c \u03b2 :=\nhave g = f.symm, from funext (\u03bb 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 : \u03b1 \u2243\u209c \u03b2) : \u21d1h.symm \u2218 \u21d1h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h \u2218 \u21d1h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : \u03b1 \u2243\u209c \u03b2) : range h = univ :=\nh.surjective.range_eq\n\nlemma image_symm (h : \u03b1 \u2243\u209c \u03b2) : image h.symm = preimage h :=\nfunext h.symm.to_equiv.image_eq_preimage\n\nlemma preimage_symm (h : \u03b1 \u2243\u209c \u03b2) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h '' (h \u207b\u00b9' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h \u207b\u00b9' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma inducing (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : topological_space.induced h \u2039_\u203a = \u2039_\u203a := h.inducing.1.symm\n\nprotected lemma quotient_map (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : topological_space.coinduced h \u2039_\u203a = \u2039_\u203a :=\nh.quotient_map.2.symm\n\nprotected lemma embedding (h : \u03b1 \u2243\u209c \u03b2) : embedding h :=\n\u27e8h.inducing, h.injective\u27e9\n\n/-- Homeomorphism given an embedding. -/\nnoncomputable def of_embedding (f : \u03b1 \u2192 \u03b2) (hf : embedding f) : \u03b1 \u2243\u209c (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 \u03b2]\n  (h : \u03b1 \u2243\u209c \u03b2) :\n  topological_space.second_countable_topology \u03b1 :=\nh.inducing.second_countable_topology\n\nlemma is_compact_image {s : set \u03b1} (h : \u03b1 \u2243\u209c \u03b2) : is_compact (h '' s) \u2194 is_compact s :=\nh.embedding.is_compact_iff_is_compact_image.symm\n\nlemma is_compact_preimage {s : set \u03b2} (h : \u03b1 \u2243\u209c \u03b2) : is_compact (h \u207b\u00b9' s) \u2194 is_compact s :=\nby rw \u2190 image_symm; exact h.symm.is_compact_image\n\n@[simp] lemma comap_cocompact (h : \u03b1 \u2243\u209c \u03b2) : comap h (cocompact \u03b2) = cocompact \u03b1 :=\n(comap_cocompact_le h.continuous).antisymm $\n  (has_basis_cocompact.le_basis_iff (has_basis_cocompact.comap h)).2 $ \u03bb K hK,\n    \u27e8h \u207b\u00b9' K, h.is_compact_preimage.2 hK, subset.rfl\u27e9\n\n@[simp] lemma map_cocompact (h : \u03b1 \u2243\u209c \u03b2) : map h (cocompact \u03b1) = cocompact \u03b2 :=\nby rw [\u2190 h.comap_cocompact, map_comap_of_surjective h.surjective]\n\nprotected lemma compact_space [compact_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : compact_space \u03b2 :=\n{ is_compact_univ := by { rw [\u2190 image_univ_of_surjective h.surjective, h.is_compact_image],\n    apply compact_space.is_compact_univ } }\n\nprotected lemma t0_space [t0_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : t0_space \u03b2 :=\nh.symm.embedding.t0_space\n\nprotected lemma t1_space [t1_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : t1_space \u03b2 :=\nh.symm.embedding.t1_space\n\nprotected lemma t2_space [t2_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : t2_space \u03b2 :=\nh.symm.embedding.t2_space\n\nprotected lemma t3_space [t3_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : t3_space \u03b2 :=\nh.symm.embedding.t3_space\n\nprotected lemma dense_embedding (h : \u03b1 \u2243\u209c \u03b2) : dense_embedding h :=\n{ dense   := h.surjective.dense_range,\n  .. h.embedding }\n\n@[simp] lemma is_open_preimage (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b2} : is_open (h \u207b\u00b9' s) \u2194 is_open s :=\nh.quotient_map.is_open_preimage\n\n@[simp] lemma is_open_image (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} : is_open (h '' s) \u2194 is_open s :=\nby rw [\u2190 preimage_symm, is_open_preimage]\n\nprotected lemma is_open_map (h : \u03b1 \u2243\u209c \u03b2) : is_open_map h := \u03bb s, h.is_open_image.2\n\n@[simp] lemma is_closed_preimage (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b2} : is_closed (h \u207b\u00b9' s) \u2194 is_closed s :=\nby simp only [\u2190 is_open_compl_iff, \u2190 preimage_compl, is_open_preimage]\n\n@[simp] lemma is_closed_image (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} : is_closed (h '' s) \u2194 is_closed s :=\nby rw [\u2190 preimage_symm, is_closed_preimage]\n\nprotected lemma is_closed_map (h : \u03b1 \u2243\u209c \u03b2) : is_closed_map h := \u03bb s, h.is_closed_image.2\n\nprotected lemma open_embedding (h : \u03b1 \u2243\u209c \u03b2) : open_embedding h :=\nopen_embedding_of_embedding_open h.embedding h.is_open_map\n\nprotected lemma closed_embedding (h : \u03b1 \u2243\u209c \u03b2) : closed_embedding h :=\nclosed_embedding_of_embedding_closed h.embedding h.is_closed_map\n\nprotected lemma normal_space [normal_space \u03b1] (h : \u03b1 \u2243\u209c \u03b2) : normal_space \u03b2 :=\nh.symm.closed_embedding.normal_space\n\nlemma preimage_closure (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h \u207b\u00b9' (closure s) = closure (h \u207b\u00b9' s) :=\nh.is_open_map.preimage_closure_eq_closure_preimage h.continuous _\n\nlemma image_closure (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h '' (closure s) = closure (h '' s) :=\nby rw [\u2190 preimage_symm, preimage_closure]\n\n\n\nlemma image_interior (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h '' (interior s) = interior (h '' s) :=\nby rw [\u2190 preimage_symm, preimage_interior]\n\nlemma preimage_frontier (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h \u207b\u00b9' (frontier s) = frontier (h \u207b\u00b9' s) :=\nh.is_open_map.preimage_frontier_eq_frontier_preimage h.continuous _\n\nlemma image_frontier (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h '' frontier s = frontier (h '' s) :=\nby rw [\u2190preimage_symm, preimage_frontier]\n\n@[to_additive]\nlemma _root_.has_compact_mul_support.comp_homeomorph {M} [has_one M] {f : \u03b2 \u2192 M}\n  (hf : has_compact_mul_support f) (\u03c6 : \u03b1 \u2243\u209c \u03b2) : has_compact_mul_support (f \u2218 \u03c6) :=\nhf.comp_closed_embedding \u03c6.closed_embedding\n\n@[simp] lemma map_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : map h (\ud835\udcdd x) = \ud835\udcdd (h x) :=\nh.embedding.map_nhds_of_mem _ (by simp)\n\nlemma symm_map_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : map h.symm (\ud835\udcdd (h x)) = \ud835\udcdd x :=\nby rw [h.symm.map_nhds_eq, h.symm_apply_apply]\n\nlemma nhds_eq_comap (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : \ud835\udcdd x = comap h (\ud835\udcdd (h x)) :=\nh.embedding.to_inducing.nhds_eq_comap x\n\n@[simp] lemma comap_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (y : \u03b2) : comap h (\ud835\udcdd y) = \ud835\udcdd (h.symm y) :=\nby rw [h.nhds_eq_comap, h.apply_symm_apply]\n\n/-- If an bijective map `e : \u03b1 \u2243 \u03b2` is continuous and open, then it is a homeomorphism. -/\ndef homeomorph_of_continuous_open (e : \u03b1 \u2243 \u03b2) (h\u2081 : continuous e) (h\u2082 : is_open_map e) :\n  \u03b1 \u2243\u209c \u03b2 :=\n{ continuous_to_fun := h\u2081,\n  continuous_inv_fun := begin\n    rw continuous_def,\n    intros s hs,\n    convert \u2190 h\u2082 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 : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (s : set \u03b3) :\n  continuous_on (h \u2218 f) s \u2194 continuous_on f s :=\nh.inducing.continuous_on_iff.symm\n\n@[simp] lemma comp_continuous_iff (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b3 \u2192 \u03b1} :\n  continuous (h \u2218 f) \u2194 continuous f :=\nh.inducing.continuous_iff.symm\n\n@[simp] lemma comp_continuous_iff' (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b2 \u2192 \u03b3} :\n  continuous (f \u2218 h) \u2194 continuous f :=\nh.quotient_map.continuous_iff.symm\n\nlemma comp_continuous_at_iff (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (x : \u03b3) :\n  continuous_at (h \u2218 f) x \u2194 continuous_at f x :=\nh.inducing.continuous_at_iff.symm\n\nlemma comp_continuous_at_iff' (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b2 \u2192 \u03b3) (x : \u03b1) :\n  continuous_at (f \u2218 h) x \u2194 continuous_at f (h x) :=\nh.inducing.continuous_at_iff' (by simp)\n\nlemma comp_continuous_within_at_iff (h : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (s : set \u03b3) (x : \u03b3) :\n  continuous_within_at f s x \u2194 continuous_within_at (h \u2218 f) s x :=\nh.inducing.continuous_within_at_iff\n\n@[simp] lemma comp_is_open_map_iff (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b3 \u2192 \u03b1} :\n  is_open_map (h \u2218 f) \u2194 is_open_map f :=\nbegin\n  refine \u27e8_, \u03bb hf, h.is_open_map.comp hf\u27e9,\n  intros hf,\n  rw [\u2190 function.comp.left_id f, \u2190 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 : \u03b1 \u2243\u209c \u03b2) {f : \u03b2 \u2192 \u03b3} :\n  is_open_map (f \u2218 h) \u2194 is_open_map f :=\nbegin\n  refine \u27e8_, \u03bb hf, hf.comp h.is_open_map\u27e9,\n  intros hf,\n  rw [\u2190 function.comp.right_id f, \u2190 h.self_comp_symm, \u2190 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 \u03b1} (h : s = t) : s \u2243\u209c 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\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) : \u03b1 \u2295 \u03b3 \u2243\u209c \u03b2 \u2295 \u03b4 :=\n{ continuous_to_fun  := h\u2081.continuous.sum_map h\u2082.continuous,\n  continuous_inv_fun := h\u2081.symm.continuous.sum_map h\u2082.symm.continuous,\n  to_equiv := h\u2081.to_equiv.sum_congr h\u2082.to_equiv }\n\n/-- Product of two homeomorphisms. -/\ndef prod_congr (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) : \u03b1 \u00d7 \u03b3 \u2243\u209c \u03b2 \u00d7 \u03b4 :=\n{ continuous_to_fun  := (h\u2081.continuous.comp continuous_fst).prod_mk\n    (h\u2082.continuous.comp continuous_snd),\n  continuous_inv_fun := (h\u2081.symm.continuous.comp continuous_fst).prod_mk\n    (h\u2082.symm.continuous.comp continuous_snd),\n  to_equiv := h\u2081.to_equiv.prod_congr h\u2082.to_equiv }\n\n@[simp] lemma prod_congr_symm (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) :\n  (h\u2081.prod_congr h\u2082).symm = h\u2081.symm.prod_congr h\u2082.symm := rfl\n\n@[simp] lemma coe_prod_congr (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) :\n  \u21d1(h\u2081.prod_congr h\u2082) = prod.map h\u2081 h\u2082 := rfl\n\nsection\nvariables (\u03b1 \u03b2 \u03b3)\n\n/-- `\u03b1 \u00d7 \u03b2` is homeomorphic to `\u03b2 \u00d7 \u03b1`. -/\ndef prod_comm : \u03b1 \u00d7 \u03b2 \u2243\u209c \u03b2 \u00d7 \u03b1 :=\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 \u03b1 \u03b2 }\n\n@[simp] lemma prod_comm_symm : (prod_comm \u03b1 \u03b2).symm = prod_comm \u03b2 \u03b1 := rfl\n@[simp] lemma coe_prod_comm : \u21d1(prod_comm \u03b1 \u03b2) = prod.swap := rfl\n\n/-- `(\u03b1 \u00d7 \u03b2) \u00d7 \u03b3` is homeomorphic to `\u03b1 \u00d7 (\u03b2 \u00d7 \u03b3)`. -/\ndef prod_assoc : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243\u209c \u03b1 \u00d7 (\u03b2 \u00d7 \u03b3) :=\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 \u03b1 \u03b2 \u03b3 }\n\n/-- `\u03b1 \u00d7 {*}` is homeomorphic to `\u03b1`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : \u03b1 \u00d7 punit \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.prod_punit \u03b1,\n  continuous_to_fun := continuous_fst,\n  continuous_inv_fun := continuous_id.prod_mk continuous_const }\n\n/-- `{*} \u00d7 \u03b1` is homeomorphic to `\u03b1`. -/\ndef punit_prod : punit \u00d7 \u03b1 \u2243\u209c \u03b1 :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : \u21d1(punit_prod \u03b1) = prod.snd := rfl\n\n/-- If both `\u03b1` and `\u03b2` have a unique element, then `\u03b1 \u2243\u209c \u03b2`. -/\n@[simps] def _root_.homeomorph.homeomorph_of_unique [unique \u03b1] [unique \u03b2] : \u03b1 \u2243\u209c \u03b2 :=\n{ continuous_to_fun := @continuous_const \u03b1 \u03b2 _ _ default,\n  continuous_inv_fun := @continuous_const \u03b2 \u03b1 _ _ default,\n  .. equiv.equiv_of_unique \u03b1 \u03b2 }\n\nend\n\n/-- If each `\u03b2\u2081 i` is homeomorphic to `\u03b2\u2082 i`, then `\u03a0 i, \u03b2\u2081 i` is homeomorphic to `\u03a0 i, \u03b2\u2082 i`. -/\n@[simps apply to_equiv] def Pi_congr_right {\u03b9 : Type*} {\u03b2\u2081 \u03b2\u2082 : \u03b9 \u2192 Type*}\n  [\u03a0 i, topological_space (\u03b2\u2081 i)] [\u03a0 i, topological_space (\u03b2\u2082 i)] (F : \u03a0 i, \u03b2\u2081 i \u2243\u209c \u03b2\u2082 i) :\n  (\u03a0 i, \u03b2\u2081 i) \u2243\u209c (\u03a0 i, \u03b2\u2082 i) :=\n{ continuous_to_fun := continuous_pi (\u03bb i, (F i).continuous.comp $ continuous_apply i),\n  continuous_inv_fun := continuous_pi (\u03bb i, (F i).symm.continuous.comp $ continuous_apply i),\n  to_equiv := equiv.Pi_congr_right (\u03bb i, (F i).to_equiv) }\n\n@[simp] lemma Pi_congr_right_symm {\u03b9 : Type*} {\u03b2\u2081 \u03b2\u2082 : \u03b9 \u2192 Type*} [\u03a0 i, topological_space (\u03b2\u2081 i)]\n  [\u03a0 i, topological_space (\u03b2\u2082 i)] (F : \u03a0 i, \u03b2\u2081 i \u2243\u209c \u03b2\u2082 i) :\n  (Pi_congr_right F).symm = Pi_congr_right (\u03bb i, (F i).symm) := rfl\n\n/-- `ulift \u03b1` is homeomorphic to `\u03b1`. -/\ndef {u v} ulift {\u03b1 : Type u} [topological_space \u03b1] : ulift.{v u} \u03b1 \u2243\u209c \u03b1 :=\n{ continuous_to_fun := continuous_ulift_down,\n  continuous_inv_fun := continuous_ulift_up,\n  to_equiv := equiv.ulift }\n\nsection distrib\n\n/-- `(\u03b1 \u2295 \u03b2) \u00d7 \u03b3` is homeomorphic to `\u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3`. -/\ndef sum_prod_distrib : (\u03b1 \u2295 \u03b2) \u00d7 \u03b3 \u2243\u209c \u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3 :=\nhomeomorph.symm $ homeomorph_of_continuous_open (equiv.sum_prod_distrib \u03b1 \u03b2 \u03b3).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/-- `\u03b1 \u00d7 (\u03b2 \u2295 \u03b3)` is homeomorphic to `\u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3`. -/\ndef prod_sum_distrib : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243\u209c \u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3 :=\n(prod_comm _ _).trans $\nsum_prod_distrib.trans $\nsum_congr (prod_comm _ _) (prod_comm _ _)\n\nvariables {\u03b9 : Type*} {\u03c3 : \u03b9 \u2192 Type*} [\u03a0 i, topological_space (\u03c3 i)]\n\n/-- `(\u03a3 i, \u03c3 i) \u00d7 \u03b2` is homeomorphic to `\u03a3 i, (\u03c3 i \u00d7 \u03b2)`. -/\ndef sigma_prod_distrib : ((\u03a3 i, \u03c3 i) \u00d7 \u03b2) \u2243\u209c (\u03a3 i, (\u03c3 i \u00d7 \u03b2)) :=\nhomeomorph.symm $ homeomorph_of_continuous_open (equiv.sigma_prod_distrib \u03c3 \u03b2).symm\n  (continuous_sigma $ \u03bb i, continuous_sigma_mk.fst'.prod_mk continuous_snd)\n  (is_open_map_sigma.2 $ \u03bb i, is_open_map_sigma_mk.prod is_open_map.id)\n\nend distrib\n\n/-- If `\u03b9` has a unique element, then `\u03b9 \u2192 \u03b1` is homeomorphic to `\u03b1`. -/\n@[simps { fully_applied := ff }]\ndef fun_unique (\u03b9 \u03b1 : Type*) [unique \u03b9] [topological_space \u03b1] : (\u03b9 \u2192 \u03b1) \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.fun_unique \u03b9 \u03b1,\n  continuous_to_fun := continuous_apply _,\n  continuous_inv_fun := continuous_pi (\u03bb _, continuous_id) }\n\n/-- Homeomorphism between dependent functions `\u03a0 i : fin 2, \u03b1 i` and `\u03b1 0 \u00d7 \u03b1 1`. -/\n@[simps { fully_applied := ff }]\ndef {u} pi_fin_two (\u03b1 : fin 2 \u2192 Type u) [\u03a0 i, topological_space (\u03b1 i)] : (\u03a0 i, \u03b1 i) \u2243\u209c \u03b1 0 \u00d7 \u03b1 1 :=\n{ to_equiv := pi_fin_two_equiv \u03b1,\n  continuous_to_fun := (continuous_apply 0).prod_mk (continuous_apply 1),\n  continuous_inv_fun := continuous_pi $ fin.forall_fin_two.2 \u27e8continuous_fst, continuous_snd\u27e9 }\n\n/-- Homeomorphism between `\u03b1\u00b2 = fin 2 \u2192 \u03b1` and `\u03b1 \u00d7 \u03b1`. -/\n@[simps { fully_applied := ff }] def fin_two_arrow : (fin 2 \u2192 \u03b1) \u2243\u209c \u03b1 \u00d7 \u03b1 :=\n{ to_equiv := fin_two_arrow_equiv \u03b1, ..  pi_fin_two (\u03bb _, \u03b1) }\n\n/--\nA subset of a topological space is homeomorphic to its image under a homeomorphism.\n-/\n@[simps] def image (e : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : s \u2243\u209c 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 \u03b1` is homeomorphic to `\u03b1`. -/\n@[simps { fully_applied := ff }]\ndef set.univ (\u03b1 : Type*) [topological_space \u03b1] : (univ : set \u03b1) \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.set.univ \u03b1,\n  continuous_to_fun := continuous_subtype_coe,\n  continuous_inv_fun := continuous_id.subtype_mk _ }\n\n/-- `s \u00d7\u02e2 t` is homeomorphic to `s \u00d7 t`. -/\n@[simps] def set.prod (s : set \u03b1) (t : set \u03b2) : \u21a5(s \u00d7\u02e2 t) \u2243\u209c s \u00d7 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 {\u03b9 : Type*}\n\n/-- The topological space `\u03a0 i, \u03b2 i` can be split as a product by separating the indices in \u03b9\n  depending on whether they satisfy a predicate p or not.-/\n@[simps] def pi_equiv_pi_subtype_prod (p : \u03b9 \u2192 Prop) (\u03b2 : \u03b9 \u2192 Type*) [\u03a0 i, topological_space (\u03b2 i)]\n  [decidable_pred p] : (\u03a0 i, \u03b2 i) \u2243\u209c (\u03a0 i : {x // p x}, \u03b2 i) \u00d7 \u03a0 i : {x // \u00acp x}, \u03b2 i :=\n{ to_equiv := equiv.pi_equiv_pi_subtype_prod p \u03b2,\n  continuous_to_fun := by apply continuous.prod_mk; exact continuous_pi (\u03bb j, continuous_apply j),\n  continuous_inv_fun := continuous_pi $ \u03bb 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 \u03b9] (i : \u03b9)\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 (\u03b2 : \u03b9 \u2192 Type*) [\u03a0 j, topological_space (\u03b2 j)] :\n  (\u03a0 j, \u03b2 j) \u2243\u209c \u03b2 i \u00d7 \u03a0 j : {j // j \u2260 i}, \u03b2 j :=\n{ to_equiv := equiv.pi_split_at i \u03b2,\n  continuous_to_fun := (continuous_apply i).prod_mk (continuous_pi $ \u03bb j, continuous_apply j),\n  continuous_inv_fun := continuous_pi $ \u03bb 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 : (\u03b9 \u2192 \u03b2) \u2243\u209c \u03b2 \u00d7 ({j // j \u2260 i} \u2192 \u03b2) := 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 \u03b1] [topological_space \u03b2] (f : \u03b1 \u2243 \u03b2)\n  (hf : inducing f) :\n  \u03b1 \u2243\u209c \u03b2 :=\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 \u03b1] [topological_space \u03b2]\n\nlemma continuous_symm_of_equiv_compact_to_t2 [compact_space \u03b1] [t2_space \u03b2]\n  {f : \u03b1 \u2243 \u03b2} (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 \u03b1] [t2_space \u03b2]\n  {f : \u03b1 \u2243 \u03b2} (hf : continuous f) : \u03b1 \u2243\u209c \u03b2 :=\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} : \u2200 {b : B}, path a b \u2192 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) \u2964 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   := \u03bb a b, (inclusion_path a b).obj,\n  map\u2082  := \u03bb a b f g \u03b7, (inclusion_path a b).map \u03b7 }\n\n@[simp]\nlemma preinclusion_obj (a : B) :\n  (preinclusion B).obj a = a :=\nrfl\n\n@[simp]\nlemma preinclusion_map\u2082 {a b : B} (f g : discrete (path.{v+1} a b)) (\u03b7 : f \u27f6 g) :\n  (preinclusion B).map\u2082 \u03b7 = eq_to_hom (congr_arg _ (discrete.ext _ _ (discrete.eq_of_hom \u03b7))) :=\nbegin\n  rcases \u03b7 with \u27e8\u27e8\u27e9\u27e9,\n  cases discrete.ext _ _ \u03b7,\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} : \u2200 {b c : B}, path a b \u2192 hom b c \u2192 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' : \u2200 {a b : B}, hom a b \u2192 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} : \u2200 {b c : B} (p : path a b) (f : hom b c),\n  (preinclusion B).map \u27e8p\u27e9 \u226b f \u2245 (preinclusion B).map \u27e8normalize_aux p f\u27e9\n| _ _ p (hom.of f)      := iso.refl _\n| _ _ p (hom.id b)      := \u03c1_ _\n| _ _ p (hom.comp f g)  := (\u03b1_ _ _ _).symm \u226a\u226b\n    whisker_right_iso (normalize_iso p f) g \u226a\u226b 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} (\u03b7 : f \u27f6 g) :\n  normalize_aux p f = normalize_aux p g :=\nbegin\n  rcases \u03b7,\n  apply @congr_fun _ _ (\u03bb p, normalize_aux p f),\n  clear p,\n  induction \u03b7,\n  case vcomp { apply eq.trans; assumption },\n  /- p \u2260 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} (\u03b7 : f \u27f6 g) :\n  (preinclusion B).map \u27e8p\u27e9 \u25c1 \u03b7 \u226b (normalize_iso p g).hom =\n    (normalize_iso p f).hom \u226b\n      (preinclusion B).map\u2082 (eq_to_hom (discrete.ext _ _ (normalize_aux_congr p \u03b7))) :=\nbegin\n  rcases \u03b7, induction \u03b7,\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 \u2260 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 \u03b7 ih\n  { dsimp,\n    rw [associator_inv_naturality_middle_assoc, \u2190comp_whisker_right_assoc, ih, comp_whisker_right],\n    have := dcongr_arg (\u03bb x, (normalize_iso x h).hom) (normalize_aux_congr p (quot.mk _ \u03b7)),\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       := \u03bb a b f, \u27e8normalize_aux nil f\u27e9,\n  map\u2082      := \u03bb a b f g \u03b7, eq_to_hom $ discrete.ext _ _ $ normalize_aux_congr nil \u03b7,\n  map_id    := \u03bb a, eq_to_iso $ discrete.ext _ _ rfl,\n  map_comp  := \u03bb 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  \ud835\udfed (a \u27f6 b) \u2245 (normalize B).map_functor a b \u22d9 inclusion_path a b :=\nnat_iso.of_components (\u03bb f, (\u03bb_ f).symm \u226a\u226b normalize_iso nil f)\nbegin\n  intros f g \u03b7,\n  erw [left_unitor_inv_naturality_assoc, assoc],\n  congr' 1,\n  exact normalize_naturality nil \u03b7\nend\n\n/-- Normalization as an equivalence of categories. -/\ndef normalize_equiv (a b : B) : hom a b \u224c 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 (\u03bb 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 \u27f6 b) :=\n\u03bb _ _, \u27e8\u03bb \u03b7 \u03b8, (normalize_equiv a b).functor.map_injective (subsingleton.elim _ _)\u27e9\n\n/-- Auxiliary definition for `inclusion`. -/\ndef inclusion_map_comp_aux {a b : B} : \u2200 {c : B} (f : path a b) (g : path b c),\n  (preinclusion _).map (\u27e8f\u27e9 \u226b \u27e8g\u27e9) \u2245 (preinclusion _).map \u27e8f\u27e9 \u226b (preinclusion _).map \u27e8g\u27e9\n| _ f nil := (\u03c1_ ((preinclusion _).map \u27e8f\u27e9)).symm\n| _ f (cons g\u2081 g\u2082) := whisker_right_iso (inclusion_map_comp_aux f g\u2081) (hom.of g\u2082) \u226a\u226b \u03b1_ _ _ _\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    := \u03bb a, iso.refl (\ud835\udfd9 a),\n  map_comp  := \u03bb 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 \u03b1`:  Typeclass saying that a type is finite. It takes as fields a `finset` and a proof\n  that all terms of type `\u03b1` 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 \u03b1)`, and pigeonhole principles.\n\n## Instances\n\nInstances for `fintype` for\n* `{x // p x}` are in this file as `fintype.subtype`\n* `option \u03b1` are in `data.fintype.option`\n* `\u03b1 \u00d7 \u03b2` are in `data.fintype.prod`\n* `\u03b1 \u2295 \u03b2` are in `data.fintype.sum`\n* `\u03a3 (a : \u03b1), \u03b2 a` are in `data.fintype.sigma`\n\nThese files also contain appropriate `infinite` instances for these types.\n\n`infinite` instances for `\u2115`, `\u2124`, `multiset \u03b1`, and `list \u03b1` 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 {\u03b1 \u03b2 \u03b3 : Type _}\n\n#print Fintype /-\n/- ./././Mathport/Syntax/Translate/Command.lean:388:30: infer kinds are unsupported in Lean 4: #[`elems] [] -/\n/-- `fintype \u03b1` means that `\u03b1` is finite, i.e. there are only\n  finitely many distinct elements of type `\u03b1`. 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 `\u03b1` is in the list. -/\nclass Fintype (\u03b1 : Type _) where\n  elems : Finset \u03b1\n  complete : \u2200 x : \u03b1, x \u2208 elems\n#align fintype Fintype\n-/\n\nnamespace Finset\n\nvariable [Fintype \u03b1] {s t : Finset \u03b1}\n\n#print Finset.univ /-\n/-- `univ` is the universal finite set of type `finset \u03b1` implied from\n  the assumption `fintype \u03b1`. -/\ndef univ : Finset \u03b1 :=\n  Fintype.elems \u03b1\n#align finset.univ Finset.univ\n-/\n\n#print Finset.mem_univ /-\n@[simp]\ntheorem mem_univ (x : \u03b1) : x \u2208 (univ : Finset \u03b1) :=\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 : \u2200 x, x \u2208 (univ : Finset \u03b1).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 \u2194 \u2200 x, x \u2208 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 : (\u2200 x, x \u2208 s) \u2192 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 : \u2191(univ : Finset \u03b1) = (Set.univ : Set \u03b1) := 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 \u03b1) = Set.univ \u2194 s = univ := by rw [\u2190 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 \u03b1] : s.Nonempty \u2192 s = univ :=\n  by\n  rintro \u27e8x, hx\u27e9\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 \u03b1).Nonempty \u2194 Nonempty \u03b1 := by\n  rw [\u2190 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 \u03b1] : (univ : Finset \u03b1).Nonempty :=\n  univ_nonempty_iff.2 \u2039_\u203a\n#align finset.univ_nonempty Finset.univ_nonempty\n-/\n\n#print Finset.univ_eq_empty_iff /-\ntheorem univ_eq_empty_iff : (univ : Finset \u03b1) = \u2205 \u2194 IsEmpty \u03b1 := by\n  rw [\u2190 not_nonempty_iff, \u2190 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 \u03b1] : (univ : Finset \u03b1) = \u2205 :=\n  univ_eq_empty_iff.2 \u2039_\u203a\n#align finset.univ_eq_empty Finset.univ_eq_empty\n-/\n\n#print Finset.univ_unique /-\n@[simp]\ntheorem univ_unique [Unique \u03b1] : (univ : Finset \u03b1) = {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 \u03b1) : s \u2286 univ := fun a _ => mem_univ a\n#align finset.subset_univ Finset.subset_univ\n-/\n\ninstance : BoundedOrder (Finset \u03b1) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Fintype.{u1} \u03b1], Eq.{succ u1} (Finset.{u1} \u03b1) (Top.top.{u1} (Finset.{u1} \u03b1) (OrderTop.toHasTop.{u1} (Finset.{u1} \u03b1) (Preorder.toLE.{u1} (Finset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1))) (BoundedOrder.toOrderTop.{u1} (Finset.{u1} \u03b1) (Preorder.toLE.{u1} (Finset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1))) (Finset.boundedOrder.{u1} \u03b1 _inst_1)))) (Finset.univ.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Fintype.{u1} \u03b1], Eq.{succ u1} (Finset.{u1} \u03b1) (Top.top.{u1} (Finset.{u1} \u03b1) (OrderTop.toTop.{u1} (Finset.{u1} \u03b1) (Preorder.toLE.{u1} (Finset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1))) (BoundedOrder.toOrderTop.{u1} (Finset.{u1} \u03b1) (Preorder.toLE.{u1} (Finset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1))) (Finset.boundedOrder.{u1} \u03b1 _inst_1)))) (Finset.univ.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align finset.top_eq_univ Finset.top_eq_univ\u2093'. -/\n@[simp]\ntheorem top_eq_univ : (\u22a4 : Finset \u03b1) = 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 \u03b1} : s \u2282 univ \u2194 s \u2260 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 \u2194 \u2200 \u2983a\u2984, a \u2209 s \u2192 a \u2208 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 \u2194 \u2200 \u2983a\u2984, a \u2209 t \u2192 a \u2208 s :=\n  Codisjoint_comm.trans codisjoint_left\n#align finset.codisjoint_right Finset.codisjoint_right\n-/\n\nsection BooleanAlgebra\n\nvariable [DecidableEq \u03b1] {a : \u03b1}\n\ninstance : BooleanAlgebra (Finset \u03b1) :=\n  GeneralizedBooleanAlgebra.toBooleanAlgebra\n\n#print Finset.sdiff_eq_inter_compl /-\ntheorem sdiff_eq_inter_compl (s t : Finset \u03b1) : s \\ t = s \u2229 t\u1d9c :=\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 \u03b1) : s\u1d9c = 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 \u2208 s\u1d9c \u2194 a \u2209 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 \u2209 s\u1d9c \u2194 a \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Set.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (Finset.Set.hasCoeT.{u1} \u03b1))) (HasCompl.compl.{u1} (Finset.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} \u03b1) (Finset.booleanAlgebra.{u1} \u03b1 _inst_1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b))) s)) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (Finset.Set.hasCoeT.{u1} \u03b1))) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Set.{u1} \u03b1) (Finset.toSet.{u1} \u03b1 (HasCompl.compl.{u1} (Finset.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} \u03b1) (Finset.booleanAlgebra.{u1} \u03b1 _inst_1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b))) s)) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) (Finset.toSet.{u1} \u03b1 s))\nCase conversion may be inaccurate. Consider using '#align finset.coe_compl Finset.coe_compl\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_compl (s : Finset \u03b1) : \u2191(s\u1d9c) = (\u2191s : Set \u03b1)\u1d9c :=\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 : (\u2205 : Finset \u03b1)\u1d9c = 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 \u03b1)\u1d9c = \u2205 :=\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 \u03b1) : s\u1d9c = \u2205 \u2194 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 \u03b1) : s\u1d9c = univ \u2194 s = \u2205 :=\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 \u03b1) : s \u222a s\u1d9c = 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 \u03b1) : s \u2229 s\u1d9c = \u2205 :=\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 \u03b1) : (s \u222a t)\u1d9c = s\u1d9c \u2229 t\u1d9c :=\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 \u03b1) : (s \u2229 t)\u1d9c = s\u1d9c \u222a t\u1d9c :=\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\u2093 a\u1d9c = insert a (s\u1d9c) :=\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\u1d9c = s\u1d9c.erase\u2093 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 : \u03b1) : insert x ({x}\u1d9c : Finset \u03b1) = univ := by\n  rw [\u2190 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 : \u03b1 \u2192 Prop) [DecidablePred p] [\u2200 x, Decidable \u00acp x] :\n    univ.filter\u2093 p\u1d9c = univ.filter\u2093 fun x => \u00acp 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 \u03b1) : s\u1d9c \u2260 univ \u2194 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 : \u03b1) : ({a} : Finset \u03b1)\u1d9c = univ.erase\u2093 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 \u03b1) : Set.InjOn (fun a => insert a s) (s\u1d9c : Finset \u03b1) :=\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 \u03b2] {f : \u03b2 \u2192 \u03b1} (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 \u03b2] {f : \u03b2 \u21aa \u03b1} (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 \u03b2] (f : \u03b2 \u2243 \u03b1) : 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 \u03b1] (s : Finset \u03b1) : univ \u2229 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 \u03b1] (s : Finset \u03b1) : s \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : forall (i : \u03b1), Decidable (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) i (Finset.univ.{u1} \u03b1 _inst_1))] {\u03b4 : \u03b1 -> Sort.{u2}} (f : forall (i : \u03b1), \u03b4 i) (g : forall (i : \u03b1), \u03b4 i), Eq.{imax (succ u1) u2} (forall (i : \u03b1), \u03b4 i) (Finset.piecewise.{u1, u2} \u03b1 (fun (i : \u03b1) => \u03b4 i) (Finset.univ.{u1} \u03b1 _inst_1) f g (fun (j : \u03b1) => _inst_2 j)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : forall (i : \u03b1), Decidable (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) i (Finset.univ.{u2} \u03b1 _inst_1))] {\u03b4 : \u03b1 -> Sort.{u1}} (f : forall (i : \u03b1), \u03b4 i) (g : forall (i : \u03b1), \u03b4 i), Eq.{imax (succ u2) u1} (forall (i : \u03b1), \u03b4 i) (Finset.piecewise.{u2, u1} \u03b1 (fun (i : \u03b1) => \u03b4 i) (Finset.univ.{u2} \u03b1 _inst_1) f g (fun (j : \u03b1) => _inst_2 j)) f\nCase conversion may be inaccurate. Consider using '#align finset.piecewise_univ Finset.piecewise_univ\u2093'. -/\n@[simp]\ntheorem piecewise_univ [\u2200 i : \u03b1, Decidable (i \u2208 (univ : Finset \u03b1))] {\u03b4 : \u03b1 \u2192 Sort _}\n    (f g : \u2200 i, \u03b4 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 {\u03b1 : Type.{u1}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1) [_inst_3 : forall (i : \u03b1), Decidable (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) i s)] [_inst_4 : forall (i : \u03b1), Decidable (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) i (HasCompl.compl.{u1} (Finset.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} \u03b1) (Finset.booleanAlgebra.{u1} \u03b1 _inst_1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b))) s))] {\u03b4 : \u03b1 -> Sort.{u2}} (f : forall (i : \u03b1), \u03b4 i) (g : forall (i : \u03b1), \u03b4 i), Eq.{imax (succ u1) u2} (forall (i : \u03b1), \u03b4 i) (Finset.piecewise.{u1, u2} \u03b1 (fun (i : \u03b1) => \u03b4 i) (HasCompl.compl.{u1} (Finset.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} \u03b1) (Finset.booleanAlgebra.{u1} \u03b1 _inst_1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b))) s) f g (fun (j : \u03b1) => _inst_4 j)) (Finset.piecewise.{u1, u2} \u03b1 (fun (i : \u03b1) => \u03b4 i) s g f (fun (j : \u03b1) => _inst_3 j))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b1] (s : Finset.{u2} \u03b1) [_inst_3 : forall (i : \u03b1), Decidable (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) i s)] [_inst_4 : forall (i : \u03b1), Decidable (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) i (HasCompl.compl.{u2} (Finset.{u2} \u03b1) (BooleanAlgebra.toHasCompl.{u2} (Finset.{u2} \u03b1) (Finset.booleanAlgebra.{u2} \u03b1 _inst_1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b))) s))] {\u03b4 : \u03b1 -> Sort.{u1}} (f : forall (i : \u03b1), \u03b4 i) (g : forall (i : \u03b1), \u03b4 i), Eq.{imax (succ u2) u1} (forall (i : \u03b1), \u03b4 i) (Finset.piecewise.{u2, u1} \u03b1 (fun (i : \u03b1) => \u03b4 i) (HasCompl.compl.{u2} (Finset.{u2} \u03b1) (BooleanAlgebra.toHasCompl.{u2} (Finset.{u2} \u03b1) (Finset.booleanAlgebra.{u2} \u03b1 _inst_1 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b))) s) f g (fun (j : \u03b1) => _inst_4 j)) (Finset.piecewise.{u2, u1} \u03b1 (fun (i : \u03b1) => \u03b4 i) s g f (fun (j : \u03b1) => _inst_3 j))\nCase conversion may be inaccurate. Consider using '#align finset.piecewise_compl Finset.piecewise_compl\u2093'. -/\ntheorem piecewise_compl [DecidableEq \u03b1] (s : Finset \u03b1) [\u2200 i : \u03b1, Decidable (i \u2208 s)]\n    [\u2200 i : \u03b1, Decidable (i \u2208 s\u1d9c)] {\u03b4 : \u03b1 \u2192 Sort _} (f g : \u2200 i, \u03b4 i) :\n    s\u1d9c.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 {\u03b4 : \u03b1 \u2192 Sort _} [DecidableEq \u03b1] (a : \u03b1) (f g : \u2200 a, \u03b4 a) :\n    (Finset.univ.erase\u2093 a).piecewise f g = Function.update f a (g a) := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_2 : Fintype.{u1} \u03b1] [_inst_3 : Fintype.{u2} \u03b2] (e : Equiv.{succ u1, succ u2} \u03b1 \u03b2), Eq.{succ u2} (Finset.{u2} \u03b2) (Finset.map.{u1, u2} \u03b1 \u03b2 (Equiv.toEmbedding.{succ u1, succ u2} \u03b1 \u03b2 e) (Finset.univ.{u1} \u03b1 _inst_2)) (Finset.univ.{u2} \u03b2 _inst_3)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_2 : Fintype.{u2} \u03b1] [_inst_3 : Fintype.{u1} \u03b2] (e : Equiv.{succ u2, succ u1} \u03b1 \u03b2), Eq.{succ u1} (Finset.{u1} \u03b2) (Finset.map.{u2, u1} \u03b1 \u03b2 (Equiv.toEmbedding.{succ u2, succ u1} \u03b1 \u03b2 e) (Finset.univ.{u2} \u03b1 _inst_2)) (Finset.univ.{u1} \u03b2 _inst_3)\nCase conversion may be inaccurate. Consider using '#align finset.univ_map_equiv_to_embedding Finset.univ_map_equiv_to_embedding\u2093'. -/\ntheorem univ_map_equiv_to_embedding {\u03b1 \u03b2 : Type _} [Fintype \u03b1] [Fintype \u03b2] (e : \u03b1 \u2243 \u03b2) :\n    univ.map e.toEmbedding = univ :=\n  eq_univ_iff_forall.mpr fun b => mem_map.mpr \u27e8e.symm b, mem_univ _, by simp\u27e9\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 : \u03b1 \u2192 \u03b2) [Fintype \u03b2] [DecidablePred fun y => \u2203 x, f x = y]\n    [DecidableEq \u03b2] : (Finset.univ.filter\u2093 fun y => \u2203 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 : \u03b1 \u2192 \u03b2) [Fintype \u03b2] [DecidablePred fun y => y \u2208 Set.range f]\n    [DecidableEq \u03b2] : (Finset.univ.filter\u2093 fun y => y \u2208 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 : \u03b1 \u2192 Prop) [DecidablePred p] : (univ.filter\u2093 p : Set \u03b1) = { 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 {\u03b1} {\u03b2 : \u03b1 \u2192 Type _} [\u2200 a, DecidableEq (\u03b2 a)] [Fintype \u03b1] :\n    DecidableEq (\u2200 a, \u03b2 a) := fun f g =>\n  decidable_of_iff (\u2200 a \u2208 Fintype.elems \u03b1, 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 : \u03b1 \u2192 Prop} [DecidablePred p] [Fintype \u03b1] :\n    Decidable (\u2200 a, p a) :=\n  decidable_of_iff (\u2200 a \u2208 @univ \u03b1 _, p a) (by simp)\n#align fintype.decidable_forall_fintype Fintype.decidableForallFintype\n-/\n\n#print Fintype.decidableExistsFintype /-\ninstance decidableExistsFintype {p : \u03b1 \u2192 Prop} [DecidablePred p] [Fintype \u03b1] :\n    Decidable (\u2203 a, p a) :=\n  decidable_of_iff (\u2203 a \u2208 @univ \u03b1 _, p a) (by simp)\n#align fintype.decidable_exists_fintype Fintype.decidableExistsFintype\n-/\n\n#print Fintype.decidableMemRangeFintype /-\ninstance decidableMemRangeFintype [Fintype \u03b1] [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) :\n    DecidablePred (\u00b7 \u2208 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 \u03b2] [Fintype \u03b1] : DecidableEq (\u03b1 \u2243 \u03b2) := 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 \u03b2] [Fintype \u03b1] : DecidableEq (\u03b1 \u21aa \u03b2) := fun a b =>\n  decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = 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 \u03b2] [Fintype \u03b1] [One \u03b1] [One \u03b2] :\n    DecidableEq (OneHom \u03b1 \u03b2) := fun a b =>\n  decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = 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 \u03b2] [Fintype \u03b1] [Mul \u03b1] [Mul \u03b2] :\n    DecidableEq (\u03b1 \u2192\u2099* \u03b2) := fun a b =>\n  decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = 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 \u03b2] [Fintype \u03b1] [MulOneClass \u03b1] [MulOneClass \u03b2] :\n    DecidableEq (\u03b1 \u2192* \u03b2) := fun a b =>\n  decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = 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 \u03b2] [Fintype \u03b1] [MulZeroOneClass \u03b1]\n    [MulZeroOneClass \u03b2] : DecidableEq (\u03b1 \u2192*\u2080 \u03b2) := fun a b =>\n  decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = 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 \u03b2] [Fintype \u03b1] [Semiring \u03b1] [Semiring \u03b2] :\n    DecidableEq (\u03b1 \u2192+* \u03b2) := fun a b =>\n  decidable_of_iff ((a : \u03b1 \u2192 \u03b2) = 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 \u03b1] [DecidableEq \u03b2] [Fintype \u03b1] :\n    DecidablePred (Injective : (\u03b1 \u2192 \u03b2) \u2192 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 \u03b2] [Fintype \u03b1] [Fintype \u03b2] :\n    DecidablePred (Surjective : (\u03b1 \u2192 \u03b2) \u2192 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 \u03b1] [DecidableEq \u03b2] [Fintype \u03b1] [Fintype \u03b2] :\n    DecidablePred (Bijective : (\u03b1 \u2192 \u03b2) \u2192 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 \u03b1] [Fintype \u03b1] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) :\n    Decidable (Function.RightInverse f g) :=\n  show Decidable (\u2200 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 \u03b2] [Fintype \u03b2] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) :\n    Decidable (Function.LeftInverse f g) :=\n  show Decidable (\u2200 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 \u03b1` from a universal multiset -/\ndef ofMultiset [DecidableEq \u03b1] (s : Multiset \u03b1) (H : \u2200 x : \u03b1, x \u2208 s) : Fintype \u03b1 :=\n  \u27e8s.toFinset, by simpa using H\u27e9\n#align fintype.of_multiset Fintype.ofMultiset\n-/\n\n#print Fintype.ofList /-\n/-- Construct a proof of `fintype \u03b1` from a universal list -/\ndef ofList [DecidableEq \u03b1] (l : List \u03b1) (H : \u2200 x : \u03b1, x \u2208 l) : Fintype \u03b1 :=\n  \u27e8l.toFinset, by simpa using H\u27e9\n#align fintype.of_list Fintype.ofList\n-/\n\ninstance (\u03b1 : Type _) : Subsingleton (Fintype \u03b1) :=\n  \u27e8fun \u27e8s\u2081, h\u2081\u27e9 \u27e8s\u2082, h\u2082\u27e9 => by congr <;> simp [Finset.ext_iff, h\u2081, h\u2082]\u27e9\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 : \u03b1 \u2192 Prop} (s : Finset \u03b1) (H : \u2200 x : \u03b1, x \u2208 s \u2194 p x) :\n    Fintype { x // p x } :=\n  \u27e8\u27e8s.1.pmap Subtype.mk fun x => (H x).1, s.Nodup.pmap fun a _ b _ => congr_arg Subtype.val\u27e9,\n    fun \u27e8x, px\u27e9 => Multiset.mem_pmap.2 \u27e8x, (H x).2 px, rfl\u27e9\u27e9\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 \u03b1} (s : Finset \u03b1) (H : \u2200 x, x \u2208 s \u2194 x \u2208 p) : Fintype p :=\n  Fintype.subtype s H\n#align fintype.of_finset Fintype.ofFinset\n-/\n\n#print Fintype.ofBijective /-\n/-- If `f : \u03b1 \u2192 \u03b2` is a bijection and `\u03b1` is a fintype, then `\u03b2` is also a fintype. -/\ndef ofBijective [Fintype \u03b1] (f : \u03b1 \u2192 \u03b2) (H : Function.Bijective f) : Fintype \u03b2 :=\n  \u27e8univ.map \u27e8f, H.1\u27e9, fun b =>\n    let \u27e8a, e\u27e9 := H.2 b\n    e \u25b8 mem_map_of_mem _ (mem_univ _)\u27e9\n#align fintype.of_bijective Fintype.ofBijective\n-/\n\n#print Fintype.ofSurjective /-\n/-- If `f : \u03b1 \u2192 \u03b2` is a surjection and `\u03b1` is a fintype, then `\u03b2` is also a fintype. -/\ndef ofSurjective [DecidableEq \u03b2] [Fintype \u03b1] (f : \u03b1 \u2192 \u03b2) (H : Function.Surjective f) : Fintype \u03b2 :=\n  \u27e8univ.image f, fun b =>\n    let \u27e8a, e\u27e9 := H b\n    e \u25b8 mem_image_of_mem _ (mem_univ _)\u27e9\n#align fintype.of_surjective Fintype.ofSurjective\n-/\n\nend Fintype\n\nnamespace Finset\n\nvariable [Fintype \u03b1] [DecidableEq \u03b1] {s t : Finset \u03b1}\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 \u03b1] [DecidableEq \u03b2]\n\nnamespace Injective\n\nvariable {f : \u03b1 \u2192 \u03b2} (hf : Function.Injective f)\n\n#print Function.Injective.invOfMemRange /-\n/-- The inverse of an `hf : injective` function `f : \u03b1 \u2192 \u03b2`, of the type `\u21a5(set.range f) \u2192 \u03b1`.\nThis is the computable version of `function.inv_fun` that requires `fintype \u03b1` and `decidable_eq \u03b2`,\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 : \u03b1` to find the `f a = b`, so it is O(N) where\n`N = fintype.card \u03b1`.\n-/\ndef invOfMemRange : Set.range f \u2192 \u03b1 := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} (hf : Function.Injective.{succ u1, succ u2} \u03b1 \u03b2 f) (a : \u03b1), Eq.{succ u1} \u03b1 (Function.Injective.invOfMemRange.{u1, u2} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f hf (Subtype.mk.{succ u2} \u03b2 (fun (x : \u03b2) => Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) x (Set.range.{u2, succ u1} \u03b2 \u03b1 f)) (f a) (Set.mem_range_self.{u2, succ u1} \u03b2 \u03b1 f a))) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} (hf : Function.Injective.{succ u2, succ u1} \u03b1 \u03b2 f) (a : \u03b1), Eq.{succ u2} \u03b1 (Function.Injective.invOfMemRange.{u2, u1} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f hf (Subtype.mk.{succ u1} \u03b2 (fun (x : \u03b2) => Membership.mem.{u1, u1} \u03b2 (Set.{u1} \u03b2) (Set.instMembershipSet.{u1} \u03b2) x (Set.range.{u1, succ u2} \u03b2 \u03b1 f)) (f a) (Set.mem_range_self.{succ u2, u1} \u03b2 \u03b1 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\u2093'. -/\n@[simp]\ntheorem right_inv_of_invOfMemRange (a : \u03b1) : hf.invOfMemRange \u27e8f a, Set.mem_range_self a\u27e9 = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} (hf : Function.Injective.{succ u1, succ u2} \u03b1 \u03b2 f) [_inst_3 : Nonempty.{succ u1} \u03b1], Eq.{max (succ u2) (succ u1)} ((coeSort.{succ u2, succ (succ u2)} (Set.{u2} \u03b2) Type.{u2} (Set.hasCoeToSort.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 f)) -> \u03b1) (Set.restrict.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (Set.range.{u2, succ u1} \u03b2 \u03b1 f) (Function.invFun.{succ u1, succ u2} \u03b1 \u03b2 _inst_3 f)) (Function.Injective.invOfMemRange.{u1, u2} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f hf)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} (hf : Function.Injective.{succ u2, succ u1} \u03b1 \u03b2 f) [_inst_3 : Nonempty.{succ u2} \u03b1], Eq.{max (succ u2) (succ u1)} ((Set.Elem.{u1} \u03b2 (Set.range.{u1, succ u2} \u03b2 \u03b1 f)) -> \u03b1) (Set.restrict.{u1, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (Set.range.{u1, succ u2} \u03b2 \u03b1 f) (Function.invFun.{succ u2, succ u1} \u03b1 \u03b2 _inst_3 f)) (Function.Injective.invOfMemRange.{u2, u1} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f hf)\nCase conversion may be inaccurate. Consider using '#align function.injective.inv_fun_restrict Function.Injective.invFun_restrict\u2093'. -/\ntheorem invFun_restrict [Nonempty \u03b1] : (Set.range f).restrict (invFun f) = hf.invOfMemRange :=\n  by\n  ext \u27e8b, h\u27e9\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  \u27e8\u27e8f a, Set.mem_range_self a\u27e9, by simp\u27e9\n#align function.injective.inv_of_mem_range_surjective Function.Injective.invOfMemRange_surjective\n-/\n\nend Injective\n\nnamespace Embedding\n\nvariable (f : \u03b1 \u21aa \u03b2) (b : Set.range f)\n\n#print Function.Embedding.invOfMemRange /-\n/-- The inverse of an embedding `f : \u03b1 \u21aa \u03b2`, of the type `\u21a5(set.range f) \u2192 \u03b1`.\nThis is the computable version of `function.inv_fun` that requires `fintype \u03b1` and `decidable_eq \u03b2`,\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 : \u03b1` to find the `f a = b`, so it is O(N) where\n`N = fintype.card \u03b1`.\n-/\ndef invOfMemRange : \u03b1 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] (f : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (a : \u03b1), Eq.{succ u1} \u03b1 (Function.Embedding.invOfMemRange.{u1, u2} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f (Subtype.mk.{succ u2} \u03b2 (fun (x : \u03b2) => Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) x (Set.range.{u2, succ u1} \u03b2 \u03b1 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f))) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f a) (Set.mem_range_self.{u2, succ u1} \u03b2 \u03b1 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f) a))) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] (f : Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) (a : \u03b1), Eq.{succ u2} \u03b1 (Function.Embedding.invOfMemRange.{u2, u1} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f (Subtype.mk.{succ u1} \u03b2 (fun (x : \u03b2) => Membership.mem.{u1, u1} \u03b2 (Set.{u1} \u03b2) (Set.instMembershipSet.{u1} \u03b2) x (Set.range.{u1, succ u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f a) (Set.mem_range_self.{succ u2, u1} \u03b2 \u03b1 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) 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\u2093'. -/\n@[simp]\ntheorem right_inv_of_invOfMemRange (a : \u03b1) : f.invOfMemRange \u27e8f a, Set.mem_range_self a\u27e9 = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] (f : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) [_inst_3 : Nonempty.{succ u1} \u03b1], Eq.{max (succ u2) (succ u1)} ((coeSort.{succ u2, succ (succ u2)} (Set.{u2} \u03b2) Type.{u2} (Set.hasCoeToSort.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f))) -> \u03b1) (Set.restrict.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (Set.range.{u2, succ u1} \u03b2 \u03b1 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f)) (Function.invFun.{succ u1, succ u2} \u03b1 \u03b2 _inst_3 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f))) (Function.Embedding.invOfMemRange.{u1, u2} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] (f : Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) [_inst_3 : Nonempty.{succ u2} \u03b1], Eq.{max (succ u2) (succ u1)} ((Set.Elem.{u1} \u03b2 (Set.range.{u1, succ u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f))) -> \u03b1) (Set.restrict.{u1, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (Set.range.{u1, succ u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f)) (Function.invFun.{succ u2, succ u1} \u03b1 \u03b2 _inst_3 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f))) (Function.Embedding.invOfMemRange.{u2, u1} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f)\nCase conversion may be inaccurate. Consider using '#align function.embedding.inv_fun_restrict Function.Embedding.invFun_restrict\u2093'. -/\ntheorem invFun_restrict [Nonempty \u03b1] : (Set.range f).restrict (invFun f) = f.invOfMemRange :=\n  by\n  ext \u27e8b, h\u27e9\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  \u27e8\u27e8f a, Set.mem_range_self a\u27e9, by simp\u27e9\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 \u03b2] (f : \u03b1 \u2192 \u03b2) (H : Function.Injective f) : Fintype \u03b1 :=\n  letI := Classical.dec\n  if h\u03b1 : Nonempty \u03b1 then\n    letI := Classical.inhabited_of_nonempty h\u03b1\n    of_surjective (inv_fun f) (inv_fun_surjective H)\n  else \u27e8\u2205, fun x => (h\u03b1 \u27e8x\u27e9).elim\u27e9\n#align fintype.of_injective Fintype.ofInjective\n-/\n\n#print Fintype.ofEquiv /-\n/-- If `f : \u03b1 \u2243 \u03b2` and `\u03b1` is a fintype, then `\u03b2` is also a fintype. -/\ndef ofEquiv (\u03b1 : Type _) [Fintype \u03b1] (f : \u03b1 \u2243 \u03b2) : Fintype \u03b2 :=\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 : \u03b1) [Subsingleton \u03b1] : Fintype \u03b1 :=\n  \u27e8{a}, fun b => Finset.mem_singleton.2 (Subsingleton.elim _ _)\u27e9\n#align fintype.of_subsingleton Fintype.ofSubsingleton\n-/\n\n#print Fintype.univ_ofSubsingleton /-\n@[simp]\ntheorem univ_ofSubsingleton (a : \u03b1) [Subsingleton \u03b1] : @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 \u03b1] : Fintype \u03b1 :=\n  \u27e8\u2205, isEmptyElim\u27e9\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 \u03b1] : @univ \u03b1 _ = \u2205 :=\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 \u03b1}\n\n#print Set.toFinset /-\n/-- Construct a finset enumerating a set `s`, given a `fintype` instance.  -/\ndef toFinset (s : Set \u03b1) [Fintype s] : Finset \u03b1 :=\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 \u03b1} [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 \u03b1} [Fintype s] {a : \u03b1} : a \u2208 s.toFinset \u2194 a \u2208 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 \u03b1} (s : Finset \u03b1) (H : \u2200 x, x \u2208 s \u2194 x \u2208 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 \u03b1] (s : Set \u03b1) [Fintype s] (a) : Decidable (a \u2208 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 \u03b1) [Fintype s] : (\u2191s.toFinset : Set \u03b1) = 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 \u03b1} [Fintype s] : s.toFinset.Nonempty \u2194 s.Nonempty := by\n  rw [\u2190 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 \u03b1} [Fintype s] [Fintype t] : s.toFinset = t.toFinset \u2194 s = t :=\n  \u27e8fun h => by rw [\u2190 s.coe_to_finset, h, t.coe_to_finset], fun h => by simp [h] <;> congr \u27e9\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 \u2286 t.toFinset \u2194 s \u2286 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 {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] {t : Finset.{u1} \u03b1}, Iff (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.hasSsubset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_1) t) (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.hasSsubset.{u1} \u03b1) s ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (Finset.Set.hasCoeT.{u1} \u03b1))) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] {t : Finset.{u1} \u03b1}, Iff (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.instHasSSubsetFinset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_1) t) (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.instHasSSubsetSet.{u1} \u03b1) s (Finset.toSet.{u1} \u03b1 t))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_ssubset Set.toFinset_ssubset\u2093'. -/\n@[simp]\ntheorem toFinset_ssubset [Fintype s] {t : Finset \u03b1} : s.toFinset \u2282 t \u2194 s \u2282 t := by\n  rw [\u2190 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 \u03b1} [Fintype t] : s \u2286 t.toFinset \u2194 \u2191s \u2286 t := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} {t : Set.{u1} \u03b1} {s : Finset.{u1} \u03b1} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) t)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.hasSsubset.{u1} \u03b1) s (Set.toFinset.{u1} \u03b1 t _inst_1)) (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.hasSsubset.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (Finset.Set.hasCoeT.{u1} \u03b1))) s) t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {t : Set.{u1} \u03b1} {s : Finset.{u1} \u03b1} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} \u03b1 t)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.instHasSSubsetFinset.{u1} \u03b1) s (Set.toFinset.{u1} \u03b1 t _inst_1)) (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.instHasSSubsetSet.{u1} \u03b1) (Finset.toSet.{u1} \u03b1 s) t)\nCase conversion may be inaccurate. Consider using '#align set.ssubset_to_finset Set.ssubset_toFinset\u2093'. -/\n@[simp]\ntheorem ssubset_toFinset {s : Finset \u03b1} [Fintype t] : s \u2282 t.toFinset \u2194 \u2191s \u2282 t := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) t)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.hasSsubset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_1) (Set.toFinset.{u1} \u03b1 t _inst_2)) (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.hasSsubset.{u1} \u03b1) s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 t)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.instHasSSubsetFinset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_1) (Set.toFinset.{u1} \u03b1 t _inst_2)) (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.instHasSSubsetSet.{u1} \u03b1) s t)\nCase conversion may be inaccurate. Consider using '#align set.to_finset_ssubset_to_finset Set.toFinset_ssubset_toFinset\u2093'. -/\n@[mono]\ntheorem toFinset_ssubset_toFinset [Fintype s] [Fintype t] : s.toFinset \u2282 t.toFinset \u2194 s \u2282 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 \u03b1} : s.toFinset \u2286 t \u2194 s \u2286 t := by\n  rw [\u2190 Finset.coe_subset, coe_to_finset]\n#align set.to_finset_subset Set.toFinset_subset\n-/\n\nalias to_finset_subset_to_finset \u2194 _ 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 {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) t)], (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.hasSsubset.{u1} \u03b1) s t) -> (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.hasSsubset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_1) (Set.toFinset.{u1} \u03b1 t _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 t)], (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.instHasSSubsetSet.{u1} \u03b1) s t) -> (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.instHasSSubsetFinset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_1) (Set.toFinset.{u1} \u03b1 t _inst_2))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_strict_mono Set.toFinset_strict_mono\u2093'. -/\nalias to_finset_ssubset_to_finset \u2194 _ 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 {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1} [_inst_1 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) t)], Iff (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.orderBot.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_1) (Set.toFinset.{u1} \u03b1 t _inst_2)) (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1} [_inst_1 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 t)], Iff (Disjoint.{u1} (Finset.{u1} \u03b1) (Finset.partialOrder.{u1} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_1) (Set.toFinset.{u1} \u03b1 t _inst_2)) (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b1) (Preorder.toLE.{u1} (Set.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) s t)\nCase conversion may be inaccurate. Consider using '#align set.disjoint_to_finset Set.disjoint_toFinset\u2093'. -/\n@[simp]\ntheorem disjoint_toFinset [Fintype s] [Fintype t] : Disjoint s.toFinset t.toFinset \u2194 Disjoint s t :=\n  by simp only [\u2190 disjoint_coe, coe_to_finset]\n#align set.disjoint_to_finset Set.disjoint_toFinset\n\nsection DecidableEq\n\nvariable [DecidableEq \u03b1] (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 {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) (t : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) t)] [_inst_4 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) s t))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) s t) _inst_4) (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u1} \u03b1 t _inst_3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) (t : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} \u03b1 t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.instInterSet.{u1} \u03b1) s t))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.instInterSet.{u1} \u03b1) s t) _inst_4) (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.instInterFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u1} \u03b1 t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_inter Set.toFinset_inter\u2093'. -/\n@[simp]\ntheorem toFinset_inter [Fintype \u21a5(s \u2229 t)] : (s \u2229 t).toFinset = s.toFinset \u2229 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 {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) (t : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) t)] [_inst_4 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s t))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s t) _inst_4) (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u1} \u03b1 t _inst_3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) (t : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} \u03b1 t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} \u03b1 (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s t))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s t) _inst_4) (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.instUnionFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u1} \u03b1 t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_union Set.toFinset_union\u2093'. -/\n@[simp]\ntheorem toFinset_union [Fintype \u21a5(s \u222a t)] : (s \u222a t).toFinset = s.toFinset \u222a 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 {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) (t : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) t)] [_inst_4 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (SDiff.sdiff.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s t))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (SDiff.sdiff.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s t) _inst_4) (SDiff.sdiff.{u1} (Finset.{u1} \u03b1) (Finset.hasSdiff.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u1} \u03b1 t _inst_3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) (t : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} \u03b1 t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} \u03b1 (SDiff.sdiff.{u1} (Set.{u1} \u03b1) (Set.instSDiffSet.{u1} \u03b1) s t))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (SDiff.sdiff.{u1} (Set.{u1} \u03b1) (Set.instSDiffSet.{u1} \u03b1) s t) _inst_4) (SDiff.sdiff.{u1} (Finset.{u1} \u03b1) (Finset.instSDiffFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u1} \u03b1 t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_diff Set.toFinset_diff\u2093'. -/\n@[simp]\ntheorem toFinset_diff [Fintype \u21a5(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 {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) (t : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) t)] [_inst_4 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (symmDiff.{u1} (Set.{u1} \u03b1) (SemilatticeSup.toHasSup.{u1} (Set.{u1} \u03b1) (Lattice.toSemilatticeSup.{u1} (Set.{u1} \u03b1) (CompleteLattice.toLattice.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1))))))) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s t))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (symmDiff.{u1} (Set.{u1} \u03b1) (SemilatticeSup.toHasSup.{u1} (Set.{u1} \u03b1) (Lattice.toSemilatticeSup.{u1} (Set.{u1} \u03b1) (CompleteLattice.toLattice.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1))))))) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s t) _inst_4) (symmDiff.{u1} (Finset.{u1} \u03b1) (SemilatticeSup.toHasSup.{u1} (Finset.{u1} \u03b1) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b1) (Finset.lattice.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)))) (Finset.hasSdiff.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u1} \u03b1 t _inst_3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) (t : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} \u03b1 t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} \u03b1 (symmDiff.{u1} (Set.{u1} \u03b1) (SemilatticeSup.toSup.{u1} (Set.{u1} \u03b1) (Lattice.toSemilatticeSup.{u1} (Set.{u1} \u03b1) (CompleteLattice.toLattice.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1))))))) (Set.instSDiffSet.{u1} \u03b1) s t))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (symmDiff.{u1} (Set.{u1} \u03b1) (SemilatticeSup.toSup.{u1} (Set.{u1} \u03b1) (Lattice.toSemilatticeSup.{u1} (Set.{u1} \u03b1) (CompleteLattice.toLattice.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1))))))) (Set.instSDiffSet.{u1} \u03b1) s t) _inst_4) (symmDiff.{u1} (Finset.{u1} \u03b1) (SemilatticeSup.toSup.{u1} (Finset.{u1} \u03b1) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b1) (Finset.instLatticeFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)))) (Finset.instSDiffFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u1} \u03b1 t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_symm_diff Set.toFinset_symmDiff\u2093'. -/\n@[simp]\ntheorem toFinset_symmDiff [Fintype \u21a5(s \u2206 t)] : (s \u2206 t).toFinset = s.toFinset \u2206 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 {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_4 : Fintype.{u1} \u03b1] [_inst_5 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) _inst_5) (HasCompl.compl.{u1} (Finset.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} \u03b1) (Finset.booleanAlgebra.{u1} \u03b1 _inst_4 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b))) (Set.toFinset.{u1} \u03b1 s _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)] [_inst_4 : Fintype.{u1} \u03b1] [_inst_5 : Fintype.{u1} (Set.Elem.{u1} \u03b1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) _inst_5) (HasCompl.compl.{u1} (Finset.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} \u03b1) (Finset.booleanAlgebra.{u1} \u03b1 _inst_4 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b))) (Set.toFinset.{u1} \u03b1 s _inst_2))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_compl Set.toFinset_compl\u2093'. -/\n@[simp]\ntheorem toFinset_compl [Fintype \u03b1] [Fintype \u21a5(s\u1d9c)] : s\u1d9c.toFinset = s.toFinset\u1d9c :=\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 `\u21a5` circumvents an elaboration bug. See comment on `set.to_finset_univ`.\n@[simp]\ntheorem toFinset_empty [Fintype \u21a5(\u2205 : Set \u03b1)] : (\u2205 : Set \u03b1).toFinset = \u2205 :=\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 (`\u21a5`) there is an elaboration bug in the following two;\nit essentially infers `fintype.{v} (set.univ.{u} : set \u03b1)` with `v` and `u` distinct.\nReported in leanprover-community/lean#672 -/\n@[simp]\ntheorem toFinset_univ [Fintype \u03b1] [Fintype \u21a5(Set.univ : Set \u03b1)] :\n    (Set.univ : Set \u03b1).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 = \u2205 \u2194 s = \u2205 := by\n  rw [\u2190 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 \u03b1] [Fintype s] : s.toFinset = Finset.univ \u2194 s = univ := by\n  rw [\u2190 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 \u03b1] (p : \u03b1 \u2192 Prop) [DecidablePred p] [Fintype { x | p x }] :\n    { x | p x }.toFinset = Finset.univ.filter\u2093 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 {\u03b1 : Type.{u1}} [_inst_1 : Fintype.{u1} \u03b1] {s : Set.{u1} \u03b1} [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.hasSsubset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_2) (Finset.univ.{u1} \u03b1 _inst_1)) (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.hasSsubset.{u1} \u03b1) s (Set.univ.{u1} \u03b1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Fintype.{u1} \u03b1] {s : Set.{u1} \u03b1} [_inst_2 : Fintype.{u1} (Set.Elem.{u1} \u03b1 s)], Iff (HasSSubset.SSubset.{u1} (Finset.{u1} \u03b1) (Finset.instHasSSubsetFinset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 s _inst_2) (Finset.univ.{u1} \u03b1 _inst_1)) (HasSSubset.SSubset.{u1} (Set.{u1} \u03b1) (Set.instHasSSubsetSet.{u1} \u03b1) s (Set.univ.{u1} \u03b1))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_ssubset_univ Set.toFinset_ssubset_univ\u2093'. -/\n@[simp]\ntheorem toFinset_ssubset_univ [Fintype \u03b1] {s : Set \u03b1} [Fintype s] :\n    s.toFinset \u2282 Finset.univ \u2194 s \u2282 univ := by rw [\u2190 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 \u03b2] (f : \u03b1 \u2192 \u03b2) (s : Set \u03b1) [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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Fintype.{u2} \u03b2] (f : \u03b2 -> \u03b1) [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.range.{u1, succ u2} \u03b1 \u03b2 f))], Eq.{succ u1} (Finset.{u1} \u03b1) (Set.toFinset.{u1} \u03b1 (Set.range.{u1, succ u2} \u03b1 \u03b2 f) _inst_3) (Finset.image.{u2, u1} \u03b2 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f (Finset.univ.{u2} \u03b2 _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : Fintype.{u1} \u03b2] (f : \u03b2 -> \u03b1) [_inst_3 : Fintype.{u2} (Set.Elem.{u2} \u03b1 (Set.range.{u2, succ u1} \u03b1 \u03b2 f))], Eq.{succ u2} (Finset.{u2} \u03b1) (Set.toFinset.{u2} \u03b1 (Set.range.{u2, succ u1} \u03b1 \u03b2 f) _inst_3) (Finset.image.{u1, u2} \u03b2 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f (Finset.univ.{u1} \u03b2 _inst_2))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_range Set.toFinset_range\u2093'. -/\n@[simp]\ntheorem toFinset_range [DecidableEq \u03b1] [Fintype \u03b2] (f : \u03b2 \u2192 \u03b1) [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 `\u21a5` circumvents an elaboration bug. See comment on `set.to_finset_univ`.\ntheorem toFinset_singleton (a : \u03b1) [Fintype \u21a5({a} : Set \u03b1)] : ({a} : Set \u03b1).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 `\u21a5` circumvents an elaboration bug. See comment on `set.to_finset_univ`.\n@[simp]\ntheorem toFinset_insert [DecidableEq \u03b1] {a : \u03b1} {s : Set \u03b1} [Fintype \u21a5(insert a s : Set \u03b1)]\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 \u03b1] (s : Set \u03b1) [Fintype s] [DecidablePred (\u00b7 \u2208 s)] :\n    Finset.univ.filter\u2093 (\u00b7 \u2208 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 \u03b1) [Fintype \u21a5(s : Set \u03b1)] : (s : Set \u03b1).toFinset = s :=\n  ext fun _ => Set.mem_toFinset\n#align finset.to_finset_coe Finset.toFinset_coe\n-/\n\ninstance (n : \u2115) : Fintype (Fin n) :=\n  \u27e8\u27e8List.finRange n, List.nodup_finRange n\u27e9, List.mem_finRange\u27e9\n\n#print Fin.univ_def /-\ntheorem Fin.univ_def (n : \u2115) : (univ : Finset (Fin n)) = \u27e8List.finRange n, List.nodup_finRange n\u27e9 :=\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\u2093'. -/\n@[simp]\ntheorem Fin.image_succAbove_univ {n : \u2115} (i : Fin (n + 1)) : univ.image i.succAbove = {i}\u1d9c :=\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\u2093'. -/\n@[simp]\ntheorem Fin.image_succ_univ (n : \u2115) : (univ : Finset (Fin n)).image Fin.succ = {0}\u1d9c := by\n  rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem Fin.image_castSucc (n : \u2115) : (univ : Finset (Fin n)).image Fin.castSucc = {Fin.last n}\u1d9c :=\n  by rw [\u2190 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))))))] (\u1fb0 : 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))))) (\u1fb0_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))))) \u1fb0 \u1fb0_1) (\u1fb0_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)))))) (\u1fb0_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)))))) \u1fb0_2 \u1fb0_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 \u1fb0) (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 \u1fb0_1) \u1fb0_2 \u1fb0_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) \u1fb0 \u1fb0_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\u2093'. -/\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 : \u2115) :\n    (univ : Finset (Fin (n + 1))) =\n      cons 0 (univ.map \u27e8Fin.succ, Fin.succ_injective _\u27e9) (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 : \u2115) :\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 : \u2115) (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 {\u03b1 : Type _} [Unique \u03b1] : Fintype \u03b1 :=\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 : \u03b1) : 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 : \u03b1) : 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 _ = \u2205 :=\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 _ = \u2205 :=\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  \u27e8\u27e8{true, false}, by simp\u27e9, fun x => by cases x <;> simp\u27e9\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 : \u2200 [Fintype \u03b1], Fintype (Additive \u03b1) :=\n  id\n#align additive.fintype Additive.fintype\n-/\n\n#print Multiplicative.fintype /-\ninstance Multiplicative.fintype : \u2200 [Fintype \u03b1], Fintype (Multiplicative \u03b1) :=\n  id\n#align multiplicative.fintype Multiplicative.fintype\n-/\n\n#print Fintype.prodLeft /-\n/-- Given that `\u03b1 \u00d7 \u03b2` is a fintype, `\u03b1` is also a fintype. -/\ndef Fintype.prodLeft {\u03b1 \u03b2} [DecidableEq \u03b1] [Fintype (\u03b1 \u00d7 \u03b2)] [Nonempty \u03b2] : Fintype \u03b1 :=\n  \u27e8(Fintype.elems (\u03b1 \u00d7 \u03b2)).image Prod.fst, fun a =>\n    by\n    let \u27e8b\u27e9 := \u2039Nonempty \u03b2\u203a\n    simp <;> exact \u27e8b, Fintype.complete _\u27e9\u27e9\n#align fintype.prod_left Fintype.prodLeft\n-/\n\n#print Fintype.prodRight /-\n/-- Given that `\u03b1 \u00d7 \u03b2` is a fintype, `\u03b2` is also a fintype. -/\ndef Fintype.prodRight {\u03b1 \u03b2} [DecidableEq \u03b2] [Fintype (\u03b1 \u00d7 \u03b2)] [Nonempty \u03b1] : Fintype \u03b2 :=\n  \u27e8(Fintype.elems (\u03b1 \u00d7 \u03b2)).image Prod.snd, fun b =>\n    by\n    let \u27e8a\u27e9 := \u2039Nonempty \u03b1\u203a\n    simp <;> exact \u27e8a, Fintype.complete _\u27e9\u27e9\n#align fintype.prod_right Fintype.prodRight\n-/\n\ninstance (\u03b1 : Type _) [Fintype \u03b1] : Fintype (ULift \u03b1) :=\n  Fintype.ofEquiv _ Equiv.ulift.symm\n\ninstance (\u03b1 : Type _) [Fintype \u03b1] : Fintype (PLift \u03b1) :=\n  Fintype.ofEquiv _ Equiv.plift.symm\n\ninstance (\u03b1 : Type _) [Fintype \u03b1] : Fintype \u03b1\u1d52\u1d48 :=\n  \u2039Fintype \u03b1\u203a\n\ninstance (\u03b1 : Type _) [Finite \u03b1] : Finite \u03b1\u1d52\u1d48 :=\n  \u2039Finite \u03b1\u203a\n\ninstance (\u03b1 : Type _) [Fintype \u03b1] : Fintype (Lex \u03b1) :=\n  \u2039Fintype \u03b1\u203a\n\nsection Finset\n\n/-! ### `fintype (s : finset \u03b1)` -/\n\n\n#print Finset.fintypeCoeSort /-\ninstance Finset.fintypeCoeSort {\u03b1 : Type u} (s : Finset \u03b1) : Fintype s :=\n  \u27e8s.attach, s.mem_attach\u27e9\n#align finset.fintype_coe_sort Finset.fintypeCoeSort\n-/\n\n#print Finset.univ_eq_attach /-\n@[simp]\ntheorem Finset.univ_eq_attach {\u03b1 : Type u} (s : Finset \u03b1) : (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2}, Eq.{succ u2} (Set.{u2} \u03b2) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (Finset.Set.hasCoeT.{u2} \u03b2))) (Finset.image.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f (Finset.univ.{u1} \u03b1 _inst_1))) (Set.range.{u2, succ u1} \u03b2 \u03b1 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2}, Eq.{succ u1} (Set.{u1} \u03b2) (Finset.toSet.{u1} \u03b2 (Finset.image.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f (Finset.univ.{u2} \u03b1 _inst_1))) (Set.range.{u1, succ u2} \u03b2 \u03b1 f)\nCase conversion may be inaccurate. Consider using '#align fintype.coe_image_univ Fintype.coe_image_univ\u2093'. -/\ntheorem Fintype.coe_image_univ [Fintype \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    \u2191(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 \u03b1] (l : List \u03b1) : Fintype { x // x \u2208 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 \u03b1] (s : Multiset \u03b1) : Fintype { x // x \u2208 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 \u03b1) : Fintype { x // x \u2208 s } :=\n  \u27e8s.attach, s.mem_attach\u27e9\n#align finset.subtype.fintype Finset.Subtype.fintype\n-/\n\n#print FinsetCoe.fintype /-\ninstance FinsetCoe.fintype (s : Finset \u03b1) : Fintype (\u2191s : Set \u03b1) :=\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 \u03b1} : 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  \u27e8if h : p then {\u27e8h\u27e9} else \u2205, fun \u27e8h\u27e9 => by simp [h]\u27e9\n#align plift.fintype_Prop PLift.fintypeProp\n-/\n\n#print Prop.fintype /-\ninstance Prop.fintype : Fintype Prop :=\n  \u27e8\u27e8{True, False}, by simp [true_ne_false]\u27e9, Classical.cases (by simp) (by simp)\u27e9\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\u2093'. -/\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 : \u03b1 \u2192 Prop) [DecidablePred p] [Fintype \u03b1] : Fintype { x // p x } :=\n  Fintype.subtype (univ.filter\u2093 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 \u03b1] (s : Set \u03b1) [DecidablePred (\u00b7 \u2208 s)] : Fintype s :=\n  Subtype.fintype fun x => x \u2208 s\n#align set_fintype setFintype\n-/\n\nsection\n\nvariable (\u03b1)\n\n/- warning: units_equiv_prod_subtype -> unitsEquivProdSubtype is a dubious translation:\nlean 3 declaration is\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Monoid.{u1} \u03b1], Equiv.{succ u1, succ u1} (Units.{u1} \u03b1 _inst_1) (Subtype.{succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => And (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p)) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)))))) (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (Prod.snd.{u1, u1} \u03b1 \u03b1 p) (Prod.fst.{u1, u1} \u03b1 \u03b1 p)) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Monoid.{u1} \u03b1], Equiv.{succ u1, succ u1} (Units.{u1} \u03b1 _inst_1) (Subtype.{succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => And (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 _inst_1)))) (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (Prod.snd.{u1, u1} \u03b1 \u03b1 p) (Prod.fst.{u1, u1} \u03b1 \u03b1 p)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align units_equiv_prod_subtype unitsEquivProdSubtype\u2093'. -/\n/-- The `\u03b1\u02e3` type is equivalent to a subtype of `\u03b1 \u00d7 \u03b1`. -/\n@[simps]\ndef unitsEquivProdSubtype [Monoid \u03b1] : \u03b1\u02e3 \u2243 { p : \u03b1 \u00d7 \u03b1 // p.1 * p.2 = 1 \u2227 p.2 * p.1 = 1 }\n    where\n  toFun u := \u27e8(u, \u2191u\u207b\u00b9), u.val_inv, u.inv_val\u27e9\n  invFun p := Units.mk (p : \u03b1 \u00d7 \u03b1).1 (p : \u03b1 \u00d7 \u03b1).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 (\u03b1 : Type.{u1}) [_inst_1 : GroupWithZero.{u1} \u03b1], Equiv.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_1))) (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_1)))))))))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : GroupWithZero.{u1} \u03b1], Equiv.{succ u1, succ u1} (Units.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_1))) (Subtype.{succ u1} \u03b1 (fun (a : \u03b1) => Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align units_equiv_ne_zero unitsEquivNeZero\u2093'. -/\n/-- In a `group_with_zero` `\u03b1`, the unit group `\u03b1\u02e3` is equivalent to the subtype of nonzero\nelements. -/\n@[simps]\ndef unitsEquivNeZero [GroupWithZero \u03b1] : \u03b1\u02e3 \u2243 { a : \u03b1 // a \u2260 0 } :=\n  \u27e8fun a => \u27e8a, a.NeZero\u27e9, fun a => Units.mk0 _ a.Prop, fun _ => Units.ext rfl, fun _ =>\n    Subtype.ext rfl\u27e9\n#align units_equiv_ne_zero unitsEquivNeZero\n\nend\n\nnamespace Fintype\n\n#print Fintype.finsetEquivSet /-\n/-- Given `fintype \u03b1`, `finset_equiv_set` is the equiv between `finset \u03b1` and `set \u03b1`. (All\nsets on a finite type are finite.) -/\nnoncomputable def finsetEquivSet [Fintype \u03b1] : Finset \u03b1 \u2243 Set \u03b1\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 \u03b1] (s : Finset \u03b1) : 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 \u03b1] (s : Set \u03b1) [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 \u03b1] (s : Setoid \u03b1) [DecidableRel ((\u00b7 \u2248 \u00b7) : \u03b1 \u2192 \u03b1 \u2192 Prop)] :\n    Fintype (Quotient s) :=\n  Fintype.ofSurjective Quotient.mk' fun x => Quotient.inductionOn x fun x => \u27e8x, rfl\u27e9\n#align quotient.fintype Quotient.fintype\n-/\n\n#print PSigma.fintypePropLeft /-\ninstance PSigma.fintypePropLeft {\u03b1 : Prop} {\u03b2 : \u03b1 \u2192 Type _} [Decidable \u03b1] [\u2200 a, Fintype (\u03b2 a)] :\n    Fintype (\u03a3'a, \u03b2 a) :=\n  if h : \u03b1 then Fintype.ofEquiv (\u03b2 h) \u27e8fun x => \u27e8h, x\u27e9, PSigma.snd, fun _ => rfl, fun \u27e8_, _\u27e9 => rfl\u27e9\n  else \u27e8\u2205, fun x => h x.1\u27e9\n#align psigma.fintype_prop_left PSigma.fintypePropLeft\n-/\n\n#print PSigma.fintypePropRight /-\ninstance PSigma.fintypePropRight {\u03b1 : Type _} {\u03b2 : \u03b1 \u2192 Prop} [\u2200 a, Decidable (\u03b2 a)] [Fintype \u03b1] :\n    Fintype (\u03a3'a, \u03b2 a) :=\n  Fintype.ofEquiv { a // \u03b2 a }\n    \u27e8fun \u27e8x, y\u27e9 => \u27e8x, y\u27e9, fun \u27e8x, y\u27e9 => \u27e8x, y\u27e9, fun \u27e8x, y\u27e9 => rfl, fun \u27e8x, y\u27e9 => rfl\u27e9\n#align psigma.fintype_prop_right PSigma.fintypePropRight\n-/\n\n#print PSigma.fintypePropProp /-\ninstance PSigma.fintypePropProp {\u03b1 : Prop} {\u03b2 : \u03b1 \u2192 Prop} [Decidable \u03b1] [\u2200 a, Decidable (\u03b2 a)] :\n    Fintype (\u03a3'a, \u03b2 a) :=\n  if h : \u2203 a, \u03b2 a then \u27e8{\u27e8h.fst, h.snd\u27e9}, fun \u27e8_, _\u27e9 => by simp\u27e9 else \u27e8\u2205, fun \u27e8x, y\u27e9 => h \u27e8x, y\u27e9\u27e9\n#align psigma.fintype_prop_prop PSigma.fintypePropProp\n-/\n\n#print pfunFintype /-\ninstance pfunFintype (p : Prop) [Decidable p] (\u03b1 : p \u2192 Type _) [\u2200 hp, Fintype (\u03b1 hp)] :\n    Fintype (\u2200 hp : p, \u03b1 hp) :=\n  if hp : p then Fintype.ofEquiv (\u03b1 hp) \u27e8fun a _ => a, fun f => f hp, fun _ => rfl, fun _ => rfl\u27e9\n  else \u27e8singleton fun h => (hp h).elim, by simp [hp, Function.funext_iff]\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} {b : \u03b2}, Iff (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) b (Finset.image.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f (Finset.univ.{u1} \u03b1 _inst_1))) (Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) b (Set.range.{u2, succ u1} \u03b2 \u03b1 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} {b : \u03b2}, Iff (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) b (Finset.image.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f (Finset.univ.{u2} \u03b1 _inst_1))) (Membership.mem.{u1, u1} \u03b2 (Set.{u1} \u03b2) (Set.instMembershipSet.{u1} \u03b2) b (Set.range.{u1, succ u2} \u03b2 \u03b1 f))\nCase conversion may be inaccurate. Consider using '#align mem_image_univ_iff_mem_range mem_image_univ_iff_mem_range\u2093'. -/\ntheorem mem_image_univ_iff_mem_range {\u03b1 \u03b2 : Type _} [Fintype \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {b : \u03b2} : b \u2208 univ.image f \u2194 b \u2208 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 \u03b1] (p : \u03b1 \u2192 Prop) [DecidablePred p]\n\n#print Fintype.chooseX /-\n/-- Given a fintype `\u03b1` and a predicate `p`, associate to a proof that there is a unique element of\n`\u03b1` satisfying `p` this unique element, as an element of the corresponding subtype. -/\ndef chooseX (hp : \u2203! a : \u03b1, p a) : { a // p a } :=\n  \u27e8Finset.choose p univ (by simp <;> exact hp), Finset.choose_property _ _ _\u27e9\n#align fintype.choose_x Fintype.chooseX\n-/\n\n#print Fintype.choose /-\n/-- Given a fintype `\u03b1` and a predicate `p`, associate to a proof that there is a unique element of\n`\u03b1` satisfying `p` this unique element, as an element of `\u03b1`. -/\ndef choose (hp : \u2203! a, p a) : \u03b1 :=\n  chooseX p hp\n#align fintype.choose Fintype.choose\n-/\n\n#print Fintype.choose_spec /-\ntheorem choose_spec (hp : \u2203! 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 {\u03b1 : Type _} (p : \u03b1 \u2192 Prop) [Fintype { a : \u03b1 // p a }] [DecidableEq \u03b1]\n    (x : { a : \u03b1 // p a })\n    (h : \u2203! a : { a // p a }, (a : \u03b1) = x :=\n      \u27e8x, rfl, fun y hy => by simpa [Subtype.ext_iff] using hy\u27e9) :\n    Fintype.choose (fun y : { a : \u03b1 // p a } => (y : \u03b1) = x) h = x := by\n  rw [Subtype.ext_iff, Fintype.choose_spec (fun y : { a : \u03b1 // p a } => (y : \u03b1) = x) _]\n#align fintype.choose_subtype_eq Fintype.choose_subtype_eq\n-/\n\nend Choose\n\nsection BijectionInverse\n\nopen Function\n\nvariable [Fintype \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\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 : \u03b2) : \u03b1 :=\n  Fintype.choose (fun a => f a = b)\n    (by\n      rcases f_bij.right b with \u27e8a', fa_eq_b\u27e9\n      rw [\u2190 fa_eq_b]\n      exact \u27e8a', \u27e8rfl, fun a h => f_bij.left h\u27e9\u27e9)\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} (f_bij : Function.Bijective.{succ u1, succ u2} \u03b1 \u03b2 f), Function.LeftInverse.{succ u1, succ u2} \u03b1 \u03b2 (Fintype.bijInv.{u1, u2} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f f_bij) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} (f_bij : Function.Bijective.{succ u2, succ u1} \u03b1 \u03b2 f), Function.LeftInverse.{succ u2, succ u1} \u03b1 \u03b2 (Fintype.bijInv.{u2, u1} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f f_bij) f\nCase conversion may be inaccurate. Consider using '#align fintype.left_inverse_bij_inv Fintype.leftInverse_bijInv\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} (f_bij : Function.Bijective.{succ u1, succ u2} \u03b1 \u03b2 f), Function.RightInverse.{succ u1, succ u2} \u03b1 \u03b2 (Fintype.bijInv.{u1, u2} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f f_bij) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} (f_bij : Function.Bijective.{succ u2, succ u1} \u03b1 \u03b2 f), Function.RightInverse.{succ u2, succ u1} \u03b1 \u03b2 (Fintype.bijInv.{u2, u1} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f f_bij) f\nCase conversion may be inaccurate. Consider using '#align fintype.right_inverse_bij_inv Fintype.rightInverse_bijInv\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Fintype.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} (f_bij : Function.Bijective.{succ u1, succ u2} \u03b1 \u03b2 f), Function.Bijective.{succ u2, succ u1} \u03b2 \u03b1 (Fintype.bijInv.{u1, u2} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f f_bij)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Fintype.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} (f_bij : Function.Bijective.{succ u2, succ u1} \u03b1 \u03b2 f), Function.Bijective.{succ u1, succ u2} \u03b2 \u03b1 (Fintype.bijInv.{u2, u1} \u03b1 \u03b2 _inst_1 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) f f_bij)\nCase conversion may be inaccurate. Consider using '#align fintype.bijective_bij_inv Fintype.bijective_bijInv\u2093'. -/\ntheorem bijective_bijInv (f_bij : Bijective f) : Bijective (bijInv f_bij) :=\n  \u27e8(rightInverse_bijInv _).Injective, (leftInverse_bijInv _).Surjective\u27e9\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 \u03b1`, we can lift the existential statement that `\u2203 x, x \u2208 s` to a `trunc \u03b1`.\n-/\ndef truncOfMultisetExistsMem {\u03b1} (s : Multiset \u03b1) : (\u2203 x, x \u2208 s) \u2192 Trunc \u03b1 :=\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 (\u03b1) [Nonempty \u03b1] [Fintype \u03b1] : Trunc \u03b1 :=\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 `\u2203 a, P a`\nto `trunc (\u03a3' a, P a)`, containing data.\n-/\ndef truncSigmaOfExists {\u03b1} [Fintype \u03b1] {P : \u03b1 \u2192 Prop} [DecidablePred P] (h : \u2203 a, P a) :\n    Trunc (\u03a3'a, P a) :=\n  @truncOfNonemptyFintype (\u03a3'a, P a) (Exists.elim h fun a ha => \u27e8\u27e8a, ha\u27e9\u27e9) _\n#align trunc_sigma_of_exists truncSigmaOfExists\n-/\n\nend Trunc\n\nnamespace Multiset\n\nvariable [Fintype \u03b1] [DecidableEq \u03b1]\n\n#print Multiset.count_univ /-\n@[simp]\ntheorem count_univ (a : \u03b1) : 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 {\u03b1 : Type _} [DecidableEq \u03b1] (P : \u03b1 \u2192 Prop)\n    (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 s : Finset \u03b1, \u2203 y, (\u2200 x \u2208 s, P x) \u2192 P y \u2227 \u2200 x \u2208 s, r x y) : \u2115 \u2192 \u03b1\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 : \u2115 \u2192 \u03b1` 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 {\u03b1 : Type _} (P : \u03b1 \u2192 Prop) (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n    (h : \u2200 s : Finset \u03b1, (\u2200 x \u2208 s, P x) \u2192 \u2203 y, P y \u2227 \u2200 x \u2208 s, r x y) :\n    \u2203 f : \u2115 \u2192 \u03b1, (\u2200 n, P (f n)) \u2227 \u2200 m n, m < n \u2192 r (f m) (f n) := by\n  classical\n    have : Nonempty \u03b1 := by\n      rcases h \u2205 (by simp) with \u27e8y, hy\u27e9\n      exact \u27e8y\u27e9\n    choose! F hF using h\n    have h' : \u2200 s : Finset \u03b1, \u2203 y, (\u2200 x \u2208 s, P x) \u2192 P y \u2227 \u2200 x \u2208 s, r x y := fun s => \u27e8F s, hF s\u27e9\n    set f := seqOfForallFinsetExistsAux P r h' with hf\n    have A : \u2200 n : \u2115, P (f n) := by\n      intro n\n      induction' n using Nat.strong_induction_on with n IH\n      have IH' : \u2200 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' \u27e8f, A, fun m n hmn => _\u27e9\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 \u27e8\u27e8m, hmn\u27e9, Finset.mem_univ _, rfl\u27e9\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 : \u2115 \u2192 \u03b1` such that `r (f m) (f n)` holds whenever `m \u2260 n`.\nWe also ensure that all constructed points satisfy a given predicate `P`. -/\ntheorem exists_seq_of_forall_finset_exists' {\u03b1 : Type _} (P : \u03b1 \u2192 Prop) (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n    [IsSymm \u03b1 r] (h : \u2200 s : Finset \u03b1, (\u2200 x \u2208 s, P x) \u2192 \u2203 y, P y \u2227 \u2200 x \u2208 s, r x y) :\n    \u2203 f : \u2115 \u2192 \u03b1, (\u2200 n, P (f n)) \u2227 \u2200 m n, m \u2260 n \u2192 r (f m) (f n) :=\n  by\n  rcases exists_seq_of_forall_finset_exists P r h with \u27e8f, hf, hf'\u27e9\n  refine' \u27e8f, hf, fun m n hmn => _\u27e9\n  rcases lt_trichotomy m n with (h | rfl | h)\n  \u00b7 exact hf' m n h\n  \u00b7 exact (hmn rfl).elim\n  \u00b7 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 := \u27e8\u27e9\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 \u2192* Y) : of X \u27f6 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 \u2192* 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 := \u27e8Group.of punit\u27e9\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 \u27f6 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\u2082 Group Mon := bundled_hom.forget\u2082 _ _\n\n@[to_additive] instance : has_coe Group.{u} Mon.{u} :=\n{ coe := (forget\u2082 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 := \u27e8\u27e9\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 \u2192* Y) :\n  of X \u27f6 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 \u2192* 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 := \u27e8CommGroup.of punit\u27e9\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 \u27f6 H) g = 1 := rfl\n\n@[ext, to_additive]\nlemma ext (G H : CommGroup) (f\u2081 f\u2082 : G \u27f6 H) (w : \u2200 x, f\u2081 x = f\u2082 x) : f\u2081 = f\u2082 :=\nby { ext1, apply w }\n\n@[to_additive has_forget_to_AddGroup]\ninstance has_forget_to_Group : has_forget\u2082 CommGroup Group := bundled_hom.forget\u2082 _ _\n\n@[to_additive] instance : has_coe CommGroup.{u} Group.{u} :=\n{ coe := (forget\u2082 CommGroup Group).obj, }\n\n@[to_additive has_forget_to_AddCommMon]\ninstance has_forget_to_CommMon : has_forget\u2082 CommGroup CommMon :=\ninduced_category.has_forget\u2082 (\u03bb G : CommGroup, CommMon.of G)\n\n@[to_additive] instance : has_coe CommGroup.{u} CommMon.{u} :=\n{ coe := (forget\u2082 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 \u27f6 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 `\u2124` sending\n`1` to that element. -/\n-- Note that because `\u2124 : 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 \u2124) \u27f6 G :=\nzmultiples_hom G g\n\n@[simp]\nlemma as_hom_apply {G : AddCommGroup.{0}} (g : G) (i : \u2124) : (as_hom g) i = i \u2022 g := rfl\n\nlemma as_hom_injective {G : AddCommGroup.{0}} : function.injective (@as_hom G) :=\n\u03bb h k w, by convert congr_arg (\u03bb k : (AddCommGroup.of \u2124) \u27f6 G, (k : \u2124 \u2192 G) (1 : \u2124)) w; simp\n\n@[ext]\nlemma int_hom_ext\n  {G : AddCommGroup.{0}} (f g : (AddCommGroup.of \u2124) \u27f6 G) (w : f (1 : \u2124) = g (1 : \u2124)) : 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 \u27f6 H) [mono f] : function.injective f :=\n\u03bb g\u2081 g\u2082 h,\nbegin\n  have t0 : as_hom g\u2081 \u226b f = as_hom g\u2082 \u226b f :=\n  begin\n    ext,\n    simpa [as_hom_apply] using h,\n  end,\n  have t1 : as_hom g\u2081 = as_hom g\u2082 := (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 \u2243* Y) : X \u2245 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 \u2243* Y) : X \u2245 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 \u2245 Y) : X \u2243* 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 \u2245 Y) : X \u2243* 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 \u2243* Y) \u2245 (X \u2245 Y) :=\n{ hom := \u03bb e, e.to_Group_iso,\n  inv := \u03bb 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 \u2243* Y \u2245 (X \u2245 Y) :=\n{ hom := \u03bb e, e.to_CommGroup_iso,\n  inv := \u03bb 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 {\u03b1 : Type u} : Group.of (Aut \u03b1) \u2245 Group.of (equiv.perm \u03b1) :=\n{ hom := \u27e8\u03bb g, g.to_equiv, (by tidy), (by tidy)\u27e9,\n  inv := \u27e8\u03bb g, g.to_iso, (by tidy), (by tidy)\u27e9 }\n\n/-- The (unbundled) group of automorphisms of a type is `mul_equiv` to the (unbundled) group\nof permutations. -/\ndef mul_equiv_perm {\u03b1 : Type u} : Aut \u03b1 \u2243* equiv.perm \u03b1 :=\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 := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Group).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Group_iso).1\u27e9,\n  end }\n\n@[to_additive]\ninstance CommGroup.forget_reflects_isos : reflects_isomorphisms (forget CommGroup.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommGroup).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommGroup_iso).1\u27e9,\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 (\ud835\udd5c : Type*) [nondiscrete_normed_field \ud835\udd5c]\nvariables {\ud835\udd5c' : Type*} [nondiscrete_normed_field \ud835\udd5c'] [normed_algebra \ud835\udd5c \ud835\udd5c']\nvariables {E : Type*} [normed_group E] [normed_space \ud835\udd5c E] [normed_space \ud835\udd5c' E]\nvariables [is_scalar_tower \ud835\udd5c \ud835\udd5c' E]\nvariables {F : Type*} [normed_group F] [normed_space \ud835\udd5c F] [normed_space \ud835\udd5c' F]\nvariables [is_scalar_tower \ud835\udd5c \ud835\udd5c' F]\nvariables {f : E \u2192 F} {f' : E \u2192L[\ud835\udd5c'] F} {s : set E} {x : E}\n\nlemma differentiable_at_iff_exists_linear_map (hf : differentiable_at \ud835\udd5c f x) :\n  differentiable_at \ud835\udd5c' f x \u2194 \u2203 (g' : E \u2192L[\ud835\udd5c'] F), g'.restrict_scalars \ud835\udd5c = fderiv \ud835\udd5c f x :=\nsorry\n\nend A\n\nsection B\n\nvariables {E : Type*} [normed_group E] [normed_space \u211d E] [normed_space \u2102 E]\n  [is_scalar_tower \u211d \u2102 E] {z : \u2102} {g : \u2102 \u2192L[\u211d] E} {f : \u2102 \u2192 E}\n\nlemma is_conformal_map_of_complex_linear\n  {map : \u2102 \u2192L[\u2102] E} (nonzero : map \u2260 0) : is_conformal_map (map.restrict_scalars \u211d) :=\nsorry\n\n\nlemma conformal_at_of_holomorph_or_antiholomorph_at_aux\n  (hf : differentiable_at \u211d f z) (hf' : fderiv \u211d f z \u2260 0)\n  (h : differentiable_at \u2102 f z \u2228 differentiable_at \u2102 (f \u2218 conj) (conj z)) :\n  conformal_at f z :=\nbegin\n  rw [conformal_at_iff_is_conformal_map_fderiv],\n  cases h with h\u2081 h\u2082,\n  { rw [differentiable_at_iff_exists_linear_map \u211d hf] at h\u2081;\n       [skip, apply_instance, apply_instance, apply_instance],\n    rcases h\u2081 with \u27e8map, hmap\u27e9,\n    have minor\u2081 : fderiv \u211d f z = map.restrict_scalars \u211d := hmap.symm,\n    rw minor\u2081,\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 algebra.module.basic\nimport algebra.module.linear_map\nimport linear_algebra.basic\nimport linear_algebra.prod\nimport linear_algebra.projection\nimport order.bounded_lattice\n\n\ntheorem cpge_reduction_7_a (R : Type*) (M : Type*) \n[semiring R] [add_comm_monoid M] [module R M] \n(E : submodule R M) (u : linear_map R M M): \n\nu^3 + u = 0 -> (u '' E) \u2282 E := 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/reduction/cpge_reduction_007_a.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9046505299595162, "lm_q2_score": 0.5389832206876841, "lm_q1q2_score": 0.4875914562344003}}
{"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 ` \u229a `:80 g:80 := category_struct.comp g f\n\nvariables   {F : Type u \u2964 Type u}\n            {\ud835\udd38 \u0392: Coalgebra F}\n            (\u03d5 \u03c8 : \ud835\udd38 \u27f6 \u0392)\n\ntheorem largest_subcoalgebra_equalizer \n    {C : set (equalizer_set \u03d5 \u03c8)}\n    (lar : is_largest_coalgebra C):\n    let E := equalizer_set \u03d5 \u03c8 in\n    let e : E \u2192 \ud835\udd38 := (E \u21aa \ud835\udd38) in\n    let \u2102 : Coalgebra F := \u27e8C , some lar.1\u27e9  in\n    let \u03c3 : \u2102 \u27f6 \ud835\udd38 := \u27e8(e \u2218 (C \u21aa E))  , some_spec lar.1\u27e9 in\n    is_equalizer \u03d5 \u03c8 \u03c3 := \n    begin \n        intros E e \u2102 \u03c3,\n\n        split,\n\n        exact eq_in_set.1 \n            (funext (\u03bb c, ((C \u21aa E) c).property)),\n        \n        intros Q q \u03d5q_\u03c8q,\n\n        have is_eq := (eqaulizer_set_is_equalizer \u03d5 \u03c8).2 q \n                    (eq_in_set.2 \u03d5q_\u03c8q),\n\n        let f : Q \u2192 E := some is_eq,\n        have eq_f := some_spec is_eq,\n\n        have fact : q.val = e \u2218 f := eq_f.1,\n\n        let f\u2081 : Q \u2192 (range f) := range_factorization f,\n\n        let e\u2081 : range f \u2192 \ud835\udd38 := e \u2218 (range f \u21aa E),\n\n        have inj_e\u2081 : injective e\u2081 := \n            begin\n                intros a\u2081 a\u2082 k,\n                have inj_e : \u2200 r\u2081 r\u2082, e r\u2081 = e r\u2082 \u2192 r\u2081 = r\u2082 := \n                    inj_inclusion \ud835\udd38 E,\n                have ra : (range f \u21aa E) a\u2081 = (range f \u21aa E) a\u2082 :=\n                    inj_e a\u2081 a\u2082 k,\n                have inj_r : \u2200 q\u2081 q\u2082, \n                    (range f \u21aa E) q\u2081 = (range f \u21aa E) q\u2082 \u2192 q\u2081 = q\u2082 := \n                        inj_inclusion E (range f),\n                exact (inj_r) a\u2081 a\u2082 ra,\n            end,\n\n        have inj_\u03c3 : injective \u03c3 := \n            begin\n                intros a\u2081 a\u2082 k,\n                have inj_e : \u2200 r\u2081 r\u2082, e r\u2081 = e r\u2082 \u2192 r\u2081 = r\u2082 := \n                    inj_inclusion \ud835\udd38 E,\n                have ra : (C \u21aa E) a\u2081 = (C \u21aa E) a\u2082 :=\n                    inj_e a\u2081 a\u2082 k,\n                have inj_r : \u2200 q\u2081 q\u2082, (C \u21aa E) q\u2081 = (C \u21aa E) q\u2082 \u2192 q\u2081 = q\u2082 := \n                    inj_inclusion E C,\n                exact inj_r a\u2081 a\u2082 ra,\n            end,\n\n        have ex := Factorization q f\u2081 e\u2081 fact\n            ((epi_iff_surjective f\u2081).2 surjective_onto_range) inj_e\u2081,\n\n        let \u03b1_\u211d : range f \u2192 F.obj (range f) := some ex,\n\n        have Rf_C : range f \u2286 C := \n            lar.2 (range f) (exists.intro \u03b1_\u211d (some_spec ex).1.2),\n\n        let fc : Q.carrier \u2192 \u2102.carrier := \u03bb q\u2081 , \u27e8f q\u2081, Rf_C (f\u2081 q\u2081).property \u27e9, \n\n        have f_fc : \u2200 q\u2081, f q\u2081 = fc q\u2081 := \u03bb q\u2081, rfl,\n\n        have q_fc_\u03c3_el : \u2200 q\u2081 , q.val q\u2081 = (\u03c3 \u2218 fc) q\u2081 := \n            \u03bb q\u2081, \n            have s0 : (\u03c3 \u2218 fc) q\u2081 = (e \u2218 f) q\u2081 := rfl,\n            by rw [fact, s0],\n        \n        have q_fc_\u03c3 : q.val = \u03c3 \u2218 fc := funext q_fc_\u03c3_el,\n        \n        have hom_\u03c3_fc : @is_coalgebra_homomorphism F Q \ud835\udd38 (\u03c3 \u2218 fc) :=\n            q_fc_\u03c3 \u25b8 q.property,\n\n        have hom_fc : @is_coalgebra_homomorphism F Q \u2102 fc :=\n            inj_to_hom fc \u03c3 hom_\u03c3_fc \u03c3.property inj_\u03c3,\n        \n        let h_fc : Q \u27f6 \u2102 := \u27e8fc , hom_fc \u27e9,\n\n        use h_fc, \n        have s1 : q.val = (\u03c3 \u229a h_fc).val := q_fc_\u03c3,\n        split,\n        exact eq_in_set.1 s1,\n\n        intros g q_\u03c3_g,\n\n        let \u03c3\u2081 : \u2102.carrier \u27f6 \ud835\udd38.carrier := \u03c3.val,\n\n        have inj_\u03c3\u2081 : injective \u03c3\u2081 := inj_\u03c3,\n\n        haveI mo : mono \u03c3\u2081 := (mono_iff_injective \u03c3).2 inj_\u03c3\u2081, \n\n        have s2 : (\u03c3 \u229a g).val = (\u03c3 \u229a h_fc).val := \n             q_\u03c3_g \u25b8 s1,\n\n        have s3 : \u03c3.val \u2218 g.val = \u03c3.val \u2218 h_fc.val := \n             s2,\n        \n        have s4 : g.val = h_fc.val :=  left_cancel \u03c3\u2081 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 \u2192 N) : with_top M \u2192 with_top N\n| \u22a4 := \u22a4\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\u2200 a b : with_top M, (a + b).cast_fun f = a.cast_fun f + b.cast_fun f\n| \u22a4 b := show _ = \u22a4 + _, by simp only [with_top.top_add]; refl\n| a \u22a4 := show _ = _ + \u22a4, by simp only [with_top.add_top]; refl \n| (a : M) (b : M) := \nby rw [\u2190 with_top.coe_add, with_top.cast_fun, with_top.cast_fun, with_top.cast_fun,\n    \u2190 with_top.coe_add, with_top.coe_eq_coe, map_add]\n\nlemma with_top.cast_fun_eq_top : \u2200 {x : with_top M}, x.cast_fun f = \u22a4 \u2192 x = \u22a4\n| \u22a4 := \u03bb h, rfl \n| (x : M) := \u03bb 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| \u22a4 y h := (with_top.cast_fun_eq_top h.symm).symm\n| x \u22a4 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 \u2192+ 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)) \u2192*\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)) \u2192*\u2080\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 \u2194 x = 0 :=\nbegin\n  rw [\u2190 mulcast_map_zero f],\n  exact \u27e8\u03bb h, mulcast_injective hf h, congr_arg _\u27e9\nend\n\n/- lemma mulcast_map_gen : \n  mulcast (mul_gen (with_top \u2124)) = mul_gen (with_top \u211a) :=\nshow \u2191_ = \u2191_, by rw int.cast_one -/\n\nlemma with_top_cast_le_with_top_cast (hf : strict_mono f) : \u2200 (x y : with_top M),\n  with_top.cast_fun f x \u2264 with_top.cast_fun f y \u2194  x \u2264 y\n| \u22a4 b := \nby erw [top_le_iff, top_le_iff]; exact \u27e8with_top.cast_fun_eq_top, \u03bb h, h.symm \u25b8 rfl\u27e9\n| a \u22a4 := \u27e8\u03bb h, le_top, \u03bb h, le_top\u27e9\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) : \u2200 (x y : with_top M),\n  with_top.cast_fun f x < with_top.cast_fun f y \u2194  x < y\n| \u22a4 \u22a4 := by simp only [lt_self_iff_false]\n| \u22a4 (b : M) := by { simp only [not_top_lt, iff_false, not_lt], exact le_top } \n| (a : M) \u22a4 := \u27e8\u03bb h, with_top.coe_lt_top _, \u03bb h, with_top.coe_lt_top _\u27e9\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 \u2264 mulcast f y \u2194 x \u2264 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 \u2194 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 \u2260 0) : \u2200 a b : with_top M,\n  (a + b) * m = a * m + b * m\n| \u22a4 _ :=\nby rw [top_add, with_top.top_mul (show (m : with_top M) \u2260 0, by norm_cast; exact hm), top_add]\n| _ \u22a4 :=\nby rw [add_top, with_top.top_mul (show (m : with_top M) \u2260 0, by norm_cast; exact hm), add_top]\n| (some a) (some b) :=\nby simp only [with_top.some_eq_coe, \u2190with_top.coe_add, \u2190with_top.coe_mul, add_mul]\n\nlemma mul_eq_top_iff (m : M) (hm : m \u2260 0) : \u2200 a : with_top M,\n  a * m = \u22a4 \u2194 a = \u22a4\n| \u22a4 := \u27e8\u03bb h, rfl, \u03bb h, by rw [with_top.top_mul]; norm_cast; exact hm\u27e9\n| (some m) := \n\u27e8\u03bb h, absurd (by rwa [with_top.some_eq_coe, \u2190with_top.coe_mul] at h) with_top.coe_ne_top, \n \u03bb h, absurd h with_top.coe_ne_top\u27e9\n\nlemma succ_nsmul_top (m : \u2115) : ((m + 1) \u2022 \u22a4 : with_top M) = \u22a4 :=\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 : \u2115) (q : M) :\n  (m \u2022 (\u22a4 : with_top M)) * q = \u22a4 * (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) \u2260 0, by norm_cast; exact h),\n      refine (with_top.top_mul _).symm,\n      norm_cast,\n      exact (\u03bb 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) : \u2200 x : with_top M,\n  0 \u2264 x \u2194 0 \u2264 x * m\n| \u22a4 := by {rw with_top.top_mul, norm_cast, linarith }\n| (some a) := \nbegin\n  simp only [with_top.some_eq_coe, \u2190with_top.coe_zero, \u2190with_top.coe_mul, \n    with_top.coe_le_coe, zero_le_mul_right hm],\nend\n\nlemma nsmul_coe (m : \u2115) (x : M) : m \u2022 (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 : \u2115) : m \u2022 (\u22a4 : with_top M) = m * \u22a4 :=\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 : \u2115) : \u2200 (x : with_top M), m \u2022 x = m * x \n| \u22a4 := nsmul_top _ \n| (some x) := nsmul_coe _ _\n\nlemma nsmul_coe_mul (m : \u2115) (x q : M) :\n  (m \u2022 (x : with_top M)) * q = x * (m * q : M) :=\nbegin\n  rw [nsmul_coe, mul_comm \u2191m, mul_assoc],\n  congr,\n  norm_cast,\nend \n\nlemma nsmul_mul (m : \u2115) (q : M) : \u2200 x : with_top M,\n  (m \u2022 x : with_top M) * q = x * (m * q : M) \n| \u22a4 := nsmul_top_mul _ _\n| (some x) := nsmul_coe_mul m x q\n\nlemma nsmul_comm (m : \u2115) (q : M) (x : with_top M) :\n  (m \u2022 x : with_top M) * q = m \u2022 (x * q) := \nbegin \n  rw [nsmul_mul, with_top.coe_mul, \u2190mul_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\u27e8\u03bb x y, ((x : with_top M) * y : with_top M)\u27e9 \n\nlemma mulM_mul_pow {m : M} (hm : m \u2260 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 \u2260 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 \u2264 1 \u2194 x ^ q \u2264 1 :=\nzero_le_mul_inv _ h _\n\nlemma mulM_pow_eq_zero_iff (x : multiplicative (order_dual (with_top M))) {q : M} (h : q \u2260 0) :\n  x ^ q = 0 \u2194 x = 0 :=\nmul_eq_top_iff _ h _ \n\nlemma mulM_pow_mul (n : \u2115) (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 : \u2115) (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 : \u2115) (h : m \u2260 0) :\n  \u2200 g h : with_top M, g \u2264 h \u2192 g * (m\u207b\u00b9 : M) \u2264 h * (m\u207b\u00b9 : M) \n| \u22a4 a H := \nbegin\n  rw [top_le_iff.1 H, with_top.top_mul],\n  { exact le_refl _},\n  { simp [h] }\nend\n| a \u22a4 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, \u2190with_top.coe_mul,\n    with_top.coe_le_coe, with_top.some_eq_coe] at \u22a2 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 : \u2115} {g h : multiplicative (order_dual (with_top M))} (hm : m \u2260 0)\n  (H : h \u2264 g) : h ^ (m\u207b\u00b9 : M) \u2264 g ^ (m\u207b\u00b9 : 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 \u2192 Type v}\nvariable [monad m]\nvariables {\u03b1 \u03b2 \u03b3 : Type u}\n\nopen functor nat\n\nnamespace monad\n\nlemma map_bind (f : \u03b3 \u2192 \u03b2) (x : m \u03b1) (g : \u03b1 \u2192 m \u03b3)\n: f <$> (x >>= g) = x >>= (map f \u2218 g) :=\nsorry\n\nlemma bind_map (f : \u03b1 \u2192 \u03b2) (x : m \u03b1) (g : \u03b2 \u2192 m \u03b3)\n: f <$> x >>= g = x >>= g \u2218 f :=\nsorry\n\ndef mmap\u2082  (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b3) : list \u03b1 \u2192 list \u03b2 \u2192 m (list \u03b3)\n| (x :: xs) (y :: ys) := (::) <$> f x y <*> mmap\u2082 xs ys\n| [] _ := pure []\n| _ [] := pure []\n\ndef mmap\u2082'  (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b3) : list \u03b1 \u2192 list \u03b2 \u2192 m punit\n| (x :: xs) (y :: ys) := f x y *> mmap\u2082' xs ys\n| [] _ := pure punit.star\n| _ [] := pure punit.star\n\nend monad\n\nopen applicative\n\ndef monad.mrepeat : \u2115 \u2192 m \u03b1 \u2192 m (list \u03b1)\n | 0 _ := return []\n | (succ n) m := lift\u2082 (::) m (monad.mrepeat n m)\n\ndef monad.mrepeat' : \u2115 \u2192 m \u03b1 \u2192 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 deduction data.equiv.denumerable\nimport data.nat.sqrt\nimport data.set.lattice\nopen encodable denumerable \n\nuniverses u\n\nnamespace fopl\nvariables {L : language.{u}} [\u2200 n, encodable (L.fn n)] [\u2200 n, encodable (L.pr n)]\n\ndef term_encode : term L \u2192 \u2115\n| (#x) := bit0 x\n| (@term.app _ n f v) :=\n    bit1 (nat.mkpair n (nat.mkpair (encode f) (encode (\u03bb x, term_encode (v x)))))\n\n-- TODO: \u3053\u308c\u3089\u3092\u8a3c\u660e\u3059\u308b\ninstance : primcodable (term L) := by sorry\n\ninstance : primcodable (formula L) := by sorry\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*}\n  [primcodable \u03b1] [primcodable \u03b2]\n\nlemma primrec.term_rew {f : \u03b1 \u2192 term L} {s : \u03b1 \u2192 \u2115 \u2192 term L}\n  (hf : primrec f) (hs : primrec\u2082 s) :\n  primrec (\u03bb x, term.rew (s x) (f x)) := by sorry\n\nlemma primrec.formula_rew {f : \u03b1 \u2192 formula L} {s : \u03b1 \u2192 \u2115 \u2192 term L}\n  (hf : primrec f) (hs : primrec\u2082 s) :\n  primrec (\u03bb x, formula.rew (s x) (f x)) := by sorry\n\nend fopl", "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/coding.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879311956428947, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4875564070002208}}
{"text": "import FirstOrderLeaning\n\nopen Classical\n\ninductive Asrt where\n  | literal : Bool \u2192 Asrt\n  | emp : Asrt\n  | singleton : Nat \u2192 Nat \u2192 Asrt\n  | sep : Asrt \u2192 Asrt \u2192 Asrt\n--  | sepimp : Asrt \u2192 Asrt \u2192 Asrt\nopen Asrt\n\ndef Partial (A B : Type): Type := A \u2192 Option B\n\ndef Store : Type := Nat \u2192 Nat\ndef Heap : Type := Partial Nat Nat\n\ndef Subset (A : Type) : Type := A \u2192 Prop\n\ndef empty_set {A : Type} : Subset A :=\n\u03bb x => false\n\ndef set_union {A : Type} (s1 s2 : Subset A) : Subset A :=\n\u03bb x => (s1 x) \u2228 (s2 x)\n\ndef set_intersection {A : Type} (s1 s2 : Subset A) : Subset A :=\n\u03bb x => (s1 x) \u2227 (s2 x)\n\ndef set_disjoint {A : Type} (s1 s2 : Subset A) : Prop :=\n\u2200 x , \u00ac((s1 x) \u2227 (s2 x))\n\ndef set_subset {A : Type} (s1 s2 : Subset A) : Prop :=\n\u2200 x , (s1 x) \u2192 (s2 x)\n\n-- s1 / s2\ndef set_difference {A : Type} (s1 s2 : Subset A) : Subset A :=\n\u03bb x => (s1 x) \u2227 \u00ac(s2 x)\n\n@[simp] def equal {A : Type} (s1 s2 : Subset A) : Prop :=\n  \u2200 x , s1 x \u2194 s2 x\n\n@[simp] def dom {A B : Type}  (p : Partial A B) : Subset A := \u03bb a => (p a).isSome\n\ndef empty_partial {A B : Type} : Partial A B := \u03bb x => none\n\nnoncomputable def singleton_partial {A B : Type} (a : A) (b : B) : Partial A B := \u03bb 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 \" \u22a5 \" => disjoint\n\ntheorem disjoint_symm {A B : Type} {p1 p2 : Partial A B} : p1 \u22a5 p2 \u2194 p2 \u22a5 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[\u2190 lhs];\n    apply funext;\n    intro x;\n    rw[and_symm];\n  }\n  case mpr => {\n    intro lhs;\n    rw[\u2190 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  \u2200 x , match p1 x with\n  | some y => (p2 x) = some y\n  | none   => True\n\ninfix:60 \" \u2286 \" => partial_of\n\n@[simp] theorem partial_of_emp {A B : Type} (p : Partial A B) : empty_partial \u2286 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) \u2286 p) \u2194 (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 \u2286 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 \u27e8 witness, proof \u27e9;\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 \u2286 p2 \u2192 p2 \u2286 p3 \u2192 p1 \u2286 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 \u27e8 witness, proof \u27e9;\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 \u22a5 p2 \u2192 p1' \u2286 p1 \u2192 p1' \u22a5 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 \u27e8 witness, proof \u27e9;\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\u03bb x => if (p1 x) = none then (p2 x) else (p1 x)\n\ninfix:60 \" \u222a \" => union\n\ntheorem union_disjoint_symm : p1 \u22a5 p2 \u2192 p1 \u222a p2 = p2 \u222a 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 \u27e8 witness, proof \u27e9;\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 \u22a5 p2 \u2192 p = p1 \u222a p2 \u2192 p1 \u2286 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 \u27e8 witness, proof \u27e9;\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 \u22a5 p2 \u2192 p = p1 \u222a p2 \u2192 p1 \u2286 p \u2227 p2 \u2286 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\u03bb 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) \u2192 \u00ac 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) \u2192 (\u2203 (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 \u2286 p3 \u2227 disjoint p1 p2 \u2192 p1 \u2286 (partial_difference p3 p2) := by {\n  simp [partial_of, partial_difference, disjoint, set_intersection, empty_set];\n  intro \u27e8 partial_p1_p3 , disjoint_p1_p2 \u27e9 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 \u27e8 witness, proof\u27e9;\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 \u2286 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 \u27e8 proof , witness \u27e9;\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 \u27e8 witness , proof \u27e9;\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 \u22a5 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 \u27e8 witness, proof \u27e9;\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 \u2286 p1 \u2192 p1 = (partial_difference p1 p2) \u222a 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 \u27e8 witness, proof \u27e9;\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    \u00b7 rw[is_some]; intro \u27e8 witness , proof \u27e9 ; simp[proof];\n    \u00b7 rw[is_not_some]; intro temp; simp[temp];\n  }\n}\n\ntheorem difference_union_opposite' {p1 p2 : Partial A B} : p2 \u2286 p1 \u2192 p1 = p2 \u222a (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       => \u2200 x , (dom h) x = false\n  | singleton v1 v2 => h (s v1) = some (s v2) \u2227 \u2200 x , (dom h) x \u2194 (x = (s v1))\n  | sep q1 q2 => \u2203 h1 h2 , (asrt q1 s h1) \u2227 (asrt q2 s h2) \u2227 (disjoint h1 h2) \u2227 h = (union h1 h2)\n--  | sepimp q1 q2 => \u2200 h' , (asrt q1 s h') \u2227 disjoint h h' -> asrt q2 s (union h h')\n\n@[simp]\nnoncomputable def check (q : Asrt) (s : Store) (h : Heap) : (Prop \u00d7 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 \u27e8 b1 , m1 \u27e9 := (check q1 s h); let \u27e8 b2 , m2 \u27e9 := (check q2 s h); (b1 \u2227 b2 \u2227 (disjoint m1 m2) , (union m1 m2))\n--  | sepimp q1 q2 => let \u27e8 b1 , m1 , t1 \u27e9 := (check q1 s h); let \u27e8 b2 , m2 , t2 \u27e9 := (check q2 s h); (b1 \u2192 b2 \u2227 m1 \u2286 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 \u2227 tight q2\n--  | sepimp q1 q2 => False;\n\ntheorem partiality (q : Asrt) (s : Store) (h_tilde : Heap) : (check q s h_tilde).2 \u2286 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 \u27e8 a, b \u27e9;\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[\u2190 is_not_some] at temp1;\n        simp[dne] at temp1;\n        rw[is_some] at temp1;\n        have \u27e8 witness, proof \u27e9 := 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[\u2190 is_not_some] at temp2;\n        simp[dne] at temp2;\n        rw[is_some] at temp2;\n        have \u27e8 witness, proof \u27e9 := 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[\u2190 is_not_some] at temp2;\n        simp[dne] at temp2;\n        rw[is_some] at temp2;\n        have \u27e8 witness, proof \u27e9 := 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[\u2190 is_not_some] at temp1;\n        simp[dne] at temp1;\n        rw[is_some] at temp1;\n        have \u27e8 witness, proof \u27e9 := 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[\u2190 is_not_some] at temp2;\n        simp[dne] at temp2;\n        rw[is_some] at temp2;\n        have \u27e8 witness, proof \u27e9 := temp2;\n        simp[proof];\n      }\n      case right => {\n        intro temp1 temp2;\n        simp[temp1, temp2];\n        rw[\u2190 is_not_some] at temp2;\n        simp[dne] at temp2;\n        rw[is_some] at temp2;\n        have \u27e8 witness, proof \u27e9 := temp2;\n        simp[proof];\n      }\n    }\n  }-/\n}\n\ntheorem uniqueness :\n  (check q s h_tilde).1 \u2227 tight q \u2192 \u2200 h h' , (asrt q s h \u2227 asrt q s h' \u2192 h = h') := by {\n    match q with\n  | literal lit => simp[asrt, tight];\n  | emp => {\n    intro \u27e8 a, b \u27e9 h h';\n    simp[asrt];\n    simp[is_not_some'];\n    intro \u27e8 hx , h'x \u27e9;\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 \u27e8 \u27e8 a , b \u27e9 , c , d \u27e9;\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 \u27e8 \u27e8 a1 , a2, a3  \u27e9, b, c \u27e9 h h' \u27e8 \u27e8 h1 , h2 , q1h1 , q2h2 , h1_disj_h2 , h_h1_h2 \u27e9 , \u27e8 h1' , h2' , q1h1' , q2h2' , h1_disj_h2' , h_h1_h2' \u27e9 \u27e9;\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 \u2227 h \u2286 h_tilde \u2192 (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 \u27e8 points, subset \u27e9;\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 \u27e8 \u27e8 a1 , a2 , a3 \u27e9 , b \u27e9;\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) \u2192 (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 \u27e8 a, b \u27e9; exact a;\n  | sep q1 q2 => {\n    simp[asrt, check];\n    intro \u27e8 h1, h2 , q1h1 , q2h2 , disjoint_h1_h2 , h_h1_h2 \u27e9;\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[\u2190 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[\u2190 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 \u27e8 b, m \u27e9 := (check q s h_tilde); b \u2192 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 \u27e8 b1 , b2 , disjoint_m1_m2 \u27e9 ;\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 \u27e8 b , m \u27e9 := (check q s h_tilde); (b \u2227 \u00ac tight q) \u2192 \u2200 h : Heap , m \u2286 h \u2227 h \u2286 h_tilde \u2192 asrt q s h := by {\n  match q with\n  | literal lit => simp[asrt, check]; intro \u27e8 _ , _ \u27e9 _ _; assumption;\n  | emp => simp[asrt, check, tight];\n  | singleton v1 v2 => simp[tight];\n  | sep q1 q2 => {\n    simp[check, tight];\n    intro \u27e8 \u27e8 b1 , b2 , disjoint_m1_m2 \u27e9 , not_both_tight \u27e9 h;\n    rw [de_morgan] at not_both_tight;\n    intro \u27e8 partial_m_h , partial_h_h_tilde \u27e9;\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 \u27e8 b , m \u27e9 := (check q s h_tilde); asrt q s h_tilde \u2194 b \u2227 (tight q \u2192 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 \u27e8 b, tight_implies_h_tilde_equal_m \u27e9;\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[\u2190 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 \u00d7 R` sending `v + r\u2022e0` to `Q v - r^2`. -/\n@[reducible]\ndef q' : QuadraticForm R (M \u00d7 R) :=\n  Q.Prod <| -@QuadraticForm.sq R _\n#align clifford_algebra.equiv_even.Q' CliffordAlgebra.EquivEven.q'\n\ntheorem q'_apply (m : M \u00d7 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  \u03b9 (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 \u2192\u2097[R] CliffordAlgebra (q' Q) :=\n  \u03b9 (q' Q) \u2218\u2097 LinearMap.inl _ _ _\n#align clifford_algebra.equiv_even.v CliffordAlgebra.EquivEven.v\n\ntheorem \u03b9_eq_v_add_smul_e0 (m : M) (r : R) : \u03b9 (q' Q) (m, r) = v Q m + r \u2022 e0 Q := by\n  rw [e0, v, LinearMap.comp_apply, LinearMap.inl_apply, \u2190 LinearMap.map_smul, Prod.smul_mk,\n    smul_zero, smul_eq_mul, mul_one, \u2190 LinearMap.map_add, Prod.mk_add_mk, zero_add, add_zero]\n#align clifford_algebra.equiv_even.\u03b9_eq_v_add_smul_e0 CliffordAlgebra.EquivEven.\u03b9_eq_v_add_smul_e0\n\ntheorem e0_mul_e0 : e0 Q * e0 Q = -1 :=\n  (\u03b9_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  (\u03b9_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 ((\u03b9_mul_\u03b9_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 [\u2190 neg_v_mul_e0, \u2190 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_\u03b9 _\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_\u03b9 _\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_\u03b9 _\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_\u03b9 _\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 \u2192\u2090[R] CliffordAlgebra.even (q' Q) :=\n  by\n  refine' CliffordAlgebra.lift Q \u27e8_, fun m => _\u27e9\n  \u00b7 refine' LinearMap.codRestrict _ _ fun m => Submodule.mem_sup\u1d62_of_mem \u27e82, rfl\u27e9 _\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  \u00b7 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 [\u2190 mul_assoc, e0_mul_v_mul_e0, v_sq_scalar]\n#align clifford_algebra.to_even CliffordAlgebra.toEven\n\n@[simp]\ntheorem toEven_\u03b9 (m : M) : (toEven Q (\u03b9 Q m) : CliffordAlgebra (q' Q)) = e0 Q * v Q m :=\n  by\n  rw [to_even, CliffordAlgebra.lift_\u03b9_apply, LinearMap.codRestrict_apply]\n  rfl\n#align clifford_algebra.to_even_\u03b9 CliffordAlgebra.toEven_\u03b9\n\n/-- The embedding from the even subalgebra with an extra dimension into the original algebra. -/\ndef ofEven : CliffordAlgebra.even (q' Q) \u2192\u2090[R] CliffordAlgebra Q :=\n  by\n  /-\n    Recall that we need:\n     * `f \u27e80,1\u27e9 \u27e8x,0\u27e9 = \u03b9 x`\n     * `f \u27e8x,0\u27e9 \u27e80,1\u27e9 = -\u03b9 x`\n     * `f \u27e8x,0\u27e9 \u27e8y,0\u27e9 = \u03b9 x * \u03b9 y`\n     * `f \u27e80,1\u27e9 \u27e80,1\u27e9 = -1`\n    -/\n  let f : M \u00d7 R \u2192\u2097[R] M \u00d7 R \u2192\u2097[R] CliffordAlgebra Q :=\n    ((LinearMap.Algebra.lmul R (CliffordAlgebra Q)).toLinearMap.comp <|\n          (\u03b9 Q).comp (LinearMap.fst _ _ _) +\n            (Algebra.linearMap R _).comp (LinearMap.snd _ _ _)).compl\u2082\n      ((\u03b9 Q).comp (LinearMap.fst _ _ _) - (Algebra.linearMap R _).comp (LinearMap.snd _ _ _))\n  have f_apply : \u2200 x y, f x y = (\u03b9 Q x.1 + algebraMap R _ x.2) * (\u03b9 Q y.1 - algebraMap R _ y.2) :=\n    fun x y => rfl\n  have hc : \u2200 (r : R) (x : CliffordAlgebra Q), Commute (algebraMap _ _ r) x := Algebra.commutes\n  have hm :\n    \u2200 m : M \u00d7 R,\n      \u03b9 Q m.1 * \u03b9 Q m.1 - algebraMap R _ m.2 * algebraMap R _ m.2 = algebraMap R _ (Q' Q m) :=\n    by\n    intro m\n    rw [\u03b9_sq_scalar, \u2190 RingHom.map_mul, \u2190 RingHom.map_sub, sub_eq_add_neg, Q'_apply, sub_eq_add_neg]\n  refine' even.lift (Q' Q) \u27e8f, _, _\u27e9 <;> simp_rw [f_apply]\n  \u00b7 intro m\n    rw [\u2190 (hc _ _).symm.mul_self_sub_mul_self_eq, hm]\n  \u00b7 intro m\u2081 m\u2082 m\u2083\n    rw [\u2190 mul_smul_comm, \u2190 mul_assoc, mul_assoc (_ + _), \u2190 (hc _ _).symm.mul_self_sub_mul_self_eq',\n      Algebra.smul_def, \u2190 mul_assoc, hm]\n#align clifford_algebra.of_even CliffordAlgebra.ofEven\n\ntheorem ofEven_\u03b9 (x y : M \u00d7 R) :\n    ofEven Q ((even.\u03b9 _).bilin x y) =\n      (\u03b9 Q x.1 + algebraMap R _ x.2) * (\u03b9 Q y.1 - algebraMap R _ y.2) :=\n  even.lift_\u03b9 _ _ _ _\n#align clifford_algebra.of_even_\u03b9 CliffordAlgebra.ofEven_\u03b9\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\u2081 =>\n        LinearMap.ext fun m\u2082 =>\n          Subtype.ext <|\n            let \u27e8m\u2081, r\u2081\u27e9 := m\u2081\n            let \u27e8m\u2082, r\u2082\u27e9 := m\u2082\n            calc\n              \u2191(toEven Q (ofEven Q ((even.\u03b9 (q' Q)).bilin (m\u2081, r\u2081) (m\u2082, r\u2082)))) =\n                  (e0 Q * v Q m\u2081 + algebraMap R _ r\u2081) * (e0 Q * v Q m\u2082 - algebraMap R _ r\u2082) :=\n                by\n                rw [of_even_\u03b9, 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_\u03b9, to_even_\u03b9, Subalgebra.coe_algebraMap, Subalgebra.coe_algebraMap]\n              _ =\n                  e0 Q * v Q m\u2081 * (e0 Q * v Q m\u2082) + r\u2081 \u2022 e0 Q * v Q m\u2082 - r\u2082 \u2022 e0 Q * v Q m\u2081 -\n                    algebraMap R _ (r\u2081 * r\u2082) :=\n                by\n                rw [mul_sub, add_mul, add_mul, \u2190 Algebra.commutes, \u2190 Algebra.smul_def, \u2190 map_mul, \u2190\n                  Algebra.smul_def, sub_add_eq_sub_sub, smul_mul_assoc, smul_mul_assoc]\n              _ =\n                  v Q m\u2081 * v Q m\u2082 + r\u2081 \u2022 e0 Q * v Q m\u2082 + v Q m\u2081 * r\u2082 \u2022 e0 Q +\n                    r\u2081 \u2022 e0 Q * r\u2082 \u2022 e0 Q :=\n                by\n                have h1 : e0 Q * v Q m\u2081 * (e0 Q * v Q m\u2082) = v Q m\u2081 * v Q m\u2082 := by\n                  rw [\u2190 mul_assoc, e0_mul_v_mul_e0]\n                have h2 : -(r\u2082 \u2022 e0 Q * v Q m\u2081) = v Q m\u2081 * r\u2082 \u2022 e0 Q := by\n                  rw [mul_smul_comm, smul_mul_assoc, \u2190 smul_neg, neg_e0_mul_v]\n                have h3 : -algebraMap R _ (r\u2081 * r\u2082) = r\u2081 \u2022 e0 Q * r\u2082 \u2022 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              _ = \u03b9 _ (m\u2081, r\u2081) * \u03b9 _ (m\u2082, r\u2082) := by\n                rw [\u03b9_eq_v_add_smul_e0, \u03b9_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 (\u03b9 Q m)) = ofEven Q \u27e8_, (toEven Q (\u03b9 Q m)).Prop\u27e9 := by\n          rw [Subtype.coe_eta]\n        _ = (\u03b9 Q 0 + algebraMap R _ 1) * (\u03b9 Q m - algebraMap R _ 0) :=\n          by\n          simp_rw [to_even_\u03b9]\n          exact of_even_\u03b9 Q _ _\n        _ = \u03b9 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 \u00d7 R`), with a quadratic form evaluating to `-1` on that new\nbasis vector. -/\n@[simps]\ndef equivEven : CliffordAlgebra Q \u2243\u2090[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    \u2191(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_\u03b9, Subalgebra.coe_neg, to_even_\u03b9, reverse.map_mul, reverse_v, reverse_e0,\n      reverse_\u03b9, 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 \u2192\u2090[R] CliffordAlgebra.even Q' :=\n  even.lift Q\n    { bilin := -(even.\u03b9 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\u2081 m\u2082 m\u2083 => 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_\u03b9 (Q' : QuadraticForm R M) (h : Q' = -Q) (m\u2081 m\u2082 : M) :\n    evenToNeg Q Q' h ((even.\u03b9 Q).bilin m\u2081 m\u2082) = -(even.\u03b9 Q').bilin m\u2081 m\u2082 :=\n  even.lift_\u03b9 _ _ m\u2081 m\u2082\n#align clifford_algebra.even_to_neg_\u03b9 CliffordAlgebra.evenToNeg_\u03b9\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\u2081 m\u2082) : 4\n  dsimp only [even_hom.compr\u2082_bilin, LinearMap.compr\u2082_apply, AlgHom.toLinearMap_apply,\n    AlgHom.comp_apply, AlgHom.id_apply]\n  rw [even_to_neg_\u03b9, map_neg, even_to_neg_\u03b9, 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, `\ud835\udc9e\u2113\u207a(p,q,r)` and `\ud835\udc9e\u2113\u207a(q,p,r)` are isomorphic. -/\n@[simps]\ndef evenEquivEvenNeg : CliffordAlgebra.even Q \u2243\u2090[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 \u2194 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 \u2194 q) \u2194 (p \u2227 q) \u2228 (\u00ac p \u2227 \u00ac q) := by\nconstructor <;> intros h\n. simp [h, and_self, Classical.em]\n. cases h <;> auto\n\n@[simp]\ntheorem not_exists (p : \u03b1 \u2192 Prop) :\n  \u00ac (\u2203 x, p x) \u2194 \u2200 x, \u00ac 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 : \u03b1 \u2192 Prop) :\n  \u00ac (\u2200 x, p x) \u2194 \u2203 x, \u00ac p x := by\nconstructor <;> intros h\nnext =>\n  apply byContradiction; intros h\u2080\n  apply h; clear h; intro x\n  apply byContradiction; intros h\u2081\n  apply h\u2080; clear h\u2080\n  exists x\nnext =>\n  intros h\u2080\n  cases h with | intro x h =>\n  apply h; clear h\n  apply h\u2080\n\n@[simp mid]\ntheorem not_implies {p q : Prop} :\n  \u00ac (p \u2192 q) \u2194 p \u2227 \u00ac q := by\nrw [not_forall]\nconstructor <;> intros h <;> cases h\n<;> constructor <;> assumption\n\n@[simp]\ntheorem not_not (p : Prop) : \u00ac \u00ac p \u2194 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  (\u00ac p \u2194 \u00ac q) \u2194 (p \u2194 q) := by\nconstructor <;> intros h\nfocus\n  rw [\u2190 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) : \u00ac (p \u2228 q) \u2194 \u00ac p \u2227 \u00ac q := by\nconstructor\nfocus\n  intros h\u2080; constructor <;>\n    intros h\u2081 <;>\n    apply h\u2080\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) : \u00ac (p \u2227 q) \u2194 \u00ac p \u2228 \u00ac q := by\nrw [\u2190 not_iff_not, not_or]\nrepeat rw [not_not]\napply Iff.refl\n\ntheorem not_and_iff_implies (p q : Prop) : \u00ac (p \u2227 q) \u2194 p \u2192 \u00ac 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  (\u00ac p \u2192 p) \u2192 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 \u2245 Y` : same as `iso X Y`;\n- `\u03b1 \u226a\u226b \u03b2` : 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 \u27f6 Y)\n(inv : Y \u27f6 X)\n(hom_inv_id' : hom \u226b inv = \ud835\udfd9 X . obviously)\n(inv_hom_id' : inv \u226b hom = \ud835\udfd9 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 ` \u2245 `: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 \u2983\u03b1 \u03b2 : X \u2245 Y\u2984 (w : \u03b1.hom = \u03b2.hom) : \u03b1 = \u03b2 :=\nsuffices \u03b1.inv = \u03b2.inv, by cases \u03b1; cases \u03b2; cc,\ncalc \u03b1.inv\n    = \u03b1.inv \u226b (\u03b2.hom \u226b \u03b2.inv) : by rw [iso.hom_inv_id, category.comp_id]\n... = (\u03b1.inv \u226b \u03b1.hom) \u226b \u03b2.inv : by rw [category.assoc, \u2190w]\n... = \u03b2.inv                   : by rw [iso.inv_hom_id, category.id_comp]\n\n/-- Inverse isomorphism. -/\n@[symm] def symm (I : X \u2245 Y) : Y \u2245 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 (\u03b1 : X \u2245 Y) : \u03b1.symm.hom = \u03b1.inv := rfl\n@[simp] lemma symm_inv (\u03b1 : X \u2245 Y) : \u03b1.symm.inv = \u03b1.hom := rfl\n\n@[simp] lemma symm_mk {X Y : C} (hom : X \u27f6 Y) (inv : Y \u27f6 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} (\u03b1 : X \u2245 Y) : \u03b1.symm.symm = \u03b1 :=\nby cases \u03b1; refl\n\n@[simp] lemma symm_eq_iff {X Y : C} {\u03b1 \u03b2 : X \u2245 Y} : \u03b1.symm = \u03b2.symm \u2194 \u03b1 = \u03b2 :=\n\u27e8\u03bb h, symm_symm_eq \u03b1 \u25b8 symm_symm_eq \u03b2 \u25b8 congr_arg symm h, congr_arg symm\u27e9\n\n/-- Identity isomorphism. -/\n@[refl, simps] def refl (X : C) : X \u2245 X :=\n{ hom := \ud835\udfd9 X,\n  inv := \ud835\udfd9 X }\n\ninstance : inhabited (X \u2245 X) := \u27e8iso.refl X\u27e9\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 (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) : X \u2245 Z :=\n{ hom := \u03b1.hom \u226b \u03b2.hom,\n  inv := \u03b2.inv \u226b \u03b1.inv }\n\ninfixr ` \u226a\u226b `:80 := iso.trans -- type as `\\ll \\gg`.\n\n@[simp] lemma trans_mk {X Y Z : C}\n  (hom : X \u27f6 Y) (inv : Y \u27f6 X) (hom_inv_id) (inv_hom_id)\n  (hom' : Y \u27f6 Z) (inv' : Z \u27f6 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 \u226b hom', inv := inv' \u226b inv, hom_inv_id' := hom_inv_id'',\n    inv_hom_id' := inv_hom_id''} :=\nrfl\n\n@[simp] lemma trans_symm (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) : (\u03b1 \u226a\u226b \u03b2).symm = \u03b2.symm \u226a\u226b \u03b1.symm := rfl\n@[simp] lemma trans_assoc {Z' : C} (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) (\u03b3 : Z \u2245 Z') :\n  (\u03b1 \u226a\u226b \u03b2) \u226a\u226b \u03b3 = \u03b1 \u226a\u226b \u03b2 \u226a\u226b \u03b3 :=\nby ext; simp only [trans_hom, category.assoc]\n\n@[simp] lemma refl_trans (\u03b1 : X \u2245 Y) : (iso.refl X) \u226a\u226b \u03b1 = \u03b1 := by ext; apply category.id_comp\n@[simp] lemma trans_refl (\u03b1 : X \u2245 Y) : \u03b1 \u226a\u226b (iso.refl Y) = \u03b1 := by ext; apply category.comp_id\n\n@[simp] lemma symm_self_id (\u03b1 : X \u2245 Y) : \u03b1.symm \u226a\u226b \u03b1 = iso.refl Y := ext \u03b1.inv_hom_id\n@[simp] lemma self_symm_id (\u03b1 : X \u2245 Y) : \u03b1 \u226a\u226b \u03b1.symm = iso.refl X := ext \u03b1.hom_inv_id\n\n@[simp] lemma symm_self_id_assoc (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) : \u03b1.symm \u226a\u226b \u03b1 \u226a\u226b \u03b2 = \u03b2 :=\nby rw [\u2190 trans_assoc, symm_self_id, refl_trans]\n\n@[simp] lemma self_symm_id_assoc (\u03b1 : X \u2245 Y) (\u03b2 : X \u2245 Z) : \u03b1 \u226a\u226b \u03b1.symm \u226a\u226b \u03b2 = \u03b2 :=\nby rw [\u2190 trans_assoc, self_symm_id, refl_trans]\n\nlemma inv_comp_eq (\u03b1 : X \u2245 Y) {f : X \u27f6 Z} {g : Y \u27f6 Z} : \u03b1.inv \u226b f = g \u2194 f = \u03b1.hom \u226b g :=\n\u27e8\u03bb H, by simp [H.symm], \u03bb H, by simp [H]\u27e9\n\nlemma eq_inv_comp (\u03b1 : X \u2245 Y) {f : X \u27f6 Z} {g : Y \u27f6 Z} : g = \u03b1.inv \u226b f \u2194 \u03b1.hom \u226b g = f :=\n(inv_comp_eq \u03b1.symm).symm\n\nlemma comp_inv_eq (\u03b1 : X \u2245 Y) {f : Z \u27f6 Y} {g : Z \u27f6 X} : f \u226b \u03b1.inv = g \u2194 f = g \u226b \u03b1.hom :=\n\u27e8\u03bb H, by simp [H.symm], \u03bb H, by simp [H]\u27e9\n\nlemma eq_comp_inv (\u03b1 : X \u2245 Y) {f : Z \u27f6 Y} {g : Z \u27f6 X} : g = f \u226b \u03b1.inv \u2194 g \u226b \u03b1.hom = f :=\n(comp_inv_eq \u03b1.symm).symm\n\nlemma inv_eq_inv (f g : X \u2245 Y) : f.inv = g.inv \u2194 f.hom = g.hom :=\nhave \u2200{X Y : C} (f g : X \u2245 Y), f.hom = g.hom \u2192 f.inv = g.inv, from \u03bb X Y f g h, by rw [ext h],\n\u27e8this f.symm g.symm, this f g\u27e9\n\nlemma hom_comp_eq_id (\u03b1 : X \u2245 Y) {f : Y \u27f6 X} : \u03b1.hom \u226b f = \ud835\udfd9 X \u2194 f = \u03b1.inv :=\nby rw [\u2190eq_inv_comp, comp_id]\n\nlemma comp_hom_eq_id (\u03b1 : X \u2245 Y) {f : Y \u27f6 X} : f \u226b \u03b1.hom = \ud835\udfd9 Y \u2194 f = \u03b1.inv :=\nby rw [\u2190eq_comp_inv, id_comp]\n\nlemma hom_eq_inv (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 X) : \u03b1.hom = \u03b2.inv \u2194 \u03b2.hom = \u03b1.inv :=\nby { erw [inv_eq_inv \u03b1.symm \u03b2, eq_comm], refl }\n\nend iso\n\n/-- `is_iso` typeclass expressing that a morphism is invertible. -/\nclass is_iso (f : X \u27f6 Y) : Prop :=\n(out : \u2203 inv : Y \u27f6 X, f \u226b inv = \ud835\udfd9 X \u2227 inv \u226b f = \ud835\udfd9 Y)\n\n/--\nThe inverse of a morphism `f` when we have `[is_iso f]`.\n-/\nnoncomputable def inv (f : X \u27f6 Y) [I : is_iso f] := classical.some I.1\n\nnamespace is_iso\n\n@[simp, reassoc] lemma hom_inv_id (f : X \u27f6 Y) [I : is_iso f] : f \u226b inv f = \ud835\udfd9 X :=\n(classical.some_spec I.1).left\n@[simp, reassoc] lemma inv_hom_id (f : X \u27f6 Y) [I : is_iso f] : inv f \u226b f = \ud835\udfd9 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 \u27f6 Y) [h : is_iso f] : X \u2245 Y := \u27e8f, inv f, hom_inv_id f, inv_hom_id f\u27e9\n\n@[simp] lemma as_iso_hom (f : X \u27f6 Y) [is_iso f] : (as_iso f).hom = f := rfl\n@[simp] lemma as_iso_inv (f : X \u27f6 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 \u27f6 Y) [is_iso f] : epi f  :=\n{ left_cancellation := \u03bb Z g h w,\n  -- This is an interesting test case for better rewrite automation.\n  by rw [\u2190 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 \u27f6 Y) [is_iso f] : mono f :=\n{ right_cancellation := \u03bb Z g h w,\n  by rw [\u2190 category.comp_id g, \u2190 category.comp_id h, \u2190 is_iso.hom_inv_id f, \u2190 category.assoc, w,\n    \u2190 category.assoc] }\n\n@[ext] lemma inv_eq_of_hom_inv_id {f : X \u27f6 Y} [is_iso f] {g : Y \u27f6 X}\n  (hom_inv_id : f \u226b g = \ud835\udfd9 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 \u27f6 Y} [is_iso f] {g : Y \u27f6 X}\n  (inv_hom_id : g \u226b f = \ud835\udfd9 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 \u27f6 Y} [is_iso f] {g : Y \u27f6 X}\n  (hom_inv_id : f \u226b g = \ud835\udfd9 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 \u27f6 Y} [is_iso f] {g : Y \u27f6 X}\n  (inv_hom_id : g \u226b f = \ud835\udfd9 Y) : g = inv f :=\n(inv_eq_of_inv_hom_id inv_hom_id).symm\n\n\ninstance id (X : C) : is_iso (\ud835\udfd9 X) :=\n\u27e8\u27e8\ud835\udfd9 X, by simp\u27e9\u27e9\n\ninstance of_iso (f : X \u2245 Y) : is_iso f.hom :=\n\u27e8\u27e8f.inv, by simp\u27e9\u27e9\n\ninstance of_iso_inv (f : X \u2245 Y) : is_iso f.inv :=\nis_iso.of_iso f.symm\n\nvariables {f g : X \u27f6 Y} {h : Y \u27f6 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 \u226b h) :=\nis_iso.of_iso $ (as_iso f) \u226a\u226b (as_iso h)\n\n@[simp] lemma inv_id : inv (\ud835\udfd9 X) = \ud835\udfd9 X := by { ext, simp, }\n@[simp] lemma inv_comp [is_iso f] [is_iso h] : inv (f \u226b h) = inv h \u226b 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 \u2245 Y) : inv (f.inv) = f.hom := by { ext, simp, }\n@[simp] lemma iso.inv_hom (f : X \u2245 Y) : inv (f.hom) = f.inv := by { ext, simp, }\n\n@[simp]\nlemma inv_comp_eq (\u03b1 : X \u27f6 Y) [is_iso \u03b1] {f : X \u27f6 Z} {g : Y \u27f6 Z} : inv \u03b1 \u226b f = g \u2194 f = \u03b1 \u226b g :=\n(as_iso \u03b1).inv_comp_eq\n\n@[simp]\nlemma eq_inv_comp (\u03b1 : X \u27f6 Y) [is_iso \u03b1] {f : X \u27f6 Z} {g : Y \u27f6 Z} : g = inv \u03b1 \u226b f \u2194 \u03b1 \u226b g = f :=\n(as_iso \u03b1).eq_inv_comp\n\n@[simp]\nlemma comp_inv_eq (\u03b1 : X \u27f6 Y) [is_iso \u03b1] {f : Z \u27f6 Y} {g : Z \u27f6 X} : f \u226b inv \u03b1 = g \u2194 f = g \u226b \u03b1 :=\n(as_iso \u03b1).comp_inv_eq\n\n@[simp]\nlemma eq_comp_inv (\u03b1 : X \u27f6 Y) [is_iso \u03b1] {f : Z \u27f6 Y} {g : Z \u27f6 X} : g = f \u226b inv \u03b1 \u2194 g \u226b \u03b1 = f :=\n(as_iso \u03b1).eq_comp_inv\n\nend is_iso\n\nopen is_iso\n\nlemma eq_of_inv_eq_inv {f g : X \u27f6 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 \u27f6 Y} [is_iso f] [is_iso g] : inv f = inv g \u2194 f = g :=\niso.inv_eq_inv (as_iso f) (as_iso g)\n\nlemma hom_comp_eq_id (g : X \u27f6 Y) [is_iso g] {f : Y \u27f6 X} : g \u226b f = \ud835\udfd9 X \u2194 f = inv g :=\n(as_iso g).hom_comp_eq_id\n\nlemma comp_hom_eq_id (g : X \u27f6 Y) [is_iso g] {f : Y \u27f6 X} : f \u226b g = \ud835\udfd9 Y \u2194 f = inv g :=\n(as_iso g).comp_hom_eq_id\n\nnamespace iso\n\n@[ext] lemma inv_ext {f : X \u2245 Y} {g : Y \u27f6 X}\n  (hom_inv_id : f.hom \u226b g = \ud835\udfd9 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 \u2245 Y} {g : Y \u27f6 X}\n  (hom_inv_id : f.hom \u226b g = \ud835\udfd9 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 \u27f6 Y`.\nPresumably we could write `X \u21aa Y` and `X \u21a0 Y`.\n-/\n\n@[simp] lemma cancel_iso_hom_left {X Y Z : C} (f : X \u2245 Y) (g g' : Y \u27f6 Z) :\n  f.hom \u226b g = f.hom \u226b g' \u2194 g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_iso_inv_left {X Y Z : C} (f : Y \u2245 X) (g g' : Y \u27f6 Z) :\n  f.inv \u226b g = f.inv \u226b g' \u2194 g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_iso_hom_right {X Y Z : C} (f f' : X \u27f6 Y) (g : Y \u2245 Z) :\n  f \u226b g.hom = f' \u226b g.hom \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_iso_inv_right {X Y Z : C} (f f' : X \u27f6 Y) (g : Z \u2245 Y) :\n  f \u226b g.inv = f' \u226b g.inv \u2194 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 \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y)\n  (h : Y \u2245 Z) :\n  f \u226b g \u226b h.hom = f' \u226b g' \u226b h.hom \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_iso_inv_right_assoc {W X X' Y Z : C}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y)\n  (h : Z \u2245 Y) :\n  f \u226b g \u226b h.inv = f' \u226b g' \u226b h.inv \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\nend iso\n\nnamespace functor\n\nuniverses u\u2081 v\u2081 u\u2082 v\u2082\nvariables {D : Type u\u2082}\n\nvariables [category.{v\u2082} D]\n\n/-- A functor `F : C \u2964 D` sends isomorphisms `i : X \u2245 Y` to isomorphisms `F.obj X \u2245 F.obj Y` -/\n@[simps]\ndef map_iso (F : C \u2964 D) {X Y : C} (i : X \u2245 Y) : F.obj X \u2245 F.obj Y :=\n{ hom := F.map i.hom,\n  inv := F.map i.inv,\n  hom_inv_id' := by rw [\u2190map_comp, iso.hom_inv_id, \u2190map_id],\n  inv_hom_id' := by rw [\u2190map_comp, iso.inv_hom_id, \u2190map_id] }\n\n@[simp] lemma map_iso_symm (F : C \u2964 D) {X Y : C} (i : X \u2245 Y) :\n  F.map_iso i.symm = (F.map_iso i).symm :=\nrfl\n\n@[simp] lemma map_iso_trans (F : C \u2964 D) {X Y Z : C} (i : X \u2245 Y) (j : Y \u2245 Z) :\n  F.map_iso (i \u226a\u226b j) = (F.map_iso i) \u226a\u226b (F.map_iso j) :=\nby ext; apply functor.map_comp\n\n@[simp] lemma map_iso_refl (F : C \u2964 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 \u2964 D) (f : X \u27f6 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 \u2964 D) {X Y : C} (f : X \u27f6 Y) [is_iso f] :\n  F.map f \u226b F.map (inv f) = \ud835\udfd9 (F.obj X) :=\nby simp\n\nlemma map_inv_hom (F : C \u2964 D) {X Y : C} (f : X \u27f6 Y) [is_iso f] :\n  F.map (inv f) \u226b F.map f = \ud835\udfd9 (F.obj Y) :=\nby simp\n\nend functor\n\nsection partial_order\nvariables {\u03b1 \u03b2 : Type*} [partial_order \u03b1] [partial_order \u03b2]\n\nlemma iso.to_eq {X Y : \u03b1} (f : X \u2245 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 {\u03b1 : Type u} : rbnode \u03b1 \u2192 rbnode \u03b1 \u2192 \u03b1 \u2192 rbnode \u03b1 \u2192 Prop\nwhere\n| of_red : \u2200 (l : rbnode \u03b1) (v : \u03b1) (r : rbnode \u03b1), is_node_of (red_node l v r) l v r\n| of_black : \u2200 (l : rbnode \u03b1) (v : \u03b1) (r : rbnode \u03b1), is_node_of (black_node l v r) l v r\n\ndef lift {\u03b1 : Type u} (lt : \u03b1 \u2192 \u03b1 \u2192 Prop) : Option \u03b1 \u2192 Option \u03b1 \u2192 Prop :=\n  sorry\n\ninductive is_searchable {\u03b1 : Type u} (lt : \u03b1 \u2192 \u03b1 \u2192 Prop) : rbnode \u03b1 \u2192 Option \u03b1 \u2192 Option \u03b1 \u2192 Prop\nwhere\n| leaf_s : \u2200 {lo hi : Option \u03b1}, lift lt lo hi \u2192 is_searchable lt leaf lo hi\n| red_s : \u2200 {l r : rbnode \u03b1} {v : \u03b1} {lo hi : Option \u03b1},\n  is_searchable lt l lo (some v) \u2192 is_searchable lt r (some v) hi \u2192 is_searchable lt (red_node l v r) lo hi\n| black_s : \u2200 {l r : rbnode \u03b1} {v : \u03b1} {lo hi : Option \u03b1},\n  is_searchable lt l lo (some v) \u2192 is_searchable lt r (some v) hi \u2192 is_searchable lt (black_node l v r) lo hi\n\ntheorem lo_lt_hi {\u03b1 : Type u} {t : rbnode \u03b1} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_trans \u03b1 lt] {lo : Option \u03b1} {hi : Option \u03b1} : is_searchable lt t lo hi \u2192 lift lt lo hi := sorry\n\ntheorem is_searchable_of_is_searchable_of_incomp {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] [is_strict_weak_order \u03b1 lt] {t : rbnode \u03b1} {lo : Option \u03b1} {hi : \u03b1} {hi' : \u03b1} (hc : \u00aclt hi' hi \u2227 \u00aclt 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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] [is_strict_weak_order \u03b1 lt] {t : rbnode \u03b1} {lo : \u03b1} {lo' : \u03b1} {hi : Option \u03b1} (hc : \u00aclt lo' lo \u2227 \u00aclt 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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] {t : rbnode \u03b1} [is_trans \u03b1 lt] {lo : \u03b1} {hi : Option \u03b1} {lo' : \u03b1} (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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] {t : rbnode \u03b1} {y : \u03b1} {hi : Option \u03b1} (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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] {t : rbnode \u03b1} [is_trans \u03b1 lt] {lo : Option \u03b1} {hi : \u03b1} {hi' : \u03b1} (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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] {t : rbnode \u03b1} {lo : Option \u03b1} {y : \u03b1} (hlt : is_searchable lt t lo (some y)) : is_searchable lt t lo none := sorry\n\ntheorem range {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] [is_strict_weak_order \u03b1 lt] {t : rbnode \u03b1} {x : \u03b1} {lo : Option \u03b1} {hi : Option \u03b1} : is_searchable lt t lo hi \u2192 mem lt x t \u2192 lift lt lo (some x) \u2227 lift lt (some x) hi := sorry\n\ntheorem lt_of_mem_left {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] [is_strict_weak_order \u03b1 lt] {y : \u03b1} {t : rbnode \u03b1} {l : rbnode \u03b1} {r : rbnode \u03b1} {lo : Option \u03b1} {hi : Option \u03b1} : is_searchable lt t lo hi \u2192 is_node_of t l y r \u2192 \u2200 {x : \u03b1}, mem lt x l \u2192 lt x y := sorry\n\ntheorem lt_of_mem_right {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] [is_strict_weak_order \u03b1 lt] {y : \u03b1} {t : rbnode \u03b1} {l : rbnode \u03b1} {r : rbnode \u03b1} {lo : Option \u03b1} {hi : Option \u03b1} : is_searchable lt t lo hi \u2192 is_node_of t l y r \u2192 \u2200 {z : \u03b1}, mem lt z r \u2192 lt y z := sorry\n\ntheorem lt_of_mem_left_right {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] [is_strict_weak_order \u03b1 lt] {y : \u03b1} {t : rbnode \u03b1} {l : rbnode \u03b1} {r : rbnode \u03b1} {lo : Option \u03b1} {hi : Option \u03b1} : is_searchable lt t lo hi \u2192 is_node_of t l y r \u2192 \u2200 {x z : \u03b1}, mem lt x l \u2192 mem lt z r \u2192 lt x z := sorry\n\ninductive is_red_black {\u03b1 : Type u} : rbnode \u03b1 \u2192 color \u2192 \u2115 \u2192 Prop\nwhere\n| leaf_rb : is_red_black leaf color.black 0\n| red_rb : \u2200 {v : \u03b1} {l r : rbnode \u03b1} {n : \u2115},\n  is_red_black l color.black n \u2192 is_red_black r color.black n \u2192 is_red_black (red_node l v r) color.red n\n| black_rb : \u2200 {v : \u03b1} {l r : rbnode \u03b1} {n : \u2115} {c\u2081 c\u2082 : color},\n  is_red_black l c\u2081 n \u2192 is_red_black r c\u2082 n \u2192 is_red_black (black_node l v r) color.black (Nat.succ n)\n\ntheorem depth_min {\u03b1 : Type u} {c : color} {n : \u2115} {t : rbnode \u03b1} : is_red_black t c n \u2192 depth min t \u2265 n := sorry\n\ntheorem depth_max' {\u03b1 : Type u} {c : color} {n : \u2115} {t : rbnode \u03b1} : is_red_black t c n \u2192 depth max t \u2264 upper c n := sorry\n\ntheorem depth_max {\u03b1 : Type u} {c : color} {n : \u2115} {t : rbnode \u03b1} (h : is_red_black t c n) : depth max t \u2264 bit0 1 * n + 1 :=\n  le_trans (depth_max' h) (upper_le c n)\n\ntheorem balanced {\u03b1 : Type u} {c : color} {n : \u2115} {t : rbnode \u03b1} (h : is_red_black t c n) : bit0 1 * depth min t + 1 \u2265 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 : \u03b9 \u2192 finset \u03b1` have `\u03b9` be finite.\nThe `combinatorics.hall.basic` module applies a compactness argument to this version\nto remove the `finite` constraint on `\u03b9`.\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 {\u03b9 : Type u} {\u03b1 : Type v} [decidable_eq \u03b1] {t : \u03b9 \u2192 finset \u03b1}\n\nsection fintype\nvariables [fintype \u03b9]\n\nlemma hall_cond_of_erase {x : \u03b9} (a : \u03b1)\n  (ha : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card)\n  (s' : finset {x' : \u03b9 | x' \u2260 x}) :\n  s'.card \u2264 (s'.bUnion (\u03bb x', (t x').erase a)).card :=\nbegin\n  haveI := classical.dec_eq \u03b9,\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 (\u03bb x, t x)).card,\n    { convert ha he (\u03bb h, by simpa [\u2190h] 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 \u2190erase_bUnion,\n    by_cases hb : a \u2208 s'.bUnion (\u03bb 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`\u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`\u03b9'` of cardinality \u2264 `n`, then it is true for `\u03b9` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_A {n : \u2115} (hn : fintype.card \u03b9 = n + 1)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (ih : \u2200 {\u03b9' : Type u} [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n        by exactI fintype.card \u03b9' \u2264 n \u2192\n                  (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                  \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x)\n  (ha : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  haveI : nonempty \u03b9 := fintype.card_pos_iff.mp (hn.symm \u25b8 nat.succ_pos _),\n  haveI := classical.dec_eq \u03b9,\n  /- Choose an arbitrary element `x : \u03b9` and `y : t x`. -/\n  let x := classical.arbitrary \u03b9,\n  have tx_ne : (t x).nonempty,\n  { rw \u2190finset.card_pos,\n    calc 0 < 1 : nat.one_pos\n       ... \u2264 (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 \u03b9' := {x' : \u03b9 | x' \u2260 x},\n  let t' : \u03b9' \u2192 finset \u03b1 := \u03bb x', (t x').erase y,\n  have card_\u03b9' : fintype.card \u03b9' = n :=\n    calc fintype.card \u03b9' = fintype.card \u03b9 - 1 : set.card_ne_eq _\n                     ... = n : by { rw [hn, nat.add_succ_sub_one, add_zero], },\n  rcases ih t' card_\u03b9'.le (hall_cond_of_erase y ha) with \u27e8f', hfinj, hfr\u27e9,\n  /- Extend the resulting function. -/\n  refine \u27e8\u03bb z, if h : z = x then y else f' \u27e8z, h\u27e9, _, _\u27e9,\n  { rintro z\u2081 z\u2082,\n    have key : \u2200 {x}, y \u2260 f' x,\n    { intros x h,\n      simpa [\u2190h] using hfr x, },\n    by_cases h\u2081 : z\u2081 = x; by_cases h\u2082 : z\u2082 = x; simp [h\u2081, h\u2082, hfinj.eq_iff, key, key.symm], },\n  { intro z,\n    split_ifs with hz,\n    { rwa hz },\n    { specialize hfr \u27e8z, hz\u27e9,\n      rw mem_erase at hfr,\n      exact hfr.2, }, },\nend\n\nlemma hall_cond_of_restrict {\u03b9 : Type u} {t : \u03b9 \u2192 finset \u03b1} {s : finset \u03b9}\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (s' : finset (s : set \u03b9)) :\n  s'.card \u2264 (s'.bUnion (\u03bb a', t a')).card :=\nbegin\n  classical,\n  rw \u2190 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 {\u03b9 : Type u} {t : \u03b9 \u2192 finset \u03b1} {s : finset \u03b9}\n  (hus : s.card = (s.bUnion t).card)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (s' : finset (s\u1d9c : set \u03b9)) :\n  s'.card \u2264 (s'.bUnion (\u03bb x', t x' \\ s.bUnion t)).card :=\nbegin\n  haveI := classical.dec_eq \u03b9,\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 \u222a 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 \u2190 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 | \u27e8x', hx', rfl\u27e9) rat hs,\n    { exact (hs x hx rat).elim },\n    { exact \u27e8\u27e8x', hx', rat\u27e9, hs\u27e9, } },\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`\u2203 (s : finset \u03b9), s \u2260 univ \u2192 s.card = (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`\u03b9'` of cardinality \u2264 `n`, then it is true for `\u03b9` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_B {n : \u2115} (hn : fintype.card \u03b9 = n + 1)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (ih : \u2200 {\u03b9' : Type u} [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n        by exactI fintype.card \u03b9' \u2264 n \u2192\n                  (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                  \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x)\n  (s : finset \u03b9)\n  (hs : s.nonempty)\n  (hns : s \u2260 univ)\n  (hus : s.card = (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  haveI := classical.dec_eq \u03b9,\n  /- Restrict to `s` -/\n  let t' : s \u2192 finset \u03b1 := \u03bb x', t x',\n  rw nat.add_one at hn,\n  have card_\u03b9'_le : fintype.card s \u2264 n,\n  { apply nat.le_of_lt_succ,\n    calc fintype.card s = s.card : fintype.card_coe _\n                    ... < fintype.card \u03b9 : (card_lt_iff_ne_univ _).mpr hns\n                    ... = n.succ : hn },\n  rcases ih t' card_\u03b9'_le (hall_cond_of_restrict ht) with \u27e8f', hf', hsf'\u27e9,\n  /- Restrict to `s\u1d9c` in the domain and `(s.bUnion t)\u1d9c` in the codomain. -/\n  set \u03b9'' := (s : set \u03b9)\u1d9c with \u03b9''_def,\n  let t'' : \u03b9'' \u2192 finset \u03b1 := \u03bb a'', t a'' \\ s.bUnion t,\n  have card_\u03b9''_le : fintype.card \u03b9'' \u2264 n,\n  { simp_rw [\u2190 nat.lt_succ_iff, \u2190 hn, \u03b9'', \u2190 finset.coe_compl, coe_sort_coe],\n    rwa [fintype.card_coe, card_compl_lt_iff_nonempty] },\n  rcases ih t'' card_\u03b9''_le (hall_cond_of_compl hus ht) with \u27e8f'', hf'', hsf''\u27e9,\n  /- Put them together -/\n  have f'_mem_bUnion : \u2200 {x'} (hx' : x' \u2208 s), f' \u27e8x', hx'\u27e9 \u2208 s.bUnion t,\n  { intros x' hx',\n    rw mem_bUnion,\n    exact \u27e8x', hx', hsf' _\u27e9, },\n  have f''_not_mem_bUnion : \u2200 {x''} (hx'' : \u00ac x'' \u2208 s), \u00ac f'' \u27e8x'', hx''\u27e9 \u2208 s.bUnion t,\n  { intros x'' hx'',\n    have h := hsf'' \u27e8x'', hx''\u27e9,\n    rw mem_sdiff at h,\n    exact h.2, },\n  have im_disj : \u2200 (x' x'' : \u03b9) (hx' : x' \u2208 s) (hx'' : \u00acx'' \u2208 s), f' \u27e8x', hx'\u27e9 \u2260 f'' \u27e8x'', hx''\u27e9,\n  { intros _ _ hx' hx'' h,\n    apply f''_not_mem_bUnion hx'',\n    rw \u2190h,\n    apply f'_mem_bUnion, },\n  refine \u27e8\u03bb x, if h : x \u2208 s then f' \u27e8x, h\u27e9 else f'' \u27e8x, h\u27e9, _, _\u27e9,\n  { exact hf'.dite _ hf'' im_disj },\n  { intro x,\n    split_ifs with h,\n    { exact hsf' \u27e8x, h\u27e9 },\n    { exact sdiff_subset _ _ (hsf'' \u27e8x, h\u27e9) } }\nend\n\n\nend fintype\n\nvariables [finite \u03b9]\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 : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  casesI nonempty_fintype \u03b9,\n  unfreezingI\n  { induction hn : fintype.card \u03b9 using nat.strong_induction_on with n ih generalizing \u03b9 },\n  rcases n with _|_,\n  { rw fintype.card_eq_zero_iff at hn,\n    exactI \u27e8is_empty_elim, is_empty_elim, is_empty_elim\u27e9, },\n  { have ih' : \u2200 (\u03b9' : Type u) [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n                 by exactI fintype.card \u03b9' \u2264 n \u2192\n                    (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                    \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x,\n    { introsI \u03b9' _ _ h\u03b9' ht',\n      exact ih _ (nat.lt_succ_of_le h\u03b9') ht' _ rfl },\n    by_cases h : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 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 \u27e8s, sne, snu, sle\u27e9,\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 : \u03b9 \u2192 finset \u03b1` with `\u03b9` 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 \u03b9` constraint is removed.\n-/\ntheorem finset.all_card_le_bUnion_card_iff_exists_injective'\n  {\u03b9 \u03b1 : Type*} [finite \u03b9] [decidable_eq \u03b1] (t : \u03b9 \u2192 finset \u03b1) :\n  (\u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card) \u2194\n    (\u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x) :=\nbegin\n  split,\n  { exact hall_marriage_theorem.hall_hard_inductive },\n  { rintro \u27e8f, hf\u2081, hf\u2082\u27e9 s,\n    rw \u2190card_image_of_injective s hf\u2081,\n    apply card_le_of_subset,\n    intro _,\n    rw [mem_image, mem_bUnion],\n    rintros \u27e8x, hx, rfl\u27e9,\n    exact \u27e8x, hx, hf\u2082 x\u27e9, },\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 \u2964 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) [\ud835\udca5 : small_category J] [@fin_category J \ud835\udca5] : @has_limits_of_shape J \ud835\udca5 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\u27e8\u03bb 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) }\u27e9\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 \u2964 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) [\ud835\udca5 : small_category J] [@fin_category J \ud835\udca5] : @has_colimits_of_shape J \ud835\udca5 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\u27e8\u03bb 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) }\u27e9\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 := \u03bb 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' \u2205 [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 \u27f6 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 \u2205 } }\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 \u27f6 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 \u2205 } }\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\u27e8\u03bb J _, by exactI has_finite_colimits.out _\u27e9\n\ninstance fintype_walking_pair : fintype walking_pair :=\n{ elems := {walking_pair.left, walking_pair.right},\n  complete := \u03bb 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\u1d62 }` of\n`U`, and a family of compatible functions `A \u27f6 F(U\u1d62)` for an `A : X`, there exists an unique\ngluing `A \u27f6 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 \u2964 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) {\u03b9 : Type v} (U : \u03b9 \u2192 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\u1d62 }` of `U`, and a family of compatible functions `A \u27f6 F(U\u1d62)` for an\n  `A : X`, there exists an unique gluing `A \u27f6 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\u1d62 }` of `U`, `F(U) \u27f6 \u220f F(U\u1d62)` is the equalizer of the two morphisms\n  `\u220f F(U\u1d62) \u27f6 \u220f F(U\u1d62 \u2229 U\u2c7c)`.\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\u1d62 }` of `U`, `F(U)` is the limit of the diagram consisting of arrows\n  `F(V\u2081) \u27f6 F(V\u2082)` for every pair of open sets `V\u2081 \u2287 V\u2082` that are contained in some `U\u1d62`.\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\u1d62 }` of `U`, `F(U)` is the limit of the diagram consisting of arrows\n  from `F(U\u1d62)` and `F(U\u2c7c)` to `F(U\u1d62 \u2229 U\u2c7c)` 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\u1d62 }` of `U`, and a compatible family of elements `x : F(U\u1d62)`, 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\u03bb x U S hS x hx, \u27e8eq_to_hom (subsingleton.elim _ _), by tidy, by tidy\u27e9\n\nlemma is_sheaf_iso_iff {F G : presheaf C X} (\u03b1 : F \u2245 G) : F.is_sheaf \u2194 G.is_sheaf :=\npresheaf.is_sheaf_of_iso_iff \u03b1\n\n/--\nTransfer the sheaf condition across an isomorphism of presheaves.\n-/\nlemma is_sheaf_of_iso {F G : presheaf C X} (\u03b1 : F \u2245 G) (h : F.is_sheaf) : G.is_sheaf :=\n(is_sheaf_iso_iff \u03b1).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\u27e8\u27e8functor.star _, presheaf.is_sheaf_unit _\u27e9\u27e9\n\nnamespace sheaf\n\n/--\nThe forgetful functor from sheaves to presheaves.\n-/\n@[derive [full, faithful]]\ndef forget : Top.sheaf C X \u2964 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 (\u039b : Type*) [polyhedral_lattice \u039b]\n\nlemma filtration_finite (\u03b5 : \u211d\u22650) : (filtration \u039b \u03b5).finite :=\nbegin\n  classical,\n  obtain \u27e8\u03b9, _\u03b9_inst, l, hl, hl'\u27e9 := polyhedral_lattice.polyhedral \u039b, resetI,\n  let n : \u03b9 \u2192 \u2115 := \u03bb i, \u2308(\u03b5 / \u2225l i\u2225\u208a : \u211d)\u2309.nat_abs + 1,\n  let S := finset.univ.pi (\u03bb i, finset.range (n i)),\n  let S' : finset \u039b := S.image (\u03bb x, \u2211 i, x i (finset.mem_univ _) \u2022 l i),\n  apply S'.finite_to_set.subset,\n  intros l\u2080 H,\n  obtain \u27e8c, h1, h2\u27e9 := hl.generates_nnnorm l\u2080,\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 \u27e8\u03bb i _, c i, _, h1.symm\u27e9,\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 < \u2225l i\u2225\u208a,\n  { rw [zero_lt_iff, ne.def, nnnorm_eq_zero], exact hl' i },\n  calc \u03b5\n      \u2264 (\u2308(\u03b5 / \u2225l i\u2225\u208a : \u211d)\u2309.nat_abs : \u211d\u22650) * \u2225l i\u2225\u208a : _\n  ... < \u2191(c i) * \u2225l i\u2225\u208a : _\n  ... \u2264 \u2211 (i : \u03b9), \u2191(c i) * \u2225l i\u2225\u208a : _,\n  { rw [\u2190 nnreal.div_le_iff aux.ne', \u2190 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 \u03bb _ _, zero_le', }\nend\n\nopen metric semi_normed_group\n\ninstance : discrete_topology \u039b :=\ndiscrete_topology_of_open_singleton_zero $\nbegin\n  classical,\n  have aux := filtration_finite \u039b 1,\n  let s := aux.to_finset,\n  let s\u2080 := s.erase 0,\n  by_cases hs\u2080 : s\u2080.nonempty,\n  { let \u03b5 : \u211d\u22650 := finset.min' (s\u2080.image $ nnnorm) (hs\u2080.image _),\n    obtain \u27e8a, has\u2080, ha\u27e9 : \u2203 a \u2208 s\u2080, \u2225a\u2225\u208a = \u03b5,\n    { rw \u2190 finset.mem_image, apply finset.min'_mem },\n    have H : 0 < \u2225a\u2225 := by simpa only [norm_pos_iff] using finset.ne_of_mem_erase has\u2080,\n    have h0\u03b5 : 0 < \u03b5, { simpa only [\u2190 ha] },\n    have h\u03b51 : \u03b5 \u2264 1,\n    { replace has\u2080 := finset.mem_of_mem_erase has\u2080,\n      simp only [set.finite.mem_to_finset, mem_filtration_iff] at has\u2080,\n      rwa [\u2190 ha] },\n    suffices : ({0} : set \u039b) = ball (0:\u039b) \u03b5,\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\u03b5 },\n    intro h,\n    have hx : x \u2208 s,\n    { simp only [set.finite.mem_to_finset, mem_filtration_iff],\n      exact le_of_lt (lt_of_lt_of_le h h\u03b51) },\n    by_contra hx0,\n    replace hx := finset.mem_erase_of_ne_of_mem hx0 hx,\n    have := finset.min'_le (s\u2080.image $ nnnorm),\n    refine not_lt.2 (this \u2225x\u2225\u208a _) h,\n    simp only [exists_prop, set.finite.mem_to_finset, finset.mem_image],\n    use \u27e8x, \u27e8hx, rfl\u27e9\u27e9 },\n  { suffices : ({0} : set \u039b) = ball (0:\u039b) 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\u2080,\n    refine \u27e8x, _\u27e9,\n    simp only [set.finite.mem_to_finset, finset.mem_erase, mem_filtration_iff, nnreal.coe_one],\n    exact \u27e8hs\u2080, h.le\u27e9 }\nend\n\ninstance filtration_fintype (c : \u211d\u22650) : fintype (filtration \u039b c) :=\n(filtration_finite \u039b c).fintype\n\n-- we don't need this\ninstance : profinitely_filtered_pseudo_normed_group \u039b :=\n{ compact := \u03bb c, by apply_instance, -- compact of finite\n  continuous_add' := \u03bb _ _, continuous_of_discrete_topology,\n  continuous_neg' := \u03bb _, continuous_of_discrete_topology,\n  continuous_cast_le := \u03bb _ _ _, continuous_of_discrete_topology,\n  .. (show pseudo_normed_group \u039b, 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\u00f6lzl, 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* `\u2192+`: Bundled `add_monoid` homs. Also use for `add_group` homs.\n* `\u2192*`: Bundled `monoid` homs. Also use for `group` homs.\n* `\u2192*\u2080`: Bundled `monoid_with_zero` homs. Also use for `group_with_zero` homs.\n* `\u2192\u2099*`: 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 {\u03b1 \u03b2 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 \u2192 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 \u2192 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 (\u03bb _, N) :=\n(map_zero : \u2200 (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 \u2192 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 \u2192 N)\n(map_add' : \u2200 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 (\u03bb _, N) :=\n(map_add : \u2200 (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 \u2192+ N` is the type of functions `M \u2192 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 \u2192+ 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 ` \u2192+ `: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 \u2192 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 \u2192 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 (\u03bb _, N) :=\n(map_one : \u2200 (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' := \u03bb 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 \u2194 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 \u2260 1 \u2194 x \u2260 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 \u2260 1) : x \u2260 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\u27e8\u03bb f, { to_fun := f, map_one' := map_one f }\u27e9\n\nend one\n\nsection mul\n\nvariables [has_mul M] [has_mul N]\n\n/-- `M \u2192\u2099* N` is the type of functions `M \u2192 N` that preserve multiplication. The `\u2099` 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 \u2192\u2099* 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 \u2192 N)\n(map_mul' : \u2200 x y, to_fun (x * y) = to_fun x * to_fun y)\n\ninfixr ` \u2192\u2099* `: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 (\u03bb _, N) :=\n(map_mul : \u2200 (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 \u2192\u2099* N) M N :=\n{ coe := mul_hom.to_fun,\n  coe_injective' := \u03bb 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 \u2192\u2099* N) :=\n\u27e8\u03bb f, { to_fun := f, map_mul' := map_mul f }\u27e9\n\nend mul\n\nsection mul_one\n\nvariables [mul_one_class M] [mul_one_class N]\n\n/-- `M \u2192* N` is the type of functions `M \u2192 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 \u2192+ 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 \u2192\u2099* N\n\nattribute [nolint doc_blame] monoid_hom.to_mul_hom\nattribute [nolint doc_blame] monoid_hom.to_one_hom\n\ninfixr ` \u2192* `: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 \u2192* N) M N :=\n{ coe := monoid_hom.to_fun,\n  coe_injective' := \u03bb 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 \u2192* N) :=\n\u27e8\u03bb f, { to_fun := f, map_one' := map_one f, map_mul' := map_mul f }\u27e9\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 [\u2190 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 : \u2200 a, f a\u207b\u00b9 = (f a)\u207b\u00b9) (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\u207b\u00b9 = (f a)\u207b\u00b9 :=\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\u207b\u00b9) = f a * (f b)\u207b\u00b9 :=\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  \u2200 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  \u2200 (n : \u2115), 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 : \u2115) (a : G) : f (n \u2022 a) = n \u2022 (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 : \u2200 (x : G), f (x\u207b\u00b9) = (f x)\u207b\u00b9) (a : G) :\n  \u2200 n : \u2124, f (a ^ n) = (f a) ^ n\n| (n : \u2115) := by rw [zpow_coe_nat, map_pow, zpow_coe_nat]\n| -[1+n]  := by rw [zpow_neg_succ_of_nat, hf, map_pow, \u2190 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 : \u2124) :\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 : \u2124) (g : G) :\n  f (n \u2022 g) = n \u2022 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 \u2192*\u2080 N` is the type of functions `M \u2192 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 \u2192*\u2080 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 ` \u2192*\u2080 `: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 \u2192*\u2080 N) M N :=\n{ coe := monoid_with_zero_hom.to_fun,\n  coe_injective' := \u03bb 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 \u2192*\u2080 N) :=\n\u27e8\u03bb f, { to_fun := f, map_one' := map_one f, map_zero' := map_zero f, map_mul' := map_mul f }\u27e9\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 \u2192* N) (one_hom M N) := \u27e8monoid_hom.to_one_hom\u27e9\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 \u2192* N) (M \u2192\u2099* N) := \u27e8monoid_hom.to_mul_hom\u27e9\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 \u2192*\u2080 N) (M \u2192* N) := \u27e8monoid_with_zero_hom.to_monoid_hom\u27e9\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 \u2192*\u2080 N) (zero_hom M N) := \u27e8monoid_with_zero_hom.to_zero_hom\u27e9\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 `\u2191f` 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 \u2192* 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 \u2192* N) :\n  (f : M \u2192\u2099* 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 \u2192*\u2080 N) :\n  (f : M \u2192* 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 \u2192*\u2080 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) (\u03bb _, M \u2192 N) :=\n\u27e8one_hom.to_fun\u27e9\n@[to_additive]\ninstance {mM : has_mul M} {mN : has_mul N} : has_coe_to_fun (M \u2192\u2099* N) (\u03bb _, M \u2192 N) :=\n\u27e8mul_hom.to_fun\u27e9\n@[to_additive]\ninstance {mM : mul_one_class M} {mN : mul_one_class N} : has_coe_to_fun (M \u2192* N) (\u03bb _, M \u2192 N) :=\n\u27e8monoid_hom.to_fun\u27e9\ninstance {mM : mul_zero_one_class M} {mN : mul_zero_one_class N} :\n  has_coe_to_fun (M \u2192*\u2080 N) (\u03bb _, M \u2192 N) :=\n\u27e8monoid_with_zero_hom.to_fun\u27e9\n\n-- these must come after the coe_to_fun definitions\ninitialize_simps_projections zero_hom (to_fun \u2192 apply)\ninitialize_simps_projections add_hom (to_fun \u2192 apply)\ninitialize_simps_projections add_monoid_hom (to_fun \u2192 apply)\n\ninitialize_simps_projections one_hom (to_fun \u2192 apply)\ninitialize_simps_projections mul_hom (to_fun \u2192 apply)\ninitialize_simps_projections monoid_hom (to_fun \u2192 apply)\ninitialize_simps_projections monoid_with_zero_hom (to_fun \u2192 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 \u2192\u2099* 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 \u2192* 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 \u2192*\u2080 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 \u2192 N) (h1) : (one_hom.mk f h1 : M \u2192 N) = f := rfl\n@[simp, to_additive]\nlemma mul_hom.coe_mk [has_mul M] [has_mul N]\n  (f : M \u2192 N) (hmul) : (mul_hom.mk f hmul : M \u2192 N) = f := rfl\n@[simp, to_additive]\nlemma monoid_hom.coe_mk [mul_one_class M] [mul_one_class N]\n  (f : M \u2192 N) (h1 hmul) : (monoid_hom.mk f h1 hmul : M \u2192 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 \u2192 N) (h0 h1 hmul) : (monoid_with_zero_hom.mk f h0 h1 hmul : M \u2192 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 \u2192* N) :\n  (f.to_one_hom : M \u2192 N) = f := rfl\n@[simp, to_additive]\nlemma monoid_hom.to_mul_hom_coe [mul_one_class M] [mul_one_class N] (f : M \u2192* N) :\n  (f.to_mul_hom : M \u2192 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 \u2192*\u2080 N) :\n  (f.to_zero_hom : M \u2192 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 \u2192*\u2080 N) :\n  (f.to_monoid_hom : M \u2192 N) = f := rfl\n\n@[ext, to_additive]\nlemma one_hom.ext [has_one M] [has_one N] \u2983f g : one_hom M N\u2984 (h : \u2200 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] \u2983f g : M \u2192\u2099* N\u2984 (h : \u2200 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  \u2983f g : M \u2192* N\u2984 (h : \u2200 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] \u2983f g : M \u2192*\u2080 N\u2984\n  (h : \u2200 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 \u2192\u2099* 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 \u2192* 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 \u2192*\u2080 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 \u2192\u2099* 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 \u2192* 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 \u2192*\u2080 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] \u2983f g : one_hom M N\u2984 (h : (f : M \u2192 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] \u2983f g : M \u2192\u2099* N\u2984 (h : (f : M \u2192 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  \u2983f g : M \u2192* N\u2984 (h : (f : M \u2192 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  \u2983f g : M \u2192*\u2080 N\u2984 (h : (f : M \u2192 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 \u2194 \u2200 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 \u2192\u2099* N} : f = g \u2194 \u2200 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 \u2192* N} : f = g \u2194 \u2200 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 \u2192*\u2080 N} :\n  f = g \u2194 \u2200 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 $ \u03bb _, rfl\n@[simp, to_additive]\nlemma mul_hom.mk_coe [has_mul M] [has_mul N]\n  (f : M \u2192\u2099* N) (hmul) : mul_hom.mk f hmul = f :=\nmul_hom.ext $ \u03bb _, rfl\n@[simp, to_additive]\nlemma monoid_hom.mk_coe [mul_one_class M] [mul_one_class N]\n  (f : M \u2192* N) (h1 hmul) : monoid_hom.mk f h1 hmul = f :=\nmonoid_hom.ext $ \u03bb _, rfl\n@[simp]\nlemma monoid_with_zero_hom.mk_coe [mul_zero_one_class M] [mul_zero_one_class N] (f : M \u2192*\u2080 N)\n  (h0 h1 hmul) : monoid_with_zero_hom.mk f h0 h1 hmul = f :=\nmonoid_with_zero_hom.ext $ \u03bb _, 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 \u2192 N)\n  (h : f' = f) : one_hom M N :=\n{ to_fun := f',\n  map_one' := h.symm \u25b8 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 \u2192\u2099* N) (f' : M \u2192 N)\n  (h : f' = f) : M \u2192\u2099* N :=\n{ to_fun := f',\n  map_mul' := h.symm \u25b8 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 \u2192* N)\n  (f' : M \u2192 N) (h : f' = f) : M \u2192* 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 \u2192*\u2080 N) (f' : M \u2192 N) (h : f' = f) : M \u2192* 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 \u2192* 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 \u2192*\u2080 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 \u2192*\u2080 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 \u2192\u2099* 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 \u2192* 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 \u2192*\u2080 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 \u2192* 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 \u2192+ 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 : \u2203 y, x * y = 1) :\n  \u2203 y, f x * y = 1 :=\nlet \u27e8y, hy\u27e9 := hx in \u27e8f y, map_mul_eq_one f hy\u27e9\n\n/-- Given a monoid homomorphism `f : M \u2192* 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 \u2192+ 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 : \u2203 y, y * x = 1) :\n  \u2203 y, y * f x = 1 :=\nlet \u27e8y, hy\u27e9 := hx in \u27e8f y, map_mul_eq_one f hy\u27e9\n\nend monoid_hom\n\nsection division_comm_monoid\nvariables [division_comm_monoid \u03b1]\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 : \u03b1 \u2192* \u03b1 :=\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 : \u03b1 \u2192 \u03b1) = has_inv.inv := rfl\n@[simp] lemma inv_monoid_hom_apply (a : \u03b1) : inv_monoid_hom a = a\u207b\u00b9 := 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 := \u03bb 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 \u2192\u2099* M :=\n{ to_fun := \u03bb x, x, map_mul' := \u03bb _ _, 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 \u2192* M :=\n{ to_fun := \u03bb x, x, map_one' := rfl, map_mul' := \u03bb _ _, 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 \u2192*\u2080 M :=\n{ to_fun := \u03bb x, x, map_zero' := rfl, map_one' := rfl, map_mul' := \u03bb _ _, 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 \u2218 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 \u2192\u2099* P) (hmn : M \u2192\u2099* N) : M \u2192\u2099* P :=\n{ to_fun := hnp \u2218 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 \u2192* P) (hmn : M \u2192* N) : M \u2192* P :=\n{ to_fun := hnp \u2218 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 \u2192*\u2080 P) (hmn : M \u2192*\u2080 N) : M \u2192*\u2080 P :=\n{ to_fun := hnp \u2218 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  \u21d1(g.comp f) = g \u2218 f := rfl\n@[simp, to_additive] lemma mul_hom.coe_comp [has_mul M] [has_mul N] [has_mul P]\n  (g : N \u2192\u2099* P) (f : M \u2192\u2099* N) :\n  \u21d1(g.comp f) = g \u2218 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 \u2192* P) (f : M \u2192* N) :\n  \u21d1(g.comp f) = g \u2218 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 \u2192*\u2080 P) (f : M \u2192*\u2080 N) :\n  \u21d1(g.comp f) = g \u2218 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 \u2192\u2099* P) (f : M \u2192\u2099* 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 \u2192* P) (f : M \u2192* 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 \u2192*\u2080 P) (f : M \u2192*\u2080 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 \u2192\u2099* N) (g : N \u2192\u2099* P) (h : P \u2192\u2099* 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 \u2192* N) (g : N \u2192* P) (h : P \u2192* 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 \u2192*\u2080 N) (g : N \u2192*\u2080 P) (h : P \u2192*\u2080 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\u2081 g\u2082 : one_hom N P} {f : one_hom M N} (hf : function.surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, one_hom.ext $ hf.forall.2 (one_hom.ext_iff.1 h), \u03bb h, h \u25b8 rfl\u27e9\n@[to_additive]\nlemma mul_hom.cancel_right [has_mul M] [has_mul N] [has_mul P]\n  {g\u2081 g\u2082 : N \u2192\u2099* P} {f : M \u2192\u2099* N} (hf : function.surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, mul_hom.ext $ hf.forall.2 (mul_hom.ext_iff.1 h), \u03bb h, h \u25b8 rfl\u27e9\n@[to_additive]\nlemma monoid_hom.cancel_right\n  [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  {g\u2081 g\u2082 : N \u2192* P} {f : M \u2192* N} (hf : function.surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, monoid_hom.ext $ hf.forall.2 (monoid_hom.ext_iff.1 h), \u03bb h, h \u25b8 rfl\u27e9\nlemma monoid_with_zero_hom.cancel_right [mul_zero_one_class M] [mul_zero_one_class N]\n  [mul_zero_one_class P] {g\u2081 g\u2082 : N \u2192*\u2080 P} {f : M \u2192*\u2080 N} (hf : function.surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, monoid_with_zero_hom.ext $ hf.forall.2 (monoid_with_zero_hom.ext_iff.1 h),\n \u03bb h, h \u25b8 rfl\u27e9\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\u2081 f\u2082 : one_hom M N} (hg : function.injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, one_hom.ext $ \u03bb x, hg $ by rw [\u2190 one_hom.comp_apply, h, one_hom.comp_apply],\n \u03bb h, h \u25b8 rfl\u27e9\n@[to_additive]\nlemma mul_hom.cancel_left [has_mul M] [has_mul N] [has_mul P]\n  {g : N \u2192\u2099* P} {f\u2081 f\u2082 : M \u2192\u2099* N} (hg : function.injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, mul_hom.ext $ \u03bb x, hg $ by rw [\u2190 mul_hom.comp_apply, h, mul_hom.comp_apply],\n \u03bb h, h \u25b8 rfl\u27e9\n@[to_additive]\nlemma monoid_hom.cancel_left [mul_one_class M] [mul_one_class N] [mul_one_class P]\n  {g : N \u2192* P} {f\u2081 f\u2082 : M \u2192* N} (hg : function.injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, monoid_hom.ext $ \u03bb x, hg $ by rw [\u2190 monoid_hom.comp_apply, h, monoid_hom.comp_apply],\n \u03bb h, h \u25b8 rfl\u27e9\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 \u2192*\u2080 P} {f\u2081 f\u2082 : M \u2192*\u2080 N} (hg : function.injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, monoid_with_zero_hom.ext $ \u03bb x, hg $ by rw [\n        \u2190 monoid_with_zero_hom.comp_apply, h, monoid_with_zero_hom.comp_apply],\n \u03bb h, h \u25b8 rfl\u27e9\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 \u2192* N) \u2192 one_hom M N) :=\n\u03bb 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 \u2192* N) \u2192 M \u2192\u2099* N) :=\n\u03bb 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 \u2192*\u2080 N) \u2192 M \u2192* N) :=\n\u03bb 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 \u2192*\u2080 N) \u2192 zero_hom M N) :=\n\u03bb 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 $ \u03bb x, rfl\n@[simp, to_additive] lemma mul_hom.comp_id [has_mul M] [has_mul N]\n  (f : M \u2192\u2099* N) : f.comp (mul_hom.id M) = f := mul_hom.ext $ \u03bb x, rfl\n@[simp, to_additive] lemma monoid_hom.comp_id [mul_one_class M] [mul_one_class N]\n  (f : M \u2192* N) : f.comp (monoid_hom.id M) = f := monoid_hom.ext $ \u03bb x, rfl\n@[simp] lemma monoid_with_zero_hom.comp_id [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M \u2192*\u2080 N) : f.comp (monoid_with_zero_hom.id M) = f :=\nmonoid_with_zero_hom.ext $ \u03bb 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 $ \u03bb x, rfl\n@[simp, to_additive] lemma mul_hom.id_comp [has_mul M] [has_mul N]\n  (f : M \u2192\u2099* N) : (mul_hom.id N).comp f = f := mul_hom.ext $ \u03bb x, rfl\n@[simp, to_additive] lemma monoid_hom.id_comp [mul_one_class M] [mul_one_class N]\n  (f : M \u2192* N) : (monoid_hom.id N).comp f = f := monoid_hom.ext $ \u03bb x, rfl\n@[simp] lemma monoid_with_zero_hom.id_comp [mul_zero_one_class M] [mul_zero_one_class N]\n  (f : M \u2192*\u2080 N) : (monoid_with_zero_hom.id N).comp f = f :=\nmonoid_with_zero_hom.ext $ \u03bb x, rfl\n\n@[to_additive add_monoid_hom.map_nsmul]\nprotected theorem monoid_hom.map_pow [monoid M] [monoid N] (f : M \u2192* N) (a : M) (n : \u2115) :\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 \u2192* N)\n  (hf : \u2200 x, f (x\u207b\u00b9) = (f x)\u207b\u00b9) (a : M) (n : \u2124) :\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 \u2192* M\n\nnamespace End\n\ninstance : monoid (monoid.End M) :=\n{ mul := monoid_hom.comp,\n  one := monoid_hom.id M,\n  mul_assoc := \u03bb _ _ _, monoid_hom.comp_assoc _ _ _,\n  mul_one := monoid_hom.comp_id,\n  one_mul := monoid_hom.id_comp }\n\ninstance : inhabited (monoid.End M) := \u27e81\u27e9\n\ninstance : has_coe_to_fun (monoid.End M) (\u03bb _, M \u2192 M) := \u27e8monoid_hom.to_fun\u27e9\n\nend End\n\n@[simp] lemma coe_one : ((1 : monoid.End M) : M \u2192 M) = id := rfl\n@[simp] lemma coe_mul (f g) : ((f * g : monoid.End M) : M \u2192 M) = f \u2218 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 \u2192+ 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 := \u03bb _ _ _, 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) := \u27e81\u27e9\n\ninstance : has_coe_to_fun (add_monoid.End A) (\u03bb _, A \u2192 A) := \u27e8add_monoid_hom.to_fun\u27e9\n\nend End\n\n@[simp] lemma coe_one : ((1 : add_monoid.End A) : A \u2192 A) = id := rfl\n@[simp] lemma coe_mul (f g) : ((f * g : add_monoid.End A) : A \u2192 A) = f \u2218 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) := \u27e8\u27e8\u03bb _, 1, rfl\u27e9\u27e9\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 \u2192\u2099* N) :=\n\u27e8\u27e8\u03bb _, 1, \u03bb _ _, (one_mul 1).symm\u27e9\u27e9\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 \u2192* N) :=\n\u27e8\u27e8\u03bb _, 1, rfl, \u03bb _ _, (one_mul 1).symm\u27e9\u27e9\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 \u2192* 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) := \u27e81\u27e9\n@[to_additive]\ninstance [has_mul M] [mul_one_class N] : inhabited (M \u2192\u2099* N) := \u27e81\u27e9\n@[to_additive]\ninstance [mul_one_class M] [mul_one_class N] : inhabited (M \u2192* N) := \u27e81\u27e9\n-- unlike the other homs, `monoid_with_zero_hom` does not have a `1` or `0`\ninstance [mul_zero_one_class M] : inhabited (M \u2192*\u2080 M) := \u27e8monoid_with_zero_hom.id M\u27e9\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 \u2192\u2099* N) :=\n\u27e8\u03bb f g,\n  { to_fun := \u03bb 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, \u2190mul_assoc, \u2190mul_assoc, mul_right_comm (f x)], end }\u27e9\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 \u2192\u2099* 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\u2081 g\u2082 : N \u2192\u2099* P) (f : M \u2192\u2099* N) :\n  (g\u2081 * g\u2082).comp f = g\u2081.comp f * g\u2082.comp f := rfl\n@[to_additive] lemma comp_mul [has_mul M] [comm_semigroup N] [comm_semigroup P]\n  (g : N \u2192\u2099* P) (f\u2081 f\u2082 : M \u2192\u2099* N) :\n  g.comp (f\u2081 * f\u2082) = g.comp f\u2081 * g.comp f\u2082 :=\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 \u2192* N) :=\n\u27e8\u03bb f g,\n  { to_fun := \u03bb 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, \u2190mul_assoc, \u2190mul_assoc, mul_right_comm (f x)], end }\u27e9\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 \u2192* 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 \u2192* N) : (1 : N \u2192* 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 \u2192* P) : f.comp (1 : M \u2192* 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\u2081 g\u2082 : N \u2192* P) (f : M \u2192* N) :\n  (g\u2081 * g\u2082).comp f = g\u2081.comp f * g\u2082.comp f := rfl\n@[to_additive] lemma comp_mul [mul_one_class M] [comm_monoid N] [comm_monoid P]\n  (g : N \u2192* P) (f\u2081 f\u2082 : M \u2192* N) :\n  g.comp (f\u2081 * f\u2082) = g.comp f\u2081 * g.comp f\u2082 :=\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\u207b\u00b9`. -/\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\u207b\u00b9 = g x\u207b\u00b9 :=\nleft_inv_eq_right_inv (map_mul_eq_one f $ inv_mul_self x) $\n  h.symm \u25b8 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 \u03b1] [division_monoid \u03b2] (f : \u03b1 \u2192* \u03b2) (a : \u03b1) : f a\u207b\u00b9 = (f a)\u207b\u00b9 :=\nmap_inv f _\n\n/-- Group homomorphisms preserve integer power. -/\n@[to_additive \"Additive group homomorphisms preserve integer scaling.\"]\nprotected theorem map_zpow [group \u03b1] [division_monoid \u03b2] (f : \u03b1 \u2192* \u03b2) (g : \u03b1) (n : \u2124) :\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 \u03b1] [division_monoid \u03b2] (f : \u03b1 \u2192* \u03b2) (g h : \u03b1) :\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 \u03b1] [division_monoid \u03b2] (f : \u03b1 \u2192* \u03b2) (g h : \u03b1) :\n  f (g * h\u207b\u00b9) = (f g) * (f h)\u207b\u00b9 :=\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 \u2194 (\u2200 a, f a = 1 \u2192 a = 1) :=\n\u27e8\u03bb h x, (map_eq_one_iff f h).mp,\n \u03bb h x y hxy, mul_inv_eq_one.1 $ h _ $ by rw [map_mul, hxy, \u2190 map_mul, mul_inv_self, map_one]\u27e9\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 \u2194 (\u2200 a, f a = 1 \u2194 a = 1) :=\n(injective_iff_map_eq_one f).trans $ forall_congr $ \u03bb a, \u27e8\u03bb h, \u27e8h, \u03bb H, H.symm \u25b8 map_one f\u27e9, iff.mp\u27e9\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 \u2192 G) (map_mul : \u2200 a b : M, f (a * b) = f a * f b) : M \u2192* G :=\n{ to_fun := f,\n  map_mul' := map_mul,\n  map_one' := mul_left_eq_self.1 $ by rw [\u2190map_mul, mul_one] }\n\nomit mM\n\n/-- Makes a group homomorphism from a proof that the map preserves right division `\u03bb x y, x * y\u207b\u00b9`.\nSee also `monoid_hom.of_map_div` for a version using `\u03bb x y, x / y`.\n-/\n@[to_additive \"Makes an additive group homomorphism from a proof that the map preserves\nthe operation `\u03bb a b, a + -b`. See also `add_monoid_hom.of_map_sub` for a version using\n`\u03bb a b, a - b`.\"]\ndef of_map_mul_inv {H : Type*} [group H] (f : G \u2192 H)\n  (map_div : \u2200 a b : G, f (a * b\u207b\u00b9) = f a * (f b)\u207b\u00b9) :\n  G \u2192* H :=\nmk' f $ \u03bb x y,\ncalc f (x * y) = f x * (f $ 1 * 1\u207b\u00b9 * y\u207b\u00b9)\u207b\u00b9 : by simp only [one_mul, inv_one, \u2190 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 \u2192 H)\n  (map_div : \u2200 a b : G, f (a * b\u207b\u00b9) = f a * (f b)\u207b\u00b9) :\n  \u21d1(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 \u2192 H) (hf : \u2200 x y, f (x / y) = f x / f y) : G \u2192* 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 \u2192 H) (hf : \u2200 x y, f (x / y) = f x / f y) :\n  \u21d1(of_map_div f hf) = f :=\nrfl\n\n/-- If `f` is a monoid homomorphism to a commutative group, then `f\u207b\u00b9` is the homomorphism sending\n`x` to `(f x)\u207b\u00b9`. -/\n@[to_additive]\ninstance {M G} [mul_one_class M] [comm_group G] : has_inv (M \u2192* G) :=\n\u27e8\u03bb f, mk' (\u03bb g, (f g)\u207b\u00b9) $ \u03bb a b, by rw [\u2190mul_inv, f.map_mul]\u27e9\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 \u2192* G) (x : M) :\n  f\u207b\u00b9 x = (f x)\u207b\u00b9 := 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} (\u03c6 : N \u2192* A) (\u03c8 : M \u2192* N) : \u03c6\u207b\u00b9.comp \u03c8 = (\u03c6.comp \u03c8)\u207b\u00b9 :=\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} (\u03c6 : A \u2192* B) (\u03c8 : M \u2192* A) : \u03c6.comp \u03c8\u207b\u00b9 = (\u03c6.comp \u03c8)\u207b\u00b9 :=\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 \u2192* G) :=\n\u27e8\u03bb f g, mk' (\u03bb x, f x / g x) $ \u03bb a b,\n  by simp [div_eq_mul_inv, mul_assoc, mul_left_comm, mul_comm]\u27e9\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 \u2192* 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 \u2192*\u2080 N) :=\n\u27e8\u03bb f g,\n  { to_fun := \u03bb a, f a * g a,\n    map_zero' := by rw [map_zero, zero_mul],\n    ..(f * g : M \u2192* N) }\u27e9\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 (\u03b1 : Type u)\n\nnamespace mul_opposite\n\n/-!\n### Additive structures on `\u03b1\u1d50\u1d52\u1d56`\n-/\n\n@[to_additive] instance [has_nat_cast \u03b1] : has_nat_cast \u03b1\u1d50\u1d52\u1d56 := \u27e8\u03bb n, op n\u27e9\n@[to_additive] instance [has_int_cast \u03b1] : has_int_cast \u03b1\u1d50\u1d52\u1d56 := \u27e8\u03bb n, op n\u27e9\n\ninstance [add_semigroup \u03b1] : add_semigroup (\u03b1\u1d50\u1d52\u1d56) :=\nunop_injective.add_semigroup _ (\u03bb x y, rfl)\n\ninstance [add_left_cancel_semigroup \u03b1] : add_left_cancel_semigroup \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_left_cancel_semigroup _ (\u03bb x y, rfl)\n\ninstance [add_right_cancel_semigroup \u03b1] : add_right_cancel_semigroup \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_right_cancel_semigroup _ (\u03bb x y, rfl)\n\ninstance [add_comm_semigroup \u03b1] : add_comm_semigroup \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_comm_semigroup _ (\u03bb x y, rfl)\n\ninstance [add_zero_class \u03b1] : add_zero_class \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_zero_class _ rfl (\u03bb x y, rfl)\n\ninstance [add_monoid \u03b1] : add_monoid \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [add_comm_monoid \u03b1] : add_comm_monoid \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_comm_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [add_monoid_with_one \u03b1] : add_monoid_with_one \u03b1\u1d50\u1d52\u1d56 :=\n{ nat_cast_zero := show op ((0 : \u2115) : \u03b1) = 0, by rw [nat.cast_zero, op_zero],\n  nat_cast_succ := show \u2200 n, op ((n + 1 : \u2115) : \u03b1) = op (n : \u2115) + 1, by simp,\n  .. mul_opposite.add_monoid \u03b1, .. mul_opposite.has_one \u03b1, ..mul_opposite.has_nat_cast _ }\n\ninstance [add_comm_monoid_with_one \u03b1] : add_comm_monoid_with_one \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.add_monoid_with_one \u03b1, ..mul_opposite.add_comm_monoid \u03b1 }\n\ninstance [sub_neg_monoid \u03b1] : sub_neg_monoid \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.sub_neg_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [add_group \u03b1] : add_group \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [add_comm_group \u03b1] : add_comm_group \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_comm_group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [add_group_with_one \u03b1] : add_group_with_one \u03b1\u1d50\u1d52\u1d56 :=\n{ int_cast := \u03bb n, op n,\n  int_cast_of_nat := \u03bb n, show op ((n : \u2124) : \u03b1) = op n, by rw int.cast_coe_nat,\n  int_cast_neg_succ_of_nat := \u03bb n, show op _ = op (- unop (op ((n + 1 : \u2115) : \u03b1))),\n    by erw [unop_op, int.cast_neg_succ_of_nat]; refl,\n  .. mul_opposite.add_monoid_with_one \u03b1, .. mul_opposite.add_group \u03b1 }\n\ninstance [add_comm_group_with_one \u03b1] : add_comm_group_with_one \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.add_group_with_one \u03b1, ..mul_opposite.add_comm_group \u03b1 }\n\n/-!\n### Multiplicative structures on `\u03b1\u1d50\u1d52\u1d56`\n\nWe also generate additive structures on `\u03b1\u1d43\u1d52\u1d56` using `to_additive`\n-/\n\n@[to_additive] instance [semigroup \u03b1] : semigroup \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_assoc := \u03bb x y z, unop_injective $ eq.symm $ mul_assoc (unop z) (unop y) (unop x),\n  .. mul_opposite.has_mul \u03b1 }\n\n@[to_additive] instance [right_cancel_semigroup \u03b1] : left_cancel_semigroup \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_left_cancel := \u03bb x y z H, unop_injective $ mul_right_cancel $ op_injective H,\n  .. mul_opposite.semigroup \u03b1 }\n\n@[to_additive] instance [left_cancel_semigroup \u03b1] : right_cancel_semigroup \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_right_cancel := \u03bb x y z H, unop_injective $ mul_left_cancel $ op_injective H,\n  .. mul_opposite.semigroup \u03b1 }\n\n@[to_additive] instance [comm_semigroup \u03b1] : comm_semigroup \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_comm := \u03bb x y, unop_injective $ mul_comm (unop y) (unop x),\n  .. mul_opposite.semigroup \u03b1 }\n\n@[to_additive] instance [mul_one_class \u03b1] : mul_one_class \u03b1\u1d50\u1d52\u1d56 :=\n{ one_mul := \u03bb x, unop_injective $ mul_one $ unop x,\n  mul_one := \u03bb x, unop_injective $ one_mul $ unop x,\n  .. mul_opposite.has_mul \u03b1, .. mul_opposite.has_one \u03b1 }\n\n@[to_additive] instance [monoid \u03b1] : monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ npow := \u03bb n x, op $ x.unop ^ n,\n  npow_zero' := \u03bb x, unop_injective $ monoid.npow_zero' x.unop,\n  npow_succ' := \u03bb n x, unop_injective $ pow_succ' x.unop n,\n  .. mul_opposite.semigroup \u03b1, .. mul_opposite.mul_one_class \u03b1 }\n\n@[to_additive] instance [right_cancel_monoid \u03b1] : left_cancel_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.left_cancel_semigroup \u03b1, .. mul_opposite.monoid \u03b1 }\n\n@[to_additive] instance [left_cancel_monoid \u03b1] : right_cancel_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.right_cancel_semigroup \u03b1, .. mul_opposite.monoid \u03b1 }\n\n@[to_additive] instance [cancel_monoid \u03b1] : cancel_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.right_cancel_monoid \u03b1, .. mul_opposite.left_cancel_monoid \u03b1 }\n\n@[to_additive] instance [comm_monoid \u03b1] : comm_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.monoid \u03b1, .. mul_opposite.comm_semigroup \u03b1 }\n\n@[to_additive] instance [cancel_comm_monoid \u03b1] : cancel_comm_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.cancel_monoid \u03b1, .. mul_opposite.comm_monoid \u03b1 }\n\n@[to_additive add_opposite.sub_neg_monoid] instance [div_inv_monoid \u03b1] : div_inv_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ zpow := \u03bb n x, op $ x.unop ^ n,\n  zpow_zero' := \u03bb x, unop_injective $ div_inv_monoid.zpow_zero' x.unop,\n  zpow_succ' := \u03bb n x, unop_injective $\n    by rw [unop_op, zpow_of_nat, zpow_of_nat, pow_succ', unop_mul, unop_op],\n  zpow_neg' := \u03bb z x, unop_injective $ div_inv_monoid.zpow_neg' z x.unop,\n  .. mul_opposite.monoid \u03b1, .. mul_opposite.has_inv \u03b1 }\n\n@[to_additive add_opposite.subtraction_monoid] instance [division_monoid \u03b1] :\n  division_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_inv_rev := \u03bb a b, unop_injective $ mul_inv_rev _ _,\n  inv_eq_of_mul := \u03bb a b h, unop_injective $ inv_eq_of_mul_eq_one_left $ congr_arg unop h,\n  .. mul_opposite.div_inv_monoid \u03b1, .. mul_opposite.has_involutive_inv \u03b1 }\n\n@[to_additive add_opposite.subtraction_comm_monoid] instance [division_comm_monoid \u03b1] :\n  division_comm_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ ..mul_opposite.division_monoid \u03b1, ..mul_opposite.comm_semigroup \u03b1 }\n\n@[to_additive] instance [group \u03b1] : group \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_left_inv := \u03bb x, unop_injective $ mul_inv_self $ unop x,\n  .. mul_opposite.div_inv_monoid \u03b1, }\n\n@[to_additive] instance [comm_group \u03b1] : comm_group \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.group \u03b1, .. mul_opposite.comm_monoid \u03b1 }\n\nvariable {\u03b1}\n\n@[simp, norm_cast, to_additive] lemma op_nat_cast [has_nat_cast \u03b1] (n : \u2115) : op (n : \u03b1) = n := rfl\n@[simp, norm_cast, to_additive] lemma op_int_cast [has_int_cast \u03b1] (n : \u2124) : op (n : \u03b1) = n := rfl\n\n@[simp, norm_cast, to_additive]\nlemma unop_nat_cast [has_nat_cast \u03b1] (n : \u2115) : unop (n : \u03b1\u1d50\u1d52\u1d56) = n := rfl\n\n@[simp, norm_cast, to_additive]\nlemma unop_int_cast [has_int_cast \u03b1] (n : \u2124) : unop (n : \u03b1\u1d50\u1d52\u1d56) = n := rfl\n\n@[simp, to_additive] lemma unop_div [div_inv_monoid \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) :\n  unop (x / y) = (unop y)\u207b\u00b9 * unop x :=\nrfl\n\n@[simp, to_additive] lemma op_div [div_inv_monoid \u03b1] (x y : \u03b1) :\n  op (x / y) = (op y)\u207b\u00b9 * op x :=\nby simp [div_eq_mul_inv]\n\n@[simp, to_additive] lemma semiconj_by_op [has_mul \u03b1] {a x y : \u03b1} :\n  semiconj_by (op a) (op y) (op x) \u2194 semiconj_by a x y :=\nby simp only [semiconj_by, \u2190 op_mul, op_inj, eq_comm]\n\n@[simp, to_additive] lemma semiconj_by_unop [has_mul \u03b1] {a x y : \u03b1\u1d50\u1d52\u1d56} :\n  semiconj_by (unop a) (unop y) (unop x) \u2194 semiconj_by a x y :=\nby conv_rhs { rw [\u2190 op_unop a, \u2190 op_unop x, \u2190 op_unop y, semiconj_by_op] }\n\n@[to_additive] lemma _root_.semiconj_by.op [has_mul \u03b1] {a x y : \u03b1} (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 \u03b1] {a x y : \u03b1\u1d50\u1d52\u1d56} (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 \u03b1] {x y : \u03b1} (h : commute x y) :\n  commute (op x) (op y) := h.op\n\n@[to_additive] lemma commute.unop [has_mul \u03b1] {x y : \u03b1\u1d50\u1d52\u1d56} (h : commute x y) :\n  commute (unop x) (unop y) := h.unop\n\n@[simp, to_additive] lemma commute_op [has_mul \u03b1] {x y : \u03b1} :\n  commute (op x) (op y) \u2194 commute x y :=\nsemiconj_by_op\n\n@[simp, to_additive] lemma commute_unop [has_mul \u03b1] {x y : \u03b1\u1d50\u1d52\u1d56} :\n  commute (unop x) (unop y) \u2194 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 \u03b1] : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56 :=\n{ map_add' := \u03bb a b, rfl, .. op_equiv }\n\n@[simp] lemma op_add_equiv_to_equiv [has_add \u03b1] :\n  (op_add_equiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).to_equiv = op_equiv :=\nrfl\n\nend mul_opposite\n\n/-!\n### Multiplicative structures on `\u03b1\u1d43\u1d52\u1d56`\n-/\n\nnamespace add_opposite\n\ninstance [semigroup \u03b1] : semigroup (\u03b1\u1d43\u1d52\u1d56) :=\nunop_injective.semigroup _ (\u03bb x y, rfl)\n\ninstance [left_cancel_semigroup \u03b1] : left_cancel_semigroup \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.left_cancel_semigroup _ (\u03bb x y, rfl)\n\ninstance [right_cancel_semigroup \u03b1] : right_cancel_semigroup \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.right_cancel_semigroup _ (\u03bb x y, rfl)\n\ninstance [comm_semigroup \u03b1] : comm_semigroup \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.comm_semigroup _ (\u03bb x y, rfl)\n\ninstance [mul_one_class \u03b1] : mul_one_class \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.mul_one_class _ rfl (\u03bb x y, rfl)\n\ninstance {\u03b2} [has_pow \u03b1 \u03b2] : has_pow \u03b1\u1d43\u1d52\u1d56 \u03b2 := { pow := \u03bb a b, op (unop a ^ b) }\n\n@[simp] lemma op_pow {\u03b2} [has_pow \u03b1 \u03b2] (a : \u03b1) (b : \u03b2) : op (a ^ b) = op a ^ b := rfl\n@[simp] lemma unop_pow {\u03b2} [has_pow \u03b1 \u03b2] (a : \u03b1\u1d43\u1d52\u1d56) (b : \u03b2) : unop (a ^ b) = unop a ^ b := rfl\n\ninstance [monoid \u03b1] : monoid \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.monoid _ rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [comm_monoid \u03b1] : comm_monoid \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.comm_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [div_inv_monoid \u03b1] : div_inv_monoid \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.div_inv_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [group \u03b1] : group \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [comm_group \u03b1] : comm_group \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.comm_group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\n-- NOTE: `add_monoid_with_one \u03b1 \u2192 add_monoid_with_one \u03b1\u1d43\u1d52\u1d56` does not hold\n\ninstance [add_comm_monoid_with_one \u03b1] : add_comm_monoid_with_one \u03b1\u1d43\u1d52\u1d56 :=\n{ nat_cast_zero := show op ((0 : \u2115) : \u03b1) = 0, by rw [nat.cast_zero, op_zero],\n  nat_cast_succ := show \u2200 n, op ((n + 1 : \u2115) : \u03b1) = op (n : \u2115) + 1, by simp [add_comm],\n  ..add_opposite.add_comm_monoid \u03b1, ..add_opposite.has_one, ..add_opposite.has_nat_cast _ }\n\ninstance [add_comm_group_with_one \u03b1] : add_comm_group_with_one \u03b1\u1d43\u1d52\u1d56 :=\n{ int_cast_of_nat := \u03bb n, congr_arg op $ int.cast_of_nat n,\n  int_cast_neg_succ_of_nat := \u03bb _, congr_arg op $ int.cast_neg_succ_of_nat _,\n  ..add_opposite.add_comm_monoid_with_one _, ..add_opposite.add_comm_group \u03b1,\n  ..add_opposite.has_int_cast \u03b1 }\n\nvariable {\u03b1}\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 \u03b1] : \u03b1 \u2243* \u03b1\u1d43\u1d52\u1d56 :=\n{ map_mul' := \u03bb a b, rfl, .. op_equiv }\n\n@[simp] lemma op_mul_equiv_to_equiv [has_mul \u03b1] :\n  (op_mul_equiv : \u03b1 \u2243* \u03b1\u1d43\u1d52\u1d56).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 \u2243* G\u1d50\u1d52\u1d56 :=\n{ map_mul' := \u03bb x y, unop_injective $ mul_inv_rev x y,\n  .. (equiv.inv G).trans op_equiv }\n\n/-- A semigroup homomorphism `f : M \u2192\u2099* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism to `N\u1d50\u1d52\u1d56`. -/\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\u1d43\u1d52\u1d56`.\",\n  simps {fully_applied := ff}]\ndef mul_hom.to_opposite {M N : Type*} [has_mul M] [has_mul N] (f : M \u2192\u2099* N)\n  (hf : \u2200 x y, commute (f x) (f y)) : M \u2192\u2099* N\u1d50\u1d52\u1d56 :=\n{ to_fun := mul_opposite.op \u2218 f,\n  map_mul' := \u03bb x y, by simp [(hf x y).eq] }\n\n/-- A semigroup homomorphism `f : M \u2192\u2099* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism from `M\u1d50\u1d52\u1d56`. -/\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\u1d43\u1d52\u1d56`.\",\n  simps {fully_applied := ff}]\ndef mul_hom.from_opposite {M N : Type*} [has_mul M] [has_mul N] (f : M \u2192\u2099* N)\n  (hf : \u2200 x y, commute (f x) (f y)) : M\u1d50\u1d52\u1d56 \u2192\u2099* N :=\n{ to_fun := f \u2218 mul_opposite.unop,\n  map_mul' := \u03bb x y, (f.map_mul _ _).trans (hf _ _).eq }\n\n/-- A monoid homomorphism `f : M \u2192* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism to `N\u1d50\u1d52\u1d56`. -/\n@[to_additive \"An additive monoid homomorphism `f : M \u2192+ N` such that `f x` additively commutes\nwith `f y` for all `x, y` defines an additive monoid homomorphism to `S\u1d43\u1d52\u1d56`.\",\n  simps {fully_applied := ff}]\ndef monoid_hom.to_opposite {M N : Type*} [mul_one_class M] [mul_one_class N] (f : M \u2192* N)\n  (hf : \u2200 x y, commute (f x) (f y)) : M \u2192* N\u1d50\u1d52\u1d56 :=\n{ to_fun := mul_opposite.op \u2218 f,\n  map_one' := congr_arg op f.map_one,\n  map_mul' := \u03bb x y, by simp [(hf x y).eq] }\n\n/-- A monoid homomorphism `f : M \u2192* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism from `M\u1d50\u1d52\u1d56`. -/\n@[to_additive \"An additive monoid homomorphism `f : M \u2192+ N` such that `f x` additively commutes\nwith `f y` for all `x`, `y` defines an additive monoid homomorphism from `M\u1d43\u1d52\u1d56`.\",\n  simps {fully_applied := ff}]\ndef monoid_hom.from_opposite {M N : Type*} [mul_one_class M] [mul_one_class N] (f : M \u2192* N)\n  (hf : \u2200 x y, commute (f x) (f y)) : M\u1d50\u1d52\u1d56 \u2192* N :=\n{ to_fun := f \u2218 mul_opposite.unop,\n  map_one' := f.map_one,\n  map_mul' := \u03bb 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\u1d50\u1d52\u1d56)\u02e3 \u2243* (M\u02e3)\u1d50\u1d52\u1d56 :=\n{ to_fun := \u03bb u, op \u27e8unop u, unop \u2191(u\u207b\u00b9), op_injective u.4, op_injective u.3\u27e9,\n  inv_fun := mul_opposite.rec $ \u03bb u, \u27e8op \u2191(u), op \u2191(u\u207b\u00b9), unop_injective $ u.4, unop_injective u.3\u27e9,\n  map_mul' := \u03bb x y, unop_injective $ units.ext $ rfl,\n  left_inv := \u03bb x, units.ext $ by simp,\n  right_inv := \u03bb x, unop_injective $ units.ext $ rfl }\n\n@[simp, to_additive]\nlemma units.coe_unop_op_equiv {M} [monoid M] (u : (M\u1d50\u1d52\u1d56)\u02e3) :\n  ((units.op_equiv u).unop : M) = unop (u : M\u1d50\u1d52\u1d56) :=\nrfl\n\n@[simp, to_additive]\nlemma units.coe_op_equiv_symm {M} [monoid M] (u : (M\u02e3)\u1d50\u1d52\u1d56) :\n  (units.op_equiv.symm u : M\u1d50\u1d52\u1d56) = op (u.unop : M) :=\nrfl\n\n/-- A semigroup homomorphism `M \u2192\u2099* N` can equivalently be viewed as a semigroup homomorphism\n`M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-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\u1d43\u1d52\u1d56 N\u1d43\u1d52\u1d56`. This is the action of the (fully faithful)\n`\u1d43\u1d52\u1d56`-functor on morphisms.\", simps]\ndef mul_hom.op {M N} [has_mul M] [has_mul N] :\n  (M \u2192\u2099* N) \u2243 (M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun   := op \u2218 f \u2218 unop,\n                      map_mul' := \u03bb x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := \u03bb f, { to_fun   := unop \u2218 f \u2218 op,\n                      map_mul' := \u03bb x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext x, simp } }\n\n/-- The 'unopposite' of a semigroup homomorphism `M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56`. Inverse to `mul_hom.op`. -/\n@[simp, to_additive \"The 'unopposite' of an additive semigroup homomorphism `M\u1d43\u1d52\u1d56 \u2192\u2099+ N\u1d43\u1d52\u1d56`. Inverse\nto `add_hom.op`.\"]\ndef mul_hom.unop {M N} [has_mul M] [has_mul N] :\n  (M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56) \u2243 (M \u2192\u2099* 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\u1d50\u1d52\u1d56 N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on\nmorphisms. -/\n@[simps]\ndef add_hom.mul_op {M N} [has_add M] [has_add N] :\n  (add_hom M N) \u2243 (add_hom M\u1d50\u1d52\u1d56 N\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun    := op \u2218 f \u2218 unop,\n                      map_add'  := \u03bb x y, unop_injective (f.map_add x.unop y.unop) },\n  inv_fun   := \u03bb f, { to_fun    := unop \u2218 f \u2218 op,\n                      map_add'  := \u03bb x y, congr_arg unop (f.map_add (op x) (op y)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext, simp } }\n\n/-- The 'unopposite' of an additive semigroup hom `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56`. Inverse to\n`add_hom.mul_op`. -/\n@[simp] def add_hom.mul_unop {\u03b1 \u03b2} [has_add \u03b1] [has_add \u03b2] :\n  (add_hom \u03b1\u1d50\u1d52\u1d56 \u03b2\u1d50\u1d52\u1d56) \u2243 (add_hom \u03b1 \u03b2) := add_hom.mul_op.symm\n\n/-- A monoid homomorphism `M \u2192* N` can equivalently be viewed as a monoid homomorphism\n`M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on morphisms. -/\n@[to_additive \"An additive monoid homomorphism `M \u2192+ N` can equivalently be viewed as an\nadditive monoid homomorphism `M\u1d43\u1d52\u1d56 \u2192+ N\u1d43\u1d52\u1d56`. This is the action of the (fully faithful)\n`\u1d43\u1d52\u1d56`-functor on morphisms.\", simps]\ndef monoid_hom.op {M N} [mul_one_class M] [mul_one_class N] :\n  (M \u2192* N) \u2243 (M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun   := op \u2218 f \u2218 unop,\n                      map_one' := congr_arg op f.map_one,\n                      map_mul' := \u03bb x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := \u03bb f, { to_fun   := unop \u2218 f \u2218 op,\n                      map_one' := congr_arg unop f.map_one,\n                      map_mul' := \u03bb x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext x, simp } }\n\n/-- The 'unopposite' of a monoid homomorphism `M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56`. Inverse to `monoid_hom.op`. -/\n@[simp, to_additive \"The 'unopposite' of an additive monoid homomorphism `M\u1d43\u1d52\u1d56 \u2192+ N\u1d43\u1d52\u1d56`. Inverse to\n`add_monoid_hom.op`.\"]\ndef monoid_hom.unop {M N} [mul_one_class M] [mul_one_class N] :\n  (M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56) \u2243 (M \u2192* N) := monoid_hom.op.symm\n\n/-- An additive homomorphism `M \u2192+ N` can equivalently be viewed as an additive homomorphism\n`M\u1d50\u1d52\u1d56 \u2192+ N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on morphisms. -/\n@[simps]\ndef add_monoid_hom.mul_op {M N} [add_zero_class M] [add_zero_class N] :\n  (M \u2192+ N) \u2243 (M\u1d50\u1d52\u1d56 \u2192+ N\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun    := op \u2218 f \u2218 unop,\n                      map_zero' := unop_injective f.map_zero,\n                      map_add'  := \u03bb x y, unop_injective (f.map_add x.unop y.unop) },\n  inv_fun   := \u03bb f, { to_fun    := unop \u2218 f \u2218 op,\n                      map_zero' := congr_arg unop f.map_zero,\n                      map_add'  := \u03bb x y, congr_arg unop (f.map_add (op x) (op y)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext, simp } }\n\n/-- The 'unopposite' of an additive monoid hom `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56`. Inverse to\n`add_monoid_hom.mul_op`. -/\n@[simp] def add_monoid_hom.mul_unop {\u03b1 \u03b2} [add_zero_class \u03b1] [add_zero_class \u03b2] :\n  (\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56) \u2243 (\u03b1 \u2192+ \u03b2) := add_monoid_hom.mul_op.symm\n\n/-- A iso `\u03b1 \u2243+ \u03b2` can equivalently be viewed as an iso `\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56`. -/\n@[simps]\ndef add_equiv.mul_op {\u03b1 \u03b2} [has_add \u03b1] [has_add \u03b2] :\n  (\u03b1 \u2243+ \u03b2) \u2243 (\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, op_add_equiv.symm.trans (f.trans op_add_equiv),\n  inv_fun   := \u03bb f, op_add_equiv.trans (f.trans op_add_equiv.symm),\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext, simp } }\n\n/-- The 'unopposite' of an iso `\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56`. Inverse to `add_equiv.mul_op`. -/\n@[simp] def add_equiv.mul_unop {\u03b1 \u03b2} [has_add \u03b1] [has_add \u03b2] :\n  (\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56) \u2243 (\u03b1 \u2243+ \u03b2) := add_equiv.mul_op.symm\n\n/-- A iso `\u03b1 \u2243* \u03b2` can equivalently be viewed as an iso `\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56`. -/\n@[to_additive \"A iso `\u03b1 \u2243+ \u03b2` can equivalently be viewed as an iso `\u03b1\u1d43\u1d52\u1d56 \u2243+ \u03b2\u1d43\u1d52\u1d56`.\", simps]\ndef mul_equiv.op {\u03b1 \u03b2} [has_mul \u03b1] [has_mul \u03b2] :\n  (\u03b1 \u2243* \u03b2) \u2243 (\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun   := op \u2218 f \u2218 unop,\n                      inv_fun  := op \u2218 f.symm \u2218 unop,\n                      left_inv := \u03bb x, unop_injective (f.symm_apply_apply x.unop),\n                      right_inv := \u03bb x, unop_injective (f.apply_symm_apply x.unop),\n                      map_mul' := \u03bb x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := \u03bb f, { to_fun   := unop \u2218 f \u2218 op,\n                      inv_fun  := unop \u2218 f.symm \u2218 op,\n                      left_inv := \u03bb x, by simp,\n                      right_inv := \u03bb x, by simp,\n                      map_mul' := \u03bb x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext, simp } }\n\n/-- The 'unopposite' of an iso `\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56`. Inverse to `mul_equiv.op`. -/\n@[simp, to_additive \"The 'unopposite' of an iso `\u03b1\u1d43\u1d52\u1d56 \u2243+ \u03b2\u1d43\u1d52\u1d56`. Inverse to `add_equiv.op`.\"]\ndef mul_equiv.unop {\u03b1 \u03b2} [has_mul \u03b1] [has_mul \u03b2] :\n  (\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56) \u2243 (\u03b1 \u2243* \u03b2) := mul_equiv.op.symm\n\nsection ext\n\n/-- This ext lemma change equalities on `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2` to equalities on `\u03b1 \u2192+ \u03b2`.\nThis is useful because there are often ext lemmas for specific `\u03b1`s that will apply\nto an equality of `\u03b1 \u2192+ \u03b2` such as `finsupp.add_hom_ext'`. -/\n@[ext]\nlemma add_monoid_hom.mul_op_ext {\u03b1 \u03b2} [add_zero_class \u03b1] [add_zero_class \u03b2]\n  (f g : \u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2)\n  (h : f.comp (op_add_equiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).to_add_monoid_hom =\n       g.comp (op_add_equiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).to_add_monoid_hom) : f = g :=\nadd_monoid_hom.ext $ mul_opposite.rec $ \u03bb 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 : \u211d\u22650) (c : \u211d\u22650) (S : Fintype) :=\n(to_fun     : S \u2192 \u2124 \u2192 \u2124)\n(summable   : \u2200 s, summable (\u03bb n, (\u2225 to_fun s n \u2225\u208a * r ^ n)))\n(bdd        : \u2200 s, tsum (\u03bb n, (\u2225 to_fun s n \u2225\u208a * r ^ n)) \u2264 c)\n-/\n\n/-- A term of type `laurent_measures r S` is, for each `s : S`, a function `\u03c6 : \u2124 \u2192 \u2124`\n  (typically thought of as a power series `\u2211 \u03c6(n)T\u207f`) such that `\u2211 |\u03c6(n)|r\u207f` converges.\n  Note that if `0<r<1` then the support of \u03c6 can only contain finitely many negative integers.  -/\nstructure laurent_measures (r : \u211d\u22650) (S : Fintype) :=\n(to_fun    : S \u2192 \u2124 \u2192 \u2124)\n(summable' : \u2200 s, summable (\u03bb n, \u2225to_fun s n\u2225\u208a * r ^ n))\n\nvariables {r : \u211d\u22650} {S S' : Fintype.{u}}\n\nlocal notation `\u2112` := laurent_measures r\n\nnamespace laurent_measures\n\ninstance : has_coe_to_fun (\u2112 S) (\u03bb F, S \u2192 \u2124 \u2192 \u2124) :=\n\u27e8\u03bb F, F.to_fun\u27e9\n\n@[simp] lemma coe_mk (f : S \u2192 \u2124 \u2192 \u2124) (hf) (s : S) (n : \u2124) :\n  (@laurent_measures.mk r S f hf) s n = f s n := rfl\n\n@[ext]\nlemma ext (F G : \u2112 S) : (F : S \u2192 \u2124 \u2192 \u2124) = G \u2192 F = G :=\nby { intros h, cases F, cases G, simpa }\n\nlemma ext_iff (F G : \u2112 S) : F = G \u2194 \u2200 s n, F s n = G s n :=\n\u27e8\u03bb h, by intros; rw h, \u03bb h, laurent_measures.ext F G $ by ext; apply h\u27e9\n\nprotected lemma nnreal_summable (F : \u2112 S) (s : S) : summable (\u03bb n, \u2225F s n\u2225\u208a * r ^ n) :=\nF.2 _\n\nprotected lemma summable (F : \u2112 S) (s : S) : summable (\u03bb n, \u2225F s n\u2225 * r ^ n) :=\nbegin\n  simpa only [\u2190 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 : \u2124) (r : \u211d\u22650) : 0 \u2264 \u2225 k \u2225 * (r : \u211d)^n :=\nmul_nonneg (norm_nonneg _) (zpow_nonneg (nnreal.coe_nonneg _) _)\n\ndef map (f : S \u27f6 S') : \u2112 S \u2192 \u2112 S' := \u03bb F,\n{ to_fun := \u03bb s' k, \u2211 s in finset.univ.filter (\u03bb t, f t = s'), F s k,\n  summable' := begin\n    intros s',\n    have : \u2200 n : \u2124, \u2225\u2211 s in finset.univ.filter (\u03bb t, f t = s'), F s n\u2225\u208a * r^n \u2264\n      \u2211 s in finset.univ.filter (\u03bb t, f t = s'), \u2225F s n\u2225\u208a * r^n := \u03bb n,\n    calc \u2225\u2211 s in finset.univ.filter (\u03bb t, f t = s'), F s n\u2225\u208a * r^n \u2264\n      (\u2211 s in finset.univ.filter (\u03bb t, f t = s'), \u2225F s n\u2225\u208a) * 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 $ \u03bb (s : S) _, F.nnreal_summable s),\n  end }\n\n@[simp] lemma map_apply (f : S \u27f6 S') (F : \u2112 S) (s' : S') (k : \u2124) :\n  map f F s' k = \u2211 s in finset.univ.filter (\u03bb t, f t = s'), F s k := rfl\n\n@[simp] lemma map_id : (map (\ud835\udfd9 S) : \u2112 S \u2192 \u2112 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 \u27f6 S') (g : S' \u27f6 S'') :\n  (map (f \u226b g) : \u2112 S \u2192 \u2112 S'') = map g \u2218 map f :=\nbegin\n  ext F s k,\n  simp only [function.comp_app, map_apply, finset.sum_congr],\n  rw \u2190 finset.sum_bUnion,\n  { apply finset.sum_congr,\n    { change finset.univ.filter (\u03bb 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 [\u2190 hk.1, \u2190 hk.2] }\nend\n\ndef add : \u2112 S \u2192 \u2112 S \u2192 \u2112 S := \u03bb F G,\n{ to_fun := F + G,\n  summable' := \u03bb s, begin\n    refine nnreal.summable_of_le _ ((F.nnreal_summable s).add (G.nnreal_summable s)),\n    intros n,\n    rw \u2190 add_mul,\n    exact mul_le_mul' (nnnorm_add_le _ _) le_rfl,\n  end }\n\ninstance : has_add (\u2112 S) := \u27e8add\u27e9\n\n@[simp]\nlemma add_apply (F G : \u2112 S) (s : S) (n : \u2124) : (F + G) s n = F s n + G s n := rfl\n\ndef zero : \u2112 S :=\n{ to_fun := 0,\n  summable' := \u03bb s, by simp [summable_zero] }\n\ninstance : has_zero (\u2112 S) := \u27e8zero\u27e9\n\n@[simp] lemma zero_apply (s : S) (n : \u2124) : (0 : \u2112 S) s n = 0 := rfl\n\ndef neg : \u2112 S \u2192 \u2112 S := \u03bb F,\n{ to_fun := - F,\n  summable' := \u03bb s, by simp [F.nnreal_summable] }\n\ninstance : has_neg (\u2112 S) := \u27e8neg\u27e9\n\n@[simp] lemma neg_apply (F : \u2112 S) (s : S) (n : \u2124) : (-F) s n = - (F s n) := rfl\n\ndef sub : \u2112 S \u2192 \u2112 S \u2192 \u2112 S := \u03bb F G,\n{ to_fun := F - G,\n  summable' := (add F (neg G)).nnreal_summable }\n\ninstance : has_sub (\u2112 S) := \u27e8sub\u27e9\n\n@[simp] lemma sub_apply (F G : \u2112 S) (s : S) (n : \u2124) : (F - G) s n = F s n - G s n := rfl\n\nexample (a m : \u2124) : (-a)*m=a*(-m) := neg_mul_comm a m\n\n-- move me\ninstance : has_continuous_smul \u2115 \u211d\u22650 :=\n{ continuous_smul := begin\n    let f : \u2115 \u00d7 \u211d\u22650 \u2192 \u211d\u22650 \u00d7 \u211d\u22650 := 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 : \u2124) : \u2225m * n\u2225 = \u2225m\u2225 * \u2225n\u2225 :=\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 : \u2124) : \u2225m * n\u2225\u208a = \u2225m\u2225\u208a * \u2225n\u2225\u208a :=\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 : \u2115) : \u2225(n : \u2124)\u2225 = 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 : \u2115) : \u2225(n : \u2124)\u2225\u208a = n :=\nby ext; simp only [coe_nnnorm, nat.norm_coe_int, nnreal.coe_nat_cast]\n\ninstance : add_comm_monoid (\u2112 S) :=\n{ add_assoc := \u03bb a b c, by { ext, simp only [add_assoc, add_apply] },\n  add_comm := \u03bb F G, by { ext, simp only [add_comm, add_apply] },\n  zero_add := \u03bb a, by { ext, simp only [zero_add, add_apply, zero_apply] },\n  add_zero := \u03bb a, by { ext, simp only [add_zero, add_apply, zero_apply] },\n  nsmul := \u03bb n F,\n  { to_fun := \u03bb s k, n \u2022 (F s k),\n    summable' := \u03bb 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' := \u03bb F, by { ext, refl },\n  nsmul_succ' := \u03bb n F, by { ext, refl },\n  ..(infer_instance : has_add _),\n  ..(infer_instance : has_zero _) }\n\ninstance : add_comm_group (\u2112 S) :=\n{ neg := neg,\n  sub := sub,\n  sub_eq_add_neg := \u03bb F G, by { ext, refl },\n  zsmul := \u03bb n F,\n  { to_fun := \u03bb s m, n \u2022 (F s m),\n    summable' := \u03bb 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' := \u03bb F, by { ext, simp only [algebra.id.smul_eq_mul, zero_mul, coe_mk, zero_apply], },\n  zsmul_succ' := \u03bb 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' := \u03bb 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 := \u03bb F, by { ext, simp only [zero_apply, add_apply, neg_apply, add_left_neg], },\n  add_comm := \u03bb 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 (\u2112 S) :=\n\u27e8\u03bb F, \u2211 s, \u2211' n, \u2225F s n\u2225 * (r : \u211d) ^ n\u27e9\n\nlemma norm_def (F : \u2112 S) : \u2225F\u2225 = \u2211 s, \u2211' n, \u2225F s n\u2225 * (r : \u211d)^n := rfl\n\ninstance : has_nnnorm (\u2112 S) :=\n\u27e8\u03bb F, \u2211 s, \u2211' n, \u2225F s n\u2225\u208a * r ^ n\u27e9\n\nlemma nnnorm_def (F : \u2112 S) : \u2225F\u2225\u208a = \u2211 s, \u2211' n, \u2225F s n\u2225\u208a * r^n := rfl\n\n@[simp] lemma coe_nnnorm (F : \u2112 S) : (\u2225F\u2225\u208a : \u211d) = \u2225F\u2225 :=\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 : \u2112 S) : 0 \u2264 \u2225F\u2225 :=\nby rw [\u2190 coe_nnnorm]; exact \u2225F\u2225\u208a.coe_nonneg\n\n@[simp] lemma nnnorm_neg (F : \u2112 S) : \u2225-F\u2225\u208a = \u2225F\u2225\u208a :=\nby simp only [nnnorm_def, neg_apply, nnnorm_neg]\n\nlemma nnnorm_add (F G : \u2112 S) : \u2225F + G\u2225\u208a \u2264 \u2225F\u2225\u208a + \u2225G\u2225\u208a :=\nbegin\n  simp only [nnnorm_def, \u2190 finset.sum_add_distrib],\n  apply finset.sum_le_sum,\n  rintro s -,\n  rw \u2190 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 [\u2190 add_mul],\n  refine mul_le_mul' (nnnorm_add_le _ _) le_rfl\nend\n\nlemma norm_add (F G : \u2112 S) : \u2225F + G\u2225 \u2264 \u2225F\u2225 + \u2225G\u2225 :=\nby simpa only [\u2190 coe_nnnorm, \u2190 nnreal.coe_add, nnreal.coe_le_coe] using nnnorm_add F G\n\n@[simp] lemma nsmul_apply (k : \u2115) (F : \u2112 S) (s : S) (n : \u2124) : (k \u2022 F) s n = k \u2022 (F s n) := rfl\n\n@[simp] lemma zsmul_apply (k : \u2124) (F : \u2112 S) (s : S) (n : \u2124) : (k \u2022 F) s n = k \u2022 (F s n) := rfl\n\nsection\nopen finset\n\nlemma map_bound (f : S \u27f6 S') (F : \u2112 S) : \u2225map f F\u2225\u208a \u2264 \u2225F\u2225\u208a := calc\n\u2225map f F\u2225\u208a = \u2211 s', \u2211' n, \u2225\u2211 s in univ.filter (\u03bb t, f t = s'), F s n\u2225\u208a * _ : rfl\n... \u2264 \u2211 s', \u2211' n, \u2211 s in univ.filter (\u03bb t, f t = s'), \u2225F s n\u2225\u208a * r^n : begin\n  apply sum_le_sum,\n  rintros s' -,\n  have h1 : summable (\u03bb n : \u2124, \u2211 (s : S.\u03b1) in univ.filter (\u03bb t, f t = s'), \u2225F s n\u2225\u208a * r^n) :=\n    summable_sum (\u03bb s _, F.nnreal_summable s),\n  have h2 : \u2200 b : \u2124,\n    \u2225\u2211 (s : S.\u03b1) in univ.filter (\u03bb t, f t = s'), F s b\u2225\u208a * r ^ b \u2264\n      \u2211 (s : S.\u03b1) in univ.filter (\u03bb t, f t = s'), \u2225F s b\u2225\u208a * r ^ b,\n  { intros b, rw \u2190 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... = \u2211 s', \u2211 s in univ.filter (\u03bb t, f t = s'), \u2211' n, \u2225F s n\u2225\u208a * r^n :\n  sum_congr rfl (\u03bb s' _, tsum_sum $ \u03bb s _, F.nnreal_summable _)\n... = _ : begin\n  rw [\u2190 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 [\u2190 hi.1, \u2190 hi.2] }\nend\n\nend\n\nlemma map_bound' (f : S \u27f6 S') (F : \u2112 S) : \u2225map f F\u2225 \u2264 \u2225F\u2225 :=\nby simpa only [\u2190 coe_nnnorm, \u2190 nnreal.coe_add, nnreal.coe_le_coe] using map_bound f F\n\n\n/-\nlemma exists_c (F : \u2112 S) : \u2203 (c : \u211d\u22650),\n  \u2200 s : S, \u2211' n, \u2225 F s n \u2225 * r ^ n \u2264 c :=\nbegin\n  use \u2211 s, \u2211' n, \u2225 F s n \u2225 * 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 : \u2112 S) (c : \u211d\u22650) :\n  \u2225F\u2225\u208a \u2264 c \u2192 \u2200 (s : S) (n : \u2124), c < r^n \u2192 F s n = 0 :=\nbegin\n  intros hF s n h,\n  suffices : \u2225F s n\u2225\u208a < 1,\n  { change abs (F s n : \u211d) < 1 at this,\n    norm_cast at this,\n    rwa \u2190 int.abs_lt_one_iff },\n  have : \u2225F s n\u2225\u208a * r ^ n \u2264 \u2211' k, \u2225F s k\u2225\u208a * r ^ k,\n  { exact le_tsum (F.nnreal_summable s) _ (\u03bb k _, zero_le'), },\n  replace this := lt_of_le_of_lt (this.trans _) h,\n  { have hr\u2081 : 0 < r^n := lt_of_le_of_lt zero_le' h,\n    have hr\u2082 : r^n \u2260 0 := hr\u2081.ne',\n    convert mul_lt_mul this (le_refl (r ^ n)\u207b\u00b9) _ hr\u2081.le,\n    { exact (mul_inv_cancel_right\u2080 hr\u2082 _).symm },\n    { exact (mul_inv_cancel hr\u2082).symm },\n    { rwa nnreal.inv_pos }, },\n  { refine le_trans _ hF,\n    apply @finset.single_le_sum S \u211d\u22650 _ (\u03bb s, \u2211' n, \u2225F s n\u2225\u208a * 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\u2080 : 0 < x) (hx\u2081 : x < 1) :\n  strict_anti (\u03bb n:\u2124, x ^ n) :=\nbegin\n  intros n m H,\n  rw [\u2190 inv_inv x],\n  simp only [inv_zpow x\u207b\u00b9, inv_lt_inv (zpow_pos_of_pos (inv_pos.mpr hx\u2080) _)\n    (zpow_pos_of_pos (inv_pos.mpr hx\u2080) _)],\n  exact zpow_strict_mono (one_lt_inv hx\u2080 hx\u2081) 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\u2080 : 0 < (r : \u211d)) (hr\u2081 : (r : \u211d) < 1) (F : \u2112 S) :\n  \u2203 d : \u2124, \u2200 s : S, \u2200 (n : \u2124), n < d \u2192 F s n = 0 :=\nbegin\n  have h_logr : (log r) < 0 := log_neg hr\u2080 hr\u2081,\n  let d := if log \u2225 F \u2225 \u2265 0 then \u230a (log \u2225 F \u2225 / log (r : \u211d)) \u230b - 1 else -1,\n  use d,\n  intros s n hn,\n  have H1 := zpow_strict_anti hr\u2080 hr\u2081 hn,\n  suffices H2 : \u2225F\u2225\u208a < r ^ d,\n  { refine eq_zero_of_filtration F (\u2225F\u2225\u208a) le_rfl s n (H2.trans _),\n    rw [\u2190 nnreal.coe_lt_coe, nnreal.coe_zpow, nnreal.coe_zpow],\n    exact zpow_strict_anti hr\u2080 hr\u2081 hn, },\n  have hd1 : 0 < -(d : \u211d),\n  { rw [lt_neg, neg_zero, \u2190 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 \u2225 F \u2225) < d * (log (r : \u211d)),\n  { rw \u2190 zsmul_eq_mul,\n    rw ite_smul,\n    split_ifs,\n    { rw zsmul_eq_mul,\n      calc (log \u2225F\u2225)\n          = (log \u2225F\u2225/log r) * log r : (div_mul_cancel (log \u2225F\u2225) (ne_of_lt h_logr)).symm\n      ... \u2264 \u230a (log \u2225F\u2225)/log r\u230b * log r : (mul_le_mul_right_of_neg h_logr).mpr (int.floor_le _)\n      ... < (\u230a (log \u2225F\u2225)/log r\u230b - 1) * log r : (mul_lt_mul_right_of_neg h_logr).mpr (sub_one_lt _)\n      ... = \u2191(\u230a (log \u2225F\u2225)/log r\u230b - 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 [\u2190 nnreal.coe_lt_coe, nnreal.coe_zpow, coe_nnnorm],\n  have := (real.lt_rpow_of_log_lt (laurent_measures.norm_nonneg F) hr\u2080 hFd1),\n  rwa [real.rpow_int_cast _ d] at this,\nend\n\ndef bdd_filtration {S : Fintype} (hr\u2080 : 0 < (r : \u211d)) (hr\u2081 : (r : \u211d) < 1) (F : \u2112 S) : \u2124 :=\n(exists_bdd_filtration hr\u2080 hr\u2081 F).some\n\ndef bdd_filtration_spec {S : Fintype} (hr\u2080 : 0 < (r : \u211d)) (hr\u2081 : (r : \u211d) < 1) (F : \u2112 S) :\n\u2200 s n, n < bdd_filtration hr\u2080 hr\u2081 F \u2192 F s n = 0 := (exists_bdd_filtration hr\u2080 hr\u2081 F).some_spec\n\nsection profinite_structure\n\n@[simps] def truncate {c : \u211d\u22650} (A : finset \u2124) :\n  { F : \u2112 S | \u2225F\u2225\u208a \u2264 c } \u2192 laurent_measures_bdd r S A c := \u03bb F,\n{ to_fun := \u03bb s i, F s i,\n  bound' := begin\n    refine (finset.sum_le_sum $ \u03bb s _, _).trans F.2,\n    convert sum_le_tsum A _ ((F : \u2112 S).nnreal_summable s) using 1,\n    { conv_rhs { rw \u2190 finset.sum_attach }, refl },\n    { intros b hb, exact zero_le', },\n  end }\n\nlemma eq_iff_truncate_eq (c : \u211d\u22650) (F G : {F : \u2112 S | \u2225F\u2225\u208a \u2264 c}) :\n  (\u2200 k, truncate k F = truncate k G) \u2192 F = G :=\nbegin\n  intros h,\n  ext s i,\n  specialize h {i},\n  apply_fun (\u03bb e, e s \u27e8i, by simp\u27e9) at h,\n  exact h,\nend\n\n\ndef finset_map {A B : finset \u2124} (h : B \u2264 A) : B \u2192 A :=\n\u03bb i, \u27e8i, h i.2\u27e9\n\ndef transition {c : \u211d\u22650} {A B : finset \u2124} (h : B \u2264 A) :\n  laurent_measures_bdd r S A c \u2192 laurent_measures_bdd r S B c := \u03bb F,\n\u27e8\u03bb s i, F s (finset_map h i), begin\n  refine (finset.sum_le_sum $ \u03bb s _, _).trans F.2,\n  have : \u2211 i : B, \u2225F s (finset_map h i)\u2225\u208a * r^(i : \u2124) =\n    \u2211 i in finset.univ.image (finset_map h), \u2225F s i\u2225\u208a * r^(i : \u2124),\n  { rw finset.sum_image,\n    { refl },\n    { rintros i - j - hh,\n      apply subtype.ext,\n      apply_fun (\u03bb e, e.val) at hh,\n      exact hh } },\n  rw this,\n  refine finset.sum_le_sum_of_subset_of_nonneg (finset.subset_univ _) (\u03bb _ _ _, zero_le'),\nend\u27e9\n\ndef mk_seq {c} (F : \u03a0 (A : finset \u2124), laurent_measures_bdd r S A c) :\n  S \u2192 \u2124 \u2192 \u2124 := \u03bb s i, F {i} s \u27e8i, by simp\u27e9\n\nlemma mk_seq_compat {c} (F : \u03a0 (A : finset \u2124), laurent_measures_bdd r S A c)\n  (compat : \u2200 (A B : finset \u2124) (h : B \u2264 A), transition h (F _) = F _) (s : S)\n  (A : finset \u2124) (i : A) : mk_seq F s i = F A s i :=\nbegin\n  have : ({i} : finset \u2124) \u2264 A, { simp },\n  specialize compat _ _ this,\n  dsimp [mk_seq],\n  rw \u2190 compat,\n  change (F A) s _ = _,\n  congr,\n  ext,\n  refl,\nend\n\nlemma mk_seq_compat_summable {c} (F : \u03a0 (A : finset \u2124), laurent_measures_bdd r S A c)\n  (compat : \u2200 (A B : finset \u2124) (h : B \u2264 A), transition h (F _) = F _) (s : S) :\n  summable (\u03bb k : \u2124, \u2225mk_seq F s k\u2225 * (r:\u211d)^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 \u2190 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 \u211d _ (\u03bb s, \u2211 (i : A), \u2225 F A s i \u2225 * (r : \u211d)^(i : \u2124)),\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 : \u03a0 (A : finset \u2124), laurent_measures_bdd r S A c)\n  (compat : \u2200 (A B : finset \u2124) (h : B \u2264 A), transition h (F _) = F _) (s : S) :\n  summable (\u03bb k : \u2124, \u2225mk_seq F s k\u2225\u208a * r^k) :=\nbegin\n  rw \u2190 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 : \u03a0 (A : finset \u2124), laurent_measures_bdd r S A c)\n  (compat : \u2200 (A B : finset \u2124) (h : B \u2264 A), transition h (F _) = F _)  :\n  \u2211 (s : S), \u2211' (k : \u2124), \u2225mk_seq F s k\u2225\u208a * r^k \u2264 c :=\nbegin\n  rw \u2190 tsum_sum,\n  swap, { intros s hs, apply mk_seq_compat_nnreal_summable _ compat },\n  have : \u2200 A : finset \u2124,\n    \u2211 (b : A), \u2211 (s : S), \u2225F A s b\u2225\u208a * r^(b : \u2124) \u2264 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 \u2190 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 : \u03a0 (A : finset \u2124), laurent_measures_bdd r S A c)\n  (compat : \u2200 (A B : finset \u2124) (h : B \u2264 A),\n    transition h (F _) = F _) :\n  \u2203 (G : {H : \u2112 S | \u2225H\u2225\u208a \u2264 c }), \u2200 (k : finset \u2124), truncate k G = F k :=\nbegin\n  let G : \u2112 S := \u27e8mk_seq F, mk_seq_compat_nnreal_summable _ compat\u27e9,\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 (\u03bb e, e s \u27e8i, by simp\u27e9) at this,\n    erw \u2190 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 \u2124` 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 : \u211d\u22650) [fact (0 < r)] :\n  (as_small (finset \u2124))\u1d52\u1d56 \u2964 Fintype :=\n{ obj := \u03bb A, Fintype.of $ laurent_measures_bdd r S (ulift.down A.unop) c,\n  map := \u03bb 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 \u2124` of the finite types `laurent_measures_bdd r S T c`. -/\ndef laurent_measures_bdd_equiv (c : \u211d\u22650) [fact (0 < r)] : { F : \u2112 S | \u2225F\u2225\u208a \u2264 c } \u2243\n  (Profinite.limit_cone (laurent_measures_bdd_functor r S c \u22d9 Fintype.to_Profinite)).X :=\nequiv.of_bijective (\u03bb F, \u27e8\u03bb A, truncate (ulift.down A.unop) F, \u03bb A B f, by { ext, refl }\u27e9)\nbegin\n  split,\n  { intros F G h,\n    apply eq_iff_truncate_eq,\n    intros k,\n    dsimp at h,\n    apply_fun (\u03bb e, e.1 (opposite.op \u27e8k\u27e9)) at h,\n    exact h },\n  { rintros \u27e8F, hF\u27e9,\n    dsimp at F hF,\n    obtain \u27e8G,hG\u27e9 := exists_of_compat (\u03bb A, F (opposite.op \u27e8A\u27e9)) _,\n    { use G,\n      ext : 2,\n      dsimp,\n      have := hG (ulift.down x.unop),\n      convert this,\n      rw \u2190 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) \u27f6 (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 : \u211d\u22650) [fact (0 < r)] : topological_space {F : \u2112 S | \u2225F\u2225\u208a \u2264 c} :=\ntopological_space.induced (laurent_measures_bdd_equiv r S c) infer_instance\n\ndef laurent_measures_bdd_homeo (c : \u211d\u22650) [fact (0 < r)] : { F : \u2112 S | \u2225F\u2225\u208a \u2264 c } \u2243\u209c\n  (Profinite.limit_cone (laurent_measures_bdd_functor r S c \u22d9 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) := \u27e8rfl\u27e9,\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 : \u211d\u22650) [fact (0 < r)] : t2_space { F : \u2112 S | \u2225F\u2225\u208a \u2264 c } :=\n(laurent_measures_bdd_homeo r S c).symm.t2_space\n\ninstance (c : \u211d\u22650) [fact (0 < r)] : totally_disconnected_space { F : \u2112 S | \u2225F\u2225\u208a \u2264 c } :=\n(laurent_measures_bdd_homeo r S c).symm.totally_disconnected_space\n\ninstance (c : \u211d\u22650) [fact (0 < r)] : compact_space {F : \u2112 S | \u2225F\u2225\u208a \u2264 c} :=\n(laurent_measures_bdd_homeo r S c).symm.compact_space\n\n@[continuity]\nlemma truncate_continuous (c : \u211d\u22650) [fact (0 < r)] (A : finset \u2124) :\n  continuous (truncate A : _ \u2192 laurent_measures_bdd r S _ c) :=\nbegin\n  let g\u2081 :=\n    (Profinite.limit_cone (laurent_measures_bdd_functor.{u} r S c \u22d9 Fintype.to_Profinite)).\u03c0.app\n    (opposite.op $ ulift.up A),\n  let g\u2082 := (laurent_measures_bdd_homeo r S c),\n  change continuous (g\u2081 \u2218 g\u2082),\n  continuity,\nend\n\nlemma continuous_iff (c : \u211d\u22650) [fact (0 < r)] {\u03b1 : Type*} [topological_space \u03b1]\n  (f : \u03b1 \u2192 { F : \u2112 S | \u2225F\u2225\u208a \u2264 c }) :\n  continuous f \u2194 \u2200 (A : finset \u2124), continuous ((truncate A) \u2218 f) :=\nbegin\n  split,\n  { intros hf A, continuity },\n  { intros h,\n    rw \u2190 (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 : \u211d\u22650) (c : \u211d\u22650) (S : Type*) (hS : fintype S) :\n  c_measures r c S hS \u2192 \u2112 S hS := \u03bb f, \u27e8f.to_fun, f.summable\u27e9\n\nlemma laurent_measures_are_c (r : \u211d\u22650) (S : Type*) (hS : fintype S) (F : \u2112 S hS) :\n  \u2203 (c : \u211d\u22650) (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 (\u2112 S) :=\n{ filtration := \u03bb c, { F | \u2225F\u2225\u208a \u2264 c },\n  filtration_mono := \u03bb c\u2081 c\u2082 h F hF, by {dsimp at *, exact le_trans hF h},\n  zero_mem_filtration := \u03bb c, by simp [nnnorm_def],\n  neg_mem_filtration := \u03bb c F h, (nnnorm_neg F).le.trans h,\n  add_mem_filtration := \u03bb c\u2081 c\u2082 F\u2081 F\u2082 h\u2081 h\u2082, (nnnorm_add _ _).trans (add_le_add h\u2081 h\u2082) }\n\n@[simp] lemma mem_filtration_iff (F : \u2112 S) (c : \u211d\u22650) :\n  F \u2208 pseudo_normed_group.filtration (\u2112 S) c \u2194 \u2225F\u2225\u208a \u2264 c := iff.rfl\n\ninstance [fact (0 < r)] : profinitely_filtered_pseudo_normed_group (\u2112 S) :=\n{ continuous_add' := begin\n    intros c\u2081 c\u2082,\n    rw continuous_iff,\n    intros A,\n    let E : laurent_measures_bdd r S A c\u2081 \u00d7 laurent_measures_bdd r S A c\u2082 \u2192\n      laurent_measures_bdd r S A (c\u2081 + c\u2082) := \u03bb G, \u27e8G.1 + G.2, _\u27e9,\n    swap, {\n      refine le_trans _ (add_le_add G.fst.2 G.snd.2),\n      rw \u2190 finset.sum_add_distrib,\n      apply finset.sum_le_sum,\n      intros i hi,\n      rw \u2190 finset.sum_add_distrib,\n      apply finset.sum_le_sum,\n      intros j hj,\n      rw \u2190 add_mul,\n      refine mul_le_mul' (norm_add_le _ _) le_rfl, },\n    have :\n      (truncate A : _ \u2192 laurent_measures_bdd r S A (c\u2081 + c\u2082)) \u2218 pseudo_normed_group.add' =\n      E \u2218 (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 \u2192 laurent_measures_bdd r S A c :=\n      \u03bb G, \u27e8- G, _\u27e9,\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 : _ \u2192 laurent_measures_bdd r S A c) \u2218 pseudo_normed_group.neg' =\n      E \u2218 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\u2081 c\u2082 h,\n    rw continuous_iff,\n    intros A,\n    let g : laurent_measures_bdd r S A c\u2081 \u2192 laurent_measures_bdd r S A c\u2082 :=\n      \u03bb g, \u27e8g, le_trans g.2 h.out\u27e9,\n    have : (truncate A : _ \u2192 laurent_measures_bdd r S A c\u2082) \u2218 pseudo_normed_group.cast_le =\n      g \u2218 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 (\u2112 S))) }\n.\n\n/-- The additive group homomorphism on Laurent measures induced by division by `T^k` on `\u2124((T))\u1d63` -/\n@[simps] def shift_add_monoid_hom [hr : fact (0 < r)] (k : \u2124) : \u2112 S \u2192+ \u2112 S :=\nadd_monoid_hom.mk' (\u03bb F,\n{ to_fun := \u03bb s n, F s (n+k),\n  summable' := \u03bb s, begin\n    convert (nnreal.summable_comp_injective\n      (F.nnreal_summable s) (add_left_injective (k:\u2124))).mul_right (r ^ -k),\n    ext n,\n    simp only [function.comp, \u2190 zpow_add\u2080 hr.out.ne', mul_assoc, add_neg_cancel_right],\n  end })\n(\u03bb F G, by { ext, refl })\n.\n\n-- move me\n@[simp, to_additive] lemma _root_.finset.prod_attach' {\u03b1 M : Type*} [comm_monoid M]\n  (s : finset \u03b1) (f : s \u2192 M) :\n  \u220f a in s.attach, f a = \u220f a in s, if h : a \u2208 s then f \u27e8a, h\u27e9 else 1 :=\nbegin\n  rw [eq_comm, \u2190 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 : \u2124) : comphaus_filtered_pseudo_normed_group_hom (\u2112 S) (\u2112 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 \u27e8H, _\u27e9,\n  { rw continuous_iff,\n    intro A,\n    let B : finset \u2124 := A.map (equiv.to_embedding (equiv.add_left (k:\u2124))),\n    let g : laurent_measures_bdd r S B c \u2192 laurent_measures_bdd r S A (r ^ -k * c) := \u03bb F,\n    { to_fun := \u03bb s a, F s \u27e8a+k, _\u27e9,\n      bound' := _, },\n    { suffices : truncate A \u2218 _ = g \u2218 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 (\u03bb 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 (\u03bb 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, \u2190 zpow_add\u2080 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 (\u03bb s _, le_of_eq _),\n    transitivity \u2211' n, \u2225F s n\u2225\u208a * r^n * (r ^ -k),\n    { refine ((equiv.add_left (-k:\u2124)).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\u2080 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 (\u2112 S) :=\n{ Tinv := shift 1,\n  Tinv_mem_filtration := \u03bb 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 (\u2112 S))}\n\n@[simp] lemma Tinv_apply [fact (0 < r)] (F : \u2112 S) :\n  comphaus_filtered_pseudo_normed_group_with_Tinv.Tinv F = shift 1 F := rfl\n\nvariable {\u03b1 : 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 \u27f6 S') :\n  comphaus_filtered_pseudo_normed_group_with_Tinv_hom r (\u2112 S) (\u2112 S') :=\n{ to_fun := map f,\n  map_zero' := by { ext, simp only [map_apply, zero_apply, finset.sum_const_zero], },\n  map_add' := \u03bb F G, by { ext s i, simp only [\u2190finset.sum_add_distrib, map_apply, add_apply], },\n  map_Tinv' := \u03bb F, by { ext s i, simp only [map_apply, Tinv_apply, shift_to_fun_to_fun] },\n  strict' := \u03bb c F (hF : \u2225F\u2225\u208a \u2264 c), (map_bound _ _).trans hF,\n  continuous' := \u03bb c, begin\n    rw continuous_iff,\n    intros T,\n    let f\u2080 : (filtration (laurent_measures r S) c) \u2192 (filtration (laurent_measures r S') c) :=\n      level (map f) (\u03bb c F (hF : \u2225F\u2225\u208a \u2264 c), (map_bound f F).trans hF) c,\n    have : truncate T \u2218 f\u2080 = laurent_measures_bdd.map f \u2218 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 : \u2112 S` be a Laurent measure.  `laurent_measures.d` chooses a bound `d \u2208 \u2124` 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 : \u2112 S) : \u2124 :=\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 : \u2112 S) (s : S) (n : \u2124) :\n  n < F.d \u2192 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 : \u2112 S) (s : S) (n : \u2124) :\n  n < F.d \u2192 (F s n : \u211d) = 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 \u211d :=\nbegin\n  sorry,\n\n--OUTPUT 2\ntheorem is_paracompact (n : \u2115) : paracompact_space (euclidean_space n) :=\nbegin\n  --Let \\mathcal{U} be an open cover of \\mathbb{R}^n\n  rintro \u27e8U, hU\u27e9,\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 \u27e8V, hV\u27e9,\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 \u2192 \u2115 := \u03bb x, nat.find (\u03bb n, x \u2208 V n),\n  --Since V is a cover, f is well-defined\n  have hf : \u2200 x, x \u2208 \u22c3 i, V i := \u03bb x, nat.find_spec (\u03bb n, x \u2208 V n),\n  --Define a function g : \\mathbb{N} \\to \\mathcal{V} by g(n) = V_n\n  let g : \u2115 \u2192 set (euclidean_space n) := \u03bb n, V n,\n  --Since V is a cover, g is well-defined\n  have hg : \u2200 n, g n \u2208 U := \u03bb n, hV n,\n  --Define a function h : \\mathbb{N} \\to \\mathcal{U} by h(n) = U_n\n  let h : \u2115 \u2192 set (euclidean_space n) := \u03bb n, U n,\n  --Since U is a cover, h is well-defined\n  have hh : \u2200 n, h n \u2208 U := \u03bb 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 : \u2115 \u2192 \u2115 := \u03bb n, nat.find (\u03bb m, V n \u2286 U m),\n  --Since V is a cover, k is well-defined\n  have hk : \u2200 n, V n \u2286 U (k n) := \u03bb n, nat.find_spec (\u03bb m, V n \u2286 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 : \u2115 \u2192 \u2115 := \u03bb n, nat.find (\u03bb m, U n \u2286 U m),\n  --Since U is a cover, l is well-defined\n  have hl : \u2200 n, U n \u2286 U (l n) := \u03bb n, nat.find_spec (\u03bb m, U n \u2286 U m),\n  --Define a function m : \\mathbb{N} \\to \\mathbb{N} by m(n) = \\min\\{k(n), l(n)\\}\n  let m : \u2115 \u2192 \u2115 := \u03bb 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 : \u2115 \u2192 set (euclidean_space n) := \u03bb n, U (m n),\n  --Since U is a cover, p is well-defined\n  have hp : \u2200 n, p n \u2208 U := \u03bb n, hU (m n),\n  --Define a function q : \\mathbb{N} \\to \\mathcal{V} by q(n) = V_{m(n)}\n  let q : \u2115 \u2192 set (euclidean_space n) := \u03bb n, V (m n),\n  --Since V is a cover, q is well-defined\n  have hq : \u2200 n, q n \u2208 U := \u03bb 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 : \u2115 \u2192 \u2115 := \u03bb n, nat.find (\u03bb m, V (m n) \u2286 U n),\n  --Since V is a cover, r is well-defined\n  have hr : \u2200 n, V (m n) \u2286 U (r n) := \u03bb n, nat.find_spec (\u03bb m, V (m n) \u2286 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 : \u2115 \u2192 \u2115 := \u03bb n, nat.find (\u03bb m, U (m n) \u2286 U n),\n  --Since U is a cover, s is well-defined\n  have hs : \u2200 n, U (m n) \u2286 U (s n) := \u03bb n, nat.find_spec (\u03bb m, U (m n) \u2286 U n),\n  --Define a function t : \\mathbb{N} \\to \\mathbb{N} by t(n) = \\min\\{r(n), s(n)\\}\n  let t : \u2115 \u2192 \u2115 := \u03bb 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 : \u2115 \u2192 set (euclidean_space n) := \u03bb n, U (t n),\n  --Since U is a cover, u is well-defined\n  have hu : \u2200 n, u n \u2208 U := \u03bb n, hU (t n),\n  --Define a function v : \\mathbb{N} \\to \\mathcal{V} by v(n) = V_{t(n)}\n  let v : \u2115 \u2192 set (euclidean_space n) := \u03bb n, V (t n),\n  --Since V is a cover, v is well-defined\n  have hv : \u2200 n, v n \u2208 U := \u03bb 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 : \u2115 \u2192 \u2115 := \u03bb n, nat.find (\u03bb m, V (t n) \u2286 U m),\n  --Since V is a cover, w is well-defined\n  have hw : \u2200 n, V (t n) \u2286 U (w n) := \u03bb n, nat.find_spec (\u03bb m, V (t n) \u2286 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 : \u2115 \u2192 \u2115 := \u03bb n, nat.find (\u03bb m, U (t n) \u2286 U m),\n  --Since U is a cover, x is well-defined\n  have hx : \u2200 n, U (t n) \u2286 U (x n) := \u03bb n, nat.find_spec (\u03bb m, U (t n) \u2286 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 : \u2115) : 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 : \u00ac A \u2227 \u00ac B) : \u00ac (A \u2228 B) :=\nbegin\n  intro,\n  cases \u1fb0,\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": "/-\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 data.int.gcd\nimport data.nat.prime\nimport algebra.squarefree\n\n/-!\n# Tests for `norm_num` extensions\n-/\n\n-- coverage tests\nexample : nat.coprime 1 2 := by norm_num\nexample : nat.coprime 2 1 := by norm_num\nexample : \u00ac nat.coprime 0 0 := by norm_num\nexample : \u00ac nat.coprime 0 3 := by norm_num\nexample : \u00ac nat.coprime 2 0 := by norm_num\nexample : nat.coprime 2 3 := by norm_num\nexample : \u00ac 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 : \u00ac nat.prime 0 := by norm_num\nexample : \u00ac nat.prime 1 := by norm_num\nexample : nat.prime 2 := by norm_num\nexample : nat.prime 3 := by norm_num\nexample : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac squarefree 0 := by norm_num\nexample : squarefree 1 := by norm_num\nexample : squarefree 2 := by norm_num\nexample : squarefree 3 := by norm_num\nexample : \u00ac squarefree 4 := by norm_num\nexample : squarefree 5 := by norm_num\nexample : squarefree 6 := by norm_num\nexample : squarefree 7 := by norm_num\nexample : \u00ac squarefree 8 := by norm_num\nexample : \u00ac squarefree 9 := by norm_num\nexample : squarefree 10 := by norm_num\nexample : squarefree (2*3*5*17) := by norm_num\nexample : \u00ac squarefree (2*3*5*5*17) := by norm_num\nexample : squarefree 251 := by norm_num\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/test/norm_num_ext.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7606506418255927, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.4873000741604557}}
{"text": "namespace hidden\nuniverses u v\n\ninductive list (\u03b1 : Type u)\n| nil {} : list\n| cons : \u03b1 \u2192 list \u2192 list\n\nnamespace list\nvariable {\u03b1 : Type}\n\nnotation h :: t := cons h t\n\ndef append (s t : list \u03b1) : list \u03b1 :=\nlist.rec t (\u03bb x l u, x::u) s\n\nnotation s ++ t := append s t\n\ntheorem nil_append (t : list \u03b1) : nil ++ t = t := rfl\ntheorem cons_append (x : \u03b1) (s t : list \u03b1) :\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 \u03b1) : t ++ nil = t :=\nlist.rec_on t\n    (show (@nil \u03b1) ++ 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 \u03b1) : (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 : \u03a0 {\u03b1 : Type u}, list \u03b1 \u2192 \u2115 :=\n\u03bb t l, list.rec_on l 0 (\u03bb h x n, n + 1)\n\ntheorem append_length (s t : list \u03b1) : 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 \u03b1) : list \u03b1 :=\nlist.rec_on s nil (\u03bb h l t, t ++ [h])\n\nexample (h : \u03b1) (s : list \u03b1) : reverse (h :: s) = (reverse s) ++ [h] :=\nrfl\n\nexample (t: list \u03b1) : 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 \u03b1,\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 \u03b1) : 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 \u03b1) : reverse (reverse t) = t :=\nlist.rec_on t\n    (show reverse (reverse nil) = nil, from rfl)\n    (\n        assume h,\n        assume l : list \u03b1,\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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+ `\u03c3 : Type*` (indexing the variables)\n\n+ `R : Type*` `[comm_semiring R]` (the coefficients)\n\n+ `s : \u03c3 \u2192\u2080 \u2115`, a function from `\u03c3` to `\u2115` which is zero away from a finite set.\nThis will give rise to a monomial in `mv_polynomial \u03c3 R` which mathematicians might call `X^s`\n\n+ `a : R`\n\n+ `i : \u03c3`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians\n\n+ `p : mv_polynomial \u03c3 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 \u2243+* R :=\n  ring_equiv.mk (eval\u2082 (ring_hom.id R) pempty.elim) \u21d1C 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] : \u2200 (\u1fb0 : R), coe_fn (alg_equiv.symm (pempty_alg_equiv R)) \u1fb0 = coe_fn C \u1fb0 :=\n  fun (\u1fb0 : R) => Eq.refl (coe_fn (alg_equiv.symm (pempty_alg_equiv R)) \u1fb0)\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\u2082 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\u2081 : Type v} {S\u2082 : Type w} [comm_semiring R] (e : S\u2081 \u2243 S\u2082) : \u2200 (\u1fb0 : mv_polynomial S\u2082 R), coe_fn (ring_equiv.symm (ring_equiv_of_equiv R e)) \u1fb0 = coe_fn (rename \u21d1(equiv.symm e)) \u1fb0 :=\n  fun (\u1fb0 : mv_polynomial S\u2082 R) => Eq.refl (coe_fn (ring_equiv.symm (ring_equiv_of_equiv R e)) \u1fb0)\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\u2081 : Type v} {S\u2082 : Type w} [comm_semiring R] (e : S\u2081 \u2243 S\u2082) : \u2200 (\u1fb0 : mv_polynomial S\u2082 R), coe_fn (alg_equiv.symm (alg_equiv_of_equiv R e)) \u1fb0 = coe_fn (rename \u21d1(equiv.symm e)) \u1fb0 :=\n  fun (\u1fb0 : mv_polynomial S\u2082 R) => Eq.refl (coe_fn (alg_equiv.symm (alg_equiv_of_equiv R e)) \u1fb0)\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\u2081 : Type v} {S\u2082 : Type w} [comm_semiring R] [comm_semiring S\u2082] (e : R \u2243+* S\u2082) : mv_polynomial S\u2081 R \u2243+* mv_polynomial S\u2081 S\u2082 :=\n  ring_equiv.mk \u21d1(map \u2191e) \u21d1(map \u2191(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\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] : mv_polynomial (S\u2081 \u2295 S\u2082) R \u2192+* mv_polynomial S\u2081 (mv_polynomial S\u2082 R) :=\n  eval\u2082_hom (ring_hom.comp C C) fun (bc : S\u2081 \u2295 S\u2082) => sum.rec_on bc X (\u21d1C \u2218 X)\n\nprotected instance is_semiring_hom_sum_to_iter (R : Type u) (S\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] : is_semiring_hom \u21d1(sum_to_iter R S\u2081 S\u2082) :=\n  eval\u2082.is_semiring_hom (ring_hom.comp C C) fun (n : S\u2081 \u2295 S\u2082) => (fun (bc : S\u2081 \u2295 S\u2082) => sum.rec_on bc X (\u21d1C \u2218 X)) n\n\n@[simp] theorem sum_to_iter_C (R : Type u) (S\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] (a : R) : coe_fn (sum_to_iter R S\u2081 S\u2082) (coe_fn C a) = coe_fn C (coe_fn C a) :=\n  eval\u2082_C (ring_hom.comp C C) (fun (n : S\u2081 \u2295 S\u2082) => (fun (bc : S\u2081 \u2295 S\u2082) => sum.rec_on bc X (\u21d1C \u2218 X)) n) a\n\n@[simp] theorem sum_to_iter_Xl (R : Type u) (S\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] (b : S\u2081) : coe_fn (sum_to_iter R S\u2081 S\u2082) (X (sum.inl b)) = X b :=\n  eval\u2082_X (ring_hom.comp C C) (fun (n : S\u2081 \u2295 S\u2082) => (fun (bc : S\u2081 \u2295 S\u2082) => sum.rec_on bc X (\u21d1C \u2218 X)) n) (sum.inl b)\n\n@[simp] theorem sum_to_iter_Xr (R : Type u) (S\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] (c : S\u2082) : coe_fn (sum_to_iter R S\u2081 S\u2082) (X (sum.inr c)) = coe_fn C (X c) :=\n  eval\u2082_X (ring_hom.comp C C) (fun (n : S\u2081 \u2295 S\u2082) => (fun (bc : S\u2081 \u2295 S\u2082) => sum.rec_on bc X (\u21d1C \u2218 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\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] : mv_polynomial S\u2081 (mv_polynomial S\u2082 R) \u2192+* mv_polynomial (S\u2081 \u2295 S\u2082) R :=\n  eval\u2082_hom (ring_hom.of (eval\u2082 C (X \u2218 sum.inr))) (X \u2218 sum.inl)\n\ntheorem iter_to_sum_C_C (R : Type u) (S\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] (a : R) : coe_fn (iter_to_sum R S\u2081 S\u2082) (coe_fn C (coe_fn C a)) = coe_fn C a :=\n  Eq.trans (eval\u2082_C (ring_hom.of (eval\u2082 C (X \u2218 sum.inr))) (fun (n : S\u2081) => function.comp X sum.inl n) (coe_fn C a))\n    (eval\u2082_C C (fun (n : S\u2082) => function.comp X sum.inr n) a)\n\ntheorem iter_to_sum_X (R : Type u) (S\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] (b : S\u2081) : coe_fn (iter_to_sum R S\u2081 S\u2082) (X b) = X (sum.inl b) :=\n  eval\u2082_X (ring_hom.of (eval\u2082 C (X \u2218 sum.inr))) (fun (n : S\u2081) => function.comp X sum.inl n) b\n\ntheorem iter_to_sum_C_X (R : Type u) (S\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] (c : S\u2082) : coe_fn (iter_to_sum R S\u2081 S\u2082) (coe_fn C (X c)) = X (sum.inr c) :=\n  Eq.trans (eval\u2082_C (ring_hom.of (eval\u2082 C (X \u2218 sum.inr))) (fun (n : S\u2081) => function.comp X sum.inl n) (X c))\n    (eval\u2082_X C (fun (n : S\u2082) => 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\u2081 : Type v) (S\u2082 : Type w) (S\u2083 : Type x) [comm_semiring R] [comm_semiring S\u2083] (f : mv_polynomial S\u2081 R \u2192+* mv_polynomial S\u2082 S\u2083) (g : mv_polynomial S\u2082 S\u2083 \u2192+* mv_polynomial S\u2081 R) (hfgC : \u2200 (a : S\u2083), coe_fn f (coe_fn g (coe_fn C a)) = coe_fn C a) (hfgX : \u2200 (n : S\u2082), coe_fn f (coe_fn g (X n)) = X n) (hgfC : \u2200 (a : R), coe_fn g (coe_fn f (coe_fn C a)) = coe_fn C a) (hgfX : \u2200 (n : S\u2081), coe_fn g (coe_fn f (X n)) = X n) : \u2200 (\u1fb0 : mv_polynomial S\u2081 R), coe_fn (mv_polynomial_equiv_mv_polynomial R S\u2081 S\u2082 S\u2083 f g hfgC hfgX hgfC hgfX) \u1fb0 = coe_fn f \u1fb0 :=\n  fun (\u1fb0 : mv_polynomial S\u2081 R) =>\n    Eq.refl (coe_fn (mv_polynomial_equiv_mv_polynomial R S\u2081 S\u2082 S\u2083 f g hfgC hfgX hgfC hgfX) \u1fb0)\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\u2081 : Type v) (S\u2082 : Type w) [comm_semiring R] : mv_polynomial (S\u2081 \u2295 S\u2082) R \u2243+* mv_polynomial S\u2081 (mv_polynomial S\u2082 R) :=\n  mv_polynomial_equiv_mv_polynomial R (S\u2081 \u2295 S\u2082) S\u2081 (mv_polynomial S\u2082 R) (sum_to_iter R S\u2081 S\u2082) (iter_to_sum R S\u2081 S\u2082) sorry\n    sorry sorry sorry\n\n/--\nThe ring isomorphism between multivariable polynomials in `option S\u2081` and\npolynomials with coefficients in `mv_polynomial S\u2081 R`.\n-/\ndef option_equiv_left (R : Type u) (S\u2081 : Type v) [comm_semiring R] : mv_polynomial (Option S\u2081) R \u2243+* polynomial (mv_polynomial S\u2081 R) :=\n  ring_equiv.trans (ring_equiv_of_equiv R (equiv.trans (equiv.option_equiv_sum_punit S\u2081) (equiv.sum_comm S\u2081 PUnit)))\n    (ring_equiv.trans (sum_ring_equiv R PUnit S\u2081) (punit_ring_equiv (mv_polynomial S\u2081 R)))\n\n/--\nThe ring isomorphism between multivariable polynomials in `option S\u2081` and\nmultivariable polynomials with coefficients in polynomials.\n-/\ndef option_equiv_right (R : Type u) (S\u2081 : Type v) [comm_semiring R] : mv_polynomial (Option S\u2081) R \u2243+* mv_polynomial S\u2081 (polynomial R) :=\n  ring_equiv.trans (ring_equiv_of_equiv R (equiv.option_equiv_sum_punit S\u2081))\n    (ring_equiv.trans (sum_ring_equiv R S\u2081 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 : \u2115) : mv_polynomial (fin (n + 1)) R \u2243+* 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 : \u2115) : \u2191(fin_succ_equiv R n) =\n  eval\u2082_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 : \u2115) (p : mv_polynomial (fin (n + 1)) R) : coe_fn (fin_succ_equiv R n) p =\n  coe_fn\n    (eval\u2082_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 : \u2115) : 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 \u2115) := nat.nth (\u03bb n, n \u2209 X)\nnoncomputable def cup_mul (X Y : finset \u2115) := X \u222a image (nth_notin X) Y\nnoncomputable def cup_pow (X : finset \u2115) (k : \u2115) := nat.iterate (\u03bb Y, cup_mul X Y) k \u2205\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 : \u2115 \u2192 \u2115} (hf : strict_mono f) (hg : strict_mono g)\n  (h : \u2203 N : \u2115, \u2200 n : \u2115, N \u2264 n \u2192 f n = g n) (h0 : f \u2218 g = g \u2218 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 (\u03bb k h1 n h2, _) N.zero_le h,\n  rw [le_iff_lt_or_eq, \u2190 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 [\u2190 h3, \u2190 h4],\n  { replace h1 := h1 (g k) h4,\n    rw [\u2190 comp_app f, h0, comp_app] at h1,\n    exact hg.injective h1 },\n  { replace h1 := h1 (f k) h3,\n    rw [\u2190 comp_app g, \u2190 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 (\u03bb _, 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 (\u03bb _, true) = id :=\nbegin\n  ext n; have h := nat.nth_count (\u03bb _, true) (trivial : (\u03bb _, true) n),\n  rwa count_true at h\nend\n\nvariables {p q : \u2115 \u2192 Prop} [decidable_pred p] [decidable_pred q]\n\nprivate lemma count_prop_inj (h : \u2200 n : \u2115, nat.count p n = nat.count q n) : p = q :=\n  by ext n; rw [\u2190 @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 \u2194 p = q :=\nbegin\n  symmetry; split,\n  intros h; rw h,\n  intros h; refine count_prop_inj (\u03bb n, _),\n  exact galois_connection.l_unique (nat.count_nth_gc _ hp) (nat.count_nth_gc _ hq) (\u03bb b, by rw h)\nend\n\nend prop_lemmas\n\n\n\nsection finset_lemmas\n\nvariables (X Y : finset \u2115)\n\nprivate lemma nat_finset_infinite_compl : {n : \u2115 | n \u2209 X}.infinite :=\nbegin\n  have h := set.finite.infinite_compl ((X : set \u2115).to_finite),\n  rwa set.compl_def at h\nend\n\nprivate lemma range_nth_notin_eq_compl : set.range (nth_notin X) = X\u1d9c :=\nbegin\n  ext n; rw [set.mem_range, set.mem_compl_iff, mem_coe],\n  refine \u27e8_, (\u03bb h, \u27e8nat.count (\u03bb n, n \u2209 X) n, _\u27e9)\u27e9,\n  rintros \u27e8y, rfl\u27e9,\n  exact nat.nth_mem_of_infinite (\u03bb n, n \u2209 X) (nat_finset_infinite_compl X) y,\n  exact nat.nth_count (\u03bb (n : \u2115), n \u2209 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 \u2194 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 [\u2190 not_iff_not, \u2190 mem_coe, set.not_not_mem, \u2190 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 \u2205 = id :=\n  by simp [nth_notin, nth_true]\n\nprivate lemma count_notin_large {n : \u2115} (h : X.sup id < n) :\n  nat.count (\u03bb x, x \u2209 X) (n + X.card) = n :=\nbegin\n  have h0 := congr_arg card (filter_union_filter_neg_eq (\u03bb x, x \u2208 X) (range (n + X.card))),\n  rw [card_range, card_union_eq, \u2190 nat.count_eq_card_filter_range,\n      \u2190 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 [\u2190 add_left_inj X.card, add_comm]; convert h0 using 2; clear h0,\n  suffices : \u2200 k : \u2115, k \u2208 X \u2194 (k < n + X.card \u2227 k \u2208 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 : \u2115} (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 [\u2190 nat.count_le_iff_le_nth _ h0, count_notin_large X h],\n  rw [\u2190 nat.succ_le_iff, \u2190 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, \u2190 ne.def, ite_ne_right_iff, and_comm],\n  refine \u27e8one_ne_zero, \u03bb h1, _\u27e9,\n  replace h1 : id (n + X.card) \u2264 X.sup id := le_sup h1,\n  rw [id.def, \u2190 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 \u2115) : X ** \u2205 = X :=\n  by rw [cup_mul, image_empty, union_empty]\n  \nlemma empty_cup_mul (X : finset \u2115) : \u2205 ** X = X :=\n  by rw [cup_mul, empty_union, nth_notin_empty, image_id]\n\n/-- For any `X Y : finset \u2115`, `|X ** Y| = |X| + |Y|`. -/\nlemma cup_mul_card (X Y : finset \u2115) : (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 \u2190 mem_coe at h1,\n  replace h1 : a \u2208 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 \u2218 f_Y` -/\nlemma cup_mul_range (X Y : finset \u2115) : nth_notin (X ** Y) = nth_notin X \u2218 nth_notin Y :=\nbegin\n  rw \u2190 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, \u2190 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 \u2115) : X ** Y ** Z = X ** (Y ** Z) :=\n  by rw \u2190 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 \u2115} (h : X.card = Y.card) (h0 : X ** Y = Y ** X) : X = Y :=\nbegin\n  rw \u2190 nth_notin_inj at h0 \u22a2,\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 \u2115) : X ^^ 0 = \u2205 := rfl\n\nlemma cup_pow_succ (X : finset \u2115) (k : \u2115) : X ^^ k.succ = X ** X ^^ k :=\n  by rw [cup_pow, cup_pow, iterate_succ', comp_app]\n\n/- For any `X : finset \u2115` and `k : \u2115`, `|X^^k| = k |X|`. -/\nlemma cup_pow_card (X : finset \u2115) (k : \u2115) : (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 \u2115} (h : X ** Y = Y ** X) (k : \u2115) :\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, \u2190 cup_mul_assoc, \u2190 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 \u2115} (h : X ** Y = Y ** X) (k m : \u2115) :\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 \u2115) (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 (\u03c4 : Type u)\n| _1 : \u03c4 \u2192 Digit \u03c4\n| _2 : \u03c4 \u2192 \u03c4 \u2192 Digit \u03c4\n| _3 : \u03c4 \u2192 \u03c4 \u2192 \u03c4 \u2192 Digit \u03c4\n\nnamespace Digit\n\n@[inline]\ndef tryAddLeft (d : Digit \u03c4) (a : \u03c4) (sc : Digit \u03c4 \u2192 \u03b1) (fc : \u03c4 \u2192 \u03c4 \u2192 \u03c4 \u2192 \u03b1) : \u03b1 :=\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 \u03c4) (sc : \u03c4 \u2192 Digit \u03c4 \u2192 \u03b1) (fc : \u03c4 \u2192 \u03b1) : \u03b1 :=\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 \u03c4) (z : \u03c4) (sc : Digit \u03c4 \u2192 \u03b1) (fc : \u03c4 \u2192 \u03c4 \u2192 \u03c4 \u2192 \u03b1) : \u03b1 :=\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 \u03c4) (sc : \u03c4 \u2192 Digit \u03c4 \u2192 \u03b1) (fc : \u03c4 \u2192 \u03b1) : \u03b1 :=\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 \u03c4 \u2192 List \u03c4\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 (\u03c4 : Type u)\n| _2 : \u03c4 \u2192 \u03c4 \u2192 Node \u03c4 \n| _3 : \u03c4 \u2192 \u03c4 \u2192 \u03c4 \u2192 Node \u03c4\n\nnamespace Node\n\ndef toDigit : Node \u03c4 \u2192 Digit \u03c4\n| _2 a b => Digit._2 a b\n| _3 a b c => Digit._3 a b c\n\ndef toList : Node \u03c4 \u2192 List \u03c4\n| _2 a b     => [a,b]\n| _3 a b c   => [a,b,c]\n\ntheorem toList_toDigit {n : Node \u03c4}\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 (\u03c4 : Type u) : Nat \u2192 Type u\n| 0 => \u03c4\n| (n+1) => Node (NodeTree \u03c4 n)\n\nend FingerTree\n\nopen FingerTree\n\ninductive FingerTree (\u03c4 : Type u) : (n : Nat) \u2192 Type u\n| Empty : FingerTree \u03c4 n\n| Single : NodeTree \u03c4 n \u2192 FingerTree \u03c4 n\n| Deep : Digit (NodeTree \u03c4 n) \u2192 FingerTree \u03c4 (n+1) \u2192 Digit (NodeTree \u03c4 n) \u2192 FingerTree \u03c4 n\n\nnamespace FingerTree\n\ndef empty : FingerTree \u03c4 0 := Empty\n\ndef toList : FingerTree \u03c4 n \u2192 List (NodeTree \u03c4 n)\n| Empty => []\n| Single x => [x]\n| Deep pr tr sf =>\n  pr.toList ++\n  (tr.toList.bind Node.toList : List (NodeTree \u03c4 n)) ++\n  sf.toList\n\n@[inline]\ndef cons (f : FingerTree \u03c4 n) (a : NodeTree \u03c4 n) : FingerTree \u03c4 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      (\u03bb pr' => Deep pr' tr sf)\n      (\u03bb b c d => Deep (Digit._2 a b) (tr.cons (Node._2 c d)) sf)\n\n@[inline]\ndef front? (f : FingerTree \u03c4 n) : Option (NodeTree \u03c4 n \u00d7 FingerTree \u03c4 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      (\u03bb a pr' => (a, Deep pr' tr sf))\n      (\u03bb 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            (\u03bb b sf' => Deep (Digit._1 b) Empty sf')\n            (\u03bb b => /- sf = Digit1 b -/\n              Single b))))\n\n@[simp]\ntheorem toList_cons (f : FingerTree \u03c4 n) (a : NodeTree \u03c4 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 \u03c4 n)\n  : f.front?.map (\u03bb (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 \u03c4 n) (z : NodeTree \u03c4 n) : FingerTree \u03c4 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      (\u03bb sf' => Deep pr tr sf')\n      (\u03bb a b c => Deep pr (tr.snoc (Node._3 a b c)) (Digit._1 z))\n\ndef back? (f : FingerTree \u03c4 n) : Option (FingerTree \u03c4 n \u00d7 NodeTree \u03c4 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      (\u03bb z sf' => (Deep pr tr sf', z))\n      (\u03bb 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            (\u03bb y pr' => Deep pr' Empty (Digit._1 y))\n            (\u03bb y => /- pr = Digit1 y -/\n              Single y),\n        z)))\n\n@[simp]\ntheorem toList_snoc (f : FingerTree \u03c4 n) (a : NodeTree \u03c4 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 \u03c4 n)\n  : f.back?.map (\u03bb (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, \u2190List.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, \u2190List.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 [\u2190List.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 [\u2190List.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 \u03c4 (n+1)}\n  : List.length (toList tr) \u2264 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 \u2264 List.length (Node.toList l) by\n    have := Nat.add_le_add this ih\n    rw [\u2190Nat.add_one, Nat.add_comm]\n    exact this\n  simp [Node.toList]; split <;> simp\n\ndef append (f1 f2 : FingerTree \u03c4 n) : FingerTree \u03c4 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) \u2264 List.length (List.bind (toList tr1) Node.toList)\n      := length_toList_deep\n    have : List.length (toList tr2) \u2264 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 {\u03b1} : Enumerable (FingerTree \u03b1 0) \u03b1 where\n  \u03c1 := FingerTree \u03b1 0\n  fromEnumerator := id\n  insert := \u03bb\n    | none => empty\n    | some (x,ft) => ft.cons x\n\ninstance {\u03b1} : Iterable (FingerTree \u03b1 0) \u03b1 where\n  \u03c1 := FingerTree \u03b1 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 \u2964 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 \u2964 D) :=\n{ hom_group := \u03bb F G,\n  { add := \u03bb \u03b1 \u03b2,\n    { app := \u03bb X, \u03b1.app X + \u03b2.app X,\n      naturality' := by { intros, rw [comp_add, add_comp, \u03b1.naturality, \u03b2.naturality] } },\n    zero := { app := \u03bb X, 0, naturality' := by { intros, rw [zero_comp, comp_zero] } },\n    neg := \u03bb \u03b1,\n    { app := \u03bb X, -\u03b1.app X,\n      naturality' := by { intros, rw [comp_neg, neg_comp, \u03b1.naturality] } },\n    sub := \u03bb \u03b1 \u03b2,\n    { app := \u03bb X, \u03b1.app X - \u03b2.app X,\n      naturality' := by { intros, rw [comp_sub, sub_comp, \u03b1.naturality, \u03b2.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 \u2964 D}\n\n/-- Application of a natural transformation at a fixed object,\nas group homomorphism -/\n@[simps] def app_hom (X : C) : (F \u27f6 G) \u2192+ (F.obj X \u27f6 G.obj X) :=\n{ to_fun := \u03bb \u03b1, \u03b1.app X,\n  map_zero' := rfl,\n  map_add' := \u03bb _ _, rfl }\n\n@[simp] lemma app_zero (X : C) : (0 : F \u27f6 G).app X = 0 := rfl\n\n@[simp] \n\n@[simp] lemma app_sub (X : C) (\u03b1 \u03b2 : F \u27f6 G) : (\u03b1 - \u03b2).app X = \u03b1.app X - \u03b2.app X := rfl\n\n@[simp] lemma app_neg (X : C) (\u03b1 : F \u27f6 G) : (-\u03b1).app X = -\u03b1.app X := rfl\n\n@[simp] lemma app_nsmul (X : C) (\u03b1 : F \u27f6 G) (n : \u2115) : (n \u2022 \u03b1).app X = n \u2022 \u03b1.app X :=\n(app_hom X).map_nsmul \u03b1 n\n\n@[simp] lemma app_zsmul (X : C) (\u03b1 : F \u27f6 G) (n : \u2124) : (n \u2022 \u03b1).app X = n \u2022 \u03b1.app X :=\n(app_hom X : (F \u27f6 G) \u2192+ (F.obj X \u27f6 G.obj X)).map_zsmul \u03b1 n\n\n@[simp] lemma app_sum {\u03b9 : Type*} (s : finset \u03b9) (X : C) (\u03b1 : \u03b9 \u2192 (F \u27f6 G)) :\n  (\u2211 i in s, \u03b1 i).app X = \u2211 i in s, ((\u03b1 i).app X) :=\nby { rw [\u2190 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 := \u27e8 pos N.zero \u27e9 \ntheorem zero_eq_zero : pos N.zero = 0 := rfl\n\ndef one : Z := pos (N.succ 0)\n\ninstance : has_one Z := \u27e8 Z.one \u27e9 \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 \u2260 neg_succ b :=\nbegin\n  intro h,\n  cases h,\nend\n\nlemma neg_neq_pos (a b : N) : neg_succ a \u2260 pos b :=\nbegin\n  intro h,\n  cases h,\nend\n\ntheorem int1_to_nat (q : Prop) : (\u2200 (a: Z), q) -> (\u2200 (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) : (\u2200 (a b: Z), q) -> (\u2200 (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 {\u03b1 : Type*}\n\ndef is_prefix (l\u2081 : list \u03b1) (l\u2082 : list \u03b1) : Prop :=\n\u2203 t, l\u2081 ++ t = l\u2082\n\ninfix ` <+: `:50 := is_prefix\n\n@[simp, refl]\ntheorem list.is_prefix_refl (l : list \u03b1) : l <+: l :=\n\u27e8[], by simp\u27e9\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) 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\nimport Mathlib.Lean3Lib.data.rbtree.basic\n\nuniverses u \n\nnamespace Mathlib\n\nnamespace rbnode\n\n\ntheorem mem_of_min_eq {\u03b1 : Type u} (lt : \u03b1 \u2192 \u03b1 \u2192 Prop) [is_irrefl \u03b1 lt] {a : \u03b1} {t : rbnode \u03b1} :\n    rbnode.min t = some a \u2192 mem lt a t :=\n  sorry\n\ntheorem mem_of_max_eq {\u03b1 : Type u} (lt : \u03b1 \u2192 \u03b1 \u2192 Prop) [is_irrefl \u03b1 lt] {a : \u03b1} {t : rbnode \u03b1} :\n    rbnode.max t = some a \u2192 mem lt a t :=\n  sorry\n\ntheorem eq_leaf_of_min_eq_none {\u03b1 : Type u} {t : rbnode \u03b1} : rbnode.min t = none \u2192 t = leaf := sorry\n\ntheorem eq_leaf_of_max_eq_none {\u03b1 : Type u} {t : rbnode \u03b1} : rbnode.max t = none \u2192 t = leaf := sorry\n\ntheorem min_is_minimal {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt]\n    [is_strict_weak_order \u03b1 lt] {a : \u03b1} {t : rbnode \u03b1} {lo : Option \u03b1} {hi : Option \u03b1} :\n    is_searchable lt t lo hi \u2192\n        rbnode.min t = some a \u2192 \u2200 {b : \u03b1}, mem lt b t \u2192 strict_weak_order.equiv a b \u2228 lt a b :=\n  sorry\n\ntheorem max_is_maximal {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt]\n    [is_strict_weak_order \u03b1 lt] {a : \u03b1} {t : rbnode \u03b1} {lo : Option \u03b1} {hi : Option \u03b1} :\n    is_searchable lt t lo hi \u2192\n        rbnode.max t = some a \u2192 \u2200 {b : \u03b1}, mem lt b t \u2192 strict_weak_order.equiv a b \u2228 lt b 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/Lean3Lib/data/rbtree/min_max_auto.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) 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 \u2964 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\u1d52\u1d56 \u2964 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) := \u27e8infer_instance\u27e9\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) := \u27e8infer_instance\u27e9\n\nvariables {C} (X : simplicial_object C)\n\n/-- Face maps for a simplicial object. -/\ndef \u03b4 {n} (i : fin (n+2)) : X _[n+1] \u27f6 X _[n] :=\nX.map (simplex_category.\u03b4 i).op\n\n/-- Degeneracy maps for a simplicial object. -/\ndef \u03c3 {n} (i : fin (n+1)) : X _[n] \u27f6 X _[n+1] :=\nX.map (simplex_category.\u03c3 i).op\n\n\n/-- Isomorphisms from identities in \u2115. -/\ndef eq_to_iso {n m : \u2115} (h : n = m) : X _[n] \u2245 X _[m] :=\nX.map_iso (eq_to_iso (by rw h))\n\n@[simp] lemma eq_to_iso_refl {n : \u2115} (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 \u03b4_comp_\u03b4 {n} {i j : fin (n+2)} (H : i \u2264 j) :\n  X.\u03b4 j.succ \u226b X.\u03b4 i = X.\u03b4 i.cast_succ \u226b X.\u03b4 j :=\nby { dsimp [\u03b4], simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03b4 H] }\n\n@[reassoc]\nlemma \u03b4_comp_\u03b4' {n} {i : fin (n+2)} {j : fin (n+3)} (H : i.cast_succ < j) :\n  X.\u03b4 j \u226b X.\u03b4 i = X.\u03b4 i.cast_succ \u226b\n    X.\u03b4 (j.pred (\u03bb hj, by simpa only [hj, fin.not_lt_zero] using H)) :=\nby { dsimp [\u03b4], simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03b4' H] }\n\n@[reassoc]\n\n\n/-- The special case of the first simplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03b4_self {n} {i : fin (n+2)} : X.\u03b4 i.cast_succ \u226b X.\u03b4 i = X.\u03b4 i.succ \u226b X.\u03b4 i :=\nby { dsimp [\u03b4], simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03b4_self] }\n\n@[reassoc]\nlemma \u03b4_comp_\u03b4_self' {n} {j : fin (n+3)} {i : fin (n+2)} (H : j = i.cast_succ) :\n  X.\u03b4 j \u226b X.\u03b4 i = X.\u03b4 i.succ \u226b X.\u03b4 i :=\nby { subst H, rw \u03b4_comp_\u03b4_self, }\n\n/-- The second simplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03c3_of_le {n} {i : fin (n+2)} {j : fin (n+1)} (H : i \u2264 j.cast_succ) :\n  X.\u03c3 j.succ \u226b X.\u03b4 i.cast_succ = X.\u03b4 i \u226b X.\u03c3 j :=\nby { dsimp [\u03b4, \u03c3], simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03c3_of_le H] }\n\n/-- The first part of the third simplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03c3_self {n} {i : fin (n+1)} :\n  X.\u03c3 i \u226b X.\u03b4 i.cast_succ = \ud835\udfd9 _ :=\nbegin\n  dsimp [\u03b4, \u03c3],\n  simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03c3_self, op_id, X.map_id],\nend\n\n@[reassoc]\nlemma \u03b4_comp_\u03c3_self' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.cast_succ):\n  X.\u03c3 i \u226b X.\u03b4 j = \ud835\udfd9 _ := by { subst H, rw \u03b4_comp_\u03c3_self, }\n\n/-- The second part of the third simplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03c3_succ {n} {i : fin (n+1)} :\n  X.\u03c3 i \u226b X.\u03b4 i.succ = \ud835\udfd9 _ :=\nbegin\n  dsimp [\u03b4, \u03c3],\n  simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03c3_succ, op_id, X.map_id],\nend\n\n@[reassoc]\nlemma \u03b4_comp_\u03c3_succ' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.succ) :\n  X.\u03c3 i \u226b X.\u03b4 j = \ud835\udfd9 _ := by { subst H, rw \u03b4_comp_\u03c3_succ, }\n\n/-- The fourth simplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03c3_of_gt {n} {i : fin (n+2)} {j : fin (n+1)} (H : j.cast_succ < i) :\n  X.\u03c3 j.cast_succ \u226b X.\u03b4 i.succ = X.\u03b4 i \u226b X.\u03c3 j :=\nby { dsimp [\u03b4, \u03c3], simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03c3_of_gt H] }\n\n@[reassoc]\nlemma \u03b4_comp_\u03c3_of_gt' {n} {i : fin (n+3)} {j : fin (n+2)} (H : j.succ < i) :\n  X.\u03c3 j \u226b X.\u03b4 i = X.\u03b4 (i.pred (\u03bb hi, by simpa only [fin.not_lt_zero, hi] using H)) \u226b\n    X.\u03c3 (j.cast_lt ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le\n      (by simpa only [fin.val_eq_coe, \u2190 fin.coe_succ]\n        using fin.lt_iff_coe_lt_coe.mp H) i.is_le))) :=\nby { dsimp [\u03b4, \u03c3], simpa only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03c3_of_gt' H], }\n\n/-- The fifth simplicial identity -/\n@[reassoc]\nlemma \u03c3_comp_\u03c3 {n} {i j : fin (n+1)} (H : i \u2264 j) :\n  X.\u03c3 j \u226b X.\u03c3 i.cast_succ = X.\u03c3 i \u226b X.\u03c3 j.succ :=\nby { dsimp [\u03b4, \u03c3], simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03c3_comp_\u03c3 H] }\n\nopen_locale simplicial\n\n@[simp, reassoc]\nlemma \u03b4_naturality {X' X : simplicial_object C} (f : X \u27f6 X') {n : \u2115} (i : fin (n+2)) :\n  X.\u03b4 i \u226b f.app (op [n]) = f.app (op [n+1]) \u226b X'.\u03b4 i := f.naturality _\n\n@[simp, reassoc]\nlemma \u03c3_naturality {X' X : simplicial_object C} (f : X \u27f6 X') {n : \u2115} (i : fin (n+1)) :\n  X.\u03c3 i \u226b f.app (op [n+1]) = f.app (op [n]) \u226b X'.\u03c3 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 \u2964 D) \u2964 simplicial_object C \u2964 simplicial_object D :=\nwhiskering_right _ _ _\n\n/-- Truncated simplicial objects. -/\n@[derive category, nolint has_nonempty_instance]\ndef truncated (n : \u2115) := (simplex_category.truncated n)\u1d52\u1d56 \u2964 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) := \u27e8infer_instance\u27e9\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) := \u27e8infer_instance\u27e9\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 \u2964 D) \u2964 truncated C n \u2964 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 : \u2115) : simplicial_object C \u2964 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 \u2964 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 (\ud835\udfed (simplicial_object C)) (const C)\n\nvariable {C}\n\nnamespace augmented\n\n/-- Drop the augmentation. -/\n@[simps]\ndef drop : augmented C \u2964 simplicial_object C := comma.fst _ _\n\n/-- The point of the augmentation. -/\n@[simps]\ndef point : augmented C \u2964 C := comma.snd _ _\n\n/-- The functor from augmented objects to arrows. -/\n@[simps]\ndef to_arrow : augmented C \u2964 arrow C :=\n{ obj := \u03bb X,\n  { left := (drop.obj X) _[0],\n    right := (point.obj X),\n    hom := X.hom.app _ },\n  map := \u03bb X Y \u03b7,\n  { left := (drop.map \u03b7).app _,\n    right := (point.map \u03b7),\n    w' := begin\n      dsimp,\n      rw \u2190 nat_trans.comp_app,\n      erw \u03b7.w,\n      refl,\n    end } }\n\n/-- The compatibility of a morphism with the augmentation, on 0-simplices -/\n@[reassoc]\nlemma w\u2080 {X Y : augmented C} (f : X \u27f6 Y) :\n  (augmented.drop.map f).app (op (simplex_category.mk 0)) \u226b\n    Y.hom.app (op (simplex_category.mk 0)) =\n  X.hom.app (op (simplex_category.mk 0)) \u226b 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 \u2964 D) :\n  augmented C \u2964 augmented D :=\n{ obj := \u03bb X,\n  { left := ((whiskering _ _).obj F).obj (drop.obj X),\n    right := F.obj (point.obj X),\n    hom := whisker_right X.hom F \u226b (functor.const_comp _ _ _).hom },\n  map := \u03bb X Y \u03b7,\n  { left := whisker_right \u03b7.left _,\n    right := F.map \u03b7.right,\n    w' := begin\n      ext,\n      dsimp,\n      rw [category.comp_id, category.comp_id, \u2190 F.map_comp, \u2190 F.map_comp, \u2190 nat_trans.comp_app],\n      erw \u03b7.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 \u2964 D) \u2964 augmented C \u2964 augmented D :=\n{ obj := whiskering_obj _ _,\n  map := \u03bb X Y \u03b7,\n  { app := \u03bb A,\n    { left := whisker_left _ \u03b7,\n      right := \u03b7.app _,\n      w' := begin\n        ext n,\n        dsimp,\n        rw [category.comp_id, category.comp_id, \u03b7.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\u2080 : C) (f : X _[0] \u27f6 X\u2080)\n  (w : \u2200 (i : simplex_category) (g\u2081 g\u2082 : [0] \u27f6 i),\n    X.map g\u2081.op \u226b f = X.map g\u2082.op \u226b f) : simplicial_object.augmented C :=\n{ left := X,\n  right := X\u2080,\n  hom :=\n  { app := \u03bb i, X.map (simplex_category.const i.unop 0).op \u226b f,\n    naturality' := begin\n      intros i j g,\n      dsimp,\n      rw \u2190 g.op_unop,\n      simpa only [\u2190 X.map_comp, \u2190 category.assoc, category.comp_id, \u2190 op_comp] using w _ _ _,\n    end } }\n\n@[simp]\nlemma augment_hom_zero (X : simplicial_object C) (X\u2080 : C) (f : X _[0] \u27f6 X\u2080) (w) :\n  (X.augment X\u2080 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 \u2964 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) := \u27e8infer_instance\u27e9\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) := \u27e8infer_instance\u27e9\n\nvariables {C} (X : cosimplicial_object C)\n\n/-- Coface maps for a cosimplicial object. -/\ndef \u03b4 {n} (i : fin (n+2)) : X _[n] \u27f6 X _[n+1] :=\nX.map (simplex_category.\u03b4 i)\n\n/-- Codegeneracy maps for a cosimplicial object. -/\ndef \u03c3 {n} (i : fin (n+1)) : X _[n+1] \u27f6 X _[n] :=\nX.map (simplex_category.\u03c3 i)\n\n/-- Isomorphisms from identities in \u2115. -/\ndef eq_to_iso {n m : \u2115} (h : n = m) : X _[n] \u2245 X _[m] :=\nX.map_iso (eq_to_iso (by rw h))\n\n@[simp] lemma eq_to_iso_refl {n : \u2115} (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 \u03b4_comp_\u03b4 {n} {i j : fin (n+2)} (H : i \u2264 j) :\n  X.\u03b4 i \u226b X.\u03b4 j.succ = X.\u03b4 j \u226b X.\u03b4 i.cast_succ :=\nby { dsimp [\u03b4], simp only [\u2190X.map_comp, simplex_category.\u03b4_comp_\u03b4 H], }\n\n@[reassoc]\nlemma \u03b4_comp_\u03b4' {n} {i : fin (n+2)} {j : fin (n+3)} (H : i.cast_succ < j) :\n  X.\u03b4 i \u226b X.\u03b4 j = X.\u03b4 (j.pred (\u03bb hj, by simpa only [hj, fin.not_lt_zero] using H)) \u226b\n    X.\u03b4 i.cast_succ :=\nby { dsimp [\u03b4], simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03b4' H] }\n\n@[reassoc]\nlemma \u03b4_comp_\u03b4'' {n} {i : fin (n+3)} {j : fin (n+2)} (H : i \u2264 j.cast_succ) :\n  X.\u03b4 (i.cast_lt (nat.lt_of_le_of_lt (fin.le_iff_coe_le_coe.mp H) j.is_lt)) \u226b X.\u03b4 j.succ =\n    X.\u03b4 j \u226b X.\u03b4 i :=\nby { dsimp [\u03b4], simp only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03b4'' H] }\n\n/-- The special case of the first cosimplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03b4_self {n} {i : fin (n+2)} : X.\u03b4 i \u226b X.\u03b4 i.cast_succ = X.\u03b4 i \u226b X.\u03b4 i.succ :=\nby { dsimp [\u03b4], simp only [\u2190X.map_comp, simplex_category.\u03b4_comp_\u03b4_self] }\n\n@[reassoc]\nlemma \u03b4_comp_\u03b4_self' {n} {i : fin (n+2)} {j : fin (n+3)} (H : j = i.cast_succ) :\n  X.\u03b4 i \u226b X.\u03b4 j = X.\u03b4 i \u226b X.\u03b4 i.succ :=\nby { subst H, rw \u03b4_comp_\u03b4_self, }\n\n/-- The second cosimplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03c3_of_le {n} {i : fin (n+2)} {j : fin (n+1)} (H : i \u2264 j.cast_succ) :\n  X.\u03b4 i.cast_succ \u226b X.\u03c3 j.succ = X.\u03c3 j \u226b X.\u03b4 i :=\nby { dsimp [\u03b4, \u03c3], simp only [\u2190X.map_comp, simplex_category.\u03b4_comp_\u03c3_of_le H] }\n\n/-- The first part of the third cosimplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03c3_self {n} {i : fin (n+1)} :\n  X.\u03b4 i.cast_succ \u226b X.\u03c3 i = \ud835\udfd9 _ :=\nbegin\n  dsimp [\u03b4, \u03c3],\n  simp only [\u2190X.map_comp, simplex_category.\u03b4_comp_\u03c3_self, X.map_id],\nend\n\n@[reassoc]\nlemma \u03b4_comp_\u03c3_self' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.cast_succ) :\n  X.\u03b4 j \u226b X.\u03c3 i = \ud835\udfd9 _ :=\nby { subst H, rw \u03b4_comp_\u03c3_self, }\n\n/-- The second part of the third cosimplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03c3_succ {n} {i : fin (n+1)} :\n  X.\u03b4 i.succ \u226b X.\u03c3 i = \ud835\udfd9 _ :=\nbegin\n  dsimp [\u03b4, \u03c3],\n  simp only [\u2190X.map_comp, simplex_category.\u03b4_comp_\u03c3_succ, X.map_id],\nend\n\n@[reassoc]\nlemma \u03b4_comp_\u03c3_succ' {n} {j : fin (n+2)} {i : fin (n+1)} (H : j = i.succ) :\n  X.\u03b4 j \u226b X.\u03c3 i = \ud835\udfd9 _ :=\nby { subst H, rw \u03b4_comp_\u03c3_succ, }\n\n/-- The fourth cosimplicial identity -/\n@[reassoc]\nlemma \u03b4_comp_\u03c3_of_gt {n} {i : fin (n+2)} {j : fin (n+1)} (H : j.cast_succ < i) :\n  X.\u03b4 i.succ \u226b X.\u03c3 j.cast_succ = X.\u03c3 j \u226b X.\u03b4 i :=\nby { dsimp [\u03b4, \u03c3], simp only [\u2190X.map_comp, simplex_category.\u03b4_comp_\u03c3_of_gt H] }\n\n@[reassoc]\nlemma \u03b4_comp_\u03c3_of_gt' {n} {i : fin (n+3)} {j : fin (n+2)} (H : j.succ < i) :\n  X.\u03b4 i \u226b X.\u03c3 j = X.\u03c3 (j.cast_lt ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le\n      (by simpa only [fin.val_eq_coe, \u2190 fin.coe_succ]\n        using fin.lt_iff_coe_lt_coe.mp H) i.is_le))) \u226b\n    X.\u03b4 (i.pred (\u03bb hi, by simpa only [fin.not_lt_zero, hi] using H)) :=\nby { dsimp [\u03b4, \u03c3], simpa only [\u2190X.map_comp, \u2190op_comp, simplex_category.\u03b4_comp_\u03c3_of_gt' H], }\n\n/-- The fifth cosimplicial identity -/\n@[reassoc]\nlemma \u03c3_comp_\u03c3 {n} {i j : fin (n+1)} (H : i \u2264 j) :\n  X.\u03c3 i.cast_succ \u226b X.\u03c3 j = X.\u03c3 j.succ \u226b X.\u03c3 i :=\nby { dsimp [\u03b4, \u03c3], simp only [\u2190X.map_comp, simplex_category.\u03c3_comp_\u03c3 H] }\n\n@[simp, reassoc]\nlemma \u03b4_naturality {X' X : cosimplicial_object C} (f : X \u27f6 X') {n : \u2115} (i : fin (n+2)) :\n  X.\u03b4 i \u226b f.app (simplex_category.mk (n+1)) =\n    f.app (simplex_category.mk n) \u226b X'.\u03b4 i := f.naturality _\n\n@[simp, reassoc]\nlemma \u03c3_naturality {X' X : cosimplicial_object C} (f : X \u27f6 X') {n : \u2115} (i : fin (n+1)) :\n  X.\u03c3 i \u226b f.app (simplex_category.mk n) =\n    f.app (simplex_category.mk (n+1)) \u226b X'.\u03c3 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 \u2964 D) \u2964 cosimplicial_object C \u2964 cosimplicial_object D :=\nwhiskering_right _ _ _\n\n/-- Truncated cosimplicial objects. -/\n@[derive category, nolint has_nonempty_instance]\ndef truncated (n : \u2115) := simplex_category.truncated n \u2964 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) := \u27e8infer_instance\u27e9\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) := \u27e8infer_instance\u27e9\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 \u2964 D) \u2964 truncated C n \u2964 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 : \u2115) : cosimplicial_object C \u2964 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 \u2964 cosimplicial_object C := category_theory.functor.const _\n\n/-- Augmented cosimplicial objects. -/\n@[derive category, nolint has_nonempty_instance]\ndef augmented := comma (const C) (\ud835\udfed (cosimplicial_object C))\n\nvariable {C}\n\nnamespace augmented\n\n/-- Drop the augmentation. -/\n@[simps]\ndef drop : augmented C \u2964 cosimplicial_object C := comma.snd _ _\n\n/-- The point of the augmentation. -/\n@[simps]\ndef point : augmented C \u2964 C := comma.fst _ _\n\n/-- The functor from augmented objects to arrows. -/\n@[simps]\ndef to_arrow : augmented C \u2964 arrow C :=\n{ obj := \u03bb X,\n  { left := (point.obj X),\n    right := (drop.obj X) _[0],\n    hom := X.hom.app _ },\n  map := \u03bb X Y \u03b7,\n  { left := (point.map \u03b7),\n    right := (drop.map \u03b7).app _,\n    w' := begin\n      dsimp,\n      rw \u2190 nat_trans.comp_app,\n      erw \u2190 \u03b7.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 \u2964 D) :\n  augmented C \u2964 augmented D :=\n{ obj := \u03bb X,\n  { left := F.obj (point.obj X),\n    right := ((whiskering _ _).obj F).obj (drop.obj X),\n    hom := (functor.const_comp _ _ _).inv \u226b whisker_right X.hom F },\n  map := \u03bb X Y \u03b7,\n  { left := F.map \u03b7.left,\n    right := whisker_right \u03b7.right _,\n    w' := begin\n      ext,\n      dsimp,\n      rw [category.id_comp, category.id_comp, \u2190 F.map_comp, \u2190 F.map_comp, \u2190 nat_trans.comp_app],\n      erw \u2190 \u03b7.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 \u2964 D) \u2964 augmented C \u2964 augmented D :=\n{ obj := whiskering_obj _ _,\n  map := \u03bb X Y \u03b7,\n  { app := \u03bb A,\n    { left := \u03b7.app _,\n      right := whisker_left _ \u03b7,\n      w' := begin\n        ext n,\n        dsimp,\n        rw [category.id_comp, category.id_comp, \u03b7.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\u2080 : C) (f : X\u2080 \u27f6 X.obj [0])\n  (w : \u2200 (i : simplex_category) (g\u2081 g\u2082 : [0] \u27f6 i),\n    f \u226b X.map g\u2081 = f \u226b X.map g\u2082) : cosimplicial_object.augmented C :=\n{ left := X\u2080,\n  right := X,\n  hom :=\n  { app := \u03bb i, f \u226b X.map (simplex_category.const i 0),\n  naturality' := begin\n    intros i j g,\n    dsimp,\n    simpa [\u2190 X.map_comp] using w _ _ _,\n  end } }\n\n@[simp]\nlemma augment_hom_zero (X : cosimplicial_object C) (X\u2080 : C) (f : X\u2080 \u27f6 X.obj [0]) (w) :\n  (X.augment X\u2080 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)\u1d52\u1d56 \u224c (cosimplicial_object C\u1d52\u1d56) :=\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)\u1d52\u1d56 \u224c (simplicial_object C\u1d52\u1d56) :=\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\u1d52\u1d56 :=\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\u1d52\u1d56) :\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 \u2245 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\u1d52\u1d56) :\n  X.left_op.right_op \u2245 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)\u1d52\u1d56 \u2964 cosimplicial_object.augmented C\u1d52\u1d56 :=\n{ obj := \u03bb X, X.unop.right_op,\n  map := \u03bb 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 \u2190 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\u1d52\u1d56 \u2964 (simplicial_object.augmented C)\u1d52\u1d56 :=\n{ obj := \u03bb X, opposite.op X.left_op,\n  map := \u03bb 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 \u2190 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)\u1d52\u1d56 \u224c cosimplicial_object.augmented C\u1d52\u1d56 :=\nequivalence.mk\n  (simplicial_to_cosimplicial_augmented _)\n  (cosimplicial_to_simplicial_augmented _)\n  (nat_iso.of_components (\u03bb X, X.unop.right_op_left_op_iso.op) $ \u03bb X Y f,\n    by { dsimp, rw \u2190f.op_unop, simp_rw \u2190 op_comp, congr' 1, tidy })\n  (nat_iso.of_components (\u03bb 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  \u22a5\n\ninstance : DiscreteTopology SignType :=\n  \u27e8rfl\u27e9\n\nvariable {\u03b1 : Type _} [Zero \u03b1] [TopologicalSpace \u03b1]\n\nsection PartialOrder\n\nvariable [PartialOrder \u03b1] [DecidableRel ((\u00b7 < \u00b7) : \u03b1 \u2192 \u03b1 \u2192 Prop)] [OrderTopology \u03b1]\n\n/- warning: continuous_at_sign_of_pos -> continuousAt_sign_of_pos is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Zero.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : PartialOrder.{u1} \u03b1] [_inst_4 : DecidableRel.{succ u1} \u03b1 (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)))] [_inst_5 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 _inst_1))) a) -> (ContinuousAt.{u1, 0} \u03b1 SignType _inst_2 SignType.topologicalSpace (coeFn.{succ u1, succ u1} (OrderHom.{u1, 0} \u03b1 SignType (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1 SignType (PartialOrder.toPreorder.{u1} \u03b1 _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) => \u03b1 -> SignType) (OrderHom.hasCoeToFun.{u1, 0} \u03b1 SignType (PartialOrder.toPreorder.{u1} \u03b1 _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) (SignType.sign.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3) (fun (a : \u03b1) (b : \u03b1) => _inst_4 a b))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Zero.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : PartialOrder.{u1} \u03b1] [_inst_4 : DecidableRel.{succ u1} \u03b1 (fun (x._@.Mathlib.Topology.Instances.Sign._hyg.105 : \u03b1) (x._@.Mathlib.Topology.Instances.Sign._hyg.107 : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)) x._@.Mathlib.Topology.Instances.Sign._hyg.105 x._@.Mathlib.Topology.Instances.Sign._hyg.107)] [_inst_5 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 _inst_1)) a) -> (ContinuousAt.{u1, 0} \u03b1 SignType _inst_2 instTopologicalSpaceSignType (OrderHom.toFun.{u1, 0} \u03b1 SignType (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3) (fun (a : \u03b1) (b : \u03b1) => _inst_4 a b))) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at_sign_of_pos continuousAt_sign_of_pos\u2093'. -/\ntheorem continuousAt_sign_of_pos {a : \u03b1} (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 \u27e8{ x | 0 < x }, fun x hx => (sign_pos hx).symm, isOpen_lt' 0, h\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Zero.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : PartialOrder.{u1} \u03b1] [_inst_4 : DecidableRel.{succ u1} \u03b1 (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)))] [_inst_5 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 _inst_1)))) -> (ContinuousAt.{u1, 0} \u03b1 SignType _inst_2 SignType.topologicalSpace (coeFn.{succ u1, succ u1} (OrderHom.{u1, 0} \u03b1 SignType (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1 SignType (PartialOrder.toPreorder.{u1} \u03b1 _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) => \u03b1 -> SignType) (OrderHom.hasCoeToFun.{u1, 0} \u03b1 SignType (PartialOrder.toPreorder.{u1} \u03b1 _inst_3) (PartialOrder.toPreorder.{0} SignType (SemilatticeInf.toPartialOrder.{0} SignType (Lattice.toSemilatticeInf.{0} SignType (LinearOrder.toLattice.{0} SignType SignType.linearOrder))))) (SignType.sign.{u1} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3) (fun (a : \u03b1) (b : \u03b1) => _inst_4 a b))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Zero.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b1] [_inst_3 : PartialOrder.{u1} \u03b1] [_inst_4 : DecidableRel.{succ u1} \u03b1 (fun (x._@.Mathlib.Topology.Instances.Sign._hyg.235 : \u03b1) (x._@.Mathlib.Topology.Instances.Sign._hyg.237 : \u03b1) => LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)) x._@.Mathlib.Topology.Instances.Sign._hyg.235 x._@.Mathlib.Topology.Instances.Sign._hyg.237)] [_inst_5 : OrderTopology.{u1} \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3)) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 _inst_1))) -> (ContinuousAt.{u1, 0} \u03b1 SignType _inst_2 instTopologicalSpaceSignType (OrderHom.toFun.{u1, 0} \u03b1 SignType (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1 _inst_1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_3) (fun (a : \u03b1) (b : \u03b1) => _inst_4 a b))) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at_sign_of_neg continuousAt_sign_of_neg\u2093'. -/\ntheorem continuousAt_sign_of_neg {a : \u03b1} (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 \u27e8{ x | x < 0 }, fun x hx => (sign_neg hx).symm, isOpen_gt' 0, h\u27e9\n#align continuous_at_sign_of_neg continuousAt_sign_of_neg\n\nend PartialOrder\n\nsection LinearOrder\n\nvariable [LinearOrder \u03b1] [OrderTopology \u03b1]\n\n#print continuousAt_sign_of_ne_zero /-\ntheorem continuousAt_sign_of_ne_zero {a : \u03b1} (h : a \u2260 0) : ContinuousAt SignType.sign a :=\n  by\n  rcases h.lt_or_lt with (h_neg | h_pos)\n  \u00b7 exact continuousAt_sign_of_neg h_neg\n  \u00b7 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\u2082 \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 \u2192 walking_cospan \u2192 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 \u27f6 one :=\n  wide_pullback_shape.hom.term walking_pair.left\n\n/-- The identity arrows of the walking cospan. -/\ndef hom.inr : right \u27f6 one :=\n  wide_pullback_shape.hom.term walking_pair.right\n\ndef hom.id (X : walking_cospan) : X \u27f6 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 \u27f6 Y) :=\n  subsingleton.intro fun (a b : X \u27f6 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 \u2192 walking_span \u2192 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 \u27f6 left :=\n  wide_pushout_shape.hom.init walking_pair.left\n\n/-- The identity arrows of the walking span. -/\ndef hom.snd : zero \u27f6 right :=\n  wide_pushout_shape.hom.init walking_pair.right\n\ndef hom.id (X : walking_span) : X \u27f6 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 \u27f6 Y) :=\n  subsingleton.intro fun (a b : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z) : walking_cospan \u2964 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 \u27f6 Y) (g : X \u27f6 Z) : walking_span \u2964 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z) (w : walking_cospan) : functor.map (cospan f g) (walking_cospan.hom.id w) = \ud835\udfd9 :=\n  rfl\n\ntheorem span_map_id {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z) (w : walking_span) : functor.map (span f g) (walking_span.hom.id w) = \ud835\udfd9 :=\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 \u2964 C) : F \u2245 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 \u2964 C) : F \u2245 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 \u27f6 Z` and\n    `g : Y \u27f6 Z`.-/\ndef pullback_cone {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Z) (g : Y \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} (t : pullback_cone f g) : cone.X t \u27f6 X :=\n  nat_trans.app (cone.\u03c0 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 \u27f6 Z} {g : Y \u27f6 Z} (t : pullback_cone f g) : cone.X t \u27f6 Y :=\n  nat_trans.app (cone.\u03c0 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 \u27f6 Z} {g : Y \u27f6 Z} (t : pullback_cone f g) (lift : (s : cone (cospan f g)) \u2192 cone.X s \u27f6 cone.X t) (fac_left : \u2200 (s : pullback_cone f g), lift s \u226b fst t = fst s) (fac_right : \u2200 (s : pullback_cone f g), lift s \u226b snd t = snd s) (uniq : \u2200 (s : pullback_cone f g) (m : cone.X s \u27f6 cone.X t),\n  (\u2200 (j : walking_cospan), m \u226b nat_trans.app (cone.\u03c0 t) j = nat_trans.app (cone.\u03c0 s) j) \u2192 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 \u27f6 Z} {g : Y \u27f6 Z} (t : pullback_cone f g) (create : (s : pullback_cone f g) \u2192\n  Subtype\n    fun (l : cone.X s \u27f6 cone.X t) =>\n      l \u226b fst t = fst s \u2227 l \u226b snd t = snd s \u2227 \u2200 {m : cone.X s \u27f6 cone.X t}, m \u226b fst t = fst s \u2192 m \u226b snd t = snd s \u2192 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 \u27f6 X` and `snd : W \u27f6 Y`\n    such that `fst \u226b f = snd \u226b g`. -/\n@[simp] theorem mk_\u03c0_app {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) (j : walking_cospan) : nat_trans.app (cone.\u03c0 (mk fst snd eq)) j =\n  option.cases_on j (fst \u226b f) fun (j' : walking_pair) => walking_pair.cases_on j' fst snd :=\n  Eq.refl (nat_trans.app (cone.\u03c0 (mk fst snd eq)) j)\n\n@[simp] theorem mk_\u03c0_app_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) : nat_trans.app (cone.\u03c0 (mk fst snd eq)) walking_cospan.left = fst :=\n  rfl\n\n@[simp] theorem mk_\u03c0_app_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) : nat_trans.app (cone.\u03c0 (mk fst snd eq)) walking_cospan.right = snd :=\n  rfl\n\n@[simp] theorem mk_\u03c0_app_one {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) : nat_trans.app (cone.\u03c0 (mk fst snd eq)) walking_cospan.one = fst \u226b f :=\n  rfl\n\n@[simp] theorem mk_fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} (t : pullback_cone f g) {X' : C} (f' : Z \u27f6 X') : fst t \u226b f \u226b f' = snd t \u226b g \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} (t : pullback_cone f g) {W : C} {k : W \u27f6 cone.X t} {l : W \u27f6 cone.X t} (h\u2080 : k \u226b fst t = l \u226b fst t) (h\u2081 : k \u226b snd t = l \u226b snd t) (j : walking_cospan) : k \u226b nat_trans.app (cone.\u03c0 t) j = l \u226b nat_trans.app (cone.\u03c0 t) j := sorry\n\ntheorem is_limit.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} {t : pullback_cone f g} (ht : is_limit t) {W : C} {k : W \u27f6 cone.X t} {l : W \u27f6 cone.X t} (h\u2080 : k \u226b fst t = l \u226b fst t) (h\u2081 : k \u226b snd t = l \u226b snd t) : k = l :=\n  is_limit.hom_ext ht (equalizer_ext t h\u2080 h\u2081)\n\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W \u27f6 X` and `k : W \u27f6 Y` are such that\n    `h \u226b f = k \u226b g`, then we have `l : W \u27f6 t.X` satisfying `l \u226b fst t = h` and `l \u226b snd t = k`.\n    -/\ndef is_limit.lift' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} {t : pullback_cone f g} (ht : is_limit t) {W : C} (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : Subtype fun (l : W \u27f6 cone.X t) => l \u226b fst t = h \u2227 l \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} {W : C} {fst : W \u27f6 X} {snd : W \u27f6 Y} (eq : fst \u226b f = snd \u226b g) (lift : (s : pullback_cone f g) \u2192 cone.X s \u27f6 W) (fac_left : \u2200 (s : pullback_cone f g), lift s \u226b fst = fst s) (fac_right : \u2200 (s : pullback_cone f g), lift s \u226b snd = snd s) (uniq : \u2200 (s : pullback_cone f g) (m : cone.X s \u27f6 W), m \u226b fst = fst s \u2192 m \u226b snd = snd s \u2192 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 \u27f6 Z} {g : Y \u27f6 Z} {W : C} {h : W \u27f6 X} {k : W \u27f6 Y} {comm : h \u226b f = k \u226b 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 `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y) [mono f] : is_limit (mk \ud835\udfd9 \ud835\udfd9 (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 `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y) (t : is_limit (mk \ud835\udfd9 \ud835\udfd9 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 \u27f6 Y` and\n    `g : X \u27f6 Z`.-/\ndef pushout_cocone {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : X \u27f6 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 \u27f6 Y} {g : X \u27f6 Z} (t : pushout_cocone f g) : Y \u27f6 cocone.X t :=\n  nat_trans.app (cocone.\u03b9 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 \u27f6 Y} {g : X \u27f6 Z} (t : pushout_cocone f g) : Z \u27f6 cocone.X t :=\n  nat_trans.app (cocone.\u03b9 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 \u27f6 Y} {g : X \u27f6 Z} (t : pushout_cocone f g) (desc : (s : pushout_cocone f g) \u2192 cocone.X t \u27f6 cocone.X s) (fac_left : \u2200 (s : pushout_cocone f g), inl t \u226b desc s = inl s) (fac_right : \u2200 (s : pushout_cocone f g), inr t \u226b desc s = inr s) (uniq : \u2200 (s : pushout_cocone f g) (m : cocone.X t \u27f6 cocone.X s),\n  (\u2200 (j : walking_span), nat_trans.app (cocone.\u03b9 t) j \u226b m = nat_trans.app (cocone.\u03b9 s) j) \u2192 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 \u27f6 Y} {g : X \u27f6 Z} (t : pushout_cocone f g) (create : (s : pushout_cocone f g) \u2192\n  Subtype\n    fun (l : cocone.X t \u27f6 cocone.X s) =>\n      inl t \u226b l = inl s \u2227\n        inr t \u226b l = inr s \u2227 \u2200 {m : cocone.X t \u27f6 cocone.X s}, inl t \u226b m = inl s \u2192 inr t \u226b m = inr s \u2192 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 \u27f6 W` and `inr : Z \u27f6 W` such\n    that `f \u226b inl = g \u21a0 inr`. -/\ndef mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) : pushout_cocone f g :=\n  cocone.mk W\n    (nat_trans.mk\n      fun (j : walking_span) => option.cases_on j (f \u226b inl) fun (j' : walking_pair) => walking_pair.cases_on j' inl inr)\n\n@[simp] theorem mk_\u03b9_app_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) : nat_trans.app (cocone.\u03b9 (mk inl inr eq)) walking_span.left = inl :=\n  rfl\n\n@[simp] theorem mk_\u03b9_app_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) : nat_trans.app (cocone.\u03b9 (mk inl inr eq)) walking_span.right = inr :=\n  rfl\n\n@[simp] theorem mk_\u03b9_app_zero {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) : nat_trans.app (cocone.\u03b9 (mk inl inr eq)) walking_span.zero = f \u226b inl :=\n  rfl\n\n@[simp] theorem mk_inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b 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 \u27f6 Y} {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b 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 \u27f6 Y} {g : X \u27f6 Z} (t : pushout_cocone f g) {X' : C} (f' : cocone.X t \u27f6 X') : f \u226b inl t \u226b f' = g \u226b inr t \u226b 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 \u27f6 Y} {g : X \u27f6 Z} (t : pushout_cocone f g) {W : C} {k : cocone.X t \u27f6 W} {l : cocone.X t \u27f6 W} (h\u2080 : inl t \u226b k = inl t \u226b l) (h\u2081 : inr t \u226b k = inr t \u226b l) (j : walking_span) : nat_trans.app (cocone.\u03b9 t) j \u226b k = nat_trans.app (cocone.\u03b9 t) j \u226b l := sorry\n\ntheorem is_colimit.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {t : pushout_cocone f g} (ht : is_colimit t) {W : C} {k : cocone.X t \u27f6 W} {l : cocone.X t \u27f6 W} (h\u2080 : inl t \u226b k = inl t \u226b l) (h\u2081 : inr t \u226b k = inr t \u226b l) : k = l :=\n  is_colimit.hom_ext ht (coequalizer_ext t h\u2080 h\u2081)\n\n/-- If `t` is a colimit pushout cocone over `f` and `g` and `h : Y \u27f6 W` and `k : Z \u27f6 W` are\n    morphisms satisfying `f \u226b h = g \u226b k`, then we have a factorization `l : t.X \u27f6 W` such that\n    `inl t \u226b l = h` and `inr t \u226b l = k`. -/\ndef is_colimit.desc' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {t : pushout_cocone f g} (ht : is_colimit t) {W : C} (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : Subtype fun (l : cocone.X t \u27f6 W) => inl t \u226b l = h \u2227 inr t \u226b 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 \u27f6 Y} {g : X \u27f6 Z} {W : C} {inl : Y \u27f6 W} {inr : Z \u27f6 W} (eq : f \u226b inl = g \u226b inr) (desc : (s : pushout_cocone f g) \u2192 W \u27f6 cocone.X s) (fac_left : \u2200 (s : pushout_cocone f g), inl \u226b desc s = inl s) (fac_right : \u2200 (s : pushout_cocone f g), inr \u226b desc s = inr s) (uniq : \u2200 (s : pushout_cocone f g) (m : W \u27f6 cocone.X s), inl \u226b m = inl s \u2192 inr \u226b m = inr s \u2192 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 \u27f6 Y} {g : X \u27f6 Z} {W : C} {h : Y \u27f6 W} {k : Z \u27f6 W} {comm : f \u226b h = g \u226b 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 \u2964 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_\u03c0 {C : Type u} [category C] {F : walking_cospan \u2964 C} (t : pullback_cone (functor.map F walking_cospan.hom.inl) (functor.map F walking_cospan.hom.inr)) : cone.\u03c0 (cone.of_pullback_cone t) = cone.\u03c0 t \u226b iso.inv (diagram_iso_cospan F) :=\n  Eq.refl (cone.\u03c0 (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 \u2964 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 \u2964 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 \u2964 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 \u2964 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 \u2964 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 \u2964 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) \u226b cocone.\u03b9 t)\n\n/--\n`has_pullback f g` represents a particular choice of limiting cone\nfor the pair of morphisms `f : X \u27f6 Z` and `g : Y \u27f6 Z`.\n-/\n/--\ndef has_pullback {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y` and `g : X \u27f6 Z`.\n-/\ndef has_pushout {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] : pullback f g \u27f6 X :=\n  limit.\u03c0 (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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] : pullback f g \u27f6 Y :=\n  limit.\u03c0 (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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] : Y \u27f6 pushout f g :=\n  colimit.\u03b9 (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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] : Z \u27f6 pushout f g :=\n  colimit.\u03b9 (span f g) walking_span.right\n\n/-- A pair of morphisms `h : W \u27f6 X` and `k : W \u27f6 Y` satisfying `h \u226b f = k \u226b g` induces a morphism\n    `pullback.lift : W \u27f6 pullback f g`. -/\ndef pullback.lift {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : W \u27f6 pullback f g :=\n  limit.lift (cospan f g) (pullback_cone.mk h k w)\n\n/-- A pair of morphisms `h : Y \u27f6 W` and `k : Z \u27f6 W` satisfying `f \u226b h = g \u226b k` induces a morphism\n    `pushout.desc : pushout f g \u27f6 W`. -/\ndef pushout.desc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : pushout f g \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) {X' : C} (f' : X \u27f6 X') : pullback.lift h k w \u226b pullback.fst \u226b f' = h \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) {X' : C} (f' : Y \u27f6 X') : pullback.lift h k w \u226b pullback.snd \u226b f' = k \u226b 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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) {X' : C} (f' : W \u27f6 X') : pushout.inl \u226b pushout.desc h k w \u226b f' = h \u226b 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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) {X' : C} (f' : W \u27f6 X') : pushout.inr \u226b pushout.desc h k w \u226b f' = k \u226b f' := sorry\n\n/-- A pair of morphisms `h : W \u27f6 X` and `k : W \u27f6 Y` satisfying `h \u226b f = k \u226b g` induces a morphism\n    `l : W \u27f6 pullback f g` such that `l \u226b pullback.fst = h` and `l \u226b pullback.snd = k`. -/\ndef pullback.lift' {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : Subtype fun (l : W \u27f6 pullback f g) => l \u226b pullback.fst = h \u2227 l \u226b pullback.snd = k :=\n  { val := pullback.lift h k w, property := sorry }\n\n/-- A pair of morphisms `h : Y \u27f6 W` and `k : Z \u27f6 W` satisfying `f \u226b h = g \u226b k` induces a morphism\n    `l : pushout f g \u27f6 W` such that `pushout.inl \u226b l = h` and `pushout.inr \u226b l = k`. -/\ndef pullback.desc' {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : Subtype fun (l : pushout f g \u27f6 W) => pushout.inl \u226b l = h \u2227 pushout.inr \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] : pullback.fst \u226b f = pullback.snd \u226b 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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] {X' : C} (f' : pushout f g \u27f6 X') : f \u226b pushout.inl \u226b f' = g \u226b pushout.inr \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] {W : C} {k : W \u27f6 pullback f g} {l : W \u27f6 pullback f g} (h\u2080 : k \u226b pullback.fst = l \u226b pullback.fst) (h\u2081 : k \u226b pullback.snd = l \u226b pullback.snd) : k = l :=\n  limit.hom_ext (pullback_cone.equalizer_ext (limit.cone (cospan f g)) h\u2080 h\u2081)\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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Z} {g : Y \u27f6 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 \u27f6 Z} {g : Y \u27f6 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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] {W : C} {k : pushout f g \u27f6 W} {l : pushout f g \u27f6 W} (h\u2080 : pushout.inl \u226b k = pushout.inl \u226b l) (h\u2081 : pushout.inr \u226b k = pushout.inr \u226b l) : k = l :=\n  colimit.hom_ext (pushout_cocone.coequalizer_ext (colimit.cocone (span f g)) h\u2080 h\u2081)\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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] [epi g] : epi pushout.inl :=\n  epi.mk\n    fun (W : C) (u v : pushout f g \u27f6 W) (h : pushout.inl \u226b u = pushout.inl \u226b 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 \u27f6 W) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : X \u27f6 W) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n                  (g \u226b pushout.inr \u226b u) (f \u226b pushout.inl \u226b v)\n                  (Eq.trans (Eq.symm (pushout.condition_assoc u))\n                    ((fun (\u1fb0 \u1fb0_1 : X \u27f6 Y) (e_1 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : Y \u27f6 W) (e_2 : \u1fb0_2 = \u1fb0_3) =>\n                        congr (congr_arg category_struct.comp e_1) e_2)\n                      f f (Eq.refl f) (pushout.inl \u226b u) (pushout.inl \u226b v) h))\n                  (g \u226b pushout.inr \u226b v) (f \u226b pushout.inl \u226b v) (Eq.symm (pushout.condition_assoc v)))\n                (propext (eq_self_iff_true (f \u226b pushout.inl \u226b 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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] [epi f] : epi pushout.inr :=\n  epi.mk\n    fun (W : C) (u v : pushout f g \u27f6 W) (h : pushout.inr \u226b u = pushout.inr \u226b 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 \u27f6 W) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : X \u27f6 W) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n                  (f \u226b pushout.inl \u226b u) (g \u226b pushout.inr \u226b v)\n                  (Eq.trans (pushout.condition_assoc u)\n                    ((fun (\u1fb0 \u1fb0_1 : X \u27f6 Z) (e_1 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : Z \u27f6 W) (e_2 : \u1fb0_2 = \u1fb0_3) =>\n                        congr (congr_arg category_struct.comp e_1) e_2)\n                      g g (Eq.refl g) (pushout.inr \u226b u) (pushout.inr \u226b v) h))\n                  (f \u226b pushout.inl \u226b v) (g \u226b pushout.inr \u226b v) (pushout.condition_assoc v))\n                (propext (eq_self_iff_true (g \u226b pushout.inr \u226b 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\u2082} [category D] (G : C \u2964 D) (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g] [has_pullback (functor.map G f) (functor.map G g)] : functor.obj G (pullback f g) \u27f6 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\u2082} [category D] (G : C \u2964 D) (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g] [has_pullback (functor.map G f) (functor.map G g)] {X' : D} (f' : functor.obj G X \u27f6 X') : pullback_comparison G f g \u226b pullback.fst \u226b f' = functor.map G pullback.fst \u226b 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\u2082} [category D] (G : C \u2964 D) (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g] [has_pullback (functor.map G f) (functor.map G g)] {X' : D} (f' : functor.obj G Y \u27f6 X') : pullback_comparison G f g \u226b pullback.snd \u226b f' = functor.map G pullback.snd \u226b 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\u2082} [category D] (G : C \u2964 D) (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g] [has_pullback (functor.map G f) (functor.map G g)] {W : C} {h : W \u27f6 X} {k : W \u27f6 Y} (w : h \u226b f = k \u226b g) {X' : D} (f' : pullback (functor.map G f) (functor.map G g) \u27f6 X') : functor.map G (pullback.lift h k w) \u226b pullback_comparison G f g \u226b 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 \u27f6 functor.obj G Z) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : functor.obj G W \u27f6 functor.obj G Z)\n              (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n            (functor.map G h \u226b functor.map G f) (functor.map G (k \u226b g))\n            (Eq.trans (Eq.symm (functor.map_comp G h f))\n              ((fun (c : C \u2964 D) {X Y : C} (\u1fb0 \u1fb0_1 : X \u27f6 Y) (e_4 : \u1fb0 = \u1fb0_1) => congr_arg (functor.map c) e_4) G (h \u226b f)\n                (k \u226b g) w))\n            (functor.map G k \u226b functor.map G g) (functor.map G (k \u226b g)) (Eq.symm (functor.map_comp G k g))))\n        (Eq.refl (functor.map G (k \u226b g)))) \u226b\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] [\u2200 {X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}, has_limit (cospan f g)] : has_pullbacks C :=\n  has_limits_of_shape.mk fun (F : walking_cospan \u2964 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] [\u2200 {X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z}, has_colimit (span f g)] : has_pushouts C :=\n  has_colimits_of_shape.mk fun (F : walking_span \u2964 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 \u207b\u00b9 := pnat.inv\n\n-----------------------------\n-- Facts about absolute values of sequences, to define inverse\n\ndefinition s_abs (s : seq) : seq := \u03bb 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        \u2203 N : \u2115+, \u2200 m : \u2115+, m \u2265 N \u2192 abs (s m) \u2265 N\u207b\u00b9 :=\n  begin\n    rewrite [\u2191sep at Hnz, \u2191s_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 \u2191sneg,\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 \u2261 t) :\n        s_abs s \u2261 s_abs t :=\n  begin\n    rewrite [\u2191equiv at *],\n    intro n,\n    rewrite \u2191s_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        \u2200 m : \u2115+, m \u2265 (pb Hs Hpos) \u2192 abs (s m) \u2265 (pb Hs Hpos)\u207b\u00b9 :=\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        \u2200 m : \u2115+, m \u2265 (ps Hs Hsep) \u2192 abs (s m) \u2265 (ps Hs Hsep)\u207b\u00b9 :=\n  some_spec (abs_pos_of_nonzero Hs Hsep)\n\nnoncomputable definition s_inv {s : seq} (Hs : regular s) (n : \u2115+) : \u211a :=\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 : \u2115+}\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 : \u2115+}\n        (Hn : n \u2265 (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 : \u2115+}\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 : \u2115+}\n        (Hn : n \u2265 (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 : \u2115+) :\n        abs (s_inv Hs n) \u2264 (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 (\u03bb n, dif_neg (!not_sep_self))\n\nprivate theorem s_inv_of_zero' {s : seq} (Hs : regular s) (Hz : \u00ac sep s zero) (n : \u2115+) : s_inv Hs n = 0 :=\n  dif_neg Hz\n\ntheorem s_inv_of_zero {s : seq} (Hs : regular s) (Hz : \u00ac 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 : \u2115+}\n        (Hn : n \u2265 (ps Hs Hsep)) : s n \u2260 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 \u2191regular,\n    intros,\n    have Hsp : s ((ps Hs Hsep) * (ps Hs Hsep) * (ps Hs Hsep)) \u2260 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) \u2260 0, from\n      s_ne_zero_of_ge_p Hs Hsep (show (ps Hs Hsep) * (ps Hs Hsep) * n \u2265 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) \u2260 0, from\n      s_ne_zero_of_ge_p Hs Hsep (show (ps Hs Hsep) * (ps Hs Hsep) * m \u2265 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 : \u2115+) : s_inv Hs n \u2260 0 :=\n  if H : n \u2265 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) \u2261 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\u2082 s (s_inv Hs)) * 2 * n) \u2260 0, from s_inv_ne_zero Hs Hsep _,\n    rewrite [\u2191smul, \u2191one, 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\u2082 s (s_inv Hs)) * 2 * n \u2265 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\u2082 s (s_inv Hs)) * 2 * n)) \u2260 0, from\n      s_ne_zero_of_ge_p Hs Hsep\n        (show ps Hs Hsep \u2264 ((ps Hs Hsep) * (ps Hs Hsep)) * ((K\u2082 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\u2082 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 \u2261 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 \u2261 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 \u2191s_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 \u2191s_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 \u2261 one) : s_inv Hs \u2261 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 \u2261 t) :\n        s_inv Hs \u2261 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) \u2261 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 (\u03bb n, dif_neg Hsep),\n     have Hsept : \u00ac 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 (\u03bb n, dif_neg Hsept),\n     by rewrite [H', H]; apply equiv.refl)\n\ntheorem s_neg_neg {s : seq} : sneg (sneg s) \u2261 s :=\n  begin\n    rewrite [\u2191equiv, \u2191sneg],\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)) \u2261 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 \u2228 s_le t s :=\n  if H : s_le s t then or.inl H else or.inr begin\n      rewrite [\u2191s_le at *],\n      have H' : \u2203 n : \u2115+, -n\u207b\u00b9 > sadd t (sneg s) n, begin\n        apply by_contradiction,\n        intro Hex,\n        have Hex' : \u2200 n : \u2115+, -n\u207b\u00b9 \u2264 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 [\u2191pos, \u2191sneg],\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 : \u00ac s_lt s t) : s_le t s :=\n  begin\n    rewrite [\u2191s_le, \u2191nonneg, \u2191s_lt at Hle, \u2191pos 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 [\u2191sadd, \u2191sneg, 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 : \u00ac equiv s t) :\n        sep s t :=\n  begin\n    rewrite \u2191sep,\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 \u2261 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 \u2228 s \u2261 t :=\n  if H : s \u2261 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 \u2261 t) (Hle : s_le s u) : s_le t u :=\n  begin\n    rewrite \u2191s_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 \u2261 u) (Hle : s_le s t) : s_le s u :=\n  begin\n    rewrite \u2191s_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 (\u03bb 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 \u2228 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 : \u00ac 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 \u2228 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 : \u211d) : \u211d :=\n  quot.lift_on x (\u03bb a, quot.mk (rat_seq.r_inv a))\n           (\u03bb 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 : \u211d) : \u211d :=\n  x * y\u207b\u00b9\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 : \u211d) : x \u2264 y \u2228 y \u2264 x :=\n  quot.induction_on\u2082 x y (\u03bb s t, rat_seq.r_le_total s t)\n\nprotected theorem mul_inv_cancel' (x : \u211d) : x \u2262 0 \u2192 x * x\u207b\u00b9 = 1 :=\n  quot.induction_on x (\u03bb s H, quot.sound (rat_seq.r_mul_inv s H))\n\nprotected theorem inv_mul_cancel' (x : \u211d) : x \u2262 0 \u2192 x\u207b\u00b9 * x = 1 :=\n  by rewrite real.mul_comm; apply real.mul_inv_cancel'\n\ntheorem neq_of_sep {x y : \u211d} (H : x \u2262 y) : \u00ac x = y :=\n  assume Heq, !not_sep_self (Heq \u25b8 H)\n\ntheorem sep_of_neq {x y : \u211d} : \u00ac x = y \u2192 x \u2262 y :=\n  quot.induction_on\u2082 x y (\u03bb s t H, rat_seq.r_sep_of_nequiv s t (assume Heq, H (quot.sound Heq)))\n\ntheorem sep_is_neq (x y : \u211d) : (x \u2262 y) = (\u00ac x = y) :=\n  propext (iff.intro neq_of_sep sep_of_neq)\n\nprotected theorem mul_inv_cancel (x : \u211d) : x \u2260 0 \u2192 x * x\u207b\u00b9 = 1 :=\n  !sep_is_neq \u25b8 !real.mul_inv_cancel'\n\nprotected theorem inv_mul_cancel (x : \u211d) : x \u2260 0 \u2192 x\u207b\u00b9 * x = 1 :=\n  !sep_is_neq \u25b8 !real.inv_mul_cancel'\n\nprotected theorem inv_zero : (0 : \u211d)\u207b\u00b9 = 0 := quot.sound (rat_seq.r_inv_zero)\n\nprotected theorem lt_or_eq_of_le (x y : \u211d) : x \u2264 y \u2192 x < y \u2228 x = y :=\n  quot.induction_on\u2082 x y (\u03bb 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 : \u211d) : x \u2264 y \u2194 x < y \u2228 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 \u2191decidable_rel,\n    intros,\n    apply prop_decidable\n  end\n\nprotected noncomputable definition discrete_linear_ordered_field [trans_instance]:\n  discrete_linear_ordered_field \u211d :=\n  \u2983 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   \u2984\n\ntheorem of_rat_divide (x y : \u211a) : 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 \u2260 0,\n    have ynz' : of_rat y \u2260 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 : \u2124) (H : y \u2223 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 : \u2115) (H : y \u2223 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 : \u211d} (xnonneg : x \u2265 0) (H : \u2200 \u03b5 : \u211d, \u03b5 > 0 \u2192 x < \u03b5) :\n  x = 0 :=\ndecidable.by_contradiction\n  (suppose x \u2260 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 : \u211d} (xnonneg : x \u2265 0) (H : \u2200 \u03b5 : \u211d, \u03b5 > 0 \u2192 x \u2264 \u03b5) :\n  x = 0 :=\nhave \u2200 \u03b5 : \u211d, \u03b5 > 0 \u2192 x < \u03b5, from\n  take \u03b5, suppose \u03b5 > 0,\n  have e2pos : \u03b5 / 2 > 0, from div_pos_of_pos_of_pos `\u03b5 > 0` two_pos,\n  have \u03b5 / 2 < \u03b5, from div_two_lt_of_pos `\u03b5 > 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 : \u211d} (H : \u2200 \u03b5 : \u211d, \u03b5 > 0 \u2192 abs x \u2264 \u03b5) :\n  x = 0 :=\nby_contradiction\n  (suppose x \u2260 0,\n   have abs x = 0, from eq_zero_of_nonneg_of_forall_le !abs_nonneg H,\n   show false, from `x \u2260 0` (eq_zero_of_abs_eq_zero this))\n\ntheorem eq_of_forall_abs_sub_le {x y : \u211d} (H : \u2200 \u03b5 : \u211d, \u03b5 > 0 \u2192 abs (x - y) \u2264 \u03b5) :\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\u00ebl Dillies, Sky Wilshaw. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 `\u03b1` is a domain `set \u03b1` and two functions `\u03b1 \u2192 \u03b1` that map `domain` to\n`domain` and are inverse to each other on `domain`.\n\n## Main declarations\n\n* `local_perm \u03b1`: The type of local permutations on `\u03b1`.\n* `equiv.to_local_perm`: Reinter\n-/\n\n\nopen function set\n\nvariables {\u03b1 : Type*}\n\n/-- A local permutation of a subset `domain` of `\u03b1`. The (global) maps `to_fun : \u03b1 \u2192 \u03b1` and\n`inv_fun : \u03b1 \u2192 \u03b1` 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 (\u03b1 : Type*) :=\n(to_fun inv_fun : \u03b1 \u2192 \u03b1)\n(domain : set \u03b1)\n(to_fun_domain' : \u2200 \u2983x\u2984, x \u2208 domain \u2192 to_fun x \u2208 domain)\n(inv_fun_domain' : \u2200 \u2983x\u2984, x \u2208 domain \u2192 inv_fun x \u2208 domain)\n(left_inv' : \u2200 \u2983x\u2984, x \u2208 domain \u2192 inv_fun (to_fun x) = x)\n(right_inv' : \u2200 \u2983x\u2984, x \u2208 domain \u2192 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 (\u03c0 : equiv.perm \u03b1) : local_perm \u03b1 :=\n{ to_fun := \u03c0,\n  inv_fun := \u03c0.symm,\n  domain := univ,\n  to_fun_domain' := \u03bb x hx, mem_univ _,\n  inv_fun_domain' := \u03bb y hy, mem_univ _,\n  left_inv' := \u03bb x hx, \u03c0.left_inv x,\n  right_inv' := \u03bb x hx, \u03c0.right_inv x }\n\nnamespace local_perm\nvariables (\u03c0 \u03c0' : local_perm \u03b1)\n\n/-- The inverse of a local permutation. -/\nprotected def symm : local_perm \u03b1 :=\n{ to_fun := \u03c0.inv_fun,\n  inv_fun := \u03c0.to_fun,\n  domain := \u03c0.domain,\n  to_fun_domain' := \u03c0.inv_fun_domain',\n  inv_fun_domain' := \u03c0.to_fun_domain',\n  left_inv' := \u03c0.right_inv',\n  right_inv' := \u03c0.left_inv' }\n\ninstance : has_coe_to_fun (local_perm \u03b1) (\u03bb _, \u03b1 \u2192 \u03b1) := \u27e8local_perm.to_fun\u27e9\n\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (\u03c0 : local_perm \u03b1) : \u03b1 \u2192 \u03b1 := \u03c0.symm\n\ninitialize_simps_projections local_perm (to_fun \u2192 apply, inv_fun \u2192 symm_apply)\n\n@[simp] theorem coe_mk (f : \u03b1 \u2192 \u03b1) (g s ml mr il ir) :\n  (local_perm.mk f g s ml mr il ir : \u03b1 \u2192 \u03b1) = f := rfl\n\n@[simp] theorem coe_symm_mk (f : \u03b1 \u2192 \u03b1) (g s ml mr il ir) :\n  ((local_perm.mk f g s ml mr il ir).symm : \u03b1 \u2192 \u03b1) = g := rfl\n\n@[simp] lemma to_fun_as_coe : \u03c0.to_fun = \u03c0 := rfl\n@[simp] lemma inv_fun_as_coe : \u03c0.inv_fun = \u03c0.symm := rfl\n\n@[simp] lemma map_domain {x : \u03b1} (h : x \u2208 \u03c0.domain) : \u03c0 x \u2208 \u03c0.domain := \u03c0.to_fun_domain' h\n@[simp] lemma iterate_domain {x : \u03b1} (h : x \u2208 \u03c0.domain) {n : \u2115} : \u03c0^[n] x \u2208 \u03c0.domain :=\nbegin\n  induction n with n ih,\n  exact h,\n  rw function.iterate_succ',\n  exact \u03c0.map_domain ih,\nend\n\n@[simp] lemma left_inv {x : \u03b1} (h : x \u2208 \u03c0.domain) : \u03c0.symm (\u03c0 x) = x := \u03c0.left_inv' h\n@[simp] lemma right_inv {x : \u03b1} (h : x \u2208 \u03c0.domain) : \u03c0 (\u03c0.symm x) = x := \u03c0.right_inv' h\n\n@[simp] lemma symm_domain : \u03c0.symm.domain = \u03c0.domain := rfl\n@[simp] lemma symm_symm : \u03c0.symm.symm = \u03c0 := by { cases \u03c0, refl }\n\nlemma eq_symm_apply {x : \u03b1} {y : \u03b1} (hx : x \u2208 \u03c0.domain) (hy : y \u2208 \u03c0.domain) :\n  x = \u03c0.symm y \u2194 \u03c0 x = y :=\n\u27e8\u03bb h, by rw [\u2190 \u03c0.right_inv hy, h], \u03bb h, by rw [\u2190 \u03c0.left_inv hx, h]\u27e9\n\nprotected lemma maps_to : maps_to \u03c0 \u03c0.domain \u03c0.domain := \u03bb x, \u03c0.map_domain\nprotected lemma left_inv_on : left_inv_on \u03c0.symm \u03c0 \u03c0.domain := \u03bb x, \u03c0.left_inv\nprotected lemma right_inv_on : right_inv_on \u03c0.symm \u03c0 \u03c0.domain := \u03bb x, \u03c0.right_inv\nprotected lemma inv_on : inv_on \u03c0.symm \u03c0 \u03c0.domain \u03c0.domain := \u27e8\u03c0.left_inv_on, \u03c0.right_inv_on\u27e9\nprotected lemma inj_on : inj_on \u03c0 \u03c0.domain := \u03c0.left_inv_on.inj_on\nprotected lemma bij_on : bij_on \u03c0 \u03c0.domain \u03c0.domain := \u03c0.inv_on.bij_on \u03c0.maps_to \u03c0.symm.maps_to\nprotected lemma surj_on : surj_on \u03c0 \u03c0.domain \u03c0.domain := \u03c0.bij_on.surj_on\n\n/-- Create a copy of a `local_perm` providing better definitional equalities. -/\n@[simps {fully_applied := ff}]\ndef copy (\u03c0 : local_perm \u03b1) (f : \u03b1 \u2192 \u03b1) (hf : \u21d1\u03c0 = f) (g : \u03b1 \u2192 \u03b1) (hg : \u21d1\u03c0.symm = g)\n  (s : set \u03b1) (hs : \u03c0.domain = s) :\n  local_perm \u03b1 :=\n{ to_fun := f,\n  inv_fun := g,\n  domain := s,\n  to_fun_domain' := hs \u25b8 hf \u25b8 \u03c0.to_fun_domain',\n  inv_fun_domain' := hs \u25b8 hg \u25b8 \u03c0.inv_fun_domain',\n  left_inv' := \u03bb x, hs \u25b8 hf \u25b8 hg \u25b8 \u03c0.left_inv,\n  right_inv' := \u03bb x, hs \u25b8 hf \u25b8 hg \u25b8 \u03c0.right_inv }\n\nlemma copy_eq (\u03c0 : local_perm \u03b1) (f : \u03b1 \u2192 \u03b1) (hf : \u21d1\u03c0 = f) (g : \u03b1 \u2192 \u03b1) (hg : \u21d1\u03c0.symm = g)\n  (s : set \u03b1) (hs : \u03c0.domain = s) :\n  \u03c0.copy f hf g hg s hs = \u03c0 :=\nby { substs f g s, cases \u03c0, refl }\n\n/-- Associating to a local_perm a permutation of the domain. -/\nprotected def to_perm : equiv.perm \u03c0.domain :=\n{ to_fun := \u03bb x, \u27e8\u03c0 x, \u03c0.map_domain x.mem\u27e9,\n  inv_fun := \u03bb y, \u27e8\u03c0.symm y, \u03c0.symm.map_domain y.mem\u27e9,\n  left_inv := \u03bb \u27e8x, hx\u27e9, subtype.eq $ \u03c0.left_inv hx,\n  right_inv := \u03bb \u27e8y, hy\u27e9, subtype.eq $ \u03c0.right_inv hy }\n\n@[simp] lemma image_domain : \u03c0 '' \u03c0.domain = \u03c0.domain := \u03c0.bij_on.image_eq\n\nlemma forall_mem_domain {p : \u03b1 \u2192 Prop} : (\u2200 y \u2208 \u03c0.domain, p y) \u2194 \u2200 x \u2208 \u03c0.domain, p (\u03c0 x) :=\nby conv_lhs { rw [\u2190image_domain, ball_image_iff] }\n\nlemma exists_mem_domain {p : \u03b1 \u2192 Prop} : (\u2203 y \u2208 \u03c0.domain, p y) \u2194 \u2203 x \u2208 \u03c0.domain, p (\u03c0 x) :=\nby conv_lhs { rw [\u2190image_domain, bex_image_iff] }\n\n/-- A set `s` is *stable* under a local equivalence `\u03c0` if it preserved by it. -/\ndef is_stable (s : set \u03b1) : Prop := \u2200 \u2983x\u2984, x \u2208 \u03c0.domain \u2192 (\u03c0 x \u2208 s \u2194 x \u2208 s)\n\nnamespace is_stable\n\nvariables {\u03c0 \u03c0'} {s : set \u03b1} {x y : \u03b1}\n\nlemma apply_mem_iff (h : \u03c0.is_stable s) (hx : x \u2208 \u03c0.domain) : \u03c0 x \u2208 s \u2194 x \u2208 s := h hx\n\nlemma symm_apply_mem_iff (h : \u03c0.is_stable s) : \u2200 \u2983y\u2984, y \u2208 \u03c0.domain \u2192 (\u03c0.symm y \u2208 s \u2194 y \u2208 s) :=\n\u03c0.forall_mem_domain.mpr $ \u03bb x hx, by rw [\u03c0.left_inv hx, h hx]\n\nprotected lemma symm (h : \u03c0.is_stable s) : \u03c0.symm.is_stable s := h.symm_apply_mem_iff\n\n@[simp] lemma symm_iff : \u03c0.symm.is_stable s \u2194 \u03c0.is_stable s := \u27e8\u03bb h, h.symm, \u03bb h, h.symm\u27e9\n\nprotected lemma maps_to (h : \u03c0.is_stable s) : maps_to \u03c0 (\u03c0.domain \u2229 s) (\u03c0.domain \u2229 s) :=\n\u03bb x hx, \u27e8\u03c0.maps_to hx.1, (h hx.1).2 hx.2\u27e9\n\nlemma symm_maps_to (h : \u03c0.is_stable s) : maps_to \u03c0.symm (\u03c0.domain \u2229 s) (\u03c0.domain \u2229 s) :=\nh.symm.maps_to\n\n/-- Restrict a `local_perm` to a stable subset. -/\n@[simps {fully_applied := ff}] def restr (h : \u03c0.is_stable s) : local_perm \u03b1 :=\n{ to_fun := \u03c0,\n  inv_fun := \u03c0.symm,\n  domain := \u03c0.domain \u2229 s,\n  to_fun_domain' := h.maps_to,\n  inv_fun_domain' := h.symm_maps_to,\n  left_inv' := \u03c0.left_inv_on.mono (inter_subset_left _ _),\n  right_inv' := \u03c0.right_inv_on.mono (inter_subset_left _ _) }\n\nlemma image_eq (h : \u03c0.is_stable s) : \u03c0 '' (\u03c0.domain \u2229 s) = \u03c0.domain \u2229 s :=\nh.restr.image_domain\n\nlemma symm_image_eq (h : \u03c0.is_stable s) : \u03c0.symm '' (\u03c0.domain \u2229 s) = \u03c0.domain \u2229 s :=\nh.symm.image_eq\n\nlemma iff_preimage_eq : \u03c0.is_stable s \u2194 \u03c0.domain \u2229 \u03c0 \u207b\u00b9' s = \u03c0.domain \u2229 s :=\nby simp only [is_stable, set.ext_iff, mem_inter_iff, and.congr_right_iff, mem_preimage]\n\nalias iff_preimage_eq \u2194 preimage_eq of_preimage_eq\n\nlemma iff_symm_preimage_eq : \u03c0.is_stable s \u2194 \u03c0.domain \u2229 \u03c0.symm \u207b\u00b9' s = \u03c0.domain \u2229 s :=\nsymm_iff.symm.trans iff_preimage_eq\n\nalias iff_symm_preimage_eq \u2194 symm_preimage_eq of_symm_preimage_eq\n\n-- lemma of_image_eq (h : \u03c0 '' (\u03c0.domain \u2229 s) = \u03c0.domain \u2229 s) : \u03c0.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 : \u03c0.symm '' (\u03c0.domain \u2229 s) = \u03c0.domain \u2229 s) : \u03c0.is_stable s :=\n-- of_preimage_eq $ eq.trans (of_preimage_eq rfl).symm_image_eq.symm h\n\nprotected lemma compl (h : \u03c0.is_stable s) : \u03c0.is_stable s\u1d9c := \u03bb x hx, not_congr (h hx)\n\nprotected lemma inter {s'} (h : \u03c0.is_stable s) (h' : \u03c0.is_stable s') : \u03c0.is_stable (s \u2229 s') :=\n\u03bb x hx, and_congr (h hx) (h' hx)\n\nprotected lemma union {s'} (h : \u03c0.is_stable s) (h' : \u03c0.is_stable s') : \u03c0.is_stable (s \u222a s') :=\n\u03bb x hx, or_congr (h hx) (h' hx)\n\nprotected lemma diff {s'} (h : \u03c0.is_stable s) (h' : \u03c0.is_stable s') : \u03c0.is_stable (s \\ s') :=\nh.inter h'.compl\n\nlemma left_inv_on_piecewise {\u03c0' : local_perm \u03b1} [\u03a0 i, decidable (i \u2208 s)]\n  (h : \u03c0.is_stable s) (h' : \u03c0'.is_stable s) :\n  left_inv_on (s.piecewise \u03c0.symm \u03c0'.symm) (s.piecewise \u03c0 \u03c0') (s.ite \u03c0.domain \u03c0'.domain) :=\nbegin\n  rintro x (\u27e8he, hs\u27e9 | \u27e8he, hs : x \u2209 s\u27e9),\n  { rw [piecewise_eq_of_mem _ _ _ hs, piecewise_eq_of_mem _ _ _ ((h he).2 hs), \u03c0.left_inv he] },\n  { rw [piecewise_eq_of_not_mem _ _ _ hs, piecewise_eq_of_not_mem _ _ _ ((h'.compl he).2 hs),\n      \u03c0'.left_inv he] }\nend\n\nlemma inter_eq_of_inter_eq_of_eq_on {\u03c0' : local_perm \u03b1} (h : \u03c0.is_stable s)\n  (h' : \u03c0'.is_stable s) (hs : \u03c0.domain \u2229 s = \u03c0'.domain \u2229 s) (Heq : eq_on \u03c0 \u03c0' (\u03c0.domain \u2229 s)) :\n  \u03c0.domain \u2229 s = \u03c0'.domain \u2229 s :=\nby rw [\u2190 h.image_eq, \u2190 h'.image_eq, \u2190 hs, Heq.image_eq]\n\nlemma symm_eq_on_of_inter_eq_of_eq_on {\u03c0' : local_perm \u03b1} (h : \u03c0.is_stable s)\n  (hs : \u03c0.domain \u2229 s = \u03c0'.domain \u2229 s) (Heq : eq_on \u03c0 \u03c0' (\u03c0.domain \u2229 s)) :\n  eq_on \u03c0.symm \u03c0'.symm (\u03c0.domain \u2229 s) :=\nbegin\n  rw \u2190h.image_eq,\n  rintro y \u27e8x, hx, rfl\u27e9,\n  have hx' := hx, rw hs at hx',\n  rw [\u03c0.left_inv hx.1, Heq hx, \u03c0'.left_inv hx'.1]\nend\n\nend is_stable\n\nlemma image_domain_inter_eq' (s : set \u03b1) :\n  \u03c0 '' (\u03c0.domain \u2229 s) = \u03c0.domain \u2229 \u03c0.symm \u207b\u00b9' s :=\nby rw [inter_comm, \u03c0.left_inv_on.image_inter', image_domain, inter_comm]\n\nlemma image_domain_inter_eq (s : set \u03b1) :\n  \u03c0 '' (\u03c0.domain \u2229 s) = \u03c0.domain \u2229 \u03c0.symm \u207b\u00b9' (\u03c0.domain \u2229 s) :=\nby rw [inter_comm, \u03c0.left_inv_on.image_inter, image_domain, inter_comm]\n\nlemma image_eq_domain_inter_inv_preimage {s : set \u03b1} (h : s \u2286 \u03c0.domain) :\n  \u03c0 '' s = \u03c0.domain \u2229 \u03c0.symm \u207b\u00b9' s :=\nby rw [\u2190 \u03c0.image_domain_inter_eq', inter_eq_self_of_subset_right h]\n\nlemma symm_image_eq_domain_inter_preimage {s : set \u03b1} (h : s \u2286 \u03c0.domain) :\n  \u03c0.symm '' s = \u03c0.domain \u2229 \u03c0 \u207b\u00b9' s :=\n\u03c0.symm.image_eq_domain_inter_inv_preimage h\n\nlemma symm_image_domain_inter_eq (s : set \u03b1) :\n  \u03c0.symm '' (\u03c0.domain \u2229 s) = \u03c0.domain \u2229 \u03c0 \u207b\u00b9' (\u03c0.domain \u2229 s) :=\n\u03c0.symm.image_domain_inter_eq _\n\nlemma symm_image_domain_inter_eq' (s : set \u03b1) : \u03c0.symm '' (\u03c0.domain \u2229 s) = \u03c0.domain \u2229 \u03c0 \u207b\u00b9' s :=\n\u03c0.symm.image_domain_inter_eq' _\n\nlemma domain_inter_preimage_inv_preimage (s : set \u03b1) :\n  \u03c0.domain \u2229 \u03c0 \u207b\u00b9' (\u03c0.symm \u207b\u00b9' s) = \u03c0.domain \u2229 s :=\nset.ext $ \u03bb x, and.congr_right_iff.2 $ \u03bb hx, by simp only [mem_preimage, \u03c0.left_inv hx]\n\nlemma domain_inter_preimage_domain_inter (s : set \u03b1) :\n  \u03c0.domain \u2229 (\u03c0 \u207b\u00b9' (\u03c0.domain \u2229 s)) = \u03c0.domain \u2229 (\u03c0 \u207b\u00b9' s) :=\next $ \u03bb x, \u27e8\u03bb hx, \u27e8hx.1, hx.2.2\u27e9, \u03bb hx, \u27e8hx.1, \u03c0.map_domain hx.1, hx.2\u27e9\u27e9\n\nlemma domain_inter_inv_preimage_preimage (s : set \u03b1) :\n  \u03c0.domain \u2229 \u03c0.symm \u207b\u00b9' (\u03c0 \u207b\u00b9' s) = \u03c0.domain \u2229 s :=\n\u03c0.symm.domain_inter_preimage_inv_preimage _\n\nlemma symm_image_image_of_subset_domain {s : set \u03b1} (h : s \u2286 \u03c0.domain) : \u03c0.symm '' (\u03c0 '' s) = s :=\n(\u03c0.left_inv_on.mono h).image_image\n\nlemma image_symm_image_of_subset_domain {s : set \u03b1} (h : s \u2286 \u03c0.domain) : \u03c0 '' (\u03c0.symm '' s) = s :=\n\u03c0.symm.symm_image_image_of_subset_domain h\n\nvariables {\u03c0 \u03c0'}\n\nlemma domain_subset_preimage_domain : \u03c0.domain \u2286 \u03c0 \u207b\u00b9' \u03c0.domain := \u03c0.maps_to\nlemma symm_image_domain : \u03c0.symm '' \u03c0.domain = \u03c0.domain := \u03c0.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 : \u2200 x, \u03c0 x = \u03c0' x)\n  (hsymm : \u2200 x, \u03c0.symm x = \u03c0'.symm x) (hs : \u03c0.domain = \u03c0'.domain) : \u03c0 = \u03c0' :=\nbegin\n  have A : (\u03c0 : \u03b1 \u2192 \u03b1) = \u03c0', by { ext x, exact h x },\n  have B : (\u03c0.symm : \u03b1 \u2192 \u03b1) = \u03c0'.symm, by { ext x, exact hsymm x },\n  have I : \u03c0 '' \u03c0.domain = \u03c0.domain := \u03c0.image_domain,\n  have I' : \u03c0' '' \u03c0'.domain = \u03c0'.domain := \u03c0'.image_domain,\n  rw [A, hs, I'] at I,\n  cases \u03c0; cases \u03c0',\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 (\u03b1 : Type*) : local_perm \u03b1 := equiv.perm.to_local_perm $ equiv.refl _\n\n@[simp] lemma refl_domain : (local_perm.refl \u03b1).domain = univ := rfl\n@[simp, norm_cast] lemma coe_refl : \u21d1(local_perm.refl \u03b1) = id := rfl\n@[simp] lemma symm_refl : (local_perm.refl \u03b1).symm = local_perm.refl \u03b1 := rfl\n\ninstance : inhabited (local_perm \u03b1) := \u27e8local_perm.refl _\u27e9\n\nvariables (\u03c0 \u03c0')\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 (\u03c0' : local_perm \u03b1) (h : \u03c0.domain = \u03c0'.domain) : local_perm \u03b1 :=\n{ to_fun := \u03c0' \u2218 \u03c0,\n  inv_fun := \u03c0.symm \u2218 \u03c0'.symm,\n  domain := \u03c0.domain,\n  to_fun_domain' := \u03bb x hx, begin\n    rw h,\n    refine map_domain _ _,\n    have := map_domain \u03c0 hx,\n    rwa h at this,\n  end,\n  inv_fun_domain' := \u03bb y hy, map_domain _ begin\n    rw h at hy,\n    have := map_domain \u03c0'.symm hy,\n    rwa [symm_domain, \u2190 h] at this,\n  end,\n  left_inv' := \u03bb x hx, by simp [hx, h.symm],\n  right_inv' := \u03bb y hy, begin\n    simp,\n    rw h at hy,\n    rw [right_inv \u03c0, right_inv \u03c0' hy],\n    have := map_domain \u03c0'.symm hy,\n    rwa [symm_domain, \u2190 h] at this,\n  end }\n\n/-- The identity local equiv on a set `s` -/\ndef of_set (s : set \u03b1) : local_perm \u03b1 :=\n{ to_fun := id,\n  inv_fun := id,\n  domain := s,\n  to_fun_domain' := \u03bb x hx, hx,\n  inv_fun_domain' := \u03bb x hx, hx,\n  left_inv' := \u03bb x hx, rfl,\n  right_inv' := \u03bb x hx, rfl }\n\n@[simp] lemma of_set_domain (s : set \u03b1) : (of_set s).domain = s := rfl\n@[simp, norm_cast] lemma coe_of_set (s : set \u03b1) : (of_set s : \u03b1 \u2192 \u03b1) = id := rfl\n@[simp] lemma of_set_symm (s : set \u03b1) : (of_set s).symm = of_set s := rfl\n@[simp] lemma of_set_trans_of_set (s : set \u03b1) : (of_set s).trans (of_set s) rfl = of_set s := rfl\n@[simp] lemma of_set_univ : of_set univ = local_perm.refl \u03b1 := rfl\n\n/-- Reinterpret a local permutation as a local equivalence. -/\ndef to_local_equiv : local_equiv \u03b1 \u03b1 :=\n{ to_fun := \u03c0,\n  inv_fun := \u03c0.symm,\n  source := \u03c0.domain,\n  target := \u03c0.domain,\n  map_source' := \u03c0.maps_to,\n  map_target' := \u03c0.symm.maps_to,\n  left_inv' := \u03c0.left_inv_on,\n  right_inv' := \u03c0.right_inv_on }\n\n@[simp] lemma coe_to_local_equiv : \u21d1\u03c0.to_local_equiv = \u03c0 := rfl\n@[simp] lemma coe_to_local_equiv_symm : \u21d1\u03c0.to_local_equiv.symm = \u03c0.symm := rfl\n@[simp] lemma to_local_equiv_source : \u03c0.to_local_equiv.source = \u03c0.domain := rfl\n@[simp] lemma to_local_equiv_target : \u03c0.to_local_equiv.target = \u03c0.domain := rfl\n\n@[simp] lemma to_local_equiv_refl : (local_perm.refl \u03b1).to_local_equiv = local_equiv.refl _ := rfl\n@[simp] lemma to_local_equiv_symm : \u03c0.symm.to_local_equiv = \u03c0.to_local_equiv.symm := rfl\n@[simp] lemma to_local_equiv_trans (h) :\n  (\u03c0.trans \u03c0' h).to_local_equiv = \u03c0.to_local_equiv.trans \u03c0'.to_local_equiv :=\nbegin\n  ext,\n  { simp },\n  { simp },\n  { simpa [\u2190h] using \u03bb hx, \u03c0.maps_to hx }\nend\n\n/-- `eq_on_domain \u03c0 \u03c0'` means that `\u03c0` and `\u03c0'` have the same domain, and coincide there. Then `\u03c0`\nand `\u03c0'` should really be considered the same local permutation. -/\ndef eq_on_domain : Prop := \u03c0.domain = \u03c0'.domain \u2227 \u03c0.domain.eq_on \u03c0 \u03c0'\n\n/-- `eq_on_domain` is an equivalence relation -/\ninstance eq_on_domain_setoid : setoid (local_perm \u03b1) :=\n{ r := eq_on_domain,\n  iseqv := \u27e8\n    \u03bb e, by simp [eq_on_domain],\n    \u03bb e e' h, by { simp [eq_on_domain, h.1.symm], exact \u03bb x hx, (h.2 hx).symm },\n    \u03bb e e' e'' h h', \u27e8by rwa [\u2190 h'.1, \u2190 h.1], \u03bb x hx, by { rw [\u2190 h'.2, h.2 hx], rwa \u2190 h.1 }\u27e9\u27e9 }\n\nvariables {\u03c0 \u03c0'}\n\nlemma eq_on_domain_refl : \u03c0 \u2248 \u03c0 := setoid.refl _\n\n/-- Two equivalent local equivs have the same domain -/\nlemma eq_on_domain.domain_eq (h : \u03c0 \u2248 \u03c0') : \u03c0.domain = \u03c0'.domain := h.1\n\n/-- Two equivalent local equivs coincide on the domain -/\nlemma eq_on_domain.eq_on (h : \u03c0 \u2248 \u03c0') : \u03c0.domain.eq_on \u03c0 \u03c0' := h.2\n\n/-- If two local equivs are equivalent, so are their inverses. -/\nlemma eq_on_domain.symm' (h : \u03c0 \u2248 \u03c0') : \u03c0.symm \u2248 \u03c0'.symm :=\nbegin\n  refine \u27e8h.domain_eq, eq_on_of_left_inv_on_of_right_inv_on \u03c0.left_inv_on _ _\u27e9;\n    simp only [symm_domain, h.domain_eq, h.domain_eq, \u03c0'.symm.maps_to],\n  exact \u03c0'.right_inv_on.congr_right \u03c0'.symm.maps_to (h.domain_eq \u25b8 h.eq_on.symm),\n  exact \u03c0'.symm.maps_to,\nend\n\n/-- Two equivalent local equivs have coinciding inverses on the domain -/\nlemma eq_on_domain.symm_eq_on (h : \u03c0 \u2248 \u03c0') : eq_on \u03c0.symm \u03c0'.symm \u03c0.domain := h.symm'.eq_on\n\n/-- Preimages are respected by equivalence -/\nlemma eq_on_domain.domain_inter_preimage_eq (h\u03c0 : \u03c0 \u2248 \u03c0') (s : set \u03b1) :\n  \u03c0.domain \u2229 \u03c0 \u207b\u00b9' s = \u03c0'.domain \u2229 \u03c0' \u207b\u00b9' s :=\nby rw [h\u03c0.eq_on.inter_preimage_eq, h\u03c0.domain_eq]\n\n/-- Two equivalent local equivs are equal when the domain and domain are univ -/\nprotected lemma eq_on_domain.eq (h : \u03c0 \u2248 \u03c0') (h\u03c0 : \u03c0.domain = univ) : \u03c0 = \u03c0' :=\nby apply local_perm.ext (\u03bb x, h.2 _) (\u03bb x, h.symm'.2 _) h.1; simp [h\u03c0]\n\n/-- We define a preorder on local permutations by saying `\u03c0 \u2264 \u03c0'` if the domain of `\u03c0` is contained\nin the domain of `\u03c0'`, and the permutations agree on the domain of `\u03c0`. -/\ninstance : preorder (local_perm \u03b1) :=\n{  le := \u03bb \u03c0 \u03c0', \u03c0.domain \u2286 \u03c0'.domain \u2227 \u03c0.domain.eq_on \u03c0 \u03c0',\n  le_refl := \u03bb a, \u27e8subset_rfl, eq_on_refl _ _\u27e9,\n  le_trans := \u03bb a b c hab hbc, \u27e8hab.1.trans hbc.1, hab.2.trans $ hbc.2.mono hab.1\u27e9 }\n\nlemma domain_mono (h : \u03c0 \u2264 \u03c0') : \u03c0.domain \u2286 \u03c0'.domain := h.1\nlemma eq_on_domain_of_le (h : \u03c0 \u2264 \u03c0') : \u03c0.domain.eq_on \u03c0 \u03c0' := h.2\nlemma le_of_eq_on_domain (h : \u03c0 \u2248 \u03c0') : \u03c0 \u2264 \u03c0' := \u27e8subset_of_eq h.1, h.2\u27e9\nlemma apply_eq_of_le (h : \u03c0 \u2264 \u03c0') {x : \u03b1} (hx : x \u2208 \u03c0.domain) : \u03c0' x = \u03c0 x :=\n(eq_on_domain_of_le h hx).symm\n\nsection piecewise\nvariables (\u03c0 \u03c0') [\u03a0 (j : \u03b1), decidable (j \u2208 \u03c0.domain)] {h : disjoint \u03c0.domain \u03c0'.domain}\n\n/-- Construct a local permutation from two local permutations with disjoint domains. -/\ndef piecewise (h : disjoint \u03c0.domain \u03c0'.domain) : local_perm \u03b1 :=\n{ to_fun := \u03c0.domain.piecewise \u03c0 \u03c0',\n  inv_fun := \u03c0.domain.piecewise \u03c0.symm \u03c0'.symm,\n  domain := \u03c0.domain \u222a \u03c0'.domain,\n  to_fun_domain' := begin\n    rintro x (hx | hx),\n    { rw piecewise_eq_on \u03c0.domain \u03c0 \u03c0' hx,\n      exact or.inl (\u03c0.map_domain hx) },\n    { rw piecewise_eq_on_compl \u03c0.domain \u03c0 \u03c0' (disjoint_right.mp h hx),\n      exact or.inr (\u03c0'.map_domain hx) },\n  end,\n  inv_fun_domain' := begin\n    rintro x (hx | hx),\n    { rw piecewise_eq_on \u03c0.domain \u03c0.symm \u03c0'.symm hx,\n      exact or.inl (\u03c0.symm.map_domain hx) },\n    { rw piecewise_eq_on_compl \u03c0.domain \u03c0.symm \u03c0'.symm (disjoint_right.mp h hx),\n      exact or.inr (\u03c0'.symm.map_domain hx) },\n  end,\n  left_inv' := begin\n    rintro x (hx | hx),\n    { rw [piecewise_eq_on \u03c0.domain \u03c0 \u03c0' hx,\n        piecewise_eq_on \u03c0.domain \u03c0.symm \u03c0'.symm (\u03c0.map_domain hx),\n        \u03c0.left_inv hx] },\n    { rw [piecewise_eq_on_compl \u03c0.domain \u03c0 \u03c0' (disjoint_right.mp h hx),\n        piecewise_eq_on_compl \u03c0.domain \u03c0.symm \u03c0'.symm (disjoint_right.mp h (\u03c0'.map_domain hx)),\n        \u03c0'.left_inv hx] },\n  end,\n  right_inv' := begin\n    rintro x (hx | hx),\n    { rw [piecewise_eq_on \u03c0.domain \u03c0.symm \u03c0'.symm hx,\n        piecewise_eq_on \u03c0.domain \u03c0 \u03c0' (\u03c0.symm.map_domain hx),\n        \u03c0.right_inv hx] },\n    { rw [piecewise_eq_on_compl \u03c0.domain \u03c0.symm \u03c0'.symm (disjoint_right.mp h hx),\n        piecewise_eq_on_compl \u03c0.domain \u03c0 \u03c0' (disjoint_right.mp h (\u03c0'.symm.map_domain hx)),\n        \u03c0'.right_inv hx] },\n  end }\n\nvariables {\u03c0 \u03c0' h}\n\n@[simp] lemma piecewise_domain : (piecewise \u03c0 \u03c0' h).domain = \u03c0.domain \u222a \u03c0'.domain := rfl\nlemma mem_piecewise_domain_left {x : \u03b1} (hx : x \u2208 \u03c0.domain) : x \u2208 (piecewise \u03c0 \u03c0' h).domain :=\nmem_union_left _ hx\nlemma mem_piecewise_domain_right {x : \u03b1} (hx : x \u2208 \u03c0'.domain) : x \u2208 (piecewise \u03c0 \u03c0' h).domain :=\nmem_union_right _ hx\n\nlemma piecewise_apply_eq_left {x : \u03b1} (hx : x \u2208 \u03c0.domain) : piecewise \u03c0 \u03c0' h x = \u03c0 x :=\npiecewise_eq_on _ _ _ hx\n\nlemma piecewise_apply_eq_right {x : \u03b1} (hx : x \u2208 \u03c0'.domain) : piecewise \u03c0 \u03c0' h x = \u03c0' x :=\npiecewise_eq_on_compl _ _ _ (disjoint_right.mp h hx)\n\nlemma le_piecewise_left : \u03c0 \u2264 piecewise \u03c0 \u03c0' h :=\n\u27e8subset_union_left _ _, \u03bb x hx, (piecewise_apply_eq_left hx).symm\u27e9\n\nlemma le_piecewise_right : \u03c0' \u2264 piecewise \u03c0 \u03c0' h :=\n\u27e8subset_union_right _ _, \u03bb x hx, (piecewise_apply_eq_right hx).symm\u27e9\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 \u03b1` and `t : set \u03b1` provides a local permutation on `\u03b1`. -/\n@[simps {fully_applied := ff}]\nnoncomputable def bij_on.to_local_perm [nonempty \u03b1] (f : \u03b1 \u2192 \u03b1) (s : set \u03b1) (hf : bij_on f s s) :\n  local_perm \u03b1 :=\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 (\u03c0 \u03c0' : perm \u03b1)\n\n@[simp] lemma to_local_perm_one : to_local_perm (equiv.refl \u03b1) = local_perm.refl \u03b1 := rfl\n@[simp] lemma to_local_perm_inv : \u03c0\u207b\u00b9.to_local_perm = \u03c0.to_local_perm.symm := rfl\n@[simp] lemma to_local_perm_mul :\n  (\u03c0 * \u03c0').to_local_perm = \u03c0'.to_local_perm.trans \u03c0.to_local_perm rfl :=\nlocal_perm.ext (\u03bb x, rfl) (\u03bb x, rfl) rfl\n\n@[simp] lemma to_local_equiv_to_local_perm : \u03c0.to_local_perm.to_local_equiv = \u03c0.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 {\u03b1 : Sort _} : \u2200 {x y : \u03b1} (hxy : x = y), hxy == @rfl \u03b1 x\n| _ _ rfl := heq.rfl\n\n--- Eliminator of `ite` of predicators.\nlemma ite_pred_iff {\u03b1 : Sort _} {p : Prop} [decidable p] {P : \u03b1 \u2192 Prop} : \u2200 {x y}, (p \u2192 P x) \u2227 (\u00acp \u2192 P y) \u2194 P (ite p x y) :=\n  begin\n    intros x y,\n    split,\n    show _ \u2192 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) \u2192 _, {\n      intros hP,\n      by_cases p,\n      rw [if_pos h] at hP; exact \u27e8(\u03bb _,hP),\u03bb hn, false.elim (hn h)\u27e9,\n      rw [if_neg h] at hP; exact \u27e8false.elim \u2218 h, (\u03bb_,hP)\u27e9\n    }\n  end\n\nlemma whether_of_ite {\u03b1 : Sort _} {p : Prop} [decidable p] {P : \u03b1 \u2192 Prop} : \u2200 {x y}, P (ite p x y) \u2192 P x \u2228 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] {\u03b1 : Type*} : p \u2192 \u2200 (a b : \u03b1), 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] {\u03b1 : Type*} : (\u00acp) \u2192 \u2200 (a b: \u03b1), 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 \u2194 p') \u2192 (q \u2194 q') \u2192 (xor p q \u2194 xor p' q') :=\n  begin\n    intros hp hq,\n    have hnp : \u00acp \u2194 \u00acp', from not_congr hp,\n    have hnq : \u00acq \u2194 \u00acq', from not_congr hq,\n    apply or_congr; apply and_congr; try { assumption },\n  end\n\ndefinition xor_self (p : Prop) : xor p p \u2194 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 \u2194 xor q p :=\n  begin\n    dunfold xor,\n    exact or.comm,\n  end\n\ndefinition false_xor (p : Prop) : xor false p \u2194 p :=\n  begin\n    split,\n    show xor false p \u2192 p, {\n      dunfold xor; intro h; apply or.elim h,\n      exact (false.elim \u2218 and.left),\n      exact and.left\n    },\n    show p \u2192 xor false p, {\n      dunfold xor; intro h,\n      right,\n      exact \u27e8h, false.elim\u27e9\n    }\n  end\n\ndefinition xor_false (p : Prop) : xor p false \u2194 p :=\n  by calc\n    xor p false\n        \u2194 xor false p : xor_comm p false\n    ... \u2194 p : false_xor p\n\nlemma not_or_distrib {p q : Prop} : \u00ac(p\u2228q) \u2194 (\u00acp)\u2227(\u00acq) :=\n  begin\n    constructor,\n    show \u00ac(p\u2228 q) \u2192 (\u00acp)\u2227(\u00acq), {\n      intros hpq,\n      split,\n      show \u00acp, { intros hp, have : p\u2228 q, by left; assumption, contradiction },\n      show \u00acq, { intros hq, have : p\u2228 q, by right; assumption, contradiction },\n    },\n    show (\u00acp)\u2227(\u00acq) \u2192 \u00ac(p\u2228 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 \u2192 q) \u2192 (p \u2227 q \u2194 p) :=\n  \u03bb hpq, iff.intro and.left (\u03bb hp, \u27e8hp,hpq hp\u27e9)\n\nlemma and_iff_right_of_imp {p q : Prop} : (q \u2192 p) \u2192 (p \u2227 q \u2194 q) :=\n  \u03bb hqp, iff.intro and.right (\u03bb hq, \u27e8hqp hq, hq\u27e9)\n\nlemma or_disproof_left {p q : Prop} (hnp : \u00acp) : (p \u2228 q) \u2194 q :=\n  iff.intro (or.rec (by intro; contradiction) id) or.inr\n\nlemma or_disproof_right {p q : Prop} (hnp : \u00acp) : (q\u2228 p) \u2194 q :=\n  iff.intro (or.rec id (by intro; contradiction)) or.inl\n\nlemma or_and_distrib {p q r : Prop} : (p \u2228 q) \u2227 r \u2194 (p \u2227 r) \u2228 (q \u2227 r) :=\n{\n  mp :=\n    \u03bb hpqr,\n      hpqr.left.elim\n        (\u03bb hp, or.inl \u27e8hp,hpqr.right\u27e9)\n        (\u03bb hq, or.inr \u27e8hq,hpqr.right\u27e9),\n  mpr :=\n    \u03bb hprqr,\n      hprqr.elim\n        (\u03bb hpr, \u27e8or.inl hpr.left, hpr.right\u27e9)\n        (\u03bb hqr, \u27e8or.inr hqr.left, hqr.right\u27e9)\n}\n\n--- The equality on \u03a3-type from equality and heterogeneous equality.\nlemma sigma_eq_heq {\u03b1 : Sort _} {\u03b2 : \u03b1 \u2192 Sort _} : \u2200 {x y : sigma \u03b2}, x.fst = y.fst \u2192 x.snd == y.snd \u2192 x = y\n| \u27e8x,hx\u27e9 \u27e8y,hy\u27e9 rfl heq.rfl := rfl\n\n--- Variant of `funext` with heterogeneous dependent domain.\nlemma funext_hdom {\u03b1 : Sort _} {\u03b2 : \u03b1 \u2192 Sort _} {\u03b3 : Sort _} : \u2200 {a\u2081 a\u2082 : \u03b1} {f : \u03b2 a\u2081 \u2192 \u03b3} {g : \u03b2 a\u2082 \u2192 \u03b3}, a\u2081 = a\u2082 \u2192 (\u2200 (x : \u03b2 a\u2081) (y : \u03b2 a\u2082), x == y \u2192 f x = g y) \u2192 f == g\n| _ _ f g rfl hfg := heq_of_eq $ funext (\u03bb 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 \u03b1`: free magma (structure with binary operation without any axioms) over alphabet `\u03b1`,\n  defined inductively, with traversable instance and decidable equality.\n* `MagmaAssocQuotient \u03b1`: quotient of a magma `\u03b1` by the associativity equivalence relation.\n* `FreeSemigroup \u03b1`: free semigroup over alphabet `\u03b1`, defined as a structure with two fields\n  `head : \u03b1` and `tail : list \u03b1` (i.e. nonempty lists), with traversable instance and decidable\n  equality.\n* `FreeMagmaAssocQuotientEquiv \u03b1`: isomorphism between `MagmaAssocQuotient (FreeMagma \u03b1)` and\n  `FreeSemigroup \u03b1`.\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 (\u03b1 : Type u) : Type u\n  | of : \u03b1 \u2192 FreeAddMagma \u03b1\n  | add : FreeAddMagma \u03b1 \u2192 FreeAddMagma \u03b1 \u2192 FreeAddMagma \u03b1\n  deriving DecidableEq\n#align free_add_magma FreeAddMagma\n\n/-- Free magma over a given alphabet. -/\n@[to_additive]\ninductive FreeMagma (\u03b1 : Type u) : Type u\n  | of : \u03b1 \u2192 FreeMagma \u03b1\n  | mul : FreeMagma \u03b1 \u2192 FreeMagma \u03b1 \u2192 FreeMagma \u03b1\n  deriving DecidableEq\n#align free_magma FreeMagma\n\nnamespace FreeMagma\n\nvariable {\u03b1 : Type u}\n\n@[to_additive]\ninstance [Inhabited \u03b1] : Inhabited (FreeMagma \u03b1) := \u27e8of default\u27e9\n\n@[to_additive]\ninstance : Mul (FreeMagma \u03b1) := \u27e8FreeMagma.mul\u27e9\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 \u03b1) : 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 \u03b1 \u2192 Sort l} (x) (ih1 : \u2200 x, C (of x))\n    (ih2 : \u2200 x y, C x \u2192 C y \u2192 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 {\u03b2 : Type v} [Mul \u03b2] {f g : FreeMagma \u03b1 \u2192\u2099* \u03b2} (h : f \u2218 of = g \u2218 of) : f = g :=\n  (FunLike.ext _ _) fun x \u21a6 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 `\u03b1 \u2192 \u03b2` to a magma homomorphism `FreeMagma \u03b1 \u2192 \u03b2` given a magma `\u03b2`. -/\ndef FreeMagma.liftAux {\u03b1 : Type u} {\u03b2 : Type v} [Mul \u03b2] (f : \u03b1 \u2192 \u03b2) : FreeMagma \u03b1 \u2192 \u03b2\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 `\u03b1 \u2192 \u03b2` to an additive magma homomorphism `FreeAddMagma \u03b1 \u2192 \u03b2` given\nan additive magma `\u03b2`. -/\ndef FreeAddMagma.liftAux {\u03b1 : Type u} {\u03b2 : Type v} [Add \u03b2] (f : \u03b1 \u2192 \u03b2) : FreeAddMagma \u03b1 \u2192 \u03b2\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 {\u03b1 : Type u} {\u03b2 : Type v} [Mul \u03b2] (f : \u03b1 \u2192 \u03b2)\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 : (\u03b1 \u2192 \u03b2) \u2243 (FreeMagma \u03b1 \u2192\u2099* \u03b2) where\n  toFun f :=\n  { toFun := liftAux f\n    map_mul' := fun x y \u21a6 rfl }\n  invFun F := F \u2218 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 \u2218 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 \u03b1 \u2192\u2099* \u03b2) : lift (f \u2218 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2)\n\n/-- The unique magma homomorphism `FreeMagma \u03b1 \u2192\u2099* FreeMagma \u03b2` that sends\neach `of x` to `of (f x)`. -/\n@[to_additive \"The unique additive magma homomorphism `FreeAddMagma \u03b1 \u2192 FreeAddMagma \u03b2` that sends\neach `of x` to `of (f x)`.\"]\ndef map (f : \u03b1 \u2192 \u03b2) : FreeMagma \u03b1 \u2192\u2099* FreeMagma \u03b2 := lift (of \u2218 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 {\u03b1 \u03b2 : 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 \u03b1 \u2192 Sort l} (x) (ih1 : \u2200 x, C (pure x))\n    (ih2 : \u2200 x y, C x \u2192 C y \u2192 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 : \u03b1 \u2192 \u03b2) (x) : (f <$> pure x : FreeMagma \u03b2) = pure (f x) := rfl\n#align free_magma.map_pure FreeMagma.map_pure\n\n@[to_additive (attr := simp)]\ntheorem map_mul' (f : \u03b1 \u2192 \u03b2) (x y : FreeMagma \u03b1) : 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 : \u03b1 \u2192 FreeMagma \u03b2) (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 : \u03b1 \u2192 FreeMagma \u03b2) (x y : FreeMagma \u03b1) : 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 {\u03b1 \u03b2 : Type u} {f : \u03b1 \u2192 \u03b2} {x : FreeMagma \u03b1} : pure f <*> x = f <$> x := rfl\n#align free_magma.pure_seq FreeMagma.pure_seq\n\n@[to_additive (attr := simp)]\ntheorem mul_seq {\u03b1 \u03b2 : Type u} {f g : FreeMagma (\u03b1 \u2192 \u03b2)} {x : FreeMagma \u03b1} :\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 \u21a6 rfl)\n  (bind_assoc := fun x f g \u21a6 FreeMagma.recOnPure x (fun x \u21a6 rfl) fun x y ih1 ih2 \u21a6 by\n    rw [mul_bind, mul_bind, mul_bind, ih1, ih2])\n  (id_map := fun x \u21a6 FreeMagma.recOnPure x (fun _ \u21a6 rfl) fun x y ih1 ih2 \u21a6 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 \u2192 Type u} [Applicative m] {\u03b1 \u03b2 : Type u}\n    (F : \u03b1 \u2192 m \u03b2) : FreeMagma \u03b1 \u2192 m (FreeMagma \u03b2)\n  | FreeMagma.of x => FreeMagma.of <$> F x\n  | x * y => (\u00b7 * \u00b7) <$> 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 \u2192 Type u} [Applicative m] {\u03b1 \u03b2 : Type u}\n    (F : \u03b1 \u2192 m \u03b2) : FreeAddMagma \u03b1 \u2192 m (FreeAddMagma \u03b2)\n  | FreeAddMagma.of x => FreeAddMagma.of <$> F x\n  | x + y => (\u00b7 + \u00b7) <$> 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 {\u03b1 : Type u}\n\nsection Category\n\nvariable {\u03b2 : Type u}\n\n@[to_additive]\ninstance : Traversable FreeMagma := \u27e8@FreeMagma.traverse\u27e9\n\nvariable {m : Type u \u2192 Type u} [Applicative m] (F : \u03b1 \u2192 m \u03b2)\n\n@[to_additive (attr := simp)]\ntheorem traverse_pure (x) : traverse F (pure x : FreeMagma \u03b1) = pure <$> F x := rfl\n#align free_magma.traverse_pure FreeMagma.traverse_pure\n\n@[to_additive (attr := simp)]\ntheorem traverse_pure' : traverse F \u2218 pure = fun x \u21a6 (pure <$> F x : m (FreeMagma \u03b2)) := rfl\n#align free_magma.traverse_pure' FreeMagma.traverse_pure'\n\n@[to_additive (attr := simp)]\ntheorem traverse_mul (x y : FreeMagma \u03b1) :\n    traverse F (x * y) = (\u00b7 * \u00b7) <$> 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) \u2218 @Mul.mul (FreeMagma \u03b1) _ = fun x y \u21a6\n      (\u00b7 * \u00b7) <$> 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 \u03b1) :\n    ((\u00b7 * \u00b7) <$> x <*> y : Id (FreeMagma \u03b1)) = (x * y : FreeMagma \u03b1) := 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 \u21a6\n      FreeMagma.recOnPure x (fun x \u21a6 rfl) fun x y ih1 ih2 \u21a6 by\n        rw [traverse_mul, ih1, ih2, mul_map_seq]\n    comp_traverse := fun f g x \u21a6\n      FreeMagma.recOnPure x\n        (fun x \u21a6 by simp only [(. \u2218 .), traverse_pure, traverse_pure', functor_norm])\n        (fun x y ih1 ih2 \u21a6 by\n          rw [traverse_mul, ih1, ih2, traverse_mul];\n          simp [Functor.Comp.map_mk, Functor.map_map, (. \u2218 .), Comp.seq_mk, seq_map_assoc,\n            map_seq, traverse_mul])\n    naturality := fun \u03b7 \u03b1 \u03b2 f x \u21a6\n      FreeMagma.recOnPure x\n        (fun x \u21a6 by simp only [traverse_pure, functor_norm, Function.comp_apply])\n        (fun x y ih1 ih2 \u21a6 by simp only [traverse_mul, functor_norm, ih1, ih2])\n    traverse_eq_map_id := fun f x \u21a6\n      FreeMagma.recOnPure x (fun _ \u21a6 rfl) fun x y ih1 ih2 \u21a6 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 {\u03b1 : Type u} [Repr \u03b1] : FreeMagma \u03b1 \u2192 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 {\u03b1 : Type u} [Repr \u03b1] : FreeAddMagma \u03b1 \u2192 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 {\u03b1 : Type u} [Repr \u03b1] : Repr (FreeMagma \u03b1) := \u27e8fun o _ => FreeMagma.repr o\u27e9\n\n/-- Length of an element of a free magma. -/\ndef FreeMagma.length {\u03b1 : Type u} : FreeMagma \u03b1 \u2192 \u2115\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 {\u03b1 : Type u} : FreeAddMagma \u03b1 \u2192 \u2115\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 (\u03b1 : Type u) [Add \u03b1] : \u03b1 \u2192 \u03b1 \u2192 Prop\n  | intro : \u2200 x y z, AddMagma.AssocRel \u03b1 (x + y + z) (x + (y + z))\n  | left : \u2200 w x y z, AddMagma.AssocRel \u03b1 (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 (\u03b1 : Type u) [Mul \u03b1] : \u03b1 \u2192 \u03b1 \u2192 Prop\n  | intro : \u2200 x y z, Magma.AssocRel \u03b1 (x * y * z) (x * (y * z))\n  | left : \u2200 w x y z, Magma.AssocRel \u03b1 (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 (\u03b1 : Type u) [Mul \u03b1] : Type u :=\n  Quot <| AssocRel \u03b1\n#align magma.assoc_quotient Magma.AssocQuotient\n\nnamespace AssocQuotient\n\nvariable {\u03b1 : Type u} [Mul \u03b1]\n\n@[to_additive]\ntheorem quot_mk_assoc (x y z : \u03b1) : Quot.mk (AssocRel \u03b1) (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 : \u03b1) :\n    Quot.mk (AssocRel \u03b1) (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 \u03b1) where\n  mul x y := by\n    refine' Quot.liftOn\u2082 x y (fun x y \u21a6 Quot.mk _ (x * y)) _ _\n    \u00b7 rintro a b\u2081 b\u2082 (\u27e8c, d, e\u27e9 | \u27e8c, d, e, f\u27e9) <;> simp only\n      \u00b7 exact quot_mk_assoc_left _ _ _ _\n      \u00b7 rw [\u2190 quot_mk_assoc, quot_mk_assoc_left, quot_mk_assoc]\n    \u00b7 rintro a\u2081 a\u2082 b (\u27e8c, d, e\u27e9 | \u27e8c, d, e, f\u27e9) <;> simp only\n      \u00b7 simp only [quot_mk_assoc, quot_mk_assoc_left]\n      \u00b7 rw [quot_mk_assoc, quot_mk_assoc, quot_mk_assoc_left, quot_mk_assoc_left,\n          quot_mk_assoc_left, \u2190 quot_mk_assoc c d, \u2190 quot_mk_assoc c d, quot_mk_assoc_left]\n  mul_assoc x y z :=\n    Quot.induction_on\u2083 x y z fun a b c \u21a6 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 : \u03b1 \u2192\u2099* AssocQuotient \u03b1 := \u27e8Quot.mk _, fun _x _y \u21a6 rfl\u27e9\n#align magma.assoc_quotient.of Magma.AssocQuotient.of\n\n@[to_additive]\ninstance [Inhabited \u03b1] : Inhabited (AssocQuotient \u03b1) := \u27e8of default\u27e9\n\n@[to_additive (attr := elab_as_elim)]\nprotected theorem induction_on {C : AssocQuotient \u03b1 \u2192 Prop} (x : AssocQuotient \u03b1)\n    (ih : \u2200 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 {\u03b2 : Type v} [Semigroup \u03b2] (f : \u03b1 \u2192\u2099* \u03b2)\n\n@[to_additive (attr := ext 1100)]\ntheorem hom_ext {f g : AssocQuotient \u03b1 \u2192\u2099* \u03b2} (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 `\u03b1 \u2192 \u03b2` to a semigroup homomorphism `Magma.AssocQuotient \u03b1 \u2192 \u03b2`\ngiven a semigroup `\u03b2`. -/\n@[to_additive (attr := simps symm_apply) \"Lifts an additive magma homomorphism `\u03b1 \u2192 \u03b2` to an\nadditive semigroup homomorphism `AddMagma.AssocQuotient \u03b1 \u2192 \u03b2` given an additive semigroup `\u03b2`.\"]\ndef lift : (\u03b1 \u2192\u2099* \u03b2) \u2243 (AssocQuotient \u03b1 \u2192\u2099* \u03b2) where\n  toFun f :=\n  { toFun := fun x \u21a6\n      Quot.liftOn x f <| by rintro a b (\u27e8c, d, e\u27e9 | \u27e8c, d, e, f\u27e9) <;> simp only [map_mul, mul_assoc]\n    map_mul' := fun x y \u21a6 Quot.induction_on\u2082 x y (map_mul f) }\n  invFun f := f.comp of\n  left_inv f := (FunLike.ext _ _) fun x \u21a6 rfl\n  right_inv f := hom_ext <| (FunLike.ext _ _) fun x \u21a6 rfl\n#align magma.assoc_quotient.lift Magma.AssocQuotient.lift\n\n@[to_additive (attr := simp)]\ntheorem lift_of (x : \u03b1) : 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 \u03b1 \u2192\u2099* \u03b2) : 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 {\u03b2 : Type v} [Mul \u03b2] (f : \u03b1 \u2192\u2099* \u03b2)\n\n/-- From a magma homomorphism `\u03b1 \u2192\u2099* \u03b2` to a semigroup homomorphism\n`Magma.AssocQuotient \u03b1 \u2192\u2099* Magma.AssocQuotient \u03b2`. -/\n@[to_additive \"From an additive magma homomorphism `\u03b1 \u2192 \u03b2` to an additive semigroup homomorphism\n`AddMagma.AssocQuotient \u03b1 \u2192 AddMagma.AssocQuotient \u03b2`.\"]\ndef map : AssocQuotient \u03b1 \u2192\u2099* AssocQuotient \u03b2 := 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 (\u03b1 : Type u) where\n/-- The head of the element -/\n  head : \u03b1\n/-- The tail of the element -/\n  tail : List \u03b1\n#align free_add_semigroup FreeAddSemigroup\n\n/-- Free semigroup over a given alphabet. -/\n@[to_additive (attr := ext)]\nstructure FreeSemigroup (\u03b1 : Type u) where\n/-- The head of the element -/\n  head : \u03b1\n/-- The tail of the element -/\n  tail : List \u03b1\n#align free_semigroup FreeSemigroup\n\nnamespace FreeSemigroup\n\nvariable {\u03b1 : Type u}\n\n@[to_additive]\ninstance : Semigroup (FreeSemigroup \u03b1) where\n  mul L1 L2 := \u27e8L1.1, L1.2 ++ L2.1 :: L2.2\u27e9\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 \u03b1) : (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 \u03b1) : (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 : \u03b1) (L1 L2 : List \u03b1) : 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 `\u03b1 \u2192 FreeSemigroup \u03b1`. -/\n@[to_additive (attr := simps) \"The embedding `\u03b1 \u2192 free_add_semigroup \u03b1`.\"]\ndef of (x : \u03b1) : FreeSemigroup \u03b1 := \u27e8x, []\u27e9\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 \u03b1) : \u2115 := x.tail.length + 1\n#align free_semigroup.length FreeSemigroup.length\n\n@[to_additive (attr := simp)]\ntheorem length_mul (x y : FreeSemigroup \u03b1) : (x * y).length = x.length + y.length := by\n  simp [length, \u2190 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 : \u03b1) : (of x).length = 1 := rfl\n#align free_semigroup.length_of FreeSemigroup.length_of\n\n@[to_additive]\ninstance [Inhabited \u03b1] : Inhabited (FreeSemigroup \u03b1) := \u27e8of default\u27e9\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 \u03b1 \u2192 Sort l} (x) (ih1 : \u2200 x, C (of x))\n    (ih2 : \u2200 x y, C (of x) \u2192 C y \u2192 C (of x * y)) : C x :=\n      FreeSemigroup.recOn x fun f s \u21a6\n      List.recOn s ih1 (fun hd tl ih f \u21a6 ih2 f \u27e8hd, tl\u27e9 (ih1 f) (ih hd)) f\n#align free_semigroup.rec_on_mul FreeSemigroup.recOnMul\n\n@[to_additive (attr := ext 1100)]\ntheorem hom_ext {\u03b2 : Type v} [Mul \u03b2] {f g : FreeSemigroup \u03b1 \u2192\u2099* \u03b2} (h : f \u2218 of = g \u2218 of) : f = g :=\n  (FunLike.ext _ _) fun x \u21a6\n    FreeSemigroup.recOnMul x (congr_fun h) fun x y hx hy \u21a6 by simp only [map_mul, *]\n#align free_semigroup.hom_ext FreeSemigroup.hom_ext\n\nsection lift\n\nvariable {\u03b2 : Type v} [Semigroup \u03b2] (f : \u03b1 \u2192 \u03b2)\n\n/-- Lifts a function `\u03b1 \u2192 \u03b2` to a semigroup homomorphism `FreeSemigroup \u03b1 \u2192 \u03b2` given\na semigroup `\u03b2`. -/\n@[to_additive (attr := simps symm_apply) \"Lifts a function `\u03b1 \u2192 \u03b2` to an additive semigroup\nhomomorphism `FreeAddSemigroup \u03b1 \u2192 \u03b2` given an additive semigroup `\u03b2`.\"]\ndef lift : (\u03b1 \u2192 \u03b2) \u2243 (FreeSemigroup \u03b1 \u2192\u2099* \u03b2) where\n  toFun f :=\n    { toFun := fun x \u21a6 x.2.foldl (fun a b \u21a6 a * f b) (f x.1)\n      map_mul' := fun x y \u21a6 by\n        simp only [head_mul, tail_mul, \u2190 List.foldl_map f, List.foldl_append, List.foldl_cons,\n          List.foldl_assoc] }\n  invFun f := f \u2218 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 : \u03b1) : 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 \u2218 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 \u03b1 \u2192\u2099* \u03b2) : lift (f \u2218 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 {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2)\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 \u03b1 \u2192\u2099* FreeSemigroup \u03b2 :=\n  lift <| of \u2218 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 \u21a6 rfl) (fun x y hx hy \u21a6 by simp only [map_mul, length_mul, *])\n#align free_semigroup.length_map FreeSemigroup.length_map\n\nend Map\n\nsection Category\n\nvariable {\u03b2 : 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 \u03b1 \u2192 Sort l} (x) (ih1 : \u2200 x, C (pure x))\n    (ih2 : \u2200 x y, C (pure x) \u2192 C y \u2192 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 : \u03b1 \u2192 \u03b2) (x) : (f <$> pure x : FreeSemigroup \u03b2) = pure (f x) := rfl\n#align free_semigroup.map_pure FreeSemigroup.map_pure\n\n@[to_additive (attr := simp)]\ntheorem map_mul' (f : \u03b1 \u2192 \u03b2) (x y : FreeSemigroup \u03b1) : 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 : \u03b1 \u2192 FreeSemigroup \u03b2) (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 : \u03b1 \u2192 FreeSemigroup \u03b2) (x y : FreeSemigroup \u03b1) :\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 : \u03b1 \u2192 \u03b2} {x : FreeSemigroup \u03b1} : 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 (\u03b1 \u2192 \u03b2)} {x : FreeSemigroup \u03b1} :\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 _ _ \u21a6 rfl)\n  (bind_assoc := fun x g f \u21a6\n    recOnPure x (fun x \u21a6 rfl) fun x y ih1 ih2 \u21a6 by rw [mul_bind, mul_bind, mul_bind, ih1, ih2])\n  (id_map := fun x \u21a6 recOnPure x (fun _ \u21a6 rfl) fun x y ih1 ih2 \u21a6 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 \u2192 Type u} [Applicative m] {\u03b1 \u03b2 : Type u}\n    (F : \u03b1 \u2192 m \u03b2) (x : FreeSemigroup \u03b1) : m (FreeSemigroup \u03b2) :=\n  recOnPure x (fun x \u21a6 pure <$> F x) fun _x _y ihx ihy \u21a6 (\u00b7 * \u00b7) <$> ihx <*> ihy\n#align free_semigroup.traverse FreeSemigroup.traverse\n\n@[to_additive]\n-- Porting note: added noncomputable\nnoncomputable instance : Traversable FreeSemigroup := \u27e8@FreeSemigroup.traverse\u27e9\n\nvariable {m : Type u \u2192 Type u} [Applicative m] (F : \u03b1 \u2192 m \u03b2)\n\n@[to_additive (attr := simp)]\ntheorem traverse_pure (x) : traverse F (pure x : FreeSemigroup \u03b1) = pure <$> F x := rfl\n#align free_semigroup.traverse_pure FreeSemigroup.traverse_pure\n\n@[to_additive (attr := simp)]\ntheorem traverse_pure' : traverse F \u2218 pure = fun x \u21a6 (pure <$> F x : m (FreeSemigroup \u03b2)) := 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 \u03b1) :\n    traverse F (x * y) = (\u00b7 * \u00b7) <$> traverse F x <*> traverse F y :=\n  let \u27e8x, L1\u27e9 := x\n  let \u27e8y, L2\u27e9 := y\n  List.recOn L1 (fun x \u21a6 rfl)\n    (fun hd tl ih x \u21a6 show\n        (\u00b7 * \u00b7) <$> pure <$> F x <*> traverse F (mk hd tl * mk y L2) =\n          (\u00b7 * \u00b7) <$> ((\u00b7 * \u00b7) <$> pure <$> F x <*> traverse F (mk hd tl)) <*> traverse F (mk y L2)\n        by rw [ih] ; simp only [(\u00b7 \u2218 \u00b7), (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) \u2218 @Mul.mul (FreeSemigroup \u03b1) _ = fun x y \u21a6\n      (\u00b7 * \u00b7) <$> traverse F x <*> traverse F y := funext fun x \u21a6 funext fun y \u21a6 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 \u03b1) :\n    ((\u00b7 * \u00b7) <$> x <*> y : Id (FreeSemigroup \u03b1)) = (x * y : FreeSemigroup \u03b1) := 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 \u21a6\n      FreeSemigroup.recOnMul x (fun x \u21a6 rfl) fun x y ih1 ih2 \u21a6 by\n        rw [traverse_mul, ih1, ih2, mul_map_seq]\n    comp_traverse := fun f g x \u21a6\n      recOnPure x (fun x \u21a6 by simp only [traverse_pure, functor_norm, (. \u2218 .)])\n        fun x y ih1 ih2 \u21a6 by (rw [traverse_mul, ih1, ih2,\n          traverse_mul, Functor.Comp.map_mk]; simp only [Function.comp, functor_norm, traverse_mul])\n    naturality := fun \u03b7 \u03b1 \u03b2 f x \u21a6\n      recOnPure x (fun x \u21a6 by simp only [traverse_pure, functor_norm, Function.comp])\n          (fun x y ih1 ih2 \u21a6 by simp only [traverse_mul, functor_norm, ih1, ih2])\n    traverse_eq_map_id := fun f x \u21a6\n      FreeSemigroup.recOnMul x (fun _ \u21a6 rfl) fun x y ih1 ih2 \u21a6 by\n        rw [traverse_mul, ih1, ih2, map_mul', mul_map_seq]; rfl }\n\nend Category\n\n@[to_additive]\ninstance [DecidableEq \u03b1] : DecidableEq (FreeSemigroup \u03b1) :=\n  fun _ _ \u21a6 decidable_of_iff' _ (FreeSemigroup.ext_iff _ _)\n\nend FreeSemigroup\n\nnamespace FreeMagma\n\nvariable {\u03b1 : Type u} {\u03b2 : Type v}\n\n/-- The canonical multiplicative morphism from `FreeMagma \u03b1` to `FreeSemigroup \u03b1`. -/\n@[to_additive \"The canonical additive morphism from `FreeAddMagma \u03b1` to `FreeAddSemigroup \u03b1`.\"]\ndef toFreeSemigroup : FreeMagma \u03b1 \u2192\u2099* FreeSemigroup \u03b1 := FreeMagma.lift FreeSemigroup.of\n#align free_magma.to_free_semigroup FreeMagma.toFreeSemigroup\n\n@[to_additive (attr := simp)]\ntheorem toFreeSemigroup_of (x : \u03b1) : 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 \u03b1 \u2218 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 : \u03b1 \u2192 \u03b2) :\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 : \u03b1 \u2192 \u03b2) (x : FreeMagma \u03b1) :\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 \u03b1) : (toFreeSemigroup x).length = x.length :=\n  FreeMagma.recOnMul x (fun x \u21a6 rfl) fun x y hx hy \u21a6 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 \u03b1)` and `FreeSemigroup \u03b1`. -/\n@[to_additive \"Isomorphism between `AddMagma.AssocQuotient (FreeAddMagma \u03b1)` and\n`FreeAddSemigroup \u03b1`.\"]\ndef FreeMagmaAssocQuotientEquiv (\u03b1 : Type u) :\n    Magma.AssocQuotient (FreeMagma \u03b1) \u2243* FreeSemigroup \u03b1 :=\n      (Magma.AssocQuotient.lift FreeMagma.toFreeSemigroup).toMulEquiv\n      (FreeSemigroup.lift (Magma.AssocQuotient.of \u2218 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 \u2964 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 \u2964 K \u2964 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\u2081 v\u2082 u\u2081 u\u2082 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\u2081} [category.{v\u2081} J] {K : Type u\u2082} [category.{v\u2082} K]\n\n@[simp, reassoc]\nlemma limit.lift_\u03c0_app (H : J \u2964 K \u2964 C) [has_limit H] (c : cone H) (j : J) (k : K) :\n  (limit.lift H c).app k \u226b (limit.\u03c0 H j).app k = (c.\u03c0.app j).app k :=\ncongr_app (limit.lift_\u03c0 c j) k\n\n@[simp, reassoc]\nlemma colimit.\u03b9_desc_app (H : J \u2964 K \u2964 C) [has_colimit H] (c : cocone H) (j : J) (k : K) :\n  (colimit.\u03b9 H j).app k \u226b (colimit.desc H c).app k = (c.\u03b9.app j).app k :=\ncongr_app (colimit.\u03b9_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 \u2964 K \u2964 C} (c : cone F)\n  (t : \u03a0 (k : K), is_limit (((evaluation K C).obj k).map_cone c)) : is_limit c :=\n{ lift := \u03bb s,\n  { app := \u03bb k, (t k).lift \u27e8s.X.obj k, whisker_right s.\u03c0 ((evaluation K C).obj k)\u27e9,\n    naturality' := \u03bb X Y f, (t Y).hom_ext $ \u03bb j,\n    begin\n      rw [assoc, (t Y).fac _ j],\n      simpa using\n        ((t X).fac_assoc \u27e8s.X.obj X, whisker_right s.\u03c0 ((evaluation K C).obj X)\u27e9 j _).symm,\n    end },\n  fac' := \u03bb s j, nat_trans.ext _ _ $ funext $ \u03bb k, (t k).fac _ j,\n  uniq' := \u03bb s m w, nat_trans.ext _ _ $ funext $ \u03bb x, (t x).hom_ext $ \u03bb j,\n      (congr_app (w j) x).trans\n        ((t x).fac \u27e8s.X.obj _, whisker_right s.\u03c0 ((evaluation K C).obj _)\u27e9 j).symm }\n\n/--\nGiven a functor `F` and a collection of limit cones for each diagram `X \u21a6 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 \u2964 K \u2964 C) (c : \u03a0 (k : K), limit_cone (F.flip.obj k)) :\n  cone F :=\n{ X :=\n  { obj := \u03bb k, (c k).cone.X,\n    map := \u03bb k\u2081 k\u2082 f, (c k\u2082).is_limit.lift \u27e8_, (c k\u2081).cone.\u03c0 \u226b F.flip.map f\u27e9,\n    map_id' := \u03bb k, (c k).is_limit.hom_ext (\u03bb j, by { dsimp, simp }),\n    map_comp' := \u03bb k\u2081 k\u2082 k\u2083 f\u2081 f\u2082, (c k\u2083).is_limit.hom_ext (\u03bb j, by simp) },\n  \u03c0 :=\n  { app := \u03bb j, { app := \u03bb k, (c k).cone.\u03c0.app j },\n    naturality' := \u03bb j\u2081 j\u2082 g, nat_trans.ext _ _ $ funext $ \u03bb k, (c k).cone.\u03c0.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 \u2964 K \u2964 C) (c : \u03a0 (k : K), limit_cone (F.flip.obj k)) (k : K) :\n  ((evaluation K C).obj k).map_cone (combine_cones F c) \u2245 (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 \u2964 K \u2964 C) (c : \u03a0 (k : K), limit_cone (F.flip.obj k)) :\n  is_limit (combine_cones F c) :=\nevaluation_jointly_reflects_limits _\n  (\u03bb 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 \u2964 K \u2964 C} (c : cocone F)\n  (t : \u03a0 (k : K), is_colimit (((evaluation K C).obj k).map_cocone c)) : is_colimit c :=\n{ desc := \u03bb s,\n  { app := \u03bb k, (t k).desc \u27e8s.X.obj k, whisker_right s.\u03b9 ((evaluation K C).obj k)\u27e9,\n    naturality' := \u03bb X Y f, (t X).hom_ext $ \u03bb j,\n    begin\n      rw [(t X).fac_assoc _ j],\n      erw \u2190 (c.\u03b9.app j).naturality_assoc f,\n      erw (t Y).fac \u27e8s.X.obj _, whisker_right s.\u03b9 _\u27e9 j,\n      dsimp,\n      simp,\n    end },\n  fac' := \u03bb s j, nat_trans.ext _ _ $ funext $ \u03bb k, (t k).fac _ j,\n  uniq' := \u03bb s m w, nat_trans.ext _ _ $ funext $ \u03bb x, (t x).hom_ext $ \u03bb j,\n      (congr_app (w j) x).trans\n        ((t x).fac \u27e8s.X.obj _, whisker_right s.\u03b9 ((evaluation K C).obj _)\u27e9 j).symm }\n\n/--\nGiven a functor `F` and a collection of colimit cocones for each diagram `X \u21a6 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 \u2964 K \u2964 C) (c : \u03a0 (k : K), colimit_cocone (F.flip.obj k)) :\n  cocone F :=\n{ X :=\n  { obj := \u03bb k, (c k).cocone.X,\n    map := \u03bb k\u2081 k\u2082 f, (c k\u2081).is_colimit.desc \u27e8_, F.flip.map f \u226b (c k\u2082).cocone.\u03b9\u27e9,\n    map_id' := \u03bb k, (c k).is_colimit.hom_ext (\u03bb j, by { dsimp, simp }),\n    map_comp' := \u03bb k\u2081 k\u2082 k\u2083 f\u2081 f\u2082, (c k\u2081).is_colimit.hom_ext (\u03bb j, by simp) },\n  \u03b9 :=\n  { app := \u03bb j, { app := \u03bb k, (c k).cocone.\u03b9.app j },\n    naturality' := \u03bb j\u2081 j\u2082 g, nat_trans.ext _ _ $ funext $ \u03bb k, (c k).cocone.\u03b9.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 \u2964 K \u2964 C) (c : \u03a0 (k : K), colimit_cocone (F.flip.obj k)) (k : K) :\n  ((evaluation K C).obj k).map_cocone (combine_cocones F c) \u2245 (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 \u2964 K \u2964 C) (c : \u03a0 (k : K), colimit_cocone (F.flip.obj k)) :\n  is_colimit (combine_cocones F c) :=\nevaluation_jointly_reflects_colimits _\n  (\u03bb 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 \u2964 C) :=\n{ has_limit := \u03bb F, has_limit.mk\n  { cone := combine_cones F (\u03bb 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 \u2964 C) :=\n{ has_colimit := \u03bb F, has_colimit.mk\n  { cocone := combine_cocones _ (\u03bb k, get_colimit_cocone _),\n    is_colimit := combined_is_colimit _ _ } }\n\ninstance functor_category_has_limits_of_size [has_limits_of_size.{v\u2081 u\u2081} C] :\n  has_limits_of_size.{v\u2081 u\u2081} (K \u2964 C) := \u27e8infer_instance\u27e9\n\ninstance functor_category_has_colimits_of_size [has_colimits_of_size.{v\u2081 u\u2081} C] :\n  has_colimits_of_size.{v\u2081 u\u2081} (K \u2964 C) := \u27e8infer_instance\u27e9\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  \u03bb 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 \u2964 K \u2964 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 \u2964 K \u2964 C) (k : K) :\n  (limit F).obj k \u2245 limit (F \u22d9 ((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_\u03c0\n  [has_limits_of_shape J C] (F : J \u2964 (K \u2964 C)) (j : J) (k : K) :\n  (limit_obj_iso_limit_comp_evaluation F k).hom \u226b limit.\u03c0 (F \u22d9 ((evaluation K C).obj k)) j =\n    (limit.\u03c0 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_\u03c0_app\n  [has_limits_of_shape J C] (F : J \u2964 (K \u2964 C)) (j : J) (k : K):\n  (limit_obj_iso_limit_comp_evaluation F k).inv \u226b (limit.\u03c0 F j).app k =\n    limit.\u03c0 (F \u22d9 ((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 \u2964 K \u2964 C) (f : i \u27f6 j) :\n  (limit F).map f \u226b (limit_obj_iso_limit_comp_evaluation _ _).hom =\n  (limit_obj_iso_limit_comp_evaluation _ _).hom \u226b\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 \u2964 K \u2964 C) (f : i \u27f6 j) :\n  (limit_obj_iso_limit_comp_evaluation _ _).inv \u226b (limit F).map f =\n  lim_map (whisker_left _ ((evaluation _ _).map f)) \u226b\n  (limit_obj_iso_limit_comp_evaluation _ _).inv :=\nby rw [iso.inv_comp_eq, \u2190 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 \u2964 K \u2964 C} [has_limits_of_shape J C]\n  {k : K} {W : C} {f g : W \u27f6 (limit H).obj k}\n  (w : \u2200 j, f \u226b (limits.limit.\u03c0 H j).app k = g \u226b (limits.limit.\u03c0 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  \u03bb 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 \u2964 K \u2964 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 \u2964 K \u2964 C) (k : K) :\n  (colimit F).obj k \u2245 colimit (F \u22d9 ((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_\u03b9_inv\n  [has_colimits_of_shape J C] (F : J \u2964 (K \u2964 C)) (j : J) (k : K) :\n  colimit.\u03b9 (F \u22d9 ((evaluation K C).obj k)) j \u226b (colimit_obj_iso_colimit_comp_evaluation F k).inv =\n    (colimit.\u03b9 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_\u03b9_app_hom\n  [has_colimits_of_shape J C] (F : J \u2964 (K \u2964 C)) (j : J) (k : K) :\n  (colimit.\u03b9 F j).app k \u226b (colimit_obj_iso_colimit_comp_evaluation F k).hom =\n     colimit.\u03b9 (F \u22d9 ((evaluation K C).obj k)) j :=\nbegin\n  dsimp [colimit_obj_iso_colimit_comp_evaluation],\n  rw \u2190iso.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 \u2964 K \u2964 C) {i j : K} (f : i \u27f6 j) :\n  (colimit_obj_iso_colimit_comp_evaluation _ _).inv \u226b (colimit F).map f =\n  colim_map (whisker_left _ ((evaluation _ _).map f)) \u226b\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 \u2964 K \u2964 C) {i j : K} (f : i \u27f6 j) :\n  (colimit F).map f \u226b (colimit_obj_iso_colimit_comp_evaluation _ _).hom =\n  (colimit_obj_iso_colimit_comp_evaluation _ _).hom \u226b\n  colim_map (whisker_left _ ((evaluation _ _).map f)) :=\nby rw [\u2190 iso.inv_comp_eq, \u2190 category.assoc, \u2190 iso.eq_comp_inv,\n  colimit_obj_iso_colimit_comp_evaluation_inv_colimit_map]\n\n@[ext]\nlemma colimit_obj_ext {H : J \u2964 K \u2964 C} [has_colimits_of_shape J C]\n  {k : K} {W : C} {f g : (colimit H).obj k \u27f6 W}\n  (w : \u2200 j, (colimit.\u03b9 H j).app k \u226b f = (colimit.\u03b9 H j).app k \u226b 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 := \u03bb J \ud835\udca5, by resetI; apply_instance }\n\n/-- `F : D \u2964 K \u2964 C` preserves the limit of some `G : J \u2964 D` if it does for each `k : K`. -/\ndef preserves_limit_of_evaluation (F : D \u2964 K \u2964 C) (G : J \u2964 D)\n  (H : \u03a0 (k : K), preserves_limit G (F \u22d9 (evaluation K C).obj k : D \u2964 C)) :\n  preserves_limit G F := \u27e8\u03bb c hc,\nbegin\n  apply evaluation_jointly_reflects_limits,\n  intro X,\n  haveI := H X,\n  change is_limit ((F \u22d9 (evaluation K C).obj X).map_cone c),\n  exact preserves_limit.preserves hc,\nend\u27e9\n\n/-- `F : D \u2964 K \u2964 C` preserves limits of shape `J` if it does for each `k : K`. -/\ndef preserves_limits_of_shape_of_evaluation (F : D \u2964 K \u2964 C) (J : Type*) [category J]\n  (H : \u03a0 (k : K), preserves_limits_of_shape J (F \u22d9 (evaluation K C).obj k)) :\n  preserves_limits_of_shape J F :=\n\u27e8\u03bb G, preserves_limit_of_evaluation F G (\u03bb k, preserves_limits_of_shape.preserves_limit)\u27e9\n\n/-- `F : D \u2964 K \u2964 C` preserves all limits if it does for each `k : K`. -/\ndef {w' w} preserves_limits_of_evaluation (F : D \u2964 K \u2964 C)\n  (H : \u03a0 (k : K), preserves_limits_of_size.{w' w} (F \u22d9 (evaluation K C).obj k)) :\n  preserves_limits_of_size.{w' w} F :=\n\u27e8\u03bb L hL, by exactI preserves_limits_of_shape_of_evaluation\n    F L (\u03bb k, preserves_limits_of_size.preserves_limits_of_shape)\u27e9\n\ninstance evaluation_preserves_colimits [has_colimits C] (k : K) :\n  preserves_colimits ((evaluation K C).obj k) :=\n{ preserves_colimits_of_shape := \u03bb J \ud835\udca5, by resetI; apply_instance }\n\n/-- `F : D \u2964 K \u2964 C` preserves the colimit of some `G : J \u2964 D` if it does for each `k : K`. -/\ndef preserves_colimit_of_evaluation (F : D \u2964 K \u2964 C) (G : J \u2964 D)\n  (H : \u03a0 (k), preserves_colimit G (F \u22d9 (evaluation K C).obj k)) : preserves_colimit G F := \u27e8\u03bb c hc,\nbegin\n  apply evaluation_jointly_reflects_colimits,\n  intro X,\n  haveI := H X,\n  change is_colimit ((F \u22d9 (evaluation K C).obj X).map_cocone c),\n  exact preserves_colimit.preserves hc,\nend\u27e9\n\n/-- `F : D \u2964 K \u2964 C` preserves all colimits of shape `J` if it does for each `k : K`. -/\ndef preserves_colimits_of_shape_of_evaluation (F : D \u2964 K \u2964 C) (J : Type*) [category J]\n  (H : \u03a0 (k : K), preserves_colimits_of_shape J (F \u22d9 (evaluation K C).obj k)) :\n  preserves_colimits_of_shape J F :=\n\u27e8\u03bb G, preserves_colimit_of_evaluation F G (\u03bb k, preserves_colimits_of_shape.preserves_colimit)\u27e9\n\n/-- `F : D \u2964 K \u2964 C` preserves all colimits if it does for each `k : K`. -/\ndef {w' w} preserves_colimits_of_evaluation (F : D \u2964 K \u2964 C)\n  (H : \u03a0 (k : K), preserves_colimits_of_size.{w' w} (F \u22d9 (evaluation K C).obj k)) :\n  preserves_colimits_of_size.{w' w} F :=\n\u27e8\u03bb L hL, by exactI preserves_colimits_of_shape_of_evaluation\n    F L (\u03bb k, preserves_colimits_of_size.preserves_colimits_of_shape)\u27e9\nopen category_theory.prod\n\n/-- The limit of a diagram `F : J \u2964 K \u2964 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 \u2964 K \u2964 C) :\n  limit F \u2245 F.flip \u22d9 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 \u2964 J \u2964 C) :\n  limit F.flip \u2245 F \u22d9 lim :=\nnat_iso.of_components (\u03bb k,\n  limit_obj_iso_limit_comp_evaluation F.flip k \u226a\u226b\n  has_limit.iso_of_nat_iso (flip_comp_evaluation _ _)) $ by tidy\n\n/--\nFor a functor `G : J \u2964 K \u2964 C`, its limit `K \u2964 C` is given by `(G' : K \u2964 J \u2964 C) \u22d9 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 \u2964 K \u2964 C) :\n  limit G \u2245 curry.obj (swap K J \u22d9 uncurry.obj G) \u22d9 lim :=\nlimit_iso_flip_comp_lim G \u226a\u226b iso_whisker_right (flip_iso_curry_swap_uncurry _) _\n\n/-- The colimit of a diagram `F : J \u2964 K \u2964 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 \u2964 K \u2964 C) :\n  colimit F \u2245 F.flip \u22d9 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 \u2964 J \u2964 C) :\n  colimit F.flip \u2245 F \u22d9 colim :=\nnat_iso.of_components (\u03bb k,\n  colimit_obj_iso_colimit_comp_evaluation _ _ \u226a\u226b\n  has_colimit.iso_of_nat_iso (flip_comp_evaluation _ _)) $ by tidy\n\n/--\nFor a functor `G : J \u2964 K \u2964 C`, its colimit `K \u2964 C` is given by `(G' : K \u2964 J \u2964 C) \u22d9 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 \u2964 K \u2964 C) :\n  colimit G \u2245 curry.obj (swap K J \u22d9 uncurry.obj G) \u22d9 colim :=\ncolimit_iso_flip_comp_colim G \u226a\u226b 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\u00f6lzl\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 `\u03b1` gets a completion `completion \u03b1` and a morphism\n(ie. uniformly continuous map) `completion : \u03b1 \u2192 completion \u03b1` which solves the universal\nmapping problem of factorizing morphisms from `\u03b1` to any complete Hausdorff uniform space `\u03b2`.\nIt means any uniformly continuous `f : \u03b1 \u2192 \u03b2` gives rise to a unique morphism\n`completion.map f : completion \u03b1 \u2192 \u03b2` such that `f = completion.extension f \u2218 completion \u03b1`.\nActually `completion.extension f` is defined for all maps from `\u03b1` to `\u03b2` but it has the desired\nproperties only if `f` is uniformly continuous.\n\nBeware that `completion \u03b1` is not injective if `\u03b1` 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 `\u03b1` and `\u03b2`, it turns `f : \u03b1 \u2192 \u03b2` into a morphism\n  `completion.map f : completion \u03b1 \u2192 completion \u03b2`\nsuch that\n  `coe \u2218 f = (completion.map f) \u2218 coe`\nprovided `f` is uniformly continuous. This construction is compatible with composition.\n\nIn this file we introduce the following concepts:\n\n* `Cauchy \u03b1` the uniform completion of the uniform space `\u03b1` (using Cauchy filters). These are not\n  minimal filters.\n\n* `completion \u03b1 := quotient (separation_setoid (Cauchy \u03b1))` 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 `\ud835\udce4` := 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 (\u03b1 : Type u) [uniform_space \u03b1] : Type u := { f : filter \u03b1 // cauchy f }\n\nnamespace Cauchy\n\nsection\nparameters {\u03b1 : Type u} [uniform_space \u03b1]\nvariables {\u03b2 : Type v} {\u03b3 : Type w}\nvariables [uniform_space \u03b2] [uniform_space \u03b3]\n\ndef gen (s : set (\u03b1 \u00d7 \u03b1)) : set (Cauchy \u03b1 \u00d7 Cauchy \u03b1) :=\n{p | s \u2208 filter.prod (p.1.val) (p.2.val) }\n\nlemma monotone_gen : monotone gen :=\nmonotone_set_of $ assume p, @monotone_mem_sets (\u03b1\u00d7\u03b1) (filter.prod (p.1.val) (p.2.val))\n\nprivate lemma symm_gen : map prod.swap ((\ud835\udce4 \u03b1).lift' gen) \u2264 (\ud835\udce4 \u03b1).lift' gen :=\ncalc map prod.swap ((\ud835\udce4 \u03b1).lift' gen) =\n  (\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), {p | s \u2208 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  ... \u2264 (\ud835\udce4 \u03b1).lift' gen :\n    uniformity_lift_le_swap\n      (monotone_comp (monotone_set_of $ assume p,\n        @monotone_mem_sets (\u03b1\u00d7\u03b1) ((filter.prod ((p.2).val) ((p.1).val)))) monotone_principal)\n      begin\n        have h := \u03bb(p:Cauchy \u03b1\u00d7Cauchy \u03b1), @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 (\u03b1\u00d7\u03b1)} : comp_rel (gen s) (gen t) \u2286\n  (gen (comp_rel s t) : set (Cauchy \u03b1 \u00d7 Cauchy \u03b1)) :=\nassume \u27e8f, g\u27e9 \u27e8h, h\u2081, h\u2082\u27e9,\nlet \u27e8t\u2081, (ht\u2081 : t\u2081 \u2208 f.val), t\u2082, (ht\u2082 : t\u2082 \u2208 h.val), (h\u2081 : set.prod t\u2081 t\u2082 \u2286 s)\u27e9 :=\n  mem_prod_iff.mp h\u2081 in\nlet \u27e8t\u2083, (ht\u2083 : t\u2083 \u2208 h.val), t\u2084, (ht\u2084 : t\u2084 \u2208 g.val), (h\u2082 : set.prod t\u2083 t\u2084 \u2286 t)\u27e9 :=\n  mem_prod_iff.mp h\u2082 in\nhave t\u2082 \u2229 t\u2083 \u2208 h.val,\n  from inter_mem_sets ht\u2082 ht\u2083,\nlet \u27e8x, xt\u2082, xt\u2083\u27e9 :=\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\u2081 ht\u2084)\n  (assume \u27e8a, b\u27e9 \u27e8(ha : a \u2208 t\u2081), (hb : b \u2208 t\u2084)\u27e9,\n    \u27e8x,\n      h\u2081 (show (a, x) \u2208 set.prod t\u2081 t\u2082, from \u27e8ha, xt\u2082\u27e9),\n      h\u2082 (show (x, b) \u2208 set.prod t\u2083 t\u2084, from \u27e8xt\u2083, hb\u27e9)\u27e9)\n\nprivate lemma comp_gen :\n  ((\ud835\udce4 \u03b1).lift' gen).lift' (\u03bbs, comp_rel s s) \u2264 (\ud835\udce4 \u03b1).lift' gen :=\ncalc ((\ud835\udce4 \u03b1).lift' gen).lift' (\u03bbs, comp_rel s s) =\n    (\ud835\udce4 \u03b1).lift' (\u03bbs, 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  ... \u2264 (\ud835\udce4 \u03b1).lift' (\u03bbs, gen $ comp_rel s s) :\n    lift'_mono' $ assume s hs, comp_rel_gen_gen_subset_gen_comp_rel\n  ... = ((\ud835\udce4 \u03b1).lift' $ \u03bbs:set(\u03b1\u00d7\u03b1), 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  ... \u2264 (\ud835\udce4 \u03b1).lift' gen : lift'_mono comp_le_uniformity (le_refl _)\n\ninstance : uniform_space (Cauchy \u03b1) :=\nuniform_space.of_core\n{ uniformity  := (\ud835\udce4 \u03b1).lift' gen,\n  refl        := principal_le_lift' $ assume s hs \u27e8a, b\u27e9 (a_eq_b : a = b),\n    a_eq_b \u25b8 a.property.right hs,\n  symm        := symm_gen,\n  comp        := comp_gen }\n\ntheorem mem_uniformity {s : set (Cauchy \u03b1 \u00d7 Cauchy \u03b1)} :\n  s \u2208 \ud835\udce4 (Cauchy \u03b1) \u2194 \u2203 t \u2208 \ud835\udce4 \u03b1, gen t \u2286 s :=\nmem_lift'_sets monotone_gen\n\ntheorem mem_uniformity' {s : set (Cauchy \u03b1 \u00d7 Cauchy \u03b1)} :\n  s \u2208 \ud835\udce4 (Cauchy \u03b1) \u2194 \u2203 t \u2208 \ud835\udce4 \u03b1,\n    \u2200 f g : Cauchy \u03b1, t \u2208 filter.prod f.1 g.1 \u2192 (f, g) \u2208 s :=\nmem_uniformity.trans $ bex_congr $ \u03bb t h, prod.forall\n\n/-- Embedding of `\u03b1` into its completion -/\ndef pure_cauchy (a : \u03b1) : Cauchy \u03b1 :=\n\u27e8pure a, cauchy_pure\u27e9\n\nlemma uniform_embedding_pure_cauchy : uniform_embedding (pure_cauchy : \u03b1 \u2192 Cauchy \u03b1) :=\n\u27e8assume a\u2081 a\u2082 h,\n  have (pure_cauchy a\u2081).val = (pure_cauchy a\u2082).val, from congr_arg _ h,\n  have {a\u2081} = ({a\u2082} : set \u03b1),\n    from principal_eq_iff_eq.mp this,\n  by simp at this; assumption,\n\n  have (preimage (\u03bb (x : \u03b1 \u00d7 \u03b1), (pure_cauchy (x.fst), pure_cauchy (x.snd))) \u2218 gen) = id,\n    from funext $ assume s, set.ext $ assume \u27e8a\u2081, a\u2082\u27e9,\n      by simp [preimage, gen, pure_cauchy, prod_principal_principal],\n  calc comap (\u03bb (x : \u03b1 \u00d7 \u03b1), (pure_cauchy (x.fst), pure_cauchy (x.snd))) ((\ud835\udce4 \u03b1).lift' gen)\n        = (\ud835\udce4 \u03b1).lift' (preimage (\u03bb (x : \u03b1 \u00d7 \u03b1), (pure_cauchy (x.fst), pure_cauchy (x.snd))) \u2218 gen) :\n      comap_lift'_eq monotone_gen\n    ... = \ud835\udce4 \u03b1 : by simp [this]\u27e9\n\nlemma pure_cauchy_dense : \u2200x, x \u2208 closure (range pure_cauchy) :=\nassume f,\nhave h_ex : \u2200 s \u2208 \ud835\udce4 (Cauchy \u03b1), \u2203y:\u03b1, (f, pure_cauchy y) \u2208 s, from\n  assume s hs,\n  let \u27e8t'', ht''\u2081, (ht''\u2082 : gen t'' \u2286 s)\u27e9 := (mem_lift'_sets monotone_gen).mp hs in\n  let \u27e8t', ht'\u2081, ht'\u2082\u27e9 := comp_mem_uniformity_sets ht''\u2081 in\n  have t' \u2208 filter.prod (f.val) (f.val),\n    from f.property.right ht'\u2081,\n  let \u27e8t, ht, (h : set.prod t t \u2286 t')\u27e9 := mem_prod_same_iff.mp this in\n  let \u27e8x, (hx : x \u2208 t)\u27e9 := inhabited_of_mem_sets f.property.left ht in\n  have t'' \u2208 filter.prod f.val (pure x),\n    from mem_prod_iff.mpr \u27e8t, ht, {y:\u03b1 | (x, y) \u2208 t'},\n      assume y, begin simp, intro h, simp [h], exact refl_mem_uniformity ht'\u2081 end,\n      assume \u27e8a, b\u27e9 \u27e8(h\u2081 : a \u2208 t), (h\u2082 : (x, b) \u2208 t')\u27e9,\n        ht'\u2082 $ prod_mk_mem_comp_rel (@h (a, x) \u27e8h\u2081, hx\u27e9) h\u2082\u27e9,\n  \u27e8x, ht''\u2082 $ by dsimp [gen]; exact this\u27e9,\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 \u27e8y, hy\u27e9 := h_ex s hs in\n      have pure_cauchy y \u2208 range pure_cauchy \u2229 {y : Cauchy \u03b1 | (f, y) \u2208 s},\n        from \u27e8mem_range_self y, hy\u27e9,\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 \u03b1) \u2194 nonempty \u03b1 :=\nbegin\n  split ; rintro \u27e8c\u27e9,\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 \u27e8_, \u27e8_, a, _\u27e9\u27e9,\n    exact \u27e8a\u27e9 },\n  { exact \u27e8pure_cauchy c\u27e9 }\nend\n\nsection\nset_option eqn_compiler.zeta true\ninstance : complete_space (Cauchy \u03b1) :=\ncomplete_space_extension\n  uniform_embedding_pure_cauchy\n  pure_cauchy_dense $\n  assume f hf,\n  let f' : Cauchy \u03b1 := \u27e8f, hf\u27e9 in\n  have map pure_cauchy f \u2264 (\ud835\udce4 $ Cauchy \u03b1).lift' (preimage (prod.mk f')),\n    from le_lift' $ assume s hs,\n    let \u27e8t, ht\u2081, (ht\u2082 : gen t \u2286 s)\u27e9 := (mem_lift'_sets monotone_gen).mp hs in\n    let \u27e8t', ht', (h : set.prod t' t' \u2286 t)\u27e9 := mem_prod_same_iff.mp (hf.right ht\u2081) in\n    have t' \u2286 { y : \u03b1 | (f', pure_cauchy y) \u2208 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\u2082),\n  \u27e8f', by simp [nhds_eq_uniformity]; assumption\u27e9\nend\n\ninstance [inhabited \u03b1] : inhabited (Cauchy \u03b1) :=\n\u27e8pure_cauchy $ default \u03b1\u27e9\n\ninstance [h : nonempty \u03b1] : nonempty (Cauchy \u03b1) :=\nh.rec_on $ assume a, nonempty.intro $ Cauchy.pure_cauchy a\n\nsection extend\nvariables [_root_.complete_space \u03b2] [separated \u03b2]\n\ndef extend (f : \u03b1 \u2192 \u03b2) : (Cauchy \u03b1 \u2192 \u03b2) :=\nif uniform_continuous f then\n  dense_embedding_pure_cauchy.extend f\nelse\n  \u03bb x, f (classical.inhabited_of_nonempty $ nonempty_Cauchy_iff.1 \u27e8x\u27e9).default\n\nlemma extend_pure_cauchy {f : \u03b1 \u2192 \u03b2} (hf : uniform_continuous f) (a : \u03b1) :\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 : \u03b1 \u2192 \u03b2} : 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  {\u03b1 : Type*} [inhabited \u03b1] [uniform_space \u03b1] [complete_space \u03b1] [separated \u03b1] {f g : Cauchy \u03b1} :\n  lim f.1 = lim g.1 \u2194 (f, g) \u2208 separation_rel (Cauchy \u03b1) :=\nbegin\n  split,\n  { intros e s hs,\n    rcases Cauchy.mem_uniformity'.1 hs with \u27e8t, tu, ts\u27e9,\n    apply ts,\n    rcases comp_mem_uniformity_sets tu with \u27e8d, du, dt\u27e9,\n    refine mem_prod_iff.2\n      \u27e8_, 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), \u03bb x h, _\u27e9,\n    cases x with a b, cases h with h\u2081 h\u2082,\n    rw \u2190 e at h\u2082,\n    exact dt \u27e8_, h\u2081, h\u2082\u27e9 },\n  { intros H,\n    refine separated_def.1 (by apply_instance) _ _ (\u03bb t tu, _),\n    rcases mem_uniformity_is_closed tu with \u27e8d, du, dc, dt\u27e9,\n    refine H {p | (lim p.1.1, lim p.2.1) \u2208 t}\n      (Cauchy.mem_uniformity'.2 \u27e8d, du, \u03bb f g h, _\u27e9),\n    rcases mem_prod_iff.1 h with \u27e8x, xf, y, yg, h\u27e9,\n    have limc : \u2200 (f : Cauchy \u03b1) (x \u2208 f.1), lim f.1 \u2208 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 \u27e8_, _\u27e9); dsimp; apply limc; assumption }\nend\n\nsection\nlocal attribute [instance] uniform_space.separation_setoid\n\nlemma injective_separated_pure_cauchy {\u03b1 : Type*} [uniform_space \u03b1] [s : separated \u03b1] :\n  function.injective (\u03bba:\u03b1, \u27e6pure_cauchy a\u27e7) | a b h :=\nseparated_def.1 s _ _ $ assume s hs,\nlet \u27e8t, ht, hts\u27e9 :=\n  by rw [\u2190 (@uniform_embedding_pure_cauchy \u03b1 _).right, filter.mem_comap_sets] at hs; exact hs in\nhave (pure_cauchy a, pure_cauchy b) \u2208 t, from quotient.exact h t ht,\n@hts (a, b) this\n\nend\n\nsection prod\nvariables {\u03b1 : Type*} {\u03b2 : Type*} [uniform_space \u03b1] [uniform_space \u03b2]\n\ndef prod : Cauchy \u03b1 \u00d7 Cauchy \u03b2 \u2192 Cauchy (\u03b1 \u00d7 \u03b2) :=\ndense_embedding.extend (dense_embedding_pure_cauchy.prod dense_embedding_pure_cauchy) pure_cauchy\n\nlemma prod_pure_cauchy_pure_cauchy (a : \u03b1) (b :\u03b2) :\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 \u03b1 \u03b2 _ _) :=\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 (\u03b1 : Type*) [uniform_space \u03b1]\nvariables {\u03b2 : Type*} [uniform_space \u03b2]\nvariables {\u03b3 : Type*} [uniform_space \u03b3]\n\ninstance complete_space_separation [h : complete_space \u03b1] :\n  complete_space (quotient (separation_setoid \u03b1)) :=\n\u27e8assume f, assume hf : cauchy f,\n  have cauchy (f.comap (\u03bbx, \u27e6x\u27e7)), from\n    cauchy_comap comap_quotient_le_uniformity hf $\n      comap_neq_bot_of_surj hf.left $ assume b, quotient.exists_rep _,\n  let \u27e8x, (hx : f.comap (\u03bbx, \u27e6x\u27e7) \u2264 nhds x)\u27e9 := complete_space.complete this in\n  \u27e8\u27e6x\u27e7, calc f = map (\u03bbx, \u27e6x\u27e7) (f.comap (\u03bbx, \u27e6x\u27e7)) :\n      (map_comap $ univ_mem_sets' $ assume b, quotient.exists_rep _).symm\n    ... \u2264 map (\u03bbx, \u27e6x\u27e7) (nhds x) : map_mono hx\n    ... \u2264 _ : continuous_iff_continuous_at.mp uniform_continuous_quotient_mk.continuous _\u27e9\u27e9\n\n\n/-- Hausdorff completion of `\u03b1` -/\ndef completion := quotient (separation_setoid $ Cauchy \u03b1)\n\nnamespace completion\n\n@[priority 50]\ninstance : uniform_space (completion \u03b1) := by dunfold completion ; apply_instance\n\ninstance : complete_space (completion \u03b1) := by dunfold completion ; apply_instance\n\ninstance : separated (completion \u03b1) := by dunfold completion ; apply_instance\n\ninstance : t2_space (completion \u03b1) := separated_t2\n\ninstance : regular_space (completion \u03b1) := separated_regular\n\n/-- Automatic coercion from `\u03b1` to its completion. Not always injective. -/\ninstance : has_coe \u03b1 (completion \u03b1) := \u27e8quotient.mk \u2218 pure_cauchy\u27e9\n\nprotected lemma coe_eq : (coe : \u03b1 \u2192 completion \u03b1) = quotient.mk \u2218 pure_cauchy := rfl\n\nlemma uniform_continuous_coe : uniform_continuous (coe : \u03b1 \u2192 completion \u03b1) :=\nuniform_continuous.comp uniform_embedding_pure_cauchy.uniform_continuous\n  uniform_continuous_quotient_mk\n\nlemma continuous_coe : continuous (coe : \u03b1 \u2192 completion \u03b1) :=\nuniform_continuous.continuous (uniform_continuous_coe \u03b1)\n\nlemma comap_coe_eq_uniformity :\n  (\ud835\udce4 _).comap (\u03bb(p:\u03b1\u00d7\u03b1), ((p.1 : completion \u03b1), (p.2 : completion \u03b1))) = \ud835\udce4 \u03b1 :=\nbegin\n  have : (\u03bbx:\u03b1\u00d7\u03b1, ((x.1 : completion \u03b1), (x.2 : completion \u03b1))) =\n    (\u03bbx:(Cauchy \u03b1)\u00d7(Cauchy \u03b1), (\u27e6x.1\u27e7, \u27e6x.2\u27e7)) \u2218 (\u03bbx:\u03b1\u00d7\u03b1, (pure_cauchy x.1, pure_cauchy x.2)),\n  { ext \u27e8a, b\u27e9; simp; refl },\n  rw [this, \u2190 filter.comap_comap_comp],\n  change filter.comap _ (filter.comap _ (\ud835\udce4 $ quotient $ separation_setoid $ Cauchy \u03b1)) = \ud835\udce4 \u03b1,\n  rw [comap_quotient_eq_uniformity, uniform_embedding_pure_cauchy.2]\nend\n\n\n\nvariable {\u03b1}\n\nlemma dense : closure (range (coe : \u03b1 \u2192 completion \u03b1)) = univ :=\nby rw [completion.coe_eq, range_comp]; exact quotient_dense_of_dense pure_cauchy_dense\n\nlemma dense_embedding_coe [separated \u03b1]: dense_embedding (coe : \u03b1 \u2192 completion \u03b1) :=\n(uniform_embedding_coe \u03b1).dense_embedding (assume x, by rw [dense]; exact mem_univ _)\n\nlemma dense\u2082 : closure (range (\u03bbx:\u03b1 \u00d7 \u03b2, ((x.1 : completion \u03b1), (x.2 : completion \u03b2)))) = univ :=\nby rw [\u2190 set.prod_range_range_eq, closure_prod_eq, dense, dense, univ_prod_univ]\n\nlemma dense\u2083 :\n  closure (range (\u03bbx:\u03b1 \u00d7 (\u03b2 \u00d7 \u03b3), ((x.1 : completion \u03b1), ((x.2.1 : completion \u03b2), (x.2.2 : completion \u03b3))))) = univ :=\nlet a : \u03b1 \u2192 completion \u03b1 := coe, bc := \u03bbp:\u03b2 \u00d7 \u03b3, ((p.1 : completion \u03b2), (p.2 : completion \u03b3)) in\nshow closure (range (\u03bbx:\u03b1 \u00d7 (\u03b2 \u00d7 \u03b3), (a x.1, bc x.2))) = univ,\nbegin\n  rw [\u2190 set.prod_range_range_eq, @closure_prod_eq _ _ _ _ (range a) (range bc), \u2190 univ_prod_univ],\n  congr,\n  exact dense,\n  exact dense\u2082\nend\n\n@[elab_as_eliminator]\nlemma induction_on {p : completion \u03b1 \u2192 Prop}\n  (a : completion \u03b1) (hp : is_closed {a | p a}) (ih : \u2200a:\u03b1, p a) : p a :=\nis_closed_property dense hp ih a\n\n@[elab_as_eliminator]\nlemma induction_on\u2082 {p : completion \u03b1 \u2192 completion \u03b2 \u2192 Prop}\n  (a : completion \u03b1) (b : completion \u03b2)\n  (hp : is_closed {x : completion \u03b1 \u00d7 completion \u03b2 | p x.1 x.2})\n  (ih : \u2200(a:\u03b1) (b:\u03b2), p a b) : p a b :=\nhave \u2200x : completion \u03b1 \u00d7 completion \u03b2, p x.1 x.2, from\n  is_closed_property dense\u2082 hp $ assume \u27e8a, b\u27e9, ih a b,\nthis (a, b)\n\n@[elab_as_eliminator]\nlemma induction_on\u2083 {p : completion \u03b1 \u2192 completion \u03b2 \u2192 completion \u03b3 \u2192 Prop}\n  (a : completion \u03b1) (b : completion \u03b2) (c : completion \u03b3)\n  (hp : is_closed {x : completion \u03b1 \u00d7 completion \u03b2 \u00d7 completion \u03b3 | p x.1 x.2.1 x.2.2})\n  (ih : \u2200(a:\u03b1) (b:\u03b2) (c:\u03b3), p a b c) : p a b c :=\nhave \u2200x : completion \u03b1 \u00d7 completion \u03b2 \u00d7 completion \u03b3, p x.1 x.2.1 x.2.2, from\n  is_closed_property dense\u2083 hp $ assume \u27e8a, b, c\u27e9, ih a b c,\nthis (a, b, c)\n\n@[elab_as_eliminator]\nlemma induction_on\u2084 {\u03b4 : Type*} [uniform_space \u03b4]\n  {p : completion \u03b1 \u2192 completion \u03b2 \u2192 completion \u03b3 \u2192 completion \u03b4 \u2192 Prop}\n  (a : completion \u03b1) (b : completion \u03b2) (c : completion \u03b3) (d : completion \u03b4)\n  (hp : is_closed {x : (completion \u03b1 \u00d7 completion \u03b2) \u00d7 (completion \u03b3 \u00d7 completion \u03b4) | p x.1.1 x.1.2 x.2.1 x.2.2})\n  (ih : \u2200(a:\u03b1) (b:\u03b2) (c:\u03b3) (d : \u03b4), p \u2191a \u2191b \u2191c \u2191d) : p a b c d :=\nlet\n  ab := \u03bbp:\u03b1 \u00d7 \u03b2, ((p.1 : completion \u03b1), (p.2 : completion \u03b2)),\n  cd := \u03bbp:\u03b3 \u00d7 \u03b4, ((p.1 : completion \u03b3), (p.2 : completion \u03b4))\nin\nhave dense\u2084 : closure (range (\u03bbx:(\u03b1 \u00d7 \u03b2) \u00d7 (\u03b3 \u00d7 \u03b4), (ab x.1, cd x.2))) = univ,\nbegin\n  rw [\u2190 set.prod_range_range_eq, @closure_prod_eq _ _ _ _ (range ab) (range cd), \u2190 univ_prod_univ],\n  congr,\n  exact dense\u2082,\n  exact dense\u2082\nend,\nhave \u2200x:(completion \u03b1 \u00d7 completion \u03b2) \u00d7 (completion \u03b3 \u00d7 completion \u03b4), p x.1.1 x.1.2 x.2.1 x.2.2, from\n  is_closed_property dense\u2084 hp (assume p:(\u03b1\u00d7\u03b2)\u00d7(\u03b3\u00d7\u03b4), ih p.1.1 p.1.2 p.2.1 p.2.2),\nthis ((a, b), (c, d))\n\nlemma ext [t2_space \u03b2] {f g : completion \u03b1 \u2192 \u03b2} (hf : continuous f) (hg : continuous g)\n  (h : \u2200a:\u03b1, f a = g a) : f = g :=\nfunext $ assume a, completion.induction_on a (is_closed_eq hf hg) h\n\nsection extension\nvariables {f : \u03b1 \u2192 \u03b2}\nvariables [complete_space \u03b2] [separated \u03b2]\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 : \u03b1 \u2192 \u03b2) : completion \u03b1 \u2192 \u03b2 :=\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 : \u03b1) : (completion.extension f) a = f a :=\nextend_pure_cauchy hf a\n\nend extension\n\nsection map\nvariables {f : \u03b1 \u2192 \u03b2}\n\n/-- Completion functor acting on morphisms -/\nprotected def map (f : \u03b1 \u2192 \u03b2) : completion \u03b1 \u2192 completion \u03b2 :=\ncompletion.extension (coe \u2218 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 : \u03b1) : (completion.map f) a = f a :=\nby rw [completion.map, extension_coe]; from hf.comp (uniform_continuous_coe \u03b2)\n\nlemma map_unique {f : \u03b1 \u2192 \u03b2} {g : completion \u03b1 \u2192 completion \u03b2}\n  (hg : uniform_continuous g) (h : \u2200a:\u03b1, \u2191(f a) = g a) : completion.map f = g :=\ncompletion.ext continuous_map hg.continuous $\nbegin\n  intro a,\n  simp only [completion.map, (\u2218), h],\n  rw [extension_coe ((uniform_continuous_coe \u03b1).comp hg)]\nend\n\nlemma map_id : completion.map (@id \u03b1) = id :=\nmap_unique uniform_continuous_id (assume a, rfl)\n\nlemma extension_map [complete_space \u03b3] [separated \u03b3] {f : \u03b2 \u2192 \u03b3} {g : \u03b1 \u2192 \u03b2}\n  (hf : uniform_continuous f) (hg : uniform_continuous g) :\n  completion.extension f \u2218 completion.map g = completion.extension (f \u2218 g) :=\ncompletion.ext (continuous_map.comp continuous_extension) continuous_extension $\n  by intro a; simp only [hg, hf, hg.comp hf, (\u2218), map_coe, extension_coe]\n\nlemma map_comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hf : uniform_continuous f) (hg : uniform_continuous g) :\n  completion.map g \u2218 completion.map f = completion.map (g \u2218 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 (\u03b1 : Type u) [uniform_space \u03b1] :\n  completion (separation_quotient \u03b1) \u2243 completion \u03b1 :=\nbegin\n  refine \u27e8completion.extension (separation_quotient.lift (coe : \u03b1 \u2192 completion \u03b1)),\n    completion.map quotient.mk, _, _\u27e9,\n  { assume a,\n    refine completion.induction_on a (is_closed_eq (continuous_extension.comp continuous_map) continuous_id) _,\n    rintros \u27e8a\u27e9,\n    show completion.map quotient.mk (completion.extension (separation_quotient.lift coe) \u2191\u27e6a\u27e7) = \u2191\u27e6a\u27e7,\n    rw [extension_coe (separation_quotient.uniform_continuous_lift _),\n      separation_quotient.lift_mk (uniform_continuous_coe \u03b1),\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 \u03b1) _] }\nend\n\nlemma uniform_continuous_completion_separation_quotient_equiv :\n  uniform_continuous \u21d1(completion_separation_quotient_equiv \u03b1) :=\nuniform_continuous_extension\n\nlemma uniform_continuous_completion_separation_quotient_equiv_symm :\n  uniform_continuous \u21d1(completion_separation_quotient_equiv \u03b1).symm :=\nuniform_continuous_map\n\nend separation_quotient_completion\n\nsection prod\nvariables [uniform_space \u03b2]\nprotected def prod {\u03b1 \u03b2} [uniform_space \u03b1] [uniform_space \u03b2] (p : completion \u03b1 \u00d7 completion \u03b2) : completion (\u03b1 \u00d7 \u03b2) :=\nquotient.lift_on\u2082 p.1 p.2 (\u03bba b, \u27e6Cauchy.prod (a, b)\u27e7) $ assume a b c d hab hcd,\n  quotient.sound $ separated_of_uniform_continuous uniform_continuous_prod $\n  separation_prod.2 \u27e8hab, hcd\u27e9\n\nlemma uniform_continuous_prod : uniform_continuous (@completion.prod \u03b1 \u03b2 _ _) :=\nuniform_continuous_quotient_lift\u2082 $\n  suffices uniform_continuous (quotient.mk \u2218 Cauchy.prod),\n  { convert this, ext \u27e8a, b\u27e9, refl },\n  Cauchy.uniform_continuous_prod.comp uniform_continuous_quotient_mk\n\nlemma prod_coe_coe (a : \u03b1) (b : \u03b2) :\n  completion.prod ((a : completion \u03b1), (b : completion \u03b2)) = (a, b) :=\ncongr_arg quotient.mk $ Cauchy.prod_pure_cauchy_pure_cauchy a b\n\nend prod\n\nsection map\u2082\n\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : completion \u03b1) (b : completion \u03b2) : completion \u03b3 :=\ncompletion.map (\u03bbp:\u03b1\u00d7\u03b2, f p.1 p.2) (completion.prod (a, b))\n\nlemma uniform_continuous_map\u2082' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :\n  uniform_continuous (\u03bbp:completion \u03b1\u00d7completion \u03b2, completion.map\u2082 f p.1 p.2) :=\nuniform_continuous.comp uniform_continuous_prod completion.uniform_continuous_map\n\nlemma continuous_map\u2082 {\u03b4} [topological_space \u03b4] {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n  {a : \u03b4 \u2192 completion \u03b1} {b : \u03b4 \u2192 completion \u03b2} (ha : continuous a) (hb : continuous b) :\n  continuous (\u03bbd:\u03b4, completion.map\u2082 f (a d) (b d)) :=\n(continuous.prod_mk ha hb).comp (uniform_continuous_map\u2082' f).continuous\n\nlemma map\u2082_coe_coe (a : \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hf : uniform_continuous (\u03bbp:\u03b1\u00d7\u03b2, f p.1 p.2)) :\n  completion.map\u2082 f (a : completion \u03b1) (b : completion \u03b2) = f a b :=\nby rw [completion.map\u2082, completion.prod_coe_coe, completion.map_coe hf]\n\nend map\u2082\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] {\u03b9 : Type u_4} (s : finset \u03b9) (p : \u03b9 \u2192 P) (b : P) : linear_map k (\u03b9 \u2192 k) V :=\n  finset.sum s fun (i : \u03b9) => linear_map.smul_right (linear_map.proj i) (p i -\u1d65 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (b : P) : coe_fn (weighted_vsub_of_point s p b) w = finset.sum s fun (i : \u03b9) => w i \u2022 (p i -\u1d65 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (h : (finset.sum s fun (i : \u03b9) => w i) = 0) (b\u2081 : P) (b\u2082 : P) : coe_fn (weighted_vsub_of_point s p b\u2081) w = coe_fn (weighted_vsub_of_point s p b\u2082) 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (h : (finset.sum s fun (i : \u03b9) => w i) = 1) (b\u2081 : P) (b\u2082 : P) : coe_fn (weighted_vsub_of_point s p b\u2081) w +\u1d65 b\u2081 = coe_fn (weighted_vsub_of_point s p b\u2082) w +\u1d65 b\u2082 := 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (i : \u03b9) : 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (i : \u03b9) : 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] {\u03b9 : Type u_4} (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (b : P) {s\u2081 : finset \u03b9} {s\u2082 : finset \u03b9} (h : s\u2081 \u2286 s\u2082) : coe_fn (weighted_vsub_of_point s\u2081 p b) w = coe_fn (weighted_vsub_of_point s\u2082 p b) (set.indicator (\u2191s\u2081) 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] {\u03b9 : Type u_4} {\u03b9\u2082 : Type u_5} (s\u2082 : finset \u03b9\u2082) (e : \u03b9\u2082 \u21aa \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (b : P) : coe_fn (weighted_vsub_of_point (map e s\u2082) p b) w = coe_fn (weighted_vsub_of_point s\u2082 (p \u2218 \u21d1e) b) (w \u2218 \u21d1e) := 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] {\u03b9 : Type u_4} (s : finset \u03b9) (p : \u03b9 \u2192 P) : linear_map k (\u03b9 \u2192 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) : coe_fn (weighted_vsub s p) w = finset.sum s fun (i : \u03b9) => w i \u2022 (p i -\u1d65 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (h : (finset.sum s fun (i : \u03b9) => 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] {\u03b9 : Type u_4} (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) : coe_fn (weighted_vsub \u2205 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] {\u03b9 : Type u_4} (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) {s\u2081 : finset \u03b9} {s\u2082 : finset \u03b9} (h : s\u2081 \u2286 s\u2082) : coe_fn (weighted_vsub s\u2081 p) w = coe_fn (weighted_vsub s\u2082 p) (set.indicator (\u2191s\u2081) 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] {\u03b9 : Type u_4} {\u03b9\u2082 : Type u_5} (s\u2082 : finset \u03b9\u2082) (e : \u03b9\u2082 \u21aa \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) : coe_fn (weighted_vsub (map e s\u2082) p) w = coe_fn (weighted_vsub s\u2082 (p \u2218 \u21d1e)) (w \u2218 \u21d1e) :=\n  weighted_vsub_of_point_map s\u2082 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] {\u03b9 : Type u_4} (s : finset \u03b9) (p : \u03b9 \u2192 P) : affine_map k (\u03b9 \u2192 k) P :=\n  affine_map.mk\n    (fun (w : \u03b9 \u2192 k) => coe_fn (weighted_vsub_of_point s p (Classical.choice sorry)) w +\u1d65 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] {\u03b9 : Type u_4} (s : finset \u03b9) (p : \u03b9 \u2192 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) : coe_fn (affine_combination s p) w =\n  coe_fn (weighted_vsub_of_point s p (Classical.choice add_torsor.nonempty)) w +\u1d65 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) (h : (finset.sum s fun (i : \u03b9) => w i) = 1) (b : P) : coe_fn (affine_combination s p) w = coe_fn (weighted_vsub_of_point s p b) w +\u1d65 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w\u2081 : \u03b9 \u2192 k) (w\u2082 : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) : coe_fn (weighted_vsub s p) w\u2081 +\u1d65 coe_fn (affine_combination s p) w\u2082 = coe_fn (affine_combination s p) (w\u2081 + w\u2082) := 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w\u2081 : \u03b9 \u2192 k) (w\u2082 : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) : coe_fn (affine_combination s p) w\u2081 -\u1d65 coe_fn (affine_combination s p) w\u2082 = coe_fn (weighted_vsub s p) (w\u2081 - w\u2082) := 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) {i : \u03b9} (his : i \u2208 s) (hwi : w i = 1) (hw0 : \u2200 (i2 : \u03b9), i2 \u2208 s \u2192 i2 \u2260 i \u2192 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] {\u03b9 : Type u_4} (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) {s\u2081 : finset \u03b9} {s\u2082 : finset \u03b9} (h : s\u2081 \u2286 s\u2082) : coe_fn (affine_combination s\u2081 p) w = coe_fn (affine_combination s\u2082 p) (set.indicator (\u2191s\u2081) 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] {\u03b9 : Type u_4} {\u03b9\u2082 : Type u_5} (s\u2082 : finset \u03b9\u2082) (e : \u03b9\u2082 \u21aa \u03b9) (w : \u03b9 \u2192 k) (p : \u03b9 \u2192 P) : coe_fn (affine_combination (map e s\u2082) p) w = coe_fn (affine_combination s\u2082 (p \u2218 \u21d1e)) (w \u2218 \u21d1e) := 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] {\u03b9 : Type u_4} {v : V} {x : k} {s : set \u03b9} {p : \u03b9 \u2192 P} {b : P} : (\u2203 (fs : finset \u03b9),\n    \u2203 (hfs : \u2191fs \u2286 s),\n      \u2203 (w : \u03b9 \u2192 k), \u2203 (hw : (finset.sum fs fun (i : \u03b9) => w i) = x), v = coe_fn (weighted_vsub_of_point fs p b) w) \u2194\n  \u2203 (fs : finset \u21a5s),\n    \u2203 (w : \u21a5s \u2192 k),\n      \u2203 (hw : (finset.sum fs fun (i : \u21a5s) => w i) = x),\n        v = coe_fn (weighted_vsub_of_point fs (fun (i : \u21a5s) => p \u2191i) 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] {\u03b9 : Type u_4} {v : V} {s : set \u03b9} {p : \u03b9 \u2192 P} : (\u2203 (fs : finset \u03b9),\n    \u2203 (hfs : \u2191fs \u2286 s),\n      \u2203 (w : \u03b9 \u2192 k), \u2203 (hw : (finset.sum fs fun (i : \u03b9) => w i) = 0), v = coe_fn (weighted_vsub fs p) w) \u2194\n  \u2203 (fs : finset \u21a5s),\n    \u2203 (w : \u21a5s \u2192 k),\n      \u2203 (hw : (finset.sum fs fun (i : \u21a5s) => w i) = 0), v = coe_fn (weighted_vsub fs fun (i : \u21a5s) => p \u2191i) 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] {\u03b9 : Type u_4} {p0 : P} {s : set \u03b9} {p : \u03b9 \u2192 P} : (\u2203 (fs : finset \u03b9),\n    \u2203 (hfs : \u2191fs \u2286 s),\n      \u2203 (w : \u03b9 \u2192 k), \u2203 (hw : (finset.sum fs fun (i : \u03b9) => w i) = 1), p0 = coe_fn (affine_combination fs p) w) \u2194\n  \u2203 (fs : finset \u21a5s),\n    \u2203 (w : \u21a5s \u2192 k),\n      \u2203 (hw : (finset.sum fs fun (i : \u21a5s) => w i) = 1), p0 = coe_fn (affine_combination fs fun (i : \u21a5s) => p \u2191i) 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] {\u03b9 : Type u_4} (s : finset \u03b9) : \u03b9 \u2192 k :=\n  function.const \u03b9 (\u2191(card s)\u207b\u00b9)\n\n/-- `centroid_weights` at any point. -/\n@[simp] theorem centroid_weights_apply (k : Type u_1) [division_ring k] {\u03b9 : Type u_4} (s : finset \u03b9) (i : \u03b9) : centroid_weights k s i = (\u2191(card s)\u207b\u00b9) :=\n  rfl\n\n/-- `centroid_weights` equals a constant function. -/\ntheorem centroid_weights_eq_const (k : Type u_1) [division_ring k] {\u03b9 : Type u_4} (s : finset \u03b9) : centroid_weights k s = function.const \u03b9 (\u2191(card s)\u207b\u00b9) :=\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] {\u03b9 : Type u_4} (s : finset \u03b9) (h : \u2191(card s) \u2260 0) : (finset.sum s fun (i : \u03b9) => 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] {\u03b9 : Type u_4} (s : finset \u03b9) [char_zero k] (h : card s \u2260 0) : (finset.sum s fun (i : \u03b9) => 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] {\u03b9 : Type u_4} (s : finset \u03b9) [char_zero k] (h : finset.nonempty s) : (finset.sum s fun (i : \u03b9) => 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] {\u03b9 : Type u_4} (s : finset \u03b9) [char_zero k] {n : \u2115} (h : card s = n + 1) : (finset.sum s fun (i : \u03b9) => centroid_weights k s i) = 1 :=\n  sum_centroid_weights_eq_one_of_card_ne_zero k s (Eq.symm h \u25b8 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] {\u03b9 : Type u_4} (s : finset \u03b9) (p : \u03b9 \u2192 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] {\u03b9 : Type u_4} (s : finset \u03b9) (p : \u03b9 \u2192 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] {\u03b9 : Type u_4} (p : \u03b9 \u2192 P) (i : \u03b9) : 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] {\u03b9 : Type u_4} [invertible (bit0 1)] (p : \u03b9 \u2192 P) (i\u2081 : \u03b9) (i\u2082 : \u03b9) : centroid k (insert i\u2081 (singleton i\u2082)) p = bit0 1\u207b\u00b9 \u2022 (p i\u2082 -\u1d65 p i\u2081) +\u1d65 p i\u2081 := 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) \u2192 P) : centroid k univ p = bit0 1\u207b\u00b9 \u2022 (p 1 -\u1d65 p 0) +\u1d65 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] {\u03b9 : Type u_4} {\u03b9\u2082 : Type u_5} (s\u2082 : finset \u03b9\u2082) (e : \u03b9\u2082 \u21aa \u03b9) (p : \u03b9 \u2192 P) : centroid k (map e s\u2082) p = centroid k s\u2082 (p \u2218 \u21d1e) := 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] {\u03b9 : Type u_4} (s : finset \u03b9) : \u03b9 \u2192 k :=\n  set.indicator (\u2191s) (centroid_weights k s)\n\n/-- The definition of `centroid_weights_indicator`. -/\ntheorem centroid_weights_indicator_def (k : Type u_1) [division_ring k] {\u03b9 : Type u_4} (s : finset \u03b9) : centroid_weights_indicator k s = set.indicator (\u2191s) (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] {\u03b9 : Type u_4} (s : finset \u03b9) [fintype \u03b9] : (finset.sum univ fun (i : \u03b9) => centroid_weights_indicator k s i) = finset.sum s fun (i : \u03b9) => centroid_weights k s i :=\n  Eq.symm (set.sum_indicator_subset (fun (i : \u03b9) => 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] {\u03b9 : Type u_4} (s : finset \u03b9) [char_zero k] [fintype \u03b9] (h : card s \u2260 0) : (finset.sum univ fun (i : \u03b9) => 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] {\u03b9 : Type u_4} (s : finset \u03b9) [char_zero k] [fintype \u03b9] (h : finset.nonempty s) : (finset.sum univ fun (i : \u03b9) => 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] {\u03b9 : Type u_4} (s : finset \u03b9) [char_zero k] [fintype \u03b9] {n : \u2115} (h : card s = n + 1) : (finset.sum univ fun (i : \u03b9) => 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] {\u03b9 : Type u_4} (s : finset \u03b9) [fintype \u03b9] (p : \u03b9 \u2192 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] {\u03b9 : Type u_4} (s : finset \u03b9) {p : \u03b9 \u2192 P} (hi : \u2200 (i j : \u03b9), i \u2208 s \u2192 j \u2208 s \u2192 p i = p j \u2192 i = j) {ps : set P} [fintype \u21a5ps] (hps : ps = p '' \u2191s) : centroid k s p = centroid k univ fun (x : \u21a5ps) => \u2191x := 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] {\u03b9 : Type u_4} (s : finset \u03b9) {\u03b9\u2082 : Type u_5} (s\u2082 : finset \u03b9\u2082) {p : \u03b9 \u2192 P} (hi : \u2200 (i j : \u03b9), i \u2208 s \u2192 j \u2208 s \u2192 p i = p j \u2192 i = j) {p\u2082 : \u03b9\u2082 \u2192 P} (hi\u2082 : \u2200 (i j : \u03b9\u2082), i \u2208 s\u2082 \u2192 j \u2208 s\u2082 \u2192 p\u2082 i = p\u2082 j \u2192 i = j) (he : p '' \u2191s = p\u2082 '' \u2191s\u2082) : centroid k s p = centroid k s\u2082 p\u2082 := 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] {\u03b9 : Type u_4} {s : finset \u03b9} {w : \u03b9 \u2192 k} (h : (finset.sum s fun (i : \u03b9) => w i) = 0) (p : \u03b9 \u2192 P) : coe_fn (finset.weighted_vsub s p) w \u2208 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] {\u03b9 : Type u_4} [nontrivial k] {s : finset \u03b9} {w : \u03b9 \u2192 k} (h : (finset.sum s fun (i : \u03b9) => w i) = 1) (p : \u03b9 \u2192 P) : coe_fn (finset.affine_combination s p) w \u2208 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] {\u03b9 : Type u_4} {v : V} {p : \u03b9 \u2192 P} : v \u2208 vector_span k (set.range p) \u2194\n  \u2203 (s : finset \u03b9),\n    \u2203 (w : \u03b9 \u2192 k), \u2203 (h : (finset.sum s fun (i : \u03b9) => 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] {\u03b9 : Type u_4} {p1 : P} {p : \u03b9 \u2192 P} (h : p1 \u2208 affine_span k (set.range p)) : \u2203 (s : finset \u03b9),\n  \u2203 (w : \u03b9 \u2192 k), \u2203 (hw : (finset.sum s fun (i : \u03b9) => 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] {\u03b9 : Type u_4} [nontrivial k] {p1 : P} {p : \u03b9 \u2192 P} : p1 \u2208 affine_span k (set.range p) \u2194\n  \u2203 (s : finset \u03b9),\n    \u2203 (w : \u03b9 \u2192 k), \u2203 (hw : (finset.sum s fun (i : \u03b9) => 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] {\u03b9 : Type u_4} {s : finset \u03b9} (p : \u03b9 \u2192 P) (h : \u2191(finset.card s) \u2260 0) : finset.centroid k s p \u2208 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] {\u03b9 : Type u_4} [char_zero k] {s : finset \u03b9} (p : \u03b9 \u2192 P) (h : finset.card s \u2260 0) : finset.centroid k s p \u2208 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] {\u03b9 : Type u_4} [char_zero k] {s : finset \u03b9} (p : \u03b9 \u2192 P) (h : finset.nonempty s) : finset.centroid k s p \u2208 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] {\u03b9 : Type u_4} [char_zero k] {s : finset \u03b9} (p : \u03b9 \u2192 P) {n : \u2115} (h : finset.card s = n + 1) : finset.centroid k s p \u2208 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] {\u03b9 : Type u_4} (s : finset \u03b9) (w : \u03b9 \u2192 k) : affine_map k ((\u03b9 \u2192 P) \u00d7 P) V :=\n  mk (fun (p : (\u03b9 \u2192 P) \u00d7 P) => coe_fn (finset.weighted_vsub_of_point s (prod.fst p) (prod.snd p)) w)\n    (finset.sum s\n      fun (i : \u03b9) =>\n        w i \u2022 (linear_map.comp (linear_map.proj i) (linear_map.fst k (\u03b9 \u2192 V) V) - linear_map.snd k (\u03b9 \u2192 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 \u03b1` is the type of\nunbounded computations returning `\u03b1`.\n-/\n\n\nopen Function\n\nuniverse u v w\n\n/-\ncoinductive Computation (\u03b1 : Type u) : Type u\n| pure : \u03b1 \u2192 Computation \u03b1\n| think : Computation \u03b1 \u2192 Xomputation \u03b1\n-/\n/-- `Computation \u03b1` is the type of unbounded computations returning `\u03b1`.\n  An element of `Computation \u03b1` is an infinite sequence of `Option \u03b1` such\n  that if `f n = some a` for some `n` then it is constantly `some a` after that. -/\ndef Computation (\u03b1 : Type u) : Type u :=\n  { f : Stream' (Option \u03b1) // \u2200 \u2983n a\u2984, f n = some a \u2192 f (n + 1) = some a }\n#align computation Computation\n\nnamespace Computation\n\nvariable {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : 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 : \u03b1) : Computation \u03b1 :=\n  \u27e8Stream'.const (some a), fun _ _ => id\u27e9\n#align computation.return Computation.pure\n\ninstance : CoeTC \u03b1 (Computation \u03b1) :=\n  \u27e8pure\u27e9\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 \u03b1) : Computation \u03b1 :=\n  \u27e8Stream'.cons none c.1, fun n a h => by\n    cases' n with n\n    . contradiction\n    . exact c.2 h\u27e9\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 \u03b1) : \u2115 \u2192 Computation \u03b1\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 \u03b1) : Option \u03b1 :=\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 \u03b1) : Computation \u03b1 :=\n  \u27e8c.1.tail, fun _ _ h => c.2 h\u27e9\n#align computation.tail Computation.tail\n\n/-- `empty \u03b1` is the computation that never returns, an infinite sequence of\n  `think`s. -/\ndef empty (\u03b1) : Computation \u03b1 :=\n  \u27e8Stream'.const none, fun _ _ => id\u27e9\n#align computation.empty Computation.empty\n\ninstance : Inhabited (Computation \u03b1) :=\n  \u27e8empty _\u27e9\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 \u03b1 \u2192 \u2115 \u2192 Option \u03b1 :=\n  Subtype.val\n#align computation.run_for Computation.runFor\n\n/-- `destruct c` is the destructor for `Computation \u03b1` as a coinductive type.\n  It returns `inl a` if `c = pure a` and `inr c'` if `c = think c'`. -/\ndef destruct (c : Computation \u03b1) : Sum \u03b1 (Computation \u03b1) :=\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 \u03b1 \u2192 \u03b1\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 \u03b1} {a : \u03b1} : destruct s = Sum.inl a \u2192 s = pure a := by\n  dsimp [destruct]\n  induction' f0 : s.1 0 with _ <;> intro h\n  \u00b7 contradiction\n  \u00b7 apply Subtype.eq\n    funext n\n    induction' n with n IH\n    \u00b7 injection h with h'\n      rwa [h'] at f0\n    \u00b7 exact s.2 IH\n#align computation.destruct_eq_ret Computation.destruct_eq_pure\n\ntheorem destruct_eq_think {s : Computation \u03b1} {s'} : destruct s = Sum.inr s' \u2192 s = think s' := by\n  dsimp [destruct]\n  induction' f0 : s.1 0 with a' <;> intro h\n  \u00b7 injection h with h'\n    rw [\u2190 h']\n    cases' s with f al\n    apply Subtype.eq\n    dsimp [think, tail]\n    rw [\u2190 f0]\n    exact (Stream'.eta f).symm\n  \u00b7 contradiction\n#align computation.destruct_eq_think Computation.destruct_eq_think\n\n@[simp]\ntheorem destruct_pure (a : \u03b1) : destruct (pure a) = Sum.inl a :=\n  rfl\n#align computation.destruct_ret Computation.destruct_pure\n\n@[simp]\ntheorem destruct_think : \u2200 s : Computation \u03b1, destruct (think s) = Sum.inr s\n  | \u27e8_, _\u27e9 => rfl\n#align computation.destruct_think Computation.destruct_think\n\n@[simp]\ntheorem destruct_empty : destruct (empty \u03b1) = Sum.inr (empty \u03b1) :=\n  rfl\n#align computation.destruct_empty Computation.destruct_empty\n\n@[simp]\ntheorem head_pure (a : \u03b1) : head (pure a) = some a :=\n  rfl\n#align computation.head_ret Computation.head_pure\n\n@[simp]\ntheorem head_think (s : Computation \u03b1) : head (think s) = none :=\n  rfl\n#align computation.head_think Computation.head_think\n\n@[simp]\ntheorem head_empty : head (empty \u03b1) = none :=\n  rfl\n#align computation.head_empty Computation.head_empty\n\n@[simp]\ntheorem tail_pure (a : \u03b1) : tail (pure a) = pure a :=\n  rfl\n#align computation.tail_ret Computation.tail_pure\n\n@[simp]\ntheorem tail_think (s : Computation \u03b1) : 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 \u03b1) = empty \u03b1 :=\n  rfl\n#align computation.tail_empty Computation.tail_empty\n\ntheorem think_empty : empty \u03b1 = think (empty \u03b1) :=\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 \u03b1 \u2192 Sort v} (s : Computation \u03b1) (h1 : \u2200 a, C (pure a))\n    (h2 : \u2200 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      | \u27e8a, s'\u27e9 => 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 : \u03b2 \u2192 Sum \u03b1 \u03b2) : Sum \u03b1 \u03b2 \u2192 Option \u03b1 \u00d7 Sum \u03b1 \u03b2\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 \u03b1` 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 : \u03b2 \u2192 Sum \u03b1 \u03b2) (b : \u03b2) : Computation \u03b1 := by\n  refine' \u27e8Stream'.corec' (Corec.f f) (Sum.inr b), fun n a' h => _\u27e9\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  \u00b7 change (Corec.f f o).1 = some a' \u2192 (Corec.f f (Corec.f f o).2).1 = some a'\n    cases' o with _ b <;> intro h\n    \u00b7 exact h\n    unfold Corec.f at *; split <;> simp_all\n  \u00b7 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 `\u2295` -/\ndef lmap (f : \u03b1 \u2192 \u03b2) : Sum \u03b1 \u03b3 \u2192 Sum \u03b2 \u03b3\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 `\u2295` -/\ndef rmap (f : \u03b2 \u2192 \u03b3) : Sum \u03b1 \u03b2 \u2192 Sum \u03b1 \u03b3\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 \u03b1 \u2295 \u03b2 \u2192 option \u03b1.\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 : \u03b2 \u2192 Sum \u03b1 \u03b2) (b : \u03b2) : 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 (\u03bb _ => 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'; \u00b7 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 \u03b1 \u2192 Computation \u03b1 \u2192 Prop)\n\n-- mathport name: \u00abexpr ~ \u00bb\n/-- bisimilarity relation-/\nlocal infixl:50 \" ~ \" => R\n\n/-- Bisimilarity over a sum of `Computation`s-/\ndef BisimO : Sum \u03b1 (Computation \u03b1) \u2192 Sum \u03b1 (Computation \u03b1) \u2192 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  \u2200 \u2983s\u2081 s\u2082\u2984, s\u2081 ~ s\u2082 \u2192 BisimO R (destruct s\u2081) (destruct s\u2082)\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\u2081 s\u2082} (r : s\u2081 ~ s\u2082) : s\u2081 = s\u2082 := by\n  apply Subtype.eq\n  apply Stream'.eq_of_bisim fun x y => \u2203 s s' : Computation \u03b1, s.1 = x \u2227 s'.1 = y \u2227 R s s'\n  dsimp [Stream'.IsBisimulation]\n  intro t\u2081 t\u2082 e\n  exact\n    match t\u2081, t\u2082, e with\n    | _, _, \u27e8s, s', rfl, rfl, r\u27e9 => by\n      suffices head s = head s' \u2227 R (tail s) (tail s') from\n        And.imp id (fun r => \u27e8tail s, tail s', by cases s; rfl, by cases s'; rfl, r\u27e9) this\n      have h := bisim r; revert r h\n      apply recOn s _ _ <;> intro r' <;> apply recOn s' _ _ <;> intro a' r h\n      \u00b7 constructor <;> dsimp at h\n        . rw [h]\n        . rw [h] at r\n          rw [tail_pure, tail_pure,h]\n          assumption\n      \u00b7 rw [destruct_pure, destruct_think] at h\n        exact False.elim h\n      \u00b7 rw [destruct_pure, destruct_think] at h\n        exact False.elim h\n      \u00b7 simp at h\n        simp [*]\n  exact \u27e8s\u2081, s\u2082, rfl, rfl, r\u27e9\n#align computation.eq_of_bisim Computation.eq_of_bisim\n\nend Bisim\n\n-- It's more of a stretch to use \u2208 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 : \u03b1) (s : Computation \u03b1) :=\n  some a \u2208 s.1\n#align computation.mem Computation.Mem\n\ninstance : Membership \u03b1 (Computation \u03b1) :=\n  \u27e8Computation.Mem\u27e9\n\ntheorem le_stable (s : Computation \u03b1) {a m n} (h : m \u2264 n) : s.1 m = some a \u2192 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 \u03b1} {a b : \u03b1} : a \u2208 s \u2192 b \u2208 s \u2192 a = b\n  | \u27e8m, ha\u27e9, \u27e8n, hb\u27e9 => 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 ((\u00b7 \u2208 \u00b7) : \u03b1 \u2192 Computation \u03b1 \u2192 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 \u03b1) : Prop where\n  /-- assertion that there is some term `a` such that the `Computation` terminates -/\n  term : \u2203 a, a \u2208 s\n#align computation.terminates Computation.Terminates\n\ntheorem terminates_iff (s : Computation \u03b1) : Terminates s \u2194 \u2203 a, a \u2208 s :=\n  \u27e8fun h => h.1, Terminates.mk\u27e9\n#align computation.terminates_iff Computation.terminates_iff\n\ntheorem terminates_of_mem {s : Computation \u03b1} {a : \u03b1} (h : a \u2208 s) : Terminates s :=\n  \u27e8\u27e8a, h\u27e9\u27e9\n#align computation.terminates_of_mem Computation.terminates_of_mem\n\ntheorem terminates_def (s : Computation \u03b1) : Terminates s \u2194 \u2203 n, (s.1 n).isSome :=\n  \u27e8fun \u27e8\u27e8a, n, h\u27e9\u27e9 =>\n    \u27e8n, by\n      dsimp [Stream'.nth] at h\n      rw [\u2190 h]\n      exact rfl\u27e9,\n    fun \u27e8n, h\u27e9 => \u27e8\u27e8Option.get _ h, n, (Option.eq_some_of_isSome h).symm\u27e9\u27e9\u27e9\n#align computation.terminates_def Computation.terminates_def\n\ntheorem ret_mem (a : \u03b1) : a \u2208 pure a :=\n  Exists.intro 0 rfl\n#align computation.ret_mem Computation.ret_mem\n\ntheorem eq_of_pure_mem {a a' : \u03b1} (h : a' \u2208 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 : \u03b1) : Terminates (pure a) :=\n  terminates_of_mem (ret_mem _)\n#align computation.ret_terminates Computation.ret_terminates\n\ntheorem think_mem {s : Computation \u03b1} {a} : a \u2208 s \u2192 a \u2208 think s\n  | \u27e8n, h\u27e9 => \u27e8n + 1, h\u27e9\n#align computation.think_mem Computation.think_mem\n\ninstance think_terminates (s : Computation \u03b1) : \u2200 [Terminates s], Terminates (think s)\n  | \u27e8\u27e8a, n, h\u27e9\u27e9 => \u27e8\u27e8a, n + 1, h\u27e9\u27e9\n#align computation.think_terminates Computation.think_terminates\n\ntheorem of_think_mem {s : Computation \u03b1} {a} : a \u2208 think s \u2192 a \u2208 s\n  | \u27e8n, h\u27e9 => by\n    cases' n with n'\n    contradiction\n    exact \u27e8n', h\u27e9\n#align computation.of_think_mem Computation.of_think_mem\n\ntheorem of_think_terminates {s : Computation \u03b1} : Terminates (think s) \u2192 Terminates s\n  | \u27e8\u27e8a, h\u27e9\u27e9 => \u27e8\u27e8a, of_think_mem h\u27e9\u27e9\n#align computation.of_think_terminates Computation.of_think_terminates\n\ntheorem not_mem_empty (a : \u03b1) : a \u2209 empty \u03b1 := fun \u27e8n, h\u27e9 => by contradiction\n#align computation.not_mem_empty Computation.not_mem_empty\n\ntheorem not_terminates_empty : \u00acTerminates (empty \u03b1) := fun \u27e8\u27e8a, h\u27e9\u27e9 => not_mem_empty a h\n#align computation.not_terminates_empty Computation.not_terminates_empty\n\ntheorem eq_empty_of_not_terminates {s} (H : \u00acTerminates s) : s = empty \u03b1 := by\n  apply Subtype.eq; funext n\n  induction' h : s.val n with _ ; \u00b7 rfl\n  refine' absurd _ H; exact \u27e8\u27e8_, _, h.symm\u27e9\u27e9\n#align computation.eq_empty_of_not_terminates Computation.eq_empty_of_not_terminates\n\ntheorem thinkN_mem {s : Computation \u03b1} {a} : \u2200 n, a \u2208 thinkN s n \u2194 a \u2208 s\n  | 0 => Iff.rfl\n  | n + 1 => Iff.trans \u27e8of_think_mem, think_mem\u27e9 (thinkN_mem n)\nset_option linter.uppercaseLean3 false in\n#align computation.thinkN_mem Computation.thinkN_mem\n\ninstance thinkN_terminates (s : Computation \u03b1) : \u2200 [Terminates s] (n), Terminates (thinkN s n)\n  | \u27e8\u27e8a, h\u27e9\u27e9, n => \u27e8\u27e8a, (thinkN_mem n).2 h\u27e9\u27e9\nset_option linter.uppercaseLean3 false in\n#align computation.thinkN_terminates Computation.thinkN_terminates\n\ntheorem of_thinkN_terminates (s : Computation \u03b1) (n) : Terminates (thinkN s n) \u2192 Terminates s\n  | \u27e8\u27e8a, h\u27e9\u27e9 => \u27e8\u27e8a, (thinkN_mem _).1 h\u27e9\u27e9\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 \u03b1) (a : \u03b1) : Prop :=\n  \u2200 \u2983a'\u2984, a' \u2208 s \u2192 a = a'\n#align computation.promises Computation.Promises\n\n-- mathport name: \u00abexpr ~> \u00bb\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 \u03b1} {a : \u03b1} : a \u2208 s \u2192 s ~> a := fun h _ => mem_unique h\n#align computation.mem_promises Computation.mem_promises\n\ntheorem empty_promises (a : \u03b1) : empty \u03b1 ~> a := fun _ h => absurd h (not_mem_empty _)\n#align computation.empty_promises Computation.empty_promises\n\nsection get\n\nvariable (s : Computation \u03b1) [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 : \u2115 :=\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 : \u03b1 :=\n  Option.get _ (Nat.find_spec <| (terminates_def _).1 h)\n#align computation.get Computation.get\n\ntheorem get_mem : get s \u2208 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 \u2208 s \u2192 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 \u2192 a \u2208 s := by intro h ; rw [\u2190 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 \u27e8n, h\u27e9 := get_mem s\n    \u27e8n + 1, h\u27e9\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 \u2208 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 \u2192 get s = a :=\n  get_eq_of_mem _ \u2218 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 \u03b1) (a : \u03b1) (n : \u2115) :=\n  \u2203 h : a \u2208 s, @length _ s (terminates_of_mem h) = n\n#align computation.results Computation.Results\n\ntheorem results_of_terminates (s : Computation \u03b1) [_T : Terminates s] :\n    Results s (get s) (length s) :=\n  \u27e8get_mem _, rfl\u27e9\n#align computation.results_of_terminates Computation.results_of_terminates\n\ntheorem results_of_terminates' (s : Computation \u03b1) [T : Terminates s] {a} (h : a \u2208 s) :\n    Results s a (length s) := by rw [\u2190 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 \u03b1} {a n} : Results s a n \u2192 a \u2208 s\n  | \u27e8m, _\u27e9 => m\n#align computation.results.mem Computation.Results.mem\n\ntheorem Results.terminates {s : Computation \u03b1} {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 \u03b1} {a n} [_T : Terminates s] : Results s a n \u2192 length s = n\n  | \u27e8_, h\u27e9 => h\n#align computation.results.length Computation.Results.length\n\ntheorem Results.val_unique {s : Computation \u03b1} {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 \u03b1} {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 [\u2190 h1.length, h2.length]\n#align computation.results.len_unique Computation.Results.len_unique\n\ntheorem exists_results_of_mem {s : Computation \u03b1} {a} (h : a \u2208 s) : \u2203 n, Results s a n :=\n  haveI := terminates_of_mem h\n  \u27e8_, results_of_terminates' s h\u27e9\n#align computation.exists_results_of_mem Computation.exists_results_of_mem\n\n@[simp]\ntheorem get_pure (a : \u03b1) : get (pure a) = a :=\n  get_eq_of_mem _ \u27e80, rfl\u27e9\n#align computation.get_ret Computation.get_pure\n\n@[simp]\ntheorem length_pure (a : \u03b1) : 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 : \u03b1) : Results (pure a) a 0 :=\n  \u27e8ret_mem a, length_pure _\u27e9\n#align computation.results_ret Computation.results_pure\n\n@[simp]\ntheorem length_think (s : Computation \u03b1) [h : Terminates s] : length (think s) = length s + 1 := by\n  apply le_antisymm\n  \u00b7 exact Nat.find_min' _ (Nat.find_spec ((terminates_def _).1 h))\n  \u00b7 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    \u00b7 simp [think, Stream'.cons] at this\n    \u00b7 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 \u03b1} {a n} (h : Results s a n) : Results (think s) a (n + 1) :=\n  haveI := h.terminates\n  \u27e8think_mem h.mem, by rw [length_think, h.length]\u27e9\n#align computation.results_think Computation.results_think\n\ntheorem of_results_think {s : Computation \u03b1} {a n} (h : Results (think s) a n) :\n    \u2203 m, Results s a m \u2227 n = m + 1 := by\n  haveI := of_think_terminates h.terminates\n  have := results_of_terminates' _ (of_think_mem h.mem)\n  exact \u27e8_, this, Results.len_unique h (results_think this)\u27e9\n#align computation.of_results_think Computation.of_results_think\n\n@[simp]\ntheorem results_think_iff {s : Computation \u03b1} {a n} : Results (think s) a (n + 1) \u2194 Results s a n :=\n  \u27e8fun h => by\n    let \u27e8n', r, e\u27e9 := of_results_think h\n    injection e with h' ; rw [Nat.add, Nat.add] at h'; rwa [h'], results_think\u27e9\n#align computation.results_think_iff Computation.results_think_iff\n\ntheorem results_thinkN {s : Computation \u03b1} {a m} :\n    \u2200 n, Results s a m \u2192 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 : \u03b1) (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 \u03b1) [_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 \u03b1} {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  \u00b7 rw [\u2190 eq_of_pure_mem h.mem]\n    rfl\n  \u00b7 cases' of_results_think h with n h\n    cases h\n    contradiction\n  \u00b7 have := h.len_unique (results_pure _)\n    contradiction\n  \u00b7 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 \u03b1) [_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 \u03b1 \u2192 Sort v} {a s} (M : a \u2208 s) (h1 : C (pure a))\n    (h2 : \u2200 s, C s \u2192 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 \u03b1 \u2192 Sort v}\n    (s) [Terminates s]\n    (h1 : \u2200 a, C (pure a))\n    (h2 : \u2200 s, C s \u2192 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 : \u03b1 \u2192 \u03b2) : Computation \u03b1 \u2192 Computation \u03b2\n  | \u27e8s, al\u27e9 =>\n    \u27e8s.map fun o => Option.casesOn o none (some \u2218 f), fun n b => by\n      dsimp [Stream'.map, Stream'.nth]\n      induction' e : s n with a <;> intro h\n      . contradiction\n      \u00b7 rw [al e]; exact h\u27e9\n#align computation.map Computation.map\n\n/-- bind over a `Sum` of `Computation`-/\ndef Bind.g : Sum \u03b2 (Computation \u03b2) \u2192 Sum \u03b2 (Sum (Computation \u03b1) (Computation \u03b2))\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 `\u03b1` to a `Computation`-/\ndef Bind.f (f : \u03b1 \u2192 Computation \u03b2) :\n    Sum (Computation \u03b1) (Computation \u03b2) \u2192 Sum \u03b2 (Sum (Computation \u03b1) (Computation \u03b2))\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 \u03b1) (f : \u03b1 \u2192 Computation \u03b2) : Computation \u03b2 :=\n  corec (Bind.f f) (Sum.inl c)\n#align computation.bind Computation.bind\n\ninstance : Bind Computation :=\n  \u27e8@bind\u27e9\n\ntheorem has_bind_eq_bind {\u03b2} (c : Computation \u03b1) (f : \u03b1 \u2192 Computation \u03b2) : 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 \u03b1)) : Computation \u03b1 :=\n  c >>= id\n#align computation.join Computation.join\n\n@[simp]\ntheorem map_pure (f : \u03b1 \u2192 \u03b2) (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 : \u03b1 \u2192 \u03b2) : \u2200 s, map f (think s) = think (map f s)\n  | \u27e8s, al\u27e9 => 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 : \u03b1 \u2192 \u03b2) (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 : \u2200 s : Computation \u03b1, map id s = s\n  | \u27e8f, al\u27e9 => by\n    apply Subtype.eq ; simp [map, Function.comp]\n    have e : @Option.rec \u03b1 (fun _ => Option \u03b1) none some = id := by ext \u27e8\u27e9 <;> rfl\n    have h : ((fun x: Option \u03b1 => x) = id) := by rfl\n    simp [e, h, Stream'.map_id]\n#align computation.map_id Computation.map_id\n\ntheorem map_comp (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) : \u2200 s : Computation \u03b1, map (g \u2218 f) s = map g (map f s)\n  | \u27e8s, al\u27e9 => by\n    apply Subtype.eq ; dsimp [map]\n    rw [Stream'.map_map]\n    apply congr_arg fun f : _ \u2192 Option \u03b3 => Stream'.map f s\n    ext \u27e8\u27e9 <;> rfl\n#align computation.map_comp Computation.map_comp\n\n@[simp]\ntheorem ret_bind (a) (f : \u03b1 \u2192 Computation \u03b2) : bind (pure a) f = f a := by\n  apply\n    eq_of_bisim fun c\u2081 c\u2082 => c\u2081 = bind (pure a) f \u2227 c\u2082 = f a \u2228 c\u2081 = corec (Bind.f f) (Sum.inr c\u2082)\n  \u00b7 intro c\u2081 c\u2082 h\n    exact\n      match c\u2081, c\u2082, h with\n      | _, _, Or.inl \u27e8rfl, rfl\u27e9 => 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  \u00b7 simp\n#align computation.ret_bind Computation.ret_bind\n\n@[simp]\ntheorem think_bind (c) (f : \u03b1 \u2192 Computation \u03b2) : 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 : \u03b1 \u2192 \u03b2) (s) : bind s (pure \u2218 f) = map f s := by\n  apply eq_of_bisim fun c\u2081 c\u2082 => c\u2081 = c\u2082 \u2228 \u2203 s, c\u2081 = bind s (pure \u2218 f) \u2227 c\u2082 = map f s\n  \u00b7 intro c\u2081 c\u2082 h\n    exact\n      match c\u2081, c\u2082, h with\n      | _, c\u2082, Or.inl (Eq.refl _) => by cases' destruct c\u2082 with b cb <;> simp\n      | _, _, Or.inr \u27e8s, rfl, rfl\u27e9 => by\n        apply recOn s <;> intro s <;> simp\n        exact Or.inr \u27e8s, rfl, rfl\u27e9\n  \u00b7 exact Or.inr \u27e8s, rfl, rfl\u27e9\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 \u03b1) : bind s pure = s := by\n  apply eq_of_bisim fun c\u2081 c\u2082 => c\u2081 = c\u2082 \u2228 \u2203 s, c\u2081 = bind s (pure) \u2227 c\u2082 = s\n  . intro c\u2081 c\u2082 h\n    exact\n      match c\u2081, c\u2082, h with\n      | _, c\u2082, Or.inl (Eq.refl _) => by cases' destruct c\u2082 with b cb <;> simp\n      | _, _, Or.inr \u27e8s, rfl, rfl\u27e9 => by\n        apply recOn s <;> intro s <;> simp\n  . exact Or.inr \u27e8s, rfl, rfl\u27e9\n#align computation.bind_ret' Computation.bind_pure'\n\n@[simp]\ntheorem bind_assoc (s : Computation \u03b1) (f : \u03b1 \u2192 Computation \u03b2) (g : \u03b2 \u2192 Computation \u03b3) :\n    bind (bind s f) g = bind s fun x : \u03b1 => bind (f x) g := by\n  apply\n    eq_of_bisim fun c\u2081 c\u2082 =>\n      c\u2081 = c\u2082 \u2228 \u2203 s, c\u2081 = bind (bind s f) g \u2227 c\u2082 = bind s fun x : \u03b1 => bind (f x) g\n  \u00b7 intro c\u2081 c\u2082 h\n    exact\n      match c\u2081, c\u2082, h with\n      | _, c\u2082, Or.inl (Eq.refl _) => by cases' destruct c\u2082 with b cb <;> simp\n      | _, _, Or.inr \u27e8s, rfl, rfl\u27e9 => by\n        apply recOn s <;> intro s <;> simp\n        \u00b7 generalize f s = fs\n          apply recOn fs <;> intro t <;> simp\n          \u00b7 cases' destruct (g t) with b cb <;> simp\n        \u00b7 exact Or.inr \u27e8s, rfl, rfl\u27e9\n  \u00b7 exact Or.inr \u27e8s, rfl, rfl\u27e9\n#align computation.bind_assoc Computation.bind_assoc\n\ntheorem results_bind {s : Computation \u03b1} {f : \u03b1 \u2192 Computation \u03b2} {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  \u00b7 intro _ h1\n    rw [ret_bind]\n    rw [h1.len_unique (results_pure _)]\n    exact h2\n  \u00b7 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 \u03b1} {f : \u03b1 \u2192 Computation \u03b2} {a b} (h1 : a \u2208 s) (h2 : b \u2208 f a) :\n    b \u2208 bind s f :=\n  let \u27e8_, h1\u27e9 := exists_results_of_mem h1\n  let \u27e8_, h2\u27e9 := 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 \u03b1) (f : \u03b1 \u2192 Computation \u03b2) [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 \u03b1) (f : \u03b1 \u2192 Computation \u03b2) [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 \u03b1) (f : \u03b1 \u2192 Computation \u03b2) [_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 \u03b1} {f : \u03b1 \u2192 Computation \u03b2} {b k} :\n    Results (bind s f) b k \u2192 \u2203 a m n, Results s a m \u2227 Results (f a) b n \u2227 k = n + m := by\n  induction' k with n IH generalizing s <;> apply recOn s (fun a => _) fun s' => _ <;> intro e h\n  \u00b7 simp [thinkN] at h\n    refine' \u27e8e, _, _, results_pure _, h, rfl\u27e9\n  \u00b7 have := congr_arg head (eq_thinkN h)\n    contradiction\n  \u00b7 simp at h\n    refine' \u27e8e, _, n + 1, results_pure _, h, rfl\u27e9\n  \u00b7 simp at h\n    exact by\n      let \u27e8a, m, n', h1, h2, e'\u27e9 := IH h\n      rw [e'] ; exact \u27e8a, m.succ, n', results_think h1, h2, rfl\u27e9\n#align computation.of_results_bind Computation.of_results_bind\n\ntheorem exists_of_mem_bind {s : Computation \u03b1} {f : \u03b1 \u2192 Computation \u03b2} {b} (h : b \u2208 bind s f) :\n    \u2203 a \u2208 s, b \u2208 f a :=\n  let \u27e8_, h\u27e9 := exists_results_of_mem h\n  let \u27e8a, _, _, h1, h2, _\u27e9 := of_results_bind h\n  \u27e8a, h1.mem, h2.mem\u27e9\n#align computation.exists_of_mem_bind Computation.exists_of_mem_bind\n\ntheorem bind_promises {s : Computation \u03b1} {f : \u03b1 \u2192 Computation \u03b2} {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 \u27e8a', a's, ba'\u27e9\n  rw [\u2190 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 {\u03b2} (f : \u03b1 \u2192 \u03b2) (c : Computation \u03b1) : 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 \u03b1) = pure a :=\n  rfl\n#align computation.return_def Computation.pure_def\n\n@[simp]\ntheorem map_pure' {\u03b1 \u03b2} : \u2200 (f : \u03b1 \u2192 \u03b2) (a), f <$> pure a = pure (f a) :=\n  map_pure\n#align computation.map_ret' Computation.map_pure'\n\n@[simp]\ntheorem map_think' {\u03b1 \u03b2} : \u2200 (f : \u03b1 \u2192 \u03b2) (s), f <$> think s = think (f <$> s) :=\n  map_think\n#align computation.map_think' Computation.map_think'\n\ntheorem mem_map (f : \u03b1 \u2192 \u03b2) {a} {s : Computation \u03b1} (m : a \u2208 s) : f a \u2208 map f s := by\n  rw [\u2190 bind_pure] ; apply mem_bind m ; apply ret_mem\n#align computation.mem_map Computation.mem_map\n\ntheorem exists_of_mem_map {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : Computation \u03b1} (h : b \u2208 map f s) :\n    \u2203 a, a \u2208 s \u2227 f a = b := by\n  rw [\u2190 bind_pure] at h ;\n    exact\n      let \u27e8a, as, fb\u27e9 := exists_of_mem_bind h\n      \u27e8a, as, mem_unique (ret_mem _) fb\u27e9\n#align computation.exists_of_mem_map Computation.exists_of_mem_map\n\ninstance terminates_map (f : \u03b1 \u2192 \u03b2) (s : Computation \u03b1) [Terminates s] : Terminates (map f s) := by\n  rw [\u2190 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 : \u03b1 \u2192 \u03b2) (s : Computation \u03b1) : Terminates (map f s) \u2194 Terminates s :=\n  \u27e8fun \u27e8\u27e8_, h\u27e9\u27e9 =>\n    let \u27e8_, h1, _\u27e9 := exists_of_mem_map h\n    \u27e8\u27e8_, h1\u27e9\u27e9,\n    @Computation.terminates_map _ _ _ _\u27e9\n#align computation.terminates_map_iff Computation.terminates_map_iff\n\n-- Parallel computation\n/-- `c\u2081 <|> c\u2082` calculates `c\u2081` and `c\u2082` simultaneously, returning\n  the first one that gives a result. -/\ndef orElse (c\u2081: Computation \u03b1) (c\u2082: Unit \u2192 Computation \u03b1): Computation \u03b1 :=\n  @Computation.corec \u03b1 (Computation \u03b1 \u00d7 Computation \u03b1)\n    (fun \u27e8c\u2081, c\u2082\u27e9 =>\n      match destruct c\u2081 with\n      | Sum.inl a => Sum.inl a\n      | Sum.inr c\u2081' =>\n        match destruct c\u2082 with\n        | Sum.inl a => Sum.inl a\n        | Sum.inr c\u2082' => Sum.inr (c\u2081', c\u2082'))\n    (c\u2081, c\u2082 ())\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 : \u03b1) (c\u2082 : Computation \u03b1) : (pure a <|> c\u2082) = 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\u2081 : Computation \u03b1) (a : \u03b1) : (think c\u2081 <|> 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\u2081 c\u2082 : Computation \u03b1) : (think c\u2081 <|> think c\u2082) = think (c\u2081 <|> c\u2082) :=\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 \u03b1 <|> c) = c := by\n  apply eq_of_bisim (fun c\u2081 c\u2082 => (empty \u03b1 <|> c\u2082) = c\u2081) _ rfl\n  intro s' s h; rw [\u2190 h]\n  apply recOn s <;> intro s <;> rw [think_empty] <;> simp\n  rw [\u2190 think_empty]\n#align computation.empty_orelse Computation.empty_orelse\n\n@[simp]\ntheorem orelse_empty (c : Computation \u03b1) : (c <|> empty \u03b1) = c := by\n  apply eq_of_bisim (fun c\u2081 c\u2082 => (c\u2082 <|> empty \u03b1) = c\u2081) _ rfl\n  intro s' s h; rw [\u2190 h]\n  apply recOn s <;> intro s <;> rw [think_empty] <;> simp\n  rw [\u2190 think_empty]\n#align computation.orelse_empty Computation.orelse_empty\n\n/-- `c\u2081 ~ c\u2082` asserts that `c\u2081` and `c\u2082` either both terminate with the same result,\n  or both loop forever. -/\ndef Equiv (c\u2081 c\u2082 : Computation \u03b1) : Prop :=\n  \u2200 a, a \u2208 c\u2081 \u2194 a \u2208 c\u2082\n#align computation.equiv Computation.Equiv\n\n-- mathport name: \u00abexpr ~ \u00bb\n/-- equivalence relation for computations-/\nscoped infixl:50 \" ~ \" => Equiv\n\n@[refl]\ntheorem Equiv.refl (s : Computation \u03b1) : s ~ s := fun _ => Iff.rfl\n#align computation.equiv.refl Computation.Equiv.refl\n\n@[symm]\ntheorem Equiv.symm {s t : Computation \u03b1} : s ~ t \u2192 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 \u03b1} : s ~ t \u2192 t ~ u \u2192 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 \u03b1) :=\n  \u27e8@Equiv.refl _, @Equiv.symm _, @Equiv.trans _\u27e9\n#align computation.equiv.equivalence Computation.Equiv.equivalence\n\ntheorem equiv_of_mem {s t : Computation \u03b1} {a} (h1 : a \u2208 s) (h2 : a \u2208 t) : s ~ t := fun a' =>\n  \u27e8fun ma => by rw [mem_unique ma h1] ; exact h2, fun ma => by rw [mem_unique ma h2] ; exact h1\u27e9\n#align computation.equiv_of_mem Computation.equiv_of_mem\n\ntheorem terminates_congr {c\u2081 c\u2082 : Computation \u03b1} (h : c\u2081 ~ c\u2082) : Terminates c\u2081 \u2194 Terminates c\u2082 := by\n  simp only [terminates_iff, exists_congr h]\n#align computation.terminates_congr Computation.terminates_congr\n\n\n\ntheorem get_equiv {c\u2081 c\u2082 : Computation \u03b1} (h : c\u2081 ~ c\u2082) [Terminates c\u2081] [Terminates c\u2082] :\n    get c\u2081 = get c\u2082 :=\n  get_eq_of_mem _ <| (h _).2 <| get_mem _\n#align computation.get_equiv Computation.get_equiv\n\ntheorem think_equiv (s : Computation \u03b1) : think s ~ s := fun _ => \u27e8of_think_mem, think_mem\u27e9\n#align computation.think_equiv Computation.think_equiv\n\ntheorem thinkN_equiv (s : Computation \u03b1) (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 \u03b1} {f1 f2 : \u03b1 \u2192 Computation \u03b2} (h1 : s1 ~ s2)\n    (h2 : \u2200 a, f1 a ~ f2 a) : bind s1 f1 ~ bind s2 f2 := fun b =>\n  \u27e8fun h =>\n    let \u27e8a, ha, hb\u27e9 := exists_of_mem_bind h\n    mem_bind ((h1 a).1 ha) ((h2 a b).1 hb),\n    fun h =>\n    let \u27e8a, ha, hb\u27e9 := exists_of_mem_bind h\n    mem_bind ((h1 a).2 ha) ((h2 a b).2 hb)\u27e9\n#align computation.bind_congr Computation.bind_congr\n\ntheorem equiv_pure_of_mem {s : Computation \u03b1} {a} (h : a \u2208 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 : \u03b1 \u2192 \u03b2 \u2192 Prop) (ca : Computation \u03b1) (cb : Computation \u03b2) : Prop :=\n  (\u2200 {a}, a \u2208 ca \u2192 \u2203 b, b \u2208 cb \u2227 R a b) \u2227 \u2200 {b}, b \u2208 cb \u2192 \u2203 a, a \u2208 ca \u2227 R a b\n#align computation.lift_rel Computation.LiftRel\n\ntheorem LiftRel.swap (R : \u03b1 \u2192 \u03b2 \u2192 Prop) (ca : Computation \u03b1) (cb : Computation \u03b2) :\n    LiftRel (swap R) cb ca \u2194 LiftRel R ca cb :=\n  @and_comm _ _\n#align computation.lift_rel.swap Computation.LiftRel.swap\n\ntheorem lift_eq_iff_equiv (c\u2081 c\u2082 : Computation \u03b1) : LiftRel (\u00b7 = \u00b7) c\u2081 c\u2082 \u2194 c\u2081 ~ c\u2082 :=\n  \u27e8fun \u27e8h1, h2\u27e9 a =>\n    \u27e8fun a1 => by\n      let \u27e8b, b2, ab\u27e9 := h1 a1\n      rwa [ab], fun a2 => by\n      let \u27e8b, b1, ab\u27e9 := h2 a2\n      rwa [\u2190 ab]\u27e9,\n    fun e => \u27e8fun {a} a1 => \u27e8a, (e _).1 a1, rfl\u27e9, fun {a} a2 => \u27e8a, (e _).2 a2, rfl\u27e9\u27e9\u27e9\n#align computation.lift_eq_iff_equiv Computation.lift_eq_iff_equiv\n\ntheorem LiftRel.refl (R : \u03b1 \u2192 \u03b1 \u2192 Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun _ =>\n  \u27e8fun {a} as => \u27e8a, as, H a\u27e9, fun {b} bs => \u27e8b, bs, H b\u27e9\u27e9\n#align computation.lift_rel.refl Computation.LiftRel.refl\n\ntheorem LiftRel.symm (R : \u03b1 \u2192 \u03b1 \u2192 Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=\n  fun _ _ \u27e8l, r\u27e9 =>\n  \u27e8fun {_} a2 =>\n    let \u27e8b, b1, ab\u27e9 := r a2\n    \u27e8b, b1, H ab\u27e9,\n    fun {_} a1 =>\n    let \u27e8b, b2, ab\u27e9 := l a1\n    \u27e8b, b2, H ab\u27e9\u27e9\n#align computation.lift_rel.symm Computation.LiftRel.symm\n\ntheorem LiftRel.trans (R : \u03b1 \u2192 \u03b1 \u2192 Prop) (H : Transitive R) : Transitive (LiftRel R) :=\n  fun _ _ _ \u27e8l1, r1\u27e9 \u27e8l2, r2\u27e9 =>\n  \u27e8fun {_} a1 =>\n    let \u27e8_, b2, ab\u27e9 := l1 a1\n    let \u27e8c, c3, bc\u27e9 := l2 b2\n    \u27e8c, c3, H ab bc\u27e9,\n    fun {_} c3 =>\n    let \u27e8_, b2, bc\u27e9 := r2 c3\n    let \u27e8a, a1, ab\u27e9 := r1 b2\n    \u27e8a, a1, H ab bc\u27e9\u27e9\n#align computation.lift_rel.trans Computation.LiftRel.trans\n\ntheorem LiftRel.equiv (R : \u03b1 \u2192 \u03b1 \u2192 Prop) : Equivalence R \u2192 Equivalence (LiftRel R)\n  -- Porting note: The code below was:\n  -- | \u27e8refl, symm, trans\u27e9 => \u27e8LiftRel.refl R refl, LiftRel.symm R symm, LiftRel.trans R trans\u27e9\n  --\n  -- The code fails to identify `symm` as being symmetric.\n  | \u27e8refl, symm, trans\u27e9 => \u27e8LiftRel.refl R refl, by apply LiftRel.symm; apply symm,\n    by apply LiftRel.trans; apply trans\u27e9\n#align computation.lift_rel.equiv Computation.LiftRel.equiv\n\ntheorem LiftRel.imp {R S : \u03b1 \u2192 \u03b2 \u2192 Prop} (H : \u2200 {a b}, R a b \u2192 S a b) (s t) :\n    LiftRel R s t \u2192 LiftRel S s t\n  | \u27e8l, r\u27e9 =>\n    \u27e8fun {_} as =>\n      let \u27e8b, bt, ab\u27e9 := l as\n      \u27e8b, bt, H ab\u27e9,\n      fun {_} bt =>\n      let \u27e8a, as, ab\u27e9 := r bt\n      \u27e8a, as, H ab\u27e9\u27e9\n#align computation.lift_rel.imp Computation.LiftRel.imp\n\ntheorem terminates_of_LiftRel {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {s t} :\n    LiftRel R s t \u2192 (Terminates s \u2194 Terminates t)\n  | \u27e8l, r\u27e9 =>\n    \u27e8fun \u27e8\u27e8_, as\u27e9\u27e9 =>\n      let \u27e8b, bt, _\u27e9 := l as\n      \u27e8\u27e8b, bt\u27e9\u27e9,\n      fun \u27e8\u27e8_, bt\u27e9\u27e9 =>\n      let \u27e8a, as, _\u27e9 := r bt\n      \u27e8\u27e8a, as\u27e9\u27e9\u27e9\n#align computation.terminates_of_lift_rel Computation.terminates_of_LiftRel\n\ntheorem rel_of_LiftRel {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {ca cb} :\n    LiftRel R ca cb \u2192 \u2200 {a b}, a \u2208 ca \u2192 b \u2208 cb \u2192 R a b\n  | \u27e8l, _\u27e9, a, b, ma, mb => by\n    let \u27e8b', mb', ab'\u27e9 := 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 : \u03b1 \u2192 \u03b2 \u2192 Prop} {a b ca cb} (ma : a \u2208 ca) (mb : b \u2208 cb) (ab : R a b) :\n    LiftRel R ca cb :=\n  \u27e8fun {a'} ma' => by rw [mem_unique ma' ma] ; exact \u27e8b, mb, ab\u27e9, fun {b'} mb' => by\n    rw [mem_unique mb' mb] ; exact \u27e8a, ma, ab\u27e9\u27e9\n#align computation.lift_rel_of_mem Computation.liftRel_of_mem\n\ntheorem exists_of_LiftRel_left {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {ca cb} (H : LiftRel R ca cb) {a} (h : a \u2208 ca) :\n    \u2203 b, b \u2208 cb \u2227 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 : \u03b1 \u2192 \u03b2 \u2192 Prop} {ca cb} (H : LiftRel R ca cb) {b} (h : b \u2208 cb) :\n    \u2203 a, a \u2208 ca \u2227 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 : \u03b1 \u2192 \u03b2 \u2192 Prop} {ca cb} :\n    LiftRel R ca cb \u2194 (Terminates ca \u2194 Terminates cb) \u2227 \u2200 {a b}, a \u2208 ca \u2192 b \u2208 cb \u2192 R a b :=\n  \u27e8fun h =>\n    \u27e8terminates_of_LiftRel h, fun {a b} ma mb => by\n      let \u27e8b', mb', ab\u27e9 := h.left ma\n      rwa [mem_unique mb mb']\u27e9,\n    fun \u27e8l, r\u27e9 =>\n    \u27e8fun {a} ma =>\n      let \u27e8\u27e8b, mb\u27e9\u27e9 := l.1 \u27e8\u27e8_, ma\u27e9\u27e9\n      \u27e8b, mb, r ma mb\u27e9,\n      fun {b} mb =>\n      let \u27e8\u27e8a, ma\u27e9\u27e9 := l.2 \u27e8\u27e8_, mb\u27e9\u27e9\n      \u27e8a, ma, r ma mb\u27e9\u27e9\u27e9\n#align computation.lift_rel_def Computation.liftRel_def\n\ntheorem liftRel_bind {\u03b4} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) (S : \u03b3 \u2192 \u03b4 \u2192 Prop) {s1 : Computation \u03b1}\n    {s2 : Computation \u03b2} {f1 : \u03b1 \u2192 Computation \u03b3} {f2 : \u03b2 \u2192 Computation \u03b4} (h1 : LiftRel R s1 s2)\n    (h2 : \u2200 {a b}, R a b \u2192 LiftRel S (f1 a) (f2 b)) : LiftRel S (bind s1 f1) (bind s2 f2) :=\n  let \u27e8l1, r1\u27e9 := h1\n  \u27e8fun {_} cB =>\n    let \u27e8_, a1, c\u2081\u27e9 := exists_of_mem_bind cB\n    let \u27e8_, b2, ab\u27e9 := l1 a1\n    let \u27e8l2, _\u27e9 := h2 ab\n    let \u27e8_, d2, cd\u27e9 := l2 c\u2081\n    \u27e8_, mem_bind b2 d2, cd\u27e9,\n    fun {_} dB =>\n    let \u27e8_, b1, d1\u27e9 := exists_of_mem_bind dB\n    let \u27e8_, a2, ab\u27e9 := r1 b1\n    let \u27e8_, r2\u27e9 := h2 ab\n    let \u27e8_, c\u2082, cd\u27e9 := r2 d1\n    \u27e8_, mem_bind a2 c\u2082, cd\u27e9\u27e9\n#align computation.lift_rel_bind Computation.liftRel_bind\n\n@[simp]\ntheorem liftRel_pure_left (R : \u03b1 \u2192 \u03b2 \u2192 Prop) (a : \u03b1) (cb : Computation \u03b2) :\n    LiftRel R (pure a) cb \u2194 \u2203 b, b \u2208 cb \u2227 R a b :=\n  \u27e8fun \u27e8l, _\u27e9 => l (ret_mem _), fun \u27e8b, mb, ab\u27e9 =>\n    \u27e8fun {a'} ma' => by rw [eq_of_pure_mem ma'] ; exact \u27e8b, mb, ab\u27e9, fun {b'} mb' =>\n      \u27e8_, ret_mem _, by rw [mem_unique mb' mb] ; exact ab\u27e9\u27e9\u27e9\n#align computation.lift_rel_return_left Computation.liftRel_pure_left\n\n@[simp]\ntheorem liftRel_pure_right (R : \u03b1 \u2192 \u03b2 \u2192 Prop) (ca : Computation \u03b1) (b : \u03b2) :\n    LiftRel R ca (pure b) \u2194 \u2203 a, a \u2208 ca \u2227 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 : \u03b1 \u2192 \u03b2 \u2192 Prop) (a : \u03b1) (b : \u03b2) :\n    LiftRel R (pure a) (pure b) \u2194 R a b := by\n  rw [liftRel_pure_left] ;\n    exact \u27e8fun \u27e8b', mb', ab'\u27e9 => by rwa [eq_of_pure_mem mb'] at ab', fun ab => \u27e8_, ret_mem _, ab\u27e9\u27e9\n#align computation.lift_rel_return Computation.liftRel_pure\n\n@[simp]\ntheorem liftRel_think_left (R : \u03b1 \u2192 \u03b2 \u2192 Prop) (ca : Computation \u03b1) (cb : Computation \u03b2) :\n    LiftRel R (think ca) cb \u2194 LiftRel R ca cb :=\n  and_congr (forall_congr' fun _ => imp_congr \u27e8of_think_mem, think_mem\u27e9 Iff.rfl)\n    (forall_congr' fun _ =>\n      imp_congr Iff.rfl <| exists_congr fun _ => and_congr \u27e8of_think_mem, think_mem\u27e9 Iff.rfl)\n#align computation.lift_rel_think_left Computation.liftRel_think_left\n\n@[simp]\ntheorem liftRel_think_right (R : \u03b1 \u2192 \u03b2 \u2192 Prop) (ca : Computation \u03b1) (cb : Computation \u03b2) :\n    LiftRel R ca (think cb) \u2194 LiftRel R ca cb := by\n  rw [\u2190 LiftRel.swap R, \u2190 LiftRel.swap R] ; apply liftRel_think_left\n#align computation.lift_rel_think_right Computation.liftRel_think_right\n\ntheorem liftRel_mem_cases {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {ca cb} (Ha : \u2200 a \u2208 ca, LiftRel R ca cb)\n    (Hb : \u2200 b \u2208 cb, LiftRel R ca cb) : LiftRel R ca cb :=\n  \u27e8fun {_} ma => (Ha _ ma).left ma, fun {_} mb => (Hb _ mb).right mb\u27e9\n#align computation.lift_rel_mem_cases Computation.liftRel_mem_cases\n\ntheorem liftRel_congr {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {ca ca' : Computation \u03b1} {cb cb' : Computation \u03b2}\n    (ha : ca ~ ca') (hb : cb ~ cb') : LiftRel R ca cb \u2194 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 {\u03b4} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) (S : \u03b3 \u2192 \u03b4 \u2192 Prop) {s1 : Computation \u03b1}\n    {s2 : Computation \u03b2} {f1 : \u03b1 \u2192 \u03b3} {f2 : \u03b2 \u2192 \u03b4} (h1 : LiftRel R s1 s2)\n    (h2 : \u2200 {a b}, R a b \u2192 S (f1 a) (f2 b)) : LiftRel S (map f1 s1) (map f2 s2) := by\n  -- Porting note: The line below was:\n  -- rw [\u2190 bind_pure, \u2190 bind_pure]; apply lift_rel_bind _ _ h1; simp; exact @h2\n  --\n  -- The code fails to work on the last exact.\n  rw [\u2190 bind_pure, \u2190 bind_pure]; apply liftRel_bind _ _ h1; simp\n  intros a b h; exact \u27e8f1 a, \u27e8ret_mem _, @h2 a b h\u27e9\u27e9\n#align computation.lift_rel_map Computation.liftRel_map\n\n-- porting notes: deleted initial arguments `(_R : \u03b1 \u2192 \u03b1 \u2192 Prop) (_S : \u03b2 \u2192 \u03b2 \u2192 Prop)`: unused\ntheorem map_congr {s1 s2 : Computation \u03b1} {f : \u03b1 \u2192 \u03b2}\n    (h1 : s1 ~ s2) : map f s1 ~ map f s2 := by\n  rw [\u2190 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 : \u03b1 \u2192 \u03b2 \u2192 Prop) (C : Computation \u03b1 \u2192 Computation \u03b2 \u2192 Prop) :\n    Sum \u03b1 (Computation \u03b1) \u2192 Sum \u03b2 (Computation \u03b2) \u2192 Prop\n  | Sum.inl a, Sum.inl b => R a b\n  | Sum.inl a, Sum.inr cb => \u2203 b, b \u2208 cb \u2227 R a b\n  | Sum.inr ca, Sum.inl b => \u2203 a, a \u2208 ca \u2227 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) = \u2203 b, b \u2208 cb \u2227 R a b :=\n  rfl\n@[simp] lemma LiftRelAux_inr_inl : LiftRelAux R C (Sum.inr ca) (Sum.inl b) = \u2203 a, a \u2208 ca \u2227 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 : \u03b1 \u2192 \u03b2 \u2192 Prop) (C : Computation \u03b1 \u2192 Computation \u03b2 \u2192 Prop) (a cb) :\n    LiftRelAux R C (Sum.inl a) (destruct cb) \u2194 \u2203 b, b \u2208 cb \u2227 R a b := by\n  apply cb.recOn (fun b => _) fun cb => _\n  \u00b7 intro b\n    exact\n      \u27e8fun h => \u27e8_, ret_mem _, h\u27e9, fun \u27e8b', mb, h\u27e9 => by rw [mem_unique (ret_mem _) mb] ; exact h\u27e9\n  \u00b7 intro\n    rw [destruct_think]\n    exact \u27e8fun \u27e8b, h, r\u27e9 => \u27e8b, think_mem h, r\u27e9, fun \u27e8b, h, r\u27e9 => \u27e8b, of_think_mem h, r\u27e9\u27e9\n#align computation.lift_rel_aux.ret_left Computation.LiftRelAux.ret_left\n\ntheorem LiftRelAux.swap (R : \u03b1 \u2192 \u03b2 \u2192 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 : \u03b1 \u2192 \u03b2 \u2192 Prop) (C : Computation \u03b1 \u2192 Computation \u03b2 \u2192 Prop) (b ca) :\n    LiftRelAux R C (destruct ca) (Sum.inl b) \u2194 \u2203 a, a \u2208 ca \u2227 R a b := by\n  rw [\u2190 LiftRelAux.swap, LiftRelAux.ret_left]\n#align computation.lift_rel_aux.ret_right Computation.LiftRelAux.ret_right\n\ntheorem LiftRelRec.lem {R : \u03b1 \u2192 \u03b2 \u2192 Prop} (C : Computation \u03b1 \u2192 Computation \u03b2 \u2192 Prop)\n    (H : \u2200 {ca cb}, C ca cb \u2192 LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) (a)\n    (ha : a \u2208 ca) : LiftRel R ca cb := by\n  revert cb\n  refine' memRecOn (C := (\u03bb ca => \u2200 (cb : Computation \u03b2), C ca cb \u2192 LiftRel R ca cb))\n    ha _ (fun ca' IH => _) <;> intro cb Hc <;> have h := H Hc\n  \u00b7 simp at h\n    simp [h]\n  \u00b7 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 : \u03b1 \u2192 \u03b2 \u2192 Prop} (C : Computation \u03b1 \u2192 Computation \u03b2 \u2192 Prop)\n    (H : \u2200 {ca cb}, C ca cb \u2192 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\u00f6lzl.\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 \u2192* G/N` given a normal subgroup `N` of `G`.\n* `lift \u03c6`: the group homomorphism `G/N \u2192* H` given a group homomorphism `\u03c6 : G \u2192* H` such that\n  `N \u2286 ker \u03c6`.\n* `map f`: the group homomorphism `G/N \u2192* H/M` given a group homomorphism `f : G \u2192* H` such that\n  `N \u2286 f\u207b\u00b9(M)`.\n\n## Main statements\n\n* `quotient_ker_equiv_range`: Noether's first isomorphism theorem, an explicit isomorphism\n  `G/ker \u03c6 \u2192 range \u03c6` for every group homomorphism `\u03c6 : G \u2192* H`.\n* `quotient_inf_equiv_prod_normal_quotient`: Noether's second isomorphism theorem, an explicit\n  isomorphism between `H/(H \u2229 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 \u2264 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' := \u03bb a b c d hab hcd, begin\n    rw [left_rel_eq] at hab hcd \u22a2,\n    calc (a * c)\u207b\u00b9 * (b * d) = c\u207b\u00b9 * (a\u207b\u00b9 * b) * c\u207b\u00b9\u207b\u00b9 * (c\u207b\u00b9 * d) :\n      by simp only [mul_inv_rev, mul_assoc, inv_mul_cancel_left]\n    ... \u2208 N : N.mul_mem (nN.conj_mem _ hab _) hcd\n  end }\n\n@[to_additive] instance quotient.group : group (G \u29f8 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 \u2192* G \u29f8 N := monoid_hom.mk' (quotient_group.mk) (\u03bb _ _, rfl)\n\n@[simp, to_additive]\nlemma coe_mk' : (mk' N : G \u2192 G \u29f8 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 \u2194 \u2203 z \u2208 N, x * z = y :=\nquotient_group.eq'.trans $\n  by simp only [\u2190 _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 \u2983f g : G \u29f8 N \u2192* H\u2984 (h : f.comp (mk' N) = g.comp (mk' N)) : f = g :=\nmonoid_hom.ext $ \u03bb 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 \u29f8 N) = 1 \u2194 x \u2208 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 \u2192* G \u29f8 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 \u29f8 N) :=\n{ mul_comm := \u03bb a b, quotient.induction_on\u2082' a b\n    (\u03bb 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 \u29f8 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\u207b\u00b9 : G) : Q) = a\u207b\u00b9 := 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 : \u2115) : ((a ^ n : G) : Q) = a ^ n := rfl\n@[simp, to_additive] lemma coe_zpow (a : G) (n : \u2124) : ((a ^ n : G) : Q) = a ^ n := rfl\n\n/-- A group homomorphism `\u03c6 : G \u2192* H` with `N \u2286 ker(\u03c6)` descends (i.e. `lift`s) to a\ngroup homomorphism `G/N \u2192* H`. -/\n@[to_additive \"An `add_group` homomorphism `\u03c6 : G \u2192+ H` with `N \u2286 ker(\u03c6)` descends (i.e. `lift`s)\nto a group homomorphism `G/N \u2192* H`.\"]\ndef lift (\u03c6 : G \u2192* H) (HN : \u2200x\u2208N, \u03c6 x = 1) : Q \u2192* H :=\n(quotient_group.con N).lift \u03c6 $ \u03bb x y h, begin\n  simp only [quotient_group.con, left_rel_apply, con.rel_mk] at h,\n  calc \u03c6 x = \u03c6 (y * (x\u207b\u00b9 * y)\u207b\u00b9) : by rw [mul_inv_rev, inv_inv, mul_inv_cancel_left]\n       ... = \u03c6 y                 : by rw [\u03c6.map_mul, HN _ (N.inv_mem h), mul_one]\n  end\n\n@[simp, to_additive]\nlemma lift_mk {\u03c6 : G \u2192* H} (HN : \u2200x\u2208N, \u03c6 x = 1) (g : G) : lift N \u03c6 HN (g : Q) = \u03c6 g := rfl\n\n@[simp, to_additive]\nlemma lift_mk' {\u03c6 : G \u2192* H} (HN : \u2200x\u2208N, \u03c6 x = 1) (g : G) : lift N \u03c6 HN (mk g : Q) = \u03c6 g := rfl\n\n@[simp, to_additive]\nlemma lift_quot_mk {\u03c6 : G \u2192* H} (HN : \u2200x\u2208N, \u03c6 x = 1) (g : G) :\n  lift N \u03c6 HN (quot.mk _ g : Q) = \u03c6 g := rfl\n\n/-- A group homomorphism `f : G \u2192* H` induces a map `G/N \u2192* H/M` if `N \u2286 f\u207b\u00b9(M)`. -/\n@[to_additive \"An `add_group` homomorphism `f : G \u2192+ H` induces a map `G/N \u2192+ H/M` if\n`N \u2286 f\u207b\u00b9(M)`.\"]\ndef map (M : subgroup H) [M.normal] (f : G \u2192* H) (h : N \u2264 M.comap f) :\n  G \u29f8 N \u2192* H \u29f8 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 \u2192* H) (h : N \u2264 M.comap f)\n  (x : G) :\n  map N M f h \u2191x = \u2191(f x) :=\nrfl\n\n@[to_additive] lemma map_mk' (M : subgroup H) [M.normal] (f : G \u2192* H) (h : N \u2264 M.comap f) (x : G) :\n  map N M f h (mk' _ x) = \u2191(f x) :=\nrfl\n\n@[to_additive]\nlemma map_id_apply (h : N \u2264 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 $ \u03bb x, rfl\n\n@[simp, to_additive]\nlemma map_id (h : N \u2264 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 \u2192* H) (g : H \u2192* I) (hf : N \u2264 subgroup.comap f M) (hg : M \u2264 subgroup.comap g O)\n  (hgf : N \u2264 subgroup.comap (g.comp f) O :=\n    hf.trans ((subgroup.comap_mono hg).trans_eq (subgroup.comap_comap _ _ _))) (x : G \u29f8 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 (\u03bb 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 \u2192* H) (g : H \u2192* I) (hf : N \u2264 subgroup.comap f M) (hg : M \u2264 subgroup.comap g O)\n  (hgf : N \u2264 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 \u2243 H` to `G \u29f8 G' \u2243 H \u29f8 H'`,\ngiven that `e` maps `G` to `H`. -/\n@[to_additive \"`quotient_add_group.congr` lifts the isomorphism `e : G \u2243 H` to `G \u29f8 G' \u2243 H \u29f8 H'`,\ngiven that `e` maps `G` to `H`.\"]\ndef congr (e : G \u2243* H) (he : G'.map \u2191e = H') : G \u29f8 G' \u2243* H \u29f8 H' :=\n{ to_fun := map G' H' \u2191e (he \u25b8 G'.le_comap_map e),\n  inv_fun := map H' G' \u2191e.symm (he \u25b8 (G'.map_equiv_eq_comap_symm e).le),\n  left_inv := \u03bb x, by rw map_map; -- `simp` doesn't like this lemma...\n    simp only [map_map, \u2190 mul_equiv.coe_monoid_hom_trans, mul_equiv.self_trans_symm,\n        mul_equiv.coe_monoid_hom_refl, map_id_apply],\n  right_inv := \u03bb x, by rw map_map; -- `simp` doesn't like this lemma...\n    simp only [\u2190 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' \u2191e (he \u25b8 G'.le_comap_map e) }\n\n@[simp] lemma congr_mk (e : G \u2243* H) (he : G'.map \u2191e = H')\n  (x) : congr G' H' e he (mk x) = e x :=\nrfl\n\nlemma congr_mk' (e : G \u2243* H) (he : G'.map \u2191e = H')\n  (x) : congr G' H' e he (mk' G' x) = mk' H' (e x) :=\nrfl\n\n@[simp] lemma congr_apply (e : G \u2243* H) (he : G'.map \u2191e = 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 \u2192* G) = G' := subgroup.map_id G') :\n  congr G' G' (mul_equiv.refl G) he = mul_equiv.refl (G \u29f8 G') :=\nby { ext \u27e8x\u27e9, refl }\n\n@[simp] lemma congr_symm (e : G \u2243* H) (he : G'.map \u2191e = 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 (\u03c6 : G \u2192* 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 \u29f8 ker \u03c6 \u2192* H :=\nlift _ \u03c6 $ \u03bb g, \u03c6.mem_ker.mp\n\n@[simp, to_additive]\nlemma ker_lift_mk (g : G) : (ker_lift \u03c6) g = \u03c6 g := lift_mk _ _ _\n\n@[simp, to_additive]\nlemma ker_lift_mk' (g : G) : (ker_lift \u03c6) (mk g) = \u03c6 g := lift_mk' _ _ _\n\n@[to_additive]\nlemma ker_lift_injective : injective (ker_lift \u03c6) :=\nassume a b, quotient.induction_on\u2082' a b $\n  assume a b (h : \u03c6 a = \u03c6 b), quotient.sound' $\n  by rw [left_rel_apply, mem_ker, \u03c6.map_mul, \u2190 h, \u03c6.map_inv, inv_mul_self]\n\n-- Note that `ker \u03c6` isn't definitionally `ker (\u03c6.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 \u29f8 ker \u03c6 \u2192* \u03c6.range :=\nlift _ \u03c6.range_restrict $ \u03bb g hg, (mem_ker _).mp $ by rwa ker_range_restrict\n\n@[to_additive]\nlemma range_ker_lift_injective : injective (range_ker_lift \u03c6) :=\nassume a b, quotient.induction_on\u2082' a b $\n  assume a b (h : \u03c6.range_restrict a = \u03c6.range_restrict b), quotient.sound' $\n  by rw [left_rel_apply, \u2190ker_range_restrict, mem_ker,\n  \u03c6.range_restrict.map_mul, \u2190 h, \u03c6.range_restrict.map_inv, inv_mul_self]\n\n@[to_additive]\nlemma range_ker_lift_surjective : surjective (range_ker_lift \u03c6) :=\nbegin\n  rintro \u27e8_, g, rfl\u27e9,\n  use mk g,\n  refl,\nend\n\n/-- **Noether's first isomorphism theorem** (a definition): the canonical isomorphism between\n`G/(ker \u03c6)` to `range \u03c6`. -/\n@[to_additive \"The first isomorphism theorem (a definition): the canonical isomorphism between\n`G/(ker \u03c6)` to `range \u03c6`.\"]\nnoncomputable def quotient_ker_equiv_range : G \u29f8 ker \u03c6 \u2243* range \u03c6 :=\nmul_equiv.of_bijective (range_ker_lift \u03c6) \u27e8range_ker_lift_injective \u03c6, range_ker_lift_surjective \u03c6\u27e9\n\n/-- The canonical isomorphism `G/(ker \u03c6) \u2243* H` induced by a homomorphism `\u03c6 : G \u2192* H`\nwith a right inverse `\u03c8 : H \u2192 G`. -/\n@[to_additive \"The canonical isomorphism `G/(ker \u03c6) \u2243+ H` induced by a homomorphism `\u03c6 : G \u2192+ H`\nwith a right inverse `\u03c8 : H \u2192 G`.\", simps]\ndef quotient_ker_equiv_of_right_inverse (\u03c8 : H \u2192 G) (h\u03c6 : right_inverse \u03c8 \u03c6) :\n  G \u29f8 ker \u03c6 \u2243* H :=\n{ to_fun := ker_lift \u03c6,\n  inv_fun := mk \u2218 \u03c8,\n  left_inv := \u03bb x, ker_lift_injective \u03c6 (by rw [comp_app, ker_lift_mk', h\u03c6]),\n  right_inv := h\u03c6,\n  .. ker_lift \u03c6 }\n\n/-- The canonical isomorphism `G/\u22a5 \u2243* G`. -/\n@[to_additive \"The canonical isomorphism `G/\u22a5 \u2243+ G`.\", simps]\ndef quotient_bot : G \u29f8 (\u22a5 : subgroup G) \u2243* G :=\nquotient_ker_equiv_of_right_inverse (monoid_hom.id G) id (\u03bb x, rfl)\n\n/-- The canonical isomorphism `G/(ker \u03c6) \u2243* H` induced by a surjection `\u03c6 : G \u2192* H`.\n\nFor a `computable` version, see `quotient_group.quotient_ker_equiv_of_right_inverse`.\n-/\n@[to_additive \"The canonical isomorphism `G/(ker \u03c6) \u2243+ H` induced by a surjection `\u03c6 : G \u2192+ H`.\n\nFor a `computable` version, see `quotient_add_group.quotient_ker_equiv_of_right_inverse`.\"]\nnoncomputable def quotient_ker_equiv_of_surjective (h\u03c6 : surjective \u03c6) :\n  G \u29f8 (ker \u03c6) \u2243* H :=\nquotient_ker_equiv_of_right_inverse \u03c6 _ h\u03c6.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 \u29f8 M \u2243* G \u29f8 N :=\n{ map_mul' := \u03bb q r, quotient.induction_on\u2082' q r (\u03bb 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' \u2264 B'` and `A \u2264 B`,\nthen there is a map `A / (A' \u2293 A) \u2192* B / (B' \u2293 B)` induced by the inclusions. -/\n@[to_additive \"Let `A', A, B', B` be subgroups of `G`. If `A' \u2264 B'` and `A \u2264 B`,\nthen there is a map `A / (A' \u2293 A) \u2192+ B / (B' \u2293 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' \u2264 B') (h : A \u2264 B) :\n  A \u29f8 (A'.subgroup_of A) \u2192* B \u29f8 (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' \u2264 B') (h : A \u2264 B) (x : A) :\n  quotient_map_subgroup_of_of_le h' h x = \u2191(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' \u2293 A)` and `B / (B' \u2293 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' \u2293 A)` and `B / (B' \u2293 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 \u29f8 (A'.subgroup_of A) \u2243* B \u29f8 (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 \u27e8x, hx\u27e9, refl })\n  (by { ext \u27e8x, hx\u27e9, refl })\n\nsection zpow\n\nvariables {A B C : Type u} [comm_group A] [comm_group B] [comm_group C]\nvariables (f : A \u2192* B) (g : B \u2192* A) (e : A \u2243* B) (d : B \u2243* C) (n : \u2124)\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 \u29f8 (zpow_group_hom n : A \u2192* A).range \u2192* B \u29f8 (zpow_group_hom n : B \u2192* B).range :=\nlift _ ((mk' _).comp f) $\n  \u03bb g \u27e8h, (hg : h ^ n = g)\u27e9, (eq_one_iff _).mpr \u27e8_, by simpa only [\u2190 hg, map_zpow]\u27e9\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 $ \u03bb 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 \u29f8 (zpow_group_hom n : A \u2192* A).range \u2243* B \u29f8 (zpow_group_hom n : B \u2192* 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 \u29f8 (zpow_group_hom n : A \u2192* A).range)\n    = equiv_quotient_zpow_of_equiv (mul_equiv.refl A) n :=\nby { ext x, rw [\u2190 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 [\u2190 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 \u2229 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 \u2229 N)` and `(H + N)/N`\"]\nnoncomputable def quotient_inf_equiv_prod_normal_quotient (H N : subgroup G) [N.normal] :\n  H \u29f8 (N.subgroup_of H) \u2243* _ \u29f8 (N.subgroup_of (H \u2294 N)) :=\n/- \u03c6 is the natural homomorphism H \u2192* (HN)/N. -/\nlet \u03c6 : H \u2192* _ \u29f8 (N.subgroup_of (H \u2294 N)) :=\n  (mk' $ N.subgroup_of (H \u2294 N)).comp (inclusion le_sup_left) in\nhave \u03c6_surjective : surjective \u03c6 := \u03bb x, x.induction_on' $\n  begin\n    rintro \u27e8y, (hy : y \u2208 \u2191(H \u2294 N))\u27e9, rw mul_normal H N at hy,\n    rcases hy with \u27e8h, n, hh, hn, rfl\u27e9,\n    use [h, hh], apply quotient.eq.mpr,\n    change setoid.r _ _,\n    rw left_rel_apply,\n    change h\u207b\u00b9 * (h * n) \u2208 N,\n    rwa [\u2190mul_assoc, inv_mul_self, one_mul],\n  end,\n(quotient_mul_equiv_of_eq (by simp [\u2190 comap_ker])).trans\n  (quotient_ker_equiv_of_surjective \u03c6 \u03c6_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 \u2264 M)\n\n/-- The map from the third isomorphism theorem for groups: `(G / N) / (M / N) \u2192 G / M`. -/\n@[to_additive \"The map from the third isomorphism theorem for additive groups:\n`(A / N) / (M / N) \u2192 A / M`.\"]\ndef quotient_quotient_equiv_quotient_aux :\n  (G \u29f8 N) \u29f8 (M.map (mk' N)) \u2192* G \u29f8 M :=\nlift (M.map (mk' N))\n  (map N M (monoid_hom.id G) h)\n  (by { rintro _ \u27e8x, hx, rfl\u27e9, 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 \u29f8 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 \u29f8 N) =\n    x :=\nquotient_group.lift_mk' _ _ x\n\n/-- **Noether's third isomorphism theorem** for groups: `(G / N) / (M / N) \u2243* G / M`. -/\n@[to_additive \"**Noether's third isomorphism theorem** for additive groups:\n`(A / N) / (M / N) \u2243+ A / M`.\"]\ndef quotient_quotient_equiv_quotient :\n  (G \u29f8 N) \u29f8 (M.map (quotient_group.mk' N)) \u2243* G \u29f8 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 \u29f8 (\u22a4 : 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 \u29f8 H)) : H = \u22a4 :=\ntop_unique $ \u03bb x _,\n  have this : 1\u207b\u00b9 * x \u2208 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\u2081 : subgroup G} [H\u2081.normal] {H\u2082 : subgroup (G \u29f8 H\u2081)} [H\u2082.normal] :\n  (((subgroup.center ((G \u29f8 H\u2081) \u29f8 H\u2082))).comap (mk' H\u2082)).comap (mk' H\u2081) =\n  (subgroup.center (G \u29f8 H\u2082.comap (mk' H\u2081))).comap (mk' (H\u2082.comap (mk' H\u2081))) :=\nbegin\n  ext x,\n  simp only [mk'_apply, subgroup.mem_comap, subgroup.mem_center_iff, forall_coe,\n    \u2190 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 \u2192* G) (g : G \u2192* H)\n\n/-- If `F` and `H` are finite such that `ker(G \u2192* H) \u2264 im(F \u2192* G)`, then `G` is finite. -/\n@[to_additive \"If `F` and `H` are finite such that `ker(G \u2192+ H) \u2264 im(F \u2192+ G)`, then `G` is finite.\"]\nnoncomputable def fintype_of_ker_le_range (h : g.ker \u2264 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 \u2192* H) = im(F \u2192* G)`, then `G` is finite. -/\n@[to_additive \"If `F` and `H` are finite such that `ker(G \u2192+ H) = im(F \u2192+ 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 \u2192* H)` and `H` are finite, then `G` is finite. -/\n@[to_additive \"If `ker(G \u2192+ 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 : _ \u2243* G).to_monoid_hom.comp $ inclusion le_top) g $\n  \u03bb x hx, \u27e8\u27e8x, hx\u27e9, rfl\u27e9\n\n/-- If `F` and `coker(F \u2192* G)` are finite, then `G` is finite. -/\n@[to_additive \"If `F` and `coker(F \u2192+ G)` are finite, then `G` is finite.\"]\nnoncomputable def fintype_of_dom_of_coker [normal f.range] [fintype $ G \u29f8 f.range] : fintype G :=\nfintype_of_ker_le_range _ (mk' f.range) $ \u03bb 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 \u2192 Q)\n(property : monotone val)\n\ninstance : has_coe_to_fun (hom P Q) (\u03bb _, P \u2192 Q) := {\n coe := \u03bb f, f.val\n}\n\n@[ext]\nlemma hom_ext (f g : hom P Q) : \n  (\u2200 (p : P), f p = g p) \u2192 f = g :=\nbegin\n  rcases f with \u27e8f,hf\u27e9,\n  rcases g with \u27e8g,hg\u27e9,\n  intro h,\n  have h' : f = g := funext h,\n  rcases h', refl,\nend\n\ndef id : hom P P := \u27e8_root_.id,monotone_id\u27e9\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 := \u03bb f g, \u2200 p, (f p) \u2264 (g p),\n le_refl := \u03bb f p,le_refl (f p),\n le_antisymm := \u03bb 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 := \u03bb 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 := \u27e8\u03bb p,q, \u03bb p\u2080 p\u2081 hp, le_refl q\u27e9\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  \u2200 {p : P} {q : Q}, f p \u2264 q \u2194 p \u2264 g q\n\ndef adjoint.iff {f : hom P Q} {g : hom Q P} (h : adjoint f g) : \n  \u2200 {p : P} {q : Q}, f p \u2264 q \u2194 p \u2264 g q := \n    by { intros p q, unfold adjoint at h, exact h }\n\ndef comp : (hom Q R) \u2192 (hom P Q) \u2192 (hom P R) := \n \u03bb g f, \u27e8g.val \u2218 f.val, monotone.comp g.property f.property\u27e9\n\nlemma comp_val (g : hom Q R) (f : hom P Q) : \n (comp g f).val = g.val \u2218 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\u2082 {g\u2080 g\u2081 : hom Q R} {f\u2080 f\u2081 : hom P Q} \n (eg : g\u2080 \u2264 g\u2081) (ef : f\u2080 \u2264 f\u2081) : comp g\u2080 f\u2080 \u2264 comp g\u2081 f\u2081 := \n \u03bb p, calc \n  g\u2080.val (f\u2080.val p) \u2264 g\u2080.val (f\u2081.val p) : g\u2080.property (ef p)\n  ... \u2264 g\u2081.val (f\u2081.val p) : eg (f\u2081.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) \u00d7 (hom P Q) \u2192 (hom P R) := \n \u03bb \u27e8g,f\u27e9, comp g f\n\nlemma comp'_mono : monotone (@comp' P _ Q _ R _) := \n \u03bb \u27e8g\u2080,f\u2080\u27e9 \u27e8g\u2081,f\u2081\u27e9 \u27e8eg,ef\u27e9, comp_mono\u2082 eg ef\n\ndef eval : (hom P Q) \u2192 P \u2192 Q := \u03bb f p, f.val p\n\nlemma eval_mono\u2082 {f\u2080 f\u2081 : hom P Q} {p\u2080 p\u2081 : P} \n (ef : f\u2080 \u2264 f\u2081) (ep : p\u2080 \u2264 p\u2081) : eval f\u2080 p\u2080 \u2264 eval f\u2081 p\u2081 := \ncalc \n  f\u2080.val p\u2080 \u2264 f\u2080.val p\u2081 : f\u2080.property ep\n  ... \u2264 f\u2081.val p\u2081 : ef p\u2081  \n\ndef eval' : (hom P Q) \u00d7 P \u2192 Q := \u03bb \u27e8f,p\u27e9, eval f p\n\nlemma eval'_mono : monotone (@eval' P _ Q _) := \n \u03bb \u27e8f\u2080,p\u2080\u27e9 \u27e8f\u2081,p\u2081\u27e9 \u27e8ef,ep\u27e9, eval_mono\u2082 ef ep\n\ndef ins' : P \u2192 (hom Q (P \u00d7 Q)) := \n \u03bb p, \u27e8\u03bb q,\u27e8p,q\u27e9, \u03bb q\u2080 q\u2081 eq, \u27e8le_refl p,eq\u27e9\u27e9 \n\nlemma ins_mono : monotone (@ins' P _ Q _) := \n \u03bb p\u2080 p\u2081 ep q, \u27e8ep,le_refl q\u27e9\n\nlemma adjoint.unit {f : hom P Q} {g : hom Q P} (h : adjoint f g) :\n  id P \u2264 comp g f := \u03bb 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 \u2264 id Q := \u03bb q, h.iff.mpr (le_refl (g q))\n\nvariable (P)\ndef \u03c0\u2080 : Type* := quot (has_le.le : P \u2192 P \u2192 Prop)\nvariable {P}\n\ndef component (p : P) : \u03c0\u2080 P := quot.mk _ p\n\ndef connected : P \u2192 P \u2192 Prop := \u03bb p\u2080 p\u2081, component p\u2080 = component p\u2081 \n\nlemma \u03c0\u2080.sound {p\u2080 p\u2081 : P} (hp : p\u2080 \u2264 p\u2081) : \n component p\u2080 = component p\u2081 := quot.sound hp\n\nlemma \u03c0\u2080.epi {X : Type*} (f\u2080 f\u2081 : \u03c0\u2080 P \u2192 X) \n (h : \u2200 p, f\u2080 (component p) = f\u2081 (component p)) : f\u2080 = f\u2081 := \n  by {apply funext, rintro \u27e8p\u27e9, exact (h p),}\n\ndef \u03c0\u2080.lift {X : Type*} (f : P \u2192 X)\n (h : \u2200 p\u2080 p\u2081 : P, p\u2080 \u2264 p\u2081 \u2192 f p\u2080 = f p\u2081) : \n  (\u03c0\u2080 P) \u2192 X := @quot.lift P has_le.le X f h\n\nlemma \u03c0\u2080.lift_beta {X : Type*} (f : P \u2192 X)\n (h : \u2200 p\u2080 p\u2081 : P, p\u2080 \u2264 p\u2081 \u2192 f p\u2080 = f p\u2081) (p : P) :\n  \u03c0\u2080.lift f h (component p) = f p := \n   @quot.lift_beta P has_le.le X f h p \n\ndef \u03c0\u2080.lift\u2082 {X : Type*} (f : P \u2192 Q \u2192 X)\n (h : \u2200 p\u2080 p\u2081 q\u2080 q\u2081, p\u2080 \u2264 p\u2081 \u2192 q\u2080 \u2264 q\u2081 \u2192 f p\u2080 q\u2080 = f p\u2081 q\u2081) : \n  (\u03c0\u2080 P) \u2192 (\u03c0\u2080 Q) \u2192 X := \nbegin\n let h1 := \u03bb p q\u2080 q\u2081 hq, h p p q\u2080 q\u2081 (le_refl p) hq,\n let f1 : P \u2192 (\u03c0\u2080 Q) \u2192 X := \u03bb p, \u03c0\u2080.lift (f p) (h1 p),\n let hf1 : \u2200 p q, f1 p (component q) = f p q := \u03bb p, \u03c0\u2080.lift_beta (f p) (h1 p),\n let h2 : \u2200 p\u2080 p\u2081, p\u2080 \u2264 p\u2081 \u2192 f1 p\u2080 = f1 p\u2081 := \u03bb p\u2080 p\u2081 hp,\n  begin\n   apply \u03c0\u2080.epi,intro q,rw[hf1,hf1],\n   exact h p\u2080 p\u2081 q q hp (le_refl q),\n  end,\n exact \u03c0\u2080.lift f1 h2\nend\n\nlemma \u03c0\u2080.lift\u2082_beta {X : Type*} (f : P \u2192 Q \u2192 X)\n (h : \u2200 p\u2080 p\u2081 q\u2080 q\u2081, p\u2080 \u2264 p\u2081 \u2192 q\u2080 \u2264 q\u2081 \u2192 f p\u2080 q\u2080 = f p\u2081 q\u2081)\n  (p : P) (q : Q) : (\u03c0\u2080.lift\u2082 f h) (component p) (component q) = f p q := \nbegin\n unfold \u03c0\u2080.lift\u2082,simp only [],rw[\u03c0\u2080.lift_beta,\u03c0\u2080.lift_beta],\nend\n\nlemma parity_induction (u : \u2115 \u2192 Prop)\n  (h_zero : u 0)\n  (h_even : \u2200 i, u (2 * i) \u2192 u (2 * i + 1))\n  (h_odd  : \u2200 i, u (2 * i + 1) \u2192 u (2 * i + 2)) : \n  \u2200 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 [\u2190 hk] at ih \u22a2, \n    exact h_even k ih },\n  { rw [add_comm] at hk,\n    rw [\u2190 hk] at ih \u22a2, \n    exact h_odd k ih }\nend\n\nlemma zigzag (u : \u2115 \u2192 P) \n  (h_even : \u2200 i, u (2 * i) \u2264 u (2 * i + 1))\n  (h_odd : \u2200 i, u (2 * i + 2) \u2264 u(2 * i + 1)) : \n   \u2200 i, component (u i) = component (u 0) := \nparity_induction \n (\u03bb i, component (u i) = component (u 0))\n rfl \n (\u03bb i h, (\u03c0\u2080.sound (h_even i)).symm.trans h)\n (\u03bb i h, (\u03c0\u2080.sound (h_odd i)).trans h)\n\nvariables (P Q)\ndef hom\u2095 := \u03c0\u2080 (hom P Q)\n\ndef id\u2095 : hom\u2095 P P := component (id P)\n\nvariables {P Q}\n\ndef comp\u2095 : (hom\u2095 Q R) \u2192 (hom\u2095 P Q) \u2192 (hom\u2095 P R) := \n \u03c0\u2080.lift\u2082 (\u03bb g f, component (comp g f)) (begin \n  intros g\u2080 g\u2081 f\u2080 f\u2081 hg hf,\n  let hgf := comp_mono\u2082 hg hf,\n  let hgf' := \u03c0\u2080.sound hgf,\n  exact (\u03c0\u2080.sound (comp_mono\u2082 hg hf))\n end)\n\nlemma comp\u2095_def (g : hom Q R) (f : hom P Q) : \n comp\u2095 (component g) (component f) = component (comp g f) := \n  by {simp[comp\u2095,\u03c0\u2080.lift\u2082_beta]}\n\nlemma id_comp\u2095 (f : hom\u2095 P Q) : comp\u2095 (id\u2095 Q) f = f := \n begin \n  rcases f with \u27e8f\u27e9,\n  change comp\u2095 (component (id Q)) (component f) = component f,\n  rw[comp\u2095_def,id_comp],\n end \n\nlemma comp_id\u2095 (f : hom\u2095 P Q) : comp\u2095 f (id\u2095 P) = f := \n begin \n  rcases f with \u27e8f\u27e9,\n  change comp\u2095 (component f) (component (id P)) = component f,\n  rw[comp\u2095_def,comp_id],\n end \n\nlemma comp_assoc\u2095 (h : hom\u2095 R S) (g : hom\u2095 Q R) (f : hom\u2095 P Q) : \n comp\u2095 (comp\u2095 h g) f = comp\u2095 h (comp\u2095 g f) := \n begin\n  rcases h with \u27e8h\u27e9, rcases g with \u27e8g\u27e9, rcases f with \u27e8f\u27e9,\n  change comp\u2095 (comp\u2095 (component h) (component g)) (component f) =\n         comp\u2095 (component h) (comp\u2095 (component g) (component f)),\n  repeat {rw[comp\u2095_def]},rw[comp_assoc],\n end\n\nvariables (P Q)\nstructure equiv\u2095 :=\n(to_fun : hom\u2095 P Q)\n(inv_fun : hom\u2095 Q P)\n(left_inv : comp\u2095 inv_fun to_fun = id\u2095 P)\n(right_inv : comp\u2095 to_fun inv_fun = id\u2095 Q)\n\n@[refl] def equiv\u2095.refl : equiv\u2095 P P := \n{ to_fun := id\u2095 P, inv_fun := id\u2095 P,\n  left_inv := comp_id\u2095 _,\n  right_inv := comp_id\u2095 _ }\n\nvariables {P Q}\n\n@[symm] def equiv\u2095.symm (e : equiv\u2095 P Q) : equiv\u2095 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\u2095.trans (e : equiv\u2095 P Q) (f : equiv\u2095 Q R) : (equiv\u2095 P R) := \n{ to_fun  := comp\u2095 f.to_fun e.to_fun,\n  inv_fun := comp\u2095 e.inv_fun f.inv_fun,\n  left_inv := by\n    rw [comp_assoc\u2095, \u2190 comp_assoc\u2095 _ f.inv_fun, f.left_inv,\n        id_comp\u2095, e.left_inv],\n  right_inv := by\n    rw [comp_assoc\u2095, \u2190 comp_assoc\u2095 _ e.to_fun, e.right_inv,\n        id_comp\u2095, f.right_inv] }\n\nlemma adjoint.unit\u2095 {f : hom P Q} {g : hom Q P} (h : adjoint f g) : \n  comp\u2095 (component g) (component f) = id\u2095 P := \nbegin\n  have : id P \u2264 comp g f := by { apply adjoint.unit, assumption },\n  exact (\u03c0\u2080.sound this).symm\nend\n\nlemma adjoint.counit\u2095 {f : hom P Q} {g : hom Q P} (h : adjoint f g) : \n  comp\u2095 (component f) (component g) = id\u2095 Q := \nbegin\n  have : comp f g \u2264 id Q := by { apply adjoint.counit, assumption },\n  exact (\u03c0\u2080.sound this)\nend\n\n/-- LaTeX: rem-adjoint-strong -/\ndef equiv\u2095_of_adjoint {f : hom P Q} {g : hom Q P} (h : adjoint f g) : \n  equiv\u2095 P Q :=\n{ to_fun := component f, \n  inv_fun := component g,\n  left_inv := adjoint.unit\u2095 h,\n  right_inv := adjoint.counit\u2095 h }\n\nvariable (P)\n\n/-- defn-strongly-contractible -/\ndef contractible\u2095 := nonempty (equiv\u2095 P punit.{uP + 1})\n\nvariable {P}\n\nlemma contractible\u2095_of_smallest {m : P} (h : \u2200 p, m \u2264 p) : contractible\u2095 P := \nbegin\n  have : adjoint (const punit.{uP + 1} m) (terminal P) :=\n  begin\n    unfold adjoint,\n    rintro \u27e8\u27e9 p,\n    change m \u2264 p \u2194 punit.star \u2264 punit.star,\n    simp only [le_refl, h p],\n  end,\n  let hh := equiv\u2095_of_adjoint this,\n  exact \u27e8hh.symm\u27e9,\nend\n\ndef \u03c0\u2080.map (f : hom P Q) : (\u03c0\u2080 P) \u2192 (\u03c0\u2080 Q) := \n \u03c0\u2080.lift (\u03bb p, component (f p)) (\u03bb p\u2080 p\u2081 ep, quot.sound (f.property ep))\n\nlemma \u03c0\u2080.map_def (f : hom P Q) (p : P) : \u03c0\u2080.map f (component p) = component (f p) := \n by { simp [\u03c0\u2080.map, \u03c0\u2080.lift_beta] }\n\nlemma \u03c0\u2080.map_congr {f\u2080 f\u2081 : hom P Q} (ef : f\u2080 \u2264 f\u2081) : \u03c0\u2080.map f\u2080 = \u03c0\u2080.map f\u2081 := \nbegin \n  apply \u03c0\u2080.epi,\n  intro p,\n  rw [\u03c0\u2080.map_def, \u03c0\u2080.map_def],\n  exact \u03c0\u2080.sound (ef p)\nend\n\nvariable (P)\nlemma \u03c0\u2080.map_id : \u03c0\u2080.map (id P) = _root_.id := \n by { apply \u03c0\u2080.epi, intro p, rw[\u03c0\u2080.map_def], refl }\nvariable {P}\n\nlemma \u03c0\u2080.map_comp (g : hom Q R) (f : hom P Q) :\n \u03c0\u2080.map (comp g f) = (\u03c0\u2080.map g) \u2218 (\u03c0\u2080.map f) := \n  by { apply \u03c0\u2080.epi, intro p, rw[\u03c0\u2080.map_def], refl }\n\ndef eval\u2095 : (hom\u2095 P Q) \u2192 (\u03c0\u2080 P) \u2192 (\u03c0\u2080 Q) := \n \u03c0\u2080.lift \u03c0\u2080.map (@\u03c0\u2080.map_congr _ _ _ _)\n\nvariables {P Q}\n\ndef comma (f : hom P Q) (q : Q) := { p : P // f p \u2264 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 \u2264 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\u2095 and cofinal\u2095.  \n  If (final\u2095 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\u2095 (f : hom P Q) : Prop := \n  \u2200 q, contractible\u2095 (cocomma f q)\n\ndef cofinal\u2095 (f : hom P Q) : Prop := \n  \u2200 q, contractible\u2095 (comma f q)\n\n\nvariable (P)\n\nstructure fin_ranking := \n(card : \u2115)\n(rank : P \u2243 fin card)\n(rank_mono : monotone rank.to_fun)\n\nsection sort \n\nvariable {P}\nvariable [decidable_rel (has_le.le : P \u2192 P \u2192 Prop)]\n\ndef is_semisorted (l : list P) : Prop := \n  l.pairwise (\u03bb a b, \u00ac b < a)\n\nlemma mem_ordered_insert (x p : P) (l : list P) : \n  x \u2208 (l.ordered_insert has_le.le p) \u2194 x = p \u2228 x \u2208 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 \u27e8\u27e8\u27e9\u27e9 | 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 \u27e8\u27e8\u27e9\u27e9 | 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 \u2192 P \u2192 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 : \u2200 p, p \u2208 l := \u03bb p,\n  begin \n    apply list.mem_map.mpr,\n    exact \u27e8f.to_fun p, \u27e8fin.elems_list_complete (f.to_fun p),f.left_inv p\u27e9\u27e9\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 : \u2200 p, p \u2208 ls := \u03bb 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) \u2192 P := \n    \u03bb i, ls.nth_le i.val (@eq.subst \u2115 (nat.lt i.val) _ _ ls_length.symm i.is_lt),\n  let to_fun_aux : \u2200 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 \u2115 (nat.lt i_val) _ _ ls_length i_lt_l,\n    let i : fin n := \u27e8i_val,i_lt_n\u27e9,\n    have : inv_fun i = p := list.index_of_nth_le i_lt_l,\n    exact \u27e8i,this\u27e9 \n  end,\n  let to_fun : P \u2192 (fin n) := \u03bb p, (to_fun_aux p).val,\n  let left_inv : \u2200 p : P, inv_fun (to_fun p) = p := \n    \u03bb p, (to_fun_aux p).property,\n  let right_inv : \u2200 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 \u2115 (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 \u2243 (fin n) := \u27e8to_fun,inv_fun,left_inv,right_inv\u27e9,\n  have g_mono : monotone g.to_fun := \u03bb 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 \u2264 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 \u27e8\u27e8n,g,g_mono\u27e9\u27e9\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 (\u03b1 : Type*) (\u03b2 : Type*) :=\n  (data : \u03b1 -> option \u03b2)\n\nnamespace Dict\n  variables {\u03b1 \u03b2 : Type*}\n  [decidable_eq \u03b1]\n\n  def empty : Dict \u03b1 \u03b2 :=\n    \u27e8\u03bb k, none\u27e9\n\n  def add (d : Dict \u03b1 \u03b2) (k : \u03b1) (e : \u03b2) : Dict \u03b1 \u03b2 :=\n    \u27e8\u03bb k', if k' = k then e else d.data k'\u27e9\n  \n  def rem (d : Dict \u03b1 \u03b2) (k : \u03b1) : Dict \u03b1 \u03b2 :=\n    \u27e8\u03bb k', if k' = k then none else d.data k'\u27e9\n\n  def get (d : Dict \u03b1 \u03b2) (k : \u03b1) : option \u03b2 := d.data k\n  \n  def inDict (d : Dict \u03b1 \u03b2) (x : \u03b1) := d.get x \u2260 none \n\n  instance : has_mem \u03b1 (Dict \u03b1 \u03b2) := \u27e8\u03bb k d, inDict d k\u27e9 \n\n  def subDictOf (d1 d2 : Dict \u03b1 \u03b2) := \u2200 k \u2208 d1, d1.get k = d2.get k\n  \n  theorem emptySubdictAll (d : Dict \u03b1 \u03b2) : subDictOf empty d := \n  begin \n    intros k h,\n    exact congr_fun (false.rec (empty.get = \u03bb (k : \u03b1), get d k) (h rfl)) k,\n  end\n\n  theorem subDictSelf (d : Dict \u03b1 \u03b2) : subDictOf d d :=\n  begin \n    intros k h,\n    refl,\n  end\n\n  theorem getSome {d : Dict \u03b1 \u03b2} {x : \u03b1} {y : \u03b2} : Dict.get d x = (some y) -> x \u2208 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 \u03b1 \u03b2} (h : subDictOf d1 d2) : \n  \u2200 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) \u2192 FinInt sz \u2192 Bool\nabbrev FinIntPred2 := (sz: Nat) \u2192 FinInt sz \u2192 FinInt sz \u2192 Bool\nabbrev FinIntPred3 := (sz: Nat) \u2192 FinInt sz \u2192 FinInt sz \u2192 FinInt sz \u2192 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\u2081: FinIntPred2 := fun _ X Y =>\n  ((X ||| Y) - X) = ((X ^^^ -1) &&& Y)\n\ntheorem P\u2081_tautology8: isTautologyUpTo2 8 P\u2081 := by\n  native_decide\n\ndef P\u2082: FinIntPred2 := fun _ X Y =>\n  (X + Y) - (X &&& Y) = (X ||| Y)\n\ntheorem P\u2082_tautology8: isTautologyUpTo2 8 P\u2082 := by\n  native_decide\n\ndef P\u2083: 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\u2083_tautology8: isTautologyUpTo2 8 P\u2083 := by\n  native_decide\n\n--\n\naxiom alive1 (P: FinIntPred1):\n  isTautologyUpTo1 8 P \u2192 \u2200 sz n, P sz n\n\naxiom alive2 (P: FinIntPred2):\n  isTautologyUpTo2 8 P \u2192 \u2200 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\", \u27e8.i32, X\u27e9), (\"Y\", \u27e8.i32, Y\u27e9)\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\u2082_tautology8 _ X Y\n  simp [P\u2082] 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 (\u03b1 : Type) where\n--   mk : \u03b1 \u2192 QpfStruct \u03b1\n\nnamespace QpfStruct\n\n  abbrev HeadT  := Unit\n\n  @[simp]\n  abbrev ChildT : HeadT \u2192 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 (\u03b1 : Type)\n    := Fix P.Obj (fun _ => \u03b1)\n\n  abbrev mk {\u03b1 : Type} (a : \u03b1) : QpfStruct \u03b1\n    := Fix.mk \u27e8(), fun i _ => match i with  \n                                | 0 => by contradiction\n                                | 1 => a\n    \u27e9\n\n  -- def rec {\u03b1} \n  --         {motive : QpfStruct \u03b1 \u2192 Sort _} \n  --         : ((a : \u03b1) \u2192 motive (mk a))\n  --         \u2192 (t : QpfStruct \u03b1)\n  --         \u2192 motive t := \n  --   fun recurse t =>\n  --     let g := fun \u27e8a, f\u27e9 =>\n  --       by cases a\n  --          let a := f 1(a\u2081, ..., a\u2098).append1, Vec.cons] at a;\n  --          apply recurse a\n  --     Fix.drec (\u03b2 := motive) g t\n\n  abbrev rec {\u03b1 motive} := Fix.drec (F:=P.Obj) (\u03b1 := \u03b1) (\u03b2 := motive)\n\n  -- open MvPFunctor in\n  -- example : QpfStruct \u03b1 \u2192 \u03b1 :=\n  --   by intro x\n  --      let x := Fix.dest x;\n  --      simp [Obj, TypeVec.append1] at x;\n  --      cases x\n  --     --  have : \u2203 a f, x = Fix.mk \u27e8a, f\u27e9\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 {\u03b1 : Type u} [comm_ring \u03b1] (P : set \u03b1) [hp : is_proper_ideal P]\ninclude hp\n\ndef find_maximal_ideal.partial_order : partial_order {S : set \u03b1 // P \u2286 S \u2227 is_proper_ideal S} :=\nsubrel.partial_order\n\ndef find_maximal_ideal.inhabited : inhabited {S : set \u03b1 // P \u2286 S \u2227 is_proper_ideal S} :=\n\u27e8\u27e8P, set.subset.refl P, hp\u27e9\u27e9\n\nlocal attribute [instance] find_maximal_ideal.partial_order find_maximal_ideal.inhabited\n\nprivate theorem find_maximal_ideal.aux :\n  \u2203 (M : {S : set \u03b1 // P \u2286 S \u2227 is_proper_ideal S}), \u2200 x, M \u2264 x \u2192 x = M :=\nzorn.zorn' {S : set \u03b1 // P \u2286 S \u2227 is_proper_ideal S} $\n\u03bb c x hx hc, \u27e8\u27e8{y | \u2203 S : {S : set \u03b1 // P \u2286 S \u2227 is_proper_ideal S}, S \u2208 c \u2227 y \u2208 S.val},\n  \u03bb z hz, \u27e8x, hx, x.2.1 hz\u27e9,\n  { zero_ := \u27e8x, hx, @@is_ideal.zero _ x.1 x.2.2.to_is_ideal\u27e9,\n    add_  := \u03bb x y \u27e8Sx, hxc, hx\u27e9 \u27e8Sy, hyc, hy\u27e9,\n      or.cases_on (hc Sx Sy hxc hyc)\n        (\u03bb hxy, \u27e8Sy, hyc, @@is_ideal.add _ Sy.2.2.to_is_ideal (hxy hx) hy\u27e9)\n        (\u03bb hyx, \u27e8Sx, hxc, @@is_ideal.add _ Sx.2.2.to_is_ideal hx (hyx hy)\u27e9),\n    smul  := \u03bb x y \u27e8Sy, hyc, hy\u27e9,\n      \u27e8Sy, hyc, @@is_ideal.mul_left _ Sy.2.2.to_is_ideal hy\u27e9,\n    ne_univ := \u03bb h, by rw set.eq_univ_iff_forall at h;\n      rcases h 1 with \u27e8S, hsc, hs\u27e9; 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 }\u27e9,\n\u03bb S hsc z hzs, \u27e8S, hsc, hzs\u27e9\u27e9\n\ndef find_maximal_ideal : set \u03b1 :=\n(classical.some find_maximal_ideal.aux).1\n\ntheorem find_maximal_ideal.contains : P \u2286 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 \u03b1 // P \u2286 S \u2227 is_proper_ideal S} :=\nclassical.some find_maximal_ideal.aux in\n{ eq_or_univ_of_subset := \u03bb T ht hmt, or_iff_not_imp_right.2 $\n    \u03bb h, congr_arg subtype.val $\n    classical.some_spec find_maximal_ideal.aux\n    \u27e8T, set.subset.trans M.2.1 hmt, { ne_univ := h, .. ht }\u27e9 hmt,\n  ..M.2.2 }\n\nend maximal_ideal\n\nsection nonunits\n\nparameters {\u03b1 : Type u} [comm_ring \u03b1]\nparameters (x : \u03b1) (hx : x \u2208 nonunits \u03b1)\n\ninclude hx\n\ntheorem ne_univ_of_nonunits : span ({x}:set \u03b1) \u2260 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 \u03b1 :=\n@@find_maximal_ideal _ (span ({x}:set \u03b1))\n{ ne_univ := ne_univ_of_nonunits }\n\ntheorem find_maximal_ideal.of_nonunits.mem :\n  x \u2208 find_maximal_ideal.of_nonunits :=\n@@find_maximal_ideal.contains _ (span ({x}:set \u03b1))\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 \u03b1))\n{ ne_univ := ne_univ_of_nonunits }\n\nend nonunits\n\nsection zero_ne_one\n\nparameters {\u03b1 : Type u} [comm_ring \u03b1]\nparameters (hzo : (0:\u03b1) \u2260 1)\n\ninclude hzo\n\ndef find_maximal_ideal.of_zero_ne_one : set \u03b1 :=\nfind_maximal_ideal.of_nonunits 0 $\n\u03bb \u27e8y, h\u27e9, 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\u03bb \u27e8y, h\u27e9, 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, Mario Carneiro\n\nThe Schr\u00f6der-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 {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (hf : injective f)\n    (hg : injective g) : \u2203 (h : \u03b1 \u2192 \u03b2), bijective h :=\n  sorry\n\ntheorem antisymm {\u03b1 : Type u} {\u03b2 : Type v} : (\u03b1 \u21aa \u03b2) \u2192 (\u03b2 \u21aa \u03b1) \u2192 Nonempty (\u03b1 \u2243 \u03b2) := sorry\n\ntheorem min_injective {\u03b9 : Type u} {\u03b2 : \u03b9 \u2192 Type v} (I : Nonempty \u03b9) :\n    \u2203 (i : \u03b9), Nonempty ((j : \u03b9) \u2192 \u03b2 i \u21aa \u03b2 j) :=\n  sorry\n\ntheorem total {\u03b1 : Type u} {\u03b2 : Type v} : Nonempty (\u03b1 \u21aa \u03b2) \u2228 Nonempty (\u03b2 \u21aa \u03b1) := 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 ` \u211d\u22650 ` := nnreal\n\ninstance : metric_space \u211d\u22650 := by unfold nnreal; apply_instance\ninstance : topological_space \u211d\u22650 := infer_instance\n\ninstance : topological_semiring \u211d\u22650 :=\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 \u211d\u22650 :=\n\u27e8 le_antisymm\n    begin\n      apply induced_le_iff_le_coinduced.2,\n      rw [orderable_topology.topology_eq_generate_intervals \u211d],\n      apply generate_from_le,\n      assume s hs,\n      rcases hs with \u27e8a, rfl | rfl\u27e9,\n      { show topological_space.generate_open _ {b : \u211d\u22650 | a < b },\n        by_cases ha : 0 \u2264 a,\n        { exact topological_space.generate_open.basic _ \u27e8\u27e8a, ha\u27e9, or.inl rfl\u27e9 },\n        { have : a < 0, from lt_of_not_ge ha,\n          have : {b : \u211d\u22650 | 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 : \u211d\u22650 | a > b },\n        by_cases ha : 0 \u2264 a,\n        { exact topological_space.generate_open.basic _ \u27e8\u27e8a, ha\u27e9, or.inr rfl\u27e9 },\n        { have : {b : \u211d\u22650 | a > b } = \u2205,\n            from (set.eq_empty_iff_forall_not_mem.2 $ assume b hb, ha $\n              show 0 \u2264 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    | _, \u27e8\u27e8a, ha\u27e9, or.inl rfl\u27e9 := \u27e8{b : \u211d | a < b}, is_open_lt' a, rfl\u27e9\n    | _, \u27e8\u27e8a, ha\u27e9, or.inr rfl\u27e9 := \u27e8{b : \u211d | b < a}, is_open_gt' a, set.ext $ assume b, iff.refl _\u27e9\n    end) \u27e9\n\nsection coe\nvariable {\u03b1 : 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 \u2192 \u211d) :=\ncontinuous_subtype_val\n\nlemma tendsto_coe {f : filter \u03b1} {m : \u03b1 \u2192 nnreal} :\n  \u2200{x : nnreal}, tendsto (\u03bba, (m a : \u211d)) f (nhds (x : \u211d)) \u2194 tendsto m f (nhds x)\n| \u27e8r, hr\u27e9 := by rw [nhds_subtype_eq_comap, tendsto_comap_iff]; refl\n\nlemma tendsto_of_real {f : filter \u03b1} {m : \u03b1 \u2192 \u211d} {x : \u211d} (h : tendsto m f (nhds x)):\n  tendsto (\u03bba, 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 \u03b1} {m n : \u03b1 \u2192 nnreal} {r p : nnreal}\n  (hm : tendsto m f (nhds r)) (hn : tendsto n f (nhds p)) :\n  tendsto (\u03bba, 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 : \u03b1 \u2192 nnreal} {r : nnreal} : is_sum (\u03bba, (f a : \u211d)) (r : \u211d) \u2194 is_sum f r :=\nby simp [is_sum, sum_coe.symm, tendsto_coe]\n\nlemma has_sum_coe {f : \u03b1 \u2192 nnreal} : has_sum (\u03bba, (f a : \u211d)) \u2194 has_sum f :=\nbegin\n  simp [has_sum],\n  split,\n  exact assume \u27e8a, ha\u27e9, \u27e8\u27e8a, is_sum_le (\u03bba, (f a).2) is_sum_zero ha\u27e9, is_sum_coe.1 ha\u27e9,\n  exact assume \u27e8a, ha\u27e9, \u27e8a.1, is_sum_coe.2 ha\u27e9\nend\n\nlemma tsum_coe {f : \u03b1 \u2192 nnreal} (hf : has_sum f) : (\u2211a, (f a : \u211d)) = \u2191(\u2211a, 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 {\u03b1 : Type} [inhabited \u03b1] (P : \u03b1 \u2192 Prop) : \u03b1 :=\nif h : \u2203 (x : \u03b1), P x then h.some else default\n\ndef fixed {\u03b1 : Type} [inhabited \u03b1] (f : \u03b1 \u2192 \u03b1) (z : \u03b1) : \u03b1 :=\nget_some (\u03bb (x : \u03b1), \u2203 (n : \u2115), (f^[n]) z = x \u2227 (f^[n + 1]) z = x)\n\ndef all {\u03b1 : Type} (P : \u03b1 \u2192 Prop) (l : list \u03b1) : Prop := l.all (\u03bb (x : \u03b1), P x)\n\ndef is_digit (n : \u2115) : Prop := n \u2264 9\n\ndef is_digit_list (l : list \u2115) : Prop := all is_digit l\n\ndef get_digits (n : \u2115) : list \u2115 :=\nget_some (\u03bb (l : list \u2115), is_digit_list l \u2227 l.foldl (\u03bb (a b : \u2115), a * 10 + b) 0 = n)\n\ndef sum_digits (n : \u2115) : \u2115 := (get_digits n).sum\n\ndef digital_root (n : \u2115) : \u2115 := fixed sum_digits n\n\n-----\n\nlemma get_some_pos {\u03b1 : Type} [inhabited \u03b1] {P : \u03b1 \u2192 Prop}\n  (h : \u2203 (x : \u03b1), P x) : get_some P = h.some :=\ndif_pos h\n\nlemma get_some_eq_get_some_of_exists_iff {\u03b1 \u03b2 : Type} [inhabited \u03b1]\n  {P\u2081 P\u2082 : \u03b1 \u2192 Prop} {f : \u03b1 \u2192 \u03b2}\n  (h\u2081 : (\u2203 (x : \u03b1), P\u2081 x) \u2194 (\u2203 (x : \u03b1), P\u2082 x))\n  (h\u2082 : \u2200 (h\u2081 : \u2203 (x : \u03b1), P\u2081 x) (h\u2082 : \u2203 (x : \u03b1), P\u2082 x), f h\u2081.some = f h\u2082.some) :\n  f (get_some P\u2081) = f (get_some P\u2082) :=\nbegin\n  simp_rw [get_some, h\u2081], split_ifs with h\u2083,\n  { apply h\u2082 },\n  { refl },\nend\n\ndef reversed {\u03b1 : Type} (f : list \u03b1 \u2192 list \u03b1) (l : list \u03b1) : list \u03b1 :=\n(f l.reverse).reverse\n\ndef trim_start : list \u2115 \u2192 list \u2115\n| (0::l) := trim_start l\n| l := l\n\ndef trim_end : list \u2115 \u2192 list \u2115 :=\nreversed trim_start\n\ninstance {n : \u2115} : decidable (is_digit n) :=\nby { rw is_digit, apply_instance }\n\nlemma list_reverse_snoc {\u03b1 : Type} {l : list \u03b1} {x : \u03b1} :\n  (l ++ [x]).reverse = x :: l.reverse := list.reverse_append _ _\n\nlemma trim_start_zero_cons {l : list \u2115} : trim_start (0 :: l) = trim_start l := rfl\n\nlemma trim_start_succ_cons {l : list \u2115} {n : \u2115} :\n  trim_start (n.succ :: l) = n.succ :: l := rfl\n\nlemma trim_end_snoc_zero {l : list \u2115} : 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 {\u03b1 : Type} {l : list \u03b1} {x : \u03b1} :\n  (l ++ [x]).length = l.length + 1 := list.length_append _ _\n\nlemma trim_end_snoc_succ {l : list \u2115} {n : \u2115} :\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 \u2115} : (trim_end l).length \u2264 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 {\u03b1 : Type} {x : \u03b1} {n : \u2115} :\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 \u2115} :\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, \u2190list.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 {\u03b1 : Type} {P : \u03b1 \u2192 Prop} : all P [] := by simp [all]\n\nlemma all_cons {\u03b1 : Type} {P : \u03b1 \u2192 Prop} {l : list \u03b1} {x : \u03b1} :\n  all P (x :: l) \u2194 P x \u2227 all P l := by simp [all]\n\nlemma all_iff {\u03b1 : Type} {P : \u03b1 \u2192 Prop} {l : list \u03b1} : all P l \u2194 \u2200 (x \u2208 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 {\u03b1 : Type} {P : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1} :\n  all P (l\u2081 ++ l\u2082) \u2194 all P l\u2081 \u2227 all P l\u2082 :=\nbegin\n  simp_rw all_iff, split; intro h,\n  { split; rintro n h\u2081; apply h n,\n    { exact list.mem_append_left _ h\u2081 },\n    { exact list.mem_append_right _ h\u2081 }},\n  { cases h with h\u2081 h\u2082, rintro n h\u2083, rw list.mem_append_eq at h\u2083, cases h\u2083,\n    { exact h\u2081 _ h\u2083 },\n    { exact h\u2082 _ h\u2083 }},\nend\n\nlemma all_singleton {\u03b1 : Type} {P : \u03b1 \u2192 Prop} {x : \u03b1} : all P [x] \u2194 P x :=\nbegin\n  simp_rw all_iff, split; intro h,\n  { exact h _ (list.mem_singleton_self _) },\n  { rintro m h\u2081, rw list.mem_singleton at h\u2081, subst m, exact h },\nend\n\nlemma all_snoc {\u03b1 : Type} {P : \u03b1 \u2192 Prop} {l : list \u03b1} {x : \u03b1} :\n  all P (l ++ [x]) \u2194 all P l \u2227 P x := by rw [all_append, all_singleton]\n\nlemma all_reverse {\u03b1 : Type} {P : \u03b1 \u2192 Prop} {l : list \u03b1} : all P l.reverse \u2194 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\u2081 d\u2082 : \u2115} (h : is_digit (d\u2081 + d\u2082)) :\n  is_digit d\u2081 \u2227 is_digit d\u2082 := \u27e8le_of_add_le_left h, le_of_add_le_right h\u27e9\n\nlemma not_is_digit_add_10 {n : \u2115} : \u00acis_digit (n + 10) := dec_trivial\n\nlemma is_digit_mul_10 {n : \u2115} : is_digit (n * 10) \u2194 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 \u2115}\n  (h : l.foldr (\u03bb (a b : \u2115), 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 \u27e8rfl, h\u27e9,\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 \u2115} {d : \u2115}\n  (h\u2081 : is_digit_list l) (h\u2082 : is_digit d)\n  (h\u2083 : l.foldr (\u03bb (a b : \u2115), a + b * 10) 0 = d) : l.sum = d :=\nbegin\n  cases l with d\u2081 l,\n  { exact h\u2083 },\n  { rw list.sum_cons, rw list.foldr_cons at h\u2083, rw [is_digit_list, all_cons] at h\u2081,\n    cases h\u2081 with h\u2081 h\u2084, subst d, congr, have h\u2083 := (is_digit_of_is_digit_add h\u2082).2,\n    rw is_digit_mul_10 at h\u2083, rw h\u2083, exact sum_eq_zero_of_foldr_eq_zero h\u2083 },\nend\n\nlemma is_digit_succ {n : \u2115} : is_digit n.succ \u2194 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 [\u2190nat.succ_le_iff, le_iff_lt_or_eq] at h },\nend\n\nlemma nat_exi_mul (x y : \u2115) :\n  \u2203 (a b : \u2115), a = x / y \u2227 b = x % y \u2227 x = a * y + b :=\nby { simp_rw mul_comm, exact \u27e8_, _, rfl, rfl, (nat.div_add_mod _ _).symm\u27e9 }\n\nlemma is_digit_mod_10 {n : \u2115} : is_digit (n % 10) :=\nby { rw [is_digit, \u2190nat.lt_succ_iff], apply nat.mod_lt, dec_trivial }\n\nlemma digit_ind {P : \u2115 \u2192 Prop} {n : \u2115}\n  (h\u2081 : P 0) (h\u2082 : \u2200 (d n : \u2115), is_digit d \u2192 P n \u2192 P (d + n * 10)) : P n :=\nbegin\n  induction n using nat.strong_induction_on with n ih, dsimp at ih,\n  obtain \u27e8a, b, ha, hb, h\u2083\u27e9 := nat_exi_mul n 10, rw [h\u2083, add_comm], apply h\u2082,\n  { rw hb, exact is_digit_mod_10 },\n  { rw ha, cases n,\n    { exact h\u2081 },\n    { apply ih, apply nat.div_lt_self; dec_trivial }},\nend\n\ndef all_zeros (l : list \u2115) : Prop := all (\u03bb (n : \u2115), n = 0) l\n\nlemma foldr_eq_zero_iff {l : list \u2115} :\n  l.foldr (\u03bb (a b : \u2115), a + b * 10) 0 = 0 \u2194 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, \u2190all_zeros, \u2190ih,\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 \u2115} : trim_end l = [] \u2194 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 : \u2115} (h : a + b < c) : a < c := buffer.lt_aux_1 h\n\nlemma right_lt_of_add_lt {a b c : \u2115} (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 : \u2115} (h : a + b < c) : a < c \u2227 b < c :=\n\u27e8left_lt_of_add_lt h, right_lt_of_add_lt h\u27e9\n\nlemma not_add_self_lt_self {a b : \u2115} : \u00aca + b < b :=\nby { intro h, cases lt_irrefl _ (right_lt_of_add_lt h) }\n\nlemma eq_zero_of_mul_lt_self {a b : \u2115} (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\u2081 d\u2082 a b : \u2115} (h\u2081 : d\u2081 < k) (h\u2082 : d\u2082 < k) :\n  d\u2081 + a * k = d\u2082 + b * k \u2194 d\u2081 = d\u2082 \u2227 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\u2081, have h\u2083 := right_lt_of_add_lt h\u2081,\n      rw mul_comm at h\u2083, replace h\u2083 := eq_zero_of_mul_lt_self h\u2083, subst b,\n      rw zero_mul, exact \u27e8rfl, rfl\u27e9 },\n    { rw [nat.succ_mul, \u2190add_assoc] at h, cases b,\n      { rw [zero_mul, add_zero] at h, subst d\u2082, cases not_add_self_lt_self h\u2082 },\n      { rw [nat.succ_mul, \u2190add_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 : \u2115} (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\u2081 d\u2082 a b : \u2115}\n  (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) :\n  d\u2081 + a * 10 = d\u2082 + b * 10 \u2194 d\u2081 = d\u2082 \u2227 a = b :=\nby { rw add_mul_eq_add_mul_iff; apply digit_lt_10; assumption }\n\nlemma trim_end_cons {l : list \u2115} {n : \u2115} :\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, \u2190all_zeros] at h, rcases h with \u27e8h, rfl\u27e9,\n      specialize ih h, rwa [\u2190list.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 \u2190list.cons_append,\n      rw [all_zeros, all_snoc, \u2190all_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 \u2115} (h : all_zeros l) : trim_end l = [] :=\nby rwa trim_end_eq_nil_iff\n\nlemma trim_end_singleton {n : \u2115} : 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\u2081 l\u2082 : list \u2115} {n : \u2115}\n  (h\u2081 : all_zeros l\u2081) (h\u2082 : \u00acall_zeros l\u2082) :\n  trim_end [n] = n :: trim_end l\u2082 \u2194 trim_end l\u2081 = trim_end l\u2082 :=\nbegin\n  rw trim_end_all_zeros h\u2081, split; intro h,\n  { rw trim_end_singleton at h, split_ifs at h with h\u2083,\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\u2081 l\u2082 : list \u2115} {n : \u2115} :\n  trim_end (n :: l\u2081) = trim_end (n :: l\u2082) \u2194 trim_end l\u2081 = trim_end l\u2082 :=\nbegin\n  nth_rewrite 0 trim_end_cons, nth_rewrite 1 trim_end_cons, split_ifs with h\u2081 h\u2082 h\u2082,\n  { simp [trim_end_all_zeros h\u2081, trim_end_all_zeros h\u2082] },\n  { exact trim_end_same_cons_eq_iff_aux h\u2081 h\u2082 },\n  { have := @trim_end_same_cons_eq_iff_aux _ _ n h\u2082 h\u2081, tauto },\n  { simp }\nend\n\nlemma trim_end_eq_trim_end_of_foldr_eq_foldr {l\u2081 l\u2082 : list \u2115}\n  (h\u2081 : is_digit_list l\u2081) (h\u2082 : is_digit_list l\u2082)\n  (h\u2083 : l\u2081.foldr (\u03bb (a b : \u2115), a + b * 10) 0 = l\u2082.foldr (\u03bb (a b : \u2115), a + b * 10) 0) :\n  trim_end l\u2081 = trim_end l\u2082 :=\nbegin\n  induction l\u2081 with n l\u2081 ih generalizing l\u2082,\n  { rw trim_end_nil, symmetry' at h\u2083 \u22a2, change _ = 0 at h\u2083,\n    rw foldr_eq_zero_iff at h\u2083, rwa trim_end_eq_nil_iff },\n  { rw [is_digit_list, all_cons, \u2190is_digit_list] at h\u2081,\n    cases h\u2081 with h\u2081 h\u2084, specialize @ih h\u2084, cases l\u2082 with m l\u2082,\n    { change _ = 0 at h\u2083,\n      rw [list.foldr_cons, add_eq_zero_iff, mul_eq_zero, foldr_eq_zero_iff] at h\u2083,\n      rcases h\u2083 with \u27e8rfl, h\u2083\u27e9, rw [trim_end_nil, trim_end_eq_nil_iff, all_zeros, all_cons],\n      use rfl, cases h\u2083,\n      { exact h\u2083 },\n      { cases h\u2083 }},\n    { rw [is_digit_list, all_cons, \u2190is_digit_list] at h\u2082, cases h\u2082 with h\u2082 h\u2085,\n      simp_rw [list.foldr_cons, digit_add_mul_10_eq_digit_add_mul_10_iff h\u2081 h\u2082] at h\u2083,\n      rcases h\u2083 with \u27e8rfl, h\u2083\u27e9, rw trim_end_same_cons_eq_iff, exact ih h\u2085 h\u2083 }},\nend\n\nlemma exi_eq_append_zeros_of_foldr_eq_foldr {l\u2081 l\u2082 : list \u2115}\n  (h\u2081 : is_digit_list l\u2081) (h\u2082 : is_digit_list l\u2082)\n  (h\u2083 : l\u2081.foldr (\u03bb (a b : \u2115), a + b * 10) 0 = l\u2082.foldr (\u03bb (a b : \u2115), a + b * 10) 0) :\n  \u2203 (l : list \u2115) (n\u2081 n\u2082 : \u2115), l\u2081 = l ++ list.repeat 0 n\u2081 \u2227 l\u2082 = l ++ list.repeat 0 n\u2082 :=\nbegin\n  use [trim_end l\u2081, l\u2081.length - (trim_end l\u2081).length, l\u2082.length - (trim_end l\u2081).length,\n    trim_end_append_repeat_zero.symm], symmetry,\n  rw [(_ : trim_end l\u2081 = trim_end l\u2082), trim_end_append_repeat_zero],\n  exact trim_end_eq_trim_end_of_foldr_eq_foldr h\u2081 h\u2082 h\u2083,\nend\n\nlemma sum_append_repeat_zero {l : list \u2115} {n : \u2115} :\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\u2081 l\u2082 : list \u2115}\n  (h\u2081 : is_digit_list l\u2081) (h\u2082 : is_digit_list l\u2082)\n  (h\u2083 : l\u2081.foldr (\u03bb (a b : \u2115), a + b * 10) 0 = l\u2082.foldr (\u03bb (a b : \u2115), a + b * 10) 0) :\n  l\u2081.sum = l\u2082.sum :=\nbegin\n  obtain \u27e8l, n\u2081, n\u2082, rfl, rfl\u27e9 := exi_eq_append_zeros_of_foldr_eq_foldr h\u2081 h\u2082 h\u2083,\n  simp_rw sum_append_repeat_zero,\nend\n\nlemma sum_eq_sum_of_foldl_eq_foldr {l\u2081 l\u2082 : list \u2115}\n  (h\u2081 : is_digit_list l\u2081) (h\u2082 : is_digit_list l\u2082)\n  (h\u2083 : l\u2081.foldl (\u03bb (a b : \u2115), a * 10 + b) 0 = l\u2082.foldr (\u03bb (a b : \u2115), a + b * 10) 0) :\n  l\u2081.sum = l\u2082.sum :=\nbegin\n  rw \u2190list.sum_reverse l\u2081,\n  rw \u2190list.foldr_reverse _ _ l\u2081 at h\u2083,\n  rename l\u2081 l,\n  rw [is_digit_list, \u2190all_reverse, \u2190is_digit_list] at h\u2081,\n  revert h\u2081 h\u2083,\n  generalize : l.reverse = l\u2081,\n  rintro h\u2081 h\u2083,\n  clear l,\n  replace h\u2083 : list.foldr (\u03bb a b, a + b * 10) 0 l\u2081 = list.foldr (\u03bb a b, a + b * 10) 0 l\u2082,\n  { convert h\u2083; ext a b; rw add_comm },\n  exact sum_eq_sum_of_foldr_eq_foldr h\u2081 h\u2082 h\u2083,\nend\n\nlemma exi_foldl_iff_exi_foldr {n : \u2115} :\n  (\u2203 (l : list \u2115), is_digit_list l \u2227 l.foldl (\u03bb (a b : \u2115), a * 10 + b) 0 = n) \u2194\n  (\u2203 (l : list \u2115), is_digit_list l \u2227 l.foldr (\u03bb (a b : \u2115), a + b * 10) 0 = n) :=\nbegin\n  split; rintro \u27e8l, hl, rfl\u27e9; use l.reverse;\n  { rw list.foldl_reverse <|> rw list.foldr_reverse,\n    simp_rw add_comm, rw [is_digit_list, all_reverse, \u2190is_digit_list], use hl },\nend\n\nlemma sum_digits_eq_get_some {n : \u2115} :\n  sum_digits n = (get_some (\u03bb (l : list \u2115), is_digit_list l \u2227\n    l.foldr (\u03bb (a b : \u2115), 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\u2081 h\u2082, have h\u2083 := h\u2081.some_spec, have h\u2084 := h\u2082.some_spec,\n  have h\u2085 : list.foldl (\u03bb (a b : \u2115), a * 10 + b) 0 h\u2081.some =\n    list.foldr (\u03bb (a b : \u2115), a + b * 10) 0 h\u2082.some := by rw [h\u2083.2, h\u2084.2],\n  exact sum_eq_sum_of_foldl_eq_foldr h\u2083.1 h\u2084.1 h\u2085,\nend\n\nlemma sum_digits_zero : sum_digits 0 = 0 :=\nbegin\n  rw [sum_digits_eq_get_some, get_some_pos], swap,\n  { exact \u27e8[], all_nil, rfl\u27e9 },\n  generalize_proofs h, exact sum_eq_zero_of_foldr_eq_zero h.some_spec.2,\nend\n\nlemma iter_sum_digits_zero {n : \u2115} : (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 \u27e80, 0, rfl, sum_digits_zero\u27e9 },\n  generalize_proofs h\u2081, obtain \u27e8n, h\u2082, h\u2083\u27e9 := h\u2081.some_spec,\n  rw iter_sum_digits_zero at h\u2082, exact h\u2082.symm,\nend\n\ndef modp (n k : \u2115) : \u2115 := if n % k = 0 then k else n % k\n\nlemma modp_digit_of_pos {d : \u2115} (h\u2081 : is_digit d) (h\u2082 : 0 < d) : modp d 9 = d :=\nbegin\n  rw modp, split_ifs,\n  { rw [is_digit, le_iff_lt_or_eq] at h\u2081, cases h\u2081,\n    { rw nat.mod_eq_of_lt h\u2081 at h, rw h at h\u2082, cases h\u2082 },\n    { exact h\u2081.symm }},\n  { rw [is_digit, le_iff_lt_or_eq] at h\u2081, cases h\u2081,\n    { exact nat.mod_eq_of_lt h\u2081 },\n    { subst d, contradiction }},\nend\n\nlemma sum_digits_digit {d : \u2115} (h : is_digit d) : sum_digits d = d :=\nbegin\n  rw [sum_digits_eq_get_some, get_some_pos], swap,\n  { exact \u27e8[d], all_singleton.mpr h, rfl\u27e9 },\n  generalize_proofs h\u2081, obtain \u27e8h\u2082, h\u2083\u27e9 := h\u2081.some_spec,\n  exact sum_eq_of_foldr_eq_digit h\u2082 h h\u2083,\nend\n\nlemma iterate_eq_self {\u03b1 : Type} {f : \u03b1 \u2192 \u03b1} {x : \u03b1} {n : \u2115}\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 {\u03b1 : Type} [inhabited \u03b1] {f : \u03b1 \u2192 \u03b1} {x : \u03b1}\n  (h : f x = x) : fixed f x = x :=\nbegin\n  rw [fixed, get_some_pos], swap,\n  { exact \u27e8x, 0, rfl, h\u27e9 },\n  generalize_proofs h\u2081, obtain \u27e8n, h\u2082, h\u2083\u27e9 := h\u2081.some_spec,\n  rw [\u2190h\u2082, iterate_eq_self h],\nend\n\nlemma digital_root_digit_eq_self {d : \u2115} (h : is_digit d) :\n  digital_root d = d := fixed_eq_self_of (sum_digits_digit h)\n\nlemma is_digit_modp_9 {n : \u2115} : 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\u2081 d\u2082 n : \u2115} (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082)\n  (h\u2083 : 9 \u2264 n) : is_digit (d\u2081 + d\u2082 - n) :=\nbegin\n  rw is_digit at h\u2081 h\u2082 \u22a2,\n  have h\u2084 := (add_le_add h\u2081 h\u2082).trans (add_le_add (le_refl _) h\u2083),\n  rwa tsub_le_iff_right,\nend\n\nlemma exi_digit_add_10_of_not_is_digit_add {d\u2081 d\u2082 : \u2115}\n  (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) (h\u2083 : \u00acis_digit (d\u2081 + d\u2082)) :\n  \u2203 (d : \u2115), is_digit d \u2227 d\u2081 + d\u2082 = d + 10 :=\nbegin\n  refine \u27e8d\u2081 + d\u2082 - 10, _, _\u27e9,\n  { apply is_digit_digit_add_digit_sub h\u2081 h\u2082, dec_trivial },\n  { rw [is_digit, not_le] at h\u2083, obtain \u27e8k, h\u2084\u27e9 := nat.exists_eq_add_of_lt h\u2083,\n    rw h\u2084, 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\u2081 d\u2082 : \u2115}\n  (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) (h\u2083 : \u00acis_digit (d\u2081 + d\u2082)) :\n  \u2203 (d : \u2115), is_digit d \u2227 d\u2081 + d\u2082 = d + 9 :=\nbegin\n  refine \u27e8d\u2081 + d\u2082 - 9, _, _\u27e9,\n  { apply is_digit_digit_add_digit_sub h\u2081 h\u2082, dec_trivial },\n  { rw [is_digit, not_le] at h\u2083, obtain \u27e8k, h\u2084\u27e9 := nat.exists_eq_add_of_lt h\u2083,\n    rw h\u2084, 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 : \u2115} (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 \u2115} {d : \u2115}\n  (h\u2081 : is_digit_list l) (h\u2082 : is_digit d)\n  (h\u2083 : l.foldr (\u03bb (a b : \u2115), a + b * 10) 0 = d + 10) : l.sum = d.succ :=\nbegin\n  cases l with d\u2081 l,\n  { cases h\u2083 },\n  { rw list.foldr_cons at h\u2083, rw [is_digit_list, all_cons, \u2190is_digit_list] at h\u2081,\n    cases h\u2081 with h\u2081 h\u2084, nth_rewrite 1 \u2190one_mul 10 at h\u2083,\n    rw digit_add_mul_10_eq_digit_add_mul_10_iff h\u2081 h\u2082 at h\u2083, rcases h\u2083 with \u27e8rfl, h\u2083\u27e9,\n    rw [list.sum_cons, sum_eq_of_foldr_eq_digit h\u2084 dec_trivial h\u2083] },\nend\n\nlemma sum_digits_pos_digit_add_9 {d : \u2115} (h\u2081 : is_digit d) (h\u2082 : 0 < d) :\n  sum_digits (d + 9) = d :=\nbegin\n  cases d,\n  { cases h\u2082 },\n  { rw [sum_digits_eq_get_some, get_some_pos], swap,\n    { refine \u27e8[d, 1], _, _\u27e9,\n      { simp_rw [is_digit_list, all_cons, all_nil],\n        exact \u27e8is_digit_of_is_digit_succ h\u2081, dec_trivial, trivial\u27e9 },\n      { refl }},\n    generalize_proofs h\u2083, obtain \u27e8h\u2084, h\u2085\u27e9 := h\u2083.some_spec, change _ = d + 10 at h\u2085,\n    exact sum_eq_of_foldr_eq_digit_add_10 h\u2084 (is_digit_of_is_digit_succ h\u2081) h\u2085 },\nend\n\nlemma pos_left_of_not_is_digit_digit_add_digit {d\u2081 d\u2082 : \u2115}\n  (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) (h\u2083 : \u00acis_digit (d\u2081 + d\u2082)) : 0 < d\u2081 :=\nby { rw is_digit at h\u2081 h\u2082 h\u2083, linarith }\n\nlemma pos_right_of_not_is_digit_digit_add_digit {d\u2081 d\u2082 : \u2115}\n  (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) (h\u2083 : \u00acis_digit (d\u2081 + d\u2082)) : 0 < d\u2082 :=\nby { rw add_comm at h\u2083, exact pos_left_of_not_is_digit_digit_add_digit h\u2082 h\u2081 h\u2083 }\n\nlemma sum_digits_digit_add_digit {d\u2081 d\u2082 : \u2115} (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) :\n  sum_digits (d\u2081 + d\u2082) = if d\u2081 + d\u2082 \u2264 9 then d\u2081 + d\u2082 else d\u2081 + d\u2082 - 9 :=\nbegin\n  split_ifs,\n  { exact sum_digits_digit h },\n  { obtain \u27e8d, h\u2083, h\u2084\u27e9 := exi_digit_add_9_of_not_is_digit_add h\u2081 h\u2082 h, have h\u2085 : 0 < d,\n    { rw h\u2084 at h, push_neg at h, rwa lt_add_iff_pos_left at h },\n    rw [h\u2084, sum_digits_pos_digit_add_9 h\u2083 h\u2085], refl },\nend\n\nlemma modp_of_le_of_pos {k d : \u2115} (h\u2081 : 0 < d) (h\u2082 : d \u2264 k) : modp d k = d :=\nbegin\n  rw modp, cases k,\n  { rw le_zero_iff at h\u2082, subst d, refl },\n  { split_ifs with h\u2083,\n    { rw le_iff_lt_or_eq at h\u2082, cases h\u2082,\n      { rw nat.mod_eq_of_lt h\u2082 at h\u2083, subst d, cases h\u2081 },\n      { subst d }},\n    { rw le_iff_lt_or_eq at h\u2082, cases h\u2082,\n      { exact nat.mod_eq_of_lt h\u2082 },\n      { subst d, cases h\u2083 (nat.mod_self _) }}},\nend\n\nlemma add_self_mod_eq_zero {a : \u2115} : (a + a) % a = 0 := by simp\n\nlemma modp_add {k a b : \u2115} : 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 : \u2115} (h : 0 < d) : 0 < modp d k :=\nbegin\n  rw modp, split_ifs with h\u2081,\n  { by_contra' h\u2082, rw le_zero_iff at h\u2082, subst k,\n    rw nat.mod_zero at h\u2081, subst d, cases h },\n  { rwa pos_iff_ne_zero },\nend\n\nlemma digital_root_eq_self_of {n : \u2115} (h : sum_digits n = n) :\n  digital_root n = n := fixed_eq_self_of h\n\nlemma modp_zero {d : \u2115} : 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 : \u2115} (h\u2081 : 0 < d) (h\u2082 : d < k) : modp d k = d :=\nbegin\n  rw modp, split_ifs,\n  { rw nat.mod_eq_of_lt h\u2082 at h, subst d, cases h\u2081 },\n  { rw nat.mod_eq_of_lt h\u2082 },\nend\n\nlemma modp_self {k : \u2115} : modp k k = k :=\nby { rw [modp, nat.mod_self], refl }\n\nlemma modp_of_le {k d : \u2115} (h\u2081 : 0 < d) (h\u2082 : d \u2264 k) : modp d k = d :=\nbegin\n  rw le_iff_lt_or_eq at h\u2082, cases h\u2082,\n  { exact modp_of_lt h\u2081 h\u2082 },\n  { subst d, rw modp_self },\nend\n\nlemma modp_add_self {k d : \u2115} : modp (d + k) k = modp d k :=\nbegin\n  simp_rw modp, split_ifs with h\u2081 h\u2082 h\u2082;\n  try { rw nat.add_mod_right at h\u2081, contradiction },\n  { refl },\n  { rw nat.add_mod_right },\nend\n\nlemma modp_of_gt_of_lt_mul_2 {k d : \u2115} (h\u2081 : k < d) (h\u2082 : d < k * 2) : modp d k = d - k :=\nbegin\n  obtain \u27e8n, rfl\u27e9 := nat.exists_eq_add_of_lt h\u2081, clear h\u2081,\n  replace h\u2082 : 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\u2082,\nend\n\nlemma modp_add_lt {k d\u2081 d\u2082 : \u2115} (h\u2081 : 0 < d\u2081 \u2228 0 < d\u2082) (h\u2082 : d\u2081 < k) (h\u2083 : d\u2082 < k) :\n  modp (d\u2081 + d\u2082) k = if d\u2081 + d\u2082 \u2264 k then d\u2081 + d\u2082 else d\u2081 + d\u2082 - k :=\nbegin\n  split_ifs with h\u2084,\n  { exact modp_of_le ((nat.add_pos_iff_pos_or_pos d\u2081 d\u2082).mpr h\u2081) h\u2084 },\n  { push_neg at h\u2084, apply modp_of_gt_of_lt_mul_2 h\u2084, rw mul_two, exact add_lt_add h\u2082 h\u2083 },\nend\n\nlemma modp_add_le_aux {k d : \u2115} (h : d < k) :\n  modp (d + k) k = if d + k \u2264 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\u2081 d\u2082 : \u2115} (h\u2081 : 0 < d\u2081 \u2228 0 < d\u2082) (h\u2082 : d\u2081 \u2264 k) (h\u2083 : d\u2082 \u2264 k) :\n  modp (d\u2081 + d\u2082) k = if d\u2081 + d\u2082 \u2264 k then d\u2081 + d\u2082 else d\u2081 + d\u2082 - k :=\nbegin\n  rw le_iff_lt_or_eq at h\u2082, cases h\u2082,\n  { rw le_iff_lt_or_eq at h\u2083, cases h\u2083,\n    { exact modp_add_lt h\u2081 h\u2082 h\u2083 },\n    { subst d\u2082, exact modp_add_le_aux h\u2082 }},\n  { subst d\u2081, rw add_comm k d\u2082, rw le_iff_lt_or_eq at h\u2083, cases h\u2083,\n    { exact modp_add_le_aux h\u2083 },\n    { subst d\u2082, rw [modp_add_self, modp_self, if_neg, nat.add_sub_cancel],\n      push_neg, rw or_self at h\u2081, exact lt_add_of_pos_left k h\u2081 }},\nend\n\nlemma modp_digit_add_digit {d\u2081 d\u2082 : \u2115} (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082)\n  (h\u2083 : 0 < d\u2081 \u2228 0 < d\u2082) :\n  modp (d\u2081 + d\u2082) 9 = if d\u2081 + d\u2082 \u2264 9 then d\u2081 + d\u2082 else d\u2081 + d\u2082 - 9 :=\nmodp_add_le h\u2083 h\u2081 h\u2082\n\nlemma modp_le {k d : \u2115} (h : 0 < k) : modp d k \u2264 k :=\nbegin\n  rw modp, split_ifs with h\u2081,\n  { refl },\n  { exact le_of_lt (nat.mod_lt _ h) },\nend\n\nlemma modp_self_mul {k n : \u2115} : modp (k * n) k = k :=\nby { rw modp, split_ifs; simp * at * }\n\nlemma zero_modp {k : \u2115} : modp 0 k = k :=\nby { rw modp, split_ifs; simp * at * }\n\nlemma modp_modp {k d : \u2115} : 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 : \u2115} : 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 : \u2115} (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 : \u2115} (h\u2081 : a < b) (h\u2082 : 0 < c) : a < b * c :=\nbegin\n  cases c,\n  { cases h\u2082 },\n  { rw nat.mul_succ, apply nat.lt_add_left, assumption },\nend\n\nlemma le_mul_of_le {a b c : \u2115} (h\u2081 : a \u2264 b) (h\u2082 : 0 < c) : a \u2264 b * c :=\nbegin\n  cases c,\n  { cases h\u2082 },\n  { rw nat.mul_succ, exact le_add_left h\u2081},\nend\n\nlemma lt_add_left_iff_lt {a b c : \u2115} : c + a < c + b \u2194 a < b :=\nby apply rel_iff_cov\n\nlemma le_add_left_iff_le {a b c : \u2115} : c + a \u2264 c + b \u2194 a \u2264 b :=\nby apply rel_iff_cov\n\nlemma sum_le_foldr {l : list \u2115} : l.sum \u2264 l.foldr (\u03bb (a b : \u2115), 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 : \u2115} : a + b \u2264 b \u2194 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 \u2115} : l.sum = 0 \u2194 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 \u2115} {n : \u2115}\n  (h\u2081 : is_digit_list l) (h\u2082 : 1 < n) :\n  l.sum = l.foldr (\u03bb (a b : \u2115), a + b * 10) 0 * n \u2194 all_zeros l :=\nbegin\n  split; intro h,\n  { have h\u2083 := @sum_le_foldr l, rw h at h\u2083,\n    obtain \u27e8n, rfl\u27e9 := nat.exists_eq_add_of_lt h\u2082, clear h\u2082,\n    have h\u2082 : 1 + n + 1 = n + 2 := by linarith, rw h\u2082 at *,\n    rw [mul_add, mul_two, \u2190add_assoc, add_left_le_self_iff, add_eq_zero_iff] at h\u2083,\n    rwa [h\u2083.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 \u2115} (h\u2081 : is_digit_list l)\n  (h\u2082 : l.sum = l.foldr (\u03bb (a b : \u2115), 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, \u2190is_digit_list] at h\u2081, cases h\u2081 with h\u2081 h\u2083,\n    rw [list.sum_cons, list.foldr_cons, add_right_inj,\n    sum_eq_foldr_mul_iff_of_gt_1 h\u2083 (dec_trivial : 1 < 10)] at h\u2082,\n    rwa [list.sum_cons, sum_eq_zero_iff.mpr h\u2082] },\nend\n\nlemma sum_digits_eq_self_iff_is_digit {n : \u2115} : sum_digits n = n \u2194 is_digit n :=\nbegin\n  split; intro h,\n  { by_cases h\u2081 : n = 0,\n    { subst n, dec_trivial },\n    { rw [sum_digits_eq_get_some, get_some] at h, split_ifs at h with h\u2081,\n      { obtain \u27e8h\u2082, h\u2083\u27e9 := h\u2081.some_spec, revert h h\u2082 h\u2083, generalize : h\u2081.some = l,\n        rintro h\u2081 h\u2082 h\u2083, subst n, exact is_digit_sum_of_sum_eq_foldr h\u2082 h\u2083.symm },\n      { subst n, dec_trivial }}},\n  { exact sum_digits_digit h },\nend\n\nlemma is_digit_digital_root {n : \u2115} : is_digit (digital_root n) :=\nbegin\n  rw [is_digit, digital_root, fixed, get_some], split_ifs,\n  { obtain \u27e8k, h\u2081, h\u2082\u27e9 := h.some_spec,\n    rwa [function.iterate_succ_apply', h\u2081, sum_digits_eq_self_iff_is_digit] at h\u2082 },\n  { dec_trivial },\nend\n\nlemma exi_sum_digits {n : \u2115} : \u2203 (l : list \u2115), is_digit_list l \u2227\n  l.foldr (\u03bb (a b : \u2115), 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 \u27e8l, h\u2081, h\u2082\u27e9, use d :: l, split,\n    { rw [is_digit_list, all_cons, \u2190is_digit_list], split; assumption },\n    { rw [list.foldr_cons, add_right_inj, h\u2082] }},\nend\n\nlemma sum_digits_digit_add_mul_10 {d n : \u2115} (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\u2081,\n  obtain \u27e8h\u2081, h\u2082\u27e9 := h\u2081.some_spec, revert h\u2081 h\u2082, generalize : exi_sum_digits.some = l\u2082,\n  clear h\u2081, rintro h\u2081 h\u2082, rw [sum_digits_eq_get_some, get_some_pos exi_sum_digits],\n  generalize_proofs h\u2081, obtain \u27e8h\u2081, h\u2082\u27e9 := h\u2081.some_spec, revert h\u2081 h\u2082,\n  generalize : exi_sum_digits.some = l\u2081, clear h\u2081, rintro h\u2083 h\u2084, cases l\u2082 with d\u2082 l\u2082,\n  { change 0 = _ at h\u2082, symmetry' at h\u2082, rw [add_eq_zero_iff, mul_eq_zero] at h\u2082,\n    rcases h\u2082 with \u27e8rfl, h\u2082\u27e9, clear h h\u2081, cases h\u2082,\n    { subst n, rw foldr_eq_zero_iff at h\u2082, rw sum_eq_zero_iff.mpr h\u2082, refl },\n    { cases h\u2082 }},\n  { rw list.foldr_cons at h\u2082, rw [is_digit_list, all_cons, \u2190is_digit_list] at h\u2081,\n    cases h\u2081 with h\u2081 h\u2085, rw digit_add_mul_10_eq_digit_add_mul_10_iff h\u2081 h at h\u2082,\n    rcases h\u2082 with \u27e8rfl, h\u2082\u27e9, rw [list.sum_cons, add_right_inj], rw \u2190h\u2084 at h\u2082,\n    exact sum_eq_sum_of_foldr_eq_foldr h\u2085 h\u2083 h\u2082 },\nend\n\nlemma sum_digits_le {n : \u2115} : sum_digits n \u2264 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 : \u2115}\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\u2081 := @sum_digits_le (sum_digits n), rwa h at h\u2081 },\nend\n\nlemma iter_le_of_le {f : \u2115 \u2192 \u2115} {z n : \u2115}\n  (h : \u2200 (z : \u2115), f z \u2264 z) : (f^[n] z) \u2264 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 : \u2115 \u2192 \u2115} {z m n : \u2115}\n  (h\u2081 : \u2200 (z : \u2115), f z \u2264 z) (h\u2082 : m \u2264 n) : (f^[n] z) \u2264 (f^[m] z) :=\nbegin\n  obtain \u27e8n, rfl\u27e9 := nat.exists_eq_add_of_le h\u2082,\n  rw [add_comm, function.iterate_add_apply], exact iter_le_of_le h\u2081,\nend\n\nlemma iter_sum_digits_le_iter_sum_digits_of_le {n k\u2081 k\u2082 : \u2115} (h : k\u2081 \u2264 k\u2082) :\n  (sum_digits^[k\u2082] n) \u2264 (sum_digits^[k\u2081] n) := iter_le_iter_of_le (\u03bb _, sum_digits_le) h\n\nlemma sum_digits_digital_root {n : \u2115} : 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 : \u2115} (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\u2081 d\u2082 : \u2115}\n  (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) : is_digit (sum_digits (d\u2081 + d\u2082)) :=\nbegin\n  rw sum_digits_digit_add_digit h\u2081 h\u2082, split_ifs,\n  { exact h },\n  { rw is_digit at *, exact nat.sub_le_sub_right (add_le_add h\u2081 h\u2082) 9 },\nend\n\nlemma iter_sum_digits_digit {d n : \u2115} (h : is_digit d) : (sum_digits^[n]) d = d :=\nfunction.iterate_fixed (sum_digits_digit h) _\n\nlemma digital_root_digit_add_digit {d\u2081 d\u2082 : \u2115} (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) :\n  digital_root (d\u2081 + d\u2082) = sum_digits (d\u2081 + d\u2082) :=\nbegin\n  rw [digital_root, fixed, get_some_pos], swap,\n  { use [sum_digits (d\u2081 + d\u2082), 1], split,\n    { refl },\n    { exact sum_digits_digit (is_digit_sum_digits_digit_add_digit h\u2081 h\u2082) }},\n  generalize_proofs h\u2083, obtain \u27e8n, -, h\u2084\u27e9 := h\u2083.some_spec,\n  symmetry, rwa [function.iterate_succ_apply,\n  iter_sum_digits_digit (is_digit_sum_digits_digit_add_digit h\u2081 h\u2082)] at h\u2084,\nend\n\nlemma sum_digits_def {n : \u2115} : sum_digits n = n % 10 + sum_digits (n / 10) :=\nbegin\n  obtain \u27e8a, b, ha, hb, h\u27e9 := nat_exi_mul n 10,\n  rw [\u2190ha, \u2190hb, h, add_comm, hb],\n  exact sum_digits_digit_add_mul_10 is_digit_mod_10,\nend\n\ndef converges_to {\u03b1 : Type} (f : \u03b1 \u2192 \u03b1) (z x : \u03b1) : Prop :=\n\u2203 (n : \u2115), (f^[n]) z = x \u2227 (f^[n + 1]) z = x\n\ndef converges {\u03b1 : Type} (f : \u03b1 \u2192 \u03b1) (z : \u03b1) : Prop :=\n\u2203 (x : \u03b1), converges_to f z x\n\nlemma iter_add {\u03b1 : Type} {f : \u03b1 \u2192 \u03b1} {z : \u03b1} {m n : \u2115} :\n  (f^[m + n]) z = (f^[n]) ((f^[m]) z) := by rw [add_comm, function.iterate_add_apply]\n\nlemma converges_to_congr_aux {\u03b1 : Type} {n\u2082 n\u2081 : \u2115} {f : \u03b1 \u2192 \u03b1} {z x y : \u03b1}\n  (h\u2081 : f^[n\u2081] z = x) (h\u2082 : f^[n\u2081 + 1] z = x) (h\u2083 : f^[n\u2082] z = y) (h\u2084 : f^[n\u2082 + 1] z = y)\n  (h\u2085 : n\u2081 \u2264 n\u2082) : x = y :=\nbegin\n  obtain \u27e8n\u2082, rfl\u27e9 := nat.exists_eq_add_of_le h\u2085, clear h\u2085, rw add_assoc at h\u2084,\n  simp_rw iter_add at h\u2082 h\u2083 h\u2084, change (f^[1]) with f at h\u2082 h\u2084, rw \u2190h\u2081 at h\u2082,\n  have h\u2085 := function.iterate_fixed h\u2082 n\u2082, rw [h\u2083, h\u2081] at h\u2085, exact h\u2085.symm,\nend\n\nlemma converges_to_congr {\u03b1 : Type} {f : \u03b1 \u2192 \u03b1} {z x y : \u03b1}\n  (h\u2081 : converges_to f z x) (h\u2082 : converges_to f z y) : x = y :=\nbegin\n  rcases h\u2082 with \u27e8n\u2082, h\u2083, h\u2084\u27e9, rcases h\u2081 with \u27e8n\u2081, h\u2081, h\u2082\u27e9, by_cases h\u2085 : n\u2081 \u2264 n\u2082,\n  { exact converges_to_congr_aux h\u2081 h\u2082 h\u2083 h\u2084 h\u2085 },\n  { push_neg at h\u2085, exact (converges_to_congr_aux h\u2083 h\u2084 h\u2081 h\u2082 (le_of_lt h\u2085)).symm },\nend\n\nlemma fixed_eq_of_converges_to {\u03b1 : Type} [inhabited \u03b1] {f : \u03b1 \u2192 \u03b1} {z x : \u03b1}\n  (h : converges_to f z x) : fixed f z = x :=\nbegin\n  rw [fixed, get_some_pos], swap, { exact \u27e8x, h\u27e9 },\n  generalize_proofs h\u2083, exact converges_to_congr h\u2083.some_spec h,\nend\n\nlemma apply_eq_of_converges_to {\u03b1 : Type} {f : \u03b1 \u2192 \u03b1} {z x : \u03b1}\n  (h : converges_to f z x) : f x = x :=\nby { rcases h with \u27e8n, h\u2081, h\u2082\u27e9, rwa [function.iterate_succ_apply', h\u2081] at h\u2082 }\n\nlemma apply_fixed_of_converges {\u03b1 : Type} [inhabited \u03b1] {f : \u03b1 \u2192 \u03b1} {z : \u03b1}\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 {\u03b1 : Type} {f : \u03b1 \u2192 \u03b1} {x : \u03b1} {n : \u2115} :\n  (f^[n]) (f x) = f ((f^[n]) x) :=\nby rw [\u2190function.iterate_succ_apply, function.iterate_succ_apply']\n\nlemma converges_of_le {f : \u2115 \u2192 \u2115} {n : \u2115} (h : \u2200 (n : \u2115), f n \u2264 n) : converges f n :=\nbegin\n  change \u2203 (_ _ : \u2115), _, induction n using nat.strong_induction_on with n ih, dsimp at ih,\n  simp_rw function.iterate_succ_apply', have h\u2081 := h ((f^[n]) n),\n  rw le_iff_lt_or_eq at h\u2081, cases h\u2081,\n  { replace h\u2081 : _ < n := gt_of_ge_of_gt (iter_le_of_le h) h\u2081,\n    specialize ih _ h\u2081, rcases ih with \u27e8y, k, h\u2082, h\u2083\u27e9,\n    use [y, n + 1 + k], split; simp_rw iter_add,\n    { exact h\u2082 },\n    { rwa \u2190@iter_apply_comm _ f }},\n  { exact \u27e8_, _, rfl, h\u2081\u27e9 },\nend\n\nlemma converges_sum_digits {n : \u2115} : converges sum_digits n :=\nconverges_of_le (\u03bb _, sum_digits_le)\n\nlemma converges_to_fixed {\u03b1 : Type} [inhabited \u03b1] {f : \u03b1 \u2192 \u03b1} {z : \u03b1}\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 {\u03b1 : Type} {f : \u03b1 \u2192 \u03b1} {z x : \u03b1}\n  (h : converges_to f z x) : converges_to f z (f x) :=\nbegin\n  rcases h with \u27e8n, h\u2081, h\u2082\u27e9, use n + 1, split; rw iter_add,\n  { rw h\u2081, refl },\n  { rw h\u2082, refl },\nend\n\nlemma apply_converges_to {\u03b1 : Type} {f : \u03b1 \u2192 \u03b1} {z x : \u03b1}\n  (h : converges_to f z x) : converges_to f (f z) x :=\nbegin\n  rcases h with \u27e8k, h\u2081, h\u2082\u27e9, cases k,\n  { use 0, split,\n    { exact h\u2082 },\n    { cases h\u2081, rwa [iter_apply_comm, h\u2082] }},\n  { exact \u27e8k, h\u2081, h\u2082\u27e9 },\nend\n\nlemma apply_converges {\u03b1 : Type} {f : \u03b1 \u2192 \u03b1} {z : \u03b1}\n  (h : converges f z) : converges f (f z) := \u27e8_, apply_converges_to h.some_spec\u27e9\n\nlemma fixed_eq_fixed_of {\u03b1 : Type} [inhabited \u03b1] {f : \u03b1 \u2192 \u03b1} {z\u2081 z\u2082 x : \u03b1}\n  (h\u2081 : converges_to f z\u2081 x) (h\u2082 : converges_to f z\u2082 x) : fixed f z\u2081 = fixed f z\u2082 :=\nby rw [fixed_eq_of_converges_to h\u2081, fixed_eq_of_converges_to h\u2082]\n\nlemma fixed_apply_eq_of_converges {\u03b1 : Type} [inhabited \u03b1] {f : \u03b1 \u2192 \u03b1} {z : \u03b1}\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 : \u2115} : digital_root (sum_digits n) = digital_root n :=\nfixed_apply_eq_of_converges converges_sum_digits\n\nlemma fixed_ind {\u03b1 : Type} [inhabited \u03b1] {P : \u03b1 \u2192 Prop} {f : \u03b1 \u2192 \u03b1} {z : \u03b1}\n  (h\u2081 : converges f z) (h\u2082 : P z) (h\u2083 : \u2200 (x : \u03b1), P x \u2192 P (f x)) : P (fixed f z) :=\nbegin\n  cases h\u2081 with x h\u2081, rw fixed_eq_of_converges_to h\u2081,\n  rcases h\u2081 with \u27e8n, h\u2081, -\u27e9, rw \u2190h\u2081, exact function.iterate.rec _ h\u2083 h\u2082 _,\nend\n\nlemma sum_digits_mod_9 {n : \u2115} : 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 : \u2115} : digital_root n % 9 = n % 9 :=\nbegin\n  apply @fixed_ind _ _ (\u03bb (k : \u2115), k % 9 = n % 9) _ _ converges_sum_digits rfl,\n  rintro x h, rw [\u2190h, sum_digits_mod_9],\nend\n\nlemma digit_mod_10 {d : \u2115} (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 : \u2115} : 0 < a + b \u2194 0 < a \u2228 0 < b :=\nby { rw \u2190not_iff_not, push_neg, simp_rw [le_zero_iff, add_eq_zero_iff] }\n\nlemma sum_digits_pos_succ {n : \u2115} : 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 \u2264 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 \u27e8n, rfl\u27e9 := nat.exists_eq_add_of_le h, clear h,\n    rw [add_comm, \u2190nat.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 : \u2115} : sum_digits n = 0 \u2194 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 : \u2115} : digital_root n = 0 \u2194 n = 0 :=\nbegin\n  apply @fixed_ind _ _ (\u03bb (k : \u2115), k = 0 \u2194 n = 0) _ _ converges_sum_digits (iff.refl _),\n  rintro x h, rw [\u2190h, sum_digits_eq_zero_iff],\nend\n\nlemma digit_mod_9_eq_zero_iff {d : \u2115} (h : is_digit d) : d % 9 = 0 \u2194 d = 0 \u2228 d = 9 :=\nbegin\n  rw is_digit at h, split; intro h\u2081,\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\u2081, cases h\u2081 }}},\n  { cases h\u2081; subst d; refl },\nend\n\nlemma digital_root_eq_of_pos {n : \u2115} (h : 0 < n) : digital_root n = modp n 9 :=\nbegin\n  cases n,\n  { cases h },\n  { rw modp, split_ifs with h\u2081;\n    rw [\u2190digital_root_mod_9, digit_mod_9_eq_zero_iff is_digit_digital_root] at h\u2081,\n    { cases h\u2081,\n      { rw digital_root_eq_zero_iff at h\u2081, cases h\u2081 },\n      { exact h\u2081 }},\n    { rw not_or_distrib at h\u2081, cases h\u2081 with h\u2081 h\u2082,\n      rw [\u2190digital_root_mod_9, nat.mod_eq_of_lt],\n      exact lt_of_le_of_ne is_digit_digital_root h\u2082 }},\nend\n\nlemma digital_root_succ {n : \u2115} : 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 : \u2115} (h : modp n k = 0) : n = 0 :=\nbegin\n  rw modp at h, split_ifs at h with h\u2081,\n  { subst k, rwa nat.mod_zero at h\u2081 },\n  { contradiction },\nend\n\nlemma succ_mod_eq_zero_iff_aux {k n : \u2115} : n.succ % k.succ = 0 \u2194 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 [\u2190ne, \u2190pos_iff_ne_zero, \u2190nat.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 [\u2190nat.add_one, nat.add_mod, h, nat.one_mod, nat.mod_self] }},\nend\n\nlemma succ_mod_eq_zero_iff {k n : \u2115} (h : 0 < k) : n.succ % k = 0 \u2194 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 : \u2115} (h : digital_root n \u2260 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 : \u2115} (h : digital_root n \u2260 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\u2081,\n  { rw [succ_mod_eq_zero_iff (nat.succ_pos _), \u2190digital_root_mod_9,\n    digital_root_mod_9_eq_of_ne_9 h] at h\u2081, rw h\u2081 },\n  { cases n,\n    { rw digital_root_zero, refl },\n    { rw [digital_root_eq_of_pos (nat.succ_pos _), modp], split_ifs with h\u2082,\n      { rw [\u2190digital_root_mod_9, digital_root_mod_9_eq_of_ne_9 h,\n        digital_root_eq_zero_iff] at h\u2082, cases h\u2082 },\n      { clear h, rw succ_mod_eq_zero_iff (nat.succ_pos _) at h\u2081 h\u2082,\n        rw [\u2190nat.add_one, nat.add_mod, nat.one_mod],\n        have h\u2083 : n.succ % 9 = (n % 9 + 1) % 9,\n        { rw [\u2190nat.add_one, nat.add_mod, nat.one_mod] },\n        rw h\u2083 at *, clear h\u2083, have h\u2083 : n % 9 < 9 := nat.mod_lt _ (nat.succ_pos _),\n        revert h\u2083 h\u2081 h\u2082, generalize : n % 9 = d, rintro h\u2081 h\u2082 h\u2083,\n        clear n, replace h\u2081 : d \u2264 7,\n        { cases d,\n          { apply zero_le },\n          { rw nat.lt_succ_iff at h\u2081, rw \u2190nat.lt_succ_iff, exact lt_of_le_of_ne h\u2081 h\u2083 }},\n        rw \u2190not_lt at h\u2081, iterate 7 { cases d, refl }, cases d, cases h\u2082 rfl,\n        contrapose! h\u2081, change 7 < d + 8, linarith }}},\nend\n\nlemma not_digit_succ_le_9_iff {d : \u2115} (h : is_digit d) : \u00acd.succ \u2264 9 \u2194 d = 9 :=\nbegin\n  split; intro h\u2081,\n  { contrapose! h\u2081, exact nat.succ_le_of_lt (lt_of_le_of_ne h h\u2081) },\n  { subst d, dec_trivial }\nend\n\nlemma digital_root_succ_eq_sum_digits {n : \u2115} :\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 \u2190nat.add_one, split_ifs with h\u2081 h\u2082 h\u2082,\n  { rw [\u2190digital_root_mod_9, digit_mod_9_eq_zero_iff is_digit_digital_root] at h\u2082,\n    cases h\u2082,\n    { rw digital_root_eq_of_pos (nat.succ_pos _) at h\u2082, cases eq_zero_of_modp_eq_zero h\u2082 },\n    { rw nat.succ_le_iff at h\u2081, rw [nat.succ_inj', \u2190nat.mod_eq_of_lt h\u2081, digital_root_mod_9],\n      apply_fun (\u03bb n, n % 9) at h\u2082, rwa [nat.mod_self, digital_root_mod_9,\n      succ_mod_eq_zero_iff (nat.succ_pos _)] at h\u2082 }},\n  { rw [\u2190digital_root_mod_9, digit_mod_9_eq_zero_iff is_digit_digital_root,\n    not_or_distrib] at h\u2082, cases h\u2082 with h\u2082 h\u2083,\n    have h\u2084 := lt_of_le_of_ne is_digit_digital_root h\u2083,\n    rw [\u2190digital_root_mod_9, nat.mod_eq_of_lt h\u2084, digital_root_succ_eq_of_ne_9],\n    exact ne_of_lt (nat.lt_of_succ_le h\u2081) },\n  { rw not_digit_succ_le_9_iff is_digit_digital_root at h\u2081,\n    rw [succ_mod_eq_zero_iff (nat.succ_pos _), \u2190digital_root_mod_9, h\u2081] at h\u2082, cases h\u2082 },\n  { rw not_digit_succ_le_9_iff is_digit_digital_root at h\u2081,\n    rw [nat.add_mod, \u2190@digital_root_mod_9 n, h\u2081], refl },\nend\n\nlemma sum_digits_digit_succ {d : \u2115} (h : is_digit d) : sum_digits d.succ = modp d.succ 9 :=\nbegin\n  rw [\u2190nat.add_one, sum_digits_digit_add_digit h (dec_trivial : is_digit 1), modp],\n  split_ifs with h\u2081 h\u2082 h\u2082; try { rw not_digit_succ_le_9_iff h at h\u2081 },\n  { rw [succ_mod_eq_zero_iff (nat.succ_pos _),\n    nat.mod_eq_of_lt (nat.lt_of_succ_le h\u2081)] at h\u2082, rwa h\u2082 },\n  { rw nat.mod_eq_of_lt, rw succ_mod_eq_zero_iff (nat.succ_pos _) at h\u2082,\n    rw le_iff_lt_or_eq at h\u2081, cases h\u2081,\n    { exact h\u2081 },\n    { rw nat.succ_inj' at h\u2081, subst d, cases h\u2082 rfl }},\n  { subst h\u2081, cases h\u2082 },\n  { subst h\u2081, refl },\nend\n\nlemma not_pos_iff {n : \u2115} : \u00ac0 < n \u2194 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 : \u2115} : m \u2264 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\u2081 d\u2082 : \u2115} (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) :\n  is_digit (d\u2081 + d\u2082 - 9) := nat.sub_le_sub_right (add_le_add h\u2081 h\u2082) _\n\nlemma digital_root_add_aux\u2081 {d\u2081 d\u2082 : \u2115} (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082)\n  (h\u2083 : 0 < d\u2081) (h\u2084 : 0 < d\u2082) :\n  sum_digits (d\u2081 + sum_digits d\u2082.succ) = modp (sum_digits (d\u2081 + d\u2082)).succ 9 :=\nbegin\n  simp_rw [sum_digits_digit_succ h\u2082, sum_digits_digit_add_digit h\u2081 h\u2082,\n  sum_digits_digit_add_digit h\u2081 is_digit_modp_9, \u2190nat.add_one],\n  split_ifs with h\u2085 h\u2086 h\u2086,\n  { rw [ modp_digit_add_digit h\u2082 is_digit_one (or.inr nat.zero_lt_one),\n    modp_digit_add_digit h\u2086 is_digit_one (or.inr nat.zero_lt_one)] at *,\n    split_ifs at *; linarith },\n  { rw [ modp_digit_add_digit h\u2082 is_digit_one (or.inr nat.zero_lt_one),\n    modp_digit_add_digit (is_digit_digit_add_digit_sub_9 h\u2081 h\u2082)\n    is_digit_one (or.inr nat.zero_lt_one)] at *, split_ifs at * with h\u2087 h\u2088 h\u2088,\n    { linarith },\n    { linarith },\n    { rw not_digit_succ_le_9_iff h\u2082 at h\u2087, subst h\u2087, refl },\n    { rw not_digit_succ_le_9_iff h\u2082 at h\u2087, subst h\u2087,\n      rw [nat.add_sub_cancel, not_digit_succ_le_9_iff h\u2081] at h\u2088, subst h\u2088,\n      contrapose! h\u2085, dec_trivial }},\n  { rw [ modp_digit_add_digit h\u2082 is_digit_one (or.inr nat.zero_lt_one),\n    modp_digit_add_digit h\u2086 is_digit_one (or.inr nat.zero_lt_one)] at *,\n    split_ifs at * with h\u2087 h\u2088 h\u2088,\n    { rw [\u2190nat.add_assoc, not_digit_succ_le_9_iff h\u2086] at h\u2085, rw [\u2190nat.add_assoc, h\u2085] },\n    { linarith },\n    { linarith }},\n  { rw [ modp_digit_add_digit h\u2082 is_digit_one (or.inr nat.zero_lt_one),\n    modp_digit_add_digit (is_digit_digit_add_digit_sub_9 h\u2081 h\u2082)\n    is_digit_one (or.inr nat.zero_lt_one) ] at *, split_ifs at * with h\u2087 h\u2088 h\u2088,\n    { push_neg at h\u2086, rw \u2190nat.add_assoc, exact nat.succ_sub (le_of_lt h\u2086) },\n    { push_neg at h\u2085 h\u2086 h\u2088, rw \u2190nat.add_assoc at h\u2085 \u22a2, contrapose! h\u2088,\n      rw nat.succ_le_succ_iff at h\u2087 \u22a2, exact tsub_le_iff_left.mpr (nat.add_le_add h\u2081 h\u2087) },\n    { push_neg at h\u2085 h\u2086 h\u2087, contrapose! h\u2085,\n      rwa [\u2190nat.add_sub_assoc (le_of_lt h\u2087), \u2190nat.add_assoc, nat.succ_sub (le_of_lt h\u2086)] },\n    { push_neg at h\u2085 h\u2086 h\u2087 h\u2088,\n      rwa [\u2190nat.add_sub_assoc (le_of_lt h\u2087), \u2190nat.add_assoc, nat.succ_sub (le_of_lt h\u2086)] }},\nend\n\nlemma digital_root_add_aux {d\u2081 d\u2082 : \u2115} (h\u2081 : is_digit d\u2081) (h\u2082 : is_digit d\u2082) :\n  sum_digits (d\u2081 + sum_digits d\u2082.succ) = modp (sum_digits (d\u2081 + d\u2082)).succ 9 :=\nbegin\n  by_cases h\u2083 : 0 < d\u2081,\n  { by_cases h\u2084 : 0 < d\u2082,\n    { exact digital_root_add_aux\u2081 h\u2081 h\u2082 h\u2083 h\u2084 },\n    { rw not_pos_iff at h\u2084, subst d\u2082, rw [add_zero, sum_digits_digit is_digit_one,\n      sum_digits_digit h\u2081, \u2190nat.add_one, sum_digits_digit_add_digit h\u2081 is_digit_one,\n      modp_digit_add_digit h\u2081 is_digit_one], exact or.inl h\u2083 }},\n  { rw not_pos_iff at h\u2083, subst d\u2081, simp_rw [zero_add, \u2190nat.add_one],\n    rw [sum_digits_digit (is_digit_sum_digits_digit_add_digit h\u2082 is_digit_one),\n    sum_digits_digit_add_digit h\u2082 is_digit_one, sum_digits_digit h\u2082,\n    modp_digit_add_digit h\u2082 is_digit_one(or.inr one_pos)] },\nend\n\nlemma digital_root_add {m n : \u2115} :\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\u2081, generalize hn : digital_root n = d\u2082,\n    have h\u2081 : is_digit d\u2081, { rw \u2190hm, exact is_digit_digital_root },\n    have h\u2082 : is_digit d\u2082, { rw \u2190hn, exact is_digit_digital_root },\n    exact (digital_root_add_aux h\u2081 h\u2082).symm },\nend\n\nlemma sum_digits_mul_10 {n : \u2115} : sum_digits (n * 10) = sum_digits n :=\nby rw [\u2190nat.zero_add (n * 10), sum_digits_digit_add_mul_10 is_digit_zero, nat.zero_add]\n\nlemma digital_root_mul_10 {n : \u2115} : digital_root (n * 10) = digital_root n :=\nby rw [\u2190digital_root_sum_digits, sum_digits_mul_10, digital_root_sum_digits]\n\nlemma digital_root_digit_add_mul_10 {d n : \u2115} (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 : \u2115} (h : 0 < n) : digital_root n = modp n 9 :=\nbegin\n  induction n using digit_ind with d n h\u2081 ih,\n  { cases h },\n  { cases n,\n    { simp_rw [zero_mul, add_zero] at h \u22a2,\n      rw [modp_digit_of_pos h\u2081 h, digital_root_digit_eq_self h\u2081] },\n    { specialize ih (nat.succ_pos _),\n      rw [digital_root_digit_add_mul_10 h\u2081, modp_digit_add_mul_10 h\u2081, ih,\n      sum_digits_digit_add_digit h\u2081 is_digit_modp_9],\n      split_ifs with h,\n      { cases d,\n        { simp },\n        { rw [modp_add, modp_digit_of_pos h\u2081 (nat.succ_pos _),\n          modp_digit_add_digit h\u2081 is_digit_modp_9 (or.inl (nat.succ_pos _)), if_pos h] }},\n      { have h\u2082 : 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\u2081 h\u2082], revert h,\n        generalize h\u2083 : modp n.succ 9 = d\u2082, intro h, have h\u2084 : 0 < d\u2082,\n        { subst d\u2082, exact modp_pos_of_pos (nat.succ_pos _) },\n        have h\u2085 : is_digit d\u2082,\n        { subst d\u2082, exact is_digit_modp_9 },\n        rw [modp_digit_add_digit h\u2081 h\u2085 (or.inl h\u2082), if_neg h] }}},\nend\n\nlemma digital_root_def {n : \u2115} :\n  digital_root n = if n = 0 then 0 else if n % 9 = 0 then 9 else n % 9 :=\nbegin\n  rw \u2190modp, split_ifs with h h\u2081,\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 \u03b1`,\nmodelled as a `multiset \u03b1` 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 \u03b1`\n(which asserts that there is some `finset \u03b1` containing every term of type `\u03b1`)\nas well as the predicate `finite` on `s : set \u03b1` (which asserts `nonempty (fintype s)`).\n-/\n\n/-- `finset \u03b1` is the type of finite sets of elements of `\u03b1`. It is implemented\n  as a multiset (a list up to permutation) which has no duplicate elements. -/\nstructure finset (\u03b1 : Type u_4) \nwhere\n  val : multiset \u03b1\n  nodup : multiset.nodup val\n\nnamespace finset\n\n\ntheorem eq_of_veq {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} : val s = val t \u2192 s = t := sorry\n\n@[simp] theorem val_inj {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} : val s = val t \u2194 s = t :=\n  { mp := eq_of_veq, mpr := congr_arg fun {s : finset \u03b1} => val s }\n\n@[simp] theorem erase_dup_eq_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : multiset.erase_dup (val s) = val s :=\n  iff.mpr multiset.erase_dup_eq_self (nodup s)\n\nprotected instance has_decidable_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] : DecidableEq (finset \u03b1) :=\n  sorry\n\n/-! ### membership -/\n\nprotected instance has_mem {\u03b1 : Type u_1} : has_mem \u03b1 (finset \u03b1) :=\n  has_mem.mk fun (a : \u03b1) (s : finset \u03b1) => a \u2208 val s\n\ntheorem mem_def {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} : a \u2208 s \u2194 a \u2208 val s :=\n  iff.rfl\n\n@[simp] theorem mem_mk {\u03b1 : Type u_1} {a : \u03b1} {s : multiset \u03b1} {nd : multiset.nodup s} : a \u2208 mk s nd \u2194 a \u2208 s :=\n  iff.rfl\n\nprotected instance decidable_mem {\u03b1 : Type u_1} [h : DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : Decidable (a \u2208 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 {\u03b1 : Type u_1} : has_coe_t (finset \u03b1) (set \u03b1) :=\n  has_coe_t.mk fun (s : finset \u03b1) => set_of fun (x : \u03b1) => x \u2208 s\n\n@[simp] theorem mem_coe {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} : a \u2208 \u2191s \u2194 a \u2208 s :=\n  iff.rfl\n\n@[simp] theorem set_of_mem {\u03b1 : Type u_1} {s : finset \u03b1} : (set_of fun (a : \u03b1) => a \u2208 s) = \u2191s :=\n  rfl\n\n@[simp] theorem coe_mem {\u03b1 : Type u_1} {s : finset \u03b1} (x : \u21a5\u2191s) : \u2191x \u2208 s :=\n  subtype.property x\n\n@[simp] theorem mk_coe {\u03b1 : Type u_1} {s : finset \u03b1} (x : \u21a5\u2191s) {h : \u2191x \u2208 \u2191s} : { val := \u2191x, property := h } = x :=\n  subtype.coe_eta x h\n\nprotected instance decidable_mem' {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : Decidable (a \u2208 \u2191s) :=\n  finset.decidable_mem a s\n\n/-! ### extensionality -/\n\ntheorem ext_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 = s\u2082 \u2194 \u2200 (a : \u03b1), a \u2208 s\u2081 \u2194 a \u2208 s\u2082 :=\n  iff.trans (iff.symm val_inj) (multiset.nodup_ext (nodup s\u2081) (nodup s\u2082))\n\ntheorem ext {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : (\u2200 (a : \u03b1), a \u2208 s\u2081 \u2194 a \u2208 s\u2082) \u2192 s\u2081 = s\u2082 :=\n  iff.mpr ext_iff\n\n@[simp] theorem coe_inj {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : \u2191s\u2081 = \u2191s\u2082 \u2194 s\u2081 = s\u2082 :=\n  iff.trans set.ext_iff (iff.symm ext_iff)\n\ntheorem coe_injective {\u03b1 : Type u_1} : function.injective coe :=\n  fun (s t : finset \u03b1) => iff.mp coe_inj\n\n/-! ### subset -/\n\nprotected instance has_subset {\u03b1 : Type u_1} : has_subset (finset \u03b1) :=\n  has_subset.mk fun (s\u2081 s\u2082 : finset \u03b1) => \u2200 {a : \u03b1}, a \u2208 s\u2081 \u2192 a \u2208 s\u2082\n\ntheorem subset_def {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 \u2286 s\u2082 \u2194 val s\u2081 \u2286 val s\u2082 :=\n  iff.rfl\n\n@[simp] theorem subset.refl {\u03b1 : Type u_1} (s : finset \u03b1) : s \u2286 s :=\n  multiset.subset.refl (val s)\n\ntheorem subset_of_eq {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} (h : s = t) : s \u2286 t :=\n  h \u25b8 subset.refl s\n\ntheorem subset.trans {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {s\u2083 : finset \u03b1} : s\u2081 \u2286 s\u2082 \u2192 s\u2082 \u2286 s\u2083 \u2192 s\u2081 \u2286 s\u2083 :=\n  multiset.subset.trans\n\ntheorem superset.trans {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {s\u2083 : finset \u03b1} : s\u2081 \u2287 s\u2082 \u2192 s\u2082 \u2287 s\u2083 \u2192 s\u2081 \u2287 s\u2083 :=\n  fun (h' : s\u2081 \u2287 s\u2082) (h : s\u2082 \u2287 s\u2083) => subset.trans h h'\n\n-- TODO: these should be global attributes, but this will require fixing other files\n\ntheorem mem_of_subset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {a : \u03b1} : s\u2081 \u2286 s\u2082 \u2192 a \u2208 s\u2081 \u2192 a \u2208 s\u2082 :=\n  multiset.mem_of_subset\n\ntheorem subset.antisymm {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (H\u2081 : s\u2081 \u2286 s\u2082) (H\u2082 : s\u2082 \u2286 s\u2081) : s\u2081 = s\u2082 :=\n  ext fun (a : \u03b1) => { mp := H\u2081, mpr := H\u2082 }\n\ntheorem subset_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 \u2286 s\u2082 \u2194 \u2200 {x : \u03b1}, x \u2208 s\u2081 \u2192 x \u2208 s\u2082 :=\n  iff.rfl\n\n@[simp] theorem coe_subset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : \u2191s\u2081 \u2286 \u2191s\u2082 \u2194 s\u2081 \u2286 s\u2082 :=\n  iff.rfl\n\n@[simp] theorem val_le_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : val s\u2081 \u2264 val s\u2082 \u2194 s\u2081 \u2286 s\u2082 :=\n  multiset.le_iff_subset (nodup s\u2081)\n\nprotected instance has_ssubset {\u03b1 : Type u_1} : has_ssubset (finset \u03b1) :=\n  has_ssubset.mk fun (a b : finset \u03b1) => a \u2286 b \u2227 \u00acb \u2286 a\n\nprotected instance partial_order {\u03b1 : Type u_1} : partial_order (finset \u03b1) :=\n  partial_order.mk has_subset.subset has_ssubset.ssubset subset.refl subset.trans subset.antisymm\n\ntheorem subset.antisymm_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 = s\u2082 \u2194 s\u2081 \u2286 s\u2082 \u2227 s\u2082 \u2286 s\u2081 :=\n  le_antisymm_iff\n\n@[simp] theorem le_iff_subset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 \u2264 s\u2082 \u2194 s\u2081 \u2286 s\u2082 :=\n  iff.rfl\n\n@[simp] theorem lt_iff_ssubset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 < s\u2082 \u2194 s\u2081 \u2282 s\u2082 :=\n  iff.rfl\n\n@[simp] theorem coe_ssubset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : \u2191s\u2081 \u2282 \u2191s\u2082 \u2194 s\u2081 \u2282 s\u2082 := sorry\n\n@[simp] theorem val_lt_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : val s\u2081 < val s\u2082 \u2194 s\u2081 \u2282 s\u2082 :=\n  and_congr val_le_iff (not_congr val_le_iff)\n\ntheorem ssubset_iff_of_subset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : s\u2081 \u2286 s\u2082) : s\u2081 \u2282 s\u2082 \u2194 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s\u2082), \u00acx \u2208 s\u2081 :=\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 `\u2203 x, x \u2208 s` or `s \u2260 \u2205` as it gives access to a nice API thanks\nto the dot notation. -/\nprotected def nonempty {\u03b1 : Type u_1} (s : finset \u03b1) :=\n  \u2203 (x : \u03b1), x \u2208 s\n\n@[simp] theorem coe_nonempty {\u03b1 : Type u_1} {s : finset \u03b1} : set.nonempty \u2191s \u2194 finset.nonempty s :=\n  iff.rfl\n\ntheorem nonempty.bex {\u03b1 : Type u_1} {s : finset \u03b1} (h : finset.nonempty s) : \u2203 (x : \u03b1), x \u2208 s :=\n  h\n\ntheorem nonempty.mono {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} (hst : s \u2286 t) (hs : finset.nonempty s) : finset.nonempty t :=\n  set.nonempty.mono hst hs\n\ntheorem nonempty.forall_const {\u03b1 : Type u_1} {s : finset \u03b1} (h : finset.nonempty s) {p : Prop} : (\u2200 (x : \u03b1), x \u2208 s \u2192 p) \u2194 p := sorry\n\n/-! ### empty -/\n\n/-- The empty finset -/\nprotected def empty {\u03b1 : Type u_1} : finset \u03b1 :=\n  mk 0 multiset.nodup_zero\n\nprotected instance has_emptyc {\u03b1 : Type u_1} : has_emptyc (finset \u03b1) :=\n  has_emptyc.mk finset.empty\n\nprotected instance inhabited {\u03b1 : Type u_1} : Inhabited (finset \u03b1) :=\n  { default := \u2205 }\n\n@[simp] theorem empty_val {\u03b1 : Type u_1} : val \u2205 = 0 :=\n  rfl\n\n@[simp] theorem not_mem_empty {\u03b1 : Type u_1} (a : \u03b1) : \u00aca \u2208 \u2205 :=\n  id\n\n@[simp] theorem not_nonempty_empty {\u03b1 : Type u_1} : \u00acfinset.nonempty \u2205 :=\n  fun (_x : finset.nonempty \u2205) =>\n    (fun (_a : finset.nonempty \u2205) => Exists.dcases_on _a fun (w : \u03b1) (h : w \u2208 \u2205) => idRhs False (not_mem_empty w h)) _x\n\n@[simp] theorem mk_zero {\u03b1 : Type u_1} : mk 0 multiset.nodup_zero = \u2205 :=\n  rfl\n\ntheorem ne_empty_of_mem {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) : s \u2260 \u2205 :=\n  fun (e : s = \u2205) => not_mem_empty a (e \u25b8 h)\n\ntheorem nonempty.ne_empty {\u03b1 : Type u_1} {s : finset \u03b1} (h : finset.nonempty s) : s \u2260 \u2205 :=\n  exists.elim h fun (a : \u03b1) => ne_empty_of_mem\n\n@[simp] theorem empty_subset {\u03b1 : Type u_1} (s : finset \u03b1) : \u2205 \u2286 s :=\n  multiset.zero_subset (val s)\n\ntheorem eq_empty_of_forall_not_mem {\u03b1 : Type u_1} {s : finset \u03b1} (H : \u2200 (x : \u03b1), \u00acx \u2208 s) : s = \u2205 :=\n  eq_of_veq (multiset.eq_zero_of_forall_not_mem H)\n\ntheorem eq_empty_iff_forall_not_mem {\u03b1 : Type u_1} {s : finset \u03b1} : s = \u2205 \u2194 \u2200 (x : \u03b1), \u00acx \u2208 s :=\n  { mp := fun (\u1fb0 : s = \u2205) (x : \u03b1) => Eq._oldrec id (Eq.symm \u1fb0),\n    mpr := fun (h : \u2200 (x : \u03b1), \u00acx \u2208 s) => eq_empty_of_forall_not_mem h }\n\n@[simp] theorem val_eq_zero {\u03b1 : Type u_1} {s : finset \u03b1} : val s = 0 \u2194 s = \u2205 :=\n  val_inj\n\ntheorem subset_empty {\u03b1 : Type u_1} {s : finset \u03b1} : s \u2286 \u2205 \u2194 s = \u2205 :=\n  iff.trans multiset.subset_zero val_eq_zero\n\ntheorem nonempty_of_ne_empty {\u03b1 : Type u_1} {s : finset \u03b1} (h : s \u2260 \u2205) : finset.nonempty s :=\n  multiset.exists_mem_of_ne_zero (mt (iff.mp val_eq_zero) h)\n\ntheorem nonempty_iff_ne_empty {\u03b1 : Type u_1} {s : finset \u03b1} : finset.nonempty s \u2194 s \u2260 \u2205 :=\n  { mp := nonempty.ne_empty, mpr := nonempty_of_ne_empty }\n\n@[simp] theorem not_nonempty_iff_eq_empty {\u03b1 : Type u_1} {s : finset \u03b1} : \u00acfinset.nonempty s \u2194 s = \u2205 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u00acfinset.nonempty s \u2194 s = \u2205)) (propext nonempty_iff_ne_empty))) not_not\n\ntheorem eq_empty_or_nonempty {\u03b1 : Type u_1} (s : finset \u03b1) : s = \u2205 \u2228 finset.nonempty s :=\n  classical.by_cases Or.inl fun (h : \u00acs = \u2205) => Or.inr (nonempty_of_ne_empty h)\n\n@[simp] theorem coe_empty {\u03b1 : Type u_1} : \u2191\u2205 = \u2205 :=\n  rfl\n\n/-- A `finset` for an empty type is empty. -/\ntheorem eq_empty_of_not_nonempty {\u03b1 : Type u_1} (h : \u00acNonempty \u03b1) (s : finset \u03b1) : s = \u2205 :=\n  eq_empty_of_forall_not_mem fun (x : \u03b1) => 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 \u2205` in that it does not require a `decidable_eq` instance for `\u03b1`.\n-/\nprotected instance has_singleton {\u03b1 : Type u_1} : has_singleton \u03b1 (finset \u03b1) :=\n  has_singleton.mk fun (a : \u03b1) => mk (singleton a) (multiset.nodup_singleton a)\n\n@[simp] theorem singleton_val {\u03b1 : Type u_1} (a : \u03b1) : val (singleton a) = a ::\u2098 0 :=\n  rfl\n\n@[simp] theorem mem_singleton {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : b \u2208 singleton a \u2194 b = a :=\n  multiset.mem_singleton\n\ntheorem not_mem_singleton {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : \u00aca \u2208 singleton b \u2194 a \u2260 b :=\n  not_congr mem_singleton\n\ntheorem mem_singleton_self {\u03b1 : Type u_1} (a : \u03b1) : a \u2208 singleton a :=\n  Or.inl rfl\n\ntheorem singleton_inj {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : singleton a = singleton b \u2194 a = b :=\n  { mp := fun (h : singleton a = singleton b) => iff.mp mem_singleton (h \u25b8 mem_singleton_self a),\n    mpr := congr_arg fun {a : \u03b1} => singleton a }\n\n@[simp] theorem singleton_nonempty {\u03b1 : Type u_1} (a : \u03b1) : finset.nonempty (singleton a) :=\n  Exists.intro a (mem_singleton_self a)\n\n@[simp] theorem singleton_ne_empty {\u03b1 : Type u_1} (a : \u03b1) : singleton a \u2260 \u2205 :=\n  nonempty.ne_empty (singleton_nonempty a)\n\n@[simp] theorem coe_singleton {\u03b1 : Type u_1} (a : \u03b1) : \u2191(singleton a) = singleton a := sorry\n\ntheorem eq_singleton_iff_unique_mem {\u03b1 : Type u_1} {s : finset \u03b1} {a : \u03b1} : s = singleton a \u2194 a \u2208 s \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 x = a := sorry\n\ntheorem eq_singleton_iff_nonempty_unique_mem {\u03b1 : Type u_1} {s : finset \u03b1} {a : \u03b1} : s = singleton a \u2194 finset.nonempty s \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 x = a := sorry\n\ntheorem singleton_iff_unique_mem {\u03b1 : Type u_1} (s : finset \u03b1) : (\u2203 (a : \u03b1), s = singleton a) \u2194 exists_unique fun (a : \u03b1) => a \u2208 s := sorry\n\ntheorem singleton_subset_set_iff {\u03b1 : Type u_1} {s : set \u03b1} {a : \u03b1} : \u2191(singleton a) \u2286 s \u2194 a \u2208 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2191(singleton a) \u2286 s \u2194 a \u2208 s)) (coe_singleton a)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a \u2286 s \u2194 a \u2208 s)) (propext set.singleton_subset_iff))) (iff.refl (a \u2208 s)))\n\n@[simp] theorem singleton_subset_iff {\u03b1 : Type u_1} {s : finset \u03b1} {a : \u03b1} : singleton a \u2286 s \u2194 a \u2208 s :=\n  singleton_subset_set_iff\n\n/-! ### cons -/\n\n/-- `cons a s h` is the set `{a} \u222a 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 \u03b1`,\nand the union is guaranteed to be disjoint.  -/\ndef cons {\u03b1 : Type u_1} (a : \u03b1) (s : finset \u03b1) (h : \u00aca \u2208 s) : finset \u03b1 :=\n  mk (a ::\u2098 val s) sorry\n\n@[simp] theorem mem_cons {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} {h : \u00aca \u2208 s} {b : \u03b1} : b \u2208 cons a s h \u2194 b = a \u2228 b \u2208 s := sorry\n\n@[simp] theorem cons_val {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) : val (cons a s h) = a ::\u2098 val s :=\n  rfl\n\n@[simp] theorem mk_cons {\u03b1 : Type u_1} {a : \u03b1} {s : multiset \u03b1} (h : multiset.nodup (a ::\u2098 s)) : mk (a ::\u2098 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 {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 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 {\u03b1 : Type u_1} {l : List \u03b1} {hl : multiset.nodup \u2191l} : finset.nonempty (mk (\u2191l) hl) \u2194 l \u2260 [] := sorry\n\n/-! ### disjoint union -/\n\n/-- `disj_union s t h` is the set such that `a \u2208 disj_union s t h` iff `a \u2208 s` or `a \u2208 t`.\nIt is the same as `s \u222a t`, but it does not require decidable equality on the type. The hypothesis\nensures that the sets are disjoint. -/\ndef disj_union {\u03b1 : Type u_1} (s : finset \u03b1) (t : finset \u03b1) (h : \u2200 (a : \u03b1), a \u2208 s \u2192 \u00aca \u2208 t) : finset \u03b1 :=\n  mk (val s + val t) sorry\n\n@[simp] theorem mem_disj_union {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} {h : \u2200 (a : \u03b1), a \u2208 s \u2192 \u00aca \u2208 t} {a : \u03b1} : a \u2208 disj_union s t h \u2194 a \u2208 s \u2228 a \u2208 t := sorry\n\n/-! ### insert -/\n\n/-- `insert a s` is the set `{a} \u222a s` containing `a` and the elements of `s`. -/\nprotected instance has_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] : has_insert \u03b1 (finset \u03b1) :=\n  has_insert.mk fun (a : \u03b1) (s : finset \u03b1) => mk (multiset.ndinsert a (val s)) sorry\n\ntheorem insert_def {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : insert a s = mk (multiset.ndinsert a (val s)) (multiset.nodup_ndinsert a (nodup s)) :=\n  rfl\n\n@[simp] theorem insert_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : val (insert a s) = multiset.ndinsert a (val s) :=\n  rfl\n\ntheorem insert_val' {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : val (insert a s) = multiset.erase_dup (a ::\u2098 val s) := sorry\n\ntheorem insert_val_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) : val (insert a s) = a ::\u2098 val s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (val (insert a s) = a ::\u2098 val s)) (insert_val a s)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (multiset.ndinsert a (val s) = a ::\u2098 val s)) (multiset.ndinsert_of_not_mem h)))\n      (Eq.refl (a ::\u2098 val s)))\n\n@[simp] theorem mem_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} : a \u2208 insert b s \u2194 a = b \u2228 a \u2208 s :=\n  multiset.mem_ndinsert\n\ntheorem mem_insert_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : a \u2208 insert a s :=\n  multiset.mem_ndinsert_self a (val s)\n\ntheorem mem_insert_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} (h : a \u2208 s) : a \u2208 insert b s :=\n  multiset.mem_ndinsert_of_mem h\n\ntheorem mem_of_mem_insert_of_ne {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} (h : b \u2208 insert a s) : b \u2260 a \u2192 b \u2208 s :=\n  or.resolve_left (iff.mp mem_insert h)\n\n@[simp] theorem cons_eq_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (h : \u00aca \u2208 s) : cons a s h = insert a s := sorry\n\n@[simp] theorem coe_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : \u2191(insert a s) = insert a \u2191s := sorry\n\ntheorem mem_insert_coe {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {x : \u03b1} {y : \u03b1} : x \u2208 insert y s \u2194 x \u2208 insert y \u2191s := sorry\n\nprotected instance is_lawful_singleton {\u03b1 : Type u_1} [DecidableEq \u03b1] : is_lawful_singleton \u03b1 (finset \u03b1) :=\n  is_lawful_singleton.mk\n    fun (a : \u03b1) =>\n      ext\n        fun (a_1 : \u03b1) =>\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 \u2208 insert a \u2205) (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 \u2208 \u2205) False\n                        (propext ((fun {\u03b1 : Type u_1} (a : \u03b1) => iff_false_intro (not_mem_empty a)) a_1))))\n                    (propext (or_false (a_1 = a))))\n                  (a_1 \u2208 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) : insert a s = s :=\n  eq_of_veq (multiset.ndinsert_of_mem h)\n\n@[simp] theorem insert_singleton_self_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) : insert a (singleton a) = singleton a :=\n  insert_eq_of_mem (mem_singleton_self a)\n\ntheorem insert.comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) (s : finset \u03b1) : insert a (insert b s) = insert b (insert a s) := sorry\n\ntheorem insert_singleton_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) : insert a (singleton b) = insert b (singleton a) := sorry\n\n@[simp] theorem insert_idem {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : insert a (insert a s) = insert a s := sorry\n\n@[simp] theorem insert_nonempty {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : finset.nonempty (insert a s) :=\n  Exists.intro a (mem_insert_self a s)\n\n@[simp] theorem insert_ne_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : insert a s \u2260 \u2205 :=\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 {\u03b1 : Type u} [DecidableEq \u03b1] (i : \u03b1) (s : finset \u03b1) : Nonempty \u21a5\u2191(insert i s) :=\n  set.nonempty.to_subtype (iff.mpr coe_nonempty (insert_nonempty i s))\n\ntheorem ne_insert_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) {a : \u03b1} (h : \u00aca \u2208 s) : s \u2260 insert a t := sorry\n\ntheorem insert_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} {t : finset \u03b1} : insert a s \u2286 t \u2194 a \u2208 t \u2227 s \u2286 t := sorry\n\ntheorem subset_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : s \u2286 insert a s :=\n  fun (b : \u03b1) => mem_insert_of_mem\n\ntheorem insert_subset_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) {s : finset \u03b1} {t : finset \u03b1} (h : s \u2286 t) : insert a s \u2286 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s \u2282 t \u2194 \u2203 (a : \u03b1), \u2203 (H : \u00aca \u2208 s), insert a s \u2286 t := sorry\n\ntheorem ssubset_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {a : \u03b1} (h : \u00aca \u2208 s) : s \u2282 insert a s :=\n  iff.mpr ssubset_iff (Exists.intro a (Exists.intro h (subset.refl (insert a s))))\n\nprotected theorem induction {\u03b1 : Type u_1} {p : finset \u03b1 \u2192 Prop} [DecidableEq \u03b1] (h\u2081 : p \u2205) (h\u2082 : \u2200 {a : \u03b1} {s : finset \u03b1}, \u00aca \u2208 s \u2192 p s \u2192 p (insert a s)) (s : finset \u03b1) : p s := sorry\n\n/--\nTo prove a proposition about an arbitrary `finset \u03b1`,\nit suffices to prove it for the empty `finset`,\nand to show that if it holds for some `finset \u03b1`,\nthen it holds for the `finset` obtained by inserting a new element.\n-/\nprotected theorem induction_on {\u03b1 : Type u_1} {p : finset \u03b1 \u2192 Prop} [DecidableEq \u03b1] (s : finset \u03b1) (h\u2081 : p \u2205) (h\u2082 : \u2200 {a : \u03b1} {s : finset \u03b1}, \u00aca \u2208 s \u2192 p s \u2192 p (insert a s)) : p s :=\n  finset.induction h\u2081 h\u2082 s\n\n/--\nTo prove a proposition about `S : finset \u03b1`,\nit suffices to prove it for the empty `finset`,\nand to show that if it holds for some `finset \u03b1 \u2286 S`,\nthen it holds for the `finset` obtained by inserting a new element of `S`.\n-/\ntheorem induction_on' {\u03b1 : Type u_1} {p : finset \u03b1 \u2192 Prop} [DecidableEq \u03b1] (S : finset \u03b1) (h\u2081 : p \u2205) (h\u2082 : \u2200 {a : \u03b1} {s : finset \u03b1}, a \u2208 S \u2192 s \u2286 S \u2192 \u00aca \u2208 s \u2192 p s \u2192 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {t : finset \u03b1} {x : \u03b1} (h : \u00acx \u2208 t) : (Subtype fun (i : \u03b1) => i \u2208 insert x t) \u2243 Option (Subtype fun (i : \u03b1) => i \u2208 t) :=\n  equiv.mk\n    (fun (y : Subtype fun (i : \u03b1) => i \u2208 insert x t) =>\n      dite (\u2191y = x) (fun (h : \u2191y = x) => none) fun (h : \u00ac\u2191y = x) => some { val := \u2191y, property := sorry })\n    (fun (y : Option (Subtype fun (i : \u03b1) => i \u2208 t)) =>\n      option.elim y { val := x, property := sorry }\n        fun (z : Subtype fun (i : \u03b1) => i \u2208 t) => { val := \u2191z, property := sorry })\n    sorry sorry\n\n/-! ### union -/\n\n/-- `s \u222a t` is the set such that `a \u2208 s \u222a t` iff `a \u2208 s` or `a \u2208 t`. -/\nprotected instance has_union {\u03b1 : Type u_1} [DecidableEq \u03b1] : has_union (finset \u03b1) :=\n  has_union.mk fun (s\u2081 s\u2082 : finset \u03b1) => mk (multiset.ndunion (val s\u2081) (val s\u2082)) sorry\n\ntheorem union_val_nd {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : val (s\u2081 \u222a s\u2082) = multiset.ndunion (val s\u2081) (val s\u2082) :=\n  rfl\n\n@[simp] theorem union_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : val (s\u2081 \u222a s\u2082) = val s\u2081 \u222a val s\u2082 :=\n  multiset.ndunion_eq_union (nodup s\u2081)\n\n@[simp] theorem mem_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : a \u2208 s\u2081 \u222a s\u2082 \u2194 a \u2208 s\u2081 \u2228 a \u2208 s\u2082 :=\n  multiset.mem_ndunion\n\n@[simp] theorem disj_union_eq_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) (h : \u2200 (a : \u03b1), a \u2208 s \u2192 \u00aca \u2208 t) : disj_union s t h = s \u222a t := sorry\n\ntheorem mem_union_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} (s\u2082 : finset \u03b1) (h : a \u2208 s\u2081) : a \u2208 s\u2081 \u222a s\u2082 :=\n  iff.mpr mem_union (Or.inl h)\n\ntheorem mem_union_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2082 : finset \u03b1} (s\u2081 : finset \u03b1) (h : a \u2208 s\u2082) : a \u2208 s\u2081 \u222a s\u2082 :=\n  iff.mpr mem_union (Or.inr h)\n\ntheorem forall_mem_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {p : \u03b1 \u2192 Prop} : (\u2200 (ab : \u03b1), ab \u2208 s\u2081 \u222a s\u2082 \u2192 p ab) \u2194 (\u2200 (a : \u03b1), a \u2208 s\u2081 \u2192 p a) \u2227 \u2200 (b : \u03b1), b \u2208 s\u2082 \u2192 p b := sorry\n\ntheorem not_mem_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : \u00aca \u2208 s\u2081 \u222a s\u2082 \u2194 \u00aca \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u00aca \u2208 s\u2081 \u222a s\u2082 \u2194 \u00aca \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082)) (propext mem_union)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u00ac(a \u2208 s\u2081 \u2228 a \u2208 s\u2082) \u2194 \u00aca \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082)) (propext not_or_distrib)))\n      (iff.refl (\u00aca \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082)))\n\n@[simp] theorem coe_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : \u2191(s\u2081 \u222a s\u2082) = \u2191s\u2081 \u222a \u2191s\u2082 :=\n  set.ext fun (x : \u03b1) => mem_union\n\ntheorem union_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {s\u2083 : finset \u03b1} (h\u2081 : s\u2081 \u2286 s\u2083) (h\u2082 : s\u2082 \u2286 s\u2083) : s\u2081 \u222a s\u2082 \u2286 s\u2083 :=\n  iff.mp val_le_iff (iff.mpr multiset.ndunion_le { left := h\u2081, right := iff.mpr val_le_iff h\u2082 })\n\ntheorem subset_union_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \u2286 s\u2081 \u222a s\u2082 :=\n  fun (x : \u03b1) => mem_union_left s\u2082\n\ntheorem subset_union_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2082 \u2286 s\u2081 \u222a s\u2082 :=\n  fun (x : \u03b1) => mem_union_right s\u2081\n\ntheorem union_subset_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s1 : finset \u03b1} {t1 : finset \u03b1} {s2 : finset \u03b1} {t2 : finset \u03b1} (h1 : s1 \u2286 t1) (h2 : s2 \u2286 t2) : s1 \u222a s2 \u2286 t1 \u222a t2 := sorry\n\ntheorem union_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \u222a s\u2082 = s\u2082 \u222a s\u2081 := sorry\n\nprotected instance has_union.union.is_commutative {\u03b1 : Type u_1} [DecidableEq \u03b1] : is_commutative (finset \u03b1) has_union.union :=\n  is_commutative.mk union_comm\n\n@[simp] theorem union_assoc {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (s\u2083 : finset \u03b1) : s\u2081 \u222a s\u2082 \u222a s\u2083 = s\u2081 \u222a (s\u2082 \u222a s\u2083) := sorry\n\nprotected instance has_union.union.is_associative {\u03b1 : Type u_1} [DecidableEq \u03b1] : is_associative (finset \u03b1) has_union.union :=\n  is_associative.mk union_assoc\n\n@[simp] theorem union_idempotent {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u222a s = s :=\n  ext fun (_x : \u03b1) => iff.trans mem_union (or_self (_x \u2208 s))\n\nprotected instance has_union.union.is_idempotent {\u03b1 : Type u_1} [DecidableEq \u03b1] : is_idempotent (finset \u03b1) has_union.union :=\n  is_idempotent.mk union_idempotent\n\ntheorem union_left_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (s\u2083 : finset \u03b1) : s\u2081 \u222a (s\u2082 \u222a s\u2083) = s\u2082 \u222a (s\u2081 \u222a s\u2083) := sorry\n\ntheorem union_right_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (s\u2083 : finset \u03b1) : s\u2081 \u222a s\u2082 \u222a s\u2083 = s\u2081 \u222a s\u2083 \u222a s\u2082 := sorry\n\ntheorem union_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u222a s = s :=\n  union_idempotent s\n\n@[simp] theorem union_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u222a \u2205 = s :=\n  ext fun (x : \u03b1) => iff.trans mem_union (or_false (x \u2208 s))\n\n@[simp] theorem empty_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : \u2205 \u222a s = s :=\n  ext fun (x : \u03b1) => iff.trans mem_union (false_or (x \u2208 s))\n\ntheorem insert_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : insert a s = singleton a \u222a s :=\n  rfl\n\n@[simp] theorem insert_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (t : finset \u03b1) : insert a s \u222a t = insert a (s \u222a t) := sorry\n\n@[simp] theorem union_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (t : finset \u03b1) : s \u222a insert a t = insert a (s \u222a t) := sorry\n\ntheorem insert_union_distrib {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (t : finset \u03b1) : insert a (s \u222a t) = insert a s \u222a insert a t := sorry\n\n@[simp] theorem union_eq_left_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s \u222a t = s \u2194 t \u2286 s :=\n  { mp := fun (h : s \u222a t = s) => eq.mp (Eq._oldrec (Eq.refl (t \u2286 s \u222a t)) h) (subset_union_right s t),\n    mpr := fun (h : t \u2286 s) => subset.antisymm (union_subset (subset.refl s) h) (subset_union_left s t) }\n\n@[simp] theorem left_eq_union_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s = s \u222a t \u2194 t \u2286 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s = s \u222a t \u2194 t \u2286 s)) (Eq.symm (propext union_eq_left_iff_subset))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s = s \u222a t \u2194 s \u222a t = s)) (propext eq_comm))) (iff.refl (s \u222a t = s)))\n\n@[simp] theorem union_eq_right_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : t \u222a s = s \u2194 t \u2286 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (t \u222a s = s \u2194 t \u2286 s)) (union_comm t s)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \u222a t = s \u2194 t \u2286 s)) (propext union_eq_left_iff_subset))) (iff.refl (t \u2286 s)))\n\n@[simp] theorem right_eq_union_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s = t \u222a s \u2194 t \u2286 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s = t \u222a s \u2194 t \u2286 s)) (Eq.symm (propext union_eq_right_iff_subset))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s = t \u222a s \u2194 t \u222a s = s)) (propext eq_comm))) (iff.refl (t \u222a 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 \u222a b, c]`.\n-/\ntheorem induction_on_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (P : finset \u03b1 \u2192 finset \u03b1 \u2192 Prop) (symm : \u2200 {a b : finset \u03b1}, P a b \u2192 P b a) (empty_right : \u2200 {a : finset \u03b1}, P a \u2205) (singletons : \u2200 {a b : \u03b1}, P (singleton a) (singleton b)) (union_of : \u2200 {a b c : finset \u03b1}, P a c \u2192 P b c \u2192 P (a \u222a b) c) (a : finset \u03b1) (b : finset \u03b1) : P a b := sorry\n\n/-! ### inter -/\n\n/-- `s \u2229 t` is the set such that `a \u2208 s \u2229 t` iff `a \u2208 s` and `a \u2208 t`. -/\nprotected instance has_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] : has_inter (finset \u03b1) :=\n  has_inter.mk fun (s\u2081 s\u2082 : finset \u03b1) => mk (multiset.ndinter (val s\u2081) (val s\u2082)) sorry\n\ntheorem inter_val_nd {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : val (s\u2081 \u2229 s\u2082) = multiset.ndinter (val s\u2081) (val s\u2082) :=\n  rfl\n\n@[simp] theorem inter_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : val (s\u2081 \u2229 s\u2082) = val s\u2081 \u2229 val s\u2082 :=\n  multiset.ndinter_eq_inter (nodup s\u2081)\n\n@[simp] theorem mem_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : a \u2208 s\u2081 \u2229 s\u2082 \u2194 a \u2208 s\u2081 \u2227 a \u2208 s\u2082 :=\n  multiset.mem_ndinter\n\ntheorem mem_of_mem_inter_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : a \u2208 s\u2081 \u2229 s\u2082) : a \u2208 s\u2081 :=\n  and.left (iff.mp mem_inter h)\n\ntheorem mem_of_mem_inter_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : a \u2208 s\u2081 \u2229 s\u2082) : a \u2208 s\u2082 :=\n  and.right (iff.mp mem_inter h)\n\ntheorem mem_inter_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : a \u2208 s\u2081 \u2192 a \u2208 s\u2082 \u2192 a \u2208 s\u2081 \u2229 s\u2082 :=\n  iff.mp and_imp (iff.mpr mem_inter)\n\ntheorem inter_subset_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \u2229 s\u2082 \u2286 s\u2081 :=\n  fun (a : \u03b1) => mem_of_mem_inter_left\n\ntheorem inter_subset_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \u2229 s\u2082 \u2286 s\u2082 :=\n  fun (a : \u03b1) => mem_of_mem_inter_right\n\ntheorem subset_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {s\u2083 : finset \u03b1} : s\u2081 \u2286 s\u2082 \u2192 s\u2081 \u2286 s\u2083 \u2192 s\u2081 \u2286 s\u2082 \u2229 s\u2083 := sorry\n\n@[simp] theorem coe_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : \u2191(s\u2081 \u2229 s\u2082) = \u2191s\u2081 \u2229 \u2191s\u2082 :=\n  set.ext fun (_x : \u03b1) => mem_inter\n\n@[simp] theorem union_inter_cancel_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : (s \u222a t) \u2229 s = s := sorry\n\n@[simp] theorem union_inter_cancel_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : (s \u222a t) \u2229 t = t := sorry\n\ntheorem inter_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \u2229 s\u2082 = s\u2082 \u2229 s\u2081 := sorry\n\n@[simp] theorem inter_assoc {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (s\u2083 : finset \u03b1) : s\u2081 \u2229 s\u2082 \u2229 s\u2083 = s\u2081 \u2229 (s\u2082 \u2229 s\u2083) := sorry\n\ntheorem inter_left_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (s\u2083 : finset \u03b1) : s\u2081 \u2229 (s\u2082 \u2229 s\u2083) = s\u2082 \u2229 (s\u2081 \u2229 s\u2083) := sorry\n\ntheorem inter_right_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (s\u2083 : finset \u03b1) : s\u2081 \u2229 s\u2082 \u2229 s\u2083 = s\u2081 \u2229 s\u2083 \u2229 s\u2082 := sorry\n\n@[simp] theorem inter_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u2229 s = s :=\n  ext fun (_x : \u03b1) => iff.trans mem_inter (and_self (_x \u2208 s))\n\n@[simp] theorem inter_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u2229 \u2205 = \u2205 :=\n  ext fun (_x : \u03b1) => iff.trans mem_inter (and_false (_x \u2208 s))\n\n@[simp] theorem empty_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : \u2205 \u2229 s = \u2205 :=\n  ext fun (_x : \u03b1) => iff.trans mem_inter (false_and (_x \u2208 s))\n\n@[simp] theorem inter_union_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : s \u2229 (t \u222a s) = s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \u2229 (t \u222a s) = s)) (inter_comm s (t \u222a s))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((t \u222a s) \u2229 s = s)) union_inter_cancel_right)) (Eq.refl s))\n\n@[simp] theorem insert_inter_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {a : \u03b1} (h : a \u2208 s\u2082) : insert a s\u2081 \u2229 s\u2082 = insert a (s\u2081 \u2229 s\u2082) := sorry\n\n@[simp] theorem inter_insert_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {a : \u03b1} (h : a \u2208 s\u2081) : s\u2081 \u2229 insert a s\u2082 = insert a (s\u2081 \u2229 s\u2082) := sorry\n\n@[simp] theorem insert_inter_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {a : \u03b1} (h : \u00aca \u2208 s\u2082) : insert a s\u2081 \u2229 s\u2082 = s\u2081 \u2229 s\u2082 := sorry\n\n@[simp] theorem inter_insert_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {a : \u03b1} (h : \u00aca \u2208 s\u2081) : s\u2081 \u2229 insert a s\u2082 = s\u2081 \u2229 s\u2082 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s\u2081 \u2229 insert a s\u2082 = s\u2081 \u2229 s\u2082)) (inter_comm s\u2081 (insert a s\u2082))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (insert a s\u2082 \u2229 s\u2081 = s\u2081 \u2229 s\u2082)) (insert_inter_of_not_mem h)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s\u2082 \u2229 s\u2081 = s\u2081 \u2229 s\u2082)) (inter_comm s\u2082 s\u2081))) (Eq.refl (s\u2081 \u2229 s\u2082))))\n\n@[simp] theorem singleton_inter_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (H : a \u2208 s) : singleton a \u2229 s = singleton a :=\n  (fun (this : insert a \u2205 \u2229 s = insert a \u2205) => this)\n    (eq.mpr (id (Eq._oldrec (Eq.refl (insert a \u2205 \u2229 s = insert a \u2205)) (insert_inter_of_mem H)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (insert a (\u2205 \u2229 s) = insert a \u2205)) (empty_inter s))) (Eq.refl (insert a \u2205))))\n\n@[simp] theorem singleton_inter_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (H : \u00aca \u2208 s) : singleton a \u2229 s = \u2205 := sorry\n\n@[simp] theorem inter_singleton_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) : s \u2229 singleton a = singleton a :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \u2229 singleton a = singleton a)) (inter_comm s (singleton a))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a \u2229 s = singleton a)) (singleton_inter_of_mem h)))\n      (Eq.refl (singleton a)))\n\n@[simp] theorem inter_singleton_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) : s \u2229 singleton a = \u2205 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \u2229 singleton a = \u2205)) (inter_comm s (singleton a))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a \u2229 s = \u2205)) (singleton_inter_of_not_mem h))) (Eq.refl \u2205))\n\ntheorem inter_subset_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {x : finset \u03b1} {y : finset \u03b1} {s : finset \u03b1} {t : finset \u03b1} (h : x \u2286 y) (h' : s \u2286 t) : x \u2229 s \u2286 y \u2229 t := sorry\n\ntheorem inter_subset_inter_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {x : finset \u03b1} {y : finset \u03b1} {s : finset \u03b1} (h : x \u2286 y) : x \u2229 s \u2286 y \u2229 s :=\n  inter_subset_inter h (subset.refl s)\n\ntheorem inter_subset_inter_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {x : finset \u03b1} {y : finset \u03b1} {s : finset \u03b1} (h : x \u2286 y) : s \u2229 x \u2286 s \u2229 y :=\n  inter_subset_inter (subset.refl s) h\n\n/-! ### lattice laws -/\n\nprotected instance lattice {\u03b1 : Type u_1} [DecidableEq \u03b1] : lattice (finset \u03b1) :=\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : s \u2294 t = s \u222a t :=\n  rfl\n\n@[simp] theorem inf_eq_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : s \u2293 t = s \u2229 t :=\n  rfl\n\nprotected instance semilattice_inf_bot {\u03b1 : Type u_1} [DecidableEq \u03b1] : semilattice_inf_bot (finset \u03b1) :=\n  semilattice_inf_bot.mk \u2205 lattice.le lattice.lt sorry sorry sorry empty_subset lattice.inf sorry sorry sorry\n\nprotected instance semilattice_sup_bot {\u03b1 : Type u_1} [DecidableEq \u03b1] : semilattice_sup_bot (finset \u03b1) :=\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] : distrib_lattice (finset \u03b1) :=\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) (u : finset \u03b1) : s \u2229 (t \u222a u) = s \u2229 t \u222a s \u2229 u :=\n  inf_sup_left\n\ntheorem inter_distrib_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) (u : finset \u03b1) : (s \u222a t) \u2229 u = s \u2229 u \u222a t \u2229 u :=\n  inf_sup_right\n\ntheorem union_distrib_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) (u : finset \u03b1) : s \u222a t \u2229 u = (s \u222a t) \u2229 (s \u222a u) :=\n  sup_inf_left\n\ntheorem union_distrib_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) (u : finset \u03b1) : s \u2229 t \u222a u = (s \u222a u) \u2229 (t \u222a u) :=\n  sup_inf_right\n\ntheorem union_eq_empty_iff {\u03b1 : Type u_1} [DecidableEq \u03b1] (A : finset \u03b1) (B : finset \u03b1) : A \u222a B = \u2205 \u2194 A = \u2205 \u2227 B = \u2205 :=\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (a : \u03b1) : finset \u03b1 :=\n  mk (multiset.erase (val s) a) sorry\n\n@[simp] theorem erase_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (a : \u03b1) : val (erase s a) = multiset.erase (val s) a :=\n  rfl\n\n@[simp] theorem mem_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} : a \u2208 erase s b \u2194 a \u2260 b \u2227 a \u2208 s :=\n  multiset.mem_erase_iff_of_nodup (nodup s)\n\ntheorem not_mem_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : \u00aca \u2208 erase s a :=\n  multiset.mem_erase_of_nodup (nodup s)\n\n@[simp] theorem erase_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) : erase \u2205 a = \u2205 :=\n  rfl\n\ntheorem ne_of_mem_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} : b \u2208 erase s a \u2192 b \u2260 a :=\n  eq.mpr (id (imp_congr_eq (propext mem_erase) (Eq.refl (b \u2260 a)))) and.left\n\ntheorem mem_of_mem_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} : b \u2208 erase s a \u2192 b \u2208 s :=\n  multiset.mem_of_mem_erase\n\ntheorem mem_erase_of_ne_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} : a \u2260 b \u2192 a \u2208 s \u2192 a \u2208 erase s b :=\n  eq.mpr (id (imp_congr_eq (Eq.refl (a \u2260 b)) (imp_congr_eq (Eq.refl (a \u2208 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} (hs : b \u2208 s) (hsa : \u00acb \u2208 erase s a) : b = a := sorry\n\ntheorem erase_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) : erase (insert a s) a = s := sorry\n\ntheorem insert_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) : insert a (erase s a) = s := sorry\n\ntheorem erase_subset_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) {s : finset \u03b1} {t : finset \u03b1} (h : s \u2286 t) : erase s a \u2286 erase t a :=\n  iff.mp val_le_iff (multiset.erase_le_erase a (iff.mpr val_le_iff h))\n\ntheorem erase_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : erase s a \u2286 s :=\n  multiset.erase_subset a (val s)\n\n@[simp] theorem coe_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : \u2191(erase s a) = \u2191s \\ singleton a := sorry\n\ntheorem erase_ssubset {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) : erase s a \u2282 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) : erase s a = s :=\n  eq_of_veq (multiset.erase_of_not_mem h)\n\ntheorem subset_insert_iff {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} {t : finset \u03b1} : s \u2286 insert a t \u2194 erase s a \u2286 t := sorry\n\ntheorem erase_insert_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : erase (insert a s) a \u2286 s :=\n  iff.mp subset_insert_iff (subset.refl (insert a s))\n\ntheorem insert_erase_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : s \u2286 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] : has_sdiff (finset \u03b1) :=\n  has_sdiff.mk fun (s\u2081 s\u2082 : finset \u03b1) => mk (val s\u2081 - val s\u2082) sorry\n\n@[simp] theorem mem_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : a \u2208 s\u2081 \\ s\u2082 \u2194 a \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082 :=\n  multiset.mem_sub_of_nodup (nodup s\u2081)\n\ntheorem not_mem_sdiff_of_mem_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} {t : finset \u03b1} (h : a \u2208 t) : \u00aca \u2208 s \\ t := sorry\n\ntheorem sdiff_union_of_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : s\u2081 \u2286 s\u2082) : s\u2082 \\ s\u2081 \u222a s\u2081 = s\u2082 := sorry\n\ntheorem union_sdiff_of_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : s\u2081 \u2286 s\u2082) : s\u2081 \u222a s\u2082 \\ s\u2081 = s\u2082 :=\n  Eq.trans (union_comm s\u2081 (s\u2082 \\ s\u2081)) (sdiff_union_of_subset h)\n\ntheorem inter_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) (u : finset \u03b1) : s \u2229 (t \\ u) = s \u2229 t \\ u := sorry\n\n@[simp] theorem inter_sdiff_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \u2229 (s\u2082 \\ s\u2081) = \u2205 := sorry\n\n@[simp] theorem sdiff_inter_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2082 \\ s\u2081 \u2229 s\u2081 = \u2205 :=\n  Eq.trans (inter_comm (s\u2082 \\ s\u2081) s\u2081) (inter_sdiff_self s\u2081 s\u2082)\n\n@[simp] theorem sdiff_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) : s\u2081 \\ s\u2081 = \u2205 := sorry\n\ntheorem sdiff_inter_distrib_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (s\u2083 : finset \u03b1) : s\u2081 \\ (s\u2082 \u2229 s\u2083) = s\u2081 \\ s\u2082 \u222a s\u2081 \\ s\u2083 := sorry\n\n@[simp] theorem sdiff_inter_self_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \\ (s\u2081 \u2229 s\u2082) = s\u2081 \\ s\u2082 := sorry\n\n@[simp] theorem sdiff_inter_self_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \\ (s\u2082 \u2229 s\u2081) = s\u2081 \\ s\u2082 := sorry\n\n@[simp] theorem sdiff_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} : s\u2081 \\ \u2205 = s\u2081 := sorry\n\ntheorem sdiff_subset_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {t\u2081 : finset \u03b1} {t\u2082 : finset \u03b1} (h\u2081 : t\u2081 \u2286 t\u2082) (h\u2082 : s\u2082 \u2286 s\u2081) : t\u2081 \\ s\u2081 \u2286 t\u2082 \\ s\u2082 := sorry\n\ntheorem sdiff_subset_self {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 \\ s\u2082 \u2286 s\u2081 := sorry\n\n@[simp] theorem coe_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : \u2191(s\u2081 \\ s\u2082) = \u2191s\u2081 \\ \u2191s\u2082 :=\n  set.ext fun (_x : \u03b1) => mem_sdiff\n\n@[simp] theorem union_sdiff_self_eq_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s \u222a t \\ s = s \u222a t := sorry\n\n@[simp] theorem sdiff_union_self_eq_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s \\ t \u222a t = s \u222a t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t \u222a t = s \u222a t)) (union_comm (s \\ t) t)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (t \u222a s \\ t = s \u222a t)) union_sdiff_self_eq_union))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (t \u222a s = s \u222a t)) (union_comm t s))) (Eq.refl (s \u222a t))))\n\ntheorem union_sdiff_symm {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s \u222a t \\ s = t \u222a s \\ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \u222a t \\ s = t \u222a s \\ t)) union_sdiff_self_eq_union))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \u222a t = t \u222a s \\ t)) union_sdiff_self_eq_union))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s \u222a t = t \u222a s)) (union_comm s t))) (Eq.refl (t \u222a s))))\n\ntheorem sdiff_union_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : s \\ t \u222a s \u2229 t = s := sorry\n\n@[simp] theorem sdiff_idem {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : s \\ t \\ t = s \\ t := sorry\n\ntheorem sdiff_eq_empty_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s \\ t = \u2205 \u2194 s \u2286 t := sorry\n\n@[simp] theorem empty_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : \u2205 \\ s = \u2205 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2205 \\ s = \u2205)) (propext sdiff_eq_empty_iff_subset))) (empty_subset s)\n\ntheorem insert_sdiff_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) {t : finset \u03b1} {x : \u03b1} (h : \u00acx \u2208 t) : insert x s \\ t = insert x (s \\ t) := sorry\n\ntheorem insert_sdiff_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) {t : finset \u03b1} {x : \u03b1} (h : x \u2208 t) : insert x s \\ t = s \\ t := sorry\n\n@[simp] theorem insert_sdiff_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) (x : \u03b1) : 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {x : \u03b1} (h : \u00acx \u2208 s) (t : finset \u03b1) : s \\ insert x t = s \\ t := sorry\n\n@[simp] theorem sdiff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : s \\ t \u2286 s := sorry\n\ntheorem union_sdiff_distrib {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (t : finset \u03b1) : (s\u2081 \u222a s\u2082) \\ t = s\u2081 \\ t \u222a s\u2082 \\ t := sorry\n\ntheorem sdiff_union_distrib {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t\u2081 : finset \u03b1) (t\u2082 : finset \u03b1) : s \\ (t\u2081 \u222a t\u2082) = s \\ t\u2081 \u2229 (s \\ t\u2082) := sorry\n\ntheorem union_sdiff_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : (s \u222a t) \\ t = s \\ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl ((s \u222a t) \\ t = s \\ t)) (union_sdiff_distrib s t t)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t \u222a t \\ t = s \\ t)) (sdiff_self t)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t \u222a \u2205 = s \\ t)) (union_empty (s \\ t)))) (Eq.refl (s \\ t))))\n\ntheorem sdiff_singleton_eq_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : s \\ singleton a = erase s a := sorry\n\ntheorem sdiff_sdiff_self_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : s \\ (s \\ t) = s \u2229 t := sorry\n\ntheorem inter_eq_inter_of_sdiff_eq_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t\u2081 : finset \u03b1} {t\u2082 : finset \u03b1} : s \\ t\u2081 = s \\ t\u2082 \u2192 s \u2229 t\u2081 = s \u2229 t\u2082 := 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 \u2208 s}`. -/\ndef attach {\u03b1 : Type u_1} (s : finset \u03b1) : finset (Subtype fun (x : \u03b1) => x \u2208 s) :=\n  mk (multiset.attach (val s)) sorry\n\ntheorem sizeof_lt_sizeof_of_mem {\u03b1 : Type u_1} [SizeOf \u03b1] {x : \u03b1} {s : finset \u03b1} (hx : x \u2208 s) : sizeof x < sizeof s := sorry\n\n@[simp] theorem attach_val {\u03b1 : Type u_1} (s : finset \u03b1) : val (attach s) = multiset.attach (val s) :=\n  rfl\n\n@[simp] theorem mem_attach {\u03b1 : Type u_1} (s : finset \u03b1) (x : Subtype fun (x : \u03b1) => x \u2208 s) : x \u2208 attach s :=\n  multiset.mem_attach (val s)\n\n@[simp] theorem attach_empty {\u03b1 : Type u_1} : attach \u2205 = \u2205 :=\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 {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_2} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] (i : \u03b1) : \u03b4 i :=\n  ite (i \u2208 s) (f i) (g i)\n\n@[simp] theorem piecewise_insert_self {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [DecidableEq \u03b1] {j : \u03b1} [(i : \u03b1) \u2192 Decidable (i \u2208 insert j s)] : piecewise (insert j s) f g j = f j := sorry\n\n@[simp] theorem piecewise_empty {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(i : \u03b1) \u2192 Decidable (i \u2208 \u2205)] : piecewise \u2205 f g = g := sorry\n\ntheorem piecewise_coe {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [(j : \u03b1) \u2192 Decidable (j \u2208 \u2191s)] : set.piecewise (\u2191s) f g = piecewise s f g := sorry\n\n@[simp] theorem piecewise_eq_of_mem {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {i : \u03b1} (hi : i \u2208 s) : piecewise s f g i = f i := sorry\n\n@[simp] theorem piecewise_eq_of_not_mem {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {i : \u03b1} (hi : \u00aci \u2208 s) : piecewise s f g i = g i := sorry\n\ntheorem piecewise_congr {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {f : (i : \u03b1) \u2192 \u03b4 i} {f' : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} {g' : (i : \u03b1) \u2192 \u03b4 i} (hf : \u2200 (i : \u03b1), i \u2208 s \u2192 f i = f' i) (hg : \u2200 (i : \u03b1), \u00aci \u2208 s \u2192 g i = g' i) : piecewise s f g = piecewise s f' g' :=\n  funext fun (i : \u03b1) => if_ctx_congr iff.rfl (hf i) (hg i)\n\n@[simp] theorem piecewise_insert_of_ne {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] {i : \u03b1} {j : \u03b1} [(i : \u03b1) \u2192 Decidable (i \u2208 insert j s)] (h : i \u2260 j) : piecewise (insert j s) f g i = piecewise s f g i := sorry\n\ntheorem piecewise_insert {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] (j : \u03b1) [(i : \u03b1) \u2192 Decidable (i \u2208 insert j s)] : piecewise (insert j s) f g = function.update (piecewise s f g) j (f j) := sorry\n\ntheorem piecewise_cases {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {i : \u03b1} (p : \u03b4 i \u2192 Prop) (hf : p (f i)) (hg : p (g i)) : p (piecewise s f g i) := sorry\n\ntheorem piecewise_mem_set_pi {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {\u03b4 : \u03b1 \u2192 Type u_2} {t : set \u03b1} {t' : (i : \u03b1) \u2192 set (\u03b4 i)} {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} (hf : f \u2208 set.pi t t') (hg : g \u2208 set.pi t t') : piecewise s f g \u2208 set.pi t t' :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (piecewise s f g \u2208 set.pi t t')) (Eq.symm (piecewise_coe s f g))))\n    (set.piecewise_mem_pi (\u2191s) hf hg)\n\ntheorem piecewise_singleton {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [DecidableEq \u03b1] (i : \u03b1) : piecewise (singleton i) f g = function.update g i (f i) := sorry\n\ntheorem piecewise_piecewise_of_subset_left {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} {s : finset \u03b1} {t : finset \u03b1} [(i : \u03b1) \u2192 Decidable (i \u2208 s)] [(i : \u03b1) \u2192 Decidable (i \u2208 t)] (h : s \u2286 t) (f\u2081 : (a : \u03b1) \u2192 \u03b4 a) (f\u2082 : (a : \u03b1) \u2192 \u03b4 a) (g : (a : \u03b1) \u2192 \u03b4 a) : piecewise s (piecewise t f\u2081 f\u2082) g = piecewise s f\u2081 g :=\n  piecewise_congr s (fun (i : \u03b1) (hi : i \u2208 s) => piecewise_eq_of_mem t f\u2081 f\u2082 (h hi)) fun (_x : \u03b1) (_x_1 : \u00ac_x \u2208 s) => rfl\n\n@[simp] theorem piecewise_idem_left {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] (f\u2081 : (a : \u03b1) \u2192 \u03b4 a) (f\u2082 : (a : \u03b1) \u2192 \u03b4 a) (g : (a : \u03b1) \u2192 \u03b4 a) : piecewise s (piecewise s f\u2081 f\u2082) g = piecewise s f\u2081 g :=\n  piecewise_piecewise_of_subset_left (subset.refl s) f\u2081 f\u2082 g\n\ntheorem piecewise_piecewise_of_subset_right {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} {s : finset \u03b1} {t : finset \u03b1} [(i : \u03b1) \u2192 Decidable (i \u2208 s)] [(i : \u03b1) \u2192 Decidable (i \u2208 t)] (h : t \u2286 s) (f : (a : \u03b1) \u2192 \u03b4 a) (g\u2081 : (a : \u03b1) \u2192 \u03b4 a) (g\u2082 : (a : \u03b1) \u2192 \u03b4 a) : piecewise s f (piecewise t g\u2081 g\u2082) = piecewise s f g\u2082 :=\n  piecewise_congr s (fun (_x : \u03b1) (_x_1 : _x \u2208 s) => rfl)\n    fun (i : \u03b1) (hi : \u00aci \u2208 s) => piecewise_eq_of_not_mem t g\u2081 g\u2082 (mt h hi)\n\n@[simp] theorem piecewise_idem_right {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] (f : (a : \u03b1) \u2192 \u03b4 a) (g\u2081 : (a : \u03b1) \u2192 \u03b4 a) (g\u2082 : (a : \u03b1) \u2192 \u03b4 a) : piecewise s f (piecewise s g\u2081 g\u2082) = piecewise s f g\u2082 :=\n  piecewise_piecewise_of_subset_right (subset.refl s) f g\u2081 g\u2082\n\ntheorem update_eq_piecewise {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] (f : \u03b1 \u2192 \u03b2) (i : \u03b1) (v : \u03b2) : function.update f i v = piecewise (singleton i) (fun (j : \u03b1) => v) f :=\n  Eq.symm (piecewise_singleton (fun (i : \u03b1) => v) f i)\n\ntheorem update_piecewise {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] (i : \u03b1) (v : \u03b4 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 {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] {i : \u03b1} (hi : i \u2208 s) (v : \u03b4 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 {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] {i : \u03b1} (hi : \u00aci \u2208 s) (v : \u03b4 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 {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} {h : (i : \u03b1) \u2192 \u03b4 i} (Hf : f \u2264 h) (Hg : g \u2264 h) : piecewise s f g \u2264 h :=\n  fun (x : \u03b1) => piecewise_cases s f g (fun (_x : \u03b4 x) => _x \u2264 h x) (Hf x) (Hg x)\n\ntheorem le_piecewise_of_le_of_le {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} {h : (i : \u03b1) \u2192 \u03b4 i} (Hf : h \u2264 f) (Hg : h \u2264 g) : h \u2264 piecewise s f g :=\n  fun (x : \u03b1) => piecewise_cases s f g (fun (y : \u03b4 x) => h x \u2264 y) (Hf x) (Hg x)\n\ntheorem piecewise_le_piecewise' {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} {f' : (i : \u03b1) \u2192 \u03b4 i} {g' : (i : \u03b1) \u2192 \u03b4 i} (Hf : \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2264 f' x) (Hg : \u2200 (x : \u03b1), \u00acx \u2208 s \u2192 g x \u2264 g' x) : piecewise s f g \u2264 piecewise s f' g' := sorry\n\ntheorem piecewise_le_piecewise {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} {f' : (i : \u03b1) \u2192 \u03b4 i} {g' : (i : \u03b1) \u2192 \u03b4 i} (Hf : f \u2264 f') (Hg : g \u2264 g') : piecewise s f g \u2264 piecewise s f' g' :=\n  piecewise_le_piecewise' s (fun (x : \u03b1) (_x : x \u2208 s) => Hf x) fun (x : \u03b1) (_x : \u00acx \u2208 s) => Hg x\n\ntheorem piecewise_mem_Icc_of_mem_of_mem {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {f\u2081 : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} {g\u2081 : (i : \u03b1) \u2192 \u03b4 i} (hf : f \u2208 set.Icc f\u2081 g\u2081) (hg : g \u2208 set.Icc f\u2081 g\u2081) : piecewise s f g \u2208 set.Icc f\u2081 g\u2081 :=\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 {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} (h : f \u2264 g) : piecewise s f g \u2208 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' {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i} (h : g \u2264 f) : piecewise s f g \u2208 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 {\u03b1 : Type u_1} {s : finset \u03b1} {p : (a : \u03b1) \u2192 a \u2208 s \u2192 Prop} [hp : (a : \u03b1) \u2192 (h : a \u2208 s) \u2192 Decidable (p a h)] : Decidable (\u2200 (a : \u03b1) (h : a \u2208 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 {\u03b1 : Type u_1} {s : finset \u03b1} {\u03b2 : \u03b1 \u2192 Type u_2} [h : (a : \u03b1) \u2192 DecidableEq (\u03b2 a)] : DecidableEq ((a : \u03b1) \u2192 a \u2208 s \u2192 \u03b2 a) :=\n  multiset.decidable_eq_pi_multiset\n\nprotected instance decidable_dexists_finset {\u03b1 : Type u_1} {s : finset \u03b1} {p : (a : \u03b1) \u2192 a \u2208 s \u2192 Prop} [hp : (a : \u03b1) \u2192 (h : a \u2208 s) \u2192 Decidable (p a h)] : Decidable (\u2203 (a : \u03b1), \u2203 (h : a \u2208 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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) : finset \u03b1 :=\n  mk (multiset.filter p (val s)) sorry\n\n@[simp] theorem filter_val {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) : val (filter p s) = multiset.filter p (val s) :=\n  rfl\n\n@[simp] theorem filter_subset {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) : filter p s \u2286 s :=\n  multiset.filter_subset p (val s)\n\n@[simp] theorem mem_filter {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} {a : \u03b1} : a \u2208 filter p s \u2194 a \u2208 s \u2227 p a :=\n  multiset.mem_filter\n\ntheorem filter_ssubset {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} : filter p s \u2282 s \u2194 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), \u00acp x := sorry\n\ntheorem filter_filter {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) [decidable_pred p] [decidable_pred q] (s : finset \u03b1) : filter q (filter p s) = filter (fun (a : \u03b1) => p a \u2227 q a) s := sorry\n\ntheorem filter_true {\u03b1 : Type u_1} {s : finset \u03b1} [h : decidable_pred fun (_x : \u03b1) => True] : filter (fun (_x : \u03b1) => True) s = s := sorry\n\n@[simp] theorem filter_false {\u03b1 : Type u_1} {h : decidable_pred fun (a : \u03b1) => False} (s : finset \u03b1) : filter (fun (a : \u03b1) => False) s = \u2205 := 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 {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 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 `\u2205`. -/\ntheorem filter_false_of_mem {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 \u00acp x) : filter p s = \u2205 := sorry\n\ntheorem filter_congr {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q] {s : finset \u03b1} (H : \u2200 (x : \u03b1), x \u2208 s \u2192 (p x \u2194 q x)) : filter p s = filter q s :=\n  eq_of_veq (multiset.filter_congr H)\n\ntheorem filter_empty {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] : filter p \u2205 = \u2205 :=\n  iff.mp subset_empty (filter_subset p \u2205)\n\ntheorem filter_subset_filter {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] {s : finset \u03b1} {t : finset \u03b1} (h : s \u2286 t) : filter p s \u2286 filter p t :=\n  fun (a : \u03b1) (ha : a \u2208 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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) : \u2191(filter p s) = has_sep.sep (fun (x : \u03b1) => p x) \u2191s :=\n  set.ext fun (_x : \u03b1) => mem_filter\n\ntheorem filter_singleton {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (a : \u03b1) : filter p (singleton a) = ite (p a) (singleton a) \u2205 := sorry\n\ntheorem filter_union {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : filter p (s\u2081 \u222a s\u2082) = filter p s\u2081 \u222a filter p s\u2082 := sorry\n\ntheorem filter_union_right {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) [decidable_pred p] [decidable_pred q] [DecidableEq \u03b1] (s : finset \u03b1) : filter p s \u222a filter q s = filter (fun (x : \u03b1) => p x \u2228 q x) s := sorry\n\ntheorem filter_mem_eq_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} [(i : \u03b1) \u2192 Decidable (i \u2208 t)] : filter (fun (i : \u03b1) => i \u2208 t) s = s \u2229 t := sorry\n\ntheorem filter_inter {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : filter p s \u2229 t = filter p (s \u2229 t) := sorry\n\ntheorem inter_filter {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : s \u2229 filter p t = filter p (s \u2229 t) := sorry\n\ntheorem filter_insert {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : filter p (insert a s) = ite (p a) (insert a (filter p s)) (filter p s) := sorry\n\ntheorem filter_or {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) [decidable_pred p] [decidable_pred q] [DecidableEq \u03b1] [decidable_pred fun (a : \u03b1) => p a \u2228 q a] (s : finset \u03b1) : filter (fun (a : \u03b1) => p a \u2228 q a) s = filter p s \u222a filter q s := sorry\n\ntheorem filter_and {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) [decidable_pred p] [decidable_pred q] [DecidableEq \u03b1] [decidable_pred fun (a : \u03b1) => p a \u2227 q a] (s : finset \u03b1) : filter (fun (a : \u03b1) => p a \u2227 q a) s = filter p s \u2229 filter q s := sorry\n\ntheorem filter_not {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] [decidable_pred fun (a : \u03b1) => \u00acp a] (s : finset \u03b1) : filter (fun (a : \u03b1) => \u00acp a) s = s \\ filter p s := sorry\n\ntheorem sdiff_eq_filter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \\ s\u2082 = filter (fun (_x : \u03b1) => \u00ac_x \u2208 s\u2082) s\u2081 := sorry\n\ntheorem sdiff_eq_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : s\u2081 \\ s\u2082 = s\u2081 \u2194 s\u2081 \u2229 s\u2082 \u2286 \u2205 := sorry\n\ntheorem filter_union_filter_neg_eq {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] [decidable_pred fun (a : \u03b1) => \u00acp a] (s : finset \u03b1) : filter p s \u222a filter (fun (a : \u03b1) => \u00acp a) s = s := sorry\n\ntheorem filter_inter_filter_neg_eq {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] (s : finset \u03b1) : filter p s \u2229 filter (fun (a : \u03b1) => \u00acp a) s = \u2205 := sorry\n\ntheorem subset_union_elim {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t\u2081 : set \u03b1} {t\u2082 : set \u03b1} (h : \u2191s \u2286 t\u2081 \u222a t\u2082) : \u2203 (s\u2081 : finset \u03b1), \u2203 (s\u2082 : finset \u03b1), s\u2081 \u222a s\u2082 = s \u2227 \u2191s\u2081 \u2286 t\u2081 \u2227 \u2191s\u2082 \u2286 t\u2082 \\ t\u2081 := 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 {\u03b1 : Type u_1} (s : finset \u03b1) (p : \u03b1 \u2192 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 \u2208 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 \u2208 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 \u2208 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 {\u03b1 : Type u_1} : has_sep \u03b1 (finset \u03b1) :=\n  has_sep.mk fun (p : \u03b1 \u2192 Prop) (x : finset \u03b1) => filter p x\n\n@[simp] theorem sep_def {\u03b1 : Type u_1} (s : finset \u03b1) (p : \u03b1 \u2192 Prop) : has_sep.sep (fun (x : \u03b1) => 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 \u2208 s.filter(eq b)`.\n\ntheorem filter_eq {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b2) (b : \u03b2) : filter (Eq b) s = ite (b \u2208 s) (singleton b) \u2205 := 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' {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b2) (b : \u03b2) : filter (fun (a : \u03b2) => a = b) s = ite (b \u2208 s) (singleton b) \u2205 :=\n  trans (filter_congr fun (_x : \u03b2) (_x_1 : _x \u2208 s) => { mp := Eq.symm, mpr := Eq.symm }) (filter_eq s b)\n\ntheorem filter_ne {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b2) (b : \u03b2) : filter (fun (a : \u03b2) => b \u2260 a) s = erase s b := sorry\n\ntheorem filter_ne' {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b2) (b : \u03b2) : filter (fun (a : \u03b2) => a \u2260 b) s = erase s b :=\n  trans (filter_congr fun (_x : \u03b2) (_x_1 : _x \u2208 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 : \u2115) : finset \u2115 :=\n  mk (multiset.range n) (multiset.nodup_range n)\n\n@[simp] theorem range_coe (n : \u2115) : val (range n) = multiset.range n :=\n  rfl\n\n@[simp] theorem mem_range {n : \u2115} {m : \u2115} : m \u2208 range n \u2194 m < n :=\n  multiset.mem_range\n\n@[simp] theorem range_zero : range 0 = \u2205 :=\n  rfl\n\n@[simp] theorem range_one : range 1 = singleton 0 :=\n  rfl\n\ntheorem range_succ {n : \u2115} : 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 : \u2115} : range (n + 1) = insert n (range n) :=\n  range_succ\n\n@[simp] theorem not_mem_range_self {n : \u2115} : \u00acn \u2208 range n :=\n  multiset.not_mem_range_self\n\n@[simp] theorem self_mem_range_succ (n : \u2115) : n \u2208 range (n + 1) :=\n  multiset.self_mem_range_succ n\n\n@[simp] theorem range_subset {n : \u2115} {m : \u2115} : range n \u2286 range m \u2194 n \u2264 m :=\n  multiset.range_subset\n\ntheorem range_mono : monotone range :=\n  fun (_x _x_1 : \u2115) => iff.mpr range_subset\n\ntheorem mem_range_succ_iff {a : \u2115} {b : \u2115} : a \u2208 range (Nat.succ b) \u2194 a \u2264 b :=\n  iff.trans mem_range nat.lt_succ_iff\n\n/- useful rules for calculations with quantifiers -/\n\ntheorem exists_mem_empty_iff {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) : (\u2203 (x : \u03b1), x \u2208 \u2205 \u2227 p x) \u2194 False := sorry\n\ntheorem exists_mem_insert {\u03b1 : Type u_1} [d : DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (p : \u03b1 \u2192 Prop) : (\u2203 (x : \u03b1), x \u2208 insert a s \u2227 p x) \u2194 p a \u2228 \u2203 (x : \u03b1), x \u2208 s \u2227 p x := sorry\n\ntheorem forall_mem_empty_iff {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) : (\u2200 (x : \u03b1), x \u2208 \u2205 \u2192 p x) \u2194 True :=\n  iff_true_intro fun (_x : \u03b1) => false.elim\n\ntheorem forall_mem_insert {\u03b1 : Type u_1} [d : DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (p : \u03b1 \u2192 Prop) : (\u2200 (x : \u03b1), x \u2208 insert a s \u2192 p x) \u2194 p a \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 p x := sorry\n\nend finset\n\n\n/-- Equivalence between the set of natural numbers which are `\u2265 k` and `\u2115`, given by `n \u2192 n - k`. -/\ndef not_mem_range_equiv (k : \u2115) : (Subtype fun (n : \u2115) => \u00acn \u2208 multiset.range k) \u2243 \u2115 :=\n  equiv.mk (fun (i : Subtype fun (n : \u2115) => \u00acn \u2208 multiset.range k) => subtype.val i - k)\n    (fun (j : \u2115) => { val := j + k, property := sorry }) sorry sorry\n\n@[simp] theorem coe_not_mem_range_equiv (k : \u2115) : \u21d1(not_mem_range_equiv k) = fun (i : Subtype fun (n : \u2115) => \u00acn \u2208 multiset.range k) => \u2191i - k :=\n  rfl\n\n@[simp] theorem coe_not_mem_range_equiv_symm (k : \u2115) : \u21d1(equiv.symm (not_mem_range_equiv k)) =\n  fun (j : \u2115) =>\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 \u2208 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 {\u03b1 : Type} (a : \u03b1) => 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 {\u03b1 : Type u_1} (o : Option \u03b1) : finset \u03b1 :=\n  sorry\n\n@[simp] theorem to_finset_none {\u03b1 : Type u_1} : to_finset none = \u2205 :=\n  rfl\n\n@[simp] theorem to_finset_some {\u03b1 : Type u_1} {a : \u03b1} : to_finset (some a) = singleton a :=\n  rfl\n\n@[simp] theorem mem_to_finset {\u03b1 : Type u_1} {a : \u03b1} {o : Option \u03b1} : a \u2208 to_finset o \u2194 a \u2208 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) : finset \u03b1 :=\n  finset.mk (erase_dup s) sorry\n\n@[simp] theorem to_finset_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) : finset.val (to_finset s) = erase_dup s :=\n  rfl\n\ntheorem to_finset_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : multiset \u03b1} (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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : multiset \u03b1} : a \u2208 to_finset s \u2194 a \u2208 s :=\n  mem_erase_dup\n\n@[simp] theorem to_finset_zero {\u03b1 : Type u_1} [DecidableEq \u03b1] : to_finset 0 = \u2205 :=\n  rfl\n\n@[simp] theorem to_finset_cons {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : multiset \u03b1) : to_finset (a ::\u2098 s) = insert a (to_finset s) :=\n  finset.eq_of_veq erase_dup_cons\n\n@[simp] theorem to_finset_add {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) (t : multiset \u03b1) : to_finset (s + t) = to_finset s \u222a to_finset t := sorry\n\n@[simp] theorem to_finset_nsmul {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) (n : \u2115) (hn : n \u2260 0) : to_finset (n \u2022\u2115 s) = to_finset s := sorry\n\n@[simp] theorem to_finset_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) (t : multiset \u03b1) : to_finset (s \u2229 t) = to_finset s \u2229 to_finset t := sorry\n\n@[simp] theorem to_finset_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) (t : multiset \u03b1) : to_finset (s \u222a t) = to_finset s \u222a to_finset t := sorry\n\ntheorem to_finset_eq_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] {m : multiset \u03b1} : to_finset m = \u2205 \u2194 m = 0 :=\n  iff.trans (iff.symm finset.val_inj) erase_dup_eq_zero\n\n@[simp] theorem to_finset_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (m1 : multiset \u03b1) (m2 : multiset \u03b1) : to_finset m1 \u2286 to_finset m2 \u2194 m1 \u2286 m2 := sorry\n\nend multiset\n\n\nnamespace finset\n\n\n@[simp] theorem val_to_finset {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (l : List \u03b1) : finset \u03b1 :=\n  multiset.to_finset \u2191l\n\n@[simp] theorem to_finset_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (l : List \u03b1) : finset.val (to_finset l) = \u2191(erase_dup l) :=\n  rfl\n\ntheorem to_finset_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] {l : List \u03b1} (n : nodup l) : finset.mk (\u2191l) n = to_finset l :=\n  multiset.to_finset_eq n\n\n@[simp] theorem mem_to_finset {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {l : List \u03b1} : a \u2208 to_finset l \u2194 a \u2208 l :=\n  mem_erase_dup\n\n@[simp] theorem to_finset_nil {\u03b1 : Type u_1} [DecidableEq \u03b1] : to_finset [] = \u2205 :=\n  rfl\n\n@[simp] theorem to_finset_cons {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {l : List \u03b1} : to_finset (a :: l) = insert a (to_finset l) := sorry\n\ntheorem to_finset_surj_on {\u03b1 : Type u_1} [DecidableEq \u03b1] : set.surj_on to_finset (set_of fun (l : List \u03b1) => nodup l) set.univ := sorry\n\ntheorem to_finset_surjective {\u03b1 : Type u_1} [DecidableEq \u03b1] : function.surjective to_finset := sorry\n\nend list\n\n\nnamespace finset\n\n\n/-! ### map -/\n\n/-- When `f` is an embedding of `\u03b1` in `\u03b2` and `s` is a finset in `\u03b1`, then `s.map f` is the image\nfinset in `\u03b2`. The embedding condition guarantees that there are no duplicates in the image. -/\ndef map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) : finset \u03b2 :=\n  mk (multiset.map (\u21d1f) (val s)) sorry\n\n@[simp] theorem map_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) : val (map f s) = multiset.map (\u21d1f) (val s) :=\n  rfl\n\n@[simp] theorem map_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) : map f \u2205 = \u2205 :=\n  rfl\n\n@[simp] theorem mem_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} {b : \u03b2} : b \u2208 map f s \u2194 \u2203 (a : \u03b1), \u2203 (H : a \u2208 s), coe_fn f a = b := sorry\n\ntheorem mem_map' {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) {a : \u03b1} {s : finset \u03b1} : coe_fn f a \u2208 map f s \u2194 a \u2208 s :=\n  multiset.mem_map_of_injective (function.embedding.inj' f)\n\ntheorem mem_map_of_mem {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) {a : \u03b1} {s : finset \u03b1} : a \u2208 s \u2192 coe_fn f a \u2208 map f s :=\n  iff.mpr (mem_map' f)\n\n@[simp] theorem coe_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) : \u2191(map f s) = \u21d1f '' \u2191s :=\n  set.ext fun (x : \u03b2) => iff.trans mem_map (iff.symm set.mem_image_iff_bex)\n\ntheorem coe_map_subset_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) : \u2191(map f s) \u2286 set.range \u21d1f :=\n  trans_rel_right has_subset.subset (coe_map f s) (set.image_subset_range \u21d1f \u2191s)\n\ntheorem map_to_finset {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} [DecidableEq \u03b1] [DecidableEq \u03b2] {s : multiset \u03b1} : map f (multiset.to_finset s) = multiset.to_finset (multiset.map (\u21d1f) s) := sorry\n\n@[simp] theorem map_refl {\u03b1 : Type u_1} {s : finset \u03b1} : map (function.embedding.refl \u03b1) s = s := sorry\n\ntheorem map_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} {g : \u03b2 \u21aa \u03b3} : map g (map f s) = map (function.embedding.trans f g) s := sorry\n\ntheorem map_subset_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : map f s\u2081 \u2286 map f s\u2082 \u2194 s\u2081 \u2286 s\u2082 := sorry\n\ntheorem map_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : map f s\u2081 = map f s\u2082 \u2194 s\u2081 = s\u2082 := sorry\n\n/-- Associate to an embedding `f` from `\u03b1` to `\u03b2` the embedding that maps a finset to its image\nunder `f`. -/\ndef map_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) : finset \u03b1 \u21aa finset \u03b2 :=\n  function.embedding.mk (map f) sorry\n\n@[simp] theorem map_embedding_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} : coe_fn (map_embedding f) s = map f s :=\n  rfl\n\ntheorem map_filter {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} {p : \u03b2 \u2192 Prop} [decidable_pred p] : filter p (map f s) = map f (filter (p \u2218 \u21d1f) s) := sorry\n\ntheorem map_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u21aa \u03b2} (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : map f (s\u2081 \u222a s\u2082) = map f s\u2081 \u222a map f s\u2082 := sorry\n\ntheorem map_inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u21aa \u03b2} (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : map f (s\u2081 \u2229 s\u2082) = map f s\u2081 \u2229 map f s\u2082 := sorry\n\n@[simp] theorem map_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (a : \u03b1) : map f (singleton a) = singleton (coe_fn f a) := sorry\n\n@[simp] theorem map_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] (f : \u03b1 \u21aa \u03b2) (a : \u03b1) (s : finset \u03b1) : map f (insert a s) = insert (coe_fn f a) (map f s) := sorry\n\n@[simp] theorem map_eq_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} : map f s = \u2205 \u2194 s = \u2205 := sorry\n\ntheorem attach_map_val {\u03b1 : Type u_1} {s : finset \u03b1} : map (function.embedding.subtype fun (x : \u03b1) => x \u2208 s) (attach s) = s := sorry\n\ntheorem nonempty.map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} (h : finset.nonempty s) (f : \u03b1 \u21aa \u03b2) : finset.nonempty (map f s) := sorry\n\ntheorem range_add_one' (n : \u2115) : range (n + 1) = insert 0 (map (function.embedding.mk (fun (i : \u2115) => i + 1) fun (i j : \u2115) => nat.succ.inj) (range n)) := sorry\n\n/-! ### image -/\n\n/-- `image f s` is the forward image of `s` under `f`. -/\ndef image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) : finset \u03b2 :=\n  multiset.to_finset (multiset.map f (val s))\n\n@[simp] theorem image_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) : val (image f s) = multiset.erase_dup (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem image_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) : image f \u2205 = \u2205 :=\n  rfl\n\n@[simp] theorem mem_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} {b : \u03b2} : b \u2208 image f s \u2194 \u2203 (a : \u03b1), \u2203 (H : a \u2208 s), f a = b := sorry\n\ntheorem mem_image_of_mem {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) : f a \u2208 image f s :=\n  iff.mpr mem_image (Exists.intro a (Exists.intro h rfl))\n\ntheorem filter_mem_image_eq_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) (t : finset \u03b2) (h : \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2208 t) : filter (fun (y : \u03b2) => y \u2208 image f s) t = image f s := sorry\n\ntheorem fiber_nonempty_iff_mem_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) (y : \u03b2) : finset.nonempty (filter (fun (x : \u03b1) => f x = y) s) \u2194 y \u2208 image f s := sorry\n\n@[simp] theorem coe_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} : \u2191(image f s) = f '' \u2191s :=\n  set.ext fun (_x : \u03b2) => iff.trans mem_image (iff.symm set.mem_image_iff_bex)\n\ntheorem nonempty.image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} (h : finset.nonempty s) (f : \u03b1 \u2192 \u03b2) : finset.nonempty (image f s) := sorry\n\ntheorem image_to_finset {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} [DecidableEq \u03b1] {s : multiset \u03b1} : image f (multiset.to_finset s) = multiset.to_finset (multiset.map f s) := sorry\n\ntheorem image_val_of_inj_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} (H : \u2200 (x : \u03b1), x \u2208 s \u2192 \u2200 (y : \u03b1), y \u2208 s \u2192 f x = f y \u2192 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 {\u03b1 : Type u_1} {s : finset \u03b1} [DecidableEq \u03b1] : image id s = s := sorry\n\ntheorem image_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} [DecidableEq \u03b3] {g : \u03b2 \u2192 \u03b3} : image g (image f s) = image (g \u2218 f) s := sorry\n\ntheorem image_subset_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : s\u2081 \u2286 s\u2082) : image f s\u2081 \u2286 image f s\u2082 := sorry\n\ntheorem image_subset_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {t : finset \u03b2} {f : \u03b1 \u2192 \u03b2} : image f s \u2286 t \u2194 \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2208 t := sorry\n\ntheorem image_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) : monotone (image f) :=\n  fun (_x _x_1 : finset \u03b1) => image_subset_image\n\ntheorem coe_image_subset_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} : \u2191(image f s) \u2286 set.range f :=\n  trans_rel_right has_subset.subset coe_image (set.image_subset_range f \u2191s)\n\ntheorem image_filter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} {p : \u03b2 \u2192 Prop} [decidable_pred p] : filter p (image f s) = image f (filter (p \u2218 f) s) := sorry\n\ntheorem image_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1] {f : \u03b1 \u2192 \u03b2} (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : image f (s\u2081 \u222a s\u2082) = image f s\u2081 \u222a image f s\u2082 := sorry\n\ntheorem image_inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (hf : \u2200 (x y : \u03b1), f x = f y \u2192 x = y) : image f (s\u2081 \u2229 s\u2082) = image f s\u2081 \u2229 image f s\u2082 := sorry\n\n@[simp] theorem image_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : image f (singleton a) = singleton (f a) := sorry\n\n@[simp] theorem image_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1] (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (s : finset \u03b1) : image f (insert a s) = insert (f a) (image f s) := sorry\n\n@[simp] theorem image_eq_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} : image f s = \u2205 \u2194 s = \u2205 := sorry\n\ntheorem attach_image_val {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} : image subtype.val (attach s) = s := sorry\n\n@[simp] theorem attach_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} : attach (insert a s) =\n  insert { val := a, property := mem_insert_self a s }\n    (image\n      (fun (x : Subtype fun (x : \u03b1) => x \u2208 s) =>\n        { val := subtype.val x, property := mem_insert_of_mem (subtype.property x) })\n      (attach s)) := sorry\n\ntheorem map_eq_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) : map f s = image (\u21d1f) s :=\n  eq_of_veq (Eq.symm (iff.mpr multiset.erase_dup_eq_self (nodup (map f s))))\n\ntheorem image_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} (h : finset.nonempty s) (b : \u03b2) : image (fun (a : \u03b1) => 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) \u2192 Decidable P] : Functor finset :=\n  { map := fun (\u03b1 \u03b2 : Type u_1) (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) => image f s,\n    mapConst := fun (\u03b1 \u03b2 : Type u_1) => (fun (f : \u03b2 \u2192 \u03b1) (s : finset \u03b2) => image f s) \u2218 function.const \u03b2 }\n\nprotected instance is_lawful_functor [(P : Prop) \u2192 Decidable P] : is_lawful_functor finset :=\n  is_lawful_functor.mk (fun (\u03b1 : Type u_1) (x : finset \u03b1) => image_id)\n    fun (\u03b1 \u03b2 \u03b3 : Type u_1) (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (s : finset \u03b1) => 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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) : finset (Subtype p) :=\n  map\n    (function.embedding.mk\n      (fun (x : Subtype fun (x : \u03b1) => x \u2208 filter p s) => { val := subtype.val x, property := sorry }) sorry)\n    (attach (filter p s))\n\n@[simp] theorem mem_subtype {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} {a : Subtype p} : a \u2208 finset.subtype p s \u2194 \u2191a \u2208 s := sorry\n\ntheorem subtype_eq_empty {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} : finset.subtype p s = \u2205 \u2194 \u2200 (x : \u03b1), p x \u2192 \u00acx \u2208 s := sorry\n\n/-- `s.subtype p` converts back to `s.filter p` with\n`embedding.subtype`. -/\n@[simp] theorem subtype_map {\u03b1 : Type u_1} {s : finset \u03b1} (p : \u03b1 \u2192 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 {\u03b1 : Type u_1} {s : finset \u03b1} {p : \u03b1 \u2192 Prop} [decidable_pred p] (h : \u2200 (x : \u03b1), x \u2208 s \u2192 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 {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} (s : finset (Subtype fun (x : \u03b1) => p x)) {a : \u03b1} (h : a \u2208 map (function.embedding.subtype fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} (s : finset (Subtype fun (x : \u03b1) => p x)) {a : \u03b1} (h : \u00acp a) : \u00aca \u2208 map (function.embedding.subtype fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {t : set \u03b1} (s : finset \u21a5t) : \u2191(map (function.embedding.subtype fun (x : \u03b1) => x \u2208 t) s) \u2286 t := sorry\n\ntheorem subset_image_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b2} {t : set \u03b1} : \u2191s \u2286 f '' t \u2194 \u2203 (s' : finset \u03b1), \u2191s' \u2286 t \u2227 image f s' = s := sorry\n\nend finset\n\n\ntheorem multiset.to_finset_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (m : multiset \u03b1) : 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 {\u03b1 : Type u_1} (s : finset \u03b1) : \u2115 :=\n  coe_fn multiset.card (val s)\n\ntheorem card_def {\u03b1 : Type u_1} (s : finset \u03b1) : card s = coe_fn multiset.card (val s) :=\n  rfl\n\n@[simp] theorem card_mk {\u03b1 : Type u_1} {m : multiset \u03b1} {nodup : multiset.nodup m} : card (mk m nodup) = coe_fn multiset.card m :=\n  rfl\n\n@[simp] theorem card_empty {\u03b1 : Type u_1} : card \u2205 = 0 :=\n  rfl\n\n@[simp] theorem card_eq_zero {\u03b1 : Type u_1} {s : finset \u03b1} : card s = 0 \u2194 s = \u2205 :=\n  iff.trans multiset.card_eq_zero val_eq_zero\n\ntheorem card_pos {\u03b1 : Type u_1} {s : finset \u03b1} : 0 < card s \u2194 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 {\u03b1 : Type u_1} {s : finset \u03b1} {a : \u03b1} (h : a \u2208 s) : card s \u2260 0 :=\n  iff.mpr (not_congr card_eq_zero) (ne_empty_of_mem h)\n\ntheorem card_eq_one {\u03b1 : Type u_1} {s : finset \u03b1} : card s = 1 \u2194 \u2203 (a : \u03b1), s = singleton a := sorry\n\n@[simp] theorem card_insert_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) : card (insert a s) = card s + 1 := sorry\n\ntheorem card_insert_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : card (insert a s) \u2264 card s + 1 := sorry\n\n@[simp] theorem card_singleton {\u03b1 : Type u_1} (a : \u03b1) : card (singleton a) = 1 :=\n  multiset.card_singleton a\n\ntheorem card_singleton_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {x : \u03b1} {s : finset \u03b1} : card (singleton x \u2229 s) \u2264 1 := sorry\n\ntheorem card_erase_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} : a \u2208 s \u2192 card (erase s a) = Nat.pred (card s) :=\n  multiset.card_erase_of_mem\n\ntheorem card_erase_lt_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} : a \u2208 s \u2192 card (erase s a) < card s :=\n  multiset.card_erase_lt_of_mem\n\ntheorem card_erase_le {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} : card (erase s a) \u2264 card s :=\n  multiset.card_erase_le\n\ntheorem pred_card_le_card_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} : card s - 1 \u2264 card (erase s a) := sorry\n\n@[simp] theorem card_range (n : \u2115) : card (range n) = n :=\n  multiset.card_range n\n\n@[simp] theorem card_attach {\u03b1 : Type u_1} {s : finset \u03b1} : card (attach s) = card s :=\n  multiset.card_attach\n\nend finset\n\n\ntheorem multiset.to_finset_card_le {\u03b1 : Type u_1} [DecidableEq \u03b1] (m : multiset \u03b1) : finset.card (multiset.to_finset m) \u2264 coe_fn multiset.card m :=\n  multiset.card_le_of_le (multiset.erase_dup_le m)\n\ntheorem list.to_finset_card_le {\u03b1 : Type u_1} [DecidableEq \u03b1] (l : List \u03b1) : finset.card (list.to_finset l) \u2264 list.length l :=\n  multiset.to_finset_card_le (quotient.mk l)\n\nnamespace finset\n\n\ntheorem card_image_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} : card (image f s) \u2264 card s := sorry\n\ntheorem card_image_of_inj_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} (H : \u2200 (x : \u03b1), x \u2208 s \u2192 \u2200 (y : \u03b1), y \u2208 s \u2192 f x = f y \u2192 x = y) : card (image f s) = card s := sorry\n\ntheorem card_image_of_injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} (s : finset \u03b1) (H : function.injective f) : card (image f s) = card s :=\n  card_image_of_inj_on fun (x : \u03b1) (_x : x \u2208 s) (y : \u03b1) (_x : y \u2208 s) (h : f x = f y) => H h\n\ntheorem fiber_card_ne_zero_iff_mem_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) [DecidableEq \u03b2] (y : \u03b2) : card (filter (fun (x : \u03b1) => f x = y) s) \u2260 0 \u2194 y \u2208 image f s := sorry\n\n@[simp] theorem card_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) {s : finset \u03b1} : card (map f s) = card s :=\n  multiset.card_map (\u21d1f) (val s)\n\n@[simp] theorem card_subtype {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) : card (finset.subtype p s) = card (filter p s) := sorry\n\ntheorem card_eq_of_bijective {\u03b1 : Type u_1} {s : finset \u03b1} {n : \u2115} (f : (i : \u2115) \u2192 i < n \u2192 \u03b1) (hf : \u2200 (a : \u03b1), a \u2208 s \u2192 \u2203 (i : \u2115), \u2203 (h : i < n), f i h = a) (hf' : \u2200 (i : \u2115) (h : i < n), f i h \u2208 s) (f_inj : \u2200 (i j : \u2115) (hi : i < n) (hj : j < n), f i hi = f j hj \u2192 i = j) : card s = n := sorry\n\ntheorem card_eq_succ {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {n : \u2115} : card s = n + 1 \u2194 \u2203 (a : \u03b1), \u2203 (t : finset \u03b1), \u00aca \u2208 t \u2227 insert a t = s \u2227 card t = n := sorry\n\ntheorem card_le_of_subset {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} : s \u2286 t \u2192 card s \u2264 card t :=\n  multiset.card_le_of_le \u2218 iff.mpr val_le_iff\n\ntheorem eq_of_subset_of_card_le {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} (h : s \u2286 t) (h\u2082 : card t \u2264 card s) : s = t :=\n  eq_of_veq (multiset.eq_of_le_of_card_le (iff.mpr val_le_iff h) h\u2082)\n\ntheorem card_lt_card {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} (h : s \u2282 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} (f : \u03b1 \u2192 \u03b2) (hf : \u2200 (a : \u03b1), a \u2208 s \u2192 f a \u2208 t) (f_inj : \u2200 (a\u2081 : \u03b1), a\u2081 \u2208 s \u2192 \u2200 (a\u2082 : \u03b1), a\u2082 \u2208 s \u2192 f a\u2081 = f a\u2082 \u2192 a\u2081 = a\u2082) : card s \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} (hc : card t < card s) {f : \u03b1 \u2192 \u03b2} (hf : \u2200 (a : \u03b1), a \u2208 s \u2192 f a \u2208 t) : \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), \u2203 (y : \u03b1), \u2203 (H : y \u2208 s), x \u2260 y \u2227 f x = f y := sorry\n\ntheorem card_le_of_inj_on {\u03b1 : Type u_1} {n : \u2115} {s : finset \u03b1} (f : \u2115 \u2192 \u03b1) (hf : \u2200 (i : \u2115), i < n \u2192 f i \u2208 s) (f_inj : \u2200 (i j : \u2115), i < n \u2192 j < n \u2192 f i = f j \u2192 i = j) : n \u2264 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 {\u03b1 : Type u_1} {p : finset \u03b1 \u2192 Sort u_2} (s : finset \u03b1) : ((s : finset \u03b1) \u2192 ((t : finset \u03b1) \u2192 t \u2282 s \u2192 p t) \u2192 p s) \u2192 p s :=\n  sorry\n\ntheorem case_strong_induction_on {\u03b1 : Type u_1} [DecidableEq \u03b1] {p : finset \u03b1 \u2192 Prop} (s : finset \u03b1) (h\u2080 : p \u2205) (h\u2081 : \u2200 (a : \u03b1) (s : finset \u03b1), \u00aca \u2208 s \u2192 (\u2200 (t : finset \u03b1), t \u2286 s \u2192 p t) \u2192 p (insert a s)) : p s := sorry\n\ntheorem card_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} (f : (a : \u03b1) \u2192 a \u2208 s \u2192 \u03b2) (h\u2081 : \u2200 (a : \u03b1) (ha : a \u2208 s), f a ha \u2208 t) (h\u2082 : \u2200 (a b : \u03b1) (ha : a \u2208 s) (hb : b \u2208 s), f a ha = f b hb \u2192 a = b) (h\u2083 : \u2200 (b : \u03b2), b \u2208 t \u2192 \u2203 (a : \u03b1), \u2203 (ha : a \u2208 s), f a ha = b) : card s = card t := sorry\n\ntheorem card_union_add_card_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : card (s \u222a t) + card (s \u2229 t) = card s + card t := sorry\n\ntheorem card_union_le {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : card (s \u222a t) \u2264 card s + card t :=\n  card_union_add_card_inter s t \u25b8 nat.le_add_right (card (s \u222a t)) (card (s \u2229 t))\n\ntheorem card_union_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} (h : disjoint s t) : card (s \u222a t) = card s + card t := sorry\n\ntheorem surj_on_of_inj_on_of_card_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} (f : (a : \u03b1) \u2192 a \u2208 s \u2192 \u03b2) (hf : \u2200 (a : \u03b1) (ha : a \u2208 s), f a ha \u2208 t) (hinj : \u2200 (a\u2081 a\u2082 : \u03b1) (ha\u2081 : a\u2081 \u2208 s) (ha\u2082 : a\u2082 \u2208 s), f a\u2081 ha\u2081 = f a\u2082 ha\u2082 \u2192 a\u2081 = a\u2082) (hst : card t \u2264 card s) (b : \u03b2) (H : b \u2208 t) : \u2203 (a : \u03b1), \u2203 (ha : a \u2208 s), b = f a ha := sorry\n\ntheorem inj_on_of_surj_on_of_card_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} (f : (a : \u03b1) \u2192 a \u2208 s \u2192 \u03b2) (hf : \u2200 (a : \u03b1) (ha : a \u2208 s), f a ha \u2208 t) (hsurj : \u2200 (b : \u03b2), b \u2208 t \u2192 \u2203 (a : \u03b1), \u2203 (ha : a \u2208 s), b = f a ha) (hst : card s \u2264 card t) {a\u2081 : \u03b1} {a\u2082 : \u03b1} (ha\u2081 : a\u2081 \u2208 s) (ha\u2082 : a\u2082 \u2208 s) (ha\u2081a\u2082 : f a\u2081 ha\u2081 = f a\u2082 ha\u2082) : a\u2081 = a\u2082 := sorry\n\n/-!\n### bUnion\n\nThis section is about the bounded union of an indexed family `t : \u03b1 \u2192 finset \u03b2` of finite sets\nover a finite set `s : finset \u03b1`.\n-/\n\n/-- `bUnion s t` is the union of `t x` over `x \u2208 s`.\n(This was formerly `bind` due to the monad structure on types with `decidable_eq`.) -/\nprotected def bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b1) (t : \u03b1 \u2192 finset \u03b2) : finset \u03b2 :=\n  multiset.to_finset (multiset.bind (val s) fun (a : \u03b1) => val (t a))\n\n@[simp] theorem bUnion_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b1) (t : \u03b1 \u2192 finset \u03b2) : val (finset.bUnion s t) = multiset.erase_dup (multiset.bind (val s) fun (a : \u03b1) => val (t a)) :=\n  rfl\n\n@[simp] theorem bUnion_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {t : \u03b1 \u2192 finset \u03b2} : finset.bUnion \u2205 t = \u2205 :=\n  rfl\n\n@[simp] theorem mem_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {t : \u03b1 \u2192 finset \u03b2} {b : \u03b2} : b \u2208 finset.bUnion s t \u2194 \u2203 (a : \u03b1), \u2203 (H : a \u2208 s), b \u2208 t a := sorry\n\n@[simp] theorem bUnion_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {t : \u03b1 \u2192 finset \u03b2} [DecidableEq \u03b1] {a : \u03b1} : finset.bUnion (insert a s) t = t a \u222a finset.bUnion s t := sorry\n\n-- ext $ \u03bb x, by simp [or_and_distrib_right, exists_or_distrib]\n\n@[simp] theorem singleton_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {t : \u03b1 \u2192 finset \u03b2} {a : \u03b1} : finset.bUnion (singleton a) t = t a := sorry\n\ntheorem bUnion_inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b1) (f : \u03b1 \u2192 finset \u03b2) (t : finset \u03b2) : finset.bUnion s f \u2229 t = finset.bUnion s fun (x : \u03b1) => f x \u2229 t := sorry\n\ntheorem inter_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (t : finset \u03b2) (s : finset \u03b1) (f : \u03b1 \u2192 finset \u03b2) : t \u2229 finset.bUnion s f = finset.bUnion s fun (x : \u03b1) => t \u2229 f x := sorry\n\ntheorem image_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [DecidableEq \u03b2] [DecidableEq \u03b3] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} {t : \u03b2 \u2192 finset \u03b3} : finset.bUnion (image f s) t = finset.bUnion s fun (a : \u03b1) => t (f a) := sorry\n\ntheorem bUnion_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [DecidableEq \u03b2] [DecidableEq \u03b3] {s : finset \u03b1} {t : \u03b1 \u2192 finset \u03b2} {f : \u03b2 \u2192 \u03b3} : image f (finset.bUnion s t) = finset.bUnion s fun (a : \u03b1) => image f (t a) := sorry\n\ntheorem bind_to_finset {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1] (s : multiset \u03b1) (t : \u03b1 \u2192 multiset \u03b2) : multiset.to_finset (multiset.bind s t) = finset.bUnion (multiset.to_finset s) fun (a : \u03b1) => multiset.to_finset (t a) := sorry\n\ntheorem bUnion_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {t\u2081 : \u03b1 \u2192 finset \u03b2} {t\u2082 : \u03b1 \u2192 finset \u03b2} (h : \u2200 (a : \u03b1), a \u2208 s \u2192 t\u2081 a \u2286 t\u2082 a) : finset.bUnion s t\u2081 \u2286 finset.bUnion s t\u2082 := sorry\n\ntheorem bUnion_subset_bUnion_of_subset_left {\u03b2 : Type u_2} [DecidableEq \u03b2] {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (t : \u03b1 \u2192 finset \u03b2) (h : s\u2081 \u2286 s\u2082) : finset.bUnion s\u2081 t \u2286 finset.bUnion s\u2082 t := sorry\n\ntheorem bUnion_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} : (finset.bUnion s fun (a : \u03b1) => singleton (f a)) = image f s := sorry\n\n@[simp] theorem bUnion_singleton_eq_self {\u03b1 : Type u_1} {s : finset \u03b1} [DecidableEq \u03b1] : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b2} {f : \u03b1 \u2192 \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2208 t) : (finset.bUnion t fun (a : \u03b2) => filter (fun (c : \u03b1) => f c = a) s) = s := sorry\n\ntheorem image_bUnion_filter_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1] (s : finset \u03b2) (g : \u03b2 \u2192 \u03b1) : (finset.bUnion (image g s) fun (a : \u03b1) => filter (fun (c : \u03b2) => g c = a) s) = s :=\n  bUnion_filter_eq_of_maps_to fun (x : \u03b2) => mem_image_of_mem g\n\n/-! ### prod -/\n\n/-- `product s t` is the set of pairs `(a, b)` such that `a \u2208 s` and `b \u2208 t`. -/\nprotected def product {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : finset \u03b1) (t : finset \u03b2) : finset (\u03b1 \u00d7 \u03b2) :=\n  mk (multiset.product (val s) (val t)) sorry\n\n@[simp] theorem product_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} : val (finset.product s t) = multiset.product (val s) (val t) :=\n  rfl\n\n@[simp] theorem mem_product {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} {p : \u03b1 \u00d7 \u03b2} : p \u2208 finset.product s t \u2194 prod.fst p \u2208 s \u2227 prod.snd p \u2208 t :=\n  multiset.mem_product\n\ntheorem subset_product {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] {s : finset (\u03b1 \u00d7 \u03b2)} : s \u2286 finset.product (image prod.fst s) (image prod.snd s) :=\n  fun (p : \u03b1 \u00d7 \u03b2) (hp : p \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] (s : finset \u03b1) (t : finset \u03b2) : finset.product s t = finset.bUnion s fun (a : \u03b1) => image (fun (b : \u03b2) => (a, b)) t := sorry\n\n@[simp] theorem card_product {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : finset \u03b1) (t : finset \u03b2) : card (finset.product s t) = card s * card t :=\n  multiset.card_product (val s) (val t)\n\ntheorem filter_product {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) [decidable_pred p] [decidable_pred q] : filter (fun (x : \u03b1 \u00d7 \u03b2) => p (prod.fst x) \u2227 q (prod.snd x)) (finset.product s t) =\n  finset.product (filter p s) (filter q t) := sorry\n\ntheorem filter_product_card {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : finset \u03b1) (t : finset \u03b2) (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) [decidable_pred p] [decidable_pred q] : card (filter (fun (x : \u03b1 \u00d7 \u03b2) => p (prod.fst x) \u2194 q (prod.snd x)) (finset.product s t)) =\n  card (filter p s) * card (filter q t) + card (filter (Not \u2218 p) s) * card (filter (Not \u2218 q) t) := sorry\n\n/-! ### sigma -/\n\n/-- `sigma s t` is the set of dependent pairs `\u27e8a, b\u27e9` such that `a \u2208 s` and `b \u2208 t a`. -/\nprotected def sigma {\u03b1 : Type u_1} {\u03c3 : \u03b1 \u2192 Type u_4} (s : finset \u03b1) (t : (a : \u03b1) \u2192 finset (\u03c3 a)) : finset (sigma fun (a : \u03b1) => \u03c3 a) :=\n  mk (multiset.sigma (val s) fun (a : \u03b1) => val (t a)) sorry\n\n@[simp] theorem mem_sigma {\u03b1 : Type u_1} {\u03c3 : \u03b1 \u2192 Type u_4} {s : finset \u03b1} {t : (a : \u03b1) \u2192 finset (\u03c3 a)} {p : sigma \u03c3} : p \u2208 finset.sigma s t \u2194 sigma.fst p \u2208 s \u2227 sigma.snd p \u2208 t (sigma.fst p) :=\n  multiset.mem_sigma\n\ntheorem sigma_mono {\u03b1 : Type u_1} {\u03c3 : \u03b1 \u2192 Type u_4} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {t\u2081 : (a : \u03b1) \u2192 finset (\u03c3 a)} {t\u2082 : (a : \u03b1) \u2192 finset (\u03c3 a)} (H1 : s\u2081 \u2286 s\u2082) (H2 : \u2200 (a : \u03b1), t\u2081 a \u2286 t\u2082 a) : finset.sigma s\u2081 t\u2081 \u2286 finset.sigma s\u2082 t\u2082 := sorry\n\ntheorem sigma_eq_bUnion {\u03b1 : Type u_1} {\u03c3 : \u03b1 \u2192 Type u_4} [DecidableEq (sigma fun (a : \u03b1) => \u03c3 a)] (s : finset \u03b1) (t : (a : \u03b1) \u2192 finset (\u03c3 a)) : finset.sigma s t = finset.bUnion s fun (a : \u03b1) => map (function.embedding.sigma_mk a) (t a) := sorry\n\n/-! ### disjoint -/\n\ntheorem disjoint_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 s \u2192 \u00aca \u2208 t := sorry\n\ntheorem disjoint_val {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : disjoint s t \u2194 multiset.disjoint (val s) (val t) :=\n  disjoint_left\n\ntheorem disjoint_iff_inter_eq_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : disjoint s t \u2194 s \u2229 t = \u2205 :=\n  disjoint_iff\n\nprotected instance decidable_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] (U : finset \u03b1) (V : finset \u03b1) : Decidable (disjoint U V) :=\n  decidable_of_decidable_of_iff (finset.has_decidable_eq (U \u2293 V) \u22a5) sorry\n\ntheorem disjoint_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)) (propext disjoint.comm)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (disjoint t s \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)) (propext disjoint_left)))\n      (iff.refl (\u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)))\n\ntheorem disjoint_iff_ne {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : disjoint s t \u2194 \u2200 (a : \u03b1), a \u2208 s \u2192 \u2200 (b : \u03b1), b \u2208 t \u2192 a \u2260 b := sorry\n\ntheorem disjoint_of_subset_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} {u : finset \u03b1} (h : s \u2286 u) (d : disjoint u t) : disjoint s t :=\n  iff.mpr disjoint_left fun (x : \u03b1) (m\u2081 : x \u2208 s) => iff.mp disjoint_left d x (h m\u2081)\n\ntheorem disjoint_of_subset_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} {u : finset \u03b1} (h : t \u2286 u) (d : disjoint s u) : disjoint s t :=\n  iff.mpr disjoint_right fun (x : \u03b1) (m\u2081 : x \u2208 t) => iff.mp disjoint_right d x (h m\u2081)\n\n@[simp] theorem disjoint_empty_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : disjoint \u2205 s :=\n  disjoint_bot_left\n\n@[simp] theorem disjoint_empty_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : disjoint s \u2205 :=\n  disjoint_bot_right\n\n@[simp] theorem singleton_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {a : \u03b1} : disjoint (singleton a) s \u2194 \u00aca \u2208 s := sorry\n\n@[simp] theorem disjoint_singleton {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {a : \u03b1} : disjoint s (singleton a) \u2194 \u00aca \u2208 s :=\n  iff.trans disjoint.comm singleton_disjoint\n\n@[simp] theorem disjoint_insert_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} {t : finset \u03b1} : disjoint (insert a s) t \u2194 \u00aca \u2208 t \u2227 disjoint s t := sorry\n\n@[simp] theorem disjoint_insert_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} {t : finset \u03b1} : disjoint s (insert a t) \u2194 \u00aca \u2208 s \u2227 disjoint s t := sorry\n\n@[simp] theorem disjoint_union_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} {u : finset \u03b1} : disjoint (s \u222a t) u \u2194 disjoint s u \u2227 disjoint t u := sorry\n\n@[simp] theorem disjoint_union_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} {u : finset \u03b1} : disjoint s (t \u222a u) \u2194 disjoint s t \u2227 disjoint s u := sorry\n\ntheorem sdiff_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : disjoint (t \\ s) s :=\n  iff.mpr disjoint_left fun (a : \u03b1) (ha : a \u2208 t \\ s) => and.right (iff.mp mem_sdiff ha)\n\ntheorem disjoint_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : disjoint s (t \\ s) :=\n  disjoint.symm sdiff_disjoint\n\ntheorem disjoint_sdiff_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) : disjoint (s \\ t) (s \u2229 t) :=\n  disjoint_of_subset_right (inter_subset_right s t) sdiff_disjoint\n\ntheorem sdiff_eq_self_iff_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} : s \\ t = s \u2194 disjoint s t := sorry\n\ntheorem sdiff_eq_self_of_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} (h : disjoint s t) : s \\ t = s :=\n  iff.mpr sdiff_eq_self_iff_disjoint h\n\ntheorem disjoint_self_iff_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : disjoint s s \u2194 s = \u2205 :=\n  disjoint_self\n\ntheorem disjoint_bUnion_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {\u03b9 : Type u_2} (s : finset \u03b9) (f : \u03b9 \u2192 finset \u03b1) (t : finset \u03b1) : disjoint (finset.bUnion s f) t \u2194 \u2200 (i : \u03b9), i \u2208 s \u2192 disjoint (f i) t := sorry\n\ntheorem disjoint_bUnion_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {\u03b9 : Type u_2} (s : finset \u03b1) (t : finset \u03b9) (f : \u03b9 \u2192 finset \u03b1) : disjoint s (finset.bUnion t f) \u2194 \u2200 (i : \u03b9), i \u2208 t \u2192 disjoint s (f i) := sorry\n\n@[simp] theorem card_disjoint_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} (h : disjoint s t) : card (s \u222a t) = card s + card t := sorry\n\ntheorem card_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} (h : s \u2286 t) : card (t \\ s) = card t - card s := sorry\n\ntheorem disjoint_filter {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q] : disjoint (filter p s) (filter q s) \u2194 \u2200 (x : \u03b1), x \u2208 s \u2192 p x \u2192 \u00acq x := sorry\n\ntheorem disjoint_filter_filter {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q] : disjoint s t \u2192 disjoint (filter p s) (filter q t) :=\n  disjoint.mono (filter_subset p s) (filter_subset q t)\n\ntheorem disjoint_iff_disjoint_coe {\u03b1 : Type u_1} {a : finset \u03b1} {b : finset \u03b1} [DecidableEq \u03b1] : disjoint a b \u2194 disjoint \u2191a \u2191b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint a b \u2194 disjoint \u2191a \u2191b)) (propext disjoint_left)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((\u2200 {a_1 : \u03b1}, a_1 \u2208 a \u2192 \u00aca_1 \u2208 b) \u2194 disjoint \u2191a \u2191b)) (propext set.disjoint_left)))\n      (iff.refl (\u2200 {a_1 : \u03b1}, a_1 \u2208 a \u2192 \u00aca_1 \u2208 b)))\n\ntheorem filter_card_add_filter_neg_card_eq_card {\u03b1 : Type u_1} {s : finset \u03b1} (p : \u03b1 \u2192 Prop) [decidable_pred p] : card (filter p s) + card (filter (Not \u2218 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 \u2208 s`. -/\ndef diag {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] : finset (\u03b1 \u00d7 \u03b1) :=\n  filter (fun (a : \u03b1 \u00d7 \u03b1) => 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 \u2260 b`\nfor `a, b \u2208 s`. -/\ndef off_diag {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] : finset (\u03b1 \u00d7 \u03b1) :=\n  filter (fun (a : \u03b1 \u00d7 \u03b1) => prod.fst a \u2260 prod.snd a) (finset.product s s)\n\n@[simp] theorem mem_diag {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] (x : \u03b1 \u00d7 \u03b1) : x \u2208 diag s \u2194 prod.fst x \u2208 s \u2227 prod.fst x = prod.snd x := sorry\n\n@[simp] theorem mem_off_diag {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] (x : \u03b1 \u00d7 \u03b1) : x \u2208 off_diag s \u2194 prod.fst x \u2208 s \u2227 prod.snd x \u2208 s \u2227 prod.fst x \u2260 prod.snd x := sorry\n\n@[simp] theorem diag_card {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] : card (diag s) = card s := sorry\n\n@[simp] theorem off_diag_card {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] : 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 {\u03b1 : Type u_1} {A : finset \u03b1} {B : finset \u03b1} (i : \u2115) (h\u2081 : i + card B \u2264 card A) (h\u2082 : B \u2286 A) : \u2203 (C : finset \u03b1), B \u2286 C \u2227 C \u2286 A \u2227 card C = i + card B := sorry\n\n/-- We can shrink A to any smaller size. -/\ntheorem exists_smaller_set {\u03b1 : Type u_1} (A : finset \u03b1) (i : \u2115) (h\u2081 : i \u2264 card A) : \u2203 (B : finset \u03b1), B \u2286 A \u2227 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 : \u2115) : finset (fin k) :=\n  mk (\u2191(list.fin_range k)) (list.nodup_fin_range k)\n\n@[simp] theorem fin_range_card {k : \u2115} : card (fin_range k) = k := sorry\n\n@[simp] theorem mem_fin_range {k : \u2115} (m : fin k) : m \u2208 fin_range k :=\n  list.mem_fin_range m\n\n@[simp] theorem coe_fin_range (k : \u2115) : \u2191(fin_range k) = set.univ :=\n  set.eq_univ_of_forall mem_fin_range\n\n/-- Given a finset `s` of `\u2115` 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 \u2115) {n : \u2115} (h : \u2200 (m : \u2115), m \u2208 s \u2192 m < n) : finset (fin n) :=\n  mk (multiset.pmap (fun (a : \u2115) (ha : a < n) => { val := a, property := ha }) (val s) h) sorry\n\n@[simp] theorem mem_attach_fin {n : \u2115} {s : finset \u2115} (h : \u2200 (m : \u2115), m \u2208 s \u2192 m < n) {a : fin n} : a \u2208 attach_fin s h \u2194 \u2191a \u2208 s := sorry\n\n@[simp] theorem card_attach_fin {n : \u2115} (s : finset \u2115) (h : \u2200 (m : \u2115), m \u2208 s \u2192 m < n) : card (attach_fin s h) = card s :=\n  multiset.card_pmap (fun (a : \u2115) (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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1) (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : Subtype fun (a : \u03b1) => a \u2208 l \u2227 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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1) (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : \u03b1 :=\n  \u2191(choose_x p l hp)\n\ntheorem choose_spec {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1) (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : choose p l hp \u2208 l \u2227 p (choose p l hp) :=\n  subtype.property (choose_x p l hp)\n\ntheorem choose_mem {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1) (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : choose p l hp \u2208 l :=\n  and.left (choose_spec p l hp)\n\ntheorem choose_property {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1) (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : p (choose p l hp) :=\n  and.right (choose_spec p l hp)\n\ntheorem lt_wf {\u03b1 : 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 \u03b1) (hxy : x < y) => card_lt_card hxy\n\nend finset\n\n\nnamespace equiv\n\n\n/-- Given an equivalence `\u03b1` to `\u03b2`, produce an equivalence between `finset \u03b1` and `finset \u03b2`. -/\nprotected def finset_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) : finset \u03b1 \u2243 finset \u03b2 :=\n  mk (fun (s : finset \u03b1) => finset.map (equiv.to_embedding e) s)\n    (fun (s : finset \u03b2) => finset.map (equiv.to_embedding (equiv.symm e)) s) sorry sorry\n\n@[simp] theorem finset_congr_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (s : finset \u03b1) : coe_fn (equiv.finset_congr e) s = finset.map (equiv.to_embedding e) s :=\n  rfl\n\n@[simp] theorem finset_congr_symm_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (s : finset \u03b2) : 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {l : List \u03b1} (h : nodup l) : finset.card (to_finset l) = length l :=\n  congr_arg (\u21d1multiset.card) (iff.mpr multiset.erase_dup_eq_self h)\n\nend list\n\n\nnamespace multiset\n\n\ntheorem to_finset_card_of_nodup {\u03b1 : Type u_1} [DecidableEq \u03b1] {l : multiset \u03b1} (h : nodup l) : finset.card (to_finset l) = coe_fn card l :=\n  congr_arg (\u21d1card) (iff.mpr erase_dup_eq_self h)\n\ntheorem disjoint_to_finset {\u03b1 : Type u_1} [DecidableEq \u03b1] (m1 : multiset \u03b1) (m2 : multiset \u03b1) : disjoint (to_finset m1) (to_finset m2) \u2194 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 \u2192 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 \u2102)`\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 \u2192 Type v) : X.Presheaf (Type v)\n    where\n  obj U := \u2200 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\u27e8x, hx\u27e9)\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 \u2192 Type v} {U : (Opens X)\u1d52\u1d56} :\n    (presheafToTypes X T).obj U = \u2200 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 \u2192 Type v} {U V : (Opens X)\u1d52\u1d56} {i : U \u27f6 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 \u2192 T\n  map U V i g := g \u2218 i.unop\n  map_id' U := by\n    ext (g\u27e8x, hx\u27e9)\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)\u1d52\u1d56} :\n    (presheafToType X T).obj U = (unop U \u2192 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)\u1d52\u1d56} {i : U \u27f6 V} {f} :\n    (presheafToType X T).map i f = f \u2218 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 \u22d9 yoneda.obj T\n#align Top.presheaf_to_Top TopCat.presheafToTop\n\n@[simp]\ntheorem presheafToTop_obj (T : TopCat.{v}) (U : (Opens X)\u1d52\u1d56) :\n    (presheafToTop X T).obj U = ((Opens.toTop X).obj (unop U) \u27f6 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}\u1d52\u1d56) (R : TopCommRing.{v}) : CommRingCat.{v} :=\n  CommRingCat.of (unop X \u27f6 (forget\u2082 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\u1d52\u1d56} (f : X \u27f6 Y) (R : TopCommRing) :\n    continuousFunctions X R \u27f6 continuousFunctions Y R\n    where\n  toFun g := f.unop \u226b 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}\u1d52\u1d56) {R S : TopCommRing.{u}} (\u03c6 : R \u27f6 S) :\n    continuousFunctions X R \u27f6 continuousFunctions X S\n    where\n  toFun g := g \u226b (forget\u2082 TopCommRing TopCat).map \u03c6\n  map_one' := by ext <;> exact \u03c6.1.map_one\n  map_zero' := by ext <;> exact \u03c6.1.map_zero\n  map_add' := by intros <;> ext <;> apply \u03c6.1.map_add\n  map_mul' := by intros <;> ext <;> apply \u03c6.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} \u2964 TopCat.{u}\u1d52\u1d56 \u2964 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 \u03c6 :=\n    { app := fun X => continuousFunctions.map X \u03c6\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 \u2286 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 \u2102)\n```\n(this requires `import topology.instances.complex`).\n-/\ndef presheafToTopCommRing (T : TopCommRing.{v}) : X.Presheaf CommRingCat.{v} :=\n  (Opens.toTop X).op \u22d9 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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 X)\n  (k : W \u27f6 Y) (H\u2081 : is_terminal Z)\n  (H\u2082 : is_limit (pullback_cone.mk _ _ (show h \u226b f = k \u226b g, from H\u2081.hom_ext _ _))) :\n  is_limit (binary_fan.mk h k) :=\n{ lift := \u03bb c, H\u2082.lift (pullback_cone.mk\n    (c.\u03c0.app walking_pair.left) (c.\u03c0.app walking_pair.right) (H\u2081.hom_ext _ _)),\n  fac' := \u03bb c j,\n  begin\n    convert H\u2082.fac (pullback_cone.mk\n      (c.\u03c0.app walking_pair.left) (c.\u03c0.app walking_pair.right) (H\u2081.hom_ext _ _)) (some j) using 1,\n    cases j; refl\n  end,\n  uniq' := \u03bb c m hm,\n  begin\n    apply pullback_cone.is_limit.hom_ext H\u2082,\n    { exact (hm walking_pair.left).trans (H\u2082.fac (pullback_cone.mk (c.\u03c0.app walking_pair.left)\n        (c.\u03c0.app walking_pair.right) (H\u2081.hom_ext _ _)) walking_cospan.left).symm },\n    { exact (hm walking_pair.right).trans (H\u2082.fac (pullback_cone.mk (c.\u03c0.app walking_pair.left)\n        (c.\u03c0.app walking_pair.right) (H\u2081.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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 X)\n  (k : W \u27f6 Y) (H\u2081 : is_terminal Z)\n  (H\u2082 : is_limit (binary_fan.mk h k)) :\n  is_limit (pullback_cone.mk _ _ (show h \u226b f = k \u226b g, from H\u2081.hom_ext _ _)) :=\nbegin\n  apply pullback_cone.is_limit_aux',\n  intro s,\n  use H\u2082.lift (binary_fan.mk s.fst s.snd),\n  use H\u2082.fac (binary_fan.mk s.fst s.snd) walking_pair.left,\n  use H\u2082.fac (binary_fan.mk s.fst s.snd) walking_pair.right,\n  intros m h\u2081 h\u2082,\n  apply H\u2082.hom_ext,\n  rintro \u27e8\u27e9,\n  { exact h\u2081.trans (H\u2082.fac (binary_fan.mk s.fst s.snd) walking_pair.left).symm },\n  { exact h\u2082.trans (H\u2082.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 := \u03bb 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      \u03c0 := discrete.nat_trans (\u03bb x, walking_pair.cases_on x pullback.fst pullback.snd)},\n    is_limit :=\n    { lift := \u03bb c, pullback.lift ((c.\u03c0).app walking_pair.left)\n                                  ((c.\u03c0).app walking_pair.right)\n                                  (subsingleton.elim _ _),\n      fac' := \u03bb s c, walking_pair.cases_on c (limit.lift_\u03c0 _ _) (limit.lift_\u03c0 _ _),\n      uniq' := \u03bb s m J,\n                begin\n                  rw [\u2190J, \u2190J],\n                  ext;\n                  rw limit.lift_\u03c0;\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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 X)\n  (k : W \u27f6 Y) (H\u2081 : is_initial W)\n  (H\u2082 : is_colimit (pushout_cocone.mk _ _ (show h \u226b f = k \u226b g, from H\u2081.hom_ext _ _))) :\n  is_colimit (binary_cofan.mk f g) :=\n{ desc := \u03bb c, H\u2082.desc (pushout_cocone.mk\n    (c.\u03b9.app walking_pair.left) (c.\u03b9.app walking_pair.right) (H\u2081.hom_ext _ _)),\n  fac' := \u03bb c j,\n  begin\n    convert H\u2082.fac (pushout_cocone.mk\n      (c.\u03b9.app walking_pair.left) (c.\u03b9.app walking_pair.right) (H\u2081.hom_ext _ _)) (some j) using 1,\n    cases j; refl\n  end,\n  uniq' := \u03bb c m hm,\n  begin\n    apply pushout_cocone.is_colimit.hom_ext H\u2082,\n    { exact (hm walking_pair.left).trans (H\u2082.fac (pushout_cocone.mk (c.\u03b9.app walking_pair.left)\n        (c.\u03b9.app walking_pair.right) (H\u2081.hom_ext _ _)) walking_cospan.left).symm },\n    { exact (hm walking_pair.right).trans (H\u2082.fac (pushout_cocone.mk (c.\u03b9.app walking_pair.left)\n        (c.\u03b9.app walking_pair.right) (H\u2081.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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 X)\n  (k : W \u27f6 Y) (H\u2081 : is_terminal Z)\n  (H\u2082 : is_limit (binary_fan.mk h k)) :\n  is_limit (pullback_cone.mk _ _ (show h \u226b f = k \u226b g, from H\u2081.hom_ext _ _)) :=\nbegin\n  apply pullback_cone.is_limit_aux',\n  intro s,\n  use H\u2082.lift (binary_fan.mk s.fst s.snd),\n  use H\u2082.fac (binary_fan.mk s.fst s.snd) walking_pair.left,\n  use H\u2082.fac (binary_fan.mk s.fst s.snd) walking_pair.right,\n  intros m h\u2081 h\u2082,\n  apply H\u2082.hom_ext,\n  rintro \u27e8\u27e9,\n  { exact h\u2081.trans (H\u2082.fac (binary_fan.mk s.fst s.snd) walking_pair.left).symm },\n  { exact h\u2082.trans (H\u2082.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 := \u03bb 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      \u03b9 := discrete.nat_trans (\u03bb x, walking_pair.cases_on x pushout.inl pushout.inr)},\n    is_colimit :=\n    { desc := \u03bb c, pushout.desc (c.\u03b9.app walking_pair.left)\n                                (c.\u03b9.app walking_pair.right)\n                                (subsingleton.elim _ _),\n      fac' := \u03bb s c, walking_pair.cases_on c (colimit.\u03b9_desc _ _) (colimit.\u03b9_desc _ _),\n      uniq' := \u03bb s m J,\n                begin\n                  rw [\u2190J, \u2190J],\n                  ext;\n                  rw colimit.\u03b9_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) \u27f6 X.function_field :=\nX.presheaf.germ \u27e8generic_point X.carrier,\n  ((generic_point_spec X.carrier).mem_open_set_iff U.prop).mpr (by simpa using h)\u27e9\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 \u27e8U, m, s, rfl\u27e9 := Top.presheaf.germ_exist _ _ a,\n  rw [or_iff_not_imp_right, \u2190 (X.presheaf.germ \u27e8_, m\u27e9).map_zero],\n  intro ha,\n  replace ha := ne_of_apply_ne _ ha,\n  have hs : generic_point X.carrier \u2208 RingedSpace.basic_open _ s,\n  { rw [\u2190 opens.mem_coe, (generic_point_spec X.carrier).mem_open_set_iff, set.top_eq_univ,\n      set.univ_inter, \u2190 set.ne_empty_iff_nonempty, ne.def, \u2190 opens.coe_bot,\n      subtype.coe_injective.eq_iff, \u2190 opens.empty_eq],\n    erw basic_open_eq_bot_iff,\n    exacts [ha, (RingedSpace.basic_open _ _).prop] },\n  have := (X.presheaf.germ \u27e8_, hs\u27e9).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 \u2190 (X.presheaf.germ x).map_zero at hy,\n  obtain \u27e8W, hW, iU, iV, e\u27e9 := X.presheaf.germ_eq _ x.prop x.prop _ _ hy,\n  cases (show iU = iV, from subsingleton.elim _ _),\n  haveI : nonempty W := \u27e8\u27e8_, hW\u27e9\u27e9,\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 \u27f6 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 \u27e8_, trivial, set.mem_range_self hX.2.some\u27e9,\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 \u226b _,\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 = (\u27e80, ideal.bot_prime\u27e9 : prime_spectrum R) :=\nbegin\n  apply (generic_point_spec (Scheme.Spec.obj $ op R).carrier).eq,\n  simp [is_generic_point_def, \u2190 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 \u27e8generic_point X.carrier,\n    ((generic_point_spec X.carrier).mem_open_set_iff U.prop).mpr (by simpa using h)\u27e9 =\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 \u22a4 = U,\n  { ext1, exact set.image_univ.trans subtype.range_coe },\n  delta is_affine_open.prime_ideal_of,\n  rw \u2190 Scheme.comp_val_base_apply,\n  convert (generic_point_eq_of_is_open_immersion ((X.restrict U.open_embedding).iso_Spec.hom \u226b\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 \u22a4 = 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 \u27e8generic_point X.carrier, _\u27e9 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 := \u27e8set.range (X.affine_cover.map x).1.base,\n    PresheafedSpace.is_open_immersion.base_open.open_range\u27e9,\n  haveI : nonempty U := \u27e8\u27e8_, X.affine_cover.covers x\u27e9\u27e9,\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 \u27e8x, X.affine_cover.covers x\u27e9)\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": "/-theorem interesting: 1 = 1 := rfl. -/\n#check \u00ac (1 = 0)\n#check \u2200 T: Type, \u2200 t: T, t = t\nlemma zeqz: 0 = 0 := rfl\nlemma oeqo: 1 = 1 := rfl\n\ntheorem helloTheorem: \"hello\" = \"hello\" := rfl\ntheorem twooneone: 2 = 1 + 1 := rfl\n\ntheorem tthof: 2 + 3 = 1 + 4 := rfl\ntheorem holeqhl: \"Hello \" ++ \"Logic!\" = \"Hello Logic!\" := rfl\n\ntheorem zeqz_and_oeqo: 0 = 0 \u2227 1 = 1 := and.intro zeqz oeqo\ntheorem haha: 0 = 0 \u2227 1 = 1 := and.intro rfl rfl\n\ntheorem negation: tt = \u00ac ff := rfl\nvariable a: bool\n#check \u00ac (a = \u00ac a)\n\nlemma ft: 5 = 1 + 4 := rfl\nlemma st: \"S\" ++ \"trike\" = \"Strike\" := rfl\n\ntheorem ftst: 5 = 1 + 4 \u2227 \"S\" ++ \"trike\" = \"Strike\" := and.intro ft st\n\n#check rfl\n\nconstant T: Type\nvariable t: T\n\n#check \"Heoo\"\n\ntheorem eee: t = t := rfl\n\n#check (eq.refl tt)\n#check (eq.refl \"Hello\")\n\nconstant a: Prop", "meta": {"author": "hanzhi713", "repo": "lean-proofs", "sha": "4d8356a878645b9ba7cb036f87737f3f1e68ede5", "save_path": "github-repos/lean/hanzhi713-lean-proofs", "path": "github-repos/lean/hanzhi713-lean-proofs/lean-proofs-4d8356a878645b9ba7cb036f87737f3f1e68ede5/src/lessons/hello.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7634837743174788, "lm_q2_score": 0.6370308082623217, "lm_q1q2_score": 0.48636268584863157}}
{"text": "/-\nCopyright (c) 2021 Ya\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl Dillies, Bhavik Mehta\n-/\nimport combinatorics.simplicial_complex.convex_independence\nimport combinatorics.simplicial_complex.glued\n\nopen set affine\nnamespace poly\nvariables {m n : \u2115} {E : Type*} [normed_group E] [normed_space \u211d 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 \u211d E] :=\n(space : set E)\n(realisable : \u2203 {S : simplicial_complex E}, S.pure \u2227 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 := \u27e8S, hS, rfl\u27e9}\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\u22c2 (S : simplicial_complex E) (H : p.space = S.space), S.vertices\n\nlemma vertices_subset_space :\n  p.vertices \u2286 p.space :=\nbegin\n  rintro x hx,\n  have hx' : x \u2208 p.to_simplicial_complex.vertices,\n  {\n    --apply bInter_subset_of_mem (polytope_space_eq_realisation_space :\n     -- p.to_simplicial_complex \u2208 set_of (\u03bb q : simplicial_complex E, p.space = q.space)),\n     sorry\n  },\n  rw polytope_space_eq_realisation_space,\n  exact mem_space_iff.2 \u27e8{x}, hx', by simp\u27e9,\nend\n\ndef polytope.edges (p : polytope E) :\n  set (finset E) :=\n\u22c2 (S : simplicial_complex E) (H : p.space = S.space), {X | X \u2208 S.faces \u2227 X.card = 2}\n\n--def polytope.faces {n : \u2115} (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 \u2227 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} \u2208 {\u2205}),\n    simp at hX,\n    exfalso,\n    exact hX,-/\n    sorry\n  },\n  obtain \u27e8x, hx\u27e9 := 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 : \u2115} :\n  \u2203 {S : simplicial_complex E}, S.pure \u2227 space = S.space \u2194 \u2203 half spaces and stuff-/\n\n@[ext] structure polytopial_complex (E : Type*) [normed_group E] [normed_space \u211d E] :=\n(faces : set (finset E))\n(indep : \u2200 {X}, X \u2208 faces \u2192 convex_independent (\u03bb p, p : (X : set E) \u2192 E))\n(down_closed : \u2200 {X Y}, X \u2208 faces \u2192 Y \u2286 X \u2192 (Y : set E) = (X : set E) \u2229 affine_span \u211d (Y : set E)\n  \u2192 Y \u2208 faces)\n(disjoint : \u2200 {X Y}, X \u2208 faces \u2192 Y \u2208 faces \u2192\n  convex_hull \u2191X \u2229 convex_hull \u2191Y \u2286 convex_hull (X \u2229 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\u22c3 (p \u2208 P.polytopes), (p : polytope E).space\n\nlemma mem_space_iff :\n  x \u2208 P.space \u2194 \u2203 (p : polytope E), p \u2208 P.polytopes \u2227 x \u2208 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 := \u03bb X hX, (S.indep hX).convex_independent,\n  down_closed := \u03bb 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\u2200 X Y \u2208 P.faces, adjacent X Y \u2192 (X : set E) \u2286 affine_span \u211d (Y : set E) \u2192\n  X.card = finite_dimensional.finrank \u211d E + 1\n\ndef polytopial_complex.to_simplicial_complex (P : polytopial_complex E) :\n  simplicial_complex E :=\n{ faces := \u22c3 (p \u2208 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 \u27e8p, hp, hX\u27e9 := 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 \u22a2 hX,\n    obtain \u27e8p, hp, hX\u27e9 := hX,\n    exact \u27e8p, hp, p.to_simplicial_complex.down_closed hX hYX\u27e9,\n  end,\n  disjoint := begin\n    rintro X Y hX hY,\n    rw mem_bUnion_iff at hX hY,\n    obtain \u27e8p, hp, hX\u27e9 := hX,\n    obtain \u27e8q, hq, hY\u27e9 := 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 \u211d E] :\n  (\u2203 (S : simplicial_complex E), S.space = C) \u2194\n  \u2203 (P : polytopial_complex E), P.space = C :=\nbegin\n  split,\n  {\n    rintro \u27e8S, hS\u27e9,\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 `\ud835\udd5c`-linear categories with finite dimensional hom spaces,\nover an algebraically closed field `\ud835\udd5c`:\nthe hom space `X \u27f6 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 \u27f6 Y} (w : f \u2260 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 \u27f6 Y) :\n  is_iso.{v} f \u2194 f \u2260 0 :=\n\u27e8\u03bb I,\n  begin\n    introI h,\n    apply id_nonzero X,\n    simp only [\u2190is_iso.hom_inv_id f, h, zero_comp],\n  end,\n  \u03bb w, is_iso_of_hom_simple w\u27e9\n\nopen finite_dimensional\n\nvariables (\ud835\udd5c : Type*) [field \ud835\udd5c]\n\n/--\nPart of **Schur's lemma** for `\ud835\udd5c`-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 \ud835\udd5c C] {X Y : C} [simple.{v} X] [simple.{v} Y]\n  (h : (X \u2245 Y) \u2192 false):\n  finrank \ud835\udd5c (X \u27f6 Y) = 0 :=\nbegin\n  haveI := subsingleton_of_forall_eq (0 : X \u27f6 Y) (\u03bb 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 (\u03bb _, by exactI h (as_iso f)),\n  end),\n  exact finrank_zero_of_subsingleton,\nend\n\nvariables [is_alg_closed \ud835\udd5c] [linear \ud835\udd5c C]\n\n-- In the proof below we have some difficulty using `I : finite_dimensional \ud835\udd5c (X \u27f6 X)`\n-- where we need a `finite_dimensional \ud835\udd5c (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 \u27f6 X` is finite dimensional, and every nonzero endomorphism is invertible,\nthen `X \u27f6 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\u00fcger's formulation of semisimplicity.\nlemma finrank_endomorphism_eq_one\n  {X : C} (is_iso_iff_nonzero : \u2200 f : X \u27f6 X, is_iso f \u2194 f \u2260 0)\n  [I : finite_dimensional \ud835\udd5c (X \u27f6 X)] :\n  finrank \ud835\udd5c (X \u27f6 X) = 1 :=\nbegin\n  have id_nonzero := (is_iso_iff_nonzero (\ud835\udfd9 X)).mp (by apply_instance),\n  apply finrank_eq_one (\ud835\udfd9 X),\n  { exact id_nonzero, },\n  { intro f,\n    haveI : nontrivial (End X) := nontrivial_of_ne _ _ id_nonzero,\n    obtain \u27e8c, nu\u27e9 := @spectrum.nonempty_of_is_alg_closed_of_finite_dimensional \ud835\udd5c (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 `\ud835\udd5c`-linear categories.\n-/\nlemma finrank_endomorphism_simple_eq_one\n  (X : C) [simple.{v} X] [I : finite_dimensional \ud835\udd5c (X \u27f6 X)] :\n  finrank \ud835\udd5c (X \u27f6 X) = 1 :=\nfinrank_endomorphism_eq_one \ud835\udd5c is_iso_iff_nonzero\n\nlemma endomorphism_simple_eq_smul_id\n  {X : C} [simple.{v} X] [I : finite_dimensional \ud835\udd5c (X \u27f6 X)] (f : X \u27f6 X) :\n  \u2203 c : \ud835\udd5c, c \u2022 \ud835\udfd9 X = f :=\n(finrank_eq_one_iff_of_nonzero' (\ud835\udfd9 X) (id_nonzero X)).mp (finrank_endomorphism_simple_eq_one \ud835\udd5c X) f\n\n/--\n**Schur's lemma** for `\ud835\udd5c`-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 `[\u2200 X Y : C, finite_dimensional \ud835\udd5c (X \u27f6 Y)]` here,\n-- just at least one of `[finite_dimensional \ud835\udd5c (X \u27f6 X)]` or `[finite_dimensional \ud835\udd5c (Y \u27f6 Y)]`.\nlemma finrank_hom_simple_simple_le_one\n  (X Y : C) [\u2200 X Y : C, finite_dimensional \ud835\udd5c (X \u27f6 Y)] [simple.{v} X] [simple.{v} Y] :\n  finrank \ud835\udd5c (X \u27f6 Y) \u2264 1 :=\nbegin\n  cases subsingleton_or_nontrivial (X \u27f6 Y) with h,\n  { resetI,\n    convert zero_le_one,\n    exact finrank_zero_of_subsingleton, },\n  { obtain \u27e8f, nz\u27e9 := (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 \u27e8c, w\u27e9 := endomorphism_simple_eq_smul_id \ud835\udd5c (g \u226b inv f),\n    exact \u27e8c, by simpa using w =\u226b f\u27e9, },\nend\n\nlemma finrank_hom_simple_simple_eq_one_iff\n  (X Y : C) [\u2200 X Y : C, finite_dimensional \ud835\udd5c (X \u27f6 Y)] [simple.{v} X] [simple.{v} Y] :\n  finrank \ud835\udd5c (X \u27f6 Y) = 1 \u2194 nonempty (X \u2245 Y) :=\nbegin\n  fsplit,\n  { intro h,\n    rw finrank_eq_one_iff' at h,\n    obtain \u27e8f, nz, -\u27e9 := h,\n    rw \u2190is_iso_iff_nonzero at nz,\n    exactI \u27e8as_iso f\u27e9, },\n  { rintro \u27e8f\u27e9,\n    have le_one := finrank_hom_simple_simple_le_one \ud835\udd5c X Y,\n    have zero_lt : 0 < finrank \ud835\udd5c (X \u27f6 Y) :=\n      finrank_pos_iff_exists_ne_zero.mpr \u27e8f.hom, (is_iso_iff_nonzero f.hom).mp infer_instance\u27e9,\n    linarith, }\nend\n\nlemma finrank_hom_simple_simple_eq_zero_iff\n  (X Y : C) [\u2200 X Y : C, finite_dimensional \ud835\udd5c (X \u27f6 Y)] [simple.{v} X] [simple.{v} Y] :\n  finrank \ud835\udd5c (X \u27f6 Y) = 0 \u2194 is_empty (X \u2245 Y) :=\nbegin\n  rw [\u2190 not_nonempty_iff, \u2190 not_congr (finrank_hom_simple_simple_eq_one_iff \ud835\udd5c X Y)],\n  refine \u27e8\u03bb h, by { rw h, simp, }, \u03bb h, _\u27e9,\n  have := finrank_hom_simple_simple_le_one \ud835\udd5c X Y,\n  interval_cases finrank \ud835\udd5c (X \u27f6 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 \u2192 A j \u2192 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 (`\u2022`) 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 \u2208 A i` for some `i : \u03b9`)\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 {\u03b9 : Type*}\n\n/-- A type alias of sigma types for graded monoids. -/\ndef graded_monoid (A : \u03b9 \u2192 Type*) := sigma A\n\nnamespace graded_monoid\n\ninstance {A : \u03b9 \u2192 Type*} [inhabited \u03b9] [inhabited (A default)]: inhabited (graded_monoid A) :=\nsigma.inhabited\n\n/-- Construct an element of a graded monoid. -/\ndef mk {A : \u03b9 \u2192 Type*} : \u03a0 i, A i \u2192 graded_monoid A := sigma.mk\n\n/-! ### Typeclasses -/\nsection defs\n\nvariables (A : \u03b9 \u2192 Type*)\n\n/-- A graded version of `has_one`, which must be of grade 0. -/\nclass ghas_one [has_zero \u03b9] :=\n(one : A 0)\n\n/-- `ghas_one` implies `has_one (graded_monoid A)` -/\ninstance ghas_one.to_has_one [has_zero \u03b9] [ghas_one A] : has_one (graded_monoid A) :=\n\u27e8\u27e8_, ghas_one.one\u27e9\u27e9\n\n/-- A graded version of `has_mul`. Multiplication combines grades additively, like\n`add_monoid_algebra`. -/\nclass ghas_mul [has_add \u03b9] :=\n(mul {i j} : A i \u2192 A j \u2192 A (i + j))\n\n/-- `ghas_mul` implies `has_mul (graded_monoid A)`. -/\ninstance ghas_mul.to_has_mul [has_add \u03b9] [ghas_mul A] :\n  has_mul (graded_monoid A) :=\n\u27e8\u03bb (x y : graded_monoid A), \u27e8_, ghas_mul.mul x.snd y.snd\u27e9\u27e9\n\nlemma mk_mul_mk [has_add \u03b9] [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 \u03b9] [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 : \u03a0 (n : \u2115) {i}, A i \u2192 A (n \u2022 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 : \u2115) (a : graded_monoid A) :\n  (graded_monoid.mk _ $ gnpow_rec n.succ a.snd) = a * \u27e8_, gnpow_rec n a.snd\u27e9 :=\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 \u03b9]  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 : \u03a0 (n : \u2115) {i}, A i \u2192 A (n \u2022 i) := gmonoid.gnpow_rec)\n(gnpow_zero' : \u03a0 (a : graded_monoid A), graded_monoid.mk _ (gnpow 0 a.snd) = 1\n  . gmonoid.apply_gnpow_rec_zero_tac)\n(gnpow_succ' : \u03a0 (n : \u2115) (a : graded_monoid A),\n  (graded_monoid.mk _ $ gnpow n.succ a.snd) = a * \u27e8_, gnpow n a.snd\u27e9\n  . gmonoid.apply_gnpow_rec_succ_tac)\n\n/-- `gmonoid` implies a `monoid (graded_monoid A)`. -/\ninstance gmonoid.to_monoid [add_monoid \u03b9] [gmonoid A] :\n  monoid (graded_monoid A) :=\n{ one := (1), mul := (*),\n  npow := \u03bb n a, graded_monoid.mk _ (gmonoid.gnpow n a.snd),\n  npow_zero' := \u03bb a, gmonoid.gnpow_zero' a,\n  npow_succ' := \u03bb 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 \u03b9] [gmonoid A] {i} (a : A i) (n : \u2115) :\n  mk i a ^ n = mk (n \u2022 i) (gmonoid.gnpow _ a) :=\nbegin\n  induction n with n,\n  { rw [pow_zero],\n    exact (gmonoid.gnpow_zero' \u27e8_, a\u27e9).symm, },\n  { rw [pow_succ, n_ih, mk_mul_mk],\n    exact (gmonoid.gnpow_succ' n \u27e8_, a\u27e9).symm, },\nend\n\n/-- A graded version of `comm_monoid`. -/\nclass gcomm_monoid [add_comm_monoid \u03b9] 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 \u03b9] [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 : \u03b9 \u2192 Type*)\n\nsection one\nvariables [has_zero \u03b9] [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\u27e8ghas_one.one\u27e9\n\nend one\n\nsection mul\nvariables [add_zero_class \u03b9] [ghas_mul A]\n\n/-- `(\u2022) : A 0 \u2192 A i \u2192 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 : \u03b9) : has_smul (A 0) (A i) :=\n{ smul := \u03bb x y, (zero_add i).rec (ghas_mul.mul x y) }\n\n/-- `(*) : A 0 \u2192 A 0 \u2192 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 := (\u2022) }\n\nvariables {A}\n\n@[simp] lemma mk_zero_smul {i} (a : A 0) (b : A i) : mk _ (a \u2022 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 \u2022 b = a * b := rfl\n\n\nend mul\n\nsection monoid\nvariables [add_monoid \u03b9] [gmonoid A]\n\ninstance : has_pow (A 0) \u2115 :=\n{ pow := \u03bb x n, (nsmul_zero n).rec (gmonoid.gnpow n x : A (n \u2022 0)) }\n\nvariables {A}\n\n@[simp] lemma mk_zero_pow (a : A 0) (n : \u2115) : 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 \u03b9] [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 \u03b9] [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 \u2192* (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 {\u03b1 : Type*} {A : \u03b9 \u2192 Type*} [add_monoid \u03b9] [graded_monoid.gmonoid A]\n\n/-- The index used by `list.dprod`. Propositionally this is equal to `(l.map f\u03b9).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 \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) : \u03b9 :=\nl.foldr (\u03bb i b, f\u03b9 i + b) 0\n\n@[simp] lemma list.dprod_index_nil (f\u03b9 : \u03b1 \u2192 \u03b9) : ([] : list \u03b1).dprod_index f\u03b9 = 0 := rfl\n@[simp] lemma list.dprod_index_cons (a : \u03b1) (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) :\n  (a :: l).dprod_index f\u03b9 = f\u03b9 a + l.dprod_index f\u03b9 := rfl\n\nlemma list.dprod_index_eq_map_sum (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) :\n  l.dprod_index f\u03b9 = (l.map f\u03b9).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 \u03b1`, this computes the product of `fA a` over `a`, where each `fA` is of type\n`A (f\u03b9 a)`. -/\ndef list.dprod (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) :\n  A (l.dprod_index f\u03b9) :=\nl.foldr_rec_on _ _ graded_monoid.ghas_one.one (\u03bb i x a ha, graded_monoid.ghas_mul.mul (fA a) x)\n\n@[simp] lemma list.dprod_nil (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) :\n  (list.nil : list \u03b1).dprod f\u03b9 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\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) (a : \u03b1) (l : list \u03b1) :\n  (a :: l).dprod f\u03b9 fA = (graded_monoid.ghas_mul.mul (fA a) (l.dprod f\u03b9 fA) : _) := rfl\n\nlemma graded_monoid.mk_list_dprod (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) :\n  graded_monoid.mk _ (l.dprod f\u03b9 fA) = (l.map (\u03bb a, graded_monoid.mk (f\u03b9 a) (fA a))).prod :=\nbegin\n  induction l,\n  { simp, refl  },\n  { simp [\u2190l_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 \u03b1) (f : \u03b1 \u2192 graded_monoid A) :\n  (l.map f).prod = graded_monoid.mk _ (l.dprod (\u03bb i, (f i).1) (\u03bb 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 : \u2115} (f : fin n \u2192 graded_monoid A) :\n  (list.of_fn f).prod =\n    graded_monoid.mk _ ((list.fin_range n).dprod (\u03bb i, (f i).1) (\u03bb 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 (\u03b9) {R : Type*}\n\n@[simps one]\ninstance has_one.ghas_one [has_zero \u03b9] [has_one R] : graded_monoid.ghas_one (\u03bb i : \u03b9, R) :=\n{ one := 1 }\n\n@[simps mul]\ninstance has_mul.ghas_mul [has_add \u03b9] [has_mul R] : graded_monoid.ghas_mul (\u03bb i : \u03b9, R) :=\n{ mul := \u03bb 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 \u03b9] [monoid R] : graded_monoid.gmonoid (\u03bb i : \u03b9, R) :=\n{ one_mul := \u03bb a, sigma.ext (zero_add _) (heq_of_eq (one_mul _)),\n  mul_one := \u03bb a, sigma.ext (add_zero _) (heq_of_eq (mul_one _)),\n  mul_assoc := \u03bb a b c, sigma.ext (add_assoc _ _ _) (heq_of_eq (mul_assoc _ _ _)),\n  gnpow := \u03bb n i a, a ^ n,\n  gnpow_zero' := \u03bb a, sigma.ext (zero_nsmul _) (heq_of_eq (monoid.npow_zero' _)),\n  gnpow_succ' := \u03bb n \u27e8i, a\u27e9, sigma.ext (succ_nsmul _ _) (heq_of_eq (monoid.npow_succ' _ _)),\n  ..has_one.ghas_one \u03b9,\n  ..has_mul.ghas_mul \u03b9 }\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 \u03b9] [comm_monoid R] :\n  graded_monoid.gcomm_monoid (\u03bb i : \u03b9, R) :=\n{ mul_comm := \u03bb a b, sigma.ext (add_comm _ _) (heq_of_eq (mul_comm _ _)),\n  ..monoid.gmonoid \u03b9 }\n\n/-- When all the indexed types are the same, the dependent product is just the regular product. -/\n@[simp] lemma list.dprod_monoid {\u03b1} [add_monoid \u03b9] [monoid R] (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9)\n  (fA : \u03b1 \u2192 R) :\n  (l.dprod f\u03b9 fA : (\u03bb i : \u03b9, 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 \u03b9]\n  (A : \u03b9 \u2192 S) : Prop :=\n(one_mem : (1 : R) \u2208 A 0)\n\ninstance set_like.ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.has_graded_one A] : graded_monoid.ghas_one (\u03bb i, A i) :=\n{ one := \u27e81, set_like.has_graded_one.one_mem\u27e9 }\n\n@[simp] lemma set_like.coe_ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.has_graded_one A] : \u2191(@graded_monoid.ghas_one.one _ (\u03bb 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 \u03b9]\n  (A : \u03b9 \u2192 S) : Prop :=\n(mul_mem : \u2200 \u2983i j\u2984 {gi gj}, gi \u2208 A i \u2192 gj \u2208 A j \u2192 gi * gj \u2208 A (i + j))\n\ninstance set_like.ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.has_graded_mul A] :\n  graded_monoid.ghas_mul (\u03bb i, A i) :=\n{ mul := \u03bb i j a b, \u27e8(a * b : R), set_like.has_graded_mul.mul_mem a.prop b.prop\u27e9 }\n\n@[simp] lemma set_like.coe_ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.has_graded_mul A] {i j : \u03b9} (x : A i) (y : A j) :\n    \u2191(@graded_monoid.ghas_mul.mul _ (\u03bb 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 \u03b9]\n  (A : \u03b9 \u2192 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 \u03b9]\nvariables {A : \u03b9 \u2192 S} [set_like.graded_monoid A]\n\nlemma pow_mem (n : \u2115) {r : R} {i : \u03b9} (h : r \u2208 A i) : r ^ n \u2208 A (n \u2022 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 {\u03b9'} (l : list \u03b9') (i : \u03b9' \u2192 \u03b9) (r : \u03b9' \u2192 R) (h : \u2200 j \u2208 l, r j \u2208 A (i j)) :\n  (l.map r).prod \u2208 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 $ \u03bb j hj, h _ $ list.mem_cons_of_mem _ hj) },\nend\n\nlemma list_prod_of_fn_mem {n} (i : fin n \u2192 \u03b9) (r : fin n \u2192 R) (h : \u2200 j, r j \u2208 A (i j)) :\n  (list.of_fn r).prod \u2208 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 _ _ _ (\u03bb _ _, 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 \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.graded_monoid A] :\n  graded_monoid.gmonoid (\u03bb i, A i) :=\n{ one_mul := \u03bb \u27e8i, a, h\u27e9, sigma.subtype_ext (zero_add _) (one_mul _),\n  mul_one := \u03bb \u27e8i, a, h\u27e9, sigma.subtype_ext (add_zero _) (mul_one _),\n  mul_assoc := \u03bb \u27e8i, a, ha\u27e9 \u27e8j, b, hb\u27e9 \u27e8k, c, hc\u27e9,\n    sigma.subtype_ext (add_assoc _ _ _) (mul_assoc _ _ _),\n  gnpow := \u03bb n i a, \u27e8a ^ n, set_like.graded_monoid.pow_mem n a.prop\u27e9,\n  gnpow_zero' := \u03bb n, sigma.subtype_ext (zero_nsmul _) (pow_zero _),\n  gnpow_succ' := \u03bb 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 \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.graded_monoid A] {i : \u03b9} (x : A i) (n : \u2115) :\n    \u2191(@graded_monoid.gmonoid.gnpow _ (\u03bb 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 \u03b9]\n  (A : \u03b9 \u2192 S) [set_like.graded_monoid A] :\n  graded_monoid.gcomm_monoid (\u03bb i, A i) :=\n{ mul_comm := \u03bb \u27e8i, a, ha\u27e9 \u27e8j, b, hb\u27e9, sigma.subtype_ext (add_comm _ _) (mul_comm _ _),\n  ..set_like.gmonoid A}\n\nsection dprod\nopen set_like set_like.graded_monoid\nvariables {\u03b1 S : Type*} [set_like S R] [monoid R] [add_monoid \u03b9]\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 : \u03b9 \u2192 S) [set_like.graded_monoid A]\n  (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) (l : list \u03b1) :\n  \u2191(l.dprod f\u03b9 fA : (\u03bb i, \u21a5(A i)) _) = (list.prod (l.map (\u03bb 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 : \u03b9 \u2192 S) [set_like.graded_monoid A]\n  (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) (l : list \u03b1) :\n  (l.dprod f\u03b9 fA : (\u03bb i, \u21a5(A i)) _) =\n    \u27e8list.prod (l.map (\u03bb a, fA a)), (l.dprod_index_eq_map_sum f\u03b9).symm \u25b8\n      list_prod_map_mem l _ _ (\u03bb i hi, (fA i).prop)\u27e9 :=\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 : \u03b9` such that `a \u2208 A i`. -/\ndef set_like.is_homogeneous (A : \u03b9 \u2192 S) (a : R) : Prop := \u2203 i, a \u2208 A i\n\n@[simp] lemma set_like.is_homogeneous_coe {A : \u03b9 \u2192 S} {i} (x : A i) :\n  set_like.is_homogeneous A (x : R) :=\n\u27e8i, x.prop\u27e9\n\nlemma set_like.is_homogeneous_one [has_zero \u03b9] [has_one R]\n  (A : \u03b9 \u2192 S) [set_like.has_graded_one A] : set_like.is_homogeneous A (1 : R) :=\n\u27e80, set_like.has_graded_one.one_mem\u27e9\n\nlemma set_like.is_homogeneous.mul [has_add \u03b9] [has_mul R] {A : \u03b9 \u2192 S}\n  [set_like.has_graded_mul A] {a b : R} :\n  set_like.is_homogeneous A a \u2192 set_like.is_homogeneous A b \u2192 set_like.is_homogeneous A (a * b)\n| \u27e8i, hi\u27e9 \u27e8j, hj\u27e9 := \u27e8i + j, set_like.has_graded_mul.mul_mem hi hj\u27e9\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 \u03b9] [monoid R]\n  (A : \u03b9 \u2192 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' := \u03bb 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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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\u2082 : Type*} [topological_space M\u2082] [add_comm_monoid M\u2082] [module R M]\n  [module R M\u2082] (f : M \u2192L[R] M\u2082) :\n  is_linear_map R \u21d1f :=\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 \u2227 b \u2194 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 \u2192 perm S) (H : finset G) (a : S) : Prop :=\n\u2200 h, h \u2208 H \u2192 hom h a = a\n\nvariables [decidable_eq S]\n\ndefinition orbit (hom : G \u2192 perm S) (H : finset G) (a : S) : finset S :=\n           image (move_by a) (image hom H)\n\ndefinition fixed_points [reducible] (hom : G \u2192 perm S) (H : finset G) : finset S :=\n{a \u2208 univ | orbit hom H a = '{a}}\n\nvariable [decidable_eq G] -- required by {x \u2208 H |p x} filtering\n\ndefinition moverset (hom : G \u2192 perm S) (H : finset G) (a b : S) : finset G :=\n           {f \u2208 H | hom f a = b}\n\ndefinition stab (hom : G \u2192 perm S) (H : finset G) (a : S) : finset G :=\n           {f \u2208 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 \u2192 perm S} {H : finset G} {a : S} [Hom : is_hom_class hom]\ninclude Hom\n\nlemma exists_of_orbit {b : S} : b \u2208 orbit hom H a \u2192 \u2203 h, h \u2208 H \u2227 hom h a = b :=\n      assume Pb,\n      obtain p (Pp\u2081 : p \u2208 image hom H) (Pp\u2082 : move_by a p = b), from exists_of_mem_image Pb,\n      obtain h (Ph\u2081 : h \u2208 H) (Ph\u2082 : hom h = p), from exists_of_mem_image Pp\u2081,\n      have Phab : hom h a = b, from calc\n        hom h a = p a : Ph\u2082\n            ... = b   : Pp\u2082,\n      exists.intro h (and.intro Ph\u2081 Phab)\n\nlemma orbit_of_exists {b : S} : (\u2203 h, h \u2208 H \u2227 hom h a = b) \u2192 b \u2208 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 \u2208 fixed_points hom H \u2192 is_fixed_point hom H a :=\nassume Pain, take h, assume Phin,\n  eq_of_mem_singleton\n    (of_mem_sep Pain \u25b8 orbit_of_exists (exists.intro h (and.intro Phin rfl)))\n\nlemma mem_fixed_points_of_exists_of_is_fixed_point :\n  (\u2203 h, h \u2208 H) \u2192 is_fixed_point hom H a \u2192 a \u2208 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  (\u2203 h, h \u2208 H) \u2192 (a \u2208 fixed_points hom H \u2194 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 \u2208 fixed_points hom H \u2194 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 \u2192 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) \u2218 (hom g)) a :=\nrfl\n\nlemma stab_lmul {f g : G} : g \u2208 stab hom H a \u2192 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) \u2218 (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 \u2286 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 \u2208 moverset hom H a (hom h a) \u2192 hom (h\u207b\u00b9*g) a = a :=\nassume Pg,\nhave hom g a = hom h a, from of_mem_sep Pg, calc\n  hom (h\u207b\u00b9*g) a = perm.f ((hom h\u207b\u00b9) * (hom g)) a : by rewrite (is_hom hom)\n  ... = ((hom h\u207b\u00b9) \u2218 hom g) a                    : by rewrite perm_f_mul\n  ... = perm.f ((hom h)\u207b\u00b9 * 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\u2081 Ph1\u2082, from exists_of_orbit Pb1,\n      have Ph1b1 : h1 \u2208 moverset hom H a b1,\n        from mem_sep_of_mem Ph1\u2081 Ph1\u2082,\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 \u2208 H \u2192 g \u2208 moverset hom H a (hom h a) \u2192 h\u207b\u00b9*g \u2208 stab hom H a :=\n      assume Ph Pg,\n      have Phinvg : h\u207b\u00b9*g \u2208 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) \u2208 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 \u2208 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 \u2208 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\u207b\u00b9 a = a, from calc\n        hom f\u207b\u00b9 a = hom f\u207b\u00b9 ((hom f) a)      : by rewrite Pf\n        ... = perm.f ((hom f\u207b\u00b9) * (hom f)) a : by rewrite perm_f_mul\n        ... = hom (f\u207b\u00b9 * 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\u207b\u00b9 \u2208 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 \u2208 H \u2192 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\u2081 : f \u2208 stab hom H a) (Pf\u2082 : h*f = g), from exists_of_mem_image Pl,\n       have Pfstab : hom f a = a, from of_mem_sep Pf\u2081,\n       have PginH : g \u2208 H, begin\n        subst Pf\u2082,\n        apply finsubg_mul_closed H,\n          assumption,\n          apply mem_of_mem_sep Pf\u2081\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\u2081,\n      mem_sep_of_mem PginH Pga)\n      (assume Pr, begin\n       rewrite [\u2191fin_lcoset, mem_image_iff],\n       existsi h\u207b\u00b9*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 \u2208 orbit hom H a \u2192 \u2203 h, h \u2208 H \u2227 fin_lcoset (stab hom H a) h = moverset hom H a b :=\n      assume Porb,\n      obtain p (Pp\u2081 : p \u2208 image hom H) (Pp\u2082 : move_by a p = b), from exists_of_mem_image Porb,\n      obtain h (Ph\u2081 : h \u2208 H) (Ph\u2082 : hom h = p), from exists_of_mem_image Pp\u2081,\n      have Phab : hom h a = b, from by subst p; assumption,\n      exists.intro h (and.intro Ph\u2081 (Phab \u25b8 subg_lcoset_eq_moverset Ph\u2081))\n\nlemma subg_lcoset_of_stab_is_moverset_of_orbit (h : G) :\n      h \u2208 H \u2192 \u2203 b, b \u2208 orbit hom H a \u2227 moverset hom H a b = fin_lcoset (stab hom H a) h :=\n      assume Ph,\n      have Pha : (hom h a) \u2208 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\u2081 Pb\u2082, from exists_of_mem_image Pl,\n      obtain h Ph, from subg_moverset_of_orbit_is_lcoset_of_stab b Pb\u2081, begin\n      rewrite [\u2191fin_lcosets, mem_image_eq],\n      existsi h, subst Pb\u2082, assumption\n      end)\n      (assume Pr, obtain h Ph\u2081 Ph\u2082, 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\u2081, begin\n      rewrite [mem_image_eq],\n      existsi b, subst Ph\u2082, 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 \u2192 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 \u2208 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 \u2208 orbit hom H b \u2192 b \u2208 orbit hom H c \u2192 a \u2208 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) \u2218 (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 \u2208 orbit hom H b \u2192 b \u2208 orbit hom H a :=\nassume Painb, obtain h PhinH Phba, from exists_of_orbit Painb,\nhave perm.f (hom h)\u207b\u00b9 a = b, by rewrite [-Phba, -perm_f_mul, mul.left_inv],\nhave (hom h\u207b\u00b9) a = b,        by rewrite [hom_map_inv, this],\norbit_of_exists (exists.intro h\u207b\u00b9 (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 \u25b8 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 (\u03bb 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 \u2208 orbits hom H | card cls = 1}\n\nvariables {hom} {H}\n\nlemma exists_iff_mem_orbits (orb : finset S) :\n  orb \u2208 orbits hom H \u2194 \u2203 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 \u2208 orbits hom H \u2192 \u2203 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 \u25b8 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\u2081 a\u2082, begin\n  rewrite [-*mem_eq_mem_to_set, \u2191fixed_points, *mem_sep_iff],\n  intro Pa\u2081 Pa\u2082,\n  rewrite [and.right Pa\u2081, and.right Pa\u2082],\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) (\u03bb 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 \u2208 orbits hom H | card cls \u2260 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 \u2208 orbits hom H | card cls \u2260 1} card : Sum_binary_union\n        ... = card (fixed_point_orbits hom H) + Sum {cls \u2208 orbits hom H | card cls \u2260 1} card            : by rewrite -card_fixed_point_orbits\n        ... = card (fixed_points hom H) + Sum {cls \u2208 orbits hom H | card cls \u2260 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 \u2192 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\u2081 (g\u2082 : G), eq.symm (calc\n      action_by_lmul g\u2081 * action_by_lmul g\u2082\n    = perm.mk ((lmul_by g\u2081)\u2218(lmul_by g\u2082)) _ : rfl\n... = perm.mk (lmul_by (g\u2081*g\u2082)) _ : by congruence; apply coset.lmul_compose)\n\nlemma action_by_lmul_inj : injective (@action_by_lmul G _ _) :=\ntake g\u2081 g\u2082, assume Peq, perm.no_confusion Peq\n  (\u03bb Pfeq Pqeq,\n  have Pappeq : g\u2081*1 = g\u2082*1, from congr_fun Pfeq _,\n  calc g\u2081 = g\u2081 * 1 : mul_one\n      ... = g\u2082 * 1 : Pappeq\n      ... = g\u2082 : 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 \u2192 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\u2081 g\u2082, eq_of_feq (funext take S, subtype.eq\n  (by rewrite [\u2191action_on_lcoset, \u2191lcoset_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 \u2192 elt_of J \u2286 normalizer H :=\nobtain j Pjin Pj, from exists_of_lcoset_type J,\nassume Pfp,\nhave PH : \u2200 {h}, h \u2208 H \u2192 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 [\u2191conj_by, inv_inv, mul.assoc, fin_lcoset_compose, -fin_lcoset_same, \u2191fin_lcoset, mem_image_iff, \u2191lmul_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 \u2208 normalizer H \u2192 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, \u2191lcoset_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 : \u2200 {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 [\u2191lift_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, \u2191lower_perm, \u2191lift_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 \u25b8 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `(\u207b\u00b9)` / `(+)` 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., `\u2115` and `\u211d\u22650` 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 {\u03b1 : Type u} {\u03b2 : 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 \u2243\u209c 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) : \u21d1(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\u207b\u00b9 :=\nby { ext, refl }\n\n@[to_additive]\nlemma is_open_map_mul_left (a : G) : is_open_map (\u03bb 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 (\u03bb 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 \u2243\u209c 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) : \u21d1(homeomorph.mul_right a) = \u03bb 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\u207b\u00b9 :=\nby { ext, refl }\n\n@[to_additive]\nlemma is_open_map_mul_right (a : G) : is_open_map (\u03bb 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 (\u03bb 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 \u2190 singletons_open_iff_discrete,\n  intro g,\n  suffices : {g} = (\u03bb (x : G), g\u207b\u00b9 * x) \u207b\u00b9' {1},\n  { rw this, exact (continuous_mul_left (g\u207b\u00b9)).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 \u2194 is_open ({1} : set G) :=\n\u27e8\u03bb h, forall_open_iff_discrete.mpr h {1}, discrete_topology_of_open_singleton_one\u27e9\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 (\u03bb 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 (\u03bb a : G, a\u207b\u00b9))\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 (\ud835\udcdd a) (\ud835\udcdd (a\u207b\u00b9)) :=\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 : \u03b1 \u2192 G} {l : filter \u03b1} {y : G} (h : tendsto f l (\ud835\udcdd y)) :\n  tendsto (\u03bb x, (f x)\u207b\u00b9) l (\ud835\udcdd y\u207b\u00b9) :=\n(continuous_inv.tendsto y).comp h\n\nvariables [topological_space \u03b1] {f : \u03b1 \u2192 G} {s : set \u03b1} {x : \u03b1}\n\n@[continuity, to_additive]\nlemma continuous.inv (hf : continuous f) : continuous (\u03bbx, (f x)\u207b\u00b9) :=\ncontinuous_inv.comp hf\n\n@[to_additive]\nlemma continuous_at.inv (hf : continuous_at f x) : continuous_at (\u03bb x, (f x)\u207b\u00b9) x :=\ncontinuous_at_inv.comp hf\n\n@[to_additive]\nlemma continuous_on.inv (hf : continuous_on f s) : continuous_on (\u03bbx, (f x)\u207b\u00b9) 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 (\u03bb x, (f x)\u207b\u00b9) s x :=\nhf.inv\n\n@[to_additive]\ninstance [topological_space H] [has_inv H] [has_continuous_inv H] : has_continuous_inv (G \u00d7 H) :=\n\u27e8(continuous_inv.comp continuous_fst).prod_mk (continuous_inv.comp continuous_snd)\u27e9\n\nvariable {\u03b9 : Type*}\n\n@[to_additive]\ninstance pi.has_continuous_inv {C : \u03b9 \u2192 Type*} [\u2200 i, topological_space (C i)]\n  [\u2200 i, has_inv (C i)] [\u2200 i, has_continuous_inv (C i)] : has_continuous_inv (\u03a0 i, C i) :=\n{ continuous_inv := continuous_pi (\u03bb 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 (\u03b9 \u2192 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\u27e8continuous_of_discrete_topology\u27e9\n\nsection pointwise_limits\n\nvariables (G\u2081 G\u2082 : Type*) [topological_space G\u2082] [t2_space G\u2082]\n\n@[to_additive] lemma is_closed_set_of_map_inv [has_inv G\u2081] [has_inv G\u2082] [has_continuous_inv G\u2082] :\n  is_closed {f : G\u2081 \u2192 G\u2082 | \u2200 x, f x\u207b\u00b9 = (f x)\u207b\u00b9 } :=\nbegin\n  simp only [set_of_forall],\n  refine is_closed_Inter (\u03bb 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\u207b\u00b9 :=\nby { rw [\u2190 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 \u2243\u209c 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 \u2192 G) :=\n(homeomorph.inv _).is_open_map\n\n@[to_additive] lemma is_closed_map_inv : is_closed_map (has_inv.inv : G \u2192 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\u207b\u00b9 := hs.preimage continuous_inv\n@[to_additive] lemma is_closed.inv (hs : is_closed s) : is_closed s\u207b\u00b9 := hs.preimage continuous_inv\n@[to_additive] lemma inv_closure : \u2200 s : set G, (closure s)\u207b\u00b9 = closure s\u207b\u00b9 :=\n(homeomorph.inv G).preimage_closure\n\nend continuous_involutive_inv\n\nsection lattice_ops\n\nvariables {\u03b9' : Sort*} [has_inv G] [has_inv H] {ts : set (topological_space G)}\n  (h : \u03a0 t \u2208 ts, @has_continuous_inv G t _) {ts' : \u03b9' \u2192 topological_space G}\n  (h' : \u03a0 i, @has_continuous_inv G (ts' i) _) {t\u2081 t\u2082 : topological_space G}\n  (h\u2081 : @has_continuous_inv G t\u2081 _) (h\u2082 : @has_continuous_inv G t\u2082 _)\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 (\u03bb 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 (\u2a05 i, ts' i) _ :=\nby {rw \u2190 Inf_range, exact has_continuous_inv_Inf (set.forall_range_iff.mpr h')}\n\nomit h'\n\ninclude h\u2081 h\u2082\n\n@[to_additive] lemma has_continuous_inv_inf :\n  @has_continuous_inv G (t\u2081 \u2293 t\u2082) _ :=\nby {rw inf_eq_infi, refine has_continuous_inv_infi (\u03bb 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 `\u03bb x y, x * y\u207b\u00b9` (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\u02e3) M :=\n\u27e8\u03bb m, (continuous_const.mul continuous_id).mul continuous_const\u27e9\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 \u00d7 G` when both `mul` and `inv` are continuous. -/\n@[to_additive \"Conjugation is jointly continuous on `G \u00d7 G` when both `mul` and `inv` are\ncontinuous.\"]\nlemma topological_group.continuous_conj_prod [has_continuous_inv G] :\n  continuous (\u03bb g : G \u00d7 G, g.fst * g.snd * g.fst\u207b\u00b9) :=\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 (\u03bb (h : G), g * h * g\u207b\u00b9) :=\n(continuous_mul_right g\u207b\u00b9).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 (\u03bb (g : G), g * h * g\u207b\u00b9) :=\n(continuous_mul_right h).mul continuous_inv\n\nend conj\n\nvariables [topological_space G] [group G] [topological_group G]\n[topological_space \u03b1] {f : \u03b1 \u2192 G} {s : set \u03b1} {x : \u03b1}\n\nsection zpow\n\n@[continuity, to_additive]\nlemma continuous_zpow : \u2200 z : \u2124, continuous (\u03bb 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 \u2124 A := \u27e8continuous_zsmul\u27e9\n\ninstance add_group.has_continuous_smul_int {A} [add_group A] [topological_space A]\n  [topological_add_group A] : has_continuous_smul \u2124 A :=\n\u27e8continuous_uncurry_of_discrete_topology continuous_zsmul\u27e9\n\n@[continuity, to_additive]\nlemma continuous.zpow {f : \u03b1 \u2192 G} (h : continuous f) (z : \u2124) :\n  continuous (\u03bb b, (f b) ^ z) :=\n(continuous_zpow z).comp h\n\n@[to_additive]\nlemma continuous_on_zpow {s : set G} (z : \u2124) : continuous_on (\u03bb x, x ^ z) s :=\n(continuous_zpow z).continuous_on\n\n@[to_additive]\nlemma continuous_at_zpow (x : G) (z : \u2124) : continuous_at (\u03bb x, x ^ z) x :=\n(continuous_zpow z).continuous_at\n\n@[to_additive]\nlemma filter.tendsto.zpow {\u03b1} {l : filter \u03b1} {f : \u03b1 \u2192 G} {x : G} (hf : tendsto f l (\ud835\udcdd x)) (z : \u2124) :\n  tendsto (\u03bb x, f x ^ z) l (\ud835\udcdd (x ^ z)) :=\n(continuous_at_zpow _ _).tendsto.comp hf\n\n@[to_additive]\nlemma continuous_within_at.zpow {f : \u03b1 \u2192 G} {x : \u03b1} {s : set \u03b1} (hf : continuous_within_at f s x)\n  (z : \u2124) : continuous_within_at (\u03bb x, f x ^ z) s x :=\nhf.zpow z\n\n@[to_additive]\nlemma continuous_at.zpow {f : \u03b1 \u2192 G} {x : \u03b1} (hf : continuous_at f x) (z : \u2124) :\n  continuous_at (\u03bb x, f x ^ z) x :=\nhf.zpow z\n\n@[to_additive continuous_on.zsmul]\nlemma continuous_on.zpow {f : \u03b1 \u2192 G} {s : set \u03b1} (hf : continuous_on f s) (z : \u2124) :\n  continuous_on (\u03bb x, f x ^ z) s :=\n\u03bb 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 (\ud835\udcdd[>] a) (\ud835\udcdd[<] (a\u207b\u00b9)) :=\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 (\ud835\udcdd[<] a) (\ud835\udcdd[>] (a\u207b\u00b9)) :=\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 (\ud835\udcdd[>] (a\u207b\u00b9)) (\ud835\udcdd[<] a) :=\nby simpa only [inv_inv] using @tendsto_inv_nhds_within_Ioi _ _ _ _ (a\u207b\u00b9)\n\n@[to_additive] lemma tendsto_inv_nhds_within_Iio_inv {a : H} :\n  tendsto has_inv.inv (\ud835\udcdd[<] (a\u207b\u00b9)) (\ud835\udcdd[>] a) :=\nby simpa only [inv_inv] using @tendsto_inv_nhds_within_Iio _ _ _ _ (a\u207b\u00b9)\n\n@[to_additive] lemma tendsto_inv_nhds_within_Ici {a : H} :\n  tendsto has_inv.inv (\ud835\udcdd[\u2265] a) (\ud835\udcdd[\u2264] (a\u207b\u00b9)) :=\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 (\ud835\udcdd[\u2264] a) (\ud835\udcdd[\u2265] (a\u207b\u00b9)) :=\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 (\ud835\udcdd[\u2265] (a\u207b\u00b9)) (\ud835\udcdd[\u2264] a) :=\nby simpa only [inv_inv] using @tendsto_inv_nhds_within_Ici _ _ _ _ (a\u207b\u00b9)\n\n@[to_additive] lemma tendsto_inv_nhds_within_Iic_inv {a : H} :\n  tendsto has_inv.inv (\ud835\udcdd[\u2264] (a\u207b\u00b9)) (\ud835\udcdd[\u2265] a) :=\nby simpa only [inv_inv] using @tendsto_inv_nhds_within_Iic _ _ _ _ (a\u207b\u00b9)\n\nend ordered_comm_group\n\n@[instance, to_additive]\ninstance [topological_space H] [group H] [topological_group H] :\n  topological_group (G \u00d7 H) :=\n{ continuous_inv := continuous_inv.prod_map continuous_inv }\n\n@[to_additive]\ninstance pi.topological_group {C : \u03b2 \u2192 Type*} [\u2200 b, topological_space (C b)]\n  [\u2200 b, group (C b)] [\u2200 b, topological_group (C b)] : topological_group (\u03a0 b, C b) :=\n{ continuous_inv := continuous_pi (\u03bb i, (continuous_apply i).inv) }\n\nopen mul_opposite\n\n@[to_additive]\ninstance [group \u03b1] [has_continuous_inv \u03b1] : has_continuous_inv \u03b1\u1d50\u1d52\u1d56 :=\n{ continuous_inv := continuous_induced_rng $ (@continuous_inv \u03b1 _ _ _).comp continuous_unop }\n\n/-- If multiplication is continuous in `\u03b1`, then it also is in `\u03b1\u1d50\u1d52\u1d56`. -/\n@[to_additive \"If addition is continuous in `\u03b1`, then it also is in `\u03b1\u1d43\u1d52\u1d56`.\"]\ninstance [group \u03b1] [topological_group \u03b1] :\n  topological_group \u03b1\u1d50\u1d52\u1d56 := { }\n\nvariable (G)\n\n@[to_additive]\nlemma nhds_one_symm : comap has_inv.inv (\ud835\udcdd (1 : G)) = \ud835\udcdd (1 : G) :=\n((homeomorph.inv G).comap_nhds_eq _).trans (congr_arg nhds inv_one)\n\n/-- The map `(x, y) \u21a6 (x, xy)` as a homeomorphism. This is a shear mapping. -/\n@[to_additive \"The map `(x, y) \u21a6 (x, x + y)` as a homeomorphism.\nThis is a shear mapping.\"]\nprotected def homeomorph.shear_mul_right : G \u00d7 G \u2243\u209c G \u00d7 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  \u21d1(homeomorph.shear_mul_right G) = \u03bb z : G \u00d7 G, (z.1, z.1 * z.2) :=\nrfl\n\n@[simp, to_additive]\nlemma homeomorph.shear_mul_right_symm_coe :\n  \u21d1(homeomorph.shear_mul_right G).symm = \u03bb z : G \u00d7 G, (z.1, z.1\u207b\u00b9 * 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' := \u03bb g m, by simpa [\u2190set.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 (\u03bb p : s.topological_closure, (p : G)\u207b\u00b9),\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 \u2264 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 \u2264 t) (ht : is_closed (t : set G)) :\n  s.topological_closure \u2264 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 \u2192* H} (hf : continuous f) (hf' : dense_range f) {s : subgroup G}\n  (hs : s.topological_closure = \u22a4) :\n  (s.map f).topological_closure = \u22a4 :=\nbegin\n  rw set_like.ext'_iff at hs \u22a2,\n  simp only [subgroup.topological_closure_coe, subgroup.coe_top, \u2190 dense_iff_closure_eq] at hs \u22a2,\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 := \u03bb 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 \u2208 connected_component (1 : G))\n  (hh : h \u2208 connected_component (1 : G)) : g * h \u2208 connected_component (1 : G) :=\nbegin\n  rw connected_component_eq hg,\n  have hmul: g \u2208 connected_component (g*h),\n  { apply continuous.image_connected_component_subset (continuous_mul_left g),\n    rw \u2190 connected_component_eq hh,\n    exact \u27e8(1 : G), mem_connected_component, by simp only [mul_one]\u27e9 },\n  simpa [\u2190 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 \u2208 connected_component (1 : G)) :\n  g\u207b\u00b9 \u2208 connected_component (1 : G) :=\nbegin\n  rw \u2190 inv_one,\n  exact continuous.image_connected_component_subset continuous_inv _\n    ((set.mem_image _ _ _).mp \u27e8g, hg, rfl\u27e9)\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' := \u03bb g h hg hh, mul_mem_connected_component_one hg hh,\n  inv_mem' := \u03bb 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 : \u2200 (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 \u2208 \ud835\udcdd (1 : G)) :\n  \u2203 V \u2208 \ud835\udcdd (1 : G), \u2200 (v \u2208 V) (w \u2208 V), v / w \u2208 s :=\nhave ((\u03bbp : G \u00d7 G, p.1 * p.2\u207b\u00b9) \u207b\u00b9' s) \u2208 \ud835\udcdd ((1, 1) : G \u00d7 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 (\u03bb y : G, y * x\u207b\u00b9) (\ud835\udcdd 1) = \ud835\udcdd x :=\n((homeomorph.mul_right x\u207b\u00b9).comap_nhds_eq 1).trans $ show \ud835\udcdd (1 * x\u207b\u00b9\u207b\u00b9) = \ud835\udcdd x, by simp\n\n@[simp, to_additive] lemma map_mul_left_nhds (x y : G) : map ((*) x) (\ud835\udcdd y) = \ud835\udcdd (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) (\ud835\udcdd 1) = \ud835\udcdd 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 $ \u03bb x,\n  by simpa only [continuous_at, \u2190 map_mul_left_nhds_one x, tendsto_map'_iff, (\u2218),\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 $ \u03bb x, by\n  rw [\u2190 @nhds_translation_mul_inv G t _ _ x , \u2190 @nhds_translation_mul_inv G t' _ _ x , \u2190 h]\n\n@[to_additive]\nlemma topological_group.of_nhds_aux {G : Type*} [group G] [topological_space G]\n  (hinv : tendsto (\u03bb (x : G), x\u207b\u00b9) (\ud835\udcdd 1) (\ud835\udcdd 1))\n  (hleft : \u2200 (x\u2080 : G), \ud835\udcdd x\u2080 = map (\u03bb (x : G), x\u2080 * x) (\ud835\udcdd 1))\n  (hconj : \u2200 (x\u2080 : G), map (\u03bb (x : G), x\u2080 * x * x\u2080\u207b\u00b9) (\ud835\udcdd 1) \u2264 \ud835\udcdd 1) : continuous (\u03bb x : G, x\u207b\u00b9) :=\nbegin\n  rw continuous_iff_continuous_at,\n  rintros x\u2080,\n  have key : (\u03bb x, (x\u2080*x)\u207b\u00b9) = (\u03bb x, x\u2080\u207b\u00b9*x) \u2218 (\u03bb x, x\u2080*x*x\u2080\u207b\u00b9) \u2218 (\u03bb x, x\u207b\u00b9),\n    by {ext ; simp[mul_assoc] },\n  calc map (\u03bb x, x\u207b\u00b9) (\ud835\udcdd x\u2080)\n      = map (\u03bb x, x\u207b\u00b9) (map (\u03bb x, x\u2080*x) $ \ud835\udcdd 1) : by rw hleft\n  ... = map (\u03bb x, (x\u2080*x)\u207b\u00b9) (\ud835\udcdd 1) : by rw filter.map_map\n  ... = map (((\u03bb x, x\u2080\u207b\u00b9*x) \u2218 (\u03bb x, x\u2080*x*x\u2080\u207b\u00b9)) \u2218 (\u03bb x, x\u207b\u00b9)) (\ud835\udcdd 1) : by rw key\n  ... = map ((\u03bb x, x\u2080\u207b\u00b9*x) \u2218 (\u03bb x, x\u2080*x*x\u2080\u207b\u00b9)) _ : by rw \u2190 filter.map_map\n  ... \u2264 map ((\u03bb x, x\u2080\u207b\u00b9 * x) \u2218 \u03bb x, x\u2080 * x * x\u2080\u207b\u00b9) (\ud835\udcdd 1) : map_mono hinv\n  ... = map (\u03bb x, x\u2080\u207b\u00b9 * x) (map (\u03bb x, x\u2080 * x * x\u2080\u207b\u00b9) (\ud835\udcdd 1)) : filter.map_map\n  ... \u2264 map (\u03bb x, x\u2080\u207b\u00b9 * x) (\ud835\udcdd 1) : map_mono (hconj x\u2080)\n  ... = \ud835\udcdd x\u2080\u207b\u00b9 : (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 \u2192 G \u2192 G)) ((\ud835\udcdd 1) \u00d7\u1da0 \ud835\udcdd 1) (\ud835\udcdd 1))\n  (hinv : tendsto (\u03bb x : G, x\u207b\u00b9) (\ud835\udcdd 1) (\ud835\udcdd 1))\n  (hleft : \u2200 x\u2080 : G, \ud835\udcdd x\u2080 = map (\u03bb x, x\u2080*x) (\ud835\udcdd 1))\n  (hright : \u2200 x\u2080 : G, \ud835\udcdd x\u2080 = map (\u03bb x, x*x\u2080) (\ud835\udcdd 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\u2080,\n  suffices : map (\u03bb (x : G), x\u2080 * x * x\u2080\u207b\u00b9) (\ud835\udcdd 1) = \ud835\udcdd 1, by simp [this, le_refl],\n  rw [show (\u03bb x, x\u2080 * x * x\u2080\u207b\u00b9) = (\u03bb x, x\u2080 * x) \u2218 \u03bb x, x*x\u2080\u207b\u00b9, by {ext, simp [mul_assoc] },\n      \u2190 filter.map_map, \u2190 hright, hleft x\u2080\u207b\u00b9, 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 \u2192 G \u2192 G)) ((\ud835\udcdd 1) \u00d7\u1da0 \ud835\udcdd 1) (\ud835\udcdd 1))\n  (hinv : tendsto (\u03bb x : G, x\u207b\u00b9) (\ud835\udcdd 1) (\ud835\udcdd 1))\n  (hleft : \u2200 x\u2080 : G, \ud835\udcdd x\u2080 = map (\u03bb x, x\u2080*x) (\ud835\udcdd 1))\n  (hconj : \u2200 x\u2080 : G, tendsto (\u03bb x, x\u2080*x*x\u2080\u207b\u00b9) (\ud835\udcdd 1) (\ud835\udcdd 1)) : topological_group G :=\n { continuous_mul := begin\n    rw continuous_iff_continuous_at,\n    rintros \u27e8x\u2080, y\u2080\u27e9,\n    have key : (\u03bb (p : G \u00d7 G), x\u2080 * p.1 * (y\u2080 * p.2)) =\n      ((\u03bb x, x\u2080*y\u2080*x) \u2218 (uncurry (*)) \u2218 (prod.map (\u03bb x, y\u2080\u207b\u00b9*x*y\u2080) id)),\n      by { ext, simp [uncurry, prod.map, mul_assoc] },\n    specialize hconj y\u2080\u207b\u00b9, rw inv_inv at hconj,\n    calc map (\u03bb (p : G \u00d7 G), p.1 * p.2) (\ud835\udcdd (x\u2080, y\u2080))\n        = map (\u03bb (p : G \u00d7 G), p.1 * p.2) ((\ud835\udcdd x\u2080) \u00d7\u1da0 \ud835\udcdd y\u2080)\n            : by rw nhds_prod_eq\n    ... = map (\u03bb (p : G \u00d7 G), x\u2080 * p.1 * (y\u2080 * p.2)) ((\ud835\udcdd 1) \u00d7\u1da0 (\ud835\udcdd 1))\n            : by rw [hleft x\u2080, hleft y\u2080, prod_map_map_eq, filter.map_map]\n    ... = map (((\u03bb x, x\u2080*y\u2080*x) \u2218 (uncurry (*))) \u2218 (prod.map (\u03bb x, y\u2080\u207b\u00b9*x*y\u2080) id))((\ud835\udcdd 1) \u00d7\u1da0 (\ud835\udcdd 1))\n            : by rw key\n    ... = map ((\u03bb x, x\u2080*y\u2080*x) \u2218 (uncurry (*))) ((map  (\u03bb x, y\u2080\u207b\u00b9*x*y\u2080) $ \ud835\udcdd 1) \u00d7\u1da0 (\ud835\udcdd 1))\n            : by rw [\u2190 filter.map_map, \u2190 prod_map_map_eq', map_id]\n    ... \u2264 map ((\u03bb x, x\u2080*y\u2080*x) \u2218 (uncurry (*))) ((\ud835\udcdd 1) \u00d7\u1da0 (\ud835\udcdd 1))\n            : map_mono (filter.prod_mono hconj $ le_rfl)\n    ... = map (\u03bb x, x\u2080*y\u2080*x) (map (uncurry (*)) ((\ud835\udcdd 1) \u00d7\u1da0 (\ud835\udcdd 1)))   : by rw filter.map_map\n    ... \u2264 map (\u03bb x, x\u2080*y\u2080*x) (\ud835\udcdd 1)   : map_mono hmul\n    ... = \ud835\udcdd (x\u2080*y\u2080)   : (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 \u2192 G \u2192 G)) ((\ud835\udcdd 1) \u00d7\u1da0 \ud835\udcdd 1) (\ud835\udcdd 1))\n  (hinv : tendsto (\u03bb x : G, x\u207b\u00b9) (\ud835\udcdd 1) (\ud835\udcdd 1))\n  (hleft : \u2200 x\u2080 : G, \ud835\udcdd x\u2080 = map (\u03bb x, x\u2080*x) (\ud835\udcdd 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 \u29f8 N) :=\nquotient.topological_space\n\nopen quotient_group\n\n@[to_additive]\nlemma quotient_group.is_open_map_coe : is_open_map (coe : G \u2192 G \u29f8 N) :=\nbegin\n  intros s s_op,\n  change is_open ((coe : G \u2192 G \u29f8 N) \u207b\u00b9' (coe '' s)),\n  rw quotient_group.preimage_image_coe N s,\n  exact is_open_Union (\u03bb n, (continuous_mul_right _).is_open_preimage s s_op)\nend\n\n@[to_additive]\ninstance topological_group_quotient [N.normal] : topological_group (G \u29f8 N) :=\n{ continuous_mul := begin\n    have cont : continuous ((coe : G \u2192 G \u29f8 N) \u2218 (\u03bb (p : G \u00d7 G), p.fst * p.snd)) :=\n      continuous_quot_mk.comp continuous_mul,\n    have quot : quotient_map (\u03bb p : G \u00d7 G, ((p.1 : G \u29f8 N), (p.2 : G \u29f8 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 \u2192 G \u29f8 N) \u2218 (\u03bb (a : G), a\u207b\u00b9)) :=\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 `\u03bb p : G \u00d7 G, p.1 - p.2` is a continuous function. This property\nautomatically holds for topological additive groups but it also holds, e.g., for `\u211d\u22650`. -/\nclass has_continuous_sub (G : Type*) [topological_space G] [has_sub G] : Prop :=\n(continuous_sub : continuous (\u03bb p : G \u00d7 G, p.1 - p.2))\n\n/-- A typeclass saying that `\u03bb p : G \u00d7 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 (\u03bb p : G \u00d7 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\u27e8by { simp only [div_eq_mul_inv], exact continuous_fst.mul continuous_snd.inv }\u27e9\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 : \u03b1 \u2192 G} {l : filter \u03b1} {a b : G} (hf : tendsto f l (\ud835\udcdd a))\n  (hg : tendsto g l (\ud835\udcdd b)) : tendsto (\u03bb x, f x / g x) l (\ud835\udcdd (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 : \u03b1 \u2192 G} {l : filter \u03b1}\n  (h : tendsto f l (\ud835\udcdd c)) : tendsto (\u03bb k : \u03b1, b / f k) l (\ud835\udcdd (b / c)) :=\ntendsto_const_nhds.div' h\n\n@[to_additive sub_const]\nlemma filter.tendsto.div_const' (b : G) {c : G} {f : \u03b1 \u2192 G} {l : filter \u03b1}\n  (h : tendsto f l (\ud835\udcdd c)) : tendsto (\u03bb k : \u03b1, f k / b) l (\ud835\udcdd (c / b)) :=\nh.div' tendsto_const_nhds\n\nvariables [topological_space \u03b1] {f g : \u03b1 \u2192 G} {s : set \u03b1} {x : \u03b1}\n\n@[continuity, to_additive sub] lemma continuous.div' (hf : continuous f) (hg : continuous g) :\n  continuous (\u03bb 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 (\u03bb b : G, a / b) :=\ncontinuous_const.div' continuous_id\n\n@[to_additive continuous_sub_right]\nlemma continuous_div_right' (a : G) : continuous (\u03bb b : G, b / a) :=\ncontinuous_id.div' continuous_const\n\n@[to_additive sub]\nlemma continuous_at.div' {f g : \u03b1 \u2192 G} {x : \u03b1} (hf : continuous_at f x) (hg : continuous_at g x) :\n  continuous_at (\u03bbx, 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 (\u03bb 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 (\u03bbx, f x / g x) s :=\n\u03bb 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\u207b\u00b9` 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 \u2243\u209c 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\u207b\u00b9 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 \u2243\u209c 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 (\u03bb 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 (\u03bb x, x / a) :=\n(homeomorph.div_right a).is_closed_map\n\n@[to_additive]\nlemma tendsto_div_nhds_one_iff\n  {\u03b1 : Type*} {l : filter \u03b1} {x : G} {u : \u03b1 \u2192 G} :\n  tendsto (\u03bb n, u n / x) l (\ud835\udcdd 1) \u2194 tendsto u l (\ud835\udcdd x) :=\nbegin\n  have A : tendsto (\u03bb (n : \u03b1), x) l (\ud835\udcdd x) := tendsto_const_nhds,\n  exact \u27e8\u03bb h, by simpa using h.mul A, \u03bb h, by simpa using h.div' A\u27e9\nend\n\n@[to_additive] lemma nhds_translation_div (x : G) : comap (/ x) (\ud835\udcdd 1) = \ud835\udcdd 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 \u03b1] [group \u03b1] [has_continuous_mul \u03b1] {s t : set \u03b1}\n\n@[to_additive] lemma is_open.mul_left (ht : is_open t) : is_open (s * t) :=\nby { rw \u2190Union_mul_left_image, exact is_open_bUnion (\u03bb 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 \u2190Union_mul_right_image, exact is_open_bUnion (\u03bb a ha, is_open_map_mul_right a s hs) }\n\n@[to_additive] lemma subset_interior_mul_left : interior s * t \u2286 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 \u2286 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 \u2286 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 \u03b1] [group \u03b1] [topological_group \u03b1] {s t : set \u03b1}\n\n@[to_additive] lemma is_open.div_left (ht : is_open t) : is_open (s / t) :=\nby { rw \u2190Union_div_left_image, exact is_open_bUnion (\u03bb 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 \u2190Union_div_right_image, exact is_open_bUnion (\u03bb a ha, is_open_map_div_right a s hs) }\n\n@[to_additive] lemma subset_interior_div_left : interior s / t \u2286 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 \u2286 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 \u2286 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 \u03b1) : s * closure t = s * t :=\nbegin\n  refine (mul_subset_iff.2 $ \u03bb a ha b hb, _).antisymm (mul_subset_mul_left subset_closure),\n  rw mem_closure_iff at hb,\n  have hbU : b \u2208 s\u207b\u00b9 * {a * b} := \u27e8a\u207b\u00b9, a * b, set.inv_mem_inv.2 ha, rfl, inv_mul_cancel_left _ _\u27e9,\n  obtain \u27e8_, \u27e8c, d, hc, (rfl : d = _), rfl\u27e9, hcs\u27e9 := hb _ hs.inv.mul_right hbU,\n  exact \u27e8c\u207b\u00b9, _, hc, hcs, inv_mul_cancel_left _ _\u27e9,\nend\n\n@[to_additive] lemma is_open.closure_mul (ht : is_open t) (s : set \u03b1) : closure s * t = s * t :=\nby rw [\u2190inv_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 \u03b1) : 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 \u03b1) : 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 \u2264 Z)\n(sub_Z : tendsto (\u03bbp:G\u00d7G, p.1 - p.2) (Z \u00d7\u1da0 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\u27e8assume x, by { convert is_closed_map_mul_right x _ h, simp }\u27e9\n\n@[to_additive]\nlemma topological_group.regular_space [t1_space G] : regular_space G :=\n\u27e8assume s a hs ha,\n let f := \u03bb p : G \u00d7 G, p.1 * (p.2)\u207b\u00b9 in\n have hf : continuous f := continuous_fst.mul continuous_snd.inv,\n -- a \u2208 -s implies f (a, 1) \u2208 -s, and so (a, 1) \u2208 f\u207b\u00b9' (-s);\n -- and so can find t\u2081 t\u2082 open such that a \u2208 t\u2081 \u00d7 t\u2082 \u2286 f\u207b\u00b9' (-s)\n let \u27e8t\u2081, t\u2082, ht\u2081, ht\u2082, a_mem_t\u2081, one_mem_t\u2082, t_subset\u27e9 :=\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\u2082, ht\u2082.mul_left, \u03bb x hx, \u27e8x, 1, hx, one_mem_t\u2082, mul_one _\u27e9],\n   rw [nhds_within, inf_principal_eq_bot, mem_nhds_iff],\n   refine \u27e8t\u2081, _, ht\u2081, a_mem_t\u2081\u27e9,\n   rintros x hx \u27e8y, z, hy, hz, yz\u27e9,\n   have : x * z\u207b\u00b9 \u2208 s\u1d9c := (prod_subset_iff.1 t_subset) x hx z hz,\n   have : x * z\u207b\u00b9 \u2208 s, rw \u2190 yz, simpa,\n   contradiction\n end\u27e9\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 \u29f8 S) :=\nbegin\n  suffices : t1_space (G \u29f8 S), { exact @topological_group.regular_space _ _ _ _ this, },\n  have hS : is_closed (S : set G) := infer_instance,\n  rw \u2190 quotient_group.ker_mk S at hS,\n  exact topological_group.t1_space (G \u29f8 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 \u2286 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 \u2286 U`.\"]\nlemma compact_open_separated_mul_right {K U : set G} (hK : is_compact K) (hU : is_open U)\n  (hKU : K \u2286 U) : \u2203 V \u2208 \ud835\udcdd (1 : G), K * V \u2286 U :=\nbegin\n  apply hK.induction_on,\n  { exact \u27e8univ, by simp\u27e9 },\n  { rintros s t hst \u27e8V, hV, hV'\u27e9,\n    exact \u27e8V, hV, (mul_subset_mul_right hst).trans hV'\u27e9 },\n  { rintros s t  \u27e8V, V_in, hV'\u27e9 \u27e8W, W_in, hW'\u27e9,\n    use [V \u2229 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 \u2208 \ud835\udcdd (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 \u27e8t, ht, s, hs, h\u27e9,\n    rw [\u2190 image_subset_iff, image_mul_prod] at h,\n    exact \u27e8t, mem_nhds_within_of_mem_nhds ht, s, hs, h\u27e9 }\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 \u2286 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 \u2286 U`.\"]\nlemma compact_open_separated_mul_left {K U : set G} (hK : is_compact K) (hU : is_open U)\n  (hKU : K \u2286 U) : \u2203 V \u2208 \ud835\udcdd (1 : G), V * K \u2286 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 \u27e8V, (hV : V \u2208 \ud835\udcdd (op (1 : G))), hV' : op '' K * V \u2286 op '' U\u27e9,\n  refine \u27e8op \u207b\u00b9' V, continuous_op.continuous_at hV, _\u27e9,\n  rwa [\u2190 image_preimage_eq V op_surjective, \u2190 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) : \u2203 t : finset G, K \u2286 \u22c3 g \u2208 t, (\u03bb h, g * h) \u207b\u00b9' V :=\nbegin\n  obtain \u27e8t, ht\u27e9 : \u2203 t : finset G, K \u2286 \u22c3 x \u2208 t, interior (((*) x) \u207b\u00b9' V),\n  { refine hK.elim_finite_subcover (\u03bb x, interior $ ((*) x) \u207b\u00b9' V) (\u03bb x, is_open_interior) _,\n    cases hV with g\u2080 hg\u2080,\n    refine \u03bb g hg, mem_Union.2 \u27e8g\u2080 * g\u207b\u00b9, _\u27e9,\n    refine preimage_interior_subset_interior_preimage (continuous_const.mul continuous_id) _,\n    rwa [mem_preimage, inv_mul_cancel_right] },\n  exact \u27e8t, subset.trans ht $ Union\u2082_mono $ \u03bb g hg, interior_subset\u27e9\nend\n\n/-- Every locally compact separable topological group is \u03c3-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 \u27e8L, hLc, hL1\u27e9 := exists_compact_mem_nhds (1 : G),\n  refine \u27e8\u27e8\u03bb n, (\u03bb x, x * dense_seq G n) \u207b\u00b9' L, _, _\u27e9\u27e9,\n  { intro n, exact (homeomorph.mul_right _).compact_preimage.mpr hLc },\n  { refine Union_eq_univ_iff.2 (\u03bb x, _),\n    obtain \u27e8_, \u27e8n, rfl\u27e9, hn\u27e9 : (range (dense_seq G) \u2229 (\u03bb y, x * y) \u207b\u00b9' L).nonempty,\n    { rw [\u2190 (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 \u27e8n, hn\u27e9 }\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 (\u03bb x, _),\n  obtain \u27e8y, hy\u27e9 := K.interior_nonempty,\n  let F := homeomorph.mul_left (x * y\u207b\u00b9),\n  refine \u27e8F '' K, _, K.compact.image F.continuous\u27e9,\n  suffices : F.symm \u207b\u00b9' K \u2208 \ud835\udcdd 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) : \ud835\udcdd (x * y) = \ud835\udcdd x * \ud835\udcdd y :=\nfilter_eq $ set.ext $ assume s,\nbegin\n  rw [\u2190 nhds_translation_mul_inv x, \u2190 nhds_translation_mul_inv y, \u2190 nhds_translation_mul_inv (x*y)],\n  split,\n  { rintros \u27e8t, ht, ts\u27e9,\n    rcases exists_nhds_one_split ht with \u27e8V, V1, h\u27e9,\n    refine \u27e8(\u03bba, a * x\u207b\u00b9) \u207b\u00b9' V, (\u03bba, a * y\u207b\u00b9) \u207b\u00b9' V,\n            \u27e8V, V1, subset.refl _\u27e9, \u27e8V, V1, subset.refl _\u27e9, _\u27e9,\n    rintros a \u27e8v, w, v_mem, w_mem, rfl\u27e9,\n    apply ts,\n    simpa [mul_comm, mul_assoc, mul_left_comm] using h (v * x\u207b\u00b9) v_mem (w * y\u207b\u00b9) w_mem },\n  { rintros \u27e8a, c, \u27e8b, hb, ba\u27e9, \u27e8d, hd, dc\u27e9, ac\u27e9,\n    refine \u27e8b \u2229 d, inter_mem hb hd, assume v, _\u27e9,\n    simp only [preimage_subset_iff, mul_inv_rev, mem_preimage] at *,\n    rintros \u27e8vb, vd\u27e9,\n    refine ac \u27e8v * y\u207b\u00b9, y, _, _, _\u27e9,\n    { rw \u2190 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, `\ud835\udcdd : G \u2192 filter G` can be promoted to a `mul_hom`. -/\n@[to_additive \"On an additive topological group, `\ud835\udcdd : G \u2192 filter G` can be promoted to an\n`add_hom`.\", simps]\ndef nhds_mul_hom : G \u2192\u2099* (filter G) :=\n{ to_fun := \ud835\udcdd,\n  map_mul' := \u03bb_ _, 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] {\u0393 : subgroup G}\n\n@[to_additive]\ninstance quotient_group.has_continuous_const_smul : has_continuous_const_smul G (G \u29f8 \u0393) :=\n{ continuous_const_smul := \u03bb g\u2080, begin\n    apply continuous_coinduced_dom,\n    change continuous (\u03bb g : G, quotient_group.mk (g\u2080 * g)),\n    exact continuous_coinduced_rng.comp (continuous_mul_left g\u2080),\n  end }\n\n@[to_additive]\nlemma quotient_group.continuous_smul\u2081 (x : G \u29f8 \u0393) : continuous (\u03bb g : G, g \u2022 x) :=\nbegin\n  obtain \u27e8g\u2080, rfl\u27e9 : \u2203 g\u2080, quotient_group.mk g\u2080 = x,\n  { exact @quotient.exists_rep _ (quotient_group.left_rel \u0393) x },\n  change continuous (\u03bb g, quotient_group.mk (g * g\u2080)),\n  exact continuous_coinduced_rng.comp (continuous_mul_right g\u2080)\nend\n\n@[to_additive]\ninstance quotient_group.has_continuous_smul [locally_compact_space G] :\n  has_continuous_smul G (G \u29f8 \u0393) :=\n{ continuous_smul := begin\n    let F : G \u00d7 G \u29f8 \u0393 \u2192 G \u29f8 \u0393 := \u03bb p, p.1 \u2022 p.2,\n    change continuous F,\n    have H : continuous (F \u2218 (\u03bb p : G \u00d7 G, (p.1, quotient_group.mk p.2))),\n    { change continuous (\u03bb p : G \u00d7 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 \u03b1] [topological_space \u03b1] [has_continuous_mul \u03b1] [monoid \u03b2] [topological_space \u03b2]\n  [has_continuous_mul \u03b2]\n\n@[to_additive] instance : topological_group \u03b1\u02e3 :=\n{ continuous_inv := continuous_induced_rng ((continuous_unop.comp\n    (@continuous_embed_product \u03b1 _ _).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 (\u03b1 \u00d7 \u03b2)\u02e3 (\u03b1\u02e3 \u00d7 \u03b2\u02e3) :=\n{ continuous_to_fun  :=\n  begin\n    show continuous (\u03bb i : (\u03b1 \u00d7 \u03b2)\u02e3, (map (monoid_hom.fst \u03b1 \u03b2) i, map (monoid_hom.snd \u03b1 \u03b2) 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 {\u03b9 : Sort*} [group G] [group H] {ts : set (topological_space G)}\n  (h : \u2200 t \u2208 ts, @topological_group G t _) {ts' : \u03b9 \u2192 topological_space G}\n  (h' : \u2200 i, @topological_group G (ts' i) _) {t\u2081 t\u2082 : topological_space G}\n  (h\u2081 : @topological_group G t\u2081 _) (h\u2082 : @topological_group G t\u2082 _)\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      (\u03bb 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      (\u03bb 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 (\u2a05 i, ts' i) _ :=\nby {rw \u2190 Inf_range, exact topological_group_Inf (set.forall_range_iff.mpr h')}\n\nomit h'\n\ninclude h\u2081 h\u2082\n\n@[to_additive] lemma topological_group_inf :\n  @topological_group G (t\u2081 \u2293 t\u2082) _ :=\nby {rw inf_eq_infi, refine topological_group_infi (\u03bb b, _), cases b; assumption}\n\nomit h\u2081 h\u2082\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 \u03b1` which endows a group `\u03b1` with a topology such that all\ngroup operations are continuous.\n\nGroup topologies on a fixed group `\u03b1` are ordered, by reverse inclusion. They form a complete\nlattice, with `\u22a5` the discrete topology and `\u22a4` the indiscrete topology.\n\nAny function `f : \u03b1 \u2192 \u03b2` induces `coinduced f : topological_space \u03b1 \u2192 group_topology \u03b2`.\n\nThe additive version `add_group_topology \u03b1` and corresponding results are provided as well.\n-/\n\n/-- A group topology on a group `\u03b1` is a topology for which multiplication and inversion\nare continuous. -/\nstructure group_topology (\u03b1 : Type u) [group \u03b1]\n  extends topological_space \u03b1, topological_group \u03b1 : Type u\n\n/-- An additive group topology on an additive group `\u03b1` is a topology for which addition and\n  negation are continuous. -/\nstructure add_group_topology (\u03b1 : Type u) [add_group \u03b1]\n  extends topological_space \u03b1, topological_add_group \u03b1 : Type u\n\nattribute [to_additive] group_topology\n\nnamespace group_topology\n\nvariables [group \u03b1]\n\n/-- A version of the global `continuous_mul` suitable for dot notation. -/\n@[to_additive]\nlemma continuous_mul' (g : group_topology \u03b1) :\n  by haveI := g.to_topological_space; exact continuous (\u03bb p : \u03b1 \u00d7 \u03b1, 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 \u03b1) :\n  by haveI := g.to_topological_space; exact continuous (has_inv.inv : \u03b1 \u2192 \u03b1) :=\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 \u03b1 \u2192 topological_space \u03b1):=\n\u03bb f g h, by { cases f, cases g, congr' }\n\n@[ext, to_additive]\nlemma ext' {f g : group_topology \u03b1} (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 `\u03b3`.\n  `t \u2264 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 \u03b1) :=\npartial_order.lift to_topological_space to_topological_space_injective\n\n@[simp, to_additive] lemma to_topological_space_le {x y : group_topology \u03b1} :\n  x.to_topological_space \u2264 y.to_topological_space \u2194 x \u2264 y := iff.rfl\n\n@[to_additive]\ninstance : has_top (group_topology \u03b1) :=\n\u27e8{to_topological_space := \u22a4,\n  continuous_mul       := continuous_top,\n  continuous_inv       := continuous_top}\u27e9\n\n@[simp, to_additive] lemma to_topological_space_top :\n  (\u22a4 : group_topology \u03b1).to_topological_space = \u22a4 := rfl\n\n@[to_additive]\ninstance : has_bot (group_topology \u03b1) :=\n\u27e8{to_topological_space := \u22a5,\n  continuous_mul       := by continuity,\n  continuous_inv       := continuous_bot}\u27e9\n\n@[simp, to_additive] lemma to_topological_space_bot :\n  (\u22a5 : group_topology \u03b1).to_topological_space = \u22a5 := rfl\n\n@[to_additive]\ninstance : bounded_order (group_topology \u03b1) :=\n{ top := \u22a4,\n  le_top := \u03bb x, show x.to_topological_space \u2264 \u22a4, from le_top,\n  bot := \u22a5,\n  bot_le := \u03bb x, show \u22a5 \u2264 x.to_topological_space, from bot_le }\n\n@[to_additive]\ninstance : has_inf (group_topology \u03b1) :=\n{ inf := \u03bb x y,\n  { to_topological_space := x.to_topological_space \u2293 y.to_topological_space,\n    continuous_mul := continuous_inf_rng\n      (continuous_inf_dom_left\u2082 x.continuous_mul') (continuous_inf_dom_right\u2082 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 \u03b1) :\n  (x \u2293 y).to_topological_space = x.to_topological_space \u2293 y.to_topological_space := rfl\n\n@[to_additive]\ninstance : semilattice_inf (group_topology \u03b1) :=\nto_topological_space_injective.semilattice_inf _ to_topological_space_inf\n\n@[to_additive]\ninstance : inhabited (group_topology \u03b1) := \u27e8\u22a4\u27e9\n\nlocal notation `cont` := @continuous _ _\n@[to_additive \"Infimum of a collection of additive group topologies\"]\ninstance : has_Inf (group_topology \u03b1) :=\n{ Inf := \u03bb S,\n  { to_topological_space := Inf (to_topological_space '' S),\n    continuous_mul       := continuous_Inf_rng begin\n      rintros _ \u27e8\u27e8t, tr\u27e9, haS, rfl\u27e9, resetI,\n      exact continuous_Inf_dom\u2082\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 _ \u27e8\u27e8t, tr\u27e9, haS, rfl\u27e9, 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 \u03b1)) :\n  (Inf s).to_topological_space = Inf (to_topological_space '' s) := rfl\n\n@[simp, to_additive]\nlemma to_topological_space_infi {\u03b9} (s : \u03b9 \u2192 group_topology \u03b1) :\n  (\u2a05 i, s i).to_topological_space = \u2a05 i, (s i).to_topological_space :=\ncongr_arg Inf (range_comp _ _).symm\n\n/-- Group topologies on `\u03b3` form a complete lattice, with `\u22a5` the discrete topology and `\u22a4` 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 \u03b1) :=\n{ Inf_le := \u03bb S a haS, to_topological_space_le.1 $ Inf_le \u27e8a, haS, rfl\u27e9,\n  le_Inf :=\n  begin\n    intros S a hab,\n    apply topological_space.complete_lattice.le_Inf,\n    rintros _ \u27e8b, hbS, rfl\u27e9,\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 \u03b1) :=\n{ inf := (\u2293),\n  top := \u22a4,\n  bot := \u22a5,\n  ..group_topology.bounded_order,\n  ..group_topology.semilattice_inf,\n  ..complete_lattice_of_complete_semilattice_Inf _ }\n\n/--  Given `f : \u03b1 \u2192 \u03b2` and a topology on `\u03b1`, the coinduced group topology on `\u03b2` is the finest\ntopology such that `f` is continuous and `\u03b2` is a topological group. -/\n@[to_additive \"Given `f : \u03b1 \u2192 \u03b2` and a topology on `\u03b1`, the coinduced additive group topology on `\u03b2`\nis the finest topology such that `f` is continuous and `\u03b2` is a topological additive group.\"]\ndef coinduced {\u03b1 \u03b2 : Type*} [t : topological_space \u03b1] [group \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  group_topology \u03b2 :=\nInf {b : group_topology \u03b2 | (topological_space.coinduced f t) \u2264 b.to_topological_space}\n\n@[to_additive]\nlemma coinduced_continuous {\u03b1 \u03b2 : Type*} [t : topological_space \u03b1] [group \u03b2]\n  (f : \u03b1 \u2192 \u03b2) : cont t (coinduced f).to_topological_space f :=\nbegin\n  rw continuous_iff_coinduced_le,\n  refine le_Inf _,\n  rintros _ \u27e8t', ht', rfl\u27e9,\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\u2081 v\u2082 u\u2081 u\u2082\n\n-- morphism levels before object levels. See note [category_theory universes].\nvariable {T : Type u\u2081} [Category.{v\u2081} 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 (\ud835\udfed 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 := \ud835\udfd9 _ }\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 \u27f6 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 = \u27e8\u27e8\u27e9\u27e9 := 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 (\ud835\udfd9 U) = \ud835\udfd9 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 \u27f6 b) (g : b \u27f6 c) : (f \u226b g).left = f.left \u226b 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\u2093'. -/\n@[simp, reassoc.1]\ntheorem w {A B : Over X} (f : A \u27f6 B) : f.left \u226b 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 \u27f6 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 \u27f6 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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_hom {X Y : T} (f : Y \u27f6 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\u2093.{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\u2093'. -/\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 \u27f6 V.left) (w : f \u226b V.Hom = U.Hom := by obviously) : U \u27f6 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\u2093.{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\u2093'. -/\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 \u2245 g.left) (hw : hl.Hom \u226b g.Hom = f.Hom := by obviously) :\n    f \u2245 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 \u2964 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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem forget_map {U V : Over X} {f : U \u27f6 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 \u2964 T` with cocone point `X`. -/\n@[simps]\ndef forgetCocone (X : T) : Limits.Cocone (forget X) :=\n  { pt\n    \u03b9 := { 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 \u27f6 Y` induces a functor `over X \u2964 over Y` in the obvious way.\n\nSee <https://stacks.math.columbia.edu/tag/001G>.\n-/\ndef map {Y : T} (f : X \u27f6 Y) : Over X \u2964 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 \u27f6 Y} {U V : Over X} {g : U \u27f6 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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem map_obj_hom : ((map f).obj U).Hom = U.Hom \u226b 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\u2093'. -/\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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\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 \u226b g` is the same as mapping by `f` then by `g`. -/\ndef mapComp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map f \u22d9 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    \u27e8\u27e8over.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\u27e9\u27e9\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 \u27f6 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 \u27f6 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 \u27f6 g) [Mono k] : Mono k.left :=\n  by\n  refine' \u27e8fun (Y : T) l m a => _\u27e9\n  let l' : mk (m \u226b f.hom) \u27f6 f :=\n    hom_mk l\n      (by\n        dsimp\n        rw [\u2190 over.w k, reassoc_of a])\n  suffices l' = hom_mk m by apply congr_arg comma_morphism.left this\n  rw [\u2190 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 \u27f6 X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iteratedSliceForward : Over f \u2964 Over f.left\n    where\n  obj \u03b1 := Over.mk \u03b1.Hom.left\n  map \u03b1 \u03b2 \u03ba :=\n    Over.homMk \u03ba.left.left\n      (by\n        rw [autoParam_eq]\n        rw [\u2190 over.w \u03ba]\n        rfl)\n#align category_theory.over.iterated_slice_forward CategoryTheory.Over.iteratedSliceForward\n-/\n\n#print CategoryTheory.Over.iteratedSliceBackward /-\n/-- Given f : Y \u27f6 X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iteratedSliceBackward : Over f.left \u2964 Over f\n    where\n  obj g := mk (homMk g.Hom : mk (g.Hom \u226b f.Hom) \u27f6 f)\n  map g h \u03b1 := homMk (homMk \u03b1.left (w_assoc \u03b1 f.Hom)) (OverMorphism.ext (w \u03b1))\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\u2093'. -/\n/-- Given f : Y \u27f6 X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iteratedSliceEquiv : Over f \u224c 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 \u22d9 forget f.left = forget f \u22d9 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 \u22d9 forget f \u22d9 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\u2082} [Category.{v\u2082} 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\u2093'. -/\n/-- A functor `F : T \u2964 D` induces a functor `over X \u2964 over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T \u2964 D) : Over X \u2964 Over (F.obj X)\n    where\n  obj Y := mk <| F.map Y.Hom\n  map Y\u2081 Y\u2082 f := Over.homMk (F.map f.left) (by tidy <;> erw [\u2190 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 (\ud835\udfed 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 := \ud835\udfd9 _ }\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 \u27f6 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 = \u27e8\u27e8\u27e9\u27e9 := 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 (\ud835\udfd9 U) = \ud835\udfd9 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 \u27f6 b) (g : b \u27f6 c) : (f \u226b g).right = f.right \u226b 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\u2093'. -/\n@[simp, reassoc.1]\ntheorem w {A B : Under X} (f : A \u27f6 B) : A.Hom \u226b 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 \u27f6 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\u2093.{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\u2093'. -/\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 \u27f6 V.right) (w : U.Hom \u226b f = V.Hom := by obviously) : U \u27f6 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\u2093'. -/\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 \u2245 g.right) (hw : f.Hom \u226b hr.Hom = g.Hom) : f \u2245 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\u2093'. -/\n@[simp]\ntheorem isoMk_hom_right {f g : Under X} (hr : f.right \u2245 g.right) (hw : f.Hom \u226b 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\u2093'. -/\n@[simp]\ntheorem isoMk_inv_right {f g : Under X} (hr : f.right \u2245 g.right) (hw : f.Hom \u226b 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 \u2964 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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem forget_map {U V : Under X} {f : U \u27f6 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 \u2964 T` with cone point `X`. -/\n@[simps]\ndef forgetCone (X : T) : Limits.Cone (forget X) :=\n  { pt\n    \u03c0 := { app := Comma.hom } }\n#align category_theory.under.forget_cone CategoryTheory.Under.forgetCone\n-/\n\n#print CategoryTheory.Under.map /-\n/-- A morphism `X \u27f6 Y` induces a functor `under Y \u2964 under X` in the obvious way. -/\ndef map {Y : T} (f : X \u27f6 Y) : Under Y \u2964 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 \u27f6 Y} {U V : Under Y} {g : U \u27f6 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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem map_obj_hom : ((map f).obj U).Hom = f \u226b 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\u2093'. -/\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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\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 \u226b g` is the same as mapping by `f` then by `g`. -/\ndef mapComp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map g \u22d9 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    \u27e8\u27e8under.hom_mk (inv ((under.forget X).map f)) ((is_iso.comp_inv_eq _).2 (under.w f).symm), by\n        tidy\u27e9\u27e9\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 \u27f6 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 \u27f6 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 \u27f6 g) [Epi k] : Epi k.right :=\n  by\n  refine' \u27e8fun (Y : T) l m a => _\u27e9\n  let l' : g \u27f6 mk (g.hom \u226b m) :=\n    hom_mk l\n      (by\n        dsimp\n        rw [\u2190 under.w k, category.assoc, a, category.assoc])\n  suffices l' = hom_mk m by apply congr_arg comma_morphism.right this\n  rw [\u2190 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\u2082} [Category.{v\u2082} 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\u2093'. -/\n/-- A functor `F : T \u2964 D` induces a functor `under X \u2964 under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T \u2964 D) : Under X \u2964 Under (F.obj X)\n    where\n  obj Y := mk <| F.map Y.Hom\n  map Y\u2081 Y\u2082 f := Under.homMk (F.map f.right) (by tidy <;> erw [\u2190 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''' {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (s: set (set \u03b1))\n  (A:s.is_algebra)\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 (measurable_space.generate_from s)}\n  {X\u2082:P\u2082 \u2192\u1d63 (measurable_space.generate_from s)}:\n  (\u2200 (T:measurable_setB (measurable_space.generate_from s)), \n   T.val \u2208 s \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  random_variable_identical X\u2081 X\u2082 :=\nbegin\n  intros h3 U,\n  cases U,\n  have AM := A.monotone_class,\n  have h7:\u2200 {T':set \u03b1}, s.monotone_class T' \u2192\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:(\u2200\u1d63 i, X\u2081 \u2208\u1d63 \u27e8f i, h7 (h_rec i)\u27e9) = (X\u2081 \u2208\u1d63 \u27e8set.Inter f, U_property\u27e9) ,\n    { apply event.eq, simp, ext \u03c9, split; intros h6_1; simp at h6_1; simp [h6_1], },\n    rw \u2190 h6,\n    have h7:(\u2200\u1d63 i, X\u2082 \u2208\u1d63 \u27e8f i, h7 (h_rec i)\u27e9) = (X\u2082 \u2208\u1d63 \u27e8set.Inter f, U_property\u27e9) ,\n    { apply event.eq, simp, ext \u03c9, split; intros h7_1; simp at h7_1; simp [h7_1], },\n    rw \u2190 h7,\n    rw Pr_forall_revent_eq_infi,\n    rw Pr_forall_revent_eq_infi,\n    have h8:(\u03bb (i : \u2115), Pr[X\u2081 \u2208\u1d63 \u27e8f i, _\u27e9]) = \u03bb (i : \u2115), Pr[X\u2082 \u2208\u1d63 \u27e8f i, _\u27e9],\n    { ext1 i, apply h_ind, \n      rw \u2190 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:(\u2203\u1d63 i, X\u2081 \u2208\u1d63 \u27e8f i, h7 (h_rec i)\u27e9) = (X\u2081 \u2208\u1d63 \u27e8set.Union f, U_property\u27e9) ,\n    { apply event.eq, simp, ext \u03c9, split; intros h9_1; simp at h9_1; simp [h9_1], },\n    rw \u2190 h9,\n    have h10:(\u2203\u1d63 i, X\u2082 \u2208\u1d63 \u27e8f i, h7 (h_rec i)\u27e9) = (X\u2082 \u2208\u1d63 \u27e8set.Union f, U_property\u27e9) ,\n    { apply event.eq, simp, ext \u03c9, split; intros h10_1; simp at h10_1; simp [h10_1] },\n    rw \u2190 h10,\n    rw Pr_exists_revent_eq_supr,\n    rw Pr_exists_revent_eq_supr,\n    have h11:(\u03bb (i : \u2115), Pr[X\u2081 \u2208\u1d63 \u27e8f i, _\u27e9]) = \u03bb (i : \u2115), Pr[X\u2082 \u2208\u1d63 \u27e8f i, _\u27e9],\n    { ext1 i, apply h_ind, \n      rw \u2190 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 {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (s: set (set \u03b1))\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 (measurable_space.generate_from s)}\n  {X\u2082:P\u2082 \u2192\u1d63 (measurable_space.generate_from s)}:\n  (set.univ \u2208 s) \u2192\n  (\u2200 a b, a\u2208 s \u2192 b \u2208 s \u2192 a \\ b \u2208 s) \u2192\n  (\u2200 (T:measurable_setB (measurable_space.generate_from s)), \n   T.val \u2208 s \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  random_variable_identical X\u2081 X\u2082 :=\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' {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (s: set (set \u03b1))\n  (M:measurable_space \u03b1)\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 M}\n  {X\u2082:P\u2082 \u2192\u1d63 M}:\n  (set.univ \u2208 s) \u2192\n  (\u2200 a b, a\u2208 s \u2192 b \u2208 s \u2192 a \\ b \u2208 s) \u2192\n  (M = measurable_space.generate_from s) \u2192\n  (\u2200 (T:measurable_setB M), \n   T.val \u2208 s \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  random_variable_identical X\u2081 X\u2082 :=\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'' {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (s t: set (set \u03b1))\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 (measurable_space.generate_from t)}\n  {X\u2082:P\u2082 \u2192\u1d63 (measurable_space.generate_from t)}:\n  (set.univ \u2208 s) \u2192\n  (\u2200 a b, a\u2208 s \u2192 b \u2208 s \u2192 a \\ b \u2208 s) \u2192\n  (t \u2286 s) \u2192\n  (\u2200 a\u2208 s, (measurable_space.generate_from t).measurable_set' a) \u2192\n  (\u2200 (T:measurable_setB (measurable_space.generate_from t)), \n   T.val \u2208 s \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  random_variable_identical X\u2081 X\u2082 :=\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 {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (S : set (set \u03b1))\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 (measurable_space.generate_from S)}\n  {X\u2082:P\u2082 \u2192\u1d63 (measurable_space.generate_from S)}:\n  (\u2200 (T:measurable_setB (measurable_space.generate_from S)), \n   T.val \u2208 S \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  (\u2200 (T:measurable_setB (measurable_space.generate_from S)),\n   T.val \u2208 S.disjoint_union_closure \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 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\u2081 \u2208\u1d63 \u27e8set.Union f, T_property\u27e9 = (eany (\u03bb (i:fin m), X\u2081 \u2208\u1d63 \u27e8f i, \n             measurable_space.measurable_set_generate_from (h_f i)\u27e9)),\n    { apply event.eq, ext \u03c9, 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\u2082 \u2208\u1d63 \u27e8set.Union f, T_property\u27e9 = (eany (\u03bb (i:fin m), X\u2082 \u2208\u1d63 \u27e8f i, \n             measurable_space.measurable_set_generate_from (h_f i)\u27e9)),\n    { apply event.eq, ext \u03c9, 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''' {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (S : set (set \u03b1))\n  (A:S.is_semialgebra)\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 (measurable_space.generate_from S)}\n  {X\u2082:P\u2082 \u2192\u1d63 (measurable_space.generate_from S)}:\n  (\u2200 (T:measurable_setB (measurable_space.generate_from S)), \n   T.val \u2208 S \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  random_variable_identical X\u2081 X\u2082 :=\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 {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (S : set (set \u03b1))\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 (measurable_space.generate_from S)}\n  {X\u2082:P\u2082 \u2192\u1d63 (measurable_space.generate_from S)}:\n  (\u2200 s t\u2208 S, s \u2229 t \u2208 S) \u2192\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n  (@set.univ \u03b1 \u2208 S) \u2192\n  (\u2200 (T:measurable_setB (measurable_space.generate_from S)), \n   T.val \u2208 S \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  random_variable_identical X\u2081 X\u2082 :=\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' {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (S : set (set \u03b1))\n  (M:measurable_space \u03b1)\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 M}\n  {X\u2082:P\u2082 \u2192\u1d63 M}:\n  (\u2200 s t\u2208 S, s \u2229 t \u2208 S) \u2192\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n  (set.univ \u2208 S) \u2192\n  (M = measurable_space.generate_from S) \u2192\n  (\u2200 (T:measurable_setB M), \n   T.val \u2208 S \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  random_variable_identical X\u2081 X\u2082 :=\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'' {\u03a9\u2081 \u03a9\u2082 \u03b1:Type*} (s t: set (set \u03b1))\n  {P\u2081:probability_space \u03a9\u2081} {P\u2082:probability_space \u03a9\u2082} \n  {X\u2081:P\u2081 \u2192\u1d63 (measurable_space.generate_from t)}\n  {X\u2082:P\u2082 \u2192\u1d63 (measurable_space.generate_from t)}:\n  (\u2200 a b\u2208 s, a \u2229 b \u2208 s) \u2192\n  (\u2200 a \u2208 s, a\u1d9c \u2208 s.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 s) \u2192\n  (set.univ \u2208 s) \u2192\n  (t \u2286 s) \u2192\n  (\u2200 a\u2208 s, (measurable_space.generate_from t).measurable_set' a) \u2192\n  (\u2200 (T:measurable_setB (measurable_space.generate_from t)), \n   T.val \u2208 s \u2192 Pr[X\u2081 \u2208\u1d63 T] = Pr[X\u2082 \u2208\u1d63 T]) \u2192 \n  random_variable_identical X\u2081 X\u2082 :=\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 `*`, `+`, `-`, `^`, `\u2264`.\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 \u00d7 expr) :=\ndo (c, ai) \u2190 c.get ``has_add,\n   return (c, (expr.const ``bit0 [c.univ]).mk_app [c.\u03b1, ai, e])\n\n/-- Faster version of `mk_app ``bit1 [e]`. -/\nmeta def mk_bit1 (c : instance_cache) (e : expr) : tactic (instance_cache \u00d7 expr) :=\ndo (c, ai) \u2190 c.get ``has_add,\n   (c, oi) \u2190 c.get ``has_one,\n   return (c, (expr.const ``bit1 [c.univ]).mk_app [c.\u03b1, 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 {\u03b1 : Type u}\n\nlemma subst_into_add {\u03b1} [has_add \u03b1] (l r tl tr t)\n  (prl : (l : \u03b1) = tl) (prr : r = tr) (prt : tl + tr = t) : l + r = t :=\nby rw [prl, prr, prt]\n\nlemma subst_into_mul {\u03b1} [has_mul \u03b1] (l r tl tr t)\n  (prl : (l : \u03b1) = tl) (prr : r = tr) (prt : tl * tr = t) : l * r = t :=\nby rw [prl, prr, prt]\n\nlemma subst_into_neg {\u03b1} [has_neg \u03b1] (a ta t : \u03b1) (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 \u2192 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 {\u03b1} [semiring \u03b1] : (0 + 1 : \u03b1) = 1 := zero_add _\ntheorem one_succ {\u03b1} [semiring \u03b1] : (1 + 1 : \u03b1) = 2 := rfl\ntheorem bit0_succ {\u03b1} [semiring \u03b1] (a : \u03b1) : bit0 a + 1 = bit1 a := rfl\ntheorem bit1_succ {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : bit1 a + 1 = bit0 b :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\n\nsection\nopen match_numeral_result\n\n/-- Given `a`, `b` natural numerals, proves `\u22a2 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 \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 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, \u22a2 a + 1 = b)`. -/\nmeta def prove_succ' (c : instance_cache) (a : expr) : tactic (instance_cache \u00d7 expr \u00d7 expr) :=\ndo na \u2190 a.to_nat,\n  (c, b) \u2190 c.of_nat (na + 1),\n  (c, p) \u2190 prove_succ c a b,\n  return (c, b, p)\n\ntheorem zero_adc {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : 0 + a + 1 = b := by rwa zero_add\ntheorem adc_zero {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : a + 0 + 1 = b := by rwa add_zero\ntheorem one_add {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : 1 + a = b := by rwa add_comm\ntheorem add_bit0_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b = c) : bit0 a + bit0 b = bit0 c :=\nh \u25b8 by simp [bit0, add_left_comm, add_assoc]\ntheorem add_bit0_bit1 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b = c) : bit0 a + bit1 b = bit1 c :=\nh \u25b8 by simp [bit0, bit1, add_left_comm, add_assoc]\ntheorem add_bit1_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b = c) : bit1 a + bit0 b = bit1 c :=\nh \u25b8 by simp [bit0, bit1, add_left_comm, add_comm, add_assoc]\ntheorem add_bit1_bit1 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b + 1 = c) : bit1 a + bit1 b = bit0 c :=\nh \u25b8 by simp [bit0, bit1, add_left_comm, add_comm, add_assoc]\ntheorem adc_one_one {\u03b1} [semiring \u03b1] : (1 + 1 + 1 : \u03b1) = 3 := rfl\ntheorem adc_bit0_one {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : bit0 a + 1 + 1 = bit0 b :=\nh \u25b8 by simp [bit0, add_left_comm, add_assoc]\ntheorem adc_one_bit0 {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : 1 + bit0 a + 1 = bit0 b :=\nh \u25b8 by simp [bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_one {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : bit1 a + 1 + 1 = bit1 b :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_one_bit1 {\u03b1} [semiring \u03b1] (a b : \u03b1) (h : a + 1 = b) : 1 + bit1 a + 1 = bit1 b :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit0_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b = c) : bit0 a + bit0 b + 1 = bit1 c :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b + 1 = c) :\n  bit1 a + bit0 b + 1 = bit0 c :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit0_bit1 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b + 1 = c) :\n  bit0 a + bit1 b + 1 = bit0 c :=\nh \u25b8 by simp [bit1, bit0, add_left_comm, add_assoc]\ntheorem adc_bit1_bit1 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a + b + 1 = c) :\n  bit1 a + bit1 b + 1 = bit1 c :=\nh \u25b8 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 \u2192 expr \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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 \u2192 expr \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 expr)\n| c a b r := do\n  match match_numeral a, match_numeral b with\n  | zero, _ := do (c, p) \u2190 prove_succ c b r, c.mk_app ``zero_adc [b, r, p]\n  | _, zero := do (c, p) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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 `\u22a2 a + b = r`. -/\nadd_decl_doc prove_add_nat\n/-- Given `a`,`b`,`r` natural numerals, proves `\u22a2 a + b + 1 = r`. -/\nadd_decl_doc prove_adc_nat\n\n/-- Given `a`,`b` natural numerals, returns `(r, \u22a2 a + b = r)`. -/\nmeta def prove_add_nat' (c : instance_cache) (a b : expr) : tactic (instance_cache \u00d7 expr \u00d7 expr) :=\ndo na \u2190 a.to_nat,\n  nb \u2190 b.to_nat,\n  (c, r) \u2190 c.of_nat (na + nb),\n  (c, p) \u2190 prove_add_nat c a b r,\n  return (c, r, p)\n\nend\n\ntheorem bit0_mul {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a * b = c) :\n  bit0 a * b = bit0 c := h \u25b8 by simp [bit0, add_mul]\ntheorem mul_bit0' {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a * b = c) :\n  a * bit0 b = bit0 c := h \u25b8 by simp [bit0, mul_add]\ntheorem mul_bit0_bit0 {\u03b1} [semiring \u03b1] (a b c : \u03b1) (h : a * b = c) :\n  bit0 a * bit0 b = bit0 (bit0 c) := bit0_mul _ _ _ (mul_bit0' _ _ _ h)\ntheorem mul_bit1_bit1 {\u03b1} [semiring \u03b1] (a b c d e : \u03b1)\n  (hc : a * b = c) (hd : a + b = d) (he : bit0 c + d = e) :\n  bit1 a * bit1 b = bit1 e :=\nby rw [\u2190 he, \u2190 hd, \u2190 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, \u22a2 a * b = r)`. -/\nmeta def prove_mul_nat : instance_cache \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 expr \u00d7 expr)\n| ic a b :=\n  match match_numeral a, match_numeral b with\n  | zero, _ := do\n    (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``zero_mul [b],\n    return (ic, z, p)\n  | _, zero := do\n    (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``mul_zero [a],\n    return (ic, z, p)\n  | one, _ := do (ic, p) \u2190 ic.mk_app ``one_mul [b], return (ic, b, p)\n  | _, one := do (ic, p) \u2190 ic.mk_app ``mul_one [a], return (ic, a, p)\n  | bit0 a, bit0 b := do\n    (ic, c, p) \u2190 prove_mul_nat ic a b,\n    (ic, p) \u2190 ic.mk_app ``mul_bit0_bit0 [a, b, c, p],\n    (ic, c') \u2190 ic.mk_bit0 c,\n    (ic, c') \u2190 ic.mk_bit0 c',\n    return (ic, c', p)\n  | bit0 a, _ := do\n    (ic, c, p) \u2190 prove_mul_nat ic a b,\n    (ic, p) \u2190 ic.mk_app ``bit0_mul [a, b, c, p],\n    (ic, c') \u2190 ic.mk_bit0 c,\n    return (ic, c', p)\n  | _, bit0 b := do\n    (ic, c, p) \u2190 prove_mul_nat ic a b,\n    (ic, p) \u2190 ic.mk_app ``mul_bit0' [a, b, c, p],\n    (ic, c') \u2190 ic.mk_bit0 c,\n    return (ic, c', p)\n  | bit1 a, bit1 b := do\n    (ic, c, pc) \u2190 prove_mul_nat ic a b,\n    (ic, d, pd) \u2190 prove_add_nat' ic a b,\n    (ic, c') \u2190 ic.mk_bit0 c,\n    (ic, e, pe) \u2190 prove_add_nat' ic c' d,\n    (ic, p) \u2190 ic.mk_app ``mul_bit1_bit1 [a, b, c, d, e, pc, pd, pe],\n    (ic, e') \u2190 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 `\u22a2 0 < a`. -/\nmeta def prove_pos_nat (c : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| e :=\n  match match_numeral e with\n  | one := c.mk_app ``zero_lt_one' []\n  | bit0 e := do (c, p) \u2190 prove_pos_nat e, c.mk_app ``bit0_pos [e, p]\n  | bit1 e := do (c, p) \u2190 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 `\u22a2 0 < a`. -/\nmeta def prove_pos (c : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| `(%%e\u2081 / %%e\u2082) := do\n  (c, p\u2081) \u2190 prove_pos_nat c e\u2081, (c, p\u2082) \u2190 prove_pos_nat c e\u2082,\n  c.mk_app ``div_pos [e\u2081, e\u2082, p\u2081, p\u2082]\n| e := prove_pos_nat c e\n\n/-- `match_neg (- e) = some e`, otherwise `none` -/\nmeta def match_neg : expr \u2192 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 \u2192 expr \u2295 bool\n| `(- %%e) := sum.inl e\n| `(has_zero.zero) := sum.inr ff\n| _ := sum.inr tt\n\ntheorem ne_zero_of_pos {\u03b1} [ordered_add_comm_group \u03b1] (a : \u03b1) : 0 < a \u2192 a \u2260 0 := ne_of_gt\ntheorem ne_zero_neg {\u03b1} [add_group \u03b1] (a : \u03b1) : a \u2260 0 \u2192 -a \u2260 0 := mt neg_eq_zero.1\n\n/-- Given `a` a rational numeral, returns `\u22a2 a \u2260 0`. -/\nmeta def prove_ne_zero' (c : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| a :=\n  match match_neg a with\n  | some a := do (c, p) \u2190 prove_ne_zero' a, c.mk_app ``ne_zero_neg [a, p]\n  | none := do (c, p) \u2190 prove_pos c a, c.mk_app ``ne_zero_of_pos [a, p]\n  end\n\ntheorem clear_denom_div {\u03b1} [division_ring \u03b1] (a b b' c d : \u03b1)\n  (h\u2080 : b \u2260 0) (h\u2081 : b * b' = d) (h\u2082 : a * b' = c) : (a / b) * d = c :=\nby rwa [\u2190 h\u2081, \u2190 mul_assoc, div_mul_cancel _ h\u2080]\n\n/-- Given `a` nonnegative rational and `d` a natural number, returns `(b, \u22a2 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 \u2192 expr \u2192 \u211a \u2192 tactic (instance_cache \u00d7 expr))\n  (c : instance_cache) (a d : expr) (na : \u211a) (nd : \u2115) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nif na.denom = 1 then\n  prove_mul_nat c a d\nelse do\n  [_, _, a, b] \u2190 return a.get_app_args,\n  (c, b') \u2190 c.of_nat (nd / na.denom),\n  (c, p\u2080) \u2190 prove_ne_zero c b (rat.of_int na.denom),\n  (c, _, p\u2081) \u2190 prove_mul_nat c b b',\n  (c, r, p\u2082) \u2190 prove_mul_nat c a b',\n  (c, p) \u2190 c.mk_app ``clear_denom_div [a, b, b', r, d, p\u2080, p\u2081, p\u2082],\n  return (c, r, p)\n\ntheorem nonneg_pos {\u03b1} [ordered_cancel_add_comm_monoid \u03b1] (a : \u03b1) : 0 < a \u2192 0 \u2264 a := le_of_lt\n\ntheorem lt_one_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) (h : 1 \u2264 a) : 1 < bit0 a :=\nlt_of_lt_of_le one_lt_two (bit0_le_bit0.2 h)\ntheorem lt_one_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) (h : 0 < a) : 1 < bit1 a :=\none_lt_bit1.2 h\ntheorem lt_bit0_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a < b \u2192 bit0 a < bit0 b :=\nbit0_lt_bit0.2\ntheorem lt_bit0_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a \u2264 b) : bit0 a < bit1 b :=\nlt_of_le_of_lt (bit0_le_bit0.2 h) (lt_add_one _)\ntheorem lt_bit1_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a + 1 \u2264 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 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a < b \u2192 bit1 a < bit1 b :=\nbit1_lt_bit1.2\n\ntheorem le_one_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) (h : 1 \u2264 a) : 1 \u2264 bit0 a :=\nle_of_lt (lt_one_bit0 _ h)\n-- deliberately strong hypothesis because bit1 0 is not a numeral\ntheorem le_one_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) (h : 0 < a) : 1 \u2264 bit1 a :=\nle_of_lt (lt_one_bit1 _ h)\ntheorem le_bit0_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a \u2264 b \u2192 bit0 a \u2264 bit0 b :=\nbit0_le_bit0.2\ntheorem le_bit0_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a \u2264 b) : bit0 a \u2264 bit1 b :=\nle_of_lt (lt_bit0_bit1 _ _ h)\ntheorem le_bit1_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a + 1 \u2264 b) : bit1 a \u2264 bit0 b :=\nle_of_lt (lt_bit1_bit0 _ _ h)\ntheorem le_bit1_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a \u2264 b \u2192 bit1 a \u2264 bit1 b :=\nbit1_le_bit1.2\n\ntheorem sle_one_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) : 1 \u2264 a \u2192 1 + 1 \u2264 bit0 a :=\nbit0_le_bit0.2\ntheorem sle_one_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a : \u03b1) : 1 \u2264 a \u2192 1 + 1 \u2264 bit1 a :=\nle_bit0_bit1 _ _\ntheorem sle_bit0_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) : a + 1 \u2264 b \u2192 bit0 a + 1 \u2264 bit0 b :=\nle_bit1_bit0 _ _\ntheorem sle_bit0_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a \u2264 b) : bit0 a + 1 \u2264 bit1 b :=\nbit1_le_bit1.2 h\ntheorem sle_bit1_bit0 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a + 1 \u2264 b) :\n  bit1 a + 1 \u2264 bit0 b :=\n(bit1_succ a _ rfl).symm \u25b8 bit0_le_bit0.2 h\ntheorem sle_bit1_bit1 {\u03b1} [linear_ordered_semiring \u03b1] (a b : \u03b1) (h : a + 1 \u2264 b) :\n  bit1 a + 1 \u2264 bit1 b :=\n(bit1_succ a _ rfl).symm \u25b8 le_bit0_bit1 _ _ h\n\n/-- Given `a` a rational numeral, returns `\u22a2 0 \u2264 a`. -/\nmeta def prove_nonneg (ic : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| e@`(has_zero.zero) := ic.mk_app ``le_refl [e]\n| e :=\n  if ic.\u03b1 = `(\u2115) then\n    return (ic, `(nat.zero_le).mk_app [e])\n  else do\n    (ic, p) \u2190 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 `\u22a2 1 \u2264 a`. -/\nmeta def prove_one_le_nat (ic : instance_cache) : expr \u2192 tactic (instance_cache \u00d7 expr)\n| a :=\n  match match_numeral a with\n  | one := ic.mk_app ``le_refl [a]\n  | bit0 a := do (ic, p) \u2190 prove_one_le_nat a, ic.mk_app ``le_one_bit0 [a, p]\n  | bit1 a := do (ic, p) \u2190 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 \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 prove_one_le_nat ic b, ic.mk_app ``le_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) \u2190 prove_pos_nat ic b, ic.mk_app ``le_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) \u2190 prove_le_nat a b, ic.mk_app ``le_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) \u2190 prove_le_nat a b, ic.mk_app ``le_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) \u2190 prove_sle_nat a b, ic.mk_app ``le_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) \u2190 prove_le_nat a b, ic.mk_app ``le_bit1_bit1 [a, b, p]\n  | _, _ := failed\n  end\nwith prove_sle_nat : expr \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 prove_one_le_nat ic b, ic.mk_app ``sle_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) \u2190 prove_one_le_nat ic b, ic.mk_app ``sle_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) \u2190 prove_sle_nat a b, ic.mk_app ``sle_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) \u2190 prove_le_nat a b, ic.mk_app ``sle_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) \u2190 prove_sle_nat a b, ic.mk_app ``sle_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) \u2190 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 `\u22a2 a \u2264 b`. -/\nadd_decl_doc prove_le_nat\n/-- Given `a`,`b` natural numerals, proves `\u22a2 a + 1 \u2264 b`. -/\nadd_decl_doc prove_sle_nat\n\n/-- Given `a`,`b` natural numerals, proves `\u22a2 a < b`. -/\nmeta def prove_lt_nat (ic : instance_cache) : expr \u2192 expr \u2192 tactic (instance_cache \u00d7 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) \u2190 prove_one_le_nat ic b, ic.mk_app ``lt_one_bit0 [b, p]\n  | one, bit1 b := do (ic, p) \u2190 prove_pos_nat ic b, ic.mk_app ``lt_one_bit1 [b, p]\n  | bit0 a, bit0 b := do (ic, p) \u2190 prove_lt_nat a b, ic.mk_app ``lt_bit0_bit0 [a, b, p]\n  | bit0 a, bit1 b := do (ic, p) \u2190 prove_le_nat ic a b, ic.mk_app ``lt_bit0_bit1 [a, b, p]\n  | bit1 a, bit0 b := do (ic, p) \u2190 prove_sle_nat ic a b, ic.mk_app ``lt_bit1_bit0 [a, b, p]\n  | bit1 a, bit1 b := do (ic, p) \u2190 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 {\u03b1} [linear_ordered_semiring \u03b1] (a a' b b' d : \u03b1)\n  (h\u2080 : 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\u2080)\n\n/-- Given `a`,`b` nonnegative rational numerals, proves `\u22a2 a < b`. -/\nmeta def prove_lt_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nif na.denom = 1 \u2227 nb.denom = 1 then\n  prove_lt_nat ic a b\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) \u2190 ic.of_nat nd,\n  (ic, p\u2080) \u2190 prove_pos ic d,\n  (ic, a', pa) \u2190 prove_clear_denom' (\u03bb ic e _, prove_ne_zero' ic e) ic a d na nd,\n  (ic, b', pb) \u2190 prove_clear_denom' (\u03bb ic e _, prove_ne_zero' ic e) ic b d nb nd,\n  (ic, p) \u2190 prove_lt_nat ic a' b',\n  ic.mk_app ``clear_denom_lt [a, a', b, b', d, p\u2080, pa, pb, p]\n\nlemma lt_neg_pos {\u03b1} [ordered_add_comm_group \u03b1] (a b : \u03b1) (ha : 0 < a) (hb : 0 < b) : -a < b :=\nlt_trans (neg_neg_of_pos ha) hb\n\n/-- Given `a`,`b` rational numerals, proves `\u22a2 a < b`. -/\nmeta def prove_lt_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 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 \u2194 -b < -a`\n  (ic, p) \u2190 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) \u2190 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) \u2190 prove_pos ic a,\n  (ic, pb) \u2190 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 {\u03b1} [linear_ordered_semiring \u03b1] (a a' b b' d : \u03b1)\n  (h\u2080 : 0 < d) (ha : a * d = a') (hb : b * d = b') (h : a' \u2264 b') : a \u2264 b :=\nle_of_mul_le_mul_right (by rwa [ha, hb]) h\u2080\n\n/-- Given `a`,`b` nonnegative rational numerals, proves `\u22a2 a \u2264 b`. -/\nmeta def prove_le_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nif na.denom = 1 \u2227 nb.denom = 1 then\n  prove_le_nat ic a b\nelse do\n  let nd := na.denom.lcm nb.denom,\n  (ic, d) \u2190 ic.of_nat nd,\n  (ic, p\u2080) \u2190 prove_pos ic d,\n  (ic, a', pa) \u2190 prove_clear_denom' (\u03bb ic e _, prove_ne_zero' ic e) ic a d na nd,\n  (ic, b', pb) \u2190 prove_clear_denom' (\u03bb ic e _, prove_ne_zero' ic e) ic b d nb nd,\n  (ic, p) \u2190 prove_le_nat ic a' b',\n  ic.mk_app ``clear_denom_le [a, a', b, b', d, p\u2080, pa, pb, p]\n\nlemma le_neg_pos {\u03b1} [ordered_add_comm_group \u03b1] (a b : \u03b1) (ha : 0 \u2264 a) (hb : 0 \u2264 b) : -a \u2264 b :=\nle_trans (neg_nonpos_of_nonneg ha) hb\n\n/-- Given `a`,`b` rational numerals, proves `\u22a2 a \u2264 b`. -/\nmeta def prove_le_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  (ic, p) \u2190 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) \u2190 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) \u2190 prove_nonneg ic a,\n  (ic, pb) \u2190 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 `\u22a2 a \u2260 b`. This version tries to prove\n`\u22a2 a < b` or `\u22a2 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 : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nif na < nb then do\n  (ic, p) \u2190 prove_lt_rat ic a b na nb,\n  ic.mk_app ``ne_of_lt [a, b, p]\nelse do\n  (ic, p) \u2190 prove_lt_rat ic b a nb na,\n  ic.mk_app ``ne_of_gt [a, b, p]\n\ntheorem nat_cast_zero {\u03b1} [semiring \u03b1] : \u2191(0 : \u2115) = (0 : \u03b1) := nat.cast_zero\ntheorem nat_cast_one {\u03b1} [semiring \u03b1] : \u2191(1 : \u2115) = (1 : \u03b1) := nat.cast_one\ntheorem nat_cast_bit0 {\u03b1} [semiring \u03b1] (a : \u2115) (a' : \u03b1) (h : \u2191a = a') : \u2191(bit0 a) = bit0 a' :=\nh \u25b8 nat.cast_bit0 _\ntheorem nat_cast_bit1 {\u03b1} [semiring \u03b1] (a : \u2115) (a' : \u03b1) (h : \u2191a = a') : \u2191(bit1 a) = bit1 a' :=\nh \u25b8 nat.cast_bit1 _\ntheorem int_cast_zero {\u03b1} [ring \u03b1] : \u2191(0 : \u2124) = (0 : \u03b1) := int.cast_zero\ntheorem int_cast_one {\u03b1} [ring \u03b1] : \u2191(1 : \u2124) = (1 : \u03b1) := int.cast_one\ntheorem int_cast_bit0 {\u03b1} [ring \u03b1] (a : \u2124) (a' : \u03b1) (h : \u2191a = a') : \u2191(bit0 a) = bit0 a' :=\nh \u25b8 int.cast_bit0 _\ntheorem int_cast_bit1 {\u03b1} [ring \u03b1] (a : \u2124) (a' : \u03b1) (h : \u2191a = a') : \u2191(bit1 a) = bit1 a' :=\nh \u25b8 int.cast_bit1 _\ntheorem rat_cast_bit0 {\u03b1} [division_ring \u03b1] [char_zero \u03b1] (a : \u211a) (a' : \u03b1) (h : \u2191a = a') :\n  \u2191(bit0 a) = bit0 a' :=\nh \u25b8 rat.cast_bit0 _\ntheorem rat_cast_bit1 {\u03b1} [division_ring \u03b1] [char_zero \u03b1] (a : \u211a) (a' : \u03b1) (h : \u2191a = a') :\n  \u2191(bit1 a) = bit1 a' :=\nh \u25b8 rat.cast_bit1 _\n\n/-- Given `a' : \u03b1` a natural numeral, returns `(a : \u2115, \u22a2 \u2191a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_nat_uncast (ic nc : instance_cache) : \u2200 (a' : expr),\n  tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (nc, e) \u2190 nc.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``nat_cast_zero [],\n    return (ic, nc, e, p)\n  | match_numeral_result.one := do\n    (nc, e) \u2190 nc.mk_app ``has_one.one [],\n    (ic, p) \u2190 ic.mk_app ``nat_cast_one [],\n    return (ic, nc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, nc, a, p) \u2190 prove_nat_uncast a',\n    (nc, a0) \u2190 nc.mk_bit0 a,\n    (ic, p) \u2190 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) \u2190 prove_nat_uncast a',\n    (nc, a1) \u2190 nc.mk_bit1 a,\n    (ic, p) \u2190 ic.mk_app ``nat_cast_bit1 [a, a', p],\n    return (ic, nc, a1, p)\n  | _ := failed\n  end\n\n/-- Given `a' : \u03b1` a natural numeral, returns `(a : \u2124, \u22a2 \u2191a = a')`.\n(Note that the returned value is on the left of the equality.) -/\nmeta def prove_int_uncast_nat (ic zc : instance_cache) : \u2200 (a' : expr),\n  tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (zc, e) \u2190 zc.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``int_cast_zero [],\n    return (ic, zc, e, p)\n  | match_numeral_result.one := do\n    (zc, e) \u2190 zc.mk_app ``has_one.one [],\n    (ic, p) \u2190 ic.mk_app ``int_cast_one [],\n    return (ic, zc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, zc, a, p) \u2190 prove_int_uncast_nat a',\n    (zc, a0) \u2190 zc.mk_bit0 a,\n    (ic, p) \u2190 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) \u2190 prove_int_uncast_nat a',\n    (zc, a1) \u2190 zc.mk_bit1 a,\n    (ic, p) \u2190 ic.mk_app ``int_cast_bit1 [a, a', p],\n    return (ic, zc, a1, p)\n  | _ := failed\n  end\n\n/-- Given `a' : \u03b1` a natural numeral, returns `(a : \u211a, \u22a2 \u2191a = 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) : \u2200 (a' : expr),\n  tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr)\n| a' :=\n  match match_numeral a' with\n  | match_numeral_result.zero := do\n    (qc, e) \u2190 qc.mk_app ``has_zero.zero [],\n    (ic, p) \u2190 ic.mk_app ``rat.cast_zero [],\n    return (ic, qc, e, p)\n  | match_numeral_result.one := do\n    (qc, e) \u2190 qc.mk_app ``has_one.one [],\n    (ic, p) \u2190 ic.mk_app ``rat.cast_one [],\n    return (ic, qc, e, p)\n  | match_numeral_result.bit0 a' := do\n    (ic, qc, a, p) \u2190 prove_rat_uncast_nat a',\n    (qc, a0) \u2190 qc.mk_bit0 a,\n    (ic, p) \u2190 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) \u2190 prove_rat_uncast_nat a',\n    (qc, a1) \u2190 qc.mk_bit1 a,\n    (ic, p) \u2190 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 {\u03b1} [division_ring \u03b1] [char_zero \u03b1] (a b : \u211a) (a' b' : \u03b1)\n  (ha : \u2191a = a') (hb : \u2191b = b') : \u2191(a / b) = a' / b' :=\nha \u25b8 hb \u25b8 rat.cast_div _ _\n\n/-- Given `a' : \u03b1` a nonnegative rational numeral, returns `(a : \u211a, \u22a2 \u2191a = 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' : \u211a) :\n tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr) :=\nif na'.denom = 1 then\n  prove_rat_uncast_nat ic qc cz_inst a'\nelse do\n  [_, _, a', b'] \u2190 return a'.get_app_args,\n  (ic, qc, a, pa) \u2190 prove_rat_uncast_nat ic qc cz_inst a',\n  (ic, qc, b, pb) \u2190 prove_rat_uncast_nat ic qc cz_inst b',\n  (qc, e) \u2190 qc.mk_app ``has_div.div [a, b],\n  (ic, p) \u2190 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 {\u03b1} [ring \u03b1] (a : \u2124) (a' : \u03b1) (h : \u2191a = a') : \u2191-a = -a' :=\nh \u25b8 int.cast_neg _\ntheorem rat_cast_neg {\u03b1} [division_ring \u03b1] (a : \u211a) (a' : \u03b1) (h : \u2191a = a') : \u2191-a = -a' :=\nh \u25b8 rat.cast_neg _\n\n/-- Given `a' : \u03b1` an integer numeral, returns `(a : \u2124, \u22a2 \u2191a = 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 \u00d7 instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_neg a' with\n| some a' := do\n  (ic, zc, a, p) \u2190 prove_int_uncast_nat ic zc a',\n  (zc, e) \u2190 zc.mk_app ``has_neg.neg [a],\n  (ic, p) \u2190 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' : \u03b1` a rational numeral, returns `(a : \u211a, \u22a2 \u2191a = 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' : \u211a) :\n  tactic (instance_cache \u00d7 instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_neg a' with\n| some a' := do\n  (ic, qc, a, p) \u2190 prove_rat_uncast_nonneg ic qc cz_inst a' (-na'),\n  (qc, e) \u2190 qc.mk_app ``has_neg.neg [a],\n  (ic, p) \u2190 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 {\u03b1} [semiring \u03b1] [char_zero \u03b1] (a b : \u2115) (a' b' : \u03b1)\n  (ha : \u2191a = a') (hb : \u2191b = b') (h : a \u2260 b) : a' \u2260 b' :=\nha \u25b8 hb \u25b8 mt nat.cast_inj.1 h\ntheorem int_cast_ne {\u03b1} [ring \u03b1] [char_zero \u03b1] (a b : \u2124) (a' b' : \u03b1)\n  (ha : \u2191a = a') (hb : \u2191b = b') (h : a \u2260 b) : a' \u2260 b' :=\nha \u25b8 hb \u25b8 mt int.cast_inj.1 h\ntheorem rat_cast_ne {\u03b1} [division_ring \u03b1] [char_zero \u03b1] (a b : \u211a) (a' b' : \u03b1)\n  (ha : \u2191a = a') (hb : \u2191b = b') (h : a \u2260 b) : a' \u2260 b' :=\nha \u25b8 hb \u25b8 mt rat.cast_inj.1 h\n\n/-- Given `a`,`b` rational numerals, proves `\u22a2 a \u2260 b`. Currently it tries two methods:\n\n  * Prove `\u22a2 a < b` or `\u22a2 b < a`, if the base type has an order\n  * Embed `\u2191(a':\u211a) = a` and `\u2191(b':\u211a) = b`, and then prove `a' \u2260 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 `\u211a` is well defined.\n\nWe may also add coercions to `\u2124` and `\u2115` as well in order to support `char_zero`\nrings and semirings. -/\nmeta def prove_ne : instance_cache \u2192 expr \u2192 expr \u2192 \u211a \u2192 \u211a \u2192 tactic (instance_cache \u00d7 expr)\n| ic a b na nb := prove_ne_rat ic a b na nb <|> do\n  cz_inst \u2190 mk_mapp ``char_zero [ic.\u03b1, none, none] >>= mk_instance,\n  if na.denom = 1 \u2227 nb.denom = 1 then\n    if na \u2265 0 \u2227 nb \u2265 0 then do\n      guard (ic.\u03b1 \u2260 `(\u2115)),\n      nc \u2190 mk_instance_cache `(\u2115),\n      (ic, nc, a', pa) \u2190 prove_nat_uncast ic nc a,\n      (ic, nc, b', pb) \u2190 prove_nat_uncast ic nc b,\n      (nc, p) \u2190 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.\u03b1 \u2260 `(\u2124)),\n      zc \u2190 mk_instance_cache `(\u2124),\n      (ic, zc, a', pa) \u2190 prove_int_uncast ic zc a,\n      (ic, zc, b', pb) \u2190 prove_int_uncast ic zc b,\n      (zc, p) \u2190 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.\u03b1 \u2260 `(\u211a)),\n    qc \u2190 mk_instance_cache `(\u211a),\n    (ic, qc, a', pa) \u2190 prove_rat_uncast ic qc cz_inst a na,\n    (ic, qc, b', pb) \u2190 prove_rat_uncast ic qc cz_inst b nb,\n    (qc, p) \u2190 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 `\u22a2 a \u2260 0`. -/\nmeta def prove_ne_zero (ic : instance_cache) : expr \u2192 \u211a \u2192 tactic (instance_cache \u00d7 expr)\n| a na := do\n  (ic, z) \u2190 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, \u22a2 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 \u2192 expr \u2192 expr \u2192 \u211a \u2192 \u2115 \u2192\n  tactic (instance_cache \u00d7 expr \u00d7 expr) := prove_clear_denom' prove_ne_zero\n\ntheorem clear_denom_add {\u03b1} [division_ring \u03b1] (a a' b b' c c' d : \u03b1)\n  (h\u2080 : d \u2260 0) (ha : a * d = a') (hb : b * d = b') (hc : c * d = c')\n  (h : a' + b' = c') : a + b = c :=\nmul_right_cancel\u2080 h\u2080 $ by rwa [add_mul, ha, hb, hc]\n\n/-- Given `a`,`b`,`c` nonnegative rational numerals, returns `\u22a2 a + b = c`. -/\nmeta def prove_add_nonneg_rat (ic : instance_cache) (a b c : expr) (na nb nc : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nif na.denom = 1 \u2227 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) \u2190 ic.of_nat nd,\n  (ic, p\u2080) \u2190 prove_ne_zero ic d (rat.of_int nd),\n  (ic, a', pa) \u2190 prove_clear_denom ic a d na nd,\n  (ic, b', pb) \u2190 prove_clear_denom ic b d nb nd,\n  (ic, c', pc) \u2190 prove_clear_denom ic c d nc nd,\n  (ic, p) \u2190 prove_add_nat ic a' b' c',\n  ic.mk_app ``clear_denom_add [a, a', b, b', c, c', d, p\u2080, pa, pb, pc, p]\n\ntheorem add_pos_neg_pos {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : c + b = a) : a + -b = c :=\nh \u25b8 by simp\ntheorem add_pos_neg_neg {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : c + a = b) : a + -b = -c :=\nh \u25b8 by simp\ntheorem add_neg_pos_pos {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : a + c = b) : -a + b = c :=\nh \u25b8 by simp\ntheorem add_neg_pos_neg {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : b + c = a) : -a + b = -c :=\nh \u25b8 by simp\ntheorem add_neg_neg {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : b + a = c) : -a + -b = -c :=\nh \u25b8 by simp\n\n/-- Given `a`,`b`,`c` rational numerals, returns `\u22a2 a + b = c`. -/\nmeta def prove_add_rat (ic : instance_cache) (ea eb ec : expr) (a b c : \u211a) :\n  tactic (instance_cache \u00d7 expr) :=\nmatch match_neg ea, match_neg eb, match_neg ec with\n| some ea, some eb, some ec := do\n  (ic, p) \u2190 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) \u2190 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) \u2190 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) \u2190 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) \u2190 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, \u22a2 a + b = c)`. -/\nmeta def prove_add_rat' (ic : instance_cache) (a b : expr) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\ndo na \u2190 a.to_rat,\n  nb \u2190 b.to_rat,\n  let nc := na + nb,\n  (ic, c) \u2190 ic.of_rat nc,\n  (ic, p) \u2190 prove_add_rat ic a b c na nb nc,\n  return (ic, c, p)\n\ntheorem clear_denom_simple_nat {\u03b1} [division_ring \u03b1] (a : \u03b1) :\n  (1:\u03b1) \u2260 0 \u2227 a * 1 = a := \u27e8one_ne_zero, mul_one _\u27e9\ntheorem clear_denom_simple_div {\u03b1} [division_ring \u03b1] (a b : \u03b1) (h : b \u2260 0) :\n  b \u2260 0 \u2227 a / b * b = a := \u27e8h, div_mul_cancel _ h\u27e9\n\n/-- Given `a` a nonnegative rational numeral, returns `(b, c, \u22a2 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 : \u211a) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr \u00d7 expr) :=\nif na.denom = 1 then do\n  (c, d) \u2190 c.mk_app ``has_one.one [],\n  (c, p) \u2190 c.mk_app ``clear_denom_simple_nat [a],\n  return (c, d, a, p)\nelse do\n  [\u03b1, _, a, b] \u2190 return a.get_app_args,\n  (c, p\u2080) \u2190 prove_ne_zero c b (rat.of_int na.denom),\n  (c, p) \u2190 c.mk_app ``clear_denom_simple_div [a, b, p\u2080],\n  return (c, b, a, p)\n\ntheorem clear_denom_mul {\u03b1} [field \u03b1] (a a' b b' c c' d\u2081 d\u2082 d : \u03b1)\n  (ha : d\u2081 \u2260 0 \u2227 a * d\u2081 = a') (hb : d\u2082 \u2260 0 \u2227 b * d\u2082 = b')\n  (hc : c * d = c') (hd : d\u2081 * d\u2082 = d)\n  (h : a' * b' = c') : a * b = c :=\nmul_right_cancel\u2080 ha.1 $ mul_right_cancel\u2080 hb.1 $\nby rw [mul_assoc c, hd, hc, \u2190 h, \u2190 ha.2, \u2190 hb.2, \u2190 mul_assoc, mul_right_comm a]\n\n/-- Given `a`,`b` nonnegative rational numerals, returns `(c, \u22a2 a * b = c)`. -/\nmeta def prove_mul_nonneg_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nif na.denom = 1 \u2227 nb.denom = 1 then\n  prove_mul_nat ic a b\nelse do\n  let nc := na * nb, (ic, c) \u2190 ic.of_rat nc,\n  (ic, d\u2081, a', pa) \u2190 prove_clear_denom_simple ic a na,\n  (ic, d\u2082, b', pb) \u2190 prove_clear_denom_simple ic b nb,\n  (ic, d, pd) \u2190 prove_mul_nat ic d\u2081 d\u2082, nd \u2190 d.to_nat,\n  (ic, c', pc) \u2190 prove_clear_denom ic c d nc nd,\n  (ic, _, p) \u2190 prove_mul_nat ic a' b',\n  (ic, p) \u2190 ic.mk_app ``clear_denom_mul [a, a', b, b', c, c', d\u2081, d\u2082, d, pa, pb, pc, pd, p],\n  return (ic, c, p)\n\ntheorem mul_neg_pos {\u03b1} [ring \u03b1] (a b c : \u03b1) (h : a * b = c) : -a * b = -c := h \u25b8 by simp\ntheorem mul_pos_neg {\u03b1} [ring \u03b1] (a b c : \u03b1) (h : a * b = c) : a * -b = -c := h \u25b8 by simp\ntheorem mul_neg_neg {\u03b1} [ring \u03b1] (a b c : \u03b1) (h : a * b = c) : -a * -b = c := h \u25b8 by simp\n\n/-- Given `a`,`b` rational numerals, returns `(c, \u22a2 a * b = c)`. -/\nmeta def prove_mul_rat (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_sign a, match_sign b with\n| sum.inl a, sum.inl b := do\n  (ic, c, p) \u2190 prove_mul_nonneg_rat ic a b (-na) (-nb),\n  (ic, p) \u2190 ic.mk_app ``mul_neg_neg [a, b, c, p],\n  return (ic, c, p)\n| sum.inr ff, _ := do\n  (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n  (ic, p) \u2190 ic.mk_app ``zero_mul [b],\n  return (ic, z, p)\n| _, sum.inr ff := do\n  (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n  (ic, p) \u2190 ic.mk_app ``mul_zero [a],\n  return (ic, z, p)\n| sum.inl a, sum.inr tt := do\n  (ic, c, p) \u2190 prove_mul_nonneg_rat ic a b (-na) nb,\n  (ic, p) \u2190 ic.mk_app ``mul_neg_pos [a, b, c, p],\n  (ic, c') \u2190 ic.mk_app ``has_neg.neg [c],\n  return (ic, c', p)\n| sum.inr tt, sum.inl b := do\n  (ic, c, p) \u2190 prove_mul_nonneg_rat ic a b na (-nb),\n  (ic, p) \u2190 ic.mk_app ``mul_pos_neg [a, b, c, p],\n  (ic, c') \u2190 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 {\u03b1} [division_ring \u03b1] (a b : \u03b1) (h : a\u207b\u00b9 = b) : (-a)\u207b\u00b9 = -b :=\nh \u25b8 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, \u22a2 a\u207b\u00b9 = b)`. -/\nmeta def prove_inv : instance_cache \u2192 expr \u2192 \u211a \u2192 tactic (instance_cache \u00d7 expr \u00d7 expr)\n| ic e n :=\n  match match_sign e with\n  | sum.inl e := do\n    (ic, e', p) \u2190 prove_inv ic e (-n),\n    (ic, r) \u2190 ic.mk_app ``has_neg.neg [e'],\n    (ic, p) \u2190 ic.mk_app ``inv_neg [e, e', p],\n    return (ic, r, p)\n  | sum.inr ff := do\n    (ic, p) \u2190 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) \u2190 ic.mk_app ``inv_one [],\n        return (ic, e, p)\n      else do\n        let e := e.app_arg,\n        (ic, p) \u2190 ic.mk_app ``inv_one_div [e],\n        return (ic, e, p)\n    else if n.denom = 1 then do\n      (ic, p) \u2190 ic.mk_app ``inv_div_one [e],\n      e \u2190 infer_type p,\n      return (ic, e.app_arg, p)\n    else do\n      [_, _, a, b] \u2190 return e.get_app_args,\n      (ic, e') \u2190 ic.mk_app ``has_div.div [b, a],\n      (ic, p) \u2190 ic.mk_app ``inv_div [a, b],\n      return (ic, e', p)\n  end\n\ntheorem div_eq {\u03b1} [division_ring \u03b1] (a b b' c : \u03b1)\n  (hb : b\u207b\u00b9 = b') (h : a * b' = c) : a / b = c :=\nby rwa [ \u2190 hb, \u2190 div_eq_mul_inv] at h\n\n/-- Given `a`,`b` rational numerals, returns `(c, \u22a2 a / b = c)`. -/\nmeta def prove_div (ic : instance_cache) (a b : expr) (na nb : \u211a) :\n  tactic (instance_cache \u00d7 expr \u00d7 expr) :=\ndo (ic, b', pb) \u2190 prove_inv ic b nb,\n  (ic, c, p) \u2190 prove_mul_rat ic a b' na nb\u207b\u00b9,\n  (ic, p) \u2190 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, \u22a2 -a = b)`. -/\nmeta def prove_neg (ic : instance_cache) (a : expr) : tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_sign a with\n| sum.inl a := do\n  (ic, p) \u2190 ic.mk_app ``neg_neg [a],\n  return (ic, a, p)\n| sum.inr ff := do\n  (ic, p) \u2190 ic.mk_app ``neg_zero [],\n  return (ic, a, p)\n| sum.inr tt := do\n  (ic, a') \u2190 ic.mk_app ``has_neg.neg [a],\n  p \u2190 mk_eq_refl a',\n  return (ic, a', p)\nend\n\ntheorem sub_pos {\u03b1} [add_group \u03b1] (a b b' c : \u03b1) (hb : -b = b') (h : a + b' = c) : a - b = c :=\nby rwa [\u2190 hb, \u2190 sub_eq_add_neg] at h\n\ntheorem sub_neg {\u03b1} [add_group \u03b1] (a b c : \u03b1) (h : a + b = c) : a - -b = c :=\nby rwa sub_neg_eq_add\n\n/-- Given `a`,`b` rational numerals, returns `(c, \u22a2 a - b = c)`. -/\nmeta def prove_sub (ic : instance_cache) (a b : expr) : tactic (instance_cache \u00d7 expr \u00d7 expr) :=\nmatch match_sign b with\n| sum.inl b := do\n  (ic, c, p) \u2190 prove_add_rat' ic a b,\n  (ic, p) \u2190 ic.mk_app ``sub_neg [a, b, c, p],\n  return (ic, c, p)\n| sum.inr ff := do\n  (ic, p) \u2190 ic.mk_app ``sub_zero [a],\n  return (ic, a, p)\n| sum.inr tt := do\n  (ic, b', pb) \u2190 prove_neg ic b,\n  (ic, c, p) \u2190 prove_add_rat' ic a b',\n  (ic, p) \u2190 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 : \u2115) (h : b + c = a) : a - b = c :=\nh \u25b8 add_tsub_cancel_left _ _\ntheorem sub_nat_neg (a b c : \u2115) (h : a + c = b) : a - b = 0 :=\ntsub_eq_zero_iff_le.mpr $ h \u25b8 nat.le_add_right _ _\n\n/-- Given `a : nat`,`b : nat` natural numerals, returns `(c, \u22a2 a - b = c)`. -/\nmeta def prove_sub_nat (ic : instance_cache) (a b : expr) : tactic (expr \u00d7 expr) :=\ndo na \u2190 a.to_nat, nb \u2190 b.to_nat,\n  if nb \u2264 na then do\n    (ic, c) \u2190 ic.of_nat (na - nb),\n    (ic, p) \u2190 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) \u2190 ic.of_nat (nb - na),\n    (ic, p) \u2190 prove_add_nat ic a c b,\n    return (`(0 : \u2115), `(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 \u2192 tactic (expr \u00d7 expr)\n| `(%%e\u2081 + %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  let n\u2083 := n\u2081 + n\u2082,\n  (c, e\u2083) \u2190 c.of_rat n\u2083,\n  (_, p) \u2190 prove_add_rat c e\u2081 e\u2082 e\u2083 n\u2081 n\u2082 n\u2083,\n  return (e\u2083, p)\n| `(%%e\u2081 * %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  prod.snd <$> prove_mul_rat c e\u2081 e\u2082 n\u2081 n\u2082\n| `(- %%e) := do\n  c \u2190 infer_type e >>= mk_instance_cache,\n  prod.snd <$> prove_neg c e\n| `(@has_sub.sub %%\u03b1 %%inst %%a %%b) := do\n  c \u2190 mk_instance_cache \u03b1,\n  if \u03b1 = `(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 \u2190 e.to_rat,\n  c \u2190 infer_type e >>= mk_instance_cache,\n  prod.snd <$> prove_inv c e n\n| `(%%e\u2081 / %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  prod.snd <$> prove_div c e\u2081 e\u2082 n\u2081 n\u2082\n| _ := failed\n\nlemma pow_bit0 [monoid \u03b1] (a c' c : \u03b1) (b : \u2115)\n  (h : a ^ b = c') (h\u2082 : c' * c' = c) : a ^ bit0 b = c :=\nh\u2082 \u25b8 by simp [pow_bit0, h]\n\nlemma pow_bit1 [monoid \u03b1] (a c\u2081 c\u2082 c : \u03b1) (b : \u2115)\n  (h : a ^ b = c\u2081) (h\u2082 : c\u2081 * c\u2081 = c\u2082) (h\u2083 : c\u2082 * a = c) : a ^ bit1 b = c :=\nby rw [\u2190 h\u2083, \u2190 h\u2082]; simp [pow_bit1, h]\n\nsection\nopen match_numeral_result\n\n/-- Given `a` a rational numeral and `b : nat`, returns `(c, \u22a2 a ^ b = c)`. -/\nmeta def prove_pow (a : expr) (na : \u211a) :\n  instance_cache \u2192 expr \u2192 tactic (instance_cache \u00d7 expr \u00d7 expr)\n| ic b :=\n  match match_numeral b with\n  | zero := do\n    (ic, p) \u2190 ic.mk_app ``pow_zero [a],\n    (ic, o) \u2190 ic.mk_app ``has_one.one [],\n    return (ic, o, p)\n  | one := do\n    (ic, p) \u2190 ic.mk_app ``pow_one [a],\n    return (ic, a, p)\n  | bit0 b := do\n    (ic, c', p) \u2190 prove_pow ic b,\n    nc' \u2190 expr.to_rat c',\n    (ic, c, p\u2082) \u2190 prove_mul_rat ic c' c' nc' nc',\n    (ic, p) \u2190 ic.mk_app ``pow_bit0 [a, c', c, b, p, p\u2082],\n    return (ic, c, p)\n  | bit1 b := do\n    (ic, c\u2081, p) \u2190 prove_pow ic b,\n    nc\u2081 \u2190 expr.to_rat c\u2081,\n    (ic, c\u2082, p\u2082) \u2190 prove_mul_rat ic c\u2081 c\u2081 nc\u2081 nc\u2081,\n    (ic, c, p\u2083) \u2190 prove_mul_rat ic c\u2082 a (nc\u2081 * nc\u2081) na,\n    (ic, p) \u2190 ic.mk_app ``pow_bit1 [a, c\u2081, c\u2082, c, b, p, p\u2082, p\u2083],\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 \u2192 tactic (expr \u00d7 expr)\n| `(@has_pow.pow %%\u03b1 _ %%m %%e\u2081 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  match m with\n  | `(@monoid.has_pow %%_ %%_) := prod.snd <$> prove_pow e\u2081 n\u2081 c e\u2082\n  | _ := failed\n  end\n| `(monoid.npow %%e\u2081 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  prod.snd <$> prove_pow e\u2081 n\u2081 c e\u2082\n| _ := failed\n\n/-- Given `\u22a2 p`, returns `(true, \u22a2 p = true)`. -/\nmeta def true_intro (p : expr) : tactic (expr \u00d7 expr) :=\nprod.mk `(true) <$> mk_app ``eq_true_intro [p]\n\n/-- Given `\u22a2 \u00ac p`, returns `(false, \u22a2 p = false)`. -/\nmeta def false_intro (p : expr) : tactic (expr \u00d7 expr) :=\nprod.mk `(false) <$> mk_app ``eq_false_intro [p]\n\ntheorem not_refl_false_intro {\u03b1} (a : \u03b1) : (a \u2260 a) = false :=\neq_false_intro $ not_not_intro rfl\n\n/-- Evaluates the inequality operations `=`,`<`,`>`,`\u2264`,`\u2265`,`\u2260` on numerals. -/\nmeta def eval_ineq : expr \u2192 tactic (expr \u00d7 expr)\n| `(%%e\u2081 < %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 < n\u2082 then\n    do (_, p) \u2190 prove_lt_rat c e\u2081 e\u2082 n\u2081 n\u2082, true_intro p\n  else if n\u2081 = n\u2082 then do\n    (_, p) \u2190 c.mk_app ``lt_irrefl [e\u2081],\n    false_intro p\n  else do\n    (c, p') \u2190 prove_lt_rat c e\u2082 e\u2081 n\u2082 n\u2081,\n    (_, p) \u2190 c.mk_app ``not_lt_of_gt [e\u2081, e\u2082, p'],\n    false_intro p\n| `(%%e\u2081 \u2264 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 \u2264 n\u2082 then do\n    (_, p) \u2190\n      if n\u2081 = n\u2082 then c.mk_app ``le_refl [e\u2081]\n      else prove_le_rat c e\u2081 e\u2082 n\u2081 n\u2082,\n    true_intro p\n  else do\n    (c, p) \u2190 prove_lt_rat c e\u2082 e\u2081 n\u2082 n\u2081,\n    (_, p) \u2190 c.mk_app ``not_le_of_gt [e\u2081, e\u2082, p],\n    false_intro p\n| `(%%e\u2081 = %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 = n\u2082 then mk_eq_refl e\u2081 >>= true_intro\n  else do (_, p) \u2190 prove_ne c e\u2081 e\u2082 n\u2081 n\u2082, false_intro p\n| `(%%e\u2081 > %%e\u2082) := mk_app ``has_lt.lt [e\u2082, e\u2081] >>= eval_ineq\n| `(%%e\u2081 \u2265 %%e\u2082) := mk_app ``has_le.le [e\u2082, e\u2081] >>= eval_ineq\n| `(%%e\u2081 \u2260 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 = n\u2082 then\n    prod.mk `(false) <$> mk_app ``not_refl_false_intro [e\u2081]\n  else do (_, p) \u2190 prove_ne c e\u2081 e\u2082 n\u2081 n\u2082, true_intro p\n| _ := failed\n\ntheorem nat_succ_eq (a b c : \u2115) (h\u2081 : a = b) (h\u2082 : b + 1 = c) : nat.succ a = c := by rwa h\u2081\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 \u2192 tactic (instance_cache \u00d7 \u2115 \u00d7 expr \u00d7 expr)\n| `(nat.succ %%a) := do\n  (ic, n, b, p\u2081) \u2190 prove_nat_succ a,\n  let n' := n + 1,\n  (ic, c) \u2190 ic.of_nat n',\n  (ic, p\u2082) \u2190 prove_add_nat ic b `(1) c,\n  return (ic, n', c, `(nat_succ_eq).mk_app [a, b, c, p\u2081, p\u2082])\n| e := do\n  n \u2190 e.to_nat,\n  p \u2190 mk_eq_refl e,\n  return (ic, n, e, p)\n\nlemma nat_div (a b q r m : \u2115) (hm : q * b = m) (h : r + m = a) (h\u2082 : r < b) : a / b = q :=\nby rw [\u2190 h, \u2190 hm, nat.add_mul_div_right _ _ (lt_of_le_of_lt (nat.zero_le _) h\u2082),\n       nat.div_eq_of_lt h\u2082, zero_add]\n\nlemma int_div (a b q r m : \u2124) (hm : q * b = m) (h : r + m = a) (h\u2081 : 0 \u2264 r) (h\u2082 : r < b) :\n  a / b = q :=\nby rw [\u2190 h, \u2190 hm, int.add_mul_div_right _ _ (ne_of_gt (lt_of_le_of_lt h\u2081 h\u2082)),\n       int.div_eq_zero_of_lt h\u2081 h\u2082, zero_add]\n\nlemma nat_mod (a b q r m : \u2115) (hm : q * b = m) (h : r + m = a) (h\u2082 : r < b) : a % b = r :=\nby rw [\u2190 h, \u2190 hm, nat.add_mul_mod_self_right, nat.mod_eq_of_lt h\u2082]\n\nlemma int_mod (a b q r m : \u2124) (hm : q * b = m) (h : r + m = a) (h\u2081 : 0 \u2264 r) (h\u2082 : r < b) :\n  a % b = r :=\nby rw [\u2190 h, \u2190 hm, int.add_mul_mod_self, int.mod_eq_of_lt h\u2081 h\u2082]\n\nlemma int_div_neg (a b c' c : \u2124) (h : a / b = c') (h\u2082 : -c' = c) : a / -b = c :=\nh\u2082 \u25b8 h \u25b8 int.div_neg _ _\n\nlemma int_mod_neg (a b c : \u2124) (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, \u22a2 a / b = c)`\n  * `prove_div_mod ic a b tt` returns `(c, \u22a2 a % b = c)`\n-/\nmeta def prove_div_mod (ic : instance_cache) :\n  expr \u2192 expr \u2192 bool \u2192 tactic (instance_cache \u00d7 expr \u00d7 expr)\n| a b mod :=\n  match match_neg b with\n  | some b := do\n    (ic, c', p) \u2190 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\u2082) \u2190 prove_neg ic c',\n      return (ic, c, `(int_div_neg).mk_app [a, b, c', c, p, p\u2082])\n  | none := do\n    nb \u2190 b.to_nat,\n    na \u2190 a.to_int,\n    let nq := na / nb,\n    let nr := na % nb,\n    let nm := nq * nr,\n    (ic, q) \u2190 ic.of_int nq,\n    (ic, r) \u2190 ic.of_int nr,\n    (ic, m, pm) \u2190 prove_mul_rat ic q b (rat.of_int nq) (rat.of_int nb),\n    (ic, p) \u2190 prove_add_rat ic r m a (rat.of_int nr) (rat.of_int nm) (rat.of_int na),\n    (ic, p') \u2190 prove_lt_nat ic r b,\n    if ic.\u03b1 = `(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.\u03b1 = `(int) then do\n      (ic, p\u2080) \u2190 prove_nonneg ic r,\n      if mod then return (ic, r, `(int_mod).mk_app [a, b, q, r, m, pm, p, p\u2080, p'])\n      else        return (ic, q, `(int_div).mk_app [a, b, q, r, m, pm, p, p\u2080, p'])\n    else failed\n  end\n\ntheorem dvd_eq_nat (a b c : \u2115) (p) (h\u2081 : b % a = c) (h\u2082 : (c = 0) = p) : (a \u2223 b) = p :=\n(propext $ by rw [\u2190 h\u2081, nat.dvd_iff_mod_eq_zero]).trans h\u2082\ntheorem dvd_eq_int (a b c : \u2124) (p) (h\u2081 : b % a = c) (h\u2082 : (c = 0) = p) : (a \u2223 b) = p :=\n(propext $ by rw [\u2190 h\u2081, int.dvd_iff_mod_eq_zero]).trans h\u2082\n\ntheorem int_to_nat_pos (a : \u2124) (b : \u2115) (h : (by haveI := @nat.cast_coe \u2124; exact b : \u2124) = a) :\n  a.to_nat = b := by rw \u2190 h; simp\ntheorem int_to_nat_neg (a : \u2124) (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 : \u2124) (b : \u2115) (h : (by haveI := @nat.cast_coe \u2124; exact b : \u2124) = a) :\n  a.nat_abs = b := by rw \u2190 h; simp\ntheorem nat_abs_neg (a : \u2124) (b : \u2115) (h : (by haveI := @nat.cast_coe \u2124; exact b : \u2124) = a) :\n  (-a).nat_abs = b := by rw \u2190 h; simp\n\ntheorem neg_succ_of_nat (a b : \u2115) (c : \u2124) (h\u2081 : a + 1 = b)\n  (h\u2082 : (by haveI := @nat.cast_coe \u2124; exact b : \u2124) = c) :\n  -[1+ a] = -c := by rw [\u2190 h\u2082, \u2190 h\u2081, int.nat_cast_eq_coe_nat]; refl\n\n/-- Evaluates some extra numeric operations on `nat` and `int`, specifically\n`nat.succ`, `/` and `%`, and `\u2223` (divisibility). -/\nmeta def eval_nat_int_ext : expr \u2192 tactic (expr \u00d7 expr)\n| e@`(nat.succ _) := do\n  ic \u2190 mk_instance_cache `(\u2115),\n  (_, _, ep) \u2190 prove_nat_succ ic e,\n  return ep\n| `(%%a / %%b) := do\n  c \u2190 infer_type a >>= mk_instance_cache,\n  prod.snd <$> prove_div_mod c a b ff\n| `(%%a % %%b) := do\n  c \u2190 infer_type a >>= mk_instance_cache,\n  prod.snd <$> prove_div_mod c a b tt\n| `(%%a \u2223 %%b) := do\n  \u03b1 \u2190 infer_type a,\n  ic \u2190 mk_instance_cache \u03b1,\n  th \u2190 if \u03b1 = `(nat) then return (`(dvd_eq_nat):expr) else\n       if \u03b1 = `(int) then return `(dvd_eq_int) else failed,\n  (ic, c, p\u2081) \u2190 prove_div_mod ic b a tt,\n  (ic, z) \u2190 ic.mk_app ``has_zero.zero [],\n  (e', p\u2082) \u2190 mk_app ``eq [c, z] >>= eval_ineq,\n  return (e', th.mk_app [a, b, c, e', p\u2081, p\u2082])\n| `(int.to_nat %%a) := do\n  n \u2190 a.to_int,\n  ic \u2190 mk_instance_cache `(\u2124),\n  if n \u2265 0 then do\n    nc \u2190 mk_instance_cache `(\u2115),\n    (_, _, b, p) \u2190 prove_nat_uncast ic nc a,\n    pure (b, `(int_to_nat_pos).mk_app [a, b, p])\n  else do\n    a \u2190 match_neg a,\n    (_, p) \u2190 prove_pos ic a,\n    pure (`(0), `(int_to_nat_neg).mk_app [a, p])\n| `(int.nat_abs %%a) := do\n  n \u2190 a.to_int,\n  ic \u2190 mk_instance_cache `(\u2124),\n  nc \u2190 mk_instance_cache `(\u2115),\n  if n \u2265 0 then do\n    (_, _, b, p) \u2190 prove_nat_uncast ic nc a,\n    pure (b, `(nat_abs_pos).mk_app [a, b, p])\n  else do\n    a \u2190 match_neg a,\n    (_, _, b, p) \u2190 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 \u2190 a.to_nat,\n  ic \u2190 mk_instance_cache `(\u2124),\n  nc \u2190 mk_instance_cache `(\u2115),\n  let nb := na + 1,\n  (nc, b) \u2190 nc.of_nat nb,\n  (nc, p\u2081) \u2190 prove_add_nat nc a `(1) b,\n  (ic, c) \u2190 ic.of_nat nb,\n  (_, _, _, p\u2082) \u2190 prove_nat_uncast ic nc c,\n  pure (`(-%%c : \u2124), `(neg_succ_of_nat).mk_app [a, b, c, p\u2081, p\u2082])\n| _ := failed\n\ntheorem int_to_nat_cast (a : \u2115) (b : \u2124)\n  (h : (by haveI := @nat.cast_coe \u2124; exact a : \u2124) = b) :\n  \u2191a = b := eq.trans (by simp) h\n\n/-- Evaluates the `\u2191n` cast operation from `\u2115`, `\u2124`, `\u211a` to an arbitrary type `\u03b1`. -/\nmeta def eval_cast : expr \u2192 tactic (expr \u00d7 expr)\n| `(@coe \u2115 %%\u03b1 %%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 \u2190 a.to_nat,\n      ic \u2190 mk_instance_cache \u03b1,\n      nc \u2190 mk_instance_cache `(\u2115),\n      (ic, b) \u2190 ic.of_nat n,\n      (_, _, _, p) \u2190 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 \u2190 a.to_int,\n      ic \u2190 mk_instance_cache \u03b1,\n      zc \u2190 mk_instance_cache `(\u2124),\n      (ic, b) \u2190 ic.of_int n,\n      (_, _, _, p) \u2190 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 \u2190 a.to_rat,\n      cz_inst \u2190 mk_mapp ``char_zero [\u03b1, none, none] >>= mk_instance,\n      ic \u2190 mk_instance_cache \u03b1,\n      qc \u2190 mk_instance_cache `(\u211a),\n        (ic, b) \u2190 ic.of_rat n,\n      (_, _, _, p) \u2190 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 \u2190 a.to_nat,\n    ic \u2190 mk_instance_cache `(\u2124),\n    nc \u2190 mk_instance_cache `(\u2115),\n    (ic, b) \u2190 ic.of_nat n,\n    (_, _, _, p) \u2190 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 \u00d7 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 \u2192 tactic (expr \u00d7 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 \u2192 tactic (expr \u00d7 expr)) unit :=\n{ name      := `norm_num,\n  descr     := \"Add norm_num derivers\",\n  cache_cfg :=\n  { mk_cache := \u03bb ns, do\n    { t \u2190 ns.mfoldl\n        (\u03bb (t : expr \u2192 tactic (expr \u00d7 expr)) n, do\n          t' \u2190 eval_expr (expr \u2192 tactic (expr \u00d7 expr)) (expr.const n []),\n          pure (\u03bb e, t' e <|> t e))\n        (\u03bb _, failed),\n      pure (\u03bb 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 \u2192 tactic (expr \u00d7 expr)) := norm_num.attr.get_cache\n\n/-- Simplify an expression bottom-up using `step` to simplify the subexpressions. -/\nmeta def derive' (step : expr \u2192 tactic (expr \u00d7 expr))\n  : expr \u2192 tactic (expr \u00d7 expr) | e :=\ndo e \u2190 instantiate_mvars e,\n   (_, e', pr) \u2190\n    ext_simplify_core () {} simp_lemmas.mk (\u03bb _, failed) (\u03bb _ _ _ _ _, failed)\n      (\u03bb _ _ _ _ e,\n        do (new_e, pr) \u2190 step e,\n           guard (\u00ac new_e =\u2090 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 \u00d7 expr) := do f \u2190 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 \u2192 tactic (expr \u00d7 expr))\n  (loc : interactive.loc) : tactic unit :=\ndo ns \u2190 loc.get_locals,\n   success \u2190 tactic.replace_at (norm_num.derive' step) ns loc.include_goal,\n   when loc.include_goal $ try tactic.triv,\n   when (\u00ac 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 \u2192 tactic (expr \u00d7 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 \u2190 get_step, tactic.norm_num1 f loc\n\n/-- Normalize numerical expressions. Supports the operations\n`+` `-` `*` `/` `^` and `%` over numerical types such as\n`\u2115`, `\u2124`, `\u211a`, `\u211d`, `\u2102` and some general algebraic types,\nand can prove goals of the form `A = B`, `A \u2260 B`, `A < B` and `A \u2264 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 \u2190 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\u2081 \u2190 to_expr x,\n  (x\u2082,_) \u2190 derive x\u2081,\n  tactic.exact x\u2082\n\n/--\nNormalises numerical expressions. It supports the operations `+` `-` `*` `/` `^` and `%` over\nnumerical types such as `\u2115`, `\u2124`, `\u211a`, `\u211d`, `\u2102`, and can prove goals of the form `A = B`, `A \u2260 B`,\n`A < B` and `A \u2264 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 : \u211d) + 2 = 4 := by norm_num\nexample : (12345.2 : \u211d) \u2260 12345.3 := by norm_num\nexample : (73 : \u211d) < 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 : \u00ac nat.prime (2^11 - 1) := by norm_num\nexample (x : \u211d) (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 : \u2115 := 2^100\n#print a -- 2 ^ 100\n\ndef normed_a : \u2115 := 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`\u2115`, `\u2124`, `\u211a`, `\u211d`, `\u2102` and some general algebraic types,\nand can prove goals of the form `A = B`, `A \u2260 B`, `A < B` and `A \u2264 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\u00f6lzl, 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 \u00d7 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 \u00d7 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 \u00d7 S \u2192+* R`, `snd R S : R \u00d7 S \u2192+* S`: projections `prod.fst` and `prod.snd`\n  as `ring_hom`s;\n* `f.prod g : `R \u2192+* S \u00d7 T`: sends `x` to `(f x, g x)`;\n* `f.prod_map g : `R \u00d7 S \u2192 R' \u00d7 S'`: `prod.map f g` as a `ring_hom`,\n  sends `(x, y)` to `(f x, g y)`.\n-/\n\n\nvariable {\u03b1 \u03b2 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 \u00d7 S) :=\n  { Prod.hasAdd,\n    Prod.hasMul with\n    left_distrib := fun a b c => mk.inj_iff.mpr \u27e8left_distrib _ _ _, left_distrib _ _ _\u27e9\n    right_distrib := fun a b c => mk.inj_iff.mpr \u27e8right_distrib _ _ _, right_distrib _ _ _\u27e9 }\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 \u00d7 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 \u00d7 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 \u00d7 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 \u00d7 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 \u00d7 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 \u00d7 S) :=\n  { Prod.semiring, Prod.commMonoid with }\n\ninstance [NonUnitalNonAssocRing R] [NonUnitalNonAssocRing S] : NonUnitalNonAssocRing (R \u00d7 S) :=\n  { Prod.addCommGroup, Prod.nonUnitalNonAssocSemiring with }\n\ninstance [NonUnitalRing R] [NonUnitalRing S] : NonUnitalRing (R \u00d7 S) :=\n  { Prod.addCommGroup, Prod.nonUnitalSemiring with }\n\ninstance [NonAssocRing R] [NonAssocRing S] : NonAssocRing (R \u00d7 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 \u00d7 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 \u00d7 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 \u00d7 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\u2093'. -/\n/-- Given non-unital semirings `R`, `S`, the natural projection homomorphism from `R \u00d7 S` to `R`.-/\ndef fst : R \u00d7 S \u2192\u2099+* 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\u2093'. -/\n/-- Given non-unital semirings `R`, `S`, the natural projection homomorphism from `R \u00d7 S` to `S`.-/\ndef snd : R \u00d7 S \u2192\u2099+* 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 (\u1fb0 : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => R) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_fst : \u21d1(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 (\u1fb0 : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => S) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_snd : \u21d1(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 \u2192\u2099+* S) (g : R \u2192\u2099+* 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\u2093'. -/\n/-- Combine two non-unital ring homomorphisms `f : R \u2192\u2099+* S`, `g : R \u2192\u2099+* T` into\n`f.prod g : R \u2192\u2099+* S \u00d7 T` given by `(f.prod g) x = (f x, g x)` -/\nprotected def prod (f : R \u2192\u2099+* S) (g : R \u2192\u2099+* T) : R \u2192\u2099+* S \u00d7 T :=\n  { MulHom.prod (f : MulHom R S) (g : MulHom R T), AddMonoidHom.prod (f : R \u2192+ S) (g : R \u2192+ 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\ntheorem prod_unique (f : R \u2192\u2099+* S \u00d7 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 \u2192\u2099+* R') (g : S \u2192\u2099+* 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\u2093'. -/\n/-- `prod.map` as a `non_unital_ring_hom`. -/\ndef prodMap : R \u00d7 S \u2192\u2099+* R' \u00d7 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\u2093'. -/\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 (\u1fb0 : Prod.{u4, u2} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u4, u2} R S) => Prod.{u3, u1} R' S') \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_prodMap : \u21d1(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\u2093'. -/\ntheorem prod_comp_prodMap (f : T \u2192\u2099+* R) (g : T \u2192\u2099+* S) (f' : R \u2192\u2099+* R') (g' : S \u2192\u2099+* 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\u2093'. -/\n/-- Given semirings `R`, `S`, the natural projection homomorphism from `R \u00d7 S` to `R`.-/\ndef fst : R \u00d7 S \u2192+* 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\u2093'. -/\n/-- Given semirings `R`, `S`, the natural projection homomorphism from `R \u00d7 S` to `S`.-/\ndef snd : R \u00d7 S \u2192+* 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 (\u1fb0 : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => R) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_fst : \u21d1(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 (\u1fb0 : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u2, u1} R S) => S) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_snd : \u21d1(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 \u2192+* S) (g : R \u2192+* 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\u2093'. -/\n/-- Combine two ring homomorphisms `f : R \u2192+* S`, `g : R \u2192+* T` into `f.prod g : R \u2192+* S \u00d7 T`\ngiven by `(f.prod g) x = (f x, g x)` -/\nprotected def prod (f : R \u2192+* S) (g : R \u2192+* T) : R \u2192+* S \u00d7 T :=\n  { MonoidHom.prod (f : R \u2192* S) (g : R \u2192* T), AddMonoidHom.prod (f : R \u2192+ S) (g : R \u2192+ 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\ntheorem prod_unique (f : R \u2192+* S \u00d7 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 \u2192+* R') (g : S \u2192+* 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\u2093'. -/\n/-- `prod.map` as a `ring_hom`. -/\ndef prodMap : R \u00d7 S \u2192+* R' \u00d7 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\u2093'. -/\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 (\u1fb0 : Prod.{u4, u2} R S), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Prod.{u4, u2} R S) => Prod.{u3, u1} R' S') \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_prodMap : \u21d1(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\u2093'. -/\ntheorem prod_comp_prodMap (f : T \u2192+* R) (g : T \u2192+* S) (f' : R \u2192+* R') (g' : S \u2192+* 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\u2093'. -/\n/-- Swapping components as an equivalence of (semi)rings. -/\ndef prodComm : R \u00d7 S \u2243+* S \u00d7 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 (\u1fb0 : Prod.{u2, u1} R S), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u2, u1} R S) => Prod.{u1, u2} S R) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_prod_comm : \u21d1(prodComm : R \u00d7 S \u2243+* S \u00d7 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 (\u1fb0 : Prod.{u1, u2} S R), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u1, u2} S R) => Prod.{u2, u1} R S) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_prod_comm_symm : \u21d1(prodComm : R \u00d7 S \u2243+* S \u00d7 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\u2093.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\u2093'. -/\n@[simp]\ntheorem fst_comp_coe_prod_comm :\n    (RingHom.fst S R).comp \u2191(prodComm : R \u00d7 S \u2243+* S \u00d7 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\u2093.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\u2093'. -/\n@[simp]\ntheorem snd_comp_coe_prod_comm :\n    (RingHom.snd S R).comp \u2191(prodComm : R \u00d7 S \u2243+* S \u00d7 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\u2093'. -/\n/-- A ring `R` is isomorphic to `R \u00d7 S` when `S` is the zero ring -/\n@[simps]\ndef prodZeroRing : R \u2243+* R \u00d7 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\u2093'. -/\n/-- A ring `R` is isomorphic to `S \u00d7 R` when `S` is the zero ring -/\n@[simps]\ndef zeroRingProd : R \u2243+* S \u00d7 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\u2093'. -/\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 \u00d7 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 (\u27e8_, h\u27e9 | \u27e8h, _\u27e9)\n  \u00b7 exact zero_ne_one h.symm\n  \u00b7 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 \u03b1] [OrderedSemiring \u03b2] : OrderedSemiring (\u03b1 \u00d7 \u03b2) :=\n  { Prod.semiring,\n    Prod.partialOrder _ _ with\n    add_le_add_left := fun _ _ => add_le_add_left\n    zero_le_one := \u27e8zero_le_one, zero_le_one\u27e9\n    mul_le_mul_of_nonneg_left := fun a b c hab hc =>\n      \u27e8mul_le_mul_of_nonneg_left hab.1 hc.1, mul_le_mul_of_nonneg_left hab.2 hc.2\u27e9\n    mul_le_mul_of_nonneg_right := fun a b c hab hc =>\n      \u27e8mul_le_mul_of_nonneg_right hab.1 hc.1, mul_le_mul_of_nonneg_right hab.2 hc.2\u27e9 }\n\ninstance [OrderedCommSemiring \u03b1] [OrderedCommSemiring \u03b2] : OrderedCommSemiring (\u03b1 \u00d7 \u03b2) :=\n  { Prod.commSemiring, Prod.orderedSemiring with }\n\ninstance [OrderedRing \u03b1] [OrderedRing \u03b2] : OrderedRing (\u03b1 \u00d7 \u03b2) :=\n  { Prod.ring, Prod.orderedSemiring with\n    mul_nonneg := fun a b ha hb => \u27e8mul_nonneg ha.1 hb.1, mul_nonneg ha.2 hb.2\u27e9 }\n\ninstance [OrderedCommRing \u03b1] [OrderedCommRing \u03b2] : OrderedCommRing (\u03b1 \u00d7 \u03b2) :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, Ya\u00ebl 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 : \u2115 \u2192 \u03b1`, this new sequence will be `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 \u2294 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 \u2294 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\u1d62_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 `\u2115`.\nRelated to the TODO in the module docstring of `Mathlib.Order.PartialSups`.\n-/\n\n\nvariable {\u03b1 \u03b2 : Type _}\n\nsection GeneralizedBooleanAlgebra\n\nvariable [GeneralizedBooleanAlgebra \u03b1]\n\n/-- If `f : \u2115 \u2192 \u03b1` 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 : \u2115 \u2192 \u03b1) : \u2115 \u2192 \u03b1\n  | 0 => f 0\n  | n + 1 => f (n + 1) \\ partialSups f n\n#align disjointed disjointed\n\n@[simp]\ntheorem disjointed_zero (f : \u2115 \u2192 \u03b1) : disjointed f 0 = f 0 :=\n  rfl\n#align disjointed_zero disjointed_zero\n\ntheorem disjointed_succ (f : \u2115 \u2192 \u03b1) (n : \u2115) : disjointed f (n + 1) = f (n + 1) \\ partialSups f n :=\n  rfl\n#align disjointed_succ disjointed_succ\n\ntheorem disjointed_le_id : disjointed \u2264 (id : (\u2115 \u2192 \u03b1) \u2192 \u2115 \u2192 \u03b1) := by\n  rintro f n\n  cases n\n  \u00b7 rfl\n  \u00b7 exact sdiff_le\n#align disjointed_le_id disjointed_le_id\n\ntheorem disjointed_le (f : \u2115 \u2192 \u03b1) : disjointed f \u2264 f :=\n  disjointed_le_id f\n#align disjointed_le disjointed_le\n\ntheorem disjoint_disjointed (f : \u2115 \u2192 \u03b1) : Pairwise (Disjoint on disjointed f) := by\n  refine' (Symmetric.pairwise_on Disjoint.symm _).2 fun m n h => _\n  cases n\n  \u00b7 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 : \u2115 \u2192 \u03b1} {p : \u03b1 \u2192 Sort _} (hdiff : \u2200 \u2983t i\u2984, p t \u2192 p (t \\ f i)) :\n    \u2200 \u2983n\u2984, p (f n) \u2192 p (disjointed f n)\n  | 0 => id\n  | n + 1 => fun h => by\n    suffices H : \u2200 k, p (f (n + 1) \\ partialSups f k)\n    \u00b7 exact H n\n    rintro k\n    induction' k with k ih\n    \u00b7 exact hdiff h\n    rw [partialSups_succ, \u2190 sdiff_sdiff_left]\n    exact hdiff ih\n#align disjointed_rec disjointedRec\n\n@[simp]\ntheorem disjointedRec_zero {f : \u2115 \u2192 \u03b1} {p : \u03b1 \u2192 Sort _} (hdiff : \u2200 \u2983t i\u2984, p t \u2192 p (t \\ f i))\n    (h\u2080 : p (f 0)) : disjointedRec hdiff h\u2080 = h\u2080 :=\n  rfl\n#align disjointed_rec_zero disjointedRec_zero\n\n-- TODO: Find a useful statement of `disjointedRec_succ`.\ntheorem Monotone.disjointed_eq {f : \u2115 \u2192 \u03b1} (hf : Monotone f) (n : \u2115) :\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 : \u2115 \u2192 \u03b1) : partialSups (disjointed f) = partialSups f := by\n  ext n\n  induction' n with k ih\n  \u00b7 rw [partialSups_zero, partialSups_zero, disjointed_zero]\n  \u00b7 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 : \u2115 \u2192 \u03b1} (hdisj : Pairwise (Disjoint on d))\n    (hsups : partialSups d = partialSups f) : d = disjointed f := by\n  ext n\n  cases' n with n\n  \u00b7 rw [\u2190 partialSups_zero d, hsups, partialSups_zero, disjointed_zero]\n  suffices h : d n.succ = partialSups d n.succ \\ partialSups d n\n  \u00b7 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 : \u2200 m \u2264 n, Disjoint (partialSups d m) (d n.succ)\n  \u00b7 exact h n le_rfl\n  rintro m hm\n  induction' m with m ih\n  \u00b7 exact hdisj (Nat.succ_ne_zero _).symm\n  rw [partialSups_succ, disjoint_iff, inf_sup_right, sup_eq_bot_iff, \u2190 disjoint_iff, \u2190 disjoint_iff]\n  exact \u27e8ih (Nat.le_of_succ_le hm), hdisj (Nat.lt_succ_of_le hm).ne\u27e9\n#align disjointed_unique disjointed_unique\n\nend GeneralizedBooleanAlgebra\n\nsection CompleteBooleanAlgebra\n\nvariable [CompleteBooleanAlgebra \u03b1]\n\ntheorem sup\u1d62_disjointed (f : \u2115 \u2192 \u03b1) : (\u2a06 n, disjointed f n) = \u2a06 n, f n :=\n  sup\u1d62_eq_sup\u1d62_of_partialSups_eq_partialSups (partialSups_disjointed f)\n#align supr_disjointed sup\u1d62_disjointed\n\ntheorem disjointed_eq_inf_compl (f : \u2115 \u2192 \u03b1) (n : \u2115) : disjointed f n = f n \u2293 \u2a05 i < n, f i\u1d9c :=\n  by\n  cases n\n  \u00b7 rw [disjointed_zero, eq_comm, inf_eq_left]\n    simp_rw [le_inf\u1d62_iff]\n    exact fun i hi => (i.not_lt_zero hi).elim\n  simp_rw [disjointed_succ, partialSups_eq_bsup\u1d62, sdiff_eq, compl_sup\u1d62]\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 : \u2115 \u2192 Set \u03b1) (n : \u2115) : disjointed f n \u2286 f n :=\n  disjointed_le f n\n#align disjointed_subset disjointed_subset\n\ntheorem union\u1d62_disjointed {f : \u2115 \u2192 Set \u03b1} : (\u22c3 n, disjointed f n) = \u22c3 n, f n :=\n  sup\u1d62_disjointed f\n#align Union_disjointed union\u1d62_disjointed\n\ntheorem disjointed_eq_inter_compl (f : \u2115 \u2192 Set \u03b1) (n : \u2115) : disjointed f n = f n \u2229 \u22c2 i < n, f i\u1d9c :=\n  disjointed_eq_inf_compl f n\n#align disjointed_eq_inter_compl disjointed_eq_inter_compl\n\ntheorem preimage_find_eq_disjointed (s : \u2115 \u2192 Set \u03b1) (H : \u2200 x, \u2203 n, x \u2208 s n)\n    [\u2200 x n, Decidable (x \u2208 s n)] (n : \u2115) : (fun x => Nat.find (H x)) \u207b\u00b9' {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 {\u03b9 R : Type _} [CommSemiring R]\n\n/- warning: ideal.supr_infi_eq_top_iff_pairwise -> Ideal.sup\u1d62_inf\u1d62_eq_top_iff_pairwise is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : CommSemiring.{u2} R] {t : Finset.{u1} \u03b9}, (Finset.Nonempty.{u1} \u03b9 t) -> (forall (I : \u03b9 -> (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1))), Iff (Eq.{succ u2} (Ideal.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (sup\u1d62.{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))))) \u03b9 (fun (i : \u03b9) => sup\u1d62.{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} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i t) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i t) => inf\u1d62.{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))) \u03b9 (fun (j : \u03b9) => inf\u1d62.{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} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) j t) (fun (hj : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) j t) => inf\u1d62.{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} \u03b9 j i) (fun (ij : Ne.{succ u1} \u03b9 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} \u03b9 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (Finset.Set.hasCoeT.{u1} \u03b9))) t) (fun (i : \u03b9) (j : \u03b9) => 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 {\u03b9 : Type.{u2}} {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {t : Finset.{u2} \u03b9}, (Finset.Nonempty.{u2} \u03b9 t) -> (forall (I : \u03b9 -> (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1))), Iff (Eq.{succ u1} (Ideal.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (sup\u1d62.{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))))) \u03b9 (fun (i : \u03b9) => sup\u1d62.{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} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i t) (fun (H : Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i t) => inf\u1d62.{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))) \u03b9 (fun (j : \u03b9) => inf\u1d62.{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} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) j t) (fun (hj : Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) j t) => inf\u1d62.{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} \u03b9 j i) (fun (ij : Ne.{succ u2} \u03b9 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} \u03b9 (Finset.toSet.{u2} \u03b9 t) (fun (i : \u03b9) (j : \u03b9) => 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\u1d62_inf\u1d62_eq_top_iff_pairwise\u2093'. -/\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 \u2294 J = I \u2294 K = J \u2294 K = \u22a4 \u2194 (I \u2293 J) \u2294 (I \u2293 K) \u2294 (J \u2293 K) = \u22a4`.\n\nWhen ideals are all of the form `I i = R \u2219 s i`, this is equivalent to the\n`exists_sum_eq_one_iff_pairwise_coprime` lemma.-/\ntheorem sup\u1d62_inf\u1d62_eq_top_iff_pairwise {t : Finset \u03b9} (h : t.Nonempty) (I : \u03b9 \u2192 Ideal R) :\n    (\u2a06 i \u2208 t, \u2a05 (j) (hj : j \u2208 t) (ij : j \u2260 i), I j) = \u22a4 \u2194\n      (t : Set \u03b9).Pairwise fun i j => I i \u2294 I j = \u22a4 :=\n  by\n  haveI : DecidableEq \u03b9 := Classical.decEq \u03b9\n  rw [eq_top_iff_one, Submodule.mem_sup\u1d62_finset_iff_exists_sum]\n  refine' h.cons_induction _ _ <;> clear t h\n  \u00b7 simp only [Finset.sum_singleton, Finset.coe_singleton, Set.pairwise_singleton, iff_true_iff]\n    refine' fun a => \u27e8fun i => if h : i = a then \u27e81, _\u27e9 else 0, _\u27e9\n    \u00b7 rw [h]\n      simp only [Finset.mem_singleton, Ne.def, inf\u1d62_inf\u1d62_eq_left, eq_self_iff_true, not_true,\n        inf\u1d62_false]\n    \u00b7 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 \u2294 I j = \u22a4) => sup_comm.trans h]\n  constructor\n  \u00b7 rintro \u27e8\u03bc, h\u03bc\u27e9\n    rw [Finset.sum_cons] at h\u03bc\n    refine' \u27e8ih.mp \u27e8Pi.single h.some \u27e8\u03bc a, _\u27e9 + fun i => \u27e8\u03bc i, _\u27e9, _\u27e9, fun b hb ab => _\u27e9\n    \u00b7 have := Submodule.coe_mem (\u03bc a)\n      rw [mem_infi] at this\u22a2\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\u22a2\n      intro hi _\n      apply this (Finset.subset_cons _ hi)\n      rintro rfl\n      exact hat hi\n    \u00b7 have := Submodule.coe_mem (\u03bc i)\n      simp only [mem_infi] at this\u22a2\n      intro j hj ij\n      exact this _ (Finset.subset_cons _ hj) ij\n    \u00b7 rw [\u2190 @if_pos _ _ h.some_spec R (\u03bc a) 0, \u2190 Finset.sum_pi_single', \u2190 Finset.sum_add_distrib] at\n        h\u03bc\n      convert h\u03bc\n      ext i\n      rw [Pi.add_apply, Submodule.coe_add, Submodule.coe_mk]\n      by_cases hi : i = h.some\n      \u00b7 rw [hi, Pi.single_eq_same, Pi.single_eq_same, Submodule.coe_mk]\n      \u00b7 rw [Pi.single_eq_of_ne hi, Pi.single_eq_of_ne hi, Submodule.coe_zero]\n    \u00b7 rw [eq_top_iff_one, Submodule.mem_sup]\n      rw [add_comm] at h\u03bc\n      refine' \u27e8_, _, _, _, h\u03bc\u27e9\n      \u00b7 refine' sum_mem _ fun x hx => _\n        have := Submodule.coe_mem (\u03bc x)\n        simp only [mem_infi] at this\n        apply this _ (Finset.mem_cons_self _ _)\n        rintro rfl\n        exact hat hx\n      \u00b7 have := Submodule.coe_mem (\u03bc a)\n        simp only [mem_infi] at this\n        exact this _ (Finset.subset_cons _ hb) ab.symm\n  \u00b7 rintro \u27e8hs, Hb\u27e9\n    obtain \u27e8\u03bc, h\u03bc\u27e9 := 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 \u27e8u, hu, v, hv, huv\u27e9 := this\n    refine' \u27e8fun i => if hi : i = a then \u27e8v, _\u27e9 else \u27e8u * \u03bc i, _\u27e9, _\u27e9\n    \u00b7 simp only [mem_infi] at hv\u22a2\n      intro j hj ij\n      rw [Finset.mem_cons, \u2190 hi] at hj\n      exact hv _ (hj.resolve_left ij)\n    \u00b7 have := Submodule.coe_mem (\u03bc i)\n      simp only [mem_infi] at this\u22a2\n      intro j hj ij\n      rcases finset.mem_cons.mp hj with (rfl | hj)\n      \u00b7 exact mul_mem_right _ _ hu\n      \u00b7 exact mul_mem_left _ _ (this _ hj ij)\n    \u00b7 rw [Finset.sum_cons, dif_pos rfl, add_comm]\n      rw [\u2190 mul_one u] at huv\n      rw [\u2190 huv, \u2190 h\u03bc, 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\u1d62_inf\u1d62_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 {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\n\nstructure sum_str (A B X : \ud835\udcd0) :=\n(inl : A \u27f6 X)\n(inr : B \u27f6 X)\n(fst : X \u27f6 A)\n(snd : X \u27f6 B)\n(inl_fst : inl \u226b fst = \ud835\udfd9 _)\n(inr_snd : inr \u226b snd = \ud835\udfd9 _)\n(inl_snd : inl \u226b snd = 0)\n(inr_fst : inr \u226b fst = 0)\n(total : fst \u226b inl + snd \u226b inr = \ud835\udfd9 _)\n\nnamespace sum_str\n\nvariables {A B X : \ud835\udcd0}\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 : \ud835\udcd0) : sum_str A B (A \u229e 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\u2081 X\u2082 : \ud835\udcd0} (S\u2081 : sum_str A B X\u2081) (S\u2082 : sum_str A B X\u2082)\n\n@[simps]\ndef iso : X\u2081 \u2245 X\u2082 :=\n{ hom := S\u2081.fst \u226b S\u2082.inl + S\u2081.snd \u226b S\u2082.inr,\n  inv := S\u2082.fst \u226b S\u2081.inl + S\u2082.snd \u226b S\u2081.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 [\u2190 op_comp, sum.inl_fst, op_id] },\n  inr_snd := by { rw [\u2190 op_comp, sum.inr_snd, op_id] },\n  inl_snd := by { rw [\u2190 op_comp, sum.inr_fst, op_zero] },\n  inr_fst := by { rw [\u2190 op_comp, sum.inl_snd, op_zero] },\n  total := by { rw [\u2190 op_comp, \u2190 op_comp, \u2190 op_add, sum.total, op_id] } }\n\n@[simps]\nprotected def unop {A B X : \ud835\udcd0\u1d52\u1d56} (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 [\u2190 unop_comp, sum.inl_fst, unop_id] },\n  inr_snd := by { rw [\u2190 unop_comp, sum.inr_snd, unop_id] },\n  inl_snd := by { rw [\u2190 unop_comp, sum.inr_fst, unop_zero] },\n  inr_fst := by { rw [\u2190 unop_comp, sum.inl_snd, unop_zero] },\n  total := by { rw [\u2190 unop_comp, \u2190 unop_comp, \u2190 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 : \ud835\udcd0\u1d52\u1d56} (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 : \ud835\udcd0\u1d52\u1d56} (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 {\u03b1} [comm_semiring \u03b1] (a x : \u03b1) (n : \u2115) (b : \u03b1) := a * x ^ n + b\n\n/-- This cache contains data required by the `ring` tactic during execution. -/\nmeta structure cache :=\n(\u03b1 : 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 (\u03b1 : Type) : Type :=\nreader_t cache tactic \u03b1\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 : \u2115) : ring_m expr :=\n\u27e8\u03bb c, do es \u2190 read_ref c.atoms, pure (es.read' n)\u27e9\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 \u2115 :=\n\u27e8\u03bb c, do\n  let red := c.red,\n  es \u2190 read_ref c.atoms,\n  es.iterate failed (\u03bb n e' t, t <|> (is_def_eq e e' red $> n)) <|>\n  (es.size <$ write_ref c.atoms (es.push_back e))\u27e9\n\n/-- Lift a tactic into the `ring_m` monad. -/\n@[inline] meta def lift {\u03b1} (m : tactic \u03b1) : ring_m \u03b1 := 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) {\u03b1} (m : ring_m \u03b1) : tactic \u03b1 :=\ndo \u03b1 \u2190 infer_type e,\n   u \u2190 mk_meta_univ,\n   infer_type \u03b1 >>= unify (expr.sort (level.succ u)),\n   u \u2190 get_univ_assignment u,\n   ic \u2190 mk_instance_cache \u03b1,\n   (ic, c) \u2190 ic.get ``comm_semiring,\n   nc \u2190 mk_instance_cache `(\u2115),\n   using_new_ref ic $ \u03bb r,\n   using_new_ref nc $ \u03bb nr,\n   reader_t.run m \u27e8\u03b1, u, c, red, r, nr, atoms\u27e9\n\n/-- Run a `ring_m` tactic in the tactic monad. -/\nmeta def ring_m.run (red : transparency) (e : expr) {\u03b1} (m : ring_m \u03b1) : tactic \u03b1 :=\nusing_new_ref mk_buffer $ \u03bb 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 `\u03b1`, or `\u2115` for exponents). -/\n@[inline] meta def ic_lift' (icf : cache \u2192 ref instance_cache) {\u03b1}\n  (f : instance_cache \u2192 tactic (instance_cache \u00d7 \u03b1)) : ring_m \u03b1 :=\n\u27e8\u03bb c, do\n  let r := icf c,\n  ic \u2190 read_ref r,\n  (ic', a) \u2190 f ic,\n  a <$ write_ref r ic'\u27e9\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 `\u03b1`. -/\n@[inline] meta def ic_lift {\u03b1} : (instance_cache \u2192 tactic (instance_cache \u00d7 \u03b1)) \u2192 ring_m \u03b1 :=\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 `\u2115`, which is used for computations in the exponent. -/\n@[inline] meta def nc_lift {\u03b1} : (instance_cache \u2192 tactic (instance_cache \u00d7 \u03b1)) \u2192 ring_m \u03b1 :=\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 \u2192 expr :=\n(@expr.const tt n [c.univ] c.\u03b1 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 `\u2115` and\n`\u211a` 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 : \u211a) : horner_expr\n| xadd (e : expr) (a : horner_expr) (x : expr \u00d7 \u2115) (n : expr \u00d7 \u2115) (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 \u2192 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 \u2192 bool\n| (horner_expr.const _ c) := c = 0\n| _ := ff\n\nmeta instance : has_coe horner_expr expr := \u27e8horner_expr.e\u27e9\nmeta instance : has_coe_to_fun horner_expr (\u03bb _, expr \u2192 expr) := \u27e8\u03bb e, \u21d1(e : expr)\u27e9\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 \u00d7 \u2115) (n : expr \u00d7 \u2115) (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 \u2192 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 \u2192 tactic format\n| (const e c) := pp (e, c)\n| (xadd e a x (_, n) b) := do\n  pa \u2190 a.pp, pb \u2190 b.pp, px \u2190 pp x.1,\n  return $ \"(\" ++ pa ++ \") * (\" ++ px ++ \")^\" ++ to_string n ++ \" + \" ++ pb\n\nmeta instance : has_to_tactic_format horner_expr := \u27e8horner_expr.pp\u27e9\n\n/-- Reflexivity conversion for a `horner_expr`. -/\nmeta def horner_expr.refl_conv (e : horner_expr) : ring_m (horner_expr \u00d7 expr) :=\ndo p \u2190 lift $ mk_eq_refl e, return (e, p)\n\ntheorem zero_horner {\u03b1} [comm_semiring \u03b1] (x n b) :\n  @horner \u03b1 _ 0 x n b = b :=\nby simp [horner]\n\ntheorem horner_horner {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 n\u2082 b n')\n  (h : n\u2081 + n\u2082 = n') :\n  @horner \u03b1 _ (horner a\u2081 x n\u2081 0) x n\u2082 b = horner a\u2081 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 \u2192 expr \u00d7 \u2115 \u2192 expr \u00d7 \u2115 \u2192 horner_expr \u2192 ring_m (horner_expr \u00d7 expr)\n| ha@(const a coeff) x n b := do\n  c \u2190 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\u2081 x\u2081 n\u2081 b\u2081) x n b := do\n  c \u2190 get_cache,\n  if x\u2081.2 = x.2 \u2227 b\u2081.e.to_nat = some 0 then do\n    (n', h) \u2190 nc_lift $ \u03bb nc, norm_num.prove_add_nat' nc n\u2081.1 n.1,\n    return (xadd' c a\u2081 x (n', n\u2081.2 + n.2) b,\n      c.cs_app ``horner_horner [a\u2081, x.1, n\u2081.1, n.1, b, n', h])\n  else (xadd' c ha x n b).refl_conv\n\ntheorem const_add_horner {\u03b1} [comm_semiring \u03b1] (k a x n b b') (h : k + b = b') :\n  k + @horner \u03b1 _ a x n b = horner a x n b' :=\nby simp [h.symm, horner]; cc\n\ntheorem horner_add_const {\u03b1} [comm_semiring \u03b1] (a x n b k b') (h : b + k = b') :\n  @horner \u03b1 _ a x n b + k = horner a x n b' :=\nby simp [h.symm, horner, add_assoc]\n\ntheorem horner_add_horner_lt {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 k a' b')\n  (h\u2081 : n\u2081 + k = n\u2082) (h\u2082 : (a\u2081 + horner a\u2082 x k 0 : \u03b1) = a') (h\u2083 : b\u2081 + b\u2082 = b') :\n  @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2081 b' :=\nby simp [h\u2082.symm, h\u2083.symm, h\u2081.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]; cc\n\ntheorem horner_add_horner_gt {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 k a' b')\n  (h\u2081 : n\u2082 + k = n\u2081) (h\u2082 : (horner a\u2081 x k 0 + a\u2082 : \u03b1) = a') (h\u2083 : b\u2081 + b\u2082 = b') :\n  @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2082 b' :=\nby simp [h\u2082.symm, h\u2083.symm, h\u2081.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]; cc\n\ntheorem horner_add_horner_eq {\u03b1} [comm_semiring \u03b1] (a\u2081 x n b\u2081 a\u2082 b\u2082 a' b' t)\n  (h\u2081 : a\u2081 + a\u2082 = a') (h\u2082 : b\u2081 + b\u2082 = b') (h\u2083 : horner a' x n b' = t) :\n  @horner \u03b1 _ a\u2081 x n b\u2081 + horner a\u2082 x n b\u2082 = t :=\nby simp [h\u2083.symm, h\u2082.symm, h\u2081.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 \u2192 horner_expr \u2192 ring_m (horner_expr \u00d7 expr)\n| (const e\u2081 c\u2081) (const e\u2082 c\u2082) := ic_lift $ \u03bb ic, do\n  let n := c\u2081 + c\u2082,\n  (ic, e) \u2190 ic.of_rat n,\n  (ic, p) \u2190 norm_num.prove_add_rat ic e\u2081 e\u2082 e c\u2081 c\u2082 n,\n  return (ic, const e n, p)\n| he\u2081@(const e\u2081 c\u2081) he\u2082@(xadd e\u2082 a x n b) := do\n  c \u2190 get_cache,\n  if c\u2081 = 0 then ic_lift $ \u03bb ic, do\n    (ic, p) \u2190 ic.mk_app ``zero_add [e\u2082],\n    return (ic, he\u2082, p)\n  else do\n    (b', h) \u2190 eval_add he\u2081 b,\n    return (xadd' c a x n b',\n      c.cs_app ``const_add_horner [e\u2081, a, x.1, n.1, b, b', h])\n| he\u2081@(xadd e\u2081 a x n b) he\u2082@(const e\u2082 c\u2082) := do\n  c \u2190 get_cache,\n  if c\u2082 = 0 then ic_lift $ \u03bb ic, do\n    (ic, p) \u2190 ic.mk_app ``add_zero [e\u2081],\n    return (ic, he\u2081, p)\n  else do\n    (b', h) \u2190 eval_add b he\u2082,\n    return (xadd' c a x n b',\n      c.cs_app ``horner_add_const [a, x.1, n.1, b, e\u2082, b', h])\n| he\u2081@(xadd e\u2081 a\u2081 x\u2081 n\u2081 b\u2081) he\u2082@(xadd e\u2082 a\u2082 x\u2082 n\u2082 b\u2082) := do\n  c \u2190 get_cache,\n  if x\u2081.2 < x\u2082.2 then do\n    (b', h) \u2190 eval_add b\u2081 he\u2082,\n    return (xadd' c a\u2081 x\u2081 n\u2081 b',\n      c.cs_app ``horner_add_const [a\u2081, x\u2081.1, n\u2081.1, b\u2081, e\u2082, b', h])\n  else if x\u2081.2 \u2260 x\u2082.2 then do\n    (b', h) \u2190 eval_add he\u2081 b\u2082,\n    return (xadd' c a\u2082 x\u2082 n\u2082 b',\n      c.cs_app ``const_add_horner [e\u2081, a\u2082, x\u2082.1, n\u2082.1, b\u2082, b', h])\n  else if n\u2081.2 < n\u2082.2 then do\n    let k := n\u2082.2 - n\u2081.2,\n    (ek, h\u2081) \u2190 nc_lift (\u03bb nc, do\n      (nc, ek) \u2190 nc.of_nat k,\n      (nc, h\u2081) \u2190 norm_num.prove_add_nat nc n\u2081.1 ek n\u2082.1,\n      return (nc, ek, h\u2081)),\n    \u03b10 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_zero.zero [],\n    (a', h\u2082) \u2190 eval_add a\u2081 (xadd' c a\u2082 x\u2081 (ek, k) (const \u03b10 0)),\n    (b', h\u2083) \u2190 eval_add b\u2081 b\u2082,\n    return (xadd' c a' x\u2081 n\u2081 b',\n      c.cs_app ``horner_add_horner_lt [a\u2081, x\u2081.1, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, ek, a', b', h\u2081, h\u2082, h\u2083])\n  else if n\u2081.2 \u2260 n\u2082.2 then do\n    let k := n\u2081.2 - n\u2082.2,\n    (ek, h\u2081) \u2190 nc_lift (\u03bb nc, do\n      (nc, ek) \u2190 nc.of_nat k,\n      (nc, h\u2081) \u2190 norm_num.prove_add_nat nc n\u2082.1 ek n\u2081.1,\n      return (nc, ek, h\u2081)),\n    \u03b10 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_zero.zero [],\n    (a', h\u2082) \u2190 eval_add (xadd' c a\u2081 x\u2081 (ek, k) (const \u03b10 0)) a\u2082,\n    (b', h\u2083) \u2190 eval_add b\u2081 b\u2082,\n    return (xadd' c a' x\u2081 n\u2082 b',\n      c.cs_app ``horner_add_horner_gt [a\u2081, x\u2081.1, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, ek, a', b', h\u2081, h\u2082, h\u2083])\n  else do\n    (a', h\u2081) \u2190 eval_add a\u2081 a\u2082,\n    (b', h\u2082) \u2190 eval_add b\u2081 b\u2082,\n    (t, h\u2083) \u2190 eval_horner a' x\u2081 n\u2081 b',\n    return (t, c.cs_app ``horner_add_horner_eq\n      [a\u2081, x\u2081.1, n\u2081.1, b\u2081, a\u2082, b\u2082, a', b', t, h\u2081, h\u2082, h\u2083])\n\ntheorem horner_neg {\u03b1} [comm_ring \u03b1] (a x n b a' b')\n  (h\u2081 : -a = a') (h\u2082 : -b = b') :\n  -@horner \u03b1 _ a x n b = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.symm, horner]; cc\n\n/-- Evaluate `-a` where `a` is already in normal form. -/\nmeta def eval_neg : horner_expr \u2192 ring_m (horner_expr \u00d7 expr)\n| (const e coeff) := do\n  (e', p) \u2190 ic_lift $ \u03bb ic, norm_num.prove_neg ic e,\n  return (const e' (-coeff), p)\n| (xadd e a x n b) := do\n  c \u2190 get_cache,\n  (a', h\u2081) \u2190 eval_neg a,\n  (b', h\u2082) \u2190 eval_neg b,\n  p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``horner_neg [a, x.1, n.1, b, a', b', h\u2081, h\u2082],\n  return (xadd' c a' x n b', p)\n\ntheorem horner_const_mul {\u03b1} [comm_semiring \u03b1] (c a x n b a' b')\n  (h\u2081 : c * a = a') (h\u2082 : c * b = b') :\n  c * @horner \u03b1 _ a x n b = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.symm, horner, mul_add, mul_assoc]\n\ntheorem horner_mul_const {\u03b1} [comm_semiring \u03b1] (a x n b c a' b')\n  (h\u2081 : a * c = a') (h\u2082 : b * c = b') :\n  @horner \u03b1 _ a x n b * c = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.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 \u00d7 \u211a) :\n  horner_expr \u2192 ring_m (horner_expr \u00d7 expr)\n| (const e coeff) := do\n  (e', p) \u2190 ic_lift $ \u03bb 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 \u2190 get_cache,\n  (a', h\u2081) \u2190 eval_const_mul a,\n  (b', h\u2082) \u2190 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\u2081, h\u2082])\n\ntheorem horner_mul_horner_zero {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 aa t)\n  (h\u2081 : @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 * a\u2082 = aa)\n  (h\u2082 : horner aa x n\u2082 0 = t) :\n  horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 0 = t :=\nby rw [\u2190 h\u2082, \u2190 h\u2081];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\ntheorem horner_mul_horner {\u03b1} [comm_semiring \u03b1]\n  (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 aa haa ab bb t)\n  (h\u2081 : @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 * a\u2082 = aa)\n  (h\u2082 : horner aa x n\u2082 0 = haa)\n  (h\u2083 : a\u2081 * b\u2082 = ab) (h\u2084 : b\u2081 * b\u2082 = bb)\n  (H : haa + horner ab x n\u2081 bb = t) :\n  horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 b\u2082 = t :=\nby rw [\u2190 H, \u2190 h\u2082, \u2190 h\u2081, \u2190 h\u2083, \u2190 h\u2084];\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 \u2192 horner_expr \u2192 ring_m (horner_expr \u00d7 expr)\n| (const e\u2081 c\u2081) (const e\u2082 c\u2082) := do\n  (e', p) \u2190 ic_lift $ \u03bb ic, norm_num.prove_mul_rat ic e\u2081 e\u2082 c\u2081 c\u2082,\n  return (const e' (c\u2081 * c\u2082), p)\n| (const e\u2081 c\u2081) e\u2082 :=\n  if c\u2081 = 0 then do\n    c \u2190 get_cache,\n    \u03b10 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_zero.zero [],\n    p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``zero_mul [e\u2082],\n    return (const \u03b10 0, p)\n  else if c\u2081 = 1 then do\n    p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``one_mul [e\u2082],\n    return (e\u2082, p)\n  else eval_const_mul (e\u2081, c\u2081) e\u2082\n| e\u2081 he\u2082@(const e\u2082 c\u2082) := do\n  p\u2081 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``mul_comm [e\u2081, e\u2082],\n  (e', p\u2082) \u2190 eval_mul he\u2082 e\u2081,\n  p \u2190 lift $ mk_eq_trans p\u2081 p\u2082, return (e', p)\n| he\u2081@(xadd e\u2081 a\u2081 x\u2081 n\u2081 b\u2081) he\u2082@(xadd e\u2082 a\u2082 x\u2082 n\u2082 b\u2082) := do\n  c \u2190 get_cache,\n  if x\u2081.2 < x\u2082.2 then do\n    (a', h\u2081) \u2190 eval_mul a\u2081 he\u2082,\n    (b', h\u2082) \u2190 eval_mul b\u2081 he\u2082,\n    return (xadd' c a' x\u2081 n\u2081 b',\n      c.cs_app ``horner_mul_const [a\u2081, x\u2081.1, n\u2081.1, b\u2081, e\u2082, a', b', h\u2081, h\u2082])\n  else if x\u2081.2 \u2260 x\u2082.2 then do\n    (a', h\u2081) \u2190 eval_mul he\u2081 a\u2082,\n    (b', h\u2082) \u2190 eval_mul he\u2081 b\u2082,\n    return (xadd' c a' x\u2082 n\u2082 b',\n      c.cs_app ``horner_const_mul [e\u2081, a\u2082, x\u2082.1, n\u2082.1, b\u2082, a', b', h\u2081, h\u2082])\n  else do\n    (aa, h\u2081) \u2190 eval_mul he\u2081 a\u2082,\n    \u03b10 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_zero.zero [],\n    (haa, h\u2082) \u2190 eval_horner aa x\u2081 n\u2082 (const \u03b10 0),\n    if b\u2082.is_zero then\n      return (haa, c.cs_app ``horner_mul_horner_zero\n        [a\u2081, x\u2081.1, n\u2081.1, b\u2081, a\u2082, n\u2082.1, aa, haa, h\u2081, h\u2082])\n    else do\n      (ab, h\u2083) \u2190 eval_mul a\u2081 b\u2082,\n      (bb, h\u2084) \u2190 eval_mul b\u2081 b\u2082,\n      (t, H) \u2190 eval_add haa (xadd' c ab x\u2081 n\u2081 bb),\n      return (t, c.cs_app ``horner_mul_horner\n        [a\u2081, x\u2081.1, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, aa, haa, ab, bb, t, h\u2081, h\u2082, h\u2083, h\u2084, H])\n\ntheorem horner_pow {\u03b1} [comm_semiring \u03b1] (a x n m n' a') (h\u2081 : n * m = n') (h\u2082 : a ^ m = a') :\n  @horner \u03b1 _ a x n 0 ^ m = horner a' x n' 0 :=\nby simp [h\u2081.symm, h\u2082.symm, horner, mul_pow, pow_mul]\n\ntheorem pow_succ {\u03b1} [comm_semiring \u03b1] (a n b c)\n  (h\u2081 : (a:\u03b1) ^ n = b) (h\u2082 : b * a = c) : a ^ (n + 1) = c :=\nby rw [\u2190 h\u2082, \u2190 h\u2081, 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 \u2192 expr \u00d7 \u2115 \u2192 ring_m (horner_expr \u00d7 expr)\n| e (_, 0) := do\n  c \u2190 get_cache,\n  \u03b11 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_one.one [],\n  p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``pow_zero [e],\n  return (const \u03b11 1, p)\n| e (_, 1) := do\n  p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``pow_one [e],\n  return (e, p)\n| (const e coeff) (e\u2082, m) := ic_lift $ \u03bb ic, do\n  (ic, e', p) \u2190 norm_num.prove_pow e coeff ic e\u2082,\n  return (ic, const e' (coeff ^ m), p)\n| he@(xadd e a x n b) m := do\n  c \u2190 get_cache,\n  match b.e.to_nat with\n  | some 0 := do\n    (n', h\u2081) \u2190 nc_lift $ \u03bb nc, norm_num.prove_mul_rat nc n.1 m.1 n.2 m.2,\n    (a', h\u2082) \u2190 eval_pow a m,\n    \u03b10 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_zero.zero [],\n    return (xadd' c a' x (n', n.2 * m.2) (const \u03b10 0),\n      c.cs_app ``horner_pow [a, x.1, n.1, m.1, n', a', h\u2081, h\u2082])\n  | _ := do\n    e\u2082 \u2190 nc_lift $ \u03bb nc, nc.of_nat (m.2-1),\n    (tl, hl) \u2190 eval_pow he (e\u2082, m.2-1),\n    (t, p\u2082) \u2190 eval_mul tl he,\n    return (t, c.cs_app ``pow_succ [e, e\u2082, tl, t, hl, p\u2082])\n  end\n\ntheorem horner_atom {\u03b1} [comm_semiring \u03b1] (x : \u03b1) : 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 \u00d7 expr) :=\ndo c \u2190 get_cache,\n  i \u2190 add_atom e,\n  \u03b10 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_zero.zero [],\n  \u03b11 \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_one.one [],\n  return (xadd' c (const \u03b11 1) (e, i) (`(1), 1) (const \u03b10 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 \u2192 tactic (expr \u00d7 expr))\n  (e : expr) : ring_m (horner_expr \u00d7 expr) :=\ndo o \u2190 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\u2082, p\u2082) \u2190 eval_atom e',\n    prod.mk e\u2082 <$> lift (mk_eq_trans p p\u2082)\n  end\n\nlemma subst_into_pow {\u03b1} [monoid \u03b1] (l r tl tr t)\n  (prl : (l : \u03b1) = tl) (prr : (r : \u2115) = tr) (prt : tl ^ tr = t) : l ^ r = t :=\nby rw [prl, prr, prt]\n\nlemma unfold_sub {\u03b1} [add_group \u03b1] (a b c : \u03b1)\n  (h : a + -b = c) : a - b = c :=\nby rw [sub_eq_add_neg, h]\n\nlemma unfold_div {\u03b1} [division_ring \u03b1] (a b c : \u03b1)\n  (h : a * b\u207b\u00b9 = 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 \u2192 tactic (expr \u00d7 expr)) : expr \u2192 ring_m (horner_expr \u00d7 expr)\n| `(%%e\u2081 + %%e\u2082) := do\n  (e\u2081', p\u2081) \u2190 eval e\u2081,\n  (e\u2082', p\u2082) \u2190 eval e\u2082,\n  (e', p') \u2190 eval_add e\u2081' e\u2082',\n  p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``norm_num.subst_into_add [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n  return (e', p)\n| e@`(@has_sub.sub %%\u03b1 %%inst %%e\u2081 %%e\u2082) :=\n  mcond (succeeds (lift $ mk_app ``comm_ring [\u03b1] >>= mk_instance))\n    (do\n      e\u2082' \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_neg.neg [e\u2082],\n      e \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_add.add [e\u2081, e\u2082'],\n      (e', p) \u2190 eval e,\n      p' \u2190 ic_lift $ \u03bb ic, ic.mk_app ``unfold_sub [e\u2081, e\u2082, e', p],\n      return (e', p'))\n    (eval_norm_atom norm_atom e)\n| `(- %%e) := do\n  (e\u2081, p\u2081) \u2190 eval e,\n  (e\u2082, p\u2082) \u2190 eval_neg e\u2081,\n  p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``norm_num.subst_into_neg [e, e\u2081, e\u2082, p\u2081, p\u2082],\n  return (e\u2082, p)\n| `(%%e\u2081 * %%e\u2082) := do\n  (e\u2081', p\u2081) \u2190 eval e\u2081,\n  (e\u2082', p\u2082) \u2190 eval e\u2082,\n  (e', p') \u2190 eval_mul e\u2081' e\u2082',\n  p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``norm_num.subst_into_mul [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n  return (e', p)\n| e@`(has_inv.inv %%_) := (do\n    (e', p) \u2190 lift $ norm_num.derive e <|> refl_conv e,\n    n \u2190 lift $ e'.to_rat,\n    return (const e' n, p)) <|> eval_norm_atom norm_atom e\n| e@`(@has_div.div _ %%inst %%e\u2081 %%e\u2082) := mcond\n  (succeeds (do\n    inst' \u2190 ic_lift $ \u03bb ic, ic.mk_app ``div_inv_monoid.to_has_div [],\n    lift $ is_def_eq inst inst'))\n  (do\n    e\u2082' \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_inv.inv [e\u2082],\n    e \u2190 ic_lift $ \u03bb ic, ic.mk_app ``has_mul.mul [e\u2081, e\u2082'],\n    (e', p) \u2190 eval e,\n    p' \u2190 ic_lift $ \u03bb ic, ic.mk_app ``unfold_div [e\u2081, e\u2082, e', p],\n    return (e', p'))\n  (eval_norm_atom norm_atom e)\n| e@`(@has_pow.pow _ _ %%inst %%e\u2081 %%e\u2082) := mcond\n  (succeeds (do\n    inst' \u2190 ic_lift $ \u03bb ic, ic.mk_app ``monoid.has_pow [],\n    lift $ is_def_eq inst inst'))\n  (do\n    (e\u2082', p\u2082) \u2190 lift $ norm_num.derive e\u2082 <|> refl_conv e\u2082,\n    match e\u2082'.to_nat with\n    | some k := do\n      (e\u2081', p\u2081) \u2190 eval e\u2081,\n      (e', p') \u2190 eval_pow e\u2081' (e\u2082, k),\n      p \u2190 ic_lift $ \u03bb ic, ic.mk_app ``subst_into_pow [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, 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 \u2192 tactic (expr \u00d7 expr)) (e : expr) : tactic (expr \u00d7 expr) :=\nring_m.run' red atoms e $ do (e', p) \u2190 eval norm_atom e, return (e', p)\n\ntheorem horner_def' {\u03b1} [comm_semiring \u03b1] (a x n b) : @horner \u03b1 _ a x n b = x ^ n * a + b :=\nby simp [horner, mul_comm]\n\ntheorem mul_assoc_rev {\u03b1} [semigroup \u03b1] (a b c : \u03b1) : a * (b * c) = a * b * c :=\nby simp [mul_assoc]\n\ntheorem pow_add_rev {\u03b1} [monoid \u03b1] (a : \u03b1) (m n : \u2115) : a ^ m * a ^ n = a ^ (m + n) :=\nby simp [pow_add]\n\ntheorem pow_add_rev_right {\u03b1} [monoid \u03b1] (a b : \u03b1) (m n : \u2115) :\n  b * a ^ m * a ^ n = b * a ^ (m + n) :=\nby simp [pow_add, mul_assoc]\n\ntheorem add_neg_eq_sub {\u03b1} [add_group \u03b1] (a b : \u03b1) : 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 := \u27e8normalize_mode.horner\u27e9\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 \u2192 opt_param _ ff \u2192 tactic (expr \u00d7 expr)\n| e inner := do\n  pow_lemma \u2190 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 \u2190 lemmas.mfoldl simp_lemmas.add_simp simp_lemmas.mk,\n  trans_conv\n    (\u03bb e, do\n      guard (mode \u2260 normalize_mode.raw),\n      (e', pr, _) \u2190 simplify simp_lemmas.mk [] e,\n      pure (e', pr))\n    (\u03bb e, do\n      a \u2190 read_ref atoms,\n      let norm_rec := if recursive then \u03bb e, normalize' e tt else \u03bb _, failed,\n      (a, e', pr) \u2190 ext_simplify_core a {}\n        simp_lemmas.mk (\u03bb _, failed) (\u03bb a _ _ p e, do\n          guard (inner \u2192 p.is_some),\n          write_ref atoms a,\n          (new_e, pr) \u2190 eval' red atoms norm_rec e,\n          (new_e, pr) \u2190 match mode with\n          | normalize_mode.raw := \u03bb _, pure (new_e, pr)\n          | normalize_mode.horner := trans_conv (\u03bb _, pure (new_e, pr))\n            (\u03bb e, do (e', prf, _) \u2190 simplify lemmas [] e, pure (e', prf))\n          | normalize_mode.SOP :=\n            trans_conv (\u03bb _, pure (new_e, pr)) $\n            trans_conv (\u03bb e, do (e', prf, _) \u2190 simplify lemmas [] e, pure (e', prf)) $\n            simp_bottom_up' (\u03bb e, norm_num.derive e <|> pow_lemma.rewrite e)\n          end e,\n          guard (\u00ac new_e =\u2090 e),\n          a \u2190 read_ref atoms,\n          pure (a, new_e, some pr, ff))\n        (\u03bb _ _ _ _ _, 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 \u00d7 expr) :=\nusing_new_ref mk_buffer $ \u03bb 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\u2081 = %%e\u2082) \u2190 target >>= instantiate_mvars,\n  ((e\u2081', p\u2081), (e\u2082', p\u2082)) \u2190 ring_m.run transp e\u2081 $\n    prod.mk <$> eval (\u03bb _, failed) e\u2081 <*> eval (\u03bb _, failed) e\u2082,\n  is_def_eq e\u2081' e\u2082',\n  p \u2190 mk_eq_symm p\u2082 >>= mk_eq_trans p\u2081,\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 \u2190 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 \u2190 loc.get_locals,\n   let transp := if red.is_some then semireducible else reducible,\n   tt \u2190 using_new_ref mk_buffer $ \u03bb 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\u00e9goire\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 (\u03b1 : Type) : Type\n| emp {} : bwd\n| snoc : bwd \u2192 \u03b1 \u2192 bwd\n\nnotation `\u03b5` := @bwd.emp _\ninfixl `\u226a`:5 := @bwd.snoc _\nnotation `\u27ea` l:(foldl `, ` (h t, (t \u226a h)) \u03b5 `\u27eb`) := l\n\n@[simp]\ndef append {\u03b1} : bwd \u03b1 \u2192 list \u03b1 \u2192 bwd \u03b1\n| xs [] := xs\n| xs (y :: ys) := append (xs \u226a y) ys\n\ninfixl `\u22c9`:3 := append\n\n\n\ndef fam (\u03b1 : Type) := \u03b1 \u2192 Type\n\n\n\n/-- Thinnings -/\ninductive thn {\u03b1} : bwd \u03b1 \u2192 bwd \u03b1 \u2192 Type\n| emp {} : thn \u27ea\u27eb \u27ea\u27eb\n| cong {\u0393 \u0394 \u03c4} : thn \u0393 \u0394 \u2192 thn (\u0393 \u226a \u03c4) (\u0394 \u226a \u03c4)\n| drop {\u0393 \u0394 \u03c4} : thn \u0393 \u0394 \u2192 thn (\u0393 \u226a \u03c4) \u0394\n\ninfixr `\u21fe`:30 := @thn _\ninfixl `\u2264` := @thn _\n\ndef idn {\u03b1} : \u03a0 (\u0393 : bwd \u03b1), \u0393 \u21fe \u0393\n| bwd.emp := thn.emp\n| (bwd.snoc \u0393 _) := thn.cong (idn \u0393)\n\ndef seq {\u03b1} : \u03a0 {\u0393 \u0394 \u039e : bwd \u03b1}, \u0393 \u21fe \u0394 \u2192 \u0394 \u21fe \u039e \u2192 \u0393 \u21fe \u039e\n| _ _ _ thn.emp thn.emp := thn.emp\n| _ _ _ (thn.cong \u03b4) (thn.cong \u03be) := thn.cong (seq \u03b4 \u03be)\n| _ _ _ (thn.cong \u03b4) (thn.drop \u03be) := thn.drop (seq \u03b4 \u03be)\n| _ _ _ (thn.drop \u03b4) \u03be := thn.drop (seq \u03b4 \u03be)\n\ntheorem seq_left_idn {\u03b1} : \u03a0 {\u0393 \u0394 : bwd \u03b1} (\u03b3 : \u0394 \u21fe \u0393), seq (idn _) \u03b3 = \u03b3\n| _ _ thn.emp := by refl\n| _ _ (thn.cong \u03be) :=\n  begin\n    unfold idn seq,\n    rewrite (seq_left_idn \u03be)\n  end\n| _ _ (thn.drop \u03be) :=\n  begin\n    unfold idn seq,\n    rewrite (seq_left_idn \u03be)\n  end\n\n\n\ninductive arity (\u03b1 : Type) : Type\n| mk : list arity \u2192 \u03b1 \u2192 arity\n\ndef sig (\u03b1 : Type) := fam (arity \u03b1)\ninfixl `\u25b6`:3 := arity.mk\n\n\n\n/-- the clone (type of terms) and type of substitutions -/\nmutual inductive cn, sb {\u03b1} (\ud835\udd16 : sig \u03b1)\nwith cn : bwd (arity \u03b1) \u2192 \u03b1 \u2192 Type\n| opr {\u0393 \u0394 \u03c4} : \ud835\udd16 (\u0394 \u25b6 \u03c4) \u2192 sb \u0393 \u0394 \u2192 cn \u0393 \u03c4\n| var {\u0393 \u0394 \u03c4} : \u0393 \u21fe \u27ea \u0394 \u25b6 \u03c4 \u27eb \u2192 sb \u0393 \u0394 \u2192 cn \u0393 \u03c4\nwith sb : bwd (arity \u03b1) \u2192 list (arity \u03b1) \u2192 Type\n| nil {\u0393} : sb \u0393 []\n| cons {\u0393 \u039e \u0394 \u03c4} : cn (\u0393 \u22c9 \u0394) \u03c4 \u2192 sb \u0393 \u039e \u2192 sb \u0393 ((\u0394 \u25b6 \u03c4) :: \u039e)\n\n\nnamespace lambda_calculus\n  inductive sort : Type\n  | chk\n  | syn\n\n  open sort\n\n  inductive LAM : arity sort \u2192 Type\n  | lam : LAM ([[[] \u25b6 syn] \u25b6 chk] \u25b6 chk)\n  | app : LAM ([[] \u25b6 syn, [] \u25b6 chk] \u25b6 syn)\n  | up : LAM ([[] \u25b6 syn] \u25b6 chk)\n\n  infix `\u2219`:5 := cn.opr\n\n  notation `\u2983` l:(foldr `, ` (h t, (sb.cons h t)) (sb.nil _) `\u2984`) := l\n\n  notation `\u019b` t := LAM.lam \u2219 \u2983 t \u2984\n\n  notation \u03be `#` \u03b3 := cn.var \u03be \u03b3\n  notation `\u21d1` t := LAM.up \u2219 \u2983 t \u2984\n  notation `x\u2080` := thn.cong thn.emp\n\n  def tm (\u0393 : bwd (arity sort)) := cn LAM \u0393 chk\n\n\n  -- identity function\n  def foo : _ :=\n    \u019b \u21d1 (x\u2080 # \u2983\u2984)\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\u00e9my Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: R\u00e9my 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 \u03bc` 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 \u03bc` for `1 \u2264 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 {\u03b1 E : Type*} {m : measurable_space \u03b1} {\u03bc : measure \u03b1} {p : \u211d\u22650\u221e}\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 \u03bc) : f \u2264\u1d50[\u03bc] g \u2194 f \u2264 g :=\nby rw [\u2190 subtype.coe_le_coe, \u2190 ae_eq_fun.coe_fn_le, \u2190 coe_fn_coe_base, \u2190 coe_fn_coe_base]\n\nlemma coe_fn_nonneg (f : Lp E p \u03bc) : 0 \u2264\u1d50[\u03bc] f \u2194 0 \u2264 f :=\nbegin\n  rw \u2190 coe_fn_le,\n  have h0 := Lp.coe_fn_zero E p \u03bc,\n  split; intro h; filter_upwards [h, h0] with _ _ h2,\n  { rwa h2, },\n  { rwa \u2190 h2, },\nend\n\ninstance : covariant_class (Lp E p \u03bc) (Lp E p \u03bc) (+) (\u2264) :=\nbegin\n  refine \u27e8\u03bb f g\u2081 g\u2082 hg\u2081\u2082, _\u27e9,\n  rw \u2190 coe_fn_le at hg\u2081\u2082 \u22a2,\n  filter_upwards [coe_fn_add f g\u2081, coe_fn_add f g\u2082, hg\u2081\u2082] 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 \u03bc) :=\n{ add_le_add_left := \u03bb 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 \u2192 Type v} {\u03b1 : Type u_1}\n    [(i : I) \u2192 has_scalar \u03b1 (f i)] : has_scalar \u03b1 ((i : I) \u2192 f i) :=\n  has_scalar.mk fun (s : \u03b1) (x : (i : I) \u2192 f i) (i : I) => s \u2022 x i\n\n@[simp] theorem smul_apply {I : Type u} {f : I \u2192 Type v} (x : (i : I) \u2192 f i) (i : I) {\u03b1 : Type u_1}\n    [(i : I) \u2192 has_scalar \u03b1 (f i)] (s : \u03b1) : has_scalar.smul s x i = s \u2022 x i :=\n  rfl\n\nprotected instance has_scalar' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1}\n    [(i : I) \u2192 has_scalar (f i) (g i)] : has_scalar ((i : I) \u2192 f i) ((i : I) \u2192 g i) :=\n  has_scalar.mk fun (s : (i : I) \u2192 f i) (x : (i : I) \u2192 g i) (i : I) => s i \u2022 x i\n\n@[simp] theorem smul_apply' {I : Type u} {f : I \u2192 Type v} (i : I) {g : I \u2192 Type u_1}\n    [(i : I) \u2192 has_scalar (f i) (g i)] (s : (i : I) \u2192 f i) (x : (i : I) \u2192 g i) :\n    has_scalar.smul s x i = s i \u2022 x i :=\n  rfl\n\nprotected instance is_scalar_tower {I : Type u} {f : I \u2192 Type v} {\u03b1 : Type u_1} {\u03b2 : Type u_2}\n    [has_scalar \u03b1 \u03b2] [(i : I) \u2192 has_scalar \u03b2 (f i)] [(i : I) \u2192 has_scalar \u03b1 (f i)]\n    [\u2200 (i : I), is_scalar_tower \u03b1 \u03b2 (f i)] : is_scalar_tower \u03b1 \u03b2 ((i : I) \u2192 f i) :=\n  is_scalar_tower.mk\n    fun (x : \u03b1) (y : \u03b2) (z : (i : I) \u2192 f i) => funext fun (i : I) => smul_assoc x y (z i)\n\nprotected instance is_scalar_tower' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1} {\u03b1 : Type u_2}\n    [(i : I) \u2192 has_scalar \u03b1 (f i)] [(i : I) \u2192 has_scalar (f i) (g i)] [(i : I) \u2192 has_scalar \u03b1 (g i)]\n    [\u2200 (i : I), is_scalar_tower \u03b1 (f i) (g i)] :\n    is_scalar_tower \u03b1 ((i : I) \u2192 f i) ((i : I) \u2192 g i) :=\n  is_scalar_tower.mk\n    fun (x : \u03b1) (y : (i : I) \u2192 f i) (z : (i : I) \u2192 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 \u2192 Type v} {g : I \u2192 Type u_1}\n    {h : I \u2192 Type u_2} [(i : I) \u2192 has_scalar (f i) (g i)] [(i : I) \u2192 has_scalar (g i) (h i)]\n    [(i : I) \u2192 has_scalar (f i) (h i)] [\u2200 (i : I), is_scalar_tower (f i) (g i) (h i)] :\n    is_scalar_tower ((i : I) \u2192 f i) ((i : I) \u2192 g i) ((i : I) \u2192 h i) :=\n  is_scalar_tower.mk\n    fun (x : (i : I) \u2192 f i) (y : (i : I) \u2192 g i) (z : (i : I) \u2192 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 \u2192 Type v} (\u03b1 : Type u_1) {m : monoid \u03b1}\n    [(i : I) \u2192 mul_action \u03b1 (f i)] : mul_action \u03b1 ((i : I) \u2192 f i) :=\n  mul_action.mk sorry sorry\n\nprotected instance mul_action' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1}\n    {m : (i : I) \u2192 monoid (f i)} [(i : I) \u2192 mul_action (f i) (g i)] :\n    mul_action ((i : I) \u2192 f i) ((i : I) \u2192 g i) :=\n  mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action {I : Type u} {f : I \u2192 Type v} (\u03b1 : Type u_1) {m : monoid \u03b1}\n    {n : (i : I) \u2192 add_monoid (f i)} [(i : I) \u2192 distrib_mul_action \u03b1 (f i)] :\n    distrib_mul_action \u03b1 ((i : I) \u2192 f i) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1}\n    {m : (i : I) \u2192 monoid (f i)} {n : (i : I) \u2192 add_monoid (g i)}\n    [(i : I) \u2192 distrib_mul_action (f i) (g i)] :\n    distrib_mul_action ((i : I) \u2192 f i) ((i : I) \u2192 g i) :=\n  distrib_mul_action.mk sorry sorry\n\nprotected instance semimodule (I : Type u) (f : I \u2192 Type v) (\u03b1 : Type u_1) {r : semiring \u03b1}\n    {m : (i : I) \u2192 add_comm_monoid (f i)} [(i : I) \u2192 semimodule \u03b1 (f i)] :\n    semimodule \u03b1 ((i : I) \u2192 f i) :=\n  semimodule.mk sorry sorry\n\nprotected instance semimodule' {I : Type u} {f : I \u2192 Type v} {g : I \u2192 Type u_1}\n    {r : (i : I) \u2192 semiring (f i)} {m : (i : I) \u2192 add_comm_monoid (g i)}\n    [(i : I) \u2192 semimodule (f i) (g i)] : semimodule ((i : I) \u2192 f i) ((i : I) \u2192 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 --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables {\u03b1 : Type*} {\u03b2 : Type*}\n\n/--\n-/\ndef const (b : \u03b2)\n    := \u03bb _ : \u03b1, b\nnotation `\u2193`:max b:max := const b\n\nsection pointwise_classes --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\n/--\n-/\ninstance pointwise.has_le [has_le \u03b2] : has_le (\u03b1 \u2192 \u03b2)\n    := \u27e8\u03bb f g, \u03a0 x, f x \u2264 g x\u27e9\n\n/--\n-/\ninstance pointwise.has_zero [has_zero \u03b2] : has_zero (\u03b1 \u2192 \u03b2)\n    := \u27e8\u21930\u27e9\n\nend pointwise_classes --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\nnamespace algebra --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables (\u03b1) (\u03b2)\n\n/--\n-/\nclass has_left_add_distributivity [has_add \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 x y z : \u03b1, x * (y + z) = x * y + x * z)\n\n/--\n-/\nclass has_right_add_distributivity [has_add \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 x y z : \u03b1, (y + z) * x = y * x + z * x)\n\n/--\n-/\nclass has_left_sub_distributivity [has_sub \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 x y z : \u03b1, x * (y - z) = x * y - x * z)\n\n/--\n-/\nclass has_right_sub_distributivity [has_sub \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 x y z : \u03b1, (y - z) * x = y * x - z * x)\n\n/--\n-/\nclass has_lift_add_comm [has_lift_t \u03b1 \u03b2] [has_add \u03b1] [has_add \u03b2]\n    := (eq : \u03a0 x y : \u03b1, (\u2191(x + y) : \u03b2) = \u2191x + \u2191y)\n\n/--\n-/\nclass has_lift_sub_comm [has_lift_t \u03b1 \u03b2] [has_sub \u03b1] [has_sub \u03b2]\n    := (eq : \u03a0 x y : \u03b1, (\u2191(x - y) : \u03b2) = \u2191x - \u2191y)\n\n/--\n-/\nclass has_lift_mul_comm [has_lift_t \u03b1 \u03b2] [has_mul \u03b1] [has_mul \u03b2]\n    := (eq : \u03a0 x y : \u03b1, (\u2191(x * y) : \u03b2) = \u2191x * \u2191y)\n\n/--\n-/\nclass has_lift_inv_comm [has_lift_t \u03b1 \u03b2] [has_inv \u03b1] [has_inv \u03b2]\n    := (eq : \u03a0 a : \u03b1, (\u2191(a\u207b\u00b9) : \u03b2) = (\u2191a)\u207b\u00b9)\n\n/--\n-/\nclass has_right_unit [has_one \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 a : \u03b1, a * 1 = a)\n\n/--\n-/\nclass has_left_unit [has_one \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 a : \u03b1, 1 * a = a)\n\n/--\n-/\nclass has_add_le_add [has_le \u03b1] [has_add \u03b1]\n    := (le : \u03a0 {a b c d : \u03b1}, a \u2264 b \u2192 c \u2264 d \u2192 a + c \u2264 b + d)\n\n/--\n-/\nclass has_add_lt_add [has_lt \u03b1] [has_add \u03b1]\n    := (lt : \u03a0 {a b c d : \u03b1}, a < b \u2192 c < d \u2192 a + c < b + d)\n\n/--\n-/\nclass has_le_add_of_nonneg_of_le [has_le \u03b1] [has_zero \u03b1] [has_add \u03b1]\n    := (le : \u03a0 {a b c : \u03b1}, 0 \u2264 a \u2192 b \u2264 c \u2192 b \u2264 a + c)\n\n/--\n-/\nclass has_lt_add_of_le_of_pos [has_le \u03b1] [has_lt \u03b1] [has_zero \u03b1] [has_add \u03b1]\n    := (lt : \u03a0 {a b c : \u03b1}, 0 < a \u2192 b \u2264 c \u2192 b < a + c)\n\n/--\n-/\nclass has_add_nonneg [has_le \u03b1] [has_zero \u03b1] [has_add \u03b1]\n    := (le : \u03a0 {a b : \u03b1}, 0 \u2264 a \u2192 0 \u2264 b \u2192 0 \u2264 a + b)\n\n/--\n-/\nclass has_zero_mul_is_zero [has_zero \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 a : \u03b1, 0 * a = 0)\n\n/--\n-/\nclass has_mul_zero_is_zero [has_zero \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 a : \u03b1, a * 0 = 0)\n\n/--\n-/\nclass has_lift_zero_same [has_lift_t \u03b1 \u03b2] [has_zero \u03b1] [has_zero \u03b2]\n    := (eq : \u2191(0 : \u03b1) = (0 : \u03b2))\n\n/--\n-/\nclass has_lift_one_same [has_lift_t \u03b1 \u03b2] [has_one \u03b1] [has_one \u03b2]\n    := (eq : \u2191(1 : \u03b1) = (1 : \u03b2))\n\n/--\n-/\nclass has_zero_right_add_cancel [has_zero \u03b1] [has_add \u03b1]\n    := (eq : \u03a0 a : \u03b1, a + 0 = a)\n\n/--\n-/\nclass has_zero_left_add_cancel [has_zero \u03b1] [has_add \u03b1]\n    := (eq : \u03a0 a : \u03b1, 0 + a = a)\n\n/--\n-/\nclass has_sub_self_is_zero [has_zero \u03b1] [has_sub \u03b1]\n    := (eq : \u03a0 a : \u03b1, a - a = 0)\n\n/--\n-/\nclass has_mul_assoc [has_mul \u03b1]\n    := (eq : \u03a0 a b c : \u03b1, (a * b) * c = a * (b * c))\n\n/--\n-/\nclass has_add_sub_assoc [has_add \u03b1] [has_sub \u03b1]\n    := (eq : \u03a0 a b c : \u03b1, (a + b) - c = a + (b - c))\n\n/--\n-/\nclass has_le_sub_add_le [has_le \u03b1] [has_sub \u03b1] [has_add \u03b1]\n    := (le : \u03a0 {a b c : \u03b1}, a \u2264 c - b \u2192 a + b \u2264 c)\n\n/--\n-/\nclass has_le_pos_mul_preserves_right [has_lt \u03b1] [has_le \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (le : \u03a0 {a b c : \u03b1}, 0 < c \u2192 a \u2264 b \u2192 a * c \u2264 b * c)\n\n/--\n-/\nclass has_le_pos_mul_preserves_left [has_lt \u03b1] [has_le \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (le : \u03a0 {a b c : \u03b1}, 0 < c \u2192 a \u2264 b \u2192 c * a \u2264 c * b)\n\n/--\n-/\nclass has_lt_pos_mul_preserves_right [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (lt : \u03a0 {a b c : \u03b1}, 0 < c \u2192 a < b \u2192 a * c < b * c)\n\n/--\n-/\nclass has_le_nonneg_mul_preserves_left [has_lt \u03b1] [has_le \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (le : \u03a0 {a b c : \u03b1}, 0 \u2264 c \u2192 a \u2264 b \u2192 c * a \u2264 c * b)\n\n/--\n-/\nclass has_le_nonneg_mul_preserves_right [has_lt \u03b1] [has_le \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (le : \u03a0 {a b c : \u03b1}, 0 \u2264 c \u2192 a \u2264 b \u2192 a * c \u2264 b * c)\n\n/--\n-/\nclass has_lift_le_comm [has_lift_t \u03b1 \u03b2] [has_le \u03b1] [has_le \u03b2]\n    := (le : \u03a0 {x y : \u03b1}, x \u2264 y \u2192 \u2191x \u2264 (\u2191y : \u03b2))\n\n/--\n-/\nclass has_lift_lt_comm [has_lift_t \u03b1 \u03b2] [has_lt \u03b1] [has_lt \u03b2]\n    := (lt : \u03a0 {x y : \u03b1}, x < y \u2192 \u2191x < (\u2191y : \u03b2))\n\n/--\n-/\nclass has_lift_ne_comm [has_lift_t \u03b1 \u03b2]\n    := (ne : \u03a0 {x y : \u03b1}, x \u2260 y \u2192 \u2191x \u2260 (\u2191y : \u03b2))\n\n/--\n-/\nclass has_sub_add_sub_cancel [has_sub \u03b1] [has_add \u03b1]\n    := (eq : \u03a0 a b c : \u03b1, a - b + (b - c) = a - c)\n\n/--\n-/\nclass has_double_sub_cancel [has_sub \u03b1]\n    := (eq : \u03a0 a b : \u03b1, a - (a - b) = b)\n\n/--\n-/\nclass has_inv_mul_right_cancel_self [has_zero \u03b1] [has_one \u03b1] [has_inv \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 a : \u03b1, a \u2260 0 \u2192 a * a\u207b\u00b9 = 1)\n\n/--\n-/\nclass has_inv_mul_left_cancel_self [has_zero \u03b1] [has_one \u03b1] [has_inv \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 a : \u03b1, a \u2260 0 \u2192 a\u207b\u00b9 * a = 1)\n\n/--\n-/\nclass has_add_sub_exchange [has_add \u03b1] [has_sub \u03b1]\n    := (eq : \u03a0 a b c d : \u03b1, (a - b) + (c - d) = (c - b) + (a - d))\n\n/--\n-/\nclass has_zero_sub_is_neg [has_zero \u03b1] [has_neg \u03b1] [has_sub \u03b1]\n    := (eq : \u03a0 a : \u03b1, 0 - a = -a)\n\n/--\n-/\nclass has_inv_right_mul_lt_pos [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1] [has_inv \u03b1]\n    := (lt : \u03a0 {a b c : \u03b1}, 0 < b \u2192 a < c * b \u2192 a * b\u207b\u00b9 < c)\n\n/--\n-/\nclass has_right_mul_inv_lt_pos [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1] [has_inv \u03b1]\n    := (lt : \u03a0 {a b c : \u03b1}, 0 < b \u2192 c < b\u207b\u00b9 * a \u2192 b * c < a)\n\n/--\n-/\nclass has_left_mul_inv_lt_pos [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1] [has_inv \u03b1]\n    := (lt : \u03a0 {a b c : \u03b1}, 0 < b \u2192 c < a * b\u207b\u00b9 \u2192 c * b < a)\n\n/--\n-/\nclass has_left_mul_inv_lt_neg [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1] [has_inv \u03b1]\n    := (lt : \u03a0 {a b c : \u03b1}, b < 0 \u2192 a * b\u207b\u00b9 < c \u2192 b * c < a)\n\n/--\n-/\nclass has_sub_ne_zero_of_ne [has_zero \u03b1] [has_sub \u03b1]\n    := (ne : \u03a0 {a b : \u03b1}, a \u2260 b \u2192 a - b \u2260 0)\n\n/--\n-/\nclass has_lt_sub_neg [has_lt \u03b1] [has_zero \u03b1] [has_sub \u03b1]\n    := (lt : \u03a0 {a b : \u03b1}, a < b \u2192 a - b < 0)\n\n/--\n-/\nclass has_zero_lt_one [has_lt \u03b1] [has_zero \u03b1] [has_one \u03b1]\n    := (lt : 0 < (1 : \u03b1))\n\n/--\n-/\nclass has_pos_mul_neg_is_neg [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (lt : \u03a0 {a b : \u03b1}, 0 < a \u2192 b < 0 \u2192 a * b < 0)\n\n/--\n-/\nclass has_nonneg_mul_nonneg_is_nonneg [has_le \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (le : \u03a0 {a b : \u03b1}, 0 \u2264 a \u2192 0 \u2264 b \u2192 0 \u2264 a * b)\n\n/--\n-/\nclass has_squared_le_monotonic [has_le \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (le : \u03a0 {a b : \u03b1}, 0 \u2264 a \u2192 a \u2264 b \u2192 a * a \u2264 b * b)\n\n/--\n-/\nclass has_sub_pos [has_lt \u03b1] [has_zero \u03b1] [has_sub \u03b1]\n    := (lt : \u03a0 {a b : \u03b1}, a < b \u2192 0 < b - a)\n\n/--\n-/\nclass has_sub_sub [has_add \u03b1] [has_sub \u03b1]\n    := (eq : \u03a0 a b c : \u03b1, a - (b - c) = (a - b) + c)\n\n/--\n-/\nclass has_add_left_lt [has_lt \u03b1] [has_add \u03b1]\n    := (lt : \u03a0 a b c : \u03b1, a < b \u2192 c + a < c + b)\n\n/--\n-/\nclass has_left_inv_pos_lt [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1] [has_inv \u03b1]\n    := (lt : \u03a0 {a b c : \u03b1}, 0 < c \u2192 a < b \u2192 c\u207b\u00b9 * a < c\u207b\u00b9 * b)\n\n/--\n-/\nclass has_right_inv_pos_lt [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1] [has_inv \u03b1]\n    := (lt : \u03a0 {a b c : \u03b1}, 0 < c \u2192 a < b \u2192 a * c\u207b\u00b9 < b * c\u207b\u00b9)\n\n/--\n-/\nclass has_mul_pos [has_lt \u03b1] [has_zero \u03b1] [has_mul \u03b1]\n    := (lt : \u03a0 {a b : \u03b1}, 0 < a \u2192 0 < b \u2192 0 < a * b)\n\n/--\n-/\nclass has_inv_pos [has_lt \u03b1] [has_zero \u03b1] [has_inv \u03b1]\n    := (lt : \u03a0 {a : \u03b1}, 0 < a \u2192 0 < a\u207b\u00b9)\n\n/--\n-/\nclass has_inv_reverses_le [has_le \u03b1] [has_inv \u03b1]\n    := (le : \u03a0 {a b : \u03b1}, a \u2264 b \u2192 b\u207b\u00b9 \u2264 a\u207b\u00b9)\n\n/--\n-/\nclass has_inv_reverses_lt [has_lt \u03b1] [has_inv \u03b1]\n    := (lt : \u03a0 {a b : \u03b1}, a < b \u2192 b\u207b\u00b9 < a\u207b\u00b9)\n\n/--\n-/\nclass has_inv_mul_reverse [has_inv \u03b1] [has_mul \u03b1]\n    := (eq : \u03a0 a b : \u03b1, (a * b)\u207b\u00b9 = b\u207b\u00b9 * a\u207b\u00b9)\n\n/--\n-/\nstructure Half [has_lt \u03b1] [has_zero \u03b1] [has_add \u03b1]\n    := (map          : \u03b1 \u2192 \u03b1)\n       (preserve_pos : \u03a0 {x}, 0 < x \u2192 0 < map x)\n       (doubled_inv  : \u03a0 (x), map x + map x = x)\n\n/--\n-/\nstructure LiftCeil [has_lift_t nat \u03b1] [has_lt \u03b1]\n    := (map     : \u03b1 \u2192 nat)\n       (lift_lt : \u03a0 {a n}, map a < n \u2192 a < \u2191n)\n\nsection lemmas --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables {\u03b1 \u03b2}\n\n/--\n-/\ndef inv_sub_inv_lemma\n    [has_zero \u03b1]\n    [has_one \u03b1]\n    [has_inv \u03b1]\n    [has_mul \u03b1]\n    [has_sub \u03b1]\n    [has_right_unit \u03b1]\n    [has_left_unit \u03b1]\n    [has_inv_mul_right_cancel_self \u03b1]\n    [has_mul_assoc \u03b1]\n    [has_right_sub_distributivity \u03b1]\n    {a b : \u03b1}\n    (a_ne_0 : a \u2260 0)\n    : a\u207b\u00b9 - b\u207b\u00b9 = (1 - b\u207b\u00b9 * a) * a\u207b\u00b9 :=\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 \u03b1]\n    [has_one \u03b1]\n    [has_inv \u03b1]\n    [has_mul \u03b1]\n    [has_sub \u03b1]\n    [has_right_unit \u03b1]\n    [has_left_unit \u03b1]\n    [has_inv_mul_left_cancel_self \u03b1]\n    [has_mul_assoc \u03b1]\n    [has_left_sub_distributivity \u03b1]\n    {a b : \u03b1}\n    (a_ne_0 : a \u2260 0)\n    : a\u207b\u00b9 - b\u207b\u00b9 = a\u207b\u00b9 * (1 - a * b\u207b\u00b9) :=\n    begin\n        rw has_left_sub_distributivity.eq,\n        rw \u2190 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 \u03b1]\n    [has_zero \u03b1]\n    [has_one \u03b1]\n    [has_sub \u03b1]\n    [has_mul \u03b1]\n    [has_inv \u03b1]\n    [has_left_unit \u03b1]\n    [has_inv_mul_right_cancel_self \u03b1]\n    [has_right_sub_distributivity \u03b1]\n    [has_lift_zero_same nat \u03b1]\n    [has_lift_one_same nat \u03b1]\n    [has_lift_sub_comm nat \u03b1]\n    [has_lift_ne_comm nat \u03b1]\n    (n : nat)\n    : (\u2191n : \u03b1) * (\u2191n.succ)\u207b\u00b9 = 1 - (\u2191n.succ)\u207b\u00b9 :=\n    begin\n        rw \u2190 has_left_unit.eq (\u2191n.succ : \u03b1)\u207b\u00b9,\n\n        have succ_non_zero : \u2191n.succ \u2260 (0 : \u03b1),\n            rw (_ : 0 = (\u21910 : \u03b1)),\n            refine has_lift_ne_comm.ne (nat.succ_ne_zero _),\n            rw has_lift_zero_same.eq,\n\n        rw \u2190 has_inv_mul_right_cancel_self.eq _ succ_non_zero,\n        rw \u2190 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 = (\u21911 : \u03b1)),\n\n        rw \u2190 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 \u03b1]\n    [has_add \u03b1]\n    [has_mul \u03b1]\n    [has_right_add_distributivity \u03b1]\n    [has_left_unit \u03b1]\n    (a : \u03b1)\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 \u03b1]\n    [has_add \u03b1]\n    [has_mul \u03b1]\n    [has_left_add_distributivity \u03b1]\n    [has_right_unit \u03b1]\n    (a : \u03b1)\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 \u03b1]\n\n    [has_add \u03b1] [has_mul \u03b1]\n\n    [has_left_unit \u03b1]\n\n    [has_left_add_distributivity \u03b1] [has_right_add_distributivity \u03b1]\n\n    [has_mul_assoc \u03b1]\n\n    (a : \u03b1)\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 \u2190 two_mul_lemma,\n        rw \u2190 two_mul_lemma,\n        rw \u2190 has_mul_assoc.eq,\n        rw \u2190 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 \u03b1]\n\n    [has_add \u03b1] [has_mul \u03b1]\n\n    [has_right_unit \u03b1]\n\n    [has_left_add_distributivity \u03b1] [has_right_add_distributivity \u03b1]\n\n    [has_mul_assoc \u03b1]\n\n    (a : \u03b1)\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 \u2190 two_mul_lemma',\n        rw \u2190 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 \u03b1]\n    [has_one \u03b1]\n    [has_add \u03b1]\n    [has_mul \u03b1]\n\n    [has_zero_mul_is_zero \u03b1]\n    [has_mul_zero_is_zero \u03b1]\n\n    [has_right_unit \u03b1]\n    [has_left_unit \u03b1]\n\n    [has_left_add_distributivity \u03b1]\n    [has_right_add_distributivity \u03b1]\n\n    [has_lift_t nat \u03b1]\n    [has_lift_zero_same nat \u03b1]\n    [has_lift_one_same nat \u03b1]\n    [has_lift_add_comm nat \u03b1]\n\n    (a : \u03b1) (n : nat)\n\n    : a * \u2191n = \u2191n * 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 --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables (\u03b1 \u03b2)\n\n/--\n-/\ndef zero_is_lifted_zero_lemma\n    [has_zero \u03b1] [has_zero \u03b2] [has_lift_t \u03b1 \u03b2] [has_lift_zero_same \u03b1 \u03b2]\n    : (0 : \u03b2) = \u2191(0 : \u03b1)\n    := by rw has_lift_zero_same.eq\n\n--\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables [has_one \u03b1] [has_one \u03b2] [has_lift_t \u03b1 \u03b2] [has_lift_one_same \u03b1 \u03b2]\n\n/--\n-/\ndef one_is_lifted_one_lemma\n    : (1 : \u03b2) = \u2191(1 : \u03b1)\n    := by rw has_lift_one_same.eq\n\n--\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables [has_add \u03b1] [has_add \u03b2] [has_lift_add_comm \u03b1 \u03b2]\n\n/--\n-/\ndef two_is_lifted_two_lemma : (2 : \u03b2) = \u2191(2 : \u03b1) :=\n    begin\n        rw (_ : (2 : \u03b2) = \u2191(1 : \u03b1) + \u2191(1 : \u03b1)),\n        rw \u2190 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 : \u03b2) = \u2191(3 : \u03b1) :=\n    begin\n        rw (_ : (3 : \u03b2) = \u2191(1 : \u03b1) + \u2191(1 : \u03b1) + \u2191(1 : \u03b1)),\n        rw [\u2190 has_lift_add_comm.eq, \u2190 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 : \u03b2) = \u2191(4 : \u03b1) :=\n    begin\n        rw (_ : (4 : \u03b2) = \u2191(1 : \u03b1) + \u2191(1 : \u03b1) + (\u2191(1 : \u03b1) + \u2191(1 : \u03b1))),\n        rw [\u2190 has_lift_add_comm.eq, \u2190 has_lift_add_comm.eq],\n        refine rfl,\n        rw has_lift_one_same.eq,\n        refine rfl,\n    end\n\nend lifted_lemmas --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nend lemmas --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nend algebra --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\nopen algebra\n\nnamespace nat --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\n/--\n-/\ndef of_le_succ {n m : nat} (n_le_m_succ : n \u2264 m.succ) : n \u2264 m \u2228 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 \u2264 b) : a - c - (b - c) = a - b\n    := by rw [nat.sub_sub, \u2190 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 \u2264 n \u2192 m \u2264 n - k :=\n    begin\n        intros h,\n        rw \u2190 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 \u2264 n) : m \u2264 n - k\n    := le_sub_right_of_add_le (by { rw \u2190 nat.add_comm, refine h })\n\n/--\n-/\ndef le_add_of_sub_le_right {k m n} : n - k \u2264 m \u2192 n \u2264 m + k :=\n    begin\n        intros h,\n        rw \u2190 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\u2081 : a \u2264 b) (h\u2082 : c < d) : a + c < b + d\n    := lt_of_le_of_lt (nat.add_le_add_right h\u2081 c) (nat.add_lt_add_left h\u2082 b)\n\n/--\n-/\ndef lt_add_of_le_of_pos {a b c} (b_le_c : b \u2264 c) (zero_lt_a : 0 < a) : b < c + a\n    := nat.add_zero b \u25b8 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 \u2264 b) :  a - (b - c) = (a + c) - b :=\n    begin\n        rw \u2190 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 \u2264 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 \u2264 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 \u2264 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 \u2192 nat) (n : nat)\n    := u n.succ - u n\n\n/--\n-/\ndef power [has_one \u03b1] [has_mul \u03b1] (a : \u03b1) : nat \u2192 \u03b1\n| (nat.zero  ) := 1\n| (nat.succ n) := power n * a\n\nnamespace power --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables [has_one \u03b1] [has_mul \u03b1]\n\n/--\n-/\ndef mul_commute\n    [has_one \u03b2] [has_mul \u03b2]\n    (map     : \u03b1 \u2192 \u03b2)\n    (map_one : map 1 = 1)\n    (map_mul : \u03a0 x y, map (x * y) = map x * map y)\n    (a : \u03b1) (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 --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\nnamespace lift --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables (\u03b1)\n\n/--\n-/\ndef succ_pos\n    [has_lt \u03b1]\n    [has_zero \u03b1]\n    [has_lift_t nat \u03b1]\n    [has_lift_zero_same nat \u03b1]\n    [has_lift_lt_comm nat \u03b1]\n    (n : nat)\n    : 0 < (\u2191n.succ : \u03b1) :=\n    begin\n        rw zero_is_lifted_zero_lemma nat \u03b1,\n        refine has_lift_lt_comm.lt (nat.succ_pos _),\n    end\n\n/--\n-/\ndef succ_nonzero\n    [preorder \u03b1]\n    [has_zero \u03b1]\n    [has_lift_t nat \u03b1]\n    [has_lift_zero_same nat \u03b1]\n    [has_lift_lt_comm nat \u03b1]\n    (n : nat)\n    : (\u2191n.succ : \u03b1) \u2260 0\n    := (ne_of_gt (nat.lift.succ_pos \u03b1 _))\n\n/--\n-/\ndef zero_lt_one\n    [has_lt \u03b1]\n    [has_zero \u03b1]\n    [has_one \u03b1]\n    [has_lift_t nat \u03b1]\n    [has_lift_zero_same nat \u03b1]\n    [has_lift_one_same nat \u03b1]\n    [has_lift_lt_comm nat \u03b1]\n    : (0 : \u03b1) < 1 :=\n    begin\n        rw one_is_lifted_one_lemma nat \u03b1,\n        refine nat.lift.succ_pos \u03b1 _,\n    end\n\n/--\n-/\ninstance zero_lt_one_instance\n    [has_lt \u03b1]\n    [has_zero \u03b1]\n    [has_one \u03b1]\n    [has_lift_t nat \u03b1]\n    [has_lift_zero_same nat \u03b1]\n    [has_lift_one_same nat \u03b1]\n    [has_lift_lt_comm nat \u03b1]\n    : has_zero_lt_one \u03b1\n    := \u27e8zero_lt_one \u03b1\u27e9\n\nend lift --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nend nat --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\nsection sequences --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\n/--\n-/\ndef strictly_increasing\n    [has_lt \u03b1]\n    (seq : nat \u2192 \u03b1)\n    := \u03a0 n, seq n < seq n.succ\n\n/--\n-/\ndef increasing\n    [has_le \u03b1]\n    (seq : nat \u2192 \u03b1)\n    := \u03a0 n, seq n \u2264 seq n.succ\n\n/--\n-/\ndef strictly_increasing.as_increasing\n    [preorder \u03b1]\n    (seq : nat \u2192 \u03b1)\n    : strictly_increasing seq \u2192 increasing seq :=\n    begin\n        intros sinc _,\n        refine le_of_lt (sinc _),\n    end\n\n/--\n-/\ndef increasing_strong\n    [has_le \u03b1]\n    (seq : nat \u2192 \u03b1)\n    := \u03a0 i j, i \u2264 j \u2192 seq i \u2264 seq j\n\n/--\n-/\ndef increasing.as_increasing_strong\n    [preorder \u03b1]\n    (seq : nat \u2192 \u03b1)\n    : increasing seq \u2192 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 \u03b1]\n    (seq : nat \u2192 \u03b1)\n    : strictly_increasing seq \u2192 increasing_strong seq\n    := \u03bb s, increasing.as_increasing_strong _ (strictly_increasing.as_increasing _ s)\n\n/--\n-/\ndef non_increasing\n    [has_le \u03b1]\n    (seq : nat \u2192 \u03b1)\n    := \u03a0 n, seq (nat.succ n) \u2264 seq n\n\n/--\n-/\ndef non_increasing_strong\n    [has_le \u03b1]\n    (seq : nat \u2192 \u03b1) (k)\n    := \u03a0 n, seq (n + k) \u2264 seq n\n\n/--\n-/\ndef non_increasing.as_non_increasing_strong\n    [preorder \u03b1]\n    (seq : nat \u2192 \u03b1)\n    : non_increasing seq \u2192 \u03a0 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 \u2264 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 \u03b1] [has_le \u03b1]\n    (seq : nat \u2192 \u03b1) (\u03c6 : nat \u2192 nat)\n    : 0 \u2264 seq \u2192 0 \u2264 seq \u2218 \u03c6\n    := \u03bb p _, p (\u03c6 _)\n\n/--\n-/\ndef translate\n    (seq : nat \u2192 \u03b1)\n    (k)\n    (n)\n    := seq (k + n)\n\n/--\n-/\ndef translate.preserve_nonneg\n    [has_zero \u03b1] [has_le \u03b1]\n    (seq : nat \u2192 \u03b1)\n    : 0 \u2264 seq \u2192 0 \u2264 translate seq\n    := \u03bb p _ _, p _\n\n/--\n-/\ndef translate.monotonicity\n    [has_le \u03b1]\n    {a b : nat \u2192 \u03b1}\n    : a \u2264 b \u2192 translate a \u2264 translate b\n    := \u03bb p _ _, p _\n\n/--\n-/\ndef translate.combine\n    (seq : nat \u2192 \u03b1)\n    (i j)\n    : translate (translate seq i) j = translate seq (i + j)\n    := funext (\u03bb _, by rw [translate, translate, translate, nat.add_assoc])\n\n/--\n-/\ndef translate.compose_commute\n    (seq : nat \u2192 \u03b1)\n    (f : \u03b1 \u2192 \u03b2)\n    (n k)\n    : f (translate seq n k) = translate (f \u2218 seq) n k\n    := by rw [translate, translate]\n\n/--\n-/\ndef translate.compose_commute.funext\n    (seq : nat \u2192 \u03b1)\n    (f : \u03b1 \u2192 \u03b2)\n    (n)\n    : f \u2218 (translate seq n) = translate (f \u2218 seq) n\n    := funext (translate.compose_commute seq f n)\n\nend sequences --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\nsection series --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables [has_zero \u03b1] [has_add \u03b1]\n\n/--\n-/\ndef partial_sum (seq : nat \u2192 \u03b1) : nat \u2192 \u03b1\n| (nat.zero  ) := 0\n| (nat.succ n) := seq n + partial_sum n\n\n/--\n-/\ndef partial_sum.preserve_nonneg\n    [preorder \u03b1] [has_add_nonneg \u03b1]\n\n    (seq : nat \u2192 \u03b1)\n\n    : 0 \u2264 seq \u2192 0 \u2264 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 \u03b1] [has_mul_zero_is_zero \u03b1] [has_left_add_distributivity \u03b1]\n    (seq : nat \u2192 \u03b1)\n    (C)\n    : partial_sum (\u03bb k, C * seq k) = \u03bb 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 \u03b1] [has_zero_mul_is_zero \u03b1] [has_right_add_distributivity \u03b1]\n    (seq : nat \u2192 \u03b1)\n    (C)\n    : partial_sum (\u03bb k, seq k * C) = \u03bb 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 \u03b1]\n    [has_mul \u03b1]\n\n    [has_zero_mul_is_zero \u03b1]\n    [has_left_unit \u03b1]\n    [has_right_add_distributivity \u03b1]\n\n    [has_lift_t nat \u03b1]\n    [has_lift_zero_same nat \u03b1]\n    [has_lift_one_same nat \u03b1]\n    [has_lift_add_comm nat \u03b1]\n\n    (a : \u03b1)\n    (n : nat)\n\n    : \u2191n * a = partial_sum \u2193a 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 \u03b1]\n    [has_mul \u03b1]\n\n    [has_mul_zero_is_zero \u03b1]\n    [has_right_unit \u03b1]\n    [has_left_add_distributivity \u03b1]\n\n    [has_lift_t nat \u03b1]\n    [has_lift_zero_same nat \u03b1]\n    [has_lift_one_same nat \u03b1]\n    [has_lift_add_comm nat \u03b1]\n\n    (a : \u03b1)\n    (n : nat)\n\n    : a * \u2191n = partial_sum \u2193a 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 \u03b1] [has_add_le_add \u03b1]\n    {a b : nat \u2192 \u03b1}\n    : a \u2264 b \u2192 partial_sum a \u2264 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 \u03b1] [has_le_add_of_nonneg_of_le \u03b1]\n\n    (seq : nat \u2192 \u03b1) (nonneg : 0 \u2264 seq)\n\n    {m n}\n\n    : m \u2264 n \u2192 partial_sum seq m \u2264 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 \u2190 h,\n    end\n\n/--\n-/\ndef partial_sum.double_monotonicity\n    [preorder \u03b1] [has_le_add_of_nonneg_of_le \u03b1] [has_add_le_add \u03b1]\n\n    (a : nat \u2192 \u03b1) (na)\n    (b : nat \u2192 \u03b1) (nb)\n\n    : 0 \u2264 a \u2192 a \u2264 b \u2192 na \u2264 nb \u2192 partial_sum a na \u2264 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 \u03b1] [has_sub_self_is_zero \u03b1] [has_add_sub_assoc \u03b1]\n\n    (seq : nat \u2192 \u03b1)\n\n    {m n} (m_le_n : m \u2264 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 \u03b1]\n    [has_add_sub_assoc \u03b1]\n    [has_sub_self_is_zero \u03b1]\n\n    [preorder \u03b1]\n    [has_le_add_of_nonneg_of_le \u03b1]\n\n    (seq : nat \u2192 \u03b1) (nonneg : 0 \u2264 seq)\n\n    {m n} (m_le_n : m \u2264 n)\n\n    : 0 \u2264 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 \u2190 h,\n                rw has_sub_self_is_zero.eq,\n    end\n\n/--\n-/\ndef partial_sum.lower_differences\n    [has_sub \u03b1]\n    [has_sub_self_is_zero \u03b1]\n    [has_add_sub_assoc \u03b1]\n\n    [preorder \u03b1]\n    [has_add_le_add \u03b1]\n    [has_le_add_of_nonneg_of_le \u03b1]\n\n    (seq : nat \u2192 \u03b1) (nonneg : 0 \u2264 seq)\n\n    {k m n} (k_le_m : k \u2264 m) (m_le_n : m \u2264 n)\n\n    : partial_sum seq n - partial_sum seq m \u2264 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 \u2190 h,\n                rw has_sub_self_is_zero.eq,\n                refine partial_sum.lower_differences.bottom _ nonneg k_le_m,\n    end\n\n--\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables [has_sub \u03b1]\n\n/--\n-/\ndef shape_sum (seq : nat \u2192 \u03b1) (\u03c6 : nat \u2192 nat) (n : nat)\n    := partial_sum seq (\u03c6 n.succ) - partial_sum seq (\u03c6 n)\n\n/--\n-/\ndef shape_sum.unfold\n    [has_sub_self_is_zero \u03b1]\n    [has_add_sub_assoc \u03b1]\n    [has_sub_add_sub_cancel \u03b1]\n\n    (seq : nat \u2192 \u03b1)\n\n    (\u03c6) (sinc_\u03c6 : strictly_increasing \u03c6)\n\n    {m n} (m_le_n : m \u2264 n)\n\n    : partial_sum (translate (shape_sum seq \u03c6) m) (n - m)\n    = partial_sum (translate seq (\u03c6 m)) (\u03c6 n - \u03c6 m) :=\n\n    begin\n        let strong_inc := strictly_increasing.as_increasing_strong _ sinc_\u03c6,\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 \u2190 partial_sum.sub_as_translate seq (strong_inc _ _ h),\n                rw \u2190 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 --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\nsection absolute_value --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\nvariables [has_zero \u03b1] [has_add \u03b1]\n\n/--\n-/\ndef triangle_inequality\n    [has_zero \u03b2] [has_add \u03b2] [preorder \u03b2] [has_add_le_add \u03b2]\n\n    (abs          : \u03b1 \u2192 \u03b2)\n    (abs_zero     : abs 0 = 0)\n    (abs_triangle : \u03a0 x y, abs (x + y) \u2264 abs x + abs y)\n\n    (seq) (n)\n\n    : abs (partial_sum seq n) \u2264 partial_sum (abs \u2218 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 \u03b1] [has_add_nonneg \u03b1]\n\n    (abs           : \u03b1 \u2192 \u03b1)\n    (nonneg_to_abs : \u03a0 z, 0 \u2264 z \u2192 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 --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\n\nend riemann_hypothesis --\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014--\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\u2081 u\u2081 \n\nnamespace Mathlib\n\n/-!\n# Conjugate morphisms by isomorphisms\n\nAn isomorphism `\u03b1 : X \u2245 Y` defines\n- a monoid isomorphism `conj : End X \u2243* End Y` by `\u03b1.conj f = \u03b1.inv \u226b f \u226b \u03b1.hom`;\n- a group isomorphism `conj_Aut : Aut X \u2243* Aut Y` by `\u03b1.conj_Aut f = \u03b1.symm \u226a\u226b f \u226a\u226b \u03b1`.\n\nFor completeness, we also define `hom_congr : (X \u2245 X\u2081) \u2192 (Y \u2245 Y\u2081) \u2192 (X \u27f6 Y) \u2243 (X\u2081 \u27f6 Y\u2081)`, cf. `equiv.arrow_congr`.\n-/\n\nnamespace category_theory\n\n\nnamespace iso\n\n\n/-- If `X` is isomorphic to `X\u2081` and `Y` is isomorphic to `Y\u2081`, then\nthere is a natural bijection between `X \u27f6 Y` and `X\u2081 \u27f6 Y\u2081`. See also `equiv.arrow_congr`. -/\ndef hom_congr {C : Type u} [category C] {X : C} {Y : C} {X\u2081 : C} {Y\u2081 : C} (\u03b1 : X \u2245 X\u2081)\n    (\u03b2 : Y \u2245 Y\u2081) : (X \u27f6 Y) \u2243 (X\u2081 \u27f6 Y\u2081) :=\n  equiv.mk (fun (f : X \u27f6 Y) => inv \u03b1 \u226b f \u226b hom \u03b2) (fun (f : X\u2081 \u27f6 Y\u2081) => hom \u03b1 \u226b f \u226b inv \u03b2) sorry\n    sorry\n\n@[simp] theorem hom_congr_apply {C : Type u} [category C] {X : C} {Y : C} {X\u2081 : C} {Y\u2081 : C}\n    (\u03b1 : X \u2245 X\u2081) (\u03b2 : Y \u2245 Y\u2081) (f : X \u27f6 Y) : coe_fn (hom_congr \u03b1 \u03b2) f = inv \u03b1 \u226b f \u226b hom \u03b2 :=\n  rfl\n\ntheorem hom_congr_comp {C : Type u} [category C] {X : C} {Y : C} {Z : C} {X\u2081 : C} {Y\u2081 : C} {Z\u2081 : C}\n    (\u03b1 : X \u2245 X\u2081) (\u03b2 : Y \u2245 Y\u2081) (\u03b3 : Z \u2245 Z\u2081) (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n    coe_fn (hom_congr \u03b1 \u03b3) (f \u226b g) = coe_fn (hom_congr \u03b1 \u03b2) f \u226b coe_fn (hom_congr \u03b2 \u03b3) g :=\n  sorry\n\n@[simp] theorem hom_congr_refl {C : Type u} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081 : C} {Y\u2081 : C} {X\u2082 : C} {Y\u2082 : C}\n    {X\u2083 : C} {Y\u2083 : C} (\u03b1\u2081 : X\u2081 \u2245 X\u2082) (\u03b2\u2081 : Y\u2081 \u2245 Y\u2082) (\u03b1\u2082 : X\u2082 \u2245 X\u2083) (\u03b2\u2082 : Y\u2082 \u2245 Y\u2083) (f : X\u2081 \u27f6 Y\u2081) :\n    coe_fn (hom_congr (\u03b1\u2081 \u226a\u226b \u03b1\u2082) (\u03b2\u2081 \u226a\u226b \u03b2\u2082)) f =\n        coe_fn (equiv.trans (hom_congr \u03b1\u2081 \u03b2\u2081) (hom_congr \u03b1\u2082 \u03b2\u2082)) f :=\n  sorry\n\n@[simp] theorem hom_congr_symm {C : Type u} [category C] {X\u2081 : C} {Y\u2081 : C} {X\u2082 : C} {Y\u2082 : C}\n    (\u03b1 : X\u2081 \u2245 X\u2082) (\u03b2 : Y\u2081 \u2245 Y\u2082) : equiv.symm (hom_congr \u03b1 \u03b2) = hom_congr (symm \u03b1) (symm \u03b2) :=\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} (\u03b1 : X \u2245 Y) : End X \u2243* End Y :=\n  mul_equiv.mk (equiv.to_fun (hom_congr \u03b1 \u03b1)) (equiv.inv_fun (hom_congr \u03b1 \u03b1)) sorry sorry sorry\n\ntheorem conj_apply {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : End X) :\n    coe_fn (conj \u03b1) f = inv \u03b1 \u226b f \u226b hom \u03b1 :=\n  rfl\n\n@[simp] theorem conj_comp {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : End X)\n    (g : End X) : coe_fn (conj \u03b1) (f \u226b g) = coe_fn (conj \u03b1) f \u226b coe_fn (conj \u03b1) g :=\n  mul_equiv.map_mul (conj \u03b1) g f\n\n@[simp] theorem conj_id {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) :\n    coe_fn (conj \u03b1) \ud835\udfd9 = \ud835\udfd9 :=\n  mul_equiv.map_one (conj \u03b1)\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} (\u03b1 : X \u2245 Y) {Z : C} (\u03b2 : Y \u2245 Z)\n    (f : End X) : coe_fn (conj (\u03b1 \u226a\u226b \u03b2)) f = coe_fn (conj \u03b2) (coe_fn (conj \u03b1) f) :=\n  hom_congr_trans \u03b1 \u03b1 \u03b2 \u03b2 f\n\n@[simp] theorem symm_self_conj {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : End X) :\n    coe_fn (conj (symm \u03b1)) (coe_fn (conj \u03b1) f) = f :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (coe_fn (conj (symm \u03b1)) (coe_fn (conj \u03b1) f) = f))\n        (Eq.symm (trans_conj \u03b1 (symm \u03b1) f))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (conj (\u03b1 \u226a\u226b symm \u03b1)) f = f)) (self_symm_id \u03b1)))\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} (\u03b1 : X \u2245 Y) (f : End Y) :\n    coe_fn (conj \u03b1) (coe_fn (conj (symm \u03b1)) f) = f :=\n  symm_self_conj (symm \u03b1) f\n\n@[simp] theorem conj_pow {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : End X) (n : \u2115) :\n    coe_fn (conj \u03b1) (f ^ n) = coe_fn (conj \u03b1) f ^ n :=\n  monoid_hom.map_pow (mul_equiv.to_monoid_hom (conj \u03b1)) 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} (\u03b1 : X \u2245 Y) : Aut X \u2243* Aut Y :=\n  mul_equiv.trans (mul_equiv.symm (Aut.units_End_equiv_Aut X))\n    (mul_equiv.trans (units.map_equiv (conj \u03b1)) (Aut.units_End_equiv_Aut Y))\n\ntheorem conj_Aut_apply {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : Aut X) :\n    coe_fn (conj_Aut \u03b1) f = symm \u03b1 \u226a\u226b f \u226a\u226b \u03b1 :=\n  sorry\n\n@[simp] theorem conj_Aut_hom {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : Aut X) :\n    hom (coe_fn (conj_Aut \u03b1) f) = coe_fn (conj \u03b1) (hom f) :=\n  rfl\n\n@[simp] theorem trans_conj_Aut {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) {Z : C}\n    (\u03b2 : Y \u2245 Z) (f : Aut X) :\n    coe_fn (conj_Aut (\u03b1 \u226a\u226b \u03b2)) f = coe_fn (conj_Aut \u03b2) (coe_fn (conj_Aut \u03b1) f) :=\n  sorry\n\n@[simp] theorem conj_Aut_mul {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : Aut X)\n    (g : Aut X) : coe_fn (conj_Aut \u03b1) (f * g) = coe_fn (conj_Aut \u03b1) f * coe_fn (conj_Aut \u03b1) g :=\n  mul_equiv.map_mul (conj_Aut \u03b1) f g\n\n@[simp] theorem conj_Aut_trans {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : Aut X)\n    (g : Aut X) : coe_fn (conj_Aut \u03b1) (f \u226a\u226b g) = coe_fn (conj_Aut \u03b1) f \u226a\u226b coe_fn (conj_Aut \u03b1) g :=\n  conj_Aut_mul \u03b1 g f\n\n@[simp] theorem conj_Aut_pow {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : Aut X)\n    (n : \u2115) : coe_fn (conj_Aut \u03b1) (f ^ n) = coe_fn (conj_Aut \u03b1) f ^ n :=\n  monoid_hom.map_pow (mul_equiv.to_monoid_hom (conj_Aut \u03b1)) f n\n\n@[simp] theorem conj_Aut_gpow {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (f : Aut X)\n    (n : \u2124) : coe_fn (conj_Aut \u03b1) (f ^ n) = coe_fn (conj_Aut \u03b1) f ^ n :=\n  monoid_hom.map_gpow (mul_equiv.to_monoid_hom (conj_Aut \u03b1)) f n\n\nend iso\n\n\nnamespace functor\n\n\ntheorem map_hom_congr {C : Type u} [category C] {D : Type u\u2081} [category D] (F : C \u2964 D) {X : C}\n    {Y : C} {X\u2081 : C} {Y\u2081 : C} (\u03b1 : X \u2245 X\u2081) (\u03b2 : Y \u2245 Y\u2081) (f : X \u27f6 Y) :\n    map F (coe_fn (iso.hom_congr \u03b1 \u03b2) f) =\n        coe_fn (iso.hom_congr (map_iso F \u03b1) (map_iso F \u03b2)) (map F f) :=\n  sorry\n\ntheorem map_conj {C : Type u} [category C] {D : Type u\u2081} [category D] (F : C \u2964 D) {X : C} {Y : C}\n    (\u03b1 : X \u2245 Y) (f : End X) :\n    map F (coe_fn (iso.conj \u03b1) f) = coe_fn (iso.conj (map_iso F \u03b1)) (map F f) :=\n  map_hom_congr F \u03b1 \u03b1 f\n\ntheorem map_conj_Aut {C : Type u} [category C] {D : Type u\u2081} [category D] (F : C \u2964 D) {X : C}\n    {Y : C} (\u03b1 : X \u2245 Y) (f : Aut X) :\n    map_iso F (coe_fn (iso.conj_Aut \u03b1) f) = coe_fn (iso.conj_Aut (map_iso F \u03b1)) (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\u2081 u\u2082 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 D) {J : Type v} (f : J \u2192 C) {P : C} (g : (j : J) \u2192 P \u27f6 f j) : is_limit (functor.map_cone G (fan.mk P g)) \u2243 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 D) {J : Type v} (f : J \u2192 C) [preserves_limit (discrete.functor f) G] {P : C} (g : (j : J) \u2192 P \u27f6 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 D) {J : Type v} (f : J \u2192 C) [reflects_limit (discrete.functor f) G] {P : C} (g : (j : J) \u2192 P \u27f6 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 D) {J : Type v} (f : J \u2192 C) [has_product f] [preserves_limit (discrete.functor f) G] : is_limit (fan.mk (functor.obj G (\u220f f)) fun (j : J) => functor.map G (pi.\u03c0 f j)) :=\n  is_limit_fan_mk_obj_of_is_limit G f (fun (j : J) => pi.\u03c0 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 D) {J : Type v} (f : J \u2192 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.\u03c0 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 D) {J : Type v} (f : J \u2192 C) [has_product f] [has_product fun (j : J) => functor.obj G (f j)] [preserves_limit (discrete.functor f) G] : functor.obj G (\u220f f) \u2245 \u220f 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 D) {J : Type v} (f : J \u2192 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 D) {J : Type v} (f : J \u2192 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u03b1 \u03b2` is an extension of `local_equiv \u03b1 \u03b2`, 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 (\u03b1 : Type u_5) (\u03b2 : Type u_6) [topological_space \u03b1] [topological_space \u03b2] \nextends local_equiv \u03b1 \u03b2\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : \u03b1 \u2243\u209c \u03b2) : local_homeomorph \u03b1 \u03b2 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] : has_coe_to_fun (local_homeomorph \u03b1 \u03b2) :=\n  has_coe_to_fun.mk (fun (e : local_homeomorph \u03b1 \u03b2) => \u03b1 \u2192 \u03b2)\n    fun (e : local_homeomorph \u03b1 \u03b2) => local_equiv.to_fun (to_local_equiv e)\n\n/-- The inverse of a local homeomorphism -/\nprotected def symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_homeomorph \u03b2 \u03b1 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : continuous_on (\u21d1e) (local_equiv.source (to_local_equiv e)) :=\n  continuous_to_fun e\n\ntheorem continuous_on_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : continuous_on (\u21d1(local_homeomorph.symm e)) (local_equiv.target (to_local_equiv e)) :=\n  continuous_inv_fun e\n\n@[simp] theorem mk_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_equiv \u03b1 \u03b2) (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)) : \u21d1(mk e a b c d) = \u21d1e :=\n  rfl\n\n@[simp] theorem mk_coe_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_equiv \u03b1 \u03b2) (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)) : \u21d1(local_homeomorph.symm (mk e a b c d)) = \u21d1(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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_equiv.to_fun (to_local_equiv e) = \u21d1e :=\n  rfl\n\n@[simp] theorem inv_fun_eq_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_equiv.inv_fun (to_local_equiv e) = \u21d1(local_homeomorph.symm e) :=\n  rfl\n\n@[simp] theorem coe_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : \u21d1(to_local_equiv e) = \u21d1e :=\n  rfl\n\n@[simp] theorem coe_coe_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : \u21d1(local_equiv.symm (to_local_equiv e)) = \u21d1(local_homeomorph.symm e) :=\n  rfl\n\n@[simp] theorem map_source {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (h : x \u2208 local_equiv.source (to_local_equiv e)) : coe_fn e x \u2208 local_equiv.target (to_local_equiv e) :=\n  local_equiv.map_source' (to_local_equiv e) h\n\n@[simp] theorem map_target {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b2} (h : x \u2208 local_equiv.target (to_local_equiv e)) : coe_fn (local_homeomorph.symm e) x \u2208 local_equiv.source (to_local_equiv e) :=\n  local_equiv.map_target' (to_local_equiv e) h\n\n@[simp] theorem left_inv {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (h : x \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b2} (h : x \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_equiv.source (to_local_equiv e) \u2286 \u21d1e \u207b\u00b9' local_equiv.target (to_local_equiv e) :=\n  fun (_x : \u03b1) (h : _x \u2208 local_equiv.source (to_local_equiv e)) => map_source e h\n\ntheorem eq_of_local_equiv_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} (h : to_local_equiv e = to_local_equiv e') : e = e' := sorry\n\ntheorem eventually_left_inverse {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (hx : x \u2208 local_equiv.source (to_local_equiv e)) : filter.eventually (fun (y : \u03b1) => 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' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b2} (hx : x \u2208 local_equiv.target (to_local_equiv e)) : filter.eventually (fun (y : \u03b1) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b2} (hx : x \u2208 local_equiv.target (to_local_equiv e)) : filter.eventually (fun (y : \u03b2) => 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' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (hx : x \u2208 local_equiv.source (to_local_equiv e)) : filter.eventually (fun (y : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (hx : x \u2208 local_equiv.source (to_local_equiv e)) : filter.eventually (fun (x' : \u03b1) => coe_fn e x' \u2260 coe_fn e x) (nhds_within x (singleton x\u1d9c)) := sorry\n\ntheorem image_eq_target_inter_inv_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b1} (h : s \u2286 local_equiv.source (to_local_equiv e)) : \u21d1e '' s = local_equiv.target (to_local_equiv e) \u2229 \u21d1(local_homeomorph.symm e) \u207b\u00b9' s :=\n  local_equiv.image_eq_target_inter_inv_preimage (to_local_equiv e) h\n\ntheorem image_inter_source_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) : \u21d1e '' (s \u2229 local_equiv.source (to_local_equiv e)) =\n  local_equiv.target (to_local_equiv e) \u2229 \u21d1(local_homeomorph.symm e) \u207b\u00b9' (s \u2229 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b2} (h : s \u2286 local_equiv.target (to_local_equiv e)) : \u21d1(local_homeomorph.symm e) '' s = local_equiv.source (to_local_equiv e) \u2229 \u21d1e \u207b\u00b9' s :=\n  image_eq_target_inter_inv_preimage (local_homeomorph.symm e) h\n\ntheorem symm_image_inter_target_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b2) : \u21d1(local_homeomorph.symm e) '' (s \u2229 local_equiv.target (to_local_equiv e)) =\n  local_equiv.source (to_local_equiv e) \u2229 \u21d1e \u207b\u00b9' (s \u2229 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b1 \u03b2) (h : \u2200 (x : \u03b1), coe_fn e x = coe_fn e' x) (hinv : \u2200 (x : \u03b2), 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : to_local_equiv (local_homeomorph.symm e) = local_equiv.symm (to_local_equiv e) :=\n  rfl\n\ntheorem symm_source {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_equiv.source (to_local_equiv (local_homeomorph.symm e)) = local_equiv.target (to_local_equiv e) :=\n  rfl\n\ntheorem symm_target {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (h : x \u2208 local_equiv.source (to_local_equiv e)) : continuous_at (\u21d1e) 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b2} (h : x \u2208 local_equiv.target (to_local_equiv e)) : continuous_at (\u21d1(local_homeomorph.symm e)) x :=\n  local_homeomorph.continuous_at (local_homeomorph.symm e) h\n\ntheorem tendsto_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (hx : x \u2208 local_equiv.source (to_local_equiv e)) : filter.tendsto (\u21d1(local_homeomorph.symm e)) (nhds (coe_fn e x)) (nhds x) := sorry\n\ntheorem map_nhds_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (hx : x \u2208 local_equiv.source (to_local_equiv e)) : filter.map (\u21d1e) (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b2) : local_equiv.source (to_local_equiv e) \u2229 \u21d1e \u207b\u00b9' interior s = local_equiv.source (to_local_equiv e) \u2229 interior (\u21d1e \u207b\u00b9' s) := sorry\n\ntheorem preimage_open_of_open {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b2} (hs : is_open s) : is_open (local_equiv.source (to_local_equiv e) \u2229 \u21d1e \u207b\u00b9' s) :=\n  continuous_on.preimage_open_of_open (local_homeomorph.continuous_on e) (open_source e) hs\n\ntheorem preimage_open_of_open_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b1} (hs : is_open s) : is_open (local_equiv.target (to_local_equiv e) \u2229 \u21d1(local_homeomorph.symm e) \u207b\u00b9' 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b1} (hs : is_open s) (h : s \u2286 local_equiv.source (to_local_equiv e)) : is_open (\u21d1e '' s) :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (is_open (\u21d1e '' 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' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b1} (hs : is_open s) : is_open (\u21d1e '' (s \u2229 local_equiv.source (to_local_equiv e))) := sorry\n\n/-- Restricting a local homeomorphism `e` to `e.source \u2229 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) (hs : is_open s) : local_homeomorph \u03b1 \u03b2 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) (hs : is_open s) : local_equiv.source (to_local_equiv (local_homeomorph.restr_open e s hs)) = local_equiv.source (to_local_equiv e) \u2229 s :=\n  rfl\n\n/-- Restricting a local homeomorphism `e` to `e.source \u2229 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) : local_homeomorph \u03b1 \u03b2 :=\n  local_homeomorph.restr_open e (interior s) is_open_interior\n\n@[simp] theorem restr_to_local_equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) : \u21d1(local_homeomorph.restr e s) = \u21d1e :=\n  rfl\n\n@[simp] theorem restr_coe_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) : \u21d1(local_homeomorph.symm (local_homeomorph.restr e s)) = \u21d1(local_homeomorph.symm e) :=\n  rfl\n\ntheorem restr_source {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) : local_equiv.source (to_local_equiv (local_homeomorph.restr e s)) = local_equiv.source (to_local_equiv e) \u2229 interior s :=\n  rfl\n\ntheorem restr_target {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) : local_equiv.target (to_local_equiv (local_homeomorph.restr e s)) =\n  local_equiv.target (to_local_equiv e) \u2229 \u21d1(local_homeomorph.symm e) \u207b\u00b9' interior s :=\n  rfl\n\ntheorem restr_source' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) (hs : is_open s) : local_equiv.source (to_local_equiv (local_homeomorph.restr e s)) = local_equiv.source (to_local_equiv e) \u2229 s := sorry\n\ntheorem restr_to_local_equiv' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {s : set \u03b1} (h : local_equiv.source (to_local_equiv e) \u2286 s) : local_homeomorph.restr e s = e := sorry\n\n@[simp] theorem restr_univ {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : set \u03b1) : local_homeomorph.restr e (local_equiv.source (to_local_equiv e) \u2229 s) = local_homeomorph.restr e s := sorry\n\n/-- The identity on the whole space as a local homeomorphism. -/\nprotected def refl (\u03b1 : Type u_1) [topological_space \u03b1] : local_homeomorph \u03b1 \u03b1 :=\n  homeomorph.to_local_homeomorph (homeomorph.refl \u03b1)\n\n@[simp] theorem refl_local_equiv {\u03b1 : Type u_1} [topological_space \u03b1] : to_local_equiv (local_homeomorph.refl \u03b1) = local_equiv.refl \u03b1 :=\n  rfl\n\ntheorem refl_source {\u03b1 : Type u_1} [topological_space \u03b1] : local_equiv.source (to_local_equiv (local_homeomorph.refl \u03b1)) = set.univ :=\n  rfl\n\ntheorem refl_target {\u03b1 : Type u_1} [topological_space \u03b1] : local_equiv.target (to_local_equiv (local_homeomorph.refl \u03b1)) = set.univ :=\n  rfl\n\n@[simp] theorem refl_symm {\u03b1 : Type u_1} [topological_space \u03b1] : local_homeomorph.symm (local_homeomorph.refl \u03b1) = local_homeomorph.refl \u03b1 :=\n  rfl\n\n@[simp] theorem refl_coe {\u03b1 : Type u_1} [topological_space \u03b1] : \u21d1(local_homeomorph.refl \u03b1) = id :=\n  rfl\n\n/-- The identity local equiv on a set `s` -/\ndef of_set {\u03b1 : Type u_1} [topological_space \u03b1] (s : set \u03b1) (hs : is_open s) : local_homeomorph \u03b1 \u03b1 :=\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 {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} (hs : is_open s) : to_local_equiv (of_set s hs) = local_equiv.of_set s :=\n  rfl\n\ntheorem of_set_source {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} (hs : is_open s) : local_equiv.source (to_local_equiv (of_set s hs)) = s :=\n  rfl\n\ntheorem of_set_target {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} (hs : is_open s) : local_equiv.target (to_local_equiv (of_set s hs)) = s :=\n  rfl\n\n@[simp] theorem of_set_coe {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} (hs : is_open s) : \u21d1(of_set s hs) = id :=\n  rfl\n\n@[simp] theorem of_set_symm {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} (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 {\u03b1 : Type u_1} [topological_space \u03b1] : of_set set.univ is_open_univ = local_homeomorph.refl \u03b1 := sorry\n\n/-- Composition of two local homeomorphisms when the target of the first and the source of\nthe second coincide. -/\nprotected def trans' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) (h : local_equiv.target (to_local_equiv e) = local_equiv.source (to_local_equiv e')) : local_homeomorph \u03b1 \u03b3 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : local_homeomorph \u03b1 \u03b3 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : \u21d1(local_homeomorph.trans e e') = \u21d1e' \u2218 \u21d1e :=\n  rfl\n\n@[simp] theorem coe_trans_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : \u21d1(local_homeomorph.symm (local_homeomorph.trans e e')) = \u21d1(local_homeomorph.symm e) \u2218 \u21d1(local_homeomorph.symm e') :=\n  rfl\n\ntheorem trans_symm_eq_symm_trans_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : local_equiv.source (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.source (to_local_equiv e) \u2229 \u21d1e \u207b\u00b9' local_equiv.source (to_local_equiv e') :=\n  local_equiv.trans_source (to_local_equiv e) (to_local_equiv e')\n\ntheorem trans_source' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : local_equiv.source (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.source (to_local_equiv e) \u2229\n    \u21d1e \u207b\u00b9' (local_equiv.target (to_local_equiv e) \u2229 local_equiv.source (to_local_equiv e')) :=\n  local_equiv.trans_source' (to_local_equiv e) (to_local_equiv e')\n\ntheorem trans_source'' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : local_equiv.source (to_local_equiv (local_homeomorph.trans e e')) =\n  \u21d1(local_homeomorph.symm e) '' (local_equiv.target (to_local_equiv e) \u2229 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : \u21d1e '' local_equiv.source (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.target (to_local_equiv e) \u2229 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : local_equiv.target (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.target (to_local_equiv e') \u2229 \u21d1(local_homeomorph.symm e') \u207b\u00b9' local_equiv.target (to_local_equiv e) :=\n  rfl\n\ntheorem trans_target' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : local_equiv.target (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.target (to_local_equiv e') \u2229\n    \u21d1(local_homeomorph.symm e') \u207b\u00b9' (local_equiv.source (to_local_equiv e') \u2229 local_equiv.target (to_local_equiv e)) :=\n  trans_source' (local_homeomorph.symm e') (local_homeomorph.symm e)\n\ntheorem trans_target'' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : local_equiv.target (to_local_equiv (local_homeomorph.trans e e')) =\n  \u21d1e' '' (local_equiv.source (to_local_equiv e') \u2229 local_equiv.target (to_local_equiv e)) :=\n  trans_source'' (local_homeomorph.symm e') (local_homeomorph.symm e)\n\ntheorem inv_image_trans_target {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) : \u21d1(local_homeomorph.symm e') '' local_equiv.target (to_local_equiv (local_homeomorph.trans e e')) =\n  local_equiv.source (to_local_equiv e') \u2229 local_equiv.target (to_local_equiv e) :=\n  image_trans_source (local_homeomorph.symm e') (local_homeomorph.symm e)\n\ntheorem trans_assoc {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) (e'' : local_homeomorph \u03b3 \u03b4) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_homeomorph.trans e (local_homeomorph.refl \u03b2) = e :=\n  eq_of_local_equiv_eq (local_equiv.trans_refl (to_local_equiv e))\n\n@[simp] theorem refl_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_homeomorph.trans (local_homeomorph.refl \u03b1) e = e :=\n  eq_of_local_equiv_eq (local_equiv.refl_trans (to_local_equiv e))\n\ntheorem trans_of_set {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b2} (hs : is_open s) : local_homeomorph.trans e (of_set s hs) = local_homeomorph.restr e (\u21d1e \u207b\u00b9' s) := sorry\n\ntheorem trans_of_set' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b2} (hs : is_open s) : local_homeomorph.trans e (of_set s hs) = local_homeomorph.restr e (local_equiv.source (to_local_equiv e) \u2229 \u21d1e \u207b\u00b9' s) := sorry\n\ntheorem of_set_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b1} (hs : is_open s) : local_homeomorph.trans (of_set s hs) e = local_homeomorph.restr e s := sorry\n\ntheorem of_set_trans' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) {s : set \u03b1} (hs : is_open s) : local_homeomorph.trans (of_set s hs) e = local_homeomorph.restr e (local_equiv.source (to_local_equiv e) \u2229 s) := sorry\n\n@[simp] theorem of_set_trans_of_set {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} (hs : is_open s) {s' : set \u03b1} (hs' : is_open s') : local_homeomorph.trans (of_set s hs) (of_set s' hs') = of_set (s \u2229 s') (is_open_inter hs hs') := sorry\n\ntheorem restr_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3) (s : set \u03b1) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b1 \u03b2) :=\n  local_equiv.source (to_local_equiv e) = local_equiv.source (to_local_equiv e') \u2227\n    set.eq_on (\u21d1e) (\u21d1e') (local_equiv.source (to_local_equiv e))\n\ntheorem eq_on_source_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b1 \u03b2) : eq_on_source e e' \u2194 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] : setoid (local_homeomorph \u03b1 \u03b2) :=\n  setoid.mk eq_on_source sorry\n\ntheorem eq_on_source_refl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : e \u2248 e :=\n  setoid.refl e\n\n/-- If two local homeomorphisms are equivalent, so are their inverses -/\ntheorem eq_on_source.symm' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} (h : e \u2248 e') : local_homeomorph.symm e \u2248 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} (h : e \u2248 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} (h : e \u2248 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} (h : e \u2248 e') : set.eq_on (\u21d1e) (\u21d1e') (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} (h : e \u2248 e') : set.eq_on (\u21d1(local_homeomorph.symm e)) (\u21d1(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' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} {f : local_homeomorph \u03b2 \u03b3} {f' : local_homeomorph \u03b2 \u03b3} (he : e \u2248 e') (hf : f \u2248 f') : local_homeomorph.trans e f \u2248 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} (he : e \u2248 e') (s : set \u03b1) : local_homeomorph.restr e s \u2248 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_homeomorph.trans e (local_homeomorph.symm e) \u2248 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) : local_homeomorph.trans (local_homeomorph.symm e) e \u2248 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {e : local_homeomorph \u03b1 \u03b2} {e' : local_homeomorph \u03b1 \u03b2} (h : e \u2248 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) : local_homeomorph (\u03b1 \u00d7 \u03b3) (\u03b2 \u00d7 \u03b4) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) : to_local_equiv (prod e e') = local_equiv.prod (to_local_equiv e) (to_local_equiv e') :=\n  rfl\n\ntheorem prod_source {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) : \u21d1(prod e e') = fun (p : \u03b1 \u00d7 \u03b3) => (coe_fn e (prod.fst p), coe_fn e' (prod.snd p)) :=\n  rfl\n\ntheorem prod_coe_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) : \u21d1(local_homeomorph.symm (prod e e')) =\n  fun (p : \u03b2 \u00d7 \u03b4) => (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] (e : local_homeomorph \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) : local_homeomorph.symm (prod e e') = prod (local_homeomorph.symm e) (local_homeomorph.symm e') :=\n  rfl\n\n@[simp] theorem prod_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] {\u03b7 : Type u_5} {\u03b5 : Type u_6} [topological_space \u03b7] [topological_space \u03b5] (e : local_homeomorph \u03b1 \u03b2) (f : local_homeomorph \u03b2 \u03b3) (e' : local_homeomorph \u03b4 \u03b7) (f' : local_homeomorph \u03b7 \u03b5) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) {f : \u03b2 \u2192 \u03b3} {s : set \u03b2} {x : \u03b2} (h : x \u2208 local_equiv.target (to_local_equiv e)) : continuous_within_at f s x \u2194 continuous_within_at (f \u2218 \u21d1e) (\u21d1e \u207b\u00b9' 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) {f : \u03b2 \u2192 \u03b3} {x : \u03b2} (h : x \u2208 local_equiv.target (to_local_equiv e)) : continuous_at f x \u2194 continuous_at (f \u2218 \u21d1e) (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) {f : \u03b2 \u2192 \u03b3} {s : set \u03b2} (h : s \u2286 local_equiv.target (to_local_equiv e)) : continuous_on f s \u2194 continuous_on (f \u2218 \u21d1e) (local_equiv.source (to_local_equiv e) \u2229 \u21d1e \u207b\u00b9' 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) {f : \u03b3 \u2192 \u03b1} {s : set \u03b3} {x : \u03b3} (hx : f x \u2208 local_equiv.source (to_local_equiv e)) (h : f \u207b\u00b9' local_equiv.source (to_local_equiv e) \u2208 nhds_within x s) : continuous_within_at f s x \u2194 continuous_within_at (\u21d1e \u2218 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) {f : \u03b3 \u2192 \u03b1} {x : \u03b3} (h : f \u207b\u00b9' local_equiv.source (to_local_equiv e) \u2208 nhds x) : continuous_at f x \u2194 continuous_at (\u21d1e \u2218 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : local_homeomorph \u03b1 \u03b2) {f : \u03b3 \u2192 \u03b1} {s : set \u03b3} (h : s \u2286 f \u207b\u00b9' local_equiv.source (to_local_equiv e)) : continuous_on f s \u2194 continuous_on (\u21d1e \u2218 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (h : local_equiv.source (to_local_equiv e) = set.univ) (h' : local_equiv.target (to_local_equiv e) = set.univ) : \u03b1 \u2243\u209c \u03b2 :=\n  homeomorph.mk (equiv.mk \u21d1e \u21d1(local_homeomorph.symm e) sorry sorry)\n\n@[simp] theorem to_homeomorph_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (h : local_equiv.source (to_local_equiv e) = set.univ) (h' : local_equiv.target (to_local_equiv e) = set.univ) : \u21d1(to_homeomorph_of_source_eq_univ_target_eq_univ e h h') = \u21d1e :=\n  rfl\n\n@[simp] theorem to_homeomorph_symm_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (h : local_equiv.source (to_local_equiv e) = set.univ) (h' : local_equiv.target (to_local_equiv e) = set.univ) : \u21d1(homeomorph.symm (to_homeomorph_of_source_eq_univ_target_eq_univ e h h')) = \u21d1(local_homeomorph.symm e) :=\n  rfl\n\n/-- A local homeomorphism whose source is all of `\u03b1` defines an open embedding of `\u03b1` into `\u03b2`.  The\nconverse is also true; see `open_embedding.to_local_homeomorph`. -/\ntheorem to_open_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : \u03b1 \u2243\u209c \u03b2) : local_equiv.source (local_homeomorph.to_local_equiv (to_local_homeomorph e)) = set.univ :=\n  rfl\n\n@[simp] theorem to_local_homeomorph_target {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : \u03b1 \u2243\u209c \u03b2) : local_equiv.target (local_homeomorph.to_local_equiv (to_local_homeomorph e)) = set.univ :=\n  rfl\n\n@[simp] theorem to_local_homeomorph_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : \u03b1 \u2243\u209c \u03b2) : \u21d1(to_local_homeomorph e) = \u21d1e :=\n  rfl\n\n@[simp] theorem to_local_homeomorph_coe_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : \u03b1 \u2243\u209c \u03b2) : \u21d1(local_homeomorph.symm (to_local_homeomorph e)) = \u21d1(homeomorph.symm e) :=\n  rfl\n\n@[simp] theorem refl_to_local_homeomorph {\u03b1 : Type u_1} [topological_space \u03b1] : to_local_homeomorph (homeomorph.refl \u03b1) = local_homeomorph.refl \u03b1 :=\n  rfl\n\n@[simp] theorem symm_to_local_homeomorph {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : \u03b1 \u2243\u209c \u03b2) : to_local_homeomorph (homeomorph.symm e) = local_homeomorph.symm (to_local_homeomorph e) :=\n  rfl\n\n@[simp] theorem trans_to_local_homeomorph {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] (e : \u03b1 \u2243\u209c \u03b2) (e' : \u03b2 \u2243\u209c \u03b3) : 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 `\u03b1` into `\u03b2`, with `\u03b1` nonempty, defines a local equivalence whose source\nis all of `\u03b1`.  This is mainly an auxiliary lemma for the stronger result `to_local_homeomorph`. -/\ndef to_local_equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (h : open_embedding f) : local_equiv \u03b1 \u03b2 :=\n  set.inj_on.to_local_equiv f set.univ sorry\n\n@[simp] theorem to_local_equiv_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (h : open_embedding f) : \u21d1(to_local_equiv h) = f :=\n  rfl\n\n@[simp] theorem to_local_equiv_source {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (h : open_embedding f) : local_equiv.source (to_local_equiv h) = set.univ :=\n  rfl\n\n@[simp] theorem to_local_equiv_target {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (h : open_embedding f) : local_equiv.target (to_local_equiv h) = set.range f := sorry\n\ntheorem open_target {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (h : open_embedding f) : is_open (local_equiv.target (to_local_equiv h)) := sorry\n\ntheorem continuous_inv_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (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 `\u03b1` into `\u03b2`, with `\u03b1` nonempty, defines a local homeomorphism whose source\nis all of `\u03b1`.  The converse is also true; see `local_homeomorph.to_open_embedding`. -/\ndef to_local_homeomorph {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (h : open_embedding f) : local_homeomorph \u03b1 \u03b2 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (h : open_embedding f) : \u21d1(to_local_homeomorph h) = f :=\n  rfl\n\n@[simp] theorem source {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [Nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} (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 \u03b1]` typeclass argument\n\nnamespace open_embedding\n\n\ntheorem continuous_at_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hf : open_embedding f) {x : \u03b1} : continuous_at (g \u2218 f) x \u2194 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 `\u03b1` into `\u03b1` is a local homeomorphism from the\nsubtype `s` to `\u03b1`. -/\ndef local_homeomorph_subtype_coe {\u03b1 : Type u_1} [topological_space \u03b1] (s : opens \u03b1) [Nonempty \u21a5s] : local_homeomorph (\u21a5s) \u03b1 :=\n  open_embedding.to_local_homeomorph sorry\n\n@[simp] theorem local_homeomorph_subtype_coe_coe {\u03b1 : Type u_1} [topological_space \u03b1] (s : opens \u03b1) [Nonempty \u21a5s] : \u21d1(local_homeomorph_subtype_coe s) = coe :=\n  rfl\n\n@[simp] theorem local_homeomorph_subtype_coe_source {\u03b1 : Type u_1} [topological_space \u03b1] (s : opens \u03b1) [Nonempty \u21a5s] : 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 {\u03b1 : Type u_1} [topological_space \u03b1] (s : opens \u03b1) [Nonempty \u21a5s] : local_equiv.target (local_homeomorph.to_local_equiv (local_homeomorph_subtype_coe s)) = \u2191s := 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : topological_space.opens \u03b1) [Nonempty \u21a5s] : local_homeomorph (\u21a5s) \u03b2 :=\n  local_homeomorph.trans (topological_space.opens.local_homeomorph_subtype_coe s) e\n\ntheorem subtype_restr_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : topological_space.opens \u03b1) [Nonempty \u21a5s] : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : topological_space.opens \u03b1) [Nonempty \u21a5s] : \u21d1(subtype_restr e s) = set.restrict \u21d1e \u2191s :=\n  rfl\n\n@[simp] theorem subtype_restr_source {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (e : local_homeomorph \u03b1 \u03b2) (s : topological_space.opens \u03b1) [Nonempty \u21a5s] : local_equiv.source (to_local_equiv (subtype_restr e s)) = coe \u207b\u00b9' 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (s : topological_space.opens \u03b1) [Nonempty \u21a5s] (f : local_homeomorph \u03b1 \u03b2) (f' : local_homeomorph \u03b1 \u03b2) : local_homeomorph.trans (local_homeomorph.symm (subtype_restr f s)) (subtype_restr f' s) \u2248\n  local_homeomorph.restr (local_homeomorph.trans (local_homeomorph.symm f) f')\n    (local_equiv.target (to_local_equiv f) \u2229 \u21d1(local_homeomorph.symm f) \u207b\u00b9' \u2191s) := 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 : \u2115 \u2192 Bool \u00d7 \u2115 :=\n  sorry\n\ndef div2 (n : \u2115) : \u2115 :=\n  prod.snd (bodd_div2 n)\n\ndef bodd (n : \u2115) : 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 : \u2115) : bodd (Nat.succ n) = bnot (bodd n) := sorry\n\n@[simp] theorem bodd_add (m : \u2115) (n : \u2115) : bodd (m + n) = bxor (bodd m) (bodd n) := sorry\n\n@[simp] theorem bodd_mul (m : \u2115) (n : \u2115) : bodd (m * n) = bodd m && bodd n := sorry\n\ntheorem mod_two_of_bodd (n : \u2115) : 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 : \u2115) : div2 (Nat.succ n) = cond (bodd n) (Nat.succ (div2 n)) (div2 n) := sorry\n\ntheorem bodd_add_div2 (n : \u2115) : cond (bodd n) 1 0 + bit0 1 * div2 n = n := sorry\n\ntheorem div2_val (n : \u2115) : div2 n = n / bit0 1 := sorry\n\ndef bit (b : Bool) : \u2115 \u2192 \u2115 :=\n  cond b bit1 bit0\n\ntheorem bit0_val (n : \u2115) : 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 : \u2115) : bit1 n = bit0 1 * n + 1 :=\n  congr_arg Nat.succ (bit0_val n)\n\ntheorem bit_val (b : Bool) (n : \u2115) : 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 : \u2115) : 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 : \u2115 \u2192 Sort u} (n : \u2115) (h : (b : Bool) \u2192 (n : \u2115) \u2192 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 : \u2115) : \u2115 \u2192 \u2115 :=\n  sorry\n\ndef shiftl : \u2115 \u2192 \u2115 \u2192 \u2115 :=\n  shiftl' false\n\n@[simp] theorem shiftl_zero (m : \u2115) : shiftl m 0 = m :=\n  rfl\n\n@[simp] theorem shiftl_succ (m : \u2115) (n : \u2115) : shiftl m (n + 1) = bit0 (shiftl m n) :=\n  rfl\n\ndef shiftr : \u2115 \u2192 \u2115 \u2192 \u2115 :=\n  sorry\n\ndef test_bit (m : \u2115) (n : \u2115) : Bool :=\n  bodd (shiftr m n)\n\ndef binary_rec {C : \u2115 \u2192 Sort u} (z : C 0) (f : (b : Bool) \u2192 (n : \u2115) \u2192 C n \u2192 C (bit b n)) (n : \u2115) : C n :=\n  sorry\n\ndef size : \u2115 \u2192 \u2115 :=\n  binary_rec 0 fun (_x : Bool) (_x : \u2115) => Nat.succ\n\ndef bits : \u2115 \u2192 List Bool :=\n  binary_rec [] fun (b : Bool) (_x : \u2115) (IH : List Bool) => b :: IH\n\ndef bitwise (f : Bool \u2192 Bool \u2192 Bool) : \u2115 \u2192 \u2115 \u2192 \u2115 :=\n  binary_rec (fun (n : \u2115) => cond (f false tt) n 0)\n    fun (a : Bool) (m : \u2115) (Ia : \u2115 \u2192 \u2115) =>\n      binary_rec (cond (f tt false) (bit a m) 0) fun (b : Bool) (n _x : \u2115) => bit (f a b) (Ia n)\n\ndef lor : \u2115 \u2192 \u2115 \u2192 \u2115 :=\n  bitwise bor\n\ndef land : \u2115 \u2192 \u2115 \u2192 \u2115 :=\n  bitwise band\n\ndef ldiff : \u2115 \u2192 \u2115 \u2192 \u2115 :=\n  bitwise fun (a b : Bool) => a && bnot b\n\ndef lxor : \u2115 \u2192 \u2115 \u2192 \u2115 :=\n  bitwise bxor\n\n@[simp] theorem binary_rec_zero {C : \u2115 \u2192 Sort u} (z : C 0) (f : (b : Bool) \u2192 (n : \u2115) \u2192 C n \u2192 C (bit b n)) : binary_rec z f 0 = z := sorry\n\n/- bitwise ops -/\n\ntheorem bodd_bit (b : Bool) (n : \u2115) : bodd (bit b n) = b := sorry\n\ntheorem div2_bit (b : Bool) (n : \u2115) : div2 (bit b n) = n := sorry\n\ntheorem shiftl'_add (b : Bool) (m : \u2115) (n : \u2115) (k : \u2115) : shiftl' b m (n + k) = shiftl' b (shiftl' b m n) k := sorry\n\ntheorem shiftl_add (m : \u2115) (n : \u2115) (k : \u2115) : shiftl m (n + k) = shiftl (shiftl m n) k :=\n  shiftl'_add false\n\ntheorem shiftr_add (m : \u2115) (n : \u2115) (k : \u2115) : shiftr m (n + k) = shiftr (shiftr m n) k := sorry\n\ntheorem shiftl'_sub (b : Bool) (m : \u2115) {n : \u2115} {k : \u2115} : k \u2264 n \u2192 shiftl' b m (n - k) = shiftr (shiftl' b m n) k := sorry\n\ntheorem shiftl_sub (m : \u2115) {n : \u2115} {k : \u2115} : k \u2264 n \u2192 shiftl m (n - k) = shiftr (shiftl m n) k :=\n  shiftl'_sub false\n\n@[simp] theorem test_bit_zero (b : Bool) (n : \u2115) : test_bit (bit b n) 0 = b :=\n  bodd_bit b n\n\ntheorem test_bit_succ (m : \u2115) (b : Bool) (n : \u2115) : test_bit (bit b n) (Nat.succ m) = test_bit n m := sorry\n\ntheorem binary_rec_eq {C : \u2115 \u2192 Sort u} {z : C 0} {f : (b : Bool) \u2192 (n : \u2115) \u2192 C n \u2192 C (bit b n)} (h : f false 0 z = z) (b : Bool) (n : \u2115) : binary_rec z f (bit b n) = f b n (binary_rec z f n) := sorry\n\ntheorem bitwise_bit_aux {f : Bool \u2192 Bool \u2192 Bool} (h : f false false = false) : (binary_rec (cond (f tt false) (bit false 0) 0) fun (b : Bool) (n _x : \u2115) => bit (f false b) (cond (f false tt) n 0)) =\n  fun (n : \u2115) => cond (f false tt) n 0 := sorry\n\n@[simp] theorem bitwise_zero_left (f : Bool \u2192 Bool \u2192 Bool) (n : \u2115) : bitwise f 0 n = cond (f false tt) n 0 := sorry\n\n@[simp] theorem bitwise_zero_right (f : Bool \u2192 Bool \u2192 Bool) (h : f false false = false) (m : \u2115) : bitwise f m 0 = cond (f tt false) m 0 := sorry\n\n@[simp] theorem bitwise_zero (f : Bool \u2192 Bool \u2192 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 \u2192 Bool \u2192 Bool} (h : f false false = false) (a : Bool) (m : \u2115) (b : Bool) (n : \u2115) : bitwise f (bit a m) (bit b n) = bit (f a b) (bitwise f m n) := sorry\n\ntheorem bitwise_swap {f : Bool \u2192 Bool \u2192 Bool} (h : f false false = false) : bitwise (function.swap f) = function.swap (bitwise f) := sorry\n\n@[simp] theorem lor_bit (a : Bool) (m : \u2115) (b : Bool) (n : \u2115) : 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 : \u2115) (b : Bool) (n : \u2115) : 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 : \u2115) (b : Bool) (n : \u2115) : 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 : \u2115) (b : Bool) (n : \u2115) : 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 \u2192 Bool \u2192 Bool} (h : f false false = false) (m : \u2115) (n : \u2115) (k : \u2115) : 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 : \u2115) (n : \u2115) (k : \u2115) : 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 : \u2115) (n : \u2115) (k : \u2115) : 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 : \u2115) (n : \u2115) (k : \u2115) : 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 : \u2115) (n : \u2115) (k : \u2115) : 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 {\u03b1 \u03b2 : Type*}\nvariables (V : Type u) [category.{v} V] [has_zero_morphisms V]\n\nsection\n\ndef complex_shape.not_rfl (a : complex_shape \u03b1) : Prop :=\n\u2200 (i : \u03b1), \u00ac a.rel i i\n\ndef complex_shape.not_rfl.ne {a : complex_shape \u03b1} (ha : a.not_rfl) {i i' : \u03b1} :\n  a.rel i i' \u2192 i \u2260 i' :=\nbegin \n  contrapose!,\n  rintro rfl,\n  exact ha _,\nend\n\nstructure homological_bicomplex (a : complex_shape \u03b1) (b : complex_shape \u03b2) :=\n(X : \u03b1 \u2192 \u03b2 \u2192 V)\n(d_h : \u03a0 (i : \u03b1) (j j' : \u03b2), X i j \u27f6 X i j')\n(shape_h' : \u2200 (i : \u03b1) (j j' : \u03b2), \u00ac b.rel j j' \u2192 d_h i j j' = 0)\n(d_v : \u03a0 (j : \u03b2) (i i' : \u03b1), X i j \u27f6 X i' j)\n(shape_v' : \u2200 (j : \u03b2) (i i' : \u03b1), \u00ac a.rel i i' \u2192 d_v j i i' = 0)\n(d_comp_d_v' : \u2200 (j : \u03b2) (i\u2081 i\u2082 i\u2083 : \u03b1), a.rel i\u2081 i\u2082 \u2192 a.rel i\u2082 i\u2083 \u2192 \n  d_v j i\u2081 i\u2082 \u226b d_v j i\u2082 i\u2083 = 0)\n(d_comp_d_h' : \u2200 (i : \u03b1) (j\u2081 j\u2082 j\u2083 : \u03b2), b.rel j\u2081 j\u2082 \u2192 b.rel j\u2082 j\u2083 \u2192 \n  d_h i j\u2081 j\u2082 \u226b d_h i j\u2082 j\u2083 = 0)\n(comm' : \u2200 (i\u2081 i\u2082 : \u03b1) (j\u2081 j\u2082 : \u03b2), a.rel i\u2081 i\u2082 \u2192 b.rel j\u2081 j\u2082 \u2192 \n  d_v j\u2081 i\u2081 i\u2082 \u226b d_h i\u2082 j\u2081 j\u2082 = d_h i\u2081 j\u2081 j\u2082 \u226b d_v j\u2082 i\u2081 i\u2082)\n\nend\n\nnamespace homological_bicomplex\n\nrestate_axiom shape_h'\nrestate_axiom shape_v'\nattribute [simp] shape_h shape_v\n\nvariables {V}  {\u03b3 : Type*} (a : complex_shape \u03b1) (b : complex_shape \u03b2) (c : complex_shape \u03b3)\n\nclass has_sign :=\n(sign : \u03b1 \u2192 zmod 2)\n(rel : \u2200 (i i' : \u03b1), a.rel i i' \u2192 sign i \u2260 sign i')\n\ninstance has_sign1 : has_sign (complex_shape.up \u2124) :=\n{ sign := \u03bb i, i,\n  rel := \u03bb 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 \u2115) :=\n{ sign := \u03bb i, i,\n  rel := \u03bb 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 \u03b1 T :=\n{ smul := \u03bb 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 : \u03b1) : x \u2022 (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 : \u03b1) (t : T) : \n  x \u2022 t = 0 \u2194 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 : \u03b1) \n  {v\u2081 v\u2082 v\u2083 : V} (f : v\u2081 \u27f6 v\u2082) (g : v\u2082 \u27f6 v\u2083) :\n  (i \u2022 f) \u226b g = i \u2022 (f \u226b 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' {} : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n(rel_h' {} : \u2200 (i\u2081 i\u2082 : \u03b1) (j : \u03b2), a.rel i\u2081 i\u2082 \u2194 c.rel (add' i\u2081 j) (add' i\u2082 j))\n(rel_v' {} : \u2200 (i : \u03b1) (j\u2081 j\u2082 : \u03b2), b.rel j\u2081 j\u2082 \u2194 c.rel (add' i j\u2081) (add' i j\u2082))\n(add_cancel_h' : \u2200 (i\u2081 i\u2082 : \u03b1) (j : \u03b2), add' i\u2081 j = add' i\u2082 j \u2194 i\u2081 = i\u2082)\n(add_cancel_v' : \u2200 (i : \u03b1) (j\u2081 j\u2082 : \u03b2), add' i j\u2081 = add' i j\u2082 \u2194 j\u2081 = j\u2082)\n(balanced' : \u2200 (i : \u03b1) (j : \u03b2) (k' : \u03b3), c.rel (add' i j) k' \u2192 \n  ((\u2203 i', k' = add' i' j) \u2227 (\u2203 j', k' = add' i j')))\n/--\nThis is wrong for example:\nin down \u2115\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 \u2124) (complex_shape.up \u2124) (complex_shape.up \u2124) :=\n{ add' := (+),\n  rel_h' := \u03bb _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  rel_v' := \u03bb _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  add_cancel_h' := \u03bb _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  add_cancel_v' := \u03bb _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  balanced' := \u03bb i j k' (h : _ = _), \n  begin \n    refine \u27e8\u27e8i + 1, by linarith\u27e9, \u27e8j + 1, by linarith\u27e9\u27e9,\n  end }\n\ninstance test2 : has_hadd (complex_shape.up \u2115) (complex_shape.up \u2115) (complex_shape.up \u2115) :=\n{ add' := (+),\n  rel_h' := \u03bb _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  rel_v' := \u03bb _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  add_cancel_h' := \u03bb _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  add_cancel_v' := \u03bb _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  balanced' := \u03bb i j k' (h : _ = _), \n  begin \n    refine \u27e8\u27e8i + 1, by linarith\u27e9, \u27e8j + 1, by linarith\u27e9\u27e9,\n  end }\n\ninstance test3 : has_hadd (complex_shape.up \u2115) (complex_shape.up \u2124) (complex_shape.up \u2124) :=\n{ add' := \u03bb n z, (n : \u2124) + z,\n  rel_h' := \u03bb _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, norm_num, ring, },\n    { intros h, linarith, },\n  end,\n  rel_v' := \u03bb _ _ _, begin\n    dsimp,\n    split,\n    { rintro rfl, ring },\n    { intros h, linarith, },\n  end,\n  add_cancel_h' := \u03bb _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  add_cancel_v' := \u03bb _ _ _, begin\n    split;\n    intros;\n    linarith,\n  end,\n  balanced' := \u03bb i j k' (h : _ = _), \n  begin \n    refine \u27e8\u27e8i + 1, by norm_num; linarith\u27e9, \u27e8j + 1, by linarith\u27e9\u27e9,\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 \u03b1] [decidable_eq \u03b2] [decidable_eq \u03b3]\n\n@[simp] lemma d_comp_d_v (C : homological_bicomplex V a b) (j : \u03b2) (i\u2081 i\u2082 i\u2083 : \u03b1) :\n  C.d_v j i\u2081 i\u2082 \u226b C.d_v j i\u2082 i\u2083 = 0 := \nbegin \n  by_cases h\u2081\u2082 : a.rel i\u2081 i\u2082,\n  { refine (em (a.rel i\u2082 i\u2083)).elim (\u03bb h\u2082\u2083, C.d_comp_d_v' j i\u2081 i\u2082 i\u2083 h\u2081\u2082 h\u2082\u2083) (\u03bb h\u2082\u2083, _),\n    rw [C.shape_v j _ _ h\u2082\u2083, comp_zero], },\n  rw [C.shape_v _ _ _ h\u2081\u2082, zero_comp],\nend\n\n@[simp] lemma comm (C : homological_bicomplex V a b) (j\u2081 j\u2082 : \u03b2) (i\u2081 i\u2082 : \u03b1) :\n  C.d_h i\u2081 j\u2081 j\u2082 \u226b C.d_v j\u2082 i\u2081 i\u2082 = \n  C.d_v j\u2081 i\u2081 i\u2082 \u226b C.d_h i\u2082 j\u2081 j\u2082 := \nbegin \n  by_cases ha : a.rel i\u2081 i\u2082;\n  by_cases hb : b.rel j\u2081 j\u2082,\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 : \u03b1) (j\u2081 j\u2082 j\u2083 : \u03b2) :\n  C.d_h i j\u2081 j\u2082 \u226b C.d_h i j\u2082 j\u2083 = 0 := \nbegin \n  by_cases h\u2081\u2082 : b.rel j\u2081 j\u2082,\n  { refine (em (b.rel j\u2082 j\u2083)).elim (\u03bb h\u2082\u2083, C.d_comp_d_h' i j\u2081 j\u2082 j\u2083 h\u2081\u2082 h\u2082\u2083) (\u03bb h\u2082\u2083, _),\n    rw [C.shape_h i _ _ h\u2082\u2083, comp_zero], },\n  rw [C.shape_h _ _ _ h\u2081\u2082, zero_comp],\nend\n\n@[simps]\ndef vertical_component (C : homological_bicomplex V a b) (j : \u03b2) : homological_complex V a :=\n{ X := \u03bb i, C.X i j,\n  d := C.d_v j,\n  shape' := \u03bb _ _ h, C.shape_v _ _ _ h,\n  d_comp_d' := \u03bb _ _ _ _ _, C.d_comp_d_v _ _ _ _ }\n\n@[simps]\ndef vertical_component_map (C : homological_bicomplex V a b) (j\u2081 j\u2082 : \u03b2) :\n  C.vertical_component j\u2081 \u27f6 C.vertical_component j\u2082 :=\n{ f := \u03bb i, C.d_h i j\u2081 j\u2082,\n  comm' := \n  begin \n    intros i\u2081 i\u2082 h\u2081\u2082,\n    dsimp,\n    by_cases H : b.rel j\u2081 j\u2082,\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' := \u03bb j\u2081 j\u2082 h\u2081\u2082, \n  begin \n    ext i,\n    simpa only [vertical_component_map_f, homological_complex.zero_apply] using C.shape_h _ _ _ h\u2081\u2082,\n  end,\n  d_comp_d' := by { intros, ext, simp } }\n\n@[simps]\ndef horizontal_component (C : homological_bicomplex V a b) (i : \u03b1) : homological_complex V b :=\n{ X := C.X i,\n  d := C.d_h i,\n  shape' := \u03bb _ _ h, C.shape_h _ _ _ h,\n  d_comp_d' := \u03bb _ _ _ _ _, C.d_comp_d_h _ _ _ _ }\n\n@[simps]\ndef horizontal_component_map (C : homological_bicomplex V a b) (i\u2081 i\u2082 : \u03b1) :\n  C.horizontal_component i\u2081 \u27f6 C.horizontal_component i\u2082 :=\n{ f := \u03bb j, C.d_v j i\u2081 i\u2082,\n  comm' := \n  begin \n    intros j\u2081 j\u2082 h\u2081\u2082,\n    dsimp,\n    by_cases H : a.rel i\u2081 i\u2082,\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' := \u03bb i\u2081 i\u2082 h\u2081\u2082, \n  begin \n    ext j,\n    simpa only [horizontal_component_map_f, homological_complex.zero_apply] using \n      C.shape_v _ _ _ h\u2081\u2082,\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 : \u03b3) :=\n(fst : \u03b1) (snd : \u03b2) (add_eq : (fst +[a, b, c] snd) = k)\n\n\nopen_locale direct_sum big_operators\n\nvariables {a b} [\u2200 k, decidable_eq $ diagonal a b c k]\ndef total_at (j : \u03b3) : Module R :=\nModule.of R $ \u2a01 (p : diagonal a b c j), C.X p.fst p.snd\n\n@[simps]\ndef diagonal.from_balancing1\n  {k k' : \u03b3} (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' : \u03b3} (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 \u2190 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 \u2190 has_hadd.rel_h' at this,\n    rwa a.next_eq',\n  end }\n\nlemma diagonal.from_balancing1'_rel\n  {k k' : \u03b3} (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 [\u2190 EQ1, \u2190 p.add_eq] at hc,\n  erw \u2190 has_hadd.rel_h' at hc,\n  exact hc,\nend\n\nlemma diagonal.from_balancing1_uniq\n  {k k' : \u03b3} (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 \u2190q'.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 [\u2190 hq', q'.add_eq], },\n  { dsimp, rw [\u2190hq'], }\nend\n\nlemma diagonal.from_balancing1_fst_eq {k k' : \u03b3} (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' : \u03b3} (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' : \u03b3} (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 [\u2190hq'], },\n  { dsimp,\n    generalize_proofs h,\n    have := h.some_spec,\n    simp_rw \u2190q'.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 [\u2190 hq', q'.add_eq], },\nend\n\n@[simps]\ndef diagonal.from_balancing2'\n  {k k' : \u03b3} (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 \u2190 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 \u2190 has_hadd.rel_v' at this,\n    rwa b.next_eq',\n  end }\n\nlemma diagonal.from_balancing2_snd_eq {k k' : \u03b3} (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 : \u03b1) \n  {T : Type*} [add_comm_group T] (t t' : T) :\n  i \u2022 (t - t') = i \u2022 t - i \u2022 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 : \u03b1) (ha : a.rel i (a.next i))\n  {T : Type*} [add_comm_group T] (t : T) :\n  a.next i \u2022 t = - (i \u2022 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 \u2228 has_sign.sign a i = 1,\n    { obtain hmm1 := (has_sign.sign a i).2,\n      have hmm2 : 0 \u2264 (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 \u2228 has_sign.sign a (a.next i) = 1,\n    { obtain hmm1 := (has_sign.sign a (a.next i)).2,\n      have hmm2 : 0 \u2264 (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 : \u03b1) \n  {v\u2081 v\u2082 : Type*} [add_comm_group v\u2081] [add_comm_group v\u2082] [module R v\u2081] [module R v\u2082] \n  (f : v\u2081 \u2192\u2097[R] v\u2082) (x)  :\n  (i \u2022 f) x = i \u2022 (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 : \u03b1) \n  {v\u2081 v\u2082 : Module R} (f : v\u2081 \u27f6 v\u2082) (x)  :\n  f (i \u2022 x) = i \u2022 (f x) :=\nbegin \n  dunfold has_smul.smul,\n  dsimp,\n  split_ifs,\n  { refl },\n  { rw map_neg, },\nend\n\nvariable [\u2200 (k k' : \u03b3), decidable $ c.rel k k']\n\n@[reducible]\ndef total_d [has_sign a] (k k' : \u03b3) :\n  C.total_at c k \u27f6 C.total_at c k' :=\nif hc : c.rel k k' \nthen direct_sum.to_module _ _ _ $ \u03bb 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 \u2022 (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' : \u03b3) (hc : c.rel k k') :\nC.total_d c k k' = \ndirect_sum.to_module _ _ _ (\u03bb 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 \u2022 (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\u2081 k\u2082 k\u2083 : \u03b3) (hc12 : c.rel k\u2081 k\u2082) (hc23 : c.rel k\u2082 k\u2083) :\n  C.total_d c k\u2081 k\u2082 \u226b C.total_d c k\u2082 k\u2083 = 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 [\u2190 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 [\u2190 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, \u2190 has_sign.smul_sub, has_sign.smul_eq_zero, sub_eq_zero],\n  congr' 1,\n  dsimp,\n  rw [\u2190 comp_apply, \u2190 comp_apply],\n  rw C.comm,\nend\n\n@[simps]\ndef total_complex [has_sign a] : homological_complex (Module R) c :=\n{ X := \u03bb k, C.total_at c k,\n  d := \u03bb 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] \u2190 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 \u2192 V )\n  ( inverse  : V \u2192 U )\n  ( witness_1 : \u2200 u : U, inverse (morphism u) = u )\n  ( witness_2 : \u2200 v : V, morphism (inverse v) = v )\n\nclass Finite ( \u03b1 : Type ) :=\n  ( cardinality : nat )\n  ( bijection : Bijection \u03b1 (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 \u201cvaluations\u201d in algebraic number theory.\n\nUsually, in the informal literature, these objects are constructed\nby taking a linearly ordered commutative group \u0393 and formally adjoining a zero element: \u0393 \u222a {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 (\u03b1 : Type _) extends LinearOrderedCommMonoidWithZero \u03b1,\n  CommGroupWithZero \u03b1\n#align linear_ordered_comm_group_with_zero LinearOrderedCommGroupWithZero\n\nvariable {\u03b1 : Type _}\n\nvariable {a b c d x y z : \u03b1}\n\ninstance [LinearOrderedAddCommMonoidWithTop \u03b1] :\n    LinearOrderedCommMonoidWithZero (Multiplicative \u03b1\u1d52\u1d48) :=\n  { Multiplicative.orderedCommMonoid, Multiplicative.linearOrder with\n    zero := Multiplicative.ofAdd (\u22a4 : \u03b1)\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 : \u03b1) \u2264 \u22a4) }\n#align multiplicative.linear_ordered_comm_monoid_with_zero instLinearOrderedCommMonoidWithZeroMultiplicativeOrderDual\n\ninstance [LinearOrderedAddCommGroupWithTop \u03b1] :\n    LinearOrderedCommGroupWithZero (Multiplicative \u03b1\u1d52\u1d48) :=\n  { Multiplicative.divInvMonoid, instLinearOrderedCommMonoidWithZeroMultiplicativeOrderDual,\n    instNontrivialMultiplicative with\n    inv_zero := @LinearOrderedAddCommGroupWithTop.neg_top _ (_)\n    mul_inv_cancel := @LinearOrderedAddCommGroupWithTop.add_neg_cancel _ (_) }\n\ninstance [LinearOrderedCommMonoid \u03b1] : LinearOrderedCommMonoidWithZero (WithZero \u03b1) :=\n  { WithZero.linearOrder, WithZero.commMonoidWithZero with\n    mul_le_mul_left := fun _ _ \u21a6 mul_le_mul_left', zero_le_one := WithZero.zero_le _ }\n#align with_zero.linear_ordered_comm_monoid_with_zero instLinearOrderedCommMonoidWithZeroWithZero\n\ninstance [LinearOrderedCommGroup \u03b1] : LinearOrderedCommGroupWithZero (WithZero \u03b1) :=\n  { instLinearOrderedCommMonoidWithZeroWithZero, WithZero.commGroupWithZero with }\n\nsection LinearOrderedCommMonoid\n\nvariable [LinearOrderedCommMonoidWithZero \u03b1]\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 {\u03b2 : Type _} [Zero \u03b2] [One \u03b2] [Mul \u03b2]\n    [Pow \u03b2 \u2115] [Sup \u03b2] [Inf \u03b2] (f : \u03b2 \u2192 \u03b1) (hf : Function.Injective f) (zero : f 0 = 0)\n    (one : f 1 = 1) (mul : \u2200 x y, f (x * y) = f x * f y) (npow : \u2200 (x) (n : \u2115), f (x ^ n) = f x ^ n)\n    (hsup : \u2200 x y, f (x \u2294 y) = max (f x) (f y)) (hinf : \u2200 x y, f (x \u2293 y) = min (f x) (f y)) :\n    LinearOrderedCommMonoidWithZero \u03b2 :=\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 \u2264 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 \u2264 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' : \u00aca < 0 :=\n  not_lt_of_le zero_le'\n#align not_lt_zero' not_lt_zero'\n\n@[simp]\ntheorem le_zero_iff : a \u2264 0 \u2194 a = 0 :=\n  \u27e8fun h \u21a6 le_antisymm h zero_le', fun h \u21a6 h \u25b8 le_rfl\u27e9\n#align le_zero_iff le_zero_iff\n\ntheorem zero_lt_iff : 0 < a \u2194 a \u2260 0 :=\n  \u27e8ne_of_gt, fun h \u21a6 lt_of_le_of_ne zero_le' h.symm\u27e9\n#align zero_lt_iff zero_lt_iff\n\ntheorem ne_zero_of_lt (h : b < a) : a \u2260 0 := fun h1 \u21a6 not_lt_zero' <| show b < 0 from h1 \u25b8 h\n#align ne_zero_of_lt ne_zero_of_lt\n\ninstance : LinearOrderedAddCommMonoidWithTop (Additive \u03b1\u1d52\u1d48) :=\n  { Additive.orderedAddCommMonoid, Additive.linearOrder with\n    top := (0 : \u03b1)\n    top_add' := fun a \u21a6 zero_mul (Additive.toMul a)\n    le_top := fun _ \u21a6 zero_le' }\n#align additive.linear_ordered_add_comm_monoid_with_top instLinearOrderedAddCommMonoidWithTopAdditiveOrderDual\n\nend LinearOrderedCommMonoid\n\nvariable [LinearOrderedCommGroupWithZero \u03b1]\n\n-- TODO: Do we really need the following two?\n/-- Alias of `mul_le_one'` for unification. -/\ntheorem mul_le_one\u2080 (ha : a \u2264 1) (hb : b \u2264 1) : a * b \u2264 1 :=\n  mul_le_one' ha hb\n#align mul_le_one\u2080 mul_le_one\u2080\n\n/-- Alias of `one_le_mul'` for unification. -/\ntheorem one_le_mul\u2080 (ha : 1 \u2264 a) (hb : 1 \u2264 b) : 1 \u2264 a * b :=\n  one_le_mul ha hb\n#align one_le_mul\u2080 one_le_mul\u2080\n\ntheorem le_of_le_mul_right (h : c \u2260 0) (hab : a * c \u2264 b * c) : a \u2264 b := by\n  simpa only [mul_inv_cancel_right\u2080 h] using mul_le_mul_right' hab c\u207b\u00b9\n#align le_of_le_mul_right le_of_le_mul_right\n\ntheorem le_mul_inv_of_mul_le (h : c \u2260 0) (hab : a * c \u2264 b) : a \u2264 b * c\u207b\u00b9 :=\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 \u2264 b * c) : a * c\u207b\u00b9 \u2264 b := by\n  by_cases h : c = 0\n  \u00b7 simp [h]\n  \u00b7 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\u2080 (ha : a \u2260 0) : a\u207b\u00b9 \u2264 1 \u2194 1 \u2264 a :=\n  @inv_le_one' _ _ _ _ <| Units.mk0 a ha\n#align inv_le_one\u2080 inv_le_one\u2080\n\ntheorem one_le_inv\u2080 (ha : a \u2260 0) : 1 \u2264 a\u207b\u00b9 \u2194 a \u2264 1 :=\n  @one_le_inv' _ _ _ _ <| Units.mk0 a ha\n#align one_le_inv\u2080 one_le_inv\u2080\n\ntheorem le_mul_inv_iff\u2080 (hc : c \u2260 0) : a \u2264 b * c\u207b\u00b9 \u2194 a * c \u2264 b :=\n  \u27e8fun h \u21a6 inv_inv c \u25b8 mul_inv_le_of_le_mul h, le_mul_inv_of_mul_le hc\u27e9\n#align le_mul_inv_iff\u2080 le_mul_inv_iff\u2080\n\ntheorem mul_inv_le_iff\u2080 (hc : c \u2260 0) : a * c\u207b\u00b9 \u2264 b \u2194 a \u2264 b * c :=\n  \u27e8fun h \u21a6 inv_inv c \u25b8 le_mul_inv_of_mul_le (inv_ne_zero hc) h, mul_inv_le_of_le_mul\u27e9\n#align mul_inv_le_iff\u2080 mul_inv_le_iff\u2080\n\ntheorem div_le_div\u2080 (a b c d : \u03b1) (hb : b \u2260 0) (hd : d \u2260 0) : a * b\u207b\u00b9 \u2264 c * d\u207b\u00b9 \u2194 a * d \u2264 c * b :=\n  by rw [mul_inv_le_iff\u2080 hb, mul_right_comm, le_mul_inv_iff\u2080 hd]\n#align div_le_div\u2080 div_le_div\u2080\n\n@[simp]\ntheorem Units.zero_lt (u : \u03b1\u02e3) : (0 : \u03b1) < 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\u2080 (hab : a \u2264 b) (hb : b \u2260 0) (hcd : c < d) : a * c < b * d :=\n  have hd : d \u2260 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\u2080 mul_lt_mul_of_lt_of_le\u2080\n\ntheorem mul_lt_mul\u2080 (hab : a < b) (hcd : c < d) : a * c < b * d :=\n  mul_lt_mul_of_lt_of_le\u2080 hab.le (ne_zero_of_lt hab) hcd\n#align mul_lt_mul\u2080 mul_lt_mul\u2080\n\ntheorem mul_inv_lt_of_lt_mul\u2080 (h : x < y * z) : x * z\u207b\u00b9 < 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\u2080 mul_inv_lt_of_lt_mul\u2080\n\ntheorem inv_mul_lt_of_lt_mul\u2080 (h : x < y * z) : y\u207b\u00b9 * x < z := by\n  rw [mul_comm] at *\n  exact mul_inv_lt_of_lt_mul\u2080 h\n#align inv_mul_lt_of_lt_mul\u2080 inv_mul_lt_of_lt_mul\u2080\n\ntheorem mul_lt_right\u2080 (c : \u03b1) (h : a < b) (hc : c \u2260 0) : a * c < b * c := by\n  contrapose! h\n  exact le_of_le_mul_right hc h\n#align mul_lt_right\u2080 mul_lt_right\u2080\n\ntheorem inv_lt_inv\u2080 (ha : a \u2260 0) (hb : b \u2260 0) : a\u207b\u00b9 < b\u207b\u00b9 \u2194 b < a :=\n  show (Units.mk0 a ha)\u207b\u00b9 < (Units.mk0 b hb)\u207b\u00b9 \u2194 Units.mk0 b hb < Units.mk0 a ha from\n    have : CovariantClass \u03b1\u02e3 \u03b1\u02e3 (\u00b7 * \u00b7) (\u00b7 < \u00b7) :=\n      LeftCancelSemigroup.covariant_mul_lt_of_covariant_mul_le \u03b1\u02e3\n    inv_lt_inv_iff\n#align inv_lt_inv\u2080 inv_lt_inv\u2080\n\ntheorem inv_le_inv\u2080 (ha : a \u2260 0) (hb : b \u2260 0) : a\u207b\u00b9 \u2264 b\u207b\u00b9 \u2194 b \u2264 a :=\n  show (Units.mk0 a ha)\u207b\u00b9 \u2264 (Units.mk0 b hb)\u207b\u00b9 \u2194 Units.mk0 b hb \u2264 Units.mk0 a ha from\n    have : CovariantClass \u03b1\u02e3 \u03b1\u02e3 (Function.swap (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7) :=\n      OrderedCommMonoid.to_covariantClass_right \u03b1\u02e3\n    have : CovariantClass \u03b1\u02e3 \u03b1\u02e3 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7) :=\n      OrderedCommGroup.to_covariantClass_left_le \u03b1\u02e3\n    inv_le_inv_iff\n#align inv_le_inv\u2080 inv_le_inv\u2080\n\ntheorem lt_of_mul_lt_mul_of_le\u2080 (h : a * b < c * d) (hc : 0 < c) (hh : c \u2264 a) : b < d := by\n  have ha : a \u2260 0 := ne_of_gt (lt_of_lt_of_le hc hh)\n  simp_rw [\u2190 inv_le_inv\u2080 ha (ne_of_gt hc)] at hh\n  have := mul_lt_mul_of_lt_of_le\u2080 hh (inv_ne_zero (ne_of_gt hc)) h\n  simpa [inv_mul_cancel_left\u2080 ha, inv_mul_cancel_left\u2080 (ne_of_gt hc)] using this\n#align lt_of_mul_lt_mul_of_le\u2080 lt_of_mul_lt_mul_of_le\u2080\n\ntheorem mul_le_mul_right\u2080 (hc : c \u2260 0) : a * c \u2264 b * c \u2194 a \u2264 b :=\n  \u27e8le_of_le_mul_right hc, fun hab \u21a6 mul_le_mul_right' hab _\u27e9\n#align mul_le_mul_right\u2080 mul_le_mul_right\u2080\n\ntheorem mul_le_mul_left\u2080 (ha : a \u2260 0) : a * b \u2264 a * c \u2194 b \u2264 c := by\n  simp only [mul_comm a]\n  exact mul_le_mul_right\u2080 ha\n#align mul_le_mul_left\u2080 mul_le_mul_left\u2080\n\ntheorem div_le_div_right\u2080 (hc : c \u2260 0) : a / c \u2264 b / c \u2194 a \u2264 b := by\n  rw [div_eq_mul_inv, div_eq_mul_inv, mul_le_mul_right\u2080 (inv_ne_zero hc)]\n#align div_le_div_right\u2080 div_le_div_right\u2080\n\ntheorem div_le_div_left\u2080 (ha : a \u2260 0) (hb : b \u2260 0) (hc : c \u2260 0) : a / b \u2264 a / c \u2194 c \u2264 b := by\n  simp only [div_eq_mul_inv, mul_le_mul_left\u2080 ha, inv_le_inv\u2080 hb hc]\n#align div_le_div_left\u2080 div_le_div_left\u2080\n\ntheorem le_div_iff\u2080 (hc : c \u2260 0) : a \u2264 b / c \u2194 a * c \u2264 b := by\n  rw [div_eq_mul_inv, le_mul_inv_iff\u2080 hc]\n#align le_div_iff\u2080 le_div_iff\u2080\n\ntheorem div_le_iff\u2080 (hc : c \u2260 0) : a / c \u2264 b \u2194 a \u2264 b * c := by\n  rw [div_eq_mul_inv, mul_inv_le_iff\u2080 hc]\n#align div_le_iff\u2080 div_le_iff\u2080\n\n/-- `Equiv.mulLeft\u2080` as an `OrderIso` on a `LinearOrderedCommGroupWithZero.`.\n\nNote that `OrderIso.mulLeft\u2080` refers to the `LinearOrderedField` version. -/\n@[simps! (config := { simpRhs := true }) apply toEquiv]\ndef OrderIso.mulLeft\u2080' {a : \u03b1} (ha : a \u2260 0) : \u03b1 \u2243o \u03b1 :=\n  { Equiv.mulLeft\u2080 a ha with map_rel_iff' := mul_le_mul_left\u2080 ha }\n#align order_iso.mul_left\u2080' OrderIso.mulLeft\u2080'\n#align order_iso.mul_left\u2080'_to_equiv OrderIso.mulLeft\u2080'_toEquiv\n#align order_iso.mul_left\u2080'_apply OrderIso.mulLeft\u2080'_apply\n\ntheorem OrderIso.mulLeft\u2080'_symm {a : \u03b1} (ha : a \u2260 0) :\n    (OrderIso.mulLeft\u2080' ha).symm = OrderIso.mulLeft\u2080' (inv_ne_zero ha) := by\n  ext\n  rfl\n#align order_iso.mul_left\u2080'_symm OrderIso.mulLeft\u2080'_symm\n\n/-- `Equiv.mulRight\u2080` as an `OrderIso` on a `LinearOrderedCommGroupWithZero.`.\n\nNote that `OrderIso.mulRight\u2080` refers to the `LinearOrderedField` version. -/\n@[simps! (config := { simpRhs := true }) apply toEquiv]\ndef OrderIso.mulRight\u2080' {a : \u03b1} (ha : a \u2260 0) : \u03b1 \u2243o \u03b1 :=\n  { Equiv.mulRight\u2080 a ha with map_rel_iff' := mul_le_mul_right\u2080 ha }\n#align order_iso.mul_right\u2080' OrderIso.mulRight\u2080'\n#align order_iso.mul_right\u2080'_apply OrderIso.mulRight\u2080'_apply\n#align order_iso.mul_right\u2080'_to_equiv OrderIso.mulRight\u2080'_toEquiv\n\ntheorem OrderIso.mulRight\u2080'_symm {a : \u03b1} (ha : a \u2260 0) :\n    (OrderIso.mulRight\u2080' ha).symm = OrderIso.mulRight\u2080' (inv_ne_zero ha) := by\n  ext\n  rfl\n#align order_iso.mul_right\u2080'_symm OrderIso.mulRight\u2080'_symm\n\ninstance : LinearOrderedAddCommGroupWithTop (Additive \u03b1\u1d52\u1d48) :=\n  { Additive.subNegMonoid, instLinearOrderedAddCommMonoidWithTopAdditiveOrderDual,\n    instNontrivialAdditive with\n    neg_top := @inv_zero _ (_)\n    add_neg_cancel := fun a ha \u21a6 mul_inv_cancel (id ha : Additive.toMul a \u2260 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 i j : \u2124, i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u2260 (int.fract (\u03b1 * \u2191j)), from by {\n    assume i j h,\n    assume heq : int.fract (\u03b1 * \u2191i) = int.fract (\u03b1 * \u2191j),\n    have h2 : (\u03b1 * \u2191i) - \u2191(int.nat_abs (\u03b1 * \u2191i)) = (\u03b1 * \u2191j) - \u2191(int.nat_abs (\u03b1 * \u2191j)), from by {\n      rw heq,\n    },\n    have h3 : (\u03b1 * \u2191i) - \u2191(int.nat_abs (\u03b1 * \u2191i)) = \u2191i * \u03b1 - \u2191i * \u03b1 + (\u2191(int.nat_abs (\u03b1 * \u2191i)) - \u2191i * \u03b1), from by {\n      rw int.fract_eq_of_nat_abs_add_sub_nat_abs_le (\u03b1 * \u2191i),\n    },\n    have h4 : (\u03b1 * \u2191j) - \u2191(int.nat_abs (\u03b1 * \u2191j)) = \u2191j * \u03b1 - \u2191j * \u03b1 + (\u2191(int.nat_abs (\u03b1 * \u2191j)) - \u2191j * \u03b1), from by {\n      rw int.fract_eq_of_nat_abs_add_sub_nat_abs_le (\u03b1 * \u2191j),\n    },\n    have h5 : \u2191i * \u03b1 - \u2191i * \u03b1 + (\u2191(int.nat_abs (\u03b1 * \u2191i)) - \u2191i * \u03b1) = \u2191j * \u03b1 - \u2191j * \u03b1 + (\u2191(int.nat_abs (\u03b1 * \u2191j)) - \u2191j * \u03b1), from by {\n      rw h2,\n    },\n    have h6 : \u2191i * \u03b1 - \u2191i * \u03b1 = \u2191j * \u03b1 - \u2191j * \u03b1, from by {\n      rw h5,\n    },\n    have h7 : \u2191i * \u03b1 = \u2191j * \u03b1, from by {\n      rw h6,\n    },\n    have h8 : i * \u03b1 = j * \u03b1, from by {\n      rw h7,\n    },\n    let h9 : (\u03b1 = (i/j : \u2124)) \u2228 (\u03b1 = -(i/j : \u2124)), from by {\n      apply exists_rat_btwn, exact h\u03b1_irrat,\n    },\n    rw h8 at h9,\n    cases h9,\n    {\n    have h10 : \u03b1 = i/j, from by {\n      rw h9,\n    },\n    have h11 : \u03b1 = (j/i : \u2124), from by {\n      rw h10,\n      rw mul_comm,\n      rw int.mul_inv_cancel i,\n    },\n    have h12 : \u03b1 = -(i/j : \u2124), from by {\n      rw h11,\n      rw int.mul_neg_self_iff,\n    },\n    rw h12 at h\u03b1_irrat,\n    exact absurd h\u03b1_irrat (irrational_of_int_div_int h),\n    },\n    {\n    have h10 : \u03b1 = -(i/j : \u2124), from by {\n      rw h9,\n    },\n    have h11 : \u03b1 = (j/i : \u2124), from by {\n      rw h10,\n      rw mul_comm,\n      rw int.mul_inv_cancel i,\n    },\n    have h12 : \u03b1 = -(i/j : \u2124), from by {\n      rw h11,\n      rw int.mul_neg_self_iff,\n    },\n    rw h12 at h\u03b1_irrat,\n    exact absurd h\u03b1_irrat (irrational_of_int_div_int h),\n    },\n  },\n  have h2 : \u2200 i j : \u2124, i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u2209 ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), from by {\n    assume i j h3,\n    assume h4 : int.fract (\u03b1 * \u2191i) \u2208 ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)),\n    cases h4 with j h5,\n    cases h5 with h6 h7,\n    have h8 : int.fract (\u03b1 * \u2191i) = int.fract (\u03b1 * \u2191j), from by {\n      rw h7,\n    },\n    have h9 : i \u2260 j, from by {\n      exact h1 i j h3 h8,\n    },\n    exact absurd h3 h9,\n  },\n  have h3 : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1, from by {\n    apply closure_eq_of_is_closed,\n    apply is_closed_Icc,\n  },\n  have h4 : \u2200 i j : \u2124, i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u2208 (set.Icc 0 1), from by {\n    assume i j h,\n    have h5 : 0 \u2264 int.fract (\u03b1 * \u2191i), from by {\n      rw int.fract_eq_of_nat_abs_add_sub_nat_abs_le (\u03b1 * \u2191i),\n    },\n    have h6 : int.fract (\u03b1 * \u2191i) < 1, from by {\n      rw int.fract_eq_of_nat_abs_add_sub_nat_abs_le (\u03b1 * \u2191i),\n    },\n    split,\n    exact h5,\n    exact h6,\n  },\n  have h5 : \u2200 i : \u2124, (int.fract (\u03b1 * \u2191i)) \u2208 (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 = ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), 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 (\u03b1 * \u21910) = int.fract (\u03b1 * \u21910), 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 (\u03b1 * \u2191i) = 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 (\u03b1 * \u2191i) = 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 (\u03b1 * \u21910) = int.fract (\u03b1 * \u21910), from rfl,\n    rw h8,\n  },\nend\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * i) \u2260 int.fract (\u03b1 * j),\n  from by {\n    assume (i j : \u2124) (hneq : i \u2260 j),\n    have h2 : int.fract (\u03b1 * i) = \u03b1 * i - \u230a\u03b1 * i\u230b, from by {rw int.fract},\n    have h3 : int.fract (\u03b1 * j) = \u03b1 * j - \u230a\u03b1 * j\u230b, from by {rw int.fract},\n    have h4 : i \u2260 j \u2192 \u03b1 \u2260 (\u230a\u03b1 * i\u230b - \u230a\u03b1 * j\u230b) / (i-j), from by {\n      assume hneq1 : i \u2260 j,\n      assume h5 : \u03b1 = (\u230a\u03b1 * i\u230b - \u230a\u03b1 * j\u230b) / (i-j),\n      have h6 : (\u230a\u03b1 * i\u230b - \u230a\u03b1 * j\u230b) = (i-j) * \u03b1, from by {rw h5, ring},\n      have h7 : \u230a\u03b1 * i\u230b = \u230a(i-j) * \u03b1\u230b, from by {rw \u2190 h6, ring},\n      have h8 : \u230a\u03b1 * j\u230b = \u230a(i-j) * \u03b1\u230b, from by {rw \u2190 h6, ring},\n      have h9 : \u230a(i-j) * \u03b1\u230b \u2208 \u2124, from by {rw int.cast_coe_int, apply int.cast_le.mp, apply int.floor_nonneg},\n      have h10 : \u230a\u03b1 * i\u230b = \u230a\u03b1 * j\u230b, from by {rw h7, rw h8},\n      have h11 : \u03b1 * i = \u230a\u03b1 * i\u230b, from by {rw int.cast_coe_int, apply int.cast_le.mp, apply int.floor_nonneg},\n      have h12 : \u03b1 * j = \u230a\u03b1 * j\u230b, from by {rw int.cast_coe_int, apply int.cast_le.mp, apply int.floor_nonneg},\n      have h13 : \u03b1 * i = \u03b1 * 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 \u2260 0, from by {intro h16, exact hneq (eq_of_sub_eq_zero h16)},\n    have h16 : rational ((\u230a\u03b1 * i\u230b - \u230a\u03b1 * j\u230b) / (i-j)), from by {rw \u2190 h2, rw \u2190 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\u03b1_irrat, exact h15, exact h15},\n    exact h\u03b1_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 : \u2200 i j : \u2124, i \u2260 j \u2192 (\u03bb m : \u2124, int.fract (\u03b1 * m)) i \u2260 (\u03bb m : \u2124, int.fract (\u03b1 * m)) j,\n  from by {\n    assume (i j : \u2124) (hneq : i \u2260 j),\n    have h3 : (\u03bb m : \u2124, int.fract (\u03b1 * m)) i = int.fract (\u03b1 * i), from by {rw (\u03bb m : \u2124, int.fract (\u03b1 * m))},\n    have h4 : (\u03bb m : \u2124, int.fract (\u03b1 * m)) j = int.fract (\u03b1 * j), from by {rw (\u03bb m : \u2124, int.fract (\u03b1 * m))},\n    rw h3, rw h4, exact h1 i j hneq,\n  },\n  have h3 : (\u03bb m : \u2124, int.fract (\u03b1 * m)) '' (@set.univ \u2124) \u2286 set.Icc 0 1,\n  from by {\n    assume x,\n    assume h4 : x \u2208 (\u03bb m : \u2124, int.fract (\u03b1 * m)) '' (@set.univ \u2124),\n    cases h4 with y h5,\n    cases h5 with h6 h7,\n    have h8 : (\u03bb m : \u2124, int.fract (\u03b1 * m)) y = x, from by {rw h7, apply h6},\n    have h9 : y \u2208 @set.univ \u2124, from by {exact h7},\n    rw h8,\n    have h10 : 0 \u2264 int.fract (\u03b1 * y), from by {rw h8, apply int.fract_nonneg},\n    have h11 : int.fract (\u03b1 * 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 \u2286 (\u03bb m : \u2124, int.fract (\u03b1 * m)) '' (@set.univ \u2124),\n  from by {\n    assume x,\n    assume h5 : x \u2208 set.Icc 0 1,\n    cases h5 with h6 h7,\n    have h8 : \u2203 i : \u2124, int.fract (\u03b1 * i) = x, from by {\n      have h9 : \u2203 i : \u2124, int.fract (\u03b1 * i) \u2264 x, from by {\n        have h10 : \u2203 i : \u2124, 0 \u2264 int.fract (\u03b1 * i), from by {\n          existsi (0 : \u2124),\n          have h11 : (\u03b1 * (0 : \u2124)) = 0, from by {rw mul_zero},\n          rw h11,\n          apply int.fract_nonneg,\n        },\n        existsi (\u2308x\u2309 : \u2124),\n        have h12 : x < int.fract (\u03b1 * \u2308x\u2309), from by {rw int.fract, linarith},\n        have h13 : x < \u03b1 * \u2308x\u2309 - \u230a\u03b1 * \u2308x\u2309\u230b, from by {rw int.fract, linarith},\n        have h14 : x < \u03b1 * \u2308x\u2309, from by {exact lt_of_lt_of_le h13 (int.floor_le _)},\n        have h15 : x \u2264 \u2308x\u2309, from by {apply le_of_lt, exact h14},\n        have h16 : x \u2264 \u03b1 * \u2308x\u2309, from by {linarith, linarith},\n        have h17 : x \u2264 int.fract (\u03b1 * \u2308x\u2309), 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * i) \u2260 int.fract (\u03b1 * j),\n  from by {\n    assume i j,\n    assume h2 : i \u2260 j,\n    assume h3 : int.fract (\u03b1 * i) = int.fract (\u03b1 * j),\n    have h4 : \u03b1 * i - (int.fract (\u03b1 * i)) = int.fract (\u03b1 * i), from by rw [h3,int.fract_eq_of_lt (by linarith)],\n    have h5 : \u03b1 * j - (int.fract (\u03b1 * j)) = int.fract (\u03b1 * j), from by rw [h3,int.fract_eq_of_lt (by linarith)],\n    have h6 : \u03b1 = (int.fract (\u03b1 * i) - int.fract (\u03b1 * j)) / (i - j), from by rw [\u2190h4,\u2190h5],\n    have h7 : (int.fract (\u03b1 * i) - int.fract (\u03b1 * j)) / (i - j) \u2208 \u211a, from by apply quotient.exact h6,\n    have h8 : \u03b1 \u2208 \u211a, from by apply rational_iff_exists_rat.mp h7,\n    have h9 : irrational \u03b1, 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 : \u2200 i : \u2124, int.fract (\u03b1 * i) \u2208 set.Icc 0 1, from by {\n    assume i : \u2124,\n    have h11 : \u2191i * \u03b1 - \u2191(int.fract (\u03b1 * i)) = int.fract (\u03b1 * i), from by apply int.fract_eq_of_lt (by linarith),\n    have h12 : \u2191i * \u03b1 - int.fract (\u03b1 * i) < \u2191i * \u03b1, from by linarith,\n    have h13 : 0 < int.fract (\u03b1 * i), from by linarith,\n    have h14 : 0 \u2264 int.fract (\u03b1 * i) \u2227 int.fract (\u03b1 * i) < 1, from by rw [\u2190h11,int.fract_lt_one],\n    exact set.mem_Icc.mpr h14,\n  },\n  have h15 : set.finite (\u2205 : set \u2124), from by apply set.finite_empty,\n  have h16 : set.finite {z : \u2124 | z = 0}, from by apply set.finite_singleton,\n  have h17 : set.finite {z : \u2124 | z = -1}, from by apply set.finite_singleton,\n  have h18 : set.finite {z : \u2124 | z = 1}, from by apply set.finite_singleton,\n  have h19 : set.finite {z : \u2124 | (0 < z) \u2227 (z < 1)}, from by apply set.finite_Ico,\n  have h20 : set.finite {z : \u2124 | (z < 0) \u2227 (-1 < z)}, from by apply set.finite_Icc,\n  have h21 : set.finite {z : \u2124 | (z < 0) \u2227 (z < -1)}, from by apply set.finite_Icc,\n  have h22 : set.finite {z : \u2124 | (0 < z) \u2227 (1 < z)}, from by apply set.finite_Ico,\n  have h23 : set.finite {z : \u2124 | z = -2}, from by apply set.finite_singleton,\n  have h24 : set.finite {z : \u2124 | z = 2}, from by apply set.finite_singleton,\n  have h25 : set.finite {z : \u2124 | (z < -2) \u2227 (-3 < z)}, from by apply set.finite_Icc,\n  have h26 : set.finite {z : \u2124 | (z < -3) \u2227 (-4 < z)}, from by apply set.finite_Icc,\n  have h27 : set.finite {z : \u2124 | (z < -4) \u2227 (-5 < z)}, from by apply set.finite_Icc,\n  have h28 : set.finite {z : \u2124 | (z < -5) \u2227 (-6 < z)}, from by apply set.finite_Icc,\n  have h29 : set.finite {z : \u2124 | (z < -6) \u2227 (-7 < z)}, from by apply set.finite_Icc,\n  have h30 : set.finite {z : \u2124 | (z < -7) \u2227 (-8 < z)}, from by apply set.finite_Icc,\n  have h31 : set.finite {z : \u2124 | (z < -8) \u2227 (-9 < z)}, from by apply set.finite_Icc,\n  have h32 : set.finite {z : \u2124 | (z < -9) \u2227 (-10 < z)}, from by apply set.finite_Icc,\n  have h33 : set.finite {z : \u2124 | (2 < z) \u2227 (z < 3)}, from by apply set.finite_Ico,\n  have h34 : set.finite {z : \u2124 | (3 < z) \u2227 (z < 4)}, from by apply set.finite_Ico,\n  have h35 : set.finite {z : \u2124 | (4 < z) \u2227 (z < 5)}, from by apply set.finite_Ico,\n  have h36 : set.finite {z : \u2124 | (5 < z) \u2227 (z < 6)}, from by apply set.finite_Ico,\n  have h37 : set.finite {z : \u2124 | (6 < z) \u2227 (z < 7)}, from by apply set.finite_Ico,\n  have h38 : set.finite {z : \u2124 | (7 < z) \u2227 (z < 8)}, from by apply set.finite_Ico,\n  have h39 : set.finite {z : \u2124 | (8 < z) \u2227 (z < 9)}, from by apply set.finite_Ico,\n  have h40 : set.finite {z : \u2124 | (9 < z) \u2227 (z < 10)}, from by apply set.finite_Ico,\n  have h41 : set.finite {z : \u2124 | (10 < z) \u2227 (z < 11)}, from by apply set.finite_Ico,\n  have h42 : set.finite {z : \u2124 | (11 < z) \u2227 (z < 12)}, from by apply set.finite_Ico,\n  have h43 : set.finite {z : \u2124 | (12 < z) \u2227 (z < 13)}, from by apply set.finite_Ico,\n  have h44 : set.finite {z : \u2124 | (13 < z) \u2227 (z < 14)}, from by apply set.finite_Ico,\n  have h45 : set.finite {z : \u2124 | (14 < z) \u2227 (z < 15)}, from by apply set.finite_Ico,\n  have h46 : set.finite {z : \u2124 | (15 < z) \u2227 (z < 16)}, from by apply set.finite_Ico,\n  have h47 : set.finite {z : \u2124 | (16 < z) \u2227 (z < 17)}, from by apply set.finite_Ico,\n  have h48 : set.finite {z : \u2124 | (17 < z) \u2227 (z < 18\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 m n : \u2124, \u2191(m * n) = (\u2191m : \u211d) * n, from by {\n    assume m n : \u2124,\n    have h1 : (\u2191m : \u211d) * n = \u2191m * n, from by {\n      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n        have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n          have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n            have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n              have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                  have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                    have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                        have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                          have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                            have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                              have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                  have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                    have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                        have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                          have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                            have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                              have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                  have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                    have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                        have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                          have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                            have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                              have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                  have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                    have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                        have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                          have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                            have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                              have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                  have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                    have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                        have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                          have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                            have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                              have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                  have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                    have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                        have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                          have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                            have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                              have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                  have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                    have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                        have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                          have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                            have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                              have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                                have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                                  have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                                    have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                                      have h1 : (\u2191m : \u211d) * n = \u2191m * \u2191n, from by {\n                                                                                                                                        have h1 : (\u2191m : \u211d\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  --By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  let S : set \u211d := {int.fract (\u03b1 * \u2191m) | m : \u2124},\n  have h1 : \u2203 x : \u211d, x \u2208 closure S, from by {\n    have h2 : \u2200 m n : \u2124, m \u2260 n \u2192 (int.fract (\u03b1 * \u2191m)) \u2260 int.fract (\u03b1 * \u2191n), from by {\n      assume m n hmn,\n      have h3 : m \u2260 n, from by {\n        cases hmn, exact hmn,\n      },\n      have h4 : \u03b1 \u2260 \u2191n / \u2191m, from by {\n        rw hmn at h\u03b1_irrat, exact h\u03b1_irrat,\n      },\n      have h5 : (\u03b1 * \u2191m) \u2260 (\u03b1 * \u2191n), from by {\n        rw mul_comm (\u03b1 * \u2191m) (\u03b1 * \u2191n),\n        rw mul_assoc \u03b1 \u2191m \u2191n,\n        rw mul_comm \u2191m \u2191n,\n        rw mul_assoc \u2191m \u03b1 \u2191n,\n        rw mul_comm \u2191m \u03b1,\n        rw mul_assoc \u2191m \u2191n \u03b1,\n        rw mul_comm \u2191n \u03b1,\n        rw mul_assoc \u2191n \u2191m \u03b1,\n        rw hmn,\n        rw mul_comm \u2191m \u2191n,\n        rw \u2190 mul_assoc,\n        rw mul_comm \u03b1,\n        rw mul_inv_cancel \u03b1,\n        rw mul_one,\n        rw mul_comm \u2191n \u2191m,\n        rw h4,\n        rw mul_comm \u2191n \u2191m,\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 : \u2200 \u03b5 > 0, \u2203 x y \u2208 S, \u2200 z \u2208 S, |z - x| < \u03b5 \u2227 |z - y| < \u03b5, from by {\n    assume \u03b5 h\u03b5,\n    cases h1 with x hx,\n    cases (mem_closure_iff.1 hx \u03b5 h\u03b5) 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 : \u2200 z' \u2208 S, \u2203 m : \u2124, z' = int.fract (\u03b1 * \u2191m), from by {\n      assume z' hz',\n      rw mem_image at hz',\n      rcases hz' with \u27e8m, rfl\u27e9,\n      use m,\n      exact rfl,\n    },\n    cases h4 z with h6 h7,\n    rcases (h5 z h6) with \u27e8m, rfl\u27e9,\n    rcases (h5 y hy) with \u27e8n, rfl\u27e9,\n    have h8 : \u2200 m n : \u2124, m \u2260 n \u2192 (int.fract (\u03b1 * \u2191m)) \u2260 int.fract (\u03b1 * \u2191n), from by {\n      assume m n hmn,\n      have h9 : m \u2260 n, from by {\n        cases hmn, exact hmn,\n      },\n      have h10 : \u03b1 \u2260 \u2191n / \u2191m, from by {\n        rw hmn at h\u03b1_irrat, exact h\u03b1_irrat,\n      },\n      have h11 : (\u03b1 * \u2191m) \u2260 (\u03b1 * \u2191n), from by {\n        rw mul_comm (\u03b1 * \u2191m) (\u03b1 * \u2191n),\n        rw mul_assoc \u03b1 \u2191m \u2191n,\n        rw mul_comm \u2191m \u2191n,\n        rw mul_assoc \u2191m \u03b1 \u2191n,\n        rw mul_comm \u2191m \u03b1,\n        rw mul_assoc \u2191m \u2191n \u03b1,\n        rw mul_comm \u2191n \u03b1,\n        rw mul_assoc \u2191n \u2191m \u03b1,\n        rw hmn,\n        rw mul_comm \u2191m \u2191n,\n        rw \u2190 mul_assoc,\n        rw mul_comm \u03b1,\n        rw mul_inv_cancel \u03b1,\n        rw mul_one,\n        rw mul_comm \u2191n \u2191m,\n        rw h10,\n        rw mul_comm \u2191n \u2191m,\n        rw mul_one,\n      },\n      exact int.fract_ne_of_ne h11,\n    },\n    have h12 : (int.fract (\u03b1 * \u2191m)) \u2260 int.fract (\u03b1 * \u2191n), from by {\n      apply h8, exact h7,\n    },\n    have h13 : (\u03b1 * \u2191m) \u2260 (\u03b1 * \u2191n), from by {\n      exact int.fract_ne_of_ne h12,\n    },\n    have h14 : \u2191m \u2260 \u2191n, from by {\n      intro h,\n      rw [\u2190 mul_assoc, mul_comm \u2191m \u2191n, h] at h13,\n      have h15 : (\u03b1 * \u2191n) = (\u03b1 * \u2191m), from h13,\n      have h16 : \u2191n = \u2191m, from by {\n        rw \u2190 mul_assoc,\n        rw mul_comm \u2191n \u03b1,\n        rw mul_inv_cancel \u03b1,\n        rw mul_one,\n      },\n      contradiction,\n    },\n    have h17 : (int.fract (\u03b1 * \u2191n)) = z, from by {\n      rw int.fract_mul,\n      rw int.fract_mul,\n      rw mul_comm \u2191n \u03b1,\n      rw mul_assoc \u2191n \u2191m \u03b1,\n      rw \u2190 mul_assoc,\n      rw mul_comm \u2191n \u2191m,\n      rw h16,\n      rw mul_assoc \u2191m \u03b1 \u2191n,\n      rw mul_comm \u2191m \u03b1,\n      rw \u2190 mul_assoc,\n      rw mul_comm \u03b1 \u2191m,\n      rw mul_inv_cancel \u03b1,\n      rw mul_one,\n    },\n    have h18 : (int.fract (\u03b1 * \u2191m)) = y, from by {\n      rw int.fract_mul,\n      rw int.fract_mul,\n      rw mul_comm \u2191m \u03b1,\n      rw mul_assoc \u2191m \u2191n \u03b1,\n      rw \u2190 mul_assoc,\n      rw mul_comm \u2191m \u2191n,\n      rw h16,\n      rw mul_assoc \u2191n \u03b1 \u2191m,\n      rw mul_comm \u2191n \u03b1,\n      rw \u2190 mul_assoc,\n      rw mul_comm \u03b1 \u2191n,\n      rw mul_inv_cancel \u03b1,\n      rw mul_one,\n    },\n    have h19 : (int.fract (\u03b1 * \u2191m)) - (int.fract (\u03b1 * \u2191n)) = y - z, from by {\n      rw h17,\n      rw h18,\n    },\n    have h20 : \u2191m - \u2191n = (y - z) / \u03b1, from by {\n      rw [\u2190 mul_assoc, mul_comm \u03b1 \u2191n, mul_assoc \u03b1 \u2191n \u2191m, \u2190 mul_assoc] at h19,\n      rw mul_comm \u03b1 \u2191m at h19,\n      rw \u2190 mul_assoc at h19,\n      rw mul_comm \u2191m \u03b1 at h19,\n      rw mul_inv_cancel \u03b1 at h19,\n      rw mul_one at h19,\n      rw h19,\n      rw mul_sub,\n      rw mul_comm \u2191m \u2191n,\n      rw mul_sub,\n      rw mul_comm \u2191m \u2191n,\n    },\n    have h21 : \u2191m - \u2191n \u2260 0, from by {\n      linarith,\n    },\n    have h\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin \n  have h1 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j),\n  from by {\n    assume i j : \u2124,\n    assume h2 : i \u2260 j,\n    assume h3 : int.fract (\u03b1 * \u2191i) = int.fract (\u03b1 * \u2191j),\n    have h4 : \u03b1 = (int.fract (\u03b1 * \u2191i)) / (i-j), from by {\n      rw h3,\n      have h5 : (int.fract (\u03b1 * \u2191i)) / (i-j) = ((\u03b1 * \u2191i) - int.nat_abs (\u03b1 * \u2191i)) / (i-j), from by {\n        rw int.fract_def, \n        have h6 : int.nat_abs (\u03b1 * \u2191i) = int.nat_abs ((\u03b1 * \u2191i) - ((\u03b1 * \u2191i) - int.nat_abs (\u03b1 * \u2191i))), 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 : \u03b1 \u2208 \u211a, from by {\n      have h6 := (set.mem_rat.mpr (\u27e8\u03b1, h4\u27e9 : \u211a \u00d7 \u211a)),\n      apply set.mem_rat_iff.mp h6,\n      },\n    apply irrational.not_mem_of_mem_rat h\u03b1_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 ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' set.univ), from by {\n    have h3 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h4 : i \u2260 j,\n      have h5 : int.fract (\u03b1 * \u2191i) \u2209 {int.fract (\u03b1 * \u2191j)}, from by {\n        rw set.not_mem_singleton,\n        apply h1 i j h4,\n      },\n      exact h5,\n    },\n    have h4 : \u2200 i j : \u2124, i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u2260 (int.fract (\u03b1 * \u2191j)), from by {\n      assume i j : \u2124,\n      assume h5 : i \u2260 j,\n      apply h3 i j h5,\n    },\n    have h5 : \u2200 i j : \u2124, i \u2260 j \u2192 \u2191i \u2260 \u2191j, from by {\n      assume i j : \u2124,\n      assume h6 : i \u2260 j,\n      apply int.cast_ne_int.mpr h6,\n    },\n    have h6 : \u2200 i j : \u2124, i \u2260 j \u2192 \u2191i \u2260 \u2191j, from by {\n      assume i j : \u2124,\n      assume h7 : i \u2260 j,\n      apply h5 i j h7,\n    },\n    have h7 : \u2200 i j : \u2124, i \u2260 j \u2192 (\u03b1 * \u2191i) \u2260 (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h8 : i \u2260 j,\n      apply int.cast_ne_int.mpr h8,\n    },\n    have h8 : \u2200 i j : \u2124, i \u2260 j \u2192 (\u03b1 * \u2191i) \u2260 (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h9 : i \u2260 j,\n      apply h7 i j h9,\n    },\n    have h9 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h10 : i \u2260 j,\n      apply h4 i j h10,\n    },\n    have h10 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h11 : i \u2260 j,\n      apply h9 i j h11,\n    },\n    have h11 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h12 : i \u2260 j,\n      apply h10 i j h12,\n    },\n    have h12 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h13 : i \u2260 j,\n      apply h11 i j h13,\n    },\n    have h13 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h14 : i \u2260 j,\n      apply h12 i j h14,\n    },\n    have h14 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h15 : i \u2260 j,\n      apply h13 i j h15,\n    },\n    have h15 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h16 : i \u2260 j,\n      apply h14 i j h16,\n    },\n    have h16 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h17 : i \u2260 j,\n      apply h15 i j h17,\n    },\n    have h17 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h18 : i \u2260 j,\n      apply h16 i j h18,\n    },\n    have h18 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h19 : i \u2260 j,\n      apply h17 i j h19,\n    },\n    have h19 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h20 : i \u2260 j,\n      apply h18 i j h20,\n    },\n    have h20 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h21 : i \u2260 j,\n      apply h19 i j h21,\n    },\n    have h21 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume i j : \u2124,\n      assume h22 : i \u2260 j,\n     \nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (i * \u03b1) \u2260 int.fract (j * \u03b1), from assume (i j : \u2124) (h2 : i \u2260 j), \n  by {\n    rw [int.fract_eq, int.fract_eq] at h2,\n    have h3 : \u03b1 = (int.nat_abs (i - j))\u207b\u00b9 * (i * \u03b1 - j * \u03b1), 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\u03b1_irrat))] at h3,\n    have h4 : \u03b1 \u2208 \u211a, from by {\n      rw int.coe_nat_dvd,\n      use (i - j),\n      simp [h3],\n    },\n    have h5 : irrational \u03b1, from h\u03b1_irrat,\n    have h6 : \u00ac(\u03b1 \u2208 \u211a), 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 ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), from by {\n    have h8 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n      assume (i j : \u2124) (h9 : i \u2260 j),\n      rw [mul_comm \u03b1 i, mul_comm \u03b1 j] at h9,\n      exact h1 i j h9,\n    },\n    have h9 : \u2200 (i j : \u2124), i \u2260 j \u2192 (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) i \u2260 (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) j, from by {\n      assume (i j : \u2124) (h10 : i \u2260 j),\n      rw [eq_comm, \u2190 function.funext_iff],\n      exact h8 i j h10,\n    },\n    show set.infinite ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), 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 ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) (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 : \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (x y : \u2124), x \u2260 y \u2227 (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) x \u2260 (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) y \u2227 int.fract (\u03b1 * \u2191y) - int.fract (\u03b1 * \u2191x) < \u03b5, from by {\n    assume (\u03b5 : \u211d) (h12 : \u03b5 > 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 (\u03b5 / 2) (1 - (\u03b5 / 2))),\n    split,\n    {\n      rw [\u2190 set.image_univ],\n      rw [\u2190 set.image_univ],\n      apply set.finite_inter_finite,\n      apply set.finite_Icc,\n      apply set.finite_Ioo,\n    },\n    {\n      rw [\u2190 set.image_univ],\n      rw [\u2190 set.image_univ],\n      apply set.finite_inter_finite,\n      apply set.finite_Icc,\n      apply set.finite_Ioo,\n    },\n    {\n      rw [\u2190 set.image_univ],\n      rw [\u2190 set.image_univ],\n      rw [\u2190 set.image_univ],\n      rw [\u2190 set.image_univ],\n      apply set.finite_inter_finite,\n      apply set.finite_Icc,\n      apply set.finite_Ioo,\n    },\n    {\n      rw [\u2190 set.image_inter],\n      rw [\u2190 set.image_inter],\n      rw [\u2190 set.image_inter],\n      rw [\u2190 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  -- let S := $\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$\n  have h1 : \u2200 m : \u2124, int.fract (\u03b1 * \u2191m) \u2208 set.Icc 0 1, by {\n    assume m,\n    have h1_1 : 0 \u2264 int.fract (\u03b1 * \u2191m), by linarith,\n    have h1_2 : int.fract (\u03b1 * \u2191m) \u2264 1, by linarith,\n    show int.fract (\u03b1 * \u2191m) \u2208 set.Icc 0 1, from \u27e8h1_1,h1_2\u27e9,\n  },\n  have h2 : \u2200 m : \u2124, int.fract (\u03b1 * \u2191m) \u2208 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124), by {\n    assume m,\n    have h2_1 : (m : \u2124) \u2208 set.univ, from set.mem_univ m,\n    show int.fract (\u03b1 * \u2191m) \u2208 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124), from \u27e8m, h2_1\u27e9,\n  },\n  let S := (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124),\n\n  -- then S is infinite set\n  have h3 : infinite S, from by {\n    have h3_1 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from \n      begin\n        assume i j,\n        assume h3_1_1,\n        have h3_1_2 : \u03b1 = (int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j)) * (i - j)\u207b\u00b9, from by {\n          rw \u2190 int.fract_add_int,\n          rw \u2190 mul_int_fract,\n          rw \u2190 mul_int_fract,\n          ring,\n        },\n        have h3_1_3 : ((i - j) : \u2124) \u2260 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 : \u03b1 \u2208 \u211a, from by {\n            exact h3_1_2.symm,\n          },\n          have h3_1_3_5 : \u03b1 \u2209 \u211a, from by {\n            apply h\u03b1_irrat,\n          },\n          exact h3_1_3_5 h3_1_3_4,\n        },\n        have h3_1_4 : (i - j)\u207b\u00b9 \u2208 \u211a, from by {\n          exact inv_in_rational (int.cast_ne_zero.mp h3_1_3),\n        },\n        have h3_1_5 : (i - j)\u207b\u00b9 \u2209 \u211a, from by {\n          apply h\u03b1_irrat,\n        },\n        exact h3_1_5 h3_1_4,\n      end,\n    have h3_1_1 : \u2200 (i j : \u2124), i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u2260 (int.fract (\u03b1 * \u2191j)), 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 (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j),\n        from h3_1_1_2,\n      end,\n    have h3_1_2 : \u2200 (i j : \u2124), i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u207b\u00b9 \u2260 (int.fract (\u03b1 * \u2191j)) \u207b\u00b9, from \n      begin\n        assume i j,\n        assume h3_1_2_1,\n        have h3_1_2_2 : int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), 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 (\u03b1 * \u2191i)) \u207b\u00b9 \u2260 (int.fract (\u03b1 * \u2191j)) \u207b\u00b9,\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 : \u2200 (i j : \u2124), (int.fract (\u03b1 * \u2191i)) \u207b\u00b9 \u2260 (int.fract (\u03b1 * \u2191j)) \u207b\u00b9 \u2192 i \u2260 j, from \n      begin\n        assume i j,\n        assume h3_1_3_1,\n        have h3_1_3_2 : int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), 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 \u2260 j, from h3_1_1_1 i j h3_1_3_2,\n      end,\n    have h3_1_4 : \u2200 (i j : \u2124), i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u207b\u00b9 \u2260 (int.fract (\u03b1 * \u2191j)) \u207b\u00b9, from \n      begin\n        assume i j,\n        assume h3_1_4_1,\n        have h3_1_4_2 : int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), 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 (\u03b1 * \u2191i)) \u207b\u00b9 \u2260 (int.fract (\u03b1 * \u2191j)) \u207b\u00b9, 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 : \u2200 (i j : \u2124), (int.fract (\u03b1 * \u2191i)) \u207b\u00b9 = (int.fract (\u03b1 * \u2191j)) \u207b\u00b9 \u2192 i = j, from \n      begin\n        assume i j,\n        assume h3_1_5_1,\n        have h3_1_5_2 : int.fract (\u03b1 * \u2191i) = int.fract (\u03b1 * \u2191j), 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 : \u2200 (i j : \u2124), i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u207b\u00b9 \u2260 (int.fract (\u03b1 * \u2191j)) \u207b\u00b9, from \n      begin\n        assume i j,\n        assume h3_1_6_1,\n        have h3_1_6_2 : int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j\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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from by \n  {\n    intro x0,\n    have h6 : |x0 - l| < \u03b5 \u2194 ((x0 - l) < \u03b5) \u2227 ((l - x0) < \u03b5), \n    from abs_sub_lt_iff, rw h6,\n    split, \n    rintro \u27e8 S_1, S_2 \u27e9, \n    split; linarith, \n    rintro \u27e8 S_3, S_4 \u27e9, \n    split; linarith,\n    },\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : \u03b5 > 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 \u03b5 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 \u03b5 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 : \u2200 n > N, n > N1 \u2227 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 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \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 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \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  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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\u22c6-algebra\n\nDefine the multiplier algebra of a C\u22c6-algebra as the algebra (over `\ud835\udd5c`) of double centralizers,\nfor which we provide the localized notation `\ud835\udcdc(\ud835\udd5c, A)`.  A double centralizer is a pair of\ncontinuous linear maps `L R : A \u2192L[\ud835\udd5c] A` satisfying the intertwining condition `R x * y = x * L y`.\n\nThere is a natural embedding `A \u2192 \ud835\udcdc(\ud835\udd5c, A)` which sends `a : A` to the continuous linear maps\n`L R : A \u2192L[\ud835\udd5c] 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\u2013\u010cech compactification in the sense\nthat when the algebra `A` is commutative, it can be identified with `C\u2080(X, \u2102)` for some locally\ncompact Hausdorff space `X`, and in that case `\ud835\udcdc(\ud835\udd5c, A)` can be identified with `C(\u03b2 X, \u2102)`.\n\n## Implementation notes\n\nWe make the hypotheses on `\ud835\udd5c` as weak as possible so that, in particular, this construction works\nfor both `\ud835\udd5c = \u211d` and `\ud835\udd5c = \u2102`.\n\nThe reader familiar with C\u22c6-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\u22c6-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 : \ud835\udcdc(\ud835\udd5c, A) \u2192+* (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56` which\nsends `a : \ud835\udcdc(\ud835\udd5c, 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 `\ud835\udcdc(\ud835\udd5c, A)` which is equipped with the strict uniform space structure\n  and show it is complete\n+ Show that the image of `A` in `\ud835\udcdc(\ud835\udd5c, A)` is an essential ideal\n+ Prove the universal property of `\ud835\udcdc(\ud835\udd5c, A)`\n+ Construct a double centralizer from a pair of maps (not necessarily linear or continuous)\n  `L : A \u2192 A`, `R : A \u2192 A` satisfying the centrality condition `\u2200 x y, R x * y = x * L y`.\n+ Show that if `A` is unital, then `A \u2243\u22c6\u2090[\ud835\udd5c] \ud835\udcdc(\ud835\udd5c, 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`\ud835\udcdc(\ud835\udd5c, A)`, of a non-unital normed algebra.\n\nIf `x : \ud835\udcdc(\ud835\udd5c, A)`, then `x.fst` and `x.snd` are what is usually referred to as $L$ and $R$. -/\n@[ext]\nstructure double_centralizer (\ud835\udd5c : Type u) (A : Type v) [nontrivially_normed_field \ud835\udd5c]\n  [non_unital_normed_ring A] [normed_space \ud835\udd5c A] [smul_comm_class \ud835\udd5c A A] [is_scalar_tower \ud835\udd5c A A]\n  extends (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A) :=\n(central : \u2200 x y : A, snd x * y = x * fst y)\n\nlocalized \"notation `\ud835\udcdc(` \ud835\udd5c `, ` A `)` := double_centralizer \ud835\udd5c A\" in multiplier_algebra\n\nnamespace double_centralizer\n\nsection nontrivially_normed\n\nvariables (\ud835\udd5c A : Type*) [nontrivially_normed_field \ud835\udd5c] [non_unital_normed_ring A]\nvariables [normed_space \ud835\udd5c A] [smul_comm_class \ud835\udd5c A A] [is_scalar_tower \ud835\udd5c 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 : \ud835\udcdc(\ud835\udd5c, A) \u2192 (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56`\ndefined by `\u03bb a, (a.fst, mul_opposite.op a.snd)`. We use this map to pull back the ring, module and\nalgebra structure from `(A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56` to `\ud835\udcdc(\ud835\udd5c, A)`. -/\n\nvariables {\ud835\udd5c A}\n\n\n\ninstance : has_add \ud835\udcdc(\ud835\udd5c, A) :=\n{ add := \u03bb a b,\n  { to_prod := a.to_prod + b.to_prod,\n    central := \u03bb 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 \ud835\udcdc(\ud835\udd5c, A) :=\n{ zero :=\n  { to_prod := 0,\n    central := \u03bb x y, (zero_mul y).trans (mul_zero x).symm } }\n\ninstance : has_neg \ud835\udcdc(\ud835\udd5c, A) :=\n{ neg := \u03bb a,\n  { to_prod := -a.to_prod,\n    central := \u03bb 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 \ud835\udcdc(\ud835\udd5c, A) :=\n{ sub := \u03bb a b,\n  { to_prod := a.to_prod - b.to_prod,\n    central := \u03bb 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 \ud835\udd5c 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 \ud835\udcdc(\ud835\udd5c, A) :=\n{ smul := \u03bb s a,\n  { to_prod := s \u2022 a.to_prod,\n    central := \u03bb x y, show (s \u2022 a.snd) x * y = x * (s \u2022 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 : \ud835\udcdc(\ud835\udd5c, A)) : (s \u2022 a).to_prod = s \u2022 a.to_prod := rfl\nlemma smul_fst (s : S) (a : \ud835\udcdc(\ud835\udd5c, A)) : (s \u2022 a).fst = s \u2022 a.fst := rfl\nlemma smul_snd (s : S) (a : \ud835\udcdc(\ud835\udd5c, A)) : (s \u2022 a).snd = s \u2022 a.snd := rfl\n\nvariables {T : Type*} [monoid T] [distrib_mul_action T A] [smul_comm_class \ud835\udd5c 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 \ud835\udcdc(\ud835\udd5c, A) :=\n{ smul_assoc := \u03bb _ _ a, ext _ _ $ smul_assoc _ _ a.to_prod }\n\ninstance [smul_comm_class S T A] : smul_comm_class S T \ud835\udcdc(\ud835\udd5c, A) :=\n{ smul_comm := \u03bb _ _ a, ext _ _ $ smul_comm _ _ a.to_prod }\n\ninstance {R : Type*} [semiring R] [module R A] [smul_comm_class \ud835\udd5c R A]\n  [has_continuous_const_smul R A] [is_scalar_tower R A A] [smul_comm_class R A A]\n  [module R\u1d50\u1d52\u1d56 A] [is_central_scalar R A] : is_central_scalar R \ud835\udcdc(\ud835\udd5c, A) :=\n{ op_smul_eq_smul := \u03bb _ a, ext _ _ $ op_smul_eq_smul _ a.to_prod }\n\nend scalars\n\ninstance : has_one \ud835\udcdc(\ud835\udd5c, A) := \u27e8\u27e81, \u03bb x y, rfl\u27e9\u27e9\n\ninstance : has_mul \ud835\udcdc(\ud835\udd5c, A) :=\n{ mul := \u03bb a b,\n  { to_prod := (a.fst.comp b.fst, b.snd.comp a.snd),\n    central := \u03bb 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 \ud835\udcdc(\ud835\udd5c, A) :=\n{ nat_cast := \u03bb n, \u27e8n, \u03bb x y,\n  begin\n    rw [prod.snd_nat_cast, prod.fst_nat_cast],\n    simp only [\u2190nat.smul_one_eq_coe, smul_apply, one_apply, mul_smul_comm, smul_mul_assoc],\n  end\u27e9 }\n\ninstance : has_int_cast \ud835\udcdc(\ud835\udd5c, A) :=\n{ int_cast := \u03bb n, \u27e8n, \u03bb x y,\n  begin\n    rw [prod.snd_int_cast, prod.fst_int_cast],\n    simp only [\u2190int.smul_one_eq_coe, smul_apply, one_apply, mul_smul_comm, smul_mul_assoc],\n  end\u27e9 }\n\ninstance : has_pow \ud835\udcdc(\ud835\udd5c, A) \u2115 :=\n{ pow := \u03bb a n, \u27e8a.to_prod ^ n, \u03bb 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 \u22a2,\n      rw [pow_succ a.snd, mul_apply, a.central, hk, pow_succ' a.fst, mul_apply] },\n  end\u27e9 }\n\ninstance : inhabited \ud835\udcdc(\ud835\udd5c, A) := \u27e80\u27e9\n\n@[simp] lemma add_to_prod (a b : \ud835\udcdc(\ud835\udd5c, A)) : (a + b).to_prod = a.to_prod + b.to_prod := rfl\n@[simp] lemma zero_to_prod : (0 : \ud835\udcdc(\ud835\udd5c, A)).to_prod = 0 := rfl\n@[simp] lemma neg_to_prod (a : \ud835\udcdc(\ud835\udd5c, A)) : (-a).to_prod = -a.to_prod := rfl\n@[simp] lemma sub_to_prod (a b : \ud835\udcdc(\ud835\udd5c, A)) : (a - b).to_prod = a.to_prod - b.to_prod := rfl\n@[simp] lemma one_to_prod : (1 : \ud835\udcdc(\ud835\udd5c, A)).to_prod = 1 := rfl\n@[simp] lemma nat_cast_to_prod (n : \u2115) : (n : \ud835\udcdc(\ud835\udd5c , A)).to_prod = n := rfl\n@[simp] lemma int_cast_to_prod (n : \u2124) : (n : \ud835\udcdc(\ud835\udd5c , A)).to_prod = n := rfl\n@[simp] lemma pow_to_prod (n : \u2115) (a : \ud835\udcdc(\ud835\udd5c, A)) : (a ^ n).to_prod = a.to_prod ^ n := rfl\n\nlemma add_fst (a b : \ud835\udcdc(\ud835\udd5c, A)) : (a + b).fst = a.fst + b.fst := rfl\nlemma add_snd (a b : \ud835\udcdc(\ud835\udd5c, A)) : (a + b).snd = a.snd + b.snd := rfl\nlemma zero_fst : (0 : \ud835\udcdc(\ud835\udd5c, A)).fst = 0 := rfl\nlemma zero_snd : (0 : \ud835\udcdc(\ud835\udd5c, A)).snd = 0 := rfl\nlemma neg_fst (a : \ud835\udcdc(\ud835\udd5c, A)) : (-a).fst = -a.fst := rfl\nlemma neg_snd (a : \ud835\udcdc(\ud835\udd5c, A)) : (-a).snd = -a.snd := rfl\nlemma sub_fst (a b : \ud835\udcdc(\ud835\udd5c, A)) : (a - b).fst = a.fst - b.fst := rfl\nlemma sub_snd (a b : \ud835\udcdc(\ud835\udd5c, A)) : (a - b).snd = a.snd - b.snd := rfl\nlemma one_fst : (1 : \ud835\udcdc(\ud835\udd5c, A)).fst = 1 := rfl\nlemma one_snd : (1 : \ud835\udcdc(\ud835\udd5c, A)).snd = 1 := rfl\n@[simp] lemma mul_fst (a b : \ud835\udcdc(\ud835\udd5c, A)) : (a * b).fst = a.fst * b.fst := rfl\n@[simp] lemma mul_snd (a b : \ud835\udcdc(\ud835\udd5c, A)) : (a * b).snd = b.snd * a.snd := rfl\nlemma nat_cast_fst (n : \u2115) : (n : \ud835\udcdc(\ud835\udd5c , A)).fst = n := rfl\nlemma nat_cast_snd (n : \u2115) : (n : \ud835\udcdc(\ud835\udd5c , A)).snd = n := rfl\nlemma int_cast_fst (n : \u2124) : (n : \ud835\udcdc(\ud835\udd5c , A)).fst = n := rfl\nlemma int_cast_snd (n : \u2124) : (n : \ud835\udcdc(\ud835\udd5c , A)).snd = n := rfl\nlemma pow_fst (n : \u2115) (a : \ud835\udcdc(\ud835\udd5c, A)) : (a ^ n).fst = a.fst ^ n := rfl\nlemma pow_snd (n : \u2115) (a : \ud835\udcdc(\ud835\udd5c, 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 `\ud835\udcdc(\ud835\udd5c, A)` is the pullback under this map. -/\ndef to_prod_mul_opposite : \ud835\udcdc(\ud835\udd5c, A) \u2192 (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56 :=\n\u03bb a, (a.fst, mul_opposite.op a.snd)\n\nlemma to_prod_mul_opposite_injective :\n  function.injective (to_prod_mul_opposite : \ud835\udcdc(\ud835\udd5c, A) \u2192 (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56) :=\n\u03bb 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 \u2192L[\ud835\udd5c] A) \u00d7 _ | \u2200 x y, unop lr.2 x * y = x * lr.1 y} :=\nset.ext $ \u03bb x,\n  \u27e8by {rintro \u27e8a, rfl\u27e9, exact a.central}, \u03bb hx, \u27e8\u27e8(x.1, unop x.2), hx\u27e9, prod.ext rfl rfl\u27e9\u27e9\n\n/-- The ring structure is inherited as the pullback under the injective map\n`double_centralizer.to_prod_mul_opposite : \ud835\udcdc(\ud835\udd5c, A) \u2192 (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56` -/\ninstance : ring \ud835\udcdc(\ud835\udd5c, A) :=\nto_prod_mul_opposite_injective.ring _\n  rfl rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl)\n  (\u03bb x n, prod.ext rfl $ mul_opposite.op_smul _ _)\n  (\u03bb x n, prod.ext rfl $ mul_opposite.op_smul _ _)\n  (\u03bb x n, prod.ext rfl $ mul_opposite.op_pow _ _)\n  (\u03bb _, rfl) (\u03bb _, rfl)\n\n/-- The canonical map `double_centralizer.to_prod` as an additive group homomorphism. -/\n@[simps]\ndef to_prod_hom : \ud835\udcdc(\ud835\udd5c, A) \u2192+ (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A) :=\n{ to_fun := to_prod,\n  map_zero' := rfl,\n  map_add' := \u03bb 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 : \ud835\udcdc(\ud835\udd5c, A) \u2192+* (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56 :=\n{ to_fun := to_prod_mul_opposite,\n  map_zero' := rfl,\n  map_one' := rfl,\n  map_add' := \u03bb x y, rfl,\n  map_mul' := \u03bb x y, rfl }\n\n/-- The module structure is inherited as the pullback under the additive group monomorphism\n`double_centralizer.to_prod : \ud835\udcdc(\ud835\udd5c, A) \u2192+ (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)` -/\ninstance {S : Type*} [semiring S] [module S A] [smul_comm_class \ud835\udd5c S A]\n  [has_continuous_const_smul S A] [is_scalar_tower S A A] [smul_comm_class S A A] :\n  module S \ud835\udcdc(\ud835\udd5c, A) :=\nfunction.injective.module S to_prod_hom ext (\u03bb x y, rfl)\n\n-- TODO: generalize to `algebra S \ud835\udcdc(\ud835\udd5c, A)` once `continuous_linear_map.algebra` is generalized.\ninstance : algebra \ud835\udd5c \ud835\udcdc(\ud835\udd5c, A) :=\n{ to_fun := \u03bb k,\n  { to_prod := algebra_map \ud835\udd5c ((A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)) k,\n    central := \u03bb 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 \ud835\udd5c ((A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)),\n  map_mul' := \u03bb k\u2081 k\u2082, ext _ _ $ prod.ext (map_mul (algebra_map \ud835\udd5c (A \u2192L[\ud835\udd5c] A)) _ _)\n    ((map_mul (algebra_map \ud835\udd5c (A \u2192L[\ud835\udd5c] A)) _ _).trans (algebra.commutes _ _)),\n  map_zero' := ext _ _ $ map_zero $ algebra_map \ud835\udd5c ((A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)),\n  map_add' := \u03bb _ _, ext _ _ $ map_add (algebra_map \ud835\udd5c ((A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A))) _ _,\n  commutes' := \u03bb _ _, ext _ _ $ prod.ext (algebra.commutes _ _) (algebra.commutes _ _).symm,\n  smul_def' := \u03bb _ _, ext _ _ $ prod.ext (algebra.smul_def _ _)\n    ((algebra.smul_def _ _).trans $ algebra.commutes _ _) }\n\n@[simp] lemma algebra_map_to_prod (k : \ud835\udd5c) :\n  (algebra_map \ud835\udd5c \ud835\udcdc(\ud835\udd5c, A) k).to_prod = algebra_map \ud835\udd5c _ k := rfl\nlemma algebra_map_fst (k : \ud835\udd5c) : (algebra_map \ud835\udd5c \ud835\udcdc(\ud835\udd5c, A) k).fst = algebra_map \ud835\udd5c _ k := rfl\nlemma algebra_map_snd (k : \ud835\udd5c) : (algebra_map \ud835\udd5c \ud835\udcdc(\ud835\udd5c, A) k).snd = algebra_map \ud835\udd5c _ k := rfl\n\n/-!\n### Star structure\n-/\n\nsection star\n\nvariables [star_ring \ud835\udd5c] [star_ring A] [star_module \ud835\udd5c A] [normed_star_group A]\n\n/-- The star operation on `a : \ud835\udcdc(\ud835\udd5c, A)` is given by\n`(star a).to_prod = (star \u2218 a.snd \u2218 star, star \u2218 a.fst \u2218 star)`. -/\ninstance : has_star \ud835\udcdc(\ud835\udd5c, A) :=\n{ star := \u03bb a,\n  { fst := (((star\u2097\u1d62 \ud835\udd5c : A \u2243\u2097\u1d62\u22c6[\ud835\udd5c] A) : A \u2192L\u22c6[\ud835\udd5c] A).comp a.snd).comp\n      ((star\u2097\u1d62 \ud835\udd5c : A \u2243\u2097\u1d62\u22c6[\ud835\udd5c] A) : A \u2192L\u22c6[\ud835\udd5c] A),\n    snd := (((star\u2097\u1d62 \ud835\udd5c : A \u2243\u2097\u1d62\u22c6[\ud835\udd5c] A) : A \u2192L\u22c6[\ud835\udd5c] A).comp a.fst).comp\n      ((star\u2097\u1d62 \ud835\udd5c : A \u2243\u2097\u1d62\u22c6[\ud835\udd5c] A) : A \u2192L\u22c6[\ud835\udd5c] A),\n    central := \u03bb 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 : \ud835\udcdc(\ud835\udd5c, A)) (b : A) : (star a).fst b = star (a.snd (star b)) := rfl\n@[simp] lemma star_snd (a : \ud835\udcdc(\ud835\udd5c, A)) (b : A) : (star a).snd b = star (a.fst (star b)) := rfl\n\ninstance : star_add_monoid \ud835\udcdc(\ud835\udd5c, A) :=\n{ star_involutive := \u03bb x, by {ext; simp only [star_fst, star_snd, star_star]},\n  star_add := \u03bb 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 \ud835\udcdc(\ud835\udd5c, A) :=\n{ star_mul := \u03bb 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 \ud835\udd5c \ud835\udcdc(\ud835\udd5c, A) :=\n{ star_smul := \u03bb 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 `\ud835\udcdc(\ud835\udd5c, A)` given by sending `a : A` to the pair of linear\nmaps `L\u2090 R\u2090 : A \u2192L[\ud835\udd5c] A` given by left- and right-multiplication by `a`, respectively.\n\nWarning: if `A = \ud835\udd5c`, then this is a coercion which is not definitionally equal to the\n`algebra_map \ud835\udd5c \ud835\udcdc(\ud835\udd5c, \ud835\udd5c)` coercion, but these are propositionally equal. See\n`double_centralizer.coe_eq_algebra_map` below. -/\nnoncomputable instance : has_coe_t A \ud835\udcdc(\ud835\udd5c, A) :=\n{ coe := \u03bb a,\n  { fst := continuous_linear_map.mul \ud835\udd5c A a,\n    snd := (continuous_linear_map.mul \ud835\udd5c A).flip a,\n    central := \u03bb x y, mul_assoc _ _ _ } }\n\n@[simp, norm_cast]\nlemma coe_fst (a : A) : (a : \ud835\udcdc(\ud835\udd5c, A)).fst = continuous_linear_map.mul \ud835\udd5c A a := rfl\n@[simp, norm_cast]\nlemma coe_snd (a : A) : (a : \ud835\udcdc(\ud835\udd5c, A)).snd = (continuous_linear_map.mul \ud835\udd5c A).flip a := rfl\n\nlemma coe_eq_algebra_map : (coe : \ud835\udd5c \u2192 \ud835\udcdc(\ud835\udd5c, \ud835\udd5c)) = algebra_map \ud835\udd5c \ud835\udcdc(\ud835\udd5c, \ud835\udd5c) :=\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 \ud835\udd5c] [star_ring A] [star_module \ud835\udd5c A] [normed_star_group A] :\n  A \u2192\u22c6\u2099\u2090[\ud835\udd5c] \ud835\udcdc(\ud835\udd5c, A) :=\n{ to_fun := \u03bb a, a,\n  map_smul' := \u03bb 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' := \u03bb a b, by ext; simp only [coe_fst, coe_snd, map_add, add_fst, add_snd],\n  map_mul' := \u03bb 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' := \u03bb 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 `\ud835\udcdc(\ud835\udd5c, A)` as the pullback under\n`double_centralizer.to_prod_mul_opposite_hom : \ud835\udcdc(\ud835\udd5c, A) \u2192+* (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56`, which\nprovides a definitional isometric embedding. Consequently, completeness of `\ud835\udcdc(\ud835\udd5c, A)` is obtained\nby proving that the range of this map is closed.\n\nIn addition, we prove that `\ud835\udcdc(\ud835\udd5c, A)` is a normed algebra, and, when `A` is a C\u22c6-algebra, we show\nthat `\ud835\udcdc(\ud835\udd5c, A)` is also a C\u22c6-algebra. Moreover, in this case, for `a : \ud835\udcdc(\ud835\udd5c, A)`,\n`\u2016a\u2016 = \u2016a.fst\u2016 = \u2016a.snd\u2016`. -/\n\n/-- The normed group structure is inherited as the pullback under the ring monomoprhism\n`double_centralizer.to_prod_mul_opposite_hom : \ud835\udcdc(\ud835\udd5c, A) \u2192+* (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56`. -/\nnoncomputable instance : normed_ring \ud835\udcdc(\ud835\udd5c, A) :=\nnormed_ring.induced _ _ (to_prod_mul_opposite_hom : \ud835\udcdc(\ud835\udd5c, A) \u2192+* (A \u2192L[\ud835\udd5c] A) \u00d7 (A \u2192L[\ud835\udd5c] A)\u1d50\u1d52\u1d56)\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 : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a\u2016 = \u2016a.to_prod_hom\u2016 := rfl\nlemma nnnorm_def (a : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a\u2016\u208a = \u2016a.to_prod_hom\u2016\u208a := rfl\n\nlemma norm_def' (a : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a\u2016 = \u2016a.to_prod_mul_opposite_hom\u2016 := rfl\nlemma nnnorm_def' (a : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a\u2016\u208a = \u2016a.to_prod_mul_opposite_hom\u2016\u208a := rfl\n\ninstance : normed_space \ud835\udd5c \ud835\udcdc(\ud835\udd5c, A) :=\n{ norm_smul_le := \u03bb k a, norm_smul_le k a.to_prod_mul_opposite,\n  .. double_centralizer.module }\n\ninstance : normed_algebra \ud835\udd5c \ud835\udcdc(\ud835\udd5c, A) :=\n{ ..double_centralizer.algebra, ..double_centralizer.normed_space }\n\nlemma uniform_embedding_to_prod_mul_opposite :\n  uniform_embedding (@to_prod_mul_opposite \ud835\udd5c A _ _ _ _ _) :=\nuniform_embedding_comap to_prod_mul_opposite_injective\n\ninstance [complete_space A] : complete_space \ud835\udcdc(\ud835\udd5c, 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 (\u03bb x, is_closed_Inter $ \u03bb y, is_closed_eq _ _),\n  exact ((continuous_linear_map.apply \ud835\udd5c A _).continuous.comp $\n    continuous_unop.comp continuous_snd).mul continuous_const,\n  exact continuous_const.mul ((continuous_linear_map.apply \ud835\udd5c A _).continuous.comp continuous_fst),\nend\n\nvariables [star_ring A] [cstar_ring A]\n\n/-- For `a : \ud835\udcdc(\ud835\udd5c, A)`, the norms of `a.fst` and `a.snd` coincide, and hence these\nalso coincide with `\u2016a\u2016` which is `max (\u2016a.fst\u2016) (\u2016a.snd\u2016)`. -/\nlemma norm_fst_eq_snd (a : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a.fst\u2016 = \u2016a.snd\u2016 :=\nbegin\n  -- a handy lemma for this proof\n  have h0 : \u2200 f : A \u2192L[\ud835\udd5c] A, \u2200 C : \u211d\u22650, (\u2200 b : A, \u2016f b\u2016\u208a ^ 2 \u2264 C * \u2016f b\u2016\u208a * \u2016b\u2016\u208a) \u2192 \u2016f\u2016\u208a \u2264 C,\n  { intros f C h,\n    have h1 : \u2200 b, C * \u2016f b\u2016\u208a * \u2016b\u2016\u208a \u2264 C * \u2016f\u2016\u208a * \u2016b\u2016\u208a ^ 2,\n    { intros b,\n      convert mul_le_mul_right' (mul_le_mul_left' (f.le_op_nnnorm b) C) (\u2016b\u2016\u208a) 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 (\u03bb 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 : \u2200 b, \u2016a.fst b\u2016\u208a ^ 2 \u2264 \u2016a.snd\u2016\u208a * \u2016a.fst b\u2016\u208a * \u2016b\u2016\u208a,\n  { intros b,\n    calc \u2016a.fst b\u2016\u208a ^ 2\n        = \u2016star (a.fst b) * (a.fst b)\u2016\u208a\n        : by simpa only [\u2190sq] using (cstar_ring.nnnorm_star_mul_self).symm\n    ... \u2264 \u2016a.snd (star (a.fst b))\u2016\u208a * \u2016b\u2016\u208a : a.central (star (a.fst b)) b \u25b8 nnnorm_mul_le _ _\n    ... \u2264 \u2016a.snd\u2016\u208a * \u2016a.fst b\u2016\u208a * \u2016b\u2016\u208a\n        : nnnorm_star (a.fst b) \u25b8 mul_le_mul_right' (a.snd.le_op_nnnorm _) _},\n  have h2 : \u2200 b, \u2016a.snd b\u2016\u208a ^ 2 \u2264 \u2016a.fst\u2016\u208a * \u2016a.snd b\u2016\u208a * \u2016b\u2016\u208a,\n  { intros b,\n    calc \u2016a.snd b\u2016\u208a ^ 2\n        = \u2016a.snd b * star (a.snd b)\u2016\u208a\n        : by simpa only [\u2190sq] using (cstar_ring.nnnorm_self_mul_star).symm\n    ... \u2264 \u2016b\u2016\u208a * \u2016a.fst (star (a.snd b))\u2016\u208a\n        : (a.central b (star (a.snd b))).symm \u25b8 nnnorm_mul_le _ _\n    ... = \u2016a.fst (star (a.snd b))\u2016\u208a * \u2016b\u2016\u208a : mul_comm _ _\n    ... \u2264 \u2016a.fst\u2016\u208a * \u2016a.snd b\u2016\u208a * \u2016b\u2016\u208a\n        : nnnorm_star (a.snd b) \u25b8 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 : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a.fst\u2016\u208a = \u2016a.snd\u2016\u208a := subtype.ext $ norm_fst_eq_snd a\n@[simp] lemma norm_fst (a : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a.fst\u2016 = \u2016a\u2016 :=\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 : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a.snd\u2016 = \u2016a\u2016 := by rw [\u2190norm_fst, norm_fst_eq_snd]\n@[simp] lemma nnnorm_fst (a : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a.fst\u2016\u208a = \u2016a\u2016\u208a := subtype.ext (norm_fst a)\n@[simp] lemma nnnorm_snd (a : \ud835\udcdc(\ud835\udd5c, A)) : \u2016a.snd\u2016\u208a = \u2016a\u2016\u208a := subtype.ext (norm_snd a)\n\nend nontrivially_normed\n\nsection densely_normed\n\nvariables {\ud835\udd5c A : Type*} [densely_normed_field \ud835\udd5c] [star_ring \ud835\udd5c]\nvariables [non_unital_normed_ring A] [star_ring A] [cstar_ring A]\nvariables [normed_space \ud835\udd5c A] [smul_comm_class \ud835\udd5c A A] [is_scalar_tower \ud835\udd5c A A] [star_module \ud835\udd5c A]\n\ninstance : cstar_ring \ud835\udcdc(\ud835\udd5c, A) :=\n{ norm_star_mul_self := \u03bb a, congr_arg (coe : \u211d\u22650 \u2192 \u211d) $ show \u2016star a * a\u2016\u208a = \u2016a\u2016\u208a * \u2016a\u2016\u208a, from\n  begin\n    /- The essence of the argument is this: let `a = (L,R)` and recall `\u2016a\u2016 = \u2016L\u2016`.\n    `star a = (star \u2218 R \u2218 star, star \u2218 L \u2218 star)`. Then for any `x y : A`, we have\n    `\u2016star a * a\u2016 = \u2016(star a * a).snd\u2016 = \u2016R (star (L (star x))) * y\u2016 = \u2016star (L (star x)) * L y\u2016`\n    Now, on the one hand,\n    `\u2016star (L (star x)) * L y\u2016 \u2264 \u2016star (L (star x))\u2016 * \u2016L y\u2016 = \u2016L (star x)\u2016 * \u2016L y\u2016 \u2264 \u2016L\u2016 ^ 2`\n    whenever `\u2016x\u2016, \u2016y\u2016 \u2264 1`, so the supremum over all such `x, y` is at most `\u2016L\u2016 ^ 2`.\n    On the other hand, for any `\u2016z\u2016 \u2264 1`, we may choose `x := star z` and `y := z` to get:\n    `\u2016star (L (star x)) * L y\u2016 = \u2016star (L z) * (L z)\u2016 = \u2016L z\u2016 ^ 2`, and taking the supremum over\n    all such `z` yields that the supremum is at least `\u2016L\u2016 ^ 2`. It is the latter part of the\n    argument where `densely_normed_field \ud835\udd5c` 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 : \u2200 x y, \u2016x\u2016\u208a \u2264 1 \u2192 \u2016y\u2016\u208a \u2264 1 \u2192 \u2016a.snd (star (a.fst (star x))) * y\u2016\u208a \u2264 \u2016a\u2016\u208a * \u2016a\u2016\u208a,\n    { intros x y hx hy,\n      rw [a.central],\n      calc \u2016star (a.fst (star x)) * a.fst y\u2016\u208a \u2264 \u2016a.fst (star x)\u2016\u208a * \u2016a.fst y\u2016\u208a\n          : nnnorm_star (a.fst (star x)) \u25b8 nnnorm_mul_le _ _\n      ... \u2264 (\u2016a.fst\u2016\u208a * 1) * (\u2016a.fst\u2016\u208a * 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      ... \u2264 \u2016a\u2016\u208a * \u2016a\u2016\u208a : by simp only [mul_one, nnnorm_fst] },\n    rw \u2190nnnorm_snd,\n    simp only [mul_snd, \u2190Sup_closed_unit_ball_eq_nnnorm, star_snd, mul_apply],\n    simp only [\u2190@op_nnnorm_mul \ud835\udd5c A],\n    simp only [\u2190Sup_closed_unit_ball_eq_nnnorm, mul_apply'],\n    refine cSup_eq_of_forall_le_of_forall_lt_exists_gt (hball.image _) _ (\u03bb r hr, _),\n    { rintro - \u27e8x, hx, rfl\u27e9,\n      refine cSup_le (hball.image _) _,\n      rintro - \u27e8y, hy, rfl\u27e9,\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 < \u2016a\u2016\u208a := (\u2016a\u2016\u208a).sqrt_mul_self \u25b8 nnreal.sqrt_lt_sqrt_iff.2 hr,\n      simp_rw [\u2190nnnorm_fst, \u2190Sup_closed_unit_ball_eq_nnnorm] at hr',\n      obtain \u27e8_, \u27e8x, hx, rfl\u27e9, hxr\u27e9 := exists_lt_of_lt_cSup (hball.image _) hr',\n      have hx' : \u2016x\u2016\u208a \u2264 1 := mem_closed_ball_zero_iff.1 hx,\n      refine \u27e8star x, mem_closed_ball_zero_iff.2 ((nnnorm_star x).trans_le hx'), _\u27e9,\n      refine lt_cSup_of_lt _ \u27e8x, hx, rfl\u27e9 _,\n      { refine \u27e8\u2016a\u2016\u208a * \u2016a\u2016\u208a, _\u27e9,\n        rintros - \u27e8y, hy, rfl\u27e9,\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, \u2190sq]\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 \u2192 string \n    | empty := \" \"\n    | ehead := \"H\"\n    | etail := \"T\"\n    | condu := \"X\"\n\ninstance cellT_to_str : has_to_string cellT := \u27e8cellT_str\u27e9\n\ninstance cellT_repr : has_repr cellT := \u27e8cellT_str\u27e9\n\ninstance cellT_deceq : decidable_eq cellT :=\n    \u03bbl 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 \u2192 \u2115 \u2192 cellT\n  | empty _ := empty\n  | ehead _ := etail\n  | etail _ := condu\n  | condu c := if c = 1 \u2228 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\u2080 cellT) : ww :=\n    \u27e8g, empty, cautomatons.moore,\n     sum.inr $ @bound_const (vec_grid\u2080 cellT) _, ww_step\u27e9\n\ndef wire_g :=\n  vec_grid\u2080.mk \u27e81, 5, dec_trivial,\n               \u27e8[etail, ehead, condu, condu, condu], rfl\u27e9\u27e9\n               \u27e80, 1\u27e9 \n\ndef wire : ww := mk_ww wire_g\n\ndef or_g_10 :=\n    vec_grid\u2080.mk \u27e85, 6, dec_trivial,\n                        \u27e8[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\u27e9\u27e9\n                        \u27e80, 1\u27e9\n\ndef or_10 : ww := mk_ww or_g_10\n\ndef or_g_01 :=\n    vec_grid\u2080.mk \u27e85, 6, dec_trivial,\n                        \u27e8[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\u27e9\u27e9\n                        \u27e80, 1\u27e9\n\ndef or_01 : ww := mk_ww or_g_01\n\nopen cardinals\n\nsection ww_or\n\ndef or_gate' :=\n    vec_grid\u2080.mk \u27e85, 6, dec_trivial,\n                        \u27e8[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\u27e9\u27e9\n                        \u27e8-5, -5\u27e9\n\ndef or_gate : ww := mk_ww or_gate'\n\ndef write_input (i\u2081 : bool) (i\u2082 : bool) :=\n    let (b\u2081, b\u2082) := if i\u2081 then (etail, ehead) else (condu, condu) in\n    let (b\u2083, b\u2084) := if i\u2082 then (etail, ehead) else (condu, condu) in\n    mod_many\n        [(\u27e8-5, -10\u27e9, b\u2081), (\u27e8-4, -10\u27e9, b\u2082), (\u27e8-5, -6\u27e9, b\u2083), (\u27e8-4, -6\u27e9, b\u2084)]\n        or_gate\n\ndef sim_or (i\u2081 i\u2082 : bool) : bool :=\n    let sim := step_n (write_input i\u2081 i\u2082) 3 in\n        yield_at sim \u27e8-8, -2\u27e9 = etail \u2227 yield_at sim \u27e8-8, -1\u27e9 = ehead\n\nend ww_or\n\nsection ww_xor\n\ninductive direction | N | W | E | S\n\nopen direction\n\nstructure inout :=\n    (p\u2081 : point)\n    (p\u2082 : point)\n    (dir : direction)\n\nstructure ww\u2081 :=\n    (aut : ww)\n    (ins : list inout)\n    (ous : list inout)\n\ndef str_of_ww\u2081 : ww\u2081 \u2192 string\n  | \u27e8aut, _, _\u27e9 := to_string aut\n\ninstance ww\u2081_to_str : has_to_string ww\u2081 := \u27e8str_of_ww\u2081\u27e9\n\ninstance ww\u2081_repr : has_repr ww\u2081 := \u27e8str_of_ww\u2081\u27e9\n\ndef mk_ww\u2081 (g : vec_grid\u2080 cellT) (inputs outputs : list inout) : ww\u2081 :=\n    \u27e8mk_ww g, inputs, outputs\u27e9\n\ndef write (a : ww\u2081) (n : \u2115) (b : bool) : ww\u2081 :=\n    let input := list.nth a.ins n in\n    match input with\n        | none := a\n        | some \u27e8p\u2081, p\u2082, dir\u27e9 :=\n          if b then\n          match dir with\n            | N :=\n                ww\u2081.mk (mod_many [(up p\u2081 p\u2082, ehead), (down p\u2081 p\u2082, etail)] a.aut)\n                        a.ins a.ous\n            | S :=\n                ww\u2081.mk (mod_many [(down p\u2081 p\u2082, ehead), (up p\u2081 p\u2082, etail)] a.aut)\n                              a.ins a.ous\n            | W :=\n              ww\u2081.mk (mod_many [(left p\u2081 p\u2082, ehead), (right p\u2081 p\u2082, etail)] a.aut)\n                              a.ins a.ous\n            | E :=\n                ww\u2081.mk (mod_many [(right p\u2081 p\u2082, ehead), (left p\u2081 p\u2082, etail)] a.aut)\n                              a.ins a.ous\n          end\n          else ww\u2081.mk (mod_many [(p\u2081, condu), (p\u2082, condu)] a.aut) a.ins a.ous\n    end\n\ndef read (a : ww\u2081) (n : \u2115) : bool :=\n    let output := list.nth a.ous n in\n    match output with\n      | none := ff\n      | some \u27e8p\u2081, p\u2082, dir\u27e9 :=\n      match dir with\n        | N := yield_at a.aut (up p\u2081 p\u2082) = ehead \u2227\n                      yield_at a.aut (down p\u2081 p\u2082) = etail\n        | S := yield_at a.aut (up p\u2081 p\u2082) = etail \u2227\n                      yield_at a.aut (down p\u2081 p\u2082) = ehead\n        | W := yield_at a.aut (left p\u2081 p\u2082) = ehead \u2227\n                      yield_at a.aut (right p\u2081 p\u2082) = etail\n        | E := yield_at a.aut (left p\u2081 p\u2082) = etail \u2227\n                      yield_at a.aut (right p\u2081 p\u2082) = ehead\n      end\n    end\n\ndef xor_gate' :=\n    vec_grid\u2080.mk \u27e87, 7, dec_trivial,\n      \u27e8[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\u27e9\u27e9\n      \u27e80, 0\u27e9\n\ndef xor_gate_inputs : list inout := [\u27e8\u27e80, 6\u27e9, \u27e81, 6\u27e9, E\u27e9, \u27e8\u27e80, 0\u27e9, \u27e81, 0\u27e9, E\u27e9]\n\ndef xor_gate_outputs : list inout := [\u27e8\u27e85, 3\u27e9, \u27e86, 3\u27e9, E\u27e9]\n\ndef mk_xor (a : ww) : ww\u2081 := \u27e8a, xor_gate_inputs, xor_gate_outputs\u27e9\n\ndef xor_gate_w : ww := mk_ww xor_gate'\n\ndef xor_gate : ww\u2081 := mk_xor xor_gate_w\n\ndef xor' (b\u2081 b\u2082 : bool) : bool :=\n    read (mk_xor (step_n (write (write xor_gate 0 b\u2082) 1 b\u2081).aut 5)) 0\n\ntheorem xor_iff_xor' {b\u2081 b\u2082} : bxor b\u2081 b\u2082 \u2194 xor' b\u2081 b\u2082 :=\nbegin\n  cases b\u2081; cases b\u2082; 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel, 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 _} {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n\n/-- `\u03b1 \u2192\u1d47 \u03b2` is the type of bounded continuous functions `\u03b1 \u2192 \u03b2` from a topological space to a\nmetric space.\n\nWhen possible, instead of parametrizing results over `(f : \u03b1 \u2192\u1d47 \u03b2)`,\nyou should parametrize over `(F : Type*) [bounded_continuous_map_class F \u03b1 \u03b2] (f : F)`.\n\nWhen you extend this structure, make sure to extend `bounded_continuous_map_class`. -/\nstructure BoundedContinuousFunction (\u03b1 : Type u) (\u03b2 : Type v) [TopologicalSpace \u03b1]\n  [PseudoMetricSpace \u03b2] extends ContinuousMap \u03b1 \u03b2 : Type max u v where\n  map_bounded' : \u2203 C, \u2200 x y, dist (to_fun x) (to_fun y) \u2264 C\n#align bounded_continuous_function BoundedContinuousFunction\n\n-- mathport name: bounded_continuous_function\nscoped[BoundedContinuousFunction] infixr:25 \" \u2192\u1d47 \" => BoundedContinuousFunction\n\nsection\n\n/-- `bounded_continuous_map_class F \u03b1 \u03b2` 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 \u03b1 \u03b2 : Type _) [TopologicalSpace \u03b1] [PseudoMetricSpace \u03b2] extends\n  ContinuousMapClass F \u03b1 \u03b2 where\n  map_bounded (f : F) : \u2203 C, \u2200 x y, dist (f x) (f y) \u2264 C\n#align bounded_continuous_map_class BoundedContinuousMapClass\n\nend\n\nexport BoundedContinuousMapClass (map_bounded)\n\nnamespace BoundedContinuousFunction\n\nsection Basics\n\nvariable [TopologicalSpace \u03b1] [PseudoMetricSpace \u03b2] [PseudoMetricSpace \u03b3]\n\nvariable {f g : \u03b1 \u2192\u1d47 \u03b2} {x : \u03b1} {C : \u211d}\n\ninstance : BoundedContinuousMapClass (\u03b1 \u2192\u1d47 \u03b2) \u03b1 \u03b2\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by\n    obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := f\n    obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := 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 (\u03b1 \u2192\u1d47 \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\n  FunLike.hasCoeToFun\n\ninstance [BoundedContinuousMapClass F \u03b1 \u03b2] : CoeTC F (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8fun f =>\n    { toFun := f\n      continuous_toFun := map_continuous f\n      map_bounded' := map_bounded f }\u27e9\n\n@[simp]\ntheorem coe_to_continuous_fun (f : \u03b1 \u2192\u1d47 \u03b2) : (f.toContinuousMap : \u03b1 \u2192 \u03b2) = 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 : \u03b1 \u2192\u1d47 \u03b2) : \u03b1 \u2192 \u03b2 :=\n  h\n#align bounded_continuous_function.simps.apply BoundedContinuousFunction.Simps.apply\n\ninitialize_simps_projections BoundedContinuousFunction (to_continuous_map_to_fun \u2192 apply)\n\nprotected theorem bounded (f : \u03b1 \u2192\u1d47 \u03b2) : \u2203 C, \u2200 x y : \u03b1, dist (f x) (f y) \u2264 C :=\n  f.map_bounded'\n#align bounded_continuous_function.bounded BoundedContinuousFunction.bounded\n\nprotected theorem continuous (f : \u03b1 \u2192\u1d47 \u03b2) : Continuous f :=\n  f.toContinuousMap.Continuous\n#align bounded_continuous_function.continuous BoundedContinuousFunction.continuous\n\n@[ext]\ntheorem ext (h : \u2200 x, f x = g x) : f = g :=\n  FunLike.ext _ _ h\n#align bounded_continuous_function.ext BoundedContinuousFunction.ext\n\ntheorem bounded_range (f : \u03b1 \u2192\u1d47 \u03b2) : 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 : \u03b1 \u2192\u1d47 \u03b2) (s : Set \u03b1) : 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 \u03b1] (f g : \u03b1 \u2192\u1d47 \u03b2) : f = g :=\n  ext <| IsEmpty.elim \u2039_\u203a\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(\u03b1, \u03b2)) (C : \u211d) (h : \u2200 x y : \u03b1, dist (f x) (f y) \u2264 C) : \u03b1 \u2192\u1d47 \u03b2 :=\n  \u27e8f, \u27e8C, h\u27e9\u27e9\n#align bounded_continuous_function.mk_of_bound BoundedContinuousFunction.mkOfBound\n\n@[simp]\ntheorem mkOfBound_coe {f} {C} {h} : (mkOfBound f C h : \u03b1 \u2192 \u03b2) = (f : \u03b1 \u2192 \u03b2) :=\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 \u03b1] (f : C(\u03b1, \u03b2)) : \u03b1 \u2192\u1d47 \u03b2 :=\n  \u27e8f, bounded_range_iff.1 (isCompact_range f.Continuous).Bounded\u27e9\n#align bounded_continuous_function.mk_of_compact BoundedContinuousFunction.mkOfCompact\n\n@[simp]\ntheorem mkOfCompact_apply [CompactSpace \u03b1] (f : C(\u03b1, \u03b2)) (a : \u03b1) : 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 \u03b1] (f : \u03b1 \u2192 \u03b2) (C : \u211d) (h : \u2200 x y : \u03b1, dist (f x) (f y) \u2264 C) :\n    \u03b1 \u2192\u1d47 \u03b2 :=\n  \u27e8\u27e8f, continuous_of_discreteTopology\u27e9, \u27e8C, h\u27e9\u27e9\n#align bounded_continuous_function.mk_of_discrete BoundedContinuousFunction.mkOfDiscrete\n\n/-- The uniform distance between two bounded continuous functions -/\ninstance : Dist (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8fun f g => inf\u209b { C | 0 \u2264 C \u2227 \u2200 x : \u03b1, dist (f x) (g x) \u2264 C }\u27e9\n\ntheorem dist_eq : dist f g = inf\u209b { C | 0 \u2264 C \u2227 \u2200 x : \u03b1, dist (f x) (g x) \u2264 C } :=\n  rfl\n#align bounded_continuous_function.dist_eq BoundedContinuousFunction.dist_eq\n\ntheorem dist_set_exists : \u2203 C, 0 \u2264 C \u2227 \u2200 x : \u03b1, dist (f x) (g x) \u2264 C :=\n  by\n  rcases f.bounded_range.union g.bounded_range with \u27e8C, hC\u27e9\n  refine' \u27e8max 0 C, le_max_left _ _, fun x => (hC _ _ _ _).trans (le_max_right _ _)\u27e9 <;> [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 : \u03b1) : dist (f x) (g x) \u2264 dist f g :=\n  le_cinf\u209b 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 \u2264 dist f g :=\n  le_cinf\u209b 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 : \u211d) \u2264 C) : dist f g \u2264 C \u2194 \u2200 x : \u03b1, dist (f x) (g x) \u2264 C :=\n  \u27e8fun h x => le_trans (dist_coe_le_dist x) h, fun H => cinf\u209b_le \u27e80, fun C => And.left\u27e9 \u27e8C0, H\u27e9\u27e9\n#align bounded_continuous_function.dist_le BoundedContinuousFunction.dist_le\n\ntheorem dist_le_iff_of_nonempty [Nonempty \u03b1] : dist f g \u2264 C \u2194 \u2200 x, dist (f x) (g x) \u2264 C :=\n  \u27e8fun h x => le_trans (dist_coe_le_dist x) h, fun w =>\n    (dist_le (le_trans dist_nonneg (w (Nonempty.some \u2039_\u203a)))).mpr w\u27e9\n#align bounded_continuous_function.dist_le_iff_of_nonempty BoundedContinuousFunction.dist_le_iff_of_nonempty\n\ntheorem dist_lt_of_nonempty_compact [Nonempty \u03b1] [CompactSpace \u03b1]\n    (w : \u2200 x : \u03b1, 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 \u27e8x, -, le\u27e9 :=\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 \u03b1] (C0 : (0 : \u211d) < C) :\n    dist f g < C \u2194 \u2200 x : \u03b1, dist (f x) (g x) < C :=\n  by\n  fconstructor\n  \u00b7 intro w x\n    exact lt_of_le_of_lt (dist_coe_le_dist x) w\n  \u00b7 by_cases h : Nonempty \u03b1\n    \u00b7 skip\n      exact dist_lt_of_nonempty_compact\n    \u00b7 rintro -\n      convert C0\n      apply le_antisymm _ dist_nonneg'\n      rw [dist_eq]\n      exact cinf\u209b_le \u27e80, fun C => And.left\u27e9 \u27e8le_rfl, fun x => False.elim (h (Nonempty.intro x))\u27e9\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 \u03b1] [CompactSpace \u03b1] :\n    dist f g < C \u2194 \u2200 x : \u03b1, dist (f x) (g x) < C :=\n  \u27e8fun w x => lt_of_le_of_lt (dist_coe_le_dist x) w, dist_lt_of_nonempty_compact\u27e9\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 (\u03b1 \u2192\u1d47 \u03b2)\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 {\u03b1 \u03b2} [TopologicalSpace \u03b1] [MetricSpace \u03b2] : MetricSpace (\u03b1 \u2192\u1d47 \u03b2)\n    where eq_of_dist_eq_zero f g hfg := by\n    ext x <;> exact eq_of_dist_eq_zero (le_antisymm (hfg \u25b8 dist_coe_le_dist _) dist_nonneg)\n\ntheorem nndist_eq : nndist f g = inf\u209b { C | \u2200 x : \u03b1, nndist (f x) (g x) \u2264 C } :=\n  Subtype.ext <|\n    dist_eq.trans <| by\n      rw [NNReal.coe_inf\u209b, NNReal.coe_image]\n      simp_rw [mem_set_of_eq, \u2190 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 : \u2203 C, \u2200 x : \u03b1, nndist (f x) (g x) \u2264 C :=\n  Subtype.exists.mpr <| dist_set_exists.imp fun a \u27e8ha, h\u27e9 => \u27e8ha, h\u27e9\n#align bounded_continuous_function.nndist_set_exists BoundedContinuousFunction.nndist_set_exists\n\ntheorem nndist_coe_le_nndist (x : \u03b1) : nndist (f x) (g x) \u2264 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 \u03b1] : 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\u1d62 : dist f g = \u2a06 x : \u03b1, dist (f x) (g x) :=\n  by\n  cases isEmpty_or_nonempty \u03b1; \u00b7 rw [sup\u1d62_of_empty', Real.sup\u209b_empty, dist_zero_of_empty]\n  refine' (dist_le_iff_of_nonempty.mpr <| le_csup\u1d62 _).antisymm (csup\u1d62_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\u1d62\n\ntheorem nndist_eq_sup\u1d62 : nndist f g = \u2a06 x : \u03b1, nndist (f x) (g x) :=\n  Subtype.ext <| dist_eq_sup\u1d62.trans <| by simp_rw [NNReal.coe_sup\u1d62, coe_nndist]\n#align bounded_continuous_function.nndist_eq_supr BoundedContinuousFunction.nndist_eq_sup\u1d62\n\ntheorem tendsto_iff_tendstoUniformly {\u03b9 : Type _} {F : \u03b9 \u2192 \u03b1 \u2192\u1d47 \u03b2} {f : \u03b1 \u2192\u1d47 \u03b2} {l : Filter \u03b9} :\n    Tendsto F l (\ud835\udcdd f) \u2194 TendstoUniformly (fun i => F i) f l :=\n  Iff.intro\n    (fun h =>\n      tendstoUniformly_iff.2 fun \u03b5 \u03b50 =>\n        (Metric.tendsto_nhds.mp h \u03b5 \u03b50).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 \u25b8 hn)))\n    fun h =>\n    Metric.tendsto_nhds.mpr fun \u03b5 \u03b5_pos =>\n      (h _ (dist_mem_uniformity <| half_pos \u03b5_pos)).mp\n        (eventually_of_forall fun n hn =>\n          lt_of_le_of_lt\n            ((dist_le (half_pos \u03b5_pos).le).mpr fun x => dist_comm (f x) (F n x) \u25b8 le_of_lt (hn x))\n            (half_lt_self \u03b5_pos))\n#align bounded_continuous_function.tendsto_iff_tendsto_uniformly BoundedContinuousFunction.tendsto_iff_tendstoUniformly\n\n/-- The topology on `\u03b1 \u2192\u1d47 \u03b2` is exactly the topology induced by the natural map to `\u03b1 \u2192\u1d64 \u03b2`. -/\ntheorem inducing_coeFn : Inducing (UniformFun.ofFun \u2218 coeFn : (\u03b1 \u2192\u1d47 \u03b2) \u2192 \u03b1 \u2192\u1d64 \u03b2) :=\n  by\n  rw [inducing_iff_nhds]\n  refine' fun f => eq_of_forall_le_iff fun l => _\n  rw [\u2190 tendsto_iff_comap, \u2190 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 \u2218 coeFn : (\u03b1 \u2192\u1d47 \u03b2) \u2192 \u03b1 \u2192\u1d64 \u03b2) :=\n  \u27e8inducing_coeFn, fun f g h => ext fun x => congr_fun h x\u27e9\n#align bounded_continuous_function.embedding_coe_fn BoundedContinuousFunction.embedding_coeFn\n\nvariable (\u03b1) {\u03b2}\n\n/-- Constant as a continuous bounded function. -/\n@[simps (config := { fullyApplied := false })]\ndef const (b : \u03b2) : \u03b1 \u2192\u1d47 \u03b2 :=\n  \u27e8ContinuousMap.const \u03b1 b, 0, by simp [le_rfl]\u27e9\n#align bounded_continuous_function.const BoundedContinuousFunction.const\n\nvariable {\u03b1}\n\ntheorem const_apply' (a : \u03b1) (b : \u03b2) : (const \u03b1 b : \u03b1 \u2192 \u03b2) 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 \u03b2] : Inhabited (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8const \u03b1 default\u27e9\n\ntheorem lipschitz_evalx (x : \u03b1) : LipschitzWith 1 fun f : \u03b1 \u2192\u1d47 \u03b2 => 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 (\u03b1 \u2192\u1d47 \u03b2) (\u03b1 \u2192 \u03b2) _ _ 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 : \u03b1 \u2192\u1d47 \u03b2) 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 : \u03b1 \u2192\u1d47 \u03b2) \u21a6 f x` is continuous -/\n@[continuity]\ntheorem continuous_eval_const {x : \u03b1} : Continuous fun f : \u03b1 \u2192\u1d47 \u03b2 => 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 : (\u03b1 \u2192\u1d47 \u03b2) \u00d7 \u03b1 => 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 \u03b2] : CompleteSpace (\u03b1 \u2192\u1d47 \u03b2) :=\n  complete_of_cauchySeq_tendsto fun (f : \u2115 \u2192 \u03b1 \u2192\u1d47 \u03b2) (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 \u27e8b, b0, b_bound, b_lim\u27e9\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 : \u2200 x, CauchySeq fun n => f n x := fun x =>\n      cauchySeq_iff_le_tendsto_0.2 \u27e8b, b0, f_bdd x, b_lim\u27e9\n    choose F hF using fun x => cauchySeq_tendsto_of_complete (fx_cau x)\n    /- F : \u03b1 \u2192 \u03b2,  hF : \u2200 (x : \u03b1), tendsto (\u03bb (n : \u2115), f n x) at_top (\ud835\udcdd (F x))\n      `F` is the desired limit function. Check that it is uniformly approximated by `f N` -/\n    have fF_bdd : \u2200 x N, dist (f N x) (F x) \u2264 b N := fun x N =>\n      le_of_tendsto (tendsto_const_nhds.dist (hF x))\n        (Filter.eventually_atTop.2 \u27e8N, fun n hn => f_bdd x N n N (le_refl N) hn\u27e9)\n    refine' \u27e8\u27e8\u27e8F, _\u27e9, _\u27e9, _\u27e9\n    \u00b7 -- 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 \u03b5 \u03b50 => _\n        refine' ((tendsto_order.1 b_lim).2 \u03b5 \u03b50).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    \u00b7 -- Check that `F` is bounded\n      rcases(f 0).Bounded with \u27e8C, hC\u27e9\n      refine' \u27e8C + (b 0 + b 0), fun x y => _\u27e9\n      calc\n        dist (F x) (F y) \u2264 dist (f 0 x) (f 0 y) + (dist (f 0 x) (F x) + dist (f 0 y) (F y)) :=\n          dist_triangle4_left _ _ _ _\n        _ \u2264 C + (b 0 + b 0) := by mono*\n        \n    \u00b7 -- 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 {\u03b4 : Type _} [TopologicalSpace \u03b4] (f : \u03b1 \u2192\u1d47 \u03b2) (g : C(\u03b4, \u03b1)) : \u03b4 \u2192\u1d47 \u03b2\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 {\u03b4 : Type _} [TopologicalSpace \u03b4] (f : \u03b1 \u2192\u1d47 \u03b2) (g : C(\u03b4, \u03b1)) :\n    coeFn (f.comp_continuous g) = f \u2218 g :=\n  rfl\n#align bounded_continuous_function.coe_comp_continuous BoundedContinuousFunction.coe_compContinuous\n\n@[simp]\ntheorem compContinuous_apply {\u03b4 : Type _} [TopologicalSpace \u03b4] (f : \u03b1 \u2192\u1d47 \u03b2) (g : C(\u03b4, \u03b1)) (x : \u03b4) :\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 {\u03b4 : Type _} [TopologicalSpace \u03b4] (g : C(\u03b4, \u03b1)) :\n    LipschitzWith 1 fun f : \u03b1 \u2192\u1d47 \u03b2 => f.comp_continuous g :=\n  LipschitzWith.mk_one fun f\u2081 f\u2082 => (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 {\u03b4 : Type _} [TopologicalSpace \u03b4] (g : C(\u03b4, \u03b1)) :\n    Continuous fun f : \u03b1 \u2192\u1d47 \u03b2 => 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 : \u03b1 \u2192\u1d47 \u03b2) (s : Set \u03b1) : s \u2192\u1d47 \u03b2 :=\n  f.comp_continuous <| (ContinuousMap.id _).restrict s\n#align bounded_continuous_function.restrict BoundedContinuousFunction.restrict\n\n@[simp]\ntheorem coe_restrict (f : \u03b1 \u2192\u1d47 \u03b2) (s : Set \u03b1) : coeFn (f.restrict s) = f \u2218 coe :=\n  rfl\n#align bounded_continuous_function.coe_restrict BoundedContinuousFunction.coe_restrict\n\n@[simp]\ntheorem restrict_apply (f : \u03b1 \u2192\u1d47 \u03b2) (s : Set \u03b1) (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 : \u03b2 \u2192 \u03b3) {C : \u211d\u22650} (H : LipschitzWith C G) (f : \u03b1 \u2192\u1d47 \u03b2) : \u03b1 \u2192\u1d47 \u03b3 :=\n  \u27e8\u27e8fun x => G (f x), H.Continuous.comp f.Continuous\u27e9,\n    let \u27e8D, hD\u27e9 := f.Bounded\n    \u27e8max C 0 * D, fun x y =>\n      calc\n        dist (G (f x)) (G (f y)) \u2264 C * dist (f x) (f y) := H.dist_le_mul _ _\n        _ \u2264 max C 0 * dist (f x) (f y) := (mul_le_mul_of_nonneg_right (le_max_left C 0) dist_nonneg)\n        _ \u2264 max C 0 * D := mul_le_mul_of_nonneg_left (hD _ _) (le_max_right C 0)\n        \u27e9\u27e9\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 : \u03b2 \u2192 \u03b3} {C : \u211d\u22650} (H : LipschitzWith C G) :\n    LipschitzWith C (comp G H : (\u03b1 \u2192\u1d47 \u03b2) \u2192 \u03b1 \u2192\u1d47 \u03b3) :=\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)) \u2264 C * dist (f x) (g x) := H.dist_le_mul _ _\n        _ \u2264 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 : \u03b2 \u2192 \u03b3} {C : \u211d\u22650} (H : LipschitzWith C G) :\n    UniformContinuous (comp G H : (\u03b1 \u2192\u1d47 \u03b2) \u2192 \u03b1 \u2192\u1d47 \u03b3) :=\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 : \u03b2 \u2192 \u03b3} {C : \u211d\u22650} (H : LipschitzWith C G) :\n    Continuous (comp G H : (\u03b1 \u2192\u1d47 \u03b2) \u2192 \u03b1 \u2192\u1d47 \u03b3) :=\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 \u03b2) (f : \u03b1 \u2192\u1d47 \u03b2) (H : \u2200 x, f x \u2208 s) : \u03b1 \u2192\u1d47 s :=\n  \u27e8\u27e8s.codRestrict f H, f.Continuous.subtype_mk _\u27e9, f.Bounded\u27e9\n#align bounded_continuous_function.cod_restrict BoundedContinuousFunction.codRestrict\n\nsection Extend\n\nvariable {\u03b4 : Type _} [TopologicalSpace \u03b4] [DiscreteTopology \u03b4]\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 : \u03b1 \u21aa \u03b4) (g : \u03b1 \u2192\u1d47 \u03b2) (h : \u03b4 \u2192\u1d47 \u03b2) : \u03b4 \u2192\u1d47 \u03b2\n    where\n  toFun := extend f g h\n  continuous_toFun := continuous_of_discreteTopology\n  map_bounded' :=\n    by\n    rw [\u2190 bounded_range_iff, range_extend f.injective, Metric.bounded_union]\n    exact \u27e8g.bounded_range, h.bounded_image _\u27e9\n#align bounded_continuous_function.extend BoundedContinuousFunction.extend\n\n@[simp]\ntheorem extend_apply (f : \u03b1 \u21aa \u03b4) (g : \u03b1 \u2192\u1d47 \u03b2) (h : \u03b4 \u2192\u1d47 \u03b2) (x : \u03b1) : 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 : \u03b1 \u21aa \u03b4) (g : \u03b1 \u2192\u1d47 \u03b2) (h : \u03b4 \u2192\u1d47 \u03b2) : extend f g h \u2218 f = g :=\n  extend_comp f.Injective _ _\n#align bounded_continuous_function.extend_comp BoundedContinuousFunction.extend_comp\n\ntheorem extend_apply' {f : \u03b1 \u21aa \u03b4} {x : \u03b4} (hx : x \u2209 range f) (g : \u03b1 \u2192\u1d47 \u03b2) (h : \u03b4 \u2192\u1d47 \u03b2) :\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 \u03b1] (f : \u03b1 \u21aa \u03b4) (g : \u03b1 \u2192\u1d47 \u03b2) (h : \u03b4 \u2192\u1d47 \u03b2) : 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 : \u03b1 \u21aa \u03b4) (g\u2081 g\u2082 : \u03b1 \u2192\u1d47 \u03b2) (h\u2081 h\u2082 : \u03b4 \u2192\u1d47 \u03b2) :\n    dist (g\u2081.extend f h\u2081) (g\u2082.extend f h\u2082) =\n      max (dist g\u2081 g\u2082) (dist (h\u2081.restrict (range f\u1d9c)) (h\u2082.restrict (range f\u1d9c))) :=\n  by\n  refine' le_antisymm ((dist_le <| le_max_iff.2 <| Or.inl dist_nonneg).2 fun x => _) (max_le _ _)\n  \u00b7 rcases em (\u2203 y, f y = x) with (\u27e8x, rfl\u27e9 | hx)\n    \u00b7 simp only [extend_apply]\n      exact (dist_coe_le_dist x).trans (le_max_left _ _)\n    \u00b7 simp only [extend_apply' hx]\n      lift x to (range f\u1d9c : Set \u03b4) using hx\n      calc\n        dist (h\u2081 x) (h\u2082 x) = dist (h\u2081.restrict (range f\u1d9c) x) (h\u2082.restrict (range f\u1d9c) x) := rfl\n        _ \u2264 dist (h\u2081.restrict (range f\u1d9c)) (h\u2082.restrict (range f\u1d9c)) := (dist_coe_le_dist x)\n        _ \u2264 _ := le_max_right _ _\n        \n  \u00b7 refine' (dist_le dist_nonneg).2 fun x => _\n    rw [\u2190 extend_apply f g\u2081 h\u2081, \u2190 extend_apply f g\u2082 h\u2082]\n    exact dist_coe_le_dist _\n  \u00b7 refine' (dist_le dist_nonneg).2 fun x => _\n    calc\n      dist (h\u2081 x) (h\u2082 x) = dist (extend f g\u2081 h\u2081 x) (extend f g\u2082 h\u2082 x) := by\n        rw [extend_apply' x.coe_prop, extend_apply' x.coe_prop]\n      _ \u2264 _ := dist_coe_le_dist _\n      \n#align bounded_continuous_function.dist_extend_extend BoundedContinuousFunction.dist_extend_extend\n\ntheorem isometry_extend (f : \u03b1 \u21aa \u03b4) (h : \u03b4 \u2192\u1d47 \u03b2) : Isometry fun g : \u03b1 \u2192\u1d47 \u03b2 => extend f g h :=\n  Isometry.of_dist_eq fun g\u2081 g\u2082 => 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 \u03b1] [CompactSpace \u03b1] [PseudoMetricSpace \u03b2]\n\nvariable {f g : \u03b1 \u2192\u1d47 \u03b2} {x : \u03b1} {C : \u211d}\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y z \u00abexpr \u2208 \u00bb 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\u2081 [CompactSpace \u03b2] (A : Set (\u03b1 \u2192\u1d47 \u03b2)) (closed : IsClosed A)\n    (H : Equicontinuous (coeFn : A \u2192 \u03b1 \u2192 \u03b2)) : 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 \u03b5 \u03b50 => _\n  rcases exists_between \u03b50 with \u27e8\u03b5\u2081, \u03b5\u20810, \u03b5\u03b5\u2081\u27e9\n  let \u03b5\u2082 := \u03b5\u2081 / 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 \u03b5. This information will be\n    provided by the values of `u` on a sufficiently dense set t\u03b1,\n    slightly translated to fit in a finite \u03b5\u2082-dense set t\u03b2 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 \u03b5, one uses the control on the modulus of\n    continuity to extend the closeness on t\u03b1 to closeness everywhere. -/\n  have \u03b5\u20820 : \u03b5\u2082 > 0 := half_pos (half_pos \u03b5\u20810)\n  have :\n    \u2200 x : \u03b1,\n      \u2203 U,\n        x \u2208 U \u2227\n          IsOpen U \u2227\n            \u2200 (y) (_ : y \u2208 U) (z) (_ : z \u2208 U) {f : \u03b1 \u2192\u1d47 \u03b2}, f \u2208 A \u2192 dist (f y) (f z) < \u03b5\u2082 :=\n    fun x =>\n    let \u27e8U, nhdsU, hU\u27e9 := H x _ \u03b5\u20820\n    let \u27e8V, VU, openV, xV\u27e9 := _root_.mem_nhds_iff.1 nhdsU\n    \u27e8V, xV, openV, fun y hy z hz f hf => hU y (VU hy) z (VU hz) \u27e8f, hf\u27e9\u27e9\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 \u03b5\u2082.\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    \u27e8t\u03b1, _, \u27e8_\u27e9, ht\u03b1\u27e9\n  -- t\u03b1 : set \u03b1, ht\u03b1 : univ \u2286 \u22c3x \u2208 t\u03b1, U x\n  rcases@finite_cover_balls_of_compact \u03b2 _ _ isCompact_univ _ \u03b5\u20820 with \u27e8t\u03b2, _, \u27e8_\u27e9, ht\u03b2\u27e9\n  skip\n  -- t\u03b2 : set \u03b2, ht\u03b2 : univ \u2286 \u22c3y \u2208 t\u03b2, ball y \u03b5\u2082 \n  -- Associate to every point `y` in the space a nearby point `F y` in t\u03b2\n  choose F hF using fun y => show \u2203 z \u2208 t\u03b2, dist y z < \u03b5\u2082 by simpa using ht\u03b2 (mem_univ y)\n  -- F : \u03b2 \u2192 \u03b2, hF : \u2200 (y : \u03b2), F y \u2208 t\u03b2 \u2227 dist y (F y) < \u03b5\u2082 \n  /- Associate to every function a discrete approximation, mapping each point in `t\u03b1`\n    to a point in `t\u03b2` close to its true image by the function. -/\n  refine' \u27e8t\u03b1 \u2192 t\u03b2, by infer_instance, fun f a => \u27e8F (f a), (hF (f a)).1\u27e9, _\u27e9\n  rintro \u27e8f, hf\u27e9 \u27e8g, hg\u27e9 f_eq_g\n  -- If two functions have the same approximation, then they are within distance \u03b5\n  refine' lt_of_le_of_lt ((dist_le <| le_of_lt \u03b5\u20810).2 fun x => _) \u03b5\u03b5\u2081\n  obtain \u27e8x', x't\u03b1, hx'\u27e9 : \u2203 x' \u2208 t\u03b1, x \u2208 U x' := mem_Union\u2082.1 (ht\u03b1 (mem_univ x))\n  calc\n    dist (f x) (g x) \u2264 dist (f x) (f x') + dist (g x) (g x') + dist (f x') (g x') :=\n      dist_triangle4_right _ _ _ _\n    _ \u2264 \u03b5\u2082 + \u03b5\u2082 + \u03b5\u2081 / 2 := (le_of_lt (add_lt_add (add_lt_add _ _) _))\n    _ = \u03b5\u2081 := by rw [add_halves, add_halves]\n    \n  \u00b7 exact (hU x').2.2 _ hx' _ (hU x').1 hf\n  \u00b7 exact (hU x').2.2 _ hx' _ (hU x').1 hg\n  \u00b7 have F_f_g : F (f x') = F (g x') :=\n      (congr_arg (fun f : t\u03b1 \u2192 t\u03b2 => (f \u27e8x', x't\u03b1\u27e9 : \u03b2)) f_eq_g : _)\n    calc\n      dist (f x') (g x') \u2264 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      _ < \u03b5\u2082 + \u03b5\u2082 := (add_lt_add (hF (f x')).2 (hF (g x')).2)\n      _ = \u03b5\u2081 / 2 := add_halves _\n      \n#align bounded_continuous_function.arzela_ascoli\u2081 BoundedContinuousFunction.arzela_ascoli\u2081\n\n/-- Second version, with pointwise equicontinuity and range in a compact subset -/\ntheorem arzela_ascoli\u2082 (s : Set \u03b2) (hs : IsCompact s) (A : Set (\u03b1 \u2192\u1d47 \u03b2)) (closed : IsClosed A)\n    (in_s : \u2200 (f : \u03b1 \u2192\u1d47 \u03b2) (x : \u03b1), f \u2208 A \u2192 f x \u2208 s) (H : Equicontinuous (coeFn : A \u2192 \u03b1 \u2192 \u03b2)) :\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 : (\u03b1 \u2192\u1d47 s) \u2192 \u03b1 \u2192\u1d47 \u03b2 := comp coe M\n  refine'\n    isCompact_of_isClosed_subset ((_ : IsCompact (F \u207b\u00b9' A)).image (continuous_comp M)) closed\n      fun f hf => _\n  \u00b7 haveI : CompactSpace s := isCompact_iff_compactSpace.1 hs\n    refine' arzela_ascoli\u2081 _ (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  \u00b7 let g := cod_restrict s f fun x => in_s f x hf\n    rw [show f = F g by ext <;> rfl] at hf\u22a2\n    exact \u27e8g, hf, rfl\u27e9\n#align bounded_continuous_function.arzela_ascoli\u2082 BoundedContinuousFunction.arzela_ascoli\u2082\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 \u03b2] (s : Set \u03b2) (hs : IsCompact s) (A : Set (\u03b1 \u2192\u1d47 \u03b2))\n    (in_s : \u2200 (f : \u03b1 \u2192\u1d47 \u03b2) (x : \u03b1), f \u2208 A \u2192 f x \u2208 s) (H : Equicontinuous (coeFn : A \u2192 \u03b1 \u2192 \u03b2)) :\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\u2082\n    s hs (closure A) isClosed_closure\n    (fun f x hf =>\n      (mem_of_closed' hs.IsClosed).2 fun \u03b5 \u03b50 =>\n        let \u27e8g, gA, dist_fg\u27e9 := Metric.mem_closure_iff.1 hf \u03b5 \u03b50\n        \u27e8g x, in_s g x gA, lt_of_le_of_lt (dist_coe_le_dist _) dist_fg\u27e9)\n    (H.closure' continuous_coe)\n#align bounded_continuous_function.arzela_ascoli BoundedContinuousFunction.arzela_ascoli\n\nend ArzelaAscoli\n\nsection One\n\nvariable [TopologicalSpace \u03b1] [PseudoMetricSpace \u03b2] [One \u03b2]\n\n@[to_additive]\ninstance : One (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8const \u03b1 1\u27e9\n\n@[simp, to_additive]\ntheorem coe_one : ((1 : \u03b1 \u2192\u1d47 \u03b2) : \u03b1 \u2192 \u03b2) = 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 \u03b1] : mkOfCompact (1 : C(\u03b1, \u03b2)) = 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 : \u03b1 \u2192\u1d47 \u03b2) : (\u2200 x, f x = 1) \u2194 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 \u03b3] (f : C(\u03b3, \u03b1)) :\n    (1 : \u03b1 \u2192\u1d47 \u03b2).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 `\u03b2` is an `add_monoid` whose addition operation is Lipschitz, then we show\nthat the space of bounded continuous functions from `\u03b1` to `\u03b2` 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 \u03b1] [PseudoMetricSpace \u03b2] [AddMonoid \u03b2]\n\nvariable [LipschitzAdd \u03b2]\n\nvariable (f g : \u03b1 \u2192\u1d47 \u03b2) {x : \u03b1} {C : \u211d}\n\n/-- The pointwise sum of two bounded continuous functions is again bounded continuous. -/\ninstance : Add (\u03b1 \u2192\u1d47 \u03b2)\n    where add f g :=\n    BoundedContinuousFunction.mkOfBound (f.toContinuousMap + g.toContinuousMap)\n      (\u2191(LipschitzAdd.C \u03b2) * max (Classical.choose f.Bounded) (Classical.choose g.Bounded))\n      (by\n        intro x y\n        refine' le_trans (lipschitz_with_lipschitz_const_add \u27e8f x, g x\u27e9 \u27e8f y, g y\u27e9) _\n        rw [Prod.dist_eq]\n        refine' mul_le_mul_of_nonneg_left _ (LipschitzAdd.C \u03b2).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 : \u21d1(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 \u03b1] (f g : C(\u03b1, \u03b2)) :\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 \u03b3] (h : C(\u03b3, \u03b1)) :\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 : \u2200 n, \u21d1(nsmulRec n f) = n \u2022 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 \u2115 (\u03b1 \u2192\u1d47 \u03b2)\n    where smul n f :=\n    { toContinuousMap := n \u2022 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 : \u2115) (f : \u03b1 \u2192\u1d47 \u03b2) : \u21d1(r \u2022 f) = r \u2022 f :=\n  rfl\n#align bounded_continuous_function.coe_nsmul BoundedContinuousFunction.coe_nsmul\n\n@[simp]\ntheorem nsmul_apply (r : \u2115) (f : \u03b1 \u2192\u1d47 \u03b2) (v : \u03b1) : (r \u2022 f) v = r \u2022 f v :=\n  rfl\n#align bounded_continuous_function.nsmul_apply BoundedContinuousFunction.nsmul_apply\n\ninstance : AddMonoid (\u03b1 \u2192\u1d47 \u03b2) :=\n  FunLike.coe_injective.AddMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _\n\ninstance : LipschitzAdd (\u03b1 \u2192\u1d47 \u03b2)\n    where lipschitz_add :=\n    \u27e8LipschitzAdd.C \u03b2, by\n      have C_nonneg := (LipschitzAdd.C \u03b2).coe_nonneg\n      rw [lipschitzWith_iff_dist_le_mul]\n      rintro \u27e8f\u2081, g\u2081\u27e9 \u27e8f\u2082, g\u2082\u27e9\n      rw [dist_le (mul_nonneg C_nonneg dist_nonneg)]\n      intro x\n      refine' le_trans (lipschitz_with_lipschitz_const_add \u27e8f\u2081 x, g\u2081 x\u27e9 \u27e8f\u2082 x, g\u2082 x\u27e9) _\n      refine' mul_le_mul_of_nonneg_left _ C_nonneg\n      apply max_le_max <;> exact dist_coe_le_dist x\u27e9\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 : (\u03b1 \u2192\u1d47 \u03b2) \u2192+ \u03b1 \u2192 \u03b2 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 (\u03b1 \u03b2)\n\n/-- The additive map forgetting that a bounded continuous function is bounded.\n-/\n@[simps]\ndef toContinuousMapAddHom : (\u03b1 \u2192\u1d47 \u03b2) \u2192+ C(\u03b1, \u03b2)\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 \u03b1] [PseudoMetricSpace \u03b2] [AddCommMonoid \u03b2] [LipschitzAdd \u03b2]\n\n@[to_additive]\ninstance : AddCommMonoid (\u03b1 \u2192\u1d47 \u03b2) :=\n  { BoundedContinuousFunction.addMonoid with add_comm := fun f g => by ext <;> simp [add_comm] }\n\nopen BigOperators\n\n@[simp]\ntheorem coe_sum {\u03b9 : Type _} (s : Finset \u03b9) (f : \u03b9 \u2192 \u03b1 \u2192\u1d47 \u03b2) :\n    \u21d1(\u2211 i in s, f i) = \u2211 i in s, (f i : \u03b1 \u2192 \u03b2) :=\n  (@coeFnAddHom \u03b1 \u03b2 _ _ _ _).map_sum f s\n#align bounded_continuous_function.coe_sum BoundedContinuousFunction.coe_sum\n\ntheorem sum_apply {\u03b9 : Type _} (s : Finset \u03b9) (f : \u03b9 \u2192 \u03b1 \u2192\u1d47 \u03b2) (a : \u03b1) :\n    (\u2211 i in s, f i) a = \u2211 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 \u03b2 is a normed group, then we show that the space of bounded\ncontinuous functions from \u03b1 to \u03b2 inherits a normed group structure, by using\npointwise operations and checking that they are compatible with the uniform distance. -/\nvariable [TopologicalSpace \u03b1] [SeminormedAddCommGroup \u03b2]\n\nvariable (f g : \u03b1 \u2192\u1d47 \u03b2) {x : \u03b1} {C : \u211d}\n\ninstance : Norm (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8fun u => dist u 0\u27e9\n\ntheorem norm_def : \u2016f\u2016 = 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 `\u2016f x\u2016`.\nWe use `Inf` to ensure that the definition works if `\u03b1` has no elements. -/\ntheorem norm_eq (f : \u03b1 \u2192\u1d47 \u03b2) : \u2016f\u2016 = inf\u209b { C : \u211d | 0 \u2264 C \u2227 \u2200 x : \u03b1, \u2016f x\u2016 \u2264 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 \u2264 C` condition in the formula for \u2016f\u2016 as an\n`Inf`. -/\ntheorem norm_eq_of_nonempty [h : Nonempty \u03b1] : \u2016f\u2016 = inf\u209b { C : \u211d | \u2200 x : \u03b1, \u2016f x\u2016 \u2264 C } :=\n  by\n  obtain \u27e8a\u27e9 := 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 \u03b1] : \u2016f\u2016 = 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 : \u03b1) : \u2016f x\u2016 \u2264 \u2016f\u2016 :=\n  calc\n    \u2016f x\u2016 = dist (f x) ((0 : \u03b1 \u2192\u1d47 \u03b2) x) := by simp [dist_zero_right]\n    _ \u2264 \u2016f\u2016 := 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 : \u03b3 \u2192 \u03b2} {C : \u211d} (hC : \u2200 x, \u2016f x\u2016 \u2264 C) (x y : \u03b3) :\n    dist (f x) (f y) \u2264 2 * C :=\n  calc\n    dist (f x) (f y) \u2264 \u2016f x\u2016 + \u2016f y\u2016 := dist_le_norm_add_norm _ _\n    _ \u2264 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 : \u03b1) : dist (f x) (f y) \u2264 2 * \u2016f\u2016 :=\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 : \u211d) \u2264 C) : \u2016f\u2016 \u2264 C \u2194 \u2200 x : \u03b1, \u2016f x\u2016 \u2264 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 \u03b1] {f : \u03b1 \u2192\u1d47 \u03b2} {M : \u211d} : \u2016f\u2016 \u2264 M \u2194 \u2200 x, \u2016f x\u2016 \u2264 M :=\n  by\n  simp_rw [norm_def, \u2190 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 \u03b1] {f : \u03b1 \u2192\u1d47 \u03b2} {M : \u211d} (M0 : 0 < M) :\n    \u2016f\u2016 < M \u2194 \u2200 x, \u2016f x\u2016 < M :=\n  by\n  simp_rw [norm_def, \u2190 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 \u03b1] [CompactSpace \u03b1] {f : \u03b1 \u2192\u1d47 \u03b2} {M : \u211d} :\n    \u2016f\u2016 < M \u2194 \u2200 x, \u2016f x\u2016 < M :=\n  by\n  simp_rw [norm_def, \u2190 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 \u03b1 b` is less than or equal to `\u2016b\u2016`. If `\u03b1` is nonempty,\nthen it is equal to `\u2016b\u2016`. -/\ntheorem norm_const_le (b : \u03b2) : \u2016const \u03b1 b\u2016 \u2264 \u2016b\u2016 :=\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 \u03b1] (b : \u03b2) : \u2016const \u03b1 b\u2016 = \u2016b\u2016 :=\n  le_antisymm (norm_const_le b) <| h.elim fun x => (const \u03b1 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 {\u03b1 : Type u} {\u03b2 : Type v} [TopologicalSpace \u03b1] [SeminormedAddCommGroup \u03b2]\n    (f : \u03b1 \u2192 \u03b2) (Hf : Continuous f) (C : \u211d) (H : \u2200 x, \u2016f x\u2016 \u2264 C) : \u03b1 \u2192\u1d47 \u03b2 :=\n  \u27e8\u27e8fun n => f n, Hf\u27e9, \u27e8_, dist_le_two_norm' H\u27e9\u27e9\n#align bounded_continuous_function.of_normed_add_comm_group BoundedContinuousFunction.ofNormedAddCommGroup\n\n@[simp]\ntheorem coe_ofNormedAddCommGroup {\u03b1 : Type u} {\u03b2 : Type v} [TopologicalSpace \u03b1]\n    [SeminormedAddCommGroup \u03b2] (f : \u03b1 \u2192 \u03b2) (Hf : Continuous f) (C : \u211d) (H : \u2200 x, \u2016f x\u2016 \u2264 C) :\n    (ofNormedAddCommGroup f Hf C H : \u03b1 \u2192 \u03b2) = f :=\n  rfl\n#align bounded_continuous_function.coe_of_normed_add_comm_group BoundedContinuousFunction.coe_ofNormedAddCommGroup\n\ntheorem norm_ofNormedAddCommGroup_le {f : \u03b1 \u2192 \u03b2} (hfc : Continuous f) {C : \u211d} (hC : 0 \u2264 C)\n    (hfC : \u2200 x, \u2016f x\u2016 \u2264 C) : \u2016ofNormedAddCommGroup f hfc C hfC\u2016 \u2264 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 {\u03b1 : Type u} {\u03b2 : Type v} [TopologicalSpace \u03b1] [DiscreteTopology \u03b1]\n    [SeminormedAddCommGroup \u03b2] (f : \u03b1 \u2192 \u03b2) (C : \u211d) (H : \u2200 x, norm (f x) \u2264 C) : \u03b1 \u2192\u1d47 \u03b2 :=\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 {\u03b1 : Type u} {\u03b2 : Type v} [TopologicalSpace \u03b1]\n    [DiscreteTopology \u03b1] [SeminormedAddCommGroup \u03b2] (f : \u03b1 \u2192 \u03b2) (C : \u211d) (H : \u2200 x, \u2016f x\u2016 \u2264 C) :\n    (ofNormedAddCommGroupDiscrete f C H : \u03b1 \u2192 \u03b2) = 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 \u211d. -/\ndef normComp : \u03b1 \u2192\u1d47 \u211d :=\n  f.comp norm lipschitzWith_one_norm\n#align bounded_continuous_function.norm_comp BoundedContinuousFunction.normComp\n\n@[simp]\ntheorem coe_normComp : (f.normComp : \u03b1 \u2192 \u211d) = norm \u2218 f :=\n  rfl\n#align bounded_continuous_function.coe_norm_comp BoundedContinuousFunction.coe_normComp\n\n@[simp]\ntheorem norm_normComp : \u2016f.normComp\u2016 = \u2016f\u2016 := 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 \u2218 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\u1d62_norm : \u2016f\u2016 = \u2a06 x : \u03b1, \u2016f x\u2016 := 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\u1d62_norm\n\n/-- If `\u2016(1 : \u03b2)\u2016 = 1`, then `\u2016(1 : \u03b1 \u2192\u1d47 \u03b2)\u2016 = 1` if `\u03b1` is nonempty. -/\ninstance [Nonempty \u03b1] [One \u03b2] [NormOneClass \u03b2] : NormOneClass (\u03b1 \u2192\u1d47 \u03b2)\n    where norm_one := by simp only [norm_eq_supr_norm, coe_one, Pi.one_apply, norm_one, csup\u1d62_const]\n\n/-- The pointwise opposite of a bounded continuous function is again bounded continuous. -/\ninstance : Neg (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8fun f =>\n    ofNormedAddCommGroup (-f) f.Continuous.neg \u2016f\u2016 fun x =>\n      trans_rel_right _ (norm_neg _) (f.norm_coe_le_norm x)\u27e9\n\n/-- The pointwise difference of two bounded continuous functions is again bounded continuous. -/\ninstance : Sub (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8fun f g =>\n    ofNormedAddCommGroup (f - g) (f.Continuous.sub g.Continuous) (\u2016f\u2016 + \u2016g\u2016) 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))\u27e9\n\n@[simp]\ntheorem coe_neg : \u21d1(-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 : \u21d1(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 \u03b1] (f : C(\u03b1, \u03b2)) : 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 \u03b1] (f g : C(\u03b1, \u03b2)) :\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 : \u2200 z, \u21d1(zsmulRec z f) = z \u2022 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 \u2124 (\u03b1 \u2192\u1d47 \u03b2)\n    where smul n f :=\n    { toContinuousMap := n \u2022 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 : \u2124) (f : \u03b1 \u2192\u1d47 \u03b2) : \u21d1(r \u2022 f) = r \u2022 f :=\n  rfl\n#align bounded_continuous_function.coe_zsmul BoundedContinuousFunction.coe_zsmul\n\n@[simp]\ntheorem zsmul_apply (r : \u2124) (f : \u03b1 \u2192\u1d47 \u03b2) (v : \u03b1) : (r \u2022 f) v = r \u2022 f v :=\n  rfl\n#align bounded_continuous_function.zsmul_apply BoundedContinuousFunction.zsmul_apply\n\ninstance : AddCommGroup (\u03b1 \u2192\u1d47 \u03b2) :=\n  FunLike.coe_injective.AddCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _)\n    fun _ _ => coe_zsmul _ _\n\ninstance : SeminormedAddCommGroup (\u03b1 \u2192\u1d47 \u03b2)\n    where dist_eq f g := by simp only [norm_eq, dist_eq, dist_eq_norm, sub_apply]\n\ninstance {\u03b1 \u03b2} [TopologicalSpace \u03b1] [NormedAddCommGroup \u03b2] : NormedAddCommGroup (\u03b1 \u2192\u1d47 \u03b2) :=\n  { BoundedContinuousFunction.seminormedAddCommGroup with }\n\ntheorem nnnorm_def : \u2016f\u2016\u208a = nndist f 0 :=\n  rfl\n#align bounded_continuous_function.nnnorm_def BoundedContinuousFunction.nnnorm_def\n\ntheorem nnnorm_coe_le_nnnorm (x : \u03b1) : \u2016f x\u2016\u208a \u2264 \u2016f\u2016\u208a :=\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 : \u03b1) : nndist (f x) (f y) \u2264 2 * \u2016f\u2016\u208a :=\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 : \u211d\u22650) : \u2016f\u2016\u208a \u2264 C \u2194 \u2200 x : \u03b1, \u2016f x\u2016\u208a \u2264 C :=\n  norm_le C.Prop\n#align bounded_continuous_function.nnnorm_le BoundedContinuousFunction.nnnorm_le\n\ntheorem nnnorm_const_le (b : \u03b2) : \u2016const \u03b1 b\u2016\u208a \u2264 \u2016b\u2016\u208a :=\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 \u03b1] (b : \u03b2) : \u2016const \u03b1 b\u2016\u208a = \u2016b\u2016\u208a :=\n  Subtype.ext <| norm_const_eq _\n#align bounded_continuous_function.nnnorm_const_eq BoundedContinuousFunction.nnnorm_const_eq\n\ntheorem nnnorm_eq_sup\u1d62_nnnorm : \u2016f\u2016\u208a = \u2a06 x : \u03b1, \u2016f x\u2016\u208a :=\n  Subtype.ext <| (norm_eq_sup\u1d62_norm f).trans <| by simp_rw [NNReal.coe_sup\u1d62, coe_nnnorm]\n#align bounded_continuous_function.nnnorm_eq_supr_nnnorm BoundedContinuousFunction.nnnorm_eq_sup\u1d62_nnnorm\n\ntheorem abs_diff_coe_le_dist : \u2016f x - g x\u2016 \u2264 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 : \u03b1 \u2192\u1d47 \u211d} : f x \u2264 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 \u03b3] (f : \u03b1 \u2192\u1d47 \u03b2) (g : C(\u03b3, \u03b1)) :\n    \u2016f.comp_continuous g\u2016 \u2264 \u2016f\u2016 :=\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 `\u03b2` is a metric space and a `\ud835\udd5c`-module whose addition and scalar multiplication\nare compatible with the metric structure, then we show that the space of bounded continuous\nfunctions from `\u03b1` to `\u03b2` 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 {\ud835\udd5c : Type _} [PseudoMetricSpace \ud835\udd5c] [TopologicalSpace \u03b1] [PseudoMetricSpace \u03b2]\n\nsection SMul\n\nvariable [Zero \ud835\udd5c] [Zero \u03b2] [SMul \ud835\udd5c \u03b2] [BoundedSMul \ud835\udd5c \u03b2]\n\ninstance : SMul \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b2)\n    where smul c f :=\n    { toContinuousMap := c \u2022 f.toContinuousMap\n      map_bounded' :=\n        let \u27e8b, hb\u27e9 := f.Bounded\n        \u27e8dist 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\u27e9 }\n\n@[simp]\ntheorem coe_smul (c : \ud835\udd5c) (f : \u03b1 \u2192\u1d47 \u03b2) : \u21d1(c \u2022 f) = fun x => c \u2022 f x :=\n  rfl\n#align bounded_continuous_function.coe_smul BoundedContinuousFunction.coe_smul\n\ntheorem smul_apply (c : \ud835\udd5c) (f : \u03b1 \u2192\u1d47 \u03b2) (x : \u03b1) : (c \u2022 f) x = c \u2022 f x :=\n  rfl\n#align bounded_continuous_function.smul_apply BoundedContinuousFunction.smul_apply\n\ninstance [SMul \ud835\udd5c\u1d50\u1d52\u1d56 \u03b2] [IsCentralScalar \ud835\udd5c \u03b2] : IsCentralScalar \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b2)\n    where op_smul_eq_smul _ _ := ext fun _ => op_smul_eq_smul _ _\n\ninstance : BoundedSMul \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b2)\n    where\n  dist_smul_pair' c f\u2081 f\u2082 :=\n    by\n    rw [dist_le (mul_nonneg dist_nonneg dist_nonneg)]\n    intro x\n    refine' (dist_smul_pair c (f\u2081 x) (f\u2082 x)).trans _\n    exact mul_le_mul_of_nonneg_left (dist_coe_le_dist x) dist_nonneg\n  dist_pair_smul' c\u2081 c\u2082 f :=\n    by\n    rw [dist_le (mul_nonneg dist_nonneg dist_nonneg)]\n    intro x\n    refine' (dist_pair_smul c\u2081 c\u2082 (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 \ud835\udd5c] [Zero \u03b2] [MulAction \ud835\udd5c \u03b2] [BoundedSMul \ud835\udd5c \u03b2]\n\ninstance : MulAction \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b2) :=\n  FunLike.coe_injective.MulAction _ coe_smul\n\nend MulAction\n\nsection DistribMulAction\n\nvariable [MonoidWithZero \ud835\udd5c] [AddMonoid \u03b2] [DistribMulAction \ud835\udd5c \u03b2] [BoundedSMul \ud835\udd5c \u03b2]\n\nvariable [LipschitzAdd \u03b2]\n\ninstance : DistribMulAction \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b2) :=\n  Function.Injective.distribMulAction \u27e8_, coe_zero, coe_add\u27e9 FunLike.coe_injective coe_smul\n\nend DistribMulAction\n\nsection Module\n\nvariable [Semiring \ud835\udd5c] [AddCommMonoid \u03b2] [Module \ud835\udd5c \u03b2] [BoundedSMul \ud835\udd5c \u03b2]\n\nvariable {f g : \u03b1 \u2192\u1d47 \u03b2} {x : \u03b1} {C : \u211d}\n\nvariable [LipschitzAdd \u03b2]\n\ninstance : Module \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b2) :=\n  Function.Injective.module _ \u27e8_, coe_zero, coe_add\u27e9 FunLike.coe_injective coe_smul\n\nvariable (\ud835\udd5c)\n\n/-- The evaluation at a point, as a continuous linear map from `\u03b1 \u2192\u1d47 \u03b2` to `\u03b2`. -/\ndef evalClm (x : \u03b1) : (\u03b1 \u2192\u1d47 \u03b2) \u2192L[\ud835\udd5c] \u03b2 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 : \u03b1) (f : \u03b1 \u2192\u1d47 \u03b2) : evalClm \ud835\udd5c x f = f x :=\n  rfl\n#align bounded_continuous_function.eval_clm_apply BoundedContinuousFunction.evalClm_apply\n\nvariable (\u03b1 \u03b2)\n\n/-- The linear map forgetting that a bounded continuous function is bounded. -/\n@[simps]\ndef toContinuousMapLinearMap : (\u03b1 \u2192\u1d47 \u03b2) \u2192\u2097[\ud835\udd5c] C(\u03b1, \u03b2)\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 `\u03b2` is a normed space, then we show that the space of bounded\ncontinuous functions from `\u03b1` to `\u03b2` inherits a normed space structure, by using\npointwise operations and checking that they are compatible with the uniform distance. -/\n\n\nvariable {\ud835\udd5c : Type _}\n\nvariable [TopologicalSpace \u03b1] [SeminormedAddCommGroup \u03b2]\n\nvariable {f g : \u03b1 \u2192\u1d47 \u03b2} {x : \u03b1} {C : \u211d}\n\ninstance [NormedField \ud835\udd5c] [NormedSpace \ud835\udd5c \u03b2] : NormedSpace \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8fun 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 _))\u27e9\n\nvariable [NontriviallyNormedField \ud835\udd5c] [NormedSpace \ud835\udd5c \u03b2]\n\nvariable [SeminormedAddCommGroup \u03b3] [NormedSpace \ud835\udd5c \u03b3]\n\nvariable (\u03b1)\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 : \u03b2 \u2192L[\ud835\udd5c] \u03b3) :\n    (\u03b1 \u2192\u1d47 \u03b2) \u2192L[\ud835\udd5c] \u03b1 \u2192\u1d47 \u03b3 :=\n  LinearMap.mkContinuous\n    { toFun := fun f =>\n        ofNormedAddCommGroup (g \u2218 f) (g.Continuous.comp f.Continuous) (\u2016g\u2016 * \u2016f\u2016) 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 } \u2016g\u2016 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 : \u03b2 \u2192L[\ud835\udd5c] \u03b3) (f : \u03b1 \u2192\u1d47 \u03b2) (x : \u03b1) :\n    (g.compLeftContinuousBounded \u03b1 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 `\u03b1` 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 \u03b1] {R : Type _}\n\nsection NonUnital\n\nsection SemiNormed\n\nvariable [NonUnitalSeminormedRing R]\n\ninstance : Mul (\u03b1 \u2192\u1d47 R)\n    where mul f g :=\n    ofNormedAddCommGroup (f * g) (f.Continuous.mul g.Continuous) (\u2016f\u2016 * \u2016g\u2016) 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 : \u03b1 \u2192\u1d47 R) : \u21d1(f * g) = f * g :=\n  rfl\n#align bounded_continuous_function.coe_mul BoundedContinuousFunction.coe_mul\n\ntheorem mul_apply (f g : \u03b1 \u2192\u1d47 R) (x : \u03b1) : (f * g) x = f x * g x :=\n  rfl\n#align bounded_continuous_function.mul_apply BoundedContinuousFunction.mul_apply\n\ninstance : NonUnitalRing (\u03b1 \u2192\u1d47 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 (\u03b1 \u2192\u1d47 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 (\u03b1 \u2192\u1d47 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 : \u03b1 \u2192\u1d47 R) : \u2200 n, \u21d1(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 (\u03b1 \u2192\u1d47 R) \u2115\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 : \u2115) (f : \u03b1 \u2192\u1d47 R) : \u21d1(f ^ n) = f ^ n :=\n  rfl\n#align bounded_continuous_function.coe_pow BoundedContinuousFunction.coe_pow\n\n@[simp]\ntheorem pow_apply (n : \u2115) (f : \u03b1 \u2192\u1d47 R) (v : \u03b1) : (f ^ n) v = f v ^ n :=\n  rfl\n#align bounded_continuous_function.pow_apply BoundedContinuousFunction.pow_apply\n\ninstance : NatCast (\u03b1 \u2192\u1d47 R) :=\n  \u27e8fun n => BoundedContinuousFunction.const _ n\u27e9\n\n@[simp, norm_cast]\ntheorem coe_nat_cast (n : \u2115) : ((n : \u03b1 \u2192\u1d47 R) : \u03b1 \u2192 R) = n :=\n  rfl\n#align bounded_continuous_function.coe_nat_cast BoundedContinuousFunction.coe_nat_cast\n\ninstance : IntCast (\u03b1 \u2192\u1d47 R) :=\n  \u27e8fun n => BoundedContinuousFunction.const _ n\u27e9\n\n@[simp, norm_cast]\ntheorem coe_int_cast (n : \u2124) : ((n : \u03b1 \u2192\u1d47 R) : \u03b1 \u2192 R) = n :=\n  rfl\n#align bounded_continuous_function.coe_int_cast BoundedContinuousFunction.coe_int_cast\n\ninstance : Ring (\u03b1 \u2192\u1d47 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 (\u03b1 \u2192\u1d47 R) :=\n  { BoundedContinuousFunction.nonUnitalSemiNormedRing with }\n\nend SemiNormed\n\ninstance [NormedRing R] : NormedRing (\u03b1 \u2192\u1d47 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 `\u03b1` 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 \u03b1] {R : Type _}\n\ninstance [SeminormedCommRing R] : CommRing (\u03b1 \u2192\u1d47 R) :=\n  { BoundedContinuousFunction.ring with mul_comm := fun f\u2081 f\u2082 => ext fun x => mul_comm _ _ }\n\ninstance [SeminormedCommRing R] : SeminormedCommRing (\u03b1 \u2192\u1d47 R) :=\n  { BoundedContinuousFunction.commRing, BoundedContinuousFunction.seminormedAddCommGroup with }\n\ninstance [NormedCommRing R] : NormedCommRing (\u03b1 \u2192\u1d47 R) :=\n  { BoundedContinuousFunction.commRing, BoundedContinuousFunction.normedAddCommGroup with }\n\nend NormedCommRing\n\nsection NormedAlgebra\n\n/-!\n### Normed algebra structure\n\nIn this section, if `\u03b3` is a normed algebra, then we show that the space of bounded\ncontinuous functions from `\u03b1` to `\u03b3` inherits a normed algebra structure, by using\npointwise operations and checking that they are compatible with the uniform distance. -/\n\n\nvariable {\ud835\udd5c : Type _} [NormedField \ud835\udd5c]\n\nvariable [TopologicalSpace \u03b1] [SeminormedAddCommGroup \u03b2] [NormedSpace \ud835\udd5c \u03b2]\n\nvariable [NormedRing \u03b3] [NormedAlgebra \ud835\udd5c \u03b3]\n\nvariable {f g : \u03b1 \u2192\u1d47 \u03b3} {x : \u03b1} {c : \ud835\udd5c}\n\n/-- `bounded_continuous_function.const` as a `ring_hom`. -/\ndef c : \ud835\udd5c \u2192+* \u03b1 \u2192\u1d47 \u03b3 where\n  toFun := fun c : \ud835\udd5c => const \u03b1 ((algebraMap \ud835\udd5c \u03b3) c)\n  map_one' := ext fun x => (algebraMap \ud835\udd5c \u03b3).map_one\n  map_mul' c\u2081 c\u2082 := ext fun x => (algebraMap \ud835\udd5c \u03b3).map_mul _ _\n  map_zero' := ext fun x => (algebraMap \ud835\udd5c \u03b3).map_zero\n  map_add' c\u2081 c\u2082 := ext fun x => (algebraMap \ud835\udd5c \u03b3).map_add _ _\n#align bounded_continuous_function.C BoundedContinuousFunction.c\n\ninstance : Algebra \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b3) :=\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 : \ud835\udd5c) (a : \u03b1) : algebraMap \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b3) k a = k \u2022 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 \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b3) :=\n  { BoundedContinuousFunction.normedSpace with }\n\n/-!\n### Structure as normed module over scalar functions\n\nIf `\u03b2` is a normed `\ud835\udd5c`-space, then we show that the space of bounded continuous\nfunctions from `\u03b1` to `\u03b2` is naturally a module over the algebra of bounded continuous\nfunctions from `\u03b1` to `\ud835\udd5c`. -/\n\n\ninstance hasSmul' : SMul (\u03b1 \u2192\u1d47 \ud835\udd5c) (\u03b1 \u2192\u1d47 \u03b2) :=\n  \u27e8fun (f : \u03b1 \u2192\u1d47 \ud835\udd5c) (g : \u03b1 \u2192\u1d47 \u03b2) =>\n    ofNormedAddCommGroup (fun x => f x \u2022 g x) (f.Continuous.smul g.Continuous) (\u2016f\u2016 * \u2016g\u2016) fun x =>\n      calc\n        \u2016f x \u2022 g x\u2016 \u2264 \u2016f x\u2016 * \u2016g x\u2016 := norm_smul_le _ _\n        _ \u2264 \u2016f\u2016 * \u2016g\u2016 :=\n          mul_le_mul (f.norm_coe_le_norm _) (g.norm_coe_le_norm _) (norm_nonneg _) (norm_nonneg _)\n        \u27e9\n#align bounded_continuous_function.has_smul' BoundedContinuousFunction.hasSmul'\n\ninstance module' : Module (\u03b1 \u2192\u1d47 \ud835\udd5c) (\u03b1 \u2192\u1d47 \u03b2) :=\n  Module.ofCore <|\n    { smul := (\u00b7 \u2022 \u00b7)\n      smul_add := fun c f\u2081 f\u2082 => ext fun x => smul_add _ _ _\n      add_smul := fun c\u2081 c\u2082 f => ext fun x => add_smul _ _ _\n      mul_smul := fun c\u2081 c\u2082 f => ext fun x => mul_smul _ _ _\n      one_smul := fun f => ext fun x => one_smul \ud835\udd5c (f x) }\n#align bounded_continuous_function.module' BoundedContinuousFunction.module'\n\ntheorem norm_smul_le (f : \u03b1 \u2192\u1d47 \ud835\udd5c) (g : \u03b1 \u2192\u1d47 \u03b2) : \u2016f \u2022 g\u2016 \u2264 \u2016f\u2016 * \u2016g\u2016 :=\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 `\u03b1` to `\u03b2` is naturally a normed\nmodule over the algebra of bounded continuous functions from `\u03b1` to `\ud835\udd5c`. -/\nend NormedAlgebra\n\ntheorem Nnreal.upper_bound {\u03b1 : Type _} [TopologicalSpace \u03b1] (f : \u03b1 \u2192\u1d47 \u211d\u22650) (x : \u03b1) :\n    f x \u2264 nndist f 0 :=\n  by\n  have key : nndist (f x) ((0 : \u03b1 \u2192\u1d47 \u211d\u22650) x) \u2264 nndist f 0 := @dist_coe_le_dist \u03b1 \u211d\u22650 _ _ 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 `\u03b2` is a normed \u22c6-group, then so is the space of bounded\ncontinuous functions from `\u03b1` to `\u03b2`, by using the star operation pointwise.\n\nIf `\ud835\udd5c` is normed field and a \u22c6-ring over which `\u03b2` is a normed algebra and a\nstar module, then the space of bounded continuous functions from `\u03b1` to `\u03b2`\nis a star module.\n\nIf `\u03b2` is a \u22c6-ring in addition to being a normed \u22c6-group, then `\u03b1 \u2192\u1d47 \u03b2`\ninherits a \u22c6-ring structure.\n\nIn summary, if `\u03b2` is a C\u22c6-algebra over `\ud835\udd5c`, then so is  `\u03b1 \u2192\u1d47 \u03b2`; note that\ncompleteness is guaranteed when `\u03b2` is complete (see\n`bounded_continuous_function.complete`). -/\n\n\nsection NormedAddCommGroup\n\nvariable {\ud835\udd5c : Type _} [NormedField \ud835\udd5c] [StarRing \ud835\udd5c] [TopologicalSpace \u03b1] [SeminormedAddCommGroup \u03b2]\n  [StarAddMonoid \u03b2] [NormedStarGroup \u03b2]\n\nvariable [NormedSpace \ud835\udd5c \u03b2] [StarModule \ud835\udd5c \u03b2]\n\ninstance : StarAddMonoid (\u03b1 \u2192\u1d47 \u03b2)\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 \u2218 \u21d1f` because of the\ninstance `pi.has_star`. Upon inspecting the goal, one sees `\u22a2 \u21d1(star f) = star \u21d1f`.-/\n@[simp]\ntheorem coe_star (f : \u03b1 \u2192\u1d47 \u03b2) : \u21d1(star f) = star f :=\n  rfl\n#align bounded_continuous_function.coe_star BoundedContinuousFunction.coe_star\n\n@[simp]\ntheorem star_apply (f : \u03b1 \u2192\u1d47 \u03b2) (x : \u03b1) : star f x = star (f x) :=\n  rfl\n#align bounded_continuous_function.star_apply BoundedContinuousFunction.star_apply\n\ninstance : NormedStarGroup (\u03b1 \u2192\u1d47 \u03b2)\n    where norm_star f := by simp only [norm_eq, star_apply, norm_star]\n\ninstance : StarModule \ud835\udd5c (\u03b1 \u2192\u1d47 \u03b2) where star_smul k f := ext fun x => star_smul k (f x)\n\nend NormedAddCommGroup\n\nsection CstarRing\n\nvariable [TopologicalSpace \u03b1]\n\nvariable [NonUnitalNormedRing \u03b2] [StarRing \u03b2]\n\ninstance [NormedStarGroup \u03b2] : StarRing (\u03b1 \u2192\u1d47 \u03b2) :=\n  { BoundedContinuousFunction.starAddMonoid with\n    star_mul := fun f g => ext fun x => star_mul (f x) (g x) }\n\nvariable [CstarRing \u03b2]\n\ninstance : CstarRing (\u03b1 \u2192\u1d47 \u03b2)\n    where norm_star_mul_self := by\n    intro f\n    refine' le_antisymm _ _\n    \u00b7 rw [\u2190 sq, norm_le (sq_nonneg _)]\n      dsimp [star_apply]\n      intro x\n      rw [CstarRing.norm_star_mul_self, \u2190 sq]\n      refine' sq_le_sq' _ _\n      \u00b7 linarith [norm_nonneg (f x), norm_nonneg f]\n      \u00b7 exact norm_coe_le_norm f x\n    \u00b7 rw [\u2190 sq, \u2190 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, \u2190 CstarRing.norm_star_mul_self]\n      exact norm_coe_le_norm (star f * f) x\n\nend CstarRing\n\nsection NormedLatticeOrderedGroup\n\nvariable [TopologicalSpace \u03b1] [NormedLatticeAddCommGroup \u03b2]\n\ninstance : PartialOrder (\u03b1 \u2192\u1d47 \u03b2) :=\n  PartialOrder.lift (fun f => f.toFun) (by tidy)\n\n/-- Continuous normed lattice group valued functions form a meet-semilattice\n-/\ninstance : SemilatticeInf (\u03b1 \u2192\u1d47 \u03b2) :=\n  {\n    BoundedContinuousFunction.partialOrder with\n    inf := fun f g =>\n      { toFun := fun t => f t \u2293 g t\n        continuous_toFun := f.Continuous.inf g.Continuous\n        map_bounded' := by\n          obtain \u27e8C\u2081, hf\u27e9 := f.bounded\n          obtain \u27e8C\u2082, hg\u27e9 := g.bounded\n          refine' \u27e8C\u2081 + C\u2082, fun x y => _\u27e9\n          simp_rw [NormedAddCommGroup.dist_eq] at hf hg\u22a2\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\u2081 g\u2082 w\u2081 w\u2082 =>\n      ContinuousMap.le_def.mpr fun _ =>\n        le_inf (ContinuousMap.le_def.mp w\u2081 _) (ContinuousMap.le_def.mp w\u2082 _) }\n\ninstance : SemilatticeSup (\u03b1 \u2192\u1d47 \u03b2) :=\n  {\n    BoundedContinuousFunction.partialOrder with\n    sup := fun f g =>\n      { toFun := fun t => f t \u2294 g t\n        continuous_toFun := f.Continuous.sup g.Continuous\n        map_bounded' := by\n          obtain \u27e8C\u2081, hf\u27e9 := f.bounded\n          obtain \u27e8C\u2082, hg\u27e9 := g.bounded\n          refine' \u27e8C\u2081 + C\u2082, fun x y => _\u27e9\n          simp_rw [NormedAddCommGroup.dist_eq] at hf hg\u22a2\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\u2081 g\u2082 w\u2081 w\u2082 =>\n      ContinuousMap.le_def.mpr fun _ =>\n        sup_le (ContinuousMap.le_def.mp w\u2081 _) (ContinuousMap.le_def.mp w\u2082 _) }\n\ninstance : Lattice (\u03b1 \u2192\u1d47 \u03b2) :=\n  { BoundedContinuousFunction.semilatticeSup, BoundedContinuousFunction.semilatticeInf with }\n\n@[simp]\ntheorem coeFn_sup (f g : \u03b1 \u2192\u1d47 \u03b2) : \u21d1(f \u2294 g) = f \u2294 g :=\n  rfl\n#align bounded_continuous_function.coe_fn_sup BoundedContinuousFunction.coeFn_sup\n\n@[simp]\ntheorem coeFn_abs (f : \u03b1 \u2192\u1d47 \u03b2) : \u21d1(|f|) = |f| :=\n  rfl\n#align bounded_continuous_function.coe_fn_abs BoundedContinuousFunction.coeFn_abs\n\ninstance : NormedLatticeAddCommGroup (\u03b1 \u2192\u1d47 \u03b2) :=\n  { BoundedContinuousFunction.lattice,\n    BoundedContinuousFunction.seminormedAddCommGroup with\n    add_le_add_left := by\n      intro f g h\u2081 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\u2081 _\n    solid := by\n      intro f g h\n      have i1 : \u2200 t, \u2016f t\u2016 \u2264 \u2016g t\u2016 := 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 \u03b1]\n\n/-- The nonnegative part of a bounded continuous `\u211d`-valued function as a bounded\ncontinuous `\u211d\u22650`-valued function. -/\ndef nnrealPart (f : \u03b1 \u2192\u1d47 \u211d) : \u03b1 \u2192\u1d47 \u211d\u22650 :=\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 : \u03b1 \u2192\u1d47 \u211d) : \u21d1f.nnrealPart = Real.toNNReal \u2218 \u21d1f :=\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 `\u211d`-valued function as a bounded\ncontinuous `\u211d\u22650`-valued function. -/\ndef nnnorm (f : \u03b1 \u2192\u1d47 \u211d) : \u03b1 \u2192\u1d47 \u211d\u22650 :=\n  BoundedContinuousFunction.comp _\n    (show LipschitzWith 1 fun x : \u211d => \u2016x\u2016\u208a from lipschitzWith_one_norm) f\n#align bounded_continuous_function.nnnorm BoundedContinuousFunction.nnnorm\n\n@[simp]\ntheorem nnnorm_coe_fun_eq (f : \u03b1 \u2192\u1d47 \u211d) : \u21d1f.nnnorm = NNNorm.nnnorm \u2218 \u21d1f :=\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 : \u03b1 \u2192\u1d47 \u211d) :\n    \u21d1f = coe \u2218 f.nnrealPart - coe \u2218 (-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 : \u03b1 \u2192\u1d47 \u211d) :\n    abs \u2218 \u21d1f = coe \u2218 f.nnrealPart + coe \u2218 (-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 {\u03b1 : Type} {p q r: \u03b1 \u2192 Prop} : \n(\u2203! a : \u03b1, r a \u2227 p a \u2227 q a) \u2192 \u2203! a : \u03b1, r a \u2227 q a \u2227 p a :=\n    \u03bb \u27e8a, \u27e8b, c \u27e9\u27e9, \n    begin \n        existsi a,\n        simp at *,\n        exact \u27e8b.symm.2, b.symm.1.1 ,b.symm.1.2 ,\u03bb y g h, c y g h\u27e9 \n    end\n\n-- Categories and functors\n\nstructure Category (type : Type) :=\n(obj : type \u2192 Prop)\n(mor : type  \u2192 type \u2192 (type \u2192 type) \u2192 Prop)\n(associativity : \u2200 a b c, \u2200 f g : type \u2192 type, mor a b f \u2192 mor b c g \u2192 mor a c (g \u2218 f))\n(identity: \u2200 a, obj a \u2192 mor a a id)\n\nstructure Functor {a b : Type} (C1: Category a) (C2: Category b) : Type :=\n(obj_map: a \u2192 b)\n(mor_map: (a \u2192 a) \u2192 (b \u2192 b))\n(respect_obj: \u2200 x, C1.obj x \u2192 C2.obj (obj_map x))\n(respect_id : mor_map id = id)\n(respect_mor: \u2200 x y z, C1.mor x y z \u2192  C2.mor (obj_map x) (obj_map y) (mor_map z))\n(respect_composition: \u2200 f g: a \u2192 a, mor_map (f \u2218 g) = mor_map f \u2218 mor_map g)\n\nstructure Contravariant_Functor {a b : Type} (C1: Category a) (C2: Category b) : Type :=\n(obj_map: a \u2192 b)\n(mor_map: (a \u2192 a) \u2192 (b \u2192 b))\n(respect_obj: \u2200 x, C1.obj x \u2192 C2.obj (obj_map x))\n(respect_id : mor_map id = id)\n(swap_mor: \u2200 x y z, C1.mor x y z \u2192  C2.mor (obj_map y) (obj_map x) (mor_map z))\n(respect_composition: \u2200 f g: a \u2192 a, mor_map (f \u2218 g) = mor_map g \u2218 mor_map f)\n\n-- Notions of isomorphims\n\ndefinition isomorphism {a: Type} (x : Category a) (f: a \u2192 a) (b c: a)\n    := \u2203 g : a \u2192 a, f \u2218 g = id \u2227 g \u2218 f = id \u2227 x.mor b c f \u2227 x.mor c b g\n\ndefinition isomorphic {a: Type} (x : Category a) (b c : a) \n    := \u2203 f : a \u2192 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: \u2200 f: a \u2192 a, \u2203 b c: a, x.obj b \u2227 x.obj c \u2227 isomorphism x f b c)\n\nstructure Monoid (a: Type) extends x : Category a :=\n(singleton : a)\n(monoid : \u2200 c : a, obj c \u2194 c = singleton)\n\nstructure Group (a: Type) extends Monoid a :=\n(isomorphisms: \u2200 f: a \u2192 a, \u2203 b c: a, x.obj b \u2227 x.obj c \u2227 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 \u2227 \u2200 b : t, c.obj b \u2192 \u2203! f : t \u2192 t, c.mor a b f\n\ndefinition terminal_object {t: Type} (c : Category t) (a: t) \n    := c.obj a \u2227 \u2200 b : t, c.obj b \u2192 \u2203! f : t \u2192 t, c.mor b a f\n\ndefinition zero_object {t: Type} (c : Category t) (a: t)\n    := c.obj a \u2227 initial_object c a \u2227 terminal_object c a\n\n-- Lemmas for uniqueness of zero, terminal and initial objects up to isomorphism\n\nlemma unique_initial {t: Type } : \u2200 c : Category t, \u2200 a b: t, initial_object c a \u2227 initial_object c b \u2192 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\u2218a_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\u2218a_1 = a_5, from a_6.2 (a_3\u2218a_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\u2218a_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\u2218a_3 = a_5, from a_7.2 (a_1\u2218a_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 } : \u2200 c : Category t, \u2200 a b: t, terminal_object c a \u2227 terminal_object c b \u2192 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\u2218a_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\u2218a_1 = a_5, from a_6.2 (a_3\u2218a_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\u2218a_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\u2218a_3 = a_5, from a_7.2 (a_1\u2218a_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 \u27e8a_2.1, a_4.1\u27e9 \nend\n\nlemma unique_zero {t: Type } : \u2200 c : Category t, \u2200 a b: t, zero_object c a \u2227 zero_object c b \u2192 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 \u2192 (S \u2192 S))\n(commutes : \u2200 a b f, A.mor a b f \u2192 (obj_assign a) \u2218 (U.mor_map f) = (V.mor_map f) \u2218 (obj_assign b) )\n(existence : \u2200 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 \u2192 t)\n    := A.mor a b f \u2227 (\u2200 m g h, A.mor m a g \u2227 A.mor m a h \u2227 (f \u2218 g) = (f \u2218 h) \u2192 g = h) \n\ndefinition epimorphism {t : Type} {A : Category t} (a b : t) (f : t \u2192 t)\n    := A.mor a b f \u2227 (\u2200 m g h, A.mor b m g \u2227 A.mor b m h \u2227 (g \u2218 f) = (h \u2218 f) \u2192 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 \u2192 t)\n    := A.obj a \u2227 A.obj b \u2227 A.obj p \u2227 A.mor p a f \u2227 A.mor p b g \u2227 \n    (\u2200 k m n, A.obj k \u2227 A.mor k a m \u2227 A.mor k b n \u2192 \u2203! u, A.mor k p u \u2227 g \u2218 u = n \u2227 f \u2218 u = m ) \n\ndefinition coproduct {t : Type} {A : Category t} (a b : t) (p : t) (f g: t \u2192 t)\n    := A.obj a \u2227 A.obj b \u2227 A.obj p \u2227 A.mor a p f \u2227 A.mor b p g \u2227 \n    (\u2200 k m n, A.obj k \u2227 A.mor a k m \u2227 A.mor b k n \u2192 \u2203! u, A.mor p k u \u2227 u \u2218 g = n \u2227 u \u2218 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 \u2192 t) : @product t A a b p f g \u2192 @product t A b a p g f :=\nbegin\nintros,\nunfold product at a_1,\nunfold product,\nhave H: (\u2200 k m n, A.obj k \u2227 A.mor k b m \u2227 A.mor k a n \u2192 \u2203! u, A.mor k p u \u2227 f \u2218 u = n \u2227 g \u2218 u = m ),\n    from ( begin\n        intros,\n        let X := a_1.2.2.2.2.2 k n m,\n        let X2 := X (\u27e8a_2.1, a_2.2.2, a_2.2.1\u27e9),\n        apply exists_and_commute,\n        exact X2\n    end ),\nexact \u27e8a_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\u27e9 \nend\n\nlemma coproduct_commutes {t : Type} {A : Category t} (a b : t) (p : t) (f g: t \u2192 t) : @coproduct t A a b p f g \u2192 @coproduct t A b a p g f :=\nbegin\nintros,\nunfold coproduct at a_1,\nunfold coproduct,\nhave H: (\u2200 k m n, A.obj k \u2227 A.mor b k m \u2227 A.mor a k n \u2192 \u2203! u, A.mor p k u \u2227 u \u2218 f = n \u2227 u \u2218 g = m ),\n    from ( begin\n        intros,\n        let X := a_1.2.2.2.2.2 k n m,\n        let X2 := X (\u27e8a_2.1, a_2.2.2, a_2.2.1\u27e9),\n        apply exists_and_commute,\n        exact X2\n    end ),\nexact \u27e8a_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\u27e9 \nend\n\n-- Equalizers and co-equalizers\n\ndefinition equalizer {t : Type} {A : Category t} (f g h: t \u2192 t) (a b c: t)\n    := A.obj a \u2227 A.obj b \u2227 A.obj c \u2227 A.mor b c g  \u2227 A.mor b c h  \u2227 A.mor a b f \n    \u2227 g \u2218 f = h \u2218 f \u2227 (\u2200 x m, A.mor x b m \u2227 g \u2218 m = h \u2218 m \u2192 \u2203! u, A.mor x a u \n    \u2227 f \u2218 u = m) \n\ndefinition coequalizer {t : Type} {A : Category t} (f g h: t \u2192 t) (a b c: t)\n    := A.obj a \u2227 A.obj b \u2227 A.obj c \u2227 A.mor a b g  \u2227 A.mor a b h  \u2227 A.mor b c f \n    \u2227 f \u2218 g = f \u2218 h \u2227 (\u2200 x m, A.mor b x m \u2227 m \u2218 g = m \u2218 h \u2192 \u2203! u, A.mor c x u \n    \u2227 u \u2218 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 \u2192 set A) {x : Category (set A)} \n    := x.mor a b c \u2194 c = id \u2227 a \u2282 b \n\ndefinition open_category {a: Type} (t : topological_space a) : Category (set a) :=\n{\n    obj := t.is_open,\n    mor := \u03bb A B: set a, \u03bb C: set a \u2192 set a, C = id \u2227 A \u2286 B,\n    associativity := \u03bb a b c, \u03bb f g , begin\n        intros h1 h2,\n        split,\n        rw [h1.1, h2.1], \n        apply id.def,\n        exact \u03bb x hx, (h2.2 (h1.2 hx))\n    end,\n    identity := \u03bb a, begin\n        split,\n        simp,\n        exact \u03bb x hx, hx\n    end\n}\n\ndefinition open_Cover {a : Type} (T: topological_space a) (t: set a) (s : set (set a))\n    := \u22c3\u2080 s = t \u2227 \u2200 b \u2208 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 := \u2200 g s, open_Cover t g s \u2192 \u2200 x y, \u2200 f h, c.mor (obj_map y) (obj_map (x \u2229 y)) f\n \u2192 c.mor (obj_map x) (obj_map (x \u2229 y)) h \u2192 f (obj_map y) = h (obj_map x) \u2192 \u2203 n:b, n = (obj_map g) \u2192\n   \u2200 l \u2208 s, \u2200 e, c.mor n (obj_map l) e \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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/-- `\u03b1 \u21aa \u03b2` is a bundled injective function. -/\nstructure Embedding (\u03b1 : Sort _) (\u03b2 : Sort _) where\n  /-- An embedding as a function. Use coercion instead. -/\n  toFun : \u03b1 \u2192 \u03b2\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 \" \u21aa \" => Embedding\n\ninstance {\u03b1 : Sort u} {\u03b2 : Sort v} : EmbeddingLike (\u03b1 \u21aa \u03b2) \u03b1 \u03b2 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 \u2192 apply)\n\n-- porting note: this needs `tactic.lift`.\n--instance {\u03b1 \u03b2 : Sort _} : CanLift (\u03b1 \u2192 \u03b2) (\u03b1 \u21aa \u03b2) coeFn Injective where prf f hf := \u27e8\u27e8f, hf\u27e9, rfl\u27e9\n\nend Function\n\nsection Equiv\n\nvariable {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2243 \u03b2)\n\n/-- Convert an `\u03b1 \u2243 \u03b2` to `\u03b1 \u21aa \u03b2`.\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 \u2243 Fin 3` but is expected to have type `Fin 3 \u21aa ?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 : \u03b1 \u21aa \u03b2 :=\n  \u27e8f, f.injective\u27e9\n#align equiv.to_embedding Equiv.toEmbedding\n\n@[simp]\ntheorem Equiv.coe_toEmbedding : (f.toEmbedding : \u03b1 \u2192 \u03b2) = f :=\n  rfl\n#align equiv.coe_to_embedding Equiv.coe_toEmbedding\n\ntheorem Equiv.toEmbedding_apply (a : \u03b1) : f.toEmbedding a = f a :=\n  rfl\n#align equiv.to_embedding_apply Equiv.toEmbedding_apply\n\ninstance Equiv.coeEmbedding : Coe (\u03b1 \u2243 \u03b2) (\u03b1 \u21aa \u03b2) :=\n  \u27e8Equiv.toEmbedding\u27e9\n#align equiv.coe_embedding Equiv.coeEmbedding\n\n@[reducible]\ninstance Equiv.Perm.coeEmbedding : Coe (Equiv.Perm \u03b1) (\u03b1 \u21aa \u03b1) :=\n  Equiv.coeEmbedding\n#align equiv.perm.coe_embedding Equiv.Perm.coeEmbedding\n\n-- port note : `theorem Equiv.coe_eq_to_embedding : \u2191f = f.toEmbedding` is a\n-- syntactic tautology in Lean 4\n\nend Equiv\n\nnamespace Function\n\nnamespace Embedding\n\ntheorem coe_injective {\u03b1 \u03b2} : @Injective (\u03b1 \u21aa \u03b2) (\u03b1 \u2192 \u03b2) (\u03bb f => \u2191f) :=\n  FunLike.coe_injective\n#align function.embedding.coe_injective Function.Embedding.coe_injective\n\n@[ext]\ntheorem ext {\u03b1 \u03b2} {f g : Embedding \u03b1 \u03b2} (h : \u2200 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 {\u03b1 \u03b2} {f g : Embedding \u03b1 \u03b2} : (\u2200 x, f x = g x) \u2194 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 {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) : toFun f = f :=\n  rfl\n#align function.embedding.to_fun_eq_coe Function.Embedding.toFun_eq_coe\n\n@[simp]\ntheorem coeFn_mk {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (i) : (@mk _ _ f i : \u03b1 \u2192 \u03b2) = f :=\n  rfl\n#align function.embedding.coe_fn_mk Function.Embedding.coeFn_mk\n\n@[simp]\ntheorem mk_coe {\u03b1 \u03b2 : Type _} (f : \u03b1 \u21aa \u03b2) (inj) : (\u27e8f, inj\u27e9 : \u03b1 \u21aa \u03b2) = f :=\n  rfl\n#align function.embedding.mk_coe Function.Embedding.mk_coe\n\nprotected theorem injective {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) : Injective f :=\n  EmbeddingLike.injective f\n#align function.embedding.injective Function.Embedding.injective\n\ntheorem apply_eq_iff_eq {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) (x y : \u03b1) : f x = f y \u2194 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 (\u03b1 : Sort _) : \u03b1 \u21aa \u03b1 :=\n  \u27e8id, injective_id\u27e9\n#align function.embedding.refl Function.Embedding.refl\n#align function.embedding.refl_apply Function.Embedding.refl_apply\n\n/-- Composition of `f : \u03b1 \u21aa \u03b2` and `g : \u03b2 \u21aa \u03b3`. -/\n@[trans, simps (config := { simpRhs := true })]\nprotected def trans {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u21aa \u03b2) (g : \u03b2 \u21aa \u03b3) : \u03b1 \u21aa \u03b3 :=\n  \u27e8g \u2218 f, g.injective.comp f.injective\u27e9\n#align function.embedding.trans Function.Embedding.trans\n#align function.embedding.trans_apply Function.Embedding.trans_apply\n\ninstance : Trans Embedding Embedding Embedding := \u27e8Embedding.trans\u27e9\n\n@[simp]\ntheorem equiv_toEmbedding_trans_symm_toEmbedding {\u03b1 \u03b2 : Sort _} (e : \u03b1 \u2243 \u03b2) :\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 {\u03b1 \u03b2 : Sort _} (e : \u03b1 \u2243 \u03b2) :\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 {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {\u03b4 : Sort x} (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b3 \u2243 \u03b4)\n    (f : \u03b1 \u21aa \u03b3) : \u03b2 \u21aa \u03b4 :=\n  (Equiv.toEmbedding e\u2081.symm).trans (f.trans e\u2082.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 {\u03b1 \u03b2} (f : \u03b2 \u2192 \u03b1) (hf : Surjective f) : \u03b1 \u21aa \u03b2 :=\n  \u27e8surjInv hf, injective_surjInv _\u27e9\n#align function.embedding.of_surjective Function.Embedding.ofSurjective\n\n/-- Convert a surjective `Embedding` to an `Equiv` -/\nprotected noncomputable def equivOfSurjective {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) (hf : Surjective f) : \u03b1 \u2243 \u03b2 :=\n  Equiv.ofBijective f \u27e8f.injective, hf\u27e9\n#align function.embedding.equiv_of_surjective Function.Embedding.equivOfSurjective\n\n/-- There is always an embedding from an empty type. -/\nprotected def ofIsEmpty {\u03b1 \u03b2} [IsEmpty \u03b1] : \u03b1 \u21aa \u03b2 :=\n  \u27e8isEmptyElim, isEmptyElim\u27e9\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 {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) (a : \u03b1) (b : \u03b2) [\u2200 a', Decidable (a' = a)]\n    [\u2200 a', Decidable (f a' = b)] : \u03b1 \u21aa \u03b2 :=\n  \u27e8fun 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\u2081 h\u2082 _ _ h\u2085 h\u2086 <;>\n        (try subst b) <;>\n        (try simp only [f.injective.eq_iff] at *)\n    \u00b7 rw[h\u2081,h\u2082]\n    \u00b7 rw[h\u2081,h]\n    \u00b7 rw[h\u2085,\u2190h]\n    \u00b7 exact h\u2086.symm\n    \u00b7 exfalso; exact h\u2085 h.symm\n    \u00b7 exfalso; exact h\u2081 h\n    \u00b7 exact h \u27e9\n#align function.embedding.set_value Function.Embedding.setValue\n\ntheorem setValue_eq {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) (a : \u03b1) (b : \u03b2) [\u2200 a', Decidable (a' = a)]\n    [\u2200 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 \u03b1` using `some`. -/\n@[simps (config := { fullyApplied := false })]\nprotected def some {\u03b1} : \u03b1 \u21aa Option \u03b1 :=\n  \u27e8some, Option.some_injective \u03b1\u27e9\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 `\u03b1 \u2192 Option \u03b1` 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 {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) : Option \u03b1 \u21aa Option \u03b2 :=\n  \u27e8Option.map f, Option.map_injective f.injective\u27e9\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 {\u03b1} (p : \u03b1 \u2192 Prop) : Subtype p \u21aa \u03b1 :=\n  \u27e8Subtype.val, fun _ _ => Subtype.ext\u27e9\n#align function.embedding.subtype Function.Embedding.subtype\n\n@[simp]\ntheorem coe_subtype {\u03b1} (p : \u03b1 \u2192 Prop) : \u2191(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 (\u03b1) [s : Setoid \u03b1] : Quotient s \u21aa \u03b1 :=\n  \u27e8_, Quotient.out_injective\u27e9\n#align function.embedding.quotient_out Function.Embedding.quotientOut\n\n@[simp]\ntheorem coe_quotientOut (\u03b1) [Setoid \u03b1] : \u2191(quotientOut \u03b1) = Quotient.out :=\n  rfl\n#align function.embedding.coe_quotient_out Function.Embedding.coe_quotientOut\n\n/-- Choosing an element `b : \u03b2` gives an embedding of `punit` into `\u03b2`. -/\ndef punit {\u03b2 : Sort _} (b : \u03b2) : PUnit \u21aa \u03b2 :=\n  \u27e8fun _ => b, by\n    rintro \u27e8\u27e9 \u27e8\u27e9 _\n    rfl\u27e9\n#align function.embedding.punit Function.Embedding.punit\n\n/-- Fixing an element `b : \u03b2` gives an embedding `\u03b1 \u21aa \u03b1 \u00d7 \u03b2`. -/\n@[simps]\ndef sectl (\u03b1 : Sort _) {\u03b2 : Sort _} (b : \u03b2) : \u03b1 \u21aa \u03b1 \u00d7 \u03b2 :=\n  \u27e8fun a => (a, b), fun _ _ h => congr_arg Prod.fst h\u27e9\n#align function.embedding.sectl Function.Embedding.sectl\n#align function.embedding.sectl_apply Function.Embedding.sectl_apply\n\n/-- Fixing an element `a : \u03b1` gives an embedding `\u03b2 \u21aa \u03b1 \u00d7 \u03b2`. -/\n@[simps]\ndef sectr {\u03b1 : Sort _} (a : \u03b1) (\u03b2 : Sort _) : \u03b2 \u21aa \u03b1 \u00d7 \u03b2 :=\n  \u27e8fun b => (a, b), fun _ _ h => congr_arg Prod.snd h\u27e9\n#align function.embedding.sectr Function.Embedding.sectr\n#align function.embedding.sectr_apply Function.Embedding.sectr_apply\n\n/-- If `e\u2081` and `e\u2082` are embeddings, then so is `prod.map e\u2081 e\u2082 : (a, b) \u21a6 (e\u2081 a, e\u2082 b)`. -/\ndef prodMap {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) : \u03b1 \u00d7 \u03b3 \u21aa \u03b2 \u00d7 \u03b4 :=\n  \u27e8Prod.map e\u2081 e\u2082, e\u2081.injective.Prod_map e\u2082.injective\u27e9\n#align function.embedding.prod_map Function.Embedding.prodMap\n\n@[simp]\ntheorem coe_prodMap {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) :\n    e\u2081.prodMap e\u2082 = Prod.map e\u2081 e\u2082 :=\n  rfl\n#align function.embedding.coe_prod_map Function.Embedding.coe_prodMap\n\n/-- If `e\u2081` and `e\u2082` are embeddings, then so is `\u03bb \u27e8a, b\u27e9, \u27e8e\u2081 a, e\u2082 b\u27e9 : pprod \u03b1 \u03b3 \u2192 pprod \u03b2 \u03b4`. -/\ndef pprodMap {\u03b1 \u03b2 \u03b3 \u03b4 : Sort _} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) : PProd \u03b1 \u03b3 \u21aa PProd \u03b2 \u03b4 :=\n  \u27e8fun x => \u27e8e\u2081 x.1, e\u2082 x.2\u27e9, e\u2081.injective.pprod_map e\u2082.injective\u27e9\n#align function.embedding.pprod_map Function.Embedding.pprodMap\n\nsection Sum\n\nopen Sum\n\n/-- If `e\u2081` and `e\u2082` are embeddings, then so is `sum.map e\u2081 e\u2082`. -/\ndef sumMap {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) : Sum \u03b1 \u03b3 \u21aa Sum \u03b2 \u03b4 :=\n  \u27e8Sum.map e\u2081 e\u2082, e\u2081.injective.sum_map e\u2082.injective\u27e9\n#align function.embedding.sum_map Function.Embedding.sumMap\n\n@[simp]\ntheorem coe_sumMap {\u03b1 \u03b2 \u03b3 \u03b4} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) : sumMap e\u2081 e\u2082 = Sum.map e\u2081 e\u2082 :=\n  rfl\n#align function.embedding.coe_sum_map Function.Embedding.coe_sumMap\n\n/-- The embedding of `\u03b1` into the sum `\u03b1 \u2295 \u03b2`. -/\n@[simps]\ndef inl {\u03b1 \u03b2 : Type _} : \u03b1 \u21aa Sum \u03b1 \u03b2 :=\n  \u27e8Sum.inl, fun _ _ => Sum.inl.inj\u27e9\n#align function.embedding.inl Function.Embedding.inl\n#align function.embedding.inl_apply Function.Embedding.inl_apply\n\n/-- The embedding of `\u03b2` into the sum `\u03b1 \u2295 \u03b2`. -/\n@[simps]\ndef inr {\u03b1 \u03b2 : Type _} : \u03b2 \u21aa Sum \u03b1 \u03b2 :=\n  \u27e8Sum.inr, fun _ _ => Sum.inr.inj\u27e9\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 {\u03b1 \u03b1' : Type _} {\u03b2 : \u03b1 \u2192 Type _} {\u03b2' : \u03b1' \u2192 Type _}\n\n/-- `Sigma.mk` as an `Function.Embedding`. -/\n@[simps apply]\ndef sigmaMk (a : \u03b1) : \u03b2 a \u21aa \u03a3x, \u03b2 x :=\n  \u27e8Sigma.mk a, sigma_mk_injective\u27e9\n#align function.embedding.sigma_mk Function.Embedding.sigmaMk\n#align function.embedding.sigma_mk_apply Function.Embedding.sigmaMk_apply\n\n/-- If `f : \u03b1 \u21aa \u03b1'` is an embedding and `g : \u03a0 a, \u03b2 \u03b1 \u21aa \u03b2' (f \u03b1)` is a family\nof embeddings, then `Sigma.map f g` is an embedding. -/\n@[simps apply]\ndef sigmaMap (f : \u03b1 \u21aa \u03b1') (g : \u2200 a, \u03b2 a \u21aa \u03b2' (f a)) : (\u03a3a, \u03b2 a) \u21aa \u03a3a', \u03b2' a' :=\n  \u27e8Sigma.map f fun a => g a, f.injective.sigma_map fun a => (g a).injective\u27e9\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 `(\u03a0 a : \u03b1, \u03b2 a) \u21aa (\u03a0 a : \u03b1, \u03b3 a)` from a family of embeddings\n`e : \u03a0 a, (\u03b2 a \u21aa \u03b3 a)`. This embedding sends `f` to `\u03bb a, e a (f a)`. -/\n@[simps]\ndef piCongrRight {\u03b1 : Sort _} {\u03b2 \u03b3 : \u03b1 \u2192 Sort _} (e : \u2200 a, \u03b2 a \u21aa \u03b3 a) : (\u2200 a, \u03b2 a) \u21aa \u2200 a, \u03b3 a :=\n  \u27e8fun f a => e a (f a), fun _ _ h => funext fun a => (e a).injective (congr_fun h a)\u27e9\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 : \u03b1 \u21aa \u03b2` defines an embedding `(\u03b3 \u2192 \u03b1) \u21aa (\u03b3 \u2192 \u03b2)` that sends each `f`\nto `e \u2218 f`. -/\ndef arrowCongrRight {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (e : \u03b1 \u21aa \u03b2) : (\u03b3 \u2192 \u03b1) \u21aa \u03b3 \u2192 \u03b2 :=\n  piCongrRight fun _ => e\n#align function.embedding.arrow_congr_right Function.Embedding.arrowCongrRight\n\n@[simp]\ntheorem arrowCongrRight_apply {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (e : \u03b1 \u21aa \u03b2) (f : \u03b3 \u21aa \u03b1) :\n    arrowCongrRight e f = e \u2218 f :=\n  rfl\n#align function.embedding.arrow_congr_right_apply Function.Embedding.arrowCongrRight_apply\n\n/-- An embedding `e : \u03b1 \u21aa \u03b2` defines an embedding `(\u03b1 \u2192 \u03b3) \u21aa (\u03b2 \u2192 \u03b3)` for any inhabited type `\u03b3`.\nThis embedding sends each `f : \u03b1 \u2192 \u03b3` to a function `g : \u03b2 \u2192 \u03b3` such that `g \u2218 e = f` and\n`g y = default` whenever `y \u2209 range e`. -/\nnoncomputable def arrowCongrLeft {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} [Inhabited \u03b3] (e : \u03b1 \u21aa \u03b2) :\n    (\u03b1 \u2192 \u03b3) \u21aa \u03b2 \u2192 \u03b3 :=\n  \u27e8fun f => extend e f default, fun f\u2081 f\u2082 h =>\n    funext fun x => by simpa only [e.injective.extend_apply] using congr_fun h (e x)\u27e9\n#align function.embedding.arrow_congr_left Function.Embedding.arrowCongrLeft\n\n/-- Restrict both domain and codomain of an embedding. -/\nprotected def subtypeMap {\u03b1 \u03b2} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (f : \u03b1 \u21aa \u03b2)\n    (h : \u2200 \u2983x\u2984, p x \u2192 q (f x)) :\n    { x : \u03b1 // p x } \u21aa { y : \u03b2 // q y } :=\n  \u27e8Subtype.map f h, Subtype.map_injective h f.2\u27e9\n#align function.embedding.subtype_map Function.Embedding.subtypeMap\n\nopen Set\n\ntheorem swap_apply {\u03b1 \u03b2 : Type _} [DecidableEq \u03b1] [DecidableEq \u03b2] (f : \u03b1 \u21aa \u03b2) (x y z : \u03b1) :\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 {\u03b1 \u03b2 : Type _} [DecidableEq \u03b1] [DecidableEq \u03b2] (f : \u03b1 \u21aa \u03b2) (x y : \u03b1) :\n    Equiv.swap (f x) (f y) \u2218 f = f \u2218 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 : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 Subtype p) : \u03b1 \u21aa \u03b2 :=\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 `\u03b1 \u21aa \u03b2` is equivalent to\n    the subtype of all injective functions `\u03b1 \u2192 \u03b2`. -/\ndef subtypeInjectiveEquivEmbedding (\u03b1 \u03b2 : Sort _) :\n    { f : \u03b1 \u2192 \u03b2 // Injective f } \u2243 (\u03b1 \u21aa \u03b2) where\n  toFun f := \u27e8f.val, f.property\u27e9\n  invFun f := \u27e8f, f.injective\u27e9\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 `\u03b1\u2081 \u2243 \u03b1\u2082` and `\u03b2\u2081 \u2243 \u03b2\u2082`, then the type of embeddings `\u03b1\u2081 \u21aa \u03b2\u2081`\nis equivalent to the type of embeddings `\u03b1\u2082 \u21aa \u03b2\u2082`. -/\n@[simps apply]\ndef embeddingCongr {\u03b1 \u03b2 \u03b3 \u03b4 : Sort _} (h : \u03b1 \u2243 \u03b2) (h' : \u03b3 \u2243 \u03b4) : (\u03b1 \u21aa \u03b3) \u2243 (\u03b2 \u21aa \u03b4) 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 {\u03b1 \u03b2 : Sort _} :\n    embeddingCongr (Equiv.refl \u03b1) (Equiv.refl \u03b2) = Equiv.refl (\u03b1 \u21aa \u03b2) :=\n  rfl\n#align equiv.embedding_congr_refl Equiv.embeddingCongr_refl\n\n@[simp]\ntheorem embeddingCongr_trans {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 \u03b1\u2083 \u03b2\u2083 : Sort _} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2081' : \u03b2\u2081 \u2243 \u03b2\u2082)\n    (e\u2082 : \u03b1\u2082 \u2243 \u03b1\u2083) (e\u2082' : \u03b2\u2082 \u2243 \u03b2\u2083) :\n    embeddingCongr (e\u2081.trans e\u2082) (e\u2081'.trans e\u2082') =\n      (embeddingCongr e\u2081 e\u2081').trans (embeddingCongr e\u2082 e\u2082') :=\n  rfl\n#align equiv.embedding_congr_trans Equiv.embeddingCongr_trans\n\n@[simp]\ntheorem embeddingCongr_symm {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Sort _} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    (embeddingCongr e\u2081 e\u2082).symm = embeddingCongr e\u2081.symm e\u2082.symm :=\n  rfl\n#align equiv.embedding_congr_symm Equiv.embeddingCongr_symm\n\ntheorem embeddingCongr_apply_trans {\u03b1\u2081 \u03b2\u2081 \u03b3\u2081 \u03b1\u2082 \u03b2\u2082 \u03b3\u2082 : Sort _} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082)\n    (ec : \u03b3\u2081 \u2243 \u03b3\u2082) (f : \u03b1\u2081 \u21aa \u03b2\u2081) (g : \u03b2\u2081 \u21aa \u03b3\u2081) :\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 {\u03b1 : Type _} : (Equiv.refl \u03b1).toEmbedding = Embedding.refl \u03b1 :=\n  rfl\n#align equiv.refl_to_embedding Equiv.refl_toEmbedding\n\n@[simp]\ntheorem trans_toEmbedding {\u03b1 \u03b2 \u03b3 : Type _} (e : \u03b1 \u2243 \u03b2) (f : \u03b2 \u2243 \u03b3) :\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 {\u03b1 : Type _}\n\n/-- A subtype `{x // p x \u2228 q x}` over a disjunction of `p q : \u03b1 \u2192 Prop` can be injectively split\ninto a sum of subtypes `{x // p x} \u2295 {x // q x}` such that `\u00ac p x` is sent to the right. -/\ndef subtypeOrLeftEmbedding (p q : \u03b1 \u2192 Prop) [DecidablePred p] :\n    { x // p x \u2228 q x } \u21aa Sum { x // p x } { x // q x } :=\n  \u27e8fun x => if h : p x then Sum.inl \u27e8x, h\u27e9 else Sum.inr \u27e8x, x.prop.resolve_left h\u27e9, by\n    intro x y\n    dsimp only\n    split_ifs <;> simp [Subtype.ext_iff]\u27e9\n#align subtype_or_left_embedding subtypeOrLeftEmbedding\n\ntheorem subtypeOrLeftEmbedding_apply_left {p q : \u03b1 \u2192 Prop} [DecidablePred p]\n    (x : { x // p x \u2228 q x }) (hx : p x) :\n    subtypeOrLeftEmbedding p q x = Sum.inl \u27e8x, hx\u27e9 :=\n  dif_pos hx\n#align subtype_or_left_embedding_apply_left subtypeOrLeftEmbedding_apply_left\n\ntheorem subtypeOrLeftEmbedding_apply_right {p q : \u03b1 \u2192 Prop} [DecidablePred p]\n    (x : { x // p x \u2228 q x }) (hx : \u00acp x) :\n    subtypeOrLeftEmbedding p q x = Sum.inr \u27e8x, x.prop.resolve_left hx\u27e9 :=\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 \u2192 q x` for all `x : \u03b1`. -/\n@[simps]\ndef Subtype.impEmbedding (p q : \u03b1 \u2192 Prop) (h : \u2200 x, p x \u2192 q x) : { x // p x } \u21aa { x // q x } :=\n  \u27e8fun x => \u27e8x, h x x.prop\u27e9, fun x y => by simp [Subtype.ext_iff]\u27e9\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u00a75 (Infinite sums in commutative groups)\n\n-/\n\n/-- Infinite sum on a topological monoid\n\nThe `at_top` filter on `finset \u03b2` 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 `\u2115 \u2192 \u211d` 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, `\u03b1` 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] (f : \u03b2 \u2192 \u03b1) (a : \u03b1) :=\n  filter.tendsto (fun (s : finset \u03b2) => finset.sum s fun (b : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] (f : \u03b2 \u2192 \u03b1) :=\n  \u2203 (a : \u03b1), has_sum f a\n\n/-- `\u2211' i, f i` is the sum of `f` it exists, or 0 otherwise -/\ndef tsum {\u03b1 : Type u_1} [add_comm_monoid \u03b1] [topological_space \u03b1] {\u03b2 : Type u_2} (f : \u03b2 \u2192 \u03b1) : \u03b1 :=\n  dite (summable f) (fun (h : summable f) => classical.some h) fun (h : \u00acsummable f) => 0\n\n-- see Note [operator precedence of big operators]\n\ntheorem summable.has_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} (ha : summable f) : has_sum f (tsum fun (b : \u03b2) => f b) := sorry\n\ntheorem has_sum.summable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : has_sum f a) : summable f :=\n  Exists.intro a h\n\n/-- Constant zero function has sum `0` -/\ntheorem has_sum_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] : has_sum (fun (b : \u03b2) => 0) 0 := sorry\n\ntheorem summable_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] : summable fun (b : \u03b2) => 0 :=\n  has_sum.summable has_sum_zero\n\ntheorem tsum_eq_zero_of_not_summable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} (h : \u00acsummable f) : (tsum fun (b : \u03b2) => f b) = 0 := sorry\n\ntheorem has_sum.has_sum_of_sum_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {g : \u03b3 \u2192 \u03b1} (h_eq : \u2200 (u : finset \u03b3),\n  \u2203 (v : finset \u03b2),\n    \u2200 (v' : finset \u03b2),\n      v \u2286 v' \u2192 \u2203 (u' : finset \u03b3), u \u2286 u' \u2227 (finset.sum u' fun (x : \u03b3) => g x) = finset.sum v' fun (b : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {g : \u03b3 \u2192 \u03b1} (h\u2081 : \u2200 (u : finset \u03b3),\n  \u2203 (v : finset \u03b2),\n    \u2200 (v' : finset \u03b2),\n      v \u2286 v' \u2192 \u2203 (u' : finset \u03b3), u \u2286 u' \u2227 (finset.sum u' fun (x : \u03b3) => g x) = finset.sum v' fun (b : \u03b2) => f b) (h\u2082 : \u2200 (v : finset \u03b2),\n  \u2203 (u : finset \u03b3),\n    \u2200 (u' : finset \u03b3),\n      u \u2286 u' \u2192 \u2203 (v' : finset \u03b2), v \u2286 v' \u2227 (finset.sum v' fun (b : \u03b2) => f b) = finset.sum u' fun (x : \u03b3) => g x) : has_sum f a \u2194 has_sum g a :=\n  { mp := has_sum.has_sum_of_sum_eq h\u2082, mpr := has_sum.has_sum_of_sum_eq h\u2081 }\n\ntheorem function.injective.has_sum_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {g : \u03b3 \u2192 \u03b2} (hg : function.injective g) (hf : \u2200 (x : \u03b2), \u00acx \u2208 set.range g \u2192 f x = 0) : has_sum (f \u2218 g) a \u2194 has_sum f a := sorry\n\ntheorem function.injective.summable_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b2} (hg : function.injective g) (hf : \u2200 (x : \u03b2), \u00acx \u2208 set.range g \u2192 f x = 0) : summable (f \u2218 g) \u2194 summable f :=\n  exists_congr fun (_x : \u03b1) => function.injective.has_sum_iff hg hf\n\ntheorem has_sum_subtype_iff_of_support_subset {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {s : set \u03b2} (hf : function.support f \u2286 s) : has_sum (f \u2218 coe) a \u2194 has_sum f a := sorry\n\ntheorem has_sum_subtype_iff_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {s : set \u03b2} : has_sum (f \u2218 coe) a \u2194 has_sum (set.indicator s f) a := sorry\n\n@[simp] theorem has_sum_subtype_support {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} : has_sum (f \u2218 coe) a \u2194 has_sum f a :=\n  has_sum_subtype_iff_of_support_subset (set.subset.refl (function.support f))\n\ntheorem has_sum_fintype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [fintype \u03b2] (f : \u03b2 \u2192 \u03b1) : has_sum f (finset.sum finset.univ fun (b : \u03b2) => f b) :=\n  order_top.tendsto_at_top_nhds fun (s : finset \u03b2) => finset.sum s fun (b : \u03b2) => f b\n\nprotected theorem finset.has_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : has_sum (f \u2218 coe) (finset.sum s fun (b : \u03b2) => f b) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (has_sum (f \u2218 coe) (finset.sum s fun (b : \u03b2) => f b))) (Eq.symm finset.sum_attach)))\n    (has_sum_fintype (f \u2218 coe))\n\nprotected theorem finset.summable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : summable (f \u2218 coe) :=\n  has_sum.summable (finset.has_sum s f)\n\nprotected theorem set.finite.summable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {s : set \u03b2} (hs : set.finite s) (f : \u03b2 \u2192 \u03b1) : summable (f \u2218 coe) := sorry\n\n/-- If a function `f` vanishes outside of a finite set `s`, then it `has_sum` `\u2211 b in s, f b`. -/\ntheorem has_sum_sum_of_ne_finset_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {s : finset \u03b2} (hf : \u2200 (b : \u03b2), \u00acb \u2208 s \u2192 f b = 0) : has_sum f (finset.sum s fun (b : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {s : finset \u03b2} (hf : \u2200 (b : \u03b2), \u00acb \u2208 s \u2192 f b = 0) : summable f :=\n  has_sum.summable (has_sum_sum_of_ne_finset_zero hf)\n\ntheorem has_sum_single {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} (b : \u03b2) (hf : \u2200 (b' : \u03b2), b' \u2260 b \u2192 f b' = 0) : has_sum f (f b) := sorry\n\ntheorem has_sum_ite_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] (b : \u03b2) (a : \u03b1) : has_sum (fun (b' : \u03b2) => ite (b' = b) a 0) a := sorry\n\ntheorem equiv.has_sum_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (e : \u03b3 \u2243 \u03b2) : has_sum (f \u2218 \u21d1e) a \u2194 has_sum f a := sorry\n\ntheorem equiv.summable_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} (e : \u03b3 \u2243 \u03b2) : summable (f \u2218 \u21d1e) \u2194 summable f :=\n  exists_congr fun (a : \u03b1) => equiv.has_sum_iff e\n\ntheorem summable.prod_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u00d7 \u03b3 \u2192 \u03b1} (hf : summable f) : summable fun (p : \u03b3 \u00d7 \u03b2) => f (prod.swap p) :=\n  iff.mpr (equiv.summable_iff (equiv.prod_comm \u03b3 \u03b2)) hf\n\ntheorem equiv.has_sum_iff_of_support {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {g : \u03b3 \u2192 \u03b1} (e : \u21a5(function.support f) \u2243 \u21a5(function.support g)) (he : \u2200 (x : \u21a5(function.support f)), g \u2191(coe_fn e x) = f \u2191x) : has_sum f a \u2194 has_sum g a := sorry\n\ntheorem has_sum_iff_has_sum_of_ne_zero_bij {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {g : \u03b3 \u2192 \u03b1} (i : \u21a5(function.support g) \u2192 \u03b2) (hi : \u2200 {x y : \u21a5(function.support g)}, i x = i y \u2192 \u2191x = \u2191y) (hf : function.support f \u2286 set.range i) (hfg : \u2200 (x : \u21a5(function.support g)), f (i x) = g \u2191x) : has_sum f a \u2194 has_sum g a := sorry\n\ntheorem equiv.summable_iff_of_support {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1} (e : \u21a5(function.support f) \u2243 \u21a5(function.support g)) (he : \u2200 (x : \u21a5(function.support f)), g \u2191(coe_fn e x) = f \u2191x) : summable f \u2194 summable g :=\n  exists_congr fun (_x : \u03b1) => equiv.has_sum_iff_of_support e he\n\nprotected theorem has_sum.map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} [add_comm_monoid \u03b3] [topological_space \u03b3] (hf : has_sum f a) (g : \u03b1 \u2192+ \u03b3) (hg : continuous \u21d1g) : has_sum (\u21d1g \u2218 f) (coe_fn g a) := sorry\n\nprotected theorem summable.map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} [add_comm_monoid \u03b3] [topological_space \u03b3] (hf : summable f) (g : \u03b1 \u2192+ \u03b3) (hg : continuous \u21d1g) : summable (\u21d1g \u2218 f) :=\n  has_sum.summable (has_sum.map (summable.has_sum hf) g hg)\n\n/-- If `f : \u2115 \u2192 \u03b1` has sum `a`, then the partial sums `\u2211_{i=0}^{n-1} f i` converge to `a`. -/\ntheorem has_sum.tendsto_sum_nat {\u03b1 : Type u_1} [add_comm_monoid \u03b1] [topological_space \u03b1] {a : \u03b1} {f : \u2115 \u2192 \u03b1} (h : has_sum f a) : filter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i) filter.at_top (nhds a) :=\n  filter.tendsto.comp h filter.tendsto_finset_range\n\ntheorem has_sum.unique {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} {a\u2082 : \u03b1} [t2_space \u03b1] : has_sum f a\u2081 \u2192 has_sum f a\u2082 \u2192 a\u2081 = a\u2082 :=\n  tendsto_nhds_unique\n\ntheorem summable.has_sum_iff_tendsto_nat {\u03b1 : Type u_1} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u2115 \u2192 \u03b1} {a : \u03b1} (hf : summable f) : has_sum f a \u2194 filter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i) filter.at_top (nhds a) := sorry\n\ntheorem equiv.summable_iff_of_has_sum_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] {\u03b1' : Type u_4} [add_comm_monoid \u03b1'] [topological_space \u03b1'] (e : \u03b1' \u2243 \u03b1) {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1'} (he : \u2200 {a : \u03b1'}, has_sum f (coe_fn e a) \u2194 has_sum g a) : summable f \u2194 summable g := sorry\n\ntheorem has_sum.add {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a : \u03b1} {b : \u03b1} [has_continuous_add \u03b1] (hf : has_sum f a) (hg : has_sum g b) : has_sum (fun (b : \u03b2) => f b + g b) (a + b) := sorry\n\ntheorem summable.add {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} [has_continuous_add \u03b1] (hf : summable f) (hg : summable g) : summable fun (b : \u03b2) => f b + g b :=\n  has_sum.summable (has_sum.add (summable.has_sum hf) (summable.has_sum hg))\n\ntheorem has_sum_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [has_continuous_add \u03b1] {f : \u03b3 \u2192 \u03b2 \u2192 \u03b1} {a : \u03b3 \u2192 \u03b1} {s : finset \u03b3} : (\u2200 (i : \u03b3), i \u2208 s \u2192 has_sum (f i) (a i)) \u2192\n  has_sum (fun (b : \u03b2) => finset.sum s fun (i : \u03b3) => f i b) (finset.sum s fun (i : \u03b3) => a i) := sorry\n\ntheorem summable_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [has_continuous_add \u03b1] {f : \u03b3 \u2192 \u03b2 \u2192 \u03b1} {s : finset \u03b3} (hf : \u2200 (i : \u03b3), i \u2208 s \u2192 summable (f i)) : summable fun (b : \u03b2) => finset.sum s fun (i : \u03b3) => f i b :=\n  has_sum.summable (has_sum_sum fun (i : \u03b3) (hi : i \u2208 s) => summable.has_sum (hf i hi))\n\ntheorem has_sum.add_compl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {b : \u03b1} [has_continuous_add \u03b1] {s : set \u03b2} (ha : has_sum (f \u2218 coe) a) (hb : has_sum (f \u2218 coe) b) : has_sum f (a + b) := sorry\n\ntheorem summable.add_compl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} [has_continuous_add \u03b1] {s : set \u03b2} (hs : summable (f \u2218 coe)) (hsc : summable (f \u2218 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {b : \u03b1} [has_continuous_add \u03b1] {s : set \u03b2} (ha : has_sum (f \u2218 coe) a) (hb : has_sum (f \u2218 coe) b) : has_sum f (a + b) := sorry\n\ntheorem summable.compl_add {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} [has_continuous_add \u03b1] {s : set \u03b2} (hs : summable (f \u2218 coe)) (hsc : summable (f \u2218 coe)) : summable f :=\n  has_sum.summable (has_sum.compl_add (summable.has_sum hs) (summable.has_sum hsc))\n\ntheorem has_sum.sigma {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [has_continuous_add \u03b1] [regular_space \u03b1] {\u03b3 : \u03b2 \u2192 Type u_3} {f : (sigma fun (b : \u03b2) => \u03b3 b) \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a : \u03b1} (ha : has_sum f a) (hf : \u2200 (b : \u03b2), has_sum (fun (c : \u03b3 b) => f (sigma.mk b c)) (g b)) : has_sum g a := sorry\n\n/-- If a series `f` on `\u03b2 \u00d7 \u03b3` has sum `a` and for each `b` the restriction of `f` to `{b} \u00d7 \u03b3`\nhas sum `g b`, then the series `g` has sum `a`. -/\ntheorem has_sum.prod_fiberwise {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [has_continuous_add \u03b1] [regular_space \u03b1] {f : \u03b2 \u00d7 \u03b3 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a : \u03b1} (ha : has_sum f a) (hf : \u2200 (b : \u03b2), has_sum (fun (c : \u03b3) => f (b, c)) (g b)) : has_sum g a :=\n  has_sum.sigma (iff.mpr (equiv.has_sum_iff (equiv.sigma_equiv_prod \u03b2 \u03b3)) ha) hf\n\ntheorem summable.sigma' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [has_continuous_add \u03b1] [regular_space \u03b1] {\u03b3 : \u03b2 \u2192 Type u_3} {f : (sigma fun (b : \u03b2) => \u03b3 b) \u2192 \u03b1} (ha : summable f) (hf : \u2200 (b : \u03b2), summable fun (c : \u03b3 b) => f (sigma.mk b c)) : summable fun (b : \u03b2) => tsum fun (c : \u03b3 b) => f (sigma.mk b c) :=\n  has_sum.summable (has_sum.sigma (summable.has_sum ha) fun (b : \u03b2) => summable.has_sum (hf b))\n\ntheorem has_sum.sigma_of_has_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [has_continuous_add \u03b1] [regular_space \u03b1] {\u03b3 : \u03b2 \u2192 Type u_3} {f : (sigma fun (b : \u03b2) => \u03b3 b) \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a : \u03b1} (ha : has_sum g a) (hf : \u2200 (b : \u03b2), has_sum (fun (c : \u03b3 b) => f (sigma.mk b c)) (g b)) (hf' : summable f) : has_sum f a := sorry\n\ntheorem has_sum.tsum_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (ha : has_sum f a) : (tsum fun (b : \u03b2) => f b) = a :=\n  has_sum.unique (summable.has_sum (Exists.intro a ha)) ha\n\ntheorem summable.has_sum_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : summable f) : has_sum f a \u2194 (tsum fun (b : \u03b2) => f b) = a :=\n  { mp := has_sum.tsum_eq, mpr := fun (eq : (tsum fun (b : \u03b2) => f b) = a) => eq \u25b8 summable.has_sum h }\n\n@[simp] theorem tsum_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] : (tsum fun (b : \u03b2) => 0) = 0 :=\n  has_sum.tsum_eq has_sum_zero\n\ntheorem tsum_eq_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u03b2 \u2192 \u03b1} {s : finset \u03b2} (hf : \u2200 (b : \u03b2), \u00acb \u2208 s \u2192 f b = 0) : (tsum fun (b : \u03b2) => f b) = finset.sum s fun (b : \u03b2) => f b :=\n  has_sum.tsum_eq (has_sum_sum_of_ne_finset_zero hf)\n\ntheorem tsum_fintype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [fintype \u03b2] (f : \u03b2 \u2192 \u03b1) : (tsum fun (b : \u03b2) => f b) = finset.sum finset.univ fun (b : \u03b2) => f b :=\n  has_sum.tsum_eq (has_sum_fintype f)\n\n@[simp] theorem finset.tsum_subtype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : (tsum fun (x : Subtype fun (x : \u03b2) => x \u2208 s) => f \u2191x) = finset.sum s fun (x : \u03b2) => f x :=\n  has_sum.tsum_eq (finset.has_sum s f)\n\n@[simp] theorem finset.tsum_subtype' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : (tsum fun (x : \u21a5\u2191s) => f \u2191x) = finset.sum s fun (x : \u03b2) => f x :=\n  finset.tsum_subtype s f\n\ntheorem tsum_eq_single {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u03b2 \u2192 \u03b1} (b : \u03b2) (hf : \u2200 (b' : \u03b2), b' \u2260 b \u2192 f b' = 0) : (tsum fun (b : \u03b2) => f b) = f b :=\n  has_sum.tsum_eq (has_sum_single b hf)\n\n@[simp] theorem tsum_ite_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] (b : \u03b2) (a : \u03b1) : (tsum fun (b' : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {\u03b1' : Type u_4} [add_comm_monoid \u03b1'] [topological_space \u03b1'] (e : \u03b1' \u2243 \u03b1) (h0 : coe_fn e 0 = 0) {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1'} (h : \u2200 {a : \u03b1'}, has_sum f (coe_fn e a) \u2194 has_sum g a) : (tsum fun (b : \u03b2) => f b) = coe_fn e (tsum fun (c : \u03b3) => g c) := sorry\n\ntheorem tsum_eq_tsum_of_has_sum_iff_has_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1} (h : \u2200 {a : \u03b1}, has_sum f a \u2194 has_sum g a) : (tsum fun (b : \u03b2) => f b) = tsum fun (c : \u03b3) => g c :=\n  equiv.tsum_eq_tsum_of_has_sum_iff_has_sum (equiv.refl \u03b1) rfl h\n\ntheorem equiv.tsum_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] (j : \u03b3 \u2243 \u03b2) (f : \u03b2 \u2192 \u03b1) : (tsum fun (c : \u03b3) => f (coe_fn j c)) = tsum fun (b : \u03b2) => f b :=\n  tsum_eq_tsum_of_has_sum_iff_has_sum fun (a : \u03b1) => equiv.has_sum_iff j\n\ntheorem equiv.tsum_eq_tsum_of_support {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1} (e : \u21a5(function.support f) \u2243 \u21a5(function.support g)) (he : \u2200 (x : \u21a5(function.support f)), g \u2191(coe_fn e x) = f \u2191x) : (tsum fun (x : \u03b2) => f x) = tsum fun (y : \u03b3) => g y :=\n  tsum_eq_tsum_of_has_sum_iff_has_sum fun (_x : \u03b1) => equiv.has_sum_iff_of_support e he\n\ntheorem tsum_eq_tsum_of_ne_zero_bij {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1} (i : \u21a5(function.support g) \u2192 \u03b2) (hi : \u2200 {x y : \u21a5(function.support g)}, i x = i y \u2192 \u2191x = \u2191y) (hf : function.support f \u2286 set.range i) (hfg : \u2200 (x : \u21a5(function.support g)), f (i x) = g \u2191x) : (tsum fun (x : \u03b2) => f x) = tsum fun (y : \u03b3) => g y :=\n  tsum_eq_tsum_of_has_sum_iff_has_sum fun (_x : \u03b1) => has_sum_iff_has_sum_of_ne_zero_bij i hi hf hfg\n\ntheorem tsum_subtype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] (s : set \u03b2) (f : \u03b2 \u2192 \u03b1) : (tsum fun (x : \u21a5s) => f \u2191x) = tsum fun (x : \u03b2) => set.indicator s f x :=\n  tsum_eq_tsum_of_has_sum_iff_has_sum fun (_x : \u03b1) => has_sum_subtype_iff_indicator\n\ntheorem tsum_add {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} [has_continuous_add \u03b1] (hf : summable f) (hg : summable g) : (tsum fun (b : \u03b2) => f b + g b) = (tsum fun (b : \u03b2) => f b) + tsum fun (b : \u03b2) => g b :=\n  has_sum.tsum_eq (has_sum.add (summable.has_sum hf) (summable.has_sum hg))\n\ntheorem tsum_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [has_continuous_add \u03b1] {f : \u03b3 \u2192 \u03b2 \u2192 \u03b1} {s : finset \u03b3} (hf : \u2200 (i : \u03b3), i \u2208 s \u2192 summable (f i)) : (tsum fun (b : \u03b2) => finset.sum s fun (i : \u03b3) => f i b) = finset.sum s fun (i : \u03b3) => tsum fun (b : \u03b2) => f i b :=\n  has_sum.tsum_eq (has_sum_sum fun (i : \u03b3) (hi : i \u2208 s) => summable.has_sum (hf i hi))\n\ntheorem tsum_sigma' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [has_continuous_add \u03b1] [regular_space \u03b1] {\u03b3 : \u03b2 \u2192 Type u_3} {f : (sigma fun (b : \u03b2) => \u03b3 b) \u2192 \u03b1} (h\u2081 : \u2200 (b : \u03b2), summable fun (c : \u03b3 b) => f (sigma.mk b c)) (h\u2082 : summable f) : (tsum fun (p : sigma fun (b : \u03b2) => \u03b3 b) => f p) = tsum fun (b : \u03b2) => tsum fun (c : \u03b3 b) => f (sigma.mk b c) :=\n  Eq.symm (has_sum.tsum_eq (has_sum.sigma (summable.has_sum h\u2082) fun (b : \u03b2) => summable.has_sum (h\u2081 b)))\n\ntheorem tsum_prod' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [has_continuous_add \u03b1] [regular_space \u03b1] {f : \u03b2 \u00d7 \u03b3 \u2192 \u03b1} (h : summable f) (h\u2081 : \u2200 (b : \u03b2), summable fun (c : \u03b3) => f (b, c)) : (tsum fun (p : \u03b2 \u00d7 \u03b3) => f p) = tsum fun (b : \u03b2) => tsum fun (c : \u03b3) => f (b, c) :=\n  Eq.symm (has_sum.tsum_eq (has_sum.prod_fiberwise (summable.has_sum h) fun (b : \u03b2) => summable.has_sum (h\u2081 b)))\n\ntheorem tsum_comm' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [has_continuous_add \u03b1] [regular_space \u03b1] {f : \u03b2 \u2192 \u03b3 \u2192 \u03b1} (h : summable (function.uncurry f)) (h\u2081 : \u2200 (b : \u03b2), summable (f b)) (h\u2082 : \u2200 (c : \u03b3), summable fun (b : \u03b2) => f b c) : (tsum fun (c : \u03b3) => tsum fun (b : \u03b2) => f b c) = tsum fun (b : \u03b2) => tsum fun (c : \u03b3) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [encodable \u03b3] [complete_lattice \u03b2] (m : \u03b2 \u2192 \u03b1) (m0 : m \u22a5 = 0) (s : \u03b3 \u2192 \u03b2) : (tsum fun (i : \u2115) => m (supr fun (b : \u03b3) => supr fun (H : b \u2208 encodable.decode2 \u03b3 i) => s b)) =\n  tsum fun (b : \u03b3) => m (s b) := sorry\n\n/-- `tsum_supr_decode2` specialized to the complete lattice of sets. -/\ntheorem tsum_Union_decode2 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [encodable \u03b3] (m : set \u03b2 \u2192 \u03b1) (m0 : m \u2205 = 0) (s : \u03b3 \u2192 set \u03b2) : (tsum fun (i : \u2115) => m (set.Union fun (b : \u03b3) => set.Union fun (H : b \u2208 encodable.decode2 \u03b3 i) => s b)) =\n  tsum fun (b : \u03b3) => 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 `(\u2264)` 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [encodable \u03b3] [complete_lattice \u03b2] (m : \u03b2 \u2192 \u03b1) (m0 : m \u22a5 = 0) (R : \u03b1 \u2192 \u03b1 \u2192 Prop) (m_supr : \u2200 (s : \u2115 \u2192 \u03b2), R (m (supr fun (i : \u2115) => s i)) (tsum fun (i : \u2115) => m (s i))) (s : \u03b3 \u2192 \u03b2) : R (m (supr fun (b : \u03b3) => s b)) (tsum fun (b : \u03b3) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b4 : Type u_4} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [complete_lattice \u03b2] (m : \u03b2 \u2192 \u03b1) (m0 : m \u22a5 = 0) (R : \u03b1 \u2192 \u03b1 \u2192 Prop) (m_supr : \u2200 (s : \u2115 \u2192 \u03b2), R (m (supr fun (i : \u2115) => s i)) (tsum fun (i : \u2115) => m (s i))) (s : \u03b4 \u2192 \u03b2) (t : finset \u03b4) : R (m (supr fun (d : \u03b4) => supr fun (H : d \u2208 t) => s d)) (finset.sum t fun (d : \u03b4) => m (s d)) := sorry\n\n/-- If a function is countably sub-additive then it is binary sub-additive -/\ntheorem rel_sup_add {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b1] [topological_space \u03b1] [t2_space \u03b1] [complete_lattice \u03b2] (m : \u03b2 \u2192 \u03b1) (m0 : m \u22a5 = 0) (R : \u03b1 \u2192 \u03b1 \u2192 Prop) (m_supr : \u2200 (s : \u2115 \u2192 \u03b2), R (m (supr fun (i : \u2115) => s i)) (tsum fun (i : \u2115) => m (s i))) (s\u2081 : \u03b2) (s\u2082 : \u03b2) : R (m (s\u2081 \u2294 s\u2082)) (m s\u2081 + m s\u2082) := sorry\n\ntheorem pi.has_sum {\u03b1 : Type u_1} {\u03b9 : Type u_5} {\u03c0 : \u03b1 \u2192 Type u_6} [(x : \u03b1) \u2192 add_comm_monoid (\u03c0 x)] [(x : \u03b1) \u2192 topological_space (\u03c0 x)] {f : \u03b9 \u2192 (x : \u03b1) \u2192 \u03c0 x} {g : (x : \u03b1) \u2192 \u03c0 x} : has_sum f g \u2194 \u2200 (x : \u03b1), has_sum (fun (i : \u03b9) => f i x) (g x) := sorry\n\ntheorem pi.summable {\u03b1 : Type u_1} {\u03b9 : Type u_5} {\u03c0 : \u03b1 \u2192 Type u_6} [(x : \u03b1) \u2192 add_comm_monoid (\u03c0 x)] [(x : \u03b1) \u2192 topological_space (\u03c0 x)] {f : \u03b9 \u2192 (x : \u03b1) \u2192 \u03c0 x} : summable f \u2194 \u2200 (x : \u03b1), summable fun (i : \u03b9) => f i x := sorry\n\ntheorem tsum_apply {\u03b1 : Type u_1} {\u03b9 : Type u_5} {\u03c0 : \u03b1 \u2192 Type u_6} [(x : \u03b1) \u2192 add_comm_monoid (\u03c0 x)] [(x : \u03b1) \u2192 topological_space (\u03c0 x)] [\u2200 (x : \u03b1), t2_space (\u03c0 x)] {f : \u03b9 \u2192 (x : \u03b1) \u2192 \u03c0 x} {x : \u03b1} (hf : summable f) : tsum (fun (i : \u03b9) => f i) x = tsum fun (i : \u03b9) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : has_sum f a) : has_sum (fun (b : \u03b2) => -f b) (-a) :=\n  eq.mpr (id (Eq.refl (has_sum (fun (b : \u03b2) => -f b) (-a))))\n    (eq.mp (Eq.refl (has_sum (\u21d1(-add_monoid_hom.id \u03b1) \u2218 f) (coe_fn (-add_monoid_hom.id \u03b1) a)))\n      (has_sum.map h (-add_monoid_hom.id \u03b1) continuous_neg))\n\ntheorem summable.neg {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} (hf : summable f) : summable fun (b : \u03b2) => -f b :=\n  has_sum.summable (has_sum.neg (summable.has_sum hf))\n\ntheorem summable.of_neg {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} (hf : summable fun (b : \u03b2) => -f b) : summable f := sorry\n\ntheorem summable_neg_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} : (summable fun (b : \u03b2) => -f b) \u2194 summable f :=\n  { mp := summable.of_neg, mpr := summable.neg }\n\ntheorem has_sum.sub {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} {a\u2082 : \u03b1} (hf : has_sum f a\u2081) (hg : has_sum g a\u2082) : has_sum (fun (b : \u03b2) => f b - g b) (a\u2081 - a\u2082) := sorry\n\ntheorem summable.sub {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (hf : summable f) (hg : summable g) : summable fun (b : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} {a\u2082 : \u03b1} {s : set \u03b2} (hf : has_sum (f \u2218 coe) a\u2081) : has_sum (f \u2218 coe) a\u2082 \u2194 has_sum f (a\u2081 + a\u2082) := sorry\n\ntheorem has_sum.has_sum_iff_compl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} {a\u2082 : \u03b1} {s : set \u03b2} (hf : has_sum (f \u2218 coe) a\u2081) : has_sum f a\u2082 \u2194 has_sum (f \u2218 coe) (a\u2082 - a\u2081) := sorry\n\ntheorem summable.summable_compl_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {s : set \u03b2} (hf : summable (f \u2218 coe)) : summable (f \u2218 coe) \u2194 summable f := sorry\n\nprotected theorem finset.has_sum_compl_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (s : finset \u03b2) : has_sum (fun (x : Subtype fun (x : \u03b2) => \u00acx \u2208 s) => f \u2191x) a \u2194 has_sum f (a + finset.sum s fun (i : \u03b2) => f i) := sorry\n\nprotected theorem finset.has_sum_iff_compl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (s : finset \u03b2) : has_sum f a \u2194 has_sum (fun (x : Subtype fun (x : \u03b2) => \u00acx \u2208 s) => f \u2191x) (a - finset.sum s fun (i : \u03b2) => f i) :=\n  has_sum.has_sum_iff_compl (finset.has_sum s f)\n\nprotected theorem finset.summable_compl_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} (s : finset \u03b2) : (summable fun (x : Subtype fun (x : \u03b2) => \u00acx \u2208 s) => f \u2191x) \u2194 summable f :=\n  summable.summable_compl_iff (finset.summable s f)\n\ntheorem set.finite.summable_compl_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {s : set \u03b2} (hs : set.finite s) : summable (f \u2218 coe) \u2194 summable f :=\n  summable.summable_compl_iff (set.finite.summable hs f)\n\ntheorem tsum_neg {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} [t2_space \u03b1] (hf : summable f) : (tsum fun (b : \u03b2) => -f b) = -tsum fun (b : \u03b2) => f b :=\n  has_sum.tsum_eq (has_sum.neg (summable.has_sum hf))\n\ntheorem tsum_sub {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} [t2_space \u03b1] (hf : summable f) (hg : summable g) : (tsum fun (b : \u03b2) => f b - g b) = (tsum fun (b : \u03b2) => f b) - tsum fun (b : \u03b2) => g b :=\n  has_sum.tsum_eq (has_sum.sub (summable.has_sum hf) (summable.has_sum hg))\n\ntheorem tsum_add_tsum_compl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} [t2_space \u03b1] {s : set \u03b2} (hs : summable (f \u2218 coe)) (hsc : summable (f \u2218 coe)) : ((tsum fun (x : \u21a5s) => f \u2191x) + tsum fun (x : \u21a5(s\u1d9c)) => f \u2191x) = tsum fun (x : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} [t2_space \u03b1] {s : finset \u03b2} (hf : summable f) : ((finset.sum s fun (x : \u03b2) => f x) + tsum fun (x : \u21a5(\u2191s\u1d9c)) => f \u2191x) = tsum fun (x : \u03b2) => 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 `\u03b1`, 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 `\u2115`, we deduce the\nformula `(\u2211 i in range k, f i) + (\u2211' i, f (i + k)) = (\u2211' i, f i)`, in `sum_add_tsum_nat_add`.\n-/\n\ntheorem has_sum_nat_add_iff {\u03b1 : Type u_1} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u2115 \u2192 \u03b1} (k : \u2115) {a : \u03b1} : has_sum (fun (n : \u2115) => f (n + k)) a \u2194 has_sum f (a + finset.sum (finset.range k) fun (i : \u2115) => f i) := sorry\n\ntheorem summable_nat_add_iff {\u03b1 : Type u_1} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u2115 \u2192 \u03b1} (k : \u2115) : (summable fun (n : \u2115) => f (n + k)) \u2194 summable f :=\n  iff.symm\n    (equiv.summable_iff_of_has_sum_iff (equiv.add_right (finset.sum (finset.range k) fun (i : \u2115) => f i))\n      fun (a : \u03b1) => iff.symm (has_sum_nat_add_iff k))\n\ntheorem has_sum_nat_add_iff' {\u03b1 : Type u_1} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] {f : \u2115 \u2192 \u03b1} (k : \u2115) {a : \u03b1} : has_sum (fun (n : \u2115) => f (n + k)) (a - finset.sum (finset.range k) fun (i : \u2115) => f i) \u2194 has_sum f a := sorry\n\ntheorem sum_add_tsum_nat_add {\u03b1 : Type u_1} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] [t2_space \u03b1] {f : \u2115 \u2192 \u03b1} (k : \u2115) (h : summable f) : ((finset.sum (finset.range k) fun (i : \u2115) => f i) + tsum fun (i : \u2115) => f (i + k)) = tsum fun (i : \u2115) => f i := sorry\n\ntheorem tsum_eq_zero_add {\u03b1 : Type u_1} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] [t2_space \u03b1] {f : \u2115 \u2192 \u03b1} (hf : summable f) : (tsum fun (b : \u2115) => f b) = f 0 + tsum fun (b : \u2115) => f (b + 1) := sorry\n\n/-- For `f : \u2115 \u2192 \u03b1`, then `\u2211' 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 {\u03b1 : Type u_1} [add_comm_group \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] [t2_space \u03b1] (f : \u2115 \u2192 \u03b1) : filter.tendsto (fun (i : \u2115) => tsum fun (k : \u2115) => f (k + i)) filter.at_top (nhds 0) := sorry\n\ntheorem has_sum.mul_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semiring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} (a\u2082 : \u03b1) (h : has_sum f a\u2081) : has_sum (fun (b : \u03b2) => a\u2082 * f b) (a\u2082 * a\u2081) :=\n  eq.mpr (id (Eq.refl (has_sum (fun (b : \u03b2) => a\u2082 * f b) (a\u2082 * a\u2081))))\n    (eq.mp (Eq.refl (has_sum (\u21d1(add_monoid_hom.mul_left a\u2082) \u2218 f) (coe_fn (add_monoid_hom.mul_left a\u2082) a\u2081)))\n      (has_sum.map h (add_monoid_hom.mul_left a\u2082) (continuous.mul continuous_const continuous_id)))\n\ntheorem has_sum.mul_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semiring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} (a\u2082 : \u03b1) (hf : has_sum f a\u2081) : has_sum (fun (b : \u03b2) => f b * a\u2082) (a\u2081 * a\u2082) :=\n  eq.mpr (id (Eq.refl (has_sum (fun (b : \u03b2) => f b * a\u2082) (a\u2081 * a\u2082))))\n    (eq.mp (Eq.refl (has_sum (\u21d1(add_monoid_hom.mul_right a\u2082) \u2218 f) (coe_fn (add_monoid_hom.mul_right a\u2082) a\u2081)))\n      (has_sum.map hf (add_monoid_hom.mul_right a\u2082) (continuous.mul continuous_id continuous_const)))\n\ntheorem summable.mul_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semiring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} (a : \u03b1) (hf : summable f) : summable fun (b : \u03b2) => a * f b :=\n  has_sum.summable (has_sum.mul_left a (summable.has_sum hf))\n\ntheorem summable.mul_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semiring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} (a : \u03b1) (hf : summable f) : summable fun (b : \u03b2) => f b * a :=\n  has_sum.summable (has_sum.mul_right a (summable.has_sum hf))\n\ntheorem summable.tsum_mul_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semiring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} [t2_space \u03b1] (a : \u03b1) (hf : summable f) : (tsum fun (b : \u03b2) => a * f b) = a * tsum fun (b : \u03b2) => f b :=\n  has_sum.tsum_eq (has_sum.mul_left a (summable.has_sum hf))\n\ntheorem summable.tsum_mul_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semiring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} [t2_space \u03b1] (a : \u03b1) (hf : summable f) : (tsum fun (b : \u03b2) => f b * a) = (tsum fun (b : \u03b2) => f b) * a :=\n  has_sum.tsum_eq (has_sum.mul_right a (summable.has_sum hf))\n\ntheorem has_sum.smul {\u03b1 : Type u_1} {\u03b2 : Type u_2} {R : Type u_5} [semiring R] [topological_space R] [topological_space \u03b1] [add_comm_monoid \u03b1] [semimodule R \u03b1] [topological_semimodule R \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} {r : R} (hf : has_sum f a) : has_sum (fun (z : \u03b2) => r \u2022 f z) (r \u2022 a) :=\n  has_sum.map hf (const_smul_hom \u03b1 r) (continuous.smul continuous_const continuous_id)\n\ntheorem summable.smul {\u03b1 : Type u_1} {\u03b2 : Type u_2} {R : Type u_5} [semiring R] [topological_space R] [topological_space \u03b1] [add_comm_monoid \u03b1] [semimodule R \u03b1] [topological_semimodule R \u03b1] {f : \u03b2 \u2192 \u03b1} {r : R} (hf : summable f) : summable fun (z : \u03b2) => r \u2022 f z :=\n  has_sum.summable (has_sum.smul (summable.has_sum hf))\n\ntheorem tsum_smul {\u03b1 : Type u_1} {\u03b2 : Type u_2} {R : Type u_5} [semiring R] [topological_space R] [topological_space \u03b1] [add_comm_monoid \u03b1] [semimodule R \u03b1] [topological_semimodule R \u03b1] {f : \u03b2 \u2192 \u03b1} [t2_space \u03b1] {r : R} (hf : summable f) : (tsum fun (z : \u03b2) => r \u2022 f z) = r \u2022 tsum fun (z : \u03b2) => f z :=\n  has_sum.tsum_eq (has_sum.smul (summable.has_sum hf))\n\ntheorem has_sum.div_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [division_ring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : has_sum f a) (b : \u03b1) : has_sum (fun (x : \u03b2) => f x / b) (a / b) := sorry\n\ntheorem has_sum_mul_left_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [division_ring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} {a\u2082 : \u03b1} (h : a\u2082 \u2260 0) : has_sum f a\u2081 \u2194 has_sum (fun (b : \u03b2) => a\u2082 * f b) (a\u2082 * a\u2081) := sorry\n\ntheorem has_sum_mul_right_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [division_ring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} {a\u2082 : \u03b1} (h : a\u2082 \u2260 0) : has_sum f a\u2081 \u2194 has_sum (fun (b : \u03b2) => f b * a\u2082) (a\u2081 * a\u2082) := sorry\n\ntheorem summable_mul_left_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [division_ring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : a \u2260 0) : summable f \u2194 summable fun (b : \u03b2) => a * f b := sorry\n\ntheorem summable_mul_right_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [division_ring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : a \u2260 0) : summable f \u2194 summable fun (b : \u03b2) => f b * a := sorry\n\ntheorem tsum_mul_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [division_ring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} [t2_space \u03b1] : (tsum fun (x : \u03b2) => a * f x) = a * tsum fun (x : \u03b2) => f x := sorry\n\ntheorem tsum_mul_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [division_ring \u03b1] [topological_space \u03b1] [topological_semiring \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} [t2_space \u03b1] : (tsum fun (x : \u03b2) => f x * a) = (tsum fun (x : \u03b2) => f x) * a := sorry\n\ntheorem has_sum_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} {a\u2082 : \u03b1} (h : \u2200 (b : \u03b2), f b \u2264 g b) (hf : has_sum f a\u2081) (hg : has_sum g a\u2082) : a\u2081 \u2264 a\u2082 :=\n  le_of_tendsto_of_tendsto' hf hg fun (s : finset \u03b2) => finset.sum_le_sum fun (b : \u03b2) (_x : b \u2208 s) => h b\n\ntheorem has_sum_le_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} {a\u2081 : \u03b1} {a\u2082 : \u03b1} {g : \u03b3 \u2192 \u03b1} (i : \u03b2 \u2192 \u03b3) (hi : function.injective i) (hs : \u2200 (c : \u03b3), \u00acc \u2208 set.range i \u2192 0 \u2264 g c) (h : \u2200 (b : \u03b2), f b \u2264 g (i b)) (hf : has_sum f a\u2081) (hg : has_sum g a\u2082) : a\u2081 \u2264 a\u2082 := sorry\n\ntheorem tsum_le_tsum_of_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1} (i : \u03b2 \u2192 \u03b3) (hi : function.injective i) (hs : \u2200 (c : \u03b3), \u00acc \u2208 set.range i \u2192 0 \u2264 g c) (h : \u2200 (b : \u03b2), f b \u2264 g (i b)) (hf : summable f) (hg : summable g) : tsum f \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {a : \u03b1} {f : \u03b2 \u2192 \u03b1} (s : finset \u03b2) (hs : \u2200 (b : \u03b2), \u00acb \u2208 s \u2192 0 \u2264 f b) (hf : has_sum f a) : (finset.sum s fun (b : \u03b2) => f b) \u2264 a := sorry\n\ntheorem le_has_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (hf : has_sum f a) (b : \u03b2) (hb : \u2200 (b' : \u03b2), b' \u2260 b \u2192 0 \u2264 f b') : f b \u2264 a := sorry\n\ntheorem sum_le_tsum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} (s : finset \u03b2) (hs : \u2200 (b : \u03b2), \u00acb \u2208 s \u2192 0 \u2264 f b) (hf : summable f) : (finset.sum s fun (b : \u03b2) => f b) \u2264 tsum f :=\n  sum_le_has_sum s hs (summable.has_sum hf)\n\ntheorem le_tsum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} (hf : summable f) (b : \u03b2) (hb : \u2200 (b' : \u03b2), b' \u2260 b \u2192 0 \u2264 f b') : f b \u2264 tsum fun (b : \u03b2) => f b :=\n  le_has_sum (summable.has_sum hf) b hb\n\ntheorem tsum_le_tsum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (h : \u2200 (b : \u03b2), f b \u2264 g b) (hf : summable f) (hg : summable g) : (tsum fun (b : \u03b2) => f b) \u2264 tsum fun (b : \u03b2) => g b :=\n  has_sum_le h (summable.has_sum hf) (summable.has_sum hg)\n\ntheorem has_sum.nonneg {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {g : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : \u2200 (b : \u03b2), 0 \u2264 g b) (ha : has_sum g a) : 0 \u2264 a :=\n  has_sum_le h has_sum_zero ha\n\ntheorem has_sum.nonpos {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {g : \u03b2 \u2192 \u03b1} {a : \u03b1} (h : \u2200 (b : \u03b2), g b \u2264 0) (ha : has_sum g a) : a \u2264 0 :=\n  has_sum_le h ha has_sum_zero\n\ntheorem tsum_nonneg {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {g : \u03b2 \u2192 \u03b1} (h : \u2200 (b : \u03b2), 0 \u2264 g b) : 0 \u2264 tsum fun (b : \u03b2) => g b := sorry\n\ntheorem tsum_nonpos {\u03b1 : Type u_1} {\u03b2 : Type u_2} [ordered_add_comm_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} (h : \u2200 (b : \u03b2), f b \u2264 0) : (tsum fun (b : \u03b2) => f b) \u2264 0 := sorry\n\ntheorem le_has_sum' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [canonically_ordered_add_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} {a : \u03b1} (hf : has_sum f a) (b : \u03b2) : f b \u2264 a :=\n  le_has_sum hf b fun (_x : \u03b2) (_x_1 : _x \u2260 b) => zero_le (f _x)\n\ntheorem le_tsum' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [canonically_ordered_add_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} (hf : summable f) (b : \u03b2) : f b \u2264 tsum fun (b : \u03b2) => f b :=\n  le_tsum hf b fun (_x : \u03b2) (_x_1 : _x \u2260 b) => zero_le (f _x)\n\ntheorem has_sum_zero_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [canonically_ordered_add_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} : has_sum f 0 \u2194 \u2200 (x : \u03b2), f x = 0 := sorry\n\ntheorem tsum_eq_zero_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [canonically_ordered_add_monoid \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] {f : \u03b2 \u2192 \u03b1} (hf : summable f) : (tsum fun (i : \u03b2) => f i) = 0 \u2194 \u2200 (x : \u03b2), f x = 0 := sorry\n\ntheorem summable_iff_cauchy_seq_finset {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [complete_space \u03b1] {f : \u03b2 \u2192 \u03b1} : summable f \u2194 cauchy_seq fun (s : finset \u03b2) => finset.sum s fun (b : \u03b2) => f b :=\n  iff.symm cauchy_map_iff_exists_tendsto\n\ntheorem cauchy_seq_finset_iff_vanishing {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} : (cauchy_seq fun (s : finset \u03b2) => finset.sum s fun (b : \u03b2) => f b) \u2194\n  \u2200 (e : set \u03b1), e \u2208 nhds 0 \u2192 \u2203 (s : finset \u03b2), \u2200 (t : finset \u03b2), disjoint t s \u2192 (finset.sum t fun (b : \u03b2) => f b) \u2208 e := sorry\n\ntheorem summable_iff_vanishing {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} [complete_space \u03b1] : summable f \u2194\n  \u2200 (e : set \u03b1), e \u2208 nhds 0 \u2192 \u2203 (s : finset \u03b2), \u2200 (t : finset \u03b2), disjoint t s \u2192 (finset.sum t fun (b : \u03b2) => f b) \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} [complete_space \u03b1] (hf : summable f) (h : \u2200 (b : \u03b2), g b = 0 \u2228 g b = f b) : summable g := sorry\n\nprotected theorem summable.indicator {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} [complete_space \u03b1] (hf : summable f) (s : set \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} [complete_space \u03b1] {i : \u03b3 \u2192 \u03b2} (hf : summable f) (hi : function.injective i) : summable (f \u2218 i) := sorry\n\ntheorem summable.subtype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} [complete_space \u03b1] (hf : summable f) (s : set \u03b2) : summable (f \u2218 coe) :=\n  summable.comp_injective hf subtype.coe_injective\n\ntheorem summable_subtype_and_compl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] {f : \u03b2 \u2192 \u03b1} [complete_space \u03b1] {s : set \u03b2} : ((summable fun (x : \u21a5s) => f \u2191x) \u2227 summable fun (x : \u21a5(s\u1d9c)) => f \u2191x) \u2194 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\u1d9c) } }\n\ntheorem summable.sigma_factor {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [complete_space \u03b1] {\u03b3 : \u03b2 \u2192 Type u_3} {f : (sigma fun (b : \u03b2) => \u03b3 b) \u2192 \u03b1} (ha : summable f) (b : \u03b2) : summable fun (c : \u03b3 b) => f (sigma.mk b c) :=\n  summable.comp_injective ha sigma_mk_injective\n\ntheorem summable.sigma {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [complete_space \u03b1] [regular_space \u03b1] {\u03b3 : \u03b2 \u2192 Type u_3} {f : (sigma fun (b : \u03b2) => \u03b3 b) \u2192 \u03b1} (ha : summable f) : summable fun (b : \u03b2) => tsum fun (c : \u03b3 b) => f (sigma.mk b c) :=\n  summable.sigma' ha fun (b : \u03b2) => summable.sigma_factor ha b\n\ntheorem summable.prod_factor {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [complete_space \u03b1] {f : \u03b2 \u00d7 \u03b3 \u2192 \u03b1} (h : summable f) (b : \u03b2) : summable fun (c : \u03b3) => f (b, c) :=\n  summable.comp_injective h\n    fun (c\u2081 c\u2082 : \u03b3) (h : (fun (c : \u03b3) => (b, c)) c\u2081 = (fun (c : \u03b3) => (b, c)) c\u2082) => and.right (iff.mp prod.ext_iff h)\n\ntheorem tsum_sigma {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [complete_space \u03b1] [regular_space \u03b1] {\u03b3 : \u03b2 \u2192 Type u_3} {f : (sigma fun (b : \u03b2) => \u03b3 b) \u2192 \u03b1} (ha : summable f) : (tsum fun (p : sigma fun (b : \u03b2) => \u03b3 b) => f p) = tsum fun (b : \u03b2) => tsum fun (c : \u03b3 b) => f (sigma.mk b c) :=\n  tsum_sigma' (fun (b : \u03b2) => summable.sigma_factor ha b) ha\n\ntheorem tsum_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [complete_space \u03b1] [regular_space \u03b1] {f : \u03b2 \u00d7 \u03b3 \u2192 \u03b1} (h : summable f) : (tsum fun (p : \u03b2 \u00d7 \u03b3) => f p) = tsum fun (b : \u03b2) => tsum fun (c : \u03b3) => f (b, c) :=\n  tsum_prod' h (summable.prod_factor h)\n\ntheorem tsum_comm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [uniform_space \u03b1] [uniform_add_group \u03b1] [complete_space \u03b1] [regular_space \u03b1] {f : \u03b2 \u2192 \u03b3 \u2192 \u03b1} (h : summable (function.uncurry f)) : (tsum fun (c : \u03b3) => tsum fun (b : \u03b2) => f b c) = tsum fun (b : \u03b2) => tsum fun (c : \u03b3) => f b c :=\n  tsum_comm' h (summable.prod_factor h) (summable.prod_factor (summable.prod_symm h))\n\ntheorem summable.vanishing {\u03b1 : Type u_1} {G : Type u_5} [topological_space G] [add_comm_group G] [topological_add_group G] {f : \u03b1 \u2192 G} (hf : summable f) {e : set G} (he : e \u2208 nhds 0) : \u2203 (s : finset \u03b1), \u2200 (t : finset \u03b1), disjoint t s \u2192 (finset.sum t fun (k : \u03b1) => f k) \u2208 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 {\u03b1 : Type u_1} {G : Type u_5} [topological_space G] [add_comm_group G] [topological_add_group G] {f : \u03b1 \u2192 G} (hf : summable f) : filter.tendsto f filter.cofinite (nhds 0) := sorry\n\ntheorem summable_abs_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_ordered_add_comm_group \u03b2] [uniform_space \u03b2] [uniform_add_group \u03b2] [complete_space \u03b2] {f : \u03b1 \u2192 \u03b2} : (summable fun (x : \u03b1) => abs (f x)) \u2194 summable f := sorry\n\ntheorem summable.of_abs {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_ordered_add_comm_group \u03b2] [uniform_space \u03b2] [uniform_add_group \u03b2] [complete_space \u03b2] {f : \u03b1 \u2192 \u03b2} : (summable fun (x : \u03b1) => abs (f x)) \u2192 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 {\u03b1 : Type u_1} [emetric_space \u03b1] {f : \u2115 \u2192 \u03b1} (d : \u2115 \u2192 nnreal) (hf : \u2200 (n : \u2115), edist (f n) (f (Nat.succ n)) \u2264 \u2191(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 {\u03b1 : Type u_1} [metric_space \u03b1] {f : \u2115 \u2192 \u03b1} (d : \u2115 \u2192 \u211d) (hf : \u2200 (n : \u2115), dist (f n) (f (Nat.succ n)) \u2264 d n) (hd : summable d) : cauchy_seq f := sorry\n\ntheorem cauchy_seq_of_summable_dist {\u03b1 : Type u_1} [metric_space \u03b1] {f : \u2115 \u2192 \u03b1} (h : summable fun (n : \u2115) => dist (f n) (f (Nat.succ n))) : cauchy_seq f :=\n  cauchy_seq_of_dist_le_of_summable (fun (n : \u2115) => dist (f n) (f (Nat.succ n)))\n    (fun (_x : \u2115) => le_refl (dist (f _x) (f (Nat.succ _x)))) h\n\ntheorem dist_le_tsum_of_dist_le_of_tendsto {\u03b1 : Type u_1} [metric_space \u03b1] {f : \u2115 \u2192 \u03b1} (d : \u2115 \u2192 \u211d) (hf : \u2200 (n : \u2115), dist (f n) (f (Nat.succ n)) \u2264 d n) (hd : summable d) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) (n : \u2115) : dist (f n) a \u2264 tsum fun (m : \u2115) => d (n + m) := sorry\n\ntheorem dist_le_tsum_of_dist_le_of_tendsto\u2080 {\u03b1 : Type u_1} [metric_space \u03b1] {f : \u2115 \u2192 \u03b1} (d : \u2115 \u2192 \u211d) (hf : \u2200 (n : \u2115), dist (f n) (f (Nat.succ n)) \u2264 d n) (hd : summable d) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) : dist (f 0) a \u2264 tsum d := sorry\n\ntheorem dist_le_tsum_dist_of_tendsto {\u03b1 : Type u_1} [metric_space \u03b1] {f : \u2115 \u2192 \u03b1} (h : summable fun (n : \u2115) => dist (f n) (f (Nat.succ n))) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) (n : \u2115) : dist (f n) a \u2264 tsum fun (m : \u2115) => dist (f (n + m)) (f (Nat.succ (n + m))) :=\n  (fun (this : dist (f n) a \u2264 tsum fun (m : \u2115) => (fun (n : \u2115) => dist (f n) (f (Nat.succ n))) (n + m)) => this)\n    (dist_le_tsum_of_dist_le_of_tendsto (fun (n : \u2115) => dist (f n) (f (Nat.succ n)))\n      (fun (_x : \u2115) => le_refl (dist (f _x) (f (Nat.succ _x)))) h ha n)\n\ntheorem dist_le_tsum_dist_of_tendsto\u2080 {\u03b1 : Type u_1} [metric_space \u03b1] {f : \u2115 \u2192 \u03b1} (h : summable fun (n : \u2115) => dist (f n) (f (Nat.succ n))) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) : dist (f 0) a \u2264 tsum fun (n : \u2115) => 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 \u03b1 \u03c3` is a realization of a filter (base) on `\u03b1`,\n  represented by a type `\u03c3` together with operations for the top element and\n  the binary inf operation. -/\nstructure cfilter (\u03b1 : Type u_1) (\u03c3 : Type u_2) [partial_order \u03b1] \nwhere\n  f : \u03c3 \u2192 \u03b1\n  pt : \u03c3\n  inf : \u03c3 \u2192 \u03c3 \u2192 \u03c3\n  inf_le_left : \u2200 (a b : \u03c3), f (inf a b) \u2264 f a\n  inf_le_right : \u2200 (a b : \u03c3), f (inf a b) \u2264 f b\n\nnamespace cfilter\n\n\nprotected instance has_coe_to_fun {\u03b1 : Type u_1} {\u03c3 : Type u_3} [partial_order \u03b1] : has_coe_to_fun (cfilter \u03b1 \u03c3) :=\n  has_coe_to_fun.mk (fun (x : cfilter \u03b1 \u03c3) => \u03c3 \u2192 \u03b1) f\n\n@[simp] theorem coe_mk {\u03b1 : Type u_1} {\u03c3 : Type u_3} [partial_order \u03b1] (f : \u03c3 \u2192 \u03b1) (pt : \u03c3) (inf : \u03c3 \u2192 \u03c3 \u2192 \u03c3) (h\u2081 : \u2200 (a b : \u03c3), f (inf a b) \u2264 f a) (h\u2082 : \u2200 (a b : \u03c3), f (inf a b) \u2264 f b) (a : \u03c3) : coe_fn (mk f pt inf h\u2081 h\u2082) a = f a :=\n  rfl\n\n/-- Map a cfilter to an equivalent representation type. -/\ndef of_equiv {\u03b1 : Type u_1} {\u03c3 : Type u_3} {\u03c4 : Type u_4} [partial_order \u03b1] (E : \u03c3 \u2243 \u03c4) : cfilter \u03b1 \u03c3 \u2192 cfilter \u03b1 \u03c4 :=\n  sorry\n\n@[simp] theorem of_equiv_val {\u03b1 : Type u_1} {\u03c3 : Type u_3} {\u03c4 : Type u_4} [partial_order \u03b1] (E : \u03c3 \u2243 \u03c4) (F : cfilter \u03b1 \u03c3) (a : \u03c4) : 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 {\u03b1 : Type u_1} {\u03c3 : Type u_3} (F : cfilter (set \u03b1) \u03c3) : filter \u03b1 :=\n  filter.mk (set_of fun (a : set \u03b1) => \u2203 (b : \u03c3), coe_fn F b \u2286 a) sorry sorry sorry\n\n@[simp] theorem mem_to_filter_sets {\u03b1 : Type u_1} {\u03c3 : Type u_3} (F : cfilter (set \u03b1) \u03c3) {a : set \u03b1} : a \u2208 to_filter F \u2194 \u2203 (b : \u03c3), coe_fn F b \u2286 a :=\n  iff.rfl\n\nend cfilter\n\n\n/-- A realizer for filter `f` is a cfilter which generates `f`. -/\nstructure filter.realizer {\u03b1 : Type u_1} (f : filter \u03b1) \nwhere\n  \u03c3 : Type u_5\n  F : cfilter (set \u03b1) \u03c3\n  eq : cfilter.to_filter F = f\n\nprotected def cfilter.to_realizer {\u03b1 : Type u_1} {\u03c3 : Type u_3} (F : cfilter (set \u03b1) \u03c3) : filter.realizer (cfilter.to_filter F) :=\n  filter.realizer.mk \u03c3 F sorry\n\nnamespace filter.realizer\n\n\ntheorem mem_sets {\u03b1 : Type u_1} {f : filter \u03b1} (F : realizer f) {a : set \u03b1} : a \u2208 f \u2194 \u2203 (b : \u03c3 F), coe_fn (F F) b \u2286 a := sorry\n\n-- Used because it has better definitional equalities than the eq.rec proof\n\ndef of_eq {\u03b1 : Type u_1} {f : filter \u03b1} {g : filter \u03b1} (e : f = g) (F : realizer f) : realizer g :=\n  mk (\u03c3 F) (F F) sorry\n\n/-- A filter realizes itself. -/\ndef of_filter {\u03b1 : Type u_1} (f : filter \u03b1) : realizer f :=\n  mk (\u21a5(sets f))\n    (cfilter.mk subtype.val { val := set.univ, property := univ_mem_sets } (fun (_x : \u21a5(sets f)) => sorry) sorry sorry)\n    sorry\n\n/-- Transfer a filter realizer to another realizer on a different base type. -/\ndef of_equiv {\u03b1 : Type u_1} {\u03c4 : Type u_4} {f : filter \u03b1} (F : realizer f) (E : \u03c3 F \u2243 \u03c4) : realizer f :=\n  mk \u03c4 (cfilter.of_equiv E (F F)) sorry\n\n@[simp] theorem of_equiv_\u03c3 {\u03b1 : Type u_1} {\u03c4 : Type u_4} {f : filter \u03b1} (F : realizer f) (E : \u03c3 F \u2243 \u03c4) : \u03c3 (of_equiv F E) = \u03c4 :=\n  rfl\n\n@[simp] theorem of_equiv_F {\u03b1 : Type u_1} {\u03c4 : Type u_4} {f : filter \u03b1} (F : realizer f) (E : \u03c3 F \u2243 \u03c4) (s : \u03c4) : 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 {\u03b1 : Type u_1} (s : set \u03b1) : 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_\u03c3 {\u03b1 : Type u_1} (s : set \u03b1) : \u03c3 (realizer.principal s) = Unit :=\n  rfl\n\n@[simp] theorem principal_F {\u03b1 : Type u_1} (s : set \u03b1) (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 {\u03b1 : Type u_1} : realizer \u22a4 :=\n  of_eq principal_univ (realizer.principal set.univ)\n\n@[simp] theorem top_\u03c3 {\u03b1 : Type u_1} : \u03c3 realizer.top = Unit :=\n  rfl\n\n@[simp] theorem top_F {\u03b1 : 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 {\u03b1 : Type u_1} : realizer \u22a5 :=\n  of_eq principal_empty (realizer.principal \u2205)\n\n@[simp] theorem bot_\u03c3 {\u03b1 : Type u_1} : \u03c3 realizer.bot = Unit :=\n  rfl\n\n@[simp] theorem bot_F {\u03b1 : Type u_1} (u : Unit) : coe_fn (F realizer.bot) u = \u2205 :=\n  rfl\n\n/-- Construct a realizer for `map m f` given a realizer for `f` -/\nprotected def map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (m : \u03b1 \u2192 \u03b2) {f : filter \u03b1} (F : realizer f) : realizer (map m f) :=\n  mk (\u03c3 F) (cfilter.mk (fun (s : \u03c3 F) => m '' coe_fn (F F) s) (cfilter.pt (F F)) (cfilter.inf (F F)) sorry sorry) sorry\n\n@[simp] theorem map_\u03c3 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (m : \u03b1 \u2192 \u03b2) {f : filter \u03b1} (F : realizer f) : \u03c3 (realizer.map m F) = \u03c3 F :=\n  rfl\n\n@[simp] theorem map_F {\u03b1 : Type u_1} {\u03b2 : Type u_2} (m : \u03b1 \u2192 \u03b2) {f : filter \u03b1} (F : realizer f) (s : \u03c3 (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (m : \u03b1 \u2192 \u03b2) {f : filter \u03b2} (F : realizer f) : realizer (comap m f) :=\n  mk (\u03c3 F) (cfilter.mk (fun (s : \u03c3 F) => m \u207b\u00b9' 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 {\u03b1 : Type u_1} {f : filter \u03b1} {g : filter \u03b1} (F : realizer f) (G : realizer g) : realizer (f \u2294 g) :=\n  mk (\u03c3 F \u00d7 \u03c3 G)\n    (cfilter.mk (fun (_x : \u03c3 F \u00d7 \u03c3 G) => sorry) (cfilter.pt (F F), cfilter.pt (F G)) (fun (_x : \u03c3 F \u00d7 \u03c3 G) => sorry) sorry\n      sorry)\n    sorry\n\n/-- Construct a realizer for the inf of two filters -/\nprotected def inf {\u03b1 : Type u_1} {f : filter \u03b1} {g : filter \u03b1} (F : realizer f) (G : realizer g) : realizer (f \u2293 g) :=\n  mk (\u03c3 F \u00d7 \u03c3 G)\n    (cfilter.mk (fun (_x : \u03c3 F \u00d7 \u03c3 G) => sorry) (cfilter.pt (F F), cfilter.pt (F G)) (fun (_x : \u03c3 F \u00d7 \u03c3 G) => sorry) sorry\n      sorry)\n    sorry\n\n/-- Construct a realizer for the cofinite filter -/\nprotected def cofinite {\u03b1 : Type u_1} [DecidableEq \u03b1] : realizer cofinite :=\n  mk (finset \u03b1) (cfilter.mk (fun (s : finset \u03b1) => set_of fun (a : \u03b1) => \u00aca \u2208 s) \u2205 has_union.union sorry sorry) sorry\n\n/-- Construct a realizer for filter bind -/\nprotected def bind {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : filter \u03b1} {m : \u03b1 \u2192 filter \u03b2} (F : realizer f) (G : (i : \u03b1) \u2192 realizer (m i)) : realizer (bind f m) :=\n  mk (sigma fun (s : \u03c3 F) => (i : \u03b1) \u2192 i \u2208 coe_fn (F F) s \u2192 \u03c3 (G i))\n    (cfilter.mk (fun (_x : sigma fun (s : \u03c3 F) => (i : \u03b1) \u2192 i \u2208 coe_fn (F F) s \u2192 \u03c3 (G i)) => sorry)\n      (sigma.mk (cfilter.pt (F F)) fun (i : \u03b1) (H : i \u2208 coe_fn (F F) (cfilter.pt (F F))) => cfilter.pt (F (G i)))\n      (fun (_x : sigma fun (s : \u03c3 F) => (i : \u03b1) \u2192 i \u2208 coe_fn (F F) s \u2192 \u03c3 (G i)) => sorry) sorry sorry)\n    sorry\n\n/-- Construct a realizer for indexed supremum -/\nprotected def Sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 filter \u03b2} (F : (i : \u03b1) \u2192 realizer (f i)) : realizer (supr fun (i : \u03b1) => f i) :=\n  let F' : realizer (supr fun (i : \u03b1) => f i) := of_eq sorry (realizer.bind realizer.top F);\n  of_equiv F'\n    ((fun (this : (sigma fun (u : Unit) => (i : \u03b1) \u2192 True \u2192 \u03c3 (F i)) \u2243 ((i : \u03b1) \u2192 \u03c3 (F i))) => this)\n      (equiv.mk (fun (_x : sigma fun (u : Unit) => (i : \u03b1) \u2192 True \u2192 \u03c3 (F i)) => sorry)\n        (fun (f_1 : (i : \u03b1) \u2192 \u03c3 (F i)) => sigma.mk Unit.unit fun (i : \u03b1) (_x : True) => f_1 i) sorry sorry))\n\n/-- Construct a realizer for the product of filters -/\nprotected def prod {\u03b1 : Type u_1} {f : filter \u03b1} {g : filter \u03b1} (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 {\u03b1 : Type u_1} {f : filter \u03b1} {g : filter \u03b1} (F : realizer f) (G : realizer g) : f \u2264 g \u2194 \u2200 (b : \u03c3 G), \u2203 (a : \u03c3 F), coe_fn (F F) a \u2264 coe_fn (F G) b := sorry\n\ntheorem tendsto_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) {l\u2081 : filter \u03b1} {l\u2082 : filter \u03b2} (L\u2081 : realizer l\u2081) (L\u2082 : realizer l\u2082) : tendsto f l\u2081 l\u2082 \u2194 \u2200 (b : \u03c3 L\u2082), \u2203 (a : \u03c3 L\u2081), \u2200 (x : \u03b1), x \u2208 coe_fn (F L\u2081) a \u2192 f x \u2208 coe_fn (F L\u2082) b :=\n  iff.trans (le_iff (realizer.map f L\u2081) L\u2082)\n    (forall_congr fun (b : \u03c3 L\u2082) => exists_congr fun (a : \u03c3 (realizer.map f L\u2081)) => set.image_subset_iff)\n\ntheorem ne_bot_iff {\u03b1 : Type u_1} {f : filter \u03b1} (F : realizer f) : f \u2260 \u22a5 \u2194 \u2200 (a : \u03c3 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.\u03bc X Y \u226b app (X \u2297 Y) = (app X \u2297 app Y) \u226b G.\u03bc 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nopen CategoryTheory.Category\n\nopen CategoryTheory.Functor\n\nnamespace CategoryTheory\n\nopen MonoidalCategory\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] [MonoidalCategory.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} D]\n  [MonoidalCategory.{v\u2082} 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.\u03bc X Y \u226b app (X \u2297 Y) = (app X \u2297 app Y) \u226b G.\u03bc X Y`\n-/\n@[ext]\nstructure MonoidalNatTrans (F G : LaxMonoidalFunctor C D) extends\n  NatTrans F.toFunctor G.toFunctor where\n  unit' : F.\u03b5 \u226b app (\ud835\udfd9_ C) = G.\u03b5 := by obviously\n  tensor' : \u2200 X Y, F.\u03bc _ _ \u226b app (X \u2297 Y) = (app X \u2297 app Y) \u226b G.\u03bc _ _ := 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  { \ud835\udfd9 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  \u27e8id F\u27e9\n\n#print CategoryTheory.MonoidalNatTrans.vcomp /-\n/-- Vertical composition of monoidal natural transformations.\n-/\n@[simps]\ndef vcomp {F G H : LaxMonoidalFunctor C D} (\u03b1 : MonoidalNatTrans F G) (\u03b2 : MonoidalNatTrans G H) :\n    MonoidalNatTrans F H :=\n  { NatTrans.vcomp \u03b1.toNatTrans \u03b2.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 \u03b1 \u03b2 := vcomp \u03b1 \u03b2\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} {\u03b1 : F \u27f6 G} {\u03b2 : G \u27f6 H} :\n    (\u03b1 \u226b \u03b2).toNatTrans = @CategoryStruct.comp (C \u2964 D) _ _ _ _ \u03b1.toNatTrans \u03b2.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} {\u03b1 : F \u27f6 G} {\u03b2 : G \u27f6 H} :\n    (\u03b1 \u226b \u03b2).toNatTrans = @CategoryStruct.comp (C \u2964 D) _ _ _ _ \u03b1.toNatTrans \u03b2.toNatTrans :=\n  rfl\n#align category_theory.monoidal_nat_trans.comp_to_nat_trans CategoryTheory.MonoidalNatTrans.comp_toNatTrans\n-/\n\nvariable {E : Type u\u2083} [Category.{v\u2083} E] [MonoidalCategory.{v\u2083} 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} (\u03b1 : MonoidalNatTrans F G)\n    (\u03b2 : MonoidalNatTrans H K) : MonoidalNatTrans (F \u2297\u22d9 H) (G \u2297\u22d9 K) :=\n  {\n    NatTrans.hcomp \u03b1.toNatTrans\n      \u03b2.toNatTrans with\n    unit' := by\n      dsimp; simp\n      conv_lhs => rw [\u2190 K.to_functor.map_comp, \u03b1.unit]\n    tensor' := fun X Y => by\n      dsimp; simp\n      conv_lhs => rw [\u2190 K.to_functor.map_comp, \u03b1.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} (\u03b1 : MonoidalNatTrans F G)\n    (\u03b2 : MonoidalNatTrans H K) : MonoidalNatTrans (F.prod' H) (G.prod' K)\n    where app X := (\u03b1.app X, \u03b2.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.\u03b5.{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.\u03b5.{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.\u03bc.{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.\u03bc.{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.\u03b5.{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.\u03b5.{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.\u03bc.{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.\u03bc.{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\u2093'. -/\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 : \u2200 X : C, F.obj X \u2245 G.obj X)\n    (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), F.map f \u226b (app Y).Hom = (app X).Hom \u226b G.map f)\n    (unit : F.\u03b5 \u226b (app (\ud835\udfd9_ C)).Hom = G.\u03b5)\n    (tensor : \u2200 X Y, F.\u03bc X Y \u226b (app (X \u2297 Y)).Hom = ((app X).Hom \u2297 (app Y).Hom) \u226b G.\u03bc X Y) : F \u2245 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 [\u2190 Unit, assoc, iso.hom_inv_id, comp_id]\n      tensor' := fun X Y => by\n        dsimp\n        rw [iso.comp_inv_eq, assoc, tensor, \u2190 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.\u03b5.{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.\u03b5.{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.\u03bc.{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.\u03bc.{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.\u03b5.{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.\u03b5.{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.\u03bc.{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.\u03bc.{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\u2093'. -/\n@[simp]\ntheorem ofComponents.hom_app (app : \u2200 X : C, F.obj X \u2245 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.\u03b5.{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.\u03b5.{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.\u03bc.{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.\u03bc.{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.\u03b5.{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.\u03b5.{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.\u03bc.{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.\u03bc.{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\u2093'. -/\n@[simp]\ntheorem ofComponents.inv_app (app : \u2200 X : C, F.obj X \u2245 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} (\u03b1 : 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 \u03b1) 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 \u03b1\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} (\u03b1 : 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 \u03b1) 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 \u03b1\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\u2093'. -/\ninstance isIso_of_isIso_app (\u03b1 : F \u27f6 G) [\u2200 X : C, IsIso (\u03b1.app X)] : IsIso \u03b1 :=\n  \u27e8(IsIso.of_iso\n        (ofComponents (fun X => asIso (\u03b1.app X)) (fun X Y f => \u03b1.toNatTrans.naturality f) \u03b1.Unit\n          \u03b1.tensor)).1\u27e9\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 \u27f6 F.toLaxMonoidalFunctor \u2297\u22d9 (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 [\u2190 functor.map_comp]\n      erw [e.counit_app_functor, e.counit_app_functor, F.to_lax_monoidal_functor.\u03bc_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 [\u2190 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 : \u2200 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 \u2297\u22d9 F.toLaxMonoidalFunctor \u27f6 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, \u2190 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 [\u2190 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 : \u2200 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 \u2227 Q \u2192 Q \u2227 R \u2192 P \u2227 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 \u03b1 : Type u\n-- Author: Chris Hughes\n\ntheorem Q1 (S : set \u211d) (H1 : \u2203 s : \u211d, s \u2208 S) (H2 : \u2203 b : \u211d, \u2200 s : \u211d, s \u2208 S \u2192 s \u2264 b) :\n  \u2203 x : \u211d, is_lub S x \u2227 \n  \u2200 T : set \u211d, (T \u2286 S \u2227 \u2203 t : \u211d, t \u2208 T) \u2192 \u2203 y : \u211d, is_lub T y \u2227 y \u2264 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 \u2192 Type v} -- The family of types already equipped with instances\nvariables (x y : \u03a0 i, f i) (i : I)\n\nnamespace pi\n\n@[to_additive]\ninstance semigroup [\u2200 i, semigroup $ f i] : semigroup (\u03a0 i : I, f i) :=\nby refine_struct { mul := (*), .. }; tactic.pi_instance_derive_field\n\ninstance semigroup_with_zero [\u2200 i, semigroup_with_zero $ f i] :\n  semigroup_with_zero (\u03a0 i : I, f i) :=\nby refine_struct { zero := (0 : \u03a0 i, f i), mul := (*), .. }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance comm_semigroup [\u2200 i, comm_semigroup $ f i] : comm_semigroup (\u03a0 i : I, f i) :=\nby refine_struct { mul := (*), .. }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance mul_one_class [\u2200 i, mul_one_class $ f i] : mul_one_class (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 i, f i), mul := (*), .. }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance monoid [\u2200 i, monoid $ f i] : monoid (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 i, f i), mul := (*), npow := \u03bb 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 [\u2200 i, monoid $ f i] (n : \u2115) : (x^n) i = (x i)^n := rfl\n\n@[to_additive]\ninstance comm_monoid [\u2200 i, comm_monoid $ f i] : comm_monoid (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 i, f i), mul := (*), npow := monoid.npow };\ntactic.pi_instance_derive_field\n\n@[to_additive]\ninstance div_inv_monoid [\u2200 i, div_inv_monoid $ f i] :\n  div_inv_monoid (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 i, f i), mul := (*), inv := has_inv.inv, div := has_div.div,\n  npow := monoid.npow, zpow := \u03bb z x i, (x i) ^ z }; tactic.pi_instance_derive_field\n\n@[to_additive]\ninstance group [\u2200 i, group $ f i] : group (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 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 [\u2200 i, comm_group $ f i] : comm_group (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 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 [\u2200 i, left_cancel_semigroup $ f i] :\n  left_cancel_semigroup (\u03a0 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 [\u2200 i, right_cancel_semigroup $ f i] :\n  right_cancel_semigroup (\u03a0 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 [\u2200 i, left_cancel_monoid $ f i] :\n  left_cancel_monoid (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 i, f i), mul := (*), npow := monoid.npow };\ntactic.pi_instance_derive_field\n\n@[to_additive add_right_cancel_monoid]\ninstance right_cancel_monoid [\u2200 i, right_cancel_monoid $ f i] :\n  right_cancel_monoid (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 i, f i), mul := (*), npow := monoid.npow, .. };\ntactic.pi_instance_derive_field\n\n@[to_additive add_cancel_monoid]\ninstance cancel_monoid [\u2200 i, cancel_monoid $ f i] :\n  cancel_monoid (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 i, f i), mul := (*), npow := monoid.npow };\ntactic.pi_instance_derive_field\n\n@[to_additive add_cancel_comm_monoid]\ninstance cancel_comm_monoid [\u2200 i, cancel_comm_monoid $ f i] :\n  cancel_comm_monoid (\u03a0 i : I, f i) :=\nby refine_struct { one := (1 : \u03a0 i, f i), mul := (*), npow := monoid.npow };\ntactic.pi_instance_derive_field\n\ninstance mul_zero_class [\u2200 i, mul_zero_class $ f i] :\n  mul_zero_class (\u03a0 i : I, f i) :=\nby refine_struct { zero := (0 : \u03a0 i, f i), mul := (*), .. }; tactic.pi_instance_derive_field\n\ninstance mul_zero_one_class [\u2200 i, mul_zero_one_class $ f i] :\n  mul_zero_one_class (\u03a0 i : I, f i) :=\nby refine_struct { zero := (0 : \u03a0 i, f i), one := (1 : \u03a0 i, f i), mul := (*), .. };\n  tactic.pi_instance_derive_field\n\ninstance monoid_with_zero [\u2200 i, monoid_with_zero $ f i] :\n  monoid_with_zero (\u03a0 i : I, f i) :=\nby refine_struct { zero := (0 : \u03a0 i, f i), one := (1 : \u03a0 i, f i), mul := (*),\n  npow := monoid.npow }; tactic.pi_instance_derive_field\n\ninstance comm_monoid_with_zero [\u2200 i, comm_monoid_with_zero $ f i] :\n  comm_monoid_with_zero (\u03a0 i : I, f i) :=\nby refine_struct { zero := (0 : \u03a0 i, f i), one := (1 : \u03a0 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 \u2192 N) = \u03bb x, f x * g x := rfl\n\nend mul_hom\n\nsection monoid_hom\n\nvariables (f) [\u03a0 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) : (\u03a0 i, f i) \u2192* f i :=\n{ to_fun := \u03bb g, g i,\n  map_one' := pi.one_apply i,\n  map_mul' := \u03bb 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 (\u03b1 \u03b2 : Type*) [mul_one_class \u03b2] : \u03b2 \u2192* (\u03b1 \u2192 \u03b2) :=\n{ to_fun := function.const \u03b1,\n  map_one' := rfl,\n  map_mul' := \u03bb _ _, 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 (\u03b1 \u03b2 : Type*) [mul_one_class \u03b1] [comm_monoid \u03b2] : (\u03b1 \u2192* \u03b2) \u2192* (\u03b1 \u2192 \u03b2) :=\n{ to_fun := \u03bb g, g,\n  map_one' := rfl,\n  map_mul' := \u03bb x y, rfl, }\n\n/-- Monoid homomorphism between the function spaces `I \u2192 \u03b1` and `I \u2192 \u03b2`, induced by a monoid\nhomomorphism `f` between `\u03b1` and `\u03b2`. -/\n@[to_additive \"Additive monoid homomorphism between the function spaces `I \u2192 \u03b1` and `I \u2192 \u03b2`,\ninduced by an additive monoid homomorphism `f` between `\u03b1` and `\u03b2`\", simps]\nprotected def monoid_hom.comp_left {\u03b1 \u03b2 : Type*} [mul_one_class \u03b1] [mul_one_class \u03b2] (f : \u03b1 \u2192* \u03b2)\n  (I : Type*) :\n  (I \u2192 \u03b1) \u2192* (I \u2192 \u03b2) :=\n{ to_fun := \u03bb h, f \u2218 h,\n  map_one' := by ext; simp,\n  map_mul' := \u03bb _ _, 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 [\u03a0 i, has_one $ f i] (i : I) : one_hom (f i) (\u03a0 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 [\u03a0 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 [\u03a0 i, mul_one_class $ f i] (i : I) : f i \u2192* \u03a0 i, f i :=\n{ map_mul' := mul_single_op\u2082 (\u03bb _, (*)) (\u03bb _, one_mul _) _,\n  .. (one_hom.single f i) }\n\n@[simp, to_additive]\nlemma monoid_hom.single_apply [\u03a0 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 [\u03a0 i, mul_zero_class $ f i] (i : I) : mul_hom (f i) (\u03a0 i, f i) :=\n{ to_fun := single i,\n  map_mul' := pi.single_op\u2082 (\u03bb _, (*)) (\u03bb _, zero_mul _) _, }\n\nvariables {f}\n\n@[to_additive]\nlemma pi.mul_single_mul [\u03a0 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 [\u03a0 i, group $ f i] (i : I) (x : f i) :\n  mul_single i (x\u207b\u00b9) = (mul_single i x)\u207b\u00b9 :=\n(monoid_hom.single f i).map_inv x\n\n@[to_additive]\nlemma pi.single_div [\u03a0 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 [\u03a0 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 [\u03a0 i, mul_one_class $ f i] :\n  pairwise (\u03bb i j, \u2200 (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 [\u03a0 i, mul_one_class $ f i] (x : \u03a0 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 [\u03a0 i, group $ f i] (g : \u03a0 (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 [\u03a0 i, has_one (f i)] [decidable_eq I] (i : I) :\n  update (1 : \u03a0 i, f i) i 1 = 1 :=\nupdate_eq_self i 1\n\n@[to_additive]\nlemma update_mul [\u03a0 i, has_mul (f i)] [decidable_eq I]\n  (f\u2081 f\u2082 : \u03a0 i, f i) (i : I) (x\u2081 : f i) (x\u2082 : f i) :\n  update (f\u2081 * f\u2082) i (x\u2081 * x\u2082) = update f\u2081 i x\u2081 * update f\u2082 i x\u2082 :=\nfunext $ \u03bb j, (apply_update\u2082 (\u03bb i, (*)) f\u2081 f\u2082 i x\u2081 x\u2082 j).symm\n\n@[to_additive]\nlemma update_inv [\u03a0 i, has_inv (f i)] [decidable_eq I]\n  (f\u2081 : \u03a0 i, f i) (i : I) (x\u2081 : f i) :\n  update (f\u2081\u207b\u00b9) i (x\u2081\u207b\u00b9) = (update f\u2081 i x\u2081)\u207b\u00b9 :=\nfunext $ \u03bb j, (apply_update (\u03bb i, has_inv.inv) f\u2081 i x\u2081 j).symm\n\n@[to_additive]\nlemma update_div [\u03a0 i, has_div (f i)] [decidable_eq I]\n  (f\u2081 f\u2082 : \u03a0 i, f i) (i : I) (x\u2081 : f i) (x\u2082 : f i) :\n  update (f\u2081 / f\u2082) i (x\u2081 / x\u2082) = update f\u2081 i x\u2081 / update f\u2082 i x\u2082 :=\nfunext $ \u03bb j, (apply_update\u2082 (\u03bb i, (/)) f\u2081 f\u2082 i x\u2081 x\u2082 j).symm\n\nend function\n\nsection piecewise\n\n@[to_additive]\nlemma set.piecewise_mul [\u03a0 i, has_mul (f i)] (s : set I) [\u03a0 i, decidable (i \u2208 s)]\n  (f\u2081 f\u2082 g\u2081 g\u2082 : \u03a0 i, f i) :\n  s.piecewise (f\u2081 * f\u2082) (g\u2081 * g\u2082) = s.piecewise f\u2081 g\u2081 * s.piecewise f\u2082 g\u2082 :=\ns.piecewise_op\u2082 _ _ _ _ (\u03bb _, (*))\n\n@[to_additive]\nlemma set.piecewise_inv [\u03a0 i, has_inv (f i)] (s : set I) [\u03a0 i, decidable (i \u2208 s)]\n  (f\u2081 g\u2081 : \u03a0 i, f i) :\n  s.piecewise (f\u2081\u207b\u00b9) (g\u2081\u207b\u00b9) = (s.piecewise f\u2081 g\u2081)\u207b\u00b9 :=\ns.piecewise_op f\u2081 g\u2081 (\u03bb _ x, x\u207b\u00b9)\n\n@[to_additive]\nlemma set.piecewise_div [\u03a0 i, has_div (f i)] (s : set I) [\u03a0 i, decidable (i \u2208 s)]\n  (f\u2081 f\u2082 g\u2081 g\u2082 : \u03a0 i, f i) :\n  s.piecewise (f\u2081 / f\u2082) (g\u2081 / g\u2082) = s.piecewise f\u2081 g\u2081 / s.piecewise f\u2082 g\u2082 :=\ns.piecewise_op\u2082 _ _ _ _ (\u03bb _, (/))\n\nend piecewise\n\nsection extend\n\nvariables {\u03b9 : Type u} {\u03b7 : Type v} (R : Type w) (s : \u03b9 \u2192 \u03b7)\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] : (\u03b9 \u2192 R) \u2192* (\u03b7 \u2192 R) :=\n{ to_fun := \u03bb f, function.extend s f 1,\n  map_one' := function.extend_one s,\n  map_mul' := \u03bb 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, `\u2205` is bounded). In the literature the\ncobounded filter is generally referred to as the *filter at infinity*.\n\n## Main definitions\n\n- `Bornology \u03b1`: a class consisting of `cobounded : Filter \u03b1` 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 \u03b1` filter. For\n  `s : set \u03b1`, one should prefer `Bornology.IsCobounded s` over `s \u2208 cobounded \u03b1`.\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\u1d9c \u2208 cobounded \u03b1`.\n- `BoundedSpace \u03b1`: a class extending `Bornology \u03b1` with the condition\n  `Bornology.IsBounded (Set.univ : Set \u03b1)`\n\nAlthough use of `cobounded \u03b1` is discouraged for indicating the (co)boundedness of individual sets,\nit is intended for regular use as a filter on `\u03b1`.\n-/\n\n\nopen Set Filter\n\nvariable {\u03b9 \u03b1 \u03b2 : Type _}\n\n/-- A **bornology** on a type `\u03b1` 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 (\u03b1 : 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 `\u03b1` argument explciit. -/\n  cobounded' : Filter \u03b1\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 `\u03b1`\n  argument explciit. -/\n  le_cofinite' : cobounded' \u2264 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 (\u03b1 : Type _) [Bornology \u03b1] : Filter \u03b1 := Bornology.cobounded'\n#align bornology.cobounded Bornology.cobounded\n\nalias Bornology.cobounded \u2190 Bornology.Simps.cobounded\n\nlemma Bornology.le_cofinite (\u03b1 : Type _) [Bornology \u03b1] : cobounded \u03b1 \u2264 cofinite :=\nBornology.le_cofinite'\n#align bornology.le_cofinite Bornology.le_cofinite\n\ninitialize_simps_projections Bornology (cobounded' \u2192 cobounded)\n\n@[ext]\nlemma Bornology.ext (t t' : Bornology \u03b1)\n    (h_cobounded : @Bornology.cobounded \u03b1 t = @Bornology.cobounded \u03b1 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 \u03b1) :\n    t = t' \u2194 @Bornology.cobounded \u03b1 t = @Bornology.cobounded \u03b1 t' :=\n\u27e8congrArg _, Bornology.ext _ _\u27e9\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 {\u03b1 : Type _} (B : Set (Set \u03b1))\n    (empty_mem : \u2205 \u2208 B)\n    (subset_mem : \u2200 s\u2081 (_ : s\u2081 \u2208 B) s\u2082, s\u2082 \u2286 s\u2081 \u2192 s\u2082 \u2208 B)\n    (union_mem : \u2200 s\u2081 (_ : s\u2081 \u2208 B) s\u2082 (_ : s\u2082 \u2208 B), s\u2081 \u222a s\u2082 \u2208 B)\n    (singleton_mem : \u2200 x, {x} \u2208 B) : Bornology \u03b1\n    where\n  cobounded' :=\n    { sets := { s : Set \u03b1 | s\u1d9c \u2208 B }\n      univ_sets := by rwa [\u2190 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}\u1d9c\u1d9c \u2208 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' {\u03b1 : Type _} (B : Set (Set \u03b1))\n    (empty_mem : \u2205 \u2208 B)\n    (subset_mem : \u2200 s\u2081 (_ : s\u2081 \u2208 B) s\u2082, s\u2082 \u2286 s\u2081 \u2192 s\u2082 \u2208 B)\n    (union_mem : \u2200 s\u2081 (_ : s\u2081 \u2208 B) s\u2082 (_ : s\u2082 \u2208 B), s\u2081 \u222a s\u2082 \u2208 B)\n    (union\u209b_univ : \u22c3\u2080 B = univ) :\n    Bornology \u03b1 :=\n  Bornology.ofBounded B empty_mem subset_mem union_mem fun x =>\n    by\n    rw [union\u209b_eq_univ_iff] at union\u209b_univ\n    rcases union\u209b_univ x with \u27e8s, hs, hxs\u27e9\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 \u03b1] {s t : Set \u03b1} {x : \u03b1}\n\n/-- `IsCobounded` is the predicate that `s` is in the filter of cobounded sets in the ambient\nbornology on `\u03b1` -/\ndef IsCobounded (s : Set \u03b1) : Prop :=\n  s \u2208 cobounded \u03b1\n#align bornology.is_cobounded Bornology.IsCobounded\n\n/-- `IsBounded` is the predicate that `s` is bounded relative to the ambient bornology on `\u03b1`. -/\ndef IsBounded (s : Set \u03b1) : Prop :=\n  IsCobounded (s\u1d9c)\n#align bornology.is_bounded Bornology.IsBounded\n\ntheorem isCobounded_def {s : Set \u03b1} : IsCobounded s \u2194 s \u2208 cobounded \u03b1 :=\n  Iff.rfl\n#align bornology.is_cobounded_def Bornology.isCobounded_def\n\ntheorem isBounded_def {s : Set \u03b1} : IsBounded s \u2194 s\u1d9c \u2208 cobounded \u03b1 :=\n  Iff.rfl\n#align bornology.is_bounded_def Bornology.isBounded_def\n\n@[simp]\ntheorem isBounded_compl_iff : IsBounded (s\u1d9c) \u2194 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\u1d9c) \u2194 IsBounded s :=\n  Iff.rfl\n#align bornology.is_cobounded_compl_iff Bornology.isCobounded_compl_iff\n\nalias isBounded_compl_iff \u2194 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 \u2194 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 (\u2205 : Set \u03b1) := 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 \u03b1) := 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 \u03b1) :=\n  univ_mem\n#align bornology.is_cobounded_univ Bornology.isCobounded_univ\n\n@[simp]\ntheorem isCobounded_inter : IsCobounded (s \u2229 t) \u2194 IsCobounded s \u2227 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 \u2229 t) :=\n  isCobounded_inter.2 \u27e8hs, ht\u27e9\n#align bornology.is_cobounded.inter Bornology.IsCobounded.inter\n\n@[simp]\ntheorem isBounded_union : IsBounded (s \u222a t) \u2194 IsBounded s \u2227 IsBounded t := by\n  simp only [\u2190 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 \u222a t) :=\n  isBounded_union.2 \u27e8hs, ht\u27e9\n#align bornology.is_bounded.union Bornology.IsBounded.union\n\ntheorem IsCobounded.superset (hs : IsCobounded s) (ht : s \u2286 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 \u2286 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\u209b_bounded_univ : \u22c3\u2080 { s : Set \u03b1 | IsBounded s } = univ :=\n  union\u209b_eq_univ_iff.2 fun a => \u27e8{a}, isBounded_singleton, mem_singleton a\u27e9\n#align bornology.sUnion_bounded_univ Bornology.union\u209b_bounded_univ\n\ntheorem comap_cobounded_le_iff [Bornology \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    (cobounded \u03b2).comap f \u2264 cobounded \u03b1 \u2194 \u2200 \u2983s\u2984, IsBounded s \u2192 IsBounded (f '' s) := by\n  refine'\n    \u27e8fun h s hs => _, fun h t ht =>\n      \u27e8(f '' t\u1d9c)\u1d9c, h <| IsCobounded.compl ht, compl_subset_comm.1 <| subset_preimage_image _ _\u27e9\u27e9\n  obtain \u27e8t, ht, hts\u27e9 := h hs.compl\n  rw [subset_compl_comm, \u2190 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 \u03b1} :\n    t = t' \u2194 \u2200 s, (@cobounded \u03b1 t).sets s \u2194 (@cobounded \u03b1 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 \u03b1} :\n    t = t' \u2194 \u2200 s, @IsBounded \u03b1 t s \u2194 @IsBounded \u03b1 t' s :=\n  \u27e8fun h s => h \u25b8 Iff.rfl, fun h => by\n    ext s\n    simpa [@isBounded_def _ t, isBounded_def, compl_compl] using h (s\u1d9c)\u27e9\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 \u03b1}\n\ntheorem isCobounded_ofBounded_iff (B : Set (Set \u03b1)) {empty_mem subset_mem union_mem sUnion_univ} :\n    @IsCobounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s \u2194 s\u1d9c \u2208 B :=\n  Iff.rfl\n#align bornology.is_cobounded_of_bounded_iff Bornology.isCobounded_ofBounded_iff\n\ntheorem isBounded_ofBounded_iff (B : Set (Set \u03b1)) {empty_mem subset_mem union_mem sUnion_univ} :\n    @IsBounded _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ) s \u2194 s \u2208 B := by\n  rw [@isBounded_def _ (ofBounded B empty_mem subset_mem union_mem sUnion_univ), \u2190 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 \u03b1]\n\ntheorem isCobounded_binter\u1d62 {s : Set \u03b9} {f : \u03b9 \u2192 Set \u03b1} (hs : s.Finite) :\n    IsCobounded (\u22c2 i \u2208 s, f i) \u2194 \u2200 i \u2208 s, IsCobounded (f i) :=\n  binter\u1d62_mem hs\n#align bornology.is_cobounded_bInter Bornology.isCobounded_binter\u1d62\n\n@[simp]\ntheorem isCobounded_binter\u1d62_finset (s : Finset \u03b9) {f : \u03b9 \u2192 Set \u03b1} :\n    IsCobounded (\u22c2 i \u2208 s, f i) \u2194 \u2200 i \u2208 s, IsCobounded (f i) :=\n  binter\u1d62_finset_mem s\n#align bornology.is_cobounded_bInter_finset Bornology.isCobounded_binter\u1d62_finset\n\n@[simp]\ntheorem isCobounded_inter\u1d62 [Finite \u03b9] {f : \u03b9 \u2192 Set \u03b1} :\n    IsCobounded (\u22c2 i, f i) \u2194 \u2200 i, IsCobounded (f i) :=\n  inter\u1d62_mem\n#align bornology.is_cobounded_Inter Bornology.isCobounded_inter\u1d62\n\ntheorem isCobounded_inter\u209b {S : Set (Set \u03b1)} (hs : S.Finite) :\n    IsCobounded (\u22c2\u2080 S) \u2194 \u2200 s \u2208 S, IsCobounded s :=\n  inter\u209b_mem hs\n#align bornology.is_cobounded_sInter Bornology.isCobounded_inter\u209b\n\ntheorem isBounded_bunion\u1d62 {s : Set \u03b9} {f : \u03b9 \u2192 Set \u03b1} (hs : s.Finite) :\n    IsBounded (\u22c3 i \u2208 s, f i) \u2194 \u2200 i \u2208 s, IsBounded (f i) := by\n  simp only [\u2190 isCobounded_compl_iff, compl_union\u1d62, isCobounded_binter\u1d62 hs]\n#align bornology.is_bounded_bUnion Bornology.isBounded_bunion\u1d62\n\ntheorem isBounded_bunion\u1d62_finset (s : Finset \u03b9) {f : \u03b9 \u2192 Set \u03b1} :\n    IsBounded (\u22c3 i \u2208 s, f i) \u2194 \u2200 i \u2208 s, IsBounded (f i) :=\n  isBounded_bunion\u1d62 s.finite_toSet\n#align bornology.is_bounded_bUnion_finset Bornology.isBounded_bunion\u1d62_finset\n\ntheorem isBounded_union\u209b {S : Set (Set \u03b1)} (hs : S.Finite) :\n    IsBounded (\u22c3\u2080 S) \u2194 \u2200 s \u2208 S, IsBounded s := by rw [union\u209b_eq_bunion\u1d62, isBounded_bunion\u1d62 hs]\n#align bornology.is_bounded_sUnion Bornology.isBounded_union\u209b\n\n@[simp]\ntheorem isBounded_union\u1d62 [Finite \u03b9] {s : \u03b9 \u2192 Set \u03b1} : IsBounded (\u22c3 i, s i) \u2194 \u2200 i, IsBounded (s i) :=\n  by rw [\u2190 union\u209b_range, isBounded_union\u209b (finite_range s), forall_range_iff]\n#align bornology.is_bounded_Union Bornology.isBounded_union\u1d62\n\nend Bornology\n\nopen Bornology\n\ntheorem Set.Finite.isBounded [Bornology \u03b1] {s : Set \u03b1} (hs : s.Finite) : IsBounded s :=\n  Bornology.le_cofinite \u03b1 hs.compl_mem_cofinite\n#align set.finite.is_bounded Set.Finite.isBounded\n\ninstance : Bornology PUnit :=\n  \u27e8\u22a5, bot_le\u27e9\n\n/-- The cofinite filter as a bornology -/\n@[reducible]\ndef Bornology.cofinite : Bornology \u03b1\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 \u03b1` is bounded. -/\nclass BoundedSpace (\u03b1 : Type _) [Bornology \u03b1] : Prop where\n  /-- The `Set.univ` is bounded. -/\n  bounded_univ : Bornology.IsBounded (univ : Set \u03b1)\n#align bounded_space BoundedSpace\n\nnamespace Bornology\n\nvariable [Bornology \u03b1]\n\ntheorem isBounded_univ : IsBounded (univ : Set \u03b1) \u2194 BoundedSpace \u03b1 :=\n  \u27e8fun h => \u27e8h\u27e9, fun h => h.1\u27e9\n#align bornology.is_bounded_univ Bornology.isBounded_univ\n\ntheorem cobounded_eq_bot_iff : cobounded \u03b1 = \u22a5 \u2194 BoundedSpace \u03b1 := by\n  rw [\u2190 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 \u03b1]\n\ntheorem IsBounded.all (s : Set \u03b1) : 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 \u03b1) : IsCobounded s :=\n  compl_compl s \u25b8 IsBounded.all (s\u1d9c)\n#align bornology.is_cobounded.all Bornology.IsCobounded.all\n\nvariable (\u03b1)\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 {\u03b1 : Type _}\n\nnamespace Multiset\n\nsection Preorder\n\nvariable [Preorder \u03b1] [LocallyFiniteOrder \u03b1] {a b c : \u03b1}\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 \u2194 \u00aca \u2264 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 \u2194 \u00aca < 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 \u2194 \u00aca < 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 \u03b1] : Ioo a b = 0 \u2194 \u00aca < 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 \u2194 _ Icc_eq_zero\n#align multiset.Icc_eq_zero Multiset.Icc_eq_zero\n\nalias Ico_eq_zero_iff \u2194 _ Ico_eq_zero\n#align multiset.Ico_eq_zero Multiset.Ico_eq_zero\n\nalias Ioc_eq_zero_iff \u2194 _ 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 : \u00aca < 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 \u2264 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 \u2264 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 \u2264 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 \u2208 Icc a b \u2194 a \u2264 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 \u2208 Ico a b \u2194 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 \u2208 Icc a b \u2194 a \u2264 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 \u2208 Ioc a b \u2194 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 \u2209 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 \u2209 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 \u2209 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 \u2209 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 (\u00b7 < c)] (hca : c \u2264 a) :\n    ((Ico a b).filter\u2093 fun x => x < c) = \u2205 :=\n  by\n  rw [Ico, \u2190 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 (\u00b7 < c)] (hbc : b \u2264 c) :\n    ((Ico a b).filter\u2093 fun x => x < c) = Ico a b := by\n  rw [Ico, \u2190 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 (\u00b7 < c)] (hcb : c \u2264 b) :\n    ((Ico a b).filter\u2093 fun x => x < c) = Ico a c :=\n  by\n  rw [Ico, \u2190 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 ((\u00b7 \u2264 \u00b7) c)] (hca : c \u2264 a) :\n    ((Ico a b).filter\u2093 fun x => c \u2264 x) = Ico a b := by\n  rw [Ico, \u2190 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 ((\u00b7 \u2264 \u00b7) b)] :\n    ((Ico a b).filter\u2093 fun x => b \u2264 x) = \u2205 :=\n  by\n  rw [Ico, \u2190 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 ((\u00b7 \u2264 \u00b7) c)] (hac : a \u2264 c) :\n    ((Ico a b).filter\u2093 fun x => c \u2264 x) = Ico c b :=\n  by\n  rw [Ico, \u2190 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 \u03b1] [LocallyFiniteOrder \u03b1] {a b : \u03b1}\n\n#print Multiset.Icc_self /-\n@[simp]\ntheorem Icc_self (a : \u03b1) : 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 \u2264 b) : b ::\u2098 Ico a b = Icc a b := by\n  classical\n    rw [Ico, \u2190 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 ::\u2098 Ioo a b = Ico a b := by\n  classical\n    rw [Ioo, \u2190 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 : \u03b1} (h : b \u2264 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 \u03b1] {a b c d : \u03b1} (h : b \u2264 c) : Ico a b \u2229 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 : \u03b1} [DecidablePred (\u00b7 \u2264 a)] (hab : a < b) :\n    ((Ico a b).filter\u2093 fun x => x \u2264 a) = {a} :=\n  by\n  rw [Ico, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)] (a : \u03b1) (b : \u03b1), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)] (a : \u03b1) (b : \u03b1), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (instHSub.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) instSubNat) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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\u2093'. -/\ntheorem card_Ico_eq_card_Icc_sub_one (a b : \u03b1) : (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 {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)] (a : \u03b1) (b : \u03b1), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)] (a : \u03b1) (b : \u03b1), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (instHSub.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) instSubNat) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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\u2093'. -/\ntheorem card_Ioc_eq_card_Icc_sub_one (a b : \u03b1) : (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 {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)] (a : \u03b1) (b : \u03b1), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)] (a : \u03b1) (b : \u03b1), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (instHSub.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) instSubNat) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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\u2093'. -/\ntheorem card_Ioo_eq_card_Ico_sub_one (a b : \u03b1) : (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 {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)] (a : \u03b1) (b : \u03b1), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1)] (a : \u03b1) (b : \u03b1), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (HSub.hSub.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (instHSub.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) instSubNat) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2 a b)) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _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\u2093'. -/\ntheorem card_Ioo_eq_card_Icc_sub_two (a b : \u03b1) : (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 \u03b1] [LocallyFiniteOrder \u03b1] {a b c d : \u03b1}\n\n#print Multiset.Ico_subset_Ico_iff /-\ntheorem Ico_subset_Ico_iff {a\u2081 b\u2081 a\u2082 b\u2082 : \u03b1} (h : a\u2081 < b\u2081) :\n    Ico a\u2081 b\u2081 \u2286 Ico a\u2082 b\u2082 \u2194 a\u2082 \u2264 a\u2081 \u2227 b\u2081 \u2264 b\u2082 :=\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 : \u03b1} (hab : a \u2264 b) (hbc : b \u2264 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, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, Eq.{succ u1} (Multiset.{u1} \u03b1) (Inter.inter.{u1} (Multiset.{u1} \u03b1) (Multiset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => Eq.decidable.{u1} \u03b1 _inst_1 a b)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 a b) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 c d)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 (LinearOrder.max.{u1} \u03b1 _inst_1 a c) (LinearOrder.min.{u1} \u03b1 _inst_1 b d))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1)))))] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, Eq.{succ u1} (Multiset.{u1} \u03b1) (Inter.inter.{u1} (Multiset.{u1} \u03b1) (Multiset.instInterMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => instDecidableEq.{u1} \u03b1 _inst_1 a b)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 a b) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 c d)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 (Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_1) a c) (Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_1) b d))\nCase conversion may be inaccurate. Consider using '#align multiset.Ico_inter_Ico Multiset.Ico_inter_Ico\u2093'. -/\ntheorem Ico_inter_Ico : Ico a b \u2229 Ico c d = Ico (max a c) (min b d) := by\n  rw [Ico, Ico, Ico, \u2190 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 : \u03b1) : ((Ico a b).filter\u2093 fun x => x < c) = Ico a (min b c) := by\n  rw [Ico, Ico, \u2190 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 : \u03b1) : ((Ico a b).filter\u2093 fun x => c \u2264 x) = Ico (max a c) b := by\n  rw [Ico, Ico, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (HSub.hSub.{u1, u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (instHSub.{u1} (Multiset.{u1} \u03b1) (Multiset.hasSub.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => Eq.decidable.{u1} \u03b1 _inst_1 a b))) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 a b) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 a c)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 (LinearOrder.max.{u1} \u03b1 _inst_1 a c) b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1)))))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (HSub.hSub.{u1, u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (instHSub.{u1} (Multiset.{u1} \u03b1) (Multiset.instSubMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => instDecidableEq.{u1} \u03b1 _inst_1 a b))) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 a b) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 a c)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 (Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_1) a c) b)\nCase conversion may be inaccurate. Consider using '#align multiset.Ico_sub_Ico_left Multiset.Ico_sub_Ico_left\u2093'. -/\n@[simp]\ntheorem Ico_sub_Ico_left (a b c : \u03b1) : Ico a b - Ico a c = Ico (max a c) b := by\n  rw [Ico, Ico, Ico, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (HSub.hSub.{u1, u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (instHSub.{u1} (Multiset.{u1} \u03b1) (Multiset.hasSub.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => Eq.decidable.{u1} \u03b1 _inst_1 a b))) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 a b) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 c b)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 a (LinearOrder.min.{u1} \u03b1 _inst_1 b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1)))))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (HSub.hSub.{u1, u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (instHSub.{u1} (Multiset.{u1} \u03b1) (Multiset.instSubMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => instDecidableEq.{u1} \u03b1 _inst_1 a b))) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 a b) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 c b)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 a (Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_1) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.Ico_sub_Ico_right Multiset.Ico_sub_Ico_right\u2093'. -/\n@[simp]\ntheorem Ico_sub_Ico_right (a b c : \u03b1) : Ico a b - Ico c b = Ico a (min b c) := by\n  rw [Ico, Ico, Ico, \u2190 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 \u03b1] [ExistsAddOfLE \u03b1] [LocallyFiniteOrder \u03b1]\n\n/- warning: multiset.map_add_left_Icc -> Multiset.map_add_left_Icc is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 ((fun (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2608 : \u03b1) (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2610 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2608 x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2610) c) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c b))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_left_Icc Multiset.map_add_left_Icc\u2093'. -/\ntheorem map_add_left_Icc (a b c : \u03b1) : (Icc a b).map ((\u00b7 + \u00b7) c) = Icc (c + a) (c + b) := by\n  classical rw [Icc, Icc, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 ((fun (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2713 : \u03b1) (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2715 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2713 x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2715) c) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c b))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_left_Ico Multiset.map_add_left_Ico\u2093'. -/\ntheorem map_add_left_Ico (a b c : \u03b1) : (Ico a b).map ((\u00b7 + \u00b7) c) = Ico (c + a) (c + b) := by\n  classical rw [Ico, Ico, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 ((fun (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2818 : \u03b1) (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2820 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2818 x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2820) c) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c b))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_left_Ioc Multiset.map_add_left_Ioc\u2093'. -/\ntheorem map_add_left_Ioc (a b c : \u03b1) : (Ioc a b).map ((\u00b7 + \u00b7) c) = Ioc (c + a) (c + b) := by\n  classical rw [Ioc, Ioc, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 ((fun (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2923 : \u03b1) (x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2925 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2923 x._@.Mathlib.Data.Multiset.LocallyFinite._hyg.2925) c) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c a) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) c b))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_left_Ioo Multiset.map_add_left_Ioo\u2093'. -/\ntheorem map_add_left_Ioo (a b c : \u03b1) : (Ioo a b).map ((\u00b7 + \u00b7) c) = Ioo (c + a) (c + b) := by\n  classical rw [Ioo, Ioo, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (fun (x : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x c) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (fun (x : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x c) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_right_Icc Multiset.map_add_right_Icc\u2093'. -/\ntheorem map_add_right_Icc (a b c : \u03b1) : ((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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (fun (x : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x c) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (fun (x : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x c) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_right_Ico Multiset.map_add_right_Ico\u2093'. -/\ntheorem map_add_right_Ico (a b c : \u03b1) : ((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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (fun (x : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x c) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (fun (x : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x c) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ioc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_right_Ioc Multiset.map_add_right_Ioc\u2093'. -/\ntheorem map_add_right_Ioc (a b c : \u03b1) : ((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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (fun (x : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x c) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedCancelAddCommMonoid.{u1} \u03b1] [_inst_2 : ExistsAddOfLE.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))] [_inst_3 : LocallyFiniteOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.map.{u1, u1} \u03b1 \u03b1 (fun (x : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) x c) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 a b)) (Multiset.Ioo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)) _inst_3 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) a c) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddRightCancelMonoid.toAddMonoid.{u1} \u03b1 (AddCancelMonoid.toAddRightCancelMonoid.{u1} \u03b1 (AddCancelCommMonoid.toAddCancelMonoid.{u1} \u03b1 (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} \u03b1 _inst_1))))))) b c))\nCase conversion may be inaccurate. Consider using '#align multiset.map_add_right_Ioo Multiset.map_add_right_Ioo\u2093'. -/\ntheorem map_add_right_Ioo (a b c : \u03b1) : ((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 Advent\nimport Lean\n\nopen Lean.FromJson\nopen Lean (Json)\n\ninductive Packet where\n| Single: Nat -> Packet\n| Multiple: List Packet -> Packet\nderiving Lean.ToJson, Inhabited\n\nnamespace Packet\n\ndef separators : List Packet := \nlet wrap := Multiple \u2218 ([\u00b7]) \u2218 Multiple \u2218 ([\u00b7]) \u2218 Single\n[wrap 2, wrap 6]\n\ndef children : Packet -> List Packet\n| Single x => [Single x]\n| Multiple xs => xs\n\nabbrev IsSingle(p: Packet) := \u2203 n, p = Single n\n\ntheorem multNotSingle (xs): \u00ac IsSingle (Multiple xs) := by\n  intros ex\n  cases ex\n  contradiction\n\ndef isSingle?: (p: Packet) -> Decidable p.IsSingle\n| Single n => Decidable.isTrue (Exists.intro n (Eq.refl _))\n| Multiple xs => Decidable.isFalse <| multNotSingle xs\n\nmutual \ndef level: Packet -> Nat \n| Single _ => 0\n| Multiple xs => levels xs + 2\n\n\ndef levels: List Packet -> Nat\n| [] => 0\n| x :: xs => x.level + (levels xs) + 1\nend\n\ntheorem children_mult_levels {x : Packet} {ys : List Packet}: levels (children x) + levels ys < x.level + (Multiple ys).level := by \n  cases x <;> simp [children, levels, level]\n  . case Single x => \n    rw [Nat.add_comm]\n    apply Nat.lt_succ_self\n  . case Multiple xs => \n    conv => \n      rhs\n      rw [Nat.add_assoc]\n      conv => \n        rhs\n        rw [\u2190 Nat.add_assoc]\n        conv => \n          lhs\n          rw [Nat.add_comm]  \n        rw [Nat.add_assoc]\n        simp [Nat.add]\n      rw [\u2190Nat.add_assoc]\n    apply @Nat.add_lt_add_left 0\n    apply Nat.zero_lt_succ\n\ntheorem children_levels {x y : Packet} (p: \u00ac (x.IsSingle \u2227 y.IsSingle)) : levels x.children + levels y.children < x.level + y.level := by\n  cases x \n  . case Single x =>\n    cases y\n    . case Single y =>\n      apply False.elim\n      apply p\n      constructor\n      . exists x\n      . exists y\n    . case Multiple ys => \n      apply children_mult_levels\n  . case Multiple xs =>\n      conv => \n        lhs\n        rw [Nat.add_comm] \n      conv => \n        rhs\n        rw [Nat.add_comm] \n      apply children_mult_levels\n\n\n  \nprivate theorem sum_lt (x y: Nat): x < x + y + 1 := by \n  rw [Nat.add_assoc]\n  apply @Nat.add_lt_add_left 0\n  apply Nat.zero_lt_succ\n\nprivate theorem sum_lt' (x y: Nat): x < y + x + 1 := by \n  rw [Nat.add_comm y x]\n  apply sum_lt\n\n\nmutual\n  def comparePacket (xp yp : Packet): Ordering  :=\n  match xp.isSingle? &&& yp.isSingle? with\n  | isTrue p => \n    match xp, yp with\n    | Single x, Single y => compare x y \n    | Multiple xs , _ => absurd p.left <| multNotSingle xs \n    | _, Multiple ys => absurd p.right <| multNotSingle ys\n  | isFalse p => \n    have := children_levels p\n    comparePackets xp.children yp.children\n\n  def comparePackets: List Packet -> List Packet -> Ordering \n  | x :: xs, y :: ys => \n    have: level x + level y < levels (x :: xs) + levels (y :: ys) := by \n      apply Nat.add_lt_add <;> simp [levels] <;> apply sum_lt\n    have: levels xs + levels ys < levels (x :: xs) + levels (y :: ys) := by \n      apply Nat.add_lt_add <;> simp [levels] <;> apply sum_lt'\n    match comparePacket x y with \n    | Ordering.eq => comparePackets xs ys\n    | other => other\n  | [], [] => Ordering.eq  \n  | _ :: _, [] => Ordering.gt\n  | [], _ :: _ => Ordering.lt\nend \ntermination_by \n  comparePacket x y => x.level + y.level\n  comparePackets xs ys => levels xs + levels ys\n\ninstance : Ord Packet where\n  compare := comparePacket\n\ninstance : BEq Packet where\n  beq := (compare \u00b7 \u00b7 == Ordering.eq)\n\ninstance : LE Packet := leOfOrd\n \npartial def fromJsonImpl(j: Json): Except String Packet := do\n  try \n    let x <- fromJson? j\n    return Single x\n  catch _ => \n    let list : List Json <- fromJson? j\n    let packets <- list.mapM fromJsonImpl\n    return Multiple packets\n  \ninstance : Lean.FromJson Packet where\n  fromJson? := fromJsonImpl\n\nend Packet\n\ndef decode [Lean.FromJson \u03b1] (s: String): Except String \u03b1 := do\n  let json <- Json.parse s\n  fromJson? json\n\ndef parseIO (s: String): IO Packet := \n  match decode s with \n  | Except.ok x => pure x\n  | Except.error s => throw <| IO.userError s\n \ndef compareBlock: List Packet -> Bool\n| [x, y] => x <= y\n| b => panic! s!\"bad block {b}\"\n\n\ndef main : IO Unit := do\n  let blocks <- readBlocks 13\n  let parsedBlocks <- blocks.mapM (\u00b7.mapM parseIO)\n  let mut x : Nat := 0\n  for (i, b) in parsedBlocks.enum do\n    let bb := compareBlock b\n    IO.println (i + 1, bb)\n    if bb then \n      x := x + i + 1\n  IO.println x\n\n  let allPackets := Packet.separators.toArray ++ parsedBlocks.join.toArray\n  let sortedPackets := allPackets.qsort (\u00b7 <= \u00b7)\n  let sepIndex := Packet.separators \n                  |> List.filterMap (sortedPackets.indexOf? \u00b7) \n                  |> List.map (\u00b7.val + 1)\n  IO.println sepIndex\n  IO.println sepIndex.prod\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/day13.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835452961427, "lm_q2_score": 0.5813030906443133, "lm_q1q2_score": 0.48566916706311586}}
{"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 \u2295 unit \u2243 G :=\n{ to_fun := \u03bb x, sum.rec_on x (\u03bb tp, tp.target) (\u03bb _, default G),\n  inv_fun := \u03bb g, match g, (default $ T.path (default G) g) with \n                      | _, quiver.path.nil      := sum.inr ()\n                      | _, quiver.path.cons p e := sum.inl \u27e8_, _, e\u27e9\n                      end,\n  left_inv := begin\n    intro x,\n    rcases x with \u27e8a, b, e\u27e9 | \u27e8\u27e8\u27e9\u27e9,\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 : \u2203 p, default (T.path (default G) g) = p := \u27e8_, rfl\u27e9,\n    rcases this with \u27e8p, hp\u27e9,\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 \u00a1T] :\n  tree_symmy T \u2243 (\u00a1T).total :=\n{ to_fun := \u03bb ht, if h : (sum.inl ht.val.edge) \u2208 T ht.val.source ht.val.target\n                  then \u27e8_, _, sum.inl ht.val.edge, h\u27e9\n                  else \u27e8_, _, sum.inr ht.val.edge, or.resolve_left ht.property h\u27e9,\n  inv_fun := \u03bb t, match t with\n          | \u27e8a, b, sum.inl e, h\u27e9 := \u27e8\u27e8_, _, e\u27e9, or.inl h\u27e9\n          | \u27e8b, a, sum.inr e, h\u27e9 := \u27e8\u27e8_, _, e\u27e9, or.inr h\u27e9\n          end,\n  left_inv := begin\n    rintro \u27e8\u27e8a, b, e\u27e9, h\u27e9,\n    cases h,\n    { dsimp, rw dif_pos h, refl },\n    { dsimp, rw dif_neg, { refl },\n      intro h2, exact tree_not_both (\u00a1T) \u27e8sum.inl e, h2\u27e9 \u27e8sum.inr e, h\u27e9 }\n  end,\n  right_inv := begin\n    rintro \u27e8a, b, e, h\u27e9,\n    cases e,\n    { dsimp, rw dif_pos, refl },\n    { dsimp, rw dif_neg, { refl }, \n      intro hn, exact tree_not_both (\u00a1T) \u27e8sum.inl e, hn\u27e9 \u27e8sum.inr e, h\u27e9 }\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) \u00d7 X \u2243 (gpd_gens : quiver (action_category G X)).total :=\n{ to_fun := \u03bb p, \u27e8\u27e8(), p.snd\u27e9, \u27e8(), ((gp_emb p.fst) \u2022 p.snd : X)\u27e9, p.fst, rfl\u27e9,\n  inv_fun := \u03bb t, (t.edge, t.source.snd),\n  left_inv := by tidy,\n  right_inv := begin -- ugh\n    intro x, rcases x with \u27e8\u27e8\u27e8\u27e9, x\u27e9, \u27e8\u27e8\u27e9, y\u27e9, e, h\u27e9,\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) \u00d7 (quotient H) \u2295 unit \u2243 (gp_gens H) \u2295 (quotient H) :=\ncalc      (gp_gens G) \u00d7 (quotient H) \u2295 unit \n        \u2243 (gpd_gens : quiver $ action_category G (quotient H)).total \u2295 unit \n                : equiv.sum_congr action_gens_equiv (equiv.refl unit)\n    ... \u2243 ((gp_gens H) \u2295 tree_symmy _) \u2295 unit\n                : equiv.sum_congr (compl_sum_set_equiv _).symm (equiv.refl unit)\n    ... \u2243 (gp_gens H) \u2295 (tree_symmy (geodesic_subgraph (symmy gpd_gens)) \u2295 unit)\n                : equiv.sum_assoc _ _ _\n    ... \u2243 (gp_gens H) \u2295 ((quiver.total _) \u2295 unit)\n                : equiv.sum_congr (equiv.refl _) (equiv.sum_congr (tree_symmy_equiv _) (equiv.refl unit))\n    ... \u2243 (gp_gens H) \u2295 action_category G (quotient H)\n                : equiv.sum_congr (equiv.refl _) (tree_equiv _) \n    ... \u2243 (gp_gens H) \u2295 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 `\u2115` goals to `\u2124`\n\nIt is often easier to work in `\u2124`, where subtraction is well behaved, than in `\u2115` 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 `\u2115` to `\u2124`.\n`zify` lemmas should have the form `\u2200 a\u2081 ... a\u2099 : \u2115, Pz (a\u2081 : \u2124) ... (a\u2099 : \u2124) \u2194 Pn a\u2081 ... a\u2099`.\nFor example, `int.coe_nat_le_coe_nat_iff : \u2200 (m n : \u2115), \u2191m \u2264 \u2191n \u2194 m \u2264 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 \u2124).\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 `\u2200 a\u2081 ... a\u2099 : \u2115, Pz (a\u2081 : \u2124) ... (a\u2099 : \u2124) \u2194 Pn a\u2081 ... a\u2099`.\nFor example, `int.coe_nat_le_coe_nat_iff : \u2200 (m n : \u2115), \u2191m \u2264 \u2191n \u2194 m \u2264 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 \u2190 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 \u00d7 expr) := do\n  let sl \u2190 zify_attr.get_cache\n  let sl \u2190 sl.add_simp `ge_iff_le\n  let sl \u2190 sl.add_simp `gt_iff_lt\n  let (e', prf, _) \u2190 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 : \u2115) : (a : \u2124) \u2260 b \u2194 a \u2260 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 `\u2115` to `\u2124`.\nThis is often useful since `\u2124` 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 \u2192 tactic (expr \u00d7 expr) := fun z =>\n  do\n  let (z1, p1) \u2190 zify.lift_to_z z <|> fail \"failed to find an applicable zify lemma\"\n  let (z2, p2) \u2190 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) \u2190 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 `\u2115` to `\u2124`.\nThis is often useful since `\u2124` has well-behaved subtraction.\n\n```lean\nexample (a b c x y z : \u2115) (h : \u00ac x*y*z < 0) : c < a + 3*b :=\nbegin\n  zify,\n  zify at h,\n  /-\n  h : \u00ac\u2191x * \u2191y * \u2191z < 0\n  \u22a2 \u2191c < \u2191a + 3 * \u2191b\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 `\u2264` arguments will allow `push_cast` to do more work.\n```\nexample (a b c : \u2115) (h : a - b < c) (hab : b \u2264 a) : false :=\nbegin\n  zify [hab] at h,\n  /- h : \u2191a - \u2191b < \u2191c -/\nend\n```\n\n`zify` makes use of the `@[zify]` attribute to move propositions,\nand the `push_cast` tactic to simplify the `\u2124`-valued expressions.\n\n`zify` is in some sense dual to the `lift` tactic. `lift (z : \u2124) to \u2115` will change the type of an\ninteger `z` (in the supertype) to `\u2115` (the subtype), given a proof that `z \u2265 0`;\npropositions concerning `z` will still be over `\u2124`. `zify` changes propositions about `\u2115` (the\nsubtype) to propositions about `\u2124` (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 \u2190 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n\n/-- The type of linear maps `\u03b2 \u2192 \u03b3` between \u03b1-modules \u03b2 and \u03b3 -/\ndef linear_map {\u03b1 : Type u} (\u03b2 : Type v) (\u03b3 : Type w) [ring \u03b1] [module \u03b1 \u03b2] [module \u03b1 \u03b3] :=\nsubtype (@is_linear_map \u03b1 \u03b2 \u03b3 _ _ _)\n\nnamespace linear_map\nvariables [ring \u03b1] [module \u03b1 \u03b2] [module \u03b1 \u03b3]\nvariables {r : \u03b1} {A B C : linear_map \u03b2 \u03b3} {x y : \u03b2}\ninclude \u03b1\n\ninstance : has_coe_to_fun (linear_map \u03b2 \u03b3) := \u27e8_, subtype.val\u27e9\n\ntheorem ext (h : \u2200 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 \u2022 x) = r \u2022 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 \u03b2 \u03b3) : set \u03b2 := {y | A y = 0}\n\nsection ker\n\n@[simp] lemma mem_ker : x \u2208 A.ker \u2194 A x = 0 := iff.rfl\n\ntheorem ker_of_map_eq_map (h : A x = A y) : x - y \u2208 A.ker :=\nby rw [mem_ker, map_sub]; exact sub_eq_zero_of_eq h\n\ntheorem inj_of_trivial_ker (H : A.ker \u2286 {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 (\u03b1 A)\n\ninstance ker.is_submodule : is_submodule A.ker :=\n{ zero_ := map_zero,\n  add_ := \u03bb x y HU HV, by rw mem_ker at *; simp [HU, HV, mem_ker],\n  smul := \u03bb r x HV, by rw mem_ker at *; simp [HV] }\n\ntheorem sub_ker (HU : x \u2208 A.ker) (HV : y \u2208 A.ker) : x - y \u2208 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 \u03b2 -/\ndef im (A : linear_map \u03b2 \u03b3) : set \u03b3 := {x | \u2203 y, A y = x}\n\n@[simp] lemma mem_im {A : linear_map \u03b2 \u03b3} {z : \u03b3} :\n  z \u2208 A.im \u2194 \u2203 y, A y = z := iff.rfl\n\ninstance im.is_submodule : is_submodule A.im :=\n{ zero_ := \u27e80, map_zero\u27e9,\n  add_ := \u03bb a b \u27e8x, hx\u27e9 \u27e8y, hy\u27e9, \u27e8x + y, by simp [hx, hy]\u27e9,\n  smul := \u03bb r a \u27e8x, hx\u27e9, \u27e8r \u2022 x, by simp [hx]\u27e9 }\n\n/- equivalences -/\nsection\nopen is_submodule quotient_module\n\n/-- first isomorphism law -/\ndef quot_ker_equiv_im (f : linear_map \u03b2 \u03b3) : (quotient \u03b2 f.ker) \u2243\u2097 f.im :=\n{ to_fun     := quotient_module.quotient.lift _\n    (is_linear_map_subtype_mk f.1 f.2 $ assume b, \u27e8b, rfl\u27e9) (assume b eq, subtype.eq eq),\n  inv_fun    := \u03bbb, @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 (\u03bba, f (a - b) = 0),\n      show (\u2200a, f a = f b \u2192 f (a - b) = 0), simp {contextual := tt}\n    end,\n  right_inv  := assume c, subtype.eq $ classical.some_spec2 (\u03bba, 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 \u03b2} [is_submodule s] {b\u2081 b\u2082 : \u03b2} (h\u2082 : b\u2082 \u2208 s) :\n  b\u2081 + b\u2082 \u2208 s \u2194 b\u2081 \u2208 s :=\niff.intro\n  (assume h,\n    have b\u2081 + b\u2082 - b\u2082 \u2208 s, from is_submodule.sub h h\u2082,\n    by rwa [add_sub_cancel] at this)\n  (assume h\u2081, is_submodule.add h\u2081 h\u2082)\n\nlemma is_submodule.neg_iff {s : set \u03b2} [is_submodule s] {b : \u03b2} :\n  - b \u2208 s \u2194 b \u2208 s :=\niff.intro\n  (assume h,\n    have - - b \u2208 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 \u03b2} [is_submodule s] [is_submodule t] :\n  quotient s ((coe : s \u2192 \u03b2) \u207b\u00b9' (s \u2229 t)) \u2243\u2097 quotient (span (s \u222a t)) ((coe : span (s \u222a t) \u2192 \u03b2) \u207b\u00b9' t) :=\nlet sel\u2081 : s \u2192 span (s \u222a t) := \u03bbb, \u27e8(b : \u03b2), subset_span $ or.inl b.2\u27e9 in\nhave sel\u2081_val : \u2200b:s, (sel\u2081 b : \u03b2) = b, from assume b, rfl,\nhave \u2200b'\u2208span (s \u222a t), \u2203x:s, \u2203y\u2208t, b' = x.1 + y,\n  by simp [span_union, span_eq_of_is_submodule, _inst_4, _inst_5] {contextual := tt},\nlet sel\u2082 : span (s \u222a t) \u2192 s := \u03bbb', classical.some (this b'.1 b'.2) in\nhave sel\u2082_spec : \u2200b':span (s \u222a t), \u2203y\u2208t, (b' : \u03b2) = (sel\u2082 b' : \u03b2) + 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\u2081 b' },\n    { assume b\u2081 b\u2082 h,\n      change b\u2081 - b\u2082 \u2208 coe \u207b\u00b9' (s \u2229 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\u2082 b' },\n    { intros b\u2081 b\u2082 h,\n      change b\u2081 - b\u2082 \u2208 _ at h,\n      rcases (sel\u2082_spec b\u2081) with \u27e8c\u2081, hc\u2081, eq_c\u2081\u27e9,\n      rcases (sel\u2082_spec b\u2082) with \u27e8c\u2082, hc\u2082, eq_c\u2082\u27e9,\n      have : ((sel\u2082 b\u2081 : \u03b2) - (sel\u2082 b\u2082 : \u03b2)) + (c\u2081 - c\u2082) \u2208 t,\n      { simpa [eq_c\u2081, eq_c\u2082, add_comm, add_left_comm, add_assoc] using h, },\n      have ht : (sel\u2082 b\u2081 : \u03b2) - (sel\u2082 b\u2082 : \u03b2) \u2208 t,\n      { rwa [is_submodule.add_left_iff (is_submodule.sub hc\u2081 hc\u2082)] at this },\n      have hs : (sel\u2082 b\u2081 : \u03b2) - (sel\u2082 b\u2082 : \u03b2) \u2208 s,\n      { from is_submodule.sub (sel\u2082 b\u2081).2 (sel\u2082 b\u2082).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\u2082_spec b) with \u27e8c, hc, eq_c\u27e9,\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\u2082_spec (sel\u2081 b)) with \u27e8c, hct, eq\u27e9,\n    have b_eq : (b : \u03b2) = c + (sel\u2082 (sel\u2081 b)),\n    { simpa [sel\u2081_val] using eq },\n    have : (b : \u03b2) \u2208 s, from b.2,\n    have hcs : c \u2208 s,\n    { rwa [b_eq, is_submodule.add_left_iff (sel\u2082 (sel\u2081 b)).mem] at this },\n    show (sel\u2082 (sel\u2081 b) - b : \u03b2) \u2208 s \u2229 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 \u03b2 \u03b3) := \u27e8\u03bbhf hg, \u27e8_, hf.2.map_add hg.2\u27e9\u27e9\ninstance : has_zero (linear_map \u03b2 \u03b3) := \u27e8\u27e8_, is_linear_map.map_zero\u27e9\u27e9\ninstance : has_neg (linear_map \u03b2 \u03b3) := \u27e8\u03bbhf, \u27e8_, hf.2.map_neg\u27e9\u27e9\n\n@[simp] lemma add_app : (A + B) x = A x + B x := rfl\n@[simp] lemma zero_app : (0 : linear_map \u03b2 \u03b3) x = 0 := rfl\n@[simp] lemma neg_app : (-A) x = -A x := rfl\n\ninstance : add_comm_group (linear_map \u03b2 \u03b3) :=\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 \u03b1] [module \u03b1 \u03b2] [module \u03b1 \u03b3]\n\ninstance : has_scalar \u03b1 (linear_map \u03b2 \u03b3) := \u27e8\u03bbr f, \u27e8\u03bbb, r \u2022 f b, f.2.map_smul_right\u27e9\u27e9\n\n@[simp] lemma smul_app {r : \u03b1} {x : \u03b2} {A : linear_map \u03b2 \u03b3} : (r \u2022 A) x = r \u2022 (A x) := rfl\n\nvariables (\u03b1 \u03b2 \u03b3)\n\ninstance : module \u03b1 (linear_map \u03b2 \u03b3) :=\nby refine {smul := (\u2022), ..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 \u03b1] [module \u03b1 \u03b2]\ninclude \u03b1 \u03b2\n\ninstance : has_one (linear_map \u03b2 \u03b2) := \u27e8\u27e8id, is_linear_map.id\u27e9\u27e9\ninstance : has_mul (linear_map \u03b2 \u03b2) := \u27e8\u03bbf g, \u27e8_, is_linear_map.comp f.2 g.2\u27e9\u27e9\n\n@[simp] lemma one_app (x : \u03b2) : (1 : linear_map \u03b2 \u03b2) x = x := rfl\n@[simp] lemma mul_app (A B : linear_map \u03b2 \u03b2) (x : \u03b2) : (A * B) x = A (B x) := rfl\n\nvariables (\u03b1 \u03b2)\n\n-- declaring this an instance breaks `real.lean` with reaching max. instance resolution depth\ndef endomorphism_ring : ring (linear_map \u03b2 \u03b2) :=\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 `\u03b2` to itself -/\ndef general_linear_group :=\nby haveI := endomorphism_ring \u03b1 \u03b2; exact units (linear_map \u03b2 \u03b2)\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\u00f6lzl, 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 {\u03b1 \u03b2 K : Type _}\n\nsection DivisionSemiring\n\nvariable [DivisionSemiring \u03b1] {a b c d : \u03b1}\n\ntheorem add_div (a b c : \u03b1) : (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 : \u03b1) : 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 \u2260 0) : (b + a) / b = 1 + a / b := by rw [\u2190 div_self h, add_div]\n#align same_add_div same_add_div\n\ntheorem div_add_same (h : b \u2260 0) : (a + b) / b = a / b + 1 := by rw [\u2190 div_self h, add_div]\n#align div_add_same div_add_same\n\ntheorem one_add_div (h : b \u2260 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 \u2260 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 \u2260 0) (hb : b \u2260 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 : \u03b1) (hc : c \u2260 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 : \u03b1) (hc : c \u2260 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 : \u03b1) (hc : c \u2260 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 \u2260 0)\n    (hd : d \u2260 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 \u2260 0) (hb : b \u2260 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 \u2260 0) (hb : b \u2260 0) :\n    a\u207b\u00b9 + b\u207b\u00b9 = (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 [\u2190 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, \u2190 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\u207b\u00b9 = (-a)\u207b\u00b9 := 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 [\u2190 div_neg_eq_neg_div]\n#align div_neg div_neg\n\ntheorem inv_neg : (-a)\u207b\u00b9 = -a\u207b\u00b9 := by rw [neg_inv]\n#align inv_neg inv_neg\n\ntheorem inv_neg_one : (-1 : K)\u207b\u00b9 = -1 := by rw [\u2190 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 \u2260 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 \u2260 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, \u2190 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 \u2260 0) : (b - a) / b = 1 - a / b := by\n  simpa only [\u2190 @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 \u2260 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 \u2260 0) : (a - b) / b = a / b - 1 := by\n  simpa only [\u2190 @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 \u2260 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 \u2260 0) (hb : b \u2260 0) : a\u207b\u00b9 - b\u207b\u00b9 = a\u207b\u00b9 * (b - a) * b\u207b\u00b9 := by\n  rw [mul_sub, sub_mul, mul_inv_cancel_right\u2080 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 \u2260 0) (hb : b \u2260 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 \u2260 0)\n    (hd : d \u2260 0) : a / b - c / d = (a * d - b * c) / (b * d) := by\n  simpa only [mul_neg, neg_div, \u2190 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 \u2260 0) (hb : b \u2260 0) :\n    a\u207b\u00b9 - b\u207b\u00b9 = (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 \u03b1] {a b c d : \u03b1}\n\ntheorem div_add_div (a : \u03b1) (c : \u03b1) (hb : b \u2260 0) (hd : d \u2260 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 \u2260 0) (hb : b \u2260 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 \u2260 0) (hb : b \u2260 0) : a\u207b\u00b9 + b\u207b\u00b9 = (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 \u2260 0) (hd : d \u2260 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 \u2260 0) (hb : b \u2260 0) : a\u207b\u00b9 - b\u207b\u00b9 = (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 \u2260 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 \u2260 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 \u03b1] [Semiring \u03b2] [Nontrivial \u03b2] (f : \u03b1 \u2192+* \u03b2) :\n    Injective f :=\n  (injective_iff_map_eq_zero f).2 fun _ \u21a6 (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 : \u2200 a : R, IsUnit a \u2228 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 : \u2200 a : R, IsUnit a \u2228 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 \u03b2] [Zero \u03b1] [Mul \u03b1] [Add \u03b1]\n    [One \u03b1] [Inv \u03b1] [Div \u03b1] [SMul \u2115 \u03b1] [Pow \u03b1 \u2115] [Pow \u03b1 \u2124] [NatCast \u03b1] (f : \u03b1 \u2192 \u03b2)\n    (hf : Injective f) (zero : f 0 = 0) (one : f 1 = 1) (add : \u2200 x y, f (x + y) = f x + f y)\n    (mul : \u2200 x y, f (x * y) = f x * f y) (inv : \u2200 x, f x\u207b\u00b9 = (f x)\u207b\u00b9)\n    (div : \u2200 x y, f (x / y) = f x / f y) (nsmul : \u2200 (x) (n : \u2115), f (n \u2022 x) = n \u2022 f x)\n    (npow : \u2200 (x) (n : \u2115), f (x ^ n) = f x ^ n) (zpow : \u2200 (x) (n : \u2124), f (x ^ n) = f x ^ n)\n    (nat_cast : \u2200 n : \u2115, f n = n) : DivisionSemiring \u03b1 :=\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 \u2115 K'] [SMul \u2124 K'] [SMul \u211a K']\n    [Pow K' \u2115] [Pow K' \u2124] [NatCast K'] [IntCast K'] [RatCast K'] (f : K' \u2192 K) (hf : Injective f)\n    (zero : f 0 = 0) (one : f 1 = 1) (add : \u2200 x y, f (x + y) = f x + f y)\n    (mul : \u2200 x y, f (x * y) = f x * f y) (neg : \u2200 x, f (-x) = -f x)\n    (sub : \u2200 x y, f (x - y) = f x - f y) (inv : \u2200 x, f x\u207b\u00b9 = (f x)\u207b\u00b9)\n    (div : \u2200 x y, f (x / y) = f x / f y) (nsmul : \u2200 (x) (n : \u2115), f (n \u2022 x) = n \u2022 f x)\n    (zsmul : \u2200 (x) (n : \u2124), f (n \u2022 x) = n \u2022 f x) (qsmul : \u2200 (x) (n : \u211a), f (n \u2022 x) = n \u2022 f x)\n    (npow : \u2200 (x) (n : \u2115), f (x ^ n) = f x ^ n) (zpow : \u2200 (x) (n : \u2124), f (x ^ n) = f x ^ n)\n    (nat_cast : \u2200 n : \u2115, f n = n) (int_cast : \u2200 n : \u2124, f n = n) (rat_cast : \u2200 n : \u211a, 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 \u21a6\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 := (\u00b7 \u2022 \u00b7), qsmul_eq_mul' := fun a x \u21a6 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 \u03b2] [Zero \u03b1] [Mul \u03b1] [Add \u03b1] [One \u03b1] [Inv \u03b1]\n    [Div \u03b1] [SMul \u2115 \u03b1] [Pow \u03b1 \u2115] [Pow \u03b1 \u2124] [NatCast \u03b1] (f : \u03b1 \u2192 \u03b2) (hf : Injective f)\n    (zero : f 0 = 0) (one : f 1 = 1) (add : \u2200 x y, f (x + y) = f x + f y)\n    (mul : \u2200 x y, f (x * y) = f x * f y) (inv : \u2200 x, f x\u207b\u00b9 = (f x)\u207b\u00b9)\n    (div : \u2200 x y, f (x / y) = f x / f y) (nsmul : \u2200 (x) (n : \u2115), f (n \u2022 x) = n \u2022 f x)\n    (npow : \u2200 (x) (n : \u2115), f (x ^ n) = f x ^ n) (zpow : \u2200 (x) (n : \u2124), f (x ^ n) = f x ^ n)\n    (nat_cast : \u2200 n : \u2115, f n = n) : Semifield \u03b1 :=\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 \u2115 K'] [SMul \u2124 K'] [SMul \u211a K'] [Pow K' \u2115] [Pow K' \u2124]\n    [NatCast K'] [IntCast K'] [RatCast K'] (f : K' \u2192 K) (hf : Injective f) (zero : f 0 = 0)\n    (one : f 1 = 1) (add : \u2200 x y, f (x + y) = f x + f y) (mul : \u2200 x y, f (x * y) = f x * f y)\n    (neg : \u2200 x, f (-x) = -f x) (sub : \u2200 x y, f (x - y) = f x - f y) (inv : \u2200 x, f x\u207b\u00b9 = (f x)\u207b\u00b9)\n    (div : \u2200 x y, f (x / y) = f x / f y) (nsmul : \u2200 (x) (n : \u2115), f (n \u2022 x) = n \u2022 f x)\n    (zsmul : \u2200 (x) (n : \u2124), f (n \u2022 x) = n \u2022 f x) (qsmul : \u2200 (x) (n : \u211a), f (n \u2022 x) = n \u2022 f x)\n    (npow : \u2200 (x) (n : \u2115), f (x ^ n) = f x ^ n) (zpow : \u2200 (x) (n : \u2124), f (x ^ n) = f x ^ n)\n    (nat_cast : \u2200 n : \u2115, f n = n) (int_cast : \u2200 n : \u2124, f n = n) (rat_cast : \u2200 n : \u211a, 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 \u21a6\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 := (\u00b7 \u2022 \u00b7), qsmul_eq_mul' := fun a x \u21a6 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 \u03b1] : RatCast \u03b1\u1d52\u1d48 :=\n  h\n\ninstance [h : DivisionSemiring \u03b1] : DivisionSemiring \u03b1\u1d52\u1d48 :=\n  h\n\ninstance [h : DivisionRing \u03b1] : DivisionRing \u03b1\u1d52\u1d48 :=\n  h\n\ninstance [h : Semifield \u03b1] : Semifield \u03b1\u1d52\u1d48 :=\n  h\n\ninstance [h : Field \u03b1] : Field \u03b1\u1d52\u1d48 :=\n  h\n\n@[simp]\ntheorem toDual_rat_cast [RatCast \u03b1] (n : \u211a) : toDual (n : \u03b1) = n :=\n  rfl\n#align to_dual_rat_cast toDual_rat_cast\n\n@[simp]\ntheorem ofDual_rat_cast [RatCast \u03b1] (n : \u211a) : (ofDual n : \u03b1) = n :=\n  rfl\n#align of_dual_rat_cast ofDual_rat_cast\n\n/-! ### Lexicographic order -/\n\ninstance [h : RatCast \u03b1] : RatCast (Lex \u03b1) :=\n  h\n\ninstance [h : DivisionSemiring \u03b1] : DivisionSemiring (Lex \u03b1) :=\n  h\n\ninstance [h : DivisionRing \u03b1] : DivisionRing (Lex \u03b1) :=\n  h\n\ninstance [h : Semifield \u03b1] : Semifield (Lex \u03b1) :=\n  h\n\ninstance [h : Field \u03b1] : Field (Lex \u03b1) :=\n  h\n\n@[simp]\ntheorem toLex_rat_cast [RatCast \u03b1] (n : \u211a) : toLex (n : \u03b1) = n :=\n  rfl\n#align to_lex_rat_cast toLex_rat_cast\n\n@[simp]\ntheorem ofLex_rat_cast [RatCast \u03b1] (n : \u211a) : (ofLex n : \u03b1) = 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 (\u2124/n\u2124)* and then relates them\nto multiplicative homomorphisms over \u2124/n\u2124 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 {\u03b1 : Type*} [monoid \u03b1] {x y : \u03b1} (hx : is_unit x) (hy : is_unit y) :\n  hx.unit * hy.unit = (hx.mul hy).unit :=\n  by { rw \u2190units.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 : \u2115) := units (zmod n) \u2192* units R\n\nopen_locale classical\n\nlemma extend_eq_char {R : Type*} [monoid_with_zero R] {n : \u2115}\n  (\u03c7 : dirichlet_character R n) {x : zmod n} (hx : is_unit x) :\n  function.extend (units.coe_hom (zmod n)) ((units.coe_hom R) \u2218 \u03c7) 0 x = \u03c7 hx.unit :=\nbegin\n  conv_lhs { congr, skip, skip, skip, rw \u2190is_unit.unit_spec hx, },\n  rw \u2190units.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 : \u2115}\n  (\u03c7 : dirichlet_character R n) {x : zmod n} (hx : \u00ac is_unit x) :\n  function.extend (units.coe_hom (zmod n)) ((units.coe_hom R) \u2218 \u03c7) 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 \u2190ha, apply units.is_unit, },\nend\n\n/-- The Dirichlet character on \u2124/n\u2124 \u2192* R determined by \u03c7, 0 on non-units. -/\nnoncomputable abbreviation asso_dirichlet_character {R : Type*} [monoid_with_zero R] {n : \u2115}\n  (\u03c7 : dirichlet_character R n) : zmod n \u2192* R :=\n{ to_fun := function.extend (units.coe_hom (zmod n)) ((units.coe_hom R) \u2218 \u03c7) 0,\n  map_one' := begin\n    rw [extend_eq_char _ is_unit_one, units.coe_eq_one],\n    convert \u03c7.map_one',\n    rw [\u2190units.eq_iff, is_unit.unit_spec, units.coe_one],\n  end,\n  map_mul' := \u03bb x y, begin\n    by_cases is_unit x \u2227 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) (\u03c7 _) = (units.coe_hom R) (\u03c7 _) * (units.coe_hom R) (\u03c7 _),\n      repeat { rw \u2190monoid_hom.comp_apply _ \u03c7, },\n      convert \u2190monoid_hom.map_mul' (monoid_hom.comp (units.coe_hom R) \u03c7) _ _,\n      rw is_unit.unit_mul, },\n    { have : \u00ac (is_unit (x * y)),\n      { contrapose h, rw not_not at *, rw \u2190is_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 : \u2115}\n  (\u03c7 : dirichlet_character R n) (a : units (zmod n)) : asso_dirichlet_character \u03c7 a = \u03c7 a :=\nby { convert extend_eq_char \u03c7 a.is_unit, rw [\u2190units.eq_iff, (a.is_unit).unit_spec], }\n\nlemma asso_dirichlet_character_eq_char' {R : Type*} [monoid_with_zero R] {n : \u2115}\n  (\u03c7 : dirichlet_character R n) {a : zmod n} (ha : is_unit a) :\n  asso_dirichlet_character \u03c7 a = \u03c7 ha.unit :=\nby { convert extend_eq_char \u03c7 ha, }\n\nlemma asso_dirichlet_character_eq_zero {R : Type*} [monoid_with_zero R] {n : \u2115}\n  (\u03c7 : dirichlet_character R n) {a : zmod n} (ha : \u00ac is_unit a) :\n  asso_dirichlet_character \u03c7 a = 0 :=\nby { convert extend_eq_zero \u03c7 ha, }\n\nlemma asso_dirichlet_character_eq_iff {R : Type*} [monoid_with_zero R] {n : \u2115}\n  (\u03c7 : dirichlet_character R n) (\u03c8 : dirichlet_character R n) :\n  \u03c7 = \u03c8 \u2194 asso_dirichlet_character \u03c7 = asso_dirichlet_character \u03c8 :=\n\u27e8\u03bb 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\u03bb h, begin\n  ext,\n  repeat { rw \u2190asso_dirichlet_character_eq_char _ x, }, rw h,\n  end\u27e9\n\nnamespace dirichlet_character\n\nvariables {R : Type*} [comm_monoid_with_zero R] {n : \u2115} (\u03c7 : 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 \u03c7 (n - x) = asso_dirichlet_character \u03c7 (-x) :=\nby { congr, simp, }\n\nlemma is_periodic (m : \u2115) (hm : n \u2223 m) (a : \u2124) :\n  asso_dirichlet_character \u03c7 (a + m) = asso_dirichlet_character \u03c7 a :=\nbegin\n  rw \u2190 zmod.nat_coe_zmod_eq_zero_iff_dvd at hm,\n  simp only [hm, add_zero],\nend\n\n/-- Extends the Dirichlet character \u03c7 of level n to level m, where n \u2223 m. -/\ndef change_level {m : \u2115} (hm : n \u2223 m) : dirichlet_character R n \u2192* dirichlet_character R m :=\n{ to_fun := \u03bb \u03c8, \u03c8.comp (units.map (zmod.cast_hom hm (zmod n))),\n  map_one' := by simp,\n  map_mul' := \u03bb \u03c8\u2081 \u03c8\u2082, monoid_hom.mul_comp _ _ _, }\n\nlemma change_level_def {m : \u2115} (hm : n \u2223 m) : change_level hm \u03c7 = \u03c7.comp (units.map (zmod.cast_hom hm (zmod n))) := rfl\n\nnamespace change_level\nlemma self : change_level (dvd_refl n) \u03c7 = \u03c7 := by { rw change_level_def, simp, }\n\nlemma dvd {m d : \u2115} (hm : n \u2223 m) (hd : m \u2223 d) :\n  change_level (dvd_trans hm hd) \u03c7 = change_level hd (change_level hm \u03c7) :=\nbegin\n  repeat { rw change_level_def, }, \n  rw [monoid_hom.comp_assoc, \u2190units.map_comp], \n  change _ = \u03c7.comp (units.map \u2191((zmod.cast_hom hm (zmod n)).comp (zmod.cast_hom hd (zmod m)))),\n  congr,\nend\n\nlemma asso_dirichlet_character_eq {m : \u2115} (hm : n \u2223 m) (a : units (zmod m)) :\n  asso_dirichlet_character (change_level hm \u03c7) a = asso_dirichlet_character \u03c7 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 \u2190zmod.cast_hom_apply (a : zmod m),\n      swap 3, { apply zmod.char_p _, },\n      swap, { assumption, },\n      rw [\u2190ring_hom.coe_monoid_hom, \u2190units.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 [\u2190units.eq_iff, units.coe_map, is_unit.unit_spec _, is_unit.unit_spec _], refl, }, },\nend\n\nlemma asso_dirichlet_character_eq' {m : \u2115} (hm : n \u2223 m) {a : zmod m}\n  (ha : is_unit a) : asso_dirichlet_character (change_level hm \u03c7) a =\n  asso_dirichlet_character \u03c7 a :=\nbegin\n  rw [\u2190is_unit.unit_spec ha, asso_dirichlet_character_eq], congr,\nend\nend change_level\n\n/-- \u03c7\u2080 of level d factors through \u03c7 of level n if d \u2223 n and \u03c7\u2080 = \u03c7 \u2218 (zmod n \u2192 zmod d). -/\nstructure factors_through (d : \u2115) : Prop :=\n(dvd : d \u2223 n)\n(ind_char : \u2203 \u03c7\u2080 : dirichlet_character R d, \u03c7 = change_level dvd \u03c7\u2080)\n\nnamespace factors_through\nlemma spec {d : \u2115} (h : factors_through \u03c7 d) :\n  \u03c7 = 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 \u2115 := {x : \u2115 | \u03c7.factors_through x}\n\nlemma mem_conductor_set_iff {x : \u2115} : x \u2208 \u03c7.conductor_set \u2194 \u03c7.factors_through x := iff.refl _\n\nlemma level_mem_conductor_set : n \u2208 conductor_set \u03c7 := (mem_conductor_set_iff _).2\n{ dvd := dvd_rfl,\n  ind_char := \u27e8\u03c7, (change_level.self \u03c7).symm\u27e9, }\n\nlemma mem_conductor_set_dvd {x : \u2115} (hx : x \u2208 \u03c7.conductor_set) : x \u2223 n := hx.1\n\nlemma mem_conductor_set_factors_through {x : \u2115} (hx : x \u2208 \u03c7.conductor_set) : \u03c7.factors_through x := hx\n\n/-- The minimum natural number n for which a Dirichlet character is periodic.\n  The Dirichlet character \u03c7 can then alternatively be reformulated on \u2124/n\u2124. -/\nnoncomputable def conductor : \u2115 := Inf (conductor_set \u03c7)\n\nlemma nat.le_one {n : \u2115} (h : n \u2264 1) : n = 0 \u2228 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 \u03c7 \u2208 conductor_set \u03c7 := Inf_mem (set.nonempty_of_mem \u03c7.level_mem_conductor_set)\n\nlemma dvd_lev : \u03c7.conductor \u2223 n := (mem_conductor_set \u03c7).1\n\nlemma factors_through : \u03c7.factors_through \u03c7.conductor := mem_conductor_set \u03c7\n\nlemma eq_one (h\u03c7 : \u03c7.conductor = 1) : \u03c7 = 1 :=\nbegin\n  obtain \u27e8h', \u03c7\u2080, h\u27e9 := factors_through \u03c7,\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 \u03c7\u2080.map_one',\n  apply subsingleton.elim _ _,\n  rw h\u03c7,\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 \u2264 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 \u27e8one_dvd _, 1, _\u27e9,\n    ext, \n    rw [units.eq_iff, change_level_def], \n    simp only [monoid_hom.one_comp], },\nend\n\nvariable {\u03c7}\nlemma eq_one_iff (hn : 0 < n) : \u03c7 = 1 \u2194 \u03c7.conductor = 1 :=\n\u27e8\u03bb h, by { rw [h, one hn], }, \u03bb h, by {rw eq_one \u03c7 h}\u27e9\n\nlemma eq_zero_iff_level_eq_zero : \u03c7.conductor = 0 \u2194 n = 0 :=\n\u27e8\u03bb h, by {rw \u2190zero_dvd_iff, convert dvd_lev \u03c7, rw h, },\n  \u03bb h, by {rw [conductor, nat.Inf_eq_zero], left, refine \u27e8zero_dvd_iff.2 h,\n  \u27e8change_level (by {rw h}) \u03c7, by { rw [\u2190change_level.dvd _ _ _, change_level.self _], }\u27e9, \u27e9, }\u27e9\nend conductor\n\n/-- A character is primitive if its level is equal to its conductor. -/\ndef is_primitive : Prop := \u03c7.conductor = n\n\nlemma is_primitive_def : \u03c7.is_primitive \u2194 \u03c7.conductor = n := \u27e8\u03bb h, h, \u03bb h, h\u27e9\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 \u27e81, rfl\u27e9,\nend\nend is_primitive\n\nlemma conductor_one_dvd (n : \u2115) : conductor (1 : dirichlet_character R 1) \u2223 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 \u2243 zmod n. -/\ndef zmod.mul_equiv {a b : \u2115} (h : a = b) : zmod a \u2243* 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 : \u2115} (h : a = b) : dirichlet_character R a \u2243* 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 \u03c7.conductor :=\n  classical.some (conductor.factors_through \u03c7).ind_char\n\nlemma mem_conductor_set_eq_conductor {d : \u2115} (hd : d \u2208 \u03c7.conductor_set) :\n  \u03c7.conductor \u2264 (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 \u27e8dvd_trans (conductor.dvd_lev _) hd.1, (conductor.factors_through (classical.some hd.2)).2.some, _\u27e9,\n  convert factors_through.spec \u03c7 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, \u2190monoid_hom.comp_assoc],\n  congr,\n  change change_level _ _ = _,\n  convert (factors_through.spec _ _).symm,\nend\n\nlemma asso_primitive_character_is_primitive : (\u03c7.asso_primitive_character).is_primitive :=\nbegin\n  by_cases \u03c7.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 (\u03c8 : dirichlet_character R n) :\n  asso_dirichlet_character (\u03c7 * \u03c8) = (asso_dirichlet_character \u03c7) * (asso_dirichlet_character \u03c8) :=\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 : \u2115} (\u03c7 : dirichlet_character R n) :\n  \u03c7.asso_primitive_character.conductor = \u03c7.conductor :=\n(is_primitive_def \u03c7.asso_primitive_character).1 (asso_primitive_character_is_primitive \u03c7)\n\n/-- Similar to multiplication of Dirichlet characters, without needing the characters to be\n  primitive. -/\nnoncomputable def mul {m : \u2115} (\u03c7\u2081 : dirichlet_character R n) (\u03c7\u2082 : dirichlet_character R m) :=\nasso_primitive_character (change_level (dvd_lcm_left n m) \u03c7\u2081 * change_level (dvd_lcm_right n m) \u03c7\u2082)\n\nlemma mul_def {n m : \u2115} {\u03c7 : dirichlet_character R n} {\u03c8 : dirichlet_character R m} :\n  \u03c7.mul \u03c8 = (change_level _ \u03c7 * change_level _ \u03c8).asso_primitive_character := rfl\n\nnamespace is_primitive\nlemma mul {m : \u2115} (\u03c8 : dirichlet_character R m) : (mul \u03c7 \u03c8).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 \u2192* units S) : dirichlet_character S n := f.comp \u03c7\n\nvariables {S : Type*} [comm_ring S] {m : \u2115} (\u03c8 : dirichlet_character S m)\n\n/-- A Dirichlet character is odd if its value at -1 is -1. -/\ndef is_odd : Prop := \u03c8 (-1) = -1\n\n/-- A Dirichlet character is even if its value at -1 is 1. -/\ndef is_even : Prop := \u03c8 (-1) = 1\n\nlemma is_odd_or_is_even [no_zero_divisors S] : \u03c8.is_odd \u2228 \u03c8.is_even :=\nbegin\n  suffices : (\u03c8 (-1))^2 = 1,\n  { rw \u2190units.eq_iff at this,\n    conv_rhs at this { rw \u2190one_pow 2 },\n    rw \u2190sub_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, \u2190units.eq_iff], simp only [this, units.coe_neg_one], },\n    { right, rw [is_even, \u2190units.eq_iff], simp only [this, units.coe_one], }, },\n  { rw [\u2190monoid_hom.map_pow, \u2190monoid_hom.map_one \u03c8],\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\u03c8 : \u03c8.is_odd) :\n  asso_dirichlet_character \u03c8 (-1) = -1 :=\nbegin\n  rw is_odd at h\u03c8,\n  convert asso_dirichlet_character_eq_char _ (-1),\n  rw h\u03c8, simp,\nend\n\nlemma asso_even_dirichlet_character_eval_neg_one (h\u03c8 : \u03c8.is_even) :\n  asso_dirichlet_character \u03c8 (-1) = 1 :=\nbegin\n  rw is_even at h\u03c8,\n  convert asso_dirichlet_character_eq_char _ (-1),\n  rw h\u03c8, simp,\nend\n\nlemma asso_odd_dirichlet_character_eval_sub (x : zmod m) (h\u03c8 : \u03c8.is_odd) :\n  asso_dirichlet_character \u03c8 (m - x) = -(asso_dirichlet_character \u03c8 x) :=\nbegin\n  rw [asso_dirichlet_character_eval_sub, \u2190neg_one_mul, monoid_hom.map_mul,\n    asso_odd_dirichlet_character_eval_neg_one _ h\u03c8],\n  simp,\nend\n\nlemma asso_even_dirichlet_character_eval_sub (x : zmod m) (h\u03c8 : \u03c8.is_even) :\n  asso_dirichlet_character \u03c8 (m - x) = asso_dirichlet_character \u03c8 x :=\nbegin\n  rw [asso_dirichlet_character_eval_sub, \u2190neg_one_mul, monoid_hom.map_mul,\n    asso_even_dirichlet_character_eval_neg_one _ h\u03c8],\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 \u2192 D) \u2192 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 \u2192 D) \u2192 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 \u2192 D) \u2192 D\n-- The eliminator\naxiom recD   : \u03a0 {C : D \u2192 Type}, (\u03a0 (f : D \u2192 D) (r : \u03a0 d, C (f d)), C (introD f)) \u2192 (\u03a0 (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 \u2192 D := \u03bbd, d\nnoncomputable definition v  : D     := introD id'\n\ntheorem inconsistent : false :=\nrecD (\u03bb 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 : \u2115) [hp : fact (nat.prime p)] : \u2115 \u2192 \u2115 \u2192 mv_polynomial \u2115 \u2124 :=\n  sorry\n\ntheorem mul_n_coeff {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (n : \u2115) (x : witt_vector p R) (k : \u2115) : coeff (x * \u2191n) 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) (x : witt_vector p R) => x * \u2191n :=\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 : \u2115) => mul_n_coeff n x k\n\n@[simp] theorem bind\u2081_witt_mul_n_witt_polynomial (p : \u2115) [hp : fact (nat.prime p)] (n : \u2115) (k : \u2115) : coe_fn (mv_polynomial.bind\u2081 (witt_mul_n p n)) (witt_polynomial p \u2124 k) = \u2191n * witt_polynomial p \u2124 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 {\u03b2 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 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)] {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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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'\u2093'. -/\n@[to_additive nsmul_le_nsmul_of_le_right, mono]\ntheorem pow_le_pow_of_le_left' [CovariantClass M M (swap (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7)] {a b : M} (hab : a \u2264 b) :\n    \u2200 i : \u2115, a ^ i \u2264 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'\u2093'. -/\n@[to_additive nsmul_nonneg]\ntheorem one_le_pow_of_one_le' {a : M} (H : 1 \u2264 a) : \u2200 n : \u2115, 1 \u2264 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'\u2093'. -/\n@[to_additive nsmul_nonpos]\ntheorem pow_le_one' {a : M} (H : a \u2264 1) (n : \u2115) : a ^ n \u2264 1 :=\n  @one_le_pow_of_one_le' M\u1d52\u1d48 _ _ _ _ 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'\u2093'. -/\n@[to_additive nsmul_le_nsmul]\ntheorem pow_le_pow' {a : M} {n m : \u2115} (ha : 1 \u2264 a) (h : n \u2264 m) : a ^ n \u2264 a ^ m :=\n  let \u27e8k, hk\u27e9 := Nat.le.dest h\n  calc\n    a ^ n \u2264 a ^ n * a ^ k := le_mul_of_one_le_right' (one_le_pow_of_one_le' ha _)\n    _ = a ^ m := by rw [\u2190 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'\u2093'. -/\n@[to_additive nsmul_le_nsmul_of_nonpos]\ntheorem pow_le_pow_of_le_one' {a : M} {n m : \u2115} (ha : a \u2264 1) (h : n \u2264 m) : a ^ m \u2264 a ^ n :=\n  @pow_le_pow' M\u1d52\u1d48 _ _ _ _ _ _ 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'\u2093'. -/\n@[to_additive nsmul_pos]\ntheorem one_lt_pow' {a : M} (ha : 1 < a) {k : \u2115} (hk : k \u2260 0) : 1 < a ^ k :=\n  by\n  rcases Nat.exists_eq_succ_of_ne_zero hk with \u27e8l, rfl\u27e9\n  clear hk\n  induction' l with l IH\n  \u00b7 simpa using ha\n  \u00b7 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'\u2093'. -/\n@[to_additive nsmul_neg]\ntheorem pow_lt_one' {a : M} (ha : a < 1) {k : \u2115} (hk : k \u2260 0) : a ^ k < 1 :=\n  @one_lt_pow' M\u1d52\u1d48 _ _ _ _ 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'\u2093'. -/\n@[to_additive nsmul_lt_nsmul]\ntheorem pow_lt_pow' [CovariantClass M M (\u00b7 * \u00b7) (\u00b7 < \u00b7)] {a : M} {n m : \u2115} (ha : 1 < a)\n    (h : n < m) : a ^ n < a ^ m :=\n  by\n  rcases Nat.le.dest h with \u27e8k, rfl\u27e9; clear h\n  rw [pow_add, pow_succ', mul_assoc, \u2190 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\u2093'. -/\n@[to_additive nsmul_strictMono_right]\ntheorem pow_strictMono_left [CovariantClass M M (\u00b7 * \u00b7) (\u00b7 < \u00b7)] {a : M} (ha : 1 < a) :\n    StrictMono ((\u00b7 ^ \u00b7) a : \u2115 \u2192 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\u2093'. -/\n@[to_additive Left.pow_nonneg]\ntheorem Left.one_le_pow_of_le (hx : 1 \u2264 x) : \u2200 {n : \u2115}, 1 \u2264 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\u2093'. -/\n@[to_additive Left.pow_nonpos]\ntheorem Left.pow_le_one_of_le (hx : x \u2264 1) : \u2200 {n : \u2115}, x ^ n \u2264 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 (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7)] {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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\n@[to_additive Right.pow_nonneg]\ntheorem Right.one_le_pow_of_le (hx : 1 \u2264 x) : \u2200 {n : \u2115}, 1 \u2264 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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\n@[to_additive Right.pow_nonpos]\ntheorem Right.pow_le_one_of_le (hx : x \u2264 1) : \u2200 {n : \u2115}, x ^ n \u2264 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 \u03b2] [CovariantClass M M (\u00b7 * \u00b7) (\u00b7 < \u00b7)]\n  [CovariantClass M M (swap (\u00b7 * \u00b7)) (\u00b7 < \u00b7)] {f : \u03b2 \u2192 M}\n\n/- warning: strict_mono.pow_right' -> StrictMono.pow_right' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b2 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_2 : Preorder.{u2} M] [_inst_3 : Preorder.{u1} \u03b2] [_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 (\u1fb0 : M) (\u1fb0 : 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 : \u03b2 -> M}, (StrictMono.{u1, u2} \u03b2 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} \u03b2 M _inst_3 _inst_2 (fun (a : \u03b2) => 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 {\u03b2 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : Preorder.{u2} \u03b2] [_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 (\u1fb0 : M) (\u1fb0 : 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 : \u03b2 -> M}, (StrictMono.{u2, u1} \u03b2 M _inst_3 _inst_2 f) -> (forall {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (StrictMono.{u2, u1} \u03b2 M _inst_3 _inst_2 (fun (a : \u03b2) => 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'\u2093'. -/\n@[to_additive StrictMono.nsmul_left]\ntheorem StrictMono.pow_right' (hf : StrictMono f) : \u2200 {n : \u2115}, n \u2260 0 \u2192 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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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'\u2093'. -/\n/-- See also `pow_strict_mono_right` -/\n@[nolint to_additive_doc, to_additive nsmul_strictMono_left]\ntheorem pow_strictMono_right' {n : \u2115} (hn : n \u2260 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 \u03b2] [CovariantClass M M (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)]\n  [CovariantClass M M (swap (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7)]\n\n/- warning: monotone.pow_right -> Monotone.pow_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b2 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_2 : Preorder.{u2} M] [_inst_3 : Preorder.{u1} \u03b2] [_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 (\u1fb0 : M) (\u1fb0 : 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 : \u03b2 -> M}, (Monotone.{u1, u2} \u03b2 M _inst_3 _inst_2 f) -> (forall (n : Nat), Monotone.{u1, u2} \u03b2 M _inst_3 _inst_2 (fun (a : \u03b2) => 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 {\u03b2 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_2 : Preorder.{u1} M] [_inst_3 : Preorder.{u2} \u03b2] [_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 (\u1fb0 : M) (\u1fb0 : 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 : \u03b2 -> M}, (Monotone.{u2, u1} \u03b2 M _inst_3 _inst_2 f) -> (forall (n : Nat), Monotone.{u2, u1} \u03b2 M _inst_3 _inst_2 (fun (a : \u03b2) => 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\u2093'. -/\n@[to_additive Monotone.nsmul_left]\ntheorem Monotone.pow_right {f : \u03b2 \u2192 M} (hf : Monotone f) : \u2200 n : \u2115, 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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\n@[to_additive nsmul_mono_left]\ntheorem pow_mono_right (n : \u2115) : 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\u2093'. -/\n@[to_additive Left.pow_neg]\ntheorem Left.pow_lt_one_of_lt [CovariantClass M M (\u00b7 * \u00b7) (\u00b7 < \u00b7)] {n : \u2115} {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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\n@[to_additive Right.pow_neg]\ntheorem Right.pow_lt_one_of_lt [CovariantClass M M (swap (\u00b7 * \u00b7)) (\u00b7 < \u00b7)] {n : \u2115} {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 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)]\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\u2093'. -/\n@[to_additive nsmul_nonneg_iff]\ntheorem one_le_pow_iff {x : M} {n : \u2115} (hn : n \u2260 0) : 1 \u2264 x ^ n \u2194 1 \u2264 x :=\n  \u27e8le_imp_le_of_lt_imp_lt fun h => pow_lt_one' h hn, fun h => one_le_pow_of_one_le' h n\u27e9\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\u2093'. -/\n@[to_additive]\ntheorem pow_le_one_iff {x : M} {n : \u2115} (hn : n \u2260 0) : x ^ n \u2264 1 \u2194 x \u2264 1 :=\n  @one_le_pow_iff M\u1d52\u1d48 _ _ _ _ _ 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\u2093'. -/\n@[to_additive nsmul_pos_iff]\ntheorem one_lt_pow_iff {x : M} {n : \u2115} (hn : n \u2260 0) : 1 < x ^ n \u2194 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\u2093'. -/\n@[to_additive]\ntheorem pow_lt_one_iff {x : M} {n : \u2115} (hn : n \u2260 0) : x ^ n < 1 \u2194 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\u2093'. -/\n@[to_additive]\ntheorem pow_eq_one_iff {x : M} {n : \u2115} (hn : n \u2260 0) : x ^ n = 1 \u2194 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 (\u00b7 * \u00b7) (\u00b7 < \u00b7)] {a : M} {m n : \u2115}\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'\u2093'. -/\n@[to_additive nsmul_le_nsmul_iff]\ntheorem pow_le_pow_iff' (ha : 1 < a) : a ^ m \u2264 a ^ n \u2194 m \u2264 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'\u2093'. -/\n@[to_additive nsmul_lt_nsmul_iff]\ntheorem pow_lt_pow_iff' (ha : 1 < a) : a ^ m < a ^ n \u2194 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 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)] [CovariantClass M M (swap (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7)]\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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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'\u2093'. -/\n@[to_additive lt_of_nsmul_lt_nsmul]\ntheorem lt_of_pow_lt_pow' {a b : M} (n : \u2115) : a ^ n < b ^ n \u2192 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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\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 (\u00b7 * \u00b7) (\u00b7 < \u00b7)] [CovariantClass M M (swap (\u00b7 * \u00b7)) (\u00b7 < \u00b7)]\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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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'\u2093'. -/\n@[to_additive le_of_nsmul_le_nsmul]\ntheorem le_of_pow_le_pow' {a b : M} {n : \u2115} (hn : n \u2260 0) : a ^ n \u2264 b ^ n \u2192 a \u2264 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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\n@[to_additive min_le_of_add_le_two_nsmul]\ntheorem min_le_of_mul_le_sq {a b c : M} (h : a * b \u2264 c ^ 2) : min a b \u2264 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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\n@[to_additive le_max_of_two_nsmul_le_add]\ntheorem le_max_of_sq_le_mul {a b c : M} (h : a ^ 2 \u2264 b * c) : a \u2264 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\u2093'. -/\n@[to_additive Left.nsmul_neg_iff]\ntheorem Left.pow_lt_one_iff [CovariantClass M M (\u00b7 * \u00b7) (\u00b7 < \u00b7)] {n : \u2115} {x : M} (hn : 0 < n) :\n    x ^ n < 1 \u2194 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 (\u1fb0 : M) (\u1fb0 : 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 (\u1fb0 : M) (\u1fb0 : 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\u2093'. -/\n@[to_additive Right.nsmul_neg_iff]\ntheorem Right.pow_lt_one_iff [CovariantClass M M (swap (\u00b7 * \u00b7)) (\u00b7 < \u00b7)] {n : \u2115} {x : M}\n    (hn : 0 < n) : x ^ n < 1 \u2194 x < 1 :=\n  \u27e8fun 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\u27e9\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 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)]\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\u2093'. -/\n@[to_additive zsmul_nonneg]\ntheorem one_le_zpow {x : G} (H : 1 \u2264 x) {n : \u2124} (hn : 0 \u2264 n) : 1 \u2264 x ^ n :=\n  by\n  lift n to \u2115 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\u2093'. -/\ntheorem pow_pos {a : R} (H : 0 < a) (n : \u2115) : 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 : \u2115}\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\u2093'. -/\ntheorem zero_pow_le_one : \u2200 n : \u2115, (0 : R) ^ n \u2264 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\u2093'. -/\ntheorem pow_add_pow_le (hx : 0 \u2264 x) (hy : 0 \u2264 y) (hn : n \u2260 0) : x ^ n + y ^ n \u2264 (x + y) ^ n :=\n  by\n  rcases Nat.exists_eq_succ_of_ne_zero hn with \u27e8k, rfl\u27e9\n  induction' k with k ih; \u00b7 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 \u2264 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), \u2190 add_assoc, \u2190 add_assoc,\n        add_assoc (x * x ^ n) (x * y ^ n), add_comm (x * y ^ n) (y * y ^ n), \u2190 add_assoc]\n    _ \u2264 (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\u2093'. -/\ntheorem pow_le_one : \u2200 (n : \u2115) (h\u2080 : 0 \u2264 a) (h\u2081 : a \u2264 1), a ^ n \u2264 1\n  | 0, h\u2080, h\u2081 => (pow_zero a).le\n  | n + 1, h\u2080, h\u2081 => (pow_succ' a n).le.trans (mul_le_one (pow_le_one n h\u2080 h\u2081) h\u2080 h\u2081)\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\u2093'. -/\ntheorem pow_lt_one (h\u2080 : 0 \u2264 a) (h\u2081 : a < 1) : \u2200 {n : \u2115} (hn : n \u2260 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\u2080 h\u2081 (pow_le_one _ h\u2080 h\u2081.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 \u2264 a) : \u2200 n : \u2115, 1 \u2264 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 \u2264 a) : Monotone fun n : \u2115 => 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 \u2264 a) (h : n \u2264 m) : a ^ n \u2264 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 \u2264 a) (h : m \u2260 0) : a \u2264 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\u2093'. -/\n@[mono]\ntheorem pow_le_pow_of_le_left {a b : R} (ha : 0 \u2264 a) (hab : a \u2264 b) : \u2200 i : \u2115, a ^ i \u2264 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) : \u2200 {n : \u2115} (hn : n \u2260 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 : \u2115}\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\u2093'. -/\ntheorem pow_lt_pow_of_lt_left (h : x < y) (hx : 0 \u2264 x) : \u2200 {n : \u2115}, 0 < n \u2192 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\u2093'. -/\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 : \u2115 => 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 \u2194 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 \u2264 a ^ m \u2194 n \u2264 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\u2093'. -/\ntheorem strictAnti_pow (h\u2080 : 0 < a) (h\u2081 : a < 1) : StrictAnti fun n : \u2115 => a ^ n :=\n  strictAnti_nat_of_succ_lt fun n => by\n    simpa only [pow_succ, one_mul] using mul_lt_mul h\u2081 le_rfl (pow_pos h\u2080 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\u2093'. -/\ntheorem pow_lt_pow_iff_of_lt_one (h\u2080 : 0 < a) (h\u2081 : a < 1) : a ^ m < a ^ n \u2194 n < m :=\n  (strictAnti_pow h\u2080 h\u2081).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\u2093'. -/\ntheorem pow_lt_pow_of_lt_one (h : 0 < a) (ha : a < 1) {i j : \u2115} (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\u2093'. -/\ntheorem pow_lt_self_of_lt_one (h\u2080 : 0 < a) (h\u2081 : a < 1) (hn : 1 < n) : a ^ n < a :=\n  calc\n    a ^ n < a ^ 1 := pow_lt_pow_of_lt_one h\u2080 h\u2081 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\u2093'. -/\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\u2093'. -/\ntheorem pow_bit0_pos_of_neg (ha : a < 0) (n : \u2115) : 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\u2093'. -/\ntheorem pow_bit1_neg (ha : a < 0) (n : \u2115) : 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\u2093'. -/\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\u2093'. -/\ntheorem pow_le_one_iff_of_nonneg {a : R} (ha : 0 \u2264 a) {n : \u2115} (hn : n \u2260 0) : a ^ n \u2264 1 \u2194 a \u2264 1 :=\n  by\n  refine' \u27e8_, pow_le_one n ha\u27e9\n  rw [\u2190 not_lt, \u2190 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\u2093'. -/\ntheorem one_le_pow_iff_of_nonneg {a : R} (ha : 0 \u2264 a) {n : \u2115} (hn : n \u2260 0) : 1 \u2264 a ^ n \u2194 1 \u2264 a :=\n  by\n  refine' \u27e8_, fun h => one_le_pow_of_one_le h n\u27e9\n  rw [\u2190 not_lt, \u2190 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\u2093'. -/\ntheorem one_lt_pow_iff_of_nonneg {a : R} (ha : 0 \u2264 a) {n : \u2115} (hn : n \u2260 0) : 1 < a ^ n \u2194 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\u2093'. -/\ntheorem pow_lt_one_iff_of_nonneg {a : R} (ha : 0 \u2264 a) {n : \u2115} (hn : n \u2260 0) : a ^ n < 1 \u2194 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\u2093'. -/\ntheorem sq_le_one_iff {a : R} (ha : 0 \u2264 a) : a ^ 2 \u2264 1 \u2194 a \u2264 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\u2093'. -/\ntheorem sq_lt_one_iff {a : R} (ha : 0 \u2264 a) : a ^ 2 < 1 \u2194 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\u2093'. -/\ntheorem one_le_sq_iff {a : R} (ha : 0 \u2264 a) : 1 \u2264 a ^ 2 \u2194 1 \u2264 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\u2093'. -/\ntheorem one_lt_sq_iff {a : R} (ha : 0 \u2264 a) : 1 < a ^ 2 \u2194 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\u2093'. -/\n@[simp]\ntheorem pow_left_inj {x y : R} {n : \u2115} (Hxpos : 0 \u2264 x) (Hypos : 0 \u2264 y) (Hnpos : 0 < n) :\n    x ^ n = y ^ n \u2194 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\u2093'. -/\ntheorem lt_of_pow_lt_pow {a b : R} (n : \u2115) (hb : 0 \u2264 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\u2093'. -/\ntheorem le_of_pow_le_pow {a b : R} (n : \u2115) (hb : 0 \u2264 b) (hn : 0 < n) (h : a ^ n \u2264 b ^ n) : a \u2264 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\u2093'. -/\n@[simp]\ntheorem sq_eq_sq {a b : R} (ha : 0 \u2264 a) (hb : 0 \u2264 b) : a ^ 2 = b ^ 2 \u2194 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\u2093'. -/\ntheorem lt_of_mul_self_lt_mul_self (hb : 0 \u2264 b) : a * a < b * b \u2192 a < b :=\n  by\n  simp_rw [\u2190 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\u2093'. -/\ntheorem pow_abs (a : R) (n : \u2115) : |a| ^ n = |a ^ n| :=\n  ((absHom.toMonoidHom : R \u2192* 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\u2093'. -/\ntheorem abs_neg_one_pow (n : \u2115) : |(-1 : R) ^ n| = 1 := by rw [\u2190 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\u2093'. -/\ntheorem pow_bit0_nonneg (a : R) (n : \u2115) : 0 \u2264 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\u2093'. -/\ntheorem sq_nonneg (a : R) : 0 \u2264 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\u2093'. -/\nalias sq_nonneg \u2190 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\u2093'. -/\ntheorem pow_bit0_pos {a : R} (h : a \u2260 0) (n : \u2115) : 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\u2093'. -/\ntheorem sq_pos_of_ne_zero (a : R) (h : a \u2260 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\u2093'. -/\nalias sq_pos_of_ne_zero \u2190 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\u2093'. -/\ntheorem pow_bit0_pos_iff (a : R) {n : \u2115} (hn : n \u2260 0) : 0 < a ^ bit0 n \u2194 a \u2260 0 :=\n  by\n  refine' \u27e8fun h => _, fun h => pow_bit0_pos h n\u27e9\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\u2093'. -/\ntheorem sq_pos_iff (a : R) : 0 < a ^ 2 \u2194 a \u2260 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\ntheorem sq_lt_sq : x ^ 2 < y ^ 2 \u2194 |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'\u2093'. -/\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 \u27e8h1, h2\u27e9) (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\u2093'. -/\ntheorem sq_le_sq : x ^ 2 \u2264 y ^ 2 \u2194 |x| \u2264 |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'\u2093'. -/\ntheorem sq_le_sq' (h1 : -y \u2264 x) (h2 : x \u2264 y) : x ^ 2 \u2264 y ^ 2 :=\n  sq_le_sq.2 (le_trans (abs_le.mpr \u27e8h1, h2\u27e9) (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\u2093'. -/\ntheorem abs_lt_of_sq_lt_sq (h : x ^ 2 < y ^ 2) (hy : 0 \u2264 y) : |x| < y := by\n  rwa [\u2190 abs_of_nonneg hy, \u2190 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'\u2093'. -/\ntheorem abs_lt_of_sq_lt_sq' (h : x ^ 2 < y ^ 2) (hy : 0 \u2264 y) : -y < x \u2227 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\u2093'. -/\ntheorem abs_le_of_sq_le_sq (h : x ^ 2 \u2264 y ^ 2) (hy : 0 \u2264 y) : |x| \u2264 y := by\n  rwa [\u2190 abs_of_nonneg hy, \u2190 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'\u2093'. -/\ntheorem abs_le_of_sq_le_sq' (h : x ^ 2 \u2264 y ^ 2) (hy : 0 \u2264 y) : -y \u2264 x \u2227 x \u2264 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\u2093'. -/\ntheorem sq_eq_sq_iff_abs_eq_abs (x y : R) : x ^ 2 = y ^ 2 \u2194 |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\u2093'. -/\n@[simp]\ntheorem sq_le_one_iff_abs_le_one (x : R) : x ^ 2 \u2264 1 \u2194 |x| \u2264 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\u2093'. -/\n@[simp]\ntheorem sq_lt_one_iff_abs_lt_one (x : R) : x ^ 2 < 1 \u2194 |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\u2093'. -/\n@[simp]\ntheorem one_le_sq_iff_one_le_abs (x : R) : 1 \u2264 x ^ 2 \u2194 1 \u2264 |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\u2093'. -/\n@[simp]\ntheorem one_lt_sq_iff_one_lt_abs (x : R) : 1 < x ^ 2 \u2194 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\u2093'. -/\ntheorem pow_four_le_pow_two_of_pow_two_le {x y : R} (h : x ^ 2 \u2264 y) : x ^ 4 \u2264 y ^ 2 :=\n  (pow_mul x 2 2).symm \u25b8 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\u2093'. -/\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 \u2264 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\u2093'. -/\nalias two_mul_le_add_sq \u2190 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 : \u2115}\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\u2093'. -/\ntheorem pow_pos_iff (hn : 0 < n) : 0 < a ^ n \u2194 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 : \u2115}\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\u2093'. -/\ntheorem pow_lt_pow_succ (ha : 1 < a) : a ^ n < a ^ n.succ :=\n  by\n  rw [\u2190 one_mul (a ^ n), pow_succ]\n  exact mul_lt_right\u2080 _ 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\u2080 -> pow_lt_pow\u2080 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\u2080 pow_lt_pow\u2080\u2093'. -/\ntheorem pow_lt_pow\u2080 (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\u2080 pow_lt_pow\u2080\n\nend LinearOrderedCommGroupWithZero\n\nnamespace MonoidHom\n\nvariable [Ring R] [Monoid M] [LinearOrder M] [CovariantClass M M (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)] (f : R \u2192* 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\u2093'. -/\ntheorem map_neg_one : f (-1) = 1 :=\n  (pow_eq_one_iff (Nat.succ_ne_zero 1)).1 <| by rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem map_neg (x : R) : f (-x) = f x := by rw [\u2190 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\u2093'. -/\ntheorem map_sub_swap (x y : R) : f (x - y) = f (y - x) := by rw [\u2190 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) 2022 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\nimport Aesop\n\nset_option aesop.check.all true\n\n@[aesop 50%]\ninductive Even : Nat \u2192 Prop\n| zero : Even 0\n| plus_two {n} : Even n \u2192 Even (n + 2)\n\nstructure Even' (n) where\n  even : Even n\n\ntheorem even'_of_false : False \u2192 Even' n\n| h => nomatch h\n\ntheorem even'_of_even' : Even' n \u2192 Even' n :=\n  id\n\n-- Once a safe rule is applied, the corresponding goal is marked as inactive\n-- and never visited again.\nexample : Even' 2 := by\n  fail_if_success aesop\n    (add safe [even'_of_false 0, Even'.mk 1]) (options := { terminal := true })\n  fail_if_success aesop\n    (add safe [even'_of_even'], unsafe [Even'.mk 100%])\n    (options := { maxRuleApplications := 10 })\n  aesop\n    (add safe [even'_of_false 1, Even'.mk 0])\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/Safe.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8519528170040853, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4854875716495382}}
{"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} {\u0393\u2080 : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero \u0393\u2080] {v : valuation R \u0393\u2080} {O : Type w} [comm_ring O] [algebra O R] (hv : integers v O) {x : R} (hx : is_integral O x) : x \u2208 integer v := sorry\n\nprotected theorem integral_closure {R : Type u} {\u0393\u2080 : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero \u0393\u2080] {v : valuation R \u0393\u2080} {O : Type w} [comm_ring O] [algebra O R] (hv : integers v O) : integral_closure O R = \u22a5 := 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 `\u2210 V i j \u21c9 \u2210 U i`, so that the general colimit API\n    can be used.\n* `algebraic_geometry.Scheme.glue_data.\u03b9`: The immersion `\u03b9 i : U i \u27f6 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  `\ud835\udcb0.glue_data.glued \u27f6 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.\u03b9_is_open_immersion`: The map `\u03b9 i : U i \u27f6 glued`\n  is an open immersion for each `i : J`.\n* `algebraic_geometry.Scheme.glue_data.\u03b9_jointly_surjective` : The underlying maps of\n  `\u03b9 i : U i \u27f6 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.\u03b9_eq_iff_rel` : `\u03b9 i x = \u03b9 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 \u00d7 J \u2192 Scheme` rather than `J \u2192 J \u2192 Scheme` to connect to the\n  limits library easier.)\n4. An open immersion `f i j : V i j \u27f6 U i` for each `i j : \u03b9`.\n5. A transition map `t i j : V i j \u27f6 V j i` for each `i j : \u03b9`.\nsuch that\n6. `f i i` is an isomorphism.\n7. `t i i` is the identity.\n8. `V i j \u00d7[U i] V i k \u27f6 V i j \u27f6 V j i` factors through `V j k \u00d7[U j] V j i \u27f6 V j i` via some\n    `t' : V i j \u00d7[U i] V i k \u27f6 V j k \u00d7[U j] V j i`.\n9. `t' i j k \u226b t' j k i \u226b t' k i j = \ud835\udfd9 _`.\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 : \u2200 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: \u00abexpr\ud835\udda3\u00bb\nlocal notation \"\ud835\udda3\" => 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 := \ud835\udda3.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 \u27e8i, y, rfl\u27e9 := D.to_LocallyRingedSpace_glue_data.\u03b9_jointly_surjective x\n  refine' \u27e8_, _ \u226b D.to_LocallyRingedSpace_glue_data.to_glue_data.\u03b9 i, _\u27e9\n  swap; exact (D.U i).affineCover.map y\n  constructor\n  \u00b7 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  \u00b7 infer_instance\n#align algebraic_geometry.Scheme.glue_data.glued_Scheme AlgebraicGeometry.Scheme.GlueData.gluedScheme\n\ninstance : CreatesColimit \ud835\udda3.diagram.multispan forgetToLocallyRingedSpace :=\n  createsColimitOfFullyFaithfulOfIso D.gluedScheme\n    (HasColimit.isoOfNatIso (\ud835\udda3.diagramIso forgetToLocallyRingedSpace).symm)\n\ninstance : PreservesColimit \ud835\udda3.diagram.multispan forgetToTop :=\n  by\n  delta forget_to_Top LocallyRingedSpace.forget_to_Top\n  infer_instance\n\ninstance : HasMulticoequalizer \ud835\udda3.diagram :=\n  hasColimit_of_created _ forgetToLocallyRingedSpace\n\n/-- The glued scheme of a glued space. -/\nabbrev glued : Scheme :=\n  \ud835\udda3.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 \u03b9 (i : D.J) : D.U i \u27f6 D.glued :=\n  \ud835\udda3.\u03b9 i\n#align algebraic_geometry.Scheme.glue_data.\u03b9 AlgebraicGeometry.Scheme.GlueData.\u03b9\n\n/-- The gluing as sheafed spaces is isomorphic to the gluing as presheafed spaces. -/\nabbrev isoLocallyRingedSpace :\n    D.glued.toLocallyRingedSpace \u2245 D.toLocallyRingedSpaceGlueData.toGlueData.glued :=\n  \ud835\udda3.gluedIso forgetToLocallyRingedSpace\n#align algebraic_geometry.Scheme.glue_data.iso_LocallyRingedSpace AlgebraicGeometry.Scheme.GlueData.isoLocallyRingedSpace\n\ntheorem \u03b9_isoLocallyRingedSpace_inv (i : D.J) :\n    D.toLocallyRingedSpaceGlueData.toGlueData.\u03b9 i \u226b D.isoLocallyRingedSpace.inv = \ud835\udda3.\u03b9 i :=\n  \ud835\udda3.\u03b9_gluedIso_inv forgetToLocallyRingedSpace i\n#align algebraic_geometry.Scheme.glue_data.\u03b9_iso_LocallyRingedSpace_inv AlgebraicGeometry.Scheme.GlueData.\u03b9_isoLocallyRingedSpace_inv\n\ninstance \u03b9_isOpenImmersion (i : D.J) : IsOpenImmersion (\ud835\udda3.\u03b9 i) :=\n  by\n  rw [\u2190 D.\u03b9_iso_LocallyRingedSpace_inv]\n  infer_instance\n#align algebraic_geometry.Scheme.glue_data.\u03b9_is_open_immersion AlgebraicGeometry.Scheme.GlueData.\u03b9_isOpenImmersion\n\ntheorem \u03b9_jointly_surjective (x : \ud835\udda3.glued.carrier) :\n    \u2203 (i : D.J)(y : (D.U i).carrier), (D.\u03b9 i).1.base y = x :=\n  \ud835\udda3.\u03b9_jointly_surjective (forgetToTop \u22d9 forget TopCat) x\n#align algebraic_geometry.Scheme.glue_data.\u03b9_jointly_surjective AlgebraicGeometry.Scheme.GlueData.\u03b9_jointly_surjective\n\n@[simp, reassoc.1]\ntheorem glue_condition (i j : D.J) : D.t i j \u226b D.f j i \u226b D.\u03b9 j = D.f i j \u226b D.\u03b9 i :=\n  \ud835\udda3.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 \u27f6 U i` and `V i j \u27f6 U j`.\nThis is a pullback diagram (`V_pullback_cone_is_limit`). -/\ndef vPullbackCone (i j : D.J) : PullbackCone (D.\u03b9 i) (D.\u03b9 j) :=\n  PullbackCone.mk (D.f i j) (D.t i j \u226b 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\u1d62\u2c7c` is the intersection of `U\u1d62` and `U\u2c7c` in `X`.\n\nV\u1d62\u2c7c \u27f6 U\u1d62\n |      |\n \u2193      \u2193\n U\u2c7c \u27f6 X\n-/\ndef vPullbackConeIsLimit (i j : D.J) : IsLimit (D.vPullbackCone i j) :=\n  \ud835\udda3.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 \u2245\n      D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.toPresheafedSpaceGlueData.toTopGlueData.toGlueData.glued :=\n  by\n  refine' (PresheafedSpace.forget _).mapIso _ \u226a\u226b glue_data.glued_iso _ (PresheafedSpace.forget _)\n  refine'\n    SheafedSpace.forget_to_PresheafedSpace.map_iso _ \u226a\u226b SheafedSpace.glue_data.iso_PresheafedSpace _\n  refine'\n    LocallyRingedSpace.forget_to_SheafedSpace.map_iso _ \u226a\u226b\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 \u03b9_isoCarrier_inv (i : D.J) :\n    D.toLocallyRingedSpaceGlueData.toSheafedSpaceGlueData.toPresheafedSpaceGlueData.toTopGlueData.toGlueData.\u03b9\n          i \u226b\n        D.isoCarrier.inv =\n      (D.\u03b9 i).1.base :=\n  by\n  delta iso_carrier\n  simp only [functor.map_iso_inv, iso.trans_inv, iso.trans_assoc, glue_data.\u03b9_glued_iso_inv_assoc,\n    functor.map_iso_trans, category.assoc]\n  iterate 3 erw [\u2190 comp_base]\n  simp_rw [\u2190 category.assoc]\n  rw [D.to_LocallyRingedSpace_glue_data.to_SheafedSpace_glue_data.\u03b9_iso_PresheafedSpace_inv i]\n  erw [D.to_LocallyRingedSpace_glue_data.\u03b9_iso_SheafedSpace_inv i]\n  change (_ \u226b D.iso_LocallyRingedSpace.inv).1.base = _\n  rw [D.\u03b9_iso_LocallyRingedSpace_inv i]\n#align algebraic_geometry.Scheme.glue_data.\u03b9_iso_carrier_inv AlgebraicGeometry.Scheme.GlueData.\u03b9_isoCarrier_inv\n\n/-- An equivalence relation on `\u03a3 i, D.U i` that holds iff `\ud835\udda3 .\u03b9 i x = \ud835\udda3 .\u03b9 j y`.\nSee `Scheme.gluing_data.\u03b9_eq_iff`. -/\ndef Rel (a b : \u03a3i, ((D.U i).carrier : Type _)) : Prop :=\n  a = b \u2228\n    \u2203 x : (D.V (a.1, b.1)).carrier, (D.f _ _).1.base x = a.2 \u2227 (D.t _ _ \u226b D.f _ _).1.base x = b.2\n#align algebraic_geometry.Scheme.glue_data.rel AlgebraicGeometry.Scheme.GlueData.Rel\n\ntheorem \u03b9_eq_iff (i j : D.J) (x : (D.U i).carrier) (y : (D.U j).carrier) :\n    (\ud835\udda3.\u03b9 i).1.base x = (\ud835\udda3.\u03b9 j).1.base y \u2194 D.Rel \u27e8i, x\u27e9 \u27e8j, y\u27e9 :=\n  by\n  refine'\n    Iff.trans _\n      (D.to_LocallyRingedSpace_glue_data.to_SheafedSpace_glue_data.toPresheafedSpaceGlueData.toTopGlueData.\u03b9_eq_iff_rel\n        i j x y)\n  rw [\u2190 ((TopCat.mono_iff_injective D.iso_carrier.inv).mp inferInstance).eq_iff]\n  simp_rw [\u2190 comp_apply, D.\u03b9_iso_carrier_inv]\n#align algebraic_geometry.Scheme.glue_data.\u03b9_eq_iff AlgebraicGeometry.Scheme.GlueData.\u03b9_eq_iff\n\ntheorem isOpen_iff (U : Set D.glued.carrier) : IsOpen U \u2194 \u2200 i, IsOpen ((D.\u03b9 i).1.base \u207b\u00b9' U) :=\n  by\n  rw [\u2190 (TopCat.homeoOfIso D.iso_carrier.symm).isOpen_preimage]\n  rw [TopCat.GlueData.isOpen_iff]\n  apply forall_congr'\n  intro i\n  erw [\u2190 Set.preimage_comp, \u2190 coe_comp, \u03b9_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.\u03b9\n  f x := (D.\u03b9_jointly_surjective x).some\n  Covers x := \u27e8_, (D.\u03b9_jointly_surjective x).choose_spec.choose_spec\u27e9\n#align algebraic_geometry.Scheme.glue_data.open_cover AlgebraicGeometry.Scheme.GlueData.openCover\n\nend GlueData\n\nnamespace OpenCover\n\nvariable {X : Scheme.{u}} (\ud835\udcb0 : OpenCover.{u} X)\n\n/-- (Implementation) the transition maps in the glue data associated with an open cover. -/\ndef gluedCoverT' (x y z : \ud835\udcb0.J) :\n    pullback (pullback.fst : pullback (\ud835\udcb0.map x) (\ud835\udcb0.map y) \u27f6 _)\n        (pullback.fst : pullback (\ud835\udcb0.map x) (\ud835\udcb0.map z) \u27f6 _) \u27f6\n      pullback (pullback.fst : pullback (\ud835\udcb0.map y) (\ud835\udcb0.map z) \u27f6 _)\n        (pullback.fst : pullback (\ud835\udcb0.map y) (\ud835\udcb0.map x) \u27f6 _) :=\n  by\n  refine' (pullback_right_pullback_fst_iso _ _ _).Hom \u226b _\n  refine' _ \u226b (pullback_symmetry _ _).Hom\n  refine' _ \u226b (pullback_right_pullback_fst_iso _ _ _).inv\n  refine' pullback.map _ _ _ _ (pullback_symmetry _ _).Hom (\ud835\udfd9 _) (\ud835\udfd9 _) _ _\n  \u00b7 simp [pullback.condition]\n  \u00b7 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 : \ud835\udcb0.J) :\n    \ud835\udcb0.gluedCoverT' x y z \u226b pullback.fst \u226b pullback.fst = pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    gluedCoverT' \ud835\udcb0 x y z \u226b pullback.fst \u226b pullback.snd = pullback.snd \u226b 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 : \ud835\udcb0.J) :\n    gluedCoverT' \ud835\udcb0 x y z \u226b pullback.snd \u226b pullback.fst = pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    gluedCoverT' \ud835\udcb0 x y z \u226b pullback.snd \u226b pullback.snd = pullback.fst \u226b 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 : \ud835\udcb0.J) :\n    gluedCoverT' \ud835\udcb0 x y z \u226b gluedCoverT' \ud835\udcb0 y z x \u226b gluedCoverT' \ud835\udcb0 z x y \u226b 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 : \ud835\udcb0.J) :\n    gluedCoverT' \ud835\udcb0 x y z \u226b gluedCoverT' \ud835\udcb0 y z x \u226b gluedCoverT' \ud835\udcb0 z x y \u226b 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 : \ud835\udcb0.J) :\n    gluedCoverT' \ud835\udcb0 x y z \u226b gluedCoverT' \ud835\udcb0 y z x \u226b gluedCoverT' \ud835\udcb0 z x y = \ud835\udfd9 _ :=\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 `\ud835\udcb0.glued_cover.glued \u27f6 X` is provided by `\ud835\udcb0.from_glued`. -/\n@[simps]\ndef gluedCover : Scheme.GlueData.{u} where\n  J := \ud835\udcb0.J\n  U := \ud835\udcb0.obj\n  V := fun \u27e8x, y\u27e9 => pullback (\ud835\udcb0.map x) (\ud835\udcb0.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' \ud835\udcb0 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 \ud835\udcb0 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 : \ud835\udcb0.gluedCover.glued \u27f6 X :=\n  by\n  fapply multicoequalizer.desc\n  exact fun x => \ud835\udcb0.map x\n  rintro \u27e8x, y\u27e9\n  change pullback.fst \u226b _ = ((pullback_symmetry _ _).Hom \u226b pullback.fst) \u226b _\n  simpa using pullback.condition\n#align algebraic_geometry.Scheme.open_cover.from_glued AlgebraicGeometry.Scheme.OpenCover.fromGlued\n\n@[simp, reassoc.1]\ntheorem \u03b9_fromGlued (x : \ud835\udcb0.J) : \ud835\udcb0.gluedCover.\u03b9 x \u226b \ud835\udcb0.fromGlued = \ud835\udcb0.map x :=\n  Multicoequalizer.\u03c0_desc _ _ _ _ _\n#align algebraic_geometry.Scheme.open_cover.\u03b9_from_glued AlgebraicGeometry.Scheme.OpenCover.\u03b9_fromGlued\n\ntheorem fromGlued_injective : Function.Injective \ud835\udcb0.fromGlued.1.base :=\n  by\n  intro x y h\n  obtain \u27e8i, x, rfl\u27e9 := \ud835\udcb0.glued_cover.\u03b9_jointly_surjective x\n  obtain \u27e8j, y, rfl\u27e9 := \ud835\udcb0.glued_cover.\u03b9_jointly_surjective y\n  simp_rw [\u2190 comp_apply, \u2190 SheafedSpace.comp_base, \u2190 LocallyRingedSpace.comp_val] at h\n  erw [\u03b9_from_glued, \u03b9_from_glued] at h\n  let e :=\n    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso\n      (is_limit_of_has_pullback_of_preserves_limit Scheme.forget_to_Top (\ud835\udcb0.map i) (\ud835\udcb0.map j))\n  rw [\ud835\udcb0.glued_cover.\u03b9_eq_iff]\n  right\n  use e.hom \u27e8\u27e8x, y\u27e9, h\u27e9\n  simp_rw [\u2190 comp_apply]\n  constructor\n  \u00b7 erw [is_limit.cone_point_unique_up_to_iso_hom_comp _ _ walking_cospan.left]\n    rfl\n  \u00b7 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 : \ud835\udcb0.gluedCover.glued.carrier) :\n    IsIso (PresheafedSpace.stalkMap \ud835\udcb0.fromGlued.val x) :=\n  by\n  obtain \u27e8i, x, rfl\u27e9 := \ud835\udcb0.glued_cover.\u03b9_jointly_surjective x\n  have :=\n    PresheafedSpace.stalk_map.congr_hom _ _\n      (congr_arg LocallyRingedSpace.hom.val <| \ud835\udcb0.\u03b9_from_glued i) x\n  erw [PresheafedSpace.stalk_map.comp] at this\n  rw [\u2190 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 \ud835\udcb0.fromGlued.1.base :=\n  by\n  intro U hU\n  rw [isOpen_iff_forall_mem_open]\n  intro x hx\n  rw [\ud835\udcb0.glued_cover.is_open_iff] at hU\n  use \ud835\udcb0.from_glued.val.base '' U \u2229 Set.range (\ud835\udcb0.map (\ud835\udcb0.f x)).1.base\n  use Set.inter_subset_left _ _\n  constructor\n  \u00b7 rw [\u2190 Set.image_preimage_eq_inter_range]\n    apply show is_open_immersion (\ud835\udcb0.map (\ud835\udcb0.f x)) by infer_instance.base_open.IsOpenMap\n    convert hU (\ud835\udcb0.f x) using 1\n    rw [\u2190 \u03b9_from_glued]\n    erw [coe_comp]\n    rw [Set.preimage_comp]\n    congr 1\n    refine' Set.preimage_image_eq _ \ud835\udcb0.from_glued_injective\n  \u00b7 exact \u27e8hx, \ud835\udcb0.covers x\u27e9\n#align algebraic_geometry.Scheme.open_cover.from_glued_open_map AlgebraicGeometry.Scheme.OpenCover.fromGlued_open_map\n\ntheorem fromGlued_openEmbedding : OpenEmbedding \ud835\udcb0.fromGlued.1.base :=\n  openEmbedding_of_continuous_injective_open (by continuity) \ud835\udcb0.fromGlued_injective\n    \ud835\udcb0.fromGlued_open_map\n#align algebraic_geometry.Scheme.open_cover.from_glued_open_embedding AlgebraicGeometry.Scheme.OpenCover.fromGlued_openEmbedding\n\ninstance : Epi \ud835\udcb0.fromGlued.val.base :=\n  by\n  rw [TopCat.epi_iff_surjective]\n  intro x\n  obtain \u27e8y, h\u27e9 := \ud835\udcb0.covers x\n  use (\ud835\udcb0.glued_cover.\u03b9 (\ud835\udcb0.f x)).1.base y\n  rw [\u2190 comp_apply]\n  rw [\u2190 \ud835\udcb0.\u03b9_from_glued (\ud835\udcb0.f x)] at h\n  exact h\n\ninstance fromGlued_open_immersion : IsOpenImmersion \ud835\udcb0.fromGlued :=\n  SheafedSpace.IsOpenImmersion.of_stalk_iso _ \ud835\udcb0.fromGlued_openEmbedding\n#align algebraic_geometry.Scheme.open_cover.from_glued_open_immersion AlgebraicGeometry.Scheme.OpenCover.fromGlued_open_immersion\n\ninstance : IsIso \ud835\udcb0.fromGlued :=\n  by\n  apply\n    is_iso_of_reflects_iso _\n      (Scheme.forget_to_LocallyRingedSpace \u22d9\n        LocallyRingedSpace.forget_to_SheafedSpace \u22d9 SheafedSpace.forget_to_PresheafedSpace)\n  change @is_iso (PresheafedSpace _) _ _ _ \ud835\udcb0.from_glued.val\n  apply PresheafedSpace.is_open_immersion.to_iso\n\n/-- Given an open cover of `X`, and a morphism `\ud835\udcb0.obj x \u27f6 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 \u27f6 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 : \u2200 x, \ud835\udcb0.obj x \u27f6 Y)\n    (hf : \u2200 x y, (pullback.fst : pullback (\ud835\udcb0.map x) (\ud835\udcb0.map y) \u27f6 _) \u226b f x = pullback.snd \u226b f y) :\n    X \u27f6 Y := by\n  refine' inv \ud835\udcb0.from_glued \u226b _\n  fapply multicoequalizer.desc\n  exact f\n  rintro \u27e8i, j\u27e9\n  change pullback.fst \u226b f i = (_ \u226b _) \u226b 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 \u03b9_glueMorphisms {Y : Scheme} (f : \u2200 x, \ud835\udcb0.obj x \u27f6 Y)\n    (hf : \u2200 x y, (pullback.fst : pullback (\ud835\udcb0.map x) (\ud835\udcb0.map y) \u27f6 _) \u226b f x = pullback.snd \u226b f y)\n    (x : \ud835\udcb0.J) : \ud835\udcb0.map x \u226b \ud835\udcb0.glueMorphisms f hf = f x :=\n  by\n  rw [\u2190 \u03b9_from_glued, category.assoc]\n  erw [is_iso.hom_inv_id_assoc, multicoequalizer.\u03c0_desc]\n#align algebraic_geometry.Scheme.open_cover.\u03b9_glue_morphisms AlgebraicGeometry.Scheme.OpenCover.\u03b9_glueMorphisms\n\ntheorem hom_ext {Y : Scheme} (f\u2081 f\u2082 : X \u27f6 Y) (h : \u2200 x, \ud835\udcb0.map x \u226b f\u2081 = \ud835\udcb0.map x \u226b f\u2082) : f\u2081 = f\u2082 :=\n  by\n  rw [\u2190 cancel_epi \ud835\udcb0.from_glued]\n  apply multicoequalizer.hom_ext\n  intro x\n  erw [multicoequalizer.\u03c0_desc_assoc]\n  erw [multicoequalizer.\u03c0_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\u2093'. -/\ntheorem smul_eq_map [MulSemiringAction M R] (m : M) :\n    (\u00b7 \u2022 \u00b7) 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 \u2022 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 := (\u00b7 \u2022 \u00b7)\n    smul_one := fun m =>\n      (smul_eq_map R m).symm \u25b8 Polynomial.map_one (MulSemiringAction.toRingHom M R m)\n    smul_mul := fun m p q =>\n      (smul_eq_map R m).symm \u25b8 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\u2093'. -/\n@[simp]\ntheorem smul_X (m : M) : (m \u2022 X : R[X]) = X :=\n  (smul_eq_map R m).symm \u25b8 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\u2093'. -/\ntheorem smul_eval_smul (m : M) (f : S[X]) (x : S) : (m \u2022 f).eval (m \u2022 x) = m \u2022 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'\u2093'. -/\ntheorem eval_smul' [MulSemiringAction G S] (g : G) (f : S[X]) (x : S) :\n    f.eval (g \u2022 x) = g \u2022 (g\u207b\u00b9 \u2022 f).eval x := by rw [\u2190 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\u2093'. -/\ntheorem smul_eval [MulSemiringAction G S] (g : G) (f : S[X]) (x : S) :\n    (g \u2022 f).eval x = g \u2022 f.eval (g\u207b\u00b9 \u2022 x) := by rw [\u2190 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 \u2022 x)` over distinct `g \u2022 x`. -/\nnoncomputable def prodXSubSmul (x : R) : R[X] :=\n  (Finset.univ : Finset (G \u29f8 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\u2093'. -/\ntheorem prodXSubSmul.eval (x : R) : (prodXSubSmul G R x).eval x = 0 :=\n  (MonoidHom.map_prod ((Polynomial.aeval x).toRingHom.toMonoidHom : R[X] \u2192* 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\u2093'. -/\ntheorem prodXSubSmul.smul (x : R) (g : G) : g \u2022 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\u2093'. -/\ntheorem prodXSubSmul.coeff (x : R) (g : G) (n : \u2115) :\n    g \u2022 (prodXSubSmul G R x).coeff n = (prodXSubSmul G R x).coeff n := by\n  rw [\u2190 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\u2093'. -/\n/-- An equivariant map induces an equivariant map on polynomials. -/\nprotected noncomputable def polynomial (g : P \u2192+*[M] Q) : P[X] \u2192+*[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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_polynomial (g : P \u2192+*[M] Q) : (g.Polynomial : P[X] \u2192 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] (\u03b1 : Type v) := m \u2192 n \u2192 \u03b1\n\nnamespace matrix\n\n\ntheorem ext_iff {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    {M : matrix m n \u03b1} {N : matrix m n \u03b1} : (\u2200 (i : m) (j : n), M i j = N i j) \u2194 M = N :=\n  sorry\n\ntheorem ext {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} {M : matrix m n \u03b1}\n    {N : matrix m n \u03b1} : (\u2200 (i : m) (j : n), M i j = N i j) \u2192 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] {\u03b1 : Type v} (M : matrix m n \u03b1)\n    {\u03b2 : Type w} (f : \u03b1 \u2192 \u03b2) : matrix m n \u03b2 :=\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] {\u03b1 : Type v}\n    {M : matrix m n \u03b1} {\u03b2 : Type w} {f : \u03b1 \u2192 \u03b2} {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] {\u03b1 : Type v}\n    {M : matrix m n \u03b1} {\u03b2 : Type u_1} {\u03b3 : Type u_4} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} :\n    map (map M f) g = map M (g \u2218 f) :=\n  sorry\n\n/-- The transpose of a matrix. -/\ndef transpose {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    (M : matrix m n \u03b1) : matrix n m \u03b1 :=\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] {\u03b1 : Type v} (w : m \u2192 \u03b1) : matrix m Unit \u03b1 := sorry\n\n/-- `matrix.row u` is the row matrix whose entries are given by `u`. -/\ndef row {n : Type u_3} [fintype n] {\u03b1 : Type v} (v : n \u2192 \u03b1) : matrix Unit n \u03b1 := sorry\n\nprotected instance inhabited {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [Inhabited \u03b1] : Inhabited (matrix m n \u03b1) :=\n  pi.inhabited m\n\nprotected instance has_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [Add \u03b1] : Add (matrix m n \u03b1) :=\n  pi.has_add\n\nprotected instance add_semigroup {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [add_semigroup \u03b1] : add_semigroup (matrix m n \u03b1) :=\n  pi.add_semigroup\n\nprotected instance add_comm_semigroup {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {\u03b1 : Type v} [add_comm_semigroup \u03b1] : add_comm_semigroup (matrix m n \u03b1) :=\n  pi.add_comm_semigroup\n\nprotected instance has_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [HasZero \u03b1] : HasZero (matrix m n \u03b1) :=\n  pi.has_zero\n\nprotected instance add_monoid {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [add_monoid \u03b1] : add_monoid (matrix m n \u03b1) :=\n  pi.add_monoid\n\nprotected instance add_comm_monoid {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {\u03b1 : Type v} [add_comm_monoid \u03b1] : add_comm_monoid (matrix m n \u03b1) :=\n  pi.add_comm_monoid\n\nprotected instance has_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [Neg \u03b1] : Neg (matrix m n \u03b1) :=\n  pi.has_neg\n\nprotected instance has_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [Sub \u03b1] : Sub (matrix m n \u03b1) :=\n  pi.has_sub\n\nprotected instance add_group {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [add_group \u03b1] : add_group (matrix m n \u03b1) :=\n  pi.add_group\n\nprotected instance add_comm_group {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [add_comm_group \u03b1] : add_comm_group (matrix m n \u03b1) :=\n  pi.add_comm_group\n\n@[simp] theorem zero_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [HasZero \u03b1] (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] {\u03b1 : Type v} [Neg \u03b1]\n    (M : matrix m n \u03b1) (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] {\u03b1 : Type v} [Add \u03b1]\n    (M : matrix m n \u03b1) (N : matrix m n \u03b1) (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] {\u03b1 : Type v} [Sub \u03b1]\n    (M : matrix m n \u03b1) (N : matrix m n \u03b1) (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] {\u03b1 : Type v}\n    [HasZero \u03b1] {\u03b2 : Type w} [HasZero \u03b2] {f : \u03b1 \u2192 \u03b2} (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] {\u03b1 : Type v} [add_monoid \u03b1]\n    {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2192+ \u03b2) (M : matrix m n \u03b1) (N : matrix m n \u03b1) :\n    map (M + N) \u21d1f = map M \u21d1f + map N \u21d1f :=\n  sorry\n\ntheorem map_sub {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [add_group \u03b1]\n    {\u03b2 : Type w} [add_group \u03b2] (f : \u03b1 \u2192+ \u03b2) (M : matrix m n \u03b1) (N : matrix m n \u03b1) :\n    map (M - N) \u21d1f = map M \u21d1f - map N \u21d1f :=\n  sorry\n\ntheorem subsingleton_of_empty_left {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {\u03b1 : Type v} (hm : \u00acNonempty m) : subsingleton (matrix m n \u03b1) :=\n  sorry\n\ntheorem subsingleton_of_empty_right {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {\u03b1 : Type v} (hn : \u00acNonempty n) : subsingleton (matrix m n \u03b1) :=\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] {\u03b1 : Type v}\n    [add_monoid \u03b1] {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2192+ \u03b2) : matrix m n \u03b1 \u2192+ matrix m n \u03b2 :=\n  add_monoid_hom.mk (fun (M : matrix m n \u03b1) => matrix.map M \u21d1f) 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] {\u03b1 : Type v} [add_monoid \u03b1] {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2192+ \u03b2)\n    (M : matrix m n \u03b1) : coe_fn (add_monoid_hom.map_matrix f) M = matrix.map M \u21d1f :=\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 \u2260 j`. -/\ndef diagonal {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] (d : n \u2192 \u03b1) :\n    matrix n n \u03b1 :=\n  fun (i j : n) => ite (i = j) (d i) 0\n\n@[simp] theorem diagonal_apply_eq {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n]\n    [HasZero \u03b1] {d : n \u2192 \u03b1} (i : n) : diagonal d i i = d i :=\n  sorry\n\n@[simp] theorem diagonal_apply_ne {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n]\n    [HasZero \u03b1] {d : n \u2192 \u03b1} {i : n} {j : n} (h : i \u2260 j) : diagonal d i j = 0 :=\n  sorry\n\ntheorem diagonal_apply_ne' {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1]\n    {d : n \u2192 \u03b1} {i : n} {j : n} (h : j \u2260 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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] :\n    (diagonal fun (_x : n) => 0) = 0 :=\n  sorry\n\n@[simp] theorem diagonal_transpose {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n]\n    [HasZero \u03b1] (v : n \u2192 \u03b1) : transpose (diagonal v) = diagonal v :=\n  sorry\n\n@[simp] theorem diagonal_add {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [add_monoid \u03b1]\n    (d\u2081 : n \u2192 \u03b1) (d\u2082 : n \u2192 \u03b1) : diagonal d\u2081 + diagonal d\u2082 = diagonal fun (i : n) => d\u2081 i + d\u2082 i :=\n  sorry\n\n@[simp] theorem diagonal_map {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] {\u03b2 : Type w}\n    [HasZero \u03b1] [HasZero \u03b2] {f : \u03b1 \u2192 \u03b2} (h : f 0 = 0) {d : n \u2192 \u03b1} :\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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1]\n    [HasOne \u03b1] : HasOne (matrix n n \u03b1) :=\n  { one := diagonal fun (_x : n) => 1 }\n\n@[simp] theorem diagonal_one {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1]\n    [HasOne \u03b1] : (diagonal fun (_x : n) => 1) = 1 :=\n  rfl\n\ntheorem one_apply {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1]\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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1]\n    [HasOne \u03b1] (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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1]\n    [HasOne \u03b1] {i : n} {j : n} : i \u2260 j \u2192 HasOne.one i j = 0 :=\n  diagonal_apply_ne\n\ntheorem one_apply_ne' {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1] [HasOne \u03b1]\n    {i : n} {j : n} : j \u2260 i \u2192 HasOne.one i j = 0 :=\n  diagonal_apply_ne'\n\n@[simp] theorem one_map {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1]\n    [HasOne \u03b1] {\u03b2 : Type w} [HasZero \u03b2] [HasOne \u03b2] {f : \u03b1 \u2192 \u03b2} (h\u2080 : f 0 = 0) (h\u2081 : f 1 = 1) :\n    map 1 f = 1 :=\n  sorry\n\n@[simp] theorem bit0_apply {m : Type u_2} [fintype m] {\u03b1 : Type v} [Add \u03b1] (M : matrix m m \u03b1)\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] {\u03b1 : Type v} [DecidableEq n] [add_monoid \u03b1] [HasOne \u03b1]\n    (M : matrix n n \u03b1) (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] {\u03b1 : Type v} [DecidableEq n] [add_monoid \u03b1]\n    [HasOne \u03b1] (M : matrix n n \u03b1) (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] {\u03b1 : Type v} [DecidableEq n] [add_monoid \u03b1]\n    [HasOne \u03b1] (M : matrix n n \u03b1) {i : n} {j : n} (h : i \u2260 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] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] (v : m \u2192 \u03b1)\n    (w : m \u2192 \u03b1) : \u03b1 :=\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] {\u03b1 : Type v}\n    [semiring \u03b1] (u : m \u2192 \u03b1) (v : m \u2192 n \u2192 \u03b1) (w : n \u2192 \u03b1) :\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] {\u03b1 : Type v} [comm_semiring \u03b1] (v : m \u2192 \u03b1)\n    (w : m \u2192 \u03b1) : dot_product v w = dot_product w v :=\n  sorry\n\n@[simp] theorem dot_product_punit {\u03b1 : Type v} [add_comm_monoid \u03b1] [Mul \u03b1] (v : PUnit \u2192 \u03b1)\n    (w : PUnit \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) :\n    dot_product v 0 = 0 :=\n  sorry\n\n@[simp] theorem dot_product_zero' {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) :\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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) :\n    dot_product 0 v = 0 :=\n  sorry\n\n@[simp] theorem zero_dot_product' {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) :\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] {\u03b1 : Type v} [semiring \u03b1] (u : m \u2192 \u03b1)\n    (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (u : m \u2192 \u03b1)\n    (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [DecidableEq m]\n    [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [DecidableEq m]\n    [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [DecidableEq m]\n    [semiring \u03b1] (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [ring \u03b1] (v : m \u2192 \u03b1)\n    (w : m \u2192 \u03b1) : dot_product (-v) w = -dot_product v w :=\n  sorry\n\n@[simp] theorem dot_product_neg {m : Type u_2} [fintype m] {\u03b1 : Type v} [ring \u03b1] (v : m \u2192 \u03b1)\n    (w : m \u2192 \u03b1) : dot_product v (-w) = -dot_product v w :=\n  sorry\n\n@[simp] theorem smul_dot_product {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (x : \u03b1)\n    (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : dot_product (x \u2022 v) w = x * dot_product v w :=\n  sorry\n\n@[simp] theorem dot_product_smul {m : Type u_2} [fintype m] {\u03b1 : Type v} [comm_semiring \u03b1] (x : \u03b1)\n    (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) : dot_product v (x \u2022 w) = x * dot_product v w :=\n  sorry\n\n/-- `M \u2b1d N` is the usual product of matrices `M` and `N`, i.e. we have that\n    `(M \u2b1d N) i k` is the dot product of the `i`-th row of `M` by the `k`-th column of `\u01f8`. -/\nprotected def mul {l : Type u_1} {m : Type u_2} {n : Type u_3} [fintype l] [fintype m] [fintype n]\n    {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] (M : matrix l m \u03b1) (N : matrix m n \u03b1) : matrix l n \u03b1 :=\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    {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] {M : matrix l m \u03b1} {N : matrix m n \u03b1} {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] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1] :\n    Mul (matrix n n \u03b1) :=\n  { mul := matrix.mul }\n\n@[simp] theorem mul_eq_mul {n : Type u_3} [fintype n] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1]\n    (M : matrix n n \u03b1) (N : matrix n n \u03b1) : M * N = matrix.mul M N :=\n  rfl\n\ntheorem mul_apply' {n : Type u_3} [fintype n] {\u03b1 : Type v} [Mul \u03b1] [add_comm_monoid \u03b1]\n    {M : matrix n n \u03b1} {N : matrix n n \u03b1} {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] {\u03b1 : Type v} [semiring \u03b1] (L : matrix l m \u03b1)\n    (M : matrix m n \u03b1) (N : matrix n o \u03b1) :\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] {\u03b1 : Type v} [semiring \u03b1] :\n    semigroup (matrix n n \u03b1) :=\n  semigroup.mk Mul.mul matrix.mul_assoc\n\n@[simp] theorem diagonal_neg {n : Type u_3} [fintype n] {\u03b1 : Type v} [DecidableEq n] [add_group \u03b1]\n    (d : n \u2192 \u03b1) : -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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (L : matrix m n \u03b1) (M : matrix n o \u03b1) (N : matrix n o \u03b1) :\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] {\u03b1 : Type v} [semiring \u03b1] (L : matrix l m \u03b1) (M : matrix l m \u03b1) (N : matrix m n \u03b1) :\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] {\u03b1 : Type v}\n    [semiring \u03b1] [DecidableEq m] (d : m \u2192 \u03b1) (M : matrix m n \u03b1) (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] {\u03b1 : Type v}\n    [semiring \u03b1] [DecidableEq n] (d : n \u2192 \u03b1) (M : matrix m n \u03b1) (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] {\u03b1 : Type v}\n    [semiring \u03b1] [DecidableEq m] (M : matrix m n \u03b1) : 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] {\u03b1 : Type v}\n    [semiring \u03b1] [DecidableEq n] (M : matrix m n \u03b1) : matrix.mul M 1 = M :=\n  sorry\n\nprotected instance monoid {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] :\n    monoid (matrix n n \u03b1) :=\n  monoid.mk semigroup.mul sorry 1 sorry sorry\n\nprotected instance semiring {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] :\n    semiring (matrix n n \u03b1) :=\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] {\u03b1 : Type v} [semiring \u03b1]\n    [DecidableEq n] (d\u2081 : n \u2192 \u03b1) (d\u2082 : n \u2192 \u03b1) :\n    matrix.mul (diagonal d\u2081) (diagonal d\u2082) = diagonal fun (i : n) => d\u2081 i * d\u2082 i :=\n  sorry\n\ntheorem diagonal_mul_diagonal' {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n]\n    (d\u2081 : n \u2192 \u03b1) (d\u2082 : n \u2192 \u03b1) : diagonal d\u2081 * diagonal d\u2082 = diagonal fun (i : n) => d\u2081 i * d\u2082 i :=\n  diagonal_mul_diagonal d\u2081 d\u2082\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] {\u03b1 : Type v} [semiring \u03b1] {L : matrix m n \u03b1} {M : matrix n o \u03b1} {\u03b2 : Type w}\n    [semiring \u03b2] {f : \u03b1 \u2192+* \u03b2} : map (matrix.mul L M) \u21d1f = matrix.mul (map L \u21d1f) (map M \u21d1f) :=\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] {\u03b1 : Type v} [semiring \u03b1]\n    [DecidableEq n] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2192+* \u03b2) : map 1 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1]\n    [DecidableEq n] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2243+* \u03b2) : map 1 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type w}\n    [HasZero \u03b2] (f : zero_hom \u03b1 \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1]\n    {\u03b2 : Type w} [add_monoid \u03b2] (f : \u03b1 \u2192+ \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type w}\n    [add_monoid \u03b2] (f : \u03b1 \u2243+ \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1]\n    {R : Type u_1} [semiring R] {\u03b2 : Type w} [add_comm_monoid \u03b2] [semimodule R \u03b1] [semimodule R \u03b2]\n    (f : linear_map R \u03b1 \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1]\n    {R : Type u_1} [semiring R] {\u03b2 : Type w} [add_comm_monoid \u03b2] [semimodule R \u03b1] [semimodule R \u03b2]\n    (f : linear_equiv R \u03b1 \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type w}\n    [semiring \u03b2] (f : \u03b1 \u2192+* \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1]\n    {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2243+* \u03b2) : map 0 \u21d1f = 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix l m \u03b1) :\n    is_add_monoid_hom fun (x : matrix m n \u03b1) => 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) :\n    is_add_monoid_hom fun (x : matrix l m \u03b1) => 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type u_4} (s : finset \u03b2) (f : \u03b2 \u2192 matrix l m \u03b1)\n    (M : matrix m n \u03b1) :\n    matrix.mul (finset.sum s fun (a : \u03b2) => f a) M =\n        finset.sum s fun (a : \u03b2) => matrix.mul (f a) M :=\n  Eq.symm (finset.sum_hom s fun (x : matrix l m \u03b1) => 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] {\u03b1 : Type v} [semiring \u03b1] {\u03b2 : Type u_4} (s : finset \u03b2) (f : \u03b2 \u2192 matrix m n \u03b1)\n    (M : matrix l m \u03b1) :\n    matrix.mul M (finset.sum s fun (a : \u03b2) => f a) =\n        finset.sum s fun (a : \u03b2) => matrix.mul M (f a) :=\n  Eq.symm (finset.sum_hom s fun (x : matrix m n \u03b1) => 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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1)\n    (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [DecidableEq m] [semiring \u03b1]\n    {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2192+* \u03b2) : matrix m m \u03b1 \u2192+* matrix m m \u03b2 :=\n  ring_hom.mk (fun (M : matrix m m \u03b1) => matrix.map M \u21d1f) sorry sorry sorry sorry\n\n@[simp] theorem ring_hom.map_matrix_apply {m : Type u_2} [fintype m] {\u03b1 : Type v} [DecidableEq m]\n    [semiring \u03b1] {\u03b2 : Type w} [semiring \u03b2] (f : \u03b1 \u2192+* \u03b2) (M : matrix m m \u03b1) :\n    coe_fn (ring_hom.map_matrix f) M = matrix.map M \u21d1f :=\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] {\u03b1 : Type v} [ring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) :\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] {\u03b1 : Type v} [ring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) :\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] {\u03b1 : Type v} [ring \u03b1] (M : matrix m n \u03b1) (M' : matrix m n \u03b1) (N : matrix n o \u03b1) :\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] {\u03b1 : Type v} [ring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) (N' : matrix n o \u03b1) :\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] {\u03b1 : Type v} [DecidableEq n] [ring \u03b1] :\n    ring (matrix n n \u03b1) :=\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] {\u03b1 : Type v}\n    [semiring \u03b1] : has_scalar \u03b1 (matrix m n \u03b1) :=\n  pi.has_scalar\n\nprotected instance semimodule {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    {\u03b2 : Type w} [semiring \u03b1] [add_comm_monoid \u03b2] [semimodule \u03b1 \u03b2] : semimodule \u03b1 (matrix m n \u03b2) :=\n  pi.semimodule m (fun (\u1fb0 : m) => n \u2192 \u03b2) \u03b1\n\n@[simp] theorem smul_apply {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [semiring \u03b1] (a : \u03b1) (A : matrix m n \u03b1) (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] {\u03b1 : Type v}\n    [semiring \u03b1] [DecidableEq m] (M : matrix m n \u03b1) (a : \u03b1) :\n    a \u2022 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (a : \u03b1) (N : matrix n l \u03b1) :\n    matrix.mul (a \u2022 M) N = a \u2022 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] {\u03b1 : Type v} [semiring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) (a : \u03b1) :\n    matrix.mul (fun (i : m) (j : n) => a * M i j) N = a \u2022 matrix.mul M N :=\n  sorry\n\n/--\nThe ring homomorphism `\u03b1 \u2192+* matrix n n \u03b1`\nsending `a` to the diagonal matrix with `a` on the diagonal.\n-/\ndef scalar {\u03b1 : Type v} [semiring \u03b1] (n : Type u) [DecidableEq n] [fintype n] :\n    \u03b1 \u2192+* matrix n n \u03b1 :=\n  ring_hom.mk (fun (a : \u03b1) => a \u2022 1) sorry sorry sorry sorry\n\n@[simp] theorem coe_scalar {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] :\n    \u21d1(scalar n) = fun (a : \u03b1) => a \u2022 1 :=\n  rfl\n\ntheorem scalar_apply_eq {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] (a : \u03b1)\n    (i : n) : coe_fn (scalar n) a i i = a :=\n  sorry\n\ntheorem scalar_apply_ne {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] (a : \u03b1)\n    (i : n) (j : n) (h : i \u2260 j) : coe_fn (scalar n) a i j = 0 :=\n  sorry\n\ntheorem scalar_inj {n : Type u_3} [fintype n] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq n] [Nonempty n]\n    {r : \u03b1} {s : \u03b1} : coe_fn (scalar n) r = coe_fn (scalar n) s \u2194 r = s :=\n  sorry\n\ntheorem smul_eq_mul_diagonal {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [comm_semiring \u03b1] [DecidableEq n] (M : matrix m n \u03b1) (a : \u03b1) :\n    a \u2022 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] {\u03b1 : Type v} [comm_semiring \u03b1] (M : matrix m n \u03b1) (a : \u03b1) (N : matrix n l \u03b1) :\n    matrix.mul M (a \u2022 N) = a \u2022 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] {\u03b1 : Type v} [comm_semiring \u03b1] (M : matrix m n \u03b1) (N : matrix n o \u03b1) (a : \u03b1) :\n    (matrix.mul M fun (i : n) (j : o) => a * N i j) = a \u2022 matrix.mul M N :=\n  sorry\n\ntheorem scalar.commute {n : Type u_3} [fintype n] {\u03b1 : Type v} [comm_semiring \u03b1] [DecidableEq n]\n    (r : \u03b1) (M : matrix n n \u03b1) : 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 \u2b1d row v`. -/\ndef vec_mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1]\n    (w : m \u2192 \u03b1) (v : n \u2192 \u03b1) : matrix m n \u03b1 :=\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 \u2b1d col v` (see `col_mul_vec`). -/\ndef mul_vec {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1]\n    (M : matrix m n \u03b1) (v : n \u2192 \u03b1) : m \u2192 \u03b1 :=\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 \u2b1d M` (see `row_vec_mul`). -/\ndef vec_mul {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v} [semiring \u03b1]\n    (v : m \u2192 \u03b1) (M : matrix m n \u03b1) : n \u2192 \u03b1 :=\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] {\u03b1 : Type v} [semiring \u03b1] (v : n \u2192 \u03b1) :\n    is_add_monoid_hom fun (M : matrix m n \u03b1) => 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 : \u03b1) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : \u03b1) (e_2 : \u1fb0 = \u1fb0_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] {\u03b1 : Type v} (v v_1 : n \u2192 \u03b1) (e_5 : v = v_1)\n                        (w w_1 : n \u2192 \u03b1) (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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m]\n    (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m]\n    (v : m \u2192 \u03b1) (w : m \u2192 \u03b1) (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] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m]\n    (v : m \u2192 \u03b1) : mul_vec 1 v = v :=\n  sorry\n\n@[simp] theorem vec_mul_one {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m]\n    (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v}\n    [semiring \u03b1] (A : matrix m n \u03b1) : 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] {\u03b1 : Type v}\n    [semiring \u03b1] (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1) (M : matrix m n \u03b1) (N : matrix n o \u03b1) :\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] {\u03b1 : Type v} [semiring \u03b1] (v : o \u2192 \u03b1) (M : matrix m n \u03b1) (N : matrix n o \u03b1) :\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] {\u03b1 : Type v}\n    [semiring \u03b1] (w : m \u2192 \u03b1) (v : n \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1]\n    [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : \u03b1) : matrix m n \u03b1 :=\n  fun (i' : m) (j' : n) => ite (i' = i \u2227 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    {\u03b1 : Type v} [semiring \u03b1] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : \u03b1) (b : \u03b1) :\n    b \u2022 std_basis_matrix i j a = std_basis_matrix i j (b \u2022 a) :=\n  sorry\n\n@[simp] theorem std_basis_matrix_zero {m : Type u_2} {n : Type u_3} [fintype m] [fintype n]\n    {\u03b1 : Type v} [semiring \u03b1] [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] {\u03b1 : Type v}\n    [semiring \u03b1] [DecidableEq m] [DecidableEq n] (i : m) (j : n) (a : \u03b1) (b : \u03b1) :\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] {\u03b1 : Type v}\n    [semiring \u03b1] [DecidableEq m] [DecidableEq n] (x : matrix n m \u03b1) :\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 \u2192 Prop} (m : matrix n n X) (h_zero : M 0)\n    (h_add : \u2200 (p q : matrix n n X), M p \u2192 M q \u2192 M (p + q))\n    (h_std_basis : \u2200 (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 \u2192 Prop} (m : matrix n n X)\n    (h_add : \u2200 (p q : matrix n n X), M p \u2192 M q \u2192 M (p + q))\n    (h_std_basis : \u2200 (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] {\u03b1 : Type v} [ring \u03b1]\n    (v : m \u2192 \u03b1) (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1]\n    (v : m \u2192 \u03b1) (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1]\n    (v : n \u2192 \u03b1) (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1]\n    (v : n \u2192 \u03b1) (A : matrix m n \u03b1) : 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] {\u03b1 : Type v} [ring \u03b1] (A : matrix n n \u03b1)\n    (b : n \u2192 \u03b1) (a : \u03b1) : mul_vec (a \u2022 A) b = a \u2022 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] {\u03b1 : Type v}\n    (M : matrix m n \u03b1) (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    {\u03b1 : Type v} (M : matrix m n \u03b1) : 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] {\u03b1 : Type v}\n    [HasZero \u03b1] : 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] {\u03b1 : Type v} [DecidableEq n] [HasZero \u03b1]\n    [HasOne \u03b1] : transpose 1 = 1 :=\n  sorry\n\n@[simp] theorem transpose_add {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [Add \u03b1] (M : matrix m n \u03b1) (N : matrix m n \u03b1) : 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] {\u03b1 : Type v}\n    [add_group \u03b1] (M : matrix m n \u03b1) (N : matrix m n \u03b1) :\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] {\u03b1 : Type v} [comm_semiring \u03b1] (M : matrix m n \u03b1) (N : matrix n l \u03b1) :\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] {\u03b1 : Type v}\n    [semiring \u03b1] (c : \u03b1) (M : matrix m n \u03b1) : transpose (c \u2022 M) = c \u2022 transpose M :=\n  ext fun (i : n) (j : m) => Eq.refl (transpose (c \u2022 M) i j)\n\n@[simp] theorem transpose_neg {m : Type u_2} {n : Type u_3} [fintype m] [fintype n] {\u03b1 : Type v}\n    [Neg \u03b1] (M : matrix m n \u03b1) : 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] {\u03b1 : Type v}\n    {\u03b2 : Type w} {f : \u03b1 \u2192 \u03b2} {M : matrix m n \u03b1} : 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] {\u03b1 : Type v} (A : matrix m n \u03b1) (row : l \u2192 m) (col : o \u2192 n) :\n    matrix l o \u03b1 :=\n  fun (i : l) (j : o) => A (row i) (col j)\n\n/-- The left `n \u00d7 l` part of a `n \u00d7 (l+r)` matrix. -/\ndef sub_left {\u03b1 : Type v} {m : \u2115} {l : \u2115} {r : \u2115} (A : matrix (fin m) (fin (l + r)) \u03b1) :\n    matrix (fin m) (fin l) \u03b1 :=\n  minor A id \u21d1(fin.cast_add r)\n\n/-- The right `n \u00d7 r` part of a `n \u00d7 (l+r)` matrix. -/\ndef sub_right {\u03b1 : Type v} {m : \u2115} {l : \u2115} {r : \u2115} (A : matrix (fin m) (fin (l + r)) \u03b1) :\n    matrix (fin m) (fin r) \u03b1 :=\n  minor A id \u21d1(fin.nat_add l)\n\n/-- The top `u \u00d7 n` part of a `(u+d) \u00d7 n` matrix. -/\ndef sub_up {\u03b1 : Type v} {d : \u2115} {u : \u2115} {n : \u2115} (A : matrix (fin (u + d)) (fin n) \u03b1) :\n    matrix (fin u) (fin n) \u03b1 :=\n  minor A (\u21d1(fin.cast_add d)) id\n\n/-- The bottom `d \u00d7 n` part of a `(u+d) \u00d7 n` matrix. -/\ndef sub_down {\u03b1 : Type v} {d : \u2115} {u : \u2115} {n : \u2115} (A : matrix (fin (u + d)) (fin n) \u03b1) :\n    matrix (fin d) (fin n) \u03b1 :=\n  minor A (\u21d1(fin.nat_add u)) id\n\n/-- The top-right `u \u00d7 r` part of a `(u+d) \u00d7 (l+r)` matrix. -/\ndef sub_up_right {\u03b1 : Type v} {d : \u2115} {u : \u2115} {l : \u2115} {r : \u2115}\n    (A : matrix (fin (u + d)) (fin (l + r)) \u03b1) : matrix (fin u) (fin r) \u03b1 :=\n  sub_up (sub_right A)\n\n/-- The bottom-right `d \u00d7 r` part of a `(u+d) \u00d7 (l+r)` matrix. -/\ndef sub_down_right {\u03b1 : Type v} {d : \u2115} {u : \u2115} {l : \u2115} {r : \u2115}\n    (A : matrix (fin (u + d)) (fin (l + r)) \u03b1) : matrix (fin d) (fin r) \u03b1 :=\n  sub_down (sub_right A)\n\n/-- The top-left `u \u00d7 l` part of a `(u+d) \u00d7 (l+r)` matrix. -/\ndef sub_up_left {\u03b1 : Type v} {d : \u2115} {u : \u2115} {l : \u2115} {r : \u2115}\n    (A : matrix (fin (u + d)) (fin (l + r)) \u03b1) : matrix (fin u) (fin l) \u03b1 :=\n  sub_up (sub_left A)\n\n/-- The bottom-left `d \u00d7 l` part of a `(u+d) \u00d7 (l+r)` matrix. -/\ndef sub_down_left {\u03b1 : Type v} {d : \u2115} {u : \u2115} {l : \u2115} {r : \u2115}\n    (A : matrix (fin (u + d)) (fin (l + r)) \u03b1) : matrix (fin d) (fin l) \u03b1 :=\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] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1)\n    (w : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (x : \u03b1) (v : m \u2192 \u03b1) :\n    col (x \u2022 v) = x \u2022 col v :=\n  ext fun (i : m) (j : Unit) => Eq.refl (col (x \u2022 v) i j)\n\n@[simp] theorem row_add {m : Type u_2} [fintype m] {\u03b1 : Type v} [semiring \u03b1] (v : m \u2192 \u03b1)\n    (w : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1] (x : \u03b1) (v : m \u2192 \u03b1) :\n    row (x \u2022 v) = x \u2022 row v :=\n  ext fun (i : Unit) (j : m) => Eq.refl (row (x \u2022 v) i j)\n\n@[simp] theorem col_apply {m : Type u_2} [fintype m] {\u03b1 : Type v} (v : m \u2192 \u03b1) (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] {\u03b1 : Type v} (v : m \u2192 \u03b1) (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] {\u03b1 : Type v} (v : m \u2192 \u03b1) :\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] {\u03b1 : Type v} (v : m \u2192 \u03b1) :\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] {\u03b1 : Type v} [semiring \u03b1]\n    (M : matrix m n \u03b1) (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1]\n    (M : matrix m n \u03b1) (v : m \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1]\n    (M : matrix m n \u03b1) (v : n \u2192 \u03b1) : 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] {\u03b1 : Type v} [semiring \u03b1]\n    (M : matrix m n \u03b1) (v : n \u2192 \u03b1) : 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] {\u03b1 : Type v} [DecidableEq n]\n    (M : matrix n m \u03b1) (i : n) (b : m \u2192 \u03b1) : matrix n m \u03b1 :=\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] {\u03b1 : Type v} [DecidableEq m]\n    (M : matrix n m \u03b1) (j : m) (b : n \u2192 \u03b1) : matrix n m \u03b1 :=\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] {\u03b1 : Type v}\n    {M : matrix n m \u03b1} {i : n} {b : m \u2192 \u03b1} [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    {\u03b1 : Type v} {M : matrix n m \u03b1} {i : n} {j : m} {c : n \u2192 \u03b1} [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] {\u03b1 : Type v}\n    {M : matrix n m \u03b1} {i : n} {b : m \u2192 \u03b1} [DecidableEq n] {i' : n} (i_ne : i' \u2260 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] {\u03b1 : Type v}\n    {M : matrix n m \u03b1} {i : n} {j : m} {c : n \u2192 \u03b1} [DecidableEq m] {j' : m} (j_ne : j' \u2260 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] {\u03b1 : Type v}\n    {M : matrix n m \u03b1} {i : n} {j : m} {b : m \u2192 \u03b1} [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] {\u03b1 : Type v}\n    {M : matrix n m \u03b1} {i : n} {j : m} {c : n \u2192 \u03b1} [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] {\u03b1 : Type v}\n    {M : matrix n m \u03b1} {j : m} {c : n \u2192 \u03b1} [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] {\u03b1 : Type v}\n    {M : matrix n m \u03b1} {i : n} {b : m \u2192 \u03b1} [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] {\u03b1 : Type v} (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1)\n    (D : matrix o m \u03b1) : matrix (n \u2295 o) (l \u2295 m) \u03b1 :=\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\u2081\u2081 {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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (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\u2081\u2082 {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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (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\u2082\u2081 {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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (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\u2082\u2082 {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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (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\u2081\u2081 {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] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : matrix n l \u03b1 :=\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\u2081\u2082 {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] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : matrix n m \u03b1 :=\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\u2082\u2081 {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] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : matrix o l \u03b1 :=\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\u2082\u2082 {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] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) : matrix o m \u03b1 :=\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] {\u03b1 : Type v} (M : matrix (n \u2295 o) (l \u2295 m) \u03b1) :\n    from_blocks (to_blocks\u2081\u2081 M) (to_blocks\u2081\u2082 M) (to_blocks\u2082\u2081 M) (to_blocks\u2082\u2082 M) = M :=\n  sorry\n\n@[simp] theorem to_blocks_from_blocks\u2081\u2081 {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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) :\n    to_blocks\u2081\u2081 (from_blocks A B C D) = A :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks\u2081\u2082 {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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) :\n    to_blocks\u2081\u2082 (from_blocks A B C D) = B :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks\u2082\u2081 {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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) :\n    to_blocks\u2082\u2081 (from_blocks A B C D) = C :=\n  rfl\n\n@[simp] theorem to_blocks_from_blocks\u2082\u2082 {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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) :\n    to_blocks\u2082\u2082 (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] {\u03b1 : Type v} (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) :\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] {\u03b1 : Type v} [semiring \u03b1] (x : \u03b1) (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) :\n    x \u2022 from_blocks A B C D = from_blocks (x \u2022 A) (x \u2022 B) (x \u2022 C) (x \u2022 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] {\u03b1 : Type v} [semiring \u03b1] (A : matrix n l \u03b1)\n    (B : matrix n m \u03b1) (C : matrix o l \u03b1) (D : matrix o m \u03b1) (A' : matrix n l \u03b1) (B' : matrix n m \u03b1)\n    (C' : matrix o l \u03b1) (D' : matrix o m \u03b1) :\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] {\u03b1 : Type v} [semiring \u03b1] {p : Type u_5} {q : Type u_6}\n    [fintype p] [fintype q] (A : matrix n l \u03b1) (B : matrix n m \u03b1) (C : matrix o l \u03b1)\n    (D : matrix o m \u03b1) (A' : matrix l p \u03b1) (B' : matrix l q \u03b1) (C' : matrix m p \u03b1)\n    (D' : matrix m q \u03b1) :\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    {\u03b1 : Type v} [semiring \u03b1] [DecidableEq l] [DecidableEq m] (d\u2081 : l \u2192 \u03b1) (d\u2082 : m \u2192 \u03b1) :\n    from_blocks (diagonal d\u2081) 0 0 (diagonal d\u2082) = diagonal (sum.elim d\u2081 d\u2082) :=\n  sorry\n\n@[simp] theorem from_blocks_one {l : Type u_1} {m : Type u_2} [fintype l] [fintype m] {\u03b1 : Type v}\n    [semiring \u03b1] [DecidableEq l] [DecidableEq m] : from_blocks 1 0 0 1 = 1 :=\n  sorry\n\n/-- `matrix.block_diagonal M` turns `M : o \u2192 matrix m n \u03b1'` into a\n`m \u00d7 o`-by`n \u00d7 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    {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] : matrix (m \u00d7 o) (n \u00d7 o) \u03b1 :=\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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] (ik : m \u00d7 o)\n    (jk : n \u00d7 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] (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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] (i : m) (j : n)\n    {k : o} {k' : o} (h : k \u2260 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [HasZero \u03b1] :\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] {\u03b1 : Type v} [DecidableEq o] [HasZero \u03b1] : 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    {\u03b1 : Type v} [DecidableEq o] [HasZero \u03b1] [DecidableEq m] (d : o \u2192 m \u2192 \u03b1) :\n    (block_diagonal fun (k : o) => diagonal (d k)) =\n        diagonal fun (ik : m \u00d7 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    {\u03b1 : Type v} [DecidableEq o] [HasZero \u03b1] [DecidableEq m] [HasOne \u03b1] : 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) (N : o \u2192 matrix m n \u03b1)\n    [DecidableEq o] [add_monoid \u03b1] : 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] [add_group \u03b1] :\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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) (N : o \u2192 matrix m n \u03b1)\n    [DecidableEq o] [add_group \u03b1] : 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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] {p : Type u_1}\n    [fintype p] [semiring \u03b1] (N : o \u2192 matrix n p \u03b1) :\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] {\u03b1 : Type v} (M : o \u2192 matrix m n \u03b1) [DecidableEq o] {R : Type u_1}\n    [semiring R] [add_comm_monoid \u03b1] [semimodule R \u03b1] (x : R) :\n    block_diagonal (x \u2022 M) = x \u2022 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] {\u03b1 : Type v} {\u03b2 : Type u_5} [semiring \u03b1] [semiring \u03b2] (M : matrix m n \u03b1)\n    (N : matrix n o \u03b1) (i : m) (j : o) (f : \u03b1 \u2192+* \u03b2) :\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 {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (n : \u2115) (x : \u03b1) (a : \u03b1) : \u03b1 :=\n  n \u2022\u2115 x + a\n\ndef termg {\u03b1 : Type u_1} [add_comm_group \u03b1] (n : \u2124) (x : \u03b1) (a : \u03b1) : \u03b1 :=\n  n \u2022\u2124 x + a\n\ntheorem const_add_term {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (k : \u03b1) (n : \u2115) (x : \u03b1) (a : \u03b1) (a' : \u03b1) (h : k + a = a') : k + term n x a = term n x a' := sorry\n\ntheorem const_add_termg {\u03b1 : Type u_1} [add_comm_group \u03b1] (k : \u03b1) (n : \u2124) (x : \u03b1) (a : \u03b1) (a' : \u03b1) (h : k + a = a') : k + termg n x a = termg n x a' := sorry\n\ntheorem term_add_const {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (n : \u2115) (x : \u03b1) (a : \u03b1) (k : \u03b1) (a' : \u03b1) (h : a + k = a') : term n x a + k = term n x a' := sorry\n\ntheorem term_add_constg {\u03b1 : Type u_1} [add_comm_group \u03b1] (n : \u2124) (x : \u03b1) (a : \u03b1) (k : \u03b1) (a' : \u03b1) (h : a + k = a') : termg n x a + k = termg n x a' := sorry\n\ntheorem term_add_term {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (n\u2081 : \u2115) (x : \u03b1) (a\u2081 : \u03b1) (n\u2082 : \u2115) (a\u2082 : \u03b1) (n' : \u2115) (a' : \u03b1) (h\u2081 : n\u2081 + n\u2082 = n') (h\u2082 : a\u2081 + a\u2082 = a') : term n\u2081 x a\u2081 + term n\u2082 x a\u2082 = term n' x a' := sorry\n\ntheorem term_add_termg {\u03b1 : Type u_1} [add_comm_group \u03b1] (n\u2081 : \u2124) (x : \u03b1) (a\u2081 : \u03b1) (n\u2082 : \u2124) (a\u2082 : \u03b1) (n' : \u2124) (a' : \u03b1) (h\u2081 : n\u2081 + n\u2082 = n') (h\u2082 : a\u2081 + a\u2082 = a') : termg n\u2081 x a\u2081 + termg n\u2082 x a\u2082 = termg n' x a' := sorry\n\ntheorem zero_term {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (x : \u03b1) (a : \u03b1) : term 0 x a = a := sorry\n\ntheorem zero_termg {\u03b1 : Type u_1} [add_comm_group \u03b1] (x : \u03b1) (a : \u03b1) : termg 0 x a = a := sorry\n\ntheorem term_neg {\u03b1 : Type u_1} [add_comm_group \u03b1] (n : \u2124) (x : \u03b1) (a : \u03b1) (n' : \u2124) (a' : \u03b1) (h\u2081 : -n = n') (h\u2082 : -a = a') : -termg n x a = termg n' x a' := sorry\n\ndef smul {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (n : \u2115) (x : \u03b1) : \u03b1 :=\n  n \u2022\u2115 x\n\ndef smulg {\u03b1 : Type u_1} [add_comm_group \u03b1] (n : \u2124) (x : \u03b1) : \u03b1 :=\n  n \u2022\u2124 x\n\ntheorem zero_smul {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (c : \u2115) : smul c 0 = 0 := sorry\n\ntheorem zero_smulg {\u03b1 : Type u_1} [add_comm_group \u03b1] (c : \u2124) : smulg c 0 = 0 := sorry\n\ntheorem term_smul {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (c : \u2115) (n : \u2115) (x : \u03b1) (a : \u03b1) (n' : \u2115) (a' : \u03b1) (h\u2081 : c * n = n') (h\u2082 : smul c a = a') : smul c (term n x a) = term n' x a' := sorry\n\ntheorem term_smulg {\u03b1 : Type u_1} [add_comm_group \u03b1] (c : \u2124) (n : \u2124) (x : \u03b1) (a : \u03b1) (n' : \u2124) (a' : \u03b1) (h\u2081 : c * n = n') (h\u2082 : smulg c a = a') : smulg c (termg n x a) = termg n' x a' := sorry\n\ntheorem term_atom {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (x : \u03b1) : x = term 1 x 0 := sorry\n\ntheorem term_atomg {\u03b1 : Type u_1} [add_comm_group \u03b1] (x : \u03b1) : x = termg 1 x 0 := sorry\n\ntheorem unfold_sub {\u03b1 : Type u_1} [add_group \u03b1] (a : \u03b1) (b : \u03b1) (c : \u03b1) (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 {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (n : \u2115) (x : \u03b1) (y : \u03b1) (h : smul n x = y) : n \u2022\u2115 x = y :=\n  h\n\ntheorem unfold_smulg {\u03b1 : Type u_1} [add_comm_group \u03b1] (n : \u2115) (x : \u03b1) (y : \u03b1) (h : smulg (Int.ofNat n) x = y) : n \u2022\u2115 x = y :=\n  h\n\ntheorem unfold_gsmul {\u03b1 : Type u_1} [add_comm_group \u03b1] (n : \u2124) (x : \u03b1) (y : \u03b1) (h : smulg n x = y) : n \u2022\u2124 x = y :=\n  h\n\ntheorem subst_into_smul {\u03b1 : Type u_1} [add_comm_monoid \u03b1] (l : \u2115) (r : \u03b1) (tl : \u2115) (tr : \u03b1) (t : \u03b1) (prl : l = tl) (prr : r = tr) (prt : smul tl tr = t) : smul l r = t := sorry\n\ntheorem subst_into_smulg {\u03b1 : Type u_1} [add_comm_group \u03b1] (l : \u2124) (r : \u03b1) (tl : \u2124) (tr : \u03b1) (t : \u03b1) (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 {\u03b1 : Type*} {a b : \u03b1} [add_comm_monoid \u03b1] : a + (b + a) = a + a + b := by abel\nexample {\u03b1 : Type*} {a b : \u03b1} [add_comm_group \u03b1] : (a + b) - ((b + a) + a) = -a := by abel\nexample {\u03b1 : Type*} {a b : \u03b1} [add_comm_group \u03b1] (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 \u2113objx \u2113homx \u2113obj \u2113hom\n\n\n\n/- -----------------------------------------------------------------------\nDependent polynomial functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief An induced dependent polynomial functor.\n-/\ndefinition DepPolyFun {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {a b c\u2081 c\u2082 : C^.obj}\n    (f : C^.hom a b)\n    (h : C^.hom a c\u2081)\n    (g : C^.hom b c\u2082)\n    [C_HasDepProd : HasDepProd C f]\n    : Fun (OverCat C c\u2081) (OverCat C c\u2082)\n:= DepSumFun g \u25a1\u25a1 DepProdFun f \u25a1\u25a1 BaseChangeFun h\n\n/-! #brief A dependent polynomial functor.\n-/\nstructure IsDepPolyFun {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {c\u2081 c\u2082 : C^.obj}\n    (P : Fun (OverCat C c\u2081) (OverCat C c\u2082))\n:= (dom : C^.obj)\n   (codom : C^.obj)\n   (hom : C^.hom dom codom)\n   (dom_out : C^.hom dom c\u2081)\n   (codom_out : C^.hom codom c\u2082)\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.{\u2113obj \u2113hom}}\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {a b c\u2081 c\u2082 : C^.obj}\n    {f : C^.hom a b}\n    {h : C^.hom a c\u2081}\n    {g : C^.hom b c\u2082}\n    {X : Cat.{\u2113objx \u2113homx}}\n    (L : Fun X (OverCat C c\u2081))\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 \u25a1\u25a1 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\u00e1mek's construction for dependent W-types.\n-/\ndefinition DepPolyFun.Adamek {C : Cat.{\u2113obj \u2113hom}}\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 := \u03bb 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.{\u2113obj \u2113hom}}\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    \u25a1\u25a1 DepPolyFun f (final_hom x) (final_hom y)\n    \u25a1\u25a1 OverFinal.to C\n\n/-! #brief PolyEndoFun is conjugate to DepPolyFun.\n-/\ntheorem PolyEndoFun_conj_DepPolyFun {C : Cat.{\u2113obj \u2113hom}}\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 \u25a1\u25a1 PolyEndoFun.induce f \u25a1\u25a1 OverFinal.from C\n        = DepPolyFun f (final_hom x) (final_hom y)\n:= let bij\u2082 := (OverFinal.Bij C)^.id\u2082\nin begin\n     dsimp [PolyEndoFun.induce],\n     repeat { rw Fun.comp_assoc },\n     rw bij\u2082,\n     repeat { rw -Fun.comp_assoc },\n     rw bij\u2082,\n     rw [Fun.comp_id_left, Fun.comp_id_right]\n   end\n\n/-! #brief A polynomial endo-functor.\n-/\nstructure PolyEndoFun (C : Cat.{\u2113obj \u2113hom})\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.{\u2113obj \u2113hom}}\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\u2081 {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    (P\u2082 : PolyEndoFun C)\n    {P\u2081 : Fun C C}\n    {\u03b7\u2081\u2082 : NatTrans P\u2081 P\u2082^.endo} {\u03b7\u2082\u2081 : NatTrans P\u2082^.endo P\u2081}\n    (\u03b7_iso : NatIso \u03b7\u2081\u2082 \u03b7\u2082\u2081)\n    : PolyEndoFun C\n:= { endo := P\u2081\n   , dom := P\u2082^.dom\n   , codom := P\u2082^.codom\n   , hom := P\u2082^.hom\n   , to_poly := NatTrans.comp P\u2082^.to_poly \u03b7\u2081\u2082\n   , of_poly := NatTrans.comp \u03b7\u2082\u2081 P\u2082^.of_poly\n   , iso := NatIso.comp P\u2082^.iso \u03b7_iso\n   }\n\ntheorem NatIso.IsPolyEndoFun\u2081.endo {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {P\u2082 : PolyEndoFun C}\n    {P\u2081 : Fun C C}\n    {\u03b7\u2081\u2082 : NatTrans P\u2081 P\u2082^.endo} {\u03b7\u2082\u2081 : NatTrans P\u2082^.endo P\u2081}\n    (\u03b7_iso : NatIso \u03b7\u2081\u2082 \u03b7\u2082\u2081)\n    : (NatIso.IsPolyEndoFun\u2081 P\u2082 \u03b7_iso)^.endo = P\u2081\n:= rfl\n\n/-! #brief IsPolyEndoFun casts along natural isomorphisms.\n-/\ndefinition NatIso.IsPolyEndoFun\u2082 {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    (P\u2081 : PolyEndoFun C)\n    {P\u2082 : Fun C C}\n    {\u03b7\u2081\u2082 : NatTrans P\u2081^.endo P\u2082} {\u03b7\u2082\u2081 : NatTrans P\u2082 P\u2081^.endo}\n    (\u03b7_iso : NatIso \u03b7\u2081\u2082 \u03b7\u2082\u2081)\n    : PolyEndoFun C\n:= NatIso.IsPolyEndoFun\u2081 P\u2081 \u03b7_iso^.flip\n\ntheorem NatIso.IsPolyEndoFun\u2082.endo {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    [C_HasDepProd : HasAllDepProd C]\n    {P\u2081 : PolyEndoFun C}\n    {P\u2082 : Fun C C}\n    {\u03b7\u2081\u2082 : NatTrans P\u2081^.endo P\u2082} {\u03b7\u2082\u2081 : NatTrans P\u2082 P\u2081^.endo}\n    (\u03b7_iso : NatIso \u03b7\u2081\u2082 \u03b7\u2082\u2081)\n    : (NatIso.IsPolyEndoFun\u2082 P\u2081 \u03b7_iso)^.endo = P\u2082\n:= rfl\n\n-- /-! #brief Every polynomial endo-functor is a dependent polynomial functor.\n-- -/\n-- definition IsPolyEndoFun.IsDepPolyFun {C : Cat.{\u2113obj \u2113hom}}\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 \u25a1\u25a1 P \u25a1\u25a1 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\u2081 := let foo := P_IsPolyEndoFun^.equiv^.id\u2081\n--                   in sorry\n--          , id\u2082 := let foo := P_IsPolyEndoFun^.equiv^.id\u2082\n--                   in sorry\n--          }\n--    }\n\n\n\n/- -----------------------------------------------------------------------\nSums of polynomial endo-functors.\n----------------------------------------------------------------------- -/\n\ndefinition PolyEndoFun.fincoproduct.IsPolyEndoFun.to_poly {C : Cat.{\u2113obj \u2113hom}}\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.{\u2113obj \u2113hom}}\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.{\u2113obj \u2113hom}}\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.{\u2113obj \u2113hom}}\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.{\u2113obj \u2113hom}}\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.{\u2113obj \u2113hom}}\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\u00e1mek's construction for polynomial endo-functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief Preservation of co-limits by PolyEndoFun.\n-/\ndefinition PolyEndoFun.PresCoLimit {C : Cat.{\u2113obj \u2113hom}}\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.{\u2113objx \u2113homx}}\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 \u25a1\u25a1 DepPolyFun f (final_hom x) (final_hom y))\n     (@PresCoLimit.comp _ _ _ _\n       (OverFinal.to C \u25a1\u25a1 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\u00e1mek's construction for W-types.\n-/\ndefinition PolyEndoFun.Adamek {C : Cat.{\u2113obj \u2113hom}}\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 := \u03bb 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 = \u27e8 0, 0 \u27e9)\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\u2228 ((ring_char K = 2 \u2192 my_perfect_field K) \u2192 \u2203 (Q : affine_plane_point K), E.affine_point_on_curve Q \u2227 Q.x \u2260 0 \u2227 Q.y = A * Q.x \u2227 - 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 \u22a2,\n  let f : monic_quad_poly K := \u27e8 E.a2 - (A + E.a1) * A, E.a4 - A * E.a3 \u27e9,\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 \u27e8 x, hx1, hx2 \u27e9,\n  have hx0 : x \u2260 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 := \u27e8 x, A * x \u27e9,\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 \u2190 sub_eq_zero,\n  transitivity f.eval_at x + x * f.eval_dx_at x, {\n    rw \u2190 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\u2228 ((ring_char K = 2 \u2192 my_perfect_field K) \u2192 \u2203 (Q : affine_plane_point K), E.affine_point_on_curve Q \u2227 Q.x \u2260 P.x \u2227 Q.y - P.y = A * (Q.x - P.x) \u2227 - E.eval_dx_at_affine_point Q = A * E.eval_dy_at_affine_point Q) :=\nbegin\n  set! C : linear_change_of_variable K := \u27e8 1, P.x, 0, P.y, by simp \u27e9 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 [\u2190 disc_lcov _ C, \u2190 from_point_lcov, \u2190 hE', \u2190 hP'] at h,\n  simp [hC] at h,\n  rw [C.preserve_affine_point E P, \u2190 hE', \u2190 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 \u27e8 Q', \u27e8 h1, h2, h3, h4 \u27e9 \u27e9,\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 [\u2190 hQ, hE', \u2190 linear_change_of_variable.preserve_affine_point] at h1,\n  use [Q, h1],\n  simp [\u2190 hQ, linear_change_of_variable.change_affine_point, hC] at h2 h3,\n  use [sub_ne_zero.1 h2],\n  split, { rw \u2190 h3, ring, },\n  simp [\u2190 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 = \u27e8 0, 0 \u27e9)\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 \u22a2,\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 := \u27e8 1, P.x, 0, P.y, by simp \u27e9 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 [\u2190 disc_lcov _ C, \u2190 from_point_lcov, \u2190 hE', \u2190 hP'],\n  rw [C.preserve_affine_point E P, \u2190 hE', \u2190 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 \u2192 my_perfect_field K)\n: (from_point E P A).poly.disc = 0\n\u2194 - E.eval_dx_at_affine_point P = A * E.eval_dy_at_affine_point P\n\u2228 \u2203 (Q : affine_plane_point K), E.affine_point_on_curve Q \u2227 Q.x \u2260 P.x \u2227 Q.y - P.y = A * (Q.x - P.x) \u2227 - 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 | \u27e8 Q, h1, h2, h3, h4 \u27e9, {\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 [\u2190 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' : \u2200 {a b : B} (f : a \u27f6 b), \ud835\udfd9 a \u226b f = f . obviously)\n(comp_id' : \u2200 {a b : B} (f : a \u27f6 b), f \u226b \ud835\udfd9 b = f . obviously)\n(assoc' : \u2200 {a b c d : B} (f : a \u27f6 b) (g : b \u27f6 c) (h : c \u27f6 d),\n  (f \u226b g) \u226b h = f \u226b (g \u226b h) . obviously)\n(left_unitor_eq_to_iso' : \u2200 {a b : B} (f : a \u27f6 b),\n  \u03bb_ f = eq_to_iso (id_comp' f) . obviously)\n(right_unitor_eq_to_iso' : \u2200 {a b : B} (f : a \u27f6 b),\n  \u03c1_ f = eq_to_iso (comp_id' f) . obviously)\n(associator_eq_to_iso' : \u2200 {a b c d : B} (f : a \u27f6 b) (g : b \u27f6 c) (h : c \u27f6 d),\n  \u03b1_ 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' := \u03bb a b, bicategory.strict.id_comp,\n  comp_id' := \u03bb a b, bicategory.strict.comp_id,\n  assoc' := \u03bb 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 \u27f6 b) {g h : b \u27f6 c} (\u03b7 : g = h) :\n  f \u25c1 eq_to_hom \u03b7 = eq_to_hom (congr_arg2 (\u226b) rfl \u03b7) :=\nby { cases \u03b7, 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 \u27f6 b} (\u03b7 : f = g) (h : b \u27f6 c) :\n  eq_to_hom \u03b7 \u25b7 h = eq_to_hom (congr_arg2 (\u226b) \u03b7 rfl) :=\nby { cases \u03b7, 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 {\u03b1 : Type*}\n\n@[simp, norm_cast] theorem cast_one [has_one \u03b1] [has_add \u03b1] :\n  ((1 : pos_num) : \u03b1) = 1 := rfl\n@[simp] theorem cast_one' [has_one \u03b1] [has_add \u03b1] : (pos_num.one : \u03b1) = 1 := rfl\n@[simp, norm_cast] theorem cast_bit0 [has_one \u03b1] [has_add \u03b1] (n : pos_num) :\n  (n.bit0 : \u03b1) = _root_.bit0 n := rfl\n@[simp, norm_cast] theorem cast_bit1 [has_one \u03b1] [has_add \u03b1] (n : pos_num) :\n  (n.bit1 : \u03b1) = _root_.bit1 n := rfl\n\n@[simp, norm_cast] theorem cast_to_nat [add_monoid_with_one \u03b1] :\n  \u2200 n : pos_num, ((n : \u2115) : \u03b1) = 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 : \u2115) : \u2124) = n :=\ncast_to_nat _\n\n@[simp, norm_cast] theorem cast_to_int [add_group_with_one \u03b1] (n : pos_num) :\n  ((n : \u2124) : \u03b1) = n :=\nby rw [\u2190 to_nat_to_int, int.cast_coe_nat, cast_to_nat]\n\ntheorem succ_to_nat : \u2200 n, (succ n : \u2115) = n + 1\n| 1        := rfl\n| (bit0 p) := rfl\n| (bit1 p) := (congr_arg _root_.bit0 (succ_to_nat p)).trans $\n  show \u2191p + 1 + \u2191p + 1 = \u2191p + \u2191p + 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 : \u2200 m n, ((m + n : pos_num) : \u2115) = 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 : \u2115) = (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 : \u2115) = (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) : \u2115) = (a + a + 1) + (b + b + 1),\n  by rw [succ_to_nat, add_to_nat]; simp [add_left_comm]\n\ntheorem add_succ : \u2200 (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 : \u03a0 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) : \u2200 n, ((m * n : pos_num) : \u2115) = m * n\n| 1        := (mul_one _).symm\n| (bit0 p) := show (\u2191(m * p) + \u2191(m * p) : \u2115) = \u2191m * (p + p), by rw [mul_to_nat, left_distrib]\n| (bit1 p) := (add_to_nat (bit0 (m * p)) m).trans $\n  show (\u2191(m * p) + \u2191(m * p) + \u2191m : \u2115) = \u2191m * (p + p) + m, by rw [mul_to_nat, left_distrib]\n\ntheorem to_nat_pos : \u2200 n : pos_num, 0 < (n : \u2115)\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:\u2115) < n \u2192 (bit1 m : \u2115) < bit0 n :=\nshow (m:\u2115) < n \u2192 (m + m + 1 + 1 : \u2115) \u2264 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) : \u2200n, (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 \u2190IH; cases cmp m n; refl\n\ntheorem cmp_to_nat : \u2200 (m n), (ordering.cases_on (cmp m n) ((m:\u2115) < n) (m = n) ((n:\u2115) < m) : Prop)\n| 1        1        := rfl\n| (bit0 a) 1        := let h : (1:\u2115) \u2264 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:\u2115) \u2264 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:\u2115) < n \u2194 m < n :=\nshow (m:\u2115) < n \u2194 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:\u2115) \u2264 n \u2194 m \u2264 n :=\nby rw \u2190 not_lt; exact not_congr lt_to_nat\n\nend pos_num\n\nnamespace num\nvariables {\u03b1 : 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 : \u2200 n : num, n + 1 = succ n\n| 0       := rfl\n| (pos p) := by cases p; refl\n\ntheorem add_succ : \u2200 (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 : \u2200 n : num, bit0 n = n.bit0\n| 0       := rfl\n| (pos p) := congr_arg pos p.bit0_of_bit0\n\ntheorem bit1_of_bit1 : \u2200 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 : \u2200 n : num, n.bit1.succ = n.succ.bit0\n| 0 := rfl\n| (pos n) := rfl\n\nlemma of_nat'_succ : \u2200 {n}, of_nat' (n + 1) = of_nat' n + 1 :=\nnat.binary_rec (by simp; refl) $ \u03bb b n ih,\nbegin\n  cases b,\n  { erw [of_nat'_bit tt n, of_nat'_bit],\n    simp only [\u2190 bit1_of_bit1, \u2190 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 \u03b1] [has_one \u03b1] [has_add \u03b1] :\n  ((0 : num) : \u03b1) = 0 := rfl\n\n@[simp] theorem cast_zero' [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1] :\n  (num.zero : \u03b1) = 0 := rfl\n\n@[simp, norm_cast] theorem cast_one [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1] :\n  ((1 : num) : \u03b1) = 1 := rfl\n\n@[simp] theorem cast_pos [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1]\n  (n : pos_num) : (num.pos n : \u03b1) = n := rfl\n\ntheorem succ'_to_nat : \u2200 n, (succ' n : \u2115) = n + 1\n| 0       := (_root_.zero_add _).symm\n| (pos p) := pos_num.succ_to_nat _\n\ntheorem succ_to_nat (n) : (succ n : \u2115) = n + 1 := succ'_to_nat n\n\n@[simp, norm_cast] theorem cast_to_nat [add_monoid_with_one \u03b1] : \u2200 n : num, ((n : \u2115) : \u03b1) = n\n| 0       := nat.cast_zero\n| (pos p) := p.cast_to_nat\n\n@[norm_cast]\ntheorem add_to_nat : \u2200 m n, ((m + n : num) : \u2115) = 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 : \u2200 m n, ((m * n : num) : \u2115) = 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 : \u2200 (m n), (ordering.cases_on (cmp m n) ((m:\u2115) < n) (m = n) ((n:\u2115) < 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:\u2115) < n \u2194 m < n :=\nshow (m:\u2115) < n \u2194 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:\u2115) \u2264 n \u2194 m \u2264 n :=\nby rw \u2190 not_lt; exact not_congr lt_to_nat\n\nend num\n\nnamespace pos_num\n\n@[simp] theorem of_to_nat' : \u03a0 (n : pos_num), num.of_nat' (n : \u2115) = 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' : \u03a0 (n : num), num.of_nat' (n : \u2115) = 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 : \u2115) = n \u2194 m = n :=\n\u27e8\u03bb h, function.left_inverse.injective of_to_nat' h, congr_arg _\u27e9\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 \u2264 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 \u2190 to_nat_inj <|> rw \u2190 lt_to_nat <|> rw \u2190 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 \u2264 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 := \u03bb _, 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 \u27e81\u27e9 \u27e8(*)\u27e9,\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                         := (\u2264),\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 \u03bb 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             := \u27e80, 1, dec_trivial\u27e9,\n  ..num.comm_semiring, ..num.ordered_cancel_add_comm_monoid }\n\n@[simp, norm_cast] theorem add_of_nat (m n) : ((m + n : \u2115) : num) = m + n :=\nadd_of_nat' _ _\n\n@[simp, norm_cast] theorem to_nat_to_int (n : num) : ((n : \u2115) : \u2124) = n :=\ncast_to_nat _\n\n@[simp, norm_cast] theorem cast_to_int {\u03b1} [add_group_with_one \u03b1] (n : num) : ((n : \u2124) : \u03b1) = n :=\nby rw [\u2190 to_nat_to_int, int.cast_coe_nat, cast_to_nat]\n\ntheorem to_of_nat : \u03a0 (n : \u2115), ((n : num) : \u2115) = 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 {\u03b1} [add_monoid_with_one \u03b1] (n : \u2115) : ((n : num) : \u03b1) = n :=\nby rw [\u2190 cast_to_nat, to_of_nat]\n\n@[simp, norm_cast] theorem of_nat_inj {m n : \u2115} : (m : num) = n \u2194 m = n :=\n\u27e8\u03bb h, function.left_inverse.injective to_of_nat h, congr_arg _\u27e9\n\n@[simp, norm_cast] theorem of_to_nat : \u03a0 (n : num), ((n : \u2115) : num) = n := of_to_nat'\n\n@[norm_cast]\ntheorem dvd_to_nat (m n : num) : (m : \u2115) \u2223 n \u2194 m \u2223 n :=\n\u27e8\u03bb \u27e8k, e\u27e9, \u27e8k, by rw [\u2190 of_to_nat n, e]; simp\u27e9,\n \u03bb \u27e8k, e\u27e9, \u27e8k, by simp [e, mul_to_nat]\u27e9\u27e9\n\nend num\n\nnamespace pos_num\nvariables {\u03b1 : Type*}\nopen num\n\n@[simp, norm_cast] theorem of_to_nat : \u03a0 (n : pos_num), ((n : \u2115) : num) = num.pos n := of_to_nat'\n\n@[norm_cast] theorem to_nat_inj {m n : pos_num} : (m : \u2115) = n \u2194 m = n :=\n\u27e8\u03bb h, num.pos.inj $ by rw [\u2190 pos_num.of_to_nat, \u2190 pos_num.of_to_nat, h],\n congr_arg _\u27e9\n\ntheorem pred'_to_nat : \u2200 n, (pred' n : \u2115) = nat.pred n\n| 1        := rfl\n| (bit0 n) :=\n  have nat.succ \u2191(pred' n) = \u2191n,\n  by rw [pred'_to_nat n, nat.succ_pred_eq_of_pos (to_nat_pos n)],\n  match pred' n, this : \u2200 k : num, nat.succ \u2191k = \u2191n \u2192\n    \u2191(num.cases_on k 1 bit1 : pos_num) = nat.pred (_root_.bit0 n) with\n  | 0, (h : ((1:num):\u2115) = n) := by rw \u2190 to_nat_inj.1 h; refl\n  | num.pos p, (h : nat.succ \u2191p = n) :=\n    by rw \u2190 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 := \u27e8\u03bb m n, pos m \u2223 pos n\u27e9\n\n@[norm_cast] theorem dvd_to_nat {m n : pos_num} : (m:\u2115) \u2223 n \u2194 m \u2223 n :=\nnum.dvd_to_nat (pos m) (pos n)\n\ntheorem size_to_nat : \u2200 n, (size n : \u2115) = 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 : \u2200 n, (size n : \u2115) = 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 [\u2190 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 \u2264 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 \u2190 to_nat_inj <|> rw \u2190 lt_to_nat <|> rw \u2190 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 \u2264 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 \u27e81\u27e9 \u27e8(*)\u27e9};\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              := (\u2264),\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) : \u2191n = num.pos n :=\nby rw [\u2190 cast_to_nat, \u2190 of_to_nat n]\n\n@[simp, norm_cast]\ntheorem bit_to_nat (b n) : (bit b n : \u2115) = nat.bit b n :=\nby cases b; refl\n\n@[simp, norm_cast]\ntheorem cast_add [add_monoid_with_one \u03b1] (m n) : ((m + n : pos_num) : \u03b1) = m + n :=\nby rw [\u2190 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 \u03b1] (n : pos_num) : (succ n : \u03b1) = n + 1 :=\nby rw [\u2190 add_one, cast_add, cast_one]\n\n@[simp, norm_cast]\ntheorem cast_inj [add_monoid_with_one \u03b1] [char_zero \u03b1] {m n : pos_num} : (m:\u03b1) = n \u2194 m = n :=\nby rw [\u2190 cast_to_nat m, \u2190 cast_to_nat n, nat.cast_inj, to_nat_inj]\n\n@[simp]\ntheorem one_le_cast [linear_ordered_semiring \u03b1] (n : pos_num) : (1 : \u03b1) \u2264 n :=\nby rw [\u2190 cast_to_nat, \u2190 nat.cast_one, nat.cast_le]; apply to_nat_pos\n\n@[simp]\ntheorem cast_pos [linear_ordered_semiring \u03b1] (n : pos_num) : 0 < (n : \u03b1) :=\nlt_of_lt_of_le zero_lt_one (one_le_cast n)\n\n@[simp, norm_cast]\ntheorem cast_mul [semiring \u03b1] (m n) : ((m * n : pos_num) : \u03b1) = m * n :=\nby rw [\u2190 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 \u2194 m = n :=\nbegin\n  have := cmp_to_nat m n,\n  cases cmp m n; simp at this \u22a2; try {exact this};\n  { simp [show m \u2260 n, from \u03bb e, by rw e at this; exact lt_irrefl _ this] }\nend\n\n@[simp, norm_cast]\ntheorem cast_lt [linear_ordered_semiring \u03b1] {m n : pos_num} : (m:\u03b1) < n \u2194 m < n :=\nby rw [\u2190 cast_to_nat m, \u2190 cast_to_nat n, nat.cast_lt, lt_to_nat]\n\n@[simp, norm_cast]\ntheorem cast_le [linear_ordered_semiring \u03b1] {m n : pos_num} : (m:\u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw \u2190 not_lt; exact not_congr cast_lt\n\nend pos_num\n\nnamespace num\nvariables {\u03b1 : Type*}\nopen pos_num\n\ntheorem bit_to_nat (b n) : (bit b n : \u2115) = nat.bit b n :=\nby cases b; cases n; refl\n\ntheorem cast_succ' [add_monoid_with_one \u03b1] (n) : (succ' n : \u03b1) = n + 1 :=\nby rw [\u2190 pos_num.cast_to_nat, succ'_to_nat, nat.cast_add_one, cast_to_nat]\n\ntheorem cast_succ [add_monoid_with_one \u03b1] (n) : (succ n : \u03b1) = n + 1 := cast_succ' n\n\n@[simp, norm_cast] theorem cast_add [semiring \u03b1] (m n) : ((m + n : num) : \u03b1) = m + n :=\nby rw [\u2190 cast_to_nat, add_to_nat, nat.cast_add, cast_to_nat, cast_to_nat]\n\n@[simp, norm_cast] theorem cast_bit0 [semiring \u03b1] (n : num) : (n.bit0 : \u03b1) = _root_.bit0 n :=\nby rw [\u2190 bit0_of_bit0, _root_.bit0, cast_add]; refl\n\n@[simp, norm_cast] theorem cast_bit1 [semiring \u03b1] (n : num) : (n.bit1 : \u03b1) = _root_.bit1 n :=\nby rw [\u2190 bit1_of_bit1, _root_.bit1, bit0_of_bit0, cast_add, cast_bit0]; refl\n\n@[simp, norm_cast] theorem cast_mul [semiring \u03b1] : \u2200 m n, ((m * n : num) : \u03b1) = 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 : \u2200 n, (size n : \u2115) = nat.size n\n| 0       := nat.size_zero.symm\n| (pos p) := p.size_to_nat\n\ntheorem size_eq_nat_size : \u2200 n, (size n : \u2115) = 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 [\u2190 size_eq_nat_size, size_to_nat]\n\n@[simp, priority 999] theorem of_nat'_eq : \u2200 n, num.of_nat' n = n :=\nnat.binary_rec (by simp) $ \u03bb b n IH, begin\n  rw of_nat' at IH \u22a2,\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 \u2194 m = n :=\n\u27e8\u03bb h, by cases m; cases n; cases h; refl, congr_arg _\u27e9\n\n@[simp, norm_cast squash] theorem cast_to_znum [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1] [has_neg \u03b1] :\n  \u2200 n : num, (n.to_znum : \u03b1) = n\n| 0           := rfl\n| (num.pos p) := rfl\n\n@[simp] theorem cast_to_znum_neg [add_group \u03b1] [has_one \u03b1] :\n  \u2200 n : num, (n.to_znum_neg : \u03b1) = -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 : \u2115) = nat.pred n :=\nbegin\n  unfold pred,\n  have := pred'_to_nat n,\n  cases e : pred' n,\n  { have : (1:\u2115) \u2264 nat.pred n :=\n      nat.pred_le_pred ((@cast_lt \u2115 _ _ _).2 h),\n    rw [\u2190 pred'_to_nat, e] at this,\n    exact absurd this dec_trivial },\n  { rw [\u2190 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 \u2194 cmp m n = ordering.lt := iff.rfl\n\ntheorem le_iff_cmp {m n} : m \u2264 n \u2194 cmp m n \u2260 ordering.gt :=\nnot_congr $ lt_iff_cmp.trans $\nby rw \u2190 cmp_swap; cases cmp m n; exact dec_trivial\n\nend pos_num\n\nnamespace num\nvariables {\u03b1 : Type*}\nopen pos_num\n\ntheorem pred_to_nat : \u2200 (n : num), (pred n : \u2115) = nat.pred n\n| 0       := rfl\n| (pos p) := by rw [pred, pos_num.pred'_to_nat]; refl\n\ntheorem ppred_to_nat : \u2200 (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 \u2194 m = n :=\nbegin\n  have := cmp_to_nat m n,\n  cases cmp m n; simp at this \u22a2; try {exact this};\n  { simp [show m \u2260 n, from \u03bb e, by rw e at this; exact lt_irrefl _ this] }\nend\n\n@[simp, norm_cast]\ntheorem cast_lt [linear_ordered_semiring \u03b1] {m n : num} : (m:\u03b1) < n \u2194 m < n :=\nby rw [\u2190 cast_to_nat m, \u2190 cast_to_nat n, nat.cast_lt, lt_to_nat]\n\n@[simp, norm_cast]\ntheorem cast_le [linear_ordered_semiring \u03b1] {m n : num} : (m:\u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw \u2190 not_lt; exact not_congr cast_lt\n\n@[simp, norm_cast]\ntheorem cast_inj [linear_ordered_semiring \u03b1] {m n : num} : (m:\u03b1) = n \u2194 m = n :=\nby rw [\u2190 cast_to_nat m, \u2190 cast_to_nat n, nat.cast_inj, to_nat_inj]\n\ntheorem lt_iff_cmp {m n} : m < n \u2194 cmp m n = ordering.lt := iff.rfl\n\ntheorem le_iff_cmp {m n} : m \u2264 n \u2194 cmp m n \u2260 ordering.gt :=\nnot_congr $ lt_iff_cmp.trans $\nby rw \u2190 cmp_swap; cases cmp m n; exact dec_trivial\n\ntheorem bitwise_to_nat {f : num \u2192 num \u2192 num} {g : bool \u2192 bool \u2192 bool}\n  (p : pos_num \u2192 pos_num \u2192 num)\n  (gff : g ff ff = ff)\n  (f00 : f 0 0 = 0)\n  (f0n : \u2200 n, f 0 (pos n) = cond (g ff tt) (pos n) 0)\n  (fn0 : \u2200 n, f (pos n) 0 = cond (g tt ff) (pos n) 0)\n  (fnn : \u2200 m n, f (pos m) (pos n) = p m n)\n  (p11 : p 1 1 = cond (g tt tt) 1 0)\n  (p1b : \u2200 b n, p 1 (pos_num.bit b n) = bit (g tt b) (cond (g ff tt) (pos n) 0))\n  (pb1 : \u2200 a m, p (pos_num.bit a m) 1 = bit (g a tt) (cond (g tt ff) (pos m) 0))\n  (pbb : \u2200 a b m n, p (pos_num.bit a m) (pos_num.bit b n) = bit (g a b) (p m n))\n  : \u2200 m n : num, (f m n : \u2115) = 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):\u2115) 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 : \u2115) = 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, \u2190h],\n    cases g tt ff; refl,\n    apply nat.bitwise_bit_aux gff },\n  { rw fnn,\n    have : \u2200b (n : pos_num), (cond b \u2191n 0 : \u2115) = \u2191(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):\u2115) with nat.bit tt 0 },\n    all_goals\n    { repeat\n      { rw show \u2200 b n, (pos (pos_num.bit b n) : \u2115) = nat.bit b \u2191n,\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, \u2190 bit_to_nat, p1b] },\n    any_goals { rw [nat.bitwise_zero_right _ gff, this, \u2190 bit_to_nat, pb1] },\n    all_goals { rw [\u2190 show \u2200 n, \u2191(p m n) = nat.bitwise g \u2191m \u2191n, from IH],\n      rw [\u2190 bit_to_nat, pbb] } }\nend\n\n@[simp, norm_cast] theorem lor_to_nat   : \u2200 m n, (lor    m n : \u2115) = nat.lor    m n :=\nby apply bitwise_to_nat (\u03bbx y, pos (pos_num.lor x y)); intros; try {cases a}; try {cases b}; refl\n@[simp, norm_cast] theorem land_to_nat  : \u2200 m n, (land   m n : \u2115) = 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 : \u2200 m n, (ldiff  m n : \u2115) = 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  : \u2200 m n, (lxor   m n : \u2115) = 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 : \u2115) = 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 \u2190IH\nend\n\n@[simp, norm_cast] theorem shiftr_to_nat (m n) : (shiftr m n : \u2115) = 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 (\u03bbx, nat.shiftr x n), unfold nat.shiftr,\n    change (bit1 \u2191m : \u2115) 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 (\u03bbx, nat.shiftr x n), unfold nat.shiftr,\n    change (bit0 \u2191m : \u2115) 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 {\u03b1 : Type*}\nopen pos_num\n\n@[simp, norm_cast] theorem cast_zero [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1] [has_neg \u03b1] :\n  ((0 : znum) : \u03b1) = 0 := rfl\n\n@[simp] theorem cast_zero' [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1] [has_neg \u03b1] :\n  (znum.zero : \u03b1) = 0 := rfl\n\n@[simp, norm_cast] theorem cast_one [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1] [has_neg \u03b1] :\n  ((1 : znum) : \u03b1) = 1 := rfl\n\n@[simp] theorem cast_pos [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1] [has_neg \u03b1]\n  (n : pos_num) : (pos n : \u03b1) = n := rfl\n\n@[simp] theorem cast_neg [has_zero \u03b1] [has_one \u03b1] [has_add \u03b1] [has_neg \u03b1]\n  (n : pos_num) : (neg n : \u03b1) = -n := rfl\n\n@[simp, norm_cast] theorem cast_zneg [add_group \u03b1] [has_one \u03b1] : \u2200 n, ((-n : znum) : \u03b1) = -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 [\u2190 zneg_zneg (succ (-n)), zneg_succ, zneg_zneg]\n\n@[simp] theorem abs_to_nat : \u2200 n, (abs n : \u2115) = 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:\u2115):\u2124) = int.nat_abs (- p),\n  by rw [p.to_nat_to_int, int.nat_abs_neg]\n\n@[simp] theorem abs_to_znum : \u2200 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 \u03b1] : \u2200 n : znum, ((n : \u2124) : \u03b1) = 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 : \u2200 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 : \u2200 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 \u03b1] :\n  \u2200 n : znum, (n.bit0 : \u03b1) = 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 \u03b1] :\n  \u2200 n : znum, (n.bit1 : \u03b1) = 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 : (\u2191(-\u2191a:\u2124) : \u03b1) = -1 + \u2191(-\u2191a + 1 : \u2124), {simp [add_comm]},\n      simpa [_root_.bit1, _root_.bit0, -add_comm] },\n  end\n\n@[simp] theorem cast_bitm1 [add_group_with_one \u03b1]\n  (n : znum) : (n.bitm1 : \u03b1) = bit0 n - 1 :=\nbegin\n  conv { to_lhs, rw \u2190 zneg_zneg n },\n  rw [\u2190 zneg_bit1, cast_zneg, cast_bit1],\n  have : ((-1 + n + n : \u2124) : \u03b1) = (n + n + -1 : \u2124), {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 : \u2200 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 {\u03b1 : Type*}\n\ntheorem cast_to_znum : \u2200 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 \u03b1] : \u2200 m n : pos_num, (sub' m n : \u03b1) = m - n\n| a        1        := by rw [sub'_one, num.cast_to_znum,\n                              \u2190 num.cast_to_nat, pred'_to_nat, \u2190 nat.sub_one];\n                          simp [pos_num.cast_pos]\n| 1        b        := by rw [one_sub', num.cast_to_znum_neg, \u2190 neg_sub, neg_inj,\n                              \u2190 num.cast_to_nat, pred'_to_nat, \u2190 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) : \u2124) : \u03b1) = 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)) : \u2124) : \u03b1) = (a + -1 + (-b + -b):\u2124),\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)) : \u2124) : \u03b1) = (a + 1 + (-b + -b):\u2124),\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) : \u2124) : \u03b1) = 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:\u2115) = n.pred' + 1 :=\nby rw [\u2190 num.succ'_to_nat, n.succ'_pred']\n\ntheorem to_int_eq_succ_pred (n : pos_num) : (n:\u2124) = (n.pred' : \u2115) + 1 :=\nby rw [\u2190 n.to_nat_to_int, to_nat_eq_succ_pred]; refl\n\nend pos_num\n\nnamespace num\nvariables {\u03b1 : Type*}\n\n@[simp] theorem cast_sub' [add_group_with_one \u03b1] : \u2200 m n : num, (sub' m n : \u03b1) = 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 : \u2200 n : num, n.succ.to_znum = n.to_znum.succ\n| 0 := rfl\n| (pos n) := rfl\n\ntheorem to_znum_neg_succ : \u2200 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 : \u2200 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, \u2190 to_znum_succ, num.succ, pos_num.succ'_pred', to_znum]\n\ntheorem succ_of_int' : \u2200 n, znum.of_int' (n + 1) = znum.of_int' n + 1\n| (n : \u2115) := 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 : \u2200 n : \u2115, 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' : \u2200 {m : num} {n : znum}, m \u2208 of_znum' n \u2194 n = to_znum m\n| 0       0      := \u27e8\u03bb _, rfl, \u03bb _, rfl\u27e9\n| (pos m) 0      := \u27e8\u03bb h, by cases h, \u03bb h, by cases h\u27e9\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) := \u27e8\u03bb h, by cases h, \u03bb h, by cases m; cases h\u27e9\n\ntheorem of_znum'_to_nat : \u2200 (n : znum), coe <$> of_znum' n = int.to_nat' n\n| 0            := rfl\n| (znum.pos p) := show _ = int.to_nat' p, by rw [\u2190 pos_num.to_nat_to_int p]; refl\n| (znum.neg p) := congr_arg (\u03bb x, int.to_nat' (-x)) $\n  show ((p.pred' + 1 : \u2115) : \u2124) = p, by rw \u2190 succ'_to_nat; simp\n\n@[simp] theorem of_znum_to_nat : \u2200 (n : znum), (of_znum n : \u2115) = int.to_nat n\n| 0            := rfl\n| (znum.pos p) := show _ = int.to_nat p, by rw [\u2190 pos_num.to_nat_to_int p]; refl\n| (znum.neg p) := congr_arg (\u03bb x, int.to_nat (-x)) $\n  show ((p.pred' + 1 : \u2115) : \u2124) = p, by rw \u2190 succ'_to_nat; simp\n\n@[simp] theorem cast_of_znum [add_group_with_one \u03b1] (n : znum) :\n  (of_znum n : \u03b1) = int.to_nat n :=\nby rw [\u2190 cast_to_nat, of_znum_to_nat]\n\n@[simp, norm_cast] theorem sub_to_nat (m n) : ((m - n : num) : \u2115) = m - n :=\nshow (of_znum _ : \u2115) = _, by rw [of_znum_to_nat, cast_sub',\n  \u2190 to_nat_to_int, \u2190 to_nat_to_int, int.to_nat_sub]\n\nend num\n\nnamespace znum\nvariables {\u03b1 : Type*}\n\n@[simp, norm_cast] theorem cast_add [add_group_with_one \u03b1] : \u2200 m n, ((m + n : znum) : \u03b1) = 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 (\u2191b + -\u2191a : \u03b1) = -\u2191a + \u2191b, by rw [\u2190 pos_num.cast_to_int a, \u2190 pos_num.cast_to_int b,\n  \u2190 int.cast_neg, \u2190 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 -(\u2191(a + b) : \u03b1) = -a + -b, by  rw [\n  pos_num.cast_add, neg_eq_iff_eq_neg, neg_add_rev, neg_neg, neg_neg,\n  \u2190 pos_num.cast_to_int a, \u2190 pos_num.cast_to_int b, \u2190 int.cast_add, \u2190 int.cast_add, add_comm]\n\n@[simp] theorem cast_succ [add_group_with_one \u03b1] (n) : ((succ n : znum) : \u03b1) = n + 1 :=\nby rw [\u2190 add_one, cast_add, cast_one]\n\n@[simp, norm_cast] theorem mul_to_int : \u2200 m n, ((m * n : znum) : \u2124) = 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 -\u2191(a * b) = \u2191a * -\u2191b, by rw [pos_num.cast_mul, neg_mul_eq_mul_neg]\n| (neg a) (pos b) := show -\u2191(a * b) = -\u2191a * \u2191b, by rw [pos_num.cast_mul, neg_mul_eq_neg_mul]\n| (neg a) (neg b) := show \u2191(a * b) = -\u2191a * -\u2191b, by rw [pos_num.cast_mul, neg_mul_neg]\n\ntheorem cast_mul [ring \u03b1] (m n) : ((m * n : znum) : \u03b1) = m * n :=\nby rw [\u2190 cast_to_int, mul_to_int, int.cast_mul, cast_to_int, cast_to_int]\n\ntheorem of_int'_neg : \u2200 n : \u2124, of_int' (-n) = -of_int' n\n| -[1+ n] := show of_int' (n + 1 : \u2115) = _, 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 : \u2115) := show num.to_znum_neg _ = -num.to_znum _, by rw [num.zneg_to_znum]; refl\n\ntheorem of_to_int' : \u2200 (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, \u2190 pos_num.cast_to_nat, \u2190 num.of_int'_to_znum, pos_num.of_to_nat]; refl\n| (neg a) := by rw [cast_neg, of_int'_neg, \u2190 pos_num.cast_to_nat, \u2190 num.of_int'_to_znum,\n  pos_num.of_to_nat]; refl\n\ntheorem to_int_inj {m n : znum} : (m : \u2124) = n \u2194 m = n :=\n\u27e8\u03bb h, function.left_inverse.injective of_to_int' h, congr_arg _\u27e9\n\ntheorem cmp_to_int : \u2200 (m n), (ordering.cases_on (cmp m n) ((m:\u2124) < n) (m = n) ((n:\u2124) < 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:\u2124) < n \u2194 m < n :=\nshow (m:\u2124) < n \u2194 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:\u2124) \u2264 n \u2194 m \u2264 n :=\nby rw \u2190 not_lt; exact not_congr lt_to_int\n\n@[simp, norm_cast]\ntheorem cast_lt [linear_ordered_ring \u03b1] {m n : znum} : (m:\u03b1) < n \u2194 m < n :=\nby rw [\u2190 cast_to_int m, \u2190 cast_to_int n, int.cast_lt, lt_to_int]\n\n@[simp, norm_cast]\ntheorem cast_le [linear_ordered_ring \u03b1] {m n : znum} : (m:\u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw \u2190 not_lt; exact not_congr cast_lt\n\n@[simp, norm_cast]\ntheorem cast_inj [linear_ordered_ring \u03b1] {m n : znum} : (m:\u03b1) = n \u2194 m = n :=\nby rw [\u2190 cast_to_int m, \u2190 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 \u2264 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 \u2190 to_int_inj <|> rw \u2190 lt_to_int <|> rw \u2190 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 \u2264 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               := (\u2264),\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 := \u03bb 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 := \u03bb 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   := \u27e80, 1, dec_trivial\u27e9,\n  add_le_add_left  := by {intros a b h c, revert h, transfer_rw, exact \u03bb h, add_le_add_left h c},\n  mul_pos          := \u03bb a b, show 0 < a \u2192 0 < b \u2192 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 \u03b1] (m n) : ((m - n : znum) : \u03b1) = m - n :=\nby simp [sub_eq_neg_add]\n\n@[simp, norm_cast] \n\n@[simp] theorem of_int'_eq : \u2200 n : \u2124, znum.of_int' n = n\n| (n : \u2115) := rfl\n| -[1+ n] := begin\n  show num.to_znum_neg (n+1 : \u2115) = -(n+1 : \u2115),\n  rw [\u2190 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 : \u2115) : num.to_znum n = n := rfl\n\n@[simp, norm_cast] theorem of_to_int (n : znum) : ((n : \u2124) : znum) = n :=\nby rw [\u2190 of_int'_eq, of_to_int']\n\ntheorem to_of_int (n : \u2124) : ((n : znum) : \u2124) = n :=\nint.induction_on' n 0 (by simp) (by simp) (by simp)\n\n@[simp] theorem of_nat_to_znum_neg (n : \u2115) : num.to_znum_neg n = -n :=\nby rw [\u2190 of_nat_to_znum, num.zneg_to_znum]\n\n@[simp, norm_cast] theorem of_int_cast [add_group_with_one \u03b1] (n : \u2124) : ((n : znum) : \u03b1) = n :=\nby rw [\u2190 cast_to_int, to_of_int]\n\n@[simp, norm_cast] theorem of_nat_cast [add_group_with_one \u03b1] (n : \u2115) : ((n : znum) : \u03b1) = n :=\nby rw [\u2190 int.cast_coe_nat, of_int_cast, int.cast_coe_nat]\n\n@[simp, norm_cast] theorem dvd_to_int (m n : znum) : (m : \u2124) \u2223 n \u2194 m \u2223 n :=\n\u27e8\u03bb \u27e8k, e\u27e9, \u27e8k, by rw [\u2190 of_to_int n, e]; simp\u27e9,\n \u03bb \u27e8k, e\u27e9, \u27e8k, by simp [e]\u27e9\u27e9\n\nend znum\n\nnamespace pos_num\n\ntheorem divmod_to_nat_aux {n d : pos_num} {q r : num}\n  (h\u2081 : (r:\u2115) + d * _root_.bit0 q = n)\n  (h\u2082 : (r:\u2115) < 2 * d) :\n  ((divmod_aux d q r).2 + d * (divmod_aux d q r).1 : \u2115) = \u2191n \u2227\n  ((divmod_aux d q r).2 : \u2115) < d :=\nbegin\n  unfold divmod_aux,\n  have : \u2200 {r\u2082}, num.of_znum' (num.sub' r (num.pos d)) = some r\u2082 \u2194 (r : \u2115) = r\u2082 + d,\n  { intro r\u2082,\n    apply num.mem_of_znum'.trans,\n    rw [\u2190 znum.to_int_inj, num.cast_to_znum,\n      num.cast_sub', sub_eq_iff_eq_add, \u2190 int.coe_nat_inj'],\n    simp },\n  cases e : num.of_znum' (num.sub' r (num.pos d)) with r\u2082;\n    simp [divmod_aux],\n  { refine \u27e8h\u2081, lt_of_not_ge (\u03bb h, _)\u27e9,\n    cases nat.le.dest h with r\u2082 e',\n    rw [\u2190 num.to_of_nat r\u2082, 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        \u2190 add_assoc, \u2190 this] },\n    { rwa [this, two_mul, add_lt_add_iff_right] at h\u2082 } }\nend\n\ntheorem divmod_to_nat (d n : pos_num) :\n  (n / d : \u2115) = (divmod d n).1 \u2227\n  (n % d : \u2115) = (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 : \u2115) < d)) },\n  { unfold divmod,\n    cases divmod d n with q r, simp only [divmod] at IH \u22a2,\n    apply divmod_to_nat_aux; simp,\n    { rw [_root_.bit1, _root_.bit1, add_right_comm,\n        bit0_eq_two_mul (n : \u2115), \u2190 IH.1,\n        mul_add, \u2190 bit0_eq_two_mul,\n        mul_left_comm, \u2190 bit0_eq_two_mul] },\n    { rw \u2190 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 \u22a2,\n    apply divmod_to_nat_aux; simp,\n    { rw [bit0_eq_two_mul (n : \u2115), \u2190 IH.1,\n        mul_add, \u2190 bit0_eq_two_mul,\n        mul_left_comm, \u2190 bit0_eq_two_mul] },\n    { rw \u2190 bit0_eq_two_mul,\n      exact nat.bit0_lt IH.2 } }\nend\n\n@[simp] theorem div'_to_nat (n d) : (div' n d : \u2115) = n / d :=\n(divmod_to_nat _ _).1.symm\n\n@[simp] theorem mod'_to_nat (n d) : (mod' n d : \u2115) = 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 : \u2200 n d, ((n / d : num) : \u2115) = 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 : \u2200 n d, ((n % d : num) : \u2115) = 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 : \u2200 {n} {a b : num},\n  a \u2264 b \u2192 (a * b).nat_size \u2264 n \u2192 (gcd_aux n a b : \u2115) = 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 [\u2190 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 \u22a2,\n  rw [mod_to_nat, mul_comm],\n  rw [pow_succ', \u2190 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 \u2264 _, 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 : \u2200 a b, (gcd a b : \u2115) = nat.gcd a b :=\nhave \u2200 a b : num, (a * b).nat_size \u2264 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 \u2223 n \u2194 n % m = 0 :=\nby rw [\u2190 dvd_to_nat, nat.dvd_iff_mod_eq_zero,\n  \u2190 to_nat_inj, mod_to_nat]; refl\n\ninstance decidable_dvd : decidable_rel ((\u2223) : num \u2192 num \u2192 Prop)\n| a b := decidable_of_iff' _ dvd_iff_mod_eq_zero\n\nend num\n\ninstance pos_num.decidable_dvd : decidable_rel ((\u2223) : pos_num \u2192 pos_num \u2192 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 : \u2200 n d, ((n / d : znum) : \u2124) = 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 \u2190 num.to_nat_to_int; simp\n| (pos n) (neg d) := (num.cast_to_znum_neg _).trans $\n  by rw \u2190 num.to_nat_to_int; simp\n| (neg n) (pos d) := show - _ = (-_/\u2191d), begin\n    rw [n.to_int_eq_succ_pred, d.to_int_eq_succ_pred,\n      \u2190 pos_num.to_nat_to_int, num.succ'_to_nat,\n      num.div_to_nat],\n    change -[1+ n.pred' / \u2191d] = -[1+ n.pred' / (d.pred' + 1)],\n    rw d.to_nat_eq_succ_pred\n  end\n| (neg n) (neg d) := show \u2191(pos_num.pred' n / num.pos d).succ' = (-_ / -\u2191d), begin\n    rw [n.to_int_eq_succ_pred, d.to_int_eq_succ_pred,\n      \u2190 pos_num.to_nat_to_int, num.succ'_to_nat,\n      num.div_to_nat],\n    change (nat.succ (_/d) : \u2124) = 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 : \u2200 n d, ((n % d : znum) : \u2124) = n % d\n| 0       d := (int.zero_mod _).symm\n| (pos n) d := (num.cast_to_znum _).trans $\n  by rw [\u2190 num.to_nat_to_int, cast_pos, num.mod_to_nat,\n    \u2190 pos_num.to_nat_to_int, abs_to_nat]; refl\n| (neg n) d := (num.cast_sub' _ _).trans $\n  by rw [\u2190 num.to_nat_to_int, cast_neg, \u2190 num.to_nat_to_int,\n    num.succ_to_nat, num.mod_to_nat, abs_to_nat,\n    \u2190 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 : \u2115) = int.gcd a b :=\n(num.gcd_to_nat _ _).trans $ by simpa\n\ntheorem dvd_iff_mod_eq_zero {m n : znum} : m \u2223 n \u2194 n % m = 0 :=\nby rw [\u2190 dvd_to_int, int.dvd_iff_mod_eq_zero,\n  \u2190 to_int_inj, mod_to_int]; refl\n\ninstance : decidable_rel ((\u2223) : znum \u2192 znum \u2192 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 \u2192 \u2124 :=\nsnum.rec' (\u03bb a, cond a (-1) 0) (\u03bba p IH, cond a (bit1 IH) (bit0 IH))\n\ninstance snum_coe : has_coe snum \u2124 := \u27e8of_snum\u27e9\nend int\n\ninstance : has_lt snum := \u27e8\u03bba b, (a : \u2124) < b\u27e9\ninstance : has_le snum := \u27e8\u03bba b, (a : \u2124) \u2264 b\u27e9\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 \u2192 PropF \u2192 bool\n  | (Var x) (Var y)           := if x = y then tt else ff\n  | Bot Bot                   := tt\n  | (Conj p\u2081 p\u2082) (Conj q\u2081 q\u2082) := equal p\u2081 q\u2081 && equal p\u2082 q\u2082\n  | (Disj p\u2081 p\u2082) (Disj q\u2081 q\u2082) := equal p\u2081 q\u2081 && equal p\u2082 q\u2082\n  | (Impl p\u2081 p\u2082) (Impl q\u2081 q\u2082) := equal p\u2081 q\u2081 && equal p\u2082 q\u2082\n  | _            _            := ff\n\n  lemma equal_refl : \u2200 p, equal p p = tt\n  | (Var x)      := if_pos rfl\n  | Bot          := rfl\n  | (Conj p\u2081 p\u2082) := begin change (equal p\u2081 p\u2081 && equal p\u2082 p\u2082 = tt), rewrite *equal_refl end\n  | (Disj p\u2081 p\u2082) := begin change (equal p\u2081 p\u2081 && equal p\u2082 p\u2082 = tt), rewrite *equal_refl end\n  | (Impl p\u2081 p\u2082) := begin change (equal p\u2081 p\u2081 && equal p\u2082 p\u2082 = tt), rewrite *equal_refl end\n\n  lemma equal_to_eq : \u2200 \u2983p q\u2984, equal p q = tt \u2192 p = q\n  | (Var x) (Var y) H :=\n    if H\u2081 : x = y then congr_arg Var H\u2081\n    else by rewrite [\u25b8 (if x = y then tt else ff) = tt at H, if_neg H\u2081 at H]; exact (absurd H ff_ne_tt)\n  | Bot Bot H  := rfl\n  | (Conj p\u2081 p\u2082) (Conj q\u2081 q\u2082) H :=\n    by rewrite [equal_to_eq (band_elim_left H), equal_to_eq (band_elim_right H)]\n  | (Disj p\u2081 p\u2082) (Disj q\u2081 q\u2082) H :=\n    by rewrite [equal_to_eq (band_elim_left H), equal_to_eq (band_elim_right H)]\n  | (Impl p\u2081 p\u2082) (Impl q\u2081 q\u2082) 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 `\u2115` and `\u211d\u22650`, 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\u2093'. -/\ntheorem Ici_add_bij : BijOn (\u00b7 + d) (Ici a) (Ici (a + d)) :=\n  by\n  refine'\n    \u27e8fun x h => add_le_add_right (mem_Ici.mp h) _, (add_left_injective d).InjOn _, fun _ h => _\u27e9\n  obtain \u27e8c, rfl\u27e9 := exists_add_of_le (mem_Ici.mp h)\n  rw [mem_Ici, add_right_comm, add_le_add_iff_right] at h\n  exact \u27e8a + c, h, by rw [add_right_comm]\u27e9\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\u2093'. -/\ntheorem Ioi_add_bij : BijOn (\u00b7 + d) (Ioi a) (Ioi (a + d)) :=\n  by\n  refine'\n    \u27e8fun x h => add_lt_add_right (mem_Ioi.mp h) _, fun _ _ _ _ h => add_right_cancel h, fun _ h =>\n      _\u27e9\n  obtain \u27e8c, rfl\u27e9 := 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 \u27e8a + c, h, by rw [add_right_comm]\u27e9\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\u2093'. -/\ntheorem Icc_add_bij : BijOn (\u00b7 + d) (Icc a b) (Icc (a + d) (b + d)) :=\n  by\n  rw [\u2190 Ici_inter_Iic, \u2190 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\u2093'. -/\ntheorem Ioo_add_bij : BijOn (\u00b7 + d) (Ioo a b) (Ioo (a + d) (b + d)) :=\n  by\n  rw [\u2190 Ioi_inter_Iio, \u2190 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\u2093'. -/\ntheorem Ioc_add_bij : BijOn (\u00b7 + d) (Ioc a b) (Ioc (a + d) (b + d)) :=\n  by\n  rw [\u2190 Ioi_inter_Iic, \u2190 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\u2093'. -/\ntheorem Ico_add_bij : BijOn (\u00b7 + d) (Ico a b) (Ico (a + d) (b + d)) :=\n  by\n  rw [\u2190 Ici_inter_Iio, \u2190 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 \u21a6 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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 \u21a6 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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 \u03b1`: turns any multiplicative structure on `\u03b1` into the corresponding\n  additive structure on `additive \u03b1`;\n* `multiplicative \u03b1`: turns any additive structure on `\u03b1` into the corresponding\n  multiplicative structure on `multiplicative \u03b1`.\n\nWe also define instances `additive.*` and `multiplicative.*` that actually transfer the structures.\n-/\n\nuniverses u v\nvariables {\u03b1 : Type u} {\u03b2 : Type v}\n\n/-- If `\u03b1` carries some multiplicative structure, then `additive \u03b1` carries the corresponding\nadditive structure. -/\ndef additive (\u03b1 : Type*) := \u03b1\n/-- If `\u03b1` carries some additive structure, then `multiplicative \u03b1` carries the corresponding\nmultiplicative structure. -/\ndef multiplicative (\u03b1 : Type*) := \u03b1\n\nnamespace additive\n\n/-- Reinterpret `x : \u03b1` as an element of `additive \u03b1`. -/\ndef of_mul : \u03b1 \u2243 additive \u03b1 := \u27e8\u03bb x, x, \u03bb x, x, \u03bb x, rfl, \u03bb x, rfl\u27e9\n\n/-- Reinterpret `x : additive \u03b1` as an element of `\u03b1`. -/\ndef to_mul : additive \u03b1 \u2243 \u03b1 := of_mul.symm\n\n@[simp] lemma of_mul_symm_eq : (@of_mul \u03b1).symm = to_mul := rfl\n\n@[simp] lemma to_mul_symm_eq : (@to_mul \u03b1).symm = of_mul := rfl\n\nend additive\n\nnamespace multiplicative\n\n/-- Reinterpret `x : \u03b1` as an element of `multiplicative \u03b1`. -/\ndef of_add : \u03b1 \u2243 multiplicative \u03b1 := \u27e8\u03bb x, x, \u03bb x, x, \u03bb x, rfl, \u03bb x, rfl\u27e9\n\n/-- Reinterpret `x : multiplicative \u03b1` as an element of `\u03b1`. -/\ndef to_add : multiplicative \u03b1 \u2243 \u03b1 := of_add.symm\n\n@[simp] lemma of_add_symm_eq : (@of_add \u03b1).symm = to_add := rfl\n\n@[simp] \n\nend multiplicative\n\n@[simp] lemma to_add_of_add (x : \u03b1) : (multiplicative.of_add x).to_add = x := rfl\n@[simp] lemma of_add_to_add (x : multiplicative \u03b1) : multiplicative.of_add x.to_add = x := rfl\n\n@[simp] lemma to_mul_of_mul (x : \u03b1) : (additive.of_mul x).to_mul = x := rfl\n@[simp] lemma of_mul_to_mul (x : additive \u03b1) : additive.of_mul x.to_mul = x := rfl\n\ninstance [inhabited \u03b1] : inhabited (additive \u03b1) := \u27e8additive.of_mul default\u27e9\ninstance [inhabited \u03b1] : inhabited (multiplicative \u03b1) := \u27e8multiplicative.of_add default\u27e9\n\ninstance [nontrivial \u03b1] : nontrivial (additive \u03b1) :=\nadditive.of_mul.injective.nontrivial\n\ninstance [nontrivial \u03b1] : nontrivial (multiplicative \u03b1) :=\nmultiplicative.of_add.injective.nontrivial\n\ninstance additive.has_add [has_mul \u03b1] : has_add (additive \u03b1) :=\n{ add := \u03bb x y, additive.of_mul (x.to_mul * y.to_mul) }\n\ninstance [has_add \u03b1] : has_mul (multiplicative \u03b1) :=\n{ mul := \u03bb x y, multiplicative.of_add (x.to_add + y.to_add) }\n\n@[simp] lemma of_add_add [has_add \u03b1] (x y : \u03b1) :\n  multiplicative.of_add (x + y) = multiplicative.of_add x * multiplicative.of_add y :=\nrfl\n\n@[simp] lemma to_add_mul [has_add \u03b1] (x y : multiplicative \u03b1) :\n  (x * y).to_add = x.to_add + y.to_add :=\nrfl\n\n@[simp] lemma of_mul_mul [has_mul \u03b1] (x y : \u03b1) :\n  additive.of_mul (x * y) = additive.of_mul x + additive.of_mul y :=\nrfl\n\n@[simp] lemma to_mul_add [has_mul \u03b1] (x y : additive \u03b1) :\n  (x + y).to_mul = x.to_mul * y.to_mul :=\nrfl\n\ninstance [semigroup \u03b1] : add_semigroup (additive \u03b1) :=\n{ add_assoc := @mul_assoc \u03b1 _,\n  ..additive.has_add }\n\ninstance [add_semigroup \u03b1] : semigroup (multiplicative \u03b1) :=\n{ mul_assoc := @add_assoc \u03b1 _,\n  ..multiplicative.has_mul }\n\ninstance [comm_semigroup \u03b1] : add_comm_semigroup (additive \u03b1) :=\n{ add_comm := @mul_comm _ _,\n  ..additive.add_semigroup }\n\ninstance [add_comm_semigroup \u03b1] : comm_semigroup (multiplicative \u03b1) :=\n{ mul_comm := @add_comm _ _,\n  ..multiplicative.semigroup }\n\ninstance [left_cancel_semigroup \u03b1] : add_left_cancel_semigroup (additive \u03b1) :=\n{ add_left_cancel := @mul_left_cancel _ _,\n  ..additive.add_semigroup }\n\ninstance [add_left_cancel_semigroup \u03b1] : left_cancel_semigroup (multiplicative \u03b1) :=\n{ mul_left_cancel := @add_left_cancel _ _,\n  ..multiplicative.semigroup }\n\ninstance [right_cancel_semigroup \u03b1] : add_right_cancel_semigroup (additive \u03b1) :=\n{ add_right_cancel := @mul_right_cancel _ _,\n  ..additive.add_semigroup }\n\ninstance [add_right_cancel_semigroup \u03b1] : right_cancel_semigroup (multiplicative \u03b1) :=\n{ mul_right_cancel := @add_right_cancel _ _,\n  ..multiplicative.semigroup }\n\ninstance [has_one \u03b1] : has_zero (additive \u03b1) := \u27e8additive.of_mul 1\u27e9\n\n@[simp] lemma of_mul_one [has_one \u03b1] : @additive.of_mul \u03b1 1 = 0 := rfl\n\n@[simp] lemma of_mul_eq_zero {A : Type*} [has_one A] {x : A} :\n  additive.of_mul x = 0 \u2194 x = 1 := iff.rfl\n\n@[simp] lemma to_mul_zero [has_one \u03b1] : (0 : additive \u03b1).to_mul = 1 := rfl\n\ninstance [has_zero \u03b1] : has_one (multiplicative \u03b1) := \u27e8multiplicative.of_add 0\u27e9\n\n@[simp] lemma of_add_zero [has_zero \u03b1] : @multiplicative.of_add \u03b1 0 = 1 := rfl\n\n@[simp] lemma of_add_eq_one {A : Type*} [has_zero A] {x : A} :\n  multiplicative.of_add x = 1 \u2194 x = 0 := iff.rfl\n\n@[simp] lemma to_add_one [has_zero \u03b1] : (1 : multiplicative \u03b1).to_add = 0 := rfl\n\ninstance [mul_one_class \u03b1] : add_zero_class (additive \u03b1) :=\n{ zero     := 0,\n  add      := (+),\n  zero_add := one_mul,\n  add_zero := mul_one }\n\ninstance [add_zero_class \u03b1] : mul_one_class (multiplicative \u03b1) :=\n{ one     := 1,\n  mul     := (*),\n  one_mul := zero_add,\n  mul_one := add_zero }\n\ninstance [h : monoid \u03b1] : add_monoid (additive \u03b1) :=\n{ zero     := 0,\n  add      := (+),\n  nsmul    := @monoid.npow \u03b1 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 \u03b1] : monoid (multiplicative \u03b1) :=\n{ one     := 1,\n  mul     := (*),\n  npow   := @add_monoid.nsmul \u03b1 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 \u03b1] : add_left_cancel_monoid (additive \u03b1) :=\n{ zero := 0, add := (+), .. additive.add_monoid, .. additive.add_left_cancel_semigroup }\n\ninstance [add_left_cancel_monoid \u03b1] : left_cancel_monoid (multiplicative \u03b1) :=\n{ one := 1, mul := (*), .. multiplicative.monoid, .. multiplicative.left_cancel_semigroup }\n\ninstance [right_cancel_monoid \u03b1] : add_right_cancel_monoid (additive \u03b1) :=\n{ zero := 0, add := (+), .. additive.add_monoid, .. additive.add_right_cancel_semigroup }\n\ninstance [add_right_cancel_monoid \u03b1] : right_cancel_monoid (multiplicative \u03b1) :=\n{ one := 1, mul := (*), .. multiplicative.monoid, .. multiplicative.right_cancel_semigroup }\n\ninstance [comm_monoid \u03b1] : add_comm_monoid (additive \u03b1) :=\n{ zero := 0, add := (+), .. additive.add_monoid, .. additive.add_comm_semigroup }\n\ninstance [add_comm_monoid \u03b1] : comm_monoid (multiplicative \u03b1) :=\n{ one := 1, mul := (*), ..multiplicative.monoid, .. multiplicative.comm_semigroup }\n\ninstance [has_inv \u03b1] : has_neg (additive \u03b1) := \u27e8\u03bb x, multiplicative.of_add x.to_mul\u207b\u00b9\u27e9\n\n@[simp] lemma of_mul_inv [has_inv \u03b1] (x : \u03b1) : additive.of_mul x\u207b\u00b9 = -(additive.of_mul x) := rfl\n\n@[simp] lemma to_mul_neg [has_inv \u03b1] (x : additive \u03b1) : (-x).to_mul = x.to_mul\u207b\u00b9 := rfl\n\ninstance [has_neg \u03b1] : has_inv (multiplicative \u03b1) := \u27e8\u03bb x, additive.of_mul (-x.to_add)\u27e9\n\n@[simp] lemma of_add_neg [has_neg \u03b1] (x : \u03b1) :\n  multiplicative.of_add (-x) = (multiplicative.of_add x)\u207b\u00b9 := rfl\n\n@[simp] lemma to_add_inv [has_neg \u03b1] (x : multiplicative \u03b1) :\n  (x\u207b\u00b9).to_add = -x.to_add := rfl\n\ninstance additive.has_sub [has_div \u03b1] : has_sub (additive \u03b1) :=\n{ sub := \u03bb x y, additive.of_mul (x.to_mul / y.to_mul) }\n\ninstance multiplicative.has_div [has_sub \u03b1] : has_div (multiplicative \u03b1) :=\n{ div := \u03bb x y, multiplicative.of_add (x.to_add - y.to_add) }\n\n@[simp] lemma of_add_sub [has_sub \u03b1] (x y : \u03b1) :\n  multiplicative.of_add (x - y) = multiplicative.of_add x / multiplicative.of_add y :=\nrfl\n\n@[simp] lemma to_add_div [has_sub \u03b1] (x y : multiplicative \u03b1) :\n  (x / y).to_add = x.to_add - y.to_add :=\nrfl\n\n@[simp] lemma of_mul_div [has_div \u03b1] (x y : \u03b1) :\n  additive.of_mul (x / y) = additive.of_mul x - additive.of_mul y :=\nrfl\n\n@[simp] lemma to_mul_sub [has_div \u03b1] (x y : additive \u03b1) :\n  (x - y).to_mul = x.to_mul / y.to_mul :=\nrfl\n\ninstance [div_inv_monoid \u03b1] : sub_neg_monoid (additive \u03b1) :=\n{ sub_eq_add_neg := @div_eq_mul_inv \u03b1 _,\n  zsmul := @div_inv_monoid.zpow \u03b1 _,\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 \u03b1] : div_inv_monoid (multiplicative \u03b1) :=\n{ div_eq_mul_inv := @sub_eq_add_neg \u03b1 _,\n  zpow := @sub_neg_monoid.zsmul \u03b1 _,\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 \u03b1] : add_group (additive \u03b1) :=\n{ add_left_neg := @mul_left_inv \u03b1 _,\n  .. additive.sub_neg_monoid }\n\ninstance [add_group \u03b1] : group (multiplicative \u03b1) :=\n{ mul_left_inv := @add_left_neg \u03b1 _,\n  .. multiplicative.div_inv_monoid }\n\ninstance [comm_group \u03b1] : add_comm_group (additive \u03b1) :=\n{ .. additive.add_group, .. additive.add_comm_monoid }\n\ninstance [add_comm_group \u03b1] : comm_group (multiplicative \u03b1) :=\n{ .. multiplicative.group, .. multiplicative.comm_monoid }\n\n/-- Reinterpret `\u03b1 \u2192+ \u03b2` as `multiplicative \u03b1 \u2192* multiplicative \u03b2`. -/\ndef add_monoid_hom.to_multiplicative [add_zero_class \u03b1] [add_zero_class \u03b2] :\n  (\u03b1 \u2192+ \u03b2) \u2243 (multiplicative \u03b1 \u2192* multiplicative \u03b2) :=\n\u27e8\u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb x, by { ext, refl, }, \u03bb x, by { ext, refl, }\u27e9\n\n/-- Reinterpret `\u03b1 \u2192* \u03b2` as `additive \u03b1 \u2192+ additive \u03b2`. -/\ndef monoid_hom.to_additive [mul_one_class \u03b1] [mul_one_class \u03b2] :\n  (\u03b1 \u2192* \u03b2) \u2243 (additive \u03b1 \u2192+ additive \u03b2) :=\n\u27e8\u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb x, by { ext, refl, }, \u03bb x, by { ext, refl, }\u27e9\n\n/-- Reinterpret `additive \u03b1 \u2192+ \u03b2` as `\u03b1 \u2192* multiplicative \u03b2`. -/\ndef add_monoid_hom.to_multiplicative' [mul_one_class \u03b1] [add_zero_class \u03b2] :\n  (additive \u03b1 \u2192+ \u03b2) \u2243 (\u03b1 \u2192* multiplicative \u03b2) :=\n\u27e8\u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb x, by { ext, refl, }, \u03bb x, by { ext, refl, }\u27e9\n\n/-- Reinterpret `\u03b1 \u2192* multiplicative \u03b2` as `additive \u03b1 \u2192+ \u03b2`. -/\ndef monoid_hom.to_additive' [mul_one_class \u03b1] [add_zero_class \u03b2] :\n  (\u03b1 \u2192* multiplicative \u03b2) \u2243 (additive \u03b1 \u2192+ \u03b2) :=\nadd_monoid_hom.to_multiplicative'.symm\n\n/-- Reinterpret `\u03b1 \u2192+ additive \u03b2` as `multiplicative \u03b1 \u2192* \u03b2`. -/\ndef add_monoid_hom.to_multiplicative'' [add_zero_class \u03b1] [mul_one_class \u03b2] :\n  (\u03b1 \u2192+ additive \u03b2) \u2243 (multiplicative \u03b1 \u2192* \u03b2) :=\n\u27e8\u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb x, by { ext, refl, }, \u03bb x, by { ext, refl, }\u27e9\n\n/-- Reinterpret `multiplicative \u03b1 \u2192* \u03b2` as `\u03b1 \u2192+ additive \u03b2`. -/\ndef monoid_hom.to_additive'' [add_zero_class \u03b1] [mul_one_class \u03b2] :\n  (multiplicative \u03b1 \u2192* \u03b2) \u2243 (\u03b1 \u2192+ additive \u03b2) :=\nadd_monoid_hom.to_multiplicative''.symm\n\n/-- If `\u03b1` has some multiplicative structure and coerces to a function,\nthen `additive \u03b1` 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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Sort*} [has_coe_to_fun \u03b1 \u03b2] :\n  has_coe_to_fun (additive \u03b1) (\u03bb a, \u03b2 a.to_mul) :=\n\u27e8\u03bb a, coe_fn a.to_mul\u27e9\n\n/-- If `\u03b1` has some additive structure and coerces to a function,\nthen `multiplicative \u03b1` 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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Sort*} [has_coe_to_fun \u03b1 \u03b2] :\n  has_coe_to_fun (multiplicative \u03b1) (\u03bb a, \u03b2 a.to_add) :=\n\u27e8\u03bb a, coe_fn a.to_add\u27e9\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 \u00d7 \u211d, Y)` instead of `to_fun : C(X \u00d7 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 \u00d7 [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\u2080 f\u2081 P`, which is a homotopy between `f\u2080` and `f\u2081`,\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\u2080 f\u2081 P` - A homotopy between `f\u2080` and `f\u2081`, where all of the intermediate maps\n  satisfy the property `P`.\n- `homotopy f\u2080 f\u2081` - A homotopy between `f\u2080` and `f\u2081`.\n-/\n\nnoncomputable theory\n\nvariables {X Y : Type _} [topological_space X] [topological_space Y]\n\n/--\nA homotopy between `f\u2080` and `f\u2081`, 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\u2080 f\u2081 : C(X, Y)) (P : (X \u2192 Y) \u2192 Prop) :=\n(to_fun : C(X \u00d7 \u211d, Y))\n(to_fun_zero' : \u2200 x, to_fun (x, 0) = f\u2080 x)\n(to_fun_one' : \u2200 x, to_fun (x, 1) = f\u2081 x)\n(prop : \u2200 t, P(\u03bb x, to_fun (x, t)))\n\nnamespace homotopy_with\n\nvariables {f\u2080 f\u2081 f\u2082 : C(X, Y)} {P : (X \u2192 Y) \u2192 Prop}\n\ninstance : has_coe_t (homotopy_with f\u2080 f\u2081 P) (C(X \u00d7 \u211d, Y)) := \u27e8homotopy_with.to_fun\u27e9\ninstance : has_coe_to_fun (homotopy_with f\u2080 f\u2081 P) := \u27e8_, \u03bb h, h.to_fun.to_fun\u27e9\n\n@[continuity]\nlemma continuous (h : homotopy_with f\u2080 f\u2081 P) : continuous h := h.to_fun.continuous\n\n@[simp] lemma to_fun_zero (h : homotopy_with f\u2080 f\u2081 P) (x : X) : h (x, 0) = f\u2080 x := \n  h.to_fun_zero' x \n\n@[simp] lemma to_fun_one (h : homotopy_with f\u2080 f\u2081 P) (x : X) : h (x, 1) = f\u2081 x := \n  h.to_fun_one' x \n\n@[simp] lemma coe_coe_apply_eq_coe (h : homotopy_with f\u2080 f\u2081 P) (x : X \u00d7 \u211d) :\n  (h : C(X \u00d7 \u211d, Y)) x = h x := rfl\n\n/--\nIf `f\u2080` satisfies the property `P`, then we have a `homotopy_with f\u2080 f\u2080 P`.\n-/\ndef refl (hP : P f\u2080) : homotopy_with f\u2080 f\u2080 P :=\n{ to_fun := \n  { to_fun := \u03bb p, f\u2080 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 := \u03bb t, hP }\n\n/--\nIf `f\u2080` and `f\u2081` agree on every input, and that `f\u2080` satisfies the property `P`, then we have a ` homotmotopy_with f\u2080 f\u2081 P`.\n-/\ndef of_refl (hP : P f\u2080) (h : f\u2080 = f\u2081) : homotopy_with f\u2080 f\u2081 P :=\n{ to_fun := { to_fun := \u03bb p, f\u2080 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 := \u03bb t, hP }\n\n/--\nIf we have `h : homotopy_with f\u2080 f\u2081 P`, we can define a `homotopy_with f\u2081 f\u2080 P` by reversing the \ndirection of the homotopy.\n-/\ndef symm (h : homotopy_with f\u2080 f\u2081 P) : homotopy_with f\u2081 f\u2080 P :=\n{ to_fun := \n  { to_fun := \u03bb p, h (p.1, 1 - p.2) },\n  to_fun_zero' := by simp,\n  to_fun_one' := by simp,\n  prop := \u03bb t, \n  begin\n    simp only [continuous_map.coe_mk],\n    apply h.prop,\n  end }\n\n/--\nIf we have `h\u2080 : homotopy_with f\u2080 f\u2081 P` and `h\u2081 : homotopy_with f\u2081 f\u2082 P`, we can define a\n`homotopy_with f\u2080 f\u2082 P` by 'gluing' the homotopies together.\n-/\ndef trans (h\u2080 : homotopy_with f\u2080 f\u2081 P) (h\u2081 : homotopy_with f\u2081 f\u2082 P) : homotopy_with f\u2080 f\u2082 P :=\n{ to_fun := \n  { to_fun := \u03bb p, if p.2 \u2264 1/2 then h\u2080 (p.1, 2 * p.2) else h\u2081 (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 \u27e8ha\u2081, ha\u2082\u27e9 := 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' := \u03bb 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' := \u03bb x, by norm_num,\n  prop := \u03bb 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\u2080.prop },\n    { apply h\u2081.prop }\n  end }\n\nend homotopy_with\n\n/--\nA `homotopy f\u2080 f\u2081` is defined to be a `homotopy_with f\u2080 f\u2081 P`, where `P` is always `true`.\n-/\nabbreviation homotopy (f\u2080 f\u2081 : C(X, Y)) := homotopy_with f\u2080 f\u2081 (\u03bb f, true)\n\nnamespace homotopy\n\nvariables {f\u2080 f\u2081 f\u2082 : C(X, Y)}\n\n/--\nFor `homotopy f\u2080 f\u2080`, 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\u2080 : C(X, Y)) : homotopy f\u2080 f\u2080 := 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\u2080 = f\u2081) : homotopy f\u2080 f\u2081 := homotopy_with.of_refl trivial h\n\nend homotopy\n\n/--\nTwo continuous functions `f\u2080` and `f\u2081` are homotopic if there exists a `homotopy f\u2080 f\u2081`.\n-/\ndef homotopic (f\u2080 f\u2081 : C(X, Y)) := nonempty (homotopy f\u2080 f\u2081)\n\nlemma homotopic.equiv : equivalence (@homotopic X Y _ _) :=\n\u27e8\u03bb f, \u27e8homotopy.refl f\u27e9, \u03bb f g \u27e8h\u27e9, \u27e8h.symm\u27e9, \u03bb f\u2080 f\u2081 f\u2082 \u27e8h\u2080\u27e9 \u27e8h\u2081\u27e9, \u27e8h\u2080.trans h\u2081\u27e9\u27e9\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 \u2115 : filter \u2115) \u211d\n\nnamespace hyperreal\n\nnotation `\u211d*` := hyperreal\n\nnoncomputable instance : has_coe_t \u211d \u211d* := \u27e8\u03bb x, (\u2191x : germ _ _)\u27e9\n\n@[simp, norm_cast]\nlemma coe_eq_coe {x y : \u211d} : (x : \u211d*) = y \u2194 x = y :=\ngerm.const_inj\n\n@[simp, norm_cast] lemma coe_eq_zero {x : \u211d} : (x : \u211d*) = 0 \u2194 x = 0 := coe_eq_coe\n@[simp, norm_cast] lemma coe_eq_one {x : \u211d} : (x : \u211d*) = 1 \u2194 x = 1 := coe_eq_coe\n\n@[simp, norm_cast] lemma coe_one : \u2191(1 : \u211d) = (1 : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_zero : \u2191(0 : \u211d) = (0 : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_inv (x : \u211d) : \u2191(x\u207b\u00b9) = (x\u207b\u00b9 : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_neg (x : \u211d) : \u2191(-x) = (-x : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_add (x y : \u211d) : \u2191(x + y) = (x + y : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_bit0 (x : \u211d) : \u2191(bit0 x) = (bit0 x : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_bit1 (x : \u211d) : \u2191(bit1 x) = (bit1 x : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_mul (x y : \u211d) : \u2191(x * y) = (x * y : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_div (x y : \u211d) : \u2191(x / y) = (x / y : \u211d*) := rfl\n@[simp, norm_cast] lemma coe_sub (x y : \u211d) : \u2191(x - y) = (x - y : \u211d*) := rfl\n\n@[simp, norm_cast] lemma coe_lt_coe {x y : \u211d} : (x : \u211d*) < y \u2194 x < y := germ.const_lt\n@[simp, norm_cast] lemma coe_pos {x : \u211d} : 0 < (x : \u211d*) \u2194 0 < x :=\ncoe_lt_coe\n@[simp, norm_cast] lemma coe_le_coe {x y : \u211d} : (x : \u211d*) \u2264 y \u2194 x \u2264 y := germ.const_le_iff\n@[simp, norm_cast] lemma coe_abs (x : \u211d) : ((abs x : \u211d) : \u211d*) = abs x := germ.const_abs _\n@[simp, norm_cast] lemma coe_max (x y : \u211d) : ((max x y : \u211d) : \u211d*) = max x y := germ.const_max _ _\n@[simp, norm_cast] lemma coe_min (x y : \u211d) : ((min x y : \u211d) : \u211d*) = min x y := germ.const_min _ _\n\n/-- Construct a hyperreal number from a sequence of real numbers. -/\nnoncomputable def of_seq (f : \u2115 \u2192 \u211d) : \u211d* := (\u2191f : germ (hyperfilter \u2115 : filter \u2115) \u211d)\n\n/-- A sample infinitesimal hyperreal-/\nnoncomputable def epsilon : \u211d* := of_seq $ \u03bb n, n\u207b\u00b9\n\n/-- A sample infinite hyperreal-/\nnoncomputable def omega : \u211d* := of_seq coe\n\nlocalized \"notation `\u03b5` := hyperreal.epsilon\" in hyperreal\nlocalized \"notation `\u03c9` := hyperreal.omega\" in hyperreal\n\nlemma epsilon_eq_inv_omega : \u03b5 = \u03c9\u207b\u00b9 := rfl\n\nlemma inv_epsilon_eq_omega : \u03b5\u207b\u00b9 = \u03c9 := @inv_inv' _ _ \u03c9\n\nlemma epsilon_pos : 0 < \u03b5 :=\nsuffices \u2200\u1da0 i in hyperfilter \u2115, (0 : \u211d) < (i : \u2115)\u207b\u00b9, by rwa lt_def,\nhave h0' : {n : \u2115 | \u00ac 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 : \u03b5 \u2260 0 := ne_of_gt epsilon_pos\n\nlemma omega_pos : 0 < \u03c9 := by rw \u2190inv_epsilon_eq_omega; exact inv_pos.2 epsilon_pos\n\nlemma omega_ne_zero : \u03c9 \u2260 0 := ne_of_gt omega_pos\n\ntheorem epsilon_mul_omega : \u03b5 * \u03c9 = 1 := @inv_mul_cancel _ _ \u03c9 omega_ne_zero\n\nlemma lt_of_tendsto_zero_of_pos {f : \u2115 \u2192 \u211d} (hf : tendsto f at_top (\ud835\udcdd 0)) :\n  \u2200 {r : \u211d}, 0 < r \u2192 of_seq f < (r : \u211d*) :=\nbegin\n  simp only [metric.tendsto_at_top, dist_zero_right, norm, lt_def] at hf \u22a2,\n  intros r hr, cases hf r hr with N hf',\n  have hs : {i : \u2115 | f i < r}\u1d9c \u2286 {i : \u2115 | i \u2264 N} :=\n    \u03bb i hi1, le_of_lt (by simp only [lt_iff_not_ge];\n    exact \u03bb 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 : \u2115 \u2192 \u211d} (hf : tendsto f at_top (\ud835\udcdd 0)) :\n  \u2200 {r : \u211d}, 0 < r \u2192 (-r : \u211d*) < of_seq f :=\n\u03bb 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 : \u2115 \u2192 \u211d} (hf : tendsto f at_top (\ud835\udcdd 0)) :\n  \u2200 {r : \u211d}, r < 0 \u2192 (r : \u211d*) < of_seq f :=\n\u03bb r hr, by rw [\u2190neg_neg r, coe_neg];\nexact neg_lt_of_tendsto_zero_of_pos hf (neg_pos.mpr hr)\n\nlemma epsilon_lt_pos (x : \u211d) : 0 < x \u2192 \u03b5 < x :=\nlt_of_tendsto_zero_of_pos tendsto_inverse_at_top_nhds_0_nat\n\n/-- Standard part predicate -/\ndef is_st (x : \u211d*) (r : \u211d) := \u2200 \u03b4 : \u211d, 0 < \u03b4 \u2192 (r - \u03b4 : \u211d*) < x \u2227 x < r + \u03b4\n\n/-- Standard part function: like a \"round\" to \u211d instead of \u2124 -/\nnoncomputable def st : \u211d* \u2192 \u211d :=\n\u03bb x, if h : \u2203 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 : \u211d*) := is_st x 0\n\n/-- A hyperreal number is positive infinite if it is larger than all real numbers -/\ndef infinite_pos (x : \u211d*) := \u2200 r : \u211d, \u2191r < x\n\n/-- A hyperreal number is negative infinite if it is smaller than all real numbers -/\ndef infinite_neg (x : \u211d*) := \u2200 r : \u211d, x < r\n\n/-- A hyperreal number is infinite if it is infinite positive or infinite negative -/\ndef infinite (x : \u211d*) := infinite_pos x \u2228 infinite_neg x\n\n/-!\n### Some facts about `st`\n-/\n\nprivate lemma is_st_unique' (x : \u211d*) (r s : \u211d) (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 : \u211d*} {r s : \u211d} (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 : \u211d*} : (\u2203 r : \u211d, is_st x r) \u2192 \u00ac infinite x :=\n\u03bb he hi, Exists.dcases_on he $ \u03bb r hr, hi.elim\n   (\u03bb hip, not_lt_of_lt (hr 2 zero_lt_two).2 (hip $ r + 2))\n   (\u03bb hin, not_lt_of_lt (hr 2 zero_lt_two).1 (hin $ r - 2))\n\ntheorem is_st_Sup {x : \u211d*} (hni : \u00ac infinite x) : is_st x (Sup {y : \u211d | (y : \u211d*) < x}) :=\nlet S : set \u211d := {y : \u211d | (y : \u211d*) < 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 $ \u03bb r\u2081 hr\u2081 r\u2082 hr\u2082,\nhave HR\u2081 : \u2203 y : \u211d, y \u2208 S :=\n  \u27e8r\u2081 - 1, lt_of_lt_of_le (coe_lt_coe.2 $ sub_one_lt _) (not_lt.mp hr\u2081) \u27e9,\nhave HR\u2082 : \u2203 z : \u211d, \u2200 y \u2208 S, y \u2264 z :=\n  \u27e8 r\u2082, \u03bb y hy, le_of_lt (coe_lt_coe.1 (lt_of_lt_of_le hy (not_lt.mp hr\u2082))) \u27e9,\n\u03bb \u03b4 h\u03b4,\n  \u27e8 lt_of_not_ge' $ \u03bb c,\n      have hc : \u2200 y \u2208 S, y \u2264 R - \u03b4 := \u03bb 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\u2081 HR\u2082).mpr hc) $ sub_lt_self R h\u03b4,\n    lt_of_not_ge' $ \u03bb c,\n      have hc : \u2191(R + \u03b4 / 2) < x :=\n        lt_of_lt_of_le (add_lt_add_left (coe_lt_coe.2 (half_lt_self h\u03b4)) R) c,\n      not_lt_of_le (real.le_Sup _ HR\u2082 hc) $ (lt_add_iff_pos_right _).mpr $ half_pos h\u03b4\u27e9\n\ntheorem exists_st_of_not_infinite {x : \u211d*} (hni : \u00ac infinite x) : \u2203 r : \u211d, is_st x r :=\n\u27e8Sup {y : \u211d | (y : \u211d*) < x}, is_st_Sup hni\u27e9\n\ntheorem st_eq_Sup {x : \u211d*} : st x = Sup {y : \u211d | (y : \u211d*) < 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 (\u03bb i, \u27e8\u03bb hi, set.mem_univ i, \u03bb hi, H i\u27e9) : {y : \u211d | (y : \u211d*) < x} = set.univ),\n    exact (real.Sup_univ).symm },\n  { rw (set.ext (\u03bb i, \u27e8\u03bb hi, false.elim (not_lt_of_lt (H i) hi),\n    \u03bb hi, false.elim (set.not_mem_empty i hi)\u27e9) : {y : \u211d | (y : \u211d*) < x} = \u2205),\n    exact (real.Sup_empty).symm } }\nend\n\ntheorem exists_st_iff_not_infinite {x : \u211d*} : (\u2203 r : \u211d, is_st x r) \u2194 \u00ac infinite x :=\n\u27e8 not_infinite_of_exists_st, exists_st_of_not_infinite \u27e9\n\ntheorem infinite_iff_not_exists_st {x : \u211d*} : infinite x \u2194 \u00ac \u2203 r : \u211d, is_st x r :=\niff_not_comm.mp exists_st_iff_not_infinite\n\ntheorem st_infinite {x : \u211d*} (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 : \u211d*} {r : \u211d} (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 \u27e8r, hxr\u27e9) }\nend\n\nlemma is_st_st_of_is_st {x : \u211d*} {r : \u211d} (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 : \u211d*} (hx : \u2203 r : \u211d, is_st x r) : is_st x (st x) :=\nExists.dcases_on hx (\u03bb r, is_st_st_of_is_st)\n\nlemma is_st_st {x : \u211d*} (hx : st x \u2260 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 : \u211d*} (hx : \u00ac 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 : \u211d) : is_st r r :=\n\u03bb \u03b4 h\u03b4, \u27e8 sub_lt_self _ (coe_lt_coe.2 h\u03b4), (lt_add_of_pos_right _ (coe_lt_coe.2 h\u03b4)) \u27e9\n\nlemma st_id_real (r : \u211d) : st r = r := st_of_is_st (is_st_refl_real r)\n\nlemma eq_of_is_st_real {r s : \u211d} : is_st r s \u2192 r = s := is_st_unique (is_st_refl_real r)\n\nlemma is_st_real_iff_eq {r s : \u211d} : is_st r s \u2194 r = s :=\n\u27e8eq_of_is_st_real, \u03bb hrs, by rw [hrs]; exact is_st_refl_real s\u27e9\n\nlemma is_st_symm_real {r s : \u211d} : is_st r s \u2194 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 : \u211d} : is_st r s \u2192 is_st s t \u2192 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\u2081 r\u2082 s : \u211d} (h1 : is_st r\u2081 s) (h2 : is_st r\u2082 s) : r\u2081 = r\u2082 :=\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 : \u211d*} {r : \u211d} :\n  is_st x r \u2194 \u2200 (\u03b4 : \u211d), 0 < \u03b4 \u2192 abs (x - r) < \u03b4 :=\nby simp only [abs_sub_lt_iff, @sub_lt _ _ (r : \u211d*) x _,\n    @sub_lt_iff_lt_add' _ _ x (r : \u211d*) _, and_comm]; refl\n\nlemma is_st_add {x y : \u211d*} {r s : \u211d} : is_st x r \u2192 is_st y s \u2192 is_st (x + y) (r + s) :=\n\u03bb hxr hys d hd,\nhave hxr' : _ := hxr (d / 2) (half_pos hd),\nhave hys' : _ := hys (d / 2) (half_pos hd),\n\u27e8by 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\u27e9\n\nlemma is_st_neg {x : \u211d*} {r : \u211d} (hxr : is_st x r) : is_st (-x) (-r) :=\n\u03bb d hd, by show -(r : \u211d*) - d < -x \u2227 -x < -r + d; cases (hxr d hd); split; linarith\n\nlemma is_st_sub {x y : \u211d*} {r s : \u211d} : is_st x r \u2192 is_st y s \u2192 is_st (x - y) (r - s) :=\n\u03bb 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) \u2192 (x < y) \u2192 (x \u2264 y) \u2192 (st x \u2264 st y) -/\n\nlemma lt_of_is_st_lt {x y : \u211d*} {r s : \u211d} (hxr : is_st x r) (hys : is_st y s) :\n  r < s \u2192 x < y :=\n\u03bb 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 : \u211d*} {r s : \u211d} (hrx : is_st x r) (hsy : is_st y s) :\n  x \u2264 y \u2192 r \u2264 s := by rw [\u2190not_lt, \u2190not_lt, not_imp_not]; exact lt_of_is_st_lt hsy hrx\n\nlemma st_le_of_le {x y : \u211d*} (hix : \u00ac infinite x) (hiy : \u00ac infinite y) :\n  x \u2264 y \u2192 st x \u2264 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 : \u211d*} (hix : \u00ac infinite x) (hiy : \u00ac infinite y) :\n  st x < st y \u2192 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 : \u211d*} : infinite_pos x \u2194 \u2200 r : \u211d, \u2191r < x := by rw iff_eq_eq; refl\n\nlemma infinite_neg_def {x : \u211d*} : infinite_neg x \u2194 \u2200 r : \u211d, x < r := by rw iff_eq_eq; refl\n\nlemma ne_zero_of_infinite {x : \u211d*} : infinite x \u2192 x \u2260 0 :=\n\u03bb hI h0, or.cases_on hI\n  (\u03bb hip, lt_irrefl (0 : \u211d*) ((by rwa \u2190h0 : infinite_pos 0) 0))\n  (\u03bb hin, lt_irrefl (0 : \u211d*) ((by rwa \u2190h0 : infinite_neg 0) 0))\n\nlemma not_infinite_zero : \u00ac infinite 0 := \u03bb hI, ne_zero_of_infinite hI rfl\n\nlemma pos_of_infinite_pos {x : \u211d*} : infinite_pos x \u2192 0 < x := \u03bb hip, hip 0\n\nlemma neg_of_infinite_neg {x : \u211d*} : infinite_neg x \u2192 x < 0 := \u03bb hin, hin 0\n\nlemma not_infinite_pos_of_infinite_neg {x : \u211d*} : infinite_neg x \u2192 \u00ac infinite_pos x :=\n\u03bb hn hp, not_lt_of_lt (hn 1) (hp 1)\n\nlemma not_infinite_neg_of_infinite_pos {x : \u211d*} : infinite_pos x \u2192 \u00ac infinite_neg x :=\nimp_not_comm.mp not_infinite_pos_of_infinite_neg\n\nlemma infinite_neg_neg_of_infinite_pos {x : \u211d*} : infinite_pos x \u2192 infinite_neg (-x) :=\n\u03bb hp r, neg_lt.mp (hp (-r))\n\nlemma infinite_pos_neg_of_infinite_neg {x : \u211d*} : infinite_neg x \u2192 infinite_pos (-x) :=\n\u03bb hp r, lt_neg.mp (hp (-r))\n\nlemma infinite_pos_iff_infinite_neg_neg {x : \u211d*} : infinite_pos x \u2194 infinite_neg (-x) :=\n\u27e8 infinite_neg_neg_of_infinite_pos, \u03bb hin, neg_neg x \u25b8 infinite_pos_neg_of_infinite_neg hin \u27e9\n\nlemma infinite_neg_iff_infinite_pos_neg {x : \u211d*} : infinite_neg x \u2194 infinite_pos (-x) :=\n\u27e8 infinite_pos_neg_of_infinite_neg, \u03bb hin, neg_neg x \u25b8 infinite_neg_neg_of_infinite_pos hin \u27e9\n\nlemma infinite_iff_infinite_neg {x : \u211d*} : infinite x \u2194 infinite (-x) :=\n\u27e8 \u03bb hi, or.cases_on hi\n  (\u03bb hip, or.inr (infinite_neg_neg_of_infinite_pos hip))\n  (\u03bb hin, or.inl (infinite_pos_neg_of_infinite_neg hin)),\n \u03bb hi, or.cases_on hi\n  (\u03bb hipn, or.inr (infinite_neg_iff_infinite_pos_neg.mpr hipn))\n  (\u03bb hinp, or.inl (infinite_pos_iff_infinite_neg_neg.mpr hinp))\u27e9\n\nlemma not_infinite_of_infinitesimal {x : \u211d*} : infinitesimal x \u2192 \u00ac infinite x :=\n\u03bb hi hI, have hi' : _ := (hi 2 zero_lt_two), or.dcases_on hI\n  (\u03bb hip, have hip' : _ := hip 2, not_lt_of_lt hip' (by convert hi'.2; exact (zero_add 2).symm))\n  (\u03bb 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 : \u211d*} : infinite_pos x \u2192 \u00ac infinitesimal x :=\n\u03bb hp, not_infinitesimal_of_infinite (or.inl hp)\n\nlemma not_infinitesimal_of_infinite_neg {x : \u211d*} : infinite_neg x \u2192 \u00ac infinitesimal x :=\n\u03bb hn, not_infinitesimal_of_infinite (or.inr hn)\n\nlemma infinite_pos_iff_infinite_and_pos {x : \u211d*} : infinite_pos x \u2194 (infinite x \u2227 0 < x) :=\n\u27e8 \u03bb hip, \u27e8or.inl hip, hip 0\u27e9,\n  \u03bb \u27e8hi, hp\u27e9, hi.cases_on (\u03bb hip, hip) (\u03bb hin, false.elim (not_lt_of_lt hp (hin 0))) \u27e9\n\nlemma infinite_neg_iff_infinite_and_neg {x : \u211d*} : infinite_neg x \u2194 (infinite x \u2227 x < 0) :=\n\u27e8 \u03bb hip, \u27e8or.inr hip, hip 0\u27e9,\n  \u03bb \u27e8hi, hp\u27e9, hi.cases_on (\u03bb hin, false.elim (not_lt_of_lt hp (hin 0))) (\u03bb hip, hip) \u27e9\n\nlemma infinite_pos_iff_infinite_of_pos {x : \u211d*} (hp : 0 < x) : infinite_pos x \u2194 infinite x :=\nby rw [infinite_pos_iff_infinite_and_pos]; exact \u27e8\u03bb hI, hI.1, \u03bb hI, \u27e8hI, hp\u27e9\u27e9\n\nlemma infinite_pos_iff_infinite_of_nonneg {x : \u211d*} (hp : 0 \u2264 x) : infinite_pos x \u2194 infinite x :=\nor.cases_on (lt_or_eq_of_le hp) (infinite_pos_iff_infinite_of_pos)\n  (\u03bb h, by rw h.symm; exact\n  \u27e8\u03bb hIP, false.elim (not_infinite_zero (or.inl hIP)), \u03bb hI, false.elim (not_infinite_zero hI)\u27e9)\n\nlemma infinite_neg_iff_infinite_of_neg {x : \u211d*} (hn : x < 0) : infinite_neg x \u2194 infinite x :=\nby rw [infinite_neg_iff_infinite_and_neg]; exact \u27e8\u03bb hI, hI.1, \u03bb hI, \u27e8hI, hn\u27e9\u27e9\n\nlemma infinite_pos_abs_iff_infinite_abs {x : \u211d*} : infinite_pos (abs x) \u2194 infinite (abs x) :=\ninfinite_pos_iff_infinite_of_nonneg (abs_nonneg _)\n\nlemma infinite_iff_infinite_pos_abs {x : \u211d*} : infinite x \u2194 infinite_pos (abs x) :=\n\u27e8 \u03bb hi d, or.cases_on hi\n   (\u03bb hip, by rw [abs_of_pos (hip 0)]; exact hip d)\n   (\u03bb hin, by rw [abs_of_neg (hin 0)]; exact lt_neg.mp (hin (-d))),\n  \u03bb 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) } } \u27e9\n\nlemma infinite_iff_infinite_abs {x : \u211d*} : infinite x \u2194 infinite (abs x) :=\nby rw [\u2190infinite_pos_iff_infinite_of_nonneg (abs_nonneg _), infinite_iff_infinite_pos_abs]\n\nlemma infinite_iff_abs_lt_abs {x : \u211d*} : infinite x \u2194 \u2200 r : \u211d, (abs r : \u211d*) < abs x :=\n\u27e8 \u03bb hI r, (coe_abs r) \u25b8 infinite_iff_infinite_pos_abs.mp hI (abs r),\n  \u03bb hR, or.cases_on (max_choice x (-x))\n  (\u03bb h, or.inl $ \u03bb r, lt_of_le_of_lt (le_abs_self _) (h \u25b8 (hR r)))\n  (\u03bb h, or.inr $ \u03bb r, neg_lt_neg_iff.mp $ lt_of_le_of_lt (neg_le_abs_self _) (h \u25b8 (hR r)))\u27e9\n\nlemma infinite_pos_add_not_infinite_neg {x y : \u211d*} :\n  infinite_pos x \u2192 \u00ac infinite_neg y \u2192 infinite_pos (x + y) :=\nbegin\n  intros hip hnin r,\n  cases not_forall.mp hnin with r\u2082 hr\u2082,\n  convert add_lt_add_of_lt_of_le (hip (r + -r\u2082)) (not_lt.mp hr\u2082) using 1,\n  simp\nend\n\nlemma not_infinite_neg_add_infinite_pos {x y : \u211d*} :\n  \u00ac infinite_neg x \u2192 infinite_pos y \u2192 infinite_pos (x + y) :=\n\u03bb 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 : \u211d*} :\n  infinite_neg x \u2192 \u00ac infinite_pos y \u2192 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 : \u211d*} :\n  \u00ac infinite_pos x \u2192 infinite_neg y \u2192 infinite_neg (x + y) :=\n\u03bb hx hy, by rw [add_comm]; exact infinite_neg_add_not_infinite_pos hy hx\n\nlemma infinite_pos_add_infinite_pos {x y : \u211d*} :\n  infinite_pos x \u2192 infinite_pos y \u2192 infinite_pos (x + y) :=\n\u03bb 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 : \u211d*} :\n  infinite_neg x \u2192 infinite_neg y \u2192 infinite_neg (x + y) :=\n\u03bb 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 : \u211d*} :\n  infinite_pos x \u2192 \u00ac infinite y \u2192 infinite_pos (x + y) :=\n\u03bb hx hy, infinite_pos_add_not_infinite_neg hx (not_or_distrib.mp hy).2\n\nlemma infinite_neg_add_not_infinite {x y : \u211d*} :\n  infinite_neg x \u2192 \u00ac infinite y \u2192 infinite_neg (x + y) :=\n\u03bb hx hy, infinite_neg_add_not_infinite_pos hx (not_or_distrib.mp hy).1\n\ntheorem infinite_pos_of_tendsto_top {f : \u2115 \u2192 \u211d} (hf : tendsto f at_top at_top) :\n  infinite_pos (of_seq f) :=\n\u03bb r, have hf' : _ := tendsto_at_top_at_top.mp hf,\nExists.cases_on (hf' (r + 1)) $ \u03bb i hi,\n  have hi' : \u2200 (a : \u2115), f a < (r + 1) \u2192 a < i :=\n    \u03bb a, by rw [\u2190not_le, \u2190not_le]; exact not_imp_not.mpr (hi a),\n  have hS : {a : \u2115 | r < f a}\u1d9c \u2286 {a : \u2115 | a \u2264 i} :=\n    by simp only [set.compl_set_of, not_lt];\n    exact \u03bb 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 : \u2115 \u2192 \u211d} (hf : tendsto f at_top at_bot) :\n  infinite_neg (of_seq f) :=\n\u03bb r, have hf' : _ := tendsto_at_top_at_bot.mp hf,\nExists.cases_on (hf' (r - 1)) $ \u03bb i hi,\n  have hi' : \u2200 (a : \u2115), r - 1 < f a \u2192 a < i :=\n    \u03bb a, by rw [\u2190not_le, \u2190not_le]; exact not_imp_not.mpr (hi a),\n  have hS : {a : \u2115 | f a < r}\u1d9c \u2286 {a : \u2115 | a \u2264 i} :=\n    by simp only [set.compl_set_of, not_lt];\n    exact \u03bb 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 : \u211d*} : \u00ac infinite x \u2192 \u00ac infinite (-x) :=\nnot_imp_not.mpr infinite_iff_infinite_neg.mpr\n\nlemma not_infinite_add {x y : \u211d*} (hx : \u00ac infinite x) (hy : \u00ac infinite y) :\n  \u00ac 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\u03bb r hr s hs, not_infinite_of_exists_st $ \u27e8s + r, is_st_add hs hr\u27e9\n\ntheorem not_infinite_iff_exist_lt_gt {x : \u211d*} : \u00ac infinite x \u2194 \u2203 r s : \u211d, (r : \u211d*) < x \u2227 x < s :=\n\u27e8 \u03bb 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) $ \u03bb r hr s hs,\nby rw [not_lt] at hr hs; exact \u27e8r - 1, s + 1,\n  \u27e8 lt_of_lt_of_le (by rw sub_eq_add_neg; norm_num) hr,\n    lt_of_le_of_lt hs (by norm_num)\u27e9 \u27e9,\n\u03bb hrs, Exists.dcases_on hrs $ \u03bb r hr, Exists.dcases_on hr $ \u03bb s hs,\n  not_or_distrib.mpr \u27e8not_forall.mpr \u27e8s, lt_asymm (hs.2)\u27e9, not_forall.mpr \u27e8r, lt_asymm (hs.1) \u27e9\u27e9\u27e9\n\ntheorem not_infinite_real (r : \u211d) : \u00ac infinite r := by rw not_infinite_iff_exist_lt_gt; exact\n\u27e8 r - 1, r + 1, coe_lt_coe.2 $ sub_one_lt r, coe_lt_coe.2 $ lt_add_one r\u27e9\n\ntheorem not_real_of_infinite {x : \u211d*} : infinite x \u2192 \u2200 r : \u211d, x \u2260 r :=\n\u03bb 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 : \u211d*} {r s : \u211d} (hxr : is_st x r) (hys : is_st y s) (hs : s \u2260 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 \u27e8r, hxr\u27e9,\nExists.cases_on h $ \u03bb u h', Exists.cases_on h' $ \u03bb t \u27e8hu, ht\u27e9,\nis_st_iff_abs_sub_lt_delta.mpr $ \u03bb 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  ... \u2264 abs (x * (y - s)) + abs ((x - r) * s) : abs_add _ _\n  ... \u2264 abs x * abs (y - s) + abs (x - r) * abs s : by simp only [abs_mul]\n  ... \u2264 abs x * ((d / t) / 2 : \u211d) + ((d / abs s) / 2 : \u211d) * 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 : \u211d*) : by\n      { push_cast [-filter.germ.const_div], -- TODO: Why wasn't `hyperreal.coe_div` used?\n        have : (abs s : \u211d*) \u2260 0, by simpa,\n        have : (2 : \u211d*) \u2260 0 := two_ne_zero,\n        field_simp [*, add_mul, mul_add, mul_assoc, mul_comm, mul_left_comm] }\n  ... < (d / 2 * 1 + d / 2 : \u211d*) :\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 : \u211d*) : by rw [mul_one, add_halves]\n\nlemma is_st_mul {x y : \u211d*} {r s : \u211d} (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 \u27e8r, hxr\u27e9,\nExists.cases_on h $ \u03bb u h', Exists.cases_on h' $ \u03bb t \u27e8hu, ht\u27e9,\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        \u2190div_mul_cancel (d : \u211d*) (ne_of_gt (lt_of_le_of_lt (abs_nonneg x) ht)),\n        \u2190coe_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 : \u211d*} (hx : \u00ac infinite x) (hy : \u00ac infinite y) :\n  \u00ac 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' $ \u03bb r hr s hs, not_infinite_of_exists_st $\n\u27e8s * r, is_st_mul hs hr\u27e9\n---\n\nlemma st_add {x y : \u211d*} (hx : \u00acinfinite x) (hy : \u00acinfinite 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 : \u211d*) : 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 : \u211d*} (hx : \u00acinfinite x) (hy : \u00acinfinite 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 : \u211d*} :\n  infinitesimal x \u2194 (\u2200 r : \u211d, 0 < r \u2192 -(r : \u211d*) < x \u2227 x < r) :=\n\u27e8 \u03bb hi r hr, by { convert (hi r hr); simp },\n  \u03bb hi d hd, by { convert (hi d hd); simp } \u27e9\n\ntheorem lt_of_pos_of_infinitesimal {x : \u211d*} : infinitesimal x \u2192 \u2200 r : \u211d, 0 < r \u2192 x < r :=\n\u03bb hi r hr, ((infinitesimal_def.mp hi) r hr).2\n\ntheorem lt_neg_of_pos_of_infinitesimal {x : \u211d*} : infinitesimal x \u2192 \u2200 r : \u211d, 0 < r \u2192 -\u2191r < x :=\n\u03bb hi r hr, ((infinitesimal_def.mp hi) r hr).1\n\ntheorem gt_of_neg_of_infinitesimal {x : \u211d*} : infinitesimal x \u2192 \u2200 r : \u211d, r < 0 \u2192 \u2191r < x :=\n\u03bb hi r hr, by convert ((infinitesimal_def.mp hi) (-r) (neg_pos.mpr hr)).1;\nexact (neg_neg \u2191r).symm\n\ntheorem abs_lt_real_iff_infinitesimal {x : \u211d*} :\n  infinitesimal x \u2194 \u2200 r : \u211d, r \u2260 0 \u2192 abs x < abs r :=\n\u27e8 \u03bb hi r hr, abs_lt.mpr (by rw \u2190coe_abs;\n  exact infinitesimal_def.mp hi (abs r) (abs_pos.2 hr)),\n  \u03bb hR, infinitesimal_def.mpr $ \u03bb r hr, abs_lt.mp $\n  (abs_of_pos $ coe_pos.2 hr) \u25b8 hR r $ ne_of_gt hr \u27e9\n\nlemma infinitesimal_zero : infinitesimal 0 := is_st_refl_real 0\n\nlemma zero_of_infinitesimal_real {r : \u211d} : infinitesimal r \u2192 r = 0 := eq_of_is_st_real\n\nlemma zero_iff_infinitesimal_real {r : \u211d} : infinitesimal r \u2194 r = 0 :=\n\u27e8zero_of_infinitesimal_real, \u03bb hr, by rw hr; exact infinitesimal_zero\u27e9\n\nlemma infinitesimal_add {x y : \u211d*} (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 : \u211d*} (hx : infinitesimal x) : infinitesimal (-x) :=\nby simpa only [neg_zero] using is_st_neg hx\n\nlemma infinitesimal_neg_iff {x : \u211d*} : infinitesimal x \u2194 infinitesimal (-x) :=\n\u27e8infinitesimal_neg, \u03bb h, (neg_neg x) \u25b8 @infinitesimal_neg (-x) h\u27e9\n\nlemma infinitesimal_mul {x y : \u211d*} (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 : \u2115 \u2192 \u211d} :\n  tendsto f at_top (\ud835\udcdd 0) \u2192 infinitesimal (of_seq f) :=\n\u03bb hf d hd, by rw [sub_eq_add_neg, \u2190coe_neg, \u2190coe_add, \u2190coe_add, zero_add, zero_add];\nexact \u27e8neg_lt_of_tendsto_zero_of_pos hf hd, lt_of_tendsto_zero_of_pos hf hd\u27e9\n\ntheorem infinitesimal_epsilon : infinitesimal \u03b5 :=\ninfinitesimal_of_tendsto_zero tendsto_inverse_at_top_nhds_0_nat\n\nlemma not_real_of_infinitesimal_ne_zero (x : \u211d*) :\n  infinitesimal x \u2192 x \u2260 0 \u2192 \u2200 r : \u211d, x \u2260 r :=\n\u03bb hi hx r hr, hx $ hr.trans $ coe_eq_zero.2 $\nis_st_unique (hr.symm \u25b8 is_st_refl_real r : is_st x r) hi\n\ntheorem infinitesimal_sub_is_st {x : \u211d*} {r : \u211d} (hxr : is_st x r) : infinitesimal (x - r) :=\nshow is_st (x - r) 0,\nby { rw [sub_eq_add_neg, \u2190 add_neg_self r], exact is_st_add hxr (is_st_refl_real (-r)) }\n\ntheorem infinitesimal_sub_st {x : \u211d*} (hx : \u00acinfinite x) : infinitesimal (x - st x) :=\ninfinitesimal_sub_is_st $ is_st_st' hx\n\nlemma infinite_pos_iff_infinitesimal_inv_pos {x : \u211d*} :\n  infinite_pos x \u2194 (infinitesimal x\u207b\u00b9 \u2227 0 < x\u207b\u00b9) :=\n\u27e8 \u03bb hip, \u27e8 infinitesimal_def.mpr $ \u03bb r hr,\n  \u27e8 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\u207b\u00b9) \u27e9,\n  inv_pos.2 $ hip 0 \u27e9,\n  \u03bb \u27e8hi, hp\u27e9 r, @classical.by_cases (r = 0) (\u2191r < x) (\u03bb h, eq.substr h (inv_pos.mp hp)) $\n  \u03bb 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)\u207b\u00b9) (inv_pos.2 (abs_pos.2 h))).2) \u27e9\n\nlemma infinite_neg_iff_infinitesimal_inv_neg {x : \u211d*} :\n  infinite_neg x \u2194 (infinitesimal x\u207b\u00b9 \u2227 x\u207b\u00b9 < 0) :=\n\u27e8 \u03bb hin, have hin' : _ := infinite_pos_iff_infinitesimal_inv_pos.mp\n  (infinite_pos_neg_of_infinite_neg hin),\n  by rwa [infinitesimal_neg_iff, \u2190neg_pos, neg_inv],\n  \u03bb hin, by rwa [\u2190neg_pos, infinitesimal_neg_iff, neg_inv,\n    \u2190infinite_pos_iff_infinitesimal_inv_pos, \u2190infinite_neg_iff_infinite_pos_neg] at hin \u27e9\n\ntheorem infinitesimal_inv_of_infinite {x : \u211d*} : infinite x \u2192 infinitesimal x\u207b\u00b9 :=\n\u03bb hi, or.cases_on hi\n (\u03bb hip, (infinite_pos_iff_infinitesimal_inv_pos.mp hip).1)\n (\u03bb hin, (infinite_neg_iff_infinitesimal_inv_neg.mp hin).1)\n\ntheorem infinite_of_infinitesimal_inv {x : \u211d*} (h0 : x \u2260 0) (hi : infinitesimal x\u207b\u00b9 ) :\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 \u27e8hi, inv_lt_zero.mpr hn\u27e9) },\n  { exact or.inl (infinite_pos_iff_infinitesimal_inv_pos.mpr \u27e8hi, inv_pos.mpr hp\u27e9) }\nend\n\ntheorem infinite_iff_infinitesimal_inv {x : \u211d*} (h0 : x \u2260 0) : infinite x \u2194 infinitesimal x\u207b\u00b9 :=\n\u27e8 infinitesimal_inv_of_infinite, infinite_of_infinitesimal_inv h0 \u27e9\n\nlemma infinitesimal_pos_iff_infinite_pos_inv {x : \u211d*} :\n  infinite_pos x\u207b\u00b9 \u2194 (infinitesimal x \u2227 0 < x) :=\nby convert infinite_pos_iff_infinitesimal_inv_pos; simp only [inv_inv']\n\nlemma infinitesimal_neg_iff_infinite_neg_inv {x : \u211d*} :\n  infinite_neg x\u207b\u00b9 \u2194 (infinitesimal x \u2227 x < 0) :=\nby convert infinite_neg_iff_infinitesimal_inv_neg; simp only [inv_inv']\n\ntheorem infinitesimal_iff_infinite_inv {x : \u211d*} (h : x \u2260 0) : infinitesimal x \u2194 infinite x\u207b\u00b9 :=\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 : \u2115 \u2192 \u211d} {r : \u211d} (hf : tendsto f at_top (\ud835\udcdd r)) :\n  is_st (of_seq f) r :=\nhave hg : tendsto (\u03bb n, f n - r) at_top (\ud835\udcdd 0) :=\n  (sub_self r) \u25b8 (hf.sub tendsto_const_nhds),\nby rw [\u2190(zero_add r), \u2190(sub_add_cancel f (\u03bb n, r))];\nexact is_st_add (infinitesimal_of_tendsto_zero hg) (is_st_refl_real r)\n\nlemma is_st_inv {x : \u211d*} {r : \u211d} (hi : \u00ac infinitesimal x) : is_st x r \u2192 is_st x\u207b\u00b9 r\u207b\u00b9 :=\n\u03bb hxr, have h : x \u2260 0 := (\u03bb h, hi (h.symm \u25b8 infinitesimal_zero)),\nhave H : _ := exists_st_of_not_infinite $ not_imp_not.mpr (infinitesimal_iff_infinite_inv h).mpr hi,\nExists.cases_on H $ \u03bb s hs,\nhave H' : is_st 1 (r * s) := mul_inv_cancel h \u25b8 is_st_mul hxr hs,\nhave H'' : s = r\u207b\u00b9 := one_div r \u25b8 eq_one_div_of_mul_eq_one (eq_of_is_st_real H').symm,\nH'' \u25b8 hs\n\nlemma st_inv (x : \u211d*) : st x\u207b\u00b9 = (st x)\u207b\u00b9 :=\nbegin\n  by_cases h0 : x = 0,\n  rw [h0, inv_zero, \u2190coe_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 \u03c9 :=\ninfinite_pos_iff_infinitesimal_inv_pos.mpr \u27e8infinitesimal_epsilon, epsilon_pos\u27e9\n\nlemma infinite_omega : infinite \u03c9 :=\n(infinite_iff_infinitesimal_inv omega_ne_zero).mpr infinitesimal_epsilon\n\nlemma infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos {x y : \u211d*} :\n  infinite_pos x \u2192 \u00ac infinitesimal y \u2192 0 < y \u2192 infinite_pos (x * y) :=\n\u03bb hx hy\u2081 hy\u2082 r, have hy\u2081' : _ := not_forall.mp (by rw infinitesimal_def at hy\u2081; exact hy\u2081),\nExists.dcases_on hy\u2081' $ \u03bb r\u2081 hy\u2081'',\nhave hyr : _ := by rw [not_imp, \u2190abs_lt, not_lt, abs_of_pos hy\u2082] at hy\u2081''; exact hy\u2081'',\nby rw [\u2190div_mul_cancel r (ne_of_gt hyr.1), coe_mul];\nexact mul_lt_mul (hx (r / r\u2081)) 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 : \u211d*} :\n  \u00ac infinitesimal x \u2192 0 < x \u2192 infinite_pos y \u2192 infinite_pos (x * y) :=\n\u03bb 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 : \u211d*} :\n  infinite_neg x \u2192 \u00ac infinitesimal y \u2192 y < 0 \u2192 infinite_pos (x * y) :=\nby rw [infinite_neg_iff_infinite_pos_neg, \u2190neg_pos, \u2190neg_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 : \u211d*} :\n  \u00ac infinitesimal x \u2192 x < 0 \u2192 infinite_neg y \u2192 infinite_pos (x * y) :=\n\u03bb 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 : \u211d*} :\n  infinite_pos x \u2192 \u00ac infinitesimal y \u2192 y < 0 \u2192 infinite_neg (x * y) :=\nby rw [infinite_neg_iff_infinite_pos_neg, \u2190neg_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 : \u211d*} :\n  \u00ac infinitesimal x \u2192 x < 0 \u2192 infinite_pos y \u2192 infinite_neg (x * y) :=\n\u03bb 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 : \u211d*} :\n  infinite_neg x \u2192 \u00ac infinitesimal y \u2192 0 < y \u2192 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 : \u211d*} :\n  \u00ac infinitesimal x \u2192 0 < x \u2192 infinite_neg y \u2192 infinite_neg (x * y) :=\n\u03bb 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 : \u211d*} :\n  infinite_pos x \u2192 infinite_pos y \u2192 infinite_pos (x * y) :=\n\u03bb 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 : \u211d*} :\n  infinite_neg x \u2192 infinite_neg y \u2192 infinite_pos (x * y) :=\n\u03bb 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 : \u211d*} :\n  infinite_pos x \u2192 infinite_neg y \u2192 infinite_neg (x * y) :=\n\u03bb 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 : \u211d*} :\n  infinite_neg x \u2192 infinite_pos y \u2192 infinite_neg (x * y) :=\n\u03bb 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 : \u211d*} :\n  infinite x \u2192 \u00ac infinitesimal y \u2192 infinite (x * y) :=\n\u03bb hx hy, have h0 : y < 0 \u2228 0 < y := lt_or_gt_of_ne (\u03bb H0, hy (eq.substr H0 (is_st_refl_real 0))),\nor.dcases_on hx\n  (or.dcases_on h0\n    (\u03bb H0 Hx, or.inr (infinite_neg_mul_of_infinite_pos_not_infinitesimal_neg Hx hy H0))\n    (\u03bb H0 Hx, or.inl (infinite_pos_mul_of_infinite_pos_not_infinitesimal_pos Hx hy H0)))\n  (or.dcases_on h0\n    (\u03bb H0 Hx, or.inl (infinite_pos_mul_of_infinite_neg_not_infinitesimal_neg Hx hy H0))\n    (\u03bb 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 : \u211d*} :\n  \u00ac infinitesimal x \u2192 infinite y \u2192 infinite (x * y) :=\n\u03bb hx hy, by rw [mul_comm]; exact infinite_mul_of_infinite_not_infinitesimal hy hx\n\nlemma infinite_mul_infinite {x y : \u211d*} : infinite x \u2192 infinite y \u2192 infinite (x * y) :=\n\u03bb 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b4 : Type x}\n\n/-- Multivariate polynomial, where `\u03c3` is the index set of the variables and\n  `\u03b1` is the coefficient ring -/\ndef mv_polynomial (\u03c3 : Type*) (\u03b1 : Type*) [comm_semiring \u03b1] := (\u03c3 \u2192\u2080 \u2115) \u2192\u2080 \u03b1\n\nnamespace mv_polynomial\nvariables {\u03c3 : Type*} {a a' a\u2081 a\u2082 : \u03b1} {e : \u2115} {n m : \u03c3} {s : \u03c3 \u2192\u2080 \u2115}\nvariables [decidable_eq \u03c3] [decidable_eq \u03b1]\n\nsection comm_semiring\nvariables [comm_semiring \u03b1] {p q : mv_polynomial \u03c3 \u03b1}\n\ninstance : decidable_eq (mv_polynomial \u03c3 \u03b1) := finsupp.decidable_eq\ninstance : has_zero (mv_polynomial \u03c3 \u03b1) := finsupp.has_zero\ninstance : has_one (mv_polynomial \u03c3 \u03b1) := finsupp.has_one\ninstance : has_add (mv_polynomial \u03c3 \u03b1) := finsupp.has_add\ninstance : has_mul (mv_polynomial \u03c3 \u03b1) := finsupp.has_mul\ninstance : comm_semiring (mv_polynomial \u03c3 \u03b1) := finsupp.to_comm_semiring\n\n/-- `monomial s a` is the monomial `a * X^s` -/\ndef monomial (s : \u03c3 \u2192\u2080 \u2115) (a : \u03b1) : mv_polynomial \u03c3 \u03b1 := single s a\n\n/-- `C a` is the constant polynomial with value `a` -/\ndef C (a : \u03b1) : mv_polynomial \u03c3 \u03b1 := monomial 0 a\n\n/-- `X n` is the polynomial with value X_n -/\ndef X (n : \u03c3) : mv_polynomial \u03c3 \u03b1 := monomial (single n 1) 1\n\n@[simp] lemma C_0 : C 0 = (0 : mv_polynomial \u03c3 \u03b1) := by simp [C, monomial]; refl\n\n@[simp] lemma C_1 : C 1 = (1 : mv_polynomial \u03c3 \u03b1) := 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 \u03c3 \u03b1) = C a + C a' := single_add\n\n@[simp] lemma C_mul : (C (a * a') : mv_polynomial \u03c3 \u03b1) = C a * C a' := C_mul_monomial.symm\n\ninstance : is_semiring_hom (C : \u03b1 \u2192 mv_polynomial \u03c3 \u03b1) :=\n{ map_zero := C_0,\n  map_one := C_1,\n  map_add := \u03bb a a', C_add,\n  map_mul := \u03bb a a', C_mul }\n\nlemma X_pow_eq_single : X n ^ e = monomial (single n e) (1 : \u03b1) :=\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 $ \u03bbn e, X n ^ e : mv_polynomial \u03c3 \u03b1) :=\nbegin\n  apply @finsupp.induction \u03c3 \u2115 _ _ _ _ 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 \u03c3 \u03b1 \u2192 Prop} (p : mv_polynomial \u03c3 \u03b1)\n  (h_C : \u2200a, M (C a)) (h_add : \u2200p q, M p \u2192 M q \u2192 M (p + q)) (h_X : \u2200p n, M p \u2192 M (p * X n)) :\n  M p :=\nhave \u2200s a, M (monomial s a),\nbegin\n  assume s a,\n  apply @finsupp.induction \u03c3 \u2115 _ _ _ _ s,\n  { show M (monomial 0 a), from h_C a, },\n  { assume n e p hpn he ih,\n    have : \u2200e:\u2115, 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 \u03b3]\n  (f g : mv_polynomial \u03c3 \u03b1 \u2192 \u03b3) (hf : is_semiring_hom f) (hg : is_semiring_hom g)\n  (hC : \u2200a:\u03b1, f (C a) = g (C a)) (hX : \u2200n:\u03c3, f (X n) = g (X n)) (p : mv_polynomial \u03c3 \u03b1) :\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 \u03c3 \u03b1 \u2192 mv_polynomial \u03c3 \u03b1) (hf : is_semiring_hom f)\n  (hC : \u2200a:\u03b1, f (C a) = (C a)) (hX : \u2200n:\u03c3, f (X n) = (X n)) (p : mv_polynomial \u03c3 \u03b1) :\n  f p = p :=\nhom_eq_hom f id hf is_semiring_hom.id hC hX p\n\nsection eval\u2082\nvariables [comm_semiring \u03b2]\nvariables (f : \u03b1 \u2192 \u03b2) (g : \u03c3 \u2192 \u03b2)\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\u2082 (p : mv_polynomial \u03c3 \u03b1) : \u03b2 :=\np.sum (\u03bbs a, f a * s.prod (\u03bbn e, g n ^ e))\n\n@[simp] lemma eval\u2082_zero : (0 : mv_polynomial \u03c3 \u03b1).eval\u2082 f g = 0 :=\nfinsupp.sum_zero_index\n\nvariables [is_semiring_hom f]\n\n@[simp] lemma eval\u2082_add : (p + q).eval\u2082 f g = p.eval\u2082 f g + q.eval\u2082 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\u2082_monomial : (monomial s a).eval\u2082 f g = f a * s.prod (\u03bbn e, g n ^ e) :=\nfinsupp.sum_single_index (by simp [is_semiring_hom.map_zero f])\n\n@[simp] lemma eval\u2082_C (a) : (C a).eval\u2082 f g = f a :=\nby simp [eval\u2082_monomial, C, prod_zero_index]\n\n@[simp] lemma eval\u2082_one : (1 : mv_polynomial \u03c3 \u03b1).eval\u2082 f g = 1 :=\n(eval\u2082_C _ _ _).trans (is_semiring_hom.map_one f)\n\n@[simp] lemma eval\u2082_X (n) : (X n).eval\u2082 f g = g n :=\nby simp [eval\u2082_monomial,\n  is_semiring_hom.map_one f, X, prod_single_index, pow_one]\n\nlemma eval\u2082_mul_monomial :\n  \u2200{s a}, (p * monomial s a).eval\u2082 f g = p.eval\u2082 f g * f a * s.prod (\u03bbn e, g n ^ e) :=\nbegin\n  apply mv_polynomial.induction_on p,\n  { assume a' s a,\n    simp [C_mul_monomial, eval\u2082_monomial, is_semiring_hom.map_mul f] },\n  { assume p q ih_p ih_q, simp [add_mul, eval\u2082_add, ih_p, ih_q] },\n  { assume p n ih s a,\n    from calc (p * X n * monomial s a).eval\u2082 f g = (p * monomial (single n 1 + s) a).eval\u2082 f g :\n        by simp [monomial_single_add, -add_comm, pow_one, mul_assoc]\n      ... = (p * monomial (single n 1) 1).eval\u2082 f g * f a * s.prod (\u03bbn 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\u2082_mul : \u2200{p}, (p * q).eval\u2082 f g = p.eval\u2082 f g * q.eval\u2082 f g :=\nbegin\n  apply mv_polynomial.induction_on q,\n  { simp [C, eval\u2082_monomial, eval\u2082_mul_monomial, prod_zero_index] },\n  { simp [mul_add, eval\u2082_add] {contextual := tt} },\n  { simp [X, eval\u2082_monomial, eval\u2082_mul_monomial, (mul_assoc _ _ _).symm] { contextual := tt} }\nend\n\nlemma eval\u2082_pow {p:mv_polynomial \u03c3 \u03b1} : \u2200{n:\u2115}, (p ^ n).eval\u2082 f g = (p.eval\u2082 f g)^n\n| 0       := eval\u2082_one _ _\n| (n + 1) := by rw [pow_add, pow_one, pow_add, pow_one, eval\u2082_mul, eval\u2082_pow]\n\ninstance eval\u2082.is_semiring_hom : is_semiring_hom (eval\u2082 f g) :=\n{ map_zero := eval\u2082_zero _ _,\n  map_one := eval\u2082_one _ _,\n  map_add := \u03bb p q, eval\u2082_add _ _,\n  map_mul := \u03bb p q, eval\u2082_mul _ _ }\n\nlemma eval\u2082_comp_left {\u03b3} [comm_semiring \u03b3]\n  (k : \u03b2 \u2192 \u03b3) [is_semiring_hom k]\n  (f : \u03b1 \u2192 \u03b2) [is_semiring_hom f] (g : \u03c3 \u2192 \u03b2)\n  (p) : k (eval\u2082 f g p) = eval\u2082 (k \u2218 f) (k \u2218 g) p :=\nby apply mv_polynomial.induction_on p; simp [\n  eval\u2082_add, is_semiring_hom.map_add k,\n  eval\u2082_mul, is_semiring_hom.map_mul k] {contextual := tt}\n\nlemma eval\u2082_eta (p : mv_polynomial \u03c3 \u03b1) : eval\u2082 C X p = p :=\nby apply mv_polynomial.induction_on p;\n   simp [eval\u2082_add, eval\u2082_mul] {contextual := tt}\n\nend eval\u2082\n\nsection eval\nvariables {f : \u03c3 \u2192 \u03b1}\n\n/-- Evaluate a polynomial `p` given a valuation `f` of all the variables -/\ndef eval (f : \u03c3 \u2192 \u03b1) : mv_polynomial \u03c3 \u03b1 \u2192 \u03b1 := eval\u2082 id f\n\n@[simp] lemma eval_zero : (0 : mv_polynomial \u03c3 \u03b1).eval f = 0 := eval\u2082_zero _ _\n\n@[simp] lemma eval_add : (p + q).eval f = p.eval f + q.eval f := eval\u2082_add _ _\n\nlemma eval_monomial : (monomial s a).eval f = a * s.prod (\u03bbn e, f n ^ e) :=\neval\u2082_monomial _ _\n\n@[simp] lemma eval_C : \u2200 a, (C a).eval f = a := eval\u2082_C _ _\n\n@[simp] lemma eval_X : \u2200 n, (X n).eval f = f n := eval\u2082_X _ _\n\n@[simp] lemma eval_mul : (p * q).eval f = p.eval f * q.eval f := eval\u2082_mul _ _\n\ninstance eval.is_semiring_hom : is_semiring_hom (eval f) :=\neval\u2082.is_semiring_hom _ _\n\ntheorem eval_assoc {\u03c4} [decidable_eq \u03c4]\n  (f : \u03c3 \u2192 mv_polynomial \u03c4 \u03b1) (g : \u03c4 \u2192 \u03b1)\n  (p : mv_polynomial \u03c3 \u03b1) :\n  p.eval (eval g \u2218 f) = (eval\u2082 C f p).eval g :=\nbegin\n  rw eval\u2082_comp_left (eval g),\n  unfold eval, congr; funext a; simp\nend\n\nend eval\n\nsection map\nvariables [comm_semiring \u03b2] [decidable_eq \u03b2]\nvariables (f : \u03b1 \u2192 \u03b2) [is_semiring_hom f]\n\n/-- `map f p` maps a polynomial `p` across a ring hom `f` -/\ndef map : mv_polynomial \u03c3 \u03b1 \u2192 mv_polynomial \u03c3 \u03b2 := eval\u2082 (C \u2218 f) X\n\n@[simp] theorem map_monomial (s : \u03c3 \u2192\u2080 \u2115) (a : \u03b1) : map f (monomial s a) = monomial s (f a) :=\n(eval\u2082_monomial _ _).trans monomial_eq.symm\n\n@[simp] theorem map_C : \u2200 (a : \u03b1), map f (C a : mv_polynomial \u03c3 \u03b1) = C (f a) := map_monomial _ _\n\n@[simp] theorem map_X : \u2200 (n : \u03c3), map f (X n : mv_polynomial \u03c3 \u03b1) = X n := eval\u2082_X _ _\n\n@[simp] theorem map_one : map f (1 : mv_polynomial \u03c3 \u03b1) = 1 := eval\u2082_one _ _\n\n@[simp] theorem map_add (p q : mv_polynomial \u03c3 \u03b1) :\n  map f (p + q) = map f p + map f q := eval\u2082_add _ _\n\n@[simp] theorem map_mul (p q : mv_polynomial \u03c3 \u03b1) :\n  map f (p * q) = map f p * map f q := eval\u2082_mul _ _\n\ninstance map.is_semiring_hom :\n  is_semiring_hom (map f : mv_polynomial \u03c3 \u03b1 \u2192 mv_polynomial \u03c3 \u03b2) :=\neval\u2082.is_semiring_hom _ _\n\ntheorem map_id : \u2200 (p : mv_polynomial \u03c3 \u03b1), map id p = p := eval\u2082_eta\n\ntheorem map_map [comm_semiring \u03b3] [decidable_eq \u03b3]\n  (g : \u03b2 \u2192 \u03b3) [is_semiring_hom g]\n  (p : mv_polynomial \u03c3 \u03b1) :\n  map g (map f p) = map (g \u2218 f) p :=\n(eval\u2082_comp_left (map g) (C \u2218 f) X p).trans $\nby congr; funext a; simp\n\ntheorem eval\u2082_eq_eval_map (g : \u03c3 \u2192 \u03b2) (p : mv_polynomial \u03c3 \u03b1) :\n  p.eval\u2082 f g = (map f p).eval g :=\nbegin\n  unfold map eval,\n  rw eval\u2082_comp_left (eval\u2082 id g),\n  congr; funext a; simp\nend\n\nend map\n\nsection degrees\n\nsection comm_semiring\n\ndef degrees (p : mv_polynomial \u03c3 \u03b1) : multiset \u03c3 :=\np.support.sup (\u03bbs:\u03c3 \u2192\u2080 \u2115, s.to_multiset)\n\nlemma degrees_monomial (s : \u03c3 \u2192\u2080 \u2115) (a : \u03b1) : degrees (monomial s a) \u2264 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 : \u03c3 \u2192\u2080 \u2115) (a : \u03b1) (ha : a \u2260 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 : \u03b1) : degrees (C a : mv_polynomial \u03c3 \u03b1) = 0 :=\nmultiset.le_zero.1 $ degrees_monomial _ _\n\nlemma degrees_X (n : \u03c3) : degrees (X n : mv_polynomial \u03c3 \u03b1) \u2264 {n} :=\nle_trans (degrees_monomial _ _) $ le_of_eq $ to_multiset_single _ _\n\nlemma degrees_zero : degrees (0 : mv_polynomial \u03c3 \u03b1) = 0 := degrees_C 0\n\nlemma degrees_one : degrees (1 : mv_polynomial \u03c3 \u03b1) = 0 := degrees_C 1\n\nlemma degrees_add (p q : mv_polynomial \u03c3 \u03b1) : (p + q).degrees \u2264 p.degrees \u2294 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 {\u03b9 : Type*} [decidable_eq \u03b9] (s : finset \u03b9) (f : \u03b9 \u2192 mv_polynomial \u03c3 \u03b1) :\n  (s.sum f).degrees \u2264 s.sup (\u03bbi, (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 \u03c3 \u03b1) : (p * q).degrees \u2264 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 \u27e8a\u2081, h\u2081, a\u2082, h\u2082, rfl\u27e9,\n  rw [finsupp.to_multiset_add],\n  exact add_le_add (finset.le_sup h\u2081) (finset.le_sup h\u2082)\nend\n\nlemma degrees_prod {\u03b9 : Type*} [decidable_eq \u03b9] (s : finset \u03b9) (f : \u03b9 \u2192 mv_polynomial \u03c3 \u03b1) :\n  (s.prod f).degrees \u2264 s.sum (\u03bbi, (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 \u03c3 \u03b1) :\n  \u2200(n : \u2115), (p^n).degrees \u2264 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 \u03c3 \u03b1) : finset \u03c3 := p.degrees.to_finset\n\n@[simp] lemma vars_0 : (0 : mv_polynomial \u03c3 \u03b1).vars = \u2205 :=\nby rw [vars, degrees_zero, multiset.to_finset_zero]\n\n@[simp] lemma vars_monomial (h : a \u2260 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 \u03c3 \u03b1).vars = \u2205 :=\nby rw [vars, degrees_C, multiset.to_finset_zero]\n\n@[simp] lemma vars_X (h : 0 \u2260 (1 : \u03b1)) : (X n : mv_polynomial \u03c3 \u03b1).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 : \u03c3) (p : mv_polynomial \u03c3 \u03b1) : \u2115 := 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 \u03c3 \u03b1) : \u2115 := p.support.sup (\u03bbs, s.sum $ \u03bbn e, e)\n\nlemma total_degree_eq (p : mv_polynomial \u03c3 \u03b1) :\n  p.total_degree = p.support.sup (\u03bbm, 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 \u03c3 \u03b1) :\n  p.total_degree \u2264 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 : \u03b1) : (C a : mv_polynomial \u03c3 \u03b1).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 \u03c3 \u03b1).total_degree = 0 :=\nby rw [\u2190 C_0]; exact total_degree_C (0 : \u03b1)\n\nlemma total_degree_one : (1 : mv_polynomial \u03c3 \u03b1).total_degree = 0 :=\ntotal_degree_C (1 : \u03b1)\n\nlemma total_degree_add (a b : mv_polynomial \u03c3 \u03b1) :\n  (a + b).total_degree \u2264 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 \u03c3 \u03b1) :\n  (a * b).total_degree \u2264 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 \u27e8a\u2081, h\u2081, a\u2082, h\u2082, rfl\u27e9,\n    rw [finsupp.sum_add_index],\n    { exact add_le_add (finset.le_sup h\u2081) (finset.le_sup h\u2082) },\n    { assume a, refl },\n    { assume a b\u2081 b\u2082, refl }\n  end\n\nlemma total_degree_list_prod :\n  \u2200(s : list (mv_polynomial \u03c3 \u03b1)), s.prod.total_degree \u2264 (s.map mv_polynomial.total_degree).sum\n| []        := by rw [@list.prod_nil (mv_polynomial \u03c3 \u03b1) _, total_degree_one]; refl\n| (p :: ps) :=\n  begin\n    rw [@list.prod_cons (mv_polynomial \u03c3 \u03b1) _, 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 \u03c3 \u03b1)) :\n  s.prod.total_degree \u2264 (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 {\u03b9 : Type*}\n  (s : finset \u03b9) (f : \u03b9 \u2192 mv_polynomial \u03c3 \u03b1) :\n  (s.prod f).total_degree \u2264 s.sum (\u03bbi, (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 \u03b1]\nvariables {p q : mv_polynomial \u03c3 \u03b1}\n\ninstance : ring (mv_polynomial \u03c3 \u03b1) := finsupp.to_ring\ninstance : comm_ring (mv_polynomial \u03c3 \u03b1) := finsupp.to_comm_ring\ninstance : has_scalar \u03b1 (mv_polynomial \u03c3 \u03b1) := finsupp.to_has_scalar\ninstance : module \u03b1 (mv_polynomial \u03c3 \u03b1) := finsupp.to_module _ \u03b1\n\ninstance C.is_ring_hom : is_ring_hom (C : \u03b1 \u2192 mv_polynomial \u03c3 \u03b1) :=\nby apply is_ring_hom.of_semiring\n\nvariables (\u03c3 a a')\nlemma C_sub : (C (a - a') : mv_polynomial \u03c3 \u03b1) = C a - C a' := is_ring_hom.map_sub _\n\n@[simp] lemma C_neg : (C (-a) : mv_polynomial \u03c3 \u03b1) = -C a := is_ring_hom.map_neg _\n\nvariables {\u03c3} (p)\ntheorem C_mul' : mv_polynomial.C a * p = a \u2022 p :=\nbegin\n  apply finsupp.induction p,\n  { exact (mul_zero $ mv_polynomial.C a).trans (@smul_zero \u03b1 (mv_polynomial \u03c3 \u03b1) _ _ _ a).symm },\n  intros p b f haf hb0 ih,\n  rw [mul_add, ih, @smul_add \u03b1 (mv_polynomial \u03c3 \u03b1) _ _ _ 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 \u03c3 \u03b1) (a : \u03b1) : a \u2022 p = C a * p :=\nbegin\n  rw [\u2190 finsupp.sum_single p, @finsupp.smul_sum (\u03c3 \u2192\u2080 \u2115) \u03b1 \u03b1, 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 \u03c3 \u03b1) (s) : (s \u2022 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 \u03b1] (p : mv_polynomial \u03c3 \u03b1) : (- p).degrees = p.degrees :=\nby rw [degrees, finsupp.support_neg]; refl\n\nlemma degrees_sub [comm_ring \u03b1] (p q : mv_polynomial \u03c3 \u03b1) :\n  (p - q).degrees \u2264 p.degrees \u2294 q.degrees :=\nle_trans (degrees_add p (-q)) $ by rw [degrees_neg]\n\nend degrees\n\nsection eval\u2082\n\nvariables [comm_ring \u03b2]\nvariables (f : \u03b1 \u2192 \u03b2) [is_ring_hom f] (g : \u03c3 \u2192 \u03b2)\n\ninstance eval\u2082.is_ring_hom : is_ring_hom (eval\u2082 f g) :=\nby apply is_ring_hom.of_semiring\n\nlemma eval\u2082_sub : (p - q).eval\u2082 f g = p.eval\u2082 f g - q.eval\u2082 f g := is_ring_hom.map_sub _\n\n@[simp] lemma eval\u2082_neg : (-p).eval\u2082 f g = -(p.eval\u2082 f g) := is_ring_hom.map_neg _\n\nend eval\u2082\n\nsection eval\n\nvariables (f : \u03c3 \u2192 \u03b1)\n\ninstance eval.is_ring_hom : is_ring_hom (eval f) := eval\u2082.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 \u03b2] [comm_ring \u03b2]\nvariables (f : \u03b1 \u2192 \u03b2) [is_ring_hom f]\n\ninstance map.is_ring_hom : is_ring_hom (map f : mv_polynomial \u03c3 \u03b1 \u2192 mv_polynomial \u03c3 \u03b2) :=\neval\u2082.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 {\u03b1} [comm_semiring \u03b1] [decidable_eq \u03b1] [decidable_eq \u03b2] [decidable_eq \u03b3] [decidable_eq \u03b4]\n\ndef rename (f : \u03b2 \u2192 \u03b3) : mv_polynomial \u03b2 \u03b1 \u2192 mv_polynomial \u03b3 \u03b1 :=\neval\u2082 C (X \u2218 f)\n\ninstance rename.is_semiring_hom (f : \u03b2 \u2192 \u03b3) :\n  is_semiring_hom (rename f : mv_polynomial \u03b2 \u03b1 \u2192 mv_polynomial \u03b3 \u03b1) :=\nby unfold rename; apply_instance\n\n@[simp] lemma rename_C (f : \u03b2 \u2192 \u03b3) (a : \u03b1) : rename f (C a) = C a :=\neval\u2082_C _ _ _\n\n@[simp] lemma rename_X (f : \u03b2 \u2192 \u03b3) (b : \u03b2) : rename f (X b : mv_polynomial \u03b2 \u03b1) = X (f b) :=\neval\u2082_X _ _ _\n\nlemma rename_rename (f : \u03b2 \u2192 \u03b3) (g : \u03b3 \u2192 \u03b4) (p : mv_polynomial \u03b2 \u03b1) :\n  rename g (rename f p) = rename (g \u2218 f) p :=\nshow rename g (eval\u2082 C (X \u2218 f) p) = _,\n  by simp only [eval\u2082_comp_left (rename g) C (X \u2218 f) p, (\u2218), rename_C, rename_X]; refl\n\nlemma rename_id (p : mv_polynomial \u03b2 \u03b1) : rename id p = p :=\neval\u2082_eta p\n\nlemma rename_monomial (f : \u03b2 \u2192 \u03b3) (p : \u03b2 \u2192\u2080 \u2115) (a : \u03b1) :\n  rename f (monomial p a) = monomial (p.map_domain f) a :=\nbegin\n  rw [rename, eval\u2082_monomial, monomial_eq, finsupp.prod_map_domain_index],\n  { exact assume n, pow_zero _ },\n  { exact assume n i\u2081 i\u2082, pow_add _ _ _ }\nend\n\nlemma rename_eq (f : \u03b2 \u2192 \u03b3) (p : mv_polynomial \u03b2 \u03b1) :\n  rename f p = finsupp.map_domain (finsupp.map_domain f) p :=\nbegin\n  simp only [rename, eval\u2082, finsupp.map_domain],\n  congr, ext s a : 2,\n  rw [\u2190 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 : \u03b2 \u2192 \u03b3) (hf : function.injective f) :\n  function.injective (rename f : mv_polynomial \u03b2 \u03b1 \u2192 mv_polynomial \u03b3 \u03b1) :=\nhave (rename f : mv_polynomial \u03b2 \u03b1 \u2192 mv_polynomial \u03b3 \u03b1) =\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 : \u03b2 \u2192 \u03b3) (p : mv_polynomial \u03b2 \u03b1) :\n  (p.rename f).total_degree \u2264 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 \u27e8s, hs, rfl\u27e9,\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  {\u03b1} [comm_ring \u03b1] [decidable_eq \u03b1] [decidable_eq \u03b2] [decidable_eq \u03b3] (f : \u03b2 \u2192 \u03b3) :\n  is_ring_hom (rename f : mv_polynomial \u03b2 \u03b1 \u2192 mv_polynomial \u03b3 \u03b1) :=\n@is_ring_hom.of_semiring (mv_polynomial \u03b2 \u03b1) (mv_polynomial \u03b3 \u03b1) _ _ (rename f)\n  (rename.is_semiring_hom f)\n\nsection equiv\n\nvariables (\u03b1) [comm_ring \u03b1]\nvariables [decidable_eq \u03b2] [decidable_eq \u03b3] [decidable_eq \u03b4]\n\ndef pempty_ring_equiv : mv_polynomial pempty \u03b1 \u2243r \u03b1 :=\n{ to_fun    := mv_polynomial.eval\u2082 id $ pempty.elim,\n  inv_fun   := C,\n  left_inv  := is_id _ (by apply_instance) (assume a, by rw [eval\u2082_C]; refl) (assume a, a.elim),\n  right_inv := \u03bb r, eval\u2082_C _ _ _,\n  hom       := eval\u2082.is_ring_hom _ _ }\n\ndef punit_ring_equiv : mv_polynomial punit \u03b1 \u2243r polynomial \u03b1 :=\n{ to_fun    := eval\u2082 polynomial.C (\u03bbu:punit, polynomial.X),\n  inv_fun   := polynomial.eval\u2082 mv_polynomial.C (X punit.star),\n  left_inv  :=\n    begin\n      refine is_id _ _ _ _,\n      apply is_semiring_hom.comp (eval\u2082 polynomial.C (\u03bbu:punit, polynomial.X)) _; apply_instance,\n      { assume a, rw [eval\u2082_C, polynomial.eval\u2082_C] },\n      { rintros \u27e8\u27e9, rw [eval\u2082_X, polynomial.eval\u2082_X] }\n    end,\n  right_inv := assume p, polynomial.induction_on p\n    (assume a, by rw [polynomial.eval\u2082_C, mv_polynomial.eval\u2082_C])\n    (assume p q hp hq, by rw [polynomial.eval\u2082_add, mv_polynomial.eval\u2082_add, hp, hq])\n    (assume p n hp,\n      by rw [polynomial.eval\u2082_mul, polynomial.eval\u2082_pow, polynomial.eval\u2082_X, polynomial.eval\u2082_C,\n        eval\u2082_mul, eval\u2082_C, eval\u2082_pow, eval\u2082_X]),\n  hom       := eval\u2082.is_ring_hom _ _ }\n\ndef ring_equiv_of_equiv (e : \u03b2 \u2243 \u03b3) : mv_polynomial \u03b2 \u03b1 \u2243r mv_polynomial \u03b3 \u03b1 :=\n{ to_fun    := rename e,\n  inv_fun   := rename e.symm,\n  left_inv  := \u03bb p, by simp only [rename_rename, (\u2218), e.symm_apply_apply]; exact rename_id p,\n  right_inv := \u03bb p, by simp only [rename_rename, (\u2218), e.apply_symm_apply]; exact rename_id p,\n  hom       := rename.is_ring_hom e }\n\ndef ring_equiv_congr [comm_ring \u03b3] (e : \u03b1 \u2243r \u03b3) : mv_polynomial \u03b2 \u03b1 \u2243r mv_polynomial \u03b2 \u03b3 :=\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 \u2218 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 \u2218 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 (\u03b2 \u03b3 \u03b4)\n\ninstance ring_on_sum : ring (mv_polynomial (\u03b2 \u2295 \u03b3) \u03b1) := by apply_instance\ninstance ring_on_iter : ring (mv_polynomial \u03b2 (mv_polynomial \u03b3 \u03b1)) := by apply_instance\n\ndef sum_to_iter : mv_polynomial (\u03b2 \u2295 \u03b3) \u03b1 \u2192 mv_polynomial \u03b2 (mv_polynomial \u03b3 \u03b1) :=\neval\u2082 (C \u2218 C) (\u03bbbc, sum.rec_on bc X (C \u2218 X))\n\ninstance is_semiring_hom_C_C :\n  is_semiring_hom (C \u2218 C : \u03b1 \u2192 mv_polynomial \u03b2 (mv_polynomial \u03b3 \u03b1)) :=\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 \u03b1 \u03b2 \u03b3) :=\neval\u2082.is_semiring_hom _ _\n\nlemma sum_to_iter_C (a : \u03b1) : sum_to_iter \u03b1 \u03b2 \u03b3 (C a) = C (C a) :=\neval\u2082_C _ _ a\n\nlemma sum_to_iter_Xl (b : \u03b2) : sum_to_iter \u03b1 \u03b2 \u03b3 (X (sum.inl b)) = X b :=\neval\u2082_X _ _ (sum.inl b)\n\nlemma sum_to_iter_Xr (c : \u03b3) : sum_to_iter \u03b1 \u03b2 \u03b3 (X (sum.inr c)) = C (X c) :=\neval\u2082_X _ _ (sum.inr c)\n\ndef iter_to_sum : mv_polynomial \u03b2 (mv_polynomial \u03b3 \u03b1) \u2192 mv_polynomial (\u03b2 \u2295 \u03b3) \u03b1 :=\neval\u2082 (eval\u2082 C (X \u2218 sum.inr)) (X \u2218 sum.inl)\n\nsection\n\ninstance is_semiring_hom_iter_to_sum : is_semiring_hom (iter_to_sum \u03b1 \u03b2 \u03b3) :=\neval\u2082.is_semiring_hom _ _\n\nend\n\nlemma iter_to_sum_C_C (a : \u03b1) : iter_to_sum \u03b1 \u03b2 \u03b3 (C (C a)) = C a :=\neq.trans (eval\u2082_C _ _ (C a)) (eval\u2082_C _ _ _)\n\nlemma iter_to_sum_X (b : \u03b2) : iter_to_sum \u03b1 \u03b2 \u03b3 (X b) = X (sum.inl b) :=\neval\u2082_X _ _ _\n\nlemma iter_to_sum_C_X (c : \u03b3) : iter_to_sum \u03b1 \u03b2 \u03b3 (C (X c)) = X (sum.inr c) :=\neq.trans (eval\u2082_C _ _ (X c)) (eval\u2082_X _ _ _)\n\ndef mv_polynomial_equiv_mv_polynomial [comm_ring \u03b4]\n  (f : mv_polynomial \u03b2 \u03b1 \u2192 mv_polynomial \u03b3 \u03b4) (hf : is_semiring_hom f)\n  (g : mv_polynomial \u03b3 \u03b4 \u2192 mv_polynomial \u03b2 \u03b1) (hg : is_semiring_hom g)\n  (hfgC : \u2200a, f (g (C a)) = C a)\n  (hfgX : \u2200n, f (g (X n)) = X n)\n  (hgfC : \u2200a, g (f (C a)) = C a)\n  (hgfX : \u2200n, g (f (X n)) = X n) :\n  mv_polynomial \u03b2 \u03b1 \u2243r mv_polynomial \u03b3 \u03b4 :=\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 (\u03b2 \u2295 \u03b3) \u03b1 \u2243r mv_polynomial \u03b2 (mv_polynomial \u03b3 \u03b1) :=\nbegin\n  apply @mv_polynomial_equiv_mv_polynomial \u03b1 (\u03b2 \u2295 \u03b3) _ _ _ _ _ _ _ _\n    (sum_to_iter \u03b1 \u03b2 \u03b3) _ (iter_to_sum \u03b1 \u03b2 \u03b3) _,\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 \u03b1 \u03b2 \u03b3 },\n      { apply mv_polynomial.is_semiring_hom_sum_to_iter \u03b1 \u03b2 \u03b3 } },\n    { apply mv_polynomial.is_semiring_hom },\n    { assume a, rw [iter_to_sum_C_C \u03b1 \u03b2 \u03b3, sum_to_iter_C \u03b1 \u03b2 \u03b3] },\n    { assume c, rw [iter_to_sum_C_X \u03b1 \u03b2 \u03b3, sum_to_iter_Xr \u03b1 \u03b2 \u03b3] } },\n  { assume b, rw [iter_to_sum_X \u03b1 \u03b2 \u03b3, sum_to_iter_Xl \u03b1 \u03b2 \u03b3] },\n  { assume a, rw [sum_to_iter_C \u03b1 \u03b2 \u03b3, iter_to_sum_C_C \u03b1 \u03b2 \u03b3] },\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 \u03b1 \u03b2 \u03b3 },\n  { apply mv_polynomial.is_semiring_hom_iter_to_sum \u03b1 \u03b2 \u03b3 }\nend\n\ninstance option_ring : ring (mv_polynomial (option \u03b2) \u03b1) :=\nmv_polynomial.ring\n\ninstance polynomial_ring : ring (polynomial (mv_polynomial \u03b2 \u03b1)) :=\n@comm_ring.to_ring _ polynomial.comm_ring\n\ninstance polynomial_ring2 : ring (mv_polynomial \u03b2 (polynomial \u03b1)) :=\nby apply_instance\n\ndef option_equiv_left : mv_polynomial (option \u03b2) \u03b1 \u2243r polynomial (mv_polynomial \u03b2 \u03b1) :=\n(ring_equiv_of_equiv \u03b1 $ (equiv.option_equiv_sum_punit \u03b2).trans (equiv.sum_comm _ _)).trans $\n(sum_ring_equiv \u03b1 _ _).trans $\npunit_ring_equiv _\n\ndef option_equiv_right : mv_polynomial (option \u03b2) \u03b1 \u2243r mv_polynomial \u03b2 (polynomial \u03b1) :=\n(ring_equiv_of_equiv \u03b1 $ equiv.option_equiv_sum_punit.{0} \u03b2).trans $\n(sum_ring_equiv \u03b1 \u03b2 unit).trans $\nring_equiv_congr (mv_polynomial unit \u03b1) (punit_ring_equiv \u03b1)\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) [\ud835\udc9e : 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 : \u2115}    -- the number of steps in the execution\n\nvariable  {rc_len : \u2115}  -- 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 \u2192 F}\n\nvariables {rc_addr rc_val : fin rc_len \u2192 F}\n\nvariables {mem_star : F \u2192 option F}\n\nvariables {n : \u2115}\n\nvariables {a v a' v' p   : fin (n + 1) \u2192 F}\n\nvariables {embed_inst\n           embed_dst\n           embed_op0\n           embed_op1     : fin T \u2192 fin (n + 1)}\n\nvariables {embed_rc      : fin rc_len \u2192 fin (n + 1)}\n\nvariables {embed_mem     : mem_dom mem_star \u2192 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  \u2200 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  \u2200 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 : \u2200 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) * \u220f 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       : \u2200 i, a (embed_inst i) = pc i\nvariable h_embed_inst     : \u2200 i, v (embed_inst i) = inst i\nvariable h_embed_dst_addr : \u2200 i, a (embed_dst i)  = dst_addr i\nvariable h_embed_dst      : \u2200 i, v (embed_dst i)  = dst i\nvariable h_embed_op0_addr : \u2200 i, a (embed_op0 i)  = op0_addr i\nvariable h_embed_op0      : \u2200 i, v (embed_op0 i)  = op0 i\nvariable h_embed_op1_addr : \u2200 i, a (embed_op1 i)  = op1_addr i\nvariable h_embed_op1      : \u2200 i, v (embed_op1 i)  = op1 i\n\nvariable h_embed_rc_addr  : \u2200 i, a (embed_rc i)   = rc_addr i\nvariable h_embed_rc_val   : \u2200 i, v (embed_rc i)   = rc_val i\n\nvariable h_embed_dom      : \u2200 i, a (embed_mem i) = 0\nvariable h_embed_val      : \u2200 i, v (embed_mem i) = 0\n\nvariable h_embed_mem_inj       : function.injective embed_mem\nvariable h_embed_mem_disj_inst : \u2200 i j, embed_mem i \u2260 embed_inst j\nvariable h_embed_mem_disj_dst  : \u2200 i j, embed_mem i \u2260 embed_dst j\nvariable h_embed_mem_disj_op0  : \u2200 i j, embed_mem i \u2260 embed_op0 j\nvariable h_embed_mem_disj_op1  : \u2200 i j, embed_mem i \u2260 embed_op1 j\nvariable h_embed_mem_disj_rc   : \u2200 i j, embed_mem i \u2260 embed_rc j\n\n/-\nThe memory.\n-/\n\ndef mem (a' v' : fin (n + 1) \u2192 F) : F \u2192 F :=\n\u03bb addr, if h : \u2203 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 \u2192 option F) (a : fin (n + 1) \u2192 F)\n    (embed_mem : mem_dom mem_star \u2192 fin (n + 1)) :\n  fin (n + 1) \u2192 F :=\n\u03bb i, if h : \u2203 addr, embed_mem addr = i then (classical.some h).val else a i\n\ndef real_v (mem_star : F \u2192 option F) (v : fin (n + 1) \u2192 F)\n    (embed_mem : mem_dom mem_star \u2192 fin (n + 1)) :\n  fin (n + 1) \u2192 F :=\n\u03bb i, if h : \u2203 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  (\u220f i, (z - (ra i + alpha * rv i))) * z^(fintype.card (mem_dom mem_star)) =\n    (\u220f i, (z - (a i + alpha * v i))) *\n      \u220f 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 [\u2190finset.prod_sdiff (finset.subset_univ s), \u2190finset.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 \u27e8_, nsi\u27e9,\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 (\u03bb x _ y _ h, @h_embed_mem_inj x y h), fintype.card, \u2190finset.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 (\u03bb x _ y _ h, @h_embed_mem_inj x y h)],\n  apply finset.prod_congr rfl,\n  intros i _, dsimp,\n  have h : \u2203 addr, embed_mem addr = embed_mem i := \u27e8i, rfl\u27e9,\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 \u2260 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  (\u220f i, (z - (ra i + alpha * rv i))) = (\u220f 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 : (\u220f i, (z - (ra i + alpha * rv i))) * z^(fintype.card (mem_dom mem_star)) =\n               (\u220f i, (z - (a' i + alpha * v' i))) * z^(fintype.card (mem_dom mem_star)),\n    from mul_right_cancel\u2080 (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 [\u2190fin.range_last, \u2190fin.succ_last, permutation_aux h_initial h_cumulative,\n    mul_assoc, h_final]\nend\n\nvariable hprob\u2081 : alpha \u2209\n  bad_set_1 (real_a mem_star a embed_mem) (real_v mem_star v embed_mem) a' v'\n\nvariable hprob\u2082 : z \u2209\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  \u2200 i, \u2203 j, real_v mem_star v embed_mem i = v' j \u2227\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 : \u220f (i : fin (n + 1)), (z - (ra i + alpha * rv i)) =\n          \u220f (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\u2081 hprob\u2082 h\n\nlemma real_perm' :\n  \u2200 i, \u2203 j, v' i = real_v mem_star v embed_mem j \u2227\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 : \u220f (i : fin (n + 1)), (z - (ra i + alpha * rv i)) =\n          \u220f (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\u2081 hprob\u2082 h\n\nvariable h_char_lt : n < ring_char F\n\ninclude h_continuity h_single_valued hprob\u2081 hprob\u2082 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  \u2200 i i', ra i = ra i' \u2192 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 : \u220f (i : fin (n + 1)), (z - (ra i + alpha * rv i)) =\n             \u220f (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\u2081 hprob\u2082 h,\n  rcases perm i with \u27e8j, veq, aeq\u27e9,\n  rcases perm i' with \u27e8j', veq', aeq'\u27e9,\n  rw [veq, veq'],\n  apply a'_single_valued h_continuity h_single_valued h_char_lt,\n  rw [\u2190aeq, \u2190aeq', 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\u2081 hprob\u2082,\n  rcases perm i with \u27e8i', v'eq, a'eq\u27e9,\n  have h : \u2203 i', a' i' = real_a mem_star a embed_mem i := \u27e8i', a'eq.symm\u27e9,\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 [\u2190@real_a_embed_inst _ T pc mem_star _ a embed_inst embed_mem _ _ h_embed_pc\n          h_embed_mem_disj_inst],\n  rw [\u2190@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\u2081 hprob\u2082 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\u2081 hprob\u2082 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\u2081 hprob\u2082 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\u2081 hprob\u2082 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 [\u2190@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 [\u2190@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\u2081 hprob\u2082 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 := \u27e8addr, h'\u27e9,\n  have h\u2080 : \u2203 i, embed_mem i = embed_mem aelt := \u27e8aelt, rfl\u27e9,\n  have h\u2081 : classical.some h\u2080 = aelt,\n  { apply h_embed_mem_inj, apply classical.some_spec h\u2080 },\n  have h\u2082 : real_a mem_star a embed_mem (embed_mem aelt) = addr,\n  { rw real_a, dsimp, rw [dif_pos h\u2080, h\u2081], refl },\n  have h\u2083 : real_v mem_star v embed_mem (embed_mem aelt) = val,\n  { rw real_v, dsimp, rw [dif_pos h\u2080, h\u2081],\n    apply option.some_inj.mp,\n    rw [\u2190h, mem_val, option.some_get] },\n  rw [\u2190h\u2082, \u2190h\u2083], 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\u2081 hprob\u2082 h_char_lt (embed_mem \u27e8addr, h'\u27e9)\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": "import tactic.slim_check\nimport .mk_slim_check_test\n\nexample : true :=\nbegin\n  have : \u2200 i j : \u2115, i < j \u2192 j < i,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n  \"\n===================\nFound problems!\n\ni := 0\nj := 1\nguard: 0 < 1 (by construction)\nissue: 1 < 0 does not hold\n(0 shrinks)\n-------------------\n\",\n  admit,\n  trivial\nend\n\nexample : true :=\nbegin\n  have : (\u2200 x : \u2115, 2 \u2223 x \u2192 x < 100),\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n  \"\n===================\nFound problems!\n\nx := 104\nissue: 104 < 100 does not hold\n(2 shrinks)\n-------------------\n\",\n  admit,\n  trivial\nend\n\nexample (xs : list \u2115) (w : \u2203 x \u2208 xs, x < 3) : true :=\nbegin\n  have : \u2200 y \u2208 xs, y < 5,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nxs := [5, 5, 0, 1]\nx := 0\ny := 5\nissue: 5 < 5 does not hold\n(5 shrinks)\n-------------------\n\",\n  admit,\n  trivial\nend\n\nexample (x : \u2115) (h : 2 \u2223 x) : true :=\nbegin\n  have : x < 100,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nx := 104\nissue: 104 < 100 does not hold\n(2 shrinks)\n-------------------\n\",\n  admit,\n  trivial\nend\n\nexample (\u03b1 : Type) (xs ys : list \u03b1) : true :=\nbegin\n  have : xs ++ ys = ys ++ xs,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\n\u03b1 := \u2124\nxs := [0]\nys := [1]\nissue: [0, 1] = [1, 0] does not hold\n(4 shrinks)\n-------------------\n\",\n  admit,\n  trivial\nend\n\nexample : true :=\nbegin\n  have : \u2200 x \u2208 [1,2,3], x < 4,\n  slim_check { random_seed := some 257, quiet := tt },\n    -- success\n  trivial,\nend\n\nopen function slim_check\n\nexample (f : \u2124 \u2192 \u2124) (h : injective f) : true :=\nbegin\n  have : monotone (f \u2218 small.mk),\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nf := [2 \u21a6 3, 3 \u21a6 9, 4 \u21a6 6, 5 \u21a6 4, 6 \u21a6 2, 8 \u21a6 5, 9 \u21a6 8, x \u21a6 x]\nx := 3\ny := 4\nguard: 3 \u2264 4 (by construction)\nissue: 9 \u2264 6 does not hold\n(5 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (f : \u2124 \u2192 \u2124) (h : injective f) (g : \u2124 \u2192 \u2124) (h : injective g) (i) : true :=\nbegin\n  have : f i = g i,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nf := [x \u21a6 x]\ng := [1 \u21a6 2, 2 \u21a6 1, x \u21a6 x]\ni := 1\nissue: 1 = 2 does not hold\n(5 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (f : \u2124 \u2192 \u2124) (h : injective f) : true :=\nbegin\n  have : monotone f,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nf := [2 \u21a6 3, 3 \u21a6 9, 4 \u21a6 6, 5 \u21a6 4, 6 \u21a6 2, 8 \u21a6 5, 9 \u21a6 8, x \u21a6 x]\nx := 3\ny := 4\nguard: 3 \u2264 4 (by construction)\nissue: 9 \u2264 6 does not hold\n(5 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (f : \u2124 \u2192 \u2124) : true :=\nbegin\n  have : injective f,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nf := [_ \u21a6 0]\nx := 0\ny := -1\nguard: 0 = 0\nissue: 0 = -1 does not hold\n(0 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (f : \u2124 \u2192 \u2124) : true :=\nbegin\n  have : monotone f,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nf := [-6 \u21a6 97, 0 \u21a6 0, _ \u21a6 4]\nx := -6\ny := -2\nguard: -6 \u2264 -2 (by construction)\nissue: 97 \u2264 4 does not hold\n(5 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\nexample (xs ys : list \u2124) (h : xs ~ ys) : true :=\nbegin\n  have : list.qsort (\u03bb x y, x \u2260 y) xs = list.qsort (\u03bb x y, x \u2260 y) ys,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nxs := [0, 1]\nys := [1, 0]\nguard: [0, 1] ~ [1, 0] (by construction)\nissue: [0, 1] = [1, 0] does not hold\n(4 shrinks)\n-------------------\n\",\n  admit,\n  trivial\nend\n\nexample (x y : \u2115) : true :=\nbegin\n  have : y \u2264 x \u2192 x + y < 100,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nx := 59\ny := 41\nguard: 41 \u2264 59 (by construction)\nissue: 100 < 100 does not hold\n(8 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (x : \u2124) : true :=\nbegin\n  have : x \u2264 3 \u2192 3 \u2264 x,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nx := 2\nguard: 2 \u2264 3 (by construction)\nissue: 3 \u2264 2 does not hold\n(1 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (x y : \u2124) : true :=\nbegin\n  have : y \u2264 x \u2192 x + y < 100,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nx := 52\ny := 52\nguard: 52 \u2264 52 (by construction)\nissue: 104 < 100 does not hold\n(4 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (x y : Prop) : true :=\nbegin\n  have : x \u2228 y \u2192 y \u2227 x,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nx := tt\ny := ff\nguard: (true \u2228 false)\nissue: false does not hold\n(0 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (x y : Prop) : true :=\nbegin\n  have : (\u00acx \u2194 y) \u2192 y \u2227 x,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nx := tt\ny := ff\nguard: (\u00ac true \u2194 false)\nissue: false does not hold\n(0 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (x y : Prop) : true :=\nbegin\n  -- deterministic\n  have : (x \u2194 y) \u2192 y \u2228 x,\n  success_if_fail_with_msg\n  { slim_check }\n\"\n===================\nFound problems!\n\nx := ff\ny := ff\nguard: (false \u2194 false)\nissue: false does not hold\nissue: false does not hold\n(0 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (x y : Prop) : true :=\nbegin\n  -- deterministic\n  have : y \u2228 x,\n  success_if_fail_with_msg\n  { slim_check }\n\"\n===================\nFound problems!\n\nx := ff\ny := ff\nissue: false does not hold\nissue: false does not hold\n(0 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\nend\n\nexample (x y : Prop) : true :=\nbegin\n  have : x \u2194 y,\n  success_if_fail_with_msg\n  { slim_check { random_seed := some 257 } }\n\"\n===================\nFound problems!\n\nx := tt\ny := ff\nissue: false does not hold\nissue: \u00ac true does not hold\n(0 shrinks)\n-------------------\n\",\n  admit,\n  trivial,\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/slim_check.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.48502870747996}}
{"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) \u224c 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 \u21a5(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 \u21a5(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 \u21a5(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 \u21a5A) (algebra.linear_map R \u21a5A) (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 \u27f6 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) \u224c 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) \u224c 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 \u22d9 category_theory.forget\u2082 (Algebra R) (Module R) \u2245\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 \u2192 \u2115\n| \"x\" := 4\n| _   := 0\ndef exampleConfig := (configE(a + b + (c * d), f))\n\n\ndef oneSmallStepExpr : configExpr \u2192 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 \u2192 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 \u2192 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) : (\u2203 n : \u2115, \u2203 f : string \u2192 \u2115, 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 ` \u2243 ` := v_eq\n\nsection\nvariable \u03b1 : Type\n\nvariables \u0393 p q r : cpred\nvariables v\u2080 v\u2081 : tvar \u03b1\nvariables f : pred' \u03b1\nvariables h\u2080 : \u0393 \u22a2 p \u2261 q\ninclude h\u2080\nexample : \u0393 \u22a2 p \u22c0 r \u2261 q \u22c0 r :=\nbegin [temporal]\n  rw h\u2080,\nend\n\nexample : \u0393 \u22a2 p \u22c0 r \u2192  \u0393 \u22a2 q \u22c0 r :=\nassume _,\nbegin [temporal]\n  rw \u2190 h\u2080,\nend\n\nvariables h\u2081 : \u0393 \u22a2 \u25fb(p \u2261 q)\nomit h\u2080\ninclude h\u2081\nexample : \u0393 \u22a2 \u25fb\u25c7p \u2261 \u25fb\u25c7q :=\nbegin [temporal]\n  rw h\u2081,\nend\n\nvariables h\u2082 : \u0393 \u22a2 \u25fb(v\u2080 \u2243 v\u2081)\ninclude h\u2082\nexample (h : \u0393 \u22a2 \u25c7(\u25fb(f ! v\u2080 \u2261 q) \u22c0 p))\n: \u0393 \u22a2 \u25c7(\u25fb(f ! v\u2081 \u2261 q) \u22c0 p) :=\nbegin [temporal]\n  rw \u2190 h\u2082,\nend\n\nexample (h : \u0393 \u22a2 \u25c7(\u25fb(f ! v\u2080 \u2261 q) \u22c0 p))\n: \u0393 \u22a2 \u25c7(\u25fb(f ! v\u2081 \u2261 q) \u22c0 p) :=\nbegin [temporal]\n  rw h\u2082 at h,\nend\nend\n\ninductive nat.even : \u2115 \u2192 Prop\n | zero : nat.even 0\n | succ_succ (n) : nat.even n \u2192 nat.even (nat.succ (nat.succ n))\n\nsection\nopen nat\nlemma even_succ_succ (n : \u2115)\n: nat.even (nat.succ $ nat.succ n) \u2194 nat.even n :=\nsorry\nend\nabbreviation succ : var \u2115 \u2115 := \u27e8 nat.succ \u27e9\nabbreviation even : var \u2115 Prop := \u27e8 nat.even \u27e9\n\nvariables \u0393 : cpred\n\nexample (x y : tvar \u2115)\n(h\u2080 : \u0393 \u22a2 \u25fb(\u2299x \u2243 succ!succ!x))\n(h\u2081 : \u0393 \u22a2 \u25fb(\u2299y \u2243 y))\n(h\u2082 : \u0393 \u22a2 even!x \u2261 even!y)\n: \u0393 \u22a2 \u25fb(even!x \u2261 even!y) :=\nbegin [temporal]\n  apply induct _ _ _ _,\n-- h\u2080 : \u25fb(\u2299x \u2243 succ ! succ ! x),\n-- h\u2081 : \u25fb(\u2299y \u2243 y),\n-- h\u2082 : even ! x \u2261 even ! y\n-- \u22a2 \u25fb((even ! x \u2261 even ! y) \u27f6 \u2299(even ! x \u2261 even ! y))\n  { clear h\u2082,\n    henceforth at \u22a2 h\u2080 h\u2081,\n-- _inst_1 : persistent \u0393,\n-- h\u2081 : \u2299y \u2243 y,\n-- h\u2080 : \u2299x \u2243 succ ! succ ! x\n-- \u22a2 (even ! x \u2261 even ! y) \u27f6 \u2299(even ! x \u2261 even ! y)\n    intros h\u2083,\n-- h\u2081 : \u2299y \u2243 y,\n-- h\u2080 : \u2299x \u2243 succ ! succ ! x,\n-- h\u2083 : even ! x \u2261 even ! y\n-- \u22a2 \u2299(even ! x \u2261 even ! y)\n    explicit' with h\u2080 h\u2081 h\u2083\n-- x x' y y' : \u2115,\n-- h\u2083 : nat.even x \u2194 nat.even y,\n-- h\u2080 : x' = nat.succ (nat.succ x),\n-- h\u2081 : y' = y\n-- \u22a2 nat.even x' \u2194 nat.even y'\n    { have := even_succ_succ x,\n-- x x' y y' : \u2115,\n-- h\u2083 : nat.even x \u2194 nat.even y,\n-- h\u2080 : x' = nat.succ (nat.succ x),\n-- h\u2081 : y' = y,\n-- this : nat.even (nat.succ (nat.succ x)) \u2194 nat.even x\n-- \u22a2 nat.even x' \u2194 nat.even y'\n      guard_hyp h\u2080 := x' = nat.succ (nat.succ x),\n      guard_target (nat.even x' \u2194 nat.even y'),\n      cc, } },\n-- h\u2080 : \u25fb(\u2299x \u2243 succ ! succ ! x),\n-- h\u2081 : \u25fb(\u2299y \u2243 y),\n-- h\u2082 : even ! x \u2261 even ! y\n-- \u22a2 even ! x \u2261 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 \u2192 Type v} [(i : I) \u2192 distrib (f i)] :\n    distrib ((i : I) \u2192 f i) :=\n  distrib.mk Mul.mul Add.add sorry sorry\n\nprotected instance semiring {I : Type u} {f : I \u2192 Type v} [(i : I) \u2192 semiring (f i)] :\n    semiring ((i : I) \u2192 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 \u2192 Type v} [(i : I) \u2192 comm_semiring (f i)] :\n    comm_semiring ((i : I) \u2192 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 \u2192 Type v} [(i : I) \u2192 ring (f i)] :\n    ring ((i : I) \u2192 f i) :=\n  ring.mk Add.add sorry 0 sorry sorry Neg.neg\n    (fun (\u1fb0 \u1fb0_1 : (i : I) \u2192 f i) (i : I) => ring.sub (\u1fb0 i) (\u1fb0_1 i)) sorry sorry Mul.mul sorry 1\n    sorry sorry sorry sorry\n\nprotected instance comm_ring {I : Type u} {f : I \u2192 Type v} [(i : I) \u2192 comm_ring (f i)] :\n    comm_ring ((i : I) \u2192 f i) :=\n  comm_ring.mk Add.add sorry 0 sorry sorry Neg.neg\n    (fun (\u1fb0 \u1fb0_1 : (i : I) \u2192 f i) (i : I) => comm_ring.sub (\u1fb0 i) (\u1fb0_1 i)) sorry sorry Mul.mul sorry 1\n    sorry sorry sorry sorry sorry\n\n/-- A family of ring homomorphisms `f a : \u03b3 \u2192+* \u03b2 a` defines a ring homomorphism\n`pi.ring_hom f : \u03b3 \u2192+* \u03a0 a, \u03b2 a` given by `pi.ring_hom f x b = f b x`. -/\nprotected def ring_hom {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v} [R : (a : \u03b1) \u2192 semiring (\u03b2 a)] {\u03b3 : Type w}\n    [semiring \u03b3] (f : (a : \u03b1) \u2192 \u03b3 \u2192+* \u03b2 a) : \u03b3 \u2192+* (a : \u03b1) \u2192 \u03b2 a :=\n  ring_hom.mk (fun (x : \u03b3) (b : \u03b1) => coe_fn (f b) x) sorry sorry sorry sorry\n\n@[simp] theorem ring_hom_apply {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v} [R : (a : \u03b1) \u2192 semiring (\u03b2 a)]\n    {\u03b3 : Type w} [semiring \u03b3] (f : (a : \u03b1) \u2192 \u03b3 \u2192+* \u03b2 a) (g : \u03b3) (a : \u03b1) :\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 \u2192 Type u_2) [(i : I) \u2192 semiring (f i)] (i : I) :\n    ((i : I) \u2192 f i) \u2192+* 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 \u2192 Type u_2) [(i : I) \u2192 semiring (f i)]\n    (i : I) (g : (i : I) \u2192 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 \u2192 Type :=\n  | intro: isTrue (.mk .MyTrue ())\n\nexample {\u03c4: T} (h: isTrue \u03c4): Unit :=\n  match \u03c4, 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        \u2983f\u2081 : \u2124 \u2192 \u2124\u2984 \u2983bound\u2081 : \u2115\u2984 (h\u2081 : AlmostAdditive f\u2081 bound\u2081)\n        \u2983f\u2082 : G \u2192 \u2124\u2984 \u2983bound\u2082 : \u2115\u2984 (h\u2082 : AlmostAdditive f\u2082 bound\u2082)\n    : AlmostAdditive (f\u2081 \u2218 f\u2082) <|\n        (bound\u2081 + |f\u2081 1|) * bound\u2082 + bound\u2081 * 3 := fun x y =>\n  calc |f\u2081 (f\u2082 (x + y)) - f\u2081 (f\u2082 x) - f\u2081 (f\u2082 y)|\n    \u2264 |f\u2081 (f\u2082 (x + y)) - f\u2081 (f\u2082 (x + y) - f\u2082 x - f\u2082 y) - f\u2081 (f\u2082 x + f\u2082 y)|\n      + |f\u2081 (f\u2082 (x + y) - f\u2082 x - f\u2082 y)|\n      + |f\u2081 (f\u2082 x + f\u2082 y) - f\u2081 (f\u2082 x) - f\u2081 (f\u2082 y)|\n        := by lax_exact Int.natAbs_add_le\u2083 (f\u2081 (f\u2082 (x + y)) - f\u2081 (f\u2082 (x + y) - f\u2082 x - f\u2082 y) - f\u2081 (f\u2082 x + f\u2082 y))\n                                           (f\u2081 (f\u2082 (x + y) - f\u2082 x - f\u2082 y))\n                                           (f\u2081 (f\u2082 x + f\u2082 y) - f\u2081 (f\u2082 x) - f\u2081 (f\u2082 y))\n              linarith\n  _ \u2264 bound\u2081\n      + ((bound\u2081 + |f\u2081 1|) * |f\u2082 (x + y) - f\u2082 x - f\u2082 y| + bound\u2081)\n      + bound\u2081\n        := by conv in f\u2081 (f\u2082 (x + y)) =>\n                /- Need `f\u2082 (x + y)` like this to use `h\u2081.almost_additive`. -/\n                rw [show f\u2082 (x + y) = (f\u2082 (x + y) - f\u2082 x - f\u2082 y) + (f\u2082 x + f\u2082 y)\n                    by linarith]\n              refine Nat.add_le_add\u2083 ?_ ?using_lemma ?_;\n              case using_lemma => apply h\u2081.linear_growth_upper_bound_int\n              all_goals apply h\u2081.almost_additive\n  _ = (bound\u2081 + |f\u2081 1|) * |f\u2082 (x + y) - f\u2082 x - f\u2082 y| + bound\u2081 * 3 := by linarith\n  _ \u2264 (bound\u2081 + |f\u2081 1|) * bound\u2082 + bound\u2081 * 3\n        := h\u2082.almost_additive .. |> Nat.mul_le_mul_left (k := _)\n                                 |> Nat.add_le_add_right (k := _)\n\n/-- If f\u2082 - f\u2081 is bounded then f \u2218 (f\u2082 - f\u2081) is bounded. -/\nlemma comp_congr_right\n        \u2983f  : \u2124 \u2192 \u2124\u2984 \u2983bound : \u2115\u2984 (h : AlmostAdditive f  bound)\n        \u2983f\u2081 f\u2082 : G \u2192 \u2124\u2984 \u2983bound' : \u2115\u2984 (h' : Bounded (-f\u2081 + f\u2082) bound')\n    : Bounded (-f.comp f\u2081 + f.comp f\u2082) <|\n        (bound + |f 1|) * bound' + bound * 2 := fun g =>\n  calc |(-f (f\u2081 g)) + f (f\u2082 g)|\n      = |f (f\u2081 g + (f\u2082 g - f\u2081 g)) - f (f\u2081 g) - f (f\u2082 g - f\u2081 g)\n         + f (f\u2082 g - f\u2081 g)|\n          := congrArg Int.natAbs <| by\n               rw [Int.add_sub_cancel_right (f\u2081 g) (f\u2082 g),\n                   \u2190Int.sub_eq_neg_add, Int.sub_add_cancel]\n    _ \u2264 bound + ((bound + |f 1|) * |f\u2082 g - f\u2081 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    _ \u2264 (bound + |f 1|) * bound' + bound * 2\n          := by have : |f\u2082 g - f\u2081 g| \u2264 bound' := Int.sub_eq_neg_add .. \u25b8 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        \u2983f  : \u2124 \u2192 \u2124\u2984 \u2983bound : \u2115\u2984 (h : AlmostAdditive f  bound)\n        (f\u2081 f\u2082 : G \u2192 \u2124)\n    : Bounded (-f \u2218 (f\u2081 + f\u2082) + (f \u2218 f\u2081 + f \u2218 f\u2082)) bound := fun g => by\n  show |(-f (f\u2081 g + f\u2082 g)) + (f (f\u2081 g) + f (f\u2082 g))| \u2264 bound\n  rewrite [\u2190Int.natAbs_neg]\n  lax_exact h.almost_additive (f\u2081 g) (f\u2082 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\u2081 : AlmostHom \u2124) (f\u2082 : AlmostHom G) : AlmostHom G where\n  toFun := f\u2081 \u2218 f\u2082\n  almostAdditive :=\n    let \u27e8_, h\u2081\u27e9 := f\u2081.almostAdditive\n    let \u27e8_, h\u2082\u27e9 := f\u2082.almostAdditive\n    -- bound is filled in based on the proof :)\n    \u27e8_, AlmostAdditive.comp h\u2081 h\u2082\u27e9\n\n/-- Concrete statement of well-defined-ness of `QuasiHom.comp` wrt second argument. -/\nlemma comp_congr_right (f : AlmostHom \u2124)\n        \u2983f\u2081 f\u2082 : AlmostHom G\u2984 (h : \u2203 bound : \u2115, Bounded (-f\u2081 + f\u2082) bound)\n    : \u2203 bound : \u2115, Bounded (-f.comp f\u2081 + f.comp f\u2082) bound :=\n  let \u27e8_, h'\u27e9 := h; let \u27e8_, h\u27e9 := f.almostAdditive\n  \u27e8_, h.comp_congr_right h'\u27e9\n\n/-- Concrete statement of additivity of `QuasiHom.comp` wrt second argument. -/\nlemma almost_comp_add (f : AlmostHom \u2124) (f\u2081 f\u2082 : AlmostHom G)\n    : \u2203 bound : \u2115, Bounded (-f.comp (f\u2081 + f\u2082) + (f.comp f\u2081 + f.comp f\u2082)) bound :=\n  let \u27e8_, h\u27e9 := f.almostAdditive\n  \u27e8_, h.almost_comp_add f\u2081 f\u2082\u27e9\n\n/-- Left distributivity of composition over addition. -/\nlemma add_comp (f : AlmostHom G) (f\u2081 f\u2082 : AlmostHom \u2124)\n    : (f\u2081 + f\u2082).comp f = f\u2081.comp f + f\u2082.comp f := by ext; rfl\n/-- If f\u2081 is bounded then f\u2081.comp f\u2082 is bounded. -/\nlemma bounded_comp (f\u2082 : AlmostHom G)\n                   \u2983f\u2081 : AlmostHom \u2124\u2984 (h : \u2203 bound : \u2115, Bounded f\u2081 bound)\n    : \u2203 bound : \u2115, Bounded (f\u2081.comp f\u2082) bound :=\n  let \u27e8bound, h\u27e9 := h; \u27e8bound, fun g => h (f\u2082 g)\u27e9\n\n/-- Composition of AlmostHoms f g is almost equal to (f n * g n)/n -/\nprivate lemma comp_almost_mul (f\u2081 f\u2082 : AlmostHom \u2124) \n    : \u2203 k, \u2200 n, |n * (f\u2081.comp f\u2082 n) - f\u2082 n * f\u2081 n| \u2264 (|n| + 1) * k := by\n  let \u27e8a', b', hlin\u27e9 := linear_growth_upper_bound_int f\u2082\n  let \u27e8b\u2081, hf\u2081\u27e9 := f\u2081.almostAdditive \n  exact \u27e8_, by\n    intro n\n    have hypcomm := AlmostAdditive.almost_smul_comm (hf\u2081) (f\u2082 n) n 1\n    specialize hlin n\n    simp only [smul_eq_mul, mul_one] at hypcomm\n    calc |n * (f\u2081.comp f\u2082 n) - f\u2082 n * f\u2081 n| \n        \u2264 b\u2081*(|f\u2082 n| + |n| + 2) := hypcomm\n      _ \u2264 b\u2081*(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\u2081*(|n| * (a' + 1) + (b'+ 2)) := by ring\n      _ \u2264 b\u2081*(|n| * (a' + 1) + (b'+ 2)) + b\u2081*(a'+1) := \n          by simp only [le_add_iff_nonneg_right, zero_le]\n      _ \u2264 b\u2081*(|n| * (a' + 1) + (b'+ 2)) + b\u2081*(a'+1) + b\u2081*(|n|)*(b'+2) := \n          by simp only [le_add_iff_nonneg_right, zero_le]\n      _ = (|n|+1)*(b\u2081*(a'+1 + b'+2)) := by ring\n  \u27e9\n\nlemma succ_le_two_mul (a : \u2115) (ha : a \u2260 0) : a+1 \u2264 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\u2081 f\u2082 : AlmostHom \u2124) \n    : (f\u2081.comp f\u2082) - (f\u2082.comp f\u2081) \u2208 boundedAlmostHoms \u2124 := by\n  simp only [boundedAlmostHoms, Bounded, AddSubgroup.mem_mk, Set.mem_setOf_eq]\n  let \u27e8k\u2081, hf\u2081\u27e9 := comp_almost_mul f\u2081 f\u2082\n  let \u27e8k\u2082, hf\u2082\u27e9 := comp_almost_mul f\u2082 f\u2081\n  exact \u27e8_, by \n    intro n\n    have triag := Int.natAbs_add_le (n * (f\u2081.comp f\u2082 n) - f\u2082 n * f\u2081 n) (f\u2082 n * f\u2081 n - n * (f\u2082.comp f\u2081 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\u2081 hf\u2082 |-\n      exact self_le_add_right |(f\u2081.comp f\u2082 - f\u2082.comp f\u2081) 0| (2*(k\u2081 + k\u2082))\n    else \n    have goal_mul_n := \n      calc \n        |n| * |f\u2081.comp f\u2082 n - f\u2082.comp f\u2081 n|\n          = |n*f\u2081.comp f\u2082 n - n*f\u2082.comp f\u2081 n| := by rw [\u2190Int.natAbs_mul, mul_sub_left_distrib]\n        _ \u2264 |n*f\u2081.comp f\u2082 n - f\u2082 n * f\u2081 n| + |f\u2082 n * f\u2081 n - n*f\u2082.comp f\u2081 n| := triag\n        _ \u2264 |n*f\u2081.comp f\u2082 n - f\u2082 n * f\u2081 n| + (|n|+1)*k\u2082  := \n            by \n              rw [mul_comm $ f\u2082 n, \u2190Int.natAbs_neg (f\u2081 n * f\u2082 n - n*f\u2082.comp f\u2081 n)]\n              apply Nat.add_le_add_left; \n              simp only [neg_sub, Int.diff_eq]; exact hf\u2082 ..\n        _ \u2264 (|n|+1)*k\u2081 + (|n|+1)*k\u2082 := Nat.add_le_add_right (hf\u2081 ..) ..\n        _ = (|n|+1)*(k\u2081 + k\u2082) := by ring\n        _ \u2264 |n| * (2*(k\u2081 + k\u2082)) := \n            by \n              rw [\u2190mul_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\u2081.comp f\u2082 n - f\u2082.comp f\u2081 n| \n      \u2264 2*(k\u2081 + k\u2082) := 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    _ \u2264 _ := self_le_add_left  (2*(k\u2081 + k\u2082)) |(f\u2081.comp f\u2082 - f\u2082.comp f\u2081) 0| \u27e9\n\ndef non_zero (f : AlmostHom \u2124) : AlmostHom \u2124 := \n  \u27e8fun n => if f n = 0 then 1 else f n, \n    by \n      let \u27e8f,b,hf\u27e9 := f \n      unfold AlmostAdditive at hf\n      exact \u27e82+b, \n      by \n        rw [AlmostAdditive]\n        intro g\u2081 g\u2082\n        split\n        case inl hg => \n          by_cases c:f g\u2081 = 0 \n          <;> by_cases d:f g\u2082 = 0\n          <;> specialize hf g\u2081 g\u2082\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          \u00b7 linarith -- TODO remove linarith\n          \u00b7 exact le_add_left hf\n          \u00b7 simp only [sub_sub_cancel_left, sub_zero] at hf |-; exact le_add_left hf\n          \u00b7 rw [Int.sub_eq_add_neg, \n                Int.sub_eq_add_neg, \n                add_assoc,\n                \u2190Int.sub_eq_add_neg]\n            have := Int.natAbs_add_le 1 (-f g\u2081 - f g\u2082)\n            rw [Int.natAbs_one] at this\n            linarith\n        case inr hg => \n          by_cases c:f g\u2081 = 0 \n          <;> by_cases d:f g\u2082 = 0\n          <;> specialize hf g\u2081 g\u2082\n          <;> simp_all only [sub_zero, ite_true, ite_false]\n          \u00b7 have := Int.natAbs_add_le\u2083 (f (g\u2081 + g\u2082)) (-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          \u00b7 rw [Int.sub_eq_add_neg, \n                Int.sub_eq_add_neg, \n                add_assoc, add_comm (-1), \n                \u2190add_assoc, \n                \u2190@Int.sub_eq_add_neg _ (f g\u2082)]\n            have := Int.natAbs_add_le (f (g\u2081 + g\u2082) - f g\u2082) (-1)\n            rw [Int.natAbs_neg, Int.natAbs_one] at this\n            linarith\n          \u00b7 rw [Int.sub_eq_add_neg]\n            have := Int.natAbs_add_le (f (g\u2081 + g\u2082) - f g\u2081) (-1)\n            rw [Int.natAbs_neg, Int.natAbs_one] at this\n            linarith\n          \u00b7 linarith [hf ..]\u27e9\u27e9\n\nend AlmostHom\n\n\n-- Tidy up the proof and add it to suitable namespace\n@[aesop norm unfold] def smulHom : QuasiHom \u2124 \u2192+ QuasiHom G \u2192+ 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 \u2124)\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\u2081 f\u2082 =>\n              show (leftRel _).r .. \u2192 (leftRel _).r ..\n                by (repeat rewrite [leftRel_apply]); exact\n              f.comp_congr_right (f\u2081 := f\u2081) (f\u2082 := f\u2082)))\n          /- Hom wrt second arg as `QuasiHom G` -/\n          (Quotient.ind\u2082 <| fun g\u2081 g\u2082 => Quotient.sound <|\n           show (leftRel _).r (f.comp (g\u2081 + g\u2082)) (f.comp g\u2081 + f.comp g\u2082)\n             by rewrite [leftRel_apply]; exact\n           f.almost_comp_add g\u2081 g\u2082))\n        /- Hom wrt first arg as `AlmostHom \u2124` -/\n        fun f\u2081 f\u2082 =>\n          AddMonoidHom.ext <|\n          Quotient.ind <| fun g => congrArg mk <|\n          g.add_comp f\u2081 f\u2082)\n      /- Show output is 0 if first arg is in `boundedAlmostHoms \u2124`\n      (i.e, well-defined wrt first arg as `QuasiHom \u2124`) -/\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 \u2208 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 \u2124) :\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 \u2124) : smulHom 0 a = 0 := by\n  simp only [map_zero, AddMonoidHom.zero_apply]\n\nprivate lemma mul_zero (a : QuasiHom \u2124) : @smulHom \u2124 _ a 0 = 0 := by\n  simp only [map_zero]\n\nprivate lemma mul_assoc (a b c : QuasiHom \u2124) :\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 \u2124 := \u27e6 \u27e8 fun n => n, \u27e80, by intros _ _ ; simp only\n                      [add_sub_cancel', sub_self,\n                      Int.natAbs_zero, le_refl]\u27e9\u27e9  \u27e7\n\nprivate def one_mul  (a : QuasiHom \u2124) : smulHom one a = a := by\n  apply QuotientAddGroup.induction_on a; intro _; rfl\n\nprivate def mul_one (a : QuasiHom \u2124) : smulHom a one = a := by\n  apply QuotientAddGroup.induction_on a; intro _; rfl\n\nprivate def inv (a : QuasiHom \u2124) : QuasiHom \u2124 := by\n  sorry\n\nprivate def exists_pair_ne : one \u2260 \u27e6\u27e80, 0, fun _ _ => Nat.le_refl ..\u27e9\u27e7 := by\n  /- rewrite [show \u2200 a : QuasiHom \u2124, a \u2260 0 \u2194 \u00aca = 0 by intro; rfl] -/\n  /- by_contra h -/\n  /- apply QuotientAddGroup.eq -/\n  \n  /- apply Quotient.exact  (\u27e8 fun n => n, \u27e80, by intros _ _ ; simp only -/\n  /-                         [add_sub_cancel', sub_self, -/\n  /-                         Int.natAbs_zero, le_refl]\u27e9\u27e9) -/\n  /- have := Quotient.exact h; -/\n  /- simp [funext] at this; -/ \n  sorry\n\nprivate def mul_comm (a b : QuasiHom \u2124) : 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 \u2208 boundedAlmostHoms \u2124\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 \u2124) :=\n  let mul : Mul (QuasiHom \u2124) := \u27e8 fun f g => smulHom f g \u27e9\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 \u00absmt-lean\u00bb\n\nexample (x y z : \u2124) (h : x < y) (h' : y < z) : x < z :=\nbegin\n  veriT,\nend\n", "meta": {"author": "cipher1024", "repo": "smt-lean", "sha": "a1ad7855ae01aca1f8be5b8c8df95a01a175d08e", "save_path": "github-repos/lean/cipher1024-smt-lean", "path": "github-repos/lean/cipher1024-smt-lean/smt-lean-a1ad7855ae01aca1f8be5b8c8df95a01a175d08e/test/transitivity_of_lt.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7745833841649232, "lm_q2_score": 0.6261241702517976, "lm_q1q2_score": 0.48498537870109193}}
{"text": "import Project.Main\nimport Project.Merge\nimport Project.findMin\n\nuniverse u\n\nnamespace project\n\nvariable {le : \u03b1 \u2192 \u03b1 \u2192 Bool} \n(not_le_le : \u2200 x y, \u00ac le x y \u2192 le y x) \n(le_trans : \u2200 x y z, le x y \u2192 le y z \u2192 le x z)\n(le_rfl : \u2200 z, le z z)\n\n\ntheorem deleteMin_empty_IsHeap :  deleteMin le xs = none \u2192 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\u2081 : r \u2260 0) : \n    IsRankedTree r s nodes \u2192 IsHeapForest' (r - 1) nodes \n  | .nil => by \n    constructor\n  | .cons (t := t) (ts := ts) eq rt _ => by\n    constructor\n    . rw[\u2190eq]\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]) \u2192 IsHeap h.children := by\n  intro h\u2081\n  cases h with | mk val rank children =>\n  dsimp at *\n  cases h\u2081 with | cons lt bt h\u2081 =>\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 \u2192 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]) \u2192 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 : \u2115} : IsHeapForest' r a \u2192 IsHeapForest' r (List.eraseIdx a id)\n  | .nil => by\n    simp \n    constructor\n  | .cons (t := t) (ts := ts) lt bt h\u2081 => 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)) \u2192 IsHeap (.heap (a :: List.eraseIdx b id)) := by\n  intros h\u2081\n  cases h\u2081\n  constructor\n  . assumption\n  . assumption\n  . apply IsHeapForest'_eraseIdx\n    assumption\n\n\ntheorem IsMinHeap_eraseIdx {id : Nat} : IsMinHeap le (.heap b) \u2192 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[\u2190 List.tail_eq_of_cons_eq heq]\n      assumption\n    . rename_i heq\n      constructor\n      . rw[\u2190 List.head_eq_of_cons_eq heq]\n        assumption\n      . apply IsMinHeap_eraseIdx\n        rw[\u2190 List.tail_eq_of_cons_eq heq]\n        assumption\n\ntheorem IsMinHeap_delete_BinTree {id : Nat} : IsMinHeap le (.heap (a :: b)) \u2192 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 \u2192 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 \u2192 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) \u2192 \u2200 x \u2208 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[\u2190 heq.left]\n    cases hel\n    . rename_i heq\u2082\n      rw[\u2190 heq\u2082]\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\u2081 : IsHeap xs) (h\u2082 : IsMinHeap le xs) : deleteMin le xs = some (y, ys) \u2192 IsHeap ys \u2227 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[\u2190 eq.right]\n    apply children_IsHeap\n    assumption \n  . rw[\u2190 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[\u2190dmeq.right]\n    rw[\u2190heq.left]\n    apply And.intro\n    . apply children_IsHeap\n      rw[heq.right] at h\u2081\n      assumption\n    . apply children_IsMinHeap\n      rw[heq.right] at h\u2082\n      assumption\n  . rename_i xs\u2082 t\u2081 ts hne\u2082 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\u2082 bt\u2082 n\u2082 lebt eqeq\n        rw[\u2190dmeq.right]\n        apply And.intro\n        . unfold merge\n          split\n          rename_i ys\u2082 xs\u2083 ts\u2083 ts\u2084 heq heq\u2082\n          simp at heq\n          unfold List.eraseIdx at heq\n          have ihts\u2083 : IsHeap (.heap ts\u2083) := by\n            split at heq\n            . simp_all\n            . simp_all\n              unfold IsHeap\n              simp\n              unfold IsHeapForest\n              cases h\u2081\n              apply IsHeapForest'_weaken\n              . assumption\n              . simp_arith\n            . rename_i heq\u2083 _\n              rw[\u2190 heq]\n              apply IsHeap_delete_BinTree\n              rw[\u2190 heq\u2083, \u2190 heqh.left, \u2190 heqh.right] \n              assumption\n          have ihts\u2084 : IsHeap (.heap ts\u2084) := by\n            clear heq \n            rw [\u2190 heq\u2082]\n            have (And.intro ml mr) := eqeq\n            rw [\u2190 ml, \u2190 mr] at *; clear eqeq ml mr\n            apply children_IsHeap\n            constructor\n            . have fm : IsBinTree (findMin le ts\u2082 (1 + 1) (t\u2081, 0)).fst := by\n                apply IsBinTree_findMin\n                . cases h\u2081 with | cons _ _ hf =>\n                  rw[heqh.right] at hf \n                  cases hf\n                  assumption\n                . cases h\u2081\n                  simp_all\n              apply min_rank_IsBinTree \n              assumption\n            . apply IsBinTree_findMin\n              . rw[heqh.right] at h\u2081\n                cases h\u2081 with | cons _ _ hf =>\n                  cases hf\n                  assumption\n              . unfold IsHeap at h\u2081\n                unfold IsHeapForest at h\u2081\n                cases h\u2081 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\u2082 xs\u2083 ts\u2083 ts\u2084 heq heq\u2082\n          simp at heq\n          unfold List.eraseIdx at heq\n          have h\u2081\u2082 : IsMinHeap le (.heap ts\u2083) := by\n            split at heq\n            . rw[\u2190 heq]\n              constructor\n            . rename_i ts\u2085 heq\u2083 _\n              rw[\u2190 heqh.right] at heq\u2083\n              have eq : hs = ts\u2085 := by\n                apply List.tail_eq_of_cons_eq\n                assumption\n              rw[\u2190 heq, \u2190 eq]\n              cases h\u2082\n              assumption\n            . rename_i heq\u2083 _\n              rw[\u2190 heq]\n              apply IsMinHeap_delete_BinTree\n              rw[\u2190 heq\u2083, \u2190 heqh.left, \u2190 heqh.right]\n              assumption                                                           \n          have h\u2081\u2083 : IsMinHeap le (.heap ts\u2084) := by\n            rw[\u2190 heq\u2082]\n            apply children_IsMinHeap\n            constructor\n            . apply IsSearchTree_findMin\n              . rw[heqh.right] at h\u2082\n                cases h\u2082 with | cons _ mh => \n                cases mh\n                assumption\n              . rw[\u2190 eqeq.left, \u2190 heqh.left]\n                cases h\u2082\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\u2082 ts\u2083 heq\u2083 heq\u2084\n        rw[\u2190 heq]\n        apply And.intro\n        . have ihts\u2082 : IsHeap (.heap ts\u2082) := by\n            rw[\u2190 heq\u2083]\n            unfold IsHeap\n            unfold IsHeapForest\n            apply IsHeapForest'_eraseIdx\n            simp at heqh\n            constructor\n            . apply min_rank_IsBinTree\n              rw[\u2190 heqh.left]\n              cases h\u2081\n              assumption\n            . rw[\u2190 heqh.left]\n              cases h\u2081\n              assumption\n            . cases h\u2081\n              rw[\u2190 heqh.left, \u2190 heqh.right]\n              assumption\n          have h\u2082\u2084 : IsHeap (.heap ts\u2083) := by\n            rw[\u2190 heq\u2084]\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\u2081\n                apply IsBinTree_findMin <;>\n                  cases h\u2081 with | cons _ _ hf =>\n                  cases hf\n                  assumption\n              apply min_rank_IsBinTree ibt\n            . simp at heqh\n              rw[heqh.right] at h\u2081\n              apply IsBinTree_findMin <;>\n                cases h\u2081 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\u2082 : IsMinHeap le (.heap ts\u2082) := by\n            rw[\u2190 heq\u2083]\n            apply IsMinHeap_eraseIdx\n            rw[\u2190 heqh.left, \u2190 heqh.right]\n            assumption\n          have imhts\u2083 : IsMinHeap le (.heap ts\u2083) := by\n            rw[\u2190 heq\u2084]\n            apply children_IsMinHeap\n            constructor\n            . apply IsSearchTree_findMin <;>\n              . rw[heqh.right] at h\u2082\n                cases h\u2082 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(\u03b9 : Type)\n[fintype : fintype \u03b9]\n[decidable_eq : decidable_eq \u03b9]\n(val : \u03b9 \u2192 C)\n\nattribute [instance] additive_envelope.fintype additive_envelope.decidable_eq\n\nvariables {C}\n\ndef dmatrix {X Y : additive_envelope C} (Z : X.\u03b9 \u2192 Y.\u03b9 \u2192 Type*) := \u03a0 (i : X.\u03b9) (j : Y.\u03b9), 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 (\u03bb i j, X.val i \u27f6 Y.val j)\n\nopen_locale big_operators\n\ninstance : category (additive_envelope C) :=\n{ hom := hom,\n  id := \u03bb X i j, if h : i = j then eq_to_hom (by subst h) else 0,\n  comp := \u03bb X Y Z f g i k, \u2211 (j : Y.\u03b9), f i j \u226b g j k,\n  id_comp' := sorry,\n  comp_id' := sorry,\n  assoc' := sorry, }\n\nvariables (C)\n\n@[simps]\ndef embedding : C \u2964 additive_envelope C :=\n{ obj := \u03bb X, \u27e8unit, \u03bb _, X\u27e9,\n  map := \u03bb 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 := \u03bb n,\n  { has_biproduct := \u03bb F, has_biproduct.mk\n    { bicone :=\n      { X :=\n        { \u03b9 := \u03a3 (j : fin n), (F j).\u03b9,\n          val := \u03bb p, (F p.1).val p.2 },\n        \u03b9 := sorry,\n        \u03c0 := sorry,\n        \u03b9_\u03c0 := 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 \u2964 D) : additive_envelope C \u2964 D :=\n{ obj := \u03bb X, \u2a01 (\u03bb 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 \u2964 D) : F \u2245 embedding C \u22d9 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} {\ud835\udd5c: Type} [nontrivially_normed_field \ud835\udd5c]\n[normed_add_comm_group E] [normed_space \ud835\udd5c 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 \u2190 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 \u2194 a=-b := \nby {split, intro f, rw\u2190 f,simp,\n    intro f, rw f,simp,}\n\nend tactic \n\nvariables {E : Type} \n[normed_add_comm_group E] [normed_space \u2102 E] [complete_space E] \n\n/-! Part O'. basic function \n\n- # Basic Function\n-/\n/-- The derivative of the inclusion \u211d \u2192 \u2102 is 1. --/\nlemma coe_has_deriv (x:\u211d ):\nhas_deriv_at (\u03bb (t : \u211d), (t : \u2102)) 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 \u211d (\u03bb (t : \u211d), (t : \u2102)):=\nbegin\n  intro x,\n  exact has_deriv_at.differentiable_at \n    (coe_has_deriv x),\nend\n\nlemma deriv_of_coe: deriv (\u03bb (x : \u211d), (x : \u2102)) = 1 :=\n deriv_eq coe_has_deriv\n\nlemma complex_affine_has_deriv (a b x:\u2102):\nhas_deriv_at (\u03bb (z : \u2102), a * z + b) a x :=\nbegin\n  apply has_deriv_at.add_const _ b,\n  have frw:(\u03bb (x : \u2102), a * x)=(\u03bb (x : \u2102), 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:\u2102):\ndifferentiable \u2102 (\u03bb (z : \u2102), 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 :\u2102)(x:\u211d):\nhas_deriv_at ((\u03bb x:\u211d, a*x+b):\u211d\u2192 \u2102) a x:=\nbegin\n  have func_eq:((\u03bb x:\u211d, a*x+b):\u211d\u2192 \u2102)= \n    ((\u03bb z:\u2102, a*z+b):\u2102\u2192 \u2102) \u2218 (\u03bb (t : \u211d), (t : \u2102)) :=\n    by {ext1, simp,},\n  have conc: has_deriv_at ((\u03bb (z : \u2102), a * z + b) \n    \u2218 \u03bb (t : \u211d), \u2191t) a x \u2194 has_deriv_at ((\u03bb (z : \u2102), \n    a * z + b) \u2218 \u03bb (t : \u211d), \u2191t) (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:\u2102):\ndifferentiable \u211d ((\u03bb x:\u211d, a*x+b):\u211d\u2192 \u2102):=\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:\u2102):\ncontinuous ((\u03bb x:\u211d, a*x+b):\u211d\u2192 \u2102):=\ndifferentiable.continuous (affine_rtc_differentiable a b)\n\nlemma complex_affine_inverse_has_deriv{a b x:\u2102}\n(h: a*x+b\u2260 0):\nhas_deriv_at ((\u03bb(t:\u2102), (a*t + b)\u207b\u00b9):\u2102\u2192 \u2102) \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 :\u2102}{x:\u211d}\n(h: a*x+b\u2260 0):\nhas_deriv_at ((\u03bb(t:\u211d), (a*t + b)\u207b\u00b9):\u211d\u2192 \u2102) \n(-a/(a*x+b)^2) x :=\nbegin\n  have func_rw:((\u03bb(t:\u211d), (a*t + b)\u207b\u00b9):\u211d\u2192 \u2102)=\n    ((\u03bb(t:\u2102), (a*t + b)\u207b\u00b9):\u2102\u2192 \u2102) \u2218 (\u03bb (t : \u211d), (t : \u2102)):=\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 :\u2102}{s: set \u211d}\n(h: \u2200(x:\u211d), x\u2208 s \u2192 a*x+b\u2260 0):\ndifferentiable_on \u211d ((\u03bb(t:\u211d), (a*t + b)\u207b\u00b9):\u211d\u2192 \u2102) 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 :\u2102}{s: set \u211d}\n(h: \u2200(x:\u211d), x\u2208 s \u2192 a*x+b\u2260 0):\ncontinuous_on ((\u03bb(t:\u211d), (a*t + b)\u207b\u00b9):\u211d\u2192 \u2102) s :=\ndifferentiable_on.continuous_on \n  (affine_rtc_differentiable_on h)\n\nlemma reciprocal_differentiable_on (c:\u2102):\ndifferentiable_on \u2102 (\u03bb (z : \u2102), (z - c)\u207b\u00b9) {c}\u1d9c :=\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:\u2102) :\ncontinuous_on (\u03bb (z : \u2102), (z - c)\u207b\u00b9) {c}\u1d9c :=\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:\u2102) (b:\u2102) : \u211d \u2192 \u2102 :=\n  \u03bb (\u03b8 : \u211d) , (b-a) * \u03b8 + a\n\n/-- The line sgement and circle are both continuously differentiable. --/\nlemma deriv_of_line (a:\u2102)(b:\u2102): \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:\u2102)(b:\u2102)(x : \u211d): \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 : \u2102) \u2022 (b - a : \u2102) := by simp,\n  rw h2,\n  have h1 : (\u03bb (x : \u211d), ((1 : \u2102) \u2022 (b - a) + 0) * \u2191x) = (\u03bb (x : \u2102), (b - a + 0) * x) \u2218 (\u03bb (x : \u211d), (x : \u2102)) := 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: (\u03bb (x' : \u2102), (b - a) * x' - \n      (b - a) * \u2191x - (x' - \u2191x) * (b - a)) = \n      (\u03bb(x:\u2102), (0:\u2102)) := 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:\u2102)(b:\u2102): \n  differentiable \u211d (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:\u2102 )(b:\u2102 ):\n  continuous (line_segment a b):=\n  by {exact differentiable.continuous (line_is_differentiable a b),}\n\nlemma line_is_continuous_on (a:\u2102 )(b:\u2102 ):\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:\u2102 )(b:\u2102):\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:\u2102)(b:\u2102):\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:\u2102 \u2192 E}{a b:\u2102}{M:\u211d}\n(hf: \u2200 z:\u2102, z \u2208 set.image (line_segment a b) \n(set.interval 0 1) \u2192 \u2225f z\u2225 \u2264 M):\n\u2225contour_integral f (line_segment a b)\u2225 \u2264 \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:\u211d)(b:\u211d)(r:\u211d):=\n  line_segment (l+b*complex.I) (r+b*complex.I)\ndef rec_right (b:\u211d)(r:\u211d)(t:\u211d):=\n  line_segment (r+b*complex.I) (r+t*complex.I)\ndef rec_top (r:\u211d)(t:\u211d)(l:\u211d):=\n  line_segment (r+t*complex.I) (l+t*complex.I)\ndef rec_left (t:\u211d)(l:\u211d)(b:\u211d):=\n  line_segment (l+t*complex.I) (l+b*complex.I)\n\n@[protected] lemma bottom_join_right (b:\u211d)(r:\u211d)(t:\u211d)(l:\u211d) : \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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d) :=\n  path_concatenation (bottom_join_right b r t l) \n\n@[protected] lemma top_join_left (b:\u211d)(r:\u211d)(t:\u211d)(l:\u211d) : \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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d) :=\n  path_concatenation (top_join_left b r t l) \n\n@[protected] lemma br_join_tl (b:\u211d)(r:\u211d)(t:\u211d)(l:\u211d) :\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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d) := \n  path_concatenation (br_join_tl b r t l) \n\nlemma center_in_interior_rectangle{c:\u2102}\n{b r t l:\u211d}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\nc \u2208 (set.Ioo l r \u00d7\u2102 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:\u2102}\n{b r t l:\u211d}: c \u2208 (set.Ioo l r \u00d7\u2102 set.Ioo b t) \u2194\n((l < c.re \u2227 c.re < r)\u2227 b < c.im \u2227 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:\u2102}\n{b r t l:\u211d}(bc: b \u2264 c.im) (ct: c.im \u2264 t)\n(lc: l \u2264 c.re) (cr: c.re \u2264 r):\nc \u2208 (set.interval l r \u00d7\u2102 set.interval b t) :=\nbegin \n  have bt:b\u2264 t:= le_trans bc ct,\n  have lr:l\u2264 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:\u211d): \nis_open (set.Ioo l r \u00d7\u2102 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:\u211d):\n(set.Ioo l r \u00d7\u2102 set.Ioo b t)\u2286 \n(set.interval l r \u00d7\u2102 set.interval b t) :=\nbegin\n  unfold set.re_prod_im,\n  have lr : set.Ioo l r \u2286 set.interval l r := \n    Ioo_subset_interval,\n  have bt : set.Ioo b t \u2286 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\u2208 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\u2208 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: \u2102}\n{b r t l:\u211d} (hin: c \u2208 (set.Ioo l r \u00d7\u2102 set.Ioo b t)):\n(set.Ioo l r \u00d7\u2102 set.Ioo b t) \u2208 (nhds c) :=\nbegin\n  rw mem_nhds_iff,\n  use (set.Ioo l r \u00d7\u2102 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: \u2102}\n{b r t l:\u211d}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\n(set.Ioo l r \u00d7\u2102 set.Ioo b t) \u2208 (nhds c) :=\n  interior_rectangle_neighborhood \n  (center_in_interior_rectangle bc ct lc cr)\n\nlemma closure_rectangle_neighborhood {c: \u2102}\n{b r t l:\u211d} (hin: c \u2208 (set.Ioo l r \u00d7\u2102 set.Ioo b t) ):\n(set.interval l r \u00d7\u2102 set.interval b t) \u2208 (nhds c) :=\nbegin\n  rw mem_nhds_iff,\n  use (set.Ioo l r \u00d7\u2102 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: \u2102}\n{b r t l:\u211d}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\n(set.interval l r \u00d7\u2102 set.interval b t) \u2208 (nhds c) :=\n  closure_rectangle_neighborhood \n  (center_in_interior_rectangle bc ct lc cr)\n\nlemma image_rec_bottom {l:\u211d}(b:\u211d){r:\u211d}(lr:l\u2264 r):\nset.image (rec_bottom l b r) (set.interval 0 1)\n\u2286  {z:\u2102 | l\u2264 z.re \u2227 z.re\u2264 r \u2227 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\u2264 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:\u211d}(r:\u211d){t:\u211d}(bt:b\u2264 t):\nset.image (rec_right b r t) (set.interval 0 1)\n\u2286  {z:\u2102 | b\u2264 z.im \u2227 z.im\u2264 t \u2227 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\u2264 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:\u211d}(t:\u211d){l:\u211d}(lr:l\u2264 r):\nset.image (rec_top r t l) (set.interval 0 1)\n\u2286  {z:\u2102 | l\u2264 z.re \u2227 z.re\u2264 r \u2227 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\u2264 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)\u2264 -((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:\u211d}(l:\u211d){b:\u211d}(bt:b\u2264 t):\nset.image (rec_left t l b) (set.interval 0 1)\n\u2286  {z:\u2102 | b\u2264 z.im \u2227 z.im\u2264 t \u2227 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\u2264 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)\u2264 -((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:\u211d}(bt: b\u2264 t)(lr: l\u2264 r):\nset.image (rectangle b r t l) (set.interval 0 1)=\n((set.image (rec_bottom l b r) (set.interval 0 1))\u222a \n(set.image (rec_right b r t) (set.interval 0 1))) \u222a \n((set.image (rec_top r t l) (set.interval 0 1))\u222a\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:\u211d}\n(bt: b\u2264 t)(lr: l\u2264 r):\nset.image (rectangle b r t l) (set.interval 0 1)\n\u2286 (set.interval l r \u00d7\u2102 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: \u2102}\n{b r t l:\u211d}(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) \u2286 {c}\u1d9c :=\nbegin\n  have bt: b\u2264 t:= le_of_lt (lt_trans bc ct),\n  have lr: l\u2264 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: \u2102}{b r t l:\u211d}(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) \u2286 \n(set.interval l r \u00d7\u2102 set.interval b t) \u2229 {c}\u1d9c :=\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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d):\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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d):\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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d):\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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d):\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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d):\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:\u211d)(r:\u211d)(t:\u211d)(l:\u211d):\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 (\u03b1:\u2102)(c:\u2102):\u2102\u2192 \u2102:=\u03bbz, \u03b1*z+c\n\nlemma contour_integral_under_affine (f:\u2102 \u2192 E)\n(L:\u211d \u2192 \u2102)(\u03b1:\u2102)(c:\u2102):\n  contour_integral f ((complex_affine \u03b1 c)\u2218 L) = \n  \u03b1 \u2022 contour_integral (f \u2218 (complex_affine \u03b1 c)) L :=\nbegin\n  repeat {rw contour_integral},\n  rw complex_affine,\n  simp,\n  rw smul_integral_convert,\n  have l1: (\u03bb t:\u211d, (\u03b1 * deriv L t) \u2022 f (\u03b1 * L t + c))\n    = (\u03bb t:\u211d, \u03b1 \u2022  deriv L t \u2022 f (\u03b1 * 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:\u2102 \u2192 E)(a:\u211d)(b:\u211d):\n  contour_integral f (line_segment a b) = \n  \u222b (t: \u211d ) in a..b, f(t):=\nbegin\n  unfold contour_integral,\n  rw [deriv_of_line, constant_path, line_segment],\n  simp,\n  have h0 : \u2191(b - a) = (b : \u2102) - (a : \u2102) := by simp,\n  rw \u2190h0,\n  cases decidable.em (b \u2260 a) with heq hneq,\n  {\n    have h1 : (\u03bb (x : \u211d), f (\u2191(b - a) * (x : \u2102) + (a : \u2102))) = (\u03bb (x : \u211d), ((f \u2218 \u03bb (y : \u211d), (y : \u2102)) ((b - a) * x + a))) := by simp,\n    have h2 : (\u03bb (t : \u211d), f (t : \u2102)) = (\u03bb (x : \u211d), ((f \u2218 \u03bb (y : \u211d), (y : \u2102)) x)) := by simp,\n    rw [h1, h2],\n    let g := (f \u2218 \u03bb (y : \u211d), (y : \u2102)),\n    have h3 : g = (f \u2218 \u03bb (y : \u211d), (y : \u2102)) := rfl,\n    rw [\u2190h3],\n    have h4 : \u222b (x : \u211d) in a..b, g x = \u222b (x : \u211d) in (b - a) * 0 + a..(b - a) * 1 + a, g x := by simp,\n    rw h4,\n    rw \u2190interval_integral.smul_integral_comp_mul_add g (b - a) a,\n    have h5 : \u222b (x : \u211d) in 0..1, g ((b - a) * x + a) = \u222b (x : \u211d) in 0..1, g ((b - a) * x + a) := rfl,\n    rw smul_type_convert (b-a) \u222b (x : \u211d) 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:\u2102 \u2192 E)(a:\u211d)(b:\u211d)(c:\u211d):\n  contour_integral f (line_segment (a+c*complex.I) (b+c*complex.I)) = \n  \u222b (t: \u211d) in a..b, f(t+c*complex.I) :=\nbegin\n  have hr: \u222b (t: \u211d) in a..b, f(t+c*complex.I) =\n    \u222b (t: \u211d) in a..b, (f\u2218 (complex_affine 1 (c*complex.I))) t:=\n    by {rw complex_affine,simp,},\n  have hl: (line_segment (\u2191a + \u2191c * complex.I) (\u2191b + \u2191c * complex.I))\n    = (complex_affine 1 (c*complex.I)) \u2218 (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:\u2102 \u2192 E)(a:\u211d)(b:\u211d)(c:\u211d):\n  contour_integral f (line_segment (c+a*complex.I) (c+b*complex.I)) = \n  complex.I \u2022 \u222b (t: \u211d) in a..b, f(c+t*complex.I) :=\nbegin\n  have hr: ((\u03bb t:\u211d, f (\u2191c + \u2191t * complex.I)):\u211d \u2192 E)\n  = ((\u03bbt:\u211d, (f \u2218 (complex_affine complex.I c)) t):\u211d\u2192 E) := \n    by {rw complex_affine, simp, ext1, ring_nf,},\n  have hl:(line_segment (\u2191c + \u2191a * complex.I) (\u2191c + \u2191b * complex.I))\n    = (complex_affine complex.I c) \u2218 (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:\u2102 \u2192 E)\n(l:\u211d)(b:\u211d)(r:\u211d):\n  contour_integral f (rec_bottom l b r) \n  = \u222b (x: \u211d) in l..r, f(x+b*complex.I) :=\n  integral_along_horizontal_line f l r b\n\nlemma integral_along_rectangle_right(f:\u2102 \u2192 E)\n(b:\u211d)(r:\u211d)(t:\u211d):\n  contour_integral f (rec_right b r t) \n  = complex.I \u2022 \u222b (x: \u211d) in b..t, f(r+x*complex.I) :=\n  integral_along_vertical_line f b t r\n\nlemma integral_along_rectangle_top(f:\u2102 \u2192 E)\n(r:\u211d)(t:\u211d)(l:\u211d):\n  contour_integral f (rec_top r t l) \n  = - \u222b (x: \u211d) 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:\u2102 \u2192 E)\n(t:\u211d)(l:\u211d)(b:\u211d):\n  contour_integral f (rec_left t l b) \n  = - complex.I \u2022 \u222b (x: \u211d) 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:\u2102 \u2192 E}{b r t l: \u211d}\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:\u2102 \u2192 E}{b r t l: \u211d}\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:\u2102 \u2192 E}{b r t l: \u211d}\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 \u2190 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 \u2190 add_assoc (contour_integral f (rec_bottom l b r)) _ _,\nend\n\ntheorem integral_along_rectangle\n{f:\u2102 \u2192 E}{b r t l: \u211d}\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  = (((\u222b (x: \u211d) in l..r, f(x+b*complex.I))\n  - (\u222b (x: \u211d) in l..r, f(x+t*complex.I)))\n  + (complex.I \u2022 \u222b (x: \u211d) in b..t, f(r+x*complex.I)))\n  - (complex.I \u2022 \u222b (x: \u211d) 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 : \u2102 \u2192 E} \n{b r t l:\u211d}(bt: b\u2264 t)(lr: l\u2264 r) \n{s: set \u2102}(hs: s.countable)\n(Hc : continuous_on f (set.interval l r \u00d7\u2102 set.interval b t)) \n(Hd : \u2200 (x : \u2102), x \u2208 (set.Ioo l r \u00d7\u2102 set.Ioo b t) \\ s \n\u2192 differentiable_at \u2102 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:\u2102:={re:=l,im:=b},\n  let w:\u2102:={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 [\u2190z_re, \u2190w_re], symmetry, exact min_eq_left lr,},\n  have hr : r = linear_order.max z.re w.re := \n    by {rw [\u2190z_re, \u2190w_re], symmetry, exact max_eq_right lr,},\n  have hb : b = linear_order.min z.im w.im := \n    by {rw [\u2190z_im, \u2190w_im], symmetry, exact min_eq_left bt,},\n  have ht : t = linear_order.max z.im w.im := \n    by {rw [\u2190z_im, \u2190w_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 : \u2102 \u2192 E} \n(c: \u2102) {b r t l:\u211d}(bt: b\u2264 t)(lr: l\u2264 r)\n(Hc : continuous_on f (set.interval l r \u00d7\u2102 set.interval b t)) \n(Hd : \u2200 (x : \u2102), x \u2208 (set.Ioo l r \u00d7\u2102 set.Ioo b t) \\ {c} \n\u2192 differentiable_at \u2102 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 : \u2102 \u2192 E} \n{b r t l:\u211d}(bt: b\u2264 t)(lr: l\u2264 r)\n(Hc : continuous_on f (set.interval l r \u00d7\u2102 \n  set.interval b t)) \n(Hd : \u2200 (x : \u2102), x \u2208 (set.Ioo l r \u00d7\u2102 set.Ioo b t) \n\u2192 differentiable_at \u2102 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 : \u2102 \u2192 E}{c: \u2102}\n{b r t l:\u211d}(bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\nset.eq_on (dslope f c) (\u03bbz:\u2102, (z-c)\u207b\u00b9\u2022f(z) - (z-c)\u207b\u00b9\u2022f(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:(\u03bbz:\u2102, (z-c)\u207b\u00b9\u2022f(z) - (z-c)\u207b\u00b9\u2022f(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 : \u2102 \u2192 E}{c: \u2102}\n{b r t l:\u211d}(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 \u00d7\u2102 set.interval b t))\n(Hd : differentiable_on \u2102 f (set.Ioo l r \u00d7\u2102 set.Ioo b t)):\ncontinuous_on (dslope f c) (set.interval l r \u00d7\u2102 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 : \u2102 \u2192 E}{c: \u2102}\n{b r t l:\u211d}(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 \u00d7\u2102 set.interval b t))\n(Hd : differentiable_on \u2102 f (set.Ioo l r \u00d7\u2102 set.Ioo b t)):\n\u2200 (x : \u2102), x \u2208 set.Ioo l r \u00d7\u2102 set.Ioo b t \\ {c} \u2192 \ndifferentiable_at \u2102 (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 : \u2102 \u2192 E} {c: \u2102}\n{b r t l:\u211d} (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 \u00d7\u2102 set.interval b t))\n(Hd : differentiable_on \u2102 f (set.Ioo l r \u00d7\u2102 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\u2264 t:= le_of_lt b_lt_t,\n  have lr: l\u2264 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 : \u2102 \u2192 E} {c: \u2102}\n{b r t l:\u211d} (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 \u00d7\u2102 set.interval b t)):\ncontinuous_on ((\u03bb (z : \u2102), (z - c)\u207b\u00b9) \u2022 f) \n(rectangle b r t l '' set.interval 0 1) :=\nbegin \n  have hr: continuous_on (\u03bb (z : \u2102), (z - c)\u207b\u00b9) \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 \u00d7\u2102 set.interval b t) \u2229 {c}\u1d9c\n  \u2286 (set.interval l r \u00d7\u2102 set.interval b t) := \n  (set.interval l r \u00d7\u2102 set.interval b t).inter_subset_left {c}\u1d9c,\n  have hf': continuous_on f \n    ((set.interval l r \u00d7\u2102 set.interval b t) \u2229 {c}\u1d9c) :=\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 : \u2102 \u2192 E} {c: \u2102}\n{b r t l:\u211d} (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 \u00d7\u2102 set.interval b t))\n(Hd : differentiable_on \u2102 f (set.Ioo l r \u00d7\u2102 set.Ioo b t)):\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9\u2022f(z)) (rectangle b r t l)=\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9) (rectangle b r t l) \u2022 f(c):=\nbegin\n  rw \u2190 contour_integral_smul_right _ _ (f(c)),\n  have func_eq:(\u03bbz:\u2102, (z-c)\u207b\u00b9\u2022f(z) - (z-c)\u207b\u00b9\u2022f(c))=\n  (\u03bbz:\u2102, (z-c)\u207b\u00b9\u2022f(z))-(\u03bbz:\u2102, (z-c)\u207b\u00b9\u2022f(c)):=\n    by {ext1, simp,},\n  have left_func:(\u03bb (z : \u2102), (z - c)\u207b\u00b9 \u2022 f z) =\n  (\u03bb (z : \u2102), (z - c)\u207b\u00b9) \u2022 f:=\n    by {ext1, simp,},\n  have right_func:(\u03bb (z : \u2102), (z - c)\u207b\u00b9 \u2022 f c) =\n  (\u03bb (z : \u2102), (z - c)\u207b\u00b9) \u2022 (\u03bb (z:\u2102), 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 ((\u03bb (z : \u2102), (z - c)\u207b\u00b9 \u2022 f z) - \n  \u03bb (z : \u2102), (z - c)\u207b\u00b9 \u2022 f c) (rectangle b r t l) = \n  contour_integral (\u03bb (z : \u2102), (z - c)\u207b\u00b9 \u2022 f z) (rectangle b r t l) - \n  contour_integral (\u03bb (z : \u2102), (z - c)\u207b\u00b9 \u2022 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:\u2102}{s:set \u211d}\n(ha: a \u2260 0)\n(h: \u2200 (x:\u211d), x\u2208 s\u2192 0 < (a*x+b).re \u2228 (a*x+b).im \u2260 0):\ncontinuous_on (\u03bb (t : \u211d), (a\u207b\u00b9*complex.log (a*t + b))) s:=\nbegin\n  apply continuous_on.const_smul _ a\u207b\u00b9,\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:\u2102}{x:\u211d}\n(ha: a \u2260 0)(h: 0 < (a*x+b).re \u2228 (a*x+b).im \u2260 0):\nhas_deriv_at (\u03bb (t : \u211d), (a\u207b\u00b9*complex.log (a*t + b)))\n((a*x+b)\u207b\u00b9) x :=\nbegin \n  have funrw: (\u03bb (t : \u211d), (a\u207b\u00b9*complex.log (a*t + b)))\n  =(\u03bb (t : \u211d), (complex.log (a*t + b))*a\u207b\u00b9):= \n    by {ext1, rw mul_comm,},\n  rw funrw,\n  have axbrw: (a*x+b)\u207b\u00b9 = (a*(a*x+b)\u207b\u00b9)*a\u207b\u00b9:=\n    by {rw mul_comm _ (a*x+b)\u207b\u00b9, rw mul_assoc,\n        have a':a * a\u207b\u00b9=1:= div_self ha,\n        rw a', ring_nf,},\n  rw axbrw,\n  apply has_deriv_at.mul_const _ a\u207b\u00b9,\n  let f:\u211d\u2192 \u2102:=\u03bbt:\u211d, (a*t+b),\n  have f_rw: (\u03bb (y : \u211d), complex.log (a * y + b))\n  =(\u03bb (t:\u211d), complex.log (f t)) :=\n    by {ext1, simp,},\n  have f'f_rw: (a * (a * \u2191x + b)\u207b\u00b9) = 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=(\u03bbt:\u2102, a*t+b) \u2218 (\u03bb (t : \u211d), (t : \u2102)):=\n    by {ext1, simp,},\n  rw coe_comp,\n  have conc:has_deriv_at ((\u03bb (t : \u2102), a * t + b) \u2218 \n    \u03bb (t : \u211d), \u2191t) a x \u2194 \n    has_deriv_at ((\u03bb (t : \u2102), a * t + b) \u2218 \n    \u03bb (t : \u211d), \u2191t) (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:\u2102}{lef ref:\u211d}\n(ha: a \u2260 0)(hlr: lef \u2264 ref)\n(h: \u2200 (x:\u211d), (x\u2208 (set.Ioo lef ref)) \u2192 \n0 < (a*x+b).re \u2228 (a*x+b).im \u2260 0)\n(hc:continuous_on  (\u03bb x : \u211d, a\u207b\u00b9 * complex.log (a * x + b)) \n(set.Icc lef ref))\n(hii: interval_integrable (\u03bb (y : \u211d), (a * \u2191y + b)\u207b\u00b9) \nmeasure_theory.measure_space.volume lef ref):\n\u222b (t: \u211d) in lef..ref, ((a*t+b)\u207b\u00b9) =\na\u207b\u00b9*(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:\u2102}{lef ref:\u211d}\n(ha: a \u2260 0)(hlr: lef \u2264 ref)\n(h: \u2200 (x:\u211d), (x\u2208 (set.Icc lef ref)) \u2192 \n0 < (a*x+b).re \u2228 (a*x+b).im \u2260 0):\n\u222b (t: \u211d) in lef..ref, ((a*t+b)\u207b\u00b9) =\na\u207b\u00b9*(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:\u2102}{lef ref:\u211d}\n(hlr: lef < ref)\n(h: \u2200 (x:\u211d), (x\u2208 (set.Icc lef ref)) \u2192 \n0 < ((x:\u2102)+b).re \u2228 ((x:\u2102)+b).im \u2260 0):\n\u222b (t: \u211d) in lef..ref, (((t:\u2102)+b)\u207b\u00b9) =\n(complex.log (ref + b)-complex.log(lef+b)) :=\nbegin\n  have one_ne_zero:(1:\u2102)\u2260 0:=by simp,\n  have hlr':lef\u2264 ref:= le_of_lt hlr,\n  have h':\u2200 (x:\u211d), (x\u2208 (set.Icc lef ref)) \u2192 \n    0 < ((1:\u2102)*x+b).re \u2228 ((1:\u2102)*x+b).im \u2260 0 :=\n    by {ring_nf,exact h,},\n  have lhs:\u222b (t: \u211d) in lef..ref, (((t:\u2102)+b)\u207b\u00b9) =\n  \u222b (t: \u211d) in lef..ref, (((1:\u2102)*t+b)\u207b\u00b9):= 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:\u2102}{lef ref:\u211d}\n(hlr: lef < ref)\n(h: \u2200 (x:\u211d), (x\u2208 (set.Ioo lef ref)) \u2192 \n0 < (complex.I*x+b:\u2102).re \u2228 (complex.I*x+b:\u2102).im \u2260 0)\n(hc:continuous_on  (\u03bb x : \u211d, complex.log (complex.I * x + b)) \n(set.Icc lef ref))\n(hii: interval_integrable (\u03bb (y : \u211d), (complex.I * y + b)\u207b\u00b9) \nmeasure_theory.measure_space.volume lef ref):\ncomplex.I \u2022 \u222b (t: \u211d) in lef..ref, ((complex.I*t+b:\u2102)\u207b\u00b9) =\n(complex.log (complex.I * ref + b)) -\n(complex.log (complex.I * lef + b)) :=\nbegin\n  have i_ne_zero:complex.I\u2260 0:=complex.I_ne_zero,\n  have hlr':lef\u2264 ref:= le_of_lt hlr,\n  have hc':continuous_on  (\u03bb x : \u211d, \n    (complex.I)\u207b\u00b9*complex.log (complex.I * x + b)) \n    (set.Icc lef ref):=\n      by { have hcm:=\n      continuous_on.const_smul hc (complex.I)\u207b\u00b9,\n      simp, simp at hcm, exact hcm,}, \n  rw integral_of_fraction' i_ne_zero hlr' h hc' hii,\n  simp, rw \u2190 mul_assoc, simp,\nend\n\nlemma integral_of_fraction_I{b:\u2102}{lef ref:\u211d}\n(hlr: lef < ref)\n(h: \u2200 (x:\u211d), (x\u2208 (set.Icc lef ref)) \u2192 \n0 < (x*complex.I+b:\u2102).re \u2228 (x*complex.I+b:\u2102).im \u2260 0):\ncomplex.I \u2022 \u222b (t: \u211d) in lef..ref, ((t*complex.I+b:\u2102)\u207b\u00b9) =\n(complex.log (ref*complex.I + b)) -\n(complex.log (lef*complex.I + b)) :=\nbegin\n  have i_ne_zero:complex.I\u2260 0:=complex.I_ne_zero,\n  have hlr':lef\u2264 ref:= le_of_lt hlr,\n  have h':\u2200 (x:\u211d), (x\u2208 (set.Icc lef ref)) \u2192 \n    0 < (complex.I*x+b).re \u2228 (complex.I*x+b).im \u2260 0 :=\n    by {ring_nf,exact h,},\n  have lhs:(\u03bbt:\u211d,(t*complex.I+b:\u2102)\u207b\u00b9) =\n    (\u03bbt:\u211d ,(complex.I*t+b)\u207b\u00b9):= \n    by {ext1,simp,rw mul_comm},\n  rw lhs, \n  rw integral_of_fraction i_ne_zero hlr' h',\n  simp, rw \u2190 mul_assoc, simp,\n  rw mul_comm, rw mul_comm \u2191lef complex.I,\nend\n\nlemma integral_of_reciprocal_on_bottom {c: \u2102}\n{l b r:\u211d} (bc: b < c.im) (lc: l < c.re) (cr: c.re < r):\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9) (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: (\u03bbx:\u211d,(\u2191x + \u2191b * complex.I - c)\u207b\u00b9)=\n  (\u03bbx:\u211d,(\u2191x + (\u2191b * complex.I - c))\u207b\u00b9) := \n    by {ext1, rw\u2190 add_sub,}, rw lhs,\n  repeat {rw \u2190 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: \u2102}\n{r t l:\u211d} (ct: c.im < t) (lc: l < c.re) (cr: c.re < r):\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9) (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: (\u03bbx:\u211d,(\u2191x + \u2191t * complex.I - c)\u207b\u00b9)=\n  (\u03bbx:\u211d,(\u2191x + (\u2191t * complex.I - c))\u207b\u00b9) := \n    by {ext1, rw\u2190 add_sub,}, rw lhs,\n  repeat {rw \u2190 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: \u2102}\n{b r t:\u211d} (bc: b < c.im) (ct: c.im < t) (cr: c.re < r) :\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9) (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: (\u03bbx:\u211d,(\u2191r + \u2191x * complex.I - c)\u207b\u00b9)=\n  (\u03bbx:\u211d,( \u2191x * complex.I +(\u2191r- c))\u207b\u00b9) := \n    by {ext1, ring_nf,}, rw lhs,\n  have rtc: \u2191r + \u2191t * complex.I - c =\n    \u2191t * complex.I+ (\u2191r-c):= by ring_nf,\n  have rbc: \u2191r + \u2191b * complex.I - c =\n    \u2191b * complex.I + (\u2191r - 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:\u2102}{t l b:\u211d}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ninterval_integrable (\u03bb (x : \u211d), \n(complex.I * \u2191x  + (\u2191l - c))\u207b\u00b9)\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 * \u2191x + (\u2191l - 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:\u2102}{t l b:\u211d}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ninterval_integrable (\u03bb (x : \u211d), \n(complex.I * \u2191x  + (\u2191l - c))\u207b\u00b9) \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:\u2102}{t l b:\u211d}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ninterval_integrable (\u03bb (x : \u211d), \n(complex.I * \u2191x  + (\u2191l - c))\u207b\u00b9) \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:\u2102}{t l b:\u211d}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9) (rec_left t l b) \n= -(complex.I \u2022 \u222b (x: \u211d) in (c.im)..t, (l+x*complex.I-c)\u207b\u00b9)\n- (complex.I \u2022 \u222b (x: \u211d) in b..(c.im), (l+x*complex.I-c)\u207b\u00b9):=\nbegin\n  rw integral_along_rectangle_left,\n  have lhs:-complex.I \u2022 \u222b (x : \u211d) in b..t, \n  (\u2191l + \u2191x * complex.I - c)\u207b\u00b9=-(complex.I \u2022 \n  \u222b (x : \u211d) in b..t, (\u2191l + \u2191x * complex.I - c)\u207b\u00b9):=\n    by {simp,}, rw lhs,\n  have fr: (\u03bb (x : \u211d), (\u2191l + \u2191x * complex.I - c)\u207b\u00b9)\n  =(\u03bb (x : \u211d), (complex.I * \u2191x  + (\u2191l - c))\u207b\u00b9) :=\n    by {ext1,simp,ring_nf,}, rw fr,\n  rw neg_rewrite, simp, symmetry,\n  rw \u2190 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:\u2102}{t l b:\u211d}\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):\u211d):= by simp,\n  rw cplx, \n  have l_sub:(((l-c.re):\u211d):\u2102)=-(((c.re-l):\u211d):\u2102):= by simp,\n  rw l_sub, rw complex.abs_neg,\n  have c_sub:c.re-l\u2265 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:\u2102}{t l b:\u211d}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\n\u2191l - \u2191(c.re)=complex.I*c.im+(l-c:\u2102) :=\nbegin\n  apply complex.ext,\n  simp, simp,\nend\n\n@[protected] lemma lcrearg{c:\u2102}{t l b:\u211d}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\n(l - (c.re):\u2102).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:\u2102}{t l b:\u211d}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\n\u222b (x: \u211d) in b..(c.im), (l+x*complex.I-c:\u2102)\u207b\u00b9=\n(complex.I)\u207b\u00b9 *(real.log(c.re-l)-real.pi*complex.I-\ncomplex.log (l+b*complex.I-c)) :=\nbegin\n  rw mul_sub,\n  have lhs:(\u03bbx:\u211d,(\u2191l + \u2191x * complex.I - c)\u207b\u00b9)=\n  (\u03bbx:\u211d,( complex.I * \u2191x + (l - c))\u207b\u00b9) := \n    by {ext1, simp, ring_nf,}, rw lhs,\n  have rhs: \u2191l + \u2191b * complex.I - c = \n    complex.I * \u2191b + (\u2191l - c) := by ring_nf, rw rhs,\n  let F:\u211d \u2192 \u2102:=\u03bb (x : \u211d), \n    ite (x=c.im) (complex.I\u207b\u00b9 * \n    (\u2191(real.log (c.re - l)) - \u2191real.pi * complex.I))\n    (complex.I\u207b\u00b9*complex.log (complex.I*x + (l-c))),\n  have Fx:\u2200x:\u211d, F x=ite (x=c.im) (complex.I\u207b\u00b9 * \n    (\u2191(real.log (c.re - l)) - \u2191real.pi * complex.I))\n    (complex.I\u207b\u00b9*complex.log (complex.I*x + (l-c))):=\n    by {intro x,exact rfl,},\n  have Fcim: F c.im = (complex.I\u207b\u00b9 * \n    (\u2191(real.log (c.re - l)) - \u2191real.pi * complex.I)):=\n    by {rw Fx c.im, simp,}, rw \u2190 Fcim,\n  have Fb: F b = complex.I\u207b\u00b9 * \n    complex.log (complex.I * \u2191b + (\u2191l - c)) :=\n    by {rw Fx b, rw if_neg (ne_of_lt bc),}, rw \u2190 Fb,\n  have F_eq_on_Ico: set.eq_on \n    (\u03bbx:\u211d, complex.I\u207b\u00b9*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\u2190 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: (\u03bb (x : \u211d), (\u03bb (x : \u211d), complex.I\u207b\u00b9 * \n      complex.log (complex.I * \u2191x + (\u2191l - c))) x) =\n      (\u03bb (x : \u211d), complex.I\u207b\u00b9 * \n      complex.log (complex.I * \u2191x + (\u2191l - c))):= by simp,\n      rw indu,\n      apply filter.tendsto.const_mul complex.I\u207b\u00b9,\n      have ftr:(\u03bb (k : \u211d), complex.log (complex.I * \u2191k + \n      (\u2191l - c)))= complex.log \u2218 (\u03bbk:\u211d, (complex.I * \u2191k + \n      (\u2191l - 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        (\u03bb (k : \u211d), complex.I * \u2191k + (\u2191l - c)),\n      rw lcre bc ct lc,\n      apply filter.tendsto.add_const (l-c:\u2102),\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\u2208 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\u2208 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 \u2190 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:\u2102}{t l b:\u211d}\n(bc: b < c.im) (ct: c.im < t) (lc: l < c.re):\ncomplex.I \u2022 \u222b (x: \u211d) in (c.im)..t, (l+x*complex.I-c:\u2102)\u207b\u00b9=\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: (\u2191(real.log (c.re - l)) \n    + \u2191real.pi * complex.I) = \n    complex.log ( complex.I * (c.im)+(l - c)) :=\n    by {rw \u2190 lcre bc ct lc,\n        unfold complex.log, rw\u2190 crel bc ct lc,\n        simp, left, rw\u2190 lcrearg bc ct lc,},\n  rw cc,\n  have lhs:(\u03bbx:\u211d,(\u2191l + \u2191x * complex.I - c)\u207b\u00b9)=\n  (\u03bbx:\u211d,( complex.I * \u2191x + (l - c))\u207b\u00b9) := \n    by {ext1, simp, ring_nf,}, rw lhs,\n  have rhs: \u2191l + \u2191t * complex.I - c = \n    complex.I * \u2191t + (\u2191l - 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: (\u03bb (x : \u211d), \n      complex.log (complex.I * \u2191x + (\u2191l - c))) = \n      (\u03bb(z:\u2102), complex.log z)\u2218 \n      (\u03bb(x:\u211d), (complex.I * \u2191x + (\u2191l - 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:\u2102)).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 * \u2191x + (\u2191l - 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: \u2102}\n{t l b:\u211d}(bc: b < c.im) (ct: c.im < t) (lc: l < c.re) :\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9) (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 \u2190 mul_assoc, simp, ring_nf,\nend\n\nlemma winding_number_of_rectangle {c: \u2102}\n{b r t l:\u211d} (bc: b < c.im) (ct: c.im < t)\n(lc: l < c.re) (cr: c.re < r):\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9) (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 : \u2102 \u2192 E} {c: \u2102}\n{b r t l:\u211d} (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 \u00d7\u2102 set.interval b t))\n(Hd : differentiable_on \u2102 f (set.Ioo l r \u00d7\u2102 set.Ioo b t)):\ncontour_integral (\u03bbz:\u2102, (z-c)\u207b\u00b9\u2022f(z)) (rectangle b r t l)=\n(2 * real.pi *complex.I :\u2102) \u2022 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 \u2964 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\u2081 v\u2082 u\u2081 u\u2082\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\u2081) : Type u\u2081 := V\n\ninstance (V : Type u\u2081) [inhabited V] : inhabited (paths V) := \u27e8(default : V)\u27e9\n\nvariables (V : Type u\u2081) [quiver.{v\u2081+1} V]\n\nnamespace paths\n\ninstance category_paths : category.{max u\u2081 v\u2081} (paths V) :=\n{ hom := \u03bb (X Y : V), quiver.path X Y,\n  id := \u03bb X, quiver.path.nil,\n  comp := \u03bb 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 \u2964q (paths V) :=\n{ obj := \u03bb X, X,\n  map := \u03bb 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] (\u03c6 : V \u2964q C) : paths V \u2964 C :=\n{ obj := \u03c6.obj,\n  map := \u03bb X Y f, @quiver.path.rec V _ X (\u03bb Y f, \u03c6.obj X \u27f6 \u03c6.obj Y) (\ud835\udfd9 $ \u03c6.obj X)\n                  (\u03bb Y Z p f ihp, ihp \u226b (\u03c6.map f)) Y f,\n  map_id' := \u03bb X, by { refl, },\n  map_comp' := \u03bb X Y Z f g, by\n  { induction g with _ _ g' p ih _ _ _,\n    { rw category.comp_id, refl, },\n    { have : f \u226b g'.cons p = (f \u226b 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] (\u03c6 : V \u2964q C) (X : V) :\n  (lift \u03c6).map (quiver.path.nil) = \ud835\udfd9 (\u03c6.obj X) := rfl\n\n@[simp] lemma lift_cons {C} [category C] (\u03c6 : V \u2964q C) {X Y Z : V}\n  (p : quiver.path X Y) (f : Y \u27f6 Z) :\n  (lift \u03c6).map (p.cons f) = (lift \u03c6).map p \u226b (\u03c6.map f) := rfl\n\n@[simp] lemma lift_to_path {C} [category C] (\u03c6 : V \u2964q C) {X Y : V} (f : X \u27f6 Y) :\n  (lift \u03c6).map f.to_path = \u03c6.map f := by {dsimp [quiver.hom.to_path,lift], simp, }\n\nlemma lift_spec {C} [category C] (\u03c6 : V \u2964q C) :\n  of \u22d9q (lift \u03c6).to_prefunctor = \u03c6 :=\nbegin\n  apply prefunctor.ext, rotate,\n  { rintro X, refl, },\n  { rintro X Y f, rcases \u03c6 with \u27e8\u03c6o,\u03c6m\u27e9,\n    dsimp [lift, quiver.hom.to_path],\n    simp only [category.id_comp], },\nend\n\nlemma lift_unique {C} [category C] (\u03c6 : V \u2964q C) (\u03a6 : paths V \u2964 C)\n  (h\u03a6 : of \u22d9q \u03a6.to_prefunctor = \u03c6) : \u03a6 = lift \u03c6 :=\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 \u22a2,\n      have : \u03a6.map (p.cons f') = \u03a6.map p \u226b (\u03a6.map (f'.to_path)), by\n      { convert functor.map_comp \u03a6 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 \u2964 C}\n  (h_obj : F.obj = G.obj)\n  (h : \u2200 (a b : V) (e : a \u27f6 b), F.map e.to_path =\n  eq_to_hom (congr_fun h_obj a) \u226b G.map e.to_path \u226b 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\u2082) [quiver.{v\u2082+1} W]\n\n-- A restatement of `prefunctor.map_path_comp` using `f \u226b g` instead of `f.comp g`.\n@[simp] lemma prefunctor.map_path_comp' (F : V \u2964q W) {X Y Z : paths V} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  F.map_path (f \u226b g) = (F.map_path f).comp (F.map_path g) :=\nprefunctor.map_path_comp _ _ _\n\nend\n\nsection\n\nvariables {C : Type u\u2081} [category.{v\u2081} 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} : \u03a0 {Y : C} (p : path X Y), X \u27f6 Y\n| _ path.nil := \ud835\udfd9 X\n| _ (path.cons p e) := compose_path p \u226b e\n\n@[simp]\nlemma compose_path_to_path {X Y : C} (f : X \u27f6 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 \u226b 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 \u27f6 Y) (g : Y \u27f6 Z) :\n  compose_path (f \u226b g) = compose_path f \u226b 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 \u2964 C :=\n{ obj := \u03bb X, X,\n  map := \u03bb 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\u03bb 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 \u2964 quotient (paths_hom_rel C) :=\n{ obj := \u03bb X, quotient.mk X,\n  map := \u03bb X Y f, quot.mk _ f.to_path,\n  map_id' := \u03bb X, quot.sound (quotient.comp_closure.of _ _ _ (by simp)),\n  map_comp' := \u03bb 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) \u2964 C :=\nquotient.lift _ (path_composition C) (\u03bb 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) \u224c C :=\n{ functor := quotient_paths_to C,\n  inverse := to_quotient_paths C,\n  unit_iso := nat_iso.of_components (\u03bb 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 (\u03bb 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 \u2964 D` for the type of all functors from `C` to `D`.\n(Unfortunately the `\u21d2` 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\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\u2081) [category.{v\u2081} C] (D : Type u\u2082) [category.{v\u2082} D]\n  extends prefunctor C D : Type (max v\u2081 v\u2082 u\u2081 u\u2082) :=\n(map_id'   : \u2200 (X : C), map (\ud835\udfd9 X) = \ud835\udfd9 (obj X) . obviously)\n(map_comp' : \u2200 {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z), map (f \u226b g) = (map f) \u226b (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 \u2964 a similar precedence to \u2192 (25).\n-- For example, `C \u00d7 D \u2964 E` should parse as `(C \u00d7 D) \u2964 E` not `C \u00d7 (D \u2964 E)`.\ninfixr ` \u2964 `: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\u2081) [category.{v\u2081} C]\n\n/-- `\ud835\udfed C` is the identity functor on a category `C`. -/\nprotected def id : C \u2964 C :=\n{ obj := \u03bb X, X,\n  map := \u03bb _ _ f, f }\n\nnotation `\ud835\udfed` := functor.id -- Type this as `\\sb1`\n\ninstance : inhabited (C \u2964 C) := \u27e8functor.id C\u27e9\n\nvariable {C}\n\n@[simp] lemma id_obj (X : C) : (\ud835\udfed C).obj X = X := rfl\n@[simp] lemma id_map {X Y : C} (f : X \u27f6 Y) : (\ud835\udfed C).map f = f := rfl\nend\n\nsection\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n          {D : Type u\u2082} [category.{v\u2082} D]\n          {E : Type u\u2083} [category.{v\u2083} E]\n\n/--\n`F \u22d9 G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\ndef comp (F : C \u2964 D) (G : D \u2964 E) : C \u2964 E :=\n{ obj := \u03bb X, G.obj (F.obj X),\n  map := \u03bb _ _ f, G.map (F.map f) }\n\ninfixr ` \u22d9 `:80 := comp\n\n@[simp] lemma comp_obj (F : C \u2964 D) (G : D \u2964 E) (X : C) : (F \u22d9 G).obj X = G.obj (F.obj X) := rfl\n@[simp] lemma comp_map (F : C \u2964 D) (G : D \u2964 E) {X Y : C} (f : X \u27f6 Y) :\n  (F \u22d9 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 \u2964 D) : F \u22d9 (\ud835\udfed D) = F := by cases F; refl\nprotected lemma id_comp (F : C \u2964 D) : (\ud835\udfed C) \u22d9 F = F := by cases F; refl\n\n@[simp] lemma map_dite (F : C \u2964 D) {X Y : C} {P : Prop} [decidable P]\n  (f : P \u2192 (X \u27f6 Y)) (g : \u00acP \u2192 (X \u27f6 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 \u27f6 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 \u27f6 Y`.\n-/\n@[simps]\ndef preadditiveYonedaObj (Y : C) : C\u1d52\u1d56 \u2964 ModuleCat.{v} (End Y)\n    where\n  obj X := ModuleCat.of _ (X.unop \u27f6 Y)\n  map X X' f :=\n    { toFun := fun g => f.unop \u226b 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 \u27f6 Y`. At each point, we get an additional `End Y`-module\nstructure, see `preadditive_yoneda_obj`.\n-/\n@[simps]\ndef preadditiveYoneda : C \u2964 C\u1d52\u1d56 \u2964 AddCommGroupCat.{v}\n    where\n  obj Y := preadditiveYonedaObj Y \u22d9 forget\u2082 _ _\n  map Y Y' f :=\n    { app := fun X =>\n        { toFun := fun g => g \u226b 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 \u27f6 Y`.\n-/\n@[simps]\ndef preadditiveCoyonedaObj (X : C\u1d52\u1d56) : C \u2964 ModuleCat.{v} (End X)\n    where\n  obj Y := ModuleCat.of _ (unop X \u27f6 Y)\n  map Y Y' f :=\n    { toFun := fun g => g \u226b 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 \u27f6 Y`. At each point, we get an additional `End X`-module\nstructure, see `preadditive_coyoneda_obj`.\n-/\n@[simps]\ndef preadditiveCoyoneda : C\u1d52\u1d56 \u2964 C \u2964 AddCommGroupCat.{v}\n    where\n  obj X := preadditiveCoyonedaObj X \u22d9 forget\u2082 _ _\n  map X X' f :=\n    { app := fun Y =>\n        { toFun := fun g => f.unop \u226b 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\u1d52\u1d56) : Functor.Additive (preadditiveCoyonedaObj X) where\n#align category_theory.additive_coyoneda_obj CategoryTheory.additive_coyoneda_obj\n\ninstance additive_coyoneda_obj' (X : C\u1d52\u1d56) : 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 \u22d9\n        (whiskeringRight C\u1d52\u1d56 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 \u22d9\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 \u2964 C\u1d52\u1d56 \u2964 AddCommGroupCat) :=\n  let yoneda_full :\n    Full\n      (preadditiveYoneda \u22d9\n        (whiskeringRight C\u1d52\u1d56 AddCommGroupCat (Type v)).obj (forget AddCommGroupCat)) :=\n    Yoneda.yonedaFull\n  full.of_comp_faithful preadditive_yoneda\n    ((whiskering_right C\u1d52\u1d56 AddCommGroupCat (Type v)).obj (forget AddCommGroupCat))\n#align category_theory.preadditive_yoneda_full CategoryTheory.preadditiveYonedaFull\n\ninstance preadditiveCoyonedaFull : Full (preadditiveCoyoneda : C\u1d52\u1d56 \u2964 C \u2964 AddCommGroupCat) :=\n  let coyoneda_full :\n    Full\n      (preadditiveCoyoneda \u22d9\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 \u2964 C\u1d52\u1d56 \u2964 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\u1d52\u1d56 \u2964 C \u2964 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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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) \u224c 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] {\u03b9 : Type _} {c : ComplexShape \u03b9}\n\nnamespace Idempotents\n\nnamespace Karoubi\n\nnamespace HomologicalComplex\n\nvariable {P Q : Karoubi (HomologicalComplex C c)} (f : P \u27f6 Q) (n : \u03b9)\n\n@[simp, reassoc.1]\ntheorem p_comp_d : P.p.f n \u226b 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 \u226b 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 \u226b f.f.f n = f.f.f n \u226b 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 \u226b 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) \u2964 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    \u27e8P.pt.pt n, P.p.f n, by\n      simpa only [HomologicalComplex.comp_f] using HomologicalComplex.congr_hom P.idem n\u27e9\n  d i j :=\n    { f := P.p.f i \u226b 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) \u2964 homological_complex (karoubi C) c`,\non morphisms. -/\n@[simps]\ndef map {P Q : Karoubi (HomologicalComplex C c)} (f : P \u27f6 Q) : obj P \u27f6 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) \u2964 homological_complex (karoubi C) c`. -/\n@[simps]\ndef functor : Karoubi (HomologicalComplex C c) \u2964 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 \u2964 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 \u2964 karoubi (homological_complex C c)`,\non morphisms -/\n@[simps]\ndef map {K L : HomologicalComplex (Karoubi C) c} (f : K \u27f6 L) : obj K \u27f6 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 \u2964 karoubi (homological_complex C c)`. -/\n@[simps]\ndef inverse : HomologicalComplex (Karoubi C) c \u2964 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) \u224c homological_complex (karoubi C) c`. -/\n@[simps]\ndef counitIso : inverse \u22d9 functor \u2245 \ud835\udfed (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) \u224c homological_complex (karoubi C) c`. -/\n@[simps]\ndef unitIso : \ud835\udfed (Karoubi (HomologicalComplex C c)) \u2245 functor \u22d9 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 \u03c6 => 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 \u03c6 => 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) \u224c homological_complex (karoubi C) c`. -/\n@[simps]\ndef karoubiHomologicalComplexEquivalence :\n    Karoubi (HomologicalComplex C c) \u224c 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 (\u03b1 : Type _) [AddRightCancelSemigroup \u03b1] [One \u03b1]\n\n/-- The equivalence `karoubi (chain_complex C \u03b1) \u224c chain_complex (karoubi C) \u03b1`. -/\n@[simps]\ndef karoubiChainComplexEquivalence : Karoubi (ChainComplex C \u03b1) \u224c ChainComplex (Karoubi C) \u03b1 :=\n  karoubiHomologicalComplexEquivalence C (ComplexShape.down \u03b1)\n#align category_theory.idempotents.karoubi_chain_complex_equivalence CategoryTheory.Idempotents.karoubiChainComplexEquivalence\n\n/-- The equivalence `karoubi (cochain_complex C \u03b1) \u224c cochain_complex (karoubi C) \u03b1`. -/\n@[simps]\ndef karoubiCochainComplexEquivalence :\n    Karoubi (CochainComplex C \u03b1) \u224c CochainComplex (Karoubi C) \u03b1 :=\n  karoubiHomologicalComplexEquivalence C (ComplexShape.up \u03b1)\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    \u2190 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 : \u03a0 (e : sym2 V), \n  e \u2208 G.edge_set \u2192 \u21a5(finset.powerset_len 2 (finset.univ : finset V)) :=\n\u03bb e, \u03bb e_in, \n\u27e8 sym2.lift \u27e8\u03bb v\u2081 v\u2082 : V, ({v\u2081, v\u2082} : finset V), \n    \u03bb v\u2081 v\u2082 : V, finset.insert.comm v\u2081 v\u2082 \u2205\u27e9 e,\n  begin\n    revert e,\n    rw sym2.forall,\n    unfold simple_graph.edge_set,\n    intros v\u2081 v\u2082,\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\u2081_ne_v\u2082 : v\u2081 \u2260 v\u2082,\n    { intro x_eq_y,\n      rw x_eq_y at h_adj,\n      exact G.loopless v\u2082 h_adj, },\n    exact \u27e8finset.subset_univ {v\u2081, v\u2082}, \u27e8v\u2081, v\u2082, v\u2081_ne_v\u2082, rfl\u27e9\u27e9,\n  end \u27e9\n\nlemma edge_to_finset_powerset_len_two_inj : \u2200 e\u2081 e\u2082 e\u2081_in e\u2082_in,\n  G.edge_to_finset_powerset_len_two e\u2081 e\u2081_in = \n    G.edge_to_finset_powerset_len_two e\u2082 e\u2082_in \u2192 \n  e\u2081 = e\u2082 :=\nbegin\n  rw sym2.forall,\n  intros v\u2081 v\u2082,\n  rw sym2.forall,\n  intros v\u2081' v\u2082',\n  intros e\u2081_in e\u2082_in h_eq,\n  apply sym2.ext,\n  rw \u2190 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 (\u2208 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 (\u2208 G'.verts)] :\ndecidable_pred (\u2208 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 \u2286 G.edge_finset := \nbegin\n  unfold edge_finset,\n  unfold simple_graph.edge_finset,\n  rw \u2190 set.subset_iff_to_finset_subset,\n  exact G'.edge_set_subset,\nend\n\ndef edge_to_finset_powerset_len_two [decidable_pred (\u2208 G'.verts)] : \u03a0 (e : sym2 V), \n  e \u2208 G'.edge_set \u2192 \u21a5(finset.powerset_len 2 G'.verts.to_finset) :=\n\u03bb e, \u03bb e_in,\n\u27e8 sym2.lift \u27e8\u03bb v\u2081 v\u2082 : V, ({v\u2081, v\u2082} : finset V), \n    \u03bb v\u2081 v\u2082 : V, finset.insert.comm v\u2081 v\u2082 \u2205\u27e9 e,\n  begin\n    revert e,\n    rw sym2.forall,\n    unfold simple_graph.subgraph.edge_set,\n    intros v\u2081 v\u2082,\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\u2081_ne_v\u2082 : v\u2081 \u2260 v\u2082,\n    { intro v\u2081_eq_v\u2082,\n      rw v\u2081_eq_v\u2082 at h_adj,\n      exact G'.loopless v\u2082 h_adj, },\n    have h_subset : {v\u2081, v\u2082} \u2286 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 \u27e8G'.edge_vert h_adj, G'.edge_vert (G'.symm h_adj)\u27e9, },\n    exact \u27e8h_subset, \u27e8v\u2081, v\u2082, v\u2081_ne_v\u2082, rfl\u27e9\u27e9,\n  end \u27e9\n\ndef edge_to_finset_powerset_len_two_inj [decidable_pred (\u2208 G'.verts)] : \u2200 e\u2081 e\u2082 e\u2081_in e\u2082_in,\n  G'.edge_to_finset_powerset_len_two e\u2081 e\u2081_in = \n    G'.edge_to_finset_powerset_len_two e\u2082 e\u2082_in \u2192 \n  e\u2081 = e\u2082 :=\nbegin\n  rw sym2.forall,\n  intros v\u2081 v\u2082,\n  rw sym2.forall,\n  intros v\u2081' v\u2082',\n  intros e\u2081_in e\u2082_in h_eq,\n  apply sym2.ext,\n  rw \u2190 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\u2081 v\u2082 u\u2081 u\u2082 -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u\u2081} [category.{v\u2081} 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 (\ud835\udfed T) X\n\n-- Satisfying the inhabited linter\ninstance over.inhabited [inhabited T] : inhabited (over (default : T)) :=\n{ default :=\n  { left := default,\n    hom := \ud835\udfd9 _ } }\n\nnamespace over\n\nvariables {X : T}\n\n@[ext] lemma over_morphism.ext {X : T} {U V : over X} {f g : U \u27f6 V}\n  (h : f.left = g.left) : f = g :=\nby tidy\n\n@[simp] lemma over_right (U : over X) : U.right = \u27e8\u27e8\u27e9\u27e9 := by tidy\n\n@[simp] lemma id_left (U : over X) : comma_morphism.left (\ud835\udfd9 U) = \ud835\udfd9 U.left := rfl\n@[simp] lemma comp_left (a b c : over X) (f : a \u27f6 b) (g : b \u27f6 c) :\n  (f \u226b g).left = f.left \u226b g.left := rfl\n\n@[simp, reassoc] lemma w {A B : over X} (f : A \u27f6 B) : f.left \u226b 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 V.left) (w : f \u226b V.hom = U.hom . obviously) :\n  U \u27f6 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 \u2245 g.left) (hw : hl.hom \u226b g.hom = f.hom . obviously) :\n  f \u2245 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 \u2964 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 \u27f6 V} : (forget X).map f = f.left := rfl\n\n/-- The natural cocone over the forgetful functor `over X \u2964 T` with cocone point `X`. -/\n@[simps] def forget_cocone (X : T) : limits.cocone (forget X) :=\n{ X := X, \u03b9 := { app := comma.hom } }\n\n/--\nA morphism `f : X \u27f6 Y` induces a functor `over X \u2964 over Y` in the obvious way.\n\nSee <https://stacks.math.columbia.edu/tag/001G>.\n-/\ndef map {Y : T} (f : X \u27f6 Y) : over X \u2964 over Y := comma.map_right _ $ discrete.nat_trans (\u03bb _, f)\n\nsection\nvariables {Y : T} {f : X \u27f6 Y} {U V : over X} {g : U \u27f6 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 \u226b 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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f \u226b g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map f \u22d9 map g :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := \u03bb Y Z f t, by exactI\n  \u27e8\u27e8over.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\u27e9\u27e9 }\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 \u27f6 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 \u27f6 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 \u27f6 g) [mono k] : mono k.left :=\nbegin\n  refine \u27e8\u03bb (Y : T) l m a, _\u27e9,\n  let l' : mk (m \u226b f.hom) \u27f6 f := hom_mk l (by { dsimp, rw [\u2190over.w k, reassoc_of a] }),\n  suffices : l' = hom_mk m,\n  { apply congr_arg comma_morphism.left this },\n  rw \u2190 cancel_mono k,\n  ext,\n  apply a,\nend\n\nsection iterated_slice\nvariables (f : over X)\n\n/-- Given f : Y \u27f6 X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iterated_slice_forward : over f \u2964 over f.left :=\n{ obj := \u03bb \u03b1, over.mk \u03b1.hom.left,\n  map := \u03bb \u03b1 \u03b2 \u03ba, over.hom_mk \u03ba.left.left (by { rw auto_param_eq, rw \u2190 over.w \u03ba, refl }) }\n\n/-- Given f : Y \u27f6 X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iterated_slice_backward : over f.left \u2964 over f :=\n{ obj := \u03bb g, mk (hom_mk g.hom : mk (g.hom \u226b f.hom) \u27f6 f),\n  map := \u03bb g h \u03b1, hom_mk (hom_mk \u03b1.left (w_assoc \u03b1 f.hom)) (over_morphism.ext (w \u03b1)) }\n\n/-- Given f : Y \u27f6 X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iterated_slice_equiv : over f \u224c over f.left :=\n{ functor := iterated_slice_forward f,\n  inverse := iterated_slice_backward f,\n  unit_iso :=\n    nat_iso.of_components\n    (\u03bb g, over.iso_mk (over.iso_mk (iso.refl _) (by tidy)) (by tidy))\n    (\u03bb X Y g, by { ext, dsimp, simp }),\n  counit_iso :=\n    nat_iso.of_components\n    (\u03bb g, over.iso_mk (iso.refl _) (by tidy))\n    (\u03bb X Y g, by { ext, dsimp, simp }) }\n\nlemma iterated_slice_forward_forget :\n  iterated_slice_forward f \u22d9 forget f.left = forget f \u22d9 forget X :=\nrfl\n\nlemma iterated_slice_backward_forget_forget :\n  iterated_slice_backward f \u22d9 forget f \u22d9 forget X = forget f.left :=\nrfl\n\nend iterated_slice\n\nsection\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `F : T \u2964 D` induces a functor `over X \u2964 over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T \u2964 D) : over X \u2964 over (F.obj X) :=\n{ obj := \u03bb Y, mk $ F.map Y.hom,\n  map := \u03bb Y\u2081 Y\u2082 f,\n  { left := F.map f.left,\n    w' := by tidy; erw [\u2190 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 (\ud835\udfed T)\n\n-- Satisfying the inhabited linter\ninstance under.inhabited [inhabited T] : inhabited (under (default : T)) :=\n{ default :=\n  { right := default,\n    hom := \ud835\udfd9 _ } }\n\nnamespace under\n\nvariables {X : T}\n\n@[ext] lemma under_morphism.ext {X : T} {U V : under X} {f g : U \u27f6 V}\n  (h : f.right = g.right) : f = g :=\nby tidy\n\n@[simp] lemma under_left (U : under X) : U.left = \u27e8\u27e8\u27e9\u27e9 := by tidy\n\n@[simp] lemma id_right (U : under X) : comma_morphism.right (\ud835\udfd9 U) = \ud835\udfd9 U.right := rfl\n@[simp] lemma comp_right (a b c : under X) (f : a \u27f6 b) (g : b \u27f6 c) :\n  (f \u226b g).right = f.right \u226b g.right := rfl\n\n@[simp, reassoc] lemma w {A B : under X} (f : A \u27f6 B) : A.hom \u226b 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 \u27f6 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 \u27f6 V.right) (w : U.hom \u226b f = V.hom . obviously) :\n  U \u27f6 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 \u2245 g.right) (hw : f.hom \u226b hr.hom = g.hom) : f \u2245 g :=\nstructured_arrow.iso_mk hr hw\n\n@[simp]\nlemma iso_mk_hom_right {f g : under X} (hr : f.right \u2245 g.right) (hw : f.hom \u226b 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 \u2245 g.right) (hw : f.hom \u226b 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 \u2964 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 \u27f6 V} : (forget X).map f = f.right := rfl\n\n/-- The natural cone over the forgetful functor `under X \u2964 T` with cone point `X`. -/\n@[simps] def forget_cone (X : T) : limits.cone (forget X) :=\n{ X := X, \u03c0 := { app := comma.hom } }\n\n/-- A morphism `X \u27f6 Y` induces a functor `under Y \u2964 under X` in the obvious way. -/\ndef map {Y : T} (f : X \u27f6 Y) : under Y \u2964 under X := comma.map_left _ $ discrete.nat_trans (\u03bb _, f)\n\nsection\nvariables {Y : T} {f : X \u27f6 Y} {U V : under Y} {g : U \u27f6 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 \u226b 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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f \u226b g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map g \u22d9 map f :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := \u03bb Y Z f t, by exactI\n  \u27e8\u27e8under.hom_mk (inv ((under.forget X).map f)) ((is_iso.comp_inv_eq _).2 (under.w f).symm),\n    by tidy\u27e9\u27e9 }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\nsection\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `F : T \u2964 D` induces a functor `under X \u2964 under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T \u2964 D) : under X \u2964 under (F.obj X) :=\n{ obj := \u03bb Y, mk $ F.map Y.hom,\n  map := \u03bb Y\u2081 Y\u2082 f,\n  { right := F.map f.right,\n    w' := by tidy; erw [\u2190 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 \u2192 A j \u2192 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 (`\u2022`) 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 \u2208 A i` for some `i : \u03b9`)\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 {\u03b9 : Type*}\n\n/-- A type alias of sigma types for graded monoids. -/\ndef graded_monoid (A : \u03b9 \u2192 Type*) := sigma A\n\nnamespace graded_monoid\n\ninstance {A : \u03b9 \u2192 Type*} [inhabited \u03b9] [inhabited (A default)]: inhabited (graded_monoid A) :=\nsigma.inhabited\n\n/-- Construct an element of a graded monoid. -/\ndef mk {A : \u03b9 \u2192 Type*} : \u03a0 i, A i \u2192 graded_monoid A := sigma.mk\n\n/-! ### Typeclasses -/\nsection defs\n\nvariables (A : \u03b9 \u2192 Type*)\n\n/-- A graded version of `has_one`, which must be of grade 0. -/\nclass ghas_one [has_zero \u03b9] :=\n(one : A 0)\n\n/-- `ghas_one` implies `has_one (graded_monoid A)` -/\ninstance ghas_one.to_has_one [has_zero \u03b9] [ghas_one A] : has_one (graded_monoid A) :=\n\u27e8\u27e8_, ghas_one.one\u27e9\u27e9\n\n/-- A graded version of `has_mul`. Multiplication combines grades additively, like\n`add_monoid_algebra`. -/\nclass ghas_mul [has_add \u03b9] :=\n(mul {i j} : A i \u2192 A j \u2192 A (i + j))\n\n/-- `ghas_mul` implies `has_mul (graded_monoid A)`. -/\ninstance ghas_mul.to_has_mul [has_add \u03b9] [ghas_mul A] :\n  has_mul (graded_monoid A) :=\n\u27e8\u03bb (x y : graded_monoid A), \u27e8_, ghas_mul.mul x.snd y.snd\u27e9\u27e9\n\nlemma mk_mul_mk [has_add \u03b9] [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 \u03b9] [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 : \u03a0 (n : \u2115) {i}, A i \u2192 A (n \u2022 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 : \u2115) (a : graded_monoid A) :\n  (graded_monoid.mk _ $ gnpow_rec n.succ a.snd) = a * \u27e8_, gnpow_rec n a.snd\u27e9 :=\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 \u03b9]  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 : \u03a0 (n : \u2115) {i}, A i \u2192 A (n \u2022 i) := gmonoid.gnpow_rec)\n(gnpow_zero' : \u03a0 (a : graded_monoid A), graded_monoid.mk _ (gnpow 0 a.snd) = 1\n  . gmonoid.apply_gnpow_rec_zero_tac)\n(gnpow_succ' : \u03a0 (n : \u2115) (a : graded_monoid A),\n  (graded_monoid.mk _ $ gnpow n.succ a.snd) = a * \u27e8_, gnpow n a.snd\u27e9\n  . gmonoid.apply_gnpow_rec_succ_tac)\n\n/-- `gmonoid` implies a `monoid (graded_monoid A)`. -/\ninstance gmonoid.to_monoid [add_monoid \u03b9] [gmonoid A] :\n  monoid (graded_monoid A) :=\n{ one := (1), mul := (*),\n  npow := \u03bb n a, graded_monoid.mk _ (gmonoid.gnpow n a.snd),\n  npow_zero' := \u03bb a, gmonoid.gnpow_zero' a,\n  npow_succ' := \u03bb 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 \u03b9] [gmonoid A] {i} (a : A i) (n : \u2115) :\n  mk i a ^ n = mk (n \u2022 i) (gmonoid.gnpow _ a) :=\nbegin\n  induction n with n,\n  { rw [pow_zero],\n    exact (gmonoid.gnpow_zero' \u27e8_, a\u27e9).symm, },\n  { rw [pow_succ, n_ih, mk_mul_mk],\n    exact (gmonoid.gnpow_succ' n \u27e8_, a\u27e9).symm, },\nend\n\n/-- A graded version of `comm_monoid`. -/\nclass gcomm_monoid [add_comm_monoid \u03b9] 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 \u03b9] [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 : \u03b9 \u2192 Type*)\n\nsection one\nvariables [has_zero \u03b9] [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\u27e8ghas_one.one\u27e9\n\nend one\n\nsection mul\nvariables [add_zero_class \u03b9] [ghas_mul A]\n\n/-- `(\u2022) : A 0 \u2192 A i \u2192 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 : \u03b9) : has_scalar (A 0) (A i) :=\n{ smul := \u03bb x y, (zero_add i).rec (ghas_mul.mul x y) }\n\n/-- `(*) : A 0 \u2192 A 0 \u2192 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 := (\u2022) }\n\nvariables {A}\n\n@[simp] lemma mk_zero_smul {i} (a : A 0) (b : A i) : mk _ (a \u2022 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 \u2022 b = a * b := rfl\n\n\nend mul\n\nsection monoid\nvariables [add_monoid \u03b9] [gmonoid A]\n\ninstance : has_pow (A 0) \u2115 :=\n{ pow := \u03bb x n, (nsmul_zero n).rec (gmonoid.gnpow n x : A (n \u2022 0)) }\n\nvariables {A}\n\n@[simp] lemma mk_zero_pow (a : A 0) (n : \u2115) : 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 \u03b9] [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 \u03b9] [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 \u2192* (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 {\u03b1 : Type*} {A : \u03b9 \u2192 Type*} [add_monoid \u03b9] [graded_monoid.gmonoid A]\n\n/-- The index used by `list.dprod`. Propositionally this is equal to `(l.map f\u03b9).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 \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) : \u03b9 :=\nl.foldr (\u03bb i b, f\u03b9 i + b) 0\n\n@[simp] lemma list.dprod_index_nil (f\u03b9 : \u03b1 \u2192 \u03b9) : ([] : list \u03b1).dprod_index f\u03b9 = 0 := rfl\n@[simp] lemma list.dprod_index_cons (a : \u03b1) (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) :\n  (a :: l).dprod_index f\u03b9 = f\u03b9 a + l.dprod_index f\u03b9 := rfl\n\nlemma list.dprod_index_eq_map_sum (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) :\n  l.dprod_index f\u03b9 = (l.map f\u03b9).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 \u03b1`, this computes the product of `fA a` over `a`, where each `fA` is of type\n`A (f\u03b9 a)`. -/\ndef list.dprod (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) :\n  A (l.dprod_index f\u03b9) :=\nl.foldr_rec_on _ _ graded_monoid.ghas_one.one (\u03bb i x a ha, graded_monoid.ghas_mul.mul (fA a) x)\n\n@[simp] lemma list.dprod_nil (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) :\n  (list.nil : list \u03b1).dprod f\u03b9 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\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) (a : \u03b1) (l : list \u03b1) :\n  (a :: l).dprod f\u03b9 fA = (graded_monoid.ghas_mul.mul (fA a) (l.dprod f\u03b9 fA) : _) := rfl\n\nlemma graded_monoid.mk_list_dprod (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) :\n  graded_monoid.mk _ (l.dprod f\u03b9 fA) = (l.map (\u03bb a, graded_monoid.mk (f\u03b9 a) (fA a))).prod :=\nbegin\n  induction l,\n  { simp, refl  },\n  { simp [\u2190l_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 \u03b1) (f : \u03b1 \u2192 graded_monoid A) :\n  (l.map f).prod = graded_monoid.mk _ (l.dprod (\u03bb i, (f i).1) (\u03bb 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 : \u2115} (f : fin n \u2192 graded_monoid A) :\n  (list.of_fn f).prod =\n    graded_monoid.mk _ ((list.fin_range n).dprod (\u03bb i, (f i).1) (\u03bb 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 (\u03b9) {R : Type*}\n\n@[simps one]\ninstance has_one.ghas_one [has_zero \u03b9] [has_one R] : graded_monoid.ghas_one (\u03bb i : \u03b9, R) :=\n{ one := 1 }\n\n@[simps mul]\ninstance has_mul.ghas_mul [has_add \u03b9] [has_mul R] : graded_monoid.ghas_mul (\u03bb i : \u03b9, R) :=\n{ mul := \u03bb 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 \u03b9] [monoid R] : graded_monoid.gmonoid (\u03bb i : \u03b9, R) :=\n{ one_mul := \u03bb a, sigma.ext (zero_add _) (heq_of_eq (one_mul _)),\n  mul_one := \u03bb a, sigma.ext (add_zero _) (heq_of_eq (mul_one _)),\n  mul_assoc := \u03bb a b c, sigma.ext (add_assoc _ _ _) (heq_of_eq (mul_assoc _ _ _)),\n  gnpow := \u03bb n i a, a ^ n,\n  gnpow_zero' := \u03bb a, sigma.ext (zero_nsmul _) (heq_of_eq (monoid.npow_zero' _)),\n  gnpow_succ' := \u03bb n \u27e8i, a\u27e9, sigma.ext (succ_nsmul _ _) (heq_of_eq (monoid.npow_succ' _ _)),\n  ..has_one.ghas_one \u03b9,\n  ..has_mul.ghas_mul \u03b9 }\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 \u03b9] [comm_monoid R] :\n  graded_monoid.gcomm_monoid (\u03bb i : \u03b9, R) :=\n{ mul_comm := \u03bb a b, sigma.ext (add_comm _ _) (heq_of_eq (mul_comm _ _)),\n  ..monoid.gmonoid \u03b9 }\n\n/-- When all the indexed types are the same, the dependent product is just the regular product. -/\n@[simp] lemma list.dprod_monoid {\u03b1} [add_monoid \u03b9] [monoid R] (l : list \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9)\n  (fA : \u03b1 \u2192 R) :\n  (l.dprod f\u03b9 fA : (\u03bb i : \u03b9, 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 \u03b9]\n  (A : \u03b9 \u2192 S) : Prop :=\n(one_mem : (1 : R) \u2208 A 0)\n\ninstance set_like.ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.has_graded_one A] : graded_monoid.ghas_one (\u03bb i, A i) :=\n{ one := \u27e81, set_like.has_graded_one.one_mem\u27e9 }\n\n@[simp] lemma set_like.coe_ghas_one {S : Type*} [set_like S R] [has_one R] [has_zero \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.has_graded_one A] : \u2191(@graded_monoid.ghas_one.one _ (\u03bb 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 \u03b9]\n  (A : \u03b9 \u2192 S) : Prop :=\n(mul_mem : \u2200 \u2983i j\u2984 {gi gj}, gi \u2208 A i \u2192 gj \u2208 A j \u2192 gi * gj \u2208 A (i + j))\n\ninstance set_like.ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.has_graded_mul A] :\n  graded_monoid.ghas_mul (\u03bb i, A i) :=\n{ mul := \u03bb i j a b, \u27e8(a * b : R), set_like.has_graded_mul.mul_mem a.prop b.prop\u27e9 }\n\n@[simp] lemma set_like.coe_ghas_mul {S : Type*} [set_like S R] [has_mul R] [has_add \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.has_graded_mul A] {i j : \u03b9} (x : A i) (y : A j) :\n    \u2191(@graded_monoid.ghas_mul.mul _ (\u03bb 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 \u03b9]\n  (A : \u03b9 \u2192 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 \u03b9]\nvariables {A : \u03b9 \u2192 S} [set_like.graded_monoid A]\n\nlemma pow_mem (n : \u2115) {r : R} {i : \u03b9} (h : r \u2208 A i) : r ^ n \u2208 A (n \u2022 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 {\u03b9'} (l : list \u03b9') (i : \u03b9' \u2192 \u03b9) (r : \u03b9' \u2192 R) (h : \u2200 j \u2208 l, r j \u2208 A (i j)) :\n  (l.map r).prod \u2208 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 $ \u03bb j hj, h _ $ list.mem_cons_of_mem _ hj) },\nend\n\nlemma list_prod_of_fn_mem {n} (i : fin n \u2192 \u03b9) (r : fin n \u2192 R) (h : \u2200 j, r j \u2208 A (i j)) :\n  (list.of_fn r).prod \u2208 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 _ _ _ (\u03bb _ _, 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 \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.graded_monoid A] :\n  graded_monoid.gmonoid (\u03bb i, A i) :=\n{ one_mul := \u03bb \u27e8i, a, h\u27e9, sigma.subtype_ext (zero_add _) (one_mul _),\n  mul_one := \u03bb \u27e8i, a, h\u27e9, sigma.subtype_ext (add_zero _) (mul_one _),\n  mul_assoc := \u03bb \u27e8i, a, ha\u27e9 \u27e8j, b, hb\u27e9 \u27e8k, c, hc\u27e9,\n    sigma.subtype_ext (add_assoc _ _ _) (mul_assoc _ _ _),\n  gnpow := \u03bb n i a, \u27e8a ^ n, set_like.graded_monoid.pow_mem n a.prop\u27e9,\n  gnpow_zero' := \u03bb n, sigma.subtype_ext (zero_nsmul _) (pow_zero _),\n  gnpow_succ' := \u03bb 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 \u03b9] (A : \u03b9 \u2192 S)\n  [set_like.graded_monoid A] {i : \u03b9} (x : A i) (n : \u2115) :\n    \u2191(@graded_monoid.gmonoid.gnpow _ (\u03bb 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 \u03b9]\n  (A : \u03b9 \u2192 S) [set_like.graded_monoid A] :\n  graded_monoid.gcomm_monoid (\u03bb i, A i) :=\n{ mul_comm := \u03bb \u27e8i, a, ha\u27e9 \u27e8j, b, hb\u27e9, sigma.subtype_ext (add_comm _ _) (mul_comm _ _),\n  ..set_like.gmonoid A}\n\nsection dprod\nopen set_like set_like.graded_monoid\nvariables {\u03b1 S : Type*} [set_like S R] [monoid R] [add_monoid \u03b9]\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 : \u03b9 \u2192 S) [set_like.graded_monoid A]\n  (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) (l : list \u03b1) :\n  \u2191(l.dprod f\u03b9 fA : (\u03bb i, \u21a5(A i)) _) = (list.prod (l.map (\u03bb 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 : \u03b9 \u2192 S) [set_like.graded_monoid A]\n  (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u03a0 a, A (f\u03b9 a)) (l : list \u03b1) :\n  (l.dprod f\u03b9 fA : (\u03bb i, \u21a5(A i)) _) =\n    \u27e8list.prod (l.map (\u03bb a, fA a)), (l.dprod_index_eq_map_sum f\u03b9).symm \u25b8\n      list_prod_map_mem l _ _ (\u03bb i hi, (fA i).prop)\u27e9 :=\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 : \u03b9` such that `a \u2208 A i`. -/\ndef set_like.is_homogeneous (A : \u03b9 \u2192 S) (a : R) : Prop := \u2203 i, a \u2208 A i\n\n@[simp] lemma set_like.is_homogeneous_coe {A : \u03b9 \u2192 S} {i} (x : A i) :\n  set_like.is_homogeneous A (x : R) :=\n\u27e8i, x.prop\u27e9\n\nlemma set_like.is_homogeneous_one [has_zero \u03b9] [has_one R]\n  (A : \u03b9 \u2192 S) [set_like.has_graded_one A] : set_like.is_homogeneous A (1 : R) :=\n\u27e80, set_like.has_graded_one.one_mem\u27e9\n\nlemma set_like.is_homogeneous.mul [has_add \u03b9] [has_mul R] {A : \u03b9 \u2192 S}\n  [set_like.has_graded_mul A] {a b : R} :\n  set_like.is_homogeneous A a \u2192 set_like.is_homogeneous A b \u2192 set_like.is_homogeneous A (a * b)\n| \u27e8i, hi\u27e9 \u27e8j, hj\u27e9 := \u27e8i + j, set_like.has_graded_mul.mul_mem hi hj\u27e9\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 \u03b9] [monoid R]\n  (A : \u03b9 \u2192 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' := \u03bb 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 \u21a5M \u21a5N)\n\ndef tensor_hom {R : Type u} [comm_ring R] {M : Module R} {N : Module R} {M' : Module R} {N' : Module R} (f : M \u27f6 N) (g : M' \u27f6 N') : tensor_obj M M' \u27f6 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 \ud835\udfd9 \ud835\udfd9 = \ud835\udfd9 :=\n  tensor_product.ext fun (x : \u21a5M) (y : \u21a5N) => Eq.refl (coe_fn (tensor_hom \ud835\udfd9 \ud835\udfd9) (tensor_product.tmul R x y))\n\ntheorem tensor_comp {R : Type u} [comm_ring R] {X\u2081 : Module R} {Y\u2081 : Module R} {Z\u2081 : Module R} {X\u2082 : Module R} {Y\u2082 : Module R} {Z\u2082 : Module R} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (g\u2081 : Y\u2081 \u27f6 Z\u2081) (g\u2082 : Y\u2082 \u27f6 Z\u2082) : tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082) = tensor_hom f\u2081 f\u2082 \u226b tensor_hom g\u2081 g\u2082 :=\n  tensor_product.ext\n    fun (x : \u21a5X\u2081) (y : \u21a5X\u2082) => Eq.refl (coe_fn (tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082)) (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 \u2245 tensor_obj M (tensor_obj N K) :=\n  linear_equiv.to_Module_iso (tensor_product.assoc R \u21a5M \u21a5N \u21a5K)\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\u2081 : Module R} {X\u2082 : Module R} {X\u2083 : Module R} {Y\u2081 : Module R} {Y\u2082 : Module R} {Y\u2083 : Module R} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083) : tensor_hom (tensor_hom f\u2081 f\u2082) f\u2083 \u226b category_theory.iso.hom (associator Y\u2081 Y\u2082 Y\u2083) =\n  category_theory.iso.hom (associator X\u2081 X\u2082 X\u2083) \u226b tensor_hom f\u2081 (tensor_hom f\u2082 f\u2083) := 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)) \ud835\udfd9 \u226b\n    category_theory.iso.hom (associator W (tensor_obj X Y) Z) \u226b\n      tensor_hom \ud835\udfd9 (category_theory.iso.hom (associator X Y Z)) =\n  category_theory.iso.hom (associator (tensor_obj W X) Y Z) \u226b 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 \u21a5M) \u2245 M :=\n  linear_equiv.to_Module_iso (tensor_product.lid R \u21a5M) \u226a\u226b of_self_iso M\n\ntheorem left_unitor_naturality {R : Type u} [comm_ring R] {M : Module R} {N : Module R} (f : M \u27f6 N) : tensor_hom \ud835\udfd9 f \u226b category_theory.iso.hom (left_unitor N) = category_theory.iso.hom (left_unitor M) \u226b 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 (\u21a5M) R) \u2245 M :=\n  linear_equiv.to_Module_iso (tensor_product.rid R \u21a5M) \u226a\u226b of_self_iso M\n\ntheorem right_unitor_naturality {R : Type u} [comm_ring R] {M : Module R} {N : Module R} (f : M \u27f6 N) : tensor_hom f \ud835\udfd9 \u226b category_theory.iso.hom (right_unitor N) = category_theory.iso.hom (right_unitor M) \u226b 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) \u226b tensor_hom \ud835\udfd9 (category_theory.iso.hom (left_unitor N)) =\n  tensor_hom (category_theory.iso.hom (right_unitor M)) \ud835\udfd9 := 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 \u21a5\ud835\udfd9_ :=\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 \u27f6 L) (g : M \u27f6 N) (k : \u21a5K) (m : \u21a5M) : coe_fn (f \u2297 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 : \u21a5M) : coe_fn (category_theory.iso.hom \u03bb_) (tensor_product.tmul R r m) = r \u2022 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 : \u21a5M) (r : R) : coe_fn (category_theory.iso.hom \u03c1_) (tensor_product.tmul R m r) = r \u2022 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 : \u21a5M) (n : \u21a5N) (k : \u21a5K) : coe_fn (category_theory.iso.hom \u03b1_) (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 \u2245 monoidal_category.tensor_obj N M :=\n  linear_equiv.to_Module_iso (tensor_product.comm R \u21a5M \u21a5N)\n\n@[simp] theorem braiding_naturality {R : Type u} [comm_ring R] {X\u2081 : Module R} {X\u2082 : Module R} {Y\u2081 : Module R} {Y\u2082 : Module R} (f : X\u2081 \u27f6 Y\u2081) (g : X\u2082 \u27f6 Y\u2082) : (f \u2297 g) \u226b category_theory.iso.hom (braiding Y\u2081 Y\u2082) = category_theory.iso.hom (braiding X\u2081 X\u2082) \u226b (g \u2297 f) :=\n  tensor_product.ext\n    fun (x : \u21a5X\u2081) (y : \u21a5X\u2082) =>\n      Eq.refl (coe_fn ((f \u2297 g) \u226b category_theory.iso.hom (braiding Y\u2081 Y\u2082)) (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 \u03b1_ \u226b category_theory.iso.hom (braiding X (Y \u2297 Z)) \u226b category_theory.iso.hom \u03b1_ =\n  (category_theory.iso.hom (braiding X Y) \u2297 \ud835\udfd9) \u226b\n    category_theory.iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 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 \u03b1_ \u226b category_theory.iso.hom (braiding (X \u2297 Y) Z) \u226b category_theory.iso.inv \u03b1_ =\n  (\ud835\udfd9 \u2297 category_theory.iso.hom (braiding Y Z)) \u226b\n    category_theory.iso.inv \u03b1_ \u226b (category_theory.iso.hom (braiding X Z) \u2297 \ud835\udfd9) := 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 : \u21a5M) (n : \u21a5N) : coe_fn (category_theory.iso.hom \u03b2_) (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 : \u21a5M) (n : \u21a5N) : coe_fn (category_theory.iso.inv \u03b2_) (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 \u2264 1. -/\ndef integer {R : Type u} {\u0393\u2080 : Type v} [ring R] [linear_ordered_comm_group_with_zero \u0393\u2080]\n    (v : valuation R \u0393\u2080) : subring R :=\n  subring.mk (set_of fun (x : R) => coe_fn v x \u2264 1) sorry sorry sorry sorry sorry\n\n/-- Given a valuation v : R \u2192 \u0393\u2080 and a ring homomorphism O \u2192+* 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} {\u0393\u2080 : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero \u0393\u2080]\n    (v : valuation R \u0393\u2080) (O : Type w) [comm_ring O] [algebra O R]\n    where\n  hom_inj : function.injective \u21d1(algebra_map O R)\n  map_le_one : \u2200 (x : O), coe_fn v (coe_fn (algebra_map O R) x) \u2264 1\n  exists_of_le_one : \u2200 {r : R}, coe_fn v r \u2264 1 \u2192 \u2203 (x : O), coe_fn (algebra_map O R) x = r\n\n-- typeclass shortcut\n\nprotected instance algebra {R : Type u} {\u0393\u2080 : Type v} [comm_ring R]\n    [linear_ordered_comm_group_with_zero \u0393\u2080] (v : valuation R \u0393\u2080) : algebra (\u21a5(integer v)) R :=\n  algebra.of_subring (integer v)\n\ntheorem integer.integers {R : Type u} {\u0393\u2080 : Type v} [comm_ring R]\n    [linear_ordered_comm_group_with_zero \u0393\u2080] (v : valuation R \u0393\u2080) : integers v \u21a5(integer v) :=\n  integers.mk subtype.coe_injective (fun (r : \u21a5(integer v)) => subtype.property r)\n    fun (r : R) (hr : coe_fn v r \u2264 1) => Exists.intro { val := r, property := hr } rfl\n\nnamespace integers\n\n\ntheorem one_of_is_unit {R : Type u} {\u0393\u2080 : Type v} [comm_ring R]\n    [linear_ordered_comm_group_with_zero \u0393\u2080] {v : valuation R \u0393\u2080} {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} {\u0393\u2080 : Type v} [comm_ring R]\n    [linear_ordered_comm_group_with_zero \u0393\u2080] {v : valuation R \u0393\u2080} {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} {\u0393\u2080 : Type v} [comm_ring R] [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {v : valuation R \u0393\u2080} {O : Type w} [comm_ring O] [algebra O R] (hv : integers v O) {x : O}\n    {y : O} (h : x \u2223 y) :\n    coe_fn v (coe_fn (algebra_map O R) y) \u2264 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} {\u0393\u2080 : Type v} [field F] [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {v : valuation F \u0393\u2080} {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) \u2264 coe_fn v (coe_fn (algebra_map O F) y)) :\n    y \u2223 x :=\n  sorry\n\ntheorem dvd_iff_le {F : Type u} {\u0393\u2080 : Type v} [field F] [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {v : valuation F \u0393\u2080} {O : Type w} [comm_ring O] [algebra O F] (hv : integers v O) {x : O}\n    {y : O} :\n    x \u2223 y \u2194 coe_fn v (coe_fn (algebra_map O F) y) \u2264 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} {\u0393\u2080 : Type v} [field F] [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {v : valuation F \u0393\u2080} {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) \u2264 coe_fn v (coe_fn (algebra_map O F) y) \u2194 y \u2223 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: \u2200 (b2 b1: B), count b2 b1 O = count b2 b1 I)\n    (count_1: \u2200 (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  \u2200 (x y : K), x \u2208 rp.OO \u2192 y \u2208 rp.OO \u2192 x * y \u2208 rp.OO :=\nbegin\n  suffices : \u2200 a b : K, a \u2208 rp.OO_m \u2192 b \u2208 rp.OO_m \u2192 a * b \u2208 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 \u2208 H, \n  { right, apply h.mul_mem_of_mem, assumption' },\n  left, refine \u27e8hxy,_\u27e9,\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) \u2208 rp.OO := or.inr $ rp.OO_p_one_mem \n\nlemma rigid_pair.preadditive.zero_mem (h : rp.preadditive) :\n  (0 : K) \u2208 rp.OO := or.inl $ rp.OO_m_zero_mem\n\nlemma rigid_pair.preadditive.neg_mem (h : rp.preadditive) :\n  \u2200 (x : K), x \u2208 rp.OO \u2192 -x \u2208 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  \u2200 (x : K), x \u2208 rp.OO \u2192 1 + x \u2208 rp.OO :=\nbegin\n  intros z hz,\n  by_cases hzz : z = -1, { rw hzz, simp [h.zero_mem] },\n  have hzz' : 1 + z \u2260 0, \n  { intro c, apply hzz,  \n    rwa [\u2190 add_eq_zero_iff_eq_neg, add_comm] },\n  by_cases hz1 : z \u2208 rp.OO_p,\n  swap, \n  { right, apply h, cases hz, assumption, contradiction },\n  have hh : 1 - (1 + z) \u2208 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 : \u2200 y : K, y \u2208 rp.OO_m \u2192 1 + (1 + z) * y \u2208 T \u2227 1 + (1 + z) * y \u2208 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) \u2208 H, \n  { right, refine \u27e8hz2, _\u27e9,  \n    intros y hy, refine \u27e8_, (aux y hy).1\u27e9,\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)\u207b\u00b9) \u2209 T,\n  { convert T.zero_nmem, field_simp, ring },\n  have : (-1) * (1 + z)\u207b\u00b9 \u2209 rp.OO_m,\n  { intro c, apply this, exact (aux _ c).1 },\n  rw (show (-1) * (1 + z)\u207b\u00b9 = (- (1 + z))\u207b\u00b9, by rw [inv_neg, \u2190 neg_eq_neg_one_mul]) at this,\n  rw \u2190 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  \u2200 x : K, x \u2208 rp.OO \u2228 x\u207b\u00b9 \u2208 rp.OO :=\nbegin\n  intros x, \n  by_cases hx : x \u2208 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  \u2200 (x y : K), x \u2208 rp.OO \u2192 y \u2208 rp.OO \u2192 x + y \u2208 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\u207b\u00b9) 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\u02e3) : \n  u \u2208 h.valuation_subring.unit_group \u2194 \n  (u : K) \u2208 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 \u27e8(h1|h1),(h2|h2)\u27e9,\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 \u27e8h1,h2\u27e9 } },\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\u02e3) (hu : u \u2208 h.valuation_subring.unit_group) : (u : K) \u2208 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\u02e3) \n  (hu : u \u2208 h.valuation_subring.principal_unit_group) : \n  (u : K) \u2208 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 _ \u2208 rp.OO \u2227 _ \u2209 _ at hu,\n  cases hu with hu1 hu2,\n  by_cases hune1 : u = 1,\n  { rw hune1, simp [T.one_mem] },\n  change \u00ac \u2203 v, _ at hu2, push_neg at hu2, \n  have husub1 : (u : K) - 1 \u2260 0, { contrapose! hune1, rw sub_eq_zero at hune1, ext, exact hune1 },\n  specialize hu2 (units.mk0 _ husub1),\n  have : units.mk0 _ husub1 \u2209 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)\u207b\u00b9 \u2209 rp.OO_p, \n  { intro c, apply this, split, \n    exact hu1, exact c },\n  obtain \u27e8y,z,hy,hz,hh\u27e9 := rp.exists_inv_eq_mul _ (H.inv_mem hu1.1) this, rw inv_inv at hh,\n  have hhneg1 : (-1 : K) \u2208 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, \u2190 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 \u03b1` is classically a nonempty `set \u03b1`,\n  and in the VM is represented by an element of `\u03b1`; 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} (\u03b1 : Type _) where mk' ::\n  s : Set \u03b1\n  val : Trunc \u21a5s\n#align semiquot Semiquot\u2093\n\nnamespace Semiquot\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _}\n\ninstance : Membership \u03b1 (Semiquot \u03b1) :=\n  \u27e8fun a q => a \u2208 q.s\u27e9\n\n/- warning: semiquot.mk -> Semiquot.mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u_1}} {a : \u03b1} {s : Set.{u_1} \u03b1}, (Membership.Mem.{u_1, u_1} \u03b1 (Set.{u_1} \u03b1) (Set.hasMem.{u_1} \u03b1) a s) -> (Semiquot\u2093.{u_2, u_1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {a : \u03b1} {s : Set.{u_1} \u03b1}, (Membership.mem.{u_1, u_1} \u03b1 (Set.{u_1} \u03b1) (Set.instMembershipSet.{u_1} \u03b1) a s) -> (Semiquot.{u_1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align semiquot.mk Semiquot.mk\u2093'. -/\n/-- Construct a `semiquot \u03b1` from `h : a \u2208 s` where `s : set \u03b1`. -/\ndef mk {a : \u03b1} {s : Set \u03b1} (h : a \u2208 s) : Semiquot \u03b1 :=\n  \u27e8s, Trunc.mk \u27e8a, h\u27e9\u27e9\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 {\u03b1 : Type.{u_1}} {q\u2081 : Semiquot\u2093.{u_2, u_1} \u03b1} {q\u2082 : Semiquot\u2093.{u_2, u_1} \u03b1}, Iff (Eq.{succ u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) q\u2081 q\u2082) (Eq.{max (succ u_1) 1} (Set.{u_1} \u03b1) (Semiquot\u2093.s.{u_2, u_1} \u03b1 q\u2081) (Semiquot\u2093.s.{u_2, u_1} \u03b1 q\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {q\u2081 : Semiquot.{u_1} \u03b1} {q\u2082 : Semiquot.{u_1} \u03b1}, Iff (Eq.{succ u_1} (Semiquot.{u_1} \u03b1) q\u2081 q\u2082) (Eq.{succ u_1} (Set.{u_1} \u03b1) (Semiquot.s.{u_1} \u03b1 q\u2081) (Semiquot.s.{u_1} \u03b1 q\u2082))\nCase conversion may be inaccurate. Consider using '#align semiquot.ext_s Semiquot.ext_s\u2093'. -/\ntheorem ext_s {q\u2081 q\u2082 : Semiquot \u03b1} : q\u2081 = q\u2082 \u2194 q\u2081.s = q\u2082.s :=\n  by\n  refine' \u27e8congr_arg _, fun h => _\u27e9\n  cases q\u2081\n  cases q\u2082\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 {\u03b1 : Type.{u_1}} {q\u2081 : Semiquot\u2093.{u_2, u_1} \u03b1} {q\u2082 : Semiquot\u2093.{u_2, u_1} \u03b1}, Iff (Eq.{succ u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) q\u2081 q\u2082) (forall (a : \u03b1), Iff (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a q\u2081) (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a q\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {q\u2081 : Semiquot.{u_1} \u03b1} {q\u2082 : Semiquot.{u_1} \u03b1}, Iff (Eq.{succ u_1} (Semiquot.{u_1} \u03b1) q\u2081 q\u2082) (forall (a : \u03b1), Iff (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q\u2081) (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q\u2082))\nCase conversion may be inaccurate. Consider using '#align semiquot.ext Semiquot.ext\u2093'. -/\ntheorem ext {q\u2081 q\u2082 : Semiquot \u03b1} : q\u2081 = q\u2082 \u2194 \u2200 a, a \u2208 q\u2081 \u2194 a \u2208 q\u2082 :=\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 {\u03b1 : Type.{u_1}} (q : Semiquot\u2093.{u_2, u_1} \u03b1), Exists.{succ u_1} \u03b1 (fun (a : \u03b1) => Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a q)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (q : Semiquot.{u_1} \u03b1), Exists.{succ u_1} \u03b1 (fun (a : \u03b1) => Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q)\nCase conversion may be inaccurate. Consider using '#align semiquot.exists_mem Semiquot.exists_mem\u2093'. -/\ntheorem exists_mem (q : Semiquot \u03b1) : \u2203 a, a \u2208 q :=\n  let \u27e8\u27e8a, h\u27e9, h\u2082\u27e9 := q.2.exists_rep\n  \u27e8a, h\u27e9\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 {\u03b1 : Type.{u_1}} {q : Semiquot\u2093.{u_2, u_1} \u03b1} {a : \u03b1} (h : Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a q), Eq.{succ u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) q (Semiquot.mk.{u_1, u_2} \u03b1 a (Semiquot\u2093.s.{u_2, u_1} \u03b1 q) h)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {q : Semiquot.{u_1} \u03b1} {a : \u03b1} (h : Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q), Eq.{succ u_1} (Semiquot.{u_1} \u03b1) q (Semiquot.mk.{u_1} \u03b1 a (Semiquot.s.{u_1} \u03b1 q) h)\nCase conversion may be inaccurate. Consider using '#align semiquot.eq_mk_of_mem Semiquot.eq_mk_of_mem\u2093'. -/\ntheorem eq_mk_of_mem {q : Semiquot \u03b1} {a : \u03b1} (h : a \u2208 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 {\u03b1 : Type.{u_1}} (q : Semiquot\u2093.{u_2, u_1} \u03b1), Set.Nonempty.{u_1} \u03b1 (Semiquot\u2093.s.{u_2, u_1} \u03b1 q)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (q : Semiquot.{u_1} \u03b1), Set.Nonempty.{u_1} \u03b1 (Semiquot.s.{u_1} \u03b1 q)\nCase conversion may be inaccurate. Consider using '#align semiquot.nonempty Semiquot.nonempty\u2093'. -/\ntheorem nonempty (q : Semiquot \u03b1) : 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 {\u03b1 : Type.{u_1}}, \u03b1 -> (Semiquot\u2093.{u_2, u_1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}}, \u03b1 -> (Semiquot.{u_1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align semiquot.pure Semiquot.pure\u2093'. -/\n/-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/\nprotected def pure (a : \u03b1) : Semiquot \u03b1 :=\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 {\u03b1 : Type.{u_1}} {a : \u03b1} {b : \u03b1}, Iff (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a (Semiquot.pure.{u_1, u_2} \u03b1 b)) (Eq.{succ u_1} \u03b1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {a : \u03b1} {b : \u03b1}, Iff (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a (Semiquot.pure.{u_1} \u03b1 b)) (Eq.{succ u_1} \u03b1 a b)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_pure' Semiquot.mem_pure'\u2093'. -/\n@[simp]\ntheorem mem_pure' {a b : \u03b1} : a \u2208 Semiquot.pure b \u2194 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 {\u03b1 : Type.{u_1}} (q : Semiquot\u2093.{u_2, u_1} \u03b1) {s : Set.{u_1} \u03b1}, (HasSubset.Subset.{u_1} (Set.{u_1} \u03b1) (Set.hasSubset.{u_1} \u03b1) (Semiquot\u2093.s.{u_2, u_1} \u03b1 q) s) -> (Semiquot\u2093.{u_3, u_1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (q : Semiquot.{u_1} \u03b1) {s : Set.{u_1} \u03b1}, (HasSubset.Subset.{u_1} (Set.{u_1} \u03b1) (Set.instHasSubsetSet.{u_1} \u03b1) (Semiquot.s.{u_1} \u03b1 q) s) -> (Semiquot.{u_1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align semiquot.blur' Semiquot.blur'\u2093'. -/\n/-- Replace `s` in a `semiquot` with a superset. -/\ndef blur' (q : Semiquot \u03b1) {s : Set \u03b1} (h : q.s \u2286 s) : Semiquot \u03b1 :=\n  \u27e8s, Trunc.lift (fun a : q.s => Trunc.mk \u27e8a.1, h a.2\u27e9) (fun _ _ => Trunc.eq _ _) q.2\u27e9\n#align semiquot.blur' Semiquot.blur'\n\n/- warning: semiquot.blur -> Semiquot.blur is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u_1}}, (Set.{u_1} \u03b1) -> (Semiquot\u2093.{u_2, u_1} \u03b1) -> (Semiquot\u2093.{u_3, u_1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}}, (Set.{u_1} \u03b1) -> (Semiquot.{u_1} \u03b1) -> (Semiquot.{u_1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align semiquot.blur Semiquot.blur\u2093'. -/\n/-- Replace `s` in a `q : semiquot \u03b1` with a union `s \u222a q.s` -/\ndef blur (s : Set \u03b1) (q : Semiquot \u03b1) : Semiquot \u03b1 :=\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 {\u03b1 : Type.{u_1}} (q : Semiquot\u2093.{u_2, u_1} \u03b1) (s : Set.{u_1} \u03b1) (h : HasSubset.Subset.{u_1} (Set.{u_1} \u03b1) (Set.hasSubset.{u_1} \u03b1) (Semiquot\u2093.s.{u_2, u_1} \u03b1 q) s), Eq.{succ u_1} (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot.blur.{u_1, u_2, u_3} \u03b1 s q) (Semiquot.blur'.{u_1, u_2, u_3} \u03b1 q s h)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (q : Semiquot.{u_1} \u03b1) (s : Set.{u_1} \u03b1) (h : HasSubset.Subset.{u_1} (Set.{u_1} \u03b1) (Set.instHasSubsetSet.{u_1} \u03b1) (Semiquot.s.{u_1} \u03b1 q) s), Eq.{succ u_1} (Semiquot.{u_1} \u03b1) (Semiquot.blur.{u_1} \u03b1 s q) (Semiquot.blur'.{u_1} \u03b1 q s h)\nCase conversion may be inaccurate. Consider using '#align semiquot.blur_eq_blur' Semiquot.blur_eq_blur'\u2093'. -/\ntheorem blur_eq_blur' (q : Semiquot \u03b1) (s : Set \u03b1) (h : q.s \u2286 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 {\u03b1 : Type.{u_1}} (q : Semiquot\u2093.{u_2, u_1} \u03b1) {s : Set.{u_1} \u03b1} (h : HasSubset.Subset.{u_1} (Set.{u_1} \u03b1) (Set.hasSubset.{u_1} \u03b1) (Semiquot\u2093.s.{u_2, u_1} \u03b1 q) s) {a : \u03b1}, Iff (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) a (Semiquot.blur'.{u_1, u_2, u_3} \u03b1 q s h)) (Membership.Mem.{u_1, u_1} \u03b1 (Set.{u_1} \u03b1) (Set.hasMem.{u_1} \u03b1) a s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (q : Semiquot.{u_1} \u03b1) {s : Set.{u_1} \u03b1} (h : HasSubset.Subset.{u_1} (Set.{u_1} \u03b1) (Set.instHasSubsetSet.{u_1} \u03b1) (Semiquot.s.{u_1} \u03b1 q) s) {a : \u03b1}, Iff (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a (Semiquot.blur'.{u_1} \u03b1 q s h)) (Membership.mem.{u_1, u_1} \u03b1 (Set.{u_1} \u03b1) (Set.instMembershipSet.{u_1} \u03b1) a s)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_blur' Semiquot.mem_blur'\u2093'. -/\n@[simp]\ntheorem mem_blur' (q : Semiquot \u03b1) {s : Set \u03b1} (h : q.s \u2286 s) {a : \u03b1} : a \u2208 blur' q h \u2194 a \u2208 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 {\u03b1 : Type.{u_1}}, (Trunc.{succ u_1} \u03b1) -> (Semiquot\u2093.{u_2, u_1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}}, (Trunc.{succ u_1} \u03b1) -> (Semiquot.{u_1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align semiquot.of_trunc Semiquot.ofTrunc\u2093'. -/\n/-- Convert a `trunc \u03b1` to a `semiquot \u03b1`. -/\ndef ofTrunc (q : Trunc \u03b1) : Semiquot \u03b1 :=\n  \u27e8Set.univ, q.map fun a => \u27e8a, trivial\u27e9\u27e9\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 {\u03b1 : Type.{u_1}}, (Semiquot\u2093.{u_2, u_1} \u03b1) -> (Trunc.{succ u_1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}}, (Semiquot.{u_1} \u03b1) -> (Trunc.{succ u_1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align semiquot.to_trunc Semiquot.toTrunc\u2093'. -/\n/-- Convert a `semiquot \u03b1` to a `trunc \u03b1`. -/\ndef toTrunc (q : Semiquot \u03b1) : Trunc \u03b1 :=\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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} (q : Semiquot\u2093.{u_3, u_1} \u03b1) (f : \u03b1 -> \u03b2), (forall (a : \u03b1), (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) a q) -> (forall (b : \u03b1), (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) b q) -> (Eq.{succ u_2} \u03b2 (f a) (f b)))) -> \u03b2\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} (q : Semiquot.{u_1} \u03b1) (f : \u03b1 -> \u03b2), (forall (a : \u03b1), (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q) -> (forall (b : \u03b1), (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) b q) -> (Eq.{succ u_2} \u03b2 (f a) (f b)))) -> \u03b2\nCase conversion may be inaccurate. Consider using '#align semiquot.lift_on Semiquot.liftOn\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b \u00abexpr \u2208 \u00bb 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 \u03b1) (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a) (_ : a \u2208 q) (b) (_ : b \u2208 q), f a = f b) : \u03b2 :=\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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} (q : Semiquot\u2093.{u_3, u_1} \u03b1) (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1), (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) a q) -> (forall (b : \u03b1), (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) b q) -> (Eq.{succ u_2} \u03b2 (f a) (f b)))) (a : \u03b1), (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) a q) -> (Eq.{succ u_2} \u03b2 (Semiquot.liftOn.{u_1, u_2, u_3} \u03b1 \u03b2 q f h) (f a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} (q : Semiquot.{u_1} \u03b1) (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1), (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q) -> (forall (b : \u03b1), (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) b q) -> (Eq.{succ u_2} \u03b2 (f a) (f b)))) (a : \u03b1), (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q) -> (Eq.{succ u_2} \u03b2 (Semiquot.liftOn.{u_1, u_2} \u03b1 \u03b2 q f h) (f a))\nCase conversion may be inaccurate. Consider using '#align semiquot.lift_on_of_mem Semiquot.liftOn_ofMem\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b \u00abexpr \u2208 \u00bb q) -/\ntheorem liftOn_ofMem (q : Semiquot \u03b1) (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a) (_ : a \u2208 q) (b) (_ : b \u2208 q), f a = f b)\n    (a : \u03b1) (aq : a \u2208 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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}}, (\u03b1 -> \u03b2) -> (Semiquot\u2093.{u_3, u_1} \u03b1) -> (Semiquot\u2093.{u_4, u_2} \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}}, (\u03b1 -> \u03b2) -> (Semiquot.{u_1} \u03b1) -> (Semiquot.{u_2} \u03b2)\nCase conversion may be inaccurate. Consider using '#align semiquot.map Semiquot.map\u2093'. -/\n/-- Apply a function to the unknown value stored in a `semiquot \u03b1`. -/\ndef map (f : \u03b1 \u2192 \u03b2) (q : Semiquot \u03b1) : Semiquot \u03b2 :=\n  \u27e8f '' q.1, q.2.map fun x => \u27e8f x.1, Set.mem_image_of_mem _ x.2\u27e9\u27e9\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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} (f : \u03b1 -> \u03b2) (q : Semiquot\u2093.{u_3, u_1} \u03b1) (b : \u03b2), Iff (Membership.Mem.{u_2, u_2} \u03b2 (Semiquot\u2093.{u_4, u_2} \u03b2) (Semiquot\u2093.hasMem.{u_2, u_4} \u03b2) b (Semiquot.map.{u_1, u_2, u_3, u_4} \u03b1 \u03b2 f q)) (Exists.{succ u_1} \u03b1 (fun (a : \u03b1) => And (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) a q) (Eq.{succ u_2} \u03b2 (f a) b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} (f : \u03b1 -> \u03b2) (q : Semiquot.{u_1} \u03b1) (b : \u03b2), Iff (Membership.mem.{u_2, u_2} \u03b2 (Semiquot.{u_2} \u03b2) (Semiquot.instMembershipSemiquot.{u_2} \u03b2) b (Semiquot.map.{u_1, u_2} \u03b1 \u03b2 f q)) (Exists.{succ u_1} \u03b1 (fun (a : \u03b1) => And (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q) (Eq.{succ u_2} \u03b2 (f a) b)))\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_map Semiquot.mem_map\u2093'. -/\n@[simp]\ntheorem mem_map (f : \u03b1 \u2192 \u03b2) (q : Semiquot \u03b1) (b : \u03b2) : b \u2208 map f q \u2194 \u2203 a, a \u2208 q \u2227 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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}}, (Semiquot\u2093.{u_3, u_1} \u03b1) -> (\u03b1 -> (Semiquot\u2093.{u_4, u_2} \u03b2)) -> (Semiquot\u2093.{u_5, u_2} \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}}, (Semiquot.{u_1} \u03b1) -> (\u03b1 -> (Semiquot.{u_2} \u03b2)) -> (Semiquot.{u_2} \u03b2)\nCase conversion may be inaccurate. Consider using '#align semiquot.bind Semiquot.bind\u2093'. -/\n/-- Apply a function returning a `semiquot` to a `semiquot`. -/\ndef bind (q : Semiquot \u03b1) (f : \u03b1 \u2192 Semiquot \u03b2) : Semiquot \u03b2 :=\n  \u27e8\u22c3 a \u2208 q.1, (f a).1, q.2.bind fun a => (f a.1).2.map fun b => \u27e8b.1, Set.mem_bunion\u1d62 a.2 b.2\u27e9\u27e9\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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} (q : Semiquot\u2093.{u_3, u_1} \u03b1) (f : \u03b1 -> (Semiquot\u2093.{u_4, u_2} \u03b2)) (b : \u03b2), Iff (Membership.Mem.{u_2, u_2} \u03b2 (Semiquot\u2093.{u_5, u_2} \u03b2) (Semiquot\u2093.hasMem.{u_2, u_5} \u03b2) b (Semiquot.bind.{u_1, u_2, u_3, u_4, u_5} \u03b1 \u03b2 q f)) (Exists.{succ u_1} \u03b1 (fun (a : \u03b1) => Exists.{0} (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) a q) (fun (H : Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_3, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_3} \u03b1) a q) => Membership.Mem.{u_2, u_2} \u03b2 (Semiquot\u2093.{u_4, u_2} \u03b2) (Semiquot\u2093.hasMem.{u_2, u_4} \u03b2) b (f a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_2}} (q : Semiquot.{u_1} \u03b1) (f : \u03b1 -> (Semiquot.{u_2} \u03b2)) (b : \u03b2), Iff (Membership.mem.{u_2, u_2} \u03b2 (Semiquot.{u_2} \u03b2) (Semiquot.instMembershipSemiquot.{u_2} \u03b2) b (Semiquot.bind.{u_1, u_2} \u03b1 \u03b2 q f)) (Exists.{succ u_1} \u03b1 (fun (a : \u03b1) => And (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a q) (Membership.mem.{u_2, u_2} \u03b2 (Semiquot.{u_2} \u03b2) (Semiquot.instMembershipSemiquot.{u_2} \u03b2) b (f a))))\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_bind Semiquot.mem_bind\u2093'. -/\n@[simp]\ntheorem mem_bind (q : Semiquot \u03b1) (f : \u03b1 \u2192 Semiquot \u03b2) (b : \u03b2) : b \u2208 bind q f \u2194 \u2203 a \u2208 q, b \u2208 f a :=\n  Set.mem_union\u1d62\u2082\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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_1}}, Eq.{succ u_1} ((\u03b1 -> \u03b2) -> (Semiquot\u2093.{u_2, u_1} \u03b1) -> (Semiquot\u2093.{u_2, u_1} \u03b2)) (Functor.map.{u_1, u_1} (fun {\u03b1 : Type.{u_1}} => Semiquot\u2093.{u_2, u_1} \u03b1) (Applicative.toFunctor.{u_1, u_1} (fun {\u03b1 : Type.{u_1}} => Semiquot\u2093.{u_2, u_1} \u03b1) (Monad.toApplicative.{u_1, u_1} (fun {\u03b1 : Type.{u_1}} => Semiquot\u2093.{u_2, u_1} \u03b1) Semiquot\u2093.monad.{u_1, u_2})) \u03b1 \u03b2) (Semiquot.map.{u_1, u_1, u_2, u_2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_1}}, Eq.{succ u_1} ((\u03b1 -> \u03b2) -> (Semiquot.{u_1} \u03b1) -> (Semiquot.{u_1} \u03b2)) (fun (x._@.Mathlib.Data.Semiquot._hyg.993 : \u03b1 -> \u03b2) (x._@.Mathlib.Data.Semiquot._hyg.995 : Semiquot.{u_1} \u03b1) => 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})) \u03b1 \u03b2 x._@.Mathlib.Data.Semiquot._hyg.993 x._@.Mathlib.Data.Semiquot._hyg.995) (Semiquot.map.{u_1, u_1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align semiquot.map_def Semiquot.map_def\u2093'. -/\n@[simp]\ntheorem map_def {\u03b2} : ((\u00b7 <$> \u00b7) : (\u03b1 \u2192 \u03b2) \u2192 Semiquot \u03b1 \u2192 Semiquot \u03b2) = 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 {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_1}}, Eq.{succ u_1} ((Semiquot\u2093.{u_2, u_1} \u03b1) -> (\u03b1 -> (Semiquot\u2093.{u_2, u_1} \u03b2)) -> (Semiquot\u2093.{u_2, u_1} \u03b2)) (Bind.bind.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Monad.toHasBind.{u_1, u_1} Semiquot\u2093.{u_2, u_1} Semiquot\u2093.monad.{u_1, u_2}) \u03b1 \u03b2) (Semiquot.bind.{u_1, u_1, u_2, u_2, u_2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {\u03b2 : Type.{u_1}}, Eq.{succ u_1} ((Semiquot.{u_1} \u03b1) -> (\u03b1 -> (Semiquot.{u_1} \u03b2)) -> (Semiquot.{u_1} \u03b2)) (fun (x._@.Mathlib.Data.Semiquot._hyg.1033 : Semiquot.{u_1} \u03b1) (x._@.Mathlib.Data.Semiquot._hyg.1035 : \u03b1 -> (Semiquot.{u_1} \u03b2)) => Bind.bind.{u_1, u_1} Semiquot.{u_1} (Monad.toBind.{u_1, u_1} Semiquot.{u_1} Semiquot.instMonadSemiquot.{u_1}) \u03b1 \u03b2 x._@.Mathlib.Data.Semiquot._hyg.1033 x._@.Mathlib.Data.Semiquot._hyg.1035) (Semiquot.bind.{u_1, u_1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align semiquot.bind_def Semiquot.bind_def\u2093'. -/\n@[simp]\ntheorem bind_def {\u03b2} : ((\u00b7 >>= \u00b7) : Semiquot \u03b1 \u2192 (\u03b1 \u2192 Semiquot \u03b2) \u2192 Semiquot \u03b2) = 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 {\u03b1 : Type.{u_1}} {a : \u03b1} {b : \u03b1}, Iff (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a (Pure.pure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquot\u2093.{u_2, u_1} Semiquot\u2093.monad.{u_1, u_2})) \u03b1 b)) (Eq.{succ u_1} \u03b1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {a : \u03b1} {b : \u03b1}, Iff (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) 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})) \u03b1 b)) (Eq.{succ u_1} \u03b1 a b)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_pure Semiquot.mem_pure\u2093'. -/\n@[simp]\ntheorem mem_pure {a b : \u03b1} : a \u2208 (pure b : Semiquot \u03b1) \u2194 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 {\u03b1 : Type.{u_1}} (a : \u03b1), Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a (Pure.pure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquot\u2093.{u_2, u_1} Semiquot\u2093.monad.{u_1, u_2})) \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (a : \u03b1), Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) 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})) \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_pure_self Semiquot.mem_pure_self\u2093'. -/\ntheorem mem_pure_self (a : \u03b1) : a \u2208 (pure a : Semiquot \u03b1) :=\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 {\u03b1 : Type.{u_1}} {a : \u03b1} {b : \u03b1}, Iff (Eq.{succ u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) (Pure.pure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquot\u2093.{u_2, u_1} Semiquot\u2093.monad.{u_1, u_2})) \u03b1 a) (Pure.pure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquot\u2093.{u_2, u_1} Semiquot\u2093.monad.{u_1, u_2})) \u03b1 b)) (Eq.{succ u_1} \u03b1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {a : \u03b1} {b : \u03b1}, Iff (Eq.{succ u_1} (Semiquot.{u_1} \u03b1) (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})) \u03b1 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})) \u03b1 b)) (Eq.{succ u_1} \u03b1 a b)\nCase conversion may be inaccurate. Consider using '#align semiquot.pure_inj Semiquot.pure_inj\u2093'. -/\n@[simp]\ntheorem pure_inj {a b : \u03b1} : (pure a : Semiquot \u03b1) = pure b \u2194 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 \u03b1 \u03b2 x f := ext.2 <| by simp\n  bind_assoc \u03b1 \u03b2 \u03b3 s f g :=\n    ext.2 <| by\n      simp <;>\n        exact fun c =>\n          \u27e8fun \u27e8b, \u27e8a, as, bf\u27e9, cg\u27e9 => \u27e8a, as, b, bf, cg\u27e9, fun \u27e8a, as, b, bf, cg\u27e9 =>\n            \u27e8b, \u27e8a, as, bf\u27e9, cg\u27e9\u27e9\n  id_map \u03b1 q := ext.2 <| by simp\n  bind_pure_comp_eq_map \u03b1 \u03b2 f s := ext.2 <| by simp [eq_comm]\n\ninstance : LE (Semiquot \u03b1) :=\n  \u27e8fun s t => s.s \u2286 t.s\u27e9\n\ninstance : PartialOrder (Semiquot \u03b1)\n    where\n  le s t := \u2200 \u2983x\u2984, x \u2208 s \u2192 x \u2208 t\n  le_refl s := Set.Subset.refl _\n  le_trans s t u := Set.Subset.trans\n  le_antisymm s t h\u2081 h\u2082 := ext_s.2 (Set.Subset.antisymm h\u2081 h\u2082)\n\ninstance : SemilatticeSup (Semiquot \u03b1) :=\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 {\u03b1 : Type.{u_1}} {a : \u03b1} {s : Semiquot\u2093.{u_2, u_1} \u03b1}, Iff (LE.le.{u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasLe.{u_1, u_2} \u03b1) (Pure.pure.{u_1, u_1} (fun {\u03b1 : Type.{u_1}} => Semiquot\u2093.{u_2, u_1} \u03b1) (Applicative.toHasPure.{u_1, u_1} (fun {\u03b1 : Type.{u_1}} => Semiquot\u2093.{u_2, u_1} \u03b1) (Monad.toApplicative.{u_1, u_1} (fun {\u03b1 : Type.{u_1}} => Semiquot\u2093.{u_2, u_1} \u03b1) Semiquot\u2093.monad.{u_1, u_2})) \u03b1 a) s) (Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {a : \u03b1} {s : Semiquot.{u_1} \u03b1}, Iff (LE.le.{u_1} (Semiquot.{u_1} \u03b1) (Semiquot.instLESemiquot.{u_1} \u03b1) (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})) \u03b1 a) s) (Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a s)\nCase conversion may be inaccurate. Consider using '#align semiquot.pure_le Semiquot.pure_le\u2093'. -/\n@[simp]\ntheorem pure_le {a : \u03b1} {s : Semiquot \u03b1} : pure a \u2264 s \u2194 a \u2208 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 {\u03b1 : Type.{u_1}}, (Semiquot\u2093.{u_2, u_1} \u03b1) -> Prop\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}}, (Semiquot.{u_1} \u03b1) -> Prop\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure Semiquot.IsPure\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a b \u00abexpr \u2208 \u00bb q) -/\n/-- Assert that a `semiquot` contains only one possible value. -/\ndef IsPure (q : Semiquot \u03b1) : Prop :=\n  \u2200 (a) (_ : a \u2208 q) (b) (_ : b \u2208 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 {\u03b1 : Type.{u_1}} (q : Semiquot\u2093.{u_2, u_1} \u03b1), (Semiquot.IsPure.{u_1, u_2} \u03b1 q) -> \u03b1\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (q : Semiquot.{u_1} \u03b1), (Semiquot.IsPure.{u_1} \u03b1 q) -> \u03b1\nCase conversion may be inaccurate. Consider using '#align semiquot.get Semiquot.get\u2093'. -/\n/-- Extract the value from a `is_pure` semiquotient. -/\ndef get (q : Semiquot \u03b1) (h : q.IsPure) : \u03b1 :=\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 {\u03b1 : Type.{u_1}} {q : Semiquot\u2093.{u_2, u_1} \u03b1} (p : Semiquot.IsPure.{u_1, u_2} \u03b1 q), Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) (Semiquot.get.{u_1, u_2} \u03b1 q p) q\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {q : Semiquot.{u_1} \u03b1} (p : Semiquot.IsPure.{u_1} \u03b1 q), Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) (Semiquot.get.{u_1} \u03b1 q p) q\nCase conversion may be inaccurate. Consider using '#align semiquot.get_mem Semiquot.get_mem\u2093'. -/\ntheorem get_mem {q : Semiquot \u03b1} (p) : get q p \u2208 q :=\n  by\n  let \u27e8a, h\u27e9 := 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 {\u03b1 : Type.{u_1}} {q : Semiquot\u2093.{u_2, u_1} \u03b1} (p : Semiquot.IsPure.{u_1, u_2} \u03b1 q), Eq.{succ u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) q (Pure.pure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquot\u2093.{u_2, u_1} Semiquot\u2093.monad.{u_1, u_2})) \u03b1 (Semiquot.get.{u_1, u_2} \u03b1 q p))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {q : Semiquot.{u_1} \u03b1} (p : Semiquot.IsPure.{u_1} \u03b1 q), Eq.{succ u_1} (Semiquot.{u_1} \u03b1) 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})) \u03b1 (Semiquot.get.{u_1} \u03b1 q p))\nCase conversion may be inaccurate. Consider using '#align semiquot.eq_pure Semiquot.eq_pure\u2093'. -/\ntheorem eq_pure {q : Semiquot \u03b1} (p) : q = pure (get q p) :=\n  ext.2 fun a => by simp <;> exact \u27e8fun h => p _ h _ (get_mem _), fun e => e.symm \u25b8 get_mem _\u27e9\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 {\u03b1 : Type.{u_1}} (a : \u03b1), Semiquot.IsPure.{u_1, u_2} \u03b1 (Pure.pure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquot\u2093.{u_2, u_1} Semiquot\u2093.monad.{u_1, u_2})) \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (a : \u03b1), Semiquot.IsPure.{u_1} \u03b1 (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})) \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align semiquot.pure_is_pure Semiquot.pure_isPure\u2093'. -/\n@[simp]\ntheorem pure_isPure (a : \u03b1) : 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 {\u03b1 : Type.{u_1}} {s : Semiquot\u2093.{u_2, u_1} \u03b1}, Iff (Semiquot.IsPure.{u_1, u_2} \u03b1 s) (Exists.{succ u_1} \u03b1 (fun (a : \u03b1) => Eq.{succ u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) s (Pure.pure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Applicative.toHasPure.{u_1, u_1} Semiquot\u2093.{u_2, u_1} (Monad.toApplicative.{u_1, u_1} Semiquot\u2093.{u_2, u_1} Semiquot\u2093.monad.{u_1, u_2})) \u03b1 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {s : Semiquot.{u_1} \u03b1}, Iff (Semiquot.IsPure.{u_1} \u03b1 s) (Exists.{succ u_1} \u03b1 (fun (a : \u03b1) => Eq.{succ u_1} (Semiquot.{u_1} \u03b1) 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})) \u03b1 a)))\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure_iff Semiquot.isPure_iff\u2093'. -/\ntheorem isPure_iff {s : Semiquot \u03b1} : IsPure s \u2194 \u2203 a, s = pure a :=\n  \u27e8fun h => \u27e8_, eq_pure h\u27e9, fun \u27e8a, e\u27e9 => e.symm \u25b8 pure_isPure _\u27e9\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 {\u03b1 : Type.{u_1}} {s : Semiquot\u2093.{u_2, u_1} \u03b1} {t : Semiquot\u2093.{u_2, u_1} \u03b1}, (LE.le.{u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasLe.{u_1, u_2} \u03b1) s t) -> (Semiquot.IsPure.{u_1, u_2} \u03b1 t) -> (Semiquot.IsPure.{u_1, u_2} \u03b1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {s : Semiquot.{u_1} \u03b1} {t : Semiquot.{u_1} \u03b1}, (LE.le.{u_1} (Semiquot.{u_1} \u03b1) (Semiquot.instLESemiquot.{u_1} \u03b1) s t) -> (Semiquot.IsPure.{u_1} \u03b1 t) -> (Semiquot.IsPure.{u_1} \u03b1 s)\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure.mono Semiquot.IsPure.mono\u2093'. -/\ntheorem IsPure.mono {s t : Semiquot \u03b1} (st : s \u2264 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 {\u03b1 : Type.{u_1}} {s : Semiquot\u2093.{u_2, u_1} \u03b1} {t : Semiquot\u2093.{u_2, u_1} \u03b1}, (Semiquot.IsPure.{u_1, u_2} \u03b1 t) -> (Iff (LE.le.{u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasLe.{u_1, u_2} \u03b1) s t) (Eq.{succ u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} {s : Semiquot.{u_1} \u03b1} {t : Semiquot.{u_1} \u03b1}, (Semiquot.IsPure.{u_1} \u03b1 t) -> (Iff (LE.le.{u_1} (Semiquot.{u_1} \u03b1) (Semiquot.instLESemiquot.{u_1} \u03b1) s t) (Eq.{succ u_1} (Semiquot.{u_1} \u03b1) s t))\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure.min Semiquot.IsPure.min\u2093'. -/\ntheorem IsPure.min {s t : Semiquot \u03b1} (h : IsPure t) : s \u2264 t \u2194 s = t :=\n  \u27e8fun 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\u27e9\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 {\u03b1 : Type.{u_1}} [_inst_1 : Subsingleton.{succ u_1} \u03b1] (q : Semiquot\u2093.{u_2, u_1} \u03b1), Semiquot.IsPure.{u_1, u_2} \u03b1 q\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} [_inst_1 : Subsingleton.{succ u_1} \u03b1] (q : Semiquot.{u_1} \u03b1), Semiquot.IsPure.{u_1} \u03b1 q\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure_of_subsingleton Semiquot.isPure_of_subsingleton\u2093'. -/\ntheorem isPure_of_subsingleton [Subsingleton \u03b1] (q : Semiquot \u03b1) : 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 {\u03b1 : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} \u03b1], Semiquot\u2093.{u_2, u_1} \u03b1\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} \u03b1], Semiquot.{u_1} \u03b1\nCase conversion may be inaccurate. Consider using '#align semiquot.univ Semiquot.univ\u2093'. -/\n/-- `univ : semiquot \u03b1` represents an unspecified element of `univ : set \u03b1`. -/\ndef univ [Inhabited \u03b1] : Semiquot \u03b1 :=\n  mk <| Set.mem_univ default\n#align semiquot.univ Semiquot.univ\n\ninstance [Inhabited \u03b1] : Inhabited (Semiquot \u03b1) :=\n  \u27e8univ\u27e9\n\n/- warning: semiquot.mem_univ -> Semiquot.mem_univ is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} \u03b1] (a : \u03b1), Membership.Mem.{u_1, u_1} \u03b1 (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot\u2093.hasMem.{u_1, u_2} \u03b1) a (Semiquot.univ.{u_1, u_2} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} \u03b1] (a : \u03b1), Membership.mem.{u_1, u_1} \u03b1 (Semiquot.{u_1} \u03b1) (Semiquot.instMembershipSemiquot.{u_1} \u03b1) a (Semiquot.univ.{u_1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align semiquot.mem_univ Semiquot.mem_univ\u2093'. -/\n@[simp]\ntheorem mem_univ [Inhabited \u03b1] : \u2200 a, a \u2208 @univ \u03b1 _ :=\n  @Set.mem_univ \u03b1\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 {\u03b1 : Type.{u_1}} (I : Inhabited.{succ u_1} \u03b1) (J : Inhabited.{succ u_1} \u03b1), Eq.{succ u_1} (Semiquot\u2093.{u_2, u_1} \u03b1) (Semiquot.univ.{u_1, u_2} \u03b1 I) (Semiquot.univ.{u_1, u_2} \u03b1 J)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} (I : Inhabited.{succ u_1} \u03b1) (J : Inhabited.{succ u_1} \u03b1), Eq.{succ u_1} (Semiquot.{u_1} \u03b1) (Semiquot.univ.{u_1} \u03b1 I) (Semiquot.univ.{u_1} \u03b1 J)\nCase conversion may be inaccurate. Consider using '#align semiquot.univ_unique Semiquot.univ_unique\u2093'. -/\n@[congr]\ntheorem univ_unique (I J : Inhabited \u03b1) : @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 {\u03b1 : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} \u03b1], Iff (Semiquot.IsPure.{u_1, u_2} \u03b1 (Semiquot.univ.{u_1, u_2} \u03b1 _inst_1)) (Subsingleton.{succ u_1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u_1}} [_inst_1 : Inhabited.{succ u_1} \u03b1], Iff (Semiquot.IsPure.{u_1} \u03b1 (Semiquot.univ.{u_1} \u03b1 _inst_1)) (Subsingleton.{succ u_1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align semiquot.is_pure_univ Semiquot.isPure_univ\u2093'. -/\n@[simp]\ntheorem isPure_univ [Inhabited \u03b1] : @IsPure \u03b1 univ \u2194 Subsingleton \u03b1 :=\n  \u27e8fun h => \u27e8fun a b => h a trivial b trivial\u27e9, fun \u27e8h\u27e9 a _ b _ => h a b\u27e9\n#align semiquot.is_pure_univ Semiquot.isPure_univ\n\ninstance [Inhabited \u03b1] : OrderTop (Semiquot \u03b1)\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 : \u2124) (L1 L2 : list \u2124) (d : \u2124) (h : list.modify L1 L2 d)\n  (n : \u2115) (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) \u2264 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 (\u03bb (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 (\u03bb (j : fin e), value_i tf e (remove_nth L2 (i.val)) j _)))) \n        \u2264 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 \u2260 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 (\u03bb (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 \u2264 \n          show abs (nth_le L1 h.n h.ha - nth_le L2 h.n h.hb) \u2265 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 _ \u27e8n, HnL\u27e9, /- nth_le (of_fn f) \u27e8n, HnL\u27e9 = f (\u27e8n, HnL\u27e9)\n                                        (where f is : \u03bb (j : fin e), value_i tf e (remove_nth L1 (i.val)) j _)) -/\n          rw nth_le_of_fn _ \u27e8n, HnL\u27e9,\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\u207b\u00b9 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\u2081\u2081` and `matrix.det_from_blocks\u2082\u2082` 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\u1d34\n  D]` is postive semidefinite if and only if `D - B\u1d34 A\u207b\u00b9 B` is postive semidefinite.\n\n-/\n\n\nnamespace Matrix\n\nopen Matrix\n\nvariable {n : Type _} {m : Type _} {\ud835\udd5c : Type _} [IsROrC \ud835\udd5c]\n\n-- mathport name: \u00abexpr \u2295\u1d65 \u00bb\nscoped infixl:65 \" \u2295\u1d65 \" => Sum.elim\n\ntheorem schur_complement_eq\u2081\u2081 [Fintype m] [DecidableEq m] [Fintype n] {A : Matrix m m \ud835\udd5c}\n    (B : Matrix m n \ud835\udd5c) (D : Matrix n n \ud835\udd5c) (x : m \u2192 \ud835\udd5c) (y : n \u2192 \ud835\udd5c) [Invertible A]\n    (hA : A.IsHermitian) :\n    vecMul (star (x \u2295\u1d65 y)) (fromBlocks A B B\u1d34 D) \u2b1d\u1d65 (x \u2295\u1d65 y) =\n      vecMul (star (x + (A\u207b\u00b9 \u2b1d B).mulVec y)) A \u2b1d\u1d65 (x + (A\u207b\u00b9 \u2b1d B).mulVec y) +\n        vecMul (star y) (D - B\u1d34 \u2b1d A\u207b\u00b9 \u2b1d B) \u2b1d\u1d65 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\u2081\u2081 Matrix.schur_complement_eq\u2081\u2081\n\ntheorem schur_complement_eq\u2082\u2082 [Fintype m] [Fintype n] [DecidableEq n] (A : Matrix m m \ud835\udd5c)\n    (B : Matrix m n \ud835\udd5c) {D : Matrix n n \ud835\udd5c} (x : m \u2192 \ud835\udd5c) (y : n \u2192 \ud835\udd5c) [Invertible D]\n    (hD : D.IsHermitian) :\n    vecMul (star (x \u2295\u1d65 y)) (fromBlocks A B B\u1d34 D) \u2b1d\u1d65 (x \u2295\u1d65 y) =\n      vecMul (star ((D\u207b\u00b9 \u2b1d B\u1d34).mulVec x + y)) D \u2b1d\u1d65 ((D\u207b\u00b9 \u2b1d B\u1d34).mulVec x + y) +\n        vecMul (star x) (A - B \u2b1d D\u207b\u00b9 \u2b1d B\u1d34) \u2b1d\u1d65 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\u2082\u2082 Matrix.schur_complement_eq\u2082\u2082\n\nend Matrix\n\nnamespace Matrix\n\nopen Matrix\n\nvariable {n : Type _} {m : Type _} {\ud835\udd5c : Type _} [IsROrC \ud835\udd5c]\n\ntheorem IsHermitian.from_blocks\u2081\u2081 [Fintype m] [DecidableEq m] {A : Matrix m m \ud835\udd5c} (B : Matrix m n \ud835\udd5c)\n    (D : Matrix n n \ud835\udd5c) (hA : A.IsHermitian) :\n    (fromBlocks A B B\u1d34 D).IsHermitian \u2194 (D - B\u1d34 \u2b1d A\u207b\u00b9 \u2b1d B).IsHermitian :=\n  by\n  have hBAB : (B\u1d34 \u2b1d A\u207b\u00b9 \u2b1d 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  \u00b7 intro h\n    apply is_hermitian.sub h.2.2.2 hBAB\n  \u00b7 intro h\n    refine' \u27e8hA, rfl, conj_transpose_conj_transpose B, _\u27e9\n    rw [\u2190 sub_add_cancel D]\n    apply is_hermitian.add h hBAB\n#align matrix.is_hermitian.from_blocks\u2081\u2081 Matrix.IsHermitian.from_blocks\u2081\u2081\n\ntheorem IsHermitian.from_blocks\u2082\u2082 [Fintype n] [DecidableEq n] (A : Matrix m m \ud835\udd5c) (B : Matrix m n \ud835\udd5c)\n    {D : Matrix n n \ud835\udd5c} (hD : D.IsHermitian) :\n    (fromBlocks A B B\u1d34 D).IsHermitian \u2194 (A - B \u2b1d D\u207b\u00b9 \u2b1d B\u1d34).IsHermitian :=\n  by\n  rw [\u2190 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\u2081\u2081 _ _ hD <;> simp\n#align matrix.is_hermitian.from_blocks\u2082\u2082 Matrix.IsHermitian.from_blocks\u2082\u2082\n\ntheorem PosSemidef.from_blocks\u2081\u2081 [Fintype m] [DecidableEq m] [Fintype n] {A : Matrix m m \ud835\udd5c}\n    (B : Matrix m n \ud835\udd5c) (D : Matrix n n \ud835\udd5c) (hA : A.PosDef) [Invertible A] :\n    (fromBlocks A B B\u1d34 D).PosSemidef \u2194 (D - B\u1d34 \u2b1d A\u207b\u00b9 \u2b1d B).PosSemidef :=\n  by\n  rw [pos_semidef, is_hermitian.from_blocks\u2081\u2081 _ _ hA.1]\n  constructor\n  \u00b7 refine' fun h => \u27e8h.1, fun x => _\u27e9\n    have := h.2 (-(A\u207b\u00b9 \u2b1d B).mulVec x \u2295\u1d65 x)\n    rw [dot_product_mul_vec, schur_complement_eq\u2081\u2081 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  \u00b7 refine' fun h => \u27e8h.1, fun x => _\u27e9\n    rw [dot_product_mul_vec, \u2190 Sum.elim_comp_inl_inr x, schur_complement_eq\u2081\u2081 B D _ _ hA.1, map_add]\n    apply le_add_of_nonneg_of_le\n    \u00b7 rw [\u2190 dot_product_mul_vec]\n      apply hA.pos_semidef.2\n    \u00b7 rw [\u2190 dot_product_mul_vec]\n      apply h.2\n#align matrix.pos_semidef.from_blocks\u2081\u2081 Matrix.PosSemidef.from_blocks\u2081\u2081\n\ntheorem PosSemidef.from_blocks\u2082\u2082 [Fintype m] [Fintype n] [DecidableEq n] (A : Matrix m m \ud835\udd5c)\n    (B : Matrix m n \ud835\udd5c) {D : Matrix n n \ud835\udd5c} (hD : D.PosDef) [Invertible D] :\n    (fromBlocks A B B\u1d34 D).PosSemidef \u2194 (A - B \u2b1d D\u207b\u00b9 \u2b1d B\u1d34).PosSemidef :=\n  by\n  rw [\u2190 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\u2081\u2081 _ _ hD <;> first |infer_instance|simp\n#align matrix.pos_semidef.from_blocks\u2082\u2082 Matrix.PosSemidef.from_blocks\u2082\u2082\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 \u03b2 \u03b3 \u03b9 \u03b9' : Type _} {r p q : \u03b1 \u2192 \u03b1 \u2192 Prop}\n\nsection Pairwise\n\nvariable {f g : \u03b9 \u2192 \u03b1} {s t u : Set \u03b1} {a b : \u03b1}\n\ntheorem pairwise_on_bool (hr : Symmetric r) {a b : \u03b1} :\n    Pairwise (r on fun c => cond c a b) \u2194 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 \u03b1] [OrderBot \u03b1] {a b : \u03b1} :\n    Pairwise (Disjoint on fun c => cond c a b) \u2194 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 \u03b9] (hr : Symmetric r) (f : \u03b9 \u2192 \u03b1) :\n    Pairwise (r on f) \u2194 \u2200 \u2983m n\u2984, m < n \u2192 r (f m) (f n) :=\n  \u27e8fun h _m _n hmn => h hmn.ne, fun h _m _n hmn => hmn.lt_or_lt.elim (@h _ _) fun h' => hr (h h')\u27e9\n#align symmetric.pairwise_on Symmetric.pairwise_on\n\ntheorem pairwise_disjoint_on [SemilatticeInf \u03b1] [OrderBot \u03b1] [LinearOrder \u03b9] (f : \u03b9 \u2192 \u03b1) :\n    Pairwise (Disjoint on f) \u2194 \u2200 \u2983m n\u2984, m < n \u2192 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 \u03b1] [OrderBot \u03b1] (hs : Pairwise (Disjoint on f))\n    (h : g \u2264 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 \u2286 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 \u2264 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 \u03b1) : s.Pairwise \u22a4 :=\n  pairwise_of_forall s _ fun _ _ => trivial\n#align set.pairwise_top Set.pairwise_top\n\nprotected theorem Subsingleton.pairwise (h : s.Subsingleton) (r : \u03b1 \u2192 \u03b1 \u2192 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) : (\u2205 : Set \u03b1).Pairwise r :=\n  subsingleton_empty.pairwise r\n#align set.pairwise_empty Set.pairwise_empty\n\n@[simp]\ntheorem pairwise_singleton (a : \u03b1) (r : \u03b1 \u2192 \u03b1 \u2192 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 \u03b1 r] : s.Pairwise r \u2194 \u2200 \u2983a\u2984, a \u2208 s \u2192 \u2200 \u2983b\u2984, b \u2208 s \u2192 r a b :=\n  forall\u2084_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 \u2194 Pairwise.of_refl _\n#align set.pairwise.of_refl Set.Pairwise.of_refl\n\ntheorem Nonempty.pairwise_iff_exists_forall [IsEquiv \u03b1 r] {s : Set \u03b9} (hs : s.Nonempty) :\n    s.Pairwise (r on f) \u2194 \u2203 z, \u2200 x \u2208 s, r (f x) z := by\n  constructor\n  \u00b7 rcases hs with \u27e8y, hy\u27e9\n    refine' fun H => \u27e8f y, fun x hx => _\u27e9\n    rcases eq_or_ne x y with (rfl | hne)\n    \u00b7 apply IsRefl.refl\n    \u00b7 exact H hx hy hne\n  \u00b7 rintro \u27e8z, hz\u27e9 x hx y hy _\n    exact @IsTrans.trans \u03b1 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 \u2208 s`. See also\n`Set.pairwise_eq_iff_exists_eq` for a version that assumes `[Nonempty \u03b9]` instead of\n`Set.Nonempty s`. -/\ntheorem Nonempty.pairwise_eq_iff_exists_eq {s : Set \u03b1} (hs : s.Nonempty) {f : \u03b1 \u2192 \u03b9} :\n    (s.Pairwise fun x y => f x = f y) \u2194 \u2203 z, \u2200 x \u2208 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 \u03b9] (s : Set \u03b1) (f : \u03b1 \u2192 \u03b9) {r : \u03b9 \u2192 \u03b9 \u2192 Prop}\n    [IsEquiv \u03b9 r] : s.Pairwise (r on f) \u2194 \u2203 z, \u2200 x \u2208 s, r (f x) z := by\n  rcases s.eq_empty_or_nonempty with (rfl | hne)\n  \u00b7 simp\n  \u00b7 exact hne.pairwise_iff_exists_forall\n#align set.pairwise_iff_exists_forall Set.pairwise_iff_exists_forall\n\n/-- A function `f : \u03b1 \u2192 \u03b9` 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 \u2208 s`. See also\n`Set.Nonempty.pairwise_eq_iff_exists_eq` for a version that assumes `Set.Nonempty s` instead of\n`[Nonempty \u03b9]`. -/\ntheorem pairwise_eq_iff_exists_eq [Nonempty \u03b9] (s : Set \u03b1) (f : \u03b1 \u2192 \u03b9) :\n    (s.Pairwise fun x y => f x = f y) \u2194 \u2203 z, \u2200 x \u2208 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 \u222a t).Pairwise r \u2194\n    s.Pairwise r \u2227 t.Pairwise r \u2227 \u2200 a \u2208 s, \u2200 b \u2208 t, a \u2260 b \u2192 r a b \u2227 r b a := by\n  simp only [Set.Pairwise, mem_union, or_imp, forall_and]\n  exact\n    \u27e8fun H => \u27e8H.1.1, H.2.2, H.2.1, fun x hx y hy hne => H.1.2 y hy x hx hne.symm\u27e9, fun H =>\n      \u27e8\u27e8H.1, fun x hx y hy hne => H.2.2.2 y hy x hx hne.symm\u27e9, H.2.2.1, H.2.1\u27e9\u27e9\n#align set.pairwise_union Set.pairwise_union\n\ntheorem pairwise_union_of_symmetric (hr : Symmetric r) :\n    (s \u222a t).Pairwise r \u2194 s.Pairwise r \u2227 t.Pairwise r \u2227 \u2200 a \u2208 s, \u2200 b \u2208 t, a \u2260 b \u2192 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 \u2194 s.Pairwise r \u2227 \u2200 b \u2208 s, a \u2260 b \u2192 r a b \u2227 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 \u2209 s) :\n    (insert a s).Pairwise r \u2194 s.Pairwise r \u2227 \u2200 b \u2208 s, r a b \u2227 r b a :=\n  pairwise_insert.trans <|\n    and_congr_right' <| forall\u2082_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 : \u2200 b \u2208 s, a \u2260 b \u2192 r a b \u2227 r b a) :\n    (insert a s).Pairwise r :=\n  pairwise_insert.2 \u27e8hs, h\u27e9\n#align set.pairwise.insert Set.Pairwise.insert\n\ntheorem Pairwise.insert_of_not_mem (ha : a \u2209 s) (hs : s.Pairwise r) (h : \u2200 b \u2208 s, r a b \u2227 r b a) :\n    (insert a s).Pairwise r :=\n  (pairwise_insert_of_not_mem ha).2 \u27e8hs, h\u27e9\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 \u2194 s.Pairwise r \u2227 \u2200 b \u2208 s, a \u2260 b \u2192 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 \u2209 s) :\n    (insert a s).Pairwise r \u2194 s.Pairwise r \u2227 \u2200 b \u2208 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 : \u2200 b \u2208 s, a \u2260 b \u2192 r a b) : (insert a s).Pairwise r :=\n  (pairwise_insert_of_symmetric hr).2 \u27e8hs, h\u27e9\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 \u2209 s)\n    (h : \u2200 b \u2208 s, r a b) : (insert a s).Pairwise r :=\n  (pairwise_insert_of_symmetric_of_not_mem hr ha).2 \u27e8hs, h\u27e9\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 \u2194 a \u2260 b \u2192 r a b \u2227 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 \u2194 a \u2260 b \u2192 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 \u03b1).Pairwise r \u2194 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 (\u22a5 : \u03b1 \u2192 \u03b1 \u2192 Prop) \u2194 (s : Set \u03b1).Subsingleton :=\n  \u27e8fun h _a ha _b hb => h.eq ha hb id, fun h => h.pairwise _\u27e9\n#align set.pairwise_bot_iff Set.pairwise_bot_iff\n\nalias pairwise_bot_iff \u2194 Pairwise.subsingleton _\n#align set.pairwise.subsingleton Set.Pairwise.subsingleton\n\ntheorem InjOn.pairwise_image {s : Set \u03b9} (h : s.InjOn f) :\n    (f '' s).Pairwise r \u2194 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 \u03b1) (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :\n    (Pairwise fun (x : s) (y : s) => r x y) \u2194 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 \u2194 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 \u03b1] [OrderBot \u03b1] {s t : Set \u03b9} {f g : \u03b9 \u2192 \u03b1}\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 \u03b9) (f : \u03b9 \u2192 \u03b1) : Prop :=\n  s.Pairwise (Disjoint on f)\n#align set.pairwise_disjoint Set.PairwiseDisjoint\n\ntheorem PairwiseDisjoint.subset (ht : t.PairwiseDisjoint f) (h : s \u2286 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 : \u2200 \u2983i\u2984, i \u2208 s \u2192 g i \u2264 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 \u2264 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 : (\u2205 : Set \u03b9).PairwiseDisjoint f :=\n  pairwise_empty _\n#align set.pairwise_disjoint_empty Set.pairwiseDisjoint_empty\n\n@[simp]\ntheorem pairwiseDisjoint_singleton (i : \u03b9) (f : \u03b9 \u2192 \u03b1) : PairwiseDisjoint {i} f :=\n  pairwise_singleton i _\n#align set.pairwise_disjoint_singleton Set.pairwiseDisjoint_singleton\n\ntheorem pairwiseDisjoint_insert {i : \u03b9} :\n    (insert i s).PairwiseDisjoint f \u2194\n      s.PairwiseDisjoint f \u2227 \u2200 j \u2208 s, i \u2260 j \u2192 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 : \u03b9} (hi : i \u2209 s) :\n    (insert i s).PairwiseDisjoint f \u2194 s.PairwiseDisjoint f \u2227 \u2200 j \u2208 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 : \u03b9}\n    (h : \u2200 j \u2208 s, i \u2260 j \u2192 Disjoint (f i) (f j)) : (insert i s).PairwiseDisjoint f :=\n  pairwiseDisjoint_insert.2 \u27e8hs, h\u27e9\n#align set.pairwise_disjoint.insert Set.PairwiseDisjoint.insert\n\ntheorem PairwiseDisjoint.insert_of_not_mem (hs : s.PairwiseDisjoint f) {i : \u03b9} (hi : i \u2209 s)\n    (h : \u2200 j \u2208 s, Disjoint (f i) (f j)) : (insert i s).PairwiseDisjoint f :=\n  (pairwiseDisjoint_insert_of_not_mem hi).2 \u27e8hs, h\u27e9\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 : \u03b9 \u2192 \u03b9} (hg : f \u2218 g \u2264 f) :\n    (g '' s).PairwiseDisjoint f := by\n  rintro _ \u27e8a, ha, rfl\u27e9 _ \u27e8b, hb, rfl\u27e9 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 : \u03b9' \u2192 \u03b9} {s : Set \u03b9'} (h : s.InjOn g) :\n    (g '' s).PairwiseDisjoint f \u2194 s.PairwiseDisjoint (f \u2218 g) :=\n  h.pairwise_image\n#align set.inj_on.pairwise_disjoint_image Set.InjOn.pairwiseDisjoint_image\n\ntheorem PairwiseDisjoint.range (g : s \u2192 \u03b9) (hg : \u2200 i : s, f (g i) \u2264 f i)\n    (ht : s.PairwiseDisjoint f) : (range g).PairwiseDisjoint f := by\n  rintro _ \u27e8x, rfl\u27e9 _ \u27e8y, rfl\u27e9 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 \u222a t).PairwiseDisjoint f \u2194\n      s.PairwiseDisjoint f \u2227\n        t.PairwiseDisjoint f \u2227 \u2200 \u2983i\u2984, i \u2208 s \u2192 \u2200 \u2983j\u2984, j \u2208 t \u2192 i \u2260 j \u2192 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 : \u2200 \u2983i\u2984, i \u2208 s \u2192 \u2200 \u2983j\u2984, j \u2208 t \u2192 i \u2260 j \u2192 Disjoint (f i) (f j)) : (s \u222a t).PairwiseDisjoint f :=\n  pairwiseDisjoint_union.2 \u27e8hs, ht, h\u27e9\n#align set.pairwise_disjoint.union Set.PairwiseDisjoint.union\n\n-- classical\ntheorem PairwiseDisjoint.elim (hs : s.PairwiseDisjoint f) {i j : \u03b9} (hi : i \u2208 s) (hj : j \u2208 s)\n    (h : \u00acDisjoint (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 \u03b1] [OrderBot \u03b1] {s t : Set \u03b9} {f g : \u03b9 \u2192 \u03b1}\n\n-- classical\ntheorem PairwiseDisjoint.elim' (hs : s.PairwiseDisjoint f) {i j : \u03b9} (hi : i \u2208 s) (hj : j \u2208 s)\n    (h : f i \u2293 f j \u2260 \u22a5) : 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 : \u03b9} (hi : i \u2208 s) (hj : j \u2208 s)\n    (hf : f i \u2260 \u22a5) (hij : f i \u2264 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 : \u03b9 \u2192 Set \u03b9)).PairwiseDisjoint id := by\n  rintro _ \u27e8a, rfl\u27e9 _ \u27e8b, rfl\u27e9 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 : \u03b9 \u2192 \u03b1) (s : Set \u03b1) : s.PairwiseDisjoint fun a => f \u207b\u00b9' {a} :=\n  fun _a _ _b _ h => disjoint_iff_inf_le.mpr fun _i \u27e8hia, hib\u27e9 => h <| (Eq.symm hia).trans hib\n#align set.pairwise_disjoint_fiber Set.pairwiseDisjoint_fiber\n\n-- classical\ntheorem PairwiseDisjoint.elim_set {s : Set \u03b9} {f : \u03b9 \u2192 Set \u03b1} (hs : s.PairwiseDisjoint f) {i j : \u03b9}\n    (hi : i \u2208 s) (hj : j \u2208 s) (a : \u03b1) (hai : a \u2208 f i) (haj : a \u2208 f j) : i = j :=\n  hs.elim hi hj <| not_disjoint_iff.2 \u27e8a, hai, haj\u27e9\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {s : Set \u03b1} {t : Set \u03b2}\n    (hf : \u2200 a \u2208 s, Injective (f a)) :\n    (s.PairwiseDisjoint fun a => f a '' t) \u2194 (s \u00d7\u02e2 t).InjOn fun p => f p.1 p.2 := by\n  refine' \u27e8fun hs x hx y hy (h : f _ _ = _) => _, fun hs x hx y hy h => _\u27e9\n  \u00b7 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 \u27e8_, mem_image_of_mem _ hx.2, _\u27e9)\n    rw [h]\n    exact mem_image_of_mem _ hy.2\n  \u00b7 refine' disjoint_iff_inf_le.mpr _\n    rintro _ \u27e8\u27e8a, ha, hab\u27e9, b, hb, rfl\u27e9\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {s : Set \u03b1} {t : Set \u03b2}\n    (hf : \u2200 b \u2208 t, Injective fun a => f a b) :\n    (t.PairwiseDisjoint fun b => (fun a => f a b) '' s) \u2194 (s \u00d7\u02e2 t).InjOn fun p => f p.1 p.2 := by\n  refine' \u27e8fun ht x hx y hy (h : f _ _ = _) => _, fun ht x hx y hy h => _\u27e9\n  \u00b7 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 \u27e8_, mem_image_of_mem _ hx.1, _\u27e9)\n    rw [h]\n    exact mem_image_of_mem _ hy.1\n  \u00b7 refine' disjoint_iff_inf_le.mpr _\n    rintro _ \u27e8\u27e8a, ha, hab\u27e9, b, hb, rfl\u27e9\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 : \u03b9 \u2192 \u03b1) : Pairwise (Disjoint on fun a : \u03b1 => f \u207b\u00b9' {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 : \u2200 {W X Y Z : C} (f : W \u27f6 X), f \u2297 (0 : Y \u27f6 Z) = 0 := by aesop_cat\n  /-- tensoring on the left with a zero morphism gives zero -/\n  zero_tensor : \u2200 {W X Y Z : C} (f : Y \u27f6 Z), (0 : W \u27f6 X) \u2297 f = 0 := by aesop_cat\n  /-- left tensoring with a morphism is compatible with addition -/\n  tensor_add : \u2200 {W X Y Z : C} (f : W \u27f6 X) (g h : Y \u27f6 Z), f \u2297 (g + h) = f \u2297 g + f \u2297 h := by\n    aesop_cat\n  /-- right tensoring with a morphism is compatible with addition -/\n  add_tensor : \u2200 {W X Y Z : C} (f g : W \u27f6 X) (h : Y \u27f6 Z), (f + g) \u2297 h = f \u2297 h + g \u2297 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 \u27f6 Q) (g : J \u2192 (R \u27f6 S)) :\n    (f \u2297 \u2211 j in s, g j) = \u2211 j in s, f \u2297 g j := by\n  rw [\u2190 tensor_id_comp_id_tensor]\n  let tQ := (((tensoringLeft C).obj Q).mapAddHom : (R \u27f6 S) \u2192+ _)\n  change _ \u226b 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 \u27f6 Q) (g : J \u2192 (R \u27f6 S)) :\n    (\u2211 j in s, g j) \u2297 f = \u2211 j in s, g j \u2297 f := by\n  rw [\u2190 tensor_id_comp_id_tensor]\n  let tQ := (((tensoringRight C).obj P).mapAddHom : (R \u27f6 S) \u2192+ _)\n  change tQ _ \u226b _ = _\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 [\u2190 tensor_comp, Category.comp_id, \u2190 tensor_sum, \u2190 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 [\u2190 tensor_comp, Category.comp_id, \u2190 sum_tensor, \u2190 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 \u2192 C) : X \u2297 \u2a01 f \u2245 \u2a01 fun j => X \u2297 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 \u2192 C) :\n    (leftDistributor X f).hom =\n      \u2211 j : J, (\ud835\udfd9 X \u2297 biproduct.\u03c0 f j) \u226b biproduct.\u03b9 (fun j => X \u2297 f j) j := by\n  ext\n  dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]\n  erw [biproduct.lift_\u03c0]\n  simp only [Preadditive.sum_comp, Category.assoc, biproduct.\u03b9_\u03c0, 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 \u2192 C) :\n    (leftDistributor X f).inv = \u2211 j : J, biproduct.\u03c0 _ j \u226b (\ud835\udfd9 X \u2297 biproduct.\u03b9 f j) := by\n  ext\n  dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]\n  simp only [Preadditive.comp_sum, biproduct.\u03b9_\u03c0_assoc, dite_comp, zero_comp,\n    Finset.sum_dite_eq, Finset.mem_univ, ite_true, eqToHom_refl, Category.id_comp,\n    biproduct.\u03b9_desc]\n#align category_theory.left_distributor_inv CategoryTheory.leftDistributor_inv\n\ntheorem leftDistributor_assoc {J : Type} [Fintype J] (X Y : C) (f : J \u2192 C) :\n    (asIso (\ud835\udfd9 X) \u2297 leftDistributor Y f) \u226a\u226b leftDistributor X _ =\n      (\u03b1_ X Y (\u2a01 f)).symm \u226a\u226b leftDistributor (X \u2297 Y) f \u226a\u226b biproduct.mapIso fun j => \u03b1_ 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.\u03b9_map,\n    biproduct.\u03b9_\u03c0, Finset.sum_dite_irrel, Finset.sum_dite_eq', Finset.sum_const_zero]\n  simp only [\u2190 id_tensor_comp, biproduct.\u03b9_\u03c0]\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 [\u2190 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 \u2192 C) : (\u2a01 f) \u2297 X \u2245 \u2a01 fun j => f j \u2297 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 \u2192 C) :\n    (rightDistributor X f).hom =\n      \u2211 j : J, (biproduct.\u03c0 f j \u2297 \ud835\udfd9 X) \u226b biproduct.\u03b9 (fun j => f j \u2297 X) j := by\n  ext\n  dsimp [rightDistributor, Functor.mapBiproduct, Functor.mapBicone]\n  erw [biproduct.lift_\u03c0]\n  simp only [Preadditive.sum_comp, Category.assoc, biproduct.\u03b9_\u03c0, 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 \u2192 C) :\n    (rightDistributor X f).inv = \u2211 j : J, biproduct.\u03c0 _ j \u226b (biproduct.\u03b9 f j \u2297 \ud835\udfd9 X) := by\n  ext\n  dsimp [rightDistributor, Functor.mapBiproduct, Functor.mapBicone]\n  simp only [biproduct.\u03b9_desc, Preadditive.comp_sum, ne_eq, biproduct.\u03b9_\u03c0_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 \u2192 C) :\n    (rightDistributor X f \u2297 asIso (\ud835\udfd9 Y)) \u226a\u226b rightDistributor Y _ =\n      \u03b1_ (\u2a01 f) X Y \u226a\u226b rightDistributor (X \u2297 Y) f \u226a\u226b biproduct.mapIso fun j => (\u03b1_ _ 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.\u03b9_map,\n    biproduct.\u03b9_\u03c0, Finset.sum_dite_irrel, Finset.sum_dite_eq', Finset.sum_const_zero,\n    Finset.mem_univ, if_true]\n  simp only [\u2190 comp_tensor_id, biproduct.\u03b9_\u03c0, 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 [\u2190 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 \u2192 C) :\n    (leftDistributor X f \u2297 asIso (\ud835\udfd9 Y)) \u226a\u226b rightDistributor Y _ =\n      \u03b1_ X (\u2a01 f) Y \u226a\u226b\n        (asIso (\ud835\udfd9 X) \u2297 rightDistributor Y _) \u226a\u226b\n          leftDistributor X _ \u226a\u226b biproduct.mapIso fun j => (\u03b1_ _ _ _).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.\u03b9_map, biproduct.\u03b9_\u03c0, Finset.sum_dite_irrel,\n    Finset.sum_dite_eq', Finset.sum_const_zero, Finset.mem_univ, if_true]\n  simp only [\u2190 comp_tensor_id, \u2190 id_tensor_comp_assoc, Category.assoc, biproduct.\u03b9_\u03c0, 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 \u03b1 \u03c3` is a realization of a topology (basis) on `\u03b1`,\n  represented by a type `\u03c3` together with operations for the top element and\n  the intersection operation. -/\nstructure Ctop (\u03b1 \u03c3 : Type _) where\n  f : \u03c3 \u2192 Set \u03b1\n  top : \u03b1 \u2192 \u03c3\n  top_mem : \u2200 x : \u03b1, x \u2208 f (top x)\n  inter : \u2200 (a b) (x : \u03b1), x \u2208 f a \u2229 f b \u2192 \u03c3\n  inter_mem : \u2200 a b x h, x \u2208 f (inter a b x h)\n  inter_sub : \u2200 a b x h, f (inter a b x h) \u2286 f a \u2229 f b\n#align ctop Ctop\n-/\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03c3 : Type _} {\u03c4 : Type _}\n\ninstance : Inhabited (Ctop \u03b1 (Set \u03b1)) :=\n  \u27e8{  f := id\n      top := singleton\n      top_mem := mem_singleton\n      inter := fun s t _ _ => s \u2229 t\n      inter_mem := fun s t a => id\n      inter_sub := fun s t a ha => Subset.rfl }\u27e9\n\nnamespace Ctop\n\nsection\n\nvariable (F : Ctop \u03b1 \u03c3)\n\ninstance : CoeFun (Ctop \u03b1 \u03c3) fun _ => \u03c3 \u2192 Set \u03b1 :=\n  \u27e8Ctop.f\u27e9\n\n/- warning: ctop.coe_mk -> Ctop.coe_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} (f : \u03c3 -> (Set.{u1} \u03b1)) (T : \u03b1 -> \u03c3) (h\u2081 : forall (x : \u03b1), Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (f (T x))) (I : forall (a : \u03c3) (b : \u03c3) (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) (f a) (f b))) -> \u03c3) (h\u2082 : forall (a : \u03c3) (b : \u03c3) (x : \u03b1) (h : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) (f a) (f b))), Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (f (I a b x h))) (h\u2083 : forall (a : \u03c3) (b : \u03c3) (x : \u03b1) (h : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) (f a) (f b))), HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (f (I a b x h)) (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) (f a) (f b))) (a : \u03c3), Eq.{succ u1} (Set.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) (Ctop.mk.{u1, u2} \u03b1 \u03c3 f T h\u2081 I h\u2082 h\u2083) a) (f a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} (f : \u03c3 -> (Set.{u2} \u03b1)) (T : \u03b1 -> \u03c3) (h\u2081 : forall (x : \u03b1), Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (f (T x))) (I : forall (a : \u03c3) (b : \u03c3) (x : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Inter.inter.{u2} (Set.{u2} \u03b1) (Set.instInterSet.{u2} \u03b1) (f a) (f b))) -> \u03c3) (h\u2082 : forall (a : \u03c3) (b : \u03c3) (x : \u03b1) (h : Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Inter.inter.{u2} (Set.{u2} \u03b1) (Set.instInterSet.{u2} \u03b1) (f a) (f b))), Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (f (I a b x h))) (h\u2083 : forall (a : \u03c3) (b : \u03c3) (x : \u03b1) (h : Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Inter.inter.{u2} (Set.{u2} \u03b1) (Set.instInterSet.{u2} \u03b1) (f a) (f b))), HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (f (I a b x h)) (Inter.inter.{u2} (Set.{u2} \u03b1) (Set.instInterSet.{u2} \u03b1) (f a) (f b))) (a : \u03c3), Eq.{succ u2} (Set.{u2} \u03b1) (Ctop.f.{u2, u1} \u03b1 \u03c3 (Ctop.mk.{u2, u1} \u03b1 \u03c3 f T h\u2081 I h\u2082 h\u2083) a) (f a)\nCase conversion may be inaccurate. Consider using '#align ctop.coe_mk Ctop.coe_mk\u2093'. -/\n@[simp]\ntheorem coe_mk (f T h\u2081 I h\u2082 h\u2083 a) : (@Ctop.mk \u03b1 \u03c3 f T h\u2081 I h\u2082 h\u2083) 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 : \u03c3 \u2243 \u03c4) : Ctop \u03b1 \u03c3 \u2192 Ctop \u03b1 \u03c4\n  | \u27e8f, T, h\u2081, I, h\u2082, h\u2083\u27e9 =>\n    { f := fun a => f (E.symm a)\n      top := fun x => E (T x)\n      top_mem := fun x => by simpa using h\u2081 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\u2082 (E.symm a) (E.symm b) x h\n      inter_sub := fun a b x h => by simpa using h\u2083 (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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} {\u03c4 : Type.{u3}} (E : Equiv.{succ u2, succ u3} \u03c3 \u03c4) (F : Ctop.{u1, u2} \u03b1 \u03c3) (a : \u03c4), Eq.{succ u1} (Set.{u1} \u03b1) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (Ctop.{u1, u3} \u03b1 \u03c4) (fun (_x : Ctop.{u1, u3} \u03b1 \u03c4) => \u03c4 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u3} \u03b1 \u03c4) (Ctop.ofEquiv.{u1, u2, u3} \u03b1 \u03c3 \u03c4 E F) a) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) F (coeFn.{max 1 (max (succ u3) (succ u2)) (succ u2) (succ u3), max (succ u3) (succ u2)} (Equiv.{succ u3, succ u2} \u03c4 \u03c3) (fun (_x : Equiv.{succ u3, succ u2} \u03c4 \u03c3) => \u03c4 -> \u03c3) (Equiv.hasCoeToFun.{succ u3, succ u2} \u03c4 \u03c3) (Equiv.symm.{succ u2, succ u3} \u03c3 \u03c4 E) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03c3 : Type.{u3}} {\u03c4 : Type.{u2}} (E : Equiv.{succ u3, succ u2} \u03c3 \u03c4) (F : Ctop.{u1, u3} \u03b1 \u03c3) (a : \u03c4), Eq.{succ u1} (Set.{u1} \u03b1) (Ctop.f.{u1, u2} \u03b1 \u03c4 (Ctop.ofEquiv.{u1, u3, u2} \u03b1 \u03c3 \u03c4 E F) a) (Ctop.f.{u1, u3} \u03b1 \u03c3 F (FunLike.coe.{max (succ u3) (succ u2), succ u2, succ u3} (Equiv.{succ u2, succ u3} \u03c4 \u03c3) \u03c4 (fun (_x : \u03c4) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03c4) => \u03c3) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u3} \u03c4 \u03c3) (Equiv.symm.{succ u3, succ u2} \u03c3 \u03c4 E) a))\nCase conversion may be inaccurate. Consider using '#align ctop.of_equiv_val Ctop.ofEquiv_val\u2093'. -/\n@[simp]\ntheorem ofEquiv_val (E : \u03c3 \u2243 \u03c4) (F : Ctop \u03b1 \u03c3) (a : \u03c4) : 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 \u03b1 \u03c3) : TopologicalSpace \u03b1 :=\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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} (F : Ctop.{u1, u2} \u03b1 \u03c3), TopologicalSpace.IsTopologicalBasis.{u1} \u03b1 (Ctop.toTopsp.{u1, u2} \u03b1 \u03c3 F) (Set.range.{u1, succ u2} (Set.{u1} \u03b1) \u03c3 (Ctop.f.{u1, u2} \u03b1 \u03c3 F))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} (F : Ctop.{u2, u1} \u03b1 \u03c3), TopologicalSpace.IsTopologicalBasis.{u2} \u03b1 (Ctop.toTopsp.{u2, u1} \u03b1 \u03c3 F) (Set.range.{u2, succ u1} (Set.{u2} \u03b1) \u03c3 (Ctop.f.{u2, u1} \u03b1 \u03c3 F))\nCase conversion may be inaccurate. Consider using '#align ctop.to_topsp_is_topological_basis Ctop.toTopsp_isTopologicalBasis\u2093'. -/\ntheorem toTopsp_isTopologicalBasis (F : Ctop \u03b1 \u03c3) :\n    @TopologicalSpace.IsTopologicalBasis _ F.toTopsp (Set.range F.f) :=\n  letI := F.to_topsp\n  \u27e8fun u \u27e8a, e\u2081\u27e9 v \u27e8b, e\u2082\u27e9 =>\n    e\u2081 \u25b8 e\u2082 \u25b8 fun x h => \u27e8_, \u27e8_, rfl\u27e9, F.inter_mem a b x h, F.inter_sub a b x h\u27e9,\n    eq_univ_iff_forall.2 fun x => \u27e8_, \u27e8_, rfl\u27e9, F.top_mem x\u27e9, rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} (F : Ctop.{u1, u2} \u03b1 \u03c3) {s : Set.{u1} \u03b1} {a : \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 (Ctop.toTopsp.{u1, u2} \u03b1 \u03c3 F) a)) (Exists.{succ u2} \u03c3 (fun (b : \u03c3) => And (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) F b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) F b) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} (F : Ctop.{u2, u1} \u03b1 \u03c3) {s : Set.{u2} \u03b1} {a : \u03b1}, Iff (Membership.mem.{u2, u2} (Set.{u2} \u03b1) (Filter.{u2} \u03b1) (instMembershipSetFilter.{u2} \u03b1) s (nhds.{u2} \u03b1 (Ctop.toTopsp.{u2, u1} \u03b1 \u03c3 F) a)) (Exists.{succ u1} \u03c3 (fun (b : \u03c3) => And (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 \u03c3 F b)) (HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (Ctop.f.{u2, u1} \u03b1 \u03c3 F b) s)))\nCase conversion may be inaccurate. Consider using '#align ctop.mem_nhds_to_topsp Ctop.mem_nhds_toTopsp\u2093'. -/\n@[simp]\ntheorem mem_nhds_toTopsp (F : Ctop \u03b1 \u03c3) {s : Set \u03b1} {a : \u03b1} :\n    s \u2208 @nhds _ F.toTopsp a \u2194 \u2203 b, a \u2208 F b \u2227 F b \u2286 s :=\n  (@TopologicalSpace.IsTopologicalBasis.mem_nhds_iff _ F.toTopsp _ _ _\n        F.toTopsp_isTopologicalBasis).trans <|\n    \u27e8fun \u27e8_, \u27e8x, rfl\u27e9, h\u27e9 => \u27e8x, h\u27e9, fun \u27e8x, h\u27e9 => \u27e8_, \u27e8x, rfl\u27e9, h\u27e9\u27e9\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 (\u03b1) [T : TopologicalSpace \u03b1] where\n  \u03c3 : Type _\n  f : Ctop \u03b1 \u03c3\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 \u03b1 \u03c3) : @Ctop.Realizer _ F.toTopsp :=\n  @Ctop.Realizer.mk _ F.toTopsp \u03c3 F rfl\n#align ctop.to_realizer Ctop.toRealizer\n-/\n\ninstance (F : Ctop \u03b1 \u03c3) : Inhabited (@Ctop.Realizer _ F.toTopsp) :=\n  \u27e8F.toRealizer\u27e9\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 {\u03b1 : Type.{u1}} [T : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u2} \u03b1 T), TopologicalSpace.IsTopologicalBasis.{u1} \u03b1 T (Set.range.{u1, succ u2} (Set.{u1} \u03b1) (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F) (Ctop.f.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F) (Ctop.Realizer.f.{u1, u2} \u03b1 T F)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [T : TopologicalSpace.{u2} \u03b1] (F : Ctop.Realizer.{u2, u1} \u03b1 T), TopologicalSpace.IsTopologicalBasis.{u2} \u03b1 T (Set.range.{u2, succ u1} (Set.{u2} \u03b1) (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 T F) (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 T F) (Ctop.Realizer.F.{u2, u1} \u03b1 T F)))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.is_basis Ctop.Realizer.is_basis\u2093'. -/\nprotected theorem is_basis [T : TopologicalSpace \u03b1] (F : Realizer \u03b1) :\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 {\u03b1 : Type.{u1}} [T : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u2} \u03b1 T) {s : Set.{u1} \u03b1} {a : \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 T a)) (Exists.{succ u2} (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F) (fun (b : Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F) => And (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F)) (Ctop.Realizer.f.{u1, u2} \u03b1 T F) b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 T F)) (Ctop.Realizer.f.{u1, u2} \u03b1 T F) b) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [T : TopologicalSpace.{u2} \u03b1] (F : Ctop.Realizer.{u2, u1} \u03b1 T) {s : Set.{u2} \u03b1} {a : \u03b1}, Iff (Membership.mem.{u2, u2} (Set.{u2} \u03b1) (Filter.{u2} \u03b1) (instMembershipSetFilter.{u2} \u03b1) s (nhds.{u2} \u03b1 T a)) (Exists.{succ u1} (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 T F) (fun (b : Ctop.Realizer.\u03c3.{u2, u1} \u03b1 T F) => And (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 T F) (Ctop.Realizer.F.{u2, u1} \u03b1 T F) b)) (HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 T F) (Ctop.Realizer.F.{u2, u1} \u03b1 T F) b) s)))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.mem_nhds Ctop.Realizer.mem_nhds\u2093'. -/\nprotected theorem mem_nhds [T : TopologicalSpace \u03b1] (F : Realizer \u03b1) {s : Set \u03b1} {a : \u03b1} :\n    s \u2208 \ud835\udcdd a \u2194 \u2203 b, a \u2208 F.f b \u2227 F.f b \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u2} \u03b1 _inst_1) {s : Set.{u1} \u03b1}, Iff (IsOpen.{u1} \u03b1 _inst_1 s) (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a s) -> (Exists.{succ u2} (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) (fun (b : Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) => And (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) b) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] (F : Ctop.Realizer.{u2, u1} \u03b1 _inst_1) {s : Set.{u2} \u03b1}, Iff (IsOpen.{u2} \u03b1 _inst_1 s) (forall (a : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a s) -> (Exists.{succ u1} (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (fun (b : Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) => And (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) b)) (HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) b) s))))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.is_open_iff Ctop.Realizer.isOpen_iff\u2093'. -/\ntheorem isOpen_iff [TopologicalSpace \u03b1] (F : Realizer \u03b1) {s : Set \u03b1} :\n    IsOpen s \u2194 \u2200 a \u2208 s, \u2203 b, a \u2208 F.f b \u2227 F.f b \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u2} \u03b1 _inst_1) {s : Set.{u1} \u03b1}, Iff (IsClosed.{u1} \u03b1 _inst_1 s) (forall (a : \u03b1), (forall (b : Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) b)) -> (Exists.{succ u1} \u03b1 (fun (z : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) z (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) b) s)))) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] (F : Ctop.Realizer.{u2, u1} \u03b1 _inst_1) {s : Set.{u2} \u03b1}, Iff (IsClosed.{u2} \u03b1 _inst_1 s) (forall (a : \u03b1), (forall (b : Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) b)) -> (Exists.{succ u2} \u03b1 (fun (z : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) z (Inter.inter.{u2} (Set.{u2} \u03b1) (Set.instInterSet.{u2} \u03b1) (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) b) s)))) -> (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a s))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.is_closed_iff Ctop.Realizer.isClosed_iff\u2093'. -/\ntheorem isClosed_iff [TopologicalSpace \u03b1] (F : Realizer \u03b1) {s : Set \u03b1} :\n    IsClosed s \u2194 \u2200 a, (\u2200 b, a \u2208 F.f b \u2192 \u2203 z, z \u2208 F.f b \u2229 s) \u2192 a \u2208 s :=\n  isOpen_compl_iff.symm.trans <|\n    F.isOpen_iff.trans <|\n      forall_congr' fun a =>\n        show (a \u2209 s \u2192 \u2203 b : F.\u03c3, a \u2208 F.f b \u2227 \u2200 z \u2208 F.f b, z \u2209 s) \u2194 _ 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u2} \u03b1 _inst_1) {s : Set.{u1} \u03b1} {a : \u03b1}, Iff (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (interior.{u1} \u03b1 _inst_1 s)) (Exists.{succ u2} (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) (fun (b : Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) => And (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) b) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] (F : Ctop.Realizer.{u2, u1} \u03b1 _inst_1) {s : Set.{u2} \u03b1} {a : \u03b1}, Iff (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (interior.{u2} \u03b1 _inst_1 s)) (Exists.{succ u1} (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (fun (b : Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) => And (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) b)) (HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) b) s)))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.mem_interior_iff Ctop.Realizer.mem_interior_iff\u2093'. -/\ntheorem mem_interior_iff [TopologicalSpace \u03b1] (F : Realizer \u03b1) {s : Set \u03b1} {a : \u03b1} :\n    a \u2208 interior s \u2194 \u2203 b, a \u2208 F.f b \u2227 F.f b \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u2} \u03b1 _inst_1) (s : Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F), IsOpen.{u1} \u03b1 _inst_1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] (F : Ctop.Realizer.{u2, u1} \u03b1 _inst_1) (s : Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F), IsOpen.{u2} \u03b1 _inst_1 (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) s)\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.is_open Ctop.Realizer.isOpen\u2093'. -/\nprotected theorem isOpen [TopologicalSpace \u03b1] (F : Realizer \u03b1) (s : F.\u03c3) : IsOpen (F.f s) :=\n  isOpen_iff_nhds.2 fun a m => by simpa using F.mem_nhds.2 \u27e8s, m, subset.refl _\u27e9\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 {\u03b1 : Type.{u1}} [T : TopologicalSpace.{u1} \u03b1] {\u03c3 : Type.{u2}} {F : Ctop.{u1, u2} \u03b1 \u03c3}, (forall (a : \u03b1) (s : Set.{u1} \u03b1), Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 T a)) (Exists.{succ u2} \u03c3 (fun (b : \u03c3) => And (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) F b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) F b) s)))) -> (Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (Ctop.toTopsp.{u1, u2} \u03b1 \u03c3 F) T)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [T : TopologicalSpace.{u2} \u03b1] {\u03c3 : Type.{u1}} {F : Ctop.{u2, u1} \u03b1 \u03c3}, (forall (a : \u03b1) (s : Set.{u2} \u03b1), Iff (Membership.mem.{u2, u2} (Set.{u2} \u03b1) (Filter.{u2} \u03b1) (instMembershipSetFilter.{u2} \u03b1) s (nhds.{u2} \u03b1 T a)) (Exists.{succ u1} \u03c3 (fun (b : \u03c3) => And (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 \u03c3 F b)) (HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (Ctop.f.{u2, u1} \u03b1 \u03c3 F b) s)))) -> (Eq.{succ u2} (TopologicalSpace.{u2} \u03b1) (Ctop.toTopsp.{u2, u1} \u03b1 \u03c3 F) T)\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.ext' Ctop.Realizer.ext'\u2093'. -/\ntheorem ext' [T : TopologicalSpace \u03b1] {\u03c3 : Type _} {F : Ctop \u03b1 \u03c3}\n    (H : \u2200 a s, s \u2208 \ud835\udcdd a \u2194 \u2203 b, a \u2208 F b \u2227 F b \u2286 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 {\u03b1 : Type.{u1}} [T : TopologicalSpace.{u1} \u03b1] {\u03c3 : Type.{u2}} {F : Ctop.{u1, u2} \u03b1 \u03c3}, (forall (a : \u03c3), IsOpen.{u1} \u03b1 T (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) F a)) -> (forall (a : \u03b1) (s : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 T a)) -> (Exists.{succ u2} \u03c3 (fun (b : \u03c3) => And (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) F b)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 \u03c3) (fun (_x : Ctop.{u1, u2} \u03b1 \u03c3) => \u03c3 -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 \u03c3) F b) s)))) -> (Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (Ctop.toTopsp.{u1, u2} \u03b1 \u03c3 F) T)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [T : TopologicalSpace.{u2} \u03b1] {\u03c3 : Type.{u1}} {F : Ctop.{u2, u1} \u03b1 \u03c3}, (forall (a : \u03c3), IsOpen.{u2} \u03b1 T (Ctop.f.{u2, u1} \u03b1 \u03c3 F a)) -> (forall (a : \u03b1) (s : Set.{u2} \u03b1), (Membership.mem.{u2, u2} (Set.{u2} \u03b1) (Filter.{u2} \u03b1) (instMembershipSetFilter.{u2} \u03b1) s (nhds.{u2} \u03b1 T a)) -> (Exists.{succ u1} \u03c3 (fun (b : \u03c3) => And (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 \u03c3 F b)) (HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (Ctop.f.{u2, u1} \u03b1 \u03c3 F b) s)))) -> (Eq.{succ u2} (TopologicalSpace.{u2} \u03b1) (Ctop.toTopsp.{u2, u1} \u03b1 \u03c3 F) T)\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.ext Ctop.Realizer.ext\u2093'. -/\ntheorem ext [T : TopologicalSpace \u03b1] {\u03c3 : Type _} {F : Ctop \u03b1 \u03c3} (H\u2081 : \u2200 a, IsOpen (F a))\n    (H\u2082 : \u2200 a s, s \u2208 \ud835\udcdd a \u2192 \u2203 b, a \u2208 F b \u2227 F b \u2286 s) : F.toTopsp = T :=\n  ext' fun a s => \u27e8H\u2082 a s, fun \u27e8b, h\u2081, h\u2082\u27e9 => mem_nhds_iff.2 \u27e8_, h\u2082, H\u2081 _, h\u2081\u27e9\u27e9\n#align ctop.realizer.ext Ctop.Realizer.ext\n\nvariable [TopologicalSpace \u03b1]\n\n#print Ctop.Realizer.id /-\n/-- The topological space realizer made of the open sets. -/\nprotected def id : Realizer \u03b1 :=\n  \u27e8{ x : Set \u03b1 // IsOpen x },\n    { f := Subtype.val\n      top := fun _ => \u27e8univ, isOpen_univ\u27e9\n      top_mem := mem_univ\n      inter := fun \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a h\u2083 => \u27e8_, h\u2081.inter h\u2082\u27e9\n      inter_mem := fun \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a => id\n      inter_sub := fun \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 a h\u2083 => Subset.refl _ },\n    ext Subtype.property fun x s h =>\n      let \u27e8t, h, o, m\u27e9 := mem_nhds_iff.1 h\n      \u27e8\u27e8t, o\u27e9, m, h\u27e9\u27e9\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 \u03b1) (E : F.\u03c3 \u2243 \u03c4) : Realizer \u03b1 :=\n  \u27e8\u03c4, F.f.of_equiv E,\n    ext' fun a s =>\n      F.mem_nhds.trans <|\n        \u27e8fun \u27e8s, h\u27e9 => \u27e8E s, by simpa using h\u27e9, fun \u27e8t, h\u27e9 => \u27e8E.symm t, by simpa using h\u27e9\u27e9\u27e9\n#align ctop.realizer.of_equiv Ctop.Realizer.ofEquiv\n-/\n\n/- warning: ctop.realizer.of_equiv_\u03c3 -> Ctop.Realizer.ofEquiv_\u03c3 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03c4 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u3} \u03b1 _inst_1) (E : Equiv.{succ u3, succ u2} (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F) \u03c4), Eq.{succ (succ u2)} Type.{u2} (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} \u03b1 \u03c4 _inst_1 F E)) \u03c4\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03c4 : Type.{u1}} [_inst_1 : TopologicalSpace.{u3} \u03b1] (F : Ctop.Realizer.{u3, u2} \u03b1 _inst_1) (E : Equiv.{succ u2, succ u1} (Ctop.Realizer.\u03c3.{u3, u2} \u03b1 _inst_1 F) \u03c4), Eq.{succ (succ u1)} Type.{u1} (Ctop.Realizer.\u03c3.{u3, u1} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u3, u1, u2} \u03b1 \u03c4 _inst_1 F E)) \u03c4\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.of_equiv_\u03c3 Ctop.Realizer.ofEquiv_\u03c3\u2093'. -/\n@[simp]\ntheorem ofEquiv_\u03c3 (F : Realizer \u03b1) (E : F.\u03c3 \u2243 \u03c4) : (F.of_equiv E).\u03c3 = \u03c4 :=\n  rfl\n#align ctop.realizer.of_equiv_\u03c3 Ctop.Realizer.ofEquiv_\u03c3\n\n/- warning: ctop.realizer.of_equiv_F -> Ctop.Realizer.ofEquiv_F is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03c4 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u3} \u03b1 _inst_1) (E : Equiv.{succ u3, succ u2} (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F) \u03c4) (s : \u03c4), Eq.{succ u1} (Set.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} \u03b1 \u03c4 _inst_1 F E))) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} \u03b1 \u03c4 _inst_1 F E))) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} \u03b1 \u03c4 _inst_1 F E)) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} \u03b1 \u03c4 _inst_1 F E))) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u1, u2, u3} \u03b1 \u03c4 _inst_1 F E)) s) (coeFn.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (Ctop.{u1, u3} \u03b1 (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u3} \u03b1 (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u3} \u03b1 (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u3} \u03b1 _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} \u03c4 (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F)) (fun (_x : Equiv.{succ u2, succ u3} \u03c4 (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F)) => \u03c4 -> (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F)) (Equiv.hasCoeToFun.{succ u2, succ u3} \u03c4 (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F)) (Equiv.symm.{succ u3, succ u2} (Ctop.Realizer.\u03c3.{u1, u3} \u03b1 _inst_1 F) \u03c4 E) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03c4 : Type.{u1}} [_inst_1 : TopologicalSpace.{u3} \u03b1] (F : Ctop.Realizer.{u3, u2} \u03b1 _inst_1) (E : Equiv.{succ u2, succ u1} (Ctop.Realizer.\u03c3.{u3, u2} \u03b1 _inst_1 F) \u03c4) (s : \u03c4), Eq.{succ u3} (Set.{u3} \u03b1) (Ctop.f.{u3, u1} \u03b1 (Ctop.Realizer.\u03c3.{u3, u1} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u3, u1, u2} \u03b1 \u03c4 _inst_1 F E)) (Ctop.Realizer.F.{u3, u1} \u03b1 _inst_1 (Ctop.Realizer.ofEquiv.{u3, u1, u2} \u03b1 \u03c4 _inst_1 F E)) s) (Ctop.f.{u3, u2} \u03b1 (Ctop.Realizer.\u03c3.{u3, u2} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u3, u2} \u03b1 _inst_1 F) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Equiv.{succ u1, succ u2} \u03c4 (Ctop.Realizer.\u03c3.{u3, u2} \u03b1 _inst_1 F)) \u03c4 (fun (_x : \u03c4) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03c4) => Ctop.Realizer.\u03c3.{u3, u2} \u03b1 _inst_1 F) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u2} \u03c4 (Ctop.Realizer.\u03c3.{u3, u2} \u03b1 _inst_1 F)) (Equiv.symm.{succ u2, succ u1} (Ctop.Realizer.\u03c3.{u3, u2} \u03b1 _inst_1 F) \u03c4 E) s))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.of_equiv_F Ctop.Realizer.ofEquiv_F\u2093'. -/\n@[simp]\ntheorem ofEquiv_F (F : Realizer \u03b1) (E : F.\u03c3 \u2243 \u03c4) (s : \u03c4) : (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 \u03b1) (a : \u03b1) : (\ud835\udcdd a).Realizer :=\n  \u27e8{ s : F.\u03c3 // a \u2208 F.f s },\n    { f := fun s => F.f s.1\n      pt := \u27e8_, F.f.top_mem a\u27e9\n      inf := fun \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 => \u27e8_, F.f.inter_mem x y a \u27e8h\u2081, h\u2082\u27e9\u27e9\n      inf_le_left := fun \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 z h => (F.f.inter_sub x y a \u27e8h\u2081, h\u2082\u27e9 h).1\n      inf_le_right := fun \u27e8x, h\u2081\u27e9 \u27e8y, h\u2082\u27e9 z h => (F.f.inter_sub x y a \u27e8h\u2081, h\u2082\u27e9 h).2 },\n    filter_eq <|\n      Set.ext fun x =>\n        \u27e8fun \u27e8\u27e8s, as\u27e9, h\u27e9 => mem_nhds_iff.2 \u27e8_, h, F.IsOpen _, as\u27e9, fun h =>\n          let \u27e8s, h, as\u27e9 := F.mem_nhds.1 h\n          \u27e8\u27e8s, h\u27e9, as\u27e9\u27e9\u27e9\n#align ctop.realizer.nhds Ctop.Realizer.nhds\n-/\n\n/- warning: ctop.realizer.nhds_\u03c3 -> Ctop.Realizer.nhds_\u03c3 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u2} \u03b1 _inst_1) (a : \u03b1), Eq.{succ (succ u2)} Type.{u2} (Filter.Realizer.\u03c3.{u1, u2} \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} \u03b1 _inst_1 F a)) (Subtype.{succ u2} (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) (fun (s : Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] (F : Ctop.Realizer.{u2, u1} \u03b1 _inst_1) (a : \u03b1), Eq.{succ (succ u1)} Type.{u1} (Filter.Realizer.\u03c3.{u2, u1} \u03b1 (nhds.{u2} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u2, u1} \u03b1 _inst_1 F a)) (Subtype.{succ u1} (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (fun (s : Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) s)))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.nhds_\u03c3 Ctop.Realizer.nhds_\u03c3\u2093'. -/\n@[simp]\ntheorem nhds_\u03c3 (F : Realizer \u03b1) (a : \u03b1) : (F.nhds a).\u03c3 = { s : F.\u03c3 // a \u2208 F.f s } :=\n  rfl\n#align ctop.realizer.nhds_\u03c3 Ctop.Realizer.nhds_\u03c3\n\n/- warning: ctop.realizer.nhds_F -> Ctop.Realizer.nhds_F is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u2} \u03b1 _inst_1) (a : \u03b1) (s : Filter.Realizer.\u03c3.{u1, u2} \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} \u03b1 _inst_1 F a)), Eq.{succ u1} (Set.{u1} \u03b1) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (CFilter.{u1, u2} (Set.{u1} \u03b1) (Filter.Realizer.\u03c3.{u1, u2} \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} \u03b1 _inst_1 F a)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1))))))) (fun (_x : CFilter.{u1, u2} (Set.{u1} \u03b1) (Filter.Realizer.\u03c3.{u1, u2} \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} \u03b1 _inst_1 F a)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1))))))) => (Filter.Realizer.\u03c3.{u1, u2} \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} \u03b1 _inst_1 F a)) -> (Set.{u1} \u03b1)) (CFilter.hasCoeToFun.{u1, u2} (Set.{u1} \u03b1) (Filter.Realizer.\u03c3.{u1, u2} \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} \u03b1 _inst_1 F a)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1))))))) (Filter.Realizer.f.{u1, u2} \u03b1 (nhds.{u1} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u1, u2} \u03b1 _inst_1 F a)) s) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) (Subtype.val.{succ u2} (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) (fun (s : Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (fun (_x : Ctop.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) => (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u2} \u03b1 (Ctop.Realizer.\u03c3.{u1, u2} \u03b1 _inst_1 F)) (Ctop.Realizer.f.{u1, u2} \u03b1 _inst_1 F) s)) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : TopologicalSpace.{u2} \u03b1] (F : Ctop.Realizer.{u2, u1} \u03b1 _inst_1) (a : \u03b1) (s : Filter.Realizer.\u03c3.{u2, u1} \u03b1 (nhds.{u2} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u2, u1} \u03b1 _inst_1 F a)), Eq.{succ u2} (Set.{u2} \u03b1) (CFilter.f.{u2, u1} (Set.{u2} \u03b1) (Filter.Realizer.\u03c3.{u2, u1} \u03b1 (nhds.{u2} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u2, u1} \u03b1 _inst_1 F a)) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) (Filter.Realizer.F.{u2, u1} \u03b1 (nhds.{u2} \u03b1 _inst_1 a) (Ctop.Realizer.nhds.{u2, u1} \u03b1 _inst_1 F a)) s) (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) (Subtype.val.{succ u1} (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (fun (s : Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 F) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 F) s)) s))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.nhds_F Ctop.Realizer.nhds_F\u2093'. -/\n@[simp]\ntheorem nhds_F (F : Realizer \u03b1) (a : \u03b1) (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] {m : \u03b2 -> \u03b1} {f : Filter.{u2} \u03b2} (F : Filter.Realizer.{u2, u3} \u03b2 f) (R : Ctop.Realizer.{u1, u4} \u03b1 _inst_1) {a : \u03b1}, Iff (Filter.Tendsto.{u2, u1} \u03b2 \u03b1 m f (nhds.{u1} \u03b1 _inst_1 a)) (forall (t : Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (coeFn.{max (succ u1) (succ u4), max (succ u4) (succ u1)} (Ctop.{u1, u4} \u03b1 (Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R)) (fun (_x : Ctop.{u1, u4} \u03b1 (Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R)) => (Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u4} \u03b1 (Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R)) (Ctop.Realizer.f.{u1, u4} \u03b1 _inst_1 R) t)) -> (Exists.{succ u3} (Filter.Realizer.\u03c3.{u2, u3} \u03b2 f F) (fun (s : Filter.Realizer.\u03c3.{u2, u3} \u03b2 f F) => forall (x : \u03b2), (Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) x (coeFn.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (CFilter.{u2, u3} (Set.{u2} \u03b2) (Filter.Realizer.\u03c3.{u2, u3} \u03b2 f F) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2))))))) (fun (_x : CFilter.{u2, u3} (Set.{u2} \u03b2) (Filter.Realizer.\u03c3.{u2, u3} \u03b2 f F) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2))))))) => (Filter.Realizer.\u03c3.{u2, u3} \u03b2 f F) -> (Set.{u2} \u03b2)) (CFilter.hasCoeToFun.{u2, u3} (Set.{u2} \u03b2) (Filter.Realizer.\u03c3.{u2, u3} \u03b2 f F) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2))))))) (Filter.Realizer.f.{u2, u3} \u03b2 f F) s)) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (m x) (coeFn.{max (succ u1) (succ u4), max (succ u4) (succ u1)} (Ctop.{u1, u4} \u03b1 (Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R)) (fun (_x : Ctop.{u1, u4} \u03b1 (Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R)) => (Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R) -> (Set.{u1} \u03b1)) (Ctop.hasCoeToFun.{u1, u4} \u03b1 (Ctop.Realizer.\u03c3.{u1, u4} \u03b1 _inst_1 R)) (Ctop.Realizer.f.{u1, u4} \u03b1 _inst_1 R) t)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u4}} [_inst_1 : TopologicalSpace.{u2} \u03b1] {m : \u03b2 -> \u03b1} {f : Filter.{u4} \u03b2} (F : Filter.Realizer.{u4, u3} \u03b2 f) (R : Ctop.Realizer.{u2, u1} \u03b1 _inst_1) {a : \u03b1}, Iff (Filter.Tendsto.{u4, u2} \u03b2 \u03b1 m f (nhds.{u2} \u03b1 _inst_1 a)) (forall (t : Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 R), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) a (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 R) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 R) t)) -> (Exists.{succ u3} (Filter.Realizer.\u03c3.{u4, u3} \u03b2 f F) (fun (s : Filter.Realizer.\u03c3.{u4, u3} \u03b2 f F) => forall (x : \u03b2), (Membership.mem.{u4, u4} \u03b2 (Set.{u4} \u03b2) (Set.instMembershipSet.{u4} \u03b2) x (CFilter.f.{u4, u3} (Set.{u4} \u03b2) (Filter.Realizer.\u03c3.{u4, u3} \u03b2 f F) (CompleteSemilatticeInf.toPartialOrder.{u4} (Set.{u4} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u4} (Set.{u4} \u03b2) (Order.Coframe.toCompleteLattice.{u4} (Set.{u4} \u03b2) (CompleteDistribLattice.toCoframe.{u4} (Set.{u4} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u4} (Set.{u4} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u4} \u03b2)))))) (Filter.Realizer.F.{u4, u3} \u03b2 f F) s)) -> (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) (m x) (Ctop.f.{u2, u1} \u03b1 (Ctop.Realizer.\u03c3.{u2, u1} \u03b1 _inst_1 R) (Ctop.Realizer.F.{u2, u1} \u03b1 _inst_1 R) t)))))\nCase conversion may be inaccurate. Consider using '#align ctop.realizer.tendsto_nhds_iff Ctop.Realizer.tendsto_nhds_iff\u2093'. -/\ntheorem tendsto_nhds_iff {m : \u03b2 \u2192 \u03b1} {f : Filter \u03b2} (F : f.Realizer) (R : Realizer \u03b1) {a : \u03b1} :\n    Tendsto m f (\ud835\udcdd a) \u2194 \u2200 t, a \u2208 R.f t \u2192 \u2203 s, \u2200 x \u2208 F.f s, m x \u2208 R.f t :=\n  (F.tendsto_iff\u2093 _ (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 \u03b1] (F : Realizer \u03b1) (f : \u03b2 \u2192 Set \u03b1) where\n  bas : \u2200 a, { s // a \u2208 F.f s }\n  sets : \u2200 x : \u03b1, Fintype { i | (f i \u2229 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] {F : Ctop.Realizer.{u1, u3} \u03b1 _inst_1} {f : \u03b2 -> (Set.{u1} \u03b1)}, (LocallyFinite.Realizer.{u1, u2, u3} \u03b1 \u03b2 _inst_1 F f) -> (LocallyFinite.{u2, u1} \u03b2 \u03b1 _inst_1 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} [_inst_1 : TopologicalSpace.{u3} \u03b1] {F : Ctop.Realizer.{u3, u2} \u03b1 _inst_1} {f : \u03b2 -> (Set.{u3} \u03b1)}, (LocallyFinite.Realizer.{u3, u1, u2} \u03b1 \u03b2 _inst_1 F f) -> (LocallyFinite.{u1, u3} \u03b2 \u03b1 _inst_1 f)\nCase conversion may be inaccurate. Consider using '#align locally_finite.realizer.to_locally_finite LocallyFinite.Realizer.to_locallyFinite\u2093'. -/\ntheorem LocallyFinite.Realizer.to_locallyFinite [TopologicalSpace \u03b1] {F : Realizer \u03b1}\n    {f : \u03b2 \u2192 Set \u03b1} (R : LocallyFinite.Realizer F f) : LocallyFinite f := fun a =>\n  \u27e8_, F.mem_nhds.2 \u27e8(R.bas a).1, (R.bas a).2, Subset.refl _\u27e9, \u27e8R.sets a\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : TopologicalSpace.{u1} \u03b1] (F : Ctop.Realizer.{u1, u3} \u03b1 _inst_1) {f : \u03b2 -> (Set.{u1} \u03b1)}, Iff (LocallyFinite.{u2, u1} \u03b2 \u03b1 _inst_1 f) (Nonempty.{max (succ u1) (succ u2) (succ u3)} (LocallyFinite.Realizer.{u1, u2, u3} \u03b1 \u03b2 _inst_1 F f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} [_inst_1 : TopologicalSpace.{u3} \u03b1] (F : Ctop.Realizer.{u3, u2} \u03b1 _inst_1) {f : \u03b2 -> (Set.{u3} \u03b1)}, Iff (LocallyFinite.{u1, u3} \u03b2 \u03b1 _inst_1 f) (Nonempty.{max (max (succ u2) (succ u1)) (succ u3)} (LocallyFinite.Realizer.{u3, u1, u2} \u03b1 \u03b2 _inst_1 F f))\nCase conversion may be inaccurate. Consider using '#align locally_finite_iff_exists_realizer locallyFinite_iff_exists_realizer\u2093'. -/\ntheorem locallyFinite_iff_exists_realizer [TopologicalSpace \u03b1] (F : Realizer \u03b1) {f : \u03b2 \u2192 Set \u03b1} :\n    LocallyFinite f \u2194 Nonempty (LocallyFinite.Realizer F f) :=\n  \u27e8fun h =>\n    let \u27e8g, h\u2081\u27e9 := Classical.axiom_of_choice h\n    let \u27e8g\u2082, h\u2082\u27e9 :=\n      Classical.axiom_of_choice fun x =>\n        show \u2203 b : F.\u03c3, x \u2208 F.f b \u2227 F.f b \u2286 g x from\n          let \u27e8h, h'\u27e9 := h\u2081 x\n          F.mem_nhds.1 h\n    \u27e8\u27e8fun x => \u27e8g\u2082 x, (h\u2082 x).1\u27e9, fun x =>\n        Finite.fintype <|\n          let \u27e8h, h'\u27e9 := h\u2081 x\n          h'.Subset fun i hi => hi.mono (inter_subset_inter_right _ (h\u2082 x).2)\u27e9\u27e9,\n    fun \u27e8R\u27e9 => R.to_locallyFinite\u27e9\n#align locally_finite_iff_exists_realizer locallyFinite_iff_exists_realizer\n\ninstance [TopologicalSpace \u03b1] [Finite \u03b2] (F : Realizer \u03b1) (f : \u03b2 \u2192 Set \u03b1) :\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 \u03b1] (s : Set \u03b1) :=\n  \u2200 {f : Filter \u03b1} (F : f.Realizer) (x : F.\u03c3), f \u2260 \u22a5 \u2192 F.f x \u2286 s \u2192 { a // a \u2208 s \u2227 \ud835\udcdd a \u2293 f \u2260 \u22a5 }\n#align compact.realizer Compact.Realizer\n-/\n\ninstance [TopologicalSpace \u03b1] : Inhabited (Compact.Realizer (\u2205 : Set \u03b1)) :=\n  \u27e8fun f F x h hF => by\n    cases h _\n    rw [\u2190 F.eq, eq_bot_iff]\n    exact fun s _ => \u27e8x, hF.trans s.empty_subset\u27e9\u27e9\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: S\u00e9bastien Gou\u00ebzel\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 `\u2113^\u221e(\u211d)` up to isometry, which is a well-defined type,\nand define the distance as the infimum of the Hausdorff distance over all\nembeddings in `\u2113^\u221e(\u211d)`. We prove that this coincides with the previous description,\nas all separable metric spaces embed isometrically into `\u2113^\u221e(\u211d)`, 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 `\u2113^\u221e(\u211d)` 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 \u2113^\u221e(\u211d) -/\nprotected instance isometry_rel.setoid : setoid (topological_space.nonempty_compacts \u2113_infty_\u211d) :=\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 (\u03b1 : Type u) [metric_space \u03b1] [compact_space \u03b1] [Nonempty \u03b1] : GH_space :=\n  quotient.mk (nonempty_compacts.Kuratowski_embedding \u03b1)\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  \u21a5(subtype.val (quot.out p))\n\ntheorem eq_to_GH_space_iff {\u03b1 : Type u} [metric_space \u03b1] [compact_space \u03b1] [Nonempty \u03b1] {p : topological_space.nonempty_compacts \u2113_infty_\u211d} : quotient.mk p = to_GH_space \u03b1 \u2194 \u2203 (\u03a8 : \u03b1 \u2192 \u2113_infty_\u211d), isometry \u03a8 \u2227 set.range \u03a8 = subtype.val p := sorry\n\ntheorem eq_to_GH_space {p : topological_space.nonempty_compacts \u2113_infty_\u211d} : quotient.mk p = to_GH_space \u21a5(subtype.val p) :=\n  iff.mpr eq_to_GH_space_iff\n    (Exists.intro (fun (x : \u21a5(subtype.val p)) => \u2191x) { 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 \u21a5(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 {\u03b1 : Type u} [metric_space \u03b1] [compact_space \u03b1] [Nonempty \u03b1] {\u03b2 : Type u} [metric_space \u03b2] [compact_space \u03b2] [Nonempty \u03b2] : to_GH_space \u03b1 = to_GH_space \u03b2 \u2194 Nonempty (\u03b1 \u2243\u1d62 \u03b2) := 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 `\u2113^\u221e(\u211d)`, 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 \u2113_infty_\u211d \u00d7 topological_space.nonempty_compacts \u2113_infty_\u211d) =>\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 \u2113_infty_\u211d) => quotient.mk a = x)\n            (set_of fun (b : topological_space.nonempty_compacts \u2113_infty_\u211d) => 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 (\u03b1 : Type u) (\u03b2 : Type v) [metric_space \u03b1] [Nonempty \u03b1] [compact_space \u03b1] [metric_space \u03b2] [Nonempty \u03b2] [compact_space \u03b2] : \u211d :=\n  dist (to_GH_space \u03b1) (to_GH_space \u03b2)\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 {\u03b1 : Type u} [metric_space \u03b1] [compact_space \u03b1] [Nonempty \u03b1] {\u03b2 : Type v} [metric_space \u03b2] [compact_space \u03b2] [Nonempty \u03b2] {\u03b3 : Type w} [metric_space \u03b3] {\u03a6 : \u03b1 \u2192 \u03b3} {\u03a8 : \u03b2 \u2192 \u03b3} (ha : isometry \u03a6) (hb : isometry \u03a8) : GH_dist \u03b1 \u03b2 \u2264 metric.Hausdorff_dist (set.range \u03a6) (set.range \u03a8) := sorry\n\n/-- The optimal coupling constructed above realizes exactly the Gromov-Hausdorff distance,\nessentially by design. -/\ntheorem Hausdorff_dist_optimal {\u03b1 : Type u} [metric_space \u03b1] [compact_space \u03b1] [Nonempty \u03b1] {\u03b2 : Type v} [metric_space \u03b2] [compact_space \u03b2] [Nonempty \u03b2] : metric.Hausdorff_dist (set.range (optimal_GH_injl \u03b1 \u03b2)) (set.range (optimal_GH_injr \u03b1 \u03b2)) = GH_dist \u03b1 \u03b2 := sorry\n\n/-- The Gromov-Hausdorff distance can also be realized by a coupling in `\u2113^\u221e(\u211d)`, by embedding\nthe optimal coupling through its Kuratowski embedding. -/\ntheorem GH_dist_eq_Hausdorff_dist (\u03b1 : Type u) [metric_space \u03b1] [compact_space \u03b1] [Nonempty \u03b1] (\u03b2 : Type v) [metric_space \u03b2] [compact_space \u03b2] [Nonempty \u03b2] : \u2203 (\u03a6 : \u03b1 \u2192 \u2113_infty_\u211d),\n  \u2203 (\u03a8 : \u03b2 \u2192 \u2113_infty_\u211d), isometry \u03a6 \u2227 isometry \u03a8 \u2227 GH_dist \u03b1 \u03b2 = metric.Hausdorff_dist (set.range \u03a6) (set.range \u03a8) := sorry\n\n-- without the next two lines, `{ exact h\u03a6.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 {\u03b1 : Type u} [metric_space \u03b1] (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 \u2192 Nat\nconstant g : Nat \u2192 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\u2081 : f (g (g (g x))) = f (g x) := by simp; /- try again with `Foo` scoped lemmas -/ open Foo in simp\n  have h\u2082 : f (g x) = x               := by simp; open Foo in simp\n  Eq.trans h\u2081 h\u2082\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 \u2227 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 : \u2115`, 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\u207b\u00b9 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\u207b\u00b9) 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 \u2260 0) : (\u2191(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 : \u211a) := 3.4`. We have\n- `gcf.int_fract_pair.stream v 0 = some \u27e83, 0.4\u27e9`, and\n- `gcf.int_fract_pair.stream v 1 = some \u27e82, 0.5\u27e9`.\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 : \u2115} [floor_ring K] {ifp_n : int_fract_pair K} :\n    int_fract_pair.stream v n = some ifp_n \u2192\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 : \u2115}\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 : \u2115}\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 : \u2115` 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    \u2203 (n : \u2115), v = convergents (generalized_continued_fraction.of v) n :=\n  exists.elim terminates\n    fun (n : \u2115) (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 : \u2115) => 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\u00e9bastien Gou\u00ebzel\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 \u2192 F`\nhas an invertible strict derivative `f'` at `a`, then it is locally invertible,\nand the inverse function has derivative `f' \u207b\u00b9`.\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 \u2243L[\ud835\udd5c] 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'\u207b\u00b9`.\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`\u211d` or `\u2102` and implemented here assuming `is_R_or_C \ud835\udd42`.\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 `\u2225f'\u207b\u00b9\u2225`;\n* by `g` we denote the auxiliary contracting map `x \u21a6 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\nvariables {E : Type*} [normed_group E] [normed_space \ud835\udd5c E]\nvariables {F : Type*} [normed_group F] [normed_space \ud835\udd5c F]\nvariables {G : Type*} [normed_group G] [normed_space \ud835\udd5c G]\nvariables {G' : Type*} [normed_group G'] [normed_space \ud835\udd5c G']\nvariables {\u03b5 : \u211d}\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 `\u2225f x - f y - f' (x - y)\u2225 \u2264 c * \u2225x - y\u2225` on an open set\n`s`, where `f' : E \u2192L[\ud835\udd5c] 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 \u2208 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 \u00d7 F \u2192 G` with estimates on `f x y\u2081 - f x y\u2082` but not on `f x\u2081 y - f x\u2082 y`.\n-/\n\n/-- We say that `f` approximates a continuous linear map `f'` on `s` with constant `c`,\nif `\u2225f x - f y - f' (x - y)\u2225 \u2264 c * \u2225x - y\u2225` whenever `x, y \u2208 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 \u2192 F) (f' : E \u2192L[\ud835\udd5c] F) (s : set E) (c : \u211d\u22650) : Prop :=\n\u2200 (x \u2208 s) (y \u2208 s), \u2225f x - f y - f' (x - y)\u2225 \u2264 c * \u2225x - y\u2225\n\nnamespace approximates_linear_on\n\nvariables [cs : complete_space E] {f : E \u2192 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 \u2192L[\ud835\udd5c] F} {s t : set E} {c c' : \u211d\u22650}\n\ntheorem mono_num (hc : c \u2264 c') (hf : approximates_linear_on f f' s c) :\n  approximates_linear_on f f' s c' :=\n\u03bb 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 \u2286 t) (hf : approximates_linear_on f f' t c) :\n  approximates_linear_on f f' s c :=\n\u03bb 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 (\u03bb x : s, f x - f' x) :=\nbegin\n  refine lipschitz_with.of_dist_le_mul (\u03bb 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 : \u211d\u22650} {f' : E \u2192L[\ud835\udd5c] 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  {\u03b5 : \u211d} {b : E} (\u03b50 : 0 \u2264 \u03b5) (h\u03b5 : closed_ball b \u03b5 \u2286 s) :\n  surj_on f (closed_ball b \u03b5) (closed_ball (f b) (((f'symm.nnnorm : \u211d)\u207b\u00b9 - c) * \u03b5)) :=\nbegin\n  assume y hy,\n  cases le_or_lt (f'symm.nnnorm : \u211d) \u207b\u00b9 c with hc hc,\n  { refine \u27e8b, by simp [\u03b50], _\u27e9,\n    have : dist y (f b) \u2264 0 :=\n      (mem_closed_ball.1 hy).trans (mul_nonpos_of_nonpos_of_nonneg (by linarith) \u03b50),\n    simp only [dist_le_zero] at this,\n    rw this },\n  have If' : (0 : \u211d) < f'symm.nnnorm,\n    by { rw [\u2190 inv_pos], exact (nnreal.coe_nonneg _).trans_lt hc },\n  have Icf' : (c : \u211d) * f'symm.nnnorm < 1, by rwa [inv_eq_one_div, lt_div_iff If'] at hc,\n  have Jf' : (f'symm.nnnorm : \u211d) \u2260 0 := ne_of_gt If',\n  have Jcf' : (1 : \u211d) - c * f'symm.nnnorm \u2260 0, by { apply ne_of_gt, linarith },\n  /- We have to show that `y` can be written as `f x` for some `x \u2208 closed_ball b \u03b5`.\n  The idea of the proof is to apply the Banach contraction principle to the map\n  `g : x \u21a6 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\u2099 = g\u207f 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 := \u03bb x, x + f'symm (y - f x) with hg,\n  set u := \u03bb (n : \u2115), g ^[n] b with hu,\n  have usucc : \u2200 n, u (n + 1) = g (u n), by simp [hu, \u2190 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 : \u2200 z, dist (g z) z \u2264 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 : \u2200 z \u2208 closed_ball b \u03b5, g z \u2208 closed_ball b \u03b5 \u2192\n    dist (f (g z)) y \u2264 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 = \u2225f (z + v) - y\u2225 : by rw [dist_eq_norm]\n    ... = \u2225f (z + v) - f  z - f' v + f' v - (y - f z)\u2225 : by { congr' 1, abel }\n    ... = \u2225f (z + v) - f z - f' ((z + v) - z)\u2225 :\n      by simp only [continuous_linear_map.nonlinear_right_inverse.right_inv,\n                    add_sub_cancel', sub_add_cancel]\n    ... \u2264 c * \u2225(z + v) - z\u2225 : hf _ (h\u03b5 hgz) _ (h\u03b5 hz)\n    ... \u2264 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 : \u2200 (n : \u2115) (w : E),\n    dist w b \u2264 f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y\n    \u2192 w \u2208 closed_ball b \u03b5,\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 : \u211d) * (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      ... \u2264 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    ... \u2264 f'symm.nnnorm * (((f'symm.nnnorm : \u211d)\u207b\u00b9 - c) * \u03b5) :\n      by { rw [mul_one],\n           exact mul_le_mul_of_nonneg_left (mem_closed_ball'.1 hy) (nnreal.coe_nonneg _) }\n    ... = \u03b5 * (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 : \u2200 (n : \u2115), dist (f (u n)) y \u2264 (c * f'symm.nnnorm)^n * dist (f b) y\n    \u2227 dist (u n) b \u2264 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 \u2264\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 \u2264 dist (g (u n)) (u n) + dist (u n) b : dist_triangle _ _ _\n      ... \u2264 f'symm.nnnorm * dist (f (u n)) y + dist (u n) b : add_le_add (A _) (le_refl _)\n      ... \u2264 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 \u27e8_, Ign\u27e9,\n    calc dist (f (g (u n))) y \u2264 c * f'symm.nnnorm * dist (f (u n)) y :\n      B _ (C n _ IH.2) (C n.succ _ Ign)\n    ... \u2264 (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\u2099` is a Cauchy sequence, therefore converging.\n  have : cauchy_seq u,\n  { have : \u2200 (n : \u2115), dist (u n) (u (n+1)) \u2264 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      ... \u2264 f'symm.nnnorm * dist (f (u n)) y : A _\n      ... \u2264 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 \u27e8x, hx\u27e9 : \u2203 x, tendsto u at_top (\ud835\udcdd x) := cauchy_seq_tendsto_of_complete this,\n  -- As all the `u\u2099` belong to the ball `closed_ball b \u03b5`, so does their limit `x`.\n  have xmem : x \u2208 closed_ball b \u03b5 :=\n    is_closed_ball.mem_of_tendsto hx (eventually_of_forall (\u03bb n, C n _ (D n).2)),\n  refine \u27e8x, xmem, _\u27e9,\n  -- It remains to check that `f x = y`. This follows from continuity of `f` on `closed_ball b \u03b5`\n  -- and from the fact that `f u\u2099` is converging to `y` by construction.\n  have hx' : tendsto u at_top (\ud835\udcdd[closed_ball b \u03b5] x),\n  { simp only [nhds_within, tendsto_inf, hx, true_and, ge_iff_le, tendsto_principal],\n    exact eventually_of_forall (\u03bb n, C n _ (D n).2) },\n  have T1 : tendsto (\u03bb n, f (u n)) at_top (\ud835\udcdd (f x)) :=\n    (hf.continuous_on.mono h\u03b5 x xmem).tendsto.comp hx',\n  have T2 : tendsto (\u03bb n, f (u n)) at_top (\ud835\udcdd y),\n  { rw tendsto_iff_dist_tendsto_zero,\n    refine squeeze_zero (\u03bb n, dist_nonneg) (\u03bb 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 \u2228 c < f'symm.nnnorm\u207b\u00b9) : 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 \u22a2,\n  intros x hx,\n  rcases hs x hx with \u27e8\u03b5, \u03b50, h\u03b5\u27e9,\n  refine \u27e8(f'symm.nnnorm\u207b\u00b9 - c) * \u03b5, mul_pos (sub_pos.2 hc) \u03b50, _\u27e9,\n  exact (hf.surj_on_closed_ball_of_nonlinear_right_inverse f'symm (le_of_lt \u03b50) h\u03b5).mono\n    h\u03b5 (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 \u2208 \ud835\udcdd x) (hc : subsingleton F \u2228 c < f'symm.nnnorm\u207b\u00b9) :\n  f '' s \u2208 \ud835\udcdd (f x) :=\nbegin\n  obtain \u27e8t, hts, ht, xt\u27e9 : \u2203 t \u2286 s, is_open t \u2227 x \u2208 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 \u2208 \ud835\udcdd x) (hc : subsingleton F \u2228 c < f'symm.nnnorm\u207b\u00b9) :\n  map f (\ud835\udcdd x) = \ud835\udcdd (f x) :=\nbegin\n  refine le_antisymm ((hf.continuous_on x (mem_of_nhds hs)).continuous_at hs) (le_map (\u03bb t ht, _)),\n  have : f '' (s \u2229 t) \u2208 \ud835\udcdd (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 \u2243L[\ud835\udd5c] F`.\n\nWe also assume that either `E = {0}`, or `c < \u2225f'\u207b\u00b9\u2225\u207b\u00b9`. We use `N` as an abbreviation for `\u2225f'\u207b\u00b9\u2225`.\n-/\n\nvariables {f' : E \u2243L[\ud835\udd5c] F} {s : set E} {c : \u211d\u22650}\n\nlocal notation `N` := nnnorm (f'.symm : F \u2192L[\ud835\udd5c] E)\n\nprotected lemma antilipschitz (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\n  antilipschitz_with (N\u207b\u00b9 - c)\u207b\u00b9 (s.restrict f) :=\nbegin\n  cases hc with hE hc,\n  { haveI : subsingleton s := \u27e8\u03bb x y, subtype.eq $ @subsingleton.elim _ hE _ _\u27e9,\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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\n  injective (s.restrict f) :=\n(hf.antilipschitz hc).injective\n\nprotected lemma inj_on (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) : 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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\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 (\u03bb 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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs : E \u2192 F) = f := rfl\n\n@[simp] lemma to_local_homeomorph_source (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (hs : is_open s) {b : E} (\u03b50 : 0 \u2264 \u03b5) (h\u03b5 : closed_ball b \u03b5 \u2286 s) :\n  closed_ball (f b) ((N\u207b\u00b9 - c) * \u03b5) \u2286 (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  \u03b50 h\u03b5).mono h\u03b5 (subset.refl _)\n\nend approximates_linear_on\n\n/-!\n### Inverse function theorem\n\nNow we prove the inverse function theorem. Let `f : E \u2192 F` be a map defined on a complete vector\nspace `E`. Assume that `f` has an invertible derivative `f' : E \u2243L[\ud835\udd5c] 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 \u2192 F} {f' : E \u2192L[\ud835\udd5c] F} {a : E}\n  (hf : has_strict_fderiv_at f f' a) {c : \u211d\u22650} (hc : subsingleton E \u2228 0 < c) :\n  \u2203 s \u2208 \ud835\udcdd a, approximates_linear_on f f' s c :=\nbegin\n  cases hc with hE hc,\n  { refine \u27e8univ, mem_nhds_sets is_open_univ trivial, \u03bb x hx y hy, _\u27e9,\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 \u27e8s, has, hs\u27e9,\n  exact \u27e8s, has, \u03bb x hx y hy, hs (mk_mem_prod hx hy)\u27e9\nend\n\nlemma map_nhds_eq_of_surj [complete_space E] [complete_space F]\n  {f : E \u2192 F} {f' : E \u2192L[\ud835\udd5c] F} {a : E}\n  (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) (h : f'.range = \u22a4) :\n  map f (\ud835\udcdd a) = \ud835\udcdd (f a) :=\nbegin\n  let f'symm := f'.nonlinear_right_inverse_of_surjective h,\n  set c : \u211d\u22650 := f'symm.nnnorm\u207b\u00b9 / 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 \u27e8s, s_nhds, hs\u27e9 : \u2203 s \u2208 \ud835\udcdd 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 \u2192 F} {f' : E \u2243L[\ud835\udd5c] F} {a : E}\n\nlemma approximates_deriv_on_open_nhds (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) :\n  \u2203 (s : set E) (hs : a \u2208 s \u2227 is_open s),\n    approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s ((nnnorm (f'.symm : F \u2192L[\ud835\udd5c] E))\u207b\u00b9 / 2) :=\nbegin\n  refine ((nhds_basis_opens a).exists_iff _).1 _,\n  exact (\u03bb s t, approximates_linear_on.mono_set),\n  exact (hf.approximates_deriv_on_nhds $ f'.subsingleton_or_nnnorm_symm_pos.imp id $\n    \u03bb 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 \u2208 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 \u2192L[\ud835\udd5c] 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 $ \u03bb 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 \u2192L[\ud835\udd5c] F) a) :\n  (hf.to_local_homeomorph f : E \u2192 F) = f := rfl\n\nlemma mem_to_local_homeomorph_source (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) :\n  a \u2208 (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 \u2192L[\ud835\udd5c] F) a) :\n  f a \u2208 (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 \u2192L[\ud835\udd5c] F) a) :\n  map f (\ud835\udcdd a) = \ud835\udcdd (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 \u2192L[\ud835\udd5c] F) a) : F \u2192 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 \u2192L[\ud835\udd5c] 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 \u2192L[\ud835\udd5c] F) a) :\n  \u2200\u1da0 x in \ud835\udcdd 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 \u2192L[\ud835\udd5c] F) a) :\n  \u2200\u1da0 y in \ud835\udcdd (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 \u2192L[\ud835\udd5c] 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 \u2192L[\ud835\udd5c] F) a) :\n  tendsto (hf.local_inverse f f' a) (\ud835\udcdd $ f a) (\ud835\udcdd 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 \u2192L[\ud835\udd5c] F) a) {g : F \u2192 E}\n  (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  \u2200\u1da0 y in \ud835\udcdd (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 \u2192L[\ud835\udd5c] F) a) :\n  has_strict_fderiv_at (hf.local_inverse f f' a) (f'.symm : F \u2192L[\ud835\udd5c] E) (f a) :=\n(hf.to_local_homeomorph f).has_strict_fderiv_at_symm hf.image_mem_to_local_homeomorph_target $\n  by simpa [\u2190 local_inverse_def] using hf\n\n/-- If `f : E \u2192 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 \u2192L[\ud835\udd5c] F) a) {g : F \u2192 E}\n  (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  has_strict_fderiv_at g (f'.symm : F \u2192L[\ud835\udd5c] E) (f a) :=\nhf.to_local_inverse.congr_of_eventually_eq $ (hf.local_inverse_unique hg).mono $ \u03bb _, 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 \u2192 F} {f' : E \u2192 E \u2243L[\ud835\udd5c] F}\n  (hf : \u2200 x, has_strict_fderiv_at f (f' x : E \u2192L[\ud835\udd5c] F) x) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ \u03bb 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 : \ud835\udd5c \u2192 \ud835\udd5c`.\nWe use `continuous_linear_equiv.units_equiv_aut` to translate `has_strict_deriv_at f f' a` and\n`f' \u2260 0` into `has_strict_fderiv_at f (_ : \ud835\udd5c \u2243L[\ud835\udd5c] \ud835\udd5c) a`.\n-/\n\nnamespace has_strict_deriv_at\n\nvariables [cs : complete_space \ud835\udd5c] {f : \ud835\udd5c \u2192 \ud835\udd5c} {f' a : \ud835\udd5c} (hf : has_strict_deriv_at f f' a)\n  (hf' : f' \u2260 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 : \ud835\udd5c \u2192 \ud835\udd5c :=\n(hf.has_strict_fderiv_at_equiv hf').local_inverse _ _ _\n\nvariables {f f' a}\n\nlemma map_nhds_eq : map f (\ud835\udcdd a) = \ud835\udcdd (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'\u207b\u00b9 (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_inverse\n\ntheorem to_local_left_inverse {g : \ud835\udd5c \u2192 \ud835\udd5c} (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  has_strict_deriv_at g f'\u207b\u00b9 (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 \ud835\udd5c] {f f' : \ud835\udd5c \u2192 \ud835\udd5c}\n  (hf : \u2200 x, has_strict_deriv_at f (f' x) x) (h0 : \u2200 x, f' x \u2260 0) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ \u03bb 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 {\ud835\udd42 : Type*} [is_R_or_C \ud835\udd42]\nvariables {E' : Type*} [normed_group E'] [normed_space \ud835\udd42 E']\nvariables {F' : Type*} [normed_group F'] [normed_space \ud835\udd42 F']\nvariables [complete_space E'] (f : E' \u2192 F') {f' : E' \u2243L[\ud835\udd42] F'} {a : E'}\n\n/-- Given a `times_cont_diff` function over `\ud835\udd42` (which is `\u211d` or `\u2102`) with an invertible\nderivative at `a`, returns a `local_homeomorph` with `to_fun = f` and `a \u2208 source`. -/\ndef to_local_homeomorph\n  {n : with_top \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 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 \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  (hf.to_local_homeomorph f hf' hn : E' \u2192 F') = f := rfl\n\nlemma mem_to_local_homeomorph_source\n  {n : with_top \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  a \u2208 (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 \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  f a \u2208 (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 `\ud835\udd42` (which is `\u211d` or `\u2102`) with an invertible derivative\nat `a`, returns a function that is locally inverse to `f`. -/\ndef local_inverse\n  {n : with_top \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  F' \u2192 E' :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse f f' a\n\nlemma local_inverse_apply_image\n  {n : with_top \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 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 `\ud835\udd42` (which is `\u211d` or `\u2102`) 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 \u2115} (hf : times_cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  times_cont_diff_at \ud835\udd42 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\u2081_ka {a b c d e : Prop} (h\u2081 : ka d e (ka a b bot)) : ka d e (ka a b c) :=\n                    have h\u2082 : ka d e (ka d b bot), from ka.ka\u2087 h\u2081,\n                    have h\u2083 : ka d (ka d e b) bot, from ka.ka\u2084 h\u2082,\n                    have h\u2084 : ka d (ka d e b) c, from kab\u2081 h\u2083,\n                    have h\u2085 : ka d e a, from ka.ka\u2086 h\u2081,\n                    have h\u2086 : ka d e (ka d b c), from ka.ka\u2084' h\u2084,\n                    show ka d e (ka a b c), from ka.ka\u2085 h\u2085 h\u2086\n\n                theorem  b\u2081 {a : Prop} (h\u2081 : bot) : a :=\n                    have h\u2082 : ka bot bot bot, from ka.ka\u2081 h\u2081 h\u2081,\n                    have h\u2083 : ka bot bot a, from kab\u2081 h\u2082,\n                    have h\u2084 : ka bot a bot, from ka.ka\u2083 h\u2083,\n                    have h\u2085 : ka bot a a, from kab\u2081 h\u2084,\n                    show a, from ka.ka\u2082 h\u2085\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 : \u03b1 \u2192 \u03b2` semiconjugates `ga : \u03b1 \u2192 \u03b1` to `gb : \u03b2 \u2192 \u03b2` if `f \u2218 ga = gb \u2218 f`;\n* `function.semiconj\u2082: `f : \u03b1 \u2192 \u03b2` semiconjugates a binary operation `ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1`\n  to `gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2` if `f (ga x y) = gb (f x) (f y)`;\n* `f : \u03b1 \u2192 \u03b1` commutes with `g : \u03b1 \u2192 \u03b1` if `f \u2218 g = g \u2218 f`, or equivalently `semiconj f g g`.\n\n-/\n\nnamespace function\n\n\n/-- We say that `f : \u03b1 \u2192 \u03b2` semiconjugates `ga : \u03b1 \u2192 \u03b1` to `gb : \u03b2 \u2192 \u03b2` if `f \u2218 ga = gb \u2218 f`. -/\ndef semiconj {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (ga : \u03b1 \u2192 \u03b1) (gb : \u03b2 \u2192 \u03b2) :=\n  \u2200 (x : \u03b1), f (ga x) = gb (f x)\n\nnamespace semiconj\n\n\nprotected theorem comp_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1} {gb : \u03b2 \u2192 \u03b2}\n    (h : semiconj f ga gb) : f \u2218 ga = gb \u2218 f :=\n  funext h\n\nprotected theorem eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1} {gb : \u03b2 \u2192 \u03b2}\n    (h : semiconj f ga gb) (x : \u03b1) : f (ga x) = gb (f x) :=\n  h x\n\ntheorem comp_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1} {ga' : \u03b1 \u2192 \u03b1} {gb : \u03b2 \u2192 \u03b2}\n    {gb' : \u03b2 \u2192 \u03b2} (h : semiconj f ga gb) (h' : semiconj f ga' gb') :\n    semiconj f (ga \u2218 ga') (gb \u2218 gb') :=\n  sorry\n\ntheorem comp_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {fab : \u03b1 \u2192 \u03b2} {fbc : \u03b2 \u2192 \u03b3}\n    {ga : \u03b1 \u2192 \u03b1} {gb : \u03b2 \u2192 \u03b2} {gc : \u03b3 \u2192 \u03b3} (hab : semiconj fab ga gb) (hbc : semiconj fbc gb gc) :\n    semiconj (fbc \u2218 fab) ga gc :=\n  sorry\n\ntheorem id_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} : semiconj f id id := fun (_x : \u03b1) => rfl\n\ntheorem id_left {\u03b1 : Type u_1} {ga : \u03b1 \u2192 \u03b1} : semiconj id ga ga := fun (_x : \u03b1) => rfl\n\ntheorem inverses_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1} {ga' : \u03b1 \u2192 \u03b1}\n    {gb : \u03b2 \u2192 \u03b2} {gb' : \u03b2 \u2192 \u03b2} (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 : \u03b1 \u2192 \u03b1` commute if `f \u2218 g = g \u2218 f`. -/\ndef commute {\u03b1 : Type u_1} (f : \u03b1 \u2192 \u03b1) (g : \u03b1 \u2192 \u03b1) := semiconj f g g\n\ntheorem semiconj.commute {\u03b1 : Type u_1} {f : \u03b1 \u2192 \u03b1} {g : \u03b1 \u2192 \u03b1} (h : semiconj f g g) :\n    commute f g :=\n  h\n\nnamespace commute\n\n\ntheorem refl {\u03b1 : Type u_1} (f : \u03b1 \u2192 \u03b1) : commute f f := fun (_x : \u03b1) => Eq.refl (f (f _x))\n\ntheorem symm {\u03b1 : Type u_1} {f : \u03b1 \u2192 \u03b1} {g : \u03b1 \u2192 \u03b1} (h : commute f g) : commute g f :=\n  fun (x : \u03b1) => Eq.symm (h x)\n\ntheorem comp_right {\u03b1 : Type u_1} {f : \u03b1 \u2192 \u03b1} {g : \u03b1 \u2192 \u03b1} {g' : \u03b1 \u2192 \u03b1} (h : commute f g)\n    (h' : commute f g') : commute f (g \u2218 g') :=\n  semiconj.comp_right h h'\n\ntheorem comp_left {\u03b1 : Type u_1} {f : \u03b1 \u2192 \u03b1} {f' : \u03b1 \u2192 \u03b1} {g : \u03b1 \u2192 \u03b1} (h : commute f g)\n    (h' : commute f' g) : commute (f \u2218 f') g :=\n  symm (comp_right (symm h) (symm h'))\n\ntheorem id_right {\u03b1 : Type u_1} {f : \u03b1 \u2192 \u03b1} : commute f id := semiconj.id_right\n\ntheorem id_left {\u03b1 : Type u_1} {f : \u03b1 \u2192 \u03b1} : 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\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2) :=\n  \u2200 (x y : \u03b1), f (ga x y) = gb (f x) (f y)\n\nnamespace semiconj\u2082\n\n\nprotected theorem eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1} {gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2}\n    (h : semiconj\u2082 f ga gb) (x : \u03b1) (y : \u03b1) : f (ga x y) = gb (f x) (f y) :=\n  h x y\n\nprotected theorem comp_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1}\n    {gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2} (h : semiconj\u2082 f ga gb) : bicompr f ga = bicompl gb f f :=\n  funext fun (x : \u03b1) => funext (h x)\n\ntheorem id_left {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) : semiconj\u2082 id op op := fun (_x _x_1 : \u03b1) => rfl\n\ntheorem comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1}\n    {gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2} {f' : \u03b2 \u2192 \u03b3} {gc : \u03b3 \u2192 \u03b3 \u2192 \u03b3} (hf' : semiconj\u2082 f' gb gc)\n    (hf : semiconj\u2082 f ga gb) : semiconj\u2082 (f' \u2218 f) ga gc :=\n  sorry\n\ntheorem is_associative_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1}\n    {gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [is_associative \u03b1 ga] (h : semiconj\u2082 f ga gb) (h_surj : surjective f) :\n    is_associative \u03b2 gb :=\n  sorry\n\ntheorem is_associative_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1}\n    {gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [is_associative \u03b2 gb] (h : semiconj\u2082 f ga gb) (h_inj : injective f) :\n    is_associative \u03b1 ga :=\n  sorry\n\ntheorem is_idempotent_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1}\n    {gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [is_idempotent \u03b1 ga] (h : semiconj\u2082 f ga gb) (h_surj : surjective f) :\n    is_idempotent \u03b2 gb :=\n  sorry\n\ntheorem is_idempotent_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {ga : \u03b1 \u2192 \u03b1 \u2192 \u03b1}\n    {gb : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [is_idempotent \u03b2 gb] (h : semiconj\u2082 f ga gb) (h_inj : injective f) :\n    is_idempotent \u03b1 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 \u2192 nat\n| pred : nat \u2192 nat\n\nnotation 0 := nat.zero\nnotation `S` := nat.succ\nnotation `P` := nat.pred\nnotation 1 := S 0\naxiom succ_pred : \u2200 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 := \u03bb(n m : nat)(f : nat \u2192 nat), n = m \u2192 f n = f m,\n  type_check (h 0 0 (\u03bb n, S n)), -- Prop\n  have h2 : \u2200 (n m : nat)(f : nat \u2192 nat), n = m \u2192 f n = f m := sorry,\n  type_check h2 0 1 (\u03bb n, n),\n\n  have h3 := h2 0 0 (\u03bb 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 \u2227 2 = 2 :=\nbegin\n  -- apply and.intro,\n  -- exact eq.refl 1,\n  -- exact eq.refl 2,\n\n  -- apply \u27e8eq.refl _, _\u27e9, -- invalid constructor \u27e8...\u27e9\n  refine \u27e8eq.refl _, _\u27e9, -- 1 goal \u22a2 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 (\u03b1 : Type) extends myfield \u03b1, has_le \u03b1:=\n-- NOTE: Theses are the ordered_myring axioms\n(f_decidable_le: \u2200 a b: \u03b1, decidable (a \u2264 b))\n(f_le_add_right (a b c : \u03b1) : a \u2264 b \u2192 a + c \u2264 b + c)\n(f_zero_le_mul (a b : \u03b1) : 0 \u2264 a \u2192 0 \u2264 b \u2192 0 \u2264 a * b)\n(f_le_trans (a b c: \u03b1): a \u2264 b \u2192 b \u2264 c \u2192 a \u2264 c)\n(f_le_total_order (a b: \u03b1): a \u2264 b \u2228 b \u2264 a)\n(f_le_antisymm (a b: \u03b1): a \u2264 b \u2192 b \u2264 a \u2192 a = b)\n\nnamespace ordered_myfield\n\nopen myfield\nopen myring\nopen ordered_myring\n\nvariables {\u03b1 : Type} [ordered_myfield \u03b1] (x y z : \u03b1)\n\n-- This is peak L\u2203\u2200N\ninstance : ordered_integral_domain \u03b1 := {\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 {\u03b5 : \u03b1} : 0 < \u03b5 \u2192 0 < \u03b5 / 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 : \u03b1} : 0 < x \u2192 0 < x\u207b\u00b9 := sorry\n\ntheorem exists_between (a c : \u03b1) :\na < c \u2192 \u2203 b : \u03b1, a < b \u2227 b < c :=\nbegin\n  assume hac,\n  existsi (a + c) * (2 : \u03b1)\u207b\u00b9,\n  split; rw add_mul, {\n    conv {\n      to_lhs,\n      rw \u2190mul_one a,\n    },\n    rw lt_add_cancel_left _ _ (a * -2\u207b\u00b9),\n    -- WTF is going on here?\n    sorry,\n    -- rw [lt_add_left (-(a/2)), \u2190add_assoc, add_comm _ a, neg_self_add],\n    -- conv {\n    --   to_lhs,\n    --   congr,\n    --     rw \u2190@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 \u2190@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 : \u03b1): 0 \u2264 a \u2192 0 \u2264 x \u2192 a < b \u2192 x < y \u2192 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 \u2264 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 \u2192 0 < a\u207b\u00b9 :=\n-- begin\n--   assume h0x,\n--   assume hxi0,\n--   by_cases h: 0 \u2264 a\u207b\u00b9, {\n--     have := le_antisymm hxi0 h,\n--     have hx0: a = 0, {\n--       rw \u2190@inv_inv a,\n--       rw this,\n--       refl,\n--     },\n--     subst hx0,\n--     from lt_nrefl _ h0x,\n--   }, {\n--     rw \u2190lt_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 \u2194 0 < a\u207b\u00b9 :=\n-- begin\n--   split, {\n--     from inv_pos a,\n--   }, {\n--     have := inv_pos a\u207b\u00b9,\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 {\u03b1 : Type*} {\u03b2 : Type*}\nvariables [decidable_eq \u03b1] [add_comm_group \u03b1] [vector_space \u211d \u03b1] [\u211d_inner_product_space \u03b1]\nvariables [decidable_eq \u03b2] [add_comm_group \u03b2] [vector_space \u211d \u03b2] [\u211d_inner_product_space \u03b2]\n\n@[reducible] def prod_inner_product (x y : \u03b1\u00d7\u03b2) : \u211d := \u27eax.1 \u2225 y.1\u27eb + \u27eax.2 \u2225 y.2\u27eb\n\n@[reducible] instance prod_has_inner_product : has_\u211d_inner_product (\u03b1\u00d7\u03b2) := \u27e8prod_inner_product\u27e9\n\nlemma prod_conj_symm (x y : \u03b1 \u00d7 \u03b2) : \u27eax \u2225 y\u27eb = \u27eay \u2225 x\u27eb :=\nby {dsimp [inner_product, prod_inner_product],\n    rw [conj_symm x.fst, conj_symm x.snd]}\n\nlemma prod_linearity (x y z : \u03b1 \u00d7 \u03b2) (a : \u211d) : \u27eaa \u2022 x + y \u2225 z\u27eb = a * \u27eax \u2225 z\u27eb + \u27eay \u2225 z\u27eb :=\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 : \u03b1 \u00d7 \u03b2) : x \u2260 0 \u2192 x.1 \u2260 0 \u2228 x.2 \u2260 0 :=\nbegin\n    rw [awesome_mt], \n    simp [not_or_distrib],\n    intros a b,\n    rw [\u2190@prod.mk.eta _ _ x, a, b],\n    refl,\nend\n\nlemma prod_pos_def (x : \u03b1 \u00d7 \u03b2) (h : x \u2260 0) : \u27eax \u2225 x\u27eb > 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 : \u211d_inner_product_space (\u03b1\u00d7\u03b2) :=\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 \u211d_has_\u211d_inner_product : has_\u211d_inner_product \u211d := \u27e8\u03bb a b, a*b\u27e9\n\nlemma \u211d_conj_symm (x y : \u211d) : \u27eax \u2225 y\u27eb = \u27eay \u2225 x\u27eb := mul_comm x y\n\nlemma \u211d_linearity (x y z : \u211d) (a : \u211d) : \u27eaa\u2022x+y \u2225 z\u27eb = a*\u27eax \u2225 z\u27eb + \u27eay \u2225 z\u27eb :=\nby {dsimp [inner_product], rw [right_distrib, mul_assoc]}\n\nlemma \u211d_pos_def (x : \u211d) : x \u2260 0 \u2192 \u27eax \u2225 x\u27eb > 0 := mul_self_pos\n\ninstance \u211d_is_\u211d_inner_product_space : \u211d_inner_product_space \u211d :=\n{conj_symm := \u211d_conj_symm, linearity := \u211d_linearity, pos_def := \u211d_pos_def}\n\nend real_ip\n\nopen function\n\nsection inj_linear_map\n\nvariables {\u03b3 : Type*} [decidable_eq \u03b3] [add_comm_group \u03b3] [vector_space \u211d \u03b3] [\u211d_inner_product_space \u03b3]\nvariables {\u03b7 : Type*} [decidable_eq \u03b7] [add_comm_group \u03b7] [vector_space \u211d \u03b7]\nvariables (f : linear_map \u211d \u03b7 \u03b3) (h : injective f.to_fun)\n\nlemma fun_coe (f : linear_map \u211d \u03b7 \u03b3) : \u21d1f = f.to_fun := rfl\n\ninclude f h\n\n@[reducible] instance inj_has_inner_product : has_\u211d_inner_product \u03b7 := \u27e8\u03bb x y, \u27eaf.to_fun x \u2225 f.to_fun y\u27eb\u27e9\n\nlemma inj_conj_symm (x y : \u03b7) : \u27eaf.to_fun x \u2225 f.to_fun y\u27eb = \u27eaf.to_fun y \u2225 f.to_fun x\u27eb := conj_symm (f.to_fun x) (f.to_fun y)\n\nlemma inj_linearity (x y z : \u03b7) (a : \u211d) : \u27eaf.to_fun (a \u2022 x + y) \u2225 f.to_fun z\u27eb = a * \u27eaf.to_fun x \u2225 f.to_fun z\u27eb + \u27eaf.to_fun y \u2225 f.to_fun z\u27eb :=\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 : \u03b7) (k : f.to_fun x = 0) : x = 0 :=\nbegin\n    have w := map_zero f,\n    dsimp [injective] at h,\n    rw [\u2190w, fun_coe f] at k,\n    exact (h k),\nend\n\nlemma inj_pos_def (x : \u03b7) : x \u2260 0 \u2192 \u27eaf.to_fun x \u2225 f.to_fun x\u27eb > 0 :=\nbegin\n    rw [awesome_mt],\n    simp,\n    have w := norm_sq_nonneg (f.to_fun x),\n    have k\u2081 := zero_iff_norm_sq_zero (f.to_fun x),\n    dsimp [norm_sq] at *,\n    intros k,\n    have w\u2081 := antisymm w k,\n    have w\u2082 := k\u2081.1 w\u2081,\n    exact (trivial_ker_of_injective f h x w\u2082),\nend\n\ninstance inj_inner_product_space (f : linear_map \u211d \u03b7 \u03b3) (h : injective f.to_fun) : \u211d_inner_product_space \u03b7 :=\nbegin\n    refine_struct {..},\n\n    use \u03bb x y, \u27eaf.to_fun x \u2225 f.to_fun y\u27eb,\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 {\u03b3 : Type*} [decidable_eq \u03b3] [add_comm_group \u03b3] [vector_space \u211d \u03b3] [\u211d_inner_product_space \u03b3]\nvariables {\u03b7 : subspace \u211d \u03b3}\n\ndef realise : linear_map \u211d \u03b7 \u03b3 :=\nbegin\n    refine_struct {..},\n    use \u03bb x, x,\n    repeat {simp},\nend\n\nlemma realise_injective : @injective \u21a5\u03b7 \u03b3 (realise.to_fun) :=\nbegin\n    dsimp [injective, realise],\n    intros x\u2081 x\u2082 k,\n    exact set_coe.ext k,\nend\n\ninstance sub_inner_product_space : \u211d_inner_product_space \u03b7 :=\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 \u27f6 n` are functorial maps `\u03c6_A : \u2124[A^m] \u2192 \u2124[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 := \u2115\n\nnamespace Mat\n\ninstance : small_category Mat :=\n{ hom := \u03bb m n, basic_universal_map m n,\n  id := basic_universal_map.id,\n  comp := \u03bb l m n f g, basic_universal_map.comp g f,\n  id_comp' := \u03bb n f, basic_universal_map.comp_id,\n  comp_id' := \u03bb n f, basic_universal_map.id_comp,\n  assoc' := \u03bb 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 := \u2115\n\nnamespace FreeMat\n\ninstance : small_category FreeMat :=\n{ hom := \u03bb m n, universal_map m n,\n  id := universal_map.id,\n  comp := \u03bb l m n f g, universal_map.comp g f,\n  id_comp' := \u03bb n f, universal_map.comp_id,\n  comp_id' := \u03bb n f, universal_map.id_comp,\n  assoc' := \u03bb k l m n f g h, (universal_map.comp_assoc h g f).symm }\n\ninstance : preadditive FreeMat :=\n{ hom_group := \u03bb m n, infer_instance,\n  add_comp' := \u03bb l m n f g h, add_monoid_hom.map_add _ _ _,\n  comp_add' := \u03bb 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 \u2964 FreeAb Mat :=\n{ obj := \u03bb n, FreeAb.of n,\n  map := \u03bb m n f, f,\n  map_id' := \u03bb m, rfl,\n  map_comp' := \u03bb 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 : \u2115) : FreeMat \u2964 FreeMat :=\n{ obj := \u03bb n, N * n,\n  map := \u03bb m n f, mul N f,\n  map_id' := \u03bb 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' := \u03bb l m n f g, mul_comp _ _ _ }\n.\ninstance mul_functor.additive (N : \u2115) : (mul_functor N).additive :=\n{ map_add' := \u03bb 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 \u2245 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 \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb 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 [\u2190 add_monoid_hom.comp_apply, \u2190 add_monoid_hom.comp_hom_apply_apply,\n    \u2190 add_monoid_hom.flip_apply _ f],\n  congr' 1, clear f, ext1 f,\n  have : f = matrix.reindex_linear_equiv \u2115 _\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 \u2297\u2096 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 {\u03b1 \u03b2 \u03b3 : Type*}\nvariables {l\u2081 m\u2081 n\u2081 l\u2082 m\u2082 n\u2082 : Type*}\nvariables [fintype l\u2081] [fintype m\u2081] [fintype n\u2081]\nvariables [fintype l\u2082] [fintype m\u2082] [fintype n\u2082]\n\nlemma kronecker_map_reindex_left (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (el : l\u2081 \u2243 l\u2082) (em : m\u2081 \u2243 m\u2082) (M : matrix l\u2081 m\u2081 \u03b1)\n  (N : matrix n\u2081 n\u2082 \u03b2) : 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 \u27e8i, i'\u27e9 \u27e8j, j'\u27e9, refl }\n\nlemma kronecker_map_reindex_right (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (em : m\u2081 \u2243 m\u2082) (en : n\u2081 \u2243 n\u2082)\n  (M : matrix l\u2081 l\u2082 \u03b1) (N : matrix m\u2081 n\u2081 \u03b2) :\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 \u27e8i, i'\u27e9 \u27e8j, j'\u27e9, refl }\n\n\nlemma mul_mul_iso_aux (m n i j : \u2115) (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    \u2190 matrix.reindex_linear_equiv_one \u2115 _ (@fin_prod_fin_equiv m n)],\n  simp only [matrix.reindex_linear_equiv_apply],\n  rw [kronecker_map_reindex_left, kronecker_map_reindex_right, \u2190 matrix.kronecker_assoc],\n  simp only [\u2190 equiv.trans_apply, matrix.reindex_trans, matrix.one_kronecker_one,\n    equiv.trans_refl],\n  congr' 3, swap 3, { apply_instance },\n  { ext \u27e8\u27e8a, b\u27e9, c\u27e9,\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 \u27e8\u27e8a, b\u27e9, c\u27e9,\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 : \u2115) : mul_functor n \u22d9 mul_functor m \u2245 mul_functor (m * n) :=\nnat_iso.of_components (\u03bb 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 [\u2190 add_monoid_hom.comp_apply, \u2190 add_monoid_hom.comp_apply,\n    \u2190 add_monoid_hom.flip_apply _ (mul (m * n) f),\n    \u2190 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 \u2115\n\nnamespace data\n\nvariable (BD : data)\n\nsection mul\n\nopen universal_map\n\n@[simps]\ndef mul (N : \u2115) : data \u2964 data :=\n(FreeMat.mul_functor N).map_homological_complex _\n\ndef mul_one_iso : (mul 1).obj BD \u2245 BD :=\nhomological_complex.hom.iso_of_components (\u03bb i, FreeMat.one_mul_iso.app _) $\n\u03bb i j _, (FreeMat.one_mul_iso.hom.naturality (BD.d i j)).symm\n\ndef mul_mul_iso (m n : \u2115) : (mul m).obj ((mul n).obj BD) \u2245 (mul (m * n)).obj BD :=\nhomological_complex.hom.iso_of_components (\u03bb i, (FreeMat.mul_mul_iso _ _).app _) $\n\u03bb 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' : \u2115 \u2192 data\n| 0     := BD\n| (n+1) := (mul 2).obj (pow' n)\n\n@[simps] def sum (BD : data) (N : \u2115) : (mul N).obj BD \u27f6 BD :=\n{ f := \u03bb n, universal_map.sum _ _,\n  comm' := \u03bb m n _, (universal_map.sum_comp_mul _ _).symm }\n\n@[simps] def proj (BD : data) (N : \u2115) : (mul N).obj BD \u27f6 BD :=\n{ f := \u03bb n, universal_map.proj _ _,\n  comm' := \u03bb 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 \u27f6 BD) : \u03a0 N, BD.pow' N \u27f6 BD\n| 0     := \ud835\udfd9 _\n| (n+1) := (mul 2).map (hom_pow' n) \u226b f\n\nopen_locale zero_object\n\ndef pow'_iso_mul : \u03a0 N, BD.pow' N \u2245 (mul (2^N)).obj BD\n| 0     := BD.mul_one_iso.symm\n| (N+1) := show (mul 2).obj (BD.pow' N) \u2245 (mul (2 * 2 ^ N)).obj BD, from\n   (mul 2).map_iso (pow'_iso_mul N) \u226a\u226b mul_mul_iso _ _ _\n\nlemma hom_pow'_sum : \u2200 N, (BD.pow'_iso_mul N).inv \u226b 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 [\u2190 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 [\u2190 finset.sum_product', finset.univ_product_univ, \u2190 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 : \u2115) : hom_pow' (BD.sum 2) N = (BD.pow'_iso_mul N).hom \u226b BD.sum (2^N) :=\nby { rw \u2190 iso.inv_comp_eq, apply hom_pow'_sum }\n\nlemma hom_pow'_proj : \u2200 N, (BD.pow'_iso_mul N).inv \u226b 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 [\u2190 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 [\u2190 finset.sum_comm, \u2190 finset.sum_product', finset.univ_product_univ,\n      \u2190 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 : \u2115) : hom_pow' (BD.proj 2) N = (BD.pow'_iso_mul N).hom \u226b BD.proj (2^N) :=\nby { rw \u2190 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 {\u03b1 : Type*}\n\nopen real set module submodule linear_map set\n\nvariables [decidable_eq \u03b1] [add_comm_group \u03b1] [vector_space \u211d \u03b1] [\u211d_inner_product_space \u03b1]\n\nsection norm_known\n\ndef \u03b1_normed_space : normed_space \u211d \u03b1 := ip_space_is_normed_space\n\nlocal attribute [instance] \u03b1_normed_space\nlocal attribute [instance] classical.prop_decidable\n\ndef orthog_set (L : set \u03b1) : Prop :=\n\u2200 (a b \u2208 L), a \u2260 b \u2192 a \u22a5 b\n\nlemma emptyset_orthog : orthog_set (\u2205 : set \u03b1) :=\nby {dsimp [orthog_set], simp}\n\nlemma add_elt_to_orthog (L : set \u03b1) (x : \u03b1) (h : orthog_set L) (w : \u2200 (y \u2208 L), x \u22a5 y) : orthog_set (L \u222a {x}) :=\nbegin\n    dsimp [orthog_set] at *,\n    intros a b k\u2081 k\u2082 k\u2083,\n    cases k\u2081,\n    cases k\u2082,\n\n    exact h a b k\u2081 k\u2082 k\u2083,\n\n    apply orthog_symm,\n    rw [eq_of_mem_singleton k\u2082],\n    exact w a k\u2081,\n\n    cases k\u2082,\n\n    rw [eq_of_mem_singleton k\u2081],\n    exact w b k\u2082,\n\n    have k\u2083 := (eq_of_mem_singleton k\u2082).symm,\n    rw [\u2190eq_of_mem_singleton k\u2081] at k\u2083,\n    contradiction,\nend\n\nlemma orthog_subset (L S : set \u03b1) (h : orthog_set L) (w : S \u2286 L) : orthog_set S :=\nby {dsimp [orthog_set] at *,\n    dsimp [(\u2286), set.subset] at w,\n    intros a b k\u2081 k\u2082 k\u2083,\n    exact (h a b (w k\u2081) (w k\u2082) k\u2083)}\n\ndef orthonormal (L : set \u03b1) : Prop :=\northog_set L \u2227 \u2200 (a \u2208 L), \u2225a\u2225=1\n\ndef normalise (L : set \u03b1) := image (\u03bb (a : \u03b1), (1/\u2225a\u2225 : \u211d) \u2022 a) L\n\nlemma elem_of_normalised (L : set \u03b1) (x : \u03b1) (h : x \u2208 normalise L) : \u2203 (y \u2208 L) (a : \u211d), a \u2022 y = x :=\nby {dsimp [normalise, image] at h, rcases h with \u27e8y, hl, hr\u27e9,\n    use y, use hl, use (1 / \u2225y\u2225), exact hr}\n\nlemma elem_of_normalised' (L : set \u03b1) (x : \u03b1) (h : x \u2208 L) : ((1 / \u2225x\u2225 : \u211d) \u2022 x) \u2208 normalise L :=\nby {dsimp [normalise, image], use x, exact \u27e8h, rfl\u27e9}\n\nlemma norm_one_of_norm_inv (x : \u03b1) (h : x \u2260 0) : \u2225(1/\u2225x\u2225)\u2022x\u2225 = 1 :=\nby {rw [one_div_eq_inv, @norm_smul \u211d \u03b1 _ ip_space_is_normed_space _ x, norm_inv,\n    @norm_norm \u03b1 ip_space_is_normed_group, inv_mul_cancel],\n    exact (@norm_neq_zero_iff_neq_zero \u03b1 ip_space_is_normed_space x).2 h}\n\nlemma norm_one_of_normalised (L : set \u03b1) (h : (0 : \u03b1) \u2209 L) (a : \u03b1) (w : a \u2208 normalise L) : \u2225a\u2225=1 :=\nbegin\n    dsimp [normalise] at w,\n    simp at w,\n    rcases w with \u27e8b, k\u2081, k\u2082\u27e9,\n    have k\u2083 : b \u2260 0, begin\n        by_contradiction,\n        simp only [not_not] at a_1,\n        rw [a_1] at k\u2081,\n        contradiction,\n    end,\n    rw [\u2190k\u2082, \u2190one_div_eq_inv],\n    exact norm_one_of_norm_inv b k\u2083,\nend\n\nlemma zero_not_elem_of_normalised (L : set \u03b1) (h : (0 : \u03b1) \u2209 L) : (0 : \u03b1) \u2209 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 \u03b1) (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\u2081 k\u2082 y k\u2083 k\u2084 k\u2085,\n    have k\u2086 : x \u2260 y, begin\n        by_contradiction,\n        simp only [not_not] at a_1,\n        rw [a_1] at k\u2082,\n        rw [k\u2082] at k\u2084,\n        contradiction,\n    end,\n    rw [\u2190k\u2084, \u2190k\u2082],\n    exact mul_orthog x y (\u2225x\u2225)\u207b\u00b9 (\u2225y\u2225)\u207b\u00b9 (h x y k\u2081 k\u2083 k\u2086),\nend\n\nlemma orthonormal_normalised_of_orthog_set (L : set \u03b1) (h : orthog_set L) (w : (0 : \u03b1) \u2209 L) : orthonormal (normalise L) :=\nby {dsimp [orthonormal], exact \u27e8orthog_normalised_of_orthog L h, norm_one_of_normalised L w\u27e9}\n\nlemma orthog_set_is_lin_indep (L : set \u03b1) (h : orthog_set L) (w : (0 : \u03b1) \u2209 L) : linear_independent \u211d L :=\nbegin\n    rw [linear_independent_iff],\n    intros l k\u2081 k\u2082,\n    -- rw [linear_combination.mem_supported] at k\u2081,\n    sorry,\nend\n\nlemma scale_elem_in_span (L : set \u03b1) (x : \u03b1) (a : \u211d) (h : x \u2208 span \u211d L) : (a \u2022 x) \u2208 span \u211d 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 \u03b1) (x : \u03b1) (a : x \u2208 normalise L) : x \u2208 span \u211d L :=\nbegin\n    have w\u2081 := elem_of_normalised L x a,\n    rcases w\u2081 with \u27e8y, w\u2081, a, w\u2082\u27e9,\n    have w\u2083 := @subset_span \u211d _ _ _ _ _,\n    rw [\u2190w\u2082],\n    exact scale_elem_in_span L y a (w\u2083 w\u2081),\nend\n\nlemma normalised_subset_span (L : set \u03b1) : normalise L \u2286 \u2191(span \u211d L) := elem_span_of_elem_normalised L\n\nlemma in_submodule_of_normalised_in_submodule (L : set \u03b1) (p : submodule \u211d \u03b1) (k : normalise L \u2286 \u2191p) : L \u2286 \u2191p :=\nbegin\n    have w : \u2200 (x : \u03b1), x \u2208 L \u2192 x \u2208 \u2191p := 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\u2081 := elem_of_normalised' L x l,\n        have w\u2082 := k w\u2081,\n        rw [mem_coe] at w\u2082,\n        have w\u2083 := smul p (\u2225x\u2225) w\u2082,\n        rw [smul_smul, one_div_eq_inv, mul_inv_cancel, one_smul] at w\u2083,\n        rw [mem_coe],\n        exact w\u2083,\n        rw [\u2190ne.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 \u03b1) : span \u211d (normalise L) = span \u211d L :=\nbegin\n    ext,\n    rw [mem_span],\n    constructor,\n\n    intros h,\n    exact (h (span \u211d L)) (normalised_subset_span L),\n\n    intros h p w,\n    have h' := mem_span.1 h,\n    have h\u2081 := h' p,\n    exact h\u2081 (in_submodule_of_normalised_in_submodule L p w),\nend\n\ndef orthonormal_basis (L : set \u03b1) := orthonormal L \u2227 is_basis \u211d L\n\ntheorem normalised_basis_is_orthonormal_basis (L : set \u03b1) (h : is_basis \u211d 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 \u211d _) h_left,\n    exact \u27e8by {dsimp [orthonormal],\n    exact \u27e8orthog_normalised_of_orthog L k, norm_one_of_normalised L w\u27e9},\n    by {exact \u27e8orthog_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]}\u27e9}\u27e9,\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 : \u2115 \u2192 \u03b1) : \u2115 \u2192 set \u03b1\n-- | 0 := {\u2225s 0\u2225\u207b\u00b9 \u2022 s 0}\n-- | n := sorry\n\n-- def gram_schmidt (s : \u2115 \u2192 \u03b1) : \u2115 \u2192 \u03b1 :=\n-- \u22c3\u2080 {L | \u2203 (n : \u2115), L = gram_partial s n}\n\nend norm_known\n\nsection perp_space\n\ndef perp (L : set \u03b1) : set \u03b1 := {x | \u2200 (y \u2208 L), x \u22a5 y}\n\nlemma perp_perp (L : set \u03b1) : L \u2286 perp (perp L) :=\nbegin\n    have w : \u2200 (x : \u03b1), x \u2208 L \u2192 x \u2208 perp (perp L) := begin\n        intros x h,\n        dsimp [perp],\n        intros y k,\n        have k\u2081 := orthog_symm (k x h),\n        exact k\u2081,\n    end,\n    exact w,\nend\n\nlemma perp_antitone (S : set \u03b1) (L : set \u03b1) (h : S \u2286 L) : perp L \u2286 perp S :=\nbegin\n    have w : \u2200 (x : \u03b1), x \u2208 perp L \u2192 x \u2208 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 \u03b1}\n\nlemma perp_add_closed (x y : \u03b1) (hx : x \u2208 perp S) (hy : y \u2208 perp S) : x + y \u2208 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 : \u211d) (x : \u03b1) (hx : x \u2208 perp S) : c\u2022x \u2208 perp S :=\nbegin\n    dsimp [perp] at *,\n    intros z hz,\n    rw [\u2190one_smul \u211d z],\n    exact @mul_orthog \u03b1 _ _ _ _ x z c 1 (hx z hz),\nend\n\nlemma zero_in_perp : (0 : \u03b1) \u2208 perp S :=\nbegin\n    dsimp [perp],\n    intros y h,\n    exact right_orthog_to_zero y,\nend\n\ndef perp_subspace : subspace \u211d \u03b1 :=\n{carrier := perp S,\n zero := zero_in_perp,\n add := perp_add_closed,\n smul := perp_smul_closed}\n\nlemma sub_simp {\u03b1 : Type*} [add_comm_group \u03b1] [vector_space \u211d \u03b1] {S : subspace \u211d \u03b1} {y : \u03b1} : y \u2208 S \u2194 y \u2208 S.carrier :=\nby {rw [\u2190submodule.mem_coe], unfold_coes}\n\nlemma perp_singleton_ker (x : \u03b1) : perp {x} = (linear_map.ker (ip_map x)).carrier :=\nbegin\n    ext y,\n    rw [\u2190sub_simp, mem_ker, ip_map_to_fun],\n    dsimp [perp],\n    split,\n\n    intros h,\n    have h\u2081 := h x (mem_singleton x),\n    dsimp [orthog] at h\u2081,\n    rw [conj_symm] at h\u2081,\n    exact h\u2081,\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 : \u03b1 \u2192\u2097[\u211d] \u211d} : (linear_map.ker f).carrier = f\u207b\u00b9' {0} :=\nby {ext, rw [\u2190sub_simp], simp}\n\nlemma bounded_functional_ker_closed {f : \u03b1 \u2192\u2097[\u211d] \u211d} {w : @is_bounded_linear_map \u211d _ \u03b1 ip_space_is_normed_space _ _ f} : @is_closed \u03b1 \u03b1_topological_space (linear_map.ker f).carrier :=\nby {rw [@functional_ker_is_preimage_zero \u03b1 _ _ _ _],\n    apply ((@continuous_iff_is_closed \u03b1 \u211d \u03b1_topological_space \u211d_topological_space f).1 (@is_bounded_linear_map.continuous \u211d _ \u03b1 ip_space_is_normed_space \u211d _ _ w) {0}),\n    exact is_closed_singleton}\n\nlemma ip_map_ker_is_preimage_zero (x : \u03b1) : (linear_map.ker (ip_map x)).carrier = (ip_map x)\u207b\u00b9' {0} :=\nfunctional_ker_is_preimage_zero\n\nlemma ip_map_ker_is_closed (x : \u03b1) : @is_closed \u03b1 \u03b1_topological_space (linear_map.ker (ip_map x)).carrier :=\n@bounded_functional_ker_closed \u03b1 _ _ _ _ _ (ip_map_is_bounded_linear_map x)\n\nlemma perp_singleton_closed (x : \u03b1) : @is_closed \u03b1 \u03b1_topological_space (perp {x}) :=\nby {rw [perp_singleton_ker], exact ip_map_ker_is_closed x}\n\nlemma perp_int_singleton (S : set \u03b1) : perp S = \u22c2\u2080 {L | \u2203 (a \u2208 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\u2081 := h (perp {y}) y w rfl,\n    dsimp [perp] at h\u2081,\n    exact h\u2081 y (mem_singleton y),\nend\n\nlemma perp_int_trivial {l : (0 : \u03b1) \u2208 S}: S \u2229 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\u2081 := zero_of_norm_sq_zero x,\n    dsimp [norm_sq] at k\u2081,\n    dsimp [orthog] at k,\n    exact k\u2081 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 \u03b1) {t : set \u03b1} (h :t \u2208 {L : set \u03b1 | \u2203 (a : \u03b1) (H : a \u2208 S), L = perp {a}}) : \u2203 (a \u2208 S), t = perp {a} :=\nby {rw [mem_set_of_eq] at h, exact h}\n\ntheorem perp_space_closed (S : set \u03b1) : @is_closed \u03b1 \u03b1_topological_space (perp S) :=\nbegin\n    rw [perp_int_singleton],\n    apply @is_closed_sInter \u03b1 \u03b1_topological_space _,\n    intros t h,\n    have k := perp_singleton_expr S h,\n    rcases k with \u27e8a, k\u2081, k\u2082\u27e9,\n    rw [k\u2082],\n    exact perp_singleton_closed a,\nend\n\nend perp_space\n\nsection orthogonal_projection\n\nlocal attribute [instance] \u03b1_normed_space\n\nvariables [Hilbert_space \u03b1]\nvariables (S : submodule \u211d \u03b1)\nvariables (h : @is_closed \u03b1 \u03b1_topological_space S.carrier)\n\ninclude h\n\ntheorem proj_exists_unique (x : \u03b1) : \u2203! (y : \u03b1), y \u2208 S \u2227 (\u2225x-y\u2225 = Inf {r | \u2203 (z \u2208 S), r = \u2225x-z\u2225}) :=\nbegin\n    sorry,\nend\n\ndef orthog_proj (x : \u03b1) := classical.some (exists_of_exists_unique (proj_exists_unique S h x))\n\nlemma orthog_classical (x : \u03b1) : orthog_proj S h x = classical.some (exists_of_exists_unique (proj_exists_unique S h x)) := rfl\n\nlemma orthog_proj_mem (x : \u03b1) : orthog_proj S h x \u2208 S :=\nbegin\n    have w := classical.some_spec (exists_of_exists_unique (proj_exists_unique S h x)),\n    rw [\u2190orthog_classical] at w,\n    cases w,\n    exact w_left,\nend\n\nlemma orthog_proj_dist (x : \u03b1) : \u2225x -  orthog_proj S h x\u2225 = Inf {r | \u2203 (z \u2208 S), r = \u2225x-z\u2225} :=\nbegin\n    have w := classical.some_spec (exists_of_exists_unique (proj_exists_unique S h x)),\n    rw [\u2190orthog_classical] at w,\n    cases w,\n    exact w_right,\nend\n\nlemma orthog_unique (x y z : \u03b1) (w : (y \u2208 S \u2227 (\u2225x-y\u2225 = Inf {r | \u2203 (j \u2208 S), r = \u2225x-j\u2225})) \u2227 (z \u2208 S \u2227 (\u2225x-z\u2225 = Inf {r | \u2203 (j \u2208 S), r = \u2225x-j\u2225}))) : 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 : \u03b1) (w : y \u2208 S \u2227 (\u2225x-y\u2225 = Inf {r | \u2203 (z \u2208 S), r = \u2225x-z\u2225})) : y = orthog_proj S h x :=\nby {apply orthog_unique S h, exact \u27e8w, \u27e8orthog_proj_mem S h x, orthog_proj_dist S h x\u27e9\u27e9}\n\nlemma orthog_proj_suff' (x y : \u03b1) (w : y \u2208 S \u2227 (\u2225x-y\u2225 = Inf {r | \u2203 (z \u2208 S), r = \u2225x-z\u2225})) : orthog_proj S h x = y :=\nby {apply symm, exact orthog_proj_suff S h x y w}\n\nlemma dist_bounded_below (x : \u03b1): \u2203 (l : \u211d), \u2200 (y : \u211d), y \u2208 {r : \u211d | \u2203 (z \u2208 S), r = \u2225x - z\u2225} \u2192 l \u2264 y :=\nbegin\n    use 0,\n    intros y,\n    simp,\n    intros z w\u2081 w\u2082,\n    rw [w\u2082],\n    exact norm_nonneg _,\nend\n\nlemma dist_nonempty (x : \u03b1) : (\u2203 (r : \u211d), r \u2208 {r : \u211d | \u2203 (z : \u03b1) (H : z \u2208 S), r = \u2225x - z\u2225}) :=\nbegin\n    use \u2225x\u2225,\n    simp,\n    use 0,\n    exact \u27e8zero_mem S, by {simp}\u27e9,\nend\n\nlemma orthog_proj_id_on_S (x : \u03b1) (k : x \u2208 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\u2081 : (0 : \u211d) \u2208 {r : \u211d | \u2203 (z : \u03b1) (H : z \u2208 S), r = \u2225x - z\u2225} := begin\n        simp,\n        use x,\n        split,\n\n        exact k,\n\n        simp,\n    end,\n    have w\u2082 := @Inf_le {r | \u2203 (z \u2208 S), r = \u2225x-z\u2225} (dist_bounded_below S h x) 0 w\u2081,\n    have w\u2083 : (\u2200 (z : \u211d), z \u2208 {r : \u211d | \u2203 (z : \u03b1) (H : z \u2208 S), r = \u2225x - z\u2225} \u2192 0 \u2264 z) := begin\n        intros z k\u2081,\n        simp at k\u2081,\n        cases k\u2081,\n        cases k\u2081_h,\n        rw [k\u2081_h_right],\n        exact norm_nonneg _,\n    end,\n    have w\u2084 := (le_Inf {r | \u2203 (z \u2208 S), r = \u2225x-z\u2225} (dist_nonempty S h _) (dist_bounded_below S h x)).2 w\u2083,\n    have w\u2085 := (antisymm w\u2082 w\u2084).symm,\n    simp at w\u2085,\n    exact w\u2085,\nend\n\nlemma orthog_proj_zero_on_perp_S (x : \u03b1) (k : x \u2208 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\u2081 : \u2225x\u2225 \u2208 {r : \u211d | \u2203 (z : \u03b1) (H : z \u2208 S), r = \u2225x - z\u2225} := begin\n        simp,\n        use 0,\n        split,\n\n        exact zero_mem S,\n\n        simp,\n    end,\n    have w\u2082 := Inf_le {r | \u2203 (z \u2208 S), r = \u2225x-z\u2225} (dist_bounded_below S h x) w\u2081,\n    have w\u2083 : (\u2203 (r : \u211d), r \u2208 {r : \u211d | \u2203 (z : \u03b1) (H : z \u2208 S), r = \u2225x - z\u2225}) := begin\n        use \u2225x\u2225,\n        exact w\u2081,\n    end,\n    have w\u2084 : (\u2200 (z : \u211d), z \u2208 {r : \u211d | \u2203 (z : \u03b1) (H : z \u2208 S), r = \u2225x - z\u2225} \u2192 \u2225x\u2225 \u2264 z) := begin\n        intros r l,\n        simp at l,\n        cases l with z l,\n        cases l,\n        rw \u2190norm_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\u2081 := @mul_orthog \u03b1 _ _ _ _ x z 1 (-1) (k z l_left),\n        rw [one_smul, neg_one_smul] at k\u2081,\n        exact k\u2081,\n        rw [l_right],\n        exact norm_nonneg _,\n    end,\n    have w\u2085 := (le_Inf {r | \u2203 (z \u2208 S), r = \u2225x-z\u2225} w\u2083 (dist_bounded_below S h x)).2 w\u2084,\n    exact (antisymm w\u2082 w\u2085).symm,\nend\n\nlemma orthog_proj_idempotent (x : \u03b1) : 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 : \u03b1) (k : \u2200 (y \u2208 S), \u2225y\u2225=1 \u2192 x \u22a5 y) : x \u2208 perp S.carrier :=\nbegin\n    dsimp [perp, orthog] at *,\n    intros y k\u2081,\n    by_cases (y=0),\n\n    rw [h],\n    exact left_orthog_to_zero x,\n\n    revert h,\n    intros k\u2082,\n    rw [\u2190ne.def] at k\u2082,\n    have w\u2081 := k ((1/\u2225y\u2225) \u2022 y) (smul_mem S (1/\u2225y\u2225) k\u2081) (norm_one_of_norm_inv y k\u2082),\n    have w\u2082 := mul_orthog x _ 1 (\u2225y\u2225) w\u2081,\n    rw [one_smul, one_div_eq_inv, \u2190mul_smul, mul_inv_cancel ((norm_neq_zero_iff_neq_zero y).2 k\u2082), one_smul] at w\u2082,\n    exact w\u2082,\nend\n\nlemma min_dist_expr (x y : \u03b1) (k : \u2225y\u2225 = 1) : \u2225x-(orthog_proj S h x + \u27eay \u2225 x - orthog_proj S h x\u27eb\u2022y)\u2225^2 = \u2225x - orthog_proj S h x\u2225^2 - \u27eay \u2225 x - orthog_proj S h x\u27eb^2 :=\nbegin\n    rw [sub_eq_add_neg, \u2190neg_one_smul \u211d, smul_add, \u2190add_assoc, neg_one_smul \u211d, neg_one_smul \u211d,\n    sqr_norm, sqr_norm, norm_sq_add (x + -orthog_proj S h x) (-(\u27eay\u2225x - orthog_proj S h x\u27eb \u2022 y))],\n    dsimp [norm_sq],\n    rw [\u2190neg_one_smul \u211d (\u27eay\u2225x + -orthog_proj S h x\u27eb \u2022 y), smul_smul, mul_right, conj_symm y,\n    mul_assoc, \u2190pow_two],\n    ring,\n    rw [add_assoc, sub_eq_add_neg (\u27eax-orthog_proj S h x\u2225x-orthog_proj S h x\u27eb) (\u27eax - orthog_proj S h x\u2225y\u27eb ^ 2)],\n    apply congr_arg (\u03bb r, \u27eax - orthog_proj S h x\u2225x - orthog_proj S h x\u27eb + r),\n    rw [mul_left, mul_right],\n    have w : norm_sq y = \u27eay \u2225 y\u27eb := rfl,\n    rw [\u2190w, \u2190sqr_norm, pow_two \u2225y\u2225, k, mul_one, mul_one, \u2190pow_two, \u2190neg_one_mul \u27eax - orthog_proj S h x\u2225y\u27eb,\n    mul_pow, neg_one_pow_eq_pow_mod_two],\n    have w\u2081 : 2 % 2 = 0 := rfl,\n    rw [w\u2081, pow_zero, \u2190neg_one_mul, \u2190mul_assoc, \u2190right_distrib],\n    apply congr_arg (\u03bb r, r * \u27eax - orthog_proj S h x\u2225y\u27eb ^ 2),\n    rw [\u2190neg_neg (1 : \u211d), mul_comm, \u2190neg_one_mul, \u2190neg_one_mul (-(1 : \u211d)), mul_assoc, \u2190left_distrib],\n    apply congr_arg (\u03bb r, (-(1 : \u211d))*r),\n    rw [neg_one_mul, neg_neg, one_mul, \u2190sub_eq_add_neg],\n    have w\u2082 : (2 : \u211d) = 1 + 1 := rfl,\n    rw [w\u2082, sub_eq_add_neg, add_assoc, add_right_neg, add_zero],\nend\n\nlemma orthog_of_orthog_proj_sub (x : \u03b1) : (x - orthog_proj S h x) \u2208 perp S.carrier:=\nbegin\n    apply perp_mem_of_orthog_to_units S h,\n    intros y k\u2081 k\u2082,\n    dsimp [orthog],\n    have w\u2081 : \u2225x-orthog_proj S h x\u2225 \u2264 \u2225x - (orthog_proj S h x + \u27eay \u2225 x - orthog_proj S h x\u27eb \u2022 y)\u2225 := begin\n        have w\u2081 := orthog_proj_dist S h x,\n        rw [w\u2081],\n        have w\u2082 : \u2225x - (orthog_proj S h x + \u27eay \u2225 x - orthog_proj S h x\u27eb \u2022 y)\u2225 \u2208 {r : \u211d | \u2203 (z : \u03b1) (H : z \u2208 S), r = \u2225x - z\u2225} := begin\n            simp,\n            existsi orthog_proj S h x + \u27eay \u2225 x - orthog_proj S h x\u27eb \u2022 y,\n            split,\n            exact add_mem S (orthog_proj_mem S h x) (smul_mem S _ k\u2081),\n            simp,\n        end,\n        have w\u2083 := Inf_le {r : \u211d | \u2203 (z : \u03b1) (H : z \u2208 S), r = \u2225x - z\u2225} (dist_bounded_below S h x) w\u2082,\n        exact w\u2083,\n    end,\n    by_contradiction,\n    rw [conj_symm, \u2190ne.def, \u2190sqr_pos_iff_neq_zero] at a,\n    have w\u2083 : \u2225x - orthog_proj S h x\u2225 ^ 2 - \u27eay \u2225 x - orthog_proj S h x\u27eb ^ 2 < \u2225x-orthog_proj S h x\u2225^2 := begin\n        rw [sub_eq_add_neg],\n        conv {to_rhs, rw [\u2190add_zero (\u2225x - orthog_proj S h x\u2225 ^ 2)]},\n        apply (real.add_lt_add_iff_left (\u2225x - orthog_proj S h x\u2225 ^ 2)).2,\n        exact neg_lt_zero.2 a,\n    end,\n    rw [\u2190min_dist_expr S h x y k\u2082] at w\u2083,\n    rw [\u2190norm_sqr_leq_iff_norm_leq] at w\u2081,\n    rw [lt_iff_not_ge] at w\u2083,\n    exact absurd w\u2081 w\u2083,\n    exact norm_nonneg _,\nend\n\nlemma orthog_proj_norm_leq (x : \u03b1) : \u2225orthog_proj S h x\u2225 \u2264 \u2225x\u2225 :=\nbegin\n    have k\u2081 := orthog_of_orthog_proj_sub S h x,\n    dsimp [perp] at k\u2081,\n    have w := pythagoras (k\u2081 (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 [\u2190@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 : \u2203 M > 0, \u2200 x : \u03b1, \u2225orthog_proj S h x \u2225 \u2264 M * \u2225 x \u2225 :=\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 : \u03b1) : \u2203 (u \u2208 S), \u2203 (v \u2208 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\u2081 u\u2082 v\u2081 v\u2082 : \u03b1) (U\u2081 : u\u2081 \u2208 S) (U\u2082 : u\u2082 \u2208 S) (V\u2081 : v\u2081 \u2208 perp S.carrier) (V\u2082 : v\u2082 \u2208 perp S.carrier)\n(k\u2081 : x = u\u2081 + v\u2081) (k\u2082 : x = u\u2082 + v\u2082) : (u\u2081 = u\u2082 \u2227 v\u2081 = v\u2082) :=\nbegin\n    rw [k\u2081] at k\u2082,\n    have k\u2083 : u\u2081 - u\u2082 = v\u2082 - v\u2081 := begin\n        have l\u2081 := congr_arg (\u03bb (z : \u03b1), z - u\u2082 - v\u2081) k\u2082,\n        simp at l\u2081,\n        rw [sub_eq_add_neg],\n        exact l\u2081,\n    end,\n    have w\u2081 := sub_mem S U\u2081 U\u2082,\n    have w\u2082 := @sub_mem \u211d \u03b1 _ _ _ (@perp_subspace \u03b1 _ _ _ _ S.carrier) v\u2082 v\u2081 V\u2082 V\u2081,\n    have w\u2083 : u\u2081 - u\u2082 \u2208 S.carrier \u2229 perp S.carrier := begin\n        split,\n        exact w\u2081,\n        rw [k\u2083],\n        exact w\u2082,\n    end,\n    rw [@perp_int_trivial \u03b1 _ _ _ _ S.carrier (zero_mem S)] at w\u2083,\n    have w\u2084 := sub_eq_zero.1 (eq_of_mem_singleton w\u2083),\n    rw [k\u2083] at w\u2083,\n    exact \u27e8w\u2084, (sub_eq_zero.1 (eq_of_mem_singleton w\u2083)).symm\u27e9,\nend\n\ntheorem orthog_proj_of_orthog_direct_sum (x u v : \u03b1) (U : u \u2208 S) (V : v \u2208 perp S.carrier) (k : x = u + v) : orthog_proj S h x = u :=\nbegin\n    have w\u2081 := 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\u2081,\n    exact (w\u2081_left).symm,\nend\n\nlemma orthog_proj_add (x y : \u03b1) : orthog_proj S h (x+y) = orthog_proj S h x + orthog_proj S h y :=\nbegin\n    have w\u2081 := orthog_direct_sum_exists S h x,\n    rcases w\u2081 with \u27e8ux, Ux, vx, Vx, w\u2081\u27e9,\n    have w\u2082 := orthog_direct_sum_exists S h y,\n    rcases w\u2082 with \u27e8uy, Uy, vy, Vy, w\u2082\u27e9,\n    have w\u2083 := orthog_proj_of_orthog_direct_sum S h x ux vx Ux Vx w\u2081,\n    have w\u2084 := orthog_proj_of_orthog_direct_sum S h y uy vy Uy Vy w\u2082,\n    rw [w\u2083, w\u2084],\n    have w\u2085 : x + y = (ux + uy) + (vx + vy) := begin\n        rw [w\u2081, w\u2082],\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\u2085),\nend\n\nlemma orthog_proj_smul (c : \u211d) (x : \u03b1) : orthog_proj S h (c \u2022 x) = c \u2022 (orthog_proj S h x) :=\nbegin\n    have w\u2081 := orthog_direct_sum_exists S h x,\n    rcases w\u2081 with \u27e8u, U, v, V, w\u2081\u27e9,\n    have w\u2082 := orthog_proj_of_orthog_direct_sum S h x u v U V w\u2081,\n    rw [w\u2082],\n    have w\u2083 : c\u2022x = c\u2022u + c\u2022v := begin\n        rw [\u2190smul_add, w\u2081],\n    end,\n    have w\u2085 := orthog_proj_of_orthog_direct_sum S h (c\u2022x) (c\u2022u) (c\u2022v) (smul_mem S c U) (smul_mem (@perp_subspace \u03b1 _ _ _ _ S.carrier) c V) w\u2083,\n    rw [w\u2085],\nend\n\ndef orthog_proj_linear : is_linear_map \u211d (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 : \u03b1) (w : orthog_proj S h x = 0) : x \u2208 perp S.carrier :=\nbegin\n    have w\u2081 := orthog_direct_sum_exists S h x,\n    rcases w\u2081 with \u27e8u, U, v, V, w\u2081\u27e9,\n    dsimp [perp, orthog] at *,\n    intros y k,\n    rw [w\u2081, add_left],\n    have w\u2082 := orthog_proj_of_orthog_direct_sum S h x u v U V w\u2081,\n    rw [w] at w\u2082,\n    rw [\u2190w\u2082, 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 \u03b1 _ _ _ _ (linear_map.range ((is_linear_map.mk' (orthog_proj S h) (orthog_proj_linear S h)))).carrier :=\nbegin\n    ext,\n    rw [\u2190sub_simp, mem_ker],\n    split,\n\n    intros k,\n    dsimp [perp],\n    intros y w,\n    rw [\u2190sub_simp] at w,\n    simp at w,\n    cases w with z w,\n    simp at k,\n    have w\u2081 := perp_of_orthog_proj_zero S h x k,\n    have w\u2082 := orthog_proj_mem S h z,\n    rw [w] at w\u2082,\n    dsimp [perp] at w\u2081,\n    exact w\u2081 y w\u2082,\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\u2081 := orthog_proj_id_on_S S h y k,\n    have w\u2082 := w y,\n    rw [\u2190sub_simp] at w\u2082,\n    simp at w\u2082,\n    exact w\u2082 y w\u2081,\nend\n\nlemma orthog_proj_is_symmetric (x y : \u03b1) : \u27eaorthog_proj S h x \u2225 y\u27eb = \u27eax \u2225 orthog_proj S h y\u27eb :=\nbegin\n    have w\u2081 := orthog_direct_sum_exists S h x,\n    rcases w\u2081 with \u27e8u\u2081, U\u2081, v\u2081, V\u2081, w\u2081\u27e9,\n    have w\u2082 := orthog_direct_sum_exists S h y,\n    rcases w\u2082 with \u27e8u\u2082, U\u2082, v\u2082, V\u2082, w\u2082\u27e9,\n    rw [w\u2081, w\u2082],\n    simp [orthog_proj_add],\n    dsimp [perp] at *,\n    have k\u2081 := V\u2082 (orthog_proj S h u\u2081) (orthog_proj_mem S h u\u2081),\n    have k\u2082 := orthog_proj_zero_on_perp_S S h v\u2081 V\u2081,\n    have k\u2083 := orthog_proj_zero_on_perp_S S h v\u2082 V\u2082,\n    have k\u2084 := V\u2081 (orthog_proj S h u\u2082) (orthog_proj_mem S h u\u2082),\n    dsimp [orthog] at *,\n    rw [conj_symm] at k\u2081,\n    rw [k\u2081, zero_add, k\u2082, right_orthog_to_zero, right_orthog_to_zero, add_zero, add_zero,\n        k\u2083, left_orthog_to_zero, left_orthog_to_zero, add_zero, zero_add, k\u2084, add_zero,\n        orthog_proj_id_on_S S h u\u2081 U\u2081, orthog_proj_id_on_S S h u\u2082 U\u2082],\nend\n\nlemma orthog_proj_is_bounded_linear_map : is_bounded_linear_map \u211d (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 : \u03b1 \u2192\u2097[\u211d] \u211d)\n\nlemma fun_coe : \u21d1f = f.to_fun := rfl\n\nvariables [Hilbert_space \u03b1]\nvariables (S : @submodule \u211d \u03b1 _ _ _)\n\nlemma perp_trivial_of_subspace_all (h : @is_closed \u03b1 \u03b1_topological_space S.carrier) (k\u2081 : \u2200 (x : \u03b1), x \u2208 S) (y : \u03b1) (k\u2082 : y \u2208 perp S.carrier) : y = 0 :=\nby {dsimp [perp] at k\u2082, exact zero_of_orthog_self (k\u2082 y (k\u2081 y))}\n\nlemma perp_nonempty_of_subspace_not_all (h : @is_closed \u03b1 \u03b1_topological_space S.carrier) : (\u2203 (x : \u03b1), x \u2209 S) \u2192 (\u2203 (y : \u03b1), y \u2260 0 \u2227 y \u2208 perp S.carrier) :=\nbegin\n    rw [awesome_mt],\n    simp,\n    intros k,\n    intros x,\n    have k\u2081 := orthog_direct_sum_exists S h x,\n    rcases k\u2081 with \u27e8u, \u27e8U, \u27e8v, \u27e8V, k\u2081\u27e9\u27e9\u27e9\u27e9,\n    rw [k\u2081],\n    have k\u2082 := k v,\n    rw [awesome_mt] at k\u2082,\n    simp at k\u2082,\n    have k\u2083 := k\u2082 V,\n    rw [k\u2083, add_zero],\n    exact U,\nend\n\nlemma perp_nonempty_of_subspace_not_all' (h : @is_closed \u03b1 \u03b1_topological_space S.carrier) (k : \u2203 (x : \u03b1), x \u2209 S) : \u2203 (y : \u03b1), \u2225y\u2225=1 \u2227 y \u2208 perp S.carrier :=\nbegin\n    have k\u2081 := perp_nonempty_of_subspace_not_all S h k,\n    rcases k\u2081 with \u27e8z, k\u2081, k\u2082\u27e9,\n    use ((1/\u2225z\u2225)\u2022z),\n    exact \u27e8norm_one_of_norm_inv z k\u2081, smul_mem perp_subspace (1/\u2225z\u2225) k\u2082\u27e9,\nend\n\ntheorem riesz_rep_exists (w : @is_bounded_linear_map \u211d _ \u03b1 ip_space_is_normed_space _ _ f) : \u2203 (x : \u03b1), f.to_fun = ip_map x :=\nbegin\n    have w\u2081 := @bounded_functional_ker_closed \u03b1 _ _ _ _ f w,\n    have w\u2082 := orthog_direct_sum_exists (linear_map.ker f) w\u2081,\n    by_cases k : (\u2200 (x : \u03b1), x \u2208 linear_map.ker f),\n\n    use 0,\n    ext,\n    simp,\n    have w\u2083 := w\u2082 x,\n    cases w\u2083 with u w\u2083,\n    cases w\u2083 with w\u2083 w\u2084,\n    cases w\u2084 with v w\u2084,\n    cases w\u2084 with w\u2084 w\u2085,\n    rw [w\u2085, linear_map.add],\n    simp at w\u2083,\n    rw [fun_coe] at w\u2083,\n    simp [w\u2083],\n    have w\u2086 := perp_trivial_of_subspace_all (linear_map.ker f) w\u2081 k v w\u2084,\n    rw [w\u2086],\n    exact linear_map.map_zero f,\n\n    rw [not_forall] at k,\n    have k\u2081 := perp_nonempty_of_subspace_not_all' (linear_map.ker f) w\u2081 k,\n    rcases k\u2081 with \u27e8z, \u27e8k\u2081, k\u2082\u27e9\u27e9,\n    use ((f z) \u2022 z),\n    ext,\n    have k\u2083 : (f x) \u2022 z - (f z) \u2022 x \u2208 linear_map.ker f := begin\n        simp,\n        ring,\n    end,\n    dsimp [perp] at k\u2082,\n    rw [\u2190mul_one (f.to_fun x), \u2190mul_one ((f.to_fun x)*1), mul_assoc, \u2190pow_two, \u2190k\u2081, sqr_norm],\n    dsimp [norm_sq],\n    rw [\u2190mul_left, \u2190add_zero (f.to_fun x \u2022 z), \u2190add_left_neg (f.to_fun z \u2022 x), \u2190add_assoc,\n    add_left],\n    have k\u2084 := k\u2082 _ k\u2083,\n    dsimp [orthog] at k\u2084,\n    rw [conj_symm, fun_coe] at k\u2084,\n    rw [k\u2084, zero_add, fun_coe, mul_left, conj_symm, \u2190mul_left],\nend\n\ntheorem riesz_rep_unique {x y : \u03b1} (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\u2081 := @congr_arg _ _ z z (\u03bb z, inner_product x z) rfl,\n    conv at k\u2081 {to_rhs, rw [w]},\n    exact k\u2081,\nend\n\nend riesz_representation\n\nsection adjoint\n\nvariables (f : \u03b1 \u2192\u2097[\u211d] \u03b1)\nvariables (h : @is_bounded_linear_map \u211d _ \u03b1 ip_space_is_normed_space \u03b1 ip_space_is_normed_space f)\nvariables [Hilbert_space \u03b1]\n\ninclude f h\n\ndef adjoint_map (y : \u03b1): \u03b1 \u2192\u2097[\u211d] \u211d :=\nbegin\n    refine_struct {..},\n    use (\u03bb x, \u27eaf x \u2225 y\u27eb),\n    repeat {simp},\nend\n\nlemma adjoint_map_fun (y : \u03b1) : (adjoint_map f h y).to_fun = \u03bb x, \u27eaf.to_fun x \u2225 y\u27eb := rfl\n\nlemma adjoint_map_bounded (y : \u03b1) : @is_bounded_linear_map \u211d _ \u03b1 ip_space_is_normed_space _ _ (adjoint_map f h y) :=\nbegin\n    constructor,\n\n    constructor,\n    repeat {simp},\n\n    have h\u2081 := @is_bounded_linear_map.bound \u211d _ \u03b1 ip_space_is_normed_space \u03b1 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\u2081 : (\u03bb (x : \u03b1), \u27eaf.to_fun x \u2225 0\u27eb) x = \u27eaf.to_fun x \u2225 0\u27eb := rfl,\n    rw [fun_coe, adjoint_map_fun, h, w\u2081, left_orthog_to_zero, norm_zero, one_mul],\n    apply norm_nonneg _,\n\n    rcases h\u2081 with \u27e8M, H, h\u2081\u27e9,\n    use M*\u2225y\u2225,\n    rw [\u2190ne.def] at h,\n    have w\u2081 := (@norm_pos_iff \u03b1 ip_space_is_normed_group y).2 h,\n    use mul_pos H w\u2081,\n    intros x,\n    apply le_trans (cauchy_schwarz (f x) y),\n    rw [mul_assoc, mul_comm \u2225y\u2225, \u2190mul_assoc],\n    apply (mul_le_mul_right w\u2081).2,\n    exact h\u2081 x,\nend\n\ndef adjoint_to_fun : \u03b1 \u2192 \u03b1 :=\n\u03bb y, classical.some (riesz_rep_exists (adjoint_map f h y) (adjoint_map_bounded f h y))\n\nlemma adjoint_ip_switch (x y : \u03b1) : \u27eaf x \u2225 y\u27eb = \u27eax \u2225 adjoint_to_fun f h y\u27eb :=\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 (\u03bb (x : \u03b1), \u27eaf.to_fun x \u2225 y\u27eb) rfl,\n    conv at k' {to_rhs, rw [\u2190k, conj_symm]},\n    exact k',\nend\n\nlemma adjoint_ip_switch' (x y : \u03b1) : \u27eaadjoint_to_fun f h x \u2225 y\u27eb = \u27eax \u2225 f y\u27eb :=\nby {rw [conj_symm, \u2190adjoint_ip_switch, conj_symm]}\n\nlemma adjoint_to_fun_unique (S : \u03b1 \u2192 \u03b1) (w : \u2200 (x y : \u03b1), \u27eaf x \u2225 y\u27eb = \u27eax \u2225 S y\u27eb) : S = adjoint_to_fun f h :=\nbegin\n    ext,\n    apply @left_ext \u03b1 _ _ _ _ _ _,\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 : \u03b1) : adjoint_to_fun f h (x+y) = adjoint_to_fun f h x + adjoint_to_fun f h y :=\nbegin\n    apply @left_ext \u03b1 _ _ _ _ _ _,\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 : \u211d) (x : \u03b1) : adjoint_to_fun f h (c \u2022 x) = c \u2022 adjoint_to_fun f h x :=\nbegin\n    apply @left_ext \u03b1 _ _ _ _ _ _,\n    intros z,\n    rw [adjoint_ip_switch', mul_left, mul_left, adjoint_ip_switch'],\nend\n\ndef adjoint : \u03b1 \u2192\u2097[\u211d] \u03b1 :=\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] \u03b1_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 \u211d _ \u03b1 ip_space_is_normed_space \u03b1 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 \u27e8M, H, w\u27e9,\n    use M,\n    use H,\n\n    have k : \u2200 (x y : \u03b1), \u2225\u27eaadjoint_to_fun f h x \u2225 y\u27eb\u2225\u2264M*\u2225x\u2225*\u2225y\u2225 := 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 [\u2190ne.def] at l,\n        rw [mul_comm, mul_assoc, mul_comm \u2225x\u2225, \u2190mul_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 (\u2225(adjoint f h).to_fun x\u2225 = 0),\n    have k\u2081 : 0 \u2264 M * \u2225x\u2225 := mul_nonneg (le_of_lt H) (norm_nonneg x),\n    rw [\u2190h] at k\u2081,\n    exact k\u2081,\n\n    revert h,\n    intros l,\n    rw [\u2190ne.def] at l,\n    have k\u2081 := k x (adjoint_to_fun f h x),\n    have k\u2082 := @sqr_norm \u03b1 _ _ _ _ (adjoint_to_fun f h x),\n    dsimp [norm_sq] at k\u2082,\n    rw [\u2190k\u2082, norm_sqr_eq_sqr, pow_two] at k\u2081,\n    have k\u2084 := mul_le_mul_of_nonneg_right k\u2081 ((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\u2084,\n    exact k\u2084,\n    rw [adjoint_fun] at l,\n    repeat {exact l},\nend\n\nlemma adjoint_ext (S : \u03b1 \u2192\u2097[\u211d] \u03b1) (k : \u2200 (x y : \u03b1), \u27eaf x \u2225 y\u27eb = \u27eax \u2225 S y\u27eb) : S = adjoint f h :=\nbegin\n    ext,\n    have k\u2081 := adjoint_to_fun_unique f h _ k,\n    simp only [] at k\u2081,\n    rw [k\u2081, \u2190adjoint_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`\u2133-bar_{r'}(S)_{\u2264c}` is the filtration on `\u2133-bar_{r'}(S)` by profinite subsets described\nat the beginning of section 9 of `analytic.pdf`. It's defined not as a subset\nof `\u2133-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 \u2192 T\u2124[[T]]/(T^{M+1})` consisting of\n  elements `F_s = \u2211_{n=1}^M a_{n,s} T^n` such that `\u2211_{s,n} |a_{n,s}| (r')^n \u2264 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 \u2192 T\u2124[[T]]/(T^{M+1})` consisting of elements\n`F_s = \u2211_{n=1}^M a_{n,s} T^n` such that `\u2211_{s,n} |a_{n,s}| r^n \u2264 c`.\nThis is an auxiliary object used to define the profinite topology on `Lbar r' S`. -/\nstructure Lbar_bdd (r : \u211d\u22650) (S : Fintype) (c : \u211d\u22650) (M : \u2115) :=\n(to_fun      : S \u2192 fin (M + 1) \u2192 \u2124)\n(coeff_zero' : \u2200 s, to_fun s 0 = 0)\n(sum_le'     : (\u2211 s i, (\u2191(to_fun s i).nat_abs * r^(i : \u2115))) \u2264 c)\n\nnamespace Lbar_bdd\n\nvariables {r' : \u211d\u22650} {S : Fintype} {c c\u2081 c\u2082 : \u211d\u22650} {M : \u2115}\n\ninstance has_coe_to_fun : has_coe_to_fun (Lbar_bdd r' S c M) (\u03bb _, S \u2192 fin (M + 1) \u2192 \u2124) :=\n\u27e8Lbar_bdd.to_fun\u27e9\n\n@[simp] lemma coe_mk (x h\u2081 h\u2082) : ((\u27e8x, h\u2081, h\u2082\u27e9 : Lbar_bdd r' S c M) : S \u2192 \u2115 \u2192 \u2124) = 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  (\u2211 s i, ((\u2191(x s i).nat_abs * r'^(i:\u2115)))) \u2264 c := x.sum_le'\n\n/-- The obvious map from `Lbar_bdd r' S c\u2081 M` to `Lbar_bdd r' S c\u2082 M`, for `c\u2081 \u2264 c\u2082`. -/\nprotected def cast_le [hc : fact (c\u2081 \u2264 c\u2082)] (x : Lbar_bdd r' S c\u2081 M) : Lbar_bdd r' S c\u2082 M :=\n\u27e8x.1, x.coeff_zero, x.sum_le.trans hc.out\u27e9\n\n@[ext] lemma ext (x y : Lbar_bdd r' S c M) (h : (\u21d1x : S \u2192 fin (M + 1) \u2192 \u2124) = 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' := \u03bb 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) := \u27e80\u27e9\n\nlemma coeff_bound [h0r : fact (0 < r')] (F : S \u2192 fin (M + 1) \u2192 \u2124)\n  (hF : \u2211 s i, (\u2191(F s i).nat_abs * r'^(i : \u2115)) \u2264 c) (n : fin (M + 1)) (s : S) :\n  \u2191(F s n).nat_abs \u2264 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 \u2191(F s n).nat_abs * min (r' ^ M) 1 \u2264 \u2191(F s n).nat_abs * r' ^ (n:\u2115) : _ -- see below for proof\n  ... \u2264 \u2211 i, (\u2191(F s i).nat_abs * r' ^ (i:\u2115)) :\n    finset.single_le_sum (\u03bb (i : fin (M + 1)) _, _) (finset.mem_univ n)\n  ... \u2264 \u2211 s i, (\u2191(F s i).nat_abs * r'^(i:\u2115)) :\n    by { refine finset.single_le_sum (\u03bb _ _, _) (finset.mem_univ s),\n      exact finset.sum_nonneg (\u03bb _ _, (subtype.property (_ : \u211d\u22650))) }\n  ... \u2264 c : hF,\n  { refine mul_le_mul_of_nonneg_left _ (subtype.property (_ : \u211d\u22650)),\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 (_ : \u211d\u22650)\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 (\u2308(-(c / min (r' ^ M) 1) : \u211d)\u2309) (\u230a(c / min (r' ^ M) 1 : \u211d)\u230b) :=\nhave h : (-(c / min (r' ^ M) 1) : \u211d) \u2264 F s n \u2227 (F s n : \u211d) \u2264 (c / min (r' ^ M) 1 : \u211d),\nby { rw [\u2190 abs_le, \u2190 real.coe_nnabs, \u2190 real.cast_nat_abs_eq_nnabs_cast],\n    exact_mod_cast coeff_bound F F.sum_le n s },\n\u27e8F s n, int.ceil_le.2 h.1, int.le_floor.2 h.2\u27e9\n\ninstance [fact (0 < r')] : fintype (Lbar_bdd r' S c M) :=\nfintype.of_injective temp_map\nbegin\n  rintros \u27e8f1, hf1, hf1'\u27e9 \u27e8f2, hf2, hf2'\u27e9 h,\n  ext s n,\n  change (temp_map \u27e8f1, hf1, hf1'\u27e9 n s).1 = (temp_map \u27e8f2, hf2, hf2'\u27e9 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 \u2264 N`. -/\ndef transition (r' : \u211d\u22650) {S : Fintype} {c : \u211d\u22650} {M N : \u2115} (h : M \u2264 N) (x : Lbar_bdd r' S c N) :\n  Lbar_bdd r' S c M :=\n{ to_fun := \u03bb s i, x s (fin.cast_le (add_le_add_right h 1) i),\n  coeff_zero' := \u03bb 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 (_ : \u211d\u22650) }\n  end }\n\nlemma transition_eq {r' : \u211d\u22650} {S : Fintype} {c : \u211d\u22650} {M N : \u2115} (h : M \u2264 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' : \u211d\u22650} {S : Fintype} {c : \u211d\u22650}\n  {M N K : \u2115} (h : M \u2264 N) (hh : N \u2264 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 : \u2115} (h : M \u2264 N) [hc : fact (c\u2081 \u2264 c\u2082)] (x : Lbar_bdd r' S c\u2081 N) :\n  transition r' h (Lbar_bdd.cast_le x : Lbar_bdd r' S c\u2082 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 : \u03a0 (M : \u2115), Lbar_bdd r' S c M // \u2200 (M N : \u2115) (h : M \u2264 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 \u2192 (\u03a0 (M : \u2115), Lbar_bdd r' S c M) := coe\n\nsection topological_structure\n\ninstance : topological_space (Lbar_bdd r' S c M) := \u22a5\ninstance : discrete_topology (Lbar_bdd r' S c M) := \u27e8rfl\u27e9\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 = \u22c2 (x : {y : \u2115 \u00d7 \u2115 // y.1 \u2264 y.2}),\n      {F : \u03a0 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 \u27e8\u27e8m, n\u27e9, h0 : m \u2264 n\u27e9,\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 [\u2190 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 : \u2115) : Lbar_bdd.limit r' S c \u2192 Lbar_bdd r' S c M := \u03bb F, F.1 M\n\nlemma continuous_iff {\u03b1 : Type*} [topological_space \u03b1] (f : \u03b1 \u2192 Lbar_bdd.limit r' S c) :\n  continuous f \u2194 (\u2200 (M : \u2115), continuous ((proj M) \u2218 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\u2081 M` and a term of type `Lbar_bdd r' S c\u2082 M`\nand produces a term of type `Lbar_bdd r' S (c\u2081 + c\u2082) M`. -/\ndef add (F : Lbar_bdd r' S c\u2081 M) (G : Lbar_bdd r' S c\u2082 M) : Lbar_bdd r' S (c\u2081 + c\u2082) M :=\n{ to_fun := F + G,\n  coeff_zero' := \u03bb s, by simp,\n  sum_le' :=\n  begin\n    refine le_trans _ (add_le_add F.sum_le G.sum_le),\n    rw \u2190 finset.sum_add_distrib,\n    refine finset.sum_le_sum _,\n    rintro s -,\n    rw \u2190 finset.sum_add_distrib,\n    refine finset.sum_le_sum _,\n    rintro i -,\n    rw \u2190 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' := \u03bb 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 \u27e8S\u27e9 as opposed to S.\n-- TODO: Use `Fintype` everywhere?!\n/-- TODO -/\ndef map {S T : Type*} [fintype S] [fintype T] (f : S \u2192 T) :\n  Lbar_bdd r' \u27e8S\u27e9 c M \u2192 Lbar_bdd r' \u27e8T\u27e9 c M := \u03bb F,\n{ to_fun := \u03bb t i, \u2211 s in finset.univ.filter (\u03bb s', f s' = t), F s i,\n  coeff_zero' := by simp,\n  sum_le' := calc\n    \u2211 (t : T) (i : fin (M+1)),\n      \u2191((\u2211 (s : S) in finset.univ.filter (\u03bb s', f s' = t), F s i).nat_abs) * r' ^ (i : \u2115)\n    \u2264 \u2211 (t : T) (i : fin (M+1)),\n      \u2211 s in finset.univ.filter (\u03bb s', f s' = t), \u2191(F s i).nat_abs * r' ^ (i : \u2115) :\n    begin\n      apply finset.sum_le_sum,\n      rintros t -,\n      apply finset.sum_le_sum,\n      rintros i -,\n      rw \u2190 finset.sum_mul,\n      refine mul_le_mul _ (le_refl _) zero_le' zero_le',\n      rw \u2190 nat.cast_sum,\n      rw nat.cast_le,\n      apply nat_abs_sum_le,\n    end\n    ... \u2264 \u2211 (s : S) (i : fin (M+1)), \u2191(F s i).nat_abs * r' ^ (i : \u2115) :\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 \u2190 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 \u22a2,\n        apply h,\n        rw [\u2190 hs.1, \u2190 hs.2] }\n    end\n    ... \u2264 _ : 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 `\u211d\u22650` 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' : \u211d\u22650) [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 (\u03ba \u03ba' : \u2115 \u2192 \u211d\u22650) [BD.data.very_suitable r r' \u03ba]\nvariables (M : ProFiltPseuNormGrpWithTinv.{u} r')\nvariables (m : \u2115)\nvariables (\u039b : PolyhedralLattice.{u})\n\ninclude BD \u03ba \u03ba' r r' M V\n\ndef thm95.IH (m : \u2115) : Prop := \u2200 \u039b : PolyhedralLattice.{u},\n  \u200b((BD.data.system \u03ba r V r').obj (op $ Hom \u039b M)).is_weak_bounded_exact\n    (k \u03ba' m) (K r r' BD \u03ba' m) m (c\u2080 r r' BD \u03ba \u03ba' m \u039b)\n\nomit BD \u03ba \u03ba' r r' M V\n\nlemma NSC_row_exact (IH : \u2200 m' < m, thm95.IH r r' BD V \u03ba \u03ba' M m')\n  (h0m : 0 < m) (i : \u2115) (hi : i \u2264 m + 1) :\n  ((thm95.double_complex BD.data \u03ba r r' V \u039b M (N r r' BD \u03ba' m)).row i).is_weak_bounded_exact\n    (k\u2081 \u03ba' m) (K\u2081 r r' BD \u03ba' m) (m - 1) (c\u2080 r r' BD \u03ba \u03ba' m \u039b) :=\nbegin\n  haveI h0m_ : fact (0 < m) := \u27e8h0m\u27e9,\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' \u039b).of_le BD.data.system_admissible _ _ le_rfl _,\n    swap 3,\n    { apply c\u2080_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\u2080_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\u2080_pred_le_of_le, exact hi },\n    all_goals { apply_instance } }\nend\n.\n\nvariables [package.adept BD \u03ba \u03ba']\n\ndef NSC_htpy :\n  normed_spectral_homotopy\n    ((thm95.double_complex BD.data \u03ba r r' V \u039b M (N r r' BD \u03ba' m)).row_map 0 1)\n      m (k' \u03ba' m) (\u03b5 r r' BD \u03ba' m) (c\u2080 r r' BD \u03ba \u03ba' m \u039b) (H r r' BD \u03ba' m) :=\n(NSH_aux BD r r' V \u03ba \u03ba' m \u039b (op (Hom \u039b M))).of_iso _ _ _\n  (iso.refl _) (thm95.mul_rescale_iso_row_one BD.data \u03ba r V _ _ (by norm_cast) \u039b M)\n  (\u03bb _ _ _, rfl) (thm95.mul_rescale_iso_row_one_strict BD.data \u03ba r V _ _ (by norm_cast) \u039b M)\n  (by apply thm95.row_map_eq_sum_comp)\n\ndef NSC (IH : \u2200 m' < m, thm95.IH r r' BD V \u03ba \u03ba' M m')\n  [pseudo_normed_group.splittable (\u039b \u2192+ M) (N r r' BD \u03ba' m) (lem98.d \u039b (N r r' BD \u03ba' m))] :\n  normed_spectral_conditions (thm95.double_complex BD.data \u03ba r r' V \u039b M (N r r' BD \u03ba' m)) m\n    (k\u2081 \u03ba' m) (K\u2081 r r' BD \u03ba' m) (k' \u03ba' m) (\u03b5 r r' BD \u03ba' m) (c\u2080 r r' BD \u03ba \u03ba' m \u039b) (H r r' BD \u03ba' m) :=\n{ row_exact := NSC_row_exact _ _ _ _ _ _ _ _ _ IH,\n  col_exact :=\n  begin\n    let N := N r r' BD \u03ba' m,\n    haveI : fact (r < 1) := \u27e8(fact.out _ : r < r').trans (fact.out _ : r' < 1)\u27e9,\n    intros j hj,\n    refine thm95.col_exact BD.data \u03ba r r' V \u039b M N j (lem98.d \u039b N) (k\u2081_sqrt \u03ba' m) m _ _\n      (k\u2081 \u03ba' m) (K\u2081 r r' BD \u03ba' m) (le_of_eq _) _ _ (c\u2080 r r' BD \u03ba \u03ba' m \u039b) \u27e8le_rfl\u27e9 infer_instance \u27e8le_rfl\u27e9,\n    { apply c\u2080_spec, assumption', },\n    { ext, delta k\u2081_sqrt, dsimp, simp only [real.mul_self_sqrt, nnreal.zero_le_coe], },\n    { apply K\u2081_spec }\n  end,\n  htpy := NSC_htpy r r' BD V \u03ba \u03ba' M m \u039b,\n  admissible := thm95.double_complex_admissible _ }\n\ninclude BD \u03ba \u03ba' r r' m\n\n/-- A variant of Theorem 9.5 in [Analytic] using weak bounded exactness. -/\ntheorem thm95' : \u2200 (\u039b : PolyhedralLattice.{u}) (S : Type u) [fintype S]\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V],\n  \u200b((BD.data.system \u03ba r V r').obj (op $ Hom \u039b (Lbar r' S))).is_weak_bounded_exact\n    (k \u03ba' m) (K r r' BD \u03ba' m) m (c\u2080 r r' BD \u03ba \u03ba' m \u039b) :=\nbegin\n  apply nat.strong_induction_on m; clear m,\n  introsI m IH \u039b S _S_fin V _V_r,\n  haveI : pseudo_normed_group.splittable\n    (\u039b \u2192+ (of r' (Lbar r' S))) (N r r' BD \u03ba' m) (lem98.d \u039b (N r r' BD \u03ba' m)) :=\n    lem98_finite \u039b S (N r r' BD \u03ba' m),\n  let cond := NSC.{u} r r' BD V \u03ba \u03ba' (of r' $ Lbar r' S) m \u039b _,\n  swap,\n  { introsI m' hm' \u039b,\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 : \u2200 (\u039b : PolyhedralLattice.{u}) (S : Profinite.{u})\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V],\n  \u200b((BD.data.system \u03ba r V r').obj (op $ Hom \u039b ((Lbar.functor.{u u} r').obj S))).is_weak_bounded_exact\n    (k \u03ba' m) (K r r' BD \u03ba' m) m (c\u2080 r r' BD \u03ba \u03ba' m \u039b) :=\nbegin\n  apply nat.strong_induction_on m; clear m,\n  introsI m IH \u039b S V _V_r,\n  haveI : pseudo_normed_group.splittable\n    (\u039b \u2192+ (of r' ((Lbar.functor.{u u} r').obj S))) (N r r' BD \u03ba' m) (lem98.d \u039b (N r r' BD \u03ba' m)) :=\n    lem98.main r' \u039b S (N r r' BD \u03ba' m),\n  let cond := NSC.{u} r r' BD V \u03ba \u03ba' (of r' $ (Lbar.functor.{u u} r').obj S) m \u039b _,\n  swap,\n  { introsI m' hm' \u039b,\n    apply IH, assumption },\n  exact normed_spectral cond\nend\n\nomit BD \u03ba \u03ba' r r' m\n\n/-- Theorem 9.5 in [Analytic] -/\ntheorem thm95 (\u039b : PolyhedralLattice.{u}) (S : Type u) [fintype S]\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V] :\n  ((BD.data.system \u03ba r V r').obj (op $ Hom \u039b (Lbar r' S))).is_bounded_exact\n    (k \u03ba' m ^ 2) (K r r' BD \u03ba' m + 1) m (c\u2080 r r' BD \u03ba \u03ba' m \u039b) :=\nbegin\n  refine system_of_complexes.is_weak_bounded_exact.strong_of_complete\n    _ (thm95' r r' BD \u03ba \u03ba' m \u039b S V) _ 1 zero_lt_one,\n  apply data.system_admissible\nend\n\n/-- Theorem 9.5 in [Analytic] -/\ntheorem thm95.profinite (\u039b : PolyhedralLattice.{u}) (S : Profinite.{u})\n  (V : SemiNormedGroup.{v}) [normed_with_aut r V] :\n  ((BD.data.system \u03ba r V r').obj (op $ Hom \u039b ((Lbar.functor.{u u} r').obj S))).is_bounded_exact\n    (k \u03ba' m ^ 2) (K r r' BD \u03ba' m + 1) m (c\u2080 r r' BD \u03ba \u03ba' m \u039b) :=\nbegin\n  refine system_of_complexes.is_weak_bounded_exact.strong_of_complete\n    _ (thm95'.profinite r r' BD \u03ba \u03ba' m \u039b 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 \u03ba r V r').obj (op $ \u27e8(Lbar.functor.{0 0} r').obj S\u27e9)).is_bounded_exact\n    (k \u03ba' m ^ 2) (K r r' BD \u03ba' m + 1) m (c\u2080 r r' BD \u03ba \u03ba' m \u27e8\u2124\u27e9) :=\nbegin\n  refine (thm95.profinite r r' BD \u03ba \u03ba' m \u27e8\u2124\u27e9 S V).of_iso\n    ((BD.data.system \u03ba r V r').map_iso (HomZ_iso \u27e8(Lbar.functor.{0 0} r').obj S\u27e9).symm.op) _,\n  intros c n,\n  rw \u2190 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' \u2192 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' : \u211d\u22650) [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' < 1)]\n  (\u03ba : \u2115 \u2192 \u211d\u22650) [BD.data.very_suitable r r' \u03ba] [\u2200 (i : \u2115), fact (0 < \u03ba i)] :\n  \u2200 m : \u2115,\n  \u2203 (k K : \u211d\u22650) (hk : fact (1 \u2264 k)),\n  \u2200 (\u039b : Type u) [polyhedral_lattice \u039b],\n  \u2203 c\u2080 : \u211d\u22650,\n  \u2200 (S : Type u) [fintype S],\n  \u2200 (V : SemiNormedGroup.{v}) [normed_with_aut r V],\n    by exactI system_of_complexes.is_weak_bounded_exact\n    (\u200b(BD.data.system \u03ba r V r').obj (op $ Hom \u039b (Lbar r' S))) k K m c\u2080 :=\nbegin\n  intro m,\n  let \u03ba' := package.\u03ba' BD \u03ba,\n  haveI _inst_\u03ba' : package.adept BD \u03ba \u03ba' := package.\u03ba'_adept BD \u03ba,\n  refine \u27e8(k \u03ba' m), (K r r' BD \u03ba' m), infer_instance, \u03bb \u039b _inst_\u039b, _\u27e9,\n  refine \u27e8c\u2080 r r' BD \u03ba \u03ba' m (@PolyhedralLattice.of \u039b _inst_\u039b), \u03bb S _inst_S V _inst_V, _\u27e9,\n  apply thm95'\nend\n\n/-- Theorem 9.5 in [Analytic] -/\ntheorem thm95''.profinite (BD : package)\n  (r r' : \u211d\u22650) [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' < 1)]\n  (\u03ba : \u2115 \u2192 \u211d\u22650) [BD.data.very_suitable r r' \u03ba] [\u2200 (i : \u2115), fact (0 < \u03ba i)] :\n  \u2200 m : \u2115,\n  \u2203 (k K : \u211d\u22650) (hk : fact (1 \u2264 k)),\n  \u2200 (\u039b : Type u) [polyhedral_lattice \u039b],\n  \u2203 c\u2080 : \u211d\u22650,\n  \u2200 (S : Profinite.{u}),\n  \u2200 (V : SemiNormedGroup.{v}) [normed_with_aut r V],\n    by exactI system_of_complexes.is_weak_bounded_exact\n    (\u200b(BD.data.system \u03ba r V r').obj (op $ Hom \u039b ((Lbar.functor.{u u} r').obj S))) k K m c\u2080 :=\nbegin\n  intro m,\n  let \u03ba' := package.\u03ba' BD \u03ba,\n  haveI _inst_\u03ba' : package.adept BD \u03ba \u03ba' := package.\u03ba'_adept BD \u03ba,\n  refine \u27e8(k \u03ba' m), (K r r' BD \u03ba' m), infer_instance, \u03bb \u039b _inst_\u039b, _\u27e9,\n  refine \u27e8c\u2080 r r' BD \u03ba \u03ba' m (@PolyhedralLattice.of \u039b _inst_\u039b), \u03bb S _inst_S V _inst_V, _\u27e9,\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": "import analysis.asymptotics.asymptotic_equivalent\nimport measure_theory.integral.interval_integral\nimport measure_theory.measure.vector_measure\n\nvariables {\u03b1 \u03b2 \u03b3 \u03b4 : Type*}\n\nsection is_equivalent\n\nopen_locale asymptotics\n\nexample {l : filter \u03b1} {u v w : \u03b1 \u2192 \u03b2} [normed_add_comm_group \u03b2]\n  (huv : u ~[l] v) (hvw : v ~[l] w) : u ~[l] w :=\ncalc u ~[l] v : huv\n   ... ~[l] w : hvw\n\nend is_equivalent\n\nsection interval_integral\n\nvariables {f : \u211d \u2192 \u211d} {\u03bc : measure_theory.measure \u211d}\nlocal notation u ` ~[`:50 a:50`-`:40 b `] `:0 v:50 := interval_integrable a b u v\n\nexample {a b c : \u211d} (hab : a ~[f-\u03bc] b)\n  (hbc : b ~[f-\u03bc] c) : interval_integrable f \u03bc a c :=\ncalc a ~[f-\u03bc] b : hab\n   ... ~[f-\u03bc] c : hbc\n\nend interval_integral\n\nsection vector_measure\n\nopen measure_theory measure_theory.vector_measure\n\nopen_locale measure_theory\n\nexample {u : vector_measure \u211d \u211d} {v : vector_measure \u211d \u211d} {w : vector_measure \u211d \u211d}\n  (huv : u \u226a\u1d65 v) (hvw : v \u226a\u1d65 w) : u \u226a\u1d65 w :=\ncalc u \u226a\u1d65 v : huv\n   ... \u226a\u1d65 w : hvw\n\nend vector_measure\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/calc.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802264851919, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.4843471976972091}}
{"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\u00e7ois 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 \u2192 \u03b2` is `convex_on` a set `s` if `s` is itself a convex set, and for any two\npoints `x y \u2208 s`, the segment joining `(x, f x)` to `(y, f y)` is above the graph of `f`.\nEquivalently, `convex_on \ud835\udd5c f s` means that the epigraph `{p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2}` is\na convex set.\n\n## Main declarations\n\n* `convex_on \ud835\udd5c s f`: The function `f` is convex on `s` with scalars `\ud835\udd5c`.\n* `concave_on \ud835\udd5c s f`: The function `f` is concave on `s` with scalars `\ud835\udd5c`.\n* `strict_convex_on \ud835\udd5c s f`: The function `f` is strictly convex on `s` with scalars `\ud835\udd5c`.\n* `strict_concave_on \ud835\udd5c s f`: The function `f` is strictly concave on `s` with scalars `\ud835\udd5c`.\n-/\n\nopen finset linear_map set\nopen_locale big_operators classical convex pointwise\n\nvariables {\ud835\udd5c E F \u03b2 \u03b9 : Type*}\n\nsection ordered_semiring\nvariables [ordered_semiring \ud835\udd5c]\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 \u03b2]\n\nsection has_scalar\nvariables (\ud835\udd5c) [has_scalar \ud835\udd5c E] [has_scalar \ud835\udd5c \u03b2] (s : set E) (f : E \u2192 \u03b2)\n\n/-- Convexity of functions -/\ndef convex_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y\n\n/-- Concavity of functions -/\ndef concave_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 a + b = 1 \u2192\n    a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)\n\n/-- Strict convexity of functions -/\ndef strict_convex_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y\n\n/-- Strict concavity of functions -/\ndef strict_concave_on : Prop :=\nconvex \ud835\udd5c s \u2227\n  \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    a \u2022 f x + b \u2022 f y < f (a \u2022 x + b \u2022 y)\n\nvariables {\ud835\udd5c s f}\n\nopen order_dual (to_dual of_dual)\n\nlemma convex_on.dual (hf : convex_on \ud835\udd5c s f) : concave_on \ud835\udd5c s (to_dual \u2218 f) := hf\n\nlemma concave_on.dual (hf : concave_on \ud835\udd5c s f) : convex_on \ud835\udd5c s (to_dual \u2218 f) := hf\n\nlemma strict_convex_on.dual (hf : strict_convex_on \ud835\udd5c s f) : strict_concave_on \ud835\udd5c s (to_dual \u2218 f) :=\nhf\n\nlemma strict_concave_on.dual (hf : strict_concave_on \ud835\udd5c s f) : strict_convex_on \ud835\udd5c s (to_dual \u2218 f) :=\nhf\n\nlemma convex_on_id {s : set \u03b2} (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s id := \u27e8hs, by { intros, refl }\u27e9\n\nlemma concave_on_id {s : set \u03b2} (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s id := \u27e8hs, by { intros, refl }\u27e9\n\nlemma convex_on.subset {t : set E} (hf : convex_on \ud835\udd5c t f) (hst : s \u2286 t) (hs : convex \ud835\udd5c s) :\n  convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma concave_on.subset {t : set E} (hf : concave_on \ud835\udd5c t f) (hst : s \u2286 t) (hs : convex \ud835\udd5c s) :\n  concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma strict_convex_on.subset {t : set E} (hf : strict_convex_on \ud835\udd5c t f) (hst : s \u2286 t)\n  (hs : convex \ud835\udd5c s) :\n  strict_convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nlemma strict_concave_on.subset {t : set E} (hf : strict_concave_on \ud835\udd5c t f) (hst : s \u2286 t)\n  (hs : convex \ud835\udd5c s) :\n  strict_concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb x y hx hy, hf.2 (hst hx) (hst hy)\u27e9\n\nend has_scalar\n\nsection distrib_mul_action\nvariables [has_scalar \ud835\udd5c E] [distrib_mul_action \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma convex_on.add (hf : convex_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  convex_on \ud835\udd5c s (f + g) :=\n\u27e8hf.1, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) + g (a \u2022 x + b \u2022 y) \u2264 (a \u2022 f x + b \u2022 f y) + (a \u2022 g x + b \u2022 g y)\n      : add_le_add (hf.2 hx hy ha hb hab) (hg.2 hx hy ha hb hab)\n    ... = a \u2022 (f x + g x) + b \u2022 (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]\u27e9\n\nlemma concave_on.add (hf : concave_on \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on_const (c : \u03b2) (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s (\u03bb x:E, c) :=\n\u27e8hs, \u03bb x y _ _ a b _ _ hab, (convex.combo_self hab c).ge\u27e9\n\nlemma concave_on_const (c : \u03b2) (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s (\u03bb x:E, c) :=\n@convex_on_const _ _ (order_dual \u03b2) _ _ _ _ _ _ c hs\n\nend module\n\nsection ordered_smul\nvariables [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.convex_le (hf : convex_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | f x \u2264 r} :=\n\u03bb x y hx hy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 ha hb hab\n                  ... \u2264 a \u2022 r + b \u2022 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\u27e9\n\nlemma concave_on.convex_ge (hf : concave_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | r \u2264 f x} :=\nhf.dual.convex_le r\n\nlemma convex_on.convex_epigraph (hf : convex_on \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2} :=\nbegin\n  rintro \u27e8x, r\u27e9 \u27e8y, t\u27e9 \u27e8hx, hr\u27e9 \u27e8hy, ht\u27e9 a b ha hb hab,\n  refine \u27e8hf.1 hx hy ha hb hab, _\u27e9,\n  calc f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha hb hab\n  ... \u2264 a \u2022 r + b \u2022 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 \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 p.2 \u2264 f p.1} :=\nhf.dual.convex_epigraph\n\nlemma convex_on_iff_convex_epigraph :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 \u2264 p.2} :=\n\u27e8convex_on.convex_epigraph, \u03bb h,\n  \u27e8\u03bb x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) \u27e8hx, le_rfl\u27e9 \u27e8hy, le_rfl\u27e9 a b ha hb hab).1,\n  \u03bb x y hx hy a b ha hb hab, (@h (x, f x) (y, f y) \u27e8hx, le_rfl\u27e9 \u27e8hy, le_rfl\u27e9 a b ha hb hab).2\u27e9\u27e9\n\nlemma concave_on_iff_convex_hypograph :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 p.2 \u2264 f p.1} :=\n@convex_on_iff_convex_epigraph \ud835\udd5c E (order_dual \u03b2) _ _ _ _ _ _ _ f\n\nend ordered_smul\n\nsection module\nvariables [module \ud835\udd5c E] [has_scalar \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\n/-- Right translation preserves convexity. -/\nlemma convex_on.translate_right (hf : convex_on \ud835\udd5c s f) (c : E) :\n  convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\n\u27e8hf.1.translate_preimage_right _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (c + (a \u2022 x + b \u2022 y)) = f (a \u2022 (c + x) + b \u2022 (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... \u2264 a \u2022 f (c + x) + b \u2022 f (c + y) : hf.2 hx hy ha hb hab\u27e9\n\n/-- Right translation preserves concavity. -/\nlemma concave_on.translate_right (hf : concave_on \ud835\udd5c s f) (c : E) :\n  concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves convexity. -/\nlemma convex_on.translate_left (hf : convex_on \ud835\udd5c s f) (c : E) :\n  convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c s f) (c : E) :\n  concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, z + c)) :=\nhf.dual.translate_left _\n\nend module\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2]\n\nlemma convex_on_iff_forall_pos {s : set E} {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y :=\nbegin\n  refine and_congr_right' \u27e8\u03bb h x y hx hy a b ha hb hab, h hx hy ha.le hb.le hab,\n    \u03bb h x y hx hy a b ha hb hab, _\u27e9,\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 \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y) :=\n@convex_on_iff_forall_pos \ud835\udd5c E (order_dual \u03b2) _ _ _ _ _ _ _\n\nlemma convex_on_iff_pairwise_pos {s : set E} {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n    s.pairwise (\u03bb x y, \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y) :=\nbegin\n  rw convex_on_iff_forall_pos,\n  refine and_congr_right' \u27e8\u03bb h x hx y hy _ a b ha hb hab, h hx hy ha hb hab,\n    \u03bb h x y hx hy a b ha hb hab, _\u27e9,\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 \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227\n   s.pairwise (\u03bb x y, \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1\n    \u2192 a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)) :=\n@convex_on_iff_pairwise_pos \ud835\udd5c E (order_dual \u03b2) _ _ _ _ _ _ _\n\n/-- A linear map is convex. -/\nlemma linear_map.convex_on (f : E \u2192\u2097[\ud835\udd5c] \u03b2) {s : set E} (hs : convex \ud835\udd5c s) : convex_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]\u27e9\n\n/-- A linear map is concave. -/\nlemma linear_map.concave_on (f : E \u2192\u2097[\ud835\udd5c] \u03b2) {s : set E} (hs : convex \ud835\udd5c s) : concave_on \ud835\udd5c s f :=\n\u27e8hs, \u03bb _ _ _ _ _ _ _ _ _, by rw [f.map_add, f.map_smul, f.map_smul]\u27e9\n\nlemma strict_convex_on.convex_on {s : set E} {f : E \u2192 \u03b2} (hf : strict_convex_on \ud835\udd5c s f) :\n  convex_on \ud835\udd5c s f :=\n\u27e8hf.1, \u03bb 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\u27e9\n\nlemma strict_concave_on.concave_on {s : set E} {f : E \u2192 \u03b2} (hf : strict_concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c s f :=\nhf.dual.convex_on\n\nsection ordered_smul\nvariables [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma strict_convex_on.convex_lt (hf : strict_convex_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 s | f x < r} :=\nconvex_iff_pairwise_pos.2 $ \u03bb x hx y hy hxy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 hxy ha hb hab\n                  ... \u2264 a \u2022 r + b \u2022 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\u27e9\n\nlemma strict_concave_on.convex_gt (hf : strict_concave_on \ud835\udd5c s f) (r : \u03b2) :\n  convex \ud835\udd5c {x \u2208 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 \u2192 \u03b2}\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 \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y` only for `x < y` and positive `a`,\n`b`. The main use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order.\n-/\nlemma linear_order.convex_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y) : convex_on \ud835\udd5c s f :=\nbegin\n  refine convex_on_iff_pairwise_pos.2 \u27e8hs, \u03bb x hx y hy hxy a b ha hb hab, _\u27e9,\n  wlog h : x \u2264 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 \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \u211d` however one can apply it, e.g., to `\u211d^n` with lexicographic order. -/\nlemma linear_order.concave_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n     a \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)) : concave_on \ud835\udd5c s f :=\n@linear_order.convex_on_of_lt _ _ (order_dual \u03b2) _ _ _ _ _ _ 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 \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order. -/\nlemma linear_order.strict_convex_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n    f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y) : strict_convex_on \ud835\udd5c s f :=\nbegin\n  refine \u27e8hs, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n  wlog h : x \u2264 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 \u2022 f x + b \u2022 f y \u2264 f (a \u2022 x + b \u2022 y)` for `x < y` and positive `a`, `b`. The\nmain use case is `E = \ud835\udd5c` however one can apply it, e.g., to `\ud835\udd5c^n` with lexicographic order. -/\nlemma linear_order.strict_concave_on_of_lt (hs : convex \ud835\udd5c s)\n  (hf : \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x < y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a \u2192 0 < b \u2192 a + b = 1 \u2192\n     a \u2022 f x + b \u2022 f y < f (a \u2022 x + b \u2022 y)) : strict_concave_on \ud835\udd5c s f :=\n@linear_order.strict_convex_on_of_lt _ _ (order_dual \u03b2) _ _ _ _ _ _ _ _ hs hf\n\nend linear_order\nend module\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c F] [has_scalar \ud835\udd5c \u03b2]\n\n/-- If `g` is convex on `s`, so is `(f \u2218 g)` on `f \u207b\u00b9' s` for a linear `f`. -/\nlemma convex_on.comp_linear_map {f : F \u2192 \u03b2} {s : set F} (hf : convex_on \ud835\udd5c s f) (g : E \u2192\u2097[\ud835\udd5c] F) :\n  convex_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 g) :=\n\u27e8hf.1.linear_preimage _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    f (g (a \u2022 x + b \u2022 y)) = f (a \u2022 (g x) + b \u2022 (g y)) : by rw [g.map_add, g.map_smul, g.map_smul]\n                      ... \u2264 a \u2022 f (g x) + b \u2022 f (g y) : hf.2 hx hy ha hb hab\u27e9\n\n/-- If `g` is concave on `s`, so is `(g \u2218 f)` on `f \u207b\u00b9' s` for a linear `f`. -/\nlemma concave_on.comp_linear_map {f : F \u2192 \u03b2} {s : set F} (hf : concave_on \ud835\udd5c s f) (g : E \u2192\u2097[\ud835\udd5c] F) :\n  concave_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 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 \u03b2]\n\nsection distrib_mul_action\nvariables [has_scalar \ud835\udd5c E] [distrib_mul_action \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma strict_convex_on.add (hf : strict_convex_on \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f + g) :=\n\u27e8hf.1, \u03bb x y hx hy hxy a b ha hb hab,\n  calc\n    f (a \u2022 x + b \u2022 y) + g (a \u2022 x + b \u2022 y) < (a \u2022 f x + b \u2022 f y) + (a \u2022 g x + b \u2022 g y)\n      : add_lt_add (hf.2 hx hy hxy ha hb hab) (hg.2 hx hy hxy ha hb hab)\n    ... = a \u2022 (f x + g x) + b \u2022 (f y + g y) : by rw [smul_add, smul_add, add_add_add_comm]\u27e9\n\nlemma strict_concave_on.add (hf : strict_concave_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n  strict_concave_on \ud835\udd5c s (f + g) :=\nhf.dual.add hg\n\nend distrib_mul_action\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.convex_lt (hf : convex_on \ud835\udd5c s f) (r : \u03b2) : convex \ud835\udd5c {x \u2208 s | f x < r} :=\nconvex_iff_forall_pos.2 $ \u03bb x y hx hy a b ha hb hab, \u27e8hf.1 hx.1 hy.1 ha.le hb.le hab,\n  calc\n    f (a \u2022 x + b \u2022 y)\n        \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx.1 hy.1 ha.le hb.le hab\n    ... < a \u2022 r + b \u2022 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 _\u27e9\n\nlemma concave_on.convex_gt (hf : concave_on \ud835\udd5c s f) (r : \u03b2) : convex \ud835\udd5c {x \u2208 s | r < f x} :=\nhf.dual.convex_lt r\n\nlemma convex_on.convex_strict_epigraph (hf : convex_on \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 f p.1 < p.2} :=\nbegin\n  rw convex_iff_forall_pos,\n  rintro \u27e8x, r\u27e9 \u27e8y, t\u27e9 \u27e8hx, hr\u27e9 \u27e8hy, ht\u27e9 a b ha hb hab,\n  refine \u27e8hf.1 hx hy ha.le hb.le hab, _\u27e9,\n  calc f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha.le hb.le hab\n  ... < a \u2022 r + b \u2022 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 \ud835\udd5c s f) :\n  convex \ud835\udd5c {p : E \u00d7 \u03b2 | p.1 \u2208 s \u2227 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 \u03b2] [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2]\n  {s : set E} {f g : E \u2192 \u03b2}\n\n/-- The pointwise maximum of convex functions is convex. -/\nlemma convex_on.sup (hf : convex_on \ud835\udd5c s f) (hg : convex_on \ud835\udd5c s g) :\n  convex_on \ud835\udd5c s (f \u2294 g) :=\nbegin\n  refine \u27e8hf.left, \u03bb x y hx hy a b ha hb hab, sup_le _ _\u27e9,\n  { calc f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.right hx hy ha hb hab\n     ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \u2022 x + b \u2022 y) \u2264 a \u2022 g x + b \u2022 g y : hg.right hx hy ha hb hab\n     ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \ud835\udd5c s f) (hg : concave_on \ud835\udd5c s g) :\n  concave_on \ud835\udd5c s (f \u2293 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 \ud835\udd5c s f) (hg : strict_convex_on \ud835\udd5c s g) :\n  strict_convex_on \ud835\udd5c s (f \u2294 g) :=\n\u27e8hf.left, \u03bb x y hx hy hxy a b ha hb hab, max_lt\n  (calc f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx hy hxy ha hb hab\n    ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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 \u2022 x + b \u2022 y) < a \u2022 g x + b \u2022 g y : hg.2 hx hy hxy ha hb hab\n    ...                   \u2264 a \u2022 (f x \u2294 g x) + b \u2022 (f y \u2294 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))\u27e9\n\n/-- The pointwise minimum of strictly concave functions is strictly concave. -/\nlemma strict_concave_on.inf (hf : strict_concave_on \ud835\udd5c s f) (hg : strict_concave_on \ud835\udd5c s g) :\n   strict_concave_on \ud835\udd5c s (f \u2293 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 \u2264 a) (hb : 0 \u2264 b) (hab : a + b = 1) :\n  f (a \u2022 x + b \u2022 y) \u2264 max (f x) (f y) :=\ncalc\n  f (a \u2022 x + b \u2022 y) \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha hb hab\n  ... \u2264 a \u2022 max (f x) (f y) + b \u2022 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 \u2264 a) (hb : 0 \u2264 b) (hab : a + b = 1) :\n  min (f x) (f y) \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  (hz : z \u2208 [x -[\ud835\udd5c] y]) :\n  f z \u2264 max (f x) (f y) :=\nlet \u27e8a, b, ha, hb, hab, hz\u27e9 := hz in hz \u25b8 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  (hz : z \u2208 [x -[\ud835\udd5c] y]) :\n  min (f x) (f y) \u2264 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  f (a \u2022 x + b \u2022 y) < max (f x) (f y) :=\ncalc\n  f (a \u2022 x + b \u2022 y) < a \u2022 f x + b \u2022 f y : hf.2 hx hy hxy ha hb hab\n  ... \u2264 a \u2022 max (f x) (f y) + b \u2022 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1) :\n  min (f x) (f y) < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) (hz : z \u2208 open_segment \ud835\udd5c x y) :\n  f z < max (f x) (f y) :=\nlet \u27e8a, b, ha, hb, hab, hz\u27e9 := hz in hz \u25b8 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hxy : x \u2260 y) (hz : z \u2208 open_segment \ud835\udd5c 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 \u03b2]\n\nsection ordered_smul\nvariables [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\nlemma convex_on.le_left_of_right_le' (hf : convex_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 \u2264 b) (hab : a + b = 1) (hfy : f y \u2264 f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) \u2264 f x :=\nle_of_not_lt $ \u03bb h, lt_irrefl (f (a \u2022 x + b \u2022 y)) $\n  calc\n    f (a \u2022 x + b \u2022 y)\n        \u2264 a \u2022 f x + b \u2022 f y : hf.2 hx hy ha.le hb hab\n    ... < a \u2022 f (a \u2022 x + b \u2022 y) + b \u2022 f (a \u2022 x + b \u2022 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 \u2022 x + b \u2022 y) : convex.combo_self hab _\n\nlemma concave_on.left_le_of_le_right' (hf : concave_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s) (hy : y \u2208 s)\n  {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 \u2264 b) (hab : a + b = 1) (hfy : f (a \u2022 x + b \u2022 y) \u2264 f y) :\n  f x \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 \u2264 a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x \u2264 f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) \u2264 f y :=\nbegin\n  rw add_comm at \u22a2 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 \u2264 a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a \u2022 x + b \u2022 y) \u2264 f x) :\n  f y \u2264 f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f y \u2264 f z) :\n  f z \u2264 f x :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f z \u2264 f y) :\n  f x \u2264 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f x \u2264 f z) :\n  f z \u2264 f y :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f z \u2264 f x) :\n  f y \u2264 f z :=\nhf.dual.le_right_of_left_le hx hy hz hxz\n\nend ordered_smul\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f g : E \u2192 \u03b2}\n\n/- The following lemmas don't require `module \ud835\udd5c E` if you add the hypothesis `x \u2260 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 \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f y < f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) < f x :=\nnot_le.1 $ \u03bb h, lt_irrefl (f (a \u2022 x + b \u2022 y)) $\n  calc\n    f (a \u2022 x + b \u2022 y)\n        < a \u2022 f x + b \u2022 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 \u2022 f (a \u2022 x + b \u2022 y) + b \u2022 f (a \u2022 x + b \u2022 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 \u2022 x + b \u2022 y) : convex.combo_self hab _\n\nlemma strict_concave_on.left_lt_of_lt_right' (hf : strict_concave_on \ud835\udd5c s f) {x y : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) {a b : \ud835\udd5c} (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfy : f (a \u2022 x + b \u2022 y) < f y) :\n  f x < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f x < f (a \u2022 x + b \u2022 y)) :\n  f (a \u2022 x + b \u2022 y) < f y :=\nbegin\n  rw add_comm at \u22a2 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 \ud835\udd5c s f) {x y : E} {a b : \ud835\udd5c}\n  (hx : x \u2208 s) (hy : y \u2208 s) (ha : 0 < a) (hb : 0 < b) (hab : a + b = 1)\n  (hfx : f (a \u2022 x + b \u2022 y) < f x) :\n  f y < f (a \u2022 x + b \u2022 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hyz : f y < f z) :\n  f z < f x :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c x y) (hxz : f x < f z) :\n  f z < f y :=\nbegin\n  obtain \u27e8a, b, ha, hb, hab, rfl\u27e9 := 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 \ud835\udd5c s f) {x y z : E} (hx : x \u2208 s)\n  (hy : y \u2208 s) (hz : z \u2208 open_segment \ud835\udd5c 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 \u03b2] [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\n/-- A function `-f` is convex iff `f` is concave. -/\n@[simp] lemma neg_convex_on_iff : convex_on \ud835\udd5c s (-f) \u2194 concave_on \ud835\udd5c s f :=\nbegin\n  split,\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy a b ha hb hab, _\u27e9,\n    simp [neg_apply, neg_le, add_comm] at h,\n    exact h hx hy ha hb hab },\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy a b ha hb hab, _\u27e9,\n    rw \u2190neg_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 \ud835\udd5c s (-f) \u2194 convex_on \ud835\udd5c s f:=\nby rw [\u2190 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 \ud835\udd5c s (-f) \u2194 strict_concave_on \ud835\udd5c s f :=\nbegin\n  split,\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n    simp [neg_apply, neg_lt, add_comm] at h,\n    exact h hx hy hxy ha hb hab },\n  { rintro \u27e8hconv, h\u27e9,\n    refine \u27e8hconv, \u03bb x y hx hy hxy a b ha hb hab, _\u27e9,\n    rw \u2190neg_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 \ud835\udd5c s (-f) \u2194 strict_convex_on \ud835\udd5c s f :=\nby rw [\u2190 neg_strict_convex_on_iff, neg_neg f]\n\nalias neg_convex_on_iff \u2194 _ concave_on.neg\nalias neg_concave_on_iff \u2194 _ convex_on.neg\nalias neg_strict_convex_on_iff \u2194 _ strict_concave_on.neg\nalias neg_strict_concave_on_iff \u2194 _ 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 \u03b2] [module \ud835\udd5c E] [has_scalar \ud835\udd5c \u03b2]\n  {s : set E} {f : E \u2192 \u03b2}\n\n/-- Right translation preserves strict convexity. -/\nlemma strict_convex_on.translate_right (hf : strict_convex_on \ud835\udd5c s f) (c : E) :\n  strict_convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\n\u27e8hf.1.translate_preimage_right _, \u03bb x y hx hy hxy a b ha hb hab,\n  calc\n    f (c + (a \u2022 x + b \u2022 y)) = f (a \u2022 (c + x) + b \u2022 (c + y))\n        : by rw [smul_add, smul_add, add_add_add_comm, convex.combo_self hab]\n    ... < a \u2022 f (c + x) + b \u2022 f (c + y) : hf.2 hx hy ((add_right_injective c).ne hxy) ha hb hab\u27e9\n\n/-- Right translation preserves strict concavity. -/\nlemma strict_concave_on.translate_right (hf : strict_concave_on \ud835\udd5c s f) (c : E) :\n  strict_concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb z, c + z)) :=\nhf.dual.translate_right _\n\n/-- Left translation preserves strict convexity. -/\nlemma strict_convex_on.translate_left (hf : strict_convex_on \ud835\udd5c s f) (c : E) :\n  strict_convex_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c s f) (c : E) :\n  strict_concave_on \ud835\udd5c ((\u03bb z, c + z) \u207b\u00b9' s) (f \u2218 (\u03bb 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 \ud835\udd5c] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection module\nvariables [has_scalar \ud835\udd5c E] [module \ud835\udd5c \u03b2] [ordered_smul \ud835\udd5c \u03b2] {s : set E} {f : E \u2192 \u03b2}\n\nlemma convex_on.smul {c : \ud835\udd5c} (hc : 0 \u2264 c) (hf : convex_on \ud835\udd5c s f) : convex_on \ud835\udd5c s (\u03bb x, c \u2022 f x) :=\n\u27e8hf.1, \u03bb x y hx hy a b ha hb hab,\n  calc\n    c \u2022 f (a \u2022 x + b \u2022 y) \u2264 c \u2022 (a \u2022 f x + b \u2022 f y)\n      : smul_le_smul_of_nonneg (hf.2 hx hy ha hb hab) hc\n    ... = a \u2022 (c \u2022 f x) + b \u2022 (c \u2022 f y)\n      : by rw [smul_add, smul_comm c, smul_comm c]; apply_instance\u27e9\n\nlemma concave_on.smul {c : \ud835\udd5c} (hc : 0 \u2264 c) (hf : concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c s (\u03bb x, c \u2022 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 \ud835\udd5c] [add_comm_group E] [add_comm_group F]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection module\nvariables [module \ud835\udd5c E] [module \ud835\udd5c F] [has_scalar \ud835\udd5c \u03b2]\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 \u2192 \u03b2} (g : E \u2192\u1d43[\ud835\udd5c] F) {s : set F} (hf : convex_on \ud835\udd5c s f) :\n  convex_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 g) :=\n\u27e8hf.1.affine_preimage _, \u03bb x y hx hy a b ha hb hab,\n  calc\n    (f \u2218 g) (a \u2022 x + b \u2022 y) = f (g (a \u2022 x + b \u2022 y))         : rfl\n                       ...  = f (a \u2022 (g x) + b \u2022 (g y))     : by rw [convex.combo_affine_apply hab]\n                       ...  \u2264 a \u2022 f (g x) + b \u2022 f (g y)     : hf.2 hx hy ha hb hab\u27e9\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 \u2192 \u03b2} (g : E \u2192\u1d43[\ud835\udd5c] F) {s : set F} (hf : concave_on \ud835\udd5c s f) :\n  concave_on \ud835\udd5c (g \u207b\u00b9' s) (f \u2218 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 \ud835\udd5c] [add_comm_monoid E]\n\nsection ordered_add_comm_monoid\nvariables [ordered_add_comm_monoid \u03b2]\n\nsection has_scalar\nvariables [has_scalar \ud835\udd5c E] [has_scalar \ud835\udd5c \u03b2] {s : set E}\n\nlemma convex_on_iff_div {f : E \u2192 \u03b2} :\n  convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b \u2192 0 < a + b\n  \u2192 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) \u2264 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y :=\nand_congr iff.rfl\n\u27e8begin\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 [\u2190add_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\u27e9\n\nlemma concave_on_iff_div {f : E \u2192 \u03b2} :\n  concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 \u2264 a \u2192 0 \u2264 b\n  \u2192 0 < a + b \u2192 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y \u2264 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) :=\n@convex_on_iff_div _ _ (order_dual \u03b2) _ _ _ _ _ _ _\n\nlemma strict_convex_on_iff_div {f : E \u2192 \u03b2} :\n  strict_convex_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a\n    \u2192 0 < b \u2192 f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) < (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y :=\nand_congr iff.rfl\n\u27e8begin\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 [\u2190add_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\u27e9\n\nlemma strict_concave_on_iff_div {f : E \u2192 \u03b2} :\n  strict_concave_on \ud835\udd5c s f \u2194 convex \ud835\udd5c s \u2227 \u2200 \u2983x y : E\u2984, x \u2208 s \u2192 y \u2208 s \u2192 x \u2260 y \u2192 \u2200 \u2983a b : \ud835\udd5c\u2984, 0 < a\n    \u2192 0 < b \u2192 (a/(a+b)) \u2022 f x + (b/(a+b)) \u2022 f y < f ((a/(a+b)) \u2022 x + (b/(a+b)) \u2022 y) :=\n@strict_convex_on_iff_div _ _ (order_dual \u03b2) _ _ _ _ _ _ _\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 `\u03b1 : F \u2245 G`, then `a.app X : F.obj X \u2245 G.obj X`,\nand building natural isomorphisms from components:\n*\n```\nnat_iso.of_components\n  (app : \u2200 X : C, F.obj X \u2245 G.obj X)\n  (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), F.map f \u226b (app Y).hom = (app X).hom \u226b G.map f) :\nF \u2245 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\u2081 v\u2082 v\u2083 v\u2084 u\u2081 u\u2082 u\u2083 u\u2084\n\nnamespace category_theory\nopen nat_trans\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} D]\n  {E : Type u\u2083} [category.{v\u2083} 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 `\u03b1.app` -/\n@[simps] def app {F G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : F.obj X \u2245 G.obj X :=\n{ hom := \u03b1.hom.app X,\n  inv := \u03b1.inv.app X,\n  hom_inv_id' := begin rw [\u2190 comp_app, iso.hom_inv_id], refl end,\n  inv_hom_id' := begin rw [\u2190 comp_app, iso.inv_hom_id], refl end }\n\n@[simp, reassoc]\nlemma hom_inv_id_app {F G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) :\n  \u03b1.hom.app X \u226b \u03b1.inv.app X = \ud835\udfd9 (F.obj X) :=\ncongr_fun (congr_arg nat_trans.app \u03b1.hom_inv_id) X\n\n@[simp, reassoc]\nlemma inv_hom_id_app {F G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) :\n  \u03b1.inv.app X \u226b \u03b1.hom.app X = \ud835\udfd9 (G.obj X) :=\ncongr_fun (congr_arg nat_trans.app \u03b1.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 \u2964 D} (\u03b1 : F \u2245 G) (\u03b2 : G \u2245 H) (X : C) :\n  (\u03b1 \u226a\u226b \u03b2).app X = \u03b1.app X \u226a\u226b \u03b2.app X := rfl\n\nlemma app_hom {F G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : (\u03b1.app X).hom = \u03b1.hom.app X := rfl\nlemma app_inv {F G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : (\u03b1.app X).inv = \u03b1.inv.app X := rfl\n\nvariables {F G : C \u2964 D}\n\ninstance hom_app_is_iso (\u03b1 : F \u2245 G) (X : C) : is_iso (\u03b1.hom.app X) :=\n\u27e8\u27e8\u03b1.inv.app X,\n  \u27e8by rw [\u2190comp_app, iso.hom_inv_id, \u2190id_app], by rw [\u2190comp_app, iso.inv_hom_id, \u2190id_app]\u27e9\u27e9\u27e9\n\ninstance inv_app_is_iso (\u03b1 : F \u2245 G) (X : C) : is_iso (\u03b1.inv.app X) :=\n\u27e8\u27e8\u03b1.hom.app X,\n  \u27e8by rw [\u2190comp_app, iso.inv_hom_id, \u2190id_app], by rw [\u2190comp_app, iso.hom_inv_id, \u2190id_app]\u27e9\u27e9\u27e9\n\nsection\n/-!\nUnfortunately we need a separate set of cancellation lemmas for components of natural isomorphisms,\nbecause the `simp` normal form is `\u03b1.hom.app X`, rather than `\u03b1.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 (\u03b1 : F \u2245 G)\n\n@[simp] lemma cancel_nat_iso_hom_left {X : C} {Z : D} (g g' : G.obj X \u27f6 Z) :\n  \u03b1.hom.app X \u226b g = \u03b1.hom.app X \u226b g' \u2194 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 \u27f6 Z) :\n  \u03b1.inv.app X \u226b g = \u03b1.inv.app X \u226b g' \u2194 g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_nat_iso_hom_right {X : D} {Y : C} (f f' : X \u27f6 F.obj Y) :\n  f \u226b \u03b1.hom.app Y = f' \u226b \u03b1.hom.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_nat_iso_inv_right {X : D} {Y : C} (f f' : X \u27f6 G.obj Y) :\n  f \u226b \u03b1.inv.app Y = f' \u226b \u03b1.inv.app Y \u2194 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 \u27f6 X) (g : X \u27f6 F.obj Y) (f' : W \u27f6 X') (g' : X' \u27f6 F.obj Y)  :\n  f \u226b g \u226b \u03b1.hom.app Y = f' \u226b g' \u226b \u03b1.hom.app Y \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_nat_iso_inv_right_assoc {W X X' : D} {Y : C}\n  (f : W \u27f6 X) (g : X \u27f6 G.obj Y) (f' : W \u27f6 X') (g' : X' \u27f6 G.obj Y)  :\n  f \u226b g \u226b \u03b1.inv.app Y = f' \u226b g' \u226b \u03b1.inv.app Y \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\nend\n\nvariables {X Y : C}\nlemma naturality_1 (\u03b1 : F \u2245 G) (f : X \u27f6 Y) :\n  (\u03b1.inv.app X) \u226b (F.map f) \u226b (\u03b1.hom.app Y) = G.map f :=\nby rw [naturality, \u2190category.assoc, \u2190nat_trans.comp_app, \u03b1.inv_hom_id, id_app, category.id_comp]\nlemma naturality_2 (\u03b1 : F \u2245 G) (f : X \u27f6 Y) :\n  (\u03b1.hom.app X) \u226b (G.map f) \u226b (\u03b1.inv.app Y) = F.map f :=\nby rw [naturality, \u2190category.assoc, \u2190nat_trans.comp_app, \u03b1.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 (\u03b1 : F \u27f6 G) [is_iso \u03b1] (X) : is_iso (\u03b1.app X) :=\n\u27e8\u27e8(inv \u03b1).app X,\n  \u27e8congr_fun (congr_arg nat_trans.app (is_iso.hom_inv_id \u03b1)) X,\n   congr_fun (congr_arg nat_trans.app (is_iso.inv_hom_id \u03b1)) X\u27e9\u27e9\u27e9\n\n@[simp] lemma is_iso_inv_app (\u03b1 : F \u27f6 G) [is_iso \u03b1] (X) : (inv \u03b1).app X = inv (\u03b1.app X) :=\nby { ext, rw \u2190nat_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 : \u2200 X : C, F.obj X \u2245 G.obj X)\n  (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), F.map f \u226b (app Y).hom = (app X).hom \u226b G.map f) :\n  F \u2245 G :=\n{ hom := { app := \u03bb X, (app X).hom },\n  inv :=\n  { app := \u03bb X, (app X).inv,\n    naturality' := \u03bb X Y f,\n    begin\n      have h := congr_arg (\u03bb f, (app X).inv \u226b (f \u226b (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' : \u2200 X : C, F.obj X \u2245 G.obj X) (naturality) (X) :\n  (of_components app' naturality).app X = app' X :=\nby tidy\n@[simp] lemma of_components.hom_app (app : \u2200 X : C, F.obj X \u2245 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 : \u2200 X : C, F.obj X \u2245 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 (\u03b1 : F \u27f6 G) [\u2200 X : C, is_iso (\u03b1.app X)] : is_iso \u03b1 :=\n\u27e8(is_iso.of_iso (of_components (\u03bb X, as_iso (\u03b1.app X)) (by tidy))).1\u27e9\n\n/-- Horizontal composition of natural isomorphisms. -/\ndef hcomp {F G : C \u2964 D} {H I : D \u2964 E} (\u03b1 : F \u2245 G) (\u03b2 : H \u2245 I) : F \u22d9 H \u2245 G \u22d9 I :=\nbegin\n  refine \u27e8\u03b1.hom \u25eb \u03b2.hom, \u03b1.inv \u25eb \u03b2.inv, _, _\u27e9,\n  { ext, rw [\u2190nat_trans.exchange], simp, refl },\n  ext, rw [\u2190nat_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 \u2192 Q) \u2192 ((Q \u2192 R) \u2192 (P \u2192 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 {\u03b1 : Type u}\n\nopen color nat\n\ninductive is_node_of : rbnode \u03b1 \u2192 rbnode \u03b1 \u2192 \u03b1 \u2192 rbnode \u03b1 \u2192 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) : option \u03b1 \u2192 option \u03b1 \u2192 Prop\n| (some a) (some b) := lt a b\n| _         _       := true\n\ninductive is_searchable (lt : \u03b1 \u2192 \u03b1 \u2192 Prop) : rbnode \u03b1 \u2192 option \u03b1 \u2192 option \u03b1 \u2192 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\u2081 : is_searchable l lo (some v)) (hs\u2082 : 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\u2081 : is_searchable l lo (some v)) (hs\u2082 : 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 : \u03b1 \u2192 \u03b1 \u2192 Prop}\n\nlemma lo_lt_hi {t : rbnode \u03b1} {lt} [is_trans \u03b1 lt] :\n  \u2200 {lo hi}, is_searchable lt t lo hi \u2192 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\u2081 := t_ih_lchild hs_hs\u2081,\n    have h\u2082 := t_ih_rchild hs_hs\u2082,\n    cases lo; cases hi; simp [lift] at *,\n    apply trans_of lt h\u2081 h\u2082, }\nend\n\nlemma is_searchable_of_is_searchable_of_incomp [is_strict_weak_order \u03b1 lt] {t} :\n  \u2200 {lo hi hi'} (hc : \u00ac lt hi' hi \u2227 \u00ac 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 \u27e8hc.2, hc.1\u27e9 },\n  all_goals { apply t_ih_rchild hc hs_hs\u2082 }\nend\n\nlemma is_searchable_of_incomp_of_is_searchable [is_strict_weak_order \u03b1 lt] {t} :\n  \u2200 {lo lo' hi} (hc : \u00ac lt lo' lo \u2227 \u00ac 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\u2081 }\nend\n\nlemma is_searchable_some_low_of_is_searchable_of_lt {t} [is_trans \u03b1 lt] :\n  \u2200 {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\u2081 }\nend\n\nlemma is_searchable_none_low_of_is_searchable_some_low {t} :\n  \u2200 {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\u2081 }\nend\n\nlemma is_searchable_some_high_of_is_searchable_of_lt {t} [is_trans \u03b1 lt] :\n  \u2200 {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\u2082 }\nend\n\nlemma is_searchable_none_high_of_is_searchable_some_high {t} :\n  \u2200 {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\u2082 }\nend\n\nlemma range [is_strict_weak_order \u03b1 lt] {t : rbnode \u03b1} {x} :\n  \u2200 {lo hi}, is_searchable lt t lo hi \u2192 mem lt x t \u2192 lift lt lo (some x) \u2227 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\u2081 h\u2082, cases h\u2081,\n    simp only [mem] at h\u2082,\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\u2083 : lift lt lo (some x) \u2227 lift lt (some x) (some t_val),\n      { apply t_ih_lchild, assumption, assumption },\n      cases h\u2083 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\u2082,\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\u2083 : lift lt (some t_val) (some x) \u2227 lift lt (some x) hi,\n      { apply t_ih_rchild, assumption, assumption },\n      cases h\u2083 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 \u03b1 lt] {y : \u03b1} {t l r : rbnode \u03b1} :\n  \u2200 {lo hi}, is_searchable lt t lo hi \u2192 is_node_of t l y r \u2192 \u2200 {x}, mem lt x l \u2192 lt x y :=\nbegin\n intros _ _ hs hn x hm, cases hn; cases hs,\n all_goals { exact (range hs_hs\u2081 hm).2 }\nend\n\nlemma lt_of_mem_right [is_strict_weak_order \u03b1 lt] {y : \u03b1} {t l r : rbnode \u03b1} :\n  \u2200 {lo hi}, is_searchable lt t lo hi \u2192 is_node_of t l y r \u2192 \u2200 {z}, mem lt z r \u2192 lt y z :=\nbegin\n intros _ _ hs hn z hm, cases hn; cases hs,\n all_goals { exact (range hs_hs\u2082 hm).1 }\nend\n\n\n\nend is_searchable_lemmas\n\ninductive is_red_black : rbnode \u03b1 \u2192 color \u2192 nat \u2192 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\u2081 c\u2082} (rb_l : is_red_black l c\u2081 n) (rb_r : is_red_black r c\u2082 n) :\n  is_red_black (black_node l v r) black (succ n)\n\nopen is_red_black\n\nlemma depth_min : \u2200 {c n} {t : rbnode \u03b1}, is_red_black t c n \u2192 n \u2264 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) \u2265 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 \u2192 nat \u2192 nat\n| red   n := 2*n + 1\n| black n := 2*n\n\nprivate lemma upper_le : \u2200 c n, upper c n \u2264 2 * n + 1\n| red n   := by exact le_refl _\n| black n := by apply le_succ\n\nlemma depth_max' : \u2200 {c n} {t : rbnode \u03b1}, is_red_black t c n \u2192 depth max t \u2264 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)) \u2264 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 \u2264 2*h_n + 1, from le_trans h_ih_rb_l (upper_le _ _),\n    have : depth max h_r \u2264 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 \u2264 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 \u03b1} (h : is_red_black t c n) : depth max t \u2264 2 * n + 1:=\nle_trans (depth_max' h) (upper_le _ _)\n\nlemma balanced {c n} {t : rbnode \u03b1} (h : is_red_black t c n) : depth max t \u2264 2 * depth min t + 1 :=\nbegin\n  have : 2 * depth min t + 1 \u2265 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 := \u2203 n : \u2115, r^(nat.succ n) = 0\n\ndef nilradical_set (R : Type u) [comm_ring R] : set R := \u03bb n, nilpotent n\n\nlemma prime_ideal_power_mem (R : Type u) [comm_ring R] (p : Spec R) : \n  \u2200 {r : R} {n : \u2115}, r^n.succ \u2208 p.body \u2192 r \u2208 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  := \u22c2\u2080 (image (\u03bb p : Spec R, p) (@univ (Spec R)))\n\nlemma nilpotents_in_all_prime_ideals {R : Type u} [comm_ring R] : \u2200 {x : R} (p : Spec R), \n  nilpotent x \u2192 x \u2208 p.body :=\nbegin\n  intros x p hx,\n  cases hx with n hx,\n  have h : x^n.succ \u2208 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] : \u2200 {f : R}, \u00ac(nilpotent f) \u2192 f \u2260 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 : \u00ac (nilpotent f))\n  : set (ideal R) := \u03bb I : ideal R, \u2200 n : \u2115, f^n.succ \u2209 I.body\n\n\nprivate lemma no_pows_of_f_implies_proper {hf : \u00ac (nilpotent f)} {I : ideal R} \n  : no_pows_of_f hf I \u2192 is_proper I :=\nbegin\n  intro hraw,\n  have hf : f \u2209 \u2191I,\n    have trv : f^1 = f := power_of_one f,\n    rw \u2190 trv,\n    apply hraw,\n  intro ab\u2081,\n  rw ab\u2081 at hf,\n  apply hf,\n  trivial,\nend\n\nprivate def cvrt {hf : \u00ac (nilpotent f)} : subtype (no_pows_of_f hf) \u2192 proper_ideal R \n| \u27e8I,hI\u27e9 := ideal_to_proper (no_pows_of_f_implies_proper hI)\n\nprivate def helper_le (hf : \u00ac (nilpotent f)) \n  : subtype (no_pows_of_f hf) \u2192 subtype (no_pows_of_f hf) \u2192 Prop \n| J\u2081 J\u2082:= J\u2081.val.body \u2286 J\u2082.val.body\n\nprivate def no_pows_of_f_has_le (hf : \u00ac (nilpotent f)) : has_le (subtype (no_pows_of_f hf))\n := \u27e8helper_le hf\u27e9\n\nlocal attribute [instance] no_pows_of_f_has_le\n\nprivate lemma cvrt_body_eq {hf : \u00ac (nilpotent f)} : \u2200 J : subtype (no_pows_of_f hf), (cvrt J).body = J.val.body\n  | \u27e8I,hI\u27e9 := rfl\n\nprivate lemma cvrt_equal {hf : \u00ac (nilpotent f)} :  \n  \u2200 J\u2081 J\u2082 : subtype (no_pows_of_f hf), J\u2081 = J\u2082 \u2194 cvrt J\u2081 = cvrt J\u2082 :=\nbegin\n  intros J\u2081 J\u2082,\n  split,\n  intro h,\n  rw h,\n  intro h,\n  apply val_injective,\n  apply ideal_equality,\n  simp [\u2190 cvrt_body_eq],\n  rw h,\nend\n\nprivate lemma cvrt_le {hf : \u00ac (nilpotent f)} :  \n  \u2200 J\u2081 J\u2082 : subtype (no_pows_of_f hf), J\u2081 \u2264 J\u2082 \u2194 cvrt J\u2081 \u2264 cvrt J\u2082 :=\nbegin\n  intros J\u2081 J\u2082,\n  split,\n  intro h,\n  suffices h\u2081 : (cvrt J\u2081).body \u2286 (cvrt J\u2082).body,\n  exact h\u2081,\n  rw cvrt_body_eq,\n  rw cvrt_body_eq,\n  exact h,\n  intro h,\n  have process : (cvrt J\u2081).body \u2286 (cvrt J\u2082).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 : \u00ac (nilpotent f)} \n  : \u2200 J : subtype (no_pows_of_f hf), J \u2264 J :=\nbegin\n  intro J,\n  rw cvrt_le,\n  exact le_refl (cvrt J),\nend\n\nprivate lemma helper_le_trans {hf : \u00ac (nilpotent f)} \n  : \u2200 J\u2081 J\u2082 J\u2083 : subtype (no_pows_of_f hf), (J\u2081 \u2264 J\u2082) \u2192 (J\u2082 \u2264 J\u2083) \u2192 (J\u2081 \u2264 J\u2083) :=\nbegin\n  intros J\u2081 J\u2082 J\u2083,\n  simp [cvrt_le],\n  exact le_trans,\nend\n\nprivate lemma helper_le_anti_symm {hf : \u00ac (nilpotent f)} \n  : \u2200 J\u2081 J\u2082 : subtype (no_pows_of_f hf), J\u2081 \u2264 J\u2082 \u2192 J\u2082 \u2264 J\u2081 \u2192 J\u2081 = J\u2082 :=\nbegin\n  intros J\u2081 J\u2082,\n  simp [cvrt_equal,cvrt_le],\n  exact le_antisymm,\nend\n\nprivate def no_pows_of_f_poset {hf : \u00ac (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 : \u00ac(nilpotent f)} {s : set (subtype (no_pows_of_f hf))} : is_chain s \u2192 is_chain (image cvrt s) :=\nbegin\n  intros hs x y hxy,\n  cases hxy with hx hy,\n  cases hx with x\u2080 hx\u2080,\n  cases hx\u2080 with hx\u2080ins hx\u2080rw,\n  cases hy with y\u2080 hy\u2080,\n  cases hy\u2080 with hy\u2080ins hy\u2080rw,\n  simp [\u2190 hx\u2080rw, \u2190 hy\u2080rw, \u2190cvrt_le],\n  apply hs,\n  exact \u27e8hx\u2080ins,hy\u2080ins\u27e9, \nend\n\nprivate def chain_upper_bound {hf : \u00ac(nilpotent f)} {s : set (subtype (no_pows_of_f hf))} (hs : is_chain s) (ns : s \u2260 \u2205) : 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 : \u00ac(nilpotent f)} {s : set (subtype (no_pows_of_f hf))} (hs : is_chain s) (ns : s \u2260 \u2205) \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 \u2190 hIrw at hfninA,\n  rw \u2190 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 : \u00ac(nilpotent f)} {C : set (subtype (no_pows_of_f hf))} (hC : is_chain C) (nC : C \u2260 \u2205)\n  : bounds_subset C \u27e8(chain_upper_bound hC nC), no_pow_of_f_chain_upper_bound hC nC\u27e9 :=\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 \u27e8hJ,rfl\u27e9,\n  refl,\n  assumption,\nend\n\nprivate def zero_ideal_no_f (hf : \u00ac(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 : \u00ac(nilpotent f)} {J : subtype (no_pows_of_f hf)} \n  : maximal_element J \u2192 \u2200 {x} , x \u2209 J.val.body \u2192 \u2203 n : \u2115, f^n.succ \u2208 (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 \u2260 J,\n    intro ab,\n    apply ideal_extension_proper hx,\n    rw \u2190 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 : \u00ac(nilpotent f)} {J : subtype (no_pows_of_f hf)} \n  : maximal_element J \u2192 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) \u2208 (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 : \u00ac(nilpotent f)) : \u2203 p : Spec R, f \u2209 p.body := \nbegin\n  have hmaxnof : \u2203 J : subtype (no_pows_of_f hf) , maximal_element J,\n    apply zorns_lemma,\n    intros C hC,\n    by_cases C = \u2205,\n    existsi zero_ideal_no_f hf,\n    intros x hx,\n    rw h at hx,\n    exact false.elim hx,\n    existsi (\u27e8(chain_upper_bound hC h), no_pow_of_f_chain_upper_bound hC h\u27e9 : 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] : \u2191(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 \u2191p,\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\u2081,\n  cases hI with p hp,\n  cases hp with trv hrw\u2082,\n  simp at hrw\u2081,\n  simp at hrw\u2082,\n  rw [\u2190 hrw\u2081,\u2190 hrw\u2082],\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/\u1d63I))\n\nprefix `\u221a` : 40 := radical\n\nlemma elements_of_radical {R : Type u} [comm_ring R] (I:ideal R) \n  : \u2200 x : R, x \u2208 (\u221aI).body \u2194 \u2203 n : \u2115, x^n.succ \u2208 I.body :=\nbegin\n  intro x,\n  split,\n  intro hx,\n  have trv\u2081 : quot_ring_hom I x \u2208 \u2191(nilradical (R/\u1d63I)) := hx,\n  rw nilradical_intersection_of_prime_ideals (R/\u1d63I) at trv\u2081,\n  cases trv\u2081 with n hn,\n  existsi n,\n  apply quotient_zero_implies_in_ideal,\n  simp,\n  rw \u2190 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 \u2208 \u2191(nilradical (R/\u1d63I)),\n    rw nilradical_intersection_of_prime_ideals,\n    have hint\u2081 : nilpotent (quot_ring_hom I x),\n      existsi n,\n      rw \u2190 ring_hom_prevs_pow,\n      apply in_ideal_implies_quotient_zero,\n      exact hn,\n    exact hint\u2081,\n  exact hint,\nend \n\ntheorem ideal_subset_of_radical {R : Type u} [comm_ring R] (I:ideal R)\n  : I.body \u2286 (\u221aI).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  : (\u221a\u221aI) = \u221aI :=\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 \u2190 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 {\u03b1 : Type _} {\u03b2 : Type _} [Ring \u03b2] [LinearOrderedField \u03b1] [Archimedean \u03b1] {abv : \u03b2 \u2192 \u03b1}\n  [IsAbsoluteValue abv]\n\ntheorem isCauSeq_of_decreasing_bounded (f : \u2115 \u2192 \u03b1) {a : \u03b1} {m : \u2115} (ham : \u2200 n \u2265 m, |f n| \u2264 a)\n    (hnm : \u2200 n \u2265 m, f n.succ \u2264 f n) : IsCauSeq abs f := fun \u03b5 \u03b50 => by\n  let \u27e8k, hk\u27e9 := Archimedean.arch a \u03b50\n  have h : \u2203 l, \u2200 n \u2265 m, a - l \u2022 \u03b5 < f n :=\n    \u27e8k + k + 1, fun n hnm =>\n      lt_of_lt_of_le\n        (show a - (k + (k + 1)) \u2022 \u03b5 < -|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 _ \u03b50))))\n        (neg_le.2 <| abs_neg (f n) \u25b8 le_abs_self _)\u27e9\n  let l := Nat.find h\n  have hl : \u2200 n : \u2115, n \u2265 m \u2192 f n > a - l \u2022 \u03b5 := Nat.find_spec h\n  have hl0 : l \u2260 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 \u2264 f i := (Nat.rel_of_forall_rel_succ_of_le_of_le (\u00b7 \u2265 \u00b7) 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 \u2264 a - Nat.pred l \u2022 \u03b5 := hi.2\n    _ = a - l \u2022 \u03b5 + \u03b5 := by\n      conv =>\n        rhs\n        rw [\u2190 Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hl0), succ_nsmul', sub_add,\n          add_sub_cancel]\n    _ < f j + \u03b5 := 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 : \u2115 \u2192 \u03b1) {a : \u03b1} {m : \u2115} (ham : \u2200 n \u2265 m, |f n| \u2264 a)\n    (hnm : \u2200 n \u2265 m, f n \u2264 f n.succ) : IsCauSeq abs f := by\n  refine'\n    @Eq.ndrecOn (\u2115 \u2192 \u03b1) _ (IsCauSeq abs) _ _\n      (-\u27e8_, @isCauSeq_of_decreasing_bounded _ _ _ (fun n => -f n) a m (by simpa) (by simpa)\u27e9 :\n          CauSeq \u03b1 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 {\u03b1 : Type _} {\u03b2 : Type _} [Ring \u03b2] [LinearOrderedField \u03b1] {abv : \u03b2 \u2192 \u03b1}\n  [IsAbsoluteValue abv]\n\ntheorem isCauSeq_series_of_abv_le_of_isCauSeq {f : \u2115 \u2192 \u03b2} {g : \u2115 \u2192 \u03b1} (n : \u2115) :\n    (\u2200 m, n \u2264 m \u2192 abv (f m) \u2264 g m) \u2192\n      (IsCauSeq abs fun n => \u2211 i in range n, g i) \u2192 IsCauSeq abv fun n => \u2211 i in range n, f i := by\n  intro hm hg \u03b5 \u03b50\n  cases' hg (\u03b5 / 2) (div_pos \u03b50 (by norm_num)) with i hi\n  exists max n i\n  intro j ji\n  have hi\u2081 := hi j (le_trans (le_max_right n i) ji)\n  have hi\u2082 := hi (max n i) (le_max_right n i)\n  have sub_le :=\n    abs_sub_le (\u2211 k in range j, g k) (\u2211 k in range i, g k) (\u2211 k in range (max n i), g k)\n  have := add_lt_add hi\u2081 hi\u2082\n  rw [abs_sub_comm (\u2211 k in range (max n i), g k), add_halves \u03b5] 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\u2082 hi\u2081 hi \u03b50 \u03b5 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  \u00b7 simp [abv_zero abv]\n  \u00b7 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 : \u2115 \u2192 \u03b2} :\n    (IsCauSeq abs fun m => \u2211 n in range m, abv (f n)) \u2192 IsCauSeq abv fun m => \u2211 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 {\u03b1 : Type _} [LinearOrderedField \u03b1] [Archimedean \u03b1]\n\ntheorem isCauSeq_geo_series {\u03b2 : Type _} [Ring \u03b2] [Nontrivial \u03b2] {abv : \u03b2 \u2192 \u03b1} [IsAbsoluteValue abv]\n    (x : \u03b2) (hx1 : abv x < 1) : IsCauSeq abv fun n => \u2211 m in range n, x ^ m :=\n  have hx1' : abv x \u2260 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 [\u2190 neg_div_neg_eq, neg_sub, neg_sub]\n      refine' @isCauSeq_of_mono_bounded _ _ _ _ ((1 : \u03b1) / (1 - abv x)) 0 _ _\n      \u00b7 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 \u25b8 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        \u00b7 simp\n        \u00b7 rw [pow_succ, \u2190 one_mul (1 : \u03b1)]\n          refine' mul_le_mul (le_of_lt hx1) ih (abv_pow abv x n \u25b8 abv_nonneg _ _) (by norm_num)\n      \u00b7 intro n _\n        refine' div_le_div_of_le (le_of_lt <| sub_pos.2 hx1) (sub_le_sub_left _ _)\n        rw [\u2190one_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 : \u03b1) {x : \u03b1} (hx1 : |x| < 1) :\n    IsCauSeq abs fun m => \u2211 n in range m, (a * x ^ n) := by\n  have : IsCauSeq abs fun m => a * \u2211 n in range m, (x ^ n) :=\n    (CauSeq.const abs a *\n      (show CauSeq \u03b1 abs from \u27e8fun n => \u2211 m in range n, x ^ m, isCauSeq_geo_series x hx1\u27e9)).2\n  simpa [mul_sum] using this\n#align is_cau_geo_series_const isCauSeq_geo_series_const\n\nvariable {\u03b2 : Type _} [Ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [IsAbsoluteValue abv]\n\ntheorem series_ratio_test {f : \u2115 \u2192 \u03b2} (n : \u2115) (r : \u03b1) (hr0 : 0 \u2264 r) (hr1 : r < 1)\n    (h : \u2200 m, n \u2264 m \u2192 abv (f m.succ) \u2264 r * abv (f m)) : IsCauSeq abv fun m => \u2211 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\u207b\u00b9 ^ n.succ) har1)\n  intro m hmn\n  cases' Classical.em (r = 0) with r_zero r_ne_zero\n  \u00b7 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  \u00b7 rw [hk, Nat.zero_add, mul_right_comm, inv_pow _ _, \u2190 div_eq_mul_inv, mul_div_cancel]\n    exact le_refl _\n    exact (ne_of_lt (pow_pos r_pos _)).symm\n  \u00b7 have kn : k + n.succ \u2265 n.succ := by\n      rw [\u2190 zero_add n.succ]; exact add_le_add (Nat.zero_le _) (by simp)\n    erw [hk, Nat.succ_add, pow_succ' r, \u2190 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 {\u03b1 : Type _} [AddCommMonoid \u03b1] (n : \u2115) (f : \u2115 \u2192 \u2115 \u2192 \u03b1) :\n    (\u2211 m in range n, \u2211 k in range (m + 1), f k (m - k)) =\n      \u2211 m in range n, \u2211 k in range (n - m), f m k := by\n  rw [sum_sigma', sum_sigma']\n  exact\n    sum_bij (fun a _ => \u27e8a.2, a.1 - a.2\u27e9)\n      (fun a ha =>\n        have h\u2081 : a.1 < n := mem_range.1 (mem_sigma.1 ha).1\n        have h\u2082 : a.2 < Nat.succ a.1 := mem_range.1 (mem_sigma.1 ha).2\n        mem_sigma.2\n          \u27e8mem_range.2 (lt_of_lt_of_le h\u2082 h\u2081),\n            mem_range.2 ((tsub_lt_tsub_iff_right (Nat.le_of_lt_succ h\u2082)).2 h\u2081)\u27e9)\n      (fun _ _ => rfl)\n      (fun \u27e8a\u2081, a\u2082\u27e9 \u27e8b\u2081, b\u2082\u27e9 ha hb h =>\n        have ha : a\u2081 < n \u2227 a\u2082 \u2264 a\u2081 :=\n          \u27e8mem_range.1 (mem_sigma.1 ha).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 ha).2)\u27e9\n        have hb : b\u2081 < n \u2227 b\u2082 \u2264 b\u2081 :=\n          \u27e8mem_range.1 (mem_sigma.1 hb).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 hb).2)\u27e9\n        have h : a\u2082 = b\u2082 \u2227 _ := by simpa using h\n        have h' : a\u2081 = b\u2081 - b\u2082 + a\u2082 := (tsub_eq_iff_eq_add_of_le ha.2).1 (eq_of_heq h.2)\n        Sigma.mk.inj_iff.2 \u27e8tsub_add_cancel_of_le hb.2 \u25b8 h'.symm \u25b8 h.1 \u25b8 rfl, heq_of_eq h.1\u27e9)\n      fun \u27e8a\u2081, a\u2082\u27e9 ha =>\n      have ha : a\u2081 < n \u2227 a\u2082 < n - a\u2081 :=\n        \u27e8mem_range.1 (mem_sigma.1 ha).1, mem_range.1 (mem_sigma.1 ha).2\u27e9\n      \u27e8\u27e8a\u2082 + a\u2081, a\u2081\u27e9,\n        \u27e8mem_sigma.2\n            \u27e8mem_range.2 (lt_tsub_iff_right.1 ha.2),\n              mem_range.2 (Nat.lt_succ_of_le (Nat.le_add_left _ _))\u27e9,\n          Sigma.mk.inj_iff.2 \u27e8rfl, heq_of_eq (add_tsub_cancel_right _ _).symm\u27e9\u27e9\u27e9\n#align sum_range_diag_flip sum_range_diag_flip\n\nend\n\nsection NoArchimedean\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} [LinearOrderedField \u03b1] {abv : \u03b2 \u2192 \u03b1}\n\nsection\n\nvariable [Semiring \u03b2] [IsAbsoluteValue abv]\n\ntheorem abv_sum_le_sum_abv {\u03b3 : Type _} (f : \u03b3 \u2192 \u03b2) (s : Finset \u03b3) :\n    abv (\u2211 k in s, f k) \u2264 \u2211 k in s, abv (f k) :=\n  haveI := Classical.decEq \u03b3\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 \u03b2] [IsAbsoluteValue abv]\n\ntheorem cauchy_product {a b : \u2115 \u2192 \u03b2} (ha : IsCauSeq abs fun m => \u2211 n in range m, abv (a n))\n    (hb : IsCauSeq abv fun m => \u2211 n in range m, b n) (\u03b5 : \u03b1) (\u03b50 : 0 < \u03b5) :\n    \u2203 i : \u2115,\n      \u2200 j \u2265 i,\n        abv\n            (((\u2211 k in range j, a k) * \u2211 k in range j, b k) -\n              \u2211 n in range j, \u2211 m in range (n + 1), a m * b (n - m)) <\n          \u03b5 :=\n  let \u27e8Q, hQ\u27e9 := CauSeq.bounded \u27e8_, hb\u27e9\n  let \u27e8P, hP\u27e9 := CauSeq.bounded \u27e8_, ha\u27e9\n  have hP0 : 0 < P := lt_of_le_of_lt (abs_nonneg _) (hP 0)\n  have hP\u03b50 : 0 < \u03b5 / (2 * P) := div_pos \u03b50 (mul_pos (show (2 : \u03b1) > 0 by norm_num) hP0)\n  let \u27e8N, hN\u27e9 := CauSeq.cauchy\u2082 \u27e8_, hb\u27e9 hP\u03b50\n  have hQ\u03b50 : 0 < \u03b5 / (4 * Q) :=\n    div_pos \u03b50 (mul_pos (show (0 : \u03b1) < 4 by norm_num) (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0)))\n  let \u27e8M, hM\u27e9 := CauSeq.cauchy\u2082 \u27e8_, ha\u27e9 hQ\u03b50\n  \u27e82 * (max N M + 1), fun K hK =>\n    by\n    have h\u2081 :\n      (\u2211 m in range K, \u2211 k in range (m + 1), a k * b (m - k)) =\n        \u2211 m in range K, \u2211 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\u2082 :\n      (fun i => \u2211 k in range (K - i), a i * b k) = fun i => a i * \u2211 k in range (K - i), b k := by\n      simp [Finset.mul_sum]\n    have h\u2083 :\n      (\u2211 i in range K, a i * \u2211 k in range (K - i), b k) =\n        (\u2211 i in range K, a i * ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) +\n          \u2211 i in range K, a i * \u2211 k in range K, b k :=\n      by rw [\u2190 sum_add_distrib]; simp [(mul_add _ _ _).symm]\n    have two_mul_two : (4 : \u03b1) = 2 * 2 := by norm_num\n    have hQ0 : Q \u2260 0 := fun h => by simp [h, lt_irrefl] at hQ\u03b50\n    have h2Q0 : 2 * Q \u2260 0 := mul_ne_zero two_ne_zero hQ0\n    have h\u03b5 : \u03b5 / (2 * P) * P + \u03b5 / (4 * Q) * (2 * Q) = \u03b5 := by\n      rw [\u2190 div_div, div_mul_cancel _ (Ne.symm (ne_of_lt hP0)), two_mul_two, mul_assoc, \u2190 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 \u2264 max N M := le_max_left _ _\n        _ < max N M + 1 := (Nat.lt_succ_self _)\n        _ < K := hNMK\n\n    have hsumlesum :\n      (\u2211 i in range (max N M + 1),\n          abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) \u2264\n        \u2211 i in range (max N M + 1), abv (a i) * (\u03b5 / (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 : (\u2211 n in range (max N M + 1), abv (a n)) < P :=\n      calc\n        (\u2211 n in range (max N M + 1), abv (a n)) = |\u2211 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\u2081, h\u2082, h\u2083, sum_mul, \u2190 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      (\u2211 i in range (max N M + 1),\n            abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) +\n          ((\u2211 i in range K, abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) -\n            \u2211 i in range (max N M + 1),\n              abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) <\n        \u03b5 / (2 * P) * P + \u03b5 / (4 * Q) * (2 * Q)\n      by\n      rw [h\u03b5] 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 [\u2190 sum_mul, mul_comm]; exact (mul_lt_mul_left hP\u03b50).mpr hsumltP))\n        _\n    rw [sum_range_sub_sum_range (le_of_lt hNMK)]\n    calc\n      (\u2211 i in (range K).filter fun k => max N M + 1 \u2264 k,\n            abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) \u2264\n          \u2211 i in (range K).filter fun k => max N M + 1 \u2264 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      _ < \u03b5 / (4 * Q) * (2 * Q) := by\n        rw [\u2190 sum_mul, \u2190 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      \u27e9\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 : \u2102) :\n    IsCauSeq Abs.abs fun n => \u2211 m in range n, abs (z ^ m / m.factorial) :=\n  let \u27e8n, hn\u27e9 := exists_nat_gt (abs z)\n  have hn0 : (0 : \u211d) < 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, \u2190 div_div,\n        mul_div_assoc, mul_div_right_comm, map_mul, map_div\u2080, 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 : \u2102) : IsCauSeq abs fun n => \u2211 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 : \u2102) : CauSeq \u2102 Complex.abs :=\n  \u27e8fun n => \u2211 m in range n, z ^ m / m.factorial, isCauSeq_exp z\u27e9\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\n  (tanh x).re\n#align real.tanh Real.tanh\n\nend\n\nend Real\n\nnamespace Complex\n\nvariable (x y : \u2102)\n\n@[simp]\ntheorem exp_zero : exp 0 = 1 := by\n  rw [exp]\n  refine' lim_eq_of_equiv_const fun \u03b5 \u03b50 => \u27e81, fun j hj => _\u27e9\n  convert (config := .unfoldSameFun) \u03b50 -- porting note: \u03b50 : \u03b5 > 0 but goal is _ < \u03b5\n  cases' j with j j\n  \u00b7 exact absurd hj (not_le_of_gt zero_lt_one)\n  \u00b7 dsimp [exp']\n    induction' j with j ih\n    \u00b7 dsimp [exp']; simp [show Nat.succ 0 = 1 from rfl]\n    \u00b7 rw [\u2190 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 : \u2200 j : \u2115, (\u2211 m in range j, (x + y) ^ m / m.factorial) =\n        \u2211 i in range j, \u2211 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\u2081 : (m.choose I : \u2102) \u2260 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\u2082 := Nat.choose_mul_factorial_mul_factorial (Nat.le_of_lt_succ <| Finset.mem_range.1 hi)\n    rw [\u2190 h\u2082, Nat.cast_mul, Nat.cast_mul, mul_inv, mul_inv]\n    simp only [mul_left_comm (m.choose I : \u2102), mul_assoc, mul_left_comm (m.choose I : \u2102)\u207b\u00b9,\n      mul_comm (m.choose I : \u2102)]\n    rw [inv_mul_cancel h\u2081]\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 \u2102` to `\u2102` -/\nnoncomputable def expMonoidHom : MonoidHom (Multiplicative \u2102) \u2102 :=\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 \u2102) : exp l.sum = (l.map exp).prod :=\n  @MonoidHom.map_list_prod (Multiplicative \u2102) \u2102 _ _ expMonoidHom l\n#align complex.exp_list_sum Complex.exp_list_sum\n\ntheorem exp_multiset_sum (s : Multiset \u2102) : exp s.sum = (s.map exp).prod :=\n  @MonoidHom.map_multiset_prod (Multiplicative \u2102) \u2102 _ _ expMonoidHom s\n#align complex.exp_multiset_sum Complex.exp_multiset_sum\n\ntheorem exp_sum {\u03b1 : Type _} (s : Finset \u03b1) (f : \u03b1 \u2192 \u2102) :\n    exp (\u2211 x in s, f x) = \u220f x in s, exp (f x) :=\n  @map_prod (Multiplicative \u2102) \u03b1 \u2102 _ _ _ _ expMonoidHom f s\n#align complex.exp_sum Complex.exp_sum\n\ntheorem exp_nat_mul (x : \u2102) : \u2200 n : \u2115, 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, \u2190 exp_nat_mul _ n, one_mul]\n#align complex.exp_nat_mul Complex.exp_nat_mul\n\ntheorem exp_ne_zero : exp x \u2260 0 := fun h =>\n  zero_ne_one <| by rw [\u2190 exp_zero, \u2190 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)\u207b\u00b9 := by\n  rw [\u2190 mul_right_inj' (exp_ne_zero x), \u2190 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 : \u2102) (n : \u2124) : 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 : \u211d) : ((exp x).re : \u2102) = exp x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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 : \u211d) : (Real.exp x : \u2102) = exp x :=\n  ofReal_exp_ofReal_re _\n#align complex.of_real_exp Complex.ofReal_exp\n\n@[simp]\ntheorem exp_ofReal_im (x : \u211d) : (exp x).im = 0 := by rw [\u2190 ofReal_exp_ofReal_re, ofReal_im]\n#align complex.exp_of_real_im Complex.exp_ofReal_im\n\ntheorem exp_ofReal_re (x : \u211d) : (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 : \u2102} :\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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), two_sinh, exp_add, neg_add, exp_add, eq_comm, mul_add, \u2190\n    mul_assoc, two_sinh, mul_left_comm, two_sinh, \u2190 mul_right_inj' (two_ne_zero' \u2102), mul_add,\n    mul_left_comm, two_cosh, \u2190 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 : \u2102} :\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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), two_cosh, exp_add, neg_add, exp_add, eq_comm, mul_add, \u2190\n    mul_assoc, two_cosh, \u2190 mul_assoc, two_sinh, \u2190 mul_right_inj' (two_ne_zero' \u2102), 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, \u2190 RingHom.map_neg, exp_conj, exp_conj, \u2190 RingHom.map_sub, sinh, map_div\u2080]\n  --Porting note: not nice\n  simp [\u2190 one_add_one_eq_two]\n#align complex.sinh_conj Complex.sinh_conj\n\n@[simp]\ntheorem ofReal_sinh_ofReal_re (x : \u211d) : ((sinh x).re : \u2102) = sinh x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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 : \u211d) : (Real.sinh x : \u2102) = 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 : \u211d) : (sinh x).im = 0 := by rw [\u2190 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 : \u211d) : (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, \u2190 RingHom.map_neg, exp_conj, exp_conj, \u2190 RingHom.map_add, cosh, map_div\u2080]\n  --Porting note: not nice\n  simp [\u2190 one_add_one_eq_two]\n#align complex.cosh_conj Complex.cosh_conj\n\ntheorem ofReal_cosh_ofReal_re (x : \u211d) : ((cosh x).re : \u2102) = cosh x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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 : \u211d) : (Real.cosh x : \u2102) = cosh x :=\n  ofReal_cosh_ofReal_re _\n#align complex.of_real_cosh Complex.ofReal_cosh\n\n@[simp]\ntheorem cosh_ofReal_im (x : \u211d) : (cosh x).im = 0 := by rw [\u2190 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 : \u211d) : (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, \u2190 map_div\u2080, tanh]\n#align complex.tanh_conj Complex.tanh_conj\n\n@[simp]\ntheorem ofReal_tanh_ofReal_re (x : \u211d) : ((tanh x).re : \u2102) = tanh x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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 : \u211d) : (Real.tanh x : \u2102) = tanh x :=\n  ofReal_tanh_ofReal_re _\n#align complex.of_real_tanh Complex.ofReal_tanh\n\n@[simp]\ntheorem tanh_ofReal_im (x : \u211d) : (tanh x).im = 0 := by rw [\u2190 ofReal_tanh_ofReal_re, ofReal_im]\n#align complex.tanh_of_real_im Complex.tanh_ofReal_im\n\ntheorem tanh_ofReal_re (x : \u211d) : (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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), 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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), 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 [\u2190 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, \u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), two_sinh, \u2190 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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), 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 [\u2190 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, \u2190 sinh_mul_I]\n    ring_nf\n    simp\n  rw [\u2190 neg_neg (sinh x), \u2190 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 [\u2190 mul_left_inj' I_ne_zero, \u2190 sinh_mul_I, add_mul, add_mul, mul_right_comm, \u2190 sinh_mul_I,\n    mul_assoc, \u2190 sinh_mul_I, \u2190 cosh_mul_I, \u2190 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 : \u2102} :\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 [\u2190 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 : \u2102) : 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 : \u2102) : 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 : \u2102) : 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 : \u2102) : 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, \u2190 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, \u2190 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 : \u2102) \u2260 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  \u00b7 congr <;> field_simp [h2]\n  \u00b7 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 [\u2190 mul_left_inj' I_ne_zero, \u2190 sinh_mul_I, \u2190 conj_neg_I, \u2190 RingHom.map_mul, \u2190 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 : \u211d) : ((sin x).re : \u2102) = sin x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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 : \u211d) : (Real.sin x : \u2102) = sin x :=\n  ofReal_sin_ofReal_re _\n#align complex.of_real_sin Complex.ofReal_sin\n\n@[simp]\ntheorem sin_ofReal_im (x : \u211d) : (sin x).im = 0 := by rw [\u2190 ofReal_sin_ofReal_re, ofReal_im]\n#align complex.sin_of_real_im Complex.sin_ofReal_im\n\ntheorem sin_ofReal_re (x : \u211d) : (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 [\u2190 cosh_mul_I, \u2190 conj_neg_I, \u2190 RingHom.map_mul, \u2190 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 : \u211d) : ((cos x).re : \u2102) = cos x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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 : \u211d) : (Real.cos x : \u2102) = cos x :=\n  ofReal_cos_ofReal_re _\n#align complex.of_real_cos Complex.ofReal_cos\n\n@[simp]\ntheorem cos_ofReal_im (x : \u211d) : (cos x).im = 0 := by rw [\u2190 ofReal_cos_ofReal_re, ofReal_im]\n#align complex.cos_of_real_im Complex.cos_ofReal_im\n\ntheorem cos_ofReal_re (x : \u211d) : (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 : \u2102} (hx : cos x \u2260 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, \u2190 map_div\u2080, tan]\n#align complex.tan_conj Complex.tan_conj\n\n@[simp]\ntheorem ofReal_tan_ofReal_re (x : \u211d) : ((tan x).re : \u2102) = tan x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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 : \u211d) : (Real.tan x : \u2102) = 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 : \u211d) : (tan x).im = 0 := by rw [\u2190 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 : \u211d) : (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 [\u2190 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, \u2190 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, \u2190 sq, \u2190 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), \u2190 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 [\u2190 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 [\u2190 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 : \u2102} (hx : cos x \u2260 0) : (1 + tan x ^ 2)\u207b\u00b9 = cos x ^ 2 := by\n  have : cos x ^ 2 \u2260 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 : \u2102} (hx : cos x \u2260 0) :\n    tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by\n  simp only [\u2190 tan_mul_cos hx, mul_pow, \u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 : \u211d) : (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 : \u211d) : (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 : \u2115) (z : \u2102) :\n    (cos z + sin z * I) ^ n = cos (\u2191n * z) + sin (\u2191n * z) * I := by\n  rw [\u2190 exp_mul_I, \u2190 exp_mul_I]\n  induction' n with n ih\n  \u00b7 rw [pow_zero, Nat.cast_zero, zero_mul, zero_mul, exp_zero]\n  \u00b7 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 : \u211d)\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 \u211d` to `\u211d` -/\nnoncomputable def expMonoidHom : MonoidHom (Multiplicative \u211d) \u211d :=\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 \u211d) : exp l.sum = (l.map exp).prod :=\n  @MonoidHom.map_list_prod (Multiplicative \u211d) \u211d _ _ expMonoidHom l\n#align real.exp_list_sum Real.exp_list_sum\n\ntheorem exp_multiset_sum (s : Multiset \u211d) : exp s.sum = (s.map exp).prod :=\n  @MonoidHom.map_multiset_prod (Multiplicative \u211d) \u211d _ _ expMonoidHom s\n#align real.exp_multiset_sum Real.exp_multiset_sum\n\ntheorem exp_sum {\u03b1 : Type _} (s : Finset \u03b1) (f : \u03b1 \u2192 \u211d) :\n    exp (\u2211 x in s, f x) = \u220f x in s, exp (f x) :=\n  @map_prod (Multiplicative \u211d) \u03b1 \u211d _ _ _ _ expMonoidHom f s\n#align real.exp_sum Real.exp_sum\n\nnonrec theorem exp_nat_mul (x : \u211d) (n : \u2115) : 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 \u2260 0 := fun h =>\n  exp_ne_zero x <| by rw [exp, \u2190 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)\u207b\u00b9 :=\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 : \u211d} (hx : cos x \u2260 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 \u2264 1 := by\n  rw [\u2190 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 \u2264 1 := by\n  rw [\u2190 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| \u2264 1 :=\n  abs_le_one_iff_mul_self_le_one.2 <| by simp only [\u2190 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| \u2264 1 :=\n  abs_le_one_iff_mul_self_le_one.2 <| by simp only [\u2190 sq, cos_sq_le_one]\n#align real.abs_cos_le_one Real.abs_cos_le_one\n\ntheorem sin_le_one : sin x \u2264 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 \u2264 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 \u2264 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 \u2264 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 [\u2190 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 : \u211d) : |sin x| = sqrt (1 - cos x ^ 2) := by\n  rw [\u2190 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 : \u211d) : |cos x| = sqrt (1 - sin x ^ 2) := by\n  rw [\u2190 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 : \u211d} (hx : cos x \u2260 0) : (1 + tan x ^ 2)\u207b\u00b9 = cos x ^ 2 :=\n  have : Complex.cos x \u2260 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 : \u211d} (hx : cos x \u2260 0) :\n    tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by\n  simp only [\u2190 tan_mul_cos hx, mul_pow, \u2190 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 : \u211d} (hx : 0 < cos x) : (sqrt (1 + tan x ^ 2))\u207b\u00b9 = cos x := by\n  rw [\u2190 sqrt_sq hx.le, \u2190 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 : \u211d} (hx : 0 < cos x) :\n    tan x / sqrt (1 + tan x ^ 2) = sin x := by\n  rw [\u2190 tan_mul_cos hx.ne', \u2190 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 [\u2190 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 [\u2190 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 : \u211d) : 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 [\u2190 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 : \u211d) : 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, \u2190 Complex.add_re, \u2190 mul_two,\n      div_mul_cancel _ (two_ne_zero' \u2102), 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 [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 : \u211d) : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 : \u211d} (hx : 0 \u2264 x) : x + 1 \u2264 exp x :=\n  calc\n    x + 1 \u2264 CauSeq.lim (\u27e8fun n : \u2115 => ((exp' x) n).re, isCauSeq_re (exp' x)\u27e9 : CauSeq \u211d Abs.abs) :=\n      le_lim\n        (CauSeq.le_of_exists\n          \u27e82, fun j hj =>\n            show x + (1 : \u211d) \u2264 (\u2211 m in range j, ((x : \u2102) ^ m / m.factorial)).re by\n              have h\u2081 : (((fun m : \u2115 => ((x : \u2102) ^ m / m.factorial)) \u2218 Nat.succ) 0).re = x :=\n                by simp [show Nat.succ 0 = 1 from rfl, Complex.ofReal_re]\n              have h\u2082 : ((x : \u2102) ^ 0 / (Nat.factorial 0)).re = 1 := by simp\n              erw [\u2190 tsub_add_cancel_of_le hj, sum_range_succ', sum_range_succ', add_re, add_re, h\u2081,\n                h\u2082, add_assoc, \u2190 coe_reAddGroupHom, reAddGroupHom.map_sum,\n                coe_reAddGroupHom]\n              refine' le_add_of_nonneg_of_le (sum_nonneg fun m _ => _) le_rfl\n              rw [\u2190 ofReal_pow, \u2190 ofReal_nat_cast, \u2190 ofReal_div, ofReal_re]\n              exact div_nonneg (pow_nonneg hx _) (Nat.cast_nonneg _)\u27e9)\n    _ = exp x := by rw [exp, Complex.exp, \u2190 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 : \u211d} (hx : 0 \u2264 x) : 1 \u2264 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 : \u211d) : 0 < exp x :=\n  (le_total 0 x).elim (lt_of_lt_of_le zero_lt_one \u2218 one_le_exp) fun h => by\n    rw [\u2190 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 : \u211d) : |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 [\u2190 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 : \u211d} : exp x < exp y \u2194 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 : \u211d} : exp x \u2264 exp y \u2194 x \u2264 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 : \u211d} : exp x = exp y \u2194 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 \u2194 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 : \u211d} : 1 < exp x \u2194 0 < x := by rw [\u2190 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 : \u211d} : exp x < 1 \u2194 x < 0 := by rw [\u2190 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 : \u211d} : exp x \u2264 1 \u2194 x \u2264 0 :=\n  exp_zero \u25b8 exp_le_exp\n#align real.exp_le_one_iff Real.exp_le_one_iff\n\n@[simp]\ntheorem one_le_exp_iff {x : \u211d} : 1 \u2264 exp x \u2194 0 \u2264 x :=\n  exp_zero \u25b8 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 : \u211d) : 0 < Real.cosh x :=\n  (cosh_eq x).symm \u25b8 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 \u25b8 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 {\u03b1 : Type _} [LinearOrderedField \u03b1] (n j : \u2115) (hn : 0 < n) :\n    (\u2211 m in filter (fun k => n \u2264 k) (range j),\n      (1 / m.factorial : \u03b1)) \u2264 n.succ / (n.factorial * n) :=\n  calc\n    (\u2211 m in filter (fun k => n \u2264 k) (range j), (1 / m.factorial : \u03b1)) =\n        \u2211 m in range (j - n), (1 / ((m + n).factorial : \u03b1)) :=\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\u2081 a\u2082 ha\u2081 ha\u2082 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        \u27e8b + n,\n          mem_filter.2 \u27e8mem_range.2 <| lt_tsub_iff_right.mp (mem_range.1 hb), Nat.le_add_left _ _\u27e9,\n          by dsimp; rw [add_tsub_cancel_right]\u27e9\n    _ \u2264 \u2211 m in range (j - n), ((n.factorial : \u03b1) * (n.succ : \u03b1) ^ m)\u207b\u00b9 := by\n      refine' sum_le_sum fun m _ => _\n      rw [one_div, inv_le_inv]\n      \u00b7 rw [\u2190 Nat.cast_pow, \u2190 Nat.cast_mul, Nat.cast_le, add_comm]\n        exact Nat.factorial_mul_pow_le_factorial\n      \u00b7 exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      \u00b7 exact mul_pos (Nat.cast_pos.2 (Nat.factorial_pos _))\n            (pow_pos (Nat.cast_pos.2 (Nat.succ_pos _)) _)\n    _ = (n.factorial : \u03b1)\u207b\u00b9 * \u2211 m in range (j - n), (n.succ : \u03b1)\u207b\u00b9 ^ m := by\n      simp [mul_inv, mul_sum.symm, sum_mul.symm, -Nat.factorial_succ, mul_comm, inv_pow]\n    _ = ((n.succ : \u03b1) - n.succ * (n.succ : \u03b1)\u207b\u00b9 ^ (j - n)) / (n.factorial * n) :=\n      by\n      have h\u2081 : (n.succ : \u03b1) \u2260 1 :=\n        @Nat.cast_one \u03b1 _ \u25b8 mt Nat.cast_inj.1 (mt Nat.succ.inj (pos_iff_ne_zero.1 hn))\n      have h\u2082 : (n.succ : \u03b1) \u2260 0 := Nat.cast_ne_zero.2 (Nat.succ_ne_zero _)\n      have h\u2083 : (n.factorial * n : \u03b1) \u2260 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\u2084 : (n.succ - 1 : \u03b1) = n := by simp\n      rw [geom_sum_inv h\u2081 h\u2082, eq_div_iff_mul_eq h\u2083, mul_comm _ (n.factorial * n : \u03b1),\n          \u2190 mul_assoc (n.factorial\u207b\u00b9 : \u03b1), \u2190 mul_inv_rev, h\u2084, \u2190 mul_assoc (n.factorial * n : \u03b1),\n          mul_comm (n : \u03b1) n.factorial, mul_inv_cancel h\u2083, one_mul, mul_comm]\n    _ \u2264 n.succ / (n.factorial * n : \u03b1) :=\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 : \u2102} (hx : abs x \u2264 1) {n : \u2115} (hn : 0 < n) :\n    abs (exp x - \u2211 m in range n, x ^ m / m.factorial) \u2264\n      abs x ^ n * ((n.succ : \u211d) * (n.factorial * n : \u211d)\u207b\u00b9) := by\n  rw [\u2190 lim_const (abv := Complex.abs) (\u2211 m in range n, _), exp, sub_eq_add_neg,\n    \u2190 lim_neg, lim_add, \u2190 lim_abs]\n  refine' lim_le (CauSeq.le_of_exists \u27e8n, fun j hj => _\u27e9)\n  simp_rw [\u2190 sub_eq_add_neg]\n  show\n    abs ((\u2211 m in range j, x ^ m / m.factorial) - \u2211 m in range n, x ^ m / m.factorial) \u2264\n      abs x ^ n * ((n.succ : \u211d) * (n.factorial * n : \u211d)\u207b\u00b9)\n  rw [sum_range_sub_sum_range hj]\n  calc\n    abs (\u2211 m in (range j).filter fun k => n \u2264 k, (x ^ m / m.factorial : \u2102)) =\n        abs (\u2211 m in (range j).filter fun k => n \u2264 k, (x ^ n * (x ^ (m - n) / m.factorial) : \u2102)) :=\n      by\n      refine' congr_arg abs (sum_congr rfl fun m hm => _)\n      rw [mem_filter, mem_range] at hm\n      rw [\u2190 mul_div_assoc, \u2190 pow_add, add_tsub_cancel_of_le hm.2]\n    _ \u2264 \u2211 m in filter (fun k => n \u2264 k) (range j), abs (x ^ n * (x ^ (m - n) / m.factorial)) :=\n      (abv_sum_le_sum_abv (abv := Complex.abs) _ _)\n    _ \u2264 \u2211 m in filter (fun k => n \u2264 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\u2080, abs_cast_nat]\n      refine' mul_le_mul_of_nonneg_left ((div_le_div_right _).2 _) _\n      \u00b7 exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      \u00b7 rw [abv_pow abs]\n        exact pow_le_one _ (abs.nonneg _) hx\n      \u00b7 exact pow_nonneg (abs.nonneg _) _\n    _ = abs x ^ n * \u2211 m in (range j).filter fun k => n \u2264 k, (1 / m.factorial : \u211d) := by\n      simp [abs_mul, abv_pow abs, abs_div, mul_sum.symm]\n    _ \u2264 abs x ^ n * (n.succ * (n.factorial * n : \u211d)\u207b\u00b9) :=\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 : \u2102} {n : \u2115} (hx : abs x / n.succ \u2264 1 / 2) :\n    abs (exp x - \u2211 m in range n, x ^ m / m.factorial) \u2264 abs x ^ n / n.factorial * 2 := by\n  rw [\u2190 lim_const (abv := Complex.abs) (\u2211 m in range n, _),\n    exp, sub_eq_add_neg, \u2190 lim_neg, lim_add, \u2190 lim_abs]\n  refine' lim_le (CauSeq.le_of_exists \u27e8n, fun j hj => _\u27e9)\n  simp_rw [\u2190 sub_eq_add_neg]\n  show abs ((\u2211 m in range j, x ^ m / m.factorial) - \u2211 m in range n, x ^ m / m.factorial) \u2264\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 (\u2211 i : \u2115 in range k, x ^ (n + i) / ((n + i).factorial : \u2102)) \u2264\n        \u2211 i : \u2115 in range k, abs (x ^ (n + i) / ((n + i).factorial : \u2102)) :=\n      abv_sum_le_sum_abv _ _\n    _ \u2264 \u2211 i : \u2115 in range k, abs x ^ (n + i) / (n + i).factorial := by\n      simp [Complex.abs_cast_nat, map_div\u2080, abv_pow abs]\n    _ \u2264 \u2211 i : \u2115 in range k, abs x ^ (n + i) / ((n.factorial : \u211d) * (n.succ : \u211d) ^ i) := ?_\n    _ = \u2211 i : \u2115 in range k, abs x ^ n / n.factorial * (abs x ^ i / (n.succ : \u211d) ^ i) := ?_\n    _ \u2264 abs x ^ n / \u2191n.factorial * 2 := ?_\n  \u00b7 refine' sum_le_sum fun m _ => div_le_div (pow_nonneg (abs.nonneg x) (n + m)) le_rfl _ _\n    \u00b7 exact_mod_cast mul_pos n.factorial_pos (pow_pos n.succ_pos _)\n    \u00b7 exact_mod_cast Nat.factorial_mul_pow_le_factorial\n  \u00b7 refine' Finset.sum_congr rfl fun _ _ => _\n    simp only [pow_add, div_eq_inv_mul, mul_inv, mul_left_comm, mul_assoc]\n  \u00b7 rw [\u2190 mul_sum]\n    apply mul_le_mul_of_nonneg_left\n    \u00b7 simp_rw [\u2190 div_pow]\n      rw [geom_sum_eq, div_le_iff_of_neg]\n      \u00b7 trans (-1 : \u211d)\n        \u00b7 -- Porting note: was linarith\n          simp [Nat.succ_eq_add_one] at hx\n          rw [mul_comm, \u2190 le_div_iff]\n          simp [hx]\n          . norm_num [this, hx]\n            simp [hx]\n          . exact zero_lt_two\n        \u00b7 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      \u00b7 -- 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      \u00b7 -- Porting note: was linarith\n        intro h\n        simp at h\n        simp [h] at hx\n        norm_num at hx\n    \u00b7 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 : \u2102} (hx : abs x \u2264 1) : abs (exp x - 1) \u2264 2 * abs x :=\n  calc\n    abs (exp x - 1) = abs (exp x - \u2211 m in range 1, x ^ m / m.factorial) := by simp [sum_range_succ]\n    _ \u2264 abs x ^ 1 * ((Nat.succ 1 : \u211d) * ((Nat.factorial 1) * (1 : \u2115) : \u211d)\u207b\u00b9) :=\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 : \u2102} (hx : abs x \u2264 1) : abs (exp x - 1 - x) \u2264 abs x ^ 2 :=\n  calc\n    abs (exp x - 1 - x) = abs (exp x - \u2211 m in range 2, x ^ m / m.factorial) := by\n      simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc]\n    _ \u2264 abs x ^ 2 * ((Nat.succ 2 : \u211d) * (Nat.factorial 2 * (2 : \u2115) : \u211d)\u207b\u00b9) :=\n      (exp_bound hx (by decide))\n    _ \u2264 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 : \u211d} (hx : |x| \u2264 1) {n : \u2115} (hn : 0 < n) :\n    |exp x - \u2211 m in range n, x ^ m / m.factorial| \u2264 |x| ^ n * (n.succ / (n.factorial * n)) := by\n  have hxc : Complex.abs x \u2264 1 := by exact_mod_cast hx\n  convert exp_bound hxc hn using 2 <;>\n  --Porting note: was `norm_cast`\n  simp only [\u2190 abs_ofReal, \u2190 ofReal_sub, \u2190 ofReal_exp, \u2190 ofReal_sum, \u2190 ofReal_pow,\n    \u2190 ofReal_div, \u2190 ofReal_nat_cast]\n#align real.exp_bound Real.exp_bound\n\ntheorem exp_bound' {x : \u211d} (h1 : 0 \u2264 x) (h2 : x \u2264 1) {n : \u2115} (hn : 0 < n) :\n    Real.exp x \u2264 (\u2211 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| \u2264 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 : \u211d} (hx : |x| \u2264 1) : |exp x - 1| \u2264 2 * |x| := by\n  have : abs' x \u2264 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 [\u2190 ofReal_exp, \u2190 ofReal_one, \u2190 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 : \u211d} (hx : |x| \u2264 1) : |exp x - 1 - x| \u2264 x ^ 2 := by\n  rw [\u2190 _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 \u2264 1 := by exact_mod_cast hx\n  have := Complex.abs_exp_sub_one_sub_id_le this\n  rw [\u2190 ofReal_one, \u2190 ofReal_exp, \u2190 ofReal_sub, \u2190 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 \u27f6 exp x` as `n \u27f6 \u221e`,\nfor any `r`. -/\nnoncomputable def expNear (n : \u2115) (x r : \u211d) : \u211d :=\n  (\u2211 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\u2081 r\u2082) : expNear n x r\u2081 -\n    expNear n x r\u2082 = x ^ n / n.factorial * (r\u2081 - r\u2082) := by\n  simp [expNear, mul_sub]\n#align real.exp_near_sub Real.expNear_sub\n\ntheorem exp_approx_end (n m : \u2115) (x : \u211d) (e\u2081 : n + 1 = m) (h : |x| \u2264 1) :\n    |exp x - expNear m x 0| \u2264 |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\u2081 b\u2081 : \u211d} (m : \u2115) (e\u2081 : n + 1 = m) (a\u2082 b\u2082 : \u211d)\n    (e : |1 + x / m * a\u2082 - a\u2081| \u2264 b\u2081 - |x| / m * b\u2082)\n    (h : |exp x - expNear m x a\u2082| \u2264 |x| ^ m / m.factorial * b\u2082) :\n    |exp x - expNear n x a\u2081| \u2264 |x| ^ n / n.factorial * b\u2081 := by\n  refine' (abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)\n  subst e\u2081; rw [expNear_succ, expNear_sub, abs_mul]\n  convert mul_le_mul_of_nonneg_left (a := abs' x ^ n / \u2191(Nat.factorial n))\n      (le_sub_iff_add_le'.1 e) ?_ using 1\n  \u00b7 simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, \u2190 pow_abs, mul_inv]\n    ac_rfl\n  \u00b7 simp [div_nonneg, abs_nonneg]\n#align real.exp_approx_succ Real.exp_approx_succ\n\ntheorem exp_approx_end' {n} {x a b : \u211d} (m : \u2115) (e\u2081 : n + 1 = m) (rm : \u211d) (er : \u2191m = rm)\n    (h : |x| \u2264 1) (e : |1 - a| \u2264 b - |x| / rm * ((rm + 1) / rm)) :\n    |exp x - expNear n x a| \u2264 |x| ^ n / n.factorial * b := by\n  subst er\n  exact exp_approx_succ _ e\u2081 _ _ (by simpa using e) (exp_approx_end _ _ _ e\u2081 h)\n#align real.exp_approx_end' Real.exp_approx_end'\n\ntheorem exp_1_approx_succ_eq {n} {a\u2081 b\u2081 : \u211d} {m : \u2115} (en : n + 1 = m) {rm : \u211d} (er : \u2191m = rm)\n    (h : |exp 1 - expNear m 1 ((a\u2081 - 1) * rm)| \u2264 |1| ^ m / m.factorial * (b\u2081 * rm)) :\n    |exp 1 - expNear n 1 a\u2081| \u2264 |1| ^ n / n.factorial * b\u2081 := by\n  subst er\n  refine' exp_approx_succ _ en _ _ _ h\n  field_simp [show (m : \u211d) \u2260 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 : \u211d) (h : |exp x - expNear 0 x a| \u2264 |x| ^ 0 / Nat.factorial 0 * b) :\n    |exp x - a| \u2264 b := by simpa using h\n#align real.exp_approx_start Real.exp_approx_start\n\ntheorem cos_bound {x : \u211d} (hx : |x| \u2264 1) : |cos x - (1 - x ^ 2 / 2)| \u2264 |x| ^ 4 * (5 / 96) :=\n  calc\n    |cos x - (1 - x ^ 2 / 2)| = Complex.abs (Complex.cos x - (1 - (x : \u2102) ^ 2 / 2)) := by\n      rw [\u2190 abs_ofReal]; simp\n    _ = Complex.abs ((Complex.exp (x * I) + Complex.exp (-x * I) - (2 - (x : \u2102) ^ 2)) / 2) := by\n      simp [Complex.cos, sub_div, add_div, neg_div, div_self (two_ne_zero' \u2102)]\n    _ = abs\n          (((Complex.exp (x * I) - \u2211 m in range 4, (x * I) ^ m / m.factorial) +\n              (Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m.factorial)) / 2) :=\n      (congr_arg Complex.abs\n        (congr_arg (fun x : \u2102 => 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    _ \u2264 abs ((Complex.exp (x * I) - \u2211 m in range 4, (x * I) ^ m / m.factorial) / 2) +\n          abs ((Complex.exp (-x * I) - \u2211 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) - \u2211 m in range 4, (x * I) ^ m / m.factorial) / 2 +\n          abs (Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m.factorial) / 2 :=\n      by simp [map_div\u2080]\n    _ \u2264 Complex.abs (x * I) ^ 4 * (Nat.succ 4 * ((Nat.factorial 4) * (4 : \u2115) : \u211d)\u207b\u00b9) / 2 +\n          Complex.abs (-x * I) ^ 4 * (Nat.succ 4 * ((Nat.factorial 4) * (4 : \u2115) : \u211d)\u207b\u00b9) / 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    _ \u2264 |x| ^ 4 * (5 / 96) := by norm_num\n#align real.cos_bound Real.cos_bound\n\ntheorem sin_bound {x : \u211d} (hx : |x| \u2264 1) : |sin x - (x - x ^ 3 / 6)| \u2264 |x| ^ 4 * (5 / 96) :=\n  calc\n    |sin x - (x - x ^ 3 / 6)| = Complex.abs (Complex.sin x - (x - x ^ 3 / 6 : \u211d)) := by\n      rw [\u2190 abs_ofReal]; simp\n    _ = Complex.abs (((Complex.exp (-x * I) - Complex.exp (x * I)) * I -\n          (2 * x - x ^ 3 / 3 : \u211d)) / 2) := by\n      simp [Complex.sin, sub_div, add_div, neg_div, mul_div_cancel_left _ (two_ne_zero' \u2102), div_div,\n        show (3 : \u2102) * 2 = 6 by norm_num]\n    _ = Complex.abs (((Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m.factorial) -\n                (Complex.exp (x * I) - \u2211 m in range 4, (x * I) ^ m / m.factorial)) * I / 2) :=\n      (congr_arg Complex.abs\n        (congr_arg (fun x : \u2102 => 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    _ \u2264 abs ((Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m.factorial) * I / 2) +\n          abs (-((Complex.exp (x * I) - \u2211 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) - \u2211 m in range 4, (x * I) ^ m / m.factorial) / 2 +\n          abs (Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m.factorial) / 2 :=\n      by simp [add_comm, map_div\u2080]\n    _ \u2264 Complex.abs (x * I) ^ 4 * (Nat.succ 4 * (Nat.factorial 4 * (4 : \u2115) : \u211d)\u207b\u00b9) / 2 +\n          Complex.abs (-x * I) ^ 4 * (Nat.succ 4 * (Nat.factorial 4 * (4 : \u2115) : \u211d)\u207b\u00b9) / 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    _ \u2264 |x| ^ 4 * (5 / 96) := by norm_num\n#align real.sin_bound Real.sin_bound\n\ntheorem cos_pos_of_le_one {x : \u211d} (hx : |x| \u2264 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 \u2264 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, \u2190 abs_mul_self, abs_mul]\n                    exact mul_le_one hx (abs_nonneg _) hx))\n            _ < 1 := by norm_num)\n    _ \u2264 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 : \u211d} (hx0 : 0 < x) (hx : x \u2264 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 \u2264 x * (5 / 96) + x / 6 :=\n              add_le_add\n                (mul_le_mul_of_nonneg_right\n                  (calc\n                    |x| ^ 4 \u2264 |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 \u2264 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    _ \u2264 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 : \u211d} (hx0 : 0 < x) (hx : x \u2264 2) : 0 < sin x :=\n  have : x / 2 \u2264 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 [\u2190 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 \u2264 2 / 3 :=\n  calc\n    cos 1 \u2264 |(1 : \u211d)| ^ 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    _ \u2264 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    _ \u2264 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 \u2264 x)` because it is no longer used\ntheorem exp_bound_div_one_sub_of_interval_approx {x : \u211d} (h2 : x \u2264 1) :\n    (\u2211 j : \u2115 in Finset.range 3, x ^ j / j.factorial) +\n        x ^ 3 * ((3 : \u2115) + 1) / ((3 : \u2115).factorial * (3 : \u2115)) \u2264\n      \u2211 j in Finset.range 3, x ^ j :=\n  calc\n    (\u2211 j : \u2115 in Finset.range 3, x ^ j / j.factorial) +\n        x ^ 3 * ((3 : \u2115) + 1) / ((3 : \u2115).factorial * (3 : \u2115))\n      = (2 / 9) * x ^ 3 + x ^ 2 / 2 + x + 1 := by simp [Finset.sum]; ring\n    _ \u2264 x ^ 2 + x + 1 := sub_nonneg.1 <|\n      calc 0 \u2264 x^2 * (2 / 9) * (9 / 4 - x) :=\n          mul_nonneg (mul_nonneg (pow_two_nonneg _) (by norm_num : (0 : \u211d) \u2264 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\u2093\n\ntheorem exp_bound_div_one_sub_of_interval {x : \u211d} (h1 : 0 \u2264 x) (h2 : x < 1) :\n    Real.exp x \u2264 1 / (1 - x) :=\n  haveI h : (\u2211 j in Finset.range 3, x ^ j) \u2264 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 [\u2190 add_assoc, mul_sub_left_distrib, mul_one, add_mul, sub_add_eq_sub_sub,\n      pow_succ' x 2]\n    have hx3 : 0 \u2264 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 : \u211d} (h : 0 \u2264 y) : 1 - y \u2264 Real.exp (-y) := by\n  rw [Real.exp_neg]\n  have r1 : (1 - y) * Real.exp y \u2264 1 :=\n    by\n    cases le_or_lt (1 - y) 0\n    \u00b7 have h'' : (1 - y) * y.exp \u2264 0 := by\n        rw [mul_nonpos_iff]\n        right\n        exact \u27e8by assumption, y.exp_pos.le\u27e9\n      linarith\n    have hy1 : y < 1 := by linarith\n    rw [\u2190 le_div_iff' \u20390 < 1 - y\u203a]\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 : \u211d} (h : x \u2264 0) : x + 1 \u2264 Real.exp x := by\n  rw [add_comm]\n  have h1 : 0 \u2264 -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 : \u211d) : x + 1 \u2264 Real.exp x := by\n  cases' le_or_lt 0 x with h h\n  \u00b7 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 : \u2115} {t : \u211d} (ht' : t \u2264 n) : (1 - t / n) ^ n \u2264 exp (-t) := by\n  rcases eq_or_ne n 0 with (rfl | hn)\n  \u00b7 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  \u00b7 abel\n  \u00b7 rw [\u2190 Real.exp_nat_mul]\n    congr 1\n    field_simp [(Nat.cast_ne_zero (R := \u211d)).mpr hn]\n    ring_nf\n  \u00b7 rwa [add_comm, \u2190 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(\u211d))) \u2190 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 : \u211d) : 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 : \u211d) : abs (exp x) = Real.exp x := by\n  rw [\u2190 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 : \u211d) : 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 : \u2102) : 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 : \u2102} : abs (exp x) = abs (exp y) \u2194 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 \u2194 a = b := \n    by {cases a, cases b, dsimp at *, simp at *}\n\n@[simp , tidy] def inclusion (S : set A) \n    : S \u2192 A := \u03bb s , s \nnotation S ` \u21aa ` 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 \u2286 T)\n    : (S \u21aa A) = (T \u21aa A) \u2218 (set.inclusion h)\n        := by tidy\n \n\nnoncomputable def graph_to_map \n                 (G :  A \u2192 B \u2192 Prop)\n                 (h : \u2200 a : A , \u2203! b : B, G a b) : A \u2192 B :=\n                 \u03bb a , some (h a)\n\n\n\ndef map_to_graph (f : A \u2192 B): set (A \u00d7 B ):= \u03bb r, r.2 = f r.1 \n\n\nlemma bij_map_to_graph_fst (f : A \u2192 B) :\n    let \u03c0\u2081 : (map_to_graph f) \u2192 A := \u03bb r , r.val.1 in \n    bijective \u03c0\u2081 := \n    begin\n        let R : set (A \u00d7 B) := map_to_graph f,\n        let \u03c0\u2081 : R \u2192 A := \u03bb r , r.val.1, \n        have inj : injective \u03c0\u2081 := \n            begin\n                assume a\u2081 a\u2082 (\u03c0a\u2081_\u03c0a\u2082 : a\u2081.val.1 = a\u2082.val.1),\n                have a1_p : a\u2081.val.2 = f a\u2081.val.1 := a\u2081.property,\n                have a2_p : a\u2082.val.2 = f a\u2082.val.1 := a\u2082.property,\n                have a_a : f a\u2081.val.1 = f a\u2082.val.1 := by tidy,\n                have a2_p : a\u2081.val.2 = a\u2082.val.2 := by simp [a1_p, a2_p, a_a],\n                tidy\n            end,\n        have sur : surjective \u03c0\u2081 := \n            begin\n                intro a,\n                let r := (\u27e8a , f a\u27e9 : A \u00d7 B),\n                have r_R : r \u2208 R := \n                    have r2_fr1 : r.2 = f r.1 := by simp,\n                    r2_fr1,\n                use r,\n                tidy\n            end,\n        exact \u27e8inj, sur\u27e9\n    end\n\nnoncomputable def invrs (f : A \u27f6 B) (bij : bijective f) : B \u27f6 A :=\n                some (iff.elim_left bijective_iff_has_inverse bij)\n\nlemma invrs_id (f : A \u27f6 B) (bij : bijective f) \n    : \n    f \u2218 (invrs f bij) = id := \n        begin\n            have h0 : left_inverse (some _) f \u2227 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 \u27f6 B) (bij : bijective f) :\n    (invrs f bij) \u2218 f = id := \n    begin\n        have h0 : left_inverse (some _) f \u2227 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 \u27f6 B) : A \u2192 A \u2192 Prop := \n        \u03bb a\u2081 a\u2082 , f a\u2081 = f a\u2082\n\ndef sub_kern (f : A \u27f6 B) (g : A \u2192 C) : Prop :=\n    \u2200 a\u2081 a\u2082, kern f a\u2081 a\u2082 \u2192 kern g a\u2081 a\u2082\n\n@[simp, tidy] def kern_comp (f : A \u27f6 B) (g : B \u2192 C) :\n        sub_kern f (g \u2218 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) \u2228 \u00ac (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            (\u00ac \u2203 s : S , true) \u2192 \n            \u2200 f\u2081 f\u2082  : S \u2192 B, f\u2081 = f\u2082 := \n            assume h f\u2081 f\u2082,\n            show f\u2081 = f\u2082, from \n            have h0 : \u2200 s : S , false := by tidy,\n            by tidy\n\n\nlemma nonempty_notexists {S : set A}: \n        \u00ac nonempty S \u2192 (\u00ac \u2203 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 \u2192 Prop} \n                (ex_uni : \u2203! a , p a)\n                (ex : \u2203 a , p a \u2227 q a)\n        : \u2203! a , p a \u2227 q a := \n        let a : A := some ex_uni in\n        have h : _ := some_spec ex_uni,\n        have h1 : \u2200 a\u2081 , p a\u2081 \u2192 a\u2081 = a :=\n                and.right h,\n        let a\u2081 : A := some ex in\n        have h2 : p a\u2081 \u2227 q a\u2081 := some_spec ex,\n        have h3 : a\u2081 = a := h1 a\u2081 (and.left h2), \n        have h4 : \u2200 a\u2082 , p a\u2082 \u2227 q a\u2082 \u2192 a\u2082 = a\u2081 := \n            \u03bb a\u2082 pq, by rw [h3, (h1 a\u2082 (and.left pq))],\n        exists.intro a\u2081 \u27e8 h2 , h4\u27e9  \n\n\nlemma eq_range_if_surjective  (f: A \u27f6 B) (g: B \u27f6 C)\n    (sur: surjective f) : range g = range (g \u2218 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 \u2218 f)          : by tidy\n\n\nlemma sub_kern_if_injective {X Y Z U : Type u}\n    (e : X \u27f6 Y) (f : Y \u27f6 U)\n    (g : X \u27f6 Z) (m : Z \u27f6 U)\n    (h : e \u226b f = g \u226b m) (inj: injective m) : sub_kern e g := \n        begin\n            assume x\u2081 x\u2082 xxe,\n            have h01 : e x\u2081 = e x\u2082 := xxe,\n            have h02 : m (g x\u2081) = m (g x\u2082) := \n            calc m (g x\u2081) = (g \u226b m) x\u2081    : rfl\n                   ...    = (e \u226b f) x\u2081    : by rw h\n                   ...    = f (e x\u2081)       : rfl\n                   ...    = f (e x\u2082)       : by rw h01\n                   ...    = (e \u226b f) x\u2082    : rfl\n                   ...    = (g \u226b m) x\u2082    : by rw h,\n            exact inj h02\n        end\n\n\nlemma eq_sets {A : Type u} {S T : set A}\n    : (\u2200a : A ,a \u2208 S \u2194 a \u2208 T) \u2194  S = T  := \n    begin \n        split,\n        assume h,\n        have h1 : \u2200s : S , s.val \u2208 T :=\n           \u03bb s, (h s.val).1 s.property,\n        have h2 : \u2200t : T , t.val \u2208 S :=\n           \u03bb 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: \u2200a : A ,a \u2208 S \u2194 a \u2208 T)\n    (f: S \u2192 B):\n    T \u2192 B := \n        \u03bb t , \n        f \u27e8t.val , (h t.val).2 t.property\u27e9\n\n\n@[tidy] lemma eq_fun_of_eq_sets {A B: Type u} (S T : set A) \n    (h: \u2200a : A ,a \u2208 S \u2194 a \u2208 T)\n    (f: S \u2192 B):\n    let fT : T \u2192 B := (fun_of_two_eq_sets h f) in\n    \u2200 s , f s = fT \u27e8 s.val , (h s.val).1 s.property\u27e9 \n    := by tidy\n\n\n\n@[tidy] lemma def_of_range {A B: Type u} (T: set A)\n        (f: T \u2192 B) (b : B) :\n    (\u2203 (a : A) (h : a \u2208 T), f \u27e8a, h\u27e9 = b) \u2194\n    b \u2208 range f := by tidy  \n\n\n@[tidy] lemma eq_ranges {A B: Type u} {S T : set A} \n    (h: \u2200a : A ,a \u2208 S \u2194 a \u2208 T)\n    (f: S \u2192 B):\n    let fT : T \u2192 B := (fun_of_two_eq_sets h f) in\n    range f = range fT\n    := \n    begin\n        intro fT,\n        have h1 : \u2200b : B ,b \u2208 range f \u2194 b \u2208 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 \u27e8 s.val , (h s.val).1 s.property\u27e9 = f s := \n                    eq.symm (eq_fun_of_eq_sets S T h f s),\n\n                have ex : \u2203 t : T , fT t = b := \n                    exists.intro \n                    (\u27e8 s.val , (h s.val).1 s.property\u27e9 : 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 \u2192 Y) (g : Y \u2192 Z) (s : set X):\n    image g (image f s) = image (g \u2218 f) s := \n    begin\n        have h3: \u2200 z : Z, (z \u2208 image g (image f s)) \u2194  \n                    (z \u2208 image (g \u2218 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 \u2208 image f s := \n                    begin use a, tidy end,\n                have gfa_Z : g (f a) \u2208 image g (image f s) :=\n                    begin \n                        use f a,\n                        split,\n                        simp,\n                        tidy\n\n                    end,\n                rw \u2190 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}: \u00ac (p \u2227 q) \u2192 p \u2192 \u00ac q :=\n    \u03bb hnpq , \u03bb hp , \u03bb hq, absurd (and.intro hp hq) hnpq\n\nlemma not_and_right {p q : Prop}: \u00ac (p \u2227 q) \u2192 q \u2192 \u00ac p :=\n    \u03bb hnpq , \u03bb 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 \u00acp\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] : \u2115 := \n    let some_fun : Prop :=         -- same thing with let ... in\n                if p\n                    then p\n                    else \u00acp 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] : \u2115 :=\n    begin\n        let some_fun : Prop :=         -- same thing with let ... in\n                    if p\n                        then p\n                        else \u00acp,\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 : \u2115) : \n        list A          \u2192   \u2115\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 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_Rn : paracompact (euclidean_space n) :=\nbegin\n  sorry\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_max_tokens_2000_n_1/clean_files/Rn is paracompact.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4841782423998309}}
{"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 {\u03b1 : Type u} {\u03b2 : Type v} {s : finset \u03b1} {b : \u03b2} {f : \u03b1 \u2192 \u03b2} \n  [non_unital_non_assoc_semiring \u03b2] : \n  \u2211 (x : \u03b1) in s, b * f x = b * \u2211 (x : \u03b1) in s, f x := finset.mul_sum.symm\n\nexample (n : \u2115) (a : F) (b : fin n -> F) : \n(\u2211 (i : fin n) in finset.fin_range n, a * b i) = a * (\u2211 (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\u2080` and `f\u2081`. 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\u2080 f\u2081 P`, for homotopies between `f\u2080` and `f\u2081`, where the\nintermediate maps satisfy the predicate `P`. Finally, we define\n`continuous_map.homotopy_rel f\u2080 f\u2081 S`, for homotopies between `f\u2080` and `f\u2081` which are fixed\non `S`.\n\n## Definitions\n\n* `continuous_map.homotopy f\u2080 f\u2081` is the type of homotopies between `f\u2080` and `f\u2081`.\n* `continuous_map.homotopy_with f\u2080 f\u2081 P` is the type of homotopies between `f\u2080` and `f\u2081`, where\n  the intermediate maps satisfy the predicate `P`.\n* `continuous_map.homotopy_rel f\u2080 f\u2081 S` is the type of homotopies between `f\u2080` and `f\u2081` 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\u2080 f\u2081`,\n  then `F.symm : continuous_map.homotopy f\u2081 f\u2080`.\n* `trans F G`, which concatenates the homotopies `F` and `G`. For example, if\n  `F : continuous_map.homotopy f\u2080 f\u2081` and `G : continuous_map.homotopy f\u2081 f\u2082`, then\n  `F.trans G : continuous_map.homotopy f\u2080 f\u2082`.\n\nWe also define the relations\n\n* `continuous_map.homotopic f\u2080 f\u2081` is defined to be `nonempty (continuous_map.homotopy f\u2080 f\u2081)`\n* `continuous_map.homotopic_with f\u2080 f\u2081 P` is defined to be\n  `nonempty (continuous_map.homotopy_with f\u2080 f\u2081 P)`\n* `continuous_map.homotopic_rel f\u2080 f\u2081 P` is defined to be\n  `nonempty (continuous_map.homotopy_rel f\u2080 f\u2081 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\u2080 f\u2081` is the type of homotopies from `f\u2080` to `f\u2081`.\n\nWhen possible, instead of parametrizing results over `(f : homotopy f\u2080 f\u2081)`,\nyou should parametrize over `{F : Type*} [homotopy_like F f\u2080 f\u2081] (f : F)`.\n\nWhen you extend this structure, make sure to extend `continuous_map.homotopy_like`. -/\nstructure homotopy (f\u2080 f\u2081 : C(X, Y)) extends C(I \u00d7 X, Y) :=\n(map_zero_left' : \u2200 x, to_fun (0, x) = f\u2080 x)\n(map_one_left' : \u2200 x, to_fun (1, x) = f\u2081 x)\n\n/-- `continuous_map.homotopy_like F f\u2080 f\u2081` states that `F` is a type of homotopies between `f\u2080` and\n`f\u2081`.\n\nYou should extend this class when you extend `continuous_map.homotopy`. -/\nclass homotopy_like (F : Type*) (f\u2080 f\u2081 : out_param $ C(X, Y))\n  extends continuous_map_class F (I \u00d7 X) Y :=\n(map_zero_left (f : F) : \u2200 x, f (0, x) = f\u2080 x)\n(map_one_left (f : F) : \u2200 x, f (1, x) = f\u2081 x)\n\n-- `f\u2080` and `f\u2081` 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\u2080 f\u2081 : C(X, Y)}\n\ninstance : homotopy_like (homotopy f\u2080 f\u2081) f\u2080 f\u2081 :=\n{ coe := \u03bb f, f.to_fun,\n  coe_injective' := \u03bb f g h, by { obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := f, obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := g, congr' },\n  map_continuous := \u03bb f, f.continuous_to_fun,\n  map_zero_left := \u03bb f, f.map_zero_left',\n  map_one_left := \u03bb 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\u2080 f\u2081) (\u03bb _, I \u00d7 X \u2192 Y) := fun_like.has_coe_to_fun\n\n@[ext]\nlemma ext {F G : homotopy f\u2080 f\u2081} (h : \u2200 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\u2080 f\u2081) : I \u00d7 X \u2192 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\u2080 f\u2081) : continuous F := F.continuous_to_fun\n\n@[simp]\nlemma apply_zero (F : homotopy f\u2080 f\u2081) (x : X) : F (0, x) = f\u2080 x := F.map_zero_left' x\n\n@[simp]\nlemma apply_one (F : homotopy f\u2080 f\u2081) (x : X) : F (1, x) = f\u2081 x := F.map_one_left' x\n\n@[simp]\nlemma coe_to_continuous_map (F : homotopy f\u2080 f\u2081) : \u21d1F.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\u2080 f\u2081) : C(I, C(X, Y)) := F.to_continuous_map.curry\n\n@[simp]\nlemma curry_apply (F : homotopy f\u2080 f\u2081) (t : I) (x : X) : F.curry t x = F (t, x) := rfl\n\n/--\nContinuously extending a curried homotopy to a function from `\u211d` to `C(X, Y)`.\n-/\ndef extend (F : homotopy f\u2080 f\u2081) : C(\u211d, C(X, Y)) := F.curry.Icc_extend zero_le_one\n\nlemma extend_apply_of_le_zero (F : homotopy f\u2080 f\u2081) {t : \u211d} (ht : t \u2264 0) (x : X) :\n  F.extend t x = f\u2080 x :=\nbegin\n  rw [\u2190F.apply_zero],\n  exact continuous_map.congr_fun (set.Icc_extend_of_le_left (@zero_le_one \u211d _) F.curry ht) x,\nend\n\nlemma extend_apply_of_one_le (F : homotopy f\u2080 f\u2081) {t : \u211d} (ht : 1 \u2264 t) (x : X) :\n  F.extend t x = f\u2081 x :=\nbegin\n  rw [\u2190F.apply_one],\n  exact continuous_map.congr_fun (set.Icc_extend_of_right_le (@zero_le_one \u211d _) F.curry ht) x,\nend\n\n@[simp]\nlemma extend_apply_coe (F : homotopy f\u2080 f\u2081) (t : I) (x : X) : F.extend t x = F (t, x) :=\ncontinuous_map.congr_fun (set.Icc_extend_coe (@zero_le_one \u211d _) F.curry t) x\n\n@[simp]\nlemma extend_apply_of_mem_I (F : homotopy f\u2080 f\u2081) {t : \u211d} (ht : t \u2208 I) (x : X) :\n  F.extend t x = F (\u27e8t, ht\u27e9, x) :=\ncontinuous_map.congr_fun (set.Icc_extend_of_mem (@zero_le_one \u211d _) F.curry ht) x\n\nlemma congr_fun {F G : homotopy f\u2080 f\u2081} (h : F = G) (x : I \u00d7 X) : F x = G x :=\ncontinuous_map.congr_fun (congr_arg _ h) x\n\nlemma congr_arg (F : homotopy f\u2080 f\u2081) {x y : I \u00d7 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 := \u03bb x, f x.2,\n  map_zero_left' := \u03bb _, rfl,\n  map_one_left' := \u03bb _, rfl }\n\ninstance : inhabited (homotopy (continuous_map.id X) (continuous_map.id X)) := \u27e8homotopy.refl _\u27e9\n\n/--\nGiven a `homotopy f\u2080 f\u2081`, we can define a `homotopy f\u2081 f\u2080` by reversing the homotopy.\n-/\n@[simps]\ndef symm {f\u2080 f\u2081 : C(X, Y)} (F : homotopy f\u2080 f\u2081) : homotopy f\u2081 f\u2080 :=\n{ to_fun := \u03bb x, F (\u03c3 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\u2080 f\u2081 : C(X, Y)} (F : homotopy f\u2080 f\u2081) : F.symm.symm = F :=\nby { ext, simp }\n\n/--\nGiven `homotopy f\u2080 f\u2081` and `homotopy f\u2081 f\u2082`, we can define a `homotopy f\u2080 f\u2082` by putting the first\nhomotopy on `[0, 1/2]` and the second on `[1/2, 1]`.\n-/\ndef trans {f\u2080 f\u2081 f\u2082 : C(X, Y)} (F : homotopy f\u2080 f\u2081) (G : homotopy f\u2081 f\u2082) :\n  homotopy f\u2080 f\u2082 :=\n{ to_fun := \u03bb x, if (x.1 : \u211d) \u2264 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' := \u03bb x, by norm_num,\n  map_one_left' := \u03bb x, by norm_num }\n\nlemma trans_apply {f\u2080 f\u2081 f\u2082 : C(X, Y)} (F : homotopy f\u2080 f\u2081) (G : homotopy f\u2081 f\u2082)\n  (x : I \u00d7 X) : (F.trans G) x =\n  if h : (x.1 : \u211d) \u2264 1/2 then\n    F (\u27e82 * x.1, (unit_interval.mul_pos_mem_iff zero_lt_two).2 \u27e8x.1.2.1, h\u27e9\u27e9, x.2)\n  else\n    G (\u27e82 * x.1 - 1, unit_interval.two_mul_sub_one_mem_iff.2 \u27e8(not_le.1 h).le, x.1.2.2\u27e9\u27e9, 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\u2080 f\u2081 f\u2082 : C(X, Y)} (F : homotopy f\u2080 f\u2081) (G : homotopy f\u2081 f\u2082) :\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\u2081 h\u2082,\n  { change (x.1 : \u211d) \u2264 _ at h\u2082,\n    change (1 : \u211d) - x.1 \u2264 _ at h\u2081,\n    have ht : (x.1 : \u211d) = 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 \u00ac (x.1 : \u211d) \u2264 _ at h,\n    change \u00ac (1 : \u211d) - x.1 \u2264 _ at h\u2081,\n    exfalso, linarith }\nend\n\n/--\nCasting a `homotopy f\u2080 f\u2081` to a `homotopy g\u2080 g\u2081` where `f\u2080 = g\u2080` and `f\u2081 = g\u2081`.\n-/\n@[simps]\ndef cast {f\u2080 f\u2081 g\u2080 g\u2081 : C(X, Y)} (F : homotopy f\u2080 f\u2081) (h\u2080 : f\u2080 = g\u2080) (h\u2081 : f\u2081 = g\u2081) :\n  homotopy g\u2080 g\u2081 :=\n{ to_fun := F,\n  map_zero_left' := by simp [\u2190h\u2080],\n  map_one_left' := by simp [\u2190h\u2081] }\n\n/--\nIf we have a `homotopy f\u2080 f\u2081` and a `homotopy g\u2080 g\u2081`, then we can compose them and get a\n`homotopy (g\u2080.comp f\u2080) (g\u2081.comp f\u2081)`.\n-/\n@[simps]\ndef hcomp {f\u2080 f\u2081 : C(X, Y)} {g\u2080 g\u2081 : C(Y, Z)} (F : homotopy f\u2080 f\u2081) (G : homotopy g\u2080 g\u2081) :\n  homotopy (g\u2080.comp f\u2080) (g\u2081.comp f\u2081) :=\n{ to_fun := \u03bb 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\u2080` and `f\u2081`, we say `f\u2080` and `f\u2081` are homotopic if there exists a\n`homotopy f\u2080 f\u2081`.\n-/\ndef homotopic (f\u2080 f\u2081 : C(X, Y)) : Prop :=\nnonempty (homotopy f\u2080 f\u2081)\n\nnamespace homotopic\n\n@[refl]\nlemma refl (f : C(X, Y)) : homotopic f f := \u27e8homotopy.refl f\u27e9\n\n@[symm]\nlemma symm \u2983f g : C(X, Y)\u2984 (h : homotopic f g) : homotopic g f := h.map homotopy.symm\n\n@[trans]\n\n\nlemma hcomp {f\u2080 f\u2081 : C(X, Y)} {g\u2080 g\u2081 : C(Y, Z)} (h\u2080 : homotopic f\u2080 f\u2081) (h\u2081 : homotopic g\u2080 g\u2081) :\n  homotopic (g\u2080.comp f\u2080) (g\u2081.comp f\u2081) :=\nh\u2080.map2 homotopy.hcomp h\u2081\n\nlemma equivalence : equivalence (@homotopic X Y _ _) := \u27e8refl, symm, trans\u27e9\n\nend homotopic\n\n/--\nThe type of homotopies between `f\u2080 f\u2081 : C(X, Y)`, where the intermediate maps satisfy the predicate\n`P : C(X, Y) \u2192 Prop`\n-/\nstructure homotopy_with (f\u2080 f\u2081 : C(X, Y)) (P : C(X, Y) \u2192 Prop) extends homotopy f\u2080 f\u2081 :=\n(prop' : \u2200 t, P \u27e8\u03bb x, to_fun (t, x),\n  continuous.comp continuous_to_fun (continuous_const.prod_mk continuous_id')\u27e9)\n\nnamespace homotopy_with\n\nsection\n\nvariables {f\u2080 f\u2081 : C(X, Y)} {P : C(X, Y) \u2192 Prop}\n\ninstance : has_coe_to_fun (homotopy_with f\u2080 f\u2081 P) (\u03bb _, I \u00d7 X \u2192 Y) := \u27e8\u03bb F, F.to_fun\u27e9\n\nlemma coe_fn_injective : @function.injective (homotopy_with f\u2080 f\u2081 P) (I \u00d7 X \u2192 Y) coe_fn :=\nbegin\n  rintros \u27e8\u27e8\u27e8F, _\u27e9, _\u27e9, _\u27e9 \u27e8\u27e8\u27e8G, _\u27e9, _\u27e9, _\u27e9 h,\n  congr' 3,\nend\n\n@[ext]\nlemma ext {F G : homotopy_with f\u2080 f\u2081 P} (h : \u2200 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\u2080 f\u2081 P) : I \u00d7 X \u2192 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\u2080 f\u2081 P) : continuous F := F.continuous_to_fun\n\n@[simp]\nlemma apply_zero (F : homotopy_with f\u2080 f\u2081 P) (x : X) : F (0, x) = f\u2080 x := F.map_zero_left' x\n\n@[simp]\nlemma apply_one (F : homotopy_with f\u2080 f\u2081 P) (x : X) : F (1, x) = f\u2081 x := F.map_one_left' x\n\n@[simp]\nlemma coe_to_continuous_map (F : homotopy_with f\u2080 f\u2081 P) : \u21d1F.to_continuous_map = F := rfl\n\n@[simp]\nlemma coe_to_homotopy (F : homotopy_with f\u2080 f\u2081 P) : \u21d1F.to_homotopy = F := rfl\n\nlemma prop (F : homotopy_with f\u2080 f\u2081 P) (t : I) : P (F.to_homotopy.curry t) := F.prop' t\n\nlemma extend_prop (F : homotopy_with f\u2080 f\u2081 P) (t : \u211d) : P (F.to_homotopy.extend t) :=\nbegin\n  by_cases ht\u2080 : 0 \u2264 t,\n  { by_cases ht\u2081 : t \u2264 1,\n    { convert F.prop \u27e8t, ht\u2080, ht\u2081\u27e9,\n      ext,\n      rw [F.to_homotopy.extend_apply_of_mem_I \u27e8ht\u2080, ht\u2081\u27e9, 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\u2081), 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\u2080), F.to_homotopy.curry_apply,\n        F.to_homotopy.apply_zero] }\nend\n\nend\n\nvariable {P : C(X, Y) \u2192 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' := \u03bb t, by { convert hf, cases f, refl },\n  ..homotopy.refl f }\n\ninstance : inhabited (homotopy_with (continuous_map.id X) (continuous_map.id X) (\u03bb f, true)) :=\n\u27e8homotopy_with.refl _ trivial\u27e9\n\n/--\nGiven a `homotopy_with f\u2080 f\u2081 P`, we can define a `homotopy_with f\u2081 f\u2080 P` by reversing the homotopy.\n-/\n@[simps]\ndef symm {f\u2080 f\u2081 : C(X, Y)} (F : homotopy_with f\u2080 f\u2081 P) : homotopy_with f\u2081 f\u2080 P :=\n{ prop' := \u03bb t, by simpa using F.prop (\u03c3 t),\n  ..F.to_homotopy.symm }\n\n@[simp]\nlemma symm_symm {f\u2080 f\u2081 : C(X, Y)} (F : homotopy_with f\u2080 f\u2081 P) : F.symm.symm = F :=\next $ homotopy.congr_fun $ homotopy.symm_symm _\n\n/--\nGiven `homotopy_with f\u2080 f\u2081 P` and `homotopy_with f\u2081 f\u2082 P`, we can define a `homotopy_with f\u2080 f\u2082 P`\nby putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.\n-/\ndef trans {f\u2080 f\u2081 f\u2082 : C(X, Y)} (F : homotopy_with f\u2080 f\u2081 P) (G : homotopy_with f\u2081 f\u2082 P) :\n  homotopy_with f\u2080 f\u2082 P :=\n{ prop' := \u03bb t, begin\n    simp only [homotopy.trans],\n    change P \u27e8\u03bb _, ite ((t : \u211d) \u2264 _) _ _, _\u27e9,\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\u2080 f\u2081 f\u2082 : C(X, Y)} (F : homotopy_with f\u2080 f\u2081 P) (G : homotopy_with f\u2081 f\u2082 P)\n  (x : I \u00d7 X) : (F.trans G) x =\n  if h : (x.1 : \u211d) \u2264 1/2 then\n    F (\u27e82 * x.1, (unit_interval.mul_pos_mem_iff zero_lt_two).2 \u27e8x.1.2.1, h\u27e9\u27e9, x.2)\n  else\n    G (\u27e82 * x.1 - 1, unit_interval.two_mul_sub_one_mem_iff.2 \u27e8(not_le.1 h).le, x.1.2.2\u27e9\u27e9, x.2) :=\nhomotopy.trans_apply _ _ _\n\nlemma symm_trans {f\u2080 f\u2081 f\u2082 : C(X, Y)} (F : homotopy_with f\u2080 f\u2081 P) (G : homotopy_with f\u2081 f\u2082 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\u2080 f\u2081 P` to a `homotopy_with g\u2080 g\u2081 P` where `f\u2080 = g\u2080` and `f\u2081 = g\u2081`.\n-/\n@[simps]\ndef cast {f\u2080 f\u2081 g\u2080 g\u2081 : C(X, Y)} (F : homotopy_with f\u2080 f\u2081 P) (h\u2080 : f\u2080 = g\u2080) (h\u2081 : f\u2081 = g\u2081) :\n  homotopy_with g\u2080 g\u2081 P :=\n{ prop' := F.prop,\n  ..F.to_homotopy.cast h\u2080 h\u2081 }\n\nend homotopy_with\n\n/--\nGiven continuous maps `f\u2080` and `f\u2081`, we say `f\u2080` and `f\u2081` are homotopic with respect to the\npredicate `P` if there exists a `homotopy_with f\u2080 f\u2081 P`.\n-/\ndef homotopic_with (f\u2080 f\u2081 : C(X, Y)) (P : C(X, Y) \u2192 Prop) : Prop :=\nnonempty (homotopy_with f\u2080 f\u2081 P)\n\nnamespace homotopic_with\n\nvariable {P : C(X, Y) \u2192 Prop}\n\n@[refl]\nlemma refl (f : C(X, Y)) (hf : P f) : homotopic_with f f P :=\n\u27e8homotopy_with.refl f hf\u27e9\n\n@[symm]\nlemma symm \u2983f g : C(X, Y)\u2984 (h : homotopic_with f g P) : homotopic_with g f P := \u27e8h.some.symm\u27e9\n\n@[trans]\nlemma trans \u2983f g h : C(X, Y)\u2984 (h\u2080 : homotopic_with f g P) (h\u2081 : homotopic_with g h P) :\n  homotopic_with f h P :=\n\u27e8h\u2080.some.trans h\u2081.some\u27e9\n\nend homotopic_with\n\n/--\nA `homotopy_rel f\u2080 f\u2081 S` is a homotopy between `f\u2080` and `f\u2081` which is fixed on the points in `S`.\n-/\nabbreviation homotopy_rel (f\u2080 f\u2081 : C(X, Y)) (S : set X) :=\nhomotopy_with f\u2080 f\u2081 (\u03bb f, \u2200 x \u2208 S, f x = f\u2080 x \u2227 f x = f\u2081 x)\n\nnamespace homotopy_rel\n\nsection\n\nvariables {f\u2080 f\u2081 : C(X, Y)} {S : set X}\n\nlemma eq_fst (F : homotopy_rel f\u2080 f\u2081 S) (t : I) {x : X} (hx : x \u2208 S) :\n  F (t, x) = f\u2080 x := (F.prop t x hx).1\n\nlemma eq_snd (F : homotopy_rel f\u2080 f\u2081 S) (t : I) {x : X} (hx : x \u2208 S) :\n  F (t, x) = f\u2081 x := (F.prop t x hx).2\n\nlemma fst_eq_snd (F : homotopy_rel f\u2080 f\u2081 S) {x : X} (hx : x \u2208 S) :\n  f\u2080 x = f\u2081 x := F.eq_fst 0 hx \u25b8 F.eq_snd 0 hx\n\nend\n\nvariables {f\u2080 f\u2081 f\u2082 : 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 (\u03bb x hx, \u27e8rfl, rfl\u27e9)\n\n/--\nGiven a `homotopy_rel f\u2080 f\u2081 S`, we can define a `homotopy_rel f\u2081 f\u2080 S` by reversing the homotopy.\n-/\n@[simps]\ndef symm (F : homotopy_rel f\u2080 f\u2081 S) : homotopy_rel f\u2081 f\u2080 S :=\n{ prop' := \u03bb 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\u2080 f\u2081 S) : F.symm.symm = F :=\nhomotopy_with.symm_symm F\n\n/--\nGiven `homotopy_rel f\u2080 f\u2081 S` and `homotopy_rel f\u2081 f\u2082 S`, we can define a `homotopy_rel f\u2080 f\u2082 S`\nby putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.\n-/\ndef trans (F : homotopy_rel f\u2080 f\u2081 S) (G : homotopy_rel f\u2081 f\u2082 S) : homotopy_rel f\u2080 f\u2082 S :=\n{ prop' := \u03bb t, begin\n    intros x hx,\n    simp only [homotopy.trans],\n    change (\u27e8\u03bb _, ite ((t : \u211d) \u2264 _) _ _, _\u27e9 : C(X, Y)) _ = _ \u2227 _ = _,\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\u2080 f\u2081 S) (G : homotopy_rel f\u2081 f\u2082 S)\n  (x : I \u00d7 X) : (F.trans G) x =\n  if h : (x.1 : \u211d) \u2264 1/2 then\n    F (\u27e82 * x.1, (unit_interval.mul_pos_mem_iff zero_lt_two).2 \u27e8x.1.2.1, h\u27e9\u27e9, x.2)\n  else\n    G (\u27e82 * x.1 - 1, unit_interval.two_mul_sub_one_mem_iff.2 \u27e8(not_le.1 h).le, x.1.2.2\u27e9\u27e9, x.2) :=\nhomotopy.trans_apply _ _ _\n\nlemma symm_trans (F : homotopy_rel f\u2080 f\u2081 S) (G : homotopy_rel f\u2081 f\u2082 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\u2080 f\u2081 S` to a `homotopy_rel g\u2080 g\u2081 S` where `f\u2080 = g\u2080` and `f\u2081 = g\u2081`.\n-/\n@[simps]\ndef cast {f\u2080 f\u2081 g\u2080 g\u2081 : C(X, Y)} (F : homotopy_rel f\u2080 f\u2081 S) (h\u2080 : f\u2080 = g\u2080) (h\u2081 : f\u2081 = g\u2081) :\n  homotopy_rel g\u2080 g\u2081 S :=\n{ prop' := \u03bb t x hx, by { simpa [\u2190h\u2080, \u2190h\u2081] using F.prop t x hx },\n  ..homotopy.cast F.to_homotopy h\u2080 h\u2081 }\n\nend homotopy_rel\n\n/--\nGiven continuous maps `f\u2080` and `f\u2081`, we say `f\u2080` and `f\u2081` are homotopic relative to a set `S` if\nthere exists a `homotopy_rel f\u2080 f\u2081 S`.\n-/\ndef homotopic_rel (f\u2080 f\u2081 : C(X, Y)) (S : set X) : Prop :=\nnonempty (homotopy_rel f\u2080 f\u2081 S)\n\nnamespace homotopic_rel\n\nvariable {S : set X}\n\n@[refl]\nlemma refl (f : C(X, Y)) : homotopic_rel f f S := \u27e8homotopy_rel.refl f S\u27e9\n\n@[symm]\nlemma symm \u2983f g : C(X, Y)\u2984 (h : homotopic_rel f g S) : homotopic_rel g f S :=\n  h.map homotopy_rel.symm\n\n@[trans]\nlemma trans \u2983f g h : C(X, Y)\u2984 (h\u2080 : homotopic_rel f g S) (h\u2081 : homotopic_rel g h S) :\n  homotopic_rel f h S :=\nh\u2080.map2 homotopy_rel.trans h\u2081\n\nlemma equivalence : equivalence (\u03bb f g : C(X, Y), homotopic_rel f g S) :=\n\u27e8refl, symm, trans\u27e9\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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n\nlemma is_ring_hom.inj_of_kernel_eq_zero [comm_ring \u03b1] [comm_ring \u03b2] {f : \u03b1 \u2192 \u03b2} [hf : is_ring_hom f] \n    (h : \u2200 {x}, f x = 0 \u2192 x = 0) : function.injective f := \n\u03bb x y hxy, by rw [\u2190 sub_eq_zero_iff_eq, \u2190 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 \u03b1] {I : Type v} {f : I \u2192 Type w} [\u2200 i, comm_ring (f i)]\n(g : \u03b1 \u2192 \u03a0 i : I, f i) [rh : \u2200 i : I, is_ring_hom (\u03bb a : \u03b1, g a i)] : is_ring_hom g :=\n{ map_add := \u03bb x y, funext $ \u03bb i, @is_ring_hom.map_add _ _ _ _ _ (rh i) x y,\n  map_mul := \u03bb x y, funext $ \u03bb i, @is_ring_hom.map_mul _ _ _ _ _ (rh i) x y,\n  map_one := funext $ \u03bb i, @is_ring_hom.map_one _ _ _ _ _ (rh i) }\n\nopen finset\n\nlemma exists_sum_iff_mem_span_finset {x : \u03b2} [ring \u03b1] [module \u03b1 \u03b2] {s : finset \u03b2} \n    : x \u2208 span (\u2191s : set \u03b2) \u2194 \u2203 r : \u03b2 \u2192 \u03b1, x = s.sum (\u03bb y, r y \u2022 y) :=\n\u27e8\u03bb \u27e8r, hr\u27e9, \u27e8r, hr.2.symm \u25b8 sum_bij_ne_zero (\u03bb a _ _, a)\n  (\u03bb a has ha, classical.by_contradiction (\u03bb h, ha (by simp [hr.1 _ h])))\n  (\u03bb _ _ _ _ _ _, id)\n  (\u03bb b hbr hb, \u27e8b, (finsupp.mem_support_iff).2 (\u03bb h, hb (by simp [h])), hb, rfl\u27e9)\n  (\u03bb _ _ _, rfl)\u27e9,\n\u03bb \u27e8r, hr\u27e9, hr.symm \u25b8 is_submodule.sum (\u03bb c hc, is_submodule.smul _ (subset_span hc))\u27e9\n\nlemma exists_sum_iff_mem_span_image_finset {x : \u03b2} [ring \u03b1] [module \u03b1 \u03b2] {s : finset \u03b3}\n    {f : \u03b3 \u2192 \u03b2} : x \u2208 span (\u2191(s.image f) : set \u03b2) \u2194 \n    \u2203 r : \u03b3 \u2192 \u03b1, x = s.sum (\u03bb b, r b \u2022 f b) :=\n\u27e8\u03bb h, let \u27e8r, hr\u27e9 := exists_sum_iff_mem_span_finset.1 h in\nhave hc : \u2200 y \u2208 s, \u2203 z \u2208 s, f z = f y := \u03bb y hy, \u27e8y, hy, rfl\u27e9,\n\u27e8\u03bb y, if \u2203 hy : y \u2208 s, y = some (hc y hy) then r (f y) else 0, \n  hr.symm \u25b8 sum_bij_ne_zero (\u03bb a ha _, some (mem_image.1 ha)) \n    (\u03bb a ha _, let \u27e8h, _\u27e9 := some_spec (mem_image.1 ha) in h) \n    (\u03bb a\u2081 a\u2082 ha\u2081 _ ha\u2082 _ h, \n      let \u27e8_, h\u2081\u27e9 := some_spec (mem_image.1 ha\u2081) in\n      let \u27e8_, h\u2082\u27e9 := some_spec (mem_image.1 ha\u2082) in\n      h\u2081 \u25b8 h\u2082 \u25b8 h \u25b8 rfl)\n    (\u03bb b hbs hb0,\n      have hfb : f b \u2208 image f s := mem_image.2 \u27e8b, hbs, rfl\u27e9,\n      have hb : b = some (mem_image.1 hfb) := classical.by_contradiction\n        (\u03bb h, have h' : \u00ac\u2203 (x : b \u2208 s), b = some _ := not_exists.2 (\u03bb hy : b \u2208 s, h), \n        by rw [if_neg h', zero_smul] at hb0; exact hb0 rfl),\n      \u27e8f b, hfb, by rwa if_pos at hb0; exact \u27e8hbs, hb\u27e9, hb\u27e9)\n    (\u03bb a ha ha0, let \u27e8h\u2081, h\u2082\u27e9 := some_spec (mem_image.1 ha) in\n      by rw [if_pos, h\u2082]; exact \u27e8h\u2081, by simp only [h\u2082]\u27e9)\u27e9,\n\u03bb \u27e8r, hr\u27e9, hr.symm \u25b8 is_submodule.sum (\u03bb c hc, is_submodule.smul _ \n    (subset_span (mem_image.2 \u27e8c, hc, rfl\u27e9)))\u27e9\n \nlemma sum_pow_mem_span {\u03b1 R : Type*} [comm_ring R] (s : finset \u03b1)\n    (f : \u03b1 \u2192 R) (n : \u03b1 \u2192 \u2115) (r : \u03b1 \u2192 R) : s.sum (\u03bb a, r a \u2022 f a) ^ (s.sum n + 1) \u2208 span \n    (\u2191(s.image (\u03bb a, f a ^ n a)) : set R) :=\nfinset.induction_on s (by simp) $ \u03bb a s has hi, \nbegin\n  rw [sum_insert has, add_pow],\n  refine @is_submodule.sum R R _ _ (span _) _ _ _ _ _ (\u03bb k hk, _),\n  cases le_total (n a) k with hak hak,\n  { rw [\u2190 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 \u27e8a, mem_insert_self _ _, rfl\u27e9)) },\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 \u2191(image (\u03bb a, f a ^ n a) s) \u2286 span \u2191(image (\u03bb 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 {\u03b1 R : Type*} [comm_ring R] {s : finset \u03b1}\n    {f : \u03b1 \u2192 R} (n : \u03b1 \u2192 \u2115) (h : (1 : R) \u2208 span (\u2191(s.image f) : set R)) : \n    (1 : R) \u2208 span (\u2191(s.image (\u03bb x, f x ^ n x)) : set R) :=\nlet \u27e8r, hr\u27e9 := exists_sum_iff_mem_span_image_finset.1 h in\n@one_pow R _ (s.sum n + 1) \u25b8 hr.symm \u25b8 sum_pow_mem_span _ _ _ _\n\nend\n\nvariables {R : Type u} {\u03b3 : Type v} [comm_ring R] [fintype \u03b3]\nopen localization\n\ndef tag00EJ.\u03b1 (f : \u03b3 \u2192 R) (x : R) : \u03a0 i, loc R (powers (f i)) :=\n  \u03bb i, of_comm_ring R _ x\n\nnoncomputable def tag00EJ.\u03b2 {f : \u03b3 \u2192 R}\n    (r : \u03a0 i, loc R (powers (f i))) (j k : \u03b3) :\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-- \u03b2 not a ring hom but it's \u03b2\u2081 - \u03b2\u2082 with ring homs defined below.\n\nnoncomputable def tag00EJ.\u03b2\u2081 {f : \u03b3 \u2192 R}\n    (r : \u03a0 i, loc R (powers (f i))) (j k : \u03b3) :\n    loc R (powers (f j * f k)) :=\nlocalize_more_left (f j) (f k) (r j)\n\nnoncomputable def tag00EJ.\u03b2\u2082 {f : \u03b3 \u2192 R}\n    (r : \u03a0 i, loc R (powers (f i))) (j k : \u03b3) :\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 : \u2115) : \n    localize_more_left f g \u27e6\u27e8x, \u27e8f^n, n, rfl\u27e9\u27e9\u27e7 = \u27e6\u27e8x * g^n, (f * g)^n, n, rfl\u27e9\u27e7 :=\nbegin\n  let h,\n  show \u27e6_\u27e7 * classical.some h = \u27e6_\u27e7,\n  have := some_spec h,\n  rw \u2190 quotient.out_eq (some h) at *,\n  rcases out (some h) with \u27e8s\u2081, s\u2082, hs\u27e9, intro this,\n  rcases quotient.exact this with \u27e8r, hr\u2081, hr\u2082\u27e9,\n  refine quot.sound \u27e8r, hr\u2081, _\u27e9,\n  rw [sub_mul, sub_eq_zero_iff_eq] at hr\u2082,\n  have hr\u2082' : s\u2082 * r = f ^ n * s\u2081 * r,\n  { simpa using hr\u2082 },\n  suffices : (s\u2082 * (x * g ^ n) - ((f * g) ^ n * (x * s\u2081))) * r = 0,\n  { rw \u2190 this, simp },\n  simp only [sub_mul, mul_pow, mul_assoc, mul_left_comm s\u2082,\n      mul_comm r, mul_left_comm r, hr\u2082'],\n  ring\nend\n\nlemma localize_more_right_eq (f g x : R) (n : \u2115) : \n    localize_more_right f g \u27e6\u27e8x, \u27e8g^n, n, rfl\u27e9\u27e9\u27e7 = \u27e6\u27e8x * f^n, (f * g)^n, n, rfl\u27e9\u27e7 := \nbegin\n  let h,\n  show \u27e6_\u27e7 * classical.some h = \u27e6_\u27e7,\n  have := some_spec h,\n  rw \u2190 quotient.out_eq (some h) at *,\n  rcases out (some h) with \u27e8s\u2081, s\u2082, hs\u27e9, intro this,\n  rcases quotient.exact this with \u27e8r, hr\u2081, hr\u2082\u27e9,\n  refine quot.sound \u27e8r, hr\u2081, _\u27e9,\n  rw [sub_mul, sub_eq_zero_iff_eq] at hr\u2082,\n  have hr\u2082' : s\u2082 * r = g ^ n * s\u2081 * r,\n  { simpa using hr\u2082 },\n  suffices : (s\u2082 * (x * f ^ n) - ((f * g) ^ n * (x * s\u2081))) * r = 0,\n  { rw \u2190 this, simp },\n  simp only [sub_mul, mul_pow, mul_assoc, mul_left_comm s\u2082, \n      mul_comm r, mul_left_comm r, hr\u2082'],\n  ring\nend\n\nlemma lemma_standard_covering\u2081 {f : \u03b3 \u2192 R}\n    (h : (1 : R) \u2208 span (\u2191(univ.image f) : set R)) : function.injective (\u03b1 f) :=\n@is_ring_hom.inj_of_kernel_eq_zero _ _ _ _ (\u03b1 f) \n  (@indexed_product.is_ring_hom _ _ _ _ _ (\u03b1 f) \n  (\u03bb i, by unfold \u03b1; apply_instance))\nbegin \n  assume x hx,\n  replace hx := congr_fun hx,\n  have : \u2200 i, \u2203 e : \u2115, f i ^ e * x = 0 := \u03bb i, begin\n    rcases (quotient.eq.1 (hx i)) with \u27e8r, hr\u2081, hr\u2082\u27e9,\n    cases hr\u2081 with e he,\n    have : x * r = 0 := by simpa using hr\u2082,\n    exact \u27e8e, by rwa [mul_comm, he]\u27e9\n  end,\n  let e : \u03b3 \u2192 \u2115 := \u03bb i, classical.some (this i),\n  have he : \u2200 i, f i ^ e i * x = 0 := \u03bb 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 [\u2190 one_mul x, hr, sum_mul, \u2190 @sum_const_zero _ _ (univ : finset \u03b3)],\n  refine finset.sum_congr rfl (\u03bb i _, _),\n  rw [smul_eq_mul, mul_assoc, he, mul_zero],\nend\n\nlemma lemma_standard_covering\u2082 (f : \u03b3 \u2192 R) \n    (H : (1:R) \u2208 span (\u2191(univ.image f) : set R)) (s : \u03a0 i, loc R (powers (f i))) :\n    \u03b2 s = 0 \u2194 \u2203 r : R, \u03b1 f r = s := \n\u27e8\u03bb h : \u03b2 s = 0,\nlet t := \u03bb i, out (s i) in\nlet r := \u03bb i, some (t i).2.2 in\nhave hst : \u2200 i, s i = \u27e6\u27e8(t i).1, (f i) ^ (r i), r i, rfl\u27e9\u27e7 := \n    \u03bb i, by simp [r, some_spec (t i).2.2],\nhave hi : \u2200 i, s i = \u27e6\u27e8(t i).1, (t i).2.1, (t i).2.2\u27e9\u27e7 := \u03bb i, by simp,\nhave h\u03b2 : _ := \u03bb i j, sub_eq_zero_iff_eq.1 $ show \u03b2 s i j = 0, by rw h; refl,\nhave h\u03b2 : \u2200 i j,\n    (\u27e6\u27e8(t i).1 * f j ^ r i, \u27e8(f i * f j) ^ r i, r i, rfl\u27e9\u27e9\u27e7 : loc R (powers (f i * f j))) =\n    \u27e6\u27e8(t j).1 * f i ^ r j, \u27e8(f i * f j) ^ r j, r j, rfl\u27e9\u27e9\u27e7 := by conv at h\u03b2 in (_ = _) {rw [hst, hst,\n      localize_more_left_eq, localize_more_right_eq] }; exact h\u03b2,\nhave \u2200 i j, \u2203 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  \u03bb i j, let \u27e8t, \u27e8n, hn\u27e9, hnt\u27e9 := quotient.exact (h\u03b2 i j) \n      in \u27e8n, by rw hn; exact hnt\u27e9,\nlet n := \u03bb i j, some (this i j) + r i + r j in\nhave hn : \u2200 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  \u03bb i j, by rw [\u2190 zero_mul (f i ^ r i), \n      \u2190 zero_mul (f j ^ r j), \u2190 some_spec (this i j)];\n    simp [n, pow_add, mul_pow];\n    ring,\nlet N := finset.sum (univ : finset (_ \u00d7 _)) (\u03bb ij, n ij.1 ij.2) in\nhave Nlt : \u2200 i j, n i j \u2264 N := \u03bb i j, \n  @single_le_sum _ _ _ (\u03bb h : \u03b3 \u00d7 \u03b3, n h.1 h.2) _\n  _ (\u03bb _ _, nat.zero_le _) _ (mem_univ (i, j)),\nhave hN : \u2200 i j, (f i ^ r i * (t j).1 - \n    f j ^ r j * (t i).1) * (f i * f j) ^ N = 0 := \u03bb i j, \n  begin rw [\u2190 nat.sub_add_cancel (Nlt i j), \n      \u2190 zero_mul ((f i * f j) ^ (N - n i j)), \u2190 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 \u27e8a, ha\u27e9 := exists_sum_iff_mem_span_image_finset.1 \n    (one_mem_span_pow_of_mem_span (\u03bb i, N + r i) H) in\n\u27e8univ.sum (\u03bb j, a j * (f j) ^ N * (t j).1),\nfunext (\u03bb i, (hst i).symm \u25b8 quot.sound \u27e8(f i) ^ N, \u27e8N, rfl\u27e9,\nhave (\u03bb j, f i ^ r i * (a j * f j ^ N * (t j).fst) * f i ^ N) =\n      (\u03bb j, (a j \u2022 (f j) ^ (N + r j) * (t i).1) * (f i) ^ N) := funext (\u03bb j, begin\n  rw [\u2190 sub_eq_zero_iff_eq, smul_eq_mul],\n  simp only [mul_assoc, mul_left_comm _ (a j)],\n  rw [\u2190 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 \u2190 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 (\u03bb 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, \u2190 sum_mul, \u2190 sum_mul, \u2190 ha, one_mul, sub_self]\nend\u27e9)\u27e9,\n\u03bb \u27e8r, hr\u27e9, hr \u25b8 show \u03b2 (\u03b1 f r) = \u03bb i j, 0, from funext $ \u03bb i, funext $ \u03bb j, \n  sub_eq_zero_iff_eq.2 $ loc_commutes _ _ _\u27e9\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) (\u03b5 : \u211d) (\u03b5_pos : 0 < \u03b5)\n  {\u03d5 : X \u2192 \u211d} (cont : continuous \u03d5) (nonneg : \u2200 y, 0 \u2264 \u03d5 y) :\n  \u2203 (\u03b5' > 0) (x' : X), \u03b5' \u2264 \u03b5 \u2227\n                       d x' x \u2264 2*\u03b5 \u2227\n                       \u03b5 * \u03d5(x) \u2264 \u03b5' * \u03d5 x' \u2227\n                       \u2200 y, d x' y \u2264 \u03b5' \u2192 \u03d5 y \u2264 2*\u03d5 x' :=\nbegin\n  by_contradiction H,\n  have reformulation : \u2200 x' (k : \u2115), \u03b5 * \u03d5 x \u2264 \u03b5 / 2 ^ k * \u03d5 x' \u2194 2^k * \u03d5 x \u2264 \u03d5 x',\n  { intros x' k,\n    rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left \u03b5_pos, mul_comm],\n    exact pow_pos (by norm_num) k, },\n  -- Now let's specialize to `\u03b5/2^k`\n  replace H : \u2200 k : \u2115, \u2200 x', d x' x \u2264 2 * \u03b5 \u2227 2^k * \u03d5 x \u2264 \u03d5 x' \u2192\n    \u2203 y, d x' y \u2264 \u03b5/2^k \u2227 2 * \u03d5 x' < \u03d5 y,\n  { intros k x',\n    push_neg at H,\n    simpa [reformulation] using\n      H (\u03b5/2^k) (by simp [\u03b5_pos, zero_lt_two]) x' (by simp [\u03b5_pos, zero_lt_two, one_le_two]) },\n  clear reformulation,\n  haveI : nonempty X := \u27e8x\u27e9,\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 : \u2115 \u2192 X := \u03bb 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    \u2200 n,\n      d (u n) x \u2264 2 * \u03b5 \u2227 2^n * \u03d5 x \u2264 \u03d5 (u n) \u2192\n      d (u n) (u $ n + 1) \u2264 \u03b5 / 2 ^ n \u2227 2 * \u03d5 (u n) < \u03d5 (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 : \u2200 n, d (u n) (u (n + 1)) \u2264 \u03b5 / 2 ^ n \u2227 2 * \u03d5 (u n) < \u03d5 (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, \u03b5_pos.le, le_refl] using hu },\n    have A : d (u (n+1)) x \u2264 2 * \u03b5,\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          \u2264 \u2211 i in r, d (u i) (u $ i+1) : dist_le_range_sum_dist u (n + 1)\n      ... \u2264 \u2211 i in r, \u03b5/2^i             : sum_le_sum (\u03bb i i_in, (IH i $ nat.lt_succ_iff.mp $\n                                                                  finset.mem_range.mp i_in).1)\n      ... = \u2211 i in r, (1/2)^i*\u03b5         : by { congr' with i, field_simp }\n      ... = (\u2211 i in r, (1/2)^i)*\u03b5       : finset.sum_mul.symm\n      ... \u2264 2*\u03b5                         : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                            (le_of_lt \u03b5_pos), },\n    have B : 2^(n+1) * \u03d5 x \u2264 \u03d5 (u (n + 1)),\n    { refine @geom_le (\u03d5 \u2218 u) _ zero_le_two (n + 1) (\u03bb m hm, _),\n      exact (IH _ $ nat.lt_add_one_iff.1 hm).2.le },\n    exact hu (n+1) \u27e8A, B\u27e9, },\n  cases forall_and_distrib.mp key with key\u2081 key\u2082,\n  clear hu key,\n  -- Hence u is Cauchy\n  have cauchy_u : cauchy_seq u,\n  { refine cauchy_seq_of_le_geometric _ \u03b5 one_half_lt_one (\u03bb n, _),\n    simpa only [one_div, inv_pow'] using key\u2081 n },\n  -- So u converges to some y\n  obtain \u27e8y, limy\u27e9 : \u2203 y, tendsto u at_top (\ud835\udcdd y),\n    from complete_space.complete cauchy_u,\n  -- And \u03d5 \u2218 u goes to +\u221e\n  have lim_top : tendsto (\u03d5 \u2218 u) at_top at_top,\n  { let v := \u03bb n, (\u03d5 \u2218 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\u2080 : 0 < v 0,\n    { have : 0 \u2264 \u03d5 (u 0) := nonneg x,\n      calc 0 \u2264 2 * \u03d5 (u 0) : by linarith\n      ... < \u03d5 (u (0 + 1)) : key\u2082 0 },\n    apply tendsto_at_top_of_geom_le hv\u2080 one_lt_two,\n    exact \u03bb n, (key\u2082 (n+1)).le },\n  -- But \u03d5 \u2218 u also needs to go to \u03d5(y)\n  have lim : tendsto (\u03d5 \u2218 u) at_top (\ud835\udcdd (\u03d5 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 : (\u00ac\u00aca \u2192 a) \u2192 Stable a\n\nabbrev inferStable (a : Prop) [inst : Stable a] := inst\n\nprotected def Stable.by_contradiction {a : Prop} [inst : Stable a] : \u00ac\u00aca \u2192 a :=\n  match inst with | Stable.intro h => h\n\n/-- double negation elimination (DNE) -/\ntheorem Stable.dne (a : Prop) [inst : Stable a] : \u00ac\u00aca \u2192 a :=\n  match inst with | Stable.intro h => h\n\n/-- Pierces's law -/\ntheorem Stable.pierce (a b : Prop) [Stable a] : ((a \u2192 b) \u2192 a) \u2192 a :=\n  \u03bb h => Stable.by_contradiction \u03bb na => na (h \u03bb ha => absurd ha na)\n\nabbrev StablePred {\u03b1} (p : \u03b1 \u2192 Prop) := (x : \u03b1) \u2192 Stable (p x)\n\nabbrev StableRel {\u03b1 \u03b2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) := (x : \u03b1) \u2192 (y : \u03b2) \u2192 Stable (r x y)\n\nabbrev StableEq (\u03b1) := StableRel (@Eq \u03b1)\n\nclass inductive StableList : List Prop \u2192 Prop\n| nil : StableList []\n| cons {a as} : Stable a \u2192 StableList as \u2192 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)] \u2192 Stable a\n| StableList.cons inst _ => inst\n\nprotected def tail (a as) : [StableList (a :: as)] \u2192 StableList as\n| StableList.cons _ inst => inst\n\nend StableList\n\n-- Complemented Propositions --\n\nclass inductive Complemented (a : Prop) : Prop\n| isTrue : a \u2192 Complemented a\n| isFalse : \u00aca \u2192 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 \u2192 motive) (isFalse : \u00aca \u2192 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 \u2228 \u00aca := Complemented.by_cases a Or.inl Or.inr\n\nabbrev ComplementedPred {\u03b1} (p : \u03b1 \u2192 Prop) := (x : \u03b1) \u2192 Complemented (p x)\n\nabbrev ComplementedRel {\u03b1 \u03b2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) := (x : \u03b1) \u2192 (y : \u03b2) \u2192 Complemented (r x y)\n\nabbrev ComplementedEq (\u03b1) := ComplementedRel (@Eq \u03b1)\n\nclass inductive ComplementedList : List Prop \u2192 Prop\n| nil : ComplementedList []\n| cons {a as} : Complemented a \u2192 ComplementedList as \u2192 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)] \u2192 Complemented a\n| ComplementedList.cons inst _ => inst\n\nprotected def tail (a as) : [ComplementedList (a :: as)] \u2192 ComplementedList as\n| ComplementedList.cons _ inst => inst\n\ninstance instMap {\u03b1} (a : \u03b1 \u2192 Prop) [ComplementedPred a] : (xs : List \u03b1) \u2192 ComplementedList (xs.map a)\n| [] => ComplementedList.nil\n| _::xs => ComplementedList.cons inferInstance (instMap a xs)\n\nend ComplementedList\n\ninstance (a : Prop) : [Complemented a] \u2192 Stable a\n| Complemented.isTrue h => Stable.intro (\u03bb _ => 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 \u2192 Type\n| nil : DecidableList []\n| cons {a as} : Decidable a \u2192 DecidableList as \u2192 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)] \u2192 Decidable a\n| DecidableList.cons inst _ => inst\n\nprotected def tail (a as) : [DecidableList (a :: as)] \u2192 DecidableList as\n| DecidableList.cons _ inst => inst\n\ninstance instMap {\u03b1} (a : \u03b1 \u2192 Prop) [DecidablePred a] : (xs : List \u03b1) \u2192 DecidableList (xs.map a)\n| [] => DecidableList.nil\n| _::xs => DecidableList.cons inferInstance (instMap a xs)\n\nend DecidableList\n\ninstance (a : Prop) : [Decidable a] \u2192 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 : \u00aca \u2192 WeaklyComplemented a\n| protected isIrrefutable : \u00ac\u00aca \u2192 WeaklyComplemented a\n\nabbrev inferWeaklyComplemented (a : Prop) [inst : WeaklyComplemented a] := inst\n\n/-- weak excluded middle (WEM) -/\ntheorem WeaklyComplemented.wem (a : Prop) : [WeaklyComplemented a] \u2192 \u00ac\u00aca \u2228 \u00aca\n| WeaklyComplemented.isIrrefutable h => Or.inl h\n| WeaklyComplemented.isFalse h => Or.inr h\n\nabbrev WeaklyComplementedPred {\u03b1} (p : \u03b1 \u2192 Prop) := (x : \u03b1) \u2192 WeaklyComplemented (p x)\n\nabbrev WeaklyComplementedRel {\u03b1 \u03b2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) := (x : \u03b1) \u2192 (y : \u03b2) \u2192 WeaklyComplemented (r x y)\n\nabbrev WeaklyComplementedEq (\u03b1) := WeaklyComplementedRel (@Eq \u03b1)\n\nclass inductive WeaklyComplementedList : List Prop \u2192 Prop\n| nil : WeaklyComplementedList []\n| cons {a as} : WeaklyComplemented a \u2192 WeaklyComplementedList as \u2192 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)] \u2192 WeaklyComplemented a\n| WeaklyComplementedList.cons inst _ => inst\n\nprotected def tail (a as) : [WeaklyComplementedList (a :: as)] \u2192 WeaklyComplementedList as\n| WeaklyComplementedList.cons _ inst => inst\n\ninstance instMap {\u03b1} (a : \u03b1 \u2192 Prop) [WeaklyComplementedPred a] : (xs : List \u03b1) \u2192 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] \u2192 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] \u2192 WeaklyComplemented a\n| Complemented.isTrue h => WeaklyComplemented.isIrrefutable (absurd h)\n| Complemented.isFalse h => WeaklyComplemented.isFalse h\n\ninstance (a : Prop) : [WeaklyComplemented a] \u2192 Complemented (\u00aca)\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 : \u00aca \u2192 WeaklyDecidable a\n| protected isIrrefutable : \u00ac\u00aca \u2192 WeaklyDecidable a\n\nabbrev inferWeaklyDecidable (a : Prop) [inst : WeaklyDecidable a] := inst\n\nabbrev WeaklyDecidablePred {\u03b1} (p : \u03b1 \u2192 Prop) := (x : \u03b1) \u2192 WeaklyDecidable (p x)\n\nabbrev WeaklyDecidableRel {\u03b1 \u03b2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) := (x : \u03b1) \u2192 (y : \u03b2) \u2192 WeaklyDecidable (r x y)\n\nabbrev WeaklyDecidableEq (\u03b1) := WeaklyDecidableRel (@Eq \u03b1)\n\nclass inductive WeaklyDecidableList : List Prop \u2192 Type\n| nil : WeaklyDecidableList []\n| cons {a as} : WeaklyDecidable a \u2192 WeaklyDecidableList as \u2192 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)] \u2192 WeaklyDecidable a\n| WeaklyDecidableList.cons inst _ => inst\n\nprotected def tail (a as) : [WeaklyDecidableList (a :: as)] \u2192 WeaklyDecidableList as\n| WeaklyDecidableList.cons _ inst => inst\n\ninstance instMap {\u03b1} (a : \u03b1 \u2192 Prop) [WeaklyDecidablePred a] : (xs : List \u03b1) \u2192 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] \u2192 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] \u2192 WeaklyDecidable a\n| Decidable.isTrue h => WeaklyDecidable.isIrrefutable (absurd h)\n| Decidable.isFalse h => WeaklyDecidable.isFalse h\n\ninstance (a : Prop) : [WeaklyDecidable a] \u2192 Decidable (\u00aca)\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* \u2192 Type* \u2192 Type*` along with a bimap which turns `F \u03b1 \u03b2` into\n`F \u03b1' \u03b2'` given two functions `\u03b1 \u2192 \u03b1'` and `\u03b2 \u2192 \u03b2'`. It further\n* respects the identity: `bimap id id = id`\n* composes in the obvious way: `(bimap f' g') \u2218 (bimap f g) = bimap (f' \u2218 f) (g' \u2218 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\u2080 u\u2081 u\u2082 v\u2080 v\u2081 v\u2082\n\nopen function\n\n/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/\nclass bifunctor (F : Type u\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082) :=\n(bimap : \u03a0 {\u03b1 \u03b1' \u03b2 \u03b2'}, (\u03b1 \u2192 \u03b1') \u2192 (\u03b2 \u2192 \u03b2') \u2192 F \u03b1 \u03b2 \u2192 F \u03b1' \u03b2')\nexport bifunctor ( bimap )\n\n/-- Bifunctor. This typeclass asserts that a lawless `bifunctor` is lawful. -/\nclass is_lawful_bifunctor (F : Type u\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082) [bifunctor F] :=\n(id_bimap : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), bimap id id x = x)\n(bimap_bimap : \u03a0 {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 \u03b2\u2080 \u03b2\u2081 \u03b2\u2082} (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b1\u2081 \u2192 \u03b1\u2082)\n  (g : \u03b2\u2080 \u2192 \u03b2\u2081) (g' : \u03b2\u2081 \u2192 \u03b2\u2082) (x : F \u03b1\u2080 \u03b2\u2080),\n  bimap f' g' (bimap f g x) = bimap (f' \u2218 f) (g' \u2218 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\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082} [bifunctor F]\n\nnamespace bifunctor\n\n/-- Left map of a bifunctor. -/\n@[reducible] def fst {\u03b1 \u03b1' \u03b2} (f : \u03b1 \u2192 \u03b1') : F \u03b1 \u03b2 \u2192 F \u03b1' \u03b2 := bimap f id\n\n/-- Right map of a bifunctor. -/\n@[reducible] def snd {\u03b1 \u03b2 \u03b2'} (f : \u03b2 \u2192 \u03b2') : F \u03b1 \u03b2 \u2192 F \u03b1 \u03b2' := bimap id f\n\nvariable [is_lawful_bifunctor F]\n\n@[higher_order fst_id]\nlemma id_fst : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), fst id x = x :=\n@id_bimap _ _ _\n\n@[higher_order snd_id]\nlemma id_snd : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), 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 {\u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081}\n  (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b2\u2080 \u2192 \u03b2\u2081) (x : F \u03b1\u2080 \u03b2\u2080) :\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 {\u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081}\n  (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b2\u2080 \u2192 \u03b2\u2081) (x : F \u03b1\u2080 \u03b2\u2080) :\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 {\u03b1 \u03b2\u2080 \u03b2\u2081 \u03b2\u2082}\n  (g : \u03b2\u2080 \u2192 \u03b2\u2081) (g' : \u03b2\u2081 \u2192 \u03b2\u2082) (x : F \u03b1 \u03b2\u2080) :\n  snd g' (snd g x) = snd (g' \u2218 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 := (\u03bb \u03b1 \u03b1' \u03b2 \u03b2 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 := (\u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (bimap f' f x : F \u03b2' \u03b1')) }\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 {\u03b1} : functor (F \u03b1) :=\n{ map := \u03bb _ _, snd }\n\n@[priority 10]\ninstance bifunctor.is_lawful_functor [is_lawful_bifunctor F] {\u03b1} : is_lawful_functor (F \u03b1) :=\nby refine {..}; intros; simp [functor.map] with functor_norm\n\nsection bicompl\n\nvariables (G : Type* \u2192 Type u\u2080) (H : Type* \u2192 Type u\u2081) [functor G] [functor H]\n\ninstance : bifunctor (bicompl F G H) :=\n{ bimap := \u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (bimap (map f) (map f') x : F (G \u03b1') (H \u03b2')) }\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\u2082 \u2192 Type*) [functor G]\n\ninstance : bifunctor (bicompr G F) :=\n{ bimap := \u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (map (bimap f f') x : G (F \u03b1' \u03b2')) }\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 := \u03bb 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}) := \u27e8X.presheaf, X.sheaf_condition\u27e9\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)) := \u27e8punit (Top.of pempty)\u27e9\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) \u2964 (PresheafedSpace C) :=\ninduced_functor _\n\nvariables {C}\n\nsection\nlocal attribute [simp] id comp\n\n@[simp] lemma id_base (X : SheafedSpace C) :\n  ((\ud835\udfd9 X) : X \u27f6 X).base = (\ud835\udfd9 (X : Top.{v})) := rfl\n\nlemma id_c (X : SheafedSpace C) :\n  ((\ud835\udfd9 X) : X \u27f6 X).c =\n  (((functor.left_unitor _).inv) \u226b\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  ((\ud835\udfd9 X) : X \u27f6 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 \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).base = f.base \u226b g.base := rfl\n\n@[simp] lemma comp_c_app {X Y Z : SheafedSpace C} (\u03b1 : X \u27f6 Y) (\u03b2 : Y \u27f6 Z) (U) :\n  (\u03b1 \u226b \u03b2).c.app U = (\u03b2.c).app U \u226b (\u03b1.c).app (op ((opens.map (\u03b2.base)).obj (unop U))) \u226b\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 \u2964 Top :=\n{ obj := \u03bb X, (X : Top.{v}),\n  map := \u03bb 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 \u27f6 (X : Top.{v})) (h : open_embedding f) : SheafedSpace C :=\n{ sheaf_condition := \u03bb \u03b9 \ud835\udcb0, 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 \ud835\udcb0).symm,\n  ..X.to_PresheafedSpace.restrict f h }\n\n/--\nThe global sections, notated Gamma.\n-/\ndef \u0393 : (SheafedSpace C)\u1d52\u1d56 \u2964 C :=\nforget_to_PresheafedSpace.op \u22d9 PresheafedSpace.\u0393\n\nlemma \u0393_def : (\u0393 : _ \u2964 C) = forget_to_PresheafedSpace.op \u22d9 PresheafedSpace.\u0393 := rfl\n\n@[simp] \n\nlemma \u0393_obj_op (X : SheafedSpace C) : \u0393.obj (op X) = X.presheaf.obj (op \u22a4) := rfl\n\n@[simp] lemma \u0393_map {X Y : (SheafedSpace C)\u1d52\u1d56} (f : X \u27f6 Y) :\n  \u0393.map f = f.unop.c.app (op \u22a4) \u226b (unop Y).presheaf.map (opens.le_map_top _ _).op := rfl\n\nlemma \u0393_map_op {X Y : SheafedSpace C} (f : X \u27f6 Y) :\n  \u0393.map f.op = f.c.app (op \u22a4) \u226b 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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 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 \u03b2)) : multiset \u03b1 :=\ns.map sigma.fst\n\n@[simp] theorem coe_keys {l : list (sigma \u03b2)} :\n  keys (l : multiset (sigma \u03b2)) = (l.keys : multiset \u03b1) :=\nrfl\n\n/-- `nodupkeys s` means that `s` has no duplicate keys. -/\ndef nodupkeys (s : multiset (sigma \u03b2)) : Prop :=\nquot.lift_on s list.nodupkeys (\u03bb s t p, propext $ perm_nodupkeys p)\n\n@[simp] theorem coe_nodupkeys {l : list (sigma \u03b2)} : @nodupkeys \u03b1 \u03b2 l \u2194 l.nodupkeys := iff.rfl\n\nend multiset\n\n/-! ### finmap -/\n\n/-- `finmap \u03b2` is the type of finite maps over a multiset. It is effectively\n  a quotient of `alist \u03b2` by permutation of the underlying list. -/\nstructure finmap (\u03b2 : \u03b1 \u2192 Type v) : Type (max u v) :=\n(entries : multiset (sigma \u03b2))\n(nodupkeys : entries.nodupkeys)\n\n/-- The quotient map from `alist` to `finmap`. -/\ndef alist.to_finmap (s : alist \u03b2) : finmap \u03b2 := \u27e8s.entries, s.nodupkeys\u27e9\n\nlocal notation `\u27e6`:max a `\u27e7`:0 := alist.to_finmap a\n\ntheorem alist.to_finmap_eq {s\u2081 s\u2082 : alist \u03b2} :\n  \u27e6s\u2081\u27e7 = \u27e6s\u2082\u27e7 \u2194 s\u2081.entries ~ s\u2082.entries :=\nby cases s\u2081; cases s\u2082; simp [alist.to_finmap]\n\n@[simp] theorem alist.to_finmap_entries (s : alist \u03b2) : \u27e6s\u27e7.entries = s.entries := rfl\n\n/-- Given `l : list (sigma \u03b2)`, create a term of type `finmap \u03b2` by removing\nentries with duplicate keys. -/\ndef list.to_finmap [decidable_eq \u03b1] (s : list (sigma \u03b2)) : finmap \u03b2 := 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  {\u03b3} (s : finmap \u03b2) (f : alist \u03b2 \u2192 \u03b3)\n  (H : \u2200 a b : alist \u03b2, a.entries ~ b.entries \u2192 f a = f b) : \u03b3 :=\nbegin\n  refine (quotient.lift_on s.1 (\u03bb l, (\u27e8_, \u03bb nd, f \u27e8l, nd\u27e9\u27e9 : roption \u03b3))\n    (\u03bb l\u2081 l\u2082 p, roption.ext' (perm_nodupkeys p) _) : roption \u03b3).get _,\n  { exact \u03bb h\u2081 h\u2082, H _ _ (by exact p) },\n  { have := s.nodupkeys, rcases s.entries with \u27e8l\u27e9, exact id }\nend\n\n@[simp] theorem lift_on_to_finmap {\u03b3} (s : alist \u03b2) (f : alist \u03b2 \u2192 \u03b3) (H) :\n  lift_on \u27e6s\u27e7 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\u2082\n  {\u03b3} (s\u2081 s\u2082 : finmap \u03b2) (f : alist \u03b2 \u2192 alist \u03b2 \u2192 \u03b3)\n  (H : \u2200 a\u2081 b\u2081 a\u2082 b\u2082 : alist \u03b2, a\u2081.entries ~ a\u2082.entries \u2192 b\u2081.entries ~ b\u2082.entries \u2192\n    f a\u2081 b\u2081 = f a\u2082 b\u2082) : \u03b3 :=\nlift_on s\u2081\n  (\u03bb l\u2081, lift_on s\u2082 (f l\u2081) (\u03bb b\u2081 b\u2082 p, H _ _ _ _ (perm.refl _) p))\n  (\u03bb a\u2081 a\u2082 p, have H' : f a\u2081 = f a\u2082 := funext (\u03bb _, H _ _ _ _ p (perm.refl _)), by simp only [H'])\n\n@[simp] theorem lift_on\u2082_to_finmap {\u03b3} (s\u2081 s\u2082 : alist \u03b2) (f : alist \u03b2 \u2192 alist \u03b2 \u2192 \u03b3) (H) :\n  lift_on\u2082 \u27e6s\u2081\u27e7 \u27e6s\u2082\u27e7 f H = f s\u2081 s\u2082 :=\nby cases s\u2081; cases s\u2082; refl\n\n/-! ### induction -/\n\n@[elab_as_eliminator] theorem induction_on\n  {C : finmap \u03b2 \u2192 Prop} (s : finmap \u03b2) (H : \u2200 (a : alist \u03b2), C \u27e6a\u27e7) : C s :=\nby rcases s with \u27e8\u27e8a\u27e9, h\u27e9; exact H \u27e8a, h\u27e9\n\n@[elab_as_eliminator] theorem induction_on\u2082 {C : finmap \u03b2 \u2192 finmap \u03b2 \u2192 Prop}\n  (s\u2081 s\u2082 : finmap \u03b2) (H : \u2200 (a\u2081 a\u2082 : alist \u03b2), C \u27e6a\u2081\u27e7 \u27e6a\u2082\u27e7) : C s\u2081 s\u2082 :=\ninduction_on s\u2081 $ \u03bb l\u2081, induction_on s\u2082 $ \u03bb l\u2082, H l\u2081 l\u2082\n\n@[elab_as_eliminator] theorem induction_on\u2083 {C : finmap \u03b2 \u2192  finmap \u03b2 \u2192 finmap \u03b2 \u2192 Prop}\n  (s\u2081 s\u2082 s\u2083 : finmap \u03b2) (H : \u2200 (a\u2081 a\u2082 a\u2083 : alist \u03b2), C \u27e6a\u2081\u27e7 \u27e6a\u2082\u27e7 \u27e6a\u2083\u27e7) : C s\u2081 s\u2082 s\u2083 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb l\u2081 l\u2082, induction_on s\u2083 $ \u03bb l\u2083, H l\u2081 l\u2082 l\u2083\n\n/-! ### extensionality -/\n\n@[ext] theorem ext : \u2200 {s t : finmap \u03b2}, s.entries = t.entries \u2192 s = t\n| \u27e8l\u2081, h\u2081\u27e9 \u27e8l\u2082, h\u2082\u27e9 H := by congr'\n\n@[simp] theorem ext_iff {s t : finmap \u03b2} : s.entries = t.entries \u2194 s = t :=\n\u27e8ext, congr_arg _\u27e9\n\n/-! ### mem -/\n\n/-- The predicate `a \u2208 s` means that `s` has a value associated to the key `a`. -/\ninstance : has_mem \u03b1 (finmap \u03b2) := \u27e8\u03bb a s, a \u2208 s.entries.keys\u27e9\n\ntheorem mem_def {a : \u03b1} {s : finmap \u03b2} :\n  a \u2208 s \u2194 a \u2208 s.entries.keys := iff.rfl\n\n@[simp] theorem mem_to_finmap {a : \u03b1} {s : alist \u03b2} :\n  a \u2208 \u27e6s\u27e7 \u2194 a \u2208 s := iff.rfl\n\n/-! ### keys -/\n\n/-- The set of keys of a finite map. -/\ndef keys (s : finmap \u03b2) : finset \u03b1 :=\n\u27e8s.entries.keys, induction_on s keys_nodup\u27e9\n\n@[simp] theorem keys_val (s : alist \u03b2) : (keys \u27e6s\u27e7).val = s.keys := rfl\n\n@[simp] theorem keys_ext {s\u2081 s\u2082 : alist \u03b2} :\n  keys \u27e6s\u2081\u27e7 = keys \u27e6s\u2082\u27e7 \u2194 s\u2081.keys ~ s\u2082.keys :=\nby simp [keys, alist.keys]\n\ntheorem mem_keys {a : \u03b1} {s : finmap \u03b2} : a \u2208 s.keys \u2194 a \u2208 s :=\ninduction_on s $ \u03bb s, alist.mem_keys\n\n/-! ### empty -/\n\n/-- The empty map. -/\ninstance : has_emptyc (finmap \u03b2) := \u27e8\u27e80, nodupkeys_nil\u27e9\u27e9\n\ninstance : inhabited (finmap \u03b2) := \u27e8\u2205\u27e9\n\n@[simp] theorem empty_to_finmap : (\u27e6\u2205\u27e7 : finmap \u03b2) = \u2205 := rfl\n\n@[simp] theorem to_finmap_nil [decidable_eq \u03b1] : ([].to_finmap : finmap \u03b2) = \u2205 := rfl\n\ntheorem not_mem_empty {a : \u03b1} : a \u2209 (\u2205 : finmap \u03b2) :=\nmultiset.not_mem_zero a\n\n@[simp] theorem keys_empty : (\u2205 : finmap \u03b2).keys = \u2205 := rfl\n\n/-! ### singleton -/\n\n/-- The singleton map. -/\ndef singleton (a : \u03b1) (b : \u03b2 a) : finmap \u03b2 := \u27e6alist.singleton a b\u27e7\n\n@[simp] theorem keys_singleton (a : \u03b1) (b : \u03b2 a) :\n  (singleton a b).keys = {a} := rfl\n\n@[simp] lemma mem_singleton (x y : \u03b1) (b : \u03b2 y) : x \u2208 singleton y b \u2194 x = y :=\nby simp only [singleton]; erw [mem_cons_eq, mem_nil_iff, or_false]\n\nsection\n\nvariables [decidable_eq \u03b1]\n\ninstance has_decidable_eq [\u2200 a, decidable_eq (\u03b2 a)] : decidable_eq (finmap \u03b2)\n| s\u2081 s\u2082 := decidable_of_iff _ ext_iff\n\n/-! ### lookup -/\n\n/-- Look up the value associated to a key in a map. -/\ndef lookup (a : \u03b1) (s : finmap \u03b2) : option (\u03b2 a) :=\nlift_on s (lookup a) (\u03bb s t, perm_lookup)\n\n@[simp] theorem lookup_to_finmap (a : \u03b1) (s : alist \u03b2) :\n  lookup a \u27e6s\u27e7 = s.lookup a := rfl\n\n@[simp] theorem lookup_list_to_finmap (a : \u03b1) (s : list (sigma \u03b2)) :\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 (\u2205 : finmap \u03b2) = none :=\nrfl\n\ntheorem lookup_is_some {a : \u03b1} {s : finmap \u03b2} :\n  (s.lookup a).is_some \u2194 a \u2208 s :=\ninduction_on s $ \u03bb s, alist.lookup_is_some\n\ntheorem lookup_eq_none {a} {s : finmap \u03b2} : lookup a s = none \u2194 a \u2209 s :=\ninduction_on s $ \u03bb s, alist.lookup_eq_none\n\n@[simp] lemma lookup_singleton_eq {a : \u03b1} {b : \u03b2 a} : (singleton a b).lookup a = some b :=\nby rw [singleton, lookup_to_finmap, alist.singleton, alist.lookup, lookup_cons_eq]\n\ninstance (a : \u03b1) (s : finmap \u03b2) : decidable (a \u2208 s) :=\ndecidable_of_iff _ lookup_is_some\n\nlemma mem_iff {a : \u03b1} {s : finmap \u03b2} : a \u2208 s \u2194 \u2203 b, s.lookup a = some b :=\ninduction_on s $ \u03bb s,\niff.trans list.mem_keys $ exists_congr $ \u03bb b,\n(mem_lookup_iff s.nodupkeys).symm\n\nlemma mem_of_lookup_eq_some {a : \u03b1} {b : \u03b2 a} {s : finmap \u03b2} (h : s.lookup a = some b) : a \u2208 s :=\nmem_iff.mpr \u27e8_, h\u27e9\n\ntheorem ext_lookup {s\u2081 s\u2082 : finmap \u03b2} : (\u2200 x, s\u2081.lookup x = s\u2082.lookup x) \u2192 s\u2081 = s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082 h,\nbegin\n  simp only [alist.lookup, lookup_to_finmap] at h,\n  rw [alist.to_finmap_eq],\n  apply lookup_ext s\u2081.nodupkeys s\u2082.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 : \u03b1) (b : \u03b2 a) (s : finmap \u03b2) : finmap \u03b2 :=\nlift_on s (\u03bb t, \u27e6replace a b t\u27e7) $\n\u03bb s\u2081 s\u2082 p, to_finmap_eq.2 $ perm_replace p\n\n@[simp] theorem replace_to_finmap (a : \u03b1) (b : \u03b2 a) (s : alist \u03b2) :\n  replace a b \u27e6s\u27e7 = \u27e6s.replace a b\u27e7 := by simp [replace]\n\n@[simp] theorem keys_replace (a : \u03b1) (b : \u03b2 a) (s : finmap \u03b2) :\n  (replace a b s).keys = s.keys :=\ninduction_on s $ \u03bb s, by simp\n\n@[simp] theorem mem_replace {a a' : \u03b1} {b : \u03b2 a} {s : finmap \u03b2} :\n  a' \u2208 replace a b s \u2194 a' \u2208 s :=\ninduction_on s $ \u03bb s, by simp\n\nend\n\n/-! ### foldl -/\n\n/-- Fold a commutative function over the key-value pairs in the map -/\ndef foldl {\u03b4 : Type w} (f : \u03b4 \u2192 \u03a0 a, \u03b2 a \u2192 \u03b4)\n  (H : \u2200 d a\u2081 b\u2081 a\u2082 b\u2082, f (f d a\u2081 b\u2081) a\u2082 b\u2082 = f (f d a\u2082 b\u2082) a\u2081 b\u2081)\n  (d : \u03b4) (m : finmap \u03b2) : \u03b4 :=\nm.entries.foldl (\u03bb d s, f d s.1 s.2) (\u03bb 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 : \u03a0 x, \u03b2 x \u2192 bool) (s : finmap \u03b2) : bool :=\ns.foldl (\u03bb x y z, x \u2228 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 : \u03a0 x, \u03b2 x \u2192 bool) (s : finmap \u03b2) : bool :=\ns.foldl (\u03bb x y z, x \u2227 f y z) (by { intros, simp [and.right_comm] }) ff\n\n/-! ### erase -/\n\nsection\n\nvariables [decidable_eq \u03b1]\n\n/-- Erase a key from the map. If the key is not present it does nothing. -/\ndef erase (a : \u03b1) (s : finmap \u03b2) : finmap \u03b2 :=\nlift_on s (\u03bb t, \u27e6erase a t\u27e7) $\n\u03bb s\u2081 s\u2082 p, to_finmap_eq.2 $ perm_erase p\n\n@[simp] theorem erase_to_finmap (a : \u03b1) (s : alist \u03b2) :\n  erase a \u27e6s\u27e7 = \u27e6s.erase a\u27e7 := by simp [erase]\n\n@[simp] \n\n@[simp] theorem keys_erase (a : \u03b1) (s : finmap \u03b2) :\n  (erase a s).keys = s.keys.erase a :=\ninduction_on s $ \u03bb s, by simp\n\n@[simp] theorem mem_erase {a a' : \u03b1} {s : finmap \u03b2} : a' \u2208 erase a s \u2194 a' \u2260 a \u2227 a' \u2208 s :=\ninduction_on s $ \u03bb s, by simp\n\ntheorem not_mem_erase_self {a : \u03b1} {s : finmap \u03b2} : \u00ac a \u2208 erase a s :=\nby rw [mem_erase, not_and_distrib, not_not]; left; refl\n\n@[simp] theorem lookup_erase (a) (s : finmap \u03b2) : lookup a (erase a s) = none :=\ninduction_on s $ lookup_erase a\n\n@[simp] theorem lookup_erase_ne {a a'} {s : finmap \u03b2} (h : a \u2260 a') :\n  lookup a (erase a' s) = lookup a s :=\ninduction_on s $ \u03bb s, lookup_erase_ne h\n\ntheorem erase_erase {a a' : \u03b1} {s : finmap \u03b2} : erase a (erase a' s) = erase a' (erase a s) :=\ninduction_on s $ \u03bb 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 \u03b2) : finmap \u03b2 :=\ns'.foldl (\u03bb s x _, s.erase x) (\u03bb a\u2080 a\u2081 _ a\u2082 _, erase_erase) s\n\ninstance : has_sdiff (finmap \u03b2) := \u27e8sdiff\u27e9\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 : \u03b1) (b : \u03b2 a) (s : finmap \u03b2) : finmap \u03b2 :=\nlift_on s (\u03bb t, \u27e6insert a b t\u27e7) $\n\u03bb s\u2081 s\u2082 p, to_finmap_eq.2 $ perm_insert p\n\n@[simp] theorem insert_to_finmap (a : \u03b1) (b : \u03b2 a) (s : alist \u03b2) :\n  insert a b \u27e6s\u27e7 = \u27e6s.insert a b\u27e7 := by simp [insert]\n\ntheorem insert_entries_of_neg {a : \u03b1} {b : \u03b2 a} {s : finmap \u03b2} : a \u2209 s \u2192\n  (insert a b s).entries = \u27e8a, b\u27e9 ::\u2098 s.entries :=\ninduction_on s $ \u03bb s h,\nby simp [insert_entries_of_neg (mt mem_to_finmap.1 h)]\n\n@[simp] theorem mem_insert {a a' : \u03b1} {b' : \u03b2 a'} {s : finmap \u03b2} :\n  a \u2208 insert a' b' s \u2194 a = a' \u2228 a \u2208 s :=\ninduction_on s mem_insert\n\n@[simp] theorem lookup_insert {a} {b : \u03b2 a} (s : finmap \u03b2) :\n  lookup a (insert a b s) = some b :=\ninduction_on s $ \u03bb s,\nby simp only [insert_to_finmap, lookup_to_finmap, lookup_insert]\n\n@[simp] theorem lookup_insert_of_ne {a a'} {b : \u03b2 a} (s : finmap \u03b2) (h : a' \u2260 a) :\n  lookup a' (insert a b s) = lookup a' s :=\ninduction_on s $ \u03bb s,\nby simp only [insert_to_finmap, lookup_to_finmap, lookup_insert_ne h]\n\n@[simp] theorem insert_insert {a} {b b' : \u03b2 a} (s : finmap \u03b2) :\n  (s.insert a b).insert a b' = s.insert a b' :=\ninduction_on s $ \u03bb s,\nby simp only [insert_to_finmap, insert_insert]\n\ntheorem insert_insert_of_ne {a a'} {b : \u03b2 a} {b' : \u03b2 a'} (s : finmap \u03b2) (h : a \u2260 a') :\n  (s.insert a b).insert a' b' = (s.insert a' b').insert a b :=\ninduction_on s $ \u03bb s,\nby simp only [insert_to_finmap, alist.to_finmap_eq, insert_insert_of_ne _ h]\n\ntheorem to_finmap_cons (a : \u03b1) (b : \u03b2 a) (xs : list (sigma \u03b2)) :\n  list.to_finmap (\u27e8a,b\u27e9 :: xs) = insert a b xs.to_finmap := rfl\n\ntheorem mem_list_to_finmap (a : \u03b1) (xs : list (sigma \u03b2)) :\n  a \u2208 xs.to_finmap \u2194 (\u2203 b : \u03b2 a, sigma.mk a b \u2208 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 \u2190 and_true (a = x_fst) },\n     apply and_congr_right, rintro \u27e8\u27e9, simp only [exists_eq, iff_self, heq_iff_eq] }\n\n@[simp] theorem insert_singleton_eq {a : \u03b1} {b b' : \u03b2 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 : \u03b1) (s : finmap \u03b2) : option (\u03b2 a) \u00d7 finmap \u03b2 :=\nlift_on s (\u03bb t, prod.map id to_finmap (extract a t)) $\n\u03bb s\u2081 s\u2082 p, by simp [perm_lookup p, to_finmap_eq, perm_erase p]\n\n@[simp] theorem extract_eq_lookup_erase (a : \u03b1) (s : finmap \u03b2) :\n  extract a s = (lookup a s, erase a s) :=\ninduction_on s $ \u03bb s, by simp [extract]\n\n/-! ### union -/\n\n/-- `s\u2081 \u222a s\u2082` is the key-based union of two finite maps. It is left-biased: if\nthere exists an `a \u2208 s\u2081`, `lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081`. -/\ndef union (s\u2081 s\u2082 : finmap \u03b2) : finmap \u03b2 :=\nlift_on\u2082 s\u2081 s\u2082 (\u03bb s\u2081 s\u2082, \u27e6s\u2081 \u222a s\u2082\u27e7) $\n\u03bb s\u2081 s\u2082 s\u2083 s\u2084 p\u2081\u2083 p\u2082\u2084, to_finmap_eq.mpr $ perm_union p\u2081\u2083 p\u2082\u2084\n\ninstance : has_union (finmap \u03b2) := \u27e8union\u27e9\n\n@[simp] theorem mem_union {a} {s\u2081 s\u2082 : finmap \u03b2} :\n  a \u2208 s\u2081 \u222a s\u2082 \u2194 a \u2208 s\u2081 \u2228 a \u2208 s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb _ _, mem_union\n\n@[simp] theorem union_to_finmap (s\u2081 s\u2082 : alist \u03b2) : \u27e6s\u2081\u27e7 \u222a \u27e6s\u2082\u27e7 = \u27e6s\u2081 \u222a s\u2082\u27e7 :=\nby simp [(\u222a), union]\n\ntheorem keys_union {s\u2081 s\u2082 : finmap \u03b2} : (s\u2081 \u222a s\u2082).keys = s\u2081.keys \u222a s\u2082.keys :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082, finset.ext $ by simp [keys]\n\n@[simp] theorem lookup_union_left {a} {s\u2081 s\u2082 : finmap \u03b2} :\n  a \u2208 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082, lookup_union_left\n\n@[simp] theorem lookup_union_right {a} {s\u2081 s\u2082 : finmap \u03b2} :\n  a \u2209 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082, lookup_union_right\n\ntheorem lookup_union_left_of_not_in {a} {s\u2081 s\u2082 : finmap \u03b2} (h : a \u2209 s\u2082) :\n  lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081 :=\nbegin\n  by_cases h' : a \u2208 s\u2081,\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 : \u03b2 a} {s\u2081 s\u2082 : finmap \u03b2} :\n  b \u2208 lookup a (s\u2081 \u222a s\u2082) \u2194 b \u2208 lookup a s\u2081 \u2228 a \u2209 s\u2081 \u2227 b \u2208 lookup a s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082, mem_lookup_union\n\ntheorem mem_lookup_union_middle {a} {b : \u03b2 a} {s\u2081 s\u2082 s\u2083 : finmap \u03b2} :\n  b \u2208 lookup a (s\u2081 \u222a s\u2083) \u2192 a \u2209 s\u2082 \u2192 b \u2208 lookup a (s\u2081 \u222a s\u2082 \u222a s\u2083) :=\ninduction_on\u2083 s\u2081 s\u2082 s\u2083 $ \u03bb s\u2081 s\u2082 s\u2083, mem_lookup_union_middle\n\ntheorem insert_union {a} {b : \u03b2 a} {s\u2081 s\u2082 : finmap \u03b2} :\n  insert a b (s\u2081 \u222a s\u2082) = insert a b s\u2081 \u222a s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb a\u2081 a\u2082, by simp [insert_union]\n\ntheorem union_assoc {s\u2081 s\u2082 s\u2083 : finmap \u03b2} : (s\u2081 \u222a s\u2082) \u222a s\u2083 = s\u2081 \u222a (s\u2082 \u222a s\u2083) :=\ninduction_on\u2083 s\u2081 s\u2082 s\u2083 $ \u03bb s\u2081 s\u2082 s\u2083,\nby simp only [alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\n@[simp] theorem empty_union {s\u2081 : finmap \u03b2} : \u2205 \u222a s\u2081 = s\u2081 :=\ninduction_on s\u2081 $ \u03bb s\u2081, by rw \u2190 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\u2081 : finmap \u03b2} : s\u2081 \u222a \u2205 = s\u2081 :=\ninduction_on s\u2081 $ \u03bb s\u2081, by rw \u2190 empty_to_finmap;\n  simp [- empty_to_finmap, alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\ntheorem erase_union_singleton (a : \u03b1) (b : \u03b2 a) (s : finmap \u03b2) (h : s.lookup a = some b) :\n  s.erase a \u222a singleton a b = s :=\next_lookup\n(\u03bb 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 \u2209 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\u2081 s\u2082` holds if `s\u2081` and `s\u2082` have no keys in common. -/\ndef disjoint (s\u2081 s\u2082 : finmap \u03b2) : Prop :=\n\u2200 x \u2208 s\u2081, \u00ac x \u2208 s\u2082\n\nlemma disjoint_empty (x : finmap \u03b2) : disjoint \u2205 x .\n\n@[symm]\nlemma disjoint.symm (x y : finmap \u03b2) (h : disjoint x y) : disjoint y x :=\n\u03bb p hy hx, h p hx hy\n\nlemma disjoint.symm_iff (x y : finmap \u03b2) : disjoint x y \u2194 disjoint y x :=\n\u27e8disjoint.symm x y, disjoint.symm y x\u27e9\n\nsection\n\nvariables [decidable_eq \u03b1]\n\ninstance : decidable_rel (@disjoint \u03b1 \u03b2) :=\n\u03bb x y, by dsimp only [disjoint]; apply_instance\n\nlemma disjoint_union_left (x y z : finmap \u03b2) : disjoint (x \u222a y) z \u2194 disjoint x z \u2227 disjoint y z :=\nby simp [disjoint, finmap.mem_union, or_imp_distrib, forall_and_distrib]\n\nlemma disjoint_union_right (x y z : finmap \u03b2) : disjoint x (y \u222a z) \u2194 disjoint x y \u2227 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\u2081 s\u2082 : finmap \u03b2} : disjoint s\u2081 s\u2082 \u2192 s\u2081 \u222a s\u2082 = s\u2082 \u222a s\u2081 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082,\nby { intros h, simp only [alist.to_finmap_eq, union_to_finmap, alist.union_comm_of_disjoint h] }\n\ntheorem union_cancel {s\u2081 s\u2082 s\u2083 : finmap \u03b2} (h : disjoint s\u2081 s\u2083) (h' : disjoint s\u2082 s\u2083) :\n  s\u2081 \u222a s\u2083 = s\u2082 \u222a s\u2083 \u2194 s\u2081 = s\u2082 :=\n\u27e8\u03bb h'', begin\n          apply ext_lookup, intro x,\n          have : (s\u2081 \u222a s\u2083).lookup x = (s\u2082 \u222a s\u2083).lookup x, from h'' \u25b8 rfl,\n          by_cases hs\u2081 : x \u2208 s\u2081,\n          { rwa [lookup_union_left hs\u2081, lookup_union_left_of_not_in (h _ hs\u2081)] at this, },\n          { by_cases hs\u2082 : x \u2208 s\u2082,\n            { rwa [lookup_union_left_of_not_in (h' _ hs\u2082), lookup_union_left hs\u2082] at this, },\n            { rw [lookup_eq_none.mpr hs\u2081, lookup_eq_none.mpr hs\u2082] } }\n        end,\n \u03bb h, h \u25b8 rfl\u27e9\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u03b1` : the least `\u03c3`-algebra that contains all open sets;\n* `class borel_space` : a space with `topological_space` and `measurable_space` structures\n  such that `\u2039measurable_space \u03b1\u203a = borel \u03b1`;\n* `class opens_measurable_space` : a space with `topological_space` and `measurable_space`\n  structures such that all open sets are measurable; equivalently, `borel \u03b1 \u2264 \u2039measurable_space \u03b1\u203a`.\n* `borel_space` instances on `empty`, `unit`, `bool`, `nat`, `int`, `rat`;\n* `measurable` and `borel_space` instances on `\u211d`, `\u211d\u22650`, `\u211d\u22650\u221e`.\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 : \u03b1 \u2192 \u03b2` and `g : \u03b1 \u2192 \u03b3` are measurable and `op : \u03b2 \u00d7 \u03b3 \u2192 \u03b4`\n  is continuous, then `\u03bb 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 `\u211d\u22650\u221e`.\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 {\u03b1 \u03b2 \u03b3 \u03b3\u2082 \u03b4 : Type _} {\u03b9 : Sort y} {s t u : Set \u03b1}\n\nopen MeasurableSpace TopologicalSpace\n\n/-- `measurable_space` structure generated by `topological_space`. -/\ndef borel (\u03b1 : Type u) [TopologicalSpace \u03b1] : MeasurableSpace \u03b1 :=\n  generateFrom { s : Set \u03b1 | IsOpen s }\n#align borel borel\n\ntheorem borel_eq_top_of_discrete [TopologicalSpace \u03b1] [DiscreteTopology \u03b1] : borel \u03b1 = \u22a4 :=\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 \u03b1] [T1Space \u03b1] [Countable \u03b1] : borel \u03b1 = \u22a4 :=\n  by\n  refine' top_le_iff.1 fun s hs => bUnion_of_singleton s \u25b8 _\n  apply MeasurableSet.bunion\u1d62 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 \u03b1)} [t : TopologicalSpace \u03b1]\n    [SecondCountableTopology \u03b1] (hs : t = generateFrom s) : borel \u03b1 = 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 \u03b1 (generate_from s)\n      case inter s\u2081 s\u2082 _ _ hs\u2081 hs\u2082 => exact @MeasurableSet.inter \u03b1 (generate_from s) _ _ hs\u2081 hs\u2082\n      case\n        sUnion f hf ih =>\n        rcases is_open_sUnion_countable f (by rwa [hs]) with \u27e8v, hv, vf, vu\u27e9\n        rw [\u2190 vu]\n        exact @MeasurableSet.union\u209b \u03b1 (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 \u03b1]\n    [SecondCountableTopology \u03b1] {s : Set (Set \u03b1)} (hs : IsTopologicalBasis s) :\n    borel \u03b1 = 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 \u03b1] : IsPiSystem (IsOpen : Set \u03b1 \u2192 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 \u03b1] :\n    borel \u03b1 = generateFrom { s | IsClosed s } :=\n  le_antisymm\n    (generateFrom_le fun t ht =>\n      @MeasurableSet.of_compl \u03b1 _ (generateFrom { s | IsClosed s })\n        (GenerateMeasurable.basic _ <| isClosed_compl_iff.2 ht))\n    (generateFrom_le fun t ht =>\n      @MeasurableSet.of_compl \u03b1 _ (borel \u03b1) (GenerateMeasurable.basic _ <| isOpen_compl_iff.2 ht))\n#align borel_eq_generate_from_is_closed borel_eq_generateFrom_isClosed\n\nsection OrderTopology\n\nvariable (\u03b1)\n\nvariable [TopologicalSpace \u03b1] [SecondCountableTopology \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1]\n\ntheorem borel_eq_generateFrom_Iio : borel \u03b1 = generateFrom (range Iio) :=\n  by\n  refine' le_antisymm _ (generate_from_le _)\n  \u00b7 rw [borel_eq_generateFrom_of_subbasis (@OrderTopology.topology_eq_generate_intervals \u03b1 _ _ _)]\n    letI : MeasurableSpace \u03b1 := MeasurableSpace.generateFrom (range Iio)\n    have H : \u2200 a : \u03b1, MeasurableSet (Iio a) := fun a => generate_measurable.basic _ \u27e8_, rfl\u27e9\n    refine' generate_from_le _\n    rintro _ \u27e8a, rfl | rfl\u27e9 <;> [skip, apply H]\n    by_cases h : \u2203 a', \u2200 b, a < b \u2194 a' \u2264 b\n    \u00b7 rcases h with \u27e8a', ha'\u27e9\n      rw [(_ : Ioi a = Iio a'\u1d9c)]\n      \u00b7 exact (H _).compl\n      simp [Set.ext_iff, ha']\n    \u00b7 rcases is_open_Union_countable (fun a' : { a' : \u03b1 // a < a' } => { b | a'.1 < b }) fun a' =>\n          isOpen_lt' _ with \u27e8v, \u27e8hv\u27e9, vu\u27e9\n      simp [Set.ext_iff] at vu\n      have : Ioi a = \u22c3 x : v, Iio x.1.1\u1d9c :=\n        by\n        simp [Set.ext_iff]\n        refine' fun x => \u27e8fun ax => _, fun \u27e8a', \u27e8h, av\u27e9, ax\u27e9 => lt_of_lt_of_le h ax\u27e9\n        rcases(vu x).2 _ with \u27e8a', h\u2081, h\u2082\u27e9\n        \u00b7 exact \u27e8a', h\u2081, le_of_lt h\u2082\u27e9\n        refine' not_imp_comm.1 (fun h => _) h\n        exact \u27e8x, fun b => \u27e8fun ab => le_of_not_lt fun h' => h \u27e8b, ab, h'\u27e9, lt_of_lt_of_le ax\u27e9\u27e9\n      rw [this]\n      skip\n      apply MeasurableSet.union\u1d62\n      exact fun _ => (H _).compl\n  \u00b7 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 \u03b1 = generateFrom (range Ioi) :=\n  @borel_eq_generateFrom_Iio \u03b1\u1d52\u1d48 _ (by infer_instance : SecondCountableTopology \u03b1) _ _\n#align borel_eq_generate_from_Ioi borel_eq_generateFrom_Ioi\n\nend OrderTopology\n\ntheorem borel_comap {f : \u03b1 \u2192 \u03b2} {t : TopologicalSpace \u03b2} :\n    @borel \u03b1 (t.induced f) = (@borel \u03b2 t).comap f :=\n  comap_generateFrom.symm\n#align borel_comap borel_comap\n\ntheorem Continuous.borel_measurable [TopologicalSpace \u03b1] [TopologicalSpace \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (hf : Continuous f) : @Measurable \u03b1 \u03b2 (borel \u03b1) (borel \u03b2) f :=\n  Measurable.of_le_map <|\n    generateFrom_le fun s hs => GenerateMeasurable.basic (f \u207b\u00b9' 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 (\u03b1 : Type _) [TopologicalSpace \u03b1] [h : MeasurableSpace \u03b1] : Prop where\n  borel_le : borel \u03b1 \u2264 h\n#align opens_measurable_space OpensMeasurableSpace\n\n/-- A space with `measurable_space` and `topological_space` structures such that\nthe `\u03c3`-algebra of measurable sets is exactly the `\u03c3`-algebra generated by open sets. -/\nclass BorelSpace (\u03b1 : Type _) [TopologicalSpace \u03b1] [MeasurableSpace \u03b1] : Prop where\n  measurable_eq : \u2039MeasurableSpace \u03b1\u203a = borel \u03b1\n#align borel_space BorelSpace\n\nnamespace Tactic\n\n/-- Add instances `borel \u03b1 : measurable_space \u03b1` and `\u27e8rfl\u27e9 : borel_space \u03b1`. -/\nunsafe def add_borel_instance (\u03b1 : expr) : tactic Unit := do\n  let n1 \u2190 get_unused_name \"_inst\"\n  to_expr ``(borel $(\u03b1)) >>= pose n1\n  reset_instance_cache\n  let n2 \u2190 get_unused_name \"_inst\"\n  let v \u2190 to_expr ``((BorelSpace.mk rfl : BorelSpace $(\u03b1)))\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 `\u03b1`, an assumption `i : measurable_space \u03b1`, and an instance `[borel_space \u03b1]`,\n      replace `i` with `borel \u03b1`. -/\n    unsafe\n  def\n    borel_to_refl\n    ( \u03b1 i : expr ) : tactic Unit\n    :=\n      do\n        let n \u2190 get_unused_name \"h\"\n          to_expr ` `( $ ( i ) = borel $ ( \u03b1 ) ) >>= assert n\n          applyc `borel_space.measurable_eq\n          unfreezing ( tactic.subst i )\n          let n1 \u2190 get_unused_name \"_inst\"\n          to_expr ` `( borel $ ( \u03b1 ) ) >>= pose n1\n          reset_instance_cache\n#align tactic.borel_to_refl tactic.borel_to_refl\n\n/-- Given a type `\u03b1`, if there is an assumption `[i : measurable_space \u03b1]`, then try to prove\n`[borel_space \u03b1]` and replace `i` with `borel \u03b1`. Otherwise, add instances\n`borel \u03b1 : measurable_space \u03b1` and `\u27e8rfl\u27e9 : borel_space \u03b1`. -/\nunsafe def borelize (\u03b1 : expr) : tactic Unit := do\n  let i \u2190 optional (to_expr ``(MeasurableSpace $(\u03b1)) >>= find_assumption)\n  i (add_borel_instance \u03b1) (borel_to_refl \u03b1)\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 \u03b1` depends on the existing assumptions on `\u03b1`.\n\n- if `\u03b1` is a topological space with instances `[measurable_space \u03b1] [borel_space \u03b1]`, then\n  `borelize \u03b1` replaces the former instance by `borel \u03b1`;\n- otherwise, `borelize \u03b1` adds instances `borel \u03b1 : measurable_space \u03b1` and `\u27e8rfl\u27e9 : borel_space \u03b1`.\n\nFinally, `borelize [\u03b1, \u03b2, \u03b3]` runs `borelize \u03b1, borelize \u03b2, borelize \u03b3`.\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 {\u03b1 : Type _} [TopologicalSpace \u03b1]\n    [MeasurableSpace \u03b1] [h : OpensMeasurableSpace \u03b1] : OpensMeasurableSpace \u03b1\u1d52\u1d48\n    where borel_le := h.borel_le\n#align order_dual.opens_measurable_space OrderDual.opensMeasurableSpace\n\ninstance (priority := 100) OrderDual.borelSpace {\u03b1 : Type _} [TopologicalSpace \u03b1]\n    [MeasurableSpace \u03b1] [h : BorelSpace \u03b1] : BorelSpace \u03b1\u1d52\u1d48 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 {\u03b1 : Type _} [TopologicalSpace \u03b1]\n    [MeasurableSpace \u03b1] [BorelSpace \u03b1] : OpensMeasurableSpace \u03b1 :=\n  \u27e8ge_of_eq <| BorelSpace.measurable_eq\u27e9\n#align borel_space.opens_measurable BorelSpace.opens_measurable\n\ninstance Subtype.borelSpace {\u03b1 : Type _} [TopologicalSpace \u03b1] [MeasurableSpace \u03b1]\n    [h\u03b1 : BorelSpace \u03b1] (s : Set \u03b1) : BorelSpace s :=\n  \u27e8by\n    rw [h\u03b1.1, Subtype.measurableSpace, \u2190 borel_comap]\n    rfl\u27e9\n#align subtype.borel_space Subtype.borelSpace\n\ninstance Subtype.opensMeasurableSpace {\u03b1 : Type _} [TopologicalSpace \u03b1] [MeasurableSpace \u03b1]\n    [h : OpensMeasurableSpace \u03b1] (s : Set \u03b1) : OpensMeasurableSpace s :=\n  \u27e8by\n    rw [borel_comap]\n    exact comap_mono h.1\u27e9\n#align subtype.opens_measurable_space Subtype.opensMeasurableSpace\n\ntheorem MeasurableSet.induction_on_open [TopologicalSpace \u03b1] [MeasurableSpace \u03b1] [BorelSpace \u03b1]\n    {C : Set \u03b1 \u2192 Prop} (h_open : \u2200 U, IsOpen U \u2192 C U)\n    (h_compl : \u2200 t, MeasurableSet t \u2192 C t \u2192 C (t\u1d9c))\n    (h_union :\n      \u2200 f : \u2115 \u2192 Set \u03b1,\n        Pairwise (Disjoint on f) \u2192 (\u2200 i, MeasurableSet (f i)) \u2192 (\u2200 i, C (f i)) \u2192 C (\u22c3 i, f i)) :\n    \u2200 \u2983t\u2984, MeasurableSet t \u2192 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 \u03b1] [MeasurableSpace \u03b1] [OpensMeasurableSpace \u03b1] [TopologicalSpace \u03b2]\n  [MeasurableSpace \u03b2] [OpensMeasurableSpace \u03b2] [TopologicalSpace \u03b3] [MeasurableSpace \u03b3]\n  [BorelSpace \u03b3] [TopologicalSpace \u03b3\u2082] [MeasurableSpace \u03b3\u2082] [BorelSpace \u03b3\u2082] [MeasurableSpace \u03b4]\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\u03b4.measurableSet (h : IsG\u03b4 s) : MeasurableSet s :=\n  by\n  rcases h with \u27e8S, hSo, hSc, rfl\u27e9\n  exact MeasurableSet.inter\u209b hSc fun t ht => (hSo t ht).MeasurableSet\n#align is_G\u03b4.measurable_set IsG\u03b4.measurableSet\n\ntheorem measurableSet_of_continuousAt {\u03b2} [EMetricSpace \u03b2] (f : \u03b1 \u2192 \u03b2) :\n    MeasurableSet { x | ContinuousAt f x } :=\n  (isG\u03b4_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 \u03b1] (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 : \u03b4 \u2192 \u03b3} (hf : \u2200 s, IsOpen s \u2192 MeasurableSet (f \u207b\u00b9' s)) :\n    Measurable f := by\n  rw [\u2039BorelSpace \u03b3\u203a.measurable_eq]\n  exact measurable_generateFrom hf\n#align measurable_of_is_open measurable_of_isOpen\n\ntheorem measurable_of_isClosed {f : \u03b4 \u2192 \u03b3} (hf : \u2200 s, IsClosed s \u2192 MeasurableSet (f \u207b\u00b9' s)) :\n    Measurable f := by\n  apply measurable_of_isOpen; intro s hs\n  rw [\u2190 MeasurableSet.compl_iff, \u2190 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 : \u03b4 \u2192 \u03b3}\n    (hf : \u2200 s, IsClosed s \u2192 s.Nonempty \u2192 s \u2260 univ \u2192 MeasurableSet (f \u207b\u00b9' s)) : Measurable f :=\n  by\n  apply measurable_of_isClosed; intro s hs\n  cases' eq_empty_or_nonempty s with h1 h1; \u00b7 simp [h1]\n  by_cases h2 : s = univ; \u00b7 simp [h2]\n  exact hf s hs h1 h2\n#align measurable_of_is_closed' measurable_of_is_closed'\n\ninstance nhds_isMeasurablyGenerated (a : \u03b1) : (\ud835\udcdd a).IsMeasurablyGenerated :=\n  by\n  rw [nhds, inf\u1d62_subtype']\n  refine' @Filter.inf\u1d62_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 `\ud835\udcdd[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 \u03b1} (hs : MeasurableSet s) (a : \u03b1) :\n    (\ud835\udcdd[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 \u03b1] :\n    MeasurableSingletonClass \u03b1 :=\n  \u27e8fun x => isClosed_singleton.MeasurableSet\u27e9\n#align opens_measurable_space.to_measurable_singleton_class OpensMeasurableSpace.to_measurableSingletonClass\n\ninstance Pi.opensMeasurableSpace {\u03b9 : Type _} {\u03c0 : \u03b9 \u2192 Type _} [Countable \u03b9]\n    [t' : \u2200 i, TopologicalSpace (\u03c0 i)] [\u2200 i, MeasurableSpace (\u03c0 i)]\n    [\u2200 i, SecondCountableTopology (\u03c0 i)] [\u2200 i, OpensMeasurableSpace (\u03c0 i)] :\n    OpensMeasurableSpace (\u2200 i, \u03c0 i) := by\n  constructor\n  have :\n    Pi.topologicalSpace =\n      generate_from\n        { t |\n          \u2203 (s : \u2200 a, Set (\u03c0 a))(i : Finset \u03b9),\n            (\u2200 a \u2208 i, s a \u2208 countable_basis (\u03c0 a)) \u2227 t = pi (\u2191i) s } :=\n    by rw [funext fun a => @eq_generate_from_countable_basis (\u03c0 a) _ _, pi_generateFrom_eq]\n  rw [borel_eq_generateFrom_of_subbasis this]\n  apply generate_from_le\n  rintro _ \u27e8s, i, hi, rfl\u27e9\n  refine' MeasurableSet.pi i.countable_to_set fun a ha => IsOpen.measurableSet _\n  rw [eq_generate_from_countable_basis (\u03c0 a)]\n  exact generate_open.basic _ (hi a ha)\n#align pi.opens_measurable_space Pi.opensMeasurableSpace\n\ninstance Prod.opensMeasurableSpace [SecondCountableTopology \u03b1] [SecondCountableTopology \u03b2] :\n    OpensMeasurableSpace (\u03b1 \u00d7 \u03b2) := by\n  constructor\n  rw [((is_basis_countable_basis \u03b1).Prod (is_basis_countable_basis \u03b2)).borel_eq_generateFrom]\n  apply generate_from_le\n  rintro _ \u27e8u, v, hu, hv, rfl\u27e9\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 {\u03b1' : Type _} [TopologicalSpace \u03b1'] [MeasurableSpace \u03b1']\n\ntheorem interior_ae_eq_of_null_frontier {\u03bc : Measure \u03b1'} {s : Set \u03b1'} (h : \u03bc (frontier s) = 0) :\n    interior s =\u1d50[\u03bc] 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 {\u03bc : Measure \u03b1'} {s : Set \u03b1'} (h : \u03bc (frontier s) = 0) :\n    \u03bc (interior s) = \u03bc 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 \u03b1} {\u03bc : Measure \u03b1} (h : \u03bc (frontier s) = 0) :\n    NullMeasurableSet s \u03bc :=\n  \u27e8interior s, isOpen_interior.MeasurableSet, (interior_ae_eq_of_null_frontier h).symm\u27e9\n#align null_measurable_set_of_null_frontier nullMeasurableSetOfNullFrontier\n\ntheorem closure_ae_eq_of_null_frontier {\u03bc : Measure \u03b1'} {s : Set \u03b1'} (h : \u03bc (frontier s) = 0) :\n    closure s =\u1d50[\u03bc] 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 {\u03bc : Measure \u03b1'} {s : Set \u03b1'} (h : \u03bc (frontier s) = 0) :\n    \u03bc (closure s) = \u03bc 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 \u03b1] [OrderClosedTopology \u03b1] {a b x : \u03b1}\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 : (\ud835\udcdd[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 : (\ud835\udcdd[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 (\ud835\udcdd[Icc a b] x) :=\n  by\n  rw [\u2190 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 \u03b1).IsMeasurablyGenerated :=\n  @Filter.inf\u1d62_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 \u03b1).IsMeasurablyGenerated :=\n  @Filter.inf\u1d62_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 \u03b1] [OrderClosedTopology \u03b1] [SecondCountableTopology \u03b1] {a b : \u03b1}\n\n@[measurability]\ntheorem measurableSet_le' : MeasurableSet { p : \u03b1 \u00d7 \u03b1 | p.1 \u2264 p.2 } :=\n  OrderClosedTopology.isClosed_le'.MeasurableSet\n#align measurable_set_le' measurableSet_le'\n\n@[measurability]\ntheorem measurableSet_le {f g : \u03b4 \u2192 \u03b1} (hf : Measurable f) (hg : Measurable g) :\n    MeasurableSet { a | f a \u2264 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 \u03b1] [OrderClosedTopology \u03b1] {a b x : \u03b1}\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 : (\ud835\udcdd[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 : (\ud835\udcdd[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 (\ud835\udcdd[[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 \u03b1] : MeasurableSet { p : \u03b1 \u00d7 \u03b1 | 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 \u03b1] {f g : \u03b4 \u2192 \u03b1} (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 \u03b1] {\u03bc : Measure \u03b4} {f g : \u03b4 \u2192 \u03b1}\n    (hf : AeMeasurable f \u03bc) (hg : AeMeasurable g \u03bc) : NullMeasurableSet { a | f a < g a } \u03bc :=\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 := \u22c3 (x \u2208 s) (y \u2208 s), Ioo x y\n  have huopen : IsOpen u := isOpen_bunion\u1d62 fun x hx => isOpen_bunion\u1d62 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 \u2286 s :=\n    Union\u2082_subset fun x hx => Union\u2082_subset fun y hy => Ioo_subset_Icc_self.trans (h.out hx hy)\n  rw [\u2190 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 {\u03b1 : Type _} [TopologicalSpace \u03b1] [LinearOrder \u03b1]\n    [OrderClosedTopology \u03b1] (s t : Set \u03b1) :\n    MeasurableSpace.generateFrom { S | \u2203 l \u2208 s, \u2203 u \u2208 t, \u2203 h : l < u, Ico l u = S } \u2264 borel \u03b1 :=\n  by\n  apply generate_from_le\n  borelize \u03b1\n  rintro _ \u27e8a, -, b, -, -, rfl\u27e9\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 {\u03b1 : Type _} [TopologicalSpace \u03b1] [LinearOrder \u03b1]\n    [OrderTopology \u03b1] [SecondCountableTopology \u03b1] {s : Set \u03b1} (hd : Dense s)\n    (hbot : \u2200 x, IsBot x \u2192 x \u2208 s) (hIoo : \u2200 x y : \u03b1, x < y \u2192 Ioo x y = \u2205 \u2192 y \u2208 s) :\n    borel \u03b1 = generateFrom { S : Set \u03b1 | \u2203 l \u2208 s, \u2203 u \u2208 s, \u2203 h : l < u, Ico l u = S } :=\n  by\n  set S : Set (Set \u03b1) := { S | \u2203 l \u2208 s, \u2203 u \u2208 s, \u2203 h : l < u, Ico l u = S }\n  refine' le_antisymm _ (generateFrom_Ico_mem_le_borel _ _)\n  letI : MeasurableSpace \u03b1 := 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 \u27e8t, hts, hc, htd, htb, htt\u27e9\n  by_cases ha : \u2200 b < a, (Ioo b a).Nonempty\n  \u00b7 convert_to MeasurableSet (\u22c3 (l \u2208 t) (u \u2208 t) (hlu : l < u) (hu : u \u2264 a), Ico l u)\n    \u00b7 ext y\n      simp only [mem_Union, mem_Iio, mem_Ico]\n      constructor\n      \u00b7 intro hy\n        rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) y with \u27e8l, hlt, hly\u27e9\n        rcases htd.exists_mem_open isOpen_Ioo (ha y hy) with \u27e8u, hut, hyu, hua\u27e9\n        exact \u27e8l, hlt, u, hut, hly.trans_lt hyu, hua.le, hly, hyu\u27e9\n      \u00b7 rintro \u27e8l, -, u, -, -, hua, -, hyu\u27e9\n        exact hyu.trans_le hua\n    \u00b7 refine' MeasurableSet.bunion\u1d62 hc fun a ha => MeasurableSet.bunion\u1d62 hc fun b hb => _\n      refine' MeasurableSet.union\u1d62 fun hab => MeasurableSet.union\u1d62 fun hb' => _\n      exact generate_measurable.basic _ \u27e8a, hts ha, b, hts hb, hab, mem_singleton _\u27e9\n  \u00b7 simp only [not_forall, not_nonempty_iff_eq_empty] at ha\n    replace ha : a \u2208 s := hIoo ha.some a ha.some_spec.fst ha.some_spec.snd\n    convert_to MeasurableSet (\u22c3 (l \u2208 t) (hl : l < a), Ico l a)\n    \u00b7 symm\n      simp only [\u2190 Ici_inter_Iio, \u2190 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 \u27e8z, hzt, hzx\u27e9\n      exact \u27e8z, hzt, hzx.trans_lt hx, hzx\u27e9\n    \u00b7 refine' MeasurableSet.bunion\u1d62 hc fun x hx => MeasurableSet.union\u1d62 fun hlt => _\n      exact generate_measurable.basic _ \u27e8x, hts hx, a, ha, hlt, mem_singleton _\u27e9\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 {\u03b1 : Type _} [TopologicalSpace \u03b1] [LinearOrder \u03b1]\n    [OrderTopology \u03b1] [SecondCountableTopology \u03b1] [DenselyOrdered \u03b1] [NoMinOrder \u03b1] {s : Set \u03b1}\n    (hd : Dense s) :\n    borel \u03b1 = generateFrom { S : Set \u03b1 | \u2203 l \u2208 s, \u2203 u \u2208 s, \u2203 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 (\u03b1 : Type _) [TopologicalSpace \u03b1] [SecondCountableTopology \u03b1]\n    [LinearOrder \u03b1] [OrderTopology \u03b1] :\n    borel \u03b1 = generateFrom { S : Set \u03b1 | \u2203 (l u : _)(h : l < u), Ico l u = S } := by\n  simpa only [exists_prop, mem_univ, true_and_iff] using\n    (@dense_univ \u03b1 _).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 {\u03b1 : Type _} [TopologicalSpace \u03b1] [LinearOrder \u03b1]\n    [OrderTopology \u03b1] [SecondCountableTopology \u03b1] {s : Set \u03b1} (hd : Dense s)\n    (hbot : \u2200 x, IsTop x \u2192 x \u2208 s) (hIoo : \u2200 x y : \u03b1, x < y \u2192 Ioo x y = \u2205 \u2192 x \u2208 s) :\n    borel \u03b1 = generateFrom { S : Set \u03b1 | \u2203 l \u2208 s, \u2203 u \u2208 s, \u2203 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  \u00b7 ext s\n    constructor <;> rintro \u27e8l, hl, u, hu, hlt, rfl\u27e9\n    exacts[\u27e8u, hu, l, hl, hlt, dual_Ico\u27e9, \u27e8u, hu, l, hl, hlt, dual_Ioc\u27e9]\n  \u00b7 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 {\u03b1 : Type _} [TopologicalSpace \u03b1] [LinearOrder \u03b1]\n    [OrderTopology \u03b1] [SecondCountableTopology \u03b1] [DenselyOrdered \u03b1] [NoMaxOrder \u03b1] {s : Set \u03b1}\n    (hd : Dense s) :\n    borel \u03b1 = generateFrom { S : Set \u03b1 | \u2203 l \u2208 s, \u2203 u \u2208 s, \u2203 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 (\u03b1 : Type _) [TopologicalSpace \u03b1] [SecondCountableTopology \u03b1]\n    [LinearOrder \u03b1] [OrderTopology \u03b1] :\n    borel \u03b1 = generateFrom { S : Set \u03b1 | \u2203 (l u : _)(h : l < u), Ioc l u = S } := by\n  simpa only [exists_prop, mem_univ, true_and_iff] using\n    (@dense_univ \u03b1 _).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`\u03b1` 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 `\u03bc` and\n`\u03bd`. -/\ntheorem ext_of_Ico_finite {\u03b1 : Type _} [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1}\n    [SecondCountableTopology \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [BorelSpace \u03b1] (\u03bc \u03bd : Measure \u03b1)\n    [IsFiniteMeasure \u03bc] (h\u03bc\u03bd : \u03bc univ = \u03bd univ) (h : \u2200 \u2983a b\u2984, a < b \u2192 \u03bc (Ico a b) = \u03bd (Ico a b)) :\n    \u03bc = \u03bd :=\n  by\n  refine'\n    ext_of_generate_finite _ (borel_space.measurable_eq.trans (borel_eq_generateFrom_Ico \u03b1))\n      (isPiSystem_Ico (id : \u03b1 \u2192 \u03b1) id) _ h\u03bc\u03bd\n  \u00b7 rintro - \u27e8a, b, hlt, rfl\u27e9\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`\u03b1` 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 `\u03bc` and\n`\u03bd`. -/\ntheorem ext_of_Ioc_finite {\u03b1 : Type _} [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1}\n    [SecondCountableTopology \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [BorelSpace \u03b1] (\u03bc \u03bd : Measure \u03b1)\n    [IsFiniteMeasure \u03bc] (h\u03bc\u03bd : \u03bc univ = \u03bd univ) (h : \u2200 \u2983a b\u2984, a < b \u2192 \u03bc (Ioc a b) = \u03bd (Ioc a b)) :\n    \u03bc = \u03bd := by\n  refine' @ext_of_Ico_finite \u03b1\u1d52\u1d48 _ _ _ _ _ \u2039_\u203a \u03bc \u03bd _ h\u03bc\u03bd 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' {\u03b1 : Type _} [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1}\n    [SecondCountableTopology \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [BorelSpace \u03b1] [NoMaxOrder \u03b1]\n    (\u03bc \u03bd : Measure \u03b1) (h\u03bc : \u2200 \u2983a b\u2984, a < b \u2192 \u03bc (Ico a b) \u2260 \u221e)\n    (h : \u2200 \u2983a b\u2984, a < b \u2192 \u03bc (Ico a b) = \u03bd (Ico a b)) : \u03bc = \u03bd :=\n  by\n  rcases exists_countable_dense_bot_top \u03b1 with \u27e8s, hsc, hsd, hsb, hst\u27e9\n  have : (\u22c3 (l \u2208 s) (u \u2208 s) (h : l < u), {Ico l u} : Set (Set \u03b1)).Countable :=\n    hsc.bUnion fun l hl => hsc.bUnion fun u hu => countable_Union fun _ => countable_singleton _\n  simp only [\u2190 set_of_eq_eq_singleton, \u2190 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 \u03b1)) (isPiSystem_Ico id id) _ this\n      _ _ _\n  \u00b7 rintro _ \u27e8l, -, u, -, h, rfl\u27e9\n    exact \u27e8l, u, h, rfl\u27e9\n  \u00b7 refine' sUnion_eq_univ_iff.2 fun x => _\n    rcases hsd.exists_le' hsb x with \u27e8l, hls, hlx\u27e9\n    rcases hsd.exists_gt x with \u27e8u, hus, hxu\u27e9\n    exact \u27e8_, \u27e8l, hls, u, hus, hlx.trans_lt hxu, rfl\u27e9, hlx, hxu\u27e9\n  \u00b7 rintro _ \u27e8l, -, u, -, hlt, rfl\u27e9\n    exact h\u03bc hlt\n  \u00b7 rintro _ \u27e8l, u, hlt, rfl\u27e9\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' {\u03b1 : Type _} [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1}\n    [SecondCountableTopology \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [BorelSpace \u03b1] [NoMinOrder \u03b1]\n    (\u03bc \u03bd : Measure \u03b1) (h\u03bc : \u2200 \u2983a b\u2984, a < b \u2192 \u03bc (Ioc a b) \u2260 \u221e)\n    (h : \u2200 \u2983a b\u2984, a < b \u2192 \u03bc (Ioc a b) = \u03bd (Ioc a b)) : \u03bc = \u03bd :=\n  by\n  refine' @ext_of_Ico' \u03b1\u1d52\u1d48 _ _ _ _ _ \u2039_\u203a _ \u03bc \u03bd _ _ <;> intro a b hab <;> erw [dual_Ico]\n  exacts[h\u03bc 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 {\u03b1 : Type _} [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1}\n    [SecondCountableTopology \u03b1] [ConditionallyCompleteLinearOrder \u03b1] [OrderTopology \u03b1]\n    [BorelSpace \u03b1] [NoMaxOrder \u03b1] (\u03bc \u03bd : Measure \u03b1) [IsLocallyFiniteMeasure \u03bc]\n    (h : \u2200 \u2983a b\u2984, a < b \u2192 \u03bc (Ico a b) = \u03bd (Ico a b)) : \u03bc = \u03bd :=\n  \u03bc.ext_of_Ico' \u03bd (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 {\u03b1 : Type _} [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1}\n    [SecondCountableTopology \u03b1] [ConditionallyCompleteLinearOrder \u03b1] [OrderTopology \u03b1]\n    [BorelSpace \u03b1] [NoMinOrder \u03b1] (\u03bc \u03bd : Measure \u03b1) [IsLocallyFiniteMeasure \u03bc]\n    (h : \u2200 \u2983a b\u2984, a < b \u2192 \u03bc (Ioc a b) = \u03bd (Ioc a b)) : \u03bc = \u03bd :=\n  \u03bc.ext_of_Ioc' \u03bd (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 {\u03b1 : Type _} [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1}\n    [SecondCountableTopology \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [BorelSpace \u03b1] (\u03bc \u03bd : Measure \u03b1)\n    [IsFiniteMeasure \u03bc] (h : \u2200 a, \u03bc (Iic a) = \u03bd (Iic a)) : \u03bc = \u03bd :=\n  by\n  refine' ext_of_Ioc_finite \u03bc \u03bd _ fun a b hlt => _\n  \u00b7 rcases exists_countable_dense_bot_top \u03b1 with \u27e8s, hsc, hsd, -, hst\u27e9\n    have : DirectedOn (\u00b7 \u2264 \u00b7) s := directedOn_iff_directed.2 (directed_of_sup fun _ _ => id)\n    simp only [\u2190 bsupr_measure_Iic hsc (hsd.exists_ge' hst) this, h]\n  rw [\u2190 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  \u00b7 rw [\u2190 h a]\n    exact (measure_lt_top \u03bc _).Ne\n  \u00b7 exact (measure_lt_top \u03bc _).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 {\u03b1 : Type _} [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1}\n    [SecondCountableTopology \u03b1] [LinearOrder \u03b1] [OrderTopology \u03b1] [BorelSpace \u03b1] (\u03bc \u03bd : Measure \u03b1)\n    [IsFiniteMeasure \u03bc] (h : \u2200 a, \u03bc (Ici a) = \u03bd (Ici a)) : \u03bc = \u03bd :=\n  @ext_of_Iic \u03b1\u1d52\u1d48 _ _ _ _ _ \u2039_\u203a _ _ _ 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 \u03b1] [OrderClosedTopology \u03b1] {a b : \u03b1}\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 \u03b1]\n\n@[measurability]\ntheorem Measurable.max {f g : \u03b4 \u2192 \u03b1} (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 : \u03b4 \u2192 \u03b1} {\u03bc : Measure \u03b4} (hf : AeMeasurable f \u03bc)\n    (hg : AeMeasurable g \u03bc) : AeMeasurable (fun a => max (f a) (g a)) \u03bc :=\n  \u27e8fun a => max (hf.mk f a) (hg.mk g a), hf.measurable_mk.max hg.measurable_mk,\n    EventuallyEq.comp\u2082 hf.ae_eq_mk _ hg.ae_eq_mk\u27e9\n#align ae_measurable.max AeMeasurable.max\n\n@[measurability]\ntheorem Measurable.min {f g : \u03b4 \u2192 \u03b1} (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 : \u03b4 \u2192 \u03b1} {\u03bc : Measure \u03b4} (hf : AeMeasurable f \u03bc)\n    (hg : AeMeasurable g \u03bc) : AeMeasurable (fun a => min (f a) (g a)) \u03bc :=\n  \u27e8fun a => min (hf.mk f a) (hg.mk g a), hf.measurable_mk.min hg.measurable_mk,\n    EventuallyEq.comp\u2082 hf.ae_eq_mk _ hg.ae_eq_mk\u27e9\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 : \u03b1 \u2192 \u03b3} (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 : \u03b1 \u2192 \u03b3} (h : Continuous f) {\u03bc : Measure \u03b1} : AeMeasurable f \u03bc :=\n  h.Measurable.AeMeasurable\n#align continuous.ae_measurable Continuous.aeMeasurable\n\ntheorem ClosedEmbedding.measurable {f : \u03b1 \u2192 \u03b3} (hf : ClosedEmbedding f) : Measurable f :=\n  hf.Continuous.Measurable\n#align closed_embedding.measurable ClosedEmbedding.measurable\n\ntheorem Continuous.isOpenPosMeasureMap {f : \u03b2 \u2192 \u03b3} (hf : Continuous f)\n    (hf_surj : Function.Surjective f) {\u03bc : Measure \u03b2} [\u03bc.IsOpenPosMeasure] :\n    (Measure.map f \u03bc).IsOpenPosMeasure :=\n  by\n  refine' \u27e8fun U hUo hUne => _\u27e9\n  rw [measure.map_apply hf.measurable hUo.measurable_set]\n  exact (hUo.preimage hf).measure_ne_zero \u03bc (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 : \u03b1 \u2192 \u03b3} {s : Set \u03b1} [\u2200 j : \u03b1, Decidable (j \u2208 s)]\n    (hf : ContinuousOn f s) (hg : ContinuousOn g (s\u1d9c)) (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  \u00b7 rcases _root_.continuous_on_iff'.1 hf t ht with \u27e8u, u_open, hu\u27e9\n    rw [hu]\n    exact u_open.measurable_set.inter hs\n  \u00b7 rcases _root_.continuous_on_iff'.1 hg t ht with \u27e8u, u_open, hu\u27e9\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 \u03b3] [ContinuousMul \u03b3] :\n    HasMeasurableMul \u03b3\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 \u03b3] [ContinuousSub \u03b3] :\n    HasMeasurableSub \u03b3\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 \u03b3] [TopologicalGroup \u03b3] :\n    HasMeasurableInv \u03b3 :=\n  \u27e8continuous_inv.Measurable\u27e9\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 \u03b1} [TopologicalSpace M]\n    [TopologicalSpace \u03b1] [MeasurableSpace M] [MeasurableSpace \u03b1] [OpensMeasurableSpace M]\n    [BorelSpace \u03b1] [SMul M \u03b1] [ContinuousSMul M \u03b1] : HasMeasurableSmul M \u03b1 :=\n  \u27e8fun c => (continuous_const_smul _).Measurable, fun y =>\n    (continuous_id.smul continuous_const).Measurable\u27e9\n#align has_continuous_smul.has_measurable_smul ContinuousSMul.hasMeasurableSmul\n\nsection Lattice\n\ninstance (priority := 100) ContinuousSup.hasMeasurableSup [Sup \u03b3] [ContinuousSup \u03b3] :\n    HasMeasurableSup \u03b3\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\u2082 [SecondCountableTopology \u03b3] [Sup \u03b3]\n    [ContinuousSup \u03b3] : HasMeasurableSup\u2082 \u03b3 :=\n  \u27e8continuous_sup.Measurable\u27e9\n#align has_continuous_sup.has_measurable_sup\u2082 ContinuousSup.hasMeasurableSup\u2082\n\ninstance (priority := 100) ContinuousInf.hasMeasurableInf [Inf \u03b3] [ContinuousInf \u03b3] :\n    HasMeasurableInf \u03b3\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\u2082 [SecondCountableTopology \u03b3] [Inf \u03b3]\n    [ContinuousInf \u03b3] : HasMeasurableInf\u2082 \u03b3 :=\n  \u27e8continuous_inf.Measurable\u27e9\n#align has_continuous_inf.has_measurable_inf\u2082 ContinuousInf.hasMeasurableInf\u2082\n\nend Lattice\n\nsection Homeomorph\n\n@[measurability]\nprotected theorem Homeomorph.measurable (h : \u03b1 \u2243\u209c \u03b3) : 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 : \u03b3 \u2243\u209c \u03b3\u2082) : \u03b3 \u2243\u1d50 \u03b3\u2082\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 : \u03b3 \u2243\u209c \u03b3\u2082) : (h.toMeasurableEquiv : \u03b3 \u2192 \u03b3\u2082) = h :=\n  rfl\n#align homeomorph.to_measurable_equiv_coe Homeomorph.toMeasurableEquiv_coe\n\n@[simp]\ntheorem Homeomorph.toMeasurableEquiv_symm_coe (h : \u03b3 \u2243\u209c \u03b3\u2082) :\n    (h.toMeasurableEquiv.symm : \u03b3\u2082 \u2192 \u03b3) = 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(\u03b1, \u03b3)) : Measurable f :=\n  f.Continuous.Measurable\n#align continuous_map.measurable ContinuousMap.measurable\n\ntheorem measurable_of_continuousOn_compl_singleton [T1Space \u03b1] {f : \u03b1 \u2192 \u03b3} (a : \u03b1)\n    (hf : ContinuousOn f ({a}\u1d9c)) : 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 \u03b1] [SecondCountableTopology \u03b2] {f : \u03b4 \u2192 \u03b1}\n    {g : \u03b4 \u2192 \u03b2} {c : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (h : Continuous fun p : \u03b1 \u00d7 \u03b2 => 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 \u03b1] [SecondCountableTopology \u03b2] {f : \u03b4 \u2192 \u03b1}\n    {g : \u03b4 \u2192 \u03b2} {c : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {\u03bc : Measure \u03b4} (h : Continuous fun p : \u03b1 \u00d7 \u03b2 => c p.1 p.2)\n    (hf : AeMeasurable f \u03bc) (hg : AeMeasurable g \u03bc) : AeMeasurable (fun a => c (f a) (g a)) \u03bc :=\n  h.Measurable.compAeMeasurable (hf.prod_mk hg)\n#align continuous.ae_measurable2 Continuous.aeMeasurable2\n\ninstance (priority := 100) HasContinuousInv\u2080.hasMeasurableInv [GroupWithZero \u03b3] [T1Space \u03b3]\n    [HasContinuousInv\u2080 \u03b3] : HasMeasurableInv \u03b3 :=\n  \u27e8measurable_of_continuousOn_compl_singleton 0 continuousOn_inv\u2080\u27e9\n#align has_continuous_inv\u2080.has_measurable_inv HasContinuousInv\u2080.hasMeasurableInv\n\n@[to_additive]\ninstance (priority := 100) ContinuousMul.hasMeasurableMul\u2082 [SecondCountableTopology \u03b3] [Mul \u03b3]\n    [ContinuousMul \u03b3] : HasMeasurableMul\u2082 \u03b3 :=\n  \u27e8continuous_mul.Measurable\u27e9\n#align has_continuous_mul.has_measurable_mul\u2082 ContinuousMul.hasMeasurableMul\u2082\n#align has_continuous_add.has_measurable_mul\u2082 ContinuousAdd.hasMeasurableMul\u2082\n\ninstance (priority := 100) ContinuousSub.hasMeasurableSub\u2082 [SecondCountableTopology \u03b3] [Sub \u03b3]\n    [ContinuousSub \u03b3] : HasMeasurableSub\u2082 \u03b3 :=\n  \u27e8continuous_sub.Measurable\u27e9\n#align has_continuous_sub.has_measurable_sub\u2082 ContinuousSub.hasMeasurableSub\u2082\n\ninstance (priority := 100) ContinuousSMul.hasMeasurableSmul\u2082 {M \u03b1} [TopologicalSpace M]\n    [SecondCountableTopology M] [MeasurableSpace M] [OpensMeasurableSpace M] [TopologicalSpace \u03b1]\n    [SecondCountableTopology \u03b1] [MeasurableSpace \u03b1] [BorelSpace \u03b1] [SMul M \u03b1] [ContinuousSMul M \u03b1] :\n    HasMeasurableSmul\u2082 M \u03b1 :=\n  \u27e8continuous_smul.Measurable\u27e9\n#align has_continuous_smul.has_measurable_smul\u2082 ContinuousSMul.hasMeasurableSmul\u2082\n\nend\n\nsection BorelSpace\n\nvariable [TopologicalSpace \u03b1] [MeasurableSpace \u03b1] [BorelSpace \u03b1] [TopologicalSpace \u03b2]\n  [MeasurableSpace \u03b2] [BorelSpace \u03b2] [TopologicalSpace \u03b3] [MeasurableSpace \u03b3] [BorelSpace \u03b3]\n  [MeasurableSpace \u03b4]\n\ntheorem pi_le_borel_pi {\u03b9 : Type _} {\u03c0 : \u03b9 \u2192 Type _} [\u2200 i, TopologicalSpace (\u03c0 i)]\n    [\u2200 i, MeasurableSpace (\u03c0 i)] [\u2200 i, BorelSpace (\u03c0 i)] : MeasurableSpace.pi \u2264 borel (\u2200 i, \u03c0 i) :=\n  by\n  have : \u2039\u2200 i, MeasurableSpace (\u03c0 i)\u203a = fun i => borel (\u03c0 i) :=\n    funext fun i => BorelSpace.measurable_eq\n  rw [this]\n  exact sup\u1d62_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 \u2264 borel (\u03b1 \u00d7 \u03b2) :=\n  by\n  rw [\u2039BorelSpace \u03b1\u203a.measurable_eq, \u2039BorelSpace \u03b2\u203a.measurable_eq]\n  refine' sup_le _ _\n  \u00b7 exact comap_le_iff_le_map.mpr continuous_fst.borel_measurable\n  \u00b7 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 {\u03b9 : Type _} {\u03c0 : \u03b9 \u2192 Type _} [Countable \u03b9] [\u2200 i, TopologicalSpace (\u03c0 i)]\n    [\u2200 i, MeasurableSpace (\u03c0 i)] [\u2200 i, SecondCountableTopology (\u03c0 i)] [\u2200 i, BorelSpace (\u03c0 i)] :\n    BorelSpace (\u2200 i, \u03c0 i) :=\n  \u27e8le_antisymm pi_le_borel_pi OpensMeasurableSpace.borel_le\u27e9\n#align pi.borel_space Pi.borelSpace\n\ninstance Prod.borelSpace [SecondCountableTopology \u03b1] [SecondCountableTopology \u03b2] :\n    BorelSpace (\u03b1 \u00d7 \u03b2) :=\n  \u27e8le_antisymm prod_le_borel_prod OpensMeasurableSpace.borel_le\u27e9\n#align prod.borel_space Prod.borelSpace\n\nprotected theorem Embedding.measurableEmbedding {f : \u03b1 \u2192 \u03b2} (h\u2081 : Embedding f)\n    (h\u2082 : MeasurableSet (range f)) : MeasurableEmbedding f :=\n  show MeasurableEmbedding (coe \u2218 (Homeomorph.ofEmbedding f h\u2081).toMeasurableEquiv) from\n    (MeasurableEmbedding.subtype_coe h\u2082).comp (MeasurableEquiv.measurableEmbedding _)\n#align embedding.measurable_embedding Embedding.measurableEmbedding\n\nprotected theorem ClosedEmbedding.measurableEmbedding {f : \u03b1 \u2192 \u03b2} (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 : \u03b1 \u2192 \u03b2} (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 \u03b1] [OrderTopology \u03b1] [SecondCountableTopology \u03b1]\n\ntheorem measurable_of_Iio {f : \u03b4 \u2192 \u03b1} (hf : \u2200 x, MeasurableSet (f \u207b\u00b9' Iio x)) : Measurable f :=\n  by\n  convert measurable_generateFrom _\n  exact borel_space.measurable_eq.trans (borel_eq_generateFrom_Iio _)\n  rintro _ \u27e8x, rfl\u27e9; exact hf x\n#align measurable_of_Iio measurable_of_Iio\n\ntheorem UpperSemicontinuous.measurable [TopologicalSpace \u03b4] [OpensMeasurableSpace \u03b4] {f : \u03b4 \u2192 \u03b1}\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 : \u03b4 \u2192 \u03b1} (hf : \u2200 x, MeasurableSet (f \u207b\u00b9' Ioi x)) : Measurable f :=\n  by\n  convert measurable_generateFrom _\n  exact borel_space.measurable_eq.trans (borel_eq_generateFrom_Ioi _)\n  rintro _ \u27e8x, rfl\u27e9; exact hf x\n#align measurable_of_Ioi measurable_of_Ioi\n\ntheorem LowerSemicontinuous.measurable [TopologicalSpace \u03b4] [OpensMeasurableSpace \u03b4] {f : \u03b4 \u2192 \u03b1}\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 : \u03b4 \u2192 \u03b1} (hf : \u2200 x, MeasurableSet (f \u207b\u00b9' Iic x)) : Measurable f :=\n  by\n  apply measurable_of_Ioi\n  simp_rw [\u2190 compl_Iic, preimage_compl, MeasurableSet.compl_iff]\n  assumption\n#align measurable_of_Iic measurable_of_Iic\n\ntheorem measurable_of_Ici {f : \u03b4 \u2192 \u03b1} (hf : \u2200 x, MeasurableSet (f \u207b\u00b9' Ici x)) : Measurable f :=\n  by\n  apply measurable_of_Iio\n  simp_rw [\u2190 compl_Ici, preimage_compl, MeasurableSet.compl_iff]\n  assumption\n#align measurable_of_Ici measurable_of_Ici\n\ntheorem Measurable.isLUB {\u03b9} [Countable \u03b9] {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} {g : \u03b4 \u2192 \u03b1} (hf : \u2200 i, Measurable (f i))\n    (hg : \u2200 b, IsLUB { a | \u2203 i, f i b = a } (g b)) : Measurable g :=\n  by\n  change \u2200 b, IsLUB (range fun i => f i b) (g b) at hg\n  rw [\u2039BorelSpace \u03b1\u203a.measurable_eq, borel_eq_generateFrom_Ioi \u03b1]\n  apply measurable_generateFrom\n  rintro _ \u27e8a, rfl\u27e9\n  simp_rw [Set.preimage, mem_Ioi, lt_isLUB_iff (hg _), exists_range_iff, set_of_exists]\n  exact MeasurableSet.union\u1d62 fun i => hf i (isOpen_lt' _).MeasurableSet\n#align measurable.is_lub Measurable.isLUB\n\nprivate theorem ae_measurable.is_lub_of_nonempty {\u03b9} (h\u03b9 : Nonempty \u03b9) {\u03bc : Measure \u03b4} [Countable \u03b9]\n    {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} {g : \u03b4 \u2192 \u03b1} (hf : \u2200 i, AeMeasurable (f i) \u03bc)\n    (hg : \u2200\u1d50 b \u2202\u03bc, IsLUB { a | \u2203 i, f i b = a } (g b)) : AeMeasurable g \u03bc :=\n  by\n  let p : \u03b4 \u2192 (\u03b9 \u2192 \u03b1) \u2192 Prop := fun x f' => IsLUB { a | \u2203 i, f' i = a } (g x)\n  let g_seq x := ite (x \u2208 aeSeqSet hf p) (g x) (\u27e8g x\u27e9 : Nonempty \u03b1).some\n  have hg_seq : \u2200 b, IsLUB { a | \u2203 i, aeSeq hf p i b = a } (g_seq b) :=\n    by\n    intro b\n    haveI h\u03b1 : Nonempty \u03b1 := Nonempty.map g \u27e8b\u27e9\n    simp only [aeSeq, g_seq]\n    split_ifs\n    \u00b7 have h_set_eq : { a : \u03b1 | \u2203 i : \u03b9, (hf i).mk (f i) b = a } = { a : \u03b1 | \u2203 i : \u03b9, 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    \u00b7 have h_singleton : { a : \u03b1 | \u2203 i : \u03b9, h\u03b1.some = a } = {h\u03b1.some} :=\n        by\n        ext1 x\n        exact \u27e8fun hx => hx.some_spec.symm, fun hx => \u27e8h\u03b9.some, hx.symm\u27e9\u27e9\n      rw [h_singleton]\n      exact isLUB_singleton\n  refine' \u27e8g_seq, Measurable.isLUB (aeSeq.measurable hf p) hg_seq, _\u27e9\n  exact\n    (ite_ae_eq_of_measure_compl_zero g (fun x => (\u27e8g x\u27e9 : Nonempty \u03b1).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 {\u03b9} {\u03bc : Measure \u03b4} [Countable \u03b9] {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} {g : \u03b4 \u2192 \u03b1}\n    (hf : \u2200 i, AeMeasurable (f i) \u03bc) (hg : \u2200\u1d50 b \u2202\u03bc, IsLUB { a | \u2203 i, f i b = a } (g b)) :\n    AeMeasurable g \u03bc := by\n  by_cases h\u03bc : \u03bc = 0\n  \u00b7 rw [h\u03bc]\n    exact aeMeasurableZeroMeasure\n  have : \u03bc.ae.ne_bot := by simpa [ne_bot_iff]\n  by_cases h\u03b9 : Nonempty \u03b9\n  \u00b7 exact ae_measurable.is_lub_of_nonempty h\u03b9 hf hg\n  suffices \u2203 x, g =\u1d50[\u03bc] fun y => g x by\n    exact \u27e8fun y => g this.some, measurable_const, this.some_spec\u27e9\n  have h_empty : \u2200 x, { a : \u03b1 | \u2203 i : \u03b9, f i x = a } = \u2205 :=\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\u03b9 (nonempty_of_exists hi)\n  simp_rw [h_empty] at hg\n  exact \u27e8hg.exists.some, hg.mono fun y hy => IsLUB.unique hy hg.exists.some_spec\u27e9\n#align ae_measurable.is_lub AeMeasurable.isLub\n\ntheorem Measurable.isGLB {\u03b9} [Countable \u03b9] {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} {g : \u03b4 \u2192 \u03b1} (hf : \u2200 i, Measurable (f i))\n    (hg : \u2200 b, IsGLB { a | \u2203 i, f i b = a } (g b)) : Measurable g :=\n  by\n  change \u2200 b, IsGLB (range fun i => f i b) (g b) at hg\n  rw [\u2039BorelSpace \u03b1\u203a.measurable_eq, borel_eq_generateFrom_Iio \u03b1]\n  apply measurable_generateFrom\n  rintro _ \u27e8a, rfl\u27e9\n  simp_rw [Set.preimage, mem_Iio, isGLB_lt_iff (hg _), exists_range_iff, set_of_exists]\n  exact MeasurableSet.union\u1d62 fun i => hf i (isOpen_gt' _).MeasurableSet\n#align measurable.is_glb Measurable.isGLB\n\ntheorem AeMeasurable.isGlb {\u03b9} {\u03bc : Measure \u03b4} [Countable \u03b9] {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} {g : \u03b4 \u2192 \u03b1}\n    (hf : \u2200 i, AeMeasurable (f i) \u03bc) (hg : \u2200\u1d50 b \u2202\u03bc, IsGLB { a | \u2203 i, f i b = a } (g b)) :\n    AeMeasurable g \u03bc := by\n  nontriviality \u03b1\n  haveI h\u03b1 : Nonempty \u03b1 := inferInstance\n  cases' isEmpty_or_nonempty \u03b9 with h\u03b9 h\u03b9\n  \u00b7 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 : \u03b4 \u2192 (\u03b9 \u2192 \u03b1) \u2192 Prop := fun x f' => IsGLB { a | \u2203 i, f' i = a } (g x)\n  let g_seq := (aeSeqSet hf p).piecewise g fun _ => h\u03b1.some\n  have hg_seq : \u2200 b, IsGLB { a | \u2203 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    \u00b7 have h_set_eq : { a : \u03b1 | \u2203 i : \u03b9, (hf i).mk (f i) b = a } = { a : \u03b1 | \u2203 i : \u03b9, 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    \u00b7 exact IsLeast.isGLB \u27e8(@exists_const (h\u03b1.some = h\u03b1.some) \u03b9 _).2 rfl, fun x \u27e8i, hi\u27e9 => hi.le\u27e9\n  refine' \u27e8g_seq, Measurable.isGLB (aeSeq.measurable hf p) hg_seq, _\u27e9\n  exact\n    (ite_ae_eq_of_measure_compl_zero g (fun x => h\u03b1.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 \u03b2] [OrderClosedTopology \u03b2] {f : \u03b2 \u2192 \u03b1}\n    (hf : Monotone f) : Measurable f :=\n  suffices h : \u2200 x, OrdConnected (f \u207b\u00b9' 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 \u03b2] [OrderClosedTopology \u03b2] {\u03bc : Measure \u03b2}\n    {s : Set \u03b2} (hs : MeasurableSet s) {f : \u03b2 \u2192 \u03b1} (hf : MonotoneOn f s) :\n    AeMeasurable f (\u03bc.restrict s) :=\n  have this : Monotone (f \u2218 coe : s \u2192 \u03b1) := fun \u27e8x, hx\u27e9 \u27e8y, hy\u27e9 (hxy : x \u2264 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 \u03b2] [OrderClosedTopology \u03b2] {f : \u03b2 \u2192 \u03b1}\n    (hf : Antitone f) : Measurable f :=\n  @Monotone.measurable \u03b1\u1d52\u1d48 \u03b2 _ _ \u2039_\u203a _ _ _ _ _ \u2039_\u203a _ _ _ hf\n#align antitone.measurable Antitone.measurable\n\ntheorem aeMeasurableRestrictOfAntitoneOn [LinearOrder \u03b2] [OrderClosedTopology \u03b2] {\u03bc : Measure \u03b2}\n    {s : Set \u03b2} (hs : MeasurableSet s) {f : \u03b2 \u2192 \u03b1} (hf : AntitoneOn f s) :\n    AeMeasurable f (\u03bc.restrict s) :=\n  @aeMeasurableRestrictOfMonotoneOn \u03b1\u1d52\u1d48 \u03b2 _ _ \u2039_\u203a _ _ _ _ _ \u2039_\u203a _ _ _ _ hs _ hf\n#align ae_measurable_restrict_of_antitone_on aeMeasurableRestrictOfAntitoneOn\n\ntheorem measurableSet_of_mem_nhdsWithin_Ioi_aux {s : Set \u03b1} (h : \u2200 x \u2208 s, s \u2208 \ud835\udcdd[>] x)\n    (h' : \u2200 x \u2208 s, \u2203 y, x < y) : MeasurableSet s :=\n  by\n  choose! M hM using h'\n  suffices H : (s \\ interior s).Countable\n  \u00b7 have : s = interior s \u222a 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 : \u2200 x \u2208 s, \u2203 y \u2208 Ioi x, Ioo x y \u2286 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    \u00b7 apply disjoint_left.2 fun z hz h'z => _\n      have : x' \u2208 interior s :=\n        mem_interior.2 \u27e8Ioo x (y x), h'y _ hx.1, isOpen_Ioo, \u27e8h', h'z.1.trans hz.2\u27e9\u27e9\n      exact False.elim (hx'.2 this)\n    \u00b7 apply disjoint_left.2 fun z hz h'z => _\n      have : x \u2208 interior s :=\n        mem_interior.2 \u27e8Ioo x' (y x'), h'y _ hx'.1, isOpen_Ioo, \u27e8h', hz.1.trans h'z.2\u27e9\u27e9\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 \u03b1} (h : \u2200 x \u2208 s, s \u2208 \ud835\udcdd[>] x) :\n    MeasurableSet s := by\n  by_cases H : \u2203 x \u2208 s, IsTop x\n  \u00b7 rcases H with \u27e8x\u2080, x\u2080s, h\u2080\u27e9\n    have : s = {x\u2080} \u222a s \\ {x\u2080} := by rw [union_diff_cancel (singleton_subset_iff.2 x\u2080s)]\n    rw [this]\n    refine' (measurable_set_singleton _).union _\n    have A : \u2200 x \u2208 s \\ {x\u2080}, x < x\u2080 := fun x hx => lt_of_le_of_ne (h\u2080 _) (by simpa using hx.2)\n    refine' measurableSet_of_mem_nhdsWithin_Ioi_aux (fun x hx => _) fun x hx => \u27e8x\u2080, A x hx\u27e9\n    obtain \u27e8u, hu, us\u27e9 : \u2203 (u : \u03b1)(H : u \u2208 Ioi x), Ioo x u \u2286 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 \u27e8u, hu, fun y hy => \u27e8us hy, _\u27e9\u27e9\n    exact ne_of_lt (hy.2.trans_le (h\u2080 _))\n  \u00b7 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\u1d62_Prop {\u03b1} [MeasurableSpace \u03b1] [CompleteLattice \u03b1] (p : Prop) {f : \u03b4 \u2192 \u03b1}\n    (hf : Measurable f) : Measurable fun b => \u2a06 h : p, f b :=\n  by_cases (fun h : p => by convert hf; funext; exact sup\u1d62_pos h) fun h : \u00acp => by\n    convert measurable_const; funext; exact sup\u1d62_neg h\n#align measurable.supr_Prop Measurable.sup\u1d62_Prop\n\n@[measurability]\ntheorem Measurable.inf\u1d62_Prop {\u03b1} [MeasurableSpace \u03b1] [CompleteLattice \u03b1] (p : Prop) {f : \u03b4 \u2192 \u03b1}\n    (hf : Measurable f) : Measurable fun b => \u2a05 h : p, f b :=\n  by_cases (fun h : p => by convert hf; funext; exact inf\u1d62_pos h) fun h : \u00acp => by\n    convert measurable_const; funext; exact inf\u1d62_neg h\n#align measurable.infi_Prop Measurable.inf\u1d62_Prop\n\nsection CompleteLinearOrder\n\nvariable [CompleteLinearOrder \u03b1] [OrderTopology \u03b1] [SecondCountableTopology \u03b1]\n\n@[measurability]\ntheorem measurable_sup\u1d62 {\u03b9} [Countable \u03b9] {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} (hf : \u2200 i, Measurable (f i)) :\n    Measurable fun b => \u2a06 i, f i b :=\n  Measurable.isLUB hf fun b => isLUB_sup\u1d62\n#align measurable_supr measurable_sup\u1d62\n\n@[measurability]\ntheorem aeMeasurableSupr {\u03b9} {\u03bc : Measure \u03b4} [Countable \u03b9] {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1}\n    (hf : \u2200 i, AeMeasurable (f i) \u03bc) : AeMeasurable (fun b => \u2a06 i, f i b) \u03bc :=\n  AeMeasurable.isLub hf <| ae_of_all \u03bc fun b => isLUB_sup\u1d62\n#align ae_measurable_supr aeMeasurableSupr\n\n@[measurability]\ntheorem measurable_inf\u1d62 {\u03b9} [Countable \u03b9] {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} (hf : \u2200 i, Measurable (f i)) :\n    Measurable fun b => \u2a05 i, f i b :=\n  Measurable.isGLB hf fun b => isGLB_inf\u1d62\n#align measurable_infi measurable_inf\u1d62\n\n@[measurability]\ntheorem aeMeasurableInfi {\u03b9} {\u03bc : Measure \u03b4} [Countable \u03b9] {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1}\n    (hf : \u2200 i, AeMeasurable (f i) \u03bc) : AeMeasurable (fun b => \u2a05 i, f i b) \u03bc :=\n  AeMeasurable.isGlb hf <| ae_of_all \u03bc fun b => isGLB_inf\u1d62\n#align ae_measurable_infi aeMeasurableInfi\n\ntheorem measurable_bsupr {\u03b9} (s : Set \u03b9) {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} (hs : s.Countable)\n    (hf : \u2200 i, Measurable (f i)) : Measurable fun b => \u2a06 i \u2208 s, f i b :=\n  by\n  haveI : Encodable s := hs.to_encodable\n  simp only [sup\u1d62_subtype']\n  exact measurable_sup\u1d62 fun i => hf i\n#align measurable_bsupr measurable_bsupr\n\ntheorem aeMeasurableBsupr {\u03b9} {\u03bc : Measure \u03b4} (s : Set \u03b9) {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} (hs : s.Countable)\n    (hf : \u2200 i, AeMeasurable (f i) \u03bc) : AeMeasurable (fun b => \u2a06 i \u2208 s, f i b) \u03bc :=\n  by\n  haveI : Encodable s := hs.to_encodable\n  simp only [sup\u1d62_subtype']\n  exact aeMeasurableSupr fun i => hf i\n#align ae_measurable_bsupr aeMeasurableBsupr\n\ntheorem measurable_binfi {\u03b9} (s : Set \u03b9) {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} (hs : s.Countable)\n    (hf : \u2200 i, Measurable (f i)) : Measurable fun b => \u2a05 i \u2208 s, f i b :=\n  by\n  haveI : Encodable s := hs.to_encodable\n  simp only [inf\u1d62_subtype']\n  exact measurable_inf\u1d62 fun i => hf i\n#align measurable_binfi measurable_binfi\n\ntheorem aeMeasurableBinfi {\u03b9} {\u03bc : Measure \u03b4} (s : Set \u03b9) {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} (hs : s.Countable)\n    (hf : \u2200 i, AeMeasurable (f i) \u03bc) : AeMeasurable (fun b => \u2a05 i \u2208 s, f i b) \u03bc :=\n  by\n  haveI : Encodable s := hs.to_encodable\n  simp only [inf\u1d62_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 `\u2115`.\n-/\ntheorem measurable_liminf' {\u03b9 \u03b9'} {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} {u : Filter \u03b9} (hf : \u2200 i, Measurable (f i))\n    {p : \u03b9' \u2192 Prop} {s : \u03b9' \u2192 Set \u03b9} (hu : u.HasCountableBasis p s) (hs : \u2200 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 `\u2115`.\n-/\ntheorem measurable_limsup' {\u03b9 \u03b9'} {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} {u : Filter \u03b9} (hf : \u2200 i, Measurable (f i))\n    {p : \u03b9' \u2192 Prop} {s : \u03b9' \u2192 Set \u03b9} (hu : u.HasCountableBasis p s) (hs : \u2200 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 `\u2115` is measurable. See `measurable_liminf'` for a version with a general filter.\n-/\n@[measurability]\ntheorem measurable_liminf {f : \u2115 \u2192 \u03b4 \u2192 \u03b1} (hf : \u2200 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 `\u2115` is measurable. See `measurable_limsup'` for a version with a general filter.\n-/\n@[measurability]\ntheorem measurable_limsup {f : \u2115 \u2192 \u03b4 \u2192 \u03b1} (hf : \u2200 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 \u03b1] [OrderTopology \u03b1] [SecondCountableTopology \u03b1]\n\ntheorem measurable_cSup {\u03b9} {f : \u03b9 \u2192 \u03b4 \u2192 \u03b1} {s : Set \u03b9} (hs : s.Countable)\n    (hf : \u2200 i, Measurable (f i)) (bdd : \u2200 x, BddAbove ((fun i => f i x) '' s)) :\n    Measurable fun x => sup\u209b ((fun i => f i x) '' s) :=\n  by\n  cases' eq_empty_or_nonempty s with h2s h2s\n  \u00b7 simp [h2s, measurable_const]\n  \u00b7 apply measurable_of_Iic\n    intro y\n    simp_rw [preimage, mem_Iic, csup\u209b_le_iff (bdd _) (h2s.image _), ball_image_iff, set_of_forall]\n    exact MeasurableSet.binter\u1d62 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 : \u03b1 \u2243\u209c \u03b2) : \u03b1 \u2243\u1d50 \u03b2\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 {\u03b1 : Type _} {m0 : MeasurableSpace \u03b1}\n    [TopologicalSpace \u03b1] [OpensMeasurableSpace \u03b1] {\u03b2 : Type _} [MeasurableSpace \u03b2]\n    [TopologicalSpace \u03b2] [BorelSpace \u03b2] [T2Space \u03b2] (\u03bc : Measure \u03b1) [IsFiniteMeasureOnCompacts \u03bc]\n    (f : \u03b1 \u2243\u209c \u03b2) : IsFiniteMeasureOnCompacts (Measure.map f \u03bc) :=\n  \u27e8by\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]\u27e9\n#align is_finite_measure_on_compacts.map IsFiniteMeasureOnCompacts.map\n\nend BorelSpace\n\ninstance Empty.borelSpace : BorelSpace Empty :=\n  \u27e8borel_eq_top_of_discrete.symm\u27e9\n#align empty.borel_space Empty.borelSpace\n\ninstance Unit.borelSpace : BorelSpace Unit :=\n  \u27e8borel_eq_top_of_discrete.symm\u27e9\n#align unit.borel_space Unit.borelSpace\n\ninstance Bool.borelSpace : BorelSpace Bool :=\n  \u27e8borel_eq_top_of_discrete.symm\u27e9\n#align bool.borel_space Bool.borelSpace\n\ninstance Nat.borelSpace : BorelSpace \u2115 :=\n  \u27e8borel_eq_top_of_discrete.symm\u27e9\n#align nat.borel_space Nat.borelSpace\n\ninstance Int.borelSpace : BorelSpace \u2124 :=\n  \u27e8borel_eq_top_of_discrete.symm\u27e9\n#align int.borel_space Int.borelSpace\n\ninstance Rat.borelSpace : BorelSpace \u211a :=\n  \u27e8borel_eq_top_of_countable.symm\u27e9\n#align rat.borel_space Rat.borelSpace\n\ninstance (priority := 900) IsROrC.measurableSpace {\ud835\udd5c : Type _} [IsROrC \ud835\udd5c] : MeasurableSpace \ud835\udd5c :=\n  borel \ud835\udd5c\n#align is_R_or_C.measurable_space IsROrC.measurableSpace\n\ninstance (priority := 900) IsROrC.borelSpace {\ud835\udd5c : Type _} [IsROrC \ud835\udd5c] : BorelSpace \ud835\udd5c :=\n  \u27e8rfl\u27e9\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 (\u03b9 \u2192 \u211d)`, so we leave them here. -/\ninstance Real.measurableSpace : MeasurableSpace \u211d :=\n  borel \u211d\n#align real.measurable_space Real.measurableSpace\n\ninstance Real.borelSpace : BorelSpace \u211d :=\n  \u27e8rfl\u27e9\n#align real.borel_space Real.borelSpace\n\ninstance NNReal.measurableSpace : MeasurableSpace \u211d\u22650 :=\n  Subtype.measurableSpace\n#align nnreal.measurable_space NNReal.measurableSpace\n\ninstance NNReal.borelSpace : BorelSpace \u211d\u22650 :=\n  Subtype.borelSpace _\n#align nnreal.borel_space NNReal.borelSpace\n\ninstance ENNReal.measurableSpace : MeasurableSpace \u211d\u22650\u221e :=\n  borel \u211d\u22650\u221e\n#align ennreal.measurable_space ENNReal.measurableSpace\n\ninstance ENNReal.borelSpace : BorelSpace \u211d\u22650\u221e :=\n  \u27e8rfl\u27e9\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  \u27e8rfl\u27e9\n#align ereal.borel_space EReal.borelSpace\n\ninstance Complex.measurableSpace : MeasurableSpace \u2102 :=\n  borel \u2102\n#align complex.measurable_space Complex.measurableSpace\n\ninstance Complex.borelSpace : BorelSpace \u2102 :=\n  \u27e8rfl\u27e9\n#align complex.borel_space Complex.borelSpace\n\ninstance AddCircle.measurableSpace {a : \u211d} : MeasurableSpace (AddCircle a) :=\n  borel (AddCircle a)\n#align add_circle.measurable_space AddCircle.measurableSpace\n\ninstance AddCircle.borelSpace {a : \u211d} : BorelSpace (AddCircle a) :=\n  \u27e8rfl\u27e9\n#align add_circle.borel_space AddCircle.borelSpace\n\n@[measurability]\nprotected theorem AddCircle.measurable_mk' {a : \u211d} : Measurable (coe : \u211d \u2192 AddCircle a) :=\n  Continuous.measurable <| AddCircle.continuous_mk' a\n#align add_circle.measurable_mk' AddCircle.measurable_mk'\n\n/-- One can cut out `\u211d\u22650\u221e` into the sets `{0}`, `Ico (t^n) (t^(n+1))` for `n : \u2124` and `{\u221e}`. 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 \u03b1] (\u03bc : Measure \u03b1)\n    {f : \u03b1 \u2192 \u211d\u22650\u221e} (hf : Measurable f) {s : Set \u03b1} (hs : MeasurableSet s) {t : \u211d\u22650} (ht : 1 < t) :\n    \u03bc s =\n      \u03bc (s \u2229 f \u207b\u00b9' {0}) + \u03bc (s \u2229 f \u207b\u00b9' {\u221e}) + \u2211' n : \u2124, \u03bc (s \u2229 f \u207b\u00b9' Ico (t ^ n) (t ^ (n + 1))) :=\n  by\n  have A : \u03bc s = \u03bc (s \u2229 f \u207b\u00b9' {0}) + \u03bc (s \u2229 f \u207b\u00b9' Ioi 0) :=\n    by\n    rw [\u2190 measure_union]\n    \u00b7 congr 1\n      ext x\n      have : 0 = f x \u2228 0 < f x := eq_or_lt_of_le bot_le\n      rw [eq_comm] at this\n      simp only [\u2190 and_or_left, this, mem_singleton_iff, mem_inter_iff, and_true_iff, mem_union,\n        mem_Ioi, mem_preimage]\n    \u00b7 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    \u00b7 exact hs.inter (hf measurableSet_Ioi)\n  have B : \u03bc (s \u2229 f \u207b\u00b9' Ioi 0) = \u03bc (s \u2229 f \u207b\u00b9' {\u221e}) + \u03bc (s \u2229 f \u207b\u00b9' Ioo 0 \u221e) :=\n    by\n    rw [\u2190 measure_union]\n    \u00b7 rw [\u2190 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 = \u221e \u2228 f x < \u221e := eq_or_lt_of_le le_top\n      cases H\n      \u00b7\n        simp only [H, eq_self_iff_true, or_false_iff, WithTop.zero_lt_top, not_top_lt,\n          and_false_iff]\n      \u00b7 simp only [H, H.ne, and_true_iff, false_or_iff]\n    \u00b7 apply disjoint_left.2 fun x hx h'x => _\n      have : f x < \u221e := h'x.2.2\n      exact lt_irrefl _ (this.trans_le (le_of_eq hx.2.symm))\n    \u00b7 exact hs.inter (hf measurableSet_Ioo)\n  have C : \u03bc (s \u2229 f \u207b\u00b9' Ioo 0 \u221e) = \u2211' n : \u2124, \u03bc (s \u2229 f \u207b\u00b9' Ico (t ^ n) (t ^ (n + 1))) :=\n    by\n    rw [\u2190 measure_Union,\n      ENNReal.Ioo_zero_top_eq_union\u1d62_Ico_zpow (ENNReal.one_lt_coe_iff.2 ht) ENNReal.coe_ne_top,\n      preimage_Union, inter_Union]\n    \u00b7 intro i j\n      simp only [Function.onFun]\n      intro hij\n      wlog h : i < j generalizing i j\n      \u00b7 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        _ \u2264 t ^ j := (ENNReal.zpow_le_of_le (ENNReal.one_le_coe_iff.2 ht.le) h)\n        _ \u2264 f x := h'x.2.1\n        \n    \u00b7 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 \u03b1] [MeasurableSpace \u03b1] [OpensMeasurableSpace \u03b1]\n\nvariable [MeasurableSpace \u03b2] {x : \u03b1} {\u03b5 : \u211d}\n\nopen Metric\n\n@[measurability]\ntheorem measurableSet_ball : MeasurableSet (Metric.ball x \u03b5) :=\n  Metric.isOpen_ball.MeasurableSet\n#align measurable_set_ball measurableSet_ball\n\n@[measurability]\ntheorem measurableSet_closedBall : MeasurableSet (Metric.closedBall x \u03b5) :=\n  Metric.isClosed_ball.MeasurableSet\n#align measurable_set_closed_ball measurableSet_closedBall\n\n@[measurability]\ntheorem measurable_infDist {s : Set \u03b1} : 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 : \u03b2 \u2192 \u03b1} (hf : Measurable f) {s : Set \u03b1} :\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 \u03b1} : 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 : \u03b2 \u2192 \u03b1} (hf : Measurable f) {s : Set \u03b1} :\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 \u03b1]\n\n@[measurability]\ntheorem measurable_dist : Measurable fun p : \u03b1 \u00d7 \u03b1 => dist p.1 p.2 :=\n  continuous_dist.Measurable\n#align measurable_dist measurable_dist\n\n@[measurability]\ntheorem Measurable.dist {f g : \u03b2 \u2192 \u03b1} (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun b => dist (f b) (g b) :=\n  (@continuous_dist \u03b1 _).measurable2 hf hg\n#align measurable.dist Measurable.dist\n\n@[measurability]\ntheorem measurable_nndist : Measurable fun p : \u03b1 \u00d7 \u03b1 => nndist p.1 p.2 :=\n  continuous_nndist.Measurable\n#align measurable_nndist measurable_nndist\n\n@[measurability]\ntheorem Measurable.nndist {f g : \u03b2 \u2192 \u03b1} (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun b => nndist (f b) (g b) :=\n  (@continuous_nndist \u03b1 _).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 {\u03bc : Measure \u03b1} {s : Set \u03b1}\n    (hs : \u2203 R > 0, \u03bc (cthickening R s) \u2260 \u221e) :\n    Tendsto (fun r => \u03bc (cthickening r s)) (\ud835\udcdd 0) (\ud835\udcdd (\u03bc (closure s))) :=\n  by\n  have A : tendsto (fun r => \u03bc (cthickening r s)) (\ud835\udcdd[Ioi 0] 0) (\ud835\udcdd (\u03bc (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 => \u03bc (cthickening r s)) (\ud835\udcdd[Iic 0] 0) (\ud835\udcdd (\u03bc (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 {\u03bc : Measure \u03b1} {s : Set \u03b1}\n    (hs : \u2203 R > 0, \u03bc (cthickening R s) \u2260 \u221e) (h's : IsClosed s) :\n    Tendsto (fun r => \u03bc (cthickening r s)) (\ud835\udcdd 0) (\ud835\udcdd (\u03bc 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 \u03b1] [MeasurableSpace \u03b1]\n    [OpensMeasurableSpace \u03b1] [ProperSpace \u03b1] {\u03bc : Measure \u03b1} [IsFiniteMeasureOnCompacts \u03bc]\n    {s : Set \u03b1} (hs : IsCompact s) :\n    Tendsto (fun r => \u03bc (Metric.cthickening r s)) (\ud835\udcdd 0) (\ud835\udcdd (\u03bc s)) :=\n  tendsto_measure_cthickening_of_isClosed \u27e81, zero_lt_one, hs.Bounded.cthickening.measure_lt_top.Ne\u27e9\n    hs.IsClosed\n#align tendsto_measure_cthickening_of_is_compact tendsto_measure_cthickening_of_isCompact\n\nsection PseudoEMetricSpace\n\nvariable [PseudoEMetricSpace \u03b1] [MeasurableSpace \u03b1] [OpensMeasurableSpace \u03b1]\n\nvariable [MeasurableSpace \u03b2] {x : \u03b1} {\u03b5 : \u211d\u22650\u221e}\n\nopen Emetric\n\n@[measurability]\ntheorem measurableSet_eball : MeasurableSet (EMetric.ball x \u03b5) :=\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 \u03b1} : Measurable fun x => infEdist x s :=\n  continuous_infEdist.Measurable\n#align measurable_inf_edist measurable_infEdist\n\n@[measurability]\ntheorem Measurable.infEdist {f : \u03b2 \u2192 \u03b1} (hf : Measurable f) {s : Set \u03b1} :\n    Measurable fun x => infEdist (f x) s :=\n  measurable_infEdist.comp hf\n#align measurable.inf_edist Measurable.infEdist\n\nvariable [SecondCountableTopology \u03b1]\n\n@[measurability]\ntheorem measurable_edist : Measurable fun p : \u03b1 \u00d7 \u03b1 => edist p.1 p.2 :=\n  continuous_edist.Measurable\n#align measurable_edist measurable_edist\n\n@[measurability]\ntheorem Measurable.edist {f g : \u03b2 \u2192 \u03b1} (hf : Measurable f) (hg : Measurable g) :\n    Measurable fun b => edist (f b) (g b) :=\n  (@continuous_edist \u03b1 _).measurable2 hf hg\n#align measurable.edist Measurable.edist\n\n@[measurability]\ntheorem AeMeasurable.edist {f g : \u03b2 \u2192 \u03b1} {\u03bc : Measure \u03b2} (hf : AeMeasurable f \u03bc)\n    (hg : AeMeasurable g \u03bc) : AeMeasurable (fun a => edist (f a) (g a)) \u03bc :=\n  (@continuous_edist \u03b1 _).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 \u211d = generateFrom (\u22c3 (a : \u211a) (b : \u211a) (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 \u211d (\u22c3 (a : \u211a) (b : \u211a) (h : a < b), {Ioo a b}) :=\n  by\n  convert isPiSystem_Ioo (coe : \u211a \u2192 \u211d) (coe : \u211a \u2192 \u211d)\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 `\u03bc` on `\u211d`. -/\ndef finiteSpanningSetsInIooRat (\u03bc : Measure \u211d) [IsLocallyFiniteMeasure \u03bc] :\n    \u03bc.FiniteSpanningSetsIn (\u22c3 (a : \u211a) (b : \u211a) (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' \u27e8-(n + 1 : \u2115), n + 1, _, by simp\u27e9\n    -- TODO: norm_cast fails here?\n    exact (neg_nonpos.2 (@Nat.cast_nonneg \u211a _ (n + 1))).trans_lt n.cast_add_one_pos\n  Finite n := measure_Ioo_lt_top\n  spanning :=\n    union\u1d62_eq_univ_iff.2 fun x =>\n      \u27e8\u230a|x|\u230b\u208a, 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 _)\u27e9\n#align real.finite_spanning_sets_in_Ioo_rat Real.finiteSpanningSetsInIooRat\n\ntheorem measure_ext_Ioo_rat {\u03bc \u03bd : Measure \u211d} [IsLocallyFiniteMeasure \u03bc]\n    (h : \u2200 a b : \u211a, \u03bc (Ioo a b) = \u03bd (Ioo a b)) : \u03bc = \u03bd :=\n  (finiteSpanningSetsInIooRat \u03bc).ext borel_eq_generateFrom_Ioo_rat isPiSystem_Ioo_rat <|\n    by\n    simp only [mem_Union, mem_singleton_iff]\n    rintro _ \u27e8a, b, -, rfl\u27e9\n    apply h\n#align real.measure_ext_Ioo_rat Real.measure_ext_Ioo_rat\n\ntheorem borel_eq_generateFrom_Iio_rat : borel \u211d = generateFrom (\u22c3 a : \u211a, {Iio a}) :=\n  by\n  let g : MeasurableSpace \u211d := generate_from (\u22c3 a : \u211a, {Iio a})\n  refine' le_antisymm _ _\n  \u00b7 rw [borel_eq_generate_from_Ioo_rat]\n    refine' generate_from_le fun t => _\n    simp only [mem_Union, mem_singleton_iff]\n    rintro \u27e8a, b, h, rfl\u27e9\n    rw [(Set.ext fun x => _ : Ioo (a : \u211d) b = (\u22c3 c > a, Iio c\u1d9c) \u2229 Iio b)]\n    \u00b7 have hg : \u2200 q : \u211a, 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\u1d62 _ _ g _ _ (to_countable _) fun c h => _\n      exact @MeasurableSet.compl _ _ g (hg _)\n    \u00b7 suffices x < \u2191b \u2192 (\u2191a < x \u2194 \u2203 i : \u211a, a < i \u2227 \u2191i \u2264 x) by simpa\n      refine' fun _ => \u27e8fun h => _, fun \u27e8i, hai, hix\u27e9 => (Rat.cast_lt.2 hai).trans_le hix\u27e9\n      rcases exists_rat_btwn h with \u27e8c, ac, cx\u27e9\n      exact \u27e8c, Rat.cast_lt.1 ac, cx.le\u27e9\n  \u00b7 refine' MeasurableSpace.generateFrom_le fun _ => _\n    simp only [mem_Union, mem_singleton_iff]\n    rintro \u27e8r, rfl\u27e9\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 \u03b1]\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 : \u03b1 \u2192 \u211d} (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 : \u03b1 \u2192 \u211d} {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => Real.toNNReal (f x)) \u03bc :=\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 : \u211d\u22650 \u2192 \u211d) :=\n  NNReal.continuous_coe.Measurable\n#align measurable_coe_nnreal_real measurable_coe_nNReal_real\n\n@[measurability]\ntheorem Measurable.coe_nNReal_real {f : \u03b1 \u2192 \u211d\u22650} (hf : Measurable f) :\n    Measurable fun x => (f x : \u211d) :=\n  measurable_coe_nNReal_real.comp hf\n#align measurable.coe_nnreal_real Measurable.coe_nNReal_real\n\n@[measurability]\ntheorem AeMeasurable.coeNnrealReal {f : \u03b1 \u2192 \u211d\u22650} {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => (f x : \u211d)) \u03bc :=\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 : \u211d\u22650 \u2192 \u211d\u22650\u221e) :=\n  ENNReal.continuous_coe.Measurable\n#align measurable_coe_nnreal_ennreal measurable_coe_nNReal_eNNReal\n\n@[measurability]\ntheorem Measurable.coe_nNReal_eNNReal {f : \u03b1 \u2192 \u211d\u22650} (hf : Measurable f) :\n    Measurable fun x => (f x : \u211d\u22650\u221e) :=\n  ENNReal.continuous_coe.Measurable.comp hf\n#align measurable.coe_nnreal_ennreal Measurable.coe_nNReal_eNNReal\n\n@[measurability]\ntheorem AeMeasurable.coeNnrealEnnreal {f : \u03b1 \u2192 \u211d\u22650} {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => (f x : \u211d\u22650\u221e)) \u03bc :=\n  ENNReal.continuous_coe.Measurable.compAeMeasurable hf\n#align ae_measurable.coe_nnreal_ennreal AeMeasurable.coeNnrealEnnreal\n\n@[measurability]\ntheorem Measurable.eNNReal_ofReal {f : \u03b1 \u2192 \u211d} (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 : \u03b1 \u2192 \u211d\u22650} :\n    Measurable (fun x => f x : \u03b1 \u2192 \u211d) \u2194 Measurable f :=\n  \u27e8fun h => by simpa only [Real.toNNReal_coe] using h.real_to_nnreal, Measurable.coe_nNReal_real\u27e9\n#align measurable_coe_nnreal_real_iff measurable_coe_nNReal_real_iff\n\n@[simp, norm_cast]\ntheorem aeMeasurable_coe_nNReal_real_iff {f : \u03b1 \u2192 \u211d\u22650} {\u03bc : Measure \u03b1} :\n    AeMeasurable (fun x => f x : \u03b1 \u2192 \u211d) \u03bc \u2194 AeMeasurable f \u03bc :=\n  \u27e8fun h => by simpa only [Real.toNNReal_coe] using h.real_to_nnreal, AeMeasurable.coeNnrealReal\u27e9\n#align ae_measurable_coe_nnreal_real_iff aeMeasurable_coe_nNReal_real_iff\n\n/-- The set of finite `\u211d\u22650\u221e` numbers is `measurable_equiv` to `\u211d\u22650`. -/\ndef MeasurableEquiv.ennrealEquivNnreal : { r : \u211d\u22650\u221e | r \u2260 \u221e } \u2243\u1d50 \u211d\u22650 :=\n  ENNReal.neTopHomeomorphNNReal.toMeasurableEquiv\n#align measurable_equiv.ennreal_equiv_nnreal MeasurableEquiv.ennrealEquivNnreal\n\nnamespace ENNReal\n\ntheorem measurable_of_measurable_nNReal {f : \u211d\u22650\u221e \u2192 \u03b1} (h : Measurable fun p : \u211d\u22650 => f p) :\n    Measurable f :=\n  measurable_of_measurable_on_compl_singleton \u221e\n    (MeasurableEquiv.ennrealEquivNnreal.symm.measurable_comp_iff.1 h)\n#align ennreal.measurable_of_measurable_nnreal ENNReal.measurable_of_measurable_nNReal\n\n/-- `\u211d\u22650\u221e` is `measurable_equiv` to `\u211d\u22650 \u2295 unit`. -/\ndef ennrealEquivSum : \u211d\u22650\u221e \u2243\u1d50 Sum \u211d\u22650 Unit :=\n  {\n    Equiv.optionEquivSumPUnit\n      \u211d\u22650 with\n    measurable_to_fun := measurable_of_measurable_nNReal measurable_inl\n    measurable_inv_fun :=\n      measurable_sum measurable_coe_nNReal_eNNReal (@measurable_const \u211d\u22650\u221e Unit _ _ \u221e) }\n#align ennreal.ennreal_equiv_sum ENNReal.ennrealEquivSum\n\nopen Function (uncurry)\n\ntheorem measurable_of_measurable_nNReal_prod [MeasurableSpace \u03b2] [MeasurableSpace \u03b3]\n    {f : \u211d\u22650\u221e \u00d7 \u03b2 \u2192 \u03b3} (H\u2081 : Measurable fun p : \u211d\u22650 \u00d7 \u03b2 => f (p.1, p.2))\n    (H\u2082 : Measurable fun x => f (\u221e, x)) : Measurable f :=\n  let e : \u211d\u22650\u221e \u00d7 \u03b2 \u2243\u1d50 Sum (\u211d\u22650 \u00d7 \u03b2) (Unit \u00d7 \u03b2) :=\n    (ennrealEquivSum.prodCongr (MeasurableEquiv.refl \u03b2)).trans\n      (MeasurableEquiv.sumProdDistrib _ _ _)\n  e.symm.measurable_comp_iff.1 <| measurable_sum H\u2081 (H\u2082.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 \u03b2] {f : \u211d\u22650\u221e \u00d7 \u211d\u22650\u221e \u2192 \u03b2}\n    (h\u2081 : Measurable fun p : \u211d\u22650 \u00d7 \u211d\u22650 => f (p.1, p.2)) (h\u2082 : Measurable fun r : \u211d\u22650 => f (\u221e, r))\n    (h\u2083 : Measurable fun r : \u211d\u22650 => f (r, \u221e)) : Measurable f :=\n  measurable_of_measurable_nNReal_prod\n    (measurable_swap_iff.1 <| measurable_of_measurable_nNReal_prod (h\u2081.comp measurable_swap) h\u2083)\n    (measurable_of_measurable_nNReal h\u2082)\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\u2082 \u211d\u22650\u221e :=\n  by\n  refine' \u27e8measurable_of_measurable_nnreal_nnreal _ _ _\u27e9\n  \u00b7 simp only [\u2190 ENNReal.coe_mul, measurable_mul.coe_nnreal_ennreal]\n  \u00b7 simp only [ENNReal.top_mul', ENNReal.coe_eq_zero]\n    exact measurable_const.piecewise (measurable_set_singleton _) measurable_const\n  \u00b7 simp only [ENNReal.mul_top', ENNReal.coe_eq_zero]\n    exact measurable_const.piecewise (measurable_set_singleton _) measurable_const\n\ninstance : HasMeasurableSub\u2082 \u211d\u22650\u221e :=\n  \u27e8by\n    apply measurable_of_measurable_nnreal_nnreal <;>\n      simp [\u2190 WithTop.coe_sub, continuous_sub.measurable.coe_nnreal_ennreal]\u27e9\n\ninstance : HasMeasurableInv \u211d\u22650\u221e :=\n  \u27e8continuous_inv.Measurable\u27e9\n\nend ENNReal\n\n@[measurability]\ntheorem Measurable.eNNReal_toNNReal {f : \u03b1 \u2192 \u211d\u22650\u221e} (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 : \u03b1 \u2192 \u211d\u22650\u221e} {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => (f x).toNNReal) \u03bc :=\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 : \u03b1 \u2192 \u211d\u22650} :\n    (Measurable fun x => (f x : \u211d\u22650\u221e)) \u2194 Measurable f :=\n  \u27e8fun h => h.eNNReal_toNNReal, fun h => h.coe_nNReal_eNNReal\u27e9\n#align measurable_coe_nnreal_ennreal_iff measurable_coe_nNReal_eNNReal_iff\n\n@[simp, norm_cast]\ntheorem aeMeasurable_coe_nNReal_eNNReal_iff {f : \u03b1 \u2192 \u211d\u22650} {\u03bc : Measure \u03b1} :\n    AeMeasurable (fun x => (f x : \u211d\u22650\u221e)) \u03bc \u2194 AeMeasurable f \u03bc :=\n  \u27e8fun h => h.eNNReal_toNNReal, fun h => h.coe_nNReal_eNNReal\u27e9\n#align ae_measurable_coe_nnreal_ennreal_iff aeMeasurable_coe_nNReal_eNNReal_iff\n\n@[measurability]\ntheorem Measurable.eNNReal_toReal {f : \u03b1 \u2192 \u211d\u22650\u221e} (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 : \u03b1 \u2192 \u211d\u22650\u221e} {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => ENNReal.toReal (f x)) \u03bc :=\n  ENNReal.measurable_toReal.compAeMeasurable hf\n#align ae_measurable.ennreal_to_real AeMeasurable.ennrealToReal\n\n/-- note: `\u211d\u22650\u221e` can probably be generalized in a future version of this lemma. -/\n@[measurability]\ntheorem Measurable.eNNReal_tsum {\u03b9} [Countable \u03b9] {f : \u03b9 \u2192 \u03b1 \u2192 \u211d\u22650\u221e} (h : \u2200 i, Measurable (f i)) :\n    Measurable fun x => \u2211' i, f i x :=\n  by\n  simp_rw [ENNReal.tsum_eq_sup\u1d62_sum]\n  apply measurable_sup\u1d62\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' {\u03b9} [Countable \u03b9] {f : \u03b9 \u2192 \u03b1 \u2192 \u211d\u22650\u221e} (h : \u2200 i, Measurable (f i)) :\n    Measurable (\u2211' 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 {\u03b9} [Countable \u03b9] {f : \u03b9 \u2192 \u03b1 \u2192 \u211d\u22650} (h : \u2200 i, Measurable (f i)) :\n    Measurable fun x => \u2211' 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 {\u03b9} [Countable \u03b9] {f : \u03b9 \u2192 \u03b1 \u2192 \u211d\u22650\u221e} {\u03bc : Measure \u03b1}\n    (h : \u2200 i, AeMeasurable (f i) \u03bc) : AeMeasurable (fun x => \u2211' i, f i x) \u03bc :=\n  by\n  simp_rw [ENNReal.tsum_eq_sup\u1d62_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 {\u03b1 : Type _} [MeasurableSpace \u03b1] {\u03b9 : Type _} [Countable \u03b9]\n    {f : \u03b9 \u2192 \u03b1 \u2192 NNReal} {\u03bc : MeasureTheory.Measure \u03b1} (h : \u2200 i : \u03b9, AeMeasurable (f i) \u03bc) :\n    AeMeasurable (fun x : \u03b1 => \u2211' i : \u03b9, f i x) \u03bc :=\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 : \u211d \u2192 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 : \u03b1 \u2192 \u211d} (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 : \u03b1 \u2192 \u211d} {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => (f x : EReal)) \u03bc :=\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 `\u211d`. -/\ndef MeasurableEquiv.erealEquivReal : ({\u22a5, \u22a4}\u1d9c : Set EReal) \u2243\u1d50 \u211d :=\n  EReal.neBotTopHomeomorphReal.toMeasurableEquiv\n#align measurable_equiv.ereal_equiv_real MeasurableEquiv.erealEquivReal\n\ntheorem EReal.measurable_of_measurable_real {f : EReal \u2192 \u03b1} (h : Measurable fun p : \u211d => f p) :\n    Measurable f :=\n  measurable_of_measurable_on_compl_finite {\u22a5, \u22a4} (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 : \u03b1 \u2192 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 : \u03b1 \u2192 EReal} {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => (f x).toReal) \u03bc :=\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 : \u211d\u22650\u221e \u2192 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 : \u03b1 \u2192 \u211d\u22650\u221e} (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 : \u03b1 \u2192 \u211d\u22650\u221e} {\u03bc : Measure \u03b1} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun x => (f x : EReal)) \u03bc :=\n  measurable_coe_eNNReal_eReal.compAeMeasurable hf\n#align ae_measurable.coe_ereal_ennreal AeMeasurable.coeErealEnnreal\n\nsection NormedAddCommGroup\n\nvariable [NormedAddCommGroup \u03b1] [OpensMeasurableSpace \u03b1] [MeasurableSpace \u03b2]\n\n@[measurability]\ntheorem measurable_norm : Measurable (norm : \u03b1 \u2192 \u211d) :=\n  continuous_norm.Measurable\n#align measurable_norm measurable_norm\n\n@[measurability]\ntheorem Measurable.norm {f : \u03b2 \u2192 \u03b1} (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 : \u03b2 \u2192 \u03b1} {\u03bc : Measure \u03b2} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun a => norm (f a)) \u03bc :=\n  measurable_norm.compAeMeasurable hf\n#align ae_measurable.norm AeMeasurable.norm\n\n@[measurability]\ntheorem measurable_nnnorm : Measurable (nnnorm : \u03b1 \u2192 \u211d\u22650) :=\n  continuous_nnnorm.Measurable\n#align measurable_nnnorm measurable_nnnorm\n\n@[measurability]\ntheorem Measurable.nnnorm {f : \u03b2 \u2192 \u03b1} (hf : Measurable f) : Measurable fun a => \u2016f a\u2016\u208a :=\n  measurable_nnnorm.comp hf\n#align measurable.nnnorm Measurable.nnnorm\n\n@[measurability]\ntheorem AeMeasurable.nnnorm {f : \u03b2 \u2192 \u03b1} {\u03bc : Measure \u03b2} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun a => \u2016f a\u2016\u208a) \u03bc :=\n  measurable_nnnorm.compAeMeasurable hf\n#align ae_measurable.nnnorm AeMeasurable.nnnorm\n\n@[measurability]\ntheorem measurable_ennnorm : Measurable fun x : \u03b1 => (\u2016x\u2016\u208a : \u211d\u22650\u221e) :=\n  measurable_nnnorm.coe_nNReal_eNNReal\n#align measurable_ennnorm measurable_ennnorm\n\n@[measurability]\ntheorem Measurable.ennnorm {f : \u03b2 \u2192 \u03b1} (hf : Measurable f) : Measurable fun a => (\u2016f a\u2016\u208a : \u211d\u22650\u221e) :=\n  hf.nnnorm.coe_nNReal_eNNReal\n#align measurable.ennnorm Measurable.ennnorm\n\n@[measurability]\ntheorem AeMeasurable.ennnorm {f : \u03b2 \u2192 \u03b1} {\u03bc : Measure \u03b2} (hf : AeMeasurable f \u03bc) :\n    AeMeasurable (fun a => (\u2016f a\u2016\u208a : \u211d\u22650\u221e)) \u03bc :=\n  measurable_ennnorm.compAeMeasurable hf\n#align ae_measurable.ennnorm AeMeasurable.ennnorm\n\nend NormedAddCommGroup\n\nsection Limits\n\nvariable [TopologicalSpace \u03b2] [PseudoMetrizableSpace \u03b2] [MeasurableSpace \u03b2] [BorelSpace \u03b2]\n\nopen Metric\n\n/-- A limit (over a general filter) of measurable `\u211d\u22650\u221e` valued functions is measurable. -/\ntheorem measurable_of_tendsto_ennreal' {\u03b9} {f : \u03b9 \u2192 \u03b1 \u2192 \u211d\u22650\u221e} {g : \u03b1 \u2192 \u211d\u22650\u221e} (u : Filter \u03b9)\n    [NeBot u] [IsCountablyGenerated u] (hf : \u2200 i, Measurable (f i)) (lim : Tendsto f u (\ud835\udcdd g)) :\n    Measurable g := by\n  rcases u.exists_seq_tendsto with \u27e8x, hx\u27e9\n  rw [tendsto_pi_nhds] at lim\n  have : (fun y => liminf (fun n => (f (x n) y : \u211d\u22650\u221e)) at_top) = g :=\n    by\n    ext1 y\n    exact ((limUnder y).comp hx).liminf_eq\n  rw [\u2190 this]\n  show Measurable fun y => liminf (fun n => (f (x n) y : \u211d\u22650\u221e)) 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 `\u211d\u22650\u221e` valued functions is measurable. -/\ntheorem measurable_of_tendsto_eNNReal {f : \u2115 \u2192 \u03b1 \u2192 \u211d\u22650\u221e} {g : \u03b1 \u2192 \u211d\u22650\u221e} (hf : \u2200 i, Measurable (f i))\n    (lim : Tendsto f atTop (\ud835\udcdd 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 `\u211d\u22650` valued functions is measurable. -/\ntheorem measurable_of_tendsto_nnreal' {\u03b9} {f : \u03b9 \u2192 \u03b1 \u2192 \u211d\u22650} {g : \u03b1 \u2192 \u211d\u22650} (u : Filter \u03b9) [NeBot u]\n    [IsCountablyGenerated u] (hf : \u2200 i, Measurable (f i)) (lim : Tendsto f u (\ud835\udcdd g)) :\n    Measurable g := by\n  simp_rw [\u2190 measurable_coe_nNReal_eNNReal_iff] at hf\u22a2\n  refine' measurable_of_tendsto_ennreal' u hf _\n  rw [tendsto_pi_nhds] at lim\u22a2\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 `\u211d\u22650` valued functions is measurable. -/\ntheorem measurable_of_tendsto_nNReal {f : \u2115 \u2192 \u03b1 \u2192 \u211d\u22650} {g : \u03b1 \u2192 \u211d\u22650} (hf : \u2200 i, Measurable (f i))\n    (lim : Tendsto f atTop (\ud835\udcdd 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' {\u03b9} {f : \u03b9 \u2192 \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (u : Filter \u03b9) [NeBot u]\n    [IsCountablyGenerated u] (hf : \u2200 i, Measurable (f i)) (lim : Tendsto f u (\ud835\udcdd g)) :\n    Measurable g :=\n  by\n  letI : PseudoMetricSpace \u03b2 := pseudo_metrizable_space_pseudo_metric \u03b2\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 (\ud835\udcdd 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\u22a2\n    intro x\n    exact ((continuous_inf_nndist_pt s).Tendsto (g x)).comp (limUnder x)\n  have h4s : g \u207b\u00b9' s = (fun x => inf_nndist (g x) s) \u207b\u00b9' {0} :=\n    by\n    ext x\n    simp [h1s, \u2190 h1s.mem_iff_inf_dist_zero h2s, \u2190 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 : \u2115 \u2192 \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (hf : \u2200 i, Measurable (f i))\n    (lim : Tendsto f atTop (\ud835\udcdd g)) : Measurable g :=\n  measurable_of_tendsto_metrizable' atTop hf limUnder\n#align measurable_of_tendsto_metrizable measurable_of_tendsto_metrizable\n\ntheorem aeMeasurableOfTendstoMetrizableAe {\u03b9} {\u03bc : Measure \u03b1} {f : \u03b9 \u2192 \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2}\n    (u : Filter \u03b9) [hu : NeBot u] [IsCountablyGenerated u] (hf : \u2200 n, AeMeasurable (f n) \u03bc)\n    (h_tendsto : \u2200\u1d50 x \u2202\u03bc, Tendsto (fun n => f n x) u (\ud835\udcdd (g x))) : AeMeasurable g \u03bc :=\n  by\n  rcases u.exists_seq_tendsto with \u27e8v, hv\u27e9\n  have h'f : \u2200 n, AeMeasurable (f (v n)) \u03bc := fun n => hf (v n)\n  set p : \u03b1 \u2192 (\u2115 \u2192 \u03b2) \u2192 Prop := fun x f' => tendsto (fun n => f' n) at_top (\ud835\udcdd (g x))\n  have hp : \u2200\u1d50 x \u2202\u03bc, 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 \u2208 aeSeqSet h'f p) (g x) (\u27e8f (v 0) x\u27e9 : Nonempty \u03b2).some with hs\n  refine'\n    \u27e8ae_seq_lim,\n      measurable_of_tendsto_metrizable' at_top (aeSeq.measurable h'f p)\n        (tendsto_pi_nhds.mpr fun x => _),\n      _\u27e9\n  \u00b7 simp_rw [aeSeq, ae_seq_lim]\n    split_ifs with hx\n    \u00b7 simp_rw [aeSeq.mk_eq_fun_of_mem_aeSeqSet h'f hx]\n      exact @aeSeq.funPropOfMemAeSeqSet _ \u03b1 \u03b2 _ _ _ _ _ h'f x hx\n    \u00b7 exact tendsto_const_nhds\n  \u00b7\n    exact\n      (ite_ae_eq_of_measure_compl_zero g (fun x => (\u27e8f (v 0) x\u27e9 : Nonempty \u03b2).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' {\u03bc : Measure \u03b1} {f : \u2115 \u2192 \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2}\n    (hf : \u2200 n, AeMeasurable (f n) \u03bc)\n    (h_ae_tendsto : \u2200\u1d50 x \u2202\u03bc, Tendsto (fun n => f n x) atTop (\ud835\udcdd (g x))) : AeMeasurable g \u03bc :=\n  aeMeasurableOfTendstoMetrizableAe atTop hf h_ae_tendsto\n#align ae_measurable_of_tendsto_metrizable_ae' aeMeasurableOfTendstoMetrizableAe'\n\ntheorem aeMeasurableOfUnifApprox {\u03b2} [MeasurableSpace \u03b2] [PseudoMetricSpace \u03b2] [BorelSpace \u03b2]\n    {\u03bc : Measure \u03b1} {g : \u03b1 \u2192 \u03b2}\n    (hf : \u2200 \u03b5 > (0 : \u211d), \u2203 f : \u03b1 \u2192 \u03b2, AeMeasurable f \u03bc \u2227 \u2200\u1d50 x \u2202\u03bc, dist (f x) (g x) \u2264 \u03b5) :\n    AeMeasurable g \u03bc :=\n  by\n  obtain \u27e8u, u_anti, u_pos, u_lim\u27e9 :\n    \u2203 u : \u2115 \u2192 \u211d, StrictAnti u \u2227 (\u2200 n : \u2115, 0 < u n) \u2227 tendsto u at_top (\ud835\udcdd 0) :=\n    exists_seq_strictAnti_tendsto (0 : \u211d)\n  choose f Hf using fun n : \u2115 => hf (u n) (u_pos n)\n  have : \u2200\u1d50 x \u2202\u03bc, tendsto (fun n => f n x) at_top (\ud835\udcdd (g x)) :=\n    by\n    have : \u2200\u1d50 x \u2202\u03bc, \u2200 n, dist (f n x) (g x) \u2264 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 {\u03bc : Measure \u03b1} [\u03bc.IsComplete] {f : \u2115 \u2192 \u03b1 \u2192 \u03b2}\n    {g : \u03b1 \u2192 \u03b2} (hf : \u2200 n, Measurable (f n))\n    (h_ae_tendsto : \u2200\u1d50 x \u2202\u03bc, Tendsto (fun n => f n x) atTop (\ud835\udcdd (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 {\u03b9} [Countable \u03b9] [Nonempty \u03b9] {\u03bc : Measure \u03b1}\n    {f : \u03b9 \u2192 \u03b1 \u2192 \u03b2} {L : Filter \u03b9} [L.IsCountablyGenerated] (hf : \u2200 n, AeMeasurable (f n) \u03bc)\n    (h_ae_tendsto : \u2200\u1d50 x \u2202\u03bc, \u2203 l : \u03b2, Tendsto (fun n => f n x) L (\ud835\udcdd l)) :\n    \u2203 (f_lim : \u03b1 \u2192 \u03b2)(hf_lim_meas : Measurable f_lim),\n      \u2200\u1d50 x \u2202\u03bc, Tendsto (fun n => f n x) L (\ud835\udcdd (f_lim x)) :=\n  by\n  inhabit \u03b9\n  rcases eq_or_ne L \u22a5 with (rfl | hL)\n  \u00b7 exact \u27e8(hf default).mk _, (hf default).measurable_mk, eventually_of_forall fun x => tendsto_bot\u27e9\n  haveI : ne_bot L := \u27e8hL\u27e9\n  let p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop := fun x f' => \u2203 l : \u03b2, tendsto (fun n => f' n) L (\ud835\udcdd l)\n  have hp_mem : \u2200 x \u2208 aeSeqSet hf p, p x fun n => f n x := fun x hx =>\n    aeSeq.funPropOfMemAeSeqSet hf hx\n  have h_ae_eq : \u2200\u1d50 x \u2202\u03bc, \u2200 n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto\n  let f_lim : \u03b1 \u2192 \u03b2 := fun x =>\n    dite (x \u2208 aeSeqSet hf p) (fun h => (hp_mem x h).some) fun h => (\u27e8f default x\u27e9 : Nonempty \u03b2).some\n  have hf_lim : \u2200 x, tendsto (fun n => aeSeq hf p n x) L (\ud835\udcdd (f_lim x)) :=\n    by\n    intro x\n    simp only [f_lim, aeSeq]\n    split_ifs\n    \u00b7 refine' (hp_mem x h).choose_spec.congr fun n => _\n      exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm\n    \u00b7 exact tendsto_const_nhds\n  have h_ae_tendsto_f_lim : \u2200\u1d50 x \u2202\u03bc, tendsto (fun n => f n x) L (\ud835\udcdd (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 \u27e8f_lim, h_f_lim_meas, h_ae_tendsto_f_lim\u27e9\n#align measurable_limit_of_tendsto_metrizable_ae measurable_limit_of_tendsto_metrizable_ae\n\nend Limits\n\nnamespace ContinuousLinearMap\n\nvariable {\ud835\udd5c : Type _} [NormedField \ud835\udd5c]\n\nvariable {E : Type _} [NormedAddCommGroup E] [NormedSpace \ud835\udd5c E] [MeasurableSpace E]\n  [OpensMeasurableSpace E] {F : Type _} [NormedAddCommGroup F] [NormedSpace \ud835\udd5c F] [MeasurableSpace F]\n  [BorelSpace F]\n\n@[measurability]\nprotected theorem measurable (L : E \u2192L[\ud835\udd5c] F) : Measurable L :=\n  L.Continuous.Measurable\n#align continuous_linear_map.measurable ContinuousLinearMap.measurable\n\ntheorem measurable_comp (L : E \u2192L[\ud835\udd5c] F) {\u03c6 : \u03b1 \u2192 E} (\u03c6_meas : Measurable \u03c6) :\n    Measurable fun a : \u03b1 => L (\u03c6 a) :=\n  L.Measurable.comp \u03c6_meas\n#align continuous_linear_map.measurable_comp ContinuousLinearMap.measurable_comp\n\nend ContinuousLinearMap\n\nnamespace ContinuousLinearMap\n\nvariable {\ud835\udd5c : Type _} [NontriviallyNormedField \ud835\udd5c]\n\nvariable {E : Type _} [NormedAddCommGroup E] [NormedSpace \ud835\udd5c E] {F : Type _} [NormedAddCommGroup F]\n  [NormedSpace \ud835\udd5c F]\n\ninstance : MeasurableSpace (E \u2192L[\ud835\udd5c] F) :=\n  borel _\n\ninstance : BorelSpace (E \u2192L[\ud835\udd5c] F) :=\n  \u27e8rfl\u27e9\n\n@[measurability]\ntheorem measurable_apply [MeasurableSpace F] [BorelSpace F] (x : E) :\n    Measurable fun f : E \u2192L[\ud835\udd5c] F => f x :=\n  (apply \ud835\udd5c 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 \u2192L[\ud835\udd5c] 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 \u2192L[\ud835\udd5c] 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 {\ud835\udd5c : Type _} [NontriviallyNormedField \ud835\udd5c]\n\nvariable {E : Type _} [NormedAddCommGroup E] [NormedSpace \ud835\udd5c E] [MeasurableSpace E] [BorelSpace E]\n  {F : Type _} [NormedAddCommGroup F] [NormedSpace \ud835\udd5c F]\n\n@[measurability]\ntheorem Measurable.apply_continuousLinearMap {\u03c6 : \u03b1 \u2192 F \u2192L[\ud835\udd5c] E} (h\u03c6 : Measurable \u03c6) (v : F) :\n    Measurable fun a => \u03c6 a v :=\n  (ContinuousLinearMap.apply \ud835\udd5c E v).Measurable.comp h\u03c6\n#align measurable.apply_continuous_linear_map Measurable.apply_continuousLinearMap\n\n@[measurability]\ntheorem AeMeasurable.applyContinuousLinearMap {\u03c6 : \u03b1 \u2192 F \u2192L[\ud835\udd5c] E} {\u03bc : Measure \u03b1}\n    (h\u03c6 : AeMeasurable \u03c6 \u03bc) (v : F) : AeMeasurable (fun a => \u03c6 a v) \u03bc :=\n  (ContinuousLinearMap.apply \ud835\udd5c E v).Measurable.compAeMeasurable h\u03c6\n#align ae_measurable.apply_continuous_linear_map AeMeasurable.applyContinuousLinearMap\n\nend ContinuousLinearMapNontriviallyNormedField\n\nsection NormedSpace\n\nvariable {\ud835\udd5c : Type _} [NontriviallyNormedField \ud835\udd5c] [CompleteSpace \ud835\udd5c] [MeasurableSpace \ud835\udd5c]\n\nvariable [BorelSpace \ud835\udd5c] {E : Type _} [NormedAddCommGroup E] [NormedSpace \ud835\udd5c E] [MeasurableSpace E]\n  [BorelSpace E]\n\ntheorem measurable_smul_const {f : \u03b1 \u2192 \ud835\udd5c} {c : E} (hc : c \u2260 0) :\n    (Measurable fun x => f x \u2022 c) \u2194 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 : \u03b1 \u2192 \ud835\udd5c} {\u03bc : Measure \u03b1} {c : E} (hc : c \u2260 0) :\n    AeMeasurable (fun x => f x \u2022 c) \u03bc \u2194 AeMeasurable f \u03bc :=\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 \u00d7 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 (\u21a5G \u00d7 \u21a5H))\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 \u21a5G \u21a5H) (add_monoid_hom.snd \u21a5G \u21a5H)))\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.\u03c0 s) category_theory.limits.walking_pair.left)\n          (category_theory.nat_trans.app (category_theory.limits.cone.\u03c0 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 \u229e H \u2245 of (\u21a5G \u00d7 \u21a5H) :=\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 \u2964 AddCommGroup) (s : category_theory.limits.cone F) : category_theory.limits.cone.X s \u27f6 of ((j : category_theory.discrete J) \u2192 \u21a5(category_theory.functor.obj F j)) :=\n  add_monoid_hom.mk\n    (fun (x : \u21a5(category_theory.limits.cone.X s)) (j : category_theory.discrete J) =>\n      coe_fn (category_theory.nat_trans.app (category_theory.limits.cone.\u03c0 s) j) x)\n    sorry sorry\n\n@[simp] theorem lift_apply {J : Type u} (F : category_theory.discrete J \u2964 AddCommGroup) (s : category_theory.limits.cone F) (x : \u21a5(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.\u03c0 s) j) x :=\n  rfl\n\n/--\nConstruct limit data for a product in `AddCommGroup`, using `AddCommGroup.of (\u03a0 j, F.obj j)`.\n-/\ndef product_limit_cone {J : Type u} (F : category_theory.discrete J \u2964 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) \u2192 \u21a5(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) => \u21a5(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 \u2192 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 \u2192 AddCommGroup) : \u2a01 f \u2245 of ((j : J) \u2192 \u21a5(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 \u2192 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 {\u03b1 : Sort u} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) : Type u where\n  value : \u03b1\n  neutral : Option $ IsNeutral op value\n\nstructure Context (\u03b1 : Sort u) where\n  op : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  assoc : IsAssociative op\n  comm : Option $ IsCommutative op\n  idem : Option $ IsIdempotent op\n  vars : List (Variable op)\n  arbitrary : \u03b1\n\nclass ContextInformation (\u03b1 : Sort u) where\n  isNeutral : \u03b1 \u2192 Nat \u2192 Bool\n  isComm : \u03b1 \u2192 Bool\n  isIdem : \u03b1 \u2192 Bool\n\nclass EvalInformation (\u03b1 : Sort u) (\u03b2 : Sort v) where\n  arbitrary : \u03b1 \u2192 \u03b2\n  evalOp : \u03b1 \u2192 \u03b2 \u2192 \u03b2 \u2192 \u03b2\n  evalVar : \u03b1 \u2192 Nat \u2192 \u03b2\n\ndef Context.var (ctx : Context \u03b1) (idx : Nat) : Variable ctx.op :=\n  ctx.vars.getD idx \u27e8ctx.arbitrary, none\u27e9\n\ninstance : ContextInformation (Context \u03b1) 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 \u03b1) \u03b1 where\n  arbitrary ctx := ctx.arbitrary\n  evalOp ctx := ctx.op\n  evalVar ctx idx := ctx.var idx |>.value\n\ndef eval (\u03b2 : Sort u) [EvalInformation \u03b1 \u03b2] (ctx : \u03b1) : (ex : Expr) \u2192 \u03b2\n  | Expr.var idx => EvalInformation.evalVar ctx idx\n  | Expr.op l r => EvalInformation.evalOp ctx (eval \u03b2 ctx l) (eval \u03b2 ctx r)\n\ndef Expr.toList : Expr \u2192 List Nat\n  | Expr.var idx => [idx]\n  | Expr.op l r => l.toList.append r.toList\n\ndef evalList (\u03b2 : Sort u) [EvalInformation \u03b1 \u03b2] (ctx : \u03b1) : List Nat \u2192 \u03b2\n  | [] => EvalInformation.arbitrary ctx\n  | [x] => EvalInformation.evalVar ctx x\n  | x :: xs => EvalInformation.evalOp ctx (EvalInformation.evalVar ctx x) (evalList \u03b2 ctx xs)\n\ndef insert (x : Nat) : List Nat \u2192 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 \u2192 List Nat \u2192 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 \u2192 List Nat \u2192 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 \u03b1] (ctx : \u03b1) : List Nat \u2192 List Nat\n  | x :: xs =>\n    match loop (x :: xs) with\n    | [] => [x]\n    | ys => ys\n  | [] => []\n  where loop : List Nat \u2192 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 \u03b1] (ctx : \u03b1) (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 \u2192 Sort u}\n  (l : List Nat)\n  (empty : motive [])\n  (single : \u2200 a, motive [a])\n  (step : \u2200 a b l, motive (b :: l) \u2192 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 \u2260 []) : mergeIdem e \u2260 [] := 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 \u2260 y) : mergeIdem (x :: y :: ys) = x :: mergeIdem (y :: ys) := by\n  simp [mergeIdem, mergeIdem.loop, h]\n\ntheorem Context.evalList_mergeIdem (ctx : Context \u03b1) (h : ContextInformation.isIdem ctx) (e : List Nat) : evalList \u03b1 ctx (mergeIdem e) = evalList \u03b1 ctx e := by\n  have h : IsIdempotent ctx.op := by simp [ContextInformation.isIdem, Option.isSome] at h; cases h\u2082 : ctx.idem <;> simp [h\u2082] 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\u2082 => simp [evalList, h\u2082, h.1, EvalInformation.evalOp]\n      rfl\n    | cons z zs =>\n      by_cases h\u2082 : x = y\n      case inl =>\n        rw [h\u2082, mergeIdem_head, ih]\n        simp [evalList, \u2190ctx.assoc.1, h.1, EvalInformation.evalOp]\n      case inr =>\n        rw [mergeIdem_head2]\n        by_cases h\u2083 : y = z\n        case inl =>\n          simp [mergeIdem_head, h\u2083, evalList]\n          cases h\u2084 : mergeIdem (z :: zs) with\n          | nil => apply absurd h\u2084; apply mergeIdem_nonEmpty; simp\n          | cons u us => simp_all [mergeIdem, mergeIdem.loop, evalList]\n        case inr =>\n          simp [mergeIdem_head2, h\u2083, evalList] at *\n          rw [ih]\n        assumption\n\ntheorem insert_nonEmpty : insert x xs \u2260 [] := 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 \u2260 []) : sort.loop xs ys \u2260 [] := 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 \u03b1)\n  (h : IsCommutative ctx.op)\n  (x : Nat)\n  (xs : List Nat)\n  : evalList \u03b1 ctx (insert x xs) = evalList \u03b1 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 \u03b1)\n  (h : IsCommutative ctx.op)\n  (h\u2082 : evalList \u03b1 ctx a = evalList \u03b1 ctx b)\n  (h\u2083 : a \u2260 [])\n  (h\u2084 : b \u2260 [])\n  : evalList \u03b1 ctx (sort.loop a c) = evalList \u03b1 ctx (sort.loop b c) := by\n  induction c generalizing a b with\n  | nil => simp [sort.loop, h\u2082]\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\u2083; simp\n    | cons a as =>\n      cases b with\n      | nil => apply absurd h\u2084; simp\n      | cons b bs => simp [evalList, h\u2082]\n    all_goals apply insert_nonEmpty\n\ntheorem Context.evalList_sort_loop_swap\n  (ctx : Context \u03b1)\n  (h : IsCommutative ctx.op)\n  (xs ys : List Nat)\n  : evalList \u03b1 ctx (sort.loop xs (y::ys)) = evalList \u03b1 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\u2082 : insert y xs\n    . apply absurd h\u2082; simp [insert_nonEmpty]\n    . simp [evalList, \u2190h\u2082, evalList_insert ctx h]\n    all_goals simp [insert_nonEmpty]\n\ntheorem Context.evalList_sort_cons\n  (ctx : Context \u03b1)\n  (h : IsCommutative ctx.op)\n  (x : Nat)\n  (xs : List Nat)\n  : evalList \u03b1 ctx (sort (x :: xs)) = evalList \u03b1 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, \u2190ih]; apply evalList_sort_congr ctx h; rw [evalList_insert ctx h]\n    cases h\u2082 : insert x ys with\n    | nil => apply absurd h\u2082; simp [insert_nonEmpty]\n    | cons u us =>\n      cases h\u2083 : insert z ys with\n      | nil => apply absurd h\u2083; simp [insert_nonEmpty]\n      | cons v vs =>\n        simp [evalList, \u2190h\u2082, \u2190h\u2083, 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 \u03b1) (h : ContextInformation.isComm ctx) (e : List Nat) : evalList \u03b1 ctx (sort e) = evalList \u03b1 ctx e := by\n  have h : IsCommutative ctx.op := by simp [ContextInformation.isComm, Option.isSome] at h; cases h\u2082 : ctx.comm <;> simp [h\u2082] 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\u2082 : sort (y :: ys) with\n    | nil => simp [sort, sort.loop] at *; apply absurd h\u2082; apply sort_loop_nonEmpty; apply insert_nonEmpty\n    | cons z zs => simp [evalList, \u2190h\u2082, ih]\n\ntheorem Context.toList_nonEmpty (e : Expr) : e.toList \u2260 [] := by\n  induction e with\n  | var => simp [Expr.toList]\n  | op l r ih\u2081 _   =>\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 \u03b1}\n  {x : Nat}\n  : ContextInformation.isNeutral ctx x = true \u2192 IsNeutral (EvalInformation.evalOp ctx) (EvalInformation.evalVar (\u03b2 := \u03b1) 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 \u03b1) (e : List Nat) : evalList \u03b1 ctx (removeNeutrals ctx e) = evalList \u03b1 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\u2081 : ContextInformation.isNeutral ctx x <;> cases h\u2082 : ContextInformation.isNeutral ctx y <;> cases h\u2083 : removeNeutrals.loop ctx ys\n    <;> simp [removeNeutrals, removeNeutrals.loop, h\u2081, h\u2082, h\u2083, evalList, \u2190ih]\n    <;> (try simp [unwrap_isNeutral h\u2082 |>.2])\n    <;> (try simp [unwrap_isNeutral h\u2081 |>.1])\n\ntheorem Context.evalList_append\n  (ctx : Context \u03b1)\n  (l r : List Nat)\n  (h\u2081 : l \u2260 [])\n  (h\u2082 : r \u2260 [])\n  : evalList \u03b1 ctx (l.append r) = ctx.op (evalList \u03b1 ctx l) (evalList \u03b1 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\u2082\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 \u03b1) (e : Expr) : evalList \u03b1 ctx e.toList = eval \u03b1 ctx e := by\n  induction e with\n  | var x => rfl\n  | op l r ih\u2081 ih\u2082 =>\n    simp [evalList, Expr.toList, eval, \u2190ih\u2081, \u2190ih\u2082]\n    apply evalList_append <;> apply toList_nonEmpty\n\ntheorem Context.eval_norm (ctx : Context \u03b1) (e : Expr) : evalList \u03b1 ctx (norm ctx e) = eval \u03b1 ctx e := by\n  simp [norm]\n  cases h\u2081 : ContextInformation.isIdem ctx <;> cases h\u2082 : ContextInformation.isComm ctx <;>\n  simp_all [evalList_removeNeutrals, eval_toList, toList_nonEmpty, evalList_mergeIdem, evalList_sort]\n\ntheorem Context.eq_of_norm (ctx : Context \u03b1) (a b : Expr) (h : norm ctx a == norm ctx b) : eval \u03b1 ctx a = eval \u03b1 ctx b := by\n  have h := congrArg (evalList \u03b1 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 `\u2113^\u221e(\u211d)` up to isometry, which is a well-defined type,\nand define the distance as the infimum of the Hausdorff distance over all\nembeddings in `\u2113^\u221e(\u211d)`. We prove that this coincides with the previous description,\nas all separable metric spaces embed isometrically into `\u2113^\u221e(\u211d)`, 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 `\u2113_infty_\u211d`:= lp (\u03bb n : \u2115, \u211d) \u221e\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 `\u2113^\u221e(\u211d)` 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 \u2113_infty_\u211d \u2192 nonempty_compacts \u2113_infty_\u211d \u2192 Prop :=\n\u03bb x y, nonempty (x \u2243\u1d62 y)\n\n/-- This is indeed an equivalence relation -/\nprivate lemma is_equivalence_isometry_rel : equivalence isometry_rel :=\n\u27e8\u03bb x, \u27e8isometric.refl _\u27e9, \u03bb x y \u27e8e\u27e9, \u27e8e.symm\u27e9, \u03bb x y z \u27e8e\u27e9 \u27e8f\u27e9, \u27e8e.trans f\u27e9\u27e9\n\n/-- setoid instance identifying two isometric nonempty compact subspaces of \u2113^\u221e(\u211d) -/\ninstance isometry_rel.setoid : setoid (nonempty_compacts \u2113_infty_\u211d) :=\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  \u27e6nonempty_compacts.Kuratowski_embedding X\u27e7\n\ninstance : inhabited GH_space := \u27e8quot.mk _ \u27e8\u27e8{0}, is_compact_singleton\u27e9, singleton_nonempty _\u27e9\u27e9\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 \u2113_infty_\u211d)\n\nlemma eq_to_GH_space_iff {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {p : nonempty_compacts \u2113_infty_\u211d} :\n  \u27e6p\u27e7 = to_GH_space X \u2194 \u2203 \u03a8 : X \u2192 \u2113_infty_\u211d, isometry \u03a8 \u2227 range \u03a8 = p :=\nbegin\n  simp only [to_GH_space, quotient.eq],\n  refine \u27e8\u03bb h, _, _\u27e9,\n  { rcases setoid.symm h with \u27e8e\u27e9,\n    have f := (Kuratowski_embedding.isometry X).isometric_on_range.trans e,\n    use [\u03bb 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 \u27e8\u03a8, \u27e8isom\u03a8, range\u03a8\u27e9\u27e9,\n    have f := ((Kuratowski_embedding.isometry X).isometric_on_range.symm.trans\n               isom\u03a8.isometric_on_range).symm,\n    have E : (range \u03a8 \u2243\u1d62 nonempty_compacts.Kuratowski_embedding X) =\n        (p \u2243\u1d62 range (Kuratowski_embedding X)),\n      by { dunfold nonempty_compacts.Kuratowski_embedding, rw [range\u03a8]; refl },\n    exact \u27e8cast E f\u27e9 }\nend\n\nlemma eq_to_GH_space {p : nonempty_compacts \u2113_infty_\u211d} : \u27e6p\u27e7 = to_GH_space p :=\neq_to_GH_space_iff.2 \u27e8\u03bb x, x, isometry_subtype_coe, subtype.range_coe\u27e9\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 \u2113_infty_\u211d) = p,\n  rw \u2190 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 \u2194 nonempty (X \u2243\u1d62 Y) :=\n\u27e8begin\n  simp only [to_GH_space, quotient.eq],\n  rintro \u27e8e\u27e9,\n  have I : ((nonempty_compacts.Kuratowski_embedding X) \u2243\u1d62\n             (nonempty_compacts.Kuratowski_embedding Y))\n          = ((range (Kuratowski_embedding X)) \u2243\u1d62 (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 \u27e8f.trans $ (cast I e).trans g\u27e9\nend,\nbegin\n  rintro \u27e8e\u27e9,\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)) \u2243\u1d62 (range (Kuratowski_embedding Y))) =\n    ((nonempty_compacts.Kuratowski_embedding X) \u2243\u1d62\n      (nonempty_compacts.Kuratowski_embedding Y)),\n    by { dunfold nonempty_compacts.Kuratowski_embedding, refl },\n  exact \u27e8cast I ((f.trans e).trans g)\u27e9\nend\u27e9\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 `\u2113^\u221e(\u211d)`, but we will prove below that it works for all spaces. -/\ninstance : has_dist (GH_space) :=\n{ dist := \u03bb x y, Inf $\n    (\u03bb p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d,\n      Hausdorff_dist (p.1 : set \u2113_infty_\u211d) p.2) '' ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = 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] : \u211d := 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  {\u03b3 : Type w} [metric_space \u03b3] {\u03a6 : X \u2192 \u03b3} {\u03a8 : Y \u2192 \u03b3} (ha : isometry \u03a6) (hb : isometry \u03a8) :\n  GH_dist X Y \u2264 Hausdorff_dist (range \u03a6) (range \u03a8) :=\nbegin\n  /- For the proof, we want to embed `\u03b3` in `\u2113^\u221e(\u211d)`, to say that the Hausdorff distance is realized\n  in `\u2113^\u221e(\u211d)` and therefore bounded below by the Gromov-Hausdorff-distance. However, `\u03b3` is not\n  separable in general. We restrict to the union of the images of `X` and `Y` in `\u03b3`, which is\n  separable and therefore embeddable in `\u2113^\u221e(\u211d)`. -/\n  rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n  let s : set \u03b3 := (range \u03a6) \u222a (range \u03a8),\n  let \u03a6' : X \u2192 subtype s := \u03bb y, \u27e8\u03a6 y, mem_union_left _ (mem_range_self _)\u27e9,\n  let \u03a8' : Y \u2192 subtype s := \u03bb y, \u27e8\u03a8 y, mem_union_right _ (mem_range_self _)\u27e9,\n  have I\u03a6' : isometry \u03a6' := \u03bb x y, ha x y,\n  have I\u03a8' : isometry \u03a8' := \u03bb 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) := \u27e8is_compact_iff_is_compact_univ.1 \u2039is_compact s\u203a\u27e9,\n  haveI : nonempty (subtype s) := \u27e8\u03a6' xX\u27e9,\n  have \u03a6\u03a6' : \u03a6 = subtype.val \u2218 \u03a6', by { funext, refl },\n  have \u03a8\u03a8' : \u03a8 = subtype.val \u2218 \u03a8', by { funext, refl },\n  have : Hausdorff_dist (range \u03a6) (range \u03a8) = Hausdorff_dist (range \u03a6') (range \u03a8'),\n  { rw [\u03a6\u03a6', \u03a8\u03a8', range_comp, range_comp],\n    exact Hausdorff_dist_image (isometry_subtype_coe) },\n  rw this,\n  -- Embed `s` in `\u2113^\u221e(\u211d)` through its Kuratowski embedding\n  let F := Kuratowski_embedding (subtype s),\n  have : Hausdorff_dist (F '' (range \u03a6')) (F '' (range \u03a8')) =\n    Hausdorff_dist (range \u03a6') (range \u03a8') := Hausdorff_dist_image (Kuratowski_embedding.isometry _),\n  rw \u2190 this,\n  -- Let `A` and `B` be the images of `X` and `Y` under this embedding. They are in `\u2113^\u221e(\u211d)`, and\n  -- their Hausdorff distance is the same as in the original space.\n  let A : nonempty_compacts \u2113_infty_\u211d := \u27e8\u27e8F '' (range \u03a6'), (is_compact_range I\u03a6'.continuous).image\n    (Kuratowski_embedding.isometry _).continuous\u27e9, (range_nonempty _).image _\u27e9,\n  let B : nonempty_compacts \u2113_infty_\u211d := \u27e8\u27e8F '' (range \u03a8'), (is_compact_range I\u03a8'.continuous).image\n    (Kuratowski_embedding.isometry _).continuous\u27e9, (range_nonempty _).image _\u27e9,\n  have AX : \u27e6A\u27e7 = to_GH_space X,\n  { rw eq_to_GH_space_iff,\n    exact \u27e8\u03bb x, F (\u03a6' x), (Kuratowski_embedding.isometry _).comp I\u03a6', range_comp _ _\u27e9 },\n  have BY : \u27e6B\u27e7 = to_GH_space Y,\n  { rw eq_to_GH_space_iff,\n    exact \u27e8\u03bb x, F (\u03a8' x), (Kuratowski_embedding.isometry _).comp I\u03a8', range_comp _ _\u27e9 },\n  refine cInf_le \u27e80,\n    begin simp [lower_bounds], assume t _ _ _ _ ht, rw \u2190 ht, exact Hausdorff_dist_nonneg end\u27e9 _,\n  apply (mem_image _ _ _).2,\n  existsi (\u27e8A, B\u27e9 : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\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 `\u2264`, 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 \u2295 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 : \u2200 p q : nonempty_compacts \u2113_infty_\u211d, \u27e6p\u27e7 = to_GH_space X \u2192 \u27e6q\u27e7 = to_GH_space Y \u2192\n        Hausdorff_dist (p : set \u2113_infty_\u211d) q < diam (univ : set X) + 1 + diam (univ : set Y) \u2192\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) \u2264\n        Hausdorff_dist (p : set \u2113_infty_\u211d) q,\n  { assume p q hp hq bound,\n    rcases eq_to_GH_space_iff.1 hp with \u27e8\u03a6, \u27e8\u03a6isom, \u03a6range\u27e9\u27e9,\n    rcases eq_to_GH_space_iff.1 hq with \u27e8\u03a8, \u27e8\u03a8isom, \u03a8range\u27e9\u27e9,\n    have I : diam (range \u03a6 \u222a range \u03a8) \u2264 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y),\n    { rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n      have : \u2203 y \u2208 range \u03a8, dist (\u03a6 xX) y < diam (univ : set X) + 1 + diam (univ : set Y),\n      { rw \u03a8range,\n        have : \u03a6 xX \u2208 \u2191p := \u03a6range.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 \u27e8y, hy, dy\u27e9,\n      rcases mem_range.1 hy with \u27e8z, hzy\u27e9,\n      rw \u2190 hzy at dy,\n      have D\u03a6 : diam (range \u03a6) = diam (univ : set X) := \u03a6isom.diam_range,\n      have D\u03a8 : diam (range \u03a8) = diam (univ : set Y) := \u03a8isom.diam_range,\n      calc\n        diam (range \u03a6 \u222a range \u03a8) \u2264 diam (range \u03a6) + dist (\u03a6 xX) (\u03a8 z) + diam (range \u03a8) :\n          diam_union (mem_range_self _) (mem_range_self _)\n        ... \u2264 diam (univ : set X) + (diam (univ : set X) + 1 + diam (univ : set Y)) +\n              diam (univ : set Y) :\n          by { rw [D\u03a6, D\u03a8], 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 \u2295 Y \u2192 \u2113_infty_\u211d := \u03bb x, match x with | inl y := \u03a6 y | inr z := \u03a8 z end,\n    let F : (X \u2295 Y) \u00d7 (X \u2295 Y) \u2192 \u211d := \u03bb p, dist (f p.1) (f p.2),\n    -- check that the induced \"distance\" is a candidate\n    have Fgood : F \u2208 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 \u03bb x y, calc\n        F (inl x, inl y) = dist (\u03a6 x) (\u03a6 y) : rfl\n        ... = dist x y : \u03a6isom.dist_eq x y },\n      { exact \u03bb x y, calc\n        F (inr x, inr y) = dist (\u03a8 x) (\u03a8 y) : rfl\n        ... = dist x y : \u03a8isom.dist_eq x y },\n      { exact \u03bb x y, dist_comm _ _ },\n      { exact \u03bb x y z, dist_triangle _ _ _ },\n      { exact \u03bb x y, calc\n        F (x, y) \u2264 diam (range \u03a6 \u222a range \u03a8) :\n        begin\n          have A : \u2200 z : X \u2295 Y, f z \u2208 range \u03a6 \u222a range \u03a8,\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 [\u03a6range, \u03a8range],\n          exact (p \u2294 q).compact.bounded,\n        end\n        ... \u2264 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)) \u2264 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 (\u03bb r hr, _)),\n    have I1 : \u2200 x : X, (\u2a05 y, Fb (inl x, inr y)) \u2264 r,\n    { assume x,\n      have : f (inl x) \u2208 \u2191p := \u03a6range.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 \u27e8z, zq, hz\u27e9,\n      have : z \u2208 range \u03a8, by rwa [\u2190 \u03a8range] at zq,\n      rcases mem_range.1 this with \u27e8y, hy\u27e9,\n      calc (\u2a05 y, Fb (inl x, inr y)) \u2264 Fb (inl x, inr y) :\n          cinfi_le (by simpa using HD_below_aux1 0) y\n        ... = dist (\u03a6 x) (\u03a8 y) : rfl\n        ... = dist (f (inl x)) z : by rw hy\n        ... \u2264 r : le_of_lt hz },\n    have I2 : \u2200 y : Y, (\u2a05 x, Fb (inl x, inr y)) \u2264 r,\n    { assume y,\n      have : f (inr y) \u2208 \u2191q := \u03a8range.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 \u27e8z, zq, hz\u27e9,\n      have : z \u2208 range \u03a6, by rwa [\u2190 \u03a6range] at zq,\n      rcases mem_range.1 this with \u27e8x, hx\u27e9,\n      calc (\u2a05 x, Fb (inl x, inr y)) \u2264 Fb (inl x, inr y) :\n          cinfi_le (by simpa using HD_below_aux2 0) x\n        ... = dist (\u03a6 x) (\u03a8 y) : rfl\n        ... = dist z (f (inr y)) : by rw hx\n        ... \u2264 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 : \u2200 p q : nonempty_compacts \u2113_infty_\u211d, \u27e6p\u27e7 = to_GH_space X \u2192 \u27e6q\u27e7 = to_GH_space Y \u2192\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) \u2264\n        Hausdorff_dist (p : set \u2113_infty_\u211d) q,\n  { assume p q hp hq,\n    by_cases h :\n      Hausdorff_dist (p : set \u2113_infty_\u211d) 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               \u2264 HD (candidates_b_dist X Y) :\n             Hausdorff_dist_optimal_le_HD _ _ (candidates_b_dist_mem_candidates_b)\n           ... \u2264 diam (univ : set X) + 1 + diam (univ : set Y) : HD_candidates_b_dist_le\n           ... \u2264 Hausdorff_dist (p : set \u2113_infty_\u211d) q : not_lt.1 h } },\n  refine le_antisymm _ _,\n  { apply le_cInf,\n    { refine (set.nonempty.prod _ _).image _; exact \u27e8_, rfl\u27e9 },\n    { rintro b \u27e8\u27e8p, q\u27e9, \u27e8hp, hq\u27e9, rfl\u27e9,\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 `\u2113^\u221e(\u211d)`, 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  \u2203 \u03a6 : X \u2192 \u2113_infty_\u211d, \u2203 \u03a8 : Y \u2192 \u2113_infty_\u211d, isometry \u03a6 \u2227 isometry \u03a8 \u2227\n  GH_dist X Y = Hausdorff_dist (range \u03a6) (range \u03a8) :=\nbegin\n  let F := Kuratowski_embedding (optimal_GH_coupling X Y),\n  let \u03a6 := F \u2218 optimal_GH_injl X Y,\n  let \u03a8 := F \u2218 optimal_GH_injr X Y,\n  refine \u27e8\u03a6, \u03a8, _, _, _\u27e9,\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 [\u2190 image_univ, \u2190 image_univ, image_comp F, image_univ, image_comp F (optimal_GH_injr X Y),\n      image_univ, \u2190 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 := \u03bb x, begin\n    rcases exists_rep x with \u27e8y, hy\u27e9,\n    refine le_antisymm _ _,\n    { apply cInf_le,\n      { exact \u27e80, by { rintro b \u27e8\u27e8u, v\u27e9, \u27e8hu, hv\u27e9, rfl\u27e9, exact Hausdorff_dist_nonneg } \u27e9},\n      { simp, existsi [y, y], simpa } },\n    { apply le_cInf,\n      { exact (nonempty.prod \u27e8y, hy\u27e9 \u27e8y, hy\u27e9).image _ },\n      { rintro b \u27e8\u27e8u, v\u27e9, \u27e8hu, hv\u27e9, rfl\u27e9, exact Hausdorff_dist_nonneg } },\n  end,\n  dist_comm := \u03bb x y, begin\n    have A : (\u03bb (p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\n                 Hausdorff_dist (p.1 : set \u2113_infty_\u211d) p.2) ''\n             ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = y})\n           = ((\u03bb (p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\n                 Hausdorff_dist (p.1 : set \u2113_infty_\u211d) p.2) \u2218 prod.swap) ''\n                 ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = 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 := \u03bb 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 \u27e8\u03a6, \u03a8, \u03a6isom, \u03a8isom, D\u03a6\u03a8\u27e9,\n    rw [\u2190 dist_GH_dist, hxy] at D\u03a6\u03a8,\n    have : range \u03a6 = range \u03a8,\n    { have h\u03a6 : is_compact (range \u03a6) := is_compact_range \u03a6isom.continuous,\n      have h\u03a8 : is_compact (range \u03a8) := is_compact_range \u03a8isom.continuous,\n      apply (is_closed.Hausdorff_dist_zero_iff_eq _ _ _).1 (D\u03a6\u03a8.symm),\n      { exact h\u03a6.is_closed },\n      { exact h\u03a8.is_closed },\n      { exact Hausdorff_edist_ne_top_of_nonempty_of_bounded (range_nonempty _)\n          (range_nonempty _) h\u03a6.bounded h\u03a8.bounded } },\n    have T : ((range \u03a8) \u2243\u1d62 y.rep) = ((range \u03a6) \u2243\u1d62 y.rep), by rw this,\n    have e\u03a8 := cast T \u03a8isom.isometric_on_range.symm,\n    have e := \u03a6isom.isometric_on_range.trans e\u03a8,\n    rw [\u2190 x.to_GH_space_rep, \u2190 y.to_GH_space_rep, to_GH_space_eq_to_GH_space_iff_isometric],\n    exact \u27e8e\u27e9\n  end,\n  dist_triangle := \u03bb 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 `\u03b31`, and an optimal coupling between `Y` and `Z` in a space\n    `\u03b32`. Then, glue these metric spaces along `Y`. We get a new space `\u03b3` 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 `\u03b3` to conclude. -/\n    let X := x.rep,\n    let Y := y.rep,\n    let Z := z.rep,\n    let \u03b31 := optimal_GH_coupling X Y,\n    let \u03b32 := optimal_GH_coupling Y Z,\n    let \u03a6 : Y \u2192 \u03b31 := optimal_GH_injr X Y,\n    have h\u03a6 : isometry \u03a6 := isometry_optimal_GH_injr X Y,\n    let \u03a8 : Y \u2192 \u03b32 := optimal_GH_injl Y Z,\n    have h\u03a8 : isometry \u03a8 := isometry_optimal_GH_injl Y Z,\n    let \u03b3 := glue_space h\u03a6 h\u03a8,\n    letI : metric_space \u03b3 := metric.metric_space_glue_space h\u03a6 h\u03a8,\n    have Comm : (to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y) =\n      (to_glue_r h\u03a6 h\u03a8) \u2218 (optimal_GH_injl Y Z) := to_glue_commute h\u03a6 h\u03a8,\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      ... \u2264 Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injl X Y)))\n                       (range ((to_glue_r h\u03a6 h\u03a8) \u2218 (optimal_GH_injr Y Z))) :\n        GH_dist_le_Hausdorff_dist\n          ((to_glue_l_isometry h\u03a6 h\u03a8).comp (isometry_optimal_GH_injl X Y))\n          ((to_glue_r_isometry h\u03a6 h\u03a8).comp (isometry_optimal_GH_injr Y Z))\n      ... \u2264 Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injl X Y)))\n                           (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y)))\n          + Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y)))\n                           (range ((to_glue_r h\u03a6 h\u03a8) \u2218 (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\u03a6 h\u03a8).comp\n              (isometry_optimal_GH_injl X Y)))).bounded },\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry h\u03a6 h\u03a8).comp\n              (isometry_optimal_GH_injr X Y)))).bounded }\n        end\n      ... = Hausdorff_dist ((to_glue_l h\u03a6 h\u03a8) '' (range (optimal_GH_injl X Y)))\n                           ((to_glue_l h\u03a6 h\u03a8) '' (range (optimal_GH_injr X Y)))\n          + Hausdorff_dist ((to_glue_r h\u03a6 h\u03a8) '' (range (optimal_GH_injl Y Z)))\n                           ((to_glue_r h\u03a6 h\u03a8) '' (range (optimal_GH_injr Y Z))) :\n        by simp only [\u2190 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\u03a6 h\u03a8),\n               Hausdorff_dist_image (to_glue_r_isometry h\u03a6 h\u03a8)]\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 \u2264 dist p q :=\nbegin\n  have ha : isometry (coe : p \u2192 X) := isometry_subtype_coe,\n  have hb : isometry (coe : q \u2192 X) := isometry_subtype_coe,\n  have A : dist p q = Hausdorff_dist (p : set X) q := rfl,\n  have I : \u2191p = range (coe : p \u2192 X) := subtype.range_coe_subtype.symm,\n  have J : \u2191q = range (coe : q \u2192 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 \u2192 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 \u2192 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 `\u03b5\u2082`, then their\nGromov-Hausdorff distance is bounded by `\u03b5\u2082 / 2`. More generally, if there are subsets which are\n`\u03b5\u2081`-dense and `\u03b5\u2083`-dense in two spaces, and isometric up to `\u03b5\u2082`, then the Gromov-Hausdorff\ndistance between the spaces is bounded by `\u03b5\u2081 + \u03b5\u2082/2 + \u03b5\u2083`. 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 `\u03b5\u2081`-dense and `\u03b5\u2083`-dense in two spaces, and\nisometric up to `\u03b5\u2082`, then the Gromov-Hausdorff distance between the spaces is bounded by\n`\u03b5\u2081 + \u03b5\u2082/2 + \u03b5\u2083`. -/\ntheorem GH_dist_le_of_approx_subsets {s : set X} (\u03a6 : s \u2192 Y) {\u03b5\u2081 \u03b5\u2082 \u03b5\u2083 : \u211d}\n  (hs : \u2200 x : X, \u2203 y \u2208 s, dist x y \u2264 \u03b5\u2081) (hs' : \u2200 x : Y, \u2203 y : s, dist x (\u03a6 y) \u2264 \u03b5\u2083)\n  (H : \u2200 x y : s, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5\u2082) :\n  GH_dist X Y \u2264 \u03b5\u2081 + \u03b5\u2082 / 2 + \u03b5\u2083 :=\nbegin\n  refine le_of_forall_pos_le_add (\u03bb \u03b4 \u03b40, _),\n  rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n  rcases hs xX with \u27e8xs, hxs, Dxs\u27e9,\n  have sne : s.nonempty := \u27e8xs, hxs\u27e9,\n  letI : nonempty s := sne.to_subtype,\n  have : 0 \u2264 \u03b5\u2082 := le_trans (abs_nonneg _) (H \u27e8xs, hxs\u27e9 \u27e8xs, hxs\u27e9),\n  have : \u2200 p q : s, |dist p q - dist (\u03a6 p) (\u03a6 q)| \u2264 2 * (\u03b5\u2082/2 + \u03b4) := \u03bb p q, calc\n    |dist p q - dist (\u03a6 p) (\u03a6 q)| \u2264 \u03b5\u2082 : H p q\n    ... \u2264 2 * (\u03b5\u2082/2 + \u03b4) : by linarith,\n  -- glue `X` and `Y` along the almost matching subsets\n  letI : metric_space (X \u2295 Y) :=\n    glue_metric_approx (\u03bb x:s, (x:X)) (\u03bb x, \u03a6 x) (\u03b5\u2082/2 + \u03b4) (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 (\u03bb x y, rfl),\n  have Ir : isometry Fr := isometry_emetric_iff_metric.2 (\u03bb 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  `\u03a6 s`, and of `\u03a6 s` and `Y` (in the coupling or, equivalently, in the original space). The first\n  term is bounded by `\u03b5\u2081`, by `\u03b5\u2081`-density. The third one is bounded by `\u03b5\u2083`. And the middle one is\n  bounded by `\u03b5\u2082/2` as in the coupling the points `x` and `\u03a6 x` are at distance `\u03b5\u2082/2` by\n  construction of the coupling (in fact `\u03b5\u2082/2 + \u03b4` where `\u03b4` 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 \u2295 Y`). -/\n  have : GH_dist X Y \u2264 Hausdorff_dist (range Fl) (range Fr) :=\n    GH_dist_le_Hausdorff_dist Il Ir,\n  have : Hausdorff_dist (range Fl) (range Fr) \u2264 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) \u2264 Hausdorff_dist (Fl '' s) (Fr '' (range \u03a6))\n                                             + Hausdorff_dist (Fr '' (range \u03a6)) (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) \u2264 \u03b5\u2081,\n  { rw [\u2190 image_univ, Hausdorff_dist_image Il],\n    have : 0 \u2264 \u03b5\u2081 := le_trans dist_nonneg Dxs,\n    refine Hausdorff_dist_le_of_mem_dist this (\u03bb x hx, hs x)\n      (\u03bb x hx, \u27e8x, mem_univ _, by simpa\u27e9) },\n  have : Hausdorff_dist (Fl '' s) (Fr '' (range \u03a6)) \u2264 \u03b5\u2082/2 + \u03b4,\n  { refine Hausdorff_dist_le_of_mem_dist (by linarith) _ _,\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with \u27e8x, \u27e8x_in_s, xx'\u27e9\u27e9,\n      rw \u2190 xx',\n      use [Fr (\u03a6 \u27e8x, x_in_s\u27e9), mem_image_of_mem Fr (mem_range_self _)],\n      exact le_of_eq (glue_dist_glued_points (\u03bb x:s, (x:X)) \u03a6 (\u03b5\u2082/2 + \u03b4) \u27e8x, x_in_s\u27e9) },\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with \u27e8y, \u27e8y_in_s', yx'\u27e9\u27e9,\n      rcases mem_range.1 y_in_s' with \u27e8x, xy\u27e9,\n      use [Fl x, mem_image_of_mem _ x.2],\n      rw [\u2190 yx', \u2190 xy, dist_comm],\n      exact le_of_eq (glue_dist_glued_points (@subtype.val X s) \u03a6 (\u03b5\u2082/2 + \u03b4) x) } },\n  have : Hausdorff_dist (Fr '' (range \u03a6)) (range Fr) \u2264 \u03b5\u2083,\n  { rw [\u2190 @image_univ _ _ Fr, Hausdorff_dist_image Ir],\n    rcases exists_mem_of_nonempty Y with \u27e8xY, _\u27e9,\n    rcases hs' xY with \u27e8xs', Dxs'\u27e9,\n    have : 0 \u2264 \u03b5\u2083 := le_trans dist_nonneg Dxs',\n    refine Hausdorff_dist_le_of_mem_dist this (\u03bb x hx, \u27e8x, mem_univ _, by simpa\u27e9) (\u03bb x _, _),\n    rcases hs' x with \u27e8y, Dy\u27e9,\n    exact \u27e8\u03a6 y, mem_range_self _, Dy\u27e9 },\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 (\u03bb \u03b4 \u03b4pos, _),\n  let \u03b5 := (2/5) * \u03b4,\n  have \u03b5pos : 0 < \u03b5 := mul_pos (by norm_num) \u03b4pos,\n  have : \u2200 p:GH_space, \u2203 s : set p.rep, s.finite \u2227 (univ \u2286 (\u22c3x\u2208s, ball x \u03b5)) :=\n    \u03bb p, by simpa using finite_cover_balls_of_compact (@compact_univ p.rep _ _) \u03b5pos,\n  -- for each `p`, `s p` is a finite `\u03b5`-dense subset of `p` (or rather the metric space\n  -- `p.rep` representing `p`)\n  choose s hs using this,\n  have : \u2200 p:GH_space, \u2200 t:set p.rep, t.finite \u2192 \u2203 n:\u2115, \u2203 e:equiv t (fin n), true,\n  { assume p t ht,\n    letI : fintype t := finite.fintype ht,\n    exact \u27e8fintype.card t, fintype.equiv_fin t, trivial\u27e9 },\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 := \u03bb 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 := \u03bb 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 `\u03b5`-dense set `s p`.\n  let F : GH_space \u2192 \u03a3n:\u2115, (fin n \u2192 fin n \u2192 \u2124) :=\n    \u03bbp, \u27e8N p, \u03bba b, \u230a\u03b5\u207b\u00b9 * dist ((E p).symm a) ((E p).symm b)\u230b\u27e9,\n  refine \u27e8\u03a3 n, fin n \u2192 fin n \u2192 \u2124, by apply_instance, F, \u03bbp q hpq, _\u27e9,\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 `\u2264 \u03b4`.\n  For this, we construct a map `\u03a6` from `s p \u2286 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 `\u03a8` between `s p` and `s q`, and then\n  composing with the canonical inclusion we get `\u03a6`. -/\n  have Npq : N p = N q := (sigma.mk.inj_iff.1 hpq).1,\n  let \u03a8 : s p \u2192 s q := \u03bb x, (E q).symm (fin.cast Npq ((E p) x)),\n  let \u03a6 : s p \u2192 q.rep := \u03bb x, \u03a8 x,\n  -- Use the almost isometry `\u03a6` to show that `p.rep` and `q.rep`\n  -- are within controlled Gromov-Hausdorff distance.\n  have main : GH_dist p.rep q.rep \u2264 \u03b5 + \u03b5/2 + \u03b5,\n  { refine GH_dist_le_of_approx_subsets \u03a6  _ _ _,\n    show \u2200 x : p.rep, \u2203 (y : p.rep) (H : y \u2208 s p), dist x y \u2264 \u03b5,\n    { -- by construction, `s p` is `\u03b5`-dense\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s p), ball y \u03b5 := (hs p).2 (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      exact \u27e8y, ys, le_of_lt hy\u27e9 },\n    show \u2200 x : q.rep, \u2203 (z : s p), dist x (\u03a6 z) \u2264 \u03b5,\n    { -- by construction, `s q` is `\u03b5`-dense, and it is the range of `\u03a6`\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s q), ball y \u03b5 := (hs q).2 (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      let i : \u2115 := E q \u27e8y, ys\u27e9,\n      let hi := ((E q) \u27e8y, ys\u27e9).is_lt,\n      have ihi_eq : (\u27e8i, hi\u27e9 : fin (N q)) = (E q) \u27e8y, ys\u27e9, 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 \u27e8i, hip\u27e9,\n      use z,\n      have C1 : (E p) z = \u27e8i, hip\u27e9 := (E p).apply_symm_apply \u27e8i, hip\u27e9,\n      have C2 : fin.cast Npq \u27e8i, hip\u27e9 = \u27e8i, hi\u27e9 := rfl,\n      have C3 : (E q).symm \u27e8i, hi\u27e9 = \u27e8y, ys\u27e9,\n        by { rw ihi_eq, exact (E q).symm_apply_apply \u27e8y, ys\u27e9 },\n      have : \u03a6 z = y :=\n        by { simp only [\u03a6, \u03a8], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_of_lt hy },\n    show \u2200 x y : s p, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `\u03a6 x` and `\u03a6 y` (two points of `s q`) is encoded in `F q`, all this up to `\u03b5`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (\u03a6 x) (\u03a6 y) = dist (\u03a8 x) (\u03a8 y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `\u03a6 x` in `fin (N p) = fin (N q)`\n      let i : \u2115 := 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) (\u03a8 x)), by { simp [\u03a8] },\n      -- introduce `j`, that codes both `y` and `\u03a6 y` in `fin (N p) = fin (N q)`\n      let j : \u2115 := 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) (\u03a8 y)).1, by { simp [\u03a8] },\n      -- Express `dist x y` in terms of `F p`\n      have : (F p).2 ((E p) x) ((E p) y) = floor (\u03b5\u207b\u00b9 * dist x y),\n        by simp only [F, (E p).symm_apply_apply],\n      have Ap : (F p).2 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9 = floor (\u03b5\u207b\u00b9 * dist x y),\n        by { rw \u2190 this, congr; apply (fin.ext_iff _ _).2; refl },\n      -- Express `dist (\u03a6 x) (\u03a6 y)` in terms of `F q`\n      have : (F q).2 ((E q) (\u03a8 x)) ((E q) (\u03a8 y)) = floor (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)),\n        by simp only [F, (E q).symm_apply_apply],\n      have Aq : (F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9 = floor (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)),\n        by { rw \u2190 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 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9 = (F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9,\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 \u22a2,\n        subst hpq,\n        intros,\n        refl },\n      rw [Ap, Aq] at this,\n      -- deduce that the distances coincide up to `\u03b5`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)| =\n          |\u03b5\u207b\u00b9 * (dist x y - dist (\u03a8 x) (\u03a8 y))| : (abs_mul _ _).symm\n        ... = |(\u03b5\u207b\u00b9 * dist x y) - (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y))| : by { congr, ring }\n        ... \u2264 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (\u03a8 x) (\u03a8 y)| = (\u03b5 * \u03b5\u207b\u00b9) * |dist x y - dist (\u03a8 x) (\u03a8 y)| :\n          by rw [mul_inv_cancel (ne_of_gt \u03b5pos), one_mul]\n        ... = \u03b5 * (|\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 \u03b5pos)), mul_assoc]\n        ... \u2264 \u03b5 * 1 : mul_le_mul_of_nonneg_left I (le_of_lt \u03b5pos)\n        ... = \u03b5 : mul_one _ } },\n  calc dist p q = GH_dist p.rep (q.rep) : dist_GH_dist p q\n    ... \u2264 \u03b5 + \u03b5/2 + \u03b5 : main\n    ... = \u03b4 : by { simp [\u03b5], 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 `\u03b5` the number of balls of radius `\u03b5` 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 : \u211d} {u : \u2115 \u2192 \u211d} {K : \u2115 \u2192 \u2115}\n  (ulim : tendsto u at_top (\ud835\udcdd 0))\n  (hdiam : \u2200 p \u2208 t, diam (univ : set (GH_space.rep p)) \u2264 C)\n  (hcov : \u2200 p \u2208 t, \u2200 n:\u2115, \u2203 s : set (GH_space.rep p),\n    cardinal.mk s \u2264 K n \u2227 univ \u2286 \u22c3x\u2208s, ball x (u n)) :\n  totally_bounded t :=\nbegin\n  /- Let `\u03b4>0`, and `\u03b5 = \u03b4/5`. For each `p`, we construct a finite subset `s p` of `p`, which\n  is `\u03b5`-dense and has cardinality at most `K n`. Encoding the mutual distances of points in `s p`,\n  up to `\u03b5`, we will get a map `F` associating to `p` finitely many data, and making it possible to\n  reconstruct `p` up to `\u03b5`. This is enough to prove total boundedness. -/\n  refine metric.totally_bounded_of_finite_discretization (\u03bb \u03b4 \u03b4pos, _),\n  let \u03b5 := (1/5) * \u03b4,\n  have \u03b5pos : 0 < \u03b5 := mul_pos (by norm_num) \u03b4pos,\n  -- choose `n` for which `u n < \u03b5`\n  rcases metric.tendsto_at_top.1 ulim \u03b5 \u03b5pos with \u27e8n, hn\u27e9,\n  have u_le_\u03b5 : u n \u2264 \u03b5,\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 `\u03b5`-dense and has cardinal `\u2264 K n`\n  have : \u2200 p:GH_space, \u2203 s : set p.rep, \u2203 N \u2264 K n, \u2203 E : equiv s (fin N),\n    p \u2208 t \u2192 univ \u2286 \u22c3x\u2208s, ball x (u n),\n  { assume p,\n    by_cases hp : p \u2209 t,\n    { have : nonempty (equiv (\u2205 : set p.rep) (fin 0)),\n      { rw \u2190 fintype.card_eq, simp },\n      use [\u2205, 0, bot_le, choice (this)] },\n    { rcases hcov _ (set.not_not_mem.1 hp) n with \u27e8s, \u27e8scard, scover\u27e9\u27e9,\n      rcases cardinal.lt_aleph_0.1 (lt_of_le_of_lt scard (cardinal.nat_lt_aleph_0 _)) with \u27e8N, hN\u27e9,\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 `\u03b5`, namely the (discretized) distances between elements of `s p`.\n  let M := \u230a\u03b5\u207b\u00b9 * max C 0\u230b\u208a,\n  let F : GH_space \u2192 (\u03a3k:fin ((K n).succ), (fin k \u2192 fin k \u2192 fin (M.succ))) :=\n    \u03bb p, \u27e8\u27e8N p, lt_of_le_of_lt (hN p) (nat.lt_succ_self _)\u27e9,\n         \u03bb a b, \u27e8min M \u230a\u03b5\u207b\u00b9 * dist ((E p).symm a) ((E p).symm b)\u230b\u208a,\n                ( min_le_left _ _).trans_lt (nat.lt_succ_self _) \u27e9 \u27e9,\n  refine \u27e8_, _, (\u03bb p, F p), _\u27e9, apply_instance,\n  -- It remains to show that if `F p = F q`, then `p` and `q` are `\u03b5`-close\n  rintros \u27e8p, pt\u27e9 \u27e8q, qt\u27e9 hpq,\n  have Npq : N p = N q := (fin.ext_iff _ _).1 (sigma.mk.inj_iff.1 hpq).1,\n  let \u03a8 : s p \u2192 s q := \u03bb x, (E q).symm (fin.cast Npq ((E p) x)),\n  let \u03a6 : s p \u2192 q.rep := \u03bb x, \u03a8 x,\n  have main : GH_dist p.rep (q.rep) \u2264 \u03b5 + \u03b5/2 + \u03b5,\n  { -- to prove the main inequality, argue that `s p` is `\u03b5`-dense in `p`, and `s q` is `\u03b5`-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 \u03a6  _ _ _,\n    show \u2200 x : p.rep, \u2203 (y : p.rep) (H : y \u2208 s p), dist x y \u2264 \u03b5,\n    { -- by construction, `s p` is `\u03b5`-dense\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s p), ball y (u n) := (hs p pt) (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      exact \u27e8y, ys, le_trans (le_of_lt hy) u_le_\u03b5\u27e9 },\n    show \u2200 x : q.rep, \u2203 (z : s p), dist x (\u03a6 z) \u2264 \u03b5,\n    { -- by construction, `s q` is `\u03b5`-dense, and it is the range of `\u03a6`\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s q), ball y (u n) := (hs q qt) (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      let i : \u2115 := E q \u27e8y, ys\u27e9,\n      let hi := ((E q) \u27e8y, ys\u27e9).2,\n      have ihi_eq : (\u27e8i, hi\u27e9 : fin (N q)) = (E q) \u27e8y, ys\u27e9, 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 \u27e8i, hip\u27e9,\n      use z,\n      have C1 : (E p) z = \u27e8i, hip\u27e9 := (E p).apply_symm_apply \u27e8i, hip\u27e9,\n      have C2 : fin.cast Npq \u27e8i, hip\u27e9 = \u27e8i, hi\u27e9 := rfl,\n      have C3 : (E q).symm \u27e8i, hi\u27e9 = \u27e8y, ys\u27e9,\n        by { rw ihi_eq, exact (E q).symm_apply_apply \u27e8y, ys\u27e9 },\n      have : \u03a6 z = y :=\n        by { simp only [\u03a6, \u03a8], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_trans (le_of_lt hy) u_le_\u03b5 },\n    show \u2200 x y : s p, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `\u03a6 x` and `\u03a6 y` (two points of `s q`) is encoded in `F q`, all this up to `\u03b5`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (\u03a6 x) (\u03a6 y) = dist (\u03a8 x) (\u03a8 y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `\u03a6 x` in `fin (N p) = fin (N q)`\n      let i : \u2115 := 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) (\u03a8 x)), by { simp [\u03a8] },\n      -- introduce `j`, that codes both `y` and `\u03a6 y` in `fin (N p) = fin (N q)`\n      let j : \u2115 := 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) (\u03a8 y)), by { simp [\u03a8] },\n      -- Express `dist x y` in terms of `F p`\n      have Ap : ((F p).2 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a := calc\n        ((F p).2 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = ((F p).2 ((E p) x) ((E p) y)).1 :\n          by { congr; apply (fin.ext_iff _ _).2; refl }\n        ... = min M \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a :\n          by simp only [F, (E p).symm_apply_apply]\n        ... = \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a :\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 \u03b5pos).le),\n          change dist (x : p.rep) y \u2264 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 (\u03a6 x) (\u03a6 y)` in terms of `F q`\n      have Aq : ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).1 = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a := calc\n        ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).1 = ((F q).2 ((E q) (\u03a8 x)) ((E q) (\u03a8 y))).1 :\n          by { congr; apply (fin.ext_iff _ _).2; [exact i', exact j'] }\n        ... = min M \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a :\n          by simp only [F, (E q).symm_apply_apply]\n        ... = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a :\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 \u03b5pos).le),\n          change dist (\u03a8 x : q.rep) (\u03a8 y) \u2264 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 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).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 \u22a2,\n        subst hpq,\n        intros,\n        refl },\n      have : \u230a\u03b5\u207b\u00b9 * dist x y\u230b = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b,\n      { rw [Ap, Aq] at this,\n        have D : 0 \u2264 \u230a\u03b5\u207b\u00b9 * dist x y\u230b :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 \u03b5pos)) dist_nonneg),\n        have D' : 0 \u2264 \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 \u03b5pos)) dist_nonneg),\n        rw [\u2190 int.to_nat_of_nonneg D, \u2190 int.to_nat_of_nonneg D', int.floor_to_nat,int.floor_to_nat,\n          this] },\n      -- deduce that the distances coincide up to `\u03b5`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)| =\n          |\u03b5\u207b\u00b9 * (dist x y - dist (\u03a8 x) (\u03a8 y))| : (abs_mul _ _).symm\n        ... = |(\u03b5\u207b\u00b9 * dist x y) - (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y))| : by { congr, ring }\n        ... \u2264 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (\u03a8 x) (\u03a8 y)| = (\u03b5 * \u03b5\u207b\u00b9) * |dist x y - dist (\u03a8 x) (\u03a8 y)| :\n          by rw [mul_inv_cancel (ne_of_gt \u03b5pos), one_mul]\n        ... = \u03b5 * (|\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 \u03b5pos)), mul_assoc]\n        ... \u2264 \u03b5 * 1 : mul_le_mul_of_nonneg_left I (le_of_lt \u03b5pos)\n        ... = \u03b5 : mul_one _ } },\n  calc dist p q = GH_dist p.rep (q.rep) : dist_GH_dist p q\n    ... \u2264 \u03b5 + \u03b5/2 + \u03b5 : main\n    ... = \u03b4/2 : by { simp [\u03b5], ring }\n    ... < \u03b4 : half_lt_self \u03b4pos\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 : \u2115 \u2192 Type) [\u2200 n, metric_space (X n)] [\u2200 n, compact_space (X n)] [\u2200 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 \u2192 space)\n(isom   : isometry embed)\n\ninstance (A : Type) [metric_space A] : inhabited (aux_gluing_struct A) :=\n\u27e8{ space := A,\n  metric := by apply_instance,\n  embed := id,\n  isom := \u03bb x y, rfl }\u27e9\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 : \u2115) : aux_gluing_struct (X n) := nat.rec_on n\n  { space  := X 0,\n    metric := by apply_instance,\n    embed  := id,\n    isom   := \u03bb x y, rfl }\n(\u03bb 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              \u2218 (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 : \u2200 (n : \u2115), 0 < ((1:\u211d) / 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 (\u03bb n, (1/2)^n) this (\u03bb u hu, _),\n  -- `X n` is a representative of `u n`\n  let X := \u03bb 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 : \u2200 n, metric_space (Y n).space := \u03bb n, (Y n).metric,\n  have E : \u2200 n : \u2115,\n    glue_space (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)) = (Y n.succ).space :=\n    \u03bb n, by { simp [Y, aux_gluing], refl },\n  let c := \u03bb n, cast (E n),\n  have ic : \u2200 n, isometry (c n) := \u03bb n x y, rfl,\n  -- there is a canonical embedding of `Y n` in `Y (n+1)`, by construction\n  let f : \u03a0n, (Y n).space \u2192 (Y n.succ).space :=\n    \u03bb n, (c n) \u2218 (to_glue_l (aux_gluing X n).isom (isometry_optimal_GH_injl (X n) (X n.succ))),\n  have I : \u2200 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 \u03a6 := to_inductive_limit I,\n  let coeZ := (coe : Z0 \u2192 Z),\n  -- let `X2 n` be the image of `X n` in the space `Z`\n  let X2 := \u03bb n, range (coeZ \u2218 (\u03a6 n) \u2218 (Y n).embed),\n  have isom : \u2200 n, isometry (coeZ \u2218 (\u03a6 n) \u2218 (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 : \u2200 n, Hausdorff_dist (X2 n) (X2 n.succ) < (1/2)^n,\n  { assume n,\n    have X2n : X2 n = range ((coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n      \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      \u2218 (optimal_GH_injl (X n) (X n.succ))),\n    { change X2 n = range (coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n        \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)))\n        \u2218 (optimal_GH_injl (X n) (X n.succ))),\n      simp only [X2, \u03a6],\n      rw [\u2190 to_inductive_limit_commute I],\n      simp only [f],\n      rw \u2190 to_glue_commute },\n    rw range_comp at X2n,\n    have X2nsucc : X2 n.succ = range ((coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n      \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      \u2218 (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, \u2190 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 : \u2115 \u2192 nonempty_compacts Z := \u03bb n,\n    \u27e8\u27e8X2 n, is_compact_range (isom n).continuous\u27e9, range_nonempty _\u27e9,\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) (\u03bb 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 \u27e8L, hL\u27e9,\n  -- the images of `X3 n` in the Gromov-Hausdorff space converge to the image of `L`\n  have M : tendsto (\u03bb n, (X3 n).to_GH_space) at_top (\ud835\udcdd 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 : \u2200 n, (X3 n).to_GH_space = u n,\n  { assume n,\n    rw [nonempty_compacts.to_GH_space, \u2190 (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 \u27e8L.to_GH_space, by simpa [this] using M\u27e9\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 \u27f6 Y) \u2192 (F.obj X \u27f6 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 \u2964 D) : Prop :=\n(map_zero' : \u03a0 {X Y : C}, F.map (0 : X \u27f6 Y) = 0 . obviously)\n(map_add' : \u03a0 {X Y : C} {f g : X \u27f6 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 \u2964 D) [functor.additive F]\n\n@[simp]\nlemma map_zero {X Y : C} : F.map (0 : X \u27f6 Y) = 0 :=\nfunctor.additive.map_zero'\n\n@[simp]\n\n\ninstance : additive (\ud835\udfed C) :=\n{}\n\ninstance {E : Type*} [category E] [preadditive E] (G : D \u2964 E) [functor.additive G] :\n  additive (F \u22d9 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 \u27f6 Y) \u2192+ (F.obj X \u27f6 F.obj Y) :=\n{ to_fun := \u03bb f, F.map f,\n  map_zero' := F.map_zero,\n  map_add' := \u03bb _ _, F.map_add }\n\nlemma coe_map_add_hom {X Y : C} : \u21d1(F.map_add_hom : (X \u27f6 Y) \u2192+ _) = @map C _ D _ F X Y := rfl\n\n@[simp]\nlemma map_neg {X Y : C} {f : X \u27f6 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 \u27f6 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} {\u03b1 : Type*} (f : \u03b1 \u2192 (X \u27f6 Y)) (s : finset \u03b1) :\n  F.map (\u2211 a in s, f a) = \u2211 a in s, F.map (f a) :=\n(F.map_add_hom : (X \u27f6 Y) \u2192+ _).map_sum f s\n\nend\n\nsection induced_category\nvariables {C : Type*} {D : Type*} [category D] [preadditive D] (F : C \u2192 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\u2081 u\u2082\n\nvariables {C : Type u\u2081} {D : Type u\u2082} [category.{v} C] [category.{v} D]\n  [preadditive C] [preadditive D] (F : C \u2964 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 \u2192 C) [has_biproduct f] :\n  has_biproduct (\u03bb j, F.obj (f j)) :=\nhas_biproduct_of_total\n{ X := F.obj (\u2a01 f),\n  \u03c0 := \u03bb j, F.map (biproduct.\u03c0 f j),\n  \u03b9 := \u03bb j, F.map (biproduct.\u03b9 f j),\n  \u03b9_\u03c0 := \u03bb j j', by { simp only [\u2190F.map_comp], split_ifs, { subst h, simp, }, { simp [h], }, }, }\n(by simp_rw [\u2190F.map_comp, \u2190F.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 \u2192 C) [has_biproduct f] :\n  F.obj (\u2a01 f) \u2245 \u2a01 (\u03bb j, F.obj (f j)) :=\n{ hom := biproduct.lift (\u03bb j, F.map (biproduct.\u03c0 f j)),\n  inv := biproduct.desc (\u03bb j, F.map (biproduct.\u03b9 f j)),\n  hom_inv_id' :=\n  by simp only [biproduct.lift_desc, \u2190F.map_comp, \u2190F.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_\u03c0, biproduct.\u03b9_desc_assoc,\n      \u2190F.map_comp, biproduct.\u03b9_\u03c0, 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 \u224c D) [e.functor.additive] : e.inverse.additive :=\n{ map_zero' := \u03bb X Y, by { apply e.functor.map_injective, simp, },\n  map_add' := \u03bb 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 {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected refl (x) : r x x\n\nprotected abbrev Reflexive.rfl {\u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [Reflexive r] {x : \u03b1} := Reflexive.refl (r:=r) x\n\ntheorem Reflexive.of_eq {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Reflexive r] : {x y : \u03b1} \u2192 x = y \u2192 r x y\n| _, _, rfl => Reflexive.rfl\n\ninstance (\u03b1) [Setoid \u03b1] : Reflexive (\u03b1:=\u03b1) (.\u2248.) := \u27e8Setoid.refl\u27e9\ninstance (\u03b1) [Setoid \u03b1] : Reflexive (\u03b1:=\u03b1) Setoid.r := \u27e8Setoid.refl\u27e9\ninstance (\u03b1) : Reflexive (\u03b1:=\u03b1) (.\u2245.) := \u27e8HEq.refl\u27e9\ninstance (\u03b1) : Reflexive (\u03b1:=\u03b1) (.=.) := \u27e8Eq.refl\u27e9\ninstance : Reflexive (.\u2192.) := \u27e8@id\u27e9\ninstance : Reflexive (.\u2194.) := \u27e8Iff.refl\u27e9\n\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Reflexive r] : Reflexive (TC r) where\n  refl x := TC.base _ _ (Reflexive.refl x)\n\nend Reflexive\n\nsection Irreflexive\n\nabbrev Irreflexive {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop := Reflexive (\u00ac r . .)\n\nprotected abbrev Irreflexive.irrefl {\u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [Irreflexive r] (x : \u03b1) := Reflexive.refl (r:=(\u00ac r . .)) x\n\nprotected abbrev Irreflexive.irrfl {\u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [Irreflexive r] {x : \u03b1} := Irreflexive.irrefl (r:=r) x\n\ntheorem Irreflexive.ne_of {\u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [Irreflexive r] : {x y : \u03b1} \u2192 r x y \u2192 x \u2260 y\n| _, _, h, rfl => Irreflexive.irrfl h\n\ninstance (\u03b1) : Irreflexive (\u03b1:=\u03b1) (.\u2260.) := \u27e8\u03bb x h => h (Eq.refl x)\u27e9\n\nend Irreflexive\n\nsection Symmetric\n\nclass HSymmetric (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (s : \u03b2 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected symm {x y} : r x y \u2192 s y x\n\nclass Symmetric (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected symm {x y} : r y x \u2192 r x y\n\n@[default_instance]\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Symmetric r] : HSymmetric r r := \u27e8Symmetric.symm\u27e9\n\nabbrev Asymmetric (r : \u03b1 \u2192 \u03b1 \u2192 Prop) := HSymmetric r (\u00ac r . .)\n\nprotected def Asymmetric.asymm {\u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [Asymmetric r] {x y : \u03b1} : r x y \u2192 \u00ac r y x := HSymmetric.symm (r:=r) (s:=(\u00ac r . .))\n\ninstance (\u03b1) : Symmetric (\u03b1:=\u03b1) (.=.) := \u27e8Eq.symm\u27e9\ninstance (\u03b1) : Symmetric (\u03b1:=\u03b1) (.\u2260.) := \u27e8Ne.symm\u27e9\ninstance (\u03b1) [Setoid \u03b1] : Symmetric (\u03b1:=\u03b1) (.\u2248.) := \u27e8Setoid.symm\u27e9\ninstance (\u03b1) [Setoid \u03b1] : Symmetric (\u03b1:=\u03b1) Setoid.r := \u27e8Setoid.symm\u27e9\ninstance (\u03b1 \u03b2) : HSymmetric (\u03b1:=\u03b1) (\u03b2:=\u03b2) (.\u2245.) (.\u2245.) := \u27e8HEq.symm\u27e9\ninstance (\u03b1) [LE \u03b1] : HSymmetric (\u03b1:=\u03b1) (.\u2264.) (.\u2265.) := \u27e8id\u27e9\ninstance (\u03b1) [LE \u03b1] : HSymmetric (\u03b1:=\u03b1) (.\u2265.) (.\u2264.) := \u27e8id\u27e9\ninstance (\u03b1) [LT \u03b1] : HSymmetric (\u03b1:=\u03b1) (.<.) (.>.) := \u27e8id\u27e9\ninstance (\u03b1) [LT \u03b1] : HSymmetric (\u03b1:=\u03b1) (.>.) (.<.) := \u27e8id\u27e9\ninstance : Symmetric (.\u2194.) := \u27e8Iff.symm\u27e9\n\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 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 {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : outParam (\u03b1 \u2192 \u03b1 \u2192 Prop)) : Prop where\n  protected antisymm {x y} : r x y \u2192 r y x \u2192 s x y\n\nclass Antisymmetric {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected antisymm {x y} : r x y \u2192 r y x \u2192 x = y\n\n@[default_instance]\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Antisymmetric r] : HAntisymmetric r Eq where\n  antisymm := Antisymmetric.antisymm\n\ninstance : HAntisymmetric (.\u2192.) (.\u2194.) := \u27e8Iff.intro\u27e9\n\nabbrev WeaklyConnex {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) := Antisymmetric (\u03bb x y => \u00ac r y x)\n\nabbrev WeaklyConnex.connex {\u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [WeaklyConnex r] {x y} : \u00ac r y x \u2192 \u00ac r x y \u2192 x = y :=\n  Antisymmetric.antisymm (r := \u03bb x y => \u00ac r y x)\n\nend Antisymmetric\n\nsection Transitive\n\nclass HTransitive {\u03b1 \u03b2 \u03b3} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (s : \u03b2 \u2192 \u03b3 \u2192 Prop) (t : outParam (\u03b1 \u2192 \u03b3 \u2192 Prop)) : Prop where\n  protected trans {x y z} : (left : r x y) \u2192 (right : s y z) \u2192 t x z\n\ninstance {\u03b1 \u03b2 \u03b3} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (s : \u03b2 \u2192 \u03b3 \u2192 Prop) (t : \u03b1 \u2192 \u03b3 \u2192 Prop) [HTransitive r s t] : Trans r s t where\n  trans := HTransitive.trans\n\nclass Transitive {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected trans {x y z} : (left : r x y) \u2192 (right : r y z) \u2192 r x z\n\n@[default_instance]\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Transitive r] : HTransitive r r r := \u27e8Transitive.trans\u27e9\n\ninstance (\u03b1) : Transitive (\u03b1:=\u03b1) (.=.) := \u27e8Eq.trans\u27e9\ninstance (\u03b1 \u03b2 \u03b3) : HTransitive (\u03b1:=\u03b1) (\u03b2:=\u03b2) (\u03b3:=\u03b3) (.\u2245.) (.\u2245.) (.\u2245.) := \u27e8HEq.trans\u27e9\ninstance {\u03b1 \u03b2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) : HTransitive (.=.) r r := \u27e8\u03bb he hr => he \u25b8 hr\u27e9\ninstance {\u03b1 \u03b2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) : HTransitive r (.=.) r := \u27e8\u03bb hr he => he \u25b8 hr\u27e9\ninstance (\u03b1) [Setoid \u03b1] : Transitive (\u03b1:=\u03b1) (.\u2248.) := \u27e8Setoid.trans\u27e9\ninstance (\u03b1) [Setoid \u03b1] : Transitive (\u03b1:=\u03b1) Setoid.r := \u27e8Setoid.trans\u27e9\ninstance : Transitive (.\u2192.) := \u27e8\u03bb h\u2081 h\u2082 h => h\u2082 (h\u2081 h)\u27e9\ninstance : Transitive (.\u2194.) := \u27e8Iff.trans\u27e9\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Transitive (TC r) := \u27e8TC.trans _ _ _\u27e9\n\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Irreflexive r] [Transitive r] : Asymmetric r := \u27e8fun hxy hyx => Irreflexive.irrfl (Transitive.trans hxy hyx)\u27e9\n\nend Transitive\n\nsection Euclidean\n\nclass HEuclidean {\u03b1 \u03b2 \u03b3} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (s : \u03b1 \u2192 \u03b3 \u2192 Prop) (t : outParam (\u03b2 \u2192 \u03b3 \u2192 Prop)) : Prop where\n  protected eucl {x y z} : (left : r x y) \u2192 (right : s x z) \u2192 t y z\n\nclass Euclidean {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected eucl {x y z} : (left : r x y) \u2192 (right : r x z) \u2192 r y z\n\n@[default_instance]\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Euclidean r] : HEuclidean r r r := \u27e8Euclidean.eucl\u27e9\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 {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Reflexive r] [Euclidean r] : Symmetric r where\n  symm hxy := Euclidean.eucl hxy Reflexive.rfl\n\ndef Euclidean.toTransitive {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 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 {\u03b1 \u03b2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (s : \u03b2 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected total (x y) : (r x y) \u2228 (s y x)\n\nclass Total {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected total (x y) : (r x y) \u2228 (r y x)\n\n@[default_instance]\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Total r] : HTotal r r := \u27e8Total.total\u27e9\n\nend Total\n\nsection Comparison\n\nclass HComparison {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected compare {x y} : s x y \u2192 (z : \u03b1) \u2192 r x z \u2228 r z y\n\nclass Comparison {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected compare {x y} : r x y \u2192 (z : \u03b1) \u2192 r x z \u2228 r z y\n\n@[default_instance]\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Comparison r] : HComparison r r := \u27e8Comparison.compare\u27e9\n\ndef Transitive.toComparison {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [ComplementedRel r] [Transitive r] : Comparison (\u03bb x y => \u00ac 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 {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Comparison r] : Transitive (\u03bb x y => \u00ac 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 {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected connex {x y} : s x y \u2192 r x y \u2228 r y x\n\nclass Connex {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop where\n  protected connex {x y} : x \u2260 y \u2192 r x y \u2228 r y x\n\n@[default_instance]\ninstance {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Connex r] : HConnex r (.\u2260.) := \u27e8Connex.connex\u27e9\n\ndef Connex.toAntisymmetric {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [StableEq \u03b1] [Connex r] : Antisymmetric (\u03bb x y => \u00ac 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 {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [WeaklyComplementedRel r] [Antisymmetric r] : Connex fun x y => \u00ac r y x where\n  connex := by\n    intro x y hne\n    rw [\u2190And.deMorgan]\n    intro \u27e8hyx, hxy\u27e9\n    absurd hne\n    exact Antisymmetric.antisymm hxy hyx\n\ndef Connex.toComparison {\u03b1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [ComplementedEq \u03b1] [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 \u2192 MCType\n\nopen MCType\n\ninductive Reg : MCType \u2192 Type\n| rax (n : Nat) : Reg (bv n)\n\ninductive Expr : MCType \u2192 Type\n| r : \u2200{tp:MCType}, Reg tp \u2192 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) := \u27e8Expr.r\u27e9\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 \u2243\u2090[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 \u2227 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 (\u21a5(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] {\u03b1 : E} (h\u03b1 : is_integral F \u03b1)\n    (h_sep : polynomial.separable (minpoly F \u03b1))\n    (h_splits :\n      polynomial.splits\n        (algebra_map F \u21a5(intermediate_field.adjoin F (intermediate_field.insert.insert \u2205 \u03b1)))\n        (minpoly F \u03b1)) :\n    fintype.card\n          (alg_equiv F \u21a5(intermediate_field.adjoin F (intermediate_field.insert.insert \u2205 \u03b1))\n            \u21a5(intermediate_field.adjoin F (intermediate_field.insert.insert \u2205 \u03b1))) =\n        finite_dimensional.findim F\n          \u21a5(intermediate_field.adjoin F (intermediate_field.insert.insert \u2205 \u03b1)) :=\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 (\u21a5K) E :=\n  is_galois.tower_top_of_is_galois F (\u21a5K) 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 (\u21a5\u22a5) E \u2194 is_galois F E :=\n  { mp := fun (h : is_galois (\u21a5\u22a5) E) => is_galois.tower_top_of_is_galois (\u21a5\u22a5) F E,\n    mpr := fun (h : is_galois F E) => is_galois.tower_top_intermediate_field \u22a5 }\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 \u2191(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 \u2194 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 \u21a5\u22a4 \u2194 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 \u21a5\u22a5 :=\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 (\u21a5H) 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 (\u21a5H) 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 (\u21a5(fixed_field H)) E = fintype.card \u21a5H :=\n  fixed_points.findim_eq_card (\u21a5H) 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 (\u03d5 : alg_equiv F E E) => \u2200 (x : \u21a5K), coe_fn \u03d5 \u2191x = \u2191x) 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 \u2264 fixed_field H \u2194 H \u2264 fixing_subgroup K :=\n  sorry\n\n/-- The fixing_subgroup of `K : intermediate_field F E` is isomorphic to `E \u2243\u2090[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) : \u21a5(fixing_subgroup K) \u2243* alg_equiv (\u21a5K) E E :=\n  mul_equiv.mk\n    (fun (\u03d5 : \u21a5(fixing_subgroup K)) =>\n      alg_equiv.of_bijective (alg_hom.mk \u21d1\u03d5 sorry sorry sorry sorry sorry) sorry)\n    (fun (\u03d5 : alg_equiv (\u21a5K) E E) =>\n      { val := alg_equiv.of_bijective (alg_hom.mk \u21d1\u03d5 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 \u21a5K \u21a5(fixed_field (fixing_subgroup K)) :=\n  algebra.mk\n    (ring_hom.mk (fun (x : \u21a5K) => { val := \u2191x, 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 (\u21a5K) (\u21a5(fixed_field (fixing_subgroup K))) E :=\n  is_scalar_tower.mk\n    fun (_x : \u21a5K) (_x_1 : \u21a5(fixed_field (fixing_subgroup K))) (_x_2 : E) =>\n      mul_assoc (\u2191_x) (\u2191_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 \u21a5(intermediate_field.fixing_subgroup K) = finite_dimensional.findim (\u21a5K) 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 \u2243o 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 (\u21d1order_dual.to_dual \u2218 intermediate_field.fixing_subgroup)\n        (intermediate_field.fixed_field \u2218 \u21d1order_dual.to_dual) :=\n  galois_insertion.mk\n    (fun (K : intermediate_field F E)\n      (_x :\n      function.comp intermediate_field.fixed_field (\u21d1order_dual.to_dual)\n          (function.comp (\u21d1order_dual.to_dual) intermediate_field.fixing_subgroup K) \u2264\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 (\u21d1order_dual.to_dual \u2218 intermediate_field.fixing_subgroup)\n        (intermediate_field.fixed_field \u2218 \u21d1order_dual.to_dual) :=\n  galois_coinsertion.mk\n    (fun (H : order_dual (subgroup (alg_equiv F E E)))\n      (_x :\n      H \u2264\n        function.comp (\u21d1order_dual.to_dual) intermediate_field.fixing_subgroup\n          (function.comp intermediate_field.fixed_field (\u21d1order_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    \u2203 (p : polynomial F), polynomial.separable p \u2227 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 \u22a4 = \u22a5) : 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 (\u21a5\u22a5) E)) (Eq.symm h)))\n      (is_galois.of_fixed_field E \u21a5\u22a4))\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 \u2208 polynomial.roots (polynomial.map (algebra_map F E) p)) :\n    fintype.card\n          (alg_hom F (\u21a5\u2191(intermediate_field.adjoin (\u21a5K) (intermediate_field.insert.insert \u2205 x)))\n            E) =\n        fintype.card (alg_hom F (\u21a5K) E) *\n          finite_dimensional.findim \u21a5K\n            \u21a5(intermediate_field.adjoin (\u21a5K) (intermediate_field.insert.insert \u2205 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 \u22a4 = \u22a5,\n          fintype.card (alg_equiv F E E) = finite_dimensional.findim F E,\n          \u2203 (p : polynomial F), polynomial.separable p \u2227 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 : \u2115} {\u03b1 : fin n \u2192 Type u}\n\ninstance [\u2200 i, inhabited (\u03b1 i)] : inhabited (d_array n \u03b1) :=\n\u27e8\u27e8\u03bb _, default\u27e9\u27e9\n\nend d_array\n\nnamespace array\n\ninstance {n \u03b1} [inhabited \u03b1] : inhabited (array n \u03b1) :=\nd_array.inhabited\n\ntheorem to_list_of_heq {n\u2081 n\u2082 \u03b1} {a\u2081 : array n\u2081 \u03b1} {a\u2082 : array n\u2082 \u03b1}\n  (hn : n\u2081 = n\u2082) (ha : a\u2081 == a\u2082) : a\u2081.to_list = a\u2082.to_list :=\nby congr; assumption\n\n/- rev_list -/\n\nsection rev_list\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem rev_list_reverse_aux : \u2200 i (h : i \u2264 n) (t : list \u03b1),\n  (a.iterate_aux (\u03bb _, (::)) i h []).reverse_core t = a.rev_iterate_aux (\u03bb _, (::)) 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 [\u2190rev_list_reverse, list.reverse_reverse]\n\nend rev_list\n\n/- mem -/\n\nsection mem\nvariables {n : \u2115} {\u03b1 : Type u} {v : \u03b1} {a : array n \u03b1}\n\ntheorem mem.def : v \u2208 a \u2194 \u2203 i, a.read i = v :=\niff.rfl\n\ntheorem mem_rev_list_aux : \u2200 {i} (h : i \u2264 n),\n  (\u2203 (j : fin n), (j : \u2115) < i \u2227 read a j = v) \u2194 v \u2208 a.iterate_aux (\u03bb _, (::)) i h []\n| 0     _ := \u27e8\u03bb \u27e8i, n, _\u27e9, absurd n i.val.not_lt_zero, false.elim\u27e9\n| (i+1) h := let IH := mem_rev_list_aux (le_of_lt h) in\n  \u27e8\u03bb \u27e8j, ji1, e\u27e9, or.elim (lt_or_eq_of_le $ nat.le_of_succ_le_succ ji1)\n    (\u03bb ji, list.mem_cons_of_mem _ $ IH.1 \u27e8j, ji, e\u27e9)\n    (\u03bb je, by simp [d_array.iterate_aux]; apply or.inl; unfold read at e;\n          have H : j = \u27e8i, h\u27e9 := fin.eq_of_veq je; rwa [\u2190H, e]),\n  \u03bb m, begin\n    simp [d_array.iterate_aux, list.mem] at m,\n    cases m with e m',\n    exact \u27e8\u27e8i, h\u27e9, nat.lt_succ_self _, eq.symm e\u27e9,\n    exact let \u27e8j, ji, e\u27e9 := IH.2 m' in\n    \u27e8j, nat.le_succ_of_le ji, e\u27e9\n  end\u27e9\n\n@[simp] theorem mem_rev_list : v \u2208 a.rev_list \u2194 v \u2208 a :=\niff.symm $ iff.trans\n  (exists_congr $ \u03bb j, iff.symm $\n    show j.1 < n \u2227 read a j = v \u2194 read a j = v,\n    from and_iff_right j.2)\n  (mem_rev_list_aux _)\n\n@[simp] theorem mem_to_list : v \u2208 a.to_list \u2194 v \u2208 a :=\nby rw \u2190rev_list_reverse; exact list.mem_reverse.trans mem_rev_list\n\nend mem\n\n/- foldr -/\n\nsection foldr\nvariables {n : \u2115} {\u03b1 : Type u} {\u03b2 : Type w} {b : \u03b2} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem rev_list_foldr_aux : \u2200 {i} (h : i \u2264 n),\n  (d_array.iterate_aux a (\u03bb _, (::)) i h []).foldr f b = d_array.iterate_aux a (\u03bb _, f) i h b\n| 0     h := rfl\n| (j+1) h := congr_arg (f (read a \u27e8j, h\u27e9)) (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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type w} {b : \u03b2} {f : \u03b2 \u2192 \u03b1 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem to_list_foldl : a.to_list.foldl f b = a.foldl b (function.swap f) :=\nby rw [\u2190rev_list_reverse, list.foldl_reverse, rev_list_foldr]\n\nend foldl\n\n/- length -/\n\nsection length\nvariables {n : \u2115} {\u03b1 : Type u}\n\ntheorem rev_list_length_aux (a : array n \u03b1) (i h) :\n  (a.iterate_aux (\u03bb _, (::)) i h []).length = i :=\nby induction i; simp [*, d_array.iterate_aux]\n\n@[simp] theorem rev_list_length (a : array n \u03b1) : a.rev_list.length = n :=\nrev_list_length_aux a _ _\n\n@[simp] theorem to_list_length (a : array n \u03b1) : a.to_list.length = n :=\nby rw[\u2190rev_list_reverse, list.length_reverse, rev_list_length]\n\nend length\n\n/- nth -/\n\nsection nth\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem to_list_nth_le_aux (i : \u2115) (ih : i < n) : \u2200 j {jh t h'},\n  (\u2200 k tl, j + k = i \u2192 list.nth_le t k tl = a.read \u27e8i, ih\u27e9) \u2192\n  (a.rev_iterate_aux (\u03bb _, (::)) j jh t).nth_le i h' = a.read \u27e8i, ih\u27e9\n| 0     _  _ _  al := al i _ $ zero_add _\n| (j+1) jh t h' al := to_list_nth_le_aux j $ \u03bb k tl hjk,\n  show list.nth_le (a.read \u27e8j, jh\u27e9 :: t) k tl = a.read \u27e8i, ih\u27e9, 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 : \u2115) (h h') : list.nth_le a.to_list i h' = a.read \u27e8i, h\u27e9 :=\nto_list_nth_le_aux _ _ _ (\u03bb k tl, absurd tl k.not_lt_zero)\n\n@[simp] theorem to_list_nth_le' (a : array n \u03b1) (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 \u2194 \u2203 h, a.read \u27e8i, h\u27e9 = 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 \u27e8ll \u25b8 h, (to_list_nth_le _ _ _).symm\u27e9 },\n  { exact \u27e8ll.symm \u25b8 h, to_list_nth_le _ _ _\u27e9 }\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) $ \u03bb j h\u2081 h\u2082, begin\n  have h\u2083 : j < n, {simpa using h\u2081},\n  rw [to_list_nth_le _ h\u2083],\n  refine let \u27e8_, e\u27e9 := list.nth_eq_some.1 _ in e.symm,\n  by_cases ij : (i : \u2115) = j,\n  { subst j, rw [show (\u27e8(i : \u2115), h\u2083\u27e9 : fin _) = i, from fin.eq_of_veq rfl,\n      array.read_write, list.nth_update_nth_of_lt],\n    simp [h\u2083] },\n  { rw [list.nth_update_nth_ne _ _ ij, a.read_write_of_ne,\n        to_list_nth.2 \u27e8h\u2083, rfl\u27e9],\n    exact fin.ne_of_vne ij }\nend\n\nend nth\n\n/- enum -/\n\nsection enum\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem mem_to_list_enum {i v} : (i, v) \u2208 a.to_list.enum \u2194 \u2203 h, a.read \u27e8i, h\u27e9 = 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 : \u2115} {\u03b1 : Type u}\n\n@[simp] theorem to_list_to_array (a : array n \u03b1) : a.to_list.to_array == a :=\nheq_of_heq_of_eq\n  (@@eq.drec_on (\u03bb m (e : a.to_list.length = m), (d_array.mk (\u03bb v, a.to_list.nth_le v.1 v.2)) ==\n    (@d_array.mk m (\u03bb _, \u03b1) $ \u03bb v, a.to_list.nth_le v.1 $ e.symm \u25b8 v.2)) a.to_list_length heq.rfl) $\n  d_array.ext $ \u03bb \u27e8i, h\u27e9, to_list_nth_le i h _\n\n@[simp] theorem to_array_to_list (l : list \u03b1) : l.to_array.to_list = l :=\nlist.ext_le (to_list_length _) $ \u03bb n h1 h2, to_list_nth_le _ h2 _\n\nend to_array\n\n/- push_back -/\n\nsection push_back\nvariables {n : \u2115} {\u03b1 : Type u} {v : \u03b1} {a : array n \u03b1}\n\nlemma push_back_rev_list_aux : \u2200 i h h',\n  d_array.iterate_aux (a.push_back v) (\u03bb _, (::)) i h [] = d_array.iterate_aux a (\u03bb _, (::)) i h' []\n| 0 h h' := rfl\n| (i+1) h h' := begin\n  simp [d_array.iterate_aux],\n  refine \u27e8_, push_back_rev_list_aux _ _ _\u27e9,\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 [\u2190rev_list_reverse, \u2190rev_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 : \u00ac 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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type v} {i : fin n} {f : fin n \u2192 \u03b1 \u2192 \u03b2} {a : array n \u03b1}\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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type v} {i : fin n} {f : \u03b1 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem read_map : (a.map f).read i = f (a.read i) :=\nread_foreach\n\nend map\n\n/- map\u2082 -/\n\nsection map\u2082\nvariables {n : \u2115} {\u03b1 : Type u} {i : fin n} {f : \u03b1 \u2192 \u03b1 \u2192 \u03b1} {a\u2081 a\u2082 : array n \u03b1}\n\n@[simp] theorem read_map\u2082 : (map\u2082 f a\u2081 a\u2082).read i = f (a\u2081.read i) (a\u2082.read i) :=\nread_foreach\n\nend map\u2082\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 : \u2115} (\u03b1 : fin n \u2192 Type*) : d_array n \u03b1 \u2243 (\u03a0 i, \u03b1 i) :=\n\u27e8d_array.read, d_array.mk, \u03bb \u27e8f\u27e9, rfl, \u03bb f, rfl\u27e9\n\n/-- The natural equivalence between length-`n` arrays and functions from `fin n`. -/\ndef array_equiv_fin (n : \u2115) (\u03b1 : Type*) : array n \u03b1 \u2243 (fin n \u2192 \u03b1) :=\nd_array_equiv_fin _\n\n/-- The natural equivalence between length-`n` vectors and length-`n` arrays. -/\ndef vector_equiv_array (\u03b1 : Type*) (n : \u2115) : vector \u03b1 n \u2243 array n \u03b1 :=\n(vector_equiv_fin _ _).trans (array_equiv_fin _ _).symm\n\nend equiv\n\nnamespace array\nopen function\nvariable {n : \u2115}\n\ninstance : traversable (array n) :=\n@equiv.traversable (flip vector n) _ (\u03bb \u03b1, equiv.vector_equiv_array \u03b1 n) _\n\ninstance : is_lawful_traversable (array n) :=\n@equiv.is_lawful_traversable (flip vector n) _ (\u03bb \u03b1, equiv.vector_equiv_array \u03b1 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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  \u27e8fun X => X.toDistLat\u27e9\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 (\u03b1 : Type _) [DistribLattice \u03b1] [BoundedOrder \u03b1] : BddDistLat :=\n  \u27e8\u27e8\u03b1\u27e9\u27e9\n#align BddDistLat.of BddDistLat.of\n\n@[simp]\ntheorem coe_of (\u03b1 : Type _) [DistribLattice \u03b1] [BoundedOrder \u03b1] : \u21a5(of \u03b1) = \u03b1 :=\n  rfl\n#align BddDistLat.coe_of BddDistLat.coe_of\n\ninstance : Inhabited BddDistLat :=\n  \u27e8of PUnit\u27e9\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) : \u21a5X.toBddLat = \u21a5X :=\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\u2082 BddDistLat DistLat\n    where forget\u2082 :=\n    { obj := fun X => \u27e8X\u27e9\n      map := fun X Y => BoundedLatticeHom.toLatticeHom }\n#align BddDistLat.has_forget_to_DistLat BddDistLat.hasForgetToDistLat\n\ninstance hasForgetToBddLat : HasForget\u2082 BddDistLat BddLat :=\n  InducedCategory.hasForget\u2082 toBddLat\n#align BddDistLat.has_forget_to_BddLat BddDistLat.hasForgetToBddLat\n\ntheorem forget_bddLat_lat_eq_forget_distLat_lat :\n    forget\u2082 BddDistLat BddLat \u22d9 forget\u2082 BddLat Lat =\n      forget\u2082 BddDistLat DistLat \u22d9 forget\u2082 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 {\u03b1 \u03b2 : BddDistLat.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2\n    where\n  Hom := (e : BoundedLatticeHom \u03b1 \u03b2)\n  inv := (e.symm : BoundedLatticeHom \u03b2 \u03b1)\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 \u2964 BddDistLat where\n  obj X := of X\u1d52\u1d48\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 \u224c 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 \u22d9 forget\u2082 BddDistLat DistLat = forget\u2082 BddDistLat DistLat \u22d9 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 \u2192\u2097\u2045R\u2046 L'` for a morphism of Lie algebras,\n * `L \u2243\u2097\u2045R\u2046 L'` for an equivalence of Lie algebras,\n * `M \u2192\u2097\u2045R,L\u2046 N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`,\n * `M \u2243\u2097\u2045R,L\u2046 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\u2081 w\u2082\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  : \u2200 (x y z : L), \u2045x + y, z\u2046 = \u2045x, z\u2046 + \u2045y, z\u2046)\n(lie_add  : \u2200 (x y z : L), \u2045x, y + z\u2046 = \u2045x, y\u2046 + \u2045x, z\u2046)\n(lie_self : \u2200 (x : L), \u2045x, x\u2046 = 0)\n(leibniz_lie : \u2200 (x y z : L), \u2045x, \u2045y, z\u2046\u2046 = \u2045\u2045x, y\u2046, z\u2046 + \u2045y, \u2045x, z\u2046\u2046)\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 : \u2200 (t : R) (x y : L), \u2045x, t \u2022 y\u2046 = t \u2022 \u2045x, y\u2046)\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     : \u2200 (x y : L) (m : M), \u2045x + y, m\u2046 = \u2045x, m\u2046 + \u2045y, m\u2046)\n(lie_add     : \u2200 (x : L) (m n : M), \u2045x, m + n\u2046 = \u2045x, m\u2046 + \u2045x, n\u2046)\n(leibniz_lie : \u2200 (x y : L) (m : M), \u2045x, \u2045y, m\u2046\u2046 = \u2045\u2045x, y\u2046, m\u2046 + \u2045y, \u2045x, m\u2046\u2046)\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 : \u2200 (t : R) (x : L) (m : M), \u2045t \u2022 x, m\u2046 = t \u2022 \u2045x, m\u2046)\n(lie_smul : \u2200 (t : R) (x : L) (m : M), \u2045x, t \u2022 m\u2046 = t \u2022 \u2045x, m\u2046)\n\nsection basic_properties\n\nvariables {R : Type u} {L : Type v} {M : Type w} {N : Type w\u2081}\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 : \u2045x + y, m\u2046 = \u2045x, m\u2046 + \u2045y, m\u2046 := lie_ring_module.add_lie x y m\n\n@[simp] lemma lie_add : \u2045x, m + n\u2046 = \u2045x, m\u2046 + \u2045x, n\u2046 := lie_ring_module.lie_add x m n\n\n@[simp] lemma smul_lie : \u2045t \u2022 x, m\u2046 = t \u2022 \u2045x, m\u2046 := lie_module.smul_lie t x m\n\n@[simp] lemma lie_smul : \u2045x, t \u2022 m\u2046 = t \u2022 \u2045x, m\u2046 := lie_module.lie_smul t x m\n\nlemma leibniz_lie : \u2045x, \u2045y, m\u2046\u2046 = \u2045\u2045x, y\u2046, m\u2046 + \u2045y, \u2045x, m\u2046\u2046 := lie_ring_module.leibniz_lie x y m\n\n@[simp] lemma lie_zero : \u2045x, 0\u2046 = (0 : M) := (add_monoid_hom.mk' _ (lie_add x)).map_zero\n\n@[simp] lemma zero_lie : \u2045(0 : L), m\u2046 = 0 :=\n(add_monoid_hom.mk' (\u03bb (x : L), \u2045x, m\u2046) (\u03bb x y, add_lie x y m)).map_zero\n\n@[simp] lemma lie_self : \u2045x, x\u2046 = 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 : -\u2045y, x\u2046 = \u2045x, y\u2046 :=\nhave h : \u2045x + y, x\u2046 + \u2045x + y, y\u2046 = 0, { rw \u2190 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 := \u03bb t x m, by rw [\u2190lie_skew, \u2190lie_skew x m, lie_algebra.lie_smul, smul_neg],\n  lie_smul := by apply lie_algebra.lie_smul, }\n\n@[simp] lemma neg_lie : \u2045-x, m\u2046 = -\u2045x, m\u2046 :=\nby { rw [\u2190sub_eq_zero, sub_neg_eq_add, \u2190add_lie], simp, }\n\n@[simp] lemma lie_neg : \u2045x, -m\u2046 = -\u2045x, m\u2046 :=\nby { rw [\u2190sub_eq_zero, sub_neg_eq_add, \u2190lie_add], simp, }\n\n@[simp] lemma sub_lie : \u2045x - y, m\u2046 = \u2045x, m\u2046 - \u2045y, m\u2046 :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma lie_sub : \u2045x, m - n\u2046 = \u2045x, m\u2046 - \u2045x, n\u2046 :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma nsmul_lie (n : \u2115) : \u2045n \u2022 x, m\u2046 = n \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_nsmul \u27e8\u03bb (x : L), \u2045x, m\u2046, zero_lie m, \u03bb _ _, add_lie _ _ _\u27e9 _ _\n\n@[simp] lemma lie_nsmul (n : \u2115) : \u2045x, n \u2022 m\u2046 = n \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_nsmul \u27e8\u03bb (m : M), \u2045x, m\u2046, lie_zero x, \u03bb _ _, lie_add _ _ _\u27e9 _ _\n\n@[simp] lemma zsmul_lie (a : \u2124) : \u2045a \u2022 x, m\u2046 = a \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_zsmul \u27e8\u03bb (x : L), \u2045x, m\u2046, zero_lie m, \u03bb _ _, add_lie _ _ _\u27e9 _ _\n\n@[simp] lemma lie_zsmul (a : \u2124) : \u2045x, a \u2022 m\u2046 = a \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_zsmul \u27e8\u03bb (m : M), \u2045x, m\u2046, lie_zero x, \u03bb _ _, lie_add _ _ _\u27e9 _ _\n\n@[simp] lemma lie_lie : \u2045\u2045x, y\u2046, m\u2046 = \u2045x, \u2045y, m\u2046\u2046 - \u2045y, \u2045x, m\u2046\u2046 :=\nby rw [leibniz_lie, add_sub_cancel]\n\nlemma lie_jacobi : \u2045x, \u2045y, z\u2046\u2046 + \u2045y, \u2045z, x\u2046\u2046 + \u2045z, \u2045x, y\u2046\u2046 = 0 :=\nby { rw [\u2190 neg_neg \u2045x, y\u2046, lie_neg z, lie_skew y x, \u2190 lie_skew, lie_lie], abel, }\n\ninstance lie_ring.int_lie_algebra : lie_algebra \u2124 L :=\n{ lie_smul := \u03bb n x y, lie_zsmul x y n, }\n\ninstance : lie_ring_module L (M \u2192\u2097[R] N) :=\n{ bracket     := \u03bb x f,\n  { to_fun    := \u03bb m, \u2045x, f m\u2046 - f \u2045x, m\u2046,\n    map_add'  := \u03bb m n, by { simp only [lie_add, linear_map.map_add], abel, },\n    map_smul' := \u03bb t m, by simp only [smul_sub, linear_map.map_smul, lie_smul, ring_hom.id_apply] },\n  add_lie     := \u03bb 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     := \u03bb x f g, by\n    { ext n, simp only [linear_map.coe_mk, lie_add, linear_map.add_apply], abel, },\n  leibniz_lie := \u03bb 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 \u2192\u2097[R] N) (x : L) (m : M) :\n  \u2045x, f\u2046 m = \u2045x, f m\u2046 - f \u2045x, m\u2046 :=\nrfl\n\ninstance : lie_module R L (M \u2192\u2097[R] N) :=\n{ smul_lie := \u03bb 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 := \u03bb 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 \u2192\u2097[R] L' :=\n(map_lie' : \u2200 {x y : L}, to_fun \u2045x, y\u2046 = \u2045to_fun x, to_fun y\u2046)\n\nattribute [nolint doc_blame] lie_hom.to_linear_map\n\nnotation L ` \u2192\u2097\u2045`:25 R:25 `\u2046 `:0 L':0 := lie_hom R L L'\n\nnamespace lie_hom\n\nvariables {R : Type u} {L\u2081 : Type v} {L\u2082 : Type w} {L\u2083 : Type w\u2081}\nvariables [comm_ring R]\nvariables [lie_ring L\u2081] [lie_algebra R L\u2081]\nvariables [lie_ring L\u2082] [lie_algebra R L\u2082]\nvariables [lie_ring L\u2083] [lie_algebra R L\u2083]\n\ninstance : has_coe (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192\u2097[R] L\u2082) := \u27e8lie_hom.to_linear_map\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (\u03bb _, L\u2081 \u2192 L\u2082) := \u27e8\u03bb f, f.to_linear_map.to_fun\u27e9\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\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082 := h\n\ninitialize_simps_projections lie_hom (to_linear_map_to_fun \u2192 apply)\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : ((f : L\u2081 \u2192\u2097[R] L\u2082) : L\u2081 \u2192 L\u2082) = f :=\nrfl\n\n@[simp] lemma to_fun_eq_coe (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f.to_fun = \u21d1f := rfl\n\n@[simp] lemma map_smul (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (c : R) (x : L\u2081) : f (c \u2022 x) = c \u2022 f x :=\nlinear_map.map_smul (f : L\u2081 \u2192\u2097[R] L\u2082) c x\n\n@[simp] lemma map_add (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : L\u2081 \u2192\u2097[R] L\u2082) x y\n\n@[simp] lemma map_sub (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : L\u2081 \u2192\u2097[R] L\u2082) x y\n\n@[simp] lemma map_neg (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x : L\u2081) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : L\u2081 \u2192\u2097[R] L\u2082) x\n\n@[simp] lemma map_lie (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f \u2045x, y\u2046 = \u2045f x, f y\u2046 := lie_hom.map_lie' f\n\n@[simp] lemma map_zero (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f 0 = 0 := (f : L\u2081 \u2192\u2097[R] L\u2082).map_zero\n\n/-- The identity map is a morphism of Lie algebras. -/\ndef id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081 :=\n{ map_lie' := \u03bb x y, rfl,\n  .. (linear_map.id : L\u2081 \u2192\u2097[R] L\u2081) }\n\n@[simp] lemma coe_id : ((id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) : L\u2081 \u2192 L\u2081) = _root_.id := rfl\n\nlemma id_apply (x : L\u2081) : (id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) x = x := rfl\n\n/-- The constant 0 map is a Lie algebra morphism. -/\ninstance : has_zero (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e8{ map_lie' := by simp, ..(0 : L\u2081 \u2192\u2097[R] L\u2082)}\u27e9\n\n@[norm_cast, simp] lemma coe_zero : ((0 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = 0 := rfl\n\nlemma zero_apply (x : L\u2081) : (0 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) x = 0 := rfl\n\n/-- The identity map is a Lie algebra morphism. -/\ninstance : has_one (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) := \u27e8id\u27e9\n\n@[simp] lemma coe_one : ((1 : (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081)) : L\u2081 \u2192 L\u2081) = _root_.id := rfl\n\nlemma one_apply (x : L\u2081) : (1 : (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081)) x = x := rfl\n\ninstance : inhabited (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e80\u27e9\n\nlemma coe_injective : @function.injective (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192 L\u2082) coe_fn :=\nby rintro \u27e8\u27e8f, _\u27e9\u27e9 \u27e8\u27e8g, _\u27e9\u27e9 \u27e8h\u27e9; congr\n\n@[ext] lemma ext {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} (h : \u2200 x, f x = g x) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} : f = g \u2194 \u2200 x, f x = g x :=\n\u27e8by { rintro rfl x, refl }, ext\u27e9\n\nlemma congr_fun {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} (h : f = g) (x : L\u2081) : f x = g x := h \u25b8 rfl\n\n@[simp] lemma mk_coe (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h\u2081 h\u2082 h\u2083) :\n  (\u27e8\u27e8f, h\u2081, h\u2082\u27e9, h\u2083\u27e9 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : L\u2081 \u2192 L\u2082) (h\u2081 h\u2082 h\u2083) :\n  ((\u27e8\u27e8f, h\u2081, h\u2082\u27e9, h\u2083\u27e9 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = f := rfl\n\n/-- The composition of morphisms is a morphism. -/\ndef comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192\u2097\u2045R\u2046 L\u2083 :=\n{ map_lie' := \u03bb x y, by { change f (g \u2045x, y\u2046) = \u2045f (g x), f (g y)\u2046, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x : L\u2081) :\n  f.comp g x = f (g x) := rfl\n\n@[norm_cast, simp]\nlemma coe_comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) :\n  (f.comp g : L\u2081 \u2192 L\u2083) = f \u2218 g :=\nrfl\n\n@[norm_cast, simp]\nlemma coe_linear_map_comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) :\n  (f.comp g : L\u2081 \u2192\u2097[R] L\u2083) = (f : L\u2082 \u2192\u2097[R] L\u2083).comp (g : L\u2081 \u2192\u2097[R] L\u2082) :=\nrfl\n\n@[simp] lemma comp_id (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f.comp (id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) = f :=\nby { ext, refl, }\n\n@[simp] lemma id_comp (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : (id : L\u2082 \u2192\u2097\u2045R\u2046 L\u2082).comp f = f :=\nby { ext, refl, }\n\n/-- The inverse of a bijective morphism is a morphism. -/\ndef inverse (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (g : L\u2082 \u2192 L\u2081)\n  (h\u2081 : function.left_inverse g f) (h\u2082 : function.right_inverse g f) : L\u2082 \u2192\u2097\u2045R\u2046 L\u2081 :=\n{ map_lie' := \u03bb x y,\n  calc g \u2045x, y\u2046 = g \u2045f (g x), f (g y)\u2046 : by { conv_lhs { rw [\u2190h\u2082 x, \u2190h\u2082 y], }, }\n            ... = g (f \u2045g x, g y\u2046) : by rw map_lie\n            ... = \u2045g x, g y\u2046 : (h\u2081 _),\n  ..linear_map.inverse f.to_linear_map g h\u2081 h\u2082 }\n\nend lie_hom\n\nsection module_pull_back\n\nvariables {R : Type u} {L\u2081 : Type v} {L\u2082 : Type w} (M : Type w\u2081)\nvariables [comm_ring R]  [lie_ring L\u2081] [lie_algebra R L\u2081] [lie_ring L\u2082] [lie_algebra R L\u2082]\nvariables [add_comm_group M] [lie_ring_module L\u2082 M]\nvariables (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082)\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\u2081 M :=\n{ bracket     := \u03bb x m, \u2045f x, m\u2046,\n  lie_add     := \u03bb x, lie_add (f x),\n  add_lie     := \u03bb x y m, by simp only [lie_hom.map_add, add_lie],\n  leibniz_lie := \u03bb 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\u2081) (m : M) :\n  by haveI := lie_ring_module.comp_lie_hom M f; exact\n  \u2045x, m\u2046 = \u2045f x, m\u2046 :=\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\u2082 M] :\n  @lie_module R L\u2081 M _ _ _ _ _ (lie_ring_module.comp_lie_hom M f) :=\n{ smul_lie := \u03bb t x m, by simp only [smul_lie, lie_hom.map_smul],\n  lie_smul := \u03bb 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 \u2192\u2097\u2045R\u2046 L' :=\n(inv_fun   : L' \u2192 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 ` \u2243\u2097\u2045`:50 R `\u2046 ` L' := lie_equiv R L L'\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L\u2081 : Type v} {L\u2082 : Type w} {L\u2083 : Type w\u2081}\nvariables [comm_ring R] [lie_ring L\u2081] [lie_ring L\u2082] [lie_ring L\u2083]\nvariables [lie_algebra R L\u2081] [lie_algebra R L\u2082] [lie_algebra R L\u2083]\n\n/-- Consider an equivalence of Lie algebras as a linear equivalence. -/\ndef to_linear_equiv (f : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2243\u2097[R] L\u2082 := { ..f.to_lie_hom, ..f }\n\ninstance has_coe_to_lie_hom : has_coe (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e8to_lie_hom\u27e9\ninstance has_coe_to_linear_equiv : has_coe (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2243\u2097[R] L\u2082) := \u27e8to_linear_equiv\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (\u03bb _, L\u2081 \u2192 L\u2082) := \u27e8\u03bb e, e.to_lie_hom.to_fun\u27e9\n\n@[simp, norm_cast] lemma coe_to_lie_hom (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = e :=\nrfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) :\n  ((e : L\u2081 \u2243\u2097[R] L\u2082) : L\u2081 \u2192 L\u2082) = e := rfl\n\n@[simp] lemma to_linear_equiv_mk (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (g h\u2081 h\u2082) :\n  (mk f g h\u2081 h\u2082 : L\u2081 \u2243\u2097[R] L\u2082) = { inv_fun := g, left_inv := h\u2081, right_inv := h\u2082, .. f } := rfl\n\nlemma coe_linear_equiv_injective : injective (coe : (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) \u2192 (L\u2081 \u2243\u2097[R] L\u2082)) :=\nbegin\n  intros f\u2081 f\u2082 h, cases f\u2081, cases f\u2082, 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\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192 L\u2082) coe_fn :=\nlinear_equiv.coe_injective.comp coe_linear_equiv_injective\n\n@[ext] lemma ext {f g : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082} (h : \u2200 x, f x = g x) : f = g := coe_injective $ funext h\n\ninstance : has_one (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) :=\n\u27e8{ map_lie' := \u03bb x y, rfl,\n  ..(1 : L\u2081 \u2243\u2097[R] L\u2081)}\u27e9\n\n@[simp] lemma one_apply (x : L\u2081) : (1 : (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081)) x = x := rfl\n\ninstance : inhabited (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) := \u27e81\u27e9\n\n/-- Lie algebra equivalences are reflexive. -/\n@[refl]\ndef refl : L\u2081 \u2243\u2097\u2045R\u2046 L\u2081 := 1\n\n@[simp] lemma refl_apply (x : L\u2081) : (refl : L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) x = x := rfl\n\n/-- Lie algebra equivalences are symmetric. -/\n@[symm]\ndef symm (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : L\u2082 \u2243\u2097\u2045R\u2046 L\u2081 :=\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\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.symm.symm = e :=\nby { ext, refl }\n\n@[simp] lemma apply_symm_apply (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : \u2200 x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : \u2200 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\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) : L\u2081 \u2243\u2097\u2045R\u2046 L\u2083 :=\n{ ..lie_hom.comp e\u2082.to_lie_hom e\u2081.to_lie_hom,\n  ..linear_equiv.trans e\u2081.to_linear_equiv e\u2082.to_linear_equiv }\n\n@[simp] lemma self_trans_symm (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.trans e.symm = refl :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.symm.trans e = refl :=\ne.symm.self_trans_symm\n\n@[simp] lemma trans_apply (e\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) (x : L\u2081) :\n  (e\u2081.trans e\u2082) x = e\u2082 (e\u2081 x) := rfl\n\n@[simp] lemma symm_trans (e\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) :\n  (e\u2081.trans e\u2082).symm = e\u2082.symm.trans e\u2081.symm := rfl\n\nprotected lemma bijective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.bijective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\ne.to_linear_equiv.bijective\n\nprotected lemma injective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.injective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\ne.to_linear_equiv.injective\n\nprotected lemma surjective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.surjective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\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\u2081 \u2192\u2097\u2045R\u2046 L\u2082)\n  (h\u2081 : function.injective f) (h\u2082 : function.surjective f) : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082 :=\n{ to_fun   := f,\n  map_lie' := f.map_lie,\n  .. (linear_equiv.of_bijective (f : L\u2081 \u2192\u2097[R] L\u2082) h\u2081 h\u2082), }\n\nend lie_equiv\n\nsection lie_module_morphisms\n\nvariables (R : Type u) (L : Type v) (M : Type w) (N : Type w\u2081) (P : Type w\u2082)\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 \u2192\u2097[R] N :=\n(map_lie' : \u2200 {x : L} {m : M}, to_fun \u2045x, m\u2046 = \u2045x, to_fun m\u2046)\n\nattribute [nolint doc_blame] lie_module_hom.to_linear_map\n\nnotation M ` \u2192\u2097\u2045`:25 R,L:25 `\u2046 `: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 \u2192\u2097\u2045R,L\u2046 N) (M \u2192\u2097[R] N) := \u27e8lie_module_hom.to_linear_map\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M \u2192\u2097\u2045R,L\u2046 N) (\u03bb _, M \u2192 N) := \u27e8\u03bb f, f.to_linear_map.to_fun\u27e9\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : M \u2192\u2097\u2045R,L\u2046 N) : ((f : M \u2192\u2097[R] N) : M \u2192 N) = f :=\nrfl\n\n@[simp] lemma map_smul (f : M \u2192\u2097\u2045R,L\u2046 N) (c : R) (x : M) : f (c \u2022 x) = c \u2022 f x :=\nlinear_map.map_smul (f : M \u2192\u2097[R] N) c x\n\n@[simp] lemma map_add (f : M \u2192\u2097\u2045R,L\u2046 N) (x y : M) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : M \u2192\u2097[R] N) x y\n\n@[simp] lemma map_sub (f : M \u2192\u2097\u2045R,L\u2046 N) (x y : M) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : M \u2192\u2097[R] N) x y\n\n@[simp] lemma map_neg (f : M \u2192\u2097\u2045R,L\u2046 N) (x : M) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : M \u2192\u2097[R] N) x\n\n@[simp] lemma map_lie (f : M \u2192\u2097\u2045R,L\u2046 N) (x : L) (m : M) : f \u2045x, m\u2046 = \u2045x, f m\u2046 :=\nlie_module_hom.map_lie' f\n\nlemma map_lie\u2082 (f : M \u2192\u2097\u2045R,L\u2046 N \u2192\u2097[R] P) (x : L) (m : M) (n : N) :\n  \u2045x, f m n\u2046 = f \u2045x, m\u2046 n + f m \u2045x, n\u2046 :=\nby simp only [sub_add_cancel, map_lie, lie_hom.lie_apply]\n\n@[simp] lemma map_zero (f : M \u2192\u2097\u2045R,L\u2046 N) : f 0 = 0 :=\nlinear_map.map_zero (f : M \u2192\u2097[R] N)\n\n/-- The identity map is a morphism of Lie modules. -/\ndef id : M \u2192\u2097\u2045R,L\u2046 M :=\n{ map_lie' := \u03bb x m, rfl,\n  .. (linear_map.id : M \u2192\u2097[R] M) }\n\n@[simp] lemma coe_id : ((id : M \u2192\u2097\u2045R,L\u2046 M) : M \u2192 M) = _root_.id := rfl\n\nlemma id_apply (x : M) : (id : M \u2192\u2097\u2045R,L\u2046 M) x = x := rfl\n\n/-- The constant 0 map is a Lie module morphism. -/\ninstance : has_zero (M \u2192\u2097\u2045R,L\u2046 N) := \u27e8{ map_lie' := by simp, ..(0 : M \u2192\u2097[R] N) }\u27e9\n\n@[norm_cast, simp] lemma coe_zero : ((0 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = 0 := rfl\n\nlemma zero_apply (m : M) : (0 : M \u2192\u2097\u2045R,L\u2046 N) m = 0 := rfl\n\n/-- The identity map is a Lie module morphism. -/\ninstance : has_one (M \u2192\u2097\u2045R,L\u2046 M) := \u27e8id\u27e9\n\ninstance : inhabited (M \u2192\u2097\u2045R,L\u2046 N) := \u27e80\u27e9\n\nlemma coe_injective : @function.injective (M \u2192\u2097\u2045R,L\u2046 N) (M \u2192 N) coe_fn :=\nby { rintros \u27e8\u27e8f, _\u27e9\u27e9 \u27e8\u27e8g, _\u27e9\u27e9 \u27e8h\u27e9, congr, }\n\n@[ext] lemma ext {f g : M \u2192\u2097\u2045R,L\u2046 N} (h : \u2200 m, f m = g m) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : M \u2192\u2097\u2045R,L\u2046 N} : f = g \u2194 \u2200 m, f m = g m :=\n\u27e8by { rintro rfl m, refl, }, ext\u27e9\n\nlemma congr_fun {f g : M \u2192\u2097\u2045R,L\u2046 N} (h : f = g) (x : M) : f x = g x := h \u25b8 rfl\n\n@[simp] lemma mk_coe (f : M \u2192\u2097\u2045R,L\u2046 N) (h) :\n  (\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : M \u2192\u2097[R] N) (h) :\n  ((\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = f :=\nby { ext, refl, }\n\n@[norm_cast, simp] lemma coe_linear_mk (f : M \u2192\u2097[R] N) (h) :\n  ((\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192\u2097[R] N) = f :=\nby { ext, refl, }\n\n/-- The composition of Lie module morphisms is a morphism. -/\ndef comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192\u2097\u2045R,L\u2046 P :=\n{ map_lie' := \u03bb x m, by { change f (g \u2045x, m\u2046) = \u2045x, f (g m)\u2046, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) :\n  f.comp g m = f (g m) := rfl\n\n@[norm_cast, simp] lemma coe_comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) :\n  (f.comp g : M \u2192 P) = f \u2218 g :=\nrfl\n\n@[norm_cast, simp] lemma coe_linear_map_comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) :\n  (f.comp g : M \u2192\u2097[R] P) = (f : N \u2192\u2097[R] P).comp (g : M \u2192\u2097[R] N) :=\nrfl\n\n/-- The inverse of a bijective morphism of Lie modules is a morphism of Lie modules. -/\ndef inverse (f : M \u2192\u2097\u2045R,L\u2046 N) (g : N \u2192 M)\n  (h\u2081 : function.left_inverse g f) (h\u2082 : function.right_inverse g f) : N \u2192\u2097\u2045R,L\u2046 M :=\n{ map_lie' := \u03bb x n,\n    calc g \u2045x, n\u2046 = g \u2045x, f (g n)\u2046 : by rw h\u2082\n              ... = g (f \u2045x, g n\u2046) : by rw map_lie\n              ... = \u2045x, g n\u2046 : (h\u2081 _),\n  ..linear_map.inverse f.to_linear_map g h\u2081 h\u2082 }\n\ninstance : has_add (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ add := \u03bb f g, { map_lie' := by simp, ..((f : M \u2192\u2097[R] N) + (g : M \u2192\u2097[R] N)) }, }\n\ninstance : has_sub (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ sub := \u03bb f g, { map_lie' := by simp, ..((f : M \u2192\u2097[R] N) - (g : M \u2192\u2097[R] N)) }, }\n\ninstance : has_neg (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ neg := \u03bb f, { map_lie' := by simp, ..(-(f : (M \u2192\u2097[R] N))) }, }\n\n@[norm_cast, simp] lemma coe_add (f g : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(f + g) = f + g := rfl\n\nlemma add_apply (f g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (f + g) m = f m + g m := rfl\n\n@[norm_cast, simp] lemma coe_sub (f g : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(f - g) = f - g := rfl\n\nlemma sub_apply (f g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (f - g) m = f m - g m := rfl\n\n@[norm_cast, simp] lemma coe_neg (f : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(-f) = -f := rfl\n\nlemma neg_apply (f : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (-f) m = -(f m) := rfl\n\ninstance : add_comm_group (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ zero           := 0,\n  add            := (+),\n  neg            := has_neg.neg,\n  sub            := has_sub.sub,\n  nsmul          := \u03bb n f, { map_lie' := \u03bb x m, by simp, ..(n \u2022 (f : M \u2192\u2097[R] N)) },\n  nsmul_zero'    := \u03bb f, by { ext, simp, },\n  nsmul_succ'    := \u03bb 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 \u2192\u2097\u2045R,L\u2046 N)) }\n\ninstance : has_scalar R (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ smul := \u03bb t f, { map_lie' := by simp, ..(t \u2022 (f : M \u2192\u2097[R] N)) }, }\n\n@[norm_cast, simp] lemma coe_smul (t : R) (f : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(t \u2022 f) = t \u2022 f := rfl\n\nlemma smul_apply (t : R) (f : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (t \u2022 f) m = t \u2022 (f m) := rfl\n\ninstance : module R (M \u2192\u2097\u2045R,L\u2046 N) :=\nfunction.injective.module R \u27e8\u03bb f, f.to_linear_map.to_fun, rfl, coe_add\u27e9 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 \u2192\u2097\u2045R,L\u2046 N :=\n(inv_fun   : N \u2192 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 ` \u2243\u2097\u2045`:25 R,L:25 `\u2046 `: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 \u2243\u2097\u2045R,L\u2046 N) : M \u2243\u2097[R] N := { ..e }\n\n/-- View an equivalence of Lie modules as a type level equivalence. -/\n@[ancestor]\ndef to_equiv (e : M \u2243\u2097\u2045R,L\u2046 N) : M \u2243 N := { ..e }\n\ninstance has_coe_to_equiv : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2243 N) := \u27e8to_equiv\u27e9\ninstance has_coe_to_lie_module_hom : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2192\u2097\u2045R,L\u2046 N) := \u27e8to_lie_module_hom\u27e9\ninstance has_coe_to_linear_equiv : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2243\u2097[R] N) := \u27e8to_linear_equiv\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M \u2243\u2097\u2045R,L\u2046 N) (\u03bb _, M \u2192 N) := \u27e8\u03bb e, e.to_lie_module_hom.to_fun\u27e9\n\nlemma injective (e : M \u2243\u2097\u2045R,L\u2046 N) : function.injective e := e.to_equiv.injective\n\n@[simp] lemma coe_mk (f : M \u2192\u2097\u2045R,L\u2046 N) (inv_fun h\u2081 h\u2082) :\n  ((\u27e8f, inv_fun, h\u2081, h\u2082\u27e9 : M \u2243\u2097\u2045R,L\u2046 N) : M \u2192 N) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_lie_module_hom (e : M \u2243\u2097\u2045R,L\u2046 N) :\n  ((e : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = e := rfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : M \u2243\u2097\u2045R,L\u2046 N) : ((e : M \u2243\u2097[R] N) : M \u2192 N) = e :=\nrfl\n\nlemma to_equiv_injective : function.injective (to_equiv : (M \u2243\u2097\u2045R,L\u2046 N) \u2192 M \u2243 N) :=\n\u03bb e\u2081 e\u2082 h, begin\n  rcases e\u2081 with \u27e8\u27e8\u27e9\u27e9, rcases e\u2082 with \u27e8\u27e8\u27e9\u27e9,\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\u2081 e\u2082 : M \u2243\u2097\u2045R,L\u2046 N) (h : \u2200 m, e\u2081 m = e\u2082 m) : e\u2081 = e\u2082 :=\nto_equiv_injective (equiv.ext h)\n\ninstance : has_one (M \u2243\u2097\u2045R,L\u2046 M) := \u27e8{ map_lie' := \u03bb x m, rfl, ..(1 : M \u2243\u2097[R] M) }\u27e9\n\n@[simp] lemma one_apply (m : M) : (1 : (M \u2243\u2097\u2045R,L\u2046 M)) m = m := rfl\n\ninstance : inhabited (M \u2243\u2097\u2045R,L\u2046 M) := \u27e81\u27e9\n\n/-- Lie module equivalences are reflexive. -/\n@[refl] def refl : M \u2243\u2097\u2045R,L\u2046 M := 1\n\n@[simp] lemma refl_apply (m : M) : (refl : M \u2243\u2097\u2045R,L\u2046 M) m = m := rfl\n\n/-- Lie module equivalences are syemmtric. -/\n@[symm] def symm (e : M \u2243\u2097\u2045R,L\u2046 N) : N \u2243\u2097\u2045R,L\u2046 M :=\n{ ..lie_module_hom.inverse e.to_lie_module_hom e.inv_fun e.left_inv e.right_inv,\n  ..(e : M \u2243\u2097[R] N).symm }\n\n@[simp] lemma apply_symm_apply (e : M \u2243\u2097\u2045R,L\u2046 N) : \u2200 x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : M \u2243\u2097\u2045R,L\u2046 N) : \u2200 x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n@[simp] lemma symm_symm (e : M \u2243\u2097\u2045R,L\u2046 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\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) : M \u2243\u2097\u2045R,L\u2046 P :=\n{ ..lie_module_hom.comp e\u2082.to_lie_module_hom e\u2081.to_lie_module_hom,\n  ..linear_equiv.trans e\u2081.to_linear_equiv e\u2082.to_linear_equiv }\n\n@[simp] lemma trans_apply (e\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) (m : M) :\n  (e\u2081.trans e\u2082) m = e\u2082 (e\u2081 m) := rfl\n\n@[simp] lemma symm_trans (e\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) :\n  (e\u2081.trans e\u2082).symm = e\u2082.symm.trans e\u2081.symm := rfl\n\n@[simp] lemma self_trans_symm (e : M \u2243\u2097\u2045R,L\u2046 N) : e.trans e.symm = refl :=\next _ _ e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : M \u2243\u2097\u2045R,L\u2046 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 \u2022 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) \u25b8 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 \u2192\u2097[R] M \u2192\u2097[R] A\n  contract (m : M) : bilin m m = algebraMap R A (Q m)\n  contract_mid (m\u2081 m\u2082 m\u2083 : M) : bilin m\u2081 m\u2082 * bilin m\u2082 m\u2083 = Q m\u2082 \u2022 bilin m\u2081 m\u2083\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\u2082 (g : EvenHom Q A) (f : A \u2192\u2090[R] B) : EvenHom Q B\n    where\n  bilin := g.bilin.compr\u2082 f.toLinearMap\n  contract m := (f.congr_arg <| g.contract _).trans <| f.commutes _\n  contract_mid m\u2081 m\u2082 m\u2083 :=\n    (f.map_mul _ _).symm.trans <| (f.congr_arg <| g.contract_mid _ _ _).trans <| f.map_smul _ _\n#align clifford_algebra.even_hom.compr\u2082 CliffordAlgebra.EvenHom.compr\u2082\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.\u03b9 : EvenHom Q (even Q)\n    where\n  bilin :=\n    LinearMap.mk\u2082 R (fun m\u2081 m\u2082 => \u27e8\u03b9 Q m\u2081 * \u03b9 Q m\u2082, \u03b9_mul_\u03b9_mem_evenOdd_zero _ _ _\u27e9)\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 <| \u03b9_sq_scalar Q m\n  contract_mid m\u2081 m\u2082 m\u2083 :=\n    Subtype.ext <|\n      calc\n        \u03b9 Q m\u2081 * \u03b9 Q m\u2082 * (\u03b9 Q m\u2082 * \u03b9 Q m\u2083) = \u03b9 Q m\u2081 * (\u03b9 Q m\u2082 * \u03b9 Q m\u2082 * \u03b9 Q m\u2083) := by\n          simp only [mul_assoc]\n        _ = Q m\u2082 \u2022 (\u03b9 Q m\u2081 * \u03b9 Q m\u2083) := by rw [Algebra.smul_def, \u03b9_sq_scalar, Algebra.left_comm]\n        \n#align clifford_algebra.even.\u03b9 CliffordAlgebra.even.\u03b9\n\ninstance : Inhabited (EvenHom Q (even Q)) :=\n  \u27e8even.\u03b9 Q\u27e9\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 \u2983f g : even Q \u2192\u2090[R] A\u2984 (h : (even.\u03b9 Q).compr\u2082 f = (even.\u03b9 Q).compr\u2082 g) :\n    f = g := by\n  rw [even_hom.ext_iff] at h\n  ext \u27e8x, hx\u27e9\n  refine' even_induction _ _ _ _ _ hx\n  \u00b7 intro r\n    exact (f.commutes r).trans (g.commutes r).symm\n  \u00b7 intro x y hx hy ihx ihy\n    have := congr_arg\u2082 (\u00b7 + \u00b7) ihx ihy\n    exact (f.map_add _ _).trans (this.trans <| (g.map_add _ _).symm)\n  \u00b7 intro m\u2081 m\u2082 x hx ih\n    have := congr_arg\u2082 (\u00b7 * \u00b7) (LinearMap.congr_fun (LinearMap.congr_fun h m\u2081) m\u2082) 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 `\u2203 x m\u2082, \u2200 m\u2081, f' m\u2081 = f m\u2081 m\u2082 * x`.  -/\nprivate def S : Submodule R (M \u2192\u2097[R] A) :=\n  Submodule.span R\n    { f' | \u2203 x m\u2082, f' = LinearMap.lcomp R _ (f.bilin.flip m\u2082) (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 \u2192\u2097[R] A \u00d7 s f \u2192\u2097[R] A \u00d7 s f :=\n  LinearMap.mk\u2082 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 \u2192\u2097[R] A \u2192\u2097[R] M \u2192\u2097[R] A)\n        ```\n        -/\n      (Acc.2 m,\n        \u27e8(LinearMap.mulRight R Acc.1).comp (f.bilin.flip m), Submodule.subset_span <| \u27e8_, _, rfl\u27e9\u27e9))\n    (fun m\u2081 m\u2082 a =>\n      Prod.ext (LinearMap.map_add _ m\u2081 m\u2082)\n        (Subtype.ext <|\n          LinearMap.ext fun m\u2083 =>\n            show f.bilin m\u2083 (m\u2081 + m\u2082) * a.1 = f.bilin m\u2083 m\u2081 * a.1 + f.bilin m\u2083 m\u2082 * 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\u2083 =>\n            show f.bilin m\u2083 (c \u2022 m) * a.1 = c \u2022 (f.bilin m\u2083 m * a.1) by\n              rw [LinearMap.map_smul, smul_mul_assoc]))\n    (fun m a\u2081 a\u2082 => Prod.ext rfl (Subtype.ext <| LinearMap.ext fun m\u2083 => mul_add _ _ _))\n    fun c m a => Prod.ext rfl (Subtype.ext <| LinearMap.ext fun m\u2083 => 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\u2081 m\u2082 : M) (x : A \u00d7 s f) :\n    (fFold f m\u2081 (fFold f m\u2082 x)).fst = f.bilin m\u2081 m\u2082 * 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\u2081 m\u2082 m\u2083 : M) (x : A \u00d7 s f) :\n    ((fFold f m\u2081 (fFold f m\u2082 x)).snd : M \u2192\u2097[R] A) m\u2083 = f.bilin m\u2083 m\u2081 * (x.snd : M \u2192\u2097[R] A) m\u2082 :=\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 \u00d7 s f) : fFold f m (fFold f m x) = Q m \u2022 x :=\n  by\n  obtain \u27e8a, \u27e8g, hg\u27e9\u27e9 := x\n  ext : 2\n  \u00b7 change f.bilin m m * a = Q m \u2022 a\n    rw [Algebra.smul_def, f.contract]\n  \u00b7 ext m\u2081\n    change f.bilin _ _ * g m = Q m \u2022 g m\u2081\n    apply Submodule.span_induction' _ _ _ _ hg\n    \u00b7 rintro _ \u27e8b, m\u2083, rfl\u27e9\n      change f.bilin _ _ * (f.bilin _ _ * b) = Q m \u2022 (f.bilin _ _ * b)\n      rw [\u2190 smul_mul_assoc, \u2190 mul_assoc, f.contract_mid]\n    \u00b7 change f.bilin m\u2081 m * 0 = Q m \u2022 0\n      rw [MulZeroClass.mul_zero, smul_zero]\n    \u00b7 rintro x hx y hy ihx ihy\n      rw [LinearMap.add_apply, LinearMap.add_apply, mul_add, smul_add, ihx, ihy]\n    \u00b7 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 \u2192\u2097[R] A :=\n  by\n  refine' _ \u2218\u2097 (Even Q).val.toLinearMap\n  exact LinearMap.fst _ _ _ \u2218\u2097 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_\u03b9 (m\u2081 m\u2082 : M) : aux f ((even.\u03b9 Q).bilin m\u2081 m\u2082) = f.bilin m\u2081 m\u2082 :=\n  (congr_arg Prod.fst (foldr_mul _ _ _ _ _ _)).trans\n    (by\n      rw [foldr_\u03b9, foldr_\u03b9]\n      exact mul_one _)\n#align clifford_algebra.even.lift.aux_\u03b9 CliffordAlgebra.even.Lift.aux_\u03b9\n\n@[simp]\ntheorem aux_algebraMap (r) (hr) : aux f \u27e8algebraMap R _ r, hr\u27e9 = 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  \u00b7 intro r\n    rw [foldr_algebra_map, aux_algebra_map]\n    exact Algebra.smul_def r _\n  \u00b7 intro x y hx hy ihx ihy\n    rw [LinearMap.map_add, Prod.fst_add, ihx, ihy, \u2190 add_mul, \u2190 LinearMap.map_add]\n    rfl\n  \u00b7 rintro m\u2081 m\u2082 x (hx : x \u2208 Even Q) ih\n    rw [aux_apply, foldr_mul, foldr_mul, foldr_\u03b9, foldr_\u03b9, fst_f_fold_f_fold, ih, \u2190 mul_assoc,\n      Subtype.coe_mk, foldr_mul, foldr_mul, foldr_\u03b9, foldr_\u03b9, 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 \u2243 (CliffordAlgebra.even Q \u2192\u2090[R] A)\n    where\n  toFun f := AlgHom.ofLinearMap (aux f) (aux_one f) (aux_mul f)\n  invFun F := (even.\u03b9 Q).compr\u2082 F\n  left_inv f := EvenHom.ext _ _ <| LinearMap.ext\u2082 <| even.Lift.aux_\u03b9 f\n  right_inv F := even.algHom_ext Q <| EvenHom.ext _ _ <| LinearMap.ext\u2082 <| even.Lift.aux_\u03b9 _\n#align clifford_algebra.even.lift CliffordAlgebra.even.lift\n\n@[simp]\ntheorem even.lift_\u03b9 (f : EvenHom Q A) (m\u2081 m\u2082 : M) :\n    even.lift Q f ((even.\u03b9 Q).bilin m\u2081 m\u2082) = f.bilin m\u2081 m\u2082 :=\n  even.Lift.aux_\u03b9 _ _ _\n#align clifford_algebra.even.lift_\u03b9 CliffordAlgebra.even.lift_\u03b9\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 \u2192 pre_homo_locus_pres G \u2192 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\u207b\u00b9)))\n\ninductive pre_homo_locus_pres_rel (G : Type u) [group G] : pre_homo_locus_pres G \u2192 pre_homo_locus_pres G \u2192 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 \u2192 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 \u2192 pre_homo_locus_pres_rel G b a\n| \u27e8r\u27e9 := 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 \u2192 pre_homo_locus_pres_rel G b c \u2192 pre_homo_locus_pres_rel G a c\n| \u27e8rab\u27e9 \u27e8rbc\u27e9 := (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 := \u03bb a b, quotient.lift_on\u2082 a b\n                  (\u03bb a b, \u27e6pre_homo_locus_pres.mul a b\u27e7)\n                  (\u03bb a b a' b' \u27e8ha\u27e9 \u27e8hb\u27e9,\n                    quotient.sound (pre_homo_locus_pres_rel'.congr_mul ha hb).rel),\n  one := \u27e6unit\u27e7,\n  inv := \u03bb a, quotient.lift_on a\n                (\u03bb a, \u27e6pre_homo_locus_pres.inv a\u27e7)\n                (\u03bb a a' \u27e8ha\u27e9,\n                  quotient.sound (pre_homo_locus_pres_rel'.congr_inv ha).rel),\n  mul_assoc := \u03bb a b c,\n    quotient.induction_on\u2083 a b c (\u03bb a b c, quotient.sound (pre_homo_locus_pres_rel'.assoc a b c).rel),\n  one_mul := \u03bb a,\n    quotient.induction_on a (\u03bb a, quotient.sound (pre_homo_locus_pres_rel'.one_mul a).rel),\n  mul_one := \u03bb a,\n    quotient.induction_on a (\u03bb a, quotient.sound (pre_homo_locus_pres_rel'.mul_one a).rel),\n  mul_left_inv := \u03bb a,\n    quotient.induction_on a (\u03bb a, quotient.sound (pre_homo_locus_pres_rel'.mul_left_inv a).rel) }\n\ndef homo_locus_of (x : G \u00d7 G) : homo_locus_pres G := \u27e6incl x.1 x.2\u27e7\n\nlemma homo_locus_of_def (x : G \u00d7 G) : homo_locus_of x = \u27e6incl x.1 x.2\u27e7 := rfl\n\nlemma homo_locus_pres_one_def : (1 : homo_locus_pres G) = \u27e6unit\u27e7 := rfl\n\nlemma homo_locus_pres_mul_def (x y : pre_homo_locus_pres G) : (\u27e6x\u27e7 * \u27e6y\u27e7 : homo_locus_pres G) = \u27e6x.mul y\u27e7 := rfl \n\nlemma homo_locus_pres_inv_def (x : pre_homo_locus_pres G) : (\u27e6x\u27e7\u207b\u00b9 : homo_locus_pres G) = \u27e6x.inv\u27e7 := rfl \n\nlemma homo_locus_pres_quot_mk_helper (x : pre_homo_locus_pres G) : quot.mk setoid.r x = \u27e6x\u27e7 := rfl\n\nvariables {H : Type*} [group H]\n\ndef is_homo_locus_liftable (f : G \u00d7 G \u2192 H) : Prop := (\u2200 a b : G \u00d7 G, f a * f b = f b * f a) \u2227 (\u2200 a b : G, homo_locus (a, b) \u2192 f (a, b) = 1) \u2227 (\u2200 a b x : G, f (a, b) = f (x, a) * f (x * a, b) * ((f (x, (a * b)))\u207b\u00b9)) \u2227 (\u2200 a b : G, f (a, b) = (f (a * b, a\u207b\u00b9))\u207b\u00b9)\n\n\ndef lift_homo_locus_pres_morph_pre (f : G \u00d7 G \u2192 H) (hf : is_homo_locus_liftable f) : pre_homo_locus_pres G \u2192 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)\u207b\u00b9\n\ndef lift_homo_locus_pres_morph (f : G \u00d7 G \u2192 H) (hf : is_homo_locus_liftable f) : homo_locus_pres G \u2192* 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\u207b\u00b9))\u207b\u00b9 = 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))\u207b\u00b9 = homo_locus_of (x * y, x\u207b\u00b9) :=\nbegin\n  rw \u2190homo_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))\u207b\u00b9) :=\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 \u2190homo_locus_pres_one_def,\n      simp only [mul_one, one_mul],\n    },\n    {\n      induction y,\n      {\n        rw \u2190homo_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 \u2190homo_locus_pres_mul_def,\n        rw \u2190mul_assoc,\n        rw y_ih_x,\n        rw mul_assoc,\n        rw y_ih_y,\n        rw \u2190mul_assoc,\n      },\n      {\n        rw \u2190homo_locus_pres_inv_def,\n        have : (\u27e6y_x\u27e7 * \u27e6y_x\u27e7\u207b\u00b9 * \u27e6incl x_x x_y\u27e7 * \u27e6y_x\u27e7 : homo_locus_pres G) = \u27e6y_x\u27e7 * \u27e6incl x_x x_y\u27e7 * \u27e6y_x\u27e7\u207b\u00b9 * \u27e6y_x\u27e7,\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 \u2190homo_locus_pres_mul_def,\n      rw mul_assoc,\n      rw x_ih_y,\n      rw \u2190mul_assoc,\n      rw x_ih_x,\n      rw \u2190mul_assoc,\n    },\n    {\n      rw \u2190homo_locus_pres_inv_def,\n      have : (\u27e6x_x\u27e7 * \u27e6x_x\u27e7\u207b\u00b9 * \u27e6y\u27e7 * \u27e6x_x\u27e7 : homo_locus_pres G) = \u27e6x_x\u27e7 * \u27e6y\u27e7 * \u27e6x_x\u27e7\u207b\u00b9 * \u27e6x_x\u27e7,\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))\u207b\u00b9 :=\nbegin\n  rw \u2190homo_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))\u207b\u00b9 = homo_locus_of (b\u207b\u00b9, a * b) :=\nbegin\n  have : (homo_locus_of (b\u207b\u00b9, a))\u207b\u00b9 * homo_locus_of (b\u207b\u00b9, 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))\u207b\u00b9 = homo_locus_of (a * b, b\u207b\u00b9) :=\nbegin\n  rw homo_locus_assoc_alt,\n  have : homo_locus_of (a, b * b\u207b\u00b9) = 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\u207b\u00b9) = 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 : \u2200 a b : G, homo_locus_of (b\u207b\u00b9, a * b) = homo_locus_of (a * b, b\u207b\u00b9),\n  {\n    intros a b,\n    rw \u2190homo_locus_of_inv_cancel,\n    rw \u2190homo_locus_of_inv_assoc,\n  },\n  specialize this (a * b) (b\u207b\u00b9),\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)\u207b\u00b9) :=\nbegin\n  have : \u2200 a b : G, homo_locus_of (a * b, b\u207b\u00b9) = homo_locus_of (a * b, a\u207b\u00b9),\n  {\n    intros a b,\n    rw \u2190homo_locus_of_inv a b,\n    rw \u2190homo_locus_of_inv_cancel,\n  },\n  specialize this (a * b) (b\u207b\u00b9),\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))\u207b\u00b9 = homo_locus_of (b\u207b\u00b9, a\u207b\u00b9) :=\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 \u2192 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\u207b\u00b9]\n| (inv a) := let x := (pre_homo_locus_pres_to_list a) in (x.map (\u03bb x : G, x\u207b\u00b9)).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 = \u27e6x\u27e7 :=\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 \u2190homo_locus_pres_mul_def,\n    rw \u2190x_ih_x,\n    rw \u2190x_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)\u207b\u00b9))\u207b\u00b9,\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 \u2190mul_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 \u2190mul_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 \u2190mul_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 \u2190homo_locus_pres_inv_def,\n    rw \u2190x_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))\u207b\u00b9 = 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)\u207b\u00b9,\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 \u2190inv_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\u207b\u00b9,\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 \u2190x_tl_ih (x_tl_hd),\n        rw \u2190x_tl_ih (x_hd * x_tl_hd),\n        simp only [\u2190mul_assoc],\n        simp only [mul_inv_rev, mul_left_inj],\n        generalize : (x_tl_tl.prod)\u207b\u00b9 = c,\n        generalize hb : (x_tl_hd)\u207b\u00b9 = b,\n        generalize ha : (x_hd)\u207b\u00b9 = a,\n        clear x_tl_ih x_tl_tl,\n        have ha1 : x_hd = a\u207b\u00b9,\n        {\n          rw \u2190ha,\n          rw inv_inv,\n        },\n        have hb1 : x_tl_hd = b\u207b\u00b9,\n        {\n          rw \u2190hb,\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\u207b\u00b9) = 1,\n        {\n          apply homo_locus_of_one,\n          exact homo_locus_closed_left_one b\u207b\u00b9,\n        },\n        rw this,\n        clear this,\n        rw mul_one,\n        rw \u2190inv_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 \u2192* (counit : pq_group G \u2192* 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))\u207b\u00b9,\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))\u207b\u00b9 * (of (x * a) * of b * (of (x * a * b))\u207b\u00b9) * of (x * (a * b)) * (of (a * b))\u207b\u00b9 = of a * of b * (of (a * b))\u207b\u00b9,\n      {\n        assoc_rw this,\n        clear this _inst,\n        assoc_rw counit_ker_abelian_counit (of a * of b * (of (a * b))\u207b\u00b9) _ _,\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 \u2190rhd_def_group,\n      rw \u2190rhd_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)) = \u27e8of a * of b * (of (a * b))\u207b\u00b9, 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\u27e9  :=\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 \u27e6x\u27e7 = \u27e8((counit_ker_decomp (pre_homo_locus_pres_to_list x)).map (\u03bb (a : G \u00d7 G), of a.1 * of a.2 * (of (a.1 * a.2))\u207b\u00b9)).prod, begin \n  apply counit_ker_decomp_comp_in_ker,\nend\u27e9 :=\nbegin\n  rw \u2190pre_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 : \u2200 x : list ((counit : pq_group G \u2192* G).ker), (\u2191(x.prod) : pq_group G) = (x.map (\u03bb x, \u2191x)).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 \u00d7 G \u2192 H) (hf : is_homo_locus_liftable f) : (counit : pq_group G \u2192* G).ker \u2192* H :=\nbegin\n  rcases hf with \u27e8hf1, hf2, hf3, hf4, hf5\u27e9,\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 \u2192 list G \u2192 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 \u2192 homo_locus_pres G := \u03bb 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 \u2192* G).ker \u2192 homo_locus_pres G := \nbegin \n  fapply pq_group_list_data_property,\n  exact (\u03bb \u27e8x, hx\u27e9, 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 : \u27e6hxy_r_b\u27e7 \u2208 has_coe_t_aux.coe counit.ker,\n      {\n        suffices : \u27e6hxy_r_a\u27e7 = \u27e6hxy_r_b\u27e7, \n        rw \u2190this,\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 \u2192* G).ker \u2192* 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 \u2192 (counit : pq_group G \u2192* 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 \u2190pre_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 \u2190counit_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 \u2243* (counit : pq_group G \u2192* 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\u2080` and `K\u2081`. 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) {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5)`,\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 `\ud835\udcd5` 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 \u211d E]\n          {F : Type*} [normed_add_comm_group F] [normed_space \u211d F]\n          {G : Type*} [normed_add_comm_group G] [normed_space \u211d G]\n\n/--\nThe setup for local h-principle is two compact subsets `K\u2080 \u2286 K\u2081` in `E` with\n`K\u2080 \u2286 interior K\u2081` and a closed subset `C`.\n-/\nstructure landscape :=\n(C K\u2080 K\u2081 : set E)\n(hC : is_closed C)\n(hK\u2080 : is_compact K\u2080)\n(hK\u2081 : is_compact K\u2081)\n(h\u2080\u2081 : K\u2080 \u2286 interior K\u2081)\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\u2080 \u2286 K\u2081` in `E` with `K\u2080 \u2286 interior K\u2081` and a closed subset `C`\ntogether with a dual pair `p` and a subspace `E'` of the corresponding hyperplane `ker p.\u03c0`.\n-/\nstructure step_landscape extends landscape E :=\n(E' : submodule \u211d E)\n(p : dual_pair E)\n(hEp : E' \u2264 ker p.\u03c0)\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) (\ud835\udcd5 : jet_sec E F) : Prop :=\n(h_op : is_open R)\n(hK\u2080 : \u2200\u1da0 x near L.K\u2080, \ud835\udcd5.is_part_holonomic_at L.E' x)\n(h_short : \u2200 x, \ud835\udcd5.is_short_at R L.p x)\n(hC : \u2200\u1da0 x near L.C, \ud835\udcd5.is_holonomic_at x)\n\n/-- The union of all slices of `R` corresponding to `\ud835\udcd5`. -/\ndef \u03a9 (L : step_landscape E) (\ud835\udcd5 : jet_sec E F) : set (E \u00d7 F) :=\n{p | p.2 \u2208 \ud835\udcd5.slice_at R L.p p.1}\n--\u22c3 x, ({x} : set E) \u00d7\u02e2 (connected_component_in (\ud835\udcd5.slice_at R L.p x) $ \ud835\udcd5.\u03c6 x L.p.v)\n\n/-- The linear form in a `step_landscape`, coming from the underlying dual pair. -/\ndef \u03c0 (L : step_landscape E) : E \u2192L[\u211d] \u211d := L.p.\u03c0\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\u2081 \u2229 C, needed as an input to the\nloop construction. -/\ndef K (L : step_landscape E) : set E := L.K\u2081 \u2229 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) (\ud835\udcd5 : jet_sec E F) : E \u2192 F := \u03bb x, \ud835\udcd5.\u03c6 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) (\ud835\udcd5 : jet_sec E F) : E \u2192 F := \u03bb x, D \ud835\udcd5.f x L.v\n\nlemma is_compact_K (L : step_landscape E) : is_compact L.K :=\nL.hK\u2081.inter_right L.hC\n\nvariables {R}\n\nlemma accepts.open [finite_dimensional \u211d E]  {L : step_landscape E} {\ud835\udcd5 : jet_sec E F} (h : L.accepts R \ud835\udcd5) :\n  is_open (L.\u03a9 R \ud835\udcd5) :=\nbegin\n  set \u03c8 : E \u00d7 F \u2192 one_jet E F := \u03bb p, (p.1, \ud835\udcd5.f p.1, L.p.update (\ud835\udcd5.\u03c6 p.1) p.2),\n  change is_open {p : E \u00d7 F | \u03c8 p \u2208 R},\n  apply is_open.preimage _ h.h_op,\n  apply continuous_fst.prod_mk (\ud835\udcd5.f_diff.continuous.fst'.prod_mk _),\n  exact L.p.continuous_update \ud835\udcd5.\u03c6_diff.continuous.fst' continuous_snd\nend\n\nlemma smooth_b (L : step_landscape E) (\ud835\udcd5 : jet_sec E F) :\n  \ud835\udc9e \u221e (L.b \ud835\udcd5) :=\n(continuous_linear_map.apply \u211d F L.v).cont_diff.comp \ud835\udcd5.\u03c6_diff\n\nlemma smooth_g (L : step_landscape E) (\ud835\udcd5 : jet_sec E F) :\n  \ud835\udc9e \u221e (L.g \ud835\udcd5) :=\n(continuous_linear_map.apply \u211d F L.v).cont_diff.comp (cont_diff_top_iff_fderiv.mp \ud835\udcd5.f_diff).2\n\nlemma accepts.rel {L : step_landscape E} {\ud835\udcd5 : jet_sec E F} (h : L.accepts R \ud835\udcd5) :\n  \u2200\u1da0 (x : E) near L.K, (L.g \ud835\udcd5) x = (L.b \ud835\udcd5) x :=\nbegin\n  apply (h.hC.filter_mono $ monotone_nhds_set (inter_subset_right L.K\u2081 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 \u211d E]  [finite_dimensional \u211d 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) {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5) :\n\u211d \u2192 E \u2192 loop F :=\nclassical.some (exist_loops L.is_compact_K h.open (L.smooth_g \ud835\udcd5) (L.smooth_b \ud835\udcd5) h.rel h.h_short)\n\nlemma nice (L : step_landscape E) {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5) :\n  nice_loop (L.g \u2191\ud835\udcd5) (L.b \u2191\ud835\udcd5) (\u03a9 R L \ud835\udcd5) L.K (L.loop h) :=\nclassical.some_spec $ exist_loops L.is_compact_K h.open (L.smooth_g \ud835\udcd5) (L.smooth_b \ud835\udcd5) h.rel h.h_short\n\nlemma update_zero (L : step_landscape E) {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5) (x : E) (s : \u211d) :\nL.p.update (\ud835\udcd5.\u03c6 x) ((L.loop h 0 x) s) = \ud835\udcd5.\u03c6 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) {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5) :\n  \ud835\udc9e \u221e \u21bf(L.loop h) :=\n(L.nice h).smooth\n\nlemma loop_smooth' (L : step_landscape E) {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5)\n  {t : G \u2192 \u211d} (ht : \ud835\udc9e \u221e t) {s : G \u2192 \u211d} (hs : \ud835\udc9e \u221e s) {x : G \u2192 E} (hx : \ud835\udc9e \u221e x) :\n  \ud835\udc9e \u221e (\u03bb 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) {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5) :\n\u2200 t, \ud835\udc9e 1 \u21bf(L.loop h t) :=\n\u03bb 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\u2080 and\nzero outside K\u2081. -/\ndef \u03c1 (L : step_landscape E) : E \u2192 \u211d :=\n(exists_cont_diff_one_nhds_of_interior L.hK\u2080.is_closed L.h\u2080\u2081).some\n\nlemma \u03c1_smooth (L : step_landscape E) : \ud835\udc9e \u221e L.\u03c1 :=\n(exists_cont_diff_one_nhds_of_interior L.hK\u2080.is_closed L.h\u2080\u2081).some_spec.1\n\nlemma \u03c1_mem (L : step_landscape E) (x : E) : L.\u03c1 x \u2208 I :=\n(exists_cont_diff_one_nhds_of_interior L.hK\u2080.is_closed L.h\u2080\u2081).some_spec.2.2.2 x\n\nlemma \u03c1_le (L : step_landscape E) (x : E) : |L.\u03c1 x| \u2264 1 :=\nbegin\n  cases L.\u03c1_mem x with h h',\n  rw abs_le,\n  refine \u27e8_, h'\u27e9,\n  linarith\nend\n\nlemma h\u03c1\u2080 (L : step_landscape E) : \u2200\u1da0 x near L.K\u2080, L.\u03c1 x = 1 :=\n(exists_cont_diff_one_nhds_of_interior L.hK\u2080.is_closed L.h\u2080\u2081).some_spec.2.1\n\nlemma h\u03c1_compl_K\u2081 (L : step_landscape E) {x : E} : x \u2209 L.K\u2081 \u2192 L.\u03c1 x = 0 :=\n(exists_cont_diff_one_nhds_of_interior L.hK\u2080.is_closed L.h\u2080\u2081).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 `\ud835\udcd5` from being `L.E'`-holonomic to\n`L.E' \u2294 span {p.v}`-holonomic near `L.K\u2080`.\n-/\ndef improve_step {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5) (N : \u211d) : htpy_jet_sec E F :=\n{ f := \u03bb t x, \ud835\udcd5.f x + (smooth_step t*L.\u03c1 x) \u2022 corrugation L.\u03c0 N (L.loop h t) x,\n  f_diff :=  \ud835\udcd5.f_diff.snd'.add $\n    (smooth_step.smooth.fst'.mul L.\u03c1_smooth.snd').smul $\n    corrugation.cont_diff' N (L.loop_smooth h) cont_diff_snd cont_diff_fst,\n  \u03c6 := \u03bb t x, L.p.update (\ud835\udcd5.\u03c6 x) (L.loop h (smooth_step t*L.\u03c1 x) x $ N * L.\u03c0 x) +\n                (smooth_step t*L.\u03c1 x) \u2022 (corrugation.remainder L.p.\u03c0 N (L.loop h 1) x),\n  \u03c6_diff := begin\n    apply cont_diff.add,\n    apply L.p.smooth_update,\n    apply \ud835\udcd5.\u03c6_diff.snd',\n    apply L.loop_smooth',\n    exact smooth_step.smooth.fst'.mul L.\u03c1_smooth.snd',\n    apply cont_diff_const.mul L.\u03c0.cont_diff.snd',\n    exact cont_diff_snd,\n    apply cont_diff.smul,\n    exact smooth_step.smooth.fst'.mul L.\u03c1_smooth.snd',\n    exact remainder.smooth _ _ (L.loop_smooth h) cont_diff_snd cont_diff_const\n  end }\n\nvariables {L} {\ud835\udcd5 : formal_sol R} (h : L.accepts R \ud835\udcd5) (N : \u211d)\n\n@[simp]\nlemma improve_step_apply (t : \u211d) (x : E) :\n  L.improve_step h N t x = (\ud835\udcd5.f x + (smooth_step t*L.\u03c1 x) \u2022 corrugation L.\u03c0 N (L.loop h t) x,\n  L.p.update (\ud835\udcd5.\u03c6 x) (L.loop h (smooth_step t*L.\u03c1 x) x $ N * L.\u03c0 x) +\n                 (smooth_step t*L.\u03c1 x) \u2022 (corrugation.remainder L.p.\u03c0 N (L.loop h 1) x)) :=\nby { simp [improve_step, h], refl }\n\n@[simp]\nlemma improve_step_apply_f (t : \u211d) (x : E) :\n  (L.improve_step h N t).f x = \ud835\udcd5.f x + (smooth_step t*L.\u03c1 x) \u2022 corrugation L.\u03c0 N (L.loop h t) x :=\nrfl\n\n@[simp]\nlemma improve_step_apply_\u03c6 (t : \u211d) (x : E) :\n  (L.improve_step h N t).\u03c6 x = L.p.update (\ud835\udcd5.\u03c6 x) (L.loop h (smooth_step t*L.\u03c1 x) x $ N * L.\u03c0 x) +\n                 (smooth_step t*L.\u03c1 x) \u2022 (corrugation.remainder L.p.\u03c0 N (L.loop h 1) x) :=\nrfl\n\nlemma improve_step_of_support (t : \u211d) {x : E}\n  (H : \u2200 t, x \u2209 loop.support (L.loop h t)) :\n  L.improve_step h N t x = \ud835\udcd5 x :=\nbegin\n  have : \u2200 t s, L.loop h t x s = \ud835\udcd5.\u03c6 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 = \ud835\udcd5 :=\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_\u03c6 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\u2081 {x} (hx : x \u2209 L.K\u2081) (t) : L.improve_step h N t x = \ud835\udcd5 x :=\nbegin\n  rw [improve_step_apply h, L.h\u03c1_compl_K\u2081 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 : \u2200\u1da0 x near L.K, \u2200 t, L.improve_step h N t x = \ud835\udcd5 x :=\nbegin\n  have : \u2200\u1da0 x near L.K, \u2200 t, x \u2209 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 : \u2200\u1da0 x near L.C, \u2200 t, L.improve_step h N t x = \ud835\udcd5 x :=\nbegin\n  apply eventually.filter_mono (L.hK\u2081.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 \u03bb x, improve_step_rel_compl_K\u2081 h N }\nend\n\n-- In the next lemma we reintroduce F to appaise the unused argument linter since\n-- `finite_dimensional \u211d F` isn't needed here.\n\nlemma bu_lt {F : Type*} [normed_add_comm_group F] [normed_space \u211d F]\n  (t : \u211d) (x : E) {v : F} {\u03b5 : \u211d} (hv : \u2016v\u2016 < \u03b5) :\n  \u2016(smooth_step t * L.\u03c1 x) \u2022 v\u2016 < \u03b5 :=\ncalc \u2016(smooth_step t * L.\u03c1 x) \u2022 v\u2016 = |smooth_step t| * |L.\u03c1 x| * \u2016v\u2016 : by\n             rw [norm_smul, real.norm_eq_abs, abs_mul]\n... \u2264 \u2016v\u2016 : mul_le_of_le_one_left (norm_nonneg _) (mul_le_one (smooth_step.abs_le t)\n                                                          (abs_nonneg _) (L.\u03c1_le x))\n... < \u03b5 : hv\n\nlemma improve_step_c0_close {\u03b5 : \u211d} (\u03b5_pos : 0 < \u03b5) :\n  \u2200\u1da0 N in at_top, \u2200 x t, \u2016(L.improve_step h N t).f x - \ud835\udcd5.f x\u2016 \u2264 \u03b5 :=\nbegin\n  set \u03b3 := L.loop h,\n  have \u03b3_cont : continuous \u21bf(\u03bb t x, \u03b3 t x) := (L.nice h).smooth.continuous,\n  have \u03b3_C1 : \ud835\udc9e 1 \u21bf(\u03b3 1) := ((L.nice h).smooth.comp (cont_diff_prod_mk_right 1)).of_le le_top,\n  apply ((corrugation.c0_small_on L.hK\u2081 (L.nice h).t_le_zero (L.nice h).t_ge_one \u03b3_cont \u03b5_pos).and $\n        remainder_c0_small_on L.\u03c0 L.hK\u2081 \u03b3_C1 \u03b5_pos).mono,\n  rintros N \u27e8H, H'\u27e9 x t,\n  by_cases hx : x \u2208 L.K\u2081,\n  { rw [improve_step_apply_f h],\n    suffices : \u2016(smooth_step t * L.\u03c1 x) \u2022 corrugation L.\u03c0 N (L.loop h t) x\u2016 \u2264 \u03b5, by simpa,\n    exact (bu_lt _ _ $ H _ hx t).le },\n  { rw show (L.improve_step h N t).f x = \ud835\udcd5.f x, from congr_arg prod.fst (improve_step_rel_compl_K\u2081 h N hx t),\n    simp [\u03b5_pos.le] }\nend\n\nlemma improve_step_part_hol {N : \u211d} (hN : N \u2260 0) :\n  \u2200\u1da0 x near L.K\u2080, (L.improve_step h N 1).is_part_holonomic_at (L.E' \u2294 L.p.span_v) x :=\nbegin\n  have \u03b3_C1 : \ud835\udc9e 1 \u21bf(L.loop h 1) := ((L.nice h).smooth.comp (cont_diff_prod_mk_right 1)).of_le le_top,\n  let \ud835\udcd5' : jet_sec E F :=\n  { f := \u03bb x, \ud835\udcd5.f x + corrugation L.\u03c0 N (L.loop h 1) x,\n    f_diff := \ud835\udcd5.f_diff.add\n     (corrugation.cont_diff' _ (L.loop_smooth h) cont_diff_id cont_diff_const),\n    \u03c6 := \u03bb x , L.p.update (\ud835\udcd5.\u03c6 x) (L.loop h 1 x $ N * L.\u03c0 x) +\n               corrugation.remainder L.p.\u03c0 N (L.loop h 1) x,\n    \u03c6_diff := begin\n      apply cont_diff.add,\n      apply L.p.smooth_update,\n      apply \ud835\udcd5.\u03c6_diff,\n      apply L.loop_smooth',\n      apply cont_diff_const,\n      apply cont_diff_const.mul L.\u03c0.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 : \u2200\u1da0 x near L.K\u2080, L.improve_step h N 1 x = \ud835\udcd5' x,\n  { apply L.h\u03c1\u2080.mono,\n    intros x hx,\n    simp [improve_step_apply h, hx],\n    refl },\n  have fderiv_\ud835\udcd5' := \u03bb x, fderiv_corrugated_map N hN \u03b3_C1 (\ud835\udcd5.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' \u2294 L.p.span_v)),\n  apply h.hK\u2080.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 [\ud835\udcd5'],\n    erw [fderiv_\ud835\udcd5', 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 \u27e8l, rfl\u27e9,\n    rw [(D \ud835\udcd5'.f x).map_smul, (\ud835\udcd5'.\u03c6 x).map_smul],\n    apply congr_arg,\n    dsimp [\ud835\udcd5'],\n    erw [fderiv_\ud835\udcd5', L.p.update_v, continuous_linear_map.add_apply, L.p.update_v],\n    refl }\nend\n\nlemma improve_step_formal_sol :\n  \u2200\u1da0 N in at_top, \u2200 t, (L.improve_step h N t).is_formal_sol R :=\nbegin\n  set \u03b3 := L.loop h,\n  have \u03b3_cont : continuous \u21bf(\u03bb t x, \u03b3 t x) := (L.nice h).smooth.continuous,\n    have \u03b3_C1 : \ud835\udc9e 1 \u21bf(\u03b3 1) := ((L.nice h).smooth.comp (cont_diff_prod_mk_right 1)).of_le le_top,\n  set K := (\u03bb p : E \u00d7 \u211d \u00d7 \u211d, (p.1, \ud835\udcd5.f p.1, L.p.update (\ud835\udcd5.\u03c6 p.1) (L.loop h p.2.1 p.1 p.2.2))) '' (L.K\u2081 \u00d7\u02e2 (I \u00d7\u02e2 I)),\n  have K_cpt : is_compact K,\n  { refine (L.hK\u2081.prod (is_compact_Icc.prod is_compact_Icc)).image _,\n    refine continuous_fst.prod_mk (\ud835\udcd5.f_diff.continuous.fst'.prod_mk _ ),\n    apply L.p.continuous_update \ud835\udcd5.\u03c6_diff.continuous.fst',\n    change continuous (\u21bf(L.loop h) \u2218 (\u03bb (g : E \u00d7 \u211d \u00d7 \u211d), (g.snd.fst, g.fst, g.snd.snd))),\n    exact (L.loop_smooth h).continuous.comp\u2083 continuous_snd.fst continuous_fst continuous_snd.snd },\n  have K_sub : K \u2286 R,\n  { rintros _ \u27e8\u27e8x, t, s\u27e9, \u27e8x_in, t_in, s_in\u27e9, rfl\u27e9,\n    exact (L.nice h).mem_\u03a9 x t s },\n  obtain \u27e8\u03b5, \u03b5_pos, h\u03b5\u27e9 : \u2203 \u03b5, 0 < \u03b5 \u2227 metric.thickening \u03b5 K \u2286 R,\n    from  K_cpt.exists_thickening_subset_open h.h_op K_sub,\n\n  apply ((corrugation.c0_small_on L.hK\u2081 (L.nice h).t_le_zero (L.nice h).t_ge_one \u03b3_cont \u03b5_pos).and $\n         remainder_c0_small_on L.\u03c0 L.hK\u2081 \u03b3_C1 \u03b5_pos).mono,\n  rintros N \u27e8H, H'\u27e9 t x,\n  by_cases hxK\u2081 : x \u2208 L.K\u2081,\n  { apply h\u03b5,\n    rw metric.mem_thickening_iff,\n    refine \u27e8(x, \ud835\udcd5.f x, L.p.update (\ud835\udcd5.\u03c6 x) $ L.loop h (smooth_step t*L.\u03c1 x) x $ N * L.\u03c0 x), _, _\u27e9,\n    { simp only [hxK\u2081, formal_sol.to_jet_sec_eq_coe, exists_prop, mem_set_of_eq, eq_self_iff_true, true_and, K],\n      exact \u27e8\u27e8x, smooth_step t * L.\u03c1 x, int.fract (N * L.\u03c0 x)\u27e9,\n            \u27e8hxK\u2081, unit_interval.mul_mem (smooth_step.mem t) (L.\u03c1_mem x),\n              unit_interval.fract_mem _\u27e9, by simp only [loop.fract_eq]\u27e9 },\n    { simp only [h, improve_step_apply_f, formal_sol.to_jet_sec_eq_coe, improve_step_apply_\u03c6],\n      rw [prod.dist_eq, max_lt_iff, prod.dist_eq, max_lt_iff],\n      refine \u27e8by simpa using \u03b5_pos, _, _\u27e9 ; dsimp only ; rw dist_self_add_left,\n      { exact (bu_lt _ _ $ H _ hxK\u2081 _) },\n      { exact (bu_lt _ _ $ H' _ hxK\u2081) } } },\n  { rw [show ((L.improve_step h N) t).f x = \ud835\udcd5.f x,\n          from congr_arg prod.fst $ improve_step_rel_compl_K\u2081 h N hxK\u2081 t,\n        show ((L.improve_step h N) t).\u03c6 x = \ud835\udcd5.\u03c6 x,\n          from congr_arg prod.snd $ improve_step_rel_compl_K\u2081 h N hxK\u2081 t],\n    exact \ud835\udcd5.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 \u211d E] [finite_dimensional \u211d F]\n  {R : rel_loc E F} (h_op : is_open R) (h_ample : R.is_ample)\nvariables (L : landscape E)\nvariables {\u03b5 : \u211d} (\u03b5_pos : 0 < \u03b5)\n\ninclude h_op h_ample \u03b5_pos\n\n/--\nHomotopy of formal solutions obtained by successive corrugations in some landscape `L` to improve a\nformal solution `\ud835\udcd5` until it becomes holonomic near `L.K\u2080`.\n-/\nlemma rel_loc.formal_sol.improve (\ud835\udcd5 : formal_sol R)\n  (h_hol : \u2200\u1da0 x near L.C, \ud835\udcd5.is_holonomic_at x) :\n  \u2203 H : htpy_jet_sec E F,\n    (\u2200\u1da0 t near Iic 0, H t = \ud835\udcd5) \u2227\n    (\u2200\u1da0 t near Ici 1, H t = H 1) \u2227\n    (\u2200\u1da0 x near L.C, \u2200 t, H t x = \ud835\udcd5 x ) \u2227\n    (\u2200 x, x \u2209 L.K\u2081 \u2192 \u2200 t, H t x = \ud835\udcd5 x) \u2227\n    (\u2200 x t, \u2016(H t).f x - \ud835\udcd5.f x\u2016 \u2264 \u03b5) \u2227\n    (\u2200 t, (H t).is_formal_sol R) \u2227\n    (\u2200\u1da0 x near L.K\u2080, (H 1).is_holonomic_at x) :=\nbegin\n  let n := finrank \u211d E,\n  let e := fin_basis \u211d E,\n  let E' := e.flag,\n  suffices : \u2200 k : fin (n + 1), \u2200 \u03b4 > (0 : \u211d), \u2203 H : htpy_jet_sec E F,\n    (\u2200\u1da0 t near Iic 0, H t = \ud835\udcd5) \u2227\n    (\u2200\u1da0 t near Ici 1, H t = H 1) \u2227\n    (\u2200\u1da0 x near L.C, \u2200 t, H t x = \ud835\udcd5 x ) \u2227\n    (\u2200 x, x \u2209 L.K\u2081 \u2192 \u2200 t, H t x = \ud835\udcd5 x) \u2227\n    (\u2200 x t, \u2016(H t).f x - \ud835\udcd5.f x\u2016 \u2264 \u03b4) \u2227\n    (\u2200 t, (H t).is_formal_sol R) \u2227\n    (\u2200\u1da0 x near L.K\u2080, (H 1).is_part_holonomic_at (E' k) x),\n  { simpa only [show E' (fin.last n) = \u22a4, from e.flag_last, jet_sec.is_part_holonomic_top] using\n      this (fin.last n) \u03b5 \u03b5_pos },\n  clear \u03b5_pos \u03b5,\n  intro k,\n  apply fin.induction_on k ; clear k,\n  { intros \u03b4 \u03b4_pos,\n    use \ud835\udcd5.to_jet_sec.const_htpy,\n    simp [show E' 0 = \u22a5, from e.flag_zero, le_of_lt \u03b4_pos] },\n  { rintros k HH \u03b4 \u03b4_pos,\n    rcases HH (\u03b4/2) (half_pos \u03b4_pos) with \u27e8H, hH\u2080, hH\u2081, hHC, hHK\u2081, hHc0, hH_sol, hH_hol\u27e9, 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\u2081 : formal_sol R := (hH_sol 1).formal_sol,\n    have h_span : S.E' \u2294 S.p.span_v = E' k.succ := e.flag_span_succ k,\n    have acc : S.accepts R H\u2081 :=\n    { h_op := h_op,\n      hK\u2080 := begin\n        apply hH_hol.mono,\n        intros x hx,\n        dsimp [S],\n        convert hx,\n        rw [\u2190 fin.coe_eq_cast_succ, coe_coe]\n      end,\n      h_short := \u03bb x, h_ample.is_short_at H\u2081 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\u2081_rel_C : \u2200\u1da0 (x : E) near S.C, H\u2081 x = \ud835\udcd5 x,\n    { apply hHC.mono,\n      intros x hx,\n      apply hx },\n    have hH\u2081_C : \u2200\u1da0 (x : E) near S.to_landscape.C, H\u2081.is_holonomic_at x,\n    { apply h_hol.congr (formal_sol.is_holonomic_at_congr _ _ _),\n      exact (h_hol.and hH\u2081_rel_C).mono (\u03bb x hx, hx.2.symm) },\n    have hH\u2081_K\u2081 : \u2200 x \u2209 L.K\u2081, H\u2081 x = \ud835\udcd5 x,\n    { intros x hx,\n      apply hHK\u2081 x hx },\n    obtain \u27e8N, \u27e8hN_close, hN_sol\u27e9, hNneq\u27e9 :=\n      (((improve_step_c0_close acc $ half_pos \u03b4_pos).and\n      (improve_step_formal_sol acc)).and $ eventually_ne_at_top (0 :\u211d)).exists,\n    have glue : H 1 = S.improve_step acc N 0,\n    { rw improve_step_rel_t_eq_0,\n      refl  },\n    refine \u27e8H.comp (S.improve_step acc N) glue, _, _, _, _, _, _, _\u27e9,\n    { apply (H.comp_le_0 _ _).mono,\n      intros t ht,\n      rw ht,\n      exact hH\u2080.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\u2081_rel_C.and $ improve_step_rel_C acc N).mono,\n      rintros x \u27e8hx, hx', hx''\u27e9 t,\n      by_cases ht : t \u2264 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\u2081\n      intros x hx t,\n      by_cases ht : t \u2264 1/2,\n      { simp only [ht, hx, hHK\u2081, htpy_jet_sec.comp_of_le, not_false_iff]},\n      { simp only [ht, hx, hH\u2081_K\u2081, improve_step_rel_compl_K\u2081, htpy_jet_sec.comp_of_not_le,\n                   not_false_iff] } },\n    { -- C\u2070-close\n      intros x t,\n      by_cases ht : t \u2264 1/2,\n      { apply le_trans _ (half_le_self $ le_of_lt \u03b4_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 \u2190 add_halves \u03b4,\n        exact norm_sub_le_add_of_le (hN_close _ _) (hHc0 _ _) } },\n    { -- formal solution\n      intros t,\n      by_cases ht : t \u2264 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 [\u2190 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' (\ud835\udcd5 : formal_sol R)\n  (h_hol : \u2200\u1da0 x near L.C, \ud835\udcd5.is_holonomic_at x) :\n  \u2203 H : htpy_formal_sol R,\n    (\u2200\u1da0 t near Iic 0, H t = \ud835\udcd5) \u2227\n    (\u2200\u1da0 t near Ici 1, H t = H 1) \u2227\n    (\u2200\u1da0 x near L.C, \u2200 t, H t x = \ud835\udcd5 x ) \u2227\n    (\u2200 x, x \u2209 L.K\u2081 \u2192 \u2200 t, H t x = \ud835\udcd5 x) \u2227\n    (\u2200 x t, \u2016(H t).f x - \ud835\udcd5.f x\u2016 < \u03b5)  \u2227\n    (\u2200\u1da0 x near L.K\u2080, (H 1).is_holonomic_at x) :=\nbegin\n  rcases \ud835\udcd5.improve h_op h_ample L (half_pos \u03b5_pos) h_hol with \u27e8H, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085, h\u2086, h\u2087\u27e9,\n  exact \u27e8{is_sol := h\u2086, ..H}, h\u2081, h\u2082, h\u2083, h\u2084, \u03bb x t, (h\u2085 x t).trans_lt (half_lt_self \u03b5_pos), h\u2087\u27e9\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 \u00d7 Array Expr :=\n  Expr.withApp e \u03bb e a => (e.constName, a)\n\nend Lean.Expr\n-- End of copied block\n\nnamespace Tactic.SolveSet\n\nsection Lemmas\n\nvariable {\u03b1 : Type u}\n\ndef general_union (l : List (Fintype \u03b1)) : Fintype \u03b1 := List.foldl HasUnion.union \u2205 l\n\ntheorem in_singleton (a : Fintype \u03b1) : a \u2286 general_union [a] :=\n  Fintype.included_union_l _ Fintype.included_refl\n\ntheorem included_of_included_l (a b c : Fintype \u03b1) (h : a \u2286 b) : a \u2286 b \u222a c := sorry\ntheorem included_of_included_r (a b c : Fintype \u03b1) (h : a \u2286 c) : a \u2286 b \u222a c := sorry\n\ntheorem union_included (a b c : Fintype \u03b1) (h : a \u2286 c) (h' : b \u2286 c) : a \u222a b \u2286 c := sorry\n\nend Lemmas\n\nstructure Cache :=\n  \u03b1 : 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 \u03b1) : MetaM \u03b1 := do\n  let Level.succ u _ \u2190 getLevel ty | throwError \"fail\"\n  (m {\u03b1 := ty, univ := u }).run' {}\n\ndef mkApp (f : Name) (args : Array Expr) : SolveM Expr := do\n  let c \u2190 read\n  pure $ mkAppN (mkConst f [c.univ]) (#[c.\u03b1] ++ args)\n\ndef addAtom (e : Expr) : SolveM Nat := do\n  let c \u2190 get\n  for i in [:c.numAtoms] do\n    if \u2190 isDefEq e c.atoms[i] then\n      return i\n  modify \u03bb 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 \u2190 get\n  for i in [:c.numAtoms] do\n    if \u2190 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 \u2190 get\n  for i in [:c.numAtoms] do\n    if \u2190 isDefEq e c.atoms[i] then\n      return true\n  return false\n\ndef getAtom (i : Nat) : SolveM Expr := do\n  let c \u2190 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 \u00d7 Expr)) (f g : Nat \u2192 Expr \u2192 SolveM Expr) :\n  SolveM (List (Nat \u00d7 Expr)) := go l r [] >>= pure \u2218 List.reverse\n  where go l r acc :\n    SolveM (List (Nat \u00d7 Expr)) := match (l, r) with\n    | ([], []) => pure acc\n    | ([], (j, e\u1d63) :: r') => do go [] r' <| (j, \u2190 g j e\u1d63) :: acc\n    | ((i, e\u2097) :: l', []) => do go l' [] <| (i, \u2190 f i e\u2097) :: acc\n    | ((i, e\u2097) :: l', (j, e\u1d63) :: r') =>\n      if i < j then do go l' r <| (i, \u2190 f i e\u2097) :: acc\n      else if i == j then do go l' r' <| (i, \u2190 f i e\u2097) :: acc\n      else do go l r' <| (j, \u2190 g j e\u1d63) :: acc\n\npartial def atomize (e : Expr) : SolveM (List (Nat \u00d7 Expr)) :=\n  match e.getAppFnArgs with\n  | (``EmptyCollection.emptyCollection, #[_, _]) => pure []\n  | (``HasUnion.union, #[_, _, e\u2097, e\u1d63]) => do\n    let ml \u2190 atomize e\u2097\n    let mr \u2190 atomize e\u1d63\n    let process_l i included : SolveM Expr := do\n        let a \u2190 getAtom i\n        mkApp ``included_of_included_l #[a, e\u2097, e\u1d63, included]\n    let process_r j included : SolveM Expr := do\n        let a \u2190 getAtom j\n        mkApp ``included_of_included_r #[a, e\u2097, e\u1d63, included]\n    return (\u2190 concat_map_assocs ml mr process_l process_r)\n  | _ => do\n    let i \u2190 addAtom e\n    return [(i, \u2190 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\u2097, e\u1d63]) => do\n      let p\u2097 \u2190 go e\u2097 r\n      let p\u1d63 \u2190 go e\u1d63 r\n      mkApp ``union_included #[e\u2097, e\u1d63, r, p\u2097, p\u1d63]\n    | _ => do\n      let i \u2190 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\u2097, e\u1d63]) => do\n    return (\u2190 check_atoms e\u2097) && (\u2190 check_atoms e\u1d63)\n  | _ => isAtom e\n\ndef solve_sets (l r : Expr) : SolveM Expr := do\n  let atoms := Array.mk\n    <| List.map (\u03bb x => x.2)\n    <| \u2190 atomize r\n  if !(\u2190 check_atoms l) then\n    throwError \"Some atomic formulas on the left aren't included in the right\"\n  let p \u2190 prove_included atoms l r\n  return p\n\nelab \"solve_sets \" : tactic => liftMetaMAtMain \u03bb g => do\n  match (\u2190 instantiateMVars (\u2190 getMVarDecl g).type).getAppFnArgs with\n  | (``HasIncluded.included, #[ty, _, l, r]) =>\n    let ty \u2190 match ty.getAppFnArgs with\n    | (``Fintype, #[a]) => pure a\n    | _ => throwError \"Expected Fintype\"\n    let p \u2190 (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\u2081 (a b c : Fintype \u03b1) : \u2205 \u222a b \u222a a \u2286 a \u222a \u2205 \u222a 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 \u2192 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 : \u2115) := vector Bool n\n\nnamespace bitvec\n\n\n/-- Create a zero bitvector -/\nprotected def zero (n : \u2115) : 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 : \u2115) : bitvec n := sorry\n\n/-- Create a bitvector from another with a provably equal length. -/\nprotected def cong {a : \u2115} {b : \u2115} (h : a = b) : bitvec a \u2192 bitvec b := sorry\n\n/-- `bitvec` specific version of `vector.append` -/\ndef append {m : \u2115} {n : \u2115} : bitvec m \u2192 bitvec n \u2192 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 : \u2115} (x : bitvec n) (i : \u2115) : 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 : \u2115} (x : bitvec n) (i : \u2115) (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 : \u2115} (x : bitvec n) (i : \u2115) : bitvec n := fill_shr x i false\n\n/-- signed shift right -/\ndef sshr {m : \u2115} : bitvec m \u2192 \u2115 \u2192 bitvec m := sorry\n\n/-! ### Bitwise operations -/\n\n/-- bitwise not -/\n/-- bitwise and -/\ndef not {n : \u2115} : bitvec n \u2192 bitvec n := vector.map bnot\n\n/-- bitwise or -/\ndef and {n : \u2115} : bitvec n \u2192 bitvec n \u2192 bitvec n := vector.map\u2082 band\n\n/-- bitwise xor -/\ndef or {n : \u2115} : bitvec n \u2192 bitvec n \u2192 bitvec n := vector.map\u2082 bor\n\ndef xor {n : \u2115} : bitvec n \u2192 bitvec n \u2192 bitvec n := vector.map\u2082 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 : \u2115} (x : bitvec n) : bitvec n :=\n  let f : Bool \u2192 Bool \u2192 Bool \u00d7 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 : \u2115} (x : bitvec n) (y : bitvec n) (c : Bool) : bitvec (n + 1) :=\n  let f : Bool \u2192 Bool \u2192 Bool \u2192 Bool \u00d7 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 : \u2115} (x : bitvec n) (y : bitvec n) : bitvec n := vector.tail (adc x y false)\n\n/-- Subtract with borrow -/\ndef sbb {n : \u2115} (x : bitvec n) (y : bitvec n) (b : Bool) : Bool \u00d7 bitvec n :=\n  let f : Bool \u2192 Bool \u2192 Bool \u2192 Bool \u00d7 Bool :=\n    fun (x y c : Bool) => (bitvec.carry (!x) y c, bitvec.xor3 x y c);\n  vector.map_accumr\u2082 f x y b\n\n/-- The difference of two bitvectors -/\nprotected def sub {n : \u2115} (x : bitvec n) (y : bitvec n) : bitvec n := prod.snd (sbb x y false)\n\nprotected instance has_zero {n : \u2115} : HasZero (bitvec n) := { zero := bitvec.zero n }\n\nprotected instance has_one {n : \u2115} : HasOne (bitvec n) := { one := bitvec.one n }\n\nprotected instance has_add {n : \u2115} : Add (bitvec n) := { add := bitvec.add }\n\nprotected instance has_sub {n : \u2115} : Sub (bitvec n) := { sub := bitvec.sub }\n\nprotected instance has_neg {n : \u2115} : Neg (bitvec n) := { neg := bitvec.neg }\n\n/-- The product of two bitvectors -/\nprotected def mul {n : \u2115} (x : bitvec n) (y : bitvec n) : bitvec n :=\n  let f : bitvec n \u2192 Bool \u2192 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 : \u2115} : 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 : \u2115} (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 : \u2115} (x : bitvec n) (y : bitvec n) := \u21a5(uborrow x y)\n\ndef ugt {n : \u2115} (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 : \u2115} (x : bitvec n) (y : bitvec n) := \u00acult y x\n\ndef uge {n : \u2115} (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 : \u2115} : bitvec n \u2192 bitvec n \u2192 Bool := sorry\n\n/-- signed less-than proposition -/\n/-- signed greater-than proposition -/\ndef slt {n : \u2115} (x : bitvec n) (y : bitvec n) := \u21a5(sborrow x y)\n\n/-- signed less-than-or-equal-to proposition -/\ndef sgt {n : \u2115} (x : bitvec n) (y : bitvec n) := slt y x\n\n/-- signed greater-than-or-equal-to proposition -/\ndef sle {n : \u2115} (x : bitvec n) (y : bitvec n) := \u00acslt y x\n\ndef sge {n : \u2115} (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 : \u2115) : \u2115 \u2192 bitvec n := sorry\n\n/-- Create a bitvector in the two's complement representation from an `int` -/\nprotected def of_int (n : \u2115) : \u2124 \u2192 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 : \u2115) (b : Bool) : \u2115 := 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) : \u2115 := list.foldl add_lsb 0 v\n\n/-- Return the natural number encoded by the input bitvector -/\nprotected def to_nat {n : \u2115} (v : bitvec n) : \u2115 := bits_to_nat (vector.to_list v)\n\ntheorem bits_to_nat_to_list {n : \u2115} (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 : \u2115} (xs : bitvec m) (b : Bool) :\n    bitvec.to_nat (vector.append xs (b::\u1d65vector.nil)) =\n        bitvec.to_nat xs * bit0 1 + bitvec.to_nat (b::\u1d65vector.nil) :=\n  sorry\n\ntheorem bits_to_nat_to_bool (n : \u2115) :\n    bitvec.to_nat (to_bool (n % bit0 1 = 1)::\u1d65vector.nil) = n % bit0 1 :=\n  sorry\n\ntheorem of_nat_succ {k : \u2115} {n : \u2115} :\n    bitvec.of_nat (Nat.succ k) n =\n        vector.append (bitvec.of_nat k (n / bit0 1)) (to_bool (n % bit0 1 = 1)::\u1d65vector.nil) :=\n  rfl\n\ntheorem to_nat_of_nat {k : \u2115} {n : \u2115} : 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 : \u2115} : bitvec n \u2192 \u2124 := sorry\n\n/-! ### Miscellaneous instances -/\n\nprotected instance has_repr (n : \u2115) : has_repr (bitvec n) := has_repr.mk repr\n\nend bitvec\n\n\nprotected instance bitvec.ult.decidable {n : \u2115} {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 : \u2115} {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 : \u2200 {s : G}, s \u2208 els \u2192 s\u207b\u00b9 \u2208 els)\n  (gen : subgroup.closure (coe els) = (\u22a4 : subgroup G))\n  (nem : els.nonempty)\n  (irr : (1:G) \u2209 els)\n\nvariables {G : Type*} [group G] {S S1 S2 : genset G} {a x y z : G}\n\ninstance : has_mem G (genset G) := \u27e8\u03bb a s, a \u2208 s.els\u27e9\n\ndef genset.adj (S : genset G) (x y : G) := x\u207b\u00b9 * y \u2208 S\n\nlemma shift_adj \u2983x y\u2984 (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 \u2983x y\u2984 (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 := \u03bb x h, S.irr (by { convert h, group }) }\n\ndef left_shift (a : G) : Cay S \u2192g Cay S := \u27e8(*) a, shift_adj\u27e9\n\nlemma shift : reachable (Cay S) x y \u2192 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\u207b\u00b9 :=\nby { symmetry, convert @shift _ _ _ x\u207b\u00b9 _ _ 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\u27e8\u03bb x y, reachable_mp.symm.trans reachable_mp, \u27e81\u27e9\u27e9\n\nlemma covariant : (Cay S).dist (a*x) (a*y) = (Cay S).dist x y :=\nbegin\n  have lem : \u2200 a {x y}, (Cay S).dist (a*x) (a*y) \u2264 (Cay S).dist x y :=\n  by { intros a x y, obtain \u27e8p,hp\u27e9 := Cay.connected.exists_walk_of_dist x y,\n    rw [\u2190hp,\u2190walk.length_map], exact dist_le (p.map (left_shift a)) },\n  apply le_antisymm (lem a), convert lem a\u207b\u00b9, 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 \u2208 (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 \u2264 distorsion S1 S2 :=\nbegin\n  refine finset.le_max_of_mem _ distorsion_spec,\n  rw [finset.mem_image], refine \u27e8x\u207b\u00b9 * y, h, _\u27e9, convert covariant, group\nend\n\nlemma lipschitz : (Cay S2).dist x y <= (distorsion S1 S2) * (Cay S1).dist x y :=\nbegin\n  obtain \u27e8p,hp\u27e9 := (@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# \u6c34\u6392\u5e8f\u62fc\u56fe\u7684\u95ee\u9898\u5b9a\u4e49\n-/\n\n/-!\n## \u5b9a\u4e49\uff1a\u989c\u8272\n-/\n\nabbrev Color (m : Nat) := Fin m\n\n/-!\n## \u5b9a\u4e49\uff1a\u8bd5\u7ba1\n-/\n\nstructure Tube (m h : Nat) where\n  val : List (Color m)\n  h_volume : val.length \u2264 h\n\nnamespace Tube\n\nvariable (t : Tube m h)\n\ndef length : Nat := t.val.length\n\ndef sameColorAux : List (Color m) \u2192 Prop\n| [] => True\n| [_] => true\n| c\u2081 :: c\u2082 :: cs => c\u2081 = c\u2082 \u2227 sameColorAux (c\u2082 :: 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 : \u00act.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 := \u27e8 [], by simp \u27e9 \n\ndef fullSameColor (i : Fin m) : Tube m h := \u27e8 List.replicate h i, by simp \u27e9 \n\nend Tube\n\n/-!\n## \u5b9a\u4e49\uff1a\u8bd5\u7ba1\u7ec4\n\n\u5173\u952e\u7c7b\u578b\uff1a\n\n- `ColorPerm`: \u8bd5\u7ba1\u989c\u8272\u6253\u4e71\u7684\u547d\u9898\u3002\n- `ColorComplete`: \u8bd5\u7ba1\u989c\u8272\u5b8c\u5907\u7684\u547d\u9898\u3002\n- `Tubes`: \u8bd5\u7ba1\u7ec4\n-/\n\n/--\n\u5b9e\u9645\u4e0a\u662f\u4e8c\u7ef4\u5217\u8868\u7684\u6253\u4e71\uff0c\u56e0\u800c\u5728\u7b26\u53f7\u4e0a\u9009\u62e9 `~\u00b2`\n-/\ndef colorPerm (ts\u2081 ts\u2082 : List (Tube m h)) : Prop :=\n  let f\u2081 := ts\u2081.map Tube.val |>.join\n  let f\u2082 := ts\u2082.map Tube.val |>.join\n  f\u2081 ~ f\u2082\n\ninfixl:50 \" ~\u00b2 \" => colorPerm\n\ntheorem colorPerm.mod_h :\n  \u2200 {ts\u2081 ts\u2082 : List (Tube m h)} {i : Fin m}, ts\u2081 ~\u00b2 ts\u2082 \u2192\n    let f\u2081 := ts\u2081.map Tube.val |>.join ;\n    let f\u2082 := ts\u2082.map Tube.val |>.join ;\n    (f\u2081.count i) % h = (f\u2082.count i) % h := by\n  intro ts\u2081 ts\u2082 i h\n  simp_all [List.join, List.count, List.countp, colorPerm]\n\n/--\n\u8bd5\u7ba1\u989c\u8272\u662f\u5426\u5b8c\u5907\u3002\u6709\u4e09\u79cd\u4e0d\u540c\u60c5\u51b5\uff1a\n\n- \u7a7a\u5217\u8868 \u662f\u5b8c\u5907\u7684\n- \u5b8c\u5907\u5217\u8868 \u52a0\u4e0a \u88c5\u6ee1\u540c\u4e00\u79cd\u989c\u8272\u7684\u8bd5\u7ba1 \u662f\u5b8c\u5907\u7684\n- \u5b8c\u5907\u5217\u8868 \u6253\u4e71\u989c\u8272\u987a\u5e8f\u662f\u5b8c\u5907\u7684\n-/\ninductive ColorComplete : List (Tube m h) \u2192 Prop\n| nil : ColorComplete []\n| cons : ColorComplete ts \u2192 ColorComplete ((.fullSameColor i)::ts)\n| perm : ColorComplete ts \u2192 ts ~\u00b2 ts' \u2192 ColorComplete ts'\n\ntheorem ColorComplete.mod_h : \u2200 {ts : List (Tube m h)}, ColorComplete ts \u2192 \n  let f := ts.map Tube.val |>.join ;\n  \u2200 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 \u2208 ts.val\n\ndef sorted : Prop :=\n  \u2200 t, t \u2208 ts \u2192 t.sameColor \u2227 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## \u5b9a\u4e49\uff1a\u503e\u5012\u8fc7\u7a0b\n-/\n\n/-- \u63cf\u8ff0\u503e\u5012\u8fc7\u7a0b -/\nstructure PourStep (n : Nat) where\n  source : Fin n\n  sink : Fin n\n\n/-- \u8fdb\u884c\u4e00\u6b21\u503e\u5012 -/\ndef PourStep.pour (ts : Tubes m h n) (s : PourStep n) : Tubes m h n :=\n  let t\u2081 := ts.get s.source\n  let t\u2082 := ts.get s.sink\n  let (t\u2081', t\u2082') := match t\u2081, t\u2082 with\n  | \u27e8[], _\u27e9 , _ => (t\u2081, t\u2082)\n  | \u27e8c::cs, h\u2081\u27e9 , \u27e8[], h\u2082\u27e9 => \n    -- \u4e00\u4e9b\u5b9a\u7406\u8bc1\u660e\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\u2081\n    have hge : h \u2265 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\u2081\n    have hle : cs.length \u2264 h      := Nat.le_of_lt hlt\n    have hle' : [c].length \u2264 h    := hge\n    (\u27e8cs, hle\u27e9, \u27e8[c], hle'\u27e9)\n  | \u27e8c\u2081::cs\u2081, h\u2081\u27e9, \u27e8c\u2082::cs\u2082, h\u2082\u27e9 =>\n    if c\u2081 = c\u2082 then\n      if h' : (c\u2082::cs\u2082).length + 1 \u2264 h then\n        -- \u4e00\u4e9b\u5b9a\u7406\u8bc1\u660e\n        have hlt : cs\u2081.length < h             := Nat.lt_of_lt_of_le (cs\u2081.length_cons_lt c\u2081) h\u2081\n        have hle : cs\u2081.length \u2264 h             := Nat.le_of_lt hlt\n        have hle' : (c\u2081::c\u2082::cs\u2082).length \u2264 h  := by simp only [List.length_cons c\u2081 (c\u2082::cs\u2082), h']\n        (\u27e8cs\u2081, hle\u27e9, \u27e8c\u2081::c\u2082::cs\u2082, hle'\u27e9)\n      else \n        (\u27e8c\u2081::cs\u2081, h\u2081\u27e9, \u27e8c\u2082::cs\u2082, h\u2082\u27e9)\n    else \n      (\u27e8c\u2081::cs\u2081, h\u2081\u27e9, \u27e8c\u2082::cs\u2082, h\u2082\u27e9)\n  ts\n  |>.set s.source t\u2081' (by sorry)\n  |>.set s.sink t\u2082' sorry\n  \n/-- \u8fdb\u884c\u4e00\u7cfb\u5217\u503e\u5012\u8fc7\u7a0b -/\ndef Tubes.apply (ts : Tubes m h n) (ss : List (PourStep n)) : Tubes m h n :=\n  ss.foldl (\u03bb acc s => s.pour acc) ts\n\n/-!\n## \u5b9a\u4e49\uff1a\u6c34\u6392\u5e8f\u95ee\u9898\n\n\u5173\u952e\u7c7b\u578b\uff1a\n\n- `Puzzle`: \u95ee\u9898\u7684\u5b9a\u4e49\uff0c\u5305\u62ec \u521d\u59cb\u72b6\u6001\u53ca\u7ea6\u675f\u3001\u7a7a\u8bd5\u7ba1\u6570\u91cf \u7b49\u914d\u7f6e\u3002\n- `Solution`: \u95ee\u9898\u7684\u89e3\uff0c\u5305\u542b\u4e00\u7cfb\u5217\u6b65\u9aa4\uff0c\u4ee5\u53ca\u6b63\u786e\u6027\u8bc1\u660e\u3002\n\n\u76ee\u6807\u5373\u4e3a\u5bfb\u627e\u5230\u4e00\u4e2a\u51fd\u6570\u5177\u6709 `(p : Puzzle m h n) \u2192 Solution p` \u7684\u7c7b\u578b\u3002\n-/\n\n/-- \u95ee\u9898\u5b9a\u4e49 -/\nstructure Puzzle (m h n : Nat) where\n  /-- \u521d\u59cb\u72b6\u6001 -/\n  initial : Tubes m h n\n  /-- \u7a7a\u8bd5\u7ba1\u7684\u6570\u91cf -/\n  k : Nat := 0\n  /-- \u521d\u59cb\u72b6\u6001\u8981\u6c42\u6240\u6709\u8bd5\u7ba1\u4e3a\u6ee1\u7684 -/\n  h_full : \u2200 t, t \u2208 initial \u2192 t.isFull\n\n/-- \u95ee\u9898\u89e3\u7684\u5b9a\u4e49 -/\nstructure Solution (p : Puzzle m h n) where\n  /-- \u4e00\u7cfb\u5217\u89e3\u7684\u6b65\u9aa4 -/\n  steps : List (PourStep n)\n  /-- \u6b63\u786e\u6027\u8bc1\u660e -/\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 : \u2115) :=\n  n <\n      bit0\n        (bit0\n          (bit0\n            (bit0\n              (bit0 (bit0 (bit0 (bit0 (bit0 (bit0 (bit0 (bit1 (bit1 (bit0 (bit1 1)))))))))))))) \u2228\n    bit1\n          (bit1\n            (bit1\n              (bit1\n                (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit1 (bit0 (bit1 1)))))))))))))) <\n        n \u2227\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 : \u2115)\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 : \u2115)\n    (h\u2081 :\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\u2082 :\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\u2081, right := h\u2082 }\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 : \u2115\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 \u2264 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 \u2264 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 : \u2115) : char :=\n  dite (is_valid_char n) (fun (h : is_valid_char n) => mk n h)\n    fun (h : \u00acis_valid_char n) => mk 0 sorry\n\ndef to_nat (c : char) : \u2115 := val c\n\ntheorem eq_of_veq {c : char} {d : char} : val c = val d \u2192 c = d := sorry\n\ntheorem veq_of_eq {c : char} {d : char} : c = d \u2192 val c = val d := sorry\n\ntheorem ne_of_vne {c : char} {d : char} (h : val c \u2260 val d) : c \u2260 d :=\n  fun (h' : c = d) => absurd (veq_of_eq h') h\n\ntheorem vne_of_ne {c : char} {d : char} (h : c \u2260 d) : val c \u2260 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 {\u03b1 : Type u} [topological_space \u03b1] \nvariables (F : presheaf_of_rings \u03b1) (x : \u03b1)\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 {\u03b1 : Type u} [topological_space \u03b1] \nparameters (F : presheaf_of_rings \u03b1) (x : \u03b1)\n\n-- Add.\n\nprivate def stalk_of_rings_add_aux : \nstalk.elem F.to_presheaf x \u2192 \nstalk.elem F.to_presheaf x \u2192 \nstalk F.to_presheaf x :=\n\u03bb s t, \n\u27e6{U := s.U \u2229 t.U, \nHxU := \u27e8s.HxU, t.HxU\u27e9, \ns := F.res s.U _ (set.inter_subset_left _ _) s.s + \n     F.res t.U _ (set.inter_subset_right _ _) t.s}\u27e7\n\ninstance stalk_of_rings_has_add : has_add (stalk_of_rings F x) := \n{ add := quotient.lift\u2082 (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 \u27e8U1, \u27e8HxU1, \u27e8HU1a1U, HU1b1U, HresU1\u27e9\u27e9\u27e9,\n    rcases H2 with \u27e8U2, \u27e8HxU2, \u27e8HU2a2U, HU2b2U, HresU2\u27e9\u27e9\u27e9,\n    apply quotient.sound,\n    use [U1 \u2229 U2, \u27e8HxU1, HxU2\u27e9],\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 \u2229 U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) =\n        (F'.res U1 (U1 \u2229 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 \u2229 U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) =\n        (F'.res U2 (U1 \u2229 U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s)))\n    := by rw HresU2,\n    repeat { rw \u2190(presheaf.Hcomp' F') at HresU1' },\n    repeat { rw \u2190(presheaf.Hcomp' F') at HresU2' },\n    repeat { rw \u2190(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\u2083 a b c _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9 \u27e8W, HxW, sW\u27e9,\n    have HUVWsub : U \u2229 V \u2229 W \u2286 U \u2229 (V \u2229 W) \n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8HxU, \u27e8HxV, HxW\u27e9\u27e9,\n    apply quotient.sound,\n    use [U \u2229 V \u2229 W, \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9],\n    use [set.subset.refl _, HUVWsub],\n    dsimp,\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { erw \u2190presheaf.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\u2082 a b _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9,\n    apply quotient.sound,\n    have HUVUV : U \u2229 V \u2286 U \u2229 V := \u03bb x HxUV, HxUV,\n    have HUVVU : U \u2229 V \u2286 V \u2229 U := \u03bb x \u27e8HxU, HxV\u27e9, \u27e8HxV, HxU\u27e9,\n    use [U \u2229 V, \u27e8HxU, HxV\u27e9, HUVUV, HUVVU],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.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\u27e6{U := opens.univ, HxU := trivial, s:= 0}\u27e7\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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUsub : U \u2286 opens.univ \u2229 U := \u03bb x HxU, \u27e8trivial, HxU\u27e9,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUsub : U \u2286 U \u2229 opens.univ := \u03bb x HxU, \u27e8HxU, trivial\u27e9,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { erw \u2190presheaf.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 \u2192 \nstalk F.to_presheaf x :=\n\u03bb s, \u27e6{U := s.U, HxU := s.HxU, s := -s.s}\u27e7\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 \u27e8U, \u27e8HxU, \u27e8HUaU, HUbU, HresU\u27e9\u27e9\u27e9,\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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUUU : U \u2286 U \u2229 U := \u03bb x HxU, \u27e8HxU, HxU\u27e9,\n    have HUuniv : U \u2286 opens.univ := \u03bb x HxU, trivial,\n    use [U, HxU, HUUU, HUuniv],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.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 \u2192 \nstalk.elem F.to_presheaf x \u2192 \nstalk F.to_presheaf x :=\n\u03bb s t, \n\u27e6{U := s.U \u2229 t.U, \nHxU := \u27e8s.HxU, t.HxU\u27e9, \ns := F.res s.U _ (set.inter_subset_left _ _) s.s * \n     F.res t.U _ (set.inter_subset_right _ _) t.s}\u27e7\n\ninstance stalk_of_rings_has_mul : has_mul (stalk_of_rings F x) := \n{ mul := quotient.lift\u2082 (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 \u27e8U1, \u27e8HxU1, \u27e8HU1a1U, HU1b1U, HresU1\u27e9\u27e9\u27e9,\n    rcases H2 with \u27e8U2, \u27e8HxU2, \u27e8HU2a2U, HU2b2U, HresU2\u27e9\u27e9\u27e9,\n    apply quotient.sound,\n    use [U1 \u2229 U2, \u27e8HxU1, HxU2\u27e9],\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 \u2229 U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) =\n        (F'.res U1 (U1 \u2229 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 \u2229 U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) =\n        (F'.res U2 (U1 \u2229 U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s)))\n    := by rw HresU2,\n    repeat { rw \u2190(presheaf.Hcomp' F') at HresU1' },\n    repeat { rw \u2190(presheaf.Hcomp' F') at HresU2' },\n    repeat { rw \u2190(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\u2083 a b c _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9 \u27e8W, HxW, sW\u27e9,\n    have HUVWsub : U \u2229 V \u2229 W \u2286 U \u2229 (V \u2229 W) \n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8HxU, \u27e8HxV, HxW\u27e9\u27e9,\n    apply quotient.sound,\n    use [U \u2229 V \u2229 W, \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9],\n    use [set.subset.refl _, HUVWsub],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw \u2190presheaf.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\u2082 a b _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9,\n    apply quotient.sound,\n    have HUVUV : U \u2229 V \u2286 U \u2229 V := \u03bb x HxUV, HxUV,\n    have HUVVU : U \u2229 V \u2286 V \u2229 U := \u03bb x \u27e8HxU, HxV\u27e9, \u27e8HxV, HxU\u27e9,\n    use [U \u2229 V, \u27e8HxU, HxV\u27e9, HUVUV, HUVVU],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw \u2190presheaf.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\u27e6{U := opens.univ, HxU := trivial, s:= 1}\u27e7\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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUsub : U \u2286 opens.univ \u2229 U := \u03bb x HxU, \u27e8trivial, HxU\u27e9,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw \u2190presheaf.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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUsub : U \u2286 U \u2229 opens.univ := \u03bb x HxU, \u27e8HxU, trivial\u27e9,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw \u2190presheaf.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\u2083 a b c _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9 \u27e8W, HxW, sW\u27e9,\n    have HUVWsub : U \u2229 V \u2229 W \u2286 U \u2229 (V \u2229 W) \n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8HxU, \u27e8HxV, HxW\u27e9\u27e9,\n    have HUVWsub2 : U \u2229 V \u2229 W \u2286 U \u2229 V \u2229 (U \u2229 W)\n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8\u27e8HxU, HxV\u27e9, \u27e8HxU, HxW\u27e9\u27e9,\n    apply quotient.sound,\n    use [U \u2229 V \u2229 W, \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, 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 \u2190presheaf.Hcomp' },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.Hcomp' },\n    rw mul_add,\n  end,\n  right_distrib := \n  begin\n    intros a b c,\n    refine quotient.induction_on\u2083 a b c _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9 \u27e8W, HxW, sW\u27e9,\n    have HUVWrfl : U \u2229 V \u2229 W \u2286 U \u2229 V \u2229 W := \u03bb x Hx, Hx,\n    have HUVWsub : U \u2229 V \u2229 W \u2286 U \u2229 W \u2229 (V \u2229 W)\n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8\u27e8HxU, HxW\u27e9, \u27e8HxV, HxW\u27e9\u27e9,\n    apply quotient.sound,\n    use [U \u2229 V \u2229 W, \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, 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 \u2190presheaf.Hcomp' },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.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 {\u03b1 : Type u} [topological_space \u03b1] \nvariables (F : presheaf_of_rings \u03b1) (x : \u03b1)\n\nvariables (S : Type w) [comm_ring S] [decidable_eq S]\nvariables (G : \u03a0 U, F.F U \u2192 S) [HG : \u03a0 U, is_ring_hom (G U)]\nvariables (hg : \u2200 U V (H : U \u2286 V) r, G U (F.res V U H r) = G V r)\n\ndef to_stalk (U : opens \u03b1) (HxU : x \u2208 U) (s : F.F U) : stalk_of_rings F x \n:= \u27e6{U := U, HxU := HxU, s := s}\u27e7\n\nlemma to_stalk.is_ring_hom (U) (HxU) : is_ring_hom (to_stalk F x U HxU) :=\n{ map_one := quotient.sound $ \u27e8U, HxU, set.subset.refl _, \u03bb 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\u27e9,\n  map_add := \u03bb y z, quotient.sound $ \u27e8U, HxU, set.subset.refl _, \u03bb x Hx, \u27e8Hx, Hx\u27e9,\n    begin\n        erw \u2190(F.res_is_ring_hom _ _ _).map_add,\n        erw presheaf.Hcomp',\n    end\u27e9, \n  map_mul := \u03bb y z, quotient.sound $ \u27e8U, HxU, set.subset.refl _, \u03bb x Hx, \u27e8Hx, Hx\u27e9,\n    begin\n        erw \u2190(F.res_is_ring_hom _ _ _).map_mul,\n        erw presheaf.Hcomp',\n    end\u27e9 }\n\ninclude hg\n\nprotected def to_stalk.rec (y : stalk_of_rings F x) : S :=\nquotient.lift_on' y (\u03bb Us, G Us.1 Us.3) \n(\u03bb \u27e8U, HxU, s\u27e9 \u27e8V, HxV, t\u27e9 \u27e8W, HxW, HWU, HWV, Hres\u27e9,\nby dsimp; rw [\u2190hg W U HWU s, \u2190hg W V HWV t, Hres])\n\n\ntheorem to_stalk.rec_to_stalk (U HxU) \n: (to_stalk.rec F x S G hg) \u2218 (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 \u25b8 rfl,\n  map_add := \u03bb y z, quotient.induction_on\u2082' y z $ \u03bb \u27e8U, HxU, s\u27e9 \u27e8V, HxV, t\u27e9,\n    begin\n        show G (U \u2229 V) (_ + _) = G _ _ + G _ _,\n        rw (HG (U \u2229 V)).map_add,\n        rw \u2190hg (U \u2229 V) U (set.inter_subset_left _ _),\n        rw \u2190hg (U \u2229 V) V (set.inter_subset_right _ _),\n    end,\n  map_mul := \u03bb y z, quotient.induction_on\u2082' y z $ \u03bb \u27e8U, HxU, s\u27e9 \u27e8V, HxV, t\u27e9,\n    begin\n        show G (U \u2229 V) (_ * _) = G _ _ * G _ _,\n        rw (HG (U \u2229 V)).map_mul,\n        rw \u2190hg (U \u2229 V) U (set.inter_subset_left _ _),\n        rw \u2190hg (U \u2229 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\u2080\nvariables p q r : Prop\nvariables h : p \u2227 q \u2228 p \u2227 r\ninclude h\nexample : p \u2227 p :=\nby tauto\n\nend tauto\u2080\n\nsection tauto\u2081\nvariables \u03b1 : Type\nvariables p q r : \u03b1 \u2192 Prop\nvariables h : (\u2203 x, p x \u2227 q x) \u2228 (\u2203 x, p x \u2227 r x)\ninclude h\nexample : \u2203 x, p x :=\nby tauto\n\nend tauto\u2081\n\nsection tauto\u2082\nvariables \u03b1 : Type\nvariables x : \u03b1\nvariables p q r : \u03b1 \u2192 Prop\nvariables h\u2080 : (\u2200 x, p x \u2192 q x \u2192 r x) \u2228 r x\nvariables h\u2081 : p x\nvariables h\u2082 : q x\n\ninclude h\u2080 h\u2081 h\u2082\nexample : \u2203 x, r x :=\nby tauto\n\nend tauto\u2082\n\nsection tauto\u2083\n\n\nexample (p : Prop) : p \u2227 true \u2194 p := by tauto\nexample (p : Prop) : p \u2228 false \u2194 p := by tauto\nexample (p q r : Prop) [decidable p] [decidable r] : p \u2228 (q \u2227 r) \u2194 (p \u2228 q) \u2227 (r \u2228 p \u2228 r) := by tauto\nexample (p q r : Prop) [decidable q] [decidable r] : p \u2228 (q \u2227 r) \u2194 (p \u2228 q) \u2227 (r \u2228 p \u2228 r) := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : \u00ac (p \u2194 q)) (h' : \u00ac p) : q := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : \u00ac (p \u2194 q)) (h' : p) : \u00ac q := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : \u00ac (p \u2194 q)) (h' : q) : \u00ac p := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : \u00ac (p \u2194 q)) (h' : \u00ac q) : p := by tauto\nexample (p q : Prop) [decidable q] [decidable p] (h : \u00ac (p \u2194 q)) (h' : \u00ac q) (h'' : \u00ac p) : false := by tauto\nexample (p q r : Prop) [decidable q] [decidable p] (h : p \u2194 q) (h' : r \u2194 q) (h'' : \u00ac r) : \u00ac p := by tauto\nexample (p q r : Prop) (h : p \u2194 q) (h' : r \u2194 q) : p \u2194 r :=\nby tauto!\nexample (p q r : Prop) (h : \u00ac p = q) (h' : r = q) : p \u2194 \u00ac r := by tauto!\n\nsection modulo_symmetry\nvariables {p q r : Prop} {\u03b1 : Type} {x y : \u03b1}\nvariables (h : x = y)\nvariables (h'' : (p \u2227 q \u2194 q \u2228 r) \u2194 (r \u2227 p \u2194 r \u2228 q))\ninclude h\ninclude h''\nexample (h' : \u00ac y = x) : p \u2227 q := by tauto\nexample (h' : p \u2227 \u00ac y = x) : p \u2227 q := by tauto\nexample : y = x := by tauto\nexample (h' : \u00ac x = y) : p \u2227 q := by tauto\nexample : x = y := by tauto\n\nend modulo_symmetry\n\nend tauto\u2083\n\nsection wlog\n\nexample {x y : \u2115} (a : x = 1) : true :=\nbegin\n  suffices : false, trivial,\n  wlog h : x = y,\n  { guard_target x = y \u2228 y = x,\n    admit },\n  { guard_hyp h := x = y,\n    guard_hyp a := x = 1,\n    admit }\nend\n\nexample {x y : \u2115} : true :=\nbegin\n  suffices : false, trivial,\n  wlog h : x \u2264 y,\n  { guard_hyp h := x \u2264 y,\n    guard_target false,\n    admit }\nend\n\nexample {x y z : \u2115} : true :=\nbegin\n  suffices : false, trivial,\n  wlog : x \u2264 y + z using x y,\n  { guard_target x \u2264 y + z \u2228 y \u2264 x + z,\n    admit },\n  { guard_hyp case := x \u2264 y + z,\n    guard_target false,\n    admit },\nend\n\nexample {x : \u2115} (S\u2080 S\u2081 : set \u2115) (P : \u2115 \u2192 Prop)\n  (h : x \u2208 S\u2080 \u222a S\u2081) : true :=\nbegin\n  suffices : false, trivial,\n  wlog h' : x \u2208 S\u2080 using S\u2080 S\u2081,\n  { guard_target x \u2208 S\u2080 \u2228 x \u2208 S\u2081,\n    admit },\n  { guard_hyp h  := x \u2208 S\u2080 \u222a S\u2081,\n    guard_hyp h' := x \u2208 S\u2080,\n    admit }\nend\n\nexample {n m i : \u2115} {p : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 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 \u2228 p n i m \u2228 p i n m,\n    admit },\n  { guard_hyp case := p n m i,\n    admit }\nend\n\nexample {n m i : \u2115} {p : \u2115 \u2192 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 \u2228 p m \u2228 p i,\n    admit },\n  { guard_hyp case := p n,\n    admit }\nend\n\nexample {n m i : \u2115} {p : \u2115 \u2192 \u2115 \u2192 Prop} {q : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 Prop} : true :=\nbegin\n  suffices : q n m i, trivial,\n  have h : p n i \u2228 p i m \u2228 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 \u2229 (B \u222a C) = (A \u2229 B) \u222a (A \u2229 C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    cases hyp,\n    wlog x_in : x \u2208 B using B C,\n    { assumption },\n    { exact or.inl \u27e8hyp_left, x_in\u27e9 } },\n  { intro hyp,\n    wlog x_in : x \u2208 A \u2229 B using B C,\n    { assumption },\n    { exact \u27e8x_in.left, or.inl x_in.right\u27e9 } }\nend\n\nexample (X : Type) (A B C : set X) : A \u2229 (B \u222a C) = (A \u2229 B) \u222a (A \u2229 C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    wlog x_in : x \u2208 B := hyp.2 using B C,\n    { exact or.inl \u27e8hyp.1, x_in\u27e9 } },\n  { intro hyp,\n    wlog x_in : x \u2208 A \u2229 B := hyp using B C,\n    { exact \u27e8x_in.left, or.inl x_in.right\u27e9 } }\nend\n\nexample (X : Type) (A B C : set X) : A \u2229 (B \u222a C) = (A \u2229 B) \u222a (A \u2229 C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    cases hyp,\n    wlog x_in : x \u2208 B := hyp_right using B C,\n    { exact or.inl \u27e8hyp_left, x_in\u27e9 }, },\n  { intro hyp,\n    wlog x_in : x \u2208 A \u2229 B := hyp using B C,\n    { exact \u27e8x_in.left, or.inl x_in.right\u27e9 } }\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 \u22a2,\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 (\u03b1 : Sort*) (L\u2081 L\u2082 L\u2083 : list \u03b1)\n  (H : L\u2081 ++ L\u2082 = L\u2083) : true :=\nbegin\n  have : L\u2081 ++ L\u2082 = L\u2082,\n  { generalize_hyp h : L\u2081 ++ L\u2082 = L at H,\n    induction L with hd tl ih,\n    case list.nil\n    { tactic.cleanup,\n      change list.nil = L\u2083 at H,\n      admit },\n    case list.cons\n    { change list.cons hd tl = L\u2083 at H,\n      admit } },\n  trivial\nend\n\nsection convert\nopen set\n\nvariables {\u03b1 \u03b2 : Type}\nlocal attribute [simp]\nprivate lemma singleton_inter_singleton_eq_empty {x y : \u03b1} :\n  ({x} \u2229 {y} = (\u2205 : set \u03b1)) \u2194 x \u2260 y :=\nby simp [singleton_inter_eq_empty]\n\nexample {f : \u03b2 \u2192 \u03b1} {x y : \u03b1} (h : x \u2260 y) : f \u207b\u00b9' {x} \u2229 f \u207b\u00b9' {y} = \u2205 :=\nbegin\n  have : {x} \u2229 {y} = (\u2205 : set \u03b1) := by simpa using h,\n  convert preimage_empty,\n  rw [\u2190preimage_inter,this],\nend\n\nend convert\n\nsection rcases\n\nuniverse u\nvariables {\u03b1 \u03b2 \u03b3 : Type u}\n\nexample (x : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3) : true :=\nbegin\n  rcases x with \u27e8a, b, c\u27e9,\n  { guard_hyp a := \u03b1,\n    guard_hyp b := \u03b2,\n    guard_hyp c := \u03b3,\n    trivial }\nend\n\nexample (x : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3) : true :=\nbegin\n  rcases x with \u27e8a, \u27e8b, c\u27e9\u27e9,\n  { guard_hyp a := \u03b1,\n    guard_hyp b := \u03b2,\n    guard_hyp c := \u03b3,\n    trivial }\nend\n\nexample (x : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3) : true :=\nbegin\n  rcases x with \u27e8\u27e8a, b\u27e9, c\u27e9,\n  { guard_hyp a := \u03b1,\n    guard_hyp b := \u03b2,\n    guard_hyp c := \u03b3,\n    trivial }\nend\n\nexample (x : inhabited \u03b1 \u00d7 option \u03b2 \u2295 \u03b3) : true :=\nbegin\n  rcases x with \u27e8\u27e8a\u27e9, _ | b\u27e9 | c,\n  { guard_hyp a := \u03b1, trivial },\n  { guard_hyp a := \u03b1, guard_hyp b := \u03b2, trivial },\n  { guard_hyp c := \u03b3, trivial }\nend\n\nexample (x y : \u2115) (h : x = y) : true :=\nbegin\n  rcases x with _|\u27e8\u27e9|z,\n  { guard_hyp h := nat.zero = y, trivial },\n  { guard_hyp h := nat.succ nat.zero = y, trivial },\n  { guard_hyp z := \u2115,\n    guard_hyp h := z.succ.succ = y, trivial },\nend\n\n-- from equiv.sum_empty\nexample (s : \u03b1 \u2295 empty) : true :=\nbegin\n  rcases s with _ | \u27e8\u27e8\u27e9\u27e9,\n  { guard_hyp s := \u03b1, 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 : \u2115) : 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 : \u2115 \u00d7 \u2115)  (h : X.1 = Y.1) (h : X.2 = Y.2) : X = Y :=\nbegin\n  ext; assumption\nend\n\nexample (X Y : (\u2115 \u2192 \u2115) \u00d7 \u2115)  (h : \u2200 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 : \u2115 \u2192 \u2115 \u00d7 \u2115)  (h : \u2200 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\u2080 s\u2081 : set \u2115) (h : s\u2081 = s\u2080) : s\u2080 = s\u2081 :=\nby { ext1, guard_target x \u2208 s\u2080 \u2194 x \u2208 s\u2081, simp * }\n\nexample (s\u2080 s\u2081 : stream \u2115) (h : s\u2081 = s\u2080) : s\u2080 = s\u2081 :=\nby { ext1, guard_target s\u2080.nth n = s\u2081.nth n, simp * }\n\nexample (s\u2080 s\u2081 : \u2124 \u2192 set (\u2115 \u00d7 \u2115))\n        (h : \u2200 i a b, (a,b) \u2208 s\u2080 i \u2194 (a,b) \u2208 s\u2081 i) : s\u2080 = s\u2081 :=\nbegin\n  ext i \u27e8a,b\u27e9,\n  apply h\nend\n\ndef my_foo {\u03b1} (x : semigroup \u03b1) (y : group \u03b1) : true := trivial\n\nexample {\u03b1 : Type} : true :=\nbegin\n  have : true,\n  { refine_struct (@my_foo \u03b1 { .. } { .. } ),\n      -- 9 goals\n    guard_tags _field mul semigroup, admit,\n      -- case semigroup, mul\n      -- \u03b1 : Type\n      -- \u22a2 \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n    guard_tags _field mul_assoc semigroup, admit,\n      -- case semigroup, mul_assoc\n      -- \u03b1 : Type\n      -- \u22a2 \u2200 (a b c : \u03b1), a * b * c = a * (b * c)\n\n    guard_tags _field mul group, admit,\n      -- case group, mul\n      -- \u03b1 : Type\n      -- \u22a2 \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n    guard_tags _field mul_assoc group, admit,\n      -- case group, mul_assoc\n      -- \u03b1 : Type\n      -- \u22a2 \u2200 (a b c : \u03b1), a * b * c = a * (b * c)\n\n    guard_tags _field one group, admit,\n      -- case group, one\n      -- \u03b1 : Type\n      -- \u22a2 \u03b1\n\n    guard_tags _field one_mul group, admit,\n      -- case group, one_mul\n      -- \u03b1 : Type\n      -- \u22a2 \u2200 (a : \u03b1), 1 * a = a\n\n    guard_tags _field mul_one group, admit,\n      -- case group, mul_one\n      -- \u03b1 : Type\n      -- \u22a2 \u2200 (a : \u03b1), a * 1 = a\n\n    guard_tags _field inv group, admit,\n      -- case group, inv\n      -- \u03b1 : Type\n      -- \u22a2 \u03b1 \u2192 \u03b1\n\n    guard_tags _field mul_left_inv group, admit,\n      -- case group, mul_left_inv\n      -- \u03b1 : Type\n      -- \u22a2 \u2200 (a : \u03b1), a\u207b\u00b9 * a = 1\n  },\n  trivial\nend\n\ndef my_bar {\u03b1} (x : semigroup \u03b1) (y : group \u03b1) (i j : \u03b1) : \u03b1 := i\n\nexample {\u03b1 : Type} : true :=\nbegin\n  have : monoid \u03b1,\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 \u2115 else \u2124)\n\n@[extensionality] lemma df.ext (s t : dependent_fields) (h : s.a = t.a)\n (w : (@eq.rec _ s.a (\u03bb b, if b then \u2115 else \u2124) 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 \u2264 b) (h2 : c \u2264 d) (h3 : 0 \u2264 e) :\na + c * e + a + c + 0 \u2264 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 \u2264 b) (h2 : c \u2264 d) (h3 : 0 \u2264 e) :\na + c * e + a + c + 0 \u2264 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 \u2264 b) (h2 : c \u2264 d) (h3 : 0 \u2264 e) :\na + c * e + a + c + 0 \u2264 b + d * e + b + d + e :=\nby apply_rules [mono_rules]\n\nexample {a b c d e : nat} (h1 : a \u2264 b) (h2 : c \u2264 d) (h3 : 0 \u2264 e) :\na + c * e + a + c + 0 \u2264 b + d * e + b + d + e :=\nby apply_rules mono_rules\n\nend apply_rules\n\nsection h_generalize\n\nvariables {\u03b1 \u03b2 \u03b3 \u03c6 \u03c8 : Type} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1 \u2192 \u03c6 \u2192 \u03b3)\n          (x y : \u03b1) (a b : \u03b2) (z : \u03c6)\n          (h\u2080 : \u03b2 = \u03b1) (h\u2081 : \u03b2 = \u03b1) (h\u2082 : \u03c6 = \u03b2)\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\u2080 a) (cast h\u2080 b) (eq.mpr h\u2081.symm a) (eq.mpr h\u2082 a) :=\nbegin\n  guard_hyp_nums 16,\n  h_generalize hp : a == p with hh,\n  guard_hyp_nums 19,\n  guard_hyp' hh := \u03b2 = \u03b1,\n  guard_target f x y x z = f p (cast h\u2080 b) p (eq.mpr h\u2082 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\u2082 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 {\u03b1 \u03b2 \u03b3 \u03c6 \u03c8 : Type} (f : list \u03b1 \u2192 list \u03b1 \u2192 \u03b3)\n          (x : list \u03b1) (a : list \u03b2) (z : \u03c6)\n          (h\u2080 : \u03b2 = \u03b1) (h\u2081 : list \u03b2 = list \u03b1)\n          (hx : x == a)\ninclude f x z a hx h\u2080 h\u2081\n\nexample : true :=\nbegin\n  have : f x x = f (eq.rec_on h\u2080 a) (cast h\u2081 a),\n  { guard_hyp_nums 11,\n    h_generalize : a == p with _,\n    guard_hyp_nums 13,\n    guard_hyp' h := \u03b2 = \u03b1,\n    guard_target f x x = f p (cast h\u2081 a),\n    h_generalize! : a == q ,\n    guard_hyp_nums 13,\n    guard_target \u2200 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 : \u2200 x y z a b c : \u2115, true :=\nbegin\n intros,\n have : x + (y + z) = 3 + y, admit,\n have : a + (b + x) + y + (z + b + c) \u2264 0,\n (do this \u2190 get_local `this,\n     tgt \u2190 to_expr ```(a + (b + x) + y + (z + b + c)),\n     assoc \u2190 mk_mapp ``add_monoid.add_assoc [`(\u2115),none],\n     (l,p) \u2190 assoc_rewrite_intl assoc this tgt,\n     note `h none p  ),\n erw h,\n guard_target a + b + 3 + y + b + c \u2264 0,\n admit,\n trivial\nend\n\nexample : \u2200 x y z a b c : \u2115, true :=\nbegin\n intros,\n have : \u2200 y, x + (y + z) = 3 + y, admit,\n have : a + (b + x) + y + (z + b + c) \u2264 0,\n (do this \u2190 get_local `this,\n     tgt \u2190 to_expr ```(a + (b + x) + y + (z + b + c)),\n     assoc_rewrite_target this ),\n guard_target a + b + 3 + y + b + c \u2264 0,\n admit,\n trivial\nend\n\nvariables x y z a b c : \u2115\nvariables h\u2080 : \u2200 (y : \u2115), x + (y + z) = 3 + y\nvariables h\u2081 : a + (b + x) + y + (z + b + a) \u2264 0\nvariables h\u2082 : y + b + c = y + b + a\ninclude h\u2080 h\u2081 h\u2082\nexample : a + (b + x) + y + (z + b + c) \u2264 0 :=\nby { assoc_rw [h\u2080,h\u2082] at *,\n     guard_hyp _inst := is_associative \u2115 has_add.add,\n       -- keep a local instance of is_associative to cache\n       -- type class queries\n     exact h\u2081 }\n\nend assoc_rw\n\n-- section tfae\n\n-- example (p q r s : Prop)\n--   (h\u2080 : p \u2194 q)\n--   (h\u2081 : q \u2194 r)\n--   (h\u2082 : r \u2194 s) :\n--   p \u2194 s :=\n-- begin\n--   scc,\n-- end\n\n-- example (p' p q r r' s s' : Prop)\n--   (h\u2080 : p' \u2192 p)\n--   (h\u2080 : p \u2192 q)\n--   (h\u2081 : q \u2192 r)\n--   (h\u2081 : r' \u2192 r)\n--   (h\u2082 : r \u2194 s)\n--   (h\u2082 : s \u2192 p)\n--   (h\u2082 : s \u2192 s') :\n--   p \u2194 s :=\n-- begin\n--   scc,\n-- end\n\n-- example (p' p q r r' s s' : Prop)\n--   (h\u2080 : p' \u2192 p)\n--   (h\u2080 : p \u2192 q)\n--   (h\u2081 : q \u2192 r)\n--   (h\u2081 : r' \u2192 r)\n--   (h\u2082 : r \u2194 s)\n--   (h\u2082 : s \u2192 p)\n--   (h\u2082 : s \u2192 s') :\n--   p \u2194 s :=\n-- begin\n--   scc',\n--   assumption\n-- end\n\n-- example : tfae [true, \u2200 n : \u2115, 0 \u2264 n * n, true, true] := begin\n--   tfae_have : 3 \u2192 1, { intro h, constructor },\n--   tfae_have : 2 \u2192 3, { intro h, constructor },\n--   tfae_have : 2 \u2190 1, { intros h n, apply nat.zero_le },\n--   tfae_have : 4 \u2194 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 : \u2115) : 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 : \u2115) : (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 : \u2115) : 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 : \u2115) (h\u2081 : n = m) (h\u2082 : \u2203 a : \u2115, a = n \u2227 a = m) : 2 * m = 2 * n :=\nlet \u27e8a, ha\u27e9 := h\u2082 in\nbegin\n  clear_aux_decl, -- subst will fail without this line\n  subst h\u2081\nend\n\nexample (x y : \u2115) (h\u2081 : \u2203 n : \u2115, n * 1 = 2) (h\u2082 : 1 + 1 = 2 \u2192 x * 1 = y) : x = y :=\nlet \u27e8n, hn\u27e9 := h\u2081 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 \u2192 Prop \u2192 Prop \u2192 Prop) (x x' y z z' : Prop)\n  (h\u2080 : x \u2194 x')\n  (h\u2081 : z \u2194 z') :\n  c x y z \u2194 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 \u2190 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 \u03b9` for describing the shapes of homological complexes\nindexed by a type `\u03b9`.\nThis is intended to capture chain complexes and cochain complexes, indexed by either `\u2115` or `\u2124`,\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 : \u03b9 \u2192 \u03b9 \u2192 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 \u27f6 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 `\u03b1` is an `add_right_cancel_semigroup`, then we define `up \u03b1 : complex_shape \u03b1`,\nthe shape appropriate for cohomology,so `d : X i \u27f6 X j` is nonzero only when `j = i + 1`,\nas well as `down \u03b1 : complex_shape \u03b1`, appropriate for homology,\nso `d : X i \u27f6 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 \u03b9` describes the shape of a chain complex,\nwith chain groups indexed by `\u03b9`.\nTypically `\u03b9` will be `\u2115`, `\u2124`, or `fin n`.\n\nThere is a relation `rel : \u03b9 \u2192 \u03b9 \u2192 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 (\u03b9 : Type _) where\n  Rel : \u03b9 \u2192 \u03b9 \u2192 Prop\n  next_eq : \u2200 {i j j'}, Rel i j \u2192 Rel i j' \u2192 j = j'\n  prev_eq : \u2200 {i i' j}, Rel i j \u2192 Rel i' j \u2192 i = i'\n#align complex_shape ComplexShape\n-/\n\nnamespace ComplexShape\n\nvariable {\u03b9 : 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 (\u03b9 : Type _) : ComplexShape \u03b9\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 \u03b9) : ComplexShape \u03b9\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 \u03b9) : 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\u2081 c\u2082 : ComplexShape \u03b9) : ComplexShape \u03b9\n    where\n  Rel := Relation.Comp c\u2081.Rel c\u2082.Rel\n  next_eq i j j' w w' := by\n    obtain \u27e8k, w\u2081, w\u2082\u27e9 := w\n    obtain \u27e8k', w\u2081', w\u2082'\u27e9 := w'\n    rw [c\u2081.next_eq w\u2081 w\u2081'] at w\u2082\n    exact c\u2082.next_eq w\u2082 w\u2082'\n  prev_eq i i' j w w' := by\n    obtain \u27e8k, w\u2081, w\u2082\u27e9 := w\n    obtain \u27e8k', w\u2081', w\u2082'\u27e9 := w'\n    rw [c\u2082.prev_eq w\u2082 w\u2082'] at w\u2081\n    exact c\u2081.prev_eq w\u2081 w\u2081'\n#align complex_shape.trans ComplexShape.trans\n-/\n\n#print ComplexShape.subsingleton_next /-\ninstance subsingleton_next (c : ComplexShape \u03b9) (i : \u03b9) : Subsingleton { j // c.Rel i j } :=\n  by\n  fconstructor\n  rintro \u27e8j, rij\u27e9 \u27e8k, rik\u27e9\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 \u03b9) (j : \u03b9) : Subsingleton { i // c.Rel i j } :=\n  by\n  fconstructor\n  rintro \u27e8i, rik\u27e9 \u27e8j, rjk\u27e9\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 \u03b9) (i : \u03b9) : \u03b9 :=\n  if h : \u2203 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 \u03b9) (j : \u03b9) : \u03b9 :=\n  if h : \u2203 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 \u03b9) {i j : \u03b9} (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 \u27e8j, h\u27e9\n#align complex_shape.next_eq' ComplexShape.next_eq'\n-/\n\n#print ComplexShape.prev_eq' /-\ntheorem prev_eq' (c : ComplexShape \u03b9) {i j : \u03b9} (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 \u27e8i, h\u27e9\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 `\u2115` or `\u2124`)\n-/\n@[simps]\ndef up' {\u03b1 : Type _} [AddRightCancelSemigroup \u03b1] (a : \u03b1) : ComplexShape \u03b1\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 `\u2115` or `\u2124`)\n-/\n@[simps]\ndef down' {\u03b1 : Type _} [AddRightCancelSemigroup \u03b1] (a : \u03b1) : ComplexShape \u03b1\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 {\u03b1 : Type.{u1}} [_inst_1 : AddRightCancelSemigroup.{u1} \u03b1] (a : \u03b1) (i : \u03b1) (j : \u03b1), (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddSemigroup.toHasAdd.{u1} \u03b1 (AddRightCancelSemigroup.toAddSemigroup.{u1} \u03b1 _inst_1))) j a) i) -> (ComplexShape.Rel.{u1} \u03b1 (ComplexShape.down'.{u1} \u03b1 _inst_1 a) i j)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : AddRightCancelSemigroup.{u1} \u03b1] (a : \u03b1) (i : \u03b1) (j : \u03b1), (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddSemigroup.toAdd.{u1} \u03b1 (AddRightCancelSemigroup.toAddSemigroup.{u1} \u03b1 _inst_1))) j a) i) -> (ComplexShape.Rel.{u1} \u03b1 (ComplexShape.down'.{u1} \u03b1 _inst_1 a) i j)\nCase conversion may be inaccurate. Consider using '#align complex_shape.down'_mk ComplexShape.down'_mk\u2093'. -/\ntheorem down'_mk {\u03b1 : Type _} [AddRightCancelSemigroup \u03b1] (a : \u03b1) (i j : \u03b1) (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 \u27f6 X j` only when `j = i + 1`.\n-/\n@[simps]\ndef up (\u03b1 : Type _) [AddRightCancelSemigroup \u03b1] [One \u03b1] : ComplexShape \u03b1 :=\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 \u27f6 X j` only when `i = j + 1`.\n-/\n@[simps]\ndef down (\u03b1 : Type _) [AddRightCancelSemigroup \u03b1] [One \u03b1] : ComplexShape \u03b1 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : AddRightCancelSemigroup.{u1} \u03b1] [_inst_2 : One.{u1} \u03b1] (i : \u03b1) (j : \u03b1), (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddSemigroup.toHasAdd.{u1} \u03b1 (AddRightCancelSemigroup.toAddSemigroup.{u1} \u03b1 _inst_1))) j (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_2)))) i) -> (ComplexShape.Rel.{u1} \u03b1 (ComplexShape.down.{u1} \u03b1 _inst_1 _inst_2) i j)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : AddRightCancelSemigroup.{u1} \u03b1] [_inst_2 : One.{u1} \u03b1] (i : \u03b1) (j : \u03b1), (Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddSemigroup.toAdd.{u1} \u03b1 (AddRightCancelSemigroup.toAddSemigroup.{u1} \u03b1 _inst_1))) j (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_2))) i) -> (ComplexShape.Rel.{u1} \u03b1 (ComplexShape.down.{u1} \u03b1 _inst_1 _inst_2) i j)\nCase conversion may be inaccurate. Consider using '#align complex_shape.down_mk ComplexShape.down_mk\u2093'. -/\ntheorem down_mk {\u03b1 : Type _} [AddRightCancelSemigroup \u03b1] [One \u03b1] (i j : \u03b1) (h : j + 1 = i) :\n    (down \u03b1).Rel i j :=\n  down'_mk (1 : \u03b1) 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 {\u03b1 : Type*} {\u03b2 : Type*} [decidable_eq \u03b1] (T : set \u03b1) (r : free_group \u03b1)\n\nopen group subgroup free_group\n\n\n\n\ndef blah (t : \u03b1) : free_group \u03b1 \u2192* free_group unit :=\nto_group (\u03bb a, if a = t then of () else 1)\n\ninstance {\u03b1 : Type*} [subsingleton \u03b1] : comm_group (free_group \u03b1) :=\n{ mul_comm := \u03bb a b, sorry,\n  ..free_group.group }\n\ndef ker_blah_free (t : \u03b1) (e : \u03b1 \u2243 option \u03b2) (he : e.symm none = t) :\n  free_group (\u03b2 \u00d7 \u2124) \u2243* (blah t).ker :=\n{ to_fun := free_group.to_group\n    (\u03bb b : \u03b2 \u00d7 \u2124, (\u27e8of 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          \u2190 monoid_hom.map_mul, \u2190 gpow_add, add_neg_self],\n        simp [blah, he.symm]\n      end\u27e9 : (blah t).ker)),\n  inv_fun := \u03bb x, begin\n    have := x.1,\n\n  end,  }\n\n@[elab_as_eliminator]\nlemma normal_closure_induction {G : Type*} [group G] {P : G \u2192 Prop} {x : G} {s : set G}\n  (h : x \u2208 subgroup.normal_closure s)\n  (hs : \u2200 x \u2208 s, P x)\n  (h1 : P 1)\n  (hmul : \u2200 x \u2208 s, \u2200 y, P y \u2192 P (x * y))\n  (hinv : \u2200 x \u2208 s, P x \u2192 P x\u207b\u00b9) : P x := sorry\n\ntheorem freiheitsatz (x : free_group \u03b1)\n  (hxr : x \u2208 subgroup.normal_closure ({r} : set (free_group \u03b1)))\n  (hxT : x \u2208 subgroup.normal_closure (free_group.of '' T)) (hx1 : x \u2260 1) :\n  r \u2208 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 _ \u27e8a, haT, rfl\u27e9 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 \u2964 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\u2081 u\u2082\n\nnamespace category_theory\nvariables {C : Type u\u2081} [category.{v} C] {D : Type u\u2082} [category.{v} D]\n\nnamespace structured_arrow\nvariables {S : D} {T : C \u2964 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 \u2192 subobject A.right :=\nbegin\n  refine subobject.lift (\u03bb 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 \u27f6 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  \u2200 P : subobject A, \u2203 q, q \u226b T.map (project_subobject P).arrow = A.hom :=\nsubobject.ind _ $ \u03bb P f hf,\n  \u27e8P.hom \u226b T.map (subobject.underlying_iso _).inv, by { dsimp, simp [\u2190 T.map_comp] }\u27e9\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 \u226b T.map P.arrow = A.hom) : subobject A :=\nsubobject.mk (hom_mk P.arrow hq : mk q \u27f6 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  \u2200 (P : subobject A) {q} (hq : q \u226b 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 [\u2190 T.map_comp] using hq }) } },\n  { exact ext _ _ (by { dsimp, simp })}\nend\n\n/-- If `A : S \u2192 T.obj B` is a structured arrow for `S : D` and `T : C \u2964 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 \u2243o { P : subobject A.right // \u2203 q, q \u226b T.map P.arrow = A.hom } :=\n{ to_fun := \u03bb P, \u27e8project_subobject P, project_subobject_factors P\u27e9,\n  inv_fun := \u03bb P, lift_subobject P.val P.prop.some_spec,\n  left_inv := \u03bb P, lift_project_subobject _ _,\n  right_inv := \u03bb P, subtype.ext (by simp),\n  map_rel_iff' := subobject.ind\u2082 _\n  begin\n    introsI P Q f g hf hg,\n    refine \u27e8\u03bb h, subobject.mk_le_mk_of_comm _ (ext _ _ _), \u03bb h, _\u27e9,\n    { refine hom_mk (subobject.of_mk_le_mk _ _ h) ((cancel_mono (T.map g.right)).1 _),\n      simp [\u2190 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 := \u03bb X, small_map (subobject_equiv X).to_equiv }\n\nend structured_arrow\n\nnamespace costructured_arrow\nvariables {S : C \u2964 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) \u2192 subobject (op A.left) :=\nbegin\n  refine subobject.lift (\u03bb 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)\u1d52\u1d56} (f : P \u27f6 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 \u226b q = A.hom) : subobject (op A) :=\nsubobject.mk (hom_mk P.arrow.unop hq : A \u27f6 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)\u1d52\u1d56} (f : P \u27f6 op A) [mono f.unop.left.op] :\n  f.unop.left \u226b (subobject.underlying_iso f.unop.left.op).hom.unop =\n    (subobject.mk f.unop.left.op).arrow.unop :=\nbegin\n  conv_lhs { congr, rw [\u2190 quiver.hom.unop_op f.unop.left] },\n  rw [\u2190 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  \u2200 (P : subobject (op A)) {q} (hq : S.map (project_quotient P).arrow.unop \u226b 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 _ _) : _ \u2245 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 [\u2190 category.assoc, \u2190 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)\u1d52\u1d56} {f : P \u27f6 op A} {g : Q \u27f6 op A} [mono f.unop.left.op]\n  [mono g.unop.left.op] (h : subobject.mk f.unop.left.op \u2264 subobject.mk g.unop.left.op) :\n  g.unop.left \u226b (subobject.of_mk_le_mk f.unop.left.op g.unop.left.op h).unop = f.unop.left :=\nbegin\n  conv_lhs { congr, rw [\u2190 quiver.hom.unop_op g.unop.left] },\n  rw [\u2190 unop_comp],\n  simp only [subobject.of_mk_le_mk_comp, quiver.hom.unop_op]\nend\n\n/-- If `A : S.obj B \u27f6 T` is a costructured arrow for `S : C \u2964 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) \u2243o { P : subobject (op A.left) // \u2203 q, S.map P.arrow.unop \u226b q = A.hom } :=\n{ to_fun := \u03bb P, \u27e8project_quotient P, project_quotient_factors P\u27e9,\n  inv_fun := \u03bb P, lift_quotient P.val P.prop.some_spec,\n  left_inv := \u03bb P, lift_project_quotient _ _,\n  right_inv := \u03bb P, subtype.ext (by simp),\n  map_rel_iff' := subobject.ind\u2082 _\n  begin\n    introsI P Q f g hf hg,\n    refine \u27e8\u03bb h, subobject.mk_le_mk_of_comm _ (quiver.hom.unop_inj (ext _ _ _)), \u03bb h, _\u27e9,\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 [\u2190 category.assoc, \u2190 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\u1d52\u1d56] [has_colimits C]\n  [preserves_colimits S] : well_powered (costructured_arrow S T)\u1d52\u1d56 :=\n{ subobject_small := \u03bb 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 \u2964 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) [\ud835\udca5 : small_category J] [@fin_category J \ud835\udca5] : @has_limits_of_shape J \ud835\udca5 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\u27e8\u03bb 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) }\u27e9\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 \u2964 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) [\ud835\udca5 : small_category J] [@fin_category J \ud835\udca5] : @has_colimits_of_shape J \ud835\udca5 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\u27e8\u03bb 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) }\u27e9\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 := \u03bb 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' \u2205 [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 \u27f6 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 \u2205 } }\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 \u27f6 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 \u2205 } }\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\u27e8\u03bb J _ _, by exactI has_finite_colimits.out _\u27e9\n\ninstance fintype_walking_pair : fintype walking_pair :=\n{ elems := {walking_pair.left, walking_pair.right},\n  complete := \u03bb 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\u00f6lzl\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 \u03b1] [topological_group \u03b1]` 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 `(\u207b\u00b9)` / `(+)` 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 \u2124-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 {\u03b1 : Type _} {\u03b2 : Type _}\n\n#print UniformGroup /-\n/-- A uniform group is a group in which multiplication and inversion are uniformly continuous. -/\nclass UniformGroup (\u03b1 : Type _) [UniformSpace \u03b1] [Group \u03b1] : Prop where\n  uniformContinuous_div : UniformContinuous fun p : \u03b1 \u00d7 \u03b1 => 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 (\u03b1 : Type _) [UniformSpace \u03b1] [AddGroup \u03b1] : Prop where\n  uniformContinuous_sub : UniformContinuous fun p : \u03b1 \u00d7 \u03b1 => 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1], (UniformContinuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (Prod.uniformSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))) -> (UniformContinuous.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (fun (p : \u03b1) => Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)) p)) -> (UniformGroup.{u1} \u03b1 _inst_1 _inst_2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1], (UniformContinuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (instUniformSpaceProd.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))) -> (UniformContinuous.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (fun (p : \u03b1) => Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))) p)) -> (UniformGroup.{u1} \u03b1 _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align uniform_group.mk' UniformGroup.mk'\u2093'. -/\n@[to_additive]\ntheorem UniformGroup.mk' {\u03b1} [UniformSpace \u03b1] [Group \u03b1]\n    (h\u2081 : UniformContinuous fun p : \u03b1 \u00d7 \u03b1 => p.1 * p.2) (h\u2082 : UniformContinuous fun p : \u03b1 => p\u207b\u00b9) :\n    UniformGroup \u03b1 :=\n  \u27e8by\n    simpa only [div_eq_mul_inv] using\n      h\u2081.comp (uniform_continuous_fst.prod_mk (h\u2082.comp uniformContinuous_snd))\u27e9\n#align uniform_group.mk' UniformGroup.mk'\n#align uniform_add_group.mk' UniformAddGroup.mk'\n\nvariable [UniformSpace \u03b1] [Group \u03b1] [UniformGroup \u03b1]\n\n/- warning: uniform_continuous_div -> uniformContinuous_div is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], UniformContinuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (Prod.uniformSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], UniformContinuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (instUniformSpaceProd.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_div uniformContinuous_div\u2093'. -/\n@[to_additive]\ntheorem uniformContinuous_div : UniformContinuous fun p : \u03b1 \u00d7 \u03b1 => 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1}, (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 g) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (x : \u03b2) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (f x) (g x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1}, (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 g) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (x : \u03b2) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (f x) (g x)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.div UniformContinuous.div\u2093'. -/\n@[to_additive]\ntheorem UniformContinuous.div [UniformSpace \u03b2] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1}, (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (x : \u03b2) => Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)) (f x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1}, (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (x : \u03b2) => Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))) (f x)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.inv UniformContinuous.inv\u2093'. -/\n@[to_additive]\ntheorem UniformContinuous.inv [UniformSpace \u03b2] {f : \u03b2 \u2192 \u03b1} (hf : UniformContinuous f) :\n    UniformContinuous fun x => (f x)\u207b\u00b9 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], UniformContinuous.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (fun (x : \u03b1) => Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)) x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], UniformContinuous.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (fun (x : \u03b1) => Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))) x)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_inv uniformContinuous_inv\u2093'. -/\n@[to_additive]\ntheorem uniformContinuous_inv : UniformContinuous fun x : \u03b1 => x\u207b\u00b9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1}, (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 g) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (x : \u03b2) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (f x) (g x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1}, (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 f) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 g) -> (UniformContinuous.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (fun (x : \u03b2) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (f x) (g x)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.mul UniformContinuous.mul\u2093'. -/\n@[to_additive]\ntheorem UniformContinuous.mul [UniformSpace \u03b2] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (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)\u207b\u00b9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], UniformContinuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (Prod.uniformSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], UniformContinuous.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (instUniformSpaceProd.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_1 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_mul uniformContinuous_mul\u2093'. -/\n@[to_additive]\ntheorem uniformContinuous_mul : UniformContinuous fun p : \u03b1 \u00d7 \u03b1 => 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 \u03b2] {f : \u03b2 \u2192 \u03b1} (hf : UniformContinuous f) :\n    \u2200 n : \u2115, 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 : \u2115) : UniformContinuous fun x : \u03b1 => 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 \u03b2] {f : \u03b2 \u2192 \u03b1} (hf : UniformContinuous f) :\n    \u2200 n : \u2124, UniformContinuous fun x => f x ^ n\n  | (n : \u2115) => 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 : \u2124) : UniformContinuous fun x : \u03b1 => 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 \u03b1\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 \u03b2] [Group \u03b2] [UniformGroup \u03b2] : UniformGroup (\u03b1 \u00d7 \u03b2) :=\n  \u27e8((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))\u27e9\n\n/- warning: uniformity_translate_mul -> uniformity_translate_mul is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.map.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Prod.mk.{u1, u1} \u03b1 \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Prod.fst.{u1, u1} \u03b1 \u03b1 x) a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Prod.snd.{u1, u1} \u03b1 \u03b1 x) a)) (uniformity.{u1} \u03b1 _inst_1)) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.map.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Prod.mk.{u1, u1} \u03b1 \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Prod.fst.{u1, u1} \u03b1 \u03b1 x) a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Prod.snd.{u1, u1} \u03b1 \u03b1 x) a)) (uniformity.{u1} \u03b1 _inst_1)) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align uniformity_translate_mul uniformity_translate_mul\u2093'. -/\n@[to_additive]\ntheorem uniformity_translate_mul (a : \u03b1) : ((\ud835\udce4 \u03b1).map fun x : \u03b1 \u00d7 \u03b1 => (x.1 * a, x.2 * a)) = \ud835\udce4 \u03b1 :=\n  le_antisymm (uniformContinuous_id.mul uniformContinuous_const)\n    (calc\n      \ud835\udce4 \u03b1 =\n          ((\ud835\udce4 \u03b1).map fun x : \u03b1 \u00d7 \u03b1 => (x.1 * a\u207b\u00b9, x.2 * a\u207b\u00b9)).map fun x : \u03b1 \u00d7 \u03b1 =>\n            (x.1 * a, x.2 * a) :=\n        by simp [Filter.map_map, (\u00b7 \u2218 \u00b7)] <;> exact filter.map_id.symm\n      _ \u2264 (\ud835\udce4 \u03b1).map fun x : \u03b1 \u00d7 \u03b1 => (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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), UniformEmbedding.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (fun (x : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) x a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] (a : \u03b1), UniformEmbedding.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (fun (x : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) x a)\nCase conversion may be inaccurate. Consider using '#align uniform_embedding_translate_mul uniformEmbedding_translate_mul\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Tactic/Lean3.lean:132:4: warning: unsupported: rw with cfg: { occs := occurrences.pos[occurrences.pos] \u00abexpr[ ,]\u00bb([1]) } -/\n@[to_additive]\ntheorem uniformEmbedding_translate_mul (a : \u03b1) : UniformEmbedding fun x : \u03b1 => x * a :=\n  { comap_uniformity := by\n      rw [\u2190 uniformity_translate_mul a, comap_map]\n      rintro \u27e8p\u2081, p\u2082\u27e9 \u27e8q\u2081, q\u2082\u27e9\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 \u03b1\u1d50\u1d52\u1d56 :=\n  \u27e8uniformContinuous_op.comp\n      ((uniformContinuous_unop.comp uniformContinuous_snd).inv.mul <|\n        uniformContinuous_unop.comp uniformContinuous_fst)\u27e9\n\nend MulOpposite\n\nnamespace Subgroup\n\n@[to_additive]\ninstance (S : Subgroup \u03b1) : UniformGroup S :=\n  \u27e8uniformContinuous_comap'\n      (uniformContinuous_div.comp <|\n        uniformContinuous_subtype_val.Prod_map uniformContinuous_subtype_val)\u27e9\n\nend Subgroup\n\nsection LatticeOps\n\nvariable [Group \u03b2]\n\n/- warning: uniform_group_Inf -> uniformGroup_inf\u209b is a dubious translation:\nlean 3 declaration is\n  forall {\u03b2 : Type.{u1}} [_inst_4 : Group.{u1} \u03b2] {us : Set.{u1} (UniformSpace.{u1} \u03b2)}, (forall (u : UniformSpace.{u1} \u03b2), (Membership.Mem.{u1, u1} (UniformSpace.{u1} \u03b2) (Set.{u1} (UniformSpace.{u1} \u03b2)) (Set.hasMem.{u1} (UniformSpace.{u1} \u03b2)) u us) -> (UniformGroup.{u1} \u03b2 u _inst_4)) -> (UniformGroup.{u1} \u03b2 (InfSet.inf\u209b.{u1} (UniformSpace.{u1} \u03b2) (UniformSpace.hasInf.{u1} \u03b2) us) _inst_4)\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} [_inst_4 : Group.{u1} \u03b2] {us : Set.{u1} (UniformSpace.{u1} \u03b2)}, (forall (u : UniformSpace.{u1} \u03b2), (Membership.mem.{u1, u1} (UniformSpace.{u1} \u03b2) (Set.{u1} (UniformSpace.{u1} \u03b2)) (Set.instMembershipSet.{u1} (UniformSpace.{u1} \u03b2)) u us) -> (UniformGroup.{u1} \u03b2 u _inst_4)) -> (UniformGroup.{u1} \u03b2 (InfSet.inf\u209b.{u1} (UniformSpace.{u1} \u03b2) (instInfSetUniformSpace.{u1} \u03b2) us) _inst_4)\nCase conversion may be inaccurate. Consider using '#align uniform_group_Inf uniformGroup_inf\u209b\u2093'. -/\n@[to_additive]\ntheorem uniformGroup_inf\u209b {us : Set (UniformSpace \u03b2)} (h : \u2200 u \u2208 us, @UniformGroup \u03b2 u _) :\n    @UniformGroup \u03b2 (inf\u209b us) _ :=\n  {\n    uniformContinuous_div :=\n      uniformContinuous_inf\u209b_rng fun u hu =>\n        uniformContinuous_inf\u209b_dom\u2082 hu hu (@UniformGroup.uniformContinuous_div \u03b2 u _ (h u hu)) }\n#align uniform_group_Inf uniformGroup_inf\u209b\n#align uniform_add_group_Inf uniformAddGroup_inf\u209b\n\n/- warning: uniform_group_infi -> uniformGroup_inf\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b2 : Type.{u1}} [_inst_4 : Group.{u1} \u03b2] {\u03b9 : Sort.{u2}} {us' : \u03b9 -> (UniformSpace.{u1} \u03b2)}, (forall (i : \u03b9), UniformGroup.{u1} \u03b2 (us' i) _inst_4) -> (UniformGroup.{u1} \u03b2 (inf\u1d62.{u1, u2} (UniformSpace.{u1} \u03b2) (UniformSpace.hasInf.{u1} \u03b2) \u03b9 (fun (i : \u03b9) => us' i)) _inst_4)\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} [_inst_4 : Group.{u1} \u03b2] {\u03b9 : Sort.{u2}} {us' : \u03b9 -> (UniformSpace.{u1} \u03b2)}, (forall (i : \u03b9), UniformGroup.{u1} \u03b2 (us' i) _inst_4) -> (UniformGroup.{u1} \u03b2 (inf\u1d62.{u1, u2} (UniformSpace.{u1} \u03b2) (instInfSetUniformSpace.{u1} \u03b2) \u03b9 (fun (i : \u03b9) => us' i)) _inst_4)\nCase conversion may be inaccurate. Consider using '#align uniform_group_infi uniformGroup_inf\u1d62\u2093'. -/\n@[to_additive]\ntheorem uniformGroup_inf\u1d62 {\u03b9 : Sort _} {us' : \u03b9 \u2192 UniformSpace \u03b2}\n    (h' : \u2200 i, @UniformGroup \u03b2 (us' i) _) : @UniformGroup \u03b2 (\u2a05 i, us' i) _ :=\n  by\n  rw [\u2190 inf\u209b_range]\n  exact uniformGroup_inf\u209b (set.forall_range_iff.mpr h')\n#align uniform_group_infi uniformGroup_inf\u1d62\n#align uniform_add_group_infi uniformAddGroup_inf\u1d62\n\n#print uniformGroup_inf /-\n@[to_additive]\ntheorem uniformGroup_inf {u\u2081 u\u2082 : UniformSpace \u03b2} (h\u2081 : @UniformGroup \u03b2 u\u2081 _)\n    (h\u2082 : @UniformGroup \u03b2 u\u2082 _) : @UniformGroup \u03b2 (u\u2081 \u2293 u\u2082) _ :=\n  by\n  rw [inf_eq_inf\u1d62]\n  refine' uniformGroup_inf\u1d62 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 {\u03b2 : Type.{u1}} [_inst_4 : Group.{u1} \u03b2] {\u03b3 : Type.{u2}} [_inst_5 : Group.{u2} \u03b3] {u : UniformSpace.{u2} \u03b3} [_inst_6 : UniformGroup.{u2} \u03b3 u _inst_5] {F : Type.{u3}} [_inst_7 : MonoidHomClass.{u3, u1, u2} F \u03b2 \u03b3 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (Group.toDivInvMonoid.{u1} \u03b2 _inst_4))) (Monoid.toMulOneClass.{u2} \u03b3 (DivInvMonoid.toMonoid.{u2} \u03b3 (Group.toDivInvMonoid.{u2} \u03b3 _inst_5)))] (f : F), UniformGroup.{u1} \u03b2 (UniformSpace.comap.{u1, u2} \u03b2 \u03b3 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b2 -> \u03b3) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b2 (fun (_x : \u03b2) => \u03b3) (MulHomClass.toFunLike.{u3, u1, u2} F \u03b2 \u03b3 (MulOneClass.toHasMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (Group.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MulOneClass.toHasMul.{u2} \u03b3 (Monoid.toMulOneClass.{u2} \u03b3 (DivInvMonoid.toMonoid.{u2} \u03b3 (Group.toDivInvMonoid.{u2} \u03b3 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} F \u03b2 \u03b3 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (Group.toDivInvMonoid.{u1} \u03b2 _inst_4))) (Monoid.toMulOneClass.{u2} \u03b3 (DivInvMonoid.toMonoid.{u2} \u03b3 (Group.toDivInvMonoid.{u2} \u03b3 _inst_5))) _inst_7))) f) u) _inst_4\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} [_inst_4 : Group.{u1} \u03b2] {\u03b3 : Type.{u3}} [_inst_5 : Group.{u3} \u03b3] {u : UniformSpace.{u3} \u03b3} [_inst_6 : UniformGroup.{u3} \u03b3 u _inst_5] {F : Type.{u2}} [_inst_7 : MonoidHomClass.{u2, u1, u3} F \u03b2 \u03b3 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (Group.toDivInvMonoid.{u1} \u03b2 _inst_4))) (Monoid.toMulOneClass.{u3} \u03b3 (DivInvMonoid.toMonoid.{u3} \u03b3 (Group.toDivInvMonoid.{u3} \u03b3 _inst_5)))] (f : F), UniformGroup.{u1} \u03b2 (UniformSpace.comap.{u1, u3} \u03b2 \u03b3 (FunLike.coe.{succ u2, succ u1, succ u3} F \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) _x) (MulHomClass.toFunLike.{u2, u1, u3} F \u03b2 \u03b3 (MulOneClass.toMul.{u1} \u03b2 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (Group.toDivInvMonoid.{u1} \u03b2 _inst_4)))) (MulOneClass.toMul.{u3} \u03b3 (Monoid.toMulOneClass.{u3} \u03b3 (DivInvMonoid.toMonoid.{u3} \u03b3 (Group.toDivInvMonoid.{u3} \u03b3 _inst_5)))) (MonoidHomClass.toMulHomClass.{u2, u1, u3} F \u03b2 \u03b3 (Monoid.toMulOneClass.{u1} \u03b2 (DivInvMonoid.toMonoid.{u1} \u03b2 (Group.toDivInvMonoid.{u1} \u03b2 _inst_4))) (Monoid.toMulOneClass.{u3} \u03b3 (DivInvMonoid.toMonoid.{u3} \u03b3 (Group.toDivInvMonoid.{u3} \u03b3 _inst_5))) _inst_7)) f) u) _inst_4\nCase conversion may be inaccurate. Consider using '#align uniform_group_comap uniformGroup_comap\u2093'. -/\n@[to_additive]\ntheorem uniformGroup_comap {\u03b3 : Type _} [Group \u03b3] {u : UniformSpace \u03b3} [UniformGroup \u03b3] {F : Type _}\n    [MonoidHomClass F \u03b2 \u03b3] (f : F) : @UniformGroup \u03b2 (u.comap f) _ :=\n  {\n    uniformContinuous_div := by\n      letI : UniformSpace \u03b2 := u.comap f\n      refine' uniformContinuous_comap' _\n      simp_rw [Function.comp, map_div]\n      change UniformContinuous ((fun p : \u03b3 \u00d7 \u03b3 => p.1 / p.2) \u2218 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 (\u03b1)\n\n/- warning: uniformity_eq_comap_nhds_one -> uniformity_eq_comap_nhds_one is a dubious translation:\nlean 3 declaration is\n  forall (\u03b1 : Type.{u1}) [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.snd.{u1, u1} \u03b1 \u03b1 x) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.snd.{u1, u1} \u03b1 \u03b1 x) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align uniformity_eq_comap_nhds_one uniformity_eq_comap_nhds_one\u2093'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_nhds_one : \ud835\udce4 \u03b1 = comap (fun x : \u03b1 \u00d7 \u03b1 => x.2 / x.1) (\ud835\udcdd (1 : \u03b1)) :=\n  by\n  rw [nhds_eq_comap_uniformity, Filter.comap_comap]\n  refine' le_antisymm (Filter.map_le_iff_le_comap.1 _) _\n  \u00b7 intro s hs\n    rcases mem_uniformity_of_uniformContinuous_invariant uniformContinuous_div hs with \u27e8t, ht, hts\u27e9\n    refine' mem_map.2 (mem_of_superset ht _)\n    rintro \u27e8a, b\u27e9\n    simpa [subset_def] using hts a b a\n  \u00b7 intro s hs\n    rcases mem_uniformity_of_uniformContinuous_invariant uniformContinuous_mul hs with \u27e8t, ht, hts\u27e9\n    refine' \u27e8_, ht, _\u27e9\n    rintro \u27e8a, b\u27e9\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 (\u03b1 : Type.{u1}) [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.fst.{u1, u1} \u03b1 \u03b1 x) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))))\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.fst.{u1, u1} \u03b1 \u03b1 x) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align uniformity_eq_comap_nhds_one_swapped uniformity_eq_comap_nhds_one_swapped\u2093'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_nhds_one_swapped :\n    \ud835\udce4 \u03b1 = comap (fun x : \u03b1 \u00d7 \u03b1 => x.1 / x.2) (\ud835\udcdd (1 : \u03b1)) :=\n  by\n  rw [\u2190 comap_swap_uniformity, uniformity_eq_comap_nhds_one, comap_comap, (\u00b7 \u2218 \u00b7)]\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\u2093'. -/\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\u2093'. -/\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 \u2194 @nhds _ u.toTopologicalSpace 1 = @nhds _ v.toTopologicalSpace 1 :=\n  \u27e8fun h => h \u25b8 rfl, hu.ext hv\u27e9\n#align uniform_group.ext_iff UniformGroup.ext_iff\n#align uniform_add_group.ext_iff UniformAddGroup.ext_iff\n\nvariable {\u03b1}\n\n/- warning: uniform_group.uniformity_countably_generated -> UniformGroup.uniformity_countably_generated is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : Filter.IsCountablyGenerated.{u1} \u03b1 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))))))], Filter.IsCountablyGenerated.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : Filter.IsCountablyGenerated.{u1} \u03b1 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))))))], Filter.IsCountablyGenerated.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align uniform_group.uniformity_countably_generated UniformGroup.uniformity_countably_generated\u2093'. -/\n@[to_additive]\ntheorem UniformGroup.uniformity_countably_generated [(\ud835\udcdd (1 : \u03b1)).IsCountablyGenerated] :\n    (\ud835\udce4 \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))))\nCase conversion may be inaccurate. Consider using '#align uniformity_eq_comap_inv_mul_nhds_one uniformity_eq_comap_inv_mul_nhds_one\u2093'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_inv_mul_nhds_one :\n    \ud835\udce4 \u03b1 = comap (fun x : \u03b1 \u00d7 \u03b1 => x.1\u207b\u00b9 * x.2) (\ud835\udcdd (1 : \u03b1)) :=\n  by\n  rw [\u2190 comap_uniformity_mulOpposite, uniformity_eq_comap_nhds_one, \u2190 op_one, \u2190 comap_unop_nhds,\n    comap_comap, comap_comap]\n  simp [(\u00b7 \u2218 \u00b7)]\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2], Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (Filter.comap.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) \u03b1 (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _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\u2093'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_inv_mul_nhds_one_swapped :\n    \ud835\udce4 \u03b1 = comap (fun x : \u03b1 \u00d7 \u03b1 => x.2\u207b\u00b9 * x.1) (\ud835\udcdd (1 : \u03b1)) :=\n  by\n  rw [\u2190 comap_swap_uniformity, uniformity_eq_comap_inv_mul_nhds_one, comap_comap, (\u00b7 \u2218 \u00b7)]\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Sort.{u2}} {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} \u03b1)}, (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.snd.{u1, u1} \u03b1 \u03b1 x) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (U i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Sort.{u2}} {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} \u03b1)}, (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.snd.{u1, u1} \u03b1 \u03b1 x) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (U i))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniformity_of_nhds_one Filter.HasBasis.uniformity_of_nhds_one\u2093'. -/\n@[to_additive]\ntheorem Filter.HasBasis.uniformity_of_nhds_one {\u03b9} {p : \u03b9 \u2192 Prop} {U : \u03b9 \u2192 Set \u03b1}\n    (h : (\ud835\udcdd (1 : \u03b1)).HasBasis p U) : (\ud835\udce4 \u03b1).HasBasis p fun i => { x : \u03b1 \u00d7 \u03b1 | x.2 / x.1 \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Sort.{u2}} {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} \u03b1)}, (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (U i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Sort.{u2}} {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} \u03b1)}, (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (Prod.snd.{u1, u1} \u03b1 \u03b1 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\u2093'. -/\n@[to_additive]\ntheorem Filter.HasBasis.uniformity_of_nhds_one_inv_mul {\u03b9} {p : \u03b9 \u2192 Prop} {U : \u03b9 \u2192 Set \u03b1}\n    (h : (\ud835\udcdd (1 : \u03b1)).HasBasis p U) : (\ud835\udce4 \u03b1).HasBasis p fun i => { x : \u03b1 \u00d7 \u03b1 | x.1\u207b\u00b9 * x.2 \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Sort.{u2}} {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} \u03b1)}, (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.fst.{u1, u1} \u03b1 \u03b1 x) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (U i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Sort.{u2}} {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} \u03b1)}, (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Prod.fst.{u1, u1} \u03b1 \u03b1 x) (Prod.snd.{u1, u1} \u03b1 \u03b1 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\u2093'. -/\n@[to_additive]\ntheorem Filter.HasBasis.uniformity_of_nhds_one_swapped {\u03b9} {p : \u03b9 \u2192 Prop} {U : \u03b9 \u2192 Set \u03b1}\n    (h : (\ud835\udcdd (1 : \u03b1)).HasBasis p U) : (\ud835\udce4 \u03b1).HasBasis p fun i => { x : \u03b1 \u00d7 \u03b1 | x.1 / x.2 \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Sort.{u2}} {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} \u03b1)}, (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (Prod.fst.{u1, u1} \u03b1 \u03b1 x)) (U i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Sort.{u2}} {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} \u03b1)}, (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) (Prod.fst.{u1, u1} \u03b1 \u03b1 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\u2093'. -/\n@[to_additive]\ntheorem Filter.HasBasis.uniformity_of_nhds_one_inv_mul_swapped {\u03b9} {p : \u03b9 \u2192 Prop} {U : \u03b9 \u2192 Set \u03b1}\n    (h : (\ud835\udcdd (1 : \u03b1)).HasBasis p U) : (\ud835\udce4 \u03b1).HasBasis p fun i => { x : \u03b1 \u00d7 \u03b1 | x.2\u207b\u00b9 * x.1 \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] (x : \u03b1) (y : \u03b1), Iff (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) (separationRel.{u1} \u03b1 _inst_1)) (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) x y) (closure.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (Singleton.singleton.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasSingleton.{u1} \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] (x : \u03b1) (y : \u03b1), Iff (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) (separationRel.{u1} \u03b1 _inst_1)) (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) x y) (closure.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (Singleton.singleton.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instSingletonSet.{u1} \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))))))))\nCase conversion may be inaccurate. Consider using '#align group_separation_rel group_separationRel\u2093'. -/\n@[to_additive]\ntheorem group_separationRel (x y : \u03b1) : (x, y) \u2208 separationRel \u03b1 \u2194 x / y \u2208 closure ({1} : Set \u03b1) :=\n  have : Embedding fun a => a * (y / x) := (uniformEmbedding_translate_mul (y / x)).Embedding\n  show (x, y) \u2208 \u22c2\u2080 (\ud835\udce4 \u03b1).sets \u2194 x / y \u2208 closure ({1} : Set \u03b1)\n    by\n    rw [this.closure_eq_preimage_closure_image, uniformity_eq_comap_nhds_one \u03b1, 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} \u03b2] [_inst_5 : Group.{u2} \u03b2] [_inst_6 : UniformGroup.{u2} \u03b2 _inst_4 _inst_5] [_inst_7 : MonoidHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))] {f : hom}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) _inst_7))) f) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))) (nhds.{u2} \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_4) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (MulOneClass.toHasOne.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))))))))) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) _inst_7))) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} \u03b2] [_inst_5 : Group.{u2} \u03b2] [_inst_6 : UniformGroup.{u2} \u03b2 _inst_4 _inst_5] [_inst_7 : MonoidHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))] {f : hom}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 (FunLike.coe.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) _inst_7)) f) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))) (nhds.{u2} \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_4) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (InvOneClass.toOne.{u2} \u03b2 (DivInvOneMonoid.toInvOneClass.{u2} \u03b2 (DivisionMonoid.toDivInvOneMonoid.{u2} \u03b2 (Group.toDivisionMonoid.{u2} \u03b2 _inst_5)))))))) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 (FunLike.coe.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) _inst_7)) f))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_of_tendsto_one uniformContinuous_of_tendsto_one\u2093'. -/\n@[to_additive]\ntheorem uniformContinuous_of_tendsto_one {hom : Type _} [UniformSpace \u03b2] [Group \u03b2] [UniformGroup \u03b2]\n    [MonoidHomClass hom \u03b1 \u03b2] {f : hom} (h : Tendsto f (\ud835\udcdd 1) (\ud835\udcdd 1)) : UniformContinuous f :=\n  by\n  have :\n    ((fun x : \u03b2 \u00d7 \u03b2 => x.2 / x.1) \u2218 fun x : \u03b1 \u00d7 \u03b1 => (f x.1, f x.2)) = fun x : \u03b1 \u00d7 \u03b1 =>\n      f (x.2 / x.1) :=\n    by simp only [map_div]\n  rw [UniformContinuous, uniformity_eq_comap_nhds_one \u03b1, uniformity_eq_comap_nhds_one \u03b2,\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} \u03b2] [_inst_5 : Group.{u2} \u03b2] [_inst_6 : UniformGroup.{u2} \u03b2 _inst_4 _inst_5] [_inst_7 : MonoidHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))] (f : hom), (ContinuousAt.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_4) (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) _inst_7))) f) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) _inst_7))) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} \u03b2] [_inst_5 : Group.{u2} \u03b2] [_inst_6 : UniformGroup.{u2} \u03b2 _inst_4 _inst_5] [_inst_7 : MonoidHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))] (f : hom), (ContinuousAt.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_4) (FunLike.coe.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) _inst_7)) f) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 (FunLike.coe.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) _inst_7)) f))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_of_continuous_at_one uniformContinuous_of_continuousAt_one\u2093'. -/\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 \u03b2] [Group \u03b2]\n    [UniformGroup \u03b2] [MonoidHomClass hom \u03b1 \u03b2] (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} \u03b2] [_inst_5 : Group.{u2} \u03b2] [_inst_6 : UniformGroup.{u2} \u03b2 _inst_4 _inst_5] (f : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))), (ContinuousAt.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_4) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) f) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))))) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : UniformSpace.{u2} \u03b2] [_inst_5 : Group.{u2} \u03b2] [_inst_6 : UniformGroup.{u2} \u03b2 _inst_4 _inst_5] (f : MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))), (ContinuousAt.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_4) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) (MonoidHom.monoidHomClass.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))))) f) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))))) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) (MonoidHom.monoidHomClass.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))))) f))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.uniform_continuous_of_continuous_at_one MonoidHom.uniformContinuous_of_continuousAt_one\u2093'. -/\n@[to_additive]\ntheorem MonoidHom.uniformContinuous_of_continuousAt_one [UniformSpace \u03b2] [Group \u03b2] [UniformGroup \u03b2]\n    (f : \u03b1 \u2192* \u03b2) (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} \u03b2] [_inst_5 : DiscreteTopology.{u2} \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_4)] [_inst_6 : Group.{u2} \u03b2] [_inst_7 : UniformGroup.{u2} \u03b2 _inst_4 _inst_6] [_inst_8 : MonoidHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6)))] {f : hom}, Iff (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 (coeFn.{succ u3, max (succ u1) (succ u2)} hom (fun (_x : hom) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6))) _inst_8))) f)) (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Subgroup.{u1} \u03b1 _inst_2) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Subgroup.{u1} \u03b1 _inst_2) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Subgroup.{u1} \u03b1 _inst_2) (Set.{u1} \u03b1) (SetLike.Set.hasCoeT.{u1, u1} (Subgroup.{u1} \u03b1 _inst_2) \u03b1 (Subgroup.setLike.{u1} \u03b1 _inst_2)))) (MonoidHom.ker.{u1, u2} \u03b1 _inst_2 \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _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} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6)))) (HasLiftT.mk.{succ u3, max (succ u2) (succ u1)} hom (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6)))) (CoeTC\u2093.coe.{succ u3, max (succ u2) (succ u1)} hom (MonoidHom.{u1, u2} \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6)))) (MonoidHom.hasCoeT.{u1, u2, u3} \u03b1 \u03b2 hom (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6))) _inst_8))) f))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {hom : Type.{u3}} [_inst_4 : UniformSpace.{u2} \u03b2] [_inst_5 : DiscreteTopology.{u2} \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_4)] [_inst_6 : Group.{u2} \u03b2] [_inst_7 : UniformGroup.{u2} \u03b2 _inst_4 _inst_6] [_inst_8 : MonoidHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6)))] {f : hom}, Iff (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 (FunLike.coe.{succ u3, succ u1, succ u2} hom \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u3, u1, u2} hom \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MulOneClass.toMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6)))) (MonoidHomClass.toMulHomClass.{u3, u1, u2} hom \u03b1 \u03b2 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6))) _inst_8)) f)) (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (SetLike.coe.{u1, u1} (Subgroup.{u1} \u03b1 _inst_2) \u03b1 (Subgroup.instSetLikeSubgroup.{u1} \u03b1 _inst_2) (MonoidHom.ker.{u1, u2} \u03b1 _inst_2 \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_6))) (MonoidHomClass.toMonoidHom.{u1, u2, u3} \u03b1 \u03b2 hom (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _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\u2093'. -/\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 \u03b2]\n    [DiscreteTopology \u03b2] [Group \u03b2] [UniformGroup \u03b2] [MonoidHomClass hom \u03b1 \u03b2] {f : hom} :\n    UniformContinuous f \u2194 IsOpen ((f : \u03b1 \u2192* \u03b2).ker : Set \u03b1) :=\n  by\n  refine' \u27e8fun hf => _, fun hf => _\u27e9\n  \u00b7 apply (isOpen_discrete ({1} : Set \u03b2)).Preimage (UniformContinuous.continuous hf)\n  \u00b7 apply uniformContinuous_of_continuousAt_one\n    rw [ContinuousAt, nhds_discrete \u03b2, 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 \u03b2] [Group \u03b2]\n    [UniformGroup \u03b2] [MonoidHomClass hom \u03b1 \u03b2] {f : hom} (h : Continuous f) : UniformContinuous f :=\n  uniformContinuous_of_tendsto_one <|\n    suffices Tendsto f (\ud835\udcdd 1) (\ud835\udcdd (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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} \u03b9] {u : \u03b9 -> \u03b1} {v : \u03b9 -> \u03b1}, (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 v) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (\u03b9 -> \u03b1) (\u03b9 -> \u03b1) (\u03b9 -> \u03b1) (instHMul.{max u2 u1} (\u03b9 -> \u03b1) (Pi.instMul.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))) u v))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} \u03b9] {u : \u03b9 -> \u03b1} {v : \u03b9 -> \u03b1}, (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 v) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 (HMul.hMul.{max u1 u2, max u1 u2, max u1 u2} (\u03b9 -> \u03b1) (\u03b9 -> \u03b1) (\u03b9 -> \u03b1) (instHMul.{max u1 u2} (\u03b9 -> \u03b1) (Pi.instMul.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))) u v))\nCase conversion may be inaccurate. Consider using '#align cauchy_seq.mul CauchySeq.mul\u2093'. -/\n@[to_additive]\ntheorem CauchySeq.mul {\u03b9 : Type _} [SemilatticeSup \u03b9] {u v : \u03b9 \u2192 \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} \u03b9] {u : \u03b9 -> \u03b1} {x : \u03b1}, (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 (fun (n : \u03b9) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (u n) x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} \u03b9] {u : \u03b9 -> \u03b1} {x : \u03b1}, (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 (fun (n : \u03b9) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) (u n) x))\nCase conversion may be inaccurate. Consider using '#align cauchy_seq.mul_const CauchySeq.mul_const\u2093'. -/\n@[to_additive]\ntheorem CauchySeq.mul_const {\u03b9 : Type _} [SemilatticeSup \u03b9] {u : \u03b9 \u2192 \u03b1} {x : \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} \u03b9] {u : \u03b9 -> \u03b1} {x : \u03b1}, (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 (fun (n : \u03b9) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) x (u n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} \u03b9] {u : \u03b9 -> \u03b1} {x : \u03b1}, (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 (fun (n : \u03b9) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) x (u n)))\nCase conversion may be inaccurate. Consider using '#align cauchy_seq.const_mul CauchySeq.const_mul\u2093'. -/\n@[to_additive]\ntheorem CauchySeq.const_mul {\u03b9 : Type _} [SemilatticeSup \u03b9] {u : \u03b9 \u2192 \u03b1} {x : \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} \u03b9] {u : \u03b9 -> \u03b1}, (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 (Inv.inv.{max u2 u1} (\u03b9 -> \u03b1) (Pi.instInv.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) u))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u2}} [_inst_4 : SemilatticeSup.{u2} \u03b9] {u : \u03b9 -> \u03b1}, (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 u) -> (CauchySeq.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_4 (Inv.inv.{max u2 u1} (\u03b9 -> \u03b1) (Pi.instInv.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2))))) u))\nCase conversion may be inaccurate. Consider using '#align cauchy_seq.inv CauchySeq.inv\u2093'. -/\n@[to_additive]\ntheorem CauchySeq.inv {\u03b9 : Type _} [SemilatticeSup \u03b9] {u : \u03b9 \u2192 \u03b1} (h : CauchySeq u) :\n    CauchySeq u\u207b\u00b9 :=\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\u1d62_nhds_one is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {s : Set.{u1} \u03b1}, Iff (TotallyBounded.{u1} \u03b1 _inst_1 s) (forall (U : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) U (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))))))) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (t : Set.{u1} \u03b1) => And (Set.Finite.{u1} \u03b1 t) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s (Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (y : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y t) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y t) => SMul.smul.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.smulSet.{u1, u1} \u03b1 \u03b1 (Mul.toSMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))) y U)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {s : Set.{u1} \u03b1}, Iff (TotallyBounded.{u1} \u03b1 _inst_1 s) (forall (U : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) U (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (InvOneClass.toOne.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_2)))))))) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (t : Set.{u1} \u03b1) => And (Set.Finite.{u1} \u03b1 t) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s (Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (y : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y t) (fun (H : Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y t) => HSMul.hSMul.{u1, u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.{u1} \u03b1) (instHSMul.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.smulSet.{u1, u1} \u03b1 \u03b1 (MulAction.toSMul.{u1, u1} \u03b1 \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)) (Monoid.toMulAction.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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\u1d62_nhds_one\u2093'. -/\n@[to_additive]\ntheorem totallyBounded_iff_subset_finite_union\u1d62_nhds_one {s : Set \u03b1} :\n    TotallyBounded s \u2194 \u2200 U \u2208 \ud835\udcdd (1 : \u03b1), \u2203 t : Set \u03b1, t.Finite \u2227 s \u2286 \u22c3 y \u2208 t, y \u2022 U :=\n  (\ud835\udcdd (1 : \u03b1)).basis_sets.uniformity_of_nhds_one_inv_mul_swapped.totallyBounded_iff.trans <| by\n    simp [\u2190 preimage_smul_inv, preimage]\n#align totally_bounded_iff_subset_finite_Union_nhds_one totallyBounded_iff_subset_finite_union\u1d62_nhds_one\n#align totally_bounded_iff_subset_finite_Union_nhds_zero totallyBounded_iff_subset_finite_union\u1d62_nhds_zero\n\nsection UniformConvergence\n\nvariable {\u03b9 : Type _} {l : Filter \u03b9} {l' : Filter \u03b2} {f f' : \u03b9 \u2192 \u03b2 \u2192 \u03b1} {g g' : \u03b2 \u2192 \u03b1} {s : Set \u03b2}\n\n/- warning: tendsto_uniformly_on_filter.mul -> TendstoUniformlyOnFilter.mul is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u3}} {l : Filter.{u3} \u03b9} {l' : Filter.{u2} \u03b2} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1}, (TendstoUniformlyOnFilter.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f g l l') -> (TendstoUniformlyOnFilter.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l l') -> (TendstoUniformlyOnFilter.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 (HMul.hMul.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHMul.{max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instMul.{u3, max u2 u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instMul.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))))) f f') (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHMul.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instMul.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))) g g') l l')\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : UniformGroup.{u2} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u1}} {l : Filter.{u1} \u03b9} {l' : Filter.{u3} \u03b2} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1}, (TendstoUniformlyOnFilter.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f g l l') -> (TendstoUniformlyOnFilter.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l l') -> (TendstoUniformlyOnFilter.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 (HMul.hMul.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHMul.{max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instMul.{u1, max u2 u3} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instMul.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))))))) f f') (HMul.hMul.{max u2 u3, max u2 u3, max u2 u3} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHMul.{max u2 u3} (\u03b2 -> \u03b1) (Pi.instMul.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))))) g g') l l')\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.mul TendstoUniformlyOnFilter.mul\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u3}} {l : Filter.{u3} \u03b9} {l' : Filter.{u2} \u03b2} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1}, (TendstoUniformlyOnFilter.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f g l l') -> (TendstoUniformlyOnFilter.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l l') -> (TendstoUniformlyOnFilter.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 (HDiv.hDiv.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHDiv.{max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instDiv.{u3, max u2 u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instDiv.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) f f') (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHDiv.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instDiv.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) g g') l l')\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : UniformGroup.{u2} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u1}} {l : Filter.{u1} \u03b9} {l' : Filter.{u3} \u03b2} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1}, (TendstoUniformlyOnFilter.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f g l l') -> (TendstoUniformlyOnFilter.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l l') -> (TendstoUniformlyOnFilter.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 (HDiv.hDiv.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHDiv.{max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instDiv.{u1, max u2 u3} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instDiv.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))))) f f') (HDiv.hDiv.{max u2 u3, max u2 u3, max u2 u3} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHDiv.{max u2 u3} (\u03b2 -> \u03b1) (Pi.instDiv.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))) g g') l l')\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly_on_filter.div TendstoUniformlyOnFilter.div\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u3}} {l : Filter.{u3} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1} {s : Set.{u2} \u03b2}, (TendstoUniformlyOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f g l s) -> (TendstoUniformlyOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l s) -> (TendstoUniformlyOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 (HMul.hMul.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHMul.{max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instMul.{u3, max u2 u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instMul.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))))) f f') (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHMul.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instMul.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))) g g') l s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : UniformGroup.{u2} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u1}} {l : Filter.{u1} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1} {s : Set.{u3} \u03b2}, (TendstoUniformlyOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f g l s) -> (TendstoUniformlyOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l s) -> (TendstoUniformlyOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 (HMul.hMul.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHMul.{max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instMul.{u1, max u2 u3} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instMul.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))))))) f f') (HMul.hMul.{max u2 u3, max u2 u3, max u2 u3} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHMul.{max u2 u3} (\u03b2 -> \u03b1) (Pi.instMul.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))))) g g') l s)\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly_on.mul TendstoUniformlyOn.mul\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u3}} {l : Filter.{u3} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1} {s : Set.{u2} \u03b2}, (TendstoUniformlyOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f g l s) -> (TendstoUniformlyOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l s) -> (TendstoUniformlyOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 (HDiv.hDiv.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHDiv.{max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instDiv.{u3, max u2 u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instDiv.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) f f') (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHDiv.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instDiv.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) g g') l s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : UniformGroup.{u2} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u1}} {l : Filter.{u1} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1} {s : Set.{u3} \u03b2}, (TendstoUniformlyOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f g l s) -> (TendstoUniformlyOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l s) -> (TendstoUniformlyOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 (HDiv.hDiv.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHDiv.{max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instDiv.{u1, max u2 u3} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instDiv.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))))) f f') (HDiv.hDiv.{max u2 u3, max u2 u3, max u2 u3} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHDiv.{max u2 u3} (\u03b2 -> \u03b1) (Pi.instDiv.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))) g g') l s)\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly_on.div TendstoUniformlyOn.div\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u3}} {l : Filter.{u3} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1}, (TendstoUniformly.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f g l) -> (TendstoUniformly.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l) -> (TendstoUniformly.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 (HMul.hMul.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHMul.{max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instMul.{u3, max u2 u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instMul.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))))) f f') (HMul.hMul.{max u2 u1, max u2 u1, max u2 u1} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHMul.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instMul.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))))) g g') l)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : UniformGroup.{u2} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u1}} {l : Filter.{u1} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1}, (TendstoUniformly.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f g l) -> (TendstoUniformly.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l) -> (TendstoUniformly.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 (HMul.hMul.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHMul.{max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instMul.{u1, max u2 u3} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instMul.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))))))) f f') (HMul.hMul.{max u2 u3, max u2 u3, max u2 u3} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHMul.{max u2 u3} (\u03b2 -> \u03b1) (Pi.instMul.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))))) g g') l)\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly.mul TendstoUniformly.mul\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u3}} {l : Filter.{u3} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1}, (TendstoUniformly.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f g l) -> (TendstoUniformly.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l) -> (TendstoUniformly.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 (HDiv.hDiv.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHDiv.{max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instDiv.{u3, max u2 u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instDiv.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) f f') (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHDiv.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instDiv.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) g g') l)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : UniformGroup.{u2} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u1}} {l : Filter.{u1} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {g : \u03b2 -> \u03b1} {g' : \u03b2 -> \u03b1}, (TendstoUniformly.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f g l) -> (TendstoUniformly.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f' g' l) -> (TendstoUniformly.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 (HDiv.hDiv.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHDiv.{max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instDiv.{u1, max u2 u3} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instDiv.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))))) f f') (HDiv.hDiv.{max u2 u3, max u2 u3, max u2 u3} (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (\u03b2 -> \u03b1) (instHDiv.{max u2 u3} (\u03b2 -> \u03b1) (Pi.instDiv.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))) g g') l)\nCase conversion may be inaccurate. Consider using '#align tendsto_uniformly.div TendstoUniformly.div\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u3}} {l : Filter.{u3} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {s : Set.{u2} \u03b2}, (UniformCauchySeqOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f l s) -> (UniformCauchySeqOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f' l s) -> (UniformCauchySeqOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 (HMul.hMul.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHMul.{max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instMul.{u3, max u2 u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instMul.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))))) f f') l s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : UniformGroup.{u2} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u1}} {l : Filter.{u1} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {s : Set.{u3} \u03b2}, (UniformCauchySeqOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f l s) -> (UniformCauchySeqOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f' l s) -> (UniformCauchySeqOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 (HMul.hMul.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHMul.{max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instMul.{u1, max u2 u3} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instMul.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))))))) f f') l s)\nCase conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on.mul UniformCauchySeqOn.mul\u2093'. -/\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : UniformGroup.{u1} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u3}} {l : Filter.{u3} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {s : Set.{u2} \u03b2}, (UniformCauchySeqOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f l s) -> (UniformCauchySeqOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 f' l s) -> (UniformCauchySeqOn.{u2, u1, u3} \u03b2 \u03b1 \u03b9 _inst_1 (HDiv.hDiv.{max u3 u2 u1, max u3 u2 u1, max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHDiv.{max u3 u2 u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instDiv.{u3, max u2 u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instDiv.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toHasDiv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))))) f f') l s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : UniformGroup.{u2} \u03b1 _inst_1 _inst_2] {\u03b9 : Type.{u1}} {l : Filter.{u1} \u03b9} {f : \u03b9 -> \u03b2 -> \u03b1} {f' : \u03b9 -> \u03b2 -> \u03b1} {s : Set.{u3} \u03b2}, (UniformCauchySeqOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f l s) -> (UniformCauchySeqOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 f' l s) -> (UniformCauchySeqOn.{u3, u2, u1} \u03b2 \u03b1 \u03b9 _inst_1 (HDiv.hDiv.{max (max u2 u3) u1, max (max u2 u3) u1, max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (\u03b9 -> \u03b2 -> \u03b1) (instHDiv.{max (max u2 u3) u1} (\u03b9 -> \u03b2 -> \u03b1) (Pi.instDiv.{u1, max u2 u3} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b2 -> \u03b1) (fun (i : \u03b9) => Pi.instDiv.{u3, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => DivInvMonoid.toDiv.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))))) f f') l s)\nCase conversion may be inaccurate. Consider using '#align uniform_cauchy_seq_on.div UniformCauchySeqOn.div\u2093'. -/\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 \u00d7 G => p.2 / p.1) (\ud835\udcdd 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 \u00d7 G => (p.2 / p.1)\u207b\u00b9) (comap (fun p : G \u00d7 G => p.2 / p.1) (\ud835\udcdd 1)) (\ud835\udcdd 1\u207b\u00b9) 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    \u00b7 rcases H with \u27e8U, U_nhds, U_sub\u27e9\n      rcases exists_nhds_one_split U_nhds with \u27e8V, \u27e8V_nhds, V_sum\u27e9\u27e9\n      exists (fun p : G \u00d7 G => p.2 / p.1) \u207b\u00b9' V\n      have H :\n        (fun p : G \u00d7 G => p.2 / p.1) \u207b\u00b9' V \u2208 comap (fun p : G \u00d7 G => p.2 / p.1) (\ud835\udcdd (1 : G)) := by\n        exists V, V_nhds <;> rfl\n      exists H\n      have comp_rel_sub :\n        compRel ((fun p : G \u00d7 G => p.2 / p.1) \u207b\u00b9' V) ((fun p => p.2 / p.1) \u207b\u00b9' V) \u2286\n          (fun p : G \u00d7 G => p.2 / p.1) \u207b\u00b9' U :=\n        by\n        intro p p_comp_rel\n        rcases p_comp_rel with \u27e8z, \u27e8Hz1, Hz2\u27e9\u27e9\n        simpa using V_sum _ Hz2 _ Hz1\n      exact Set.Subset.trans comp_rel_sub U_sub\n    \u00b7 exact monotone_id.comp_rel monotone_id\n  isOpen_uniformity := by\n    intro S\n    let S' x := { p : G \u00d7 G | p.1 = x \u2192 p.2 \u2208 S }\n    show IsOpen S \u2194 \u2200 x : G, x \u2208 S \u2192 S' x \u2208 comap (fun p : G \u00d7 G => p.2 / p.1) (\ud835\udcdd (1 : G))\n    rw [isOpen_iff_mem_nhds]\n    refine' forall\u2082_congr fun a ha => _\n    rw [\u2190 nhds_translation_div, mem_comap, mem_comap]\n    refine' exists\u2082_congr fun t ht => _\n    show (fun y : G => y / a) \u207b\u00b9' t \u2286 S \u2194 (fun p : G \u00d7 G => p.snd / p.fst) \u207b\u00b9' t \u2286 S' a\n    constructor\n    \u00b7 rintro h \u27e8x, y\u27e9 hx rfl\n      exact h hx\n    \u00b7 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'\u2093'. -/\n@[to_additive]\ntheorem uniformity_eq_comap_nhds_one' : \ud835\udce4 G = comap (fun p : G \u00d7 G => p.2 / p.1) (\ud835\udcdd (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  \u27e8by\n    apply CompactSpace.uniformContinuous_of_continuous\n    exact continuous_div'\u27e9\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\u2093.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\u2093'. -/\n@[to_additive]\ninstance Subgroup.isClosed_of_discrete [T2Space G] {H : Subgroup G} [DiscreteTopology H] :\n    IsClosed (H : Set G) :=\n  by\n  obtain \u27e8V, V_in, VH\u27e9 : \u2203 (V : Set G)(hV : V \u2208 \ud835\udcdd (1 : G)), V \u2229 (H : Set G) = {1}\n  exact nhds_inter_eq_singleton_of_mem_discrete H.one_mem\n  haveI : SeparatedSpace G := separated_iff_t2.mpr \u2039_\u203a\n  have : (fun p : G \u00d7 G => p.2 / p.1) \u207b\u00b9' V \u2208 \ud835\udce4 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 \u2208 V)\n  have : h' / h \u2208 ({1} : Set G) := VH \u25b8 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] {\u03b9 : Type.{u2}} {\u03b1 : Type.{u3}} (F : \u03b9 -> \u03b1 -> G) (f : \u03b1 -> G) (p : Filter.{u2} \u03b9), Iff (TendstoUniformly.{u3, u1, u2} \u03b1 G \u03b9 (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} \u03b9 (fun (i : \u03b9) => forall (a : \u03b1), 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] {\u03b9 : Type.{u3}} {\u03b1 : Type.{u2}} (F : \u03b9 -> \u03b1 -> G) (f : \u03b1 -> G) (p : Filter.{u3} \u03b9), Iff (TendstoUniformly.{u2, u1, u3} \u03b1 G \u03b9 (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} \u03b9 (fun (i : \u03b9) => forall (a : \u03b1), 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\u2093'. -/\n@[to_additive]\ntheorem TopologicalGroup.tendstoUniformly_iff {\u03b9 \u03b1 : Type _} (F : \u03b9 \u2192 \u03b1 \u2192 G) (f : \u03b1 \u2192 G)\n    (p : Filter \u03b9) :\n    @TendstoUniformly \u03b1 G \u03b9 (TopologicalGroup.toUniformSpace G) F f p \u2194\n      \u2200 u \u2208 \ud835\udcdd (1 : G), \u2200\u1da0 i in p, \u2200 a, F i a / f a \u2208 u :=\n  \u27e8fun h u hu => h _ \u27e8u, hu, fun _ => id\u27e9, fun h v \u27e8u, hu, hv\u27e9 =>\n    mem_of_superset (h u hu) fun i hi a => hv (hi a)\u27e9\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] {\u03b9 : Type.{u2}} {\u03b1 : Type.{u3}} (F : \u03b9 -> \u03b1 -> G) (f : \u03b1 -> G) (p : Filter.{u2} \u03b9) (s : Set.{u3} \u03b1), Iff (TendstoUniformlyOn.{u3, u1, u2} \u03b1 G \u03b9 (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} \u03b9 (fun (i : \u03b9) => forall (a : \u03b1), (Membership.Mem.{u3, u3} \u03b1 (Set.{u3} \u03b1) (Set.hasMem.{u3} \u03b1) 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] {\u03b9 : Type.{u3}} {\u03b1 : Type.{u2}} (F : \u03b9 -> \u03b1 -> G) (f : \u03b1 -> G) (p : Filter.{u3} \u03b9) (s : Set.{u2} \u03b1), Iff (TendstoUniformlyOn.{u2, u1, u3} \u03b1 G \u03b9 (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} \u03b9 (fun (i : \u03b9) => forall (a : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) 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\u2093'. -/\n@[to_additive]\ntheorem TopologicalGroup.tendstoUniformlyOn_iff {\u03b9 \u03b1 : Type _} (F : \u03b9 \u2192 \u03b1 \u2192 G) (f : \u03b1 \u2192 G)\n    (p : Filter \u03b9) (s : Set \u03b1) :\n    @TendstoUniformlyOn \u03b1 G \u03b9 (TopologicalGroup.toUniformSpace G) F f p s \u2194\n      \u2200 u \u2208 \ud835\udcdd (1 : G), \u2200\u1da0 i in p, \u2200 a \u2208 s, F i a / f a \u2208 u :=\n  \u27e8fun h u hu => h _ \u27e8u, hu, fun _ => id\u27e9, fun h v \u27e8u, hu, hv\u27e9 =>\n    mem_of_superset (h u hu) fun i hi a ha => hv (hi a ha)\u27e9\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] {\u03b9 : Type.{u2}} {\u03b1 : Type.{u3}} [_inst_4 : TopologicalSpace.{u3} \u03b1] (F : \u03b9 -> \u03b1 -> G) (f : \u03b1 -> G) (p : Filter.{u2} \u03b9), Iff (TendstoLocallyUniformly.{u3, u1, u2} \u03b1 G \u03b9 (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 : \u03b1), Exists.{succ u3} (Set.{u3} \u03b1) (fun (t : Set.{u3} \u03b1) => Exists.{0} (Membership.Mem.{u3, u3} (Set.{u3} \u03b1) (Filter.{u3} \u03b1) (Filter.hasMem.{u3} \u03b1) t (nhds.{u3} \u03b1 _inst_4 x)) (fun (H : Membership.Mem.{u3, u3} (Set.{u3} \u03b1) (Filter.{u3} \u03b1) (Filter.hasMem.{u3} \u03b1) t (nhds.{u3} \u03b1 _inst_4 x)) => Filter.Eventually.{u2} \u03b9 (fun (i : \u03b9) => forall (a : \u03b1), (Membership.Mem.{u3, u3} \u03b1 (Set.{u3} \u03b1) (Set.hasMem.{u3} \u03b1) 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] {\u03b9 : Type.{u3}} {\u03b1 : Type.{u2}} [_inst_4 : TopologicalSpace.{u2} \u03b1] (F : \u03b9 -> \u03b1 -> G) (f : \u03b1 -> G) (p : Filter.{u3} \u03b9), Iff (TendstoLocallyUniformly.{u2, u1, u3} \u03b1 G \u03b9 (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 : \u03b1), Exists.{succ u2} (Set.{u2} \u03b1) (fun (t : Set.{u2} \u03b1) => And (Membership.mem.{u2, u2} (Set.{u2} \u03b1) (Filter.{u2} \u03b1) (instMembershipSetFilter.{u2} \u03b1) t (nhds.{u2} \u03b1 _inst_4 x)) (Filter.Eventually.{u3} \u03b9 (fun (i : \u03b9) => forall (a : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) 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\u2093'. -/\n@[to_additive]\ntheorem TopologicalGroup.tendstoLocallyUniformly_iff {\u03b9 \u03b1 : Type _} [TopologicalSpace \u03b1]\n    (F : \u03b9 \u2192 \u03b1 \u2192 G) (f : \u03b1 \u2192 G) (p : Filter \u03b9) :\n    @TendstoLocallyUniformly \u03b1 G \u03b9 (TopologicalGroup.toUniformSpace G) _ F f p \u2194\n      \u2200 u \u2208 \ud835\udcdd (1 : G), \u2200 (x : \u03b1), \u2203 t \u2208 \ud835\udcdd x, \u2200\u1da0 i in p, \u2200 a \u2208 t, F i a / f a \u2208 u :=\n  \u27e8fun h u hu => h _ \u27e8u, hu, fun _ => id\u27e9, fun h v \u27e8u, hu, hv\u27e9 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)\u27e9\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] {\u03b9 : Type.{u2}} {\u03b1 : Type.{u3}} [_inst_4 : TopologicalSpace.{u3} \u03b1] (F : \u03b9 -> \u03b1 -> G) (f : \u03b1 -> G) (p : Filter.{u2} \u03b9) (s : Set.{u3} \u03b1), Iff (TendstoLocallyUniformlyOn.{u3, u1, u2} \u03b1 G \u03b9 (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 : \u03b1), (Membership.Mem.{u3, u3} \u03b1 (Set.{u3} \u03b1) (Set.hasMem.{u3} \u03b1) x s) -> (Exists.{succ u3} (Set.{u3} \u03b1) (fun (t : Set.{u3} \u03b1) => Exists.{0} (Membership.Mem.{u3, u3} (Set.{u3} \u03b1) (Filter.{u3} \u03b1) (Filter.hasMem.{u3} \u03b1) t (nhdsWithin.{u3} \u03b1 _inst_4 x s)) (fun (H : Membership.Mem.{u3, u3} (Set.{u3} \u03b1) (Filter.{u3} \u03b1) (Filter.hasMem.{u3} \u03b1) t (nhdsWithin.{u3} \u03b1 _inst_4 x s)) => Filter.Eventually.{u2} \u03b9 (fun (i : \u03b9) => forall (a : \u03b1), (Membership.Mem.{u3, u3} \u03b1 (Set.{u3} \u03b1) (Set.hasMem.{u3} \u03b1) 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] {\u03b9 : Type.{u3}} {\u03b1 : Type.{u2}} [_inst_4 : TopologicalSpace.{u2} \u03b1] (F : \u03b9 -> \u03b1 -> G) (f : \u03b1 -> G) (p : Filter.{u3} \u03b9) (s : Set.{u2} \u03b1), Iff (TendstoLocallyUniformlyOn.{u2, u1, u3} \u03b1 G \u03b9 (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 : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x s) -> (Exists.{succ u2} (Set.{u2} \u03b1) (fun (t : Set.{u2} \u03b1) => And (Membership.mem.{u2, u2} (Set.{u2} \u03b1) (Filter.{u2} \u03b1) (instMembershipSetFilter.{u2} \u03b1) t (nhdsWithin.{u2} \u03b1 _inst_4 x s)) (Filter.Eventually.{u3} \u03b9 (fun (i : \u03b9) => forall (a : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) 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\u2093'. -/\n@[to_additive]\ntheorem TopologicalGroup.tendstoLocallyUniformlyOn_iff {\u03b9 \u03b1 : Type _} [TopologicalSpace \u03b1]\n    (F : \u03b9 \u2192 \u03b1 \u2192 G) (f : \u03b1 \u2192 G) (p : Filter \u03b9) (s : Set \u03b1) :\n    @TendstoLocallyUniformlyOn \u03b1 G \u03b9 (TopologicalGroup.toUniformSpace G) _ F f p s \u2194\n      \u2200 u \u2208 \ud835\udcdd (1 : G), \u2200 x \u2208 s, \u2203 t \u2208 \ud835\udcdd[s] x, \u2200\u1da0 i in p, \u2200 a \u2208 t, F i a / f a \u2208 u :=\n  \u27e8fun h u hu => h _ \u27e8u, hu, fun _ => id\u27e9, fun h v \u27e8u, hu, hv\u27e9 x =>\n    (Exists.imp fun a => Exists.imp fun ha hp => mem_of_superset hp fun i hi a ha => hv (hi a ha)) \u2218\n      h u hu x\u27e9\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 \u00d7 G => p.1 / p.2) \u2218 fun p : (G \u00d7 G) \u00d7 G \u00d7 G => (p.1.2 / p.1.1, p.2.2 / p.2.1))\n      (comap (fun p : (G \u00d7 G) \u00d7 G \u00d7 G => (p.1.2 / p.1.1, p.2.2 / p.2.1)) ((\ud835\udcdd 1).Prod (\ud835\udcdd 1)))\n      (\ud835\udcdd (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 [(\u00b7 \u2218 \u00b7), 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\u2093'. -/\n@[to_additive]\ntheorem TopologicalGroup.t2Space_iff_one_closed : T2Space G \u2194 IsClosed ({1} : Set G) :=\n  by\n  haveI : UniformGroup G := comm_topologicalGroup_is_uniform\n  rw [\u2190 separated_iff_t2, separatedSpace_iff, \u2190 closure_eq_iff_isClosed]\n  constructor <;> intro h\n  \u00b7 apply subset.antisymm\n    \u00b7 intro x x_in\n      have := group_separationRel x 1\n      rw [div_one] at this\n      rw [\u2190 this, h] at x_in\n      change x = 1 at x_in\n      simp [x_in]\n    \u00b7 exact subset_closure\n  \u00b7 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\u2093'. -/\n@[to_additive]\ntheorem TopologicalGroup.t2Space_of_one_sep (H : \u2200 x : G, x \u2260 1 \u2192 \u2203 U \u2208 nhds (1 : G), x \u2209 U) :\n    T2Space G :=\n  by\n  rw [TopologicalGroup.t2Space_iff_one_closed, \u2190 isOpen_compl_iff, isOpen_iff_mem_nhds]\n  intro x x_not\n  have : x \u2260 1 := mem_compl_singleton_iff.mp x_not\n  rcases H x this with \u27e8U, U_in, xU\u27e9\n  rw [\u2190 nhds_one_symm G] at U_in\n  rcases U_in with \u27e8W, W_in, UW\u27e9\n  rw [\u2190 nhds_translation_mul_inv]\n  use W, W_in\n  rw [subset_compl_comm]\n  suffices x\u207b\u00b9 \u2209 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 {\u03b1 : Type _} {\u03b2 : Type _} {hom : Type _}\n\nvariable [TopologicalSpace \u03b1] [Group \u03b1] [TopologicalGroup \u03b1]\n\n-- \u03b2 is a dense subgroup of \u03b1, inclusion is denoted by e\nvariable [TopologicalSpace \u03b2] [Group \u03b2]\n\nvariable [MonoidHomClass hom \u03b2 \u03b1] {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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {hom : Type.{u3}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : Group.{u1} \u03b1] [_inst_3 : TopologicalGroup.{u1} \u03b1 _inst_1 _inst_2] [_inst_4 : TopologicalSpace.{u2} \u03b2] [_inst_5 : Group.{u2} \u03b2] [_inst_6 : MonoidHomClass.{u3, u2, u1} hom \u03b2 \u03b1 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))] {e : hom}, (DenseInducing.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (coeFn.{succ u3, max (succ u2) (succ u1)} hom (fun (_x : hom) => \u03b2 -> \u03b1) (FunLike.hasCoeToFun.{succ u3, succ u2, succ u1} hom \u03b2 (fun (_x : \u03b2) => \u03b1) (MulHomClass.toFunLike.{u3, u2, u1} hom \u03b2 \u03b1 (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MonoidHomClass.toMulHomClass.{u3, u2, u1} hom \u03b2 \u03b1 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) _inst_6))) e)) -> (forall (x\u2080 : \u03b1), Filter.Tendsto.{u2, u2} (Prod.{u2, u2} \u03b2 \u03b2) \u03b2 (fun (t : Prod.{u2, u2} \u03b2 \u03b2) => HDiv.hDiv.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHDiv.{u2} \u03b2 (DivInvMonoid.toHasDiv.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) (Prod.snd.{u2, u2} \u03b2 \u03b2 t) (Prod.fst.{u2, u2} \u03b2 \u03b2 t)) (Filter.comap.{u2, u1} (Prod.{u2, u2} \u03b2 \u03b2) (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u2, u2} \u03b2 \u03b2) => Prod.mk.{u1, u1} \u03b1 \u03b1 (coeFn.{succ u3, max (succ u2) (succ u1)} hom (fun (_x : hom) => \u03b2 -> \u03b1) (FunLike.hasCoeToFun.{succ u3, succ u2, succ u1} hom \u03b2 (fun (_x : \u03b2) => \u03b1) (MulHomClass.toFunLike.{u3, u2, u1} hom \u03b2 \u03b1 (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MonoidHomClass.toMulHomClass.{u3, u2, u1} hom \u03b2 \u03b1 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) _inst_6))) e (Prod.fst.{u2, u2} \u03b2 \u03b2 p)) (coeFn.{succ u3, max (succ u2) (succ u1)} hom (fun (_x : hom) => \u03b2 -> \u03b1) (FunLike.hasCoeToFun.{succ u3, succ u2, succ u1} hom \u03b2 (fun (_x : \u03b2) => \u03b1) (MulHomClass.toFunLike.{u3, u2, u1} hom \u03b2 \u03b1 (MulOneClass.toHasMul.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))) (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2)))) (MonoidHomClass.toMulHomClass.{u3, u2, u1} hom \u03b2 \u03b1 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5))) (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_2))) _inst_6))) e (Prod.snd.{u2, u2} \u03b2 \u03b2 p))) (nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (Prod.mk.{u1, u1} \u03b1 \u03b1 x\u2080 x\u2080))) (nhds.{u2} \u03b2 _inst_4 (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (MulOneClass.toHasOne.{u2} \u03b2 (Monoid.toMulOneClass.{u2} \u03b2 (DivInvMonoid.toMonoid.{u2} \u03b2 (Group.toDivInvMonoid.{u2} \u03b2 _inst_5)))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {hom : Type.{u1}} [_inst_1 : TopologicalSpace.{u2} \u03b1] [_inst_2 : Group.{u2} \u03b1] [_inst_3 : TopologicalGroup.{u2} \u03b1 _inst_1 _inst_2] [_inst_4 : TopologicalSpace.{u3} \u03b2] [_inst_5 : Group.{u3} \u03b2] [_inst_6 : MonoidHomClass.{u1, u3, u2} hom \u03b2 \u03b1 (Monoid.toMulOneClass.{u3} \u03b2 (DivInvMonoid.toMonoid.{u3} \u03b2 (Group.toDivInvMonoid.{u3} \u03b2 _inst_5))) (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))] {e : hom}, (DenseInducing.{u3, u2} \u03b2 \u03b1 _inst_4 _inst_1 (FunLike.coe.{succ u1, succ u3, succ u2} hom \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u3, u2} hom \u03b2 \u03b1 (MulOneClass.toMul.{u3} \u03b2 (Monoid.toMulOneClass.{u3} \u03b2 (DivInvMonoid.toMonoid.{u3} \u03b2 (Group.toDivInvMonoid.{u3} \u03b2 _inst_5)))) (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} hom \u03b2 \u03b1 (Monoid.toMulOneClass.{u3} \u03b2 (DivInvMonoid.toMonoid.{u3} \u03b2 (Group.toDivInvMonoid.{u3} \u03b2 _inst_5))) (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))) _inst_6)) e)) -> (forall (x\u2080 : \u03b1), Filter.Tendsto.{u3, u3} (Prod.{u3, u3} \u03b2 \u03b2) \u03b2 (fun (t : Prod.{u3, u3} \u03b2 \u03b2) => HDiv.hDiv.{u3, u3, u3} \u03b2 \u03b2 \u03b2 (instHDiv.{u3} \u03b2 (DivInvMonoid.toDiv.{u3} \u03b2 (Group.toDivInvMonoid.{u3} \u03b2 _inst_5))) (Prod.snd.{u3, u3} \u03b2 \u03b2 t) (Prod.fst.{u3, u3} \u03b2 \u03b2 t)) (Filter.comap.{u3, u2} (Prod.{u3, u3} \u03b2 \u03b2) (Prod.{u2, u2} \u03b1 \u03b1) (fun (p : Prod.{u3, u3} \u03b2 \u03b2) => Prod.mk.{u2, u2} \u03b1 \u03b1 (FunLike.coe.{succ u1, succ u3, succ u2} hom \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u3, u2} hom \u03b2 \u03b1 (MulOneClass.toMul.{u3} \u03b2 (Monoid.toMulOneClass.{u3} \u03b2 (DivInvMonoid.toMonoid.{u3} \u03b2 (Group.toDivInvMonoid.{u3} \u03b2 _inst_5)))) (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} hom \u03b2 \u03b1 (Monoid.toMulOneClass.{u3} \u03b2 (DivInvMonoid.toMonoid.{u3} \u03b2 (Group.toDivInvMonoid.{u3} \u03b2 _inst_5))) (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))) _inst_6)) e (Prod.fst.{u3, u3} \u03b2 \u03b2 p)) (FunLike.coe.{succ u1, succ u3, succ u2} hom \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u3, u2} hom \u03b2 \u03b1 (MulOneClass.toMul.{u3} \u03b2 (Monoid.toMulOneClass.{u3} \u03b2 (DivInvMonoid.toMonoid.{u3} \u03b2 (Group.toDivInvMonoid.{u3} \u03b2 _inst_5)))) (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2)))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} hom \u03b2 \u03b1 (Monoid.toMulOneClass.{u3} \u03b2 (DivInvMonoid.toMonoid.{u3} \u03b2 (Group.toDivInvMonoid.{u3} \u03b2 _inst_5))) (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_2))) _inst_6)) e (Prod.snd.{u3, u3} \u03b2 \u03b2 p))) (nhds.{u2} (Prod.{u2, u2} \u03b1 \u03b1) (instTopologicalSpaceProd.{u2, u2} \u03b1 \u03b1 _inst_1 _inst_1) (Prod.mk.{u2, u2} \u03b1 \u03b1 x\u2080 x\u2080))) (nhds.{u3} \u03b2 _inst_4 (OfNat.ofNat.{u3} \u03b2 1 (One.toOfNat1.{u3} \u03b2 (InvOneClass.toOne.{u3} \u03b2 (DivInvOneMonoid.toInvOneClass.{u3} \u03b2 (DivisionMonoid.toDivInvOneMonoid.{u3} \u03b2 (Group.toDivisionMonoid.{u3} \u03b2 _inst_5))))))))\nCase conversion may be inaccurate. Consider using '#align tendsto_div_comap_self tendsto_div_comap_self\u2093'. -/\n@[to_additive]\ntheorem tendsto_div_comap_self (x\u2080 : \u03b1) :\n    Tendsto (fun t : \u03b2 \u00d7 \u03b2 => t.2 / t.1) ((comap fun p : \u03b2 \u00d7 \u03b2 => (e p.1, e p.2)) <| \ud835\udcdd (x\u2080, x\u2080))\n      (\ud835\udcdd 1) :=\n  by\n  have comm :\n    ((fun x : \u03b1 \u00d7 \u03b1 => x.2 / x.1) \u2218 fun t : \u03b2 \u00d7 \u03b2 => (e t.1, e t.2)) =\n      e \u2218 fun t : \u03b2 \u00d7 \u03b2 => t.2 / t.1 :=\n    by\n    ext t\n    change e t.2 / e t.1 = e (t.2 / t.1)\n    rwa [\u2190 map_div e t.2 t.1]\n  have lim : tendsto (fun x : \u03b1 \u00d7 \u03b1 => x.2 / x.1) (\ud835\udcdd (x\u2080, x\u2080)) (\ud835\udcdd (e 1)) := by\n    simpa using (continuous_div'.comp (@continuous_swap \u03b1 \u03b1 _ _)).Tendsto (x\u2080, x\u2080)\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 {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _} {\u03b4 : Type _}\n\nvariable {G : Type _}\n\n-- \u03b2 is a dense subgroup of \u03b1, inclusion is denoted by e\n-- \u03b4 is a dense subgroup of \u03b3, inclusion is denoted by f\nvariable [TopologicalSpace \u03b1] [AddCommGroup \u03b1] [TopologicalAddGroup \u03b1]\n\nvariable [TopologicalSpace \u03b2] [AddCommGroup \u03b2] [TopologicalAddGroup \u03b2]\n\nvariable [TopologicalSpace \u03b3] [AddCommGroup \u03b3] [TopologicalAddGroup \u03b3]\n\nvariable [TopologicalSpace \u03b4] [AddCommGroup \u03b4] [TopologicalAddGroup \u03b4]\n\nvariable [UniformSpace G] [AddCommGroup G] [UniformAddGroup G] [SeparatedSpace G] [CompleteSpace G]\n\nvariable {e : \u03b2 \u2192+ \u03b1} (de : DenseInducing e)\n\nvariable {f : \u03b4 \u2192+ \u03b3} (df : DenseInducing f)\n\nvariable {\u03c6 : \u03b2 \u2192+ \u03b4 \u2192+ G}\n\n-- mathport name: expr\u03a6\nlocal notation \"\u03a6\" => fun p : \u03b2 \u00d7 \u03b4 => \u03c6 p.1 p.2\n\nvariable (h\u03c6 : Continuous \u03a6)\n\ninclude de df h\u03c6\n\nvariable {W' : Set G} (W'_nhd : W' \u2208 \ud835\udcdd (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]\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x x' \u00abexpr \u2208 \u00bb U\u2082) -/\n#print [anonymous] /-\nprivate theorem [anonymous] (x\u2080 : \u03b1) (y\u2081 : \u03b4) :\n    \u2203 U\u2082 \u2208 comap e (\ud835\udcdd x\u2080), \u2200 (x) (_ : x \u2208 U\u2082) (x') (_ : x' \u2208 U\u2082), \u03a6 (x' - x, y\u2081) \u2208 W' :=\n  by\n  let Nx := \ud835\udcdd x\u2080\n  let ee := fun u : \u03b2 \u00d7 \u03b2 => (e u.1, e u.2)\n  have lim1 : tendsto (fun a : \u03b2 \u00d7 \u03b2 => (a.2 - a.1, y\u2081)) (comap e Nx \u00d7\u1da0 comap e Nx) (\ud835\udcdd (0, y\u2081)) :=\n    by\n    have :=\n      tendsto.prod_mk (tendsto_sub_comap_self de x\u2080)\n        (tendsto_const_nhds : tendsto (fun p : \u03b2 \u00d7 \u03b2 => y\u2081) (comap ee <| \ud835\udcdd (x\u2080, x\u2080)) (\ud835\udcdd y\u2081))\n    rw [nhds_prod_eq, prod_comap_comap_eq, \u2190 nhds_prod_eq]\n    exact (this : _)\n  have lim2 : tendsto \u03a6 (\ud835\udcdd (0, y\u2081)) (\ud835\udcdd 0) := by simpa using h\u03c6.tendsto (0, y\u2081)\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]\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x x' \u00abexpr \u2208 \u00bb U\u2081) -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y y' \u00abexpr \u2208 \u00bb V\u2081) -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x x' \u00abexpr \u2208 \u00bb U) -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y y' \u00abexpr \u2208 \u00bb V) -/\n#print [anonymous] /-\nprivate theorem [anonymous] (x\u2080 : \u03b1) (y\u2080 : \u03b3) :\n    \u2203 U \u2208 comap e (\ud835\udcdd x\u2080),\n      \u2203 V \u2208 comap f (\ud835\udcdd y\u2080),\n        \u2200 (x) (_ : x \u2208 U) (x') (_ : x' \u2208 U),\n          \u2200 (y) (_ : y \u2208 V) (y') (_ : y' \u2208 V), \u03a6 (x', y') - \u03a6 (x, y) \u2208 W' :=\n  by\n  let Nx := \ud835\udcdd x\u2080\n  let Ny := \ud835\udcdd y\u2080\n  let dp := DenseInducing.prod de df\n  let ee := fun u : \u03b2 \u00d7 \u03b2 => (e u.1, e u.2)\n  let ff := fun u : \u03b4 \u00d7 \u03b4 => (f u.1, f u.2)\n  have lim_\u03c6 : Filter.Tendsto \u03a6 (\ud835\udcdd (0, 0)) (\ud835\udcdd 0) := by simpa using h\u03c6.tendsto (0, 0)\n  have lim_\u03c6_sub_sub :\n    tendsto (fun p : (\u03b2 \u00d7 \u03b2) \u00d7 \u03b4 \u00d7 \u03b4 => \u03a6 (p.1.2 - p.1.1, p.2.2 - p.2.1))\n      ((comap ee <| \ud835\udcdd (x\u2080, x\u2080)) \u00d7\u1da0 (comap ff <| \ud835\udcdd (y\u2080, y\u2080))) (\ud835\udcdd 0) :=\n    by\n    have lim_sub_sub :\n      tendsto (fun p : (\u03b2 \u00d7 \u03b2) \u00d7 \u03b4 \u00d7 \u03b4 => (p.1.2 - p.1.1, p.2.2 - p.2.1))\n        (comap ee (\ud835\udcdd (x\u2080, x\u2080)) \u00d7\u1da0 comap ff (\ud835\udcdd (y\u2080, y\u2080))) (\ud835\udcdd 0 \u00d7\u1da0 \ud835\udcdd 0) :=\n      by\n      have := Filter.prod_mono (tendsto_sub_comap_self de x\u2080) (tendsto_sub_comap_self df y\u2080)\n      rwa [prod_map_map_eq] at this\n    rw [\u2190 nhds_prod_eq] at lim_sub_sub\n    exact tendsto.comp lim_\u03c6 lim_sub_sub\n  rcases exists_nhds_zero_quarter W'_nhd with \u27e8W, W_nhd, W4\u27e9\n  have :\n    \u2203 U\u2081 \u2208 comap e (\ud835\udcdd x\u2080),\n      \u2203 V\u2081 \u2208 comap f (\ud835\udcdd y\u2080),\n        \u2200 (x) (_ : x \u2208 U\u2081) (x') (_ : x' \u2208 U\u2081),\n          \u2200 (y) (_ : y \u2208 V\u2081) (y') (_ : y' \u2208 V\u2081), \u03a6 (x' - x, y' - y) \u2208 W :=\n    by\n    have := tendsto_prod_iff.1 lim_\u03c6_sub_sub W W_nhd\n    repeat' rw [nhds_prod_eq, \u2190 prod_comap_comap_eq] at this\n    rcases this with \u27e8U, U_in, V, V_in, H\u27e9\n    rw [mem_prod_same_iff] at U_in V_in\n    rcases U_in with \u27e8U\u2081, U\u2081_in, HU\u2081\u27e9\n    rcases V_in with \u27e8V\u2081, V\u2081_in, HV\u2081\u27e9\n    exists U\u2081, U\u2081_in, V\u2081, V\u2081_in\n    intro x x_in x' x'_in y y_in y' y'_in\n    exact H _ _ (HU\u2081 (mk_mem_prod x_in x'_in)) (HV\u2081 (mk_mem_prod y_in y'_in))\n  rcases this with \u27e8U\u2081, U\u2081_nhd, V\u2081, V\u2081_nhd, H\u27e9\n  obtain \u27e8x\u2081, x\u2081_in\u27e9 : U\u2081.nonempty := (de.comap_nhds_ne_bot _).nonempty_of_mem U\u2081_nhd\n  obtain \u27e8y\u2081, y\u2081_in\u27e9 : V\u2081.nonempty := (df.comap_nhds_ne_bot _).nonempty_of_mem V\u2081_nhd\n  have cont_flip : Continuous fun p : \u03b4 \u00d7 \u03b2 => \u03c6.flip p.1 p.2 :=\n    by\n    show Continuous (\u03a6 \u2218 Prod.swap)\n    exact h\u03c6.comp continuous_swap\n  rcases extend_Z_bilin_aux de df h\u03c6 W_nhd x\u2080 y\u2081 with \u27e8U\u2082, U\u2082_nhd, HU\u27e9\n  rcases extend_Z_bilin_aux df de cont_flip W_nhd y\u2080 x\u2081 with \u27e8V\u2082, V\u2082_nhd, HV\u27e9\n  exists U\u2081 \u2229 U\u2082, inter_mem U\u2081_nhd U\u2082_nhd, V\u2081 \u2229 V\u2082, inter_mem V\u2081_nhd V\u2082_nhd\n  rintro x \u27e8xU\u2081, xU\u2082\u27e9 x' \u27e8x'U\u2081, x'U\u2082\u27e9 y \u27e8yV\u2081, yV\u2082\u27e9 y' \u27e8y'V\u2081, y'V\u2082\u27e9\n  have key_formula :\n    \u03c6 x' y' - \u03c6 x y = \u03c6 (x' - x) y\u2081 + \u03c6 (x' - x) (y' - y\u2081) + \u03c6 x\u2081 (y' - y) + \u03c6 (x - x\u2081) (y' - y) :=\n    by\n    simp\n    abel\n  rw [key_formula]\n  have h\u2081 := HU x xU\u2082 x' x'U\u2082\n  have h\u2082 := H x xU\u2081 x' x'U\u2081 y\u2081 y\u2081_in y' y'V\u2081\n  have h\u2083 := HV y yV\u2082 y' y'V\u2082\n  have h\u2084 := H x\u2081 x\u2081_in x xU\u2081 y yV\u2081 y' y'V\u2081\n  exact W4 h\u2081 h\u2082 h\u2083 h\u2084\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {G : Type.{u5}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : AddCommGroup.{u1} \u03b1] [_inst_3 : TopologicalAddGroup.{u1} \u03b1 _inst_1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2)] [_inst_4 : TopologicalSpace.{u2} \u03b2] [_inst_5 : AddCommGroup.{u2} \u03b2] [_inst_6 : TopologicalAddGroup.{u2} \u03b2 _inst_4 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)] [_inst_7 : TopologicalSpace.{u3} \u03b3] [_inst_8 : AddCommGroup.{u3} \u03b3] [_inst_9 : TopologicalAddGroup.{u3} \u03b3 _inst_7 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8)] [_inst_10 : TopologicalSpace.{u4} \u03b4] [_inst_11 : AddCommGroup.{u4} \u03b4] [_inst_12 : TopologicalAddGroup.{u4} \u03b4 _inst_10 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))} (de : DenseInducing.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) e)) {f : AddMonoidHom.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))} (df : DenseInducing.{u4, u3} \u03b4 \u03b3 _inst_10 _inst_7 (coeFn.{max (succ u3) (succ u4), max (succ u4) (succ u3)} (AddMonoidHom.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) (fun (_x : AddMonoidHom.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) => \u03b4 -> \u03b3) (AddMonoidHom.hasCoeToFun.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) f)) {\u03c6 : AddMonoidHom.{u2, max u5 u4} \u03b2 (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) _inst_14)))))}, (Continuous.{max u2 u4, u5} (Prod.{u2, u4} \u03b2 \u03b4) G (Prod.topologicalSpace.{u2, u4} \u03b2 \u03b4 _inst_4 _inst_10) (UniformSpace.toTopologicalSpace.{u5} G _inst_13) (fun (p : Prod.{u2, u4} \u03b2 \u03b4) => coeFn.{max (succ u5) (succ u4), max (succ u4) (succ u5)} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) => \u03b4 -> G) (AddMonoidHom.hasCoeToFun.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b2 (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) _inst_14)))))) (fun (_x : AddMonoidHom.{u2, max u5 u4} \u03b2 (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) _inst_14)))))) => \u03b2 -> (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b2 (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) _inst_14)))))) \u03c6 (Prod.fst.{u2, u4} \u03b2 \u03b4 p)) (Prod.snd.{u2, u4} \u03b2 \u03b4 p))) -> (Continuous.{max u1 u3, u5} (Prod.{u1, u3} \u03b1 \u03b3) G (Prod.topologicalSpace.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_7) (UniformSpace.toTopologicalSpace.{u5} G _inst_13) (DenseInducing.extend.{max u2 u4, max u1 u3, u5} (Prod.{u2, u4} \u03b2 \u03b4) (Prod.{u1, u3} \u03b1 \u03b3) G (Prod.topologicalSpace.{u2, u4} \u03b2 \u03b4 _inst_4 _inst_10) (Prod.topologicalSpace.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_7) (fun (p : Prod.{u2, u4} \u03b2 \u03b4) => Prod.mk.{u1, u3} \u03b1 \u03b3 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) e (Prod.fst.{u2, u4} \u03b2 \u03b4 p)) (coeFn.{max (succ u3) (succ u4), max (succ u4) (succ u3)} (AddMonoidHom.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) (fun (_x : AddMonoidHom.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) => \u03b4 -> \u03b3) (AddMonoidHom.hasCoeToFun.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) f (Prod.snd.{u2, u4} \u03b2 \u03b4 p))) (UniformSpace.toTopologicalSpace.{u5} G _inst_13) (DenseInducing.prod.{u2, u1, u4, u3} \u03b2 \u03b1 \u03b4 \u03b3 _inst_4 _inst_1 _inst_10 _inst_7 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (SubNegMonoid.toAddMonoid.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddCommGroup.toAddGroup.{u1} \u03b1 _inst_2))))) e) (coeFn.{max (succ u3) (succ u4), max (succ u4) (succ u3)} (AddMonoidHom.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) (fun (_x : AddMonoidHom.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) => \u03b4 -> \u03b3) (AddMonoidHom.hasCoeToFun.{u4, u3} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (SubNegMonoid.toAddMonoid.{u3} \u03b3 (AddGroup.toSubNegMonoid.{u3} \u03b3 (AddCommGroup.toAddGroup.{u3} \u03b3 _inst_8))))) f) de df) (fun (p : Prod.{u2, u4} \u03b2 \u03b4) => coeFn.{max (succ u5) (succ u4), max (succ u4) (succ u5)} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) => \u03b4 -> G) (AddMonoidHom.hasCoeToFun.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b2 (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) _inst_14)))))) (fun (_x : AddMonoidHom.{u2, max u5 u4} \u03b2 (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) _inst_14)))))) => \u03b2 -> (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b2 (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u5 u4} (AddMonoidHom.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) (AddMonoid.toAddZeroClass.{u5} G (SubNegMonoid.toAddMonoid.{u5} G (AddGroup.toSubNegMonoid.{u5} G (AddCommGroup.toAddGroup.{u5} G _inst_14))))) (AddMonoidHom.addCommGroup.{u4, u5} \u03b4 G (AddMonoid.toAddZeroClass.{u4} \u03b4 (SubNegMonoid.toAddMonoid.{u4} \u03b4 (AddGroup.toSubNegMonoid.{u4} \u03b4 (AddCommGroup.toAddGroup.{u4} \u03b4 _inst_11)))) _inst_14)))))) \u03c6 (Prod.fst.{u2, u4} \u03b2 \u03b4 p)) (Prod.snd.{u2, u4} \u03b2 \u03b4 p))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u5}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u1}} {G : Type.{u3}} [_inst_1 : TopologicalSpace.{u5} \u03b1] [_inst_2 : AddCommGroup.{u5} \u03b1] [_inst_3 : TopologicalAddGroup.{u5} \u03b1 _inst_1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2)] [_inst_4 : TopologicalSpace.{u2} \u03b2] [_inst_5 : AddCommGroup.{u2} \u03b2] [_inst_6 : TopologicalSpace.{u4} \u03b3] [_inst_7 : AddCommGroup.{u4} \u03b3] [_inst_8 : TopologicalAddGroup.{u4} \u03b3 _inst_6 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7)] [_inst_9 : TopologicalSpace.{u1} \u03b4] [_inst_10 : AddCommGroup.{u1} \u03b4] [_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} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))} (_inst_17 : DenseInducing.{u2, u5} \u03b2 \u03b1 _inst_4 _inst_1 (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) a) (AddHomClass.toFunLike.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5))))) (AddZeroClass.toAdd.{u5} \u03b1 (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) (AddMonoidHomClass.toAddHomClass.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2)))) (AddMonoidHom.addMonoidHomClass.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))))) _inst_16)) {e : AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))} (de : DenseInducing.{u1, u4} \u03b4 \u03b3 _inst_9 _inst_6 (FunLike.coe.{max (succ u4) (succ u1), succ u1, succ u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 (fun (_x : \u03b4) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b4) => \u03b3) _x) (AddHomClass.toFunLike.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 \u03b3 (AddZeroClass.toAdd.{u1} \u03b4 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10))))) (AddZeroClass.toAdd.{u4} \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) (AddMonoidHomClass.toAddHomClass.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7)))) (AddMonoidHom.addMonoidHomClass.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))))) e)) {f : AddMonoidHom.{u2, max u3 u1} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))}, (Continuous.{max u2 u1, u3} (Prod.{u2, u1} \u03b2 \u03b4) G (instTopologicalSpaceProd.{u2, u1} \u03b2 \u03b4 _inst_4 _inst_9) (UniformSpace.toTopologicalSpace.{u3} G _inst_11) (fun (p : Prod.{u2, u1} \u03b2 \u03b4) => FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) \u03b4 (fun (a : \u03b4) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b4) => G) a) (AddHomClass.toFunLike.{max u1 u3, u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) \u03b4 G (AddZeroClass.toAdd.{u1} \u03b4 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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 : \u03b2) => AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12)))) (AddMonoidHom.addMonoidHomClass.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))) \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5))))) (AddZeroClass.toAdd.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))) (AddMonoidHomClass.toAddHomClass.{max (max u2 u1) u3, u2, max u1 u3} (AddMonoidHom.{u2, max u3 u1} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))) \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12))))) (AddMonoidHom.addMonoidHomClass.{u2, max u1 u3} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))))) f (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) (Prod.snd.{u2, u1} \u03b2 \u03b4 p))) -> (Continuous.{max u5 u4, u3} (Prod.{u5, u4} \u03b1 \u03b3) G (instTopologicalSpaceProd.{u5, u4} \u03b1 \u03b3 _inst_1 _inst_6) (UniformSpace.toTopologicalSpace.{u3} G _inst_11) (DenseInducing.extend.{max u2 u1, max u5 u4, u3} (Prod.{u2, u1} \u03b2 \u03b4) (Prod.{u5, u4} \u03b1 \u03b3) G (instTopologicalSpaceProd.{u2, u1} \u03b2 \u03b4 _inst_4 _inst_9) (instTopologicalSpaceProd.{u5, u4} \u03b1 \u03b3 _inst_1 _inst_6) (fun (p : Prod.{u2, u1} \u03b2 \u03b4) => Prod.mk.{u5, u4} \u03b1 \u03b3 (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) a) (AddHomClass.toFunLike.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5))))) (AddZeroClass.toAdd.{u5} \u03b1 (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) (AddMonoidHomClass.toAddHomClass.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2)))) (AddMonoidHom.addMonoidHomClass.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))))) _inst_16 (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) (FunLike.coe.{max (succ u4) (succ u1), succ u1, succ u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 (fun (a : \u03b4) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b4) => \u03b3) a) (AddHomClass.toFunLike.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 \u03b3 (AddZeroClass.toAdd.{u1} \u03b4 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10))))) (AddZeroClass.toAdd.{u4} \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) (AddMonoidHomClass.toAddHomClass.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7)))) (AddMonoidHom.addMonoidHomClass.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))))) e (Prod.snd.{u2, u1} \u03b2 \u03b4 p))) (UniformSpace.toTopologicalSpace.{u3} G _inst_11) (DenseInducing.prod.{u5, u2, u4, u1} \u03b2 \u03b1 \u03b4 \u03b3 _inst_4 _inst_1 _inst_9 _inst_6 (FunLike.coe.{max (succ u5) (succ u2), succ u2, succ u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) a) (AddHomClass.toFunLike.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5))))) (AddZeroClass.toAdd.{u5} \u03b1 (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) (AddMonoidHomClass.toAddHomClass.{max u5 u2, u2, u5} (AddMonoidHom.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2)))) (AddMonoidHom.addMonoidHomClass.{u2, u5} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{u5} \u03b1 (SubNegMonoid.toAddMonoid.{u5} \u03b1 (AddGroup.toSubNegMonoid.{u5} \u03b1 (AddCommGroup.toAddGroup.{u5} \u03b1 _inst_2))))))) _inst_16) (FunLike.coe.{max (succ u4) (succ u1), succ u1, succ u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 (fun (a : \u03b4) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b4) => \u03b3) a) (AddHomClass.toFunLike.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 \u03b3 (AddZeroClass.toAdd.{u1} \u03b4 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10))))) (AddZeroClass.toAdd.{u4} \u03b3 (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) (AddMonoidHomClass.toAddHomClass.{max u4 u1, u1, u4} (AddMonoidHom.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))) \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7)))) (AddMonoidHom.addMonoidHomClass.{u1, u4} \u03b4 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u4} \u03b3 (SubNegMonoid.toAddMonoid.{u4} \u03b3 (AddGroup.toSubNegMonoid.{u4} \u03b3 (AddCommGroup.toAddGroup.{u4} \u03b3 _inst_7))))))) e) _inst_17 de) (fun (p : Prod.{u2, u1} \u03b2 \u03b4) => FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) \u03b4 (fun (a : \u03b4) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b4) => G) a) (AddHomClass.toFunLike.{max u1 u3, u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) \u03b4 G (AddZeroClass.toAdd.{u1} \u03b4 (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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 : \u03b2) => AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12)))) (AddMonoidHom.addMonoidHomClass.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))) \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5))))) (AddZeroClass.toAdd.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))) (AddMonoidHomClass.toAddHomClass.{max (max u2 u1) u3, u2, max u1 u3} (AddMonoidHom.{u2, max u3 u1} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))) \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12))))) (AddMonoidHom.addMonoidHomClass.{u2, max u1 u3} \u03b2 (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (SubNegMonoid.toAddMonoid.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddCommGroup.toAddGroup.{u2} \u03b2 _inst_5)))) (AddMonoid.toAddZeroClass.{max u1 u3} (AddMonoidHom.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _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} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) (AddMonoid.toAddZeroClass.{u3} G (SubNegMonoid.toAddMonoid.{u3} G (AddGroup.toSubNegMonoid.{u3} G (AddCommGroup.toAddGroup.{u3} G _inst_12))))) (AddMonoidHom.addCommGroup.{u1, u3} \u03b4 G (AddMonoid.toAddZeroClass.{u1} \u03b4 (SubNegMonoid.toAddMonoid.{u1} \u03b4 (AddGroup.toSubNegMonoid.{u1} \u03b4 (AddCommGroup.toAddGroup.{u1} \u03b4 _inst_10)))) _inst_12)))))))) f (Prod.fst.{u2, u1} \u03b2 \u03b4 p)) (Prod.snd.{u2, u1} \u03b2 \u03b4 p))))\nCase conversion may be inaccurate. Consider using '#align dense_inducing.extend_Z_bilin DenseInducing.extend_Z_bilin\u2093'. -/\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\u2124-bilinear continuous maps from dense images into a complete Hausdorff group extend by continuity.\nNote: Bourbaki assumes that \u03b1 and \u03b2 are also complete Hausdorff, but this is not necessary. -/\ntheorem extend_Z_bilin : Continuous (extend (de.Prod df) \u03a6) :=\n  by\n  refine' continuous_extend_of_cauchy _ _\n  rintro \u27e8x\u2080, y\u2080\u27e9\n  constructor\n  \u00b7 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\u2080, y\u2080)) U h with \u27e8x, x_in, \u27e8z, z_x\u27e9\u27e9\n    exists z\n    cc\n  \u00b7 suffices\n      map (fun p : (\u03b2 \u00d7 \u03b4) \u00d7 \u03b2 \u00d7 \u03b4 => \u03a6 p.2 - \u03a6 p.1)\n          (comap (fun p : (\u03b2 \u00d7 \u03b4) \u00d7 \u03b2 \u00d7 \u03b4 => ((e p.1.1, f p.1.2), (e p.2.1, f p.2.2)))\n            (\ud835\udcdd (x\u2080, y\u2080) \u00d7\u1da0 \ud835\udcdd (x\u2080, y\u2080))) \u2264\n        \ud835\udcdd 0\n      by\n      rwa [uniformity_eq_comap_nhds_zero G, prod_map_map_eq, \u2190 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\u03c6 W'_nhd x\u2080 y\u2080\n    rcases key with \u27e8U, U_nhd, V, V_nhd, h\u27e9\n    rw [mem_comap] at U_nhd\n    rcases U_nhd with \u27e8U', U'_nhd, U'_sub\u27e9\n    rw [mem_comap] at V_nhd\n    rcases V_nhd with \u27e8V', V'_nhd, V'_sub\u27e9\n    rw [mem_map, mem_comap, nhds_prod_eq]\n    exists (U' \u00d7\u02e2 V') \u00d7\u02e2 U' \u00d7\u02e2 V'\n    rw [mem_prod_same_iff]\n    simp only [exists_prop]\n    constructor\n    \u00b7 change U' \u2208 \ud835\udcdd x\u2080 at U'_nhd\n      change V' \u2208 \ud835\udcdd y\u2080 at V'_nhd\n      have := prod_mem_prod U'_nhd V'_nhd\n      tauto\n    \u00b7 intro p h'\n      simp only [Set.mem_preimage, Set.prod_mk_mem_set_prod_eq] at h'\n      rcases p with \u27e8\u27e8x, y\u27e9, \u27e8x', y'\u27e9\u27e9\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 \u29f8 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 \u29f8 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 \u29f8 N) (TopologicalGroup.toUniformSpace (G \u29f8 N)) :=\n  by\n  /- Since `G \u29f8 N` is a topological group it is a uniform space, and since `G` is first countable\n    the uniformities of both `G` and `G \u29f8 N` are countably generated. Moreover, we may choose a\n    sequential antitone neighborhood basis `u` for `\ud835\udcdd (1 : G)` so that `(u (n + 1)) ^ 2 \u2286 u n`, and\n    this descends to an antitone neighborhood basis `v` for `\ud835\udcdd (1 : G \u29f8 N)`. Since `\ud835\udce4 (G \u29f8 N)` is\n    countably generated, it suffices to show any Cauchy sequence `x` converges. -/\n  letI : UniformSpace (G \u29f8 N) := TopologicalGroup.toUniformSpace (G \u29f8 N)\n  letI : UniformSpace G := TopologicalGroup.toUniformSpace G\n  haveI : (\ud835\udce4 (G \u29f8 N)).IsCountablyGenerated := comap.is_countably_generated _ _\n  obtain \u27e8u, hu, u_mul\u27e9 := TopologicalGroup.exists_antitone_basis_nhds_one G\n  obtain \u27e8hv, v_anti\u27e9 := @has_antitone_basis.map _ _ _ _ _ _ (coe : G \u2192 G \u29f8 N) hu\n  rw [\u2190 QuotientGroup.nhds_eq N 1, QuotientGroup.mk_one] at hv\n  refine' UniformSpace.complete_of_cauchySeq_tendsto fun x hx => _\n  /- Given `n : \u2115`, for sufficiently large `a b : \u2115`, 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\u2080 :\n    \u2200 i j : \u2115,\n      \u2203 M : \u2115,\n        j < M \u2227 \u2200 a b : \u2115, M \u2264 a \u2192 M \u2264 b \u2192 \u2200 g : G, x b = g \u2192 \u2203 g' : G, g / g' \u2208 u i \u2227 x a = g' :=\n    by\n    have h\ud835\udce4GN : (\ud835\udce4 (G \u29f8 N)).HasBasis (fun _ => True) fun i => { x | x.snd / x.fst \u2208 coe '' u i } :=\n      by simpa [uniformity_eq_comap_nhds_one'] using hv.comap _\n    simp only [h\ud835\udce4GN.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 \u27e8M, hM\u27e9\n    refine' \u27e8max j M + 1, (le_max_left _ _).trans_lt (lt_add_one _), fun a b ha hb g hg => _\u27e9\n    obtain \u27e8y, y_mem, hy\u27e9 :=\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      \u27e8y\u207b\u00b9 * g, by\n        simpa only [div_eq_mul_inv, mul_inv_rev, inv_inv, mul_inv_cancel_left] using y_mem, _\u27e9\n    rw [QuotientGroup.mk_mul, QuotientGroup.mk_inv, hy, hg, inv_div, div_mul_cancel']\n  /- Inductively construct a subsequence `\u03c6 : \u2115 \u2192 \u2115` using `key\u2080` so that if `a b : \u2115` exceed\n    `\u03c6 (n + 1)`, then we may find lifts whose quotients lie within `u n`. -/\n  set \u03c6 : \u2115 \u2192 \u2115 := fun n => Nat.recOn n (some <| key\u2080 0 0) fun k yk => some <| key\u2080 (k + 1) yk\n  have h\u03c6 :\n    \u2200 n : \u2115,\n      \u03c6 n < \u03c6 (n + 1) \u2227\n        \u2200 a b : \u2115,\n          \u03c6 (n + 1) \u2264 a \u2192\n            \u03c6 (n + 1) \u2264 b \u2192 \u2200 g : G, x b = g \u2192 \u2203 g' : G, g / g' \u2208 u (n + 1) \u2227 x a = g' :=\n    fun n => some_spec (key\u2080 (n + 1) (\u03c6 n))\n  /- Inductively construct a sequence `x' n : G` of lifts of `x (\u03c6 (n + 1))` such that quotients of\n    successive terms lie in `x' n / x' (n + 1) \u2208 u (n + 1)`. We actually need the proofs that each\n    term is a lift to construct the next term, so we use a \u03a3-type. -/\n  set x' : \u2200 n, PSigma fun g : G => x (\u03c6 (n + 1)) = g := fun n =>\n    Nat.recOn n\n      \u27e8some (QuotientGroup.mk_surjective (x (\u03c6 1))),\n        (some_spec (QuotientGroup.mk_surjective (x (\u03c6 1)))).symm\u27e9\n      fun k hk =>\n      \u27e8some <| (h\u03c6 k).2 _ _ (h\u03c6 (k + 1)).1.le le_rfl hk.fst hk.snd,\n        (some_spec <| (h\u03c6 k).2 _ _ (h\u03c6 (k + 1)).1.le le_rfl hk.fst hk.snd).2\u27e9\n  have hx' : \u2200 n : \u2115, (x' n).fst / (x' (n + 1)).fst \u2208 u (n + 1) := fun n =>\n    (some_spec <| (h\u03c6 n).2 _ _ (h\u03c6 (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 \u2208 u m` if `m \u2264 n`. -/\n  have x'_cauchy : CauchySeq fun n => (x' n).fst :=\n    by\n    have h\ud835\udce4G : (\ud835\udce4 G).HasBasis (fun _ => True) fun i => { x | x.snd / x.fst \u2208 u i } := by\n      simpa [uniformity_eq_comap_nhds_one'] using hu.to_has_basis.comap _\n    simp only [h\ud835\udce4G.cauchy_seq_iff', ge_iff_le, mem_set_of_eq, forall_true_left]\n    exact fun m =>\n      \u27e8m, fun n hmn =>\n        Nat.decreasingInduction'\n          (fun k hkn hkm hk => u_mul k \u27e8_, _, hx' k, hk, div_mul_div_cancel' _ _ _\u27e9) hmn\n          (by simpa only [div_self'] using mem_of_mem_nhds (hu.mem _))\u27e9\n  /- Since `G` is complete, `x'` converges to some `x\u2080`, and so the image of this sequence under\n    the quotient map converges to `\u2191x\u2080`. 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 \u27e8x\u2080, hx\u2080\u27e9\n  refine'\n    \u27e8\u2191x\u2080,\n      tendsto_nhds_of_cauchySeq_of_subseq hx\n        (strictMono_nat_of_lt_succ fun n => (h\u03c6 (n + 1)).1).tendsto_atTop _\u27e9\n  convert((continuous_coinduced_rng : Continuous (coe : G \u2192 G \u29f8 N)).Tendsto x\u2080).comp hx\u2080\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 \u29f8 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 \u29f8 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 \u29f8 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 \u29f8 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 \u2500 quotients of normed additive commutative groups by subgroups \u2500\\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 \u29f8 N) (TopologicalGroup.toUniformSpace (G \u29f8 N)) :=\n  by\n  rw [\u2190 @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 \u00d7 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 (\u03bb v w, _)),\n  have :\n    (\u2203 (x : X), coords R x = v \u2227 coords R x = w) \u2194\n    v \u2208 coordinate_image R X \u2227 v = w,\n  { split,\n    { rintros \u27e8x, rfl, rfl\u27e9, exact \u27e8\u27e8x, rfl\u27e9, rfl\u27e9 },\n    { rintros \u27e8\u27e8x, rfl\u27e9, rfl\u27e9, exact \u27e8x, rfl, rfl\u27e9 } },\n  simp,\n  dsimp,\n  simpa [finvec.append.inj_iff]\nend\n\nlemma reindex (dX : S.def_coords (set.univ : set X)) {f : X \u2192 Y} (hf : is_reindexing R f)\n  {s : set Y} (ds : S.def_coords s) : S.def_coords (f \u207b\u00b9' s) :=\nbegin\n  cases hf with f\u03c3 hf,\n  unfold struc.def_coords,\n  -- The preimage f \u207b\u00b9' s, as a subset of the R\u207f 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\u03c3 ds),\n  ext z,\n  suffices : (\u2203 (x : X), f x \u2208 s \u2227 coords R x = z) \u2194\n    z \u2208 set.range (@coords R X _) \u2227 \u2203 (y : Y), y \u2208 s \u2227 coords R y = z \u2218 f\u03c3,\n  { simpa },\n  -- TODO: funext'd version of `is_reindexing.hf`\n  replace hf : \u2200 (x : X), coords R x \u2218 f\u03c3 = coords R (f x) := \u03bb x, funext (\u03bb i, (hf x i)),\n  split,\n  { rintro \u27e8x, hfx, rfl\u27e9,\n    refine \u27e8set.mem_range_self _, f x, hfx, (hf x).symm\u27e9 },\n  { rintro \u27e8\u27e8x, rfl\u27e9, y, hy, H\u27e9,\n    rw hf x at H,\n    replace hf := injective_coords _ H,\n    subst y,\n    exact \u27e8x, hy, rfl\u27e9 }\nend\n\nlemma \u00abexists\u00bb {s : X \u2192 Y \u2192 Prop} (ds : S.def_coords {p : X \u00d7 Y | s p.1 p.2}) :\n  S.def_coords {x | \u2203 y, s x y} :=\nbegin\n  unfold struc.def_coords at \u22a2 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 \u2229 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 \u00d7 Y)) :=\nbegin\n  unfold struc.def_coords,\n  convert S.definable_external_prod dX dY,\n  refine set.ext (finvec.rec (\u03bb 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 \u27e8n, h\u27e9 else \u27e80, zero_lt_unsignedSz\u27e9\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\u2081 w\u2082 v u\nvariables {C : Type u} [category.{v} C] (J : grothendieck_topology C)\nvariables {D : Type w\u2081} [category.{max v u} D]\nvariables {E : Type w\u2082} [category.{max v u} E]\nvariables (F : D \u2964 E)\n\nnoncomputable theory\n\nvariables [\u2200 (\u03b1 \u03b2 : Type (max v u)) (fst snd : \u03b2 \u2192 \u03b1),\n  has_limits_of_shape (walking_multicospan fst snd) D]\nvariables [\u2200 (\u03b1 \u03b2 : Type (max v u)) (fst snd : \u03b2 \u2192 \u03b1),\n  has_limits_of_shape (walking_multicospan fst snd) E]\nvariables [\u2200 (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 D), preserves_limit (W.index P).multicospan F]\n\nvariables (P : C\u1d52\u1d56 \u2964 D)\n\n/-- The diagram used to define `P\u207a`, composed with `F`, is isomorphic\nto the diagram used to define `P \u22d9 F`. -/\ndef diagram_comp_iso (X : C) : J.diagram P X \u22d9 F \u2245 J.diagram (P \u22d9 F) X :=\nnat_iso.of_components\n(\u03bb W, begin\n  refine _ \u226a\u226b 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_\u03c0_app, multiequalizer.multifork_\u03c0_app_left,\n    iso.symm_hom, multiequalizer.lift_\u03b9, 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_\u03c0, category.assoc],\n  simp only [\u2190 F.map_comp, multiequalizer.lift_\u03b9],\nend\n\n@[simp, reassoc]\nlemma diagram_comp_iso_hom_\u03b9 (X : C) (W : (J.cover X)\u1d52\u1d56) (i : W.unop.arrow):\n  (J.diagram_comp_iso F P X).hom.app W \u226b multiequalizer.\u03b9 _ i =\n  F.map (multiequalizer.\u03b9 _ _) :=\nbegin\n  delta diagram_comp_iso,\n  dsimp,\n  simp,\nend\n\nvariables [\u2200 (X : C), has_colimits_of_shape (J.cover X)\u1d52\u1d56 D]\nvariables [\u2200 (X : C), has_colimits_of_shape (J.cover X)\u1d52\u1d56 E]\nvariables [\u2200 (X : C), preserves_colimits_of_shape (J.cover X)\u1d52\u1d56 F]\n\n/-- The isomorphism between `P\u207a \u22d9 F` and `(P \u22d9 F)\u207a`. -/\ndef plus_comp_iso : J.plus_obj P \u22d9 F \u2245 J.plus_obj (P \u22d9 F) :=\nnat_iso.of_components\n(\u03bb X, begin\n  refine _ \u226a\u226b 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 [\u2190 F.map_comp],\n    dsimp [colim_map, is_colimit.map, colimit.pre],\n    simp only [colimit.\u03b9_desc_assoc, colimit.\u03b9_desc],\n    dsimp [cocones.precompose],\n    rw [category.assoc, colimit.\u03b9_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_\u03b9_hom_assoc,\n    grothendieck_topology.diagram_pullback_app, colimit.\u03b9_pre,\n    has_colimit.iso_of_nat_iso_\u03b9_hom, \u03b9_colim_map_assoc],\n  simp only [\u2190 category.assoc],\n  congr' 1,\n  ext,\n  dsimp,\n  simp only [category.assoc],\n  erw [multiequalizer.lift_\u03b9, diagram_comp_iso_hom_\u03b9, diagram_comp_iso_hom_\u03b9,\n    \u2190 F.map_comp, multiequalizer.lift_\u03b9],\nend\n\n@[simp, reassoc]\nlemma \u03b9_plus_comp_iso_hom (X) (W) : F.map (colimit.\u03b9 _ W) \u226b (J.plus_comp_iso F P).hom.app X =\n  (J.diagram_comp_iso F P X.unop).hom.app W \u226b colimit.\u03b9 _ W :=\nbegin\n  delta diagram_comp_iso plus_comp_iso,\n  dsimp [is_colimit.cocone_point_unique_up_to_iso],\n  simp only [\u2190 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 \u2964 E} (\u03b7 : F \u27f6 G) (P : C\u1d52\u1d56 \u2964 D)\n  [\u2200 (X : C), preserves_colimits_of_shape (J.cover X)\u1d52\u1d56 F]\n  [\u2200 (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 D), preserves_limit (W.index P).multicospan F]\n  [\u2200 (X : C), preserves_colimits_of_shape (J.cover X)\u1d52\u1d56 G]\n  [\u2200 (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 D), preserves_limit (W.index P).multicospan G] :\n  whisker_left _ \u03b7 \u226b (J.plus_comp_iso G P).hom =\n  (J.plus_comp_iso F P).hom \u226b J.plus_map (whisker_left _ \u03b7) :=\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 [\u03b9_plus_comp_iso_hom, \u03b9_colim_map, whisker_left_app, \u03b9_plus_comp_iso_hom_assoc,\n    nat_trans.naturality_assoc, grothendieck_topology.diagram_nat_trans_app],\n  simp only [\u2190 category.assoc],\n  congr' 1,\n  ext,\n  dsimp,\n  simpa,\nend\n\n/-- The isomorphism between `P\u207a \u22d9 F` and `(P \u22d9 F)\u207a`, functorially in `F`. -/\n@[simps hom_app inv_app]\ndef plus_functor_whisker_left_iso (P : C\u1d52\u1d56 \u2964 D)\n  [\u2200 (F : D \u2964 E) (X : C), preserves_colimits_of_shape (J.cover X)\u1d52\u1d56 F]\n  [\u2200 (F : D \u2964 E) (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 D),\n    preserves_limit (W.index P).multicospan F] :\n  (whiskering_left _ _ E).obj (J.plus_obj P) \u2245\n  (whiskering_left _ _ _).obj P \u22d9 J.plus_functor E :=\nnat_iso.of_components\n(\u03bb X, plus_comp_iso _ _ _) $ \u03bb F G \u03b7, plus_comp_iso_whisker_left _ _ _\n\n@[simp, reassoc]\nlemma plus_comp_iso_whisker_right {P Q : C\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) :\n  whisker_right (J.plus_map \u03b7) F \u226b (J.plus_comp_iso F Q).hom =\n  (J.plus_comp_iso F P).hom \u226b J.plus_map (whisker_right \u03b7 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 [\u03b9_colim_map, whisker_right_app, \u03b9_plus_comp_iso_hom_assoc,\n    grothendieck_topology.diagram_nat_trans_app],\n  simp only [\u2190 category.assoc, \u2190 F.map_comp],\n  dsimp [colim_map, is_colimit.map],\n  simp only [colimit.\u03b9_desc],\n  dsimp [cocones.precompose],\n  simp only [functor.map_comp, category.assoc, \u03b9_plus_comp_iso_hom],\n  simp only [\u2190 category.assoc],\n  congr' 1,\n  ext,\n  dsimp,\n  simp only [diagram_comp_iso_hom_\u03b9_assoc, multiequalizer.lift_\u03b9,\n    diagram_comp_iso_hom_\u03b9, category.assoc],\n  simp only [\u2190 F.map_comp, multiequalizer.lift_\u03b9],\nend\n\n/-- The isomorphism between `P\u207a \u22d9 F` and `(P \u22d9 F)\u207a`, functorially in `P`. -/\n@[simps hom_app inv_app]\ndef plus_functor_whisker_right_iso : J.plus_functor D \u22d9 (whiskering_right _ _ _).obj F \u2245\n  (whiskering_right _ _ _).obj F \u22d9 J.plus_functor E :=\nnat_iso.of_components (\u03bb P, J.plus_comp_iso _ _) $ \u03bb P Q \u03b7, 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 _) _ \u226b (J.plus_comp_iso F P).hom = J.to_plus _ :=\nbegin\n  ext,\n  dsimp [to_plus],\n  simp only [\u03b9_plus_comp_iso_hom, functor.map_comp, category.assoc],\n  simp only [\u2190 category.assoc],\n  congr' 1,\n  ext,\n  delta cover.to_multiequalizer,\n  simp only [diagram_comp_iso_hom_\u03b9, category.assoc, \u2190 F.map_comp],\n  erw [multiequalizer.lift_\u03b9, multiequalizer.lift_\u03b9],\n  refl,\nend\n\n@[simp]\nlemma to_plus_comp_plus_comp_iso_inv : J.to_plus _ \u226b (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) \u22d9 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 \u2295 D) \u2295 E) \u2964 (C \u2295 (D \u2295 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 \u2295 D) \u2295 E \u2964 C \u2295 (D \u2295 E)` for sums of categories.\n-/\ndef associator : (C \u2295 D) \u2295 E \u2964 C \u2295 (D \u2295 E) :=\n{ obj := \u03bb 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 := \u03bb 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) \u27f6 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) \u27f6 inl (inr Y)) :\n  (associator C D E).map f = f := rfl\n@[simp] lemma associator_map_inr {X Y : E} (f : inr X \u27f6 inr Y) :\n  (associator C D E).map f = f := rfl\n\n/--\nThe inverse associator functor `C \u2295 (D \u2295 E) \u2964 (C \u2295 D) \u2295 E` for sums of categories.\n-/\ndef inverse_associator : C \u2295 (D \u2295 E) \u2964 (C \u2295 D) \u2295 E :=\n{ obj := \u03bb 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 := \u03bb 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 \u2295 D) \u2295 E \u224c C \u2295 (D \u2295 E) :=\nequivalence.mk (associator C D E) (inverse_associator C D E)\n  (nat_iso.of_components (\u03bb X, eq_to_iso (by tidy)) (by tidy))\n  (nat_iso.of_components (\u03bb 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\u2081 v\u2082 u\u2081 u\u2082 l u\u2083 v\u2083 \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\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2192 D) \nwhere\n  map : {X Y : C} \u2192 (X \u27f6 Y) \u2192 (F X \u27f6 F Y)\n  map_id' : autoParam (C \u2192 map \ud835\udfd9 = \ud835\udfd9)\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 (\u2200 {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z), map (f \u226b g) = map f \u226b 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 \u2192 D` (just a function) has `[functorial F]`,\nwe can write `map F f : F X \u27f6 F Y` for the action of `F` on a morphism `f : X \u27f6 Y`.\n-/\ndef map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2192 D) [functorial F] {X : C} {Y : C} (f : X \u27f6 Y) : F X \u27f6 F Y :=\n  functorial.map f\n\n@[simp] theorem map_as_map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2192 D} [functorial F] {X : C} {Y : C} {f : X \u27f6 Y} : functorial.map f = map F f :=\n  rfl\n\n@[simp] theorem functorial.map_id {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2192 D} [functorial F] {X : C} : map F \ud835\udfd9 = \ud835\udfd9 :=\n  functorial.map_id' X\n\n@[simp] theorem functorial.map_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2192 D} [functorial F] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : Y \u27f6 Z} : map F (f \u226b g) = map F f \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2192 D) [I : functorial F] : C \u2964 D :=\n  mk F functorial.map\n\nend functor\n\n\nprotected instance functor.obj.functorial {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) : functorial (functor.obj F) :=\n  functorial.mk (functor.map F)\n\n@[simp] theorem map_functorial_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) {X : C} {Y : C} (f : X \u27f6 Y) : map (functor.obj F) f = functor.map F f :=\n  rfl\n\nprotected instance functorial_id {C : Type u\u2081} [category C] : functorial id :=\n  functorial.mk fun (X Y : C) (f : X \u27f6 Y) => f\n\n/--\n`G \u2218 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\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2192 D) [functorial F] (G : D \u2192 E) [functorial G] : functorial (G \u2218 F) :=\n  functorial.mk (functor.map (functor.of F \u22d9 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 \u2964 D) (R : D \u2964 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\u1d52\u1d56 \u00d7 D \u2964 Type v := \n{ obj := \u03bb x, (x.1.unop \u27f6 R.obj x.2),\n  map := \u03bb _ _ f g, f.fst.unop \u226b g \u226b R.map f.snd,\n  map_id' := \u03bb x, \n    by {funext, rw [prod_id_fst, prod_id_snd, unop_id, id_comp, map_id, comp_id], refl}, \n  map_comp' := \u03bb _ _ _ f g, by tidy }\n\n-- (c, d) --> D(Lc, d)\ndef left_hom : C\u1d52\u1d56 \u00d7 D \u2964 Type v := \n{ obj := \u03bb x, (L.obj x.1.unop \u27f6 x.2),\n  map := \u03bb _ _ f g, L.map f.fst.unop \u226b g \u226b f.snd,\n  map_id' := \u03bb x, \n    by {funext, rw [prod_id_fst, prod_id_snd, unop_id, map_id, id_comp, comp_id], refl},\n  map_comp' := \u03bb _ _ _ f g, by tidy }\n\n@[simp] lemma left_hom_obj (x : C\u1d52\u1d56 \u00d7 D) : (left_hom L).obj x = (L.obj x.1.unop \u27f6 x.2) := rfl\n@[simp] lemma right_hom_obj (x : C\u1d52\u1d56 \u00d7 D) : (right_hom R).obj x = (x.1.unop \u27f6 R.obj x.2) := rfl\n\nlemma left_hom_map {x y : C\u1d52\u1d56 \u00d7 D} (f : x \u27f6 y) (g : (left_hom L).obj x) : \n  (left_hom L).map f g = L.map f.fst.unop \u226b g \u226b f.snd := rfl\nlemma right_hom_map {x y : C\u1d52\u1d56 \u00d7 D} (f : x \u27f6 y) (g : (right_hom R).obj x) : \n  (right_hom R).map f g = f.fst.unop \u226b g \u226b R.map f.snd := rfl\n\nvariables {L R}\n\nlemma left_hom_iso_right_hom_of_adjunction (adj : L \u22a3 R) : left_hom L \u2245 right_hom R   :=\nnat_iso.of_components \n  (\u03bb x, (equiv.to_iso (adj.hom_equiv x.1.unop x.2) : (left_hom L).obj x \u2245 (right_hom R).obj x)) \n  (begin  intros x y f,  \n    ext g, simp, \n    rw [left_hom_map, map_comp, \u2190assoc, 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 \u2245 right_hom R) : \n  adjunction.core_hom_equiv L R :=\n{ hom_equiv := \u03bb 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, \ud835\udfd9 d) : (op c', d) \u27f6 (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 ((\ud835\udfd9 (op c), g) : (op c, d) \u27f6 (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 \u226b g)] at g',\n    rw g', apply id_comp,\n  end }\n \ndef adjunction_of_left_hom_iso_right (i : left_hom L \u2245 right_hom R) : L \u22a3 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 : \u2115 \u2192 \u2115) (k : \u2115)\n\nexample (h\u2081 : f 0 = 0) (h\u2082 : k = 0) : f k = 0 :=\n  by simp [h\u2081, h\u2082]\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 ` \u00d7\u1da0 `:51 := filter.prod\nlocal notation `\ud835\udce4` := uniformity\nlocal notation `\ud835\udcdd` x:70 := nhds x\n\nsection\nopen tactic\nmeta def clean_step : tactic unit :=\ndo tgt \u2190 target,\n   match tgt with\n   | `(%%a \u2192 %%b) := `[intros]\n   | `(%%a \u2194 %%b) := match a with\n                     | `(%%c \u2192 %%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 (\u03b1 : Type*) [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1]\n\nlemma add_group_filter_basis.cauchy_iff {B : add_group_filter_basis \u03b1}\n  (h : uniform_space.to_topological_space \u03b1 = B.topology) {F : filter \u03b1} :\n  cauchy F \u2194 F \u2260 \u22a5 \u2227 \u2200 U \u2208 B, \u2203 M \u2208 F, \u2200 x y \u2208 M, y - x \u2208 U :=\nbegin\n  suffices : F \u00d7\u1da0 F \u2264 \ud835\udce4 \u03b1 \u2194 \u2200 U \u2208 B, \u2203 M \u2208 F, \u2200 x y \u2208 M, y - x \u2208 U,\n    by split ; rintros \u27e8h', h\u27e9 ; refine \u27e8h', _\u27e9 ; [rwa \u2190 this, rwa this],\n  rw [uniformity_eq_comap_nhds_zero \u03b1, \u2190 map_le_iff_le_comap],\n  change tendsto _ _ _ \u2194 _,\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 {\u03b1 : Type*} [has_sub \u03b1] (S T : set $ set \u03b1) :\n (\u2200 {V : set \u03b1}, V \u2208 S \u2192 (\u2203 (t : set \u03b1) (H : t \u2208 T), set.prod t t \u2286 (\u03bb (x : \u03b1 \u00d7 \u03b1), x.snd - x.fst) \u207b\u00b9' V)) \u2194\n    \u2200 (U : set \u03b1), U \u2208 S \u2192 (\u2203 (M : set \u03b1) (H : M \u2208 T), \u2200 (x y : \u03b1), x \u2208 M \u2192 y \u2208 M \u2192 y - x \u2208 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 \u2192 \u2115\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 \u2192 memval\n| Fragment : val \u2192 quantity \u2192 nat \u2192 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 : \u2115) (x : \u2124) : list byte :=\nrev_if_be (words_of_int sz x)\n\ndef decode_int (b : list byte) : \u2115 :=\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 \u2192\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 \u2192\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 \u2192 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 \u2192 cl = inj_bytes bl := sorry'\n\ndef inj_value_rec (v : val) (q : quantity) : \u2115 \u2192 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) : \u2115 \u2192 list memval \u2192 bool\n| 0 [] := tt\n| (m + 1) (Fragment v' q' m' :: vl') :=\n  v = v' \u2227 q = q' \u2227 m = m' \u2227 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 \u2192 val \u2192 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 \u2208 inj_value q v \u2192 \u2203 n, mv = Fragment v q n := sorry'\n\nlemma proj_inj_value_mismatch (q1 q2 v) : q1 \u2260 q2 \u2192 proj_value q1 (inj_value q2 v) = Vundef := sorry'\n\ndef decode_encode_val : val \u2192 memory_chunk \u2192 memory_chunk \u2192 val \u2192 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 \u2192\n  chunk1.type = chunk2.type \u2192\n  chunk1.size = chunk2.size \u2192\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 \u2192 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 \u2192 quantity\n| Mint64   := Q64\n| Mfloat64 := Q64\n| Many64   := Q64\n| _        := Q32\n\ndef shape_encoding.b.type : val \u2192 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 \u2192 Prop\n| f (q i) : \u2200 mvl,\n      (chunk = Mint32 \u2228 chunk = Many32 \u2228 chunk = Mint64 \u2228 chunk = Many64) \u2192\n      q = quantity_chunk chunk \u2192\n      i+1 = q.size \u2192\n      (\u2200 mv \u2208 mvl, \u2203 j, mv = Fragment v q j \u2227 j+1 \u2260 q.size) \u2192\n      shape_encoding (Fragment v q i :: mvl)\n| b (b mvl) : memdata.shape_encoding.b.type v \u2192\n      (\u2200 mv \u2208 mvl, \u2203 b', mv = Byte b') \u2192 shape_encoding (Byte b :: mvl)\n| u (mvl) : (\u2200 mv \u2208 mvl, mv = Undef) \u2192 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 \u2192 val \u2192 Prop\n| f (v q i) : \u2200 mvl,\n      (chunk = Mint32 \u2228 chunk = Many32 \u2228 chunk = Mint64 \u2228 chunk = Many64) \u2192\n      q = quantity_chunk chunk \u2192\n      i+1 = q.size \u2192\n      (\u2200 mv \u2208 mvl, \u2203 j, mv = Fragment v q j \u2227 j+1 \u2260 q.size) \u2192\n      shape_decoding (Fragment v q i :: mvl) (val.load_result chunk v)\n| b (b mvl v) : shape_encoding.b.type v \u2192\n      (\u2200 mv \u2208 mvl, \u2203 b', mv = Byte b') \u2192\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 \u2192 memval \u2192 Prop\n| byte (n) : memval_inject (Byte n) (Byte n)\n| frag (v1 v2 q n) : inject f v1 v2 \u2192\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 \u2192 inject_incr f f' \u2192 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' \u2192\n  \u2200 bl, proj_bytes vl = some bl \u2192 proj_bytes vl' = some bl := sorry'\n\nlemma check_value_inject (f vl vl') :\n  list.forall2 (memval_inject f) vl vl' \u2192\n  \u2200 v v' q n,\n  check_value v q n vl \u2192\n  inject f v v' \u2192 v \u2260 Vundef \u2192\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 \u2192\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' \u2192\n  proj_bytes vl = none \u2192 proj_bytes vl' \u2260 none \u2192 Undef \u2208 vl := sorry'\n\nlemma check_value_undef (n q v vl) :\n  Undef \u2208 vl \u2192 \u00ac check_value v q n vl := sorry'\n\nlemma proj_value_undef (q vl) : Undef \u2208 vl \u2192 proj_value q vl = Vundef := sorry'\n\ntheorem decode_val_inject (f vl1 vl2 chunk) :\n  list.forall2 (memval_inject f) vl1 vl2 \u2192\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 \u2192\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 \u2192\n  list.forall2 (memval_inject f) (encode_val chunk v1) (encode_val chunk v2) := sorry'\n\ndef memval_lessdef : memval \u2192 memval \u2192 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 \u2192 memval_inject f' v2 v3 \u2192\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 \u2192 b.length = l.length := sorry'\n\nlemma proj_bytes_append (l2 l1) : proj_bytes (l1 ++ l2) =\n  do b1 \u2190 proj_bytes l1, b2 \u2190 proj_bytes l2, some (b1 ++ b2) := sorry'\n\nlemma decode_val_int64 {l1 l2 : list memval} : l1.length = 4 \u2192 l2.length = 4 \u2192 \u00ac archi.ptr64 \u2192\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) : \u00ac archi.ptr64 \u2192 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\u00f6l\u00e4. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kalle Kyt\u00f6l\u00e4\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 {\u03b1 : Type} [topological_space \u03b1]\n\n\nlemma portmanteau_open_closed_imp_borel_cond\n  (\u03bcseq : \u2115 \u2192 @measure_theory.measure \u03b1 (borel \u03b1)) (\u03bc : @measure_theory.measure \u03b1 (borel \u03b1)) : \n    portmanteau_open \u03bcseq \u03bc \u2227 portmanteau_closed \u03bcseq \u03bc\n    \u2192 portmanteau_borel \u03bcseq \u03bc :=\nbegin\n  rintros \u27e8 hopcond , hclcond \u27e9 ,\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 \u2286 Ecl := subset_closure ,\n  have h_Eint_subset_E : Eint \u2286 E := interior_subset ,\n  have ineq_E_le_Ecl := @measure_mono \u03b1 (borel(\u03b1)) \u03bc E Ecl subset_closure ,\n  have ineq_E_le_Ecl_seq := (\u03bb (n : \u2115) , @measure_mono \u03b1 (borel(\u03b1)) (\u03bcseq(n)) E Ecl subset_closure ) ,\n  have ineq_Eint_le_E := @measure_mono \u03b1 (borel(\u03b1)) \u03bc Eint E interior_subset ,\n  have ineq_Eint_le_E_seq := (\u03bb (n : \u2115) , @measure_mono \u03b1 (borel(\u03b1)) (\u03bcseq(n)) Eint E interior_subset) ,\n  have equalities := meas_eq_various_of_null_bdry \u03bc E hEnullbdry ,\n  have pt_limsup : limsup_enn (\u03bb n , (\u03bcseq(n))(E)) \u2264 \u03bc(E) ,\n  { calc limsup_enn (\u03bb n , (\u03bcseq(n))(E))\n        \u2264 limsup_enn (\u03bb n , (\u03bcseq(n))(Ecl))  : limsup_enn_mono ineq_E_le_Ecl_seq\n    ... \u2264 \u03bc(Ecl)                             : hclcond Ecl is_closed_closure\n    ... = \u03bc(E)                               : by rw equalities.2 ,\n    } ,\n  have pt_liminf : \u03bc(E) \u2264 liminf_enn (\u03bb n , (\u03bcseq(n))(E)) ,\n  { calc \u03bc(E) = \u03bc(Eint)                      : by rw equalities.1\n    ... \u2264 liminf_enn (\u03bb n , (\u03bcseq(n))(Eint)) : hopcond Eint is_open_interior\n    ... \u2264 liminf_enn (\u03bb n , (\u03bcseq(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 (\u03bb n , (\u03bcseq(n))(E)) = \u03bc(E) ,\n  { rw \u2190 this ,\n    exact key , } , \n  apply le_antisymm ,\n  { exact le_trans (liminf_le_limsup_enn (\u03bb n , (\u03bcseq(n))(E))) pt_limsup , } ,\n  { exact pt_liminf , } ,\nend\n\n\nlemma portmanteau_open_imp_borel\n  (\u03bcseq : \u2115 \u2192 @measure_theory.measure \u03b1 (borel \u03b1)) \n  (\u03bcseq_fin : \u2200 (n : \u2115) , @probability_measure \u03b1 (borel(\u03b1)) (\u03bcseq(n)))\n  (\u03bc : @measure_theory.measure \u03b1 (borel \u03b1)) (\u03bc_fin : @probability_measure \u03b1 (borel(\u03b1)) \u03bc) : \n    portmanteau_open \u03bcseq \u03bc \u2192 portmanteau_borel \u03bcseq \u03bc :=\nbegin\n  intros hopcond ,\n  have hclcond := portmanteau_open_imp_closed_cond \u03bcseq \u03bcseq_fin \u03bc \u03bc_fin hopcond ,\n  exact portmanteau_open_closed_imp_borel_cond \u03bcseq \u03bc \u27e8 hopcond , hclcond \u27e9 ,\nend\n\n\nlemma portmanteau_closed_imp_borel\n  (\u03bcseq : \u2115 \u2192 @measure_theory.measure \u03b1 (borel \u03b1)) \n  (\u03bcseq_fin : \u2200 (n : \u2115) , @probability_measure \u03b1 (borel(\u03b1)) (\u03bcseq(n)))\n  (\u03bc : @measure_theory.measure \u03b1 (borel \u03b1)) (\u03bc_fin : @probability_measure \u03b1 (borel(\u03b1)) \u03bc) : \n    portmanteau_closed \u03bcseq \u03bc \u2192 portmanteau_borel \u03bcseq \u03bc :=\nbegin\n  intros hclcond ,\n  have hopcond := portmanteau_closed_imp_open_cond \u03bcseq \u03bcseq_fin \u03bc \u03bc_fin hclcond ,\n  exact portmanteau_open_closed_imp_borel_cond \u03bcseq \u03bc \u27e8 hopcond , hclcond \u27e9 ,\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": "/-\nCopyright (c) 2019 Bruno Bentzen. All rights reserved.\nReleased under the Apache License 2.0 (see \"License\");\nAuthor: Bruno Bentzen\n-/\n\nimport ..core.interval\n\nopen interval\n\nvariables (A : I \u2192 I \u2192 Type) (a : \u03a0 j i, A j i)\n\n-- adjacency conditions are immediate\n\nexample : a i0 i0 = (\u03bb i, a i i0) i0 := rfl \n\nexample : a i1 i0 = (\u03bb i, a i i0) i1 := rfl\n\nexample : a i0 i1 = (\u03bb i, a i i1) i0 := rfl\n\nexample : a i1 i1 = (\u03bb i, a i i1) i1 := rfl\n\n/-                                                                        \n\n(\u03bb i, a i1 i) i1 = (\u03bb j, a j i1) i1 ======= (\u03bb i, a i1 i) i1 = (\u03bb j, a j i1) i1        --> i        \n                ||                                              |                   j | \n                ||                                              |                     v\n                ||                                              |\n    \u03bb j, a j i0 ||                     a                        | a j i1 \n                ||                                              |\n                ||                                              |\n                ||                                              v\n(\u03bb i, a i1 i) i1 = (\u03bb j, a j i1) i1 ======= (\u03bb i, a i1 i) i1 = (\u03bb j, a j i1) i1 \n\n-/\n\n-- faces and degeneracies \n\nexample : (\u03bb _, a) i0 = a := rfl \n\nexample : (\u03bb _, a) i1 = a := rfl \n\nexample : (\u03bb _, a i0) i1 = a i0 := rfl ", "meta": {"author": "bbentzen", "repo": "cubicalean", "sha": "3b94cd2aefdfc2163c263bd3fc6f2086fef814b5", "save_path": "github-repos/lean/bbentzen-cubicalean", "path": "github-repos/lean/bbentzen-cubicalean/cubicalean-3b94cd2aefdfc2163c263bd3fc6f2086fef814b5/src/examples/adjacency.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8152324983301568, "lm_q2_score": 0.5926665999540697, "lm_q1q2_score": 0.4831610729573958}}
{"text": "import for_mathlib.locally_closed\n\nnamespace topological_space\n\nvariables (\u03b1 \u03b2 : Type*) [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2192 \u03b2)\n\ndef closed_points : set \u03b1 := { x : \u03b1 | is_closed ({x} : set \u03b1) }\n\nlemma mem_closed_points {x} : x \u2208 closed_points \u03b1 \u2194 is_closed ({x} : set \u03b1) := iff.rfl\n\ndef is_jacobson : Prop :=\n\u2200 Z, is_closed Z \u2192 closure (Z \u2229 closed_points \u03b1) = Z\n\nvariables {\u03b1 \u03b2 f}\n\nlemma is_jacobson_iff_locally_closed : \n  is_jacobson \u03b1 \u2194 \u2200 Z : set \u03b1, Z.nonempty \u2192 is_locally_closed Z \u2192 (Z \u2229 closed_points \u03b1).nonempty :=\nbegin\n  split,\n  { simp_rw [is_locally_closed_iff_is_open_coboundary, coboundary, is_open_compl_iff,\n      \u2190 set.ne_empty_iff_nonempty],\n    intros H Z hZ hZ' e,\n    have : Z \u2286 closure Z \\ Z,\n    { refine subset_closure.trans _,\n      nth_rewrite 0 \u2190 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 \u27e8set.inter_subset_left _ _, set.inter_subset_right _ _\u27e9 },\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 [\u2190 set.disjoint_compl_left_iff_subset, set.disjoint_iff_inter_eq_empty, \n      \u2190 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 [\u2190 set.ne_empty_iff_nonempty, ne.def, set.inter_assoc,\n      \u2190 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 \u2194 is_jacobson.nonempty_inter_closed_points _\n\nlemma is_jacobson.is_closed_of_is_locally_closed (h\u03b1 : is_jacobson \u03b1) {x : \u03b1}\n  (hx : is_locally_closed ({x} : set \u03b1)) : is_closed ({x} : set \u03b1) :=\nbegin\n  obtain \u27e8_, \u27e8y, rfl : y = x, rfl\u27e9, hy'\u27e9 := h\u03b1.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 \u207b\u00b9' closed_points \u03b2 \u2286 closed_points \u03b1 :=\nbegin\n  intros x hx,\n  rw mem_closed_points,\n  convert continuous_iff_is_closed.mp hf.continuous _ hx,\n  rw [\u2190 set.image_singleton, set.preimage_image_eq _ hf.inj]\nend\n\nlemma closed_embedding.preimage_closed_points (hf : closed_embedding f) :\n  f \u207b\u00b9' closed_points \u03b2 = closed_points \u03b1 :=\nbegin\n  ext x, simp [mem_closed_points, \u2190 set.image_singleton, hf.closed_iff_image_closed],\nend\n\nlemma open_embedding.preimage_closed_points (hf : open_embedding f) (h\u03b2 : is_jacobson \u03b2) :\n  f \u207b\u00b9' closed_points \u03b2 = closed_points \u03b1 :=\nbegin\n  apply subset_antisymm (preimage_closed_points_subset hf.to_embedding),\n  intros x hx,\n  apply h\u03b2.is_closed_of_is_locally_closed,\n  rw \u2190 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\u03b1 : is_jacobson \u03b2)\n  (hf : open_embedding f) : is_jacobson \u03b1 :=\nbegin\n  rw is_jacobson_iff_locally_closed,\n  rw \u2190 hf.preimage_closed_points h\u03b1,\n  rw is_jacobson_iff_locally_closed at h\u03b1,\n  intros Z hZ hZ',\n  obtain \u27e8_, \u27e8x, hx, rfl\u27e9, hx'\u27e9 := h\u03b1 _ (hZ.image f) (hZ'.image hf.to_inducing \n    hf.open_range.is_locally_closed),\n  exact \u27e8_, hx, hx'\u27e9\nend\n\nlemma is_jacobson.of_closed_embedding (h\u03b1 : is_jacobson \u03b2)\n  (hf : closed_embedding f) : is_jacobson \u03b1 :=\nbegin\n  rw is_jacobson_iff_locally_closed at h\u03b1 \u22a2,\n  rw \u2190 hf.preimage_closed_points,\n  intros Z hZ hZ',\n  obtain \u27e8_, \u27e8x, hx, rfl\u27e9, hx'\u27e9 := h\u03b1 _ (hZ.image f) (hZ'.image hf.to_inducing \n    hf.closed_range.is_locally_closed),\n  exact \u27e8_, hx, hx'\u27e9\nend\n\nlemma is_jacobson.discrete_of_finite [finite \u03b1] (h\u03b1 : is_jacobson \u03b1) : discrete_topology \u03b1 :=\nbegin\n  suffices : closed_points \u03b1 = set.univ,\n  { rw \u2190 forall_open_iff_discrete,\n    intro s,\n    rw [\u2190 is_closed_compl_iff, \u2190 set.bUnion_of_singleton s\u1d9c],\n    refine is_closed_bUnion (set.to_finite _) (\u03bb x hx, _),\n    rw [\u2190 mem_closed_points, this],\n    trivial },\n  rw [\u2190 set.univ_subset_iff, \u2190 h\u03b1 _ is_closed_univ, set.univ_inter, closure_subset_iff_is_closed,\n    \u2190 set.bUnion_of_singleton (closed_points \u03b1)],\n  exact is_closed_bUnion (set.to_finite _) (\u03bb _, id),\nend\n\nlemma {u} is_jacobson_iff_of_supr_eq_top {\u03b1 : Type u} [topological_space \u03b1]\n  {\u03b9 : Type u} {U : \u03b9 \u2192 opens \u03b1} (hU : supr U = \u22a4) :\n  is_jacobson \u03b1 \u2194 \u2200 i, is_jacobson (U i) :=\nbegin\n  refine \u27e8\u03bb h i, h.of_open_embedding (U i).2.open_embedding_subtype_coe, \u03bb H, _\u27e9,\n  rw is_jacobson_iff_locally_closed,\n  intros Z hZ hZ',\n  have : (\u22c3 i, (U i : set \u03b1)) = set.univ, { rw \u2190 opens.coe_supr, injection hU },\n  have : (\u22c3 i, Z \u2229 U i) = Z, { rw [\u2190 set.inter_Union, this, set.inter_univ] },\n  rw [\u2190 this, set.nonempty_Union] at hZ,\n  obtain \u27e8i, x, hx, hx'\u27e9 := hZ,\n  obtain \u27e8y, hy, hy'\u27e9 := (is_jacobson_iff_locally_closed.mp $ H i) (coe \u207b\u00b9' Z) \u27e8\u27e8x, hx'\u27e9, hx\u27e9\n    (hZ'.preimage continuous_subtype_coe),\n  refine \u27e8y, hy, (is_closed_iff_coe_preimage_of_supr_eq_top hU _).mpr $ \u03bb j, _\u27e9,\n  by_cases (y : \u03b1) \u2208 U j,\n  { convert_to is_closed {(\u27e8y, h\u27e9 : U j)}, { ext z, exact @subtype.coe_inj _ _ z \u27e8y, h\u27e9 },\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 \u27e8y, h\u27e9).symm },\n  { convert is_closed_empty, rw set.eq_empty_iff_forall_not_mem, rintros z (hz : \u2191z = \u2191y),\n    rw \u2190 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 Mathlib.Tactic.Ring\nimport Mathlib.Data.Nat.Basic\nimport Mathlib.Data.Nat.Parity\nimport Mathlib.Algebra.Ring.Basic\nimport Mathlib.Algebra.Free\nimport Mathlib.SetTheory.Ordinal.Basic\nimport Mathlib.SetTheory.Cardinal.Ordinal\n\nlemma l1 (x : Nat) : Xor' (Even x) (Odd x) := by simp\n\nstructure Tree : Type (u+1) where\n  set : Type u\n  o : PartialOrder set\n  exists_root : \u2203 r : set, \u2200 a : set, r \u2264 a\n  prec_well_ordered : \u2200 p : set, \u2200 a b: {x:set//x<p}, a\u2264b \u2228 b\u2264a\n  \n\n", "meta": {"author": "Archaeoindris-fontoynontii", "repo": "inf_comb", "sha": "7626bd6818066b62a7206ac735ce5276d813540f", "save_path": "github-repos/lean/Archaeoindris-fontoynontii-inf_comb", "path": "github-repos/lean/Archaeoindris-fontoynontii-inf_comb/inf_comb-7626bd6818066b62a7206ac735ce5276d813540f/InfComb.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8774767778695834, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.48314517698112264}}
{"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 := \u03bb s, match s with star := \"*\" | box := \"\u25a1\" end }\n\ninductive Exp : Type\n| free : string \u2192 Exp\n| bound : nat \u2192 Exp\n| sort : PTSSort \u2192 Exp\n| app : Exp \u2192 Exp \u2192 Exp\n| lam : string \u2192 Exp \u2192 Exp \u2192 Exp\n| pi : string \u2192 Exp \u2192 Exp \u2192 Exp\n\n/-- A pretty printing of formulae. It doesn't try to interpolate\n  de-bruijn variables, which means that (\u03a0 x, 0) is the identity\n  function and (\u03a0 x, x) is the constant function for the free variable x. -/\ndef exp_repr : Exp \u2192 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) := \"\u03bb(\" ++ x ++ \" : \" ++ exp_repr a ++ \") \u2192 \" ++ exp_repr b\n| (Exp.pi x a b) := \"\u03a0(\" ++ x ++ \" : \" ++ exp_repr a ++ \") \u2192 \" ++ 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 \u2227 q) :=\n  infer_instance\n\ninstance exp_decidable_eq : decidable_eq Exp :=\n\u03bb 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 \u2192 nat \u2192 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 \u2192 nat \u2192 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 : \u03a0 (e : Exp), finset string\n| (Exp.free x) := finset.singleton x\n| (Exp.app a b) := free_vars a \u222a free_vars b\n| (Exp.lam _ a b) := free_vars a \u222a free_vars b\n| (Exp.pi _ a b) := free_vars a \u222a free_vars b\n| (Exp.bound _) := \u2205\n| (Exp.sort _) := \u2205\n\n/-- The bound variables -/\n@[simp] def bound_vars : \u03a0 (e : Exp), finset string\n| (Exp.app a b) := free_vars a \u222a free_vars b\n| (Exp.lam x a b) := insert x (free_vars a \u222a free_vars b)\n| (Exp.pi x a b) := insert x (free_vars a \u222a free_vars b)\n| _ := \u2205 \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 `\u2225x\u2225 = 0 \u2192 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 \u2192 W)\n(map_add' : \u2200 v\u2081 v\u2082, to_fun (v\u2081 + v\u2082) = to_fun v\u2081 + to_fun v\u2082)\n(bound' : \u2203 C, \u2200 v, \u2225to_fun v\u2225 \u2264 C * \u2225v\u2225)\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 `\u211d\u22650` for the bound. -/\ndef mk_normed_group_hom (f : V \u2192+ W)\n  (C : \u211d) (h : \u2200 v, \u2225f v\u2225 \u2264 C * \u2225v\u2225) : normed_group_hom V W :=\n{ bound' := \u27e8C, h\u27e9, ..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 `\u211d` for the bound. -/\ndef mk_normed_group_hom' (f : V \u2192+ W) (C : \u211d\u22650) (hC : \u2200 x, nnnorm (f x) \u2264 C * nnnorm x) :\n  normed_group_hom V W :=\n{ bound' := \u27e8C, hC\u27e9 .. 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 \u2192 W} (M : \u211d) (h : \u2200x, \u2225f x\u2225 \u2264 M * \u2225x\u2225) :\n  \u2203 N, 0 < N \u2227 \u2200x, \u2225f x\u2225 \u2264 N * \u2225x\u2225 :=\n\u27e8max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), \u03bbx, calc\n  \u2225f x\u2225 \u2264 M * \u2225x\u2225 : h x\n  ... \u2264 max M 1 * \u2225x\u2225 : mul_le_mul_of_nonneg_right (le_max_left _ _) (norm_nonneg _) \u27e9\n\nnamespace normed_group_hom\n\nvariables {V V\u2081 V\u2082 V\u2083 : Type*}\nvariables [semi_normed_group V] [semi_normed_group V\u2081] [semi_normed_group V\u2082] [semi_normed_group V\u2083]\nvariables {f g : normed_group_hom V\u2081 V\u2082}\n\ninstance : has_coe_to_fun (normed_group_hom V\u2081 V\u2082) (\u03bb _, V\u2081 \u2192 V\u2082) := \u27e8normed_group_hom.to_fun\u27e9\n\ninitialize_simps_projections normed_group_hom (to_fun \u2192 apply)\n\nlemma coe_inj (H : (f : V\u2081 \u2192 V\u2082) = g) : f = g :=\nby cases f; cases g; congr'; exact funext H\n\nlemma coe_injective : @function.injective (normed_group_hom V\u2081 V\u2082) (V\u2081 \u2192 V\u2082) coe_fn :=\nby apply coe_inj\n\nlemma coe_inj_iff : f = g \u2194 (f : V\u2081 \u2192 V\u2082) = g := \u27e8congr_arg _, coe_inj\u27e9\n\n@[ext] lemma ext (H : \u2200 x, f x = g x) : f = g := coe_inj $ funext H\n\nlemma ext_iff : f = g \u2194 \u2200 x, f x = g x := \u27e8by rintro rfl x; refl, ext\u27e9\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\u2081) (h\u2082) (h\u2083) : \u21d1(\u27e8f, h\u2081, h\u2082, h\u2083\u27e9 : normed_group_hom V\u2081 V\u2082) = f := rfl\n\n@[simp] lemma coe_mk_normed_group_hom (f : V\u2081 \u2192+ V\u2082) (C) (hC) :\n  \u21d1(f.mk_normed_group_hom C hC) = f := rfl\n\n@[simp] lemma coe_mk_normed_group_hom' (f : V\u2081 \u2192+ V\u2082) (C) (hC) :\n  \u21d1(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\u2081 V\u2082) : V\u2081 \u2192+ V\u2082 :=\nadd_monoid_hom.mk' f f.map_add'\n\n@[simp] lemma coe_to_add_monoid_hom : \u21d1f.to_add_monoid_hom = f := rfl\n\nlemma to_add_monoid_hom_injective :\n  function.injective (@normed_group_hom.to_add_monoid_hom V\u2081 V\u2082 _ _) :=\n\u03bb f g h, coe_inj $ show \u21d1f.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 {\u03b9 : Type*} (v : \u03b9 \u2192 V\u2081) (s : finset \u03b9) :\n  f (\u2211 i in s, v i) = \u2211 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 : \u2203 C, 0 < C \u2227 \u2200 x, \u2225f x\u2225 \u2264 C * \u2225x\u2225 :=\nlet \u27e8C, hC\u27e9 := f.bound' in exists_pos_bound_of_bound _ hC\n\ntheorem antilipschitz_of_norm_ge {K : \u211d\u22650} (h : \u2200 x, \u2225x\u2225 \u2264 K * \u2225f x\u2225) :\n  antilipschitz_with K f :=\nantilipschitz_with.of_le_mul_dist $\n\u03bb 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*\u2225x\u2225`. 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\u2081 V\u2082) (K : add_subgroup V\u2082) (C : \u211d) : Prop :=\n  \u2200 h \u2208 K, \u2203 g, f g = h \u2227 \u2225g\u2225 \u2264 C*\u2225h\u2225\n\nlemma surjective_on_with.mono {f : normed_group_hom V\u2081 V\u2082} {K : add_subgroup V\u2082} {C C' : \u211d}\n  (h : f.surjective_on_with K C) (H : C \u2264 C') : f.surjective_on_with K C' :=\nbegin\n  intros k k_in,\n  rcases h k k_in with \u27e8g, rfl, hg\u27e9,\n  use [g, rfl],\n  by_cases Hg : \u2225f g\u2225 = 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\u2081 V\u2082} {K : add_subgroup V\u2082} {C : \u211d}\n  (h : f.surjective_on_with K C) : \u2203 C' > 0, f.surjective_on_with K C' :=\nbegin\n  refine \u27e8|C| + 1, _, _\u27e9,\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\u2081 V\u2082} {K : add_subgroup V\u2082} {C : \u211d}\n  (h : f.surjective_on_with K C) : set.surj_on f set.univ K :=\n\u03bb x hx, (h x hx).imp $ \u03bb a \u27e8ha, _\u27e9, \u27e8set.mem_univ _, ha\u27e9\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\u2081 V\u2082) := Inf {c | 0 \u2264 c \u2227 \u2200 x, \u2225f x\u2225 \u2264 c * \u2225x\u2225}\ninstance has_op_norm : has_norm (normed_group_hom V\u2081 V\u2082) := \u27e8op_norm\u27e9\n\nlemma norm_def : \u2225f\u2225 = Inf {c | 0 \u2264 c \u2227 \u2200 x, \u2225f x\u2225 \u2264 c * \u2225x\u2225} := 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\u2081 V\u2082} :\n  \u2203 c, c \u2208 { c | 0 \u2264 c \u2227 \u2200 x, \u2225f x\u2225 \u2264 c * \u2225x\u2225 } :=\nlet \u27e8M, hMp, hMb\u27e9 := f.bound in \u27e8M, le_of_lt hMp, hMb\u27e9\n\nlemma bounds_bdd_below {f : normed_group_hom V\u2081 V\u2082} :\n  bdd_below {c | 0 \u2264 c \u2227 \u2200 x, \u2225f x\u2225 \u2264 c * \u2225x\u2225} :=\n\u27e80, \u03bb _ \u27e8hn, _\u27e9, hn\u27e9\n\nlemma op_norm_nonneg : 0 \u2264 \u2225f\u2225 :=\nle_cInf bounds_nonempty (\u03bb _ \u27e8hx, _\u27e9, hx)\n\n/-- The fundamental property of the operator norm: `\u2225f x\u2225 \u2264 \u2225f\u2225 * \u2225x\u2225`. -/\ntheorem le_op_norm (x : V\u2081) : \u2225f x\u2225 \u2264 \u2225f\u2225 * \u2225x\u2225 :=\nbegin\n  obtain \u27e8C, Cpos, hC\u27e9 := f.bound,\n  replace hC := hC x,\n  by_cases h : \u2225x\u2225 = 0,\n  { rwa [h, mul_zero] at \u22a2 hC },\n  have hlt : 0 < \u2225x\u2225 := lt_of_le_of_ne (norm_nonneg x) (ne.symm h),\n  exact (div_le_iff hlt).mp (le_cInf bounds_nonempty (\u03bb c \u27e8_, hc\u27e9,\n    (div_le_iff hlt).mpr $ by { apply hc })),\nend\n\ntheorem le_op_norm_of_le {c : \u211d} {x} (h : \u2225x\u2225 \u2264 c) : \u2225f x\u2225 \u2264 \u2225f\u2225 * 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 : \u211d} (h : \u2225f\u2225 \u2264 c) (x : V\u2081) : \u2225f x\u2225 \u2264 c * \u2225x\u2225 :=\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 \u27e8\u2225f\u2225, op_norm_nonneg f\u27e9 f :=\nlipschitz_with.of_dist_le_mul $ \u03bb x y,\n  by { rw [dist_eq_norm, dist_eq_norm, \u2190map_sub], apply le_op_norm }\n\nprotected lemma uniform_continuous (f : normed_group_hom V\u2081 V\u2082) :\n  uniform_continuous f := f.lipschitz.uniform_continuous\n\n@[continuity]\nprotected lemma continuous (f : normed_group_hom V\u2081 V\u2082) : continuous f :=\nf.uniform_continuous.continuous\n\nlemma ratio_le_op_norm (x : V\u2081) : \u2225f x\u2225 / \u2225x\u2225 \u2264 \u2225f\u2225 :=\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 : \u211d} (hMp: 0 \u2264 M) (hM : \u2200 x, \u2225f x\u2225 \u2264 M * \u2225x\u2225) :\n  \u2225f\u2225 \u2264 M :=\ncInf_le bounds_bdd_below \u27e8hMp, hM\u27e9\n\nlemma op_norm_eq_of_bounds {M : \u211d} (M_nonneg : 0 \u2264 M)\n  (h_above : \u2200 x, \u2225f x\u2225 \u2264 M*\u2225x\u2225) (h_below : \u2200 N \u2265 0, (\u2200 x, \u2225f x\u2225 \u2264 N*\u2225x\u2225) \u2192 M \u2264 N) :\n  \u2225f\u2225 = M :=\nle_antisymm (f.op_norm_le_bound M_nonneg h_above)\n  ((le_cInf_iff normed_group_hom.bounds_bdd_below \u27e8M, M_nonneg, h_above\u27e9).mpr $\n   \u03bb N \u27e8N_nonneg, hN\u27e9, h_below N N_nonneg hN)\n\ntheorem op_norm_le_of_lipschitz {f : normed_group_hom V\u2081 V\u2082} {K : \u211d\u22650} (hf : lipschitz_with K f) :\n  \u2225f\u2225 \u2264 K :=\nf.op_norm_le_bound K.2 $ \u03bb 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\u2081 \u2192+ V\u2082) {C : \u211d} (hC : 0 \u2264 C) (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  \u2225f.mk_normed_group_hom C h\u2225 \u2264 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\u2081 \u2192+ V\u2082) {C : \u211d} (h : \u2200x, \u2225f x\u2225 \u2264 C * \u2225x\u2225) :\n  \u2225f.mk_normed_group_hom C h\u2225 \u2264 max C 0 :=\nop_norm_le_bound _ (le_max_right _ _) $ \u03bb 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 \u2190 add_monoid_hom.mk_normed_group_hom_norm_le\nalias mk_normed_group_hom_norm_le' \u2190 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\u2081 V\u2082) :=\n\u27e8\u03bb f g, (f.to_add_monoid_hom + g.to_add_monoid_hom).mk_normed_group_hom (\u2225f\u2225 + \u2225g\u2225) $ \u03bb v, calc\n  \u2225f v + g v\u2225\n      \u2264 \u2225f v\u2225 + \u2225g v\u2225 : norm_add_le _ _\n  ... \u2264 \u2225f\u2225 * \u2225v\u2225 + \u2225g\u2225 * \u2225v\u2225 : add_le_add (le_op_norm f v) (le_op_norm g v)\n  ... = (\u2225f\u2225 + \u2225g\u2225) * \u2225v\u2225 : by rw add_mul\u27e9\n\n/-- The operator norm satisfies the triangle inequality. -/\ntheorem op_norm_add_le : \u2225f + g\u2225 \u2264 \u2225f\u2225 + \u2225g\u2225 :=\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\u2081 \u2192 V\u2082)`\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\u2081 V\u2082) : \u21d1(f + g) = (f + g : V\u2081 \u2192 V\u2082) := rfl\n@[simp] lemma add_apply (f g : normed_group_hom V\u2081 V\u2082) (v : V\u2081) :\n  (f + g : normed_group_hom V\u2081 V\u2082) v = f v + g v := rfl\n\n/-! ### The zero normed group hom -/\n\ninstance : has_zero (normed_group_hom V\u2081 V\u2082) :=\n\u27e8(0 : V\u2081 \u2192+ V\u2082).mk_normed_group_hom 0 (by simp)\u27e9\n\ninstance : inhabited (normed_group_hom V\u2081 V\u2082) := \u27e80\u27e9\n\n/-- The norm of the `0` operator is `0`. -/\ntheorem op_norm_zero : \u2225(0 : normed_group_hom V\u2081 V\u2082)\u2225 = 0 :=\nle_antisymm (cInf_le bounds_bdd_below\n    \u27e8ge_of_eq rfl, \u03bb _, le_of_eq (by { rw [zero_mul], exact norm_zero })\u27e9)\n    (op_norm_nonneg _)\n\n/-- For normed groups, an operator is zero iff its norm vanishes. -/\ntheorem op_norm_zero_iff {V\u2081 V\u2082 : Type*} [normed_group V\u2081] [normed_group V\u2082]\n  {f : normed_group_hom V\u2081 V\u2082} : \u2225f\u2225 = 0 \u2194 f = 0 :=\niff.intro\n  (\u03bb hn, ext (\u03bb x, norm_le_zero_iff.1\n    (calc _ \u2264 \u2225f\u2225 * \u2225x\u2225 : le_op_norm _ _\n     ...     = _ : by rw [hn, zero_mul])))\n  (\u03bb hf, by rw [hf, op_norm_zero] )\n\n-- see Note [addition on function coercions]\n@[simp] lemma coe_zero : \u21d1(0 : normed_group_hom V\u2081 V\u2082) = (0 : V\u2081 \u2192 V\u2082) := rfl\n@[simp] lemma zero_apply (v : V\u2081) : (0 : normed_group_hom V\u2081 V\u2082) 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 : \u2225(id V : normed_group_hom V V)\u2225 \u2264 1 :=\nop_norm_le_bound _ zero_le_one (\u03bbx, 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 : \u2203 (x : V), \u2225x\u2225 \u2260 0 ) :\n  \u2225(id V)\u2225 = 1 :=\nle_antisymm (norm_id_le V) $ let \u27e8x, hx\u27e9 := 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] : \u2225(id V)\u2225 = 1 :=\nbegin\n  refine norm_id_of_nontrivial_seminorm V _,\n  obtain \u27e8x, hx\u27e9 := exists_ne (0 : V),\n  exact \u27e8x, ne_of_gt (norm_pos_iff.2 hx)\u27e9,\nend\n\nlemma coe_id : ((normed_group_hom.id V) : V \u2192 V) = (_root_.id : V \u2192 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\u2081 V\u2082) :=\n\u27e8\u03bb f, (-f.to_add_monoid_hom).mk_normed_group_hom (\u2225f\u2225) (\u03bb v, by simp [le_op_norm f v])\u27e9\n\n-- see Note [addition on function coercions]\n@[simp] lemma coe_neg (f : normed_group_hom V\u2081 V\u2082) : \u21d1(-f) = (-f : V\u2081 \u2192 V\u2082) := rfl\n@[simp] lemma neg_apply (f : normed_group_hom V\u2081 V\u2082) (v : V\u2081) :\n  (-f : normed_group_hom V\u2081 V\u2082) v = - (f v) := rfl\n\nlemma op_norm_neg (f : normed_group_hom V\u2081 V\u2082) : \u2225-f\u2225 = \u2225f\u2225 :=\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\u2081 V\u2082) :=\n\u27e8\u03bb 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) }\u27e9\n\n-- see Note [addition on function coercions]\n@[simp] lemma coe_sub (f g : normed_group_hom V\u2081 V\u2082) : \u21d1(f - g) = (f - g : V\u2081 \u2192 V\u2082) := rfl\n@[simp] lemma sub_apply (f g : normed_group_hom V\u2081 V\u2082) (v : V\u2081) :\n  (f - g : normed_group_hom V\u2081 V\u2082) 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\u2081 V\u2082) :=\ncoe_injective.add_comm_group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, 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\u2081 V\u2082) :=\nsemi_normed_group.of_core _ \u27e8op_norm_zero, op_norm_add_le, op_norm_neg\u27e9\n\n/-- Normed group homomorphisms themselves form a normed group with respect to\n    the operator norm. -/\ninstance to_normed_group {V\u2081 V\u2082 : Type*} [normed_group V\u2081] [normed_group V\u2082] :\n  normed_group (normed_group_hom V\u2081 V\u2082) :=\nnormed_group.of_core _ \u27e8\u03bb f, op_norm_zero_iff, op_norm_add_le, op_norm_neg\u27e9\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\u2081 V\u2082 \u2192+ (V\u2081 \u2192 V\u2082) :=\n{ to_fun := coe_fn, map_zero' := coe_zero, map_add' := coe_add}\n\n@[simp] lemma coe_sum {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 normed_group_hom V\u2081 V\u2082) :\n  \u21d1(\u2211 i in s, f i) = \u2211 i in s, (f i) :=\n(coe_fn_add_hom : _ \u2192+ (V\u2081 \u2192 V\u2082)).map_sum f s\n\nlemma sum_apply {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 normed_group_hom V\u2081 V\u2082) (v : V\u2081) :\n  (\u2211 i in s, f i) v = \u2211 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\u2082 V\u2083) (f : normed_group_hom V\u2081 V\u2082) :\n  normed_group_hom V\u2081 V\u2083 :=\n(g.to_add_monoid_hom.comp f.to_add_monoid_hom).mk_normed_group_hom (\u2225g\u2225 * \u2225f\u2225) $ \u03bb v, calc\n\u2225g (f v)\u2225 \u2264 \u2225g\u2225 * \u2225f v\u2225 : le_op_norm _ _\n... \u2264 \u2225g\u2225 * (\u2225f\u2225 * \u2225v\u2225) : mul_le_mul_of_nonneg_left (le_op_norm _ _) (op_norm_nonneg _)\n... = \u2225g\u2225 * \u2225f\u2225 * \u2225v\u2225   : by rw mul_assoc\n\nlemma norm_comp_le (g : normed_group_hom V\u2082 V\u2083) (f : normed_group_hom V\u2081 V\u2082) :\n  \u2225g.comp f\u2225 \u2264 \u2225g\u2225 * \u2225f\u2225 :=\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\u2082 V\u2083} {C\u2081 C\u2082 : \u211d} (hg : \u2225g\u2225 \u2264 C\u2082) (hf : \u2225f\u2225 \u2264 C\u2081) :\n  \u2225g.comp f\u2225 \u2264 C\u2082 * C\u2081 :=\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\u2082 V\u2083} (C\u2081 C\u2082 C\u2083 : \u211d) (h : C\u2083 = C\u2082 * C\u2081)\n  (hg : \u2225g\u2225 \u2264 C\u2082) (hf : \u2225f\u2225 \u2264 C\u2081) : \u2225g.comp f\u2225 \u2264 C\u2083 :=\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\u2082 V\u2083) \u2192+ (normed_group_hom V\u2081 V\u2082) \u2192+ (normed_group_hom V\u2081 V\u2083) :=\nadd_monoid_hom.mk' (\u03bb g, add_monoid_hom.mk' (\u03bb 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\u2082 V\u2083) : f.comp (0 : normed_group_hom V\u2081 V\u2082) = 0 :=\nby { ext, exact f.map_zero }\n\n@[simp] lemma zero_comp (f : normed_group_hom V\u2081 V\u2082) : (0 : normed_group_hom V\u2082 V\u2083).comp f = 0 :=\nby { ext, refl }\n\nlemma comp_assoc {V\u2084: Type* } [semi_normed_group V\u2084] (h : normed_group_hom V\u2083 V\u2084)\n  (g : normed_group_hom V\u2082 V\u2083) (f : normed_group_hom V\u2081 V\u2082) :\n  (h.comp g).comp f = h.comp (g.comp f) :=\nby { ext, refl }\n\nlemma coe_comp (f : normed_group_hom V\u2081 V\u2082) (g : normed_group_hom V\u2082 V\u2083) :\n  (g.comp f : V\u2081 \u2192 V\u2083) = (g : V\u2082 \u2192 V\u2083) \u2218 (f : V\u2081 \u2192 V\u2082) := rfl\n\nend normed_group_hom\n\nnamespace normed_group_hom\n\nvariables {V W V\u2081 V\u2082 V\u2083 : Type*}\nvariables [semi_normed_group V] [semi_normed_group W] [semi_normed_group V\u2081] [semi_normed_group V\u2082]\n[semi_normed_group V\u2083]\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 \u2192 V),\n  map_add' := \u03bb v w, add_subgroup.coe_add _ _ _,\n  bound' := \u27e81, \u03bb v, by { rw [one_mul], refl }\u27e9 }\n\nlemma norm_incl {V' : add_subgroup V} (x : V') : \u2225incl _ x\u2225 = \u2225x\u2225 :=\nrfl\n\n/-!### Kernel -/\nsection kernels\nvariables (f : normed_group_hom V\u2081 V\u2082) (g : normed_group_hom V\u2082 V\u2083)\n\n/-- The kernel of a bounded group homomorphism. Naturally endowed with a\n`semi_normed_group` instance. -/\ndef ker : add_subgroup V\u2081 := f.to_add_monoid_hom.ker\n\nlemma mem_ker (v : V\u2081) : v \u2208 f.ker \u2194 f v = 0 :=\nby { erw f.to_add_monoid_hom.mem_ker, refl }\n\n/-- Given a normed group hom `f : V\u2081 \u2192 V\u2082` satisfying `g.comp f = 0` for some `g : V\u2082 \u2192 V\u2083`,\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\u2081 g.ker :=\n{ to_fun := \u03bb v, \u27e8f v, by { erw g.mem_ker, show (g.comp f) v = 0, rw h, refl }\u27e9,\n  map_add' := \u03bb 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\u2081 V\u2082).ker = \u22a4 :=\nby { ext, simp [mem_ker] }\n\nlemma coe_ker : (f.ker : set V\u2081) = (f : V\u2081 \u2192 V\u2082) \u207b\u00b9' {0} := rfl\n\nlemma is_closed_ker {V\u2082 : Type*} [normed_group V\u2082] (f : normed_group_hom V\u2081 V\u2082) :\n  is_closed (f.ker : set V\u2081) :=\nf.coe_ker \u25b8 is_closed.preimage f.continuous (t1_space.t1 0)\n\nend kernels\n\n/-! ### Range -/\nsection range\n\nvariables (f : normed_group_hom V\u2081 V\u2082) (g : normed_group_hom V\u2082 V\u2083)\n\n/-- The image of a bounded group homomorphism. Naturally endowed with a\n`semi_normed_group` instance. -/\ndef range : add_subgroup V\u2082 := f.to_add_monoid_hom.range\n\nlemma mem_range (v : V\u2082) : v \u2208 f.range \u2194 \u2203 w, f w = v :=\nby { rw [range, add_monoid_hom.mem_range], refl }\n\n@[simp]\nlemma mem_range_self (v : V\u2081) : f v \u2208 f.range :=\n\u27e8v, rfl\u27e9\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\u2081) : (incl s).range = s :=\nby { ext x, exact \u27e8\u03bb \u27e8y, hy\u27e9, by { rw \u2190 hy; simp }, \u03bb hx, \u27e8\u27e8x, hx\u27e9, by simp\u27e9\u27e9 }\n\n@[simp]\nlemma range_comp_incl_top : (f.comp (incl (\u22a4 : add_subgroup V\u2081))).range = f.range :=\nby simpa [comp_range, incl_range, \u2190 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 `\u2225f v\u2225 \u2264 \u2225v\u2225` for all `v`. -/\ndef norm_noninc (f : normed_group_hom V W) : Prop :=\n\u2200 v, \u2225f v\u2225 \u2264 \u2225v\u2225\n\nnamespace norm_noninc\n\nlemma norm_noninc_iff_norm_le_one : f.norm_noninc \u2194 \u2225f\u2225 \u2264 1 :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, \u03bb v, _\u27e9,\n  { refine op_norm_le_bound _ (zero_le_one) (\u03bb 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\u2081 V\u2082).norm_noninc :=\n\u03bb v, by simp\n\nlemma id : (id V).norm_noninc :=\n\u03bb v, le_rfl\n\nlemma comp {g : normed_group_hom V\u2082 V\u2083} {f : normed_group_hom V\u2081 V\u2082}\n  (hg : g.norm_noninc) (hf : f.norm_noninc) :\n  (g.comp f).norm_noninc :=\n\u03bb v, (hg (f v)).trans (hf v)\n\n@[simp] lemma neg_iff {f : normed_group_hom V\u2081 V\u2082} : (-f).norm_noninc \u2194 f.norm_noninc :=\n\u27e8\u03bb h x, by { simpa using h x }, \u03bb h x, (norm_neg (f x)).le.trans (h x)\u27e9\n\nend norm_noninc\n\nsection isometry\n\nlemma isometry_iff_norm (f : normed_group_hom V W) :\n  isometry f \u2194 \u2200 v, \u2225f v\u2225 = \u2225v\u2225 :=\nadd_monoid_hom.isometry_iff_norm f.to_add_monoid_hom\n\nlemma isometry_of_norm (f : normed_group_hom V W) (hf : \u2200 v, \u2225f v\u2225 = \u2225v\u2225) :\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  \u2225f v\u2225 = \u2225v\u2225 :=\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\u2082 V\u2083} {f : normed_group_hom V\u2081 V\u2082}\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\u03bb v, le_of_eq $ norm_eq_of_isometry hf v\n\nend isometry\n\nvariables {W\u2081 W\u2082 W\u2083 : Type*} [semi_normed_group W\u2081] [semi_normed_group W\u2082] [semi_normed_group W\u2083]\nvariables (f) (g : normed_group_hom V W)\nvariables {f\u2081 g\u2081 : normed_group_hom V\u2081 W\u2081}\nvariables {f\u2082 g\u2082 : normed_group_hom V\u2082 W\u2082}\nvariables {f\u2083 g\u2083 : normed_group_hom V\u2083 W\u2083}\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 \u03b9 : normed_group_hom (f.equalizer g) V := incl _\n\nlemma comp_\u03b9_eq : f.comp (\u03b9 f g) = g.comp (\u03b9 f g) :=\nby { ext, rw [comp_apply, comp_apply, \u2190 sub_eq_zero, \u2190 normed_group_hom.sub_apply], exact x.2 }\n\nvariables {f g}\n\n/-- If `\u03c6 : normed_group_hom V\u2081 V` is such that `f.comp \u03c6 = g.comp \u03c6`, the induced morphism\n`normed_group_hom V\u2081 (f.equalizer g)`. -/\n@[simps]\ndef lift (\u03c6 : normed_group_hom V\u2081 V) (h : f.comp \u03c6 = g.comp \u03c6) :\n  normed_group_hom V\u2081 (f.equalizer g) :=\n{ to_fun := \u03bb v, \u27e8\u03c6 v, show (f - g) (\u03c6 v) = 0,\n    by rw [normed_group_hom.sub_apply, sub_eq_zero, \u2190 comp_apply, h, comp_apply]\u27e9,\n  map_add' := \u03bb v\u2081 v\u2082, by { ext, simp only [map_add, add_subgroup.coe_add, subtype.coe_mk] },\n  bound' := by { obtain \u27e8C, C_pos, hC\u27e9 := \u03c6.bound, exact \u27e8C, hC\u27e9 } }\n\n@[simp] lemma \u03b9_comp_lift (\u03c6 : normed_group_hom V\u2081 V) (h : f.comp \u03c6 = g.comp \u03c6) :\n  (\u03b9 _ _).comp (lift \u03c6 h) = \u03c6 :=\nby { ext, refl }\n\n/-- The lifting property of the equalizer as an equivalence. -/\n@[simps]\ndef lift_equiv : {\u03c6 : normed_group_hom V\u2081 V // f.comp \u03c6 = g.comp \u03c6} \u2243\n  normed_group_hom V\u2081 (f.equalizer g) :=\n{ to_fun := \u03bb \u03c6, lift \u03c6 \u03c6.prop,\n  inv_fun := \u03bb \u03c8, \u27e8(\u03b9 f g).comp \u03c8, by { rw [\u2190 comp_assoc, \u2190 comp_assoc, comp_\u03b9_eq] }\u27e9,\n  left_inv := \u03bb \u03c6, by simp,\n  right_inv := \u03bb \u03c8, by { ext, refl } }\n\n/-- Given `\u03c6 : normed_group_hom V\u2081 V\u2082` and `\u03c8 : normed_group_hom W\u2081 W\u2082` such that\n`\u03c8.comp f\u2081 = f\u2082.comp \u03c6` and `\u03c8.comp g\u2081 = g\u2082.comp \u03c6`, the induced morphism\n`normed_group_hom (f\u2081.equalizer g\u2081) (f\u2082.equalizer g\u2082)`. -/\ndef map (\u03c6 : normed_group_hom V\u2081 V\u2082) (\u03c8 : normed_group_hom W\u2081 W\u2082)\n  (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6) :\n  normed_group_hom (f\u2081.equalizer g\u2081) (f\u2082.equalizer g\u2082) :=\nlift (\u03c6.comp $ \u03b9 _ _) $\nby { simp only [\u2190 comp_assoc, \u2190 hf, \u2190 hg], simp only [comp_assoc, comp_\u03b9_eq] }\n\nvariables {\u03c6 : normed_group_hom V\u2081 V\u2082} {\u03c8 : normed_group_hom W\u2081 W\u2082}\nvariables {\u03c6' : normed_group_hom V\u2082 V\u2083} {\u03c8' : normed_group_hom W\u2082 W\u2083}\n\n@[simp] lemma \u03b9_comp_map (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6) :\n  (\u03b9 f\u2082 g\u2082).comp (map \u03c6 \u03c8 hf hg) = \u03c6.comp (\u03b9 _ _) :=\n\u03b9_comp_lift _ _\n\n@[simp] lemma map_id : map (id V\u2081) (id W\u2081) rfl rfl = id (f\u2081.equalizer g\u2081) :=\nby { ext, refl }\n\nlemma comm_sq\u2082 (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hf' : \u03c8'.comp f\u2082 = f\u2083.comp \u03c6') :\n  (\u03c8'.comp \u03c8).comp f\u2081 = f\u2083.comp (\u03c6'.comp \u03c6) :=\nby rw [comp_assoc, hf, \u2190 comp_assoc, hf', comp_assoc]\n\nlemma map_comp_map (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6)\n  (hf' : \u03c8'.comp f\u2082 = f\u2083.comp \u03c6') (hg' : \u03c8'.comp g\u2082 = g\u2083.comp \u03c6') :\n  (map \u03c6' \u03c8' hf' hg').comp (map \u03c6 \u03c8 hf hg) =\n    map (\u03c6'.comp \u03c6) (\u03c8'.comp \u03c8) (comm_sq\u2082 hf hf') (comm_sq\u2082 hg hg') :=\nby { ext, refl }\n\nlemma \u03b9_norm_noninc : (\u03b9 f g).norm_noninc := \u03bb v, le_rfl\n\n/-- The lifting of a norm nonincreasing morphism is norm nonincreasing. -/\nlemma lift_norm_noninc (\u03c6 : normed_group_hom V\u2081 V) (h : f.comp \u03c6 = g.comp \u03c6) (h\u03c6 : \u03c6.norm_noninc) :\n  (lift \u03c6 h).norm_noninc :=\nh\u03c6\n\n/-- If `\u03c6` satisfies `\u2225\u03c6\u2225 \u2264 C`, then the same is true for the lifted morphism. -/\nlemma norm_lift_le (\u03c6 : normed_group_hom V\u2081 V) (h : f.comp \u03c6 = g.comp \u03c6)\n  (C : \u211d) (h\u03c6 : \u2225\u03c6\u2225 \u2264 C) : \u2225(lift \u03c6 h)\u2225 \u2264 C := h\u03c6\n\nlemma map_norm_noninc (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6)\n  (h\u03c6 : \u03c6.norm_noninc) : (map \u03c6 \u03c8 hf hg).norm_noninc :=\nlift_norm_noninc _ _ $ h\u03c6.comp \u03b9_norm_noninc\n\nlemma norm_map_le (hf : \u03c8.comp f\u2081 = f\u2082.comp \u03c6) (hg : \u03c8.comp g\u2081 = g\u2082.comp \u03c6)\n  (C : \u211d) (h\u03c6 : \u2225\u03c6.comp (\u03b9 f\u2081 g\u2081)\u2225 \u2264 C) : \u2225map \u03c6 \u03c8 hf hg\u2225 \u2264 C :=\nnorm_lift_le _ _ _ h\u03c6\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*\u2225x\u2225` then the same holds for\nelements of the (topological) closure of `K` with constant `C+\u03b5` instead of `C`, for any\npositive `\u03b5`.\n-/\nlemma controlled_closure_of_complete  {f : normed_group_hom G H} {K : add_subgroup H}\n  {C \u03b5 : \u211d} (hC : 0 < C) (h\u03b5 : 0 < \u03b5) (hyp : f.surjective_on_with K C) :\n  f.surjective_on_with K.topological_closure (C + \u03b5) :=\nbegin\n  rintros (h : H) (h_in : h \u2208 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 : \u2115 \u2192 \u211d := \u03bb i, (1/2)^i*(\u03b5*\u2225h\u2225/2)/C,\n  have b_pos : \u2200 i, 0 < b i,\n  { intro i,\n    field_simp [b, hC],\n    exact div_pos (mul_pos h\u03b5 (norm_pos_iff.mpr hyp_h))\n                  (mul_pos (by norm_num : (0 : \u211d) < 2^i*2) hC) },\n  obtain \u27e8v : \u2115 \u2192 H, lim_v : tendsto (\u03bb (n : \u2115), \u2211 k in range (n + 1), v k) at_top (\ud835\udcdd h),\n    v_in : \u2200 n, v n \u2208 K, hv\u2080 : \u2225v 0 - h\u2225 < b 0, hv : \u2200 n > 0, \u2225v n\u2225 < b n\u27e9 :=\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 : \u2200 n, \u2203 m' : G, f m' = v n \u2227 \u2225m'\u2225 \u2264 C * \u2225v n\u2225 := \u03bb (n : \u2115), 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 : \u2115 \u2192 G := \u03bb n, \u2211 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 \u2265 1),\n    calc \u2225u n\u2225 \u2264 C*\u2225v n\u2225 : hnorm_u n\n    ... \u2264 C * b n : mul_le_mul_of_nonneg_left (hv _ $ nat.succ_le_iff.mp hn).le hC.le\n    ... = (1/2)^n * (\u03b5 * \u2225h\u2225/2) : by simp [b, mul_div_cancel' _ hC.ne.symm]\n    ... = (\u03b5 * \u2225h\u2225/2) * (1/2)^n : mul_comm _ _ },\n  /- We now show that the limit `g` of `s` is the desired preimage. -/\n  obtain \u27e8g : G, hg\u27e9 := cauchy_seq_tendsto_of_complete this,\n  refine \u27e8g, _, _\u27e9,\n  { /- We indeed get a preimage. First note: -/\n    have : f \u2218 s = \u03bb n, \u2211 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 \u2190 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 : \u2200 n, \u2225s n\u2225 \u2264 (C + \u03b5) * \u2225h\u2225,\n      from le_of_tendsto' (continuous_norm.continuous_at.tendsto.comp hg) this,\n    intros n,\n    have hnorm\u2080 : \u2225u 0\u2225 \u2264 C*b 0 + C*\u2225h\u2225,\n    { have := calc\n      \u2225v 0\u2225 \u2264 \u2225h\u2225 + \u2225v 0 - h\u2225 : norm_le_insert' _ _\n      ... \u2264 \u2225h\u2225 + b 0 : by apply add_le_add_left hv\u2080.le,\n      calc \u2225u 0\u2225 \u2264 C*\u2225v 0\u2225 : hnorm_u 0\n      ... \u2264 C*(\u2225h\u2225 + b 0) : mul_le_mul_of_nonneg_left this hC.le\n      ... = C * b 0 + C * \u2225h\u2225 : by rw [add_comm, mul_add] },\n    have : \u2211 k in range (n + 1), C * b k \u2264 \u03b5 * \u2225h\u2225 := calc\n      \u2211 k in range (n + 1), C * b k = (\u2211 k in range (n + 1), (1 / 2) ^ k) * (\u03b5 * \u2225h\u2225 / 2) :\n                     by simp only [b, mul_div_cancel' _ hC.ne.symm, \u2190 sum_mul]\n      ... \u2264  2 * (\u03b5 * \u2225h\u2225 / 2) : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                                            (by nlinarith [h\u03b5, norm_nonneg h])\n      ... = \u03b5 * \u2225h\u2225 : mul_div_cancel' _ two_ne_zero,\n    calc \u2225s n\u2225 \u2264 \u2211 k in range (n+1), \u2225u k\u2225 : norm_sum_le _ _\n    ... = \u2211 k in range n, \u2225u (k + 1)\u2225 + \u2225u 0\u2225 : sum_range_succ' _ _\n    ... \u2264 \u2211 k in range n, C*\u2225v (k + 1)\u2225 + \u2225u 0\u2225 : add_le_add_right (sum_le_sum (\u03bb _ _, hnorm_u _)) _\n    ... \u2264 \u2211 k in range n, C*b (k+1) + (C*b 0 + C*\u2225h\u2225) :\n      add_le_add (sum_le_sum (\u03bb k _, mul_le_mul_of_nonneg_left (hv _ k.succ_pos).le hC.le)) hnorm\u2080\n    ... = \u2211 k in range (n+1), C*b k + C*\u2225h\u2225 : by rw [\u2190 add_assoc, sum_range_succ']\n    ... \u2264 (C+\u03b5)*\u2225h\u2225 : 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*\u2225x\u2225` then the same holds for elements of the (topological) closure of this image with constant\n`C+\u03b5` instead of `C`, for any positive `\u03b5`.\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 : \u2200 x, \u2225j x\u2225 = \u2225x\u2225)\n  {C \u03b5 : \u211d} (hC : 0 < C) (h\u03b5 : 0 < \u03b5) (hyp : \u2200 k, \u2203 g, f g = j k \u2227 \u2225g\u2225 \u2264 C*\u2225k\u2225) :\n  f.surjective_on_with j.range.topological_closure (C + \u03b5) :=\nbegin\n  replace hyp : \u2200 h \u2208 j.range, \u2203 g, f g = h \u2227 \u2225g\u2225 \u2264 C*\u2225h\u2225,\n  { intros h h_in,\n    rcases (j.mem_range _).mp h_in with \u27e8k, rfl\u27e9,\n    rw hj,\n    exact hyp k },\n  exact controlled_closure_of_complete hC h\u03b5 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 := \u2115\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 ` \u27f6 ` :(std.prec.arrow+1)\nreserve prefix `\u25a1` :40\nreserve prefix `\u25c7` :40\n\nnotation `\u22a5` := formula.bottom\nnotation `\u22a4` := formula.top\nnotation \u00ac a := formula.not a\nnotation a ` \u2227 ` b := (formula.and a b)\nnotation a ` \u2228 ` b := formula.or a b\nnotation a ` \u27f6 ` b := formula.implies a b\nnotation a ` \u2194 ` b := formula.iff a b\nnotation \u25a1a := formula.box a\nnotation \u25c7a := formula.diamond a\n\n-- Used to construct formulas containing arbitrary symbols e.g. `0 \u2228 1` (`p \u2228 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 := \u03bbx 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 \u2192 Prop\n| \u22a4 := true\n| \u22a5 := true\n| (formula.symbol _) := true\n| \u00aca := modal_free a\n| (a \u2227 b) := modal_free a \u2227 modal_free b\n| (a \u2228 b) := modal_free a \u2227 modal_free b\n| (a \u27f6 b) := modal_free a \u2227 modal_free b\n| (a \u2194 b) := modal_free a \u2227 modal_free b\n| \u25a1_ := false\n| \u25c7_ := false\n\n/-- Substitutes sentence symbols for formulas in a formula according to a mapping function. -/\n@[simp] def subst (substs : symbol \u2192 formula) : formula \u2192 formula\n| \u22a4 := \u22a4\n| \u22a5 := \u22a5\n| (formula.symbol s) := substs s\n| \u00aca := \u00acsubst a\n| (a \u2227 b) := subst a \u2227 subst b\n| (a \u2228 b) := subst a \u2228 subst b\n| (a \u27f6 b) := subst a \u27f6 subst b\n| (a \u2194 b) := subst a \u2194 subst b\n| \u25a1a := \u25a1subst a\n| \u25c7a := \u25c7subst 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\u2203substs, 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 `\u2295'` 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 {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) :=\n  \u2203 f, Computable f \u2227 \u2200 a, p a \u2194 q (f a)\n#align many_one_reducible ManyOneReducible\n\n-- mathport name: \u00abexpr \u2264\u2080 \u00bb\ninfixl:1000 \" \u2264\u2080 \" => ManyOneReducible\n\ntheorem ManyOneReducible.mk {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {f : \u03b1 \u2192 \u03b2} (q : \u03b2 \u2192 Prop)\n    (h : Computable f) : (fun a => q (f a)) \u2264\u2080 q :=\n  \u27e8f, h, fun a => Iff.rfl\u27e9\n#align many_one_reducible.mk ManyOneReducible.mk\n\n@[refl]\ntheorem manyOneReducible_refl {\u03b1} [Primcodable \u03b1] (p : \u03b1 \u2192 Prop) : p \u2264\u2080 p :=\n  \u27e8id, Computable.id, by simp\u27e9\n#align many_one_reducible_refl manyOneReducible_refl\n\n@[trans]\ntheorem ManyOneReducible.trans {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} : p \u2264\u2080 q \u2192 q \u2264\u2080 r \u2192 p \u2264\u2080 r\n  | \u27e8f, c\u2081, h\u2081\u27e9, \u27e8g, c\u2082, h\u2082\u27e9 =>\n    \u27e8g \u2218 f, c\u2082.comp c\u2081, fun a => \u27e8fun h => by rwa [\u2190 h\u2082, \u2190 h\u2081], fun h => by rwa [h\u2081, h\u2082]\u27e9\u27e9\n#align many_one_reducible.trans ManyOneReducible.trans\n\ntheorem reflexive_manyOneReducible {\u03b1} [Primcodable \u03b1] : Reflexive (@ManyOneReducible \u03b1 \u03b1 _ _) :=\n  manyOneReducible_refl\n#align reflexive_many_one_reducible reflexive_manyOneReducible\n\ntheorem transitive_manyOneReducible {\u03b1} [Primcodable \u03b1] : Transitive (@ManyOneReducible \u03b1 \u03b1 _ _) :=\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 {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) :=\n  \u2203 f, Computable f \u2227 Injective f \u2227 \u2200 a, p a \u2194 q (f a)\n#align one_one_reducible OneOneReducible\n\n-- mathport name: \u00abexpr \u2264\u2081 \u00bb\ninfixl:1000 \" \u2264\u2081 \" => OneOneReducible\n\ntheorem OneOneReducible.mk {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {f : \u03b1 \u2192 \u03b2} (q : \u03b2 \u2192 Prop)\n    (h : Computable f) (i : Injective f) : (fun a => q (f a)) \u2264\u2081 q :=\n  \u27e8f, h, i, fun a => Iff.rfl\u27e9\n#align one_one_reducible.mk OneOneReducible.mk\n\n@[refl]\ntheorem oneOneReducible_refl {\u03b1} [Primcodable \u03b1] (p : \u03b1 \u2192 Prop) : p \u2264\u2081 p :=\n  \u27e8id, Computable.id, injective_id, by simp\u27e9\n#align one_one_reducible_refl oneOneReducible_refl\n\n@[trans]\ntheorem OneOneReducible.trans {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} : p \u2264\u2081 q \u2192 q \u2264\u2081 r \u2192 p \u2264\u2081 r\n  | \u27e8f, c\u2081, i\u2081, h\u2081\u27e9, \u27e8g, c\u2082, i\u2082, h\u2082\u27e9 =>\n    \u27e8g \u2218 f, c\u2082.comp c\u2081, i\u2082.comp i\u2081, fun a =>\n      \u27e8fun h => by rwa [\u2190 h\u2082, \u2190 h\u2081], fun h => by rwa [h\u2081, h\u2082]\u27e9\u27e9\n#align one_one_reducible.trans OneOneReducible.trans\n\ntheorem OneOneReducible.to_many_one {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} : p \u2264\u2081 q \u2192 p \u2264\u2080 q\n  | \u27e8f, c, i, h\u27e9 => \u27e8f, c, h\u27e9\n#align one_one_reducible.to_many_one OneOneReducible.to_many_one\n\ntheorem OneOneReducible.of_equiv {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {e : \u03b1 \u2243 \u03b2} (q : \u03b2 \u2192 Prop)\n    (h : Computable e) : (q \u2218 e) \u2264\u2081 q :=\n  OneOneReducible.mk _ h e.Injective\n#align one_one_reducible.of_equiv OneOneReducible.of_equiv\n\ntheorem OneOneReducible.of_equiv_symm {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {e : \u03b1 \u2243 \u03b2}\n    (q : \u03b2 \u2192 Prop) (h : Computable e.symm) : q \u2264\u2081 (q \u2218 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 {\u03b1} [Primcodable \u03b1] : Reflexive (@OneOneReducible \u03b1 \u03b1 _ _) :=\n  oneOneReducible_refl\n#align reflexive_one_one_reducible reflexive_oneOneReducible\n\ntheorem transitive_oneOneReducible {\u03b1} [Primcodable \u03b1] : Transitive (@OneOneReducible \u03b1 \u03b1 _ _) :=\n  fun p q r => OneOneReducible.trans\n#align transitive_one_one_reducible transitive_oneOneReducible\n\nnamespace ComputablePred\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03c3]\n\nopen Computable\n\ntheorem computable_of_manyOneReducible {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (h\u2081 : p \u2264\u2080 q)\n    (h\u2082 : ComputablePred q) : ComputablePred p :=\n  by\n  rcases h\u2081 with \u27e8f, c, hf\u27e9\n  rw [show p = fun a => q (f a) from Set.ext hf]\n  rcases computable_iff.1 h\u2082 with \u27e8g, hg, rfl\u27e9\n  exact \u27e8by infer_instance, by simpa using hg.comp c\u27e9\n#align computable_pred.computable_of_many_one_reducible ComputablePred.computable_of_manyOneReducible\n\ntheorem computable_of_oneOneReducible {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (h : p \u2264\u2081 q) :\n    ComputablePred q \u2192 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 {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) :=\n  p \u2264\u2080 q \u2227 q \u2264\u2080 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 {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) :=\n  p \u2264\u2081 q \u2227 q \u2264\u2081 p\n#align one_one_equiv OneOneEquiv\n\n@[refl]\ntheorem manyOneEquiv_refl {\u03b1} [Primcodable \u03b1] (p : \u03b1 \u2192 Prop) : ManyOneEquiv p p :=\n  \u27e8manyOneReducible_refl _, manyOneReducible_refl _\u27e9\n#align many_one_equiv_refl manyOneEquiv_refl\n\n@[symm]\ntheorem ManyOneEquiv.symm {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} :\n    ManyOneEquiv p q \u2192 ManyOneEquiv q p :=\n  And.symm\n#align many_one_equiv.symm ManyOneEquiv.symm\n\n@[trans]\ntheorem ManyOneEquiv.trans {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} : ManyOneEquiv p q \u2192 ManyOneEquiv q r \u2192 ManyOneEquiv p r\n  | \u27e8pq, qp\u27e9, \u27e8qr, rq\u27e9 => \u27e8pq.trans qr, rq.trans qp\u27e9\n#align many_one_equiv.trans ManyOneEquiv.trans\n\ntheorem equivalence_of_manyOneEquiv {\u03b1} [Primcodable \u03b1] : Equivalence (@ManyOneEquiv \u03b1 \u03b1 _ _) :=\n  \u27e8manyOneEquiv_refl, fun x y => ManyOneEquiv.symm, fun x y z => ManyOneEquiv.trans\u27e9\n#align equivalence_of_many_one_equiv equivalence_of_manyOneEquiv\n\n@[refl]\ntheorem oneOneEquiv_refl {\u03b1} [Primcodable \u03b1] (p : \u03b1 \u2192 Prop) : OneOneEquiv p p :=\n  \u27e8oneOneReducible_refl _, oneOneReducible_refl _\u27e9\n#align one_one_equiv_refl oneOneEquiv_refl\n\n@[symm]\ntheorem OneOneEquiv.symm {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} :\n    OneOneEquiv p q \u2192 OneOneEquiv q p :=\n  And.symm\n#align one_one_equiv.symm OneOneEquiv.symm\n\n@[trans]\ntheorem OneOneEquiv.trans {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} : OneOneEquiv p q \u2192 OneOneEquiv q r \u2192 OneOneEquiv p r\n  | \u27e8pq, qp\u27e9, \u27e8qr, rq\u27e9 => \u27e8pq.trans qr, rq.trans qp\u27e9\n#align one_one_equiv.trans OneOneEquiv.trans\n\ntheorem equivalence_of_oneOneEquiv {\u03b1} [Primcodable \u03b1] : Equivalence (@OneOneEquiv \u03b1 \u03b1 _ _) :=\n  \u27e8oneOneEquiv_refl, fun x y => OneOneEquiv.symm, fun x y z => OneOneEquiv.trans\u27e9\n#align equivalence_of_one_one_equiv equivalence_of_oneOneEquiv\n\ntheorem OneOneEquiv.to_many_one {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} : OneOneEquiv p q \u2192 ManyOneEquiv p q\n  | \u27e8pq, qp\u27e9 => \u27e8pq.to_many_one, qp.to_many_one\u27e9\n#align one_one_equiv.to_many_one OneOneEquiv.to_many_one\n\n/-- a computable bijection -/\ndef Equiv.Computable {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] (e : \u03b1 \u2243 \u03b2) :=\n  Computable e \u2227 Computable e.symm\n#align equiv.computable Equiv.Computable\n\ntheorem Equiv.Computable.symm {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {e : \u03b1 \u2243 \u03b2} :\n    e.Computable \u2192 e.symm.Computable :=\n  And.symm\n#align equiv.computable.symm Equiv.Computable.symm\n\ntheorem Equiv.Computable.trans {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] {e\u2081 : \u03b1 \u2243 \u03b2}\n    {e\u2082 : \u03b2 \u2243 \u03b3} : e\u2081.Computable \u2192 e\u2082.Computable \u2192 (e\u2081.trans e\u2082).Computable\n  | \u27e8l\u2081, r\u2081\u27e9, \u27e8l\u2082, r\u2082\u27e9 => \u27e8l\u2082.comp l\u2081, r\u2081.comp r\u2082\u27e9\n#align equiv.computable.trans Equiv.Computable.trans\n\ntheorem Computable.eqv (\u03b1) [Denumerable \u03b1] : (Denumerable.eqv \u03b1).Computable :=\n  \u27e8Computable.encode, Computable.ofNat _\u27e9\n#align computable.eqv Computable.eqv\n\ntheorem Computable.equiv\u2082 (\u03b1 \u03b2) [Denumerable \u03b1] [Denumerable \u03b2] :\n    (Denumerable.equiv\u2082 \u03b1 \u03b2).Computable :=\n  (Computable.eqv _).trans (Computable.eqv _).symm\n#align computable.equiv\u2082 Computable.equiv\u2082\n\ntheorem OneOneEquiv.of_equiv {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {e : \u03b1 \u2243 \u03b2} (h : e.Computable)\n    {p} : OneOneEquiv (p \u2218 e) p :=\n  \u27e8OneOneReducible.of_equiv _ h.1, OneOneReducible.of_equiv_symm _ h.2\u27e9\n#align one_one_equiv.of_equiv OneOneEquiv.of_equiv\n\ntheorem ManyOneEquiv.of_equiv {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {e : \u03b1 \u2243 \u03b2} (h : e.Computable)\n    {p} : ManyOneEquiv (p \u2218 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 {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (h : ManyOneEquiv p q) : p \u2264\u2080 r \u2194 q \u2264\u2080 r :=\n  \u27e8h.2.trans, h.1.trans\u27e9\n#align many_one_equiv.le_congr_left ManyOneEquiv.le_congr_left\n\ntheorem ManyOneEquiv.le_congr_right {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (h : ManyOneEquiv q r) : p \u2264\u2080 q \u2194 p \u2264\u2080 r :=\n  \u27e8fun h' => h'.trans h.1, fun h' => h'.trans h.2\u27e9\n#align many_one_equiv.le_congr_right ManyOneEquiv.le_congr_right\n\ntheorem OneOneEquiv.le_congr_left {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (h : OneOneEquiv p q) : p \u2264\u2081 r \u2194 q \u2264\u2081 r :=\n  \u27e8h.2.trans, h.1.trans\u27e9\n#align one_one_equiv.le_congr_left OneOneEquiv.le_congr_left\n\ntheorem OneOneEquiv.le_congr_right {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (h : OneOneEquiv q r) : p \u2264\u2081 q \u2194 p \u2264\u2081 r :=\n  \u27e8fun h' => h'.trans h.1, fun h' => h'.trans h.2\u27e9\n#align one_one_equiv.le_congr_right OneOneEquiv.le_congr_right\n\ntheorem ManyOneEquiv.congr_left {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (h : ManyOneEquiv p q) :\n    ManyOneEquiv p r \u2194 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 {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (h : ManyOneEquiv q r) :\n    ManyOneEquiv p q \u2194 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 {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (h : OneOneEquiv p q) :\n    OneOneEquiv p r \u2194 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 {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} (h : OneOneEquiv q r) :\n    OneOneEquiv p q \u2194 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 {\u03b1} [Primcodable \u03b1] : (Ulower.equiv \u03b1).Computable :=\n  \u27e8Primrec.ulower_down.to_comp, Primrec.ulower_up.to_comp\u27e9\n#align ulower.down_computable Ulower.down_computable\n\ntheorem manyOneEquiv_up {\u03b1} [Primcodable \u03b1] {p : \u03b1 \u2192 Prop} : ManyOneEquiv (p \u2218 Ulower.up) p :=\n  ManyOneEquiv.of_equiv Ulower.down_computable.symm\n#align many_one_equiv_up manyOneEquiv_up\n\n-- mathport name: \u00abexpr \u2295' \u00bb\nlocal infixl:1001 \" \u2295' \" => Sum.elim\n\nopen Nat.Primrec\n\ntheorem OneOneReducible.disjoin_left {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} : p \u2264\u2081 p \u2295' q :=\n  \u27e8Sum.inl, Computable.sum_inl, fun x y => Sum.inl.inj_iff.1, fun a => Iff.rfl\u27e9\n#align one_one_reducible.disjoin_left OneOneReducible.disjoin_left\n\ntheorem OneOneReducible.disjoin_right {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} : q \u2264\u2081 p \u2295' q :=\n  \u27e8Sum.inr, Computable.sum_inr, fun x y => Sum.inr.inj_iff.1, fun a => Iff.rfl\u27e9\n#align one_one_reducible.disjoin_right OneOneReducible.disjoin_right\n\ntheorem disjoin_manyOneReducible {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3]\n    {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} : p \u2264\u2080 r \u2192 q \u2264\u2080 r \u2192 p \u2295' q \u2264\u2080 r\n  | \u27e8f, c\u2081, h\u2081\u27e9, \u27e8g, c\u2082, h\u2082\u27e9 =>\n    \u27e8Sum.elim f g,\n      Computable.id.sum_cases (c\u2081.comp Computable.snd).to\u2082 (c\u2082.comp Computable.snd).to\u2082, fun x => by\n      cases x <;> [apply h\u2081, apply h\u2082]\u27e9\n#align disjoin_many_one_reducible disjoin_manyOneReducible\n\ntheorem disjoin_le {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} {r : \u03b3 \u2192 Prop} : p \u2295' q \u2264\u2080 r \u2194 p \u2264\u2080 r \u2227 q \u2264\u2080 r :=\n  \u27e8fun h =>\n    \u27e8OneOneReducible.disjoin_left.to_many_one.trans h,\n      OneOneReducible.disjoin_right.to_many_one.trans h\u27e9,\n    fun \u27e8h\u2081, h\u2082\u27e9 => disjoin_manyOneReducible h\u2081 h\u2082\u27e9\n#align disjoin_le disjoin_le\n\nvariable {\u03b1 : Type u} [Primcodable \u03b1] [Inhabited \u03b1]\n\nvariable {\u03b2 : Type v} [Primcodable \u03b2] [Inhabited \u03b2]\n\nvariable {\u03b3 : Type w} [Primcodable \u03b3] [Inhabited \u03b3]\n\n/-- Computable and injective mapping of predicates to sets of natural numbers.\n-/\ndef toNat (p : Set \u03b1) : Set \u2115 :=\n  { n | p ((Encodable.decode \u03b1 n).getD default) }\n#align to_nat toNat\n\n@[simp]\ntheorem toNat_manyOneReducible {p : Set \u03b1} : toNat p \u2264\u2080 p :=\n  \u27e8fun n => (Encodable.decode \u03b1 n).getD default,\n    Computable.option_getD Computable.decode (Computable.const _), fun _ => Iff.rfl\u27e9\n#align to_nat_many_one_reducible toNat_manyOneReducible\n\n@[simp]\ntheorem manyOneReducible_toNat {p : Set \u03b1} : p \u2264\u2080 toNat p :=\n  \u27e8Encodable.encode, Computable.encode, by simp [toNat, setOf]\u27e9\n#align many_one_reducible_to_nat manyOneReducible_toNat\n\n@[simp]\ntheorem manyOneReducible_toNat_toNat {p : Set \u03b1} {q : Set \u03b2} : toNat p \u2264\u2080 toNat q \u2194 p \u2264\u2080 q :=\n  \u27e8fun h => manyOneReducible_toNat.trans (h.trans toNat_manyOneReducible), fun h =>\n    toNat_manyOneReducible.trans (h.trans manyOneReducible_toNat)\u27e9\n#align many_one_reducible_to_nat_to_nat manyOneReducible_toNat_toNat\n\n@[simp]\ntheorem toNat_manyOneEquiv {p : Set \u03b1} : ManyOneEquiv (toNat p) p := by simp [ManyOneEquiv]\n#align to_nat_many_one_equiv toNat_manyOneEquiv\n\n@[simp]\ntheorem manyOneEquiv_toNat (p : Set \u03b1) (q : Set \u03b2) :\n    ManyOneEquiv (toNat p) (toNat q) \u2194 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 (\u27e8ManyOneEquiv, equivalence_of_manyOneEquiv\u27e9 : Setoid (Set \u2115))\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 : \u03b1 \u2192 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 \u2192 Prop} (d : ManyOneDegree)\n    (h : \u2200 p : Set \u2115, 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 {\u03c6} (d : ManyOneDegree) (f : Set \u2115 \u2192 \u03c6)\n    (h : \u2200 p q, ManyOneEquiv p q \u2192 f p = f q) : \u03c6 :=\n  Quotient.liftOn' d f h\n#align many_one_degree.lift_on ManyOneDegree.liftOn\n\n@[simp]\nprotected theorem liftOn_eq {\u03c6} (p : Set \u2115) (f : Set \u2115 \u2192 \u03c6)\n    (h : \u2200 p q, ManyOneEquiv p q \u2192 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\u2082 {\u03c6} (d\u2081 d\u2082 : ManyOneDegree) (f : Set \u2115 \u2192 Set \u2115 \u2192 \u03c6)\n    (h : \u2200 p\u2081 p\u2082 q\u2081 q\u2082, ManyOneEquiv p\u2081 p\u2082 \u2192 ManyOneEquiv q\u2081 q\u2082 \u2192 f p\u2081 q\u2081 = f p\u2082 q\u2082) : \u03c6 :=\n  d\u2081.liftOn (fun p => d\u2082.liftOn (f p) fun q\u2081 q\u2082 hq => h _ _ _ _ (by rfl) hq)\n    (by\n      intro p\u2081 p\u2082 hp\n      induction d\u2082 using ManyOneDegree.ind_on\n      apply h\n      assumption\n      rfl)\n#align many_one_degree.lift_on\u2082 ManyOneDegree.liftOn\u2082\n\n@[simp]\nprotected theorem liftOn\u2082_eq {\u03c6} (p q : Set \u2115) (f : Set \u2115 \u2192 Set \u2115 \u2192 \u03c6)\n    (h : \u2200 p\u2081 p\u2082 q\u2081 q\u2082, ManyOneEquiv p\u2081 p\u2082 \u2192 ManyOneEquiv q\u2081 q\u2082 \u2192 f p\u2081 q\u2081 = f p\u2082 q\u2082) :\n    (of p).liftOn\u2082 (of q) f h = f p q :=\n  rfl\n#align many_one_degree.lift_on\u2082_eq ManyOneDegree.liftOn\u2082_eq\n\n@[simp]\ntheorem of_eq_of {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} : of p = of q \u2194 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  \u27e8of (\u2205 : Set \u2115)\u27e9\n\n/-- For many-one degrees `d\u2081` and `d\u2082`, `d\u2081 \u2264 d\u2082` if the sets in `d\u2081` are many-one reducible to the\nsets in `d\u2082`.\n-/\ninstance : LE ManyOneDegree :=\n  \u27e8fun d\u2081 d\u2082 =>\n    ManyOneDegree.liftOn\u2082 d\u2081 d\u2082 (\u00b7 \u2264\u2080 \u00b7) fun p\u2081 p\u2082 q\u2081 q\u2082 hp hq =>\n      propext (hp.le_congr_left.trans hq.le_congr_right)\u27e9\n\n@[simp]\ntheorem of_le_of {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} : of p \u2264 of q \u2194 p \u2264\u2080 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 \u2264 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\u2081 d\u2082 : ManyOneDegree} : d\u2081 \u2264 d\u2082 \u2192 d\u2082 \u2264 d\u2081 \u2192 d\u2081 = d\u2082 :=\n  by\n  induction d\u2081 using ManyOneDegree.ind_on\n  induction d\u2082 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\u2081 d\u2082 d\u2083 : ManyOneDegree} : d\u2081 \u2264 d\u2082 \u2192 d\u2082 \u2264 d\u2083 \u2192 d\u2081 \u2264 d\u2083 :=\n  by\n  induction d\u2081 using ManyOneDegree.ind_on\n  induction d\u2082 using ManyOneDegree.ind_on\n  induction d\u2083 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 := (\u00b7 \u2264 \u00b7)\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  \u27e8fun d\u2081 d\u2082 =>\n    d\u2081.liftOn\u2082 d\u2082 (fun a b => of (a \u2295' b))\n      (by\n        rintro a b c d \u27e8hl\u2081, hr\u2081\u27e9 \u27e8hl\u2082, hr\u2082\u27e9\n        rw [of_eq_of]\n        exact\n          \u27e8disjoin_manyOneReducible (hl\u2081.trans one_one_reducible.disjoin_left.to_many_one)\n              (hl\u2082.trans one_one_reducible.disjoin_right.to_many_one),\n            disjoin_manyOneReducible (hr\u2081.trans one_one_reducible.disjoin_left.to_many_one)\n              (hr\u2082.trans one_one_reducible.disjoin_right.to_many_one)\u27e9)\u27e9\n\n@[simp]\ntheorem add_of (p : Set \u03b1) (q : Set \u03b2) : of (p \u2295' q) = of p + of q :=\n  of_eq_of.mpr\n    \u27e8disjoin_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)\u27e9\n#align many_one_degree.add_of ManyOneDegree.add_of\n\n@[simp]\nprotected theorem add_le {d\u2081 d\u2082 d\u2083 : ManyOneDegree} : d\u2081 + d\u2082 \u2264 d\u2083 \u2194 d\u2081 \u2264 d\u2083 \u2227 d\u2082 \u2264 d\u2083 :=\n  by\n  induction d\u2081 using ManyOneDegree.ind_on\n  induction d\u2082 using ManyOneDegree.ind_on\n  induction d\u2083 using ManyOneDegree.ind_on\n  simpa only [\u2190 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\u2081 d\u2082 : ManyOneDegree) : d\u2081 \u2264 d\u2081 + d\u2082 :=\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\u2081 d\u2082 : ManyOneDegree) : d\u2082 \u2264 d\u2081 + d\u2082 :=\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 := (\u00b7 + \u00b7)\n    le_sup_left := ManyOneDegree.le_add_left\n    le_sup_right := ManyOneDegree.le_add_right\n    sup_le := fun a b c h\u2081 h\u2082 => ManyOneDegree.add_le.2 \u27e8h\u2081, h\u2082\u27e9 }\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 : \u211d\u22650} (w : 0 < c) (h : c \u2264 b) : a / b \u2264 a / c :=\nbegin\n  rcases a with \u27e8a, a_pos\u27e9,\n  rcases b with \u27e8b, b_pos\u27e9,\n  rcases c with \u27e8c, c_pos\u27e9,\n  change a / b \u2264 a / c,\n  change 0 < c at w,\n  change c \u2264 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 {\u03b1 \u03b2: Type*} (F : \u03b1 \u2192 \u03b2 \u2192 \u211d\u22650)\n  (h_rows : \u2200 n, summable (\u03bb k, F n k)) (h_cols : \u2200 k, summable (\u03bb n, F n k))\n  (h_col_row : summable (\u03bb k, \u2211' n, F n k)) : summable (\u03bb n, \u2211' k, F n k) :=\nbegin\n  cases h_col_row with a ha,\n  use a,\n  rw \u2190 ennreal.has_sum_coe,\n  convert_to has_sum (\u03bb n, \u2211' k, (F n k : \u211d\u22650\u221e)) a,\n  { ext1 n,\n    exact ennreal.coe_tsum (h_rows n) },\n  { rw ennreal.has_sum_comm,\n    rw \u2190 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 {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192 \u211d\u22650} {i : \u03b2 \u2192 \u03b1}\n  (hi : function.injective i) (hi' : \u2200 a, a \u2209 set.range i \u2192 f a = 0) (hfi : summable (f \u2218 i)) :\n  summable f :=\nbegin\n  rw \u2190 summable_coe at hfi \u22a2,\n  let e : \u03b2 \u2243 ({x : \u03b1 | x \u2208 set.range i} : set \u03b1) :=\n  { to_fun := \u03bb b, \u27e8i b, b, rfl\u27e9,\n  inv_fun := \u03bb x, x.2.some,\n  left_inv := begin intro b, simp, apply hi, exact Exists.some_spec (\u27e8b, rfl\u27e9 : \u2203 y, i y = i b) end,\n  right_inv := begin rintro \u27e8x, b, rfl\u27e9, simp, exact Exists.some_spec (\u27e8b, rfl\u27e9 : \u2203 y, i y = i b) end },\n  have this2 : summable ((\u03bb (x : {x : \u03b1 // x \u2208 set.range i}), (f x.1 : \u211d)) \u2218 \u21d1e : \u03b2 \u2192 \u211d),\n  { convert (summable_congr _).1 hfi,\n    intro b, refl },\n  rw e.summable_iff at this2,\n  change summable ((\u03bb a, (f a : \u211d)) \u2218 (coe : {x // x \u2208 set.range i} \u2192 \u03b1)) at this2,\n  rw \u2190 this2.summable_compl_iff,\n  convert summable_zero,\n  ext1 \u27e8x, hx\u27e9,\n  simp [hi' x hx],\nend\n\nlemma nnreal.summable_subtype {\u03b2 : Type*} {f : \u03b2 \u2192 \u211d\u22650} (hf : summable f)\n  (s : set \u03b2) :  summable (f \u2218 (coe : s \u2192 \u03b2)) :=\nbegin\n  rw \u2190 summable_coe at \u22a2 hf,\n  exact hf.subtype s,\nend\n\nlemma nnreal.mul_le_mul_right {a b : \u211d\u22650} (h : a \u2264 b) (c : \u211d\u22650) : a * c \u2264 b * c :=\nbegin\n  suffices : (a : \u211d) * c \u2264 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 : \u211d\u22650} (h : a \u2264 b) (c : \u211d\u22650) : c * a \u2264 c * b :=\nby simpa [mul_comm] using nnreal.mul_le_mul_right h c\n\nlemma nnreal.rpow_sum_le_sum_rpow\n  {\u03b9 : Type*} (s : finset \u03b9) {p : \u211d} (a : \u03b9 \u2192 \u211d\u22650) (hp_pos : 0 < p) (hp1 : p \u2264 1) :\n  (\u2211 i in s, a i) ^ p \u2264 \u2211 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 : \u211d\u22650} {m : \u211d} (ha : 1 \u2264 a) (hm : 1 \u2264 m) : a \u2264 a ^ m :=\nbegin\n  suffices : a ^ (1 : \u211d) \u2264 a ^ m,\n    simpa,\n  exact rpow_le_rpow_of_exponent_le ha hm,\nend\n\n\nlemma nnreal.le_self_rpow' {a : \u211d\u22650} {m : \u211d} (ha : a \u2264 1) (hm : m \u2264 1) : a \u2264 a ^ m :=\nbegin\n  obtain (rfl|\u27e8u, rfl\u27e9) := group_with_zero.eq_zero_or_unit a, apply zero_le, -- a=0 special case\n  suffices : (u : \u211d\u22650) ^ (1 : \u211d) \u2264 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 : \u211d} (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 : \u211d} {s : \u211d} (hr : 0 < r) (hs : 0 < s) (hs' : s \u2260 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 \u2190 eq_div_iff,\n  apply mt (\u03bb 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 : \u211d\u22650} : a / b\u207b\u00b9 = 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 \u2192 \u211d\u22650} (hle : \u2200 x, f x \u2264 g x)\n  (hsummable : summable g) : \u2211' x, f x \u2264 \u2211' x, g x :=\ntsum_le_tsum hle (summable_of_le hle hsummable) hsummable\n\nlemma nnreal.summable_iff_summable_nnnorm {X : Type*} {f : X \u2192 \u211d} :\n  summable f \u2194 summable (\u03bb x, \u2225f x\u2225\u208a) :=\nbegin\n  rw \u2190 summable_norm_iff,\n  rw \u2190 summable_coe,\n  congr',\nend\n\nlemma nnreal.le_zero_iff {a : \u211d\u22650} : a \u2264 0 \u2194 a = 0 := le_bot_iff\n\nlemma nnreal.sub_pos {a b : \u211d\u22650} : 0 < a - b \u2194 b < a :=\nbegin\n  rw \u2190 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 : \u211d\u22650} (ha : a \u2260 0) (hab : a\u207b\u00b9 < b) : b\u207b\u00b9 < a :=\nbegin\n  suffices : (b : \u211d)\u207b\u00b9 < 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' : \u2200 r, algebra_map R A r \u2208 carrier)\n(zero_mem' := (algebra_map R A).map_zero \u25b8 algebra_map_mem' 0)\n(one_mem' := (algebra_map R A).map_one \u25b8 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\u27e8subalgebra.carrier, \u03bb p q h, by cases p; cases q; congr'\u27e9\n\n@[simp]\nlemma mem_carrier {s : subalgebra R A} {x : A} : x \u2208 s.carrier \u2194 x \u2208 s := iff.rfl\n\n@[ext] theorem ext {S T : subalgebra R A} (h : \u2200 x : A, x \u2208 S \u2194 x \u2208 T) : S = T := set_like.ext h\n\n@[simp] lemma mem_to_subsemiring {S : subalgebra R A} {x} : x \u2208 S.to_subsemiring \u2194 x \u2208 S := iff.rfl\n\n@[simp] lemma coe_to_subsemiring (S : subalgebra R A) : (\u2191S.to_subsemiring : set A) = S := rfl\n\ntheorem to_subsemiring_injective :\n  function.injective (to_subsemiring : subalgebra R A \u2192 subsemiring A) :=\n\u03bb S T h, ext $ \u03bb x, by rw [\u2190 mem_to_subsemiring, \u2190 mem_to_subsemiring, h]\n\ntheorem to_subsemiring_inj {S U : subalgebra R A} : S.to_subsemiring = U.to_subsemiring \u2194 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 = \u2191S) : subalgebra R A :=\n{ carrier := s,\n  add_mem' := hs.symm \u25b8 S.add_mem',\n  mul_mem' := hs.symm \u25b8 S.mul_mem',\n  algebra_map_mem' := hs.symm \u25b8 S.algebra_map_mem' }\n\n@[simp] lemma coe_copy (S : subalgebra R A) (s : set A) (hs : s = \u2191S) :\n  (S.copy s hs : set A) = s := rfl\n\nlemma copy_eq (S : subalgebra R A) (s : set A) (hs : s = \u2191S) : 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 \u2208 S :=\nS.algebra_map_mem' r\n\ntheorem srange_le : (algebra_map R A).srange \u2264 S.to_subsemiring :=\n\u03bb x \u27e8r, hr\u27e9, hr \u25b8 S.algebra_map_mem r\n\ntheorem range_subset : set.range (algebra_map R A) \u2286 S :=\n\u03bb x \u27e8r, hr\u27e9, hr \u25b8 S.algebra_map_mem r\n\ntheorem range_le : set.range (algebra_map R A) \u2264 S :=\nS.range_subset\n\ntheorem one_mem : (1 : A) \u2208 S :=\nS.to_subsemiring.one_mem\n\ntheorem mul_mem {x y : A} (hx : x \u2208 S) (hy : y \u2208 S) : x * y \u2208 S :=\nS.to_subsemiring.mul_mem hx hy\n\ntheorem smul_mem {x : A} (hx : x \u2208 S) (r : R) : r \u2022 x \u2208 S :=\n(algebra.smul_def r x).symm \u25b8 S.mul_mem (S.algebra_map_mem r) hx\n\ntheorem pow_mem {x : A} (hx : x \u2208 S) (n : \u2115) : x ^ n \u2208 S :=\nS.to_subsemiring.pow_mem hx n\n\ntheorem zero_mem : (0 : A) \u2208 S :=\nS.to_subsemiring.zero_mem\n\ntheorem add_mem {x y : A} (hx : x \u2208 S) (hy : y \u2208 S) : x + y \u2208 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 \u2208 S) : -x \u2208 S :=\nneg_one_smul R x \u25b8 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 \u2208 S) (hy : y \u2208 S) : x - y \u2208 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 \u2208 S) (n : \u2115) : n \u2022 x \u2208 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 \u2208 S) : \u2200 (n : \u2124), n \u2022 x \u2208 S\n| (n : \u2115) := 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 : \u2115) : (n : A) \u2208 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 : \u2124) : (n : A) \u2208 S :=\nint.cases_on n (\u03bb i, S.coe_nat_mem i) (\u03bb i, S.neg_mem $ S.coe_nat_mem $ i + 1)\n\ntheorem list_prod_mem {L : list A} (h : \u2200 x \u2208 L, x \u2208 S) : L.prod \u2208 S :=\nS.to_subsemiring.list_prod_mem h\n\ntheorem list_sum_mem {L : list A} (h : \u2200 x \u2208 L, x \u2208 S) : L.sum \u2208 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 : \u2200 x \u2208 m, x \u2208 S) : m.prod \u2208 S :=\nS.to_subsemiring.multiset_prod_mem m h\n\ntheorem multiset_sum_mem {m : multiset A} (h : \u2200 x \u2208 m, x \u2208 S) : m.sum \u2208 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) {\u03b9 : Type w} {t : finset \u03b9} {f : \u03b9 \u2192 A}\n  (h : \u2200 x \u2208 t, f x \u2208 S) : \u220f x in t, f x \u2208 S :=\nS.to_subsemiring.prod_mem h\n\ntheorem sum_mem {\u03b9 : Type w} {t : finset \u03b9} {f : \u03b9 \u2192 A}\n  (h : \u2200 x \u2208 t, f x \u2208 S) : \u2211 x in t, f x \u2208 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' := \u03bb _, 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 \u2208 S.to_subring \u2194 x \u2208 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) : (\u2191S.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 \u2192 subring A) :=\n\u03bb S T h, ext $ \u03bb x, by rw [\u2190 mem_to_subring, \u2190 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 \u2194 S = U :=\nto_subring_injective.eq_iff\n\ninstance : inhabited S := \u27e8(0 : S.to_subsemiring)\u27e9\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' := \u03bb x y hx hy, (\u27e8x, hx\u27e9 + \u27e8y, hy\u27e9 : S).2,\n  smul_mem' := \u03bb c x hx, (algebra.smul_def c x).symm \u25b8\n    (\u27e8algebra_map R A c, S.range_le \u27e8c, rfl\u27e9\u27e9 * \u27e8x, hx\u27e9:S).2 }\n\n@[simp] lemma mem_to_submodule {x} : x \u2208 S.to_submodule \u2194 x \u2208 S := iff.rfl\n\n@[simp] lemma coe_to_submodule (S : subalgebra R A) : (\u2191S.to_submodule : set A) = S := rfl\n\ntheorem to_submodule_injective :\n  function.injective (to_submodule : subalgebra R A \u2192 submodule R A) :=\n\u03bb S T h, ext $ \u03bb x, by rw [\u2190 mem_to_submodule, \u2190 mem_to_submodule, h]\n\ntheorem to_submodule_inj {S U : subalgebra R A} : S.to_submodule = U.to_submodule \u2194 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' := \u03bb c x, subtype.eq $ algebra.commutes _ _,\n  smul_def' := \u03bb c x, subtype.eq $ algebra.smul_def _ _,\n  .. (algebra_map R' A).cod_srestrict S.to_subsemiring $ \u03bb x, begin\n    rw [algebra.algebra_map_eq_smul_one, \u2190smul_one_smul R x (1 : A),\n      \u2190algebra.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\u27e8\u03bb c x h,\n  have c = 0 \u2228 (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\u27e9\n\n@[simp, norm_cast] lemma coe_add (x y : S) : (\u2191(x + y) : A) = \u2191x + \u2191y := rfl\n@[simp, norm_cast] lemma coe_mul (x y : S) : (\u2191(x * y) : A) = \u2191x * \u2191y := 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) : (\u2191(-x) : A) = -\u2191x := 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) : (\u2191(x - y) : A) = \u2191x - \u2191y := 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) : (\u2191(r \u2022 x) : A) = r \u2022 \u2191x := 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  \u2191(algebra_map R' S r) = algebra_map R' A r := rfl\n\n@[simp, norm_cast] lemma coe_pow (x : S) (n : \u2115) : (\u2191(x^n) : A) = (\u2191x)^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 \u2194 x = 0 :=\n(subtype.ext_iff.symm : (x : A) = (0 : S) \u2194 x = 0)\n@[simp, norm_cast] lemma coe_eq_one {x : S} : (x : A) = 1 \u2194 x = 1 :=\n(subtype.ext_iff.symm : (x : A) = (1 : S) \u2194 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 \u2192\u2090[R] A :=\nby refine_struct { to_fun := (coe : S \u2192 A) }; intros; refl\n\n@[simp] lemma coe_val : (S.val : S \u2192 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 \u2192+* 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 \u2192+* 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 \u2190 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 \u2243\u2097[R] S :=\nlinear_equiv.of_eq _ _ rfl\n\n/-- Transport a subalgebra via an algebra homomorphism. -/\ndef map (S : subalgebra R A) (f : A \u2192\u2090[R] B) : subalgebra R B :=\n{ algebra_map_mem' := \u03bb r, f.commutes r \u25b8 set.mem_image_of_mem _ (S.algebra_map_mem r),\n  .. S.to_subsemiring.map (f : A \u2192+* B) }\n\nlemma map_mono {S\u2081 S\u2082 : subalgebra R A} {f : A \u2192\u2090[R] B} :\n  S\u2081 \u2264 S\u2082 \u2192 S\u2081.map f \u2264 S\u2082.map f :=\nset.image_subset f\n\nlemma map_injective {S\u2081 S\u2082 : subalgebra R A} (f : A \u2192\u2090[R] B)\n  (hf : function.injective f) (ih : S\u2081.map f = S\u2082.map f) : S\u2081 = S\u2082 :=\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 \u2192\u2090[R] C) (f : A \u2192\u2090[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 \u2192\u2090[R] B} {y : B} :\n  y \u2208 map S f \u2194 \u2203 x \u2208 S, f x = y :=\nsubsemiring.mem_map\n\nlemma map_to_submodule {S : subalgebra R A} {f : A \u2192\u2090[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 \u2192\u2090[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 \u2192\u2090[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 \u2192\u2090[R] B) : subalgebra R A :=\n{ algebra_map_mem' := \u03bb r, show f (algebra_map R A r) \u2208 S,\n    from (f.commutes r).symm \u25b8 S.algebra_map_mem r,\n  .. S.to_subsemiring.comap (f : A \u2192+* B) }\n\ntheorem map_le {S : subalgebra R A} {f : A \u2192\u2090[R] B} {U : subalgebra R B} :\n  map S f \u2264 U \u2194 S \u2264 comap' U f :=\nset.image_subset_iff\n\nlemma gc_map_comap (f : A \u2192\u2090[R] B) : galois_connection (\u03bb S, map S f) (\u03bb S, comap' S f) :=\n\u03bb S U, map_le\n\n@[simp] lemma mem_comap (S : subalgebra R B) (f : A \u2192\u2090[R] B) (x : A) :\n  x \u2208 S.comap' f \u2194 f x \u2208 S :=\niff.rfl\n\n@[simp, norm_cast] lemma coe_comap (S : subalgebra R B) (f : A \u2192\u2090[R] B) :\n  (S.comap' f : set A) = f \u207b\u00b9' (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 (\u03c6 : A \u2192\u2090[R] B)\n\n/-- Range of an `alg_hom` as a subalgebra. -/\nprotected def range (\u03c6 : A \u2192\u2090[R] B) : subalgebra R B :=\n{ algebra_map_mem' := \u03bb r, \u27e8algebra_map R A r, \u03c6.commutes r\u27e9,\n  .. \u03c6.to_ring_hom.srange }\n\n@[simp] lemma mem_range (\u03c6 : A \u2192\u2090[R] B) {y : B} :\n  y \u2208 \u03c6.range \u2194 \u2203 x, \u03c6 x = y := ring_hom.mem_srange\n\ntheorem mem_range_self (\u03c6 : A \u2192\u2090[R] B) (x : A) : \u03c6 x \u2208 \u03c6.range := \u03c6.mem_range.2 \u27e8x, rfl\u27e9\n\n@[simp] lemma coe_range (\u03c6 : A \u2192\u2090[R] B) : (\u03c6.range : set B) = set.range \u03c6 :=\nby { ext, rw [set_like.mem_coe, mem_range], refl }\n\ntheorem range_comp (f : A \u2192\u2090[R] B) (g : B \u2192\u2090[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 \u2192\u2090[R] B) (g : B \u2192\u2090[R] C) : (g.comp f).range \u2264 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 \u2192\u2090[R] B) (S : subalgebra R B) (hf : \u2200 x, f x \u2208 S) : A \u2192\u2090[R] S :=\n{ commutes' := \u03bb r, subtype.eq $ f.commutes r,\n  .. ring_hom.cod_srestrict (f : A \u2192+* B) S.to_subsemiring hf }\n\n@[simp] lemma val_comp_cod_restrict (f : A \u2192\u2090[R] B) (S : subalgebra R B) (hf : \u2200 x, f x \u2208 S) :\n  S.val.comp (f.cod_restrict S hf) = f :=\nalg_hom.ext $ \u03bb _, rfl\n\n@[simp] lemma coe_cod_restrict (f : A \u2192\u2090[R] B) (S : subalgebra R B) (hf : \u2200 x, f x \u2208 S) (x : A) :\n  \u2191(f.cod_restrict S hf x) = f x := rfl\n\ntheorem injective_cod_restrict (f : A \u2192\u2090[R] B) (S : subalgebra R B) (hf : \u2200 x, f x \u2208 S) :\n  function.injective (f.cod_restrict S hf) \u2194 function.injective f :=\n\u27e8\u03bb H x y hxy, H $ subtype.eq hxy, \u03bb H x y hxy, H (congr_arg subtype.val hxy : _)\u27e9\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 \u2192\u2090[R] B) : A \u2192\u2090[R] f.range :=\nf.cod_restrict f.range f.mem_range_self\n\n/-- The equalizer of two R-algebra homomorphisms -/\ndef equalizer (\u03d5 \u03c8 : A \u2192\u2090[R] B) : subalgebra R A :=\n{ carrier := {a | \u03d5 a = \u03c8 a},\n  add_mem' := \u03bb x y (hx : \u03d5 x = \u03c8 x) (hy : \u03d5 y = \u03c8 y),\n    by rw [set.mem_set_of_eq, \u03d5.map_add, \u03c8.map_add, hx, hy],\n  mul_mem' := \u03bb x y (hx : \u03d5 x = \u03c8 x) (hy : \u03d5 y = \u03c8 y),\n    by rw [set.mem_set_of_eq, \u03d5.map_mul, \u03c8.map_mul, hx, hy],\n  algebra_map_mem' := \u03bb x,\n    by rw [set.mem_set_of_eq, alg_hom.commutes, alg_hom.commutes] }\n\n@[simp] lemma mem_equalizer (\u03d5 \u03c8 : A \u2192\u2090[R] B) (x : A) :\n  x \u2208 \u03d5.equalizer \u03c8 \u2194 \u03d5 x = \u03c8 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] (\u03c6 : A \u2192\u2090[R] B) : fintype \u03c6.range :=\nset.fintype_range \u03c6\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 \u2192 A} {f : A \u2192\u2090[R] B} (h : function.left_inverse g f) :\n  A \u2243\u2090[R] f.range :=\n{ to_fun := f.range_restrict,\n  inv_fun := g \u2218 f.range.val,\n  left_inv := h,\n  right_inv := \u03bb x, subtype.ext $\n    let \u27e8x', hx'\u27e9 := f.mem_range.mp x.prop in\n    show f (g x) = x, by rw [\u2190hx', h x'],\n  ..f.range_restrict }\n\n@[simp] lemma of_left_inverse_apply\n  {g : B \u2192 A} {f : A \u2192\u2090[R] B} (h : function.left_inverse g f) (x : A) :\n  \u2191(of_left_inverse h x) = f x := rfl\n\n@[simp] lemma of_left_inverse_symm_apply\n  {g : B \u2192 A} {f : A \u2192\u2090[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 \u2192\u2090[R] B) (hf : function.injective f) :\n  A \u2243\u2090[R] f.range :=\nof_left_inverse (classical.some_spec hf.has_left_inverse)\n\n@[simp] lemma of_injective_apply (f : A \u2192\u2090[R] B) (hf : function.injective f) (x : A) :\n  \u2191(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 \u2192\u2090[R] F) : E \u2243\u2090[R] f.range :=\nof_injective f f.to_ring_hom.injective\n\n/-- Given an equivalence `e : A \u2243\u2090[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 \u2243\u2090[R] B) (S : subalgebra R A) :\n  S \u2243\u2090[R] (S.map e.to_alg_hom) :=\n{ commutes' := \u03bb 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' := \u03bb r, subsemiring.subset_closure $ or.inl \u27e8r, rfl\u27e9,\n  .. subsemiring.closure (set.range (algebra_map R A) \u222a s) }\nvariables {R}\n\nprotected lemma gc : galois_connection (adjoin R : set A \u2192 subalgebra R A) coe :=\n\u03bb s S, \u27e8\u03bb H, le_trans (le_trans (set.subset_union_right _ _) subsemiring.subset_closure) H,\n\u03bb H, show subsemiring.closure (set.range (algebra_map R A) \u222a s) \u2264 S.to_subsemiring,\n     from subsemiring.closure_le.2 $ set.union_subset S.range_subset H\u27e9\n\n/-- Galois insertion between `adjoin` and `coe`. -/\nprotected def gi : galois_insertion (adjoin R : set A \u2192 subalgebra R A) coe :=\n{ choice := \u03bb s hs, (adjoin R s).copy s $ le_antisymm (algebra.gc.le_u_l s) hs,\n  gc := algebra.gc,\n  le_l_u := \u03bb S, (algebra.gc (S : set A) (adjoin R S)).1 $ le_rfl,\n  choice_eq := \u03bb _ _, subalgebra.copy_eq _ _ _ }\n\ninstance : complete_lattice (subalgebra R A) :=\ngalois_insertion.lift_complete_lattice algebra.gi\n\n@[simp]\nlemma coe_top : (\u2191(\u22a4 : subalgebra R A) : set A) = set.univ := rfl\n\n@[simp] lemma mem_top {x : A} : x \u2208 (\u22a4 : subalgebra R A) :=\nset.mem_univ x\n\n@[simp] lemma top_to_submodule : (\u22a4 : subalgebra R A).to_submodule = \u22a4 := rfl\n\n@[simp] lemma top_to_subsemiring : (\u22a4 : subalgebra R A).to_subsemiring = \u22a4 := rfl\n\n@[simp] lemma top_to_subring {R A : Type*} [comm_ring R] [ring A] [algebra R A] :\n  (\u22a4 : subalgebra R A).to_subring = \u22a4 := rfl\n\n@[simp] lemma to_submodule_eq_top {S : subalgebra R A} : S.to_submodule = \u22a4 \u2194 S = \u22a4 :=\nsubalgebra.to_submodule_injective.eq_iff' top_to_submodule\n\n@[simp] lemma to_subsemiring_eq_top {S : subalgebra R A} : S.to_subsemiring = \u22a4 \u2194 S = \u22a4 :=\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 = \u22a4 \u2194 S = \u22a4 :=\nsubalgebra.to_subring_injective.eq_iff' top_to_subring\n\nlemma mem_sup_left {S T : subalgebra R A} : \u2200 {x : A}, x \u2208 S \u2192 x \u2208 S \u2294 T :=\nshow S \u2264 S \u2294 T, from le_sup_left\n\nlemma mem_sup_right {S T : subalgebra R A} : \u2200 {x : A}, x \u2208 T \u2192 x \u2208 S \u2294 T :=\nshow T \u2264 S \u2294 T, from le_sup_right\n\nlemma mul_mem_sup {S T : subalgebra R A} {x y : A} (hx : x \u2208 S) (hy : y \u2208 T) :\n  x * y \u2208 S \u2294 T :=\n(S \u2294 T).mul_mem (mem_sup_left hx) (mem_sup_right hy)\n\nlemma map_sup (f : A \u2192\u2090[R] B) (S T : subalgebra R A) : (S \u2294 T).map f = S.map f \u2294 T.map f :=\n(subalgebra.gc_map_comap f).l_sup\n\n@[simp, norm_cast]\nlemma coe_inf (S T : subalgebra R A) : (\u2191(S \u2293 T) : set A) = S \u2229 T := rfl\n\n@[simp]\nlemma mem_inf {S T : subalgebra R A} {x : A} : x \u2208 S \u2293 T \u2194 x \u2208 S \u2227 x \u2208 T := iff.rfl\n\n@[simp] lemma inf_to_submodule (S T : subalgebra R A) :\n  (S \u2293 T).to_submodule = S.to_submodule \u2293 T.to_submodule := rfl\n\n@[simp] lemma inf_to_subsemiring (S T : subalgebra R A) :\n  (S \u2293 T).to_subsemiring = S.to_subsemiring \u2293 T.to_subsemiring := rfl\n\n@[simp, norm_cast]\nlemma coe_Inf (S : set (subalgebra R A)) : (\u2191(Inf S) : set A) = \u22c2 s \u2208 S, \u2191s := Inf_image\n\nlemma mem_Inf {S : set (subalgebra R A)} {x : A} : x \u2208 Inf S \u2194 \u2200 p \u2208 S, x \u2208 p :=\nby simp only [\u2190 set_like.mem_coe, coe_Inf, set.mem_Inter\u2082]\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 {\u03b9 : Sort*} {S : \u03b9 \u2192 subalgebra R A} : (\u2191(\u2a05 i, S i) : set A) = \u22c2 i, S i :=\nby simp [infi]\n\nlemma mem_infi {\u03b9 : Sort*} {S : \u03b9 \u2192 subalgebra R A} {x : A} : (x \u2208 \u2a05 i, S i) \u2194 \u2200 i, x \u2208 S i :=\nby simp only [infi, mem_Inf, set.forall_range_iff]\n\n@[simp] lemma infi_to_submodule {\u03b9 : Sort*} (S : \u03b9 \u2192 subalgebra R A) :\n  (\u2a05 i, S i).to_submodule = \u2a05 i, (S i).to_submodule :=\nset_like.coe_injective $ by simp\n\ninstance : inhabited (subalgebra R A) := \u27e8\u22a5\u27e9\n\ntheorem mem_bot {x : A} : x \u2208 (\u22a5 : subalgebra R A) \u2194 x \u2208 set.range (algebra_map R A) :=\nsuffices (of_id R A).range = (\u22a5 : subalgebra R A),\nby { rw [\u2190 this, \u2190set_like.mem_coe, alg_hom.coe_range], refl },\nle_bot_iff.mp (\u03bb x hx, subalgebra.range_le _ ((of_id R A).coe_range \u25b8 hx))\n\ntheorem to_submodule_bot : (\u22a5 : subalgebra R A).to_submodule = R \u2219 1 :=\nby { ext x, simp [mem_bot, -set.singleton_one, submodule.mem_span_singleton, algebra.smul_def] }\n\n@[simp] theorem coe_bot : ((\u22a5 : 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 = \u22a4 \u2194 \u2200 x : A, x \u2208 S :=\n\u27e8\u03bb h x, by rw h; exact mem_top, \u03bb h, by ext x; exact \u27e8\u03bb _, mem_top, \u03bb _, h x\u27e9\u27e9\n\n@[simp] theorem range_id : (alg_hom.id R A).range = \u22a4 :=\nset_like.coe_injective set.range_id\n\n@[simp] theorem map_top (f : A \u2192\u2090[R] B) : subalgebra.map (\u22a4 : subalgebra R A) f = f.range :=\nset_like.coe_injective set.image_univ\n\n@[simp] theorem map_bot (f : A \u2192\u2090[R] B) : subalgebra.map (\u22a5 : subalgebra R A) f = \u22a5 :=\nset_like.coe_injective $\n  by simp only [\u2190 set.range_comp, (\u2218), algebra.coe_bot, subalgebra.coe_map, f.commutes]\n\n@[simp] theorem comap_top (f : A \u2192\u2090[R] B) : subalgebra.comap' (\u22a4 : subalgebra R B) f = \u22a4 :=\neq_top_iff.2 $ \u03bb x, mem_top\n\n/-- `alg_hom` to `\u22a4 : subalgebra R A`. -/\ndef to_top : A \u2192\u2090[R] (\u22a4 : subalgebra R A) :=\n(alg_hom.id R A).cod_restrict \u22a4 (\u03bb _, mem_top)\n\ntheorem surjective_algebra_map_iff :\n  function.surjective (algebra_map R A) \u2194 (\u22a4 : subalgebra R A) = \u22a5 :=\n\u27e8\u03bb h, eq_bot_iff.2 $ \u03bb y _, let \u27e8x, hx\u27e9 := h y in hx \u25b8 subalgebra.algebra_map_mem _ _,\n\u03bb h y, algebra.mem_bot.1 $ eq_bot_iff.1 h (algebra.mem_top : y \u2208 _)\u27e9\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) \u2194 (\u22a4 : subalgebra R A) = \u22a5 :=\n\u27e8\u03bb h, surjective_algebra_map_iff.1 h.2,\n\u03bb h, \u27e8(algebra_map R A).injective, surjective_algebra_map_iff.2 h\u27e9\u27e9\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  (\u22a5 : subalgebra R A) \u2243\u2090[R] R :=\nalg_equiv.symm $ alg_equiv.of_bijective (algebra.of_id R _)\n\u27e8\u03bb x y hxy, h (congr_arg subtype.val hxy : _),\n \u03bb \u27e8y, hy\u27e9, let \u27e8x, hx\u27e9 := algebra.mem_bot.1 hy in \u27e8x, subtype.eq hx\u27e9\u27e9\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  (\u22a5 : subalgebra F R) \u2243\u2090[F] F :=\nbot_equiv_of_injective (ring_hom.injective _)\n\n/-- The top subalgebra is isomorphic to the field. -/\n@[simps] def top_equiv : (\u22a4 : subalgebra R A) \u2243\u2090[R] A :=\nalg_equiv.of_alg_hom (subalgebra.val \u22a4) to_top rfl $ alg_hom.ext $ \u03bb 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\u27e8\u03bb B C, ext (\u03bb x, by { simp only [subsingleton.elim x 0, zero_mem] })\u27e9\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 \u2192\u2090[R] B) :=\n\u27e8\u03bb f g, alg_hom.ext $ \u03bb a,\n  have a \u2208 (\u22a5 : subalgebra R A) := subsingleton.elim (\u22a4 : subalgebra R A) \u22a5 \u25b8 mem_top,\n  let \u27e8x, hx\u27e9 := set.mem_range.mp (mem_bot.mp this) in\n  hx \u25b8 (f.commutes _).trans (g.commutes _).symm\u27e9\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 \u2243\u2090[R] B) :=\nbegin\n  haveI : subsingleton (A \u2192\u2090[R] B) := alg_hom.subsingleton,\n  exact \u27e8\u03bb f g, alg_equiv.ext\n    (\u03bb x, alg_hom.ext_iff.mp (subsingleton.elim f.to_alg_hom g.to_alg_hom) x)\u27e9,\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 \u2243\u2090[R] B) :=\nbegin\n  haveI : subsingleton (B \u2243\u2090[R] A) := alg_equiv.subsingleton_left,\n  exact \u27e8\u03bb f g, eq.trans (alg_equiv.symm_symm _).symm\n    (by rw [subsingleton.elim f.symm g.symm, alg_equiv.symm_symm])\u27e9\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 (\u03bb 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 \u2192 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 \u2264 T) : S \u2192\u2090[R] T :=\n{ to_fun := set.inclusion h,\n  map_one' := rfl,\n  map_add' := \u03bb _ _, rfl,\n  map_mul' := \u03bb _ _, rfl,\n  map_zero' := rfl,\n  commutes' := \u03bb _, rfl }\n\nlemma inclusion_injective {S T : subalgebra R A} (h : S \u2264 T) :\n  function.injective (inclusion h) :=\n\u03bb _ _, subtype.ext \u2218 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 $ \u03bb x, subtype.ext rfl\n\n@[simp] lemma inclusion_right {S T : subalgebra R A} (h : S \u2264 T) (x : T)\n  (m : (x : A) \u2208 S) : inclusion h \u27e8x, m\u27e9 = x := subtype.ext rfl\n\n@[simp] lemma inclusion_inclusion {S T U : subalgebra R A} (hst : S \u2264 T) (htu : T \u2264 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 \u2264 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 \u2243\u2090[R] T :=\n{ to_fun := \u03bb x, \u27e8x, h \u25b8 x.2\u27e9,\n  inv_fun := \u03bb x, \u27e8x, h.symm \u25b8 x.2\u27e9,\n  map_mul' := \u03bb _ _, rfl,\n  commutes' := \u03bb _, 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\u2081 : subalgebra R B)\n\n/-- The product of two subalgebras is a subalgebra. -/\ndef prod : subalgebra R (A \u00d7 B) :=\n{ carrier := (S : set A) \u00d7\u02e2 (S\u2081 : set B),\n  algebra_map_mem' := \u03bb r, \u27e8algebra_map_mem _ _, algebra_map_mem _ _\u27e9,\n  .. S.to_subsemiring.prod S\u2081.to_subsemiring }\n\n@[simp] lemma coe_prod :\n  (prod S S\u2081 : set (A \u00d7 B)) = (S : set A) \u00d7\u02e2 (S\u2081 : set B):= rfl\n\nlemma prod_to_submodule :\n  (S.prod S\u2081).to_submodule = S.to_submodule.prod S\u2081.to_submodule := rfl\n\n@[simp] lemma mem_prod {S : subalgebra R A} {S\u2081 : subalgebra R B} {x : A \u00d7 B} :\n  x \u2208 prod S S\u2081 \u2194 x.1 \u2208 S \u2227 x.2 \u2208 S\u2081 := set.mem_prod\n\n@[simp] lemma prod_top : (prod \u22a4 \u22a4 : subalgebra R (A \u00d7 B)) = \u22a4 :=\nby ext; simp\n\nlemma prod_mono {S T : subalgebra R A} {S\u2081 T\u2081 : subalgebra R B} :\n  S \u2264 T \u2192 S\u2081 \u2264 T\u2081 \u2192 prod S S\u2081 \u2264 prod T T\u2081 := set.prod_mono\n\n@[simp] lemma prod_inf_prod {S T : subalgebra R A} {S\u2081 T\u2081 : subalgebra R B} :\n  S.prod S\u2081 \u2293 T.prod T\u2081 = (S \u2293 T).prod (S\u2081 \u2293 T\u2081) :=\nset_like.coe_injective set.prod_inter_prod\n\nend prod\n\nsection supr_lift\nvariables {\u03b9 : Type*}\n\nlemma coe_supr_of_directed [nonempty \u03b9] {S : \u03b9 \u2192 subalgebra R A}\n  (dir : directed (\u2264) S) : \u2191(supr S) = \u22c3 i, (S i : set A) :=\nlet K : subalgebra R A :=\n  { carrier := \u22c3 i, (S i),\n    mul_mem' := \u03bb x y hx hy,\n      let \u27e8i, hi\u27e9 := set.mem_Union.1 hx in\n      let \u27e8j, hj\u27e9 := set.mem_Union.1 hy in\n      let \u27e8k, hik, hjk\u27e9 := dir i j in\n      set.mem_Union.2 \u27e8k, subalgebra.mul_mem (S k) (hik hi) (hjk hj)\u27e9 ,\n    add_mem' := \u03bb x y hx hy,\n      let \u27e8i, hi\u27e9 := set.mem_Union.1 hx in\n      let \u27e8j, hj\u27e9 := set.mem_Union.1 hy in\n      let \u27e8k, hik, hjk\u27e9 := dir i j in\n      set.mem_Union.2 \u27e8k, subalgebra.add_mem (S k) (hik hi) (hjk hj)\u27e9,\n    algebra_map_mem' := \u03bb r, let i := @nonempty.some \u03b9 infer_instance in\n      set.mem_Union.2 \u27e8i, subalgebra.algebra_map_mem _ _\u27e9 } in\nhave supr S = K,\n  from le_antisymm (supr_le (\u03bb i, set.subset_Union (\u03bb i, \u2191(S i)) i))\n    (set_like.coe_subset_coe.1\n      (set.Union_subset (\u03bb i, set_like.coe_subset_coe.2 (le_supr _ _)))),\nthis.symm \u25b8 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 \u03b9]\n  (K : \u03b9 \u2192 subalgebra R A)\n  (dir : directed (\u2264) K)\n  (f : \u03a0 i, K i \u2192\u2090[R] B)\n  (hf : \u2200 (i j : \u03b9) (h : K i \u2264 K j), f i = (f j).comp (inclusion h))\n  (T : subalgebra R A) (hT : T = supr K) :\n  \u21a5T \u2192\u2090[R] B :=\nby subst hT; exact\n{ to_fun := set.Union_lift (\u03bb i, \u2191(K i)) (\u03bb i x, f i x)\n    (\u03bb i j x hxi hxj,\n      let \u27e8k, hik, hjk\u27e9 := dir i j in\n      begin\n        rw [hf i k hik, hf j k hjk],\n        refl\n      end) \u2191(supr K)\n    (by rw coe_supr_of_directed dir; refl),\n  map_one' := set.Union_lift_const _ (\u03bb _, 1) (\u03bb _, rfl) _ (by simp),\n  map_zero' := set.Union_lift_const _ (\u03bb _, 0) (\u03bb _, rfl) _ (by simp),\n  map_mul' := set.Union_lift_binary (coe_supr_of_directed dir) dir _\n    (\u03bb _, (*)) (\u03bb _ _ _, rfl) _ (by simp),\n  map_add' := set.Union_lift_binary (coe_supr_of_directed dir) dir _\n    (\u03bb _, (+)) (\u03bb _ _ _, rfl) _ (by simp),\n  commutes' := \u03bb r, set.Union_lift_const _ (\u03bb _, algebra_map _ _ r)\n    (\u03bb _, rfl) _ (\u03bb i, by erw [alg_hom.commutes (f i)]) }\n\nvariables [nonempty \u03b9] {K : \u03b9 \u2192 subalgebra R A} {dir : directed (\u2264) K}\n  {f : \u03a0 i, K i \u2192\u2090[R] B}\n  {hf : \u2200 (i j : \u03b9) (h : K i \u2264 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 : \u03b9} (x : K i) (h : K i \u2264 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 : \u03b9} (h : K i \u2264 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 : \u03b9} (x : K i) (hx : (x : A) \u2208 T) :\n  supr_lift K dir f hf T hT \u27e8x, hx\u27e9 = f i x :=\nby subst hT; exact set.Union_lift_mk x hx\n\nlemma supr_lift_of_mem {i : \u03b9} (x : T) (hx : (x : A) \u2208 K i) :\n  supr_lift K dir f hf T hT x = f i \u27e8x, hx\u27e9 :=\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 {\u03b1 \u03b2 : Type*}\n\n/-- The action by a subalgebra is the action by the underlying ring. -/\ninstance [mul_action A \u03b1] (S : subalgebra R A) : mul_action S \u03b1 :=\nS.to_subsemiring.mul_action\n\nlemma smul_def [mul_action A \u03b1] {S : subalgebra R A} (g : S) (m : \u03b1) : g \u2022 m = (g : A) \u2022 m := rfl\n\ninstance smul_comm_class_left\n  [mul_action A \u03b2] [has_scalar \u03b1 \u03b2] [smul_comm_class A \u03b1 \u03b2] (S : subalgebra R A) :\n  smul_comm_class S \u03b1 \u03b2 :=\nS.to_subsemiring.smul_comm_class_left\n\ninstance smul_comm_class_right\n  [has_scalar \u03b1 \u03b2] [mul_action A \u03b2] [smul_comm_class \u03b1 A \u03b2] (S : subalgebra R A) :\n  smul_comm_class \u03b1 S \u03b2 :=\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 \u03b1 \u03b2] [mul_action A \u03b1] [mul_action A \u03b2] [is_scalar_tower A \u03b1 \u03b2] (S : subalgebra R A) :\n  is_scalar_tower S \u03b1 \u03b2 :=\nS.to_subsemiring.is_scalar_tower\n\ninstance [mul_action A \u03b1] [has_faithful_scalar A \u03b1] (S : subalgebra R A) :\n  has_faithful_scalar S \u03b1 :=\nS.to_subsemiring.has_faithful_scalar\n\n/-- The action by a subalgebra is the action by the underlying algebra. -/\ninstance [add_monoid \u03b1] [distrib_mul_action A \u03b1] (S : subalgebra R A) : distrib_mul_action S \u03b1 :=\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 \u03b1] [module A \u03b1] (S : subalgebra R A) : module S \u03b1 :=\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 \u03b1]\n  [algebra R A] [algebra A \u03b1] (S : subalgebra R A) : algebra S \u03b1 :=\nalgebra.of_subsemiring S.to_subsemiring\n\nlemma algebra_map_eq {R A : Type*} [comm_semiring R] [comm_semiring A] [semiring \u03b1]\n  [algebra R A] [algebra A \u03b1] (S : subalgebra R A) :\n  algebra_map S \u03b1 = (algebra_map A \u03b1).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, \u2190 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, \u2190 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\u27e8\u03bb c x h,\n  have (c : A) = 0 \u2228 x = 0,\n  from eq_zero_or_eq_zero_of_mul_eq_zero h,\n  this.imp_left (@subtype.ext_iff _ _ c 0).mpr\u27e9\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 := \u03bb a S, S.map (mul_semiring_action.to_alg_hom _ _ a),\n  one_smul := \u03bb S,\n    (congr_arg (\u03bb f, S.map f) (alg_hom.ext $ by exact one_smul R')).trans S.map_id,\n  mul_smul := \u03bb a\u2081 a\u2082 S,\n    (congr_arg (\u03bb 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) : \u2191(m \u2022 S) = m \u2022 (S : set A) := rfl\n\n@[simp] lemma pointwise_smul_to_subsemiring (m : R') (S : subalgebra R A) :\n  (m \u2022 S).to_subsemiring = m \u2022 S.to_subsemiring := rfl\n\n@[simp] lemma pointwise_smul_to_submodule (m : R') (S : subalgebra R A) :\n  (m \u2022 S).to_submodule = m \u2022 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 \u2022 S).to_subring = m \u2022 S.to_subring := rfl\n\nlemma smul_mem_pointwise_smul (m : R') (r : A) (S : subalgebra R A) : r \u2208 S \u2192 m \u2022 r \u2208 m \u2022 S :=\n(set.smul_mem_smul_set : _ \u2192 _ \u2208 m \u2022 (S : set A))\n\nend pointwise\n\nsection center\n\nlemma _root_.set.algebra_map_mem_center (r : R) : algebra_map R A r \u2208 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 = \u22a4 :=\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 \u2208 center R A \u2194 \u2200 (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 `\u2115`-subalgebra. -/\ndef subalgebra_of_subsemiring (S : subsemiring R) : subalgebra \u2115 R :=\n{ algebra_map_mem' := \u03bb i, S.coe_nat_mem i,\n  .. S }\n\n@[simp] lemma mem_subalgebra_of_subsemiring {x : R} {S : subsemiring R} :\n  x \u2208 subalgebra_of_subsemiring S \u2194 x \u2208 S :=\niff.rfl\n\nend nat\n\nsection int\n\nvariables {R : Type*} [ring R]\n\n/-- A subring is a `\u2124`-subalgebra. -/\ndef subalgebra_of_subring (S : subring R) : subalgebra \u2124 R :=\n{ algebra_map_mem' := \u03bb i, int.induction_on i S.zero_mem\n  (\u03bb i ih, S.add_mem ih S.one_mem)\n  (\u03bb i ih, show ((-i - 1 : \u2124) : R) \u2208 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 \u2208 subalgebra_of_subring S \u2194 x \u2208 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 : \u2115) (\u03b1 : fin m \u2192 fin n \u2192 Type u) := d_array m (\u03bb j, d_array n (\u03b1 j))\n\nnamespace computable_d_matrix\n    variables {m n : \u2115} {\u03b1 : fin m \u2192 fin n \u2192 Type u} {\u03b2 : Type v}\n    def nil {\u03b1} : computable_d_matrix 0 0 \u03b1 := \n    \u27e8\u03bb i, absurd (fin.is_lt i) (nat.not_lt_zero (fin.val i))\u27e9\n\n    def read (a : computable_d_matrix m n \u03b1) (i : fin m) (j : fin n) : \u03b1 i j :=\n    d_array.read (d_array.read a i) j\n\n    def read_row (a : computable_d_matrix m n \u03b1) (i : fin m) : d_array n (\u03b1 i) :=\n    d_array.read a i\n    \n    def read_col (a : computable_d_matrix m n \u03b1) (j : fin n) : d_array m (\u03bb i, \u03b1 i j) :=\n    \u27e8\u03bb i, d_array.read (d_array.read a i) j\u27e9\n\n    def transpose (a : computable_d_matrix m n \u03b1) : computable_d_matrix n m (\u03bb (j : fin n) (i : fin m), \u03b1 i j) :=\n    \u27e8\u03bb j, \u27e8\u03bb i, a.read i j\u27e9\u27e9 -- TODO: This can probably be optimised\n\n    def write (a : computable_d_matrix m n \u03b1) (i : fin m) (j : fin n) (v : \u03b1 i j) : computable_d_matrix m n \u03b1 :=\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 \u03b1) (i : fin m) (v : d_array n (\u03b1 i)) : computable_d_matrix m n \u03b1 :=\n    d_array.write a i v\n    \n    def write_col (a : computable_d_matrix m n \u03b1) (j : fin n) (v : d_array m (\u03bb i, \u03b1 i j)) : computable_d_matrix m n \u03b1 :=\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 \u03b1) (b : \u03b2) (f : \u03a0 (i : fin m) (j : fin n), \u03b1 i j \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\n    d_array.iterate a b (\u03bb i arr state, d_array.iterate arr state (\u03bb j, f i j))            \n\n    def iterate_row (a : computable_d_matrix m n \u03b1) (b : \u03b2) (f : \u03a0 (i : fin m), (d_array n (\u03b1 i)) \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\n    d_array.iterate a b f\n\n    def iterate_col (a : computable_d_matrix m n \u03b1) (b : \u03b2) (f : \u03a0 (j : fin n), d_array m (\u03bb i, \u03b1 i j) \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\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 \u03b1) (f : \u03a0 (i : fin m) (j : fin n), \u03b1 i j \u2192 \u03b1 i j) : computable_d_matrix m n \u03b1 :=\n    iterate a a $ \u03bb i j v a', a'.write i j (f i j v)\n\n    def map (f : \u03a0 (i : fin m) (j : fin n), \u03b1 i j \u2192 \u03b1 i j) (a : computable_d_matrix m n \u03b1) : computable_d_matrix m n \u03b1 :=\n    foreach a f\n\n    def map\u2082 (f : \u03a0 (i : fin m) (j : fin n), \u03b1 i j \u2192 \u03b1 i j \u2192 \u03b1 i j) (a b : computable_d_matrix m n \u03b1) : computable_d_matrix m n \u03b1 :=\n    foreach b (\u03bb i j, f i j (a.read i j))\n\n    def foldl (a : computable_d_matrix m n \u03b1) (b : \u03b2) (f : \u03a0 (i : fin m) (j : fin n), \u03b1 i j \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\n    iterate a b f\n\n    @[simp] lemma read_write (a : computable_d_matrix m n \u03b1) (i : fin m) (j : fin n) (v : \u03b1 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 \u03b1) (i : fin m) (v : d_array n (\u03b1 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 \u03b1) (j : fin n) (v : d_array m (\u03bb i, \u03b1 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 \u03b1) {i j : fin m} {k l : fin n} (v : \u03b1 i k) : i \u2260 j \u2192 k \u2260 l \u2192 (read (write a i k v) j l) = (read a j l):=\n    by intros h\u2081 h\u2082; simp [read, write, h\u2081, h\u2082]\n\n    protected lemma ext {a b : computable_d_matrix m n \u03b1} (h : \u2200 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 \u03b1} (h : \u2200 (i j : nat) (h\u2081 : i < m) (h\u2082 : j < n), read a \u27e8i, h\u2081\u27e9 \u27e8j, h\u2082\u27e9 = read b \u27e8i, h\u2081\u27e9 \u27e8j, h\u2082\u27e9) : 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 = \u27e8i.val, (fin.is_lt i)\u27e9, by simp,\n    have hj : j = \u27e8j.val, (fin.is_lt j)\u27e9, 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 [\u2200 i j, decidable_eq (\u03b1 i j)] (a b : computable_d_matrix m n \u03b1) : \u03a0 (i : nat), i \u2264 m \u2192 bool :=\n    @d_array.beq_aux _ _ _ a b\n\n    protected def beq [\u2200 i j, decidable_eq (\u03b1 i j)] (a b : computable_d_matrix m n \u03b1) : bool :=\n    @d_array.beq_aux _ _ _ a b _ (le_refl m)\n\n    instance [\u2200 i j, decidable_eq (\u03b1 i j)] : decidable_eq (computable_d_matrix m n \u03b1) :=\n    d_array.decidable_eq\n\nend computable_d_matrix\n\ndef computable_matrix (m n : \u2115) (\u03b1 : Type u) := computable_d_matrix m n (\u03bb i j, \u03b1)\n\nnamespace computable_matrix\n    variables {m n : nat} {\u03b1 : Type u} {\u03b2 : Type v}\n    def nil : computable_matrix 0 0 \u03b1 :=\n    computable_d_matrix.nil\n\n    def read (a : computable_matrix m n \u03b1) (i : fin m) (j : fin n) : \u03b1 :=\n    computable_d_matrix.read a i j\n\n    def read_row (a : computable_matrix m n \u03b1) (i : fin m) : array n \u03b1 :=\n    computable_d_matrix.read_row a i\n\n    def read_col (a : computable_matrix m n \u03b1) (j : fin n) : array m \u03b1 :=\n    computable_d_matrix.read_col a j\n\n    def transpose (a : computable_matrix m n \u03b1) : computable_matrix n m \u03b1 :=\n    computable_d_matrix.transpose a\n\n    def write (a : computable_matrix m n \u03b1) (i : fin m) (j : fin n) (v : \u03b1) : computable_matrix m n \u03b1 :=\n    computable_d_matrix.write a i j v\n\n    def write_row (a : computable_matrix m n \u03b1) (i : fin m) (v : array n \u03b1) : computable_matrix m n \u03b1 :=\n    computable_d_matrix.write_row a i v\n\n    def write_col (a : computable_matrix m n \u03b1) (j : fin n) (v : array m \u03b1) : computable_matrix m n \u03b1 :=\n    computable_d_matrix.write_col a j v\n\n    def iterate_row (a : computable_matrix m n \u03b1) (b : \u03b2) (f : fin m \u2192 array n \u03b1 \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\n    computable_d_matrix.iterate_row a b (\u03bb i V\u2081, f i \u27e8V\u2081.data\u27e9)\n\n    def iterate_col (a : computable_matrix m n \u03b1) (b : \u03b2) (f : fin n \u2192 array m \u03b1 \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\n    computable_d_matrix.iterate_col a b (\u03bb i V\u2081, f i \u27e8V\u2081.data\u27e9)\n\n    def iterate (a : computable_matrix m n \u03b1) (b : \u03b2) (f : fin m \u2192 fin n \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\n    computable_d_matrix.iterate a b (\u03bb i j v, f i j v)\n\n    def foreach (a : computable_matrix m n \u03b1) (f : fin m \u2192 fin n \u2192 \u03b1 \u2192 \u03b1) : computable_matrix m n \u03b1 :=\n    iterate a a (\u03bb i j v a', a'.write i j (f i j v))\n\n    def map (f : \u03b1 \u2192 \u03b1) (a : computable_matrix m n \u03b1) : computable_matrix m n \u03b1 :=\n    foreach a (\u03bb _ _, f)\n\n    def map\u2082 (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (a b : computable_matrix m n \u03b1) : computable_matrix m n \u03b1 :=\n    foreach b (\u03bb i j, f (a.read i j))\n\n    def foldl_row (a : computable_matrix m n \u03b1) (b : \u03b2) (f : (array n \u03b1) \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\n    iterate_row a b (\u03bb _, f)\n\n    def foldl_col (a : computable_matrix m n \u03b1) (b : \u03b2) (f : (array m \u03b1) \u2192 \u03b2 \u2192 \u03b2) : \u03b2 :=\n    iterate_col a b (\u03bb _, f)\n\n    def rev_list_row (a : computable_matrix m n \u03b1) : list (array n \u03b1) :=\n    a.foldl_row [] (::)\n\n    def rev_list_col (a : computable_matrix m n \u03b1) : list (array m \u03b1) :=\n    a.foldl_col [] (::)\n\n    @[simp] lemma read_write (a : computable_matrix m n \u03b1) (i : fin m) (j : fin n) (v : \u03b1) : 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 \u03b1) {i j : fin m} {k l : fin n} (v : \u03b1) : i \u2260 j \u2192 k \u2260 l \u2192 (read (write a i k v) j l) = (read a j l):=\n    by intros h\u2081 h\u2082; simp [read, write, h\u2081, h\u2082]\n\n    protected lemma ext {a b : computable_matrix m n \u03b1} (h : \u2200 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 \u03b1} (h : \u2200 (i j : nat) (h\u2081 : i < m) (h\u2082 : j < n), read a \u27e8i, h\u2081\u27e9 \u27e8j, h\u2082\u27e9 = read b \u27e8i, h\u2081\u27e9 \u27e8j, h\u2082\u27e9) : 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 = \u27e8i.val, (fin.is_lt i)\u27e9, by simp,\n    have hj : j = \u27e8j.val, (fin.is_lt j)\u27e9, 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 \u03b1] (a b : computable_matrix m n \u03b1) : bool :=\n    @computable_d_matrix.beq m n (\u03bb i j, \u03b1) _ a b\n\n    instance [decidable_eq \u03b1] : decidable_eq (computable_matrix m n \u03b1) :=\n    computable_d_matrix.decidable_eq\n\n    def to_list (a : computable_matrix m n \u03b1) : list (list (\u03b1)) :=\n    iterate_row a [] (\u03bb i v b, list.concat b (array.to_list v))\n\n    instance repr [has_repr \u03b1] : has_repr (computable_matrix m n \u03b1) :=\n    \u27e8\u03bb a, list.repr (to_list a)\u27e9\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 \u03b1) (i\u2081 i\u2082 : fin m) : computable_matrix m n \u03b1 :=\n    \u27e8\u03bb i, if h\u2081 : i\u2081 = i then eq.rec_on h\u2081 (a.read_row i\u2082) else if h\u2082 : i\u2082 = i then eq.rec_on h\u2082 (a.read_row i\u2081) else a.read_row i\u27e9\n\n    def exchange_cols (a : computable_matrix m n \u03b1) (j\u2081 j\u2082 : fin n) : computable_matrix m n \u03b1 :=\n    (computable_matrix.exchange_rows (a.transpose) j\u2081 j\u2082).transpose -- TODO: Can probably be optimised without transpose\n\n    def add_multiple_of_row_to_row (a : computable_matrix m n \u03b1) [has_add \u03b1] [has_mul \u03b1] (i\u2081 : fin m) (s : \u03b1) (i\u2082 : fin m) : computable_matrix m n \u03b1 :=\n    computable_matrix.write_row a i\u2081 (array.map\u2082 (has_add.add) (a.read_row i\u2081) (array.map (has_mul.mul s) (a.read_row i\u2082)))\n\n    def add_multiple_of_col_to_col (a : computable_matrix m n \u03b1) [has_add \u03b1] [has_mul \u03b1] (j\u2081 : fin n) (s : \u03b1) (j\u2082 : fin n) : computable_matrix m n \u03b1 :=\n    (add_multiple_of_row_to_row (a.transpose) j\u2081 s j\u2082).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 {\u03b1 : Type u} {n : \u2115} : vector \u03b1 n \u2192 array n \u03b1 :=\n\u03bb v, \u27e8\u03bb i, vector.nth v i\u27e9\n\ninstance coe_array_of_vector {\u03b1 : Type u} {n : \u2115} : has_coe (vector \u03b1 n) (array n \u03b1) :=\n\u27e8array_of_vector\u27e9\n\ndef vector_of_array {\u03b1 : Type u} {n : \u2115} : array n \u03b1 \u2192 vector \u03b1 n :=\n \u03bb a, \u27e8list.reverse (array.to_list a), by simp \u27e9\n\ninstance coe_vector_of_array {\u03b1 : Type u} {n : \u2115} : has_coe (array n \u03b1) (vector \u03b1 n) :=\n\u27e8vector_of_array\u27e9 \n\n-- TODO: These coes are unrelated and probably shouldn't be here.\ninstance coe_matrix_of_array_of_array {\u03b1 : Type u} {m n : \u2115} : has_coe (array m (array n \u03b1)) (computable_matrix m n \u03b1) :=\n\u27e8\u03bb M, M\u27e9\n\ninstance coe_distributes_over_list {\u03b1 \u03b2 : Type u} [has_coe \u03b1 \u03b2] : has_coe (list \u03b1) (list \u03b2) :=\n\u27e8\u03bb l, l.map coe\u27e9\n\ninstance coe_distributes_over_array {\u03b1 \u03b2 : Type u} {n : \u2115} [has_coe \u03b1 \u03b2] : has_coe (array n \u03b1) (array n \u03b2) :=\n\u27e8\u03bb a, \u27e8\u03bb i, a.read i\u27e9\u27e9\n\ninstance coe_distributes_over_vector {\u03b1 \u03b2 : Type u} {n : \u2115} [has_coe \u03b1 \u03b2] : has_coe (vector \u03b1 n) (vector \u03b2 n) :=\n\u27e8\u03bbv, v.map coe\u27e9\n-----------------------------------------------------------------\n\ninstance coe_matrix_of_vector_of_vector {\u03b1 : Type u} {m n : \u2115} : has_coe (vector (vector \u03b1 n) m) (computable_matrix m n \u03b1) :=\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 : \u2115} {\u03b1 \u03b2 : Type u} [has_coe \u03b1 \u03b2] : has_coe (computable_matrix m n \u03b1) (computable_matrix m n \u03b2) :=\n\u27e8\u03bb M, \u27e8\u03bb i, \u27e8\u03bb j, M.read i j\u27e9\u27e9\u27e9\n\n-- Notation\n\ndef array.mk {\u03b1 : Type*} {n : \u2115} (l : list \u03b1) (pr : l.length = n) : array n \u03b1 :=\narray_of_vector \u27e8l, pr\u27e9\n\nnotation `![` l:(foldr `, ` (h t, list.cons h t) list.nil `]`) :=\n  array.mk l (refl _)\n\ndef test1 : computable_matrix 2 3 \u2124 := -- 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": "theorem ex : True \u2227 (match True with | _ => True) := by\n  constructor; exact trivial\n  split; trivial\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/1168.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7853085708384736, "lm_q2_score": 0.6150878555160665, "lm_q1q2_score": 0.4830337647554237}}
{"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 \u2192 Prop) : Prop :=\n  \u2200 \u2983F : J \u2964 C\u2984 \u2983c : Cone F\u2984 (hc : IsLimit c), (\u2200 j, P (F.obj j)) \u2192 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 \u2192 Prop) : Prop :=\n  \u2200 \u2983F : J \u2964 C\u2984 \u2983c : Cocone F\u2984 (hc : IsColimit c), (\u2200 j, P (F.obj j)) \u2192 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 \u2192 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\u2093'. -/\ntheorem ClosedUnderLimitsOfShape.limit (h : ClosedUnderLimitsOfShape J P) {F : J \u2964 C} [HasLimit F] :\n    (\u2200 j, P (F.obj j)) \u2192 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\u2093'. -/\ntheorem ClosedUnderColimitsOfShape.colimit (h : ClosedUnderColimitsOfShape J P) {F : J \u2964 C}\n    [HasColimit F] : (\u2200 j, P (F.obj j)) \u2192 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 \u2192 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\u2093.{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\u2093.{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\u2093.{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\u2093.{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\u2093.{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'\u2093'. -/\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 \u2964 FullSubcategory P)\n    {c : Cone (F \u22d9 fullSubcategoryInclusion P)} (hc : IsLimit c) (h : P c.pt) :\n    CreatesLimit F (fullSubcategoryInclusion P) :=\n  createsLimitOfFullyFaithfulOfIso' hc \u27e8_, h\u27e9 (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\u2093.{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\u2093.{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\u2093.{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\u2093.{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\u2093'. -/\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 \u2964 FullSubcategory P)\n    [HasLimit (F \u22d9 fullSubcategoryInclusion P)] (h : P (limit (F \u22d9 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\u2093.{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\u2093.{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\u2093.{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\u2093.{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\u2093.{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'\u2093'. -/\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 \u2964 FullSubcategory P)\n    {c : Cocone (F \u22d9 fullSubcategoryInclusion P)} (hc : IsColimit c) (h : P c.pt) :\n    CreatesColimit F (fullSubcategoryInclusion P) :=\n  createsColimitOfFullyFaithfulOfIso' hc \u27e8_, h\u27e9 (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\u2093.{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\u2093.{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\u2093.{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\u2093.{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\u2093'. -/\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 \u2964 FullSubcategory P)\n    [HasColimit (F \u22d9 fullSubcategoryInclusion P)]\n    (h : P (colimit (F \u22d9 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\u2093.{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\u2093.{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\u2093.{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\u2093'. -/\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 \u2964 FullSubcategory P) [HasLimit (F \u22d9 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\u2093.{u3, u4} C _inst_2 P) (CategoryTheory.InducedCategory.category.{u3, u4, u4} (CategoryTheory.FullSubcategory\u2093.{u3, u4} C _inst_2 P) C _inst_2 (CategoryTheory.FullSubcategory\u2093.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\u2093'. -/\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\u2093.{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\u2093.{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\u2093.{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\u2093'. -/\ntheorem hasLimit_of_closed_under_limits (h : ClosedUnderLimitsOfShape J P)\n    (F : J \u2964 FullSubcategory P) [HasLimit (F \u22d9 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\u2093.{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\u2093'. -/\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\u2093.{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\u2093.{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\u2093.{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\u2093'. -/\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 \u2964 FullSubcategory P) [HasColimit (F \u22d9 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\u2093.{u3, u4} C _inst_2 P) (CategoryTheory.InducedCategory.category.{u3, u4, u4} (CategoryTheory.FullSubcategory\u2093.{u3, u4} C _inst_2 P) C _inst_2 (CategoryTheory.FullSubcategory\u2093.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\u2093'. -/\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\u2093.{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\u2093.{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\u2093.{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\u2093'. -/\ntheorem hasColimit_of_closed_under_colimits (h : ClosedUnderColimitsOfShape J P)\n    (F : J \u2964 FullSubcategory P) [HasColimit (F \u22d9 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\u2093.{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\u2093'. -/\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 \u27f6 X)\n\n/-- A set of arrows all with codomain `X`. -/\n@[derive complete_lattice]\ndef presieve (X : C) := \u03a0 \u2983Y\u2984, set (Y \u27f6 X)\n\nnamespace presieve\n\ninstance : inhabited (presieve X) := \u27e8\u22a4\u27e9\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 \u27f6 X` in `S`, produce a set of arrows with codomain `X`:\n`{ g \u226b f | (f : Y \u27f6 X) \u2208 S, (g : Z \u27f6 Y) \u2208 R f }`.\n-/\ndef bind (S : presieve X) (R : \u03a0 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984, S f \u2192 presieve Y) :\n  presieve X :=\n\u03bb Z h, \u2203 (Y : C) (g : Z \u27f6 Y) (f : Y \u27f6 X) (H : S f), R H g \u2227 g \u226b f = h\n\n@[simp]\nlemma bind_comp {S : presieve X}\n  {R : \u03a0 \u2983Y : C\u2984 \u2983f : Y \u27f6 X\u2984, S f \u2192 presieve Y} {g : Z \u27f6 Y} (h\u2081 : S f) (h\u2082 : R h\u2081 g) :\nbind S R (g \u226b f) :=\n\u27e8_, _, _, h\u2081, h\u2082, rfl\u27e9\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 \u27f6 X) : singleton f g \u2194 f = g :=\nbegin\n  split,\n  { rintro \u27e8a, rfl\u27e9,\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 \u27f6 X) : R h \u2192 pullback_arrows (pullback.snd : pullback h f \u27f6 Y)\n\nlemma pullback_singleton [has_pullbacks C] (g : Z \u27f6 X) :\n pullback_arrows f (singleton g) = singleton (pullback.snd : pullback g f \u27f6 _) :=\nbegin\n  ext W h,\n  split,\n  { rintro \u27e8W, _, _, _\u27e9,\n    exact singleton.mk },\n  { rintro \u27e8_\u27e9,\n    exact pullback_arrows.mk Z g singleton.mk }\nend\n\n/-- Construct the presieve given by the family of arrows indexed by `\u03b9`. -/\ninductive of_arrows {\u03b9 : Type*} (Y : \u03b9 \u2192 C) (f : \u03a0 i, Y i \u27f6 X) : presieve X\n| mk (i : \u03b9) : of_arrows (f i)\n\nlemma of_arrows_punit :\n  of_arrows _ (\u03bb _ : punit, f) = singleton f :=\nbegin\n  ext Y g,\n  split,\n  { rintro \u27e8_\u27e9,\n    apply singleton.mk },\n  { rintro \u27e8_\u27e9,\n    exact of_arrows.mk punit.star },\nend\n\nlemma of_arrows_pullback [has_pullbacks C] {\u03b9 : Type*}\n  (Z : \u03b9 \u2192 C) (g : \u03a0 (i : \u03b9), Z i \u27f6 X) :\n  of_arrows (\u03bb i, pullback (g i) f) (\u03bb i, pullback.snd) =\n    pullback_arrows f (of_arrows Z g) :=\nbegin\n  ext T h,\n  split,\n  { rintro \u27e8hk\u27e9,\n   exact pullback_arrows.mk _ _ (of_arrows.mk hk) },\n  { rintro \u27e8W, k, hk\u2081\u27e9,\n    cases hk\u2081 with i hi,\n    apply of_arrows.mk },\nend\n\nlemma of_arrows_bind {\u03b9 : Type*} (Z : \u03b9 \u2192 C) (g : \u03a0 (i : \u03b9), Z i \u27f6 X)\n  (j : \u03a0 \u2983Y\u2984 (f : Y \u27f6 X), of_arrows Z g f \u2192 Type*)\n  (W : \u03a0 \u2983Y\u2984 (f : Y \u27f6 X) H, j f H \u2192 C)\n  (k : \u03a0 \u2983Y\u2984 (f : Y \u27f6 X) H i, W f H i \u27f6 Y) :\n  (of_arrows Z g).bind (\u03bb Y f H, of_arrows (W f H) (k f H)) =\n    of_arrows (\u03bb (i : \u03a3 i, j _ (of_arrows.mk i)), W (g i.1) _ i.2)\n      (\u03bb ij, k (g ij.1) _ ij.2 \u226b g ij.1) :=\nbegin\n  ext Y f,\n  split,\n  { rintro \u27e8_, _, _, \u27e8i\u27e9, \u27e8i'\u27e9, rfl\u27e9,\n    exact of_arrows.mk (sigma.mk _ _) },\n  { rintro \u27e8i\u27e9,\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' : \u2200 {Y Z f} (hf : arrows f) (g : Z \u27f6 Y), arrows (g \u226b f))\n\nnamespace sieve\n\ninstance {X : C} : has_coe_to_fun (sieve X) := \u27e8_, sieve.arrows\u27e9\n\ninitialize_simps_projections sieve (arrows \u2192 apply)\n\nvariables {S R : sieve X}\n\n@[simp, priority 100] lemma downward_closed (S : sieve X) {f : Y \u27f6 X} (hf : S f)\n  (g : Z \u27f6 Y) : S (g \u226b f) :=\nS.downward_closed' hf g\n\nlemma arrows_ext : \u03a0 {R S : sieve X}, R.arrows = S.arrows \u2192 R = S\n| \u27e8Ra, _\u27e9 \u27e8Sa, _\u27e9 rfl := rfl\n\n@[ext]\nprotected lemma ext {R S : sieve X}\n  (h : \u2200 \u2983Y\u2984 (f : Y \u27f6 X), R f \u2194 S f) :\n  R = S :=\narrows_ext $ funext $ \u03bb x, funext $ \u03bb f, propext $ h f\n\nprotected lemma ext_iff {R S : sieve X} :\n  R = S \u2194 (\u2200 \u2983Y\u2984 (f : Y \u27f6 X), R f \u2194 S f) :=\n\u27e8\u03bb h Y f, h \u25b8 iff.rfl, sieve.ext\u27e9\n\nopen lattice\n\n/-- The supremum of a collection of sieves: the union of them all. -/\nprotected def Sup (\ud835\udcae : set (sieve X)) : (sieve X) :=\n{ arrows := \u03bb Y, {f | \u2203 S \u2208 \ud835\udcae, sieve.arrows S f},\n  downward_closed' := \u03bb Y Z f, by { rintro \u27e8S, hS, hf\u27e9 g, exact \u27e8S, hS, S.downward_closed hf _\u27e9 } }\n\n/-- The infimum of a collection of sieves: the intersection of them all. -/\nprotected def Inf (\ud835\udcae : set (sieve X)) : (sieve X) :=\n{ arrows := \u03bb Y, {f | \u2200 S \u2208 \ud835\udcae, sieve.arrows S f},\n  downward_closed' := \u03bb 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 := \u03bb Y f, S f \u2228 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 := \u03bb Y f, S f \u2227 R f,\n  downward_closed' := by { rintros Y Z f \u27e8h\u2081, h\u2082\u27e9 g, simp [h\u2081, h\u2082] } }\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           := \u03bb S R, \u2200 \u2983Y\u2984 (f : Y \u27f6 X), S f \u2192 R f,\n  le_refl      := \u03bb S f q, id,\n  le_trans     := \u03bb S\u2081 S\u2082 S\u2083 S\u2081\u2082 S\u2082\u2083 Y f h, S\u2082\u2083 _ (S\u2081\u2082 _ h),\n  le_antisymm  := \u03bb S R p q, sieve.ext (\u03bb Y f, \u27e8p _, q _\u27e9),\n  top          := { arrows := \u03bb _, set.univ, downward_closed' := \u03bb Y Z f g h, \u27e8\u27e9 },\n  bot          := { arrows := \u03bb _, \u2205, downward_closed' := \u03bb _ _ _ p _, false.elim p },\n  sup          := sieve.union,\n  inf          := sieve.inter,\n  Sup          := sieve.Sup,\n  Inf          := sieve.Inf,\n  le_Sup       := \u03bb \ud835\udcae S hS Y f hf, \u27e8S, hS, hf\u27e9,\n  Sup_le       := \u03bb \u2130 S hS Y f, by { rintro \u27e8R, hR, hf\u27e9, apply hS R hR _ hf },\n  Inf_le       := \u03bb _ _ hS _ _ h, h _ hS,\n  le_Inf       := \u03bb _ _ hS _ _ hf _ hR, hS _ hR _ hf,\n  le_sup_left  := \u03bb _ _ _ _, or.inl,\n  le_sup_right := \u03bb _ _ _ _, or.inr,\n  sup_le       := \u03bb _ _ _ a b _ _ hf, hf.elim (a _) (b _),\n  inf_le_left  := \u03bb _ _ _ _, and.left,\n  inf_le_right := \u03bb _ _ _ _, and.right,\n  le_inf       := \u03bb _ _ _ p q _ _ z, \u27e8p _ z, q _ z\u27e9,\n  le_top       := \u03bb _ _ _ _, trivial,\n  bot_le       := \u03bb _ _ _, false.elim }\n\n/-- The maximal sieve always exists. -/\ninstance sieve_inhabited : inhabited (sieve X) := \u27e8\u22a4\u27e9\n\n@[simp]\nlemma Inf_apply {Ss : set (sieve X)} {Y} (f : Y \u27f6 X) :\n  Inf Ss f \u2194 \u2200 (S : sieve X) (H : S \u2208 Ss), S f :=\niff.rfl\n\n@[simp]\nlemma Sup_apply {Ss : set (sieve X)} {Y} (f : Y \u27f6 X) :\n  Sup Ss f \u2194 \u2203 (S : sieve X) (H : S \u2208 Ss), S f :=\niff.rfl\n\n@[simp]\nlemma inter_apply {R S : sieve X} {Y} (f : Y \u27f6 X) :\n  (R \u2293 S) f \u2194 R f \u2227 S f :=\niff.rfl\n\n@[simp]\nlemma union_apply {R S : sieve X} {Y} (f : Y \u27f6 X) :\n  (R \u2294 S) f \u2194 R f \u2228 S f :=\niff.rfl\n\n@[simp]\nlemma top_apply (f : Y \u27f6 X) : (\u22a4 : 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 := \u03bb Z f, \u2203 Y (h : Z \u27f6 Y) (g : Y \u27f6 X), R g \u2227 h \u226b g = f,\n  downward_closed' :=\n  begin\n    rintro Y Z _ \u27e8W, g, f, hf, rfl\u27e9 h,\n    exact \u27e8_, h \u226b g, _, hf, by simp\u27e9,\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 : \u03a0 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984, S f \u2192 sieve Y) : sieve X :=\n{ arrows := S.bind (\u03bb Y f h, R h),\n  downward_closed' :=\n  begin\n    rintro Y Z f \u27e8W, f, h, hh, hf, rfl\u27e9 g,\n    exact \u27e8_, g \u226b f, _, hh, by simp [hf]\u27e9,\n  end }\n\nopen order lattice\n\nlemma sets_iff_generate (R : presieve X) (S : sieve X) :\n  generate R \u2264 S \u2194 R \u2264 S :=\n\u27e8\u03bb H Y g hg, H _ \u27e8_, \ud835\udfd9 _, _, hg, category.id_comp _\u27e9,\n \u03bb ss Y f,\n  begin\n    rintro \u27e8Z, f, g, hg, rfl\u27e9,\n    exact S.downward_closed (ss Z hg) f,\n  end\u27e9\n\n/-- Show that there is a galois insertion (generate, set_over). -/\ndef gi_generate : galois_insertion (generate : presieve X \u2192 sieve X) arrows :=\n{ gc := sets_iff_generate,\n  choice := \u03bb \ud835\udca2 _, generate \ud835\udca2,\n  choice_eq := \u03bb _ _, rfl,\n  le_l_u := \u03bb S Y f hf, \u27e8_, \ud835\udfd9 _, _, hf, category.id_comp _\u27e9 }\n\nlemma le_generate (R : presieve X) : R \u2264 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 (\ud835\udfd9 X) \u2194 S = \u22a4 :=\n\u27e8\u03bb h, top_unique $ \u03bb Y f _, by simpa using downward_closed _ h f,\n \u03bb h, h.symm \u25b8 trivial\u27e9\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 \u27f6 X) [split_epi f]\n  (hf : R f) : generate R = \u22a4 :=\nbegin\n  rw \u2190 id_mem_iff_eq_top,\n  exact \u27e8_, section_ f, f, hf, by simp\u27e9,\nend\n\n@[simp]\nlemma generate_of_singleton_split_epi (f : Y \u27f6 X) [split_epi f] :\n  generate (presieve.singleton f) = \u22a4 :=\ngenerate_of_contains_split_epi f (presieve.singleton_self _)\n\n@[simp]\nlemma generate_top : generate (\u22a4 : presieve X) = \u22a4 :=\ngenerate_of_contains_split_epi (\ud835\udfd9 _) \u27e8\u27e9\n\n/-- Given a morphism `h : Y \u27f6 X`, send a sieve S on X to a sieve on Y\n    as the inverse image of S with `_ \u226b h`.\n    That is, `sieve.pullback S h := (\u226b h) '\u207b\u00b9 S`. -/\n@[simps]\ndef pullback (h : Y \u27f6 X) (S : sieve X) : sieve Y :=\n{ arrows := \u03bb Y sl, S (sl \u226b h),\n  downward_closed' := \u03bb Z W f g h, by simp [g] }\n\n@[simp]\nlemma pullback_id : S.pullback (\ud835\udfd9 _) = S :=\nby simp [sieve.ext_iff]\n\n@[simp]\nlemma pullback_top {f : Y \u27f6 X} : (\u22a4 : sieve X).pullback f = \u22a4 :=\ntop_unique (\u03bb _ g, id)\n\nlemma pullback_comp {f : Y \u27f6 X} {g : Z \u27f6 Y} (S : sieve X) :\n  S.pullback (g \u226b f) = (S.pullback f).pullback g :=\nby simp [sieve.ext_iff]\n\n@[simp]\nlemma pullback_inter {f : Y \u27f6 X} (S R : sieve X) :\n (S \u2293 R).pullback f = S.pullback f \u2293 R.pullback f :=\nby simp [sieve.ext_iff]\n\nlemma pullback_eq_top_iff_mem (f : Y \u27f6 X) : S f \u2194 S.pullback f = \u22a4 :=\nby rw [\u2190 id_mem_iff_eq_top, pullback_apply, category.id_comp]\n\nlemma pullback_eq_top_of_mem (S : sieve X) {f : Y \u27f6 X} : S f \u2192 S.pullback f = \u22a4 :=\n(pullback_eq_top_iff_mem f).1\n\n/--\nPush a sieve `R` on `Y` forward along an arrow `f : Y \u27f6 X`: `gf : Z \u27f6 X` is in the sieve if `gf`\nfactors through some `g : Z \u27f6 Y` which is in `R`.\n-/\n@[simps]\ndef pushforward (f : Y \u27f6 X) (R : sieve Y) : sieve X :=\n{ arrows := \u03bb Z gf, \u2203 g, g \u226b f = gf \u2227 R g,\n  downward_closed' := \u03bb Z\u2081 Z\u2082 g \u27e8j, k, z\u27e9 h, \u27e8h \u226b j, by simp [k], by simp [z]\u27e9 }\n\nlemma pushforward_apply_comp {R : sieve Y} {Z : C} {g : Z \u27f6 Y} (hg : R g) (f : Y \u27f6 X) :\n  R.pushforward f (g \u226b f) :=\n\u27e8g, rfl, hg\u27e9\n\nlemma pushforward_comp {f : Y \u27f6 X} {g : Z \u27f6 Y} (R : sieve Z) :\n  R.pushforward (g \u226b f) = (R.pushforward g).pushforward f :=\nsieve.ext (\u03bb W h, \u27e8\u03bb \u27e8f\u2081, hq, hf\u2081\u27e9, \u27e8f\u2081 \u226b g, by simpa, f\u2081, rfl, hf\u2081\u27e9,\n                   \u03bb \u27e8y, hy, z, hR, hz\u27e9, \u27e8z, by rwa reassoc_of hR, hz\u27e9\u27e9)\n\nlemma galois_connection (f : Y \u27f6 X) : galois_connection (sieve.pushforward f) (sieve.pullback f) :=\n\u03bb S R, \u27e8\u03bb hR Z g hg, hR _ \u27e8g, rfl, hg\u27e9, \u03bb hS Z g \u27e8h, hg, hh\u27e9, hg \u25b8 hS h hh\u27e9\n\nlemma pullback_monotone (f : Y \u27f6 X) : monotone (sieve.pullback f) :=\n(galois_connection f).monotone_u\n\nlemma pushforward_monotone (f : Y \u27f6 X) : monotone (sieve.pushforward f) :=\n(galois_connection f).monotone_l\n\nlemma le_pushforward_pullback (f : Y \u27f6 X) (R : sieve Y) :\n  R \u2264 (R.pushforward f).pullback f :=\n(galois_connection f).le_u_l _\n\nlemma pullback_pushforward_le (f : Y \u27f6 X) (R : sieve X) :\n  (R.pullback f).pushforward f \u2264 R :=\n(galois_connection f).l_u_le _\n\nlemma pushforward_union {f : Y \u27f6 X} (S R : sieve Y) :\n  (S \u2294 R).pushforward f = S.pushforward f \u2294 R.pushforward f :=\n(galois_connection f).l_sup\n\nlemma pushforward_le_bind_of_mem (S : presieve X)\n  (R : \u03a0 \u2983Y : C\u2984 \u2983f : Y \u27f6 X\u2984, S f \u2192 sieve Y) (f : Y \u27f6 X) (h : S f) :\n  (R h).pushforward f \u2264 bind S R :=\nbegin\n  rintro Z _ \u27e8g, rfl, hg\u27e9,\n  exact \u27e8_, g, f, h, hg, rfl\u27e9,\nend\n\nlemma le_pullback_bind (S : presieve X) (R : \u03a0 \u2983Y : C\u2984 \u2983f : Y \u27f6 X\u2984, S f \u2192 sieve Y)\n  (f : Y \u27f6 X) (h : S f) :\n  R h \u2264 (bind S R).pullback f :=\nbegin\n  rw \u2190 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 \u27f6 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 \u27e8g\u2081, hf, hg\u2081\u27e9,\n  rw cancel_mono f at hf,\n  rwa \u2190 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 \u27f6 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 \u27e8g \u226b section_ f, by simpa\u27e9,\nend\n\nlemma pullback_arrows_comm [has_pullbacks C] {X Y : C} (f : Y \u27f6 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 \u27e8_, h, k, hk, rfl\u27e9,\n    cases hk with W g hg,\n    change (sieve.generate R).pullback f (h \u226b pullback.snd),\n    rw [sieve.pullback_apply, assoc, \u2190 pullback.condition, \u2190 assoc],\n    exact sieve.downward_closed _ (sieve.le_generate R W hg) (h \u226b pullback.fst)},\n  { rintro \u27e8W, h, k, hk, comm\u27e9,\n    exact \u27e8_, _, _, presieve.pullback_arrows.mk _ _ hk, pullback.lift_snd _ _ comm\u27e9 },\nend\n\n/-- A sieve induces a presheaf. -/\n@[simps]\ndef functor (S : sieve X) : C\u1d52\u1d56 \u2964 Type v :=\n{ obj := \u03bb Y, {g : Y.unop \u27f6 X // S g},\n  map := \u03bb Y Z f g, \u27e8f.unop \u226b g.1, downward_closed _ g.2 _\u27e9 }\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 \u2264 T) : S.functor \u27f6 T.functor :=\n{ app := \u03bb Y f, \u27e8f.1, h _ f.2\u27e9 }.\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 \u27f6 yoneda.obj X :=\n{ app := \u03bb Y f, f.1 }.\n\nlemma nat_trans_of_le_comm {S T : sieve X} (h : S \u2264 T) :\n  nat_trans_of_le h \u226b 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\u27e8\u03bb Z f g h, by { ext Y y, apply congr_fun (nat_trans.congr_app h Y) y }\u27e9\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 \u27f6 yoneda.obj X) : sieve X :=\n{ arrows := \u03bb Y g, \u2203 t, f.app (opposite.op Y) t = g,\n  downward_closed' := \u03bb Y Z _,\n  begin\n    rintro \u27e8t, rfl\u27e9 g,\n    refine \u27e8R.map g.op t, _\u27e9,\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 \u27e8\u27e8f, hf\u27e9, rfl\u27e9,\n    exact hf },\n  { intro hf,\n    exact \u27e8\u27e8_, hf\u27e9, rfl\u27e9 }\nend\n\ninstance functor_inclusion_top_is_iso : is_iso ((\u22a4 : sieve X).functor_inclusion) :=\n\u27e8\u27e8{ app := \u03bb Y a, \u27e8a, \u27e8\u27e9\u27e9 }, by tidy\u27e9\u27e9\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 \u2192 prop \u2192 prop\n| true : prop\n| impl : prop \u2192 prop \u2192 prop\n| other : \u2115 \u2192 prop\n\nabbreviation context : Type := list prop\n\ninductive entails\u2081 : context \u2192 prop \u2192 Prop\n| refl\u2081 {\u0393 A} : entails\u2081 (A :: \u0393) A\n| trans {\u0393 A C} : entails\u2081 (A :: \u0393) C \u2192 entails\u2081 \u0393 A \u2192 entails\u2081 \u0393 C\n| weak {\u0393 A C} : entails\u2081 \u0393 C \u2192 entails\u2081 (A :: \u0393) C\n| contr {\u0393 A C} : entails\u2081 (A :: A :: \u0393) C \u2192 entails\u2081 (A :: \u0393) C\n| exch {\u0393 A B C} : entails\u2081 (B :: A :: \u0393) C \u2192 entails\u2081 (A :: B :: \u0393) C\n| and_intro {\u0393 A B} : entails\u2081 \u0393 A \u2192 entails\u2081 \u0393 B \u2192 entails\u2081 \u0393 (prop.and A B)\n| and_elim\u2081 {\u0393 A B} : entails\u2081 \u0393 (prop.and A B) \u2192 entails\u2081 \u0393 A\n| and_elim\u2082 {\u0393 A B} : entails\u2081 \u0393 (prop.and A B) \u2192 entails\u2081 \u0393 B\n| true_intro {\u0393} : entails\u2081 \u0393 prop.true\n| impl_intro {\u0393 A B} : entails\u2081 (A :: \u0393) B \u2192 entails\u2081 \u0393 (prop.impl A B)\n| impl_elim {\u0393 A B} : entails\u2081 \u0393 (prop.impl A B) \u2192 entails\u2081 \u0393 A \u2192 entails\u2081 \u0393 B\n\ninductive entails\u2082 : context \u2192 prop \u2192 Prop\n| refl\u2082 {\u0393 A} : list.mem A \u0393 \u2192 entails\u2082 \u0393 A\n| and_intro {\u0393 A B} : entails\u2082 \u0393 A \u2192 entails\u2082 \u0393 B \u2192 entails\u2082 \u0393 (prop.and A B)\n| and_elim\u2081 {\u0393 A B} : entails\u2082 \u0393 (prop.and A B) \u2192 entails\u2082 \u0393 A\n| and_elim\u2082 {\u0393 A B} : entails\u2082 \u0393 (prop.and A B) \u2192 entails\u2082 \u0393 B\n| true_intro {\u0393} : entails\u2082 \u0393 prop.true\n| impl_intro {\u0393 A B} : entails\u2082 (A :: \u0393) B \u2192 entails\u2082 \u0393 (prop.impl A B)\n| impl_elim {\u0393 A B} : entails\u2082 \u0393 (prop.impl A B) \u2192 entails\u2082 \u0393 A \u2192 entails\u2082 \u0393 B\n\nlemma entails\u2081.refl\u2082 {\u0393 A} : list.mem A \u0393 \u2192 entails\u2081 \u0393 A :=\nbegin\n  intro h,\n  induction \u0393 with B \u0393 ih,\n  { cases h },\n  { by_cases h' : A = B,\n    { subst h',\n      exact entails\u2081.refl\u2081 },\n    { replace h : list.mem A \u0393,\n      { cases h, exact false.elim (h' h), exact h },\n      specialize ih h, clear h h',\n      exact entails\u2081.weak ih } }\nend\n\nlemma entails\u2082.refl\u2081 {\u0393 A} : entails\u2082 (A :: \u0393) A :=\nbegin\n  exact entails\u2082.refl\u2082 (list.mem_cons_self A \u0393)\nend\n\nlemma aux {\u0393\u2081 \u0393\u2082 C} (h\u0393 : \u2200 (A : prop), list.mem A \u0393\u2081 \u2192 list.mem A \u0393\u2082) :\n  entails\u2082 \u0393\u2081 C \u2192 entails\u2082 \u0393\u2082 C :=\nbegin\n  intro h,\n  induction h with \u0393\u2081 C h \u0393\u2081 A B h\u2081 h\u2082 ih\u2081 ih\u2082 \u0393\u2081 A B h ih \u0393\u2081 A B h ih \u0393\u2081 \u0393\u2081 A B h ih \u0393\u2081 A B h\u2081 h\u2082 ih\u2081 ih\u2082 generalizing \u0393\u2082,\n  any_goals { specialize ih\u2081 h\u0393, specialize ih\u2082 h\u0393 },\n  { exact entails\u2082.refl\u2082 (h\u0393 C h) },\n  { exact entails\u2082.and_intro ih\u2081 ih\u2082 },\n  { exact entails\u2082.and_elim\u2081 (ih h\u0393) },\n  { exact entails\u2082.and_elim\u2082 (ih h\u0393) },\n  { exact entails\u2082.true_intro },\n  { replace h\u0393 : \u2200 B, list.mem B (A :: \u0393\u2081) \u2192 list.mem B (A :: \u0393\u2082),\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\u0393 B h') } },\n    exact entails\u2082.impl_intro (ih h\u0393) },\n  { exact entails\u2082.impl_elim ih\u2081 ih\u2082 }\nend\n\nlemma entails\u2082.exch {\u0393 A B C} :\n  entails\u2082 (B :: A :: \u0393) C \u2192 entails\u2082 (A :: B :: \u0393) C :=\nbegin\n  apply aux; clear C,\n  intro C,\n  by_cases h\u2081 : C = A,\n  { subst h\u2081,\n    intro h,\n    exact or.inl rfl },\n  { by_cases h\u2082 : C = B,\n    { subst h\u2082,\n      intro h,\n      exact or.inr (or.inl rfl) },\n    { intro h,\n      cases h, exact false.elim (h\u2082 h),\n      cases h, exact false.elim (h\u2081 h),\n      exact or.inr (or.inr h) } }\nend\n\nlemma entails\u2082.weak {\u0393 A C} : entails\u2082 \u0393 C \u2192 entails\u2082 (A :: \u0393) C :=\nbegin\n  intro h,\n  induction h with \u0393 C h \u0393 B C h\u2081 h\u2082 ih\u2081 ih\u2082 \u0393 C B h ih \u0393 B C h ih \u0393 \u0393 B C h ih \u0393 B C h\u2081 h\u2082 ih\u2081 ih\u2082,\n  { exact entails\u2082.refl\u2082 (or.inr h) },\n  { exact entails\u2082.and_intro ih\u2081 ih\u2082 },\n  { exact entails\u2082.and_elim\u2081 ih },\n  { exact entails\u2082.and_elim\u2082 ih },\n  { exact entails\u2082.true_intro },\n  { exact entails\u2082.impl_intro (entails\u2082.exch ih) },\n  { exact entails\u2082.impl_elim ih\u2081 ih\u2082 }\nend\n\nlemma entails\u2082.trans {\u0393 A C} :\n  entails\u2082 (A :: \u0393) C \u2192 entails\u2082 \u0393 A \u2192 entails\u2082 \u0393 C :=\nbegin\n  intros H\u2081 H\u2082,\n  have h\u0393 : \u2200 (B : prop), list.mem B (A :: \u0393) \u2192 B = A \u2228 list.mem B \u0393,\n  { intros B h, exact h },\n  induction H\u2081 with \u0393' C h \u0393' A' B h\u2081 h\u2082 ih\u2081 ih\u2082 \u0393' A' B h ih \u0393' A' B h ih \u0393' \u0393' A' B h ih \u0393' A' B h\u2081 h\u2082 ih\u2081 ih\u2082 generalizing \u0393,\n  any_goals { specialize ih\u2081 H\u2082 h\u0393, specialize ih\u2082 H\u2082 h\u0393 },\n  { by_cases h' : C = A,\n    { subst h',\n      exact H\u2082 },\n    { replace h\u0393 : list.mem C \u0393,\n      { specialize h\u0393 C h,\n        cases h\u0393,\n        { exact false.elim (h' h\u0393) },\n        { exact h\u0393 } },\n      exact entails\u2082.refl\u2082 h\u0393 } },\n  { exact entails\u2082.and_intro ih\u2081 ih\u2082 },\n  { exact entails\u2082.and_elim\u2081 (ih H\u2082 h\u0393) },\n  { exact entails\u2082.and_elim\u2082 (ih H\u2082 h\u0393) },\n  { exact entails\u2082.true_intro },\n  { replace H\u2082 : entails\u2082 (A' :: \u0393) A := entails\u2082.weak H\u2082,\n    replace h\u0393 : \u2200 (B : prop), list.mem B (A' :: \u0393') \u2192 B = A \u2228 list.mem B (A' :: \u0393),\n    { clear_dependent B,\n      intros B h,\n      cases h,\n      { subst h,\n        exact or.inr (or.inl rfl) },\n      { specialize h\u0393 B h,\n        cases h\u0393,\n        { subst h\u0393,\n          exact or.inl rfl },\n        { exact or.inr (or.inr h\u0393) } } },\n    exact entails\u2082.impl_intro (ih H\u2082 h\u0393) },\n  { exact entails\u2082.impl_elim ih\u2081 ih\u2082 }\nend\n\nlemma entails\u2082.contr {\u0393 A C} :\n  entails\u2082 (A :: A :: \u0393) C \u2192 entails\u2082 (A :: \u0393) 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\u2081_iff_entails\u2082 {\u0393 C} :\n  entails\u2081 \u0393 C \u2194 entails\u2082 \u0393 C :=\nbegin\n  split; intro h,\n  { induction h with \u0393 A \u0393 A C h\u2081 h\u2082 ih\u2081 ih\u2082 \u0393 A C h ih \u0393 A C h ih \u0393 A B C h ih \u0393 A B h\u2081 h\u2082 ih\u2081 ih\u2082 \u0393 A B h ih \u0393 A B h ih \u0393 \u0393 A B h ih \u0393 A B h\u2081 h\u2082 ih\u2081 ih\u2082,\n    { exact entails\u2082.refl\u2081 },\n    { exact entails\u2082.trans ih\u2081 ih\u2082 },\n    { exact entails\u2082.weak ih },\n    { exact entails\u2082.contr ih },\n    { exact entails\u2082.exch ih },\n    { exact entails\u2082.and_intro ih\u2081 ih\u2082 },\n    { exact entails\u2082.and_elim\u2081 ih },\n    { exact entails\u2082.and_elim\u2082 ih },\n    { exact entails\u2082.true_intro },\n    { exact entails\u2082.impl_intro ih },\n    { exact entails\u2082.impl_elim ih\u2081 ih\u2082 } },\n  { induction h with \u0393 C h \u0393 A B h\u2081 h\u2082 ih\u2081 ih\u2082 \u0393 A B h ih \u0393 A B h ih \u0393 \u0393 A B h ih \u0393 A B h\u2081 h\u2082 ih\u2081 ih\u2082,\n    { exact entails\u2081.refl\u2082 h },\n    { exact entails\u2081.and_intro ih\u2081 ih\u2082 },\n    { exact entails\u2081.and_elim\u2081 ih },\n    { exact entails\u2081.and_elim\u2082 ih },\n    { exact entails\u2081.true_intro },\n    { exact entails\u2081.impl_intro ih },\n    { exact entails\u2081.impl_elim ih\u2081 ih\u2082 } }\nend\n\n#print axioms entails\u2081_iff_entails\u2082 -- 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 \u27f6 A`.\nAn alternate definition is that the diagonal morphism `A \u27f6 A \u2a2f 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\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable theory\n\nnamespace category_theory\n\nopen limits category\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {A : C}\n\n/-- An object `A` is subterminal iff for any `Z`, there is at most one morphism `Z \u27f6 A`. -/\ndef is_subterminal (A : C) : Prop := \u2200 \u2983Z : C\u2984 (f g : Z \u27f6 A), f = g\n\nlemma is_subterminal.def : is_subterminal A \u2194 \u2200 \u2983Z : C\u2984 (f g : Z \u27f6 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 := \u03bb 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\u03bb Z f g, by { rw \u2190 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\u03bb Z f g, by { rw \u2190 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\u03bb Z f g, hT.hom_ext _ _\n\nlemma is_subterminal_of_terminal [has_terminal C] : is_subterminal (\u22a4_ C) :=\n\u03bb 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\u27e8\u27e8limits.prod.fst, \u27e8by simp, by { rw is_subterminal.def at hA, tidy }\u27e9\u27e9\u27e9\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\u03bb Z f g,\nbegin\n  have : (limits.prod.fst : A \u2a2f A \u27f6 _) = limits.prod.snd,\n  { simp [\u2190cancel_epi (diag A)] },\n  rw [\u2190prod.lift_fst f g, this, prod.lift_snd],\nend\n\n/-- If `A` is subterminal, it is isomorphic to `A \u2a2f A`. -/\n@[simps]\ndef is_subterminal.iso_diag (hA : is_subterminal A) [has_binary_product A A] :\n  A \u2a2f A \u2245 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\u2081) [category.{v\u2081} C] :=\nfull_subcategory (\u03bb (A : C), is_subterminal A)\n\ninstance [has_terminal C] : inhabited (subterminals C) :=\n\u27e8\u27e8\u22a4_ C, is_subterminal_of_terminal\u27e9\u27e9\n\n/-- The inclusion of the subterminal objects into the original category. -/\n@[derive [full, faithful], simps]\ndef subterminal_inclusion : subterminals C \u2964 C := full_subcategory_inclusion _\n\ninstance subterminals_thin (X Y : subterminals C) : subsingleton (X \u27f6 Y) :=\n\u27e8\u03bb f g, Y.2 f g\u27e9\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 \u224c mono_over (\u22a4_ C) :=\n{ functor :=\n  { obj := \u03bb X, \u27e8over.mk (terminal.from X.1), X.2.mono_terminal_from\u27e9,\n    map := \u03bb X Y f, mono_over.hom_mk f (by ext1 \u27e8\u27e8\u27e9\u27e9) },\n  inverse :=\n  { obj := \u03bb X, \u27e8X.obj.left, \u03bb Z f g, by { rw \u2190 cancel_mono X.arrow, apply subsingleton.elim }\u27e9,\n    map := \u03bb X Y f, f.1 },\n  unit_iso :=\n  { hom := { app := \u03bb X, \ud835\udfd9 _ },\n    inv := { app := \u03bb X, \ud835\udfd9 _ } },\n  counit_iso :=\n  { hom := { app := \u03bb X, over.hom_mk (\ud835\udfd9 _) },\n    inv := { app := \u03bb X, over.hom_mk (\ud835\udfd9 _) } } }\n\n@[simp]\nlemma subterminals_to_mono_over_terminal_comp_forget [has_terminal C] :\n  (subterminals_equiv_mono_over_terminal C).functor \u22d9 mono_over.forget _ \u22d9 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 \u22d9 subterminal_inclusion C =\n    mono_over.forget _ \u22d9 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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\u2082 : Type w} {V\u2082 : Type w'}\nvariables {M\u2083 : Type y} {V\u2083 : Type y'} {M\u2084 : Type z} {\u03b9 : Type x}\nvariables {M\u2085 M\u2086 : 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\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\nvariables [add_comm_monoid M\u2085] [add_comm_monoid M\u2086]\nvariables [module R M] [module R M\u2082] [module R M\u2083] [module R M\u2084]\nvariables [module R M\u2085] [module R M\u2086]\nvariables (f : M \u2192\u2097[R] M\u2082)\n\nsection\nvariables (R M M\u2082)\n\n/-- The first projection of a product is a linear map. -/\ndef fst : M \u00d7 M\u2082 \u2192\u2097[R] M := { to_fun := prod.fst, map_add' := \u03bb x y, rfl, map_smul' := \u03bb x y, rfl }\n\n/-- The second projection of a product is a linear map. -/\ndef snd : M \u00d7 M\u2082 \u2192\u2097[R] M\u2082 := { to_fun := prod.snd, map_add' := \u03bb x y, rfl, map_smul' := \u03bb x y, rfl }\nend\n\n@[simp] theorem fst_apply (x : M \u00d7 M\u2082) : fst R M M\u2082 x = x.1 := rfl\n@[simp] theorem snd_apply (x : M \u00d7 M\u2082) : snd R M M\u2082 x = x.2 := rfl\n\ntheorem fst_surjective : function.surjective (fst R M M\u2082) := \u03bb x, \u27e8(x, 0), rfl\u27e9\ntheorem snd_surjective : function.surjective (snd R M M\u2082) := \u03bb x, \u27e8(0, x), rfl\u27e9\n\n/-- The prod of two linear maps is a linear map. -/\n@[simps] def prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) : (M \u2192\u2097[R] M\u2082 \u00d7 M\u2083) :=\n{ to_fun    := pi.prod f g,\n  map_add'  := \u03bb x y, by simp only [pi.prod, prod.mk_add_mk, map_add],\n  map_smul' := \u03bb c x, by simp only [pi.prod, prod.smul_mk, map_smul, ring_hom.id_apply] }\n\nlemma coe_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) : \u21d1(f.prod g) = pi.prod f g := rfl\n\n@[simp] theorem fst_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) :\n  (fst R M\u2082 M\u2083).comp (prod f g) = f := by ext; refl\n\n@[simp] theorem snd_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) :\n  (snd R M\u2082 M\u2083).comp (prod f g) = g := by ext; refl\n\n@[simp] theorem pair_fst_snd : prod (fst R M M\u2082) (snd R M M\u2082) = 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\u2082] [module S M\u2083] [smul_comm_class R S M\u2082] [smul_comm_class R S M\u2083] :\n  ((M \u2192\u2097[R] M\u2082) \u00d7 (M \u2192\u2097[R] M\u2083)) \u2243\u2097[S] (M \u2192\u2097[R] M\u2082 \u00d7 M\u2083) :=\n{ to_fun := \u03bb f, f.1.prod f.2,\n  inv_fun := \u03bb f, ((fst _ _ _).comp f, (snd _ _ _).comp f),\n  left_inv := \u03bb f, by ext; refl,\n  right_inv := \u03bb f, by ext; refl,\n  map_add' := \u03bb a b, rfl,\n  map_smul' := \u03bb r a, rfl }\n\nsection\nvariables (R M M\u2082)\n\n/-- The left injection into a product is a linear map. -/\ndef inl : M \u2192\u2097[R] M \u00d7 M\u2082 := prod linear_map.id 0\n\n/-- The right injection into a product is a linear map. -/\ndef inr : M\u2082 \u2192\u2097[R] M \u00d7 M\u2082 := prod 0 linear_map.id\n\ntheorem range_inl : range (inl R M M\u2082) = ker (snd R M M\u2082) :=\nbegin\n  ext x,\n  simp only [mem_ker, mem_range],\n  split,\n  { rintros \u27e8y, rfl\u27e9, refl },\n  { intro h, exact \u27e8x.fst, prod.ext rfl h.symm\u27e9 }\nend\n\ntheorem ker_snd : ker (snd R M M\u2082) = range (inl R M M\u2082) :=\neq.symm $ range_inl R M M\u2082\n\ntheorem range_inr : range (inr R M M\u2082) = ker (fst R M M\u2082) :=\nbegin\n  ext x,\n  simp only [mem_ker, mem_range],\n  split,\n  { rintros \u27e8y, rfl\u27e9, refl },\n  { intro h, exact \u27e8x.snd, prod.ext h.symm rfl\u27e9 }\nend\n\ntheorem ker_fst : ker (fst R M M\u2082) = range (inr R M M\u2082) :=\neq.symm $ range_inr R M M\u2082\n\nend\n\n@[simp] theorem coe_inl : (inl R M M\u2082 : M \u2192 M \u00d7 M\u2082) = \u03bb x, (x, 0) := rfl\ntheorem inl_apply (x : M) : inl R M M\u2082 x = (x, 0) := rfl\n\n@[simp] theorem coe_inr : (inr R M M\u2082 : M\u2082 \u2192 M \u00d7 M\u2082) = prod.mk 0 := rfl\ntheorem inr_apply (x : M\u2082) : inr R M M\u2082 x = (0, x) := rfl\n\ntheorem inl_eq_prod : inl R M M\u2082 = prod linear_map.id 0 := rfl\n\ntheorem inr_eq_prod : inr R M M\u2082 = prod 0 linear_map.id := rfl\n\ntheorem inl_injective : function.injective (inl R M M\u2082) :=\n\u03bb _, by simp\n\n\n\n/-- The coprod function `\u03bb x : M \u00d7 M\u2082, f x.1 + g x.2` is a linear map. -/\ndef coprod (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) : M \u00d7 M\u2082 \u2192\u2097[R] M\u2083 :=\nf.comp (fst _ _ _) + g.comp (snd _ _ _)\n\n@[simp] theorem coprod_apply (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) (x : M \u00d7 M\u2082) :\n  coprod f g x = f x.1 + g x.2 := rfl\n\n@[simp] theorem coprod_inl (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) :\n  (coprod f g).comp (inl R M M\u2082) = f :=\nby ext; simp only [map_zero, add_zero, coprod_apply, inl_apply, comp_apply]\n\n@[simp] theorem coprod_inr (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) :\n  (coprod f g).comp (inr R M M\u2082) = 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\u2082) (inr R M M\u2082) = 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\u2083 \u2192\u2097[R] M\u2084) (g\u2081 : M \u2192\u2097[R] M\u2083) (g\u2082 : M\u2082 \u2192\u2097[R] M\u2083) :\n  f.comp (g\u2081.coprod g\u2082) = (f.comp g\u2081).coprod (f.comp g\u2082) :=\next $ \u03bb x, f.map_add (g\u2081 x.1) (g\u2082 x.2)\n\ntheorem fst_eq_coprod : fst R M M\u2082 = coprod linear_map.id 0 := by ext; simp\n\ntheorem snd_eq_coprod : snd R M M\u2082 = coprod 0 linear_map.id := by ext; simp\n\n@[simp] theorem coprod_comp_prod (f : M\u2082 \u2192\u2097[R] M\u2084) (g : M\u2083 \u2192\u2097[R] M\u2084)\n  (f' : M \u2192\u2097[R] M\u2082) (g' : M \u2192\u2097[R] M\u2083) :\n  (f.coprod g).comp (f'.prod g') = f.comp f' + g.comp g' :=\nrfl\n\n@[simp]\nlemma coprod_map_prod (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) (S : submodule R M)\n  (S' : submodule R M\u2082) :\n  (submodule.prod S S').map (linear_map.coprod f g) = S.map f \u2294 S'.map g :=\nset_like.coe_injective $ begin\n  simp only [linear_map.coprod_apply, submodule.coe_sup, submodule.map_coe],\n  rw [\u2190set.image2_add, set.image2_image_left, set.image2_image_right],\n  exact set.image_prod (\u03bb m m\u2082, f m + g m\u2082),\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\u2083] [smul_comm_class R S M\u2083] :\n  ((M \u2192\u2097[R] M\u2083) \u00d7 (M\u2082 \u2192\u2097[R] M\u2083)) \u2243\u2097[S] (M \u00d7 M\u2082 \u2192\u2097[R] M\u2083) :=\n{ to_fun := \u03bb f, f.1.coprod f.2,\n  inv_fun := \u03bb f, (f.comp (inl _ _ _), f.comp (inr _ _ _)),\n  left_inv := \u03bb f, by simp only [prod.mk.eta, coprod_inl, coprod_inr],\n  right_inv := \u03bb f, by simp only [\u2190comp_coprod, comp_id, coprod_inl_inr],\n  map_add' := \u03bb a b,\n    by { ext, simp only [prod.snd_add, add_apply, coprod_apply, prod.fst_add, add_add_add_comm] },\n  map_smul' := \u03bb 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 \u00d7 M\u2082 \u2192\u2097[R] M\u2083} :\n  f = g \u2194 f.comp (inl _ _ _) = g.comp (inl _ _ _) \u2227 f.comp (inr _ _ _) = g.comp (inr _ _ _) :=\n(coprod_equiv \u2115).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 \u2192\u2097 M\u2083` and `M\u2082 \u2192\u2097 M\u2083`.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext] theorem prod_ext {f g : M \u00d7 M\u2082 \u2192\u2097[R] M\u2083}\n  (hl : f.comp (inl _ _ _) = g.comp (inl _ _ _))\n  (hr : f.comp (inr _ _ _) = g.comp (inr _ _ _)) :\n  f = g :=\nprod_ext_iff.2 \u27e8hl, hr\u27e9\n\n/-- `prod.map` of two linear maps. -/\ndef prod_map (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2084) : (M \u00d7 M\u2082) \u2192\u2097[R] (M\u2083 \u00d7 M\u2084) :=\n(f.comp (fst R M M\u2082)).prod (g.comp (snd R M M\u2082))\n\n@[simp] theorem prod_map_apply (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2084) (x) :\n  f.prod_map g x = (f x.1, g x.2) := rfl\n\nlemma prod_map_comap_prod (f : M \u2192\u2097[R] M\u2082) (g : M\u2083 \u2192\u2097[R] M\u2084) (S : submodule R M\u2082)\n  (S' : submodule R M\u2084) :\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 \u2192\u2097[R] M\u2082) (g : M\u2083 \u2192\u2097[R] M\u2084) :\n  (linear_map.prod_map f g).ker = submodule.prod f.ker g.ker :=\nbegin\n  dsimp only [ker],\n  rw [\u2190prod_map_comap_prod, submodule.prod_bot],\nend\n\n@[simp]\nlemma prod_map_id : (id : M \u2192\u2097[R] M).prod_map (id : M\u2082 \u2192\u2097[R] M\u2082) = id :=\nlinear_map.ext $ \u03bb _, prod.mk.eta\n\n@[simp]\nlemma prod_map_one : (1 : M \u2192\u2097[R] M).prod_map (1 : M\u2082 \u2192\u2097[R] M\u2082) = 1 :=\nlinear_map.ext $ \u03bb _, prod.mk.eta\n\nlemma prod_map_comp (f\u2081\u2082 : M \u2192\u2097[R] M\u2082) (f\u2082\u2083 : M\u2082 \u2192\u2097[R] M\u2083) (g\u2081\u2082 : M\u2084 \u2192\u2097[R] M\u2085) (g\u2082\u2083 : M\u2085 \u2192\u2097[R] M\u2086) :\n  f\u2082\u2083.prod_map g\u2082\u2083 \u2218\u2097 f\u2081\u2082.prod_map g\u2081\u2082 = (f\u2082\u2083 \u2218\u2097 f\u2081\u2082).prod_map (g\u2082\u2083 \u2218\u2097 g\u2081\u2082) := rfl\n\nlemma prod_map_mul (f\u2081\u2082 : M \u2192\u2097[R] M) (f\u2082\u2083 : M \u2192\u2097[R] M) (g\u2081\u2082 : M\u2082 \u2192\u2097[R] M\u2082) (g\u2082\u2083 : M\u2082 \u2192\u2097[R] M\u2082) :\n  f\u2082\u2083.prod_map g\u2082\u2083 * f\u2081\u2082.prod_map g\u2081\u2082 = (f\u2082\u2083 * f\u2081\u2082).prod_map (g\u2082\u2083 * g\u2081\u2082) := rfl\n\nlemma prod_map_add (f\u2081 : M \u2192\u2097[R] M\u2083) (f\u2082 : M \u2192\u2097[R] M\u2083) (g\u2081 : M\u2082 \u2192\u2097[R] M\u2084) (g\u2082 : M\u2082 \u2192\u2097[R] M\u2084) :\n  (f\u2081 + f\u2082).prod_map (g\u2081 + g\u2082) = f\u2081.prod_map g\u2081 + f\u2082.prod_map g\u2082 := rfl\n\n@[simp] lemma prod_map_zero :\n  (0 : M \u2192\u2097[R] M\u2082).prod_map (0 : M\u2083 \u2192\u2097[R] M\u2084) = 0 := rfl\n\n@[simp] lemma prod_map_smul\n [module S M\u2083] [module S M\u2084] [smul_comm_class R S M\u2083] [smul_comm_class R S M\u2084]\n (s : S) (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2084) : prod_map (s \u2022 f) (s \u2022 g) = s \u2022 prod_map f g := rfl\n\nvariables (R M M\u2082 M\u2083 M\u2084)\n\n/-- `linear_map.prod_map` as a `linear_map` -/\n@[simps]\ndef prod_map_linear\n [module S M\u2083] [module S M\u2084] [smul_comm_class R S M\u2083] [smul_comm_class R S M\u2084] :\n ((M \u2192\u2097[R] M\u2083) \u00d7 (M\u2082 \u2192\u2097[R] M\u2084)) \u2192\u2097[S] ((M \u00d7 M\u2082) \u2192\u2097[R] (M\u2083 \u00d7 M\u2084)) :=\n{ to_fun := \u03bb f, prod_map f.1 f.2,\n  map_add' := \u03bb _ _, rfl,\n  map_smul' := \u03bb _ _, rfl}\n\n/-- `linear_map.prod_map` as a `ring_hom` -/\n@[simps]\ndef prod_map_ring_hom : (M \u2192\u2097[R] M) \u00d7 (M\u2082 \u2192\u2097[R] M\u2082) \u2192+* ((M \u00d7 M\u2082) \u2192\u2097[R] (M \u00d7 M\u2082)) :=\n{ to_fun := \u03bb f, prod_map f.1 f.2,\n  map_one' := prod_map_one,\n  map_zero' := rfl,\n  map_add' := \u03bb _ _, rfl,\n  map_mul' := \u03bb _ _, rfl }\n\nvariables {R M M\u2082 M\u2083 M\u2084}\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\u2081 a\u2082 : A) : linear_map.inl R A B (a\u2081 * a\u2082) =\n  linear_map.inl R A B a\u2081 * linear_map.inl R A B a\u2082 :=\nprod.ext rfl (by simp)\n\nlemma inr_map_mul (b\u2081 b\u2082 : B) : linear_map.inr R A B (b\u2081 * b\u2082) =\n  linear_map.inr R A B b\u2081 * linear_map.inr R A B b\u2082 :=\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\u2082)\n\nvariables [comm_semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M\u2082]\nvariables [module R M] [module R M\u2082]\n\n/-- `linear_map.prod_map` as an `algebra_hom` -/\n@[simps]\ndef prod_map_alg_hom : (module.End R M) \u00d7 (module.End R M\u2082) \u2192\u2090[R] module.End R (M \u00d7 M\u2082) :=\n{ commutes' := \u03bb _, rfl, ..prod_map_ring_hom R M M\u2082 }\n\nend linear_map\n\nnamespace linear_map\nopen submodule\n\nvariables [semiring R]\n  [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n  [module R M] [module R M\u2082] [module R M\u2083] [module R M\u2084]\n\nlemma range_coprod (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) :\n  (f.coprod g).range = f.range \u2294 g.range :=\nsubmodule.ext $ \u03bb x, by simp [mem_sup]\n\nlemma is_compl_range_inl_inr : is_compl (inl R M M\u2082).range (inr R M M\u2082).range :=\nbegin\n  split,\n  { rintros \u27e8_, _\u27e9 \u27e8\u27e8x, hx\u27e9, \u27e8y, hy\u27e9\u27e9,\n    simp only [prod.ext_iff, inl_apply, inr_apply, mem_bot] at hx hy \u22a2,\n    exact \u27e8hy.1.symm, hx.2.symm\u27e9 },\n  { rintros \u27e8x, y\u27e9 -,\n    simp only [mem_sup, mem_range, exists_prop],\n    refine \u27e8(x, 0), \u27e8x, rfl\u27e9, (0, y), \u27e8y, rfl\u27e9, _\u27e9,\n    simp }\nend\n\nlemma sup_range_inl_inr : (inl R M M\u2082).range \u2294 (inr R M M\u2082).range = \u22a4 :=\nis_compl_range_inl_inr.sup_eq_top\n\nlemma disjoint_inl_inr : disjoint (inl R M M\u2082).range (inr R M M\u2082).range :=\nby simp [disjoint_def, @eq_comm M 0, @eq_comm M\u2082 0] {contextual := tt}; intros; refl\ntheorem map_coprod_prod (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083)\n  (p : submodule R M) (q : submodule R M\u2082) :\n  map (coprod f g) (p.prod q) = map f p \u2294 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 _ \u27e8x, \u27e8h\u2081, h\u2082\u27e9, rfl\u27e9,\n    exact mem_sup.2 \u27e8_, \u27e8_, h\u2081, rfl\u27e9, _, \u27e8_, h\u2082, rfl\u27e9, rfl\u27e9 },\n  { exact \u03bb x hx, \u27e8(x, 0), by simp [hx]\u27e9 },\n  { exact \u03bb x hx, \u27e8(0, x), by simp [hx]\u27e9 }\nend\n\ntheorem comap_prod_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083)\n  (p : submodule R M\u2082) (q : submodule R M\u2083) :\n  comap (prod f g) (p.prod q) = comap f p \u2293 comap g q :=\nsubmodule.ext $ \u03bb x, iff.rfl\n\ntheorem prod_eq_inf_comap (p : submodule R M) (q : submodule R M\u2082) :\n  p.prod q = p.comap (linear_map.fst R M M\u2082) \u2293 q.comap (linear_map.snd R M M\u2082) :=\nsubmodule.ext $ \u03bb x, iff.rfl\n\ntheorem prod_eq_sup_map (p : submodule R M) (q : submodule R M\u2082) :\n  p.prod q = p.map (linear_map.inl R M M\u2082) \u2294 q.map (linear_map.inr R M M\u2082) :=\nby rw [\u2190 map_coprod_prod, coprod_inl_inr, map_id]\n\nlemma span_inl_union_inr {s : set M} {t : set M\u2082} :\n  span R (inl R M  M\u2082 '' s \u222a inr R M M\u2082 '' t) = (span R s).prod (span R t) :=\nby rw [span_union, prod_eq_sup_map, \u2190 span_image, \u2190 span_image]\n\n@[simp] lemma ker_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) :\n  ker (prod f g) = ker f \u2293 ker g :=\nby rw [ker, \u2190 prod_bot, comap_prod_prod]; refl\n\nlemma range_prod_le (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) :\n  range (prod f g) \u2264 (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 \u27e8\u27e8x, rfl\u27e9, \u27e8x, rfl\u27e9\u27e9\nend\n\nlemma ker_prod_ker_le_ker_coprod {M\u2082 : Type*} [add_comm_group M\u2082] [module R M\u2082]\n  {M\u2083 : Type*} [add_comm_group M\u2083] [module R M\u2083]\n  (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) :\n  (ker f).prod (ker g) \u2264 ker (f.coprod g) :=\nby { rintros \u27e8y, z\u27e9, simp {contextual := tt} }\n\nlemma ker_coprod_of_disjoint_range {M\u2082 : Type*} [add_comm_group M\u2082] [module R M\u2082]\n  {M\u2083 : Type*} [add_comm_group M\u2083] [module R M\u2083]\n  (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) (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 \u27e8y, z\u27e9 h,\n  simp only [mem_ker, mem_prod, coprod_apply] at h \u22a2,\n  have : f y \u2208 f.range \u2293 g.range,\n  { simp only [true_and, mem_range, mem_inf, exists_apply_eq_apply],\n    use -z,\n    rwa [eq_comm, map_neg, \u2190 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\u2082]\nvariables [module R M] [module R M\u2082]\n\nlemma sup_eq_range (p q : submodule R M) : p \u2294 q = (p.subtype.coprod q.subtype).range :=\nsubmodule.ext $ \u03bb x, by simp [submodule.mem_sup, set_like.exists]\n\nvariables (p : submodule R M) (q : submodule R M\u2082)\n\n@[simp] theorem map_inl : p.map (inl R M M\u2082) = prod p \u22a5 :=\nby { ext \u27e8x, y\u27e9, 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\u2082) = prod \u22a5 q :=\nby ext \u27e8x, y\u27e9; simp [and.left_comm, eq_comm]\n\n@[simp] theorem comap_fst : p.comap (fst R M M\u2082) = prod p \u22a4 :=\nby ext \u27e8x, y\u27e9; simp\n\n@[simp] theorem comap_snd : q.comap (snd R M M\u2082) = prod \u22a4 q :=\nby ext \u27e8x, y\u27e9; simp\n\n@[simp] theorem prod_comap_inl : (prod p q).comap (inl R M M\u2082) = p := by ext; simp\n\n@[simp] theorem prod_comap_inr : (prod p q).comap (inr R M M\u2082) = q := by ext; simp\n\n@[simp] theorem prod_map_fst : (prod p q).map (fst R M M\u2082) = p :=\nby ext x; simp [(\u27e80, zero_mem _\u27e9 : \u2203 x, x \u2208 q)]\n\n@[simp] theorem prod_map_snd : (prod p q).map (snd R M M\u2082) = q :=\nby ext x; simp [(\u27e80, zero_mem _\u27e9 : \u2203 x, x \u2208 p)]\n\n@[simp] theorem ker_inl : (inl R M M\u2082).ker = \u22a5 :=\nby rw [ker, \u2190 prod_bot, prod_comap_inl]\n\n@[simp] theorem ker_inr : (inr R M M\u2082).ker = \u22a5 :=\nby rw [ker, \u2190 prod_bot, prod_comap_inr]\n\n@[simp] theorem range_fst : (fst R M M\u2082).range = \u22a4 :=\nby rw [range_eq_map, \u2190 prod_top, prod_map_fst]\n\n@[simp] theorem range_snd : (snd R M M\u2082).range = \u22a4 :=\nby rw [range_eq_map, \u2190 prod_top, prod_map_snd]\n\nvariables (R M M\u2082)\n\n/-- `M` as a submodule of `M \u00d7 N`. -/\ndef fst : submodule R (M \u00d7 M\u2082) := (\u22a5 : submodule R M\u2082).comap (linear_map.snd R M M\u2082)\n\n/-- `M` as a submodule of `M \u00d7 N` is isomorphic to `M`. -/\n@[simps] def fst_equiv : submodule.fst R M M\u2082 \u2243\u2097[R] M :=\n{ to_fun := \u03bb x, x.1.1,\n  inv_fun := \u03bb m, \u27e8\u27e8m, 0\u27e9, by tidy\u27e9,\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\u2082).map (linear_map.fst R M M\u2082) = \u22a4 :=\nby tidy\nlemma fst_map_snd : (submodule.fst R M M\u2082).map (linear_map.snd R M M\u2082) = \u22a5 :=\nby { tidy, exact 0, }\n\n/-- `N` as a submodule of `M \u00d7 N`. -/\ndef snd : submodule R (M \u00d7 M\u2082) := (\u22a5 : submodule R M).comap (linear_map.fst R M M\u2082)\n\n/-- `N` as a submodule of `M \u00d7 N` is isomorphic to `N`. -/\n@[simps] def snd_equiv : submodule.snd R M M\u2082 \u2243\u2097[R] M\u2082 :=\n{ to_fun := \u03bb x, x.1.2,\n  inv_fun := \u03bb n, \u27e8\u27e80, n\u27e9, by tidy\u27e9,\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\u2082).map (linear_map.fst R M M\u2082) = \u22a5 :=\nby { tidy, exact 0, }\nlemma snd_map_snd : (submodule.snd R M M\u2082).map (linear_map.snd R M M\u2082) = \u22a4 :=\nby tidy\n\nlemma fst_sup_snd : submodule.fst R M M\u2082 \u2294 submodule.snd R M M\u2082 = \u22a4 :=\nbegin\n  rw eq_top_iff,\n  rintro \u27e8m, n\u27e9 -,\n  rw [show (m, n) = (m, 0) + (0, n), by simp],\n  apply submodule.add_mem (submodule.fst R M M\u2082 \u2294 submodule.snd R M M\u2082),\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\u2082 \u2293 submodule.snd R M M\u2082 = \u22a5 := by tidy\n\nlemma le_prod_iff {p\u2081 : submodule R M} {p\u2082 : submodule R M\u2082} {q : submodule R (M \u00d7 M\u2082)} :\n  q \u2264 p\u2081.prod p\u2082 \u2194 map (linear_map.fst R M M\u2082) q \u2264 p\u2081 \u2227 map (linear_map.snd R M M\u2082) q \u2264 p\u2082 :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros x \u27e8\u27e8y1,y2\u27e9, \u27e8hy1,rfl\u27e9\u27e9, exact (h hy1).1 },\n    { rintros x \u27e8\u27e8y1,y2\u27e9, \u27e8hy1,rfl\u27e9\u27e9, exact (h hy1).2 }, },\n  { rintros \u27e8hH, hK\u27e9 \u27e8x1, x2\u27e9 h, exact \u27e8hH \u27e8_ , h, rfl\u27e9, hK \u27e8 _, h, rfl\u27e9\u27e9, }\nend\n\nlemma prod_le_iff {p\u2081 : submodule R M} {p\u2082 : submodule R M\u2082} {q : submodule R (M \u00d7 M\u2082)} :\n  p\u2081.prod p\u2082 \u2264 q \u2194 map (linear_map.inl R M M\u2082) p\u2081 \u2264 q \u2227 map (linear_map.inr R M M\u2082) p\u2082 \u2264 q :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros _ \u27e8x, hx, rfl\u27e9, apply h, exact \u27e8hx, zero_mem p\u2082\u27e9, },\n    { rintros _ \u27e8x, hx, rfl\u27e9, apply h, exact \u27e8zero_mem p\u2081, hx\u27e9, }, },\n  { rintros \u27e8hH, hK\u27e9 \u27e8x1, x2\u27e9 \u27e8h1, h2\u27e9,\n    have h1' : (linear_map.inl R _ _) x1 \u2208 q, { apply hH, simpa using h1, },\n    have h2' : (linear_map.inr R _ _) x2 \u2208 q, { apply hK, simpa using h2, },\n    simpa using add_mem h1' h2', }\nend\n\nlemma prod_eq_bot_iff {p\u2081 : submodule R M} {p\u2082 : submodule R M\u2082} :\n  p\u2081.prod p\u2082 = \u22a5 \u2194 p\u2081 = \u22a5 \u2227 p\u2082 = \u22a5 :=\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\u2081 : submodule R M} {p\u2082 : submodule R M\u2082} :\n  p\u2081.prod p\u2082 = \u22a4 \u2194 p\u2081 = \u22a4 \u2227 p\u2082 = \u22a4 :=\nby simp only [eq_top_iff, le_prod_iff, \u2190 (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 \u00d7 N) \u2243\u2097[R] (N \u00d7 M) :=\n{ to_fun := prod.swap,\n  map_smul' := \u03bb r \u27e8m, n\u27e9, rfl,\n  ..add_equiv.prod_comm }\n\nsection\n\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\nvariables {module_M : module R M} {module_M\u2082 : module R M\u2082}\nvariables {module_M\u2083 : module R M\u2083} {module_M\u2084 : module R M\u2084}\nvariables (e\u2081 : M \u2243\u2097[R] M\u2082) (e\u2082 : M\u2083 \u2243\u2097[R] M\u2084)\n\n/-- Product of linear equivalences; the maps come from `equiv.prod_congr`. -/\nprotected def prod :\n  (M \u00d7 M\u2083) \u2243\u2097[R] (M\u2082 \u00d7 M\u2084) :=\n{ map_smul' := \u03bb c x, prod.ext (e\u2081.map_smul\u209b\u2097 c _) (e\u2082.map_smul\u209b\u2097 c _),\n  .. e\u2081.to_add_equiv.prod_congr e\u2082.to_add_equiv }\n\nlemma prod_symm : (e\u2081.prod e\u2082).symm = e\u2081.symm.prod e\u2082.symm := rfl\n\n@[simp] lemma prod_apply (p) :\n  e\u2081.prod e\u2082 p = (e\u2081 p.1, e\u2082 p.2) := rfl\n\n@[simp, norm_cast] lemma coe_prod :\n  (e\u2081.prod e\u2082 : (M \u00d7 M\u2083) \u2192\u2097[R] (M\u2082 \u00d7 M\u2084)) = (e\u2081 : M \u2192\u2097[R] M\u2082).prod_map (e\u2082 : M\u2083 \u2192\u2097[R] M\u2084) := rfl\n\nend\n\nsection\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_group M\u2084]\nvariables {module_M : module R M} {module_M\u2082 : module R M\u2082}\nvariables {module_M\u2083 : module R M\u2083} {module_M\u2084 : module R M\u2084}\nvariables (e\u2081 : M \u2243\u2097[R] M\u2082) (e\u2082 : M\u2083 \u2243\u2097[R] M\u2084)\n\n/-- Equivalence given by a block lower diagonal matrix. `e\u2081` and `e\u2082` are diagonal square blocks,\n  and `f` is a rectangular block below the diagonal. -/\nprotected def skew_prod (f : M \u2192\u2097[R] M\u2084) :\n  (M \u00d7 M\u2083) \u2243\u2097[R] M\u2082 \u00d7 M\u2084 :=\n{ inv_fun := \u03bb p : M\u2082 \u00d7 M\u2084, (e\u2081.symm p.1, e\u2082.symm (p.2 - f (e\u2081.symm p.1))),\n  left_inv := \u03bb p, by simp,\n  right_inv := \u03bb p, by simp,\n  .. ((e\u2081 : M \u2192\u2097[R] M\u2082).comp (linear_map.fst R M M\u2083)).prod\n    ((e\u2082 : M\u2083 \u2192\u2097[R] M\u2084).comp (linear_map.snd R M M\u2083) +\n      f.comp (linear_map.fst R M M\u2083)) }\n\n@[simp] lemma skew_prod_apply (f : M \u2192\u2097[R] M\u2084) (x) :\n  e\u2081.skew_prod e\u2082 f x = (e\u2081 x.1, e\u2082 x.2 + f x.1) := rfl\n\n@[simp] lemma skew_prod_symm_apply (f : M \u2192\u2097[R] M\u2084) (x) :\n  (e\u2081.skew_prod e\u2082 f).symm x = (e\u2081.symm x.1, e\u2082.symm (x.2 - f (e\u2081.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\u2082] [add_comm_group M\u2083]\nvariables [module R M] [module R M\u2082] [module R M\u2083]\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 \u2192\u2097[R] M\u2082} {g : M \u2192\u2097[R] M\u2083} (h : ker f \u2294 ker g = \u22a4) :\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, \u2190 sub_mem_ker_iff],\n  have : y - x \u2208 ker f \u2294 ker g, { simp only [h, mem_top] },\n  rcases mem_sup.1 this with \u27e8x', hx', y', hy', H\u27e9,\n  refine \u27e8x' + x, _, _\u27e9,\n  { rwa add_sub_cancel },\n  { rwa [\u2190 eq_sub_iff_add_eq.1 H, add_sub_add_right_eq_sub, \u2190 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 \u00d7 N \u2192\u2097[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 \u00d7 N \u2192\u2097[R] M) (K\u03c6 : \u03a3 K : submodule R M, K \u2243\u2097[R] M) :\n  M \u00d7 N \u2192\u2097[R] M :=\n(K\u03c6.1.subtype.comp K\u03c6.2.symm.to_linear_map).comp f\n\nlemma tunnel_aux_injective\n  (f : M \u00d7 N \u2192\u2097[R] M) (i : injective f) (K\u03c6 : \u03a3 K : submodule R M, K \u2243\u2097[R] M) :\n  injective (tunnel_aux f K\u03c6) :=\n(subtype.val_injective.comp K\u03c6.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 \u00d7 N \u2192\u2097[R] M) (i : injective f) :\n  \u2115 \u2192 \u03a3 (K : submodule R M), K \u2243\u2097[R] M\n| 0 := \u27e8\u22a4, linear_equiv.of_top \u22a4 rfl\u27e9\n| (n+1) :=\n\u27e8(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)\u27e9\n\n/--\nGive an injective map `f : M \u00d7 N \u2192\u2097[R] M` we can find a nested sequence of submodules\nall isomorphic to `M`.\n-/\ndef tunnel (f : M \u00d7 N \u2192\u2097[R] M) (i : injective f) : \u2115 \u2192o (submodule R M)\u1d52\u1d48 :=\n\u27e8\u03bb n, (tunnel' f i n).1, monotone_nat_of_le_succ (\u03bb n, begin\n    dsimp [tunnel', tunnel_aux],\n    rw [submodule.map_comp, submodule.map_comp],\n    apply submodule.map_subtype_le,\n  end)\u27e9\n\n/--\nGive an injective map `f : M \u00d7 N \u2192\u2097[R] M` we can find a sequence of submodules\nall isomorphic to `N`.\n-/\ndef tailing (f : M \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) : 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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) : tailing f i n \u2243\u2097[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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\n  tailing f i n \u2264 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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\n  tailing f i n \u2294 tunnel f i (n+1) \u2264 tunnel f i n :=\nbegin\n  dsimp [tailing, tunnel, tunnel', tunnel_aux],\n  rw [\u2190submodule.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 \u00d7 N \u2192\u2097[R] M) (i : injective f) : \u2115 \u2192 submodule R M :=\npartial_sups (tailing f i)\n\n@[simp] lemma tailings_zero (f : M \u00d7 N \u2192\u2097[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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\n  tailings f i (n+1) = tailings f i n \u2294 tailing f i (n+1) :=\nby simp [tailings]\n\nlemma tailings_disjoint_tunnel (f : M \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\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\u2082]\n  [add_comm_group M\u2083] [add_comm_group M\u2084] [module R M] [module R M\u2082]\n  [module R M\u2083] [module R M\u2084] (f : M \u2192\u2097[R] M\u2082) (g : M\u2083 \u2192\u2097[R] M\u2084)\n\n/-- Graph of a linear map. -/\ndef graph : submodule R (M \u00d7 M\u2082) :=\n{ carrier := {p | p.2 = f p.1},\n  add_mem' := \u03bb 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' := \u03bb c x (hx : _ = _),\n  begin\n    change _ \u2022 _ = f (_ \u2022 _),\n    rw [map_smul, hx]\n  end }\n\n@[simp] lemma mem_graph_iff (x : M \u00d7 M\u2082) : x \u2208 f.graph \u2194 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 _ = _ \u2194 -(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 \u27e8\u03bb hx, \u27e8x.1, prod.ext rfl hx.symm\u27e9, \u03bb \u27e8u, hu\u27e9, hu \u25b8 rfl\u27e9\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 `\u03b1` and `\u03b2` to `\u03b1 \u00d7\u2097 \u03b2`.\n\n## Notation\n\n* `\u03b1 \u00d7\u2097 \u03b2`: `\u03b1 \u00d7 \u03b2` 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 `\u03a0\u2097 i, \u03b1 i`.\n* `data.psigma.order`: Lexicographic order on `\u03a3' i, \u03b1 i`.\n* `data.sigma.order`: Lexicographic order on `\u03a3 i, \u03b1 i`.\n-/\n\n\nvariable {\u03b1 \u03b2 \u03b3 : Type _}\n\nnamespace Prod.Lex\n\n-- mathport name: \u00abexpr \u00d7\u2097 \u00bb\nnotation:35 \u03b1 \" \u00d7\u2097 \" \u03b2:34 => Lex (Prod \u03b1 \u03b2)\n\nunsafe instance [has_to_format \u03b1] [has_to_format \u03b2] : has_to_format (\u03b1 \u00d7\u2097 \u03b2) :=\n  prod.has_to_format\n\n#print Prod.Lex.decidableEq /-\ninstance decidableEq (\u03b1 \u03b2 : Type _) [DecidableEq \u03b1] [DecidableEq \u03b2] : DecidableEq (\u03b1 \u00d7\u2097 \u03b2) :=\n  Prod.decidableEq\n#align prod.lex.decidable_eq Prod.Lex.decidableEq\n-/\n\n#print Prod.Lex.inhabited /-\ninstance inhabited (\u03b1 \u03b2 : Type _) [Inhabited \u03b1] [Inhabited \u03b2] : Inhabited (\u03b1 \u00d7\u2097 \u03b2) :=\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 (\u03b1 \u03b2 : Type _) [LT \u03b1] [LE \u03b2] : LE (\u03b1 \u00d7\u2097 \u03b2) where le := Prod.Lex (\u00b7 < \u00b7) (\u00b7 \u2264 \u00b7)\n#align prod.lex.has_le Prod.Lex.instLE\n-/\n\n#print Prod.Lex.instLT /-\ninstance instLT (\u03b1 \u03b2 : Type _) [LT \u03b1] [LT \u03b2] : LT (\u03b1 \u00d7\u2097 \u03b2) where lt := Prod.Lex (\u00b7 < \u00b7) (\u00b7 < \u00b7)\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LT.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2), Iff (LE.le.{max u1 u2} (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.Lex.instLE.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) => (Prod.{u1, u2} \u03b1 \u03b2) -> (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (toLex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) a) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) => (Prod.{u1, u2} \u03b1 \u03b2) -> (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (toLex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) b)) (Or (LT.lt.{u1} \u03b1 _inst_1 (Prod.fst.{u1, u2} \u03b1 \u03b2 a) (Prod.fst.{u1, u2} \u03b1 \u03b2 b)) (And (Eq.{succ u1} \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 a) (Prod.fst.{u1, u2} \u03b1 \u03b2 b)) (LE.le.{u2} \u03b2 _inst_2 (Prod.snd.{u1, u2} \u03b1 \u03b2 a) (Prod.snd.{u1, u2} \u03b1 \u03b2 b))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LT.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (a : Prod.{u2, u1} \u03b1 \u03b2) (b : Prod.{u2, u1} \u03b1 \u03b2), Iff (LE.le.{max u2 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) a) (Prod.Lex.instLE.{u2, u1} \u03b1 \u03b2 _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} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (Prod.{u2, u1} \u03b1 \u03b2) (fun (_x : Prod.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (toLex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) 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} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (Prod.{u2, u1} \u03b1 \u03b2) (fun (_x : Prod.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (toLex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) b)) (Or (LT.lt.{u2} \u03b1 _inst_1 (Prod.fst.{u2, u1} \u03b1 \u03b2 a) (Prod.fst.{u2, u1} \u03b1 \u03b2 b)) (And (Eq.{succ u2} \u03b1 (Prod.fst.{u2, u1} \u03b1 \u03b2 a) (Prod.fst.{u2, u1} \u03b1 \u03b2 b)) (LE.le.{u1} \u03b2 _inst_2 (Prod.snd.{u2, u1} \u03b1 \u03b2 a) (Prod.snd.{u2, u1} \u03b1 \u03b2 b))))\nCase conversion may be inaccurate. Consider using '#align prod.lex.le_iff Prod.Lex.le_iff\u2093'. -/\ntheorem le_iff [LT \u03b1] [LE \u03b2] (a b : \u03b1 \u00d7 \u03b2) :\n    toLex a \u2264 toLex b \u2194 a.1 < b.1 \u2228 a.1 = b.1 \u2227 a.2 \u2264 b.2 :=\n  Prod.lex_def (\u00b7 < \u00b7) (\u00b7 \u2264 \u00b7)\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LT.{u1} \u03b1] [_inst_2 : LT.{u2} \u03b2] (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2), Iff (LT.lt.{max u1 u2} (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.Lex.instLT.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) => (Prod.{u1, u2} \u03b1 \u03b2) -> (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (toLex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) a) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) => (Prod.{u1, u2} \u03b1 \u03b2) -> (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (toLex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) b)) (Or (LT.lt.{u1} \u03b1 _inst_1 (Prod.fst.{u1, u2} \u03b1 \u03b2 a) (Prod.fst.{u1, u2} \u03b1 \u03b2 b)) (And (Eq.{succ u1} \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 a) (Prod.fst.{u1, u2} \u03b1 \u03b2 b)) (LT.lt.{u2} \u03b2 _inst_2 (Prod.snd.{u1, u2} \u03b1 \u03b2 a) (Prod.snd.{u1, u2} \u03b1 \u03b2 b))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LT.{u2} \u03b1] [_inst_2 : LT.{u1} \u03b2] (a : Prod.{u2, u1} \u03b1 \u03b2) (b : Prod.{u2, u1} \u03b1 \u03b2), Iff (LT.lt.{max u2 u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) a) (Prod.Lex.instLT.{u2, u1} \u03b1 \u03b2 _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} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (Prod.{u2, u1} \u03b1 \u03b2) (fun (_x : Prod.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (toLex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) 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} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (Prod.{u2, u1} \u03b1 \u03b2) (fun (_x : Prod.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (toLex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) b)) (Or (LT.lt.{u2} \u03b1 _inst_1 (Prod.fst.{u2, u1} \u03b1 \u03b2 a) (Prod.fst.{u2, u1} \u03b1 \u03b2 b)) (And (Eq.{succ u2} \u03b1 (Prod.fst.{u2, u1} \u03b1 \u03b2 a) (Prod.fst.{u2, u1} \u03b1 \u03b2 b)) (LT.lt.{u1} \u03b2 _inst_2 (Prod.snd.{u2, u1} \u03b1 \u03b2 a) (Prod.snd.{u2, u1} \u03b1 \u03b2 b))))\nCase conversion may be inaccurate. Consider using '#align prod.lex.lt_iff Prod.Lex.lt_iff\u2093'. -/\ntheorem lt_iff [LT \u03b1] [LT \u03b2] (a b : \u03b1 \u00d7 \u03b2) :\n    toLex a < toLex b \u2194 a.1 < b.1 \u2228 a.1 = b.1 \u2227 a.2 < b.2 :=\n  Prod.lex_def (\u00b7 < \u00b7) (\u00b7 < \u00b7)\n#align prod.lex.lt_iff Prod.Lex.lt_iff\n\n#print Prod.Lex.preorder /-\n/-- Dictionary / lexicographic preorder for pairs. -/\ninstance preorder (\u03b1 \u03b2 : Type _) [Preorder \u03b1] [Preorder \u03b2] : Preorder (\u03b1 \u00d7\u2097 \u03b2) :=\n  { Prod.Lex.instLE \u03b1 \u03b2,\n    Prod.Lex.instLT \u03b1 \u03b2 with\n    le_refl := refl_of <| Prod.Lex _ _\n    le_trans := fun _ _ _ => trans_of <| Prod.Lex _ _\n    lt_iff_le_not_le := fun x\u2081 x\u2082 =>\n      match x\u2081, x\u2082 with\n      | toLex (a\u2081, b\u2081), toLex (a\u2082, b\u2082) => by\n        constructor\n        \u00b7 rintro (\u27e8_, _, hlt\u27e9 | \u27e8_, hlt\u27e9)\n          \u00b7 constructor\n            \u00b7 left\n              assumption\n            \u00b7 rintro \u27e8\u27e9\n              \u00b7 apply lt_asymm hlt\n                assumption\n              \u00b7 apply lt_irrefl _ hlt\n          \u00b7 constructor\n            \u00b7 right\n              rw [lt_iff_le_not_le] at hlt\n              exact hlt.1\n            \u00b7 rintro \u27e8\u27e9\n              \u00b7 apply lt_irrefl a\u2081\n                assumption\n              \u00b7 rw [lt_iff_le_not_le] at hlt\n                apply hlt.2\n                assumption\n        \u00b7 rintro \u27e8\u27e8\u27e9, h\u2082r\u27e9\n          \u00b7 left\n            assumption\n          \u00b7 right\n            rw [lt_iff_le_not_le]\n            constructor\n            \u00b7 assumption\n            \u00b7 intro h\n              apply h\u2082r\n              right\n              exact h }\n#align prod.lex.preorder Prod.Lex.preorder\n-/\n\nsection Preorder\n\nvariable [PartialOrder \u03b1] [Preorder \u03b2]\n\n/- warning: prod.lex.to_lex_mono -> Prod.Lex.toLex_mono is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2], Monotone.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.preorder.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2) (Prod.Lex.preorder.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) => (Prod.{u1, u2} \u03b1 \u03b2) -> (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (toLex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : PartialOrder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2], Monotone.{max u2 u1, max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Prod.instPreorderProd.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 _inst_1) _inst_2) (Prod.Lex.preorder.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 _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} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (Prod.{u2, u1} \u03b1 \u03b2) (fun (_x : Prod.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (toLex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)))\nCase conversion may be inaccurate. Consider using '#align prod.lex.to_lex_mono Prod.Lex.toLex_mono\u2093'. -/\ntheorem toLex_mono : Monotone (toLex : \u03b1 \u00d7 \u03b2 \u2192 \u03b1 \u00d7\u2097 \u03b2) :=\n  by\n  rintro \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 \u27e8ha, hb\u27e9\n  obtain rfl | ha : a\u2081 = a\u2082 \u2228 _ := ha.eq_or_lt\n  \u00b7 exact right _ hb\n  \u00b7 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2], StrictMono.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.preorder.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1) _inst_2) (Prod.Lex.preorder.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 _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} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (fun (_x : Equiv.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) => (Prod.{u1, u2} \u03b1 \u03b2) -> (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (Equiv.hasCoeToFun.{succ (max u1 u2), succ (max u1 u2)} (Prod.{u1, u2} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2))) (toLex.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : PartialOrder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2], StrictMono.{max u2 u1, max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Lex.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Prod.instPreorderProd.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 _inst_1) _inst_2) (Prod.Lex.preorder.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 _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} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (Prod.{u2, u1} \u03b1 \u03b2) (fun (_x : Prod.{u2, u1} \u03b1 \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Prod.{u2, u1} \u03b1 \u03b2) => Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ (max u2 u1), succ (max u2 u1)} (Prod.{u2, u1} \u03b1 \u03b2) (Lex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2))) (toLex.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2)))\nCase conversion may be inaccurate. Consider using '#align prod.lex.to_lex_strict_mono Prod.Lex.toLex_strictMono\u2093'. -/\ntheorem toLex_strictMono : StrictMono (toLex : \u03b1 \u00d7 \u03b2 \u2192 \u03b1 \u00d7\u2097 \u03b2) :=\n  by\n  rintro \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 h\n  obtain rfl | ha : a\u2081 = a\u2082 \u2228 _ := h.le.1.eq_or_lt\n  \u00b7 exact right _ (Prod.mk_lt_mk_iff_right.1 h)\n  \u00b7 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 (\u03b1 \u03b2 : Type _) [PartialOrder \u03b1] [PartialOrder \u03b2] : PartialOrder (\u03b1 \u00d7\u2097 \u03b2) :=\n  { Prod.Lex.preorder \u03b1 \u03b2 with\n    le_antisymm :=\n      by\n      haveI : IsStrictOrder \u03b1 (\u00b7 < \u00b7) :=\n        { irrefl := lt_irrefl\n          trans := fun _ _ _ => lt_trans }\n      haveI : IsAntisymm \u03b2 (\u00b7 \u2264 \u00b7) := \u27e8fun _ _ => le_antisymm\u27e9\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 (\u03b1 \u03b2 : Type _) [LinearOrder \u03b1] [LinearOrder \u03b2] : LinearOrder (\u03b1 \u00d7\u2097 \u03b2) :=\n  { Prod.Lex.partialOrder \u03b1 \u03b2 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 \u03b1] [Preorder \u03b2] [OrderBot \u03b1] [OrderBot \u03b2] : OrderBot (\u03b1 \u00d7\u2097 \u03b2)\n    where\n  bot := toLex \u22a5\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 \u03b1] [Preorder \u03b2] [OrderTop \u03b1] [OrderTop \u03b2] : OrderTop (\u03b1 \u00d7\u2097 \u03b2)\n    where\n  top := toLex \u22a4\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 \u03b1] [Preorder \u03b2] [BoundedOrder \u03b1] [BoundedOrder \u03b2] :\n    BoundedOrder (\u03b1 \u00d7\u2097 \u03b2) :=\n  { Lex.orderBot, Lex.orderTop with }\n#align prod.lex.bounded_order Prod.Lex.boundedOrder\n-/\n\ninstance [Preorder \u03b1] [Preorder \u03b2] [DenselyOrdered \u03b1] [DenselyOrdered \u03b2] :\n    DenselyOrdered (\u03b1 \u00d7\u2097 \u03b2) :=\n  \u27e8by\n    rintro _ _ (@\u27e8a\u2081, b\u2081, a\u2082, b\u2082, h\u27e9 | @\u27e8a, b\u2081, b\u2082, h\u27e9)\n    \u00b7 obtain \u27e8c, h\u2081, h\u2082\u27e9 := exists_between h\n      exact \u27e8(c, b\u2081), left _ _ h\u2081, left _ _ h\u2082\u27e9\n    \u00b7 obtain \u27e8c, h\u2081, h\u2082\u27e9 := exists_between h\n      exact \u27e8(a, c), right _ h\u2081, right _ h\u2082\u27e9\u27e9\n\n#print Prod.Lex.noMaxOrder_of_left /-\ninstance noMaxOrder_of_left [Preorder \u03b1] [Preorder \u03b2] [NoMaxOrder \u03b1] : NoMaxOrder (\u03b1 \u00d7\u2097 \u03b2) :=\n  \u27e8by\n    rintro \u27e8a, b\u27e9\n    obtain \u27e8c, h\u27e9 := exists_gt a\n    exact \u27e8\u27e8c, b\u27e9, left _ _ h\u27e9\u27e9\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 \u03b1] [Preorder \u03b2] [NoMinOrder \u03b1] : NoMinOrder (\u03b1 \u00d7\u2097 \u03b2) :=\n  \u27e8by\n    rintro \u27e8a, b\u27e9\n    obtain \u27e8c, h\u27e9 := exists_lt a\n    exact \u27e8\u27e8c, b\u27e9, left _ _ h\u27e9\u27e9\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 \u03b1] [Preorder \u03b2] [NoMaxOrder \u03b2] : NoMaxOrder (\u03b1 \u00d7\u2097 \u03b2) :=\n  \u27e8by\n    rintro \u27e8a, b\u27e9\n    obtain \u27e8c, h\u27e9 := exists_gt b\n    exact \u27e8\u27e8a, c\u27e9, right _ h\u27e9\u27e9\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 \u03b1] [Preorder \u03b2] [NoMinOrder \u03b2] : NoMinOrder (\u03b1 \u00d7\u2097 \u03b2) :=\n  \u27e8by\n    rintro \u27e8a, b\u27e9\n    obtain \u27e8c, h\u27e9 := exists_lt b\n    exact \u27e8\u27e8a, c\u27e9, right _ h\u27e9\u27e9\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 \u27f6 Spec \u0393(X)` is an\n  isomorphism.\n* `algebraic_geometry.Scheme.iso_Spec`: The canonical isomorphism `X \u2245 Spec \u0393(X)` for an affine\n  scheme.\n* `algebraic_geometry.AffineScheme.equiv_CommRing`: The equivalence of categories\n  `AffineScheme \u224c CommRing\u1d52\u1d56` given by `AffineScheme.Spec : CommRing\u1d52\u1d56 \u2964 AffineScheme` and\n  `AffineScheme.\u0393 : AffineScheme\u1d52\u1d56 \u2964 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 \ud835\udcaa\u2093(U) \u27f6 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 \u27f6 Spec \u0393(X)` is an isomorphism. -/\nclass is_affine (X : Scheme) : Prop :=\n(affine : is_iso (\u0393_Spec.adjunction.unit.app X))\n\nattribute [instance] is_affine.affine\n\n/-- The canonical isomorphism `X \u2245 Spec \u0393(X)` for an affine scheme. -/\ndef Scheme.iso_Spec (X : Scheme) [is_affine X] :\n  X \u2245 Scheme.Spec.obj (op $ Scheme.\u0393.obj $ op X) :=\nas_iso (\u0393_Spec.adjunction.unit.app X)\n\nlemma mem_AffineScheme (X : Scheme) : X \u2208 AffineScheme \u2194 is_affine X :=\n\u27e8\u03bb h, \u27e8functor.ess_image.unit_is_iso h\u27e9, \u03bb h, @@mem_ess_image_of_unit_is_iso _ _ _ X h.1\u27e9\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\u1d52\u1d56) : 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 \u27f6 Y) [is_iso f] [h : is_affine Y] :\n  is_affine X :=\nby { rw [\u2190 mem_AffineScheme] at h \u22a2, 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\u1d52\u1d56 \u2964 AffineScheme := Scheme.Spec.to_ess_image\n\n/-- The forgetful functor `AffineScheme \u2964 Scheme`. -/\n@[derive [full, faithful], simps]\ndef forget_to_Scheme : AffineScheme \u2964 Scheme := Scheme.Spec.ess_image_inclusion\n\n/-- The global section functor of an affine scheme. -/\ndef \u0393 : AffineScheme\u1d52\u1d56 \u2964 CommRing := forget_to_Scheme.op \u22d9 Scheme.\u0393\n\n/-- The category of affine schemes is equivalent to the category of commutative rings. -/\ndef equiv_CommRing : AffineScheme \u224c CommRing\u1d52\u1d56 :=\nequiv_ess_image_of_reflective.symm\n\ninstance \u0393_is_equiv : is_equivalence \u0393.{u} :=\nbegin\n  haveI : is_equivalence \u0393.{u}.right_op.op := is_equivalence.of_equivalence equiv_CommRing.op,\n  exact (functor.is_equivalence_trans \u0393.{u}.right_op.op (op_op_equivalence _).functor : _),\nend\n\ninstance : has_colimits AffineScheme.{u} :=\nbegin\n  haveI := adjunction.has_limits_of_equivalence.{u} \u0393.{u},\n  haveI : has_colimits AffineScheme.{u} \u1d52\u1d56\u1d52\u1d56 := 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 \u0393.{u},\n  haveI : has_limits AffineScheme.{u} \u1d52\u1d56\u1d52\u1d56 := 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 \u27f6 Y)\n  [H : is_open_immersion f] : is_affine_open \u27e8set.range f.1.base, H.base_open.open_range\u27e9 :=\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 (\u22a4 : opens X.carrier) :=\nbegin\n  convert range_is_affine_open_of_open_immersion (\ud835\udfd9 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 \u2208 (U : set X.carrier)),\n  obtain \u27e8S, hS, hxS, hSU\u27e9 := X.affine_basis_cover_is_basis.exists_subset_of_mem_open hU U.prop,\n  refine \u27e8\u27e8S, X.affine_basis_cover_is_basis.is_open hS\u27e9, _, hxS, hSU\u27e9,\n  rcases hS with \u27e8i, rfl\u27e9,\n  exact range_is_affine_open_of_open_immersion _,\nend\n\n/-- The open immersion `Spec \ud835\udcaa\u2093(U) \u27f6 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) \u27f6 X :=\nbegin\n  haveI : is_affine (X.restrict U.open_embedding) := hU,\n  have : U.open_embedding.is_open_map.functor.obj \u22a4 = 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 \u226b\n    (X.restrict U.open_embedding).iso_Spec.inv \u226b 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 [\u2190 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 \u2190 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 \u22a4 = 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\u27e8(top_is_affine_open X).is_compact\u27e9\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 = \u22a4 :=\nbegin\n  ext1,\n  change hU.from_Spec.1.base \u207b\u00b9' (U : set X.carrier) = set.univ,\n  rw [\u2190 hU.from_Spec_range, \u2190 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 (\ud835\udfd9 (op U))).op = \ud835\udfd9 _,\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_\u0393_identity_hom_app_from_Spec {X : Scheme} {U : opens X.carrier}\n  (hU : is_affine_open U) :\n  (Spec_\u0393_identity.hom.app (X.presheaf.obj $ op U)) \u226b 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\u2081 :=\n    Spec_\u0393_identity.hom.naturality (X.presheaf.map (eq_to_hom U.open_embedding_obj_top).op),\n  rw \u2190 is_iso.comp_inv_eq at e\u2081,\n  have e\u2082 := \u0393_Spec.adjunction_unit_app_app_top (X.restrict U.open_embedding),\n  erw \u2190 e\u2082 at e\u2081,\n  simp only [functor.id_map, quiver.hom.unop_op, functor.comp_map, \u2190 functor.map_inv, \u2190 op_inv,\n    LocallyRingedSpace.\u0393_map, category.assoc, functor.right_op_map, inv_eq_to_hom] at e\u2081,\n  delta is_affine_open.from_Spec Scheme.iso_Spec,\n  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app, \u2190 e\u2081],\n  simp_rw category.assoc,\n  erw \u2190 X.presheaf.map_comp_assoc,\n  rw \u2190 op_comp,\n  have e\u2083 : U.open_embedding.is_open_map.adjunction.counit.app U \u226b\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\u2084 : X.presheaf.map _ \u226b _ = _ :=\n    (as_iso (\u0393_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\u2083, e\u2084, \u2190 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_\u0393_identity.inv.app (X.presheaf.obj $ op U) \u226b\n    (Scheme.Spec.obj _).presheaf.map (eq_to_hom hU.from_Spec_base_preimage).op :=\nby rw [\u2190 hU.Spec_\u0393_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 \u226b hU.from_Spec),\n  ext1,\n  have : hU.from_Spec.val.base '' (hU.from_Spec.val.base \u207b\u00b9' (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, \u2190 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 = \u22a4,\n  { ext1,\n    change hU.from_Spec.1.base \u207b\u00b9' (U : set X.carrier) = set.univ,\n    rw [\u2190 hU.from_Spec_range, \u2190 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 : \u2200 s, (opens.map hU.from_Spec.val.base).obj U \u2293 s = s := \u03bb s, this.symm \u25b8 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 \u2190 comp_apply,\n  congr' 2,\n  rw iso.eq_inv_comp,\n  erw hU.Spec_\u0393_identity_hom_app_from_Spec,\nend\n\nlemma Scheme.map_prime_spectrum_basic_open_of_affine (X : Scheme) [is_affine X]\n  (f : Scheme.\u0393.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 \u2190 basic_open_eq_of_affine,\n  transitivity (opens.map X.iso_Spec.hom.1.base).obj ((Scheme.Spec.obj\n    (op (Scheme.\u0393.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 \u22a4)))) ((X.presheaf.map (eq_to_hom _)) f))),\n  congr,\n  { rw [\u2190 is_iso.inv_eq_inv, is_iso.inv_inv, is_iso.iso.inv_inv, nat_iso.app_hom],\n    erw \u2190 \u0393_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 \u22a4) \u2192 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 \u27e8_, \u27e8x, rfl\u27e9, rfl\u27e9,\n    refine \u27e8_, \u27e8_, \u27e8x, rfl\u27e9, rfl\u27e9, _\u27e9,\n    exact congr_arg subtype.val (X.map_prime_spectrum_basic_open_of_affine x) },\n  { rintro \u27e8_, \u27e8_, \u27e8x, rfl\u27e9, rfl\u27e9, rfl\u27e9,\n    refine \u27e8_, \u27e8x, rfl\u27e9, _\u27e9,\n    exact congr_arg subtype.val (X.map_prime_spectrum_basic_open_of_affine x).symm }\nend\n\n/-- The prime ideal of `\ud835\udcaa\u2093(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 \u22a4 = 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 [\u2190 Scheme.comp_val_base_apply, \u2190 Scheme.comp_val_base_apply],\n  simpa only [\u2190 functor.map_comp_assoc, \u2190 functor.map_comp, \u2190 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 (\u0393_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 \u22a4 \u27f6\n          (U.open_embedding.is_open_map.functor.obj ((opens.map U.inclusion).obj U))).op \u226b\n      to_Spec_\u0393 (X.presheaf.obj $ op (U.open_embedding.is_open_map.functor.obj \u22a4)) \u226b\n      (Scheme.Spec.obj $ op $ X.presheaf.obj $ _).presheaf.map\n        (eq_to_hom (by { rw [opens.inclusion_map_eq_top], refl }) : unop _ \u27f6 \u22a4).op :=\nbegin\n  have e : (opens.map (inv (\u0393_Spec.adjunction.unit.app (X.restrict U.open_embedding))).1.base).obj\n    ((opens.map U.inclusion).obj U) = \u22a4,\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    \u0393_Spec.adjunction_unit_app_app_top],\n  simp only [category.assoc, eq_to_hom_op],\n  erw \u2190 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_\u0393_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 := \u27e8x\u27e9,\n  rcases x with \u27e8x, hx\u27e9,\n  let y := hU.prime_ideal_of \u27e8x, hx\u27e9,\n  have : hU.from_Spec.val.base y = x := hU.from_Spec_prime_ideal_of \u27e8x, hx\u27e9,\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 _ \u27e8_, _\u27e9).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 \u2190 category.assoc },\n  erw [\u2190 X.presheaf.map_comp, Spec_\u0393_naturality_assoc],\n  congr' 1,\n  simp only [\u2190 category.assoc],\n  transitivity _ \u226b (structure_sheaf (X.presheaf.obj $ op U)).1.germ \u27e8_, _\u27e9,\n  { refl },\n  convert ((structure_sheaf (X.presheaf.obj $ op U)).1.germ_res (hom_of_le le_top) \u27e8_, _\u27e9) using 2,\n  rw category.assoc,\n  erw nat_trans.naturality,\n  rw [\u2190 LocallyRingedSpace.\u0393_map_op, \u2190 LocallyRingedSpace.\u0393.map_comp_assoc, \u2190 op_comp],\n  erw \u2190 Scheme.Spec.map_comp,\n  rw [\u2190 op_comp, \u2190 X.presheaf.map_comp],\n  transitivity LocallyRingedSpace.\u0393.map (quiver.hom.op $ Scheme.Spec.map\n    (X.presheaf.map (\ud835\udfd9 (op U))).op) \u226b _,\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 : \u2124} (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 : \u2124) \u2260 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 : \u2115) [hp : fact p.prime] :\n  \u2203 (a b : \u2124) (k : \u2115), a^2 + b^2 + 1 = k * p \u2227 k < p :=\nhp.1.eq_two_or_odd.elim (\u03bb hp2, hp2.symm \u25b8 \u27e81, 0, 1, rfl, dec_trivial\u27e9) $ \u03bb hp1,\nlet \u27e8a, b, hab\u27e9 := zmod.sq_add_sq p (-1) in\nhave hab' : (p : \u2124) \u2223 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 \u27e8k, hk\u27e9 := hab' in\nhave hk0 : 0 \u2264 k, from nonneg_of_mul_nonneg_left\n  (by rw \u2190 hk; exact (add_nonneg (add_nonneg (sq_nonneg _) (sq_nonneg _)) zero_le_one))\n  (int.coe_nat_pos.2 hp.1.pos),\n\u27e8a.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 [\u2190 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      ... \u2264 (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 [\u2190 nat.mod_add_div p 2] }, ring })\n    (show 0 \u2264 p, from nat.zero_le _)\u27e9\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 : \u2124}\n  (h : a^2 + b^2 + c^2 + d^2 = 2 * m) : \u2203 w x y z : \u2124, w^2 + x^2 + y^2 + z^2 = m :=\nhave \u2200 f : fin 4 \u2192 zmod 2, (f 0)^2 + (f 1)^2 + (f 2)^2 + (f 3)^2 = 0 \u2192\n    \u2203 i : (fin 4), (f i)^2 + f (swap i 0 1)^2 = 0 \u2227 f (swap i 0 2)^2 + f (swap i 0 3)^2 = 0,\n  from dec_trivial,\nlet f : fin 4 \u2192 \u2124 :=\n  vector.nth (a ::\u1d65 b ::\u1d65 c ::\u1d65 d ::\u1d65 vector.nil) in\nlet \u27e8i, h\u03c3\u27e9 := this (coe \u2218 f) (by rw [\u2190 @zero_mul (zmod 2) _ m,\n  \u2190 show ((2 : \u2124) : zmod 2) = 0, from rfl,\n  \u2190 int.cast_mul, \u2190 h]; simp only [int.cast_add, int.cast_pow]; refl) in\nlet \u03c3 := swap i 0 in\nhave h01 : 2 \u2223 f (\u03c3 0) ^ 2 + f (\u03c3 1) ^ 2,\n  from (char_p.int_cast_eq_zero_iff (zmod 2) 2 _).1 $ by simpa [\u03c3] using h\u03c3.1,\nhave h23 : 2 \u2223 f (\u03c3 2) ^ 2 + f (\u03c3 3) ^ 2,\n  from (char_p.int_cast_eq_zero_iff (zmod 2) 2 _).1 $ by simpa using h\u03c3.2,\nlet \u27e8x, hx\u27e9 := h01 in let \u27e8y, hy\u27e9 := h23 in\n\u27e8(f (\u03c3 0) - f (\u03c3 1)) / 2, (f (\u03c3 0) + f (\u03c3 1)) / 2, (f (\u03c3 2) - f (\u03c3 3)) / 2, (f (\u03c3 2) + f (\u03c3 3)) / 2,\n  begin\n    rw [\u2190 int.sq_add_sq_of_two_mul_sq_add_sq hx.symm, add_assoc,\n      \u2190 int.sq_add_sq_of_two_mul_sq_add_sq hy.symm,\n      \u2190 mul_right_inj' (show (2 : \u2124) \u2260 0, from dec_trivial), \u2190 h, mul_add, \u2190 hx, \u2190 hy],\n    have : \u2211 x, f (\u03c3 x)^2 = \u2211 x, f x^2,\n    { conv_rhs { rw \u2190 \u03c3.sum_comp } },\n    have fin4univ : (univ : finset (fin 4)).1 = 0 ::\u2098 1 ::\u2098 2 ::\u2098 3 ::\u2098 0, from dec_trivial,\n    simpa [finset.sum_eq_multiset_sum, fin4univ, multiset.sum_cons, f, add_assoc]\n  end\u27e9\n\nprivate lemma prime_sum_four_squares (p : \u2115) [hp : _root_.fact p.prime] :\n  \u2203 a b c d : \u2124, a^2 + b^2 + c^2 + d^2 = p :=\nhave hm : \u2203 m < p, 0 < m \u2227 \u2203 a b c d : \u2124, a^2 + b^2 + c^2 + d^2 = m * p,\n  from let \u27e8a, b, k, hk\u27e9 := exists_sq_add_sq_add_one_eq_k p in\n  \u27e8k, hk.2, nat.pos_of_ne_zero $\n    (\u03bb 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\u27e9,\nlet m := nat.find hm in\nlet \u27e8a, b, c, d, (habcd : a^2 + b^2 + c^2 + d^2 = m * p)\u27e9 := (nat.find_spec hm).snd.2 in\nby haveI hm0 : _root_.fact (0 < m) := \u27e8(nat.find_spec hm).snd.1\u27e9; exact\nhave hmp : m < p, from (nat.find_spec hm).fst,\nm.mod_two_eq_zero_or_one.elim\n  (\u03bb hm2 : m % 2 = 0,\n    let \u27e8k, hk\u27e9 := (nat.dvd_iff_mod_eq_zero _ _).2 hm2 in\n    have hk0 : 0 < k, from nat.pos_of_ne_zero $ \u03bb _, 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 \u27e8lt_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 })\u27e9)\n  (\u03bb hm2 : m % 2 = 1,\n    if hm1 : m = 1 then \u27e8a, b, c, d, by simp only [hm1, habcd, int.coe_nat_one, one_mul]\u27e9\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 : \u2115),\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 : \u2115) : hnat_abs\n        ... \u2264 ((m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 : \u2115) :\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 : \u2115) ^ 2 : by simp [sq, bit0, bit1, mul_add, add_mul, add_assoc]\n        ... < 4 * (m / 2 : \u2115) ^ 2 + ((4 * (m / 2) : \u2115) * (m % 2 : \u2115) + (m % 2 : \u2115)^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 [\u2190 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 : \u2124) : zmod m) =\n          ((a^2 + b^2 + c^2 + d^2 : \u2124) : zmod m),\n        by simp [w, x, y, z, sq],\n      have hwxyz0 : ((w^2 + x^2 + y^2 + z^2 : \u2124) : zmod m) = 0,\n        by rw [hwxyzabcd, habcd, int.cast_mul, cast_coe_nat, zmod.nat_cast_self, zero_mul],\n      let \u27e8n, hn\u27e9 := ((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 (\u03bb hn0,\n        have hwxyz0 : (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs^2 + z.nat_abs^2 : \u2115) = 0,\n          by { rw [\u2190 int.coe_nat_eq_zero, \u2190 hnat_abs], rwa [hn0, mul_zero] at hn },\n        have habcd0 : (m : \u2124) \u2223 a \u2227 (m : \u2124) \u2223 b \u2227 (m : \u2124) \u2223 c \u2227 (m : \u2124) \u2223 d,\n          by simpa [@add_eq_zero_iff_eq_zero_of_nonneg \u2124 _ _ _ (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 \u27e8ma, hma\u27e9 := habcd0.1,     \u27e8mb, hmb\u27e9 := habcd0.2.1,\n            \u27e8mc, hmc\u27e9 := habcd0.2.2.1, \u27e8md, hmd\u27e9 := habcd0.2.2.2 in\n        have hmdvdp : m \u2223 p,\n          from int.coe_nat_dvd.1 \u27e8ma^2 + mb^2 + mc^2 + md^2,\n            (mul_right_inj' (show (m : \u2124) \u2260 0, from int.coe_nat_ne_zero_iff_pos.2 hm0.1)).1 $\n              by { rw [\u2190 habcd, hma, hmb, hmc, hmd], ring }\u27e9,\n        (hp.1.2 _ hmdvdp).elim hm1 (\u03bb hmeqp, by simpa [lt_irrefl, hmeqp] using hmp)),\n      have hawbxcydz : ((m : \u2115) : \u2124) \u2223 a * w + b * x + c * y + d * z,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $ by { rw [\u2190 hwxyz0], simp, ring },\n      have haxbwczdy : ((m : \u2115) : \u2124) \u2223 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 : \u2115) : \u2124) \u2223 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 : \u2115) : \u2124) \u2223 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 \u27e8s, hs\u27e9 := hawbxcydz, \u27e8t, ht\u27e9 := haxbwczdy, \u27e8u, hu\u27e9 := haybzcwdx, \u27e8v, hv\u27e9 := hazbycxdw in\n      have hn_nonneg : 0 \u2264 n,\n        from nonneg_of_mul_nonneg_left\n          (by { erw [\u2190 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, \u2190 hn, \u2190 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 : \u2124) \u2260 0, from pow_ne_zero 2\n            (int.coe_nat_ne_zero_iff_pos.2 hm0.1))).1 $\n          calc (m : \u2124)^2 * (s^2 + t^2 + u^2 + v^2) = ((m : \u2115) * s)^2 + ((m : \u2115) * t)^2 +\n              ((m : \u2115) * u)^2 + ((m : \u2115) * 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 \u27e8lt_trans hnm hmp, hn0, s, t, u, v, hstuv\u27e9)\n\nlemma sum_four_squares : \u2200 n : \u2115, \u2203 a b c d : \u2115, a^2 + b^2 + c^2 + d^2 = n\n| 0 := \u27e80, 0, 0, 0, rfl\u27e9\n| 1 := \u27e81, 0, 0, 0, rfl\u27e9\n| n@(k+2) :=\nhave hm : _root_.fact (min_fac (k+2)).prime := \u27e8min_fac_prime dec_trivial\u27e9,\nhave n / min_fac n < n := factors_lemma,\nlet \u27e8a, b, c, d, h\u2081\u27e9 := show \u2203 a b c d : \u2124, a^2 + b^2 + c^2 + d^2 = min_fac n,\n  by exactI prime_sum_four_squares (min_fac (k+2)) in\nlet \u27e8w, x, y, z, h\u2082\u27e9 := sum_four_squares (n / min_fac n) in\n\u27e8(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 [\u2190 int.coe_nat_inj', \u2190 nat.mul_div_cancel' (min_fac_dvd (k+2)), int.coe_nat_mul, \u2190 h\u2081, \u2190 h\u2082],\n    simp [sum_four_sq_mul_sum_four_sq],\n  end\u27e9\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 \u2964 D` and `G : D \u2964 C` such\nthat `\u03b7 : \ud835\udfed C \u2245 F \u22d9 G` and `\u03b5 : G \u22d9 F \u2245 \ud835\udfed 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 \u2964 D` and `G : D \u2964 C` are adjoint is using\ntwo natural transformations `\u03b7 : \ud835\udfed C \u27f6 F \u22d9 G` and `\u03b5 : G \u22d9 F \u27f6 \ud835\udfed D`, called the unit and the\ncounit, such that the compositions `F \u27f6 FGF \u27f6 F` and `G \u27f6 GFG \u27f6 G` are the identity. Unfortunately,\nit is not the case that the natural isomorphisms `\u03b7` and `\u03b5` 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 `\u03b7` 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, \u03b7, \u03b5)` as in the first paragraph such that the composite `F \u27f6 FGF \u27f6 F` is the\nidentity. By the remark above, this already implies that the tuple is an \"adjoint equivalence\",\ni.e., that the composite `G \u27f6 GFG \u27f6 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 `\u03b7` and `\u03b5`.\n* `ess_surj`: type class on a functor `F` containing the data of the preimages and the isomorphisms\n  `F.obj (preimage d) \u2245 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 \u224c D` (`\\backcong`, not to be confused with `\u2245`/`\\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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\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\u03b7 \u226b \u03b5F = 1`, or in other\n  words the composite `F \u27f6 FGF \u27f6 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 \u27f6 GFG \u27f6 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 \u27f6 F1`.\n\nSee https://stacks.math.columbia.edu/tag/001J\n-/\nstructure equivalence (C : Type u\u2081) [category.{v\u2081} C] (D : Type u\u2082) [category.{v\u2082} D] :=\nmk' ::\n(functor : C \u2964 D)\n(inverse : D \u2964 C)\n(unit_iso   : \ud835\udfed C \u2245 functor \u22d9 inverse)\n(counit_iso : inverse \u22d9 functor \u2245 \ud835\udfed D)\n(functor_unit_iso_comp' : \u2200(X : C), functor.map ((unit_iso.hom : \ud835\udfed C \u27f6 functor \u22d9 inverse).app X) \u226b\n  counit_iso.hom.app (functor.obj X) = \ud835\udfd9 (functor.obj X) . obviously)\n\nrestate_axiom equivalence.functor_unit_iso_comp'\n\ninfixr ` \u224c `:10  := equivalence\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} D]\n\nnamespace equivalence\n\n/-- The unit of an equivalence of categories. -/\nabbreviation unit (e : C \u224c D) : \ud835\udfed C \u27f6 e.functor \u22d9 e.inverse := e.unit_iso.hom\n/-- The counit of an equivalence of categories. -/\nabbreviation counit (e : C \u224c D) : e.inverse \u22d9 e.functor \u27f6 \ud835\udfed D := e.counit_iso.hom\n/-- The inverse of the unit of an equivalence of categories. -/\nabbreviation unit_inv (e : C \u224c D) : e.functor \u22d9 e.inverse \u27f6 \ud835\udfed C := e.unit_iso.inv\n/-- The inverse of the counit of an equivalence of categories. -/\nabbreviation counit_inv (e : C \u224c D) : \ud835\udfed D \u27f6 e.inverse \u22d9 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  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).unit = unit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).counit = counit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_unit_inv (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).unit_inv = unit_iso.inv := rfl\n@[simp] lemma equivalence_mk'_counit_inv (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).counit_inv = counit_iso.inv := rfl\n\n@[simp] lemma functor_unit_comp (e : C \u224c D) (X : C) :\n  e.functor.map (e.unit.app X) \u226b e.counit.app (e.functor.obj X) = \ud835\udfd9 (e.functor.obj X) :=\ne.functor_unit_iso_comp X\n\n@[simp] lemma counit_inv_functor_comp (e : C \u224c D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) \u226b e.functor.map (e.unit_inv.app X) = \ud835\udfd9 (e.functor.obj X) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.functor.map_iso (e.unit_iso.app X) \u226a\u226b 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 \u224c D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) = e.functor.map (e.unit.app X) :=\nby { symmetry, erw [\u2190iso.comp_hom_eq_id (e.counit_iso.app _), functor_unit_comp], refl }\n\nlemma counit_app_functor (e : C \u224c D) (X : C) :\n  e.counit.app (e.functor.obj X) = e.functor.map (e.unit_inv.app X) :=\nby { erw [\u2190iso.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 \u224c D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) \u226b e.inverse.map (e.counit.app Y) = \ud835\udfd9 (e.inverse.obj Y) :=\nbegin\n  rw [\u2190id_comp (e.inverse.map _), \u2190map_id e.inverse, \u2190counit_inv_functor_comp, map_comp,\n      \u2190iso.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 [\u2190iso.hom_inv_id_assoc (e.inverse.map_iso (e.counit_iso.app _)) (e.unit_inv.app _)] },\n  slice_lhs 3 4 { erw [\u2190map_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 [\u2190map_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 [\u2190map_comp (e.functor \u22d9 e.inverse), (e.unit_iso.app _).hom_inv_id, map_id] },\n  erw [id_comp],\n  slice_lhs 3 4 { erw [\u2190e.unit_inv.naturality] },\n  slice_lhs 2 3 { erw [\u2190map_comp e.inverse, \u2190e.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 \u224c D) (Y : D) :\n  e.inverse.map (e.counit_inv.app Y) \u226b e.unit_inv.app (e.inverse.obj Y) = \ud835\udfd9 (e.inverse.obj Y) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.unit_iso.app (e.inverse.obj Y) \u226a\u226b 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 \u224c D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counit_inv.app Y) :=\nby { erw [\u2190iso.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 \u224c D) (Y : D) :\n  e.unit_inv.app (e.inverse.obj Y) = e.inverse.map (e.counit.app Y) :=\nby { symmetry, erw [\u2190iso.hom_comp_eq_id (e.unit_iso.app _), unit_inverse_comp], refl }\n\n@[simp] lemma fun_inv_map (e : C \u224c D) (X Y : D) (f : X \u27f6 Y) :\n  e.functor.map (e.inverse.map f) = e.counit.app X \u226b f \u226b e.counit_inv.app Y :=\n(nat_iso.naturality_2 (e.counit_iso) f).symm\n\n@[simp] lemma inv_fun_map (e : C \u224c D) (X Y : C) (f : X \u27f6 Y) :\n  e.inverse.map (e.functor.map f) = e.unit_inv.app X \u226b f \u226b 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 \u2964 D} {G : D \u2964 C} (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D)\n\n/-- If `\u03b7 : \ud835\udfed C \u2245 F \u22d9 G` is part of a (not necessarily half-adjoint) equivalence, we can upgrade it\nto a refined natural isomorphism `adjointify_\u03b7 \u03b7 : \ud835\udfed C \u2245 F \u22d9 G` which exhibits the properties\nrequired for a half-adjoint equivalence. See `equivalence.mk`. -/\ndef adjointify_\u03b7 : \ud835\udfed C \u2245 F \u22d9 G :=\ncalc\n  \ud835\udfed C \u2245 F \u22d9 G               : \u03b7\n  ... \u2245 F \u22d9 (\ud835\udfed D \u22d9 G)      : iso_whisker_left F (left_unitor G).symm\n  ... \u2245 F \u22d9 ((G \u22d9 F) \u22d9 G) : iso_whisker_left F (iso_whisker_right \u03b5.symm G)\n  ... \u2245 F \u22d9 (G \u22d9 (F \u22d9 G)) : iso_whisker_left F (associator G F G)\n  ... \u2245 (F \u22d9 G) \u22d9 (F \u22d9 G) : (associator F G (F \u22d9 G)).symm\n  ... \u2245 \ud835\udfed C \u22d9 (F \u22d9 G)      : iso_whisker_right \u03b7.symm (F \u22d9 G)\n  ... \u2245 F \u22d9 G               : left_unitor (F \u22d9 G)\n\nlemma adjointify_\u03b7_\u03b5 (X : C) :\n  F.map ((adjointify_\u03b7 \u03b7 \u03b5).hom.app X) \u226b \u03b5.hom.app (F.obj X) = \ud835\udfd9 (F.obj X) :=\nbegin\n  dsimp [adjointify_\u03b7], simp,\n  have := \u03b5.hom.naturality (F.map (\u03b7.inv.app X)), dsimp at this, rw [this], clear this,\n  rw [\u2190assoc _ _ (F.map _)],\n  have := \u03b5.hom.naturality (\u03b5.inv.app $ F.obj X), dsimp at this, rw [this], clear this,\n  have := (\u03b5.app $ F.obj X).hom_inv_id, dsimp at this, rw [this], clear this,\n  rw [id_comp], have := (F.map_iso $ \u03b7.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 \u22d9 G` and\n    `G \u22d9 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 \u2964 D) (G : D \u2964 C)\n  (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D) : C \u224c D :=\n\u27e8F, G, adjointify_\u03b7 \u03b7 \u03b5, \u03b5, adjointify_\u03b7_\u03b5 \u03b7 \u03b5\u27e9\n\n/-- Equivalence of categories is reflexive. -/\n@[refl, simps] def refl : C \u224c C :=\n\u27e8\ud835\udfed C, \ud835\udfed C, iso.refl _, iso.refl _, \u03bb X, category.id_comp _\u27e9\n\ninstance : inhabited (C \u224c C) :=\n\u27e8refl\u27e9\n\n/-- Equivalence of categories is symmetric. -/\n@[symm, simps] def symm (e : C \u224c D) : D \u224c C :=\n\u27e8e.inverse, e.functor, e.counit_iso.symm, e.unit_iso.symm, e.inverse_counit_inv_comp\u27e9\n\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\n/-- Equivalence of categories is transitive. -/\n@[trans, simps] def trans (e : C \u224c D) (f : D \u224c E) : C \u224c E :=\n{ functor := e.functor \u22d9 f.functor,\n  inverse := f.inverse \u22d9 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' := \u03bb X,\n  begin\n    dsimp,\n    rw [\u2190 f.functor.map_comp_assoc, e.functor.map_comp, \u2190counit_inv_app_functor, fun_inv_map,\n        iso.inv_hom_id_app_assoc, assoc, iso.inv_hom_id_app, counit_app_functor,\n        \u2190 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 \u224c D) (F : C \u2964 E) : e.functor \u22d9 e.inverse \u22d9 F \u2245 F :=\n(functor.associator _ _ _).symm \u226a\u226b iso_whisker_right e.unit_iso.symm F \u226a\u226b F.left_unitor\n\n@[simp] lemma fun_inv_id_assoc_hom_app (e : C \u224c D) (F : C \u2964 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 \u224c D) (F : C \u2964 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 \u224c D) (F : D \u2964 E) : e.inverse \u22d9 e.functor \u22d9 F \u2245 F :=\n(functor.associator _ _ _).symm \u226a\u226b iso_whisker_right e.counit_iso F \u226a\u226b F.left_unitor\n\n@[simp] lemma inv_fun_id_assoc_hom_app (e : C \u224c D) (F : D \u2964 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 \u224c D) (F : D \u2964 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 \u2964 E` is equivalent to `D \u2964 E`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_left (e : C \u224c D) : (C \u2964 E) \u224c (D \u2964 E) :=\nequivalence.mk\n  ((whiskering_left _ _ _).obj e.inverse)\n  ((whiskering_left _ _ _).obj e.functor)\n  (nat_iso.of_components (\u03bb F, (e.fun_inv_id_assoc F).symm) (by tidy))\n  (nat_iso.of_components (\u03bb F, e.inv_fun_id_assoc F) (by tidy))\n\n/-- If `C` is equivalent to `D`, then `E \u2964 C` is equivalent to `E \u2964 D`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_right (e : C \u224c D) : (E \u2964 C) \u224c (E \u2964 D) :=\nequivalence.mk\n  ((whiskering_right _ _ _).obj e.functor)\n  ((whiskering_right _ _ _).obj e.inverse)\n  (nat_iso.of_components\n    (\u03bb F, F.right_unitor.symm \u226a\u226b iso_whisker_left F e.unit_iso \u226a\u226b functor.associator _ _ _)\n    (by tidy))\n  (nat_iso.of_components\n    (\u03bb F, functor.associator _ _ _ \u226a\u226b iso_whisker_left F e.counit_iso \u226a\u226b F.right_unitor)\n    (by tidy))\n\nsection cancellation_lemmas\nvariables (e : C \u224c 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 \u27f6 Y) :\n  f \u226b e.unit.app Y = f' \u226b e.unit.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_inv_right {X Y : C}\n  (f f' : X \u27f6 e.inverse.obj (e.functor.obj Y))   :\n  f \u226b e.unit_inv.app Y = f' \u226b e.unit_inv.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_right {X Y : D}\n  (f f' : X \u27f6 e.functor.obj (e.inverse.obj Y))   :\n  f \u226b e.counit.app Y = f' \u226b e.counit.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right {X Y : D}\n  (f f' : X \u27f6 Y) :\n  f \u226b e.counit_inv.app Y = f' \u226b e.counit_inv.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc {W X X' Y : C}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y) :\n  f \u226b g \u226b e.unit.app Y = f' \u226b g' \u226b e.unit.app Y \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right_assoc {W X X' Y : D}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y) :\n  f \u226b g \u226b e.counit_inv.app Y = f' \u226b g' \u226b e.counit_inv.app Y \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc' {W X X' Y Y' Z : C}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (h : Y \u27f6 Z) (f' : W \u27f6 X') (g' : X' \u27f6 Y') (h' : Y' \u27f6 Z) :\n  f \u226b g \u226b h \u226b e.unit.app Z = f' \u226b g' \u226b h' \u226b e.unit.app Z \u2194 f \u226b g \u226b h = f' \u226b g' \u226b h' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] \n\nend cancellation_lemmas\n\nsection\n\n-- There's of course a monoid structure on `C \u224c 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 \u224c C) : \u2115 \u2192 (C \u224c 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 \u224c C) : \u2124 \u2192 (C \u224c 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 \u224c C) \u2124 := \u27e8pow\u27e9\n\n@[simp] lemma pow_zero (e : C \u224c C) : e^(0 : \u2124) = equivalence.refl := rfl\n@[simp] lemma pow_one (e : C \u224c C) : e^(1 : \u2124) = e := rfl\n@[simp] lemma pow_neg_one (e : C \u224c C) : e^(-1 : \u2124) = e.symm := rfl\n\n-- TODO as necessary, add the natural isomorphisms `(e^a).trans e^b \u2245 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 \u2964 D) :=\nmk' ::\n(inverse    : D \u2964 C)\n(unit_iso   : \ud835\udfed C \u2245 F \u22d9 inverse)\n(counit_iso : inverse \u22d9 F \u2245 \ud835\udfed D)\n(functor_unit_iso_comp' : \u2200 (X : C), F.map ((unit_iso.hom : \ud835\udfed C \u27f6 F \u22d9 inverse).app X) \u226b\n  counit_iso.hom.app (F.obj X) = \ud835\udfd9 (F.obj X) . obviously)\n\nrestate_axiom is_equivalence.functor_unit_iso_comp'\n\nnamespace is_equivalence\n\ninstance of_equivalence (F : C \u224c D) : is_equivalence F.functor :=\n{ ..F }\n\ninstance of_equivalence_inverse (F : C \u224c 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 \u22d9 G` and `G \u22d9 F` are naturally isomorphic to identity functors. -/\nprotected definition mk {F : C \u2964 D} (G : D \u2964 C)\n  (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D) : is_equivalence F :=\n\u27e8G, adjointify_\u03b7 \u03b7 \u03b5, \u03b5, adjointify_\u03b7_\u03b5 \u03b7 \u03b5\u27e9\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 \u2964 D) [is_equivalence F] : C \u224c D :=\n\u27e8F, is_equivalence.inverse F, is_equivalence.unit_iso, is_equivalence.counit_iso,\n  is_equivalence.functor_unit_iso_comp\u27e9\n\ninstance is_equivalence_refl : is_equivalence (\ud835\udfed C) :=\nis_equivalence.of_equivalence equivalence.refl\n\n/-- The inverse functor of a functor that is an equivalence. -/\ndef inv (F : C \u2964 D) [is_equivalence F] : D \u2964 C :=\nis_equivalence.inverse F\n\ninstance is_equivalence_inv (F : C \u2964 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 \u2964 D) [is_equivalence F] :\n  F.as_equivalence.functor = F := rfl\n\n@[simp] lemma as_equivalence_inverse (F : C \u2964 D) [is_equivalence F] :\n  F.as_equivalence.inverse = inv F := rfl\n\n@[simp] lemma inv_inv (F : C \u2964 D) [is_equivalence F] :\n  inv (inv F) = F := rfl\n\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\ninstance is_equivalence_trans (F : C \u2964 D) (G : D \u2964 E) [is_equivalence F] [is_equivalence G] :\n  is_equivalence (F \u22d9 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 \u224c D) : E.functor.inv = E.inverse := rfl\n\n@[simp]\nlemma inverse_inv (E : C \u224c D) : E.inverse.inv = E.functor := rfl\n\n@[simp]\nlemma functor_as_equivalence (E : C \u224c D) : E.functor.as_equivalence = E :=\nby { cases E, congr, }\n\n@[simp]\nlemma inverse_as_equivalence (E : C \u224c 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 \u2964 D) [is_equivalence F] (X Y : D) (f : X \u27f6 Y) :\n  F.map (F.inv.map f) = F.as_equivalence.counit.app X \u226b f \u226b 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 \u2964 D) [is_equivalence F] (X Y : C) (f : X \u27f6 Y) :\n  F.inv.map (F.map f) = F.as_equivalence.unit_inv.app X \u226b f \u226b 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 \u2964 D) [is_equivalence F] : ess_surj F :=\n\u27e8\u03bb Y, \u27e8F.inv.obj Y, \u27e8F.as_equivalence.counit_iso.app Y\u27e9\u27e9\u27e9\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 \u2964 D) [is_equivalence F] : faithful F :=\n{ map_injective' := \u03bb 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 \u2964 D) [is_equivalence F] : full F :=\n{ preimage := \u03bb X Y f, F.as_equivalence.unit.app X \u226b F.inv.map f \u226b F.as_equivalence.unit_inv.app Y,\n  witness' := \u03bb 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 \u2964 D) [full F] [faithful F]\n  [ess_surj F] : D \u2964 C :=\n{ obj  := \u03bb X, F.obj_preimage X,\n  map := \u03bb X Y f, F.preimage ((F.obj_obj_preimage_iso X).hom \u226b f \u226b (F.obj_obj_preimage_iso Y).inv),\n  map_id' := \u03bb X, begin apply F.map_injective, tidy end,\n  map_comp' := \u03bb 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 \u2964 D) [full F] [faithful F] [ess_surj F] : is_equivalence F :=\nis_equivalence.mk (equivalence_inverse F)\n  (nat_iso.of_components\n    (\u03bb X, (preimage_iso $ F.obj_obj_preimage_iso $ F.obj X).symm)\n    (\u03bb 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 \u224c D) {X Y : C} (f g : X \u27f6 Y) :\n  e.functor.map f = e.functor.map g \u2194 f = g :=\n\u27e8\u03bb h, e.functor.map_injective h, \u03bb h, h \u25b8 rfl\u27e9\n\n@[simp] lemma inverse_map_inj_iff (e : C \u224c D) {X Y : D} (f g : X \u27f6 Y) :\n  e.inverse.map f = e.inverse.map g \u2194 f = g :=\nfunctor_map_inj_iff e.symm f g\n\ninstance ess_surj_induced_functor {C' : Type*} (e : C' \u2243 D) : ess_surj (induced_functor e) :=\n{ mem_ess_image := \u03bb Y, \u27e8e.symm Y, by simp\u27e9, }\n\nnoncomputable\ninstance induced_functor_of_equiv {C' : Type*} (e : C' \u2243 D) : is_equivalence (induced_functor e) :=\nequivalence_of_fully_faithfully_ess_surj _\n\nend equivalence\n\nsection partial_order\nvariables {\u03b1 \u03b2 : Type*} [partial_order \u03b1] [partial_order \u03b2]\n\n/--\nA categorical equivalence between partial orders is just an order isomorphism.\n-/\ndef equivalence.to_order_iso (e : \u03b1 \u224c \u03b2) : \u03b1 \u2243o \u03b2 :=\n{ to_fun := e.functor.obj,\n  inv_fun := e.inverse.obj,\n  left_inv := \u03bb a, (e.unit_iso.app a).to_eq.symm,\n  right_inv := \u03bb b, (e.counit_iso.app b).to_eq,\n  map_rel_iff' := \u03bb a a',\n    \u27e8\u03bb h, le_of_hom\n      ((equivalence.unit e).app a \u226b e.inverse.map (hom_of_le h) \u226b (equivalence.unit_inv e).app a'),\n     \u03bb (h : a \u2264 a'), le_of_hom (e.functor.map (hom_of_le h))\u27e9, }\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 : \u03b1 \u224c \u03b2) (a : \u03b1) :\n  e.to_order_iso a = e.functor.obj a := rfl\n\n@[simp]\nlemma equivalence.to_order_iso_symm_apply (e : \u03b1 \u224c \u03b2) (b : \u03b2) :\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 \u2022 a) = star r \u2022 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 : \u2200 (r : R) (a : A), star (r \u2022 a) = has_star.star r \u2022 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 \u2022 a) = star r \u2022 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  {\u03b9 : Sort*} (p : \u03b9 \u2192 submodule R M) (h : \u03b9 \u2192 Prop) : \n  (\u2a06 (i : \u03b9) (hi : h i), p i) = submodule.span R (\u22c3 (i : \u03b9) (hi : h i), \u2191(p i)) :=\nby simp_rw [\u2190 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 (\u03bb J : {J : ideal A // J \u2264 I}, (J : ideal A))\n  (\u03bb J : ideal A, \u27e8J \u2293 I, by exact inf_le_right\u27e9) :=\ngalois_coinsertion.monotone_intro (\u03bb J J' h, mk_le_mk.mpr (inf_le_inf_right I h))\n  (\u03bb J J' h, h) (\u03bb J, inf_le_left) (\u03bb \u27e8J, hJ\u27e9, by simp only [coe_mk]; exact inf_eq_left.mpr hJ) \n\ninstance : complete_lattice {J : ideal A // J \u2264 I} := \ngalois_coinsertion.lift_complete_lattice (galois_coinsertion)\n\nlemma top_def : (\u27e8I, le_refl I\u27e9 : {J : ideal A // J \u2264 I}) = \u22a4 := \neq_top_iff.mpr (\u22a4 : {J : ideal A // J \u2264 I}).property\n\nlemma bot_def : (\u27e8\u22a5, bot_le\u27e9 : {J : ideal A // J \u2264 I}) = \u22a5 := by rw mk_bot\n\nlemma inf_def (J J' : {J : ideal A // J \u2264 I}) : \n  (J \u2293 J' : {J : ideal A // J \u2264 I} ) = \u27e8(J : ideal A) \u2293 (J' : ideal A), inf_le_of_left_le J.2\u27e9 :=\nby { ext x, exact \u27e8\u03bb \u27e8h, h'\u27e9, h, \u03bb h, \u27e8h, J.property h.left\u27e9\u27e9 }\n\nlemma  Inf_def (S : set {J : ideal A // J \u2264 I}) : \n  (Inf S : {J : ideal A // J \u2264 I} ) = \u27e8(Inf ((coe : _ \u2192 ideal A) '' S)) \u2293 I, inf_le_right\u27e9 :=\nby { ext x, refl }\n\nlemma sup_def (J J' : {J : ideal A // J \u2264 I}) : \n  (J \u2294 J' : {J : ideal A // J \u2264 I} ) = \n    \u27e8Inf {B | (J : ideal A) \u2264 B \u2227 (J' : ideal A) \u2264 B}, Inf_le_of_le \u27e8J.2, J'.2\u27e9 (le_refl I)\u27e9 :=\nbegin\n  ext x,\n  refine \u27e8\u03bb \u27e8h, h'\u27e9, h, \u03bb h, \u27e8h, _\u27e9\u27e9,\n  rw [coe_mk, submodule.mem_Inf] at h,\n  exact h I \u27e8J.2, J'.2\u27e9\nend\n\nlemma Sup_def (S : set {J : ideal A // J \u2264 I}) : \n  (Sup S : {J : ideal A // J \u2264 I} ) = \u27e8(Sup ((coe : _ \u2192 ideal A) '' S)) \u2293 I, inf_le_right\u27e9 :=\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 \u2264 I)\n(dpow_mem_ideal : \u2200 (n : \u2115) (hn : n \u2260 0) (j \u2208 J), hI.dpow n j \u2208 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\u00a0\u2293 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 \u2293 I)) \u2194 (\u2200 (n : \u2115) (a b : A) (ha : a \u2208 I) (hb : b \u2208 I) (hab : (a - b) \u2208 J),\n    hI.dpow n a - hI.dpow n b \u2208 J) := \nbegin\n  refine \u27e8\u03bb hIJ n a b ha hb hab, _, \u03bb hIJ, _\u27e9,\n  { have hab' : a - b \u2208 I := I.sub_mem ha hb,  \n    rw [\u2190 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 \u2293 I).smul_mem _ (hIJ.dpow_mem_ideal (n - i) \n      (ne_of_gt (nat.sub_pos_of_lt (finset.mem_range.mp hi))) _ \u27e8hab, hab'\u27e9) },\n  { refine \u27e8semilattice_inf.inf_le_right J I, \u03bb n hn a ha,  \u27e8_, hI.dpow_mem hn ha.right\u27e9\u27e9,\n    rw [\u2190 sub_zero (hI.dpow n a), \u2190 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 \u2286 I) :\n  is_sub_pd_ideal hI (ideal.span S) \u2194 \n  \u2200 (n : \u2115) (hn : n \u2260 0) (s \u2208 S), hI.dpow n s \u2208 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 \u2286 I) :\n  ideal.span { y : A | \u2203 (n : \u2115) (hn : n \u2260 0) (x : A) (hx : x \u2208 S), y = hI.dpow n x } \u2264 I :=\nbegin\n  rw ideal.span_le,\n  rintros y \u27e8n, hn, x, hx, hxy\u27e9,\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 \u2208 \u2115 \u2265 0` and all\n  `j \u2208 J`, `hI.dpow n j \u2208 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 \u2264 I)\n(dpow_mem_ideal : \u2200 (n : \u2115) (hn : n \u2260 0) (j \u2208 carrier), hI.dpow n j \u2208 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 := \u27e8J, hJ.1, hJ.2\u27e9\n\ninstance : set_like (sub_pd_ideal hI) A :=\n{ coe := \u03bb s, s.carrier,\n  coe_injective' := \u03bb 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) := \u27e8\u03bb J, J.carrier\u27e9\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 \u2208 s.carrier \u2194 x \u2208 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 \u2293 I is a sub-pd-ideal of I -/\ndef inter_quot (J : ideal A) (hJ : divided_powers (I.map (ideal.quotient.mk J)))\n  (\u03c6 : pd_morphism hI hJ) (h\u03c6:  \u03c6.to_ring_hom = ideal.quotient.mk J) : \n  sub_pd_ideal hI := \n{ carrier        := J \u2293 I,\n  is_sub_ideal   := set.inter_subset_right J I, \n  dpow_mem_ideal := \u03bb n hn a \u27e8haJ, haI\u27e9,\n  begin\n    refine \u27e8_, hI.dpow_mem hn haI\u27e9,\n    rw [set_like.mem_coe,\u2190 ideal.quotient.eq_zero_iff_mem, \u2190 h\u03c6, \u2190 \u03c6.dpow_comp n a haI], \n    suffices ha0 : (\u03c6.to_ring_hom) a = 0,\n    { rw ha0,\n      exact hJ.dpow_eval_zero hn },\n    rw [h\u03c6, ideal.quotient.eq_zero_iff_mem], \n    exact haJ, \n  end }\n\n/-- If J is an ideal of A, then J\u00a0\u2b1d 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 \u2022 J,\n  is_sub_ideal   := ideal.mul_le_right,\n  dpow_mem_ideal := \u03bb 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 \u2022 J),\n      intros k hk,\n      by_cases hk0 : k = 0,\n      { rw hk0, apply ideal.mul_mem_left (I \u2022 J), exact hy' _ hn, },\n      { apply ideal.mul_mem_right _ (I \u2022 J), exact hx' k hk0, }, }\n  end }\n\nsection complete_lattice\n\ninstance : has_coe (sub_pd_ideal hI) {J : ideal A // J \u2264 I} :=  \u27e8\u03bb J, \u27e8J.carrier, J.is_sub_ideal\u27e9\u27e9\n\ninstance : has_le (sub_pd_ideal hI) := \u27e8\u03bb J J', J.carrier \u2264 J'.carrier\u27e9\n\nlemma le_iff {J J' : sub_pd_ideal hI} : J \u2264 J' \u2194 J.carrier \u2264 J'.carrier := iff.rfl\n\ninstance : has_lt (sub_pd_ideal hI) := \u27e8\u03bb J J', J.carrier < J'.carrier\u27e9\n\nlemma lt_iff {J J' : sub_pd_ideal hI} : J < J' \u2194 J.carrier < J'.carrier := iff.rfl\n\n/-- I is a sub-pd-ideal ot itself. -/\ninstance : has_top (sub_pd_ideal hI) :=\n\u27e8{ carrier       := I,\n  is_sub_ideal   := le_refl _,\n  dpow_mem_ideal := \u03bb n hn x hx, hI.dpow_mem hn hx }\u27e9\n\ninstance inhabited : inhabited hI.sub_pd_ideal := \u27e8\u22a4\u27e9\n\n/-- (0) is a sub-pd-ideal ot the pd-ideal I. -/\ninstance : has_bot (sub_pd_ideal hI) :=\n\u27e8{ carrier       := \u22a5,\n  is_sub_ideal   := bot_le,\n  dpow_mem_ideal := \u03bb n hn x hx, \n  by rw [ideal.mem_bot.mp hx, hI.dpow_eval_zero hn, ideal.mem_bot]}\u27e9\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) := \u27e8\u03bb J J',\n{ carrier := J.carrier \u2293 J'.carrier,\n  is_sub_ideal := \u03bb x hx, J.is_sub_ideal hx.1,\n  dpow_mem_ideal :=  \u03bb n hn x hx, \u27e8J.dpow_mem_ideal n hn x hx.1, J'.dpow_mem_ideal n hn x hx.2\u27e9 }\u27e9\n\nlemma inf_carrier_def (J J' : sub_pd_ideal hI) :\n  (J \u2293 J').carrier = J.carrier \u2293 J'.carrier := rfl\n\ninstance : has_Inf (sub_pd_ideal hI) := \u27e8\u03bb S,\n{ carrier := \u2a05 s \u2208 (has_insert.insert \u22a4 S), (s : hI.sub_pd_ideal).carrier, \n  is_sub_ideal := \u03bb x hx,\n  begin\n    simp only [ideal.mem_infi] at hx,\n    exact hx \u22a4 (set.mem_insert \u22a4 S),\n  end,\n  dpow_mem_ideal := \u03bb n hn x hx,\n  begin\n    simp only [ideal.mem_infi] at hx \u22a2,\n    intros s hs,\n    refine (s : hI.sub_pd_ideal).dpow_mem_ideal n hn x (hx s hs),\n  end }\u27e9\n\nlemma Inf_carrier_def (S : set (sub_pd_ideal hI)) :\n  (Inf S).carrier = \u2a05 s \u2208 (has_insert.insert \u22a4 S), (s : hI.sub_pd_ideal).carrier := rfl\n\ninstance : has_sup (sub_pd_ideal hI) := \n\u27e8\u03bb J J', sub_pd_ideal.mk' hI ((J : ideal A) \u2294 J')  $ begin\n  have hJJ' : (J : ideal A) \u2294 (J' : ideal A) = ideal.span(J \u222a J'),\n  { simp only [ideal.span_union, coe_coe, ideal.span_eq] },\n  rw [hJJ', span_is_sub_pd_ideal_iff hI (J \u222a 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\u27e9\n\nlemma sup_carrier_def (J J' : sub_pd_ideal hI) : (J \u2294 J').carrier = J \u2294 J' := rfl\n\ninstance : has_Sup (sub_pd_ideal hI) := \n\u27e8\u03bb S, sub_pd_ideal.mk' hI (Sup ((coe : sub_pd_ideal hI \u2192 ideal A) '' S)) $ \n  begin\n    have h : (\u22c3 (i : ideal A) (hi : i \u2208 coe '' S), \u2191i) \u2286 (I : set A),\n    { rintros a \u27e8-, \u27e8J, rfl\u27e9, haJ\u27e9,\n      rw [set.mem_Union, set_like.mem_coe, exists_prop] at haJ,\n      obtain \u27e8J', hJ'\u27e9 := (set.mem_image _ _ _).mp haJ.1,\n      rw [\u2190 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 \u27e8T, hT, hTx\u27e9,\n    obtain \u27e8J, hJ\u27e9 := hT,\n    rw \u2190 hJ at hTx,\n    obtain \u27e8J', \u27e8\u27e8hJ', rfl\u27e9, h'\u27e9\u27e9 := hTx,\n    apply ideal.subset_span,\n    apply set.mem_bUnion hJ',\n    obtain \u27e8K, hKS, rfl\u27e9 := hJ',\n    exact K.dpow_mem_ideal n hn x h', \nend\u27e9\n\nlemma Sup_carrier_def (S : set (sub_pd_ideal hI)) :\n  (Sup S).carrier = Sup ((coe : sub_pd_ideal hI \u2192 ideal A) '' S) := rfl\n\ninstance : complete_lattice (sub_pd_ideal hI) :=\nbegin\n  refine function.injective.complete_lattice (\u03bb J : sub_pd_ideal hI, (J : {J : ideal A // J \u2264 I}))\n    (\u03bb J J' h, (ext_iff _ _).mpr (subtype.ext_iff.mp h)) (\u03bb J J', by rw subideal.sup_def; refl)\n    (\u03bb J J', by rw subideal.inf_def; refl) _ _ (by rw \u2190 subideal.top_def; refl) \n    (by rw \u2190 subideal.bot_def; refl),\n  { intro S,\n    conv_rhs { rw supr },\n    rw [subideal.Sup_def, subtype.ext_iff,\u2190 coe_coe, coe_def, Sup_carrier_def, coe_mk, \n      Sup_image, Sup_image, supr_range], \n    have : \u2200 (J : hI.sub_pd_ideal),\n      ((\u2a06 (H : J \u2208 S), (J : {B : ideal A // B \u2264 I}) : {B : ideal A // B \u2264 I} ) : ideal A) =\n      (\u2a06 (H : J \u2208 S), (J : ideal A)),\n    { intro J,\n      by_cases hJ : J \u2208 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 \u27e8\u03bb ha, \u27e8ha, _\u27e9, \u03bb ha, ha.1\u27e9,\n    apply (submodule.mem_supr _).mp ha I,\n    intro J,\n    by_cases hJ : J \u2208 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, \u2190 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 \u2208 S,\n    { rw [cinfi_pos hJ, cinfi_pos hJ, inf_comm], refl, },\n    { simp only [hJ, infi_false, inf_top_eq, \u2190 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 \u2286 J.carrier }\n\n/-- The sub-pd-ideal of I generated by the family `hI.dpow n x`, where `n \u2208 \u2115 \u2265 0` and `x \u2208 S`. -/\ndef generated_dpow {S : set A} (hS : S \u2286 I) :\n  sub_pd_ideal hI := \n{ carrier := ideal.span { y : A | \u2203 (n : \u2115) (hn : n \u2260 0) (x : A) (hx : x \u2208 S), y = hI.dpow n x },\n  is_sub_ideal := generated_dpow_is_sub_ideal hI hS,\n  dpow_mem_ideal := \u03bb 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 \u27e8m, hm, x, hxS, hxy\u27e9 n hn,\n      rw [hxy, hI.dpow_comp n hm (hS hxS)],\n      exact ideal.mul_mem_left _ _ (ideal.subset_span \u27e8n*m, mul_ne_zero hn hm, x, hxS, rfl\u27e9) },\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 \u2286 I) :\n  (generated_dpow hI hS).carrier = \n  ideal.span { y : A | \u2203 (n : \u2115) (hn : n \u2260 0) (x : A) (hx : x \u2208 S), y = hI.dpow n x } := rfl\n\nlemma le_generated_dpow {S : set A} (hS : S \u2286 I) :\n  S \u2286 (generated_dpow hI hS).carrier :=\n\u03bb x hx, ideal.subset_span \u27e81, one_ne_zero, x, hx, by rw hI.dpow_one (hS hx)\u27e9\n\nlemma generated_dpow_le (S : set A) (J : sub_pd_ideal hI) \n  (hSJ : S \u2286 J.carrier) :\n  ideal.span { y : A | \u2203 (n : \u2115) (hn : n \u2260 0) (x : A) (hx : x \u2208 S), y = hI.dpow n x } \u2264 J.carrier :=\nbegin\n  rw ideal.span_le,\n  rintros y \u27e8n, hn, x, hx, hxy\u27e9,\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 \u2286 I) :\n  (generated hI S).carrier =\n    ideal.span { y : A | \u2203 (n : \u2115) (hn : n \u2260 0) (x : A) (hx : x \u2208 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 \u2208 insert \u22a4 {J : hI.sub_pd_ideal | S \u2286 \u2191(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 \u27e8generated_dpow hI hS, _\u27e9 (le_refl _),\n    simp only [h, cinfi_pos],\n    refl },\n  { rw le_infi\u2082_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 \u2293 I), dpow_quot_eq proves that no choices are involved -/\n/-- The definition of divided powers on A \u29f8 J -/\nnoncomputable def dpow (J : ideal A) : \u2115 \u2192 (A \u29f8 J) \u2192 (A \u29f8 J) := \n\u03bb n, function.extend (\u03bb a, ideal.quotient.mk J \u2191a : I \u2192 A \u29f8 J) \n  (\u03bb a, (ideal.quotient.mk J) (hI.dpow n a) : I \u2192 A \u29f8 J) 0\n\nvariables {J : ideal A} (hIJ : is_sub_pd_ideal hI (J \u2293 I))\n\ninclude hIJ\n\nopen_locale classical\n\n/-- Divided powers on the quotient are compatible with quotient map -/\nlemma dpow_eq {n : \u2115} {a : A} (ha : a \u2208 I) :\n  dpow hI J n (ideal.quotient.mk J a) = (ideal.quotient.mk J) (hI.dpow n a) :=\nbegin\n  have ha' : \u2203 (a' : \u21a5I), (ideal.quotient.mk J) \u2191a' = (ideal.quotient.mk J) a := \u27e8\u27e8a, ha\u27e9, rfl\u27e9,\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 [\u2190 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 \u29f8 J \n/-- When `I \u2293 J` is a `sub_pd_ideal` of `I`, the dpow map for the ideal `I(A\u29f8J)` of the quotient -/\nnoncomputable def divided_powers : divided_powers (I.map (ideal.quotient.mk J)) :=\n{ dpow := dpow hI J, \n  dpow_null := \u03bb n x hx, \n  begin\n    simp only [dpow, function.extend_def], \n    have ha' : \u00ac \u2203 (a' : \u21a5I), (ideal.quotient.mk J) \u2191a' = x,\n    { rintro \u27e8a, rfl\u27e9, \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 := \u03bb x hx, \n  begin\n    obtain \u27e8a, ha, hax\u27e9 := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    rw [\u2190 hax, dpow_eq hI hIJ ha, hI.dpow_zero ha, map_one],\n  end,\n  dpow_one := \u03bb x hx, \n  begin\n    obtain \u27e8a, ha, hax\u27e9 := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    rw [\u2190 hax, dpow_eq hI hIJ ha, hI.dpow_one ha],\n  end,\n  dpow_mem := \u03bb 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 := \u03bb n x y hx hy, \n  begin\n    obtain \u27e8a, ha, hax\u27e9 := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    obtain \u27e8b, hb, hby\u27e9 := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hy,\n    rw [\u2190 hax, \u2190 hby, \u2190 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, \u2190 map_mul] },\n  end,\n  dpow_smul := \u03bb n x y hy, \n  begin\n    obtain \u27e8a, rfl\u27e9 := ideal.quotient.mk_surjective x, \n    obtain \u27e8b, hb, hby\u27e9 := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hy,\n    rw [\u2190 hby, dpow_eq hI hIJ hb, \u2190 map_mul, \u2190 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 := \u03bb m n x hx, \n  begin\n    obtain \u27e8a, ha, hax\u27e9 := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    simp only [\u2190 hax, dpow_eq hI hIJ ha], \n    rw [\u2190 map_mul, hI.dpow_mul m n ha, map_mul, map_nat_cast],\n  end,\n  dpow_comp := \u03bb m n hn x hx,\n  begin \n    obtain \u27e8a, ha, hax\u27e9 := \n    (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n    simp only [\u2190 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 : \u2115} {x : A \u29f8 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 _ _ $ \u03bb n x hx,\nbegin\n  obtain \u27e8a, ha, hax\u27e9 := \n  (ideal.mem_map_iff_of_surjective _ (ideal.quotient.mk J).is_surjective).mp hx,\n  rw [\u2190 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nnamespace category_theory\n\nopen category\n\nvariables (C : Type u\u2081) [category.{v\u2081} C]\nvariables (D : Type u\u2082) [category.{v\u2082} D]\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\n/-- A category is skeletal if isomorphic objects are equal. -/\ndef skeletal : Prop := \u2200 \u2983X Y : C\u2984, is_isomorphic X Y \u2192 X = Y\n\n/--\n`is_skeleton_of C D F` says that `F : D \u2964 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 \u2964 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\u2081 F\u2082 : D \u2964 C} [\u2200 X Y : C, subsingleton (X \u27f6 Y)] (hC : skeletal C)\n  (hF : F\u2081 \u2245 F\u2082) : F\u2081 = F\u2082 :=\nfunctor.ext (\u03bb X, hC \u27e8hF.app X\u27e9) (\u03bb _ _ _, subsingleton.elim _ _)\n\n/--\nIf `C` is thin and skeletal, `D \u2964 C` is skeletal.\n`category_theory.functor_thin` shows it is thin also.\n-/\nlemma functor_skeletal [\u2200 X Y : C, subsingleton (X \u27f6 Y)] (hC : skeletal C) : skeletal (D \u2964 C) :=\n\u03bb F\u2081 F\u2082 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\u2081 := induced_category C quotient.out\n\ninstance [inhabited C] : inhabited (skeleton C) := \u27e8\u27e6default C\u27e7\u27e9\n\n/-- The functor from the skeleton of `C` to `C`. -/\n@[simps, derive [full, faithful]]\nnoncomputable def from_skeleton : skeleton C \u2964 C := induced_functor _\n\ninstance : ess_surj (from_skeleton C) :=\n{ mem_ess_image := \u03bb X, \u27e8quotient.mk X, quotient.mk_out X\u27e9 }\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 \u224c C :=\n(from_skeleton C).as_equivalence\n\nlemma skeleton_skeletal : skeletal (skeleton C) :=\nbegin\n  rintro X Y \u27e8h\u27e9,\n  have : X.out \u2248 Y.out := \u27e8(from_skeleton C).map_iso h\u27e9,\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 \u224c D) : skeleton C \u2243 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 := \u03bb X, skeleton_skeletal C \u27e8(f.unit_iso.app X).symm\u27e9,\n  right_inv := \u03bb Y, skeleton_skeletal D \u27e8(f.counit_iso.app Y)\u27e9, }\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\u2081 := quotient (is_isomorphic_setoid C)\n\ninstance inhabited_thin_skeleton [inhabited C] : inhabited (thin_skeleton C) :=\n\u27e8quotient.mk (default _)\u27e9\n\ninstance thin_skeleton.preorder : preorder (thin_skeleton C) :=\n{ le := quotient.lift\u2082 (\u03bb X Y, nonempty (X \u27f6 Y))\n  begin\n    rintros _ _ _ _ \u27e8i\u2081\u27e9 \u27e8i\u2082\u27e9,\n    exact propext \u27e8nonempty.map (\u03bb f, i\u2081.inv \u226b f \u226b i\u2082.hom),\n      nonempty.map (\u03bb f, i\u2081.hom \u226b f \u226b i\u2082.inv)\u27e9,\n  end,\n  le_refl :=\n  begin\n    refine quotient.ind (\u03bb a, _),\n    exact \u27e8\ud835\udfd9 _\u27e9,\n  end,\n  le_trans := \u03bb a b c, quotient.induction_on\u2083 a b c $ \u03bb A B C, nonempty.map2 (\u226b) }\n\n/-- The functor from a category to its thin skeleton. -/\n@[simps]\ndef to_thin_skeleton : C \u2964 thin_skeleton C :=\n{ obj := quotient.mk,\n  map := \u03bb 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 \u27f6 Y) :=\n\u27e8by { rintros \u27e8\u27e8f\u2081\u27e9\u27e9 \u27e8\u27e8f\u2082\u27e9\u27e9, refl }\u27e9\n\nvariables {C} {D}\n\n/-- A functor `C \u2964 D` computably lowers to a functor `thin_skeleton C \u2964 thin_skeleton D`. -/\n@[simps]\ndef map (F : C \u2964 D) : thin_skeleton C \u2964 thin_skeleton D :=\n{ obj := quotient.map F.obj $ \u03bb X\u2081 X\u2082 \u27e8hX\u27e9, \u27e8F.map_iso hX\u27e9,\n  map := \u03bb X Y, quotient.rec_on_subsingleton\u2082 X Y $\n           \u03bb x y k, hom_of_le (k.le.elim (\u03bb t, \u27e8F.map t\u27e9)) }\n\nlemma comp_to_thin_skeleton (F : C \u2964 D) : F \u22d9 to_thin_skeleton D = to_thin_skeleton C \u22d9 map F :=\nrfl\n\n/-- Given a natural transformation `F\u2081 \u27f6 F\u2082`, induce a natural transformation `map F\u2081 \u27f6 map F\u2082`.-/\ndef map_nat_trans {F\u2081 F\u2082 : C \u2964 D} (k : F\u2081 \u27f6 F\u2082) : map F\u2081 \u27f6 map F\u2082 :=\n{ app := \u03bb X, quotient.rec_on_subsingleton X (\u03bb x, \u27e8\u27e8\u27e8k.app x\u27e9\u27e9\u27e9) }\n\n-- TODO: state the lemmas about what happens when you compose with `to_thin_skeleton`\n/-- A functor `C \u2964 D \u2964 E` computably lowers to a functor\n`thin_skeleton C \u2964 thin_skeleton D \u2964 thin_skeleton E` -/\n@[simps]\ndef map\u2082 (F : C \u2964 D \u2964 E) :\n  thin_skeleton C \u2964 thin_skeleton D \u2964 thin_skeleton E :=\n{ obj := \u03bb x,\n  { obj := \u03bb y, quotient.map\u2082 (\u03bb X Y, (F.obj X).obj Y)\n                (\u03bb X\u2081 X\u2082 \u27e8hX\u27e9 Y\u2081 Y\u2082 \u27e8hY\u27e9, \u27e8(F.obj X\u2081).map_iso hY \u226a\u226b (F.map_iso hX).app Y\u2082\u27e9) x y,\n    map := \u03bb y\u2081 y\u2082, quotient.rec_on_subsingleton x $\n            \u03bb X, quotient.rec_on_subsingleton\u2082 y\u2081 y\u2082 $\n              \u03bb Y\u2081 Y\u2082 hY, hom_of_le (hY.le.elim (\u03bb g, \u27e8(F.obj X).map g\u27e9)) },\n  map := \u03bb x\u2081 x\u2082, quotient.rec_on_subsingleton\u2082 x\u2081 x\u2082 $\n           \u03bb X\u2081 X\u2082 f,\n           { app := \u03bb y, quotient.rec_on_subsingleton y\n              (\u03bb Y, hom_of_le (f.le.elim (\u03bb f', \u27e8(F.map f').app Y\u27e9))) } }\n\nvariables (C)\n\nsection\nvariables [\u2200 X Y : C, subsingleton (X \u27f6 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 \u2964 C :=\n{ obj := quotient.out,\n  map := \u03bb x y, quotient.rec_on_subsingleton\u2082 x y $\n    \u03bb X Y f,\n            (nonempty.some (quotient.mk_out X)).hom\n          \u226b f.le.some\n          \u226b (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 (\u03bb X, (nonempty.some (quotient.mk_out X))) (by tidy),\n  unit_iso :=\n    nat_iso.of_components\n      (\u03bb x, quotient.rec_on_subsingleton x\n        (\u03bb X, eq_to_iso (quotient.sound \u27e8(nonempty.some (quotient.mk_out X)).symm\u27e9)))\n      (by tidy) }\n\n/-- The equivalence between the thin skeleton and the category itself. -/\nnoncomputable def equivalence : thin_skeleton C \u224c C :=\n(from_thin_skeleton C).as_equivalence\n\nvariables {C}\n\nlemma equiv_of_both_ways {X Y : C} (f : X \u27f6 Y) (g : Y \u27f6 X) : X \u2248 Y :=\n\u27e8iso_of_both_ways f g\u27e9\n\ninstance thin_skeleton_partial_order : partial_order (thin_skeleton C) :=\n{ le_antisymm := quotient.ind\u2082\n  begin\n    rintros _ _ \u27e8f\u27e9 \u27e8g\u27e9,\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\u03bb X Y, quotient.induction_on\u2082 X Y $ \u03bb x y h, h.elim $ \u03bb i, i.1.le.antisymm i.2.le\n\nlemma map_comp_eq (F : E \u2964 D) (G : D \u2964 C) : map (F \u22d9 G) = map F \u22d9 map G :=\nfunctor.eq_of_iso skeletal $\n  nat_iso.of_components (\u03bb X, quotient.rec_on_subsingleton X (\u03bb x, iso.refl _)) (by tidy)\n\nlemma map_id_eq : map (\ud835\udfed C) = \ud835\udfed (thin_skeleton C) :=\nfunctor.eq_of_iso skeletal $\n  nat_iso.of_components (\u03bb X, quotient.rec_on_subsingleton X (\u03bb x, iso.refl _)) (by tidy)\n\nlemma map_iso_eq {F\u2081 F\u2082 : D \u2964 C} (h : F\u2081 \u2245 F\u2082) : map F\u2081 = map F\u2082 :=\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\u27e8thin_skeleton_is_skeleton\u27e9\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 \u2964 C) (L : C \u2964 D) (h : L \u22a3 R) :\n  thin_skeleton.map L \u22a3 thin_skeleton.map R :=\nadjunction.mk_of_unit_counit\n{ unit :=\n  { app := \u03bb X,\n    begin\n      letI := is_isomorphic_setoid C,\n      refine quotient.rec_on_subsingleton X (\u03bb x, hom_of_le \u27e8h.unit.app x\u27e9),\n      -- TODO: make quotient.rec_on_subsingleton' so the letI isn't needed\n    end },\n  counit :=\n  { app := \u03bb X,\n    begin\n      letI := is_isomorphic_setoid D,\n      refine quotient.rec_on_subsingleton X (\u03bb x, hom_of_le \u27e8h.counit.app x\u27e9),\n    end } }\n\nend thin_skeleton\n\nopen thin_skeleton\n\nsection\nvariables {C} {\u03b1 : Type*} [partial_order \u03b1]\n\n/--\nWhen `e : C \u224c \u03b1` is a categorical equivalence from a thin category `C` to some partial order `\u03b1`,\nthe `thin_skeleton C` is order isomorphic to `\u03b1`.\n-/\nnoncomputable\ndef equivalence.thin_skeleton_order_iso\n  [\u2200 X Y : C, subsingleton (X \u27f6 Y)] (e : C \u224c \u03b1) : thin_skeleton C \u2243o \u03b1 :=\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 `\u039b \u2192 \u039b'`\n\nLet `\u039b` be a polyhedral lattice, and let `0 < n` be a natural number.\nLet `\u039b' := rescale n (fin n \u2192\u2080 \u039b)` be the polyhedral lattice\nthat is the `n`-fold direct sum of `\u039b` with itself,\nendowed with the norm `\u2225(l\u2081, l\u2082, ..., l\u2099)\u2225 = (\u2225l\u2081\u2225 + \u2225l\u2082\u2225 + ... + \u2225l\u2099\u2225) / n`.\n\nThe diagonal embedding `\u039b \u2192 \u039b'` 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 `\u039b'^(m)` defined as `(\u039b')^m/L`,\nwhere `L` is the sublattice `\u039b \u2297 {x : \u2124^m | \u2211 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 (\u039b : PolyhedralLattice.{u}) (N : \u2115) [hN : fact (0 < N)]\n\ninclude hN\n\ndef rescaled_power : PolyhedralLattice :=\nof (rescale N $ fin N \u2192\u2080 \u039b)\n\ndef diagonal_embedding : \u039b \u27f6 rescaled_power \u039b N :=\n{ to_fun := \u03bb l, @rescale.of N (fin N \u2192\u2080 \u039b) $ \u2211 i, single_add_hom i l,\n  map_add' := \u03bb l\u2081 l\u2082, by { simp only [add_monoid_hom.map_add, finset.sum_add_distrib], refl }, -- defeq abuse\n  strict' := \u03bb 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 [\u2190 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 (\u2225l\u2225 : \u211d),\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 : \u039b) (i : fin N) :\n  ((@rescale.of N ((fin N) \u2192\u2080 \u039b)).symm (\u039b.diagonal_embedding N l) : fin N \u2192\u2080 \u039b) 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 : \u2115) (g\u2080 : \u039b \u2192+ M)\n  (g : fin (m + 1) \u2192 (\u039b.rescaled_power N \u2192+ M))\n  (hg : \u2200 i l, (g i) (\u039b.diagonal_embedding N l) = g\u2080 l) :\n  polyhedral_lattice.conerve.obj (\u039b.diagonal_embedding N) (m + 1) \u2192+ M :=\npolyhedral_lattice.conerve.lift' _ m g\u2080 g hg $\nbegin\n  intros l\u2081 l\u2082 h,\n  rw [finsupp.ext_iff] at h,\n  specialize h \u27e80, fact.out _\u27e9,\n  erw [diagonal_embedding_apply, diagonal_embedding_apply] at h,\n  exact h\nend\n\nlemma zsmul_rescaled_power (n : \u2124) (l : \u039b.rescaled_power N) :\n  n \u2022 (@rescale.of N ((fin N) \u2192\u2080 \u039b)).symm l = (@rescale.of N ((fin N) \u2192\u2080 \u039b)).symm (n \u2022 l) :=\nrfl\n\ninstance : fact (polyhedral_lattice_hom.to_add_monoid_hom (\u039b.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\u2080 : \u21a5\u039b := ((@rescale.of N ((fin N) \u2192\u2080 \u039b)).symm l' : fin N \u2192\u2080 \u039b) \u27e80, hN.1\u27e9,\n  refine or.inr \u27e8l\u2080, _\u27e9,\n  simp only [polyhedral_lattice_hom.coe_to_add_monoid_hom, add_monoid_hom.mem_range] at h \u22a2,\n  obtain \u27e8l, hl\u27e9 := h,\n  refine @smul_right_injective \u2124 _ _ _ _ _ n hn _ _ _,\n  rw [\u2190 hl, \u2190 polyhedral_lattice_hom.map_zsmul],\n  dsimp only [l\u2080],\n  rw [\u2190 finsupp.smul_apply, zsmul_rescaled_power _ _ n l', \u2190 hl, diagonal_embedding_apply],\nend\n\ndef cosimplicial : cosimplicial_object PolyhedralLattice.{u} :=\nCech_conerve $ diagonal_embedding \u039b N\n\nopen simplex_category\n\ndef cosimplicial_augmentation_map : \u039b \u27f6 (cosimplicial \u039b N).obj (mk 0) :=\nCech_augmentation_map _\n\ndef augmented_cosimplicial : cosimplicial_object.augmented PolyhedralLattice.{u} :=\naugmented_Cech_conerve $ diagonal_embedding \u039b 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 \u2192 Either S T\n  | inr : T \u2192 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 \u03b1 \u03b2 \u2192 Product \u03b2 \u03b1 := 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 \u2192 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 {\u03b1 \u03b2 : Type u} : Sum \u03b1 \u03b2 \u2192 Sum \u03b2 \u03b1 := 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 \u03b1 \u03b2) \u03b3 \u2192 Either \u03b1 (Either \u03b2 \u03b3) := 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 \u2192 \u03b1 := 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 \u2260 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  \u2203 (a : A) (b : non_zero_divisors A),\n  (\u2200 {d}, d \u2223 a \u2192 d \u2223 b \u2192 is_unit d) \u2227 mk' K a b = x :=\nbegin\n  obtain \u27e8\u27e8b, b_nonzero\u27e9, a, hab\u27e9 := exists_integer_multiple (non_zero_divisors A) x,\n  obtain \u27e8a', b', c', no_factor, rfl, rfl\u27e9 :=\n    unique_factorization_monoid.exists_reduced_factors' a b\n      (mem_non_zero_divisors_iff_ne_zero.mp b_nonzero),\n  obtain \u27e8c'_nonzero, b'_nonzero\u27e9 := mul_mem_non_zero_divisors.mp b_nonzero,\n  refine \u27e8a', \u27e8b', b'_nonzero\u27e9, @no_factor, _\u27e9,\n  refine mul_left_cancel\u2080\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 [\u2190hab, mul_assoc, mk'_spec' _ a' \u27e8b', b'_nonzero\u27e9],\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 \u2223 num A x \u2192 d \u2223 denom A x \u2192 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) \u2194 x = y :=\n\u27e8\u03bb h, by simpa only [mk'_num_denom] using eq_mk'_iff_mul_eq.mpr h,\n \u03bb h, eq_mk'_iff_mul_eq.mp (by rw [h, mk'_num_denom])\u27e9\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) \u2194 x = y :=\n\u27e8\u03bb h, by simpa only [eq_comm, mk'_num_denom] using eq_mk'_iff_mul_eq.mpr h,\n \u03bb h, eq_mk'_iff_mul_eq.mp (by rw [h, mk'_num_denom])\u27e9\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 \u2194 x = y :=\n\u27e8\u03bb h, by simpa only [mk'_num_denom] using mk'_eq_of_eq' h,\n \u03bb h, by rw h\u27e9\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) \u2260 0 :=\n    is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors (denom A x).2,\n  use \u2191d\u207b\u00b9 * num A x,\n  refine trans _ (mk'_num_denom A x),\n  rw [map_mul, map_units_inv, hd],\n  apply mul_left_cancel\u2080 d_ne_zero,\n  rw [\u2190mul_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 \u25b8 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": "\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 Symmetric real matrices have real eigenvalues in Lean mathlib\n \n--OUTPUT 1\ntheorem symmetric_real_matrix_has_real_eigenvalues {n : \u2115} (A : (matrix (fin n) (fin n) \u211d)) (h : is_symmetric n A) : \nhas_real_eigenvalues n A :=\nbegin\n    sorry\n\n--OUTPUT 2\ntheorem symmetric_matrix_real {n : \u2115} (A : matrix n n \u211d ) (hA : A.transpose = A) :\n    \u2203 (l : \u2115) (\u03bb : vector n \u211d ) (M : matrix n n \u211d) \n      (hM : M.transpose = M) (hA_eq : A = M.mul \u03bb.diag_embedding), \n  \u2200 i : \u2115, i < n \u2192 (\u03bb.diag_embedding).to_matrix.mul A = (\u03bb.diag_embedding).to_matrix :=\nbegin\n  sorry\n\n--OUTPUT 3\ntheorem symm_real_has_real_eigen (A : \u211d\u207fx\u207f) (P : polynomial \u211d) (h : characteristic_polynomial A P) (HA : symm A) : \n(\u2203 (\u03bb : \u211d), (is_eigenvalue A P \u03bb) \u2227 (is_real \u03bb)) :=\nbegin\n    cases exists_roots_in_complex P with s hs,\n    cases s with v hv,\n    cases hv with h2 h3,\n    cases h2 with h2 h2,\n    existsi Re v,\n    split,\n    use exists.intro v h2,\n    cases h3,\n    unfold is_real,\n    unfold complex.Re,\n    rw smul_one,\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.8_max_tokens_2000_n_3/clean_files/Symmetric real matrices have real eigenvalues.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": "/-\nCopyright (c) 2022 Jo\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u2964 D) [reflects_isomorphisms F] {X Y : C} (f : X \u27f6 Y) : is_iso (F.map f) \u2194 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 \u27f6 Y} {f' : X' \u27f6 Y'} {g : X \u27f6 X'} {g' : Y \u27f6 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 \u2194 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 \u2190 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 \u2964 Ho) [L.is_localization weq]\n  {Hocof : Type*} [category Hocof] (Lcof : cofibrant_object C \u2964 Hocof)\n    [Lcof.is_localization cofibrant_object.weq]\n  {Hobif : Type*} [category Hobif] (Lbif : bifibrant_object C \u2964 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 \u27f6 Y) [is_iso (Lbif.map f)] :\n  \u2203 (g : Y \u27f6 X) (hg\u2081 : f \u226b g = \ud835\udfd9 X) (P : path_object Y.obj)\n    (H : right_homotopy P.pre ((bifibrant_object.forget C).map (g \u226b f)) (\ud835\udfd9 Y.obj)),\n    (bifibrant_object.forget C).map f \u226b H.h = (bifibrant_object.forget C).map f \u226b P.\u03c3 :=\nbegin\n  sorry,\nend\n\nlemma bifibrant_object.is_iso_Lbif_map_cofibration_iff\n  {X Y : bifibrant_object C} (f : X \u27f6 Y) [cofibration ((bifibrant_object.forget C).map f)] :\n  is_iso (Lbif.map f) \u2194 bifibrant_object.weq f :=\nbegin\n  refine \u27e8_, localization.inverts Lbif bifibrant_object.weq f\u27e9,\n  introI,\n  rcases strong_deformation_retract_of_cofibration_and_homotopy_equivalence Lbif f\n    with \u27e8g, hg\u2081, P, H, property\u27e9,\n  let f' := (bifibrant_object.forget C).map f,\n  let W := CM5a.obj f',\n  let i : X.obj \u27f6 W := CM5a.i f',\n  let p : W \u27f6 Y.obj := CM5a.p f',\n  have sq : comm_sq i f' p (\ud835\udfd9 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\u2081 : \ud835\udfd9 X.obj \u226b i = f' \u226b sq.lift := by rw [id_comp, sq.fac_left],\n    have fac\u2082 : \ud835\udfd9 X.obj \u226b f' = i \u226b p := by rw [id_comp, CM5a.fac f'],\n    refine is_retract.mk (arrow.hom_mk fac\u2081) (arrow.hom_mk fac\u2082) _,\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 \u27f6 Y) :\n  is_iso (Lbif.map f) \u2194 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 \u27f6 bifibrant_object.mk Z := CM5b.i f',\n    let p : bifibrant_object.mk Z \u27f6 Y := CM5b.p f',\n    have h : i \u226b p = f := CM5b.fac f',\n    rw \u2190 h,\n    rw [\u2190 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 \u27f6 Y) :\n  is_iso (Lbif.map f) \u2194 is_iso (Lcof.map ((bifibrant_object.forget_fib C).map f)) :=\nby rw [\u2190 (Hobif_to_Hocof Lcof Lbif).is_iso_map_iff, \u2190 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 \u27f6 Y) :\n  is_iso (Lcof.map f) \u2194 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 \u2190 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 \u27f6 Y) :\n  is_iso (Lcof.map f) \u2194 is_iso (L.map ((cofibrant_object.forget C).map f)) :=\nby rw [\u2190 (Hocof_to_Ho Lcof L).is_iso_map_iff, \u2190 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 \u27f6 Y) :\n  is_iso (L.map f) \u2194 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 \u2190 eq at hf,\n    change is_iso _ at hf,\n    rw \u2190 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 (\u03b1:Type u_1) (\u03b2:Type u_2) (s:set \u03b1)\nopen measure_theory measure_theory.simple_func\n\nlemma lintegral_mul_indicator_eq_lintegral_mul_lintegral_indicator\n  {\u03b1} [M:measurable_space \u03b1] (\u03bc:measure_theory.measure \u03b1) \n  (Mf:measurable_space \u03b1) (hMf:Mf \u2264 M)\n  (c:ennreal) (T:set \u03b1) (h_meas_T:M.measurable_set' T)\n  (h_ind:\u2200 (S:set \u03b1), Mf.measurable_set' S \u2192\n  (\u03bc S * \u03bc T = \u03bc (S \u2229 T)))   \n  (f:\u03b1 \u2192 ennreal) (h_meas_f:@measurable \u03b1 ennreal Mf _ f):\n@lintegral \u03b1 M \u03bc (\u03bb a, (f * (T.indicator (\u03bb (_x : \u03b1), c))) a) =\n  @lintegral \u03b1 M \u03bc f * \n  @lintegral \u03b1 M \u03bc (T.indicator (\u03bb (_x : \u03b1), c)) :=\nbegin\n  revert f,\n  apply measurable.ennreal_induction,\n  { intros c' s' h_meas_s',\n      have h1:(\u03bb a, (s'.indicator (\u03bb (_x : \u03b1), c') * T.indicator (\u03bb (_x : \u03b1), c)) a) =\n         (\u03bb a, (s' \u2229 T).indicator (\u03bb (_x :\u03b1), c * c') a),\n      { ext1 a, cases classical.em (a \u2208 s' \u2229 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 \u2190 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 \u03b1 ennreal M ennreal.measurable_space (\u03bb (a : \u03b1), T.indicator (\u03bb (_x : \u03b1), c) a),\n    { apply measurable.indicator,\n      apply measurable_const,\n      apply h_meas_T,   },\n    have h8:(f' + g) * T.indicator (\u03bb (_x : \u03b1), c)= \n             (\u03bb a, (f' * (T.indicator (\u03bb _, c))) a + (g * (T.indicator (\u03bb _, c))) a),\n    { ext1 a, simp [right_distrib] },\n    rw h8,\n    have h_add:(f' + g) = (\u03bb 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 := (\u03bb n, measurable.mono (h_meas_f n) hMf (le_refl _)),\n    have h_mul:\n     (\u03bb a, ((\u03bb (x : \u03b1), \u2a06 (n : \u2115), f n x) * T.indicator (\u03bb (_x : \u03b1), c)) a) =\n      (\u03bb (a : \u03b1), \u2a06 (n : \u2115), (\u03bb (x:\u03b1), f n x * (T.indicator (\u03bb (_x : \u03b1), 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:(\u03bb (n:\u2115), (@lintegral \u03b1 M \u03bc \n       (\u03bb (x : \u03b1), f n x * T.indicator (\u03bb (_x : \u03b1), c) x)))  =\n        (\u03bb n, @lintegral \u03b1 M \u03bc (f n) * @lintegral \u03b1 M \u03bc (T.indicator (\u03bb (_x : \u03b1), c))), \n    { ext1 n, rw \u2190 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{\u03b1} [M:measurable_space \u03b1] (\u03bc:measure_theory.measure \u03b1) \n(Mf:measurable_space \u03b1) (Mg:measurable_space \u03b1) (hMf:Mf \u2264 M)\n(hMg:Mg \u2264 M)\n(h_ind:\u2200 (S T:set \u03b1), Mf.measurable_set' S \u2192 Mg.measurable_set' T \u2192\n (\u03bc S * \u03bc T = \u03bc (S \u2229 T)))   \n(f g:\u03b1 \u2192 ennreal) (h_meas_f:@measurable \u03b1 ennreal Mf _ f) (h_meas_g:@measurable \u03b1 ennreal Mg _ g):\n   @lintegral \u03b1 M \u03bc (\u03bb a, (f * g) a) =\n   @lintegral \u03b1 M \u03bc f * \n   @lintegral \u03b1 M \u03bc g :=\nbegin\n  revert g,\n  have h_meas_Mf:\u2200 \u2983f:\u03b1 \u2192 ennreal\u2984, (@measurable \u03b1 ennreal Mf _ f) \u2192 (@measurable \u03b1 ennreal M _ f),\n  { intros f' h_meas_f', apply measurable.mono h_meas_f' hMf, apply le_refl _ }, \n  have h_meas_Mg:\u2200 \u2983f:\u03b1 \u2192 ennreal\u2984, (@measurable \u03b1 ennreal Mg _ f) \u2192 (@measurable \u03b1 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) = (\u03bb a, (f' a + g a)),\n    { refl },\n    rw h_add,\n    rw measure_theory.lintegral_add,\n    have h8:(\u03bb a, (f * \u03bb a', (f' a' + g a')) a ) = (\u03bb 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:(\u03bb a, (f * f') a) = (\u03bb a, f a * f' a),\n    { ext1 a, refl },\n    rw \u2190 h9,\n    rw h_ind_f',\n    have h10:(\u03bb a, (f * g) a) = (\u03bb a, f a * g a),\n    { ext1 a, refl },\n    rw \u2190 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' := (\u03bb n, h_meas_Mg (h_meas_f' n)),\n    have h_mul:(\u03bb (a : \u03b1), (f * \u03bb (x : \u03b1), \u2a06 (n : \u2115), f' n x) a) = \n      (\u03bb (a : \u03b1), \u2a06 (n : \u2115), (\u03bb (x:\u03b1), (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:(\u03bb (n:\u2115), (@lintegral \u03b1 M \u03bc (\u03bb (x : \u03b1), f x * f' n x))) =\n        (\u03bb n, @lintegral \u03b1 M \u03bc f * @lintegral \u03b1 M \u03bc (f' n)), \n    { ext1 n, rw \u2190 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 {\u03b1} [M:measurable_space \u03b1] (\u03bc:measure_theory.measure \u03b1) \n(f g:\u03b1 \u2192 ennreal) (h_meas_f:measurable f) (h_meas_g:measurable g)\n(h_ind:\u2200 (S T:set ennreal), measurable_set S \u2192 measurable_set T \u2192\n (\u03bc (f \u207b\u00b9' S) * \u03bc (g \u207b\u00b9' T) = \u03bc ((f \u207b\u00b9' S) \u2229 (g \u207b\u00b9' T)))):\n\u222b\u207b (a : \u03b1), (f * g) a \u2202\u03bc =\n(\u222b\u207b (a : \u03b1), f a \u2202\u03bc) *\n(\u222b\u207b (a : \u03b1), g a \u2202\u03bc) :=\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 \u03bc 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':\u2203 (A:set ennreal), (measurable_set A) \u2227 (f \u207b\u00b9' A = S),\n      { apply h_S },\n      have h_T':\u2203 (B:set ennreal), (measurable_set B) \u2227 (g \u207b\u00b9' B = T),\n      { apply h_T },\n      cases h_S' with A h_S',\n      cases h_T' with B h_T',\n      rw \u2190 h_S'.right,\n      rw \u2190 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 := \u03bbx 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 \u2192 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 \u00d7 TheoryVar)\n  deriving BEq, Hashable, Repr\n\nnamespace Poly\n\n-- | Create polynomial denoting constant zero.\nprotected def const (z:Int) : Poly := \u27e8#[(z, \u27e80\u27e9)]\u27e9\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 := \u27e8Poly.zero\u27e9\n\n-- | Create polynomial denoting constant zero.\n-- protected def one : Poly := \u27e8#[(1, \u27e80\u27e9)]\u27e9\n\ndef addc : Poly \u2192 Int \u2192 Poly\n| \u27e8a\u27e9, q =>\n  let (p,v) := a.get! 0\n  \u27e8a.set! 0 (p+q, v)\u27e9\n\n-- | @add p i _ v@ returns poly denoting @p + i*v@.\ndef add : Poly \u2192 Int \u2192 TheoryVar \u2192 Poly\n| \u27e8a\u27e9, q, v =>\n  let rec loop : \u2200(i : Nat), Poly\n      | 0 => \u27e8a.insertAt 1 (q, v)\u27e9\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          \u27e8a.insertAt (i+2) (q,v)\u27e9\n        else -- v = u\n          let q := p+q\n          if q = 0 then\n            \u27e8a.eraseIdx (i+1)\u27e9\n          else\n            \u27e8a.set! (i+1) (q,v)\u27e9\n  loop (a.size-1)\n\nprotected def toString : Poly \u2192 String\n| \u27e8a\u27e9 =>\n  let scalarProd : Int \u00d7 TheoryVar \u2192 String\n        | (m,v) => s!\"{m}*{v}\"\n  let firstScalarProd : Int \u00d7 TheoryVar \u2192 String\n        | (m, _) => toString m\n  let polyIns := \u03bb(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 \u2192 IO IntExpr) : Int \u00d7 v \u2192 IO IntExpr\n| (m,  v) => do IntExpr.mk (mkAppN intMulConst #[m, \u2190 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 \u2192 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 \u2265 poly.elements.size then\n    panic! \"polyExpr given bad limit.\"\n  let mut e : IntExpr \u2190 poly.elements[0].fst\n  for p in poly.elements[1:limit+1] do\n    e := e + (\u2190 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 \u2192 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 \u2190 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 (\u03bbx => 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 \u25b8 rfl) (Int.add_zero r)\n\nend Lemmas\n\ndef addcProof (f:TheoryVar \u2192 IO IntExpr) (poly:Poly) (c:Int) (g:c \u2260 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 \u2192 IO IntExpr) : \u2200(poly:Poly) (q:Int), q \u2260 0 \u2192 TheoryVar \u2192 IO Expr\n| poly, q, g, v => do\n  let c \u2190 scalarProd f (q, v)\n  let rec loop : \u2200(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 \u2190 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 \u2190 poly.expr f (limit := i)\n            let x := a + (\u2190 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, \u2190 f v, rflExpr]\n            polyProofAddContext f x c a h poly (i+2)\n          else\n            let r \u2190 poly.expr f (limit := i)\n            let x := r + (\u2190scalarProd f (p, u))\n            let a := r + (\u2190scalarProd f (p+q, u))\n            let h := mkAppN (mkConst ``sumLemma) #[r, p, q, \u2190f 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 \u2192 Decl\n  -- A nat variable from another theory.\n| uninterpNat : Var \u2192 Decl\n  -- Theory variable is equal to polynomial.\n| poly : Poly \u2192 Decl\nderiving BEq, Hashable\n\nnamespace Decl\n\nprotected def toString : Decl \u2192 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 := \u27e8uninterpInt arbitrary\u27e9\n\nend Decl\n\n-- | An atomic predicate\ninductive Pred where\n-- This denotes a proof of the form (v = 0)\n| IsEq0 : TheoryVar \u2192 Pred\n-- This denotes a proof of the form (Not (v = 0))\n| IsNe0 : TheoryVar \u2192 Pred\n-- This denotes a proof of the form (Int.NonNeg v)\n| IsGe0 : TheoryVar \u2192 Pred\n  deriving Inhabited\n\nnamespace Pred\n\nprotected def toString : Pred \u2192 String\n| IsEq0 v => s!\"IsEq0 {v}\"\n| IsNe0 v => s!\"IsNe0 {v}\"\n| IsGe0 v => s!\"IsGe0 {v}\"\n\ninstance : ToString Pred := \u27e8Pred.toString\u27e9\n\nend Pred\n\ndef oneVar : TheoryVar := \u27e80\u27e9\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 \u2192 IO Expr)\n\n-- | Return Lean expression associated with IntExpr\npartial def thvarExpr (v:TheoryVar) : IO IntExpr := do\n  let s \u2190 r.get\n  if p : v.toNat < s.vars.size then\n    match s.vars.get \u27e8v.toNat, p\u27e9  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 \u2190 read\n  let s \u2190 r.get\n  match s.exprMap.find? d with\n  | none => pure ()\n  | some v => return v\n  let newVar := \u27e8OfNat.ofNat s.vars.size\u27e9\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 \u2190 (read : SolverM _)\n  let r \u2190 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 \u2190 (read : SolverM _)\n  let r \u2190 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 \u2190 read\n  let s \u2190 r.get\n  if TheoryPred.max \u2264 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 \u2192 IO Expr)  (thv : TheoryVar) : IO Expr := do\n  IntExpr.toExpr <$> thvarExpr r f thv\n\ndef predExpr (r : IO.Ref State) (f : Var \u2192 IO Expr) (idx : TheoryPred) : IO Expr := do\n  let s \u2190 r.get\n  if lt : idx.toNat < s.preds.size  then\n    match s.preds.get \u27e8idx.toNat, lt\u27e9  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 \u2192 Bool \u2192 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 \u2194 (x \u2194 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 \u2194 x = true \u2227 y = true := by bool_tt using simp x y\ntheorem and_eq_false_iff : (x && y) = false \u2194 x = false \u2228 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 \u2194 x = true \u2228 y = true := by bool_tt using simp x y\ntheorem or_eq_false_iff : (x || y) = false \u2194 x = false \u2227 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 \u2260 y) := by bool_tt x y\ntheorem bge_eq_decide_ge : Bool.bge x y = decide (x \u2265 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 \u2264 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 \u2264 x := by bool_tt x\nprotected theorem le_trans {x y z : Bool} : x \u2264 y \u2192 y \u2264 z \u2192 x \u2264 z := by bool_tt using simp x y z\nprotected theorem le_antisymm {x y : Bool} : x \u2264 y \u2192 y \u2264 x \u2192 x = y := by bool_tt using simp x y\nprotected theorem lt_irrefl : \u00ac x < x := by bool_tt using simp x\nprotected theorem lt_asymm {x y : Bool} : x < y \u2192 \u00ac y < x := by bool_tt using simp x y\nprotected theorem lt_trans {x y z : Bool} : x < y \u2192 y < z \u2192 x < z := by bool_tt using simp x y z\nprotected theorem lt_of_le_of_lt {x y z : Bool} : x \u2264 y \u2192 y < z \u2192 x < z := by bool_tt using simp x y z\nprotected theorem lt_of_lt_of_le {x y z : Bool} : x < y \u2192 y \u2264 z \u2192 x < z := by bool_tt using simp x y z\nprotected theorem le_of_lt {x y : Bool} : x < y \u2192 x \u2264 y := by bool_tt using simp x y z\nprotected theorem le_of_eq {x y : Bool} : x = y \u2192 x \u2264 y := by bool_tt using simp x y z\nprotected theorem ne_of_lt {x y : Bool} : x < y \u2192 x \u2260 y := by bool_tt using simp x y z\nprotected theorem lt_of_le_of_ne {x y : Bool} : x \u2264 y \u2192 x \u2260 y \u2192 x < y := by bool_tt using simp x y z\nprotected theorem le_of_lt_or_eq {x y : Bool} : x < y \u2228 x = y \u2192 x \u2264 y := by bool_tt using simp x y z\nprotected theorem le_true : x \u2264 true := by bool_tt x\nprotected theorem false_le : false \u2264 x := by bool_tt x\nprotected theorem eq_true_of_true_le {x : Bool} : true \u2264 x \u2192 x = true := by bool_tt using simp x\nprotected theorem eq_false_of_le_false {x : Bool} : x \u2264 false \u2192 x = false := by bool_tt using simp x\n\ninstance : Relation.Reflexive (\u03b1:=Bool) (.\u2264.) := \u27e8Bool.le_refl\u27e9\ninstance : Relation.Irreflexive (\u03b1:=Bool) (.<.) := \u27e8Bool.lt_irrefl\u27e9\ninstance : Relation.Antisymmetric (\u03b1:=Bool) (.\u2264.) := \u27e8Bool.le_antisymm\u27e9\ninstance : Relation.Asymmetric (\u03b1:=Bool) (.<.) := \u27e8Bool.lt_asymm\u27e9\ninstance : Relation.Transitive (\u03b1:=Bool) (.\u2264.) := \u27e8Bool.le_trans\u27e9\ninstance : Relation.Transitive (\u03b1:=Bool) (.<.) := \u27e8Bool.lt_trans\u27e9\ninstance : Relation.HTransitive (\u03b1:=Bool) (\u03b2:=Bool) (\u03b3:=Bool) (.<.) (.\u2264.) (.<.) := \u27e8Bool.lt_of_lt_of_le\u27e9\ninstance : Relation.HTransitive (\u03b1:=Bool) (\u03b2:=Bool) (\u03b3:=Bool) (.\u2264.) (.<.) (.<.) := \u27e8Bool.lt_of_le_of_lt\u27e9\n\ntheorem not_inj {x y : Bool} : (!x) = (!y) \u2192 x = y := by\n  bool_tt using simp x y\n\ntheorem and_or_inj_right {m x y : Bool}: (x && m) = (y && m) \u2192 (x || m) = (y || m) \u2192 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) \u2192 (m || x) = (m || y) \u2192 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 \u03b2)`, treated as a key-value store.\n\nIf `\u03b1 : Type*` and `\u03b2 : \u03b1 \u2192 Type*`, then we regard `s : sigma \u03b2` as having key `s.1 : \u03b1` and value\n`s.2 : \u03b2 s.1`. Hence, `list (sigma \u03b2)` 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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v}\n\n/-! ### `keys` -/\n\n/-- List of keys from a list of key-value pairs -/\ndef keys : list (sigma \u03b2) \u2192 list \u03b1 := map sigma.fst\n\n@[simp] theorem keys_nil : @keys \u03b1 \u03b2 [] = [] := rfl\n\n@[simp] theorem keys_cons {s} {l : list (sigma \u03b2)} : (s :: l).keys = s.1 :: l.keys := rfl\n\ntheorem mem_keys_of_mem {s : sigma \u03b2} {l : list (sigma \u03b2)} : s \u2208 l \u2192 s.1 \u2208 l.keys :=\nmem_map_of_mem sigma.fst\n\ntheorem exists_of_mem_keys {a} {l : list (sigma \u03b2)} (h : a \u2208 l.keys) :\n  \u2203 (b : \u03b2 a), sigma.mk a b \u2208 l :=\nlet \u27e8\u27e8a', b'\u27e9, m, e\u27e9 := exists_of_mem_map h in\neq.rec_on e (exists.intro b' m)\n\ntheorem mem_keys {a} {l : list (sigma \u03b2)} : a \u2208 l.keys \u2194 \u2203 (b : \u03b2 a), sigma.mk a b \u2208 l :=\n\u27e8exists_of_mem_keys, \u03bb \u27e8b, h\u27e9, mem_keys_of_mem h\u27e9\n\ntheorem not_mem_keys {a} {l : list (sigma \u03b2)} : a \u2209 l.keys \u2194 \u2200 b : \u03b2 a, sigma.mk a b \u2209 l :=\n(not_iff_not_of_iff mem_keys).trans not_exists\n\ntheorem not_eq_key {a} {l : list (sigma \u03b2)} : a \u2209 l.keys \u2194 \u2200 s : sigma \u03b2, s \u2208 l \u2192 a \u2260 s.1 :=\niff.intro\n  (\u03bb h\u2081 s h\u2082 e, absurd (mem_keys_of_mem h\u2082) (by rwa e at h\u2081))\n  (\u03bb f h\u2081, let \u27e8b, h\u2082\u27e9 := exists_of_mem_keys h\u2081 in f _ h\u2082 rfl)\n\n/-! ### `nodupkeys` -/\n\n/-- Determines whether the store uses a key several times. -/\ndef nodupkeys (l : list (sigma \u03b2)) : Prop := l.keys.nodup\n\ntheorem nodupkeys_iff_pairwise {l} : nodupkeys l \u2194\n  pairwise (\u03bb s s' : sigma \u03b2, s.1 \u2260 s'.1) l := pairwise_map _\n\ntheorem nodupkeys.pairwise_ne {l} (h : nodupkeys l) :\n  pairwise (\u03bb s s' : sigma \u03b2, s.1 \u2260 s'.1) l :=\nnodupkeys_iff_pairwise.1 h\n\n@[simp] theorem nodupkeys_nil : @nodupkeys \u03b1 \u03b2 [] := pairwise.nil\n\n@[simp] theorem nodupkeys_cons {s : sigma \u03b2} {l : list (sigma \u03b2)} :\n  nodupkeys (s::l) \u2194 s.1 \u2209 l.keys \u2227 nodupkeys l :=\nby simp [keys, nodupkeys]\n\ntheorem nodupkeys.eq_of_fst_eq {l : list (sigma \u03b2)}\n  (nd : nodupkeys l) {s s' : sigma \u03b2} (h : s \u2208 l) (h' : s' \u2208 l) :\n  s.1 = s'.1 \u2192 s = s' :=\n@forall_of_forall_of_pairwise _\n  (\u03bb s s' : sigma \u03b2, s.1 = s'.1 \u2192 s = s')\n  (\u03bb s s' H h, (H h.symm).symm) _ (\u03bb x h _, rfl)\n  ((nodupkeys_iff_pairwise.1 nd).imp (\u03bb s s' h h', (h h').elim)) _ h _ h'\n\ntheorem nodupkeys.eq_of_mk_mem {a : \u03b1} {b b' : \u03b2 a} {l : list (sigma \u03b2)}\n  (nd : nodupkeys l) (h : sigma.mk a b \u2208 l) (h' : sigma.mk a b' \u2208 l) : b = b' :=\nby cases nd.eq_of_fst_eq h h' rfl; refl\n\ntheorem nodupkeys_singleton (s : sigma \u03b2) : nodupkeys [s] := nodup_singleton _\n\ntheorem nodupkeys_of_sublist {l\u2081 l\u2082 : list (sigma \u03b2)} (h : l\u2081 <+ l\u2082) :\n  nodupkeys l\u2082 \u2192 nodupkeys l\u2081 :=\nnodup_of_sublist (h.map _)\n\ntheorem nodup_of_nodupkeys {l : list (sigma \u03b2)} : nodupkeys l \u2192 nodup l :=\nnodup_of_nodup_map _\n\ntheorem perm_nodupkeys {l\u2081 l\u2082 : list (sigma \u03b2)} (h : l\u2081 ~ l\u2082) : nodupkeys l\u2081 \u2194 nodupkeys l\u2082 :=\n(h.map _).nodup_iff\n\ntheorem nodupkeys_join {L : list (list (sigma \u03b2))} :\n  nodupkeys (join L) \u2194 (\u2200 l \u2208 L, nodupkeys l) \u2227 pairwise disjoint (L.map keys) :=\nbegin\n  rw [nodupkeys_iff_pairwise, pairwise_join, pairwise_map],\n  refine and_congr (ball_congr $ \u03bb l h, by simp [nodupkeys_iff_pairwise]) _,\n  apply iff_of_eq, congr' with l\u2081 l\u2082,\n  simp [keys, disjoint_iff_ne]\nend\n\ntheorem nodup_enum_map_fst (l : list \u03b1) : (l.enum.map prod.fst).nodup :=\nby simp [list.nodup_range]\n\nlemma mem_ext {l\u2080 l\u2081 : list (sigma \u03b2)}\n  (nd\u2080 : l\u2080.nodup) (nd\u2081 : l\u2081.nodup)\n  (h : \u2200 x, x \u2208 l\u2080 \u2194 x \u2208 l\u2081) : l\u2080 ~ l\u2081 :=\nbegin\n  induction l\u2080 with x xs generalizing l\u2081; cases l\u2081 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\u2080 nd\u2081, classical,\n  cases nd\u2080, cases nd\u2081,\n  by_cases h' : x = y,\n  { subst y, constructor, apply l\u2080_ih \u2039 _ \u203a \u2039 nodup ys \u203a,\n    intro a, specialize h a, simp at h,\n    by_cases h' : a = x,\n    { subst a, rw \u2190 not_iff_not, split; intro; assumption },\n    { simp [h'] at h, exact h } },\n  { transitivity x :: y :: ys.erase x,\n    { constructor, apply l\u2080_ih \u2039 _ \u203a,\n      { simp, split, { intro, apply nd\u2081_left, apply mem_of_mem_erase \u2039_\u203a },\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 \u2190 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 \u03b1]\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 : \u03b1) : list (sigma \u03b2) \u2192 option (\u03b2 a)\n| []             := none\n| (\u27e8a', b\u27e9 :: l) := if h : a' = a then some (eq.rec_on h b) else lookup l\n\n@[simp] theorem lookup_nil (a : \u03b1) : lookup a [] = @none (\u03b2 a) := rfl\n\n@[simp] theorem lookup_cons_eq (l) (a : \u03b1) (b : \u03b2 a) : lookup a (\u27e8a, b\u27e9::l) = some b :=\ndif_pos rfl\n\n@[simp] theorem lookup_cons_ne (l) {a} :\n  \u2200 s : sigma \u03b2, a \u2260 s.1 \u2192 lookup a (s::l) = lookup a l\n| \u27e8a', b\u27e9 h := dif_neg h.symm\n\ntheorem lookup_is_some {a : \u03b1} : \u2200 {l : list (sigma \u03b2)},\n  (lookup a l).is_some \u2194 a \u2208 l.keys\n| []             := by simp\n| (\u27e8a', b\u27e9 :: 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 : \u03b1} {l : list (sigma \u03b2)} :\n  lookup a l = none \u2194 a \u2209 l.keys :=\nby simp [\u2190 lookup_is_some, option.is_none_iff_eq_none]\n\ntheorem of_mem_lookup\n  {a : \u03b1} {b : \u03b2 a} : \u2200 {l : list (sigma \u03b2)}, b \u2208 lookup a l \u2192 sigma.mk a b \u2208 l\n| (\u27e8a', b'\u27e9 :: 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 : \u03b2 a} {l : list (sigma \u03b2)} (nd : l.nodupkeys)\n  (h : sigma.mk a b \u2208 l) : b \u2208 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 : \u03b1) : \u2200 l : list (sigma \u03b2),\n  (lookup a l).map (sigma.mk a) = find (\u03bb s, a = s.1) l\n| [] := rfl\n| (\u27e8a', b'\u27e9 :: 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 : \u03b1} {b : \u03b2 a} {l : list (sigma \u03b2)} (nd : l.nodupkeys) :\n  b \u2208 lookup a l \u2194 sigma.mk a b \u2208 l :=\n\u27e8of_mem_lookup, mem_lookup nd\u27e9\n\ntheorem perm_lookup (a : \u03b1) {l\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd\u2081 : l\u2081.nodupkeys) (nd\u2082 : l\u2082.nodupkeys) (p : l\u2081 ~ l\u2082) : lookup a l\u2081 = lookup a l\u2082 :=\nby ext b; simp [mem_lookup_iff, nd\u2081, nd\u2082]; exact p.mem_iff\n\nlemma lookup_ext {l\u2080 l\u2081 : list (sigma \u03b2)}\n  (nd\u2080 : l\u2080.nodupkeys) (nd\u2081 : l\u2081.nodupkeys)\n  (h : \u2200 x y, y \u2208 l\u2080.lookup x \u2194 y \u2208 l\u2081.lookup x) : l\u2080 ~ l\u2081 :=\nmem_ext (nodup_of_nodupkeys nd\u2080) (nodup_of_nodupkeys nd\u2081)\n  (\u03bb \u27e8a,b\u27e9, by rw [\u2190 mem_lookup_iff, \u2190 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 : \u03b1) : list (sigma \u03b2) \u2192 list (\u03b2 a)\n| []             := []\n| (\u27e8a', b\u27e9 :: 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 : \u03b1) (b : \u03b2 a) :\n  lookup_all a (\u27e8a, b\u27e9::l) = b :: lookup_all a l :=\ndif_pos rfl\n\n@[simp] theorem lookup_all_cons_ne (l) {a} :\n  \u2200 s : sigma \u03b2, a \u2260 s.1 \u2192 lookup_all a (s::l) = lookup_all a l\n| \u27e8a', b\u27e9 h := dif_neg h.symm\n\ntheorem lookup_all_eq_nil {a : \u03b1} : \u2200 {l : list (sigma \u03b2)},\n  lookup_all a l = [] \u2194 \u2200 b : \u03b2 a, sigma.mk a b \u2209 l\n| []             := by simp\n| (\u27e8a', b\u27e9 :: 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 : \u03b1) : \u2200 l : list (sigma \u03b2),\n  head' (lookup_all a l) = lookup a l\n| []             := by simp\n| (\u27e8a', b\u27e9 :: l) := by by_cases h : a = a'; [{subst h, simp}, simp *]\n\ntheorem mem_lookup_all {a : \u03b1} {b : \u03b2 a} :\n  \u2200 {l : list (sigma \u03b2)}, b \u2208 lookup_all a l \u2194 sigma.mk a b \u2208 l\n| []              := by simp\n| (\u27e8a', b'\u27e9 :: l) := by by_cases h : a = a'; [{subst h, simp *}, simp *]\n\ntheorem lookup_all_sublist (a : \u03b1) :\n  \u2200 l : list (sigma \u03b2), (lookup_all a l).map (sigma.mk a) <+ l\n| []              := by simp\n| (\u27e8a', b'\u27e9 :: 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 : \u03b1) {l : list (sigma \u03b2)} (h : l.nodupkeys) :\n  length (lookup_all a l) \u2264 1 :=\nby have := nodup_of_sublist ((lookup_all_sublist a l).map _) h;\n   rw map_map at this; rwa [\u2190 nodup_repeat, \u2190 map_const _ a]\n\ntheorem lookup_all_eq_lookup (a : \u03b1) {l : list (sigma \u03b2)} (h : l.nodupkeys) :\n  lookup_all a l = (lookup a l).to_list :=\nbegin\n  rw \u2190 head_lookup_all,\n  have := lookup_all_length_le_one a h, revert this,\n  rcases lookup_all a l with _|\u27e8b, _|\u27e8c, l\u27e9\u27e9; intro; try {refl},\n  exact absurd this dec_trivial\nend\n\ntheorem lookup_all_nodup (a : \u03b1) {l : list (sigma \u03b2)} (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 : \u03b1) {l\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd\u2081 : l\u2081.nodupkeys) (nd\u2082 : l\u2082.nodupkeys) (p : l\u2081 ~ l\u2082) : lookup_all a l\u2081 = lookup_all a l\u2082 :=\nby simp [lookup_all_eq_lookup, nd\u2081, nd\u2082, perm_lookup a nd\u2081 nd\u2082 p]\n\n/-! ### `kreplace` -/\n\n/-- Replaces the first value with key `a` by `b`. -/\ndef kreplace (a : \u03b1) (b : \u03b2 a) : list (sigma \u03b2) \u2192 list (sigma \u03b2) :=\nlookmap $ \u03bb s, if a = s.1 then some \u27e8a, b\u27e9 else none\n\ntheorem kreplace_of_forall_not (a : \u03b1) (b : \u03b2 a) {l : list (sigma \u03b2)}\n  (H : \u2200 b : \u03b2 a, sigma.mk a b \u2209 l) : kreplace a b l = l :=\nlookmap_of_forall_not _ $ begin\n  rintro \u27e8a', b'\u27e9 h, dsimp, split_ifs,\n  { subst a', exact H _ h }, {refl}\nend\n\ntheorem kreplace_self {a : \u03b1} {b : \u03b2 a} {l : list (sigma \u03b2)}\n  (nd : nodupkeys l) (h : sigma.mk a b \u2208 l) : kreplace a b l = l :=\nbegin\n  refine (lookmap_congr _).trans\n    (lookmap_id' (option.guard (\u03bb s, a = s.1)) _ _),\n  { rintro \u27e8a', b'\u27e9 h', dsimp [option.guard], split_ifs,\n    { subst a', exact \u27e8rfl, heq_of_eq $ nd.eq_of_mk_mem h h'\u27e9 },\n    { refl } },\n  { rintro \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9, dsimp [option.guard], split_ifs,\n    { subst a\u2081, rintro \u27e8\u27e9, simp }, { rintro \u27e8\u27e9 } },\nend\n\ntheorem keys_kreplace (a : \u03b1) (b : \u03b2 a) : \u2200 l : list (sigma \u03b2),\n  (kreplace a b l).keys = l.keys :=\nlookmap_map_eq _ _ $ by rintro \u27e8a\u2081, b\u2082\u27e9 \u27e8a\u2082, b\u2082\u27e9;\n  dsimp; split_ifs; simp [h] {contextual := tt}\n\ntheorem kreplace_nodupkeys (a : \u03b1) (b : \u03b2 a) {l : list (sigma \u03b2)} :\n  (kreplace a b l).nodupkeys \u2194 l.nodupkeys :=\nby simp [nodupkeys, keys_kreplace]\n\ntheorem perm.kreplace {a : \u03b1} {b : \u03b2 a} {l\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd : l\u2081.nodupkeys) : l\u2081 ~ l\u2082 \u2192\n  kreplace a b l\u2081 ~ kreplace a b l\u2082 :=\nperm_lookmap _ $ begin\n  refine nd.pairwise_ne.imp _,\n  intros x y h z h\u2081 w h\u2082,\n  split_ifs at h\u2081 h\u2082; cases h\u2081; cases h\u2082,\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 : \u03b1) : list (sigma \u03b2) \u2192 list (sigma \u03b2) :=\nerasep $ \u03bb s, a = s.1\n\n@[simp] theorem kerase_nil {a} : @kerase _ \u03b2 _ a [] = [] :=\nrfl\n\n@[simp, priority 990]\ntheorem kerase_cons_eq {a} {s : sigma \u03b2} {l : list (sigma \u03b2)} (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 \u03b2} {l : list (sigma \u03b2)} (h : a \u2260 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 \u03b2)} (h : a \u2209 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 : \u03b1) (l : list (sigma \u03b2)) : kerase a l <+ l :=\nerasep_sublist _\n\ntheorem kerase_keys_subset (a) (l : list (sigma \u03b2)) :\n  (kerase a l).keys \u2286 l.keys :=\n((kerase_sublist a l).map _).subset\n\ntheorem mem_keys_of_mem_keys_kerase {a\u2081 a\u2082} {l : list (sigma \u03b2)} :\n  a\u2081 \u2208 (kerase a\u2082 l).keys \u2192 a\u2081 \u2208 l.keys :=\n@kerase_keys_subset _ _ _ _ _ _\n\ntheorem exists_of_kerase {a : \u03b1} {l : list (sigma \u03b2)} (h : a \u2208 l.keys) :\n  \u2203 (b : \u03b2 a) (l\u2081 l\u2082 : list (sigma \u03b2)),\n    a \u2209 l\u2081.keys \u2227\n    l = l\u2081 ++ \u27e8a, b\u27e9 :: l\u2082 \u2227\n    kerase a l = l\u2081 ++ l\u2082 :=\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 \u27e8hd.2, [], tl, by simp, by cases hd; refl, by simp\u27e9 },\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 \u27e8b, tl\u2081, tl\u2082, h\u2081, h\u2082, h\u2083\u27e9,\n        exact \u27e8b, hd :: tl\u2081, tl\u2082, not_mem_cons_of_ne_of_not_mem e h\u2081,\n               by rw h\u2082; refl, by simp [e, h\u2083]\u27e9 } } }\nend\n\n@[simp, priority 990]\ntheorem mem_keys_kerase_of_ne {a\u2081 a\u2082} {l : list (sigma \u03b2)} (h : a\u2081 \u2260 a\u2082) :\n  a\u2081 \u2208 (kerase a\u2082 l).keys \u2194 a\u2081 \u2208 l.keys :=\niff.intro mem_keys_of_mem_keys_kerase $ \u03bb p,\n  if q : a\u2082 \u2208 l.keys then\n    match l, kerase a\u2082 l, exists_of_kerase q, p with\n    | _, _, \u27e8_, _, _, _, rfl, rfl\u27e9, p := by simpa [keys, h] using p\n    end\n  else\n    by simp [q, p]\n\ntheorem keys_kerase {a} {l : list (sigma \u03b2)} : (kerase a l).keys = l.keys.erase a :=\nby rw [keys, kerase, \u2190erasep_map sigma.fst l, erase_eq_erasep]\n\ntheorem kerase_kerase {a a'} {l : list (sigma \u03b2)} :\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 : \u03b1) {l : list (sigma \u03b2)} : nodupkeys l \u2192 (kerase a l).nodupkeys :=\nnodupkeys_of_sublist $ kerase_sublist _ _\n\ntheorem perm.kerase {a : \u03b1} {l\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd : l\u2081.nodupkeys) : l\u2081 ~ l\u2082 \u2192 kerase a l\u2081 ~ kerase a l\u2082 :=\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 \u03b2)} (nd : l.nodupkeys) :\n  a \u2209 (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 \u03b2)} (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 \u03b2)} (h : a \u2260 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\u2081 : a = ah; by_cases h\u2082 : a' = ah,\n    { substs h\u2081 h\u2082, cases ne.irrefl h },\n    { subst h\u2081, simp [h\u2082] },\n    { subst h\u2082, simp [h] },\n    { simp [h\u2081, h\u2082, ih] } }\nend\n\ntheorem kerase_append_left {a} : \u2200 {l\u2081 l\u2082 : list (sigma \u03b2)},\n  a \u2208 l\u2081.keys \u2192 kerase a (l\u2081 ++ l\u2082) = kerase a l\u2081 ++ l\u2082\n| []        _  h  := by cases h\n| (s :: l\u2081) l\u2082 h\u2081 :=\n  if h\u2082 : a = s.1 then\n    by simp [h\u2082]\n  else\n    by simp at h\u2081;\n       cases h\u2081;\n       [exact absurd h\u2081 h\u2082, simp [h\u2082, kerase_append_left h\u2081]]\n\ntheorem kerase_append_right {a} : \u2200 {l\u2081 l\u2082 : list (sigma \u03b2)},\n  a \u2209 l\u2081.keys \u2192 kerase a (l\u2081 ++ l\u2082) = l\u2081 ++ kerase a l\u2082\n| []        _  h := rfl\n| (_ :: l\u2081) l\u2082 h := by simp [not_or_distrib] at h;\n                       simp [h.1, kerase_append_right h.2]\n\ntheorem kerase_comm (a\u2081 a\u2082) (l : list (sigma \u03b2)) :\n  kerase a\u2082 (kerase a\u2081 l) = kerase a\u2081 (kerase a\u2082 l) :=\nif h : a\u2081 = a\u2082 then\n  by simp [h]\nelse if ha\u2081 : a\u2081 \u2208 l.keys then\n  if ha\u2082 : a\u2082 \u2208 l.keys then\n    match l, kerase a\u2081 l, exists_of_kerase ha\u2081, ha\u2082 with\n    | _, _, \u27e8b\u2081, l\u2081, l\u2082, a\u2081_nin_l\u2081, rfl, rfl\u27e9, a\u2082_in_l\u2081_app_l\u2082 :=\n      if h' : a\u2082 \u2208 l\u2081.keys then\n        by simp [kerase_append_left h',\n                 kerase_append_right (mt (mem_keys_kerase_of_ne h).mp a\u2081_nin_l\u2081)]\n      else\n        by simp [kerase_append_right h', kerase_append_right a\u2081_nin_l\u2081,\n                 @kerase_cons_ne _ _ _ a\u2082 \u27e8a\u2081, b\u2081\u27e9 _ (ne.symm h)]\n    end\n  else\n    by simp [ha\u2082, mt mem_keys_of_mem_keys_kerase ha\u2082]\nelse\n  by simp [ha\u2081, mt mem_keys_of_mem_keys_kerase ha\u2081]\n\nlemma sizeof_kerase {\u03b1} {\u03b2 : \u03b1 \u2192 Type*} [decidable_eq \u03b1] [has_sizeof (sigma \u03b2)] (x : \u03b1)\n  (xs : list (sigma \u03b2)) :\n  sizeof (list.kerase x xs) \u2264 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 `\u27e8a, b\u27e9` and erase the first pair with the key `a`. -/\ndef kinsert (a : \u03b1) (b : \u03b2 a) (l : list (sigma \u03b2)) : list (sigma \u03b2) :=\n\u27e8a, b\u27e9 :: kerase a l\n\n@[simp] theorem kinsert_def {a} {b : \u03b2 a} {l : list (sigma \u03b2)} :\n  kinsert a b l = \u27e8a, b\u27e9 :: kerase a l := rfl\n\ntheorem mem_keys_kinsert {a a'} {b' : \u03b2 a'} {l : list (sigma \u03b2)} :\n  a \u2208 (kinsert a' b' l).keys \u2194 a = a' \u2228 a \u2208 l.keys :=\nby by_cases h : a = a'; simp [h]\n\ntheorem kinsert_nodupkeys (a) (b : \u03b2 a) {l : list (sigma \u03b2)} (nd : l.nodupkeys) :\n  (kinsert a b l).nodupkeys :=\nnodupkeys_cons.mpr \u27e8not_mem_keys_kerase a nd, kerase_nodupkeys a nd\u27e9\n\ntheorem perm.kinsert {a} {b : \u03b2 a} {l\u2081 l\u2082 : list (sigma \u03b2)} (nd\u2081 : l\u2081.nodupkeys)\n  (p : l\u2081 ~ l\u2082) : kinsert a b l\u2081 ~ kinsert a b l\u2082 :=\n(p.kerase nd\u2081).cons _\n\ntheorem lookup_kinsert {a} {b : \u03b2 a} (l : list (sigma \u03b2)) :\n  lookup a (kinsert a b l) = some b :=\nby simp only [kinsert, lookup_cons_eq]\n\ntheorem lookup_kinsert_ne {a a'} {b' : \u03b2 a'} {l : list (sigma \u03b2)} (h : a \u2260 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 : \u03b1) : list (sigma \u03b2) \u2192 option (\u03b2 a) \u00d7 list (sigma \u03b2)\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 : \u03b1) :\n  \u2200 l : list (sigma \u03b2), kextract a l = (lookup a l, kerase a l)\n| []     := rfl\n| (\u27e8a', b\u27e9::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 \u03b2)`. -/\ndef erase_dupkeys : list (sigma \u03b2) \u2192 list (sigma \u03b2) :=\nlist.foldr (\u03bb x, kinsert x.1 x.2) []\n\nlemma erase_dupkeys_cons {x : sigma \u03b2} (l : list (sigma \u03b2)) :\n  erase_dupkeys (x :: l) = kinsert x.1 x.2 (erase_dupkeys l) := rfl\n\nlemma nodupkeys_erase_dupkeys (l : list (sigma \u03b2)) : nodupkeys (erase_dupkeys l) :=\nbegin\n  dsimp [erase_dupkeys], generalize hl : nil = l',\n  have : nodupkeys l', { rw \u2190 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 : \u03b1) (l : list (sigma \u03b2)) : 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 {\u03b1} {\u03b2 : \u03b1 \u2192 Type*} [decidable_eq \u03b1] [has_sizeof (sigma \u03b2)]\n  (xs : list (sigma \u03b2)) :\n  sizeof (list.erase_dupkeys xs) \u2264 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\u2081 l\u2082` is the append to l\u2081 of l\u2082 after, for each key in l\u2081, the\nfirst matching pair in l\u2082 is erased. -/\ndef kunion : list (sigma \u03b2) \u2192 list (sigma \u03b2) \u2192 list (sigma \u03b2)\n| []        l\u2082 := l\u2082\n| (s :: l\u2081) l\u2082 := s :: kunion l\u2081 (kerase s.1 l\u2082)\n\n@[simp] theorem nil_kunion {l : list (sigma \u03b2)} : kunion [] l = l :=\nrfl\n\n@[simp] theorem kunion_nil : \u2200 {l : list (sigma \u03b2)}, kunion l [] = l\n| []       := rfl\n| (_ :: l) := by rw [kunion, kerase_nil, kunion_nil]\n\n@[simp] theorem kunion_cons {s} {l\u2081 l\u2082 : list (sigma \u03b2)} :\n  kunion (s :: l\u2081) l\u2082 = s :: kunion l\u2081 (kerase s.1 l\u2082) :=\nrfl\n\n@[simp] theorem mem_keys_kunion {a} {l\u2081 l\u2082 : list (sigma \u03b2)} :\n  a \u2208 (kunion l\u2081 l\u2082).keys \u2194 a \u2208 l\u2081.keys \u2228 a \u2208 l\u2082.keys :=\nbegin\n  induction l\u2081 generalizing l\u2082,\n  case list.nil { simp },\n  case list.cons : s l\u2081 ih { by_cases h : a = s.1; [simp [h], simp [h, ih]] }\nend\n\n@[simp] theorem kunion_kerase {a} : \u2200 {l\u2081 l\u2082 : list (sigma \u03b2)},\n  kunion (kerase a l\u2081) (kerase a l\u2082) = kerase a (kunion l\u2081 l\u2082)\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\u2081 l\u2082 : list (sigma \u03b2)}\n  (nd\u2081 : l\u2081.nodupkeys) (nd\u2082 : l\u2082.nodupkeys) : (kunion l\u2081 l\u2082).nodupkeys :=\nbegin\n  induction l\u2081 generalizing l\u2082,\n  case list.nil { simp only [nil_kunion, nd\u2082] },\n  case list.cons : s l\u2081 ih\n  { simp at nd\u2081,\n    simp [not_or_distrib, nd\u2081.1, nd\u2082, ih nd\u2081.2 (kerase_nodupkeys s.1 nd\u2082)] }\nend\n\ntheorem perm.kunion_right {l\u2081 l\u2082 : list (sigma \u03b2)} (p : l\u2081 ~ l\u2082) (l) :\n  kunion l\u2081 l ~ kunion l\u2082 l :=\nbegin\n  induction p generalizing l,\n  case list.perm.nil { refl },\n  case list.perm.cons : hd tl\u2081 tl\u2082 p ih\n  { simp [ih (kerase hd.1 l), perm.cons] },\n  case list.perm.swap : s\u2081 s\u2082 l\n  { simp [kerase_comm, perm.swap] },\n  case list.perm.trans : l\u2081 l\u2082 l\u2083 p\u2081\u2082 p\u2082\u2083 ih\u2081\u2082 ih\u2082\u2083\n  { exact perm.trans (ih\u2081\u2082 l) (ih\u2082\u2083 l) }\nend\n\ntheorem perm.kunion_left : \u2200 l {l\u2081 l\u2082 : list (sigma \u03b2)},\n  l\u2081.nodupkeys \u2192 l\u2081 ~ l\u2082 \u2192 kunion l l\u2081 ~ kunion l l\u2082\n| []       _  _  _   p := p\n| (s :: l) l\u2081 l\u2082 nd\u2081 p :=\n  by simp [((p.kerase nd\u2081).kunion_left l (kerase_nodupkeys s.1 nd\u2081)).cons s]\n\ntheorem perm.kunion {l\u2081 l\u2082 l\u2083 l\u2084 : list (sigma \u03b2)} (nd\u2083 : l\u2083.nodupkeys)\n  (p\u2081\u2082 : l\u2081 ~ l\u2082) (p\u2083\u2084 : l\u2083 ~ l\u2084) : kunion l\u2081 l\u2083 ~ kunion l\u2082 l\u2084 :=\n(p\u2081\u2082.kunion_right l\u2083).trans (p\u2083\u2084.kunion_left l\u2082 nd\u2083)\n\n@[simp] theorem lookup_kunion_left {a} {l\u2081 l\u2082 : list (sigma \u03b2)} (h : a \u2208 l\u2081.keys) :\n  lookup a (kunion l\u2081 l\u2082) = lookup a l\u2081 :=\nbegin\n  induction l\u2081 with s _ ih generalizing l\u2082; 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\u2081 l\u2082 : list (sigma \u03b2)} (h : a \u2209 l\u2081.keys) :\n  lookup a (kunion l\u2081 l\u2082) = lookup a l\u2082 :=\nbegin\n  induction l\u2081 generalizing l\u2082,\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 : \u03b2 a} {l\u2081 l\u2082 : list (sigma \u03b2)} :\n  b \u2208 lookup a (kunion l\u2081 l\u2082) \u2194 b \u2208 lookup a l\u2081 \u2228 a \u2209 l\u2081.keys \u2227 b \u2208 lookup a l\u2082 :=\nbegin\n  induction l\u2081 generalizing l\u2082,\n  case list.nil { simp },\n  case list.cons : s _ ih\n  { cases s with a',\n    by_cases h\u2081 : a = a',\n    { subst h\u2081, simp },\n    { let h\u2082 := @ih (kerase a' l\u2082), simp [h\u2081] at h\u2082, simp [h\u2081, h\u2082] } }\nend\n\ntheorem mem_lookup_kunion_middle {a} {b : \u03b2 a} {l\u2081 l\u2082 l\u2083 : list (sigma \u03b2)}\n  (h\u2081 : b \u2208 lookup a (kunion l\u2081 l\u2083)) (h\u2082 : a \u2209 keys l\u2082) :\n  b \u2208 lookup a (kunion (kunion l\u2081 l\u2082) l\u2083) :=\nmatch mem_lookup_kunion.mp h\u2081 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 \u27e8mt mem_keys_kunion.mp (not_or_distrib.mpr \u27e8h.1, h\u2082\u27e9), h.2\u27e9\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 `\u2a01 i, A i`\n\nThis module provides a set of heterogeneous typeclasses for defining a multiplicative structure\nover `\u2a01 i, A i` such that `(*) : A i \u2192 A j \u2192 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 `\u2a01 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 (`\u2022`) 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, `\u2a01 i, A i` itself inherits an `A 0`-action.\n\n`direct_sum.of_zero_ring_hom : A 0 \u2192+* \u2a01 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 : \u03b9 \u2192 submonoid S`:\n  `direct_sum.gsemiring.of_add_submonoids`, `direct_sum.gcomm_semiring.of_add_submonoids`.\n* `A : \u03b9 \u2192 subgroup S`:\n  `direct_sum.gsemiring.of_add_subgroups`, `direct_sum.gcomm_semiring.of_add_subgroups`.\n* `A : \u03b9 \u2192 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 `\u2a06 i, A i`, and the\nmapping `\u2a01 i, A i \u2192+ \u2a06 i, A i` can be obtained as\n`direct_sum.to_monoid (\u03bb i, add_submonoid.inclusion $ le_supr A i)`.\n\n## tags\n\ngraded ring, filtered ring, direct sum, add_submonoid\n-/\n\n\nvariable {\u03b9 : Type _} [DecidableEq \u03b9]\n\nnamespace DirectSum\n\nopen DirectSum\n\n/-! ### Typeclasses -/\n\n\nsection Defs\n\nvariable (A : \u03b9 \u2192 Type _)\n\n/-- A graded version of `non_unital_non_assoc_semiring`. -/\nclass GnonUnitalNonAssocSemiring [Add \u03b9] [\u2200 i, AddCommMonoid (A i)] extends\n  GradedMonoid.GMul A where\n  mul_zero : \u2200 {i j} (a : A i), mul a (0 : A j) = 0\n  zero_mul : \u2200 {i j} (b : A j), mul (0 : A i) b = 0\n  mul_add : \u2200 {i j} (a : A i) (b c : A j), mul a (b + c) = mul a b + mul a c\n  add_mul : \u2200 {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 : \u03b9 \u2192 Type _)\n\n/-- A graded version of `semiring`. -/\nclass Gsemiring [AddMonoid \u03b9] [\u2200 i, AddCommMonoid (A i)] extends GnonUnitalNonAssocSemiring A,\n  GradedMonoid.GMonoid A where\n  natCast : \u2115 \u2192 A 0\n  natCast_zero : nat_cast 0 = 0\n  natCast_succ : \u2200 n : \u2115, 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 \u03b9] [\u2200 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 \u03b9] [\u2200 i, AddCommGroup (A i)] extends Gsemiring A where\n  intCast : \u2124 \u2192 A 0\n  intCast_ofNat : \u2200 n : \u2115, int_cast n = nat_cast n\n  intCast_negSucc : \u2200 n : \u2115, int_cast (-(n + 1 : \u2115)) = -nat_cast (n + 1 : \u2115)\n#align direct_sum.gring DirectSum.Gring\n\n/-- A graded version of `comm_ring`. -/\nclass GcommRing [AddCommMonoid \u03b9] [\u2200 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 : \u03b9 \u2192 Type _} [\u2200 i : \u03b9, AddCommMonoid (A i)] {i j : \u03b9} {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 : \u03b9 \u2192 Type _)\n\n/-! ### Instances for `\u2a01 i, A i` -/\n\n\nsection One\n\nvariable [Zero \u03b9] [GradedMonoid.GOne A] [\u2200 i, AddCommMonoid (A i)]\n\ninstance : One (\u2a01 i, A i) where one := DirectSum.of (fun i => A i) 0 GradedMonoid.GOne.one\n\nend One\n\nsection Mul\n\nvariable [Add \u03b9] [\u2200 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 \u2192+ A j \u2192+ 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\u2081 a\u2082 := 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 : (\u2a01 i, A i) \u2192+ (\u2a01 i, A i) \u2192+ \u2a01 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 (\u2a01 i, A i) :=\n  { DirectSum.addCommMonoid _ _ with\n    mul := fun a b => mulHom A a b\n    zero := 0\n    add := (\u00b7 + \u00b7)\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 [\u2200 i, AddCommMonoid (A i)] [AddMonoid \u03b9] [Gsemiring A]\n\nopen AddMonoidHom (flipHom coe_comp compHom_apply_apply flip_apply flipHom_apply)\n\nprivate theorem one_mul (x : \u2a01 i, A i) : 1 * x = x :=\n  by\n  suffices mulHom A 1 = AddMonoidHom.id (\u2a01 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 : \u2a01 i, A i) : x * 1 = x :=\n  by\n  suffices (mulHom A).flip 1 = AddMonoidHom.id (\u2a01 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 : \u2a01 i, A i) : a * b * c = a * (b * c) :=\n  by\n  suffices\n    (-- `\u03bb a b c, a * b * c` as a bundled hom\n              mulHom\n              A).compHom.comp\n        (mulHom A) =\n      (AddMonoidHom.compHom flipHom <|\n          (-- `\u03bb 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) \u27e8bi, bx\u27e9 \u27e8ci, cx\u27e9)\n#align direct_sum.mul_assoc direct_sum.mul_assoc\n\n/-- The `semiring` structure derived from `gsemiring A`. -/\ninstance semiring : Semiring (\u2a01 i, A i) :=\n  { DirectSum.nonUnitalNonAssocSemiring _ with\n    one := 1\n    mul := (\u00b7 * \u00b7)\n    zero := 0\n    add := (\u00b7 + \u00b7)\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 : \u2115) :\n    of _ i a ^ n = of _ (n \u2022 i) (GradedMonoid.GMonoid.gnpow _ a) :=\n  by\n  induction' n with n\n  \u00b7 exact of_eq_of_graded_monoid_eq (pow_zero <| GradedMonoid.mk _ a).symm\n  \u00b7 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 {\u03b1} (l : List \u03b1) (f\u03b9 : \u03b1 \u2192 \u03b9) (fA : \u2200 a, A (f\u03b9 a)) :\n    of A _ (l.dProd f\u03b9 fA) = (l.map fun a => of A (f\u03b9 a) (fA a)).Prod :=\n  by\n  induction l\n  \u00b7 simp only [List.map_nil, List.prod_nil, List.dProd_nil]\n    rfl\n  \u00b7 simp only [List.map_cons, List.prod_cons, List.dProd_cons, \u2190 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 : \u2115) (f\u03b9 : Fin n \u2192 \u03b9) (fA : \u2200 a, A (f\u03b9 a)) :\n    (List.ofFn fun a => of A (f\u03b9 a) (fA a)).Prod = of A _ ((List.finRange n).dProd f\u03b9 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 [\u2200 (i : \u03b9) (x : A i), Decidable (x \u2260 0)] (a a' : \u2a01 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 [\u2200 (i : \u03b9) (x : A i), Decidable (x \u2260 0)] (a a' : \u2a01 i, A i) :\n    a * a' =\n      \u2211 ij in Dfinsupp.support a \u00d7\u02e2 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 [\u2200 i, AddCommMonoid (A i)] [AddCommMonoid \u03b9] [GcommSemiring A]\n\nprivate theorem mul_comm (a b : \u2a01 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 \u27e8ai, ax\u27e9 \u27e8bi, bx\u27e9)\n#align direct_sum.mul_comm direct_sum.mul_comm\n\n/-- The `comm_semiring` structure derived from `gcomm_semiring A`. -/\ninstance commSemiring : CommSemiring (\u2a01 i, A i) :=\n  { DirectSum.semiring _ with\n    one := 1\n    mul := (\u00b7 * \u00b7)\n    zero := 0\n    add := (\u00b7 + \u00b7)\n    mul_comm := mul_comm A }\n#align direct_sum.comm_semiring DirectSum.commSemiring\n\nend CommSemiring\n\nsection NonUnitalNonAssocRing\n\nvariable [\u2200 i, AddCommGroup (A i)] [Add \u03b9] [GnonUnitalNonAssocSemiring A]\n\n/-- The `ring` derived from `gsemiring A`. -/\ninstance nonAssocRing : NonUnitalNonAssocRing (\u2a01 i, A i) :=\n  { DirectSum.nonUnitalNonAssocSemiring _,\n    DirectSum.addCommGroup _ with\n    mul := (\u00b7 * \u00b7)\n    zero := 0\n    add := (\u00b7 + \u00b7)\n    neg := Neg.neg }\n#align direct_sum.non_assoc_ring DirectSum.nonAssocRing\n\nend NonUnitalNonAssocRing\n\nsection Ring\n\nvariable [\u2200 i, AddCommGroup (A i)] [AddMonoid \u03b9] [Gring A]\n\n/-- The `ring` derived from `gsemiring A`. -/\ninstance ring : Ring (\u2a01 i, A i) :=\n  { DirectSum.semiring _,\n    DirectSum.addCommGroup _ with\n    one := 1\n    mul := (\u00b7 * \u00b7)\n    zero := 0\n    add := (\u00b7 + \u00b7)\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 [\u2200 i, AddCommGroup (A i)] [AddCommMonoid \u03b9] [GcommRing A]\n\n/-- The `comm_ring` derived from `gcomm_semiring A`. -/\ninstance commRing : CommRing (\u2a01 i, A i) :=\n  { DirectSum.ring _,\n    DirectSum.commSemiring _ with\n    one := 1\n    mul := (\u00b7 * \u00b7)\n    zero := 0\n    add := (\u00b7 + \u00b7)\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 \u03b9] [GradedMonoid.GOne A] [\u2200 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 \u03b9] [\u2200 i, AddCommMonoid (A i)] [GnonUnitalNonAssocSemiring A]\n\n@[simp]\ntheorem of_zero_smul {i} (a : A 0) (b : A i) : of _ _ (a \u2022 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 : \u03b9) : SMulWithZero (A 0) (A i) :=\n  by\n  letI := SMulWithZero.compHom (\u2a01 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 [\u2200 i, AddCommMonoid (A i)] [AddMonoid \u03b9] [Gsemiring A]\n\n@[simp]\ntheorem of_zero_pow (a : A 0) : \u2200 n : \u2115, 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  \u27e8Gsemiring.natCast\u27e9\n\n@[simp]\ntheorem of_nat_cast (n : \u2115) : 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 \u2192+* \u2a01 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) (\u2a01 i, A i)` structure via `direct_sum.module`.\n-/\ninstance GradeZero.module {i} : Module (A 0) (A i) :=\n  letI := Module.compHom (\u2a01 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 [\u2200 i, AddCommMonoid (A i)] [AddCommMonoid \u03b9] [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 [\u2200 i, AddCommGroup (A i)] [AddZeroClass \u03b9] [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 : \u2200 i, DistribMulAction \u2115 (A i) := fun i => inferInstance\n      Dfinsupp.single_smul n x)\n    fun x n =>\n    letI : \u2200 i, DistribMulAction \u2124 (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 [\u2200 i, AddCommGroup (A i)] [AddMonoid \u03b9] [Gring A]\n\ninstance : IntCast (A 0) :=\n  \u27e8Gring.intCast\u27e9\n\n@[simp]\ntheorem of_int_cast (n : \u2124) : 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 : \u2200 i, DistribMulAction \u2115 (A i) := fun i => inferInstance\n      Dfinsupp.single_smul n x)\n    (fun x n =>\n      letI : \u2200 i, DistribMulAction \u2124 (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 [\u2200 i, AddCommGroup (A i)] [AddCommMonoid \u03b9] [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 : \u2200 i, DistribMulAction \u2115 (A i) := fun i => inferInstance\n      Dfinsupp.single_smul n x)\n    (fun x n =>\n      letI : \u2200 i, DistribMulAction \u2124 (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 _} [\u2200 i, AddCommMonoid (A i)] [AddMonoid \u03b9] [Gsemiring A] [Semiring R]\n\nvariable {A}\n\n/-- If two ring homomorphisms from `\u2a01 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' \u2983F G : (\u2a01 i, A i) \u2192+* R\u2984\n    (h : \u2200 i, (\u2191F : _ \u2192+ R).comp (of A i) = (\u2191G : _ \u2192+ 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 \u2983f g : (\u2a01 i, A i) \u2192+* R\u2984 (h : \u2200 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 `\u2a01 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 : \u2200 i, A i \u2192+ R) (hone : f _ GradedMonoid.GOne.one = 1)\n    (hmul : \u2200 {i j} (ai : A i) (aj : A j), f _ (GradedMonoid.GMul.mul ai aj) = f _ ai * f _ aj) :\n    (\u2a01 i, A i) \u2192+* 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 : \u2200 i, A i \u2192+ R) (hone hmul) (i : \u03b9) (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 : \u2200 i, A i \u2192+ R) (hone hmul) :\n    (toSemiring f hone hmul : (\u2a01 i, A i) \u2192+ 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 `\u2a01 i, A i`. This is a stronger version of `dfinsupp.lift_add_hom`.\n-/\n@[simps]\ndef liftRingHom :\n    { f : \u2200 {i}, A i \u2192+ R //\n        f GradedMonoid.GOne.one = 1 \u2227\n          \u2200 {i j} (ai : A i) (aj : A j), f (GradedMonoid.GMul.mul ai aj) = f ai * f aj } \u2243\n      ((\u2a01 i, A i) \u2192+* R)\n    where\n  toFun f := toSemiring (fun _ => f.1) f.2.1 fun _ _ => f.2.2\n  invFun F :=\n    \u27e8fun i => (F : (\u2a01 i, A i) \u2192+ R).comp (of _ i),\n      by\n      simp only [AddMonoidHom.comp_apply, [anonymous]]\n      rw [\u2190 F.map_one]\n      rfl, fun i j ai aj =>\n      by\n      simp only [AddMonoidHom.comp_apply, [anonymous]]\n      rw [\u2190 F.map_mul, of_mul_of]\u27e9\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 (\u03b9)\n\n/-- A direct sum of copies of a `semiring` inherits the multiplication structure. -/\ninstance NonUnitalNonAssocSemiring.directSumGnonUnitalNonAssocSemiring {R : Type _} [AddMonoid \u03b9]\n    [NonUnitalNonAssocSemiring R] : DirectSum.GnonUnitalNonAssocSemiring fun i : \u03b9 => R :=\n  { Mul.gMul \u03b9 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 \u03b9] [Semiring R] :\n    DirectSum.Gsemiring fun i : \u03b9 => R :=\n  { NonUnitalNonAssocSemiring.directSumGnonUnitalNonAssocSemiring \u03b9,\n    Monoid.gMonoid \u03b9 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 \u03b9] [Semiring R] (i j : \u03b9) (a b : R) :\n    (DirectSum.of _ i a * DirectSum.of _ j b : \u2a01 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 \u03b9] [CommSemiring R] :\n    DirectSum.GcommSemiring fun i : \u03b9 => R :=\n  { CommMonoid.gCommMonoid \u03b9, Semiring.directSumGsemiring \u03b9 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 \u00d7 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 \u2192 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 {\u03b1 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 \u2039_\u203a \u2293 TopologicalSpace.induced snd \u2039_\u203a\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 \u2192 R) :=\n  continuous_fst\n#align triv_sq_zero_ext.continuous_fst TrivSqZeroExt.continuous_fst\n\ntheorem continuous_snd : Continuous (snd : tsze R M \u2192 M) :=\n  continuous_snd\n#align triv_sq_zero_ext.continuous_snd TrivSqZeroExt.continuous_snd\n\ntheorem continuous_inl [Zero M] : Continuous (inl : R \u2192 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 \u2192 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 \u2192 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 \u2192 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 \u2192L[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 \u2192L[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 \u2192L[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 \u2192L[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\u1d50\u1d52\u1d56 M] [ContinuousMul R] [ContinuousSMul R M]\n    [ContinuousSMul R\u1d50\u1d52\u1d56 M] [ContinuousAdd M] : ContinuousMul (tsze R M) :=\n  \u27e8((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))\u27e9\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\u1d50\u1d52\u1d56 M]\n    [TopologicalSemiring R] [ContinuousAdd M] [ContinuousSMul R M]\n    [ContinuousSMul R\u1d50\u1d52\u1d56\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\u1d50\u1d52\u1d56 M] [TopologicalRing R]\n    [TopologicalAddGroup M] [ContinuousSMul R M] [ContinuousSMul R\u1d50\u1d52\u1d56 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 : \u03b1 \u2192 R} {a : R} (h : HasSum f a) :\n    HasSum (fun x => inl (f x)) (inl a : tsze R M) :=\n  h.map (\u27e8inl, inl_zero _, inl_add _\u27e9 : R \u2192+ 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 : \u03b1 \u2192 M} {a : M} (h : HasSum f a) :\n    HasSum (fun x => inr (f x)) (inr a : tsze R M) :=\n  h.map (\u27e8inr, inr_zero _, inr_add _\u27e9 : M \u2192+ 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 : \u03b1 \u2192 tsze R M} {a : tsze R M}\n    (h : HasSum f a) : HasSum (fun x => fst (f x)) (fst a) :=\n  h.map (\u27e8fst, fst_zero, fst_add\u27e9 : tsze R M \u2192+ R) continuous_fst\n#align triv_sq_zero_ext.has_sum_fst TrivSqZeroExt.hasSum_fst\n\ntheorem hasSum_snd [AddCommMonoid R] [AddCommMonoid M] {f : \u03b1 \u2192 tsze R M} {a : tsze R M}\n    (h : HasSum f a) : HasSum (fun x => snd (f x)) (snd a) :=\n  h.map (\u27e8snd, snd_zero, snd_add\u27e9 : tsze R M \u2192+ 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) := \u2200 t, s t \u2264 s (t+1).\ndef is_positive {b: Type} [ordered_add_comm_group b]\n  (f: stream a \u2192 stream b) := \u2200 s, positive s \u2192 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 \u2194 (\u2200 t1 t2, t1 \u2264 t2 \u2192 s t1 \u2264 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 \u2192 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 \u2264 s 0 \u2192\n  stream_monotone s \u2192 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  (\u2203 (x:a), x < 0) \u2192\n  \u00ac(\u2200 (s: stream a), stream_monotone s \u2192 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  -- \u2203 (x : stream a), stream_monotone x \u2227 \u00acpositive (D x)\n  use (\u03bb _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 : \u2200 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 := \u03bb X : LocallyRingedSpace, (X.to_Top : Type u), }\n\n-- PROJECT: how about a typeclass \"has_structure_sheaf\" to mediate the \ud835\udcaa 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 \ud835\udcaa : 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 \u27f6 Y.to_SheafedSpace //\n    \u2200 x, is_local_ring_hom (PresheafedSpace.stalk_map f x) }\n\ninstance : quiver LocallyRingedSpace := \u27e8hom\u27e9\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.\ud835\udcaa.stalk` here?\nnoncomputable\ndef stalk (X : LocallyRingedSpace) (x : X) : CommRing := X.presheaf.stalk x\n\n/--\nA morphism of locally ringed spaces `f : X \u27f6 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 \u27f6 Y) (x : X) :\n  Y.stalk (f.1.1 x) \u27f6 X.stalk x :=\nPresheafedSpace.stalk_map f.1 x\n\ninstance {X Y : LocallyRingedSpace} (f : X \u27f6 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\u27e8\ud835\udfd9 _, \u03bb x, by { erw PresheafedSpace.stalk_map.id, apply is_local_ring_hom_id, }\u27e9\n\ninstance (X : LocallyRingedSpace) : inhabited (hom X X) := \u27e8id X\u27e9\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\u27e8f.val \u226b g.val, \u03bb x,\nbegin\n  erw PresheafedSpace.stalk_map.comp,\n  exact @is_local_ring_hom_comp _ _ _ _ _ _ _ _ (f.2 _) (g.2 _),\nend\u27e9\n\n/-- The category of locally ringed spaces. -/\ninstance : category LocallyRingedSpace :=\n{ hom := hom,\n  id := id,\n  comp := \u03bb 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 \u2964 SheafedSpace CommRing :=\n{ obj := \u03bb X, X.to_SheafedSpace,\n  map := \u03bb 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 \u27f6 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 \u0393 : LocallyRingedSpace\u1d52\u1d56 \u2964 CommRing :=\nforget_to_SheafedSpace.op \u22d9 SheafedSpace.\u0393\n\nlemma \u0393_def : \u0393 = forget_to_SheafedSpace.op \u22d9 SheafedSpace.\u0393 := rfl\n\n@[simp] lemma \u0393_obj (X : LocallyRingedSpace\u1d52\u1d56) : \u0393.obj X = (unop X).presheaf.obj (op \u22a4) := rfl\n\nlemma \u0393_obj_op (X : LocallyRingedSpace) : \u0393.obj (op X) = X.presheaf.obj (op \u22a4) := rfl\n\n@[simp] lemma \u0393_map {X Y : LocallyRingedSpace\u1d52\u1d56} (f : X \u27f6 Y) :\n  \u0393.map f = f.unop.1.c.app (op \u22a4) \u226b (unop Y).presheaf.map (opens.le_map_top _ _).op := rfl\n\nlemma \u0393_map_op {X Y : LocallyRingedSpace} (f : X \u27f6 Y) :\n  \u0393.map f.op = f.1.c.app (op \u22a4) \u226b 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 `\u0393 \u22a3 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 \u27f6 S) :\n  Spec.Top_obj S \u27f6 Spec.Top_obj R :=\nprime_spectrum.comap f\n\n@[simp] lemma Spec.Top_map_id (R : CommRing) :\n  Spec.Top_map (\ud835\udfd9 R) = \ud835\udfd9 (Spec.Top_obj R) :=\nprime_spectrum.comap_id\n\nlemma Spec.Top_map_comp {R S T : CommRing} (f : R \u27f6 S) (g : S \u27f6 T) :\n  Spec.Top_map (f \u226b g) = Spec.Top_map g \u226b 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\u1d52\u1d56 \u2964 Top :=\n{ obj := \u03bb R, Spec.Top_obj (unop R),\n  map := \u03bb R S f, Spec.Top_map f.unop,\n  map_id' := \u03bb R, by rw [unop_id, Spec.Top_map_id],\n  map_comp' := \u03bb 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 \u27f6 S) :\n  Spec.SheafedSpace_obj S \u27f6 Spec.SheafedSpace_obj R :=\n{ base := Spec.Top_map f,\n  c :=\n  { app := \u03bb U, comap f (unop U) ((topological_space.opens.map (Spec.Top_map f)).obj (unop U))\n      (\u03bb p, id),\n    naturality' := \u03bb U V i, ring_hom.ext $ \u03bb s, subtype.eq $ funext $ \u03bb p, rfl } }\n\n@[simp] lemma Spec.SheafedSpace_map_id {R : CommRing} :\n  Spec.SheafedSpace_map (\ud835\udfd9 R) = \ud835\udfd9 (Spec.SheafedSpace_obj R) :=\nPresheafedSpace.ext _ _ (Spec.Top_map_id R) $ nat_trans.ext _ _ $ funext $ \u03bb 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 \u27f6 S) (g : S \u27f6 T) :\n  Spec.SheafedSpace_map (f \u226b g) = Spec.SheafedSpace_map g \u226b Spec.SheafedSpace_map f :=\nPresheafedSpace.ext _ _ (Spec.Top_map_comp f g) $ nat_trans.ext _ _ $ funext $ \u03bb 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\u1d52\u1d56 \u2964 SheafedSpace CommRing :=\n{ obj := \u03bb R, Spec.SheafedSpace_obj (unop R),\n  map := \u03bb R S f, Spec.SheafedSpace_map f.unop,\n  map_id' := \u03bb R, by rw [unop_id, Spec.SheafedSpace_map_id],\n  map_comp' := \u03bb 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\u1d52\u1d56 \u2964 PresheafedSpace.{u} CommRing.{u} :=\n  Spec.to_SheafedSpace \u22d9 SheafedSpace.forget_to_PresheafedSpace\n\n@[simp] lemma Spec.to_PresheafedSpace_obj (R : CommRing\u1d52\u1d56) :\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\u1d52\u1d56) (f : R \u27f6 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 \u27f6 S) :\n  Spec.to_PresheafedSpace.map f.op = Spec.SheafedSpace_map f := rfl\n\nlemma Spec.basic_open_hom_ext {X : RingedSpace} {R : CommRing} {\u03b1 \u03b2 : X \u27f6 Spec.SheafedSpace_obj R}\n  (w : \u03b1.base = \u03b2.base) (h : \u2200 r : R, let U := prime_spectrum.basic_open r in\n    (to_open R U \u226b \u03b1.c.app (op U)) \u226b X.presheaf.map (eq_to_hom (by rw w)) =\n     to_open R U \u226b \u03b2.c.app (op U)) : \u03b1 = \u03b2 :=\nbegin\n  ext1,\n  { apply ((Top.sheaf.pushforward \u03b2.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 := \u03bb 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 \u27f6 S) (p : prime_spectrum S) :\n  to_stalk R (prime_spectrum.comap f p) \u226b\n  PresheafedSpace.stalk_map (Spec.SheafedSpace_map f) p =\n  f \u226b to_stalk S p :=\nbegin\n  erw [\u2190 to_open_germ S \u22a4 \u27e8p, trivial\u27e9, \u2190 to_open_germ R \u22a4 \u27e8prime_spectrum.comap f p, trivial\u27e9,\n    category.assoc, PresheafedSpace.stalk_map_germ (Spec.SheafedSpace_map f) \u22a4 \u27e8p, trivial\u27e9,\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 \u27f6 S) (p : prime_spectrum S) :\n  (stalk_iso R (prime_spectrum.comap f p)).hom \u226b\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 _ _ _ _ $ \u03bb 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 \u27f6 S) :\n  Spec.LocallyRingedSpace_obj S \u27f6 Spec.LocallyRingedSpace_obj R :=\nLocallyRingedSpace.hom.mk (Spec.SheafedSpace_map f) $ \u03bb p, is_local_ring_hom.mk $ \u03bb 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 \u2190 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 (\ud835\udfd9 R) = \ud835\udfd9 (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 \u27f6 S) (g : S \u27f6 T) :\n  Spec.LocallyRingedSpace_map (f \u226b g) =\n  Spec.LocallyRingedSpace_map g \u226b 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\u1d52\u1d56 \u2964 LocallyRingedSpace :=\n{ obj := \u03bb R, Spec.LocallyRingedSpace_obj (unop R),\n  map := \u03bb R S f, Spec.LocallyRingedSpace_map f.unop,\n  map_id' := \u03bb R, by rw [unop_id, Spec.LocallyRingedSpace_map_id],\n  map_comp' := \u03bb R S T f g, by rw [unop_comp, Spec.LocallyRingedSpace_map_comp] }\n\nsection Spec_\u0393\nopen algebraic_geometry.LocallyRingedSpace\n\n/-- The counit morphism `R \u27f6 \u0393(Spec R)` given by `algebraic_geometry.structure_sheaf.to_open`.  -/\n@[simps {rhs_md := tactic.transparency.semireducible}]\ndef to_Spec_\u0393 (R : CommRing) : R \u27f6 \u0393.obj (op (Spec.to_LocallyRingedSpace.obj (op R))) :=\nstructure_sheaf.to_open R \u22a4\n\ninstance is_iso_to_Spec_\u0393 (R : CommRing) : is_iso (to_Spec_\u0393 R) :=\nby { cases R, apply structure_sheaf.is_iso_to_global }\n\n@[reassoc]\nlemma Spec_\u0393_naturality {R S : CommRing} (f : R \u27f6 S) :\n  f \u226b to_Spec_\u0393 S = to_Spec_\u0393 R \u226b \u0393.map (Spec.to_LocallyRingedSpace.map f.op).op :=\nby { ext, symmetry, apply localization.local_ring_hom_to_map }\n\n/-- The counit (`Spec_\u0393_identity.inv.op`) of the adjunction `\u0393 \u22a3 Spec` is an isomorphism. -/\n@[simps hom_app inv_app] def Spec_\u0393_identity : Spec.to_LocallyRingedSpace.right_op \u22d9 \u0393 \u2245 \ud835\udfed _ :=\niso.symm $ nat_iso.of_components (\u03bb R, as_iso (to_Spec_\u0393 R) : _) (\u03bb _ _, Spec_\u0393_naturality)\n\nend Spec_\u0393\n\n/-- The stalk map of `Spec M\u207b\u00b9R \u27f6 Spec R` is an iso for each `p : Spec M\u207b\u00b9R`. -/\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 \u2190 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 \u27f6 S) (p : prime_spectrum R)\n\n/--\nFor an algebra `f : R \u2192+* S`, this is the ring homomorphism `S \u2192+* (f\u2217 \ud835\udcaa\u209b)\u209a` 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 \u27f6 (Spec.Top_map f _* (structure_sheaf S).1).stalk p :=\nstructure_sheaf.to_open S \u22a4 \u226b\n  @Top.presheaf.germ _ _ _ _ (Spec.Top_map f _* (structure_sheaf S).1) \u22a4 \u27e8p, trivial\u27e9\n\n@[reassoc]\nlemma to_pushforward_stalk_comp :\n  f \u226b structure_sheaf.to_pushforward_stalk f p =\n  structure_sheaf.to_stalk R p \u226b\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_\u0393_naturality_assoc f _,\nend\n\ninstance : algebra R ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) :=\n(f \u226b 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 \u226b 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 \u27f6 (f\u2217 \ud835\udcaa\u209b)\u209a` for some\nalgebra `R \u27f6 S` and some `p : Spec R`.\n-/\n@[simps]\ndef to_pushforward_stalk_alg_hom :\n  S \u2192\u2090[R] (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).stalk p :=\n{ commutes' := \u03bb _, rfl, ..(structure_sheaf.to_pushforward_stalk (algebra_map R S) p) }\n\nlemma is_localized_module_to_pushforward_stalk_alg_hom_aux (y) :\n  \u2203 (x : S \u00d7 p.as_ideal.prime_compl), x.2 \u2022 y = to_pushforward_stalk_alg_hom R S p x.1 :=\nbegin\n  obtain \u27e8U, hp, s, e\u27e9 := Top.presheaf.germ_exist _ _ y,\n  obtain \u27e8_, \u27e8r, rfl\u27e9, hpr : p \u2208 prime_spectrum.basic_open r,\n    hrU : prime_spectrum.basic_open r \u2264 U\u27e9 := prime_spectrum.is_topological_basis_basic_opens\n      .exists_subset_of_mem_open (show p \u2208 \u2191U, from hp) U.2,\n  change prime_spectrum.basic_open r \u2264 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) \u27e8p, hpr\u27e9 _).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 \u2190 h at e,\n  clear_value s', clear_dependent U,\n  obtain \u27e8\u27e8s, \u27e8_, n, rfl\u27e9\u27e9, hsn\u27e9 := @is_localization.surj _ _ _\n    _ _ _ (structure_sheaf.is_localization.to_basic_open S $ algebra_map R S r) s',\n  refine \u27e8\u27e8s, \u27e8r, hpr\u27e9 ^ n\u27e9, _\u27e9,\n  rw [submonoid.smul_def, algebra.smul_def, algebra_map_pushforward_stalk, to_pushforward_stalk,\n    comp_apply, comp_apply],\n  iterate 2 { erw \u2190 (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).germ_res_apply\n    (hom_of_le le_top) \u27e8p, hpr\u27e9 },\n  rw [\u2190 e, \u2190 map_mul, mul_comm],\n  dsimp only [subtype.coe_mk] at hsn,\n  rw \u2190 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) \u27e8x, hx\u27e9).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      \u2190 (to_pushforward_stalk (algebra_map R S) p).map_zero, to_pushforward_stalk, comp_apply,\n      comp_apply, map_zero] at hx,\n    obtain \u27e8U, hpU, i\u2081, i\u2082, e\u27e9 := Top.presheaf.germ_eq _ _ _ _ _ _ hx,\n    obtain \u27e8_, \u27e8r, rfl\u27e9, hpr, hrU\u27e9 := prime_spectrum.is_topological_basis_basic_opens\n      .exists_subset_of_mem_open (show p \u2208 U.1, from hpU) U.2,\n    change prime_spectrum.basic_open r \u2264 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, \u2190 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 \u27e8\u27e8_, n, rfl\u27e9, e\u27e9 := (is_localization.mk'_eq_zero_iff _ _).mp this,\n    refine \u27e8\u27e8r, hpr\u27e9 ^ n, _\u27e9,\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\u2081 u\u2082\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u\u2081} [category.{v} C]\nvariables {D : Type u\u2082} [category.{v} D]\nvariables (G : C \u2964 D)\n\nnamespace category_theory.limits\n\nvariables {J : Type v} (f : J \u2192 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 : \u03a0 j, P \u27f6 f j) :\n  is_limit (G.map_cone (fan.mk P g)) \u2243\n  is_limit (fan.mk _ (\u03bb j, G.map (g j)) : fan (\u03bb 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 (\u03bb j, iso.refl (G.obj (f j.as))),\n  refine cones.ext (iso.refl _) (\u03bb 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 : \u03a0 j, P \u27f6 f j) (t : is_limit (fan.mk _ g)) :\n  is_limit (fan.mk (G.obj P) (\u03bb j, G.map (g j)) : fan (\u03bb 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 : \u03a0 j, P \u27f6 f j) (t : is_limit (fan.mk _ (\u03bb j, G.map (g j)) : fan (\u03bb 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 _ (\u03bb (j : J), G.map (pi.\u03c0 f j)) : fan (\u03bb j, G.obj (f j))) :=\nis_limit_fan_mk_obj_of_is_limit G f _ (product_is_product _)\n\nvariables [has_product (\u03bb (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 (\u03bb (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 (\u220f f) \u2245 \u220f (\u03bb 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 \u2190 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 : \u03a0 j, f j \u27f6 P) :\n  is_colimit (G.map_cocone (cofan.mk P g)) \u2243\n  is_colimit (cofan.mk _ (\u03bb j, G.map (g j)) : cofan (\u03bb 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 (\u03bb j, iso.refl (G.obj (f j.as))),\n  refine cocones.ext (iso.refl _) (\u03bb 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 : \u03a0 j, f j \u27f6 P) (t : is_colimit (cofan.mk _ g)) :\n  is_colimit (cofan.mk (G.obj P) (\u03bb j, G.map (g j)) : cofan (\u03bb 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 : \u03a0 j, f j \u27f6 P)\n  (t : is_colimit (cofan.mk _ (\u03bb j, G.map (g j)) : cofan (\u03bb 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 _ (\u03bb (j : J), G.map (sigma.\u03b9 f j)) : cofan (\u03bb j, G.obj (f j))) :=\nis_colimit_cofan_mk_obj_of_is_colimit G f _ (coproduct_is_coproduct _)\n\nvariables [has_coproduct (\u03bb (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 (\u03bb (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 (\u2210 f) \u2245 \u2210 (\u03bb 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 \u2190 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 \u2260 Three := begin\n    intro two_is_three,\n    have hatonosu : \u2200a b c: Two, a = b \u2228 b = c \u2228 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 `\u03b1` is a linear archimedean succ order and `\u03b2` is a linear\n  order, then for any monotone function `f` and `m n : \u03b1`, the union of intervals\n  `set.Ioc (f i) (f (order.succ i))`, `m \u2264 i < n`, is equal to `set.Ioc (f m) (f n)`;\n\n* `monotone.pairwise_disjoint_on_Ioc_succ`: if `\u03b1` is a linear succ order, `\u03b2` is a preorder, and\n  `f : \u03b1 \u2192 \u03b2` 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 {\u03b1 \u03b2 : Type _} [LinearOrder \u03b1]\n\nnamespace Monotone\n\n/- warning: monotone.bUnion_Ico_Ioc_map_succ -> Monotone.bunion\u1d62_Ico_Ioc_map_succ is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : SuccOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : IsSuccArchimedean.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2] [_inst_4 : LinearOrder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (LinearOrder.toLattice.{u2} \u03b2 _inst_4)))) f) -> (forall (m : \u03b1) (n : \u03b1), Eq.{succ u2} (Set.{u2} \u03b2) (Set.union\u1d62.{u2, succ u1} \u03b2 \u03b1 (fun (i : \u03b1) => Set.union\u1d62.{u2, 0} \u03b2 (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) i (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) m n)) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) i (Set.Ico.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) m n)) => Set.Ioc.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (LinearOrder.toLattice.{u2} \u03b2 _inst_4)))) (f i) (f (Order.succ.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 i))))) (Set.Ioc.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (LinearOrder.toLattice.{u2} \u03b2 _inst_4)))) (f m) (f n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : SuccOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : IsSuccArchimedean.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_2] [_inst_4 : LinearOrder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (DistribLattice.toLattice.{u1} \u03b2 (instDistribLattice.{u1} \u03b2 _inst_4))))) f) -> (forall (m : \u03b1) (n : \u03b1), Eq.{succ u1} (Set.{u1} \u03b2) (Set.union\u1d62.{u1, succ u2} \u03b2 \u03b1 (fun (i : \u03b1) => Set.union\u1d62.{u1, 0} \u03b2 (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) i (Set.Ico.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) m n)) (fun (H : Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) i (Set.Ico.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) m n)) => Set.Ioc.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (DistribLattice.toLattice.{u1} \u03b2 (instDistribLattice.{u1} \u03b2 _inst_4))))) (f i) (f (Order.succ.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_2 i))))) (Set.Ioc.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (DistribLattice.toLattice.{u1} \u03b2 (instDistribLattice.{u1} \u03b2 _inst_4))))) (f m) (f n)))\nCase conversion may be inaccurate. Consider using '#align monotone.bUnion_Ico_Ioc_map_succ Monotone.bunion\u1d62_Ico_Ioc_map_succ\u2093'. -/\n/-- If `\u03b1` is a linear archimedean succ order and `\u03b2` is a linear order, then for any monotone\nfunction `f` and `m n : \u03b1`, the union of intervals `set.Ioc (f i) (f (order.succ i))`, `m \u2264 i < n`,\nis equal to `set.Ioc (f m) (f n)` -/\ntheorem bunion\u1d62_Ico_Ioc_map_succ [SuccOrder \u03b1] [IsSuccArchimedean \u03b1] [LinearOrder \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (hf : Monotone f) (m n : \u03b1) : (\u22c3 i \u2208 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  \u00b7 rw [Ico_eq_empty_of_le hnm, Ioc_eq_empty_of_le (hf hnm), bUnion_empty]\n  \u00b7 refine' Succ.rec _ _ hmn\n    \u00b7 simp only [Ioc_self, Ico_self, bUnion_empty]\n    \u00b7 intro k hmk ihk\n      rw [\u2190 Ioc_union_Ioc_eq_Ioc (hf hmk) (hf <| le_succ _), union_comm, \u2190 ihk]\n      by_cases hk : IsMax k\n      \u00b7 rw [hk.succ_eq, Ioc_self, empty_union]\n      \u00b7 rw [Ico_succ_right_eq_insert_of_not_is_max hmk hk, bUnion_insert]\n#align monotone.bUnion_Ico_Ioc_map_succ Monotone.bunion\u1d62_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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : SuccOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ioc.{u2} \u03b2 _inst_3 (f n) (f (Order.succ.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : SuccOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ioc.{u1} \u03b2 _inst_3 (f n) (f (Order.succ.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear succ order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 \u27e8\u27e8_, h\u2081\u27e9, \u27e8h\u2082, _\u27e9\u27e9 =>\n      h\u2082.not_le <| h\u2081.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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : SuccOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ico.{u2} \u03b2 _inst_3 (f n) (f (Order.succ.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : SuccOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ico.{u1} \u03b2 _inst_3 (f n) (f (Order.succ.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear succ order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 \u27e8\u27e8_, h\u2081\u27e9, \u27e8h\u2082, _\u27e9\u27e9 =>\n      h\u2081.not_le <| (hf <| succ_le_of_lt hmn).trans h\u2082\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : SuccOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ioo.{u2} \u03b2 _inst_3 (f n) (f (Order.succ.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : SuccOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ioo.{u1} \u03b2 _inst_3 (f n) (f (Order.succ.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear succ order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : PredOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ioc.{u2} \u03b2 _inst_3 (f (Order.pred.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : PredOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ioc.{u1} \u03b2 _inst_3 (f (Order.pred.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear pred order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ioc (f (pred n)) (f n)) := by\n  simpa only [(\u00b7 \u2218 \u00b7), 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : PredOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ico.{u2} \u03b2 _inst_3 (f (Order.pred.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : PredOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ico.{u1} \u03b2 _inst_3 (f (Order.pred.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear pred order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ico (f (pred n)) (f n)) := by\n  simpa only [(\u00b7 \u2218 \u00b7), 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : PredOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ioo.{u2} \u03b2 _inst_3 (f (Order.pred.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : PredOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ioo.{u1} \u03b2 _inst_3 (f (Order.pred.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear pred order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : Monotone f) :\n    Pairwise (Disjoint on fun n => Ioo (f (pred n)) (f n)) := by\n  simpa only [(\u00b7 \u2218 \u00b7), 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : SuccOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ioc.{u2} \u03b2 _inst_3 (f (Order.succ.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : SuccOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ioc.{u1} \u03b2 _inst_3 (f (Order.succ.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear succ order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : SuccOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ico.{u2} \u03b2 _inst_3 (f (Order.succ.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : SuccOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ico.{u1} \u03b2 _inst_3 (f (Order.succ.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear succ order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : SuccOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ioo.{u2} \u03b2 _inst_3 (f (Order.succ.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)) (f n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : SuccOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ioo.{u1} \u03b2 _inst_3 (f (Order.succ.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear succ order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : PredOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ioc.{u2} \u03b2 _inst_3 (f n) (f (Order.pred.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : PredOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ioc.{u1} \u03b2 _inst_3 (f n) (f (Order.pred.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear pred order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : PredOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ico.{u2} \u03b2 _inst_3 (f n) (f (Order.pred.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : PredOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ico.{u1} \u03b2 _inst_3 (f n) (f (Order.pred.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear pred order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : PredOrder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_3 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_3 f) -> (Pairwise.{u1} \u03b1 (Function.onFun.{succ u1, succ u2, 1} \u03b1 (Set.{u2} \u03b2) Prop (Disjoint.{u2} (Set.{u2} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b2) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b2) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b2) (Set.completeBooleanAlgebra.{u2} \u03b2)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u2} (Set.{u2} \u03b2) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u2} (Set.{u2} \u03b2) (Set.booleanAlgebra.{u2} \u03b2)))) (fun (n : \u03b1) => Set.Ioo.{u2} \u03b2 _inst_3 (f n) (f (Order.pred.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 n)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : PredOrder.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_3 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Antitone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_3 f) -> (Pairwise.{u2} \u03b1 (Function.onFun.{succ u2, succ u1, 1} \u03b1 (Set.{u1} \u03b2) Prop (Disjoint.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b2) (Preorder.toLE.{u1} (Set.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b2) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b2) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b2) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b2) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b2) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b2) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b2))))))) (fun (n : \u03b1) => Set.Ioo.{u1} \u03b2 _inst_3 (f n) (f (Order.pred.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _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\u2093'. -/\n/-- If `\u03b1` is a linear pred order, `\u03b2` is a preorder, and `f : \u03b1 \u2192 \u03b2` 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 \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} (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 (\u03b1 : Sort _) where\n  neg : \u03b1 \u2192 \u03b1\n\nprefix:75 \"~\" => HasNeg.neg\n\n@[notation_class] class HasArrow (\u03b1 : Sort _) where\n  arrow : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\ninfixr:60 \" \u27f6 \" => HasArrow.arrow\n\n@[notation_class] class HasAnd (\u03b1 : Sort _) where\n  and : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\ninfixl:69 \" \u22cf \" => HasAnd.and\n\n@[match_pattern, notation_class] class HasOr (\u03b1 : Sort _) where\n  or : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\ninfixl:68 \" \u22ce \" => HasOr.or\n\nclass HasLogicSymbols (\u03b1 : Sort _)\n  extends Top \u03b1, Bot \u03b1, HasNeg \u03b1, HasArrow \u03b1, HasAnd \u03b1, HasOr \u03b1\n\n@[notation_class] class HasUniv (\u03b1 : \u2115 \u2192 Sort _) where\n  univ : \u2200 {n}, \u03b1 (n + 1) \u2192 \u03b1 n\n\nprefix:64 \"\u2200' \" => HasUniv.univ\n\nsection HasUniv\n\nvariable {\u03b1 : \u2115 \u2192 Sort u} [HasUniv \u03b1]\n\ndef univClosure : {n : \u2115} \u2192 \u03b1 n \u2192 \u03b1 0\n  | 0,     a => a\n  | _ + 1, a => univClosure (\u2200' a)\n\n@[simp] lemma univ_closure_zero (a : \u03b1 0) : univClosure a = a := rfl\n\n@[simp] lemma univ_closure_succ {n} (a : \u03b1 (n + 1)) : univClosure a = univClosure (\u2200' a) := rfl\n\nend HasUniv\n\n@[notation_class] class HasEx (\u03b1 : \u2115 \u2192 Sort _) where\n  ex : \u2200 {n}, \u03b1 (n + 1) \u2192 \u03b1 n\n\nprefix:64 \"\u2203' \" => HasEx.ex\n\nattribute [match_pattern] HasNeg.neg HasArrow.arrow HasAnd.and HasOr.or HasUniv.univ HasEx.ex\n\n@[notation_class] class HasTurnstile (\u03b1 : Sort _) (\u03b2 : Sort _) where\n  turnstile : Set \u03b1 \u2192 \u03b1 \u2192 \u03b2\n\ninfix:45 \" \u22a2 \" => HasTurnstile.turnstile\n\n@[notation_class] class HasVdash (\u03b1 : Sort _) (\u03b2 : outParam (Sort _)) where\n  vdash : \u03b1 \u2192 \u03b2\n\nprefix:45 \"\u22a9 \" => HasVdash.vdash\n\nend logicNotation\n\nnamespace HasLogicSymbols\n\nsection\nvariable {\u03b1 : Sort _} [HasLogicSymbols \u03b1]\n\n@[match_pattern] def iff (a b : \u03b1) := (a \u27f6 b) \u22cf (b \u27f6 a)\n\ninfix:61 \" \u27f7 \" => 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 \u2192 Q)\n  and := And\n  or := Or\n\n@[simp] lemma Prop_top_eq : \u22a4 = True := rfl\n\n@[simp] lemma Prop_bot_eq : \u22a5 = False := rfl\n\n@[simp] lemma Prop_neg_eq (p : Prop) : ~ p = \u00acp := rfl\n\n@[simp] lemma Prop_arrow_eq (p q : Prop) : (p \u27f6 q) = (p \u2192 q) := rfl\n\n@[simp] lemma Prop_and_eq (p q : Prop) : (p \u22cf q) = (p \u2227 q) := rfl\n\n@[simp] lemma Prop_or_eq (p q : Prop) : (p \u22ce q) = (p \u2228 q) := rfl\n\n@[simp] lemma Prop_iff_eq (p q : Prop) : (p \u27f7 q) = (p \u2194 q) := by simp[HasLogicSymbols.iff, iff_iff_implies_and_implies]\n\nvariable (\u03b1 \u03b2 \u03b3 : Type _) [HasLogicSymbols \u03b1] [HasLogicSymbols \u03b2] [HasLogicSymbols \u03b3]\n\nstructure Hom where\n  toFun : \u03b1 \u2192 \u03b2\n  map_top' : toFun \u22a4 = \u22a4\n  map_bot' : toFun \u22a5 = \u22a5\n  map_neg' : \u2200 p, toFun (~ p) = ~toFun p\n  map_imp' : \u2200 p q, toFun (p \u27f6 q) = toFun p \u27f6 toFun q\n  map_and' : \u2200 p q, toFun (p \u22cf q) = toFun p \u22cf toFun q\n  map_or'  : \u2200 p q, toFun (p \u22ce q) = toFun p \u22ce toFun q\n\ninfix:25 \" \u2192L \" => Hom\n\nnamespace Hom\nvariable {\u03b1 \u03b2 \u03b3}\n\ninstance coeToFun : CoeFun (\u03b1 \u2192L \u03b2) (fun _ => \u03b1 \u2192 \u03b2) := \u27e8fun f => f.toFun\u27e9\n\nvariable (f : \u03b1 \u2192L \u03b2) (a b : \u03b1)\n\n@[simp] lemma map_top : f \u22a4 = \u22a4 := map_top' f\n\n@[simp] lemma map_bot : f \u22a5 = \u22a5 := 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 \u27f6 b) = f a \u27f6 f b := map_imp' f a b\n\n@[simp] lemma map_and : f (a \u22cf b) = f a \u22cf f b := map_and' f a b\n\n@[simp] lemma map_or : f (a \u22ce b) = f a \u22ce f b := map_or' f a b\n\n@[simp] lemma map_iff : f (a \u27f7 b) = f a \u27f7 f b := by simp[HasLogicSymbols.iff]\n\nprotected def id : \u03b1 \u2192L \u03b1 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 : \u03b1) : HasLogicSymbols.Hom.id a = a := rfl\n\ndef comp (g : \u03b2 \u2192L \u03b3) (f : \u03b1 \u2192L \u03b2) : \u03b1 \u2192L \u03b3 where\n  toFun := g.toFun \u2218 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 : \u03b2 \u2192L \u03b3) (f : \u03b1 \u2192L \u03b2) (a : \u03b1) :\n     g.comp f a = g (f a) := rfl\n\n@[ext] lemma ext (f g : \u03b1 \u2192L \u03b2) (h : \u2200 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 \u00a9 2020 Nicol\u00f2 Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Nicol\u00f2 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` \u00d7 `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 \ud835\udd5c 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 \u00d7 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 \ud835\udd5c 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space \ud835\udd5c E] (I : model_with_corners \ud835\udd5c 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 (\u03bb 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n  {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space \ud835\udd5c E] (I : model_with_corners \ud835\udd5c 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 (\u03bb a:G, a\u207b\u00b9))\n\nend\n\nsection lie_group\n\nvariables {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n{H : Type*} [topological_space H]\n{E : Type*} [normed_group E] [normed_space \ud835\udd5c E] {I : model_with_corners \ud835\udd5c E H}\n{F : Type*} [normed_group F] [normed_space \ud835\udd5c F] {J : model_with_corners \ud835\udd5c 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 \ud835\udd5c E']\n{H' : Type*} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'}\n{M : Type*} [topological_space M] [charted_space H' M]\n{E'' : Type*} [normed_group E''] [normed_space \ud835\udd5c E'']\n{H'' : Type*} [topological_space H''] {I'' : model_with_corners \ud835\udd5c 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 (\u03bb x : G, x\u207b\u00b9) :=\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 \u2192 G}\n  (hf : smooth I' I f) : smooth I' I (\u03bbx, (f x)\u207b\u00b9) :=\n(smooth_inv I).comp hf\n\n@[to_additive]\nlemma smooth_on.inv {f : M \u2192 G} {s : set M}\n  (hf : smooth_on I' I f s) : smooth_on I' I (\u03bbx, (f x)\u207b\u00b9) s :=\n(smooth_inv I).comp_smooth_on hf\n\n@[to_additive]\nlemma smooth.div {f g : M \u2192 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 \u2192 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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c] {H : Type*} [topological_space H]\n  {E : Type*} [normed_group E] [normed_space \ud835\udd5c E]  {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E']\n  {H' : Type*} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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\u00d7G') :=\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 {\ud835\udd5c : Type*} [nondiscrete_normed_field \ud835\udd5c]\n  {E : Type*} [normed_group E] [normed_space \ud835\udd5c E] :\n  lie_add_group (\ud835\udcd8(\ud835\udd5c, E)) E :=\n{ smooth_add := smooth_iff.2 \u27e8continuous_add, \u03bb x y, times_cont_diff_add.times_cont_diff_on\u27e9,\n  smooth_neg := smooth_iff.2 \u27e8continuous_neg, \u03bb x y, times_cont_diff_neg.times_cont_diff_on\u27e9,\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  {\u03b1 : Type u} {a : \u03b1} (b : \u03b1) {l : list \u03b1}        : a \u2208 l \u2192 a \u2208 b::l   := mem_cons_of_mem _\nlemma in_head  {\u03b1 : Type u} (a : \u03b1) (l : list \u03b1)                : a \u2208 a::l           := mem_cons_self _ _\nlemma in_left  {\u03b1 : Type u} {a : \u03b1}   {l : list \u03b1} (r : list \u03b1) : a \u2208 l \u2192 a \u2208 l ++ r := mem_append_left _\nlemma in_right {\u03b1 : Type u} {a : \u03b1}   (l : list \u03b1) {r : list \u03b1} : a \u2208 r \u2192 a \u2208 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 \u2208 [b, c] ++ [b, a, b] :=\nby mk_mem_list\n\nexample (a b c : nat) : a \u2208 [b, c] ++ [b, a, b] :=\nby mk_mem_list\n\nexample (a b c : nat) : a \u2208 [b, c] ++ [b, c, c] ++ [b, a, b] :=\nby mk_mem_list\n\nexample (a b c : nat) (l : list nat) : a \u2208 l \u2192 a \u2208 [b, c] ++ b::l :=\nbegin intros, mk_mem_list end\n\nexample (a b c : nat) (l\u2081 l\u2082 : list nat) : a \u2208 l\u2081 \u2192 a \u2208 b::b::c::l\u2082 ++ b::c::l\u2081 ++ [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 \u2192 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\u00f6del 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 (\u1fb0 : Nat), (C \u1fb0) -> (C (Nat.succ \u1fb0))) -> (forall (\u1fb0 : Nat), C \u1fb0)\nCase conversion may be inaccurate. Consider using '#align nat.elim Nat.rec\u2093'. -/\n/-- The non-dependent recursor on naturals. -/\ndef rec {C : Sort _} : C \u2192 (\u2115 \u2192 C \u2192 C) \u2192 \u2115 \u2192 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 (\u1fb0 : Nat), (C \u1fb0) -> (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) \u1fb0 (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\u2093'. -/\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 (\u1fb0 : Nat), (C \u1fb0) -> (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) \u1fb0 (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\u2093'. -/\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\u2093'. -/\n/-- Cases on whether the input is 0 or a successor. -/\ndef casesOn {C : Sort _} (a : C) (f : \u2115 \u2192 C) : \u2115 \u2192 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 (\u1fb0 : Nat), (C \u1fb0) -> (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) \u1fb0 (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\u2093'. -/\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 (\u1fb0 : Nat), (C \u1fb0) -> (C (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) \u1fb0 (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\u2093'. -/\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 {\u03b1} (f : \u2115 \u2192 \u2115 \u2192 \u03b1) (n : \u2115) : \u03b1 :=\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 `\u2115 \u2192 \u2115`. -/\ninductive Primrec : (\u2115 \u2192 \u2115) \u2192 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 \u2192 Primrec g \u2192 Primrec fun n => pair (f n) (g n)\n  | comp {f g} : Primrec f \u2192 Primrec g \u2192 Primrec fun n => f (g n)\n  |\n  prec {f g} :\n    Primrec f \u2192\n      Primrec g \u2192 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 : \u2115 \u2192 \u2115} (hf : Primrec f) (H : \u2200 n, f n = g n) : Primrec g :=\n  (funext H : f = g) \u25b8 hf\n#align nat.primrec.of_eq Nat.Primrec.of_eq\n-/\n\n#print Nat.Primrec.const /-\ntheorem const : \u2200 n : \u2115, 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 : \u2115) (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 : \u2115) (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 (\u00b7 + \u00b7)) :=\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 (\u00b7 * \u00b7)) :=\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 (\u00b7 ^ \u00b7)) :=\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 (\u03b1 : Type _) extends Encodable \u03b1 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 (\u03b1) [Denumerable \u03b1] : Primcodable \u03b1 :=\n  \u27e8succ.of_eq <| by simp\u27e9\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 (\u03b1) {\u03b2} [Primcodable \u03b1] (e : \u03b2 \u2243 \u03b1) : Primcodable \u03b2 :=\n  { Encodable.ofEquiv \u03b1 e with\n    prim :=\n      (Primcodable.prim \u03b1).of_eq fun n =>\n        show\n          encode (decode \u03b1 n) =\n            (Option.casesOn (Option.map e.symm (decode \u03b1 n)) 0 fun a => Nat.succ (encode (e a)) : \u2115)\n          by cases decode \u03b1 n <;> dsimp <;> simp }\n#align primcodable.of_equiv Primcodable.ofEquiv\n-/\n\n#print Primcodable.empty /-\ninstance empty : Primcodable Empty :=\n  \u27e8zero\u27e9\n#align primcodable.empty Primcodable.empty\n-/\n\n#print Primcodable.unit /-\ninstance unit : Primcodable PUnit :=\n  \u27e8(cases1 1 zero).of_eq fun n => by cases n <;> simp\u27e9\n#align primcodable.unit Primcodable.unit\n-/\n\n#print Primcodable.option /-\ninstance option {\u03b1 : Type _} [h : Primcodable \u03b1] : Primcodable (Option \u03b1) :=\n  \u27e8(cases1 1 ((cases1 0 (succ.comp succ)).comp (Primcodable.prim \u03b1))).of_eq fun n => by\n      cases n <;> simp <;> cases decode \u03b1 n <;> rfl\u27e9\n#align primcodable.option Primcodable.option\n-/\n\n#print Primcodable.bool /-\ninstance bool : Primcodable Bool :=\n  \u27e8(cases1 1 (cases1 2 zero)).of_eq fun n => by\n      cases n; \u00b7 rfl; cases n; \u00b7 rfl\n      rw [decode_ge_two]; \u00b7 rfl\n      exact by decide\u27e9\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 {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] (f : \u03b1 \u2192 \u03b2) : Prop :=\n  Nat.Primrec fun n => encode ((decode \u03b1 n).map f)\n#align primrec Primrec\n-/\n\nnamespace Primrec\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03c3]\n\nopen Nat.Primrec\n\n#print Primrec.encode /-\nprotected theorem encode : Primrec (@encode \u03b1 _) :=\n  (Primcodable.prim \u03b1).of_eq fun n => by cases decode \u03b1 n <;> rfl\n#align primrec.encode Primrec.encode\n-/\n\n#print Primrec.decode /-\nprotected theorem decode : Primrec (decode \u03b1) :=\n  succ.comp (Primcodable.prim \u03b1)\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_4 : Denumerable.{u1} \u03b1] [_inst_5 : Primcodable.{u2} \u03b2] {f : \u03b1 -> \u03b2}, Iff (Primrec.{u1, u2} \u03b1 \u03b2 (Primcodable.ofDenumerable.{u1} \u03b1 _inst_4) _inst_5 f) (Nat.Primrec (fun (n : Nat) => Encodable.encode.{u2} \u03b2 (Primcodable.toEncodable.{u2} \u03b2 _inst_5) (f (Denumerable.ofNat.{u1} \u03b1 _inst_4 n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_4 : Denumerable.{u2} \u03b1] [_inst_5 : Primcodable.{u1} \u03b2] {f : \u03b1 -> \u03b2}, Iff (Primrec.{u2, u1} \u03b1 \u03b2 (Primcodable.ofDenumerable.{u2} \u03b1 _inst_4) _inst_5 f) (Nat.Primrec (fun (n : Nat) => Encodable.encode.{u1} \u03b2 (Primcodable.toEncodable.{u1} \u03b2 _inst_5) (f (Denumerable.ofNat.{u2} \u03b1 _inst_4 n))))\nCase conversion may be inaccurate. Consider using '#align primrec.dom_denumerable Primrec.dom_denumerable\u2093'. -/\ntheorem dom_denumerable {\u03b1 \u03b2} [Denumerable \u03b1] [Primcodable \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    Primrec f \u2194 Nat.Primrec fun n => encode (f (ofNat \u03b1 n)) :=\n  \u27e8fun h => (pred.comp h).of_eq fun n => by simp <;> rfl, fun h =>\n    (succ.comp h).of_eq fun n => by simp <;> rfl\u27e9\n#align primrec.dom_denumerable Primrec.dom_denumerable\n\n#print Primrec.nat_iff /-\ntheorem nat_iff {f : \u2115 \u2192 \u2115} : Primrec f \u2194 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 \u03b1 n) :=\n  nat_iff.2 (Primcodable.prim \u03b1)\n#align primrec.encdec Primrec.encdec\n-/\n\n#print Primrec.option_some /-\ntheorem option_some : Primrec (@some \u03b1) :=\n  ((cases1 0 (succ.comp succ)).comp (Primcodable.prim \u03b1)).of_eq fun n => by\n    cases decode \u03b1 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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_3 : Primcodable.{u2} \u03c3] {f : \u03b1 -> \u03c3} {g : \u03b1 -> \u03c3}, (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_3 f) -> (forall (n : \u03b1), Eq.{succ u2} \u03c3 (f n) (g n)) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_3 g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03c3} {g : \u03b1 -> \u03c3}, (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_3 f) -> (forall (n : \u03b1), Eq.{succ u1} \u03c3 (f n) (g n)) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_3 g)\nCase conversion may be inaccurate. Consider using '#align primrec.of_eq Primrec.of_eq\u2093'. -/\ntheorem of_eq {f g : \u03b1 \u2192 \u03c3} (hf : Primrec f) (H : \u2200 n, f n = g n) : Primrec g :=\n  (funext H : f = g) \u25b8 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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_3 : Primcodable.{u2} \u03c3] (x : \u03c3), Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_3 (fun (a : \u03b1) => x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_3 : Primcodable.{u1} \u03c3] (x : \u03c3), Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_3 (fun (a : \u03b1) => x)\nCase conversion may be inaccurate. Consider using '#align primrec.const Primrec.const\u2093'. -/\ntheorem const (x : \u03c3) : Primrec fun a : \u03b1 => x :=\n  ((cases1 0 (const (encode x).succ)).comp (Primcodable.prim \u03b1)).of_eq fun n => by\n    cases decode \u03b1 n <;> rfl\n#align primrec.const Primrec.const\n\n#print Primrec.id /-\nprotected theorem id : Primrec (@id \u03b1) :=\n  (Primcodable.prim \u03b1).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : \u03b2 -> \u03c3} {g : \u03b1 -> \u03b2}, (Primrec.{u2, u3} \u03b2 \u03c3 _inst_2 _inst_3 f) -> (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 g) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_3 (fun (a : \u03b1) => f (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_3 : Primcodable.{u2} \u03c3] {f : \u03b2 -> \u03c3} {g : \u03b1 -> \u03b2}, (Primrec.{u3, u2} \u03b2 \u03c3 _inst_2 _inst_3 f) -> (Primrec.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 g) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_3 (fun (a : \u03b1) => f (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.comp Primrec.comp\u2093'. -/\ntheorem comp {f : \u03b2 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2} (hf : Primrec f) (hg : Primrec g) : Primrec fun a => f (g a) :=\n  ((cases1 0 (hf.comp <| pred.comp hg)).comp (Primcodable.prim \u03b1)).of_eq fun n =>\n    by\n    cases decode \u03b1 n; \u00b7 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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_3 : Primcodable.{u2} \u03c3] {f : \u03b1 -> \u03c3}, Iff (Primrec.{u1, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : \u03b1) => Encodable.encode.{u2} \u03c3 (Primcodable.toEncodable.{u2} \u03c3 _inst_3) (f a))) (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_3 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03c3}, Iff (Primrec.{u2, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : \u03b1) => Encodable.encode.{u1} \u03c3 (Primcodable.toEncodable.{u1} \u03c3 _inst_3) (f a))) (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec.encode_iff Primrec.encode_iff\u2093'. -/\ntheorem encode_iff {f : \u03b1 \u2192 \u03c3} : (Primrec fun a => encode (f a)) \u2194 Primrec f :=\n  \u27e8fun h => Nat.Primrec.of_eq h fun n => by cases decode \u03b1 n <;> rfl, Primrec.encode.comp\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_4 : Denumerable.{u1} \u03b1] [_inst_5 : Primcodable.{u2} \u03b2] {f : \u03b1 -> \u03b2}, Iff (Primrec.{u1, u2} \u03b1 \u03b2 (Primcodable.ofDenumerable.{u1} \u03b1 _inst_4) _inst_5 f) (Primrec.{0, u2} Nat \u03b2 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_5 (fun (n : Nat) => f (Denumerable.ofNat.{u1} \u03b1 _inst_4 n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_4 : Denumerable.{u2} \u03b1] [_inst_5 : Primcodable.{u1} \u03b2] {f : \u03b1 -> \u03b2}, Iff (Primrec.{u2, u1} \u03b1 \u03b2 (Primcodable.ofDenumerable.{u2} \u03b1 _inst_4) _inst_5 f) (Primrec.{0, u1} Nat \u03b2 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_5 (fun (n : Nat) => f (Denumerable.ofNat.{u2} \u03b1 _inst_4 n)))\nCase conversion may be inaccurate. Consider using '#align primrec.of_nat_iff Primrec.ofNat_iff\u2093'. -/\ntheorem ofNat_iff {\u03b1 \u03b2} [Denumerable \u03b1] [Primcodable \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    Primrec f \u2194 Primrec fun n => f (ofNat \u03b1 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 (\u03b1) [Denumerable \u03b1] : Primrec (ofNat \u03b1) :=\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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_3 : Primcodable.{u2} \u03c3] {f : \u03b1 -> \u03c3}, Iff (Primrec.{u1, u2} \u03b1 (Option.{u2} \u03c3) _inst_1 (Primcodable.option.{u2} \u03c3 _inst_3) (fun (a : \u03b1) => Option.some.{u2} \u03c3 (f a))) (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_3 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03c3}, Iff (Primrec.{u2, u1} \u03b1 (Option.{u1} \u03c3) _inst_1 (Primcodable.option.{u1} \u03c3 _inst_3) (fun (a : \u03b1) => Option.some.{u1} \u03c3 (f a))) (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec.option_some_iff Primrec.option_some_iff\u2093'. -/\ntheorem option_some_iff {f : \u03b1 \u2192 \u03c3} : (Primrec fun a => some (f a)) \u2194 Primrec f :=\n  \u27e8fun h => encode_iff.1 <| pred.comp <| encode_iff.2 h, option_some.comp\u27e9\n#align primrec.option_some_iff Primrec.option_some_iff\n\n#print Primrec.ofEquiv /-\ntheorem ofEquiv {\u03b2} {e : \u03b2 \u2243 \u03b1} :\n    haveI := Primcodable.ofEquiv \u03b1 e\n    Primrec e :=\n  letI : Primcodable \u03b2 := Primcodable.ofEquiv \u03b1 e\n  encode_iff.1 Primrec.encode\n#align primrec.of_equiv Primrec.ofEquiv\n-/\n\n#print Primrec.ofEquiv_symm /-\ntheorem ofEquiv_symm {\u03b2} {e : \u03b2 \u2243 \u03b1} :\n    haveI := Primcodable.ofEquiv \u03b1 e\n    Primrec e.symm :=\n  letI := Primcodable.ofEquiv \u03b1 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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_3 : Primcodable.{u2} \u03c3] {\u03b2 : Type.{u3}} (e : Equiv.{succ u3, succ u1} \u03b2 \u03b1) {f : \u03c3 -> \u03b2}, Iff (Primrec.{u2, u1} \u03c3 \u03b1 _inst_3 _inst_1 (fun (a : \u03c3) => coeFn.{max 1 (max (succ u3) (succ u1)) (succ u1) (succ u3), max (succ u3) (succ u1)} (Equiv.{succ u3, succ u1} \u03b2 \u03b1) (fun (_x : Equiv.{succ u3, succ u1} \u03b2 \u03b1) => \u03b2 -> \u03b1) (Equiv.hasCoeToFun.{succ u3, succ u1} \u03b2 \u03b1) e (f a))) (Primrec.{u2, u3} \u03c3 \u03b2 _inst_3 (Primcodable.ofEquiv.{u1, u3} \u03b1 \u03b2 _inst_1 e) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_3 : Primcodable.{u1} \u03c3] {\u03b2 : Type.{u3}} (e : Equiv.{succ u3, succ u2} \u03b2 \u03b1) {f : \u03c3 -> \u03b2}, Iff (Primrec.{u1, u2} \u03c3 \u03b1 _inst_3 _inst_1 (fun (a : \u03c3) => FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u2} (Equiv.{succ u3, succ u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u3, succ u2} \u03b2 \u03b1) e (f a))) (Primrec.{u1, u3} \u03c3 \u03b2 _inst_3 (Primcodable.ofEquiv.{u2, u3} \u03b1 \u03b2 _inst_1 e) f)\nCase conversion may be inaccurate. Consider using '#align primrec.of_equiv_iff Primrec.ofEquiv_iff\u2093'. -/\ntheorem ofEquiv_iff {\u03b2} (e : \u03b2 \u2243 \u03b1) {f : \u03c3 \u2192 \u03b2} :\n    haveI := Primcodable.ofEquiv \u03b1 e\n    (Primrec fun a => e (f a)) \u2194 Primrec f :=\n  letI := Primcodable.ofEquiv \u03b1 e\n  \u27e8fun h => (of_equiv_symm.comp h).of_eq fun a => by simp, of_equiv.comp\u27e9\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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_3 : Primcodable.{u2} \u03c3] {\u03b2 : Type.{u3}} (e : Equiv.{succ u3, succ u1} \u03b2 \u03b1) {f : \u03c3 -> \u03b1}, Iff (Primrec.{u2, u3} \u03c3 \u03b2 _inst_3 (Primcodable.ofEquiv.{u1, u3} \u03b1 \u03b2 _inst_1 e) (fun (a : \u03c3) => coeFn.{max 1 (max (succ u1) (succ u3)) (succ u3) (succ u1), max (succ u1) (succ u3)} (Equiv.{succ u1, succ u3} \u03b1 \u03b2) (fun (_x : Equiv.{succ u1, succ u3} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Equiv.hasCoeToFun.{succ u1, succ u3} \u03b1 \u03b2) (Equiv.symm.{succ u3, succ u1} \u03b2 \u03b1 e) (f a))) (Primrec.{u2, u1} \u03c3 \u03b1 _inst_3 _inst_1 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_3 : Primcodable.{u1} \u03c3] {\u03b2 : Type.{u3}} (e : Equiv.{succ u3, succ u2} \u03b2 \u03b1) {f : \u03c3 -> \u03b1}, Iff (Primrec.{u1, u3} \u03c3 \u03b2 _inst_3 (Primcodable.ofEquiv.{u2, u3} \u03b1 \u03b2 _inst_1 e) (fun (a : \u03c3) => FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (Equiv.{succ u2, succ u3} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u3} \u03b1 \u03b2) (Equiv.symm.{succ u3, succ u2} \u03b2 \u03b1 e) (f a))) (Primrec.{u1, u2} \u03c3 \u03b1 _inst_3 _inst_1 f)\nCase conversion may be inaccurate. Consider using '#align primrec.of_equiv_symm_iff Primrec.ofEquiv_symm_iff\u2093'. -/\ntheorem ofEquiv_symm_iff {\u03b2} (e : \u03b2 \u2243 \u03b1) {f : \u03c3 \u2192 \u03b1} :\n    haveI := Primcodable.ofEquiv \u03b1 e\n    (Primrec fun a => e.symm (f a)) \u2194 Primrec f :=\n  letI := Primcodable.ofEquiv \u03b1 e\n  \u27e8fun h => (of_equiv.comp h).of_eq fun a => by simp, of_equiv_symm.comp\u27e9\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 {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] : Primcodable (\u03b1 \u00d7 \u03b2) :=\n  \u27e8((cases zero ((cases zero succ).comp (pair right ((Primcodable.prim \u03b2).comp left)))).comp\n          (pair right ((Primcodable.prim \u03b1).comp left))).of_eq\n      fun n => by\n      simp [Nat.unpaired]\n      cases decode \u03b1 n.unpair.1; \u00b7 simp\n      cases decode \u03b2 n.unpair.2 <;> simp\u27e9\n#align primcodable.prod Primcodable.prod\n-/\n\nend Primcodable\n\nnamespace Primrec\n\nvariable {\u03b1 : Type _} {\u03c3 : Type _} [Primcodable \u03b1] [Primcodable \u03c3]\n\nopen Nat.Primrec\n\n/- warning: primrec.fst -> Primrec.fst is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_3 : Primcodable.{u1} \u03b1] [_inst_4 : Primcodable.{u2} \u03b2], Primrec.{max u1 u2, u1} (Prod.{u1, u2} \u03b1 \u03b2) \u03b1 (Primcodable.prod.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_4) _inst_3 (Prod.fst.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_3 : Primcodable.{u2} \u03b1] [_inst_4 : Primcodable.{u1} \u03b2], Primrec.{max u2 u1, u2} (Prod.{u2, u1} \u03b1 \u03b2) \u03b1 (Primcodable.prod.{u2, u1} \u03b1 \u03b2 _inst_3 _inst_4) _inst_3 (Prod.fst.{u2, u1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align primrec.fst Primrec.fst\u2093'. -/\ntheorem fst {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] : Primrec (@Prod.fst \u03b1 \u03b2) :=\n  ((cases zero\n            ((cases zero (Nat.Primrec.succ.comp left)).comp\n              (pair right ((Primcodable.prim \u03b2).comp left)))).comp\n        (pair right ((Primcodable.prim \u03b1).comp left))).of_eq\n    fun n => by\n    simp\n    cases decode \u03b1 n.unpair.1 <;> simp\n    cases decode \u03b2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_3 : Primcodable.{u1} \u03b1] [_inst_4 : Primcodable.{u2} \u03b2], Primrec.{max u1 u2, u2} (Prod.{u1, u2} \u03b1 \u03b2) \u03b2 (Primcodable.prod.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_4) _inst_4 (Prod.snd.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_3 : Primcodable.{u2} \u03b1] [_inst_4 : Primcodable.{u1} \u03b2], Primrec.{max u2 u1, u1} (Prod.{u2, u1} \u03b1 \u03b2) \u03b2 (Primcodable.prod.{u2, u1} \u03b1 \u03b2 _inst_3 _inst_4) _inst_4 (Prod.snd.{u2, u1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align primrec.snd Primrec.snd\u2093'. -/\ntheorem snd {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] : Primrec (@Prod.snd \u03b1 \u03b2) :=\n  ((cases zero\n            ((cases zero (Nat.Primrec.succ.comp right)).comp\n              (pair right ((Primcodable.prim \u03b2).comp left)))).comp\n        (pair right ((Primcodable.prim \u03b1).comp left))).of_eq\n    fun n => by\n    simp\n    cases decode \u03b1 n.unpair.1 <;> simp\n    cases decode \u03b2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : Primcodable.{u1} \u03b1] [_inst_4 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b3}, (Primrec.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_4 f) -> (Primrec.{u1, u3} \u03b1 \u03b3 _inst_3 _inst_5 g) -> (Primrec.{u1, max u2 u3} \u03b1 (Prod.{u2, u3} \u03b2 \u03b3) _inst_3 (Primcodable.prod.{u2, u3} \u03b2 \u03b3 _inst_4 _inst_5) (fun (a : \u03b1) => Prod.mk.{u2, u3} \u03b2 \u03b3 (f a) (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : Primcodable.{u3} \u03b1] [_inst_4 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u1} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b3}, (Primrec.{u3, u2} \u03b1 \u03b2 _inst_3 _inst_4 f) -> (Primrec.{u3, u1} \u03b1 \u03b3 _inst_3 _inst_5 g) -> (Primrec.{u3, max u1 u2} \u03b1 (Prod.{u2, u1} \u03b2 \u03b3) _inst_3 (Primcodable.prod.{u2, u1} \u03b2 \u03b3 _inst_4 _inst_5) (fun (a : \u03b1) => Prod.mk.{u2, u1} \u03b2 \u03b3 (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.pair Primrec.pair\u2093'. -/\ntheorem pair {\u03b1 \u03b2 \u03b3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3}\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 \u03b1)).of_eq\n    fun n => by cases decode \u03b1 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?\u2081 /-\ntheorem list_get?\u2081 : \u2200 l : List \u03b1, 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\u2081 l).of_eq fun n => by\n        cases n <;> simp\n#align primrec.list_nth\u2081 Primrec.list_get?\u2081\n-/\n\nend Primrec\n\n#print Primrec\u2082 /-\n/-- `primrec\u2082 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\u2082 {\u03b1 \u03b2 \u03c3} [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03c3] (f : \u03b1 \u2192 \u03b2 \u2192 \u03c3) :=\n  Primrec fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2\n#align primrec\u2082 Primrec\u2082\n-/\n\n#print PrimrecPred /-\n/-- `primrec_pred p` means `p : \u03b1 \u2192 Prop` is a (decidable)\n  primitive recursive predicate, which is to say that\n  `to_bool \u2218 p : \u03b1 \u2192 bool` is primitive recursive. -/\ndef PrimrecPred {\u03b1} [Primcodable \u03b1] (p : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b2 \u2192 Prop` is a (decidable)\n  primitive recursive relation, which is to say that\n  `to_bool \u2218 p : \u03b1 \u2192 \u03b2 \u2192 bool` is primitive recursive. -/\ndef PrimrecRel {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] (s : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    [\u2200 a b, Decidable (s a b)] :=\n  Primrec\u2082 fun a b => decide (s a b)\n#align primrec_rel PrimrecRel\n-/\n\nnamespace Primrec\u2082\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03c3]\n\n/- warning: primrec\u2082.of_eq -> Primrec\u2082.of_eq is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3} {g : \u03b1 -> \u03b2 -> \u03c3}, (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f) -> (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03c3 (f a b) (g a b)) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3} {g : \u03b1 -> \u03b2 -> \u03c3}, (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f) -> (forall (a : \u03b1) (b : \u03b2), Eq.{succ u1} \u03c3 (f a b) (g a b)) -> (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 g)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.of_eq Primrec\u2082.of_eq\u2093'. -/\ntheorem of_eq {f g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (hg : Primrec\u2082 f) (H : \u2200 a b, f a b = g a b) : Primrec\u2082 g :=\n  (by funext a b <;> apply H : f = g) \u25b8 hg\n#align primrec\u2082.of_eq Primrec\u2082.of_eq\n\n/- warning: primrec\u2082.const -> Primrec\u2082.const is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] (x : \u03c3), Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 (fun (a : \u03b1) (b : \u03b2) => x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] (x : \u03c3), Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 (fun (a : \u03b1) (b : \u03b2) => x)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.const Primrec\u2082.const\u2093'. -/\ntheorem const (x : \u03c3) : Primrec\u2082 fun (a : \u03b1) (b : \u03b2) => x :=\n  Primrec.const _\n#align primrec\u2082.const Primrec\u2082.const\n\n/- warning: primrec\u2082.pair -> Primrec\u2082.pair is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2], Primrec\u2082.{u1, u2, max u1 u2} \u03b1 \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) _inst_1 _inst_2 (Primcodable.prod.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (Prod.mk.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2], Primrec\u2082.{u2, u1, max u2 u1} \u03b1 \u03b2 (Prod.{u2, u1} \u03b1 \u03b2) _inst_1 _inst_2 (Primcodable.prod.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (Prod.mk.{u2, u1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.pair Primrec\u2082.pair\u2093'. -/\nprotected theorem pair : Primrec\u2082 (@Prod.mk \u03b1 \u03b2) :=\n  Primrec.pair Primrec.fst Primrec.snd\n#align primrec\u2082.pair Primrec\u2082.pair\n\n/- warning: primrec\u2082.left -> Primrec\u2082.left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2], Primrec\u2082.{u1, u2, u1} \u03b1 \u03b2 \u03b1 _inst_1 _inst_2 _inst_1 (fun (a : \u03b1) (b : \u03b2) => a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2], Primrec\u2082.{u2, u1, u2} \u03b1 \u03b2 \u03b1 _inst_1 _inst_2 _inst_1 (fun (a : \u03b1) (b : \u03b2) => a)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.left Primrec\u2082.left\u2093'. -/\ntheorem left : Primrec\u2082 fun (a : \u03b1) (b : \u03b2) => a :=\n  Primrec.fst\n#align primrec\u2082.left Primrec\u2082.left\n\n/- warning: primrec\u2082.right -> Primrec\u2082.right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2], Primrec\u2082.{u1, u2, u2} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 (fun (a : \u03b1) (b : \u03b2) => b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2], Primrec\u2082.{u2, u1, u1} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 (fun (a : \u03b1) (b : \u03b2) => b)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.right Primrec\u2082.right\u2093'. -/\ntheorem right : Primrec\u2082 fun (a : \u03b1) (b : \u03b2) => b :=\n  Primrec.snd\n#align primrec\u2082.right Primrec\u2082.right\n\n#print Primrec\u2082.natPair /-\ntheorem natPair : Primrec\u2082 Nat.pair := by simp [Primrec\u2082, Primrec] <;> constructor\n#align primrec\u2082.mkpair Primrec\u2082.natPair\n-/\n\n#print Primrec\u2082.unpaired /-\ntheorem unpaired {f : \u2115 \u2192 \u2115 \u2192 \u03b1} : Primrec (Nat.unpaired f) \u2194 Primrec\u2082 f :=\n  \u27e8fun h => by simpa using h.comp mkpair, fun h => h.comp Primrec.unpair\u27e9\n#align primrec\u2082.unpaired Primrec\u2082.unpaired\n-/\n\n#print Primrec\u2082.unpaired' /-\ntheorem unpaired' {f : \u2115 \u2192 \u2115 \u2192 \u2115} : Nat.Primrec (Nat.unpaired f) \u2194 Primrec\u2082 f :=\n  Primrec.nat_iff.symm.trans unpaired\n#align primrec\u2082.unpaired' Primrec\u2082.unpaired'\n-/\n\n/- warning: primrec\u2082.encode_iff -> Primrec\u2082.encode_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u1, u2, 0} \u03b1 \u03b2 Nat _inst_1 _inst_2 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : \u03b1) (b : \u03b2) => Encodable.encode.{u3} \u03c3 (Primcodable.toEncodable.{u3} \u03c3 _inst_3) (f a b))) (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u3, u2, 0} \u03b1 \u03b2 Nat _inst_1 _inst_2 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : \u03b1) (b : \u03b2) => Encodable.encode.{u1} \u03c3 (Primcodable.toEncodable.{u1} \u03c3 _inst_3) (f a b))) (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.encode_iff Primrec\u2082.encode_iff\u2093'. -/\ntheorem encode_iff {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} : (Primrec\u2082 fun a b => encode (f a b)) \u2194 Primrec\u2082 f :=\n  Primrec.encode_iff\n#align primrec\u2082.encode_iff Primrec\u2082.encode_iff\n\n/- warning: primrec\u2082.option_some_iff -> Primrec\u2082.option_some_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 (Option.{u3} \u03c3) _inst_1 _inst_2 (Primcodable.option.{u3} \u03c3 _inst_3) (fun (a : \u03b1) (b : \u03b2) => Option.some.{u3} \u03c3 (f a b))) (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 (Option.{u1} \u03c3) _inst_1 _inst_2 (Primcodable.option.{u1} \u03c3 _inst_3) (fun (a : \u03b1) (b : \u03b2) => Option.some.{u1} \u03c3 (f a b))) (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.option_some_iff Primrec\u2082.option_some_iff\u2093'. -/\ntheorem option_some_iff {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} : (Primrec\u2082 fun a b => some (f a b)) \u2194 Primrec\u2082 f :=\n  Primrec.option_some_iff\n#align primrec\u2082.option_some_iff Primrec\u2082.option_some_iff\n\n/- warning: primrec\u2082.of_nat_iff -> Primrec\u2082.ofNat_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_4 : Denumerable.{u1} \u03b1] [_inst_5 : Denumerable.{u2} \u03b2] [_inst_6 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 (Primcodable.ofDenumerable.{u1} \u03b1 _inst_4) (Primcodable.ofDenumerable.{u2} \u03b2 _inst_5) _inst_6 f) (Primrec\u2082.{0, 0, u3} Nat Nat \u03c3 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_6 (fun (m : Nat) (n : Nat) => f (Denumerable.ofNat.{u1} \u03b1 _inst_4 m) (Denumerable.ofNat.{u2} \u03b2 _inst_5 n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_4 : Denumerable.{u3} \u03b1] [_inst_5 : Denumerable.{u2} \u03b2] [_inst_6 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 (Primcodable.ofDenumerable.{u3} \u03b1 _inst_4) (Primcodable.ofDenumerable.{u2} \u03b2 _inst_5) _inst_6 f) (Primrec\u2082.{0, 0, u1} Nat Nat \u03c3 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_6 (fun (m : Nat) (n : Nat) => f (Denumerable.ofNat.{u3} \u03b1 _inst_4 m) (Denumerable.ofNat.{u2} \u03b2 _inst_5 n)))\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.of_nat_iff Primrec\u2082.ofNat_iff\u2093'. -/\ntheorem ofNat_iff {\u03b1 \u03b2 \u03c3} [Denumerable \u03b1] [Denumerable \u03b2] [Primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    Primrec\u2082 f \u2194 Primrec\u2082 fun m n : \u2115 => f (ofNat \u03b1 m) (ofNat \u03b2 n) :=\n  (Primrec.ofNat_iff.trans <| by simp).trans unpaired\n#align primrec\u2082.of_nat_iff Primrec\u2082.ofNat_iff\n\n/- warning: primrec\u2082.uncurry -> Primrec\u2082.uncurry is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03c3 (Primcodable.prod.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} \u03b1 \u03b2 \u03c3 f)) (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec.{max u3 u2, u1} (Prod.{u2, u3} \u03b1 \u03b2) \u03c3 (Primcodable.prod.{u2, u3} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 (Function.uncurry.{u2, u3, u1} \u03b1 \u03b2 \u03c3 f)) (Primrec\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.uncurry Primrec\u2082.uncurry\u2093'. -/\ntheorem uncurry {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} : Primrec (Function.uncurry f) \u2194 Primrec\u2082 f := by\n  rw [show Function.uncurry f = fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2 from funext fun \u27e8a, b\u27e9 => rfl] <;> rfl\n#align primrec\u2082.uncurry Primrec\u2082.uncurry\n\n/- warning: primrec\u2082.curry -> Primrec\u2082.curry is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03c3}, Iff (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 (Function.curry.{u1, u2, u3} \u03b1 \u03b2 \u03c3 f)) (Primrec.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03c3 (Primcodable.prod.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] {f : (Prod.{u3, u2} \u03b1 \u03b2) -> \u03c3}, Iff (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 (Function.curry.{u3, u2, u1} \u03b1 \u03b2 \u03c3 f)) (Primrec.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03c3 (Primcodable.prod.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.curry Primrec\u2082.curry\u2093'. -/\ntheorem curry {f : \u03b1 \u00d7 \u03b2 \u2192 \u03c3} : Primrec\u2082 (Function.curry f) \u2194 Primrec f := by\n  rw [\u2190 uncurry, Function.uncurry_curry]\n#align primrec\u2082.curry Primrec\u2082.curry\n\nend Primrec\u2082\n\nsection Comp\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _} {\u03b4 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] [Primcodable \u03b4] [Primcodable \u03c3]\n\n/- warning: primrec.comp\u2082 -> Primrec.comp\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03c3 : Type.{u4}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03b3] [_inst_5 : Primcodable.{u4} \u03c3] {f : \u03b3 -> \u03c3} {g : \u03b1 -> \u03b2 -> \u03b3}, (Primrec.{u3, u4} \u03b3 \u03c3 _inst_3 _inst_5 f) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g) -> (Primrec\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 (fun (a : \u03b1) (b : \u03b2) => f (g a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u4}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] [_inst_3 : Primcodable.{u4} \u03b3] [_inst_5 : Primcodable.{u3} \u03c3] {f : \u03b3 -> \u03c3} {g : \u03b1 -> \u03b2 -> \u03b3}, (Primrec.{u4, u3} \u03b3 \u03c3 _inst_3 _inst_5 f) -> (Primrec\u2082.{u2, u1, u4} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g) -> (Primrec\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 (fun (a : \u03b1) (b : \u03b2) => f (g a b)))\nCase conversion may be inaccurate. Consider using '#align primrec.comp\u2082 Primrec.comp\u2082\u2093'. -/\ntheorem Primrec.comp\u2082 {f : \u03b3 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hf : Primrec f) (hg : Primrec\u2082 g) :\n    Primrec\u2082 fun a b => f (g a b) :=\n  hf.comp hg\n#align primrec.comp\u2082 Primrec.comp\u2082\n\n/- warning: primrec\u2082.comp -> Primrec\u2082.comp is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03c3 : Type.{u4}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03b3] [_inst_5 : Primcodable.{u4} \u03c3] {f : \u03b2 -> \u03b3 -> \u03c3} {g : \u03b1 -> \u03b2} {h : \u03b1 -> \u03b3}, (Primrec\u2082.{u2, u3, u4} \u03b2 \u03b3 \u03c3 _inst_2 _inst_3 _inst_5 f) -> (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 g) -> (Primrec.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 h) -> (Primrec.{u1, u4} \u03b1 \u03c3 _inst_1 _inst_5 (fun (a : \u03b1) => f (g a) (h a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u4}} {\u03b3 : Type.{u3}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u4} \u03b2] [_inst_3 : Primcodable.{u3} \u03b3] [_inst_5 : Primcodable.{u2} \u03c3] {f : \u03b2 -> \u03b3 -> \u03c3} {g : \u03b1 -> \u03b2} {h : \u03b1 -> \u03b3}, (Primrec\u2082.{u4, u3, u2} \u03b2 \u03b3 \u03c3 _inst_2 _inst_3 _inst_5 f) -> (Primrec.{u1, u4} \u03b1 \u03b2 _inst_1 _inst_2 g) -> (Primrec.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 h) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 (fun (a : \u03b1) => f (g a) (h a)))\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.comp Primrec\u2082.comp\u2093'. -/\ntheorem Primrec\u2082.comp {f : \u03b2 \u2192 \u03b3 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2} {h : \u03b1 \u2192 \u03b3} (hf : Primrec\u2082 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\u2082.comp Primrec\u2082.comp\n\n/- warning: primrec\u2082.comp\u2082 -> Primrec\u2082.comp\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {\u03c3 : Type.{u5}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03b3] [_inst_4 : Primcodable.{u4} \u03b4] [_inst_5 : Primcodable.{u5} \u03c3] {f : \u03b3 -> \u03b4 -> \u03c3} {g : \u03b1 -> \u03b2 -> \u03b3} {h : \u03b1 -> \u03b2 -> \u03b4}, (Primrec\u2082.{u3, u4, u5} \u03b3 \u03b4 \u03c3 _inst_3 _inst_4 _inst_5 f) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g) -> (Primrec\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 h) -> (Primrec\u2082.{u1, u2, u5} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 (fun (a : \u03b1) (b : \u03b2) => f (g a b) (h a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u4}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] [_inst_3 : Primcodable.{u5} \u03b3] [_inst_4 : Primcodable.{u4} \u03b4] [_inst_5 : Primcodable.{u3} \u03c3] {f : \u03b3 -> \u03b4 -> \u03c3} {g : \u03b1 -> \u03b2 -> \u03b3} {h : \u03b1 -> \u03b2 -> \u03b4}, (Primrec\u2082.{u5, u4, u3} \u03b3 \u03b4 \u03c3 _inst_3 _inst_4 _inst_5 f) -> (Primrec\u2082.{u2, u1, u5} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g) -> (Primrec\u2082.{u2, u1, u4} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 h) -> (Primrec\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 (fun (a : \u03b1) (b : \u03b2) => f (g a b) (h a b)))\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.comp\u2082 Primrec\u2082.comp\u2082\u2093'. -/\ntheorem Primrec\u2082.comp\u2082 {f : \u03b3 \u2192 \u03b4 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b4} (hf : Primrec\u2082 f)\n    (hg : Primrec\u2082 g) (hh : Primrec\u2082 h) : Primrec\u2082 fun a b => f (g a b) (h a b) :=\n  hf.comp hg hh\n#align primrec\u2082.comp\u2082 Primrec\u2082.comp\u2082\n\n#print PrimrecPred.comp /-\ntheorem PrimrecPred.comp {p : \u03b2 \u2192 Prop} [DecidablePred p] {f : \u03b1 \u2192 \u03b2} :\n    PrimrecPred p \u2192 Primrec f \u2192 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03b3] {R : \u03b2 -> \u03b3 -> Prop} [_inst_6 : forall (a : \u03b2) (b : \u03b3), Decidable (R a b)] {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b3}, (PrimrecRel.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3 R (fun (a : \u03b2) (b : \u03b3) => _inst_6 a b)) -> (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Primrec.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 g) -> (PrimrecPred.{u1} \u03b1 _inst_1 (fun (a : \u03b1) => R (f a) (g a)) (fun (a : \u03b1) => _inst_6 (f a) (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_3 : Primcodable.{u2} \u03b3] {R : \u03b2 -> \u03b3 -> Prop} [_inst_6 : forall (a : \u03b2) (b : \u03b3), Decidable (R a b)] {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b3}, (PrimrecRel.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3 R (fun (a : \u03b2) (b : \u03b3) => _inst_6 a b)) -> (Primrec.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Primrec.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3 g) -> (PrimrecPred.{u1} \u03b1 _inst_1 (fun (a : \u03b1) => R (f a) (g a)) (fun (a : \u03b1) => _inst_6 (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec_rel.comp PrimrecRel.comp\u2093'. -/\ntheorem PrimrecRel.comp {R : \u03b2 \u2192 \u03b3 \u2192 Prop} [\u2200 a b, Decidable (R a b)] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} :\n    PrimrecRel R \u2192 Primrec f \u2192 Primrec g \u2192 PrimrecPred fun a => R (f a) (g a) :=\n  Primrec\u2082.comp\n#align primrec_rel.comp PrimrecRel.comp\n\n/- warning: primrec_rel.comp\u2082 -> PrimrecRel.comp\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03b3] [_inst_4 : Primcodable.{u4} \u03b4] {R : \u03b3 -> \u03b4 -> Prop} [_inst_6 : forall (a : \u03b3) (b : \u03b4), Decidable (R a b)] {f : \u03b1 -> \u03b2 -> \u03b3} {g : \u03b1 -> \u03b2 -> \u03b4}, (PrimrecRel.{u3, u4} \u03b3 \u03b4 _inst_3 _inst_4 R (fun (a : \u03b3) (b : \u03b4) => _inst_6 a b)) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f) -> (Primrec\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 g) -> (PrimrecRel.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) (b : \u03b2) => R (f a b) (g a b)) (fun (a : \u03b1) (b : \u03b2) => _inst_6 (f a b) (g a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u3}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] [_inst_3 : Primcodable.{u4} \u03b3] [_inst_4 : Primcodable.{u3} \u03b4] {R : \u03b3 -> \u03b4 -> Prop} [_inst_6 : forall (a : \u03b3) (b : \u03b4), Decidable (R a b)] {f : \u03b1 -> \u03b2 -> \u03b3} {g : \u03b1 -> \u03b2 -> \u03b4}, (PrimrecRel.{u4, u3} \u03b3 \u03b4 _inst_3 _inst_4 R (fun (a : \u03b3) (b : \u03b4) => _inst_6 a b)) -> (Primrec\u2082.{u2, u1, u4} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f) -> (Primrec\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 g) -> (PrimrecRel.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) (b : \u03b2) => R (f a b) (g a b)) (fun (a : \u03b1) (b : \u03b2) => _inst_6 (f a b) (g a b)))\nCase conversion may be inaccurate. Consider using '#align primrec_rel.comp\u2082 PrimrecRel.comp\u2082\u2093'. -/\ntheorem PrimrecRel.comp\u2082 {R : \u03b3 \u2192 \u03b4 \u2192 Prop} [\u2200 a b, Decidable (R a b)] {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n    {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4} :\n    PrimrecRel R \u2192 Primrec\u2082 f \u2192 Primrec\u2082 g \u2192 PrimrecRel fun a b => R (f a b) (g a b) :=\n  PrimrecRel.comp\n#align primrec_rel.comp\u2082 PrimrecRel.comp\u2082\n\nend Comp\n\n#print PrimrecPred.of_eq /-\ntheorem PrimrecPred.of_eq {\u03b1} [Primcodable \u03b1] {p q : \u03b1 \u2192 Prop} [DecidablePred p] [DecidablePred q]\n    (hp : PrimrecPred p) (H : \u2200 a, p a \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] {r : \u03b1 -> \u03b2 -> Prop} {s : \u03b1 -> \u03b2 -> Prop} [_inst_3 : forall (a : \u03b1) (b : \u03b2), Decidable (r a b)] [_inst_4 : forall (a : \u03b1) (b : \u03b2), Decidable (s a b)], (PrimrecRel.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 r (fun (a : \u03b1) (b : \u03b2) => _inst_3 a b)) -> (forall (a : \u03b1) (b : \u03b2), Iff (r a b) (s a b)) -> (PrimrecRel.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 s (fun (a : \u03b1) (b : \u03b2) => _inst_4 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] {r : \u03b1 -> \u03b2 -> Prop} {s : \u03b1 -> \u03b2 -> Prop} [_inst_3 : forall (a : \u03b1) (b : \u03b2), Decidable (r a b)] [_inst_4 : forall (a : \u03b1) (b : \u03b2), Decidable (s a b)], (PrimrecRel.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 r (fun (a : \u03b1) (b : \u03b2) => _inst_3 a b)) -> (forall (a : \u03b1) (b : \u03b2), Iff (r a b) (s a b)) -> (PrimrecRel.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 s (fun (a : \u03b1) (b : \u03b2) => _inst_4 a b))\nCase conversion may be inaccurate. Consider using '#align primrec_rel.of_eq PrimrecRel.of_eq\u2093'. -/\ntheorem PrimrecRel.of_eq {\u03b1 \u03b2} [Primcodable \u03b1] [Primcodable \u03b2] {r s : \u03b1 \u2192 \u03b2 \u2192 Prop}\n    [\u2200 a b, Decidable (r a b)] [\u2200 a b, Decidable (s a b)] (hr : PrimrecRel r)\n    (H : \u2200 a b, r a b \u2194 s a b) : PrimrecRel s :=\n  Primrec\u2082.of_eq hr fun a b => Bool.decide_congr (H a b)\n#align primrec_rel.of_eq PrimrecRel.of_eq\n\nnamespace Primrec\u2082\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03c3]\n\nopen Nat.Primrec\n\n/- warning: primrec\u2082.swap -> Primrec\u2082.swap is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f) -> (Primrec\u2082.{u2, u1, u3} \u03b2 \u03b1 \u03c3 _inst_2 _inst_1 _inst_3 (Function.swap.{succ u1, succ u2, succ u3} \u03b1 \u03b2 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b2) => \u03c3) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f) -> (Primrec\u2082.{u2, u3, u1} \u03b2 \u03b1 \u03c3 _inst_2 _inst_1 _inst_3 (Function.swap.{succ u3, succ u2, succ u1} \u03b1 \u03b2 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b2) => \u03c3) f))\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.swap Primrec\u2082.swap\u2093'. -/\ntheorem swap {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (h : Primrec\u2082 f) : Primrec\u2082 (swap f) :=\n  h.comp\u2082 Primrec\u2082.right Primrec\u2082.left\n#align primrec\u2082.swap Primrec\u2082.swap\n\n/- warning: primrec\u2082.nat_iff -> Primrec\u2082.nat_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f) (Nat.Primrec (Nat.unpaired.{1} Nat (fun (m : Nat) (n : Nat) => Encodable.encode.{u3} (Option.{u3} \u03c3) (Option.encodable.{u3} \u03c3 (Primcodable.toEncodable.{u3} \u03c3 _inst_3)) (Option.bind.{u1, u3} \u03b1 \u03c3 (Encodable.decode.{u1} \u03b1 (Primcodable.toEncodable.{u1} \u03b1 _inst_1) m) (fun (a : \u03b1) => Option.map.{u2, u3} \u03b2 \u03c3 (f a) (Encodable.decode.{u2} \u03b2 (Primcodable.toEncodable.{u2} \u03b2 _inst_2) n))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f) (Nat.Primrec (Nat.unpaired.{1} Nat (fun (m : Nat) (n : Nat) => Encodable.encode.{u1} (Option.{u1} \u03c3) (Option.encodable.{u1} \u03c3 (Primcodable.toEncodable.{u1} \u03c3 _inst_3)) (Option.bind.{u3, u1} \u03b1 \u03c3 (Encodable.decode.{u3} \u03b1 (Primcodable.toEncodable.{u3} \u03b1 _inst_1) m) (fun (a : \u03b1) => Option.map.{u2, u1} \u03b2 \u03c3 (f a) (Encodable.decode.{u2} \u03b2 (Primcodable.toEncodable.{u2} \u03b2 _inst_2) n))))))\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.nat_iff Primrec\u2082.nat_iff\u2093'. -/\ntheorem nat_iff {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    Primrec\u2082 f \u2194\n      Nat.Primrec\n        (Nat.unpaired fun m n : \u2115 => encode <| (decode \u03b1 m).bind fun a => (decode \u03b2 n).map (f a)) :=\n  by\n  have :\n    \u2200 (a : Option \u03b1) (b : Option \u03b2),\n      Option.map (fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2)\n          (Option.bind a fun a : \u03b1 => Option.map (Prod.mk a) b) =\n        Option.bind a fun a => Option.map (f a) b :=\n    by intros <;> cases a <;> [rfl, \u00b7 cases b <;> rfl]\n  simp [Primrec\u2082, Primrec, this]\n#align primrec\u2082.nat_iff Primrec\u2082.nat_iff\n\n/- warning: primrec\u2082.nat_iff' -> Primrec\u2082.nat_iff' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f) (Primrec\u2082.{0, 0, u3} Nat Nat (Option.{u3} \u03c3) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u3} \u03c3 _inst_3) (fun (m : Nat) (n : Nat) => Option.bind.{u1, u3} \u03b1 \u03c3 (Encodable.decode.{u1} \u03b1 (Primcodable.toEncodable.{u1} \u03b1 _inst_1) m) (fun (a : \u03b1) => Option.map.{u2, u3} \u03b2 \u03c3 (f a) (Encodable.decode.{u2} \u03b2 (Primcodable.toEncodable.{u2} \u03b2 _inst_2) n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_3 f) (Primrec\u2082.{0, 0, u1} Nat Nat (Option.{u1} \u03c3) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u1} \u03c3 _inst_3) (fun (m : Nat) (n : Nat) => Option.bind.{u3, u1} \u03b1 \u03c3 (Encodable.decode.{u3} \u03b1 (Primcodable.toEncodable.{u3} \u03b1 _inst_1) m) (fun (a : \u03b1) => Option.map.{u2, u1} \u03b2 \u03c3 (f a) (Encodable.decode.{u2} \u03b2 (Primcodable.toEncodable.{u2} \u03b2 _inst_2) n))))\nCase conversion may be inaccurate. Consider using '#align primrec\u2082.nat_iff' Primrec\u2082.nat_iff'\u2093'. -/\ntheorem nat_iff' {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    Primrec\u2082 f \u2194\n      Primrec\u2082 fun m n : \u2115 => Option.bind (decode \u03b1 m) fun a => Option.map (f a) (decode \u03b2 n) :=\n  nat_iff.trans <| unpaired'.trans encode_iff\n#align primrec\u2082.nat_iff' Primrec\u2082.nat_iff'\n\nend Primrec\u2082\n\nnamespace Primrec\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _} {\u03b4 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] [Primcodable \u03b4] [Primcodable \u03c3]\n\n/- warning: primrec.to\u2082 -> Primrec.to\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u3} \u03c3] {f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03c3}, (Primrec.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03c3 (Primcodable.prod.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_5 f) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 (fun (a : \u03b1) (b : \u03b2) => f (Prod.mk.{u1, u2} \u03b1 \u03b2 a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u1} \u03c3] {f : (Prod.{u3, u2} \u03b1 \u03b2) -> \u03c3}, (Primrec.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03c3 (Primcodable.prod.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_5 f) -> (Primrec\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 (fun (a : \u03b1) (b : \u03b2) => f (Prod.mk.{u3, u2} \u03b1 \u03b2 a b)))\nCase conversion may be inaccurate. Consider using '#align primrec.to\u2082 Primrec.to\u2082\u2093'. -/\ntheorem to\u2082 {f : \u03b1 \u00d7 \u03b2 \u2192 \u03c3} (hf : Primrec f) : Primrec\u2082 fun a b => f (a, b) :=\n  hf.of_eq fun \u27e8a, b\u27e9 => rfl\n#align primrec.to\u2082 Primrec.to\u2082\n\n#print Primrec.nat_elim /-\ntheorem nat_elim {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u2115 \u00d7 \u03b2 \u2192 \u03b2} (hf : Primrec f) (hg : Primrec\u2082 g) :\n    Primrec\u2082 fun a (n : \u2115) => n.elim (f a) fun n IH => g a (n, IH) :=\n  Primrec\u2082.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 \u03b1).comp Nat.Primrec.left).of_eq\n      fun n => by\n      simp\n      cases' decode \u03b1 n.unpair.1 with a; \u00b7 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 : \u03b1 \u2192 \u2115} {g : \u03b1 \u2192 \u03b2} {h : \u03b1 \u2192 \u2115 \u00d7 \u03b2 \u2192 \u03b2} (hf : Primrec f) (hg : Primrec g)\n    (hh : Primrec\u2082 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\u2081 /-\ntheorem nat_elim\u2081 {f : \u2115 \u2192 \u03b1 \u2192 \u03b1} (a : \u03b1) (hf : Primrec\u2082 f) : Primrec (Nat.rec a f) :=\n  nat_elim' Primrec.id (const a) <| comp\u2082 hf Primrec\u2082.right\n#align primrec.nat_elim\u2081 Primrec.nat_elim\u2081\n-/\n\n/- warning: primrec.nat_cases' -> Primrec.nat_cases' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] {f : \u03b1 -> \u03b2} {g : \u03b1 -> Nat -> \u03b2}, (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Primrec\u2082.{u1, 0, u2} \u03b1 Nat \u03b2 _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 g) -> (Primrec\u2082.{u1, 0, u2} \u03b1 Nat \u03b2 _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 (fun (a : \u03b1) => Nat.casesOn.{succ u2} \u03b2 (f a) (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] {f : \u03b1 -> \u03b2} {g : \u03b1 -> Nat -> \u03b2}, (Primrec.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Primrec\u2082.{u2, 0, u1} \u03b1 Nat \u03b2 _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 g) -> (Primrec\u2082.{u2, 0, u1} \u03b1 Nat \u03b2 _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 (fun (a : \u03b1) (n : Nat) => Nat.casesOn.{succ u1} (fun (x._@.Mathlib.Computability.Primrec._hyg.4800 : Nat) => \u03b2) n (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.nat_cases' Primrec.nat_cases'\u2093'. -/\ntheorem nat_cases' {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u2115 \u2192 \u03b2} (hf : Primrec f) (hg : Primrec\u2082 g) :\n    Primrec\u2082 fun a => Nat.casesOn (f a) (g a) :=\n  nat_elim hf <| hg.comp\u2082 Primrec\u2082.left <| comp\u2082 fst Primrec\u2082.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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] {f : \u03b1 -> Nat} {g : \u03b1 -> \u03b2} {h : \u03b1 -> Nat -> \u03b2}, (Primrec.{u1, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) f) -> (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 g) -> (Primrec\u2082.{u1, 0, u2} \u03b1 Nat \u03b2 _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 h) -> (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) => Nat.casesOn.{succ u2} \u03b2 (g a) (h a) (f a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] {f : \u03b1 -> Nat} {g : \u03b1 -> \u03b2} {h : \u03b1 -> Nat -> \u03b2}, (Primrec.{u2, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) f) -> (Primrec.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 g) -> (Primrec\u2082.{u2, 0, u1} \u03b1 Nat \u03b2 _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) _inst_2 h) -> (Primrec.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) => Nat.casesOn.{succ u1} (fun (x._@.Mathlib.Computability.Primrec._hyg.4875 : Nat) => \u03b2) (f a) (g a) (h a)))\nCase conversion may be inaccurate. Consider using '#align primrec.nat_cases Primrec.nat_cases\u2093'. -/\ntheorem nat_cases {f : \u03b1 \u2192 \u2115} {g : \u03b1 \u2192 \u03b2} {h : \u03b1 \u2192 \u2115 \u2192 \u03b2} (hf : Primrec f) (hg : Primrec g)\n    (hh : Primrec\u2082 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\u2081 /-\ntheorem nat_cases\u2081 {f : \u2115 \u2192 \u03b1} (a : \u03b1) (hf : Primrec f) : Primrec (Nat.casesOn a f) :=\n  nat_cases Primrec.id (const a) (comp\u2082 hf Primrec\u2082.right)\n#align primrec.nat_cases\u2081 Primrec.nat_cases\u2081\n-/\n\n/- warning: primrec.nat_iterate -> Primrec.nat_iterate is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] {f : \u03b1 -> Nat} {g : \u03b1 -> \u03b2} {h : \u03b1 -> \u03b2 -> \u03b2}, (Primrec.{u1, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) f) -> (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 g) -> (Primrec\u2082.{u1, u2, u2} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 h) -> (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) => Nat.iterate.{succ u2} \u03b2 (h a) (f a) (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] {f : \u03b1 -> Nat} {g : \u03b1 -> \u03b2} {h : \u03b1 -> \u03b2 -> \u03b2}, (Primrec.{u2, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) f) -> (Primrec.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 g) -> (Primrec\u2082.{u2, u1, u1} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 h) -> (Primrec.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) => Nat.iterate.{succ u1} \u03b2 (h a) (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.nat_iterate Primrec.nat_iterate\u2093'. -/\ntheorem nat_iterate {f : \u03b1 \u2192 \u2115} {g : \u03b1 \u2192 \u03b2} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b2} (hf : Primrec f) (hg : Primrec g)\n    (hh : Primrec\u2082 h) : Primrec fun a => (h a^[f a]) (g a) :=\n  (nat_elim' hf hg (hh.comp\u2082 Primrec\u2082.left <| snd.comp\u2082 Primrec\u2082.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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u3} \u03c3] {o : \u03b1 -> (Option.{u2} \u03b2)} {f : \u03b1 -> \u03c3} {g : \u03b1 -> \u03b2 -> \u03c3}, (Primrec.{u1, u2} \u03b1 (Option.{u2} \u03b2) _inst_1 (Primcodable.option.{u2} \u03b2 _inst_2) o) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_5 f) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 g) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_5 (fun (a : \u03b1) => Option.casesOn.{succ u3, u2} \u03b2 (fun (_x : Option.{u2} \u03b2) => \u03c3) (o a) (f a) (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_5 : Primcodable.{u1} \u03c3] {o : \u03b1 -> (Option.{u3} \u03b2)} {f : \u03b1 -> \u03c3} {g : \u03b1 -> \u03b2 -> \u03c3}, (Primrec.{u2, u3} \u03b1 (Option.{u3} \u03b2) _inst_1 (Primcodable.option.{u3} \u03b2 _inst_2) o) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 f) -> (Primrec\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 g) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 (fun (a : \u03b1) => Option.casesOn.{succ u1, u3} \u03b2 (fun (_x : Option.{u3} \u03b2) => \u03c3) (o a) (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.option_cases Primrec.option_cases\u2093'. -/\ntheorem option_cases {o : \u03b1 \u2192 Option \u03b2} {f : \u03b1 \u2192 \u03c3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (ho : Primrec o)\n    (hf : Primrec f) (hg : Primrec\u2082 g) :\n    @Primrec _ \u03c3 _ _ 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\u2082 <|\n            Primrec\u2082.encode_iff.2 <|\n              (Primrec\u2082.nat_iff'.1 hg).comp\u2082 ((@Primrec.encode \u03b1 _).comp fst).to\u2082\n                Primrec\u2082.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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u3} \u03c3] {f : \u03b1 -> (Option.{u2} \u03b2)} {g : \u03b1 -> \u03b2 -> (Option.{u3} \u03c3)}, (Primrec.{u1, u2} \u03b1 (Option.{u2} \u03b2) _inst_1 (Primcodable.option.{u2} \u03b2 _inst_2) f) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 (Option.{u3} \u03c3) _inst_1 _inst_2 (Primcodable.option.{u3} \u03c3 _inst_5) g) -> (Primrec.{u1, u3} \u03b1 (Option.{u3} \u03c3) _inst_1 (Primcodable.option.{u3} \u03c3 _inst_5) (fun (a : \u03b1) => Option.bind.{u2, u3} \u03b2 \u03c3 (f a) (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_5 : Primcodable.{u2} \u03c3] {f : \u03b1 -> (Option.{u3} \u03b2)} {g : \u03b1 -> \u03b2 -> (Option.{u2} \u03c3)}, (Primrec.{u1, u3} \u03b1 (Option.{u3} \u03b2) _inst_1 (Primcodable.option.{u3} \u03b2 _inst_2) f) -> (Primrec\u2082.{u1, u3, u2} \u03b1 \u03b2 (Option.{u2} \u03c3) _inst_1 _inst_2 (Primcodable.option.{u2} \u03c3 _inst_5) g) -> (Primrec.{u1, u2} \u03b1 (Option.{u2} \u03c3) _inst_1 (Primcodable.option.{u2} \u03c3 _inst_5) (fun (a : \u03b1) => Option.bind.{u3, u2} \u03b2 \u03c3 (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.option_bind Primrec.option_bind\u2093'. -/\ntheorem option_bind {f : \u03b1 \u2192 Option \u03b2} {g : \u03b1 \u2192 \u03b2 \u2192 Option \u03c3} (hf : Primrec f) (hg : Primrec\u2082 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\u2081 /-\ntheorem option_bind\u2081 {f : \u03b1 \u2192 Option \u03c3} (hf : Primrec f) : Primrec fun o => Option.bind o f :=\n  option_bind Primrec.id (hf.comp snd).to\u2082\n#align primrec.option_bind\u2081 Primrec.option_bind\u2081\n-/\n\n/- warning: primrec.option_map -> Primrec.option_map is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u3} \u03c3] {f : \u03b1 -> (Option.{u2} \u03b2)} {g : \u03b1 -> \u03b2 -> \u03c3}, (Primrec.{u1, u2} \u03b1 (Option.{u2} \u03b2) _inst_1 (Primcodable.option.{u2} \u03b2 _inst_2) f) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 g) -> (Primrec.{u1, u3} \u03b1 (Option.{u3} \u03c3) _inst_1 (Primcodable.option.{u3} \u03c3 _inst_5) (fun (a : \u03b1) => Option.map.{u2, u3} \u03b2 \u03c3 (g a) (f a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_5 : Primcodable.{u1} \u03c3] {f : \u03b1 -> (Option.{u3} \u03b2)} {g : \u03b1 -> \u03b2 -> \u03c3}, (Primrec.{u2, u3} \u03b1 (Option.{u3} \u03b2) _inst_1 (Primcodable.option.{u3} \u03b2 _inst_2) f) -> (Primrec\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 g) -> (Primrec.{u2, u1} \u03b1 (Option.{u1} \u03c3) _inst_1 (Primcodable.option.{u1} \u03c3 _inst_5) (fun (a : \u03b1) => Option.map.{u3, u1} \u03b2 \u03c3 (g a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.option_map Primrec.option_map\u2093'. -/\ntheorem option_map {f : \u03b1 \u2192 Option \u03b2} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (hf : Primrec f) (hg : Primrec\u2082 g) :\n    Primrec fun a => (f a).map (g a) :=\n  option_bind hf (option_some.comp\u2082 hg)\n#align primrec.option_map Primrec.option_map\n\n/- warning: primrec.option_map\u2081 -> Primrec.option_map\u2081 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_5 : Primcodable.{u2} \u03c3] {f : \u03b1 -> \u03c3}, (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 f) -> (Primrec.{u1, u2} (Option.{u1} \u03b1) (Option.{u2} \u03c3) (Primcodable.option.{u1} \u03b1 _inst_1) (Primcodable.option.{u2} \u03c3 _inst_5) (Option.map.{u1, u2} \u03b1 \u03c3 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_5 : Primcodable.{u1} \u03c3] {f : \u03b1 -> \u03c3}, (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 f) -> (Primrec.{u2, u1} (Option.{u2} \u03b1) (Option.{u1} \u03c3) (Primcodable.option.{u2} \u03b1 _inst_1) (Primcodable.option.{u1} \u03c3 _inst_5) (Option.map.{u2, u1} \u03b1 \u03c3 f))\nCase conversion may be inaccurate. Consider using '#align primrec.option_map\u2081 Primrec.option_map\u2081\u2093'. -/\ntheorem option_map\u2081 {f : \u03b1 \u2192 \u03c3} (hf : Primrec f) : Primrec (Option.map f) :=\n  option_map Primrec.id (hf.comp snd).to\u2082\n#align primrec.option_map\u2081 Primrec.option_map\u2081\n\n#print Primrec.option_iget /-\ntheorem option_iget [Inhabited \u03b1] : Primrec (@Option.iget \u03b1 _) :=\n  (option_cases Primrec.id (const <| @default \u03b1 _) Primrec\u2082.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 \u03b1) :=\n  (option_cases Primrec.id (const false) (const true).to\u2082).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\u2082 (@Option.getD \u03b1) :=\n  Primrec.of_eq (option_cases Primrec\u2082.left Primrec\u2082.right Primrec\u2082.right) fun \u27e8o, a\u27e9 => 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> (Option.{u3} \u03c3)}, Iff (Primrec\u2082.{u1, 0, u3} \u03b1 Nat (Option.{u3} \u03c3) _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u3} \u03c3 _inst_5) (fun (a : \u03b1) (n : Nat) => Option.bind.{u2, u3} \u03b2 \u03c3 (Encodable.decode.{u2} \u03b2 (Primcodable.toEncodable.{u2} \u03b2 _inst_2) n) (f a))) (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 (Option.{u3} \u03c3) _inst_1 _inst_2 (Primcodable.option.{u3} \u03c3 _inst_5) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] [_inst_5 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> (Option.{u3} \u03c3)}, Iff (Primrec\u2082.{u2, 0, u3} \u03b1 Nat (Option.{u3} \u03c3) _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u3} \u03c3 _inst_5) (fun (a : \u03b1) (n : Nat) => Option.bind.{u1, u3} \u03b2 \u03c3 (Encodable.decode.{u1} \u03b2 (Primcodable.toEncodable.{u1} \u03b2 _inst_2) n) (f a))) (Primrec\u2082.{u2, u1, u3} \u03b1 \u03b2 (Option.{u3} \u03c3) _inst_1 _inst_2 (Primcodable.option.{u3} \u03c3 _inst_5) f)\nCase conversion may be inaccurate. Consider using '#align primrec.bind_decode_iff Primrec.bind_decode_iff\u2093'. -/\ntheorem bind_decode_iff {f : \u03b1 \u2192 \u03b2 \u2192 Option \u03c3} :\n    (Primrec\u2082 fun a n => (decode \u03b2 n).bind (f a)) \u2194 Primrec\u2082 f :=\n  \u27e8fun h => by simpa [encodek] using h.comp fst ((@Primrec.encode \u03b2 _).comp snd), fun h =>\n    option_bind (Primrec.decode.comp snd) <| h.comp (fst.comp fst) snd\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_5 : Primcodable.{u3} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u1, 0, u3} \u03b1 Nat (Option.{u3} \u03c3) _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u3} \u03c3 _inst_5) (fun (a : \u03b1) (n : Nat) => Option.map.{u2, u3} \u03b2 \u03c3 (f a) (Encodable.decode.{u2} \u03b2 (Primcodable.toEncodable.{u2} \u03b2 _inst_2) n))) (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u3} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] [_inst_5 : Primcodable.{u2} \u03c3] {f : \u03b1 -> \u03b2 -> \u03c3}, Iff (Primrec\u2082.{u3, 0, u2} \u03b1 Nat (Option.{u2} \u03c3) _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (Primcodable.option.{u2} \u03c3 _inst_5) (fun (a : \u03b1) (n : Nat) => Option.map.{u1, u2} \u03b2 \u03c3 (f a) (Encodable.decode.{u1} \u03b2 (Primcodable.toEncodable.{u1} \u03b2 _inst_2) n))) (Primrec\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_5 f)\nCase conversion may be inaccurate. Consider using '#align primrec.map_decode_iff Primrec.map_decode_iff\u2093'. -/\ntheorem map_decode_iff {f : \u03b1 \u2192 \u03b2 \u2192 \u03c3} :\n    (Primrec\u2082 fun a n => (decode \u03b2 n).map (f a)) \u2194 Primrec\u2082 f :=\n  bind_decode_iff.trans Primrec\u2082.option_some_iff\n#align primrec.map_decode_iff Primrec.map_decode_iff\n\n#print Primrec.nat_add /-\ntheorem nat_add : Primrec\u2082 ((\u00b7 + \u00b7) : \u2115 \u2192 \u2115 \u2192 \u2115) :=\n  Primrec\u2082.unpaired'.1 Nat.Primrec.add\n#align primrec.nat_add Primrec.nat_add\n-/\n\n#print Primrec.nat_sub /-\ntheorem nat_sub : Primrec\u2082 (Sub.sub : \u2115 \u2192 \u2115 \u2192 \u2115) :=\n  Primrec\u2082.unpaired'.1 Nat.Primrec.sub\n#align primrec.nat_sub Primrec.nat_sub\n-/\n\n#print Primrec.nat_mul /-\ntheorem nat_mul : Primrec\u2082 ((\u00b7 * \u00b7) : \u2115 \u2192 \u2115 \u2192 \u2115) :=\n  Primrec\u2082.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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_5 : Primcodable.{u2} \u03c3] {c : \u03b1 -> Bool} {f : \u03b1 -> \u03c3} {g : \u03b1 -> \u03c3}, (Primrec.{u1, 0} \u03b1 Bool _inst_1 Primcodable.bool c) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 f) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 g) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 (fun (a : \u03b1) => cond.{u2} \u03c3 (c a) (f a) (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_5 : Primcodable.{u1} \u03c3] {c : \u03b1 -> Bool} {f : \u03b1 -> \u03c3} {g : \u03b1 -> \u03c3}, (Primrec.{u2, 0} \u03b1 Bool _inst_1 Primcodable.bool c) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 f) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 g) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 (fun (a : \u03b1) => cond.{u1} \u03c3 (c a) (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.cond Primrec.cond\u2093'. -/\ntheorem cond {c : \u03b1 \u2192 Bool} {f : \u03b1 \u2192 \u03c3} {g : \u03b1 \u2192 \u03c3} (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\u2082).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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_5 : Primcodable.{u2} \u03c3] {c : \u03b1 -> Prop} [_inst_6 : DecidablePred.{succ u1} \u03b1 c] {f : \u03b1 -> \u03c3} {g : \u03b1 -> \u03c3}, (PrimrecPred.{u1} \u03b1 _inst_1 c (fun (a : \u03b1) => _inst_6 a)) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 f) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 g) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 (fun (a : \u03b1) => ite.{succ u2} \u03c3 (c a) (_inst_6 a) (f a) (g a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_5 : Primcodable.{u1} \u03c3] {c : \u03b1 -> Prop} [_inst_6 : DecidablePred.{succ u2} \u03b1 c] {f : \u03b1 -> \u03c3} {g : \u03b1 -> \u03c3}, (PrimrecPred.{u2} \u03b1 _inst_1 c (fun (a : \u03b1) => _inst_6 a)) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 f) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 g) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 (fun (a : \u03b1) => ite.{succ u1} \u03c3 (c a) (_inst_6 a) (f a) (g a)))\nCase conversion may be inaccurate. Consider using '#align primrec.ite Primrec.ite\u2093'. -/\ntheorem ite {c : \u03b1 \u2192 Prop} [DecidablePred c] {f : \u03b1 \u2192 \u03c3} {g : \u03b1 \u2192 \u03c3} (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\u2093'. -/\ntheorem nat_le : PrimrecRel ((\u00b7 \u2264 \u00b7) : \u2115 \u2192 \u2115 \u2192 Prop) :=\n  (nat_cases nat_sub (const true) (const false).to\u2082).of_eq fun p =>\n    by\n    dsimp [swap]\n    cases' e : p.1 - p.2 with n\n    \u00b7 simp [tsub_eq_zero_iff_le.1 e]\n    \u00b7 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\u2082.{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\u2082.{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\u2093'. -/\ntheorem nat_min : Primrec\u2082 (@min \u2115 _) :=\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\u2082.{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\u2082.{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\u2093'. -/\ntheorem nat_max : Primrec\u2082 (@max \u2115 _) :=\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 \u2192 \u03b1) : 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\u2082 /-\ntheorem dom_bool\u2082 (f : Bool \u2192 Bool \u2192 \u03b1) : Primrec\u2082 f :=\n  (cond fst ((dom_bool (f true)).comp snd) ((dom_bool (f false)).comp snd)).of_eq fun \u27e8a, b\u27e9 => by\n    cases a <;> rfl\n#align primrec.dom_bool\u2082 Primrec.dom_bool\u2082\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\u2082 and :=\n  dom_bool\u2082 _\n#align primrec.band Primrec.and\n-/\n\n#print Primrec.or /-\nprotected theorem or : Primrec\u2082 or :=\n  dom_bool\u2082 _\n#align primrec.bor Primrec.or\n-/\n\n#print PrimrecPred.not /-\nprotected theorem not {p : \u03b1 \u2192 Prop} [DecidablePred p] (hp : PrimrecPred p) :\n    PrimrecPred fun a => \u00acp 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 : \u03b1 \u2192 Prop} [DecidablePred p] [DecidablePred q] (hp : PrimrecPred p)\n    (hq : PrimrecPred q) : PrimrecPred fun a => p a \u2227 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 : \u03b1 \u2192 Prop} [DecidablePred p] [DecidablePred q] (hp : PrimrecPred p)\n    (hq : PrimrecPred q) : PrimrecPred fun a => p a \u2228 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 \u03b1] : PrimrecRel (@Eq \u03b1) :=\n  have : PrimrecRel fun a b : \u2115 => a = b :=\n    (PrimrecPred.and nat_le nat_le.symm).of_eq fun a => by simp [le_antisymm_iff]\n  (this.comp\u2082 (Primrec.encode.comp\u2082 Primrec\u2082.left) (Primrec.encode.comp\u2082 Primrec\u2082.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\u2093'. -/\ntheorem nat_lt : PrimrecRel ((\u00b7 < \u00b7) : \u2115 \u2192 \u2115 \u2192 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] {p : \u03b1 -> \u03b2 -> Prop} [_inst_6 : forall (a : \u03b1) (b : \u03b2), Decidable (p a b)], (PrimrecRel.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 p (fun (a : \u03b1) (b : \u03b2) => _inst_6 a b)) -> (forall {f : \u03b1 -> \u03b2}, (Primrec.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Primrec.{u1, u2} \u03b1 (Option.{u2} \u03b2) _inst_1 (Primcodable.option.{u2} \u03b2 _inst_2) (fun (a : \u03b1) => Option.guard.{u2} \u03b2 (p a) (fun (a_1 : \u03b2) => _inst_6 a a_1) (f a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] {p : \u03b1 -> \u03b2 -> Prop} [_inst_6 : forall (a : \u03b1) (b : \u03b2), Decidable (p a b)], (PrimrecRel.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 p (fun (a : \u03b1) (b : \u03b2) => _inst_6 a b)) -> (forall {f : \u03b1 -> \u03b2}, (Primrec.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Primrec.{u2, u1} \u03b1 (Option.{u1} \u03b2) _inst_1 (Primcodable.option.{u1} \u03b2 _inst_2) (fun (a : \u03b1) => Option.guard.{u1} \u03b2 (p a) (fun (a_1 : \u03b2) => _inst_6 a a_1) (f a))))\nCase conversion may be inaccurate. Consider using '#align primrec.option_guard Primrec.option_guard\u2093'. -/\ntheorem option_guard {p : \u03b1 \u2192 \u03b2 \u2192 Prop} [\u2200 a b, Decidable (p a b)] (hp : PrimrecRel p) {f : \u03b1 \u2192 \u03b2}\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 {\u03b1 : Type.{u1}} [_inst_1 : Primcodable.{u1} \u03b1], Primrec\u2082.{u1, u1, u1} (Option.{u1} \u03b1) (Option.{u1} \u03b1) (Option.{u1} \u03b1) (Primcodable.option.{u1} \u03b1 _inst_1) (Primcodable.option.{u1} \u03b1 _inst_1) (Primcodable.option.{u1} \u03b1 _inst_1) (HasOrelse.orelse.{u1, u1} Option.{u1} (Alternative.toHasOrelse.{u1, u1} Option.{u1} Option.alternative.{u1}) \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Primcodable.{u1} \u03b1], Primrec\u2082.{u1, u1, u1} (Option.{u1} \u03b1) (Option.{u1} \u03b1) (Option.{u1} \u03b1) (Primcodable.option.{u1} \u03b1 _inst_1) (Primcodable.option.{u1} \u03b1 _inst_1) (Primcodable.option.{u1} \u03b1 _inst_1) (fun (x._@.Mathlib.Computability.Primrec._hyg.7041 : Option.{u1} \u03b1) (x._@.Mathlib.Computability.Primrec._hyg.7043 : Option.{u1} \u03b1) => HOrElse.hOrElse.{u1, u1, u1} (Option.{u1} \u03b1) (Option.{u1} \u03b1) (Option.{u1} \u03b1) (instHOrElse.{u1} (Option.{u1} \u03b1) (Option.instOrElseOption.{u1} \u03b1)) 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\u2093'. -/\ntheorem option_orElse : Primrec\u2082 ((\u00b7 <|> \u00b7) : Option \u03b1 \u2192 Option \u03b1 \u2192 Option \u03b1) :=\n  (option_cases fst snd (fst.comp fst).to\u2082).of_eq fun \u27e8o\u2081, o\u2082\u27e9 => by cases o\u2081 <;> cases o\u2082 <;> rfl\n#align primrec.option_orelse Primrec.option_orElse\n\n#print Primrec.decode\u2082 /-\nprotected theorem decode\u2082 : Primrec (decode\u2082 \u03b1) :=\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\u2082 Primrec.decode\u2082\n-/\n\n/- warning: primrec.list_find_index\u2081 -> Primrec.list_findIdx\u2081 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] {p : \u03b1 -> \u03b2 -> Prop} [_inst_6 : forall (a : \u03b1) (b : \u03b2), Decidable (p a b)], (PrimrecRel.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 p (fun (a : \u03b1) (b : \u03b2) => _inst_6 a b)) -> (forall (l : List.{u2} \u03b2), Primrec.{u1, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : \u03b1) => List.findIndex.{u2} \u03b2 (p a) (fun (a_1 : \u03b2) => _inst_6 a a_1) l))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2] {p : \u03b1 -> \u03b2 -> Bool}, (Primrec\u2082.{u2, u1, 0} \u03b1 \u03b2 Bool _inst_1 _inst_2 Primcodable.bool p) -> (forall (hp : List.{u1} \u03b2), Primrec.{u2, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : \u03b1) => List.findIdx.{u1} \u03b2 (p a) hp))\nCase conversion may be inaccurate. Consider using '#align primrec.list_find_index\u2081 Primrec.list_findIdx\u2081\u2093'. -/\ntheorem list_findIdx\u2081 {p : \u03b1 \u2192 \u03b2 \u2192 Prop} [\u2200 a b, Decidable (p a b)] (hp : PrimrecRel p) :\n    \u2200 l : List \u03b2, 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\u2081 l))\n#align primrec.list_find_index\u2081 Primrec.list_findIdx\u2081\n\n#print Primrec.list_indexOf\u2081 /-\ntheorem list_indexOf\u2081 [DecidableEq \u03b1] (l : List \u03b1) : Primrec fun a => l.indexOf\u2093 a :=\n  list_findIdx\u2081 Primrec.eq l\n#align primrec.list_index_of\u2081 Primrec.list_indexOf\u2081\n-/\n\n/- warning: primrec.dom_fintype -> Primrec.dom_fintype is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_5 : Primcodable.{u2} \u03c3] [_inst_6 : Fintype.{u1} \u03b1] (f : \u03b1 -> \u03c3), Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_5 f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_5 : Primcodable.{u1} \u03c3] [_inst_6 : Fintype.{u2} \u03b1] (f : \u03b1 -> \u03c3), Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_5 f\nCase conversion may be inaccurate. Consider using '#align primrec.dom_fintype Primrec.dom_fintype\u2093'. -/\ntheorem dom_fintype [Fintype \u03b1] (f : \u03b1 \u2192 \u03c3) : Primrec f :=\n  let \u27e8l, nd, m\u27e9 := Finite.exists_univ_list \u03b1\n  option_some_iff.1 <| by\n    haveI := decidable_eq_of_encodable \u03b1\n    refine' ((list_nth\u2081 (l.map f)).comp (list_index_of\u2081 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 {\u03b1 : Type.{u}} {\u03b2 : Type.{v}}, (Nat -> \u03b1 -> \u03b2) -> Nat -> (List.{u} \u03b1) -> (List.{v} \u03b2)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_bodd_div2 [anonymous]\u2093'. -/\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\u2082).of_eq\n    fun n => by\n    simp [-Nat.boddDiv2_eq]\n    induction' n with n IH; \u00b7 rfl\n    simp [-Nat.boddDiv2_eq, Nat.boddDiv2, *]\n    rcases Nat.boddDiv2 n with \u27e8_ | _, m\u27e9 <;> 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\u2093'. -/\ntheorem nat_double : Primrec (@bit0 \u2115 _) :=\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\u2093'. -/\ntheorem nat_double_succ : Primrec (@bit1 \u2115 _ _) :=\n  nat_add.comp nat_double (const 1)\n#align primrec.nat_bit1 Primrec.nat_double_succ\n\ntheorem nat_bit : Primrec\u2082 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\u2082.{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 {\u03b1 : Type.{u}} {\u03b2 : Type.{v}}, (Nat -> \u03b1 -> \u03b2) -> Nat -> (List.{u} \u03b1) -> (List.{v} \u03b2)\nCase conversion may be inaccurate. Consider using '#align primrec.nat_div_mod [anonymous]\u2093'. -/\ntheorem [anonymous] : Primrec\u2082 fun n k : \u2115 => (n / k, n % k) :=\n  let f (a : \u2115 \u00d7 \u2115) : \u2115 \u00d7 \u2115 :=\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 \u2115 _ _).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\u2082\n  suffices \u2200 k n, (n / k, n % k) = f (n, k) from hf.of_eq fun \u27e8m, n\u27e9 => by simp [this]\n  fun k n =>\n  by\n  have :\n    (f (n, k)).2 + k * (f (n, k)).1 = n \u2227 (0 < k \u2192 (f (n, k)).2 < k) \u2227 (k = 0 \u2192 (f (n, k)).1 = 0) :=\n    by\n    induction' n with n IH\n    \u00b7 exact \u27e8rfl, id, fun _ => rfl\u27e9\n    rw [fun n : \u2115 =>\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    \u00b7 have := congr_arg Nat.succ IH.1\n      refine' \u27e8_, fun k0 => Nat.noConfusion (h.trans k0)\u27e9\n      rwa [\u2190 Nat.succ_add, h, add_comm, \u2190 Nat.mul_succ] at this\n    \u00b7 exact \u27e8by rw [Nat.succ_add, IH.1], fun k0 => lt_of_le_of_ne (IH.2.1 k0) h, IH.2.2\u27e9\n  revert this\n  cases' f (n, k) with D M\n  simp\n  intro h\u2081 h\u2082 h\u2083\n  cases Nat.eq_zero_or_pos k\n  \u00b7 simp [h, h\u2083 h] at h\u2081\u22a2\n    simp [h\u2081]\n  \u00b7 exact (Nat.div_mod_unique h).2 \u27e8h\u2081, h\u2082 h\u27e9\n#align primrec.nat_div_mod [anonymous]\n\n#print Primrec.nat_div /-\ntheorem nat_div : Primrec\u2082 ((\u00b7 / \u00b7) : \u2115 \u2192 \u2115 \u2192 \u2115) :=\n  fst.comp\u2082 [anonymous]\n#align primrec.nat_div Primrec.nat_div\n-/\n\n#print Primrec.nat_mod /-\ntheorem nat_mod : Primrec\u2082 ((\u00b7 % \u00b7) : \u2115 \u2192 \u2115 \u2192 \u2115) :=\n  snd.comp\u2082 [anonymous]\n#align primrec.nat_mod Primrec.nat_mod\n-/\n\nend Primrec\n\nsection\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03c3]\n\nvariable (H : Nat.Primrec fun n => Encodable.encode (decode (List \u03b2) n))\n\ninclude H\n\nopen Primrec\n\nprivate def prim : Primcodable (List \u03b2) :=\n  \u27e8H\u27e9\n#align prim prim\n\nprivate theorem list_cases' {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b2 \u00d7 List \u03b2 \u2192 \u03c3}\n    (hf :\n      haveI := prim H\n      Primrec f)\n    (hg : Primrec g)\n    (hh :\n      haveI := prim H\n      Primrec\u2082 h) :\n    @Primrec _ \u03c3 _ _ fun a => List.casesOn (f a) (g a) fun b l => h a (b, l) :=\n  letI := prim H\n  have :\n    @Primrec _ (Option \u03c3) _ _ fun a =>\n      (decode (Option (\u03b2 \u00d7 List \u03b2)) (encode (f a))).map fun o => Option.casesOn o (g a) (h a) :=\n    ((@map_decode_iff _ (Option (\u03b2 \u00d7 List \u03b2)) _ _ _ _ _).2 <|\n          to\u2082 <|\n            option_cases snd (hg.comp fst) (hh.comp\u2082 (fst.comp\u2082 Primrec\u2082.left) Primrec\u2082.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 : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03c3 \u00d7 \u03b2 \u2192 \u03c3}\n    (hf :\n      haveI := prim H\n      Primrec f)\n    (hg : Primrec g)\n    (hh :\n      haveI := prim H\n      Primrec\u2082 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 : \u03b1) (IH : \u03c3 \u00d7 List \u03b2) : \u03c3 \u00d7 List \u03b2 := List.casesOn IH.2 IH fun b l => (h a (IH.1, b), l)\n  let F (a : \u03b1) (n : \u2115) := (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\u2082 <|\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      \u2200 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      \u00b7 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\u2082 (@List.cons \u03b2) :=\n  letI := prim H\n  encode_iff.1 (succ.comp <| primrec\u2082.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 \u03b2) :=\n  letI := prim H\n  (list_foldl' H Primrec.id (const []) <| to\u2082 <| ((list_cons' H).comp snd fst).comp snd).of_eq\n    (suffices \u2200 l r, List.foldl (fun (s : List \u03b2) (b : \u03b2) => 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 {\u03b1 : Type _} {\u03b2 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2]\n\nopen Primrec\n\n#print Primcodable.sum /-\ninstance sum : Primcodable (Sum \u03b1 \u03b2) :=\n  \u27e8Primrec.nat_iff.1 <|\n      (encode_iff.2\n            (cond nat_bodd\n              (((@Primrec.decode \u03b2 _).comp nat_div2).option_map <|\n                to\u2082 <| nat_bit.comp (const true) (Primrec.encode.comp snd))\n              (((@Primrec.decode \u03b1 _).comp nat_div2).option_map <|\n                to\u2082 <| 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          \u00b7 cases decode \u03b1 n.div2 <;> rfl\n          \u00b7 cases decode \u03b2 n.div2 <;> rfl\u27e9\n#align primcodable.sum Primcodable.sum\n-/\n\n#print Primcodable.list /-\ninstance list : Primcodable (List \u03b1) :=\n  \u27e8letI H := Primcodable.prim (List \u2115)\n    have : Primrec\u2082 fun (a : \u03b1) (o : Option (List \u2115)) => o.map (List.cons (encode a)) :=\n      option_map snd <| (list_cons' H).comp ((@Primrec.encode \u03b1 _).comp (fst.comp fst)) snd\n    have :\n      Primrec fun n =>\n        (of_nat (List \u2115) n).reverse.foldl\n          (fun o m => (decode \u03b1 m).bind fun a => o.map (List.cons (encode a))) (some []) :=\n      list_foldl' H ((list_reverse' H).comp (Primrec.ofNat (List \u2115))) (const (some []))\n        (Primrec.comp\u2082 (bind_decode_iff.2 <| Primrec\u2082.swap this) Primrec\u2082.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; \u00b7 simp\n        intro n IH; simp\n        cases' decode \u03b1 n.unpair.1 with a; \u00b7 rfl\n        simp\n        suffices :\n          \u2200 (o : Option (List \u2115)) (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\u27e9\n#align primcodable.list Primcodable.list\n-/\n\nend Primcodable\n\nnamespace Primrec\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] [Primcodable \u03c3]\n\n/- warning: primrec.sum_inl -> Primrec.sum_inl is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2], Primrec.{u1, max u1 u2} \u03b1 (Sum.{u1, u2} \u03b1 \u03b2) _inst_1 (Primcodable.sum.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (Sum.inl.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u1} \u03b2], Primrec.{u2, max u2 u1} \u03b1 (Sum.{u2, u1} \u03b1 \u03b2) _inst_1 (Primcodable.sum.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (Sum.inl.{u2, u1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align primrec.sum_inl Primrec.sum_inl\u2093'. -/\ntheorem sum_inl : Primrec (@Sum.inl \u03b1 \u03b2) :=\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 \u03b1 \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03c3 : Type.{u4}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_3 : Primcodable.{u3} \u03b3] [_inst_4 : Primcodable.{u4} \u03c3] {f : \u03b1 -> (Sum.{u2, u3} \u03b2 \u03b3)} {g : \u03b1 -> \u03b2 -> \u03c3} {h : \u03b1 -> \u03b3 -> \u03c3}, (Primrec.{u1, max u2 u3} \u03b1 (Sum.{u2, u3} \u03b2 \u03b3) _inst_1 (Primcodable.sum.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) f) -> (Primrec\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_4 g) -> (Primrec\u2082.{u1, u3, u4} \u03b1 \u03b3 \u03c3 _inst_1 _inst_3 _inst_4 h) -> (Primrec.{u1, u4} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => Sum.casesOn.{succ u4, u2, u3} \u03b2 \u03b3 (fun (_x : Sum.{u2, u3} \u03b2 \u03b3) => \u03c3) (f a) (g a) (h a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u4}} {\u03b3 : Type.{u3}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u4} \u03b2] [_inst_3 : Primcodable.{u3} \u03b3] [_inst_4 : Primcodable.{u1} \u03c3] {f : \u03b1 -> (Sum.{u4, u3} \u03b2 \u03b3)} {g : \u03b1 -> \u03b2 -> \u03c3} {h : \u03b1 -> \u03b3 -> \u03c3}, (Primrec.{u2, max u4 u3} \u03b1 (Sum.{u4, u3} \u03b2 \u03b3) _inst_1 (Primcodable.sum.{u4, u3} \u03b2 \u03b3 _inst_2 _inst_3) f) -> (Primrec\u2082.{u2, u4, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_4 g) -> (Primrec\u2082.{u2, u3, u1} \u03b1 \u03b3 \u03c3 _inst_1 _inst_3 _inst_4 h) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => Sum.casesOn.{succ u1, u4, u3} \u03b2 \u03b3 (fun (_x : Sum.{u4, u3} \u03b2 \u03b3) => \u03c3) (f a) (g a) (h a)))\nCase conversion may be inaccurate. Consider using '#align primrec.sum_cases Primrec.sum_cases\u2093'. -/\ntheorem sum_cases {f : \u03b1 \u2192 Sum \u03b2 \u03b3} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b3 \u2192 \u03c3} (hf : Primrec f)\n    (hg : Primrec\u2082 g) (hh : Primrec\u2082 h) : @Primrec _ \u03c3 _ _ 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\u2082 (@List.cons \u03b1) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_4 : Primcodable.{u3} \u03c3] {f : \u03b1 -> (List.{u2} \u03b2)} {g : \u03b1 -> \u03c3} {h : \u03b1 -> (Prod.{u2, u2} \u03b2 (List.{u2} \u03b2)) -> \u03c3}, (Primrec.{u1, u2} \u03b1 (List.{u2} \u03b2) _inst_1 (Primcodable.list.{u2} \u03b2 _inst_2) f) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_4 g) -> (Primrec\u2082.{u1, u2, u3} \u03b1 (Prod.{u2, u2} \u03b2 (List.{u2} \u03b2)) \u03c3 _inst_1 (Primcodable.prod.{u2, u2} \u03b2 (List.{u2} \u03b2) _inst_2 (Primcodable.list.{u2} \u03b2 _inst_2)) _inst_4 h) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => List.casesOn.{succ u3, u2} \u03b2 (fun (_x : List.{u2} \u03b2) => \u03c3) (f a) (g a) (fun (b : \u03b2) (l : List.{u2} \u03b2) => h a (Prod.mk.{u2, u2} \u03b2 (List.{u2} \u03b2) b l))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_4 : Primcodable.{u1} \u03c3] {f : \u03b1 -> (List.{u3} \u03b2)} {g : \u03b1 -> \u03c3} {h : \u03b1 -> (Prod.{u3, u3} \u03b2 (List.{u3} \u03b2)) -> \u03c3}, (Primrec.{u2, u3} \u03b1 (List.{u3} \u03b2) _inst_1 (Primcodable.list.{u3} \u03b2 _inst_2) f) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_4 g) -> (Primrec\u2082.{u2, u3, u1} \u03b1 (Prod.{u3, u3} \u03b2 (List.{u3} \u03b2)) \u03c3 _inst_1 (Primcodable.prod.{u3, u3} \u03b2 (List.{u3} \u03b2) _inst_2 (Primcodable.list.{u3} \u03b2 _inst_2)) _inst_4 h) -> (Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => List.casesOn.{succ u1, u3} \u03b2 (fun (_x : List.{u3} \u03b2) => \u03c3) (f a) (g a) (fun (b : \u03b2) (l : List.{u3} \u03b2) => h a (Prod.mk.{u3, u3} \u03b2 (List.{u3} \u03b2) b l))))\nCase conversion may be inaccurate. Consider using '#align primrec.list_cases Primrec.list_cases\u2093'. -/\ntheorem list_cases {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b2 \u00d7 List \u03b2 \u2192 \u03c3} :\n    Primrec f \u2192\n      Primrec g \u2192\n        Primrec\u2082 h \u2192 @Primrec _ \u03c3 _ _ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_4 : Primcodable.{u3} \u03c3] {f : \u03b1 -> (List.{u2} \u03b2)} {g : \u03b1 -> \u03c3} {h : \u03b1 -> (Prod.{u3, u2} \u03c3 \u03b2) -> \u03c3}, (Primrec.{u1, u2} \u03b1 (List.{u2} \u03b2) _inst_1 (Primcodable.list.{u2} \u03b2 _inst_2) f) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_4 g) -> (Primrec\u2082.{u1, max u3 u2, u3} \u03b1 (Prod.{u3, u2} \u03c3 \u03b2) \u03c3 _inst_1 (Primcodable.prod.{u3, u2} \u03c3 \u03b2 _inst_4 _inst_2) _inst_4 h) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => List.foldl.{u3, u2} \u03c3 \u03b2 (fun (s : \u03c3) (b : \u03b2) => h a (Prod.mk.{u3, u2} \u03c3 \u03b2 s b)) (g a) (f a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_4 : Primcodable.{u2} \u03c3] {f : \u03b1 -> (List.{u3} \u03b2)} {g : \u03b1 -> \u03c3} {h : \u03b1 -> (Prod.{u2, u3} \u03c3 \u03b2) -> \u03c3}, (Primrec.{u1, u3} \u03b1 (List.{u3} \u03b2) _inst_1 (Primcodable.list.{u3} \u03b2 _inst_2) f) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 g) -> (Primrec\u2082.{u1, max u3 u2, u2} \u03b1 (Prod.{u2, u3} \u03c3 \u03b2) \u03c3 _inst_1 (Primcodable.prod.{u2, u3} \u03c3 \u03b2 _inst_4 _inst_2) _inst_4 h) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => List.foldl.{u2, u3} \u03c3 \u03b2 (fun (s : \u03c3) (b : \u03b2) => h a (Prod.mk.{u2, u3} \u03c3 \u03b2 s b)) (g a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_foldl Primrec.list_foldl\u2093'. -/\ntheorem list_foldl {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03c3 \u00d7 \u03b2 \u2192 \u03c3} :\n    Primrec f \u2192\n      Primrec g \u2192 Primrec\u2082 h \u2192 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 \u03b1) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_4 : Primcodable.{u3} \u03c3] {f : \u03b1 -> (List.{u2} \u03b2)} {g : \u03b1 -> \u03c3} {h : \u03b1 -> (Prod.{u2, u3} \u03b2 \u03c3) -> \u03c3}, (Primrec.{u1, u2} \u03b1 (List.{u2} \u03b2) _inst_1 (Primcodable.list.{u2} \u03b2 _inst_2) f) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_4 g) -> (Primrec\u2082.{u1, max u2 u3, u3} \u03b1 (Prod.{u2, u3} \u03b2 \u03c3) \u03c3 _inst_1 (Primcodable.prod.{u2, u3} \u03b2 \u03c3 _inst_2 _inst_4) _inst_4 h) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => List.foldr.{u2, u3} \u03b2 \u03c3 (fun (b : \u03b2) (s : \u03c3) => h a (Prod.mk.{u2, u3} \u03b2 \u03c3 b s)) (g a) (f a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_4 : Primcodable.{u2} \u03c3] {f : \u03b1 -> (List.{u3} \u03b2)} {g : \u03b1 -> \u03c3} {h : \u03b1 -> (Prod.{u3, u2} \u03b2 \u03c3) -> \u03c3}, (Primrec.{u1, u3} \u03b1 (List.{u3} \u03b2) _inst_1 (Primcodable.list.{u3} \u03b2 _inst_2) f) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 g) -> (Primrec\u2082.{u1, max u3 u2, u2} \u03b1 (Prod.{u3, u2} \u03b2 \u03c3) \u03c3 _inst_1 (Primcodable.prod.{u3, u2} \u03b2 \u03c3 _inst_2 _inst_4) _inst_4 h) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => List.foldr.{u3, u2} \u03b2 \u03c3 (fun (b : \u03b2) (s : \u03c3) => h a (Prod.mk.{u3, u2} \u03b2 \u03c3 b s)) (g a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_foldr Primrec.list_foldr\u2093'. -/\ntheorem list_foldr {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b2 \u00d7 \u03c3 \u2192 \u03c3} (hf : Primrec f)\n    (hg : Primrec g) (hh : Primrec\u2082 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\u2082 <| 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? \u03b1) :=\n  (list_cases Primrec.id (const none) (option_some_iff.2 <| fst.comp snd).to\u2082).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 \u03b1] : Primrec (@List.headI \u03b1 _) :=\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 \u03b1) :=\n  (list_cases Primrec.id (const []) (snd.comp snd).to\u2082).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_4 : Primcodable.{u3} \u03c3] {f : \u03b1 -> (List.{u2} \u03b2)} {g : \u03b1 -> \u03c3} {h : \u03b1 -> (Prod.{u2, max u2 u3} \u03b2 (Prod.{u2, u3} (List.{u2} \u03b2) \u03c3)) -> \u03c3}, (Primrec.{u1, u2} \u03b1 (List.{u2} \u03b2) _inst_1 (Primcodable.list.{u2} \u03b2 _inst_2) f) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_4 g) -> (Primrec\u2082.{u1, max u2 u3, u3} \u03b1 (Prod.{u2, max u2 u3} \u03b2 (Prod.{u2, u3} (List.{u2} \u03b2) \u03c3)) \u03c3 _inst_1 (Primcodable.prod.{u2, max u2 u3} \u03b2 (Prod.{u2, u3} (List.{u2} \u03b2) \u03c3) _inst_2 (Primcodable.prod.{u2, u3} (List.{u2} \u03b2) \u03c3 (Primcodable.list.{u2} \u03b2 _inst_2) _inst_4)) _inst_4 h) -> (Primrec.{u1, u3} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => List.recOn.{succ u3, u2} \u03b2 (fun (_x : List.{u2} \u03b2) => \u03c3) (f a) (g a) (fun (b : \u03b2) (l : List.{u2} \u03b2) (IH : \u03c3) => h a (Prod.mk.{u2, max u2 u3} \u03b2 (Prod.{u2, u3} (List.{u2} \u03b2) \u03c3) b (Prod.mk.{u2, u3} (List.{u2} \u03b2) \u03c3 l IH)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_4 : Primcodable.{u2} \u03c3] {f : \u03b1 -> (List.{u3} \u03b2)} {g : \u03b1 -> \u03c3} {h : \u03b1 -> (Prod.{u3, max u2 u3} \u03b2 (Prod.{u3, u2} (List.{u3} \u03b2) \u03c3)) -> \u03c3}, (Primrec.{u1, u3} \u03b1 (List.{u3} \u03b2) _inst_1 (Primcodable.list.{u3} \u03b2 _inst_2) f) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 g) -> (Primrec\u2082.{u1, max u3 u2, u2} \u03b1 (Prod.{u3, max u2 u3} \u03b2 (Prod.{u3, u2} (List.{u3} \u03b2) \u03c3)) \u03c3 _inst_1 (Primcodable.prod.{u3, max u3 u2} \u03b2 (Prod.{u3, u2} (List.{u3} \u03b2) \u03c3) _inst_2 (Primcodable.prod.{u3, u2} (List.{u3} \u03b2) \u03c3 (Primcodable.list.{u3} \u03b2 _inst_2) _inst_4)) _inst_4 h) -> (Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 (fun (a : \u03b1) => List.recOn.{succ u2, u3} \u03b2 (fun (_x : List.{u3} \u03b2) => \u03c3) (f a) (g a) (fun (b : \u03b2) (l : List.{u3} \u03b2) (IH : \u03c3) => h a (Prod.mk.{u3, max u3 u2} \u03b2 (Prod.{u3, u2} (List.{u3} \u03b2) \u03c3) b (Prod.mk.{u3, u2} (List.{u3} \u03b2) \u03c3 l IH)))))\nCase conversion may be inaccurate. Consider using '#align primrec.list_rec Primrec.list_rec\u2093'. -/\ntheorem list_rec {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03c3} {h : \u03b1 \u2192 \u03b2 \u00d7 List \u03b2 \u00d7 \u03c3 \u2192 \u03c3} (hf : Primrec f)\n    (hg : Primrec g) (hh : Primrec\u2082 h) :\n    @Primrec _ \u03c3 _ _ fun a => List.recOn (f a) (g a) fun b l IH => h a (b, l, IH) :=\n  let F (a : \u03b1) := (f a).foldr (fun (b : \u03b2) (s : List \u03b2 \u00d7 \u03c3) => (b :: s.1, h a (b, s))) ([], g a)\n  have : Primrec F :=\n    list_foldr hf (pair (const []) hg) <|\n      to\u2082 <| 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\u2082 (@List.get? \u03b1) :=\n  let F (l : List \u03b1) (n : \u2115) :=\n    l.foldl\n      (fun (s : Sum \u2115 \u03b1) (a : \u03b1) =>\n        Sum.casesOn s (@Nat.casesOn (Sum \u2115 \u03b1) (Sum.inr a) Sum.inl) Sum.inr)\n      (Sum.inl n)\n  have hF : Primrec\u2082 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\u2082).to\u2082\n              (sum_inr.comp snd).to\u2082).comp\n          snd).to\u2082\n  have :\n    @Primrec _ (Option \u03b1) _ _ fun p : List \u03b1 \u00d7 \u2115 => Sum.casesOn (F p.1 p.2) (fun _ => none) some :=\n    sum_cases hF (const none).to\u2082 (option_some.comp snd).to\u2082\n  this.to\u2082.of_eq fun l n => by\n    dsimp; symm\n    induction' l with a l IH generalizing n; \u00b7 rfl\n    cases' n with n\n    \u00b7 rw [(_ : F (a :: l) 0 = Sum.inr a)]\n      \u00b7 rfl\n      clear IH\n      dsimp [F]\n      induction' l with b l IH <;> simp [*]\n    \u00b7 apply IH\n#align primrec.list_nth Primrec.list_get?\n-/\n\n#print Primrec.list_getD /-\ntheorem list_getD (d : \u03b1) : Primrec\u2082 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\u2082 list_nth (const _)\n#align primrec.list_nthd Primrec.list_getD\n-/\n\n#print Primrec.list_getI /-\ntheorem list_getI [Inhabited \u03b1] : Primrec\u2082 (@List.getI \u03b1 _) :=\n  list_getD _\n#align primrec.list_inth Primrec.list_getI\n-/\n\n#print Primrec.list_append /-\ntheorem list_append : Primrec\u2082 ((\u00b7 ++ \u00b7) : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1) :=\n  (list_foldr fst snd <| to\u2082 <| comp (@list_cons \u03b1 _) snd).to\u2082.of_eq fun l\u2081 l\u2082 => by\n    induction l\u2081 <;> simp [*]\n#align primrec.list_append Primrec.list_append\n-/\n\n#print Primrec.list_concat /-\ntheorem list_concat : Primrec\u2082 fun l (a : \u03b1) => 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03c3 : Type.{u3}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] [_inst_4 : Primcodable.{u3} \u03c3] {f : \u03b1 -> (List.{u2} \u03b2)} {g : \u03b1 -> \u03b2 -> \u03c3}, (Primrec.{u1, u2} \u03b1 (List.{u2} \u03b2) _inst_1 (Primcodable.list.{u2} \u03b2 _inst_2) f) -> (Primrec\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_4 g) -> (Primrec.{u1, u3} \u03b1 (List.{u3} \u03c3) _inst_1 (Primcodable.list.{u3} \u03c3 _inst_4) (fun (a : \u03b1) => List.map.{u2, u3} \u03b2 \u03c3 (g a) (f a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_2 : Primcodable.{u3} \u03b2] [_inst_4 : Primcodable.{u1} \u03c3] {f : \u03b1 -> (List.{u3} \u03b2)} {g : \u03b1 -> \u03b2 -> \u03c3}, (Primrec.{u2, u3} \u03b1 (List.{u3} \u03b2) _inst_1 (Primcodable.list.{u3} \u03b2 _inst_2) f) -> (Primrec\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03c3 _inst_1 _inst_2 _inst_4 g) -> (Primrec.{u2, u1} \u03b1 (List.{u1} \u03c3) _inst_1 (Primcodable.list.{u1} \u03c3 _inst_4) (fun (a : \u03b1) => List.map.{u3, u1} \u03b2 \u03c3 (g a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_map Primrec.list_map\u2093'. -/\ntheorem list_map {f : \u03b1 \u2192 List \u03b2} {g : \u03b1 \u2192 \u03b2 \u2192 \u03c3} (hf : Primrec f) (hg : Primrec\u2082 g) :\n    Primrec fun a => (f a).map (g a) :=\n  (list_foldr hf (const []) <|\n        to\u2082 <| 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\u2082).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 \u03b1) :=\n  (list_foldr Primrec.id (const []) <| to\u2082 <| comp (@list_append \u03b1 _) 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 \u03b1) :=\n  (list_foldr (@Primrec.id (List \u03b1) _) (const 0) <| to\u2082 <| (succ.comp <| snd.comp snd).to\u2082).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] {f : \u03b1 -> (List.{u2} \u03b2)} {p : \u03b1 -> \u03b2 -> Prop} [_inst_5 : forall (a : \u03b1) (b : \u03b2), Decidable (p a b)], (Primrec.{u1, u2} \u03b1 (List.{u2} \u03b2) _inst_1 (Primcodable.list.{u2} \u03b2 _inst_2) f) -> (PrimrecRel.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 p (fun (a : \u03b1) (b : \u03b2) => _inst_5 a b)) -> (Primrec.{u1, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : \u03b1) => List.findIndex.{u2} \u03b2 (p a) (fun (a_1 : \u03b2) => _inst_5 a a_1) (f a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_2 : Primcodable.{u2} \u03b2] {f : \u03b1 -> (List.{u2} \u03b2)} {p : \u03b1 -> \u03b2 -> Bool}, (Primrec.{u1, u2} \u03b1 (List.{u2} \u03b2) _inst_1 (Primcodable.list.{u2} \u03b2 _inst_2) f) -> (Primrec\u2082.{u1, u2, 0} \u03b1 \u03b2 Bool _inst_1 _inst_2 Primcodable.bool p) -> (Primrec.{u1, 0} \u03b1 Nat _inst_1 (Primcodable.ofDenumerable.{0} Nat Denumerable.nat) (fun (a : \u03b1) => List.findIdx.{u2} \u03b2 (p a) (f a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_find_index Primrec.list_findIdx\u2093'. -/\ntheorem list_findIdx {f : \u03b1 \u2192 List \u03b2} {p : \u03b1 \u2192 \u03b2 \u2192 Prop} [\u2200 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\u2082 <| 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 \u03b1] : Primrec\u2082 (@List.indexOf \u03b1 _) :=\n  to\u2082 <| list_findIdx snd <| Primrec.eq.comp\u2082 (fst.comp fst).to\u2082 snd.to\u2082\n#align primrec.list_index_of Primrec.list_indexOf\u2093\n\n#print Primrec.nat_strong_rec /-\ntheorem nat_strong_rec (f : \u03b1 \u2192 \u2115 \u2192 \u03c3) {g : \u03b1 \u2192 List \u03c3 \u2192 Option \u03c3} (hg : Primrec\u2082 g)\n    (H : \u2200 a n, g a ((List.range n).map (f a)) = some (f a n)) : Primrec\u2082 f :=\n  suffices Primrec\u2082 fun a n => (List.range n).map (f a) from\n    Primrec\u2082.option_some_iff.1 <|\n      (list_get?.comp (this.comp fst (succ.comp snd)) snd).to\u2082.of_eq fun a n => by\n        simp [List.get?_range (Nat.lt_succ_self n)] <;> rfl\n  Primrec\u2082.option_some_iff.1 <|\n    (nat_elim (const (some []))\n          (to\u2082 <|\n            option_bind (snd.comp snd) <|\n              to\u2082 <|\n                option_map (hg.comp (fst.comp fst) snd)\n                  (to\u2082 <| list_concat.comp (snd.comp fst) snd))).of_eq\n      fun a n => by\n      simp; induction' n with n IH; \u00b7 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 {\u03b1 : Type _} {\u03b2 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2]\n\nopen Primrec\n\n#print Primcodable.subtype /-\n/-- A subtype of a primitive recursive predicate is `primcodable`. -/\ndef subtype {p : \u03b1 \u2192 Prop} [DecidablePred p] (hp : PrimrecPred p) : Primcodable (Subtype p) :=\n  \u27e8have : Primrec fun n => (decode \u03b1 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 \u03b1 n).bind fun a => _)\n          by\n          cases' decode \u03b1 n with a; \u00b7 rfl\n          dsimp [Option.guard]\n          by_cases h : p a <;> simp [h] <;> rfl\u27e9\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 \u03b1 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 \u2192 \u03b1) :=\n  ofEquiv _ (Equiv.vectorEquivFin _ _).symm\n#align primcodable.fin_arrow Primcodable.finArrow\n-/\n\ninstance array {n} : Primcodable (Array' n \u03b1) :=\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 \u03b1) :=\n  have : PrimrecPred fun n => Encodable.decode\u2082 \u03b1 n \u2260 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\u2082_ne_none_iff\n#align primcodable.ulower Primcodable.ulower\n-/\n\nend Ulower\n\nend Primcodable\n\nnamespace Primrec\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _} {\u03c3 : Type _}\n\nvariable [Primcodable \u03b1] [Primcodable \u03b2] [Primcodable \u03b3] [Primcodable \u03c3]\n\n#print Primrec.subtype_val /-\ntheorem subtype_val {p : \u03b1 \u2192 Prop} [DecidablePred p] {hp : PrimrecPred p} :\n    haveI := Primcodable.subtype hp\n    Primrec (@Subtype.val \u03b1 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 (_ | \u27e8a, h\u27e9) <;> rfl\n#align primrec.subtype_val Primrec.subtype_val\n-/\n\n#print Primrec.subtype_val_iff /-\ntheorem subtype_val_iff {p : \u03b2 \u2192 Prop} [DecidablePred p] {hp : PrimrecPred p} {f : \u03b1 \u2192 Subtype p} :\n    haveI := Primcodable.subtype hp\n    (Primrec fun a => (f a).1) \u2194 Primrec f :=\n  by\n  letI := Primcodable.subtype hp\n  refine' \u27e8fun h => _, fun hf => subtype_val.comp hf\u27e9\n  refine' Nat.Primrec.of_eq h fun n => _\n  cases' decode \u03b1 n with a; \u00b7 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 : \u03b2 \u2192 Prop} [DecidablePred p] {hp : PrimrecPred p} {f : \u03b1 \u2192 \u03b2}\n    {h : \u2200 a, p (f a)} (hf : Primrec f) :\n    haveI := Primcodable.subtype hp\n    Primrec fun a => @Subtype.mk \u03b2 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 : \u03b1 \u2192 Option \u03b2} {h : \u2200 a, (f a).isSome} :\n    Primrec f \u2192 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 \u03b1 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 : \u03b1 \u2192 Ulower \u03b1) :=\n  letI : \u2200 a, Decidable (a \u2208 Set.range (encode : \u03b1 \u2192 \u2115)) := 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 \u03b1 \u2192 \u03b1) :=\n  letI : \u2200 a, Decidable (a \u2208 Set.range (encode : \u03b1 \u2192 \u2115)) := decidable_range_encode _\n  option_get (primrec.decode\u2082.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 : \u03b1 \u2192 Fin n} : (Primrec fun a => (f a).1) \u2194 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 \u2192 \u2115) :=\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 \u03b1 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 : \u03b1 \u2192 Vector \u03b2 n} : (Primrec fun a => (f a).toList) \u2194 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\u2082 (@Vector.cons \u03b1 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 \u03b1 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 \u03b1 n) :=\n  option_some_iff.1 <| (list_head?.comp vector_toList).of_eq fun \u27e8a :: l, h\u27e9 => rfl\n#align primrec.vector_head Primrec.vector_head\n-/\n\n#print Primrec.vector_tail /-\ntheorem vector_tail {n} : Primrec (@Vector.tail \u03b1 n) :=\n  vector_toList_iff.1 <| (list_tail.comp vector_toList).of_eq fun \u27e8l, h\u27e9 => by cases l <;> rfl\n#align primrec.vector_tail Primrec.vector_tail\n-/\n\n#print Primrec.vector_get /-\ntheorem vector_get {n} : Primrec\u2082 (@Vector.get \u03b1 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 [\u2190 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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_4 : Primcodable.{u2} \u03c3] {n : Nat} {f : (Fin n) -> \u03b1 -> \u03c3}, (forall (i : Fin n), Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 (f i)) -> (Primrec.{u1, u2} \u03b1 (List.{u2} \u03c3) _inst_1 (Primcodable.list.{u2} \u03c3 _inst_4) (fun (a : \u03b1) => List.ofFn.{u2} \u03c3 n (fun (i : Fin n) => f i a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_4 : Primcodable.{u1} \u03c3] {n : Nat} {f : (Fin n) -> \u03b1 -> \u03c3}, (forall (i : Fin n), Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_4 (f i)) -> (Primrec.{u2, u1} \u03b1 (List.{u1} \u03c3) _inst_1 (Primcodable.list.{u1} \u03c3 _inst_4) (fun (a : \u03b1) => List.ofFn.{u1} \u03c3 n (fun (i : Fin n) => f i a)))\nCase conversion may be inaccurate. Consider using '#align primrec.list_of_fn Primrec.list_ofFn\u2093'. -/\ntheorem list_ofFn :\n    \u2200 {n} {f : Fin n \u2192 \u03b1 \u2192 \u03c3}, (\u2200 i, Primrec (f i)) \u2192 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 {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_4 : Primcodable.{u2} \u03c3] {n : Nat} {f : (Fin n) -> \u03b1 -> \u03c3}, (forall (i : Fin n), Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 (f i)) -> (Primrec.{u1, u2} \u03b1 (Vector.{u2} \u03c3 n) _inst_1 (Primcodable.vector.{u2} \u03c3 _inst_4 n) (fun (a : \u03b1) => Vector.ofFn.{u2} \u03c3 n (fun (i : Fin n) => f i a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_4 : Primcodable.{u1} \u03c3] {n : Nat} {f : (Fin n) -> \u03b1 -> \u03c3}, (forall (i : Fin n), Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_4 (f i)) -> (Primrec.{u2, u1} \u03b1 (Vector.{u1} \u03c3 n) _inst_1 (Primcodable.vector.{u1} \u03c3 _inst_4 n) (fun (a : \u03b1) => Vector.ofFn.{u1} \u03c3 n (fun (i : Fin n) => f i a)))\nCase conversion may be inaccurate. Consider using '#align primrec.vector_of_fn Primrec.vector_ofFn\u2093'. -/\ntheorem vector_ofFn {n} {f : Fin n \u2192 \u03b1 \u2192 \u03c3} (hf : \u2200 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 \u03b1 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 \u03b1 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\u2082 (@id (Fin n \u2192 \u03c3)) :=\n  (vector_get.comp (vector_of_fn'.comp fst) snd).of_eq fun \u27e8v, i\u27e9 => by simp\n#align primrec.fin_app Primrec.fin_app\n-/\n\n/- warning: primrec.fin_curry\u2081 -> Primrec.fin_curry\u2081 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_4 : Primcodable.{u2} \u03c3] {n : Nat} {f : (Fin n) -> \u03b1 -> \u03c3}, Iff (Primrec\u2082.{0, u1, u2} (Fin n) \u03b1 \u03c3 (Primcodable.fin n) _inst_1 _inst_4 f) (forall (i : Fin n), Primrec.{u1, u2} \u03b1 \u03c3 _inst_1 _inst_4 (f i))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_4 : Primcodable.{u1} \u03c3] {n : Nat} {f : (Fin n) -> \u03b1 -> \u03c3}, Iff (Primrec\u2082.{0, u2, u1} (Fin n) \u03b1 \u03c3 (Primcodable.fin n) _inst_1 _inst_4 f) (forall (i : Fin n), Primrec.{u2, u1} \u03b1 \u03c3 _inst_1 _inst_4 (f i))\nCase conversion may be inaccurate. Consider using '#align primrec.fin_curry\u2081 Primrec.fin_curry\u2081\u2093'. -/\ntheorem fin_curry\u2081 {n} {f : Fin n \u2192 \u03b1 \u2192 \u03c3} : Primrec\u2082 f \u2194 \u2200 i, Primrec (f i) :=\n  \u27e8fun 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\u27e9\n#align primrec.fin_curry\u2081 Primrec.fin_curry\u2081\n\n/- warning: primrec.fin_curry -> Primrec.fin_curry is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03c3 : Type.{u2}} [_inst_1 : Primcodable.{u1} \u03b1] [_inst_4 : Primcodable.{u2} \u03c3] {n : Nat} {f : \u03b1 -> (Fin n) -> \u03c3}, Iff (Primrec.{u1, u2} \u03b1 ((Fin n) -> \u03c3) _inst_1 (Primcodable.finArrow.{u2} \u03c3 _inst_4 n) f) (Primrec\u2082.{u1, 0, u2} \u03b1 (Fin n) \u03c3 _inst_1 (Primcodable.fin n) _inst_4 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c3 : Type.{u1}} [_inst_1 : Primcodable.{u2} \u03b1] [_inst_4 : Primcodable.{u1} \u03c3] {n : Nat} {f : \u03b1 -> (Fin n) -> \u03c3}, Iff (Primrec.{u2, u1} \u03b1 ((Fin n) -> \u03c3) _inst_1 (Primcodable.finArrow.{u1} \u03c3 _inst_4 n) f) (Primrec\u2082.{u2, 0, u1} \u03b1 (Fin n) \u03c3 _inst_1 (Primcodable.fin n) _inst_4 f)\nCase conversion may be inaccurate. Consider using '#align primrec.fin_curry Primrec.fin_curry\u2093'. -/\ntheorem fin_curry {n} {f : \u03b1 \u2192 Fin n \u2192 \u03c3} : Primrec f \u2194 Primrec\u2082 f :=\n  \u27e8fun 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\u27e9\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 \u2115, and so has to\n  work with n-ary functions on \u2115 instead of unary functions.\n  We prove that this is equivalent to the regular notion\n  in `to_prim` and `of_prim`. -/\ninductive Primrec' : \u2200 {n}, (Vector \u2115 n \u2192 \u2115) \u2192 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 \u2192 Vector \u2115 m \u2192 \u2115) :\n    primrec' f \u2192 (\u2200 i, primrec' (g i)) \u2192 primrec' fun a => f (ofFn fun i => g i a)\n  |\n  prec {n f g} :\n    @primrec' n f \u2192\n      @primrec' (n + 2) g \u2192\n        primrec' fun v : Vector \u2115 (n + 1) =>\n          v.headI.elim (f v.tail) fun y IH => g (y ::\u1d65 IH ::\u1d65 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\u2082\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 \u2115 n \u2192 \u2115} (hf : Primrec' f) (H : \u2200 i, f i = g i) : Primrec' g :=\n  (funext H : f = g) \u25b8 hf\n#align nat.primrec'.of_eq Nat.Primrec'.of_eq\n-/\n\n#print Nat.Primrec'.const /-\ntheorem const {n} : \u2200 m, @Primrec' n fun v => m\n  | 0 => zero.comp Fin.elim0 fun i => i.elim0\u2093\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 : \u2115} : @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 [\u2190 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 \u2115 n \u2192 Vector \u2115 m) : Prop :=\n  \u2200 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\u2093\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 ::\u1d65 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\u2081 /-\ntheorem comp\u2081 (f : \u2115 \u2192 \u2115) (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\u2081 Nat.Primrec'.comp\u2081\n-/\n\n#print Nat.Primrec'.comp\u2082 /-\ntheorem comp\u2082 (f : \u2115 \u2192 \u2115 \u2192 \u2115) (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\u2082 Nat.Primrec'.comp\u2082\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 : \u2115 => h (y ::\u1d65 IH ::\u1d65 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\u2081 _ (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\u2082 (fun a b => b - a) this (tail head) head\n  refine' (prec head (pred.comp\u2081 _ (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\u2082 _ (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\u2093'. -/\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\u2082 _ hb ha) hg (tail <| tail hf)).of_eq fun v =>\n    by\n    cases e : b v - a v\n    \u00b7 simp [not_lt.2 (tsub_eq_zero_iff_le.mp e)]\n    \u00b7 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\u2082 _ (tail <| mul.comp\u2082 _ head head) head)\n    (add.comp\u2082 _ (add.comp\u2082 _ (mul.comp\u2082 _ head head) head) (tail head))\n#align nat.primrec'.mkpair Nat.Primrec'.natPair\n-/\n\n#print Nat.Primrec'.encode /-\nprotected theorem encode : \u2200 {n}, @Primrec' n encode\n  | 0 => (const 0).of_eq fun v => by rw [v.eq_nil] <;> rfl\n  | n + 1 => (succ.comp\u2081 _ (natPair.comp\u2082 _ head (tail encode))).of_eq fun \u27e8a :: l, e\u27e9 => 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 : \u2200 n : \u2115, n.sqrt = n.elim 0 fun x y => if x.succ < y.succ * y.succ then y else y.succ\n  \u00b7 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    \u00b7 convert this\n      funext\n      congr\n      funext x y\n      congr <;> simp\n    have x1 := succ.comp\u2081 _ head\n    have y1 := succ.comp\u2081 _ (tail head)\n    exact if_lt x1 (mul.comp\u2082 _ y1 y1) (tail head) y1\n  intro ; symm\n  induction' n with n IH; \u00b7 simp\n  dsimp; rw [IH]; split_ifs\n  \u00b7 exact le_antisymm (Nat.sqrt_le_sqrt (Nat.le_succ _)) (Nat.lt_succ_iff.1 <| Nat.sqrt_lt.2 h)\n  \u00b7\n    exact\n      Nat.eq_sqrt.2 \u27e8not_lt.1 h, Nat.sqrt_lt.1 <| Nat.lt_succ_iff.2 <| Nat.sqrt_succ_le_succ_sqrt _\u27e9\n#align nat.primrec'.sqrt Nat.Primrec'.sqrt\n-/\n\n#print Nat.Primrec'.unpair\u2081 /-\ntheorem unpair\u2081 {n f} (hf : @Primrec' n f) : @Primrec' n fun v => (f v).unpair.1 :=\n  by\n  have s := sqrt.comp\u2081 _ hf\n  have fss := sub.comp\u2082 _ hf (mul.comp\u2082 _ 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\u2081 Nat.Primrec'.unpair\u2081\n-/\n\n#print Nat.Primrec'.unpair\u2082 /-\ntheorem unpair\u2082 {n f} (hf : @Primrec' n f) : @Primrec' n fun v => (f v).unpair.2 :=\n  by\n  have s := sqrt.comp\u2081 _ hf\n  have fss := sub.comp\u2082 _ hf (mul.comp\u2082 _ s s)\n  refine' (if_lt fss s s (sub.comp\u2082 _ fss s)).of_eq fun v => _\n  simp [Nat.unpair]; split_ifs <;> rfl\n#align nat.primrec'.unpair\u2082 Nat.Primrec'.unpair\u2082\n-/\n\n#print Nat.Primrec'.of_prim /-\ntheorem of_prim : \u2200 {n f}, Primrec f \u2192 @Primrec' n f :=\n  suffices \u2200 f, Nat.Primrec f \u2192 @Primrec' 1 fun v => f v.headI from fun n f hf =>\n    (pred.comp\u2081 _ <|\n          (this _ hf).comp\u2081 (fun m => Encodable.encode <| (decode (Vector \u2115 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\u2081 head\n  case right => exact unpair\u2082 head\n  case pair f g _ _ hf hg => exact mkpair.comp\u2082 _ hf hg\n  case comp f g _ _ hf hg => exact hf.comp\u2081 _ hg\n  case prec f g _ _ hf hg =>\n    simpa using\n      prec' (unpair\u2082 head) (hf.comp\u2081 _ (unpair\u2081 head))\n        (hg.comp\u2081 _ <|\n          mkpair.comp\u2082 _ (unpair\u2081 <| tail <| tail head) (mkpair.comp\u2082 _ 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 \u2194 Primrec f :=\n  \u27e8to_prim, of_prim\u27e9\n#align nat.primrec'.prim_iff Nat.Primrec'.prim_iff\n-/\n\n#print Nat.Primrec'.prim_iff\u2081 /-\ntheorem prim_iff\u2081 {f : \u2115 \u2192 \u2115} : (@Primrec' 1 fun v => f v.headI) \u2194 Primrec f :=\n  prim_iff.trans\n    \u27e8fun h => (h.comp <| vector_ofFn fun i => Primrec.id).of_eq fun v => by simp, fun h =>\n      h.comp vector_head\u27e9\n#align nat.primrec'.prim_iff\u2081 Nat.Primrec'.prim_iff\u2081\n-/\n\n#print Nat.Primrec'.prim_iff\u2082 /-\ntheorem prim_iff\u2082 {f : \u2115 \u2192 \u2115 \u2192 \u2115} : (@Primrec' 2 fun v => f v.headI v.tail.headI) \u2194 Primrec\u2082 f :=\n  prim_iff.trans\n    \u27e8fun 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)\u27e9\n#align nat.primrec'.prim_iff\u2082 Nat.Primrec'.prim_iff\u2082\n-/\n\n#print Nat.Primrec'.vec_iff /-\ntheorem vec_iff {m n f} : @Vec m n f \u2194 Primrec f :=\n  \u27e8fun 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)\u27e9\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\u2081.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": "/-\nCopyright (c) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n\nnotation, basic datatypes and type classes\n-/\nprelude\n\nuniverses u v w\n\n@[inline] def id {\u03b1 : Sort u} (a : \u03b1) : \u03b1 := a\n\nabbrev Function.comp {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b4 : Sort w} (f : \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b4 :=\n  fun x => f (g x)\n\nabbrev Function.const {\u03b1 : Sort u} (\u03b2 : Sort v) (a : \u03b1) : \u03b2 \u2192 \u03b1 :=\n  fun x => a\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\ninductive PUnit : Sort u\n  | unit : PUnit\n\n/-- An abbreviation for `PUnit.{0}`, its most common instantiation.\n    This Type should be preferred over `PUnit` where possible to avoid\n    unnecessary universe parameters. -/\nabbrev Unit : Type := PUnit\n\n@[matchPattern] abbrev Unit.unit : Unit := PUnit.unit\n\n/-- Auxiliary unsafe constant used by the Compiler when erasing proofs from code. -/\nunsafe axiom lcProof {\u03b1 : Prop} : \u03b1\n\n/-- Auxiliary unsafe constant used by the Compiler to mark unreachable code. -/\nunsafe axiom lcUnreachable {\u03b1 : Sort u} : \u03b1\n\ninductive True : Prop\n  | intro : True\n\ninductive False : Prop\n\ninductive Empty : Type\n\ndef Not (a : Prop) : Prop := a \u2192 False\n\n@[macroInline] def False.elim {C : Sort u} (h : False) : C :=\n  False.rec (fun _ => C) h\n\n@[macroInline] def absurd {a : Prop} {b : Sort v} (h\u2081 : a) (h\u2082 : Not a) : b :=\n  False.elim (h\u2082 h\u2081)\n\ninductive Eq {\u03b1 : Sort u} (a : \u03b1) : \u03b1 \u2192 Prop\n  | refl {} : Eq a a\n\nabbrev Eq.ndrec.{u1, u2} {\u03b1 : Sort u2} {a : \u03b1} {motive : \u03b1 \u2192 Sort u1} (m : motive a) {b : \u03b1} (h : Eq a b) : motive b :=\n  Eq.rec (motive := fun \u03b1 _ => motive \u03b1) m h\n\n@[matchPattern] def rfl {\u03b1 : Sort u} {a : \u03b1} : Eq a a := Eq.refl a\n\ntheorem Eq.subst {\u03b1 : Sort u} {motive : \u03b1 \u2192 Prop} {a b : \u03b1} (h\u2081 : Eq a b) (h\u2082 : motive a) : motive b :=\n  Eq.ndrec h\u2082 h\u2081\n\ntheorem Eq.symm {\u03b1 : Sort u} {a b : \u03b1} (h : a = b) : b = a :=\n  h \u25b8 rfl\n\n@[macroInline] def cast {\u03b1 \u03b2 : Sort u} (h : \u03b1 = \u03b2) (a : \u03b1) : \u03b2 :=\n  Eq.rec (motive := fun \u03b1 _ => \u03b1) a h\n\ntheorem congrArg {\u03b1 : Sort u} {\u03b2 : Sort v} {a\u2081 a\u2082 : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : Eq a\u2081 a\u2082) : Eq (f a\u2081) (f a\u2082) :=\n  h \u25b8 rfl\n\n/-\nInitialize the Quotient Module, which effectively adds the following definitions:\n\nconstant Quot {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Sort u\n\nconstant Quot.mk {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : Quot r\n\nconstant Quot.lift {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) :\n  (\u2200 a b : \u03b1, r a b \u2192 Eq (f a) (f b)) \u2192 Quot r \u2192 \u03b2\n\nconstant Quot.ind {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Quot r \u2192 Prop} :\n  (\u2200 a : \u03b1, \u03b2 (Quot.mk r a)) \u2192 \u2200 q : Quot r, \u03b2 q\n-/\ninit_quot\n\ninductive HEq {\u03b1 : Sort u} (a : \u03b1) : {\u03b2 : Sort u} \u2192 \u03b2 \u2192 Prop\n  | refl {} : HEq a a\n\n@[matchPattern] def HEq.rfl {\u03b1 : Sort u} {a : \u03b1} : a \u2245 a :=\n  HEq.refl a\n\ntheorem eqOfHEq {\u03b1 : Sort u} {a a' : \u03b1} (h : HEq a a') : Eq a a' :=\n  have (\u03b1 \u03b2 : Sort u) \u2192 (a : \u03b1) \u2192 (b : \u03b2) \u2192 HEq a b \u2192 (h : Eq \u03b1 \u03b2) \u2192 Eq (cast h a) b from\n    fun \u03b1 \u03b2 a b h\u2081 =>\n      HEq.rec (motive := fun {\u03b2} (b : \u03b2) (h : HEq a b) => (h\u2082 : Eq \u03b1 \u03b2) \u2192 Eq (cast h\u2082 a) b)\n        (fun (h\u2082 : Eq \u03b1 \u03b1) => rfl)\n        h\u2081\n  this \u03b1 \u03b1 a a' h rfl\n\nstructure Prod (\u03b1 : Type u) (\u03b2 : Type v) :=\n  (fst : \u03b1) (snd : \u03b2)\n\nattribute [unbox] Prod\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` can be propositions.\n   We use this Type internally to automatically generate the brecOn recursor. -/\nstructure PProd (\u03b1 : Sort u) (\u03b2 : Sort v) :=\n  (fst : \u03b1) (snd : \u03b2)\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` are in the same universe. -/\nstructure MProd (\u03b1 \u03b2 : Type u) :=\n  (fst : \u03b1) (snd : \u03b2)\n\nstructure And (a b : Prop) : Prop :=\n  intro :: (left : a) (right : b)\n\ninductive Or (a b : Prop) : Prop\n  | inl (h : a) : Or a b\n  | inr (h : b) : Or a b\n\ninductive Bool : Type\n  | false : Bool\n  | true : Bool\n\nexport Bool (false true)\n\n/- Remark: Subtype must take a Sort instead of Type because of the axiom strongIndefiniteDescription. -/\nstructure Subtype {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) :=\n  (val : \u03b1) (property : p val)\n\n/-- Gadget for optional parameter support. -/\n@[reducible] def optParam (\u03b1 : Sort u) (default : \u03b1) : Sort u := \u03b1\n\n/-- Gadget for marking output parameters in type classes. -/\n@[reducible] def outParam (\u03b1 : Sort u) : Sort u := \u03b1\n\n/-- Auxiliary Declaration used to implement the notation (a : \u03b1) -/\n@[reducible] def typedExpr (\u03b1 : Sort u) (a : \u03b1) : \u03b1 := a\n\n/-- Auxiliary Declaration used to implement the named patterns `x@p` -/\n@[reducible] def namedPattern {\u03b1 : Sort u} (x a : \u03b1) : \u03b1 := a\n\n/- Auxiliary axiom used to implement `sorry`. -/\naxiom sorryAx (\u03b1 : Sort u) (synthetic := true) : \u03b1\n\ntheorem eqFalseOfNeTrue : {b : Bool} \u2192 Not (Eq b true) \u2192 b = false\n  | true, h => False.elim (h rfl)\n  | false, h => rfl\n\ntheorem eqTrueOfNeFalse : {b : Bool} \u2192 Not (Eq b false) \u2192 b = true\n  | true, h => rfl\n  | false, h => False.elim (h rfl)\n\ntheorem neFalseOfEqTrue : {b : Bool} \u2192 Eq b true \u2192 Not (Eq b false)\n  | true, _  => fun h => Bool.noConfusion h\n  | false, h => Bool.noConfusion h\n\ntheorem neTrueOfEqFalse : {b : Bool} \u2192 Eq b false \u2192 Not (Eq b true)\n  | true, h  => Bool.noConfusion h\n  | false, _ => fun h => Bool.noConfusion h\n\nclass Inhabited (\u03b1 : Sort u) :=\n  mk {} :: (default : \u03b1)\n\nconstant arbitrary (\u03b1 : Sort u) [s : Inhabited \u03b1] : \u03b1 :=\n  @Inhabited.default \u03b1 s\n\ninstance (\u03b1 : Sort u) {\u03b2 : Sort v} [Inhabited \u03b2] : Inhabited (\u03b1 \u2192 \u03b2) := {\n  default := fun _ => arbitrary \u03b2\n}\n\ninstance (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(a : \u03b1) \u2192 Inhabited (\u03b2 a)] : Inhabited ((a : \u03b1) \u2192 \u03b2 a) := {\n  default := fun a => arbitrary (\u03b2 a)\n}\n\n/-- Universe lifting operation from Sort to Type -/\nstructure PLift (\u03b1 : Sort u) : Type u :=\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and PLift \u03b1 -/\ntheorem PLift.upDown {\u03b1 : Sort u} : \u2200 (b : PLift \u03b1), up (down b) = b\n  | up a => rfl\n\ntheorem PLift.downUp {\u03b1 : Sort u} (a : \u03b1) : down (up a) = a :=\n  rfl\n\n/- Pointed types -/\nstructure PointedType :=\n  (type : Type u)\n  (val : type)\n\ninstance : Inhabited PointedType.{u} := {\n  default := { type := PUnit.{u+1}, val := \u27e8\u27e9 }\n}\n\n/-- Universe lifting operation -/\nstructure ULift.{r, s} (\u03b1 : Type s) : Type (max s r) :=\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and ULift.{v} \u03b1 -/\ntheorem ULift.upDown {\u03b1 : Type u} : \u2200 (b : ULift.{v} \u03b1), up (down b) = b\n  | up a => rfl\n\ntheorem ULift.downUp {\u03b1 : Type u} (a : \u03b1) : down (up.{v} a) = a :=\n  rfl\n\nclass inductive Decidable (p : Prop)\n  | isFalse (h : Not p) : Decidable p\n  | isTrue  (h : p) : Decidable p\n\n@[inlineIfReduce, nospecialize] def Decidable.decide (p : Prop) [h : Decidable p] : Bool :=\n  Decidable.casesOn (motive := fun _ => Bool) h (fun _ => false) (fun _ => true)\n\nexport Decidable (isTrue isFalse decide)\n\nabbrev DecidablePred {\u03b1 : Sort u} (r : \u03b1 \u2192 Prop) :=\n  (a : \u03b1) \u2192 Decidable (r a)\n\nabbrev DecidableRel {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :=\n  (a b : \u03b1) \u2192 Decidable (r a b)\n\nabbrev DecidableEq (\u03b1 : Sort u) :=\n  (a b : \u03b1) \u2192 Decidable (Eq a b)\n\ndef decEq {\u03b1 : Sort u} [s : DecidableEq \u03b1] (a b : \u03b1) : Decidable (Eq a b) :=\n  s a b\n\ntheorem decideEqTrue : {p : Prop} \u2192 [s : Decidable p] \u2192 p \u2192 Eq (decide p) true\n  | _, isTrue  _, _   => rfl\n  | _, isFalse h\u2081, h\u2082 => absurd h\u2082 h\u2081\n\ntheorem decideEqFalse : {p : Prop} \u2192 [s : Decidable p] \u2192 Not p \u2192 Eq (decide p) false\n  | _, isTrue  h\u2081, h\u2082 => absurd h\u2081 h\u2082\n  | _, isFalse h, _   => rfl\n\ntheorem ofDecideEqTrue {p : Prop} [s : Decidable p] : Eq (decide p) true \u2192 p := fun h =>\n  match s with\n  | isTrue  h\u2081 => h\u2081\n  | isFalse h\u2081 => absurd h (neTrueOfEqFalse (decideEqFalse h\u2081))\n\ntheorem ofDecideEqFalse {p : Prop} [s : Decidable p] : Eq (decide p) false \u2192 Not p := fun h =>\n  match s with\n  | isTrue  h\u2081 => absurd h (neFalseOfEqTrue (decideEqTrue h\u2081))\n  | isFalse h\u2081 => h\u2081\n\n@[inline] instance : DecidableEq Bool :=\n  fun a b => match a, b with\n   | false, false => isTrue rfl\n   | false, true  => isFalse (fun h => Bool.noConfusion h)\n   | true, false  => isFalse (fun h => Bool.noConfusion h)\n   | true, true   => isTrue rfl\n\nclass BEq      (\u03b1 : Type u) := (beq : \u03b1 \u2192 \u03b1 \u2192 Bool)\n\nopen BEq (beq)\n\ninstance {\u03b1 : Type u} [DecidableEq \u03b1] : BEq \u03b1 :=\n  \u27e8fun a b => decide (Eq a b)\u27e9\n\n-- We use \"dependent\" if-then-else to be able to communicate the if-then-else condition\n-- to the branches\n@[macroInline] def dite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t : c \u2192 \u03b1) (e : Not c \u2192 \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h e t\n\n/- if-then-else -/\n\n@[macroInline] def ite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t e : \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h (fun _ => e) (fun _ => t)\n\n@[macroInline] instance {p q} [Decidable p] [Decidable q] : Decidable (And p q) :=\n  if hp : p then\n    if hq : q then\n      isTrue \u27e8hp, hq\u27e9\n    else\n      isFalse (fun h => hq (And.right h))\n  else\n    isFalse (fun h => hp (And.left h))\n\n@[macroInline] instance {p q} [Decidable p] [Decidable q] : Decidable (Or p q) :=\n  if hp : p then\n    isTrue (Or.inl hp)\n  else if hq : q then\n    isTrue (Or.inr hq)\n  else\n    isFalse fun h => match h with\n      | Or.inl h => hp h\n      | Or.inr h => hq h\n\ninstance {p} [Decidable p] : Decidable (Not p) :=\n  if hp : p then isFalse (absurd hp) else isTrue hp\n\n/- Boolean operators -/\n\n@[macroInline] def cond {a : Type u} : Bool \u2192 a \u2192 a \u2192 a\n  | true,  x, y => x\n  | false, x, y => y\n\n@[macroInline] def or : Bool \u2192 Bool \u2192 Bool\n  | true,  _ => true\n  | false, b => b\n\n@[macroInline] def and : Bool \u2192 Bool \u2192 Bool\n  | false, _ => false\n  | true,  b => b\n\n@[macroInline] def not : Bool \u2192 Bool\n  | true  => false\n  | false => true\n\ninductive Nat\n  | zero : Nat\n  | succ (n : Nat) : Nat\n\n/- For numeric literals notation -/\nclass OfNat (\u03b1 : Type u) :=\n  (ofNat : Nat \u2192 \u03b1)\n\nexport OfNat (ofNat)\n\ninstance : OfNat Nat := \u27e8id\u27e9\n\ninstance : Inhabited Nat := {\n  default := 0\n}\n\nclass HasLessEq (\u03b1 : Type u) := (LessEq : \u03b1 \u2192 \u03b1 \u2192 Prop)\nclass HasLess   (\u03b1 : Type u) := (Less : \u03b1 \u2192 \u03b1 \u2192 Prop)\n\nexport HasLess (Less)\nexport HasLessEq (LessEq)\n\nclass Add     (\u03b1 : Type u) := (add : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\nclass Mul     (\u03b1 : Type u) := (mul : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\nclass Neg     (\u03b1 : Type u) := (neg : \u03b1 \u2192 \u03b1)\nclass Sub     (\u03b1 : Type u) := (sub : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\nclass Div     (\u03b1 : Type u) := (div : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\nclass Mod     (\u03b1 : Type u) := (mod : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\nclass ModN    (\u03b1 : Type u) := (modn : \u03b1 \u2192 Nat \u2192 \u03b1)\nclass Pow     (\u03b1 : Type u) (\u03b2 : Type v) := (pow : \u03b1 \u2192 \u03b2 \u2192 \u03b1)\nclass Append  (\u03b1 : Type u) := (append : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\nclass OrElse  (\u03b1 : Type u) := (orElse  : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\nclass AndThen (\u03b1 : Type u) := (andThen : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n\nopen Add (add)\nopen Mul (mul)\nopen Pow (pow)\nopen Append (append)\n\n@[reducible] def GreaterEq {\u03b1 : Type u} [HasLessEq \u03b1] (a b : \u03b1) : Prop := LessEq b a\n@[reducible] def Greater {\u03b1 : Type u} [HasLess \u03b1] (a b : \u03b1) : Prop     := Less b a\n\nset_option bootstrap.gen_matcher_code false in\n@[extern \"lean_nat_add\"]\nprotected def Nat.add : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, Nat.zero   => a\n  | a, Nat.succ b => Nat.succ (Nat.add a b)\n\ninstance : Add Nat := {\n  add := Nat.add\n}\n\nset_option bootstrap.gen_matcher_code false in\n@[extern \"lean_nat_mul\"]\nprotected def Nat.mul : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0          => 0\n  | a, Nat.succ b => Nat.add (Nat.mul a b) a\n\ninstance : Mul Nat := {\n  mul := Nat.mul\n}\n\nset_option bootstrap.gen_matcher_code false in\n@[extern \"lean_nat_pow\"]\nprotected def Nat.pow (m : @& Nat) : (@& Nat) \u2192 Nat\n  | 0      => 1\n  | succ n => Nat.mul (Nat.pow m n) m\n\ninstance : Pow Nat Nat := {\n  pow := Nat.pow\n}\n\nset_option bootstrap.gen_matcher_code false in\n@[extern \"lean_nat_dec_eq\"]\ndef Nat.beq : Nat \u2192 Nat \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => false\n  | succ n, zero   => false\n  | succ n, succ m => beq n m\n\ntheorem Nat.eqOfBeqEqTt : {n m : Nat} \u2192 Eq (beq n m) true \u2192 Eq n m\n  | zero,   zero,   h => rfl\n  | zero,   succ m, h => Bool.noConfusion h\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have Eq (beq n m) true from h\n    have Eq n m from eqOfBeqEqTt this\n    this \u25b8 rfl\n\ntheorem Nat.neOfBeqEqFf : {n m : Nat} \u2192 Eq (beq n m) false \u2192 Not (Eq n m)\n  | zero,   zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | zero,   succ m, h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, zero,   h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have beq n m = false from h\u2081\n    Nat.noConfusion h\u2082 (fun h\u2082 => absurd h\u2082 (neOfBeqEqFf this))\n\n@[extern \"lean_nat_dec_eq\"]\nprotected def Nat.decEq (n m : @& Nat) : Decidable (n = m) :=\n  if h : beq n m = true then isTrue (eqOfBeqEqTt h)\n  else isFalse (neOfBeqEqFf (eqFalseOfNeTrue h))\n\n@[inline] instance : DecidableEq Nat := Nat.decEq\n\nset_option bootstrap.gen_matcher_code false in\n@[extern \"lean_nat_dec_le\"]\ndef Nat.ble : Nat \u2192 Nat \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => true\n  | succ n, zero   => false\n  | succ n, succ m => ble n m\n\nprotected def Nat.le (n m : Nat) : Prop :=\n  ble n m = true\n\ninstance : HasLessEq Nat := \u27e8Nat.le\u27e9\n\nprotected def Nat.lt (n m : Nat) : Prop :=\n  Nat.le (succ n) m\n\ninstance : HasLess Nat := \u27e8Nat.lt\u27e9\n\ntheorem Nat.notSuccLeZero : \u2200 (n : Nat), LessEq (succ n) 0 \u2192 False\n  | 0,      h => nomatch h\n  | succ n, h => nomatch h\n\ntheorem Nat.notLtZero (n : Nat) : Not (Less n 0) :=\n  notSuccLeZero n\n\n@[extern \"lean_nat_dec_le\"]\ninstance Nat.decLe (n m : @& Nat) : Decidable (LessEq n m) :=\n  decEq (Nat.ble n m) true\n\n@[extern \"lean_nat_dec_lt\"]\ninstance Nat.decLt (n m : @& Nat) : Decidable (Less n m) :=\n  decLe (succ n) m\n\ntheorem Nat.zeroLe : (n : Nat) \u2192 LessEq 0 n\n  | zero   => rfl\n  | succ n => rfl\n\ntheorem Nat.succLeSucc {n m : Nat} (h : LessEq n m) : LessEq (succ n) (succ m) :=\n  h\n\ntheorem Nat.zeroLtSucc (n : Nat) : Less 0 (succ n) :=\n  succLeSucc (zeroLe n)\n\ntheorem Nat.leStep : {n m : Nat} \u2192 LessEq n m \u2192 LessEq n (succ m)\n  | zero,   zero,   h => rfl\n  | zero,   succ n, h => rfl\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have LessEq n m from h\n    have LessEq n (succ m) from leStep this\n    succLeSucc this\n\nprotected theorem Nat.leTrans : {n m k : Nat} \u2192 LessEq n m \u2192 LessEq m k \u2192 LessEq n k\n  | zero,   m,      k,      h\u2081, h\u2082 => zeroLe _\n  | succ n, zero,   k,      h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | succ n, succ m, zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2082\n  | succ n, succ m, succ k, h\u2081, h\u2082 =>\n    have h\u2081' : LessEq n m from h\u2081\n    have h\u2082' : LessEq m k from h\u2082\n    Nat.leTrans h\u2081' h\u2082'\n\nprotected theorem Nat.ltTrans {n m k : Nat} (h\u2081 : Less n m) : Less m k \u2192 Less n k :=\n  Nat.leTrans (leStep h\u2081)\n\ntheorem Nat.leSucc : (n : Nat) \u2192 LessEq n (succ n)\n  | zero   => rfl\n  | succ n => leSucc n\n\ntheorem Nat.leSuccOfLe {n m : Nat} (h : LessEq n m) : LessEq n (succ m) :=\n  Nat.leTrans h (leSucc m)\n\nprotected theorem Nat.eqOrLtOfLe : {n m: Nat} \u2192 LessEq n m \u2192 Or (Eq n m) (Less n m)\n  | zero,   zero,   h => Or.inl rfl\n  | zero,   succ n, h => Or.inr (zeroLe n)\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have LessEq n m from h\n    match Nat.eqOrLtOfLe this with\n    | Or.inl h => Or.inl (h \u25b8 rfl)\n    | Or.inr h => Or.inr (succLeSucc h)\n\nprotected def Nat.leRefl : (n : Nat) \u2192 LessEq n n\n  | zero   => rfl\n  | succ n => Nat.leRefl n\n\nprotected theorem Nat.ltOrGe (n m : Nat) : Or (Less n m) (GreaterEq n m) :=\n  match m with\n  | zero   => Or.inr (zeroLe n)\n  | succ m =>\n    match Nat.ltOrGe n m with\n    | Or.inl h => Or.inl (leSuccOfLe h)\n    | Or.inr h =>\n      match Nat.eqOrLtOfLe h with\n      | Or.inl h1 => Or.inl (h1 \u25b8 Nat.leRefl _)\n      | Or.inr h1 => Or.inr h1\n\nprotected theorem Nat.leAntisymm : {n m : Nat} \u2192 LessEq n m \u2192 LessEq m n \u2192 Eq n m\n  | zero,   zero,   h\u2081, h\u2082 => rfl\n  | succ n, zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | zero,   succ m, h\u2081, h\u2082 => Bool.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have h\u2081' : LessEq n m from h\u2081\n    have h\u2082' : LessEq m n from h\u2082\n    (Nat.leAntisymm h\u2081' h\u2082') \u25b8 rfl\n\nprotected theorem Nat.ltOfLeOfNe {n m : Nat} (h\u2081 : LessEq n m) (h\u2082 : Not (Eq n m)) : Less n m :=\n  match Nat.ltOrGe n m with\n  | Or.inl h\u2083 => h\u2083\n  | Or.inr h\u2083 => absurd (Nat.leAntisymm h\u2081 h\u2083) h\u2082\n\nset_option bootstrap.gen_matcher_code false in\n@[extern c inline \"lean_nat_sub(#1, lean_box(1))\"]\ndef Nat.pred : Nat \u2192 Nat\n  | 0      => 0\n  | succ a => a\n\ntheorem Nat.predLePred : {n m : Nat} \u2192 LessEq n m \u2192 LessEq (pred n) (pred m)\n  | zero,   zero,   h => rfl\n  | zero,   succ n, h => zeroLe n\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h => h\n\ntheorem Nat.leOfSuccLeSucc {n m : Nat} : LessEq (succ n) (succ m) \u2192 LessEq n m :=\n  predLePred\n\ntheorem Nat.leOfLtSucc {m n : Nat} : Less m (succ n) \u2192 LessEq m n :=\n  leOfSuccLeSucc\n\n@[extern \"lean_system_platform_nbits\"] constant System.Platform.getNumBits : Unit \u2192 { n : Nat // Or (Eq n 32) (Eq n 64) } :=\n  fun _ => \u27e864, Or.inr rfl\u27e9 -- inhabitant\n\ndef System.Platform.numBits : Nat :=\n  (getNumBits ()).val\n\ntheorem System.Platform.numBitsEq : Or (Eq numBits 32) (Eq numBits 64) :=\n  (getNumBits ()).property\n\nstructure Fin (n : Nat) :=\n  (val  : Nat)\n  (isLt : Less val n)\n\ntheorem Fin.eqOfVeq {n} : \u2200 {i j : Fin n}, Eq i.val j.val \u2192 Eq i j\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Fin.veqOfEq {n} {i j : Fin n} (h : Eq i j) : i.val = j.val :=\n  h \u25b8 rfl\n\ntheorem Fin.neOfVne {n} {i j : Fin n} (h : Not (Eq i.val j.val)) : Not (Eq i j) :=\n  fun h' => absurd (veqOfEq h') h\n\ninstance (n : Nat) : DecidableEq (Fin n) :=\n  fun i j =>\n    match decEq i.val j.val with\n    | isTrue h  => isTrue (Fin.eqOfVeq h)\n    | isFalse h => isFalse (Fin.neOfVne h)\n\ndef uint8Sz : Nat := 256\nstructure UInt8 :=\n  (val : Fin uint8Sz)\n\nset_option bootstrap.gen_matcher_code false in\n@[extern c inline \"#1 == #2\"]\ndef UInt8.decEq (a b : UInt8) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => if h : Eq n m then isTrue (h \u25b8 rfl) else isFalse (fun h' => UInt8.noConfusion h' (fun h' => absurd h' h))\n\ninstance : DecidableEq UInt8 := UInt8.decEq\n\ninstance : Inhabited UInt8 := {\n  default := { val := { val := 0, isLt := decide! } }\n}\n\ndef uint16Sz : Nat := 65536\nstructure UInt16 :=\n  (val : Fin uint16Sz)\n\nset_option bootstrap.gen_matcher_code false in\n@[extern c inline \"#1 == #2\"]\ndef UInt16.decEq (a b : UInt16) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => if h : Eq n m then isTrue (h \u25b8 rfl) else isFalse (fun h' => UInt16.noConfusion h' (fun h' => absurd h' h))\n\ninstance : DecidableEq UInt16 := UInt16.decEq\n\ninstance : Inhabited UInt16 := {\n  default := { val := { val := 0, isLt := decide! } }\n}\n\ndef uint32Sz : Nat := 4294967296\nstructure UInt32 :=\n  (val : Fin uint32Sz)\n\nset_option bootstrap.gen_matcher_code false in\n@[extern c inline \"#1 == #2\"]\ndef UInt32.decEq (a b : UInt32) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => if h : Eq n m then isTrue (h \u25b8 rfl) else isFalse (fun h' => UInt32.noConfusion h' (fun h' => absurd h' h))\n\ninstance : DecidableEq UInt32 := UInt32.decEq\n\ninstance : Inhabited UInt32 := {\n  default := { val := { val := 0, isLt := decide! } }\n}\n\ndef uint64Sz : Nat := 18446744073709551616\nstructure UInt64 :=\n  (val : Fin uint64Sz)\n\nset_option bootstrap.gen_matcher_code false in\n@[extern c inline \"#1 == #2\"]\ndef UInt64.decEq (a b : UInt64) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => if h : Eq n m then isTrue (h \u25b8 rfl) else isFalse (fun h' => UInt64.noConfusion h' (fun h' => absurd h' h))\n\ninstance : DecidableEq UInt64 := UInt64.decEq\n\ninstance : Inhabited UInt64 := {\n  default := { val := { val := 0, isLt := decide! } }\n}\n\ndef usizeSz : Nat := pow 2 System.Platform.numBits\n\ntheorem usizeSzEq : Or (Eq usizeSz 4294967296) (Eq usizeSz 18446744073709551616) :=\n  show Or (Eq (pow 2 System.Platform.numBits) 4294967296) (Eq (pow 2 System.Platform.numBits) 18446744073709551616) from\n  match System.Platform.numBits, System.Platform.numBitsEq with\n  | _, Or.inl rfl => Or.inl (decide! : (Eq (pow 2 32) (4294967296:Nat)))\n  | _, Or.inr rfl => Or.inr (decide! : (Eq (pow 2 64) (18446744073709551616:Nat)))\n\nstructure USize :=\n  (val : Fin usizeSz)\n\nset_option bootstrap.gen_matcher_code false in\n@[extern c inline \"#1 == #2\"]\ndef USize.decEq (a b : USize) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => if h : Eq n m then isTrue (h \u25b8 rfl) else isFalse (fun h' => USize.noConfusion h' (fun h' => absurd h' h))\n\ninstance : DecidableEq USize := USize.decEq\n\ninstance : Inhabited USize := {\n  default := { val := { val := 0, isLt := match usizeSz, usizeSzEq with | _, Or.inl rfl => decide! | _, Or.inr rfl => decide! } }\n}\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNat32 (n : @& Nat) (h : Less n 4294967296) : USize := {\n  val := {\n    val  := n,\n    isLt := match usizeSz, usizeSzEq with\n      | _, Or.inl rfl => h\n      | _, Or.inr rfl => Nat.ltTrans h (decide! : Less 4294967296 18446744073709551616)\n  }\n}\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNatCore (n : @& Nat) (h : Less n usizeSz) : USize := {\n  val := { val := n, isLt := h }\n}\n\nabbrev Nat.isValidChar (n : Nat) : Prop :=\n  Or (Less n 0xd800) (And (Less 0xdfff n) (Less n 0x110000))\n\nabbrev UInt32.isValidChar (n : UInt32) : Prop :=\n  n.val.val.isValidChar\n\n/-- The `Char` Type represents an unicode scalar value.\n    See http://www.unicode.org/glossary/#unicode_scalar_value). -/\nstructure Char :=\n  (val   : UInt32)\n  (valid : val.isValidChar)\n\nprivate theorem validCharIsUInt32 {n : Nat} (h : n.isValidChar) : Less n uint32Sz :=\n  match h with\n  | Or.inl h      => Nat.ltTrans h (decide! : Less 55296 uint32Sz)\n  | Or.inr \u27e8_, h\u27e9 => Nat.ltTrans h (decide! : Less 1114112 uint32Sz)\n\nabbrev Char.ofNat (n : Nat) : Char :=\n  if h : n.isValidChar then\n    { val := \u27e8{ val := n, isLt := validCharIsUInt32 h }\u27e9, valid := h }\n  else\n    { val := \u27e8{ val := 0, isLt := decide! }\u27e9, valid := Or.inl decide! }\n\ntheorem Char.eqOfVeq : \u2200 {c d : Char}, Eq c.val d.val \u2192 Eq c d\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Char.veqOfEq : \u2200 {c d : Char}, Eq c d \u2192 Eq c.val d.val\n  | _, _, rfl => rfl\n\ntheorem Char.neOfVne {c d : Char} (h : Not (Eq c.val d.val)) : Not (Eq c d) :=\n  fun h' => absurd (veqOfEq h') h\n\ntheorem Char.vneOfNe {c d : Char} (h : Not (Eq c d)) : Not (Eq c.val d.val) :=\n  fun h' => absurd (eqOfVeq h') h\n\ninstance : DecidableEq Char :=\n  fun c d =>\n    match decEq c.val d.val with\n    | isTrue h  => isTrue (Char.eqOfVeq h)\n    | isFalse h => isFalse (Char.neOfVne h)\n\ninductive Option (\u03b1 : Type u)\n  | none : Option \u03b1\n  | some (val : \u03b1) : Option \u03b1\n\nattribute [unbox] Option\n\nexport Option (none some)\n\ninstance {\u03b1} : Inhabited (Option \u03b1) := {\n  default := none\n}\n\ninductive List (\u03b1 : Type u)\n  | nil : List \u03b1\n  | cons (head : \u03b1) (tail : List \u03b1) : List \u03b1\n\ninstance {\u03b1} : Inhabited (List \u03b1) := {\n  default := List.nil\n}\n\nprotected def List.hasDecEq {\u03b1: Type u} [DecidableEq \u03b1] : (a b : List \u03b1) \u2192 Decidable (Eq a b)\n  | nil,       nil       => isTrue rfl\n  | cons a as, nil       => isFalse (fun h => List.noConfusion h)\n  | nil,       cons b bs => isFalse (fun h => List.noConfusion h)\n  | cons a as, cons b bs =>\n    match decEq a b with\n    | isTrue hab  =>\n      match List.hasDecEq as bs with\n      | isTrue habs  => isTrue (hab \u25b8 habs \u25b8 rfl)\n      | isFalse nabs => isFalse (fun h => List.noConfusion h (fun _ habs => absurd habs nabs))\n    | isFalse nab => isFalse (fun h => List.noConfusion h (fun hab _ => absurd hab nab))\n\ninstance {\u03b1 : Type u} [DecidableEq \u03b1] : DecidableEq (List \u03b1) := List.hasDecEq\n\n@[specialize]\ndef List.foldl {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) : (init : \u03b1) \u2192 List \u03b2 \u2192 \u03b1\n  | a, nil      => a\n  | a, cons b l => foldl f (f a b) l\n\nstructure String :=\n  (data : List Char)\n\nattribute [extern \"lean_string_mk\"] String.mk\nattribute [extern \"lean_string_data\"] String.data\n\n@[extern \"lean_string_dec_eq\"]\ndef String.decEq (s\u2081 s\u2082 : @& String) : Decidable (s\u2081 = s\u2082) :=\n  match s\u2081, s\u2082 with\n  | \u27e8s\u2081\u27e9, \u27e8s\u2082\u27e9 =>\n   if h : s\u2081 = s\u2082 then isTrue (congrArg _ h)\n   else isFalse (fun h' => String.noConfusion h' (fun h' => absurd h' h))\n\ninstance : DecidableEq String := String.decEq\n\n/-- A byte position in a `String`. Internally, `String`s are UTF-8 encoded.\nCodepoint positions (counting the Unicode codepoints rather than bytes)\nare represented by plain `Nat`s instead.\nIndexing a `String` by a byte position is constant-time, while codepoint\npositions need to be translated internally to byte positions in linear-time. -/\nabbrev String.Pos := Nat\n\nstructure Substring :=\n  (str : String)\n  (startPos : String.Pos)\n  (stopPos : String.Pos)\n\n@[extern c inline \"#3\"]\nunsafe def unsafeCast {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) : \u03b2 :=\n  cast lcProof (PUnit.{v})\n\n@[neverExtract, extern \"lean_panic_fn\"]\nconstant panic {\u03b1 : Type u} [Inhabited \u03b1] (msg : String) : \u03b1\n\n/-\nThe Compiler has special support for arrays.\nThey are implemented using dynamic arrays: https://en.wikipedia.org/wiki/Dynamic_array\n-/\nstructure Array (\u03b1 : Type u) :=\n  (sz   : Nat)\n  (data : Fin sz \u2192 \u03b1)\n\nattribute [extern \"lean_array_mk\"] Array.mk\nattribute [extern \"lean_array_data\"] Array.data\nattribute [extern \"lean_array_sz\"] Array.sz\n\n/- The parameter `c` is the initial capacity -/\n@[extern \"lean_mk_empty_array_with_capacity\"]\ndef Array.mkEmpty {\u03b1 : Type u} (c : @& Nat) : Array \u03b1 := {\n  sz   := 0,\n  data := fun \u27e8x, h\u27e9 => absurd h (Nat.notLtZero x)\n}\n\ndef Array.empty {\u03b1 : Type u} : Array \u03b1 :=\n  mkEmpty 0\n\n@[reducible, extern \"lean_array_get_size\"]\ndef Array.size {\u03b1 : Type u} (a : @& Array \u03b1) : Nat :=\n  a.sz\n\n@[extern \"lean_array_fget\"]\ndef Array.get {\u03b1 : Type u} (a : @& Array \u03b1) (i : @& Fin a.size) : \u03b1 :=\n  a.data i\n\n/- \"Comfortable\" version of `fget`. It performs a bound check at runtime. -/\n@[extern \"lean_array_get\"]\ndef Array.get! {\u03b1 : Type u} [Inhabited \u03b1] (a : @& Array \u03b1) (i : @& Nat) : \u03b1 :=\n  if h : Less i a.size then a.get \u27e8i, h\u27e9 else arbitrary \u03b1\n\n@[extern \"lean_array_push\"]\ndef push {\u03b1 : Type u} (a : Array \u03b1) (v : \u03b1) : Array \u03b1 := {\n  sz   := Nat.succ a.sz,\n  data := fun \u27e8j, h\u2081\u27e9 =>\n    if h\u2082 : j = a.sz then\n      v\n    else\n      a.data \u27e8j, Nat.ltOfLeOfNe (Nat.leOfLtSucc h\u2081) h\u2082\u27e9\n}\n\nclass Bind (m : Type u \u2192 Type v) :=\n  (bind : {\u03b1 \u03b2 : Type u} \u2192 m \u03b1 \u2192 (\u03b1 \u2192 m \u03b2) \u2192 m \u03b2)\n\nexport Bind (bind)\n\nclass Pure (f : Type u \u2192 Type v) :=\n  (pure {\u03b1 : Type u} : \u03b1 \u2192 f \u03b1)\n\nexport Pure (pure)\n\nclass Functor (f : Type u \u2192 Type v) : Type (max (u+1) v) :=\n  (map      : {\u03b1 \u03b2 : Type u} \u2192 (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2)\n  (mapConst : {\u03b1 \u03b2 : Type u} \u2192 \u03b1 \u2192 f \u03b2 \u2192 f \u03b1 := Function.comp map (Function.const _))\n\nclass Seq (f : Type u \u2192 Type v) : Type (max (u+1) v) :=\n  (seq  : {\u03b1 \u03b2 : Type u} \u2192 f (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2)\n\nclass SeqLeft (f : Type u \u2192 Type v) : Type (max (u+1) v) :=\n  (seqLeft : {\u03b1 : Type u} \u2192 f \u03b1 \u2192 f PUnit \u2192 f \u03b1)\n\nclass SeqRight (f : Type u \u2192 Type v) : Type (max (u+1) v) :=\n  (seqRight : {\u03b2 : Type u} \u2192 f PUnit \u2192 f \u03b2 \u2192 f \u03b2)\n\nclass Applicative (f : Type u \u2192 Type v) extends Functor f, Pure f, Seq f, SeqLeft f, SeqRight f :=\n  (map      := fun x y => Seq.seq (pure x) y)\n  (seqLeft  := fun a b => Seq.seq (Functor.map (Function.const _) a) b)\n  (seqRight := fun a b => Seq.seq (Functor.map (Function.const _ id) a) b)\n\nclass Monad (m : Type u \u2192 Type v) extends Applicative m, Bind m : Type (max (u+1) v) :=\n  (map      := fun f x => bind x (Function.comp pure f))\n  (seq      := fun f x => bind f (fun y => Functor.map y x))\n  (seqLeft  := fun x y => bind x (fun a => bind y (fun _ => pure a)))\n  (seqRight := fun x y => bind x (fun _ => y))\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] : Inhabited (\u03b1 \u2192 m \u03b1) := \u27e8pure\u27e9\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] [Inhabited \u03b1] : Inhabited (m \u03b1) := \u27e8pure $ arbitrary _\u27e9\n\n/-- A Function for lifting a computation from an inner Monad to an outer Monad.\n    Like [MonadTrans](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Class.html),\n    but `n` does not have to be a monad transformer.\n    Alternatively, an implementation of [MonadLayer](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLayer) without `layerInvmap` (so far). -/\nclass MonadLift (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) :=\n  (monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1)\n\n/-- The reflexive-transitive closure of `MonadLift`.\n    `monadLift` is used to transitively lift monadic computations such as `StateT.get` or `StateT.put s`.\n    Corresponds to [MonadLift](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLift). -/\nclass MonadLiftT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) :=\n  (monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1)\n\nexport MonadLiftT (monadLift)\n\nabbrev liftM := @monadLift\n\ninstance (m n o) [MonadLiftT m n] [MonadLift n o] : MonadLiftT m o := {\n  monadLift := fun x => MonadLift.monadLift (m := n) (monadLift x)\n}\n\ninstance (m) : MonadLiftT m m := {\n  monadLift := fun x => x\n}\n\n/-- A functor in the category of monads. Can be used to lift monad-transforming functions.\n    Based on pipes' [MFunctor](https://hackage.haskell.org/package/pipes-2.4.0/docs/Control-MFunctor.html),\n    but not restricted to monad transformers.\n    Alternatively, an implementation of [MonadTransFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadTransFunctor). -/\nclass MonadFunctor (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) :=\n  (monadMap {\u03b1 : Type u} : (\u2200 {\u03b2}, m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1)\n\n/-- The reflexive-transitive closure of `MonadFunctor`.\n    `monadMap` is used to transitively lift Monad morphisms -/\nclass MonadFunctorT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) :=\n  (monadMap {\u03b1 : Type u} : (\u2200 {\u03b2}, m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1)\n\nexport MonadFunctorT (monadMap)\n\ninstance (m n o) [MonadFunctorT m n] [MonadFunctor n o] : MonadFunctorT m o := {\n  monadMap := fun f => MonadFunctor.monadMap (m := n) (monadMap (m := m) f)\n}\n\ninstance monadFunctorRefl (m) : MonadFunctorT m m := {\n  monadMap := fun f => f\n}\n\ninductive Except (\u03b5 : Type u) (\u03b1 : Type v)\n  | error : \u03b5 \u2192 Except \u03b5 \u03b1\n  | ok    : \u03b1 \u2192 Except \u03b5 \u03b1\n\nattribute [unbox] Except\n\ninstance {\u03b5 : Type u} {\u03b1 : Type v} [Inhabited \u03b5] : Inhabited (Except \u03b5 \u03b1) :=\n  \u27e8Except.error (arbitrary \u03b5)\u27e9\n\n/-- An implementation of [MonadError](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Except.html#t:MonadError) -/\nclass MonadExceptOf (\u03b5 : Type u) (m : Type v \u2192 Type w) :=\n  (throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1)\n  (tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1)\n\nabbrev throwThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (e : \u03b5) : m \u03b1 :=\n  MonadExceptOf.throw e\n\nabbrev tryCatchThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (x : m \u03b1) (handle : \u03b5 \u2192 m \u03b1) : m \u03b1 :=\n  MonadExceptOf.tryCatch x handle\n\n/-- Similar to `MonadExceptOf`, but `\u03b5` is an outParam for convenience -/\nclass MonadExcept (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) :=\n  (throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1)\n  (tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1)\n\nexport MonadExcept (throw tryCatch)\n\ninstance (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) [MonadExceptOf \u03b5 m] : MonadExcept \u03b5 m := {\n  throw    := throwThe \u03b5,\n  tryCatch := tryCatchThe \u03b5\n}\n\nnamespace MonadExcept\nvariables {\u03b5 : Type u} {m : Type v \u2192 Type w}\n\n@[inline] protected def orelse [MonadExcept \u03b5 m] {\u03b1 : Type v} (t\u2081 t\u2082 : m \u03b1) : m \u03b1 :=\n  tryCatch t\u2081 fun _ => t\u2082\n\ninstance [MonadExcept \u03b5 m] {\u03b1 : Type v} : OrElse (m \u03b1) := \u27e8MonadExcept.orelse\u27e9\n\nend MonadExcept\n\n/-- An implementation of [ReaderT](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Reader.html#t:ReaderT) -/\ndef ReaderT (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) : Type (max u v) :=\n  \u03c1 \u2192 m \u03b1\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) [Inhabited (m \u03b1)] : Inhabited (ReaderT \u03c1 m \u03b1) :=\n  \u27e8fun _ => arbitrary _\u27e9\n\n@[inline] def ReaderT.run {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u} (x : ReaderT \u03c1 m \u03b1) (r : \u03c1) : m \u03b1 :=\n  x r\n\n@[reducible] def Reader (\u03c1 : Type u) := ReaderT \u03c1 id\n\nnamespace ReaderT\n\nsection\nvariables {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u}\n\n@[inline] protected def lift  (a : m \u03b1) : ReaderT \u03c1 m \u03b1 :=\n  fun r => a\n\ninstance  : MonadLift m (ReaderT \u03c1 m) := \u27e8ReaderT.lift\u27e9\n\ninstance (\u03b5) [MonadExceptOf \u03b5 m] : MonadExceptOf \u03b5 (ReaderT \u03c1 m) := {\n  throw    := Function.comp ReaderT.lift (throwThe \u03b5),\n  tryCatch := fun x c r => tryCatchThe \u03b5 (x r) (fun e => (c e) r)\n}\n\nend\n\nsection\nvariables {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] {\u03b1 \u03b2 : Type u}\n\n@[inline] protected def read : ReaderT \u03c1 m \u03c1 :=\n  pure\n\n@[inline] protected def pure (a : \u03b1) : ReaderT \u03c1 m \u03b1 :=\n  fun r => pure a\n\n@[inline] protected def bind (x : ReaderT \u03c1 m \u03b1) (f : \u03b1 \u2192 ReaderT \u03c1 m \u03b2) : ReaderT \u03c1 m \u03b2 :=\n  fun r => bind (x r) fun a => f a r\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : ReaderT \u03c1 m \u03b1) : ReaderT \u03c1 m \u03b2 :=\n  fun r => Functor.map f (x r)\n\ninstance : Monad (ReaderT \u03c1 m) := {\n  pure := ReaderT.pure,\n  bind := ReaderT.bind,\n  map  := ReaderT.map\n}\n\ninstance (\u03c1 m) [Monad m] : MonadFunctor m (ReaderT \u03c1 m) := \u27e8fun f x r => f (x r)\u27e9\n\n@[inline] protected def adapt {\u03c1' : Type u} [Monad m] {\u03b1 : Type u} (f : \u03c1' \u2192 \u03c1) : ReaderT \u03c1 m \u03b1 \u2192 ReaderT \u03c1' m \u03b1 :=\n  fun x r => x (f r)\n\nend\nend ReaderT\n\n/-- An implementation of [MonadReader](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Reader-Class.html#t:MonadReader).\n    It does not contain `local` because this Function cannot be lifted using `monadLift`.\n    Instead, the `MonadReaderAdapter` class provides the more general `adaptReader` Function.\n\n    Note: This class can be seen as a simplification of the more \"principled\" definition\n    ```\n    class MonadReader (\u03c1 : outParam (Type u)) (n : Type u \u2192 Type u) :=\n    (lift {\u03b1 : Type u} : (\u2200 {m : Type u \u2192 Type u} [Monad m], ReaderT \u03c1 m \u03b1) \u2192 n \u03b1)\n    ```\n    -/\nclass MonadReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) :=\n  (read : m \u03c1)\n\n@[inline] def readThe (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadReaderOf \u03c1 m] : m \u03c1 :=\n  MonadReaderOf.read\n\n/-- Similar to `MonadReaderOf`, but `\u03c1` is an outParam for convenience -/\nclass MonadReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) :=\n  (read : m \u03c1)\n\nexport MonadReader (read)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadReaderOf \u03c1 m] : MonadReader \u03c1 m :=\n  \u27e8readThe \u03c1\u27e9\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadReaderOf \u03c1 m] [MonadLift m n] : MonadReaderOf \u03c1 n :=\n  \u27e8monadLift (MonadReader.read : m \u03c1)\u27e9\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadReaderOf \u03c1 (ReaderT \u03c1 m) :=\n  \u27e8ReaderT.read\u27e9\n\nclass MonadWithReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) :=\n  (withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1)\n\n@[inline] def withTheReader (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadWithReaderOf \u03c1 m] {\u03b1 : Type u} (f : \u03c1 \u2192 \u03c1) (x : m \u03b1) : m \u03b1 :=\n  MonadWithReaderOf.withReader f x\n\nclass MonadWithReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) :=\n  (withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1)\n\nexport MonadWithReader (withReader)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadWithReaderOf \u03c1 m] : MonadWithReader \u03c1 m := \u27e8withTheReader \u03c1\u27e9\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type v} [MonadWithReaderOf \u03c1 m] [MonadFunctor m n] : MonadWithReaderOf \u03c1 n :=\n  \u27e8fun f => monadMap (m := m) (withTheReader \u03c1 f)\u27e9\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadWithReaderOf \u03c1 (ReaderT \u03c1 m) :=\n  \u27e8fun f x ctx => x (f ctx)\u27e9\n\n/-- An implementation of [MonadState](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-State-Class.html).\n    In contrast to the Haskell implementation, we use overlapping instances to derive instances\n    automatically from `monadLift`. -/\nclass MonadStateOf (\u03c3 : Type u) (m : Type u \u2192 Type v) :=\n  /- Obtain the top-most State of a Monad stack. -/\n  (get : m \u03c3)\n  /- Set the top-most State of a Monad stack. -/\n  (set : \u03c3 \u2192 m PUnit)\n  /- Map the top-most State of a Monad stack.\n\n     Note: `modifyGet f` may be preferable to `do s <- get; let (a, s) := f s; put s; pure a`\n     because the latter does not use the State linearly (without sufficient inlining). -/\n  (modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 \u03b1 \u00d7 \u03c3) \u2192 m \u03b1)\n\nexport MonadStateOf (set)\n\nabbrev getThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] : m \u03c3 :=\n  MonadStateOf.get\n\n@[inline] abbrev modifyThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  MonadStateOf.modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] abbrev modifyGetThe {\u03b1 : Type u} (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 \u03b1 \u00d7 \u03c3) : m \u03b1 :=\n  MonadStateOf.modifyGet f\n\n/-- Similar to `MonadStateOf`, but `\u03c3` is an outParam for convenience -/\nclass MonadState (\u03c3 : outParam (Type u)) (m : Type u \u2192 Type v) :=\n  (get : m \u03c3)\n  (set : \u03c3 \u2192 m PUnit)\n  (modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 \u03b1 \u00d7 \u03c3) \u2192 m \u03b1)\n\nexport MonadState (get modifyGet)\n\ninstance (\u03c3 : Type u) (m : Type u \u2192 Type v) [MonadStateOf \u03c3 m] : MonadState \u03c3 m := {\n  set       := MonadStateOf.set,\n  get       := getThe \u03c3,\n  modifyGet := fun f => MonadStateOf.modifyGet f\n}\n\n@[inline] def modify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] def getModify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] [Monad m] (f : \u03c3 \u2192 \u03c3) : m \u03c3 :=\n  modifyGet fun s => (s, f s)\n\n-- NOTE: The Ordering of the following two instances determines that the top-most `StateT` Monad layer\n-- will be picked first\ninstance {\u03c3 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadStateOf \u03c3 m] [MonadLift m n] : MonadStateOf \u03c3 n := {\n  get       := liftM (m := m) MonadStateOf.get,\n  set       := fun s => liftM (m := m) (MonadStateOf.set s),\n  modifyGet := fun f => monadLift (m := m) (MonadState.modifyGet f)\n}\n\nnamespace EStateM\n\ninductive Result (\u03b5 \u03c3 \u03b1 : Type u)\n  | ok    : \u03b1 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n  | error : \u03b5 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nvariables {\u03b5 \u03c3 \u03b1 : Type u}\n\ninstance [Inhabited \u03b5] [Inhabited \u03c3] : Inhabited (Result \u03b5 \u03c3 \u03b1) := \u27e8Result.error (arbitrary _) (arbitrary _)\u27e9\n\nend EStateM\n\nopen EStateM (Result) in\ndef EStateM (\u03b5 \u03c3 \u03b1 : Type u) := \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nnamespace EStateM\n\nvariables {\u03b5 \u03c3 \u03b1 \u03b2 : Type u}\n\ninstance [Inhabited \u03b5] : Inhabited (EStateM \u03b5 \u03c3 \u03b1) := \u27e8fun s =>\n  Result.error (arbitrary \u03b5) s\u27e9\n\n@[inline] protected def pure (a : \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.ok a s\n\n@[inline] protected def set (s : \u03c3) : EStateM \u03b5 \u03c3 PUnit := fun _ =>\n  Result.ok \u27e8\u27e9 s\n\n@[inline] protected def get : EStateM \u03b5 \u03c3 \u03c3 := fun s =>\n  Result.ok s s\n\n@[inline] protected def modifyGet (f : \u03c3 \u2192 \u03b1 \u00d7 \u03c3) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  match f s with\n  | (a, s) => Result.ok a s\n\n@[inline] protected def throw (e : \u03b5) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.error e s\n\n/-- Auxiliary instance for saving/restoring the \"backtrackable\" part of the state. -/\nclass Backtrackable (\u03b4 : outParam (Type u)) (\u03c3 : Type u) :=\n  (save    : \u03c3 \u2192 \u03b4)\n  (restore : \u03c3 \u2192 \u03b4 \u2192 \u03c3)\n\n@[inline] protected def tryCatch {\u03b4} [Backtrackable \u03b4 \u03c3] {\u03b1} (x : EStateM \u03b5 \u03c3 \u03b1) (handle : \u03b5 \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s\n  match x s with\n  | Result.error e s => handle e (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] protected def orElse {\u03b4} [Backtrackable \u03b4 \u03c3] (x\u2081 x\u2082 : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s;\n  match x\u2081 s with\n  | Result.error _ s => x\u2082 (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] def adaptExcept {\u03b5' : Type u} (f : \u03b5 \u2192 \u03b5') (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5' \u03c3 \u03b1 := fun s =>\n  match x s with\n  | Result.error e s => Result.error (f e) s\n  | Result.ok a s    => Result.ok a s\n\n@[inline] protected def bind (x : EStateM \u03b5 \u03c3 \u03b1) (f : \u03b1 \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => f a s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => Result.ok (f a) s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def seqRight (x : EStateM \u03b5 \u03c3 PUnit) (y : EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok _ s    => y s\n  | Result.error e s => Result.error e s\n\ninstance : Monad (EStateM \u03b5 \u03c3) := {\n  bind     := EStateM.bind,\n  pure     := EStateM.pure,\n  map      := EStateM.map,\n  seqRight := EStateM.seqRight\n}\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : OrElse (EStateM \u03b5 \u03c3 \u03b1) := {\n  orElse := EStateM.orElse\n}\n\ninstance : MonadStateOf \u03c3 (EStateM \u03b5 \u03c3) := {\n  set       := EStateM.set,\n  get       := EStateM.get,\n  modifyGet := EStateM.modifyGet\n}\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : MonadExceptOf \u03b5 (EStateM \u03b5 \u03c3) := {\n  throw    := EStateM.throw,\n  tryCatch := EStateM.tryCatch\n}\n\n@[inline] def run (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Result \u03b5 \u03c3 \u03b1 :=\n  x s\n\n@[inline] def run' (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Option \u03b1 :=\n  match run x s with\n  | Result.ok v _    => some v\n  | Result.error _ _ => none\n\n@[inline] def dummySave : \u03c3 \u2192 PUnit := fun _ => \u27e8\u27e9\n\n@[inline] def dummyRestore : \u03c3 \u2192 PUnit \u2192 \u03c3 := fun s _ => s\n\n/- Dummy default instance -/\ninstance nonBacktrackable : Backtrackable PUnit \u03c3 := {\n  save    := dummySave,\n  restore := dummyRestore\n}\n\nend EStateM\n\nclass Hashable (\u03b1 : Type u) :=\n  (hash : \u03b1 \u2192 USize)\n\nexport Hashable (hash)\n\n@[extern \"lean_usize_mix_hash\"]\nconstant mixHash (u\u2081 u\u2082 : USize) : USize\n\n@[extern \"lean_string_hash\"]\nprotected constant String.hash (s : @& String) : USize\n\ninstance : Hashable String := \u27e8String.hash\u27e9\n\nnamespace Lean\n\n/- Hierarchical names -/\ninductive Name\n  | anonymous : Name\n  | str : Name \u2192 String \u2192 USize \u2192 Name\n  | num : Name \u2192 Nat \u2192 USize \u2192 Name\n\ninstance : Inhabited Name := \u27e8Name.anonymous\u27e9\n\nprotected def Name.hash : Name \u2192 USize\n  | Name.anonymous => USize.ofNat32 1723 decide!\n  | Name.str p s h => h\n  | Name.num p v h => h\n\ninstance : Hashable Name := \u27e8Name.hash\u27e9\n\n@[export lean_name_mk_string]\ndef mkNameStr (p : Name) (s : String) : Name :=\n  Name.str p s (mixHash (hash p) (hash s))\n\n@[export lean_name_mk_numeral]\ndef mkNameNum (p : Name) (v : Nat) : Name :=\n  Name.num p v (mixHash (hash p) (if h : Less v usizeSz then USize.ofNatCore v h else USize.ofNat32 17 decide!))\n\ndef mkNameSimple (s : String) : Name :=\n  mkNameStr Name.anonymous s\n\nnamespace Name\n@[extern \"lean_name_eq\"]\nprotected def beq : (@& Name) \u2192 (@& Name) \u2192 Bool\n  | anonymous,   anonymous   => true\n  | str p\u2081 s\u2081 _, str p\u2082 s\u2082 _ => BEq.beq s\u2081 s\u2082 && Name.beq p\u2081 p\u2082\n  | num p\u2081 n\u2081 _, num p\u2082 n\u2082 _ => BEq.beq n\u2081 n\u2082 && Name.beq p\u2081 p\u2082\n  | _,           _           => false\n\ninstance : BEq Name := \u27e8Name.beq\u27e9\n\nprotected def append : Name \u2192 Name \u2192 Name\n  | n, anonymous => n\n  | n, str p s _ => mkNameStr (Name.append n p) s\n  | n, num p d _ => mkNameNum (Name.append n p) d\n\ninstance : Append Name := \u27e8Name.append\u27e9\n\nend Name\n\n/- Syntax -/\n\n/--\n  Source information of syntax atoms. All information is generally set for unquoted syntax and unset for syntax in\n  syntax quotations, but syntax transformations might want to invalidate only one side to make the pretty printer\n  reformat it. In the special case of the delaborator, we also use purely synthetic position information without\n  whitespace information. -/\nstructure SourceInfo :=\n  /- Will be inferred after parsing by `Syntax.updateLeading`. During parsing,\n     it is not at all clear what the preceding token was, especially with backtracking. -/\n  (leading  : Option Substring  := none)\n  (pos      : Option String.Pos := none)\n  (trailing : Option Substring  := none)\n\ninstance : Inhabited SourceInfo := \u27e8{}\u27e9\n\nabbrev SyntaxNodeKind := Name\n\n/- Syntax AST -/\n\ninductive Syntax\n  | missing : Syntax\n  | node   (kind : SyntaxNodeKind) (args : Array Syntax) : Syntax\n  | atom   (info : SourceInfo) (val : String) : Syntax\n  | ident  (info : SourceInfo) (rawVal : Substring) (val : Name) (preresolved : List (Prod Name (List String))) : Syntax\n\ninstance : Inhabited Syntax := \u27e8Syntax.missing\u27e9\n\n/- Builtin kinds -/\ndef choiceKind : SyntaxNodeKind := `choice\ndef nullKind : SyntaxNodeKind := `null\ndef identKind : SyntaxNodeKind := `ident\ndef strLitKind : SyntaxNodeKind := `strLit\ndef charLitKind : SyntaxNodeKind := `charLit\ndef numLitKind : SyntaxNodeKind := `numLit\ndef nameLitKind : SyntaxNodeKind := `nameLit\ndef fieldIdxKind : SyntaxNodeKind := `fieldIdx\ndef interpolatedStrLitKind : SyntaxNodeKind := `interpolatedStrLitKind\ndef interpolatedStrKind : SyntaxNodeKind := `interpolatedStrKind\n\nnamespace Syntax\n\ndef getKind (stx : Syntax) : SyntaxNodeKind :=\n  match stx with\n  | Syntax.node k args   => k\n  -- We use these \"pseudo kinds\" for antiquotation kinds.\n  -- For example, an antiquotation `$id:ident` (using Lean.Parser.Term.ident)\n  -- is compiled to ``if stx.isOfKind `ident ...``\n  | Syntax.missing       => `missing\n  | Syntax.atom _ v      => mkNameSimple v\n  | Syntax.ident _ _ _ _ => identKind\n\ndef setKind (stx : Syntax) (k : SyntaxNodeKind) : Syntax :=\n  match stx with\n  | Syntax.node _ args => Syntax.node k args\n  | _                  => stx\n\ndef isOfKind (stx : Syntax) (k : SyntaxNodeKind) : Bool :=\n  beq stx.getKind k\n\ndef getArg (stx : Syntax) (i : Nat) : Syntax :=\n  match stx with\n  | Syntax.node _ args => args.get! i\n  | _                  => Syntax.missing -- panic! \"Syntax.getArg: not a node\"\n\n-- Add `stx[i]` as sugar for `stx.getArg i`\n@[inline] def getOp (self : Syntax) (idx : Nat) : Syntax :=\n  self.getArg idx\n\ndef getArgs (stx : Syntax) : Array Syntax :=\n  match stx with\n  | Syntax.node _ args => args\n  | _                  => Array.empty\n\nend Syntax\n\ninductive ParserDescr\n  | andthen           : ParserDescr \u2192 ParserDescr \u2192 ParserDescr\n  | orelse            : ParserDescr \u2192 ParserDescr \u2192 ParserDescr\n  | optional          : ParserDescr \u2192 ParserDescr\n  | lookahead         : ParserDescr \u2192 ParserDescr\n  | \u00abtry\u00bb             : ParserDescr \u2192 ParserDescr\n  | many              : ParserDescr \u2192 ParserDescr\n  | many1             : ParserDescr \u2192 ParserDescr\n  | sepBy             : ParserDescr \u2192 ParserDescr \u2192 Bool \u2192 ParserDescr\n  | sepBy1            : ParserDescr \u2192 ParserDescr \u2192 Bool \u2192 ParserDescr\n  | node              : Name \u2192 Nat \u2192 ParserDescr \u2192 ParserDescr\n  | trailingNode      : Name \u2192 Nat \u2192 ParserDescr \u2192 ParserDescr\n  | symbol            : String \u2192 ParserDescr\n  | nonReservedSymbol : String \u2192 Bool \u2192 ParserDescr\n  | noWs              : ParserDescr\n  | numLit            : ParserDescr\n  | strLit            : ParserDescr\n  | charLit           : ParserDescr\n  | nameLit           : ParserDescr\n  | interpolatedStr   : ParserDescr \u2192 ParserDescr -- interpolated string\n  | ident             : ParserDescr\n  | cat               : Name \u2192 Nat \u2192 ParserDescr\n  | parser            : Name \u2192 ParserDescr\n  | notFollowedBy     : ParserDescr \u2192 ParserDescr\n  | withPosition      : ParserDescr \u2192 ParserDescr\n  | checkCol          : Bool \u2192 ParserDescr\n\ninstance : Inhabited ParserDescr := \u27e8ParserDescr.symbol \"\"\u27e9\nabbrev TrailingParserDescr := ParserDescr\n\n/-\nRuntime support for making quotation terms auto-hygienic, by mangling identifiers\nintroduced by them with a \"macro scope\" supplied by the context. Details to appear in a\npaper soon.\n-/\n\nabbrev MacroScope := Nat\n/-- Macro scope used internally. It is not available for our frontend. -/\ndef reservedMacroScope := 0\n/-- First macro scope available for our frontend -/\ndef firstFrontendMacroScope := add reservedMacroScope 1\n\n/-- A monad that supports syntax quotations. Syntax quotations (in term\n    position) are monadic values that when executed retrieve the current \"macro\n    scope\" from the monad and apply it to every identifier they introduce\n    (independent of whether this identifier turns out to be a reference to an\n    existing declaration, or an actually fresh binding during further\n    elaboration). -/\nclass MonadQuotation (m : Type \u2192 Type) :=\n  -- Get the fresh scope of the current macro invocation\n  (getCurrMacroScope : m MacroScope)\n  (getMainModule     : m Name)\n  /- Execute action in a new macro invocation context. This transformer should be\n     used at all places that morally qualify as the beginning of a \"macro call\",\n     e.g. `elabCommand` and `elabTerm` in the case of the elaborator. However, it\n     can also be used internally inside a \"macro\" if identifiers introduced by\n     e.g. different recursive calls should be independent and not collide. While\n     returning an intermediate syntax tree that will recursively be expanded by\n     the elaborator can be used for the same effect, doing direct recursion inside\n     the macro guarded by this transformer is often easier because one is not\n     restricted to passing a single syntax tree. Modelling this helper as a\n     transformer and not just a monadic action ensures that the current macro\n     scope before the recursive call is restored after it, as expected. -/\n  (withFreshMacroScope {\u03b1 : Type} : m \u03b1 \u2192 m \u03b1)\n\nexport MonadQuotation (getCurrMacroScope getMainModule withFreshMacroScope)\n\ninstance {m n : Type \u2192 Type} [MonadQuotation m] [MonadLift m n] [MonadFunctorT m n] : MonadQuotation n := {\n  getCurrMacroScope   := liftM (m := m) getCurrMacroScope,\n  getMainModule       := liftM (m := m) getMainModule,\n  withFreshMacroScope := monadMap (m := m) withFreshMacroScope\n}\n\n/-\nWe represent a name with macro scopes as\n```\n<actual name>._@.(<module_name>.<scopes>)*.<module_name>._hyg.<scopes>\n```\nExample: suppose the module name is `Init.Data.List.Basic`, and name is `foo.bla`, and macroscopes [2, 5]\n```\nfoo.bla._@.Init.Data.List.Basic._hyg.2.5\n```\n\nWe may have to combine scopes from different files/modules.\nThe main modules being processed is always the right most one.\nThis situation may happen when we execute a macro generated in\nan imported file in the current file.\n```\nfoo.bla._@.Init.Data.List.Basic.2.1.Init.Lean.Expr_hyg.4\n```\n\nThe delimiter `_hyg` is used just to improve the `hasMacroScopes` performance.\n-/\n\ndef Name.hasMacroScopes : Name \u2192 Bool\n  | str _ s _   => beq s \"_hyg\"\n  | num p _   _ => hasMacroScopes p\n  | _           => false\n\nprivate def eraseMacroScopesAux : Name \u2192 Name\n  | Name.str p s _   => if s = \"_@\" then p else eraseMacroScopesAux p\n  | Name.num p _ _   => eraseMacroScopesAux p\n  | Name.anonymous   => Name.anonymous\n\n@[export lean_erase_macro_scopes]\ndef Name.eraseMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => eraseMacroScopesAux n\n  | false => n\n\nprivate def simpMacroScopesAux : Name \u2192 Name\n  | Name.num p i _ => mkNameNum (simpMacroScopesAux p) i\n  | n              => eraseMacroScopesAux n\n\n/- Helper function we use to create binder names that do not need to be unique. -/\n@[export lean_simp_macro_scopes]\ndef Name.simpMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => simpMacroScopesAux n\n  | false => n\n\nstructure MacroScopesView :=\n  (name       : Name)\n  (imported   : Name)\n  (mainModule : Name)\n  (scopes     : List MacroScope)\n\ninstance : Inhabited MacroScopesView := \u27e8\u27e8arbitrary _, arbitrary _, arbitrary _, arbitrary _\u27e9\u27e9\n\ndef MacroScopesView.review (view : MacroScopesView) : Name :=\n  match view.scopes with\n  | List.nil      => view.name\n  | List.cons _ _ =>\n    let base := (mkNameStr (append (append (mkNameStr view.name \"_@\") view.imported) view.mainModule) \"_hyg\")\n    view.scopes.foldl mkNameNum base\n\nprivate def assembleParts : List Name \u2192 Name \u2192 Name\n  | List.nil,                      acc => acc\n  | List.cons (Name.str _ s _) ps, acc => assembleParts ps (mkNameStr acc s)\n  | List.cons (Name.num _ n _) ps, acc => assembleParts ps (mkNameNum acc n)\n  | _,                             acc => panic \"unreachable @ assembleParts\"\n\nprivate def extractImported (scps : List MacroScope) (mainModule : Name) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    if str = \"_@\" then\n      { name := p, mainModule := mainModule, imported := assembleParts parts Name.anonymous, scopes := scps }\n    else\n      extractImported scps mainModule p (List.cons n parts)\n  | n@(Name.num p str _), parts => extractImported scps mainModule p (List.cons n parts)\n  | _,                    _     => panic \"unreachable @ extractImported\"\n\nprivate def extractMainModule (scps : List MacroScope) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    if str = \"_@\" then\n      { name := p, mainModule := assembleParts parts Name.anonymous, imported := Name.anonymous, scopes := scps }\n    else\n      extractMainModule scps p (List.cons n parts)\n  | n@(Name.num p num _), acc => extractImported scps (assembleParts acc Name.anonymous) n List.nil\n  | _,                    _   => panic \"unreachable @ extractMainModule\"\n\nprivate def extractMacroScopesAux : Name \u2192 List MacroScope \u2192 MacroScopesView\n  | Name.num p scp _, acc => extractMacroScopesAux p (List.cons scp acc)\n  | Name.str p str _, acc => extractMainModule acc p List.nil -- str must be \"_hyg\"\n  | _,                _   => panic \"unreachable @ extractMacroScopesAux\"\n\n/--\n  Revert all `addMacroScope` calls. `v = extractMacroScopes n \u2192 n = v.review`.\n  This operation is useful for analyzing/transforming the original identifiers, then adding back\n  the scopes (via `MacroScopesView.review`). -/\ndef extractMacroScopes (n : Name) : MacroScopesView :=\n  match n.hasMacroScopes with\n  | true  => extractMacroScopesAux n List.nil\n  | false => { name := n, scopes := List.nil, imported := Name.anonymous, mainModule := Name.anonymous }\n\ndef addMacroScope (mainModule : Name) (n : Name) (scp : MacroScope) : Name :=\n  match n.hasMacroScopes with\n  | true =>\n    let view := extractMacroScopes n\n    match beq view.mainModule mainModule with\n    | true  => mkNameNum n scp\n    | false =>\n      { view with\n        imported   := view.scopes.foldl mkNameNum (append view.imported view.mainModule),\n        mainModule := mainModule,\n        scopes     := List.cons scp List.nil\n      }.review\n  | false =>\n    mkNameNum (mkNameStr (append (mkNameStr n \"_@\") mainModule) \"_hyg\") scp\n\n@[inline] def MonadQuotation.addMacroScope {m : Type \u2192 Type} [MonadQuotation m] [Monad m] (n : Name) : m Name :=\n  bind getMainModule     fun mainModule =>\n  bind getCurrMacroScope fun scp =>\n  pure (Lean.addMacroScope mainModule n scp)\n\ndef defaultMaxRecDepth := 512\n\ndef maxRecDepthErrorMessage : String :=\n  \"maximum recursion depth has been reached (use `set_option maxRecDepth <num>` to increase limit)\"\n\nnamespace Macro\n\n/- References -/\nconstant MacroEnvPointed : PointedType.{0}\n\ndef MacroEnv : Type := MacroEnvPointed.type\ninstance : Inhabited MacroEnv := \u27e8MacroEnvPointed.val\u27e9\n\nstructure Context :=\n  (macroEnv       : MacroEnv)\n  (mainModule     : Name)\n  (currMacroScope : MacroScope)\n  (currRecDepth   : Nat := 0)\n  (maxRecDepth    : Nat := defaultMaxRecDepth)\n\ninductive Exception\n  | error             : Syntax \u2192 String \u2192 Exception\n  | unsupportedSyntax : Exception\n\nend Macro\n\nabbrev MacroM := ReaderT Macro.Context (EStateM Macro.Exception MacroScope)\n\nabbrev Macro := Syntax \u2192 MacroM Syntax\n\nnamespace Macro\n\ndef addMacroScope (n : Name) : MacroM Name :=\n  bind read fun ctx =>\n  pure (Lean.addMacroScope ctx.mainModule n ctx.currMacroScope)\n\ndef throwUnsupported {\u03b1} : MacroM \u03b1 :=\n  throw Exception.unsupportedSyntax\n\ndef throwError {\u03b1} (ref : Syntax) (msg : String) : MacroM \u03b1 :=\n  throw (Exception.error ref msg)\n\n@[inline] protected def withFreshMacroScope {\u03b1} (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind (modifyGet (fun s => (s, add s 1))) fun fresh =>\n  withReader (fun ctx => { ctx with currMacroScope := fresh }) x\n\n@[inline] def withIncRecDepth {\u03b1} (ref : Syntax) (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind read fun ctx =>\n  if ctx.currRecDepth = ctx.maxRecDepth then\n    throw (Exception.error ref maxRecDepthErrorMessage)\n  else\n    withReader (fun ctx => { ctx with currRecDepth := add ctx.currRecDepth 1 }) x\n\ninstance : MonadQuotation MacroM := {\n  getCurrMacroScope   := fun ctx => pure ctx.currMacroScope,\n  getMainModule       := fun ctx => pure ctx.mainModule,\n  withFreshMacroScope := Macro.withFreshMacroScope\n}\n\nunsafe def mkMacroEnvImp (expandMacro? : Syntax \u2192 MacroM (Option Syntax)) : MacroEnv :=\n  unsafeCast expandMacro?\n\n@[implementedBy mkMacroEnvImp]\nconstant mkMacroEnv (expandMacro? : Syntax \u2192 MacroM (Option Syntax)) : MacroEnv\n\ndef expandMacroNotAvailable? (stx : Syntax) : MacroM (Option Syntax) :=\n  throwError stx \"expandMacro has not been set\"\n\ndef mkMacroEnvSimple : MacroEnv :=\n  mkMacroEnv expandMacroNotAvailable?\n\nunsafe def expandMacro?Imp (stx : Syntax) : MacroM (Option Syntax) :=\n  bind read fun ctx =>\n  let f : Syntax \u2192 MacroM (Option Syntax) := unsafeCast (ctx.macroEnv)\n  f stx\n\n/-- `expandMacro? stx` return `some stxNew` if `stx` is a macro, and `stxNew` is its expansion. -/\n@[implementedBy expandMacro?Imp] constant expandMacro? : Syntax \u2192 MacroM (Option Syntax)\n\nend Macro\n\nexport Macro (expandMacro?)\n\nend Lean\n\nsyntax \"foo\" term : term\n\nmacro_rules\n  | `(foo $x) => x\n\n#check foo 10\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/PreludeNew.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.665410558746814, "lm_q2_score": 0.7248702642896702, "lm_q1q2_score": 0.48233632757994016}}
{"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) \u2190 (fromJson? (\u2190 j.getObjVal? \"year\")).map Year.mk\n    let (month : Month) \u2190 (fromJson? (\u2190 j.getObjVal? \"month\"))\n    let (day : Nat) \u2190 fromJson? (\u2190 j.getObjVal? \"day\")\n    if h : day >= 1 \u2227 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 : \u2200 {o\u2081 o\u2082 : Ymd} (h_year : o\u2081.year = o\u2082.year) (h_month : o\u2081.month = o\u2082.month) (h_day : o\u2081.day = o\u2082.day), o\u2081 = o\u2082\n| \u27e8y\u2081, m\u2081, d\u2081, hGt\u2081, hLt\u2081\u27e9, \u27e8y\u2082, m\u2082, d\u2082, hGt\u2082, hLt\u2082\u27e9, hy, hm, hd => by simp [hy, hm, hd]\n\ninstance : Ord Ymd where\n  compare d\u2081 d\u2082 :=  \n    match Ord.compare d\u2081.year d\u2082.year with\n    | Ordering.eq =>\n      match Ord.compare d\u2081.month d\u2082.month with\n      | Ordering.eq => Ord.compare d\u2081.day d\u2082.day\n      | owise => owise\n    | owise => owise\n\ninstance : LE Ymd := leOfOrd  \ninstance : LT Ymd := ltOfOrd\n\ntheorem Ymd.le_def (d\u2081 d\u2082 : Ymd) : (d\u2081 <= d\u2082) = (compare d\u2081 d\u2082).isLE := rfl \ntheorem Ymd.lt_def (d\u2081 d\u2082 : Ymd) : (d\u2081 < d\u2082) = (Ord.compare d\u2081 d\u2082 == Ordering.lt) := rfl \n\ntheorem Ymd.le_def' (d\u2081 d\u2082 : Ymd) : \n  (d\u2081 <= d\u2082) = \n  (d\u2081.year < d\u2082.year \u2228 (d\u2081.year = d\u2082.year \u2227 d\u2081.month < d\u2082.month) \u2228 (d\u2081.year = d\u2082.year \u2227 d\u2081.month = d\u2082.month \u2227 d\u2081.day <= d\u2082.day)) := by\n   simp [Ymd.le_def, Ordering.isLE, compare, compareOfLessAndEq]\n   match lt_trichotomy d\u2081.year d\u2082.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\u2081.month d\u2082.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\u2081.day d\u2082.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\u2082.day]\n\ntheorem Ymd.lt_def' (d\u2081 d\u2082 : Ymd) : \n  (d\u2081 < d\u2082) = \n  (d\u2081.year < d\u2082.year \n   \u2228 (d\u2081.year = d\u2082.year \u2227 d\u2081.month < d\u2082.month)\n   \u2228 (d\u2081.year = d\u2082.year \u2227 d\u2081.month = d\u2082.month \u2227 d\u2081.day < d\u2082.day)) := by\n   simp [Ymd.lt_def, compare, compareOfLessAndEq]\n   match lt_trichotomy d\u2081.year d\u2082.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\u2081.month d\u2082.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\u2081.day d\u2082.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\u2082.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 | \u27e8ay_eq_by, am_lt_bm\u27e9 | \u27e8ay_eq_by, am_eq_bm, ad_le_bd\u27e9)\n    <;> rintro (by_lt_cy | \u27e8by_eq_cy, bm_lt_cm\u27e9 | \u27e8by_eq_cy, bm_eq_cm, bd_le_cd\u27e9)\n    . exact .inl $ lt_trans ay_lt_by by_lt_cy\n    . exact .inl $ by_eq_cy \u25b8 ay_lt_by\n    . exact .inl $ by_eq_cy \u25b8 ay_lt_by\n    . exact .inl $ ay_eq_by \u25b8 by_lt_cy\n    . exact .inr $ .inl \u27e8ay_eq_by \u25b8 by_eq_cy, lt_trans am_lt_bm bm_lt_cm\u27e9\n    . exact .inr $ .inl \u27e8ay_eq_by \u25b8 by_eq_cy, bm_eq_cm \u25b8 am_lt_bm\u27e9\n    . exact .inl $ ay_eq_by \u25b8 by_lt_cy\n    . exact .inr $ .inl \u27e8ay_eq_by \u25b8 by_eq_cy, am_eq_bm \u25b8 bm_lt_cm\u27e9\n    . exact .inr $ .inr \u27e8ay_eq_by \u25b8 by_eq_cy, \u27e8am_eq_bm \u25b8 bm_eq_cm, le_trans ad_le_bd bd_le_cd\u27e9\u27e9\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 | \u27e8y_eq, m_lt\u27e9 | \u27e8y_eq, m_eq, d_le\u27e9)\n      case inl =>\n        have hr : \u00ac(b.year < a.year \u2228 b.year = a.year \u2227 b.month < a.month \u2228 b.year = a.year \u2227 b.month = a.month \u2227 b.day \u2264 a.day) := by\n          rintro (y_lt' | \u27e8y_eq', m_lt'\u27e9 | \u27e8y_eq', m_lt', d_le'\u27e9)           \n          . exact (not_lt_of_gt y_lt) y_lt'\n          . exact (lt_irrefl a.year (y_eq' \u25b8 y_lt))\n          . exact (lt_irrefl a.year (y_eq' \u25b8 y_lt))\n        exact \u27e8Or.inl y_lt, hr\u27e9\n      case inr.inl.intro =>\n        have hr : \u00ac(b.year < a.year \u2228 b.year = a.year \u2227 b.month < a.month \u2228 b.year = a.year \u2227 b.month = a.month \u2227 b.day \u2264 a.day) := by\n          rintro (y_lt' | \u27e8y_eq', m_le\u27e9 | \u27e8y_eq', m_eq', d_le'\u27e9)           \n          . exact (lt_irrefl a.year (y_eq \u25b8 y_lt'))\n          . exact (not_lt_of_gt m_lt) m_le\n          . exact (lt_irrefl a.month (m_eq' \u25b8 m_lt))\n        exact \u27e8.inr $ .inl \u27e8y_eq, m_lt\u27e9, hr\u27e9 \n      case inr.inr.intro.intro =>\n        have hr : \u00ac(b.year < a.year \u2228 b.year = a.year \u2227 b.month < a.month \u2228 b.year = a.year \u2227 b.month = a.month \u2227 b.day \u2264 a.day) := by\n          rintro (y_lt' | \u27e8y_eq', m_lt\u27e9 | \u27e8y_eq', m_eq, d_le'\u27e9)\n          . exact (lt_irrefl a.year (y_eq \u25b8 y_lt'))\n          . exact (lt_irrefl a.month (m_eq \u25b8 m_lt))\n          . exact (not_le_of_gt d_le d_le')\n        exact \u27e8.inr $ .inr \u27e8y_eq, \u27e8m_eq, le_of_lt d_le\u27e9\u27e9, hr\u27e9\n    case mpr =>\n      rintro (y_lt | \u27e8y_eq, m_lt\u27e9 | \u27e8y_eq, m_eq, d_le\u27e9)\n      case intro.inl => exact .inl y_lt\n      case intro.inr.inl.intro => exact .inr $ .inl \u27e8y_eq, m_lt\u27e9\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 \u27e8y_eq, \u27e8m_eq, d_lt\u27e9\u27e9\n        | .inr d_eq => exact False.elim $ hnot $ .inr $ .inr \u27e8y_eq.symm, \u27e8m_eq.symm, (le_of_eq d_eq.symm)\u27e9\u27e9\n  le_antisymm (a b) := by \n    simp [Ymd.le_def']\n    rintro (ay_lt_by | \u27e8ay_eq_by, am_lt_bm\u27e9 | \u27e8ay_eq_by, am_eq_bm, ad_le_bd\u27e9) \n    <;> rintro (by_lt_ay | \u27e8by_eq_ay, bm_lt_am\u27e9 | \u27e8by_eq_ay, bm_eq_am, bd_le_ad\u27e9)\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 : \u2124) (hn : 0 < n) (hk : 0 \u2264 k + n) (hu : 0 \u2264 u)\n  (h : k + n = 2 + x) (f : false) :\n  k + n = m + x :=\nbegin\n  lift n to \u2115 using le_of_lt hn,\n    guard_target (k + \u2191n = m + x), guard_hyp hn : (0 : \u2124) < \u2191n,\n  lift m to \u2115,\n    guard_target (0 \u2264 m), tactic.swap, guard_target (k + \u2191n = \u2191m + x),\n    tactic.num_goals >>= \u03bb n, guard (n = 2),\n  lift (k + n) to \u2115 using hk with l hl,\n    guard_hyp l : \u2115, guard_hyp hl : \u2191l = k + \u2191n, guard_target (\u2191l = \u2191m + x),\n    tactic.success_if_fail (tactic.get_local `hk),\n  lift x to \u2115 with y hy,\n    tactic.swap, guard_hyp y : \u2115, guard_hyp hy : \u2191y = x, guard_target (\u2191l = \u2191m + x), tactic.swap,\n  lift z to \u2115 with w,\n    tactic.swap, guard_hyp w : \u2115, tactic.success_if_fail (tactic.get_local `z), tactic.swap,\n  lift u to \u2115 using hu with u rfl hu,\n    guard_hyp hu : (0 : \u2124) \u2264 \u2191u,\n\n  all_goals { exfalso, assumption },\nend\n\n-- test lift of functions\nexample (\u03b1 : Type*) (f : \u03b1 \u2192 \u2124) (hf : \u2200 a, 0 \u2264 f a) (hf' : \u2200 a, f a < 1) (a : \u03b1) : 0 \u2264 2 * f a :=\nbegin\n  lift f to \u03b1 \u2192 \u2115 using hf,\n    guard_target ((0:\u2124) \u2264 2 * (\u03bb i : \u03b1, (f i : \u2124)) a),\n    guard_hyp hf' : \u2200 a, ((\u03bb i : \u03b1, (f i:\u2124)) a) < 1,\n  constructor,\nend\n\n-- fail gracefully when the lifted variable is a local definition\nexample : let n : \u2124 := 3 in n = n :=\nbegin\n  intro n,\n  success_if_fail_with_msg { lift n to \u2115 }\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 (\u03bb _, true) := \u27e8\u03bb x _, \u27e8x, rfl\u27e9\u27e9\n\n/- test error messages -/\nexample (n : \u2124) (hn : 0 < n) : true :=\nbegin\n  success_if_fail_with_msg {lift n to \u2115 using hn} (\"lift tactic failed.\\n\" ++\n    \"invalid type ascription, term has type\\n  0 < n\\nbut is expected to have type\\n  0 \u2264 n\"),\n  success_if_fail_with_msg {lift (n : option \u2124) to \u2115}\n    (\"Failed to find a lift from option \u2124 to \u2115. \" ++\n    \"Provide an instance of\\n  can_lift (option \u2124) \u2115 ?m_1 ?m_2\"),\n  trivial\nend\n\nexample (n : \u2124) : \u2115 :=\nbegin\n  success_if_fail_with_msg {lift n to \u2115}\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 (\u03bb x, x \u2208 s) :=\n{ prf := \u03bb x hx, \u27e8\u27e8x, hx\u27e9, rfl\u27e9 }\n\nexample {R : Type*} {P : R \u2192 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 \u2208 s) : true :=\nby { lift x to s using hx with y, trivial }\n\nexample (n : \u2124) (hn : 0 \u2264 n) : true :=\nby { lift n to \u2115, exact hn, trivial }\n\nexample (n : \u2124) (hn : 0 \u2264 n) : true :=\nby { lift n to \u2115 using hn, trivial }\n\nexample (n : \u2124) (hn : n \u2265 0) : true :=\nby { lift n to \u2115 using ge.le _, trivial, guard_target (n \u2265 0), exact hn }\n\nexample (n : \u2124) (hn : 0 \u2264 1 * n) : true :=\nbegin\n  lift n to \u2115 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 \u2264 1 * ((k : \u2115) : \u2124),\n  trivial\nend\n\nexample (n : \u2124) (hn : 0 \u2264 n \u2194 true) : true :=\nbegin\n  lift n to \u2115 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 \u00a9 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 (\u27e8a,b\u27e9 ~ \u27e8c,d\u27e9) \u2194 (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 (\u03b1 : Type u) [integral_domain \u03b1] := (n : \u03b1) (d : \u03b1 ) (nz : d \u2260 0)\nlemma q.ext {\u03b1 : Type u} [integral_domain \u03b1] : \u03a0 (q1 q2 : q \u03b1), q1.n = q2.n \u2192 q1.d = q2.d \u2192 q1 = q2\n|\u27e8n,d,nz\u27e9 \u27e8_,_,_\u27e9 rfl rfl := rfl\n\ninstance (\u03b1 : Type u) [integral_domain \u03b1] : setoid (q \u03b1) :=\n{ r := (\u03bb a b, a.1 * b.2 = b.1 * a.2)\n, iseqv :=\n  \u27e8 \u03bb a, rfl\n  , \u03bb a b, eq.symm\n  , \u03bb \u27e8a,b,_\u27e9 \u27e8c,d,h\u27e9 \u27e8e,f,_\u27e9\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  \u27e9\n}\ndef free (\u03b1 : Type u) [integral_domain \u03b1] : Type* := @quotient (q \u03b1) (by apply_instance)\nvariables {\u03b1 : Type u} [integral_domain \u03b1]\n\n-- [TODO]\n-- namespace free\n-- def add : free \u03b1 \u2192 free \u03b1 \u2192 free \u03b1\n-- := \u03bb x y, quotient.lift_on\u2082 x y\n--   (\u03bb x y, \u27e6(\u27e8x.1 * y.2 + y.1 * x.2, x.2 * y.2, mul_ne_zero x.nz y.nz\u27e9 : q \u03b1)\u27e7)\n--   (\u03bb 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": "\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 Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\n \n--OUTPUT 1\ntheorem fin_ab_hom_eq_dual_hom {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H] [group_hom f : G \u2192* H] [group_hom g : G \u2192* H]\n  (h : \u2200 x, f x = g x) :\n  \u2200 x, (finsupp.single x : G \u2192\u2097[\u2124] \u2124) \u2218 f = (finsupp.single x : G \u2192\u2097[\u2124] \u2124) \u2218 g :=\nbegin\n  intro x,\n  have h1 : f x = g x,\n    from h x,\n  have h2 : (finsupp.single x : G \u2192\u2097[\u2124] \u2124) \u2218 f = (finsupp.single x : G \u2192\u2097[\u2124] \u2124) \u2218 g,\n    from congr_fun h1 _,\n  exact h2,\n\n--OUTPUT 2\ntheorem abelian_hom_isomorphism {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp G H).to_fun \u226b (finsupp.map f).to_fun = f := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp.map f).to_fun \u226b (finsupp G H).to_fun = f := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp.map f).to_fun \u226b (finsupp.map f).to_fun = finsupp.map f := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp G H).to_fun \u226b (finsupp G H).to_fun = finsupp G H := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun = finsupp G H := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun = finsupp.map f := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun = finsupp.map f := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun = finsupp G H := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun = finsupp G H := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv_inv_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun = finsupp.map f := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv_inv_inv_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun = finsupp.map f := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv_inv_inv_inv_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_fun = finsupp G H := sorry\n\n--Prove that Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals in Lean mathlib\ntheorem abelian_hom_isomorphism_inv_inv_inv_inv_inv_inv_inv_inv_inv_inv_inv_inv {G H : Type*} [fintype G] [fintype H] [add_comm_group G] [add_comm_group H]\n(f : G \u2192 H) [is_group_hom f] : (finsupp G H).to_fun \u226b (finsupp.map f).to_fun \u226b (finsupp G H).to_\n\n--OUTPUT 3\ntheorem is_isomorphic_to_hom_of_dual (G : Type) [add_comm_group G] [module \u2124 G] [fintype G] [decidable_eq G] [fintype (dual G)] [decidable_eq (dual G)] (H : Type) [add_comm_group H] [module \u2124 H] [fintype H] [decidable_eq H] [fintype (dual H)] [decidable_eq (dual H)] (f : G \u2192 H) (hf : is_homomorphism f) : (dual G \u2192 dual H) \u2243 (G \u2192 H) :=\nbegin\n  haveI := classical.dec_eq G,\n  haveI := classical.dec_eq H,\n  haveI := classical.dec_eq (dual G),\n  haveI := classical.dec_eq (dual H),\n  haveI := classical.dec_eq (G \u2192 H),\n  haveI := classical.dec_eq (dual G \u2192 dual H),\n  let g : (dual G \u2192 dual H) \u2192 (G \u2192 H) := \u03bb f, f \u2218 dual.val,\n  let h : (G \u2192 H) \u2192 (dual G \u2192 dual H) := \u03bb f, dual.map \u2218 f,\n  have hg : h \u2218 g = id,\n  {\n    ext,\n    rw [h, g, dual.map_val, id_comp],\n  },\n  have gh : g \u2218 h = id,\n  {\n    ext,\n    rw [h, g, dual.map_val, id_comp],\n  },\n  exact equiv.mk g h hg gh,\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/Homomorphisms between two finite abelian groups are isomorphic to homomorphisms between their duals.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7745833737577159, "lm_q2_score": 0.6224593312018546, "lm_q1q2_score": 0.482146648789304}}
{"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 \u27f6 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 \u27f6 R` is mono if and only if `g \u226b f = 0 \u2192 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 \u226b (-g)` and `(-f) \u226b g` both become `-(f \u226b g)`, and `(-f) \u226b (-g)`\nis simplified to `f \u226b 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 \u27f6 Q` is an abelian group such that composition is\n    linear in both variables. -/\nclass preadditive :=\n(hom_group : \u03a0 P Q : C, add_comm_group (P \u27f6 Q) . tactic.apply_instance)\n(add_comp' : \u2200 (P Q R : C) (f f' : P \u27f6 Q) (g : Q \u27f6 R),\n  (f + f') \u226b g = f \u226b g + f' \u226b g . obviously)\n(comp_add' : \u2200 (P Q R : C) (f : P \u27f6 Q) (g g' : Q \u27f6 R),\n  f \u226b (g + g') = f \u226b g + f \u226b 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 \u2192 C)\n\ninstance induced_category.category : preadditive.{v} (induced_category C F) :=\n{ hom_group := \u03bb P Q, @preadditive.hom_group C _ _ (F P) (F Q),\n  add_comp' := \u03bb P Q R f f' g, add_comp' _ _ _ _ _ _,\n  comp_add' := \u03bb 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 := \u03bb f g h, preadditive.add_comp X X X g h f,\n  right_distrib := \u03bb 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 \u27f6 Q) : (Q \u27f6 R) \u2192+ (P \u27f6 R) :=\nmk' (\u03bb g, f \u226b g) $ \u03bb 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 \u27f6 R) : (P \u27f6 Q) \u2192+ (P \u27f6 R) :=\nmk' (\u03bb f, f \u226b g) $ \u03bb f f', by simp\n\n@[simp, reassoc] lemma sub_comp {P Q R : C} (f f' : P \u27f6 Q) (g : Q \u27f6 R) :\n  (f - f') \u226b g = f \u226b g - f' \u226b 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 \u27f6 Q) (g g' : Q \u27f6 R) :\n  f \u226b (g - g') = f \u226b g - f \u226b g' :=\nmap_sub (left_comp R f) g g'\n\n@[simp, reassoc] lemma neg_comp {P Q R : C} (f : P \u27f6 Q) (g : Q \u27f6 R) : (-f) \u226b g = -(f \u226b 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 \u27f6 Q) (g : Q \u27f6 R) : f \u226b (-g) = -(f \u226b g) :=\nmap_neg (left_comp _ _) _\n\n@[reassoc] lemma neg_comp_neg {P Q R : C} (f : P \u27f6 Q) (g : Q \u27f6 R) : (-f) \u226b (-g) = f \u226b 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 \u27f6 Q) (g : J \u2192 (Q \u27f6 R)) :\n  f \u226b \u2211 j in s, g j = \u2211 j in s, f \u226b 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 \u2192 (P \u27f6 Q)) (g : Q \u27f6 R) :\n  (\u2211 j in s, f j) \u226b g  = \u2211 j in s, f j \u226b 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 \u27f6 Q} [epi f] : epi (-f) :=\n\u27e8\u03bb R g g' H, by rwa [neg_comp, neg_comp, \u2190comp_neg, \u2190comp_neg, cancel_epi, neg_inj] at H\u27e9\n\ninstance {P Q : C} {f : P \u27f6 Q} [mono f] : mono (-f) :=\n\u27e8\u03bb R g g' H, by rwa [comp_neg, comp_neg, \u2190neg_comp, \u2190neg_comp, cancel_mono, neg_inj] at H\u27e9\n\n@[priority 100]\ninstance preadditive_has_zero_morphisms : has_zero_morphisms C :=\n{ has_zero := infer_instance,\n  comp_zero' := \u03bb P Q f R, map_zero $ left_comp R f,\n  zero_comp' := \u03bb P Q R f, map_zero $ right_comp P f }\n\nlemma mono_of_cancel_zero {Q R : C} (f : Q \u27f6 R) (h : \u2200 {P : C} (g : P \u27f6 Q), g \u226b f = 0 \u2192 g = 0) :\n  mono f :=\n\u27e8\u03bb P g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (right_comp P f) g g').trans $ sub_eq_zero.2 hg\u27e9\n\nlemma mono_iff_cancel_zero {Q R : C} (f : Q \u27f6 R) :\n  mono f \u2194 \u2200 (P : C) (g : P \u27f6 Q), g \u226b f = 0 \u2192 g = 0 :=\n\u27e8\u03bb m P g, by exactI zero_of_comp_mono _, mono_of_cancel_zero f\u27e9\n\nlemma mono_of_kernel_zero {X Y : C} {f : X \u27f6 Y} [has_limit (parallel_pair f 0)]\n  (w : kernel.\u03b9 f = 0) : mono f :=\nmono_of_cancel_zero f (\u03bb P g h, by rw [\u2190kernel.lift_\u03b9 f g h, w, limits.comp_zero])\n\nlemma epi_of_cancel_zero {P Q : C} (f : P \u27f6 Q) (h : \u2200 {R : C} (g : Q \u27f6 R), f \u226b g = 0 \u2192 g = 0) :\n  epi f :=\n\u27e8\u03bb R g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (left_comp R f) g g').trans $ sub_eq_zero.2 hg\u27e9\n\nlemma epi_iff_cancel_zero {P Q : C} (f : P \u27f6 Q) :\n  epi f \u2194 \u2200 (R : C) (g : Q \u27f6 R), f \u226b g = 0 \u2192 g = 0 :=\n\u27e8\u03bb e R g, by exactI zero_of_epi_comp _, epi_of_cancel_zero f\u27e9\n\nlemma epi_of_cokernel_zero {X Y : C} (f : X \u27f6 Y) [has_colimit (parallel_pair f 0 )]\n  (w : cokernel.\u03c0 f = 0) : epi f :=\nepi_of_cancel_zero f (\u03bb P g h, by rw [\u2190cokernel.\u03c0_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 \u27f6 Y) (g : X \u27f6 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_\u03b9 (kernel.\u03b9 (f - g)) (sub_eq_zero.1 $\n    by { rw \u2190comp_sub, exact kernel.condition _ }),\n  is_limit := fork.is_limit.mk _\n    (\u03bb s, kernel.lift (f - g) (fork.\u03b9 s) $\n      by { rw comp_sub, apply sub_eq_zero.2, exact fork.condition _ })\n    (\u03bb s, by simp)\n    (\u03bb 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 _ _ (\u03bb _ _ f g, has_limit_parallel_pair f g)\n\nend\n\nsection\nvariables {X Y : C} (f : X \u27f6 Y) (g : X \u27f6 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_\u03c0 (cokernel.\u03c0 (f - g)) (sub_eq_zero.1 $\n    by { rw \u2190sub_comp, exact cokernel.condition _ }),\n  is_colimit := cofork.is_colimit.mk _\n    (\u03bb s, cokernel.desc (f - g) (cofork.\u03c0 s) $\n      by { rw sub_comp, apply sub_eq_zero.2, exact cofork.condition _ })\n    (\u03bb s, by simp)\n    (\u03bb 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 _ _ (\u03bb _ _ 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 \u2192 Nat\nopaque g : Nat \u2192 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\u2081 : f (g (g (g x))) = f (g x) := by simp; /- try again with `Foo` scoped lemmas -/ open Foo in simp\n  have h\u2082 : f (g x) = x               := by simp; open Foo in simp\n  Eq.trans h\u2081 h\u2082\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 \u2227 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 (\u03b1 : Type u) (S : sieve \u03b1) => \u2200 (x : \u03b1), 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 (\u03b1 : Type u) (\u03b2 : Type u) (f : \u03b2 \u27f6 \u03b1) : coe_fn (discrete_sieve \u03b1) \u03b2 f = \u2203 (x : \u03b1), \u2200 (y : \u03b2), f y = x :=\n  Eq.refl (coe_fn (discrete_sieve \u03b1) \u03b2 f)\n\ntheorem discrete_sieve_mem (\u03b1 : Type u) : discrete_sieve \u03b1 \u2208 coe_fn types_grothendieck_topology \u03b1 :=\n  fun (x : \u03b1) => 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 (\u03b1 : Type u) : presieve \u03b1 :=\n  fun (\u03b2 : Type u) (f : \u03b2 \u27f6 \u03b1) => \u2203 (x : \u03b2), \u2200 (y : \u03b2), y = x\n\ntheorem generate_discrete_presieve_mem (\u03b1 : Type u) : sieve.generate (discrete_presieve \u03b1) \u2208 coe_fn types_grothendieck_topology \u03b1 := sorry\n\ntheorem is_sheaf_yoneda' {\u03b1 : Type u} : presieve.is_sheaf types_grothendieck_topology (functor.obj yoneda \u03b1) := sorry\n\n/-- The yoneda functor that sends a type to a sheaf over the category of types -/\n@[simp] theorem yoneda'_map (\u03b1 : Type u) (\u03b2 : Type u) (f : \u03b1 \u27f6 \u03b2) : functor.map yoneda' f = functor.map yoneda f :=\n  Eq.refl (functor.map yoneda' f)\n\n@[simp] theorem yoneda'_comp : yoneda' \u22d9 induced_functor subtype.val = yoneda :=\n  rfl\n\n/-- Given a presheaf `P` on the category of types, construct\na map `P(\u03b1) \u2192 (\u03b1 \u2192 P(*))` for all type `\u03b1`. -/\ndef eval (P : Type u\u1d52\u1d56 \u2964 Type u) (\u03b1 : Type u) (s : functor.obj P (opposite.op \u03b1)) (x : \u03b1) : functor.obj P (opposite.op PUnit) :=\n  functor.map P (has_hom.hom.op (\u21befun (_x : PUnit) => x)) s\n\n/-- Given a sheaf `S` on the category of types, construct a map\n`(\u03b1 \u2192 S(*)) \u2192 S(\u03b1)` that is inverse to `eval`. -/\ndef types_glue (S : Type u\u1d52\u1d56 \u2964 Type u) (hs : presieve.is_sheaf types_grothendieck_topology S) (\u03b1 : Type u) (f : \u03b1 \u2192 functor.obj S (opposite.op PUnit)) : functor.obj S (opposite.op \u03b1) :=\n  presieve.is_sheaf_for.amalgamate sorry\n    (fun (\u03b2 : Type u) (g : \u03b2 \u27f6 \u03b1) (hg : discrete_presieve \u03b1 g) =>\n      functor.map S (has_hom.hom.op (\u21befun (x : \u03b2) => PUnit.unit)) (f (g (classical.some hg))))\n    sorry\n\ntheorem eval_types_glue {S : Type u\u1d52\u1d56 \u2964 Type u} {hs : presieve.is_sheaf types_grothendieck_topology S} {\u03b1 : Type u} (f : \u03b1 \u2192 functor.obj S (opposite.op PUnit)) : eval S \u03b1 (types_glue S hs \u03b1 f) = f := sorry\n\ntheorem types_glue_eval {S : Type u\u1d52\u1d56 \u2964 Type u} {hs : presieve.is_sheaf types_grothendieck_topology S} {\u03b1 : Type u} (s : functor.obj S (opposite.op \u03b1)) : types_glue S hs \u03b1 (eval S \u03b1 s) = s := sorry\n\n/-- Given a sheaf `S`, construct an equivalence `S(\u03b1) \u2243 (\u03b1 \u2192 S(*))`. -/\ndef eval_equiv (S : Type u\u1d52\u1d56 \u2964 Type u) (hs : presieve.is_sheaf types_grothendieck_topology S) (\u03b1 : Type u) : functor.obj S (opposite.op \u03b1) \u2243 (\u03b1 \u2192 functor.obj S (opposite.op PUnit)) :=\n  equiv.mk (eval S \u03b1) (types_glue S hs \u03b1) types_glue_eval eval_types_glue\n\ntheorem eval_map (S : Type u\u1d52\u1d56 \u2964 Type u) (\u03b1 : Type u) (\u03b2 : Type u) (f : \u03b2 \u27f6 \u03b1) (s : functor.obj S (opposite.op \u03b1)) (x : \u03b2) : eval S \u03b2 (functor.map S (has_hom.hom.op f) s) x = eval S \u03b1 s (f x) := sorry\n\n/-- Given a sheaf `S`, construct an isomorphism `S \u2245 [-, S(*)]`. -/\ndef equiv_yoneda (S : Type u\u1d52\u1d56 \u2964 Type u) (hs : presieve.is_sheaf types_grothendieck_topology S) : S \u2245 functor.obj yoneda (functor.obj S (opposite.op PUnit)) :=\n  nat_iso.of_components (fun (\u03b1 : Type u\u1d52\u1d56) => equiv.to_iso (eval_equiv S hs (opposite.unop \u03b1))) sorry\n\n/-- Given a sheaf `S`, construct an isomorphism `S \u2245 [-, 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\u2081 : SheafOfTypes types_grothendieck_topology) (S\u2082 : SheafOfTypes types_grothendieck_topology) (f : S\u2081 \u27f6 S\u2082) (\u03b1 : Type u) (s : functor.obj (subtype.val S\u2081) (opposite.op \u03b1)) (x : \u03b1) : eval (subtype.val S\u2082) \u03b1 (nat_trans.app f (opposite.op \u03b1) s) x =\n  nat_trans.app f (opposite.op PUnit) (eval (subtype.val S\u2081) \u03b1 s x) :=\n  Eq.symm (congr_fun (nat_trans.naturality' f (has_hom.hom.op (\u21befun (_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 (\u2191X) (opposite.op PUnit) :=\n  Eq.refl (functor.obj (\u2191X) (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 \u2124 as a quotient of \u2115 \u00d7 \u2115.\n  * HoTT 6.10, remark 6.10.7\n-/\n\nabbreviation builtin.int := int\n\nnamespace ground_zero.HITs\n\ndef int.rel : \u2115 \u00d7 \u2115 \u2192 \u2115 \u00d7 \u2115 \u2192 Prop\n| \u27e8a, b\u27e9 \u27e8c, d\u27e9 := a + d = b + c\n\ndef int := quot int.rel\nlocal notation \u2124 := int\n\nnamespace nat.product\n  def add (x y : \u2115 \u00d7 \u2115) : \u2115 \u00d7 \u2115 := 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 (\u2115 \u00d7 \u2115) := \u27e8add\u27e9\n\n  def mul (x y : \u2115 \u00d7 \u2115) : \u2115 \u00d7 \u2115 := 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 (\u2115 \u00d7 \u2115) := \u27e8mul\u27e9\n\n  lemma add_comm (x y : \u2115 \u00d7 \u2115) : 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 : \u2115 \u00d7 \u2115) : 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 : \u2115 \u00d7 \u2115) : nat.product.add a b = a + b :=\n  by trivial\n\n  lemma rw.mul (a b : \u2115 \u00d7 \u2115) : nat.product.mul a b = a * b :=\n  by trivial\nend nat.product\n\nnamespace int\n  universes u v\n\n  def mk : \u2115 \u00d7 \u2115 \u2192 \u2124 := quot.mk rel\n  def elem (a b : \u2115) : \u2124 := quot.mk rel \u27e8a, b\u27e9\n\n  def pos (n : \u2115) := mk \u27e8n, 0\u27e9\n  instance : has_coe \u2115 \u2124 := \u27e8pos\u27e9\n\n  def neg (n : \u2115) := mk \u27e80, n\u27e9\n\n  instance : has_zero int := \u27e8mk \u27e80, 0\u27e9\u27e9\n  instance : has_one int := \u27e8mk \u27e81, 0\u27e9\u27e9\n\n  def knife {a b c d : \u2115} (H : a + d = b + c :> \u2115) :\n    mk \u27e8a, b\u27e9 = mk \u27e8c, d\u27e9 :> \u2124 :=\n  ground_zero.support.inclusion $ @quot.sound _ int.rel\n    \u27e8a, b\u27e9 \u27e8c, d\u27e9 (ground_zero.support.truncation H)\n\n  def ind {\u03c0 : \u2124 \u2192 Sort u}\n    (mk\u2081 : \u03a0 (x : \u2115 \u00d7 \u2115), \u03c0 (mk x))\n    (knife\u2081 : \u03a0 {a b c d : \u2115} (H : a + d = b + c :> \u2115),\n      mk\u2081 \u27e8a, b\u27e9 =[knife H] mk\u2081 \u27e8c, d\u27e9) (x : \u2124) : \u03c0 x := begin\n    refine quot.hrec_on x _ _,\n    exact mk\u2081, 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\u2081 (ground_zero.support.inclusion p))),\n    apply ground_zero.types.heq.eq_subst_heq\n  end\n\n  def injs {\u03b2 : Sort u} (pos\u2081 : \u2115 \u2192 \u03b2) (zero\u2081 : \u03b2) (neg\u2081 : \u2115 \u2192 \u03b2) :\n    \u2115 \u00d7 \u2115 \u2192 \u03b2\n  | \u27e80, 0\u27e9 := zero\u2081\n  | \u27e8n, 0\u27e9 := pos\u2081 n\n  | \u27e80, n\u27e9 := neg\u2081 n\n  | \u27e8n + 1, m + 1\u27e9 := if n > m\n    then injs \u27e8n + 1, m\u27e9\n    else injs \u27e8n, m + 1\u27e9\n\n  def simplify : \u2115 \u00d7 \u2115 \u2192 \u2115 \u00d7 \u2115\n  | \u27e80, 0\u27e9 := \u27e80, 0\u27e9\n  | \u27e8n + 1, 0\u27e9 := \u27e8n + 1, 0\u27e9\n  | \u27e80, n + 1\u27e9 := \u27e80, n + 1\u27e9\n  | \u27e8n + 1, m + 1\u27e9 := if n > m then \u27e8n - m, 0\u27e9 else \u27e80, m - n\u27e9\n\n  lemma ite.left {c : Prop} [decidable c] {\u03b1 : Sort u} {x y : \u03b1}\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] {\u03b1 : Sort u} {x y : \u03b1}\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 : \u2115 \u00d7 \u2115) : mk x = mk (simplify x) := begin\n    apply quot.sound, cases x with u v,\n    induction u with u ih\u2081,\n    { induction v with v ih,\n      repeat { simp [simplify, rel] } },\n    { induction v with v ih\u2082,\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 {\u03c0 : \u2124 \u2192 Sort u}\n    (pos\u2081 : \u03a0 (n : \u2115), \u03c0 (elem n 0))\n    (zero\u2081 : \u03c0 0)\n    (neg\u2081 : \u03a0 (n : \u2115), \u03c0 (elem 0 n)) :\n    \u03a0 x, \u03c0 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  \u27e8quot.lift\n    (\u03bb (x : \u2115 \u00d7 \u2115), mk \u27e8x.pr\u2082, x.pr\u2081\u27e9)\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)\u27e9\n\n  lemma nat_rw (a b : \u2115) : nat.add a b = a + b :=\n  by trivial\n\n  def lift\u2082 (f : \u2115 \u00d7 \u2115 \u2192 \u2115 \u00d7 \u2115 \u2192 \u2115 \u00d7 \u2115)\n    (h\u2081 : \u03a0 (a b x : \u2115 \u00d7 \u2115) (H : rel a b),\n      mk (f x a) = mk (f x b))\n    (h\u2082 : \u03a0 (a b : \u2115 \u00d7 \u2115),\n      mk (f a b) = mk (f b a))\n    (x y : int) : int :=\n  quot.lift\n    (\u03bb x, quot.lift\n          (\u03bb y, mk (f x y))\n          (begin intros a b H, simp, apply h\u2081, assumption end) y)\n    (begin\n      intros a b H, simp,\n      induction y, simp,\n      rw [h\u2082 a y], rw [h\u2082 b y], apply h\u2081,\n      assumption, trivial\n    end) x\n\n  lemma add_saves_int {a b c d : \u2115} (H : a + d = b + c)\n    (y : \u2115 \u00d7 \u2115) :\n    mk (\u27e8a, b\u27e9 + y) = mk (\u27e8c, d\u27e9 + 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 [\u2190nat.add_assoc], rw [H],\n    rw [nat.add_assoc]\n  end\n\n  def eq_map {\u03b1 : Sort u} {\u03b2 : Sort v} {a b : \u03b1}\n    (f : \u03b1 \u2192 \u03b2) (p : a = b) : f a = f b :=\n  begin induction p, reflexivity end\n\n  def add : int \u2192 int \u2192 int := begin\n    apply lift\u2082 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 \u27e8a, b\u27e9],\n      rw [nat.product.add_comm u \u27e8c, d\u27e9],\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 := \u27e8add\u27e9\n  instance : has_sub int := \u27e8\u03bb a b, a + (-b)\u27e9\n\n  theorem inv_append (a : \u2124) : 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 : \u2124} : (a + b = c) \u2192 (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 [\u2190h], 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 : \u2124 \u2192 \u2124 \u2192 \u2124 := begin\n    apply lift\u2082 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 [\u2190nat.add_assoc (u * a)],\n      rw [\u2190nat.add_assoc (u * b)],\n\n      rw [\u2190nat.left_distrib u a d],\n      rw [\u2190nat.left_distrib v b c],\n\n      rw [\u2190nat.left_distrib u b c],\n      rw [\u2190nat.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 := \u27e8mul\u27e9\n\n  theorem k_equiv (a b k : \u2115) : mk \u27e8a, b\u27e9 = mk \u27e8a + k, b + k\u27e9 :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u2208 s\n  add_mem : \u2200 {a b : A}, a \u2208 s \u2192 b \u2208 s \u2192 a + b \u2208 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 \u2208 s\n  mul_mem : \u2200 {a b : M}, a \u2208 s \u2192 b \u2208 s \u2192 a * b \u2208 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 \u2208 s) (mul_mem : \u2200 {a b : M}, a \u2208 s \u2192 b \u2208 s \u2192 a * b \u2208 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 \u2194 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 \u2208 s) (add_mem : \u2200 {a b : A}, a \u2208 s \u2192 b \u2208 s \u2192 a + b \u2208 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 \u2194 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\u2081 : set M) (s\u2082 : set M)\n    [is_submonoid s\u2081] [is_submonoid s\u2082] : is_submonoid (s\u2081 \u2229 s\u2082) :=\n  is_submonoid.mk { left := is_submonoid.one_mem, right := is_submonoid.one_mem }\n    fun (x y : M) (hx : x \u2208 s\u2081 \u2229 s\u2082) (hy : y \u2208 s\u2081 \u2229 s\u2082) =>\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] {\u03b9 : Sort u_2}\n    (s : \u03b9 \u2192 set M) [h : \u2200 (y : \u03b9), is_add_submonoid (s y)] : is_add_submonoid (set.Inter s) :=\n  is_add_submonoid.mk (iff.mpr set.mem_Inter fun (y : \u03b9) => is_add_submonoid.zero_mem)\n    fun (x\u2081 x\u2082 : M) (h\u2081 : x\u2081 \u2208 set.Inter s) (h\u2082 : x\u2082 \u2208 set.Inter s) =>\n      iff.mpr set.mem_Inter\n        fun (y : \u03b9) =>\n          is_add_submonoid.add_mem (iff.mp set.mem_Inter h\u2081 y) (iff.mp set.mem_Inter h\u2082 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] {\u03b9 : Type u_2}\n    [h\u03b9 : Nonempty \u03b9] (s : \u03b9 \u2192 set M) [\u2200 (i : \u03b9), is_add_submonoid (s i)]\n    (directed : \u2200 (i j : \u03b9), \u2203 (k : \u03b9), s i \u2286 s k \u2227 s j \u2286 s k) :\n    is_add_submonoid (set.Union fun (i : \u03b9) => s i) :=\n  sorry\n\n/-- The set of natural number powers `1, x, x\u00b2, ...` 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) => \u2203 (n : \u2115), x ^ n = y\n\ndef multiples {A : Type u_2} [add_monoid A] (x : A) : set A :=\n  set_of fun (y : A) => \u2203 (n : \u2115), n \u2022\u2115 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 \u2208 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 \u2208 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 \u2208 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 \u2208 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 \u2208 powers x \u2192 z \u2208 powers x \u2192 y * z \u2208 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 \u2208 multiples x \u2192 z \u2208 multiples x \u2192 y + z \u2208 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 {\u03b1 : Type u_1} (x : \u03b1) => 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 {\u03b1 : Type u_1} (x : \u03b1) => iff_true_intro (set.mem_univ x)) a))\n                        (Eq.trans\n                          (imp_congr_eq\n                            (propext\n                              ((fun {\u03b1 : Type u_1} (x : \u03b1) => iff_true_intro (set.mem_univ x)) b))\n                            (propext\n                              ((fun {\u03b1 : Type u_1} (x : \u03b1) => 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 \u2192 N) [is_add_monoid_hom f] (s : set N) [is_add_submonoid s] :\n    is_add_submonoid (f \u207b\u00b9' s) :=\n  is_add_submonoid.mk\n    ((fun (this : f 0 \u2208 s) => this)\n      (eq.mpr (id (Eq._oldrec (Eq.refl (f 0 \u2208 s)) (is_add_monoid_hom.map_zero f)))\n        is_add_submonoid.zero_mem))\n    fun (a b : M) (ha : f a \u2208 s) (hb : f b \u2208 s) =>\n      (fun (this : f (a + b) \u2208 s) => this)\n        (eq.mpr (id (Eq._oldrec (Eq.refl (f (a + b) \u2208 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] {\u03b3 : Type u_2} [add_monoid \u03b3]\n    (f : M \u2192 \u03b3) [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] {\u03b3 : Type u_2}\n    [add_monoid \u03b3] (f : M \u2192 \u03b3) [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 \u2208 s) {n : \u2115} : a ^ n \u2208 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 \u2208 t) {n : \u2115} : n \u2022\u2115 a \u2208 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 \u2208 s) : powers a \u2286 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 \u2208 t \u2192 multiples a \u2286 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    (\u2200 (x : M), x \u2208 l \u2192 x \u2208 s) \u2192 list.prod l \u2208 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) : (\u2200 (a : M), a \u2208 m \u2192 a \u2208 s) \u2192 multiset.sum m \u2208 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 \u2192 M) (t : finset A) :\n    (\u2200 (b : A), b \u2208 t \u2192 f b \u2208 s) \u2192 (finset.prod t fun (b : A) => f b) \u2208 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 \u21a5s :=\n  add_monoid.mk (fun (x y : \u21a5s) => { val := \u2191x + \u2191y, 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 \u21a5s :=\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    \u21911 = 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 : \u21a5s) (b : \u21a5s) : \u2191(a + b) = \u2191a + \u2191b :=\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 : \u21a5s)\n    (n : \u2115) : \u2191(a ^ n) = \u2191a ^ 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 : \u21a5s) (n : \u2115) : \u2191(n \u2022\u2115 a) = n \u2022\u2115 \u2191a :=\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 : \u03b3 \u2192 M` whose image is contained in a submonoid `s`, the induced map\n    from `\u03b3` 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    {\u03b3 : Type u_2} [add_monoid \u03b3] [is_add_submonoid s] (f : \u03b3 \u2192 M) [is_add_monoid_hom f]\n    (h : \u2200 (x : \u03b3), f x \u2208 s) : is_add_monoid_hom fun (x : \u03b3) => { 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 \u2286 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 \u2286 t) : is_monoid_hom (set.inclusion h) :=\n  subtype_mk.is_monoid_hom (fun (x : \u21a5s) => \u2191x) fun (x : \u21a5s) => 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 \u2192 Prop where\n| basic : \u2200 {a : A}, a \u2208 s \u2192 in_closure s a\n| zero : in_closure s 0\n| add : \u2200 {a b : A}, in_closure s a \u2192 in_closure s b \u2192 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 \u2192 Prop where\n| basic : \u2200 {a : M}, a \u2208 s \u2192 in_closure s a\n| one : in_closure s 1\n| mul : \u2200 {a b : M}, in_closure s a \u2192 in_closure s b \u2192 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 \u2286 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 \u2286 t) : add_monoid.closure s \u2286 t :=\n  sorry\n\n/-- Given subsets `t` and `s` of a monoid `M`, if `s \u2286 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 \u2286 t) : add_monoid.closure s \u2286 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 \u2192 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 \u2208 add_monoid.closure s) :\n    \u2203 (l : List M), (\u2200 (x : M), x \u2208 l \u2192 x \u2208 s) \u2227 list.sum l = a :=\n  sorry\n\n/-- Given sets `s, t` of a commutative monoid `M`, `x \u2208 M` is in the submonoid of `M` generated by\n    `s \u222a 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 \u2208 add_monoid.closure (s \u222a t) \u2194\n        \u2203 (y : M),\n          \u2203 (H : y \u2208 add_monoid.closure s),\n            \u2203 (z : M), \u2203 (H : z \u2208 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 \u2191S :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 \u03b2 : Type*}\n\n/-! ### Chains -/\n\nsection chain\nvariables (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n\nlocal infix ` \u227a `:50 := r\n\n/-- A chain is a set `s` satisfying `x \u227a y \u2228 x = y \u2228 y \u227a x` for all `x y \u2208 s`. -/\ndef is_chain (s : set \u03b1) : Prop := s.pairwise (\u03bb x y, x \u227a y \u2228 y \u227a x)\n\n/-- `super_chain s t` means that `t` is a chain that strictly includes `s`. -/\ndef super_chain (s t : set \u03b1) : Prop := is_chain r t \u2227 s \u2282 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 \u03b1) : Prop := is_chain r s \u2227 \u2200 \u2983t\u2984, is_chain r t \u2192 s \u2286 t \u2192 s = t\n\nvariables {r} {c c\u2081 c\u2082 c\u2083 s t : set \u03b1} {a b x y : \u03b1}\n\nlemma is_chain_empty : is_chain r \u2205 := set.pairwise_empty _\n\nlemma set.subsingleton.is_chain (hs : s.subsingleton) : is_chain r s := hs.pairwise _\n\nlemma is_chain.mono : s \u2286 t \u2192 is_chain r t \u2192 is_chain r s := set.pairwise.mono\n\nlemma is_chain.mono_rel {r' : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : is_chain r s)\n  (h_imp : \u2200 x y, r x y \u2192 r' x y) : is_chain r' s :=\nh.mono' $ \u03bb x y, or.imp (h_imp x y) (h_imp y x)\n\n/-- This can be used to turn `is_chain (\u2265)` into `is_chain (\u2264)` and vice-versa. -/\nlemma is_chain.symm (h : is_chain r s) : is_chain (flip r) s := h.mono' $ \u03bb _ _, or.symm\n\nlemma is_chain_of_trichotomous [is_trichotomous \u03b1 r] (s : set \u03b1) : is_chain r s :=\n\u03bb a _ b _ hab, (trichotomous_of r a b).imp_right $ \u03bb h, h.resolve_left hab\n\nlemma is_chain.insert (hs : is_chain r s) (ha : \u2200 b \u2208 s, a \u2260 b \u2192 a \u227a b \u2228 b \u227a a) :\n  is_chain r (insert a s) :=\nhs.insert_of_symmetric (\u03bb _ _, or.symm) ha\n\nlemma is_chain_univ_iff : is_chain r (univ : set \u03b1) \u2194 is_trichotomous \u03b1 r :=\nbegin\n  refine \u27e8\u03bb h, \u27e8\u03bb a b , _\u27e9, \u03bb h, @is_chain_of_trichotomous _ _ h univ\u27e9,\n  rw [or.left_comm, or_iff_not_imp_left],\n  exact h trivial trivial,\nend\n\nlemma is_chain.image (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2)\n  (h : \u2200 x y, r x y \u2192 s (f x) (f y)) {c : set \u03b1} (hrc : is_chain r c) :\n  is_chain s (f '' c) :=\n\u03bb x \u27e8a, ha\u2081, ha\u2082\u27e9 y \u27e8b, hb\u2081, hb\u2082\u27e9, ha\u2082 \u25b8 hb\u2082 \u25b8 \u03bb hxy,\n  (hrc ha\u2081 hb\u2081 $ ne_of_apply_ne f hxy).imp (h _ _) (h _ _)\n\nsection total\nvariables [is_refl \u03b1 r]\n\nlemma is_chain.total (h : is_chain r s) (hx : x \u2208 s) (hy : y \u2208 s) : x \u227a y \u2228 y \u227a x :=\n(eq_or_ne x y).elim (\u03bb e, or.inl $ e \u25b8 refl _) (h hx hy)\n\nlemma is_chain.directed_on (H : is_chain r s) : directed_on r s :=\n\u03bb x hx y hy, (H.total hx hy).elim (\u03bb h, \u27e8y, hy, h, refl _\u27e9) $ \u03bb h, \u27e8x, hx, refl _, h\u27e9\n\nprotected lemma is_chain.directed {f : \u03b2 \u2192 \u03b1} {c : set \u03b2} (h : is_chain (f \u207b\u00b9'o r) c) :\n  directed r (\u03bb x : {a : \u03b2 // a \u2208 c}, f x) :=\n\u03bb \u27e8a, ha\u27e9 \u27e8b, hb\u27e9, by_cases\n  (\u03bb hab : a = b, by simp only [hab, exists_prop, and_self, subtype.exists];\n    exact \u27e8b, hb, refl _\u27e9) $\n  \u03bb hab, (h ha hb hab).elim (\u03bb h, \u27e8\u27e8b, hb\u27e9, h, refl _\u27e9) $ \u03bb h, \u27e8\u27e8a, ha\u27e9, refl _, h\u27e9\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) : \u00acsuper_chain r s t :=\n\u03bb ht, ht.2.ne $ h.2 ht.1 ht.2.1\n\nlemma is_max_chain.bot_mem [has_le \u03b1] [order_bot \u03b1] (h : is_max_chain (\u2264) s) : \u22a5 \u2208 s :=\n(h.2 (h.1.insert $ \u03bb a _ _, or.inl bot_le) $ subset_insert _ _).symm \u25b8 mem_insert _ _\n\nlemma is_max_chain.top_mem [has_le \u03b1] [order_top \u03b1] (h : is_max_chain (\u2264) s) : \u22a4 \u2208 s :=\n(h.2 (h.1.insert $ \u03bb a _ _, or.inr le_top) $ subset_insert _ _).symm \u25b8 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : set \u03b1) : set \u03b1 :=\nif h : \u2203 t, is_chain r s \u2227 super_chain r s t then some h else s\n\nlemma succ_chain_spec (h : \u2203 t, is_chain r s \u2227 super_chain r s t) :\n  super_chain r s (succ_chain r s) :=\nlet \u27e8t, hc'\u27e9 := h in\nhave is_chain r s \u2227 super_chain r s (some h),\n  from @some_spec _ (\u03bb t, is_chain r s \u2227 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 : \u2203 t, is_chain r s \u2227 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\u2081 : is_chain r s) (hs\u2082 : \u00ac 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\u2082,\n  obtain \u27e8t, ht, hst\u27e9 := hs\u2082.neg_resolve_left hs\u2081,\n  exact succ_chain_spec \u27e8t, hs\u2081, ht, ssubset_iff_subset_ne.2 hst\u27e9,\nend\n\nlemma subset_succ_chain : s \u2286 succ_chain r s :=\nif h : \u2203 t, is_chain r s \u2227 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 `\u2205` using `succ_chain` and `\u22c3\u2080`. -/\ninductive chain_closure (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : set \u03b1 \u2192 Prop\n| succ : \u2200 {s}, chain_closure s \u2192 chain_closure (succ_chain r s)\n| union : \u2200 {s}, (\u2200 a \u2208 s, chain_closure a) \u2192 chain_closure (\u22c3\u2080 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) := \u22c3\u2080 set_of (chain_closure r)\n\nlemma chain_closure_empty : chain_closure r \u2205 :=\nhave chain_closure r (\u22c3\u2080 \u2205),\n  from chain_closure.union $ \u03bb a h, h.rec _,\nby simpa using this\n\nlemma chain_closure_max_chain : chain_closure r (max_chain r) := chain_closure.union $ \u03bb s, id\n\nprivate lemma chain_closure_succ_total_aux (hc\u2081 : chain_closure r c\u2081) (hc\u2082 : chain_closure r c\u2082)\n  (h : \u2200 \u2983c\u2083\u2984, chain_closure r c\u2083 \u2192 c\u2083 \u2286 c\u2082 \u2192 c\u2082 = c\u2083 \u2228 succ_chain r c\u2083 \u2286 c\u2082) :\n  succ_chain r c\u2082 \u2286 c\u2081 \u2228 c\u2081 \u2286 c\u2082 :=\nbegin\n  induction hc\u2081,\n  case succ : c\u2083 hc\u2083 ih\n  { cases ih with ih ih,\n    { exact or.inl (ih.trans subset_succ_chain) },\n    { exact (h hc\u2083 ih).imp_left (\u03bb h, h \u25b8 subset.rfl) } },\n  case union : s hs ih\n  { refine (or_iff_not_imp_left.2 $ \u03bb hn, sUnion_subset $ \u03bb a ha, _),\n    exact (ih a ha).resolve_left (\u03bb h, hn $ h.trans $ subset_sUnion_of_mem ha) }\nend\n\nprivate lemma chain_closure_succ_total (hc\u2081 : chain_closure r c\u2081) (hc\u2082 : chain_closure r c\u2082)\n  (h : c\u2081 \u2286 c\u2082) :\n  c\u2082 = c\u2081 \u2228 succ_chain r c\u2081 \u2286 c\u2082 :=\nbegin\n  induction hc\u2082 generalizing c\u2081 hc\u2081 h,\n  case succ : c\u2082 hc\u2082 ih\n  { refine (chain_closure_succ_total_aux hc\u2081 hc\u2082 $ \u03bb c\u2081, ih).imp h.antisymm' (\u03bb h\u2081, _),\n    obtain rfl | h\u2082 := ih hc\u2081 h\u2081,\n    { exact subset.rfl },\n    { exact h\u2082.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\u2083 hc\u2083 h\u2081 h\u2082,\n    obtain h | h := chain_closure_succ_total_aux hc\u2081 (hs c\u2083 hc\u2083) (\u03bb c\u2084, ih _ hc\u2083),\n    { exact h\u2081 (subset_succ_chain.trans h) },\n    obtain h' | h' := ih c\u2083 hc\u2083 hc\u2081 h,\n    { exact h\u2081 h'.subset },\n    { exact h\u2082 (h'.trans $ subset_sUnion_of_mem hc\u2083) } }\nend\n\nlemma chain_closure.total (hc\u2081 : chain_closure r c\u2081) (hc\u2082 : chain_closure r c\u2082) :\n  c\u2081 \u2286 c\u2082 \u2228 c\u2082 \u2286 c\u2081 :=\n(chain_closure_succ_total_aux hc\u2082 hc\u2081 $ \u03bb c\u2083 hc\u2083, chain_closure_succ_total hc\u2083 hc\u2081).imp_left\n  subset_succ_chain.trans\n\nlemma chain_closure.succ_fixpoint (hc\u2081 : chain_closure r c\u2081) (hc\u2082 : chain_closure r c\u2082)\n  (hc : succ_chain r c\u2082 = c\u2082) :\n  c\u2081 \u2286 c\u2082 :=\nbegin\n  induction hc\u2081,\n  case succ : s\u2081 hc\u2081 h\n  { exact (chain_closure_succ_total hc\u2081 hc\u2082 h).elim (\u03bb h, h \u25b8 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 \u2194 c = max_chain r :=\n\u27e8\u03bb h, (subset_sUnion_of_mem hc).antisymm $ chain_closure_max_chain.succ_fixpoint hc h,\n  \u03bb h, subset_succ_chain.antisymm' $ (subset_sUnion_of_mem hc.succ).trans h.symm.subset\u27e9\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 \u2200 c \u2208 s, is_chain r c at h,\n    exact \u03bb c\u2081 \u27e8t\u2081, ht\u2081, (hc\u2081 : c\u2081 \u2208 t\u2081)\u27e9 c\u2082 \u27e8t\u2082, ht\u2082, (hc\u2082 : c\u2082 \u2208 t\u2082)\u27e9 hneq,\n      ((hs _ ht\u2081).total $ hs _ ht\u2082).elim\n        (\u03bb ht, h t\u2082 ht\u2082 (ht hc\u2081) hc\u2082 hneq)\n        (\u03bb ht, h t\u2081 ht\u2081 hc\u2081 (ht hc\u2082) hneq) }\nend\n\n/-- **Hausdorff's maximality principle**\n\nThere exists a maximal totally ordered set of `\u03b1`.\nNote that we do not require `\u03b1` to be partially ordered by `r`. -/\nlemma max_chain_spec : is_max_chain r (max_chain r) :=\nclassical.by_contradiction $ \u03bb h,\nlet \u27e8h\u2081, H\u27e9 := 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 (\u03b1 : Type*) [has_le \u03b1] :=\n(carrier : set \u03b1)\n(chain' : is_chain (\u2264) carrier)\n(max_chain' : \u2200 \u2983s\u2984, is_chain (\u2264) s \u2192 carrier \u2286 s \u2192 carrier = s)\n\nnamespace flag\nsection has_le\nvariables [has_le \u03b1] {s t : flag \u03b1} {a : \u03b1}\n\ninstance : set_like (flag \u03b1) \u03b1 :=\n{ coe := carrier,\n  coe_injective' := \u03bb s t h, by { cases s, cases t, congr' } }\n\n@[ext] lemma ext : (s : set \u03b1) = t \u2192 s = t := set_like.ext'\n@[simp] lemma mem_coe_iff : a \u2208 (s : set \u03b1) \u2194 a \u2208 s := iff.rfl\n@[simp] lemma coe_mk (s : set \u03b1) (h\u2081 h\u2082) : (mk s h\u2081 h\u2082 : set \u03b1) = s := rfl\n@[simp] lemma mk_coe (s : flag \u03b1) : mk (s : set \u03b1) s.chain' s.max_chain' = s := ext rfl\n\nlemma chain_le (s : flag \u03b1) : is_chain (\u2264) (s : set \u03b1) := s.chain'\nprotected lemma max_chain (s : flag \u03b1) : is_max_chain (\u2264) (s : set \u03b1) := \u27e8s.chain_le, s.max_chain'\u27e9\n\nlemma top_mem [order_top \u03b1] (s : flag \u03b1) : (\u22a4 : \u03b1) \u2208 s := s.max_chain.top_mem\nlemma bot_mem [order_bot \u03b1] (s : flag \u03b1) : (\u22a5 : \u03b1) \u2208 s := s.max_chain.bot_mem\n\nend has_le\n\nsection preorder\nvariables [preorder \u03b1] {a b : \u03b1}\n\nprotected lemma le_or_le (s : flag \u03b1) (ha : a \u2208 s) (hb : b \u2208 s) : a \u2264 b \u2228 b \u2264 a :=\ns.chain_le.total ha hb\n\ninstance [order_top \u03b1] (s : flag \u03b1) : order_top s := subtype.order_top s.top_mem\ninstance [order_bot \u03b1] (s : flag \u03b1) : order_bot s := subtype.order_bot s.bot_mem\ninstance [bounded_order \u03b1] (s : flag \u03b1) : bounded_order s :=\nsubtype.bounded_order s.bot_mem s.top_mem\n\nend preorder\n\nsection partial_order\nvariables [partial_order \u03b1]\n\nlemma chain_lt (s : flag \u03b1) : is_chain (<) (s : set \u03b1) :=\n\u03bb a ha b hb h, (s.le_or_le ha hb).imp h.lt_of_le h.lt_of_le'\n\ninstance [decidable_eq \u03b1] [@decidable_rel \u03b1 (\u2264)] [@decidable_rel \u03b1 (<)] (s : flag \u03b1) :\n  linear_order s :=\n{ le_total := \u03bb 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 \u03b1] : unique (flag \u03b1) :=\n{ default := \u27e8univ, is_chain_of_trichotomous _, \u03bb s _, s.subset_univ.antisymm'\u27e9,\n  uniq := \u03bb 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 {\u03b1 : Type*} [semiring \u03b1]\n\ntheorem mul_two_eq_add_self (x : \u03b1) : x * 2 = x + x :=\nshow x * (1 + 1) = x + x, by rw [mul_add, mul_one]\n\ntheorem two_mul_eq_add_self (x : \u03b1) : 2 * x = x + x :=\nshow (1 + 1) * x = x + x, by rw [add_mul, one_mul]\n\nend\n\nnamespace linear_ordered_ring\nvariables (\u03b1 : Type*) [i : linear_ordered_ring \u03b1]\ninclude i\n\nlemma one_pos : (0:\u03b1) < 1 := zero_lt_one \u03b1\n\nlemma two_pos : (0:\u03b1) < 2 := _root_.add_pos (one_pos \u03b1) (one_pos \u03b1)\n\nvariable {\u03b1}\n\nlemma add_pos (x y : \u03b1) : 0 < x \u2192 0 < y \u2192 0 < x + y := _root_.add_pos\n\nlemma succ_pos (x : \u03b1) : 0 < x \u2192 0 < x + 1 := \u03bb h, add_pos x 1 h (one_pos \u03b1)\n\n-- linear_ordered_ring.mul_pos (x y : \u03b1) : 0 < x \u2192 0 < y \u2192 0 < x * y\n\nlemma bit0_pos (x : \u03b1) : 0 < x \u2192 0 < bit0 x := \u03bb h, add_pos x x h h\n\nlemma bit1_pos (x : \u03b1) : 0 < x \u2192 0 < bit1 x := \u03bb h, succ_pos (bit0 x) (bit0_pos x h)\n\nclass num_pos (x : \u03b1) := (elim : (0:\u03b1) < x)\n\nnamespace num_pos\nvariable {i}\n\n@[priority 30] instance one : @num_pos \u03b1 i (1:\u03b1) := \u27e8one_pos \u03b1\u27e9\n@[priority 30] instance two : @num_pos \u03b1 i (2:\u03b1) := \u27e8two_pos \u03b1\u27e9\n@[priority 30] instance bit0 (x : \u03b1) [@num_pos \u03b1 i x] : @num_pos \u03b1 i (bit0 x) := \u27e8bit0_pos x (elim x)\u27e9\n@[priority 30] instance bit1 (x : \u03b1) [@num_pos \u03b1 i x] : @num_pos \u03b1 i (bit1 x) := \u27e8bit1_pos x (elim x)\u27e9\n@[priority 10] instance succ (x : \u03b1) [@num_pos \u03b1 i x] : @num_pos \u03b1 i (x+1) := \u27e8succ_pos x (elim x)\u27e9\n@[priority 20] instance add (x y : \u03b1) [@num_pos \u03b1 i x] [@num_pos \u03b1 i y] : @num_pos \u03b1 i (x + y) := \u27e8add_pos x y (elim x) (elim y)\u27e9\n@[priority 30] instance mul (x y : \u03b1) [@num_pos \u03b1 i x] [@num_pos \u03b1 i y] : @num_pos \u03b1 i (x * y) := \u27e8mul_pos x y (elim x) (elim y)\u27e9\n\nend num_pos\n\nclass num_nonzero (x : \u03b1) := (elim : x \u2260 (0:\u03b1))\n\n@[priority 30] instance of_pos (x : \u03b1) {i : linear_ordered_ring \u03b1} [@num_pos \u03b1 i x] : num_nonzero x := \u27e8ne_of_gt $ num_pos.elim x\u27e9\n\nend linear_ordered_ring\n\ntheorem pos_trivial {\u03b1 : Type*} [linear_ordered_ring \u03b1] (x : \u03b1) [linear_ordered_ring.num_pos x] : (0:\u03b1) < x := linear_ordered_ring.num_pos.elim x\ntheorem nonzero_trivial {\u03b1 : Type*} [linear_ordered_ring \u03b1] (x : \u03b1) [linear_ordered_ring.num_nonzero x] : x \u2260 0 := linear_ordered_ring.num_nonzero.elim x\n\nsection\nvariables {\u03b1 : Type*} [linear_ordered_ring \u03b1]\n\ntheorem le_of_mul_ge_mul_left {a b c : \u03b1} : c * b \u2264 c * a \u2192 c < 0 \u2192 a \u2264 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 : \u03b1} : b * c \u2264 a * c \u2192 c < 0 \u2192 a \u2264 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 {\u03b1 : Type*} [linear_ordered_field \u03b1]\n\ntheorem div_le_of_le_mul_of_pos {x y : \u03b1} (z : \u03b1) : x \u2264 y*z \u2192 0 < z \u2192 x/z \u2264 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 : \u03b1} (z : \u03b1) : x*z \u2264 y \u2192 0 < z \u2192 x \u2264 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 : \u03b1} (z : \u03b1) : y \u2264 x*z \u2192 z < 0 \u2192 x \u2264 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 : \u03b1} (z : \u03b1) : y*z \u2264 x \u2192 z < 0 \u2192 x/z \u2264 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 {\u03b1 : Type u} [has_lt \u03b1] (x y : \u03b1) : Type u\n| eq : x = y \u2192 lt_cmp\n| lt : x < y \u2192 lt_cmp\n| gt : y < x \u2192 lt_cmp\n\ninductive {u} le_cmp {\u03b1 : Type u} [has_le \u03b1] (x y : \u03b1) : Type u\n| le : x \u2264 y \u2192 le_cmp\n| ge : y \u2264 x \u2192 le_cmp\n\nvariables {\u03b1 : Type*} [decidable_linear_order \u03b1]\n\ndef lt_compare (x y : \u03b1) : 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 : \u03b1) : 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 : \u03b1) {C : Sort*} : (x = y \u2192 C) \u2192 (x < y \u2192 C) \u2192 (y < x \u2192 C) \u2192 C :=\n\u03bb heq hlt hgt, lt_cmp.cases_on (lt_compare x y) heq hlt hgt\n\n@[elab_as_eliminator]\ndef dichotomy_on (x y : \u03b1) {C : Sort*} : (x \u2264 y \u2192 C) \u2192 (y \u2264 x \u2192 C) \u2192 C :=\n\u03bb 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 \u2192 tactic unit :=\n\u03bb e, do {\n  `(@prod.mk %%t %%.(t) %%x %%y) \u2190 to_expr e,\n  d \u2190 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 \u2264 y`\nand the second assuming `y \u2264 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 \u2192 tactic unit :=\n\u03bb e, do {\n  `(@prod.mk %%t %%.(t) %%x %%y) \u2190 to_expr e,\n  d \u2190 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' : \u2200 (c : R) {x : M}, x \u2208 carrier \u2192 c \u2022 x \u2208 carrier)\n\nnamespace sub_mul_action\n\nvariables [has_scalar R M]\n\ninstance : set_like (sub_mul_action R M) M :=\n\u27e8sub_mul_action.carrier, \u03bb p q h, by cases p; cases q; congr'\u27e9\n\n@[simp] lemma mem_carrier {p : sub_mul_action R M} {x : M} : x \u2208 p.carrier \u2194 x \u2208 (p : set M) :=\niff.rfl\n\n@[ext] theorem ext {p q : sub_mul_action R M} (h : \u2200 x, x \u2208 p \u2194 x \u2208 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 = \u2191p) : sub_mul_action R M :=\n{ carrier := s,\n  smul_mem' := hs.symm \u25b8 p.smul_mem' }\n\n@[simp] lemma coe_copy (p : sub_mul_action R M) (s : set M) (hs : s = \u2191p) :\n  (p.copy s hs : set M) = s := rfl\n\nlemma copy_eq (p : sub_mul_action R M) (s : set M) (hs : s = \u2191p) : p.copy s hs = p :=\nset_like.coe_injective hs\n\ninstance : has_bot (sub_mul_action R M) :=\n\u27e8{ carrier := \u2205, smul_mem' := \u03bb c, set.not_mem_empty}\u27e9\n\ninstance : inhabited (sub_mul_action R M) := \u27e8\u22a5\u27e9\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 \u2208 p) : r \u2022 x \u2208 p := p.smul_mem' r h\n\ninstance : has_scalar R p :=\n{ smul := \u03bb c x, \u27e8c \u2022 x.1, smul_mem _ c x.2\u27e9 }\n\nvariables {p}\n@[simp, norm_cast] lemma coe_smul (r : R) (x : p) : ((r \u2022 x : p) : M) = r \u2022 \u2191x := rfl\n@[simp, norm_cast] lemma coe_mk (x : M) (hx : x \u2208 p) : ((\u27e8x, hx\u27e9 : p) : M) = x := rfl\n\nvariables (p)\n\n/-- Embedding of a submodule `p` to the ambient space `M`. -/\nprotected def subtype : p \u2192[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 \u2192 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 \u2208 p) : s \u2022 x \u2208 p :=\nby { rw [\u2190one_smul R x, \u2190smul_assoc], exact p.smul_mem _ h }\n\ninstance has_scalar' : has_scalar S p :=\n{ smul := \u03bb c x, \u27e8c \u2022 x.1, smul_of_tower_mem _ c x.2\u27e9 }\n\ninstance : is_scalar_tower S R p :=\n{ smul_assoc := \u03bb s r x, subtype.ext $ smul_assoc s r \u2191x }\n\n@[simp, norm_cast] lemma coe_smul_of_tower (s : S) (x : p) : ((s \u2022 x : p) : M) = s \u2022 \u2191x := 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 \u2022 x \u2208 p \u2194 x \u2208 p :=\n\u27e8\u03bb h, inv_smul_smul g x \u25b8 p.smul_of_tower_mem g\u207b\u00b9 h, p.smul_of_tower_mem g\u27e9\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 := (\u2022),\n  one_smul := \u03bb x, subtype.ext $ one_smul _ x,\n  mul_smul := \u03bb c\u2081 c\u2082 x, subtype.ext $ mul_smul c\u2081 c\u2082 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) \u2208 p :=\nlet \u27e8x, hx\u27e9 := h in zero_smul R (x : M) \u25b8 p.smul_mem 0 hx\n\n/-- If the scalar product forms a `module`, and the `sub_mul_action` is not `\u22a5`, then the\nsubset inherits the zero. -/\ninstance [n_empty : nonempty p] : has_zero p :=\n{ zero := \u27e80, n_empty.elim $ \u03bb x, p.zero_mem \u27e8x, x.prop\u27e9\u27e9 }\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 \u2208 p) : -x \u2208 p := by { rw \u2190 neg_one_smul R, exact p.smul_mem _ hx }\n\n@[simp] lemma neg_mem_iff : -x \u2208 p \u2194 x \u2208 p :=\n\u27e8\u03bb h, by { rw \u2190neg_neg x, exact neg_mem _ h}, neg_mem _\u27e9\n\ninstance : has_neg p := \u27e8\u03bbx, \u27e8-x.1, neg_mem _ x.2\u27e9\u27e9\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 \u2260 0) : s \u2022 x \u2208 p \u2194 x \u2208 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\u00f6lzl, Patrick Massot, S\u00e9bastien Gou\u00ebzel, Zhouhang Zhou, Reid Barton\n-/\nimport topology.dense_embedding\n\nopen set filter\nopen_locale topological_space\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\n\n/-- Homeomorphism between `\u03b1` and `\u03b2`, also called topological isomorphism -/\n@[nolint has_inhabited_instance] -- not all spaces are homeomorphic to each other\nstructure homeomorph (\u03b1 : Type*) (\u03b2 : Type*) [topological_space \u03b1] [topological_space \u03b2]\n  extends \u03b1 \u2243 \u03b2 :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\ninfix ` \u2243\u209c `:25 := homeomorph\n\nnamespace homeomorph\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4]\n\ninstance : has_coe_to_fun (\u03b1 \u2243\u209c \u03b2) := \u27e8\u03bb_, \u03b1 \u2192 \u03b2, \u03bbe, e.to_equiv\u27e9\n\n@[simp] lemma homeomorph_mk_coe (a : equiv \u03b1 \u03b2) (b c) :\n  ((homeomorph.mk a b c) : \u03b1 \u2192 \u03b2) = a :=\nrfl\n\n@[simp] lemma coe_to_equiv (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h.to_equiv = h := rfl\n\n/-- Inverse of a homeomorphism. -/\nprotected def symm (h : \u03b1 \u2243\u209c \u03b2) : \u03b2 \u2243\u209c \u03b1 :=\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 : \u03b1 \u2243\u209c \u03b2) : \u03b1 \u2192 \u03b2 := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : \u03b1 \u2243\u209c \u03b2) : \u03b2 \u2192 \u03b1 := h.symm\n\ninitialize_simps_projections homeomorph\n  (to_equiv_to_fun \u2192 apply, to_equiv_inv_fun \u2192 symm_apply, -to_equiv)\n\nlemma to_equiv_injective : function.injective (to_equiv : \u03b1 \u2243\u209c \u03b2 \u2192 \u03b1 \u2243 \u03b2)\n| \u27e8e, h\u2081, h\u2082\u27e9 \u27e8e', h\u2081', h\u2082'\u27e9 rfl := rfl\n\n@[ext] lemma ext {h h' : \u03b1 \u2243\u209c \u03b2} (H : \u2200 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 (\u03b1 : Type*) [topological_space \u03b1] : \u03b1 \u2243\u209c \u03b1 :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  to_equiv := equiv.refl \u03b1 }\n\n/-- Composition of two homeomorphisms. -/\nprotected def trans (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b2 \u2243\u209c \u03b3) : \u03b1 \u2243\u209c \u03b3 :=\n{ continuous_to_fun  := h\u2082.continuous_to_fun.comp h\u2081.continuous_to_fun,\n  continuous_inv_fun := h\u2081.continuous_inv_fun.comp h\u2082.continuous_inv_fun,\n  to_equiv := equiv.trans h\u2081.to_equiv h\u2082.to_equiv }\n\n@[simp] lemma homeomorph_mk_coe_symm (a : equiv \u03b1 \u03b2) (b c) :\n  ((homeomorph.mk a b c).symm : \u03b2 \u2192 \u03b1) = a.symm :=\nrfl\n\n@[simp] lemma refl_symm : (homeomorph.refl \u03b1).symm = homeomorph.refl \u03b1 := rfl\n\n@[continuity]\nprotected lemma continuous (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : continuous (h.symm) := h.continuous_inv_fun\n\n@[simp] lemma apply_symm_apply (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b2) : h (h.symm x) = x :=\nh.to_equiv.apply_symm_apply x\n\n@[simp] lemma symm_apply_apply (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : h.symm (h x) = x :=\nh.to_equiv.symm_apply_apply x\n\nprotected lemma bijective (h : \u03b1 \u2243\u209c \u03b2) : function.bijective h := h.to_equiv.bijective\nprotected lemma injective (h : \u03b1 \u2243\u209c \u03b2) : function.injective h := h.to_equiv.injective\nprotected lemma surjective (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) (g : \u03b2 \u2192 \u03b1) (hg : function.right_inverse g f) : \u03b1 \u2243\u209c \u03b2 :=\nhave g = f.symm, from funext (\u03bb 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 : \u03b1 \u2243\u209c \u03b2) : \u21d1h.symm \u2218 \u21d1h = id :=\nfunext h.symm_apply_apply\n\n@[simp] lemma self_comp_symm (h : \u03b1 \u2243\u209c \u03b2) : \u21d1h \u2218 \u21d1h.symm = id :=\nfunext h.apply_symm_apply\n\n@[simp] lemma range_coe (h : \u03b1 \u2243\u209c \u03b2) : range h = univ :=\nh.surjective.range_eq\n\nlemma image_symm (h : \u03b1 \u2243\u209c \u03b2) : image h.symm = preimage h :=\nfunext h.symm.to_equiv.image_eq_preimage\n\nlemma preimage_symm (h : \u03b1 \u2243\u209c \u03b2) : preimage h.symm = image h :=\n(funext h.to_equiv.image_eq_preimage).symm\n\n@[simp] lemma image_preimage (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h '' (h \u207b\u00b9' s) = s :=\nh.to_equiv.image_preimage s\n\n@[simp] lemma preimage_image (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h \u207b\u00b9' (h '' s) = s :=\nh.to_equiv.preimage_image s\n\nprotected lemma inducing (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : topological_space.induced h \u2039_\u203a = \u2039_\u203a := h.inducing.1.symm\n\nprotected lemma quotient_map (h : \u03b1 \u2243\u209c \u03b2) : 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 : \u03b1 \u2243\u209c \u03b2) : topological_space.coinduced h \u2039_\u203a = \u2039_\u203a :=\nh.quotient_map.2.symm\n\nprotected lemma embedding (h : \u03b1 \u2243\u209c \u03b2) : embedding h :=\n\u27e8h.inducing, h.injective\u27e9\n\nprotected lemma second_countable_topology [topological_space.second_countable_topology \u03b2]\n  (h : \u03b1 \u2243\u209c \u03b2) :\n  topological_space.second_countable_topology \u03b1 :=\nh.inducing.second_countable_topology\n\nlemma compact_image {s : set \u03b1} (h : \u03b1 \u2243\u209c \u03b2) : is_compact (h '' s) \u2194 is_compact s :=\nh.embedding.compact_iff_compact_image.symm\n\nlemma compact_preimage {s : set \u03b2} (h : \u03b1 \u2243\u209c \u03b2) : is_compact (h \u207b\u00b9' s) \u2194 is_compact s :=\nby rw \u2190 image_symm; exact h.symm.compact_image\n\nprotected lemma dense_embedding (h : \u03b1 \u2243\u209c \u03b2) : dense_embedding h :=\n{ dense   := h.surjective.dense_range,\n  .. h.embedding }\n\n@[simp] lemma is_open_preimage (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b2} : is_open (h \u207b\u00b9' s) \u2194 is_open s :=\nh.quotient_map.is_open_preimage\n\n@[simp] lemma is_open_image (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} : is_open (h '' s) \u2194 is_open s :=\nby rw [\u2190 preimage_symm, is_open_preimage]\n\n@[simp] lemma is_closed_preimage (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b2} : is_closed (h \u207b\u00b9' s) \u2194 is_closed s :=\nby simp only [\u2190 is_open_compl_iff, \u2190 preimage_compl, is_open_preimage]\n\n@[simp] lemma is_closed_image (h : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} : is_closed (h '' s) \u2194 is_closed s :=\nby rw [\u2190 preimage_symm, is_closed_preimage]\n\nlemma preimage_closure (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b2) : h \u207b\u00b9' (closure s) = closure (h \u207b\u00b9' s) :=\nby rw [h.embedding.closure_eq_preimage_closure_image, h.image_preimage]\n\nlemma image_closure (h : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : h '' (closure s) = closure (h '' s) :=\nby rw [\u2190 preimage_symm, preimage_closure]\n\nprotected lemma is_open_map (h : \u03b1 \u2243\u209c \u03b2) : is_open_map h := \u03bb s, h.is_open_image.2\n\nprotected lemma is_closed_map (h : \u03b1 \u2243\u209c \u03b2) : is_closed_map h := \u03bb s, h.is_closed_image.2\n\nprotected lemma closed_embedding (h : \u03b1 \u2243\u209c \u03b2) : closed_embedding h :=\nclosed_embedding_of_embedding_closed h.embedding h.is_closed_map\n\n@[simp] lemma map_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : map h (\ud835\udcdd x) = \ud835\udcdd (h x) :=\nh.embedding.map_nhds_of_mem _ (by simp)\n\nlemma symm_map_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : map h.symm (\ud835\udcdd (h x)) = \ud835\udcdd x :=\nby rw [h.symm.map_nhds_eq, h.symm_apply_apply]\n\nlemma nhds_eq_comap (h : \u03b1 \u2243\u209c \u03b2) (x : \u03b1) : \ud835\udcdd x = comap h (\ud835\udcdd (h x)) :=\nh.embedding.to_inducing.nhds_eq_comap x\n\n@[simp] lemma comap_nhds_eq (h : \u03b1 \u2243\u209c \u03b2) (y : \u03b2) : comap h (\ud835\udcdd y) = \ud835\udcdd (h.symm y) :=\nby rw [h.nhds_eq_comap, h.apply_symm_apply]\n\n/-- If an bijective map `e : \u03b1 \u2243 \u03b2` is continuous and open, then it is a homeomorphism. -/\ndef homeomorph_of_continuous_open (e : \u03b1 \u2243 \u03b2) (h\u2081 : continuous e) (h\u2082 : is_open_map e) :\n  \u03b1 \u2243\u209c \u03b2 :=\n{ continuous_to_fun := h\u2081,\n  continuous_inv_fun := begin\n    rw continuous_def,\n    intros s hs,\n    convert \u2190 h\u2082 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 : \u03b1 \u2243\u209c \u03b2) (f : \u03b3 \u2192 \u03b1) (s : set \u03b3) :\n  continuous_on (h \u2218 f) s \u2194 continuous_on f s :=\nh.inducing.continuous_on_iff.symm\n\n@[simp] lemma comp_continuous_iff (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b3 \u2192 \u03b1} :\n  continuous (h \u2218 f) \u2194 continuous f :=\nh.inducing.continuous_iff.symm\n\n@[simp] lemma comp_continuous_iff' (h : \u03b1 \u2243\u209c \u03b2) {f : \u03b2 \u2192 \u03b3} :\n  continuous (f \u2218 h) \u2194 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 \u03b1} (h : s = t) : s \u2243\u209c 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\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) : \u03b1 \u2295 \u03b3 \u2243\u209c \u03b2 \u2295 \u03b4 :=\n{ continuous_to_fun  :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h\u2081.continuous)\n      (continuous_inr.comp h\u2082.continuous),\n    ext x, cases x; refl,\n  end,\n  continuous_inv_fun :=\n  begin\n    convert continuous_sum_rec (continuous_inl.comp h\u2081.symm.continuous)\n      (continuous_inr.comp h\u2082.symm.continuous),\n    ext x, cases x; refl\n  end,\n  to_equiv := h\u2081.to_equiv.sum_congr h\u2082.to_equiv }\n\n/-- Product of two homeomorphisms. -/\ndef prod_congr (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) : \u03b1 \u00d7 \u03b3 \u2243\u209c \u03b2 \u00d7 \u03b4 :=\n{ continuous_to_fun  := (h\u2081.continuous.comp continuous_fst).prod_mk\n    (h\u2082.continuous.comp continuous_snd),\n  continuous_inv_fun := (h\u2081.symm.continuous.comp continuous_fst).prod_mk\n    (h\u2082.symm.continuous.comp continuous_snd),\n  to_equiv := h\u2081.to_equiv.prod_congr h\u2082.to_equiv }\n\n@[simp] lemma prod_congr_symm (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) :\n  (h\u2081.prod_congr h\u2082).symm = h\u2081.symm.prod_congr h\u2082.symm := rfl\n\n@[simp] lemma coe_prod_congr (h\u2081 : \u03b1 \u2243\u209c \u03b2) (h\u2082 : \u03b3 \u2243\u209c \u03b4) :\n  \u21d1(h\u2081.prod_congr h\u2082) = prod.map h\u2081 h\u2082 := rfl\n\nsection\nvariables (\u03b1 \u03b2 \u03b3)\n\n/-- `\u03b1 \u00d7 \u03b2` is homeomorphic to `\u03b2 \u00d7 \u03b1`. -/\ndef prod_comm : \u03b1 \u00d7 \u03b2 \u2243\u209c \u03b2 \u00d7 \u03b1 :=\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 \u03b1 \u03b2 }\n\n@[simp] lemma prod_comm_symm : (prod_comm \u03b1 \u03b2).symm = prod_comm \u03b2 \u03b1 := rfl\n@[simp] lemma coe_prod_comm : \u21d1(prod_comm \u03b1 \u03b2) = prod.swap := rfl\n\n/-- `(\u03b1 \u00d7 \u03b2) \u00d7 \u03b3` is homeomorphic to `\u03b1 \u00d7 (\u03b2 \u00d7 \u03b3)`. -/\ndef prod_assoc : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243\u209c \u03b1 \u00d7 (\u03b2 \u00d7 \u03b3) :=\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 \u03b1 \u03b2 \u03b3 }\n\n/-- `\u03b1 \u00d7 {*}` is homeomorphic to `\u03b1`. -/\n@[simps apply {fully_applied := ff}]\ndef prod_punit : \u03b1 \u00d7 punit \u2243\u209c \u03b1 :=\n{ to_equiv := equiv.prod_punit \u03b1,\n  continuous_to_fun := continuous_fst,\n  continuous_inv_fun := continuous_id.prod_mk continuous_const }\n\n/-- `{*} \u00d7 \u03b1` is homeomorphic to `\u03b1`. -/\ndef punit_prod : punit \u00d7 \u03b1 \u2243\u209c \u03b1 :=\n(prod_comm _ _).trans (prod_punit _)\n\n@[simp] lemma coe_punit_prod : \u21d1(punit_prod \u03b1) = prod.snd := rfl\n\nend\n\n/-- `ulift \u03b1` is homeomorphic to `\u03b1`. -/\ndef {u v} ulift {\u03b1 : Type u} [topological_space \u03b1] : ulift.{v u} \u03b1 \u2243\u209c \u03b1 :=\n{ continuous_to_fun := continuous_ulift_down,\n  continuous_inv_fun := continuous_ulift_up,\n  to_equiv := equiv.ulift }\n\nsection distrib\n\n/-- `(\u03b1 \u2295 \u03b2) \u00d7 \u03b3` is homeomorphic to `\u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3`. -/\ndef sum_prod_distrib : (\u03b1 \u2295 \u03b2) \u00d7 \u03b3 \u2243\u209c \u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3 :=\nbegin\n  refine (homeomorph.homeomorph_of_continuous_open (equiv.sum_prod_distrib \u03b1 \u03b2 \u03b3).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/-- `\u03b1 \u00d7 (\u03b2 \u2295 \u03b3)` is homeomorphic to `\u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3`. -/\ndef prod_sum_distrib : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243\u209c \u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3 :=\n(prod_comm _ _).trans $\nsum_prod_distrib.trans $\nsum_congr (prod_comm _ _) (prod_comm _ _)\n\nvariables {\u03b9 : Type*} {\u03c3 : \u03b9 \u2192 Type*} [\u03a0 i, topological_space (\u03c3 i)]\n\n/-- `(\u03a3 i, \u03c3 i) \u00d7 \u03b2` is homeomorphic to `\u03a3 i, (\u03c3 i \u00d7 \u03b2)`. -/\ndef sigma_prod_distrib : ((\u03a3 i, \u03c3 i) \u00d7 \u03b2) \u2243\u209c (\u03a3 i, (\u03c3 i \u00d7 \u03b2)) :=\nhomeomorph.symm $\nhomeomorph_of_continuous_open (equiv.sigma_prod_distrib \u03c3 \u03b2).symm\n  (continuous_sigma $ \u03bb i,\n    (continuous_sigma_mk.comp continuous_fst).prod_mk continuous_snd)\n  (is_open_map_sigma $ \u03bb 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 : \u03b1 \u2243\u209c \u03b2) (s : set \u03b1) : s \u2243\u209c 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 \u27f6 S`,\n  then `restrict_scalars : Module S \u2964 Module R` is defined by `M \u21a6 M` where `M : S-module` is seen\n  as `R-module` by `r \u2022 m := f r \u2022 m` and `S`-linear map `l : M \u27f6 M'` is `R`-linear as well.\n\n* `category_theory.Module.extend_scalars`: given **commutative** rings `R, S` and ring homomorphism\n  `f : R \u27f6 S`, then `extend_scalars : Module R \u2964 Module S` is defined by `M \u21a6 S \u2a02 M` where the\n  module structure is defined by `s \u2022 (s' \u2297 m) := (s * s') \u2297 m` and `R`-linear map `l : M \u27f6 M'`\n  is sent to `S`-linear map `s \u2297 m \u21a6 s \u2297 l m : S \u2a02 M \u27f6 S \u2a02 M'`.\n\n## List of notations\nLet `R, S` be rings and `f : R \u2192+* S`\n* if `M` is an `R`-module, `s : S` and `m : M`, then `s \u2297\u209c[R, f] m` is the pure tensor\n  `s \u2297 m : S \u2297[R, f] M`.\n-/\n\n\nnamespace CategoryTheory.Module\n\nuniverse v u\u2081 u\u2082\n\nnamespace RestrictScalars\n\nvariable {R : Type u\u2081} {S : Type u\u2082} [Ring R] [Ring S] (f : R \u2192+* S)\n\nvariable (M : ModuleCat.{v} S)\n\n/-- Any `S`-module M is also an `R`-module via a ring homomorphism `f : R \u27f6 S` by defining\n    `r \u2022 m := f r \u2022 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 \u2192 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 \u27f6 M') : obj' f M \u27f6 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 \u2192+* S` a ring homomorphism,\n* an `S`-module `M` can be considered as `R`-module by `r \u2022 m = f r \u2022 m`\n* an `S`-linear map is also `R`-linear\n-/\ndef restrictScalars {R : Type u\u2081} {S : Type u\u2082} [Ring R] [Ring S] (f : R \u2192+* S) :\n    ModuleCat.{v} S \u2964 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\u2081} {S : Type u\u2082} [Ring R] [Ring S] (f : R \u2192+* S)\n    {M M' : ModuleCat.{v} S} (g : M \u27f6 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\u2081} {S : Type u\u2082} [Ring R] [Ring S] (f : R \u2192+* S)\n    {M : ModuleCat.{v} S} (r : R) (m : (restrictScalars f).obj M) : r \u2022 m = (f r \u2022 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\u2081} {S : Type u\u2082} [Ring R] [Ring S] (f : R \u2192+* S)\n    {M : ModuleCat.{v} S} (r : R) (m : M) : (r \u2022 m : (restrictScalars f).obj M) = (f r \u2022 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\u2081} {S : Type u\u2082} [Ring R] [CommRing S]\n    (f : R \u2192+* 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 [\u2190 mul_smul, mul_comm] : f r \u2022 s \u2022 m = s \u2022 f r \u2022 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\u2081} {S : Type u\u2082} [CommRing R] [CommRing S] (f : R \u2192+* S)\n\nsection Unbundled\n\nvariable (M : Type v) [AddCommMonoid M] [Module R M]\n\n-- mathport name: \u00abexpr \u2297\u209c[ , ] \u00bb\n-- This notation is necessary because we need to reason about `s \u2297\u209c m` where `s : S` and `m : M`;\n-- without this notation, one need to work with `s : (restrict_scalars f).obj \u27e8S\u27e9`.\nscoped[ChangeOfRings]\n  notation s \"\u2297\u209c[\" 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 \u21a6 S \u2a02 M\n-/\ndef obj' : ModuleCat S :=\n  \u27e8TensorProduct R ((restrictScalars f).obj \u27e8S\u27e9) M\u27e9\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 \u2297 M` and\n`l : M1 \u27f6 M2` is sent to `s \u2297 m \u21a6 s \u2297 l m`\n-/\ndef map' {M1 M2 : ModuleCat.{v} R} (l : M1 \u27f6 M2) : obj' f M1 \u27f6 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 (\ud835\udfd9 M) = \ud835\udfd9 _ :=\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    \u00b7 simp only [map_zero]\n    \u00b7 rw [LinearMap.baseChange_tmul, ModuleCat.id_apply]\n    \u00b7 rw [map_add, ihx, ihy]\n#align category_theory.Module.extend_scalars.map'_id CategoryTheory.Module.ExtendScalars.map'_id\n\ntheorem map'_comp {M\u2081 M\u2082 M\u2083 : ModuleCat.{v} R} (l\u2081\u2082 : M\u2081 \u27f6 M\u2082) (l\u2082\u2083 : M\u2082 \u27f6 M\u2083) :\n    map' f (l\u2081\u2082 \u226b l\u2082\u2083) = map' f l\u2081\u2082 \u226b map' f l\u2082\u2083 :=\n  LinearMap.ext fun x : obj' f M\u2081 => by\n    dsimp only [map']\n    induction' x using TensorProduct.induction_on with _ _ x y ihx ihy\n    \u00b7 rfl\n    \u00b7 rfl\n    \u00b7 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 \u2297 M` and\n`l : M1 \u27f6 M2` is sent to `s \u2297 m \u21a6 s \u2297 l m`\n-/\ndef extendScalars {R : Type u\u2081} {S : Type u\u2082} [CommRing R] [CommRing S] (f : R \u2192+* S) :\n    ModuleCat.{v} R \u2964 ModuleCat.{max v u\u2082} 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\u2081} {S : Type u\u2082} [CommRing R] [CommRing S] (f : R \u2192+* S)\n\n@[simp]\nprotected theorem smul_tmul {M : ModuleCat.{v} R} (s s' : S) (m : M) :\n    s \u2022 (s'\u2297\u209c[R,f]m : (extendScalars f).obj M) = (s * s')\u2297\u209c[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 \u27f6 M') (s : S) (m : M) :\n    (extendScalars f).map g (s\u2297\u209c[R,f]m) = s\u2297\u209c[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\u2081 w\u2082\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' : \u2200 {x y}, x \u2208 carrier \u2192 y \u2208 carrier \u2192 \u2045x, y\u2046 \u2208 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\u27e8{ lie_mem' := \u03bb 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) }\u27e9\n\ninstance : inhabited (lie_subalgebra R L) := \u27e80\u27e9\ninstance : has_coe (lie_subalgebra R L) (submodule R L) := \u27e8lie_subalgebra.to_submodule\u27e9\ninstance : has_mem L (lie_subalgebra R L) := \u27e8\u03bb x L', x \u2208 (L' : set L)\u27e9\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      := \u03bb x y, \u27e8\u2045x.val, y.val\u2046, L'.lie_mem' x.property y.property\u27e9,\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\u2081 : Type*} [semiring R\u2081]\n\n/-- A Lie subalgebra inherits module structures from `L`. -/\ninstance [has_scalar R\u2081 R] [module R\u2081 L] [is_scalar_tower R\u2081 R L]\n  (L' : lie_subalgebra R L) : module R\u2081 L' :=\nL'.to_submodule.module'\n\ninstance [has_scalar R\u2081 R] [has_scalar R\u2081\u1d50\u1d52\u1d56 R] [module R\u2081 L] [module R\u2081\u1d50\u1d52\u1d56 L]\n  [is_scalar_tower R\u2081 R L] [is_scalar_tower R\u2081\u1d50\u1d52\u1d56 R L] [is_central_scalar R\u2081 L]\n  (L' : lie_subalgebra R L) : is_central_scalar R\u2081 L' :=\nL'.to_submodule.is_central_scalar\n\ninstance [has_scalar R\u2081 R] [module R\u2081 L] [is_scalar_tower R\u2081 R L]\n  (L' : lie_subalgebra R L) : is_scalar_tower R\u2081 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) \u2208 L' := (L' : submodule R L).zero_mem\n\nlemma smul_mem (t : R) {x : L} (h : x \u2208 L') : t \u2022 x \u2208 L' := (L' : submodule R L).smul_mem t h\n\nlemma add_mem {x y : L} (hx : x \u2208 L') (hy : y \u2208 L') : (x + y : L) \u2208 L' :=\n(L' : submodule R L).add_mem hx hy\n\nlemma sub_mem {x y : L} (hx : x \u2208 L') (hy : y \u2208 L') : (x - y : L) \u2208 L' :=\n(L' : submodule R L).sub_mem hx hy\n\n@[simp] lemma neg_mem_iff {x : L} : -x \u2208 L' \u2194 x \u2208 L' := L'.to_submodule.neg_mem_iff\n\nlemma lie_mem {x y : L} (hx : x \u2208 L') (hy : y \u2208 L') : (\u2045x, y\u2046 : L) \u2208 L' := L'.lie_mem' hx hy\n\n@[simp] lemma mem_carrier {x : L} : x \u2208 L'.carrier \u2194 x \u2208 (L' : set L) := iff.rfl\n\n@[simp] lemma mem_mk_iff (S : set L) (h\u2081 h\u2082 h\u2083 h\u2084) {x : L} :\n  x \u2208 (\u27e8\u27e8S, h\u2081, h\u2082, h\u2083\u27e9, h\u2084\u27e9 : lie_subalgebra R L) \u2194 x \u2208 S :=\niff.rfl\n\n@[simp] lemma mem_coe_submodule {x : L} : x \u2208 (L' : submodule R L) \u2194 x \u2208 L' := iff.rfl\n\nlemma mem_coe {x : L} : x \u2208 (L' : set L) \u2194 x \u2208 L' := iff.rfl\n\n@[simp, norm_cast] lemma coe_bracket (x y : L') : (\u2191\u2045x, y\u2046 : L) = \u2045(\u2191x : L), \u2191y\u2046 := rfl\n\nlemma ext_iff (x y : L') : x = y \u2194 (x : L) = y := subtype.ext_iff\n\nlemma coe_zero_iff_zero (x : L') : (x : L) = 0 \u2194 x = 0 := (ext_iff L' x 0).symm\n\n@[ext] lemma ext (L\u2081' L\u2082' : lie_subalgebra R L) (h : \u2200 x, x \u2208 L\u2081' \u2194 x \u2208 L\u2082') :\n  L\u2081' = L\u2082' :=\nby { cases L\u2081', cases L\u2082', simp only [], ext x, exact h x, }\n\nlemma ext_iff' (L\u2081' L\u2082' : lie_subalgebra R L) : L\u2081' = L\u2082' \u2194 \u2200 x, x \u2208 L\u2081' \u2194 x \u2208 L\u2082' :=\n\u27e8\u03bb h x, by rw h, ext L\u2081' L\u2082'\u27e9\n\n@[simp] lemma mk_coe (S : set L) (h\u2081 h\u2082 h\u2083 h\u2084) :\n  ((\u27e8\u27e8S, h\u2081, h\u2082, h\u2083\u27e9, h\u2084\u27e9 : 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 \u2192 set L) :=\nby { rintro \u27e8\u27e8\u27e9\u27e9 \u27e8\u27e8\u27e9\u27e9 h, congr' }\n\ninstance : set_like (lie_subalgebra R L) L := \u27e8coe, coe_injective\u27e9\n\n@[norm_cast] theorem coe_set_eq (L\u2081' L\u2082' : lie_subalgebra R L) :\n  (L\u2081' : set L) = L\u2082' \u2194 L\u2081' = L\u2082' := coe_injective.eq_iff\n\nlemma to_submodule_injective :\n  function.injective (coe : lie_subalgebra R L \u2192 submodule R L) :=\n\u03bb L\u2081' L\u2082' h, by { rw set_like.ext'_iff at h, rw \u2190 coe_set_eq, exact h, }\n\n@[simp] lemma coe_to_submodule_eq_iff (L\u2081' L\u2082' : lie_subalgebra R L) :\n  (L\u2081' : submodule R L) = (L\u2082' : submodule R L) \u2194 L\u2081' = L\u2082' :=\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\u2081} [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' \u2286 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     := \u03bb x m, \u2045(x : L), m\u2046,\n  add_lie     := \u03bb x y m, add_lie x y m,\n  lie_add     := \u03bb x y m, lie_add x y m,\n  leibniz_lie := \u03bb x y m, leibniz_lie x y m, }\n\n@[simp] lemma coe_bracket_of_module (x : L') (m : M) : \u2045x, m\u2046 = \u2045(x : L), m\u2046 := rfl\n\nvariables [module R M] [lie_module R L M]\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' \u2286 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 := \u03bb t x m, by simp only [coe_bracket_of_module, smul_lie, submodule.coe_smul_of_tower],\n  lie_smul := \u03bb t x m, by simp only [coe_bracket_of_module, lie_smul], }\n\n/-- An `L`-equivariant map of Lie modules `M \u2192 N` is `L'`-equivariant for any Lie subalgebra\n`L' \u2286 L`. -/\ndef _root_.lie_module_hom.restrict_lie (f : M \u2192\u2097\u2045R,L\u2046 N) (L' : lie_subalgebra R L) : M \u2192\u2097\u2045R,L'\u2046 N :=\n{ map_lie' := \u03bb x m, f.map_lie \u2191x m,\n  .. (f : M \u2192\u2097[R] N)}\n\n@[simp] lemma _root_.lie_module_hom.coe_restrict_lie (f : M \u2192\u2097\u2045R,L\u2046 N) :\n  \u21d1(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' \u2192\u2097\u2045R\u2046 L :=\n{ map_lie' := \u03bb 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 : \u21d1L'.incl = coe := rfl\n\n/-- The embedding of a Lie subalgebra into the ambient space as a morphism of Lie modules. -/\ndef incl' : L' \u2192\u2097\u2045R,L'\u2046 L :=\n{ map_lie' := \u03bb 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' : \u21d1L'.incl' = coe := rfl\n\nend lie_subalgebra\n\nvariables {R L} {L\u2082 : Type w} [lie_ring L\u2082] [lie_algebra R L\u2082]\nvariables (f : L \u2192\u2097\u2045R\u2046 L\u2082)\n\nnamespace lie_hom\n\n/-- The range of a morphism of Lie algebras is a Lie subalgebra. -/\ndef range : lie_subalgebra R L\u2082 :=\n{ lie_mem' := \u03bb x y,\n    show x \u2208 f.to_linear_map.range \u2192 y \u2208 f.to_linear_map.range \u2192 \u2045x, y\u2046 \u2208 f.to_linear_map.range,\n    by { repeat { rw linear_map.mem_range }, rintros \u27e8x', hx\u27e9 \u27e8y', hy\u27e9, refine \u27e8\u2045x', y'\u2046, _\u27e9,\n         rw [\u2190hx, \u2190hy], change f \u2045x', y'\u2046 = \u2045f x', f y'\u2046, rw map_lie, },\n  ..(f : L \u2192\u2097[R] L\u2082).range }\n\n@[simp] lemma range_coe : (f.range : set L\u2082) = set.range f :=\nlinear_map.range_coe \u2191f\n\n@[simp] lemma mem_range (x : L\u2082) : x \u2208 f.range \u2194 \u2203 (y : L), f y = x := linear_map.mem_range\n\nlemma mem_range_self (x : L) : f x \u2208 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 \u2192\u2097\u2045R\u2046 f.range :=\n{ map_lie' := \u03bb x y, by { apply subtype.ext, exact f.map_lie x y, },\n  ..(f : L \u2192\u2097[R] L\u2082).range_restrict, }\n\n@[simp] lemma range_restrict_apply (x : L) : f.range_restrict x = \u27e8f x, f.mem_range_self x\u27e9 := rfl\n\nlemma surjective_range_restrict : function.surjective (f.range_restrict) :=\nbegin\n  rintros \u27e8y, hy\u27e9,\n  erw mem_range at hy, obtain \u27e8x, rfl\u27e9 := 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 \u2243\u2097\u2045R\u2046 f.range :=\nlie_equiv.of_bijective f.range_restrict (\u03bb 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 = \u27e8f x, mem_range_self f x\u27e9 :=\nrfl\n\nend lie_hom\n\nlemma submodule.exists_lie_subalgebra_coe_eq_iff (p : submodule R L) :\n  (\u2203 (K : lie_subalgebra R L), \u2191K = p) \u2194 \u2200 (x y : L), x \u2208 p \u2192 y \u2208 p \u2192 \u2045x, y\u2046 \u2208 p :=\nbegin\n  split,\n  { rintros \u27e8K, rfl\u27e9, 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\u2082 : lie_subalgebra R L\u2082)\n\n@[simp] lemma incl_range : K.incl.range = K :=\nby { rw \u2190 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\u2082 :=\n{ lie_mem' := \u03bb x y hx hy, by\n  { erw submodule.mem_map at hx, rcases hx with \u27e8x', hx', hx\u27e9, rw \u2190hx,\n    erw submodule.mem_map at hy, rcases hy with \u27e8y', hy', hy\u27e9, rw \u2190hy,\n    erw submodule.mem_map,\n    exact \u27e8\u2045x', y'\u2046, K.lie_mem hx' hy', f.map_lie x' y'\u27e9, },\n..((K : submodule R L).map (f : L \u2192\u2097[R] L\u2082)) }\n\n@[simp] lemma mem_map (x : L\u2082) : x \u2208 K.map f \u2194 \u2203 (y : L), y \u2208 K \u2227 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 \u2243\u2097\u2045R\u2046 L\u2082) (x : L\u2082) :\n  x \u2208 K.map (e : L \u2192\u2097\u2045R\u2046 L\u2082) \u2194 x \u2208 (K : submodule R L).map (e : L \u2192\u2097[R] L\u2082) :=\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' := \u03bb x y hx hy, by\n    { suffices : \u2045f x, f y\u2046 \u2208 K\u2082, by { simp [this], }, exact K\u2082.lie_mem hx hy, },\n  ..((K\u2082 : submodule R L\u2082).comap (f : L \u2192\u2097[R] L\u2082)), }\n\nsection lattice_structure\n\nopen set\n\ninstance : partial_order (lie_subalgebra R L) :=\n{ le := \u03bb N N', \u2200 \u2983x\u2984, x \u2208 N \u2192 x \u2208 N', -- Overriding `le` like this gives a better defeq.\n  ..partial_order.lift (coe : lie_subalgebra R L \u2192 set L) coe_injective }\n\nlemma le_def : K \u2264 K' \u2194 (K : set L) \u2286 K' := iff.rfl\n\n@[simp, norm_cast] lemma coe_submodule_le_coe_submodule : (K : submodule R L) \u2264 K' \u2194 K \u2264 K' :=\niff.rfl\n\ninstance : has_bot (lie_subalgebra R L) := \u27e80\u27e9\n\n@[simp] lemma bot_coe : ((\u22a5 : lie_subalgebra R L) : set L) = {0} := rfl\n\n@[simp] lemma bot_coe_submodule : ((\u22a5 : lie_subalgebra R L) : submodule R L) = \u22a5 := rfl\n\n@[simp] lemma mem_bot (x : L) : x \u2208 (\u22a5 : lie_subalgebra R L) \u2194 x = 0 := mem_singleton_iff\n\ninstance : has_top (lie_subalgebra R L) :=\n\u27e8{ lie_mem' := \u03bb x y hx hy, mem_univ \u2045x, y\u2046,\n   ..(\u22a4 : submodule R L) }\u27e9\n\n@[simp] lemma top_coe : ((\u22a4 : lie_subalgebra R L) : set L) = univ := rfl\n\n@[simp] lemma top_coe_submodule : ((\u22a4 : lie_subalgebra R L) : submodule R L) = \u22a4 := rfl\n\n@[simp] lemma mem_top (x : L) : x \u2208 (\u22a4 : lie_subalgebra R L) := mem_univ x\n\nlemma _root_.lie_hom.range_eq_map : f.range = map f \u22a4 :=\nby { ext, simp }\n\ninstance : has_inf (lie_subalgebra R L) :=\n\u27e8\u03bb K K', { lie_mem' := \u03bb x y hx hy, mem_inter (K.lie_mem hx.1 hy.1) (K'.lie_mem hx.2 hy.2),\n            ..(K \u2293 K' : submodule R L) }\u27e9\n\ninstance : has_Inf (lie_subalgebra R L) :=\n\u27e8\u03bb S, { lie_mem' := \u03bb 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\u2082, 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 \u2208 S} }\u27e9\n\n@[simp] theorem inf_coe : (\u2191(K \u2293 K') : set L) = K \u2229 K' := rfl\n\n@[simp] lemma Inf_coe_to_submodule (S : set (lie_subalgebra R L)) :\n  (\u2191(Inf S) : submodule R L) = Inf {(s : submodule R L) | s \u2208 S} := rfl\n\n@[simp] lemma Inf_coe (S : set (lie_subalgebra R L)) : (\u2191(Inf S) : set L) = \u22c2 s \u2208 S, (s : set L) :=\nbegin\n  rw [\u2190 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\u2082, exists_imp_distrib],\nend\n\nlemma Inf_glb (S : set (lie_subalgebra R L)) : is_glb S (Inf S) :=\nbegin\n  have h : \u2200 (K K' : lie_subalgebra R L), (K : set L) \u2264 K' \u2194 K \u2264 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          := \u22a5,\n  bot_le       := \u03bb N _ h, by { rw mem_bot at h, rw h, exact N.zero_mem', },\n  top          := \u22a4,\n  le_top       := \u03bb _ _ _, trivial,\n  inf          := (\u2293),\n  le_inf       := \u03bb N\u2081 N\u2082 N\u2083 h\u2081\u2082 h\u2081\u2083 m hm, \u27e8h\u2081\u2082 hm, h\u2081\u2083 hm\u27e9,\n  inf_le_left  := \u03bb _ _ _, and.left,\n  inf_le_right := \u03bb _ _ _, and.right,\n  ..complete_lattice_of_Inf _ Inf_glb }\n\ninstance : add_comm_monoid (lie_subalgebra R L) :=\n{ add       := (\u2294),\n  add_assoc := \u03bb _ _ _, sup_assoc,\n  zero      := \u22a5,\n  zero_add  := \u03bb _, bot_sup_eq,\n  add_zero  := \u03bb _, sup_bot_eq,\n  add_comm  := \u03bb _ _, sup_comm, }\n\n@[simp] lemma add_eq_sup : K + K' = K \u2294 K' := rfl\n\n@[norm_cast, simp] lemma inf_coe_to_submodule :\n  (\u2191(K \u2293 K') : submodule R L) = (K : submodule R L) \u2293 (K' : submodule R L) := rfl\n\n@[simp] lemma mem_inf (x : L) : x \u2208 K \u2293 K' \u2194 x \u2208 K \u2227 x \u2208 K' :=\nby rw [\u2190 mem_coe_submodule, \u2190 mem_coe_submodule, \u2190 mem_coe_submodule, inf_coe_to_submodule,\n  submodule.mem_inf]\n\nlemma eq_bot_iff : K = \u22a5 \u2194 \u2200 (x : L), x \u2208 K \u2192 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 \u21a5(\u22a5 : lie_subalgebra R L)) :=\nbegin\n  apply subsingleton_of_bot_eq_top,\n  ext \u27e8x, hx\u27e9, change x \u2208 \u22a5 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 \u2192 lie_subalgebra R L \u2192 Prop) :=\n  let f : ((>) : lie_subalgebra R L \u2192 lie_subalgebra R L \u2192 Prop) \u2192r\n          ((>) : submodule R L \u2192 submodule R L \u2192 Prop) :=\n  { to_fun       := coe,\n    map_rel' := \u03bb 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 \u2264 K')\n\n/-- Given two nested Lie subalgebras `K \u2286 K'`, the inclusion `K \u21aa K'` is a morphism of Lie\nalgebras. -/\ndef hom_of_le : K \u2192\u2097\u2045R\u2046 K' :=\n{ map_lie' := \u03bb 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 = \u27e8x.1, h x.2\u27e9 := rfl\n\nlemma hom_of_le_injective : function.injective (hom_of_le h) :=\n\u03bb 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 \u2286 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 \u2208 of_le h \u2194 (x : L) \u2208 K :=\nbegin\n  simp only [of_le, hom_of_le_apply, lie_hom.mem_range],\n  split,\n  { rintros \u27e8y, rfl\u27e9, exact y.property, },\n  { intros h, use \u27e8(x : L), h\u27e9, 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 \u2286 K'`, there is a natural equivalence from `K` to its image in\n`K'`.  -/\nnoncomputable def equiv_of_le : K \u2243\u2097\u2045R\u2046 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\u2082} :\n  map f K \u2264 K' \u2194 K \u2264 comap f K' := set.image_subset_iff\n\nlemma gc_map_comap : galois_connection (map f) (comap f) := \u03bb 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 \u2286 L`. -/\ndef lie_span : lie_subalgebra R L := Inf {N | s \u2286 N}\n\nvariables {R L s}\n\nlemma mem_lie_span {x : L} : x \u2208 lie_span R L s \u2194 \u2200 K : lie_subalgebra R L, s \u2286 K \u2192 x \u2208 K :=\nby { change x \u2208 (lie_span R L s : set L) \u2194 _, erw Inf_coe, exact set.mem_Inter\u2082, }\n\nlemma subset_lie_span : s \u2286 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 \u2264 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 \u2264 K \u2194 s \u2286 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 \u2286 t) : lie_span R L s \u2264 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 \u2194 \u2203 (K : lie_subalgebra R L), \u2191K = p :=\nbegin\n  rw p.exists_lie_subalgebra_coe_eq_iff, split; intros h,\n  { intros x m hm, rw [\u2190 h, mem_coe_submodule], exact lie_mem _ (subset_lie_span hm), },\n  { rw [\u2190 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 \u2192 lie_subalgebra R L) coe :=\n{ choice    := \u03bb s _, lie_span R L s,\n  gc        := \u03bb s t, lie_span_le,\n  le_l_u    := \u03bb s, subset_lie_span,\n  choice_eq := \u03bb s h, rfl }\n\n@[simp] lemma span_empty : lie_span R L (\u2205 : set L) = \u22a5 :=\n(lie_subalgebra.gi R L).gc.l_bot\n\n@[simp] lemma span_univ : lie_span R L (set.univ : set L) = \u22a4 :=\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 \u222a t) = lie_span R L s \u2294 lie_span R L t :=\n(lie_subalgebra.gi R L).gc.l_sup\n\nlemma span_Union {\u03b9} (s : \u03b9 \u2192 set L) : lie_span R L (\u22c3 i, s i) = \u2a06 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\u2081 : Type v} {L\u2082 : Type w}\nvariables [comm_ring R] [lie_ring L\u2081] [lie_ring L\u2082] [lie_algebra R L\u2081] [lie_algebra R L\u2082]\n\n/-- An injective Lie algebra morphism is an equivalence onto its range. -/\nnoncomputable def of_injective (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h : function.injective f) :\n  L\u2081 \u2243\u2097\u2045R\u2046 f.range :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, simpa, },\n..(linear_equiv.of_injective \u2191f $ by rwa [lie_hom.coe_to_linear_map])}\n\n@[simp] lemma of_injective_apply (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h : function.injective f) (x : L\u2081) :\n  \u2191(of_injective f h x) = f x := rfl\n\nvariables (L\u2081' L\u2081'' : lie_subalgebra R L\u2081) (L\u2082' : lie_subalgebra R L\u2082)\n\n/-- Lie subalgebras that are equal as sets are equivalent as Lie algebras. -/\ndef of_eq (h : (L\u2081' : set L\u2081) = L\u2081'') : L\u2081' \u2243\u2097\u2045R\u2046 L\u2081'' :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, simp, },\n  ..(linear_equiv.of_eq \u2191L\u2081' \u2191L\u2081''\n      (by {ext x, change x \u2208 (L\u2081' : set L\u2081) \u2194 x \u2208 (L\u2081'' : set L\u2081), rw h, } )) }\n\n@[simp] lemma of_eq_apply (L L' : lie_subalgebra R L\u2081) (h : (L : set L\u2081) = L') (x : L) :\n  (\u2191(of_eq L L' h x) : L\u2081) = x := rfl\n\nvariables (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082)\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef lie_subalgebra_map : L\u2081'' \u2243\u2097\u2045R\u2046 (L\u2081''.map e : lie_subalgebra R L\u2082) :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, exact lie_hom.map_lie (\u2191e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) \u2191x \u2191y, }\n  ..(linear_equiv.submodule_map (e : L\u2081 \u2243\u2097[R] L\u2082) \u2191L\u2081'') }\n\n@[simp] lemma lie_subalgebra_map_apply (x : L\u2081'') : \u2191(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\u2081'.map \u2191e = L\u2082') : L\u2081' \u2243\u2097\u2045R\u2046 L\u2082' :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, exact lie_hom.map_lie (\u2191e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) \u2191x \u2191y, },\n  ..(linear_equiv.of_submodules (e : L\u2081 \u2243\u2097[R] L\u2082) \u2191L\u2081' \u2191L\u2082' (by { rw \u2190h, refl, })) }\n\n@[simp] lemma of_subalgebras_apply (h : L\u2081'.map \u2191e = L\u2082') (x : L\u2081') :\n  \u2191(e.of_subalgebras _ _ h x) = e x := rfl\n\n@[simp] lemma of_subalgebras_symm_apply (h : L\u2081'.map \u2191e = L\u2082') (x : L\u2082') :\n  \u2191((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 \u27f6 G`, a morphism between presieves, and `s : G.obj (op U)`, this is the sieve\nof `U` consisting of the `i : V \u27f6 U` such that `s` restricted along `i` is in the image of `f`. -/\n@[simps (config := lemmasOnly)]\ndef imageSieve {F G : C\u1d52\u1d56 \u2964 A} (f : F \u27f6 G) {U : C} (s : G.obj (op U)) : Sieve U\n    where\n  arrows V i := \u2203 t : F.obj (op V), f.app _ t = G.map i.op s\n  downward_closed' := by\n    rintro V W i \u27e8t, ht\u27e9 j\n    refine' \u27e8F.map j.op t, _\u27e9\n    rw [op_comp, G.map_comp, comp_apply, \u2190 ht, elementwise_of f.naturality]\n#align category_theory.image_sieve CategoryTheory.imageSieve\n\ntheorem imageSieve_eq_sieveOfSection {F G : C\u1d52\u1d56 \u2964 A} (f : F \u27f6 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\u1d52\u1d56 \u2964 A} (f : F \u27f6 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\u1d52\u1d56 \u2964 A} (f : F \u27f6 G) {U : C} (s : F.obj (op U)) :\n    imageSieve f (f.app _ s) = \u22a4 := 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 \u27e8F.map i.op s, this s\u27e9\n#align category_theory.image_sieve_app CategoryTheory.imageSieve_app\n\n/-- A morphism of presheaves `f : F \u27f6 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\u1d52\u1d56 \u2964 A} (f : F \u27f6 G) : Prop :=\n  \u2200 (U : C) (s : G.obj (op U)), imageSieve f s \u2208 J U\n#align category_theory.is_locally_surjective CategoryTheory.IsLocallySurjective\n\ntheorem isLocallySurjective_iff_imagePresheaf_sheafify_eq_top {F G : C\u1d52\u1d56 \u2964 A} (f : F \u27f6 G) :\n    IsLocallySurjective J f \u2194 (imagePresheaf (whiskerRight f (forget A))).sheafify J = \u22a4 :=\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 \u27e8fun H U => H (unop U), fun H U => H (op U)\u27e9\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\u1d52\u1d56 \u2964 Type w} (f : F \u27f6 G) :\n    IsLocallySurjective J f \u2194 (imagePresheaf f).sheafify J = \u22a4 :=\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 \u27e8fun H U => H (unop U), fun H U => H (op U)\u27e9\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 \u27f6 G) :\n    IsLocallySurjective J f.1 \u2194 IsIso (imageSheaf\u03b9 f) :=\n  by\n  rw [image_sheaf_\u03b9, is_locally_surjective_iff_image_presheaf_sheafify_eq_top',\n    subpresheaf.eq_top_iff_is_iso]\n  exact\n    \u27e8fun h => @is_iso_of_reflects_iso _ _ (image_sheaf_\u03b9 f) (Sheaf_to_presheaf J _) h _, fun h =>\n      @functor.map_is_iso _ _ (Sheaf_to_presheaf J _) _ h\u27e9\n#align category_theory.is_locally_surjective_iff_is_iso CategoryTheory.isLocallySurjective_iff_isIso\n\ntheorem isLocallySurjective_iff_whisker_forget {F G : C\u1d52\u1d56 \u2964 A} (f : F \u27f6 G) :\n    IsLocallySurjective J f \u2194 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\u1d52\u1d56 \u2964 A} (f : F \u27f6 G)\n    (H : \u2200 U, Function.Surjective (f.app U)) : IsLocallySurjective J f :=\n  by\n  intro U s\n  obtain \u27e8t, rfl\u27e9 := 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\u1d52\u1d56 \u2964 A} (f : F \u27f6 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 [\u2190 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\u2081 F\u2082 F\u2083 : C\u1d52\u1d56 \u2964 A} {f\u2081 : F\u2081 \u27f6 F\u2082} {f\u2082 : F\u2082 \u27f6 F\u2083}\n    (h\u2081 : IsLocallySurjective J f\u2081) (h\u2082 : IsLocallySurjective J f\u2082) :\n    IsLocallySurjective J (f\u2081 \u226b f\u2082) := by\n  intro U s\n  have :\n    (sieve.bind (image_sieve f\u2082 s) fun _ _ h => image_sieve f\u2081 h.some) \u2264 image_sieve (f\u2081 \u226b f\u2082) s :=\n    by\n    rintro V i \u27e8W, i, j, H, \u27e8t', ht'\u27e9, rfl\u27e9\n    refine' \u27e8t', _\u27e9\n    rw [op_comp, F\u2083.map_comp, nat_trans.comp_app, comp_apply, comp_apply, ht',\n      elementwise_of f\u2082.naturality, H.some_spec]\n  apply J.superset_covering this\n  apply J.bind_covering\n  \u00b7 apply h\u2082\n  \u00b7 intros\n    apply h\u2081\n#align category_theory.is_locally_surjective.comp CategoryTheory.IsLocallySurjective.comp\n\nsection\n\nvariable (F : C\u1d52\u1d56 \u2964 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 \u2245 ((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.\u03b9 _\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 [\u2190 cancel_mono (subpresheaf.\u03b9 _), 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  [\u2200 X : C, Limits.HasColimitsOfShape (J.cover X)\u1d52\u1d56 B]\n  [\u2200 (P : C\u1d52\u1d56 \u2964 B) (X : C) (S : J.cover X), Limits.HasMultiequalizer (S.index P)]\n  [\u2200 (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 B),\n      Limits.PreservesLimit (W.index P).multicospan (forget B)]\n  [\u2200 X : C, Limits.PreservesColimitsOfShape (J.cover X)\u1d52\u1d56 (forget B)]\n  [\u2200 (\u03b1 \u03b2 : Type max u v) (fst snd : \u03b2 \u2192 \u03b1),\n      Limits.HasLimitsOfShape (Limits.WalkingMulticospan fst snd) B]\n\ntheorem toSheafify_isLocallySurjective (F : C\u1d52\u1d56 \u2964 B) : IsLocallySurjective J (J.toSheafify F) :=\n  by\n  rw [is_locally_surjective_iff_whisker_forget, \u2190 to_sheafify_comp_sheafify_comp_iso_inv]\n  apply is_locally_surjective.comp\n  \u00b7 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 \u22d9 forget B))\n  \u00b7 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 | \u2203s, 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    (\u2200 x, (r.lookup x).is_some \u2192 \u2203 y, (\u2983y\u2984 \u2208 r.lookup x)) \u2227\n    -- r is injective\n    (\u2200 x y, r.lookup x = r.lookup y \u2192 \n           (r.lookup x).is_some \u2192 (r.lookup y).is_some \u2192 x = y) }\n\ndef rename.apply (r : rename vars) := subst.apply (r.val)\n\ndef rename.union (r\u2081 r\u2082 : rename vars) : rename vars := \u27e8r\u2081.val \u222a r\u2082.val, sorry\u27e9\n\ninstance : has_union (rename vars) := \u27e8rename.union\u27e9\ninstance : has_mem vars (rename vars) := \u27e8\u03bb x r, x \u2208 r.val\u27e9\ninstance : has_emptyc (rename vars) := \u27e8\u27e8\u2205, by simp\u27e9\u27e9\n\nuniverses u v\n\n@[simp]\ntheorem list.lookup_cons_not_mem {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v} [decidable_eq \u03b1]\n(l : list (sigma \u03b2)) {a : \u03b1} (s : sigma \u03b2) \n: a \u2209 l.keys \u2192 ((list.lookup a (s :: l)).is_some \u2194 a = s.fst) :=\nbegin\n  rcases s with \u27e8s_fst, s_snd\u27e9,\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  : \u2203 (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 \u22a2 h,\n    specialize h B,\n    cases h.mpr \u27e8\u2205, subst.apply_empty_id\u27e9 with _ this,\n    exact \u27e8\u2205, this\u27e9,\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 := \u27e8\u27e8[\u27e8a, \u2983b\u2984\u27e9], (by simp)\u27e9, by {\n        simp [alist.lookup],\n        intros x y hxy hx hy,\n        rw [hx, hy]\n      }\u27e9 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 \u2983A\u2984, which contradicts h\n      exfalso,\n      cases (h \u2983a\u2984).mp \u27e8\u2205, subst.apply_empty_id\u27e9 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 \u22a2 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 : \u2200 (x : form vars), (\u2203 (s : subst vars), s.apply A = x) \u2194 \n                                (\u2203 (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 \u2983B\u2984).mpr \u27e8\u2205, subst.apply_empty_id\u27e9 with s this,\n      simp only [subst.apply] at this,\n      exact this\n    },\n    all_goals {\n      exfalso,\n      cases (h (~A)).mp \u27e8\u2205, subst.apply_empty_id\u27e9 with s this,\n      simp only [subst.apply] at this,\n      exact this\n    }\n  },\n  case form.And : A\u2081 A\u2082 ih\u2081 ih\u2082  {\n    cases B,\n    case form.And : B\u2081 B\u2082 {\n      simp only [rename.apply, subst.apply] at \u22a2 h,\n      -- Now we know that the variable x in h has to be of the form (x\u2081 \u22c0 x\u2082), \n      -- which means we can simplify it to the following:\n      have : \u2200 (x\u2081 x\u2082 : form vars), \n        (\u2203 (s : subst vars), s.apply A\u2081 = x\u2081 \u2227 s.apply A\u2082 = x\u2082) \u2194 \n        (\u2203 (s : subst vars), s.apply B\u2081 = x\u2081 \u2227 s.apply B\u2082 = x\u2082),\n        intros x\u2081 x\u2082,\n        specialize h (x\u2081 \u22c0 x\u2082),\n        simp only at h,\n        exact h,\n      have hAB\u2081 : \u2200 (x : form vars),\n        (\u2203 (s : subst vars), s.apply A\u2081 = x) \u2194\n        (\u2203 (s : subst vars), s.apply B\u2081 = x),\n        intros x,\n        split,\n        { rintro \u27e8sA\u2081, hA\u2081\u27e9,\n          obtain \u27e8sB\u2081, hB\u2081, _\u27e9 := (this x (sA\u2081.apply A\u2082)).mp \u27e8sA\u2081, hA\u2081, rfl\u27e9,\n          exact \u27e8sB\u2081, hB\u2081\u27e9\n        },\n        { rintro \u27e8sB\u2081, hB\u2081\u27e9,\n          obtain \u27e8sA\u2081, hA\u2081, _\u27e9 := (this x (sB\u2081.apply B\u2082)).mpr \u27e8sB\u2081, hB\u2081, rfl\u27e9,\n          exact \u27e8sA\u2081, hA\u2081\u27e9\n        },\n      have hAB\u2082 : \u2200 (x : form vars),\n        (\u2203 (s : subst vars), s.apply A\u2082 = x) \u2194\n        (\u2203 (s : subst vars), s.apply B\u2082 = x),\n        intros x,\n        split,\n        { rintro \u27e8sA\u2082, hA\u2082\u27e9,\n          obtain \u27e8sB\u2082, _, hB\u2082\u27e9 := (this (sA\u2082.apply A\u2081) x).mp \u27e8sA\u2082, rfl, hA\u2082\u27e9,\n          exact \u27e8sB\u2082, hB\u2082\u27e9\n        },\n        { rintro \u27e8sB\u2082, hB\u2082\u27e9,\n          obtain \u27e8sA\u2082, _, hA\u2082\u27e9 := (this (sB\u2082.apply B\u2081) x).mpr \u27e8sB\u2082, rfl, hB\u2082\u27e9,\n          exact \u27e8sA\u2082, hA\u2082\u27e9\n        },\n      obtain \u27e8r\u2081, hr\u2081\u27e9 := ih\u2081 hAB\u2081,\n      obtain \u27e8r\u2082, hr\u2082\u27e9 := ih\u2082 hAB\u2082,\n      use r\u2081 \u222a r\u2082,\n      split,\n      simp [has_union.union, rename.union, subst.apply],\n      sorry, sorry\n    },\n    case form.Var {\n      exfalso,\n      cases (h \u2983B\u2984).mpr \u27e8\u2205, subst.apply_empty_id\u27e9 with s this,\n      simp only [subst.apply] at this,\n      exact this\n    },\n    all_goals {\n      exfalso,\n      cases (h (A\u2081 \u22c0 A\u2082)).mp \u27e8\u2205, subst.apply_empty_id\u27e9 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)) := \u2200 B \u2208 S, M \u22a9 B\nnotation M ` \u22a8 ` S := eval_schema M S\nnotation M ` \u22ad ` S := \u00ac eval_schema M S\n\ndef valid_schema (S : set (form vars)) :=\n\u2200 M : model vars, M \u22a8 S\n\nexample : valid_schema (schema (\u25a1 (\u2983p\u2984 \u27f9 \u2983q\u2984) \u27f9 \u25a1 \u2983p\u2984 \u27f9 \u25a1 \u2983q\u2984)) :=\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 \u2190hC,\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 \u2192 W \u2192 Prop} {V V' : vars \u2192 set W} {w : W} \n{s : subst vars} (hM' : \u2200 x, V' x = {w | \u27eaW, R, V\u27eb @@ w \u22a9 s.get x}) \n: (\u27eaW, R, V\u27eb @@ w \u22a9 s.apply A) \u2194 (\u27eaW, R, V'\u27eb @@ w \u22a9 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\u2081 A\u2082 ih\u2081 ih\u2082 {\n    simp only [subst.apply, eval, ih\u2081, ih\u2082],\n  },\n  case form.Or : A\u2081 A\u2082 ih\u2081 ih\u2082 {\n    simp only [subst.apply, eval, ih\u2081, ih\u2082],\n  },\n  case form.Imply : A\u2081 A\u2082 ih\u2081 ih\u2082 {\n    simp only [subst.apply, eval, ih\u2081, ih\u2082],\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) \u2194 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 \u27e8\u2205, subst.apply_empty_id\u27e9 w },\n  rintros hv \u27e8\u27e8W, hnonempty, R\u27e9, V\u27e9 A' \u27e8s, rfl\u27e9 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' := \u03bb x, {w | \u27eaW, R, V\u27eb@@w \u22a9 s.get x} with hV',\n  set M' : model vars := \u27eaW, R, V'\u27eb 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 \u22a8 schema A) \u2192 (M \u22a9 A) :=\nbegin\n  intros hsA w,\n  exact hsA A \u27e8\u2205, subst.apply_empty_id\u27e9 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 := \u03bb _ _, false }, -- the frame relation doesn't matter\n  V := \u03bb 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 \u22a5 that is never true at any world. -/\ntheorem characteristic_true_but_schema_not_true {p : vars}\n  : (myM \u22a9 \u2983p\u2984) \u2227 (myM \u22ad schema \u2983p\u2984) :=\nbegin\n  split,\n  { rintro \u27e8\u27e9, simp only [eval], tauto }, -- hint told me to use tauto \n  { simp only [eval_schema, not_forall, exists_prop], \n    use \u22a5,\n    split,\n    { use \u27e8[\u27e8p, \u22a5\u27e9], by simp\u27e9, simp [subst.apply, subst.get, alist.lookup] },\n    { use \u27e8\u27e9, simp [eval] }\n  }\nend\n\n/-- Classes of models defined by a property of their frames. -/\ndef \u2102 (F_prop : \u2200 {W : Type}, (W \u2192 W \u2192 Prop) \u2192 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 \u2102_reflexive : set (model vars) :=\n \u2102 (\u03bb W R, \u2200 w, R w w)\n\n/-- Models with transitive frames -/\ndef \u2102_transitive : set (model vars) :=\n\u2102 (\u03bb W R, \u2200 w1 w2 w3, R w1 w2 \u2227 R w2 w3 \u2192 R w1 w3)\n\n/-- The general class of all models -/\ndef \u2102_all : set (model vars) := \u2102 (\u03bb _ _, true)\n\n/-- It is also possible to define a restricted notion of validity to classes of \nmodels. -/\ndef \u2102_valid (\u2102 : set (model vars)) (A : form vars) :=\n\u2200 M \u2208 \u2102, M \u22a9 A\n\ndef \u2102_schema_valid (\u2102 : set (model vars)) (\ud835\udd4a : set (form vars)) :=\n\u2200 M \u2208 \u2102, M \u22a8 \ud835\udd4a\n\n/-- We can modify the proof of valid_schema_iff_valid to adapt it to \nclass validity, but only for classes constructed by \u2102. -/\ntheorem class_valid_schema_iff_class_valid \n{F_prop : \u2200 {W : Type}, (W \u2192 W \u2192 Prop) \u2192 Prop} \n: \u2102_schema_valid (\u2102 @F_prop) (schema A) \u2194 \u2102_valid (\u2102 @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\u2102 w, exact hv M hM\u2102 A \u27e8\u2205, subst.apply_empty_id\u27e9 w },\n  rintros hv \u27e8\u27e8W, _, R\u27e9, V\u27e9 hM\u2102 A' \u27e8s, rfl\u27e9 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' := \u03bb x, {w | \u27eaW, R, V\u27eb@@w \u22a9 s.get x} with hV',\n  set M' : model vars := \u27eaW, R, V'\u27eb 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 \u2102\n  -- aserts some kind of property on R which we know to be preserved since we\n  -- use the same R.\n  have hM'\u2102 : M' \u2208 (@\u2102 vars _ @F_prop), { \n    simp only [\u2102, set.mem_set_of_eq], exact hM\u2102\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'\u2102 w),\n  exact h this,\nend\n\n/- There is a vague sense in which the formula T \u2261 \u25a1 p \u27f9 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_\u2102_valid_reflexive {p : vars} \n: \u2102_valid \u2102_reflexive (\u25a1 \u2983p\u2984 \u27f9 \u2983p\u2984) := \nbegin\n  unfold \u2102_valid,\n  intros M hM w,\n  simp only [\u2102_reflexive, \u2102, 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 := \u03bb _ _, false }, -- the frame relation is not reflexive\n  V := \u03bb x, {} -- no variable is ever true at any world\n}\n\ntheorem T_true_in_non_reflexive_model {p : vars} \n: (myM' \u22a9 \u2983p\u2984 \u27f9 \u25c7\u2983p\u2984) \u2227 (myM' \u2209 @\u2102_reflexive vars _) :=\nbegin\n  split,\n  { rintro w \u27e8\u27e9 }, -- \u27e8\u27e9 : false allows to prove anything\n  { simp [\u2102_reflexive, \u2102, 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 : \u2102_valid C A) : \u2102_valid C (\u25a1 A) :=\nbegin\n  unfold \u2102_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' \u2286 C) \n(hvA : \u2102_valid C A) : \u2102_valid C' A :=\nbegin\n  unfold \u2102_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 : \u211a \u2192 \u2124) := \u2200 (x : \u211a) (a : \u2124) (b : \u2115+), f ((x + a) / b) = f (((f x : \u211a) + a) / b)\n\n\n\nsection extra\n\nvariables {\u03b1 : Type*} [linear_ordered_ring \u03b1] [floor_ring \u03b1]\n\nlemma floor_eq_floor_iff (x y : \u03b1) : \u230ax\u230b = \u230ay\u230b \u2194 (\u2200 k : \u2124, \u2191k \u2264 x \u2194 \u2191k \u2264 y) :=\n  \u27e8\u03bb h k, by rw [\u2190 int.le_floor, h, int.le_floor],\n   \u03bb h, le_antisymm (int.le_floor.mpr ((h _).mp (int.floor_le x)))\n                    (int.le_floor.mpr ((h _).mpr (int.floor_le y)))\u27e9\n\nend extra\n\n\n\nsection results\n\nvariables {f : \u211a \u2192 \u2124} (feq : fn_eq f)\ninclude feq\n\nprivate lemma lem1 (h : f 0 = f 1) : \u2203 C : \u2124, f = const \u211a C :=\nbegin\n  suffices : \u2200 (n : \u2115) (a : \u2124) (b : \u2115+), 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 \u2115+ using h0,\n    rw [\u2190 rat.coe_int_div_eq_mk, \u2190 coe_coe, \u2190 coe_coe],\n    cases le_total 0 a with h0 h0,\n    { lift a to \u2115 using h0,\n      replace h1 := this a 0 b,\n      rw [int.cast_zero, zero_div, zero_add] at h1,\n      rw [\u2190 coe_coe, \u2190 h1] },\n    { rw \u2190 neg_nonneg at h0,\n      lift (-a) to \u2115 using h0 with x h0,\n      replace h1 := this x a b,\n      rw [h1, \u2190 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, \u2190 feq, add_comm, \u2190 int.cast_one, \u2190 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 \u2260 f 1) (m : \u2124) : f m = m :=\nbegin\n  apply le_antisymm; rw \u2190 not_lt; intros h0,\n  { lift (f m - m) to \u2115+ using (by rwa sub_pos) with k h1,\n    replace feq := feq m (-m) k,\n    rw [\u2190 int.cast_add, add_neg_self, int.cast_zero, zero_div, \u2190 int.cast_add,\n        \u2190 sub_eq_add_neg, \u2190 h1, coe_coe, int.cast_coe_nat, \u2190 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 \u2115+ using (by rwa sub_pos) with k h1,\n    replace feq := feq m (-f m) k,\n    rw [\u2190 int.cast_add, \u2190 sub_eq_add_neg, \u2190 h1, coe_coe, int.cast_coe_nat, \u2190 coe_coe,\n        div_self, \u2190 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 : \u2200 m : \u2124, f m = m) : f (1 / 2) = 0 \u2228 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 \u2115+ 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 [\u2190 sub_eq_add_neg, eq_div_iff, div_sub', coe_coe, \u2190 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, \u2190 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, \u2190 mul_one (1 + 1 : \u2124), \u2190 bit0, mul_le_mul_left],\n      exacts [h0, two_pos]\n    end,\n    lift 2 * f (1 / 2) - 1 to \u2115+ using h1 with b h1,\n    replace feq := feq (1 / 2) (f (1 / 2) - 1) b,\n    have h2 : (b : \u211a) \u2260 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, \u2190 int.cast_coe_nat, h1, int.cast_sub, int.cast_sub,\n        sub_mul, add_sub_left_comm, int.cast_one, mul_two (1 : \u211a), int.cast_mul, sub_add_cancel',\n        \u2190 sub_eq_add_neg, int.cast_two, mul_comm (2 : \u211a), div_mul_comm, mul_one],\n    exact two_ne_zero,\n    rw [\u2190 int.cast_add, \u2190 add_sub_assoc, \u2190 two_mul, \u2190 h1, coe_coe, int.cast_coe_nat,\n        \u2190 coe_coe b, div_self h2, eq_comm, \u2190 int.cast_one, h] }\nend\n\nprivate lemma lem4 (h : \u2200 m : \u2124, f m = m) (h0 : f (1 / 2) = 0)\n  (a : \u2115) (b : \u2115+) (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, \u2190 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 : \u2200 a : \u2115, a < b \u2192 f (a / \u2191(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, \u2190 bit0, h0],\n    replace h1 := pnat.exists_eq_succ_of_ne_one h1,\n    rcases h1 with \u27e8k, rfl\u27e9,\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 / \u2191(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, \u2190 coe_coe, b_ih,\n        div_add', div_div, mul_comm \u2191(k + 1 + 1), \u2190 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, \u2190 coe_coe],\n    generalize : ((k : \u2115) : \u211a) = m,\n    rw [mul_add_one, mul_add_one, add_comm (1 : \u211a), 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 : \u211a)\u207b\u00b9 + 1) / \u2191(b + 1) = (b : \u211a)\u207b\u00b9,\n    rwa [b_ih, int.cast_zero, zero_add, \u2190 coe_coe, div_eq_mul_inv (a : \u211a),\n         \u2190 mul_add_one, mul_div_assoc, this, \u2190 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, \u2190 coe_coe],\n  generalize h : ((b : \u2115) : \u211a) = k,\n  replace h : 0 < k := by rw [\u2190 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 : \u2200 m : \u2124, f m = m) (h0 : f (1 / 2) = 0) : f = int.floor :=\nbegin\n  suffices : \u2200 x : \u211a, \u230ax\u230b = 0 \u2192 f x = 0,\n  { ext x,\n    replace feq := feq (x - \u230ax\u230b) \u230ax\u230b 1,\n    rwa [coe_coe (1 : \u2115+), pnat.one_coe, nat.cast_one, div_one, div_one,\n         sub_add_cancel, this (x - \u230ax\u230b), 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 \u2115+ using h2,\n  rw [\u2190 rat.coe_int_div_eq_mk, int.cast_coe_nat] at h1 \u22a2,\n  have h2 : 0 < ((b : \u2115) : \u211a) := 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, \u2190 int.cast_coe_nat, int.cast_lt, \u2190 coe_coe] at h1,\n  cases h1 with h3 h1,\n  lift a to \u2115 using h3,\n  rw [coe_coe, nat.cast_lt] at h1,\n  rw [\u2190 coe_coe, \u2190 coe_coe, lem4 feq h h0 a b h1]\nend\n\nend results\n\n\n\n/-- Final solution -/\ntheorem final_solution (f : \u211a \u2192 \u2124) : fn_eq f \u2194\n  ((\u2203 C : \u2124, f = const \u211a C) \u2228 f = int.floor \u2228 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 : (\u03bb 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 (\u03bb x a b, _) (\u03bb m, _) _,\n    rw [neg_inj, \u2190 neg_div, \u2190 neg_div, neg_add, neg_add,\n        int.cast_neg, neg_neg, \u2190 int.cast_neg, feq],\n    rw [\u2190 int.cast_neg, h, neg_neg],\n    rw [neg_eq_zero, \u2190 h 0],\n    convert feq (1 / 2) (-1) 1; field_simp,\n    rw [bit0, neg_add, \u2190 add_assoc, add_neg_self, zero_add],\n    rw [h0, int.cast_one, add_neg_self] },\n  suffices : fn_eq int.floor,\n  { rintros (\u27e8C, rfl\u27e9 | 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, \u2190 neg_add, neg_div, int.floor_neg, int.floor_neg,\n         int.cast_neg, \u2190 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 : \u211a) := by rw [coe_coe, nat.cast_pos]; exact b.pos,\n  rw [le_div_iff h, le_div_iff h, \u2190 sub_le_iff_le_add, \u2190 sub_le_iff_le_add, coe_coe,\n      \u2190 int.cast_coe_nat, \u2190 coe_coe b, \u2190 int.cast_mul, \u2190 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 : \u2200 j, basis (\u03b9 j) R (M j))`,\nwhich is the `\u03a3 j, \u03b9 j`-indexed basis of \u03a0 j, M j`. The basis vectors are given by\n`pi.basis s \u27e8j, i\u27e9 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^\u03b7`, i.e. `\u03b7 \u2192 R` is called `pi.basis_fun`.\n\nTo give a concrete example, `linear_map.std_basis R (\u03bb (i : fin 3), R) i 1`\ngives the `i`th unit basis vector in `R\u00b3`, and `pi.basis_fun R (fin 3)` proves\nthis is a basis over `fin 3 \u2192 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 `\u03a0 i, M i`.\n - `pi.basis s`: given a basis `s i` for each `M i`, the standard basis on `\u03a0 i, M i`\n - `pi.basis_fun R \u03b7`: the standard basis on `R^\u03b7`, i.e. `\u03b7 \u2192 R`, given by\n   `pi.basis_fun R \u03b7 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*) {\u03b9 : Type*} [semiring R] (\u03c6 : \u03b9 \u2192 Type*)\n  [\u03a0 i, add_comm_monoid (\u03c6 i)] [\u03a0 i, module R (\u03c6 i)] [decidable_eq \u03b9]\n\n/-- The standard basis of the product of `\u03c6`. -/\ndef std_basis : \u03a0 (i : \u03b9), \u03c6 i \u2192\u2097[R] (\u03a0i, \u03c6 i) := single\n\nlemma std_basis_apply (i : \u03b9) (b : \u03c6 i) : std_basis R \u03c6 i b = update 0 i b :=\nrfl\n\n@[simp] lemma std_basis_apply' (i i' : \u03b9) : (std_basis R (\u03bb (_x : \u03b9), 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 : \u03b9) : \u21d1(std_basis R \u03c6 i) = pi.single i :=\nrfl\n\n@[simp] lemma std_basis_same (i : \u03b9) (b : \u03c6 i) : std_basis R \u03c6 i b i = b :=\npi.single_eq_same i b\n\nlemma std_basis_ne (i j : \u03b9) (h : j \u2260 i) (b : \u03c6 i) : std_basis R \u03c6 i b j = 0 :=\npi.single_eq_of_ne h b\n\nlemma std_basis_eq_pi_diag (i : \u03b9) : std_basis R \u03c6 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 : \u03b9) : ker (std_basis R \u03c6 i) = \u22a5 :=\nker_eq_bot_of_injective $ pi.single_injective _ _\n\nlemma proj_comp_std_basis (i j : \u03b9) : (proj i).comp (std_basis R \u03c6 j) = diag j i :=\nby rw [std_basis_eq_pi_diag, proj_pi]\n\nlemma proj_std_basis_same (i : \u03b9) : (proj i).comp (std_basis R \u03c6 i) = id :=\nlinear_map.ext $ std_basis_same R \u03c6 i\n\nlemma proj_std_basis_ne (i j : \u03b9) (h : i \u2260 j) : (proj i).comp (std_basis R \u03c6 j) = 0 :=\nlinear_map.ext $ std_basis_ne R \u03c6 _ _ h\n\nlemma supr_range_std_basis_le_infi_ker_proj (I J : set \u03b9) (h : disjoint I J) :\n  (\u2a06i\u2208I, range (std_basis R \u03c6 i)) \u2264 (\u2a05i\u2208J, ker (proj i : (\u03a0i, \u03c6 i) \u2192\u2097[R] \u03c6 i)) :=\nbegin\n  refine (supr_le $ \u03bb i, supr_le $ \u03bb 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 \u03c6 j i, zero_apply],\n  rintro rfl,\n  exact h.le_bot \u27e8hi, hj\u27e9\nend\n\nlemma infi_ker_proj_le_supr_range_std_basis {I : finset \u03b9} {J : set \u03b9} (hu : set.univ \u2286 \u2191I \u222a J) :\n  (\u2a05 i\u2208J, ker (proj i : (\u03a0i, \u03c6 i) \u2192\u2097[R] \u03c6 i)) \u2264 (\u2a06i\u2208I, range (std_basis R \u03c6 i)) :=\nset_like.le_def.2\nbegin\n  assume b hb,\n  simp only [mem_infi, mem_ker, proj_apply] at hb,\n  rw \u2190 show \u2211 i in I, std_basis R \u03c6 i (b i) = b,\n  { ext i,\n    rw [finset.sum_apply, \u2190 std_basis_same R \u03c6 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 (\u03bb i hi, mem_range_self (std_basis R \u03c6 i) (b i))\nend\n\nlemma supr_range_std_basis_eq_infi_ker_proj {I J : set \u03b9}\n  (hd : disjoint I J) (hu : set.univ \u2286 I \u222a J) (hI : set.finite I) :\n  (\u2a06i\u2208I, range (std_basis R \u03c6 i)) = (\u2a05i\u2208J, ker (proj i : (\u03a0i, \u03c6 i) \u2192\u2097[R] \u03c6 i)) :=\nbegin\n  refine le_antisymm (supr_range_std_basis_le_infi_ker_proj _ _ _ _ hd) _,\n  have : set.univ \u2286 \u2191hI.to_finset \u222a J, { rwa [hI.coe_to_finset] },\n  refine le_trans (infi_ker_proj_le_supr_range_std_basis R \u03c6 this) (supr_mono $ assume i, _),\n  rw [set.finite.mem_to_finset],\n  exact le_rfl\nend\n\nlemma supr_range_std_basis [finite \u03b9] : (\u2a06 i, range (std_basis R \u03c6 i)) = \u22a4 :=\nbegin\n  casesI nonempty_fintype \u03b9,\n  convert top_unique (infi_emptyset.ge.trans $ infi_ker_proj_le_supr_range_std_basis R \u03c6 _),\n  { exact funext (\u03bb i, (@supr_pos _ _ _ (\u03bb h, range $ std_basis R \u03c6 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 \u03b9) (h : disjoint I J) :\n  disjoint (\u2a06i\u2208I, range (std_basis R \u03c6 i)) (\u2a06i\u2208J, range (std_basis R \u03c6 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 \u27e8hI, hJ\u27e9 i,\n  classical,\n  by_cases hiI : i \u2208 I,\n  { by_cases hiJ : i \u2208 J,\n    { exact (h.le_bot \u27e8hiI, hiJ\u27e9).elim },\n    { exact hJ i hiJ } },\n  { exact hI i hiI }\nend\n\nlemma std_basis_eq_single {a : R} :\n  (\u03bb (i : \u03b9), (std_basis R (\u03bb _ : \u03b9, R) i) a) = \u03bb (i : \u03b9), (finsupp.single i a) :=\nfunext $ \u03bb 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 {\u03b7 : Type*} {\u03b9s : \u03b7 \u2192 Type*} {Ms : \u03b7 \u2192 Type*}\n\nlemma linear_independent_std_basis [ring R] [\u2200i, add_comm_group (Ms i)] [\u2200i, module R (Ms i)]\n  [decidable_eq \u03b7] (v : \u03a0j, \u03b9s j \u2192 (Ms j)) (hs : \u2200i, linear_independent R (v i)) :\n  linear_independent R (\u03bb (ji : \u03a3 j, \u03b9s j), std_basis R Ms ji.1 (v ji.1 ji.2)) :=\nbegin\n  have hs' : \u2200j : \u03b7, linear_independent R (\u03bb i : \u03b9s 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\u2080 : \u2200 j, span R (range (\u03bb (i : \u03b9s j), std_basis R Ms j (v j i)))\n        \u2264 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\u2081 : span R (range (\u03bb (i : \u03b9s j), std_basis R Ms j (v j i)))\n        \u2264 \u2a06 i \u2208 {j}, range (std_basis R Ms i),\n    { rw @supr_singleton _ _ _ (\u03bb i, linear_map.range (std_basis R (\u03bb (j : \u03b7), Ms j) i)),\n      apply h\u2080 },\n    have h\u2082 : (\u2a06 j \u2208 J, span R (range (\u03bb (i : \u03b9s j), std_basis R Ms j (v j i)))) \u2264\n               \u2a06 j \u2208 J, range (std_basis R (\u03bb (j : \u03b7), Ms j) j) :=\n      supr\u2082_mono (\u03bb i _, h\u2080 i),\n    have h\u2083 : disjoint (\u03bb (i : \u03b7), i \u2208 {j}) J,\n    { convert set.disjoint_singleton_left.2 hiJ using 0 },\n    exact (disjoint_std_basis_std_basis _ _ _ _ h\u2083).mono h\u2081 h\u2082 }\nend\n\nvariables [semiring R] [\u2200i, add_comm_monoid (Ms i)] [\u2200i, module R (Ms i)]\n\nvariable [fintype \u03b7]\n\nsection\n\nopen linear_equiv\n\n/-- `pi.basis (s : \u2200 j, basis (\u03b9s j) R (Ms j))` is the `\u03a3 j, \u03b9s j`-indexed basis on `\u03a0 j, Ms j`\ngiven by `s j` on each component.\n\nFor the standard basis over `R` on the finite-dimensional space `\u03b7 \u2192 R` see `pi.basis_fun`.\n-/\nprotected noncomputable def basis (s : \u2200 j, basis (\u03b9s j) R (Ms j)) :\n  basis (\u03a3 j, \u03b9s j) R (\u03a0 j, Ms j) :=\n-- The `add_comm_monoid (\u03a0 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 (_ \u226a\u226b\u2097 (finsupp.sigma_finsupp_lequiv_pi_finsupp R).symm),\n     exact linear_equiv.Pi_congr_right (\u03bb j, (s j).repr) }\n\n@[simp] lemma basis_repr_std_basis [decidable_eq \u03b7] (s : \u2200 j, basis (\u03b9s j) R (Ms j)) (j i) :\n  (pi.basis s).repr (std_basis R _ j (s j i)) = finsupp.single \u27e8j, i\u27e9 1 :=\nbegin\n  ext \u27e8j', i'\u27e9,\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      (\u03bb i i' (h : (\u27e8j, i\u27e9 : \u03a3 j, \u03b9s j) = \u27e8j, i'\u27e9), 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 \u27e8\u27e9,\n  contradiction\nend\n\n@[simp] lemma basis_apply [decidable_eq \u03b7] (s : \u2200 j, basis (\u03b9s 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 : \u2200 j, basis (\u03b9s 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 \u03b7)\n\n/-- The basis on `\u03b7 \u2192 R` where the `i`th basis vector is `function.update 0 i 1`. -/\nnoncomputable def basis_fun : basis \u03b7 R (\u03a0 (j : \u03b7), R) :=\nbasis.of_equiv_fun (linear_equiv.refl _ _)\n\n@[simp] lemma basis_fun_apply [decidable_eq \u03b7] (i) :\n  basis_fun R \u03b7 i = std_basis R (\u03bb (i : \u03b7), 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 : \u03b7 \u2192 R) (i : \u03b7) :\n  (pi.basis_fun R \u03b7).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 \u00d7 n) R (matrix m n R) :=\nbasis.reindex (pi.basis (\u03bb (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) := \u27e8\u03bb U, U.1\u27e9\n\n@[to_additive]\ninstance : has_mem G (open_subgroup G) := \u27e8\u03bb g U, g \u2208 (U : set G)\u27e9\n\n@[to_additive]\ninstance has_coe_subgroup : has_coe_t (open_subgroup G) (subgroup G) := \u27e8to_subgroup\u27e9\n\n@[to_additive]\ninstance has_coe_opens : has_coe_t (open_subgroup G) (opens G) := \u27e8\u03bb U, \u27e8U, U.is_open'\u27e9\u27e9\n\n@[simp, to_additive] lemma mem_coe : g \u2208 (U : set G) \u2194 g \u2208 U := iff.rfl\n@[simp, to_additive] lemma mem_coe_opens : g \u2208 (U : opens G) \u2194 g \u2208 U := iff.rfl\n@[simp, to_additive]\nlemma mem_coe_subgroup : g \u2208 (U : subgroup G) \u2194 g \u2208 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 \u2192 set G) :=\n\u03bb U V h, by cases U; cases V; congr; assumption\n\n@[ext, to_additive]\nlemma ext (h : \u2200 x, x \u2208 U \u2194 x \u2208 V) : (U = V) := coe_injective $ set.ext h\n\n@[to_additive]\nlemma ext_iff : (U = V) \u2194 (\u2200 x, x \u2208 U \u2194 x \u2208 V) := \u27e8\u03bb h x, h \u25b8 iff.rfl, ext\u27e9\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) \u2208 U := U.one_mem'\n\n@[to_additive]\nprotected lemma inv_mem {g : G} (h : g \u2208 U) : g\u207b\u00b9 \u2208 U := U.inv_mem' h\n\n@[to_additive]\nprotected lemma mul_mem {g\u2081 g\u2082 : G} (h\u2081 : g\u2081 \u2208 U) (h\u2082 : g\u2082 \u2208 U) : g\u2081 * g\u2082 \u2208 U := U.mul_mem' h\u2081 h\u2082\n\n@[to_additive]\nlemma mem_nhds_one : (U : set G) \u2208 \ud835\udcdd (1 : G) :=\nmem_nhds_sets U.is_open U.one_mem\nvariable {U}\n\n@[to_additive]\ninstance : has_top (open_subgroup G) := \u27e8{ is_open' := is_open_univ, .. (\u22a4 : subgroup G) }\u27e9\n\n@[to_additive]\ninstance : inhabited (open_subgroup G) := \u27e8\u22a4\u27e9\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 (\u03bb x hx, \u27e8(\u03bb y, y * x\u207b\u00b9) \u207b\u00b9' U, _, _, _\u27e9),\n  { intros u hux,\n    simp only [set.mem_preimage, set.mem_compl_iff, mem_coe] at hux hx \u22a2,\n    refine mt (\u03bb 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 \u00d7 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 := \u03bb U V, \u2200 \u2983x\u2984, x \u2208 U \u2192 x \u2208 V,\n  .. partial_order.lift (coe : open_subgroup G \u2192 set G) coe_injective }\n\n@[to_additive]\ninstance : semilattice_inf_top (open_subgroup G) :=\n{ inf := \u03bb U V, { is_open' := is_open_inter U.is_open V.is_open, .. (U : subgroup G) \u2293 V },\n  inf_le_left := \u03bb U V, set.inter_subset_left _ _,\n  inf_le_right := \u03bb U V, set.inter_subset_right _ _,\n  le_inf := \u03bb U V W hV hW, set.subset_inter hV hW,\n  top := \u22a4,\n  le_top := \u03bb U, set.subset_univ _,\n  ..open_subgroup.partial_order }\n\n@[simp, to_additive] lemma coe_inf : (\u2191(U \u2293 V) : set G) = (U : set G) \u2229 V := rfl\n\n@[simp, to_additive] lemma coe_subset : (U : set G) \u2286 V \u2194 U \u2264 V := iff.rfl\n\n@[simp, to_additive] lemma coe_subgroup_le : (U : subgroup G) \u2264 (V : subgroup G) \u2194 U \u2264 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 \u2192* 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 \u2192* N) (hf : continuous f) :\n  (H.comap f hf : set G) = f \u207b\u00b9' H := rfl\n\n@[simp, to_additive]\nlemma mem_comap {H : open_subgroup N} {f : G \u2192* N} {hf : continuous f} {x : G} :\n  x \u2208 H.comap f hf \u2194 f x \u2208 H := iff.rfl\n\n@[to_additive]\nlemma comap_comap {P : Type*} [group P] [topological_space P]\n  (K : open_subgroup P) (f\u2082 : N \u2192* P) (hf\u2082 : continuous f\u2082) (f\u2081 : G \u2192* N) (hf\u2081 : continuous f\u2081) :\n  (K.comap f\u2082 hf\u2082).comap f\u2081 hf\u2081 = K.comap (f\u2082.comp f\u2081) (hf\u2082.comp hf\u2081) :=\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) \u2208 \ud835\udcdd g) :\n  is_open (H : set G) :=\nbegin\n  simp only [is_open_iff_mem_nhds, set_like.mem_coe] at hg \u22a2,\n  intros x hx,\n  have : filter.tendsto (\u03bb y, y * (x\u207b\u00b9 * g)) (\ud835\udcdd x) (\ud835\udcdd $ x * (x\u207b\u00b9 * 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 \u2208 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 \u2264 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 := \u03bb U V,\n  { is_open' := show is_open (((U : subgroup G) \u2294 V : subgroup G) : set G),\n    from subgroup.is_open_mono le_sup_left U.is_open,\n    .. ((U : subgroup G) \u2294 V) },\n  le_sup_left := \u03bb U V, coe_subgroup_le.1 le_sup_left,\n  le_sup_right := \u03bb U V, coe_subgroup_le.1 le_sup_right,\n  sup_le := \u03bb 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 \u2264 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 \u2264 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 : \u00ac 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\u00f6lich, *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 \u00abexpr \u2260 \u00bb (\u00abexpr\u22a5\u00bb() : 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    \u2200 (P) (_ : P \u2260 (\u22a5 : Ideal A)), P.IsPrime \u2192 DiscreteValuationRing (Localization.AtPrime P)\n#align is_dedekind_domain_dvr IsDedekindDomainDvr\n\n/-- Localizing a domain of Krull dimension `\u2264 1` gives another ring of Krull dimension `\u2264 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\u2098 : Type _) [CommRing R] [IsDomain R]\n    [CommRing R\u2098] [Algebra R R\u2098] {M : Submonoid R} [IsLocalization M R\u2098] (hM : M \u2264 R\u2070)\n    (h : Ring.DimensionLeOne R) : Ring.DimensionLeOne R\u2098 :=\n  by\n  intro p hp0 hpp\n  refine' ideal.is_maximal_def.mpr \u27e8hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _\u27e9\n  have hpP' : (\u27e8p, hpp\u27e9 : { p : Ideal R\u2098 // p.IsPrime }) < \u27e8P, hPm.is_prime\u27e9 := hpP\n  rw [\u2190 (IsLocalization.orderIsoOfPrime M R\u2098).lt_iff_lt] at hpP'\n  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R R\u2098) p) :=\n    ((IsLocalization.orderIsoOfPrime M R\u2098) \u27e8p, hpp\u27e9).2.1\n  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R R\u2098) P) :=\n    ((IsLocalization.orderIsoOfPrime M R\u2098) \u27e8P, hPm.is_prime\u27e9).2.1\n  have hlt : Ideal.comap (algebraMap R R\u2098) p < Ideal.comap (algebraMap R R\u2098) P := hpP'\n  refine' h.not_lt_lt \u22a5 (Ideal.comap _ _) (Ideal.comap _ _) \u27e8_, hpP'\u27e9\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 \u2264 A\u2070)\n    (A\u2098 : Type _) [CommRing A\u2098] [IsDomain A\u2098] [Algebra A A\u2098] [IsLocalization M A\u2098] :\n    IsDedekindDomain A\u2098 :=\n  by\n  have : \u2200 y : M, IsUnit (algebraMap A (FractionRing A) y) :=\n    by\n    rintro \u27e8y, hy\u27e9\n    exact IsUnit.mk0 _ (mt is_fraction_ring.to_map_eq_zero_iff.mp (nonZeroDivisors.ne_zero (hM hy)))\n  letI : Algebra A\u2098 (FractionRing A) := RingHom.toAlgebra (IsLocalization.lift this)\n  haveI : IsScalarTower A A\u2098 (FractionRing A) :=\n    IsScalarTower.of_algebraMap_eq fun x => (IsLocalization.lift_eq this x).symm\n  haveI : IsFractionRing A\u2098 (FractionRing A) :=\n    IsFractionRing.isFractionRing_of_isDomain_of_isLocalization M _ _\n  refine' (isDedekindDomain_iff _ (FractionRing A)).mpr \u27e8_, _, _\u27e9\n  \u00b7 exact IsLocalization.isNoetherianRing M _ (by infer_instance)\n  \u00b7 exact is_dedekind_domain.dimension_le_one.localization A\u2098 hM\n  \u00b7 intro x hx\n    obtain \u27e8\u27e8y, y_mem\u27e9, hy\u27e9 := hx.exists_multiple_integral_of_is_localization M _\n    obtain \u27e8z, hz\u27e9 := (isIntegrallyClosed_iff _).mp IsDedekindDomain.isIntegrallyClosed hy\n    refine' \u27e8IsLocalization.mk' A\u2098 z \u27e8y, y_mem\u27e9, (IsLocalization.lift_mk'_spec _ _ _ _).mpr _\u27e9\n    rw [hz, [anonymous], \u2190 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\u2098 : Type _) [CommRing A\u2098] [IsDomain A\u2098] [Algebra A A\u2098] [IsLocalization.AtPrime A\u2098 P] :\n    IsDedekindDomain A\u2098 :=\n  IsLocalization.isDedekindDomain A P.primeCompl_le_nonZeroDivisors A\u2098\n#align is_localization.at_prime.is_dedekind_domain IsLocalization.AtPrime.isDedekindDomain\n\ntheorem IsLocalization.AtPrime.not_isField {P : Ideal A} (hP : P \u2260 \u22a5) [pP : P.IsPrime] (A\u2098 : Type _)\n    [CommRing A\u2098] [Algebra A A\u2098] [IsLocalization.AtPrime A\u2098 P] : \u00acIsField A\u2098 :=\n  by\n  intro h\n  letI := h.to_field\n  obtain \u27e8x, x_mem, x_ne\u27e9 := 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\u2098 P _).mpr x_mem)\n        (is_unit_iff_ne_zero.mpr\n          ((map_ne_zero_iff (algebraMap A A\u2098)\n                (IsLocalization.injective A\u2098 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 \u2260 \u22a5) [pP : P.IsPrime] (A\u2098 : Type _) [CommRing A\u2098] [IsDomain A\u2098]\n    [Algebra A A\u2098] [IsLocalization.AtPrime A\u2098 P] : DiscreteValuationRing A\u2098 := by\n  classical\n    letI : IsNoetherianRing A\u2098 :=\n      IsLocalization.isNoetherianRing P.prime_compl _ IsDedekindDomain.isNoetherianRing\n    letI : LocalRing A\u2098 := IsLocalization.AtPrime.localRing A\u2098 P\n    have hnf := IsLocalization.AtPrime.not_isField A hP A\u2098\n    exact\n      ((DiscreteValuationRing.tFAE A\u2098 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 \u2264 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\u2081 \u2286 M\u2082 \u2286 M\u2083 \u2286 \u22ef 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 : \u2200 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\u2093'. -/\n/-- An R-module is Noetherian iff all its submodules are finitely-generated. -/\ntheorem isNoetherian_def : IsNoetherian R M \u2194 \u2200 s : Submodule R M, s.Fg :=\n  \u27e8fun h => h.noetherian, IsNoetherian.mk\u27e9\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\u2093'. -/\ntheorem isNoetherian_submodule {N : Submodule R M} :\n    IsNoetherian R N \u2194 \u2200 s : Submodule R M, s \u2264 N \u2192 s.Fg :=\n  by\n  refine'\n    \u27e8fun \u27e8hn\u27e9 => fun s hs =>\n      have : s \u2264 N.subtype.range := N.range_subtype.symm \u25b8 hs\n      Submodule.map_comap_eq_self this \u25b8 (hn _).map _,\n      fun h => \u27e8fun s => _\u27e9\u27e9\n  have f := (Submodule.equivMapOfInjective N.subtype Subtype.val_injective s).symm\n  have h\u2081 := h (s.map N.subtype) (Submodule.map_subtype_le N s)\n  have h\u2082 : (\u22a4 : Submodule R (s.map N.subtype)).map f = \u22a4 := by simp\n  have h\u2083 := ((Submodule.fg_top _).2 h\u2081).map (\u2191f : _ \u2192\u2097[R] s)\n  exact (Submodule.fg_top _).1 (h\u2082 \u25b8 h\u2083)\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\u2093'. -/\ntheorem isNoetherian_submodule_left {N : Submodule R M} :\n    IsNoetherian R N \u2194 \u2200 s : Submodule R M, (N \u2293 s).Fg :=\n  isNoetherian_submodule.trans \u27e8fun H s => H _ inf_le_left, fun H s hs => inf_of_le_right hs \u25b8 H _\u27e9\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\u2093'. -/\ntheorem isNoetherian_submodule_right {N : Submodule R M} :\n    IsNoetherian R N \u2194 \u2200 s : Submodule R M, (s \u2293 N).Fg :=\n  isNoetherian_submodule.trans \u27e8fun H s => H _ inf_le_right, fun H s hs => inf_of_le_left hs \u25b8 H _\u27e9\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\u2093'. -/\ntheorem isNoetherian_of_le {s t : Submodule R M} [ht : IsNoetherian R t] (h : s \u2264 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\u2093'. -/\ntheorem isNoetherian_of_surjective (f : M \u2192\u2097[R] P) (hf : f.range = \u22a4) [IsNoetherian R M] :\n    IsNoetherian R P :=\n  \u27e8fun s =>\n    have : (s.comap f).map f = s := Submodule.map_comap_eq_self <| hf.symm \u25b8 le_top\n    this \u25b8 (noetherian _).map _\u27e9\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\u2093'. -/\ntheorem isNoetherian_of_linearEquiv (f : M \u2243\u2097[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\u2093'. -/\ntheorem isNoetherian_top_iff : IsNoetherian R (\u22a4 : Submodule R M) \u2194 IsNoetherian R M :=\n  by\n  constructor <;> intro h\n  \u00b7 exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (\u22a4 : Submodule R M) rfl)\n  \u00b7 exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (\u22a4 : 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\u2093'. -/\ntheorem isNoetherian_of_injective [IsNoetherian R P] (f : M \u2192\u2097[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\u2093'. -/\ntheorem fg_of_injective [IsNoetherian R P] {N : Submodule R M} (f : M \u2192\u2097[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  \u27e8IsNoetherian.noetherian \u22a4\u27e9\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\u2093'. -/\ntheorem Finite.of_injective [IsNoetherian R N] (f : M \u2192\u2097[R] N) (hf : Function.Injective f) :\n    Finite R M :=\n  \u27e8fg_of_injective f hf\u27e9\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\u2093'. -/\ntheorem isNoetherian_of_ker_bot [IsNoetherian R P] (f : M \u2192\u2097[R] P) (hf : f.ker = \u22a5) :\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\u2093'. -/\ntheorem fg_of_ker_bot [IsNoetherian R P] {N : Submodule R M} (f : M \u2192\u2097[R] P) (hf : f.ker = \u22a5) :\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\u2093'. -/\ninstance isNoetherian_prod [IsNoetherian R M] [IsNoetherian R P] : IsNoetherian R (M \u00d7 P) :=\n  \u27e8fun s =>\n    Submodule.fg_of_fg_map_of_fg_inf_ker (LinearMap.snd R M P) (noetherian _) <|\n      have : s \u2293 LinearMap.ker (LinearMap.snd R M P) \u2264 LinearMap.range (LinearMap.inl R M P) :=\n        fun x \u27e8hx1, hx2\u27e9 => \u27e8x.1, Prod.ext rfl <| Eq.symm <| LinearMap.mem_ker.1 hx2\u27e9\n      Submodule.map_comap_eq_self this \u25b8 (noetherian _).map _\u27e9\n#align is_noetherian_prod isNoetherian_prod\n\n#print isNoetherian_pi /-\ninstance isNoetherian_pi {R \u03b9 : Type _} {M : \u03b9 \u2192 Type _} [Ring R] [\u2200 i, AddCommGroup (M i)]\n    [\u2200 i, Module R (M i)] [Finite \u03b9] [\u2200 i, IsNoetherian R (M i)] : IsNoetherian R (\u2200 i, M i) :=\n  by\n  cases nonempty_fintype \u03b9\n  haveI := Classical.decEq \u03b9\n  suffices on_finset : \u2200 s : Finset \u03b9, IsNoetherian R (\u2200 i : s, M i)\n  \u00b7 let coe_e := Equiv.subtypeUnivEquiv Finset.mem_univ\n    letI : IsNoetherian R (\u2200 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  \u00b7 exact \u27e8fun s => by convert Submodule.fg_bot\u27e9\n  refine'\n    @isNoetherian_of_linearEquiv _ _ _ _ _ _ _ _ _ (@isNoetherian_prod _ (M a) _ _ _ _ _ _ _ ih)\n  fconstructor\n  \u00b7\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 \u2208 s => show M i.1 from f.2 \u27e8i.1, h\u27e9\n  \u00b7 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    \u00b7 change _ = _ + _\n      simp only [dif_pos]\n      rfl\n    \u00b7 change _ = _ + _\n      have : \u00aci = a := by\n        rintro rfl\n        exact has h\n      simp only [dif_neg this, dif_pos h]\n      rfl\n  \u00b7 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    \u00b7 change _ = c \u2022 _\n      simp only [dif_pos]\n      rfl\n    \u00b7 change _ = c \u2022 _\n      have : \u00aci = a := by\n        rintro rfl\n        exact has h\n      simp only [dif_neg this, dif_pos h]\n      rfl\n  \u00b7\n    exact fun f =>\n      (f \u27e8a, Finset.mem_insert_self _ _\u27e9, fun i => f \u27e8i.1, Finset.mem_insert_of_mem i.2\u27e9)\n  \u00b7 intro f\n    apply Prod.ext\n    \u00b7 simp only [Or.by_cases, dif_pos]\n    \u00b7 ext \u27e8i, his\u27e9\n      have : \u00aci = a := by\n        rintro rfl\n        exact has his\n      simp only [Or.by_cases, this, not_false_iff, dif_neg]\n  \u00b7 intro f\n    ext \u27e8i, hi\u27e9\n    rcases Finset.mem_insert.1 hi with (rfl | h)\n    \u00b7 simp only [Or.by_cases, dif_pos]\n    \u00b7 have : \u00aci = 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 `\u03b9 \u2192 \u211d` is finite dimensional over `\u211d`). -/\ninstance isNoetherian_pi' {R \u03b9 M : Type _} [Ring R] [AddCommGroup M] [Module R M] [Finite \u03b9]\n    [IsNoetherian R M] : IsNoetherian R (\u03b9 \u2192 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\u2093'. -/\ntheorem isNoetherian_iff_wellFounded :\n    IsNoetherian R M \u2194 WellFounded ((\u00b7 > \u00b7) : Submodule R M \u2192 Submodule R M \u2192 Prop) :=\n  by\n  rw [(CompleteLattice.wellFounded_characterisations <| Submodule R M).out 0 3]\n  exact\n    \u27e8fun \u27e8h\u27e9 => fun k => (fg_iff_compact k).mp (h k), fun h =>\n      \u27e8fun k => (fg_iff_compact k).mpr (h k)\u27e9\u27e9\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\u2093'. -/\ntheorem isNoetherian_iff_fg_wellFounded :\n    IsNoetherian R M \u2194\n      WellFounded\n        ((\u00b7 > \u00b7) : { N : Submodule R M // N.Fg } \u2192 { N : Submodule R M // N.Fg } \u2192 Prop) :=\n  by\n  let \u03b1 := { N : Submodule R M // N.Fg }\n  constructor\n  \u00b7 intro H\n    let f : \u03b1 \u21aao Submodule R M := OrderEmbedding.subtype _\n    exact OrderEmbedding.wellFounded f.dual (is_noetherian_iff_well_founded.mp H)\n  \u00b7 intro H\n    constructor\n    intro N\n    obtain \u27e8\u27e8N\u2080, h\u2081\u27e9, e : N\u2080 \u2264 N, h\u2082\u27e9 :=\n      well_founded.well_founded_iff_has_max'.mp H { N' : \u03b1 | N'.1 \u2264 N }\n        \u27e8\u27e8\u22a5, Submodule.fg_bot\u27e9, bot_le\u27e9\n    convert h\u2081\n    refine' (e.antisymm _).symm\n    by_contra h\u2083\n    obtain \u27e8x, hx\u2081 : x \u2208 N, hx\u2082 : x \u2209 N\u2080\u27e9 := set.not_subset.mp h\u2083\n    apply hx\u2082\n    have := h\u2082 \u27e8(R \u2219 x) \u2294 N\u2080, _\u27e9 _ _\n    \u00b7 injection this with eq\n      rw [\u2190 Eq]\n      exact (le_sup_left : (R \u2219 x) \u2264 (R \u2219 x) \u2294 N\u2080) (Submodule.mem_span_singleton_self _)\n    \u00b7 exact Submodule.Fg.sup \u27e8{x}, by rw [Finset.coe_singleton]\u27e9 h\u2081\n    \u00b7 exact sup_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hx\u2081) e\n    \u00b7 show N\u2080 \u2264 (R \u2219 x) \u2294 N\u2080\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\u2093'. -/\ntheorem wellFounded_submodule_gt (R M) [Semiring R] [AddCommMonoid M] [Module R M] :\n    \u2200 [IsNoetherian R M], WellFounded ((\u00b7 > \u00b7) : Submodule R M \u2192 Submodule R M \u2192 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\u2093'. -/\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    (\u2200 a : Set <| Submodule R M, a.Nonempty \u2192 \u2203 M' \u2208 a, \u2200 I \u2208 a, M' \u2264 I \u2192 I = M') \u2194\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    (\u2200 f : \u2115 \u2192o Submodule R M, \u2203 n, \u2200 m, n \u2264 m \u2192 f n = f m) \u2194 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\u2093'. -/\n/-- If `\u2200 I > J, P I` implies `P J`, then `P` holds for all submodules. -/\ntheorem IsNoetherian.induction [IsNoetherian R M] {P : Submodule R M \u2192 Prop}\n    (hgt : \u2200 I, (\u2200 J > I, P J) \u2192 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\u2093.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\u2093'. -/\ntheorem finite_of_linearIndependent [Nontrivial R] [IsNoetherian R M] {s : Set M}\n    (hs : LinearIndependent R (coe : s \u2192 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 : \u2115 \u21aa s := Set.Infinite.natEmbedding s hf\n  have : \u2200 n, coe \u2218 f '' { m | m \u2264 n } \u2286 s :=\n    by\n    rintro n x \u27e8y, hy\u2081, rfl\u27e9\n    exact (f y).2\n  have : \u2200 a b : \u2115, a \u2264 b \u2194 span R (coe \u2218 f '' { m | m \u2264 a }) \u2264 span R (coe \u2218 f '' { m | m \u2264 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 \u27e8fun hab x (hxa : x \u2264 a) => le_trans hxa hab, fun hx => hx a (le_refl a)\u27e9\n  exact\n    \u27e8\u27e8fun n => span R (coe \u2218 f '' { m | m \u2264 n }), fun x y => by\n        simp (config := { contextual := true }) [le_antisymm_iff, (this _ _).symm]\u27e9,\n      by dsimp [GT.gt] <;> simp only [lt_iff_le_not_le, (this _ _).symm] <;> tauto\u27e9\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\u2093'. -/\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 \u2192\u2097[R] N)\n    (g : N \u2192\u2097[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\u2093'. -/\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 \u2192\u2097[R] M) : \u2203 n : \u2115, n \u2260 0 \u2227 (f ^ n).ker \u2293 (f ^ n).range = \u22a5 :=\n  by\n  obtain \u27e8n, w\u27e9 :=\n    monotone_stabilizes_iff_noetherian.mpr I\n      (f.iterate_ker.comp \u27e8fun n => n + 1, fun n m w => by linarith\u27e9)\n  specialize w (2 * n + 1) (by linarith only)\n  dsimp at w\n  refine' \u27e8n + 1, Nat.succ_ne_zero _, _\u27e9\n  rw [eq_bot_iff]\n  rintro - \u27e8h, \u27e8y, rfl\u27e9\u27e9\n  rw [mem_bot, \u2190 LinearMap.mem_ker, w]\n  erw [LinearMap.mem_ker] at h\u22a2\n  change (f ^ (n + 1) * f ^ (n + 1)) y = 0 at h\n  rw [\u2190 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\u2093'. -/\n/-- Any surjective endomorphism of a Noetherian module is injective. -/\ntheorem IsNoetherian.injective_of_surjective_endomorphism [IsNoetherian R M] (f : M \u2192\u2097[R] M)\n    (s : Surjective f) : Injective f :=\n  by\n  obtain \u27e8n, ne, w\u27e9 := 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\u2093'. -/\n/-- Any surjective endomorphism of a Noetherian module is bijective. -/\ntheorem IsNoetherian.bijective_of_surjective_endomorphism [IsNoetherian R M] (f : M \u2192\u2097[R] M)\n    (s : Surjective f) : Bijective f :=\n  \u27e8IsNoetherian.injective_of_surjective_endomorphism f s, s\u27e9\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\u2093'. -/\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 : \u2115 \u2192 Submodule R M) (h : \u2200 n, Disjoint (partialSups f n) (f (n + 1))) :\n    \u2203 n : \u2115, \u2200 m, n \u2264 m \u2192 f m = \u22a5 :=\n  by\n  -- A little off-by-one cleanup first:\n  suffices t : \u2203 n : \u2115, \u2200 m, n \u2264 m \u2192 f (m + 1) = \u22a5\n  \u00b7 obtain \u27e8n, w\u27e9 := t\n    use n + 1\n    rintro (_ | m) p\n    \u00b7 cases p\n    \u00b7 apply w\n      exact nat.succ_le_succ_iff.mp p\n  obtain \u27e8n, w\u27e9 := monotone_stabilizes_iff_noetherian.mpr I (partialSups f)\n  exact\n    \u27e8n, 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\u27e9\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\u2093'. -/\n/-- If `M \u2295 N` embeds into `M`, for `M` noetherian over `R`, then `N` is trivial.\n-/\nnoncomputable def IsNoetherian.equivPunitOfProdInjective [IsNoetherian R M] (f : M \u00d7 N \u2192\u2097[R] M)\n    (i : Injective f) : N \u2243\u2097[R] PUnit.{w + 1} :=\n  by\n  apply Nonempty.some\n  obtain \u27e8n, w\u27e9 :=\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 \u226a\u226b\u2097 _\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 \u2194 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 \u2194 \u2200 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  \u27e8fun s => \u27e8(s : Set M).toFinite.toFinset, by rw [Set.Finite.coe_toFinset, Submodule.span_eq]\u27e9\u27e9\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\u2093'. -/\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\u22a2\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 \u29f8 N) :=\n  by\n  rw [isNoetherian_iff_wellFounded] at h\u22a2\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\u2093'. -/\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\u22a2\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\u2093'. -/\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 \u27e8s, hs\u27e9 := hN\n  haveI := Classical.decEq M\n  haveI := Classical.decEq R\n  letI : IsNoetherian R R := by infer_instance\n  have : \u2200 x \u2208 s, x \u2208 N := fun x hx => hs \u25b8 Submodule.subset_span hx\n  refine'\n    @isNoetherian_of_surjective ((\u2191s : Set M) \u2192 R) _ _ _ (Pi.module _ _ _) _ _ _ isNoetherian_pi\n  \u00b7 fapply LinearMap.mk\n    \u00b7 exact fun f => \u27e8\u2211 i in s.attach, f i \u2022 i.1, N.sum_mem fun c _ => N.smul_mem _ <| this _ c.2\u27e9\n    \u00b7 intro f g\n      apply Subtype.eq\n      change (\u2211 i in s.attach, (f i + g i) \u2022 _) = _\n      simp only [add_smul, Finset.sum_add_distrib]\n      rfl\n    \u00b7 intro c f\n      apply Subtype.eq\n      change (\u2211 i in s.attach, (c \u2022 f i) \u2022 _) = _\n      simp only [smul_eq_mul, mul_smul]\n      exact finset.smul_sum.symm\n  rw [LinearMap.range_eq_top]\n  rintro \u27e8n, hn\u27e9\n  change n \u2208 N at hn\n  rw [\u2190 hs, \u2190 Set.image_id \u2191s, Finsupp.mem_span_image_iff_total] at hn\n  rcases hn with \u27e8l, hl1, hl2\u27e9\n  refine' \u27e8fun x => l x, Subtype.ext _\u27e9\n  change (\u2211 i in s.attach, l i \u2022 (i : M)) = n\n  rw [@Finset.sum_attach M M s _ fun i => l i \u2022 i, \u2190 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'\u2093'. -/\ntheorem isNoetherian_of_fg_of_noetherian' {R M} [Ring R] [AddCommGroup M] [Module R M]\n    [IsNoetherianRing R] (h : (\u22a4 : Submodule R M).Fg) : IsNoetherian R M :=\n  have : IsNoetherian R (\u22a4 : Submodule R M) := isNoetherian_of_fg_of_noetherian _ h\n  isNoetherian_of_linearEquiv (LinearEquiv.ofTop (\u22a4 : 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\u2093'. -/\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 \u27e8A, hA, rfl\u27e9)\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\u2093'. -/\ntheorem isNoetherianRing_of_surjective (R) [Ring R] (S) [Ring S] (f : R \u2192+* S)\n    (hf : Function.Surjective f) [H : IsNoetherianRing R] : IsNoetherianRing S :=\n  by\n  rw [isNoetherianRing_iff, isNoetherian_iff_wellFounded] at H\u22a2\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\u2093'. -/\ninstance isNoetherianRing_range {R} [Ring R] {S} [Ring S] (f : R \u2192+* 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\u2093'. -/\ntheorem isNoetherianRing_of_ringEquiv (R) [Ring R] {S} [Ring S] (f : R \u2243+* 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\u2093'. -/\ntheorem IsNoetherianRing.isNilpotent_nilradical (R : Type _) [CommRing R] [IsNoetherianRing R] :\n    IsNilpotent (nilradical R) :=\n  by\n  obtain \u27e8n, hn\u27e9 := Ideal.exists_radical_pow_le_of_fg (\u22a5 : Ideal R) (IsNoetherian.noetherian _)\n  exact \u27e8n, eq_bot_iff.mpr hn\u27e9\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.nat.prime\n\nopen nat\n\n-- BEGIN\nexample {m n : \u2115} (h : m \u2223 n \u2227 m \u2260 n) :\n  m \u2223 n \u2227 \u00ac n \u2223 m :=\nbegin\n  cases h with h1 h2,\n  sorry,\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/ex3_split_dvd.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.48194127630986816}}
{"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 : \u2115\u207a) (qs : list point) : Prop :=\n  q \u2208 qs \u2227\n  q \u2260 p \u2227\n  \u2225q - p\u2225 \u2264 c\n\n-- def min_dist_pair_aux : list (point \u00d7 \u211a) \u2192 option (point \u00d7 \u211a)\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 \u00d7 \u211a) \u2192 option point\n-- | [] := none\n-- | pds := min_dist_pair_aux pds >>= (\u03bb (p : point \u00d7 \u211a), some p.1)\n\ndef min_dist_pair (p : point) : list point \u2192 option (point \u00d7 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 \u00d7 point) :=\n  let ps := get_neighbs p g in\n  min_dist_pair p ps\n\nlemma range_in_hypercube :\n  \u2200 (i j : \u2124) (n : \u2115),\n    ((-(\u2191n) \u2264 i) \u2227 (i \u2264 n) \u2227\n     (-(\u2191n) \u2264 j) \u2227 (j \u2264 n))\n    \u2194\n    (i, j) \u2208 (get_hypercube n) := sorry\n\nlemma norm_bd_on_coords :\n  \u2200 (a b : \u2124) (c : \u2115),\n    \u2225(a, b)\u2225 \u2264 c \u2192\n    a*a \u2264 c \u2227 b*b \u2264 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--   \u2200 (c : \u2115),\n--     ((nat.sqrt c) + 1)*((nat.sqrt c) + 1) > c := sorry\n\nlemma sq_neg_lt :\n  \u2200 (a b : \u2124),\n    a \u2264 0 \u2192\n    b \u2264 0 \u2192\n    a < b \u2192\n    b*b < a*a := begin\n  intros a b h1 h2 h3,\n  sorry\nend\n\nlemma sq_nonneg_lt :\n  \u2200 (a b : \u2124),\n    a \u2265 0 \u2192\n    b \u2265 0 \u2192\n    a < b \u2192\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  \u2200 (n : \u2115), n \u2265 0 := begin\n  intros n,\n  linarith,\nend\n\nlemma ge_neg_le :\n  \u2200 (n : \u2124),\n    n \u2265 0 \u2192\n    -n \u2264 0 := begin\n  intros n h,\n  linarith,\nend\n\nlemma coe_nat_int_ge :\n  \u2200 (n : \u2115),\n  n \u2265 0 \u2192\n  (\u2191n : \u2124) \u2265 0 := begin\n  intros n h,\n  simp [h],\nend\n\nlemma lt_to_le :\n  \u2200 (a b : \u2124),\n    a < b \u2192 a \u2264 b := begin\n  intros a b h,\n  linarith,\nend\n\nlemma neg_sq_sq :\n  \u2200 (a : \u2124),\n    (-a)*(-a) = a*a := begin\n  intros a,\n  ring,\nend\n\nlemma succ_sqrt_sq_gt_orig :\n  \u2200 (c : \u2115),\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  \u2200 (a b : \u2115),\n    a < b \u2192\n    (\u2191a : \u2124) < \u2191b := begin\n  intros a b h,\n  simp [h],\nend\n\nlemma coe_preserves_ge :\n  \u2200 (a b : \u2115),\n    a \u2265 b \u2192\n    (\u2191a : \u2124) \u2265 \u2191b := begin\n  intros a b h,\n  linarith,\nend\n\nlemma coe_nat_nat_nop :\n  \u2200 (n : \u2115),\n    (\u2191n : \u2115) = n := begin\n  intros n,\n  simp,\nend\n\nlemma bounded_norm_in_hypercube:\n  \u2200 (ab : \u2124 \u00d7 \u2124) (c : \u2115),\n    \u2225ab\u2225 \u2264 c \u2192\n    (ab \u2208 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 : -\u2191((nat.sqrt c) + 1) \u2264 a,\n    assumption,\n    simp at h,\n    have a_sq_le_c_and_b_sq_le_c: a*a \u2264 c \u2227 b*b \u2264 c := begin\n      apply norm_bd_on_coords,\n      assumption,\n    end,\n    have h : a < -(\u2191(nat.sqrt c) + 1) := begin\n      simp,\n      rw [add_comm],\n      exact h,\n    end,\n    have sq_succ_sqrt_lt_sq_a : -(\u2191(nat.sqrt c) + 1) * -(\u2191(nat.sqrt c) + 1) < a * a := begin\n      apply sq_neg_lt,\n      {\n        have succ_sqrt_ge_zero : \u2191(nat.sqrt c) + 1 \u2265 0 := begin\n          apply nat_ge_zero,\n        end,\n        have neg_succ_sqrt_le_zero : -(\u2191(\u2191(nat.sqrt c) + 1) : \u2124) \u2264 0 := begin\n          apply ge_neg_le,\n          apply coe_nat_int_ge,\n          assumption,\n        end,\n        have h_le : a \u2264 -(\u2191(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 : \u2191(nat.sqrt c) + 1 \u2265 0 := begin\n          apply nat_ge_zero,\n        end,\n        have neg_succ_sqrt_le_zero : -(\u2191(\u2191(nat.sqrt c) + 1) : \u2124) \u2264 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 : (\u2191c : \u2124) < a*a := begin\n      fapply lt_trans,\n      exact \u2191((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 \u2264 \u2191(nat.sqrt c + 1),\n    { assumption, },\n    simp at h,\n    have a_sq_le_c_and_b_sq_le_c: a*a \u2264 c \u2227 b*b \u2264 c := begin\n      apply norm_bd_on_coords,\n      assumption,\n    end,\n    have sq_succ_sqrt_lt_sq_a : (\u2191(nat.sqrt c) + 1) * (\u2191(nat.sqrt c) + 1) < a * a := begin\n      apply sq_nonneg_lt,\n      {\n        have succ_sqrt_ge_zero : \u2191(nat.sqrt c) + 1 \u2265 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 : \u2191(nat.sqrt c) + 1 \u2265 0 := begin\n          apply nat_ge_zero,\n        end,\n        fapply le_trans,\n        exact (\u2191(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 : (\u2191c : \u2124) < a*a := begin\n      fapply lt_trans,\n      exact \u2191((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 : -\u2191((nat.sqrt c) + 1) \u2264 b,\n    assumption,\n    simp at h,\n    have a_sq_le_c_and_b_sq_le_c: a*a \u2264 c \u2227 b*b \u2264 c := begin\n      apply norm_bd_on_coords,\n      assumption,\n    end,\n    have h : b < -(\u2191(nat.sqrt c) + 1) := begin\n      simp,\n      rw [add_comm],\n      exact h,\n    end,\n    have sq_succ_sqrt_lt_sq_a : -(\u2191(nat.sqrt c) + 1) * -(\u2191(nat.sqrt c) + 1) < b * b := begin\n      apply sq_neg_lt,\n      {\n        have succ_sqrt_ge_zero : \u2191(nat.sqrt c) + 1 \u2265 0 := begin\n          apply nat_ge_zero,\n        end,\n        have neg_succ_sqrt_le_zero : -(\u2191(\u2191(nat.sqrt c) + 1) : \u2124) \u2264 0 := begin\n          apply ge_neg_le,\n          apply coe_nat_int_ge,\n          assumption,\n        end,\n        have h_le : b \u2264 -(\u2191(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 : \u2191(nat.sqrt c) + 1 \u2265 0 := begin\n          apply nat_ge_zero,\n        end,\n        have neg_succ_sqrt_le_zero : -(\u2191(\u2191(nat.sqrt c) + 1) : \u2124) \u2264 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 : (\u2191c : \u2124) < b*b := begin\n      fapply lt_trans,\n      exact \u2191((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 \u2264 \u2191(nat.sqrt c + 1),\n    { assumption, },\n    simp at h,\n    have a_sq_le_c_and_b_sq_le_c: a*a \u2264 c \u2227 b*b \u2264 c := begin\n      apply norm_bd_on_coords,\n      assumption,\n    end,\n    have sq_succ_sqrt_lt_sq_a : (\u2191(nat.sqrt c) + 1) * (\u2191(nat.sqrt c) + 1) < b*b := begin\n      apply sq_nonneg_lt,\n      {\n        have succ_sqrt_ge_zero : \u2191(nat.sqrt c) + 1 \u2265 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 : \u2191(nat.sqrt c) + 1 \u2265 0 := begin\n          apply nat_ge_zero,\n        end,\n        fapply le_trans,\n        exact (\u2191(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 : (\u2191c : \u2124) < b*b := begin\n      fapply lt_trans,\n      exact \u2191((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  \u2200 (p q : point) (c : \u2115\u207a) (qs : list point),\n    pt_in_ball p q c qs \u2192\n    (\u2203 (a b : \u2124),\n      (\u2225(a, b)\u2225 \u2264 c) \u2227 (p + (a, b) = q)) := sorry\n\nlemma q_in_ball_means_grid_idx_in_get_idxs :\n  \u2200 (p q : point) (c : \u2115\u207a) (qs : list point),\n  pt_in_ball p q c qs \u2192\n  (get_grid_idx q) \u2208 (get_idxs p c) := begin\n  intros p q c qs q_in_p_ball,\n  have exists_idx : (\u2203 (a b : \u2124), (\u2225(a, b)\u2225 \u2264 c) \u2227 (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  \u2200 (x : point) (ls : list (list point)),\n    (\u2203 (l : list point), x \u2208 l \u2227 l \u2208 ls) \u2192\n    x \u2208 ls.join := sorry\n\nlemma x_in_grid_idxs_x_in_find_res :\n  \u2200 (p x : point) (g : grid_2D),\n    (get_grid_idx x \u2208 get_idxs p g.c) \u2192\n    (\u2203 l, (in_opt_list x l) \u2227 (l \u2208 (get_idxs p g.c).map g.data.find)) := sorry\n\nlemma some_l_in_ls_l_in_lift :\n  \u2200 {\u03b1} (l : list \u03b1) (ls : list (option (list \u03b1))),\n    some l \u2208 ls \u2192\n    l \u2208 list.map lift_option_list ls := begin\n  sorry\nend\n\nlemma get_neighbs_gets_neighbs :\n  \u2200 (p : point) (g : grid_2D),\n    \u2200 (x : point),\n      (pt_in_ball p x g.c g.ps) \u2192\n      (x \u2208 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) \u2208 (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 : (\u2203 l, (in_opt_list x l) \u2227 (l \u2208 (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  \u2200 (p : point) (ps : list point),\n    \u2200 (x : point),\n      (x \u2208 ps) \u2192\n      (min_dist_pair p ps \u2264 some (p, x)) :=\nbegin\n  sorry\nend\n\n-- lemma min_dist_pair_includes_center :\n--   \u2200 (p : point) (ps : list point),\n--     (\u2203 (z w : point), min_dist_pair p ps = some (z, w)) \u2192\n--     (\u2203 (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--   \u2200 (p : point) (g : grid_2D),\n--     (\u2203 (x : point), pt_in_ball p x g.c g.ps) \u2192\n--     (\u2203 (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 \u2208 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) \u2264 some (p, x) := begin\n--     apply min_dist_pair_closest,\n--     assumption,\n--   end,\n--   have mdp_is_some : \u2203 (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  \u2200 (p : point) (g : grid_2D),\n    \u2200 (x : point),\n      (pt_in_ball p x g.c g.ps) \u2192\n      ((mdp_with p g) \u2264 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  \u2200 (p q : point) (g : grid_2D),\n    (mdp_with p g = some (p, q)) \u2192\n    pt_in_ball p q g.c g.ps := begin\n  sorry\nend\n\n-- lemma get_neighbs_contains_all_within_ball :\n--   \u2200 (c : \u2115\u207a) (ps : list point) (p q : point) (g : grid_2D),\n--     (\u2225 p - q \u2225 \u2264 c) \u2192\n--     (q \u2208 get_neighbs p g) := begin\n--   sorry\n-- end\n\n\ndef aux (g : grid_2D) : list point \u2192 option (point \u00d7 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 : \u2115\u207a)\n  (points : list point)\n  : option (point \u00d7 point) :=\n  let g := grid_points c points in\n  aux g points >>= (\n    \u03bb pq : point \u00d7 point,\n      if \u2225 pq.1 - pq.2 \u2225 > c\n      then none\n      else some pq\n  )\n\n\n#eval find_closest_pair \u27e83, by simp\u27e9 [(0, 0), (2, 0), (5, 0)]\n#eval find_closest_pair \u27e84, by simp\u27e9 [(0, 0), (2, 0), (5, 0)]\n#eval find_closest_pair \u27e87, by simp\u27e9 [(0, 0), (2, 2), (5, 0)]\n#eval find_closest_pair \u27e88, by simp\u27e9 [(0, 0), (2, 2), (5, 0)]\n\ndef closest_pair (p q : point) (ps : list point) : Prop :=\n  (p \u2208 ps) \u2227\n  (q \u2208 ps) \u2227\n  (p \u2260 q) \u2227\n  (\u2200 (r s : point), r \u2260 s \u2192 \u2225p - q\u2225 \u2264 \u2225r - s\u2225)\n\n/-\n  Closest pair with help\n-/\ndef cp_with_help (p q : point) (ps : list point) (c : \u2115\u207a) : Prop :=\n  (closest_pair p q ps) \u2227 (1 < \u2225 p - q \u2225) \u2227 (\u2225 p - q \u2225 \u2264 c)\n\ninductive closest_pair_in_ball_union (c : \u2115\u207a) (qs : list point) : option (point \u00d7 point) \u2192 list point \u2192 Prop\n| no_ball : closest_pair_in_ball_union none []\n| cons_ball_no_update (xy : option (point \u00d7 point)) (p : point) (ps' : list point) :\n    closest_pair_in_ball_union xy ps' \u2192\n    (\u2200 (q : point),\n      pt_in_ball p q c qs \u2192\n      (xy \u2264 some (p, q))) \u2192\n    closest_pair_in_ball_union xy (p :: ps')\n| cons_ball_update\n    (xy : option (point \u00d7 point))\n    (p : point)\n    (ps' : list point)\n    (q : point) :\n    (\n      pt_in_ball p q c qs \u2227\n      (\u2200 (x : point), (pt_in_ball p x c qs) \u2192 \u2225q - p\u2225 \u2264 \u2225x - p\u2225) \u2227\n      some (p, q) < xy\n    ) \u2192\n    closest_pair_in_ball_union xy ps' \u2192\n    closest_pair_in_ball_union (some (p, q)) (p :: ps')\n\n\nlemma point_lt_iff_point_lt'_eq_true :\n  \u2200 (xy zw : option (point \u00d7 point)),\n    xy < zw \u2194 (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  \u2200 (xy : option (point \u00d7 point)) (z w : point),\n    xy \u2264 some (z, w) \u2194 (\u2203 (x y : point), xy = some (x, y)) := begin\n  sorry,\nend\n\nlemma get_mdp_includes_center_pt :\n  \u2200 (p : point) (g : grid_2D),\n    (\u2203 (q : point), (mdp_with p g) = some (p, q)) \u2228\n    (mdp_with p g) = none := begin\n  sorry\nend\n\nlemma closer_than_pt_in_ball_is_in_ball :\n  \u2200 (p x y : point) (c : \u2115\u207a) (qs : list point),\n    pt_in_ball p y c qs \u2192\n    some (p, x) \u2264 some (p, y) \u2192\n    pt_in_ball p x c qs := begin\n  sorry\nend\n\nlemma aux_monotonic_in_pt_list :\n  \u2200 (c : \u2115\u207a) (g : grid_2D) (p : point) (ps' : list point),\n    (aux g (p :: ps')) \u2264 (aux g ps')\n     := begin\n  intros c qs ps' p,\n  sorry,\nend\n\nlemma cp_in_ball_union_downward_closed :\n  \u2200 (c : \u2115\u207a) (xy zw : option (point \u00d7 point)) (qs ps : list point),\n    closest_pair_in_ball_union c qs zw ps \u2192\n    xy \u2264 zw \u2192\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  \u2200 (ps' ps : list point) (p q : point) (c : \u2115\u207a),\n    pt_in_ball p q c ps' \u2192\n    ps' \u2286 ps \u2192\n    pt_in_ball p q c ps := sorry\n\n\nlemma aux_finds_closest_pair_in_ball_union:\n  \u2200 (g : grid_2D),\n    -- `aux` finds the closest pair in union of balls of radius \u2264 `c`\n    -- (intersected with `qs`) around all points in `ps`.\n    (\u2200 (ps : list point),\n      ps \u2286 g.ps \u2192\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 \u2192 p, ps_tl \u2192 ps'],\n    have ps'_subseteq_qs : ps' \u2286 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      \u2203 (q : point),\n        pt_in_ball p q g.c g.ps \u2227\n        (\u2200 (x : point), pt_in_ball p x g.c g.ps \u2192 \u2225 q - p \u2225 \u2264 \u2225 x - p \u2225) \u2227\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 : \u2200 (x : point), (pt_in_ball p x g.c g.ps) \u2192 ((mdp_with p g) \u2264 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 \u2264 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: (\u2203 (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          (\u2203 (z : point), mdp_with p g = some (p, z)) \u2228\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 : \u2225q - p\u2225 \u2264 \u2225z - p\u2225 := hq.right.left z z_in_ball,\n          have y_closer_than_q : \u2225y - p\u2225 \u2264 \u2225q - p\u2225 := 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 \u22a2,\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 : \u2200 (x : point), pt_in_ball p x g.c g.ps \u2192 (mdp_with p g) \u2264 some (p, x) := begin\n          apply get_min_dist_pair_correct,\n        end,\n        -- aux ps' \u2264 mdp p\n        -- intuitively, by `h`\n        have aux_ps'_le_mdp_p : aux g ps' \u2264 mdp_with p g := begin\n          by_cases aux_ps'_le_mdp_p : aux g ps' \u2264 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 : (\u2203 (y : point), mdp_with p g = some (p, y)) \u2228 (mdp_with p g) = none := get_mdp_includes_center_pt p g,\n            have mdp_p_eq_some : \u2203 (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 : (\u2203 (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 \u2227\n              (\u2200 (x : point), pt_in_ball p x g.c g.ps \u2192 \u2225y - p\u2225 \u2264 \u2225x - p\u2225) \u2227\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 \u22a2,\n                rw [point_norm_sub_comm p y] at mdp_p_closest,\n                have mdp_p_closest' : \u2200 (x : point), (pt_in_ball p x g.c g.ps) \u2192 (\u2225y - p\u2225.le \u2225x - p\u2225) := 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 \u2264 q\n        -- intuitively, by univ property of `mdp` given by `mdp_correct` lemma\n        have mdp_p_le_q : mdp_with p g \u2264 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        -- \u00ac(mdp p < aux ps')\n        have mdp_not_lt_aux : \u00ac(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--   \u2200 (c : \u2115\u207a) (z w : point) (ps qs : list point),\n--     closest_pair_in_ball_union c qs (some (z, w)) ps \u2192\n--     z \u2208 ps := sorry\n\nlemma cp_in_ball_union_closer_than_all_pts_in_dist_c :\n  \u2200 (c : \u2115\u207a) (r s : point) (zw : option (point \u00d7 point)) (ps qs : list point),\n    ps \u2286 qs \u2192\n    r \u2208 ps \u2192\n    pt_in_ball r s c qs \u2192\n    closest_pair_in_ball_union c qs zw ps \u2192\n    zw \u2264 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 \u2192 zw,\n      zw_cp_in_balls_p \u2192 p,\n      zw_cp_in_balls_ps' \u2192 ps',\n      zw_cp_in_balls_\u1fb0 \u2192 zw_cp_in_union_ps'_balls,\n      zw_cp_in_balls_\u1fb0_1 \u2192 zw_closest_in_p_ball,\n      zw_cp_in_balls_ih \u2192 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 \u2208 qs \u2227 ps' \u2286 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 \u2192 zw',\n      zw_cp_in_balls_p \u2192 p,\n      zw_cp_in_balls_ps' \u2192 ps',\n      zw_cp_in_balls_q \u2192 q,\n      zw_cp_in_balls_\u1fb0 \u2192 q_closest_in_p_ball_and_pq_le_zw',\n      zw_cp_in_balls_\u1fb0_1 \u2192 zw_cp_in_union_ps'_balls,\n      zw_cp_in_balls_ih \u2192 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 \u2208 qs \u2227 ps' \u2286 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  \u2200 (c : \u2115\u207a) (x y : point) (xy : option (point \u00d7 point)) (ps : list point),\n    xy = some (x, y) \u2192\n    closest_pair_in_ball_union c ps xy ps \u2192\n    x \u2208 ps \u2227 y \u2208 ps \u2227 x \u2260 y := sorry\n\nlemma cp_with_help_and_cp_in_balls_implies_closest_pair :\n  \u2200 (c : \u2115\u207a) (ps : list point) (xy : option (point \u00d7 point)),\n    -- If there's a closest pair within distance `c`\n    (\u2203 (p q : point),\n      cp_with_help p q ps c) \u2192\n    -- and `xy` gives the closest pair in all balls of radius \u2265 `c` around\n    -- points in `ps`,\n    (closest_pair_in_ball_union c ps xy ps) \u2192\n    -- then `xy` contains the closest pair in all `ps`.\n    \u2203 (x y : point),\n      xy = some (x, y) \u2227 (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 \u2264 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 : \u2203 (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 : \u2225x - y\u2225 \u2264 \u2225p - q\u2225 := begin\n    rw [xy_is_some] at xy_leq_pq,\n    simp [has_le.le, point_le] at xy_leq_pq \u22a2,\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 \u2208 ps \u2227 y \u2208 ps \u2227 x \u2260 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 : \u2225p - q\u2225 \u2264 \u2225r - s\u2225 := 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 \u27e8xy_is_some, xy_closest\u27e9,\nend\n\n\nlemma aux_gives_closest_pair:\n  \u2200 (g : grid_2D),\n    (\u2203 (p q : point),\n      cp_with_help p q g.ps g.c) \u2192\n    (\u2203 (p q : point),\n      aux g g.ps = some (p, q)\n      \u2227 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  \u2200 (c : \u2115\u207a) (ps : list point),\n    (grid_points c ps).c = c := sorry\n\nlemma grid_pts_dot_ps_with_ps_eq_ps :\n  \u2200 (c : \u2115\u207a) (ps : list point),\n    (grid_points c ps).ps = ps := sorry\n\ntheorem find_closest_pair_correct :\n  \u2200 (c : \u2115\u207a) (ps : list point),\n    -- If there's a closest pair within distance `c`\n    (\u2203 (p q : point),\n      cp_with_help p q ps c) \u2192\n    -- then our algorithm finds a closest pair.\n    (\u2203 (p q : point),\n      (find_closest_pair c ps) = some (p, q) \u2227\n      closest_pair p q ps) := begin\n  intros c ps exists_pair,\n  have aux_gives_closest :\n    (\u2203 (p q : point),\n        aux (grid_points c ps) ps = some (p, q)\n        \u2227 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      (\u2203 (p q : point), aux (grid_points c ps) (grid_points c ps).ps = some (p, q) \u2227 closest_pair p q (grid_points c ps).ps) \u2192\n      (\u2203 (p q : point), aux (grid_points c ps) (grid_points c ps).ps = some (p, q) \u2227 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 : (\u2225p - q\u2225 \u2264 \u2191c) := begin\n      cases exists_pair with p' exists_pair,\n      cases exists_pair with q' exists_pair,\n      have aux_closer_than_cp : \u2225p - q\u2225 \u2264 \u2225p' - q'\u2225 := 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 (\u2191c < \u2225p - q\u2225),\n\n    rw [\u2190coe_to_\u2115_then_\u2124_eq_coe_to_\u2124] 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 [\u2190coe_to_\u2115_then_\u2124_eq_coe_to_\u2124] 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 \u2192 Prop :=\n  sorry\n\ntheorem impartial_def {G : pgame} : impartial G \u2194\n  equiv G (-G) \u2227 (\u2200 (i : left_moves G), impartial (move_left G i)) \u2227 \u2200 (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 \u2228 first_wins G := sorry\n\ntheorem not_first_wins (G : pgame) [impartial G] : \u00acfirst_wins G \u2194 first_loses G := sorry\n\ntheorem not_first_loses (G : pgame) [impartial G] : \u00acfirst_loses G \u2194 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 \u2194 first_loses (G + H) := sorry\n\ntheorem le_zero_iff {G : pgame} [impartial G] : G \u2264 0 \u2194 0 \u2264 G :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (G \u2264 0 \u2194 0 \u2264 G)) (propext le_zero_iff_zero_le_neg)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (0 \u2264 -G \u2194 0 \u2264 G)) (propext (le_congr (equiv_refl 0) (neg_equiv_self G)))))\n      (iff.refl (0 \u2264 -G)))\n\ntheorem lt_zero_iff {G : pgame} [impartial G] : G < 0 \u2194 0 < G := sorry\n\ntheorem first_loses_symm (G : pgame) [impartial G] : first_loses G \u2194 G \u2264 0 :=\n  { mp := and.left, mpr := fun (h : G \u2264 0) => { left := h, right := iff.mp le_zero_iff h } }\n\ntheorem first_wins_symm (G : pgame) [impartial G] : first_wins G \u2194 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 \u2194 0 \u2264 G :=\n  { mp := and.right, mpr := fun (h : 0 \u2264 G) => { left := iff.mpr le_zero_iff h, right := h } }\n\ntheorem first_wins_symm' (G : pgame) [impartial G] : first_wins G \u2194 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] : (\u2200 (i : left_moves G), first_wins (move_left G i)) \u2194 first_loses G := sorry\n\ntheorem no_good_right_moves_iff_first_loses (G : pgame) [impartial G] : (\u2200 (j : right_moves G), first_wins (move_right G j)) \u2194 first_loses G := sorry\n\ntheorem good_left_move_iff_first_wins (G : pgame) [impartial G] : (\u2203 (i : left_moves G), first_loses (move_left G i)) \u2194 first_wins G := sorry\n\ntheorem good_right_move_iff_first_wins (G : pgame) [impartial G] : (\u2203 (j : right_moves G), first_loses (move_right G j)) \u2194 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\u27e8\u03bb M N [monoid M] [monoid N], by exactI @monoid_hom.to_fun M N _ _,\n \u03bb M [monoid M], by exactI @monoid_hom.id M _,\n \u03bb M N P [monoid M] [monoid N] [monoid P], by exactI @monoid_hom.comp M N P _ _ _,\n \u03bb M N [monoid M] [monoid N], by exactI @monoid_hom.coe_inj M N _ _\u27e9\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 \u2192* Y) :\n  of X \u27f6 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 \u2192* 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\u27e8@of punit $ @group.to_monoid _ $ @comm_group.to_group _ punit.comm_group\u27e9\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 := \u27e8\u27e9\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\u27e8@of punit $ @comm_group.to_comm_monoid _ punit.comm_group\u27e9\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\u2082 CommMon Mon := bundled_hom.forget\u2082 _ _\n\n@[to_additive] instance : has_coe CommMon.{u} Mon.{u} :=\n{ coe := (forget\u2082 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 \u27f6 S) : (R : Type) \u2192 (S : Type) := f\nexample {R S : CommMon} (f : R \u27f6 S) : (R : Type) \u2192 (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 `\u21a5R`,\n-- rather than `R.\u03b1` or (as we used to have) `\u21a5(bundled.map comm_monoid.to_monoid R)`.\nexample (R : CommMon.{u}) : R \u27f6 R :=\n{ to_fun := \u03bb 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' := \u03bb x y,\n  begin rw [mul_assoc x y (x * y), \u2190mul_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 \u2243* Y) : Mon.of X \u2245 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 \u2243* Y) : CommMon.of X \u2245 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 \u2245 Y) : X \u2243* 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 \u2245 Y) : X \u2243* 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 \u2243* Y) \u2245 (Mon.of X \u2245 Mon.of Y) :=\n{ hom := \u03bb e, e.to_Mon_iso,\n  inv := \u03bb 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 \u2243* Y) \u2245 (CommMon.of X \u2245 CommMon.of Y) :=\n{ hom := \u03bb e, e.to_CommMon_iso,\n  inv := \u03bb i, i.CommMon_iso_to_mul_equiv, }\n\n@[to_additive]\ninstance Mon.forget_reflects_isos : reflects_isomorphisms (forget Mon.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Mon).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Mon_iso).1\u27e9,\n  end }\n\n@[to_additive]\ninstance CommMon.forget_reflects_isos : reflects_isomorphisms (forget CommMon.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommMon).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommMon_iso).1\u27e9,\n  end }\n\n/-!\nOnce we've shown that the forgetful functors to type reflect isomorphisms,\nwe automatically obtain that the `forget\u2082` functors between our concrete categories\nreflect isomorphisms.\n-/\nexample : reflects_isomorphisms (forget\u2082 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 \u27f6 Y`, or `eq_to_iso h : X \u2245 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n-- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nopen opposite\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n\n/--\nAn equality `X = Y` gives us a morphism `X \u27f6 Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `\ud835\udfd9 _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_hom {X Y : C} (p : X = Y) : X \u27f6 Y := by rw p; exact \ud835\udfd9 _\n\n@[simp] lemma eq_to_hom_refl (X : C) (p : X = X) : eq_to_hom p = \ud835\udfd9 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 \u226b 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 \u27f6 Y) (g : X \u27f6 Y') :\n  f \u226b eq_to_hom p = g \u2194 f = g \u226b eq_to_hom p.symm :=\n{ mp := \u03bb h, h \u25b8 by simp,\n  mpr := \u03bb 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 \u27f6 Y) (g : X' \u27f6 Y) :\n  eq_to_hom p \u226b g = f \u2194 g = eq_to_hom p.symm \u226b f :=\n{ mp := \u03bb h, h \u25b8 by simp,\n  mpr := \u03bb h, h \u25b8 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 \u27f6 Z) :\n  (congr_arg (\u03bb W : C, W \u27f6 Z) p).mpr q = eq_to_hom p \u226b 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 \u27f6 Y) (q : Z = Y) :\n  (congr_arg (\u03bb W : C, X \u27f6 W) q).mpr p = p \u226b eq_to_hom q.symm :=\nby { cases q, simp, }\n\n/--\nAn equality `X = Y` gives us an isomorphism `X \u2245 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 \u2245 Y :=\n\u27e8eq_to_hom p, eq_to_hom p.symm, by simp, by simp\u27e9\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\u1d52\u1d56} (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\u2082} [category.{v\u2082} 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 \u2964 D} (h_obj : \u2200 X, F.obj X = G.obj X)\n  (h_map : \u2200 X Y f, F.map f = eq_to_hom (h_obj X) \u226b G.map f \u226b 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 \u27f6 X) (g : Y \u27f6 Z) (h : W = Y) (h' : X = Z) :\n  f = eq_to_hom h \u226b g \u226b eq_to_hom h'.symm \u2194 f == g :=\nby { cases h, cases h', simp }\n\n/-- Proving equality between functors using heterogeneous equality. -/\nlemma hext {F G : C \u2964 D} (h_obj : \u2200 X, F.obj X = G.obj X)\n  (h_map : \u2200 X Y (f : X \u27f6 Y), F.map f == G.map f) : F = G :=\nfunctor.ext h_obj (\u03bb _ _ 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 \u2964 D} (h : F = G) (X) : F.obj X = G.obj X :=\nby subst h\n\nlemma congr_hom {F G : C \u2964 D} (h : F = G) {X Y} (f : X \u27f6 Y) :\n  F.map f = eq_to_hom (congr_obj h X) \u226b G.map f \u226b eq_to_hom (congr_obj h Y).symm :=\nby subst h; simp\n\nlemma congr_inv_of_congr_hom (F G : C \u2964 D) {X Y : C} (e : X \u2245 Y)\n  (hX : F.obj X = G.obj X) (hY : F.obj Y = G.obj Y)\n  (h\u2082 : F.map e.hom = eq_to_hom (by rw hX) \u226b G.map e.hom \u226b eq_to_hom (by rw hY)) :\nF.map e.inv = eq_to_hom (by rw hY) \u226b G.map e.inv \u226b eq_to_hom (by rw hX) :=\nby simp only [\u2190 is_iso.iso.inv_hom e, functor.map_inv, h\u2082, is_iso.inv_comp,\n  inv_eq_to_hom, category.assoc]\n\nlemma congr_map (F : C \u2964 D) {X Y : C} {f g : X \u27f6 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\u2083} [category.{v\u2083} E] {F G : C \u2964 D} {X Y Z : C} {f : X \u27f6 Y} {g : Y \u27f6 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 \u226b g) == G.map (f \u226b g) :=\nby { rw [F.map_comp, G.map_comp], congr' }\n\nlemma map_comp_heq' (hobj : \u2200 X : C, F.obj X = G.obj X)\n  (hmap : \u2200 {X Y} (f : X \u27f6 Y), F.map f == G.map f) :\n  F.map (f \u226b g) == G.map (f \u226b g) :=\nby rw functor.hext hobj (\u03bb _ _, hmap)\n\nlemma precomp_map_heq (H : E \u2964 C)\n  (hmap : \u2200 {X Y} (f : X \u27f6 Y), F.map f == G.map f) {X Y : E} (f : X \u27f6 Y) :\n  (H \u22d9 F).map f == (H \u22d9 G).map f := hmap _\n\nlemma postcomp_map_heq (H : D \u2964 E) (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y)\n  (hmap : F.map f == G.map f) : (F \u22d9 H).map f == (G \u22d9 H).map f :=\nby { dsimp, congr' }\n\nlemma postcomp_map_heq' (H : D \u2964 E) (hobj : \u2200 X : C, F.obj X = G.obj X)\n  (hmap : \u2200 {X Y} (f : X \u27f6 Y), F.map f == G.map f) :\n  (F \u22d9 H).map f == (G \u22d9 H).map f :=\nby rw functor.hext hobj (\u03bb _ _, hmap)\n\nlemma hcongr_hom {F G : C \u2964 D} (h : F = G) {X Y} (f : X \u27f6 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 \u2964 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 \u2964 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 \u2964 D} (h : F = G) (X : C) :\n  (eq_to_hom h : F \u27f6 G).app X = eq_to_hom (functor.congr_obj h X) :=\nby subst h; refl\n\nlemma nat_trans.congr {F G : C \u2964 D} (\u03b1 : F \u27f6 G) {X Y : C} (h : X = Y) :\n  \u03b1.app X = F.map (eq_to_hom h) \u226b \u03b1.app Y \u226b G.map (eq_to_hom h.symm) :=\nby { rw [\u03b1.naturality_assoc], simp [eq_to_hom_map], }\n\nlemma eq_conj_eq_to_hom {X Y : C} (f : X \u27f6 Y) :\n  f = eq_to_hom rfl \u226b f \u226b eq_to_hom rfl :=\nby simp only [category.id_comp, eq_to_hom_refl, category.comp_id]\n\nlemma dcongr_arg {\u03b9 : Type*} {F G : \u03b9 \u2192 C} (\u03b1 : \u2200 i, F i \u27f6 G i) {i j : \u03b9} (h : i = j) :\n  \u03b1 i = eq_to_hom (congr_arg F h) \u226b \u03b1 j \u226b 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 \u03b2`, a.k.a. `\u03b1 \u2192+* \u03b2`, 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* `\u2192\u2099+*`: Non-unital (semi)ring homs\n* `\u2192+*`: (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 \u03b1 \u03b2 \u03b3 : Type _}\n\n#print NonUnitalRingHom /-\n/-- Bundled non-unital semiring homomorphisms `\u03b1 \u2192\u2099+* \u03b2`; use this for bundled non-unital ring\nhomomorphisms too.\n\nWhen possible, instead of parametrizing results over `(f : \u03b1 \u2192\u2099+* \u03b2)`,\nyou should parametrize over `(F : Type*) [non_unital_ring_hom_class F \u03b1 \u03b2] (f : F)`.\n\nWhen you extend this structure, make sure to extend `non_unital_ring_hom_class`. -/\nstructure NonUnitalRingHom (\u03b1 \u03b2 : Type _) [NonUnitalNonAssocSemiring \u03b1]\n  [NonUnitalNonAssocSemiring \u03b2] extends \u03b1 \u2192\u2099* \u03b2, \u03b1 \u2192+ \u03b2\n#align non_unital_ring_hom NonUnitalRingHom\n-/\n\n-- mathport name: \u00abexpr \u2192\u2099+* \u00bb\ninfixr:25 \" \u2192\u2099+* \" => NonUnitalRingHom\n\n/-- Reinterpret a non-unital ring homomorphism `f : \u03b1 \u2192\u2099+* \u03b2` as a semigroup\nhomomorphism `\u03b1 \u2192\u2099* \u03b2`. The `simp`-normal form is `(f : \u03b1 \u2192\u2099* \u03b2)`. -/\nadd_decl_doc NonUnitalRingHom.toMulHom\n\n/-- Reinterpret a non-unital ring homomorphism `f : \u03b1 \u2192\u2099+* \u03b2` as an additive\nmonoid homomorphism `\u03b1 \u2192+ \u03b2`. The `simp`-normal form is `(f : \u03b1 \u2192+ \u03b2)`. -/\nadd_decl_doc NonUnitalRingHom.toAddMonoidHom\n\nsection NonUnitalRingHomClass\n\n#print NonUnitalRingHomClass /-\n/-- `non_unital_ring_hom_class F \u03b1 \u03b2` 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 _) (\u03b1 \u03b2 : outParam (Type _)) [NonUnitalNonAssocSemiring \u03b1]\n  [NonUnitalNonAssocSemiring \u03b2] extends MulHomClass F \u03b1 \u03b2, AddMonoidHomClass F \u03b1 \u03b2\n#align non_unital_ring_hom_class NonUnitalRingHomClass\n-/\n\nvariable [NonUnitalNonAssocSemiring \u03b1] [NonUnitalNonAssocSemiring \u03b2] [NonUnitalRingHomClass F \u03b1 \u03b2]\n\ninstance : CoeTC F (\u03b1 \u2192\u2099+* \u03b2) :=\n  \u27e8fun f =>\n    { toFun := f\n      map_zero' := map_zero f\n      map_mul' := map_mul f\n      map_add' := map_add f }\u27e9\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\u03b1 : NonUnitalNonAssocSemiring \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring \u03b2}\n\ninclude r\u03b1 r\u03b2\n\ninstance : NonUnitalRingHomClass (\u03b1 \u2192\u2099+* \u03b2) \u03b1 \u03b2\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 (\u03b1 \u2192\u2099+* \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\n  \u27e8NonUnitalRingHom.toFun\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (NonUnitalRingHom.toFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}}, (Nat -> \u03b1 -> \u03b2) -> Nat -> (List.{u1} \u03b1) -> (List.{u2} \u03b2)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.to_fun_eq_coe [anonymous]\u2093'. -/\n@[simp]\ntheorem [anonymous] (f : \u03b1 \u2192\u2099+* \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (f x) (f y))) (h\u2082 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))))))) (h\u2083 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))))) (f x) (f y))), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f h\u2081 h\u2082 h\u2083)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}}, (Nat -> \u03b1 -> \u03b2) -> Nat -> (List.{u1} \u03b1) -> (List.{u2} \u03b2)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mk [anonymous]\u2093'. -/\n@[simp]\ntheorem [anonymous] (f : \u03b1 \u2192 \u03b2) (h\u2081 h\u2082 h\u2083) : \u21d1(\u27e8f, h\u2081, h\u2082, h\u2083\u27e9 : \u03b1 \u2192\u2099+* \u03b2) = 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}} {\u03b1 : Type.{u_2}} {\u03b2 : Type.{u_3}} {r\u03b1 : NonUnitalNonAssocSemiring.{u_2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u_3} \u03b2} [_inst_1 : NonUnitalRingHomClass.{u_1, u_2, u_3} F \u03b1 \u03b2 r\u03b1 r\u03b2] (f : F), Eq.{max (succ u_2) (succ u_3)} ((fun (_x : NonUnitalRingHom.{u_2, u_3} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (HasLiftT.mk.{succ u_1, max (succ u_2) (succ u_3)} F (NonUnitalRingHom.{u_2, u_3} \u03b1 \u03b2 r\u03b1 r\u03b2) (CoeTC\u2093.coe.{succ u_1, max (succ u_2) (succ u_3)} F (NonUnitalRingHom.{u_2, u_3} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.hasCoeT.{u_1, u_2, u_3} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1))) f)) (coeFn.{max (succ u_2) (succ u_3), max (succ u_2) (succ u_3)} (NonUnitalRingHom.{u_2, u_3} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u_2, u_3} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u_2, u_3} \u03b1 \u03b2 r\u03b1 r\u03b2) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (HasLiftT.mk.{succ u_1, max (succ u_2) (succ u_3)} F (NonUnitalRingHom.{u_2, u_3} \u03b1 \u03b2 r\u03b1 r\u03b2) (CoeTC\u2093.coe.{succ u_1, max (succ u_2) (succ u_3)} F (NonUnitalRingHom.{u_2, u_3} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.hasCoeT.{u_1, u_2, u_3} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1))) f)) (coeFn.{succ u_1, max (succ u_2) (succ u_3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u_1, succ u_2, succ u_3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u_1, u_2, u_3} F \u03b1 \u03b2 (Distrib.toHasMul.{u_2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u_2} \u03b1 r\u03b1)) (Distrib.toHasMul.{u_3} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u_3} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{u_1, u_2, u_3} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1))) f)\nbut is expected to have type\n  forall {F : Type.{u}} {\u03b1 : Type.{v}}, (Nat -> F -> \u03b1) -> Nat -> (List.{u} F) -> (List.{v} \u03b1)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_coe [anonymous]\u2093'. -/\n@[simp]\ntheorem [anonymous] [NonUnitalRingHomClass F \u03b1 \u03b2] (f : F) : ((f : \u03b1 \u2192\u2099+* \u03b2) : \u03b1 \u2192 \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (fun (_x : MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) => \u03b1 -> \u03b2) (MulHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (NonUnitalRingHom.toMulHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2} (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MulHom.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MulHom.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (MulHom.mulHomClass.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2))) (NonUnitalRingHom.toMulHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_to_mul_hom NonUnitalRingHom.coe_toMulHom\u2093'. -/\n@[simp]\ntheorem coe_toMulHom (f : \u03b1 \u2192\u2099+* \u03b2) : \u21d1f.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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (f x) (f y))) (h\u2082 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))))))) (h\u2083 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))))) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (MulHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) (NonUnitalRingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f h\u2081 h\u2082 h\u2083)) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) f h\u2081)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1)) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2)) (f x) (f y))) (h\u2082 : Eq.{succ u2} \u03b2 (MulHom.toFun.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (AddZeroClass.toZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddZeroClass.toZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))))))) (h\u2083 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (MulHom.toFun.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))))) (MulHom.toFun.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) x) (MulHom.toFun.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) y))), Eq.{max (succ u1) (succ u2)} (MulHom.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2)) (MulHomClass.toMulHom.{u1, u2, max u1 u2} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)) (NonUnitalRingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) h\u2082 h\u2083)) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mul_hom_mk NonUnitalRingHom.coe_mulHom_mk\u2093'. -/\n@[simp]\ntheorem coe_mulHom_mk (f : \u03b1 \u2192 \u03b2) (h\u2081 h\u2082 h\u2083) : ((\u27e8f, h\u2081, h\u2082, h\u2083\u27e9 : \u03b1 \u2192\u2099+* \u03b2) : \u03b1 \u2192\u2099* \u03b2) = \u27e8f, h\u2081\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (fun (_x : AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) => \u03b1 -> \u03b2) (AddMonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (NonUnitalRingHom.toAddMonoidHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2} (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (AddMonoidHom.{u2, u1} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{max u2 u1, u2, u1} (AddMonoidHom.{u2, u1} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2)))) \u03b1 \u03b2 (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1)))) (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2)))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u2, u1} (AddMonoidHom.{u2, u1} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2)))) \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2))) (AddMonoidHom.addMonoidHomClass.{u2, u1} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2)))))) (NonUnitalRingHom.toAddMonoidHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_to_add_monoid_hom NonUnitalRingHom.coe_toAddMonoidHom\u2093'. -/\n@[simp]\ntheorem coe_toAddMonoidHom (f : \u03b1 \u2192\u2099+* \u03b2) : \u21d1f.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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (f x) (f y))) (h\u2082 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))))))) (h\u2083 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))))) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) (NonUnitalRingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f h\u2081 h\u2082 h\u2083)) (AddMonoidHom.mk.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) f h\u2082 h\u2083)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1)) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2)) (f x) (f y))) (h\u2082 : Eq.{succ u2} \u03b2 (MulHom.toFun.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (AddZeroClass.toZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddZeroClass.toZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))))))) (h\u2083 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (MulHom.toFun.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))))) (MulHom.toFun.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) x) (MulHom.toFun.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) y))), Eq.{max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (AddMonoidHomClass.toAddMonoidHom.{u1, u2, max u1 u2} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)) (NonUnitalRingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 (MulHom.mk.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) f h\u2081) h\u2082 h\u2083)) (AddMonoidHom.mk.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (ZeroHom.mk.{u1, u2} \u03b1 \u03b2 (AddZeroClass.toZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))) (AddZeroClass.toZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) f h\u2082) h\u2083)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_add_monoid_hom_mk NonUnitalRingHom.coe_addMonoidHom_mk\u2093'. -/\n@[simp]\ntheorem coe_addMonoidHom_mk (f : \u03b1 \u2192 \u03b2) (h\u2081 h\u2082 h\u2083) :\n    ((\u27e8f, h\u2081, h\u2082, h\u2083\u27e9 : \u03b1 \u2192\u2099+* \u03b2) : \u03b1 \u2192+ \u03b2) = \u27e8f, h\u2082, h\u2083\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)) -> (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))) f)) -> (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.copy NonUnitalRingHom.copy\u2093'. -/\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 : \u03b1 \u2192\u2099+* \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u03b1 \u2192\u2099+* \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.copy.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f f' h)) f'\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2} (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f)), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) (NonUnitalRingHom.copy.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_copy NonUnitalRingHom.coe_copy\u2093'. -/\n@[simp]\ntheorem coe_copy (f : \u03b1 \u2192\u2099+* \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.copy.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f f' h) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2} (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f)), Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.copy.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f f' h) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.copy_eq NonUnitalRingHom.copy_eq\u2093'. -/\ntheorem copy_eq (f : \u03b1 \u2192\u2099+* \u03b2) (f' : \u03b1 \u2192 \u03b2) (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\u03b1 : NonUnitalNonAssocSemiring \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring \u03b2]\n\nsection\n\ninclude r\u03b1 r\u03b2\n\nvariable (f : \u03b1 \u2192\u2099+* \u03b2) {x y : \u03b1} {r\u03b1 r\u03b2}\n\n/- warning: non_unital_ring_hom.ext -> NonUnitalRingHom.ext is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} {{f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}} {{g : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}}, (forall (x : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) g x)) -> (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2} {{f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}} {{g : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}}, (forall (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) g x)) -> (Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) f g)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.ext NonUnitalRingHom.ext\u2093'. -/\n@[ext]\ntheorem ext \u2983f g : \u03b1 \u2192\u2099+* \u03b2\u2984 : (\u2200 x, f x = g x) \u2192 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} {f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2} {g : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}, Iff (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f g) (forall (x : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) g x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2} {f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2} {g : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}, Iff (Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) f g) (forall (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) g x))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.ext_iff NonUnitalRingHom.ext_iff\u2093'. -/\ntheorem ext_iff {f g : \u03b1 \u2192\u2099+* \u03b2} : f = g \u2194 \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (h\u2081 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f y))) (h\u2082 : Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))))))) (h\u2083 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f y))), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f) h\u2081 h\u2082 h\u2083) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2} (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (h\u2081 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u1} \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1)) x y)) (HMul.hMul.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f y))) (h\u2082 : Eq.{succ u1} \u03b2 (MulHom.toFun.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (MulHom.mk.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f) h\u2081) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (AddZeroClass.toZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u1} \u03b2 0 (Zero.toOfNat0.{u1} \u03b2 (AddZeroClass.toZero.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2))))))) (h\u2083 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u1} \u03b2 (MulHom.toFun.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (MulHom.mk.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f) h\u2081) (HAdd.hAdd.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHAdd.{u2} \u03b1 (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))))) x y)) (HAdd.hAdd.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHAdd.{u1} \u03b2 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2))))) (MulHom.toFun.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (MulHom.mk.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f) h\u2081) x) (MulHom.toFun.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (MulHom.mk.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f) h\u2081) y))), Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.mk.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 (MulHom.mk.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) f) h\u2081) h\u2082 h\u2083) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.mk_coe NonUnitalRingHom.mk_coe\u2093'. -/\n@[simp]\ntheorem mk_coe (f : \u03b1 \u2192\u2099+* \u03b2) (h\u2081 h\u2082 h\u2083) : NonUnitalRingHom.mk f h\u2081 h\u2082 h\u2083 = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2}, Function.Injective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u2, u1} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2)))) (fun (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) => AddMonoidHomClass.toAddMonoidHom.{u2, u1, max u2 u1} \u03b1 \u03b2 (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddCommMonoid.toAddMonoid.{u1} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_add_monoid_hom_injective NonUnitalRingHom.coe_addMonoidHom_injective\u2093'. -/\ntheorem coe_addMonoidHom_injective : Injective (coe : (\u03b1 \u2192\u2099+* \u03b2) \u2192 \u03b1 \u2192+ \u03b2) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2}, Function.Injective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (MulHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2)) (fun (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) => MulHomClass.toMulHom.{u2, u1, max u2 u1} \u03b1 \u03b2 (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mul_hom_injective NonUnitalRingHom.coe_mulHom_injective\u2093'. -/\ntheorem coe_mulHom_injective : Injective (coe : (\u03b1 \u2192\u2099+* \u03b2) \u2192 \u03b1 \u2192\u2099* \u03b2) := 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 (\u03b1 : Type _) [NonUnitalNonAssocSemiring \u03b1] : \u03b1 \u2192\u2099+* \u03b1 := by\n  refine' { toFun := id.. } <;> intros <;> rfl\n#align non_unital_ring_hom.id NonUnitalRingHom.id\n-/\n\ninclude r\u03b1 r\u03b2\n\ninstance : Zero (\u03b1 \u2192\u2099+* \u03b2) :=\n  \u27e8{  toFun := 0\n      map_mul' := fun x y => (MulZeroClass.mul_zero (0 : \u03b2)).symm\n      map_zero' := rfl\n      map_add' := fun x y => (add_zero (0 : \u03b2)).symm }\u27e9\n\ninstance : Inhabited (\u03b1 \u2192\u2099+* \u03b2) :=\n  \u27e80\u27e9\n\n/- warning: non_unital_ring_hom.coe_zero -> NonUnitalRingHom.coe_zero is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2], Eq.{succ (max u1 u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), succ (max u1 u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (OfNat.mk.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (Zero.zero.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.hasZero.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) (OfNat.ofNat.{max u1 u2} (\u03b1 -> \u03b2) 0 (OfNat.mk.{max u1 u2} (\u03b1 -> \u03b2) 0 (Zero.zero.{max u1 u2} (\u03b1 -> \u03b2) (Pi.instZero.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b2) (fun (i : \u03b1) => MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 r\u03b2))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2], Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2))) (OfNat.ofNat.{max u2 u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (Zero.toOfNat0.{max u2 u1} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) (OfNat.ofNat.{max u2 u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) \u1fb0) 0 (Zero.toOfNat0.{max u2 u1} (forall (a : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (Pi.instZero.{u2, u1} \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (fun (i : \u03b1) => MulZeroClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) i) (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) i) r\u03b2)))))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_zero NonUnitalRingHom.coe_zero\u2093'. -/\n@[simp]\ntheorem coe_zero : \u21d1(0 : \u03b1 \u2192\u2099+* \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] (x : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (OfNat.mk.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (Zero.zero.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.hasZero.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)))) x) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 r\u03b2)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] (x : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))) (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (Zero.toOfNat0.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))) x) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (MulZeroClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) r\u03b2))))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply\u2093'. -/\n@[simp]\ntheorem zero_apply (x : \u03b1) : (0 : \u03b1 \u2192\u2099+* \u03b2) x = 0 :=\n  rfl\n#align non_unital_ring_hom.zero_apply NonUnitalRingHom.zero_apply\n\nomit r\u03b2\n\n/- warning: non_unital_ring_hom.id_apply -> NonUnitalRingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] (x : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (NonUnitalRingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1) x) x\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))) (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1) x) x\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.id_apply NonUnitalRingHom.id_apply\u2093'. -/\n@[simp]\ntheorem id_apply (x : \u03b1) : NonUnitalRingHom.id \u03b1 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 {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))) (HasLiftT.mk.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))) (CoeTC\u2093.coe.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))) (AddMonoidHom.hasCoeT.{u1, u1, u1} \u03b1 \u03b1 (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (NonUnitalRingHomClass.toAddMonoidHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))))) (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1)) (AddMonoidHom.id.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))) (AddMonoidHomClass.toAddMonoidHom.{u1, u1, u1} \u03b1 \u03b1 (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (NonUnitalRingHomClass.toAddMonoidHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)) (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1)) (AddMonoidHom.id.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_add_monoid_hom_id NonUnitalRingHom.coe_addMonoidHom_id\u2093'. -/\n@[simp]\ntheorem coe_addMonoidHom_id : (NonUnitalRingHom.id \u03b1 : \u03b1 \u2192+ \u03b1) = AddMonoidHom.id \u03b1 :=\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 {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (MulHom.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulHom.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1))) (HasLiftT.mk.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulHom.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1))) (CoeTC\u2093.coe.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulHom.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1))) (MulHom.hasCoeT.{u1, u1, u1} \u03b1 \u03b1 (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))))) (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1)) (MulHom.id.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (MulHom.{u1, u1} \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1)) (MulHomClass.toMulHom.{u1, u1, u1} \u03b1 \u03b1 (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)) (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1)) (MulHom.id.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id\u2093'. -/\n@[simp]\ntheorem coe_mulHom_id : (NonUnitalRingHom.id \u03b1 : \u03b1 \u2192\u2099* \u03b1) = MulHom.id \u03b1 :=\n  rfl\n#align non_unital_ring_hom.coe_mul_hom_id NonUnitalRingHom.coe_mulHom_id\n\nvariable {r\u03b3 : NonUnitalNonAssocSemiring \u03b3}\n\ninclude r\u03b2 r\u03b3\n\n#print NonUnitalRingHom.comp /-\n/-- Composition of non-unital ring homomorphisms is a non-unital ring homomorphism. -/\ndef comp (g : \u03b2 \u2192\u2099+* \u03b3) (f : \u03b1 \u2192\u2099+* \u03b2) : \u03b1 \u2192\u2099+* \u03b3 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} {\u03b4 : Type.{u4}} {r\u03b4 : NonUnitalNonAssocSemiring.{u4} \u03b4} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (g : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (h : NonUnitalRingHom.{u3, u4} \u03b3 \u03b4 r\u03b3 r\u03b4), Eq.{max (succ u1) (succ u4)} (NonUnitalRingHom.{u1, u4} \u03b1 \u03b4 r\u03b1 r\u03b4) (NonUnitalRingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b4 r\u03b1 r\u03b2 r\u03b4 (NonUnitalRingHom.comp.{u2, u3, u4} \u03b2 \u03b3 \u03b4 r\u03b2 r\u03b3 r\u03b4 h g) f) (NonUnitalRingHom.comp.{u1, u3, u4} \u03b1 \u03b3 \u03b4 r\u03b1 r\u03b3 r\u03b4 h (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u3} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u1} \u03b3} {\u03b4 : Type.{u4}} {r\u03b4 : NonUnitalNonAssocSemiring.{u4} \u03b4} (f : NonUnitalRingHom.{u3, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (g : NonUnitalRingHom.{u2, u1} \u03b2 \u03b3 r\u03b2 r\u03b3) (h : NonUnitalRingHom.{u1, u4} \u03b3 \u03b4 r\u03b3 r\u03b4), Eq.{max (succ u3) (succ u4)} (NonUnitalRingHom.{u3, u4} \u03b1 \u03b4 r\u03b1 r\u03b4) (NonUnitalRingHom.comp.{u3, u2, u4} \u03b1 \u03b2 \u03b4 r\u03b1 r\u03b2 r\u03b4 (NonUnitalRingHom.comp.{u2, u1, u4} \u03b2 \u03b3 \u03b4 r\u03b2 r\u03b3 r\u03b4 h g) f) (NonUnitalRingHom.comp.{u3, u1, u4} \u03b1 \u03b3 \u03b4 r\u03b1 r\u03b3 r\u03b4 h (NonUnitalRingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.comp_assoc NonUnitalRingHom.comp_assoc\u2093'. -/\n/-- Composition of non-unital ring homomorphisms is associative. -/\ntheorem comp_assoc {\u03b4} {r\u03b4 : NonUnitalNonAssocSemiring \u03b4} (f : \u03b1 \u2192\u2099+* \u03b2) (g : \u03b2 \u2192\u2099+* \u03b3)\n    (h : \u03b3 \u2192\u2099+* \u03b4) : (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} (g : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u3)} (\u03b1 -> \u03b3) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (fun (_x : NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) => \u03b1 -> \u03b3) (NonUnitalRingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f)) (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (fun (_x : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) => \u03b2 -> \u03b3) (NonUnitalRingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) g) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u3} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u2} \u03b3} (g : NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) (f : NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b3) \u1fb0) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b3) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 r\u03b1 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3))) (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f)) (Function.comp.{succ u1, succ u3, succ u2} \u03b1 \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3))) g) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2))) f))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_comp NonUnitalRingHom.coe_comp\u2093'. -/\n@[simp]\ntheorem coe_comp (g : \u03b2 \u2192\u2099+* \u03b3) (f : \u03b1 \u2192\u2099+* \u03b2) : \u21d1(g.comp f) = g \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} (g : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (x : \u03b1), Eq.{succ u3} \u03b3 (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (fun (_x : NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) => \u03b1 -> \u03b3) (NonUnitalRingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f) x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (fun (_x : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) => \u03b2 -> \u03b3) (NonUnitalRingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) g (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u3} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u2} \u03b3} (g : NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) (f : NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) (x : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b3) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b3) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 r\u03b1 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3))) (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3))) g (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2))) f x))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.comp_apply NonUnitalRingHom.comp_apply\u2093'. -/\n@[simp]\ntheorem comp_apply (g : \u03b2 \u2192\u2099+* \u03b3) (f : \u03b1 \u2192\u2099+* \u03b2) (x : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} (g : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u3) (succ u1)} (AddMonoidHom.{u1, u3} \u03b1 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3)))) ((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} \u03b1 \u03b3 r\u03b1 r\u03b3) (AddMonoidHom.{u1, u3} \u03b1 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3)))) (HasLiftT.mk.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (AddMonoidHom.{u1, u3} \u03b1 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3)))) (CoeTC\u2093.coe.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (AddMonoidHom.{u1, u3} \u03b1 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3)))) (AddMonoidHom.hasCoeT.{u1, u3, max u1 u3} \u03b1 \u03b3 (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 r\u03b1 r\u03b3 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3))))) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f)) (AddMonoidHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3))) ((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} \u03b2 \u03b3 r\u03b2 r\u03b3) (AddMonoidHom.{u2, u3} \u03b2 \u03b3 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3)))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (AddMonoidHom.{u2, u3} \u03b2 \u03b3 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3)))) (CoeTC\u2093.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (AddMonoidHom.{u2, u3} \u03b2 \u03b3 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3)))) (AddMonoidHom.hasCoeT.{u2, u3, max u2 u3} \u03b2 \u03b3 (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (AddMonoid.toAddZeroClass.{u3} \u03b3 (AddCommMonoid.toAddMonoid.{u3} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b3 r\u03b3))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u2 u3, u2, u3} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.nonUnitalRingHomClass.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3))))) 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} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2)))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u3} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u2} \u03b3} (g : NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) (f : NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} \u03b1 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddCommMonoid.toAddMonoid.{u2} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b3 r\u03b3)))) (AddMonoidHom.mk.{u1, u2} \u03b1 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddCommMonoid.toAddMonoid.{u2} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b3 r\u03b3))) (ZeroHom.mk.{u1, u2} \u03b1 \u03b3 (AddZeroClass.toZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1)))) (AddZeroClass.toZero.{u2} \u03b3 (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddCommMonoid.toAddMonoid.{u2} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b3 r\u03b3)))) (Function.comp.{succ u1, succ u3, succ u2} \u03b1 \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) a) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3))) g) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2))) f)) (NonUnitalRingHom.map_zero'.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3 (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f))) (NonUnitalRingHom.map_add'.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3 (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f))) (AddMonoidHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddCommMonoid.toAddMonoid.{u3} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b2 r\u03b2))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddCommMonoid.toAddMonoid.{u2} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b3 r\u03b3))) (AddMonoidHomClass.toAddMonoidHom.{u3, u2, max u3 u2} \u03b2 \u03b3 (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddCommMonoid.toAddMonoid.{u3} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b2 r\u03b2))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddCommMonoid.toAddMonoid.{u2} \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b3 r\u03b3))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3)) g) (AddMonoidHomClass.toAddMonoidHom.{u1, u3, max u1 u3} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b1 r\u03b1))) (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddCommMonoid.toAddMonoid.{u3} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toAddMonoidHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2)) f))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_comp_add_monoid_hom NonUnitalRingHom.coe_comp_addMonoidHom\u2093'. -/\n@[simp]\ntheorem coe_comp_addMonoidHom (g : \u03b2 \u2192\u2099+* \u03b3) (f : \u03b1 \u2192\u2099+* \u03b2) :\n    (g.comp f : \u03b1 \u2192+ \u03b3) = (g : \u03b2 \u2192+ \u03b3).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} (g : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u3) (succ u1)} (MulHom.{u1, u3} \u03b1 \u03b3 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3))) ((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} \u03b1 \u03b3 r\u03b1 r\u03b3) (MulHom.{u1, u3} \u03b1 \u03b3 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3))) (HasLiftT.mk.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (MulHom.{u1, u3} \u03b1 \u03b3 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3))) (CoeTC\u2093.coe.{max (succ u1) (succ u3), max (succ u3) (succ u1)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (MulHom.{u1, u3} \u03b1 \u03b3 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3))) (MulHom.hasCoeT.{u1, u3, max u1 u3} \u03b1 \u03b3 (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 r\u03b1 r\u03b3 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3))))) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f)) (MulHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3)) ((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} \u03b2 \u03b3 r\u03b2 r\u03b3) (MulHom.{u2, u3} \u03b2 \u03b3 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3))) (HasLiftT.mk.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (MulHom.{u2, u3} \u03b2 \u03b3 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3))) (CoeTC\u2093.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (MulHom.{u2, u3} \u03b2 \u03b3 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3))) (MulHom.hasCoeT.{u2, u3, max u2 u3} \u03b2 \u03b3 (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) (Distrib.toHasMul.{u3} \u03b3 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b3 r\u03b3)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u3, u2, u3} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.nonUnitalRingHomClass.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3))))) 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} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulHom.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2))) (MulHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 r\u03b1)) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.nonUnitalRingHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u3} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u2} \u03b3} (g : NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) (f : NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (MulHom.{u1, u2} \u03b1 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3)) (MulHom.mk.{u1, u2} \u03b1 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (Function.comp.{succ u1, succ u3, succ u2} \u03b1 \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 (fun (a : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) a) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3))) g) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2))) f)) (MulHom.map_mul'.{u1, u2} \u03b1 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHom.toMulHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3 (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f)))) (MulHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (MulHomClass.toMulHom.{u3, u2, max u3 u2} \u03b2 \u03b3 (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3)) g) (MulHomClass.toMulHom.{u1, u3, max u1 u3} \u03b1 \u03b2 (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2)) f))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_comp_mul_hom NonUnitalRingHom.coe_comp_mulHom\u2093'. -/\n@[simp]\ntheorem coe_comp_mulHom (g : \u03b2 \u2192\u2099+* \u03b3) (f : \u03b1 \u2192\u2099+* \u03b2) :\n    (g.comp f : \u03b1 \u2192\u2099* \u03b3) = (g : \u03b2 \u2192\u2099* \u03b3).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} (g : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3), Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (OfNat.mk.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (Zero.zero.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.hasZero.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) (OfNat.ofNat.{max u1 u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) 0 (OfNat.mk.{max u1 u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) 0 (Zero.zero.{max u1 u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.hasZero.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u3} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u2} \u03b3} (g : NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g (OfNat.ofNat.{max u1 u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) 0 (Zero.toOfNat0.{max u1 u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2)))) (OfNat.ofNat.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) 0 (Zero.toOfNat0.{max u1 u2} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3)))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.comp_zero NonUnitalRingHom.comp_zero\u2093'. -/\n@[simp]\ntheorem comp_zero (g : \u03b2 \u2192\u2099+* \u03b3) : g.comp (0 : \u03b1 \u2192\u2099+* \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 (OfNat.ofNat.{max u2 u3} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) 0 (OfNat.mk.{max u2 u3} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) 0 (Zero.zero.{max u2 u3} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (NonUnitalRingHom.hasZero.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3)))) f) (OfNat.ofNat.{max u1 u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) 0 (OfNat.mk.{max u1 u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) 0 (Zero.zero.{max u1 u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.hasZero.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u3} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u1} \u03b3} (f : NonUnitalRingHom.{u3, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u3) (succ u1)} (NonUnitalRingHom.{u3, u1} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 (OfNat.ofNat.{max u2 u1} (NonUnitalRingHom.{u2, u1} \u03b2 \u03b3 r\u03b2 r\u03b3) 0 (Zero.toOfNat0.{max u2 u1} (NonUnitalRingHom.{u2, u1} \u03b2 \u03b3 r\u03b2 r\u03b3) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u2, u1} \u03b2 \u03b3 r\u03b2 r\u03b3))) f) (OfNat.ofNat.{max u3 u1} (NonUnitalRingHom.{u3, u1} \u03b1 \u03b3 r\u03b1 r\u03b3) 0 (Zero.toOfNat0.{max u3 u1} (NonUnitalRingHom.{u3, u1} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.instZeroNonUnitalRingHom.{u3, u1} \u03b1 \u03b3 r\u03b1 r\u03b3)))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp\u2093'. -/\n@[simp]\ntheorem zero_comp (f : \u03b1 \u2192\u2099+* \u03b2) : (0 : \u03b2 \u2192\u2099+* \u03b3).comp f = 0 :=\n  by\n  ext\n  rfl\n#align non_unital_ring_hom.zero_comp NonUnitalRingHom.zero_comp\n\nomit r\u03b3\n\n/- warning: non_unital_ring_hom.comp_id -> NonUnitalRingHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.comp.{u1, u1, u2} \u03b1 \u03b1 \u03b2 r\u03b1 r\u03b1 r\u03b2 f (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2] (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.comp.{u2, u2, u1} \u03b1 \u03b1 \u03b2 r\u03b1 r\u03b1 r\u03b2 f (NonUnitalRingHom.id.{u2} \u03b1 r\u03b1)) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.comp_id NonUnitalRingHom.comp_id\u2093'. -/\n@[simp]\ntheorem comp_id (f : \u03b1 \u2192\u2099+* \u03b2) : f.comp (NonUnitalRingHom.id \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] (f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.comp.{u1, u2, u2} \u03b1 \u03b2 \u03b2 r\u03b1 r\u03b2 r\u03b2 (NonUnitalRingHom.id.{u2} \u03b2 r\u03b2) f) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u2} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u1} \u03b2] (f : NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (NonUnitalRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (NonUnitalRingHom.comp.{u2, u1, u1} \u03b1 \u03b2 \u03b2 r\u03b1 r\u03b2 r\u03b2 (NonUnitalRingHom.id.{u1} \u03b2 r\u03b2) f) f\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp\u2093'. -/\n@[simp]\ntheorem id_comp (f : \u03b1 \u2192\u2099+* \u03b2) : (NonUnitalRingHom.id \u03b2).comp f = f :=\n  ext fun x => rfl\n#align non_unital_ring_hom.id_comp NonUnitalRingHom.id_comp\n\nomit r\u03b2\n\ninstance : MonoidWithZero (\u03b1 \u2192\u2099+* \u03b1)\n    where\n  one := NonUnitalRingHom.id \u03b1\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 {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (OfNat.ofNat.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (OfNat.mk.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (One.one.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulOneClass.toHasOne.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroOneClass.toMulOneClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.monoidWithZero.{u1} \u03b1 r\u03b1))))))) (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (OfNat.ofNat.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (One.toOfNat1.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toOne.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidWithZero.toMonoid.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.instMonoidWithZeroNonUnitalRingHom.{u1} \u03b1 r\u03b1))))) (NonUnitalRingHom.id.{u1} \u03b1 r\u03b1)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.one_def NonUnitalRingHom.one_def\u2093'. -/\ntheorem one_def : (1 : \u03b1 \u2192\u2099+* \u03b1) = NonUnitalRingHom.id \u03b1 :=\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 {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (NonUnitalRingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (OfNat.ofNat.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (OfNat.mk.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (One.one.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulOneClass.toHasOne.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroOneClass.toMulOneClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.monoidWithZero.{u1} \u03b1 r\u03b1)))))))) (id.{succ u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) \u1fb0) (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))) (OfNat.ofNat.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (One.toOfNat1.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toOne.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidWithZero.toMonoid.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.instMonoidWithZeroNonUnitalRingHom.{u1} \u03b1 r\u03b1)))))) (id.{succ u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_one NonUnitalRingHom.coe_one\u2093'. -/\n@[simp]\ntheorem coe_one : \u21d1(1 : \u03b1 \u2192\u2099+* \u03b1) = 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 {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] (f : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (g : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1), Eq.{succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (HMul.hMul.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (instHMul.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroClass.toHasMul.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroOneClass.toMulZeroClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.monoidWithZero.{u1} \u03b1 r\u03b1))))) f g) (NonUnitalRingHom.comp.{u1, u1, u1} \u03b1 \u03b1 \u03b1 r\u03b1 r\u03b1 r\u03b1 f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] (f : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (g : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1), Eq.{succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (HMul.hMul.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (instHMul.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroClass.toMul.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroOneClass.toMulZeroClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.instMonoidWithZeroNonUnitalRingHom.{u1} \u03b1 r\u03b1))))) f g) (NonUnitalRingHom.comp.{u1, u1, u1} \u03b1 \u03b1 \u03b1 r\u03b1 r\u03b1 r\u03b1 f g)\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.mul_def NonUnitalRingHom.mul_def\u2093'. -/\ntheorem mul_def (f g : \u03b1 \u2192\u2099+* \u03b1) : 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 {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] (f : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (g : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1), Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (NonUnitalRingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (HMul.hMul.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (instHMul.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroClass.toHasMul.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroOneClass.toMulZeroClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.monoidWithZero.{u1} \u03b1 r\u03b1))))) f g)) (Function.comp.{succ u1, succ u1, succ u1} \u03b1 \u03b1 \u03b1 (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (NonUnitalRingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) f) (coeFn.{succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (NonUnitalRingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] (f : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (g : NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1), Eq.{succ u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) \u1fb0) (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))) (HMul.hMul.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (instHMul.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroClass.toMul.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroOneClass.toMulZeroClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidWithZero.toMulZeroOneClass.{u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (NonUnitalRingHom.instMonoidWithZeroNonUnitalRingHom.{u1} \u03b1 r\u03b1))))) f g)) (Function.comp.{succ u1, succ u1, succ u1} \u03b1 \u03b1 \u03b1 (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))) f) (FunLike.coe.{succ u1, succ u1, succ u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (NonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))) g))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul\u2093'. -/\n@[simp]\ntheorem coe_mul (f g : \u03b1 \u2192\u2099+* \u03b1) : \u21d1(f * g) = f \u2218 g :=\n  rfl\n#align non_unital_ring_hom.coe_mul NonUnitalRingHom.coe_mul\n\ninclude r\u03b2 r\u03b3\n\n/- warning: non_unital_ring_hom.cancel_right -> NonUnitalRingHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} {g\u2081 : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3} {g\u2082 : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3} {f : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (NonUnitalRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g\u2081 f) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g\u2082 f)) (Eq.{max (succ u2) (succ u3)} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) g\u2081 g\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u3} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u2} \u03b3} {g\u2081 : NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3} {g\u2082 : NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3} {f : NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Function.Surjective.{succ u1, succ u3} \u03b1 \u03b2 (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 r\u03b1) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2))) f)) -> (Iff (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g\u2081 f) (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g\u2082 f)) (Eq.{max (succ u3) (succ u2)} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.cancel_right NonUnitalRingHom.cancel_right\u2093'. -/\ntheorem cancel_right {g\u2081 g\u2082 : \u03b2 \u2192\u2099+* \u03b3} {f : \u03b1 \u2192\u2099+* \u03b2} (hf : Surjective f) :\n    g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => ext <| hf.forall.2 (ext_iff.1 h), fun h => h \u25b8 rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u3} \u03b3} {g : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3} {f\u2081 : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2} {f\u2082 : NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (fun (_x : NonUnitalRingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) => \u03b2 -> \u03b3) (NonUnitalRingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f\u2081) (NonUnitalRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f\u2082)) (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f\u2081 f\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [r\u03b1 : NonUnitalNonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonUnitalNonAssocSemiring.{u3} \u03b2] {r\u03b3 : NonUnitalNonAssocSemiring.{u2} \u03b3} {g : NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3} {f\u2081 : NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2} {f\u2082 : NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Function.Injective.{succ u3, succ u2} \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 r\u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 r\u03b3) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (NonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (NonUnitalRingHom.instNonUnitalRingHomClassNonUnitalRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (NonUnitalRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f\u2081) (NonUnitalRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f\u2082)) (Eq.{max (succ u1) (succ u3)} (NonUnitalRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left\u2093'. -/\ntheorem cancel_left {g : \u03b2 \u2192\u2099+* \u03b3} {f\u2081 f\u2082 : \u03b1 \u2192\u2099+* \u03b2} (hg : Injective g) :\n    g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => ext fun x => hg <| by rw [\u2190 comp_apply, h, comp_apply], fun h => h \u25b8 rfl\u27e9\n#align non_unital_ring_hom.cancel_left NonUnitalRingHom.cancel_left\n\nomit r\u03b1 r\u03b2 r\u03b3\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 (\u03b1 : Type _) (\u03b2 : Type _) [NonAssocSemiring \u03b1] [NonAssocSemiring \u03b2] extends\n  \u03b1 \u2192* \u03b2, \u03b1 \u2192+ \u03b2, \u03b1 \u2192\u2099+* \u03b2, \u03b1 \u2192*\u2080 \u03b2\n#align ring_hom RingHom\n-/\n\n-- mathport name: \u00abexpr \u2192+* \u00bb\ninfixr:25 \" \u2192+* \" => RingHom\n\n/-- Reinterpret a ring homomorphism `f : \u03b1 \u2192+* \u03b2` as a monoid with zero homomorphism `\u03b1 \u2192*\u2080 \u03b2`.\nThe `simp`-normal form is `(f : \u03b1 \u2192*\u2080 \u03b2)`. -/\nadd_decl_doc RingHom.toMonoidWithZeroHom\n\n/-- Reinterpret a ring homomorphism `f : \u03b1 \u2192+* \u03b2` as a monoid homomorphism `\u03b1 \u2192* \u03b2`.\nThe `simp`-normal form is `(f : \u03b1 \u2192* \u03b2)`. -/\nadd_decl_doc RingHom.toMonoidHom\n\n/-- Reinterpret a ring homomorphism `f : \u03b1 \u2192+* \u03b2` as an additive monoid homomorphism `\u03b1 \u2192+ \u03b2`.\nThe `simp`-normal form is `(f : \u03b1 \u2192+ \u03b2)`. -/\nadd_decl_doc RingHom.toAddMonoidHom\n\n/-- Reinterpret a ring homomorphism `f : \u03b1 \u2192+* \u03b2` as a non-unital ring homomorphism `\u03b1 \u2192\u2099+* \u03b2`. The\n`simp`-normal form is `(f : \u03b1 \u2192\u2099+* \u03b2)`. -/\nadd_decl_doc RingHom.toNonUnitalRingHom\n\nsection RingHomClass\n\n#print RingHomClass /-\n/-- `ring_hom_class F \u03b1 \u03b2` 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 _) (\u03b1 \u03b2 : outParam (Type _)) [NonAssocSemiring \u03b1]\n  [NonAssocSemiring \u03b2] extends MonoidHomClass F \u03b1 \u03b2, AddMonoidHomClass F \u03b1 \u03b2,\n  MonoidWithZeroHomClass F \u03b1 \u03b2\n#align ring_hom_class RingHomClass\n-/\n\nvariable [NonAssocSemiring \u03b1] [NonAssocSemiring \u03b2] [RingHomClass F \u03b1 \u03b2]\n\n/- warning: map_bit1 -> map_bit1 is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : NonAssocSemiring.{u3} \u03b2] [_inst_3 : RingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : \u03b1), Eq.{succ u3} \u03b2 (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (MulOneClass.toHasMul.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1))) (MulOneClass.toHasMul.{u3} \u03b2 (MulZeroOneClass.toMulOneClass.{u3} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u3} \u03b2 _inst_2))) (MonoidHomClass.toMulHomClass.{u1, u2, u3} F \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u3} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u3} \u03b2 _inst_2)) (RingHomClass.toMonoidHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f (bit1.{u2} \u03b1 (AddMonoidWithOne.toOne.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1))) (Distrib.toHasAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) a)) (bit1.{u3} \u03b2 (AddMonoidWithOne.toOne.{u3} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u3} \u03b2 _inst_2))) (Distrib.toHasAdd.{u3} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 _inst_2))) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (MulOneClass.toHasMul.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1))) (MulOneClass.toHasMul.{u3} \u03b2 (MulZeroOneClass.toMulOneClass.{u3} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u3} \u03b2 _inst_2))) (MonoidHomClass.toMulHomClass.{u1, u2, u3} F \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u3} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u3} \u03b2 _inst_2)) (RingHomClass.toMonoidHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f a))\nbut is expected to have type\n  forall {F : Type.{u1}} {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u3} \u03b1] [_inst_2 : NonAssocSemiring.{u2} \u03b2] [_inst_3 : RingHomClass.{u1, u3, u2} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (bit1.{u3} \u03b1 (NonAssocSemiring.toOne.{u3} \u03b1 _inst_1) (Distrib.toAdd.{u3} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b1 _inst_1))) a)) (FunLike.coe.{succ u1, succ u3, succ u2} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u1, u3, u2} F \u03b1 \u03b2 (MulOneClass.toMul.{u3} \u03b1 (MulZeroOneClass.toMulOneClass.{u3} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u3} \u03b1 _inst_1))) (MulOneClass.toMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_2))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u3} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u3} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_2)) (RingHomClass.toMonoidHomClass.{u1, u3, u2} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3))) f (bit1.{u3} \u03b1 (NonAssocSemiring.toOne.{u3} \u03b1 _inst_1) (Distrib.toAdd.{u3} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b1 _inst_1))) a)) (bit1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonAssocSemiring.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) _inst_2) (Distrib.toAdd.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonUnitalNonAssocSemiring.toDistrib.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) _inst_2))) (FunLike.coe.{succ u1, succ u3, succ u2} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u1, u3, u2} F \u03b1 \u03b2 (MulOneClass.toMul.{u3} \u03b1 (MulZeroOneClass.toMulOneClass.{u3} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u3} \u03b1 _inst_1))) (MulOneClass.toMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_2))) (MonoidHomClass.toMulHomClass.{u1, u3, u2} F \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u3} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u3} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_2)) (RingHomClass.toMonoidHomClass.{u1, u3, u2} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3))) f a))\nCase conversion may be inaccurate. Consider using '#align map_bit1 map_bit1\u2093'. -/\n/-- Ring homomorphisms preserve `bit1`. -/\n@[simp]\ntheorem map_bit1 (f : F) (a : \u03b1) : (f (bit1 a) : \u03b2) = bit1 (f a) := by simp [bit1]\n#align map_bit1 map_bit1\n\ninstance : CoeTC F (\u03b1 \u2192+* \u03b2) :=\n  \u27e8fun 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 }\u27e9\n\n#print RingHomClass.toNonUnitalRingHomClass /-\ninstance (priority := 100) RingHomClass.toNonUnitalRingHomClass : NonUnitalRingHomClass F \u03b1 \u03b2 :=\n  { \u2039RingHomClass F \u03b1 \u03b2\u203a 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\u03b1 : NonAssocSemiring \u03b1} {r\u03b2 : NonAssocSemiring \u03b2}\n\ninclude r\u03b1 r\u03b2\n\ninstance : RingHomClass (\u03b1 \u2192+* \u03b2) \u03b1 \u03b2\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 (\u03b1 \u2192+* \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\n  \u27e8RingHom.toFun\u27e9\n\ninitialize_simps_projections RingHom (toFun \u2192 apply)\n\n/- warning: ring_hom.to_fun_eq_coe -> RingHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (RingHom.toFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (RingHom.toMonoidHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_fun_eq_coe RingHom.toFun_eq_coe\u2093'. -/\n@[simp]\ntheorem toFun_eq_coe (f : \u03b1 \u2192+* \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (MulOneClass.toHasOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))))))) (h\u2082 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (MulOneClass.toHasMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))) (f x) (f y))) (h\u2083 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))))))) (h\u2084 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))))) (f x) (f y))), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f h\u2081 h\u2082 h\u2083 h\u2084)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : MonoidHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (h\u2081 : Eq.{succ u1} \u03b2 (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) f) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (AddZeroClass.toZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))))))) (OfNat.ofNat.{u1} \u03b2 0 (Zero.toOfNat0.{u1} \u03b2 (AddZeroClass.toZero.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2)))))))) (h\u2082 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u1} \u03b2 (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) f) (HAdd.hAdd.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHAdd.{u2} \u03b1 (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))))) x y)) (HAdd.hAdd.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHAdd.{u1} \u03b2 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2)))))) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) f) x) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) f) y))), Eq.{max (succ u2) (succ u1)} (forall (a : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) (RingHom.mk.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f h\u2081 h\u2082)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toMul.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (MonoidHom.monoidHomClass.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))))) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_mk RingHom.coe_mk\u2093'. -/\n@[simp]\ntheorem coe_mk (f : \u03b1 \u2192 \u03b2) (h\u2081 h\u2082 h\u2083 h\u2084) : \u21d1(\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084\u27e9 : \u03b1 \u2192+* \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u1, u2} F \u03b1 \u03b2 r\u03b1 r\u03b2] (f : F), Eq.{max (succ u1) (succ u2)} ((fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (HasLiftT.mk.{succ u3, max (succ u1) (succ u2)} F (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (CoeTC\u2093.coe.{succ u3, max (succ u1) (succ u2)} F (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.hasCoeT.{u3, u1, u2} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (HasLiftT.mk.{succ u3, max (succ u1) (succ u2)} F (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (CoeTC\u2093.coe.{succ u3, max (succ u1) (succ u2)} F (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.hasCoeT.{u3, u1, u2} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1))) f)) (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1))) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toMulHomClass.{u3, u1, u2} F \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{u3, u1, u2} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1)))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u2, u1} F \u03b1 \u03b2 r\u03b1 r\u03b2] (f : F), Eq.{max (succ u2) (succ u1)} (forall (a : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) (RingHomClass.toRingHom.{u3, u2, u1} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1 f)) (FunLike.coe.{succ u3, succ u2, succ u1} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u3, u2, u1} F \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{u3, u2, u1} F \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{u3, u2, u1} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1))) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_coe RingHom.coe_coe\u2093'. -/\n@[simp]\ntheorem coe_coe {F : Type _} [RingHomClass F \u03b1 \u03b2] (f : F) : ((f : \u03b1 \u2192+* \u03b2) : \u03b1 \u2192 \u03b2) = f :=\n  rfl\n#align ring_hom.coe_coe RingHom.coe_coe\n\n#print RingHom.coeToMonoidHom /-\ninstance coeToMonoidHom : Coe (\u03b1 \u2192+* \u03b2) (\u03b1 \u2192* \u03b2) :=\n  \u27e8RingHom.toMonoidHom\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (MonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (RingHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.ringHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}}, (Nat -> \u03b1 -> \u03b2) -> Nat -> (List.{u1} \u03b1) -> (List.{u2} \u03b2)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_monoid_hom [anonymous]\u2093'. -/\n@[simp, norm_cast]\ntheorem [anonymous] (f : \u03b1 \u2192+* \u03b2) : \u21d1(f : \u03b1 \u2192* \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (RingHom.toMonoidHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 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} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (MonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (RingHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.ringHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (RingHom.toMonoidHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f) (MonoidHomClass.toMonoidHom.{u2, u1, max u2 u1} \u03b1 \u03b2 (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (RingHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_monoid_hom_eq_coe RingHom.toMonoidHom_eq_coe\u2093'. -/\n@[simp]\ntheorem toMonoidHom_eq_coe (f : \u03b1 \u2192+* \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} ((fun (_x : MonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) => \u03b1 -> \u03b2) (RingHom.toMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f)) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (fun (_x : MonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) => \u03b1 -> \u03b2) (MonoidWithZeroHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (RingHom.toMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (forall (a : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (MonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) \u03b1 \u03b2 (MulOneClass.toMul.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toMul.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHomClass.toMulHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (MonoidWithZeroHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (MonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2) (MonoidWithZeroHom.monoidWithZeroHomClass.{u2, u1} \u03b1 \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))))) (RingHom.toMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_monoid_with_zero_hom_eq_coe RingHom.toMonoidWithZeroHom_eq_coe\u2093'. -/\n@[simp]\ntheorem toMonoidWithZeroHom_eq_coe (f : \u03b1 \u2192+* \u03b2) : (f.toMonoidWithZeroHom : \u03b1 \u2192 \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (MulOneClass.toHasOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))))))) (h\u2082 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (MulOneClass.toHasMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))) (f x) (f y))) (h\u2083 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))))))) (h\u2084 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))))) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (MonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (RingHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.ringHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) (RingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f h\u2081 h\u2082 h\u2083 h\u2084)) (MonoidHom.mk.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) f h\u2081 h\u2082)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : MonoidHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (h\u2081 : Eq.{succ u1} \u03b2 (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) f) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (AddZeroClass.toZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))))))) (OfNat.ofNat.{u1} \u03b2 0 (Zero.toOfNat0.{u1} \u03b2 (AddZeroClass.toZero.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2)))))))) (h\u2082 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u1} \u03b2 (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) f) (HAdd.hAdd.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHAdd.{u2} \u03b1 (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))))) x y)) (HAdd.hAdd.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHAdd.{u1} \u03b2 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2)))))) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) f) x) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) f) y))), Eq.{max (succ u2) (succ u1)} (MonoidHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHomClass.toMonoidHom.{u2, u1, max u2 u1} \u03b1 \u03b2 (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (RingHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)) (RingHom.mk.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f h\u2081 h\u2082)) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_monoid_hom_mk RingHom.coe_monoidHom_mk\u2093'. -/\n@[simp]\ntheorem coe_monoidHom_mk (f : \u03b1 \u2192 \u03b2) (h\u2081 h\u2082 h\u2083 h\u2084) :\n    ((\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084\u27e9 : \u03b1 \u2192+* \u03b2) : \u03b1 \u2192* \u03b2) = \u27e8f, h\u2081, h\u2082\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (fun (_x : AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) => \u03b1 -> \u03b2) (AddMonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.ringHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}}, (Nat -> \u03b1 -> \u03b2) -> Nat -> (List.{u1} \u03b1) -> (List.{u2} \u03b2)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_add_monoid_hom [anonymous]\u2093'. -/\n@[simp, norm_cast]\ntheorem [anonymous] (f : \u03b1 \u2192+* \u03b2) : \u21d1(f : \u03b1 \u2192+ \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (RingHom.toAddMonoidHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 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} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.ringHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2))))) (RingHom.toAddMonoidHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f) (AddMonoidHomClass.toAddMonoidHom.{u2, u1, max u2 u1} \u03b1 \u03b2 (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2)))) (RingHomClass.toAddMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.to_add_monoid_hom_eq_coe RingHom.toAddMonoidHom_eq_coe\u2093'. -/\n@[simp]\ntheorem toAddMonoidHom_eq_coe (f : \u03b1 \u2192+* \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (MulOneClass.toHasOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))))))) (h\u2082 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (MulOneClass.toHasMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))) (f x) (f y))) (h\u2083 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))))))) (h\u2084 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))))) (f x) (f y))), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.ringHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))) (RingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f h\u2081 h\u2082 h\u2083 h\u2084)) (AddMonoidHom.mk.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))) f h\u2083 h\u2084)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h\u2081 : Eq.{succ u2} \u03b2 (f (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)))))) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))))) (h\u2082 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (OneHom.toFun.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (OneHom.mk.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) f h\u2081) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (MulOneClass.toMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))) (OneHom.toFun.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (OneHom.mk.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) f h\u2081) x) (OneHom.toFun.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (OneHom.mk.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) f h\u2081) y))) (h\u2083 : Eq.{succ u2} \u03b2 (OneHom.toFun.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (MonoidHom.mk.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (OneHom.mk.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) f h\u2081) h\u2082)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (AddZeroClass.toZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))))) (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddZeroClass.toZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))))))) (h\u2084 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (OneHom.toFun.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (MonoidHom.mk.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (OneHom.mk.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) f h\u2081) h\u2082)) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))))) (OneHom.toFun.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (MonoidHom.mk.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (OneHom.mk.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) f h\u2081) h\u2082)) x) (OneHom.toFun.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (MonoidHom.mk.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (OneHom.mk.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) f h\u2081) h\u2082)) y))), Eq.{max (succ u1) (succ u2)} (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (AddMonoidHomClass.toAddMonoidHom.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)) (RingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 (MonoidHom.mk.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (OneHom.mk.{u1, u2} \u03b1 \u03b2 (MulOneClass.toOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MulOneClass.toOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) f h\u2081) h\u2082) h\u2083 h\u2084)) (AddMonoidHom.mk.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))) (ZeroHom.mk.{u1, u2} \u03b1 \u03b2 (AddZeroClass.toZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))) (AddZeroClass.toZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) f h\u2083) h\u2084)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_add_monoid_hom_mk RingHom.coe_addMonoidHom_mk\u2093'. -/\n@[simp]\ntheorem coe_addMonoidHom_mk (f : \u03b1 \u2192 \u03b2) (h\u2081 h\u2082 h\u2083 h\u2084) :\n    ((\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084\u27e9 : \u03b1 \u2192+* \u03b2) : \u03b1 \u2192+ \u03b2) = \u27e8f, h\u2083, h\u2084\u27e9 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)) -> (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f)) -> (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)\nCase conversion may be inaccurate. Consider using '#align ring_hom.copy RingHom.copy\u2093'. -/\n/-- Copy of a `ring_hom` with a new `to_fun` equal to the old one. Useful to fix definitional\nequalities. -/\ndef copy (f : \u03b1 \u2192+* \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u03b1 \u2192+* \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.copy.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f f' h)) f'\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f)), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) (RingHom.copy.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_copy RingHom.coe_copy\u2093'. -/\n@[simp]\ntheorem coe_copy (f : \u03b1 \u2192+* \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.copy.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 f f' h) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f)), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.copy.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 f f' h) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.copy_eq RingHom.copy_eq\u2093'. -/\ntheorem copy_eq (f : \u03b1 \u2192+* \u03b2) (f' : \u03b1 \u2192 \u03b2) (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\u03b1 : NonAssocSemiring \u03b1] [r\u03b2 : NonAssocSemiring \u03b2]\n\nsection\n\ninclude r\u03b1 r\u03b2\n\nvariable (f : \u03b1 \u2192+* \u03b2) {x y : \u03b1} {r\u03b1 r\u03b2}\n\n/- warning: ring_hom.congr_fun -> RingHom.congr_fun is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} {f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2} {g : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f g) -> (forall (x : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) g x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} {f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2} {g : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) f g) -> (forall (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) g x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.congr_fun RingHom.congr_fun\u2093'. -/\ntheorem congr_fun {f g : \u03b1 \u2192+* \u03b2} (h : f = g) (x : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) {x : \u03b1} {y : \u03b1}, (Eq.{succ u1} \u03b1 x y) -> (Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f y))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) {x : \u03b1} {y : \u03b1}, (Eq.{succ u2} \u03b1 x y) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f y))\nCase conversion may be inaccurate. Consider using '#align ring_hom.congr_arg RingHom.congr_arg\u2093'. -/\ntheorem congr_arg (f : \u03b1 \u2192+* \u03b2) {x y : \u03b1} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} {{f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}} {{g : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}}, (Eq.{max (succ u1) (succ u2)} ((fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) g)) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} {{f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}} {{g : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}}, (Eq.{max (succ u2) (succ u1)} (forall (a : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) g)) -> (Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) f g)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_inj RingHom.coe_inj\u2093'. -/\ntheorem coe_inj \u2983f g : \u03b1 \u2192+* \u03b2\u2984 (h : (f : \u03b1 \u2192 \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} {{f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}} {{g : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}}, (forall (x : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) g x)) -> (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} {{f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}} {{g : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}}, (forall (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) g x)) -> (Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) f g)\nCase conversion may be inaccurate. Consider using '#align ring_hom.ext RingHom.ext\u2093'. -/\n@[ext]\ntheorem ext \u2983f g : \u03b1 \u2192+* \u03b2\u2984 : (\u2200 x, f x = g x) \u2192 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} {f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2} {g : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}, Iff (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f g) (forall (x : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) g x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} {f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2} {g : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2}, Iff (Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) f g) (forall (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) g x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.ext_iff RingHom.ext_iff\u2093'. -/\ntheorem ext_iff {f g : \u03b1 \u2192+* \u03b2} : f = g \u2194 \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (h\u2081 : Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (MulOneClass.toHasOne.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))))))) (h\u2082 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)))) x y)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (MulOneClass.toHasMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f y))) (h\u2083 : Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))))))) (h\u2084 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))) x y)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f y))), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.mk.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f) h\u2081 h\u2082 h\u2083 h\u2084) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (h\u2081 : Eq.{succ u1} \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)))))) (h\u2082 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u1} \u03b2 (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (OneHom.mk.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) h\u2081) (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) x y)) (HMul.hMul.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (MulOneClass.toMul.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)))) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (OneHom.mk.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) h\u2081) x) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (OneHom.mk.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) h\u2081) y))) (h\u2083 : Eq.{succ u1} \u03b2 (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (MonoidHom.mk.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (OneHom.mk.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) h\u2081) h\u2082)) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (AddZeroClass.toZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))))))) (OfNat.ofNat.{u1} \u03b2 0 (Zero.toOfNat0.{u1} \u03b2 (AddZeroClass.toZero.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2)))))))) (h\u2084 : forall (x : \u03b1) (y : \u03b1), Eq.{succ u1} \u03b2 (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (MonoidHom.mk.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (OneHom.mk.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) h\u2081) h\u2082)) (HAdd.hAdd.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHAdd.{u2} \u03b1 (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))))) x y)) (HAdd.hAdd.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHAdd.{u1} \u03b2 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2)))))) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (MonoidHom.mk.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (OneHom.mk.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) h\u2081) h\u2082)) x) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (MonoidHom.mk.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (OneHom.mk.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) h\u2081) h\u2082)) y))), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.mk.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2 (MonoidHom.mk.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (OneHom.mk.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f) h\u2081) h\u2082) h\u2083 h\u2084) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.mk_coe RingHom.mk_coe\u2093'. -/\n@[simp]\ntheorem mk_coe (f : \u03b1 \u2192+* \u03b2) (h\u2081 h\u2082 h\u2083 h\u2084) : RingHom.mk f h\u2081 h\u2082 h\u2083 h\u2084 = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2}, Function.Injective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u1, u2} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))) (AddMonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))) (RingHomClass.toAddMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.ringHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoidHom.{u2, u1} \u03b1 \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2))))) (fun (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) => AddMonoidHomClass.toAddMonoidHom.{u2, u1, max u2 u1} \u03b1 \u03b2 (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 r\u03b2)))) (RingHomClass.toAddMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_add_monoid_hom_injective RingHom.coe_addMonoidHom_injective\u2093'. -/\ntheorem coe_addMonoidHom_injective : Injective (coe : (\u03b1 \u2192+* \u03b2) \u2192 \u03b1 \u2192+ \u03b2) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2}, Function.Injective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) ((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} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))) (MonoidHom.hasCoeT.{u1, u2, max u1 u2} \u03b1 \u03b2 (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)) (RingHomClass.toMonoidHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.ringHomClass.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (MonoidHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2))) (fun (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) => MonoidHomClass.toMonoidHom.{u2, u1, max u2 u1} \u03b1 \u03b2 (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 r\u03b2)) (RingHomClass.toMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_monoid_hom_injective RingHom.coe_monoidHom_injective\u2093'. -/\ntheorem coe_monoidHom_injective : Injective (coe : (\u03b1 \u2192+* \u03b2) \u2192 \u03b1 \u2192* \u03b2) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))))) (MulZeroOneClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))))) (NonAssocSemiring.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1))))) r\u03b2))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_zero RingHom.map_zero\u2093'. -/\n/-- Ring homomorphisms map zero to zero. -/\nprotected theorem map_zero (f : \u03b1 \u2192+* \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1)))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1)))) (NonAssocSemiring.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1)))) r\u03b2)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_one RingHom.map_one\u2093'. -/\n/-- Ring homomorphisms map one to one. -/\nprotected theorem map_one (f : \u03b1 \u2192+* \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (a : \u03b1) (b : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)))) a b)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (a : \u03b1) (b : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (HAdd.hAdd.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHAdd.{u2} \u03b1 (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)))) a b)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f (HAdd.hAdd.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHAdd.{u2} \u03b1 (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)))) a b)) (HAdd.hAdd.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (instHAdd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (Distrib.toAdd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonUnitalNonAssocSemiring.toDistrib.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) r\u03b2)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f b))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_add RingHom.map_add\u2093'. -/\n/-- Ring homomorphisms preserve addition. -/\nprotected theorem map_add (f : \u03b1 \u2192+* \u03b2) : \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (a : \u03b1) (b : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)))) a b)) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (a : \u03b1) (b : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1))) a b)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1))) a b)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonUnitalNonAssocSemiring.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) r\u03b2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f b))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_mul RingHom.map_mul\u2093'. -/\n/-- Ring homomorphisms preserve multiplication. -/\nprotected theorem map_mul (f : \u03b1 \u2192+* \u03b2) : \u2200 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 : \u03b1 \u2192+* \u03b2) : \u2200 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 : \u03b1 \u2192+* \u03b2) : \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u1, u2} F \u03b1 \u03b2 r\u03b1 r\u03b2] (f : F) (p : Prop) [_inst_2 : Decidable p], Eq.{succ u2} \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1))) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toMulHomClass.{u3, u1, u2} F \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{u3, u1, u2} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1)))) f (ite.{succ u1} \u03b1 p _inst_2 (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))))) (ite.{succ u2} \u03b2 p _inst_2 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u2, u1} F \u03b1 \u03b2 r\u03b1 r\u03b2] (f : F) (p : Prop) [_inst_2 : Decidable p], Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) (FunLike.coe.{succ u3, succ u2, succ u1} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u3, u2, u1} F \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{u3, u2, u1} F \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{u3, u2, u1} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1))) f (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) (ite.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) p _inst_2 (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) (MulZeroOneClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) (NonAssocSemiring.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) r\u03b2)))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) (NonAssocSemiring.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))))) r\u03b2))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_ite_zero_one RingHom.map_ite_zero_one\u2093'. -/\n@[simp]\ntheorem map_ite_zero_one {F : Type _} [RingHomClass F \u03b1 \u03b2] (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u1, u2} F \u03b1 \u03b2 r\u03b1 r\u03b2] (f : F) (p : Prop) [_inst_2 : Decidable p], Eq.{succ u2} \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (MulHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1))) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2))) (NonUnitalRingHomClass.toMulHomClass.{u3, u1, u2} F \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{u3, u1, u2} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1)))) f (ite.{succ u1} \u03b1 p _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)))))))) (ite.{succ u2} \u03b2 p _inst_2 (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2)))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} {F : Type.{u3}} [_inst_1 : RingHomClass.{u3, u2, u1} F \u03b1 \u03b2 r\u03b1 r\u03b2] (f : F) (p : Prop) [_inst_2 : Decidable p], Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) (FunLike.coe.{succ u3, succ u2, succ u1} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{u3, u2, u1} F \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{u3, u2, u1} F \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{u3, u2, u1} F \u03b1 \u03b2 r\u03b1 r\u03b2 _inst_1))) f (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) (ite.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) p _inst_2 (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) (NonAssocSemiring.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) r\u03b2))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) (MulZeroOneClass.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) (NonAssocSemiring.toMulZeroOneClass.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (ite.{succ u2} \u03b1 p _inst_2 (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocSemiring.toOne.{u2} \u03b1 r\u03b1))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MulZeroOneClass.toZero.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 r\u03b1)))))) r\u03b2)))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_ite_one_zero RingHom.map_ite_one_zero\u2093'. -/\n@[simp]\ntheorem map_ite_one_zero {F : Type _} [RingHomClass F \u03b1 \u03b2] (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Iff (Eq.{succ u2} \u03b2 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))))) (Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Iff (Eq.{succ u2} \u03b2 (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (MulZeroOneClass.toZero.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocSemiring.toOne.{u2} \u03b2 r\u03b2)))) (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) (MulZeroOneClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) (NonAssocSemiring.toMulZeroOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) r\u03b2)))))\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\u2093'. -/\n/-- `f : \u03b1 \u2192+* \u03b2` has a trivial codomain iff `f 1 = 0`. -/\ntheorem codomain_trivial_iff_map_one_eq_zero : (0 : \u03b2) = 1 \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Iff (Eq.{succ u2} \u03b2 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))))) (forall (x : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f x) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Iff (Eq.{succ u2} \u03b2 (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (MulZeroOneClass.toZero.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocSemiring.toOne.{u2} \u03b2 r\u03b2)))) (forall (x : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f x) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (MulZeroOneClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (NonAssocSemiring.toMulZeroOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) r\u03b2)))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.codomain_trivial_iff_range_trivial RingHom.codomain_trivial_iff_range_trivial\u2093'. -/\n/-- `f : \u03b1 \u2192+* \u03b2` has a trivial codomain iff it has a trivial range. -/\ntheorem codomain_trivial_iff_range_trivial : (0 : \u03b2) = 1 \u2194 \u2200 x, f x = 0 :=\n  f.codomain_trivial_iff_map_one_eq_zero.trans\n    \u27e8fun h x => by rw [\u2190 mul_one x, map_mul, h, MulZeroClass.mul_zero], fun h => h 1\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Iff (Eq.{succ u2} \u03b2 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)))))) (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 r\u03b2))))))) (Eq.{succ u2} (Set.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)) (Singleton.singleton.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasSingleton.{u2} \u03b2) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Iff (Eq.{succ u2} \u03b2 (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (MulZeroOneClass.toZero.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2)))) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocSemiring.toOne.{u2} \u03b2 r\u03b2)))) (Eq.{succ u2} (Set.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f)) (Singleton.singleton.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.instSingletonSet.{u2} \u03b2) (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (MulZeroOneClass.toZero.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 r\u03b2))))))\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\u2093'. -/\n/-- `f : \u03b1 \u2192+* \u03b2` has a trivial codomain iff its range is `{0}`. -/\ntheorem codomain_trivial_iff_range_eq_singleton_zero : (0 : \u03b2) = 1 \u2194 Set.range f = {0} :=\n  f.codomain_trivial_iff_range_trivial.trans\n    \u27e8fun h =>\n      Set.ext fun y => \u27e8fun \u27e8x, hx\u27e9 => by simp [\u2190 hx, h x], fun hy => \u27e80, by simpa using hy.symm\u27e9\u27e9,\n      fun h x => Set.mem_singleton_iff.mp (h \u25b8 Set.mem_range_self x)\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) [_inst_1 : Nontrivial.{u2} \u03b2], Ne.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (MulZeroClass.toHasZero.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMulZeroClass.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) [_inst_1 : Nontrivial.{u2} \u03b2], Ne.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) (MulZeroOneClass.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) (NonAssocSemiring.toMulZeroOneClass.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocSemiring.toOne.{u1} \u03b1 r\u03b1)))) r\u03b2))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_one_ne_zero RingHom.map_one_ne_zero\u2093'. -/\n/-- `f : \u03b1 \u2192+* \u03b2` doesn't map `1` to `0` if `\u03b2` is nontrivial -/\ntheorem map_one_ne_zero [Nontrivial \u03b2] : f 1 \u2260 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 : \u03b1 \u2192+* \u03b2` and `\u03b2` is nontrivial, then `\u03b1` is nontrivial. -/\ntheorem domain_nontrivial [Nontrivial \u03b2] : Nontrivial \u03b1 :=\n  \u27e8\u27e81, 0, mt (fun h => show f 1 = 0 by rw [h, map_zero]) f.map_one_ne_zero\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2}, (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) -> (forall [h : Subsingleton.{succ u1} \u03b1], Subsingleton.{succ u2} \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2}, (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) -> (forall [h : Subsingleton.{succ u2} \u03b1], Subsingleton.{succ u1} \u03b2)\nCase conversion may be inaccurate. Consider using '#align ring_hom.codomain_trivial RingHom.codomain_trivial\u2093'. -/\ntheorem codomain_trivial (f : \u03b1 \u2192+* \u03b2) [h : Subsingleton \u03b1] : Subsingleton \u03b2 :=\n  (subsingleton_or_nontrivial \u03b2).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocRing.{u1} \u03b1] [_inst_2 : NonAssocRing.{u2} \u03b2] (f : RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (x : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) f (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u1} \u03b1 _inst_1))))) x)) (Neg.neg.{u2} \u03b2 (SubNegMonoid.toHasNeg.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddGroupWithOne.toAddGroup.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (NonAssocRing.toAddCommGroupWithOne.{u2} \u03b2 _inst_2))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) f x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocRing.{u2} \u03b1] [_inst_2 : NonAssocRing.{u1} \u03b2] (f : RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (Neg.neg.{u2} \u03b1 (AddGroupWithOne.toNeg.{u2} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u2} \u03b1 _inst_1))) x)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))))) f (Neg.neg.{u2} \u03b1 (AddGroupWithOne.toNeg.{u2} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u2} \u03b1 _inst_1))) x)) (Neg.neg.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (AddGroupWithOne.toNeg.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (AddCommGroupWithOne.toAddGroupWithOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (NonAssocRing.toAddCommGroupWithOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) _inst_2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))))) f x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_neg RingHom.map_neg\u2093'. -/\n/-- Ring homomorphisms preserve additive inverse. -/\nprotected theorem map_neg [NonAssocRing \u03b1] [NonAssocRing \u03b2] (f : \u03b1 \u2192+* \u03b2) (x : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocRing.{u1} \u03b1] [_inst_2 : NonAssocRing.{u2} \u03b2] (f : RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) f (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u1} \u03b1 _inst_1)))))) x y)) (HSub.hSub.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHSub.{u2} \u03b2 (SubNegMonoid.toHasSub.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddGroupWithOne.toAddGroup.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (NonAssocRing.toAddCommGroupWithOne.{u2} \u03b2 _inst_2)))))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) f x) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)) f y))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocRing.{u2} \u03b1] [_inst_2 : NonAssocRing.{u1} \u03b2] (f : RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (x : \u03b1) (y : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (HSub.hSub.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHSub.{u2} \u03b1 (AddGroupWithOne.toSub.{u2} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u2} \u03b1 _inst_1)))) x y)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))))) f (HSub.hSub.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHSub.{u2} \u03b1 (AddGroupWithOne.toSub.{u2} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b1 (NonAssocRing.toAddCommGroupWithOne.{u2} \u03b1 _inst_1)))) x y)) (HSub.hSub.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) y) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (instHSub.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (AddGroupWithOne.toSub.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (AddCommGroupWithOne.toAddGroupWithOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) (NonAssocRing.toAddCommGroupWithOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) x) _inst_2)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 _inst_2))))) f y))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_sub RingHom.map_sub\u2093'. -/\n/-- Ring homomorphisms preserve subtraction. -/\nprotected theorem map_sub [NonAssocRing \u03b1] [NonAssocRing \u03b2] (f : \u03b1 \u2192+* \u03b2) (x y : \u03b1) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : NonAssocRing.{u2} \u03b2] (f : MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))), (forall (a : \u03b1) (b : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)))) a b)) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 _inst_2))))) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) f a) (coeFn.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) (fun (_x : MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) => \u03b1 -> \u03b2) (MonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) f b))) -> (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : NonAssocRing.{u2} \u03b2] (f : MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))), (forall (a : \u03b1) (b : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)))) a b)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1))) (MulOneClass.toMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2))) (MonoidHom.monoidHomClass.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))))) f (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)))) a b)) (HAdd.hAdd.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) b) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (instHAdd.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (Distrib.toAdd.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonUnitalNonAssocSemiring.toDistrib.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonAssocRing.toNonUnitalNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) _inst_2))))) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1))) (MulOneClass.toMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2))) (MonoidHom.monoidHomClass.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))))) f a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 \u03b2 (MulOneClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1))) (MulOneClass.toMul.{u2} \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) (MonoidHomClass.toMulHomClass.{max u1 u2, u1, u2} (MonoidHom.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))) \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2))) (MonoidHom.monoidHomClass.{u1, u2} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u2} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2)))))) f b))) -> (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 _inst_2))\nCase conversion may be inaccurate. Consider using '#align ring_hom.mk' RingHom.mk'\u2093'. -/\n/-- Makes a ring homomorphism from a monoid homomorphism of rings which preserves addition. -/\ndef mk' [NonAssocSemiring \u03b1] [NonAssocRing \u03b2] (f : \u03b1 \u2192* \u03b2)\n    (map_add : \u2200 a b, f (a + b) = f a + f b) : \u03b1 \u2192+* \u03b2 :=\n  { AddMonoidHom.mk' f map_add, f with }\n#align ring_hom.mk' RingHom.mk'\n\nsection Semiring\n\nvariable [Semiring \u03b1] [Semiring \u03b2]\n\n/- warning: ring_hom.is_unit_map -> RingHom.isUnit_map is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Semiring.{u1} \u03b1] [_inst_2 : Semiring.{u2} \u03b2] (f : RingHom.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) {a : \u03b1}, (IsUnit.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 _inst_1)) a) -> (IsUnit.{u2} \u03b2 (MonoidWithZero.toMonoid.{u2} \u03b2 (Semiring.toMonoidWithZero.{u2} \u03b2 _inst_2)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) f a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Semiring.{u2} \u03b1] [_inst_2 : Semiring.{u1} \u03b2] (f : RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) {a : \u03b1}, (IsUnit.{u2} \u03b1 (MonoidWithZero.toMonoid.{u2} \u03b1 (Semiring.toMonoidWithZero.{u2} \u03b1 _inst_1)) a) -> (IsUnit.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (MonoidWithZero.toMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (Semiring.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) _inst_2)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2))))) f a))\nCase conversion may be inaccurate. Consider using '#align ring_hom.is_unit_map RingHom.isUnit_map\u2093'. -/\ntheorem isUnit_map (f : \u03b1 \u2192+* \u03b2) {a : \u03b1} : IsUnit a \u2192 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Semiring.{u1} \u03b1] [_inst_2 : Semiring.{u2} \u03b2] (f : RingHom.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) {a : \u03b1} {b : \u03b1}, (Dvd.Dvd.{u1} \u03b1 (semigroupDvd.{u1} \u03b1 (SemigroupWithZero.toSemigroup.{u1} \u03b1 (NonUnitalSemiring.toSemigroupWithZero.{u1} \u03b1 (Semiring.toNonUnitalSemiring.{u1} \u03b1 _inst_1)))) a b) -> (Dvd.Dvd.{u2} \u03b2 (semigroupDvd.{u2} \u03b2 (SemigroupWithZero.toSemigroup.{u2} \u03b2 (NonUnitalSemiring.toSemigroupWithZero.{u2} \u03b2 (Semiring.toNonUnitalSemiring.{u2} \u03b2 _inst_2)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2)) f b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Semiring.{u2} \u03b1] [_inst_2 : Semiring.{u1} \u03b2] (f : RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) {a : \u03b1} {b : \u03b1}, (Dvd.dvd.{u2} \u03b1 (semigroupDvd.{u2} \u03b1 (SemigroupWithZero.toSemigroup.{u2} \u03b1 (NonUnitalSemiring.toSemigroupWithZero.{u2} \u03b1 (Semiring.toNonUnitalSemiring.{u2} \u03b1 _inst_1)))) a b) -> (Dvd.dvd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (semigroupDvd.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (SemigroupWithZero.toSemigroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (NonUnitalSemiring.toSemigroupWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (Semiring.toNonUnitalSemiring.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) _inst_2)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2)) \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2) (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b1 _inst_1) (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2))))) f b))\nCase conversion may be inaccurate. Consider using '#align ring_hom.map_dvd RingHom.map_dvd\u2093'. -/\nprotected theorem map_dvd (f : \u03b1 \u2192+* \u03b2) {a b : \u03b1} : a \u2223 b \u2192 f a \u2223 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 (\u03b1 : Type _) [NonAssocSemiring \u03b1] : \u03b1 \u2192+* \u03b1 := by\n  refine' { toFun := id.. } <;> intros <;> rfl\n#align ring_hom.id RingHom.id\n-/\n\ninclude r\u03b1\n\ninstance : Inhabited (\u03b1 \u2192+* \u03b1) :=\n  \u27e8id \u03b1\u27e9\n\n/- warning: ring_hom.id_apply -> RingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] (x : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (RingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.id.{u1} \u03b1 r\u03b1) x) x\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} (x : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) x) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.instRingHomClassRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)))) (RingHom.id.{u1} \u03b1 r\u03b1) x) x\nCase conversion may be inaccurate. Consider using '#align ring_hom.id_apply RingHom.id_apply\u2093'. -/\n@[simp]\ntheorem id_apply (x : \u03b1) : RingHom.id \u03b1 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 {\u03b1 : Type.{u1}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))) (HasLiftT.mk.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))) (CoeTC\u2093.coe.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))) (AddMonoidHom.hasCoeT.{u1, u1, u1} \u03b1 \u03b1 (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (RingHomClass.toAddMonoidHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.ringHomClass.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))))) (RingHom.id.{u1} \u03b1 r\u03b1)) (AddMonoidHom.id.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1}, Eq.{succ u1} (AddMonoidHom.{u1, u1} \u03b1 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1))))) (AddMonoidHomClass.toAddMonoidHom.{u1, u1, u1} \u03b1 \u03b1 (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))) (RingHomClass.toAddMonoidHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.instRingHomClassRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)) (RingHom.id.{u1} \u03b1 r\u03b1)) (AddMonoidHom.id.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 r\u03b1)))))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_add_monoid_hom_id RingHom.coe_addMonoidHom_id\u2093'. -/\n@[simp]\ntheorem coe_addMonoidHom_id : (id \u03b1 : \u03b1 \u2192+ \u03b1) = AddMonoidHom.id \u03b1 :=\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 {\u03b1 : Type.{u1}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidHom.{u1, u1} \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (HasLiftT.mk.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidHom.{u1, u1} \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (CoeTC\u2093.coe.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MonoidHom.{u1, u1} \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MonoidHom.hasCoeT.{u1, u1, u1} \u03b1 \u03b1 (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (RingHomClass.toMonoidHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.ringHomClass.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1))))) (RingHom.id.{u1} \u03b1 r\u03b1)) (MonoidHom.id.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1}, Eq.{succ u1} (MonoidHom.{u1, u1} \u03b1 \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1))) (MonoidHomClass.toMonoidHom.{u1, u1, u1} \u03b1 \u03b1 (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)) (RingHomClass.toMonoidHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.instRingHomClassRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)) (RingHom.id.{u1} \u03b1 r\u03b1)) (MonoidHom.id.{u1} \u03b1 (MulZeroOneClass.toMulOneClass.{u1} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 r\u03b1)))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_monoid_hom_id RingHom.coe_monoidHom_id\u2093'. -/\n@[simp]\ntheorem coe_monoidHom_id : (id \u03b1 : \u03b1 \u2192* \u03b1) = MonoidHom.id \u03b1 :=\n  rfl\n#align ring_hom.coe_monoid_hom_id RingHom.coe_monoidHom_id\n\nvariable {r\u03b3 : NonAssocSemiring \u03b3}\n\ninclude r\u03b2 r\u03b3\n\n#print RingHom.comp /-\n/-- Composition of ring homomorphisms is a ring homomorphism. -/\ndef comp (g : \u03b2 \u2192+* \u03b3) (f : \u03b1 \u2192+* \u03b2) : \u03b1 \u2192+* \u03b3 :=\n  {\n    g.toNonUnitalRingHom.comp f.toNonUnitalRingHom with\n    toFun := g \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonAssocSemiring.{u3} \u03b3} {\u03b4 : Type.{u4}} {r\u03b4 : NonAssocSemiring.{u4} \u03b4} (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (g : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (h : RingHom.{u3, u4} \u03b3 \u03b4 r\u03b3 r\u03b4), Eq.{max (succ u1) (succ u4)} (RingHom.{u1, u4} \u03b1 \u03b4 r\u03b1 r\u03b4) (RingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b4 r\u03b1 r\u03b2 r\u03b4 (RingHom.comp.{u2, u3, u4} \u03b2 \u03b3 \u03b4 r\u03b2 r\u03b3 r\u03b4 h g) f) (RingHom.comp.{u1, u3, u4} \u03b1 \u03b3 \u03b4 r\u03b1 r\u03b3 r\u03b4 h (RingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u3} \u03b1} {r\u03b2 : NonAssocSemiring.{u2} \u03b2} {r\u03b3 : NonAssocSemiring.{u1} \u03b3} {\u03b4 : Type.{u4}} {r\u03b4 : NonAssocSemiring.{u4} \u03b4} (f : RingHom.{u3, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (g : RingHom.{u2, u1} \u03b2 \u03b3 r\u03b2 r\u03b3) (h : RingHom.{u1, u4} \u03b3 \u03b4 r\u03b3 r\u03b4), Eq.{max (succ u3) (succ u4)} (RingHom.{u3, u4} \u03b1 \u03b4 r\u03b1 r\u03b4) (RingHom.comp.{u3, u2, u4} \u03b1 \u03b2 \u03b4 r\u03b1 r\u03b2 r\u03b4 (RingHom.comp.{u2, u1, u4} \u03b2 \u03b3 \u03b4 r\u03b2 r\u03b3 r\u03b4 h g) f) (RingHom.comp.{u3, u1, u4} \u03b1 \u03b3 \u03b4 r\u03b1 r\u03b3 r\u03b4 h (RingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f))\nCase conversion may be inaccurate. Consider using '#align ring_hom.comp_assoc RingHom.comp_assoc\u2093'. -/\n/-- Composition of semiring homomorphisms is associative. -/\ntheorem comp_assoc {\u03b4} {r\u03b4 : NonAssocSemiring \u03b4} (f : \u03b1 \u2192+* \u03b2) (g : \u03b2 \u2192+* \u03b3) (h : \u03b3 \u2192+* \u03b4) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonAssocSemiring.{u3} \u03b3} (hnp : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (hmn : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u3)} ((fun (_x : RingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) => \u03b1 -> \u03b3) (RingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 hnp hmn)) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (fun (_x : RingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) => \u03b1 -> \u03b3) (RingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (RingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 hnp hmn)) (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (fun (_x : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) => \u03b2 -> \u03b3) (RingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) hnp) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) hmn))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u3} \u03b2} {r\u03b3 : NonAssocSemiring.{u2} \u03b3} (hnp : RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) (hmn : RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (forall (a : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b3) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b3) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 r\u03b1 r\u03b3 (RingHom.instRingHomClassRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3)))) (RingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 hnp hmn)) (Function.comp.{succ u1, succ u3, succ u2} \u03b1 \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (RingHom.instRingHomClassRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3)))) hnp) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2)))) hmn))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_comp RingHom.coe_comp\u2093'. -/\n@[simp]\ntheorem coe_comp (hnp : \u03b2 \u2192+* \u03b3) (hmn : \u03b1 \u2192+* \u03b2) : (hnp.comp hmn : \u03b1 \u2192 \u03b3) = hnp \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonAssocSemiring.{u3} \u03b3} (hnp : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (hmn : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (x : \u03b1), Eq.{succ u3} \u03b3 (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (fun (_x : RingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) => \u03b1 -> \u03b3) (RingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (RingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 hnp hmn) x) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (fun (_x : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) => \u03b2 -> \u03b3) (RingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) hnp (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) hmn x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u3} \u03b2} {r\u03b3 : NonAssocSemiring.{u2} \u03b3} (hnp : RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) (hmn : RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) (x : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b3) x) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b3) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) \u03b1 \u03b3 r\u03b1 r\u03b3 (RingHom.instRingHomClassRingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3)))) (RingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 hnp hmn) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (RingHom.instRingHomClassRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3)))) hnp (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2)))) hmn x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.comp_apply RingHom.comp_apply\u2093'. -/\ntheorem comp_apply (hnp : \u03b2 \u2192+* \u03b3) (hmn : \u03b1 \u2192+* \u03b2) (x : \u03b1) :\n    (hnp.comp hmn : \u03b1 \u2192 \u03b3) x = hnp (hmn x) :=\n  rfl\n#align ring_hom.comp_apply RingHom.comp_apply\n\nomit r\u03b3\n\n/- warning: ring_hom.comp_id -> RingHom.comp_id is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonAssocSemiring.{u2} \u03b2] (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.comp.{u1, u1, u2} \u03b1 \u03b1 \u03b2 r\u03b1 r\u03b1 r\u03b2 f (RingHom.id.{u1} \u03b1 r\u03b1)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.comp.{u2, u2, u1} \u03b1 \u03b1 \u03b2 r\u03b1 r\u03b1 r\u03b2 f (RingHom.id.{u2} \u03b1 r\u03b1)) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.comp_id RingHom.comp_id\u2093'. -/\n@[simp]\ntheorem comp_id (f : \u03b1 \u2192+* \u03b2) : f.comp (id \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonAssocSemiring.{u2} \u03b2] (f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.comp.{u1, u2, u2} \u03b1 \u03b2 \u03b2 r\u03b1 r\u03b2 r\u03b2 (RingHom.id.{u2} \u03b2 r\u03b2) f) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u2} \u03b1} {r\u03b2 : NonAssocSemiring.{u1} \u03b2} (f : RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 r\u03b1 r\u03b2) (RingHom.comp.{u2, u1, u1} \u03b1 \u03b2 \u03b2 r\u03b1 r\u03b2 r\u03b2 (RingHom.id.{u1} \u03b2 r\u03b2) f) f\nCase conversion may be inaccurate. Consider using '#align ring_hom.id_comp RingHom.id_comp\u2093'. -/\n@[simp]\ntheorem id_comp (f : \u03b1 \u2192+* \u03b2) : (id \u03b2).comp f = f :=\n  ext fun x => rfl\n#align ring_hom.id_comp RingHom.id_comp\n\nomit r\u03b2\n\ninstance : Monoid (\u03b1 \u2192+* \u03b1) where\n  one := id \u03b1\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 {\u03b1 : Type.{u1}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (OfNat.ofNat.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (OfNat.mk.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (One.one.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulOneClass.toHasOne.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.monoid.{u1} \u03b1 r\u03b1)))))) (RingHom.id.{u1} \u03b1 r\u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1}, Eq.{succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (OfNat.ofNat.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (One.toOfNat1.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toOne.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.instMonoidRingHom.{u1} \u03b1 r\u03b1)))) (RingHom.id.{u1} \u03b1 r\u03b1)\nCase conversion may be inaccurate. Consider using '#align ring_hom.one_def RingHom.one_def\u2093'. -/\ntheorem one_def : (1 : \u03b1 \u2192+* \u03b1) = id \u03b1 :=\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 {\u03b1 : Type.{u1}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] (f : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (g : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1), Eq.{succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (HMul.hMul.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (instHMul.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulOneClass.toHasMul.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.monoid.{u1} \u03b1 r\u03b1)))) f g) (RingHom.comp.{u1, u1, u1} \u03b1 \u03b1 \u03b1 r\u03b1 r\u03b1 r\u03b1 f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} (f : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (g : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1), Eq.{succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (HMul.hMul.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (instHMul.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulOneClass.toMul.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.instMonoidRingHom.{u1} \u03b1 r\u03b1)))) f g) (RingHom.comp.{u1, u1, u1} \u03b1 \u03b1 \u03b1 r\u03b1 r\u03b1 r\u03b1 f g)\nCase conversion may be inaccurate. Consider using '#align ring_hom.mul_def RingHom.mul_def\u2093'. -/\ntheorem mul_def (f g : \u03b1 \u2192+* \u03b1) : 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 {\u03b1 : Type.{u1}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (RingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (OfNat.ofNat.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (OfNat.mk.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (One.one.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulOneClass.toHasOne.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.monoid.{u1} \u03b1 r\u03b1))))))) (id.{succ u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1}, Eq.{succ u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) \u1fb0) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.instRingHomClassRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)))) (OfNat.ofNat.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) 1 (One.toOfNat1.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toOne.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.instMonoidRingHom.{u1} \u03b1 r\u03b1))))) (id.{succ u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_one RingHom.coe_one\u2093'. -/\n@[simp]\ntheorem coe_one : \u21d1(1 : \u03b1 \u2192+* \u03b1) = 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 {\u03b1 : Type.{u1}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] (f : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (g : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1), Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (RingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (HMul.hMul.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (instHMul.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulOneClass.toHasMul.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.monoid.{u1} \u03b1 r\u03b1)))) f g)) (Function.comp.{succ u1, succ u1, succ u1} \u03b1 \u03b1 \u03b1 (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (RingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) f) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (fun (_x : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) => \u03b1 -> \u03b1) (RingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} (f : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (g : RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1), Eq.{succ u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) \u1fb0) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.instRingHomClassRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)))) (HMul.hMul.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (instHMul.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (MulOneClass.toMul.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (Monoid.toMulOneClass.{u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) (RingHom.instMonoidRingHom.{u1} \u03b1 r\u03b1)))) f g)) (Function.comp.{succ u1, succ u1, succ u1} \u03b1 \u03b1 \u03b1 (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.instRingHomClassRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)))) f) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1) \u03b1 \u03b1 r\u03b1 r\u03b1 (RingHom.instRingHomClassRingHom.{u1, u1} \u03b1 \u03b1 r\u03b1 r\u03b1)))) g))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_mul RingHom.coe_mul\u2093'. -/\n@[simp]\ntheorem coe_mul (f g : \u03b1 \u2192+* \u03b1) : \u21d1(f * g) = f \u2218 g :=\n  rfl\n#align ring_hom.coe_mul RingHom.coe_mul\n\ninclude r\u03b2 r\u03b3\n\n/- warning: ring_hom.cancel_right -> RingHom.cancel_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonAssocSemiring.{u3} \u03b3} {g\u2081 : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3} {g\u2082 : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3} {f : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (RingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g\u2081 f) (RingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g\u2082 f)) (Eq.{max (succ u2) (succ u3)} (RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) g\u2081 g\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u3} \u03b2} {r\u03b3 : NonAssocSemiring.{u2} \u03b3} {g\u2081 : RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3} {g\u2082 : RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3} {f : RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Function.Surjective.{succ u1, succ u3} \u03b1 \u03b2 (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1)) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2)) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 r\u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) \u03b1 \u03b2 r\u03b1 r\u03b2 (RingHom.instRingHomClassRingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2)))) f)) -> (Iff (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) (RingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g\u2081 f) (RingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g\u2082 f)) (Eq.{max (succ u3) (succ u2)} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align ring_hom.cancel_right RingHom.cancel_right\u2093'. -/\ntheorem cancel_right {g\u2081 g\u2082 : \u03b2 \u2192+* \u03b3} {f : \u03b1 \u2192+* \u03b2} (hf : Surjective f) :\n    g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => RingHom.ext <| hf.forall.2 (ext_iff.1 h), fun h => h \u25b8 rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [r\u03b1 : NonAssocSemiring.{u1} \u03b1] [r\u03b2 : NonAssocSemiring.{u2} \u03b2] {r\u03b3 : NonAssocSemiring.{u3} \u03b3} {g : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3} {f\u2081 : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2} {f\u2082 : RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) (fun (_x : RingHom.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) => \u03b2 -> \u03b3) (RingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 r\u03b2 r\u03b3) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} \u03b1 \u03b3 r\u03b1 r\u03b3) (RingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f\u2081) (RingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f\u2082)) (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 r\u03b1 r\u03b2) f\u2081 f\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} {r\u03b1 : NonAssocSemiring.{u1} \u03b1} {r\u03b2 : NonAssocSemiring.{u3} \u03b2} {r\u03b3 : NonAssocSemiring.{u2} \u03b3} {g : RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3} {f\u2081 : RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2} {f\u2082 : RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2}, (Function.Injective.{succ u3, succ u2} \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b3) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3)) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 r\u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b3 r\u03b3) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3) \u03b2 \u03b3 r\u03b2 r\u03b3 (RingHom.instRingHomClassRingHom.{u3, u2} \u03b2 \u03b3 r\u03b2 r\u03b3)))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b3 r\u03b1 r\u03b3) (RingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f\u2081) (RingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 r\u03b1 r\u03b2 r\u03b3 g f\u2082)) (Eq.{max (succ u1) (succ u3)} (RingHom.{u1, u3} \u03b1 \u03b2 r\u03b1 r\u03b2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align ring_hom.cancel_left RingHom.cancel_left\u2093'. -/\ntheorem cancel_left {g : \u03b2 \u2192+* \u03b3} {f\u2081 f\u2082 : \u03b1 \u2192+* \u03b2} (hg : Injective g) :\n    g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => RingHom.ext fun x => hg <| by rw [\u2190 comp_apply, h, comp_apply], fun h => h \u25b8 rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Ring.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 _inst_1)] [_inst_3 : Ring.{u2} \u03b2] (f : RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))), (Function.Injective.{succ u2, succ u1} \u03b2 \u03b1 (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) (fun (_x : RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) => \u03b2 -> \u03b1) (RingHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 _inst_1))) f)) -> (IsDomain.{u2} \u03b2 (Ring.toSemiring.{u2} \u03b2 _inst_3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Ring.{u2} \u03b1] [_inst_2 : IsDomain.{u2} \u03b1 (Ring.toSemiring.{u2} \u03b1 _inst_1)] [_inst_3 : Ring.{u1} \u03b2] (f : RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1))), (Function.Injective.{succ u1, succ u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b1) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1))) \u03b2 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)))) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1))) \u03b2 \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1))) \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1)) (RingHom.instRingHomClassRingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 _inst_1)))))) f)) -> (IsDomain.{u1} \u03b2 (Ring.toSemiring.{u1} \u03b2 _inst_3))\nCase conversion may be inaccurate. Consider using '#align function.injective.is_domain Function.Injective.isDomain\u2093'. -/\n/-- Pullback `is_domain` instance along an injective function. -/\nprotected theorem Function.Injective.isDomain [Ring \u03b1] [IsDomain \u03b1] [Ring \u03b2] (f : \u03b2 \u2192+* \u03b1)\n    (hf : Injective f) : IsDomain \u03b2 :=\n  by\n  haveI := pullback_nonzero f f.map_zero f.map_one\n  haveI := IsRightCancelMulZero.to_noZeroDivisors \u03b1\n  haveI := hf.no_zero_divisors f f.map_zero f.map_mul\n  exact NoZeroDivisors.to_isDomain \u03b2\n#align function.injective.is_domain Function.Injective.isDomain\n\nnamespace AddMonoidHom\n\nvariable [CommRing \u03b1] [IsDomain \u03b1] [CommRing \u03b2] (f : \u03b2 \u2192+ \u03b1)\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CommRing.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))] [_inst_3 : CommRing.{u2} \u03b2] (f : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))), (forall (x : \u03b2), Eq.{succ u1} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))) x x)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f x) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f x))) -> (Ne.{succ u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))))))) -> (Eq.{succ u1} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))))) -> (RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CommRing.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))] [_inst_3 : CommRing.{u2} \u03b2] (f : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))), (forall (x : \u03b2), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (NonUnitalNonAssocRing.toMul.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) x x)) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))))) f (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (NonUnitalNonAssocRing.toMul.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) x x)) (HMul.hMul.{u1, u1, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (instHMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (NonUnitalNonAssocRing.toMul.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (NonAssocRing.toNonUnitalNonAssocRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (Ring.toNonAssocRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (CommRing.toRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) _inst_1))))) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))))) f x) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))))) f x))) -> (Ne.{succ u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommSemiring.toCommMonoidWithZero.{u1} \u03b1 (CommRing.toCommSemiring.{u1} \u03b1 _inst_1)))))) -> (Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocRing.toOne.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u1 u2, u2, u1} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (Ring.toAddGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (Ring.toAddGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))))) f (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocRing.toOne.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocRing.toOne.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) 1 (One.toOfNat1.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocRing.toOne.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (NonAssocRing.toOne.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocRing.toOne.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (Ring.toNonAssocRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocRing.toOne.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (CommRing.toRing.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u2} \u03b2 1 (One.toOfNat1.{u2} \u03b2 (NonAssocRing.toOne.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) _inst_1)))))) -> (RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _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\u2093'. -/\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 : \u2200 x, f (x * x) = f x * f x) (h_two : (2 : \u03b1) \u2260 0)\n    (h_one : f 1 = 1) : \u03b2 \u2192+* \u03b1 :=\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, \u2190 sub_eq_zero, add_comm, \u2190 sub_sub, \u2190 sub_sub, \u2190 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, \u2190 two_mul, \u2190 add_sub_assoc, \u2190 two_mul, \u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CommRing.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))] [_inst_3 : CommRing.{u2} \u03b2] (f : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (h : forall (x : \u03b2), Eq.{succ u1} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))) x x)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f x) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f x))) (h_two : Ne.{succ u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))))))) (h_one : Eq.{succ u1} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))))), Eq.{max (succ u2) (succ u1)} ((fun (_x : RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) => \u03b2 -> \u03b1) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u1, u2} \u03b1 \u03b2 _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} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (fun (_x : RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) => \u03b2 -> \u03b1) (RingHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u1, u2} \u03b1 \u03b2 _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} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : CommRing.{u2} \u03b1] [_inst_2 : IsDomain.{u2} \u03b1 (Ring.toSemiring.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))] [_inst_3 : CommRing.{u1} \u03b2] (f : AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (h : forall (x : \u03b2), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (HMul.hMul.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (NonUnitalNonAssocRing.toMul.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) x x)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))))) f (HMul.hMul.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (NonUnitalNonAssocRing.toMul.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) x x)) (HMul.hMul.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (instHMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (NonUnitalNonAssocRing.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (NonAssocRing.toNonUnitalNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (Ring.toNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (CommRing.toRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))))) f x))) (h_two : Ne.{succ u2} \u03b1 (OfNat.ofNat.{u2} \u03b1 2 (instOfNat.{u2} \u03b1 2 (NonAssocRing.toNatCast.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (CommMonoidWithZero.toZero.{u2} \u03b1 (CommSemiring.toCommMonoidWithZero.{u2} \u03b1 (CommRing.toCommSemiring.{u2} \u03b1 _inst_1)))))) (h_one : Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))))) f (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (NonAssocRing.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (Ring.toNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (CommRing.toRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) _inst_1)))))), Eq.{max (succ u2) (succ u1)} (forall (a : \u03b2), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b1) a) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b2) => \u03b1) _x) (MulHomClass.toFunLike.{max u2 u1, u1, u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))) \u03b2 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))) \u03b2 \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))) \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))) (RingHom.instRingHomClassRingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))))) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u2, u1} \u03b1 \u03b2 _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} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem coe_fn_mkRingHomOfMulSelfOfTwoNeZero (h h_two h_one) :\n    (f.mkRingHomOfMulSelfOfTwoNeZero h h_two h_one : \u03b2 \u2192 \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CommRing.{u1} \u03b1] [_inst_2 : IsDomain.{u1} \u03b1 (Ring.toSemiring.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))] [_inst_3 : CommRing.{u2} \u03b2] (f : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (h : forall (x : \u03b2), Eq.{succ u1} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))) x x)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f x) (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f x))) (h_two : Ne.{succ u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))))))) (h_one : Eq.{succ u1} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (fun (_x : AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (AddMonoidHom.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) f (OfNat.ofNat.{u2} \u03b2 1 (OfNat.mk.{u2} \u03b2 1 (One.one.{u2} \u03b2 (AddMonoidWithOne.toOne.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))))), Eq.{max (succ u1) (succ u2)} (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _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} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (HasLiftT.mk.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (CoeTC\u2093.coe.{max (succ u2) (succ u1), max (succ u1) (succ u2)} (RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (AddMonoidHom.{u2, u1} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))))))) (AddMonoidHom.hasCoeT.{u2, u1, max u2 u1} \u03b2 \u03b1 (RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3)))))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))) (RingHomClass.toAddMonoidHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))) \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1))) (RingHom.ringHomClass.{u2, u1} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (CommRing.toRing.{u2} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (CommRing.toRing.{u1} \u03b1 _inst_1)))))))) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 f h h_two h_one)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : CommRing.{u2} \u03b1] [_inst_2 : IsDomain.{u2} \u03b1 (Ring.toSemiring.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))] [_inst_3 : CommRing.{u1} \u03b2] (f : AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (h : forall (x : \u03b2), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (HMul.hMul.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (NonUnitalNonAssocRing.toMul.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) x x)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))))) f (HMul.hMul.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (NonUnitalNonAssocRing.toMul.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) x x)) (HMul.hMul.{u2, u2, u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (instHMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (NonUnitalNonAssocRing.toMul.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (NonAssocRing.toNonUnitalNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (Ring.toNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) (CommRing.toRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) x) _inst_1))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))))) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))))) f x))) (h_two : Ne.{succ u2} \u03b1 (OfNat.ofNat.{u2} \u03b1 2 (instOfNat.{u2} \u03b1 2 (NonAssocRing.toNatCast.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (CommMonoidWithZero.toZero.{u2} \u03b1 (CommSemiring.toCommMonoidWithZero.{u2} \u03b1 (CommRing.toCommSemiring.{u2} \u03b1 _inst_1)))))) (h_one : Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) _x) (AddHomClass.toFunLike.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddZeroClass.toAdd.{u1} \u03b2 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddHomClass.{max u2 u1, u1, u2} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.addMonoidHomClass.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))))) f (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) 1 (One.toOfNat1.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (NonAssocRing.toOne.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (Ring.toNonAssocRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) (CommRing.toRing.{u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b2) => \u03b1) (OfNat.ofNat.{u1} \u03b2 1 (One.toOfNat1.{u1} \u03b2 (NonAssocRing.toOne.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3)))))) _inst_1)))))), Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} \u03b2 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))))) (AddMonoidHomClass.toAddMonoidHom.{u1, u2, max u2 u1} \u03b2 \u03b1 (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b2 (Ring.toAddGroupWithOne.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))))) (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u2} \u03b1 (Ring.toAddGroupWithOne.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (RingHomClass.toAddMonoidHomClass.{max u2 u1, u1, u2} (RingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1)))) \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))) (RingHom.instRingHomClassRingHom.{u1, u2} \u03b2 \u03b1 (NonAssocRing.toNonAssocSemiring.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 (CommRing.toRing.{u1} \u03b2 _inst_3))) (NonAssocRing.toNonAssocSemiring.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (CommRing.toRing.{u2} \u03b1 _inst_1))))) (AddMonoidHom.mkRingHomOfMulSelfOfTwoNeZero.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem coe_addMonoidHom_mkRingHomOfMulSelfOfTwoNeZero (h h_two h_one) :\n    (f.mkRingHomOfMulSelfOfTwoNeZero h h_two h_one : \u03b2 \u2192+ \u03b1) = 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": "/-\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, Robert Y. Lewis, Gabriel Ebner\n-/\nimport data.bool.basic\nimport meta.rb_map\nimport tactic.lint.basic\n\n/-!\n# Linters about type classes\n\nThis file defines several linters checking the correct usage of type classes\nand the appropriate definition of instances:\n\n * `instance_priority` ensures that blanket instances have low priority.\n * `has_nonempty_instances` checks that every type has a `nonempty` instance, an `inhabited`\n   instance, or a `unique` instance.\n * `impossible_instance` checks that there are no instances which can never apply.\n * `incorrect_type_class_argument` checks that only type classes are used in\n   instance-implicit arguments.\n * `dangerous_instance` checks for instances that generate subproblems with metavariables.\n * `fails_quickly` checks that type class resolution finishes quickly.\n * `class_structure` checks that every `class` is a structure, i.e. `@[class] def` is forbidden.\n * `has_coe_variable` checks that there is no instance of type `has_coe \u03b1 t`.\n * `inhabited_nonempty` checks whether `[inhabited \u03b1]` arguments could be generalized\n   to `[nonempty \u03b1]`.\n * `decidable_classical` checks propositions for `[decidable_... p]` hypotheses that are not used\n   in the statement, and could thus be removed by using `classical` in the proof.\n * `linter.has_coe_to_fun` checks whether necessary `has_coe_to_fun` instances are declared.\n * `linter.check_reducibility` checks whether non-instances with a class as type are reducible.\n-/\n\nopen tactic\n\n/-- Pretty prints a list of arguments of a declaration. Assumes `l` is a list of argument positions\nand binders (or any other element that can be pretty printed).\n`l` can be obtained e.g. by applying `list.indexes_values` to a list obtained by\n`get_pi_binders`. -/\nmeta def print_arguments {\u03b1} [has_to_tactic_format \u03b1] (l : list (\u2115 \u00d7 \u03b1)) : tactic string := do\n  fs \u2190 l.mmap (\u03bb \u27e8n, b\u27e9, (\u03bb s, to_fmt \"argument \" ++ to_fmt (n+1) ++ \": \" ++ s) <$> pp b),\n  return $ fs.to_string_aux tt\n\n/-- checks whether an instance that always applies has priority \u2265 1000. -/\nprivate meta def instance_priority (d : declaration) : tactic (option string) := do\n  let nm := d.to_name,\n  b \u2190 is_instance nm,\n  /- return `none` if `d` is not an instance -/\n  if \u00ac b then return none else do\n  (is_persistent, prio) \u2190 has_attribute `instance nm,\n  /- return `none` if `d` is has low priority -/\n  if prio < 1000 then return none else do\n  (_, tp) \u2190 open_pis d.type,\n  tp \u2190 whnf tp transparency.none,\n  let (fn, args) := tp.get_app_fn_args,\n  cls \u2190 get_decl fn.const_name,\n  let (pi_args, _) := cls.type.pi_binders,\n  guard (args.length = pi_args.length),\n  /- List all the arguments of the class that block type-class inference from firing\n    (if they are metavariables). These are all the arguments except instance-arguments and\n    out-params. -/\n  let relevant_args := (args.zip pi_args).filter_map $ \u03bb\u27e8e, \u27e8_, info, tp\u27e9\u27e9,\n    if info = binder_info.inst_implicit \u2228 tp.get_app_fn.is_constant_of `out_param\n    then none else some e,\n  let always_applies := relevant_args.all expr.is_local_constant \u2227 relevant_args.nodup,\n  if always_applies then return $ some \"set priority below 1000\" else return none\n\n/--\nThere are places where typeclass arguments are specified with implicit `{}` brackets instead of\nthe usual `[]` brackets. This is done when the instances can be inferred because they are implicit\narguments to the type of one of the other arguments. When they can be inferred from these other\narguments,  it is faster to use this method than to use type class inference.\n\nFor example, when writing lemmas about `(f : \u03b1 \u2192+* \u03b2)`, it is faster to specify the fact that `\u03b1`\nand `\u03b2` are `semiring`s as `{r\u03b1 : semiring \u03b1} {r\u03b2 : semiring \u03b2}` rather than the usual\n`[semiring \u03b1] [semiring \u03b2]`.\n-/\nlibrary_note \"implicit instance arguments\"\n\n/--\nCertain instances always apply during type-class resolution. For example, the instance\n`add_comm_group.to_add_group {\u03b1} [add_comm_group \u03b1] : add_group \u03b1` applies to all type-class\nresolution problems of the form `add_group _`, and type-class inference will then do an\nexhaustive search to find a commutative group. These instances take a long time to fail.\nOther instances will only apply if the goal has a certain shape. For example\n`int.add_group : add_group \u2124` or\n`add_group.prod {\u03b1 \u03b2} [add_group \u03b1] [add_group \u03b2] : add_group (\u03b1 \u00d7 \u03b2)`. Usually these instances\nwill fail quickly, and when they apply, they are almost always the desired instance.\nFor this reason, we want the instances of the second type (that only apply in specific cases) to\nalways have higher priority than the instances of the first type (that always apply).\nSee also #1561.\n\nTherefore, if we create an instance that always applies, we set the priority of these instances to\n100 (or something similar, which is below the default value of 1000).\n-/\nlibrary_note \"lower instance priority\"\n\n/-- A linter object for checking instance priorities of instances that always apply.\nThis is in the default linter set. -/\n@[linter] meta def linter.instance_priority : linter :=\n{ test := instance_priority,\n  no_errors_found := \"All instance priorities are good.\",\n  errors_found := \"DANGEROUS INSTANCE PRIORITIES.\nThe following instances always apply, and therefore should have a priority < 1000.\nIf you don't know what priority to choose, use priority 100.\nSee note [lower instance priority] for instructions to change the priority.\",\n  auto_decls := tt }\n\n/-- Reports declarations of types that do not have an nonemptiness instance.\nA `nonempty`, `inhabited` or `unique` instance suffices, and we prefer a computable `inhabited`\nor `unique` instance if possible. -/\nprivate meta def has_nonempty_instance (d : declaration) : tactic (option string) := do\ntt \u2190 pure d.is_trusted | pure none,\nff \u2190 has_attribute' `reducible d.to_name | pure none,\nff \u2190 has_attribute' `class d.to_name | pure none,\n(_, ty) \u2190 open_pis d.type,\nty \u2190 whnf ty,\nif ty = `(Prop) then pure none else do\n`(Sort _) \u2190 whnf ty | pure none,\ninsts \u2190 attribute.get_instances `instance,\ninsts_tys \u2190 insts.mmap $ \u03bb i, expr.pi_codomain <$> declaration.type <$> get_decl i,\nlet nonempty_insts := insts_tys.filter\n  (\u03bb i, i.app_fn.const_name \u2208 [``nonempty, ``inhabited, `unique]),\nlet nonempty_tys := nonempty_insts.map (\u03bb i, i.app_arg.get_app_fn.const_name),\nif d.to_name \u2208 nonempty_tys then\n  pure none\nelse\n  pure \"nonempty/inhabited/unique instance missing\"\n\n/-- A linter for missing `nonempty` instances. -/\n@[linter]\nmeta def linter.has_nonempty_instance : linter :=\n{ test := has_nonempty_instance,\n  auto_decls := ff,\n  no_errors_found := \"No types have missing nonempty instances.\",\n  errors_found := \"TYPES ARE MISSING NONEMPTY INSTANCES.\nThe following types should have an associated instance of the class\n`nonempty`, or if computably possible `inhabited` or `unique`:\",\n  is_fast := ff }\n\nattribute [nolint has_nonempty_instance] pempty\n\n/-- Checks whether an instance can never be applied. -/\nprivate meta def impossible_instance (d : declaration) : tactic (option string) := do\n  tt \u2190 is_instance d.to_name | return none,\n  (binders, _) \u2190 get_pi_binders_nondep d.type,\n  let bad_arguments := binders.filter $ \u03bb nb, nb.2.info \u2260 binder_info.inst_implicit,\n  _ :: _ \u2190 return bad_arguments | return none,\n  (\u03bb s, some $ \"Impossible to infer \" ++ s) <$> print_arguments bad_arguments\n\n/-- A linter object for `impossible_instance`. -/\n@[linter] meta def linter.impossible_instance : linter :=\n{ test := impossible_instance,\n  auto_decls := tt,\n  no_errors_found := \"All instances are applicable.\",\n  errors_found := \"IMPOSSIBLE INSTANCES FOUND.\nThese instances have an argument that cannot be found during type-class resolution, and \" ++\n\"therefore can never succeed. Either mark the arguments with square brackets (if it is a \" ++\n\"class), or don't make it an instance.\" }\n\n/-- Checks whether an instance can never be applied. -/\nprivate meta def incorrect_type_class_argument (d : declaration) : tactic (option string) := do\n  (binders, _) \u2190 get_pi_binders d.type,\n  let instance_arguments := binders.indexes_values $\n    \u03bb b : binder, b.info = binder_info.inst_implicit,\n  /- the head of the type should either unfold to a class, or be a local constant.\n  A local constant is allowed, because that could be a class when applied to the\n  proper arguments. -/\n  bad_arguments \u2190 instance_arguments.mfilter (\u03bb \u27e8_, b\u27e9, do\n    (_, head) \u2190 open_pis b.type,\n    if head.get_app_fn.is_local_constant then return ff else do\n    bnot <$> is_class head),\n  _ :: _ \u2190 return bad_arguments | return none,\n  (\u03bb s, some $ \"These are not classes. \" ++ s) <$> print_arguments bad_arguments\n\n/-- A linter object for `incorrect_type_class_argument`. -/\n@[linter] meta def linter.incorrect_type_class_argument : linter :=\n{ test := incorrect_type_class_argument,\n  auto_decls := tt,\n  no_errors_found := \"All declarations have correct type-class arguments.\",\n  errors_found := \"INCORRECT TYPE-CLASS ARGUMENTS.\nSome declarations have non-classes between [square brackets]:\" }\n\n/-- Checks whether an instance is dangerous: it creates a new type-class problem with metavariable\narguments. -/\nprivate meta def dangerous_instance (d : declaration) : tactic (option string) := do\n  tt \u2190 is_instance d.to_name | return none,\n  (local_constants, target) \u2190 open_pis d.type,\n  let instance_arguments := local_constants.indexes_values $\n    \u03bb e : expr, e.local_binding_info = binder_info.inst_implicit,\n  let bad_arguments := local_constants.indexes_values $ \u03bb x,\n      !target.has_local_constant x &&\n      (x.local_binding_info \u2260 binder_info.inst_implicit) &&\n      instance_arguments.any (\u03bb nb, nb.2.local_type.has_local_constant x),\n  let bad_arguments : list (\u2115 \u00d7 binder) := bad_arguments.map $ \u03bb \u27e8n, e\u27e9, \u27e8n, e.to_binder\u27e9,\n  _ :: _ \u2190 return bad_arguments | return none,\n  (\u03bb s, some $ \"The following arguments become metavariables. \" ++ s) <$>\n    print_arguments bad_arguments\n\n/-- A linter object for `dangerous_instance`. -/\n@[linter] meta def linter.dangerous_instance : linter :=\n{ test := dangerous_instance,\n  no_errors_found := \"No dangerous instances.\",\n  errors_found := \"DANGEROUS INSTANCES FOUND.\\nThese instances are recursive, and create a new \" ++\n\"type-class problem which will have metavariables.\nPossible solution: remove the instance attribute or make it a local instance instead.\n\nCurrently this linter does not check whether the metavariables only occur in arguments marked \" ++\n\"with `out_param`, in which case this linter gives a false positive.\",\n  auto_decls := tt }\n\n/-- Auxilliary definition for `find_nondep` -/\nmeta def find_nondep_aux : list expr \u2192 expr_set \u2192 tactic expr_set\n| []      r := return r\n| (h::hs) r :=\n  do type \u2190 infer_type h,\n    find_nondep_aux hs $ r.union type.list_local_consts'\n\n/-- Finds all hypotheses that don't occur in the target or other hypotheses. -/\nmeta def find_nondep : tactic (list expr) := do\n  ctx \u2190 local_context,\n  tgt \u2190 target,\n  lconsts \u2190 find_nondep_aux ctx tgt.list_local_consts',\n  return $ ctx.filter $ \u03bb e, !lconsts.contains e\n\n/--\nTests whether type-class inference search will end quickly on certain unsolvable\ntype-class problems. This is to detect loops or very slow searches, which are problematic\n(recall that normal type-class search often creates unsolvable subproblems, which have to fail\nquickly for type-class inference to perform well.\nWe create these type-class problems by taking an instance, and removing the last hypothesis that\ndoesn't appear in the goal (or a later hypothesis). Note: this argument is necessarily an\ninstance-implicit argument if it passes the `linter.incorrect_type_class_argument`.\nThis tactic succeeds if `mk_instance` succeeds quickly or fails quickly with the error\nmessage that it cannot find an instance. It fails if the tactic takes too long, or if any other\nerror message is raised (usually a maximum depth in the search).\n-/\nmeta def fails_quickly (max_steps : \u2115) (d : declaration) : tactic (option string) := retrieve $ do\n  tt \u2190 is_instance d.to_name | return none,\n  let e := d.type,\n  g \u2190 mk_meta_var e,\n  set_goals [g],\n  intros,\n  l@(_::_) \u2190 find_nondep | return none, -- if all arguments occur in the goal, this instance is ok\n  clear l.ilast,\n  reset_instance_cache,\n  state \u2190 read,\n  let state_msg := \"\\nState:\\n\" ++ to_string state,\n  tgt \u2190 target >>= instantiate_mvars,\n  sum.inr msg \u2190 retrieve_or_report_error $ tactic.try_for max_steps $ mk_instance tgt |\n    return none, /- it's ok if type-class inference can find an instance with fewer hypotheses.\n    This happens a lot for `has_sizeof` and `has_well_founded`, but can also happen if there is a\n    noncomputable instance with fewer assumptions. -/\n  return $ if \"tactic.mk_instance failed to generate instance for\".is_prefix_of msg then none else\n    some $ (++ state_msg) $\n      if msg = \"try_for tactic failed, timeout\" then \"type-class inference timed out\" else msg\n\n/--\nA linter object for `fails_quickly`.\nWe currently set the number of steps in the type-class search pretty high.\nSome instances take quite some time to fail, and we seem to run against the caching issue in\nhttps://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/odd.20repeated.20type.20class.20search\n-/\n@[linter] meta def linter.fails_quickly : linter :=\n{ test := fails_quickly 30000,\n  auto_decls := tt,\n  no_errors_found := \"No type-class searches timed out.\",\n  errors_found := \"TYPE CLASS SEARCHES TIMED OUT.\nThe following instances are part of a loop, or an excessively long search.\nIt is common that the loop occurs in a different class than the one flagged below,\nbut usually an instance that is part of the loop is also flagged.\nTo debug:\n(1) run `scripts/mk_all.sh` and create a file with `import all` and\n`set_option trace.class_instances true`\n(2) Recreate the state shown in the error message. You can do this easily by copying the type of\nthe instance (the output of `#check @my_instance`), turning this into an example and removing the\nlast argument in square brackets. Prove the example using `by apply_instance`.\nFor example, if `additive.topological_add_group` raises an error, run\n```\nexample {G : Type*} [topological_space G] [group G] : topological_add_group (additive G) :=\nby apply_instance\n```\n(3) What error do you get?\n(3a) If the error is \\\"tactic.mk_instance failed to generate instance\\\",\nthere might be nothing wrong. But it might take unreasonably long for the type-class inference to\nfail. Check the trace to see if type-class inference takes any unnecessary long unexpected turns.\nIf not, feel free to increase the value in the definition of the linter `fails_quickly`.\n(3b) If the error is \\\"maximum class-instance resolution depth has been reached\\\" there is almost\ncertainly a loop in the type-class inference. Find which instance causes the type-class inference to\ngo astray, and fix that instance.\",\n  is_fast := ff }\n\n/-- Checks that all uses of the `@[class]` attribute apply to structures or inductive types.\n  This is future-proofing for lean 4, which no longer supports `@[class] def`. -/\nprivate meta def class_structure (n : name) : tactic (option string) := do\n  is_class \u2190 has_attribute' `class n,\n  if is_class then do\n    env \u2190 get_env,\n    pure $ if env.is_inductive n then none else\n      \"is a non-structure or inductive type marked @[class]\"\n  else pure none\n\n/-- A linter object for `class_structure`. -/\n@[linter] meta def linter.class_structure : linter :=\n{ test := \u03bb d, class_structure d.to_name,\n  auto_decls := tt,\n  no_errors_found := \"All classes are structures.\",\n  errors_found := \"USE OF @[class] def IS DISALLOWED:\" }\n\n/--\nTests whether there is no instance of type `has_coe \u03b1 t` where `\u03b1` is a variable,\nor `has_coe t \u03b1` where `\u03b1` does not occur in `t`.\nSee note [use has_coe_t].\n-/\nprivate meta def has_coe_variable (d : declaration) : tactic (option string) := do\ntt \u2190 is_instance d.to_name | return none,\n`(has_coe %%a %%b) \u2190 return d.type.pi_codomain | return none,\nif a.is_var then\n  return $ some $ \"illegal instance, first argument is variable\"\nelse if b.is_var \u2227 \u00ac b.occurs a then\n  return $ some $ \"illegal instance, second argument is variable not occurring in first argument\"\nelse\n  return none\n\n/-- A linter object for `has_coe_variable`. -/\n@[linter] meta def linter.has_coe_variable : linter :=\n{ test := has_coe_variable,\n  auto_decls := tt,\n  no_errors_found := \"No invalid `has_coe` instances.\",\n  errors_found := \"INVALID `has_coe` INSTANCES.\nMake the following declarations instances of the class `has_coe_t` instead of `has_coe`.\" }\n\n/-- Checks whether a declaration is prop-valued and takes an `inhabited _` argument that is unused\nelsewhere in the type. In this case, that argument can be replaced with `nonempty _`. -/\nprivate meta def inhabited_nonempty (d : declaration) : tactic (option string) :=\ndo tt \u2190 is_prop d.type | return none,\n   (binders, _) \u2190 get_pi_binders_nondep d.type,\n   let inhd_binders := binders.filter $ \u03bb pr, pr.2.type.is_app_of `inhabited,\n   if inhd_binders.length = 0 then return none\n   else (\u03bb s, some $ \"The following `inhabited` instances should be `nonempty`. \" ++ s) <$>\n      print_arguments inhd_binders\n\n/-- A linter object for `inhabited_nonempty`. -/\n@[linter] meta def linter.inhabited_nonempty : linter :=\n{ test := inhabited_nonempty,\n  auto_decls := ff,\n  no_errors_found := \"No uses of `inhabited` arguments should be replaced with `nonempty`.\",\n  errors_found := \"USES OF `inhabited` SHOULD BE REPLACED WITH `nonempty`.\" }\n\n/-- Checks whether a declaration is `Prop`-valued and takes a `decidable* _`\nhypothesis that is unused elsewhere in the type.\nIn this case, that hypothesis can be replaced with `classical` in the proof.\nTheorems in the `decidable` namespace are exempt from the check. -/\nprivate meta def decidable_classical (d : declaration) : tactic (option string) :=\ndo tt \u2190 is_prop d.type | return none,\n   ff \u2190 pure $ (`decidable).is_prefix_of d.to_name | return none,\n   (binders, _) \u2190 get_pi_binders_nondep d.type,\n   let deceq_binders := binders.filter $ \u03bb pr, pr.2.type.is_app_of `decidable_eq\n     \u2228 pr.2.type.is_app_of `decidable_pred \u2228 pr.2.type.is_app_of `decidable_rel\n     \u2228 pr.2.type.is_app_of `decidable,\n   if deceq_binders.length = 0 then return none\n   else (\u03bb s, some $ \"The following `decidable` hypotheses should be replaced with\n                      `classical` in the proof. \" ++ s) <$>\n      print_arguments deceq_binders\n\n/-- A linter object for `decidable_classical`. -/\n@[linter] meta def linter.decidable_classical : linter :=\n{ test := decidable_classical,\n  auto_decls := ff,\n  no_errors_found := \"No uses of `decidable` arguments should be replaced with `classical`.\",\n  errors_found := \"USES OF `decidable` SHOULD BE REPLACED WITH `classical` IN THE PROOF.\" }\n\n/- The file `logic/basic.lean` emphasizes the differences between what holds under classical\nand non-classical logic. It makes little sense to make all these lemmas classical, so we add them\nto the list of lemmas which are not checked by the linter `decidable_classical`. -/\nattribute [nolint decidable_classical] dec_em dec_em' not.decidable_imp_symm\n\n/-- Checks whether a declaration is `Prop`-valued and takes a `fintype _`\nhypothesis that is unused elsewhere in the type.\nIn this case, that hypothesis can be replaced with `casesI nonempty_fintype _` in the proof. -/\nmeta def linter.fintype_finite_fun (d : declaration) : tactic (option string) :=\ndo tt \u2190 is_prop d.type | return none,\n   (binders, _) \u2190 get_pi_binders_nondep d.type,\n   let fintype_binders := binders.filter $ \u03bb pr, pr.2.type.is_app_of `fintype,\n   if fintype_binders.length = 0 then return none\n   else (\u03bb s, some $ \"The following `fintype` hypotheses should be replaced with\n                      `casesI nonempty_fintype _` in the proof. \" ++ s) <$>\n      print_arguments fintype_binders\n\n/-- A linter object for `fintype` vs `finite`. -/\n@[linter] meta def linter.fintype_finite : linter :=\n{ test := linter.fintype_finite_fun,\n  auto_decls := ff,\n  no_errors_found :=\n    \"No uses of `fintype` arguments should be replaced with `casesI nonempty_fintype _`.\",\n  errors_found :=\n    \"USES OF `fintype` SHOULD BE REPLACED WITH `casesI nonempty_fintype _` IN THE PROOF.\" }\n\nprivate meta def has_coe_to_fun_linter (d : declaration) : tactic (option string) :=\nretrieve $ do\ntt \u2190 return d.is_trusted | pure none,\nmk_meta_var d.type >>= set_goals \u2218 pure,\nargs \u2190 unfreezing intros,\nexpr.sort _ \u2190 target | pure none,\nlet ty : expr := (expr.const d.to_name d.univ_levels).mk_app args,\nsome coe_fn_inst \u2190\n  try_core $ to_expr ``(_root_.has_coe_to_fun %%ty _) >>= mk_instance | pure none,\nset_bool_option `pp.all true,\nsome trans_inst@(expr.app (expr.app _ trans_inst_1) trans_inst_2) \u2190\n  try_core $ to_expr ``(@_root_.coe_fn_trans %%ty _ _ _ _) | pure none,\ntt \u2190 succeeds $ unify trans_inst coe_fn_inst transparency.reducible | pure none,\nset_bool_option `pp.all true,\ntrans_inst_1 \u2190 pp trans_inst_1,\ntrans_inst_2 \u2190 pp trans_inst_2,\npure $ format.to_string $\n  \"`has_coe_to_fun` instance is definitionally equal to a transitive instance composed of: \" ++\n  trans_inst_1.group.indent 2 ++\n  format.line ++ \"and\" ++\n  trans_inst_2.group.indent 2\n\n/-- Linter that checks whether `has_coe_to_fun` instances comply with Note [function coercion]. -/\n@[linter] meta def linter.has_coe_to_fun : linter :=\n{ test := has_coe_to_fun_linter,\n  auto_decls := tt,\n  no_errors_found := \"has_coe_to_fun is used correctly\",\n  errors_found := \"INVALID/MISSING `has_coe_to_fun` instances.\nYou should add a `has_coe_to_fun` instance for the following types.\nSee Note [function coercion].\" }\n\n/--\nChecks whether an instance contains a semireducible non-instance with a class as\ntype in its value. We add some restrictions to get not too many false positives:\n* We only consider classes with an `add` or `mul` field, since those classes are most likely to\n  occur as a field to another class, and be an extension of another class.\n* We only consider instances of type-valued classes and non-instances that are definitions.\n* We currently ignore declarations `foo` that have a `foo._main` declaration. We could look inside,\nor at the generated equation lemmas, but it's unlikely that there are many problematic instances\ndefined using the equation compiler.\n-/\nmeta def check_reducible_non_instances (d : declaration) : tactic (option string) := do\n  tt \u2190 is_instance d.to_name | return none,\n  ff \u2190 is_prop d.type | return none,\n  env \u2190 get_env,\n  -- We only check if the class of the instance contains an `add` or a `mul` field.\n  let cls := d.type.pi_codomain.get_app_fn.const_name,\n  some constrs \u2190 return $ env.structure_fields cls | return none,\n  tt \u2190 return $ constrs.mem `add || constrs.mem `mul | return none,\n  l \u2190 d.value.list_constant.mfilter $ \u03bb nm, do\n  { d \u2190 env.get nm,\n    ff \u2190 is_instance nm | return ff,\n    tt \u2190 is_class d.type | return ff,\n    tt \u2190 return d.is_definition | return ff,\n    -- We only check if the class of the non-instance contains an `add` or a `mul` field.\n    let cls := d.type.pi_codomain.get_app_fn.const_name,\n    some constrs \u2190 return $ env.structure_fields cls | return ff,\n    tt \u2190 return $ constrs.mem `add || constrs.mem `mul | return ff,\n    ff \u2190 has_attribute' `reducible nm | return ff,\n    return tt },\n  if l.empty then return none else\n  -- we currently ignore declarations that have a `foo._main` declaration.\n  if l.to_list = [d.to_name ++ `_main] then return none else\n    return $ some $ \"This instance contains the declarations \" ++ to_string l.to_list ++\n      \", which are semireducible non-instances.\"\n\n/-- A linter that checks whether an instance contains a semireducible non-instance. -/\n@[linter]\nmeta def linter.check_reducibility : linter :=\n{ test := check_reducible_non_instances,\n  auto_decls := ff,\n  no_errors_found :=\n    \"All non-instances are reducible.\",\n  errors_found := \"THE FOLLOWING INSTANCES MIGHT NOT REDUCE.\nThese instances contain one or more declarations that are not instances and are also not marked\n`@[reducible]`. This means that type-class inference cannot unfold these declarations, \" ++\n\"which might mean that type-class inference cannot infer that two instances are definitionally \" ++\n\"equal. This can cause unexpected errors when this class occurs \" ++\n\"as an *argument* to a type-class problem. See note [reducible non-instances].\",\n  is_fast := tt }\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/lint/type_classes.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754371026367, "lm_q2_score": 0.6619228825191872, "lm_q1q2_score": 0.48186359973014253}}
{"text": "import data.multiset data.equiv.basic data.nat.basic group_theory.perm\n\nopen equiv.perm equiv list\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} [decidable_eq \u03b1]\n\ndef thing : list \u03b1 \u2192 list (perm \u03b1)\n| []       := [1]\n| (a :: l) := thing l ++ l.bind (\u03bb b, (thing l).map (\u03bb f, swap a b * f))\n\n@[simp] lemma thing_nil : thing ([] : list \u03b1) = [1] := rfl\n\nlemma length_thing : \u2200 l : list \u03b1, 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 : \u2200 (l : list \u03b1) (f : perm \u03b1) (hl : l.nodup) (h : \u2200 x, f x \u2260 x \u2192 x \u2208 l), f \u2208 thing l\n| []     f hl h := list.mem_singleton.2 $ equiv.ext _ _$ \u03bb 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    (\u03bb x hx, mem_of_ne_of_mem (\u03bb h, by rw h at hx; exact hx hfa) (h x hx))\nelse\nhave hfa' : f (f a) \u2260 f a, from mt (\u03bb h, f.bijective.1 h) hfa,\nhave \u2200 (x : \u03b1), (swap a (f a) * f) x \u2260 x \u2192 x \u2208 l,\n  from \u03bb x hx, have hxa : x \u2260 a, from \u03bb h, by simpa [h, mul_apply] using hx,\n    have hfxa : f x \u2260 f a, from mt (\u03bb h, f.bijective.1 h) hxa,\n    list.mem_of_ne_of_mem hxa\n      (h x (\u03bb h, by simp [h, mul_apply, swap_apply_def] at hx; split_ifs at hx; cc)),\nsuffices f \u2208 thing l \u2228 \u2203 (b : \u03b1), b \u2208 l \u2227 \u2203 g : perm \u03b1, g \u2208 thing l \u2227 swap a b * g = f,\n  by simpa [thing],\n(@or_iff_not_imp_left _ _ (classical.prop_decidable _)).2\n  (\u03bb hfl, \u27e8f a,\n    if hffa : f (f a) = a then mem_of_ne_of_mem hfa (h _ (mt (\u03bb h, f.bijective.1 h) hfa))\n      else this _ $ by simp [mul_apply, swap_apply_def]; split_ifs; cc,\n    \u27e8swap a (f a) * f, mem_thing _ _ (list.nodup_of_nodup_cons hl) this,\n      by rw [\u2190 mul_assoc, mul_def (swap a (f a)) (swap a (f a)), swap_swap, \u2190 one_def, one_mul]\u27e9\u27e9)\n\nlemma mem_thing' : \u2200 (l : list \u03b1) (f : perm \u03b1), f \u2208 thing l \u2192 \u2200 x, f x \u2260 x \u2192 x \u2208 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  (\u03bb h x hx, mem_cons_of_mem _ (mem_thing' l f h x hx))\n  (\u03bb h x hx,\n    let \u27e8y, hy, hy'\u27e9 := mem_bind.1 h in\n    let \u27e8g, hg\u2081, hg\u2082\u27e9 := 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\u2081 _ $\n      by rw [eq_inv_mul_iff_mul_eq.2 hg\u2082, mul_apply, swap_inv, swap_apply_def];\n        split_ifs; cc)\n\nlemma nodup_thing : \u2200 (l : list \u03b1) (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 : \u2200 {f : perm \u03b1}, f \u2208 thing l \u2192 f a = a,\n  from \u03bb 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\u27e8hln', \u27e8\u03bb _ _, nodup_map (\u03bb _ _, (mul_left_inj _).1) hln',\n  \u03bb i j hj hij x hx\u2081 hx\u2082,\n    let \u27e8f, hf\u27e9 := mem_map.1 hx\u2081 in\n    let \u27e8g, hg\u27e9 := mem_map.1 hx\u2082 in\n    have hix : x a = nth_le l i (lt_trans hij hj),\n      by rw [\u2190 hf.2, mul_apply, hmeml hf.1, swap_apply_left],\n    have hiy : x a = nth_le l j hj,\n      by rw [\u2190 hg.2, mul_apply, hmeml hg.1, swap_apply_left],\n    absurd (hf.2.trans (hg.2.symm)) $\n      \u03bb h, ne_of_lt hij $ nodup_iff_nth_le_inj.1 hl' i j (lt_trans hij hj) hj $\n        by rw [\u2190 hix, hiy]\u27e9,\n  \u03bb f hf\u2081 hf\u2082,\n    let \u27e8x, hx, hx'\u27e9 := mem_bind.1 hf\u2082 in\n    let \u27e8g, hg\u27e9 := mem_map.1 hx' in\n    have hgxa : g\u207b\u00b9 x = a, from f.bijective.1 $\n      by rw [hmeml hf\u2081, \u2190 hg.2]; simp,\n    have hxa : x \u2260 a, from \u03bb h, (list.nodup_cons.1 hl).1 (h \u25b8 hx),\n    (list.nodup_cons.1 hl).1 $\n      hgxa \u25b8 mem_thing' _ _ hg.1 _ (by rwa [apply_inv_self, hgxa])\u27e9\n\ndef perm_fintype_aux [decidable_eq (perm \u03b1)] {s : multiset \u03b1} :\n  (\u2200 x, x \u2208 s) \u2192 s.nodup \u2192 fintype (perm \u03b1) :=\nquotient.rec_on_subsingleton s (\u03bb l hl hln, \u27e8\u27e8thing l, nodup_thing _ hln\u27e9,\n  (\u03bb x, mem_thing _ _ hln (\u03bb _ _, (hl _)))\u27e9)\n\ninstance perm.fintype [fintype \u03b1] : fintype (perm \u03b1) := perm_fintype_aux finset.mem_univ finset.univ.2\n\nlemma card_perm [fintype \u03b1] : fintype.card (perm \u03b1) = (fintype.card \u03b1).fact :=\nquotient.induction_on (@finset.univ \u03b1 _).1 begin end\n\n#exit\n\nlemma thing_cons (m : multiset \u03b1) (a : \u03b1) :\n  thing (a :: m) = thing m + m.bind (\u03bb b, (thing m).map (\u03bb f, swap a b * f)) :=\nby simp [thing]\n\nlemma mem_perm (m : multiset \u03b1) (f : perm \u03b1) : (\u2200 x, f x \u2260 x \u2192 x \u2208 m) \u2192 f \u2208 thing m :=\nmultiset.induction_on m\n  (\u03bb h, mem_singleton.2 $ equiv.ext _ _ $ \u03bb x, not_not.1 $ by simpa [-not_not, not_mem_zero] using h x)\n  $ \u03bb a s ih h, begin\n    simp [thing_cons],\n\n  end\n\nlemma card_perm (m : multiset \u03b1) : (thing m).card = nat.fact m.card :=\nmultiset.induction_on m rfl (\u03bb 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 : \u03b1 \u2243 \u03b2) (m : multiset \u03b1) (a : \u03b1) (b : \u03b2) (f : \u03b1 \u2243 \u03b2) : \u03b1 \u2243 \u03b2 :=\n(swap a (e.symm b)).trans f\n\ndef list_to_function : \u03a0 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2), l\u2081.length = l\u2082.length \u2192 \u03a0 a \u2208 l\u2081, \u03b2\n| []      l\u2082      h\u2081 a h\u2082 := absurd h\u2082 (list.not_mem_nil _)\n| (b::l\u2081) []      h\u2081 a h\u2082 := absurd h\u2081 (nat.succ_ne_zero _)\n| (b::l\u2081) (c::l\u2082) h\u2081 a h\u2082 := if h : a = b then c\n  else list_to_function l\u2081 l\u2082 (nat.succ_inj h\u2081) a (list.mem_of_ne_of_mem h h\u2082)\n\nopen list nat\n\ndef list_to_perm : \u03a0 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2), l\u2081.length = l\u2082.length \u2192\n  {a // a \u2208 l\u2081} \u2243 {b // b \u2208 l\u2082}\n| []      []      h := \u27e8\u03bb a, (not_mem_nil _ a.2).elim, \u03bb b, (not_mem_nil _ b.2).elim,\n  \u03bb a, (not_mem_nil _ a.2).elim, \u03bb b, (not_mem_nil _ b.2).elim\u27e9\n| []      (b::l\u2082) h := (succ_ne_zero _ h.symm).elim\n| (a::l\u2081) []      h := (succ_ne_zero _ h).elim\n| (a::l\u2081) (b::l\u2082) h :=\nlet f := list_to_perm l\u2081 l\u2082 (succ_inj h) in\n{ to_fun := \u03bb x, if h : x.1 = a then \u27e8b, list.mem_cons_self _ _\u27e9\n            else \u27e8(f \u27e8x, mem_of_ne_of_mem h x.2\u27e9).1, mem_cons_of_mem _ begin end\u27e9  }\n\ndef multiset.perm (m : multiset \u03b1) (t : multiset \u03b2) : multiset (\u03b1 \u2243 \u03b2) :=\nmultiset.rec_on m (e :: 0)\n  (\u03bb a m ih, m.bind (\u03bb b, ih.map (\u03bb f, begin end)))\n  (\u03bb 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 : \u2115 \u2192 MPPC_Form\n    | and : MPPC_Form \u2192 MPPC_Form \u2192 MPPC_Form\n    | impl : MPPC_Form \u2192 MPPC_Form \u2192 MPPC_Form\n    | diamond : MPPC_Form \u2192 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 \u2192 Prop\n    | ModalEmpty : isModal \u2205\n    | ModalInsert : \u2200 (\u03a6 : MPPC_Hyp) (\u03c6 : MPPC_Form), \n        isModal \u03a6 \u2192 isModal (insert (MPPC_Form.diamond \u03c6) \u03a6)\n\n    inductive MPPC_derives : MPPC_Hyp \u2192 MPPC_Form \u2192 Prop \n    | hyp {\u03a6 : MPPC_Hyp} {\u03c6 : MPPC_Form}  \n        : (\u03c6 \u2208 \u03a6) \u2192  MPPC_derives \u03a6 \u03c6\n    | truth {\u03a6}                               \n        : MPPC_derives \u03a6 MPPC_Form.top \n    | and_intro {\u03a6} {\u03c6 \u03c8 : MPPC_Form}    \n        : MPPC_derives \u03a6 \u03c6 \u2192 MPPC_derives \u03a6 \u03c8 \u2192 MPPC_derives \u03a6 (MPPC_Form.and \u03c6 \u03c8)\n    | and_eliml {\u03a6} {\u03c6 \u03c8 : MPPC_Form}    \n        : MPPC_derives \u03a6 (MPPC_Form.and \u03c6 \u03c8) \u2192 MPPC_derives \u03a6 \u03c6\n    | and_elimr {\u03a6} {\u03c6 \u03c8 : MPPC_Form}    \n        : MPPC_derives \u03a6 (MPPC_Form.and \u03c6 \u03c8) \u2192 MPPC_derives \u03a6 \u03c8\n    | impl_intro {\u03a6 : MPPC_Hyp} (\u03c6 : MPPC_Form) {\u03c8 : MPPC_Form}   \n        : MPPC_derives (insert \u03c6 \u03a6) \u03c8 \u2192 MPPC_derives \u03a6 (MPPC_Form.impl \u03c6 \u03c8)\n    | impl_elim {\u03a6 : MPPC_Hyp} (\u03c6 : MPPC_Form) {\u03c8 : MPPC_Form} \n        : MPPC_derives \u03a6 (MPPC_Form.impl \u03c6 \u03c8) \u2192 MPPC_derives \u03a6 \u03c6 \u2192 MPPC_derives \u03a6 \u03c8\n    | weak {\u03a6 \u03a8 : MPPC_Hyp} {\u03c6 : MPPC_Form}\n        : MPPC_derives \u03a6 \u03c6 \u2192 MPPC_derives (\u03a6 \u222a \u03a8) \u03c6\n    | dmap {\u03a6 : MPPC_Hyp}{\u03c6 \u03c8 : MPPC_Form} \n        : MPPC_derives (insert \u03c6 \u03a6) \u03c8 \u2192 MPPC_derives (insert (MPPC_Form.diamond \u03c6) \u03a6) (MPPC_Form.diamond \u03c8)\n    | dpure {\u03a6 : MPPC_Hyp} {\u03c6 : MPPC_Form}\n        : MPPC_derives \u03a6 \u03c6 \u2192 MPPC_derives \u03a6 (MPPC_Form.diamond \u03c6)\n    | djoin {\u03a6 : MPPC_Hyp} {\u03c6 : MPPC_Form}\n        : MPPC_derives \u03a6 (MPPC_Form.diamond(MPPC_Form.diamond \u03c6)) \u2192 MPPC_derives \u03a6 (MPPC_Form.diamond \u03c6)\n    open MPPC_derives\n\nnotation (name:= MPPC.diamond) `\u25c7`:81 \u03c6 := MPPC_Form.diamond \u03c6 \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 : \u2200 \u03c6 : MPPC_Form, \n        MPPC_has_derives.MPPC_singleton.singleton \u03c6 = set.has_singleton.singleton \u03c6 :=\n    begin \n      assume \u03c6,\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 {\u03a6 : MPPC_Hyp} {\u03c6 : MPPC_Form}\n        : insert \u03c6 \u03a6 = {\u03c6} \u222a \u03a6 := 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 \u03a6 \u03c8 \u03b8 h\u03c6\u03c8 h\u03c8\u03b8,\n          have helper : MPPC_derives \u03a6 (MPPC_Form.impl \u03c8 \u03b8),\n            apply impl_intro,\n            rw single_union,\n            apply weak,\n            exact h\u03c8\u03b8,\n          apply impl_elim \u03c8,\n          exact helper,\n          exact h\u03c6\u03c8,\n        end,\n      inInsert := set.mem_insert,\n      hyp := @hyp,\n      weak1 := \n        begin\n          assume \u03a6 \u03c6 \u03c8 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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 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 \u03b2)) : multiset \u03b1 :=\ns.map sigma.fst\n\n@[simp] theorem coe_keys {l : list (sigma \u03b2)} :\n  keys (l : multiset (sigma \u03b2)) = (l.keys : multiset \u03b1) :=\nrfl\n\n/-- `nodupkeys s` means that `s` has no duplicate keys. -/\ndef nodupkeys (s : multiset (sigma \u03b2)) : Prop :=\nquot.lift_on s list.nodupkeys (\u03bb s t p, propext $ perm_nodupkeys p)\n\n@[simp] theorem coe_nodupkeys {l : list (sigma \u03b2)} : @nodupkeys \u03b1 \u03b2 l \u2194 l.nodupkeys := iff.rfl\n\nend multiset\n\n/-! ### finmap -/\n\n/-- `finmap \u03b2` is the type of finite maps over a multiset. It is effectively\n  a quotient of `alist \u03b2` by permutation of the underlying list. -/\nstructure finmap (\u03b2 : \u03b1 \u2192 Type v) : Type (max u v) :=\n(entries : multiset (sigma \u03b2))\n(nodupkeys : entries.nodupkeys)\n\n/-- The quotient map from `alist` to `finmap`. -/\ndef alist.to_finmap (s : alist \u03b2) : finmap \u03b2 := \u27e8s.entries, s.nodupkeys\u27e9\n\nlocal notation `\u27e6`:max a `\u27e7`:0 := alist.to_finmap a\n\ntheorem alist.to_finmap_eq {s\u2081 s\u2082 : alist \u03b2} :\n  \u27e6s\u2081\u27e7 = \u27e6s\u2082\u27e7 \u2194 s\u2081.entries ~ s\u2082.entries :=\nby cases s\u2081; cases s\u2082; simp [alist.to_finmap]\n\n@[simp] theorem alist.to_finmap_entries (s : alist \u03b2) : \u27e6s\u27e7.entries = s.entries := rfl\n\n/-- Given `l : list (sigma \u03b2)`, create a term of type `finmap \u03b2` by removing\nentries with duplicate keys. -/\ndef list.to_finmap [decidable_eq \u03b1] (s : list (sigma \u03b2)) : finmap \u03b2 := 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  {\u03b3} (s : finmap \u03b2) (f : alist \u03b2 \u2192 \u03b3)\n  (H : \u2200 a b : alist \u03b2, a.entries ~ b.entries \u2192 f a = f b) : \u03b3 :=\nbegin\n  refine (quotient.lift_on s.1 (\u03bb l, (\u27e8_, \u03bb nd, f \u27e8l, nd\u27e9\u27e9 : part \u03b3))\n    (\u03bb l\u2081 l\u2082 p, part.ext' (perm_nodupkeys p) _) : part \u03b3).get _,\n  { exact \u03bb h\u2081 h\u2082, H _ _ (by exact p) },\n  { have := s.nodupkeys, rcases s.entries with \u27e8l\u27e9, exact id }\nend\n\n@[simp] theorem lift_on_to_finmap {\u03b3} (s : alist \u03b2) (f : alist \u03b2 \u2192 \u03b3) (H) :\n  lift_on \u27e6s\u27e7 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\u2082\n  {\u03b3} (s\u2081 s\u2082 : finmap \u03b2) (f : alist \u03b2 \u2192 alist \u03b2 \u2192 \u03b3)\n  (H : \u2200 a\u2081 b\u2081 a\u2082 b\u2082 : alist \u03b2, a\u2081.entries ~ a\u2082.entries \u2192 b\u2081.entries ~ b\u2082.entries \u2192\n    f a\u2081 b\u2081 = f a\u2082 b\u2082) : \u03b3 :=\nlift_on s\u2081\n  (\u03bb l\u2081, lift_on s\u2082 (f l\u2081) (\u03bb b\u2081 b\u2082 p, H _ _ _ _ (perm.refl _) p))\n  (\u03bb a\u2081 a\u2082 p, have H' : f a\u2081 = f a\u2082 := funext (\u03bb _, H _ _ _ _ p (perm.refl _)), by simp only [H'])\n\n@[simp] theorem lift_on\u2082_to_finmap {\u03b3} (s\u2081 s\u2082 : alist \u03b2) (f : alist \u03b2 \u2192 alist \u03b2 \u2192 \u03b3) (H) :\n  lift_on\u2082 \u27e6s\u2081\u27e7 \u27e6s\u2082\u27e7 f H = f s\u2081 s\u2082 :=\nby cases s\u2081; cases s\u2082; refl\n\n/-! ### induction -/\n\n@[elab_as_eliminator] theorem induction_on\n  {C : finmap \u03b2 \u2192 Prop} (s : finmap \u03b2) (H : \u2200 (a : alist \u03b2), C \u27e6a\u27e7) : C s :=\nby rcases s with \u27e8\u27e8a\u27e9, h\u27e9; exact H \u27e8a, h\u27e9\n\n@[elab_as_eliminator] theorem induction_on\u2082 {C : finmap \u03b2 \u2192 finmap \u03b2 \u2192 Prop}\n  (s\u2081 s\u2082 : finmap \u03b2) (H : \u2200 (a\u2081 a\u2082 : alist \u03b2), C \u27e6a\u2081\u27e7 \u27e6a\u2082\u27e7) : C s\u2081 s\u2082 :=\ninduction_on s\u2081 $ \u03bb l\u2081, induction_on s\u2082 $ \u03bb l\u2082, H l\u2081 l\u2082\n\n@[elab_as_eliminator] theorem induction_on\u2083 {C : finmap \u03b2 \u2192  finmap \u03b2 \u2192 finmap \u03b2 \u2192 Prop}\n  (s\u2081 s\u2082 s\u2083 : finmap \u03b2) (H : \u2200 (a\u2081 a\u2082 a\u2083 : alist \u03b2), C \u27e6a\u2081\u27e7 \u27e6a\u2082\u27e7 \u27e6a\u2083\u27e7) : C s\u2081 s\u2082 s\u2083 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb l\u2081 l\u2082, induction_on s\u2083 $ \u03bb l\u2083, H l\u2081 l\u2082 l\u2083\n\n/-! ### extensionality -/\n\n@[ext] theorem ext : \u2200 {s t : finmap \u03b2}, s.entries = t.entries \u2192 s = t\n| \u27e8l\u2081, h\u2081\u27e9 \u27e8l\u2082, h\u2082\u27e9 H := by congr'\n\n@[simp] theorem ext_iff {s t : finmap \u03b2} : s.entries = t.entries \u2194 s = t :=\n\u27e8ext, congr_arg _\u27e9\n\n/-! ### mem -/\n\n/-- The predicate `a \u2208 s` means that `s` has a value associated to the key `a`. -/\ninstance : has_mem \u03b1 (finmap \u03b2) := \u27e8\u03bb a s, a \u2208 s.entries.keys\u27e9\n\ntheorem mem_def {a : \u03b1} {s : finmap \u03b2} :\n  a \u2208 s \u2194 a \u2208 s.entries.keys := iff.rfl\n\n@[simp] theorem mem_to_finmap {a : \u03b1} {s : alist \u03b2} :\n  a \u2208 \u27e6s\u27e7 \u2194 a \u2208 s := iff.rfl\n\n/-! ### keys -/\n\n/-- The set of keys of a finite map. -/\ndef keys (s : finmap \u03b2) : finset \u03b1 :=\n\u27e8s.entries.keys, induction_on s keys_nodup\u27e9\n\n@[simp] theorem keys_val (s : alist \u03b2) : (keys \u27e6s\u27e7).val = s.keys := rfl\n\n@[simp] theorem keys_ext {s\u2081 s\u2082 : alist \u03b2} :\n  keys \u27e6s\u2081\u27e7 = keys \u27e6s\u2082\u27e7 \u2194 s\u2081.keys ~ s\u2082.keys :=\nby simp [keys, alist.keys]\n\ntheorem mem_keys {a : \u03b1} {s : finmap \u03b2} : a \u2208 s.keys \u2194 a \u2208 s :=\ninduction_on s $ \u03bb s, alist.mem_keys\n\n/-! ### empty -/\n\n/-- The empty map. -/\ninstance : has_emptyc (finmap \u03b2) := \u27e8\u27e80, nodupkeys_nil\u27e9\u27e9\n\ninstance : inhabited (finmap \u03b2) := \u27e8\u2205\u27e9\n\n@[simp] theorem empty_to_finmap : (\u27e6\u2205\u27e7 : finmap \u03b2) = \u2205 := rfl\n\n@[simp] theorem to_finmap_nil [decidable_eq \u03b1] : ([].to_finmap : finmap \u03b2) = \u2205 := rfl\n\ntheorem not_mem_empty {a : \u03b1} : a \u2209 (\u2205 : finmap \u03b2) :=\nmultiset.not_mem_zero a\n\n@[simp] theorem keys_empty : (\u2205 : finmap \u03b2).keys = \u2205 := rfl\n\n/-! ### singleton -/\n\n/-- The singleton map. -/\ndef singleton (a : \u03b1) (b : \u03b2 a) : finmap \u03b2 := \u27e6alist.singleton a b\u27e7\n\n@[simp] theorem keys_singleton (a : \u03b1) (b : \u03b2 a) :\n  (singleton a b).keys = {a} := rfl\n\n@[simp] lemma mem_singleton (x y : \u03b1) (b : \u03b2 y) : x \u2208 singleton y b \u2194 x = y :=\nby simp only [singleton]; erw [mem_cons_eq, mem_nil_iff, or_false]\n\nsection\n\nvariables [decidable_eq \u03b1]\n\ninstance has_decidable_eq [\u2200 a, decidable_eq (\u03b2 a)] : decidable_eq (finmap \u03b2)\n| s\u2081 s\u2082 := decidable_of_iff _ ext_iff\n\n/-! ### lookup -/\n\n/-- Look up the value associated to a key in a map. -/\ndef lookup (a : \u03b1) (s : finmap \u03b2) : option (\u03b2 a) :=\nlift_on s (lookup a) (\u03bb s t, perm_lookup)\n\n@[simp] theorem lookup_to_finmap (a : \u03b1) (s : alist \u03b2) :\n  lookup a \u27e6s\u27e7 = s.lookup a := rfl\n\n@[simp] theorem lookup_list_to_finmap (a : \u03b1) (s : list (sigma \u03b2)) :\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 (\u2205 : finmap \u03b2) = none :=\nrfl\n\ntheorem lookup_is_some {a : \u03b1} {s : finmap \u03b2} :\n  (s.lookup a).is_some \u2194 a \u2208 s :=\ninduction_on s $ \u03bb s, alist.lookup_is_some\n\ntheorem lookup_eq_none {a} {s : finmap \u03b2} : lookup a s = none \u2194 a \u2209 s :=\ninduction_on s $ \u03bb s, alist.lookup_eq_none\n\n@[simp] lemma lookup_singleton_eq {a : \u03b1} {b : \u03b2 a} : (singleton a b).lookup a = some b :=\nby rw [singleton, lookup_to_finmap, alist.singleton, alist.lookup, lookup_cons_eq]\n\ninstance (a : \u03b1) (s : finmap \u03b2) : decidable (a \u2208 s) :=\ndecidable_of_iff _ lookup_is_some\n\nlemma mem_iff {a : \u03b1} {s : finmap \u03b2} : a \u2208 s \u2194 \u2203 b, s.lookup a = some b :=\ninduction_on s $ \u03bb s,\niff.trans list.mem_keys $ exists_congr $ \u03bb b,\n(mem_lookup_iff s.nodupkeys).symm\n\nlemma mem_of_lookup_eq_some {a : \u03b1} {b : \u03b2 a} {s : finmap \u03b2} (h : s.lookup a = some b) : a \u2208 s :=\nmem_iff.mpr \u27e8_, h\u27e9\n\ntheorem ext_lookup {s\u2081 s\u2082 : finmap \u03b2} : (\u2200 x, s\u2081.lookup x = s\u2082.lookup x) \u2192 s\u2081 = s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082 h,\nbegin\n  simp only [alist.lookup, lookup_to_finmap] at h,\n  rw [alist.to_finmap_eq],\n  apply lookup_ext s\u2081.nodupkeys s\u2082.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 : \u03b1) (b : \u03b2 a) (s : finmap \u03b2) : finmap \u03b2 :=\nlift_on s (\u03bb t, \u27e6replace a b t\u27e7) $\n\u03bb s\u2081 s\u2082 p, to_finmap_eq.2 $ perm_replace p\n\n@[simp] theorem replace_to_finmap (a : \u03b1) (b : \u03b2 a) (s : alist \u03b2) :\n  replace a b \u27e6s\u27e7 = \u27e6s.replace a b\u27e7 := by simp [replace]\n\n@[simp] theorem keys_replace (a : \u03b1) (b : \u03b2 a) (s : finmap \u03b2) :\n  (replace a b s).keys = s.keys :=\ninduction_on s $ \u03bb s, by simp\n\n@[simp] theorem mem_replace {a a' : \u03b1} {b : \u03b2 a} {s : finmap \u03b2} :\n  a' \u2208 replace a b s \u2194 a' \u2208 s :=\ninduction_on s $ \u03bb s, by simp\n\nend\n\n/-! ### foldl -/\n\n/-- Fold a commutative function over the key-value pairs in the map -/\ndef foldl {\u03b4 : Type w} (f : \u03b4 \u2192 \u03a0 a, \u03b2 a \u2192 \u03b4)\n  (H : \u2200 d a\u2081 b\u2081 a\u2082 b\u2082, f (f d a\u2081 b\u2081) a\u2082 b\u2082 = f (f d a\u2082 b\u2082) a\u2081 b\u2081)\n  (d : \u03b4) (m : finmap \u03b2) : \u03b4 :=\nm.entries.foldl (\u03bb d s, f d s.1 s.2) (\u03bb 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 : \u03a0 x, \u03b2 x \u2192 bool) (s : finmap \u03b2) : bool :=\ns.foldl (\u03bb x y z, x \u2228 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 : \u03a0 x, \u03b2 x \u2192 bool) (s : finmap \u03b2) : bool :=\ns.foldl (\u03bb x y z, x \u2227 f y z) (by { intros, simp [and.right_comm] }) ff\n\n/-! ### erase -/\n\nsection\n\nvariables [decidable_eq \u03b1]\n\n/-- Erase a key from the map. If the key is not present it does nothing. -/\ndef erase (a : \u03b1) (s : finmap \u03b2) : finmap \u03b2 :=\nlift_on s (\u03bb t, \u27e6erase a t\u27e7) $\n\u03bb s\u2081 s\u2082 p, to_finmap_eq.2 $ perm_erase p\n\n@[simp] theorem erase_to_finmap (a : \u03b1) (s : alist \u03b2) :\n  erase a \u27e6s\u27e7 = \u27e6s.erase a\u27e7 := by simp [erase]\n\n@[simp] \n\n@[simp] theorem keys_erase (a : \u03b1) (s : finmap \u03b2) :\n  (erase a s).keys = s.keys.erase a :=\ninduction_on s $ \u03bb s, by simp\n\n@[simp] theorem mem_erase {a a' : \u03b1} {s : finmap \u03b2} : a' \u2208 erase a s \u2194 a' \u2260 a \u2227 a' \u2208 s :=\ninduction_on s $ \u03bb s, by simp\n\ntheorem not_mem_erase_self {a : \u03b1} {s : finmap \u03b2} : \u00ac a \u2208 erase a s :=\nby rw [mem_erase, not_and_distrib, not_not]; left; refl\n\n@[simp] theorem lookup_erase (a) (s : finmap \u03b2) : lookup a (erase a s) = none :=\ninduction_on s $ lookup_erase a\n\n@[simp] theorem lookup_erase_ne {a a'} {s : finmap \u03b2} (h : a \u2260 a') :\n  lookup a (erase a' s) = lookup a s :=\ninduction_on s $ \u03bb s, lookup_erase_ne h\n\ntheorem erase_erase {a a' : \u03b1} {s : finmap \u03b2} : erase a (erase a' s) = erase a' (erase a s) :=\ninduction_on s $ \u03bb 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 \u03b2) : finmap \u03b2 :=\ns'.foldl (\u03bb s x _, s.erase x) (\u03bb a\u2080 a\u2081 _ a\u2082 _, erase_erase) s\n\ninstance : has_sdiff (finmap \u03b2) := \u27e8sdiff\u27e9\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 : \u03b1) (b : \u03b2 a) (s : finmap \u03b2) : finmap \u03b2 :=\nlift_on s (\u03bb t, \u27e6insert a b t\u27e7) $\n\u03bb s\u2081 s\u2082 p, to_finmap_eq.2 $ perm_insert p\n\n@[simp] theorem insert_to_finmap (a : \u03b1) (b : \u03b2 a) (s : alist \u03b2) :\n  insert a b \u27e6s\u27e7 = \u27e6s.insert a b\u27e7 := by simp [insert]\n\ntheorem insert_entries_of_neg {a : \u03b1} {b : \u03b2 a} {s : finmap \u03b2} : a \u2209 s \u2192\n  (insert a b s).entries = \u27e8a, b\u27e9 ::\u2098 s.entries :=\ninduction_on s $ \u03bb s h,\nby simp [insert_entries_of_neg (mt mem_to_finmap.1 h)]\n\n@[simp] theorem mem_insert {a a' : \u03b1} {b' : \u03b2 a'} {s : finmap \u03b2} :\n  a \u2208 insert a' b' s \u2194 a = a' \u2228 a \u2208 s :=\ninduction_on s mem_insert\n\n@[simp] theorem lookup_insert {a} {b : \u03b2 a} (s : finmap \u03b2) :\n  lookup a (insert a b s) = some b :=\ninduction_on s $ \u03bb s,\nby simp only [insert_to_finmap, lookup_to_finmap, lookup_insert]\n\n@[simp] theorem lookup_insert_of_ne {a a'} {b : \u03b2 a} (s : finmap \u03b2) (h : a' \u2260 a) :\n  lookup a' (insert a b s) = lookup a' s :=\ninduction_on s $ \u03bb s,\nby simp only [insert_to_finmap, lookup_to_finmap, lookup_insert_ne h]\n\n@[simp] theorem insert_insert {a} {b b' : \u03b2 a} (s : finmap \u03b2) :\n  (s.insert a b).insert a b' = s.insert a b' :=\ninduction_on s $ \u03bb s,\nby simp only [insert_to_finmap, insert_insert]\n\ntheorem insert_insert_of_ne {a a'} {b : \u03b2 a} {b' : \u03b2 a'} (s : finmap \u03b2) (h : a \u2260 a') :\n  (s.insert a b).insert a' b' = (s.insert a' b').insert a b :=\ninduction_on s $ \u03bb s,\nby simp only [insert_to_finmap, alist.to_finmap_eq, insert_insert_of_ne _ h]\n\ntheorem to_finmap_cons (a : \u03b1) (b : \u03b2 a) (xs : list (sigma \u03b2)) :\n  list.to_finmap (\u27e8a,b\u27e9 :: xs) = insert a b xs.to_finmap := rfl\n\ntheorem mem_list_to_finmap (a : \u03b1) (xs : list (sigma \u03b2)) :\n  a \u2208 xs.to_finmap \u2194 (\u2203 b : \u03b2 a, sigma.mk a b \u2208 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 \u2190 and_true (a = x_fst) },\n     apply and_congr_right, rintro \u27e8\u27e9, simp only [exists_eq, iff_self, heq_iff_eq] }\n\n@[simp] theorem insert_singleton_eq {a : \u03b1} {b b' : \u03b2 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 : \u03b1) (s : finmap \u03b2) : option (\u03b2 a) \u00d7 finmap \u03b2 :=\nlift_on s (\u03bb t, prod.map id to_finmap (extract a t)) $\n\u03bb s\u2081 s\u2082 p, by simp [perm_lookup p, to_finmap_eq, perm_erase p]\n\n@[simp] theorem extract_eq_lookup_erase (a : \u03b1) (s : finmap \u03b2) :\n  extract a s = (lookup a s, erase a s) :=\ninduction_on s $ \u03bb s, by simp [extract]\n\n/-! ### union -/\n\n/-- `s\u2081 \u222a s\u2082` is the key-based union of two finite maps. It is left-biased: if\nthere exists an `a \u2208 s\u2081`, `lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081`. -/\ndef union (s\u2081 s\u2082 : finmap \u03b2) : finmap \u03b2 :=\nlift_on\u2082 s\u2081 s\u2082 (\u03bb s\u2081 s\u2082, \u27e6s\u2081 \u222a s\u2082\u27e7) $\n\u03bb s\u2081 s\u2082 s\u2083 s\u2084 p\u2081\u2083 p\u2082\u2084, to_finmap_eq.mpr $ perm_union p\u2081\u2083 p\u2082\u2084\n\ninstance : has_union (finmap \u03b2) := \u27e8union\u27e9\n\n@[simp] theorem mem_union {a} {s\u2081 s\u2082 : finmap \u03b2} :\n  a \u2208 s\u2081 \u222a s\u2082 \u2194 a \u2208 s\u2081 \u2228 a \u2208 s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb _ _, mem_union\n\n@[simp] theorem union_to_finmap (s\u2081 s\u2082 : alist \u03b2) : \u27e6s\u2081\u27e7 \u222a \u27e6s\u2082\u27e7 = \u27e6s\u2081 \u222a s\u2082\u27e7 :=\nby simp [(\u222a), union]\n\ntheorem keys_union {s\u2081 s\u2082 : finmap \u03b2} : (s\u2081 \u222a s\u2082).keys = s\u2081.keys \u222a s\u2082.keys :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082, finset.ext $ by simp [keys]\n\n@[simp] theorem lookup_union_left {a} {s\u2081 s\u2082 : finmap \u03b2} :\n  a \u2208 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082, lookup_union_left\n\n@[simp] theorem lookup_union_right {a} {s\u2081 s\u2082 : finmap \u03b2} :\n  a \u2209 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082, lookup_union_right\n\ntheorem lookup_union_left_of_not_in {a} {s\u2081 s\u2082 : finmap \u03b2} (h : a \u2209 s\u2082) :\n  lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081 :=\nbegin\n  by_cases h' : a \u2208 s\u2081,\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 : \u03b2 a} {s\u2081 s\u2082 : finmap \u03b2} :\n  b \u2208 lookup a (s\u2081 \u222a s\u2082) \u2194 b \u2208 lookup a s\u2081 \u2228 a \u2209 s\u2081 \u2227 b \u2208 lookup a s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082, mem_lookup_union\n\ntheorem mem_lookup_union_middle {a} {b : \u03b2 a} {s\u2081 s\u2082 s\u2083 : finmap \u03b2} :\n  b \u2208 lookup a (s\u2081 \u222a s\u2083) \u2192 a \u2209 s\u2082 \u2192 b \u2208 lookup a (s\u2081 \u222a s\u2082 \u222a s\u2083) :=\ninduction_on\u2083 s\u2081 s\u2082 s\u2083 $ \u03bb s\u2081 s\u2082 s\u2083, mem_lookup_union_middle\n\ntheorem insert_union {a} {b : \u03b2 a} {s\u2081 s\u2082 : finmap \u03b2} :\n  insert a b (s\u2081 \u222a s\u2082) = insert a b s\u2081 \u222a s\u2082 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb a\u2081 a\u2082, by simp [insert_union]\n\ntheorem union_assoc {s\u2081 s\u2082 s\u2083 : finmap \u03b2} : (s\u2081 \u222a s\u2082) \u222a s\u2083 = s\u2081 \u222a (s\u2082 \u222a s\u2083) :=\ninduction_on\u2083 s\u2081 s\u2082 s\u2083 $ \u03bb s\u2081 s\u2082 s\u2083,\nby simp only [alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\n@[simp] theorem empty_union {s\u2081 : finmap \u03b2} : \u2205 \u222a s\u2081 = s\u2081 :=\ninduction_on s\u2081 $ \u03bb s\u2081, by rw \u2190 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\u2081 : finmap \u03b2} : s\u2081 \u222a \u2205 = s\u2081 :=\ninduction_on s\u2081 $ \u03bb s\u2081, by rw \u2190 empty_to_finmap;\n  simp [- empty_to_finmap, alist.to_finmap_eq, union_to_finmap, alist.union_assoc]\n\ntheorem erase_union_singleton (a : \u03b1) (b : \u03b2 a) (s : finmap \u03b2) (h : s.lookup a = some b) :\n  s.erase a \u222a singleton a b = s :=\next_lookup\n(\u03bb 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 \u2209 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\u2081 s\u2082` holds if `s\u2081` and `s\u2082` have no keys in common. -/\ndef disjoint (s\u2081 s\u2082 : finmap \u03b2) : Prop :=\n\u2200 x \u2208 s\u2081, \u00ac x \u2208 s\u2082\n\nlemma disjoint_empty (x : finmap \u03b2) : disjoint \u2205 x .\n\n@[symm]\nlemma disjoint.symm (x y : finmap \u03b2) (h : disjoint x y) : disjoint y x :=\n\u03bb p hy hx, h p hx hy\n\nlemma disjoint.symm_iff (x y : finmap \u03b2) : disjoint x y \u2194 disjoint y x :=\n\u27e8disjoint.symm x y, disjoint.symm y x\u27e9\n\nsection\n\nvariables [decidable_eq \u03b1]\n\ninstance : decidable_rel (@disjoint \u03b1 \u03b2) :=\n\u03bb x y, by dsimp only [disjoint]; apply_instance\n\nlemma disjoint_union_left (x y z : finmap \u03b2) : disjoint (x \u222a y) z \u2194 disjoint x z \u2227 disjoint y z :=\nby simp [disjoint, finmap.mem_union, or_imp_distrib, forall_and_distrib]\n\nlemma disjoint_union_right (x y z : finmap \u03b2) : disjoint x (y \u222a z) \u2194 disjoint x y \u2227 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\u2081 s\u2082 : finmap \u03b2} : disjoint s\u2081 s\u2082 \u2192 s\u2081 \u222a s\u2082 = s\u2082 \u222a s\u2081 :=\ninduction_on\u2082 s\u2081 s\u2082 $ \u03bb s\u2081 s\u2082,\nby { intros h, simp only [alist.to_finmap_eq, union_to_finmap, alist.union_comm_of_disjoint h] }\n\ntheorem union_cancel {s\u2081 s\u2082 s\u2083 : finmap \u03b2} (h : disjoint s\u2081 s\u2083) (h' : disjoint s\u2082 s\u2083) :\n  s\u2081 \u222a s\u2083 = s\u2082 \u222a s\u2083 \u2194 s\u2081 = s\u2082 :=\n\u27e8\u03bb h'', begin\n          apply ext_lookup, intro x,\n          have : (s\u2081 \u222a s\u2083).lookup x = (s\u2082 \u222a s\u2083).lookup x, from h'' \u25b8 rfl,\n          by_cases hs\u2081 : x \u2208 s\u2081,\n          { rwa [lookup_union_left hs\u2081, lookup_union_left_of_not_in (h _ hs\u2081)] at this, },\n          { by_cases hs\u2082 : x \u2208 s\u2082,\n            { rwa [lookup_union_left_of_not_in (h' _ hs\u2082), lookup_union_left hs\u2082] at this, },\n            { rw [lookup_eq_none.mpr hs\u2081, lookup_eq_none.mpr hs\u2082] } }\n        end,\n \u03bb h, h \u25b8 rfl\u27e9\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 \u2192 type \u2192 type\nopen type\n\nvariable \u03bd : type \u2192 Type\n\ninductive term : type \u2192 Type\n| var : \u03a0 {t}, \u03bd t \u2192 term t\n| lam : \u03a0 {t\u2081 t\u2082}, (\u03bd t\u2081 \u2192 term t\u2082) \u2192 term (arrow t\u2081 t\u2082)\n| app : \u03a0 {t\u2081 t\u2082}, term (arrow t\u2081 t\u2082) \u2192 term t\u2081 \u2192 term t\u2082\n| eq : \u03a0 {t}, term t \u2192 term t \u2192 term prop\nopen term\n\ndef Term (t : type) : Type 1 :=\n\u03a0 \u03bd, term \u03bd t\n\ndef judgment : list type \u2192 type \u2192 Type :=\n\u03bb \u0393 t, list.foldr (\u03bb t \u03b1, \u03bd t \u2192 \u03b1) (term \u03bd t) \u0393\n\ndef Judgment (\u0393 : list type) (t : type) : Type 1 :=\n\u03a0 \u03bd, judgment \u03bd \u0393 t\n\n----\n\nuniverse u\nvariables {\u03b1 \u03b2 : Type u}\n\ninductive mem : \u03b1 \u2192 list \u03b1 \u2192 Type u\n| here : \u03a0 {x l}, mem x (x :: l)\n| there : \u03a0 {x l y}, mem x l \u2192 mem x (y :: l)\nopen mem\n\nlocal infix ` \u2208' `:50 := mem\n\nvariables {\u0393 \u0393\u2081 \u0393\u2082 : list type} {t t\u2081 t\u2082 t\u2083 : type}\n\ndef subst' : \u03a0 {t : type}, term (term \u03bd) t \u2192 term \u03bd t\n| _ (var m) := m\n| _ (lam f) := lam (\u03bb x, subst' (f (var x)))\n| _ (app m\u2081 m\u2082) := app (subst' m\u2081) (subst' m\u2082)\n| _ (eq m\u2081 m\u2082) := eq (subst' m\u2081) (subst' m\u2082)\n\nnamespace judgment\n  def weak : Judgment \u0393 t\u2082 \u2192 Judgment (t\u2081 :: \u0393) t\u2082 :=\n  \u03bb m \u03bd x, m \u03bd\n\n  def var' : \u03a0 {\u0393}, judgment \u03bd (t :: \u0393) t\n  | [] := \u03bb x, var x\n  | (t :: \u0393) := \u03bb x y, var' x\n\n  def var : \u03a0 {\u0393}, t \u2208' \u0393 \u2192 Judgment \u0393 t\n  | _ here := \u03bb \u03bd, var' \u03bd\n  | _ (there h) := weak (var h)\n\n  def lam' : \u03a0 {\u0393}, judgment \u03bd (t\u2081 :: \u0393) t\u2082 \u2192 judgment \u03bd \u0393 (arrow t\u2081 t\u2082)\n  | [] m := lam (\u03bb x, m x)\n  | (t :: \u0393) f := \u03bb x, lam' (\u03bb y, f y x)\n\n  def lam : Judgment (t\u2081 :: \u0393) t\u2082 \u2192 Judgment \u0393 (arrow t\u2081 t\u2082) :=\n  \u03bb m \u03bd, lam' \u03bd (m \u03bd)\n\n  def app' : \u03a0 {\u0393}, judgment \u03bd \u0393 (arrow t\u2081 t\u2082) \u2192 judgment \u03bd \u0393 t\u2081 \u2192 judgment \u03bd \u0393 t\u2082\n  | [] m\u2081 m\u2082 := app m\u2081 m\u2082\n  | (t :: \u0393) f m := \u03bb x, app' (f x) (m x)\n\n  def app : Judgment \u0393 (arrow t\u2081 t\u2082) \u2192 Judgment \u0393 t\u2081 \u2192 Judgment \u0393 t\u2082 :=\n  \u03bb m\u2081 m\u2082 \u03bd, app' \u03bd (m\u2081 \u03bd) (m\u2082 \u03bd)\n\n  def eq' : \u03a0 {\u0393 : list type}, judgment \u03bd \u0393 t \u2192 judgment \u03bd \u0393 t \u2192 judgment \u03bd \u0393 prop\n  | [] m\u2081 m\u2082 := eq m\u2081 m\u2082\n  | (t :: \u0393) m\u2081 m\u2082 := \u03bb x, eq' (m\u2081 x) (m\u2082 x)\n\n  def eq : Judgment \u0393 t \u2192 Judgment \u0393 t \u2192 Judgment \u0393 prop :=\n  \u03bb m\u2081 m\u2082 \u03bd, eq' \u03bd (m\u2081 \u03bd) (m\u2082 \u03bd)\n\n  def subst'' : \u03a0 {\u0393}, judgment (term \u03bd) (t\u2081 :: \u0393) t\u2082 \u2192 judgment \u03bd \u0393 t\u2081 \u2192 judgment \u03bd \u0393 t\u2082\n  | [] m\u2081 m\u2082 := subst' \u03bd (m\u2081 m\u2082)\n  | (t :: \u0393) f m := \u03bb x, subst'' (\u03bb x', f x' (term.var x)) (m x)\n\n  def subst : Judgment (t\u2081 :: \u0393) t\u2082 \u2192 Judgment \u0393 t\u2081 \u2192 Judgment \u0393 t\u2082 :=\n  \u03bb m\u2081 m\u2082 \u03bd, subst'' \u03bd (m\u2081 _) (m\u2082 \u03bd)\nend judgment\nopen judgment\n\n----\n\ndef type.foldr : list type \u2192 type \u2192 type :=\n\u03bb \u0393 t, list.foldr arrow t \u0393\n\ndef judgment.to_term' : \u03a0 {\u0393 : list type}, judgment \u03bd \u0393 t \u2192 term \u03bd (type.foldr \u0393 t)\n| [] m := m\n| (t :: \u0393) f := lam (\u03bb x, judgment.to_term' (f x))\n\ndef judgment.to_term : Judgment \u0393 t \u2192 Term (type.foldr \u0393 t) :=\n\u03bb m \u03bd, judgment.to_term' \u03bd (m \u03bd)\n\ndef term.to_judgment' : \u03a0 {\u0393 : list type}, term (term \u03bd) (type.foldr \u0393 t) \u2192 judgment \u03bd \u0393 t\n| [] m := subst' \u03bd m\n| (t :: \u0393) m :=\n  match m with\n  | (var x) := \u03bb x, term.to_judgment' (app m (var (var x)))\n  | (lam f) := \u03bb x, term.to_judgment' (f (var x))\n  | (app m\u2081 m\u2082) := \u03bb x, term.to_judgment' (app m (var (var x)))\n  end\n\ndef term.to_judgment : Term (type.foldr \u0393 t) \u2192 Judgment \u0393 t :=\n\u03bb m \u03bd, term.to_judgment' \u03bd (m _)\n\n----\n\ndef domain : type \u2192 Type\n| base := term \u03bd base\n| prop := term \u03bd prop\n| (arrow t\u2081 t\u2082) := domain t\u2081 \u2192 domain t\u2082\n\ndef Domain (t : type) : Type 1 :=\n\u03a0 \u03bd, domain \u03bd t\n\ndef reify_reflect : \u03a0 (t : type), (domain \u03bd t \u2192 term \u03bd t) \u00d7 (term \u03bd t \u2192 domain \u03bd t)\n| base := \u27e8 id, id \u27e9\n| prop := \u27e8 id, id \u27e9\n| (arrow t\u2081 t\u2082) :=\n   let r\u2081 := reify_reflect t\u2081 in\n   let r\u2082 := reify_reflect t\u2082 in\n   let reify (f : domain \u03bd t\u2081 \u2192 domain \u03bd t\u2082) := lam (\u03bb x, r\u2082.1 (f (r\u2081.2 (var x)))) in\n   let reflect (f : term \u03bd (arrow t\u2081 t\u2082)) := \u03bb x, r\u2082.2 (app f (r\u2081.1 x)) in\n   \u27e8reify, reflect\u27e9\n\ndef reify' : domain \u03bd t \u2192 term \u03bd t :=\n\u03bb x, (reify_reflect \u03bd t).1 x\n\ndef reify : Domain t \u2192 Term t :=\n\u03bb x \u03bd, reify' \u03bd (x \u03bd)\n\ndef eval' : \u03a0 {t : type}, term (domain \u03bd) t \u2192 domain \u03bd t\n| _ (var x) := x\n| _ (lam f) := \u03bb x, eval' (f x)\n| _ (app m\u2081 m\u2082) := (eval' m\u2081) (eval' m\u2082)\n| _ (eq m\u2081 m\u2082) := eq (reify' \u03bd (eval' m\u2081)) (reify' \u03bd (eval' m\u2082))\n\ndef eval : Term t \u2192 Domain t :=\n\u03bb m \u03bd, eval' \u03bd (m _)\n\ndef normalize : Term t \u2192 Term t :=\nreify \u2218 eval\n\ninstance term_setoid : setoid (Term t) :=\n\u27e8inv_image eq normalize,\n inv_image.equivalence eq normalize eq_equivalence\u27e9\n\ninstance judgment_setoid [h : setoid (Term (type.foldr \u0393 t))] : setoid (Judgment \u0393 t) :=\n\u27e8inv_image h.r judgment.to_term,\n inv_image.equivalence h.r judgment.to_term h.iseqv\u27e9\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  \u03bb \u03bd, eq (lam (\u03bb x : \u03bd prop, var x)) (lam (\u03bb x, var x))\n\n  def and : Term (arrow prop (arrow prop prop)) :=\n  \u03bb \u03bd, lam (\u03bb p\u2081, lam (\u03bb p\u2082, eq (lam (\u03bb f : \u03bd (arrow _ (arrow _ prop)), app (app (var f) (top \u03bd)) (top \u03bd))) (lam (\u03bb f, app (app (var f) (var p\u2081)) (var p\u2082)))))\n\n  def Forall : Term (arrow (arrow t prop) prop) :=\n  \u03bb \u03bd, lam (\u03bb f, eq (var f) (lam (\u03bb x, (top \u03bd))))\n\n  def bot : Term prop :=\n  \u03bb \u03bd, app (Forall \u03bd) (lam (\u03bb p, var p))\n\n  def implies : Term (arrow prop (arrow prop prop)) :=\n  \u03bb \u03bd, lam (\u03bb p\u2081, lam (\u03bb p\u2082, eq (app (app (and \u03bd) (var p\u2081)) (var p\u2082)) (var p\u2081)))\n\n  def not : Term (arrow prop prop) :=\n  \u03bb \u03bd, lam (\u03bb p, app (app (implies \u03bd) (var p)) (bot \u03bd))\n\n  def iff : Term (arrow prop (arrow prop prop)) :=\n  \u03bb \u03bd, lam (\u03bb p\u2081, lam (\u03bb p\u2082, app (app (and \u03bd) (app (app (implies \u03bd) (var p\u2081)) (var p\u2082))) (app (app (implies \u03bd) (var p\u2082)) (var p\u2081))))\n\n  def or : Term (arrow prop (arrow prop prop)) :=\n  \u03bb \u03bd, lam (\u03bb p\u2081, lam (\u03bb p\u2082, app (Forall \u03bd) (lam (\u03bb r, app (app (implies \u03bd) (app (app (and \u03bd) (app (app (implies \u03bd) (var p\u2081)) (var r))) (app (app (implies \u03bd) (var p\u2082)) (var r)))) (var r)))))\n\n  def Exists : Term (arrow (arrow t prop) prop) :=\n  \u03bb \u03bd, lam (\u03bb f, app (Forall \u03bd) (lam (\u03bb r, app (app (implies \u03bd) (app (Forall \u03bd) (lam (\u03bb x, app (app (implies \u03bd) (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 : \u03a0 {\u0393}, list (Judgment \u0393 prop) \u2192 Judgment \u0393 prop \u2192 Prop\n| hyp : \u03a0 {\u0393 \u03a6} {\u03c6 : Judgment \u0393 prop}, \u03c6 \u2208 \u03a6 \u2192 Theorem \u03a6 \u03c6\n| refl : \u03a0 {\u0393 \u03a6 t} {m\u2081 m\u2082 : Judgment \u0393 t}, m\u2081 \u2248 m\u2082 \u2192 Theorem \u03a6 (eq m\u2081 m\u2082)\n| subst : \u03a0 {\u0393 \u03a6 t} (m : Judgment (t :: \u0393) prop) (m\u2082 m\u2081 : Judgment \u0393 t), Theorem \u03a6 (eq m\u2081 m\u2082) \u2192 Theorem \u03a6 (subst m m\u2081) \u2192 Theorem \u03a6 (subst m m\u2082)\n| prop_ext : \u03a0 {\u0393 \u03a6} {\u03c6\u2081 \u03c6\u2082 : Judgment \u0393 prop}, Theorem (\u03c6\u2081 :: \u03a6) \u03c6\u2082 \u2192 Theorem (\u03c6\u2082 :: \u03a6) \u03c6\u2081 \u2192 Theorem \u03a6 (eq \u03c6\u2081 \u03c6\u2082)\n| fun_ext : \u03a0 {\u0393 \u03a6 t\u2081 t\u2082} (m\u2081 m\u2082 : Judgment (t\u2081 :: \u0393) t\u2082), Theorem (list.map weak \u03a6) (eq m\u2081 m\u2082) \u2192 Theorem \u03a6 (eq (lam m\u2081) (lam m\u2082))\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 {\u03c6\u2081 \u03c6\u2082} {\u03a6 : list (Judgment [] prop)} : Theorem \u03a6 (app (app and \u03c6\u2081) \u03c6\u2082) \u2192 Theorem \u03a6 \u03c6\u2081 :=\nbegin\n  intro p,\n  apply Theorem.subst\n    (var here)\n    \u03c6\u2081\n    (\u03bb \u03bd, app (lam (\u03bb f, app (app (var f) (\u03c6\u2081 \u03bd)) (\u03c6\u2082 \u03bd))) (lam (\u03bb p\u2081, lam (\u03bb p\u2082, var p\u2081)))),\n  { apply Theorem.refl,\n    canonicity, },\n  { apply Theorem.subst\n      (@id (Judgment [arrow _ prop] prop) $ \u03bb \u03bd f, app (var f) (lam (\u03bb p\u2081, lam (\u03bb p\u2082, var p\u2081))))\n      (\u03bb \u03bd, lam (\u03bb f, app (app (var f) (\u03c6\u2081 \u03bd)) (\u03c6\u2082 \u03bd)))\n      (@id (Judgment [] (arrow _ prop)) $ \u03bb \u03bd, lam (\u03bb f, app (app (var f) (top \u03bd)) (top \u03bd))),\n    { apply Theorem.subst\n        (var here)\n        (eq\n          (@id (Judgment [] (arrow _ prop)) $ \u03bb \u03bd, lam (\u03bb f, app (app (var f) (top \u03bd)) (top \u03bd)))\n          (\u03bb \u03bd, lam (\u03bb f, app (app (var f) (\u03c6\u2081 \u03bd)) (\u03c6\u2082 \u03bd))))\n        (\u03bb \u03bd, app (app (lam (\u03bb p\u2081, lam (\u03bb p\u2082, eq (lam (\u03bb f : \u03bd (arrow _ (arrow _ prop)), app (app (var f) (top \u03bd)) (top \u03bd))) (lam (\u03bb f, app (app (var f) (var p\u2081)) (var p\u2082)))))) (\u03c6\u2081 \u03bd)) (\u03c6\u2082 \u03bd)),\n      { apply Theorem.refl,\n        canonicity },\n      { from p } },\n    { apply Theorem.subst\n        (var here)\n        (@id (Judgment [] _) $ \u03bb \u03bd, app (lam (\u03bb f, app (app (var f) (top \u03bd)) (top \u03bd))) (lam (\u03bb p\u2081, lam (\u03bb p\u2082, var p\u2081))))\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 \u00d7 A -> X \u00d7 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 {\u03b1  \u03c3 \u03b2 : Type} (f : \u03c3 \u2192 \u03b1 \u2192 \u03b2 \u00d7 \u03c3) : \u03c3 \u2192 list \u03b1 \u2192 (list \u03b2 \u00d7 \u03c3)\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 {\u03b1 : Type} (p : \u03b1 \u2192 bool) : \u2115 \u2192 list \u03b1 \u2192 option (\u2115 \u00d7 \u03b1)\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 {\u03b1 : Type} (p : \u03b1 \u2192 bool) (l : list \u03b1) : option (\u2115 \u00d7 \u03b1) :=\n  first_index_of_core p 0 l\n\n\ndef find_option {A} [decidable_eq A] (item: A) (l : list A) : option \u2115 :=\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 \u2208 xs)\n  : \u2203 n, xs.find_option x = some n \u2227 n < xs.length\n:= begin\nrw \u2190 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 \u2260 length xs,\n  apply ne_of_lt, assumption,\n  rw (if_neg H) at Hn, injection Hn with Hn',\n  rw \u2190 Hn', assumption\n}\nend\n\nlemma find_option_mem {A} [decidable_eq A] {x : A} {xs : list A}\n  (H : x \u2208 xs)\n  : \u2203 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 \u2192 Prop} [decidable_pred P]\n  (xs ys : list A)\n  (n : \u2115)\n  (Hn : n \u2260 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 : \u2115)\n  (Hn : n \u2260 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] : \u00ac\u00aca \u2194 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 : \u2115)\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 \u2190 list.index_of_lt_length at H,\n  have H1 : list.index_of x xs \u2260 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 \u2260 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 \u2192 list Y \u2192 Sort u)\n  (P0 : P [] [])\n  (PS : \u2200 x y xs ys, P xs ys \u2192 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 \u2218 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 \u2218 list.cons x) xs =\n   ((\u03bb xs, xs ++ [x]) \u2218 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 \u2192 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 \u00d7 A)) (f : A -> B)\n  : map (prod.fst \u2218 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 \u2260 []) : list.map f xs \u2260 [] :=\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 : \u2115)\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 {\u03b1 : Type u} {\u03b2 : 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 \u03b1 \u2192 Prop := \u03bbx, x = nil\n\ninstance null_decidable : \u2200 xs : list \u03b1, 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 \u03b2 \u2192 \u03b1 \u2192 Prop)\n                    (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1)\n                    (h : \u2200(l : list \u03b2) (t : \u03b1) (e : \u03b2), P l t \u2192  P (l ++ [e]) (f t e))\n: \u2200(r : list \u03b2) (s : \u03b1), P r s \u2192 \u2200 (l : list \u03b2), 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 \u03b2 \u2192 \u03b1 \u2192 Prop)\n                  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1)\n                  (ind_step : \u2200(l : list \u03b2) (t : \u03b1) (e : \u03b2), P l t \u2192  P (l ++ [e]) (f t e))\n                  (s : \u03b1)\n                  (base_case : P nil s)\n                  (l : list \u03b2)\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u03b1 \u03b2 \u03b3 \u03b4 : Type*}\n\n/-- The type of bounded maps from `\u03b1` to `\u03b2`, the maps which send a bounded set to a bounded set. -/\nstructure locally_bounded_map (\u03b1 \u03b2 : Type*) [bornology \u03b1] [bornology \u03b2] :=\n(to_fun : \u03b1 \u2192 \u03b2)\n(comap_cobounded_le' : (cobounded \u03b2).comap to_fun \u2264 cobounded \u03b1)\n\n/-- `locally_bounded_map_class F \u03b1 \u03b2` 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*) (\u03b1 \u03b2 : out_param $ Type*) [bornology \u03b1]\n  [bornology \u03b2]\n  extends fun_like F \u03b1 (\u03bb _, \u03b2) :=\n(comap_cobounded_le (f : F) : (cobounded \u03b2).comap f \u2264 cobounded \u03b1)\n\nexport locally_bounded_map_class (comap_cobounded_le)\n\nlemma is_bounded.image [bornology \u03b1] [bornology \u03b2] [locally_bounded_map_class F \u03b1 \u03b2] {f : F}\n  {s : set \u03b1} (hs : is_bounded s) : is_bounded (f '' s) :=\ncomap_cobounded_le_iff.1 (comap_cobounded_le f) hs\n\ninstance [bornology \u03b1] [bornology \u03b2] [locally_bounded_map_class F \u03b1 \u03b2] :\n  has_coe_t F (locally_bounded_map \u03b1 \u03b2) :=\n\u27e8\u03bb f, \u27e8f, comap_cobounded_le f\u27e9\u27e9\n\nnamespace locally_bounded_map\nvariables [bornology \u03b1] [bornology \u03b2] [bornology \u03b3]\n  [bornology \u03b4]\n\ninstance : locally_bounded_map_class (locally_bounded_map \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := \u03bb f, f.to_fun,\n  coe_injective' := \u03bb f g h, by { cases f, cases g, congr' },\n  comap_cobounded_le := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : locally_bounded_map \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n@[ext] lemma ext {f g : locally_bounded_map \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) :\n  locally_bounded_map \u03b1 \u03b2 :=\n\u27e8f', h.symm \u25b8 f.comap_cobounded_le'\u27e9\n\n/-- Construct a `locally_bounded_map` from the fact that the function maps bounded sets to bounded\nsets. -/\ndef of_map_bounded (f : \u03b1 \u2192 \u03b2) (h) : locally_bounded_map \u03b1 \u03b2 := \u27e8f, comap_cobounded_le_iff.2 h\u27e9\n\n@[simp] lemma coe_of_map_bounded (f : \u03b1 \u2192 \u03b2) {h} : \u21d1(of_map_bounded f h) = f := rfl\n@[simp] lemma of_map_bounded_apply (f : \u03b1 \u2192 \u03b2) {h} (a : \u03b1) : of_map_bounded f h a = f a := rfl\n\nvariables (\u03b1)\n\n/-- `id` as a `locally_bounded_map`. -/\nprotected def id : locally_bounded_map \u03b1 \u03b1 := \u27e8id, comap_id.le\u27e9\n\ninstance : inhabited (locally_bounded_map \u03b1 \u03b1) := \u27e8locally_bounded_map.id \u03b1\u27e9\n\n@[simp] lemma coe_id : \u21d1(locally_bounded_map.id \u03b1) = id := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : locally_bounded_map.id \u03b1 a = a := rfl\n\n/-- Composition of `locally_bounded_map`s as a `locally_bounded_map`. -/\ndef comp (f : locally_bounded_map \u03b2 \u03b3) (g : locally_bounded_map \u03b1 \u03b2) : locally_bounded_map \u03b1 \u03b3 :=\n{ to_fun := f \u2218 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 \u03b2 \u03b3) (g : locally_bounded_map \u03b1 \u03b2) :\n  \u21d1(f.comp g) = f \u2218 g := rfl\n@[simp] lemma comp_apply (f : locally_bounded_map \u03b2 \u03b3) (g : locally_bounded_map \u03b1 \u03b2) (a : \u03b1) :\n  f.comp g a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : locally_bounded_map \u03b3 \u03b4) (g : locally_bounded_map \u03b2 \u03b3)\n  (h : locally_bounded_map \u03b1 \u03b2) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : locally_bounded_map \u03b1 \u03b2) :\n  f.comp (locally_bounded_map.id \u03b1) = f := ext $ \u03bb a, rfl\n@[simp] lemma id_comp (f : locally_bounded_map \u03b1 \u03b2) :\n  (locally_bounded_map.id \u03b2).comp f = f := ext $ \u03bb a, rfl\n\nlemma cancel_right {g\u2081 g\u2082 : locally_bounded_map \u03b2 \u03b3} {f : locally_bounded_map \u03b1 \u03b2}\n  (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : locally_bounded_map \u03b2 \u03b3} {f\u2081 f\u2082 : locally_bounded_map \u03b1 \u03b2}\n  (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, ext $ \u03bb a, hg $ by rw [\u2190comp_apply, h, comp_apply], congr_arg _\u27e9\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jan-David Salchow, S\u00e9bastien Gou\u00ebzel, Jean Lo, Yury Kudryashov, Fr\u00e9d\u00e9ric 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\u2081`-module `M` and `R\u2082`-module `M\u2082` with respect to the `ring_hom` `\u03c3` is denoted by `M \u2192SL[\u03c3] M\u2082`.\nPlain linear maps are denoted by `M \u2192L[R] M\u2082` and star-linear maps by `M \u2192L\u22c6[R] M\u2082`.\n\nThe corresponding notation for equivalences is `M \u2243SL[\u03c3] M\u2082`, `M \u2243L[R] M\u2082` and `M \u2243L\u22c6[R] M\u2082`.\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 (\u03bb p : R \u00d7 M, p.1 \u2022 p.2) (\ud835\udcdd 0 \u00d7\u1da0 (\ud835\udcdd 0)) (\ud835\udcdd 0))\n  (hmulleft : \u2200 m : M, tendsto (\u03bb a : R, a \u2022 m) (\ud835\udcdd 0) (\ud835\udcdd 0))\n  (hmulright : \u2200 a : R, tendsto (\u03bb m : M, a \u2022 m) (\ud835\udcdd 0) (\ud835\udcdd 0)) : has_continuous_smul R M :=\n\u27e8begin\n  rw continuous_iff_continuous_at,\n  rintros \u27e8a\u2080, m\u2080\u27e9,\n  have key : \u2200 p : R \u00d7 M,\n    p.1 \u2022 p.2 = a\u2080 \u2022 m\u2080 + ((p.1 - a\u2080) \u2022 m\u2080 + a\u2080 \u2022 (p.2 - m\u2080) + (p.1 - a\u2080) \u2022 (p.2 - m\u2080)),\n  { rintro \u27e8a, m\u27e9,\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\u2080).comp,\n    rw [show (\u03bb p : R \u00d7 M, p.1 - a\u2080) = (\u03bb a, a - a\u2080) \u2218 prod.fst, by {ext, refl }, nhds_prod_eq],\n    have : tendsto (\u03bb a, a - a\u2080) (\ud835\udcdd a\u2080) (\ud835\udcdd 0),\n    { rw \u2190 sub_self a\u2080,\n      exact tendsto_id.sub tendsto_const_nhds },\n    exact this.comp tendsto_fst  },\n  { rw [sub_self, smul_zero],\n    apply (hmulright a\u2080).comp,\n    rw [show (\u03bb p : R \u00d7 M, p.2 - m\u2080) = (\u03bb m, m - m\u2080) \u2218 prod.snd, by {ext, refl }, nhds_prod_eq],\n    have : tendsto (\u03bb m, m - m\u2080) (\ud835\udcdd m\u2080) (\ud835\udcdd 0),\n    { rw \u2190 sub_self m\u2080,\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 (\u03bb p : R \u00d7 M, (p.fst - a\u2080) \u2022 (p.snd - m\u2080)) =\n             (\u03bb  p : R \u00d7 M, p.1 \u2022 p.2) \u2218 (prod.map (\u03bb a, a - a\u2080) (\u03bb m, m - m\u2080)), by { ext, refl }],\n    apply hmul.comp (tendsto.prod_map _ _);\n    { rw \u2190 sub_self ,\n      exact tendsto_id.sub tendsto_const_nhds } },\nend\u27e9\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`\u22a4` 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 (\ud835\udcdd[{x : R | is_unit x}] 0)]\n  (s : submodule R M) (hs : (interior (s:set M)).nonempty) :\n  s = \u22a4 :=\nbegin\n  rcases hs with \u27e8y, hy\u27e9,\n  refine (submodule.eq_top_iff'.2 $ \u03bb x, _),\n  rw [mem_interior_iff_mem_nhds] at hy,\n  have : tendsto (\u03bb c:R, y + c \u2022 x) (\ud835\udcdd[{x : R | is_unit x}] 0) (\ud835\udcdd (y + (0:R) \u2022 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 \u27e8_, hu : y + _ \u2022 _ \u2208 s, u, rfl\u27e9 :=\n    nonempty_of_mem (inter_mem (mem_map.1 (this hy)) self_mem_nhds_within),\n  have hy' : y \u2208 \u2191s := mem_of_mem_nhds hy,\n  rwa [s.add_mem_iff_right hy', \u2190units.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 \u2022 x = 0` implies `c = 0 \u2228 x = 0`. Then `M` has no isolated points. We formulate this\nusing `ne_bot (\ud835\udcdd[{x}\u1d9c] 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 = \u211d` 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 (\ud835\udcdd[{0}\u1d9c] (0 : R))]\n  [no_zero_smul_divisors R M] (x : M) :\n  ne_bot (\ud835\udcdd[{x}\u1d9c] x) :=\nbegin\n  rcases exists_ne (0 : M) with \u27e8y, hy\u27e9,\n  suffices : tendsto (\u03bb c : R, x + c \u2022 y) (\ud835\udcdd[{0}\u1d9c] 0) (\ud835\udcdd[{x}\u1d9c] 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 {\u03b1 \u03b2 : Type*} [topological_space \u03b2]\n\ninstance [topological_space \u03b1] [semiring \u03b1] [add_comm_monoid \u03b2] [module \u03b1 \u03b2]\n  [has_continuous_smul \u03b1 \u03b2] (S : submodule \u03b1 \u03b2) :\n  has_continuous_smul \u03b1 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 \u03b1] [add_comm_group \u03b2] [module \u03b1 \u03b2] [topological_add_group \u03b2] (S : submodule \u03b1 \u03b2) :\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  (\u03bb p : R \u00d7 M, p.1 \u2022 p.2) '' ((set.univ : set R).prod (closure (s : set M)))\n  \u2286 closure (s : set M) :=\ncalc\n(\u03bb p : R \u00d7 M, p.1 \u2022 p.2) '' ((set.univ : set R).prod (closure (s : set M)))\n    = (\u03bb p : R \u00d7 M, p.1 \u2022 p.2) '' (closure ((set.univ : set R).prod s)) : by simp [closure_prod_eq]\n... \u2286 closure ((\u03bb p : R \u00d7 M, p.1 \u2022 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 \u27e8_, \u03bb hx, \u27e8\u27e81, x\u27e9, \u27e8set.mem_univ _, hx\u27e9, one_smul R _\u27e9\u27e9,\n  rintros \u27e8\u27e8c, y\u27e9, \u27e8hc, hy\u27e9, rfl\u27e9,\n  simp [s.smul_mem c hy]\nend\n\nlemma submodule.closure_smul_self_eq (s : submodule R M) :\n  (\u03bb p : R \u00d7 M, p.1 \u2022 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  (\u03bb x hx, \u27e8\u27e81, x\u27e9, \u27e8set.mem_univ _, hx\u27e9, one_smul R _\u27e9)\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' := \u03bb c x hx, s.closure_smul_self_subset \u27e8\u27e8c, x\u27e9, \u27e8set.mem_univ _, hx\u27e9, rfl\u27e9,\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 (\u03bb p : R \u00d7 s.topological_closure, p.1 \u2022 (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 \u2264 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 \u2264 t) (ht : is_closed (t : set M)) :\n  s.topological_closure \u2264 t :=\nclosure_minimal h ht\n\nlemma submodule.topological_closure_mono {s : submodule R M} {t : submodule R M} (h : s \u2264 t) :\n  s.topological_closure \u2264 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\u2082` will be topological modules over the topological\nring `R`. -/\nstructure continuous_linear_map\n  {R : Type*} {S : Type*} [semiring R] [semiring S] (\u03c3 : R \u2192+* S)\n  (M : Type*) [topological_space M] [add_comm_monoid M]\n  (M\u2082 : Type*) [topological_space M\u2082] [add_comm_monoid M\u2082]\n  [module R M] [module S M\u2082]\n  extends M \u2192\u209b\u2097[\u03c3] M\u2082 :=\n(cont : continuous to_fun . tactic.interactive.continuity')\n\nnotation M ` \u2192SL[`:25 \u03c3 `] ` M\u2082 := continuous_linear_map \u03c3 M M\u2082\nnotation M ` \u2192L[`:25 R `] ` M\u2082 := continuous_linear_map (ring_hom.id R) M M\u2082\nnotation M ` \u2192L\u22c6[`:25 R `] ` M\u2082 := continuous_linear_map (@star_ring_aut R _ _ : R \u2192+* R) M M\u2082\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\u2082` 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] (\u03c3 : R \u2192+* S)\n  {\u03c3' : S \u2192+* R} [ring_hom_inv_pair \u03c3 \u03c3'] [ring_hom_inv_pair \u03c3' \u03c3]\n  (M : Type*) [topological_space M] [add_comm_monoid M]\n  (M\u2082 : Type*) [topological_space M\u2082] [add_comm_monoid M\u2082]\n  [module R M] [module S M\u2082]\n  extends M \u2243\u209b\u2097[\u03c3] M\u2082 :=\n(continuous_to_fun  : continuous to_fun . tactic.interactive.continuity')\n(continuous_inv_fun : continuous inv_fun . tactic.interactive.continuity')\n\nnotation M ` \u2243SL[`:50 \u03c3 `] ` M\u2082 := continuous_linear_equiv \u03c3 M M\u2082\nnotation M ` \u2243L[`:50 R `] ` M\u2082 := continuous_linear_equiv (ring_hom.id R) M M\u2082\nnotation M ` \u2243L\u22c6[`:50 R `] ` M\u2082 := continuous_linear_equiv (@star_ring_aut R _ _ : R \u2192+* R) M M\u2082\n\nnamespace continuous_linear_map\n\nsection semiring\n/-!\n### Properties that hold for non-necessarily commutative semirings.\n-/\n\nvariables\n{R\u2081 : Type*} {R\u2082 : Type*} {R\u2083 : Type*} [semiring R\u2081] [semiring R\u2082] [semiring R\u2083]\n{\u03c3\u2081\u2082 : R\u2081 \u2192+* R\u2082} {\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083}\n{M\u2081 : Type*} [topological_space M\u2081] [add_comm_monoid M\u2081]\n{M\u2082 : Type*} [topological_space M\u2082] [add_comm_monoid M\u2082]\n{M\u2083 : Type*} [topological_space M\u2083] [add_comm_monoid M\u2083]\n{M\u2084 : Type*} [topological_space M\u2084] [add_comm_monoid M\u2084]\n[module R\u2081 M\u2081] [module R\u2082 M\u2082] [module R\u2083 M\u2083]\n\n/-- Coerce continuous linear maps to linear maps. -/\ninstance : has_coe (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) := \u27e8to_linear_map\u27e9\n\n-- make the coercion the preferred form\n@[simp] lemma to_linear_map_eq_coe (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : 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\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (\u03bb _, M\u2081 \u2192 M\u2082) := \u27e8\u03bb f, f\u27e9\n\n@[simp] lemma coe_mk (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) (h) : (mk f h : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) = f := rfl\n@[simp] lemma coe_mk' (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) (h) : (mk f h : M\u2081 \u2192 M\u2082) = f := rfl\n\n@[continuity]\nprotected lemma continuous (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : continuous f := f.2\n\ntheorem coe_injective : function.injective (coe : (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) \u2192 (M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082)) :=\nby { intros f g H, cases f, cases g, congr' }\n\n@[simp, norm_cast] lemma coe_inj {f g : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082} :\n  (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) = g \u2194 f = g :=\ncoe_injective.eq_iff\n\ntheorem coe_fn_injective : @function.injective (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (M\u2081 \u2192 M\u2082) 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\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192 M\u2082 := h\n\n/-- See Note [custom simps projection]. -/\ndef simps.coe (h : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082 := h\n\ninitialize_simps_projections continuous_linear_map\n  (to_linear_map_to_fun \u2192 apply, to_linear_map \u2192 coe)\n\n@[ext] theorem ext {f g : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082} (h : \u2200 x, f x = g x) : f = g :=\ncoe_fn_injective $ funext h\n\ntheorem ext_iff {f g : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082} : f = g \u2194 \u2200 x, f x = g x :=\n\u27e8\u03bb h x, by rw h, by ext\u27e9\n\nvariables (f g : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (c : R\u2081) (h : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083) (x y z : M\u2081)\n\n-- make some straightforward lemmas available to `simp`.\n@[simp] lemma map_zero : f (0 : M\u2081) = 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\u209b\u2097 : f (c \u2022 x) = (\u03c3\u2081\u2082 c) \u2022 f x := (to_linear_map _).map_smul\u209b\u2097 _ _\n\n@[simp] lemma map_smul [module R\u2081 M\u2082] (f : M\u2081 \u2192L[R\u2081] M\u2082)(c : R\u2081) (x : M\u2081) : f (c \u2022 x) = c \u2022 f x :=\nby simp only [ring_hom.id_apply, map_smul\u209b\u2097]\n\n@[simp, priority 900]\nlemma map_smul_of_tower {R S : Type*} [semiring S] [has_scalar R M\u2081]\n  [module S M\u2081] [has_scalar R M\u2082] [module S M\u2082]\n  [linear_map.compatible_smul M\u2081 M\u2082 R S] (f : M\u2081 \u2192L[S] M\u2082) (c : R) (x : M\u2081) :\n  f (c \u2022 x) = c \u2022 f x :=\nlinear_map.compatible_smul.map_smul f c x\n\nlemma map_sum {\u03b9 : Type*} (s : finset \u03b9) (g : \u03b9 \u2192 M\u2081) :\n  f (\u2211 i in s, g i) = \u2211 i in s, f (g i) := f.to_linear_map.map_sum\n\n@[simp, norm_cast] lemma coe_coe : ((f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) : (M\u2081 \u2192 M\u2082)) = (f : M\u2081 \u2192 M\u2082) := rfl\n\n@[ext] theorem ext_ring [topological_space R\u2081] {f g : R\u2081 \u2192L[R\u2081] M\u2081} (h : f 1 = g 1) : f = g :=\ncoe_inj.1 $ linear_map.ext_ring h\n\ntheorem ext_ring_iff [topological_space R\u2081] {f g : R\u2081 \u2192L[R\u2081] M\u2081} : f = g \u2194 f 1 = g 1 :=\n\u27e8\u03bb h, h \u25b8 rfl, ext_ring\u27e9\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\u2082] {s : set M\u2081} {f g : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082} (h : set.eq_on f g s) :\n  set.eq_on f g (closure (submodule.span R\u2081 s : set M\u2081)) :=\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\u2082] {s : set M\u2081} (hs : dense (submodule.span R\u2081 s : set M\u2081))\n  {f g : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082} (h : set.eq_on f g s) :\n  f = g :=\next $ \u03bb 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 \u03c3\u2081\u2082] [topological_space R\u2081]\n  [topological_space R\u2082] [has_continuous_smul R\u2081 M\u2081] [has_continuous_add M\u2081]\n  [has_continuous_smul R\u2082 M\u2082] [has_continuous_add M\u2082] (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (s : submodule R\u2081 M\u2081) :\n  (s.topological_closure.map (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082))\n  \u2264 (s.map (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082)).topological_closure :=\nimage_closure_subset_closure_image f.continuous\n\n/-- Under a dense continuous linear map, a submodule whose `topological_closure` is `\u22a4` 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 \u03c3\u2081\u2082]\n  [topological_space R\u2081] [topological_space R\u2082] [has_continuous_smul R\u2081 M\u2081] [has_continuous_add M\u2081]\n  [has_continuous_smul R\u2082 M\u2082] [has_continuous_add M\u2082] {f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082} (hf' : dense_range f)\n  {s : submodule R\u2081 M\u2081} (hs : s.topological_closure = \u22a4) :\n  (s.map (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082)).topological_closure = \u22a4 :=\nbegin\n  rw set_like.ext'_iff at hs \u22a2,\n  simp only [submodule.topological_closure_coe, submodule.top_coe, \u2190 dense_iff_closure_eq] at hs \u22a2,\n  exact hf'.dense_image f.continuous hs\nend\n\n/-- The continuous map that is constantly zero. -/\ninstance: has_zero (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) := \u27e8\u27e80, continuous_zero\u27e9\u27e9\ninstance : inhabited (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) := \u27e80\u27e9\n\n@[simp] lemma default_def : default (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) = 0 := rfl\n@[simp] lemma zero_apply : (0 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) x = 0 := rfl\n@[simp, norm_cast] lemma coe_zero : ((0 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) = 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\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192 M\u2082) = 0 := rfl\n\ninstance unique_of_left [subsingleton M\u2081] : unique (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :=\ncoe_injective.unique\n\ninstance unique_of_right [subsingleton M\u2082] : unique (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :=\ncoe_injective.unique\n\nsection\n\nvariables (R\u2081 M\u2081)\n\n/-- the identity map as a continuous linear map. -/\ndef id : M\u2081 \u2192L[R\u2081] M\u2081 :=\n\u27e8linear_map.id, continuous_id\u27e9\n\nend\n\ninstance : has_one (M\u2081 \u2192L[R\u2081] M\u2081) := \u27e8id R\u2081 M\u2081\u27e9\n\nlemma one_def : (1 : M\u2081 \u2192L[R\u2081] M\u2081) = id R\u2081 M\u2081 := rfl\nlemma id_apply : id R\u2081 M\u2081 x = x := rfl\n@[simp, norm_cast] lemma coe_id : (id R\u2081 M\u2081 : M\u2081 \u2192\u2097[R\u2081] M\u2081) = linear_map.id := rfl\n@[simp, norm_cast] lemma coe_id' : (id R\u2081 M\u2081 : M\u2081 \u2192 M\u2081) = _root_.id := rfl\n\n@[simp, norm_cast] lemma coe_eq_id {f : M\u2081 \u2192L[R\u2081] M\u2081} :\n  (f : M\u2081 \u2192\u2097[R\u2081] M\u2081) = linear_map.id \u2194 f = id _ _ :=\nby rw [\u2190 coe_id, coe_inj]\n\n@[simp] lemma one_apply : (1 : M\u2081 \u2192L[R\u2081] M\u2081) x = x := rfl\n\nsection add\nvariables [has_continuous_add M\u2082]\n\ninstance : has_add (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :=\n\u27e8\u03bb f g, \u27e8f + g, f.2.add g.2\u27e9\u27e9\n\nlemma continuous_nsmul (n : \u2115) : continuous (\u03bb (x : M\u2082), n \u2022 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 {\u03b1 : Type*} [topological_space \u03b1] {n : \u2115} {f : \u03b1 \u2192 M\u2082} (hf : continuous f) :\n  continuous (\u03bb (x : \u03b1), n \u2022 (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\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) = f + g := rfl\n@[norm_cast] lemma coe_add' : (((f + g) : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192 M\u2082) = (f : M\u2081 \u2192 M\u2082) + g := rfl\n\ninstance : add_comm_monoid (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :=\n{ zero := (0 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082),\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 := \u03bb n f,\n    { to_fun := \u03bb x, n \u2022 (f x),\n      map_add' := by simp,\n      map_smul' := by simp [smul_comm n] },\n  nsmul_zero' := \u03bb f, by { ext, simp },\n  nsmul_succ' := \u03bb n f, by { ext, simp [nat.succ_eq_one_add, add_smul] } }\n\n@[simp, norm_cast] lemma coe_sum {\u03b9 : Type*} (t : finset \u03b9) (f : \u03b9 \u2192 M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :\n  \u2191(\u2211 d in t, f d) = (\u2211 d in t, f d : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\n(add_monoid_hom.mk (coe : (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) \u2192 (M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082)) rfl (\u03bb _ _, rfl)).map_sum _ _\n\n@[simp, norm_cast] lemma coe_sum' {\u03b9 : Type*} (t : finset \u03b9) (f : \u03b9 \u2192 M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :\n  \u21d1(\u2211 d in t, f d) = \u2211 d in t, f d :=\nby simp only [\u2190 coe_coe, coe_sum, linear_map.coe_fn_sum]\n\nlemma sum_apply {\u03b9 : Type*} (t : finset \u03b9) (f : \u03b9 \u2192 M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (b : M\u2081) :\n  (\u2211 d in t, f d) b = \u2211 d in t, f d b :=\nby simp only [coe_sum', finset.sum_apply]\n\nend add\n\nvariables {\u03c3\u2081\u2083 : R\u2081 \u2192+* R\u2083} [ring_hom_comp_triple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083]\n\n/-- Composition of bounded linear maps. -/\ndef comp (g : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083) (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192SL[\u03c3\u2081\u2083] M\u2083 :=\n\u27e8(g : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083).comp \u2191f, g.2.comp f.2\u27e9\n\ninfixr ` \u2218L `: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\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2083] M\u2083)) = (h : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083).comp (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) := rfl\n\ninclude \u03c3\u2081\u2083\n@[simp, norm_cast] lemma coe_comp' : ((h.comp f) : (M\u2081 \u2192 M\u2083)) = (h : M\u2082 \u2192 M\u2083) \u2218 f := rfl\n\nlemma comp_apply (g : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083) (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (x : M\u2081) : (g.comp f) x = g (f x) := rfl\nomit \u03c3\u2081\u2083\n\n@[simp] theorem comp_id : f.comp (id R\u2081 M\u2081) = f :=\next $ \u03bb x, rfl\n\n@[simp] theorem id_comp : (id R\u2082 M\u2082).comp f = f :=\next $ \u03bb x, rfl\n\ninclude \u03c3\u2081\u2083\n@[simp] theorem comp_zero (g : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083) : g.comp (0 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) = 0 :=\nby { ext, simp }\n\n@[simp] theorem zero_comp : (0 : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083).comp f = 0 :=\nby { ext, simp }\n\n@[simp] lemma comp_add [has_continuous_add M\u2082] [has_continuous_add M\u2083]\n  (g : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083) (f\u2081 f\u2082 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :\n  g.comp (f\u2081 + f\u2082) = g.comp f\u2081 + g.comp f\u2082 :=\nby { ext, simp }\n\n@[simp] lemma add_comp [has_continuous_add M\u2083]\n  (g\u2081 g\u2082 : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083) (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :\n  (g\u2081 + g\u2082).comp f = g\u2081.comp f + g\u2082.comp f :=\nby { ext, simp }\nomit \u03c3\u2081\u2083\n\ntheorem comp_assoc {R\u2084 : Type*} [semiring R\u2084] [module R\u2084 M\u2084] {\u03c3\u2081\u2084 : R\u2081 \u2192+* R\u2084} {\u03c3\u2082\u2084 : R\u2082 \u2192+* R\u2084}\n  {\u03c3\u2083\u2084 : R\u2083 \u2192+* R\u2084} [ring_hom_comp_triple \u03c3\u2081\u2083 \u03c3\u2083\u2084 \u03c3\u2081\u2084] [ring_hom_comp_triple \u03c3\u2082\u2083 \u03c3\u2083\u2084 \u03c3\u2082\u2084]\n  [ring_hom_comp_triple \u03c3\u2081\u2082 \u03c3\u2082\u2084 \u03c3\u2081\u2084] (h : M\u2083 \u2192SL[\u03c3\u2083\u2084] M\u2084) (g : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083)\n  (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) :\n  (h.comp g).comp f = h.comp (g.comp f) :=\nrfl\n\ninstance : has_mul (M\u2081 \u2192L[R\u2081] M\u2081) := \u27e8comp\u27e9\n\nlemma mul_def (f g : M\u2081 \u2192L[R\u2081] M\u2081) : f * g = f.comp g := rfl\n\n@[simp] lemma coe_mul (f g : M\u2081 \u2192L[R\u2081] M\u2081) : \u21d1(f * g) = f \u2218 g := rfl\n\nlemma mul_apply (f g : M\u2081 \u2192L[R\u2081] M\u2081) (x : M\u2081) : (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\u2081 M\u2082] [module R\u2081 M\u2083] (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2082) (f\u2082 : M\u2081 \u2192L[R\u2081] M\u2083) :\n  M\u2081 \u2192L[R\u2081] (M\u2082 \u00d7 M\u2083) :=\n\u27e8(f\u2081 : M\u2081 \u2192\u2097[R\u2081] M\u2082).prod f\u2082, f\u2081.2.prod_mk f\u2082.2\u27e9\n\n@[simp, norm_cast] lemma coe_prod [module R\u2081 M\u2082] [module R\u2081 M\u2083] (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2082)\n  (f\u2082 : M\u2081 \u2192L[R\u2081] M\u2083) :\n  (f\u2081.prod f\u2082 : M\u2081 \u2192\u2097[R\u2081] M\u2082 \u00d7 M\u2083) = linear_map.prod f\u2081 f\u2082 :=\nrfl\n\n@[simp, norm_cast] lemma prod_apply [module R\u2081 M\u2082] [module R\u2081 M\u2083] (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2082)\n  (f\u2082 : M\u2081 \u2192L[R\u2081] M\u2083) (x : M\u2081) :\n  f\u2081.prod f\u2082 x = (f\u2081 x, f\u2082 x) :=\nrfl\n\nsection\n\nvariables (R\u2081 M\u2081 M\u2082)\n\n/-- The left injection into a product is a continuous linear map. -/\ndef inl [module R\u2081 M\u2082] : M\u2081 \u2192L[R\u2081] M\u2081 \u00d7 M\u2082 := (id R\u2081 M\u2081).prod 0\n\n/-- The right injection into a product is a continuous linear map. -/\ndef inr [module R\u2081 M\u2082] : M\u2082 \u2192L[R\u2081] M\u2081 \u00d7 M\u2082 := (0 : M\u2082 \u2192L[R\u2081] M\u2081).prod (id R\u2081 M\u2082)\n\nend\n\n@[simp] lemma inl_apply [module R\u2081 M\u2082] (x : M\u2081) : inl R\u2081 M\u2081 M\u2082 x = (x, 0) := rfl\n@[simp] lemma inr_apply [module R\u2081 M\u2082] (x : M\u2082) : inr R\u2081 M\u2081 M\u2082 x = (0, x) := rfl\n\n@[simp, norm_cast] lemma coe_inl [module R\u2081 M\u2082] :\n  (inl R\u2081 M\u2081 M\u2082 : M\u2081 \u2192\u2097[R\u2081] M\u2081 \u00d7 M\u2082) = linear_map.inl R\u2081 M\u2081 M\u2082 := rfl\n@[simp, norm_cast] lemma coe_inr [module R\u2081 M\u2082] :\n  (inr R\u2081 M\u2081 M\u2082 : M\u2082 \u2192\u2097[R\u2081] M\u2081 \u00d7 M\u2082) = linear_map.inr R\u2081 M\u2081 M\u2082 := rfl\n\n/-- Kernel of a continuous linear map. -/\ndef ker (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : submodule R\u2081 M\u2081 := (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082).ker\n\n@[norm_cast] lemma ker_coe : (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082).ker = f.ker := rfl\n\n@[simp] lemma mem_ker {f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082} {x} : x \u2208 f.ker \u2194 f x = 0 := linear_map.mem_ker\n\nlemma is_closed_ker [t1_space M\u2082] : is_closed (f.ker : set M\u2081) :=\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\u2081 M'] [t1_space M\u2082] (f : M' \u2192SL[\u03c3\u2081\u2082] M\u2082) :\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\u2081 M'] [t1_space M\u2082] (f : M' \u2192SL[\u03c3\u2081\u2082] M\u2082) :\n  complete_space f.ker :=\nf.is_closed_ker.complete_space_coe\n\n@[simp] lemma ker_prod [module R\u2081 M\u2082] [module R\u2081 M\u2083] (f : M\u2081 \u2192L[R\u2081] M\u2082) (g : M\u2081 \u2192L[R\u2081] M\u2083) :\n  ker (f.prod g) = ker f \u2293 ker g :=\nlinear_map.ker_prod f g\n\n/-- Range of a continuous linear map. -/\ndef range [ring_hom_surjective \u03c3\u2081\u2082] (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : submodule R\u2082 M\u2082 :=\n(f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082).range\n\nlemma range_coe [ring_hom_surjective \u03c3\u2081\u2082] : (f.range : set M\u2082) = set.range f :=\nlinear_map.range_coe _\nlemma mem_range [ring_hom_surjective \u03c3\u2081\u2082] {f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082} {y} : y \u2208 f.range \u2194 \u2203 x, f x = y :=\nlinear_map.mem_range\n\nlemma mem_range_self [ring_hom_surjective \u03c3\u2081\u2082] (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (x : M\u2081) : f x \u2208 f.range :=\nmem_range.2 \u27e8x, rfl\u27e9\n\nlemma range_prod_le [module R\u2081 M\u2082] [module R\u2081 M\u2083] (f : M\u2081 \u2192L[R\u2081] M\u2082) (g : M\u2081 \u2192L[R\u2081] M\u2083) :\n  range (f.prod g) \u2264 (range f).prod (range g) :=\n(f : M\u2081 \u2192\u2097[R\u2081] M\u2082).range_prod_le g\n\n/-- Restrict codomain of a continuous linear map. -/\ndef cod_restrict (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (p : submodule R\u2082 M\u2082) (h : \u2200 x, f x \u2208 p) :\n  M\u2081 \u2192SL[\u03c3\u2081\u2082] p :=\n{ cont := continuous_subtype_mk h f.continuous,\n  to_linear_map := (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082).cod_restrict p h}\n\n@[norm_cast] lemma coe_cod_restrict (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (p : submodule R\u2082 M\u2082) (h : \u2200 x, f x \u2208 p) :\n  (f.cod_restrict p h : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] p) = (f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082).cod_restrict p h :=\nrfl\n\n@[simp] lemma coe_cod_restrict_apply (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (p : submodule R\u2082 M\u2082) (h : \u2200 x, f x \u2208 p)\n  (x) :\n  (f.cod_restrict p h x : M\u2082) = f x :=\nrfl\n\n@[simp] lemma ker_cod_restrict (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (p : submodule R\u2082 M\u2082) (h : \u2200 x, f x \u2208 p) :\n  ker (f.cod_restrict p h) = ker f :=\n(f : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082).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\u2081 M\u2081) : p \u2192L[R\u2081] M\u2081 :=\n{ cont := continuous_subtype_val,\n  to_linear_map := p.subtype }\n\n@[simp, norm_cast] lemma coe_subtype_val (p : submodule R\u2081 M\u2081) :\n  (subtype_val p : p \u2192\u2097[R\u2081] M\u2081) = p.subtype :=\nrfl\n\n@[simp, norm_cast] lemma subtype_val_apply (p : submodule R\u2081 M\u2081) (x : p) :\n  (subtype_val p : p \u2192 M\u2081) x = x :=\nrfl\n\nvariables (R\u2081 M\u2081 M\u2082)\n\n/-- `prod.fst` as a `continuous_linear_map`. -/\ndef fst [module R\u2081 M\u2082] : M\u2081 \u00d7 M\u2082 \u2192L[R\u2081] M\u2081 :=\n{ cont := continuous_fst, to_linear_map := linear_map.fst R\u2081 M\u2081 M\u2082 }\n\n/-- `prod.snd` as a `continuous_linear_map`. -/\ndef snd [module R\u2081 M\u2082] : M\u2081 \u00d7 M\u2082 \u2192L[R\u2081] M\u2082 :=\n{ cont := continuous_snd, to_linear_map := linear_map.snd R\u2081 M\u2081 M\u2082 }\n\nvariables {R\u2081 M\u2081 M\u2082}\n\n@[simp, norm_cast] lemma coe_fst [module R\u2081 M\u2082] :\n  (fst R\u2081 M\u2081 M\u2082 : M\u2081 \u00d7 M\u2082 \u2192\u2097[R\u2081] M\u2081) = linear_map.fst R\u2081 M\u2081 M\u2082 := rfl\n\n@[simp, norm_cast] lemma coe_fst' [module R\u2081 M\u2082] : (fst R\u2081 M\u2081 M\u2082 : M\u2081 \u00d7 M\u2082 \u2192 M\u2081) = prod.fst := rfl\n\n@[simp, norm_cast] lemma coe_snd [module R\u2081 M\u2082] :\n  (snd R\u2081 M\u2081 M\u2082 : M\u2081 \u00d7 M\u2082 \u2192\u2097[R\u2081] M\u2082) = linear_map.snd R\u2081 M\u2081 M\u2082 := rfl\n\n@[simp, norm_cast] lemma coe_snd' [module R\u2081 M\u2082] : (snd R\u2081 M\u2081 M\u2082 : M\u2081 \u00d7 M\u2082 \u2192 M\u2082) = prod.snd := rfl\n\n@[simp] lemma fst_prod_snd [module R\u2081 M\u2082] : (fst R\u2081 M\u2081 M\u2082).prod (snd R\u2081 M\u2081 M\u2082) = id R\u2081 (M\u2081 \u00d7 M\u2082) :=\n  ext $ \u03bb \u27e8x, y\u27e9, rfl\n\n@[simp] lemma fst_comp_prod [module R\u2081 M\u2082] [module R\u2081 M\u2083] (f : M\u2081 \u2192L[R\u2081] M\u2082) (g : M\u2081 \u2192L[R\u2081] M\u2083) :\n  (fst R\u2081 M\u2082 M\u2083).comp (f.prod g) = f :=\next $ \u03bb x, rfl\n\n@[simp] lemma snd_comp_prod [module R\u2081 M\u2082] [module R\u2081 M\u2083] (f : M\u2081 \u2192L[R\u2081] M\u2082) (g : M\u2081 \u2192L[R\u2081] M\u2083) :\n  (snd R\u2081 M\u2082 M\u2083).comp (f.prod g) = g :=\next $ \u03bb x, rfl\n\n/-- `prod.map` of two continuous linear maps. -/\ndef prod_map [module R\u2081 M\u2082] [module R\u2081 M\u2083] [module R\u2081 M\u2084] (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2082) (f\u2082 : M\u2083 \u2192L[R\u2081] M\u2084) :\n  (M\u2081 \u00d7 M\u2083) \u2192L[R\u2081] (M\u2082 \u00d7 M\u2084) :=\n(f\u2081.comp (fst R\u2081 M\u2081 M\u2083)).prod (f\u2082.comp (snd R\u2081 M\u2081 M\u2083))\n\n@[simp, norm_cast] lemma coe_prod_map [module R\u2081 M\u2082] [module R\u2081 M\u2083] [module R\u2081 M\u2084]\n  (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2082) (f\u2082 : M\u2083 \u2192L[R\u2081] M\u2084) :\n  (f\u2081.prod_map f\u2082 : (M\u2081 \u00d7 M\u2083) \u2192\u2097[R\u2081] (M\u2082 \u00d7 M\u2084))\n  = ((f\u2081 : M\u2081 \u2192\u2097[R\u2081] M\u2082).prod_map (f\u2082 : M\u2083 \u2192\u2097[R\u2081] M\u2084)) :=\nrfl\n\n@[simp, norm_cast] lemma coe_prod_map' [module R\u2081 M\u2082] [module R\u2081 M\u2083] [module R\u2081 M\u2084]\n  (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2082) (f\u2082 : M\u2083 \u2192L[R\u2081] M\u2084) :\n  \u21d1(f\u2081.prod_map f\u2082) = prod.map f\u2081 f\u2082 :=\nrfl\n\n/-- The continuous linear map given by `(x, y) \u21a6 f\u2081 x + f\u2082 y`. -/\ndef coprod [module R\u2081 M\u2082] [module R\u2081 M\u2083] [has_continuous_add M\u2083] (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2083)\n  (f\u2082 : M\u2082 \u2192L[R\u2081] M\u2083) :\n  (M\u2081 \u00d7 M\u2082) \u2192L[R\u2081] M\u2083 :=\n\u27e8linear_map.coprod f\u2081 f\u2082, (f\u2081.cont.comp continuous_fst).add (f\u2082.cont.comp continuous_snd)\u27e9\n\n@[norm_cast, simp] lemma coe_coprod [module R\u2081 M\u2082] [module R\u2081 M\u2083] [has_continuous_add M\u2083]\n  (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2083) (f\u2082 : M\u2082 \u2192L[R\u2081] M\u2083) :\n  (f\u2081.coprod f\u2082 : (M\u2081 \u00d7 M\u2082) \u2192\u2097[R\u2081] M\u2083) = linear_map.coprod f\u2081 f\u2082 :=\nrfl\n\n@[simp] lemma coprod_apply [module R\u2081 M\u2082] [module R\u2081 M\u2083] [has_continuous_add M\u2083]\n  (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2083) (f\u2082 : M\u2082 \u2192L[R\u2081] M\u2083) (x) :\n  f\u2081.coprod f\u2082 x = f\u2081 x.1 + f\u2082 x.2 := rfl\n\nlemma range_coprod [module R\u2081 M\u2082] [module R\u2081 M\u2083] [has_continuous_add M\u2083] (f\u2081 : M\u2081 \u2192L[R\u2081] M\u2083)\n  (f\u2082 : M\u2082 \u2192L[R\u2081] M\u2083) :\n  (f\u2081.coprod f\u2082).range = f\u2081.range \u2294 f\u2082.range :=\nlinear_map.range_coprod _ _\n\nsection\n\nvariables {R S : Type*} [semiring R] [semiring S] [module R M\u2081] [module R M\u2082] [module R S]\n  [module S M\u2082] [is_scalar_tower R S M\u2082] [topological_space S] [has_continuous_smul S M\u2082]\n\n/-- The linear map `\u03bb x, c x \u2022 f`.  Associates to a scalar-valued linear map and an element of\n`M\u2082` the `M\u2082`-valued linear map obtained by multiplying the two (a.k.a. tensoring by `M\u2082`).\nSee also `continuous_linear_map.smul_right\u2097` and `continuous_linear_map.smul_rightL`. -/\ndef smul_right (c : M\u2081 \u2192L[R] S) (f : M\u2082) : M\u2081 \u2192L[R] M\u2082 :=\n{ cont := c.2.smul continuous_const,\n  ..c.to_linear_map.smul_right f }\n\n@[simp]\nlemma smul_right_apply {c : M\u2081 \u2192L[R] S} {f : M\u2082} {x : M\u2081} :\n  (smul_right c f : M\u2081 \u2192 M\u2082) x = c x \u2022 f :=\nrfl\n\nend\n\nvariables [module R\u2081 M\u2082] [topological_space R\u2081] [has_continuous_smul R\u2081 M\u2082]\n\n@[simp]\nlemma smul_right_one_one (c : R\u2081 \u2192L[R\u2081] M\u2082) : smul_right (1 : R\u2081 \u2192L[R\u2081] R\u2081) (c 1) = c :=\nby ext; simp [\u2190 continuous_linear_map.map_smul_of_tower]\n\n@[simp]\nlemma smul_right_one_eq_iff {f f' : M\u2082} :\n  smul_right (1 : R\u2081 \u2192L[R\u2081] R\u2081) f = smul_right (1 : R\u2081 \u2192L[R\u2081] R\u2081) f' \u2194 f = f' :=\nby simp only [ext_ring_iff, smul_right_apply, one_apply, one_smul]\n\nlemma smul_right_comp [has_continuous_mul R\u2081] {x : M\u2082} {c : R\u2081} :\n  (smul_right (1 : R\u2081 \u2192L[R\u2081] R\u2081) x).comp (smul_right (1 : R\u2081 \u2192L[R\u2081] R\u2081) c) =\n    smul_right (1 : R\u2081 \u2192L[R\u2081] R\u2081) (c \u2022 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\u2082 : Type*} [topological_space M\u2082] [add_comm_monoid M\u2082] [module R M\u2082]\n  {\u03b9 : Type*} {\u03c6 : \u03b9 \u2192 Type*} [\u2200i, topological_space (\u03c6 i)] [\u2200i, add_comm_monoid (\u03c6 i)]\n  [\u2200i, module R (\u03c6 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 : \u03a0i, M \u2192L[R] \u03c6 i) : M \u2192L[R] (\u03a0i, \u03c6 i) :=\n\u27e8linear_map.pi (\u03bb i, f i), continuous_pi (\u03bb i, (f i).continuous)\u27e9\n\n@[simp] lemma coe_pi' (f : \u03a0 i, M \u2192L[R] \u03c6 i) : \u21d1(pi f) = \u03bb c i, f i c := rfl\n@[simp] lemma coe_pi (f : \u03a0 i, M \u2192L[R] \u03c6 i) :\n  (pi f : M \u2192\u2097[R] \u03a0 i, \u03c6 i) = linear_map.pi (\u03bb i, f i) :=\nrfl\n\nlemma pi_apply (f : \u03a0i, M \u2192L[R] \u03c6 i) (c : M) (i : \u03b9) :\n  pi f c i = f i c := rfl\n\nlemma pi_eq_zero (f : \u03a0i, M \u2192L[R] \u03c6 i) : pi f = 0 \u2194 (\u2200i, f i = 0) :=\nby { simp only [ext_iff, pi_apply, function.funext_iff], exact forall_swap }\n\nlemma pi_zero : pi (\u03bbi, 0 : \u03a0i, M \u2192L[R] \u03c6 i) = 0 := ext $ \u03bb _, rfl\n\nlemma pi_comp (f : \u03a0i, M \u2192L[R] \u03c6 i) (g : M\u2082 \u2192L[R] M) : (pi f).comp g = pi (\u03bbi, (f i).comp g) := rfl\n\n/-- The projections from a family of topological modules are continuous linear maps. -/\ndef proj (i : \u03b9) : (\u03a0i, \u03c6 i) \u2192L[R] \u03c6 i :=\n\u27e8linear_map.proj i, continuous_apply _\u27e9\n\n@[simp] lemma proj_apply (i : \u03b9) (b : \u03a0i, \u03c6 i) : (proj i : (\u03a0i, \u03c6 i) \u2192L[R] \u03c6 i) b = b i := rfl\n\nlemma proj_pi (f : \u03a0i, M\u2082 \u2192L[R] \u03c6 i) (i : \u03b9) : (proj i).comp (pi f) = f i :=\next $ assume c, rfl\n\nlemma infi_ker_proj : (\u2a05i, ker (proj i) : submodule R (\u03a0i, \u03c6 i)) = \u22a5 :=\nlinear_map.infi_ker_proj\n\nvariables (R \u03c6)\n\n/-- If `I` and `J` are complementary index sets, the product of the kernels of the `J`th projections\nof `\u03c6` is linearly equivalent to the product over `I`. -/\ndef infi_ker_proj_equiv {I J : set \u03b9} [decidable_pred (\u03bbi, i \u2208 I)]\n  (hd : disjoint I J) (hu : set.univ \u2286 I \u222a J) :\n  (\u2a05i \u2208 J, ker (proj i) : submodule R (\u03a0i, \u03c6 i)) \u2243L[R] (\u03a0i:I, \u03c6 i) :=\n\u27e8 linear_map.infi_ker_proj_equiv R \u03c6 hd hu,\n  continuous_pi (\u03bb i, begin\n    have := @continuous_subtype_coe _ _ (\u03bb x, x \u2208 (\u2a05i \u2208 J, ker (proj i) : submodule R (\u03a0i, \u03c6 i))),\n    have := continuous.comp (by exact continuous_apply i) this,\n    exact this\n  end),\n  continuous_subtype_mk _ (continuous_pi (\u03bb i, begin\n    dsimp, split_ifs; [apply continuous_apply, exact continuous_zero]\n  end)) \u27e9\n\nend pi\n\nsection ring\n\nvariables\n{R : Type*} [ring R] {R\u2082 : Type*} [ring R\u2082]\n{M : Type*} [topological_space M] [add_comm_group M]\n{M\u2082 : Type*} [topological_space M\u2082] [add_comm_group M\u2082]\n{M\u2083 : Type*} [topological_space M\u2083] [add_comm_group M\u2083]\n{M\u2084 : Type*} [topological_space M\u2084] [add_comm_group M\u2084]\n[module R M] [module R\u2082 M\u2082]\n{\u03c3\u2081\u2082 : R \u2192+* R\u2082}\n\nsection\nvariables (f g : M \u2192SL[\u03c3\u2081\u2082] M\u2082) (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 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) - g) x = f x - g x := rfl\nend\n\nsection\nvariables [module R M\u2082] [module R M\u2083] [module R M\u2084]\nvariables (c : R) (f g : M \u2192L[R] M\u2082) (h : M\u2082 \u2192L[R] M\u2083) (x y z : M)\n\nlemma range_prod_eq  {f : M \u2192L[R] M\u2082} {g : M \u2192L[R] M\u2083} (h : ker f \u2294 ker g = \u22a4) :\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\u2083]\n  (f : M \u2192L[R] M\u2083) (g : M\u2082 \u2192L[R] M\u2083) :\n  (ker f).prod (ker g) \u2264 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\u2083]\n  (f : M \u2192L[R] M\u2083) (g : M\u2082 \u2192L[R] M\u2083) (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\u2082]\nvariables (f g : M \u2192SL[\u03c3\u2081\u2082] M\u2082) (x y : M)\n\ninstance : has_neg (M \u2192SL[\u03c3\u2081\u2082] M\u2082) := \u27e8\u03bb f, \u27e8-f, f.2.neg\u27e9\u27e9\n\n@[simp] lemma neg_apply : (-f) x = - (f x) := rfl\n\n@[simp, norm_cast] lemma coe_neg :\n  (((-f) : M \u2192SL[\u03c3\u2081\u2082] M\u2082) : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) = -(f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\nrfl\n@[norm_cast] lemma coe_neg' : (((-f) : M \u2192SL[\u03c3\u2081\u2082] M\u2082) : M \u2192 M\u2082) = -(f : M \u2192 M\u2082) := rfl\n\ninstance : has_sub (M \u2192SL[\u03c3\u2081\u2082] M\u2082) := \u27e8\u03bb f g, \u27e8f - g, f.2.sub g.2\u27e9\u27e9\n\nlemma continuous_zsmul : \u2200 (n : \u2124), continuous (\u03bb (x : M\u2082), n \u2022 x)\n| (n : \u2115) := 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 {\u03b1 : Type*} [topological_space \u03b1] {n : \u2124} {f : \u03b1 \u2192 M\u2082} (hf : continuous f) :\n  continuous (\u03bb (x : \u03b1), n \u2022 (f x)) :=\n(continuous_zsmul n).comp hf\n\ninstance : add_comm_group (M \u2192SL[\u03c3\u2081\u2082] M\u2082) :=\nby refine\n{ zero := 0,\n  add := (+),\n  neg := has_neg.neg,\n  sub := has_sub.sub,\n  sub_eq_add_neg := _,\n  nsmul := \u03bb n f,\n    { to_fun := \u03bb x, n \u2022 (f x),\n      map_add' := by simp,\n      map_smul' := by simp [smul_comm n] },\n  zsmul := \u03bb n f,\n    { to_fun := \u03bb x, n \u2022 (f x),\n      map_add' := by simp,\n      map_smul' := by simp [smul_comm n] },\n  zsmul_zero' := \u03bb f, by { ext, simp },\n  zsmul_succ' := \u03bb n f, by { ext, simp [add_smul, add_comm] },\n  zsmul_neg' := \u03bb 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 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) = f - g := rfl\n@[simp, norm_cast] lemma coe_sub' : (((f - g) : M \u2192SL[\u03c3\u2081\u2082] M\u2082) : M \u2192 M\u2082) = (f : M \u2192 M\u2082) - g := rfl\n\nend\n\ninstance [topological_add_group M] : ring (M \u2192L[R] M) :=\n{ mul := (*),\n  one := 1,\n  mul_one := \u03bb _, ext $ \u03bb _, rfl,\n  one_mul := \u03bb _, ext $ \u03bb _, rfl,\n  mul_assoc := \u03bb _ _ _, ext $ \u03bb _, rfl,\n  left_distrib := \u03bb _ _ _, ext $ \u03bb _, map_add _ _ _,\n  right_distrib := \u03bb _ _ _, ext $ \u03bb _, 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 : \u2115) :\n  (smul_right (1 : R \u2192L[R] R) c)^n = smul_right (1 : R \u2192L[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 {\u03c3\u2082\u2081 : R\u2082 \u2192+* R} [ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081]\n\n/-- Given a right inverse `f\u2082 : M\u2082 \u2192L[R] M` to `f\u2081 : M \u2192L[R] M\u2082`,\n`proj_ker_of_right_inverse f\u2081 f\u2082 h` is the projection `M \u2192L[R] f\u2081.ker` along `f\u2082.range`. -/\ndef proj_ker_of_right_inverse [topological_add_group M] (f\u2081 : M \u2192SL[\u03c3\u2081\u2082] M\u2082) (f\u2082 : M\u2082 \u2192SL[\u03c3\u2082\u2081] M)\n  (h : function.right_inverse f\u2082 f\u2081) :\n  M \u2192L[R] f\u2081.ker :=\n(id R M - f\u2082.comp f\u2081).cod_restrict f\u2081.ker $ \u03bb x, by simp [h (f\u2081 x)]\n\n@[simp] lemma coe_proj_ker_of_right_inverse_apply [topological_add_group M]\n  (f\u2081 : M \u2192SL[\u03c3\u2081\u2082] M\u2082) (f\u2082 : M\u2082 \u2192SL[\u03c3\u2082\u2081] M) (h : function.right_inverse f\u2082 f\u2081) (x : M) :\n  (f\u2081.proj_ker_of_right_inverse f\u2082 h x : M) = x - f\u2082 (f\u2081 x) :=\nrfl\n\n@[simp] lemma proj_ker_of_right_inverse_apply_idem [topological_add_group M]\n  (f\u2081 : M \u2192SL[\u03c3\u2081\u2082] M\u2082) (f\u2082 : M\u2082 \u2192SL[\u03c3\u2082\u2081] M) (h : function.right_inverse f\u2082 f\u2081) (x : f\u2081.ker) :\n  f\u2081.proj_ker_of_right_inverse f\u2082 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\u2081 : M \u2192SL[\u03c3\u2081\u2082] M\u2082) (f\u2082 : M\u2082 \u2192SL[\u03c3\u2082\u2081] M) (h : function.right_inverse f\u2082 f\u2081) (y : M\u2082) :\n  f\u2081.proj_ker_of_right_inverse f\u2082 h (f\u2082 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\u2082 : Type*} [topological_space M\u2082] [add_comm_monoid M\u2082] [module R M\u2082]\n  {M\u2083 : Type*} [topological_space M\u2083] [add_comm_monoid M\u2083] [module R M\u2083]\n  [distrib_mul_action S M\u2083] [smul_comm_class R S M\u2083] [has_continuous_smul S M\u2083]\n\ninstance : mul_action S (M \u2192L[R] M\u2083) :=\n{ smul := \u03bb c f, \u27e8c \u2022 f, (continuous_const.smul f.2 : continuous (\u03bb x, c \u2022 f x))\u27e9,\n  one_smul := \u03bb f, ext $ \u03bb x, one_smul _ _,\n  mul_smul := \u03bb a b f, ext $ \u03bb x, mul_smul _ _ _ }\n\nvariables (c : S) (h : M\u2082 \u2192L[R] M\u2083) (f g : M \u2192L[R] M\u2082) (x y z : M)\n\n@[simp] lemma smul_comp : (c \u2022 h).comp f = c \u2022 (h.comp f) := rfl\n\nvariables [distrib_mul_action S M\u2082] [has_continuous_smul S M\u2082] [smul_comm_class R S M\u2082]\n\nlemma smul_apply : (c \u2022 f) x = c \u2022 (f x) := rfl\n@[simp, norm_cast] lemma coe_smul : (((c \u2022 f) : M \u2192L[R] M\u2082) : M \u2192\u2097[R] M\u2082) = c \u2022 f := rfl\n@[simp, norm_cast] lemma coe_smul' : (((c \u2022 f) : M \u2192L[R] M\u2082) : M \u2192 M\u2082) = c \u2022 f := rfl\n\n@[simp] lemma comp_smul [linear_map.compatible_smul M\u2082 M\u2083 S R] : h.comp (c \u2022 f) = c \u2022 (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\u2082]\n  [has_continuous_smul T M\u2082] [smul_comm_class R T M\u2082] [has_scalar S T]\n  [is_scalar_tower S T M\u2082] : is_scalar_tower S T (M \u2192L[R] M\u2082) :=\n\u27e8\u03bb a b f, ext $ \u03bb x, smul_assoc a b (f x)\u27e9\n\ninstance {T : Type*} [monoid T] [topological_space T] [distrib_mul_action T M\u2082]\n  [has_continuous_smul T M\u2082] [smul_comm_class R T M\u2082] [smul_comm_class S T M\u2082] :\n  smul_comm_class S T (M \u2192L[R] M\u2082) :=\n\u27e8\u03bb a b f, ext $ \u03bb x, smul_comm a b (f x)\u27e9\n\ninstance [has_continuous_add M\u2082] : distrib_mul_action S (M \u2192L[R] M\u2082) :=\n{ smul_add := \u03bb a f g, ext $ \u03bb x, smul_add a (f x) (g x),\n  smul_zero := \u03bb a, ext $ \u03bb 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\u2082 : Type*} [topological_space M\u2082] [add_comm_monoid M\u2082] [module R M\u2082]\n  {M\u2083 : Type*} [topological_space M\u2083] [add_comm_monoid M\u2083] [module R M\u2083]\n  [module S M\u2083] [has_continuous_smul S M\u2083] [smul_comm_class R S M\u2083]\n  [module S M\u2082] [has_continuous_smul S M\u2082] [smul_comm_class R S M\u2082]\n  (c : S) (h : M\u2082 \u2192L[R] M\u2083) (f g : M \u2192L[R] M\u2082) (x y z : M)\n\n/-- `continuous_linear_map.prod` as an `equiv`. -/\n@[simps apply] def prod_equiv : ((M \u2192L[R] M\u2082) \u00d7 (M \u2192L[R] M\u2083)) \u2243 (M \u2192L[R] M\u2082 \u00d7 M\u2083) :=\n{ to_fun := \u03bb f, f.1.prod f.2,\n  inv_fun := \u03bb f, \u27e8(fst _ _ _).comp f, (snd _ _ _).comp f\u27e9,\n  left_inv := \u03bb f, by ext; refl,\n  right_inv := \u03bb f, by ext; refl }\n\nlemma prod_ext_iff {f g : M \u00d7 M\u2082 \u2192L[R] M\u2083} :\n  f = g \u2194 f.comp (inl _ _ _) = g.comp (inl _ _ _) \u2227 f.comp (inr _ _ _) = g.comp (inr _ _ _) :=\nby { simp only [\u2190 coe_inj, linear_map.prod_ext_iff], refl }\n\n@[ext] lemma prod_ext {f g : M \u00d7 M\u2082 \u2192L[R] M\u2083} (hl : f.comp (inl _ _ _) = g.comp (inl _ _ _))\n  (hr : f.comp (inr _ _ _) = g.comp (inr _ _ _)) : f = g :=\nprod_ext_iff.2 \u27e8hl, hr\u27e9\n\nvariables [has_continuous_add M\u2082]\n\ninstance : module S (M \u2192L[R] M\u2082) :=\n{ zero_smul := \u03bb _, ext $ \u03bb _, zero_smul _ _,\n  add_smul  := \u03bb _ _ _, ext $ \u03bb _, add_smul _ _ _, }\n\nvariables (S) [has_continuous_add M\u2083]\n\n/-- `continuous_linear_map.prod` as a `linear_equiv`. -/\n@[simps apply] def prod\u2097 : ((M \u2192L[R] M\u2082) \u00d7 (M \u2192L[R] M\u2083)) \u2243\u2097[S] (M \u2192L[R] M\u2082 \u00d7 M\u2083) :=\n{ map_add' := \u03bb f g, rfl,\n  map_smul' := \u03bb c f, rfl,\n  .. prod_equiv }\n\n/-- The coercion from `M \u2192L[R] M\u2082` to `M \u2192\u2097[R] M\u2082`, as a linear map. -/\n@[simps]\ndef coe_lm : (M \u2192L[R] M\u2082) \u2192\u2097[S] (M \u2192\u2097[R] M\u2082) :=\n{ to_fun := coe,\n  map_add' := \u03bb f g, coe_add f g,\n  map_smul' := \u03bb c f, coe_smul c f }\n\nend smul\n\nsection smul_right\u2097\n\nvariables {R S T M M\u2082 : Type*} [ring R] [ring S] [ring T] [module R S]\n  [add_comm_group M\u2082] [module R M\u2082] [module S M\u2082] [is_scalar_tower R S M\u2082]\n  [topological_space S] [topological_space M\u2082] [has_continuous_smul S M\u2082]\n  [topological_space M] [add_comm_group M] [module R M] [topological_add_group M\u2082]\n  [topological_space T] [module T M\u2082] [has_continuous_smul T M\u2082]\n  [smul_comm_class R T M\u2082] [smul_comm_class S T M\u2082]\n\n/-- Given `c : E \u2192L[\ud835\udd5c] \ud835\udd5c`, `c.smul_right\u2097` is the linear map from `F` to `E \u2192L[\ud835\udd5c] F`\nsending `f` to `\u03bb e, c e \u2022 f`. See also `continuous_linear_map.smul_rightL`. -/\ndef smul_right\u2097 (c : M \u2192L[R] S) : M\u2082 \u2192\u2097[T] (M \u2192L[R] M\u2082) :=\n{ to_fun := c.smul_right,\n  map_add' := \u03bb x y, by { ext e, apply smul_add },\n  map_smul' := \u03bb a x, by { ext e, dsimp, apply smul_comm } }\n\n@[simp] lemma coe_smul_right\u2097 (c : M \u2192L[R] S) :\n  \u21d1(smul_right\u2097 c : M\u2082 \u2192\u2097[T] (M \u2192L[R] M\u2082)) = c.smul_right := rfl\n\nend smul_right\u2097\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\u2082 : Type*} [topological_space M\u2082] [add_comm_group M\u2082]\n{M\u2083 : Type*} [topological_space M\u2083] [add_comm_group M\u2083]\n[module R M] [module R M\u2082] [module R M\u2083] [has_continuous_smul R M\u2083]\n\nvariables [topological_add_group M\u2082] [has_continuous_smul R M\u2082]\n\ninstance : algebra R (M\u2082 \u2192L[R] M\u2082) :=\nalgebra.of_module smul_comp (\u03bb _ _ _, comp_smul _ _ _)\n\nend comm_ring\n\nsection restrict_scalars\n\nvariables {A M M\u2082 : Type*} [ring A] [add_comm_group M] [add_comm_group M\u2082]\n  [module A M] [module A M\u2082] [topological_space M] [topological_space M\u2082]\n  (R : Type*) [ring R] [module R M] [module R M\u2082] [linear_map.compatible_smul M M\u2082 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\u2082 R A` to match assumptions of\n`linear_map.map_smul_of_tower`. -/\ndef restrict_scalars (f : M \u2192L[A] M\u2082) : M \u2192L[R] M\u2082 :=\n\u27e8(f : M \u2192\u2097[A] M\u2082).restrict_scalars R, f.continuous\u27e9\n\nvariable {R}\n\n@[simp, norm_cast] lemma coe_restrict_scalars (f : M \u2192L[A] M\u2082) :\n  (f.restrict_scalars R : M \u2192\u2097[R] M\u2082) = (f : M \u2192\u2097[A] M\u2082).restrict_scalars R := rfl\n\n@[simp] lemma coe_restrict_scalars' (f : M \u2192L[A] M\u2082) : \u21d1(f.restrict_scalars R) = f := rfl\n\n@[simp] lemma restrict_scalars_zero : (0 : M \u2192L[A] M\u2082).restrict_scalars R = 0 := rfl\n\nsection\nvariable [topological_add_group M\u2082]\n\n@[simp] lemma restrict_scalars_add (f g : M \u2192L[A] M\u2082) :\n  (f + g).restrict_scalars R = f.restrict_scalars R + g.restrict_scalars R := rfl\n\n@[simp] lemma restrict_scalars_neg (f : M \u2192L[A] M\u2082) :\n  (-f).restrict_scalars R = -f.restrict_scalars R := rfl\nend\n\nvariables {S : Type*} [ring S] [topological_space S] [module S M\u2082] [has_continuous_smul S M\u2082]\n  [smul_comm_class A S M\u2082] [smul_comm_class R S M\u2082]\n\n@[simp] lemma restrict_scalars_smul (c : S) (f : M \u2192L[A] M\u2082) :\n  (c \u2022 f).restrict_scalars R = c \u2022 f.restrict_scalars R := rfl\n\nvariables (A M M\u2082 R S) [topological_add_group M\u2082]\n\n/-- `continuous_linear_map.restrict_scalars` as a `linear_map`. See also\n`continuous_linear_map.restrict_scalarsL`. -/\ndef restrict_scalars\u2097 : (M \u2192L[A] M\u2082) \u2192\u2097[S] (M \u2192L[R] M\u2082) :=\n{ to_fun := restrict_scalars R,\n  map_add' := restrict_scalars_add,\n  map_smul' := restrict_scalars_smul }\n\nvariables {A M M\u2082 R S}\n\n@[simp] lemma coe_restrict_scalars\u2097 : \u21d1(restrict_scalars\u2097 A M M\u2082 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\u2081 : Type*} {R\u2082 : Type*} {R\u2083 : Type*} [semiring R\u2081] [semiring R\u2082] [semiring R\u2083]\n{\u03c3\u2081\u2082 : R\u2081 \u2192+* R\u2082} {\u03c3\u2082\u2081 : R\u2082 \u2192+* R\u2081} [ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081] [ring_hom_inv_pair \u03c3\u2082\u2081 \u03c3\u2081\u2082]\n{\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083} {\u03c3\u2083\u2082 : R\u2083 \u2192+* R\u2082} [ring_hom_inv_pair \u03c3\u2082\u2083 \u03c3\u2083\u2082] [ring_hom_inv_pair \u03c3\u2083\u2082 \u03c3\u2082\u2083]\n{\u03c3\u2081\u2083 : R\u2081 \u2192+* R\u2083} {\u03c3\u2083\u2081 : R\u2083 \u2192+* R\u2081} [ring_hom_inv_pair \u03c3\u2081\u2083 \u03c3\u2083\u2081] [ring_hom_inv_pair \u03c3\u2083\u2081 \u03c3\u2081\u2083]\n[ring_hom_comp_triple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083] [ring_hom_comp_triple \u03c3\u2083\u2082 \u03c3\u2082\u2081 \u03c3\u2083\u2081]\n{M\u2081 : Type*} [topological_space M\u2081] [add_comm_monoid M\u2081]\n{M\u2082 : Type*} [topological_space M\u2082] [add_comm_monoid M\u2082]\n{M\u2083 : Type*} [topological_space M\u2083] [add_comm_monoid M\u2083]\n{M\u2084 : Type*} [topological_space M\u2084] [add_comm_monoid M\u2084]\n[module R\u2081 M\u2081] [module R\u2082 M\u2082] [module R\u2083 M\u2083]\n\ninclude \u03c3\u2082\u2081\n/-- A continuous linear equivalence induces a continuous linear map. -/\ndef to_continuous_linear_map (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082 :=\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\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) := \u27e8to_continuous_linear_map\u27e9\n\n/-- Coerce continuous linear equivs to maps. -/\n-- see Note [function coercion]\ninstance : has_coe_to_fun (M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (\u03bb _, M\u2081 \u2192 M\u2082) := \u27e8\u03bb f, f\u27e9\n\n@[simp] theorem coe_def_rev (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : e.to_continuous_linear_map = e := rfl\n\ntheorem coe_apply (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (b : M\u2081) : (e : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) b = e b := rfl\n\n@[simp] lemma coe_to_linear_equiv (f : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : \u21d1f.to_linear_equiv = f := rfl\n\n@[simp, norm_cast] lemma coe_coe (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : ((e : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192 M\u2082) = e := rfl\n\nlemma to_linear_equiv_injective :\n  function.injective (to_linear_equiv : (M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) \u2192 (M\u2081 \u2243\u209b\u2097[\u03c3\u2081\u2082] M\u2082))\n| \u27e8e, _, _\u27e9 \u27e8e', _, _\u27e9 rfl := rfl\n\n@[ext] lemma ext {f g : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082} (h : (f : M\u2081 \u2192 M\u2082) = g) : f = g :=\nto_linear_equiv_injective $ linear_equiv.ext $ congr_fun h\n\nlemma coe_injective : function.injective (coe : (M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) \u2192 (M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082)) :=\n\u03bb e e' h, ext $ funext $ continuous_linear_map.ext_iff.1 h\n\n@[simp, norm_cast] lemma coe_inj {e e' : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082} : (e : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) = e' \u2194 e = e' :=\ncoe_injective.eq_iff\n\n/-- A continuous linear equivalence induces a homeomorphism. -/\ndef to_homeomorph (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2243\u209c M\u2082 := { to_equiv := e.to_linear_equiv.to_equiv, ..e }\n\n@[simp] lemma coe_to_homeomorph (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : \u21d1e.to_homeomorph = e := rfl\n\nlemma image_closure (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (s : set M\u2081) : e '' closure s = closure (e '' s) :=\ne.to_homeomorph.image_closure s\n\nlemma preimage_closure (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (s : set M\u2082) : e \u207b\u00b9' closure s = closure (e \u207b\u00b9' s) :=\ne.to_homeomorph.preimage_closure s\n\n@[simp] lemma is_closed_image (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {s : set M\u2081} :\n  is_closed (e '' s) \u2194 is_closed s :=\ne.to_homeomorph.is_closed_image\n\nlemma map_nhds_eq (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (x : M\u2081) : map e (\ud835\udcdd x) = \ud835\udcdd (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\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : e (0 : M\u2081) = 0 := (e : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082).map_zero\n@[simp] lemma map_add (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (x y : M\u2081) : e (x + y) = e x + e y :=\n(e : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082).map_add x y\n@[simp] lemma map_smul\u209b\u2097 (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (c : R\u2081) (x : M\u2081) : e (c \u2022 x) = \u03c3\u2081\u2082 c \u2022 (e x) :=\n(e : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082).map_smul\u209b\u2097 c x\nomit \u03c3\u2082\u2081\n\n@[simp] lemma map_smul [module R\u2081 M\u2082] (e : M\u2081 \u2243L[R\u2081] M\u2082) (c : R\u2081) (x : M\u2081) :\n  e (c \u2022 x) = c \u2022 (e x) :=\n(e : M\u2081 \u2192L[R\u2081] M\u2082).map_smul c x\n\ninclude \u03c3\u2082\u2081\n@[simp] lemma map_eq_zero_iff (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {x : M\u2081} : e x = 0 \u2194 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\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : continuous (e : M\u2081 \u2192 M\u2082) :=\ne.continuous_to_fun\n\nprotected lemma continuous_on (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {s : set M\u2081} : continuous_on (e : M\u2081 \u2192 M\u2082) s :=\ne.continuous.continuous_on\n\nprotected lemma continuous_at (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {x : M\u2081} : continuous_at (e : M\u2081 \u2192 M\u2082) x :=\ne.continuous.continuous_at\n\nprotected lemma continuous_within_at (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {s : set M\u2081} {x : M\u2081} :\n  continuous_within_at (e : M\u2081 \u2192 M\u2082) s x :=\ne.continuous.continuous_within_at\n\nlemma comp_continuous_on_iff\n  {\u03b1 : Type*} [topological_space \u03b1] (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {f : \u03b1 \u2192 M\u2081} {s : set \u03b1} :\n  continuous_on (e \u2218 f) s \u2194 continuous_on f s :=\ne.to_homeomorph.comp_continuous_on_iff _ _\n\nlemma comp_continuous_iff\n  {\u03b1 : Type*} [topological_space \u03b1] (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {f : \u03b1 \u2192 M\u2081} :\n  continuous (e \u2218 f) \u2194 continuous f :=\ne.to_homeomorph.comp_continuous_iff\nomit \u03c3\u2082\u2081\n\n/-- An extensionality lemma for `R \u2243L[R] M`. -/\nlemma ext\u2081 [topological_space R\u2081] {f g : R\u2081 \u2243L[R\u2081] M\u2081} (h : f 1 = g 1) : f = g :=\next $ funext $ \u03bb x, mul_one x \u25b8 by rw [\u2190 smul_eq_mul, map_smul, h, map_smul]\n\nsection\nvariables (R\u2081 M\u2081)\n\n/-- The identity map as a continuous linear equivalence. -/\n@[refl] protected def refl : M\u2081 \u2243L[R\u2081] M\u2081 :=\n{ continuous_to_fun := continuous_id,\n  continuous_inv_fun := continuous_id,\n  .. linear_equiv.refl R\u2081 M\u2081 }\nend\n\n@[simp, norm_cast] lemma coe_refl :\n  (continuous_linear_equiv.refl R\u2081 M\u2081 : M\u2081 \u2192L[R\u2081] M\u2081) = continuous_linear_map.id R\u2081 M\u2081 := rfl\n\n@[simp, norm_cast] lemma coe_refl' :\n  (continuous_linear_equiv.refl R\u2081 M\u2081 : M\u2081 \u2192 M\u2081) = id := rfl\n\n/-- The inverse of a continuous linear equivalence as a continuous linear equivalence-/\n@[symm] protected def symm (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : M\u2082 \u2243SL[\u03c3\u2082\u2081] M\u2081 :=\n{ continuous_to_fun := e.continuous_inv_fun,\n  continuous_inv_fun := e.continuous_to_fun,\n  .. e.to_linear_equiv.symm }\n\ninclude \u03c3\u2082\u2081\n@[simp] lemma symm_to_linear_equiv (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) :\n  e.symm.to_linear_equiv = e.to_linear_equiv.symm :=\nby { ext, refl }\n\n@[simp] lemma symm_to_homeomorph (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) :\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\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : M\u2081 \u2192 M\u2082 := h\n\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : M\u2082 \u2192 M\u2081 := h.symm\n\ninitialize_simps_projections continuous_linear_equiv\n  (to_linear_equiv_to_fun \u2192 apply, to_linear_equiv_inv_fun \u2192 symm_apply)\n\nlemma symm_map_nhds_eq (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (x : M\u2081) : map e.symm (\ud835\udcdd (e x)) = \ud835\udcdd x :=\ne.to_homeomorph.symm_map_nhds_eq x\nomit \u03c3\u2082\u2081\n\ninclude \u03c3\u2082\u2081 \u03c3\u2083\u2082 \u03c3\u2083\u2081\n/-- The composition of two continuous linear equivalences as a continuous linear equivalence. -/\n@[trans] protected def trans (e\u2081 : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (e\u2082 : M\u2082 \u2243SL[\u03c3\u2082\u2083] M\u2083) : M\u2081 \u2243SL[\u03c3\u2081\u2083] M\u2083 :=\n{ continuous_to_fun := e\u2082.continuous_to_fun.comp e\u2081.continuous_to_fun,\n  continuous_inv_fun := e\u2081.continuous_inv_fun.comp e\u2082.continuous_inv_fun,\n  .. e\u2081.to_linear_equiv.trans e\u2082.to_linear_equiv }\n\ninclude \u03c3\u2081\u2083\n@[simp] lemma trans_to_linear_equiv (e\u2081 : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (e\u2082 : M\u2082 \u2243SL[\u03c3\u2082\u2083] M\u2083) :\n  (e\u2081.trans e\u2082).to_linear_equiv = e\u2081.to_linear_equiv.trans e\u2082.to_linear_equiv :=\nby { ext, refl }\nomit \u03c3\u2081\u2083 \u03c3\u2082\u2081 \u03c3\u2083\u2082 \u03c3\u2083\u2081\n\n/-- Product of two continuous linear equivalences. The map comes from `equiv.prod_congr`. -/\ndef prod [module R\u2081 M\u2082] [module R\u2081 M\u2083] [module R\u2081 M\u2084] (e : M\u2081 \u2243L[R\u2081] M\u2082) (e' : M\u2083 \u2243L[R\u2081] M\u2084) :\n  (M\u2081 \u00d7 M\u2083) \u2243L[R\u2081] (M\u2082 \u00d7 M\u2084) :=\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\u2081 M\u2082] [module R\u2081 M\u2083] [module R\u2081 M\u2084] (e : M\u2081 \u2243L[R\u2081] M\u2082)\n  (e' : M\u2083 \u2243L[R\u2081] M\u2084) (x) :\n  e.prod e' x = (e x.1, e' x.2) := rfl\n\n@[simp, norm_cast] lemma coe_prod [module R\u2081 M\u2082] [module R\u2081 M\u2083] [module R\u2081 M\u2084] (e : M\u2081 \u2243L[R\u2081] M\u2082)\n  (e' : M\u2083 \u2243L[R\u2081] M\u2084) :\n  (e.prod e' : (M\u2081 \u00d7 M\u2083) \u2192L[R\u2081] (M\u2082 \u00d7 M\u2084)) = (e : M\u2081 \u2192L[R\u2081] M\u2082).prod_map (e' : M\u2083 \u2192L[R\u2081] M\u2084) :=\nrfl\n\ninclude \u03c3\u2082\u2081\ntheorem bijective (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : function.bijective e :=\ne.to_linear_equiv.to_equiv.bijective\ntheorem injective (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : function.injective e :=\ne.to_linear_equiv.to_equiv.injective\ntheorem surjective (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : function.surjective e :=\ne.to_linear_equiv.to_equiv.surjective\n\ninclude \u03c3\u2083\u2082 \u03c3\u2083\u2081 \u03c3\u2081\u2083\n@[simp] theorem trans_apply (e\u2081 : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (e\u2082 : M\u2082 \u2243SL[\u03c3\u2082\u2083] M\u2083) (c : M\u2081) :\n  (e\u2081.trans e\u2082) c = e\u2082 (e\u2081 c) :=\nrfl\nomit \u03c3\u2083\u2082 \u03c3\u2083\u2081 \u03c3\u2081\u2083\n\n@[simp] theorem apply_symm_apply (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (c : M\u2082) : e (e.symm c) = c :=\ne.1.right_inv c\n@[simp] theorem symm_apply_apply (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (b : M\u2081) : e.symm (e b) = b := e.1.left_inv b\n\ninclude \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083 \u03c3\u2083\u2081\n@[simp] theorem symm_trans_apply (e\u2081 : M\u2082 \u2243SL[\u03c3\u2082\u2081] M\u2081) (e\u2082 : M\u2083 \u2243SL[\u03c3\u2083\u2082] M\u2082) (c : M\u2081) :\n  (e\u2082.trans e\u2081).symm c = e\u2082.symm (e\u2081.symm c) :=\nrfl\nomit \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083 \u03c3\u2083\u2081\n\n@[simp] theorem symm_image_image (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (s : set M\u2081) : e.symm '' (e '' s) = s :=\ne.to_linear_equiv.to_equiv.symm_image_image s\n@[simp] theorem image_symm_image (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (s : set M\u2082) : e '' (e.symm '' s) = s :=\ne.symm.symm_image_image s\n\ninclude \u03c3\u2083\u2082 \u03c3\u2083\u2081\n@[simp, norm_cast]\nlemma comp_coe (f : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (f' : M\u2082 \u2243SL[\u03c3\u2082\u2083] M\u2083) :\n  (f' : M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083).comp (f : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) = (f.trans f' : M\u2081 \u2192SL[\u03c3\u2081\u2083] M\u2083) :=\nrfl\nomit \u03c3\u2083\u2082 \u03c3\u2083\u2081 \u03c3\u2082\u2081\n\n@[simp] theorem coe_comp_coe_symm (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) :\n  (e : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082).comp (e.symm : M\u2082 \u2192SL[\u03c3\u2082\u2081] M\u2081) = continuous_linear_map.id R\u2082 M\u2082 :=\ncontinuous_linear_map.ext e.apply_symm_apply\n\n@[simp] theorem coe_symm_comp_coe (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) :\n  (e.symm : M\u2082 \u2192SL[\u03c3\u2082\u2081] M\u2081).comp (e : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) = continuous_linear_map.id R\u2081 M\u2081 :=\ncontinuous_linear_map.ext e.symm_apply_apply\n\ninclude \u03c3\u2082\u2081\n@[simp] lemma symm_comp_self (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) :\n  (e.symm : M\u2082 \u2192 M\u2081) \u2218 (e : M\u2081 \u2192 M\u2082) = id :=\nby{ ext x, exact symm_apply_apply e x }\n\n@[simp] lemma self_comp_symm (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) :\n  (e : M\u2081 \u2192 M\u2082) \u2218 (e.symm : M\u2082 \u2192 M\u2081) = id :=\nby{ ext x, exact apply_symm_apply e x }\n\n@[simp] theorem symm_symm (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) : e.symm.symm = e :=\nby { ext x, refl }\nomit \u03c3\u2082\u2081\n\n@[simp] lemma refl_symm :\n (continuous_linear_equiv.refl R\u2081 M\u2081).symm = continuous_linear_equiv.refl R\u2081 M\u2081 :=\nrfl\n\ninclude \u03c3\u2082\u2081\ntheorem symm_symm_apply (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (x : M\u2081) : e.symm.symm x = e x :=\nrfl\n\nlemma symm_apply_eq (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {x y} : e.symm x = y \u2194 x = e y :=\ne.to_linear_equiv.symm_apply_eq\n\nlemma eq_symm_apply (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) {x y} : y = e.symm x \u2194 e y = x :=\ne.to_linear_equiv.eq_symm_apply\n\nprotected lemma image_eq_preimage (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (s : set M\u2081) : e '' s = e.symm \u207b\u00b9' s :=\ne.to_linear_equiv.to_equiv.image_eq_preimage s\n\nprotected lemma image_symm_eq_preimage (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (s : set M\u2082) : e.symm '' s = e \u207b\u00b9' s :=\nby rw [e.symm.image_eq_preimage, e.symm_symm]\n\n@[simp] protected lemma symm_preimage_preimage (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (s : set M\u2082) :\n  e.symm \u207b\u00b9' (e \u207b\u00b9' s) = s := e.to_linear_equiv.to_equiv.symm_preimage_preimage s\n\n@[simp] protected lemma preimage_symm_preimage (e : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (s : set M\u2081) :\n  e \u207b\u00b9' (e.symm \u207b\u00b9' s) = s := e.symm.symm_preimage_preimage s\n\nomit \u03c3\u2082\u2081\n\n/-- Create a `continuous_linear_equiv` from two `continuous_linear_map`s that are\ninverse of each other. -/\ndef equiv_of_inverse (f\u2081 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (f\u2082 : M\u2082 \u2192SL[\u03c3\u2082\u2081] M\u2081) (h\u2081 : function.left_inverse f\u2082 f\u2081)\n  (h\u2082 : function.right_inverse f\u2082 f\u2081) :\n  M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082 :=\n{ to_fun := f\u2081,\n  continuous_to_fun := f\u2081.continuous,\n  inv_fun := f\u2082,\n  continuous_inv_fun := f\u2082.continuous,\n  left_inv := h\u2081,\n  right_inv := h\u2082,\n  .. f\u2081 }\n\ninclude \u03c3\u2082\u2081\n@[simp] lemma equiv_of_inverse_apply (f\u2081 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (f\u2082 h\u2081 h\u2082 x) :\n  equiv_of_inverse f\u2081 f\u2082 h\u2081 h\u2082 x = f\u2081 x :=\nrfl\n\n@[simp] lemma symm_equiv_of_inverse (f\u2081 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082) (f\u2082 h\u2081 h\u2082) :\n  (equiv_of_inverse f\u2081 f\u2082 h\u2081 h\u2082).symm = equiv_of_inverse f\u2082 f\u2081 h\u2082 h\u2081 :=\nrfl\nomit \u03c3\u2082\u2081\n\nvariable (M\u2081)\n\n/-- The continuous linear equivalences from `M` to itself form a group under composition. -/\ninstance automorphism_group : group (M\u2081 \u2243L[R\u2081] M\u2081) :=\n{ mul          := \u03bb f g, g.trans f,\n  one          := continuous_linear_equiv.refl R\u2081 M\u2081,\n  inv          := \u03bb f, f.symm,\n  mul_assoc    := \u03bb f g h, by {ext, refl},\n  mul_one      := \u03bb f, by {ext, refl},\n  one_mul      := \u03bb f, by {ext, refl},\n  mul_left_inv := \u03bb f, by {ext, exact f.left_inv x} }\n\nvariables {M\u2081} {R\u2084 : Type*} [semiring R\u2084] [module R\u2084 M\u2084]\n  {\u03c3\u2083\u2084 : R\u2083 \u2192+* R\u2084} {\u03c3\u2084\u2083 : R\u2084 \u2192+* R\u2083} [ring_hom_inv_pair \u03c3\u2083\u2084 \u03c3\u2084\u2083] [ring_hom_inv_pair \u03c3\u2084\u2083 \u03c3\u2083\u2084]\n  {\u03c3\u2082\u2084 : R\u2082 \u2192+* R\u2084} {\u03c3\u2081\u2084 : R\u2081 \u2192+* R\u2084}\n  [ring_hom_comp_triple \u03c3\u2082\u2081 \u03c3\u2081\u2084 \u03c3\u2082\u2084] [ring_hom_comp_triple \u03c3\u2082\u2084 \u03c3\u2084\u2083 \u03c3\u2082\u2083]\n  [ring_hom_comp_triple \u03c3\u2081\u2083 \u03c3\u2083\u2084 \u03c3\u2081\u2084]\n\ninclude \u03c3\u2082\u2081 \u03c3\u2083\u2084 \u03c3\u2082\u2083 \u03c3\u2082\u2084 \u03c3\u2081\u2083\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\u2081\u2082 : M\u2081 \u2243SL[\u03c3\u2081\u2082] M\u2082) (e\u2084\u2083 : M\u2084 \u2243SL[\u03c3\u2084\u2083] M\u2083) :\n  (M\u2081 \u2192SL[\u03c3\u2081\u2084] M\u2084) \u2243 (M\u2082 \u2192SL[\u03c3\u2082\u2083] M\u2083) :=\n{ to_fun := \u03bb f, (e\u2084\u2083 : M\u2084 \u2192SL[\u03c3\u2084\u2083] M\u2083).comp (f.comp (e\u2081\u2082.symm : M\u2082 \u2192SL[\u03c3\u2082\u2081] M\u2081)),\n  inv_fun := \u03bb f, (e\u2084\u2083.symm : M\u2083 \u2192SL[\u03c3\u2083\u2084] M\u2084).comp (f.comp (e\u2081\u2082 : M\u2081 \u2192SL[\u03c3\u2081\u2082] M\u2082)),\n  left_inv := \u03bb f, continuous_linear_map.ext $ \u03bb x,\n    by simp only [continuous_linear_map.comp_apply, symm_apply_apply, coe_coe],\n  right_inv := \u03bb f, continuous_linear_map.ext $ \u03bb 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\u2082 : Type*} [topological_space M\u2082] [add_comm_group M\u2082]\n{M\u2083 : Type*} [topological_space M\u2083] [add_comm_group M\u2083]\n{M\u2084 : Type*} [topological_space M\u2084] [add_comm_group M\u2084]\n[module R M] [module R M\u2082] [module R M\u2083] [module R M\u2084]\n\nvariables [topological_add_group M\u2084]\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 \u2243L[R] M\u2082) (e' : M\u2083 \u2243L[R] M\u2084) (f : M \u2192L[R] M\u2084) :\n  (M \u00d7 M\u2083) \u2243L[R] M\u2082 \u00d7 M\u2084 :=\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 \u2191f }\n@[simp] lemma skew_prod_apply (e : M \u2243L[R] M\u2082) (e' : M\u2083 \u2243L[R] M\u2084) (f : M \u2192L[R] M\u2084) (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 \u2243L[R] M\u2082) (e' : M\u2083 \u2243L[R] M\u2084) (f : M \u2192L[R] M\u2084) (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\u2082 : Type*} [ring R\u2082]\n{M : Type*} [topological_space M] [add_comm_group M] [module R M]\n{M\u2082 : Type*} [topological_space M\u2082] [add_comm_group M\u2082] [module R\u2082 M\u2082]\nvariables {\u03c3\u2081\u2082 : R \u2192+* R\u2082} {\u03c3\u2082\u2081 : R\u2082 \u2192+* R} [ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081] [ring_hom_inv_pair \u03c3\u2082\u2081 \u03c3\u2081\u2082]\n\ninclude \u03c3\u2082\u2081\n@[simp] lemma map_sub (e : M \u2243SL[\u03c3\u2081\u2082] M\u2082) (x y : M) : e (x - y) = e x - e y :=\n(e : M \u2192SL[\u03c3\u2081\u2082] M\u2082).map_sub x y\n\n@[simp] lemma map_neg (e : M \u2243SL[\u03c3\u2081\u2082] M\u2082) (x : M) : e (-x) = -e x := (e : M \u2192SL[\u03c3\u2081\u2082] M\u2082).map_neg x\nomit \u03c3\u2082\u2081\n\nsection\n/-! The next theorems cover the identification between `M \u2243L[\ud835\udd5c] M`and the group of units of the ring\n`M \u2192L[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 \u2192L[R] M)) : (M \u2243L[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  := \u03bb x, show (f.inv * f.val) x = x, by {rw f.inv_val, simp},\n    right_inv := \u03bb 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 \u2243L[R] M)) : units (M \u2192L[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 \u2192L[R] M) \u2243* (M \u2243L[R] M) :=\n{ to_fun    := of_unit,\n  inv_fun   := to_unit,\n  left_inv  := \u03bb f, by {ext, refl},\n  right_inv := \u03bb f, by {ext, refl},\n  map_mul'  := \u03bb x y, by {ext, refl} }\n\n@[simp] lemma units_equiv_apply (f : units (M \u2192L[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 \u2243L[R] R` are enumerated by `units R`. -/\ndef units_equiv_aut : units R \u2243 (R \u2243L[R] R) :=\n{ to_fun := \u03bb u, equiv_of_inverse\n    (continuous_linear_map.smul_right (1 : R \u2192L[R] R) \u2191u)\n    (continuous_linear_map.smul_right (1 : R \u2192L[R] R) \u2191u\u207b\u00b9)\n    (\u03bb x, by simp) (\u03bb x, by simp),\n  inv_fun := \u03bb e, \u27e8e 1, e.symm 1,\n    by rw [\u2190 smul_eq_mul, \u2190 map_smul, smul_eq_mul, mul_one, symm_apply_apply],\n    by rw [\u2190 smul_eq_mul, \u2190 map_smul, smul_eq_mul, mul_one, apply_symm_apply]\u27e9,\n  left_inv := \u03bb u, units.ext $ by simp,\n  right_inv := \u03bb e, ext\u2081 $ 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 * \u2191u\u207b\u00b9 := rfl\n\n@[simp] lemma units_equiv_aut_symm_apply (e : R \u2243L[R] R) :\n  \u2191((units_equiv_aut R).symm e) = e 1 :=\nrfl\n\nend\n\nvariables [module R M\u2082] [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\u2081 \u2218 f\u2082 = id` generates a continuous\nlinear equivalence `e` between `M` and `M\u2082 \u00d7 f\u2081.ker` such that `(e x).2 = x` for `x \u2208 f\u2081.ker`,\n`(e x).1 = f\u2081 x`, and `(e (f\u2082 y)).2 = 0`. The map is given by `e x = (f\u2081 x, x - f\u2082 (f\u2081 x))`. -/\ndef equiv_of_right_inverse (f\u2081 : M \u2192L[R] M\u2082) (f\u2082 : M\u2082 \u2192L[R] M) (h : function.right_inverse f\u2082 f\u2081) :\n  M \u2243L[R] M\u2082 \u00d7 f\u2081.ker :=\nequiv_of_inverse (f\u2081.prod (f\u2081.proj_ker_of_right_inverse f\u2082 h)) (f\u2082.coprod (subtype_val f\u2081.ker))\n  (\u03bb x, by simp)\n  (\u03bb \u27e8x, y\u27e9, by simp [h x])\n\n@[simp] lemma fst_equiv_of_right_inverse (f\u2081 : M \u2192L[R] M\u2082) (f\u2082 : M\u2082 \u2192L[R] M)\n  (h : function.right_inverse f\u2082 f\u2081) (x : M) :\n  (equiv_of_right_inverse f\u2081 f\u2082 h x).1 = f\u2081 x := rfl\n\n@[simp] lemma snd_equiv_of_right_inverse (f\u2081 : M \u2192L[R] M\u2082) (f\u2082 : M\u2082 \u2192L[R] M)\n  (h : function.right_inverse f\u2082 f\u2081) (x : M) :\n  ((equiv_of_right_inverse f\u2081 f\u2082 h x).2 : M) = x - f\u2082 (f\u2081 x) := rfl\n\n@[simp] lemma equiv_of_right_inverse_symm_apply (f\u2081 : M \u2192L[R] M\u2082) (f\u2082 : M\u2082 \u2192L[R] M)\n  (h : function.right_inverse f\u2082 f\u2081) (y : M\u2082 \u00d7 f\u2081.ker) :\n  (equiv_of_right_inverse f\u2081 f\u2082 h).symm y = f\u2082 y.1 + y.2 := rfl\n\nend ring\n\nsection\n\nvariables (\u03b9 R M : Type*) [unique \u03b9] [semiring R] [add_comm_monoid M] [module R M]\n  [topological_space M]\n\n/-- If `\u03b9` has a unique element, then `\u03b9 \u2192 M` is continuously linear equivalent to `M`. -/\ndef fun_unique : (\u03b9 \u2192 M) \u2243L[R] M :=\n{ to_linear_equiv := linear_equiv.fun_unique \u03b9 R M,\n  .. homeomorph.fun_unique \u03b9 M }\n\nvariables {\u03b9 R M}\n\n@[simp] lemma coe_fun_unique : \u21d1(fun_unique \u03b9 R M) = function.eval (default \u03b9) := rfl\n@[simp] lemma coe_fun_unique_symm : \u21d1(fun_unique \u03b9 R M).symm = function.const \u03b9 := rfl\n\nvariables (R M)\n\n/-- Continuous linear equivalence between dependent functions `\u03a0 i : fin 2, M i` and `M 0 \u00d7 M 1`. -/\n@[simps { fully_applied := ff }]\ndef pi_fin_two (M : fin 2 \u2192 Type*) [\u03a0 i, add_comm_monoid (M i)] [\u03a0 i, module R (M i)]\n  [\u03a0 i, topological_space (M i)] :\n  (\u03a0 i, M i) \u2243L[R] M 0 \u00d7 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\u00b2 = fin 2 \u2192 M` and `M \u00d7 M`. -/\n@[simps { fully_applied := ff }]\ndef fin_two_arrow : (fin 2 \u2192 M) \u2243L[R] M \u00d7 M :=\n{ to_linear_equiv := linear_equiv.fin_two_arrow R M, .. pi_fin_two R (\u03bb _, M) }\n\nend\n\nend continuous_linear_equiv\n\nnamespace continuous_linear_map\n\nopen_locale classical\n\nvariables {R : Type*} {M : Type*} {M\u2082 : Type*} [topological_space M] [topological_space M\u2082]\n\nsection\nvariables [semiring R]\nvariables [add_comm_monoid M\u2082] [module R M\u2082]\nvariables [add_comm_monoid M] [module R M]\n\n/-- Introduce a function `inverse` from `M \u2192L[R] M\u2082` to `M\u2082 \u2192L[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 \u2192L[R] M\u2082) \u2192 (M\u2082 \u2192L[R] M) :=\n\u03bb f, if h : \u2203 (e : M \u2243L[R] M\u2082), (e : M \u2192L[R] M\u2082) = f then ((classical.some h).symm : M\u2082 \u2192L[R] M)\nelse 0\n\n/-- By definition, if `f` is invertible then `inverse f = f.symm`. -/\n@[simp] lemma inverse_equiv (e : M \u2243L[R] M\u2082) : inverse (e : M \u2192L[R] M\u2082) = e.symm :=\nbegin\n  have h : \u2203 (e' : M \u2243L[R] M\u2082), (e' : M \u2192L[R] M\u2082) = \u2191e := \u27e8e, rfl\u27e9,\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 \u2192L[R] M\u2082) (h : \u00ac\u2203 (e' : M \u2243L[R] M\u2082), \u2191e' = 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\u2082] [module R M\u2082]\n\n@[simp] lemma ring_inverse_equiv (e : M \u2243L[R] M) :\n  ring.inverse \u2191e = inverse (e : M \u2192L[R] M) :=\nbegin\n  suffices :\n    ring.inverse ((((continuous_linear_equiv.units_equiv _ _).symm e) : M \u2192L[R] M)) = inverse \u2191e,\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 \u2243L[R] M\u2082) (f : M \u2192L[R] M\u2082) :\n  inverse f = (ring.inverse ((e.symm : (M\u2082 \u2192L[R] M)).comp f)) \u2218L \u2191e.symm :=\nbegin\n  by_cases h\u2081 : \u2203 (e' : M \u2243L[R] M\u2082), \u2191e' = f,\n  { obtain \u27e8e', he'\u27e9 := h\u2081,\n    rw \u2190 he',\n    change _ = (ring.inverse \u2191(e'.trans e.symm)) \u2218L \u2191e.symm,\n    ext,\n    simp },\n  { suffices : \u00acis_unit ((e.symm : M\u2082 \u2192L[R] M).comp f),\n    { simp [this, h\u2081] },\n    contrapose! h\u2081,\n    rcases h\u2081 with \u27e8F, hF\u27e9,\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\u2082 : Type*} [topological_space M\u2082] [add_comm_group M\u2082] [module R M\u2082]\n\nopen continuous_linear_map\n\n/-- A submodule `p` is called *complemented* if there exists a continuous projection `M \u2192\u2097[R] p`. -/\ndef closed_complemented (p : submodule R M) : Prop := \u2203 f : M \u2192L[R] p, \u2200 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  \u2203 (q : submodule R M) (hq : is_closed (q : set M)), is_compl p q :=\nexists.elim h $ \u03bb f hf, \u27e8f.ker, f.is_closed_ker, linear_map.is_compl_of_proj hf\u27e9\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 \u27e8f, hf\u27e9,\n  have : ker (id R M - (subtype_val p).comp f) = p := linear_map.ker_id_sub_eq_of_proj hf,\n  exact this \u25b8 (is_closed_ker _)\nend\n\n@[simp] lemma closed_complemented_bot : closed_complemented (\u22a5 : submodule R M) :=\n\u27e80, \u03bb x, by simp only [zero_apply, eq_zero_of_bot_submodule x]\u27e9\n\n@[simp] lemma closed_complemented_top : closed_complemented (\u22a4 : submodule R M) :=\n\u27e8(id R M).cod_restrict \u22a4 (\u03bb x, trivial), \u03bb x, subtype.ext_iff_val.2 $ by simp\u27e9\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\u2082 : Type*} [topological_space M\u2082] [add_comm_group M\u2082] [module R M] [module R M\u2082]\n  [topological_add_group M] (f\u2081 : M \u2192L[R] M\u2082) (f\u2082 : M\u2082 \u2192L[R] M)\n  (h : function.right_inverse f\u2082 f\u2081) :\n  f\u2081.ker.closed_complemented :=\n\u27e8f\u2081.proj_ker_of_right_inverse f\u2082 h, f\u2081.proj_ker_of_right_inverse_apply_idem f\u2082 h\u27e9\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 : \u00ac 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\u00f6lich, *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 \u00abexpr \u2260 \u00bb (\u00abexpr\u22a5\u00bb() : 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  \u2200 (p) (_ : p \u2260 (\u22a5 : Ideal R)), p.IsPrime \u2192 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\u2080 p\u2081 p\u2082 : Ideal R) [hp\u2081 : p\u2081.IsPrime]\n    [hp\u2082 : p\u2082.IsPrime] : \u00ac(p\u2080 < p\u2081 \u2227 p\u2081 < p\u2082)\n  | \u27e8h01, h12\u27e9 => h12.Ne ((h p\u2081 (bot_le.trans_lt h01).ne' hp\u2081).eq_of_le hp\u2082.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 = \u22a5 :=\n  by_contra fun hp0 => h.not_lt_lt \u22a5 p P \u27e8Ne.bot_lt hp0, hpP\u27e9\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 \u2264 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 \u2194\n      IsNoetherianRing A \u2227\n        DimensionLeOne A \u2227 \u2200 {x : K}, IsIntegral A x \u2192 \u2203 y, algebraMap A K y = x :=\n  \u27e8fun \u27e8hr, hd, hi\u27e9 => \u27e8hr, hd, fun x => (isIntegrallyClosed_iff K).mp hi\u27e9, fun \u27e8hr, hd, hi\u27e9 =>\n    \u27e8hr, hd, (isIntegrallyClosed_iff K).mpr @hi\u27e9\u27e9\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  \u27e8PrincipalIdealRing.isNoetherianRing, Ring.DimensionLeOne.principal_ideal_ring A,\n    UniqueFactorizationMonoid.isIntegrallyClosed\u27e9\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 := \u03bb 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 := \u03bb U, Z,\n    map := \u03bb U V f, \ud835\udfd9 Z, } }\n\ninstance [inhabited C] : inhabited (PresheafedSpace C) := \u27e8const (Top.of pempty) (default C)\u27e9\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}) \u27f6 (Y : Top.{v}))\n(c : Y.presheaf \u27f6 base _* X.presheaf)\n\n@[ext] lemma ext {X Y : PresheafedSpace C} (\u03b1 \u03b2 : hom X Y)\n  (w : \u03b1.base = \u03b2.base)\n  (h : \u03b1.c \u226b (whisker_right (eq_to_hom (by rw w)) _) = \u03b2.c) :\n  \u03b1 = \u03b2 :=\nbegin\n  cases \u03b1, cases \u03b2,\n  dsimp [presheaf.pushforward_obj] at *,\n  tidy, -- TODO including `injections` would make tidy work earlier.\nend\n\nlemma hext {X Y : PresheafedSpace C} (\u03b1 \u03b2 : hom X Y)\n  (w : \u03b1.base = \u03b2.base)\n  (h : \u03b1.c == \u03b2.c) :\n  \u03b1 = \u03b2 :=\nby { cases \u03b1, cases \u03b2, congr, exacts [w,h] }\n\n.\n\n/-- The identity morphism of a `PresheafedSpace`. -/\ndef id (X : PresheafedSpace C) : hom X X :=\n{ base := \ud835\udfd9 (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) := \u27e8id X\u27e9\n\n/-- Composition of morphisms of `PresheafedSpace`s. -/\ndef comp {X Y Z : PresheafedSpace C} (\u03b1 : hom X Y) (\u03b2 : hom Y Z) : hom X Z :=\n{ base := \u03b1.base \u226b \u03b2.base,\n  c := \u03b2.c \u226b (presheaf.pushforward _ \u03b2.base).map \u03b1.c }\n\nlemma comp_c {X Y Z : PresheafedSpace C} (\u03b1 : hom X Y) (\u03b2 : hom Y Z) :\n  (comp \u03b1 \u03b2).c = \u03b2.c \u226b (presheaf.pushforward _ \u03b2.base).map \u03b1.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 := \u03bb X Y Z f g, comp f g,\n  id_comp' := \u03bb 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' := \u03bb 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' := \u03bb 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  ((\ud835\udfd9 X) : X \u27f6 X).base = \ud835\udfd9 (X : Top.{v}) := rfl\n\nlemma id_c (X : PresheafedSpace C) :\n  ((\ud835\udfd9 X) : X \u27f6 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  ((\ud835\udfd9 X) : X \u27f6 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 \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).base = f.base \u226b 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} (\u03b1 : X \u27f6 Y) (\u03b2 : Y \u27f6 Z) (U) :\n  (\u03b1 \u226b \u03b2).c.app U = (\u03b2.c).app U \u226b (\u03b1.c).app (op ((opens.map (\u03b2.base)).obj (unop U))) := rfl\n\nlemma congr_app {X Y : PresheafedSpace C} {\u03b1 \u03b2 : X \u27f6 Y} (h : \u03b1 = \u03b2) (U) :\n  \u03b1.c.app U = \u03b2.c.app U \u226b 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 \u2964 Top :=\n{ obj := \u03bb X, (X : Top.{v}),\n  map := \u03bb 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 \u2245 Y.1) (\u03b1 : H.hom _* X.2 \u2245 Y.2) : X \u2245 Y :=\n{ hom := { base := H.hom, c := \u03b1.inv },\n  inv := { base := H.inv,\n    c := presheaf.to_pushforward_of_iso H \u03b1.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 [\u2190 \u03b1.hom.naturality],\n    have := nat_trans.congr_app (\u03b1.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 \u2245 Y) : Y.2 \u2245 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 (\u03bb f, f \u226b 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 (\u03bb f, f \u226b X.presheaf.map (eq_to_hom h.symm)) this\n  end }\n\ninstance base_is_iso_of_iso (f : X \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 (X : Top.{v})} (h : open_embedding f) : PresheafedSpace C :=\n{ carrier := U,\n  presheaf := h.is_open_map.functor.op \u22d9 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 \u27f6 (X : Top.{v})} (h : open_embedding f) :\n  X.restrict h \u27f6 X :=\n{ base := f,\n  c := { app := \u03bb V, X.presheaf.map (h.is_open_map.adjunction.counit.app V.unop).op,\n    naturality' := \u03bb U V f, show _ = _ \u226b X.presheaf.map _,\n      by { rw [\u2190 map_comp, \u2190 map_comp], refl } } }\n\ninstance of_restrict_mono {U : Top} (X : PresheafedSpace C) (f : U \u27f6 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\u2081 g\u2082 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 : _ \u226b _ = _ \u226b _ \u226b _ :=\n       congr_arg (\u03bb f, (X.restrict hf).presheaf.map (eq_to_hom hV).op \u226b f) this,\n     erw [g\u2081.c.naturality, g\u2082.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 \u2190is_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 \u22a4)).c = eq_to_hom\n    (by { rw [restrict_top_presheaf, \u2190presheaf.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 \u27e8 \u03bb h, \u27e8\u27e8x,trivial\u27e9,h,rfl\u27e9, \u03bb \u27e8\u27e8_,_\u27e9,h,rfl\u27e9, h \u27e9 },\n  /- or `rw [opens.inclusion_top_functor, \u2190comp_obj, \u2190opens.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 \u27f6 X.restrict (opens.open_embedding \u22a4) :=\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 \u22a4) \u2245 X :=\n{ hom := X.of_restrict _,\n  inv := X.to_restrict_top,\n  hom_inv_id' := ext _ _ (concrete_category.hom_ext _ _ $ \u03bb \u27e8x, _\u27e9, 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 \u0393 : (PresheafedSpace C)\u1d52\u1d56 \u2964 C :=\n{ obj := \u03bb X, (unop X).presheaf.obj (op \u22a4),\n  map := \u03bb X Y f, f.unop.c.app (op \u22a4) }\n\nlemma \u0393_obj_op (X : PresheafedSpace C) : \u0393.obj (op X) = X.presheaf.obj (op \u22a4) := rfl\n\nlemma \u0393_map_op {X Y : PresheafedSpace C} (f : X \u27f6 Y) :\n  \u0393.map f.op = f.c.app (op \u22a4) := 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 \u2964 D` to the values of the presheaf in any `PresheafedSpace C`,\n    giving a functor `PresheafedSpace C \u2964 PresheafedSpace D` -/\ndef map_presheaf (F : C \u2964 D) : PresheafedSpace C \u2964 PresheafedSpace D :=\n{ obj := \u03bb X, { carrier := X.carrier, presheaf := X.presheaf \u22d9 F },\n  map := \u03bb X Y f, { base := f.base, c := whisker_right f.c F }, }\n\n@[simp] lemma map_presheaf_obj_X (F : C \u2964 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 \u2964 D) (X : PresheafedSpace C) :\n  (F.map_presheaf.obj X).presheaf = X.presheaf \u22d9 F := rfl\n@[simp] lemma map_presheaf_map_f (F : C \u2964 D) {X Y : PresheafedSpace C} (f : X \u27f6 Y) :\n  (F.map_presheaf.map f).base = f.base := rfl\n@[simp] lemma map_presheaf_map_c (F : C \u2964 D) {X Y : PresheafedSpace C} (f : X \u27f6 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 \u2964 D} (\u03b1 : F \u27f6 G) : G.map_presheaf \u27f6 F.map_presheaf :=\n{ app := \u03bb X,\n  { base := \ud835\udfd9 _,\n    c := whisker_left X.presheaf \u03b1 \u226b eq_to_hom (presheaf.pushforward.id_eq _).symm } }\n\n-- TODO Assemble the last two constructions into a functor\n--   `(C \u2964 D) \u2964 (PresheafedSpace C \u2964 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 \u2964 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 := \u27e8{to_Top := { \u03b1 := pempty }}\u27e9\n\ninstance : has_coe_to_sort CompHaus := \u27e8Type*, \u03bb X, X.to_Top\u27e9\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 := \u2039_\u203a,\n  is_hausdorff := \u2039_\u203a }\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 \u27f6 Y) : is_closed_map f :=\n\u03bb 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 \u27f6 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 \u2190 E.image_eq_preimage,\n    exact is_closed_map f S hS },\n  refine \u27e8\u27e8\u27e8E.symm, hE\u27e9, _, _\u27e9\u27e9,\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 \u27f6 Y) (bij : function.bijective f) : X \u2245 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} \u2964 Top.{u} := induced_functor _\n\ninstance CompHaus.forget_reflects_isomorphisms : reflects_isomorphisms (forget CompHaus) :=\n\u27e8by introsI A B f hf; exact CompHaus.is_iso_of_bijective _ ((is_iso_iff_bijective \u21d1f).mp hf)\u27e9\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 \u27f6 Y) \u2243 (X \u27f6 CompHaus_to_Top.obj Y) :=\n{ to_fun := \u03bb f,\n  { to_fun := f \u2218 stone_cech_unit,\n    continuous_to_fun := f.2.comp (@continuous_stone_cech_unit X _) },\n  inv_fun := \u03bb 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 \u27e8f : stone_cech X \u27f6 Y, hf : continuous f\u27e9,\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 _ \u27e8y, rfl\u27e9,\n    apply congr_fun (stone_cech_extend_extends (hf.comp _)) y,\n  end,\n  right_inv :=\n  begin\n    rintro \u27e8f : \u21a5X \u27f6 Y, hf : continuous f\u27e9,\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} \u2964 CompHaus.{u} :=\nadjunction.left_adjoint_of_equiv stone_cech_equivalence.{u u} (\u03bb _ _ _ _ _, rfl)\n\nlemma Top_to_CompHaus_obj (X : Top) : \u21a5(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 := \u27e8Top_to_CompHaus, adjunction.adjunction_of_equiv_left _ _\u27e9 }\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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nnamespace CategoryTheory.Functor\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} D] {E : Type u\u2083}\n  [Category.{v\u2083} E]\n\n/-- A functor preserves monomorphisms if it maps monomorphisms to monomorphisms. -/\nclass PreservesMonomorphisms (F : C \u2964 D) : Prop where\n  /-- A functor preserves monomorphisms if it maps monomorphisms to monomorphisms. -/\n  preserves : \u2200 {X Y : C} (f : X \u27f6 Y) [Mono f], Mono (F.map f)\n#align category_theory.functor.preserves_monomorphisms CategoryTheory.Functor.PreservesMonomorphisms\n\ninstance map_mono (F : C \u2964 D) [PreservesMonomorphisms F] {X Y : C} (f : X \u27f6 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 \u2964 D) : Prop where\n  /-- A functor preserves epimorphisms if it maps epimorphisms to epimorphisms. -/\n  preserves : \u2200 {X Y : C} (f : X \u27f6 Y) [Epi f], Epi (F.map f)\n#align category_theory.functor.preserves_epimorphisms CategoryTheory.Functor.PreservesEpimorphisms\n\ninstance map_epi (F : C \u2964 D) [PreservesEpimorphisms F] {X Y : C} (f : X \u27f6 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 \u2964 D) : Prop where\n   /-- A functor reflects monomorphisms if morphisms that are mapped to monomorphisms are themselves\n    monomorphisms. -/\n  reflects : \u2200 {X Y : C} (f : X \u27f6 Y), Mono (F.map f) \u2192 Mono f\n#align category_theory.functor.reflects_monomorphisms CategoryTheory.Functor.ReflectsMonomorphisms\n\ntheorem mono_of_mono_map (F : C \u2964 D) [ReflectsMonomorphisms F] {X Y : C} {f : X \u27f6 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 \u2964 D) : Prop where\n  /-- A functor reflects epimorphisms if morphisms that are mapped to epimorphisms are themselves\n      epimorphisms. -/\n  reflects : \u2200 {X Y : C} (f : X \u27f6 Y), Epi (F.map f) \u2192 Epi f\n#align category_theory.functor.reflects_epimorphisms CategoryTheory.Functor.ReflectsEpimorphisms\n\ntheorem epi_of_epi_map (F : C \u2964 D) [ReflectsEpimorphisms F] {X Y : C} {f : X \u27f6 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 \u2964 D) (G : D \u2964 E) [PreservesMonomorphisms F]\n    [PreservesMonomorphisms G] : PreservesMonomorphisms (F \u22d9 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 \u2964 D) (G : D \u2964 E) [PreservesEpimorphisms F]\n    [PreservesEpimorphisms G] : PreservesEpimorphisms (F \u22d9 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 \u2964 D) (G : D \u2964 E) [ReflectsMonomorphisms F]\n    [ReflectsMonomorphisms G] : ReflectsMonomorphisms (F \u22d9 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 \u2964 D) (G : D \u2964 E) [ReflectsEpimorphisms F]\n    [ReflectsEpimorphisms G] : ReflectsEpimorphisms (F \u22d9 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 \u2964 D) (G : D \u2964 E)\n    [PreservesMonomorphisms (F \u22d9 G)] [ReflectsMonomorphisms G] : PreservesMonomorphisms F :=\n  \u27e8fun f _ => G.mono_of_mono_map <| show Mono ((F \u22d9 G).map f) from inferInstance\u27e9\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 \u2964 D) (G : D \u2964 E)\n    [PreservesEpimorphisms G] [ReflectsEpimorphisms (F \u22d9 G)] : ReflectsEpimorphisms F :=\n  \u27e8fun f _ => (F \u22d9 G).epi_of_epi_map <| show Epi (G.map (F.map f)) from inferInstance\u27e9\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 \u2964 D) (G : D \u2964 E)\n    [PreservesMonomorphisms G] [ReflectsMonomorphisms (F \u22d9 G)] : ReflectsMonomorphisms F :=\n  \u27e8fun f _ => (F \u22d9 G).mono_of_mono_map <| show Mono (G.map (F.map f)) from inferInstance\u27e9\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 \u2964 D} [PreservesMonomorphisms F] (\u03b1 : F \u2245 G) :\n    PreservesMonomorphisms G :=\n  {\n    preserves := fun {X} {Y} f h =>\n      by\n      haveI : Mono (F.map f \u226b (\u03b1.app Y).hom) := mono_comp _ _\n      convert (mono_comp _ _ : Mono ((\u03b1.app X).inv \u226b F.map f \u226b (\u03b1.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 \u2964 D} (\u03b1 : F \u2245 G) :\n    PreservesMonomorphisms F \u2194 PreservesMonomorphisms G :=\n  \u27e8fun _ => preservesMonomorphisms.of_iso \u03b1, fun _ => preservesMonomorphisms.of_iso \u03b1.symm\u27e9\n#align category_theory.functor.preserves_monomorphisms.iso_iff CategoryTheory.Functor.preservesMonomorphisms.iso_iff\n\ntheorem preservesEpimorphisms.of_iso {F G : C \u2964 D} [PreservesEpimorphisms F] (\u03b1 : F \u2245 G) :\n    PreservesEpimorphisms G :=\n  {\n    preserves := fun {X} {Y} f h =>\n      by\n      haveI : Epi (F.map f \u226b (\u03b1.app Y).hom) := epi_comp _ _\n      convert (epi_comp _ _ : Epi ((\u03b1.app X).inv \u226b F.map f \u226b (\u03b1.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 \u2964 D} (\u03b1 : F \u2245 G) :\n    PreservesEpimorphisms F \u2194 PreservesEpimorphisms G :=\n  \u27e8fun _ => preservesEpimorphisms.of_iso \u03b1, fun _ => preservesEpimorphisms.of_iso \u03b1.symm\u27e9\n#align category_theory.functor.preserves_epimorphisms.iso_iff CategoryTheory.Functor.preservesEpimorphisms.iso_iff\n\ntheorem reflectsMonomorphisms.of_iso {F G : C \u2964 D} [ReflectsMonomorphisms F] (\u03b1 : F \u2245 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 \u226b (\u03b1.app Y).inv) := mono_comp _ _\n      convert (mono_comp _ _ : Mono ((\u03b1.app X).hom \u226b G.map f \u226b (\u03b1.app Y).inv))\n      rw [\u2190 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 \u2964 D} (\u03b1 : F \u2245 G) :\n    ReflectsMonomorphisms F \u2194 ReflectsMonomorphisms G :=\n  \u27e8fun _ => reflectsMonomorphisms.of_iso \u03b1, fun _ => reflectsMonomorphisms.of_iso \u03b1.symm\u27e9\n#align category_theory.functor.reflects_monomorphisms.iso_iff CategoryTheory.Functor.reflectsMonomorphisms.iso_iff\n\ntheorem reflectsEpimorphisms.of_iso {F G : C \u2964 D} [ReflectsEpimorphisms F] (\u03b1 : F \u2245 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 \u226b (\u03b1.app Y).inv) := epi_comp _ _\n      convert (epi_comp _ _ : Epi ((\u03b1.app X).hom \u226b G.map f \u226b (\u03b1.app Y).inv))\n      rw [\u2190 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 \u2964 D} (\u03b1 : F \u2245 G) :\n    ReflectsEpimorphisms F \u2194 ReflectsEpimorphisms G :=\n  \u27e8fun _ => reflectsEpimorphisms.of_iso \u03b1, fun _ => reflectsEpimorphisms.of_iso \u03b1.symm\u27e9\n#align category_theory.functor.reflects_epimorphisms.iso_iff CategoryTheory.Functor.reflectsEpimorphisms.iso_iff\n\ntheorem preservesEpimorphsisms_of_adjunction {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) :\n    PreservesEpimorphisms F :=\n  {\n    preserves := fun {X} {Y} f hf =>\n      \u27e8by\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\u27e9 }\n#align category_theory.functor.preserves_epimorphsisms_of_adjunction CategoryTheory.Functor.preservesEpimorphsisms_of_adjunction\n\ninstance (priority := 100) preservesEpimorphisms_of_isLeftAdjoint (F : C \u2964 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 \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) :\n    PreservesMonomorphisms G :=\n  {\n    preserves := fun {X} {Y} f hf =>\n      \u27e8by\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\u27e9 }\n#align category_theory.functor.preserves_monomorphisms_of_adjunction CategoryTheory.Functor.preservesMonomorphisms_of_adjunction\n\ninstance (priority := 100) preservesMonomorphisms_of_isRightAdjoint (F : C \u2964 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 \u2964 D) [Faithful F] :\n    ReflectsMonomorphisms F\n    where reflects {X} {Y} f hf :=\n    \u27e8fun {Z} g h hgh =>\n      F.map_injective ((cancel_mono (F.map f)).1 (by rw [\u2190 F.map_comp, hgh, F.map_comp]))\u27e9\n#align category_theory.functor.reflects_monomorphisms_of_faithful CategoryTheory.Functor.reflectsMonomorphisms_of_faithful\n\ninstance (priority := 100) reflectsEpimorphisms_of_faithful (F : C \u2964 D) [Faithful F] :\n    ReflectsEpimorphisms F\n    where reflects {X} {Y} f hf :=\n    \u27e8fun {Z} g h hgh =>\n      F.map_injective ((cancel_epi (F.map f)).1 (by rw [\u2190 F.map_comp, hgh, F.map_comp]))\u27e9\n#align category_theory.functor.reflects_epimorphisms_of_faithful CategoryTheory.Functor.reflectsEpimorphisms_of_faithful\n\nsection\n\nvariable (F : C \u2964 D) {X Y : C} (f : X \u27f6 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 \u2243 SplitEpi (F.map f)\n    where\n  toFun f := f.map F\n  invFun s := by\n    refine' \u27e8F.preimage s.section_, _\u27e9\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) \u2194 IsSplitEpi f := by\n  constructor\n  \u00b7 intro h\n    exact IsSplitEpi.mk' ((splitEpiEquiv F f).invFun h.exists_splitEpi.some)\n  \u00b7 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 \u2243 SplitMono (F.map f)\n    where\n  toFun f := f.map F\n  invFun s := by\n    refine' \u27e8F.preimage s.retraction, _\u27e9\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) \u2194 IsSplitMono f := by\n  constructor\n  \u00b7 intro h\n    exact IsSplitMono.mk' ((splitMonoEquiv F f).invFun h.exists_splitMono.some)\n  \u00b7 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\u2081 : PreservesEpimorphisms F] [hF\u2082 : ReflectsEpimorphisms F] :\n    Epi (F.map f) \u2194 Epi f := by\n  constructor\n  \u00b7 exact F.epi_of_epi_map\n  \u00b7 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\u2081 : PreservesMonomorphisms F] [hF\u2082 : ReflectsMonomorphisms F] :\n    Mono (F.map f) \u2194 Mono f := by\n  constructor\n  \u00b7 exact F.mono_of_mono_map\n  \u00b7 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 \u2964 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  \u27e8fun {X} {Y} f => by\n    intro\n    rw [\u2190 F.inv.isSplitEpi_iff f]\n    apply isSplitEpi_of_epi\u27e9\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 \u2964 D} {F' : D \u2964 C} {A B : C}\n\ntheorem strongEpi_map_of_strongEpi (adj : F \u22a3 F') (f : A \u27f6 B) [h\u2081 : F'.PreservesMonomorphisms]\n    [h\u2082 : F.PreservesEpimorphisms] [StrongEpi f] : StrongEpi (F.map f) :=\n  \u27e8inferInstance, fun X Y Z => by\n    intro\n    rw [adj.hasLiftingProperty_iff]\n    infer_instance\u27e9\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 \u27f6 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 \u2964 D} {A B : C} (f : A \u27f6 B)\n\n@[simp]\ntheorem strongEpi_map_iff_strongEpi_of_isEquivalence [IsEquivalence F] :\n    StrongEpi (F.map f) \u2194 StrongEpi f := by\n  constructor\n  \u00b7 intro\n    have e : Arrow.mk f \u2245 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  \u00b7 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 `\u00ac P` for some proposition `P`.\nIt should use this contradiction to close the goal.\n\nBonus: handle `P \u2192 false` as well as `\u00ac 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 : \u00ac R) (hnq : \u00ac Q) : false :=\nby contr\n\n\nexample (P Q R : Prop) (hnq : \u00ac Q) (hp : P) (hq : Q) (hr : \u00ac R) : 0 = 1 :=\nby contr\n\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hnq : Q \u2192 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 `\u2115`\n(presumably with some arguments), e.g. `nat.add : \u2115 \u2192 \u2115 \u2192 \u2115`\nor `list.length : \u03a0 \u03b1 : Type, list \u03b1 \u2192 \u2115`.\nIt should add a new declaration to the environment which proves all applications\nof this function are nonnegative,\ne.g. `nat.add_nonneg : \u2200 m n : \u2115, 0 \u2264 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 : \u211a) (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 : \u211a) (h : q / (3 / 4) > 0) : false :=\nbegin\n  cancel_denoms at h,\nend\n\nexample (p q : \u211a) (h : q / 2 / 3 < q) : false :=\nbegin\n  cancel_denoms at h,\nend\n\nexample (p q : \u211a) (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 : \u211a) (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 \u2192 M` with (n : \u2115)\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 \u2192 M`, and I am going to define a bijection `S`\n-- of `fin n \u2192 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 : \u2115} (a : fin n.succ) : zmod n.succ := a\ndef zmod.to_fin {n : \u2115} (a : zmod n.succ) : fin n.succ := a\n\n-- if we are only thinking of \u2115 as an ordered set then these ideas are \"the same\"\ndef fin.equiv_zmod {n : \u2115} : fin n.succ \u2243 zmod n.succ := equiv.refl _\n\ndef zmod.S {m : \u2115} : zmod m \u2243 zmod m := \n  \u27e8\u03bb n, n + 1, \u03bb n, n - 1, by { intro _, simp }, by { intro _, simp }\u27e9\n\nlemma list.ext' {n : \u2115} {\u03b1 : Type} {L M : list \u03b1} (hL : L.length = n)\n  (hM : M.length = n) (hLM : \u2200 (i : fin n),\n    L.nth_le i.1 (hL.symm \u25b8 i.2) = M.nth_le i.1 (hM.symm \u25b8 i.2)) : L = M :=\nbegin\n  suffices : (\u27e8L, hL\u27e9 : vector \u03b1 n) = \u27e8M, hM\u27e9,\n    exact subtype.mk.inj this,\n  exact vector.ext (\u03bb i, hLM i),\nend\n\nlemma vector.to_list.succ (n : \u2115) (M : Type) (v : vector M n.succ) :\nv.to_list = v.nth 0 :: list.of_fn\n  (\u03bb (i : fin n), v.nth i.succ : fin n \u2192 M) :=\nbegin\n  have h1 : v.to_list.length = n.succ := by simp,  \n  have h2 : (list.cons (v.nth 0) (list.of_fn (\u03bb (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 \u27e8_ | \u27e8v_val_hd, _\u27e9\u27e9,\n    { suffices : 0 = n.succ,\n        cases this,\n      rw \u2190h1, simp },\n    { simp, refl } },\n  { -- i \u2260 0\n    have hj : \u2203 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 \u2260 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 \u27e8_, hi3\u27e9,\n      cases i with i hin,\n      simp,\n      ext,\n      simp,\n      have hi4 : i \u2260 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 \u27e8\u27e8j,hj\u27e9, rfl\u27e9,\n    suffices : v.to_list.nth_le j.succ (h1.symm \u25b8 _) = v.nth (\u27e8j, hj\u27e9 : fin n).succ,\n      simpa,\n    rcases v with \u27e8_ | \u27e8hd,tl\u27e9\u27e9,\n    { cases h1 },\n    simp [vector.nth] },\nend\n\nlemma vector.to_list.succ' (n : \u2115) (M : Type) (v : vector M n.succ) :\nv.to_list = list.of_fn\n  (\u03bb (i : fin n), v.nth i.cast_succ : fin n \u2192 M) ++ [v.nth \u27e8n, nat.lt_succ_self _\u27e9] :=\nbegin\n  have ht1 : v.to_list.length = n.succ := by simp,\n  apply list.ext' ht1,\n  { rintro \u27e8i, hi\u27e9,\n    by_cases h : i < n,\n    { rw list.nth_le_append,\n      { simp,\n        suffices : v.to_list.nth_le i _ = v.nth \u27e8i, hi\u27e9,\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 \u2192 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 : \u2115) (g : G) : (list.repeat g d).prod' = g ^ (d : \u2124) :=\nbegin\n  induction d with e he,\n    { refl },\n    { suffices : g * (list.repeat g e).prod' = g ^ ((e  : \u2124) + 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 : \u2115} : set (fin n \u2192 G) :=\n\u03bb f, (vector.of_fn f).to_list.prod' = 1\n\nlemma mem_finmap_prod_eq_one {n : \u2115} (v : fin n \u2192 G) :\n  v \u2208 (finmap.prod_eq_one : set (fin n \u2192 G)) \u2194 (vector.of_fn v).to_list.prod' = 1 :=\niff.rfl\n\nvariables {n : \u2115}\n\ndef fin.S.succ {n : \u2115} : fin n.succ \u2243 fin n.succ :=\ncalc\nfin n.succ \u2243 zmod n.succ : fin.equiv_zmod\n...         \u2243 zmod n.succ : zmod.S\n...         \u2243 fin n.succ : fin.equiv_zmod.symm\n\ndef fin.S.succ' (n : \u2115) := @fin.S.succ n\n\n-- I never use the next two things.\ndef fin.S.zero : fin 0 \u2243 fin 0 := equiv.refl _\n\ndef fin.S (n : \u2115) : fin n \u2243 fin n := nat.rec_on n fin.S.zero (\u03bb 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 \u2192 G} :\nfinmap.prod_eq_one f \u2192 finmap.prod_eq_one (f \u2218 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 \u2218 (fin.S.succ' n))).to_list.prod' = 1,\n  change (vector.of_fn (\u03bb x, (f \u2218 (fin.S.succ' n)) x)).to_list.prod' = 1,\n  change (vector.of_fn (\u03bb 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 \u2200 a b : G, a * b = 1 \u2192 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 \u27e8n, (nat.lt_succ_self n)\u27e9 + 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 : \u2115) : 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 : \u2115) : 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 \u2192 G} (d : \u2115) :\nfinmap.prod_eq_one f \u2192 finmap.prod_eq_one \n  (\u03bb i, f (((fin.S.succ : fin n.succ \u2243 fin n.succ) ^ (d : \u2124) : \n  fin n.succ \u2243 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 \u2243 zmod n) := by apply_instance\n\nlemma zmod.S.pow_k (k : \u2115) (n : \u2115) (d : zmod n) :\n  ((zmod.S : zmod n \u2243 zmod n) ^ (k : \u2124)) 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 : \u2115) (n : \u2115) (d : fin n.succ) :\n  ((fin.S.succ' n : fin n.succ \u2243 fin n.succ) ^ (k : \u2124)) d = k + d :=\nbegin\n  -- evil proof\n  apply zmod.S.pow_k k n.succ \nend\n\nlemma zmod.S.pow_n (n : \u2115) (d : zmod n) :\n  ((zmod.S : zmod n \u2243 zmod n) ^ (n : \u2124)) d = d := by simp [zmod.S.pow_k]\n\nlemma fin.S.succ.pow_n (n : \u2115) (d : fin n.succ) :\n  ((fin.S.succ' n) ^ (((n.succ : \u2115) : \u2124))) 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\n\nQuotients -- extends the core library\n-/\nvariables {\u03b1 : Sort*} {\u03b2 : Sort*}\n\nnamespace setoid\n\nlemma ext {\u03b1 : Sort*} :\n  \u2200{s t : setoid \u03b1}, (\u2200a b, @setoid.r \u03b1 s a b \u2194 @setoid.r \u03b1 t a b) \u2192 s = t\n| \u27e8r, _\u27e9 \u27e8p, _\u27e9 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} {rb : \u03b2 \u2192 \u03b2 \u2192 Prop} {\u03c6 : quot ra \u2192 quot rb \u2192 Sort*}\nlocal notation `\u27e6`:max a `\u27e7` := quot.mk _ a\n\nprotected def hrec_on\u2082 (qa : quot ra) (qb : quot rb) (f : \u2200 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n  (ca : \u2200 {b a\u2081 a\u2082}, ra a\u2081 a\u2082 \u2192 f a\u2081 b == f a\u2082 b)\n  (cb : \u2200 {a b\u2081 b\u2082}, rb b\u2081 b\u2082 \u2192 f a b\u2081 == f a b\u2082) : \u03c6 qa qb :=\nquot.hrec_on qa (\u03bb a, quot.hrec_on qb (f a) (\u03bb b\u2081 b\u2082 pb, cb pb)) $ \u03bb a\u2081 a\u2082 pa,\n  quot.induction_on qb $ \u03bb b,\n    calc @quot.hrec_on _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2081) (@cb _)\n          == f a\u2081 b                                     : by simp\n      ... == f a\u2082 b                                     : ca pa\n      ... == @quot.hrec_on _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2082) (@cb _) : by simp\n\nprotected def map {\u03b1} (r r' : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200a b, r a b \u2192 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 \u03b1] [sb : setoid \u03b2]\nvariables {\u03c6 : quotient sa \u2192 quotient sb \u2192 Sort*}\n\nprotected def hrec_on\u2082 (qa : quotient sa) (qb : quotient sb) (f : \u2200 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) : \u03c6 qa qb :=\nquot.hrec_on\u2082 qa qb f\n  (\u03bb _ _ _ p, c _ _ _ _ p (setoid.refl _))\n  (\u03bb _ _ _ p, c _ _ _ _ (setoid.refl _) p)\nend quotient\n\n@[simp] theorem quotient.eq [r : setoid \u03b1] {x y : \u03b1} : \u27e6x\u27e7 = \u27e6y\u27e7 \u2194 x \u2248 y :=\n\u27e8quotient.exact, quotient.sound\u27e9\n\ntheorem forall_quotient_iff {\u03b1 : Type*} [r : setoid \u03b1] {p : quotient r \u2192 Prop} :\n  (\u2200a:quotient r, p a) \u2194 (\u2200a:\u03b1, p \u27e6a\u27e7) :=\n\u27e8assume h x, h _, assume h a, a.induction_on h\u27e9\n\n@[simp] lemma quotient.lift_beta [s : setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b) (x : \u03b1):\nquotient.lift f h (quotient.mk x) = f x := rfl\n\n@[simp] lemma quotient.lift_on_beta [s : setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b) (x : \u03b1):\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 : \u03b1 \u2192 \u03b1 \u2192 Prop} (q : quot r) : \u03b1 :=\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 : \u03b1 \u2192 \u03b1 \u2192 Prop} : quot r \u2192 \u03b1 := unchecked_cast\n\n@[simp] theorem quot.out_eq {r : \u03b1 \u2192 \u03b1 \u2192 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 \u03b1] : quotient s \u2192 \u03b1 := quot.out\n\n@[simp] theorem quotient.out_eq [s : setoid \u03b1] (q : quotient s) : \u27e6q.out\u27e7 = q := q.out_eq\n\ntheorem quotient.mk_out [s : setoid \u03b1] (a : \u03b1) : \u27e6a\u27e7.out \u2248 a :=\nquotient.exact (quotient.out_eq _)\n\ninstance pi_setoid {\u03b9 : Sort*} {\u03b1 : \u03b9 \u2192 Sort*} [\u2200 i, setoid (\u03b1 i)] : setoid (\u03a0 i, \u03b1 i) :=\n{ r := \u03bb a b, \u2200 i, a i \u2248 b i,\n  iseqv := \u27e8\n    \u03bb a i, setoid.refl _,\n    \u03bb a b h i, setoid.symm (h _),\n    \u03bb a b c h\u2081 h\u2082 i, setoid.trans (h\u2081 _) (h\u2082 _)\u27e9 }\n\nnoncomputable def quotient.choice {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [S : \u2200 i, setoid (\u03b1 i)]\n  (f : \u2200 i, quotient (S i)) : @quotient (\u03a0 i, \u03b1 i) (by apply_instance) :=\n\u27e6\u03bb i, (f i).out\u27e7\n\ntheorem quotient.choice_eq {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, setoid (\u03b1 i)]\n  (f : \u2200 i, \u03b1 i) : quotient.choice (\u03bb i, \u27e6f i\u27e7) = \u27e6f\u27e7 :=\nquotient.sound $ \u03bb i, quotient.mk_out _\n\nlemma nonempty_quotient_iff (s : setoid \u03b1): nonempty (quotient s) \u2194 nonempty \u03b1 :=\n\u27e8assume \u27e8a\u27e9, quotient.induction_on a nonempty.intro, assume \u27e8a\u27e9, \u27e8\u27e6a\u27e7\u27e9\u27e9\n\n/-- `trunc \u03b1` is the quotient of `\u03b1` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty \u03b1`, but unlike `nonempty \u03b1`, `trunc \u03b1` is data,\n  so the VM representation is the same as `\u03b1`, and so this can be used to\n  maintain computability. -/\ndef {u} trunc (\u03b1 : Sort u) : Sort u := @quot \u03b1 (\u03bb _ _, true)\n\ntheorem true_equivalence : @equivalence \u03b1 (\u03bb _ _, true) :=\n\u27e8\u03bb _, trivial, \u03bb _ _ _, trivial, \u03bb _ _ _ _ _, trivial\u27e9\n\nnamespace trunc\n\n/-- Constructor for `trunc \u03b1` -/\ndef mk (a : \u03b1) : trunc \u03b1 := quot.mk _ a\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : \u03b1 \u2192 \u03b2) (c : \u2200 a b : \u03b1, f a = f b) : trunc \u03b1 \u2192 \u03b2 :=\nquot.lift f (\u03bb a b _, c a b)\n\ntheorem ind {\u03b2 : trunc \u03b1 \u2192 Prop} : (\u2200 a : \u03b1, \u03b2 (mk a)) \u2192 \u2200 q : trunc \u03b1, \u03b2 q := quot.ind\n\nprotected theorem lift_beta (f : \u03b1 \u2192 \u03b2) (c) (a : \u03b1) : lift f c (mk a) = f a := rfl\n\n@[reducible, elab_as_eliminator]\nprotected def lift_on (q : trunc \u03b1) (f : \u03b1 \u2192 \u03b2)\n  (c : \u2200 a b : \u03b1, f a = f b) : \u03b2 := lift f c q\n\n@[elab_as_eliminator]\nprotected theorem induction_on {\u03b2 : trunc \u03b1 \u2192 Prop} (q : trunc \u03b1)\n  (h : \u2200 a, \u03b2 (mk a)) : \u03b2 q := ind h q\n\ntheorem exists_rep (q : trunc \u03b1) : \u2203 a : \u03b1, mk a = q := quot.exists_rep q\n\nattribute [elab_as_eliminator]\nprotected theorem induction_on\u2082\n   {C : trunc \u03b1 \u2192 trunc \u03b2 \u2192 Prop} (q\u2081 : trunc \u03b1) (q\u2082 : trunc \u03b2) (h : \u2200 a b, C (mk a) (mk b)) : C q\u2081 q\u2082 :=\ntrunc.induction_on q\u2081 $ \u03bb a\u2081, trunc.induction_on q\u2082 (h a\u2081)\n\nprotected theorem eq (a b : trunc \u03b1) : a = b :=\ntrunc.induction_on\u2082 a b (\u03bb x y, quot.sound trivial)\n\ninstance : subsingleton (trunc \u03b1) := \u27e8trunc.eq\u27e9\n\ndef bind (q : trunc \u03b1) (f : \u03b1 \u2192 trunc \u03b2) : trunc \u03b2 :=\ntrunc.lift_on q f (\u03bb a b, trunc.eq _ _)\n\ndef map (f : \u03b1 \u2192 \u03b2) (q : trunc \u03b1) : trunc \u03b2 := bind q (trunc.mk \u2218 f)\n\ninstance : monad trunc :=\n{ pure := @trunc.mk,\n  bind := @trunc.bind }\n\ninstance : is_lawful_monad trunc :=\n{ id_map := \u03bb \u03b1 q, trunc.eq _ _,\n  pure_bind := \u03bb \u03b1 \u03b2 q f, rfl,\n  bind_assoc := \u03bb \u03b1 \u03b2 \u03b3 x f g, trunc.eq _ _ }\n\nvariable {C : trunc \u03b1 \u2192 Sort*}\n\n@[reducible, elab_as_eliminator]\nprotected def rec\n   (f : \u03a0 a, C (mk a)) (h : \u2200 (a b : \u03b1), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n   (q : trunc \u03b1) : C q :=\nquot.rec f (\u03bb a b _, h a b) q\n\n@[reducible, elab_as_eliminator]\nprotected def rec_on (q : trunc \u03b1) (f : \u03a0 a, C (mk a))\n  (h : \u2200 (a b : \u03b1), (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   [\u2200 a, subsingleton (C (mk a))] (q : trunc \u03b1) (f : \u03a0 a, C (mk a)) : C q :=\ntrunc.rec f (\u03bb a b, subsingleton.elim _ (f b)) q\n\n/-- Noncomputably extract a representative of `trunc \u03b1` (using the axiom of choice). -/\nnoncomputable def out : trunc \u03b1 \u2192 \u03b1 := quot.out\n\n@[simp] theorem out_eq (q : trunc \u03b1) : mk q.out = q := trunc.eq _ _\n\nend trunc\n\ntheorem nonempty_of_trunc (q : trunc \u03b1) : nonempty \u03b1 :=\nlet \u27e8a, _\u27e9 := q.exists_rep in \u27e8a\u27e9\n\nnamespace quotient\nvariables {\u03b3 : Sort*} {\u03c6 : Sort*}\n  {s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2} {s\u2083 : setoid \u03b3}\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 : \u03b1) : quotient s\u2081 := quot.mk s\u2081.1 a\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on' (q : quotient s\u2081) (f : \u03b1 \u2192 \u03c6)\n  (h : \u2200 a b, @setoid.r \u03b1 s\u2081 a b \u2192 f a = f b) : \u03c6 := quotient.lift_on q f h\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on\u2082' (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082, @setoid.r \u03b1 s\u2081 a\u2081 b\u2081 \u2192 @setoid.r \u03b2 s\u2082 a\u2082 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) : \u03b3 :=\nquotient.lift_on\u2082 q\u2081 q\u2082 f h\n\n@[elab_as_eliminator]\nprotected lemma ind' {p : quotient s\u2081 \u2192 Prop}\n  (h : \u2200 a, p (quotient.mk' a)) (q : quotient s\u2081) : p q :=\nquotient.ind h q\n\n@[elab_as_eliminator]\nprotected lemma ind\u2082' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Prop}\n  (h : \u2200 a\u2081 a\u2082, p (quotient.mk' a\u2081) (quotient.mk' a\u2082))\n  (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) : p q\u2081 q\u2082 :=\nquotient.ind\u2082 h q\u2081 q\u2082\n\n@[elab_as_eliminator]\nprotected lemma induction_on' {p : quotient s\u2081 \u2192 Prop} (q : quotient s\u2081)\n  (h : \u2200 a, p (quotient.mk' a)) : p q := quotient.induction_on q h\n\n@[elab_as_eliminator]\nprotected lemma induction_on\u2082' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Prop} (q\u2081 : quotient s\u2081)\n  (q\u2082 : quotient s\u2082) (h : \u2200 a\u2081 a\u2082, p (quotient.mk' a\u2081) (quotient.mk' a\u2082)) : p q\u2081 q\u2082 :=\nquotient.induction_on\u2082 q\u2081 q\u2082 h\n\n@[elab_as_eliminator]\nprotected lemma induction_on\u2083' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 quotient s\u2083 \u2192 Prop}\n  (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (q\u2083 : quotient s\u2083)\n  (h : \u2200 a\u2081 a\u2082 a\u2083, p (quotient.mk' a\u2081) (quotient.mk' a\u2082) (quotient.mk' a\u2083)) : p q\u2081 q\u2082 q\u2083 :=\nquotient.induction_on\u2083 q\u2081 q\u2082 q\u2083 h\n\nlemma exact' {a b : \u03b1} :\n  (quotient.mk' a : quotient s\u2081) = quotient.mk' b \u2192 @setoid.r _ s\u2081 a b :=\nquotient.exact\n\nlemma sound' {a b : \u03b1} : @setoid.r _ s\u2081 a b \u2192 @quotient.mk' \u03b1 s\u2081 a = quotient.mk' b :=\nquotient.sound\n\n@[simp] protected lemma eq' {a b : \u03b1} : @quotient.mk' \u03b1 s\u2081 a = quotient.mk' b \u2194 @setoid.r _ s\u2081 a b :=\nquotient.eq\n\nnoncomputable def out' (a : quotient s\u2081) : \u03b1 := quotient.out a\n\n@[simp] theorem out_eq' (q : quotient s\u2081) : quotient.mk' q.out' = q := q.out_eq\n\ntheorem mk_out' (a : \u03b1) : @setoid.r \u03b1 s\u2081 (quotient.mk' a : quotient s\u2081).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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u2264 q`\nmeans that `p \u2286 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 \u2192\u2097[R] M\u2082` for the type of linear maps from `M` to `M\u2082` over the\n  ring `R`.\n* We introduce the notations `M \u2243\u2097 M\u2082` and `M \u2243\u2097[R] M\u2082` for `linear_equiv M M\u2082`. In the first, the\n  ring `R` is implicit.\n* We introduce the notation `R \u2219 v` for the span of a singleton, `submodule.span R {v}`.  This is\n  `\\.`, not the same as the scalar multiplication `\u2022`/`\\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 {\u03b1 : Type u} {\u03b2 : Type v} {R : Type w} {M : Type y} [HasZero \u03b2] [semiring R]\n    [add_comm_monoid M] [semimodule R M] {v : \u03b1 \u2192\u2080 \u03b2} {c : R} {h : \u03b1 \u2192 \u03b2 \u2192 M} :\n    c \u2022 sum v h = sum v fun (a : \u03b1) (b : \u03b2) => c \u2022 h a b :=\n  finset.smul_sum\n\nend finsupp\n\n\n/-- decomposing `x : \u03b9 \u2192 R` as a sum along the canonical basis -/\ntheorem pi_eq_sum_univ {\u03b9 : Type u} [fintype \u03b9] {R : Type v} [semiring R] (x : \u03b9 \u2192 R) :\n    x = finset.sum finset.univ fun (i : \u03b9) => x i \u2022 fun (j : \u03b9) => 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    comp f id = f :=\n  ext fun (x : M) => rfl\n\n@[simp] theorem id_comp {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    comp id f = f :=\n  ext fun (x : M) => rfl\n\ntheorem comp_assoc {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n    [semimodule R M] [semimodule R M\u2082] [semimodule R M\u2083] [semimodule R M\u2084] (f : linear_map R M M\u2082)\n    (g : linear_map R M\u2082 M\u2083) (h : linear_map R M\u2083 M\u2084) : comp (comp h g) f = comp h (comp g f) :=\n  rfl\n\n/-- The restriction of a linear map `f : M \u2192 M\u2082` to a submodule `p \u2286 M` gives a linear map\n`p \u2192 M\u2082`. -/\ndef dom_restrict {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (p : submodule R M) : linear_map R (\u21a5p) M\u2082 :=\n  comp f (submodule.subtype p)\n\n@[simp] theorem dom_restrict_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (f : linear_map R M M\u2082) (p : submodule R M) (x : \u21a5p) :\n    coe_fn (dom_restrict f p) x = coe_fn f \u2191x :=\n  rfl\n\n/-- A linear map `f : M\u2082 \u2192 M` whose values lie in a submodule `p \u2286 M` can be restricted to a\nlinear map M\u2082 \u2192 p. -/\ndef cod_restrict {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M\u2082 M) (h : \u2200 (c : M\u2082), coe_fn f c \u2208 p) : linear_map R M\u2082 \u21a5p :=\n  mk (fun (c : M\u2082) => { val := coe_fn f c, property := h c }) sorry sorry\n\n@[simp] theorem cod_restrict_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M\u2082 M) {h : \u2200 (c : M\u2082), coe_fn f c \u2208 p} (x : M\u2082) :\n    \u2191(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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (p : submodule R M\u2082) (h : \u2200 (b : M), coe_fn f b \u2208 p)\n    (g : linear_map R M\u2083 M) :\n    comp (cod_restrict p f h) g = cod_restrict p (comp f g) fun (b : M\u2083) => h (coe_fn g b) :=\n  ext fun (b : M\u2083) => rfl\n\n@[simp] theorem subtype_comp_cod_restrict {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (f : linear_map R M M\u2082) (p : submodule R M\u2082) (h : \u2200 (b : M), coe_fn f b \u2208 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 : \u2200 (x : M), x \u2208 p \u2192 coe_fn f x \u2208 p) :\n    linear_map R \u21a5p \u21a5p :=\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 : \u2200 (x : M), x \u2208 p \u2192 coe_fn f x \u2208 p) (x : \u21a5p) :\n    coe_fn (restrict f hf) x =\n        { val := coe_fn f \u2191x, 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 : \u2200 (x : M), x \u2208 p \u2192 coe_fn f x \u2208 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 : \u2200 (x : M), x \u2208 p \u2192 coe_fn f x \u2208 p) :\n    restrict f hf =\n        cod_restrict p (dom_restrict f p) fun (x : \u21a5p) => 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 : \u2200 (x : M), coe_fn f x \u2208 p) :\n    (restrict f fun (x : M) (_x : x \u2208 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : HasZero (linear_map R M M\u2082) :=\n  { zero := mk (fun (_x : M) => 0) sorry sorry }\n\nprotected instance inhabited {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    Inhabited (linear_map R M M\u2082) :=\n  { default := 0 }\n\n@[simp] theorem zero_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (x : M) : coe_fn 0 x = 0 :=\n  rfl\n\n@[simp] theorem default_def {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : Inhabited.default = 0 :=\n  rfl\n\nprotected instance unique_of_left {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] [subsingleton M] :\n    unique (linear_map R M M\u2082) :=\n  unique.mk { default := Inhabited.default } sorry\n\nprotected instance unique_of_right {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] [subsingleton M\u2082] :\n    unique (linear_map R M M\u2082) :=\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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : Add (linear_map R M M\u2082) :=\n  { add :=\n      fun (f g : linear_map R M M\u2082) => 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (g : linear_map R M M\u2082) (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\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    add_comm_monoid (linear_map R M M\u2082) :=\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\u2082 : Type w}\n    [semiring R] [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (a : M) : is_add_monoid_hom fun (f : linear_map R M M\u2082) => coe_fn f a :=\n  is_add_monoid_hom.mk rfl\n\ntheorem add_comp {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) (h : linear_map R M\u2082 M\u2083) :\n    comp (h + g) f = comp h f + comp g f :=\n  rfl\n\ntheorem comp_add {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M M\u2082) (h : linear_map R M\u2082 M\u2083) :\n    comp h (f + g) = comp h f + comp h g :=\n  sorry\n\ntheorem sum_apply {R : Type u} {M : Type v} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (t : finset \u03b9)\n    (f : \u03b9 \u2192 linear_map R M M\u2082) (b : M) :\n    coe_fn (finset.sum t fun (d : \u03b9) => f d) b = finset.sum t fun (d : \u03b9) => coe_fn (f d) b :=\n  Eq.symm (finset.sum_hom t fun (g : linear_map R M M\u2082) => coe_fn g b)\n\n/-- `\u03bbb, f b \u2022 x` is a linear map. -/\ndef smul_right {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M\u2082 R) (x : M) :\n    linear_map R M\u2082 M :=\n  mk (fun (b : M\u2082) => coe_fn f b \u2022 x) sorry sorry\n\n@[simp] theorem smul_right_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (f : linear_map R M\u2082 R) (x : M) (c : M\u2082) : coe_fn (smul_right f x) c = coe_fn f c \u2022 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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) : comp f 0 = 0 :=\n  sorry\n\n@[simp] theorem zero_comp {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) : comp 0 f = 0 :=\n  rfl\n\ntheorem coe_fn_sum {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b9 : Type u_1} (t : finset \u03b9)\n    (f : \u03b9 \u2192 linear_map R M M\u2082) :\n    \u21d1(finset.sum t fun (i : \u03b9) => f i) = finset.sum t fun (i : \u03b9) => \u21d1(f i) :=\n  add_monoid_hom.map_sum (add_monoid_hom.mk to_fun rfl fun (x y : linear_map R M M\u2082) => rfl)\n    (fun (x : \u03b9) => 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 : \u03b9 \u2192 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} {\u03b9 : Type x} [semiring R] [add_comm_monoid M]\n    [semimodule R M] [fintype \u03b9] (f : linear_map R (\u03b9 \u2192 R) M) (x : \u03b9 \u2192 R) :\n    coe_fn f x =\n        finset.sum finset.univ fun (i : \u03b9) => x i \u2022 coe_fn f fun (j : \u03b9) => 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\u2082 : Type w) [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : linear_map R (M \u00d7 M\u2082) 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\u2082 : Type w) [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : linear_map R (M \u00d7 M\u2082) M\u2082 :=\n  mk prod.snd sorry sorry\n\n@[simp] theorem fst_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (x : M \u00d7 M\u2082) :\n    coe_fn (fst R M M\u2082) x = prod.fst x :=\n  rfl\n\n@[simp] theorem snd_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (x : M \u00d7 M\u2082) :\n    coe_fn (snd R M M\u2082) 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\u2082 : Type w} {M\u2083 : Type y} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082] [semimodule R M\u2083]\n    (f : linear_map R M M\u2082) (g : linear_map R M M\u2083) : linear_map R M (M\u2082 \u00d7 M\u2083) :=\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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M M\u2083) (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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M M\u2083) :\n    comp (fst R M\u2082 M\u2083) (prod f g) = f :=\n  ext fun (x : M) => Eq.refl (coe_fn (comp (fst R M\u2082 M\u2083) (prod f g)) x)\n\n@[simp] theorem snd_prod {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M M\u2083) :\n    comp (snd R M\u2082 M\u2083) (prod f g) = g :=\n  ext fun (x : M) => Eq.refl (coe_fn (comp (snd R M\u2082 M\u2083) (prod f g)) x)\n\n@[simp] theorem pair_fst_snd {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    prod (fst R M M\u2082) (snd R M M\u2082) = id :=\n  sorry\n\n/-- The left injection into a product is a linear map. -/\ndef inl (R : Type u) (M : Type v) (M\u2082 : Type w) [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : linear_map R M (M \u00d7 M\u2082) :=\n  mk \u21d1(add_monoid_hom.inl M M\u2082) sorry sorry\n\n/-- The right injection into a product is a linear map. -/\ndef inr (R : Type u) (M : Type v) (M\u2082 : Type w) [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : linear_map R M\u2082 (M \u00d7 M\u2082) :=\n  mk \u21d1(add_monoid_hom.inr M M\u2082) sorry sorry\n\n@[simp] theorem inl_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (x : M) :\n    coe_fn (inl R M M\u2082) x = (x, 0) :=\n  rfl\n\n@[simp] theorem inr_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (x : M\u2082) :\n    coe_fn (inr R M M\u2082) x = (0, x) :=\n  rfl\n\ntheorem inl_injective {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : function.injective \u21d1(inl R M M\u2082) :=\n  sorry\n\ntheorem inr_injective {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : function.injective \u21d1(inr R M M\u2082) :=\n  sorry\n\n/-- The coprod function `\u03bb x : M \u00d7 M\u2082, f x.1 + g x.2` is a linear map. -/\ndef coprod {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082] [semimodule R M\u2083]\n    (f : linear_map R M M\u2083) (g : linear_map R M\u2082 M\u2083) : linear_map R (M \u00d7 M\u2082) M\u2083 :=\n  mk (fun (x : M \u00d7 M\u2082) => 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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2083) (g : linear_map R M\u2082 M\u2083) (x : M) (y : M\u2082) :\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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2083) (g : linear_map R M\u2082 M\u2083) :\n    comp (coprod f g) (inl R M M\u2082) = f :=\n  sorry\n\n@[simp] theorem coprod_inr {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2083) (g : linear_map R M\u2082 M\u2083) :\n    comp (coprod f g) (inr R M M\u2082) = g :=\n  sorry\n\n@[simp] theorem coprod_inl_inr {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    coprod (inl R M M\u2082) (inr R M M\u2082) = id :=\n  sorry\n\ntheorem fst_eq_coprod {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : fst R M M\u2082 = coprod id 0 :=\n  sorry\n\ntheorem snd_eq_coprod {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : snd R M M\u2082 = coprod 0 id :=\n  sorry\n\ntheorem inl_eq_prod {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : inl R M M\u2082 = prod id 0 :=\n  rfl\n\ntheorem inr_eq_prod {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : inr R M M\u2082 = prod 0 id :=\n  rfl\n\n/-- `prod.map` of two linear maps. -/\ndef prod_map {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n    [semimodule R M] [semimodule R M\u2082] [semimodule R M\u2083] [semimodule R M\u2084] (f : linear_map R M M\u2083)\n    (g : linear_map R M\u2082 M\u2084) : linear_map R (M \u00d7 M\u2082) (M\u2083 \u00d7 M\u2084) :=\n  prod (comp f (fst R M M\u2082)) (comp g (snd R M M\u2082))\n\n@[simp] theorem prod_map_apply {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z}\n    [semiring R] [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n    [semimodule R M] [semimodule R M\u2082] [semimodule R M\u2083] [semimodule R M\u2084] (f : linear_map R M M\u2083)\n    (g : linear_map R M\u2082 M\u2084) (x : M \u00d7 M\u2082) :\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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] : Neg (linear_map R M M\u2082) :=\n  { neg := fun (f : linear_map R M M\u2082) => mk (fun (b : M) => -coe_fn f b) sorry sorry }\n\n@[simp] theorem neg_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) (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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_group M\u2082] [add_comm_group M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) : 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] : Sub (linear_map R M M\u2082) :=\n  { sub :=\n      fun (f g : linear_map R M M\u2082) => 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (g : linear_map R M M\u2082) (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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_group M\u2082] [add_comm_group M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) (h : linear_map R M\u2082 M\u2083) :\n    comp (g - h) f = comp g f - comp h f :=\n  rfl\n\ntheorem comp_sub {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_group M\u2082] [add_comm_group M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M M\u2082) (h : linear_map R M\u2082 M\u2083) :\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\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    add_comm_group (linear_map R M M\u2082) :=\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\u2082 : Type w}\n    [semiring R] [add_comm_monoid M] [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (a : M) : is_add_group_hom fun (f : linear_map R M M\u2082) => coe_fn f a :=\n  is_add_group_hom.mk\n\nprotected instance has_scalar {R : Type u} {M : Type v} {M\u2082 : Type w} {S : Type u_1} [semiring R]\n    [monoid S] [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    [distrib_mul_action S M\u2082] [smul_comm_class R S M\u2082] : has_scalar S (linear_map R M M\u2082) :=\n  has_scalar.mk\n    fun (a : S) (f : linear_map R M M\u2082) => mk (fun (b : M) => a \u2022 coe_fn f b) sorry sorry\n\n@[simp] theorem smul_apply {R : Type u} {M : Type v} {M\u2082 : Type w} {S : Type u_1} [semiring R]\n    [monoid S] [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    [distrib_mul_action S M\u2082] [smul_comm_class R S M\u2082] (f : linear_map R M M\u2082) (a : S) (x : M) :\n    coe_fn (a \u2022 f) x = a \u2022 coe_fn f x :=\n  rfl\n\nprotected instance distrib_mul_action {R : Type u} {M : Type v} {M\u2082 : Type w} {S : Type u_1}\n    [semiring R] [monoid S] [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M]\n    [semimodule R M\u2082] [distrib_mul_action S M\u2082] [smul_comm_class R S M\u2082] :\n    distrib_mul_action S (linear_map R M M\u2082) :=\n  distrib_mul_action.mk sorry sorry\n\ntheorem smul_comp {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} {S : Type u_1} [semiring R]\n    [monoid S] [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M]\n    [semimodule R M\u2082] [semimodule R M\u2083] [distrib_mul_action S M\u2082] [smul_comm_class R S M\u2082] (a : S)\n    (g : linear_map R M\u2083 M\u2082) (f : linear_map R M M\u2083) : comp (a \u2022 g) f = a \u2022 comp g f :=\n  rfl\n\nprotected instance semimodule {R : Type u} {M : Type v} {M\u2082 : Type w} {S : Type u_1} [semiring R]\n    [semiring S] [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    [semimodule S M\u2082] [smul_comm_class R S M\u2082] : semimodule S (linear_map R M M\u2082) :=\n  semimodule.mk sorry sorry\n\n/-- Applying a linear map at `v : M`, seen as `S`-linear map from `M \u2192\u2097[R] M\u2082` to `M\u2082`.\n\n See `apply\u2097` for a version where `S = R` -/\ndef apply\u2097' {R : Type u} {M : Type v} {M\u2082 : Type w} (S : Type u_1) [semiring R] [semiring S]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] [semimodule S M\u2082]\n    [smul_comm_class R S M\u2082] (v : M) : linear_map S (linear_map R M M\u2082) M\u2082 :=\n  mk (fun (f : linear_map R M M\u2082) => coe_fn f v) sorry sorry\n\ntheorem comp_smul {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [comm_semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) (a : R) :\n    comp g (a \u2022 f) = a \u2022 comp g f :=\n  sorry\n\n/-- Composition by `f : M\u2082 \u2192 M\u2083` is a linear map from the space of linear maps `M \u2192 M\u2082`\nto the space of linear maps `M\u2082 \u2192 M\u2083`. -/\ndef comp_right {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [comm_semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M\u2082 M\u2083) :\n    linear_map R (linear_map R M M\u2082) (linear_map R M M\u2083) :=\n  mk (comp f) sorry sorry\n\n/-- Applying a linear map at `v : M`, seen as a linear map from `M \u2192\u2097[R] M\u2082` to `M\u2082`.\nSee also `linear_map.apply\u2097'` for a version that works with two different semirings. -/\ndef apply\u2097 {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (v : M) :\n    linear_map R (linear_map R M M\u2082) M\u2082 :=\n  apply\u2097' 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\u2082 \u2192 M` parameterised by `f \u2208 M\u2082 \u2192 R`, `x \u2208 M`, is linear in `f`, `x`.\n-/\ndef smul_right\u2097 {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    linear_map R (linear_map R M\u2082 R) (linear_map R M (linear_map R M\u2082 M)) :=\n  mk (fun (f : linear_map R M\u2082 R) => mk (smul_right f) sorry sorry) sorry sorry\n\n@[simp] theorem smul_right\u2097_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (f : linear_map R M\u2082 R) (x : M) (c : M\u2082) :\n    coe_fn (coe_fn (coe_fn smul_right\u2097 f) x) c = coe_fn f c \u2022 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) => \u2200 {x : M}, x \u2208 p \u2192 x \u2208 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 \u2264 p' \u2194 \u2191p \u2286 \u2191p' :=\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 \u2264 p' \u2194 \u2200 (x : M), x \u2208 p \u2192 x \u2208 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' \u2194 \u2191p \u2282 \u2191p' :=\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    \u00acp \u2264 p' \u2194 \u2203 (x : M), \u2203 (H : x \u2208 p), \u00acx \u2208 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' \u2192 \u2203 (x : M), \u2203 (H : x \u2208 p'), \u00acx \u2208 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' \u2194 p \u2264 p' \u2227 \u2203 (x : M), \u2203 (H : x \u2208 p'), \u00acx \u2208 p :=\n  sorry\n\n/-- If two submodules `p` and `p'` satisfy `p \u2286 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 \u2264 p') : linear_map R \u21a5p \u21a5p' :=\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 \u2264 p') (x : \u21a5p) :\n    \u2191(coe_fn (of_le h) x) = \u2191x :=\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 \u2264 p') (x : \u21a5p) :\n    coe_fn (of_le h) x = { val := \u2191x, 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 \u2264 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 := \u22a5 }\n\n@[simp] theorem bot_coe {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M]\n    [semimodule R M] : \u2191\u22a5 = 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 \u2208 \u22a5 \u2194 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 : \u22a5 < I) : \u2203 (a : \u21a5I), a \u2260 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 \u22a5 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 = \u22a5 \u2194 \u2200 (x : M), x \u2208 p \u2192 x = 0 :=\n  { mp := fun (h : p = \u22a5) => Eq.symm h \u25b8 fun (x : M) (hx : x \u2208 \u22a5) => iff.mp (mem_bot R) hx,\n    mpr :=\n      fun (h : \u2200 (x : M), x \u2208 p \u2192 x = 0) =>\n        iff.mpr eq_bot_iff fun (x : M) (hx : x \u2208 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 \u2260 \u22a5 \u2194 \u2203 (x : M), \u2203 (H : x \u2208 p), x \u2260 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] : \u2191\u22a4 = 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 \u2208 \u22a4 :=\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 = \u22a5 :=\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 \u22a4 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 \u2208 S) => \u2191s) 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 (\u2191p \u2229 \u2191p') 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 \u2264 x \u2227 b \u2264 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) => \u2200 (t' : submodule R M), t' \u2208 tt \u2192 t' \u2264 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 \u22a5 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 \u2294 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 = \u22a5 :=\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 = \u22a4 \u2194 \u2200 (x : M), x \u2208 p :=\n  iff.trans eq_top_iff\n    { mp := fun (h : \u22a4 \u2264 p) (x : M) => h trivial,\n      mpr := fun (h : \u2200 (x : M), x \u2208 p) (x : M) (_x : x \u2208 \u22a4) => 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] : \u22a5 \u2260 \u22a4 :=\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) : \u2191p \u2293 \u2191p' = \u2191p \u2229 \u2191p' :=\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 \u2208 p \u2293 p' \u2194 x \u2208 p \u2227 x \u2208 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    \u2191(Inf P) = set.Inter fun (p : submodule R M) => set.Inter fun (H : p \u2208 P) => \u2191p :=\n  rfl\n\n@[simp] theorem infi_coe {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {\u03b9 : Sort u_1} (p : \u03b9 \u2192 submodule R M) :\n    \u2191(infi fun (i : \u03b9) => p i) = set.Inter fun (i : \u03b9) => \u2191(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 \u2208 Inf S \u2194 \u2200 (p : submodule R M), p \u2208 S \u2192 x \u2208 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} {\u03b9 : Sort u_1} (p : \u03b9 \u2192 submodule R M) :\n    (x \u2208 infi fun (i : \u03b9) => p i) \u2194 \u2200 (i : \u03b9), x \u2208 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' \u2194 \u2200 (x : M), x \u2208 p \u2192 x \u2208 p' \u2192 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' \u2194 \u2200 (x : M), x \u2208 p \u2192 \u2200 (y : M), y \u2208 p' \u2192 x = y \u2192 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 : \u21a5p} :\n    \u2191x \u2208 p' \u2194 x = 0 :=\n  { mp :=\n      fun (hx : \u2191x \u2208 p') => iff.mp coe_eq_zero (iff.mp disjoint_def h (\u2191x) (subtype.property x) hx),\n    mpr := fun (h : x = 0) => Eq.symm h \u25b8 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 : \u21a5p'} :\n    \u2191x \u2208 p \u2194 x = 0 :=\n  { mp :=\n      fun (hx : \u2191x \u2208 p) => iff.mp coe_eq_zero (iff.mp disjoint_def h (\u2191x) hx (subtype.property x)),\n    mpr := fun (h : x = 0) => Eq.symm h \u25b8 zero_mem p }\n\n/-- The pushforward of a submodule `p \u2286 M` by `f : M \u2192 M\u2082` -/\ndef map {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (p : submodule R M) : submodule R M\u2082 :=\n  mk (\u21d1f '' \u2191p) sorry sorry sorry\n\n@[simp] theorem map_coe {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (p : submodule R M) : \u2191(map f p) = \u21d1f '' \u2191p :=\n  rfl\n\n@[simp] theorem mem_map {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} {x : M\u2082} : x \u2208 map f p \u2194 \u2203 (y : M), y \u2208 p \u2227 coe_fn f y = x :=\n  iff.rfl\n\ntheorem mem_map_of_mem {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} {r : M} (h : r \u2208 p) : coe_fn f r \u2208 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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) (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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} {p' : submodule R M} : p \u2264 p' \u2192 map f p \u2264 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M) : map 0 p = \u22a5 :=\n  sorry\n\n/-- The pullback of a submodule `p \u2286 M\u2082` along `f : M \u2192 M\u2082` -/\ndef comap {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (p : submodule R M\u2082) : submodule R M :=\n  mk (\u21d1f \u207b\u00b9' \u2191p) sorry sorry sorry\n\n@[simp] theorem comap_coe {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (p : submodule R M\u2082) : \u2191(comap f p) = \u21d1f \u207b\u00b9' \u2191p :=\n  rfl\n\n@[simp] theorem mem_comap {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {x : M} {f : linear_map R M M\u2082}\n    {p : submodule R M\u2082} : x \u2208 comap f p \u2194 coe_fn f x \u2208 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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) (p : submodule R M\u2083) :\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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {q : submodule R M\u2082} {q' : submodule R M\u2082} : q \u2264 q' \u2192 comap f q \u2264 comap f q' :=\n  set.preimage_mono\n\ntheorem map_le_iff_le_comap {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} {q : submodule R M\u2082} : map f p \u2264 q \u2194 p \u2264 comap f q :=\n  set.image_subset_iff\n\ntheorem gc_map_comap {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    galois_connection (map f) (comap f) :=\n  fun (a : submodule R M) (b : submodule R M\u2082) =>\n    idRhs (map f a \u2264 b \u2194 a \u2264 comap f b) map_le_iff_le_comap\n\n@[simp] theorem map_bot {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) : map f \u22a5 = \u22a5 :=\n  galois_connection.l_bot (gc_map_comap f)\n\n@[simp] theorem map_sup {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M) (p' : submodule R M)\n    (f : linear_map R M M\u2082) : map f (p \u2294 p') = map f p \u2294 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b9 : Sort u_1} (f : linear_map R M M\u2082)\n    (p : \u03b9 \u2192 submodule R M) : map f (supr fun (i : \u03b9) => p i) = supr fun (i : \u03b9) => 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    comap f \u22a4 = \u22a4 :=\n  rfl\n\n@[simp] theorem comap_inf {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (q : submodule R M\u2082)\n    (q' : submodule R M\u2082) (f : linear_map R M M\u2082) : comap f (q \u2293 q') = comap f q \u2293 comap f q' :=\n  rfl\n\n@[simp] theorem comap_infi {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b9 : Sort u_1} (f : linear_map R M M\u2082)\n    (p : \u03b9 \u2192 submodule R M\u2082) :\n    comap f (infi fun (i : \u03b9) => p i) = infi fun (i : \u03b9) => 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (q : submodule R M\u2082) : comap 0 q = \u22a4 :=\n  sorry\n\ntheorem map_comap_le {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (q : submodule R M\u2082) : map f (comap f q) \u2264 q :=\n  galois_connection.l_u_le (gc_map_comap f) q\n\ntheorem le_comap_map {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (p : submodule R M) : p \u2264 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\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    {f : linear_map R M M\u2082} {p : submodule R M} {p' : submodule R M\u2082} :\n    map f p \u2293 p' = map f (p \u2293 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 \u2293 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 : \u21a5\u22a5) : b = 0 :=\n  sorry\n\n/-- The span of a set `s \u2286 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 \u2286 \u2191p)\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 \u2208 span R s \u2194 \u2200 (p : submodule R M), s \u2286 \u2191p \u2192 x \u2208 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 \u2286 \u2191(span R s) :=\n  fun (x : M) (h : x \u2208 s) => iff.mpr mem_span fun (p : submodule R M) (hp : s \u2286 \u2191p) => 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 \u2264 p \u2194 s \u2286 \u2191p :=\n  { mp := set.subset.trans subset_span,\n    mpr := fun (ss : s \u2286 \u2191p) (x : M) (h : x \u2208 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 \u2286 t) : span R s \u2264 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\u2081 : s \u2286 \u2191p) (h\u2082 : p \u2264 span R s) : span R s = p :=\n  le_antisymm (iff.mpr span_le h\u2081) h\u2082\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 \u2191p = p :=\n  span_eq_of_le p (set.subset.refl \u2191p) subset_span\n\ntheorem map_span {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) (s : set M) :\n    map f (span R s) = span R (\u21d1f '' s) :=\n  sorry\n\n/- See also `span_preimage_eq` below. -/\n\ntheorem span_preimage_le {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) (s : set M\u2082) :\n    span R (\u21d1f \u207b\u00b9' s) \u2264 comap f (span R s) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (span R (\u21d1f \u207b\u00b9' s) \u2264 comap f (span R s))) (propext span_le)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u21d1f \u207b\u00b9' s \u2286 \u2191(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 \u2192 Prop} (h : x \u2208 span R s) (Hs : \u2200 (x : M), x \u2208 s \u2192 p x) (H0 : p 0)\n    (H1 : \u2200 (x y : M), p x \u2192 p y \u2192 p (x + y)) (H2 : \u2200 (a : R) (x : M), p x \u2192 p (a \u2022 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 : \u2191(span R s) \u2264 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 \u2205 = \u22a5 :=\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 = \u22a4 :=\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 \u222a t) = span R s \u2294 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    {\u03b9 : Sort u_1} (s : \u03b9 \u2192 set M) :\n    span R (set.Union fun (i : \u03b9) => s i) = supr fun (i : \u03b9) => 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 \u2208 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] {\u03b9 : Sort u_1} [h\u03b9 : Nonempty \u03b9] (S : \u03b9 \u2192 submodule R M)\n    (H : directed LessEq S) : \u2191(supr S) = set.Union fun (i : \u03b9) => \u2191(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 \u2208 S \u2192 x \u2208 S \u2294 T :=\n  (fun (this : S \u2264 S \u2294 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 \u2208 T \u2192 x \u2208 S \u2294 T :=\n  (fun (this : T \u2264 S \u2294 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    {\u03b9 : Sort u_1} {b : M} {p : \u03b9 \u2192 submodule R M} (i : \u03b9) (h : b \u2208 p i) :\n    b \u2208 supr fun (i : \u03b9) => p i :=\n  (fun (this : p i \u2264 supr fun (i : \u03b9) => 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 \u2208 S) {x : M} : x \u2208 s \u2192 x \u2208 Sup S :=\n  (fun (this : s \u2264 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] {\u03b9 : Sort u_1} [Nonempty \u03b9] (S : \u03b9 \u2192 submodule R M) (H : directed LessEq S)\n    {x : M} : x \u2208 supr S \u2194 \u2203 (i : \u03b9), x \u2208 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 \u2208 Sup s \u2194 \u2203 (y : submodule R M), \u2203 (H : y \u2208 s), z \u2208 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 \u2208 p \u2294 p' \u2194 \u2203 (y : M), \u2203 (H : y \u2208 p), \u2203 (z : M), \u2203 (H : z \u2208 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 \u2208 p \u2294 p' \u2194 \u2203 (y : \u21a5p), \u2203 (z : \u21a5p'), \u2191y + \u2191z = 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 \u2208 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 \u2260 0) : nontrivial \u21a5(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 \u2208 span R (singleton y) \u2194 \u2203 (a : R), a \u2022 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\u2080 : M} :\n    s \u2264 span R (singleton v\u2080) \u2194 \u2200 (v : M), v \u2208 s \u2192 \u2203 (r : R), r \u2022 v\u2080 = 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) = \u22a5 :=\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) : \u2191(span R (singleton y)) = set.range fun (_x : R) => _x \u2022 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 \u2022 x)) \u2264 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 \u2260 0) : span K (singleton (r \u2022 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)) \u2194 x \u2208 s \u2192 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 \u2260 0) :\n    disjoint p (span K (singleton x)) \u2194 \u00acx \u2208 p :=\n  iff.trans disjoint_span_singleton\n    { mp := fun (h\u2081 : x \u2208 p \u2192 x = 0) (h\u2082 : x \u2208 p) => x0 (h\u2081 h\u2082),\n      mpr := fun (h\u2081 : \u00acx \u2208 p) (h\u2082 : x \u2208 p) => false.elim (h\u2081 h\u2082) }\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 \u2208 span R (insert y s) \u2194 \u2203 (a : R), \u2203 (z : M), \u2203 (H : z \u2208 span R s), x = a \u2022 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 \u2208 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 \u2191(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 = \u22a5 \u2194 \u2200 (x : M), x \u2208 s \u2192 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) = \u22a5 \u2194 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 = \u22a5 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (span R 0 = \u22a5)) (Eq.symm set.singleton_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (span R (singleton 0) = \u22a5)) (propext span_singleton_eq_bot)))\n      (Eq.refl 0))\n\n@[simp] theorem span_image {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {s : set M} (f : linear_map R M M\u2082) :\n    span R (\u21d1f '' s) = map f (span R s) :=\n  span_eq_of_le (map f (span R s)) (set.image_subset (\u21d1f) 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    {\u03b9 : Sort w} (p : \u03b9 \u2192 submodule R M) :\n    (supr fun (i : \u03b9) => p i) = span R (set.Union fun (i : \u03b9) => \u2191(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) \u2264 p \u2194 m \u2208 p :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (span R (singleton m) \u2264 p \u2194 m \u2208 p)) (propext span_le)))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (singleton m \u2286 \u2191p \u2194 m \u2208 p)) (propext set.singleton_subset_iff)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (m \u2208 \u2191p \u2194 m \u2208 p)) (propext (mem_coe p))))\n        (iff.refl (m \u2208 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) \u2194 \u00aca \u2208 I :=\n  sorry\n\ntheorem mem_supr {R : Type u} {M : Type v} [semiring R] [add_comm_monoid M] [semimodule R M]\n    {\u03b9 : Sort w} (p : \u03b9 \u2192 submodule R M) {m : M} :\n    (m \u2208 supr fun (i : \u03b9) => p i) \u2194 \u2200 (N : submodule R M), (\u2200 (i : \u03b9), p i \u2264 N) \u2192 m \u2208 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 \u2208 span R S) :\n    \u2203 (T : finset M), \u2191T \u2286 S \u2227 x \u2208 span R \u2191T :=\n  sorry\n\n/-- The product of two submodules is a submodule. -/\ndef prod {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (q : submodule R M\u2082) : submodule R (M \u00d7 M\u2082) :=\n  mk (set.prod \u2191p \u2191q) sorry sorry sorry\n\n@[simp] theorem prod_coe {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (q : submodule R M\u2082) : \u2191(prod p q) = set.prod \u2191p \u2191q :=\n  rfl\n\n@[simp] theorem mem_prod {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {p : submodule R M} {q : submodule R M\u2082}\n    {x : M \u00d7 M\u2082} : x \u2208 prod p q \u2194 prod.fst x \u2208 p \u2227 prod.snd x \u2208 q :=\n  set.mem_prod\n\ntheorem span_prod_le {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (s : set M) (t : set M\u2082) :\n    span R (set.prod s t) \u2264 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : prod \u22a4 \u22a4 = \u22a4 :=\n  sorry\n\n@[simp] theorem prod_bot {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : prod \u22a5 \u22a5 = \u22a5 :=\n  sorry\n\ntheorem prod_mono {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {p : submodule R M} {p' : submodule R M}\n    {q : submodule R M\u2082} {q' : submodule R M\u2082} : p \u2264 p' \u2192 q \u2264 q' \u2192 prod p q \u2264 prod p' q' :=\n  set.prod_mono\n\n@[simp] theorem prod_inf_prod {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (p' : submodule R M) (q : submodule R M\u2082) (q' : submodule R M\u2082) :\n    prod p q \u2293 prod p' q' = prod (p \u2293 p') (q \u2293 q') :=\n  coe_injective set.prod_inter_prod\n\n@[simp] theorem prod_sup_prod {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (p' : submodule R M) (q : submodule R M\u2082) (q' : submodule R M\u2082) :\n    prod p q \u2294 prod p' q' = prod (p \u2294 p') (q \u2294 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) : -\u2191p = \u2191p :=\n  set.ext fun (x : M) => neg_mem_iff p\n\n@[simp] protected theorem map_neg {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M M\u2082) : 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 \u2208 span R (insert y s) \u2194 \u2203 (a : R), x + a \u2022 y \u2208 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 \u2248 y` iff `y - x \u2208 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 \u2208 p) sorry\n\n/-- The quotient of a module `M` by a submodule `p \u2286 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 \u2192 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 \u2194 x - y \u2208 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 \u2194 x \u2208 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\u2082' 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\u2082' 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 \u2022 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 \u2022 x) = r \u2022 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 < \u22a4) : nontrivial (quotient p) :=\n  sorry\n\nend quotient\n\n\ntheorem quot_hom_ext {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    {f : linear_map R (quotient p) M\u2082} {g : linear_map R (quotient p) M\u2082}\n    (h : \u2200 (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\u2082 : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V V\u2082)\n    (p : submodule K V\u2082) (a : K) (h : a \u2260 0) : comap (a \u2022 f) p = comap f p :=\n  sorry\n\ntheorem map_smul {K : Type u'} {V : Type v'} {V\u2082 : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V V\u2082)\n    (p : submodule K V) (a : K) (h : a \u2260 0) : map (a \u2022 f) p = map f p :=\n  sorry\n\ntheorem comap_smul' {K : Type u'} {V : Type v'} {V\u2082 : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V V\u2082)\n    (p : submodule K V\u2082) (a : K) : comap (a \u2022 f) p = infi fun (h : a \u2260 0) => comap f p :=\n  sorry\n\ntheorem map_smul' {K : Type u'} {V : Type v'} {V\u2082 : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V V\u2082)\n    (p : submodule K V) (a : K) : map (a \u2022 f) p = supr fun (h : a \u2260 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {s : set M} {f : linear_map R M M\u2082}\n    {g : linear_map R M M\u2082} (H : set.eq_on (\u21d1f) (\u21d1g) s) {x : M} (h : x \u2208 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 \u2208 (span R s : set M)`.\nSee `linear_map.eq_on_span` for a version that takes `h : x \u2208 span R s` as an argument. -/\ntheorem eq_on_span' {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {s : set M} {f : linear_map R M M\u2082}\n    {g : linear_map R M M\u2082} (H : set.eq_on (\u21d1f) (\u21d1g) s) : set.eq_on \u21d1f \u21d1g \u2191(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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {s : set M} {f : linear_map R M M\u2082}\n    {g : linear_map R M M\u2082} (hv : submodule.span R s = \u22a4) (h : set.eq_on (\u21d1f) (\u21d1g) 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 : \u03b9 \u2192 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\u2082 : Type w} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {v : \u03b9 \u2192 M}\n    {f : linear_map R M M\u2082} {g : linear_map R M M\u2082} (hv : submodule.span R (set.range v) = \u22a4)\n    (h : \u2200 (i : \u03b9), 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\u2082 : Type w} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b3 : Type u_1}\n    [HasZero \u03b3] (f : linear_map R M M\u2082) {t : \u03b9 \u2192\u2080 \u03b3} {g : \u03b9 \u2192 \u03b3 \u2192 M} :\n    coe_fn f (finsupp.sum t g) = finsupp.sum t fun (i : \u03b9) (d : \u03b3) => coe_fn f (g i d) :=\n  map_sum f\n\ntheorem coe_finsupp_sum {R : Type u} {M : Type v} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b3 : Type u_1}\n    [HasZero \u03b3] (t : \u03b9 \u2192\u2080 \u03b3) (g : \u03b9 \u2192 \u03b3 \u2192 linear_map R M M\u2082) :\n    \u21d1(finsupp.sum t g) = finsupp.sum t fun (i : \u03b9) (d : \u03b3) => \u21d1(g i d) :=\n  coe_fn_sum (finsupp.support t) fun (a : \u03b9) => g a (coe_fn t a)\n\n@[simp] theorem finsupp_sum_apply {R : Type u} {M : Type v} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b3 : Type u_1}\n    [HasZero \u03b3] (t : \u03b9 \u2192\u2080 \u03b3) (g : \u03b9 \u2192 \u03b3 \u2192 linear_map R M M\u2082) (b : M) :\n    coe_fn (finsupp.sum t g) b = finsupp.sum t fun (i : \u03b9) (d : \u03b3) => coe_fn (g i d) b :=\n  sum_apply (finsupp.support t) (fun (a : \u03b9) => g a (coe_fn t a)) b\n\n@[simp] theorem map_dfinsupp_sum {R : Type u} {M : Type v} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b3 : \u03b9 \u2192 Type u_1}\n    [DecidableEq \u03b9] [(i : \u03b9) \u2192 HasZero (\u03b3 i)] [(i : \u03b9) \u2192 (x : \u03b3 i) \u2192 Decidable (x \u2260 0)]\n    (f : linear_map R M M\u2082) {t : dfinsupp fun (i : \u03b9) => \u03b3 i} {g : (i : \u03b9) \u2192 \u03b3 i \u2192 M} :\n    coe_fn f (dfinsupp.sum t g) = dfinsupp.sum t fun (i : \u03b9) (d : \u03b3 i) => coe_fn f (g i d) :=\n  map_sum f\n\ntheorem coe_dfinsupp_sum {R : Type u} {M : Type v} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b3 : \u03b9 \u2192 Type u_1}\n    [DecidableEq \u03b9] [(i : \u03b9) \u2192 HasZero (\u03b3 i)] [(i : \u03b9) \u2192 (x : \u03b3 i) \u2192 Decidable (x \u2260 0)]\n    (t : dfinsupp fun (i : \u03b9) => \u03b3 i) (g : (i : \u03b9) \u2192 \u03b3 i \u2192 linear_map R M M\u2082) :\n    \u21d1(dfinsupp.sum t g) = dfinsupp.sum t fun (i : \u03b9) (d : \u03b3 i) => \u21d1(g i d) :=\n  coe_fn_sum (dfinsupp.support t) fun (i : \u03b9) => g i (coe_fn t i)\n\n@[simp] theorem dfinsupp_sum_apply {R : Type u} {M : Type v} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {\u03b3 : \u03b9 \u2192 Type u_1}\n    [DecidableEq \u03b9] [(i : \u03b9) \u2192 HasZero (\u03b3 i)] [(i : \u03b9) \u2192 (x : \u03b3 i) \u2192 Decidable (x \u2260 0)]\n    (t : dfinsupp fun (i : \u03b9) => \u03b3 i) (g : (i : \u03b9) \u2192 \u03b3 i \u2192 linear_map R M M\u2082) (b : M) :\n    coe_fn (dfinsupp.sum t g) b = dfinsupp.sum t fun (i : \u03b9) (d : \u03b3 i) => coe_fn (g i d) b :=\n  sum_apply (dfinsupp.support t) (fun (i : \u03b9) => g i (coe_fn t i)) b\n\ntheorem map_cod_restrict {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M\u2082 M) (h : \u2200 (c : M\u2082), coe_fn f c \u2208 p) (p' : submodule R M\u2082) :\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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M\u2082 M) (hf : \u2200 (c : M\u2082), coe_fn f c \u2208 p) (p' : submodule R \u21a5p) :\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 \u2192 M\u2082` is a submodule of `M\u2082`. -/\ndef range {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    submodule R M\u2082 :=\n  submodule.map f \u22a4\n\ntheorem range_coe {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    \u2191(range f) = set.range \u21d1f :=\n  set.image_univ\n\n@[simp] theorem mem_range {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} {x : M\u2082} :\n    x \u2208 range f \u2194 \u2203 (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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) (x : M) :\n    coe_fn f x \u2208 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 = \u22a4 :=\n  submodule.map_id \u22a4\n\ntheorem range_comp {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) :\n    range (comp g f) = submodule.map g (range f) :=\n  submodule.map_comp f g \u22a4\n\ntheorem range_comp_le_range {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) :\n    range (comp g f) \u2264 range g :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (range (comp g f) \u2264 range g)) (range_comp f g)))\n    (submodule.map_mono le_top)\n\ntheorem range_eq_top {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} :\n    range f = \u22a4 \u2194 function.surjective \u21d1f :=\n  sorry\n\ntheorem range_le_iff_comap {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M\u2082} : range f \u2264 p \u2194 submodule.comap f p = \u22a4 :=\n  sorry\n\ntheorem map_le_range {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} : submodule.map f p \u2264 range f :=\n  submodule.map_mono le_top\n\ntheorem range_coprod {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2083) (g : linear_map R M\u2082 M\u2083) :\n    range (coprod f g) = range f \u2294 range g :=\n  sorry\n\ntheorem is_compl_range_inl_inr {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    is_compl (range (inl R M M\u2082)) (range (inr R M M\u2082)) :=\n  sorry\n\ntheorem sup_range_inl_inr {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    range (inl R M M\u2082) \u2294 range (inr R M M\u2082) = \u22a4 :=\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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    linear_map R M \u21a5(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 \u2192 M\u2082` is defined to be `comap f \u22a5`. 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    submodule R M :=\n  submodule.comap f \u22a5\n\n@[simp] theorem mem_ker {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} {y : M} :\n    y \u2208 ker f \u2194 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 = \u22a5 :=\n  rfl\n\n@[simp] theorem map_coe_ker {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) (x : \u21a5(ker f)) :\n    coe_fn f \u2191x = 0 :=\n  iff.mp mem_ker (subtype.property x)\n\ntheorem comp_ker_subtype {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    comp f (submodule.subtype (ker f)) = 0 :=\n  sorry\n\ntheorem ker_comp {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) :\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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) : ker f \u2264 ker (comp g f) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (ker f \u2264 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} : disjoint p (ker f) \u2194 \u2200 (x : M), x \u2208 p \u2192 coe_fn f x = 0 \u2192 x = 0 :=\n  sorry\n\ntheorem disjoint_inl_inr {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    disjoint (range (inl R M M\u2082)) (range (inr R M M\u2082)) :=\n  sorry\n\ntheorem ker_eq_bot' {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} :\n    ker f = \u22a5 \u2194 \u2200 (m : M), coe_fn f m = 0 \u2192 m = 0 :=\n  sorry\n\ntheorem ker_eq_bot_of_inverse {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    {f : linear_map R M M\u2082} {g : linear_map R M\u2082 M} (h : comp g f = id) : ker f = \u22a5 :=\n  sorry\n\ntheorem le_ker_iff_map {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} : p \u2264 ker f \u2194 submodule.map f p = \u22a5 :=\n  sorry\n\ntheorem ker_cod_restrict {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M\u2082 M) (hf : \u2200 (c : M\u2082), coe_fn f c \u2208 p) : ker (cod_restrict p f hf) = ker f :=\n  sorry\n\ntheorem range_cod_restrict {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M\u2082 M) (hf : \u2200 (c : M\u2082), coe_fn f c \u2208 p) :\n    range (cod_restrict p f hf) = submodule.comap (submodule.subtype p) (range f) :=\n  map_cod_restrict p f hf \u22a4\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 : \u2200 (x : M), x \u2208 p \u2192 coe_fn f x \u2208 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (q : submodule R M\u2082) : submodule.map f (submodule.comap f q) = range f \u2293 q :=\n  sorry\n\ntheorem map_comap_eq_self {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {q : submodule R M\u2082} (h : q \u2264 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 \u2293 q = q)) (propext inf_eq_right))) h)\n\n@[simp] theorem ker_zero {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : ker 0 = \u22a4 :=\n  sorry\n\n@[simp] theorem range_zero {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] : range 0 = \u22a5 :=\n  submodule.map_zero \u22a4\n\ntheorem ker_eq_top {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} :\n    ker f = \u22a4 \u2194 f = 0 :=\n  { mp := fun (h : ker f = \u22a4) => ext fun (x : M) => iff.mp mem_ker (Eq.symm h \u25b8 trivial),\n    mpr := fun (h : f = 0) => Eq.symm h \u25b8 ker_zero }\n\ntheorem range_le_bot_iff {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    range f \u2264 \u22a5 \u2194 f = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (range f \u2264 \u22a5 \u2194 f = 0)) (propext range_le_iff_comap))) ker_eq_top\n\ntheorem range_eq_bot {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} :\n    range f = \u22a5 \u2194 f = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (range f = \u22a5 \u2194 f = 0)) (Eq.symm (propext (range_le_bot_iff f)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (range f = \u22a5 \u2194 range f \u2264 \u22a5)) (propext le_bot_iff)))\n      (iff.refl (range f = \u22a5)))\n\ntheorem range_le_ker_iff {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] {f : linear_map R M M\u2082} {g : linear_map R M\u2082 M\u2083} :\n    range f \u2264 ker g \u2194 comp g f = 0 :=\n  sorry\n\ntheorem comap_le_comap_iff {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    (hf : range f = \u22a4) {p : submodule R M\u2082} {p' : submodule R M\u2082} :\n    submodule.comap f p \u2264 submodule.comap f p' \u2194 p \u2264 p' :=\n  sorry\n\ntheorem comap_injective {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    (hf : range f = \u22a4) : function.injective (submodule.comap f) :=\n  fun (p p' : submodule R M\u2082) (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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2083) (g : linear_map R M\u2082 M\u2083) (p : submodule R M)\n    (q : submodule R M\u2082) :\n    submodule.map (coprod f g) (submodule.prod p q) = submodule.map f p \u2294 submodule.map g q :=\n  sorry\n\ntheorem comap_prod_prod {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M M\u2083) (p : submodule R M\u2082)\n    (q : submodule R M\u2083) :\n    submodule.comap (prod f g) (submodule.prod p q) = submodule.comap f p \u2293 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (q : submodule R M\u2082) :\n    submodule.prod p q = submodule.comap (fst R M M\u2082) p \u2293 submodule.comap (snd R M M\u2082) q :=\n  submodule.ext fun (x : M \u00d7 M\u2082) => iff.rfl\n\ntheorem prod_eq_sup_map {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (q : submodule R M\u2082) :\n    submodule.prod p q = submodule.map (inl R M M\u2082) p \u2294 submodule.map (inr R M M\u2082) q :=\n  sorry\n\ntheorem span_inl_union_inr {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] {s : set M} {t : set M\u2082} :\n    submodule.span R (\u21d1(inl R M M\u2082) '' s \u222a \u21d1(inr R M M\u2082) '' 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\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M M\u2083) :\n    ker (prod f g) = ker f \u2293 ker g :=\n  sorry\n\ntheorem range_prod_le {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_map R M M\u2082) (g : linear_map R M M\u2083) :\n    range (prod f g) \u2264 submodule.prod (range f) (range g) :=\n  sorry\n\ntheorem ker_eq_bot_of_injective {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    {f : linear_map R M M\u2082} (hf : function.injective \u21d1f) : ker f = \u22a5 :=\n  sorry\n\ntheorem comap_map_eq {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    (p : submodule R M) : submodule.comap f (submodule.map f p) = p \u2294 ker f :=\n  sorry\n\ntheorem comap_map_eq_self {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} (h : ker f \u2264 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 \u2294 ker f = p)) (sup_of_le_left h))) (Eq.refl p))\n\ntheorem map_le_map_iff {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082)\n    {p : submodule R M} {p' : submodule R M} :\n    submodule.map f p \u2264 submodule.map f p' \u2194 p \u2264 p' \u2294 ker f :=\n  sorry\n\ntheorem map_le_map_iff' {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} (hf : ker f = \u22a5)\n    {p : submodule R M} {p' : submodule R M} : submodule.map f p \u2264 submodule.map f p' \u2194 p \u2264 p' :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (submodule.map f p \u2264 submodule.map f p' \u2194 p \u2264 p'))\n        (propext (map_le_map_iff f))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (p \u2264 p' \u2294 ker f \u2194 p \u2264 p')) hf))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (p \u2264 p' \u2294 \u22a5 \u2194 p \u2264 p')) sup_bot_eq)) (iff.refl (p \u2264 p'))))\n\ntheorem map_injective {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    (hf : ker f = \u22a5) : 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\u2082 : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    (hf : range f = \u22a4) {p : submodule R M} : submodule.map f p = \u22a4 \u2194 p \u2294 ker f = \u22a4 :=\n  sorry\n\ntheorem sub_mem_ker_iff {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} {x : M} {y : M} :\n    x - y \u2208 ker f \u2194 coe_fn f x = coe_fn f y :=\n  sorry\n\ntheorem disjoint_ker' {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} :\n    disjoint p (ker f) \u2194 \u2200 (x y : M), x \u2208 p \u2192 y \u2208 p \u2192 coe_fn f x = coe_fn f y \u2192 x = y :=\n  sorry\n\ntheorem inj_of_disjoint_ker {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} {s : set M} (h : s \u2286 \u2191p) (hd : disjoint p (ker f)) (x : M) (y : M)\n    (H : x \u2208 s) : y \u2208 s \u2192 coe_fn f x = coe_fn f y \u2192 x = y :=\n  fun (hy : y \u2208 s) => iff.mp disjoint_ker' hd x y (h hx) (h hy)\n\ntheorem ker_eq_bot {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} :\n    ker f = \u22a5 \u2194 function.injective \u21d1f :=\n  sorry\n\ntheorem ker_le_iff {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082}\n    {p : submodule R M} : ker f \u2264 p \u2194 \u2203 (y : M\u2082), \u2203 (H : y \u2208 range f), \u21d1f \u207b\u00b9' singleton y \u2286 \u2191p :=\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\u2082 : Type w} {M\u2083 : Type y} [ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [add_comm_group M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] {f : linear_map R M M\u2082} {g : linear_map R M M\u2083} (h : ker f \u2294 ker g = \u22a4) :\n    range (prod f g) = submodule.prod (range f) (range g) :=\n  sorry\n\ntheorem ker_smul {K : Type u'} {V : Type v'} {V\u2082 : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V V\u2082) (a : K)\n    (h : a \u2260 0) : ker (a \u2022 f) = ker f :=\n  submodule.comap_smul f \u22a5 a h\n\ntheorem ker_smul' {K : Type u'} {V : Type v'} {V\u2082 : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V V\u2082) (a : K) :\n    ker (a \u2022 f) = infi fun (h : a \u2260 0) => ker f :=\n  submodule.comap_smul' f \u22a5 a\n\ntheorem range_smul {K : Type u'} {V : Type v'} {V\u2082 : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V V\u2082) (a : K)\n    (h : a \u2260 0) : range (a \u2022 f) = range f :=\n  submodule.map_smul f \u22a4 a h\n\ntheorem range_smul' {K : Type u'} {V : Type v'} {V\u2082 : Type w'} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V V\u2082) (a : K) :\n    range (a \u2022 f) = supr fun (h : a \u2260 0) => range f :=\n  submodule.map_smul' f \u22a4 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 \u2294 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 \u00d7 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 \u00d7 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\u2082 : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : linear_map R M M\u2082) :\n    map f \u22a4 = linear_map.range f :=\n  rfl\n\n@[simp] theorem comap_bot {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (f : linear_map R M M\u2082) : comap f \u22a5 = 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) = \u22a5 :=\n  linear_map.ker_eq_bot_of_injective fun (x y : \u21a5p) => 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 \u21a5p) : map (submodule.subtype p) p' \u2264 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) \u22a4 = 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' = \u22a4 \u2194 p \u2264 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 = \u22a4 :=\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 \u2264 p') :\n    linear_map.ker (of_le h) = \u22a5 :=\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 \u2264 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\u2082 : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M) :\n    map (linear_map.inl R M M\u2082) p = prod p \u22a5 :=\n  sorry\n\n@[simp] theorem map_inr {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (q : submodule R M\u2082) :\n    map (linear_map.inr R M M\u2082) q = prod \u22a5 q :=\n  sorry\n\n@[simp] theorem comap_fst {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (p : submodule R M) : comap (linear_map.fst R M M\u2082) p = prod p \u22a4 :=\n  sorry\n\n@[simp] theorem comap_snd {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (q : submodule R M\u2082) : comap (linear_map.snd R M M\u2082) q = prod \u22a4 q :=\n  sorry\n\n@[simp] theorem prod_comap_inl {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (q : submodule R M\u2082) : comap (linear_map.inl R M M\u2082) (prod p q) = p :=\n  sorry\n\n@[simp] theorem prod_comap_inr {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (q : submodule R M\u2082) : comap (linear_map.inr R M M\u2082) (prod p q) = q :=\n  sorry\n\n@[simp] theorem prod_map_fst {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (q : submodule R M\u2082) : map (linear_map.fst R M M\u2082) (prod p q) = p :=\n  sorry\n\n@[simp] theorem prod_map_snd {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (q : submodule R M\u2082) : map (linear_map.snd R M M\u2082) (prod p q) = q :=\n  sorry\n\n@[simp] theorem ker_inl {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    linear_map.ker (linear_map.inl R M M\u2082) = \u22a5 :=\n  sorry\n\n@[simp] theorem ker_inr {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R} [add_comm_monoid M]\n    [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    linear_map.ker (linear_map.inr R M M\u2082) = \u22a5 :=\n  sorry\n\n@[simp] theorem range_fst {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    linear_map.range (linear_map.fst R M M\u2082) = \u22a4 :=\n  sorry\n\n@[simp] theorem range_snd {R : Type u} {M : Type v} {M\u2082 : Type w} {T : semiring R}\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] :\n    linear_map.range (linear_map.snd R M M\u2082) = \u22a4 :=\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 \u2194 comap (submodule.subtype p) q = \u22a5 :=\n  sorry\n\n/-- If `N \u2286 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 \u21a5p \u2243o Subtype fun (p' : submodule R M) => p' \u2264 p :=\n  rel_iso.mk\n    (equiv.mk\n      (fun (p' : submodule R \u21a5p) => { val := map (submodule.subtype p) p', property := sorry })\n      (fun (q : Subtype fun (p' : submodule R M) => p' \u2264 p) => comap (submodule.subtype p) \u2191q) sorry\n      sorry)\n    sorry\n\n/-- If `p \u2286 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 \u21a5p \u21aao 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' \u2264 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 \u21a5p) :\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\u2082` induced by a linear map `f : M \u2192 M\u2082`\nvanishing on `p`, as a linear map. -/\ndef liftq {R : Type u} {M : Type v} {M\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M M\u2082) (h : p \u2264 linear_map.ker f) : linear_map R (quotient p) M\u2082 :=\n  linear_map.mk (fun (x : quotient p) => quotient.lift_on' x \u21d1f sorry) sorry sorry\n\n@[simp] theorem liftq_apply {R : Type u} {M : Type v} {M\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M M\u2082) {h : p \u2264 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\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M M\u2082) (h : p \u2264 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) = \u22a4 :=\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 \u2264 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 = \u22a5 :=\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 \u2294 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' = \u22a4 \u2194 p \u2294 p' = \u22a4 :=\n  sorry\n\n/-- The map from the quotient of `M` by submodule `p` to the quotient of `M\u2082` by submodule `q` along\n`f : M \u2192 M\u2082` is linear. -/\ndef mapq {R : Type u} {M : Type v} {M\u2082 : Type w} {T : ring R} [add_comm_group M] [add_comm_group M\u2082]\n    [semimodule R M] [semimodule R M\u2082] (p : submodule R M) (q : submodule R M\u2082)\n    (f : linear_map R M M\u2082) (h : p \u2264 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\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M) (q : submodule R M\u2082)\n    (f : linear_map R M M\u2082) {h : p \u2264 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\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M) (q : submodule R M\u2082)\n    (f : linear_map R M M\u2082) {h : p \u2264 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\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M) (q : submodule R M\u2082)\n    (f : linear_map R M M\u2082) (h : p \u2264 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\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M M\u2082) (h : p \u2264 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\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M M\u2082) (h : p \u2264 linear_map.ker f) :\n    linear_map.ker (liftq p f h) = map (mkq p) (linear_map.ker f) :=\n  comap_liftq p \u22a5 f h\n\ntheorem range_liftq {R : Type u} {M : Type v} {M\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M M\u2082) (h : p \u2264 linear_map.ker f) :\n    linear_map.range (liftq p f h) = linear_map.range f :=\n  map_liftq p f h \u22a4\n\ntheorem ker_liftq_eq_bot {R : Type u} {M : Type v} {M\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (p : submodule R M)\n    (f : linear_map R M M\u2082) (h : p \u2264 linear_map.ker f) (h' : linear_map.ker f \u2264 p) :\n    linear_map.ker (liftq p f h) = \u22a5 :=\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) \u2243o Subtype fun (p' : submodule R M) => p \u2264 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 \u2264 p') => map (mkq p) \u2191q) 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) \u21aao 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 \u2264 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\u2082 : Type w} {T : ring R} [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] {f : linear_map R M M\u2082} {s : set M\u2082}\n    (h\u2080 : set.nonempty s) (h\u2081 : s \u2286 \u2191(linear_map.range f)) :\n    span R (\u21d1f \u207b\u00b9' 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\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [module R M] [module R M\u2082] (f : linear_map R M M\u2082) :\n    comp (submodule.mkq (range f)) f = 0 :=\n  sorry\n\ntheorem ker_le_range_iff {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [add_comm_group M\u2083] [module R M] [module R M\u2082]\n    [module R M\u2083] {f : linear_map R M M\u2082} {g : linear_map R M\u2082 M\u2083} :\n    ker g \u2264 range f \u2194 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\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [module R M] [module R M\u2082] {f : linear_map R M M\u2082}\n    (h : \u2200 (u v : linear_map R (\u21a5(ker f)) M), comp f u = comp f v \u2192 u = v) : ker f = \u22a5 :=\n  sorry\n\n/-- An epimorphism is surjective. -/\ntheorem range_eq_top_of_cancel {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [module R M] [module R M\u2082] {f : linear_map R M M\u2082}\n    (h : \u2200 (u v : linear_map R M\u2082 (submodule.quotient (range f))), comp u f = comp v f \u2192 u = v) :\n    range f = \u22a4 :=\n  sorry\n\nend linear_map\n\n\n@[simp] theorem linear_map.range_range_restrict {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082]\n    (f : linear_map R M M\u2082) : linear_map.range (linear_map.range_restrict f) = \u22a4 :=\n  sorry\n\n/-! ### Linear equivalences -/\n\nnamespace linear_equiv\n\n\ntheorem map_eq_comap {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    (e : linear_equiv R M M\u2082) {p : submodule R M} :\n    submodule.map (\u2191e) p = submodule.comap (\u2191(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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    (e : linear_equiv R M M\u2082) (p : submodule R M) : linear_equiv R \u21a5p \u21a5(submodule.map (\u2191e) p) :=\n  mk\n    (linear_map.to_fun\n      (linear_map.cod_restrict (submodule.map (\u2191e) p) (linear_map.dom_restrict (\u2191e) p) sorry))\n    sorry sorry\n    (fun (y : \u21a5(submodule.map (\u2191e) p)) => { val := coe_fn (symm e) \u2191y, property := sorry }) sorry\n    sorry\n\n@[simp] theorem of_submodule_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (e : linear_equiv R M M\u2082) (p : submodule R M) (x : \u21a5p) :\n    \u2191(coe_fn (of_submodule e p) x) = coe_fn e \u2191x :=\n  rfl\n\n@[simp] theorem of_submodule_symm_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (e : linear_equiv R M M\u2082) (p : submodule R M)\n    (x : \u21a5(submodule.map (\u2191e) p)) : \u2191(coe_fn (symm (of_submodule e p)) x) = coe_fn (symm e) \u2191x :=\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\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n    {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    {semimodule_M\u2083 : semimodule R M\u2083} {semimodule_M\u2084 : semimodule R M\u2084} (e\u2081 : linear_equiv R M M\u2082)\n    (e\u2082 : linear_equiv R M\u2083 M\u2084) : linear_equiv R (M \u00d7 M\u2083) (M\u2082 \u00d7 M\u2084) :=\n  mk (equiv.to_fun (equiv.prod_congr (to_equiv e\u2081) (to_equiv e\u2082))) sorry sorry\n    (equiv.inv_fun (equiv.prod_congr (to_equiv e\u2081) (to_equiv e\u2082))) sorry sorry\n\ntheorem prod_symm {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n    {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    {semimodule_M\u2083 : semimodule R M\u2083} {semimodule_M\u2084 : semimodule R M\u2084} (e\u2081 : linear_equiv R M M\u2082)\n    (e\u2082 : linear_equiv R M\u2083 M\u2084) :\n    symm (linear_equiv.prod e\u2081 e\u2082) = linear_equiv.prod (symm e\u2081) (symm e\u2082) :=\n  rfl\n\n@[simp] theorem prod_apply {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z}\n    [semiring R] [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n    {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    {semimodule_M\u2083 : semimodule R M\u2083} {semimodule_M\u2084 : semimodule R M\u2084} (e\u2081 : linear_equiv R M M\u2082)\n    (e\u2082 : linear_equiv R M\u2083 M\u2084) (p : M \u00d7 M\u2083) :\n    coe_fn (linear_equiv.prod e\u2081 e\u2082) p = (coe_fn e\u2081 (prod.fst p), coe_fn e\u2082 (prod.snd p)) :=\n  rfl\n\n@[simp] theorem coe_prod {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z}\n    [semiring R] [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n    {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    {semimodule_M\u2083 : semimodule R M\u2083} {semimodule_M\u2084 : semimodule R M\u2084} (e\u2081 : linear_equiv R M M\u2082)\n    (e\u2082 : linear_equiv R M\u2083 M\u2084) : \u2191(linear_equiv.prod e\u2081 e\u2082) = linear_map.prod_map \u2191e\u2081 \u2191e\u2082 :=\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\u2082 : Type w') [semiring R] :\n    linear_equiv R (V \u2192 V\u2082 \u2192 R) (V \u00d7 V\u2082 \u2192 R) :=\n  mk (equiv.to_fun (equiv.arrow_arrow_equiv_prod_arrow V V\u2082 R)) sorry sorry\n    (equiv.inv_fun (equiv.arrow_arrow_equiv_prod_arrow V V\u2082 R)) sorry sorry\n\n@[simp] theorem coe_uncurry (R : Type u) (V : Type v') (V\u2082 : Type w') [semiring R] :\n    \u21d1(linear_equiv.uncurry R V V\u2082) = function.uncurry :=\n  rfl\n\n@[simp] theorem coe_uncurry_symm (R : Type u) (V : Type v') (V\u2082 : Type w') [semiring R] :\n    \u21d1(symm (linear_equiv.uncurry R V V\u2082)) = 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 \u21a5p \u21a5q :=\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 : \u21a5p) :\n    \u2191(coe_fn (of_eq p q h) x) = \u2191x :=\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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    (e : linear_equiv R M M\u2082) (p : submodule R M) (q : submodule R M\u2082)\n    (h : submodule.map (\u2191e) p = q) : linear_equiv R \u21a5p \u21a5q :=\n  trans (of_submodule e p) (of_eq (submodule.map (\u2191e) p) q h)\n\n@[simp] theorem of_submodules_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (e : linear_equiv R M M\u2082) {p : submodule R M}\n    {q : submodule R M\u2082} (h : submodule.map (\u2191e) p = q) (x : \u21a5p) :\n    \u2191(coe_fn (of_submodules e p q h) x) = coe_fn e \u2191x :=\n  rfl\n\n@[simp] theorem of_submodules_symm_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (e : linear_equiv R M M\u2082) {p : submodule R M}\n    {q : submodule R M\u2082} (h : submodule.map (\u2191e) p = q) (x : \u21a5q) :\n    \u2191(coe_fn (symm (of_submodules e p q h)) x) = coe_fn (symm e) \u2191x :=\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 = \u22a4) : linear_equiv R (\u21a5p) 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 = \u22a4} (x : \u21a5p) :\n    coe_fn (of_top p h) x = \u2191x :=\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 = \u22a4} (x : M) :\n    \u2191(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 = \u22a4} (x : M) :\n    coe_fn (symm (of_top p h)) x = { val := x, property := Eq.symm h \u25b8 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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M) (h\u2081 : linear_map.comp f g = linear_map.id)\n    (h\u2082 : linear_map.comp g f = linear_map.id) : linear_equiv R M M\u2082 :=\n  mk (linear_map.to_fun f) (linear_map.map_add' f) (linear_map.map_smul' f) \u21d1g sorry sorry\n\n@[simp] theorem of_linear_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M)\n    {h\u2081 : linear_map.comp f g = linear_map.id} {h\u2082 : linear_map.comp g f = linear_map.id} (x : M) :\n    coe_fn (of_linear f g h\u2081 h\u2082) x = coe_fn f x :=\n  rfl\n\n@[simp] theorem of_linear_symm_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M)\n    {h\u2081 : linear_map.comp f g = linear_map.id} {h\u2082 : linear_map.comp g f = linear_map.id} (x : M\u2082) :\n    coe_fn (symm (of_linear f g h\u2081 h\u2082)) x = coe_fn g x :=\n  rfl\n\n@[simp] protected theorem range {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (e : linear_equiv R M M\u2082) : linear_map.range \u2191e = \u22a4 :=\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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [add_comm_monoid M\u2082] {semimodule_M : semimodule R M} (p : submodule R M) [semimodule R M\u2082]\n    (e : linear_equiv R \u21a5p \u21a5\u22a5) : p = \u22a5 :=\n  sorry\n\n@[simp] protected theorem ker {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [add_comm_monoid M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (e : linear_equiv R M M\u2082) : linear_map.ker \u2191e = \u22a5 :=\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\u2082 : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M\u2082] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    (e : linear_equiv R M M\u2082) (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\u2082 : Type w} [semiring R] [add_comm_group M]\n    [add_comm_group M\u2082] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    (e : linear_equiv R M M\u2082) (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\u2081` and `e\u2082` 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\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z}\n    [semiring R] [add_comm_group M] [add_comm_group M\u2082] [add_comm_group M\u2083] [add_comm_group M\u2084]\n    {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    {semimodule_M\u2083 : semimodule R M\u2083} {semimodule_M\u2084 : semimodule R M\u2084} (e\u2081 : linear_equiv R M M\u2082)\n    (e\u2082 : linear_equiv R M\u2083 M\u2084) (f : linear_map R M M\u2084) : linear_equiv R (M \u00d7 M\u2083) (M\u2082 \u00d7 M\u2084) :=\n  mk\n    (linear_map.to_fun\n      (linear_map.prod (linear_map.comp (\u2191e\u2081) (linear_map.fst R M M\u2083))\n        (linear_map.comp (\u2191e\u2082) (linear_map.snd R M M\u2083) +\n          linear_map.comp f (linear_map.fst R M M\u2083))))\n    sorry sorry\n    (fun (p : M\u2082 \u00d7 M\u2084) =>\n      (coe_fn (symm e\u2081) (prod.fst p),\n      coe_fn (symm e\u2082) (prod.snd p - coe_fn f (coe_fn (symm e\u2081) (prod.fst p)))))\n    sorry sorry\n\n@[simp] theorem skew_prod_apply {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} {M\u2084 : Type z}\n    [semiring R] [add_comm_group M] [add_comm_group M\u2082] [add_comm_group M\u2083] [add_comm_group M\u2084]\n    {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    {semimodule_M\u2083 : semimodule R M\u2083} {semimodule_M\u2084 : semimodule R M\u2084} (e\u2081 : linear_equiv R M M\u2082)\n    (e\u2082 : linear_equiv R M\u2083 M\u2084) (f : linear_map R M M\u2084) (x : M \u00d7 M\u2083) :\n    coe_fn (linear_equiv.skew_prod e\u2081 e\u2082 f) x =\n        (coe_fn e\u2081 (prod.fst x), coe_fn e\u2082 (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\u2082 : Type w} {M\u2083 : Type y}\n    {M\u2084 : Type z} [semiring R] [add_comm_group M] [add_comm_group M\u2082] [add_comm_group M\u2083]\n    [add_comm_group M\u2084] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    {semimodule_M\u2083 : semimodule R M\u2083} {semimodule_M\u2084 : semimodule R M\u2084} (e\u2081 : linear_equiv R M M\u2082)\n    (e\u2082 : linear_equiv R M\u2083 M\u2084) (f : linear_map R M M\u2084) (x : M\u2082 \u00d7 M\u2084) :\n    coe_fn (symm (linear_equiv.skew_prod e\u2081 e\u2082 f)) x =\n        (coe_fn (symm e\u2081) (prod.fst x),\n        coe_fn (symm e\u2082) (prod.snd x - coe_fn f (coe_fn (symm e\u2081) (prod.fst x)))) :=\n  rfl\n\n/-- `x \u21a6 -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    \u21d1(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 \u2192\u2097[R] M\u2082` defines a linear equivalence\nbetween `M` and `f.range`. -/\ndef of_injective {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    (f : linear_map R M M\u2082) (h : linear_map.ker f = \u22a5) : linear_equiv R M \u21a5(linear_map.range f) :=\n  mk (equiv.to_fun (equiv.trans (equiv.set.range \u21d1f sorry) (equiv.set.of_eq sorry))) sorry sorry\n    (equiv.inv_fun (equiv.trans (equiv.set.range \u21d1f sorry) (equiv.set.of_eq sorry))) sorry sorry\n\n@[simp] theorem of_injective_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R]\n    [add_comm_group M] [add_comm_group M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (f : linear_map R M M\u2082) {h : linear_map.ker f = \u22a5} (x : M) :\n    \u2191(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\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] {semimodule_M : semimodule R M} {semimodule_M\u2082 : semimodule R M\u2082}\n    (f : linear_map R M M\u2082) (hf\u2081 : linear_map.ker f = \u22a5) (hf\u2082 : linear_map.range f = \u22a4) :\n    linear_equiv R M M\u2082 :=\n  trans (of_injective f hf\u2081) (of_top (linear_map.range f) hf\u2082)\n\n@[simp] theorem of_bijective_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [ring R]\n    [add_comm_group M] [add_comm_group M\u2082] {semimodule_M : semimodule R M}\n    {semimodule_M\u2082 : semimodule R M\u2082} (f : linear_map R M M\u2082) {hf\u2081 : linear_map.ker f = \u22a5}\n    {hf\u2082 : linear_map.range f = \u22a4} (x : M) : coe_fn (of_bijective f hf\u2081 hf\u2082) 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 (\u2191a \u2022 1) (\u2191(a\u207b\u00b9) \u2022 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\u2081 : Type u_2} {M\u2082 : Type u_3} {M\u2082\u2081 : Type u_4} {M\u2082\u2082 : Type u_5}\n    [comm_ring R] [add_comm_group M\u2081] [add_comm_group M\u2082] [add_comm_group M\u2082\u2081] [add_comm_group M\u2082\u2082]\n    [module R M\u2081] [module R M\u2082] [module R M\u2082\u2081] [module R M\u2082\u2082] (e\u2081 : linear_equiv R M\u2081 M\u2082)\n    (e\u2082 : linear_equiv R M\u2082\u2081 M\u2082\u2082) : linear_equiv R (linear_map R M\u2081 M\u2082\u2081) (linear_map R M\u2082 M\u2082\u2082) :=\n  mk (fun (f : linear_map R M\u2081 M\u2082\u2081) => linear_map.comp (\u2191e\u2082) (linear_map.comp f \u2191(symm e\u2081))) sorry\n    sorry (fun (f : linear_map R M\u2082 M\u2082\u2082) => linear_map.comp (\u2191(symm e\u2082)) (linear_map.comp f \u2191e\u2081))\n    sorry sorry\n\n@[simp] theorem arrow_congr_apply {R : Type u_1} {M\u2081 : Type u_2} {M\u2082 : Type u_3} {M\u2082\u2081 : Type u_4}\n    {M\u2082\u2082 : Type u_5} [comm_ring R] [add_comm_group M\u2081] [add_comm_group M\u2082] [add_comm_group M\u2082\u2081]\n    [add_comm_group M\u2082\u2082] [module R M\u2081] [module R M\u2082] [module R M\u2082\u2081] [module R M\u2082\u2082]\n    (e\u2081 : linear_equiv R M\u2081 M\u2082) (e\u2082 : linear_equiv R M\u2082\u2081 M\u2082\u2082) (f : linear_map R M\u2081 M\u2082\u2081) (x : M\u2082) :\n    coe_fn (coe_fn (arrow_congr e\u2081 e\u2082) f) x = coe_fn e\u2082 (coe_fn f (coe_fn (symm e\u2081) x)) :=\n  rfl\n\n@[simp] theorem arrow_congr_symm_apply {R : Type u_1} {M\u2081 : Type u_2} {M\u2082 : Type u_3}\n    {M\u2082\u2081 : Type u_4} {M\u2082\u2082 : Type u_5} [comm_ring R] [add_comm_group M\u2081] [add_comm_group M\u2082]\n    [add_comm_group M\u2082\u2081] [add_comm_group M\u2082\u2082] [module R M\u2081] [module R M\u2082] [module R M\u2082\u2081]\n    [module R M\u2082\u2082] (e\u2081 : linear_equiv R M\u2081 M\u2082) (e\u2082 : linear_equiv R M\u2082\u2081 M\u2082\u2082)\n    (f : linear_map R M\u2082 M\u2082\u2082) (x : M\u2081) :\n    coe_fn (coe_fn (symm (arrow_congr e\u2081 e\u2082)) f) x = coe_fn (symm e\u2082) (coe_fn f (coe_fn e\u2081 x)) :=\n  rfl\n\ntheorem arrow_congr_comp {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [comm_ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [add_comm_group M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] {N : Type u_1} {N\u2082 : Type u_2} {N\u2083 : Type u_3} [add_comm_group N]\n    [add_comm_group N\u2082] [add_comm_group N\u2083] [module R N] [module R N\u2082] [module R N\u2083]\n    (e\u2081 : linear_equiv R M N) (e\u2082 : linear_equiv R M\u2082 N\u2082) (e\u2083 : linear_equiv R M\u2083 N\u2083)\n    (f : linear_map R M M\u2082) (g : linear_map R M\u2082 M\u2083) :\n    coe_fn (arrow_congr e\u2081 e\u2083) (linear_map.comp g f) =\n        linear_map.comp (coe_fn (arrow_congr e\u2082 e\u2083) g) (coe_fn (arrow_congr e\u2081 e\u2082) f) :=\n  sorry\n\ntheorem arrow_congr_trans {R : Type u} [comm_ring R] {M\u2081 : Type u_1} {M\u2082 : Type u_2} {M\u2083 : Type u_3}\n    {N\u2081 : Type u_4} {N\u2082 : Type u_5} {N\u2083 : Type u_6} [add_comm_group M\u2081] [module R M\u2081]\n    [add_comm_group M\u2082] [module R M\u2082] [add_comm_group M\u2083] [module R M\u2083] [add_comm_group N\u2081]\n    [module R N\u2081] [add_comm_group N\u2082] [module R N\u2082] [add_comm_group N\u2083] [module R N\u2083]\n    (e\u2081 : linear_equiv R M\u2081 M\u2082) (e\u2082 : linear_equiv R N\u2081 N\u2082) (e\u2083 : linear_equiv R M\u2082 M\u2083)\n    (e\u2084 : linear_equiv R N\u2082 N\u2083) :\n    trans (arrow_congr e\u2081 e\u2082) (arrow_congr e\u2083 e\u2084) = arrow_congr (trans e\u2081 e\u2083) (trans e\u2082 e\u2084) :=\n  rfl\n\n/-- If `M\u2082` and `M\u2083` are linearly isomorphic then the two spaces of linear maps from `M` into `M\u2082`\nand `M` into `M\u2083` are linearly isomorphic. -/\ndef congr_right {R : Type u} {M : Type v} {M\u2082 : Type w} {M\u2083 : Type y} [comm_ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [add_comm_group M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (f : linear_equiv R M\u2082 M\u2083) :\n    linear_equiv R (linear_map R M M\u2082) (linear_map R M M\u2083) :=\n  arrow_congr (refl R M) f\n\n/-- If `M` and `M\u2082` are linearly isomorphic then the two spaces of linear maps from `M` and `M\u2082` to\nthemselves are linearly isomorphic. -/\ndef conj {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (e : linear_equiv R M M\u2082) :\n    linear_equiv R (module.End R M) (module.End R M\u2082) :=\n  arrow_congr e e\n\ntheorem conj_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (e : linear_equiv R M M\u2082)\n    (f : module.End R M) : coe_fn (conj e) f = linear_map.comp (linear_map.comp (\u2191e) f) \u2191(symm e) :=\n  rfl\n\ntheorem symm_conj_apply {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (e : linear_equiv R M M\u2082)\n    (f : module.End R M\u2082) :\n    coe_fn (conj (symm e)) f = linear_map.comp (linear_map.comp (\u2191(symm e)) f) \u2191e :=\n  rfl\n\ntheorem conj_comp {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (e : linear_equiv R M M\u2082)\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\u2082 : Type w} {M\u2083 : Type y} [comm_ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [add_comm_group M\u2083] [semimodule R M] [semimodule R M\u2082]\n    [semimodule R M\u2083] (e\u2081 : linear_equiv R M M\u2082) (e\u2082 : linear_equiv R M\u2082 M\u2083) :\n    trans (conj e\u2081) (conj e\u2082) = conj (trans e\u2081 e\u2082) :=\n  ext\n    fun (f : module.End R M) =>\n      linear_map.ext fun (x : M\u2083) => Eq.refl (coe_fn (coe_fn (trans (conj e\u2081) (conj e\u2082)) f) x)\n\n@[simp] theorem conj_id {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [semimodule R M] [semimodule R M\u2082] (e : linear_equiv R M M\u2082) :\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 \u2260 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 \u2260 0) : linear_map.ker (linear_map.to_span_singleton K M x) = \u22a5 :=\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 \u2260 0) : linear_equiv K K \u21a5(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 \u2260 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 \u2260 0) :\n    linear_equiv K (\u21a5(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 \u2260 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 \u2264 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 \u2264 q) :\n    linear_equiv R \u21a5(comap (submodule.subtype q) p) \u21a5p :=\n  linear_equiv.mk (fun (x : \u21a5(comap (submodule.subtype q) p)) => { val := \u2191x, property := sorry })\n    sorry sorry (fun (x : \u21a5p) => { val := { val := \u2191x, property := sorry }, property := sorry })\n    sorry sorry\n\n/-- If `p = \u22a5`, then `M / p \u2243\u2097[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 = \u22a5) : 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 = \u22a5) (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 = \u22a5) (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 = \u22a5) :\n    \u2191(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\u2082 : Type w} [comm_ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [module R M] [module R M\u2082] (p : submodule R M)\n    {e : linear_equiv R M M\u2082} {x : M\u2082} : x \u2208 map (\u2191e) p \u2194 coe_fn (linear_equiv.symm e) x \u2208 p :=\n  sorry\n\ntheorem comap_le_comap_smul {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [module R M] [module R M\u2082] (q : submodule R M\u2082) (f : linear_map R M M\u2082)\n    (c : R) : comap f q \u2264 comap (c \u2022 f) q :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (comap f q \u2264 comap (c \u2022 f) q)) (propext le_def')))\n    fun (m : M) (h : m \u2208 comap f q) => id (id (fun (h : coe_fn f m \u2208 q) => smul_mem q c h) h)\n\ntheorem inf_comap_le_comap_add {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [module R M] [module R M\u2082] (q : submodule R M\u2082)\n    (f\u2081 : linear_map R M M\u2082) (f\u2082 : linear_map R M M\u2082) :\n    comap f\u2081 q \u2293 comap f\u2082 q \u2264 comap (f\u2081 + f\u2082) q :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (comap f\u2081 q \u2293 comap f\u2082 q \u2264 comap (f\u2081 + f\u2082) q)) (propext le_def')))\n    fun (m : M) (h : m \u2208 comap f\u2081 q \u2293 comap f\u2082 q) =>\n      id\n        (id (fun (h : coe_fn f\u2081 m \u2208 q \u2227 coe_fn f\u2082 m \u2208 q) => add_mem q (and.left h) (and.right h)) h)\n\n/-- Given modules `M`, `M\u2082` over a commutative ring, together with submodules `p \u2286 M`, `q \u2286 M\u2082`, the\nset of maps $\\\\{f \u2208 Hom(M, M\u2082) | f(p) \u2286 q \\\\}$ is a submodule of `Hom(M, M\u2082)`. -/\ndef compatible_maps {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [module R M] [module R M\u2082] (p : submodule R M) (q : submodule R M\u2082) :\n    submodule R (linear_map R M M\u2082) :=\n  mk (set_of fun (f : linear_map R M M\u2082) => p \u2264 comap f q) sorry sorry sorry\n\n/-- Given modules `M`, `M\u2082` over a commutative ring, together with submodules `p \u2286 M`, `q \u2286 M\u2082`, the\nnatural map $\\\\{f \u2208 Hom(M, M\u2082) | f(p) \u2286 q \\\\} \\to Hom(M/p, M\u2082/q)$ is linear. -/\ndef mapq_linear {R : Type u} {M : Type v} {M\u2082 : Type w} [comm_ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [module R M] [module R M\u2082] (p : submodule R M) (q : submodule R M\u2082) :\n    linear_map R (\u21a5(compatible_maps p q)) (linear_map R (quotient p) (quotient q)) :=\n  linear_map.mk (fun (f : \u21a5(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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] [add_comm_monoid M\u2082] [semimodule R M\u2082] (e : M \u2243 M\u2082) (h : is_linear_map R \u21d1e) :\n    linear_equiv R M M\u2082 :=\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\u2082 : Type w} [semiring R] [add_comm_monoid M]\n    [semimodule R M] [add_comm_monoid M\u2082] [semimodule R M\u2082] (e : M \u2243+ M\u2082)\n    (h : \u2200 (c : R) (x : M), coe_fn e (c \u2022 x) = c \u2022 coe_fn e x) : linear_equiv R M M\u2082 :=\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\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid M\u2082] [semimodule R M\u2082] (e : M \u2243+ M\u2082)\n    (h : \u2200 (c : R) (x : M), coe_fn e (c \u2022 x) = c \u2022 coe_fn e x) : \u21d1(to_linear_equiv e h) = \u21d1e :=\n  rfl\n\n@[simp] theorem coe_to_linear_equiv_symm {R : Type u} {M : Type v} {M\u2082 : Type w} [semiring R]\n    [add_comm_monoid M] [semimodule R M] [add_comm_monoid M\u2082] [semimodule R M\u2082] (e : M \u2243+ M\u2082)\n    (h : \u2200 (c : R) (x : M), coe_fn e (c \u2022 x) = c \u2022 coe_fn e x) :\n    \u21d1(linear_equiv.symm (to_linear_equiv e h)) = \u21d1(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\u2082 : Type w} [ring R] [add_comm_group M]\n    [add_comm_group M\u2082] [module R M] [module R M\u2082] (f : linear_map R M M\u2082) :\n    linear_equiv R (submodule.quotient (ker f)) \u21a5(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\u2082 : Type w} [ring R]\n    [add_comm_group M] [add_comm_group M\u2082] [module R M] [module R M\u2082] (f : linear_map R M M\u2082)\n    (x : M) : \u2191(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\u2082 : Type w}\n    [ring R] [add_comm_group M] [add_comm_group M\u2082] [module R M] [module R M\u2082]\n    (f : linear_map R M M\u2082) (x : M) (h : coe_fn f x \u2208 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 \u2229 p')` to `(p+p')/p'`, mapping `x + (p \u2229 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 \u2293 p')))\n        (submodule.quotient (submodule.comap (submodule.subtype (p \u2294 p')) p')) :=\n  submodule.liftq (submodule.comap (submodule.subtype p) (p \u2293 p'))\n    (comp (submodule.mkq (submodule.comap (submodule.subtype (p \u2294 p')) p')) (submodule.of_le sorry))\n    sorry\n\n/--\nSecond Isomorphism Law : the canonical map from `p/(p \u2229 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 \u2293 p')))\n        (submodule.quotient (submodule.comap (submodule.subtype (p \u2294 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    \u21d1(quotient_inf_to_sup_quotient p p') = \u21d1(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 : \u21a5p) :\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 : \u21a5(p \u2294 p'))\n    (hx : \u2191x \u2208 p) :\n    coe_fn (linear_equiv.symm (quotient_inf_equiv_sup_quotient p p')) (submodule.quotient.mk x) =\n        submodule.quotient.mk { val := \u2191x, 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 : \u21a5(p \u2294 p')} :\n    coe_fn (linear_equiv.symm (quotient_inf_equiv_sup_quotient p p')) (submodule.quotient.mk x) =\n          0 \u2194\n        \u2191x \u2208 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 : \u21a5(p \u2294 p')}\n    (hx : \u2191x \u2208 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\u2082 : Type u_3} {M\u2083 : Type u_4}\n    [comm_semiring R] [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_group M\u2083] [semimodule R M]\n    [semimodule R M\u2082] [semimodule R M\u2083] :\n    is_linear_map R\n        fun (p : linear_map R M M\u2082 \u00d7 linear_map R M M\u2083) => prod (prod.fst p) (prod.snd p) :=\n  is_linear_map.mk (fun (u v : linear_map R M M\u2082 \u00d7 linear_map R M M\u2083) => rfl)\n    fun (c : R) (u : linear_map R M M\u2082 \u00d7 linear_map R M M\u2083) => 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\u2082 : Type w} {\u03b9 : Type x} [semiring R] [add_comm_monoid M\u2082] [semimodule R M\u2082]\n    {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)]\n    (f : (i : \u03b9) \u2192 linear_map R M\u2082 (\u03c6 i)) : linear_map R M\u2082 ((i : \u03b9) \u2192 \u03c6 i) :=\n  mk (fun (c : M\u2082) (i : \u03b9) => coe_fn (f i) c) sorry sorry\n\n@[simp] theorem pi_apply {R : Type u} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R] [add_comm_monoid M\u2082]\n    [semimodule R M\u2082] {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)]\n    [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] (f : (i : \u03b9) \u2192 linear_map R M\u2082 (\u03c6 i)) (c : M\u2082) (i : \u03b9) :\n    coe_fn (pi f) c i = coe_fn (f i) c :=\n  rfl\n\ntheorem ker_pi {R : Type u} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R] [add_comm_monoid M\u2082]\n    [semimodule R M\u2082] {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)]\n    [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] (f : (i : \u03b9) \u2192 linear_map R M\u2082 (\u03c6 i)) :\n    ker (pi f) = infi fun (i : \u03b9) => ker (f i) :=\n  sorry\n\ntheorem pi_eq_zero {R : Type u} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R] [add_comm_monoid M\u2082]\n    [semimodule R M\u2082] {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)]\n    [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] (f : (i : \u03b9) \u2192 linear_map R M\u2082 (\u03c6 i)) :\n    pi f = 0 \u2194 \u2200 (i : \u03b9), f i = 0 :=\n  sorry\n\ntheorem pi_zero {R : Type u} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R] [add_comm_monoid M\u2082]\n    [semimodule R M\u2082] {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)]\n    [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] : (pi fun (i : \u03b9) => 0) = 0 :=\n  ext fun (x : M\u2082) => funext fun (x_1 : \u03b9) => Eq.refl (coe_fn (pi fun (i : \u03b9) => 0) x x_1)\n\ntheorem pi_comp {R : Type u} {M\u2082 : Type w} {M\u2083 : Type y} {\u03b9 : Type x} [semiring R]\n    [add_comm_monoid M\u2082] [semimodule R M\u2082] [add_comm_monoid M\u2083] [semimodule R M\u2083] {\u03c6 : \u03b9 \u2192 Type i}\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)]\n    (f : (i : \u03b9) \u2192 linear_map R M\u2082 (\u03c6 i)) (g : linear_map R M\u2083 M\u2082) :\n    comp (pi f) g = pi fun (i : \u03b9) => comp (f i) g :=\n  rfl\n\n/-- The projections from a family of modules are linear maps. -/\ndef proj {R : Type u} {\u03b9 : Type x} [semiring R] {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)]\n    [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] (i : \u03b9) : linear_map R ((i : \u03b9) \u2192 \u03c6 i) (\u03c6 i) :=\n  mk (fun (a : (i : \u03b9) \u2192 \u03c6 i) => a i) sorry sorry\n\n@[simp] theorem proj_apply {R : Type u} {\u03b9 : Type x} [semiring R] {\u03c6 : \u03b9 \u2192 Type i}\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] (i : \u03b9) (b : (i : \u03b9) \u2192 \u03c6 i) :\n    coe_fn (proj i) b = b i :=\n  rfl\n\ntheorem proj_pi {R : Type u} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R] [add_comm_monoid M\u2082]\n    [semimodule R M\u2082] {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)]\n    [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] (f : (i : \u03b9) \u2192 linear_map R M\u2082 (\u03c6 i)) (i : \u03b9) :\n    comp (proj i) (pi f) = f i :=\n  ext fun (c : M\u2082) => rfl\n\ntheorem infi_ker_proj {R : Type u} {\u03b9 : Type x} [semiring R] {\u03c6 : \u03b9 \u2192 Type i}\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] :\n    (infi fun (i : \u03b9) => ker (proj i)) = \u22a5 :=\n  sorry\n\n/-- If `I` and `J` are disjoint index sets, the product of the kernels of the `J`th projections of\n`\u03c6` is linearly equivalent to the product over `I`. -/\ndef infi_ker_proj_equiv (R : Type u) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] {I : set \u03b9} {J : set \u03b9}\n    [decidable_pred fun (i : \u03b9) => i \u2208 I] (hd : disjoint I J) (hu : set.univ \u2286 I \u222a J) :\n    linear_equiv R (\u21a5(infi fun (i : \u03b9) => infi fun (H : i \u2208 J) => ker (proj i)))\n        ((i : \u21a5I) \u2192 \u03c6 \u2191i) :=\n  linear_equiv.of_linear\n    (pi\n      fun (i : \u21a5I) =>\n        comp (proj \u2191i)\n          (submodule.subtype (infi fun (i : \u03b9) => infi fun (H : i \u2208 J) => ker (proj i))))\n    (cod_restrict (infi fun (i : \u03b9) => infi fun (H : i \u2208 J) => ker (proj i))\n      (pi\n        fun (i : \u03b9) =>\n          dite (i \u2208 I) (fun (h : i \u2208 I) => proj { val := i, property := h }) fun (h : \u00aci \u2208 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} {\u03b9 : Type x} [semiring R] {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)]\n    [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9) (j : \u03b9) : linear_map R (\u03c6 i) (\u03c6 j) :=\n  function.update 0 i id j\n\ntheorem update_apply {R : Type u} {M\u2082 : Type w} {\u03b9 : Type x} [semiring R] [add_comm_monoid M\u2082]\n    [semimodule R M\u2082] {\u03c6 : \u03b9 \u2192 Type i} [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)]\n    [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (f : (i : \u03b9) \u2192 linear_map R M\u2082 (\u03c6 i)) (c : M\u2082)\n    (i : \u03b9) (j : \u03b9) (b : linear_map R M\u2082 (\u03c6 i)) :\n    coe_fn (function.update f i b j) c =\n        function.update (fun (i : \u03b9) => coe_fn (f i) c) i (coe_fn b c) j :=\n  sorry\n\n/-- The standard basis of the product of `\u03c6`. -/\ndef std_basis (R : Type u) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9) :\n    linear_map R (\u03c6 i) ((i : \u03b9) \u2192 \u03c6 i) :=\n  pi (diag i)\n\ntheorem std_basis_apply (R : Type u) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9)\n    (b : \u03c6 i) : coe_fn (std_basis R \u03c6 i) b = function.update 0 i b :=\n  sorry\n\n@[simp] theorem std_basis_same (R : Type u) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9)\n    (b : \u03c6 i) : coe_fn (std_basis R \u03c6 i) b i = b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (std_basis R \u03c6 i) b i = b)) (std_basis_apply R \u03c6 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) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9) (j : \u03b9)\n    (h : j \u2260 i) (b : \u03c6 i) : coe_fn (std_basis R \u03c6 i) b j = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (std_basis R \u03c6 i) b j = 0)) (std_basis_apply R \u03c6 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) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9) :\n    ker (std_basis R \u03c6 i) = \u22a5 :=\n  sorry\n\ntheorem proj_comp_std_basis (R : Type u) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9)\n    (j : \u03b9) : comp (proj i) (std_basis R \u03c6 j) = diag j i :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (comp (proj i) (std_basis R \u03c6 j) = diag j i))\n        (std_basis.equations._eqn_1 R \u03c6 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) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9) :\n    comp (proj i) (std_basis R \u03c6 i) = id :=\n  sorry\n\ntheorem proj_std_basis_ne (R : Type u) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (i : \u03b9) (j : \u03b9)\n    (h : i \u2260 j) : comp (proj i) (std_basis R \u03c6 j) = 0 :=\n  sorry\n\ntheorem supr_range_std_basis_le_infi_ker_proj (R : Type u) {\u03b9 : Type x} [semiring R]\n    (\u03c6 : \u03b9 \u2192 Type i) [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)]\n    [DecidableEq \u03b9] (I : set \u03b9) (J : set \u03b9) (h : disjoint I J) :\n    (supr fun (i : \u03b9) => supr fun (H : i \u2208 I) => range (std_basis R \u03c6 i)) \u2264\n        infi fun (i : \u03b9) => infi fun (H : i \u2208 J) => ker (proj i) :=\n  sorry\n\ntheorem infi_ker_proj_le_supr_range_std_basis (R : Type u) {\u03b9 : Type x} [semiring R]\n    (\u03c6 : \u03b9 \u2192 Type i) [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)]\n    [DecidableEq \u03b9] {I : finset \u03b9} {J : set \u03b9} (hu : set.univ \u2286 \u2191I \u222a J) :\n    (infi fun (i : \u03b9) => infi fun (H : i \u2208 J) => ker (proj i)) \u2264\n        supr fun (i : \u03b9) => supr fun (H : i \u2208 I) => range (std_basis R \u03c6 i) :=\n  sorry\n\ntheorem supr_range_std_basis_eq_infi_ker_proj (R : Type u) {\u03b9 : Type x} [semiring R]\n    (\u03c6 : \u03b9 \u2192 Type i) [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)]\n    [DecidableEq \u03b9] {I : set \u03b9} {J : set \u03b9} (hd : disjoint I J) (hu : set.univ \u2286 I \u222a J)\n    (hI : set.finite I) :\n    (supr fun (i : \u03b9) => supr fun (H : i \u2208 I) => range (std_basis R \u03c6 i)) =\n        infi fun (i : \u03b9) => infi fun (H : i \u2208 J) => ker (proj i) :=\n  sorry\n\ntheorem supr_range_std_basis (R : Type u) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] [fintype \u03b9] :\n    (supr fun (i : \u03b9) => range (std_basis R \u03c6 i)) = \u22a4 :=\n  sorry\n\ntheorem disjoint_std_basis_std_basis (R : Type u) {\u03b9 : Type x} [semiring R] (\u03c6 : \u03b9 \u2192 Type i)\n    [(i : \u03b9) \u2192 add_comm_monoid (\u03c6 i)] [(i : \u03b9) \u2192 semimodule R (\u03c6 i)] [DecidableEq \u03b9] (I : set \u03b9)\n    (J : set \u03b9) (h : disjoint I J) :\n    disjoint (supr fun (i : \u03b9) => supr fun (H : i \u2208 I) => range (std_basis R \u03c6 i))\n        (supr fun (i : \u03b9) => supr fun (H : i \u2208 J) => range (std_basis R \u03c6 i)) :=\n  sorry\n\ntheorem std_basis_eq_single (R : Type u) {\u03b9 : Type x} [semiring R] [DecidableEq \u03b9] {a : R} :\n    (fun (i : \u03b9) => coe_fn (std_basis R (fun (_x : \u03b9) => R) i) a) =\n        fun (i : \u03b9) => \u21d1(finsupp.single i a) :=\n  sorry\n\n/-- Given an `R`-module `M` and a function `m \u2192 n` between arbitrary types,\nconstruct a linear map `(n \u2192 M) \u2192\u2097[R] (m \u2192 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 \u2192 n) : linear_map R (n \u2192 M) (m \u2192 M) :=\n  mk (fun (_x : n \u2192 M) => _x \u2218 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 \u2192 n) (g : n \u2192 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 \u2192 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\u2081 : n \u2192 p) (f\u2082 : m \u2192 n) :\n    fun_left R M (f\u2081 \u2218 f\u2082) = comp (fun_left R M f\u2082) (fun_left R M f\u2081) :=\n  rfl\n\n/-- Given an `R`-module `M` and an equivalence `m \u2243 n` between arbitrary types,\nconstruct a linear equivalence `(n \u2192 M) \u2243\u2097[R] (m \u2192 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 \u2243 n) : linear_equiv R (n \u2192 M) (m \u2192 M) :=\n  linear_equiv.of_linear (fun_left R M \u21d1e) (fun_left R M \u21d1(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 \u2243 n) (x : n \u2192 M) :\n    coe_fn (fun_congr_left R M e) x = coe_fn (fun_left R M \u21d1e) 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 \u2192 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\u2081 : m \u2243 n) (e\u2082 : n \u2243 p) :\n    fun_congr_left R M (equiv.trans e\u2081 e\u2082) =\n        linear_equiv.trans (fun_congr_left R M e\u2082) (fun_congr_left R M e\u2081) :=\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 \u2243 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 \u2191f \u2191(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 \u2243* 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    \u2191(coe_fn (general_linear_equiv R M) f) = \u2191f :=\n  ext fun (x : M) => Eq.refl (coe_fn (\u2191(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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 (\u03b1 : Type*) :=\n(measure_of : set \u03b1 \u2192 ennreal)\n(empty : measure_of \u2205 = 0)\n(mono : \u2200{s\u2081 s\u2082}, s\u2081 \u2286 s\u2082 \u2192 measure_of s\u2081 \u2264 measure_of s\u2082)\n(Union_nat : \u2200(s:\u2115 \u2192 set \u03b1), measure_of (\u22c3i, s i) \u2264 (\u2211i, measure_of (s i)))\n\nnamespace outer_measure\n\ninstance {\u03b1} : has_coe_to_fun (outer_measure \u03b1) := \u27e8_, \u03bb m, m.measure_of\u27e9\n\nsection basic\nvariables {\u03b1 : Type*} {ms : set (outer_measure \u03b1)} {m : outer_measure \u03b1}\n\n@[simp] theorem empty' (m : outer_measure \u03b1) : m \u2205 = 0 := m.empty\n\ntheorem mono' (m : outer_measure \u03b1) {s\u2081 s\u2082}\n  (h : s\u2081 \u2286 s\u2082) : m s\u2081 \u2264 m s\u2082 := m.mono h\n\ntheorem Union_aux (m : set \u03b1 \u2192 ennreal) (m0 : m \u2205 = 0)\n  {\u03b2} [encodable \u03b2] (s : \u03b2 \u2192 set \u03b1) :\n  (\u2211 b, m (s b)) = \u2211 i, m (\u22c3 b \u2208 decode2 \u03b2 i, s b) :=\nbegin\n  have H : \u2200 n, m (\u22c3 b \u2208 decode2 \u03b2 n, s b) \u2260 0 \u2192 (decode2 \u03b2 n).is_some,\n  { intros n h,\n    cases decode2 \u03b2 n with b,\n    { exact (h (by simp [m0])).elim },\n    { exact rfl } },\n  refine tsum_eq_tsum_of_ne_zero_bij (\u03bb 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 [\u2190 e, mem_decode2.1 (option.get_mem (H m hm))] at this },\n  { intros b h,\n    refine \u27e8encode b, _, _\u27e9,\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 \u03b2 n = _, from option.get_mem (H n h)],\n    congr, simp [ext_iff] }\nend\n\nprotected theorem Union (m : outer_measure \u03b1)\n  {\u03b2} [encodable \u03b2] (s : \u03b2 \u2192 set \u03b1) :\n  m (\u22c3i, s i) \u2264 (\u2211i, m (s i)) :=\nby rw [Union_decode2, Union_aux _ m.empty' s]; exact m.Union_nat _\n\nlemma Union_null (m : outer_measure \u03b1)\n  {\u03b2} [encodable \u03b2] {s : \u03b2 \u2192 set \u03b1} (h : \u2200 i, m (s i) = 0) : m (\u22c3i, s i) = 0 :=\nby simpa [h] using m.Union s\n\nprotected lemma union (m : outer_measure \u03b1) (s\u2081 s\u2082 : set \u03b1) :\n  m (s\u2081 \u222a s\u2082) \u2264 m s\u2081 + m s\u2082 :=\nbegin\n  convert m.Union (\u03bb b, cond b s\u2081 s\u2082),\n  { simp [union_eq_Union] },\n  { rw tsum_fintype, change _ = _ + _, simp }\nend\n\nlemma union_null (m : outer_measure \u03b1) {s\u2081 s\u2082 : set \u03b1}\n  (h\u2081 : m s\u2081 = 0) (h\u2082 : m s\u2082 = 0) : m (s\u2081 \u222a s\u2082) = 0 :=\nby simpa [h\u2081, h\u2082] using m.union s\u2081 s\u2082\n\n@[extensionality] lemma ext : \u2200{\u03bc\u2081 \u03bc\u2082 : outer_measure \u03b1},\n  (\u2200s, \u03bc\u2081 s = \u03bc\u2082 s) \u2192 \u03bc\u2081 = \u03bc\u2082\n| \u27e8m\u2081, e\u2081, _, u\u2081\u27e9 \u27e8m\u2082, e\u2082, _, u\u2082\u27e9 h := by congr; exact funext h\n\ninstance : has_zero (outer_measure \u03b1) :=\n\u27e8{ measure_of := \u03bb_, 0,\n   empty      := rfl,\n   mono       := assume _ _ _, le_refl 0,\n   Union_nat  := assume s, zero_le _ }\u27e9\n\n@[simp] theorem zero_apply (s : set \u03b1) : (0 : outer_measure \u03b1) s = 0 := rfl\n\ninstance : inhabited (outer_measure \u03b1) := \u27e80\u27e9\n\ninstance : has_add (outer_measure \u03b1) :=\n\u27e8\u03bbm\u2081 m\u2082,\n  { measure_of := \u03bbs, m\u2081 s + m\u2082 s,\n    empty      := show m\u2081 \u2205 + m\u2082 \u2205 = 0, by simp [outer_measure.empty],\n    mono       := assume s\u2081 s\u2082 h, add_le_add' (m\u2081.mono h) (m\u2082.mono h),\n    Union_nat  := assume s,\n      calc m\u2081 (\u22c3i, s i) + m\u2082 (\u22c3i, s i) \u2264\n          (\u2211i, m\u2081 (s i)) + (\u2211i, m\u2082 (s i)) :\n          add_le_add' (m\u2081.Union_nat s) (m\u2082.Union_nat s)\n        ... = _ : ennreal.tsum_add.symm}\u27e9\n\n@[simp] theorem add_apply (m\u2081 m\u2082 : outer_measure \u03b1) (s : set \u03b1) :\n  (m\u2081 + m\u2082) s = m\u2081 s + m\u2082 s := rfl\n\ninstance : add_comm_monoid (outer_measure \u03b1) :=\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 \u03b1) := \u27e80\u27e9\n\ninstance outer_measure.order_bot : order_bot (outer_measure \u03b1) :=\n{ le          := \u03bbm\u2081 m\u2082, \u2200s, m\u2081 s \u2264 m\u2082 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 \u03b1) :=\n\u27e8\u03bbms, {\n  measure_of := \u03bbs, \u2a06m:ms, m.val s,\n  empty      := le_zero_iff_eq.1 $ supr_le $ \u03bb \u27e8m, h\u27e9, le_of_eq m.empty,\n  mono       := assume s\u2081 s\u2082 hs, supr_le_supr $ assume \u27e8m, hm\u27e9, m.mono hs,\n  Union_nat  := assume f, supr_le $ assume m,\n    calc m.val (\u22c3i, f i) \u2264 (\u2211 (i : \u2115), m.val (f i)) : m.val.Union_nat _\n      ... \u2264 (\u2211i, \u2a06m:ms, m.val (f i)) :\n        ennreal.tsum_le_tsum $ assume i, le_supr (\u03bbm:ms, m.val (f i)) m }\u27e9\n\nprivate lemma le_Sup (hm : m \u2208 ms) : m \u2264 Sup ms :=\n\u03bb s, le_supr (\u03bbm:ms, m.val s) \u27e8m, hm\u27e9\n\nprivate lemma Sup_le (hm : \u2200m' \u2208 ms, m' \u2264 m) : Sup ms \u2264 m :=\n\u03bb s, (supr_le $ assume \u27e8m', h'\u27e9, (hm m' h') s)\n\ninstance : has_Inf (outer_measure \u03b1) := \u27e8\u03bbs, Sup {m | \u2200m'\u2208s, m \u2264 m'}\u27e9\nprivate lemma Inf_le (hm : m \u2208 ms) : Inf ms \u2264 m := Sup_le $ assume m' h', h' _ hm\nprivate lemma le_Inf (hm : \u2200m' \u2208 ms, m \u2264 m') : m \u2264 Inf ms := le_Sup hm\n\ninstance : complete_lattice (outer_measure \u03b1) :=\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          := \u03bba 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          := \u03bba 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 \u03b1)) (s : set \u03b1) :\n  (Sup ms) s = \u2a06 m : ms, m s := rfl\n\n@[simp] theorem supr_apply {\u03b9} (f : \u03b9 \u2192 outer_measure \u03b1) (s : set \u03b1) :\n  (\u2a06 i : \u03b9, f i) s = \u2a06 i, f i s :=\nle_antisymm\n  (supr_le $ \u03bb \u27e8_, i, rfl\u27e9, le_supr _ i)\n  (supr_le $ \u03bb i, le_supr\n    (\u03bb (m : {a : outer_measure \u03b1 // \u2203 i, a = f i}), m.1 s)\n    \u27e8f i, i, rfl\u27e9)\n\n@[simp] theorem sup_apply (m\u2081 m\u2082 : outer_measure \u03b1) (s : set \u03b1) :\n  (m\u2081 \u2294 m\u2082) s = m\u2081 s \u2294 m\u2082 s :=\nby have := supr_apply (\u03bb b, cond b m\u2081 m\u2082) s;\n  rwa [supr_bool_eq, supr_bool_eq] at this\n\nend supremum\n\ndef map {\u03b2} (f : \u03b1 \u2192 \u03b2) (m : outer_measure \u03b1) : outer_measure \u03b2 :=\n{ measure_of := \u03bbs, m (f \u207b\u00b9' s),\n  empty := m.empty,\n  mono := \u03bb s t h, m.mono (preimage_mono h),\n  Union_nat := \u03bb s, by rw [preimage_Union]; exact\n    m.Union_nat (\u03bb i, f \u207b\u00b9' s i) }\n\n@[simp] theorem map_apply {\u03b2} (f : \u03b1 \u2192 \u03b2)\n  (m : outer_measure \u03b1) (s : set \u03b2) : map f m s = m (f \u207b\u00b9' s) := rfl\n\n@[simp] theorem map_id (m : outer_measure \u03b1) : map id m = m :=\next $ \u03bb s, rfl\n\n@[simp] theorem map_map {\u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3)\n  (m : outer_measure \u03b1) : map g (map f m) = map (g \u2218 f) m :=\next $ \u03bb s, rfl\n\ninstance : functor outer_measure := {map := \u03bb \u03b1 \u03b2, map}\n\ninstance : is_lawful_functor outer_measure :=\n{ id_map := \u03bb \u03b1, map_id,\n  comp_map := \u03bb \u03b1 \u03b2 \u03b3 f g m, (map_map f g m).symm }\n\n/-- The dirac outer measure. -/\ndef dirac (a : \u03b1) : outer_measure \u03b1 :=\n{ measure_of := \u03bbs, \u2a06 h : a \u2208 s, 1,\n  empty := by simp,\n  mono := \u03bb s t h, supr_le_supr2 (\u03bb h', \u27e8h h', le_refl _\u27e9),\n  Union_nat := \u03bb s, supr_le $ \u03bb h,\n    let \u27e8i, h\u27e9 := mem_Union.1 h in\n    le_trans (by exact le_supr _ h) (ennreal.le_tsum i) }\n\n@[simp] theorem dirac_apply (a : \u03b1) (s : set \u03b1) :\n  dirac a s = \u2a06 h : a \u2208 s, 1 := rfl\n\ndef sum {\u03b9} (f : \u03b9 \u2192 outer_measure \u03b1) : outer_measure \u03b1 :=\n{ measure_of := \u03bbs, \u2211 i, f i s,\n  empty := by simp,\n  mono := \u03bb s t h, ennreal.tsum_le_tsum (\u03bb i, (f i).mono' h),\n  Union_nat := \u03bb s, by rw ennreal.tsum_comm; exact\n    ennreal.tsum_le_tsum (\u03bb i, (f i).Union_nat _) }\n\n@[simp] theorem sum_apply {\u03b9} (f : \u03b9 \u2192 outer_measure \u03b1) (s : set \u03b1) :\n  sum f s = \u2211 i, f i s := rfl\n\ninstance : has_scalar ennreal (outer_measure \u03b1) :=\n\u27e8\u03bb a m, {\n  measure_of := \u03bbs, a * m s,\n  empty := by simp,\n  mono := \u03bb s t h, canonically_ordered_semiring.mul_le_mul (le_refl _) (m.mono' h),\n  Union_nat := \u03bb s, by rw ennreal.mul_tsum; exact\n    canonically_ordered_semiring.mul_le_mul (le_refl _) (m.Union_nat _) }\u27e9\n\n@[simp] theorem smul_apply (a : ennreal) (m : outer_measure \u03b1) (s : set \u03b1) :\n  (a \u2022 m) s = a * m s := rfl\n\ninstance : semimodule ennreal (outer_measure \u03b1) :=\n{ smul_add := \u03bb a m\u2081 m\u2082, ext $ \u03bb s, mul_add _ _ _,\n  add_smul := \u03bb a b m, ext $ \u03bb s, add_mul _ _ _,\n  mul_smul := \u03bb a b m, ext $ \u03bb s, mul_assoc _ _ _,\n  one_smul := \u03bb m, ext $ \u03bb s, one_mul _,\n  zero_smul := \u03bb m, ext $ \u03bb s, zero_mul _,\n  smul_zero := \u03bb a, ext $ \u03bb s, mul_zero _,\n  ..outer_measure.has_scalar }\n\ntheorem smul_dirac_apply (a : ennreal) (b : \u03b1) (s : set \u03b1) :\n  (a \u2022 dirac b) s = \u2a06 h : b \u2208 s, a :=\nby by_cases b \u2208 s; simp [h]\n\ntheorem top_apply {s : set \u03b1} (h : s \u2260 \u2205) : (\u22a4 : outer_measure \u03b1) s = \u22a4 :=\nlet \u27e8a, as\u27e9 := set.exists_mem_of_ne_empty h in\ntop_unique $ le_supr_of_le \u27e8\u22a4 \u2022 dirac a, trivial\u27e9 $\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 \u2205 = 0`, there is\n  a unique maximal outer measure `\u03bc` satisfying `\u03bc s \u2264 m s` for all `s : set \u03b1`. -/\nprotected def of_function {\u03b1 : Type*} (m : set \u03b1 \u2192 ennreal) (m_empty : m \u2205 = 0) :\n  outer_measure \u03b1 :=\nlet \u03bc := \u03bbs, \u2a05{f : \u2115 \u2192 set \u03b1} (h : s \u2286 \u22c3i, f i), \u2211i, m (f i) in\n{ measure_of := \u03bc,\n  empty      := le_antisymm\n    (infi_le_of_le (\u03bb_, \u2205) $ infi_le_of_le (empty_subset _) $ by simp [m_empty])\n    (zero_le _),\n  mono       := assume s\u2081 s\u2082 hs, infi_le_infi $ assume f,\n    infi_le_infi2 $ assume hb, \u27e8subset.trans hs hb, le_refl _\u27e9,\n  Union_nat := assume s, ennreal.le_of_forall_epsilon_le $ begin\n    assume \u03b5 h\u03b5 (hb : (\u2211i, \u03bc (s i)) < \u22a4),\n    rcases ennreal.exists_pos_sum_of_encodable (ennreal.coe_lt_coe.2 h\u03b5) \u2115 with \u27e8\u03b5', h\u03b5', hl\u27e9,\n    refine le_trans _ (add_le_add_left' (le_of_lt hl)),\n    rw \u2190 ennreal.tsum_add,\n    have : \u2200i, \u2203f:\u2115 \u2192 set \u03b1, s i \u2286 (\u22c3i, f i) \u2227 (\u2211i, m (f i)) < \u03bc (s i) + \u03b5' i,\n    { intro,\n      have : \u03bc (s i) < \u03bc (s i) + \u03b5' i :=\n        ennreal.lt_add_right\n          (lt_of_le_of_lt (by apply ennreal.le_tsum) hb)\n          (by simpa using h\u03b5' i),\n      simpa [\u03bc, 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 $ \u03bb i, le_of_lt (hf i).2),\n    rw [\u2190 ennreal.tsum_prod, \u2190 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 (\u03bb i, subset.trans (hf i).1 $\n      Union_subset $ \u03bb j, subset.trans (by simp) $\n      subset_Union _ $ equiv.nat_prod_nat_equiv_nat (i, j)),\n  end }\n\ntheorem of_function_le {\u03b1 : Type*} (m : set \u03b1 \u2192 ennreal) (m_empty s) :\n  outer_measure.of_function m m_empty s \u2264 m s :=\nlet f : \u2115 \u2192 set \u03b1 := \u03bbi, nat.rec_on i s (\u03bbn s, \u2205) in\ninfi_le_of_le f $ infi_le_of_le (subset_Union f 0) $ le_of_eq $\ncalc (\u2211i, m (f i)) = ({0} : finset \u2115).sum (\u03bbi, 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 {\u03b1 : Type*} {m m_empty} {\u03bc : outer_measure \u03b1} :\n  \u03bc \u2264 outer_measure.of_function m m_empty \u2194 \u2200 s, \u03bc s \u2264 m s :=\n\u27e8\u03bb H s, le_trans (H _) (of_function_le _ _ _),\n \u03bb H s, le_infi $ \u03bb f, le_infi $ \u03bb hs,\n  le_trans (\u03bc.mono hs) $ le_trans (\u03bc.Union f) $\n  ennreal.tsum_le_tsum $ \u03bb i, H _\u27e9\n\nend of_function\n\nsection caratheodory_measurable\nuniverse u\nparameters {\u03b1 : Type u} (m : outer_measure \u03b1)\ninclude m\n\nlocal attribute [simp] set.inter_comm set.inter_left_comm set.inter_assoc\n\nvariables {s s\u2081 s\u2082 : set \u03b1}\n\nprivate def C (s : set \u03b1) := \u2200t, m t = m (t \u2229 s) + m (t \\ s)\n\nprivate lemma C_iff_le {s : set \u03b1} : C s \u2194 \u2200t, m (t \u2229 s) + m (t \\ s) \u2264 m t :=\nforall_congr $ \u03bb 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 \u2205 := by simp [C, m.empty, diff_empty]\n\nprivate lemma C_compl : C s\u2081 \u2192 C (- s\u2081) := by simp [C, diff_eq]\n\n@[simp] private lemma C_compl_iff : C (- s) \u2194 C s :=\n\u27e8\u03bb h, by simpa using C_compl m h, C_compl\u27e9\n\nprivate lemma C_union (h\u2081 : C s\u2081) (h\u2082 : C s\u2082) : C (s\u2081 \u222a s\u2082) :=\n\u03bb t, begin\n  rw [h\u2081 t, h\u2082 (t \u2229 s\u2081), h\u2082 (t \\ s\u2081), h\u2081 (t \u2229 (s\u2081 \u222a s\u2082)),\n    inter_diff_assoc _ _ s\u2081, set.inter_assoc _ _ s\u2081,\n    inter_eq_self_of_subset_right (set.subset_union_left _ _),\n    union_diff_left, h\u2082 (t \u2229 s\u2081)],\n  simp [diff_eq]\nend\n\nprivate lemma measure_inter_union (h : s\u2081 \u2229 s\u2082 \u2286 \u2205) (h\u2081 : C s\u2081) {t : set \u03b1} :\n  m (t \u2229 (s\u2081 \u222a s\u2082)) = m (t \u2229 s\u2081) + m (t \u2229 s\u2082) :=\nby rw [h\u2081, set.inter_assoc, union_inter_cancel_left h,\n  inter_diff_assoc, union_diff_cancel_left h]\n\nprivate lemma C_Union_lt {s : \u2115 \u2192 set \u03b1} : \u2200{n:\u2115}, (\u2200i<n, C (s i)) \u2192 C (\u22c3i<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\u2081 : C s\u2081) (h\u2082 : C s\u2082) : C (s\u2081 \u2229 s\u2082) :=\nby rw [\u2190 C_compl_iff, compl_inter]; from C_union _ (C_compl _ h\u2081) (C_compl _ h\u2082)\n\nprivate lemma C_sum {s : \u2115 \u2192 set \u03b1} (h : \u2200i, C (s i)) (hd : pairwise (disjoint on s)) {t : set \u03b1} :\n  \u2200 {n}, (finset.range n).sum (\u03bbi, m (t \u2229 s i)) = m (t \u2229 \u22c3i<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 \u03bb h\u2081 i hi h\u2082, hd _ _ (ne_of_gt hi) \u27e8h\u2081, h\u2082\u27e9\nend\n\nprivate lemma C_Union_nat {s : \u2115 \u2192 set \u03b1} (h : \u2200i, C (s i))\n  (hd : pairwise (disjoint on s)) : C (\u22c3i, s i) :=\nC_iff_le.2 $ \u03bb t, begin\n  have hp : m (t \u2229 \u22c3i, s i) \u2264 (\u2a06n, m (t \u2229 \u22c3i<n, s i)),\n  { convert m.Union (\u03bb i, t \u2229 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 (\u03bb n, le_trans (add_le_add_left' _)\n    (ge_of_eq (C_Union_lt m (\u03bb i _, h i) _))),\n  refine m.mono (diff_subset_diff_right _),\n  exact bUnion_subset (\u03bb i _, subset_Union _ i),\nend\n\nprivate lemma f_Union {s : \u2115 \u2192 set \u03b1} (h : \u2200i, C (s i))\n  (hd : pairwise (disjoint on s)) : m (\u22c3i, s i) = \u2211i, m (s i) :=\nbegin\n  refine le_antisymm (m.Union_nat s) _,\n  rw ennreal.tsum_eq_supr_nat,\n  refine supr_le (\u03bb n, _),\n  have := @C_sum _ m _ h hd univ n,\n  simp at this, simp [this],\n  exact m.mono (bUnion_subset (\u03bb i _, subset_Union _ i)),\nend\n\nprivate def caratheodory_dynkin : measurable_space.dynkin_system \u03b1 :=\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 `\u03bc`, the Caratheodory measurable space is\n  defined such that `s` is measurable if `\u2200t, \u03bc t = \u03bc (t \u2229 s) + \u03bc (t \\ s)`. -/\nprotected def caratheodory : measurable_space \u03b1 :=\ncaratheodory_dynkin.to_measurable_space $ assume s\u2081 s\u2082, C_inter\n\nlemma is_caratheodory {s : set \u03b1} :\n  caratheodory.is_measurable s \u2194 \u2200t, m t = m (t \u2229 s) + m (t \\ s) :=\niff.rfl\n\nlemma is_caratheodory_le {s : set \u03b1} :\n  caratheodory.is_measurable s \u2194 \u2200t, m (t \u2229 s) + m (t \\ s) \u2264 m t :=\nC_iff_le\n\nprotected lemma Union_eq_of_caratheodory {s : \u2115 \u2192 set \u03b1}\n  (h : \u2200i, caratheodory.is_measurable (s i)) (hd : pairwise (disjoint on s)) :\n  m (\u22c3i, s i) = \u2211i, m (s i) :=\nf_Union h hd\n\nend caratheodory_measurable\n\nvariables {\u03b1 : Type*}\n\nlemma caratheodory_is_measurable {m : set \u03b1 \u2192 ennreal} {s : set \u03b1}\n  {h\u2080 : m \u2205 = 0} (hs : \u2200t, m (t \u2229 s) + m (t \\ s) \u2264 m t) :\n  (outer_measure.of_function m h\u2080).caratheodory.is_measurable s :=\nlet o := (outer_measure.of_function m h\u2080) in\n(is_caratheodory_le o).2 $ \u03bb t,\nle_infi $ \u03bb f, le_infi $ \u03bb hf, begin\n  refine le_trans (add_le_add'\n    (infi_le_of_le (\u03bbi, f i \u2229 s) $ infi_le _ _)\n    (infi_le_of_le (\u03bbi, f i \\ s) $ infi_le _ _)) _,\n  { rw \u2190 inter_Union_right,\n    exact inter_subset_inter_left _ hf },\n  { rw \u2190 diff_Union_right,\n    exact diff_subset_diff_left hf },\n  { rw \u2190 ennreal.tsum_add,\n    exact ennreal.tsum_le_tsum (\u03bb i, hs _) }\nend\n\n@[simp] theorem zero_caratheodory : (0 : outer_measure \u03b1).caratheodory = \u22a4 :=\ntop_unique $ \u03bb s _ t, (add_zero _).symm\n\ntheorem le_add_caratheodory (m\u2081 m\u2082 : outer_measure \u03b1) :\n  m\u2081.caratheodory \u2293 m\u2082.caratheodory \u2264 (m\u2081 + m\u2082 : outer_measure \u03b1).caratheodory :=\n\u03bb s \u27e8hs\u2081, hs\u2082\u27e9 t, by simp [hs\u2081 t, hs\u2082 t]\n\ntheorem le_sum_caratheodory {\u03b9} (m : \u03b9 \u2192 outer_measure \u03b1) :\n  (\u2a05 i, (m i).caratheodory) \u2264 (sum m).caratheodory :=\n\u03bb s h t, by simp [\u03bb i,\n  measurable_space.is_measurable_infi.1 h i t, ennreal.tsum_add]\n\ntheorem le_smul_caratheodory (a : ennreal) (m : outer_measure \u03b1) :\n  m.caratheodory \u2264 (a \u2022 m).caratheodory :=\n\u03bb s h t, by simp [h t, mul_add]\n\n@[simp] theorem dirac_caratheodory (a : \u03b1) : (dirac a).caratheodory = \u22a4 :=\ntop_unique $ \u03bb s _ t, begin\n  by_cases a \u2208 t; simp [h],\n  by_cases a \u2208 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 \u2245 Y` : same as `iso X Y`;\n- `\u03b1 \u226a\u226b \u03b2` : 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 \u27f6 Y)\n(inv : Y \u27f6 X)\n(hom_inv_id' : hom \u226b inv = \ud835\udfd9 X . obviously)\n(inv_hom_id' : inv \u226b hom = \ud835\udfd9 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 ` \u2245 `: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 \u2983\u03b1 \u03b2 : X \u2245 Y\u2984 (w : \u03b1.hom = \u03b2.hom) : \u03b1 = \u03b2 :=\nsuffices \u03b1.inv = \u03b2.inv, by cases \u03b1; cases \u03b2; cc,\ncalc \u03b1.inv\n    = \u03b1.inv \u226b (\u03b2.hom \u226b \u03b2.inv) : by rw [iso.hom_inv_id, category.comp_id]\n... = (\u03b1.inv \u226b \u03b1.hom) \u226b \u03b2.inv : by rw [category.assoc, \u2190w]\n... = \u03b2.inv                   : by rw [iso.inv_hom_id, category.id_comp]\n\n/-- Inverse isomorphism. -/\n@[symm] def symm (I : X \u2245 Y) : Y \u2245 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 (\u03b1 : X \u2245 Y) : \u03b1.symm.hom = \u03b1.inv := rfl\n@[simp] lemma symm_inv (\u03b1 : X \u2245 Y) : \u03b1.symm.inv = \u03b1.hom := rfl\n\n@[simp] lemma symm_mk {X Y : C} (hom : X \u27f6 Y) (inv : Y \u27f6 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} (\u03b1 : X \u2245 Y) : \u03b1.symm.symm = \u03b1 :=\nby cases \u03b1; refl\n\n@[simp] lemma symm_eq_iff {X Y : C} {\u03b1 \u03b2 : X \u2245 Y} : \u03b1.symm = \u03b2.symm \u2194 \u03b1 = \u03b2 :=\n\u27e8\u03bb h, symm_symm_eq \u03b1 \u25b8 symm_symm_eq \u03b2 \u25b8 congr_arg symm h, congr_arg symm\u27e9\n\n/-- Identity isomorphism. -/\n@[refl, simps] def refl (X : C) : X \u2245 X :=\n{ hom := \ud835\udfd9 X,\n  inv := \ud835\udfd9 X }\n\ninstance : inhabited (X \u2245 X) := \u27e8iso.refl X\u27e9\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 (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) : X \u2245 Z :=\n{ hom := \u03b1.hom \u226b \u03b2.hom,\n  inv := \u03b2.inv \u226b \u03b1.inv }\n\ninfixr ` \u226a\u226b `:80 := iso.trans -- type as `\\ll \\gg`.\n\n@[simp] lemma trans_mk {X Y Z : C}\n  (hom : X \u27f6 Y) (inv : Y \u27f6 X) (hom_inv_id) (inv_hom_id)\n  (hom' : Y \u27f6 Z) (inv' : Z \u27f6 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 \u226b hom', inv := inv' \u226b inv, hom_inv_id' := hom_inv_id'',\n    inv_hom_id' := inv_hom_id''} :=\nrfl\n\n@[simp] lemma trans_symm (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) : (\u03b1 \u226a\u226b \u03b2).symm = \u03b2.symm \u226a\u226b \u03b1.symm := rfl\n@[simp] lemma trans_assoc {Z' : C} (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) (\u03b3 : Z \u2245 Z') :\n  (\u03b1 \u226a\u226b \u03b2) \u226a\u226b \u03b3 = \u03b1 \u226a\u226b \u03b2 \u226a\u226b \u03b3 :=\nby ext; simp only [trans_hom, category.assoc]\n\n@[simp] lemma refl_trans (\u03b1 : X \u2245 Y) : (iso.refl X) \u226a\u226b \u03b1 = \u03b1 := by ext; apply category.id_comp\n@[simp] lemma trans_refl (\u03b1 : X \u2245 Y) : \u03b1 \u226a\u226b (iso.refl Y) = \u03b1 := by ext; apply category.comp_id\n\n@[simp] lemma symm_self_id (\u03b1 : X \u2245 Y) : \u03b1.symm \u226a\u226b \u03b1 = iso.refl Y := ext \u03b1.inv_hom_id\n@[simp] lemma self_symm_id (\u03b1 : X \u2245 Y) : \u03b1 \u226a\u226b \u03b1.symm = iso.refl X := ext \u03b1.hom_inv_id\n\n@[simp] lemma symm_self_id_assoc (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) : \u03b1.symm \u226a\u226b \u03b1 \u226a\u226b \u03b2 = \u03b2 :=\nby rw [\u2190 trans_assoc, symm_self_id, refl_trans]\n\n@[simp] lemma self_symm_id_assoc (\u03b1 : X \u2245 Y) (\u03b2 : X \u2245 Z) : \u03b1 \u226a\u226b \u03b1.symm \u226a\u226b \u03b2 = \u03b2 :=\nby rw [\u2190 trans_assoc, self_symm_id, refl_trans]\n\nlemma inv_comp_eq (\u03b1 : X \u2245 Y) {f : X \u27f6 Z} {g : Y \u27f6 Z} : \u03b1.inv \u226b f = g \u2194 f = \u03b1.hom \u226b g :=\n\u27e8\u03bb H, by simp [H.symm], \u03bb H, by simp [H]\u27e9\n\nlemma eq_inv_comp (\u03b1 : X \u2245 Y) {f : X \u27f6 Z} {g : Y \u27f6 Z} : g = \u03b1.inv \u226b f \u2194 \u03b1.hom \u226b g = f :=\n(inv_comp_eq \u03b1.symm).symm\n\nlemma comp_inv_eq (\u03b1 : X \u2245 Y) {f : Z \u27f6 Y} {g : Z \u27f6 X} : f \u226b \u03b1.inv = g \u2194 f = g \u226b \u03b1.hom :=\n\u27e8\u03bb H, by simp [H.symm], \u03bb H, by simp [H]\u27e9\n\nlemma eq_comp_inv (\u03b1 : X \u2245 Y) {f : Z \u27f6 Y} {g : Z \u27f6 X} : g = f \u226b \u03b1.inv \u2194 g \u226b \u03b1.hom = f :=\n(comp_inv_eq \u03b1.symm).symm\n\nlemma inv_eq_inv (f g : X \u2245 Y) : f.inv = g.inv \u2194 f.hom = g.hom :=\nhave \u2200{X Y : C} (f g : X \u2245 Y), f.hom = g.hom \u2192 f.inv = g.inv, from \u03bb X Y f g h, by rw [ext h],\n\u27e8this f.symm g.symm, this f g\u27e9\n\nlemma hom_comp_eq_id (\u03b1 : X \u2245 Y) {f : Y \u27f6 X} : \u03b1.hom \u226b f = \ud835\udfd9 X \u2194 f = \u03b1.inv :=\nby rw [\u2190eq_inv_comp, comp_id]\n\nlemma comp_hom_eq_id (\u03b1 : X \u2245 Y) {f : Y \u27f6 X} : f \u226b \u03b1.hom = \ud835\udfd9 Y \u2194 f = \u03b1.inv :=\nby rw [\u2190eq_comp_inv, id_comp]\n\nlemma inv_comp_eq_id (\u03b1 : X \u2245 Y) {f : X \u27f6 Y} : \u03b1.inv \u226b f = \ud835\udfd9 Y \u2194 f = \u03b1.hom :=\nhom_comp_eq_id \u03b1.symm\n\nlemma comp_inv_eq_id (\u03b1 : X \u2245 Y) {f : X \u27f6 Y} : f \u226b \u03b1.inv = \ud835\udfd9 X \u2194 f = \u03b1.hom :=\ncomp_hom_eq_id \u03b1.symm\n\nlemma hom_eq_inv (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 X) : \u03b1.hom = \u03b2.inv \u2194 \u03b2.hom = \u03b1.inv :=\nby { erw [inv_eq_inv \u03b1.symm \u03b2, eq_comm], refl }\n\nend iso\n\n/-- `is_iso` typeclass expressing that a morphism is invertible. -/\nclass is_iso (f : X \u27f6 Y) : Prop :=\n(out : \u2203 inv : Y \u27f6 X, f \u226b inv = \ud835\udfd9 X \u2227 inv \u226b f = \ud835\udfd9 Y)\n\n/--\nThe inverse of a morphism `f` when we have `[is_iso f]`.\n-/\nnoncomputable def inv (f : X \u27f6 Y) [I : is_iso f] := classical.some I.1\n\nnamespace is_iso\n\n@[simp, reassoc] lemma hom_inv_id (f : X \u27f6 Y) [I : is_iso f] : f \u226b inv f = \ud835\udfd9 X :=\n(classical.some_spec I.1).left\n@[simp, reassoc] lemma inv_hom_id (f : X \u27f6 Y) [I : is_iso f] : inv f \u226b f = \ud835\udfd9 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 \u27f6 Y) [h : is_iso f] : X \u2245 Y := \u27e8f, inv f, hom_inv_id f, inv_hom_id f\u27e9\n\n@[simp] lemma as_iso_hom (f : X \u27f6 Y) [is_iso f] : (as_iso f).hom = f := rfl\n@[simp] lemma as_iso_inv (f : X \u27f6 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 \u27f6 Y) [is_iso f] : epi f  :=\n{ left_cancellation := \u03bb Z g h w,\n  -- This is an interesting test case for better rewrite automation.\n  by rw [\u2190 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 \u27f6 Y) [is_iso f] : mono f :=\n{ right_cancellation := \u03bb Z g h w,\n  by rw [\u2190 category.comp_id g, \u2190 category.comp_id h, \u2190 is_iso.hom_inv_id f, \u2190 category.assoc, w,\n    \u2190 category.assoc] }\n\n@[ext] lemma inv_eq_of_hom_inv_id {f : X \u27f6 Y} [is_iso f] {g : Y \u27f6 X}\n  (hom_inv_id : f \u226b g = \ud835\udfd9 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 \u27f6 Y} [is_iso f] {g : Y \u27f6 X}\n  (inv_hom_id : g \u226b f = \ud835\udfd9 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 \u27f6 Y} [is_iso f] {g : Y \u27f6 X}\n  (hom_inv_id : f \u226b g = \ud835\udfd9 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 \u27f6 Y} [is_iso f] {g : Y \u27f6 X}\n  (inv_hom_id : g \u226b f = \ud835\udfd9 Y) : g = inv f :=\n(inv_eq_of_inv_hom_id inv_hom_id).symm\n\n\ninstance id (X : C) : is_iso (\ud835\udfd9 X) :=\n\u27e8\u27e8\ud835\udfd9 X, by simp\u27e9\u27e9\n\ninstance of_iso (f : X \u2245 Y) : is_iso f.hom :=\n\u27e8\u27e8f.inv, by simp\u27e9\u27e9\n\ninstance of_iso_inv (f : X \u2245 Y) : is_iso f.inv :=\nis_iso.of_iso f.symm\n\nvariables {f g : X \u27f6 Y} {h : Y \u27f6 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 \u2245 Y` with `X Y : Type u`.\nWithout the lower priority, typeclass inference cannot deduce `is_iso f.hom`\nbecause `f.hom` is defeq to `(\u03bb x, x) \u226b f.hom`, triggering a loop. -/\n@[priority 900]\ninstance comp_is_iso [is_iso f] [is_iso h] : is_iso (f \u226b h) :=\nis_iso.of_iso $ (as_iso f) \u226a\u226b (as_iso h)\n\n@[simp] lemma inv_id : inv (\ud835\udfd9 X) = \ud835\udfd9 X := by { ext, simp, }\n@[simp] lemma inv_comp [is_iso f] [is_iso h] : inv (f \u226b h) = inv h \u226b 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 \u2245 Y) : inv (f.inv) = f.hom := by { ext, simp, }\n@[simp] lemma iso.inv_hom (f : X \u2245 Y) : inv (f.hom) = f.inv := by { ext, simp, }\n\n@[simp]\nlemma inv_comp_eq (\u03b1 : X \u27f6 Y) [is_iso \u03b1] {f : X \u27f6 Z} {g : Y \u27f6 Z} : inv \u03b1 \u226b f = g \u2194 f = \u03b1 \u226b g :=\n(as_iso \u03b1).inv_comp_eq\n\n@[simp]\nlemma eq_inv_comp (\u03b1 : X \u27f6 Y) [is_iso \u03b1] {f : X \u27f6 Z} {g : Y \u27f6 Z} : g = inv \u03b1 \u226b f \u2194 \u03b1 \u226b g = f :=\n(as_iso \u03b1).eq_inv_comp\n\n@[simp]\nlemma comp_inv_eq (\u03b1 : X \u27f6 Y) [is_iso \u03b1] {f : Z \u27f6 Y} {g : Z \u27f6 X} : f \u226b inv \u03b1 = g \u2194 f = g \u226b \u03b1 :=\n(as_iso \u03b1).comp_inv_eq\n\n@[simp]\nlemma eq_comp_inv (\u03b1 : X \u27f6 Y) [is_iso \u03b1] {f : Z \u27f6 Y} {g : Z \u27f6 X} : g = f \u226b inv \u03b1 \u2194 g \u226b \u03b1 = f :=\n(as_iso \u03b1).eq_comp_inv\n\nlemma of_is_iso_comp_left {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [is_iso f] [is_iso (f \u226b g)] : is_iso g :=\nby { rw [\u2190 id_comp g, \u2190 inv_hom_id f, assoc], apply_instance, }\n\nlemma of_is_iso_comp_right {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [is_iso g] [is_iso (f \u226b g)] : is_iso f :=\nby { rw [\u2190 comp_id f, \u2190 hom_inv_id g, \u2190 assoc], apply_instance, }\n\nlemma of_is_iso_fac_left {X Y Z : C} {f : X \u27f6 Y} {g : Y \u27f6 Z} {h : X \u27f6 Z}\n  [is_iso f] [hh : is_iso h] (w : f \u226b g = h) : is_iso g :=\nby { rw \u2190 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 \u27f6 Y} {g : Y \u27f6 Z} {h : X \u27f6 Z}\n  [is_iso g] [hh : is_iso h] (w : f \u226b g = h) : is_iso f :=\nby { rw \u2190 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 \u27f6 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 \u27f6 Y} [is_iso f] [is_iso g] : inv f = inv g \u2194 f = g :=\niso.inv_eq_inv (as_iso f) (as_iso g)\n\nlemma hom_comp_eq_id (g : X \u27f6 Y) [is_iso g] {f : Y \u27f6 X} : g \u226b f = \ud835\udfd9 X \u2194 f = inv g :=\n(as_iso g).hom_comp_eq_id\n\nlemma comp_hom_eq_id (g : X \u27f6 Y) [is_iso g] {f : Y \u27f6 X} : f \u226b g = \ud835\udfd9 Y \u2194 f = inv g :=\n(as_iso g).comp_hom_eq_id\n\nlemma inv_comp_eq_id (g : X \u27f6 Y) [is_iso g] {f : X \u27f6 Y} : inv g \u226b f = \ud835\udfd9 Y \u2194 f = g :=\n(as_iso g).inv_comp_eq_id\n\nlemma comp_inv_eq_id (g : X \u27f6 Y) [is_iso g] {f : X \u27f6 Y} : f \u226b inv g = \ud835\udfd9 X \u2194 f = g :=\n(as_iso g).comp_inv_eq_id\n\nlemma is_iso_of_hom_comp_eq_id (g : X \u27f6 Y) [is_iso g] {f : Y \u27f6 X} (h : g \u226b f = \ud835\udfd9 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 \u27f6 Y) [is_iso g] {f : Y \u27f6 X} (h : f \u226b g = \ud835\udfd9 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 \u2245 Y} {g : Y \u27f6 X}\n  (hom_inv_id : f.hom \u226b g = \ud835\udfd9 X) : f.inv = g :=\n((hom_comp_eq_id f).1 hom_inv_id).symm\n\n@[ext] lemma inv_ext' {f : X \u2245 Y} {g : Y \u27f6 X}\n  (hom_inv_id : f.hom \u226b g = \ud835\udfd9 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 \u27f6 Y`.\nPresumably we could write `X \u21aa Y` and `X \u21a0 Y`.\n-/\n\n@[simp] lemma cancel_iso_hom_left {X Y Z : C} (f : X \u2245 Y) (g g' : Y \u27f6 Z) :\n  f.hom \u226b g = f.hom \u226b g' \u2194 g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_iso_inv_left {X Y Z : C} (f : Y \u2245 X) (g g' : Y \u27f6 Z) :\n  f.inv \u226b g = f.inv \u226b g' \u2194 g = g' :=\nby simp only [cancel_epi]\n\n@[simp] lemma cancel_iso_hom_right {X Y Z : C} (f f' : X \u27f6 Y) (g : Y \u2245 Z) :\n  f \u226b g.hom = f' \u226b g.hom \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_iso_inv_right {X Y Z : C} (f f' : X \u27f6 Y) (g : Z \u2245 Y) :\n  f \u226b g.inv = f' \u226b g.inv \u2194 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 \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y)\n  (h : Y \u2245 Z) :\n  f \u226b g \u226b h.hom = f' \u226b g' \u226b h.hom \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_iso_inv_right_assoc {W X X' Y Z : C}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y)\n  (h : Z \u2245 Y) :\n  f \u226b g \u226b h.inv = f' \u226b g' \u226b h.inv \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\nend iso\n\nnamespace functor\n\nuniverses u\u2081 v\u2081 u\u2082 v\u2082\nvariables {D : Type u\u2082}\n\nvariables [category.{v\u2082} D]\n\n/-- A functor `F : C \u2964 D` sends isomorphisms `i : X \u2245 Y` to isomorphisms `F.obj X \u2245 F.obj Y` -/\n@[simps]\ndef map_iso (F : C \u2964 D) {X Y : C} (i : X \u2245 Y) : F.obj X \u2245 F.obj Y :=\n{ hom := F.map i.hom,\n  inv := F.map i.inv,\n  hom_inv_id' := by rw [\u2190map_comp, iso.hom_inv_id, \u2190map_id],\n  inv_hom_id' := by rw [\u2190map_comp, iso.inv_hom_id, \u2190map_id] }\n\n@[simp] lemma map_iso_symm (F : C \u2964 D) {X Y : C} (i : X \u2245 Y) :\n  F.map_iso i.symm = (F.map_iso i).symm :=\nrfl\n\n@[simp] lemma map_iso_trans (F : C \u2964 D) {X Y Z : C} (i : X \u2245 Y) (j : Y \u2245 Z) :\n  F.map_iso (i \u226a\u226b j) = (F.map_iso i) \u226a\u226b (F.map_iso j) :=\nby ext; apply functor.map_comp\n\n@[simp] lemma map_iso_refl (F : C \u2964 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 \u2964 D) (f : X \u27f6 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 \u2964 D) {X Y : C} (f : X \u27f6 Y) [is_iso f] :\n  F.map f \u226b F.map (inv f) = \ud835\udfd9 (F.obj X) :=\nby simp\n\nlemma map_inv_hom (F : C \u2964 D) {X Y : C} (f : X \u27f6 Y) [is_iso f] :\n  F.map (inv f) \u226b F.map f = \ud835\udfd9 (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 `\u03c9Sup`). In this sense, it is strictly weaker than join complete\nsemi-lattices as only \u03c9-sized totally ordered sets have a supremum.\n\nThe concept of an omega-complete partial order (\u03c9CPO) 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 \u2192\ud835\udc84)\n   * an instance of `omega_complete_partial_order (\u03b1 \u2192\ud835\udc84 \u03b2)`\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 (\u03b1 : Type*) (\u03b2 : Type*) {\u03b3 : Type*} {\u03c6 : Type*}\nvariables [preorder \u03b1] [preorder \u03b2] [preorder \u03b3] [preorder \u03c6]\n\nvariables {\u03b2 \u03b3}\n\n/-- The constant function, as a monotone function. -/\n@[simps]\ndef const (f : \u03b2) : \u03b1 \u2192\u2098 \u03b2 :=\n{ to_fun := function.const _ f,\n  monotone' := assume x y h, le_refl _}\n\nvariables {\u03b1} {\u03b1' : Type*} {\u03b2' : Type*} [preorder \u03b1'] [preorder \u03b2']\n\n/-- The diagonal function, as a monotone function. -/\n@[simps]\ndef prod.diag : \u03b1 \u2192\u2098 (\u03b1 \u00d7 \u03b1) :=\n{ to_fun := \u03bb x, (x,x),\n  monotone' := \u03bb x y h, \u27e8h,h\u27e9 }\n\n/-- The `prod.map` function, as a monotone function. -/\n@[simps]\ndef prod.map (f : \u03b1 \u2192\u2098 \u03b2) (f' : \u03b1' \u2192\u2098 \u03b2') : (\u03b1 \u00d7 \u03b1') \u2192\u2098 (\u03b2 \u00d7 \u03b2') :=\n{ to_fun := prod.map f f',\n  monotone' := \u03bb \u27e8x,x'\u27e9 \u27e8y,y'\u27e9 \u27e8h,h'\u27e9, \u27e8f.monotone h,f'.monotone h'\u27e9 }\n\n/-- The `prod.fst` projection, as a monotone function. -/\n@[simps]\ndef prod.fst : (\u03b1 \u00d7 \u03b2) \u2192\u2098 \u03b1 :=\n{ to_fun := prod.fst,\n  monotone' := \u03bb \u27e8x,x'\u27e9 \u27e8y,y'\u27e9 \u27e8h,h'\u27e9, h }\n\n/-- The `prod.snd` projection, as a monotone function. -/\n@[simps]\ndef prod.snd : (\u03b1 \u00d7 \u03b2) \u2192\u2098 \u03b2 :=\n{ to_fun := prod.snd,\n  monotone' := \u03bb \u27e8x,x'\u27e9 \u27e8y,y'\u27e9 \u27e8h,h'\u27e9, h' }\n\n/-- The `prod` constructor, as a monotone function. -/\n@[simps]\ndef prod.zip (f : \u03b1 \u2192\u2098 \u03b2) (g : \u03b1 \u2192\u2098 \u03b3) : \u03b1 \u2192\u2098 (\u03b2 \u00d7 \u03b3) :=\n(prod.map f g).comp prod.diag\n\n/-- `roption.bind` as a monotone function -/\n@[simps]\ndef bind {\u03b2 \u03b3} (f : \u03b1 \u2192\u2098 roption \u03b2) (g : \u03b1 \u2192\u2098 \u03b2 \u2192 roption \u03b3) : \u03b1 \u2192\u2098 roption \u03b3 :=\n{ to_fun := \u03bb 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 \u27e8b, f.monotone h _ hb, g.monotone h _ _ ha\u27e9,\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 (\u03b1 : Type u) [preorder \u03b1] :=\n\u2115 \u2192\u2098 \u03b1\n\nnamespace chain\n\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type*}\nvariables [preorder \u03b1] [preorder \u03b2] [preorder \u03b3]\n\ninstance : has_coe_to_fun (chain \u03b1) :=\n@infer_instance (has_coe_to_fun $ \u2115 \u2192\u2098 \u03b1) _\n\ninstance [inhabited \u03b1] : inhabited (chain \u03b1) :=\n\u27e8 \u27e8 \u03bb _, default _, \u03bb _ _ _, le_refl _ \u27e9 \u27e9\n\ninstance : has_mem \u03b1 (chain \u03b1) :=\n\u27e8\u03bba (c : \u2115 \u2192\u2098 \u03b1), \u2203 i, a = c i\u27e9\n\nvariables (c c' : chain \u03b1)\nvariables (f : \u03b1 \u2192\u2098 \u03b2)\nvariables (g : \u03b2 \u2192\u2098 \u03b3)\n\ninstance : has_le (chain \u03b1) :=\n{ le := \u03bb x y, \u2200 i, \u2203 j, x i \u2264 y j  }\n\n/-- `map` function for `chain` -/\n@[simps] def map : chain \u03b2 :=\nf.comp c\n\nvariables {f}\n\nlemma mem_map (x : \u03b1) : x \u2208 c \u2192 f x \u2208 chain.map c f :=\n\u03bb \u27e8i,h\u27e9, \u27e8i, h.symm \u25b8 rfl\u27e9\n\nlemma exists_of_mem_map {b : \u03b2} : b \u2208 c.map f \u2192 \u2203 a, a \u2208 c \u2227 f a = b :=\n\u03bb \u27e8i,h\u27e9, \u27e8c i, \u27e8i, rfl\u27e9, h.symm\u27e9\n\nlemma mem_map_iff {b : \u03b2} : b \u2208 c.map f \u2194 \u2203 a, a \u2208 c \u2227 f a = b :=\n\u27e8 exists_of_mem_map _, \u03bb h, by { rcases h with \u27e8w,h,h'\u27e9, subst b, apply mem_map c _ h, } \u27e9\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 : \u03b1 \u2192\u2098 \u03b2} (h : f \u2264 g) : c.map f \u2264 c.map g :=\n\u03bb 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\u2080 : chain \u03b1) (c\u2081 : chain \u03b2) : chain (\u03b1 \u00d7 \u03b2) :=\npreorder_hom.prod.zip c\u2080 c\u2081\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 `\u03c9Sup`). In this sense, it is strictly weaker than join complete\nsemi-lattices as only \u03c9-sized totally ordered sets have a supremum.\n\nSee the definition on page 114 of [gunter]. -/\nclass omega_complete_partial_order (\u03b1 : Type*) extends partial_order \u03b1 :=\n(\u03c9Sup     : chain \u03b1 \u2192 \u03b1)\n(le_\u03c9Sup  : \u2200(c:chain \u03b1), \u2200 i, c i \u2264 \u03c9Sup c)\n(\u03c9Sup_le  : \u2200(c:chain \u03b1) x, (\u2200 i, c i \u2264 x) \u2192 \u03c9Sup c \u2264 x)\n\nend prio\n\nnamespace omega_complete_partial_order\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type*}\nvariables [omega_complete_partial_order \u03b1]\n\n/-- Transfer a `omega_complete_partial_order` on `\u03b2` to a `omega_complete_partial_order` on `\u03b1`\nusing a strictly monotone function `f : \u03b2 \u2192\u2098 \u03b1`, a definition of \u03c9Sup and a proof that `f` is\ncontinuous with regard to the provided `\u03c9Sup` and the \u03c9CPO on `\u03b1`. -/\n@[reducible]\nprotected def lift [partial_order \u03b2] (f : \u03b2 \u2192\u2098 \u03b1)\n  (\u03c9Sup\u2080 : chain \u03b2 \u2192 \u03b2)\n  (h : \u2200 x y, f x \u2264 f y \u2192 x \u2264 y)\n  (h' : \u2200 c, f (\u03c9Sup\u2080 c) = \u03c9Sup (c.map f)) : omega_complete_partial_order \u03b2 :=\n{ \u03c9Sup := \u03c9Sup\u2080,\n  \u03c9Sup_le := \u03bb c x hx, h _ _ (by rw h'; apply \u03c9Sup_le; intro; apply f.monotone (hx i)),\n  le_\u03c9Sup := \u03bb c i, h _ _ (by rw h'; apply le_\u03c9Sup (c.map f)) }\n\nlemma le_\u03c9Sup_of_le {c : chain \u03b1} {x : \u03b1} (i : \u2115) (h : x \u2264 c i) : x \u2264 \u03c9Sup c :=\nle_trans h (le_\u03c9Sup c _)\n\nlemma \u03c9Sup_total {c : chain \u03b1} {x : \u03b1} (h : \u2200 i, c i \u2264 x \u2228 x \u2264 c i) : \u03c9Sup c \u2264 x \u2228 x \u2264 \u03c9Sup c :=\nclassical.by_cases\n  (assume : \u2200 i, c i \u2264 x, or.inl (\u03c9Sup_le _ _ this))\n  (assume : \u00ac \u2200 i, c i \u2264 x,\n    have \u2203 i, \u00ac c i \u2264 x,\n      by simp only [not_forall] at this \u22a2; assumption,\n    let \u27e8i, hx\u27e9 := this in\n    have x \u2264 c i, from (h i).resolve_left hx,\n    or.inr $ le_\u03c9Sup_of_le _ this)\n\n@[mono]\nlemma \u03c9Sup_le_\u03c9Sup_of_le {c\u2080 c\u2081 : chain \u03b1} (h : c\u2080 \u2264 c\u2081) : \u03c9Sup c\u2080 \u2264 \u03c9Sup c\u2081 :=\n\u03c9Sup_le _ _ $\n\u03bb i, Exists.rec_on (h i) $\n\u03bb j h, le_trans h (le_\u03c9Sup _ _)\n\nlemma \u03c9Sup_le_iff (c : chain \u03b1) (x : \u03b1) : \u03c9Sup c \u2264 x \u2194 (\u2200 i, c i \u2264 x) :=\nbegin\n  split; intros,\n  { transitivity \u03c9Sup c,\n    exact le_\u03c9Sup _ _, assumption },\n  exact \u03c9Sup_le _ _ \u2039_\u203a,\nend\n\n/-- A subset `p : \u03b1 \u2192 Prop` of the type closed under `\u03c9Sup` induces an\n`omega_complete_partial_order` on the subtype `{a : \u03b1 // p a}`. -/\ndef subtype {\u03b1 : Type*} [omega_complete_partial_order \u03b1] (p : \u03b1 \u2192 Prop)\n  (hp : \u2200 (c : chain \u03b1), (\u2200 i \u2208 c, p i) \u2192 p (\u03c9Sup c)) :\n  omega_complete_partial_order (subtype p) :=\nomega_complete_partial_order.lift\n  (preorder_hom.subtype.val p)\n  (\u03bb c, \u27e8\u03c9Sup _, hp (c.map (preorder_hom.subtype.val p)) (\u03bb i \u27e8n, q\u27e9, q.symm \u25b8 (c n).2)\u27e9)\n  (\u03bb x y h, h)\n  (\u03bb c, rfl)\n\nsection continuity\nopen chain\n\nvariables [omega_complete_partial_order \u03b2]\nvariables [omega_complete_partial_order \u03b3]\n\n/-- A monotone function `f : \u03b1 \u2192\u2098 \u03b2` is continuous if it distributes over \u03c9Sup.\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 : \u03b1 \u2192\u2098 \u03b2) : Prop :=\n\u2200 c : chain \u03b1, f (\u03c9Sup c) = \u03c9Sup (c.map f)\n\n/-- `continuous' f` asserts that `f` is both monotone and continuous. -/\ndef continuous' (f : \u03b1 \u2192 \u03b2) : Prop :=\n\u2203 hf : monotone f, continuous \u27e8f, hf\u27e9\n\nlemma continuous.to_monotone {f : \u03b1 \u2192 \u03b2} (hf : continuous' f) : monotone f := hf.fst\n\nlemma continuous.of_bundled (f : \u03b1 \u2192 \u03b2) (hf : monotone f)\n  (hf' : continuous \u27e8f, hf\u27e9) : continuous' f := \u27e8hf, hf'\u27e9\n\nlemma continuous.of_bundled' (f : \u03b1 \u2192\u2098 \u03b2) (hf' : continuous f) : continuous' f :=\n\u27e8f.monotone, hf'\u27e9\n\nlemma continuous.to_bundled (f : \u03b1 \u2192 \u03b2) (hf : continuous' f) :\n  continuous \u27e8f, continuous.to_monotone hf\u27e9 := hf.snd\n\nvariables (f : \u03b1 \u2192\u2098 \u03b2) (g : \u03b2 \u2192\u2098 \u03b3)\n\nlemma continuous_id : continuous (@preorder_hom.id \u03b1 _) :=\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 \u03b1) :=\ncontinuous.of_bundled _ (\u03bb a b h, h)\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp [\u03c9Sup_le_iff,function.const],\nend\n\nlemma const_continuous' (x: \u03b2) : continuous' (function.const \u03b1 x) :=\ncontinuous.of_bundled _ (\u03bb a b h, le_refl _)\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp [\u03c9Sup_le_iff,function.const],\nend\n\nend continuity\n\nend omega_complete_partial_order\n\nnamespace roption\n\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type*}\nopen omega_complete_partial_order\n\nlemma eq_of_chain {c : chain (roption \u03b1)} {a b : \u03b1} (ha : some a \u2208 c) (hb : some b \u2208 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 \u2264 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) `\u03c9Sup` definition for the `\u03c9`-CPO structure on `roption \u03b1`. -/\nprotected noncomputable def \u03c9Sup (c : chain (roption \u03b1)) : roption \u03b1 :=\nif h : \u2203a, some a \u2208 c then some (classical.some h) else none\n\nlemma \u03c9Sup_eq_some {c : chain (roption \u03b1)} {a : \u03b1} (h : some a \u2208 c) : roption.\u03c9Sup c = some a :=\nhave \u2203a, some a \u2208 c, from \u27e8a, h\u27e9,\nhave a' : some (classical.some this) \u2208 c, from classical.some_spec this,\ncalc roption.\u03c9Sup c = some (classical.some this) : dif_pos this\n                ... = some a : congr_arg _ (eq_of_chain a' h)\n\nlemma \u03c9Sup_eq_none {c : chain (roption \u03b1)} (h : \u00ac\u2203a, some a \u2208 c) : roption.\u03c9Sup c = none :=\ndif_neg h\n\nlemma mem_chain_of_mem_\u03c9Sup {c : chain (roption \u03b1)} {a : \u03b1} (h : a \u2208 roption.\u03c9Sup c) : some a \u2208 c :=\nbegin\n  simp [roption.\u03c9Sup] at h, split_ifs at h,\n  { have h' := classical.some_spec h_1,\n    rw \u2190 eq_some_iff at h, rw \u2190 h, exact h' },\n  { rcases h with \u27e8 \u27e8 \u27e9 \u27e9 }\nend\n\nnoncomputable instance omega_complete_partial_order : omega_complete_partial_order (roption \u03b1) :=\n{ \u03c9Sup    := roption.\u03c9Sup,\n  le_\u03c9Sup := \u03bb c i, by { intros x hx, rw \u2190 eq_some_iff at hx \u22a2,\n                         rw [\u03c9Sup_eq_some, \u2190 hx], rw \u2190 hx, exact \u27e8i,rfl\u27e9 },\n  \u03c9Sup_le := by { rintros c x hx a ha, replace ha := mem_chain_of_mem_\u03c9Sup ha,\n                  cases ha with i ha, apply hx i, rw \u2190 ha, apply mem_some } }\n\nsection inst\n\nlemma mem_\u03c9Sup (x : \u03b1) (c : chain (roption \u03b1)) : x \u2208 \u03c9Sup c \u2194 some x \u2208 c :=\nbegin\n  simp [omega_complete_partial_order.\u03c9Sup,roption.\u03c9Sup],\n  split,\n  { split_ifs, swap, rintro \u27e8\u27e8\u27e9\u27e9,\n    intro h', have hh := classical.some_spec h,\n    simp at h', subst x, exact hh },\n  { intro h,\n    have h' : \u2203 (a : \u03b1), some a \u2208 c := \u27e8_,h\u27e9,\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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Type*} {\u03b3 : Type*}\n\n/-- Function application `\u03bb f, f a` is monotone with respect to `f` for fixed `a`. -/\n@[simps]\ndef monotone_apply [\u2200a, partial_order (\u03b2 a)] (a : \u03b1) : (\u03a0a, \u03b2 a) \u2192\u2098 \u03b2 a :=\n{ to_fun := (\u03bbf:\u03a0a, \u03b2 a, f a),\n  monotone' := assume f g hfg, hfg a }\n\nopen omega_complete_partial_order omega_complete_partial_order.chain\n\ninstance [\u2200a, omega_complete_partial_order (\u03b2 a)] : omega_complete_partial_order (\u03a0a, \u03b2 a) :=\n{ \u03c9Sup    := \u03bbc a, \u03c9Sup (c.map (monotone_apply a)),\n  \u03c9Sup_le := assume c f hf a, \u03c9Sup_le _ _ $ by { rintro i, apply hf },\n  le_\u03c9Sup := assume c i x, le_\u03c9Sup_of_le _ $ le_refl _ }\n\nnamespace omega_complete_partial_order\n\nvariables [\u2200 x, omega_complete_partial_order $ \u03b2 x]\nvariables [omega_complete_partial_order \u03b3]\n\nlemma flip\u2081_continuous'\n  (f : \u2200 x : \u03b1, \u03b3 \u2192 \u03b2 x) (a : \u03b1) (hf : continuous' (\u03bb x y, f y x)) :\n  continuous' (f a) :=\ncontinuous.of_bundled _\n  (\u03bb x y h, continuous.to_monotone hf h a)\n  (\u03bb c, congr_fun (continuous.to_bundled _ hf c) a)\n\nlemma flip\u2082_continuous'\n  (f : \u03b3 \u2192 \u03a0 x, \u03b2 x) (hf : \u2200 x, continuous' (\u03bb g, f g x)) : continuous' f :=\ncontinuous.of_bundled _\n  (\u03bb 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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\nvariables [omega_complete_partial_order \u03b1]\nvariables [omega_complete_partial_order \u03b2]\nvariables [omega_complete_partial_order \u03b3]\n\n/-- The supremum of a chain in the product `\u03c9`-CPO. -/\n@[simps]\nprotected def \u03c9Sup (c : chain (\u03b1 \u00d7 \u03b2)) : \u03b1 \u00d7 \u03b2 :=\n(\u03c9Sup (c.map preorder_hom.prod.fst), \u03c9Sup (c.map preorder_hom.prod.snd))\n\n@[simps \u03c9Sup_fst \u03c9Sup_snd]\ninstance : omega_complete_partial_order (\u03b1 \u00d7 \u03b2) :=\n{ \u03c9Sup := prod.\u03c9Sup,\n  \u03c9Sup_le := \u03bb c \u27e8x,x'\u27e9 h, \u27e8\u03c9Sup_le _ _ $ \u03bb i, (h i).1, \u03c9Sup_le _ _ $ \u03bb i, (h i).2\u27e9,\n  le_\u03c9Sup := \u03bb c i,\n    \u27e8le_\u03c9Sup (c.map preorder_hom.prod.fst) i, le_\u03c9Sup (c.map preorder_hom.prod.snd) i\u27e9 }\n\nend prod\n\nnamespace complete_lattice\nvariables (\u03b1 : Type u)\n\n/-- Any complete lattice has an `\u03c9`-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 \u03b1] : omega_complete_partial_order \u03b1 :=\n{ \u03c9Sup    := \u03bbc, \u2a06 i, c i,\n  \u03c9Sup_le := \u03bb \u27e8c, _\u27e9 s hs, by simp only [supr_le_iff, preorder_hom.coe_fun_mk] at \u22a2 hs;\n    intros i; apply hs i,\n  le_\u03c9Sup := assume \u27e8c, _\u27e9 i, by simp only [preorder_hom.coe_fun_mk]; apply le_supr_of_le i; refl }\n\nvariables {\u03b1} {\u03b2 : Type v} [omega_complete_partial_order \u03b1] [complete_lattice \u03b2]\nopen omega_complete_partial_order\n\nlemma inf_continuous [is_total \u03b2 (\u2264)] (f g : \u03b1 \u2192\u2098 \u03b2) (hf : continuous f) (hg : continuous g) :\n  continuous (f \u2293 g) :=\nbegin\n  intro c,\n  apply eq_of_forall_ge_iff, intro z,\n  simp only [inf_le_iff, hf c, hg c, \u03c9Sup_le_iff, \u2190forall_or_distrib_left, \u2190forall_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 $ \u03b1 \u2192\u2098 \u03b2) (hs : \u2200 f \u2208 s, continuous f) :\n  continuous (Sup s) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp only [\u03c9Sup_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_\u03c9Sup },\n  { rw [hs _ hx c, \u03c9Sup_le_iff], intro,\n    apply h i _ x hx rfl, }\nend\n\ntheorem Sup_continuous' :\n  \u2200s : set (\u03b1 \u2192 \u03b2), (\u2200t\u2208s, omega_complete_partial_order.continuous' t) \u2192\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 \u27e8f y, \u27e8f, hfs, rfl\u27e9, _\u27e9,\n    cases ht _ hfs with hf,\n    apply hf h },\n  existsi this,\n  let s' : set (\u03b1 \u2192\u2098 \u03b2) := { f | \u21d1f \u2208 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 \u27e8y,hy,hy'\u27e9,\n      cases ht _ hy,\n      refine \u27e8\u27e8_, w\u27e9, hy, hy'\u27e9 },\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 : \u03b1 \u2192\u2098 \u03b2} (hf : continuous f) (hg : continuous g) :\n  continuous (f \u2294 g) :=\nbegin\n  rw \u2190 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 (\u22a4 : \u03b1 \u2192\u2098 \u03b2) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp only [\u03c9Sup_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 (\u22a5 : \u03b1 \u2192\u2098 \u03b2) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp only [\u03c9Sup_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 {\u03b1 : Type u} {\u03b1' : Type*} {\u03b2 : Type v} {\u03b2' : Type*} {\u03b3 : Type*} {\u03c6 : Type*}\n\nvariables [omega_complete_partial_order \u03b1] [omega_complete_partial_order \u03b2]\nvariables [omega_complete_partial_order \u03b3] [omega_complete_partial_order \u03c6]\nvariables [omega_complete_partial_order \u03b1'] [omega_complete_partial_order \u03b2']\n\nnamespace preorder_hom\n\n/-- Function application `\u03bb f, f a` (for fixed `a`) is a monotone function from the\nmonotone function space `\u03b1 \u2192\u2098 \u03b2` to `\u03b2`. -/\n@[simps]\ndef monotone_apply (a : \u03b1) : (\u03b1 \u2192\u2098 \u03b2) \u2192\u2098 \u03b2 :=\n{ to_fun := (\u03bbf : \u03b1 \u2192\u2098 \u03b2, f a),\n  monotone' := assume f g hfg, hfg a }\n\n/-- The \"forgetful functor\" from `\u03b1 \u2192\u2098 \u03b2` to `\u03b1 \u2192 \u03b2` that takes the underlying function,\nis monotone. -/\ndef to_fun_hom : (\u03b1 \u2192\u2098 \u03b2) \u2192\u2098 (\u03b1 \u2192 \u03b2) :=\n{ to_fun := \u03bb f, f.to_fun,\n  monotone' := \u03bb x y h, h }\n\n/-- The `\u03c9Sup` operator for monotone functions. -/\n@[simps]\nprotected def \u03c9Sup (c : chain (\u03b1 \u2192\u2098 \u03b2)) : \u03b1 \u2192\u2098 \u03b2 :=\n{ to_fun := \u03bb a, \u03c9Sup (c.map (monotone_apply a)),\n  monotone' := \u03bb x y h, \u03c9Sup_le_\u03c9Sup_of_le (chain.map_le_map _ $ \u03bb a, a.monotone h) }\n\n@[simps \u03c9Sup_to_fun]\ninstance omega_complete_partial_order : omega_complete_partial_order (\u03b1 \u2192\u2098 \u03b2) :=\nomega_complete_partial_order.lift preorder_hom.to_fun_hom preorder_hom.\u03c9Sup\n  (\u03bb x y h, h) (\u03bb c, rfl)\n\nend preorder_hom\n\nsection old_struct\nset_option old_structure_cmd true\nvariables (\u03b1 \u03b2)\n\n/-- A monotone function on `\u03c9`-continuous partial orders is said to be continuous\nif for every chain `c : chain \u03b1`, `f (\u2294 i, c i) = \u2294 i, f (c i)`.\nThis is just the bundled version of `preorder_hom.continuous`. -/\nstructure continuous_hom extends preorder_hom \u03b1 \u03b2 :=\n(cont : continuous (preorder_hom.mk to_fun monotone'))\n\nattribute [nolint doc_blame] continuous_hom.to_preorder_hom\n\ninfixr ` \u2192\ud835\udc84 `:25 := continuous_hom -- Input: \\r\\MIc\n\ninstance : has_coe_to_fun (\u03b1 \u2192\ud835\udc84 \u03b2) :=\n{ F := \u03bb _, \u03b1 \u2192 \u03b2,\n  coe :=  continuous_hom.to_fun }\n\ninstance : has_coe (\u03b1 \u2192\ud835\udc84 \u03b2) (\u03b1 \u2192\u2098 \u03b2) :=\n{ coe :=  continuous_hom.to_preorder_hom }\n\ninstance : partial_order (\u03b1 \u2192\ud835\udc84 \u03b2) :=\npartial_order.lift continuous_hom.to_fun $ by rintro \u27e8\u27e9 \u27e8\u27e9 h; congr; exact h\n\nend old_struct\n\nnamespace continuous_hom\n\ntheorem congr_fun {f g : \u03b1 \u2192\ud835\udc84 \u03b2} (h : f = g) (x : \u03b1) : f x = g x :=\ncongr_arg (\u03bb h : \u03b1 \u2192\ud835\udc84 \u03b2, h x) h\n\ntheorem congr_arg (f : \u03b1 \u2192\ud835\udc84 \u03b2) {x y : \u03b1} (h : x = y) : f x = f y :=\ncongr_arg (\u03bb x : \u03b1, f x) h\n\n@[mono]\nlemma monotone (f : \u03b1 \u2192\ud835\udc84 \u03b2) : monotone f :=\ncontinuous_hom.monotone' f\n\nlemma ite_continuous' {p : Prop} [hp : decidable p] (f g : \u03b1 \u2192 \u03b2)\n  (hf : continuous' f) (hg : continuous' g) : continuous' (\u03bb x, if p then f x else g x) :=\nby split_ifs; simp *\n\nlemma \u03c9Sup_bind {\u03b2 \u03b3 : Type v} (c : chain \u03b1) (f : \u03b1 \u2192\u2098 roption \u03b2) (g : \u03b1 \u2192\u2098 \u03b2 \u2192 roption \u03b3) :\n  \u03c9Sup (c.map (f.bind g)) = \u03c9Sup (c.map f) >>= \u03c9Sup (c.map g) :=\nbegin\n  apply eq_of_forall_ge_iff, intro x,\n  simp only [\u03c9Sup_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 \u03c9Sup_le _ _ _,\n    rintros i y hy, simp only [roption.mem_\u03c9Sup] at hb,\n    rcases hb with \u27e8j,hb\u27e9, 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 \u2208 f (c (max i j))   := f.monotone (c.monotone (le_max_right i j)) _ hb,\n    replace hy : y \u2208 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 \u27e8_,hb,hy\u27e9, },\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 \u27e8b,hb\u2080,hb\u2081\u27e9,\n    apply h''' b _,\n    { apply le_\u03c9Sup (c.map g) _ _ _ hb\u2081 },\n    { apply le_\u03c9Sup (c.map f) i _ hb\u2080 } },\nend\n\nlemma bind_continuous' {\u03b2 \u03b3 : Type v} (f : \u03b1 \u2192 roption \u03b2) (g : \u03b1 \u2192 \u03b2 \u2192 roption \u03b3) :\n  continuous' f \u2192 continuous' g \u2192\n  continuous' (\u03bb x, f x >>= g x)\n| \u27e8hf,hf'\u27e9 \u27e8hg,hg'\u27e9 :=\ncontinuous.of_bundled' (preorder_hom.bind \u27e8f,hf\u27e9 \u27e8g,hg\u27e9)\n  (by intro c; rw [\u03c9Sup_bind, \u2190 hf', \u2190 hg']; refl)\n\nlemma map_continuous' {\u03b2 \u03b3 : Type v} (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 roption \u03b2)\n  (hg : continuous' g) :\n  continuous' (\u03bb 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' {\u03b2 \u03b3 : Type v} (f : \u03b1 \u2192 roption (\u03b2 \u2192 \u03b3)) (g : \u03b1 \u2192 roption \u03b2)\n  (hf : continuous' f) (hg : continuous' g) :\n  continuous' (\u03bb 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\u2082_continuous'; intro;\n   apply map_continuous' _ _ hg\n\nlemma continuous (F : \u03b1 \u2192\ud835\udc84 \u03b2) (C : chain \u03b1) : F (\u03c9Sup C) = \u03c9Sup (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 : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192\ud835\udc84 \u03b2) (h : f = g) : \u03b1 \u2192\ud835\udc84 \u03b2 :=\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 : \u03b1 \u2192\u2098 \u03b2) (h : \u2200 c : chain \u03b1, f (\u03c9Sup c) = \u03c9Sup (c.map f)) : \u03b1 \u2192\ud835\udc84 \u03b2 :=\n{ to_fun := f,\n  monotone' := f.monotone,\n  cont := h }\n\n/-- The identity as a continuous function. -/\n@[simps]\ndef id : \u03b1 \u2192\ud835\udc84 \u03b1 :=\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 : \u03b2 \u2192\ud835\udc84 \u03b3) (g : \u03b1 \u2192\ud835\udc84 \u03b2) : \u03b1 \u2192\ud835\udc84 \u03b3 :=\nof_mono (preorder_hom.comp (\u2191f) (\u2191g))\n  (by intro; rw [preorder_hom.comp, \u2190 preorder_hom.comp, \u2190 chain.map_comp, \u2190 f.continuous,\n                 \u2190 g.continuous]; refl)\n\n@[ext]\nprotected lemma ext (f g : \u03b1 \u2192\ud835\udc84 \u03b2) (h : \u2200 x, f x = g x) : f = g :=\nby cases f; cases g; congr; ext; apply h\n\nprotected lemma coe_inj (f g : \u03b1 \u2192\ud835\udc84 \u03b2) (h : (f : \u03b1 \u2192 \u03b2) = g) : f = g :=\ncontinuous_hom.ext _ _ $ _root_.congr_fun h\n\n@[simp]\nlemma comp_id (f : \u03b2 \u2192\ud835\udc84 \u03b3) : f.comp id = f := by ext; refl\n\n@[simp]\nlemma id_comp (f : \u03b2 \u2192\ud835\udc84 \u03b3) : id.comp f = f := by ext; refl\n\n@[simp]\nlemma comp_assoc (f : \u03b3 \u2192\ud835\udc84 \u03c6) (g : \u03b2 \u2192\ud835\udc84 \u03b3) (h : \u03b1 \u2192\ud835\udc84 \u03b2) : f.comp (g.comp h) = (f.comp g).comp h :=\nby ext; refl\n\n@[simp]\nlemma coe_apply (a : \u03b1) (f : \u03b1 \u2192\ud835\udc84 \u03b2) : (f : \u03b1 \u2192\u2098 \u03b2) a = f a := rfl\n\n/-- `function.const` is a continuous function. -/\ndef const (f : \u03b2) : \u03b1 \u2192\ud835\udc84 \u03b2 :=\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_\u03c9Sup_of_le 0, refl },\n      { apply \u03c9Sup_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 : \u03b2) (a : \u03b1) : const f a = f := rfl\n\ninstance [inhabited \u03b2] : inhabited (\u03b1 \u2192\ud835\udc84 \u03b2) :=\n\u27e8 const (default \u03b2) \u27e9\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 `\u03b1 \u2192\ud835\udc84 \u03b2`, and we cannot use it as the domain or image\nof a continuous function before we do.) -/\n@[simps]\ndef apply : (\u03b1 \u2192\ud835\udc84 \u03b2) \u00d7 \u03b1 \u2192\u2098 \u03b2 :=\n{ to_fun := \u03bb f, f.1 f.2,\n  monotone' := \u03bb 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 : (\u03b1 \u2192\ud835\udc84 \u03b2) \u2192\u2098 (\u03b1 \u2192\u2098 \u03b2) :=\n{ to_fun := \u03bb f, f,\n  monotone' := \u03bb 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\u2080` only needs to be a\nchain of monotone functions, but it is only used with continuous functions. -/\n@[simp]\nlemma forall_forall_merge (c\u2080 : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) (c\u2081 : chain \u03b1) (z : \u03b2) :\n  (\u2200 (i j : \u2115), (c\u2080 i) (c\u2081 j) \u2264 z) \u2194 \u2200 (i : \u2115), (c\u2080 i) (c\u2081 i) \u2264 z :=\nbegin\n  split; introv h,\n  { apply h },\n  { apply le_trans _ (h (max i j)),\n    transitivity c\u2080 i (c\u2081 (max i j)),\n    { apply (c\u2080 i).monotone, apply c\u2081.monotone, apply le_max_right },\n    { apply c\u2080.monotone, apply le_max_left } }\nend\n\n@[simp]\nlemma forall_forall_merge' (c\u2080 : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) (c\u2081 : chain \u03b1) (z : \u03b2) :\n  (\u2200 (j i : \u2115), (c\u2080 i) (c\u2081 j) \u2264 z) \u2194 \u2200 (i : \u2115), (c\u2080 i) (c\u2081 i) \u2264 z :=\nby rw [forall_swap,forall_forall_merge]\n\n/-- The `\u03c9Sup` operator for continuous functions, which takes the pointwise countable supremum\nof the functions in the `\u03c9`-chain. -/\n@[simps]\nprotected def \u03c9Sup (c : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) : \u03b1 \u2192\ud835\udc84 \u03b2 :=\ncontinuous_hom.of_mono (\u03c9Sup $ c.map to_mono)\nbegin\n  intro c',\n  apply eq_of_forall_ge_iff, intro z,\n  simp only [\u03c9Sup_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_\u03c9Sup_to_fun,\n    forall_forall_merge, forall_forall_merge', function.comp_app],\nend\n\n@[simps \u03c9Sup]\ninstance : omega_complete_partial_order (\u03b1 \u2192\ud835\udc84 \u03b2) :=\nomega_complete_partial_order.lift continuous_hom.to_mono continuous_hom.\u03c9Sup\n  (\u03bb x y h, h) (\u03bb c, rfl)\n\nlemma \u03c9Sup_def (c : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) (x : \u03b1) : \u03c9Sup c x = continuous_hom.\u03c9Sup c x := rfl\n\nlemma \u03c9Sup_\u03c9Sup (c\u2080 : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) (c\u2081 : chain \u03b1) :\n  \u03c9Sup c\u2080 (\u03c9Sup c\u2081) = \u03c9Sup (continuous_hom.prod.apply.comp $ c\u2080.zip c\u2081) :=\nbegin\n  apply eq_of_forall_ge_iff, intro z,\n  simp only [\u03c9Sup_le_iff, (c\u2080 _).continuous, chain.map_to_fun, to_mono_to_fun, coe_apply,\n    preorder_hom.omega_complete_partial_order_\u03c9Sup_to_fun, \u03c9Sup_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, \u03c9Sup_to_fun],\nend\n\n/-- A family of continuous functions yields a continuous family of functions. -/\n@[simps]\ndef flip {\u03b1 : Type*} (f : \u03b1 \u2192 \u03b2 \u2192\ud835\udc84 \u03b3) : \u03b2 \u2192\ud835\udc84 \u03b1 \u2192 \u03b3 :=\n{ to_fun := \u03bb x y, f y x,\n  monotone' := \u03bb 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 {\u03b2 \u03b3 : Type v}\n  (f : \u03b1 \u2192\ud835\udc84 roption \u03b2) (g : \u03b1 \u2192\ud835\udc84 \u03b2 \u2192 roption \u03b3) : \u03b1 \u2192\ud835\udc84 roption \u03b3 :=\nof_mono (preorder_hom.bind (\u2191f) (\u2191g)) $ \u03bb c, begin\n  rw [preorder_hom.bind, \u2190 preorder_hom.bind, \u03c9Sup_bind, \u2190 f.continuous, \u2190 g.continuous],\n  refl\nend\n\n/-- `roption.map` as a continuous function. -/\n@[simps {rhs_md := reducible}]\nnoncomputable def map {\u03b2 \u03b3 : Type v} (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192\ud835\udc84 roption \u03b2) : \u03b1 \u2192\ud835\udc84 roption \u03b3 :=\nof_fun (\u03bb x, f <$> g x) (bind g (const (pure \u2218 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 {\u03b2 \u03b3 : Type v} (f : \u03b1 \u2192\ud835\udc84 roption (\u03b2 \u2192 \u03b3)) (g : \u03b1 \u2192\ud835\udc84 roption \u03b2) :\n  \u03b1 \u2192\ud835\udc84 roption \u03b3 :=\nof_fun (\u03bb 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 (\u03b1 : Type): Type\n| none : dm_option\n| some (a : \u03b1) : dm_option\n\n/-\nHeres an example of a representation in Lean of\na partial function, p, from \u2115 to \u2115, such that \np(n) = 0 if n=0 and p(n) is undefined otherwise.  \n-/\n\ndef p : \u2115 \u2192 dm_option \u2115 \n| nat.zero := dm_option.some nat.zero\n| _ := dm_option.none \u2115       -- 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\u2082_neg {a b c : Prop} (h\u2081 : neg (pt a b c)) : neg (pt b a c) :=\n                    have h\u2082 : pt (neg a) b c, from ptn\u2081 h\u2081,\n                    have h\u2083 : pt a (neg b) c, from ptn\u2083 h\u2082,\n                    have h\u2084 : pt (neg b) a c, from pt.pt\u2082 h\u2083,\n                    show neg (pt b a c), from ptn\u2082 h\u2084\n\n                theorem pt\u2083_neg {a b c : Prop} (h\u2081 : neg (pt a b c)) : neg (pt a c b) :=\n                    have h\u2082 : pt (neg a) b c, from ptn\u2081 h\u2081,\n                    have h\u2083 : pt (neg a) c b, from pt.pt\u2083 h\u2082,\n                    show neg (pt a c b), from ptn\u2082 h\u2083\n\n                theorem pt\u2084_neg {a b : Prop} (h\u2081 : neg a) : neg (pt a b b) :=\n                    have h\u2082 : pt (neg a) b b, from pt.pt\u2084 h\u2081,\n                    show neg (pt a b b), from ptn\u2082 h\u2082\n\n                theorem pt\u2085_neg {a b : Prop} (h\u2081 : neg (pt a b b)) : neg a :=\n                    have h\u2082 : pt (neg a) b b, from ptn\u2081 h\u2081,\n                    show neg a, from pt.pt\u2085 h\u2082\n\n                theorem pt\u2086_neg {a b c d e : Prop} (h\u2081 : neg (pt a b (pt c d e))) : neg (pt (pt a b c) d e) :=\n                    have h\u2082 : pt (neg a) b (pt c d e), from ptn\u2081 h\u2081,\n                    have h\u2083 : pt (pt (neg a) b c) d e, from pt.pt\u2086 h\u2082,\n                    have h\u2084 : pt d e (pt (neg a) b c), from pt.pt\u2083 (pt.pt\u2082 h\u2083),\n                    have h\u2085 : pt (pt d e (neg a)) b c, from pt.pt\u2086 h\u2084,\n                    have h\u2086 : pt b c (pt d e (neg a)), from pt.pt\u2083 (pt.pt\u2082 h\u2085),\n                    have h\u2087 : pt b c (pt (neg a) d e), from pt.pt\u2082_pt (pt.pt\u2083_pt h\u2086),\n                    have h\u2088 : pt (pt (neg a) d e) b c, from pt.pt\u2082 (pt.pt\u2083 h\u2087),\n                    have h\u2089 : pt (neg a) d (pt e b c), from pt.pt\u2087 h\u2088,\n                    have h\u2081\u2080 : neg (pt a d (pt e b c)), from ptn\u2082 h\u2089,\n                    have h\u2081\u2081 : neg (pt d a (pt e b c)), from pt\u2082_neg h\u2081\u2080,\n                    have h\u2081\u2082 : pt (neg d) a (pt e b c), from ptn\u2081 h\u2081\u2081,\n                    have h\u2081\u2083 : pt (pt (neg d) a e) b c, from pt.pt\u2086 h\u2081\u2082,\n                    have h\u2081\u2084 : pt b c (pt (neg d) a e), from pt.pt\u2083 (pt.pt\u2082 h\u2081\u2083),\n                    have h\u2081\u2085 : pt b c (pt a (neg d) e), from pt.pt\u2082_pt h\u2081\u2084,\n                    have h\u2081\u2086 : pt (pt b c a) (neg d) e, from pt.pt\u2086 h\u2081\u2085,\n                    have h\u2081\u2087 : pt (neg d) e (pt b c a), from pt.pt\u2083 (pt.pt\u2082 h\u2081\u2086),\n                    have h\u2081\u2088 : pt (neg d) e (pt a b c), from pt.pt\u2082_pt (pt.pt\u2083_pt h\u2081\u2087),\n                    have h\u2081\u2089 : neg (pt d e (pt a b c)), from ptn\u2082 h\u2081\u2088,\n                    show neg (pt (pt a b c) d e), from pt\u2082_neg (pt\u2083_neg h\u2081\u2089)\n\n                theorem pt\u2087_neg {a b c d e : Prop} (h\u2081 : neg (pt (pt a b c) d e)) : neg (pt a b (pt c d e))  :=\n                    have h\u2082 : neg (pt d (pt a b c) e), from pt\u2082_neg h\u2081,\n                    have h\u2083 : neg (pt d e (pt a b c)), from pt\u2083_neg h\u2082,\n                    have h\u2084 : neg (pt (pt d e a) b c), from pt\u2086_neg h\u2083,\n                    have h\u2085 : neg (pt b (pt d e a) c), from pt\u2082_neg h\u2084,\n                    have h\u2086 : neg (pt b c (pt d e a)), from pt\u2083_neg h\u2085,\n                    have h\u2087 : neg (pt (pt b c d) e a), from pt\u2086_neg h\u2086,\n                    have h\u2088 : neg (pt e (pt b c d) a), from pt\u2082_neg h\u2087,\n                    have h\u2089 : neg (pt e a (pt b c d)), from pt\u2083_neg h\u2088,\n                    have h\u2081\u2080 : neg (pt (pt e a b) c d), from pt\u2086_neg h\u2089,\n                    have h\u2081\u2081 : neg (pt c (pt e a b) d), from pt\u2082_neg h\u2081\u2080,\n                    have h\u2081\u2082 : neg (pt c d (pt e a b)), from pt\u2083_neg h\u2081\u2081,\n                    have h\u2081\u2083 : neg (pt (pt c d e) a b), from pt\u2086_neg h\u2081\u2082,\n                    have h\u2081\u2084 : neg (pt a (pt c d e) b), from pt\u2082_neg h\u2081\u2083,\n                    show neg (pt a b (pt c d e)), from pt\u2083_neg h\u2081\u2084\n\n                theorem n\u2081_pt {a b c d : Prop} (h\u2081 : pt c d a) (h\u2082 : pt c d (neg a)) : pt c d b :=\n                    have h\u2083 : pt a c d, from pt.pt\u2082 (pt.pt\u2083 h\u2081),\n                    have h\u2084 : pt (neg a) c d, from pt.pt\u2082 (pt.pt\u2083 h\u2082),\n                    have h\u2085 : neg (pt a c d), from ptn\u2082 h\u2084,\n                    show pt c d b, from n\u2081 h\u2083 h\u2085\n\n                theorem ptn\u2081_pt {a b c d e : Prop} (h\u2081 : pt d e (neg (pt a b c))) : pt d e (pt (neg a) b c) :=\n                    have h\u2082 : pt (neg (pt a b c)) d e, from pt.pt\u2082 (pt.pt\u2083 h\u2081),\n                    have h\u2083 : neg (pt (pt a b c) d e), from ptn\u2082 h\u2082,\n                    have h\u2084 : neg (pt a b (pt c d e)), from pt\u2087_neg h\u2083,\n                    have h\u2085 : pt (neg a) b (pt c d e), from ptn\u2081 h\u2084,\n                    have h\u2086 : pt (pt (neg a) b c) d e, from pt.pt\u2086 h\u2085,\n                    show pt d e (pt (neg a) b c), from pt.pt\u2083 (pt.pt\u2082 h\u2086)\n\n                theorem ptn\u2082_pt {a b c d e : Prop} (h\u2081 : pt d e (pt (neg a) b c))  : pt d e (neg (pt a b c)) :=\n                    have h\u2082 : pt (pt (neg a) b c) d e, from pt.pt\u2082 (pt.pt\u2083 h\u2081),\n                    have h\u2083 : pt (neg a) b (pt c d e), from pt.pt\u2087 h\u2082,\n                    have h\u2084 : neg (pt a b (pt c d e)), from ptn\u2082 h\u2083,\n                    have h\u2085 : neg (pt (pt a b c) d e), from pt\u2086_neg h\u2084,\n                    have h\u2086 : pt (neg (pt a b c)) d e, from ptn\u2081 h\u2085,\n                    show pt d e (neg (pt a b c)), from pt.pt\u2083 (pt.pt\u2082 h\u2086)\n\n                theorem ptn\u2083_pt {a b c d e : Prop} (h\u2081 : pt d e (neg (pt a b c))) : pt d e (pt a (neg b) c) :=\n                    have h\u2082 : pt (neg (pt a b c)) d e, from pt.pt\u2082 (pt.pt\u2083 h\u2081),\n                    have h\u2083 : neg (pt (pt a b c) d e), from ptn\u2082 h\u2082,\n                    have h\u2084 : neg (pt a b (pt c d e)), from pt\u2087_neg h\u2083,\n                    have h\u2085 : neg (pt b a (pt c d e)), from pt\u2082_neg h\u2084,\n                    have h\u2086 : pt (neg b) a (pt c d e), from ptn\u2081 h\u2085,\n                    have h\u2087 : pt a (neg b) (pt c d e), from pt.pt\u2082 h\u2086,\n                    have h\u2088 : pt (pt a (neg b) c) d e, from pt.pt\u2086 h\u2087,\n                    show pt d e (pt a (neg b) c), from pt.pt\u2083 (pt.pt\u2082 h\u2088)\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 \u27f6 Y` is a morphism for which there exists a morphism `g : Y \u27f6 X`, such that `f \u226b g = \ud835\udfd9 X` and `g \u226b f = \ud835\udfd9 Y`.\n-/\n\n\n/- Lemma\nIf $$f : X \u27f6 Y$$ and $$g : X \u27f6 Y$$ are morphisms such that $$f = g$$, then $$f \u226b h = g \u226b h$$.\n-/\nlemma cancel_left_iso' {X Y Z : C} (f : X \u27f6 Y) [is_iso f] {g h : Z \u27f6 X} : (g \u226b f = h \u226b f) \u2194 g = h :=\nbegin\n    split,\n\n    intro hyp,\n    rw \u2190 category.comp_id g,\n    rw \u2190 category.comp_id h,\n    rw \u2190 is_iso.hom_inv_id f,\n    rw \u2190 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 (\u03b1 : Type _) [BooleanRing \u03b1] : BoolRing :=\n  Bundled.of \u03b1\n#align BoolRing.of BoolRing.of\n\n@[simp]\ntheorem coe_of (\u03b1 : Type _) [BooleanRing \u03b1] : \u21a5(of \u03b1) = \u03b1 :=\n  rfl\n#align BoolRing.coe_of BoolRing.coe_of\n\ninstance : Inhabited BoolRing :=\n  \u27e8of PUnit\u27e9\n\ninstance : BundledHom.ParentProjection @BooleanRing.toCommRing :=\n  \u27e8\u27e9\n\nderiving instance LargeCategory, ConcreteCategory for BoolRing\n\n@[simps]\ninstance hasForgetToCommRing : HasForget\u2082 BoolRing CommRingCat :=\n  BundledHom.forget\u2082 _ _\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 {\u03b1 \u03b2 : BoolRing.{u}} (e : \u03b1 \u2243+* \u03b2) : \u03b1 \u2245 \u03b2\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\u2082 BoolRing BoolAlg\n    where forget\u2082 :=\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\u2082 BoolAlg BoolRing\n    where forget\u2082 :=\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 \u224c BoolAlg :=\n  Equivalence.mk (forget\u2082 BoolRing BoolAlg) (forget\u2082 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 \u2964 C) \u2964 C` is lax monoidal when `C` is a monoidal category.\n\nWhen `C` is a monoidal category, the functorial association `F \u21a6 limit F` is lax monoidal,\ni.e. there are morphisms\n* `lim_lax.\u03b5 : (\ud835\udfd9_ C) \u2192 limit (\ud835\udfd9_ (J \u2964 C))`\n* `lim_lax.\u03bc : limit F \u2297 limit G \u27f6 limit (F \u2297 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 \u2964 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 \u2964 C} {G : J \u2964 C} (\u03b1 : F \u27f6 G) : map (fun (F : J \u2964 C) => limit F) \u03b1 = functor.map lim \u03b1 :=\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 \u2964 C) => limit F :=\n  lax_monoidal.mk (limit.lift (functor.obj (functor.const J) \ud835\udfd9_) (cone.mk \ud835\udfd9_ (nat_trans.mk fun (j : J) => \ud835\udfd9)))\n    fun (F G : J \u2964 C) =>\n      limit.lift (F \u2297 G) (cone.mk (limit F \u2297 limit G) (nat_trans.mk fun (j : J) => limit.\u03c0 F j \u2297 limit.\u03c0 G j))\n\n/-- The limit functor `F \u21a6 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 \u2964 C) C :=\n  lax_monoidal_functor.of fun (F : J \u2964 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 \u2964 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 \u2964 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 \u2964 C} {G : J \u2964 C} (\u03b1 : F \u27f6 G) : functor.map (lax_monoidal_functor.to_functor lim_lax) \u03b1 = functor.map lim \u03b1 :=\n  rfl\n\n@[simp] theorem lim_lax_\u03b5 {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] : lax_monoidal_functor.\u03b5 lim_lax =\n  limit.lift (functor.obj (functor.const J) \ud835\udfd9_) (cone.mk \ud835\udfd9_ (nat_trans.mk fun (j : J) => \ud835\udfd9)) :=\n  rfl\n\n@[simp] theorem lim_lax_\u03bc {J : Type v} [small_category J] {C : Type u} [category C] [has_limits C] [monoidal_category C] (F : J \u2964 C) (G : J \u2964 C) : lax_monoidal_functor.\u03bc lim_lax F G =\n  limit.lift (F \u2297 G) (cone.mk (limit F \u2297 limit G) (nat_trans.mk fun (j : J) => limit.\u03c0 F j \u2297 limit.\u03c0 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) 2022 Asta H. From. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Asta H. From, Jannis Limperg\n-/\nimport Aesop\n\nset_option aesop.check.all true\n\ninductive Perm : (xs ys : List \u03b1) \u2192 Type where\n  | prep {xs} x : Perm (x :: xs) (x :: xs)\n\ninductive Proof : (\u0393 \u0394 : List \u03a6) \u2192 Prop where\n  | basic (\u0393 \u0394 n) : Proof (n :: \u0393) (n :: \u0394)\n  | per_l (\u0393 \u0393' \u0394) : Proof \u0393 \u0394 \u2192 Perm \u0393' \u0393 \u2192 Proof \u0393' \u0394\n\ntheorem weaken (\u0393 \u0394 : List \u03a6) (prf : Proof \u0393 \u0394) (\u03b4 : \u03a6) : Proof \u0393 (\u03b4 :: \u0394) := by\n  induction prf\n  case basic \u0393 \u0394 n =>\n    aesop (add unsafe [constructors Proof, constructors Perm])\n      (options := { maxRuleApplications := 50, terminal := true })\n  case per_l \u0393 \u0393' \u0394 _ perm ih =>\n    apply Proof.per_l \u0393 \u0393' (\u03b4 :: \u0394) ih perm\n", "meta": {"author": "JLimperg", "repo": "aesop", "sha": "c68fb1d5a9172498230d81d95c61f6461bea6722", "save_path": "github-repos/lean/JLimperg-aesop", "path": "github-repos/lean/JLimperg-aesop/aesop-c68fb1d5a9172498230d81d95c61f6461bea6722/tests/golden/13_2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8175744761936437, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.48146072262364037}}
{"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 {\u03b9 : Type*}\nvariables {V : Type u} [category.{v} V] [preadditive V]\n\nvariables {c : complex_shape \u03b9} {C D E : homological_complex V c}\nvariables (f g : C \u27f6 D) (h k : D \u27f6 E) (i : \u03b9)\n\nnamespace homological_complex\n\ninstance : has_zero (C \u27f6 D) := \u27e8{ f := \u03bb i, 0 }\u27e9\ninstance : has_add (C \u27f6 D) := \u27e8\u03bb f g, { f := \u03bb i, f.f i + g.f i, }\u27e9\ninstance : has_neg (C \u27f6 D) := \u27e8\u03bb f, { f := \u03bb i, -(f.f i), }\u27e9\ninstance : has_sub (C \u27f6 D) := \u27e8\u03bb f g, { f := \u03bb i, f.f i - g.f i, }\u27e9\n\n@[simp] lemma zero_f_apply (i : \u03b9) : (0 : C \u27f6 D).f i = 0 := rfl\n@[simp] lemma add_f_apply (f g : C \u27f6 D) (i : \u03b9) : (f + g).f i = f.f i + g.f i := rfl\n@[simp] lemma neg_f_apply (f : C \u27f6 D) (i : \u03b9) : (-f).f i = -(f.f i) := rfl\n@[simp] lemma sub_f_apply (f g : C \u27f6 D) (i : \u03b9) : (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 \u27f6 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\u2081 C\u2082 : homological_complex V c} (i : \u03b9) :\n  (C\u2081 \u27f6 C\u2082) \u2192+ (C\u2081.X i \u27f6 C\u2082.X i) :=\nadd_monoid_hom.mk' (\u03bb f, hom.f f i) (\u03bb _ _, rfl)\n\nend homological_complex\n\nnamespace homological_complex\n\ninstance eval_additive (i : \u03b9) : (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' := \u03bb C D f g, begin\n    dsimp [homology_functor],\n    ext,\n    simp only [homology.\u03c0_map, preadditive.comp_add, \u2190preadditive.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 \u2964 W) [F.additive] (c : complex_shape \u03b9) :\n  homological_complex V c \u2964 homological_complex W c :=\n{ obj := \u03bb C,\n  { X := \u03bb i, F.obj (C.X i),\n    d := \u03bb i j, F.map (C.d i j),\n    shape' := \u03bb i j w, by rw [C.shape _ _ w, F.map_zero],\n    d_comp_d' := \u03bb i j k _ _, by rw [\u2190F.map_comp, C.d_comp_d, F.map_zero], },\n  map := \u03bb C D f,\n  { f := \u03bb i, F.map (f.f i),\n    comm' := \u03bb i j h, by { dsimp,  rw [\u2190F.map_comp, \u2190F.map_comp, f.comm], }, }, }.\n\ninstance functor.map_homogical_complex_additive\n  (F : V \u2964 W) [F.additive] (c : complex_shape \u03b9) : (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 \u2964 W} [F.additive] [G.additive]\n  (\u03b1 : F \u27f6 G) (c : complex_shape \u03b9) : F.map_homological_complex c \u27f6 G.map_homological_complex c :=\n{ app := \u03bb C, { f := \u03bb i, \u03b1.app _, }, }\n\n@[simp] lemma nat_trans.map_homological_complex_id (c : complex_shape \u03b9) (F : V \u2964 W) [F.additive] :\n  nat_trans.map_homological_complex (\ud835\udfd9 F) c = \ud835\udfd9 (F.map_homological_complex c) :=\nby tidy\n\n@[simp] lemma nat_trans.map_homological_complex_comp (c : complex_shape \u03b9)\n  {F G H : V \u2964 W} [F.additive] [G.additive] [H.additive]\n  (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H):\n  nat_trans.map_homological_complex (\u03b1 \u226b \u03b2) c =\n    nat_trans.map_homological_complex \u03b1 c \u226b nat_trans.map_homological_complex \u03b2 c :=\nby tidy\n\n@[simp, reassoc] lemma nat_trans.map_homological_complex_naturality {c : complex_shape \u03b9}\n  {F G : V \u2964 W} [F.additive] [G.additive] (\u03b1 : F \u27f6 G) {C D : homological_complex V c} (f : C \u27f6 D) :\n  (F.map_homological_complex c).map f \u226b (nat_trans.map_homological_complex \u03b1 c).app D =\n    (nat_trans.map_homological_complex \u03b1 c).app C \u226b (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 \u2964 W) [F.additive] (c : complex_shape \u03b9) (j : \u03b9):\n  single V c j \u22d9 F.map_homological_complex _ \u2245 F \u22d9 single W c j :=\nnat_iso.of_components (\u03bb X,\n{ hom := { f := \u03bb i, if h : i = j then\n    eq_to_hom (by simp [h])\n  else\n    0, },\n  inv := { f := \u03bb 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  (\u03bb X Y f, begin\n    ext i,\n    dsimp,\n    split_ifs with h; simp [h],\n  end).\n\nvariables (F : V \u2964 W) [functor.additive F] (c)\n\n@[simp] lemma single_map_homological_complex_hom_app_self (j : \u03b9) (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 : \u03b9} (h : i \u2260 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 : \u03b9) (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 : \u03b9} (h : i \u2260 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\u2080_map_homological_complex (F : V \u2964 W) [F.additive] :\n  single\u2080 V \u22d9 F.map_homological_complex _ \u2245 F \u22d9 single\u2080 W :=\nnat_iso.of_components (\u03bb X,\n{ hom := { f := \u03bb i, match i with\n    | 0 := \ud835\udfd9 _\n    | (i+1) := F.map_zero_object.hom\n    end, },\n  inv := { f := \u03bb i, match i with\n    | 0 := \ud835\udfd9 _\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  (\u03bb 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": "import Hw7\nimport Lean.Elab.Print\nimport Lean.Elab.Command\n\ntheorem desiredType : \u2200 (\u03b1 : Type) (A B : \u03b1 \u2192 Prop), (\u2200 (x : \u03b1), A x \u2192 B x) \u2192 (\u2203 y, A y) \u2192 \u2203 z, B z := sorry \n\nopen Lean\nopen Lean.Meta\nopen Lean.Elab.Command\n\ndef collectAxiomsOf (constName : Name) : MetaM (List String) := do\n  let env \u2190 getEnv\n  let (_, s) := ((CollectAxioms.collect constName).run env).run {}\n  let a := s.axioms.toList.map toString\n  return a\n\n#eval isDefEq (Expr.const ``desiredType []) (Expr.const ``problem1 [])\n#eval collectAxiomsOf ``problem1\n", "meta": {"author": "UofSC-Fall-2022-Math-300-H01", "repo": "homework7", "sha": "4873226c2ce223b0f592894b99ced612f0f2712d", "save_path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-homework7", "path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-homework7/homework7-4873226c2ce223b0f592894b99ced612f0f2712d/_Tests/Problem1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.743168019989179, "lm_q2_score": 0.6477982043529715, "lm_q1q2_score": 0.48142290888154343}}
{"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\u2081 v\u2082 u\u2081 u\u2082\n\nopen CategoryTheory CategoryTheory.Category CategoryTheory.Limits\n\nnamespace CategoryTheory.Limits\n\nsection Pullback\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C]\n\nvariable {D : Type u\u2082} [Category.{v\u2082} D]\n\nvariable (G : C \u2964 D)\n\nvariable {W X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} {h : W \u27f6 X} {k : W \u27f6 Y} (comm : h \u226b f = k \u226b 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\u2093'. -/\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)) \u2243\n      IsLimit\n        (PullbackCone.mk (G.map h) (G.map k) (by simp only [\u2190 G.map_comp, comm]) :\n          PullbackCone (G.map f) (G.map g)) :=\n  (IsLimit.postcomposeHomEquiv (diagramIsoCospan.{v\u2082} _) _).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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2082} _) _).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    \u00b7 apply (config := { instances := false }) preserves_limit.preserves\n      \u00b7 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\u2081} _) _).invFun hc\n    \u00b7\n      exact\n        (c.\u03c0.naturality walking_cospan.hom.inr).symm.trans\n          (c.\u03c0.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\u2093'. -/\ntheorem hasPullback_of_preservesPullback [HasPullback f g] : HasPullback (G.map f) (G.map g) :=\n  \u27e8\u27e8\u27e8_, isLimitPullbackConeMapOfIsLimit G _ (pullbackIsPullback _ _)\u27e9\u27e9\u27e9\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\u2093'. -/\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) \u2245 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\u2093'. -/\n@[reassoc.1]\ntheorem PreservesPullback.iso_hom_fst :\n    (PreservesPullback.iso G f g).Hom \u226b 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\u2093'. -/\n@[reassoc.1]\ntheorem PreservesPullback.iso_hom_snd :\n    (PreservesPullback.iso G f g).Hom \u226b 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\u2093'. -/\n@[simp, reassoc.1]\ntheorem PreservesPullback.iso_inv_fst :\n    (PreservesPullback.iso G f g).inv \u226b 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\u2093'. -/\n@[simp, reassoc.1]\ntheorem PreservesPullback.iso_inv_snd :\n    (PreservesPullback.iso G f g).inv \u226b 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\u2081} [Category.{v\u2081} C]\n\nvariable {D : Type u\u2082} [Category.{v\u2082} D]\n\nvariable (G : C \u2964 D)\n\nvariable {W X Y Z : C} {h : X \u27f6 Z} {k : Y \u27f6 Z} {f : W \u27f6 X} {g : W \u27f6 Y} (comm : f \u226b h = g \u226b 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\u2093'. -/\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)) \u2243\n      IsColimit\n        (PushoutCocone.mk (G.map h) (G.map k) (by simp only [\u2190 G.map_comp, comm]) :\n          PushoutCocone (G.map f) (G.map g)) :=\n  (IsColimit.precomposeHomEquiv (diagramIsoSpan.{v\u2082} _).symm _).symm.trans <|\n    IsColimit.equivIsoColimit <|\n      Cocones.ext (Iso.refl _) <| by\n        rintro (_ | _ | _) <;> dsimp <;>\n          simp only [category.comp_id, category.id_comp, \u2190 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2082} _).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    \u00b7 apply (config := { instances := false }) preserves_colimit.preserves\n      \u00b7 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\u2081} _) _).invFun hc\n    \u00b7 exact (c.\u03b9.naturality walking_span.hom.snd).trans (c.\u03b9.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\u2093'. -/\ntheorem hasPushout_of_preservesPushout [HasPushout f g] : HasPushout (G.map f) (G.map g) :=\n  \u27e8\u27e8\u27e8_, isColimitPushoutCoconeMapOfIsColimit G _ (pushoutIsPushout _ _)\u27e9\u27e9\u27e9\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\u2093'. -/\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) \u2245 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\u2093'. -/\n@[reassoc.1]\ntheorem PreservesPushout.inl_iso_hom :\n    pushout.inl \u226b (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\u2093'. -/\n@[reassoc.1]\ntheorem PreservesPushout.inr_iso_hom :\n    pushout.inr \u226b (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\u2093'. -/\n@[simp, reassoc.1]\ntheorem PreservesPushout.inl_iso_inv :\n    G.map pushout.inl \u226b (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\u2093'. -/\n@[simp, reassoc.1]\ntheorem PreservesPushout.inr_iso_inv :\n    G.map pushout.inr \u226b (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\u2081} [Category.{v\u2081} C]\n\nvariable {D : Type u\u2082} [Category.{v\u2081} D]\n\nvariable (G : C \u2964 D)\n\nsection Pullback\n\nvariable {X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 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\u2093'. -/\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\u2093'. -/\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 [\u2190 preserves_pullback.iso_hom]\n  infer_instance\n\nend Pullback\n\nsection Pushout\n\nvariable {X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 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\u2093'. -/\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\u2093'. -/\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 [\u2190 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 \u03b2`,\nfor some type index `\u03b2`.\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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v}\n\n/-- `alist \u03b2` 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 (\u03b2 : \u03b1 \u2192 Type v) : Type (max u v) :=\n(entries : list (sigma \u03b2))\n(nodupkeys : entries.nodupkeys)\n\n/-- Given `l : list (sigma \u03b2)`, create a term of type `alist \u03b2` by removing\nentries with duplicate keys. -/\ndef list.to_alist [decidable_eq \u03b1] {\u03b2 : \u03b1 \u2192 Type v} (l : list (sigma \u03b2)) : alist \u03b2 :=\n{ entries := _,\n  nodupkeys := nodupkeys_erase_dupkeys l }\n\nnamespace alist\n\n@[ext] theorem ext : \u2200 {s t : alist \u03b2}, s.entries = t.entries \u2192 s = t\n| \u27e8l\u2081, h\u2081\u27e9 \u27e8l\u2082, h\u2082\u27e9 H := by congr'\n\nlemma ext_iff {s t : alist \u03b2} : s = t \u2194 s.entries = t.entries :=\n\u27e8congr_arg _, ext\u27e9\n\ninstance [decidable_eq \u03b1] [\u2200 a, decidable_eq (\u03b2 a)] : decidable_eq (alist \u03b2) :=\n\u03bb 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 \u03b2) : list \u03b1 := s.entries.keys\n\ntheorem keys_nodup (s : alist \u03b2) : s.keys.nodup := s.nodupkeys\n\n/-! ### mem -/\n\n/-- The predicate `a \u2208 s` means that `s` has a value associated to the key `a`. -/\ninstance : has_mem \u03b1 (alist \u03b2) := \u27e8\u03bb a s, a \u2208 s.keys\u27e9\n\ntheorem mem_keys {a : \u03b1} {s : alist \u03b2} : a \u2208 s \u2194 a \u2208 s.keys := iff.rfl\n\ntheorem mem_of_perm {a : \u03b1} {s\u2081 s\u2082 : alist \u03b2} (p : s\u2081.entries ~ s\u2082.entries) : a \u2208 s\u2081 \u2194 a \u2208 s\u2082 :=\n(p.map sigma.fst).mem_iff\n\n/-! ### empty -/\n\n/-- The empty association list. -/\ninstance : has_emptyc (alist \u03b2) := \u27e8\u27e8[], nodupkeys_nil\u27e9\u27e9\n\ninstance : inhabited (alist \u03b2) := \u27e8\u2205\u27e9\n\ntheorem not_mem_empty (a : \u03b1) : a \u2209 (\u2205 : alist \u03b2) :=\nnot_mem_nil a\n\n@[simp] theorem empty_entries : (\u2205 : alist \u03b2).entries = [] := rfl\n\n@[simp] theorem keys_empty : (\u2205 : alist \u03b2).keys = [] := rfl\n\n/-! ### singleton -/\n\n/-- The singleton association list. -/\ndef singleton (a : \u03b1) (b : \u03b2 a) : alist \u03b2 :=\n\u27e8[\u27e8a, b\u27e9], nodupkeys_singleton _\u27e9\n\n@[simp] \n\n@[simp] theorem keys_singleton (a : \u03b1) (b : \u03b2 a) : (singleton a b).keys = [a] := rfl\n\n/-! ### lookup -/\n\nsection\n\nvariables [decidable_eq \u03b1]\n\n/-- Look up the value associated to a key in an association list. -/\ndef lookup (a : \u03b1) (s : alist \u03b2) : option (\u03b2 a) :=\ns.entries.lookup a\n\n@[simp] theorem lookup_empty (a) : lookup a (\u2205 : alist \u03b2) = none :=\nrfl\n\ntheorem lookup_is_some {a : \u03b1} {s : alist \u03b2} :\n  (s.lookup a).is_some \u2194 a \u2208 s := lookup_is_some\n\ntheorem lookup_eq_none {a : \u03b1} {s : alist \u03b2} :\n  lookup a s = none \u2194 a \u2209 s :=\nlookup_eq_none\n\ntheorem perm_lookup {a : \u03b1} {s\u2081 s\u2082 : alist \u03b2} (p : s\u2081.entries ~ s\u2082.entries) :\n  s\u2081.lookup a = s\u2082.lookup a :=\nperm_lookup _ s\u2081.nodupkeys s\u2082.nodupkeys p\n\ninstance (a : \u03b1) (s : alist \u03b2) : decidable (a \u2208 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 : \u03b1) (b : \u03b2 a) (s : alist \u03b2) : alist \u03b2 :=\n\u27e8kreplace a b s.entries, (kreplace_nodupkeys a b).2 s.nodupkeys\u27e9\n\n@[simp] theorem keys_replace (a : \u03b1) (b : \u03b2 a) (s : alist \u03b2) :\n  (replace a b s).keys = s.keys :=\nkeys_kreplace _ _ _\n\n@[simp] theorem mem_replace {a a' : \u03b1} {b : \u03b2 a} {s : alist \u03b2} :\n  a' \u2208 replace a b s \u2194 a' \u2208 s :=\nby rw [mem_keys, keys_replace, \u2190mem_keys]\n\ntheorem perm_replace {a : \u03b1} {b : \u03b2 a} {s\u2081 s\u2082 : alist \u03b2} :\n  s\u2081.entries ~ s\u2082.entries \u2192 (replace a b s\u2081).entries ~ (replace a b s\u2082).entries :=\nperm.kreplace s\u2081.nodupkeys\n\nend\n\n/-- Fold a function over the key-value pairs in the map. -/\ndef foldl {\u03b4 : Type w} (f : \u03b4 \u2192 \u03a0 a, \u03b2 a \u2192 \u03b4) (d : \u03b4) (m : alist \u03b2) : \u03b4 :=\nm.entries.foldl (\u03bb r a, f r a.1 a.2) d\n\n/-! ### erase -/\n\nsection\n\nvariables [decidable_eq \u03b1]\n\n/-- Erase a key from the map. If the key is not present, do nothing. -/\ndef erase (a : \u03b1) (s : alist \u03b2) : alist \u03b2 :=\n\u27e8kerase a s.entries, kerase_nodupkeys _ s.nodupkeys\u27e9\n\n@[simp] theorem keys_erase (a : \u03b1) (s : alist \u03b2) :\n  (erase a s).keys = s.keys.erase a :=\nby simp only [erase, keys, keys_kerase]\n\n@[simp] theorem mem_erase {a a' : \u03b1} {s : alist \u03b2} : a' \u2208 erase a s \u2194 a' \u2260 a \u2227 a' \u2208 s :=\nby rw [mem_keys, keys_erase, mem_erase_iff_of_nodup s.keys_nodup, \u2190mem_keys]\n\ntheorem perm_erase {a : \u03b1} {s\u2081 s\u2082 : alist \u03b2} :\n  s\u2081.entries ~ s\u2082.entries \u2192 (erase a s\u2081).entries ~ (erase a s\u2082).entries :=\nperm.kerase s\u2081.nodupkeys\n\n@[simp] theorem lookup_erase (a) (s : alist \u03b2) : lookup a (erase a s) = none :=\nlookup_kerase a s.nodupkeys\n\n@[simp] theorem lookup_erase_ne {a a'} {s : alist \u03b2} (h : a \u2260 a') :\n  lookup a (erase a' s) = lookup a s :=\nlookup_kerase_ne h\n\ntheorem erase_erase (a a' : \u03b1) (s : alist \u03b2) :\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 : \u03b1) (b : \u03b2 a) (s : alist \u03b2) : alist \u03b2 :=\n\u27e8kinsert a b s.entries, kinsert_nodupkeys a b s.nodupkeys\u27e9\n\n@[simp] theorem insert_entries {a} {b : \u03b2 a} {s : alist \u03b2} :\n  (insert a b s).entries = sigma.mk a b :: kerase a s.entries :=\nrfl\n\ntheorem insert_entries_of_neg {a} {b : \u03b2 a} {s : alist \u03b2} (h : a \u2209 s) :\n  (insert a b s).entries = \u27e8a, b\u27e9 :: s.entries :=\nby rw [insert_entries, kerase_of_not_mem_keys h]\n\n@[simp] theorem mem_insert {a a'} {b' : \u03b2 a'} (s : alist \u03b2) :\n  a \u2208 insert a' b' s \u2194 a = a' \u2228 a \u2208 s :=\nmem_keys_kinsert\n\n@[simp] theorem keys_insert {a} {b : \u03b2 a} (s : alist \u03b2) :\n  (insert a b s).keys = a :: s.keys.erase a :=\nby simp [insert, keys, keys_kerase]\n\ntheorem perm_insert {a} {b : \u03b2 a} {s\u2081 s\u2082 : alist \u03b2} (p : s\u2081.entries ~ s\u2082.entries) :\n  (insert a b s\u2081).entries ~ (insert a b s\u2082).entries :=\nby simp only [insert_entries]; exact p.kinsert s\u2081.nodupkeys\n\n@[simp] theorem lookup_insert {a} {b : \u03b2 a} (s : alist \u03b2) : 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' : \u03b2 a'} {s : alist \u03b2} (h : a \u2260 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 \u03b2)) : 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' : \u03b2 a} (s : alist \u03b2) :\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* [_ \u2227 _]; refl\n\ntheorem insert_insert_of_ne {a a'} {b : \u03b2 a} {b' : \u03b2 a'} (s : alist \u03b2) (h : a \u2260 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 : \u03b1} {b b' : \u03b2 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 \u03b2)) :\n  (list.to_alist xs).entries = erase_dupkeys xs := rfl\n\ntheorem to_alist_cons (a : \u03b1) (b : \u03b2 a) (xs : list (sigma \u03b2)) :\n  list.to_alist (\u27e8a,b\u27e9 :: 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 : \u03b1) (s : alist \u03b2) : option (\u03b2 a) \u00d7 alist \u03b2 :=\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, \u27e8l, h\u27e9)\nend\n\n@[simp] theorem extract_eq_lookup_erase (a : \u03b1) (s : alist \u03b2) :\n  extract a s = (lookup a s, erase a s) :=\nby simp [extract]; split; refl\n\n/-! ### union -/\n\n/-- `s\u2081 \u222a s\u2082` is the key-based union of two association lists. It is\nleft-biased: if there exists an `a \u2208 s\u2081`, `lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081`.\n-/\ndef union (s\u2081 s\u2082 : alist \u03b2) : alist \u03b2 :=\n\u27e8kunion s\u2081.entries s\u2082.entries, kunion_nodupkeys s\u2081.nodupkeys s\u2082.nodupkeys\u27e9\n\ninstance : has_union (alist \u03b2) := \u27e8union\u27e9\n\n@[simp] theorem union_entries {s\u2081 s\u2082 : alist \u03b2} :\n  (s\u2081 \u222a s\u2082).entries = kunion s\u2081.entries s\u2082.entries :=\nrfl\n\n@[simp] theorem empty_union {s : alist \u03b2} : (\u2205 : alist \u03b2) \u222a s = s :=\next rfl\n\n@[simp] theorem union_empty {s : alist \u03b2} : s \u222a (\u2205 : alist \u03b2) = s :=\next $ by simp\n\n@[simp] theorem mem_union {a} {s\u2081 s\u2082 : alist \u03b2} :\n  a \u2208 s\u2081 \u222a s\u2082 \u2194 a \u2208 s\u2081 \u2228 a \u2208 s\u2082 :=\nmem_keys_kunion\n\ntheorem perm_union {s\u2081 s\u2082 s\u2083 s\u2084 : alist \u03b2}\n  (p\u2081\u2082 : s\u2081.entries ~ s\u2082.entries) (p\u2083\u2084 : s\u2083.entries ~ s\u2084.entries) :\n  (s\u2081 \u222a s\u2083).entries ~ (s\u2082 \u222a s\u2084).entries :=\nby simp [p\u2081\u2082.kunion s\u2083.nodupkeys p\u2083\u2084]\n\ntheorem union_erase (a : \u03b1) (s\u2081 s\u2082 : alist \u03b2) : erase a (s\u2081 \u222a s\u2082) = erase a s\u2081 \u222a erase a s\u2082 :=\next kunion_kerase.symm\n\n@[simp] theorem lookup_union_left {a} {s\u2081 s\u2082 : alist \u03b2} :\n  a \u2208 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081 :=\nlookup_kunion_left\n\n@[simp] theorem lookup_union_right {a} {s\u2081 s\u2082 : alist \u03b2} :\n  a \u2209 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2082 :=\nlookup_kunion_right\n\n@[simp] theorem mem_lookup_union {a} {b : \u03b2 a} {s\u2081 s\u2082 : alist \u03b2} :\n  b \u2208 lookup a (s\u2081 \u222a s\u2082) \u2194 b \u2208 lookup a s\u2081 \u2228 a \u2209 s\u2081 \u2227 b \u2208 lookup a s\u2082 :=\nmem_lookup_kunion\n\ntheorem mem_lookup_union_middle {a} {b : \u03b2 a} {s\u2081 s\u2082 s\u2083 : alist \u03b2} :\n  b \u2208 lookup a (s\u2081 \u222a s\u2083) \u2192 a \u2209 s\u2082 \u2192 b \u2208 lookup a (s\u2081 \u222a s\u2082 \u222a s\u2083) :=\nmem_lookup_kunion_middle\n\ntheorem insert_union {a} {b : \u03b2 a} {s\u2081 s\u2082 : alist \u03b2} :\n  insert a b (s\u2081 \u222a s\u2082) = insert a b s\u2081 \u222a s\u2082 :=\nby ext; simp\n\ntheorem union_assoc {s\u2081 s\u2082 s\u2083 : alist \u03b2} : ((s\u2081 \u222a s\u2082) \u222a s\u2083).entries ~ (s\u2081 \u222a (s\u2082 \u222a s\u2083)).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\u2081 s\u2082 : alist \u03b2) : Prop :=\n\u2200 k \u2208 s\u2081.keys, \u00ac k \u2208 s\u2082.keys\n\nvariables [decidable_eq \u03b1]\n\ntheorem union_comm_of_disjoint {s\u2081 s\u2082 : alist \u03b2} (h : disjoint s\u2081 s\u2082) :\n  (s\u2081 \u222a s\u2082).entries ~ (s\u2082 \u222a s\u2081).entries :=\nlookup_ext (alist.nodupkeys _) (alist.nodupkeys _)\n(begin\n   intros, simp,\n   split; intro h',\n   cases h',\n   { right, refine \u27e8_,h'\u27e9,\n     apply h, rw [keys,\u2190 list.lookup_is_some,h'], exact rfl },\n   { left, rw h'.2 },\n   cases h',\n   { right, refine \u27e8_,h'\u27e9, intro h'',\n     apply h _ h'', rw [keys,\u2190 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 \u2964 AddCommGroup.{u} :=\n{ obj := \u03bb X, AddCommGroup.of $ X \u2192\u2080 \u2124,\n  map := \u03bb 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 \u2243+ B) : of A \u2245 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} \u2245 free'.{u} :=\ncategory_theory.nat_iso.of_components\n(\u03bb X, of_iso (free_abelian_group.equiv_finsupp X))\nbegin\n  intros X Y f, ext, dsimp, simp,\nend\n\ndef adj' : free'.{u} \u22a3 forget AddCommGroup.{u} :=\nAddCommGroup.adj.of_nat_iso_left $ free_iso_free'.{u}\n\nend AddCommGroup\n\ndef types.pt {\u03b1 : Type u} (a : \u03b1) : \u22a4_ _ \u27f6 \u03b1 :=\n\u03bb x, a\n\ndef types.punit_iso : (punit : Type u) \u2245 \u22a4_ _ :=\n{ hom := limits.terminal.from _,\n  inv := types.pt punit.star }\n\nnamespace AddCommGroup\n\ndef tunit : AddCommGroup.{u} :=\n  AddCommGroup.free'.obj (\u22a4_ _)\n\ndef tunit.lift {A : AddCommGroup.{u}} (e : \u22a4_ _ \u27f6 (forget _).obj A) :\n  tunit \u27f6 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) \u2192\u2080 M) \u2243+ M :=\n{ to_fun := \u03bb f, f punit.star,\n  inv_fun := \u03bb m, finsupp.single punit.star m,\n  left_inv := \u03bb x, by { ext, dsimp, simp },\n  right_inv := \u03bb x, by { dsimp, simp },\n  map_add' := \u03bb f g, by simp }\n\n-- Do we really not have this?!\ndef add_equiv_of_iso (A B : AddCommGroup.{u}) (e : A \u2245 B) :\n  A \u2243+ B :=\n{ to_fun := e.hom,\n  inv_fun := e.inv,\n  left_inv := \u03bb x, by simp,\n  right_inv := \u03bb x, by simp,\n  map_add' := \u03bb x y, e.hom.map_add _ _ }\n\ndef tunit_add_equiv : tunit.{u} \u2243+ \u2124 :=\nadd_equiv.trans (add_equiv_of_iso _ _ $ AddCommGroup.free'.map_iso\n  types.punit_iso.symm) (finsupp.punit_add_equiv \u2124)\n\ndef tunit.gen : tunit.{u} :=\nAddCommGroup.adj'.unit.app _ $\n  (limits.terminal.from (punit : Type u) : punit \u2192 \u22a4_ (Type u)) punit.star\n\nopen_locale classical\n\ndef coproduct_cocone_of_basis {\u03b9 : Type v} {A : AddCommGroup.{u}} (\ud835\udcd1 : basis \u03b9 \u2124 A) :\n  limits.cofan (\u03bb i : \u03b9, tunit.{u}) :=\nlimits.cofan.mk A (\u03bb i, AddCommGroup.of_hom\n  ((zmultiples_add_hom A.\u03b1 (\ud835\udcd1 i)).comp tunit_add_equiv.to_add_monoid_hom))\n\ndef coproduct_cocone_of_basis_is_colimit {\u03b9 : Type v} {A : AddCommGroup.{u}}\n  (\ud835\udcd1 : basis \u03b9 \u2124 A) : limits.is_colimit (coproduct_cocone_of_basis \ud835\udcd1) :=\n{ desc := \u03bb s, AddCommGroup.of_hom\n    ((finsupp.total \u03b9 s.X.\u03b1 \u2124 (\u03bb i, s.\u03b9.app \u27e8i\u27e9 (tunit_add_equiv.symm 1))).comp\n      \ud835\udcd1.repr.to_linear_map).to_add_monoid_hom,\n  fac' := begin\n    rintros s \u27e8j\u27e9,\n    apply finsupp.add_hom_ext,\n    intros x y,\n    dsimp [coproduct_cocone_of_basis],\n    simp [\u2190 map_zsmul],\n  end,\n  uniq' := begin\n    intros s m e,\n    apply (add_monoid_hom_lequiv_int \u2124).injective,\n    swap, { apply_instance },\n    apply \ud835\udcd1.ext,\n    intro i,\n    convert concrete_category.congr_hom (e \u27e8i\u27e9) (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 {\u03b9 : Type v} [limits.has_coproduct (\u03bb (i : \u03b9), tunit.{u})]\n  {A : AddCommGroup.{u}} (\ud835\udcd1 : basis \u03b9 \u2124 A) :\n  (\u2210 (\u03bb i : \u03b9, tunit.{u})) \u2245 A :=\nlimits.is_colimit.cocone_point_unique_up_to_iso (limits.coproduct_is_coproduct _)\n  (coproduct_cocone_of_basis_is_colimit \ud835\udcd1)\n-- begin\n--   -- This is very messy...\n--   let e : (\u2210 (\u03bb i : \u03b9, tunit.{u})) \u2245 (\u2a01 (\u03bb i, tunit.{u})) :=\n--     (limits.colimit.is_colimit _).cocone_point_unique_up_to_iso\n--       (limits.biproduct.is_bilimit _).is_colimit,\n--   refine e \u226a\u226b _,\n--   refine biproduct_iso_pi _ \u226a\u226b _,\n--   let e : A \u2243+ ulift.{u} (\u03b9 \u2192\u2080 \u2124) := \ud835\udcd1.repr.to_add_equiv.trans add_equiv.ulift.symm,\n--   refine AddCommGroup.of_iso _ \u226a\u226b (AddCommGroup.of_iso e).symm \u226a\u226b\n--     \u27e8add_monoid_hom.id _, add_monoid_hom.id _, by { ext, refl }, by { ext, refl }\u27e9,\n--   refine add_equiv.trans _ add_equiv.ulift.symm,\n--   let q : tunit.{u} \u2243+ \u2124 := tunit_add_equiv,\n--   let e : (\u03b9 \u2192\u2080 \u2124) \u2243+ (\u03b9 \u2192 \u2124),\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 \u2124 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 \u2124 A] :\n  nonempty A.index_cat := \u27e8\u27e8\u22a5, \u2205, by simp\u27e9\u27e9\n\ninstance semilattice_sup_index_cat\n  (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A] :\n  semilattice_sup A.index_cat :=\n{ sup := \u03bb I J, \u27e8I.1 \u2294 J.1, begin\n    obtain \u27e8S,hS\u27e9 := I.2,\n    obtain \u27e8T,hT\u27e9 := J.2,\n    rw [\u2190 hS, \u2190 hT],\n    use S \u222a T,\n    simp only [finset.coe_union, add_subgroup.closure_union],\n  end\u27e9,\n  le_sup_left := \u03bb I J, @le_sup_left (add_subgroup A) _ _ _,\n  le_sup_right := \u03bb I J, @le_sup_right (add_subgroup A) _ _ _,\n  sup_le := \u03bb 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 \u2124 A] :\n  A.index_cat \u2964 AddCommGroup.{u} :=\n{ obj := \u03bb I, AddCommGroup.of I.1,\n  map := \u03bb I J h, add_subgroup.inclusion h.le }\n\ndef cocone (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A] :\n  limits.cocone A.diagram :=\n{ X := A,\n  \u03b9 := { app := \u03bb I, I.1.subtype } }\n\ndef is_colimit_cocone (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A] :\n  limits.is_colimit A.cocone :=\n{ desc := \u03bb S,\n  { to_fun := \u03bb a, S.\u03b9.app \u27e8add_subgroup.closure {a}, {a}, by simp\u27e9\n      \u27e8a, add_subgroup.subset_closure rfl\u27e9,\n    map_zero' := add_monoid_hom.map_zero _,\n    map_add' := \u03bb x y, begin\n      let I : A.index_cat := \u27e8add_subgroup.closure {x}, {x}, by simp\u27e9,\n      let J : A.index_cat := \u27e8add_subgroup.closure {y}, {y}, by simp\u27e9,\n      let K : A.index_cat := \u27e8add_subgroup.closure {x + y}, {x + y}, by simp\u27e9,\n      let IJ : A.index_cat := \u27e8add_subgroup.closure {x,y}, {x,y}, by simp\u27e9,\n      let iI : I \u27f6 IJ := hom_of_le (add_subgroup.closure_mono $ by simp),\n      let iJ : J \u27f6 IJ := hom_of_le (add_subgroup.closure_mono $ by simp),\n      let iK : K \u27f6 IJ := hom_of_le ((add_subgroup.closure_le _).2 _),\n      swap,\n      { rintro a (rfl : a = _), change x + y \u2208 IJ.1, apply IJ.1.add_mem,\n        { apply add_subgroup.subset_closure, simp },\n        { apply add_subgroup.subset_closure, simp } },\n      rw [\u2190 S.w iI, \u2190 S.w iJ, \u2190 S.w iK, comp_apply, comp_apply, comp_apply,\n        \u2190 add_monoid_hom.map_add],\n      refl,\n    end },\n  fac' := begin\n    rintros S J, ext \u27e8x,hx\u27e9,\n    let I : A.index_cat := \u27e8add_subgroup.closure {x}, {x}, by simp\u27e9,\n    let e : I \u27f6 J := hom_of_le ((add_subgroup.closure_le _).2 _),\n    { rw comp_apply, dsimp [cocone], rw \u2190 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 \u22a2,\n    let I : A.index_cat := \u27e8add_subgroup.closure {x}, {x}, by simp\u27e9,\n    specialize hm I,\n    let y : I.1 := \u27e8x, add_subgroup.subset_closure rfl\u27e9,\n    apply_fun (\u03bb e, e y) at hm, exact hm,\n  end }\n\ndef colimit_comparison (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A] :\n  limits.colimit A.diagram \u2245 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 \u2124 A]\n  (I : A.index_cat) : \u2203 (\u03b9 : Type v) [fintype \u03b9]\n  (\ud835\udcd1 : basis \u03b9 \u2124 (AddCommGroup.of I.1)), true :=\nbegin\n  obtain \u27e8S,hS\u27e9 := I.2,\n  let e : S \u2192 I.1 := \u03bb s, \u27e8s,_\u27e9,\n  swap, { rw \u2190 hS, apply add_subgroup.subset_closure, exact s.2 },\n  haveI : no_zero_smul_divisors \u2124 I.1,\n  { constructor, rintros c \u27e8x, hx\u27e9 h, apply_fun (\u03bb 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 \u27e8n,B\u27e9 := @module.free_of_finite_type_torsion_free S \u2124 _ _ _ I.1 _ _ _ e _ _,\n  { use [ulift (fin n), infer_instance],\n    refine \u27e8_, trivial\u27e9,\n    apply B.reindex,\n    exact equiv.ulift.symm },\n  { apply le_antisymm, { intros x hx, trivial },\n    rintros \u27e8x,hx\u27e9 -,\n    let J := (submodule.span \u2124 (set.range e)).to_add_subgroup,\n    change _ \u2208 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 [\u2190 hS, submodule.span_int_eq_add_subgroup_closure, add_monoid_hom.map_closure], congr' 1,\n    ext t,\n    split,\n    { rintros \u27e8t,\u27e8t,rfl\u27e9,rfl\u27e9, exact t.2 },\n    { intros ht, refine \u27e8\u27e8t, _\u27e9, \u27e8\u27e8t, ht\u27e9, rfl\u27e9, rfl\u27e9 } },\nend\n.\n\nlemma exists_sigma_iso_of_index (A : AddCommGroup.{u})\n  [no_zero_smul_divisors \u2124 A]\n  (I : A.index_cat) : \u2203 (\u03b9 : Type v) [fintype \u03b9]\n  (e : by exactI (\u2210 (\u03bb i : \u03b9, tunit.{u})) \u2245 AddCommGroup.of I.1), true :=\nbegin\n  obtain \u27e8\u03b9,h\u03b9,\ud835\udcd1,-\u27e9 := exists_basis_of_index.{v} A I,\n  resetI,\n  exact \u27e8\u03b9, h\u03b9, iso_of_basis \ud835\udcd1, trivial\u27e9,\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\u27e8\u03bb F, begin\n  have : F = (F \u2218 (fintype.equiv_fin J).inv_fun) \u2218 (fintype.equiv_fin J).to_fun,\n  { ext, dsimp, rw equiv.symm_apply_apply },\n  rw this,\n  exact \u27e8\u27e8\u27e8_, (limits.bicone.whisker_is_bilimit_iff _ (fintype.equiv_fin J)).symm\n  (limits.biproduct.is_bilimit $ F \u2218 (fintype.equiv_fin J).inv_fun)\u27e9\u27e9\u27e9\nend\u27e9\n\nlemma exists_biprod_iso_of_index\n  (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A]\n  (I : A.index_cat) : \u2203 (\u03b9 : Type v) [fintype \u03b9]\n  (e : by exactI (\u2a01 (\u03bb i : \u03b9, tunit.{u})) \u2245 AddCommGroup.of I.1), true :=\nbegin\n  obtain \u27e8\u03b9,h\u03b9,e,-\u27e9 := exists_sigma_iso_of_index A I,\n  resetI, use [\u03b9, h\u03b9],\n  use (limits.biproduct.is_bilimit _).is_colimit.cocone_point_unique_up_to_iso\n      (limits.colimit.is_colimit _) \u226a\u226b e,\nend\n\nuniverses u'\n\n\nlemma is_iso_of_preserves {\ud835\udcd0 : Type u'} [category.{u} \ud835\udcd0] [preadditive \ud835\udcd0]\n  (F G : AddCommGroup \u2964 \ud835\udcd0)\n  [F.additive]\n  [G.additive]\n  [limits.preserves_filtered_colimits F]\n  [limits.preserves_filtered_colimits G]\n  (\u03b7 : F \u27f6 G)\n  [h\u03b7 : is_iso (\u03b7.app tunit)]\n  (A : AddCommGroup.{u})\n  [no_zero_smul_divisors \u2124 A] :\n  is_iso (\u03b7.app A) :=\nbegin\n  let T := (limits.cocones.precompose (whisker_left A.diagram \u03b7)).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 : \u03b7.app A = hS.desc T,\n  { apply hS.hom_ext, intros j, rw hS.fac,\n    dsimp, apply \u03b7.naturality },\n  rw this, clear this,\n  suffices : \u2200 I : A.index_cat, is_iso (\u03b7.app (A.diagram.obj I)),\n  { resetI,\n    haveI : is_iso (whisker_left A.diagram \u03b7),\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 \u03b7))\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 \u27e8\u03b9 : Type,h\u03b9,e,-\u27e9 := 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 (\u2a01 \u03bb (i : \u03b9), tunit.{u}) \u2245 \u2a01 \u03bb (i : \u03b9), F.obj tunit :=\n    (limits.is_bilimit_of_preserves F\n    (limits.biproduct.is_bilimit (\u03bb i : \u03b9, tunit.{u}))).is_colimit.cocone_point_unique_up_to_iso\n    (limits.biproduct.is_bilimit (\u03bb i : \u03b9, F.obj tunit)).is_colimit,\n  let eG : G.obj (\u2a01 \u03bb (i : \u03b9), tunit.{u}) \u2245 \u2a01 \u03bb (i : \u03b9), G.obj tunit :=\n    (limits.is_bilimit_of_preserves G\n    (limits.biproduct.is_bilimit (\u03bb i : \u03b9, tunit.{u}))).is_colimit.cocone_point_unique_up_to_iso\n    (limits.biproduct.is_bilimit (\u03bb i : \u03b9, G.obj tunit)).is_colimit,\n  have : \u03b7.app (A.diagram.obj I) =\n    F.map e.inv \u226b eF.hom \u226b limits.biproduct.map (\u03bb i, \u03b7.app _) \u226b eG.inv \u226b G.map e.hom,\n  { rw [\u2190 functor.map_iso_inv, iso.eq_inv_comp, \u2190 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.\u03b9_map_assoc, category.assoc],\n    erw [limits.biproduct.\u03b9_desc_assoc, limits.biproduct.\u03b9_desc_assoc],\n    dsimp, rw \u03b7.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      (\u03bb i, inv (\u03b7.app _) \u226b limits.biproduct.\u03b9 _ i),\n  split,\n  { ext, simp },\n  { ext, simp },\nend\n\ndef is_tensor_unit (A : AddCommGroup.{u}) : Prop :=\n\u2203 a : A, \u2200 (B : AddCommGroup.{u}), function.bijective\n  (\u03bb f : A \u27f6 B, (f : A \u2192 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 \u27f6 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 \u27f6 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 \u2245 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 _ \u226b (forget _).map f) _ =\n      (adj'.unit.app _ \u226b (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 _ \u226b\n      (forget _).map (free'.map (\u03bb (x : \u22a4_ Type u), t) \u226b 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 {\ud835\udcd0 : Type u'} [category.{u} \ud835\udcd0] [preadditive \ud835\udcd0]\n  (F G : AddCommGroup \u2964 \ud835\udcd0)\n  [F.additive]\n  [G.additive]\n  [limits.preserves_filtered_colimits F]\n  [limits.preserves_filtered_colimits G]\n  (\u03b7 : F \u27f6 G)\n  (U : AddCommGroup)\n  (hU : U.is_tensor_unit)\n  [h\u03b7 : is_iso (\u03b7.app U)]\n  (A : AddCommGroup.{u})\n  [no_zero_smul_divisors \u2124 A] :\n  is_iso (\u03b7.app A) :=\nbegin\n  suffices : is_iso (\u03b7.app tunit),\n  { resetI, apply is_iso_of_preserves },\n  let e : tunit \u2245 U := is_tensor_unit_tunit.iso hU,\n  suffices : \u03b7.app tunit = F.map e.hom \u226b \u03b7.app U \u226b G.map e.inv,\n  { rw this, apply is_iso.comp_is_iso, },\n  rw [\u2190 \u03b7.naturality, \u2190 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 : \u2115) : \u2115 := n + n\n\n#check double\n\n#check double \u2218 double\n\ndefinition quadruple : \u2115 \u2192 \u2115 := double \u2218 double\n\ndefinition FLT : Prop :=\n\u2200 n > 2, \u2200 x y z, x^n + y^n = z^n \u2192 (x = 0 \u2228 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 \u2192 Q)\n(Q_imp_R : Q \u2192 R) :\n  P \u2192 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 \u2192 Q)\n(Q_imp_R : Q \u2192 R) :\n  P \u2192 R := Q_imp_R \u2218 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 : Type*}\nlocal infix ` ~\u1d64 ` : 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 (\u03b1 : Type*) [comm_monoid_with_zero \u03b1] : Prop :=\n(well_founded_dvd_not_unit : well_founded (@dvd_not_unit \u03b1 _))\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 \u03b1] [is_domain \u03b1] [is_noetherian_ring \u03b1] :\n  wf_dvd_monoid \u03b1 :=\n\u27e8by { convert inv_image.wf (\u03bb a, ideal.span ({a} : set \u03b1)) (well_founded_submodule_gt _ _),\n      ext,\n      exact ideal.span_singleton_lt_span_singleton.symm }\u27e9\n\nnamespace wf_dvd_monoid\n\nvariables [comm_monoid_with_zero \u03b1]\nopen associates nat\n\ntheorem of_wf_dvd_monoid_associates (h : wf_dvd_monoid (associates \u03b1)): wf_dvd_monoid \u03b1 :=\n\u27e8begin\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\u27e9\n\nvariables [wf_dvd_monoid \u03b1]\n\ninstance wf_dvd_monoid_associates : wf_dvd_monoid (associates \u03b1) :=\n\u27e8begin\n  refine (surjective.well_founded_iff mk_surjective _).1 well_founded_dvd_not_unit,\n  intros, rw mk_dvd_not_unit_mk_iff\nend\u27e9\n\ntheorem well_founded_associates : well_founded ((<) : associates \u03b1 \u2192 associates \u03b1 \u2192 Prop) :=\nsubrelation.wf (\u03bb 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 : \u03b1} (ha : \u00ac is_unit a) (ha0 : a \u2260 0) :\n  \u2203 i, irreducible i \u2227 i \u2223 a :=\nlet \u27e8b, hs, hr\u27e9 := well_founded_dvd_not_unit.has_min {b | b \u2223 a \u2227 \u00ac is_unit b} \u27e8a, dvd_rfl, ha\u27e9 in\n\u27e8b, \u27e8hs.2, \u03bb c d he, let h := dvd_trans \u27e8d, he\u27e9 hs.1 in or_iff_not_imp_left.2 $\n  \u03bb hc, of_not_not $ \u03bb hd, hr c \u27e8h, hc\u27e9 \u27e8ne_zero_of_dvd_ne_zero ha0 h, d, hd, he\u27e9\u27e9, hs.1\u27e9\n\n@[elab_as_eliminator] lemma induction_on_irreducible {P : \u03b1 \u2192 Prop} (a : \u03b1)\n  (h0 : P 0) (hu : \u2200 u : \u03b1, is_unit u \u2192 P u)\n  (hi : \u2200 a i : \u03b1, a \u2260 0 \u2192 irreducible i \u2192 P a \u2192 P (i * a)) :\n  P a :=\nby haveI := classical.dec; exact\nwell_founded_dvd_not_unit.fix\n  (\u03bb a ih, if ha0 : a = 0 then ha0.substr h0\n    else if hau : is_unit a then hu a hau\n    else let \u27e8i, hii, b, hb\u27e9 := exists_irreducible_factor hau ha0,\n      hb0 : b \u2260 0 := ne_zero_of_dvd_ne_zero ha0 \u27e8i, mul_comm i b \u25b8 hb\u27e9 in\n      hb.symm \u25b8 hi b i hb0 hii $ ih b \u27e8hb0, i, hii.1, mul_comm i b \u25b8 hb\u27e9)\n  a\n\nlemma exists_factors (a : \u03b1) : a \u2260 0 \u2192\n  \u2203 f : multiset \u03b1, (\u2200 b \u2208 f, irreducible b) \u2227 associated f.prod a :=\ninduction_on_irreducible a\n  (\u03bb h, (h rfl).elim)\n  (\u03bb u hu _, \u27e80, \u03bb _ h, h.elim, hu.unit, one_mul _\u27e9)\n  (\u03bb a i ha0 hi ih _,\n    let \u27e8s, hs\u27e9 := ih ha0 in\n    \u27e8i ::\u2098 s, \u03bb b H, (multiset.mem_cons.1 H).elim (\u03bb h, h.symm \u25b8 hi) (hs.1 b),\n      by { rw s.prod_cons i, exact hs.2.mul_left i }\u27e9)\n\nlemma not_unit_iff_exists_factors_eq (a : \u03b1) (hn0 : a \u2260 0) :\n  \u00ac is_unit a \u2194 \u2203 f : multiset \u03b1, (\u2200 b \u2208 f, irreducible b) \u2227 f.prod = a \u2227 f \u2260 \u2205 :=\n\u27e8\u03bb hnu, begin\n  obtain \u27e8f, hi, u, rfl\u27e9 := exists_factors a hn0,\n  obtain \u27e8b, h\u27e9 := multiset.exists_mem_of_ne_zero (\u03bb h : f = 0, hnu $ by simp [h]),\n  classical, refine \u27e8(f.erase b).cons (b * u), \u03bb a ha, _, _, multiset.cons_ne_zero\u27e9,\n  { obtain (rfl|ha) := multiset.mem_cons.1 ha,\n    exacts [associated.irreducible \u27e8u,rfl\u27e9 (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\u03bb \u27e8f, hi, he, hne\u27e9, let \u27e8b, h\u27e9 := multiset.exists_mem_of_ne_zero hne in\n  not_is_unit_of_not_is_unit_dvd (hi b h).not_unit $ he \u25b8 multiset.dvd_prod h\u27e9\n\nend wf_dvd_monoid\n\ntheorem wf_dvd_monoid.of_well_founded_associates [cancel_comm_monoid_with_zero \u03b1]\n  (h : well_founded ((<) : associates \u03b1 \u2192 associates \u03b1 \u2192 Prop)) : wf_dvd_monoid \u03b1 :=\nwf_dvd_monoid.of_wf_dvd_monoid_associates\n  \u27e8by { convert h, ext, exact associates.dvd_not_unit_iff_lt }\u27e9\n\ntheorem wf_dvd_monoid.iff_well_founded_associates [cancel_comm_monoid_with_zero \u03b1] :\n  wf_dvd_monoid \u03b1 \u2194 well_founded ((<) : associates \u03b1 \u2192 associates \u03b1 \u2192 Prop) :=\n\u27e8by apply wf_dvd_monoid.well_founded_associates, wf_dvd_monoid.of_well_founded_associates\u27e9\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 (\u03b1 : Type*) [cancel_comm_monoid_with_zero \u03b1]\n  extends wf_dvd_monoid \u03b1 : Prop :=\n(irreducible_iff_prime : \u2200 {a : \u03b1}, irreducible a \u2194 prime a)\n\n/-- Can't be an instance because it would cause a loop `ufm \u2192 wf_dvd_monoid \u2192 ufm \u2192 ...`. -/\n@[reducible] lemma ufm_of_gcd_of_wf_dvd_monoid [cancel_comm_monoid_with_zero \u03b1]\n  [wf_dvd_monoid \u03b1] [gcd_monoid \u03b1] : unique_factorization_monoid \u03b1 :=\n{ irreducible_iff_prime := \u03bb _, gcd_monoid.irreducible_iff_prime\n  .. \u2039wf_dvd_monoid \u03b1\u203a }\n\ninstance associates.ufm [cancel_comm_monoid_with_zero \u03b1]\n  [unique_factorization_monoid \u03b1] : unique_factorization_monoid (associates \u03b1) :=\n{ irreducible_iff_prime := by { rw \u2190 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 \u03b1)) }\n\nend prio\n\nnamespace unique_factorization_monoid\nvariables [cancel_comm_monoid_with_zero \u03b1] [unique_factorization_monoid \u03b1]\n\ntheorem exists_prime_factors (a : \u03b1) : a \u2260 0 \u2192\n  \u2203 f : multiset \u03b1, (\u2200b \u2208 f, prime b) \u2227 f.prod ~\u1d64 a :=\nby { simp_rw \u2190 unique_factorization_monoid.irreducible_iff_prime,\n     apply wf_dvd_monoid.exists_factors a }\n\n@[elab_as_eliminator] lemma induction_on_prime {P : \u03b1 \u2192 Prop}\n  (a : \u03b1) (h\u2081 : P 0) (h\u2082 : \u2200 x : \u03b1, is_unit x \u2192 P x)\n  (h\u2083 : \u2200 a p : \u03b1, a \u2260 0 \u2192 prime p \u2192 P a \u2192 P (p * a)) : P a :=\nbegin\n  simp_rw \u2190 unique_factorization_monoid.irreducible_iff_prime at h\u2083,\n  exact wf_dvd_monoid.induction_on_irreducible a h\u2081 h\u2082 h\u2083,\nend\n\nlemma factors_unique : \u2200{f g : multiset \u03b1},\n  (\u2200x\u2208f, irreducible x) \u2192 (\u2200x\u2208g, irreducible x) \u2192 f.prod ~\u1d64 g.prod \u2192\n  multiset.rel associated f g :=\nby haveI := classical.dec_eq \u03b1; exact\n\u03bb f, multiset.induction_on f\n  (\u03bb g _ hg h,\n    multiset.rel_zero_left.2 $\n      multiset.eq_zero_of_forall_not_mem (\u03bb 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  (\u03bb p f ih g hf hg hfg,\n    let \u27e8b, hbg, hb\u27e9 := exists_associated_mem_of_dvd_prod\n      (irreducible_iff_prime.1 (hf p (by simp)))\n      (\u03bb q hq, irreducible_iff_prime.1 (hg _ hq)) $\n        hfg.dvd_iff_dvd_right.1\n          (show p \u2223 (p ::\u2098 f).prod, by simp) in\n    begin\n      rw \u2190 multiset.cons_erase hbg,\n      exact multiset.rel.cons hb (ih (\u03bb q hq, hf _ (by simp [hq]))\n        (\u03bb q (hq : q \u2208 g.erase b), hg q (multiset.mem_of_mem_erase hq))\n        (associated.of_mul_left\n          (by rwa [\u2190 multiset.prod_cons, \u2190 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 \u03b1] : \u2200 {f g : multiset \u03b1},\n  (\u2200 x \u2208 f, prime x) \u2192 (\u2200 x \u2208 g, prime x) \u2192 f.prod ~\u1d64 g.prod \u2192\n  multiset.rel associated f g :=\nby haveI := classical.dec_eq \u03b1; exact\n\u03bb f, multiset.induction_on f\n  (\u03bb g _ hg h,\n    multiset.rel_zero_left.2 $\n    multiset.eq_zero_of_forall_not_mem $ \u03bb 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  (\u03bb p f ih g hf hg hfg,\n    let \u27e8b, hbg, hb\u27e9 := exists_associated_mem_of_dvd_prod\n      (hf p (by simp)) (\u03bb q hq, hg _ hq) $\n        hfg.dvd_iff_dvd_right.1\n          (show p \u2223 (p ::\u2098 f).prod, by simp) in\n    begin\n      rw \u2190 multiset.cons_erase hbg,\n      exact multiset.rel.cons hb (ih (\u03bb q hq, hf _ (by simp [hq]))\n        (\u03bb q (hq : q \u2208 g.erase b), hg q (multiset.mem_of_mem_erase hq))\n        (associated.of_mul_left\n          (by rwa [\u2190 multiset.prod_cons, \u2190 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 \u03b1] {a : \u03b1} {f : multiset \u03b1}\n  (ha : irreducible a) (pfa : (\u2200 b \u2208 f, prime b) \u2227 f.prod ~\u1d64 a) :\n  \u2203 p, a ~\u1d64 p \u2227 f = {p} :=\nbegin\n  haveI := classical.dec_eq \u03b1,\n  refine multiset.induction_on f (\u03bb h, (ha.not_unit\n    (associated_one_iff_is_unit.1 (associated.symm h))).elim) _ pfa.2 pfa.1,\n  rintros p s _ \u27e8u, hu\u27e9 hs,\n  use p,\n  have hs0 : s = 0,\n  { by_contra hs0,\n    obtain \u27e8q, hq\u27e9 := 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 * \u2191u) * (s.erase q).prod) * _)).resolve_left _,\n    { rw [mul_right_comm _ _ q, mul_assoc, \u2190 multiset.prod_cons, multiset.cons_erase hq, \u2190 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 \u27e8associated.symm \u27e8u, hu\u27e9, rfl\u27e9,\nend\n\nsection exists_prime_factors\n\nvariables [cancel_comm_monoid_with_zero \u03b1]\nvariables (pf : \u2200 (a : \u03b1), a \u2260 0 \u2192 \u2203 f : multiset \u03b1, (\u2200b \u2208 f, prime b) \u2227 f.prod ~\u1d64 a)\n\ninclude pf\n\nlemma wf_dvd_monoid.of_exists_prime_factors : wf_dvd_monoid \u03b1 :=\n\u27e8begin\n  classical,\n  refine rel_hom_class.well_founded\n    (rel_hom.mk _ _ : (dvd_not_unit : \u03b1 \u2192 \u03b1 \u2192 Prop) \u2192r ((<) : with_top \u2115 \u2192 with_top \u2115 \u2192 Prop))\n    (with_top.well_founded_lt nat.lt_wf),\n  { intro a,\n    by_cases h : a = 0, { exact \u22a4 },\n    exact (classical.some (pf a h)).card },\n\n  rintros a b \u27e8ane0, \u27e8c, hc, b_eq\u27e9\u27e9,\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 \u2260 0, { refine mt (\u03bb 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 (\u03bb 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 \u2190 b_eq,\n      apply (classical.some_spec (pf _ _)).2.symm, } }\nend\u27e9\n\nlemma irreducible_iff_prime_of_exists_prime_factors {p : \u03b1} : irreducible p \u2194 prime p :=\nbegin\n  by_cases hp0 : p = 0,\n  { simp [hp0] },\n  refine \u27e8\u03bb h, _, prime.irreducible\u27e9,\n  obtain \u27e8f, hf\u27e9 := pf p hp0,\n  obtain \u27e8q, hq, rfl\u27e9 := 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 \u03b1 :=\n{ irreducible_iff_prime := \u03bb _, 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 \u03b1] :\n  unique_factorization_monoid \u03b1 \u2194\n    (\u2200 (a : \u03b1), a \u2260 0 \u2192 \u2203 f : multiset \u03b1, (\u2200b \u2208 f, prime b) \u2227 f.prod ~\u1d64 a) :=\n\u27e8\u03bb h, @unique_factorization_monoid.exists_prime_factors _ _ h,\n  unique_factorization_monoid.of_exists_prime_factors\u27e9\n\nsection\nvariables {\u03b2 : Type*} [cancel_comm_monoid_with_zero \u03b1] [cancel_comm_monoid_with_zero \u03b2]\n\nlemma mul_equiv.unique_factorization_monoid (e : \u03b1 \u2243* \u03b2)\n  (h\u03b1 : unique_factorization_monoid \u03b1) : unique_factorization_monoid \u03b2 :=\nbegin\n  rw unique_factorization_monoid.iff_exists_prime_factors at h\u03b1 \u22a2, intros a ha,\n  obtain \u27e8w,hp,u,h\u27e9 := h\u03b1 (e.symm a) (\u03bb h, ha $ by { convert \u2190 map_zero e, simp [\u2190 h] }),\n  exact \u27e8 w.map e,\n    \u03bb b hb, let \u27e8c,hc,he\u27e9 := multiset.mem_map.1 hb in he \u25b8 e.prime_iff.1 (hp c hc),\n    units.map e.to_monoid_hom u,\n    by { erw [multiset.prod_hom, \u2190 e.map_mul, h], simp } \u27e9,\nend\n\nlemma mul_equiv.unique_factorization_monoid_iff (e : \u03b1 \u2243* \u03b2) :\n  unique_factorization_monoid \u03b1 \u2194 unique_factorization_monoid \u03b2 :=\n\u27e8 e.unique_factorization_monoid, e.symm.unique_factorization_monoid \u27e9\n\nend\n\ntheorem irreducible_iff_prime_of_exists_unique_irreducible_factors [cancel_comm_monoid_with_zero \u03b1]\n  (eif : \u2200 (a : \u03b1), a \u2260 0 \u2192 \u2203 f : multiset \u03b1, (\u2200b \u2208 f, irreducible b) \u2227 f.prod ~\u1d64 a)\n  (uif : \u2200 (f g : multiset \u03b1),\n  (\u2200 x \u2208 f, irreducible x) \u2192 (\u2200 x \u2208 g, irreducible x) \u2192 f.prod ~\u1d64 g.prod \u2192\n    multiset.rel associated f g)\n  (p : \u03b1) : irreducible p \u2194 prime p :=\n\u27e8by letI := classical.dec_eq \u03b1; exact \u03bb hpi,\n    \u27e8hpi.ne_zero, hpi.1,\n      \u03bb a b \u27e8x, hx\u27e9,\n      if hab0 : a * b = 0\n      then (eq_zero_or_eq_zero_of_mul_eq_zero hab0).elim\n        (\u03bb ha0, by simp [ha0])\n        (\u03bb hb0, by simp [hb0])\n      else\n        have hx0 : x \u2260 0, from \u03bb hx0, by simp * at *,\n        have ha0 : a \u2260 0, from left_ne_zero_of_mul hab0,\n        have hb0 : b \u2260 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 ::\u2098 fx) (fa + fb),\n          { apply uif,\n            { exact \u03bb i hi, (multiset.mem_cons.1 hi).elim (\u03bb hip, hip.symm \u25b8 hpi) (hfx.1 _), },\n            { exact \u03bb i hi, (multiset.mem_add.1 hi).elim (hfa.1 _) (hfb.1 _), },\n            calc multiset.prod (p ::\u2098 fx)\n                  ~\u1d64 a * b : by rw [hx, multiset.prod_cons];\n                    exact hfx.2.mul_left _\n              ... ~\u1d64 (fa).prod * (fb).prod :\n                hfa.2.symm.mul_mul hfb.2.symm\n              ... = _ : by rw multiset.prod_add, },\n          exact let \u27e8q, hqf, hq\u27e9 := multiset.exists_mem_of_rel_of_mem h\n          (multiset.mem_cons_self p _) in\n        (multiset.mem_add.1 hqf).elim\n          (\u03bb hqa, or.inl $ hq.dvd_iff_dvd_left.2 $\n            hfa.2.dvd_iff_dvd_right.1\n              (multiset.dvd_prod hqa))\n          (\u03bb hqb, or.inr $ hq.dvd_iff_dvd_left.2 $\n            hfb.2.dvd_iff_dvd_right.1\n              (multiset.dvd_prod hqb))\n        end\u27e9, prime.irreducible\u27e9\n\ntheorem unique_factorization_monoid.of_exists_unique_irreducible_factors\n  [cancel_comm_monoid_with_zero \u03b1]\n  (eif : \u2200 (a : \u03b1), a \u2260 0 \u2192 \u2203 f : multiset \u03b1, (\u2200b \u2208 f, irreducible b) \u2227 f.prod ~\u1d64 a)\n  (uif : \u2200 (f g : multiset \u03b1),\n  (\u2200 x \u2208 f, irreducible x) \u2192 (\u2200 x \u2208 g, irreducible x) \u2192 f.prod ~\u1d64 g.prod \u2192\n    multiset.rel associated f g) :\n  unique_factorization_monoid \u03b1 :=\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 \u03b1] [decidable_eq \u03b1]\nvariables [unique_factorization_monoid \u03b1]\n/-- Noncomputably determines the multiset of prime factors. -/\nnoncomputable def factors (a : \u03b1) : multiset \u03b1 := if h : a = 0 then 0 else\nclassical.some (unique_factorization_monoid.exists_prime_factors a h)\n\ntheorem factors_prod {a : \u03b1} (ane0 : a \u2260 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 : \u03b1} : \u2200 (x : \u03b1), x \u2208 factors a \u2192 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 : \u03b1} : \u2200 (x : \u03b1), x \u2208 factors a \u2192 irreducible x :=\n\u03bb x h, (prime_of_factor x h).irreducible\n\nlemma exists_mem_factors_of_dvd {a p : \u03b1} (ha0 : a \u2260 0) (hp : irreducible p) : p \u2223 a \u2192\n  \u2203 q \u2208 factors a, p ~\u1d64 q :=\n\u03bb \u27e8b, hb\u27e9,\nhave hb0 : b \u2260 0, from \u03bb hb0, by simp * at *,\nhave multiset.rel associated (p ::\u2098 factors b) (factors a),\n  from factors_unique\n    (\u03bb x hx, (multiset.mem_cons.1 hx).elim (\u03bb h, h.symm \u25b8 hp) (irreducible_of_factor _))\n    irreducible_of_factor\n    (associated.symm $ calc multiset.prod (factors a) ~\u1d64 a : factors_prod ha0\n      ... = p * b : hb\n      ... ~\u1d64 multiset.prod (p ::\u2098 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 \u03b1] [decidable_eq \u03b1] [normalization_monoid \u03b1]\nvariables [unique_factorization_monoid \u03b1]\n\n/-- Noncomputably determines the multiset of prime factors. -/\nnoncomputable def normalized_factors (a : \u03b1) : multiset \u03b1 :=\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\u02e3)] (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 : \u03b1} (ane0 : a \u2260 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 [\u2190 associates.mk_eq_mk_iff_associated, \u2190 associates.prod_mk, \u2190 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 : \u03b1} : \u2200 (x : \u03b1), x \u2208 normalized_factors a \u2192 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 \u27e8y, \u27e8hy, rfl\u27e9\u27e9,\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 : \u03b1} :\n  \u2200 (x : \u03b1), x \u2208 normalized_factors a \u2192 irreducible x :=\n\u03bb x h, (prime_of_normalized_factor x h).irreducible\n\ntheorem normalize_normalized_factor {a : \u03b1} :\n  \u2200 (x : \u03b1), x \u2208 normalized_factors a \u2192 normalize x = x :=\nbegin\n  rw [normalized_factors, factors],\n  split_ifs with h, { simp },\n  intros x hx,\n  obtain \u27e8y, hy, rfl\u27e9 := multiset.mem_map.1 hx,\n  apply normalize_idem\nend\n\nlemma normalized_factors_irreducible {a : \u03b1} (ha : irreducible a) :\n  normalized_factors a = {normalize a} :=\nbegin\n  obtain \u27e8p, a_assoc, hp\u27e9 := prime_factors_irreducible ha\n    \u27e8prime_of_normalized_factor, normalized_factors_prod ha.ne_zero\u27e9,\n  have p_mem : p \u2208 normalized_factors a,\n  { rw hp, exact multiset.mem_singleton_self _ },\n  convert hp,\n  rwa [\u2190 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 : \u03b1} (ha0 : a \u2260 0) (hp : irreducible p) : p \u2223 a \u2192\n  \u2203 q \u2208 normalized_factors a, p ~\u1d64 q :=\n\u03bb \u27e8b, hb\u27e9,\nhave hb0 : b \u2260 0, from \u03bb hb0, by simp * at *,\nhave multiset.rel associated (p ::\u2098 normalized_factors b) (normalized_factors a),\n  from factors_unique\n    (\u03bb x hx, (multiset.mem_cons.1 hx).elim (\u03bb h, h.symm \u25b8 hp)\n      (irreducible_of_normalized_factor _))\n    irreducible_of_normalized_factor\n    (associated.symm $ calc multiset.prod (normalized_factors a) ~\u1d64 a : normalized_factors_prod ha0\n      ... = p * b : hb\n      ... ~\u1d64 multiset.prod (p ::\u2098 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 : \u03b1) = 0 :=\nby simp [normalized_factors, factors]\n\n@[simp] lemma normalized_factors_one : normalized_factors (1 : \u03b1) = 0 :=\nbegin\n  nontriviality \u03b1 using [normalized_factors, factors],\n  rw \u2190 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 \u03b1 _ _)] },\n  apply_instance\nend\n\n@[simp] lemma normalized_factors_mul {x y : \u03b1} (hx : x \u2260 0) (hy : y \u2260 0) :\n  normalized_factors (x * y) = normalized_factors x + normalized_factors y :=\nbegin\n  have h : (normalize : \u03b1 \u2192 \u03b1) = associates.out \u2218 associates.mk,\n  { ext, rw [function.comp_apply, associates.out_mk], },\n  rw [\u2190 multiset.map_id' (normalized_factors (x * y)), \u2190 multiset.map_id' (normalized_factors x),\n    \u2190 multiset.map_id' (normalized_factors y), \u2190 multiset.map_congr rfl normalize_normalized_factor,\n    \u2190 multiset.map_congr rfl normalize_normalized_factor,\n    \u2190 multiset.map_congr rfl normalize_normalized_factor,\n    \u2190 multiset.map_add, h, \u2190 multiset.map_map associates.out, eq_comm,\n    \u2190 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 : \u03b1} (n : \u2115) :\n  normalized_factors (x ^ n) = n \u2022 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 : \u03b1} (hp : irreducible p) (k : \u2115) :\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 : \u03b1} (hx : x \u2260 0) (hy : y \u2260 0) :\n  x \u2223 y \u2194 normalized_factors x \u2264 normalized_factors y :=\nbegin\n  split,\n  { rintro \u27e8c, rfl\u27e9,\n    simp [hx, right_ne_zero_of_mul hy] },\n  { rw [\u2190 (normalized_factors_prod hx).dvd_iff_dvd_left,\n      \u2190 (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 : \u03b1} (hp : irreducible p) (k : \u2115) :\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 : \u03b1) : (0 : \u03b1) \u2209 normalized_factors x :=\n\u03bb h, prime.ne_zero (prime_of_normalized_factor _ h) rfl\n\nlemma dvd_of_mem_normalized_factors {a p : \u03b1} (H : p \u2208 normalized_factors a) : p \u2223 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 : \u03b1}\n  (h : \u2200 {m}, m \u2208 normalized_factors r \u2192 m = p) (hr : r \u2260 0) : \u2203 (i : \u2115), 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 (\u03bb 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 \u03b1] [nontrivial \u03b1] [unique_factorization_monoid \u03b1]\n\n/-- Noncomputably defines a `normalization_monoid` structure on a `unique_factorization_monoid`. -/\nprotected def normalization_monoid : normalization_monoid \u03b1 :=\nnormalization_monoid_of_monoid_hom_right_inverse\n{ to_fun := \u03bb a : associates \u03b1, if a = 0 then 0 else ((normalized_factors a).map\n    (classical.some mk_surjective.has_right_inverse : associates \u03b1 \u2192 \u03b1)).prod,\n  map_one' := by simp,\n  map_mul' := \u03bb 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 \u2218 (classical.some mk_surjective.has_right_inverse) =\n           (id : associates \u03b1 \u2192 associates \u03b1),\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, \u2190 mk_monoid_hom_apply, monoid_hom.map_multiset_prod, map_map, h, map_id,\n      \u2190 associated_iff_eq],\n  apply normalized_factors_prod hx\nend\n\ninstance : inhabited (normalization_monoid \u03b1) := \u27e8unique_factorization_monoid.normalization_monoid\u27e9\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 \u2260 0)\n  (h : (\u2200 {d}, d \u2223 a \u2192 d \u2223 b \u2192 \u00ac prime d)) : \u2200 {d}, d \u2223 a \u2192 d \u2223 b \u2192 is_unit d :=\n\u03bb d, induction_on_prime d\n  (by { simp only [zero_dvd_iff], intros, contradiction })\n  (\u03bb x hx _ _, hx)\n  (\u03bb 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 \u2223 b * c` and `a` and `c` have no common prime factors, `a \u2223 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 \u2260 0) :\n  (\u2200 {d}, d \u2223 a \u2192 d \u2223 c \u2192 \u00ac prime d) \u2192 a \u2223 b * c \u2192 a \u2223 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 _ \u27e8x, rfl\u27e9 _ 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 (\u03bb 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) (\u03bb h, _),\n    exact no_factors h (dvd_mul_right p c) hp }\nend\n\n/-- Euclid's lemma: if `a \u2223 b * c` and `a` and `b` have no common prime factors, `a \u2223 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 \u2260 0)\n  (no_factors : \u2200 {d}, d \u2223 a \u2192 d \u2223 b \u2192 \u00ac prime d) : a \u2223 b * c \u2192 a \u2223 c :=\nby simpa [mul_comm b c] using dvd_of_dvd_mul_left_of_no_prime_factors ha @no_factors\n\n/-- If `a \u2260 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 : \u2200 (a \u2260 (0 : R)) b,\n  \u2203 a' b' c', (\u2200 {d}, d \u2223 a' \u2192 d \u2223 b' \u2192 is_unit d) \u2227 c' * a' = a \u2227 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 \u2223 b,\n    { rcases h with \u27e8b, rfl\u27e9,\n      obtain \u27e8a', b', c', no_factor, ha', hb'\u27e9 := ih_a a_ne_zero b,\n      refine \u27e8a', b', p * c', @no_factor, _, _\u27e9,\n      { rw [mul_assoc, ha'] },\n      { rw [mul_assoc, hb'] } },\n    { obtain \u27e8a', b', c', coprime, rfl, rfl\u27e9 := ih_a a_ne_zero b,\n      refine \u27e8p * a', b', c', _, mul_left_comm _ _ _, rfl\u27e9,\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 \u2223 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 \u2260 0) :\n  \u2203 a' b' c', (\u2200 {d}, d \u2223 a' \u2192 d \u2223 b' \u2192 is_unit d) \u2227 c' * a' = a \u2227 c' * b' = b :=\nlet \u27e8b', a', c', no_factor, hb, ha\u27e9 := exists_reduced_factors b hb a\nin \u27e8a', b', c', \u03bb _ hpb hpa, no_factor hpa hpb, ha, hb\u27e9\n\nsection multiplicity\nvariables [nontrivial R] [normalization_monoid R] [decidable_eq R]\nvariables [dec_dvd : decidable_rel (has_dvd.dvd : R \u2192 R \u2192 Prop)]\nopen multiplicity multiset\n\ninclude dec_dvd\nlemma le_multiplicity_iff_repeat_le_normalized_factors {a b : R} {n : \u2115}\n  (ha : irreducible a) (hb : b \u2260 0) :\n  \u2191n \u2264 multiplicity a b \u2194 repeat (normalize a) n \u2264 normalized_factors b :=\nbegin\n  rw \u2190 pow_dvd_iff_le_multiplicity,\n  revert b,\n  induction n with n ih, { simp },\n  intros b hb,\n  split,\n  { rintro \u27e8c, rfl\u27e9,\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, \u2190 ih hb.2],\n    apply dvd.intro _ rfl },\n  { rw [multiset.le_iff_exists_add],\n    rintro \u27e8u, hu\u27e9,\n    rw [\u2190 (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 \u2260 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 [\u2190 nat.cast_one, \u2190 nat.cast_add, lt_iff_not_ge, ge_iff_le,\n      le_multiplicity_iff_repeat_le_normalized_factors ha hb, \u2190 le_count_iff_repeat_le],\n    simp },\n  rw [le_multiplicity_iff_repeat_le_normalized_factors ha hb, \u2190 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 : \u2115}\n  (hle : p^n \u2223 x) (hlt : \u00ac (p^(n+1) \u2223 x)) :\n  (normalized_factors x).count p = n :=\nbegin\n  letI : decidable_rel ((\u2223) : R \u2192 R \u2192 Prop) := \u03bb _ _, classical.prop_decidable _,\n  by_cases hx0 : x = 0,\n  { simp [hx0] at hlt, contradiction },\n  rw [\u2190 enat.coe_inj],\n  convert (multiplicity_eq_count_normalized_factors hp hx0).symm,\n  { exact hnorm.symm },\n  exact (multiplicity.eq_coe_iff.mpr \u27e8hle, hlt\u27e9).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 \u03b1]\n\n/-- `factor_set \u03b1` representation elements of unique factorization domain as multisets.\n`multiset \u03b1` produced by `normalized_factors` are only unique up to associated elements, while the\nmultisets in `factor_set \u03b1` are unique by equality and restricted to irreducible elements. This\ngives us a representation of each element as a unique multisets (or the added \u22a4 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 (\u03b1 : Type u) [cancel_comm_monoid_with_zero \u03b1] :\n  Type u :=\nwith_top (multiset { a : associates \u03b1 // irreducible a })\n\nlocal attribute [instance] associated.setoid\n\ntheorem factor_set.coe_add {a b : multiset { a : associates \u03b1 // irreducible a }} :\n  (\u2191(a + b) : factor_set \u03b1) = a + b :=\nby norm_cast\n\nlemma factor_set.sup_add_inf_eq_add [decidable_eq (associates \u03b1)] :\n  \u2200(a b : factor_set \u03b1), a \u2294 b + a \u2293 b = a + b\n| none     b        := show \u22a4 \u2294 b + \u22a4 \u2293 b = \u22a4 + b, by simp\n| a        none     := show a \u2294 \u22a4 + a \u2293 \u22a4 = a + \u22a4, by simp\n| (some a) (some b) := show (a : factor_set \u03b1) \u2294 b + a \u2293 b = a + b, from\n  begin\n    rw [\u2190 with_top.coe_sup, \u2190 with_top.coe_inf, \u2190 with_top.coe_add, \u2190 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 \u03b1 \u2192 associates \u03b1\n| none     := 0\n| (some s) := (s.map coe).prod\n\n@[simp] theorem prod_top : (\u22a4 : factor_set \u03b1).prod = 0 := rfl\n\n@[simp] theorem prod_coe {s : multiset { a : associates \u03b1 // irreducible a }} :\n  (s : factor_set \u03b1).prod = (s.map coe).prod :=\nrfl\n\n@[simp] theorem prod_add : \u2200(a b : factor_set \u03b1), (a + b).prod = a.prod * b.prod\n| none b    := show (\u22a4 + b).prod = (\u22a4:factor_set \u03b1).prod * b.prod, by simp\n| a    none := show (a + \u22a4).prod = a.prod * (\u22a4:factor_set \u03b1).prod, by simp\n| (some a) (some b) :=\n  show (\u2191a + \u2191b:factor_set \u03b1).prod = (\u2191a:factor_set \u03b1).prod * (\u2191b:factor_set \u03b1).prod,\n    by rw [\u2190 factor_set.coe_add, prod_coe, prod_coe, prod_coe, multiset.map_add, multiset.prod_add]\n\ntheorem prod_mono : \u2200{a b : factor_set \u03b1}, a \u2264 b \u2192 a.prod \u2264 b.prod\n| none b h := have b = \u22a4, from top_unique h, by rw [this, prod_top]; exact le_rfl\n| a none h := show a.prod \u2264 (\u22a4 : factor_set \u03b1).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 \u03b1] (p : factor_set \u03b1) :\n  p.prod = 0 \u2194 p = \u22a4 :=\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 \u27e8\u27e8a, ha\u27e9, -, eq\u27e9,\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 \u03b1)] (p : {a : associates \u03b1 // irreducible a}) :\n  factor_set \u03b1 \u2192 \u2115\n| none := 0\n| (some s) := s.count p\n\nvariables [dec_irr : \u03a0 (p : associates \u03b1), 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 \u03b1)] (p : associates \u03b1) :\n  factor_set \u03b1 \u2192 \u2115 :=\nif hp : irreducible p then bcount \u27e8p, hp\u27e9  else 0\n\n@[simp] lemma count_some [decidable_eq (associates \u03b1)] {p : associates \u03b1} (hp : irreducible p)\n  (s : multiset _) : count p (some s) = s.count \u27e8p, hp\u27e9:=\nby { dunfold count, split_ifs, refl }\n\n@[simp] lemma count_zero [decidable_eq (associates \u03b1)] {p : associates \u03b1} (hp : irreducible p) :\n  count p (0 : factor_set \u03b1) = 0 :=\nby { dunfold count, split_ifs, refl }\n\nlemma count_reducible [decidable_eq (associates \u03b1)] {p : associates \u03b1} (hp : \u00ac 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 \u03b1 // irreducible a} \u2192 (factor_set \u03b1) \u2192 Prop\n| _ \u22a4 := true\n| p (some l) := p \u2208 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 \u03b1`.\n\nIf `p` is not irreducible, `p` is not a member of any `factor_set`. -/\ndef factor_set_mem (p : associates \u03b1) (s : factor_set \u03b1) : Prop :=\nif hp : irreducible p then bfactor_set_mem \u27e8p, hp\u27e9 s else false\n\ninstance : has_mem (associates \u03b1) (factor_set \u03b1) := \u27e8factor_set_mem\u27e9\n\n@[simp] lemma factor_set_mem_eq_mem (p : associates \u03b1) (s : factor_set \u03b1) :\n  factor_set_mem p s = (p \u2208 s) := rfl\n\nlemma mem_factor_set_top {p : associates \u03b1} {hp : irreducible p} :\n  p \u2208 (\u22a4 : factor_set \u03b1) :=\nbegin\n  dunfold has_mem.mem, dunfold factor_set_mem, split_ifs, exact trivial\nend\n\nlemma mem_factor_set_some {p : associates \u03b1} {hp : irreducible p}\n   {l : multiset {a : associates \u03b1 // irreducible a }} :\n  p \u2208 (l : factor_set \u03b1) \u2194 subtype.mk p hp \u2208 l :=\nbegin\n  dunfold has_mem.mem, dunfold factor_set_mem, split_ifs, refl\nend\n\nlemma reducible_not_mem_factor_set {p : associates \u03b1} (hp : \u00ac irreducible p)\n  (s : factor_set \u03b1) : \u00ac p \u2208 s :=\n\u03bb (h : if hp : irreducible p then bfactor_set_mem \u27e8p, hp\u27e9 s else false),\n  by rwa [dif_neg hp] at h\n\nomit dec_irr\n\nvariable [unique_factorization_monoid \u03b1]\n\ntheorem unique' {p q : multiset (associates \u03b1)} :\n  (\u2200a\u2208p, irreducible a) \u2192 (\u2200a\u2208q, irreducible a) \u2192 p.prod = q.prod \u2192 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 \u03b1] {p q : factor_set \u03b1} (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, \u2190factor_set.prod_eq_zero_iff, \u2190h, associates.prod_top] },\n  { rw [\u2190factor_set.prod_eq_zero_iff, h, associates.prod_top] },\n  { congr' 1,\n    rw  \u2190multiset.map_eq_map subtype.coe_injective,\n    apply unique' _ _ h;\n    { intros a ha,\n      obtain \u27e8\u27e8a', irred\u27e9, -, rfl\u27e9 := multiset.mem_map.mp ha,\n      rwa [subtype.coe_mk] } },\nend\n\ntheorem prod_le_prod_iff_le [nontrivial \u03b1] {p q : multiset (associates \u03b1)}\n  (hp : \u2200a\u2208p, irreducible a) (hq : \u2200a\u2208q, irreducible a) :\n  p.prod \u2264 q.prod \u2194 p \u2264 q :=\niff.intro\n  begin\n    classical,\n    rintros \u27e8c, eqc\u27e9,\n    refine multiset.le_iff_exists_add.2 \u27e8factors c, unique' hq (\u03bb x hx, _) _\u27e9,\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 (\u03bb hc, _)).symm,\n      refine not_irreducible_zero (hq _ _),\n      rw [\u2190prod_eq_zero_iff, eqc, hc, mul_zero] }\n  end\n  prod_le_prod\n\nvariables [dec : decidable_eq \u03b1] [dec' : decidable_eq (associates \u03b1)]\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 : \u03b1) :\n  multiset { a : associates \u03b1 // irreducible a } :=\n(factors a).pmap (\u03bba ha, \u27e8associates.mk a, (irreducible_mk _).2 ha\u27e9)\n  (irreducible_of_factor)\n\n@[simp] theorem map_subtype_coe_factors' {a : \u03b1} :\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 : \u03b1} (h : a ~\u1d64 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 \u2260 0,\n  { contrapose! hb with ha,\n    rw [\u2190associated_zero_iff_eq_zero, \u2190ha],\n    exact h.symm },\n  rw [\u2190multiset.map_eq_map subtype.coe_injective, map_subtype_coe_factors',\n    map_subtype_coe_factors', \u2190rel_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 \u03b1) :\n  factor_set \u03b1 :=\nbegin\n  refine (if h : a = 0 then \u22a4 else\n    quotient.hrec_on a (\u03bbx h, some $ factors' x) _ h),\n  assume a b hab,\n  apply function.hfunext,\n  { have : a ~\u1d64 0 \u2194 b ~\u1d64 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 \u03b1).factors = \u22a4 :=\ndif_pos rfl\n\n@[simp] theorem factors_mk (a : \u03b1) (h : a \u2260 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 \u03b1) : 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 \u2260 0,\n    have a \u2260 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 \u03b1] (s : factor_set \u03b1) : s.prod.factors = s :=\nfactor_set.unique $ factors_prod _\n\n@[nontriviality] lemma factors_subsingleton [subsingleton \u03b1] {a : associates \u03b1} :\n  a.factors = option.none :=\nby { convert factors_0; apply_instance }\n\nlemma factors_eq_none_iff_zero {a : associates \u03b1} :\n  a.factors = option.none \u2194 a = 0 :=\nbegin\n  nontriviality \u03b1,\n  exact \u27e8\u03bb h, by rwa [\u2190 factors_prod a, factor_set.prod_eq_zero_iff], \u03bb h, h.symm \u25b8 factors_0\u27e9\nend\n\nlemma factors_eq_some_iff_ne_zero {a : associates \u03b1} :\n  (\u2203 (s : multiset {p : associates \u03b1 // irreducible p}), a.factors = some s) \u2194 a \u2260 0 :=\nby rw [\u2190 option.is_some_iff_exists, \u2190 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 \u03b1} (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 \u03b1] {a b : factor_set \u03b1} (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 \u03b1} (ha : a \u2260 0) (hb : b \u2260 0)\n  (h : \u2200 (p : associates \u03b1) (hp : irreducible p), p.count a.factors = p.count b.factors) :\n  a.factors = b.factors :=\nbegin\n  obtain \u27e8sa, h_sa\u27e9 := factors_eq_some_iff_ne_zero.mpr ha,\n  obtain \u27e8sb, h_sb\u27e9 := factors_eq_some_iff_ne_zero.mpr hb,\n  rw [h_sa, h_sb] at h \u22a2,\n  rw option.some_inj,\n  have h_count : \u2200 (p : associates \u03b1) (hp : irreducible p), sa.count \u27e8p, hp\u27e9 = sb.count \u27e8p, hp\u27e9,\n  { intros p hp, rw [\u2190 count_some, \u2190 count_some, h p hp] },\n  apply multiset.to_finsupp.injective,\n  ext \u27e8p, hp\u27e9,\n  rw [multiset.to_finsupp_apply, multiset.to_finsupp_apply, h_count p hp]\nend\n\ntheorem eq_of_eq_counts {a b : associates \u03b1} (ha : a \u2260 0) (hb  : b \u2260 0)\n  (h : \u2200 (p : associates \u03b1), irreducible p \u2192 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 \u03b1} (hb : b \u2260 0)\n  (hp : irreducible p) (h : a.factors \u2264 b.factors) : p.count a.factors \u2264 p.count b.factors :=\nbegin\n  by_cases ha : a = 0,\n  { simp [*] at *, },\n  obtain \u27e8sa, h_sa\u27e9 := factors_eq_some_iff_ne_zero.mpr ha,\n  obtain \u27e8sb, h_sb\u27e9 := factors_eq_some_iff_ne_zero.mpr hb,\n  rw [h_sa, h_sb] at h \u22a2,\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 \u03b1) :\n  (a * b).factors = a.factors + b.factors :=\nbegin\n  casesI subsingleton_or_nontrivial \u03b1,\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 : \u2200{a b : associates \u03b1}, a \u2264 b \u2192 a.factors \u2264 b.factors\n| s t \u27e8d, rfl\u27e9 := by rw [factors_mul] ; exact le_add_of_nonneg_right bot_le\n\ntheorem factors_le {a b : associates \u03b1} : a.factors \u2264 b.factors \u2194 a \u2264 b :=\niff.intro\n  (assume h, have a.factors.prod \u2264 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 \u03b1} (hb : b \u2260 0)\n  (hp : irreducible p) (h : a \u2264 b) : p.count a.factors \u2264 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 \u03b1] {a b : factor_set \u03b1} : a.prod \u2264 b.prod \u2194 a \u2264 b :=\nbegin\n  classical,\n  exact iff.intro\n  (assume h, have a.prod.factors \u2264 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 \u03b1) := \u27e8\u03bba b, (a.factors \u2294 b.factors).prod\u27e9\nnoncomputable instance : has_inf (associates \u03b1) := \u27e8\u03bba b, (a.factors \u2293 b.factors).prod\u27e9\n\nnoncomputable instance : lattice (associates \u03b1) :=\n{ sup          := (\u2294),\n  inf          := (\u2293),\n  sup_le       :=\n    assume a b c hac hbc, factors_prod c \u25b8 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 \u25b8 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 \u03b1) : (a \u2294 b) * (a \u2293 b) = a * b :=\nshow (a.factors \u2294 b.factors).prod * (a.factors \u2293 b.factors).prod = a * b,\nbegin\n  nontriviality \u03b1,\n  refine eq_of_factors_eq_factors _,\n  rw [\u2190 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 \u03b1} {hp : irreducible p}\n  (hm : p \u2208 factors a) : p \u2223 a :=\nbegin\n  by_cases ha0 : a = 0, { rw ha0, exact dvd_zero p },\n  obtain \u27e8a0, nza, ha'\u27e9 := exists_non_zero_rep ha0,\n  rw [\u2190 associates.factors_prod a],\n  rw [\u2190 ha', factors_mk a0 nza] at hm \u22a2,\n  erw prod_coe,\n  apply multiset.dvd_prod, apply multiset.mem_map.mpr,\n  exact \u27e8\u27e8p, hp\u27e9, mem_factor_set_some.mp hm, rfl\u27e9\nend\n\nomit dec'\n\nlemma dvd_of_mem_factors' {a : \u03b1} {p : associates \u03b1} {hp : irreducible p} {hz : a \u2260 0}\n  (h_mem : subtype.mk p hp \u2208 factors' a) : p \u2223 associates.mk a :=\nby { haveI := classical.dec_eq (associates \u03b1),\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 : \u03b1} (ha0 : a \u2260 0) (hp : irreducible p) (hd : p \u2223 a) :\n  subtype.mk (associates.mk p) ((irreducible_mk _).2 hp) \u2208 factors' a :=\nbegin\n  obtain \u27e8q, hq, hpq\u27e9 := 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 : \u03b1} (ha0 : a \u2260 0) (hp : irreducible p) :\n  subtype.mk (associates.mk p) ((irreducible_mk _).2 hp) \u2208 factors' a \u2194 p \u2223 a :=\nbegin\n  split,\n  { rw \u2190 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 : \u03b1} (ha0 : a \u2260 0) (hp : irreducible p) (hd : p \u2223 a) :\n  (associates.mk p) \u2208 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 : \u03b1} (ha0 : a \u2260 0) (hp : irreducible p) :\n  (associates.mk p) \u2208 factors (associates.mk a) \u2194 p \u2223 a :=\nbegin\n  split,\n  { rw \u2190 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 : \u03b1}\n  (ha : a \u2260 0) (hb : b \u2260 0) (h : (associates.mk a) \u2293 (associates.mk b) \u2260 1)  :\n  \u2203 (p : \u03b1), prime p \u2227 p \u2223 a \u2227 p \u2223 b :=\nbegin\n  have hz : (factors (associates.mk a)) \u2293 (factors (associates.mk b)) \u2260 0,\n  { contrapose! h with hf,\n    change ((factors (associates.mk a)) \u2293 (factors (associates.mk b))).prod = 1,\n    rw hf,\n    exact multiset.prod_zero },\n  rw [factors_mk a ha, factors_mk b hb, \u2190 with_top.coe_inf] at hz,\n  obtain \u27e8\u27e8p0, p0_irr\u27e9, p0_mem\u27e9 := 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 \u27e8p, rfl\u27e9 : \u2203 p, associates.mk p = p0 := quot.exists_rep p0,\n  refine \u27e8p, _, _, _\u27e9,\n  { rw [\u2190 irreducible_iff_prime, \u2190 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 : \u03b1} (ha0 : a \u2260 0) (hb0 : b \u2260 0) :\n  (associates.mk a) \u2293 (associates.mk b) = 1 \u2194 \u2200 {d : \u03b1}, d \u2223 a \u2192 d \u2223 b \u2192 \u00ac 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 \u2190 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 \u27e8p, hp, hpa, hpb\u27e9 := 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 \u03b1] {p : associates \u03b1}  (hp : irreducible p) :\n  p.factors = some ({\u27e8p, hp\u27e9}) :=\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 \u03b1] {p : associates \u03b1} (hp : irreducible p)\n  (k : \u2115) : factors (p ^ k) = some (multiset.repeat \u27e8p, hp\u27e9 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 \u03b1] {m p : associates \u03b1} (h\u2081 : m \u2260 0)\n  (h\u2082 : irreducible p) {k : \u2115} : p ^ k \u2264 m \u2194 k \u2264 count p m.factors :=\nbegin\n  obtain \u27e8a, nz, rfl\u27e9 := associates.exists_non_zero_rep h\u2081,\n  rw [factors_mk _ nz, \u2190 with_top.some_eq_coe, count_some, multiset.le_count_iff_repeat_le,\n      \u2190 factors_le, factors_prime_pow h\u2082, factors_mk _ nz],\n  exact with_top.coe_le_coe\nend\n\ntheorem le_of_count_ne_zero {m p : associates \u03b1} (h0 : m \u2260 0)\n  (hp : irreducible p) : count p m.factors \u2260 0 \u2192 p \u2264 m :=\nbegin\n  nontriviality \u03b1,\n  rw [\u2190 pos_iff_ne_zero],\n  intro h,\n  rw [\u2190 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 : \u03b1} (ha0 : a \u2260 0) (hp : irreducible p) :\n  (associates.mk p).count (associates.mk a).factors \u2260 0 \u2194 p \u2223 a :=\nbegin\n  nontriviality \u03b1,\n  rw \u2190 associates.mk_le_mk_iff_dvd_iff,\n  refine \u27e8\u03bb h, associates.le_of_count_ne_zero (associates.mk_ne_zero.mpr ha0)\n    ((associates.irreducible_mk p).mpr hp) h, \u03bb h, _\u27e9,\n  { rw [\u2190 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 \u03b1] {p : associates \u03b1} (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 \u03b1} (hp : irreducible p) (hq : irreducible q)\n  (h : p \u2260 q) : p.count q.factors = 0 :=\nnot_ne_iff.mp $ \u03bb h', h $ associated_iff_eq.mp $ hp.associated_of_dvd hq $\nby { nontriviality \u03b1, exact le_of_count_ne_zero hq.ne_zero hp h' }\n\ntheorem count_mul {a : associates \u03b1} (ha : a \u2260 0) {b : associates \u03b1} (hb : b \u2260 0)\n  {p : associates \u03b1} (hp : irreducible p) :\n  count p (factors (a * b)) = count p a.factors + count p b.factors :=\nbegin\n  obtain \u27e8a0, nza, ha'\u27e9 := exists_non_zero_rep ha,\n  obtain \u27e8b0, nzb, hb'\u27e9 := exists_non_zero_rep hb,\n  rw [factors_mul, \u2190 ha', \u2190 hb', factors_mk a0 nza, factors_mk b0 nzb, \u2190 factor_set.coe_add,\n      \u2190 with_top.some_eq_coe, \u2190 with_top.some_eq_coe, \u2190 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 \u03b1} (ha : a \u2260 0) {b : associates \u03b1}\n  (hb : b \u2260 0)\n  (hab : \u2200 d, d \u2223 a \u2192 d \u2223 b \u2192 \u00ac prime d) {p : associates \u03b1} (hp : irreducible p) :\n  count p a.factors = 0 \u2228 count p b.factors = 0 :=\nbegin\n  rw [or_iff_not_imp_left, \u2190 ne.def],\n  intro hca,\n  contrapose! hab with hcb,\n  exact \u27e8p, le_of_count_ne_zero ha hp hca, le_of_count_ne_zero hb hp hcb,\n    (irreducible_iff_prime.mp hp)\u27e9,\nend\n\ntheorem count_mul_of_coprime {a : associates \u03b1} {b : associates \u03b1}\n  (hb : b \u2260 0)\n  {p : associates \u03b1} (hp : irreducible p) (hab : \u2200 d, d \u2223 a \u2192 d \u2223 b \u2192 \u00ac prime d) :\n  count p a.factors = 0 \u2228 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 \u03b1}\n  {p : associates \u03b1} (hp : irreducible p) (hab : \u2200 d, d \u2223 a \u2192 d \u2223 b \u2192 \u00ac prime d) :\n  count p (a * b).factors = count p a.factors\n  \u2228 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 \u03b1} (hb : b \u2260 0)\n  {p : associates \u03b1} (hp : irreducible p) (hab : \u2200 d, d \u2223 a \u2192 d \u2223 b \u2192 \u00ac prime d)\n  {k : \u2115} (habk : k \u2223 count p (a * b).factors) : k \u2223 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 \u03b1] : factors (1 : associates \u03b1) = 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 \u03b1] {a : associates \u03b1} {k : \u2115} :\n  (a ^ k).factors = k \u2022 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 \u03b1] {a : associates \u03b1} (ha : a \u2260 0) {p : associates \u03b1}\n  (hp : irreducible p)\n  (k : \u2115) : 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 \u03b1] {a : associates \u03b1} (ha : a \u2260 0) {p : associates \u03b1}\n  (hp : irreducible p)\n  (k : \u2115) : k \u2223 count p (a ^ k).factors := by { rw count_pow ha hp, apply dvd_mul_right }\n\ntheorem is_pow_of_dvd_count [nontrivial \u03b1] {a : associates \u03b1} (ha : a \u2260 0) {k : \u2115}\n  (hk : \u2200 (p : associates \u03b1) (hp : irreducible p), k \u2223 count p a.factors) :\n  \u2203 (b : associates \u03b1), a = b ^ k :=\nbegin\n  obtain \u27e8a0, hz, rfl\u27e9 := exists_non_zero_rep ha,\n  rw [factors_mk a0 hz] at hk,\n  have hk' : \u2200 p, p \u2208 (factors' a0) \u2192 k \u2223 (factors' a0).count p,\n  { rintros p -,\n    have pp : p = \u27e8p.val, p.2\u27e9, { simp only [subtype.coe_eta, subtype.val_eq_coe] },\n    rw [pp, \u2190 count_some p.2], exact hk p.val p.2 },\n  obtain \u27e8u, hu\u27e9 := multiset.exists_smul_of_dvd_count _ hk',\n  use (u : factor_set \u03b1).prod,\n  apply eq_of_factors_eq_factors,\n  rw [pow_factors, prod_factors, factors_mk a0 hz, \u2190 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 \u03b1} (hp : irreducible p)\n  {n : \u2115} (h : a \u2223 p ^ n) : a = p ^ p.count a.factors :=\nbegin\n  nontriviality \u03b1,\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 : \u2200 (q : associates \u03b1), irreducible q \u2192 q \u2260 p \u2192 _ = 0 :=\n  \u03bb 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 \u03b1} (hp : irreducible p)\n  [\u2200 n : \u2115, decidable (a \u2223 p ^ n)] {n : \u2115} (h : a \u2223 p ^ n) : nat.find \u27e8n, h\u27e9 = p.count a.factors :=\nbegin\n  apply le_antisymm,\n  { refine nat.find_le \u27e81, _\u27e9, rw mul_one, symmetry, exact eq_pow_count_factors_of_dvd_pow hp h },\n  { have hph := pow_ne_zero (nat.find \u27e8n, h\u27e9) hp.ne_zero,\n    casesI (subsingleton_or_nontrivial \u03b1) with h\u03b1 h\u03b1,\n    { simpa using hph, },\n    convert count_le_count_of_le hph hp (nat.find_spec \u27e8n, h\u27e9),\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 \u03b1] {a b c : associates \u03b1} (ha : a \u2260 0) (hb : b \u2260 0)\n  (hab : \u2200 d, d \u2223 a \u2192 d \u2223 b \u2192 \u00ac prime d) {k : \u2115} (h : a * b = c ^ k) :\n  \u2203 (d : associates \u03b1), a = d ^ k :=\nbegin\n  classical,\n  by_cases hk0 : k = 0,\n  { use 1,\n    rw [hk0, pow_zero] at h \u22a2,\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 \u03b1} (hp : irreducible p)\n  [\u2200 n : \u2115, decidable (a \u2223 p ^ n)] {n : \u2115} (h : a \u2223 p ^ n) : a = p ^ nat.find \u27e8n, h\u27e9 :=\nby { classical, rw [count_factors_eq_find_of_dvd_pow hp, \u2190 eq_pow_count_factors_of_dvd_pow hp h] }\n\nend associates\n\nsection\nopen associates unique_factorization_monoid\n\nlemma associates.quot_out {\u03b1 : Type*} [comm_monoid \u03b1] (a : associates \u03b1):\nassociates.mk (quot.out (a)) = a :=\nby rw [\u2190quot_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  (\u03b1 : Type*) [cancel_comm_monoid_with_zero \u03b1] [unique_factorization_monoid \u03b1]\n  [decidable_eq (associates \u03b1)] [decidable_eq \u03b1] : gcd_monoid \u03b1 :=\n{ gcd := \u03bba b, quot.out (associates.mk a \u2293 associates.mk b : associates \u03b1),\n  lcm := \u03bba b, quot.out (associates.mk a \u2294 associates.mk b : associates \u03b1),\n  gcd_dvd_left := \u03bb a b, by\n  { rw [\u2190mk_dvd_mk, (associates.mk a \u2293 associates.mk b).quot_out, dvd_eq_le],\n    exact inf_le_left },\n  gcd_dvd_right := \u03bb a b, by\n  { rw [\u2190mk_dvd_mk, (associates.mk a \u2293 associates.mk b).quot_out, dvd_eq_le],\n    exact inf_le_right },\n  dvd_gcd := \u03bb a b c hac hab, by\n  { rw [\u2190mk_dvd_mk, (associates.mk c \u2293 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 \u27e8hac, hab\u27e9 },\n  lcm_zero_left := \u03bb a, by\n  { have : associates.mk (0 : \u03b1) = \u22a4 := rfl,\n    rw [this, top_sup_eq, \u2190this, \u2190associated_zero_iff_eq_zero, \u2190mk_eq_mk_iff_associated,\n      \u2190associated_iff_eq, associates.quot_out] },\n  lcm_zero_right := \u03bb a, by\n  { have : associates.mk (0 : \u03b1) = \u22a4 := rfl,\n    rw [this, sup_top_eq, \u2190this, \u2190associated_zero_iff_eq_zero, \u2190mk_eq_mk_iff_associated,\n      \u2190associated_iff_eq, associates.quot_out] },\n  gcd_mul_lcm := \u03bb a b, by\n  { rw [\u2190mk_eq_mk_iff_associated, \u2190associates.mk_mul_mk, \u2190associated_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  (\u03b1 : Type*) [cancel_comm_monoid_with_zero \u03b1] [unique_factorization_monoid \u03b1]\n  [normalization_monoid \u03b1] [decidable_eq (associates \u03b1)] [decidable_eq \u03b1] :\n  normalized_gcd_monoid \u03b1 :=\n{ gcd := \u03bba b, (associates.mk a \u2293 associates.mk b).out,\n  lcm := \u03bba b, (associates.mk a \u2294 associates.mk b).out,\n  gcd_dvd_left := assume a b, (out_dvd_iff a (associates.mk a \u2293 associates.mk b)).2 $ inf_le_left,\n  gcd_dvd_right := assume a b, (out_dvd_iff b (associates.mk a \u2293 associates.mk b)).2 $ inf_le_right,\n  dvd_gcd := assume a b c hac hab, show a \u2223 (associates.mk c \u2293 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 \u27e8hac, hab\u27e9,\n  lcm_zero_left := assume a, show (\u22a4 \u2294 associates.mk a).out = 0, by simp,\n  lcm_zero_right := assume a, show (associates.mk a \u2294 \u22a4).out = 0, by simp,\n  gcd_mul_lcm := assume a b, by\n  { rw [\u2190 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  .. \u2039normalization_monoid \u03b1\u203a }\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. `\u2124`, `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\u02e3]\n  (y : M) (hy : y \u2260 0) :\n  fintype {x // x \u2223 y} :=\nbegin\n  haveI : nontrivial M := \u27e8\u27e8y, 0, hy\u27e9\u27e9,\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 `\u03bb (u : M\u02e3) (f \u2286 factors y) \u2192 u * \u03a0 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\u02e3)).image\n      (\u03bb s, (s.snd : M) * s.fst.prod))\n    (\u03bb 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 \u27e8s, hs, rfl\u27e9,\n    have prod_s_ne : s.fst.prod \u2260 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 \u2190 (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 \u2223 y,\n    rw [(unit_associated_one.mul_right s.fst.prod).dvd_iff_dvd_left, one_mul,\n        \u2190 (normalized_factors_prod hy).dvd_iff_dvd_right],\n    exact multiset.prod_dvd_prod_of_le hs },\n  { rintro (h : x \u2223 y),\n    have hx : x \u2260 0, { refine mt (\u03bb hx, _) hy, rwa [hx, zero_dvd_iff] at h },\n    obtain \u27e8u, hu\u27e9 := normalized_factors_prod hx,\n    refine \u27e8\u27e8normalized_factors x, u\u27e9, _, (mul_comm _ _).trans hu\u27e9,\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 \u03b1] [unique_factorization_monoid \u03b1]\nvariables [normalization_monoid \u03b1] [decidable_eq \u03b1]\n\nopen unique_factorization_monoid\n\n/-- This returns the multiset of irreducible factors as a `finsupp` -/\nnoncomputable def factorization (n : \u03b1) : \u03b1 \u2192\u2080 \u2115 := (normalized_factors n).to_finsupp\n\nlemma factorization_eq_count {n p : \u03b1} :\n  factorization n p = multiset.count p (normalized_factors n) :=\nby simp [factorization]\n\n@[simp] lemma factorization_zero : factorization (0 : \u03b1) = 0 := by simp [factorization]\n\n@[simp] lemma factorization_one : factorization (1 : \u03b1) = 0 := by simp [factorization]\n\n/-- The support of `factorization n` is exactly the finset of normalized factors -/\n@[simp] lemma support_factorization {n : \u03b1} :\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 : \u03b1} (ha : a \u2260 0) (hb : b \u2260 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 : \u03b1} {n : \u2115} :\n  factorization (x^n) = n \u2022 factorization x :=\nby { ext, simp [factorization] }\n\nlemma associated_of_factorization_eq (a b: \u03b1) (ha: a \u2260 0) (hb: b \u2260 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 : \u2115 \u2192 Prop) (a b : \u2115)\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 `\u211d\u208a` for positive real numbers `{c : \u211d // 0 < c}`.\n-/\n\nsection real\n\n@[reducible] def posreal := {c : \u211d // 0 < c}\nnotation `\u211d\u208a` := posreal\nnamespace posreal\ninstance coe_nnreal : has_coe \u211d\u208a nnreal := \u27e8\u03bb c, \u27e8c.val, le_of_lt c.property\u27e9\u27e9\nlemma ne_zero (c : \u211d\u208a) : (c:\u211d) \u2260 0 := by { rw \u2190subtype.val_eq_coe, exact ne_of_gt c.property }\nend posreal\n\nlemma real.max_mul_nonneg_zero (c x : \u211d) (hc : 0 \u2264 c) : max (c * x) 0 = c * (max x 0) :=\n  if hx : 0 \u2264 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 \u27e8hc, hx\u27e9)), 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 {\u03b1 : Type*} [decidable_eq \u03b1]\nvariables {R : Type*} [decidable_eq R] [semiring R] [no_zero_smul_divisors R R]\nvariables {f g : \u03b1 \u2192\u2080 R}\n\n@[reducible] def sum_image (f : \u03b1 \u2192\u2080 R) := f.support.sum f\nlemma extend_support_sum_iamge {s : finset \u03b1}\n  (s_extend_supp : f.support \u2286 s) : s.sum f = f.sum_image := by {\n  rw \u2190sum_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 \u222a g.support,\n  have : (f + g).support \u2286 s, from support_add           , rw \u2190extend_support_sum_iamge this,\n  have :  f     .support \u2286 s, from subset_union_left  _ _, rw \u2190extend_support_sum_iamge this,\n  have :      g .support \u2286 s, from subset_union_right _ _, rw \u2190extend_support_sum_iamge this,\n  exact finset.sum_add_distrib, }\nlemma sum_image_smul {c : R} : (c \u2022 f).sum_image = c \u2022 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 \u2022 f).support = f.support, from support_smul_eq hc, rw this,\n    simp [finset.smul_sum], }\n--\n\nlemma support_add_exact {supp : finset \u03b1}\n  (non_zero_on_supp   : \u2200 x \u2208 supp                           , f x + g x \u2260 0)\n  (zero_on_sdiff_supp : \u2200 x \u2208 (f.support \u222a 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 \u2208 (f.support \u222a 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 \u27e8hx_union, hx_supp\u27e9), }\n    else by {\n      have : (f + g).support \u2286 (f.support \u222a 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 \u03b1}\n  (supp_is_supp : f.support = supp)\n  (non_zero_smul : c \u2260 0) :\n  (c \u2022 f).support = supp := by {\n  rw \u2190supp_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 {\u03b1 : Type _}\n\nopen Function\n\nsection LinearOrderedSemifield\n\nvariable [LinearOrderedSemifield \u03b1] {a b c d e : \u03b1} {m n : \u2124}\n\n/-! ### Integer powers -/\n\n\n#print zpow_le_of_le /-\ntheorem zpow_le_of_le (ha : 1 \u2264 a) (h : m \u2264 n) : a ^ m \u2264 a ^ n :=\n  by\n  have ha\u2080 : 0 < a := one_pos.trans_le ha\n  lift n - m to \u2115 using sub_nonneg.2 h with k hk\n  calc\n    a ^ m = a ^ m * 1 := (mul_one _).symm\n    _ \u2264 a ^ m * a ^ k :=\n      (mul_le_mul_of_nonneg_left (one_le_pow_of_one_le ha _) (zpow_nonneg ha\u2080.le _))\n    _ = a ^ n := by rw [\u2190 zpow_ofNat, \u2190 zpow_add\u2080 ha\u2080.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 \u2264 a) (hn : n \u2264 0) : a ^ n \u2264 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 \u2264 a) (hn : 0 \u2264 n) : 1 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {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} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) a) n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) a) -> (forall (n : Int), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))) a) n))\nCase conversion may be inaccurate. Consider using '#align nat.zpow_pos_of_pos Nat.zpow_pos_of_pos\u2093'. -/\nprotected theorem Nat.zpow_pos_of_pos {a : \u2115} (h : 0 < a) (n : \u2124) : 0 < (a : \u03b1) ^ 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {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} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) a) n) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : Nat}, (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) a) -> (forall (n : Int), Ne.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))) a) n) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align nat.zpow_ne_zero_of_pos Nat.zpow_ne_zero_of_pos\u2093'. -/\ntheorem Nat.zpow_ne_zero_of_pos {a : \u2115} (h : 0 < a) (n : \u2124) : (a : \u03b1) ^ n \u2260 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) : \u2200 n : \u2124, 0 < n \u2192 1 < a ^ n\n  | (n : \u2115), 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 ((\u00b7 ^ \u00b7) a : \u2124 \u2192 \u03b1) :=\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\u2080 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))))))) -> (StrictAnti.{0, u1} Int \u03b1 (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} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) -> (StrictAnti.{0, u1} Int \u03b1 (PartialOrder.toPreorder.{0} Int (StrictOrderedRing.toPartialOrder.{0} Int (LinearOrderedRing.toStrictOrderedRing.{0} Int (LinearOrderedCommRing.toLinearOrderedRing.{0} Int Int.linearOrderedCommRing)))) (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) ((fun (x._@.Mathlib.Algebra.Order.Field.Power._hyg.671 : \u03b1) (x._@.Mathlib.Algebra.Order.Field.Power._hyg.673 : Int) => HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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\u2093'. -/\ntheorem zpow_strictAnti (h\u2080 : 0 < a) (h\u2081 : a < 1) : StrictAnti ((\u00b7 ^ \u00b7) a : \u2124 \u2192 \u03b1) :=\n  strictAnti_int_of_succ_lt fun n =>\n    calc\n      a ^ (n + 1) = a ^ n * a := zpow_add_one\u2080 h\u2080.ne' _\n      _ < a ^ n * 1 := ((mul_lt_mul_left <| zpow_pos_of_pos h\u2080 _).2 h\u2081)\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 \u2194 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 \u2264 a ^ n \u2194 m \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) b) -> (forall (k : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) b k)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (forall (k : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) b k)) a)\nCase conversion may be inaccurate. Consider using '#align div_pow_le div_pow_le\u2093'. -/\n@[simp]\ntheorem div_pow_le (ha : 0 \u2264 a) (hb : 1 \u2264 b) (k : \u2115) : a / b ^ k \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) a) -> (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))))))) -> (Function.Injective.{1, succ u1} Int \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) -> (Function.Injective.{1, succ u1} Int \u03b1 ((fun (x._@.Mathlib.Algebra.Order.Field.Power._hyg.925 : \u03b1) (x._@.Mathlib.Algebra.Order.Field.Power._hyg.927 : Int) => HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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\u2093'. -/\ntheorem zpow_injective (h\u2080 : 0 < a) (h\u2081 : a \u2260 1) : Injective ((\u00b7 ^ \u00b7) a : \u2124 \u2192 \u03b1) :=\n  by\n  rcases h\u2081.lt_or_lt with (H | H)\n  \u00b7 exact (zpow_strictAnti h\u2080 H).Injective\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {m : Int} {n : Int}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) a) -> (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))))))) -> (Iff (Eq.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a m) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a n)) (Eq.{1} Int m n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {m : Int} {n : Int}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) -> (Iff (Eq.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a m) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a n)) (Eq.{1} Int m n))\nCase conversion may be inaccurate. Consider using '#align zpow_inj zpow_inj\u2093'. -/\n@[simp]\ntheorem zpow_inj (h\u2080 : 0 < a) (h\u2081 : a \u2260 1) : a ^ m = a ^ n \u2194 m = n :=\n  (zpow_injective h\u2080 h\u2081).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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {x : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg c)) (LinearOrder.max.{u1} \u03b1 (LinearOrderedAddCommMonoid.toLinearOrder.{u1} \u03b1 (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg a)) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg b)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {x : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt c)) (Max.max.{u1} \u03b1 (LinearOrderedCommSemiring.toMax.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt a)) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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\u2093'. -/\ntheorem zpow_le_max_of_min_le {x : \u03b1} (hx : 1 \u2264 x) {a b c : \u2124} (h : min a b \u2264 c) :\n    x ^ (-c) \u2264 max (x ^ (-a)) (x ^ (-b)) :=\n  haveI : Antitone fun n : \u2124 => 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {x : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) x) -> (forall {a : Int} {b : Int} {c : Int}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg c)) (LinearOrder.max.{u1} \u03b1 (LinearOrderedAddCommMonoid.toLinearOrder.{u1} \u03b1 (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.hasNeg a)) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {x : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x) -> (forall {a : Int} {b : Int} {c : Int}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt c)) (Max.max.{u1} \u03b1 (LinearOrderedCommSemiring.toMax.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) x (Neg.neg.{0} Int Int.instNegInt a)) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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\u2093'. -/\ntheorem zpow_le_max_iff_min_le {x : \u03b1} (hx : 1 < x) {a b c : \u2124} :\n    x ^ (-c) \u2264 max (x ^ (-a)) (x ^ (-b)) \u2194 min a b \u2264 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 \u03b1] {a b c d : \u03b1} {n : \u2124}\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1) (n : Int), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit0.{0} Int Int.hasAdd n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1) (n : Int), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit0.{0} Int Int.instAddInt n))\nCase conversion may be inaccurate. Consider using '#align zpow_bit0_nonneg zpow_bit0_nonneg\u2093'. -/\ntheorem zpow_bit0_nonneg (a : \u03b1) (n : \u2124) : 0 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)))\nCase conversion may be inaccurate. Consider using '#align zpow_two_nonneg zpow_two_nonneg\u2093'. -/\ntheorem zpow_two_nonneg (a : \u03b1) : 0 \u2264 a ^ (2 : \u2124) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _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\u2093'. -/\ntheorem zpow_neg_two_nonneg (a : \u03b1) : 0 \u2264 a ^ (-2 : \u2124) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) -> (forall (n : Int), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit0.{0} Int Int.hasAdd n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (forall (n : Int), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit0.{0} Int Int.instAddInt n)))\nCase conversion may be inaccurate. Consider using '#align zpow_bit0_pos zpow_bit0_pos\u2093'. -/\ntheorem zpow_bit0_pos (h : a \u2260 0) (n : \u2124) : 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _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\u2093'. -/\ntheorem zpow_two_pos_of_ne_zero (h : a \u2260 0) : 0 < a ^ (2 : \u2124) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {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} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit0.{0} Int Int.hasAdd n))) (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit0.{0} Int Int.instAddInt n))) (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align zpow_bit0_pos_iff zpow_bit0_pos_iff\u2093'. -/\n@[simp]\ntheorem zpow_bit0_pos_iff (hn : n \u2260 0) : 0 < a ^ bit0 n \u2194 a \u2260 0 :=\n  \u27e8by\n    rintro h rfl\n    refine' (zero_zpow _ _).not_gt h\n    rwa [bit0_ne_zero], fun h => zpow_bit0_pos h _\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit1.{0} Int Int.hasOne Int.hasAdd n)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit1.{0} Int (NonAssocRing.toOne.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)) Int.instAddInt n)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align zpow_bit1_neg_iff zpow_bit1_neg_iff\u2093'. -/\n@[simp]\ntheorem zpow_bit1_neg_iff : a ^ bit1 n < 0 \u2194 a < 0 :=\n  \u27e8fun h => not_le.1 fun h' => not_le.2 h <| zpow_nonneg h' _, fun h => by\n    rw [bit1, zpow_add_one\u2080 h.ne] <;> exact mul_neg_of_pos_of_neg (zpow_bit0_pos h.ne _) h\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit1.{0} Int Int.hasOne Int.hasAdd n))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit1.{0} Int (NonAssocRing.toOne.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)) Int.instAddInt n))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a)\nCase conversion may be inaccurate. Consider using '#align zpow_bit1_nonneg_iff zpow_bit1_nonneg_iff\u2093'. -/\n@[simp]\ntheorem zpow_bit1_nonneg_iff : 0 \u2264 a ^ bit1 n \u2194 0 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit1.{0} Int Int.hasOne Int.hasAdd n)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit1.{0} Int (NonAssocRing.toOne.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)) Int.instAddInt n)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align zpow_bit1_nonpos_iff zpow_bit1_nonpos_iff\u2093'. -/\n@[simp]\ntheorem zpow_bit1_nonpos_iff : a ^ bit1 n \u2264 0 \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit1.{0} Int Int.hasOne Int.hasAdd n))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit1.{0} Int (NonAssocRing.toOne.{0} Int (Ring.toNonAssocRing.{0} Int Int.instRingInt)) Int.instAddInt n))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a)\nCase conversion may be inaccurate. Consider using '#align zpow_bit1_pos_iff zpow_bit1_pos_iff\u2093'. -/\n@[simp]\ntheorem zpow_bit1_pos_iff : 0 < a ^ bit1 n \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {n : Int}, (Even.{0} Int Int.hasAdd n) -> (forall (a : \u03b1), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {n : Int}, (Even.{0} Int Int.instAddInt n) -> (forall (a : \u03b1), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n))\nCase conversion may be inaccurate. Consider using '#align even.zpow_nonneg Even.zpow_nonneg\u2093'. -/\nprotected theorem Even.zpow_nonneg (hn : Even n) (a : \u03b1) : 0 \u2264 a ^ n := by\n  obtain \u27e8k, rfl\u27e9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {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} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n)) (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Even.{0} Int Int.instAddInt n) -> (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n)) (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align even.zpow_pos_iff Even.zpow_pos_iff\u2093'. -/\ntheorem Even.zpow_pos_iff (hn : Even n) (h : n \u2260 0) : 0 < a ^ n \u2194 a \u2260 0 := by\n  obtain \u27e8k, rfl\u27e9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.semiring n) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_neg_iff Odd.zpow_neg_iff\u2093'. -/\ntheorem Odd.zpow_neg_iff (hn : Odd n) : a ^ n < 0 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.semiring n) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_nonneg_iff Odd.zpow_nonneg_iff\u2093'. -/\nprotected theorem Odd.zpow_nonneg_iff (hn : Odd n) : 0 \u2264 a ^ n \u2194 0 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.semiring n) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_nonpos_iff Odd.zpow_nonpos_iff\u2093'. -/\ntheorem Odd.zpow_nonpos_iff (hn : Odd n) : a ^ n \u2264 0 \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.semiring n) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_pos_iff Odd.zpow_pos_iff\u2093'. -/\ntheorem Odd.zpow_pos_iff (hn : Odd n) : 0 < a ^ n \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {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} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Even.{0} Int Int.instAddInt n) -> (Ne.{1} Int n (OfNat.ofNat.{0} Int 0 (instOfNatInt 0))) -> (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n))\nCase conversion may be inaccurate. Consider using '#align even.zpow_pos Even.zpow_pos\u2093'. -/\nalias Even.zpow_pos_iff \u2194 _ 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.semiring n) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_neg Odd.zpow_neg\u2093'. -/\nalias Odd.zpow_neg_iff \u2194 _ 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.semiring n) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {n : Int}, (Odd.{0} Int Int.instSemiringInt n) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a n) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align odd.zpow_nonpos Odd.zpow_nonpos\u2093'. -/\nalias Odd.zpow_nonpos_iff \u2194 _ 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {p : Int}, (Even.{0} Int Int.hasAdd p) -> (forall (a : \u03b1), Eq.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a) p) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a p))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {p : Int}, (Even.{0} Int Int.instAddInt p) -> (forall (a : \u03b1), Eq.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) p) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a p))\nCase conversion may be inaccurate. Consider using '#align even.zpow_abs Even.zpow_abs\u2093'. -/\ntheorem Even.zpow_abs {p : \u2124} (hp : Even p) (a : \u03b1) : |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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1) (p : Int), Eq.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a) (bit0.{0} Int Int.hasAdd p)) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit0.{0} Int Int.hasAdd p))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1) (p : Int), Eq.{succ u1} \u03b1 (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) (bit0.{0} Int Int.instAddInt p)) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (bit0.{0} Int Int.instAddInt p))\nCase conversion may be inaccurate. Consider using '#align zpow_bit0_abs zpow_bit0_abs\u2093'. -/\n@[simp]\ntheorem zpow_bit0_abs (a : \u03b1) (p : \u2124) : |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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))) a) -> (forall (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))) n) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (Ring.toMonoid.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))) a n) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))) a) -> (forall (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Nat.cast.{u1} \u03b1 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) n) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) a n) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align nat.cast_le_pow_sub_div_sub Nat.cast_le_pow_sub_div_sub\u2093'. -/\n/-- Bernoulli's inequality reformulated to estimate `(n : \u03b1)`. -/\ntheorem Nat.cast_le_pow_sub_div_sub (H : 1 < a) (n : \u2115) : (n : \u03b1) \u2264 (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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))) a) -> (forall (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))) n) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (Ring.toMonoid.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))) a n) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))) a) -> (forall (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Nat.cast.{u1} \u03b1 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) n) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) a n) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align nat.cast_le_pow_div_sub Nat.cast_le_pow_div_sub\u2093'. -/\n/-- For any `a > 1` and a natural `n` we have `n \u2264 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 : \u2115) : (n : \u03b1) \u2264 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) {\u03b1 : Sort _} {\u03b2 : Type _} [mb : model th \u03b2] (j : \u03b1 \u2192 \u03b2) : Prop :=\n  \u2200 {\u03b3 : Type u} [mc : model th \u03b3] (f : \u03b1 \u2192 \u03b3), \u2203! (g : @morphism th \u03b2 \u03b3 mb.to_premodel mc.to_premodel), \u2200 (a : \u03b1), g.val (j a) = f a\n\nlemma free_on_bijective_bases (th : theory) {\u03b1 \u03b2 : Sort _} {\u03c6 : Type _} [mb : model th \u03c6] (u : bijection \u03b1 \u03b2) (j : \u03b2 \u2192 \u03c6) : is_free.{u} th j \u2192 is_free.{u} th (j\u2218 u.to_fun) :=\n  begin\n    intros hfree,\n    intros \u03c8 mpsi g,\n    cases @hfree \u03c8 mpsi (g\u2218 u.inv) with g\u2081 hg\u2081,\n    existsi g\u2081,\n    dsimp [function.comp] at *,\n    split,\n    show \u2200 (a : \u03b1), g\u2081.val (j (u.to_fun a)) = g a, {\n      intros a,\n      by calc\n        g\u2081.val (j (u.to_fun a))\n            = g (u.inv (u.to_fun a)) : hg\u2081.left (u.to_fun a)\n        ... = g a : by rw [u.left_inverse a]\n    },\n    show \u2200 (g' : @morphism th \u03c6 \u03c8 _ mpsi.to_premodel), (\u2200 a, g'.val (j (u.to_fun a)) = g a) \u2192 g' = g\u2081, {\n      intros g' hg',\n      apply hg\u2081.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 : \u2115} (hp : Nat.Prime p) (hn23 : p \u2260 2 \u2227 p \u2260 3) (a b c : \u2124) (habc)\n\nlemma c4_abc : Model.c4 \u27e80, a, 0, b, c\u27e9 = 16 * a ^ 2 - 48 * b :=\nby\n  simp [c4, b2, b4]\n  ring\n\nlemma discr_abc :\n  Model.discr \u27e80, a, 0, b, c\u27e9 = -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 \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9 =\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) \u2260 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 \u27e80, a, 0, b, c\u27e9) = 0) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .I 0 :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   sorry\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 0\n--   . simp [\u2190 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 : \u2115) (hn : n \u2265 1)\n--   (hcona : (primeEVR hp).valtn a = 0)\n--   (hconb : (primeEVR hp).valtn b \u2265 ((n + 1)/2 : \u2115))\n--   (hconc : (primeEVR hp).valtn c = n) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .I n :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 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 \u2265 1)\n--   (hconb : (primeEVR hp).valtn b \u2265 1)\n--   (hconc : (primeEVR hp).valtn c = 1) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .II :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 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 \u2265 1)\n--   (hconb : (primeEVR hp).valtn b = 1)\n--   (hconc : (primeEVR hp).valtn c \u2265 2) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .III :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 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 \u2265 1)\n--   (hconb : (primeEVR hp).valtn b \u2265 2)\n--   (hconc : (primeEVR hp).valtn c = 2) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .IV :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 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 \u27e80, a, 0, b, c\u27e9) < 7)\n--   (hcona : (primeEVR hp).valtn a \u2265 1)\n--   (hconb : (primeEVR hp).valtn b \u2265 2)\n--   (hconc : (primeEVR hp).valtn c \u2265 3) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .Is 0 :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 h, val_discr_abc hp a b c habc, nat_of_val, c4_abc]\n--   simp [valc4, valdisc']\n\n-- lemma kodaira_Is {n : \u2115} (hn : n \u2265 1)\n--   (hcona : (primeEVR hp).valtn a = 1)\n--   (hconb : (primeEVR hp).valtn b \u2265 ((n + 1)/2 + 2 : \u2115))\n--   (hconc : (primeEVR hp).valtn c \u2265 n + 3) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .Is n :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 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 \u2265 2)\n--   (hconb : (primeEVR hp).valtn b \u2265 3)\n--   (hconc : (primeEVR hp).valtn c = 4) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .IVs :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 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 \u2265 2)\n--   (hconb : (primeEVR hp).valtn b \u2265 3)\n--   (hconc : (primeEVR hp).valtn c \u2265 5) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .IIIs :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 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 \u2265 2)\n--   (hconb : (primeEVR hp).valtn b \u2265 4)\n--   (hconc : (primeEVR hp).valtn c = 5) :\n--   (tate_algorithm p hp \u27e8\u27e80, a, 0, b, c\u27e9, habc\u27e9).1 = .IIs :=\n-- by\n--   rw [tate_algorithm, if_neg hn23.1, if_neg hn23.2, tate_big_prime]\n--   generalize h : (\u27e8\u27e80,a,0,b,c\u27e9, _\u27e9 : ValidModel \u2124) = e\n--   have valc4 : 3 * (primeEVR hp).valtn e.c4 = \u221e; simp [\u2190 h, c4_abc]\n--   have valdisc' : val_discr_to_nat (primeEVR hp).valtn e % 12 = 8\n--   . simp [\u2190 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 : \u03b1 \u2192 \u03b1 \u2192 \u03b1) : Prop :=\n    \u2200 a\u2081 a\u2082,\n      op a\u2081 a\u2082 = op a\u2082 a\u2081\n\n  class Zero (\u03b1 : Type u) :=\n    zero : \u03b1\n  instance : Zero Nat := \u27e80\u27e9\n  instance : Zero Int := \u27e80\u27e9\n\n  open Zero (zero)\n\n  class One (\u03b1 : Type u) :=\n    one : \u03b1\n  instance : One Nat := \u27e81\u27e9\n  instance : One Int := \u27e81\u27e9\n\n  open One (one)\nend NoMathlib\n\n\n\nsection Range\n  --- A range, inclusive on both ends.\n  abbrev Range \u03b1 := \u03b1 \u00d7 \u03b1\n\n  infix:min \"\u00b7\u00b7\" => (fun lb ub => ((lb, ub) : Range _))\n\n  --- Conversion from regular products to ranges.\n  instance : Coe (\u03b1 \u00d7 \u03b1) (Range \u03b1) where\n    coe := id\n  --- Conversion from ranges to regular products.\n  instance : Coe (Range \u03b1) (\u03b1 \u00d7 \u03b1) where\n    coe := id\n\n  --- Length of a range.\n  def Prod.len [Sub \u03b1] (self : Range \u03b1) : \u03b1 :=\n    self.1 - self.2\n\n  --- `True` if the range is empty.\n  def Prod.isEmpty [LT \u03b1] (self : Range \u03b1) : Prop :=\n    self.2 < self.1\n  --- `Prod.isEmpty` is decidable.\n  instance\n    [inst : LT \u03b1] [decLt : DecidableRel inst.lt]\n    {self : Range \u03b1}\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 : \u03b1)\n    (fld : \u03b1 \u2192 Int \u2192 \u03b1)\n    : \u03b1\n  :=\n    if range.1 \u2264 range.2 then\n      let acc := fld acc range.1\n      let range := range.1 + 1 \u00b7\u00b7 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 \u2192 tgt\n  \n  postfix:55 \" :>\" => Of.of\n\n  --- Conversion to self.\n  instance : Of \u03b1 \u03b1 where\n    of := id\n\n  --- `OfNat \u2192 Of Nat`\n  instance {conv : (n : Nat) \u2192 OfNat \u03b1 n} : Of Nat \u03b1 where\n    of val :=\n      conv val\n      |>.ofNat\n\n  --- `Of` is transitive.\n  instance instTransOf [of\u03b1\u03b2 : Of \u03b1 \u03b2] [of\u03b2\u03b3 : Of \u03b2 \u03b3] : Of \u03b1 \u03b3 where\n    of a :=\n      of\u03b1\u03b2.of a\n      |> of\u03b2\u03b3.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    \u2200 (i\u2081 i\u2082 : Int), i\u2081 + i\u2082 = i\u2082 + i\u2081\n  := by\n    intros i\u2081 i\u2082\n    cases i\u2081\n    <;> cases i\u2082\n    <;> simp [HAdd.hAdd, Add.add, Int.add]\n    <;> rw [Nat.add_comm]\n\n  --- Multiplication is commutative.\n  theorem mul_comm :\n    \u2200 (i\u2081 i\u2082 : Int), i\u2081 * i\u2082 = i\u2082 * i\u2081\n  := by\n    intros i\u2081 i\u2082\n    cases i\u2081\n    <;> cases i\u2082\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 {\u03b1 : Sort u} : Nonempty \u03b1 \u2192 \u03b1\n\ntheorem indefinite_description {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) (h : \u2203 (x : \u03b1), p x) :\n    Subtype fun (x : \u03b1) => p x :=\n  sorry\n\ndef some {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (h : \u2203 (x : \u03b1), p x) : \u03b1 :=\n  subtype.val (indefinite_description p h)\n\ntheorem some_spec {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (h : \u2203 (x : \u03b1), 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 \u2228 \u00acp :=\n  or.elim (not_uv_or_p p) (fun (hne : u p \u2260 v p) => Or.inr (mt (p_implies_uv p) hne)) Or.inl\n\ntheorem exists_true_of_nonempty {\u03b1 : Sort u} : Nonempty \u03b1 \u2192 \u2203 (x : \u03b1), True :=\n  fun (\u1fb0 : Nonempty \u03b1) =>\n    nonempty.dcases_on \u1fb0 fun (\u1fb0 : \u03b1) => idRhs (\u2203 (x : \u03b1), True) (Exists.intro \u1fb0 trivial)\n\ndef inhabited_of_nonempty {\u03b1 : Sort u} (h : Nonempty \u03b1) : Inhabited \u03b1 :=\n  { default := Classical.choice h }\n\ndef inhabited_of_exists {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (h : \u2203 (x : \u03b1), p x) : Inhabited \u03b1 :=\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 (\u03b1 : Sort u) : DecidableEq \u03b1 := fun (x y : \u03b1) => prop_decidable (x = y)\n\ndef type_decidable (\u03b1 : Sort u) : psum \u03b1 (\u03b1 \u2192 False) := sorry\n\ntheorem strong_indefinite_description {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) (h : Nonempty \u03b1) :\n    Subtype fun (x : \u03b1) => (\u2203 (y : \u03b1), p y) \u2192 p x :=\n  sorry\n\n/- the Hilbert epsilon function -/\n\ndef epsilon {\u03b1 : Sort u} [h : Nonempty \u03b1] (p : \u03b1 \u2192 Prop) : \u03b1 :=\n  subtype.val (strong_indefinite_description p h)\n\ntheorem epsilon_spec_aux {\u03b1 : Sort u} (h : Nonempty \u03b1) (p : \u03b1 \u2192 Prop) :\n    (\u2203 (y : \u03b1), p y) \u2192 p (epsilon p) :=\n  subtype.property (strong_indefinite_description p h)\n\ntheorem epsilon_spec {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} (hex : \u2203 (y : \u03b1), p y) : p (epsilon p) :=\n  epsilon_spec_aux (nonempty_of_exists hex) p hex\n\ntheorem epsilon_singleton {\u03b1 : Sort u} (x : \u03b1) : (epsilon fun (y : \u03b1) => y = x) = x :=\n  epsilon_spec (Exists.intro x rfl)\n\n/- the axiom of choice -/\n\ntheorem axiom_of_choice {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {r : (x : \u03b1) \u2192 \u03b2 x \u2192 Prop}\n    (h : \u2200 (x : \u03b1), \u2203 (y : \u03b2 x), r x y) : \u2203 (f : (x : \u03b1) \u2192 \u03b2 x), \u2200 (x : \u03b1), r x (f x) :=\n  Exists.intro (fun (x : \u03b1) => some (h x)) fun (x : \u03b1) => some_spec (h x)\n\ntheorem skolem {\u03b1 : Sort u} {b : \u03b1 \u2192 Sort v} {p : (x : \u03b1) \u2192 b x \u2192 Prop} :\n    (\u2200 (x : \u03b1), \u2203 (y : b x), p x y) \u2194 \u2203 (f : (x : \u03b1) \u2192 b x), \u2200 (x : \u03b1), p x (f x) :=\n  sorry\n\ntheorem prop_complete (a : Prop) : a = True \u2228 a = False :=\n  or.elim (em a) (fun (t : a) => Or.inl (eq_true_intro t)) fun (f : \u00aca) => Or.inr (eq_false_intro f)\n\ndef eq_true_or_eq_false (a : Prop) : a = True \u2228 a = False := prop_complete\n\ntheorem cases_true_false (p : Prop \u2192 Prop) (h1 : p True) (h2 : p False) (a : Prop) : p a :=\n  or.elim (prop_complete a) (fun (ht : a = True) => Eq.symm ht \u25b8 h1)\n    fun (hf : a = False) => Eq.symm hf \u25b8 h2\n\ntheorem cases_on (a : Prop) {p : Prop \u2192 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 \u2192 q) (hnpq : \u00acp \u2192 q) : q := decidable.by_cases hpq hnpq\n\n-- this supercedes by_contradiction in decidable\n\ntheorem by_contradiction {p : Prop} (h : \u00acp \u2192 False) : p := decidable.by_contradiction h\n\ntheorem eq_false_or_eq_true (a : Prop) : a = False \u2228 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\u2082 u u\u2082\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 \u2964 C}\n          {c\u2081 : fan F.obj}\n          {c\u2082 : fan (\u03bb f : (\u03a3 p : J \u00d7 J, p.1 \u27f6 p.2), F.obj f.1.2)}\n          (s t : c\u2081.X \u27f6 c\u2082.X)\n          (hs : \u2200 (f : \u03a3 p : J \u00d7 J, p.1 \u27f6 p.2), s \u226b c\u2082.\u03c0.app \u27e8f\u27e9 = c\u2081.\u03c0.app \u27e8f.1.1\u27e9 \u226b F.map f.2)\n          (ht : \u2200 (f : \u03a3 p : J \u00d7 J, p.1 \u27f6 p.2), t \u226b c\u2082.\u03c0.app \u27e8f\u27e9 = c\u2081.\u03c0.app \u27e8f.1.2\u27e9)\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  \u03c0 :=\n  { app := \u03bb j, i.\u03b9 \u226b c\u2081.\u03c0.app \u27e8_\u27e9,\n    naturality' := \u03bb j\u2081 j\u2082 f, begin\n      dsimp,\n      rw [category.id_comp, category.assoc, \u2190 hs \u27e8\u27e8_, _\u27e9, f\u27e9, 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\u2081 : is_limit c\u2081) (t\u2082 : is_limit c\u2082) (hi : is_limit i) :\n  is_limit (build_limit s t hs ht i) :=\n{ lift := \u03bb q,\n  begin\n    refine hi.lift (fork.of_\u03b9 _ _),\n    { refine t\u2081.lift (fan.mk _ (\u03bb j, _)),\n      apply q.\u03c0.app j },\n    { apply t\u2082.hom_ext,\n      intro j, discrete_cases,\n      simp [hs, ht] },\n  end,\n  uniq' := \u03bb q m w, hi.hom_ext (i.equalizer_ext (t\u2081.hom_ext\n    (\u03bb 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 \u2964 C)\n  [has_limit (discrete.functor F.obj)]\n  [has_limit (discrete.functor (\u03bb f : (\u03a3 p : J \u00d7 J, p.1 \u27f6 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 (\u03bb f, limit.\u03c0 (discrete.functor F.obj) \u27e8_\u27e9 \u226b F.map f.2))\n      (pi.lift (\u03bb f, limit.\u03c0 (discrete.functor F.obj) \u27e8f.1.2\u27e9))\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 \u2964 C)\n  [has_limit (discrete.functor F.obj)]\n  [has_limit (discrete.functor (\u03bb f : (\u03a3 p : J \u00d7 J, p.1 \u27f6 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 \u2964 C) :\n  limit F \u27f6 \u220f (\u03bb j, F.obj j) :=\n(limit.iso_limit_cone (limit_cone_of_equalizer_and_product F)).hom \u226b equalizer.\u03b9 _ _\n\ninstance limit_subobject_product_mono [has_limits_of_size.{w w} C] (F : J \u2964 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 := \u03bb J \ud835\udca5,\n  { has_limit := \u03bb 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\u27e8\u03bb J _ _, { has_limit := \u03bb F, by exactI has_limit_of_equalizer_and_product F }\u27e9\n\nvariables {D : Type u\u2082} [category.{v\u2082} D]\nnoncomputable theory\n\nsection\n\nvariables [has_limits_of_shape (discrete J) C]\n          [has_limits_of_shape (discrete (\u03a3 p : J \u00d7 J, p.1 \u27f6 p.2)) C]\n          [has_equalizers C]\nvariables (G : C \u2964 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} (\u03a3 p : J \u00d7 J, p.1 \u27f6 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 := \u03bb K,\n  begin\n    let P := \u220f K.obj,\n    let Q := \u220f (\u03bb (f : (\u03a3 (p : J \u00d7 J), p.fst \u27f6 p.snd)), K.obj f.1.2),\n    let s : P \u27f6 Q := pi.lift (\u03bb f, limit.\u03c0 (discrete.functor K.obj) \u27e8_\u27e9 \u226b K.map f.2),\n    let t : P \u27f6 Q := pi.lift (\u03bb f, limit.\u03c0 (discrete.functor K.obj) \u27e8f.1.2\u27e9),\n    let I := equalizer s t,\n    let i : I \u27f6 P := equalizer.\u03b9 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 _ (\u03bb j, G.map (pi.\u03c0 _ j)) },\n    { exact fan.mk (G.obj Q) (\u03bb f, G.map (pi.\u03c0 _ f)) },\n    { apply G.map s },\n    { apply G.map t },\n    { intro f,\n      dsimp,\n      simp only [\u2190G.map_comp, limit.lift_\u03c0, fan.mk_\u03c0_app] },\n    { intro f,\n      dsimp,\n      simp only [\u2190G.map_comp, limit.lift_\u03c0, fan.mk_\u03c0_app] },\n    { apply fork.of_\u03b9 (G.map i) _,\n      simp only [\u2190 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 \u2964 D) [preserves_limits_of_shape walking_parallel_pair G]\n  [\u2200 (J : Type) [fintype J], preserves_limits_of_shape (discrete J) G] :\n  preserves_finite_limits G :=\n\u27e8\u03bb _ _ _, by exactI preserves_limit_of_preserves_equalizers_and_product G\u27e9\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 \u2964 D) [preserves_limits_of_shape walking_parallel_pair G]\n  [\u2200 J, preserves_limits_of_shape (discrete.{w} J) G] :\npreserves_limits_of_size.{w w} G :=\n{ preserves_limits_of_shape := \u03bb J \ud835\udca5,\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 \u2964 C}\n          {c\u2081 : cofan (\u03bb f : (\u03a3 p : J \u00d7 J, p.1 \u27f6 p.2), F.obj f.1.1)}\n          {c\u2082 : cofan F.obj}\n          (s t : c\u2081.X \u27f6 c\u2082.X)\n          (hs : \u2200 (f : \u03a3 p : J \u00d7 J, p.1 \u27f6 p.2), c\u2081.\u03b9.app \u27e8f\u27e9 \u226b s = F.map f.2 \u226b c\u2082.\u03b9.app \u27e8f.1.2\u27e9)\n          (ht : \u2200 (f : \u03a3 p : J \u00d7 J, p.1 \u27f6 p.2), c\u2081.\u03b9.app \u27e8f\u27e9 \u226b t = c\u2082.\u03b9.app \u27e8f.1.1\u27e9)\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  \u03b9 :=\n  { app := \u03bb j, c\u2082.\u03b9.app \u27e8_\u27e9 \u226b i.\u03c0,\n    naturality' := \u03bb j\u2081 j\u2082 f, begin\n      dsimp,\n      rw [category.comp_id, \u2190reassoc_of (hs \u27e8\u27e8_, _\u27e9, f\u27e9), i.condition, \u2190category.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\u2081 : is_colimit c\u2081) (t\u2082 : is_colimit c\u2082) (hi : is_colimit i) :\n  is_colimit (build_colimit s t hs ht i) :=\n{ desc := \u03bb q,\n  begin\n    refine hi.desc (cofork.of_\u03c0 _ _),\n    { refine t\u2082.desc (cofan.mk _ (\u03bb j, _)),\n      apply q.\u03b9.app j },\n    { apply t\u2081.hom_ext,\n      intro j, discrete_cases,\n      simp [reassoc_of hs, reassoc_of ht] },\n  end,\n  uniq' := \u03bb q m w, hi.hom_ext (i.coequalizer_ext (t\u2082.hom_ext\n    (\u03bb 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 \u2964 C)\n  [has_colimit (discrete.functor F.obj)]\n  [has_colimit (discrete.functor (\u03bb f : (\u03a3 p : J \u00d7 J, p.1 \u27f6 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 (\u03bb f, F.map f.2 \u226b colimit.\u03b9 (discrete.functor F.obj) \u27e8f.1.2\u27e9))\n      (sigma.desc (\u03bb f, colimit.\u03b9 (discrete.functor F.obj) \u27e8f.1.1\u27e9))\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 \u2964 C)\n  [has_colimit (discrete.functor F.obj)]\n  [has_colimit (discrete.functor (\u03bb f : (\u03a3 p : J \u00d7 J, p.1 \u27f6 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 \u2964 C) :\n  \u2210 (\u03bb j, F.obj j) \u27f6 colimit F :=\ncoequalizer.\u03c0 _ _ \u226b (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 \u2964 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 := \u03bb J \ud835\udca5,\n  { has_colimit := \u03bb 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\u27e8\u03bb J _ _, { has_colimit := \u03bb F, by exactI has_colimit_of_coequalizer_and_coproduct F }\u27e9\n\nnoncomputable theory\n\nsection\n\nvariables [has_colimits_of_shape (discrete.{w} J) C]\n          [has_colimits_of_shape (discrete.{w} (\u03a3 p : J \u00d7 J, p.1 \u27f6 p.2)) C]\n          [has_coequalizers C]\nvariables (G : C \u2964 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} (\u03a3 p : J \u00d7 J, p.1 \u27f6 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 := \u03bb K,\n  begin\n    let P := \u2210 K.obj,\n    let Q := \u2210 (\u03bb (f : (\u03a3 (p : J \u00d7 J), p.fst \u27f6 p.snd)), K.obj f.1.1),\n    let s : Q \u27f6 P := sigma.desc (\u03bb f, K.map f.2 \u226b colimit.\u03b9 (discrete.functor K.obj) \u27e8_\u27e9),\n    let t : Q \u27f6 P := sigma.desc (\u03bb f, colimit.\u03b9 (discrete.functor K.obj) \u27e8f.1.1\u27e9),\n    let I := coequalizer s t,\n    let i : P \u27f6 I := coequalizer.\u03c0 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) (\u03bb j, G.map (sigma.\u03b9 _ j)) },\n    { exact cofan.mk _ (\u03bb f, G.map (sigma.\u03b9 _ f)) },\n    { apply G.map s },\n    { apply G.map t },\n    { intro f,\n      dsimp,\n      simp only [\u2190G.map_comp, colimit.\u03b9_desc, cofan.mk_\u03b9_app] },\n    { intro f,\n      dsimp,\n      simp only [\u2190G.map_comp, colimit.\u03b9_desc, cofan.mk_\u03b9_app] },\n    { apply cofork.of_\u03c0 (G.map i) _,\n      simp only [\u2190 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 \u2964 D) [preserves_colimits_of_shape walking_parallel_pair G]\n  [\u2200 J [fintype J], preserves_colimits_of_shape (discrete.{0} J) G] :\n  preserves_finite_colimits G :=\n\u27e8\u03bb _ _ _, by exactI preserves_colimit_of_preserves_coequalizers_and_coproduct G\u27e9\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 \u2964 D) [preserves_colimits_of_shape walking_parallel_pair G]\n  [\u2200 J, preserves_colimits_of_shape (discrete.{w} J) G] :\npreserves_colimits_of_size.{w} G :=\n{ preserves_colimits_of_shape := \u03bb J \ud835\udca5,\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 {\u03b1 : Type u} [comm_ring \u03b1]\nparameters (f : \u03b1) (P : set \u03b1) [hp : is_ideal P]\nparameters (hf : \u2200 n : \u2115, f^n \u2209 P)\ninclude hp hf\n\nprivate def avoid_powers_aux :\n  \u2203 (M : {S : set \u03b1 // is_ideal S \u2227 P \u2286 S \u2227 \u2200 n, f ^ n \u2209 S}),\n  \u2200 x, M \u2264 x \u2192 x = M :=\n@@zorn.zorn' {S // is_ideal S \u2227 P \u2286 S \u2227 \u2200 n, f^n \u2209 S} _ \u27e8\u27e8P, hp, set.subset.refl P, hf\u27e9\u27e9 $\n\u03bb c x hx hc, \u27e8\u27e8{y | \u2203 S : {S // is_ideal S \u2227 P \u2286 S \u2227 \u2200 n, f^n \u2209 S}, S \u2208 c \u2227 y \u2208 S.val},\n  { zero_ := \u27e8x, hx, @@is_ideal.zero _ x.1 x.2.1\u27e9,\n    add_  := \u03bb x y \u27e8Sx, hxc, hx\u27e9 \u27e8Sy, hyc, hy\u27e9,\n      or.cases_on (hc Sx Sy hxc hyc)\n        (\u03bb hxy, \u27e8Sy, hyc, @@is_ideal.add _ Sy.2.1 (hxy hx) hy\u27e9)\n        (\u03bb hyx, \u27e8Sx, hxc, @@is_ideal.add _ Sx.2.1 hx (hyx hy)\u27e9),\n    smul  := \u03bb x y \u27e8Sy, hyc, hy\u27e9,\n      \u27e8Sy, hyc, @@is_ideal.mul_left _ Sy.2.1 hy\u27e9 },\n  \u03bb z hz, \u27e8x, hx, x.2.2.1 hz\u27e9,\n  \u03bb n \u27e8S, hsc, hfns\u27e9, S.2.2.2 n hfns\u27e9,\n\u03bb S hsc z hzs, \u27e8S, hsc, hzs\u27e9\u27e9\n\ndef avoid_powers : set \u03b1 :=\n(classical.some avoid_powers_aux).1\n\ntheorem avoid_powers.contains : P \u2286 avoid_powers :=\n(classical.some avoid_powers_aux).2.2.1\n\ntheorem avoid_powers.avoid_powers : \u2200 n : \u2115, f^n \u2209 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 := \u03bb h,\n    have h1 : (1:\u03b1) \u2208 (set.univ:set \u03b1), from show true, by trivial,\n    have h2 : (1:\u03b1) \u2208 avoid_powers, by rwa h,\n    avoid_powers.avoid_powers 0 h2,\n  mem_or_mem_of_mul_mem := \u03bb x y hxy,\n    have h1 : \u2200 x, classical.some avoid_powers_aux \u2264 x \u2192 x = classical.some avoid_powers_aux,\n      from classical.some_spec avoid_powers_aux,\n    have hax : avoid_powers \u2286 span (insert x avoid_powers),\n      from set.subset.trans (set.subset_insert x _) subset_span,\n    have hay : avoid_powers \u2286 span (insert y avoid_powers),\n      from set.subset.trans (set.subset_insert y _) subset_span,\n    have hax2 : P \u2286 span (insert x avoid_powers),\n      from set.subset.trans avoid_powers.contains hax,\n    have hay2 : P \u2286 span (insert y avoid_powers),\n      from set.subset.trans avoid_powers.contains hay,\n    have hnx : (\u00ac\u2203 n, f^n \u2208 span (insert x avoid_powers)) \u2192 x \u2208 avoid_powers,\n      from \u03bb h,\n      have h2 : _ := h1 \u27e8_, is_ideal_span, hax2, \u03bb n hnfs, h \u27e8n, hnfs\u27e9\u27e9 hax,\n      suffices x \u2208 span (insert x avoid_powers),\n        by unfold avoid_powers; rw \u2190 h2; exact this,\n      subset_span $ set.mem_insert x _,\n    have hny : (\u00ac\u2203 n, f^n \u2208 span (insert y avoid_powers)) \u2192 y \u2208 avoid_powers,\n      from \u03bb h,\n      have h2 : _ := h1 \u27e8_, is_ideal_span, hay2, \u03bb n hnfs, h \u27e8n, hnfs\u27e9\u27e9 hay,\n      suffices y \u2208 span (insert y avoid_powers),\n        by unfold avoid_powers; rw \u2190 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 : \u2203 m : \u2115, f^m \u2208 span (insert x (avoid_powers f P hf)),\n      { by_cases hy : \u2203 n : \u2115, f^n \u2208 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 \u27e8x1, x2, hx2, hx\u27e9,\n          rcases hy with \u27e8y1, y2, hy2, hy\u27e9,\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 \u2022 x + x2) * (y1 \u2022 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                  ... \u2208 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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 {\u03b1 : Type*} [fintype \u03b1] {P : finpartition (univ : finset \u03b1)} (hP : P.is_equipartition)\n  (G : simple_graph \u03b1) (\u03b5 : \u211d)\n\nlocal notation `m` := (card \u03b1/exp_bound P.parts.card : \u2115)\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 \u03b1) :=\nP.bind (\u03bb U, hP.chunk_increment G \u03b5)\n\nopen finpartition finpartition.is_equipartition\n\nvariables {hP G \u03b5}\n\nlemma card_increment (hP\u03b1 : P.parts.card * 16^P.parts.card \u2264 card \u03b1) (hPG : \u00acP.is_uniform G \u03b5) :\n  (hP.increment G \u03b5).parts.card = exp_bound P.parts.card :=\nbegin\n  have hP\u03b1' : exp_bound P.parts.card \u2264 card \u03b1 :=\n    (nat.mul_le_mul_of_nonneg_left $ nat.pow_le_pow_of_le_left (by norm_num) _).trans hP\u03b1,\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 \u03bb x hx, finpartition.equitabilise.parts_card (nat.div_pos hP\u03b1' hPpos) _,\n  exact \u03bb x hx, finpartition.equitabilise.parts_card (nat.div_pos hP\u03b1' 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), \u2190add_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 \u03b1) (\u03b5 : \u211d) :\n  (hP.increment G \u03b5).is_equipartition :=\nbegin\n  rw [is_equipartition, set.equitable_on_iff_exists_eq_eq_add_one],\n  refine \u27e8m, \u03bb A hA, _\u27e9,\n  rw [mem_coe, increment, mem_bind] at hA,\n  obtain \u27e8U, hU, hA\u27e9 := 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    (\u03bb UV, (hP.chunk_increment G \u03b5 ((mem_off_diag _ _).1 UV.2).1).parts.product\n      (hP.chunk_increment G \u03b5 ((mem_off_diag _ _).1 UV.2).2.1).parts)\n  \u2286 (hP.increment G \u03b5).parts.off_diag :=\nbegin\n  rintro \u27e8Ui, Vj\u27e9,\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 \u27e8\u27e8_, hUV.1, hUi\u27e9, \u27e8_, hUV.2.1, hVj\u27e9, _\u27e9,\n  rintro rfl,\n  obtain \u27e8i, hi\u27e9 := 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 \u03b1) (\u03b5 : \u211d) (hP : P.is_equipartition)\n  (x : {x // x \u2208 P.parts.off_diag}) :=\n(\u2211 i in\n  (hP.chunk_increment G \u03b5 ((mem_off_diag _ _).1 x.2).1).parts.product\n    (hP.chunk_increment G \u03b5 ((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  \u2211 x in P.parts.off_diag.attach, pair_contrib G \u03b5 hP x / (hP.increment G \u03b5).parts.card ^ 2 \u2264\n    (hP.increment G \u03b5).energy G :=\nbegin\n  simp_rw [pair_contrib, \u2190sum_div],\n  refine div_le_div_of_le_of_nonneg _ (sq_nonneg _),\n  rw \u2190sum_bUnion,\n  { exact sum_le_sum_of_subset_of_nonneg distinct_pairs_increment (\u03bb i _ _, sq_nonneg _) },\n  rintro \u27e8\u27e8s\u2081, s\u2082\u27e9, hs\u27e9 _ \u27e8\u27e8t\u2081, t\u2082\u27e9, ht\u27e9 _ hst \u27e8u, v\u27e9 huv,\n  simp only [inf_eq_inter, mem_inter, mem_product] at huv,\n  rw mem_off_diag at hs ht,\n  obtain \u27e8a, ha\u27e9 := finpartition.nonempty_of_mem_parts _ huv.1.1,\n  obtain \u27e8b, hb\u27e9 := 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 \u03b1] (x : {i // i \u2208 P.parts.off_diag}) (h\u03b5\u2081 : \u03b5 \u2264 1)\n  (hP\u03b1 : P.parts.card * 16^P.parts.card \u2264 card \u03b1) (hP\u03b5 : 100 \u2264 4^P.parts.card * \u03b5^5) :\n  G.edge_density x.1.1 x.1.2^2 - \u03b5^5/25 + (if G.is_uniform \u03b5 x.1.1 x.1.2 then 0 else \u03b5^4/3) \u2264\n    pair_contrib G \u03b5 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\u03b1 hP\u03b5 _ _ },\n  { apply sq_density_sub_eps_le_sum_sq_density_div_card_of_nonuniform hP\u03b1 hP\u03b5 h\u03b5\u2081 _ h,\n    exact ((mem_off_diag _ _).1 x.2).2.2 }\nend\n\nlemma uniform_add_nonuniform_eq_off_diag_pairs [nonempty \u03b1] (h\u03b5\u2081 : \u03b5 \u2264 1) (hP\u2087 : 7 \u2264 P.parts.card)\n  (hP\u03b1 : P.parts.card * 16^P.parts.card \u2264 card \u03b1) (hP\u03b5 : 100 \u2264 4^P.parts.card * \u03b5^5)\n  (hPG : \u00acP.is_uniform G \u03b5) :\n  (\u2211 x in P.parts.off_diag, G.edge_density x.1 x.2 ^ 2 + P.parts.card^2 * (\u03b5 ^ 5 / 4))\n    / P.parts.card ^ 2\n      \u2264 \u2211 x in P.parts.off_diag.attach, pair_contrib G \u03b5 hP x / (hP.increment G \u03b5).parts.card ^ 2 :=\nbegin\n  conv_rhs\n  { rw [\u2190sum_div, card_increment hP\u03b1 hPG, exp_bound, \u2190nat.cast_pow, mul_pow, pow_right_comm,\n      nat.cast_mul, mul_comm, \u2190div_div_eq_div_mul, (show 4^2 = 16, by norm_num), sum_div] },\n  rw [\u2190nat.cast_pow, nat.cast_pow 16],\n  refine div_le_div_of_le_of_nonneg _ (nat.cast_nonneg _),\n  norm_num,\n  suffices : _ \u2264 \u2211 x in P.parts.off_diag.attach,\n      (G.edge_density x.1.1 x.1.2^2 - \u03b5^5/25 + if G.is_uniform \u03b5 x.1.1 x.1.2 then 0 else \u03b5^4/3),\n  { apply le_trans this (sum_le_sum (\u03bb i hi, pair_contrib_lower_bound i h\u03b5\u2081 hP\u03b1 hP\u03b5)) },\n  have : \u2211 x in P.parts.off_diag.attach,\n    (G.edge_density x.1.1 x.1.2^2 - \u03b5^5/25 + if G.is_uniform \u03b5 x.1.1 x.1.2 then 0 else \u03b5^4/3) =\n    \u2211 x in P.parts.off_diag,\n      (G.edge_density x.1 x.2^2 - \u03b5^5/25 + if G.is_uniform \u03b5 x.1 x.2 then 0 else \u03b5^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, \u2190finpartition.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 \u2190mul_one P.parts.card }, rw \u2190nat.mul_sub_left_distrib },\n    simp_rw [mul_assoc, sub_add_eq_add_sub, add_sub_assoc, \u2190mul_sub_left_distrib, mul_div_assoc' \u03b5,\n      \u2190pow_succ, div_eq_mul_one_div (\u03b5^5), \u2190mul_sub_left_distrib],\n    rw [mul_left_comm, mul_left_comm _ (\u03b5^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\u03b5).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, \u2190mul_sub_left_distrib,\n      \u2190div_le_iff (show (0:\u211d) < 1/3 - 1/25 - 1/4, by norm_num)],\n    refine le_trans (show _ \u2264 (7:\u211d), by norm_num) (by exact_mod_cast hP\u2087) },\n  exact div_nonneg (pow_bit0_nonneg _ _) (by norm_num),\nend\n\nlemma energy_increment [nonempty \u03b1] (hP : P.is_equipartition) (hP\u2087 : 7 \u2264 P.parts.card)\n  (h\u03b5 : 100 < 4^P.parts.card * \u03b5^5) (hP\u03b1 : P.parts.card * 16^P.parts.card \u2264 card \u03b1)\n  (hPG : \u00acP.is_uniform G \u03b5) (h\u03b5\u2081 : \u03b5 \u2264 1) :\n  P.energy G + \u03b5^5 / 4 \u2264 (hP.increment G \u03b5).energy G :=\nbegin\n  have h := uniform_add_nonuniform_eq_off_diag_pairs h\u03b5\u2081 hP\u2087 hP\u03b1 h\u03b5.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\u00f6ckle\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 \u2192 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 `\u03b5`, `dual_pair e \u03b5` 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 `\u03b5` form a dual pair, `e` is a basis and\n  `\u03b5` 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\u00f6s-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 \u2192 R`. -/\n@[derive [add_comm_monoid, module R]] def dual := M \u2192\u2097[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 \u2192\u2097[R] M \u2192\u2097[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) (\u03bb _, M \u2192 R) := \u27e8linear_map.to_fun\u27e9\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 \u2192\u2097[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 \u2192\u2097[R] M'` to\n`dual R M' \u2192\u2097[R] dual R M`. -/\ndef transpose : (M \u2192\u2097[R] M') \u2192\u2097[R] (dual R M' \u2192\u2097[R] dual R M) :=\n(linear_map.llcomp R M M' R).flip\n\nlemma transpose_apply (u : M \u2192\u2097[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' \u2192\u2097[R] M'') (v : M \u2192\u2097[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 \u03b9 : Type*}\n\nsection comm_semiring\n\nvariables [comm_semiring R] [add_comm_monoid M] [module R M] [decidable_eq \u03b9]\nvariables (b : basis \u03b9 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 \u2192\u2097[R] module.dual R M :=\nb.constr \u2115 $ \u03bb v, b.constr \u2115 $ \u03bb w, if w = v then (1 : R) else 0\n\nlemma to_dual_apply (i j : \u03b9) :\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 : \u03b9 \u2192\u2080 R) (i : \u03b9) :\n  b.to_dual (finsupp.total \u03b9 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 : \u03b9 \u2192\u2080 R) (i : \u03b9) :\n  b.to_dual (b i) (finsupp.total \u03b9 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 : \u03b9) : b.to_dual m (b i) = b.repr m i :=\nby rw [\u2190 b.to_dual_total_left, b.total_repr]\n\nlemma to_dual_apply_right (i : \u03b9) (m : M) : b.to_dual (b i) m = b.repr m i :=\nby rw [\u2190 b.to_dual_total_right, b.total_repr]\n\nlemma coe_to_dual_self (i : \u03b9) : 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 \u2192\u2097[R] R) := b.to_dual.flip m\n\nlemma to_dual_flip_apply (m\u2081 m\u2082 : M) : b.to_dual_flip m\u2081 m\u2082 = b.to_dual m\u2082 m\u2081 := rfl\n\nlemma to_dual_eq_repr (m : M) (i : \u03b9) : 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 \u03b9] (m : M) (i : \u03b9) : 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 [\u2190 mem_bot R, \u2190 b.repr.ker, mem_ker, linear_equiv.coe_coe],\n  apply finsupp.ext,\n  intro b,\n  rw [\u2190 to_dual_eq_repr, a],\n  refl\nend\n\ntheorem to_dual_ker : b.to_dual.ker = \u22a5 :=\nker_eq_bot'.mpr b.to_dual_inj\n\ntheorem to_dual_range [fin : fintype \u03b9] : b.to_dual.range = \u22a4 :=\nbegin\n  rw eq_top_iff',\n  intro f,\n  rw linear_map.mem_range,\n  let lin_comb : \u03b9 \u2192\u2080 R := finsupp.on_finset fin.elems (\u03bb i, f.to_fun (b i)) _,\n  { use finsupp.total \u03b9 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 \u03b9]\nvariables (b : basis \u03b9 R M)\n\n@[simp] lemma sum_dual_apply_smul_coord (f : module.dual R M) : \u2211 x, f (b x) \u2022 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 _), \u2190smul_eq_mul,\n    \u2190f.map_smul, \u2190f.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 \u03b9]\nvariables (b : basis \u03b9 R M)\n\n/-- A vector space is linearly equivalent to its dual space. -/\n@[simps]\ndef to_dual_equiv [fintype \u03b9] : M \u2243\u2097[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 \u03b9] : basis \u03b9 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 \u03b9] (i j : \u03b9) :\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 \u03b9] (f : \u03b9 \u2192\u2080 R) (i : \u03b9) :\n  finsupp.total \u03b9 (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 \u03b9] (l : dual R M) (i : \u03b9) :\n  b.dual_basis.repr l i = l (b i) :=\nby rw [\u2190 total_dual_basis b, basis.total_repr b.dual_basis l]\n\nlemma dual_basis_equiv_fun [fintype \u03b9] (l : dual R M) (i : \u03b9) :\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 \u03b9] (i : \u03b9) (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 \u03b9] :\n  \u21d1b.dual_basis = b.coord :=\nby { ext i x, apply dual_basis_apply }\n\n@[simp] lemma to_dual_to_dual [fintype \u03b9] :\n  b.dual_basis.to_dual.comp b.to_dual = dual.eval R M :=\nbegin\n  refine b.ext (\u03bb i, b.dual_basis.ext (\u03bb j, _)),\n  rw [linear_map.comp_apply, to_dual_apply_left, coe_to_dual_self, \u2190 coe_dual_basis,\n      dual.eval_apply, basis.repr_self, finsupp.single_apply, dual_basis_apply_self]\nend\n\ntheorem eval_ker {\u03b9 : Type*} (b : basis \u03b9 R M) :\n  (dual.eval R M).ker = \u22a5 :=\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 (\u03bb i, hm (b.coord i))\nend\n\nlemma eval_range {\u03b9 : Type*} [fintype \u03b9] (b : basis \u03b9 R M) :\n  (eval R M).range = \u22a4 :=\nbegin\n  classical,\n  rw [\u2190 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  {\u03b9 : Type*} [fintype \u03b9] (b : basis \u03b9 R M) : M \u2243\u2097[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 {\u03b9 : Type*} [fintype \u03b9] (b : basis \u03b9 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 \u03b9]\n  (b : basis \u03b9 R M) (f : \u03b9 \u2192\u2080 R) (i : \u03b9) :\n  finsupp.total \u03b9 (dual R M) R b.coord f (b i) = f i :=\nby { haveI := classical.dec_eq \u03b9, rw [\u2190 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 \u03b9] (b : basis \u03b9 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, \u2190 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 = \u22a5 :=\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 = \u22a4 :=\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 \u2243\u2097[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 \u03b9 : Type*}\nvariables [comm_semiring R] [add_comm_monoid M] [module R M] [decidable_eq \u03b9]\n\n/-- `e` and `\u03b5` have characteristic properties of a basis and its dual -/\n@[nolint has_inhabited_instance]\nstructure dual_pair (e : \u03b9 \u2192 M) (\u03b5 : \u03b9 \u2192 (dual R M)) :=\n(eval : \u2200 i j : \u03b9, \u03b5 i (e j) = if i = j then 1 else 0)\n(total : \u2200 {m : M}, (\u2200 i, \u03b5 i m = 0) \u2192 m = 0)\n[finite : \u2200 m : M, fintype {i | \u03b5 i m \u2260 0}]\n\nend dual_pair\n\nnamespace dual_pair\n\nopen module module.dual linear_map function\n\nvariables {R M \u03b9 : Type*}\nvariables [comm_ring R] [add_comm_group M] [module R M]\nvariables {e : \u03b9 \u2192 M} {\u03b5 : \u03b9 \u2192 dual R M}\n\n/-- The coefficients of `v` on the basis `e` -/\ndef coeffs [decidable_eq \u03b9] (h : dual_pair e \u03b5) (m : M) : \u03b9 \u2192\u2080 R :=\n{ to_fun := \u03bb i, \u03b5 i m,\n  support := by { haveI := h.finite m, exact {i : \u03b9 | \u03b5 i m \u2260 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 {\u03b9} (e : \u03b9 \u2192 M) (l : \u03b9 \u2192\u2080 R) : M := l.sum (\u03bb (i : \u03b9) (a : R), a \u2022 (e i))\n\nlemma lc_def (e : \u03b9 \u2192 M) (l : \u03b9 \u2192\u2080 R) : lc e l = finsupp.total _ _ _ e l := rfl\n\nvariables [decidable_eq \u03b9] (h : dual_pair e \u03b5)\ninclude h\n\nlemma dual_lc (l : \u03b9 \u2192\u2080 R) (i : \u03b9) : \u03b5 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 : \u03b9 \u2192\u2080 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 \u2208 Q n} (\u03b5 p m) \u2022 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 \u03b5).basis` shows the family of vectors `e` forms a basis. -/\n@[simps]\ndef basis : basis \u03b9 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' := \u03bb v w, by { ext i, exact (\u03b5 i).map_add v w },\n  map_smul' := \u03bb c v, by { ext i, exact (\u03b5 i).map_smul c v } }\n\n@[simp] lemma coe_basis : \u21d1h.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 \u03b9} {x : M} (hmem : x \u2208 submodule.span R (e '' H)) :\n  \u2200 i : \u03b9, \u03b5 i x \u2260 0 \u2192 i \u2208 H :=\nbegin\n  intros i hi,\n  rcases (finsupp.mem_span_image_iff_total _).mp hmem with \u27e8l, supp_l, rfl\u27e9,\n  apply not_imp_comm.mp ((finsupp.mem_supported' _ _).mp supp_l i),\n  rwa [\u2190 lc_def, h.dual_lc] at hi\nend\n\nlemma coe_dual_basis [fintype \u03b9] : \u21d1h.basis.dual_basis = \u03b5 :=\nfunext (\u03bb i, h.basis.ext (\u03bb 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 \u2192\u2097[R] module.dual R W :=\nlinear_map.dom_restrict' W\n\n@[simp] lemma dual_restrict_apply\n  (W : submodule R M) (\u03c6 : module.dual R M) (x : W) :\n  W.dual_restrict \u03c6 x = \u03c6 (x : M) := rfl\n\n/-- The `dual_annihilator` of a submodule `W` is the set of linear maps `\u03c6` such\n  that `\u03c6 w = 0` for all `w \u2208 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 (\u03c6 : module.dual R M) :\n  \u03c6 \u2208 W.dual_annihilator \u2194 \u2200 w \u2208 W, \u03c6 w = 0 :=\nbegin\n  refine linear_map.mem_ker.trans _,\n  simp_rw [linear_map.ext_iff, dual_restrict_apply],\n  exact \u27e8\u03bb h w hw, h \u27e8w, hw\u27e9, \u03bb h w, h w.1 w.2\u27e9\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 \u2294 V).dual_annihilator = U.dual_annihilator \u2293 V.dual_annihilator :=\nbegin\n  ext \u03c6,\n  rw [mem_inf, mem_dual_annihilator, mem_dual_annihilator, mem_dual_annihilator],\n  split; intro h,\n  { refine \u27e8_, _\u27e9;\n    intros x hx,\n    exact h x (mem_sup.2 \u27e8x, hx, 0, zero_mem _, add_zero _\u27e9),\n    exact h x (mem_sup.2 \u27e80, zero_mem _, x, hx, zero_add _\u27e9) },\n  { simp_rw mem_sup,\n    rintro _ \u27e8x, hx, y, hy, rfl\u27e9,\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 (\u03a6 : submodule R (module.dual R M)) : submodule R M :=\n\u03a6.dual_annihilator.comap (module.dual.eval R M)\n\nlemma mem_dual_annihilator_comap_iff {\u03a6 : submodule R (module.dual R M)} (x : M) :\n  x \u2208 \u03a6.dual_annihilator_comap \u2194 \u2200 \u03c6 \u2208 \u03a6, (\u03c6 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 `\u03c6`, `dual_lift W \u03c6` is\nthe natural extension of `\u03c6` to an element of the dual of `V`.\nThat is, `dual_lift W \u03c6` sends `w \u2208 W` to `\u03c6 x` and `x` in the complement of `W` to `0`. -/\nnoncomputable def dual_lift (W : subspace K V) :\n  module.dual K W \u2192\u2097[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 {\u03c6 : module.dual K W} (w : W) :\n  W.dual_lift \u03c6 (w : V) = \u03c6 w :=\nby { erw of_is_compl_left_apply _ w, refl }\n\nlemma dual_lift_of_mem {\u03c6 : module.dual K W} {w : V} (hw : w \u2208 W) :\n  W.dual_lift \u03c6 w = \u03c6 \u27e8w, hw\u27e9 :=\nby convert dual_lift_of_subtype \u27e8w, hw\u27e9\n\n@[simp] lemma dual_restrict_comp_dual_lift (W : subspace K V) :\n  W.dual_restrict.comp W.dual_lift = 1 :=\nby { ext \u03c6 x, simp }\n\nlemma dual_restrict_left_inverse (W : subspace K V) :\n  function.left_inverse W.dual_restrict W.dual_lift :=\n\u03bb 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 \u29f8 W.dual_annihilator) \u2243\u2097[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 \u2243\u2097[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 (\u03c6 : module.dual K W) :\n  W.dual_equiv_dual \u03c6 = \u27e8W.dual_lift \u03c6, mem_range.2 \u27e8\u03c6, rfl\u27e9\u27e9 := rfl\n\nsection\n\nopen_locale classical\n\nopen finite_dimensional\n\nvariables {V\u2081 : Type*} [add_comm_group V\u2081] [module K V\u2081]\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\u2081]\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 \u29f8 W.dual_lift.range) \u2243\u2097[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 \u29f8 W) \u2243\u2097[K] W.dual_annihilator :=\nbegin\n  refine _ \u226a\u226b\u2097 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 {\u03a6 : subspace K (module.dual K V)} :\n  finrank K \u03a6.dual_annihilator_comap = finrank K \u03a6.dual_annihilator :=\nbegin\n  rw [submodule.dual_annihilator_comap, \u2190 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\u2081 : Type*} {M\u2082 : Type*}\nvariables [add_comm_monoid M\u2081] [module R M\u2081] [add_comm_monoid M\u2082] [module R M\u2082]\n\n/-- Given a linear map `f : M\u2081 \u2192\u2097[R] M\u2082`, `f.dual_map` is the linear map between the dual of\n`M\u2082` and `M\u2081` such that it maps the functional `\u03c6` to `\u03c6 \u2218 f`. -/\ndef linear_map.dual_map (f : M\u2081 \u2192\u2097[R] M\u2082) : dual R M\u2082 \u2192\u2097[R] dual R M\u2081 :=\nlinear_map.lcomp R R f\n\n@[simp] lemma linear_map.dual_map_apply (f : M\u2081 \u2192\u2097[R] M\u2082) (g : dual R M\u2082) (x : M\u2081) :\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\u2081 \u2192\u2097[R] M\u2081).dual_map = linear_map.id :=\nby { ext, refl }\n\nlemma linear_map.dual_map_comp_dual_map {M\u2083 : Type*} [add_comm_group M\u2083] [module R M\u2083]\n  (f : M\u2081 \u2192\u2097[R] M\u2082) (g : M\u2082 \u2192\u2097[R] M\u2083) :\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\u2081 \u2243\u2097[R] M\u2082) : dual R M\u2082 \u2243\u2097[R] dual R M\u2081 :=\n{ inv_fun := f.symm.to_linear_map.dual_map,\n  left_inv :=\n    begin\n      intro \u03c6, 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 \u03c6, 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\u2081 \u2243\u2097[R] M\u2082) (g : dual R M\u2082) (x : M\u2081) :\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\u2081).dual_map = linear_equiv.refl R (dual R M\u2081) :=\nby { ext, refl }\n\n@[simp] lemma linear_equiv.dual_map_symm {f : M\u2081 \u2243\u2097[R] M\u2082} :\n  (linear_equiv.dual_map f).symm = linear_equiv.dual_map f.symm := rfl\n\nlemma linear_equiv.dual_map_trans {M\u2083 : Type*} [add_comm_group M\u2083] [module R M\u2083]\n  (f : M\u2081 \u2243\u2097[R] M\u2082) (g : M\u2082 \u2243\u2097[R] M\u2083) :\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\u2081 : Type*} {M\u2082 : Type*}\nvariables [add_comm_monoid M\u2081] [module R M\u2081] [add_comm_monoid M\u2082] [module R M\u2082]\n\nvariable (f : M\u2081 \u2192\u2097[R] M\u2082)\n\nlemma ker_dual_map_eq_dual_annihilator_range :\n  f.dual_map.ker = f.range.dual_annihilator :=\nbegin\n  ext \u03c6, split; intro h\u03c6,\n  { rw mem_ker at h\u03c6,\n    rw submodule.mem_dual_annihilator,\n    rintro y \u27e8x, rfl\u27e9,\n    rw [\u2190 dual_map_apply, h\u03c6, zero_apply] },\n  { ext x,\n    rw dual_map_apply,\n    rw submodule.mem_dual_annihilator at h\u03c6,\n    exact h\u03c6 (f x) \u27e8x, rfl\u27e9 }\nend\n\nlemma range_dual_map_le_dual_annihilator_ker :\n  f.dual_map.range \u2264 f.ker.dual_annihilator :=\nbegin\n  rintro _ \u27e8\u03c8, rfl\u27e9,\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\u2081 : Type*} {V\u2082 : Type*}\nvariables [add_comm_group V\u2081] [module K V\u2081] [add_comm_group V\u2082] [module K V\u2082]\n\nopen finite_dimensional\n\nvariable [finite_dimensional K V\u2082]\n\n@[simp] lemma finrank_range_dual_map_eq_finrank_range (f : V\u2081 \u2192\u2097[K] V\u2082) :\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      \u2190 ker_dual_map_eq_dual_annihilator_range] at this,\n  conv_rhs at this { rw \u2190 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\u2081] (f : V\u2081 \u2192\u2097[K] V\u2082) :\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 \u27e8separating_left_iff_ker_eq_bot.mpr ker_id, _\u27e9,\n  intros x,\n  contrapose,\n  rintros hx : x \u2260 0,\n  rw [not_forall],\n  let f : V \u2192\u2097[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 \u2219 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 {\u03b9 \u03ba : Type*}\nvariables [decidable_eq \u03b9] [decidable_eq \u03ba]\nvariables [fintype \u03b9] [fintype \u03ba]\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 \u2297 dual N` to `dual (M \u2297 N)`,\nsending `f \u2297 g` to the composition of `tensor_product.map f g` with\nthe natural isomorphism `R \u2297 R \u2243 R`.\n-/\ndef dual_distrib : (dual R M) \u2297[R] (dual R N) \u2192\u2097[R] dual R (M \u2297[R] N) :=\n(comp_right \u2191(tensor_product.lid R R)) \u2218\u2097 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 \u2297\u209c g) (m \u2297\u209c 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 \u03b9 R M) (c : basis \u03ba R N) :\n  dual R (M \u2297[R] N) \u2192\u2097[R] (dual R M) \u2297[R] (dual R N) :=\n\u2211 i j, (ring_lmap_equiv_self R \u2115 _).symm (b.dual_basis i \u2297\u209c c.dual_basis j)\n    \u2218\u2097 apply\u2097 (c j) \u2218\u2097 apply\u2097 (b i) \u2218\u2097 (lcurry R M N R)\n\n@[simp]\nlemma dual_distrib_inv_of_basis_apply (b : basis \u03b9 R M) (c : basis \u03ba R N)\n  (f : dual R (M \u2297[R] N)) : dual_distrib_inv_of_basis b c f =\n  \u2211 i j, (f (b i \u2297\u209c c j)) \u2022 (b.dual_basis i \u2297\u209c c.dual_basis j) :=\nby simp [dual_distrib_inv_of_basis]\n\n/--\nA linear equivalence between `dual M \u2297 dual N` and `dual (M \u2297 N)` given bases for `M` and `N`.\nIt sends `f \u2297 g` to the composition of `tensor_product.map f g` with the natural\nisomorphism `R \u2297 R \u2243 R`.\n-/\n@[simps]\nnoncomputable def dual_distrib_equiv_of_basis (b : basis \u03b9 R M) (c : basis \u03ba R N) :\n  (dual R M) \u2297[R] (dual R N) \u2243\u2097[R] dual R (M \u2297[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 : \u2200 (r s : R), r \u2022 s = s \u2022 r := is_commutative.comm,\n    simp only [compr\u2082_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      \u2190 f.map_smul, \u2190f.map_sum, \u2190smul_tmul_smul, \u2190tmul_sum, \u2190sum_tmul, basis.coe_dual_basis,\n      basis.coord_apply, basis.sum_repr] },\n  { ext f g,\n    simp only [compr\u2082_apply, mk_apply, comp_apply, id_apply, dual_distrib_inv_of_basis_apply,\n      dual_distrib_apply, \u2190smul_tmul_smul, \u2190tmul_sum, \u2190sum_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 \u2297 dual N` and `dual (M \u2297 N)` when `M` and `N` are finite free\nmodules. It sends `f \u2297 g` to the composition of `tensor_product.map f g` with the natural\nisomorphism `R \u2297 R \u2243 R`.\n-/\n@[simp]\nnoncomputable\ndef dual_distrib_equiv : (dual R M) \u2297[R] (dual R N) \u2243\u2097[R] dual R (M \u2297[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 smt2\n\nlemma p_implies_p (P : Prop) : P \u2192 P :=\nbegin\n    intros,\n    z3\nend\n", "meta": {"author": "leanprover", "repo": "smt2_interface", "sha": "7ff0ce248b68ea4db2a2d4966a97b5786da05ed7", "save_path": "github-repos/lean/leanprover-smt2_interface", "path": "github-repos/lean/leanprover-smt2_interface/smt2_interface-7ff0ce248b68ea4db2a2d4966a97b5786da05ed7/test/p_implies_p.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7549149868676283, "lm_q2_score": 0.6370307875894138, "lm_q1q2_score": 0.4809040886473372}}
{"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 \u27f6 X} {g : W \u27f6 Y} {h : X \u27f6 Z} {i : Y \u27f6 Z} \n\nlemma is_pullback.is_iso_right (H : is_pullback f g h i) [is_iso h] : is_iso g :=\nbegin\n  have : _ \u226b \ud835\udfd9 _ = 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 \u2190 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 \u27f6 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 \u27f6 R` is mono if and only if `g \u226b f = 0 \u2192 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 \u226b (-g)` and `(-f) \u226b g` both become `-(f \u226b g)`, and `(-f) \u226b (-g)`\nis simplified to `f \u226b 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 \u27f6 Q` is an abelian group such that composition is\n    linear in both variables. -/\nclass preadditive :=\n(hom_group : \u03a0 P Q : C, add_comm_group (P \u27f6 Q) . tactic.apply_instance)\n(add_comp' : \u2200 (P Q R : C) (f f' : P \u27f6 Q) (g : Q \u27f6 R),\n  (f + f') \u226b g = f \u226b g + f' \u226b g . obviously)\n(comp_add' : \u2200 (P Q R : C) (f : P \u27f6 Q) (g g' : Q \u27f6 R),\n  f \u226b (g + g') = f \u226b g + f \u226b 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 \u2192 C)\n\ninstance induced_category : preadditive.{v} (induced_category C F) :=\n{ hom_group := \u03bb P Q, @preadditive.hom_group C _ _ (F P) (F Q),\n  add_comp' := \u03bb P Q R f f' g, add_comp' _ _ _ _ _ _,\n  comp_add' := \u03bb P Q R f g g', comp_add' _ _ _ _ _ _, }\n\nend induced_category\n\ninstance full_subcategory (Z : C \u2192 Prop) : preadditive.{v} (full_subcategory Z) :=\n{ hom_group := \u03bb P Q, @preadditive.hom_group C _ _ P.obj Q.obj,\n  add_comp' := \u03bb P Q R f f' g, add_comp' _ _ _ _ _ _,\n  comp_add' := \u03bb 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 := \u03bb f g h, preadditive.add_comp X X X g h f,\n  right_distrib := \u03bb 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 \u27f6 Q) : (Q \u27f6 R) \u2192+ (P \u27f6 R) :=\nmk' (\u03bb g, f \u226b g) $ \u03bb 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 \u27f6 R) : (P \u27f6 Q) \u2192+ (P \u27f6 R) :=\nmk' (\u03bb f, f \u226b g) $ \u03bb f f', by simp\n\nvariables {P Q R : C} (f f' : P \u27f6 Q) (g g' : Q \u27f6 R)\n\n/-- Composition as a bilinear group homomorphism -/\ndef comp_hom : (P \u27f6 Q) \u2192+ (Q \u27f6 R) \u2192+ (P \u27f6 R) :=\nadd_monoid_hom.mk' (\u03bb f, left_comp _ f) $\n  \u03bb f\u2081 f\u2082, add_monoid_hom.ext $ \u03bb g, (right_comp _ g).map_add f\u2081 f\u2082\n\n@[simp, reassoc] lemma sub_comp :\n  (f - f') \u226b g = f \u226b g - f' \u226b 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 \u226b (g - g') = f \u226b g - f \u226b g' :=\nmap_sub (left_comp R f) g g'\n\n@[simp, reassoc] lemma neg_comp : (-f) \u226b g = -(f \u226b 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 \u226b (-g) = -(f \u226b g) :=\nmap_neg (left_comp R f) g\n\n@[reassoc] lemma neg_comp_neg : (-f) \u226b (-g) = f \u226b g :=\nby simp\n\nlemma nsmul_comp (n : \u2115) : (n \u2022 f) \u226b g = n \u2022 (f \u226b g) :=\nmap_nsmul (right_comp P g) n f\n\nlemma comp_nsmul (n : \u2115) : f \u226b (n \u2022 g) = n \u2022 (f \u226b g) :=\nmap_nsmul (left_comp R f) n g\n\nlemma zsmul_comp (n : \u2124) : (n \u2022 f) \u226b g = n \u2022 (f \u226b g) :=\nmap_zsmul (right_comp P g) n f\n\nlemma comp_zsmul (n : \u2124) : f \u226b (n \u2022 g) = n \u2022 (f \u226b 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 \u27f6 Q) (g : J \u2192 (Q \u27f6 R)) :\n  f \u226b \u2211 j in s, g j = \u2211 j in s, f \u226b 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 \u2192 (P \u27f6 Q)) (g : Q \u27f6 R) :\n  (\u2211 j in s, f j) \u226b g  = \u2211 j in s, f j \u226b g :=\nmap_sum (right_comp P g) _ _\n\ninstance {P Q : C} {f : P \u27f6 Q} [epi f] : epi (-f) :=\n\u27e8\u03bb R g g' H, by rwa [neg_comp, neg_comp, \u2190comp_neg, \u2190comp_neg, cancel_epi, neg_inj] at H\u27e9\n\ninstance {P Q : C} {f : P \u27f6 Q} [mono f] : mono (-f) :=\n\u27e8\u03bb R g g' H, by rwa [comp_neg, comp_neg, \u2190neg_comp, \u2190neg_comp, cancel_mono, neg_inj] at H\u27e9\n\n@[priority 100]\ninstance preadditive_has_zero_morphisms : has_zero_morphisms C :=\n{ has_zero := infer_instance,\n  comp_zero' := \u03bb P Q f R, show left_comp R f 0 = 0, from map_zero _,\n  zero_comp' := \u03bb 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 \u27f6 Y) :=\n{ smul_add := \u03bb r f g, add_comp _ _ _ _ _ _,\n  smul_zero := \u03bb r, zero_comp,\n  add_smul := \u03bb r s f, comp_add _ _ _ _ _ _,\n  zero_smul := \u03bb r, comp_zero }\n\nlemma mono_of_cancel_zero {Q R : C} (f : Q \u27f6 R) (h : \u2200 {P : C} (g : P \u27f6 Q), g \u226b f = 0 \u2192 g = 0) :\n  mono f :=\n\u27e8\u03bb P g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (right_comp P f) g g').trans $ sub_eq_zero.2 hg\u27e9\n\nlemma mono_iff_cancel_zero {Q R : C} (f : Q \u27f6 R) :\n  mono f \u2194 \u2200 (P : C) (g : P \u27f6 Q), g \u226b f = 0 \u2192 g = 0 :=\n\u27e8\u03bb m P g, by exactI zero_of_comp_mono _, mono_of_cancel_zero f\u27e9\n\nlemma mono_of_kernel_zero {X Y : C} {f : X \u27f6 Y} [has_limit (parallel_pair f 0)]\n  (w : kernel.\u03b9 f = 0) : mono f :=\nmono_of_cancel_zero f (\u03bb P g h, by rw [\u2190kernel.lift_\u03b9 f g h, w, limits.comp_zero])\n\nlemma epi_of_cancel_zero {P Q : C} (f : P \u27f6 Q) (h : \u2200 {R : C} (g : Q \u27f6 R), f \u226b g = 0 \u2192 g = 0) :\n  epi f :=\n\u27e8\u03bb R g g' hg, sub_eq_zero.1 $ h _ $ (map_sub (left_comp R f) g g').trans $ sub_eq_zero.2 hg\u27e9\n\nlemma epi_iff_cancel_zero {P Q : C} (f : P \u27f6 Q) :\n  epi f \u2194 \u2200 (R : C) (g : Q \u27f6 R), f \u226b g = 0 \u2192 g = 0 :=\n\u27e8\u03bb e R g, by exactI zero_of_epi_comp _, epi_of_cancel_zero f\u27e9\n\n\n\nnamespace is_iso\n\n@[simp] lemma comp_left_eq_zero [is_iso f] :\n  f \u226b g = 0 \u2194 g = 0 :=\nby rw [\u2190 is_iso.eq_inv_comp, limits.comp_zero]\n\n@[simp] lemma comp_right_eq_zero [is_iso g] :\n  f \u226b g = 0 \u2194 f = 0 :=\nby rw [\u2190 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 \u27f6 Y} [has_limit (parallel_pair f 0)]\n  (w : kernel f \u2245 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 \u27f6 Y} [has_colimit (parallel_pair f 0)]\n  (w : cokernel f \u2245 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 \u27f6 Y} {g : X \u27f6 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_\u03b9 c.\u03b9 $ by rw [\u2190 sub_eq_zero, \u2190 comp_sub, c.condition]\n\n@[simp] lemma fork_of_kernel_fork_\u03b9 (c : kernel_fork (f - g)) :\n  (fork_of_kernel_fork c).\u03b9 = c.\u03b9 := 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_\u03b9 c.\u03b9 $ by rw [comp_sub, comp_zero, sub_eq_zero, c.condition]\n\n@[simp] lemma kernel_fork_of_fork_\u03b9 (c : fork f g) : (kernel_fork_of_fork c).\u03b9 = c.\u03b9 := rfl\n\n@[simp] lemma kernel_fork_of_fork_of_\u03b9 {P : C} (\u03b9 : P \u27f6 X) (w : \u03b9 \u226b f = \u03b9 \u226b g) :\n  (kernel_fork_of_fork (fork.of_\u03b9 \u03b9 w)) = kernel_fork.of_\u03b9 \u03b9 (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' _ $ \u03bb s,\n  \u27e8i.lift (kernel_fork_of_fork s), i.fac _ _,\n   \u03bb m h, by apply fork.is_limit.hom_ext i; tidy\u27e9\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' _ $ \u03bb s,\n  \u27e8i.lift (fork_of_kernel_fork s), i.fac _ _,\n    \u03bb m h, by apply fork.is_limit.hom_ext i; tidy\u27e9\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_\u03c0 c.\u03c0 $ by rw [\u2190 sub_eq_zero, \u2190 sub_comp, c.condition]\n\n@[simp] lemma cofork_of_cokernel_cofork_\u03c0 (c : cokernel_cofork (f - g)) :\n  (cofork_of_cokernel_cofork c).\u03c0 = c.\u03c0 := 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_\u03c0 c.\u03c0 $ by rw [sub_comp, zero_comp, sub_eq_zero, c.condition]\n\n@[simp] lemma cokernel_cofork_of_cofork_\u03c0 (c : cofork f g) :\n  (cokernel_cofork_of_cofork c).\u03c0 = c.\u03c0 := rfl\n\n@[simp] lemma cokernel_cofork_of_cofork_of_\u03c0 {P : C} (\u03c0 : Y \u27f6 P) (w : f \u226b \u03c0 = g \u226b \u03c0) :\n  (cokernel_cofork_of_cofork (cofork.of_\u03c0 \u03c0 w)) = cokernel_cofork.of_\u03c0 \u03c0 (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' _ $ \u03bb s,\n  \u27e8i.desc (cokernel_cofork_of_cofork s), i.fac _ _,\n    \u03bb m h, by apply cofork.is_colimit.hom_ext i; tidy\u27e9\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' _ $ \u03bb s,\n  \u27e8i.desc (cofork_of_cokernel_cofork s), i.fac _ _,\n    \u03bb m h, by apply cofork.is_colimit.hom_ext i; tidy\u27e9\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 _ _ (\u03bb _ _ 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 _ _ (\u03bb _ _ 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 \u2228 p \u2228 r :=\n  by repeat (first |apply Or.inl; assumption | apply Or.inr | assumption)\n example (p q r : Prop) (hp : p)\n         : (p \u2228 q \u2228 r) \u2227 (q \u2228 p \u2228 r) \u2227 (q \u2228 r \u2228 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 \u00d7 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 {\u03b1 : Type u} {\u03b2 : Type v} {p : Prod \u03b1 \u03b2} : \u03b1 := \n  match p with \n  | Prod.mk a b => a\n\ndef snd {\u03b1 : Type u} {\u03b2 : Type v} (p : Prod \u03b1 \u03b2 ) : \u03b2 := \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 (\u03b1 : Type u) (\u03b2 : Type v) where\n  mk :: (fst : \u03b1) (snd : \u03b2)\ninductive Sigma {\u03b1 : Type u} ( \u03b2 : \u03b1 \u2192 Type v) where \n  | mk : (a : \u03b1) \u2192 \u03b2 a \u2192 Sigma \u03b2 \ninductive Option (\u03b1 : Type u) where \n  | none : Option \u03b1 \n  | some : \u03b1 \u2192 Option \u03b1 \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 \u2192 carrier \u2192 carrier\n  mul_assoc : \u2200 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 (\u03b1 : Type u) where\n| nil : List \u03b1 \n| cons : \u03b1 \u2192 List \u03b1 \u2192 List \u03b1 \n\nnamespace List\ndef append (as bs : List \u03b1) : List \u03b1 := \n  match as with \n  | nil => bs \n  | cons a as => cons a (append as bs)\ntheorem nil_append (as : List \u03b1) : append nil as = as := \n  rfl \n\ntheorem cons_append (a : \u03b1) (as bs : List \u03b1)\n          : append (cons a as) bs = cons a (append as bs) := \n          rfl \n#check @List.recOn\ntheorem append_nil (as : List \u03b1) : 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 \u03b1)\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 \u03b1) : 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 \u03b1) : 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 \u2192 BinaryTree \u2192 BinaryTree\n\ninductive CBTree where\nend List\nend Hidden \n\nexample (p : Nat \u2192 Prop) (hz : p 0) (hs : \u2200 n, p (Nat.succ n)) : \u2200 n, p n := by\n  intro n\n  cases n\n  . exact hz  -- goal is p 0\n  . apply hs  -- goal is a : \u2115 \u22a2 p (succ a)\n\nexample (n : Nat) (h : n \u2260  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 (\u03b1 : Type) (n : Nat) := \n{ as : List \u03b1 // as.length = n}\ndef fr {n :Nat} {t : Tuple \u03b1 n} : Nat := by \n  cases n ; exact 3; exact 7\n\ndef myTuple : Tuple Nat 3 :=\n\u27e8 [0,1,2], rfl \u27e9 \n\ninductive Foo where \n| bar1 : Nat \u2192 Nat \u2192 Foo\n| bar2 : Nat \u2192 Nat \u2192 Nat \u2192 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 \u2192 Prop) (hz : p 0) (hs : \u2200 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\u2081 : m < n \u2192 p) (h\u2082 : m \u2265 n \u2192 p) : p := by \n  cases Nat.lt_or_ge m n \n  case inl hlt => exact h\u2081 hlt \n  case inr glt => exact h\u2082 glt\n\n  #check Nat.sub_self\n  example (m n : Nat) : m - n = 0 \u2228 m \u2260 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\u2081 ih =>\n    rw [Nat.mod_eq_sub_mod h\u2081.2]\n    exact ih h\n  | base x y h\u2081 =>\n    have : \u00ac 0 < y \u2228 \u00ac y \u2264 x := Iff.mp (Decidable.not_and_iff_or_not ..) h\u2081\n    match this with \n    | Or.inl h\u2081 => exact absurd h h\u2081 \n    | Or.inr h\u2081 => \n      have hgt : y > x := Nat.gt_of_not_le h\u2081 \n      rw [\u2190 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 `\u25a1\u207b\u00b9` :40\nreserve prefix `\u25c7\u207b\u00b9` :40\n\nnotation \u25a1\u207b\u00b9\u0393 := {a | (\u25a1a) \u2208 \u0393}\nnotation \u25c7\u207b\u00b9\u0393 := {a | (\u25c7a) \u2208 \u0393}\nnotation \u25a1\u0393 := {(\u25a1a) | a \u2208 \u0393}\nnotation \u25c7\u0393 := {(\u25c7a) | a \u2208 \u0393}\n\n/-- As set `s` is complete if, for any formula `x`, either `x` or `\u00acx` is contained in `s`. -/\ndef set.complete (s : set formula) := \u2200x, x \u2208 s \u2228 (\u00acx) \u2208 s\n\n/-- As set `s` is complete `\u03a3`-consistent if it is complete and `\u03a3`-consistent. -/\ndef set.complete_consistent (s : set formula) (axms) := s.consistent axms \u2227 s.complete\n\n@[simp] lemma set.complete_consistent.not_mem_iff {axms : set formula} {\u0393 : set formula} (hcc : \u0393.complete_consistent axms) {a : formula} :\n  a \u2209 \u0393 \u2194 (\u00aca) \u2208 \u0393 :=\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 \u00aca,\n      { derive_taut, },\n      { exact hdna, }, },\n    apply derivable.reflexivity ha, },\nend\n\nlemma set.complete_consistent.deductive_closure {axms : set formula} {\u0393 : set formula} (hcc : \u0393.complete_consistent axms) (a : formula) :\n  (\u0393 \u22a2[axms] a) \u2192 a \u2208 \u0393 :=\nbegin\n  intro ha,\n  by_contradiction,\n  rw set.complete_consistent.not_mem_iff at h,\n  { cases hcc with h\u2081 h\u2082,\n    apply h\u2081,\n    apply derivable.from.mp a,\n    { apply derivable.from.mp \u00aca,\n      { derive_taut, },\n      { apply derivable.reflexivity,\n        assumption, }, },\n    assumption, },\n  assumption,\nend\n\nlemma set.complete_consistent.not_mem_bot {axms} {\u0393 : set formula} (h\u0393 : \u0393.complete_consistent axms) :\n  formula.bottom \u2209 \u0393 :=\nbegin\n  by_contradiction,\n  apply h\u0393.elim_left,\n  exact derivable.reflexivity h,\nend\n\nlemma set.complete_consistent.mem_top {axms} {\u0393 : set formula} (h\u0393 : \u0393.complete_consistent axms) :\n  formula.top \u2208 \u0393 :=\nbegin\n  apply set.complete_consistent.deductive_closure h\u0393,\n  derive_taut,\nend\n\nlemma set.complete_consistent.mem_and {axms} {\u0393 : set formula} (h\u0393 : \u0393.complete_consistent axms) {a b : formula} :\n  (a \u2227 b) \u2208 \u0393 \u2194 a \u2208 \u0393 \u2227 b \u2208 \u0393 :=\nbegin\n  apply iff.intro,\n  { intro h,\n    split,\n    repeat {\n      apply set.complete_consistent.deductive_closure h\u0393,\n      apply derivable.from.mp (a \u2227 b) _ _ (derivable.reflexivity h),\n      derive_taut,\n    }, },\n  { intro h,\n    apply set.complete_consistent.deductive_closure h\u0393,\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} {\u0393 : set formula} (h\u0393 : \u0393.complete_consistent axms) {a b : formula} :\n  (a \u2228 b) \u2208 \u0393 \u2194 a \u2208 \u0393 \u2228 b \u2208 \u0393 :=\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\u0393,\n      apply set.complete_consistent.deductive_closure h\u0393,\n      apply derivable.from.mp (\u00aca),\n      apply derivable.from.mp (\u00acb),\n      derive_taut,\n      repeat {\n        apply derivable.reflexivity,\n        rw \u2190set.complete_consistent.not_mem_iff h\u0393,\n        tauto,\n      }, }, },\n  { intro h,\n    apply set.complete_consistent.deductive_closure h\u0393,\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} {\u0393 : set formula} (h\u0393 : \u0393.complete_consistent axms) {a b : formula} :\n  (a \u27f6 b) \u2208 \u0393 \u2194 a \u2208 \u0393 \u2192 b \u2208 \u0393 :=\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\u0393,\n      apply set.complete_consistent.deductive_closure h\u0393,\n      apply derivable.from.mp a,\n      apply derivable.from.mp (\u00acb),\n      derive_taut,\n      { apply derivable.reflexivity,\n        rw \u2190set.complete_consistent.not_mem_iff h\u0393,\n        tauto, },\n      { apply derivable.reflexivity,\n        tauto, }, }, },\n  { intro h,\n    apply set.complete_consistent.deductive_closure h\u0393,\n    have h := not_or_of_imp h,\n    cases h,\n    { rw set.complete_consistent.not_mem_iff h\u0393 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} {\u0393 : set formula} (h\u0393 : \u0393.complete_consistent axms) {a b : formula} :\n  (a \u2194 b) \u2208 \u0393 \u2194 (a \u2208 \u0393 \u2194 b \u2208 \u0393) :=\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\u0393,\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\u0393,\n    by_cases ha : a \u2208 \u0393,\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\u0393).mp ha,\n      have hnb := (set.complete_consistent.not_mem_iff h\u0393).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} {\u0393 : set formula} {a : formula} :\n  (\u0393 \u22a2[axms] a) \u2192 (\u25a1\u0393 \u22a2[axms] \u25a1a) :=\nbegin\n  intro hda,\n  cases hda with xs hxs,\n  cases hxs with hxs hda,\n  apply exists.intro (xs.map (\u03bba, \u25a1a)),\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} {\u0393 : set formula} {a : formula} :\n  (\u25a1\u207b\u00b9\u0393 \u22a2[axms] a) \u2192 (\u0393 \u22a2[axms] \u25a1a) :=\nbegin\n  intro hda,\n  cases hda with xs hxs,\n  cases hxs with hxs hda,\n  apply exists.intro (xs.map (\u03bba, \u25a1a)),\n  split,\n  { intros x hx,\n    simp * at *,\n    cases hx with a ha,\n    rw \u2190ha.elim_right,\n    apply hxs,\n    exact ha.elim_left, },\n  { exact derivable.RK hda, },\nend\n\ndef cc\u2099 (s axms : set formula) : \u2115 \u2192 set formula\n| 0 := s\n| (n + 1) := if (cc\u2099 n \u222a {enumerate n}).consistent axms\n  then cc\u2099 n \u222a {enumerate n}\n  else cc\u2099 n \u222a {\u00acenumerate n}\n\n/-- `cc s \u03a3` constructs a complete, `\u03a3`-consistent set built upon `s`. -/\ndef cc (s : set formula) (axms) : set formula := \u22c3n, cc\u2099 s axms n\n\nlemma cc\u2099_sub_cc (s) (axms) (n : \u2115) : cc\u2099 s axms n \u2286 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\u2099_sub_cc\u2098' (s axms) (n m) : cc\u2099 s axms n \u2286 cc\u2099 s axms (n + m) :=\nbegin\n  intros x hn,\n  induction m,\n  { assumption, },\n  { rw nat.add_succ,\n    rw cc\u2099,\n    by_cases (cc\u2099 s axms (n + m_n) \u222a {enumerate (n + m_n)}).consistent axms,\n    { simp [h, m_ih], },\n    { simp [h, m_ih], }, },\nend\n\nlemma cc\u2099_sub_cc\u2098 (s axms) (n m : \u2115) (hm : m \u2265 n) : cc\u2099 s axms n \u2286 cc\u2099 s axms m :=\nbegin\n  have h := cc\u2099_sub_cc\u2098' s axms n (m - n),\n  simp [nat.add_sub_of_le hm] at h,\n  assumption,\nend\n\nlemma cc\u2099_consistent (s axms : set formula) (n : \u2115) (h\u2080 : s.consistent axms) :\n  (cc\u2099 s axms n).consistent axms :=\nbegin\n  induction n,\n  { simp [cc\u2099, h\u2080], },\n  { rw cc\u2099,\n    by_cases (cc\u2099 s axms n_n \u222a {enumerate n_n}).consistent axms;\n    have h' := consistent_extensible (cc\u2099 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\u2099 (s axms : set formula) (xs : list formula) (hxs : \u2200x \u2208 xs, x \u2208 cc s axms) :\n  \u2203n, \u2200x \u2208 xs, x \u2208 cc\u2099 s axms n :=\nbegin\n  induction xs with _ _ ih,\n  { simp, },\n  { have hxs' : \u2200 (x : formula), x \u2208 xs_tl \u2192 x \u2208 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\u2099_sub_cc\u2098 s axms n' _,\n      { simp, },\n      { simp [ha, hn'], }, },\n    { apply cc\u2099_sub_cc\u2098 s axms n _,\n      { simp },\n      { apply hn,\n        exact ha, }, }, },\nend\n\nlemma cc_consistent (s axms : set formula) (h\u2080 : 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\u2099 s axms xs hxs,\n  apply exists.elim h,\n  intros n hn,\n  have hnc := cc\u2099_consistent s axms n h\u2080,\n  apply not.elim hnc,\n  apply exists.intro xs,\n  split,\n  assumption',\nend\n\n/-- For any `\u03a3` consistent set `s`, there exists a complete, `\u03a3`-consistent set built upon `s`. -/\ntheorem lindenbaum {axms : set formula} {s : set formula} (hcc : s.consistent axms) :\n  \u2203s' \u2287 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\u2099,\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\u2099 s axms n) \u222a {x}).consistent axms),\n      { apply or.intro_left,\n        apply exists.intro (n + 1),\n        simp at h,\n        simp [cc\u2099, hn, h], },\n      { apply or.intro_right,\n        apply exists.intro (n + 1),\n        simp at h,\n        simp [cc\u2099, hn, h], }, }, },\nend\n\nlemma derivable_iff_mem_cc (axms \u0393 : set formula) (a : formula) :\n  (\u0393 \u22a2[axms] a) \u2194 (\u2200\u0394 \u2287 \u0393, \u0394.complete_consistent axms \u2192 a \u2208 \u0394) :=\nbegin\n  apply iff.intro,\n  { intros hda \u0394 h\u0394 hcc,\n    by_contradiction,\n    cases hcc with hconsistent hcomplete,\n    apply hconsistent,\n    apply derivable.from.mp a,\n    { apply derivable.from.mp \u00aca,\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 \u0393 \u0394 h\u0394 hda, }, },\n  { intros h,\n    by_contradiction hnc,\n    rw [derivable_iff_not_consistent, not_not] at hnc,\n    cases lindenbaum hnc with \u0394 h\u0394,\n    cases h\u0394 with h\u0394 h\u0394cc,\n    apply @not.elim (a \u2208 \u0394),\n    { rw set.complete_consistent.not_mem_iff h\u0394cc,\n      apply set.mem_of_subset_of_mem h\u0394,\n      simp, },\n    { refine h \u0394 _ h\u0394cc,\n      intros x hx,\n      exact h\u0394 (or.intro_left _ hx), }, },\nend\n\nlemma set.complete_consistent.mem_box {axms} {\u0393 : set formula} (h\u0393 : \u0393.complete_consistent axms) {a : formula} :\n  (\u25a1a) \u2208 \u0393 \u2194 \u2200\u0394 : set formula, \u0394.complete_consistent axms \u2192 (\u25a1\u207b\u00b9\u0393) \u2286 \u0394 \u2192 a \u2208 \u0394 :=\nbegin\n  apply iff.intro,\n  { intros hba \u0394 h\u0394cc h\u0394,\n    apply h\u0394,\n    exact hba, },\n  { contrapose,\n    intros hnba h,\n    have hndba : \u00ac(\u0393 \u22a2[axms] \u25a1a) := begin\n      by_contradiction,\n      apply hnba,\n      exact set.complete_consistent.deductive_closure h\u0393 _ h,\n    end,\n    have hndba' : \u00ac(\u25a1\u207b\u00b9\u0393 \u22a2[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 \u0394 h\u0394,\n    cases h\u0394 with h\u0394 h\u0394cc, \n    apply not.elim,\n    { change a \u2209 \u0394,\n      intro ha,\n      apply h\u0394cc.elim_left,\n      apply derivable.from.mp a _ _ (derivable.reflexivity ha),\n      apply derivable.from.mp \u00aca,\n      derive_taut,\n      apply derivable.reflexivity,\n      apply h\u0394,\n      simp, },\n    { apply h \u0394 h\u0394cc,\n      intros x hx,\n      apply h\u0394,\n      exact or.intro_left _ hx, }, },\nend\n\nlemma set.complete_consistent.debox_subset_iff {axms} {\u0393 \u0394 : set formula}\n    (h\u0393 : \u0393.complete_consistent axms) (h\u0394 : \u0394.complete_consistent axms) :\n  (\u25a1\u207b\u00b9\u0393) \u2286 \u0394 \u2194 (\u25c7\u0394) \u2286 \u0393 :=\nbegin\n  apply iff.intro,\n  { intros h x hx,\n    cases hx with a ha,\n    cases ha with ha hx,\n    rw \u2190hx at *,\n    clear hx x,\n    apply set.complete_consistent.deductive_closure h\u0393,\n    apply derivable.from.mp \u00ac\u25a1\u00aca,\n    { apply derivable.from.mp (dual a),\n      { derive_taut, },\n      { ignore_premises,\n        apply derivable.dual, }, },\n    { apply derivable.reflexivity,\n      apply (h\u0393.elim_right _).resolve_left,\n      by_contradiction h',\n      apply not.elim _ ha,\n      rw set.complete_consistent.not_mem_iff h\u0394,\n      exact h h', }, },\n  { intros h a,\n    simp at h,\n    contrapose,\n    intro ha,\n    change (\u25a1a) \u2209 \u0393,\n    rw set.complete_consistent.not_mem_iff h\u0393,\n    apply set.complete_consistent.deductive_closure h\u0393,\n    { rw derivable.from.not_box_iff_diamond_not,\n      apply derivable.reflexivity,\n      rw set.complete_consistent.not_mem_iff h\u0394 at ha,\n      apply h,\n      simp,\n      exact ha, }, },\nend\n\nlemma set.complete_consistent.mem_diamond {axms} {\u0393 : set formula} (h\u0393 : \u0393.complete_consistent axms) {a : formula} :\n  (\u25c7a) \u2208 \u0393 \u2194 \u2203\u0394 : set formula, \u0394.complete_consistent axms \u2227 (\u25c7\u0394) \u2286 \u0393 \u2227 a \u2208 \u0394 :=\nbegin\n  -- have h\u2081 : (\u25c7a) \u2208 \u0393 \u2194 (\u00ac\u25a1\u00aca) \u2208 \u0393 := sorry,\n  -- have h\u2082 : (\u00ac\u25a1\u00aca) \u2208 \u0393 \u2194 (\u25a1\u00aca) \u2209 \u0393 := sorry,\n  -- have h\u2083 := set.complete_consistent.mem_box h\u0393,\n  sorry\nend\n\ndef set.canonical_model (axms : set formula) : model :=\n{\n  world := set formula,\n  w := {\u0394 | \u0394.complete_consistent axms},\n  r := \u03bb\u0394 \u0394', (\u25a1\u207b\u00b9\u0394) \u2286 \u0394',\n  v := \u03bbp, {\u0394 | formula.symbol p \u2208 \u0394},\n}\n\n@[simp] lemma set.canonical_model.w (axms : set formula) : axms.canonical_model.w = {\u0394 | \u0394.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 = \u03bbp : symbol, {\u0394 : set formula | formula.symbol p \u2208 \u0394} :=\nby refl\n\n@[simp] lemma set.canonical_model.r {axms : set formula} : axms.canonical_model.r = \u03bb\u0394 \u0394' : set formula, (\u25a1\u207b\u00b9\u0394) \u2286 \u0394' :=\nby refl\n\n/-- The Truth Lemma: a world `\u0394` in the canonical model of a system makes a formula true\n    iff the formula is contained in `\u0394`. -/\ntheorem truth_lemma {axms : set formula} {\u0394 : set formula} {h\u0394 : \u0394 \u2208 axms.canonical_model.w} :\n  \u2200a, (\u27e8axms.canonical_model, \u0394\u27e9 \u22a9 a) \u2194 a \u2208 \u0394 :=\nbegin\n  intros a,\n  simp * at *,\n  induction a generalizing \u0394,\n  { simp,\n    exact set.complete_consistent.not_mem_bot h\u0394, },\n  { simp,\n    exact set.complete_consistent.mem_top h\u0394, },\n  { simp, exact iff.rfl, },\n  { simp * at *,\n    apply set.complete_consistent.not_mem_iff h\u0394, },\n  { simp * at *,\n    exact iff.symm (set.complete_consistent.mem_and h\u0394), },\n  { simp * at *,\n    exact iff.symm (set.complete_consistent.mem_or h\u0394), },\n  { simp * at *,\n    exact iff.symm (set.complete_consistent.mem_imp h\u0394), },\n  { simp * at *,\n    exact iff.symm (set.complete_consistent.mem_iff h\u0394), },\n  { apply iff.intro,\n    { intro hba,\n      simp at hba,\n      apply (set.complete_consistent.mem_box h\u0394).mpr,\n      intros \u0394' h\u0394'cc h\u0394',\n      rw \u2190a_ih h\u0394'cc,\n      exact hba \u0394' h\u0394'cc h\u0394', },\n    { intro hba,\n      intros \u0394' h\u0394' hr\u0394',\n      rw a_ih h\u0394',\n      apply hr\u0394',\n      exact hba, }, },\n  { apply iff.intro,\n    { intro hda,\n      simp at hda,\n      apply (set.complete_consistent.mem_diamond h\u0394).mpr,\n      cases hda with \u0394' h\u0394',\n      cases h\u0394' with h\u0394'cc h\u0394',\n      cases h\u0394' with h\u0394' h\u0394'a,\n      apply exists.intro \u0394',\n      split,\n      exact h\u0394'cc,\n      split,\n      { intros x hx,\n        rw set.complete_consistent.debox_subset_iff h\u0394 h\u0394'cc at h\u0394',\n        apply h\u0394',\n        exact hx, },\n      { rw \u2190a_ih h\u0394'cc,\n        exact h\u0394'a, }, },\n    { contrapose,\n      intro hnda,\n      rw set.complete_consistent.not_mem_iff h\u0394,\n      have hbna : \u27e8axms.canonical_model, \u0394\u27e9 \u22a9 \u25a1\u00aca_a := begin\n        intros \u0394' h\u0394' h\u0394'r,\n        by_contradiction,\n        apply hnda,\n        apply exists.intro \u0394',\n        apply exists.intro h\u0394',\n        split,\n        exact h\u0394'r,\n        simp at h,\n        exact h,\n      end,\n      apply set.complete_consistent.deductive_closure h\u0394,\n      sorry }, },\nend\n\n/-- Determination: the canonical model for `\u03a3` satisfies a formula iff the formula is `\u03a3`-derivable. -/\ntheorem determination (axms : set formula) : \u2200a, (axms.canonical_model \u22a9 a) \u2194 (axms \u22a2 a) :=\nbegin\n  intro a,\n  apply iff.intro,\n  { intro ha,\n    rw [\u2190derivable.from.no_premises, derivable_iff_mem_cc],\n    intros s _ hs,\n    rw \u2190truth_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 \u2205,\n      { tauto, },\n      { rw derivable.from.no_premises,\n        assumption, }, },\n    assumption, },\nend\n\n/-- A system `\u03a3` is complete for a set `\ud835\udc9e` of models iff for any formula `a`, `\ud835\udc9e \u22a8 a \u2192 \u03a3 \u22a2 a`. -/\nclass complete (axms : set formula) (\ud835\udc9e : set model) :=\n(complete : \u2200a, (\ud835\udc9e \u22a8 a) \u2192 (axms \u22a2 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 \u2190determination,\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 \u2264 the ith row bump column.\n    [ssyt.rbs_cert.next_rbc_le]\n  3. If we insert k, followed by k' \u2265 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 \u2264 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 {\u03bc : young_diagram} (T : ssyt \u03bc) (i val : \u2115) :\n  \u2203 j, (i, j) \u2208 \u03bc \u2192 val < T i j :=\nby { obtain \u27e8j, hj\u27e9 := \u03bc.row_len_aux i, use j }\n\ndef ssyt.rbc {\u03bc : young_diagram} (T : ssyt \u03bc) (i val : \u2115) : \u2115 :=\n  nat.find $ T.rbc_aux i val\n\nlemma ssyt.lt_rbc_iff {\u03bc : young_diagram} (T : ssyt \u03bc) {i j val: \u2115} :\n  j < T.rbc i val \u2194 (i, j) \u2208 \u03bc \u2227 T i j \u2264 val :=\nbegin\n  rw [ssyt.rbc, nat.lt_find_iff], push_neg,\n  exact \u27e8\u03bb h, h _ (le_refl _),\n         \u03bb h _ hm, \u27e8\u03bc.nw_of (le_refl _) hm h.1, (T.row_weak' hm h.1).trans h.2\u27e9\u27e9\nend\n\nlemma ssyt.rbc_le_iff {\u03bc : young_diagram} (T : ssyt \u03bc) {i j val: \u2115} :\n  T.rbc i val \u2264 j \u2194 (i, j) \u2208 \u03bc \u2192 val < T i j :=\nbegin\n  rw \u2190 not_iff_not, push_neg, apply ssyt.lt_rbc_iff\nend\n\nlemma ssyt.rbc_not_cell_or_val_lt {\u03bc : young_diagram} (T : ssyt \u03bc) (i val: \u2115) :\n  (i, T.rbc i val) \u2208 \u03bc \u2192 val < T i (T.rbc i val) :=\nnat.find_spec (T.rbc_aux i val)\n\nlemma ssyt.rbc_eq_iff {\u03bc : young_diagram} (T : ssyt \u03bc) {i j val: \u2115} :\n  T.rbc i val = j \u2194\n  ((i, j) \u2208 \u03bc \u2192 val < T i j) \u2227 (\u2200 j' < j, (i, j') \u2208 \u03bc \u2227 T i j' \u2264 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  {\u03bc \u03bd : young_diagram} (T : ssyt \u03bc) (T' : ssyt \u03bd) {i val : \u2115}\n  (eq_cell : \u2200 {j}, (i, j) \u2208 \u03bc \u2194 (i, j) \u2208 \u03bd)\n  (eq_row : \u2200 {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 \u2190 T'.rbc_eq_iff,\nend\n\n-- section old_rbc\n\n-- lemma ssyt.rbc_aux {\u03bc : young_diagram} (T : ssyt \u03bc) (i val : \u2115) :\n--   \u2203 j, (i, j) \u2209 \u03bc \u2228 val < T i j :=\n-- exists_or_distrib.mpr $ or.inl $ \u03bc.row_len_aux i\n\n-- def ssyt.rbc {\u03bc : young_diagram} (T : ssyt \u03bc) (i val : \u2115) : \u2115 :=\n--   nat.find $ T.rbc_aux i val\n\n-- lemma ssyt.lt_rbc_iff {\u03bc : young_diagram} (T : ssyt \u03bc) {i j val: \u2115} :\n--   j < T.rbc i val \u2194 (i, j) \u2208 \u03bc \u2227 T i j \u2264 val :=\n-- begin\n--   rw [ssyt.rbc, nat.lt_find_iff], push_neg,\n--   exact \u27e8\u03bb h, h _ (le_refl _),\n--          \u03bb h _ hm, \u27e8\u03bc.nw_of (le_refl _) hm h.1, (T.row_weak' hm h.1).trans h.2\u27e9\u27e9\n-- end\n\n-- lemma ssyt.rbc_le_iff {\u03bc : young_diagram} (T : ssyt \u03bc) {i j val: \u2115} :\n--   T.rbc i val \u2264 j \u2194 (i, j) \u2209 \u03bc \u2228 val < T i j :=\n-- begin\n--   rw \u2190 not_iff_not, push_neg, apply ssyt.lt_rbc_iff\n-- end\n\n-- lemma ssyt.rbc_not_cell_or_val_lt {\u03bc : young_diagram} (T : ssyt \u03bc) (i val: \u2115) :\n--   (i, T.rbc i val) \u2209 \u03bc \u2228 val < T i (T.rbc i val) :=\n-- nat.find_spec (T.rbc_aux i val)\n\n-- lemma ssyt.rbc_eq_iff {\u03bc : young_diagram} (T : ssyt \u03bc) {i j val: \u2115} :\n--   T.rbc i val = j \u2194\n--   ((i, j) \u2209 \u03bc \u2228 val < T i j) \u2227 (\u2200 j' < j, (i, j') \u2208 \u03bc \u2227 T i j' \u2264 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--   {\u03bc \u03bd : young_diagram} (T : ssyt \u03bc) (T' : ssyt \u03bd) {i val : \u2115}\n--   (eq_cell : \u2200 {j}, (i, j) \u2208 \u03bc \u2194 (i, j) \u2208 \u03bd)\n--   (eq_row : \u2200 {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 \u2190 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 {\u03bc : young_diagram} (T : ssyt \u03bc) :=\n  (i val : \u2115)\n  (cell_up : \u2200 {i'} (hi' : i' < i), (i', T.rbc i val) \u2208 \u03bc)\n  (up : \u2200 {i'} (hi' : i' < i), T i' (T.rbc i val) < val)\n\ndef ssyt.rbs_start_cert {\u03bc : young_diagram} (T : ssyt \u03bc) (val : \u2115) : T.rbs_cert :=\n{ i := 0,\n  val := val,\n  cell_up := \u03bb _ h, false.rec _ $ nat.not_lt_zero _ h,\n  up := \u03bb _ h, false.rec _ $ nat.not_lt_zero _ h,\n}\n\n@[reducible]\ndef ssyt.rbs_cert.j {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert) : \u2115 :=\n  T.rbc h.i h.val\n\n@[reducible]\ndef ssyt.rbs_cert.out {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert) : \u2115 :=\n  T h.i h.j\n\nlemma ssyt.rbs_cert.val_lt_out\n  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  (cell : (h.i, h.j) \u2208 \u03bc) : h.val < h.out :=\nT.rbc_not_cell_or_val_lt _ _ cell\n\n@[simps]\ndef ssyt.rbs_cert.legal_of_cert {\u03bc : young_diagram} {T : ssyt \u03bc} (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 := \u03bb j' hj', (T.lt_rbc_iff.mp hj').1,\n  left := \u03bb j' hj', (T.lt_rbc_iff.mp hj').2,\n  right := \u03bb j' hj' hcell',\n    le_of_lt $ T.rbc_le_iff.mp (le_of_lt hj') hcell',\n  up := h.up,\n  down := \u03bb i' hi' hcell', begin\n    apply (h.val_lt_out _).trans,\n    exact T.col_strict hi' hcell',\n    exact \u03bc.nw_of (le_of_lt hi') (by refl) hcell',\n  end,\n}\n\n@[simps]\ndef ssyt.rbs_cert.copy {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  {\u03bd : young_diagram} (T' : ssyt \u03bd)\n  (eq_cell : \u2200 i j (hi : i \u2264 h.i), (i, j) \u2208 \u03bc \u2194 (i, j) \u2208 \u03bd)\n  (eq_le_row : \u2200 i j (hi : i \u2264 h.i), T i j = T' i j) : T'.rbs_cert :=\n{ i := h.i,\n  val := h.val,\n  cell_up := \u03bb i' hi', begin\n    rw [\u2190 eq_cell _ _ (le_of_lt hi'),\n        \u2190 T.rbc_eq_of_eq_row T' \n          (\u03bb j, eq_cell _ _ (le_refl _)) (\u03bb j, eq_le_row _ _ (le_refl _))],\n    exact h.cell_up hi',\n  end,\n  up := \u03bb i' hi', begin\n    rw [\u2190 eq_le_row _ _ (le_of_lt hi'),\n        \u2190 T.rbc_eq_of_eq_row T' \n          (\u03bb j, eq_cell _ _ (le_refl _)) (\u03bb j, eq_le_row _ _ (le_refl _))],\n    exact h.up hi',\n  end,\n}\n\nlemma ssyt.rbs_cert.copy_j {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  {\u03bd : young_diagram} (T' : ssyt \u03bd)\n  (eq_cell : \u2200 i j (hi : i \u2264 h.i), (i, j) \u2208 \u03bc \u2194 (i, j) \u2208 \u03bd)\n  (eq_le_row : \u2200 i j (hi : i \u2264 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 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  {\u03bd : young_diagram} (T' : ssyt \u03bd)\n  (eq_cell : \u2200 i j (hi : i \u2264 h.i), (i, j) \u2208 \u03bc \u2194 (i, j) \u2208 \u03bd)\n  (eq_le_row : \u2200 i j (hi : i \u2264 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' {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  {\u03bd : young_diagram} (T' : ssyt \u03bd)\n  (subset_cell_lt_row : \u2200 i j (hi : i < h.i), (i, j) \u2208 \u03bc \u2192 (i, j) \u2208 \u03bd)\n  (eq_cell_row : \u2200 j, (h.i, j) \u2208 \u03bc \u2194 (h.i, j) \u2208 \u03bd)\n  (le_lt_row : \u2200 i j (hi : i < h.i), T' i j \u2264 T i j)\n  (eq_eq_row : \u2200 j, T h.i j = T' h.i j) : T'.rbs_cert :=\n{ i := h.i,\n  val := h.val,\n  cell_up := \u03bb i' hi', begin\n    apply subset_cell_lt_row _ _ hi',\n    rw [\u2190 T.rbc_eq_of_eq_row T' eq_cell_row eq_eq_row],\n    exact h.cell_up hi',\n  end,\n  up := \u03bb i' hi', begin\n    apply lt_of_le_of_lt (le_lt_row _ _ hi'),\n    rw [\u2190 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 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  {\u03bd : young_diagram} (T' : ssyt \u03bd)\n  (subset_cell_lt_row : \u2200 i j (hi : i < h.i), (i, j) \u2208 \u03bc \u2192 (i, j) \u2208 \u03bd)\n  (eq_cell_row : \u2200 j, (h.i, j) \u2208 \u03bc \u2194 (h.i, j) \u2208 \u03bd)\n  (le_lt_row : \u2200 i j (hi : i < h.i), T' i j \u2264 T i j)\n  (eq_eq_row : \u2200 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 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  {\u03bd : young_diagram} (T' : ssyt \u03bd)\n  (subset_cell_lt_row : \u2200 i j (hi : i < h.i), (i, j) \u2208 \u03bc \u2192 (i, j) \u2208 \u03bd)\n  (eq_cell_row : \u2200 j, (h.i, j) \u2208 \u03bc \u2194 (h.i, j) \u2208 \u03bd)\n  (le_lt_row : \u2200 i j (hi : i < h.i), T' i j \u2264 T i j)\n  (eq_eq_row : \u2200 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 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  (cell : (h.i, h.j) \u2208 \u03bc) : ssyt \u03bc := h.legal_of_cert.replace cell\n\ndef ssyt.rbs_cert.rbs_end {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) \u2209 \u03bc) := h.legal_of_cert.add not_cell\n\n@[reducible]\ndef ssyt.rbs_cert.rbs_end_corner {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) \u2209 \u03bc) : \u03bc.outer_corner := (h.legal_of_cert.to_outer not_cell)\n@[reducible]\ndef ssyt.rbs_cert.rbs_end_shape {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) \u2209 \u03bc) : young_diagram := (h.rbs_end_corner not_cell).add\n\nlemma ssyt.rbs_cert.rbs_end_shape_eq_of_ne_row {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (not_cell : (h.i, h.j) \u2209 \u03bc) {i j : \u2115} (h_ne : i \u2260 h.i) :\n(i, j) \u2208 h.rbs_end_shape not_cell \u2194 (i, j) \u2208 \u03bc := \nbegin\n  rw young_diagram.outer_corner.mem_add,\n  apply or_iff_right,\n  rw prod.mk.inj_iff, exact \u03bb h_eq, h_ne h_eq.1,\nend\n\nlemma ssyt.rbs_cert.rbs_entry {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  (cell : (h.i, h.j) \u2208 \u03bc) {i j : \u2115} :\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 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) \u2209 \u03bc) {i j : \u2115} :\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 {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc) {i j : \u2115} (h_ne : i \u2260 h.i) :\nh.rbs cell i j = T i j := \nbegin\n  rw [h.rbs_entry, if_neg], rintro \u27e8\u27e9, exact h_ne rfl\nend\n\nlemma ssyt.rbs_cert.rbs_end_entry_eq_of_ne_row {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (not_cell : (h.i, h.j) \u2209 \u03bc) {i j : \u2115} (h_ne : i \u2260 h.i) :\nh.rbs_end not_cell i j = T i j := \nbegin\n  rw [h.rbs_end_entry, if_neg], rintro \u27e8rfl, _\u27e9, exact h_ne rfl\nend\n\nlemma ssyt.rbs_cert.rbs_entry_le {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc) {i j : \u2115} :\nh.rbs cell i j \u2264 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 {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc) :\n (h.rbs cell).rbc h.i.succ h.out \u2264 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 {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc) :\nlet j' := (h.rbs cell).rbc h.i.succ h.out in\n\u2200 i' (hi' : i' < h.i.succ), (i', j') \u2208 \u03bc :=\nbegin\n  intros j' i' hi',\n  rw nat.lt_succ_iff at hi',\n  apply \u03bc.nw_of hi' (h.next_rbc_le _) cell,\nend\n\nlemma ssyt.rbs_cert.next_cert_up {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc) :\nlet j' := (h.rbs cell).rbc h.i.succ h.out in\n\u2200 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 \u2039i' < h.i\u203a _\n      ...          \u2264 T h.i h.j : T.row_weak' (h.next_rbc_le cell) cell,\n      exact \u03bc.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' \u2264 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) \u2039j' \u2260 h.j\u203a }\nend\n\n@[simps]\ndef ssyt.rbs_cert.next_cert {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc) : (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 {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc)\n  {val' : \u2115} (hval : h.val \u2264 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 {\u03bc : young_diagram} {T : ssyt \u03bc} \n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc)\n  {val' : \u2115} (hval : h.val \u2264 val') \n  (cell' : (h.i, (h.rbs cell).rbc h.i val') \u2208 \u03bc) :\nh.out \u2264 (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 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.rbs_cert)\n  (not_cell : (h.i, h.j) \u2209 \u03bc) : \n  (h.legal_of_cert.to_outer not_cell).add.size = \u03bc.size + 1 :=\nby apply young_diagram.outer_corner.add_size\n\nlemma ssyt.rbs_cert.rbs_wt {\u03bc : young_diagram} (T : ssyt \u03bc) (val : \u2115)\n  (h : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc) :\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 {\u03bc : young_diagram} (T : ssyt \u03bc) (val : \u2115)\n  (h : T.rbs_cert) (not_cell : (h.i, h.j) \u2209 \u03bc) :\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  \u2192h1  T1\n\u2193h      \u2193h'\nT' \u2192h1' Tf\n\ngives the same result, assuming the bumps are in different rows.\n-/\nlemma ssyt.rbs_cert.rbs_comm {\u03bc : young_diagram}\n  {T : ssyt \u03bc} (h h1 : T.rbs_cert) (cell : (h.i, h.j) \u2208 \u03bc) (cell1 : (h1.i, h1.j) \u2208 \u03bc)\n  (h_h1_i : h1.i \u2260 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) \u2208 \u03bc := by {\n    rwa [hi, (_ : h'.j = h.j)],\n    rw [ssyt.rbs_cert.j, hi, hval, ssyt.rbc_eq_of_eq_row],\n    exact \u03bb _, iff.rfl,\n    intro j, rw h1.rbs_entry_eq_of_ne_row, exact h_h1_i.symm }) \n  (cell1' : (h1'.i, h1'.j) \u2208 \u03bc := by {\n    rwa [h1i, (_ : h1'.j = h1.j)],\n    rw [ssyt.rbs_cert.j, h1i, h1val, ssyt.rbc_eq_of_eq_row],\n    exact \u03bb _, iff.rfl,\n    intro j, rw h.rbs_entry_eq_of_ne_row, exact h_h1_i })\n  (i j : \u2115) : 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 \u03bb _, 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 \u03bb _, 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 (\u03bc5331.lowest_ssyt.rbs_start_cert 0).rbs sorry\n-- #eval (\u03bc5331.lowest_ssyt.rbs_start_cert 2).rbs sorry\n-- #eval (\u03bc5331.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 `\u03b1` to `\u03b2` assuming `cond` is true.\n  Used by the tactic `lift`. -/\nclass CanLift (\u03b1 \u03b2 : Sort _) (coe : outParam <| \u03b2 \u2192 \u03b1) (cond : outParam <| \u03b1 \u2192 Prop) where\n  prf : \u2200 x : \u03b1, cond x \u2192 \u2203 y : \u03b2, coe y = x\n#align can_lift CanLift\n-/\n\ninstance : CanLift \u2124 \u2115 coe ((\u00b7 \u2264 \u00b7) 0) :=\n  \u27e8fun n hn => \u27e8n.natAbs, Int.natAbs_of_nonneg hn\u27e9\u27e9\n\n#print Pi.canLift /-\n/-- Enable automatic handling of pi types in `can_lift`. -/\ninstance Pi.canLift (\u03b9 : Sort _) (\u03b1 \u03b2 : \u03b9 \u2192 Sort _) (coe : \u2200 i, \u03b2 i \u2192 \u03b1 i) (P : \u2200 i, \u03b1 i \u2192 Prop)\n    [\u2200 i : \u03b9, CanLift (\u03b1 i) (\u03b2 i) (coe i) (P i)] :\n    CanLift (\u2200 i : \u03b9, \u03b1 i) (\u2200 i : \u03b9, \u03b2 i) (fun f i => coe i (f i)) fun f => \u2200 i, P i (f i)\n    where prf f hf :=\n    \u27e8fun i => Classical.choose (CanLift.prf (f i) (hf i)),\n      funext fun i => Classical.choose_spec (CanLift.prf (f i) (hf i))\u27e9\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 {\u03b9 : Sort.{u1}} {\u03b1 : \u03b9 -> Sort.{u2}} [ne : forall (i : \u03b9), Nonempty.{u2} (\u03b1 i)] {p : \u03b9 -> Prop} (f : forall (i : Subtype.{u1} \u03b9 p), \u03b1 ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b9 p) \u03b9 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (coeSubtype.{u1} \u03b9 (fun (x : \u03b9) => p x))))) i)), Exists.{imax u1 u2} (forall (i : \u03b9), \u03b1 i) (fun (g : forall (i : \u03b9), \u03b1 i) => Eq.{imax (max 1 u1) u2} (forall (i : Subtype.{u1} \u03b9 p), \u03b1 ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b9 p) \u03b9 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (coeSubtype.{u1} \u03b9 (fun (x : \u03b9) => p x))))) i)) (fun (i : Subtype.{u1} \u03b9 p) => g ((fun (a : Sort.{max 1 u1}) (b : Sort.{u1}) [self : HasLiftT.{max 1 u1, u1} a b] => self.0) (Subtype.{u1} \u03b9 p) \u03b9 (HasLiftT.mk.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (CoeTC\u2093.coe.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (coeBase.{max 1 u1, u1} (Subtype.{u1} \u03b9 p) \u03b9 (coeSubtype.{u1} \u03b9 (fun (x : \u03b9) => p x))))) i)) f)\nbut is expected to have type\n  forall {\u03b9 : Sort.{u2}} {\u03b1 : \u03b9 -> Sort.{u1}} [ne : forall (i : \u03b9), Nonempty.{u1} (\u03b1 i)] {p : \u03b9 -> Prop} (f : forall (i : Subtype.{u2} \u03b9 p), \u03b1 (Subtype.val.{u2} \u03b9 p i)), Exists.{imax u2 u1} (forall (i : \u03b9), \u03b1 i) (fun (g : forall (i : \u03b9), \u03b1 i) => Eq.{imax (max 1 u2) u1} (forall (i : Subtype.{u2} \u03b9 p), \u03b1 (Subtype.val.{u2} \u03b9 p i)) (fun (i : Subtype.{u2} \u03b9 p) => g (Subtype.val.{u2} \u03b9 p i)) f)\nCase conversion may be inaccurate. Consider using '#align subtype.exists_pi_extension Subtype.exists_pi_extension\u2093'. -/\ntheorem Subtype.exists_pi_extension {\u03b9 : Sort _} {\u03b1 : \u03b9 \u2192 Sort _} [ne : \u2200 i, Nonempty (\u03b1 i)]\n    {p : \u03b9 \u2192 Prop} (f : \u2200 i : Subtype p, \u03b1 i) :\n    \u2203 g : \u2200 i : \u03b9, \u03b1 i, (fun i : Subtype p => g i) = f := by\n  classical\n    refine' \u27e8fun i => if hi : p i then f \u27e8i, hi\u27e9 else Classical.choice (Ne i), funext _\u27e9\n    rintro \u27e8i, hi\u27e9\n    exact dif_pos hi\n#align subtype.exists_pi_extension Subtype.exists_pi_extension\n\n#print PiSubtype.canLift /-\ninstance PiSubtype.canLift (\u03b9 : Sort _) (\u03b1 : \u03b9 \u2192 Sort _) [ne : \u2200 i, Nonempty (\u03b1 i)] (p : \u03b9 \u2192 Prop) :\n    CanLift (\u2200 i : Subtype p, \u03b1 i) (\u2200 i, \u03b1 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' (\u03b9 : Sort _) (\u03b1 : Sort _) [ne : Nonempty \u03b1] (p : \u03b9 \u2192 Prop) :\n    CanLift (Subtype p \u2192 \u03b1) (\u03b9 \u2192 \u03b1) (fun f i => f i) fun _ => True :=\n  PiSubtype.canLift \u03b9 (fun _ => \u03b1) p\n#align pi_subtype.can_lift' PiSubtype.canLift'\n-/\n\n#print Subtype.canLift /-\ninstance Subtype.canLift {\u03b1 : Sort _} (p : \u03b1 \u2192 Prop) : CanLift \u03b1 { x // p x } coe p\n    where prf a ha := \u27e8\u27e8a, ha\u27e9, rfl\u27e9\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 \u00d7 Bool) := do\n  let expected_prf_ty := P.app e\n  let expected_prf_ty \u2190 simp_lemmas.mk.dsimplify [] expected_prf_ty { failIfUnchanged := false }\n  match h with\n    | some h => do\n      let e \u2190 decorate_error \"lift tactic failed.\" (i_to_expr ``(($(h) : $(expected_prf_ty))))\n      return (e, tt)\n    | none => do\n      let prf_nm \u2190 get_unused_name\n      let prf \u2190 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 \u2190 i_to_expr p\n          let old_tp \u2190 infer_type e\n          let new_tp \u2190 i_to_expr ` `( ( $ ( t ) : Sort _ ) )\n          let coe \u2190 i_to_expr ` `( $ ( new_tp ) \u2192 $ ( old_tp ) ) >>= mk_meta_var\n          let P \u2190 i_to_expr ` `( $ ( old_tp ) \u2192 Prop ) >>= mk_meta_var\n          let inst_type \u2190 mk_app ` ` CanLift [ old_tp , new_tp , coe , P ]\n          let\n            inst\n              \u2190\n              mk_instance inst_type\n                <|>\n                (\n                    f!\n                      \"Failed to find a lift from {\n                        ( \u2190 old_tp )\n                        } to {\n                        ( \u2190 new_tp )\n                        }. Provide an instance of\n                          { \u2190 inst_type }\"\n                    )\n                  >>=\n                  fail\n          let inst \u2190 instantiate_mvars inst\n          let coe \u2190 instantiate_mvars coe\n          let P \u2190 instantiate_mvars P\n          let ( prf_cond , b ) \u2190 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 \u2190 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              \u2190\n              if\n                n \u2260 [ ]\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              \u2190\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 \u2190 get_unused_name\n          let temp_e \u2190 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            ( \u00ac e )\n              (\n                get_local eq_nm\n                  >>=\n                  fun\n                    e\n                      =>\n                      interactive.rw\n                        \u27e8 [ \u27e8 \u27e8 0 , 0 \u27e9 , tt , pexpr.of_expr e \u27e9 ] , none \u27e9 Interactive.Loc.wildcard\n                )\n          if\n            h_prf_nm\n            :\n            prf_nm \u2227 n 2 \u2260 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 : \u2124` and `hn : n \u2265 0` then the tactic `lift n to \u2115 using hn` creates a new\n  constant of type `\u2115`, also named `n` and replaces all occurrences of the old variable `(n : \u2124)`\n  with `\u2191n` (where `n` in the new variable). It will remove `n` and `hn` from the context.\n  + So for example the tactic `lift n to \u2115 using hn` transforms the goal\n    `n : \u2124, hn : n \u2265 0, h : P n \u22a2 n = 3` to `n : \u2115, h : P \u2191n \u22a2 \u2191n = 3`\n    (here `P` is some term of type `\u2124 \u2192 Prop`).\n* The argument `using hn` is optional, the tactic `lift n to \u2115` does the same, but also creates a\n  new subgoal that `n \u2265 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 \u2115` transforms the goal\n    `n : \u2124, h : P n \u22a2 n = 3` to two goals\n    `n : \u2124, h : P n \u22a2 n \u2265 0` and `n : \u2115, h : P \u2191n \u22a2 \u2191n = 3`.\n* You can also use `lift n to \u2115 using e` where `e` is any expression of type `n \u2265 0`.\n* Use `lift n to \u2115 with k` to specify the name of the new variable.\n* Use `lift n to \u2115 with k hk` to also specify the name of the equality `\u2191k = 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 \u2115 with k hk` where `e` is any expression of type `\u2124`.\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 \u2115 using hn with k hk` transforms the goal\n    `n : \u2124, hn : n + 3 \u2265 0, h : P (n + 3) \u22a2 n + 3 = 2 * n` to the goal\n    `n : \u2124, k : \u2115, hk : \u2191k = n + 3, h : P \u2191k \u22a2 \u2191k = 2 * n`.\n* The tactic `lift n to \u2115 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 \u2115 using h with n rfl h`.\n* More generally, this can lift an expression from `\u03b1` to `\u03b2` assuming that there is an instance\n  of `can_lift \u03b1 \u03b2`. In this case the proof obligation is specified by `can_lift.cond`.\n* Given an instance `can_lift \u03b2 \u03b3`, it can also lift `\u03b1 \u2192 \u03b2` to `\u03b1 \u2192 \u03b3`; more generally, given\n  `\u03b2 : \u03a0 a : \u03b1, Type*`, `\u03b3 : \u03a0 a : \u03b1, Type*`, and `[\u03a0 a : \u03b1, can_lift (\u03b2 a) (\u03b3 a)]`, it\n  automatically generates an instance `can_lift (\u03a0 a, \u03b2 a) (\u03a0 a, \u03b3 a)`.\n\n`lift` is in some sense dual to the `zify` tactic. `lift (z : \u2124) to \u2115` will change the type of an\ninteger `z` (in the supertype) to `\u2115` (the subtype), given a proof that `z \u2265 0`;\npropositions concerning `z` will still be over `\u2124`. `zify` changes propositions about `\u2115` (the\nsubtype) to propositions about `\u2124` (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\u2081 w\u2082\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' : \u2200 {x y}, x \u2208 carrier \u2192 y \u2208 carrier \u2192 \u2045x, y\u2046 \u2208 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\u27e8{ lie_mem' := \u03bb 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) }\u27e9\n\ninstance : inhabited (lie_subalgebra R L) := \u27e80\u27e9\ninstance : has_coe (lie_subalgebra R L) (submodule R L) := \u27e8lie_subalgebra.to_submodule\u27e9\n\nnamespace lie_subalgebra\n\ninstance : set_like (lie_subalgebra R L) L :=\n{ coe := \u03bb L', L',\n  coe_injective' := \u03bb L' L'' h, by { rcases L' with \u27e8\u27e8\u27e9\u27e9, rcases L'' with \u27e8\u27e8\u27e9\u27e9, congr' } }\n\ninstance : add_subgroup_class (lie_subalgebra R L) L :=\n{ add_mem := \u03bb L', L'.add_mem',\n  zero_mem := \u03bb L', L'.zero_mem',\n  neg_mem := \u03bb L' x hx, show -x \u2208 (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      := \u03bb x y, \u27e8\u2045x.val, y.val\u2046, L'.lie_mem' x.property y.property\u27e9,\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\u2081 : Type*} [semiring R\u2081]\n\n/-- A Lie subalgebra inherits module structures from `L`. -/\ninstance [has_scalar R\u2081 R] [module R\u2081 L] [is_scalar_tower R\u2081 R L]\n  (L' : lie_subalgebra R L) : module R\u2081 L' :=\nL'.to_submodule.module'\n\ninstance [has_scalar R\u2081 R] [has_scalar R\u2081\u1d50\u1d52\u1d56 R] [module R\u2081 L] [module R\u2081\u1d50\u1d52\u1d56 L]\n  [is_scalar_tower R\u2081 R L] [is_scalar_tower R\u2081\u1d50\u1d52\u1d56 R L] [is_central_scalar R\u2081 L]\n  (L' : lie_subalgebra R L) : is_central_scalar R\u2081 L' :=\nL'.to_submodule.is_central_scalar\n\ninstance [has_scalar R\u2081 R] [module R\u2081 L] [is_scalar_tower R\u2081 R L]\n  (L' : lie_subalgebra R L) : is_scalar_tower R\u2081 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) \u2208 L' := zero_mem L'\nprotected lemma add_mem {x y : L} : x \u2208 L' \u2192 y \u2208 L' \u2192 (x + y : L) \u2208 L' := add_mem\nprotected lemma sub_mem {x y : L} : x \u2208 L' \u2192 y \u2208 L' \u2192 (x - y : L) \u2208 L' := sub_mem\n\nlemma smul_mem (t : R) {x : L} (h : x \u2208 L') : t \u2022 x \u2208 L' := (L' : submodule R L).smul_mem t h\n\nlemma lie_mem {x y : L} (hx : x \u2208 L') (hy : y \u2208 L') : (\u2045x, y\u2046 : L) \u2208 L' := L'.lie_mem' hx hy\n\n@[simp] lemma mem_carrier {x : L} : x \u2208 L'.carrier \u2194 x \u2208 (L' : set L) := iff.rfl\n\n@[simp] lemma mem_mk_iff (S : set L) (h\u2081 h\u2082 h\u2083 h\u2084) {x : L} :\n  x \u2208 (\u27e8\u27e8S, h\u2081, h\u2082, h\u2083\u27e9, h\u2084\u27e9 : lie_subalgebra R L) \u2194 x \u2208 S :=\niff.rfl\n\n@[simp] lemma mem_coe_submodule {x : L} : x \u2208 (L' : submodule R L) \u2194 x \u2208 L' := iff.rfl\n\nlemma mem_coe {x : L} : x \u2208 (L' : set L) \u2194 x \u2208 L' := iff.rfl\n\n@[simp, norm_cast] lemma coe_bracket (x y : L') : (\u2191\u2045x, y\u2046 : L) = \u2045(\u2191x : L), \u2191y\u2046 := rfl\n\nlemma ext_iff (x y : L') : x = y \u2194 (x : L) = y := subtype.ext_iff\n\nlemma coe_zero_iff_zero (x : L') : (x : L) = 0 \u2194 x = 0 := (ext_iff L' x 0).symm\n\n@[ext] lemma ext (L\u2081' L\u2082' : lie_subalgebra R L) (h : \u2200 x, x \u2208 L\u2081' \u2194 x \u2208 L\u2082') :\n  L\u2081' = L\u2082' :=\nset_like.ext h\n\nlemma ext_iff' (L\u2081' L\u2082' : lie_subalgebra R L) : L\u2081' = L\u2082' \u2194 \u2200 x, x \u2208 L\u2081' \u2194 x \u2208 L\u2082' :=\nset_like.ext_iff\n\n@[simp] lemma mk_coe (S : set L) (h\u2081 h\u2082 h\u2083 h\u2084) :\n  ((\u27e8\u27e8S, h\u2081, h\u2082, h\u2083\u27e9, h\u2084\u27e9 : 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 \u2192 set L) :=\nset_like.coe_injective\n\n@[norm_cast] theorem coe_set_eq (L\u2081' L\u2082' : lie_subalgebra R L) :\n  (L\u2081' : set L) = L\u2082' \u2194 L\u2081' = L\u2082' := set_like.coe_set_eq\n\nlemma to_submodule_injective :\n  function.injective (coe : lie_subalgebra R L \u2192 submodule R L) :=\n\u03bb L\u2081' L\u2082' h, by { rw set_like.ext'_iff at h, rw \u2190 coe_set_eq, exact h, }\n\n@[simp] lemma coe_to_submodule_eq_iff (L\u2081' L\u2082' : lie_subalgebra R L) :\n  (L\u2081' : submodule R L) = (L\u2082' : submodule R L) \u2194 L\u2081' = L\u2082' :=\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\u2081} [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' \u2286 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     := \u03bb x m, \u2045(x : L), m\u2046,\n  add_lie     := \u03bb x y m, add_lie x y m,\n  lie_add     := \u03bb x y m, lie_add x y m,\n  leibniz_lie := \u03bb x y m, leibniz_lie x y m, }\n\n@[simp] lemma coe_bracket_of_module (x : L') (m : M) : \u2045x, m\u2046 = \u2045(x : L), m\u2046 := rfl\n\nvariables [module R M] [lie_module R L M]\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' \u2286 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 := \u03bb t x m, by simp only [coe_bracket_of_module, smul_lie, submodule.coe_smul_of_tower],\n  lie_smul := \u03bb t x m, by simp only [coe_bracket_of_module, lie_smul], }\n\n/-- An `L`-equivariant map of Lie modules `M \u2192 N` is `L'`-equivariant for any Lie subalgebra\n`L' \u2286 L`. -/\ndef _root_.lie_module_hom.restrict_lie (f : M \u2192\u2097\u2045R,L\u2046 N) (L' : lie_subalgebra R L) : M \u2192\u2097\u2045R,L'\u2046 N :=\n{ map_lie' := \u03bb x m, f.map_lie \u2191x m,\n  .. (f : M \u2192\u2097[R] N)}\n\n@[simp] lemma _root_.lie_module_hom.coe_restrict_lie (f : M \u2192\u2097\u2045R,L\u2046 N) :\n  \u21d1(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' \u2192\u2097\u2045R\u2046 L :=\n{ map_lie' := \u03bb 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 : \u21d1L'.incl = coe := rfl\n\n/-- The embedding of a Lie subalgebra into the ambient space as a morphism of Lie modules. -/\ndef incl' : L' \u2192\u2097\u2045R,L'\u2046 L :=\n{ map_lie' := \u03bb 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' : \u21d1L'.incl' = coe := rfl\n\nend lie_subalgebra\n\nvariables {R L} {L\u2082 : Type w} [lie_ring L\u2082] [lie_algebra R L\u2082]\nvariables (f : L \u2192\u2097\u2045R\u2046 L\u2082)\n\nnamespace lie_hom\n\n/-- The range of a morphism of Lie algebras is a Lie subalgebra. -/\ndef range : lie_subalgebra R L\u2082 :=\n{ lie_mem' := \u03bb x y,\n    show x \u2208 f.to_linear_map.range \u2192 y \u2208 f.to_linear_map.range \u2192 \u2045x, y\u2046 \u2208 f.to_linear_map.range,\n    by { repeat { rw linear_map.mem_range }, rintros \u27e8x', hx\u27e9 \u27e8y', hy\u27e9, refine \u27e8\u2045x', y'\u2046, _\u27e9,\n         rw [\u2190hx, \u2190hy], change f \u2045x', y'\u2046 = \u2045f x', f y'\u2046, rw map_lie, },\n  ..(f : L \u2192\u2097[R] L\u2082).range }\n\n@[simp] lemma range_coe : (f.range : set L\u2082) = set.range f :=\nlinear_map.range_coe \u2191f\n\n@[simp] lemma mem_range (x : L\u2082) : x \u2208 f.range \u2194 \u2203 (y : L), f y = x := linear_map.mem_range\n\nlemma mem_range_self (x : L) : f x \u2208 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 \u2192\u2097\u2045R\u2046 f.range :=\n{ map_lie' := \u03bb x y, by { apply subtype.ext, exact f.map_lie x y, },\n  ..(f : L \u2192\u2097[R] L\u2082).range_restrict, }\n\n@[simp] lemma range_restrict_apply (x : L) : f.range_restrict x = \u27e8f x, f.mem_range_self x\u27e9 := rfl\n\nlemma surjective_range_restrict : function.surjective (f.range_restrict) :=\nbegin\n  rintros \u27e8y, hy\u27e9,\n  erw mem_range at hy, obtain \u27e8x, rfl\u27e9 := 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 \u2243\u2097\u2045R\u2046 f.range :=\nlie_equiv.of_bijective f.range_restrict (\u03bb 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 = \u27e8f x, mem_range_self f x\u27e9 :=\nrfl\n\nend lie_hom\n\nlemma submodule.exists_lie_subalgebra_coe_eq_iff (p : submodule R L) :\n  (\u2203 (K : lie_subalgebra R L), \u2191K = p) \u2194 \u2200 (x y : L), x \u2208 p \u2192 y \u2208 p \u2192 \u2045x, y\u2046 \u2208 p :=\nbegin\n  split,\n  { rintros \u27e8K, rfl\u27e9, 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\u2082 : lie_subalgebra R L\u2082)\n\n@[simp] lemma incl_range : K.incl.range = K :=\nby { rw \u2190 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\u2082 :=\n{ lie_mem' := \u03bb x y hx hy, by\n  { erw submodule.mem_map at hx, rcases hx with \u27e8x', hx', hx\u27e9, rw \u2190hx,\n    erw submodule.mem_map at hy, rcases hy with \u27e8y', hy', hy\u27e9, rw \u2190hy,\n    erw submodule.mem_map,\n    exact \u27e8\u2045x', y'\u2046, K.lie_mem hx' hy', f.map_lie x' y'\u27e9, },\n..((K : submodule R L).map (f : L \u2192\u2097[R] L\u2082)) }\n\n@[simp] lemma mem_map (x : L\u2082) : x \u2208 K.map f \u2194 \u2203 (y : L), y \u2208 K \u2227 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 \u2243\u2097\u2045R\u2046 L\u2082) (x : L\u2082) :\n  x \u2208 K.map (e : L \u2192\u2097\u2045R\u2046 L\u2082) \u2194 x \u2208 (K : submodule R L).map (e : L \u2192\u2097[R] L\u2082) :=\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' := \u03bb x y hx hy, by\n    { suffices : \u2045f x, f y\u2046 \u2208 K\u2082, by { simp [this], }, exact K\u2082.lie_mem hx hy, },\n  ..((K\u2082 : submodule R L\u2082).comap (f : L \u2192\u2097[R] L\u2082)), }\n\nsection lattice_structure\n\nopen set\n\ninstance : partial_order (lie_subalgebra R L) :=\n{ le := \u03bb N N', \u2200 \u2983x\u2984, x \u2208 N \u2192 x \u2208 N', -- Overriding `le` like this gives a better defeq.\n  ..partial_order.lift (coe : lie_subalgebra R L \u2192 set L) coe_injective }\n\nlemma le_def : K \u2264 K' \u2194 (K : set L) \u2286 K' := iff.rfl\n\n@[simp, norm_cast] lemma coe_submodule_le_coe_submodule : (K : submodule R L) \u2264 K' \u2194 K \u2264 K' :=\niff.rfl\n\ninstance : has_bot (lie_subalgebra R L) := \u27e80\u27e9\n\n@[simp] lemma bot_coe : ((\u22a5 : lie_subalgebra R L) : set L) = {0} := rfl\n\n@[simp] lemma bot_coe_submodule : ((\u22a5 : lie_subalgebra R L) : submodule R L) = \u22a5 := rfl\n\n@[simp] lemma mem_bot (x : L) : x \u2208 (\u22a5 : lie_subalgebra R L) \u2194 x = 0 := mem_singleton_iff\n\ninstance : has_top (lie_subalgebra R L) :=\n\u27e8{ lie_mem' := \u03bb x y hx hy, mem_univ \u2045x, y\u2046,\n   ..(\u22a4 : submodule R L) }\u27e9\n\n@[simp] lemma top_coe : ((\u22a4 : lie_subalgebra R L) : set L) = univ := rfl\n\n@[simp] lemma top_coe_submodule : ((\u22a4 : lie_subalgebra R L) : submodule R L) = \u22a4 := rfl\n\n@[simp] lemma mem_top (x : L) : x \u2208 (\u22a4 : lie_subalgebra R L) := mem_univ x\n\nlemma _root_.lie_hom.range_eq_map : f.range = map f \u22a4 :=\nby { ext, simp }\n\ninstance : has_inf (lie_subalgebra R L) :=\n\u27e8\u03bb K K', { lie_mem' := \u03bb x y hx hy, mem_inter (K.lie_mem hx.1 hy.1) (K'.lie_mem hx.2 hy.2),\n            ..(K \u2293 K' : submodule R L) }\u27e9\n\ninstance : has_Inf (lie_subalgebra R L) :=\n\u27e8\u03bb S, { lie_mem' := \u03bb 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\u2082, 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 \u2208 S} }\u27e9\n\n@[simp] theorem inf_coe : (\u2191(K \u2293 K') : set L) = K \u2229 K' := rfl\n\n@[simp] lemma Inf_coe_to_submodule (S : set (lie_subalgebra R L)) :\n  (\u2191(Inf S) : submodule R L) = Inf {(s : submodule R L) | s \u2208 S} := rfl\n\n@[simp] lemma Inf_coe (S : set (lie_subalgebra R L)) : (\u2191(Inf S) : set L) = \u22c2 s \u2208 S, (s : set L) :=\nbegin\n  rw [\u2190 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\u2082, exists_imp_distrib],\nend\n\nlemma Inf_glb (S : set (lie_subalgebra R L)) : is_glb S (Inf S) :=\nbegin\n  have h : \u2200 (K K' : lie_subalgebra R L), (K : set L) \u2264 K' \u2194 K \u2264 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          := \u22a5,\n  bot_le       := \u03bb N _ h, by { rw mem_bot at h, rw h, exact N.zero_mem', },\n  top          := \u22a4,\n  le_top       := \u03bb _ _ _, trivial,\n  inf          := (\u2293),\n  le_inf       := \u03bb N\u2081 N\u2082 N\u2083 h\u2081\u2082 h\u2081\u2083 m hm, \u27e8h\u2081\u2082 hm, h\u2081\u2083 hm\u27e9,\n  inf_le_left  := \u03bb _ _ _, and.left,\n  inf_le_right := \u03bb _ _ _, and.right,\n  ..complete_lattice_of_Inf _ Inf_glb }\n\ninstance : add_comm_monoid (lie_subalgebra R L) :=\n{ add       := (\u2294),\n  add_assoc := \u03bb _ _ _, sup_assoc,\n  zero      := \u22a5,\n  zero_add  := \u03bb _, bot_sup_eq,\n  add_zero  := \u03bb _, sup_bot_eq,\n  add_comm  := \u03bb _ _, sup_comm, }\n\ninstance : canonically_ordered_add_monoid (lie_subalgebra R L) :=\n{ add_le_add_left := \u03bb a b, sup_le_sup_left,\n  exists_add_of_le := \u03bb a b h, \u27e8b, (sup_eq_right.2 h).symm\u27e9,\n  le_self_add := \u03bb 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 \u2294 K' := rfl\n\n@[norm_cast, simp] lemma inf_coe_to_submodule :\n  (\u2191(K \u2293 K') : submodule R L) = (K : submodule R L) \u2293 (K' : submodule R L) := rfl\n\n@[simp] lemma mem_inf (x : L) : x \u2208 K \u2293 K' \u2194 x \u2208 K \u2227 x \u2208 K' :=\nby rw [\u2190 mem_coe_submodule, \u2190 mem_coe_submodule, \u2190 mem_coe_submodule, inf_coe_to_submodule,\n  submodule.mem_inf]\n\nlemma eq_bot_iff : K = \u22a5 \u2194 \u2200 (x : L), x \u2208 K \u2192 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 \u21a5(\u22a5 : lie_subalgebra R L)) :=\nbegin\n  apply subsingleton_of_bot_eq_top,\n  ext \u27e8x, hx\u27e9, change x \u2208 \u22a5 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 \u21a5(\u22a5 : lie_subalgebra R L) :=\nshow subsingleton ((\u22a5 : 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 \u2192 lie_subalgebra R L \u2192 Prop) :=\n  let f : ((>) : lie_subalgebra R L \u2192 lie_subalgebra R L \u2192 Prop) \u2192r\n          ((>) : submodule R L \u2192 submodule R L \u2192 Prop) :=\n  { to_fun       := coe,\n    map_rel' := \u03bb 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 \u2264 K')\n\n/-- Given two nested Lie subalgebras `K \u2286 K'`, the inclusion `K \u21aa K'` is a morphism of Lie\nalgebras. -/\ndef hom_of_le : K \u2192\u2097\u2045R\u2046 K' :=\n{ map_lie' := \u03bb 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 = \u27e8x.1, h x.2\u27e9 := rfl\n\nlemma hom_of_le_injective : function.injective (hom_of_le h) :=\n\u03bb 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 \u2286 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 \u2208 of_le h \u2194 (x : L) \u2208 K :=\nbegin\n  simp only [of_le, hom_of_le_apply, lie_hom.mem_range],\n  split,\n  { rintros \u27e8y, rfl\u27e9, exact y.property, },\n  { intros h, use \u27e8(x : L), h\u27e9, 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 \u2286 K'`, there is a natural equivalence from `K` to its image in\n`K'`.  -/\nnoncomputable def equiv_of_le : K \u2243\u2097\u2045R\u2046 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\u2082} :\n  map f K \u2264 K' \u2194 K \u2264 comap f K' := set.image_subset_iff\n\nlemma gc_map_comap : galois_connection (map f) (comap f) := \u03bb 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 \u2286 L`. -/\ndef lie_span : lie_subalgebra R L := Inf {N | s \u2286 N}\n\nvariables {R L s}\n\nlemma mem_lie_span {x : L} : x \u2208 lie_span R L s \u2194 \u2200 K : lie_subalgebra R L, s \u2286 K \u2192 x \u2208 K :=\nby { change x \u2208 (lie_span R L s : set L) \u2194 _, erw Inf_coe, exact set.mem_Inter\u2082, }\n\nlemma subset_lie_span : s \u2286 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 \u2264 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 \u2264 K \u2194 s \u2286 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 \u2286 t) : lie_span R L s \u2264 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 \u2194 \u2203 (K : lie_subalgebra R L), \u2191K = p :=\nbegin\n  rw p.exists_lie_subalgebra_coe_eq_iff, split; intros h,\n  { intros x m hm, rw [\u2190 h, mem_coe_submodule], exact lie_mem _ (subset_lie_span hm), },\n  { rw [\u2190 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 \u2192 lie_subalgebra R L) coe :=\n{ choice    := \u03bb s _, lie_span R L s,\n  gc        := \u03bb s t, lie_span_le,\n  le_l_u    := \u03bb s, subset_lie_span,\n  choice_eq := \u03bb s h, rfl }\n\n@[simp] lemma span_empty : lie_span R L (\u2205 : set L) = \u22a5 :=\n(lie_subalgebra.gi R L).gc.l_bot\n\n@[simp] lemma span_univ : lie_span R L (set.univ : set L) = \u22a4 :=\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 \u222a t) = lie_span R L s \u2294 lie_span R L t :=\n(lie_subalgebra.gi R L).gc.l_sup\n\nlemma span_Union {\u03b9} (s : \u03b9 \u2192 set L) : lie_span R L (\u22c3 i, s i) = \u2a06 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\u2081 : Type v} {L\u2082 : Type w}\nvariables [comm_ring R] [lie_ring L\u2081] [lie_ring L\u2082] [lie_algebra R L\u2081] [lie_algebra R L\u2082]\n\n/-- An injective Lie algebra morphism is an equivalence onto its range. -/\nnoncomputable def of_injective (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h : function.injective f) :\n  L\u2081 \u2243\u2097\u2045R\u2046 f.range :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, simpa },\n  .. linear_equiv.of_injective (f : L\u2081 \u2192\u2097[R] L\u2082) $ by rwa [lie_hom.coe_to_linear_map] }\n\n@[simp] lemma of_injective_apply (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h : function.injective f) (x : L\u2081) :\n  \u2191(of_injective f h x) = f x := rfl\n\nvariables (L\u2081' L\u2081'' : lie_subalgebra R L\u2081) (L\u2082' : lie_subalgebra R L\u2082)\n\n/-- Lie subalgebras that are equal as sets are equivalent as Lie algebras. -/\ndef of_eq (h : (L\u2081' : set L\u2081) = L\u2081'') : L\u2081' \u2243\u2097\u2045R\u2046 L\u2081'' :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, simp, },\n  ..(linear_equiv.of_eq \u2191L\u2081' \u2191L\u2081''\n      (by {ext x, change x \u2208 (L\u2081' : set L\u2081) \u2194 x \u2208 (L\u2081'' : set L\u2081), rw h, } )) }\n\n@[simp] lemma of_eq_apply (L L' : lie_subalgebra R L\u2081) (h : (L : set L\u2081) = L') (x : L) :\n  (\u2191(of_eq L L' h x) : L\u2081) = x := rfl\n\nvariables (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082)\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef lie_subalgebra_map : L\u2081'' \u2243\u2097\u2045R\u2046 (L\u2081''.map e : lie_subalgebra R L\u2082) :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, exact lie_hom.map_lie (\u2191e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) \u2191x \u2191y, }\n  ..(linear_equiv.submodule_map (e : L\u2081 \u2243\u2097[R] L\u2082) \u2191L\u2081'') }\n\n@[simp] lemma lie_subalgebra_map_apply (x : L\u2081'') : \u2191(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\u2081'.map \u2191e = L\u2082') : L\u2081' \u2243\u2097\u2045R\u2046 L\u2082' :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, exact lie_hom.map_lie (\u2191e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) \u2191x \u2191y, },\n  ..(linear_equiv.of_submodules (e : L\u2081 \u2243\u2097[R] L\u2082) \u2191L\u2081' \u2191L\u2082' (by { rw \u2190h, refl, })) }\n\n@[simp] lemma of_subalgebras_apply (h : L\u2081'.map \u2191e = L\u2082') (x : L\u2081') :\n  \u2191(e.of_subalgebras _ _ h x) = e x := rfl\n\n@[simp] lemma of_subalgebras_symm_apply (h : L\u2081'.map \u2191e = L\u2082') (x : L\u2082') :\n  \u2191((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 : \u2115 \u2192 \u211d // \u2200 (n : \u2115), u n \u2265 0}\ndef nnseqQ := {u : \u2115 \u2192 \u211a // \u2200 (n : \u2115), u n \u2265 0}\n\ndef RoC (\u03c6: \u2115  \u2192 \u2115 ) (\u03b1 : nnseqR) := \u2200 k > (0 : \u2115 ), \u2200 n m \u2265 \u03c6 k , abs((\u03b1.1 m) - (\u03b1.1 n)) < (1/k) \n\n\ndef temp: \u2200 \u03b5>(0:\u211d), \u2203 k > (0: \u2115 ) , (1/k :\u211d) < \u03b5:=\nbegin\nintros,\nuse  nat.ceil(1 / \u03b5) + 1,\nhave h\u2081: (1/\u03b5)< nat.ceil(1 / \u03b5) + 1,\n  calc (1/\u03b5) \u2264 nat.ceil(1 / \u03b5): by exact nat.le_ceil (1/\u03b5)\n  ... < nat.ceil(1 / \u03b5) + 1: by exact lt_add_one (nat.ceil(1 / \u03b5)),\nhave h\u2082 : 0 < (nat.ceil(1 / \u03b5):\u211d ) + 1,\n  calc 0 < (1/\u03b5) :by exact one_div_pos.mpr H\n  ... < nat.ceil(1 / \u03b5) + 1 : by exact h\u2081,\nsimp at h\u2081,\nsplit,\nnorm_num,\nsimp,\nexact inv_lt_of_inv_lt H h\u2081,\nend\ndef tempQ: \u2200 \u03b5>(0:\u211a), \u2203 k > (0: \u2115 ) , (1/k :\u211a) < \u03b5:=\nbegin\nintros,\nuse  nat.ceil(1 / \u03b5) + 1,\nhave h\u2081: (1/\u03b5) < (nat.ceil(1 / \u03b5):\u211a) + 1,\n  calc (1/\u03b5) \u2264 nat.ceil(1 / \u03b5): by exact nat.le_ceil (1/\u03b5)\n  ... < nat.ceil(1 / \u03b5) + 1: by exact lt_add_one (nat.ceil(1 / \u03b5)),\nhave h\u2082 : 0 < (nat.ceil(1 / \u03b5):\u211a)  + 1,\n  calc 0 < (1/\u03b5) :by exact one_div_pos.mpr H\n  ... < nat.ceil(1 / \u03b5) + 1 : by exact h\u2081,\nsimp at h\u2081,\nsplit,\nnorm_num,\nsimp,\nexact inv_lt_of_inv_lt H h\u2081,\nend\n\ndef RoM (\u03c6: \u2115 \u2192 (\u2115 \u2192 \u2115) \u2192 \u2115 )(\u03b1 : nnseqR) := \u2200 k > (0 : \u2115), \u2200 (g: \u2115 \u2192 \u2115), \u2203 n <\u03c6 k g, \u2200 i \u2208  {i :\u2115  | i \u2265  n \u2227 i \u2264  (n  + (g n))}, \u2200 j \u2208  {i :\u2115  | i \u2265  n \u2227 i \u2264  (n  + (g n))} , abs((\u03b1.1 i) - (\u03b1.1 j)) < (1/k)\n\ntheorem RoC_implies_cauchy {\u03b1 : nnseqR} (h: \u2203 (\u03c6: \u2115 \u2192 \u2115 ), RoC \u03c6 \u03b1) : (is_cau_seq abs \u03b1.1) := \nbegin\nintros \u03b5 h\u2081,\ncases h with \u03c6 h\u2082,\nhave h\u2084 :\u2203 k > (0 : \u2115) , (1/k :\u211d) < \u03b5,\nexact temp \u03b5 h\u2081,\ncases h\u2084 with k h\u2085,\ncases h\u2085 with h\u2086 h\u2087,\nuse \u03c6 k,\nspecialize h\u2082 k h\u2086 (\u03c6 k),\nintros j h\u2083,\nhave h\u2088 : |\u03b1.val j - \u03b1.val (\u03c6 k)| < (1/k),\nexact h\u2082 j (by norm_num) h\u2083,\ncalc |\u03b1.val j - \u03b1.val (\u03c6 k)| < (1/k) : by exact h\u2088\n... < \u03b5 : by exact h\u2087,\nend\n\ntheorem RoM_implies_cauchy {\u03b1 : nnseqR} (h: \u2203 (\u03c6: \u2115  \u2192 (\u2115 \u2192 \u2115) \u2192 \u2115 ), RoM \u03c6 \u03b1) : (is_cau_seq abs \u03b1.1) :=\nbegin\nintros \u03b5 h\u2081,\ncases h with \u03c6 h\u2082,\nintros,\nby_contradiction h\u2083,\npush_neg at h\u2083,\ncases classical.axiom_of_choice h\u2083 with f h\u2084,\nlet g : \u2115 \u2192 \u2115  := \u03bb x, f x - x,\nhave h\u2085 :\u2203 k > (0 : \u2115) , (1/k :\u211d) < \u03b5,\nexact temp \u03b5 h\u2081,\ncases h\u2085 with k h\u2086,\ncases h\u2086 with h\u2087 q,\nspecialize h\u2082 k h\u2087 g,\ncases h\u2082 with n h\u2085,\ncases h\u2085 with h\u2086 h\u2087,\nhave h\u2088 : n \u2208  {i :\u2115  | i \u2265  n \u2227 i \u2264  (n  + (g n))},\nsimp,\nhave h\u2089 : f n \u2208  {i :\u2115  | i \u2265  n \u2227 i \u2264  (n  + (g n))},\nsimp,\nsplit,\nexact (h\u2084 n).1,\nrw \u2190  nat.add_sub_assoc (h\u2084 n).1,\nrw add_comm n (f n),\nrw nat.add_sub_assoc,\nsimp,\nspecialize h\u2087 n h\u2088 (f n) h\u2089,\nspecialize h\u2084 n,\nrw abs_sub_comm at h\u2087,\nhave p : \u00ac |\u03b1.val (f n) - \u03b1.val n| < \u03b5,\npush_neg,\nexact h\u2084.2,\nhave p :|\u03b1.val (f n) - \u03b1.val n| < \u03b5,\ncalc |\u03b1.val (f n) - \u03b1.val n| < 1 / \u2191k : by exact h\u2087\n... < \u03b5 : by exact q,\ncontradiction,\nend\n\nopen computable part nat.partrec (code) nat.partrec.code\n\ndef  s_prop(n :\u2115 ) : \u2115 \u2192 Prop:= (\u03bb (m : \u2115),\n       m \u2264 n \u2227\n         (\u2203 (x : \u2115), evaln n (of_nat_code m) 0 = some x) \u2227\n           \u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code m) 0 = some w)\n\n@[instance] def s_decideable (n :\u2115) :decidable_pred (s_prop n) :=\nbegin\nunfold decidable_pred,\nintros,\nhave h\u2081: decidable (a \u2264 n),\nexact nat.decidable_le a n,\nhave h\u2082 : \u2200 o : option \u2115, decidable( \u2203 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\u2082 (evaln n (of_nat_code a) 0),\nhave h\u2083 : decidable(\u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code a) 0 = some w),\nlet P : fin n \u2192 Prop := \u03bb l, \u2200 (w : \u2115), \u00acevaln l (of_nat_code a) 0 = some w,\nhave h\u2084 : decidable_pred P,\nunfold decidable_pred,\nintros l,\nsimp[P],\nhave h\u2085 : \u2200 o : option \u2115, decidable( \u2200 (w : \u2115), \u00ac o =some w),\nintros,\napply option.rec_on o, simp, exact decidable.true, intros, simp,\nhave p\u2081: \u00ac \u2200 (w : \u2115), \u00acval = w,\npush_neg, use val, exact is_false p\u2081,\nexact h\u2085 (evaln l (of_nat_code a) 0),\nhave h\u2086 : decidable(\u2200 l : fin n, P l),\nexact @nat.decidable_forall_fin n P h\u2084,\nsimp[P] at h\u2086,\ndsimp[ fin] at h\u2086,\nhave h\u2087: \u2200 Q : \u2115 \u2192 Prop, (\u2200 l : fin n, Q l) \u2194 (\u2200 l < n, Q l),\nintros,split,intros Q\u2081 l Q\u2082, exact Q\u2081 \u27e8 l, Q\u2082\u27e9, intros Q\u2081 l, exact Q\u2081 l.1 l.2,\nspecialize h\u2087 (\u03bbl, \u2200 (w : \u2115), \u00acevaln l (of_nat_code a) 0 = some w), simp at h\u2087,\nexact  decidable_of_decidable_of_iff h\u2086 h\u2087,\nhave h\u2088 : decidable ((\u2203 x, (evaln n (of_nat_code a) 0) = some x) \u2227  (\u2200 l < n,  \u2200 w, \u00ac (evaln l (of_nat_code a) 0) = some w)),\nexact @and.decidable (\u2203 x, (evaln n (of_nat_code a) 0) = some x)  (\u2200 l < n,  \u2200 w, \u00ac (evaln l (of_nat_code a) 0) = some w) h\u2082 h\u2083,\nexact @and.decidable (a \u2264 n) ((\u2203 x, (evaln n (of_nat_code a) 0) = some x) \u2227 \u2200 l < n,  \u2200 w, \u00ac (evaln l (of_nat_code a) 0) = some w) h\u2081 h\u2088,\n\nend\n\n@[instance] def s_exist_decidable (n : \u2115 ): decidable (\u2203 (m : \u2115), s_prop n m):= \nbegin\nunfold s_prop,\nlet P : \u2115 \u2192 Prop:= \u03bb m, (\u2203 (x : \u2115), evaln n (of_nat_code m) 0 = some x) \u2227 \u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code m) 0 = some w,\nhave h\u2081 : decidable_pred P,\nunfold decidable_pred,\nintros,\nsimp[P],\nhave h\u2082 : \u2200 o : option \u2115, decidable( \u2203 x, o = some x),\nintros,\napply option.rec_on o, simp, \nexact decidable.false, intros, simp, exact decidable.true,\nspecialize h\u2082 (evaln n (of_nat_code a) 0),\nhave h\u2083 : decidable(\u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code a) 0 = some w),\nlet P : fin n \u2192 Prop := \u03bb l, \u2200 (w : \u2115), \u00acevaln l (of_nat_code a) 0 = some w,\nhave h\u2084 : decidable_pred P,\nunfold decidable_pred,\nintros l,\nsimp[P],\nhave h\u2085 : \u2200 o : option \u2115, decidable( \u2200 (w : \u2115), \u00ac o =some w),\nintros,\napply option.rec_on o, simp, exact decidable.true, intros, simp,\nhave p\u2081: \u00ac \u2200 (w : \u2115), \u00acval = w,\npush_neg, use val, exact is_false p\u2081,\nexact h\u2085 (evaln l (of_nat_code a) 0),\nhave h\u2086 : decidable(\u2200 l : fin n, P l),\nexact @nat.decidable_forall_fin n P h\u2084,\nsimp[P] at h\u2086,\ndsimp[ fin] at h\u2086,\nhave h\u2087: \u2200 Q : \u2115 \u2192 Prop, (\u2200 l : fin n, Q l) \u2194 (\u2200 l < n, Q l),\nintros,split,intros Q\u2081 l Q\u2082, exact Q\u2081 \u27e8 l, Q\u2082\u27e9, intros Q\u2081 l, exact Q\u2081 l.1 l.2,\nspecialize h\u2087 (\u03bbl, \u2200 (w : \u2115), \u00acevaln l (of_nat_code a) 0 = some w), simp at h\u2087,\nexact  decidable_of_decidable_of_iff h\u2086 h\u2087,\nhave h\u2088 : decidable ((\u2203 x, (evaln n (of_nat_code a) 0) = some x) \u2227  (\u2200 l < n,  \u2200 w, \u00ac (evaln l (of_nat_code a) 0) = some w)),\nexact @and.decidable (\u2203 x, (evaln n (of_nat_code a) 0) = some x)  (\u2200 l < n,  \u2200 w, \u00ac (evaln l (of_nat_code a) 0) = some w) h\u2082 h\u2083,\nexact h\u2088,\nhave h\u2082 : decidable_pred(\u03bbx, \u2203 (m : \u2115), m < x \u2227 P m ),\nexact @nat.decidable_exists_lt P h\u2081,\nsimp[decidable_pred] at h\u2082, specialize h\u2082 (n+1), simp[P] at h\u2082,\nhave h\u2083 : (\u2203 m , m < (n + 1) \u2227 (\u2203 (x : \u2115), evaln n (of_nat_code m) 0 = some x) \u2227 \n\u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code m) 0 = some w) \u2194 \n(\u2203 (m : \u2115), m \u2264 n  \u2227 (\u2203 (x : \u2115), evaln n (of_nat_code m) 0 = some x) \u2227 \n\u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code m) 0 = some w),\nsplit, intro H, cases H with m H, use m, split, rw \u2190 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\u2082 h\u2083,\nend\ndef Specker_seq (\u03b1: nnseqR):= \u2200 \u03c6: \u2115 \u2192 \u2115, (RoC \u03c6 \u03b1) \u2192 \u00ac computable(\u03c6)\n@[reducible]\ndef s (\u03b1: nnseqQ): \u2115 \u2192 \u211a := \n\u03bb n, if h: \u2203 m : \u2115, s_prop n m then \u03b1.1 (nat.find h) else 0\n\ntheorem s_converges (\u03b1: nnseqQ)(h\u2081 : \u2200 n m, n < m \u2192 \u03b1.1 n > \u03b1.1 m)(h\u2082: \u2200 \u03b5 > (0 :\u211d), \u2203 N : \u2115, \u2200n\u2265N, (\u03b1.1 n: \u211d) < \u03b5 ): \u2200 \u03b5 > (0 :\u211d), \u2203 N : \u2115, \u2200n\u2265N, (s \u03b1 n : \u211d) < \u03b5 := \nbegin\nintros,\nspecialize h\u2082 \u03b5 H ,\ncases h\u2082  with N h\u2083,\nby_cases \u2203 i < N, \u2203 x,  x \u2208 (eval (of_nat_code i) 0),\ncases h with i h\u2084, cases h\u2084 with  h\u2084 h\u2085,\nlet S := {j \u2208 finset.range N | \u2203 x, x \u2208 (eval ( of_nat_code j) 0)},\nhave p\u2081: finset.nonempty S,\nunfold finset.nonempty,use i,simp[S],split,exact h\u2084,exact h\u2085,\nlet f : \u2115 \u2192 \u2115 := \u03bbj, if r : \u2203 k: \u2115,  \u2203 x, x \u2208 (evaln k (of_nat_code j) 0) then (nat.find r) else 0,let S\u2081 := S.image f,\nhave p\u2082: finset.nonempty S\u2081,\nsimp,exact p\u2081,\nhave p\u2083 : \u2203 x, x \u2208 S\u2081.max,\nexact finset.max_of_nonempty p\u2082,\ncases p\u2083 with k k_h,\nuse k + 1,\nintros,\nunfold s,\nsplit_ifs,\nswap, simp,\nexact H,\nlet z := nat.find h,\nhave p\u2084 : N \u2264 z,\nby_contradiction q,\npush_neg at q,\nhave p\u2085 : z \u2208 S,\nsimp[S],\nsplit,\nuse z,\nsplit,\nexact q,\nexact nat.find_spec h,\nhave h' : z \u2264 n \u2227  (\u2203 (x : \u2115), evaln n (of_nat_code z) 0 = some x) \u2227 \u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code z) 0 = some w, \nexact nat.find_spec h, \ncases h' with bounded h',\ncases h' with h'\u2081 h'\u2082,\ncases h'\u2081 with x h'\u2081,\nuse x,\nhave h''\u2081 : \u2203 k, x \u2208 evaln k (of_nat_code z) 0,\nuse n,\nexact h'\u2081,\nrw evaln_complete,\nexact h''\u2081,\nhave p\u2086 : f z \u2208 S\u2081,\nsimp[S\u2081],\nuse z,\nsplit,\nexact p\u2085, simp,\nhave p\u2087: f z \u2264 k,\nexact finset.le_max_of_mem p\u2086 k_h,\nhave p\u2088 : n \u2264 f z,\nby_contradiction q\u2081,\npush_neg at q\u2081,\nhave h' : z \u2264 n \u2227 (\u2203 (x : \u2115), evaln n (of_nat_code z) 0 = some x) \u2227 \u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code z) 0 = some w, \nexact nat.find_spec h, \ncases h' with bounded h',\nhave h'\u2081 :  \u2200(l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code z) 0 = some w,\nexact h'.2,\nspecialize h'\u2081 (f z),\nhave q\u2082 :\u2203 (w : \u2115), evaln (f z) (of_nat_code z) 0 = some w,\nsimp[f],\nsplit_ifs,\nhave h_1': \u2203 (a_2 : \u2115), 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 : \u2203 (a a_1 : \u2115), evaln a (of_nat_code z) 0 = some a_1,\nuse n, exact h'.1,\ncontradiction,\nhave h'\u2081_contra : \u00ac \u2203 (w : \u2115), evaln (f z) (of_nat_code z) 0 = some w,\npush_neg,\nexact h'\u2081 q\u2081, \ncontradiction,\nhave q\u2083 : k + 1 \u2264 k,\ncalc k + 1 \u2264 n : by exact H_1\n... \u2264 f z : by exact p\u2088\n... \u2264 k : by exact p\u2087,\nhave q\u2083' : \u00ac  k + 1 \u2264 k,\npush_neg,\nexact lt_add_one k,\ncontradiction,\nexact h\u2083 z p\u2084,\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 \u2264 n \u2227 (\u2203 (x : \u2115), evaln n (of_nat_code z) 0 = some x) \u2227 \u2200 (l : \u2115), l < n \u2192 \u2200 (w : \u2115), \u00acevaln l (of_nat_code z) 0 = some w,\nexact nat.find_spec h_1,\nhave q : \u00ac z < N,\nby_contradiction q,\nspecialize h z,\nhave q\u2081 :\u2200 (x : \u2115), \u00ac  x \u2208 eval (of_nat_code z) 0 ,\nexact h q,\nhave q\u2082 : \u2203 (x : \u2115), evaln n (of_nat_code z) 0 = some x,\nexact h_1'.2.1,\ncases q\u2082 with x q\u2082,\nspecialize q\u2081 x,\nhave q\u2083 : x \u2208 evaln n (of_nat_code z) 0,\nsimp,\nexact q\u2082,\nhave q\u2083': \u2203 k, x \u2208 evaln k (of_nat_code z) 0,\nuse n, exact q\u2083,\nrw \u2190 evaln_complete at q\u2083',\ncontradiction,\npush_neg at q,\nexact h\u2083 z q,\n\nend\n\ntheorem bound (n: \u2115) {P : \u2115 \u2192 Prop} [decidable_pred P] (hP: primrec_pred P): \nprimrec_pred(\u03bb x :\u2115 , \u2200 x \u2264 n, P x):=\nbegin\nunfold primrec_pred,\n\nend\n\n --def coprime_prim: \u2200 n : \u2115 , primrec_pred(\u03bb d, n.coprime d):= \n\ninstance : primcodable \u211a := primcodable.of_equiv (\u03a3 n : \u2124, {d : \u2115 // 0 < d \u2227 n.nat_abs.coprime d})\n  \u27e8\u03bb \u27e8a, b, c, d\u27e9, \u27e8a, b, c, d\u27e9, \u03bb\u27e8a, b, c, d\u27e9, \u27e8a, b, c, d\u27e9,\n   \u03bb \u27e8a, b, c, d\u27e9, rfl, \u03bb\u27e8a, b, c, d\u27e9, rfl\u27e9\n\ninstance PrimcodeQ : primcodable \u211a:= sorry\n\ntheorem s_specker (\u03b1: nnseqQ)(h\u2080: computable \u03b1.1)(h\u2081 : \u2200 n m, n < m \u2192 \u03b1.1 n > \u03b1.1 m)(h\u2082: \u2200 \u03b5 > (0 :\u211d), \u2203 N : \u2115, \u2200n\u2265N, (\u03b1.1 n :\u211d) < \u03b5 ):\n \u2200 \u03c6: \u211a \u2192 \u2115, (\u2200 \u03b5  > (0 : \u211a), \u2200 n > \u03c6 \u03b5 , ((s \u03b1) n) < \u03b5 ) \u2192 \u00ac computable(\u03c6) :=\n begin\n intros \u03c6 h\u2083,\n by_contradiction, \n have h\u2084 : \u2200 n, \u03b1.1 n > 0,\nintros,\nby_contradiction p,\npush_neg at p,\nhave p\u2081: \u03b1.1 (n + 1) < 0,\ncalc \u03b1.1 (n + 1) < \u03b1.1 n : by exact h\u2081 n (n+1) (lt_add_one n)\n...  \u2264 0 : by exact p,\nhave p\u2082 : \u00ac \u03b1.1 (n + 1) < 0,\npush_neg,\nexact (\u03b1.2(n +1)),\ncontradiction,\n--have h\u2085: \u2200 n, \u2203 k > (0: \u2115 ) , (1/k :\u211a) < \u03b1.1 n,\n--intro, exact tempQ (\u03b1.1 n) (h\u2084 n),\n--let r := \u03bbn, nat.find (h\u2085 n),\nlet max_halt: \u2115 \u2192 \u2115  := \u03bb n, max_default n (\u03c6 (\u03b1.1 (n + 1))),\nhave h\u2086 : \u2200 n, (\u2203 x, x \u2208 evaln (max_halt n) (of_nat_code n) 0) \u2194 (\u2203 x, x \u2208 eval (of_nat_code n) 0), \nintros n, split,swap, intro p\u2081,\ncases p\u2081 with x,\nhave p\u2082 : \u2203 k, x \u2208 evaln k (of_nat_code n) 0,\nrw \u2190  evaln_complete, exact p\u2081_h,\nhave p\u2082': \u2203 k, \u2203 x, x \u2208 evaln k (of_nat_code n) 0,\ncases p\u2082 with k, use k, use x, exact p\u2082_h,\nlet k:= nat.find p\u2082',\nhave p\u2083 : k \u2264 max_halt n,\nby_contradiction p\u2083, push_neg at p\u2083,\nhave p\u2084: n \u2264 max_halt n,\nsimp[max_halt], unfold max_default, split_ifs, simp, simp at h_1, exact le_of_lt h_1,\nhave p\u2085: n < k,\ncalc n \u2264 max_halt n : by exact p\u2084\n... < k: by exact p\u2083,\nhave p\u2086:s_prop k n,\nunfold s_prop,split,exact le_of_lt p\u2085,split, exact nat.find_spec p\u2082',\nintro,\nhave min: l < k \u2192 \u00ac\u2203(w : \u2115),evaln l (of_nat_code n) 0 = some w,\nexact nat.find_min p\u2082',push_neg at min, exact min,\nhave p\u2087: s \u03b1 k \u2265 \u03b1.1 n,\nunfold s, split_ifs,\nhave p\u2088: nat.find h_1 \u2264 n, exact nat.find_min' h_1 p\u2086,\nhave p\u2088': nat.find h_1 < n \u2228 nat.find h_1 = n,\nexact lt_or_eq_of_le p\u2088, cases p\u2088',\nexact le_of_lt (h\u2081 (nat.find h_1) n p\u2088'), exact (congr_arg \u03b1.val p\u2088').ge,\npush_neg at h_1,specialize h_1 n, contradiction,\nhave p\u2088 : \u03b1.val n > \u03b1.val (n + 1),\nexact h\u2081 n (n+1) (lt_add_one n),\nhave p\u2089 : s \u03b1 k > \u03b1.val (n + 1),\ncalc s \u03b1 k \u2265 \u03b1.1 n : by exact p\u2087\n... > \u03b1.val (n + 1) : by exact p\u2088,\nhave q\u2081 : \u03c6 (\u03b1.1 (n + 1)) \u2264 max_halt n,\nsimp[max_halt], unfold max_default, split_ifs, exact  h_1, simp,\nhave q\u2082:  \u03c6 (\u03b1.1 (n + 1)) < k,\ncalc \u03c6 (\u03b1.1 (n + 1)) \u2264 max_halt n : by exact q\u2081\n...< k : by exact p\u2083,\nrw \u2190 gt_iff_lt at q\u2082,\nhave h\u2089': s \u03b1 k < \u03b1.val (n + 1),\nexact h\u2083 (\u03b1.1 (n+1)) (h\u2084 (n + 1)) k q\u2082,\nhave h\u2089'': \u00ac s \u03b1 k < \u03b1.val (n + 1),\npush_neg, exact le_of_lt p\u2089, contradiction,\nhave spec: \u2203 x, x \u2208 evaln k (of_nat_code n) 0,\nexact nat.find_spec p\u2082',\ncases spec with x,\nuse x, exact evaln_mono p\u2083 spec_h,\nintro h\u2085,cases h\u2085 with x,\nuse x,\nhave h\u2086 : \u2203 k, x \u2208 evaln k (of_nat_code n) 0,\nuse (max_halt n), exact h\u2085_h,\nrw evaln_complete, exact h\u2086,\nhave p\u2081 : computable (\u03bb n, \u03c6 ( \u03b1.1 (n+1))),\nexact computable.comp h (computable.comp h\u2080 computable.succ),\nhave p\u2082 : computable(\u03bbn, max_halt n),\nsimp[max_halt], exact computable\u2082.comp primrec.nat_max.to_comp computable.id p\u2081,\nhave p\u2083 : computable(\u03bb n, of_nat_code n),\nrw \u2190 of_nat_code_eq, exact computable.of_nat code,\nlet evalnmap:= \u03bb (a : (\u2115 \u00d7 code) \u00d7 \u2115), evaln a.1.1 a.1.2 a.2,\nhave p\u2084 : computable(evalnmap),\nexact evaln_prim.to_comp,\nlet evalnmap':= \u03bb (a : \u2115 \u00d7 code) , evalnmap (\u27e8 a, 0\u27e9),\nhave p\u2085 : computable(evalnmap'),\nexact computable.comp p\u2084 (computable.pair computable.id (primrec.to_comp (primrec\u2082.const 0))),\nlet E:= \u03bb n, evalnmap' (((max_halt n), (of_nat_code n))),\nhave p\u2086 : computable E,\nsimp[E], exact computable.comp p\u2085 (computable.pair p\u2082 p\u2083),\nsimp[E] at p\u2086,simp[evalnmap'] at p\u2086, simp[evalnmap] at p\u2086, simp at p\u2086,\nhave p\u2087 : computable_pred (\u03bb n, option.is_some (evaln (max_halt n) (of_nat_code n) 0)),\nsimp[computable_pred],\nrefine \u27e8by apply_instance, _\u27e9,\nexact computable.comp primrec.option_is_some.to_comp p\u2086,\nhave p\u2088 : \u2200 n,option.is_some (evaln (max_halt n) (of_nat_code n) 0) \u2194 (\u2203 x, x \u2208 evaln (max_halt n) (of_nat_code n) 0) ,\nintros,exact option.is_some_iff_exists,\nhave p\u2089 : computable_pred(\u03bbn, \u2203 x, x \u2208 evaln (max_halt n) (of_nat_code n) 0),\nexact computable_pred.of_eq p\u2087 p\u2088,\nhave q\u2081: computable_pred(\u03bb n, \u2203 (x : \u2115), x \u2208 (of_nat_code n).eval 0),\nexact computable_pred.of_eq p\u2089 h\u2086,\nhave q\u2082 : \u2200 n ,(\u2203 (x : \u2115), x \u2208 (of_nat_code n).eval 0) \u2194 ((of_nat_code n).eval 0).dom,\nintros, rw \u2190  dom_iff_mem,\nhave q\u2083 : computable_pred( \u03bb n, ((of_nat_code n).eval 0).dom),\nexact computable_pred.of_eq q\u2081 q\u2082,\nhave q\u2084 : computable_pred(\u03bb c : code, ((eval (of_nat_code (encode_code c))) 0).dom),\ncasesI q\u2083,\nrefine \u27e8by apply_instance, _\u27e9,\nrw \u2190 encode_code_eq,\nexact computable.comp q\u2083_h computable.encode,\nrw \u2190 encode_code_eq at q\u2084,rw \u2190 of_nat_code_eq at q\u2084, simp at q\u2084,\nexact (computable_pred.halting_problem 0) q\u2084,\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 \u2192 R) \u2192 (S \u2192 Q) \u2192 (R \u2192 T) \u2192 (Q \u2192 R) \u2192 S \u2192 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 `\u2124\u02e3` 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 {\u03b1 : Type u} {\u03b2 : 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 \u03b1] (i j : \u03b1) : setoid (perm \u03b1) :=\n\u27e8\u03bb \u03c3 \u03c4, \u03c3 = \u03c4 \u2228 \u03c3 = swap i j * \u03c4,\n \u03bb \u03c3, or.inl (refl \u03c3),\n \u03bb \u03c3 \u03c4 h, or.cases_on h (\u03bb h, or.inl h.symm) (\u03bb h, or.inr (by rw [h, swap_mul_self_mul])),\n \u03bb \u03c3 \u03c4 \u03c5 h\u03c3\u03c4 h\u03c4\u03c5, by cases h\u03c3\u03c4; cases h\u03c4\u03c5; try {rw [h\u03c3\u03c4, h\u03c4\u03c5, swap_mul_self_mul]}; simp [h\u03c3\u03c4, h\u03c4\u03c5] \u27e9\n\ninstance {\u03b1 : Type*} [fintype \u03b1] [decidable_eq \u03b1] (i j : \u03b1) : decidable_rel (mod_swap i j).r :=\n\u03bb \u03c3 \u03c4, or.decidable\n\nlemma perm_inv_on_of_perm_on_finset {s : finset \u03b1} {f : perm \u03b1}\n  (h : \u2200 x \u2208 s, f x \u2208 s) {y : \u03b1} (hy : y \u2208 s) : f\u207b\u00b9 y \u2208 s :=\nbegin\n  have h0 : \u2200 y \u2208 s, \u2203 x (hx : x \u2208 s), y = (\u03bb i (hi : i \u2208 s), f i) x hx :=\n    finset.surj_on_of_inj_on_of_card_le (\u03bb x hx, (\u03bb i hi, f i) x hx)\n    (\u03bb a ha, h a ha) (\u03bb a\u2081 a\u2082 ha\u2081 ha\u2082 heq, (equiv.apply_eq_iff_eq f).mp heq) rfl.ge,\n  obtain \u27e8y2, hy2, heq\u27e9 := 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 \u03b1) {s : set \u03b1} [fintype s]\n  (h : set.maps_to f s s) : set.maps_to (f\u207b\u00b9 : _) s s :=\n\u03bb x hx, set.mem_to_finset.mp $\n  perm_inv_on_of_perm_on_finset\n   (\u03bb 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 \u03b1} {s : set \u03b1} [fintype s] :\n  set.maps_to (f\u207b\u00b9 : _) s s \u2194 set.maps_to f s s :=\n\u27e8perm_inv_maps_to_of_maps_to f\u207b\u00b9, perm_inv_maps_to_of_maps_to f\u27e9\n\nlemma perm_inv_on_of_perm_on_fintype {f : perm \u03b1} {p : \u03b1 \u2192 Prop} [fintype {x // p x}]\n  (h : \u2200 x, p x \u2192 p (f x)) {x : \u03b1} (hx : p x) : p (f\u207b\u00b9 x) :=\nbegin\n  letI : fintype \u21a5(show set \u03b1, from p) := \u2039fintype {x // p x}\u203a,\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 \u03b1) {p : \u03b1 \u2192 Prop} [fintype {x // p x}]\n  (h : \u2200 x, p x \u2192 p (f x)) : perm {x // p x} :=\nf.subtype_perm (\u03bb x, \u27e8h x, \u03bb h\u2082, f.inv_apply_self x \u25b8 perm_inv_on_of_perm_on_fintype h h\u2082\u27e9)\n\n@[simp] lemma subtype_perm_of_fintype_apply (f : perm \u03b1) {p : \u03b1 \u2192 Prop} [fintype {x // p x}]\n  (h : \u2200 x, p x \u2192 p (f x)) (x : {x // p x}) : subtype_perm_of_fintype f h x = \u27e8f x, h x x.2\u27e9 := rfl\n\n@[simp] lemma subtype_perm_of_fintype_one (p : \u03b1 \u2192 Prop) [fintype {x // p x}]\n  (h : \u2200 x, p x \u2192 p ((1 : perm \u03b1) x)) : @subtype_perm_of_fintype \u03b1 1 p _ h = 1 :=\nequiv.ext $ \u03bb \u27e8_, _\u27e9, rfl\n\nlemma perm_maps_to_inl_iff_maps_to_inr {m n : Type*} [fintype m] [fintype n]\n  (\u03c3 : equiv.perm (m \u2295 n)) :\n  set.maps_to \u03c3 (set.range sum.inl) (set.range sum.inl) \u2194\n  set.maps_to \u03c3 (set.range sum.inr) (set.range sum.inr) :=\nbegin\n  split; id\n  { intros h,\n    classical,\n    rw \u2190perm_inv_maps_to_iff_maps_to at h,\n    intro x,\n    cases hx : \u03c3 x with l r, },\n  { rintros \u27e8a, rfl\u27e9,\n    obtain \u27e8y, hy\u27e9 := h \u27e8l, rfl\u27e9,\n    rw [\u2190hx, \u03c3.inv_apply_self] at hy,\n    exact absurd hy sum.inl_ne_inr},\n  { rintros \u27e8a, ha\u27e9, exact \u27e8r, rfl\u27e9, },\n  { rintros \u27e8a, ha\u27e9, exact \u27e8l, rfl\u27e9, },\n  { rintros \u27e8a, rfl\u27e9,\n    obtain \u27e8y, hy\u27e9 := h \u27e8r, rfl\u27e9,\n    rw [\u2190hx, \u03c3.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  {\u03c3 : perm (m \u2295 n)} (h : set.maps_to \u03c3 (set.range sum.inl) (set.range sum.inl)) :\n  \u03c3 \u2208 (sum_congr_hom m n).range :=\nbegin\n  classical,\n  have h1 : \u2200 (x : m \u2295 n), (\u2203 (a : m), sum.inl a = x) \u2192 (\u2203 (a : m), sum.inl a = \u03c3 x),\n  { rintros x \u27e8a, ha\u27e9, apply h, rw \u2190 ha, exact \u27e8a, rfl\u27e9 },\n  have h3 : \u2200 (x : m \u2295 n), (\u2203 (b : n), sum.inr b = x) \u2192 (\u2203 (b : n), sum.inr b = \u03c3 x),\n  { rintros x \u27e8b, hb\u27e9,\n    apply (perm_maps_to_inl_iff_maps_to_inr \u03c3).mp h,\n    rw \u2190 hb, exact \u27e8b, rfl\u27e9 },\n  let \u03c3\u2081' := subtype_perm_of_fintype \u03c3 h1,\n  let \u03c3\u2082' := subtype_perm_of_fintype \u03c3 h3,\n  let \u03c3\u2081 := perm_congr (equiv.of_injective _ sum.inl_injective).symm \u03c3\u2081',\n  let \u03c3\u2082 := perm_congr (equiv.of_injective _ sum.inr_injective).symm \u03c3\u2082',\n  rw [monoid_hom.mem_range, prod.exists],\n  use [\u03c3\u2081, \u03c3\u2082],\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 {\u03c3 \u03c4 : perm \u03b1} (h\u03c3\u03c4 : disjoint \u03c3 \u03c4) :\n  order_of (\u03c3 * \u03c4) = nat.lcm (order_of \u03c3) (order_of \u03c4) :=\nbegin\n  have h : \u2200 n : \u2115, (\u03c3 * \u03c4) ^ n = 1 \u2194 \u03c3 ^ n = 1 \u2227 \u03c4 ^ n = 1 :=\n  \u03bb n, by rw [h\u03c3\u03c4.commute.mul_pow, disjoint.mul_eq_one_iff (h\u03c3\u03c4.pow_disjoint_pow n n)],\n  exact nat.dvd_antisymm h\u03c3\u03c4.commute.order_of_mul_dvd_lcm (nat.lcm_dvd\n    (order_of_dvd_of_pow_eq_one ((h (order_of (\u03c3 * \u03c4))).mp (pow_order_of_eq_one (\u03c3 * \u03c4))).1)\n    (order_of_dvd_of_pow_eq_one ((h (order_of (\u03c3 * \u03c4))).mp (pow_order_of_eq_one (\u03c3 * \u03c4))).2)),\nend\n\nlemma disjoint.extend_domain {\u03b1 : Type*} {p : \u03b2 \u2192 Prop} [decidable_pred p]\n  (f : \u03b1 \u2243 subtype p) {\u03c3 \u03c4 : perm \u03b1} (h : disjoint \u03c3 \u03c4) :\n  disjoint (\u03c3.extend_domain f) (\u03c4.extend_domain f) :=\nbegin\n  intro b,\n  by_cases pb : p b,\n  { refine (h (f.symm \u27e8b, pb\u27e9)).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 \u03b1]\n\nsection fintype\nvariable [fintype \u03b1]\n\nlemma support_pow_coprime {\u03c3 : perm \u03b1} {n : \u2115} (h : nat.coprime n (order_of \u03c3)) :\n  (\u03c3 ^ n).support = \u03c3.support :=\nbegin\n  obtain \u27e8m, hm\u27e9 := exists_pow_eq_self_of_coprime h,\n  exact le_antisymm (support_pow_le \u03c3 n) (le_trans (ge_of_eq (congr_arg support hm))\n    (support_pow_le (\u03c3 ^ n) m)),\nend\n\nend fintype\n\n/-- Given a list `l : list \u03b1` and a permutation `f : perm \u03b1` such that the nonfixed points of `f`\n  are in `l`, recursively factors `f` as a product of transpositions. -/\ndef swap_factors_aux : \u03a0 (l : list \u03b1) (f : perm \u03b1), (\u2200 {x}, f x \u2260 x \u2192 x \u2208 l) \u2192\n  {l : list (perm \u03b1) // l.prod = f \u2227 \u2200 g \u2208 l, is_swap g}\n| []       := \u03bb f h, \u27e8[], equiv.ext $ \u03bb x, by { rw [list.prod_nil],\n    exact (not_not.1 (mt h (list.not_mem_nil _))).symm }, by simp\u27e9\n| (x :: l) := \u03bb f h,\nif hfx : x = f x\nthen swap_factors_aux l f\n  (\u03bb y hy, list.mem_of_ne_of_mem (\u03bb 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      (\u03bb y hy, have f y \u2260 y \u2227 y \u2260 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  \u27e8swap x (f x) :: m.1,\n  by rw [list.prod_cons, m.2.1, \u2190 mul_assoc,\n    mul_def (swap x (f x)), swap_swap, \u2190 one_def, one_mul],\n  \u03bb g hg, ((list.mem_cons_iff _ _ _).1 hg).elim (\u03bb h, \u27e8x, f x, hfx, h\u27e9) (m.2.2 _)\u27e9\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 \u03b1] [linear_order \u03b1] (f : perm \u03b1) :\n  {l : list (perm \u03b1) // l.prod = f \u2227 \u2200 g \u2208 l, is_swap g} :=\nswap_factors_aux ((@univ \u03b1 _).sort (\u2264)) f (\u03bb _ _, (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 \u03b1] (f : perm \u03b1) :\n  trunc {l : list (perm \u03b1) // l.prod = f \u2227 \u2200 g \u2208 l, is_swap g} :=\nquotient.rec_on_subsingleton (@univ \u03b1 _).1\n  (\u03bb l h, trunc.mk (swap_factors_aux l f h))\n  (show \u2200 x, f x \u2260 x \u2192 x \u2208 (@univ \u03b1 _).1, from \u03bb _ _, 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 \u03b1] {P : perm \u03b1 \u2192 Prop} (f : perm \u03b1) :\n  P 1 \u2192 (\u2200 f x y, x \u2260 y \u2192 P f \u2192 P (swap x y * f)) \u2192 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 \u27e8x, y, hxy\u27e9,\n    rw [\u2190 hl.1, list.prod_cons, hxy.2],\n    exact hmul_swap _ _ _ hxy.1\n      (ih _ \u27e8rfl, \u03bb v hv, hl.2 _ (list.mem_cons_of_mem _ hv)\u27e9 h1 hmul_swap) }\nend\n\nlemma closure_is_swap [fintype \u03b1] : subgroup.closure {\u03c3 : perm \u03b1 | is_swap \u03c3} = \u22a4 :=\nbegin\n  refine eq_top_iff.mpr (\u03bb x hx, _),\n  obtain \u27e8h1, h2\u27e9 := subtype.mem (trunc_swap_factors x).out,\n  rw \u2190 h1,\n  exact subgroup.list_prod_mem _ (\u03bb 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 \u03b1] {P : perm \u03b1 \u2192 Prop} (f : perm \u03b1) :\n  P 1 \u2192 (\u2200 f x y, x \u2260 y \u2192 P f \u2192 P (f * swap x y)) \u2192 P f :=\n\u03bb h1 IH, inv_inv f \u25b8 swap_induction_on f\u207b\u00b9 h1 (\u03bb f, IH f\u207b\u00b9)\n\nlemma is_conj_swap {w x y z : \u03b1} (hwx : w \u2260 x) (hyz : y \u2260 z) : is_conj (swap w x) (swap y z) :=\nis_conj_iff.2 (have h : \u2200 {y z : \u03b1}, y \u2260 z \u2192 w \u2260 z \u2192\n      (swap w y * swap x z) * swap w x * (swap w y * swap x z)\u207b\u00b9 = swap y z :=\n    \u03bb y z hyz hwz, by rw [mul_inv_rev, swap_inv, swap_inv, mul_assoc (swap w y),\n      mul_assoc (swap w y), \u2190 mul_assoc _ (swap x z), swap_mul_swap_mul_swap hwx hwz,\n      \u2190 mul_assoc, swap_mul_swap_mul_swap hwz.symm hyz.symm],\n  if hwz : w = z\n  then have hwy : w \u2260 y, by cc,\n    \u27e8swap w z * swap x y, by rw [swap_comm y z, h hyz.symm hwy]\u27e9\n  else \u27e8swap w y * swap x z, h hyz hwz\u27e9)\n\n/-- set of all pairs (\u27e8a, b\u27e9 : \u03a3 a : fin n, fin n) such that b < a -/\ndef fin_pairs_lt (n : \u2115) : finset (\u03a3 a : fin n, fin n) :=\n(univ : finset (fin n)).sigma (\u03bb a, (range a).attach_fin\n  (\u03bb m hm, (mem_range.1 hm).trans a.2))\n\nlemma mem_fin_pairs_lt {n : \u2115} {a : \u03a3 a : fin n, fin n} :\n  a \u2208 fin_pairs_lt n \u2194 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 \u03c3` is the sign of a permutation on `fin n`, defined as the parity of the number of\n  pairs `(x\u2081, x\u2082)` such that `x\u2082 < x\u2081` but `\u03c3 x\u2081 \u2264 \u03c3 x\u2082` -/\ndef sign_aux {n : \u2115} (a : perm (fin n)) : \u2124\u02e3 :=\n\u220f x in fin_pairs_lt n, if a x.1 \u2264 a x.2 then -1 else 1\n\n@[simp] lemma sign_aux_one (n : \u2115) : sign_aux (1 : perm (fin n)) = 1 :=\nbegin\n  unfold sign_aux,\n  conv { to_rhs, rw \u2190 @finset.prod_const_one \u2124\u02e3 _\n    (fin_pairs_lt n) },\n  exact finset.prod_congr rfl (\u03bb a ha, if_neg (mem_fin_pairs_lt.1 ha).not_le)\nend\n\n/-- `sign_bij_aux f \u27e8a, b\u27e9` returns the pair consisting of `f a` and `f b` in decreasing order. -/\ndef sign_bij_aux {n : \u2115} (f : perm (fin n)) (a : \u03a3 a : fin n, fin n) :\n  \u03a3 a : fin n, fin n :=\nif hxa : f a.2 < f a.1 then \u27e8f a.1, f a.2\u27e9 else \u27e8f a.2, f a.1\u27e9\n\nlemma sign_bij_aux_inj {n : \u2115} {f : perm (fin n)} : \u2200 a b : \u03a3 a : fin n, fin n,\n   a \u2208 fin_pairs_lt n \u2192 b \u2208 fin_pairs_lt n \u2192\n   sign_bij_aux f a = sign_bij_aux f b \u2192 a = b :=\n\u03bb \u27e8a\u2081, a\u2082\u27e9 \u27e8b\u2081, b\u2082\u27e9 ha hb h, begin\n  unfold sign_bij_aux at h,\n  rw mem_fin_pairs_lt at *,\n  have : \u00acb\u2081 < b\u2082 := 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 : \u2115} {f : perm (fin n)} : \u2200 a \u2208 fin_pairs_lt n,\n  \u2203 b \u2208 fin_pairs_lt n, a = sign_bij_aux f b :=\n\u03bb \u27e8a\u2081, a\u2082\u27e9 ha,\nif hxa : f\u207b\u00b9 a\u2082 < f\u207b\u00b9 a\u2081\nthen \u27e8\u27e8f\u207b\u00b9 a\u2081, f\u207b\u00b9 a\u2082\u27e9, 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)] }\u27e9\nelse \u27e8\u27e8f\u207b\u00b9 a\u2082, f\u207b\u00b9 a\u2081\u27e9, mem_fin_pairs_lt.2 $ (le_of_not_gt hxa).lt_of_ne $ \u03bb h,\n    by simpa [mem_fin_pairs_lt, (f\u207b\u00b9).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] }\u27e9\n\nlemma sign_bij_aux_mem {n : \u2115} {f : perm (fin n)} : \u2200 a : \u03a3 a : fin n, fin n,\n  a \u2208 fin_pairs_lt n \u2192 sign_bij_aux f a \u2208 fin_pairs_lt n :=\n\u03bb \u27e8a\u2081, a\u2082\u27e9 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 (\u03bb h, (mem_fin_pairs_lt.1 ha).ne (f.injective h.symm))) }\nend\n\n@[simp] lemma sign_aux_inv {n : \u2115} (f : perm (fin n)) : sign_aux f\u207b\u00b9 = sign_aux f :=\nprod_bij (\u03bb a ha, sign_bij_aux f\u207b\u00b9 a)\n  sign_bij_aux_mem\n  (\u03bb \u27e8a, b\u27e9 hab, if h : f\u207b\u00b9 b < f\u207b\u00b9 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 : \u2115} (f g : perm (fin n)) :\n  sign_aux (f * g) = sign_aux f * sign_aux g :=\nbegin\n  rw \u2190 sign_aux_inv g,\n  unfold sign_aux,\n  rw \u2190 prod_mul_distrib,\n  refine prod_bij (\u03bb a ha, sign_bij_aux g a) sign_bij_aux_mem _ sign_bij_aux_inj sign_bij_aux_surj,\n  rintros \u27e8a, b\u27e9 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\u2081 : f (g b) \u2264 f (g a),\n    { have : f (g b) \u2260 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\u2081, if_neg (h\u2081.lt_of_ne this).not_le],\n      refl },\n    { rw [if_neg h\u2081, if_pos (lt_of_not_ge h\u2081).le],\n      refl } }\nend\n\nprivate lemma sign_aux_swap_zero_one' (n : \u2115) :\n  sign_aux (swap (0 : fin (n + 2)) 1) = -1 :=\nshow _ = \u220f x : \u03a3 a : fin (n + 2), fin (n + 2) in {(\u27e81, 0\u27e9 : \u03a3 a : fin (n + 2), fin (n + 2))},\n  if (equiv.swap 0 1) x.1 \u2264 swap 0 1 x.2 then (-1 : \u2124\u02e3) else 1,\nbegin\n  refine eq.symm (prod_subset (\u03bb \u27e8x\u2081, x\u2082\u27e9,\n    by simp [mem_fin_pairs_lt, fin.one_pos] {contextual := tt}) (\u03bb a ha\u2081 ha\u2082, _)),\n  rcases a with \u27e8a\u2081, a\u2082\u27e9,\n  replace ha\u2081 : a\u2082 < a\u2081 := mem_fin_pairs_lt.1 ha\u2081,\n  dsimp only,\n  rcases a\u2081.zero_le.eq_or_lt with rfl|H,\n  { exact absurd a\u2082.zero_le ha\u2081.not_le },\n  rcases a\u2082.zero_le.eq_or_lt with rfl|H',\n  { simp only [and_true, eq_self_iff_true, heq_iff_eq, mem_singleton] at ha\u2082,\n    have : 1 < a\u2081 := lt_of_le_of_ne (nat.succ_le_of_lt ha\u2081) (ne.symm ha\u2082),\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\u2082, this.not_le, h01] },\n  { have le : 1 \u2264 a\u2082 := nat.succ_le_of_lt H',\n    have lt : 1 < a\u2081 := le.trans_lt ha\u2081,\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\u2081.not_le] } }\nend\n\nprivate lemma sign_aux_swap_zero_one {n : \u2115} (hn : 2 \u2264 n) :\n  sign_aux (swap (\u27e80, lt_of_lt_of_le dec_trivial hn\u27e9 : fin n)\n  \u27e81, lt_of_lt_of_le dec_trivial hn\u27e9) = -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 : \u2200 {n : \u2115} {x y : fin n} (hxy : x \u2260 y),\n  sign_aux (swap x y) = -1\n| 0 := dec_trivial\n| 1 := dec_trivial\n| (n+2) := \u03bb x y hxy,\nhave h2n : 2 \u2264 n + 2 := dec_trivial,\nby { rw [\u2190 is_conj_iff_eq, \u2190 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 \u03b1` contains all nonfixed points of the permutation `f : perm \u03b1`,\n  `sign_aux2 l f` recursively calculates the sign of `f`. -/\ndef sign_aux2 : list \u03b1 \u2192 perm \u03b1 \u2192 \u2124\u02e3\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 : \u2115} : \u2200 (l : list \u03b1) (f : perm \u03b1) (e : \u03b1 \u2243 fin n)\n  (h : \u2200 x, f x \u2260 x \u2192 x \u2208 l), sign_aux ((e.symm.trans f).trans e) = sign_aux2 l f\n| []     f e h := have f = 1, from equiv.ext $\n  \u03bb y, not_not.1 (mt (h y) (list.not_mem_nil _)),\nby rw [this, one_def, equiv.trans_refl, equiv.symm_trans_self, \u2190 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 _ (\u03bb y (hy : f y \u2260 y), list.mem_of_ne_of_mem\n      (\u03bb h : y = x, by simpa [h, hfx.symm] using hy) (h y hy) ) },\n  { have hy : \u2200 y : \u03b1, (swap x (f x) * f) y \u2260 y \u2192 y \u2208 l, from \u03bb y hy,\n      have f y \u2260 y \u2227 y \u2260 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 [\u2190 equiv.symm_trans_swap_trans, mul_def],\n    have hefx : e x \u2260 e (f x), from mt e.injective.eq_iff.1 hfx,\n    rw [if_neg hfx, \u2190 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 \u03b1` contains all nonfixed points of the permutation `f : perm \u03b1`,\n  `sign_aux2 f _` recursively calculates the sign of `f`. -/\ndef sign_aux3 [fintype \u03b1] (f : perm \u03b1) {s : multiset \u03b1} : (\u2200 x, x \u2208 s) \u2192 \u2124\u02e3 :=\nquotient.hrec_on s (\u03bb l h, sign_aux2 l f)\n  (trunc.induction_on (fintype.trunc_equiv_fin \u03b1)\n    (\u03bb e l\u2081 l\u2082 h, function.hfunext\n      (show (\u2200 x, x \u2208 l\u2081) = \u2200 x, x \u2208 l\u2082, by simp only [h.mem_iff])\n      (\u03bb h\u2081 h\u2082 _, by rw [\u2190 sign_aux_eq_sign_aux2 _ _ e (\u03bb _ _, h\u2081 _),\n        \u2190 sign_aux_eq_sign_aux2 _ _ e (\u03bb _ _, h\u2082 _)])))\n\nlemma sign_aux3_mul_and_swap [fintype \u03b1] (f g : perm \u03b1) (s : multiset \u03b1) (hs : \u2200 x, x \u2208 s) :\n  sign_aux3 (f * g) hs = sign_aux3 f hs * sign_aux3 g hs \u2227 \u2200 x y, x \u2260 y \u2192\n  sign_aux3 (swap x y) hs = -1 :=\nlet \u27e8l, hl\u27e9 := quotient.exists_rep s in\nlet e := equiv_fin \u03b1 in\nbegin\n  clear _let_match,\n  subst hl,\n  show sign_aux2 l (f * g) = sign_aux2 l f * sign_aux2 l g \u2227\n    \u2200 x y, x \u2260 y \u2192 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 (\u03bb h, by simp [mul_apply]),\n  split,\n  { rw [\u2190 sign_aux_eq_sign_aux2 _ _ e (\u03bb _ _, hs _), \u2190 sign_aux_eq_sign_aux2 _ _ e (\u03bb _ _, hs _),\n      \u2190 sign_aux_eq_sign_aux2 _ _ e (\u03bb _ _, hs _), hfg, sign_aux_mul] },\n  { assume x y hxy,\n    have hexy : e x \u2260 e y, from mt e.injective.eq_iff.1 hxy,\n    rw [\u2190 sign_aux_eq_sign_aux2 _ _ e (\u03bb _ _, 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 \u03b1` to the group with two elements.-/\ndef sign [fintype \u03b1] : perm \u03b1 \u2192* \u2124\u02e3 := monoid_hom.mk'\n(\u03bb f, sign_aux3 f mem_univ) (\u03bb f g, (sign_aux3_mul_and_swap f g _ mem_univ).1)\n\nsection sign\n\nvariable [fintype \u03b1]\n\n@[simp] lemma sign_mul (f g : perm \u03b1) : sign (f * g) = sign f * sign g :=\nmonoid_hom.map_mul sign f g\n\n@[simp] lemma sign_trans (f g : perm \u03b1) : sign (f.trans g) = sign g * sign f :=\nby rw [\u2190mul_def, sign_mul]\n\n@[simp] lemma sign_one : (sign (1 : perm \u03b1)) = 1 :=\nmonoid_hom.map_one sign\n\n@[simp] lemma sign_refl : sign (equiv.refl \u03b1) = 1 :=\nmonoid_hom.map_one sign\n\n@[simp] lemma sign_inv (f : perm \u03b1) : sign f\u207b\u00b9 = sign f :=\nby rw [monoid_hom.map_inv sign f, int.units_inv_eq_self]\n\n@[simp] lemma sign_symm (e : perm \u03b1) : sign e.symm = sign e :=\nsign_inv e\n\nlemma sign_swap {x y : \u03b1} (h : x \u2260 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 : \u03b1} :\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 \u03b1} (h : f.is_swap) : sign f = -1 :=\nlet \u27e8x, y, hxy\u27e9 := h in hxy.2.symm \u25b8 sign_swap hxy.1\n\n\n\n@[simp] lemma sign_symm_trans_trans [decidable_eq \u03b2] [fintype \u03b2] (f : perm \u03b1) (e : \u03b1 \u2243 \u03b2) :\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 \u03b2] [fintype \u03b2] (f : perm \u03b2) (e : \u03b1 \u2243 \u03b2) :\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 \u03b1)}\n  (hl : \u2200 g \u2208 l, is_swap g) : sign l.prod = (-1) ^ l.length :=\nhave h\u2081 : l.map sign = list.repeat (-1) l.length :=\n  list.eq_repeat.2 \u27e8by simp, \u03bb u hu,\n  let \u27e8g, hg\u27e9 := list.mem_map.1 hu in\n  hg.2 \u25b8 (hl _ hg.1).sign_eq\u27e9,\nby rw [\u2190 list.prod_repeat, \u2190 h\u2081, list.prod_hom _ (@sign \u03b1 _ _)]\n\nvariable (\u03b1)\n\nlemma sign_surjective [nontrivial \u03b1] : function.surjective (sign : perm \u03b1 \u2192 \u2124\u02e3) :=\n\u03bb a, (int.units_eq_one_or a).elim\n  (\u03bb h, \u27e81, by simp [h]\u27e9)\n  (\u03bb h, let \u27e8x, y, hxy\u27e9 := exists_pair_ne \u03b1 in\n    \u27e8swap x y, by rw [sign_swap hxy, h]\u27e9 )\n\nvariable {\u03b1}\n\nlemma eq_sign_of_surjective_hom {s : perm \u03b1 \u2192* \u2124\u02e3} (hs : surjective s) : s = sign :=\nhave \u2200 {f}, is_swap f \u2192 s f = -1 :=\n  \u03bb f \u27e8x, y, hxy, hxy'\u27e9, hxy'.symm \u25b8 by_contradiction (\u03bb h,\n    have \u2200 f, is_swap f \u2192 s f = 1 := \u03bb f \u27e8a, b, hab, hab'\u27e9,\n      by { rw [\u2190 is_conj_iff_eq, \u2190 or.resolve_right (int.units_eq_one_or _) h, hab'],\n        exact s.map_is_conj (is_conj_swap hab hxy) },\n  let \u27e8g, hg\u27e9 := hs (-1) in\n  let \u27e8l, hl\u27e9 := (trunc_swap_factors g).out in\n  have \u2200 a \u2208 l.map s, a = (1 : \u2124\u02e3) := \u03bb a ha,\n    let \u27e8g, hg\u27e9 := list.mem_map.1 ha in hg.2 \u25b8 this _ (hl.2 _ hg.1),\n  have s l.prod = 1,\n    by rw [\u2190 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 $ \u03bb f,\nlet \u27e8l, hl\u2081, hl\u2082\u27e9 := (trunc_swap_factors f).out in\nhave hsl : \u2200 a \u2208 l.map s, a = (-1 : \u2124\u02e3) := \u03bb a ha,\n  let \u27e8g, hg\u27e9 := list.mem_map.1 ha in hg.2 \u25b8  this (hl\u2082 _ hg.1),\nby rw [\u2190 hl\u2081, \u2190 l.prod_hom s, list.eq_repeat'.2 hsl, list.length_map,\n     list.prod_repeat, sign_prod_list_swap hl\u2082]\n\nlemma sign_subtype_perm (f : perm \u03b1) {p : \u03b1 \u2192 Prop} [decidable_pred p]\n  (h\u2081 : \u2200 x, p x \u2194 p (f x)) (h\u2082 : \u2200 x, f x \u2260 x \u2192 p x) : sign (subtype_perm f h\u2081) = sign f :=\nlet l := (trunc_swap_factors (subtype_perm f h\u2081)).out in\nhave hl' : \u2200 g' \u2208 l.1.map of_subtype, is_swap g' :=\n  \u03bb g' hg',\n  let \u27e8g, hg\u27e9 := list.mem_map.1 hg' in\n  hg.2 \u25b8 (l.2.2 _ hg.1).of_subtype_is_swap,\nhave hl'\u2082 : (l.1.map of_subtype).prod = f,\n  by rw [l.1.prod_hom of_subtype, l.2.1, of_subtype_subtype_perm _ h\u2082],\nby { conv { congr, rw \u2190 l.2.1, skip, rw \u2190 hl'\u2082 },\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 : \u03b1 \u2192 Prop} [decidable_pred p]\n  (f : perm (subtype p)) : sign (of_subtype f) = sign f :=\nhave \u2200 x, of_subtype f x \u2260 x \u2192 p x, from \u03bb x, not_imp_comm.1 (of_subtype_apply_of_not_mem f),\nby conv {to_rhs, rw [\u2190 subtype_perm_of_subtype f, sign_subtype_perm _ _ this]}\n\nlemma sign_eq_sign_of_equiv [decidable_eq \u03b2] [fintype \u03b2] (f : perm \u03b1) (g : perm \u03b2)\n  (e : \u03b1 \u2243 \u03b2) (h : \u2200 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 \u03b2] [fintype \u03b2]\n  {f : perm \u03b1} {g : perm \u03b2} (i : \u03a0 x : \u03b1, f x \u2260 x \u2192 \u03b2)\n  (h : \u2200 x hx hx', i (f x) hx' = g (i x hx))\n  (hi : \u2200 x\u2081 x\u2082 hx\u2081 hx\u2082, i x\u2081 hx\u2081 = i x\u2082 hx\u2082 \u2192 x\u2081 = x\u2082)\n  (hg : \u2200 y, g y \u2260 y \u2192 \u2203 x hx, i x hx = y) :\n  sign f = sign g :=\ncalc sign f = sign (@subtype_perm _ f (\u03bb x, f x \u2260 x) (by simp)) :\n  (sign_subtype_perm _ _ (\u03bb _, id)).symm\n... = sign (@subtype_perm _ g (\u03bb x, g x \u2260 x) (by simp)) :\n  sign_eq_sign_of_equiv _ _\n    (equiv.of_bijective (\u03bb x : {x // f x \u2260 x},\n        (\u27e8i x.1 x.2, have f (f x) \u2260 f x, from mt (\u03bb h, f.injective h) x.2,\n          by { rw [\u2190 h _ x.2 this], exact mt (hi _ _ this x.2) x.2 }\u27e9 : {y // g y \u2260 y}))\n        \u27e8\u03bb \u27e8x, hx\u27e9 \u27e8y, hy\u27e9 h, subtype.eq (hi _ _ _ _ (subtype.mk.inj h)),\n          \u03bb \u27e8y, hy\u27e9, let \u27e8x, hfx, hx\u27e9 := hg y hy in \u27e8\u27e8x, hfx\u27e9, subtype.eq hx\u27e9\u27e9)\n      (\u03bb \u27e8x, _\u27e9, subtype.eq (h x _ _))\n... = sign g : sign_subtype_perm _ _ (\u03bb _, id)\n\n/-- If we apply `prod_extend_right a (\u03c3 a)` for all `a : \u03b1` in turn,\nwe get `prod_congr_right \u03c3`. -/\nlemma prod_prod_extend_right {\u03b1 : Type*} [decidable_eq \u03b1] (\u03c3 : \u03b1 \u2192 perm \u03b2)\n  {l : list \u03b1} (hl : l.nodup) (mem_l : \u2200 a, a \u2208 l) :\n  (l.map (\u03bb a, prod_extend_right a (\u03c3 a))).prod = prod_congr_right \u03c3 :=\nbegin\n  ext \u27e8a, b\u27e9 : 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 \u2208 l \u2227 (l.map (\u03bb a, prod_extend_right a (\u03c3 a))).prod (a, b) = (a, \u03c3 a b)) \u2228\n             (a \u2209 l \u2227 (l.map (\u03bb a, prod_extend_right a (\u03c3 a))).prod (a, b) = (a, b)),\n  { obtain \u27e8_, prod_eq\u27e9 := or.resolve_right this (not_and.mpr (\u03bb 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 \u27e8list.not_mem_nil _, _\u27e9,\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 \u27e8mem_l, prod_eq\u27e9 | \u27e8not_mem_l, prod_eq\u27e9; rw prod_eq,\n  { refine or.inl \u27e8list.mem_cons_of_mem _ mem_l, _\u27e9,\n    rw prod_extend_right_apply_ne _ (\u03bb (h : a = a'), (list.nodup_cons.mp hl).1 (h \u25b8 mem_l)) },\n  by_cases ha' : a = a',\n  { rw \u2190 ha' at *,\n    refine or.inl \u27e8l.mem_cons_self a, _\u27e9,\n    rw prod_extend_right_apply_eq },\n  { refine or.inr \u27e8\u03bb h, not_or ha' not_mem_l ((list.mem_cons_iff _ _ _).mp h), _\u27e9,\n    rw prod_extend_right_apply_ne _ ha' },\nend\n\nsection congr\n\nvariables [decidable_eq \u03b2] [fintype \u03b2]\n\n@[simp] lemma sign_prod_extend_right (a : \u03b1) (\u03c3 : perm \u03b2) :\n  (prod_extend_right a \u03c3).sign = \u03c3.sign :=\nsign_bij (\u03bb (ab : \u03b1 \u00d7 \u03b2) _, ab.snd)\n  (\u03bb \u27e8a', b\u27e9 hab hab', by simp [eq_of_prod_extend_right_ne hab])\n  (\u03bb \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 hab\u2081 hab\u2082 h,\n    by simpa [eq_of_prod_extend_right_ne hab\u2081, eq_of_prod_extend_right_ne hab\u2082] using h)\n  (\u03bb y hy, \u27e8(a, y), by simpa, by simp\u27e9)\n\nlemma sign_prod_congr_right (\u03c3 : \u03b1 \u2192 perm \u03b2) :\n  sign (prod_congr_right \u03c3) = \u220f k, (\u03c3 k).sign :=\nbegin\n  obtain \u27e8l, hl, mem_l\u27e9 := fintype.exists_univ_list \u03b1,\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 [\u2190 prod_prod_extend_right \u03c3 hl mem_l, sign.map_list_prod,\n      list.map_map, \u2190 l_to_finset, list.prod_to_finset _ hl],\n  simp_rw \u2190 \u03bb a, sign_prod_extend_right a (\u03c3 a)\nend\n\nlemma sign_prod_congr_left (\u03c3 : \u03b1 \u2192 perm \u03b2) :\n  sign (prod_congr_left \u03c3) = \u220f k, (\u03c3 k).sign :=\nbegin\n  refine (sign_eq_sign_of_equiv _ _ (prod_comm \u03b2 \u03b1) _).trans (sign_prod_congr_right \u03c3),\n  rintro \u27e8b, \u03b1\u27e9,\n  refl\nend\n\n@[simp] lemma sign_perm_congr (e : \u03b1 \u2243 \u03b2) (p : perm \u03b1) :\n  (e.perm_congr p).sign = p.sign :=\nsign_eq_sign_of_equiv _ _ e.symm (by simp)\n\n@[simp] lemma sign_sum_congr (\u03c3a : perm \u03b1) (\u03c3b : perm \u03b2) :\n  (sum_congr \u03c3a \u03c3b).sign = \u03c3a.sign * \u03c3b.sign :=\nbegin\n  suffices : (sum_congr \u03c3a (1 : perm \u03b2)).sign = \u03c3a.sign \u2227\n             (sum_congr (1 : perm \u03b1) \u03c3b).sign = \u03c3b.sign,\n  { rw [\u2190this.1, \u2190this.2, \u2190sign_mul, sum_congr_mul, one_mul, mul_one], },\n  split,\n  { apply \u03c3a.swap_induction_on _ (\u03bb \u03c3a' a\u2081 a\u2082 ha ih, _),\n    { simp },\n    { rw [\u2190one_mul (1 : perm \u03b2), \u2190sum_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 \u03c3b.swap_induction_on _ (\u03bb \u03c3b' b\u2081 b\u2082 hb ih, _),\n    { simp },\n    { rw [\u2190one_mul (1 : perm \u03b1), \u2190sum_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 : \u03b1 \u2192 Prop} [decidable_pred p]\n  (ep : perm {a // p a}) (en : perm {a // \u00ac 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 \u03b1)\n  {p : \u03b2 \u2192 Prop} [decidable_pred p] (f : \u03b1 \u2243 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\u2081 w\u2082\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 | \u2200 (y : L), (y \u2208 H) \u2192 \u2045x, y\u2046 \u2208 H },\n  zero_mem' := \u03bb y hy, by { rw zero_lie y, exact H.zero_mem, },\n  add_mem'  := \u03bb z\u2081 z\u2082 h\u2081 h\u2082 y hy, by { rw add_lie, exact H.add_mem (h\u2081 y hy) (h\u2082 y hy), },\n  smul_mem' := \u03bb t y hy z hz, by { rw smul_lie, exact H.smul_mem t (hy z hz), },\n  lie_mem'  := \u03bb z\u2081 z\u2082 h\u2081 h\u2082 y hy, by\n    { rw lie_lie, exact H.sub_mem (h\u2081 _ (h\u2082 y hy)) (h\u2082 _ (h\u2081 y hy)), }, }\n\nlemma mem_normalizer_iff (x : L) : x \u2208 H.normalizer \u2194 \u2200 (y : L), (y \u2208 H) \u2192 \u2045x, y\u2046 \u2208 H := iff.rfl\n\nlemma mem_normalizer_iff' (x : L) : x \u2208 H.normalizer \u2194 \u2200 (y : L), (y \u2208 H) \u2192 \u2045y, x\u2046 \u2208 H :=\nforall\u2082_congr $ \u03bb y hy, by rw [\u2190 lie_skew, H.neg_mem_iff]\n\nlemma le_normalizer : H \u2264 H.normalizer :=\n\u03bb x hx, show \u2200 (y : L), y \u2208 H \u2192 \u2045x,y\u2046 \u2208 H, from \u03bb y, H.lie_mem hx\n\nvariables {H}\n\nlemma lie_mem_sup_of_mem_normalizer {x y z : L} (hx : x \u2208 H.normalizer)\n  (hy : y \u2208 (R \u2219 x) \u2294 \u2191H) (hz : z \u2208 (R \u2219 x) \u2294 \u2191H) : \u2045y, z\u2046 \u2208 (R \u2219 x) \u2294 \u2191H :=\nbegin\n  rw submodule.mem_sup at hy hz,\n  obtain \u27e8u\u2081, hu\u2081, v, hv : v \u2208 H, rfl\u27e9 := hy,\n  obtain \u27e8u\u2082, hu\u2082, w, hw : w \u2208 H, rfl\u27e9 := hz,\n  obtain \u27e8t, rfl\u27e9 := submodule.mem_span_singleton.mp hu\u2081,\n  obtain \u27e8s, rfl\u27e9 := submodule.mem_span_singleton.mp hu\u2082,\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 : \u2200 {x y : L}, x \u2208 H.normalizer \u2192 y \u2208 H \u2192 \u2045x,y\u2046 \u2208 H :=\n\u03bb 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\u2081 : H \u2264 K) (h\u2082 : K \u2264 H.normalizer) :\n  \u2203 (I : lie_ideal R K), (I : lie_subalgebra R K) = of_le h\u2081 :=\nbegin\n  rw exists_nested_lie_ideal_coe_eq_iff,\n  exact \u03bb x y hx hy, ideal_in_normalizer (h\u2082 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 : \u2200 (x y : L), x \u2208 N \u2192 y \u2208 H \u2192 \u2045x,y\u2046 \u2208 H) : N \u2264 H.normalizer :=\n\u03bb x hx y, h x y hx\n\nvariables (H)\n\nlemma normalizer_eq_self_iff :\n  H.normalizer = H \u2194 (lie_module.max_triv_submodule R H $ L \u29f8 H.to_lie_submodule) = \u22a5 :=\nbegin\n  rw lie_submodule.eq_bot_iff,\n  refine \u27e8\u03bb h, _, \u03bb h, le_antisymm (\u03bb x hx, _) H.le_normalizer\u27e9,\n  { rintros \u27e8x\u27e9 hx,\n    suffices : x \u2208 H, by simpa,\n    rw [\u2190 h, H.mem_normalizer_iff'],\n    intros y hy,\n    replace hx : \u2045_, lie_submodule.quotient.mk' _ x\u2046 = 0 := hx \u27e8y, hy\u27e9,\n    rwa [\u2190 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 \u2208 lie_module.max_triv_submodule R H (L \u29f8 H.to_lie_submodule),\n    { rintros \u27e8z, hz\u27e9,\n      rw [\u2190 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 = \u22a4 :=\nbegin\n  ext x,\n  simpa only [lie_subalgebra.mem_normalizer_iff, lie_subalgebra.mem_top, iff_true]\n    using \u03bb 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 (\u22a4 : lie_subalgebra R L) :=\n{ nilpotent        := infer_instance,\n  self_normalizing :=\n    by { rw [\u2190 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 := \u03bb 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\u2080 x\u2081 x\u2082 x\u2083 : X}\n\nprotected def cast (p\u2080 : x\u2080 = x\u2081) (p\u2081 : x\u2082 = x\u2083) (P : path.homotopic.quotient x\u2081 x\u2083) : \n  (path.homotopic.quotient x\u2080 x\u2082) := by rwa [p\u2080, p\u2081]\n\n@[simp] lemma cast_of_eq (P : path.homotopic.quotient x\u2080 x\u2081) : path.homotopic.cast rfl rfl P = P := rfl \n\nlemma cast_lift (p\u2080 : x\u2080 = x\u2081) (p\u2081 : x\u2082 = x\u2083) (P\u2080 : path x\u2081 x\u2083) : \u27e6P\u2080.cast p\u2080 p\u2081\u27e7 = path.homotopic.cast p\u2080 p\u2081 \u27e6P\u2080\u27e7 := \nby { subst_vars, rw cast_of_eq, congr, ext, rw path.cast_coe, }\n\nlemma path_heq_cast (p\u2080 : x\u2080 = x\u2081) (p\u2081 : x\u2082 = x\u2083) (P : path x\u2081 x\u2083) : P.cast p\u2080 p\u2081 == P :=\nby { subst_vars, rw heq_iff_eq, ext, rw path.cast_coe, }\n\nlemma path.homotopic.heq_cast (p\u2080 : x\u2080 = x\u2081) (p\u2081 : x\u2082 = x\u2083) (P : path.homotopic.quotient x\u2081 x\u2083) : \npath.homotopic.cast p\u2080 p\u2081 P == P := by { subst_vars, refl, }\n\nend cast\n\nvariables (x\u2080 x\u2081 : X) (p : path.homotopic.quotient x\u2080 x\u2081)\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\u2080)) (H (1, x\u2081)) :=\n(path.homotopic.prod \u27e6straight_path\u27e7 p).map_fn H.to_continuous_map\n\ndef diagonal_path' : path.homotopic.quotient (f x\u2080) (g x\u2081) :=  \npath.homotopic.cast (H.apply_zero x\u2080).symm (H.apply_one x\u2081).symm (diagonal_path H x\u2080 x\u2081 p)\n\nlemma up_is_f : (p.map_fn f) = path.homotopic.cast (H.apply_zero x\u2080).symm (H.apply_zero x\u2081).symm ((path.homotopic.prod \u27e6path.refl (0 : I)\u27e7 p).map_fn H.to_continuous_map) :=\nbegin\n  apply quotient.induction_on p,\n  intro p',\n  rw [path.homotopic.prod_lift, \u2190 path.homotopic.map_lift, \u2190 path.homotopic.map_lift, \u2190 cast_lift],\n  congr, ext, simp,\nend\n\nlemma down_is_g : p.map_fn g = path.homotopic.cast (H.apply_one x\u2080).symm (H.apply_one x\u2081).symm ((path.homotopic.prod \u27e6path.refl (1 : I)\u27e7 p).map_fn H.to_continuous_map) :=\nbegin\n  apply quotient.induction_on p,\n  intro p',\n  rw [path.homotopic.prod_lift, \u2190 path.homotopic.map_lift, \u2190 path.homotopic.map_lift, \u2190 cast_lift],\n  congr, ext, simp,\nend\n\nlemma H_to_path (x : X) : \u27e6H.to_path x\u27e7 =\n  path.homotopic.cast (H.apply_zero x).symm (H.apply_one x).symm ((path.homotopic.prod \u27e6straight_path\u27e7 \u27e6path.refl x\u27e7).map_fn H.to_continuous_map) :=\nby { rw [prod_lift, \u2190 map_lift, \u2190 cast_lift], refl, }\n\nlemma up_right_is_diag : (p.map_fn f).comp \u27e6H.to_path x\u2081\u27e7 = diagonal_path' H x\u2080 x\u2081 p :=\nbegin\n  rw up_is_f H x\u2080 x\u2081 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) \u2192 \n           (head : Clause (n + 1)) \u2192 \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) \u2192 \n    (clausesAccum: Vector (Clause (n + 1)) domAccum) \u2192 \n    (s : domHead + domAccum = dom) \u2192 \n    (restAcum : ReductionData branch focus focusLt clausesAccum) \u2192 \n    (clauses: Vector (Clause (n + 1)) dom) \u2192\n    (clsEq : concatSeqAux s clausesHead.coords clausesAccum.coords = clauses.coords) \u2192    \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 [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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               \u2190 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) \u2192   \n        ReductionData branch focus focusLt clauses := \n        fun clauses =>\n          let rc : ReductionClauses branch focus focusLt Vector.nil := \n              \u27e80, Vector.nil, Vector.nil,\n                fun k w => nomatch w, \n                Vector.nil, fun k w => nomatch w\u27e9\n          let rd : ReductionData branch focus focusLt Vector.nil := \u27e8rc,\n            \u27e8fun k w => nomatch w\u27e9,\n            \u27e8fun k w => nomatch w\u27e9,\n            \u27e8fun k w => nomatch w\u27e9, \n            \u27e8(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            )\u27e9\u27e9\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) \u2192  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                      \u27e8zero, zero_lt_succ _, lem\u27e9                      \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                      \u27e8zero, zero_lt_succ _, lem\u27e9\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) \u2192 x = none \u2228  x = some b  \u2192 \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 [\u2190 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 [\u2190 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) \u2192 SatSolution clauses := \n          fun sol =>\n          match sol with\n          | SatSolution.sat val pf => \n              SatSolution.sat val (\n                fun k kw => \n                        let \u27e8ind, bd, w\u27e9 := 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) \u2192  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 \u27e8i, iw, index, bd, par, eql\u27e9 => \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 \u27e8index, bd, par, evid\u27e9=> \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) \u2192 (lt : j < cntn.codom) \u2192 \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 \u27e8valuation, evidence\u27e9\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 \u27e8valuation, evidence\u27e9 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 \u2192 exp\n| const : \u2115 \u2192 exp\n| abs : atom \u2192 exp \u2192 exp\n| app : exp \u2192 exp \u2192 exp\n\nopen exp\n\ndef fvs : exp \u2192 list atom\n| (var v)     := [v]\n| (const n)   := []\n| (abs v e)   := remove_all (fvs e) [v]\n| (app e\u2081 e\u2082) := fvs e\u2081 \u222a fvs e\u2082\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 \u2192 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\u2081 e\u2082) := app (swap e\u2081) (swap e\u2082)\n\n@[reducible] def heap := hash_map atom (\u03bb x, exp)\nstructure frame := (val : exp)\ndef stack := list frame\n\nstructure config := (hp : heap) (t : exp) (stk : stack)\n\ninductive step (\u03b1 : Type) : Type\n| error {}  : step\n| done  {}  : exp \u2192 step\n| take      : \u03b1 \u2192 step\n\ndef machine_step (avoid : list atom) : config \u2192 step config\n| \u27e8hp, abs x e, []\u27e9 := step.done (abs x e)\n\n| \u27e8hp, abs x e, (\u27e8val\u27e9 :: stk)\u27e9 :=\n if x \u2208 hp \u2228 x \u2208 avoid\n then let y := atom.fresh (hp^.keys \u222a avoid) in step.take \u27e8hp^.insert y val, swap x y e, stk\u27e9\n else step.take \u27e8hp^.insert x val, e, stk\u27e9\n\n| \u27e8hp, var x, stk\u27e9 := match hp^.find x with\n                     | some e := step.take \u27e8hp, e, stk\u27e9\n                     | none   := step.error\n                     end\n\n| \u27e8hp, app f a, stk\u27e9 := step.take \u27e8hp, f, \u27e8a\u27e9 :: stk\u27e9\n\n\n| \u27e8hp, const n, stk\u27e9 := step.done (const n)\n\ndef init_config (t : exp) : config := \u27e8mk_hash_map (\u03bb a : atom, a^.id), t, []\u27e9\n\ndef is_val : exp \u2192 Prop\n| (abs _ _) := true\n| _         := false\n\nlemma values_are_done (avoid : list atom) : \u2200 (t : exp), is_val t \u2192 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 \u2192 \u2115\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) : \u2200 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 \u2192 exp\n| const : \u2115 \u2192 exp\n| abs : atom \u2192 exp \u2192 exp\n| app : exp \u2192 exp \u2192 exp\n-/\nopen exp\n\ninductive result : Type\n| error   : string \u2192 result\n| done    : exp \u2192 result\n| nofuel  : exp \u2192 result\n\ndef reduce (avoid : list atom) : \u2115 \u2192 config \u2192 result\n| 0     \u27e8hp, e, stk\u27e9       := result.nofuel e\n| (t+1) \u27e8hp, abs x e, []\u27e9  := result.done (abs x e)\n| (t+1) \u27e8hp, const n, stk\u27e9 := result.done (const n)\n\n| (t+1) \u27e8hp, abs x e, (\u27e8val\u27e9 :: stk)\u27e9 :=\n if x \u2208 hp \u2228 x \u2208 avoid\n then let y := atom.fresh (hp^.keys \u222a avoid) in reduce t \u27e8hp^.insert y val, swap x y e, stk\u27e9\n else reduce t \u27e8hp^.insert x val, e, stk\u27e9\n\n| (t+1) \u27e8hp, var x, stk\u27e9 :=\n match hp^.find x with\n | some e := reduce t \u27e8hp, e, stk\u27e9\n | none   := result.error \"variable not found\"\n end\n\n| (t+1) \u27e8hp, app f a, stk\u27e9 := reduce t \u27e8hp, f, \u27e8a\u27e9 :: stk\u27e9\n\nexample : reduce [] 10 (init_config $ app (abs \u27e80\u27e9 (var \u27e80\u27e9)) (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) \u27f6 X.function_field :=\nX.presheaf.germ \u27e8generic_point X.carrier,\n  ((generic_point_spec X.carrier).mem_open_set_iff U.is_open).mpr (by simpa using h)\u27e9\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 \u27e8U, m, s, rfl\u27e9 := Top.presheaf.germ_exist _ _ a,\n  rw [or_iff_not_imp_right, \u2190 (X.presheaf.germ \u27e8_, m\u27e9).map_zero],\n  intro ha,\n  replace ha := ne_of_apply_ne _ ha,\n  have hs : generic_point X.carrier \u2208 RingedSpace.basic_open _ s,\n  { rw [\u2190 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, \u2190 opens.coe_bot,\n      \u2190 set_like.ext'_iff],\n    erw basic_open_eq_bot_iff,\n    exacts [ha, (RingedSpace.basic_open _ _).is_open] },\n  have := (X.presheaf.germ \u27e8_, hs\u27e9).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 \u2190 (X.presheaf.germ x).map_zero at hy,\n  obtain \u27e8W, hW, iU, iV, e\u27e9 := X.presheaf.germ_eq _ x.prop x.prop _ _ hy,\n  cases (show iU = iV, from subsingleton.elim _ _),\n  haveI : nonempty W := \u27e8\u27e8_, hW\u27e9\u27e9,\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 \u27f6 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 \u27e8_, trivial, set.mem_range_self hX.2.some\u27e9,\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 \u226b _,\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 \u27f6 _, 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 = (\u27e80, ideal.bot_prime\u27e9 : prime_spectrum R) :=\nbegin\n  apply (generic_point_spec (Scheme.Spec.obj $ op R).carrier).eq,\n  simp [is_generic_point_def, \u2190 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 \u27e8generic_point X.carrier,\n    ((generic_point_spec X.carrier).mem_open_set_iff U.is_open).mpr (by simpa using h)\u27e9 =\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 \u22a4 = U,\n  { ext1, exact set.image_univ.trans subtype.range_coe },\n  delta is_affine_open.prime_ideal_of,\n  rw \u2190 Scheme.comp_val_base_apply,\n  convert (generic_point_eq_of_is_open_immersion ((X.restrict U.open_embedding).iso_Spec.hom \u226b\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 \u22a4 = 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 \u27e8generic_point X.carrier, _\u27e9 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 := \u27e8set.range (X.affine_cover.map x).1.base,\n    PresheafedSpace.is_open_immersion.base_open.open_range\u27e9,\n  haveI : nonempty U := \u27e8\u27e8_, X.affine_cover.covers x\u27e9\u27e9,\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 \u27e8x, X.affine_cover.covers x\u27e9)\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 {\u03b1: TypeDecl} (x: Var \u03b1) (e: Expr \u03b1) (P: Assert)\n                    : Assert :=\n    \u03bb s h, (eval e s).elim \u22a4 (\u03bb 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 {\u03b1: TypeDecl} (x: Var \u03b1) (e: Expr (gPtr \u03b1)) (P: Assert)\n              : Assert :=\n\t  \u03bb s h,\n\t    \u2203 p, val2loc (eval e s) = some p \u2227\n\t      \u2203 (z: Val \u03b1), h.lookup p = some z \u2227\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 {\u03b1: TypeDecl} (e:Expr (gPtr \u03b1)) (e':Expr \u03b1) (P:Assert)\n                  : Assert :=\n\t  \u03bb s h ,\n      (eval e' s).elim \u22a4 (\u03bb v, -- 2nd expr being an error gives trivial Assert\n\t    \u2203 p, val2loc (eval e s) = some p \u2227\n\t      \u2203 (z: Val \u03b1), h.lookup p = some z \u2227\n\t        P s (h.update v p)).\n\n  open cmd\n\n\tinductive semax: Assert -> cmd -> Assert -> Prop\n\t  | semax_skip: \u2200 P, semax P skip P\n\t  | semax_assign: \u2200 {\u03b1: TypeDecl} (P: Assert) (x: Var \u03b1) (e: Expr \u03b1),\n\t    semax (update_store2 x e P) (x \u21d0 e) P\n\t  | semax_lookup: \u2200 {\u03b1: TypeDecl} (P: Assert) (x: Var \u03b1) (e: Expr (gPtr \u03b1)),\n\t    semax (lookup2 x e P) (x \u21a9 e) P\n\t  | semax_mutation: \u2200 {\u03b1: TypeDecl} (P: Assert) (e: Expr (gPtr \u03b1))\n                        (e': Expr \u03b1),\n\t    semax (update_heap2 e e' P) (e \u226a e') P\n\n\t  | semax_seq: \u2200 P Q R c d,\n\t    semax P c Q -> semax Q d R -> semax P (c \u2223 d) R\n\t  | semax_while: \u2200 (P: Assert) (b: Expr gBool) c,\n\t    semax (\u03bb s h, (P s h \u2227 eval b s = some tt)) c P ->\n\t    semax P (while b c) (\u03bb s h, P s h \u2227 eval b s = some ff)\n\t  | semax_conseq: \u2200 (P P' Q Q':Assert) c,\n\t    (Q' \u27f9 Q) -> (P \u27f9 P') ->\n\t    semax P' c Q' -> semax P c Q\n\t  | semax_ifte: \u2200 (P Q: Assert) (b: Expr gBool) c d,\n\t    semax (\u03bb s h, P s h \u2227 eval b s = some tt) c Q ->\n\t    semax (\u03bb s h, P s h \u2227 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 : \u2200 (P Q Q': Assert) c,\n\t  (Q' \u27f9 Q) -> {{ P }} c {{ Q' }} -> {{ P }} c {{ Q }} := sorry.\n\n  lemma semax_strengthen_pre : \u2200 (P P':Assert) Q c,\n  \t  (P \u27f9 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        \u2200 s h, (P s h -> \u00ac(exec (some (s, h)) c none)) \u2227\n          (\u2200 s' h', P s h -> (exec (some (s, h)) c  (some (s', h'))) -> Q s' h')\n\n\tlemma semax_sound : \u2200 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 \u2192 Assert\n\n\n  def wp_semantics (c: cmd) (Q: Assert'): Assert' :=\n      \u03bb d s h,\n        \u00ac (exec (some (s, h, d))  c none) \u2227\n        \u2200 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    \u2200 {\u03b1: TypeDecl} (s: Store) (h: Heap) (d: Decls) (v: Var \u03b1)\n      (e: Expr (gPtr \u03b1)),\n        \u00ac (exec (some (s, h, d)) (v \u21a9 e) none) ->\n          \u2203 p : Address,\n            val2loc (eval e s) = some p \u2227\n            (\u2203 z: Val \u03b1, h.lookup p = some z)\n            := sorry.\n\n  lemma exec_mutation_not_None:\n    \u2200 {\u03b1: TypeDecl} (s: Store) (h: Heap) (d: Decls) (e: Expr (gPtr \u03b1))\n      (e0: Expr \u03b1),\n        \u00ac exec (some (s, h, d)) (e \u226a e0) none ->\n        \u2203 p : Address,\n          val2loc (eval e s) = some p \u2227\n          (\u2203 z: Val \u03b1, h.lookup p = some z)\n          := sorry.\n\n  lemma exec_seq1_not_None: \u2200 (s: Store) (h: Heap) (c1 c2: cmd),\n      \u00ac exec (some (s, h))  (c1 \u2223 c2)  none ->\n      \u00ac exec (some (s, h)) c1 none\n      := sorry.\n\n  lemma exec_seq2_not_None:\n    \u2200 (s: Store) (h: Heap) (c1 c2: cmd) (s': Store) (h': Heap),\n      \u00ac exec (some (s, h)) (c1 \u2223 c2) none ->\n      exec (some (s, h)) c1 (some (s',h')) ->\n      \u00ac exec (some (s', h')) c2 none\n      := sorry.\n\n  lemma exec_ifte1_not_None: \u2200 s h c1 c2 e,\n      \u00ac exec (some (s, h))  (ifte e  c1  c2)  none ->\n      eval e s = some tt ->\n      \u00ac exec (some (s, h)) c1  none\n      := sorry.\n\n  lemma exec_ifte2_not_None: \u2200 s h c1 c2 e,\n      \u00ac exec (some (s, h))  (ifte e  c1  c2)  none ->\n      eval e s = some ff ->\n      \u00ac exec (some (s, h)) c2  none\n      := sorry.\n\n  lemma exec_while1_not_None: \u2200 s h e c,\n        \u00ac exec (some (s, h)) (while e c) none ->\n        eval e s = some tt ->\n        \u00ac exec (some (s, h)) c none\n        := sorry.\n\n  lemma exec_while2_not_None: \u2200 s h e c s' h',\n        \u00ac exec (some (s, h)) (while e c) none ->\n        eval e s = some tt ->\n        exec (some (s, h)) c (some (s', h')) ->\n      \u00ac exec (some (s', h')) (while e c)  none\n      := sorry.\n\n  lemma wp_semantics_sound: \u2200 c Q,\n      {{wp_semantics c Q}} c {{Q}} := sorry.\n\n  lemma semax_complete : \u2200 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      \u2200 s h, P s h ->\n        (\u2200 s' h', exec (some (s, h))  c  (some (s', h')) -> (Q s' h')).\n\n  lemma semax_sound_alternative : \u2200 P Q c,\n    {{ P }} c {{ Q }} -> semax_alternative P c Q := sorry.\n\n  /- Derived reynolds' axioms-/\n  lemma semax_lookup_backwards:\n    \u2200{\u03b1: TypeDecl} (x : Var \u03b1) (e: Expr (gPtr \u03b1)) (P: Assert),\n      {{ \u03bb s h, \u2203 e0, (e \u21a6 e0 \u2217 (e \u21a6 e0 \u22b8 update_store2 x e0 P)) s h }}\n       (x \u21a9 e) {{ P }} := sorry.\n\n  lemma semax_lookup_backwards_alternative :\n    \u2200{\u03b1: TypeDecl} (x : Var ( \u03b1)) (e: Expr (gPtr \u03b1)) (P: Assert) (e0: Expr \u03b1),\n      {{ ((e \u21a6 e0) \u2217 ((e \u21a6 e0) \u22b8 (update_store2 x e0 P))) }} (x \u21a9 e) {{ P }}\n      := sorry.\n\n  lemma semax_mutation_local: \u2200{\u03b1: TypeDecl} (x : Expr (gPtr \u03b1)) v v',\n        {{ (x \u21a6 v) }} (x \u226a v') {{ (x \u21a6 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 \u2192 list (\u03a3 \u03b1: TypeDecl, Var \u03b1)\n    | skip              := list.nil\n    | (assign x e)      := [\u27e8_, x\u27e9]\n    | (lookup x e)      := [\u27e8_, x\u27e9]\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)       := [\u27e8_, x\u27e9]\n    | (new x)           := [\u27e8_, x\u27e9]\n    | (call _ _ _ vars) := vars\n\n  lemma inde_seq : \u2200 R (c d: cmd),\n\t  inde (modified_cmd_var (c \u2223 d)) R ->\n\t  inde (modified_cmd_var c) R \u2227 inde (modified_cmd_var d) R := sorry.\n\n  lemma inde_ifte : \u2200 R b c d,\n      inde (modified_cmd_var (ifte b  c  d)) R \u2192\n      inde (modified_cmd_var c) R \u2227 inde (modified_cmd_var d) R := sorry.\n\n  lemma frame_rule : \u2200 (P: Assert) (c: cmd) (Q: Assert),\n      {{P}} c {{Q}} ->\n      \u2200 (R: Assert) ,\n        (inde (modified_cmd_var c) R ->\n          {{ (P \u2217 R) }} c {{ (Q \u2217 R) }}) := sorry.\n\n  /-\n  - More reynolds axioms\n  -/\n\n\tlemma semax_mutation_global :\n    \u2200 {\u03b1: TypeDecl} (P: Assert) (e: Expr (gPtr \u03b1)) e',\n\t  {{((\u03bb s' h', \u2203 e'', (((e \u21a6 e'') s' h'))) \u2217 P) }} (e \u226a e') {{((e \u21a6 e')\u2217P)}}\n    := sorry.\n\n  lemma semax_mutation_global_alternative :\n    \u2200 {\u03b1: TypeDecl} (P: Assert) (e: Expr (gPtr \u03b1)) e' e'',\n      {{ ((e \u21a6 e'') \u2217 P) }} (e \u226a e') {{ ((e \u21a6 e') \u2217 P) }} := sorry.\n\n  lemma semax_mutation_backwards :\n    \u2200 {\u03b1: TypeDecl} (P: Assert) (e: Expr (gPtr \u03b1)) e',\n      {{\u03bb s h, \u2203 e'', ((e \u21a6 e'')\u2217(e \u21a6 e' \u22b8 P)) s h}} (e \u226a e') {{P}} := sorry.\n\n\n\tlemma semax_mutation_backwards_alternative :\n   \u2200 {\u03b1: TypeDecl} (P: Assert) (e: Expr (gPtr \u03b1)) e' e'',\n\t  {{ ((e \u21a6 e'') \u2217 ((e \u21a6 e') \u22b8 P)) }} (e \u226a 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 \u27f6 Y) (hf : function.surjective f) :\n  quotient_map f :=\nbegin\n  rw quotient_map_iff,\n  refine \u27e8hf,_\u27e9,\n  intro S,\n  refine \u27e8\u03bb hS, hS.preimage f.continuous, \u03bb hS, _\u27e9,\n  rw \u2190 is_closed_compl_iff at *,\n  rw \u2190 set.preimage_compl at hS,\n  have : S\u1d9c = f '' (f \u207b\u00b9' S\u1d9c),\n  { ext,\n    split,\n    { intro h,\n      obtain \u27e8y,rfl\u27e9 := hf x,\n      refine \u27e8y,h,rfl\u27e9 },\n    { rintro \u27e8y,h,rfl\u27e9,\n      exact h } },\n  rw this,\n  exact Profinite.is_closed_map f (\u21d1f \u207b\u00b9' S\u1d9c) 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 \u2964 D` and `G : D \u2964 C` such\nthat `\u03b7 : \ud835\udfed C \u2245 F \u22d9 G` and `\u03b5 : G \u22d9 F \u2245 \ud835\udfed 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 \u2964 D` and `G : D \u2964 C` are adjoint is using\ntwo natural transformations `\u03b7 : \ud835\udfed C \u27f6 F \u22d9 G` and `\u03b5 : G \u22d9 F \u27f6 \ud835\udfed D`, called the unit and the\ncounit, such that the compositions `F \u27f6 FGF \u27f6 F` and `G \u27f6 GFG \u27f6 G` are the identity. Unfortunately,\nit is not the case that the natural isomorphisms `\u03b7` and `\u03b5` 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 `\u03b7` 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, \u03b7, \u03b5)` as in the first paragraph such that the composite `F \u27f6 FGF \u27f6 F` is the\nidentity. By the remark above, this already implies that the tuple is an \"adjoint equivalence\",\ni.e., that the composite `G \u27f6 GFG \u27f6 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 `\u03b7` and `\u03b5`.\n* `ess_surj`: type class on a functor `F` containing the data of the preimages and the isomorphisms\n  `F.obj (preimage d) \u2245 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 \u224c D` (`\\backcong`, not to be confused with `\u2245`/`\\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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\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\u03b7 \u226b \u03b5F = 1`, or in other\n  words the composite `F \u27f6 FGF \u27f6 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 \u27f6 GFG \u27f6 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 \u27f6 F1`.\n\nSee https://stacks.math.columbia.edu/tag/001J\n-/\nstructure equivalence (C : Type u\u2081) [category.{v\u2081} C] (D : Type u\u2082) [category.{v\u2082} D] :=\nmk' ::\n(functor : C \u2964 D)\n(inverse : D \u2964 C)\n(unit_iso   : \ud835\udfed C \u2245 functor \u22d9 inverse)\n(counit_iso : inverse \u22d9 functor \u2245 \ud835\udfed D)\n(functor_unit_iso_comp' : \u2200(X : C), functor.map ((unit_iso.hom : \ud835\udfed C \u27f6 functor \u22d9 inverse).app X) \u226b\n  counit_iso.hom.app (functor.obj X) = \ud835\udfd9 (functor.obj X) . obviously)\n\nrestate_axiom equivalence.functor_unit_iso_comp'\n\ninfixr ` \u224c `:10  := equivalence\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} D]\n\nnamespace equivalence\n\n/-- The unit of an equivalence of categories. -/\nabbreviation unit (e : C \u224c D) : \ud835\udfed C \u27f6 e.functor \u22d9 e.inverse := e.unit_iso.hom\n/-- The counit of an equivalence of categories. -/\nabbreviation counit (e : C \u224c D) : e.inverse \u22d9 e.functor \u27f6 \ud835\udfed D := e.counit_iso.hom\n/-- The inverse of the unit of an equivalence of categories. -/\nabbreviation unit_inv (e : C \u224c D) : e.functor \u22d9 e.inverse \u27f6 \ud835\udfed C := e.unit_iso.inv\n/-- The inverse of the counit of an equivalence of categories. -/\nabbreviation counit_inv (e : C \u224c D) : \ud835\udfed D \u27f6 e.inverse \u22d9 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  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).unit = unit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).counit = counit_iso.hom := rfl\n@[simp] lemma equivalence_mk'_unit_inv (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).unit_inv = unit_iso.inv := rfl\n@[simp] lemma equivalence_mk'_counit_inv (functor inverse unit_iso counit_iso f) :\n  (\u27e8functor, inverse, unit_iso, counit_iso, f\u27e9 : C \u224c D).counit_inv = counit_iso.inv := rfl\n\n@[simp] lemma functor_unit_comp (e : C \u224c D) (X : C) :\n  e.functor.map (e.unit.app X) \u226b e.counit.app (e.functor.obj X) = \ud835\udfd9 (e.functor.obj X) :=\ne.functor_unit_iso_comp X\n\n@[simp] lemma counit_inv_functor_comp (e : C \u224c D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) \u226b e.functor.map (e.unit_inv.app X) = \ud835\udfd9 (e.functor.obj X) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.functor.map_iso (e.unit_iso.app X) \u226a\u226b 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 \u224c D) (X : C) :\n  e.counit_inv.app (e.functor.obj X) = e.functor.map (e.unit.app X) :=\nby { symmetry, erw [\u2190iso.comp_hom_eq_id (e.counit_iso.app _), functor_unit_comp], refl }\n\nlemma counit_app_functor (e : C \u224c D) (X : C) :\n  e.counit.app (e.functor.obj X) = e.functor.map (e.unit_inv.app X) :=\nby { erw [\u2190iso.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 \u224c D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) \u226b e.inverse.map (e.counit.app Y) = \ud835\udfd9 (e.inverse.obj Y) :=\nbegin\n  rw [\u2190id_comp (e.inverse.map _), \u2190map_id e.inverse, \u2190counit_inv_functor_comp, map_comp,\n      \u2190iso.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 [\u2190iso.hom_inv_id_assoc (e.inverse.map_iso (e.counit_iso.app _)) (e.unit_inv.app _)] },\n  slice_lhs 3 4 { erw [\u2190map_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 [\u2190map_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 [\u2190map_comp (e.functor \u22d9 e.inverse), (e.unit_iso.app _).hom_inv_id, map_id] },\n  erw [id_comp],\n  slice_lhs 3 4 { erw [\u2190e.unit_inv.naturality] },\n  slice_lhs 2 3 { erw [\u2190map_comp e.inverse, \u2190e.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 \u224c D) (Y : D) :\n  e.inverse.map (e.counit_inv.app Y) \u226b e.unit_inv.app (e.inverse.obj Y) = \ud835\udfd9 (e.inverse.obj Y) :=\nbegin\n  erw [iso.inv_eq_inv\n    (e.unit_iso.app (e.inverse.obj Y) \u226a\u226b 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 \u224c D) (Y : D) :\n  e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counit_inv.app Y) :=\nby { erw [\u2190iso.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 \u224c D) (Y : D) :\n  e.unit_inv.app (e.inverse.obj Y) = e.inverse.map (e.counit.app Y) :=\nby { symmetry, erw [\u2190iso.hom_comp_eq_id (e.unit_iso.app _), unit_inverse_comp], refl }\n\n@[simp] lemma fun_inv_map (e : C \u224c D) (X Y : D) (f : X \u27f6 Y) :\n  e.functor.map (e.inverse.map f) = e.counit.app X \u226b f \u226b e.counit_inv.app Y :=\n(nat_iso.naturality_2 (e.counit_iso) f).symm\n\n@[simp] lemma inv_fun_map (e : C \u224c D) (X Y : C) (f : X \u27f6 Y) :\n  e.inverse.map (e.functor.map f) = e.unit_inv.app X \u226b f \u226b 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 \u2964 D} {G : D \u2964 C} (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D)\n\n/-- If `\u03b7 : \ud835\udfed C \u2245 F \u22d9 G` is part of a (not necessarily half-adjoint) equivalence, we can upgrade it\nto a refined natural isomorphism `adjointify_\u03b7 \u03b7 : \ud835\udfed C \u2245 F \u22d9 G` which exhibits the properties\nrequired for a half-adjoint equivalence. See `equivalence.mk`. -/\ndef adjointify_\u03b7 : \ud835\udfed C \u2245 F \u22d9 G :=\ncalc\n  \ud835\udfed C \u2245 F \u22d9 G               : \u03b7\n  ... \u2245 F \u22d9 (\ud835\udfed D \u22d9 G)      : iso_whisker_left F (left_unitor G).symm\n  ... \u2245 F \u22d9 ((G \u22d9 F) \u22d9 G) : iso_whisker_left F (iso_whisker_right \u03b5.symm G)\n  ... \u2245 F \u22d9 (G \u22d9 (F \u22d9 G)) : iso_whisker_left F (associator G F G)\n  ... \u2245 (F \u22d9 G) \u22d9 (F \u22d9 G) : (associator F G (F \u22d9 G)).symm\n  ... \u2245 \ud835\udfed C \u22d9 (F \u22d9 G)      : iso_whisker_right \u03b7.symm (F \u22d9 G)\n  ... \u2245 F \u22d9 G               : left_unitor (F \u22d9 G)\n\nlemma adjointify_\u03b7_\u03b5 (X : C) :\n  F.map ((adjointify_\u03b7 \u03b7 \u03b5).hom.app X) \u226b \u03b5.hom.app (F.obj X) = \ud835\udfd9 (F.obj X) :=\nbegin\n  dsimp [adjointify_\u03b7], simp,\n  have := \u03b5.hom.naturality (F.map (\u03b7.inv.app X)), dsimp at this, rw [this], clear this,\n  rw [\u2190assoc _ _ (F.map _)],\n  have := \u03b5.hom.naturality (\u03b5.inv.app $ F.obj X), dsimp at this, rw [this], clear this,\n  have := (\u03b5.app $ F.obj X).hom_inv_id, dsimp at this, rw [this], clear this,\n  rw [id_comp], have := (F.map_iso $ \u03b7.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 \u22d9 G` and\n    `G \u22d9 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 \u2964 D) (G : D \u2964 C)\n  (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D) : C \u224c D :=\n\u27e8F, G, adjointify_\u03b7 \u03b7 \u03b5, \u03b5, adjointify_\u03b7_\u03b5 \u03b7 \u03b5\u27e9\n\n/-- Equivalence of categories is reflexive. -/\n@[refl, simps] def refl : C \u224c C :=\n\u27e8\ud835\udfed C, \ud835\udfed C, iso.refl _, iso.refl _, \u03bb X, category.id_comp _\u27e9\n\ninstance : inhabited (C \u224c C) :=\n\u27e8refl\u27e9\n\n/-- Equivalence of categories is symmetric. -/\n@[symm, simps] def symm (e : C \u224c D) : D \u224c C :=\n\u27e8e.inverse, e.functor, e.counit_iso.symm, e.unit_iso.symm, e.inverse_counit_inv_comp\u27e9\n\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\n/-- Equivalence of categories is transitive. -/\n@[trans, simps] def trans (e : C \u224c D) (f : D \u224c E) : C \u224c E :=\n{ functor := e.functor \u22d9 f.functor,\n  inverse := f.inverse \u22d9 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' := \u03bb X,\n  begin\n    dsimp,\n    rw [\u2190 f.functor.map_comp_assoc, e.functor.map_comp, \u2190counit_inv_app_functor, fun_inv_map,\n        iso.inv_hom_id_app_assoc, assoc, iso.inv_hom_id_app, counit_app_functor,\n        \u2190 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 \u224c D) (F : C \u2964 E) : e.functor \u22d9 e.inverse \u22d9 F \u2245 F :=\n(functor.associator _ _ _).symm \u226a\u226b iso_whisker_right e.unit_iso.symm F \u226a\u226b F.left_unitor\n\n@[simp] lemma fun_inv_id_assoc_hom_app (e : C \u224c D) (F : C \u2964 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 \u224c D) (F : C \u2964 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 \u224c D) (F : D \u2964 E) : e.inverse \u22d9 e.functor \u22d9 F \u2245 F :=\n(functor.associator _ _ _).symm \u226a\u226b iso_whisker_right e.counit_iso F \u226a\u226b F.left_unitor\n\n@[simp] lemma inv_fun_id_assoc_hom_app (e : C \u224c D) (F : D \u2964 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 \u224c D) (F : D \u2964 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 \u2964 E` is equivalent to `D \u2964 E`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_left (e : C \u224c D) : (C \u2964 E) \u224c (D \u2964 E) :=\nequivalence.mk\n  ((whiskering_left _ _ _).obj e.inverse)\n  ((whiskering_left _ _ _).obj e.functor)\n  (nat_iso.of_components (\u03bb F, (e.fun_inv_id_assoc F).symm) (by tidy))\n  (nat_iso.of_components (\u03bb F, e.inv_fun_id_assoc F) (by tidy))\n\n/-- If `C` is equivalent to `D`, then `E \u2964 C` is equivalent to `E \u2964 D`. -/\n@[simps functor inverse unit_iso counit_iso]\ndef congr_right (e : C \u224c D) : (E \u2964 C) \u224c (E \u2964 D) :=\nequivalence.mk\n  ((whiskering_right _ _ _).obj e.functor)\n  ((whiskering_right _ _ _).obj e.inverse)\n  (nat_iso.of_components\n    (\u03bb F, F.right_unitor.symm \u226a\u226b iso_whisker_left F e.unit_iso \u226a\u226b functor.associator _ _ _)\n    (by tidy))\n  (nat_iso.of_components\n    (\u03bb F, functor.associator _ _ _ \u226a\u226b iso_whisker_left F e.counit_iso \u226a\u226b F.right_unitor)\n    (by tidy))\n\nsection cancellation_lemmas\nvariables (e : C \u224c 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 \u27f6 Y) :\n  f \u226b e.unit.app Y = f' \u226b e.unit.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_inv_right {X Y : C}\n  (f f' : X \u27f6 e.inverse.obj (e.functor.obj Y))   :\n  f \u226b e.unit_inv.app Y = f' \u226b e.unit_inv.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_right {X Y : D}\n  (f f' : X \u27f6 e.functor.obj (e.inverse.obj Y))   :\n  f \u226b e.counit.app Y = f' \u226b e.counit.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right {X Y : D}\n  (f f' : X \u27f6 Y) :\n  f \u226b e.counit_inv.app Y = f' \u226b e.counit_inv.app Y \u2194 f = f' :=\nby simp only [cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc {W X X' Y : C}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y) :\n  f \u226b g \u226b e.unit.app Y = f' \u226b g' \u226b e.unit.app Y \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_counit_inv_right_assoc {W X X' Y : D}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y) :\n  f \u226b g \u226b e.counit_inv.app Y = f' \u226b g' \u226b e.counit_inv.app Y \u2194 f \u226b g = f' \u226b g' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] lemma cancel_unit_right_assoc' {W X X' Y Y' Z : C}\n  (f : W \u27f6 X) (g : X \u27f6 Y) (h : Y \u27f6 Z) (f' : W \u27f6 X') (g' : X' \u27f6 Y') (h' : Y' \u27f6 Z) :\n  f \u226b g \u226b h \u226b e.unit.app Z = f' \u226b g' \u226b h' \u226b e.unit.app Z \u2194 f \u226b g \u226b h = f' \u226b g' \u226b h' :=\nby simp only [\u2190category.assoc, cancel_mono]\n\n@[simp] \n\nend cancellation_lemmas\n\nsection\n\n-- There's of course a monoid structure on `C \u224c 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 \u224c C) : \u2115 \u2192 (C \u224c 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 \u224c C) : \u2124 \u2192 (C \u224c 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 \u224c C) \u2124 := \u27e8pow\u27e9\n\n@[simp] lemma pow_zero (e : C \u224c C) : e^(0 : \u2124) = equivalence.refl := rfl\n@[simp] lemma pow_one (e : C \u224c C) : e^(1 : \u2124) = e := rfl\n@[simp] lemma pow_neg_one (e : C \u224c C) : e^(-1 : \u2124) = e.symm := rfl\n\n-- TODO as necessary, add the natural isomorphisms `(e^a).trans e^b \u2245 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 \u2964 D) :=\nmk' ::\n(inverse    : D \u2964 C)\n(unit_iso   : \ud835\udfed C \u2245 F \u22d9 inverse)\n(counit_iso : inverse \u22d9 F \u2245 \ud835\udfed D)\n(functor_unit_iso_comp' : \u2200 (X : C), F.map ((unit_iso.hom : \ud835\udfed C \u27f6 F \u22d9 inverse).app X) \u226b\n  counit_iso.hom.app (F.obj X) = \ud835\udfd9 (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 \u224c D) : is_equivalence F.functor :=\n{ ..F }\n\ninstance of_equivalence_inverse (F : C \u224c 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 \u22d9 G` and `G \u22d9 F` are naturally isomorphic to identity functors. -/\nprotected definition mk {F : C \u2964 D} (G : D \u2964 C)\n  (\u03b7 : \ud835\udfed C \u2245 F \u22d9 G) (\u03b5 : G \u22d9 F \u2245 \ud835\udfed D) : is_equivalence F :=\n\u27e8G, adjointify_\u03b7 \u03b7 \u03b5, \u03b5, adjointify_\u03b7_\u03b5 \u03b7 \u03b5\u27e9\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 \u2964 D) [is_equivalence F] : C \u224c D :=\n\u27e8F, is_equivalence.inverse F, is_equivalence.unit_iso, is_equivalence.counit_iso,\n  is_equivalence.functor_unit_iso_comp\u27e9\n\ninstance is_equivalence_refl : is_equivalence (\ud835\udfed C) :=\nis_equivalence.of_equivalence equivalence.refl\n\n/-- The inverse functor of a functor that is an equivalence. -/\ndef inv (F : C \u2964 D) [is_equivalence F] : D \u2964 C :=\nis_equivalence.inverse F\n\ninstance is_equivalence_inv (F : C \u2964 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 \u2964 D) [is_equivalence F] :\n  F.as_equivalence.functor = F := rfl\n\n@[simp] lemma as_equivalence_inverse (F : C \u2964 D) [is_equivalence F] :\n  F.as_equivalence.inverse = inv F := rfl\n\n@[simp] lemma as_equivalence_unit {F : C \u2964 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 \u2964 D} [is_equivalence F] :\n  F.as_equivalence.counit_iso = is_equivalence.counit_iso := rfl\n\n@[simp] lemma inv_inv (F : C \u2964 D) [is_equivalence F] :\n  inv (inv F) = F := rfl\n\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\ninstance is_equivalence_trans (F : C \u2964 D) (G : D \u2964 E) [is_equivalence F] [is_equivalence G] :\n  is_equivalence (F \u22d9 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 \u224c D) : E.functor.inv = E.inverse := rfl\n\n@[simp]\nlemma inverse_inv (E : C \u224c D) : E.inverse.inv = E.functor := rfl\n\n@[simp]\nlemma functor_as_equivalence (E : C \u224c D) : E.functor.as_equivalence = E :=\nby { cases E, congr, }\n\n@[simp]\nlemma inverse_as_equivalence (E : C \u224c 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 \u2964 D) [is_equivalence F] (X Y : D) (f : X \u27f6 Y) :\n  F.map (F.inv.map f) = F.as_equivalence.counit.app X \u226b f \u226b 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 \u2964 D) [is_equivalence F] (X Y : C) (f : X \u27f6 Y) :\n  F.inv.map (F.map f) = F.as_equivalence.unit_inv.app X \u226b f \u226b 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 \u2964 D} (e : F \u2245 G) (hF : is_equivalence F) : is_equivalence G :=\n{ inverse := hF.inverse,\n  unit_iso := hF.unit_iso \u226a\u226b nat_iso.hcomp e (iso.refl hF.inverse),\n  counit_iso := nat_iso.hcomp (iso.refl hF.inverse) e.symm \u226a\u226b hF.counit_iso,\n  functor_unit_iso_comp' := \u03bb 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 \u2190 e.hom.naturality, },\n    slice_lhs 2 3 { rw [\u2190 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 \u2964 D} (e : F \u2245 G) (e' : G \u2245 H) (hF : is_equivalence F) :\n  (of_iso e' (of_iso e hF)) = of_iso (e \u226a\u226b 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 \u2964 D) (hF : is_equivalence F) : of_iso (iso.refl F) hF = hF :=\nbegin\n  unfreezingI { rcases hF with \u27e8Finv, Funit, Fcounit, Fcomp\u27e9, },\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 \u2964 D} (e : F \u2245 G) : is_equivalence F \u2243 is_equivalence G :=\n{ to_fun := of_iso e,\n  inv_fun := of_iso e.symm,\n  left_inv := \u03bb hF, by rw [of_iso_trans, iso.self_symm_id, of_iso_refl],\n  right_inv := \u03bb hF, by rw [of_iso_trans, iso.symm_self_id, of_iso_refl], }\n\n/-- If `G` and `F \u22d9 G` are equivalence of categories, then `F` is also an equivalence. -/\n@[simp]\ndef cancel_comp_right {E : Type*} [category E]\n  (F : C \u2964 D) (G : D \u2964 E) (hG : is_equivalence G) (hGF : is_equivalence (F \u22d9 G)) :\n  is_equivalence F :=\nof_iso ((functor.associator F G G.inv) \u226a\u226b nat_iso.hcomp (iso.refl F) hG.unit_iso.symm \u226a\u226b\n  right_unitor F) (functor.is_equivalence_trans (F \u22d9 G) (G.inv))\n\n/-- If `F` and `F \u22d9 G` are equivalence of categories, then `G` is also an equivalence. -/\n@[simp]\ndef cancel_comp_left {E : Type*} [category E]\n  (F : C \u2964 D) (G : D \u2964 E) (hF : is_equivalence F) (hGF : is_equivalence (F \u22d9 G)) :\n  is_equivalence G :=\nof_iso ((functor.associator F.inv F G).symm \u226a\u226b nat_iso.hcomp hF.counit_iso (iso.refl G) \u226a\u226b\n  left_unitor G) (functor.is_equivalence_trans F.inv (F \u22d9 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 \u2964 D) [is_equivalence F] : ess_surj F :=\n\u27e8\u03bb Y, \u27e8F.inv.obj Y, \u27e8F.as_equivalence.counit_iso.app Y\u27e9\u27e9\u27e9\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 \u2964 D) [is_equivalence F] : faithful F :=\n{ map_injective' := \u03bb 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 \u2964 D) [is_equivalence F] : full F :=\n{ preimage := \u03bb X Y f, F.as_equivalence.unit.app X \u226b F.inv.map f \u226b F.as_equivalence.unit_inv.app Y,\n  witness' := \u03bb 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 \u2964 D) [full F] [faithful F]\n  [ess_surj F] : D \u2964 C :=\n{ obj  := \u03bb X, F.obj_preimage X,\n  map := \u03bb X Y f, F.preimage ((F.obj_obj_preimage_iso X).hom \u226b f \u226b (F.obj_obj_preimage_iso Y).inv),\n  map_id' := \u03bb X, begin apply F.map_injective, tidy end,\n  map_comp' := \u03bb 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 \u2964 D) [full F] [faithful F] [ess_surj F] : is_equivalence F :=\nis_equivalence.mk (equivalence_inverse F)\n  (nat_iso.of_components\n    (\u03bb X, (preimage_iso $ F.obj_obj_preimage_iso $ F.obj X).symm)\n    (\u03bb 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 \u224c D) {X Y : C} (f g : X \u27f6 Y) :\n  e.functor.map f = e.functor.map g \u2194 f = g :=\n\u27e8\u03bb h, e.functor.map_injective h, \u03bb h, h \u25b8 rfl\u27e9\n\n@[simp] lemma inverse_map_inj_iff (e : C \u224c D) {X Y : D} (f g : X \u27f6 Y) :\n  e.inverse.map f = e.inverse.map g \u2194 f = g :=\nfunctor_map_inj_iff e.symm f g\n\ninstance ess_surj_induced_functor {C' : Type*} (e : C' \u2243 D) : ess_surj (induced_functor e) :=\n{ mem_ess_image := \u03bb Y, \u27e8e.symm Y, by simp\u27e9, }\n\nnoncomputable\ninstance induced_functor_of_equiv {C' : Type*} (e : C' \u2243 D) : is_equivalence (induced_functor e) :=\nequivalence.of_fully_faithfully_ess_surj _\n\nnoncomputable\ninstance fully_faithful_to_ess_image (F : C \u2964 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\u00f6lzl, 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\u27e8@ring_hom.to_fun, @ring_hom.id, @ring_hom.comp, @ring_hom.coe_inj\u27e9\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 := \u27e8of punit\u27e9\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\u2082 SemiRing Mon :=\nbundled_hom.mk_has_forget\u2082\n  (\u03bb R hR, @monoid_with_zero.to_monoid R (@semiring.to_monoid_with_zero R hR))\n  (\u03bb R\u2081 R\u2082, ring_hom.to_monoid_hom) (\u03bb _ _ _, rfl)\n\ninstance has_forget_to_AddCommMon : has_forget\u2082 SemiRing AddCommMon :=\n-- can't use bundled_hom.mk_has_forget\u2082, since AddCommMon is an induced category\n{ forget\u2082 :=\n  { obj := \u03bb R, AddCommMon.of R,\n    map := \u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\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 := \u27e8of punit\u27e9\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\u2082 Ring SemiRing := bundled_hom.forget\u2082 _ _\ninstance has_forget_to_AddCommGroup : has_forget\u2082 Ring AddCommGroup :=\n-- can't use bundled_hom.mk_has_forget\u2082, since AddCommGroup is an induced category\n{ forget\u2082 :=\n  { obj := \u03bb R, AddCommGroup.of R,\n    map := \u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\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 := \u27e8of punit\u27e9\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\u2082 CommSemiRing SemiRing := bundled_hom.forget\u2082 _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommMon : has_forget\u2082 CommSemiRing CommMon :=\nhas_forget\u2082.mk'\n  (\u03bb R : CommSemiRing, CommMon.of R) (\u03bb R, rfl)\n  (\u03bb R\u2081 R\u2082 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 := \u27e8\u27e9\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 := \u27e8of punit\u27e9\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\u2082 CommRing Ring := bundled_hom.forget\u2082 _ _\n\n/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/\ninstance has_forget_to_CommSemiRing : has_forget\u2082 CommRing CommSemiRing :=\nhas_forget\u2082.mk' (\u03bb R : CommRing, CommSemiRing.of R) (\u03bb R, rfl) (\u03bb R\u2081 R\u2082 f, f) (by tidy)\n\ninstance : full (forget\u2082 CommRing CommSemiRing) :=\n{ preimage := \u03bb 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 \u27f6 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 \u2243+* Y) : Ring.of X \u2245 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 \u2243+* Y) :\n  CommRing.of X \u2245 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 \u2245 Y) : X \u2243+* 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 \u2245 Y) : X \u2243+* 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 \u2243+* Y) \u2245 (Ring.of X \u2245 Ring.of Y) :=\n{ hom := \u03bb e, e.to_Ring_iso,\n  inv := \u03bb 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 \u2243+* Y) \u2245 (CommRing.of X \u2245 CommRing.of Y) :=\n{ hom := \u03bb e, e.to_CommRing_iso,\n  inv := \u03bb i, i.CommRing_iso_to_ring_equiv, }\n\ninstance Ring.forget_reflects_isos : reflects_isomorphisms (forget Ring.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Ring).map f),\n    let e : X \u2243+* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Ring_iso).1\u27e9,\n  end }\n\ninstance CommRing.forget_reflects_isos : reflects_isomorphisms (forget CommRing.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommRing).map f),\n    let e : X \u2243+* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommRing_iso).1\u27e9,\n  end }\n\nexample : reflects_isomorphisms (forget\u2082 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u03c3-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\u03c3-algebras on a fixed set `\u03b1` form a complete lattice. Here we order\n\u03c3-algebras by writing `m\u2081 \u2264 m\u2082` if every set which is `m\u2081`-measurable is\nalso `m\u2082`-measurable (that is, `m\u2081` is a subset of `m\u2082`). In particular, any\ncollection of subsets of `\u03b1` generates a smallest \u03c3-algebra which\ncontains all of them. A function `f : \u03b1 \u2192 \u03b2` induces a Galois connection\nbetween the lattices of \u03c3-algebras on `\u03b1` and `\u03b2`.\n\nA measurable equivalence between measurable spaces is an equivalence\nwhich respects the \u03c3-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 \u2208 f` includes a measurable\nset `t \u2208 f`. This property is useful, e.g., to extract a measurable witness of `filter.eventually`.\n\n## Notation\n\n* We write `\u03b1 \u2243\u1d50 \u03b2` for measurable equivalences between the measurable spaces `\u03b1` and `\u03b2`.\n  This should not be confused with `\u2243\u2098` which is used for diffeomorphisms between manifolds.\n\n## Implementation notes\n\nMeasurability of a function `f : \u03b1 \u2192 \u03b2` 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, \u03c3-algebra, measurable function, measurable equivalence, dynkin system,\n\u03c0-\u03bb theorem, \u03c0-system\n-/\n\nopen set encodable function equiv\nopen_locale filter measure_theory\n\n\nvariables {\u03b1 \u03b2 \u03b3 \u03b4 \u03b4' : Type*} {\u03b9 : Sort*} {s t u : set \u03b1}\n\n\nnamespace measurable_space\n\nsection functors\nvariables {m m\u2081 m\u2082 : measurable_space \u03b1} {m' : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\n\n/-- The forward image of a measurable space under a function. `map f m` contains the sets\n  `s : set \u03b2` whose preimage under `f` is measurable. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (m : measurable_space \u03b1) : measurable_space \u03b2 :=\n{ measurable_set'      := \u03bb s, measurable_set[m] $ f \u207b\u00b9' 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 : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} : (m.map f).map g = m.map (g \u2218 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 \u03b1` such that `s` is the `f`-preimage of a measurable set in `\u03b2`. -/\nprotected def comap (f : \u03b1 \u2192 \u03b2) (m : measurable_space \u03b2) : measurable_space \u03b1 :=\n{ measurable_set'      := \u03bb s, \u2203s', measurable_set[m] s' \u2227 f \u207b\u00b9' s' = s,\n  measurable_set_empty := \u27e8\u2205, m.measurable_set_empty, rfl\u27e9,\n  measurable_set_compl := assume s \u27e8s', h\u2081, h\u2082\u27e9, \u27e8s'\u1d9c, m.measurable_set_compl _ h\u2081, h\u2082 \u25b8 rfl\u27e9,\n  measurable_set_Union := assume s hs,\n    let \u27e8s', hs'\u27e9 := classical.axiom_of_choice hs in\n    \u27e8\u22c3 i, s' i, m.measurable_set_Union _ (\u03bb i, (hs' i).left), by simp [hs'] \u27e9 }\n\nlemma comap_eq_generate_from (m : measurable_space \u03b2) (f : \u03b1 \u2192 \u03b2) :\n  m.comap f = generate_from {t | \u2203 s, measurable_set s \u2227 f \u207b\u00b9' s = t} :=\nby convert generate_from_measurable_set.symm\n\n@[simp] lemma comap_id : m.comap id = m :=\nmeasurable_space.ext $ assume s, \u27e8assume \u27e8s', hs', h\u27e9, h \u25b8 hs', assume h, \u27e8s, h, rfl\u27e9\u27e9\n\n@[simp] lemma comap_comp {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b2} : (m.comap f).comap g = m.comap (f \u2218 g) :=\nmeasurable_space.ext $ assume s,\n  \u27e8assume \u27e8t, \u27e8u, h, hu\u27e9, ht\u27e9, \u27e8u, h, ht \u25b8 hu \u25b8 rfl\u27e9, assume \u27e8t, h, ht\u27e9, \u27e8f \u207b\u00b9' t, \u27e8_, h, rfl\u27e9, ht\u27e9\u27e9\n\nlemma comap_le_iff_le_map {f : \u03b1 \u2192 \u03b2} : m'.comap f \u2264 m \u2194 m' \u2264 m.map f :=\n\u27e8assume h s hs, h _ \u27e8_, hs, rfl\u27e9, assume h s \u27e8t, ht, heq\u27e9, heq \u25b8 h _ ht\u27e9\n\nlemma gc_comap_map (f : \u03b1 \u2192 \u03b2) :\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\u2081 \u2264 m\u2082) : m\u2081.map f \u2264 m\u2082.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\u2081 \u2264 m\u2082) : m\u2081.comap g \u2264 m\u2082.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 : (\u22a5 : measurable_space \u03b1).comap g = \u22a5 := (gc_comap_map g).l_bot\n@[simp] lemma comap_sup : (m\u2081 \u2294 m\u2082).comap g = m\u2081.comap g \u2294 m\u2082.comap g := (gc_comap_map g).l_sup\n@[simp] lemma comap_supr {m : \u03b9 \u2192 measurable_space \u03b1} : (\u2a06i, m i).comap g = (\u2a06i, (m i).comap g) :=\n(gc_comap_map g).l_supr\n\n@[simp] lemma map_top : (\u22a4 : measurable_space \u03b1).map f = \u22a4 := (gc_comap_map f).u_top\n@[simp] lemma map_inf : (m\u2081 \u2293 m\u2082).map f = m\u2081.map f \u2293 m\u2082.map f := (gc_comap_map f).u_inf\n@[simp] lemma map_infi {m : \u03b9 \u2192 measurable_space \u03b1} : (\u2a05i, m i).map f = (\u2a05i, (m i).map f) :=\n(gc_comap_map f).u_infi\n\nlemma comap_map_le : (m.map f).comap f \u2264 m := (gc_comap_map f).l_u_le _\nlemma le_map_comap : m \u2264 (m.comap g).map g := (gc_comap_map g).le_u_l _\n\nend functors\n\nlemma comap_generate_from {f : \u03b1 \u2192 \u03b2} {s : set (set \u03b2)} :\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 \u27e8u, hu, eq\u27e9, eq \u25b8 \u27e8u, generate_measurable.basic _ hu, rfl\u27e9)\n\nend measurable_space\n\nsection measurable_functions\nopen measurable_space\n\nlemma measurable_iff_le_map {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} :\n  measurable f \u2194 m\u2082 \u2264 m\u2081.map f :=\niff.rfl\n\nalias measurable_iff_le_map \u2194 measurable.le_map measurable.of_le_map\n\nlemma measurable_iff_comap_le {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2} :\n  measurable f \u2194 m\u2082.comap f \u2264 m\u2081 :=\ncomap_le_iff_le_map.symm\n\nalias measurable_iff_comap_le \u2194 measurable.comap_le measurable.of_comap_le\n\nlemma comap_measurable {m : measurable_space \u03b2} (f : \u03b1 \u2192 \u03b2) :\n  measurable[m.comap f] f :=\n\u03bb s hs, \u27e8s, hs, rfl\u27e9\n\nlemma measurable.mono {ma ma' : measurable_space \u03b1} {mb mb' : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2}\n  (hf : @measurable \u03b1 \u03b2 ma mb f) (ha : ma \u2264 ma') (hb : mb' \u2264 mb) :\n  @measurable \u03b1 \u03b2 ma' mb' f :=\n\u03bb t ht, ha _ $ hf $ hb _ ht\n\n@[measurability]\nlemma measurable_from_top [measurable_space \u03b2] {f : \u03b1 \u2192 \u03b2} : measurable[\u22a4] f :=\n\u03bb s hs, trivial\n\nlemma measurable_generate_from [measurable_space \u03b1] {s : set (set \u03b2)} {f : \u03b1 \u2192 \u03b2}\n  (h : \u2200 t \u2208 s, measurable_set (f \u207b\u00b9' t)) : @measurable _ _ _ (generate_from s) f :=\nmeasurable.of_le_map $ generate_from_le h\n\nvariables {f g : \u03b1 \u2192 \u03b2}\n\nsection typeclass_measurable_space\nvariables [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3]\n\n@[nontriviality, measurability]\nlemma subsingleton.measurable [subsingleton \u03b1] : measurable f :=\n\u03bb s hs, @subsingleton.measurable_set \u03b1 _ _ _\n\n@[nontriviality, measurability]\nlemma measurable_of_subsingleton_codomain [subsingleton \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  measurable f :=\n\u03bb s hs, subsingleton.set_cases measurable_set.empty measurable_set.univ s\n\n@[to_additive]\nlemma measurable_one [has_one \u03b1] : measurable (1 : \u03b2 \u2192 \u03b1) := @measurable_const _ _ _ _ 1\n\nlemma measurable_of_empty [is_empty \u03b1] (f : \u03b1 \u2192 \u03b2) : measurable f :=\nsubsingleton.measurable\n\nlemma measurable_of_empty_codomain [is_empty \u03b2] (f : \u03b1 \u2192 \u03b2) : 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 : \u03b2 \u2192 \u03b1} (hf : \u2200 x y, f x = f y) : measurable f :=\nbegin\n  casesI is_empty_or_nonempty \u03b2,\n  { exact measurable_of_empty f },\n  { convert measurable_const, exact funext (\u03bb x, hf x h.some) }\nend\n\nlemma measurable_of_finite [finite \u03b1] [measurable_singleton_class \u03b1] (f : \u03b1 \u2192 \u03b2) : measurable f :=\n\u03bb s hs, (f \u207b\u00b9' s).to_finite.measurable_set\n\nlemma measurable_of_countable [countable \u03b1] [measurable_singleton_class \u03b1] (f : \u03b1 \u2192 \u03b2) :\n  measurable f :=\n\u03bb s hs, (f \u207b\u00b9' s).to_countable.measurable_set\n\nend typeclass_measurable_space\n\nvariables {m : measurable_space \u03b1}\ninclude m\n\n@[measurability] lemma measurable.iterate {f : \u03b1 \u2192 \u03b1} (hf : measurable f) : \u2200 n, measurable (f^[n])\n| 0 := measurable_id\n| (n+1) := (measurable.iterate n).comp hf\n\nvariables {m\u03b2 : measurable_space \u03b2}\ninclude m\u03b2\n\n@[measurability]\nlemma measurable_set_preimage {t : set \u03b2} (hf : measurable f) (ht : measurable_set t) :\n  measurable_set (f \u207b\u00b9' t) :=\nhf ht\n\n@[measurability]\nlemma measurable.piecewise {_ : decidable_pred (\u2208 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 : \u03b1 \u2192 Prop} {_ : decidable_pred p}\n  (hp : measurable_set {a : \u03b1 | p a}) (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb x, ite (p x) (f x) (g x)) :=\nmeasurable.piecewise hp hf hg\n\n@[measurability]\nlemma measurable.indicator [has_zero \u03b2] (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 \u03b2]\n  [measurable_singleton_class \u03b2] (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 \u03b1]\n  (hf : measurable f) (h : set.countable {x | f x \u2260 g x}) : measurable g :=\nbegin\n  assume t ht,\n  have : g \u207b\u00b9' t = (g \u207b\u00b9' t \u2229 {x | f x = g x}\u1d9c) \u222a (g \u207b\u00b9' t \u2229 {x | f x = g x}),\n    by simp [\u2190 inter_union_distrib_left],\n  rw this,\n  apply measurable_set.union (h.mono (inter_subset_right _ _)).measurable_set,\n  have : g \u207b\u00b9' t \u2229 {x : \u03b1 | f x = g x} = f \u207b\u00b9' t \u2229 {x : \u03b1 | 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 := \u22a4\ninstance : measurable_space punit := \u22a4 -- this also works for `unit`\ninstance : measurable_space bool := \u22a4\ninstance : measurable_space \u2115 := \u22a4\ninstance : measurable_space \u2124 := \u22a4\ninstance : measurable_space \u211a := \u22a4\n\ninstance : measurable_singleton_class empty := \u27e8\u03bb _, trivial\u27e9\ninstance : measurable_singleton_class punit := \u27e8\u03bb _, trivial\u27e9\ninstance : measurable_singleton_class bool := \u27e8\u03bb _, trivial\u27e9\ninstance : measurable_singleton_class \u2115 := \u27e8\u03bb _, trivial\u27e9\ninstance : measurable_singleton_class \u2124 := \u27e8\u03bb _, trivial\u27e9\ninstance : measurable_singleton_class \u211a := \u27e8\u03bb _, trivial\u27e9\n\nlemma measurable_to_countable [measurable_space \u03b1] [countable \u03b1] [measurable_space \u03b2] {f : \u03b2 \u2192 \u03b1}\n  (h : \u2200 y, measurable_set (f \u207b\u00b9' {f y})) :\n  measurable f :=\nbegin\n  assume s hs,\n  rw [\u2190 bUnion_preimage_singleton],\n  refine measurable_set.Union (\u03bb y, measurable_set.Union $ \u03bb hy, _),\n  by_cases hyf : y \u2208 range f,\n  { rcases hyf with \u27e8y, rfl\u27e9,\n    apply h },\n  { simp only [preimage_singleton_eq_empty.2 hyf, measurable_set.empty] }\nend\n\n@[measurability] lemma measurable_unit [measurable_space \u03b1] (f : unit \u2192 \u03b1) : measurable f :=\nmeasurable_from_top\n\nsection nat\nvariables [measurable_space \u03b1]\n\n@[measurability] lemma measurable_from_nat {f : \u2115 \u2192 \u03b1} : measurable f :=\nmeasurable_from_top\n\nlemma measurable_to_nat {f : \u03b1 \u2192 \u2115} : (\u2200 y, measurable_set (f \u207b\u00b9' {f y})) \u2192 measurable f :=\nmeasurable_to_countable\n\nlemma measurable_find_greatest' {p : \u03b1 \u2192 \u2115 \u2192 Prop} [\u2200 x, decidable_pred (p x)]\n  {N : \u2115} (hN : \u2200 k \u2264 N, measurable_set {x | nat.find_greatest (p x) N = k}) :\n  measurable (\u03bb x, nat.find_greatest (p x) N) :=\nmeasurable_to_nat $ \u03bb x, hN _ N.find_greatest_le\n\nlemma measurable_find_greatest {p : \u03b1 \u2192 \u2115 \u2192 Prop} [\u2200 x, decidable_pred (p x)]\n  {N} (hN : \u2200 k \u2264 N, measurable_set {x | p x k}) :\n  measurable (\u03bb x, nat.find_greatest (p x) N) :=\nbegin\n  refine measurable_find_greatest' (\u03bb k hk, _),\n  simp only [nat.find_greatest_eq_iff, set_of_and, set_of_forall, \u2190 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 : \u03b1 \u2192 \u2115 \u2192 Prop} [\u2200 x, decidable_pred (p x)]\n  (hp : \u2200 x, \u2203 N, p x N) (hm : \u2200 k, measurable_set {x | p x k}) :\n  measurable (\u03bb x, nat.find (hp x)) :=\nbegin\n  refine measurable_to_nat (\u03bb x, _),\n  rw [preimage_find_eq_disjointed],\n  exact measurable_set.disjointed hm _\nend\n\nend nat\n\nsection quotient\nvariables [measurable_space \u03b1] [measurable_space \u03b2]\n\ninstance {\u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [m : measurable_space \u03b1] : measurable_space (quot r) :=\nm.map (quot.mk r)\n\ninstance {\u03b1} {s : setoid \u03b1} [m : measurable_space \u03b1] : 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 \u29f8 S) :=\nquotient.measurable_space\n\nlemma measurable_set_quotient {s : setoid \u03b1} {t : set (quotient s)} :\n  measurable_set t \u2194 measurable_set (quotient.mk' \u207b\u00b9' t) :=\niff.rfl\n\nlemma measurable_from_quotient {s : setoid \u03b1} {f : quotient s \u2192 \u03b2} :\n  measurable f \u2194 measurable (f \u2218 quotient.mk') :=\niff.rfl\n\n@[measurability] lemma measurable_quotient_mk [s : setoid \u03b1] :\n  measurable (quotient.mk : \u03b1 \u2192 quotient s) :=\n\u03bb s, id\n\n@[measurability] lemma measurable_quotient_mk' {s : setoid \u03b1} :\n  measurable (quotient.mk' : \u03b1 \u2192 quotient s) :=\n\u03bb s, id\n\n@[measurability] lemma measurable_quot_mk {r : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n  measurable (quot.mk r) :=\n\u03bb s, id\n\n@[to_additive] lemma quotient_group.measurable_coe {G} [group G] [measurable_space G]\n  {S : subgroup G} : measurable (coe : G \u2192 G \u29f8 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 \u29f8 S \u2192 \u03b1} :\n  measurable f \u2194 measurable (f \u2218 (coe : G \u2192 G \u29f8 S)) :=\nmeasurable_from_quotient\n\nend quotient\n\nsection subtype\n\ninstance {\u03b1} {p : \u03b1 \u2192 Prop} [m : measurable_space \u03b1] : measurable_space (subtype p) :=\nm.comap (coe : _ \u2192 \u03b1)\n\nsection\nvariables [measurable_space \u03b1]\n\n@[measurability] lemma measurable_subtype_coe {p : \u03b1 \u2192 Prop} : measurable (coe : subtype p \u2192 \u03b1) :=\nmeasurable_space.le_map_comap\n\ninstance {p : \u03b1 \u2192 Prop} [measurable_singleton_class \u03b1] : measurable_singleton_class (subtype p) :=\n{ measurable_set_singleton := \u03bb x,\n  begin\n    have : measurable_set {(x : \u03b1)} := measurable_set_singleton _,\n    convert @measurable_subtype_coe \u03b1 _ p _ this,\n    ext y,\n    simp [subtype.ext_iff],\n  end }\n\nend\n\nvariables {m : measurable_space \u03b1} {m\u03b2 : measurable_space \u03b2}\n\ninclude m\n\nlemma measurable_set.subtype_image {s : set \u03b1} {t : set s}\n  (hs : measurable_set s) : measurable_set t \u2192 measurable_set ((coe : s \u2192 \u03b1) '' t)\n| \u27e8u, (hu : measurable_set u), (eq : coe \u207b\u00b9' u = t)\u27e9 :=\n  begin\n    rw [\u2190 eq, subtype.image_preimage_coe],\n    exact hu.inter hs\n  end\n\ninclude m\u03b2\n\n@[measurability] lemma measurable.subtype_coe {p : \u03b2 \u2192 Prop} {f : \u03b1 \u2192 subtype p}\n  (hf : measurable f) :\n  measurable (\u03bb a : \u03b1, (f a : \u03b2)) :=\nmeasurable_subtype_coe.comp hf\n\n@[measurability]\nlemma measurable.subtype_mk {p : \u03b2 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} (hf : measurable f) {h : \u2200 x, p (f x)} :\n  measurable (\u03bb x, (\u27e8f x, h x\u27e9 : subtype p)) :=\n\u03bb t \u27e8s, hs\u27e9, hs.2 \u25b8 by simp only [\u2190 preimage_comp, (\u2218), subtype.coe_mk, hf hs.1]\n\nlemma measurable_of_measurable_union_cover\n  {f : \u03b1 \u2192 \u03b2} (s t : set \u03b1) (hs : measurable_set s) (ht : measurable_set t) (h : univ \u2286 s \u222a t)\n  (hc : measurable (\u03bb a : s, f a)) (hd : measurable (\u03bb 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 \u207b\u00b9' u = coe '' (coe \u207b\u00b9' (f \u207b\u00b9' u) : set s) \u222a coe '' (coe \u207b\u00b9' (f \u207b\u00b9' u) : set t),\n  rw [image_preimage_eq_inter_range, image_preimage_eq_inter_range, subtype.range_coe,\n      subtype.range_coe, \u2190 inter_distrib_left, univ_subset_iff.1 h, inter_univ],\nend\n\nlemma measurable_of_restrict_of_restrict_compl {f : \u03b1 \u2192 \u03b2} {s : set \u03b1}\n  (hs : measurable_set s) (h\u2081 : measurable (s.restrict f)) (h\u2082 : measurable (s\u1d9c.restrict f)) :\n  measurable f :=\nmeasurable_of_measurable_union_cover s s\u1d9c hs hs.compl (union_compl_self s).ge h\u2081 h\u2082\n\nlemma measurable.dite [\u2200 x, decidable (x \u2208 s)] {f : s \u2192 \u03b2} (hf : measurable f)\n  {g : s\u1d9c \u2192 \u03b2} (hg : measurable g) (hs : measurable_set s) :\n  measurable (\u03bb x, if hx : x \u2208 s then f \u27e8x, hx\u27e9 else g \u27e8x, hx\u27e9) :=\nmeasurable_of_restrict_of_restrict_compl hs (by simpa) (by simpa)\n\nlemma measurable_of_measurable_on_compl_finite [measurable_singleton_class \u03b1]\n  {f : \u03b1 \u2192 \u03b2} (s : set \u03b1) (hs : s.finite) (hf : measurable (s\u1d9c.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 \u03b1]\n  {f : \u03b1 \u2192 \u03b2} (a : \u03b1) (hf : measurable ({x | x \u2260 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 {\u03b1 \u03b2} (m\u2081 : measurable_space \u03b1) (m\u2082 : measurable_space \u03b2) :\n  measurable_space (\u03b1 \u00d7 \u03b2) :=\nm\u2081.comap prod.fst \u2294 m\u2082.comap prod.snd\n\ninstance {\u03b1 \u03b2} [m\u2081 : measurable_space \u03b1] [m\u2082 : measurable_space \u03b2] : measurable_space (\u03b1 \u00d7 \u03b2) :=\nm\u2081.prod m\u2082\n\n@[measurability] lemma measurable_fst {ma : measurable_space \u03b1} {mb : measurable_space \u03b2} :\n  measurable (prod.fst : \u03b1 \u00d7 \u03b2 \u2192 \u03b1) :=\nmeasurable.of_comap_le le_sup_left\n\n@[measurability] lemma measurable_snd {ma : measurable_space \u03b1} {mb : measurable_space \u03b2} :\n  measurable (prod.snd : \u03b1 \u00d7 \u03b2 \u2192 \u03b2) :=\nmeasurable.of_comap_le le_sup_right\n\nvariables {m : measurable_space \u03b1} {m\u03b2 : measurable_space \u03b2} {m\u03b3 : measurable_space \u03b3}\n\ninclude m m\u03b2 m\u03b3\n\nlemma measurable.fst {f : \u03b1 \u2192 \u03b2 \u00d7 \u03b3} (hf : measurable f) :\n  measurable (\u03bb a : \u03b1, (f a).1) :=\nmeasurable_fst.comp hf\n\nlemma measurable.snd {f : \u03b1 \u2192 \u03b2 \u00d7 \u03b3} (hf : measurable f) :\n  measurable (\u03bb a : \u03b1, (f a).2) :=\nmeasurable_snd.comp hf\n\n@[measurability] lemma measurable.prod {f : \u03b1 \u2192 \u03b2 \u00d7 \u03b3}\n  (hf\u2081 : measurable (\u03bb a, (f a).1)) (hf\u2082 : measurable (\u03bb 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\u2081 })\n  (by { rw [measurable_space.comap_le_iff_le_map, measurable_space.map_comp], exact hf\u2082 })\n\nlemma measurable.prod_mk {\u03b2 \u03b3} {m\u03b2 : measurable_space \u03b2}\n  {m\u03b3 : measurable_space \u03b3} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb a : \u03b1, (f a, g a)) :=\nmeasurable.prod hf hg\n\nlemma measurable.prod_map [measurable_space \u03b4] {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b4} (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\u03b3\n\nlemma measurable_prod_mk_left {x : \u03b1} : measurable (@prod.mk _ \u03b2 x) :=\nmeasurable_const.prod_mk measurable_id\n\nlemma measurable_prod_mk_right {y : \u03b2} : measurable (\u03bb x : \u03b1, (x, y)) :=\nmeasurable_id.prod_mk measurable_const\n\ninclude m\u03b3\n\nlemma measurable.of_uncurry_left {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hf : measurable (uncurry f)) {x : \u03b1} :\n  measurable (f x) :=\nhf.comp measurable_prod_mk_left\n\nlemma measurable.of_uncurry_right {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hf : measurable (uncurry f)) {y : \u03b2} :\n  measurable (\u03bb x, f x y) :=\nhf.comp measurable_prod_mk_right\n\nlemma measurable_prod {f : \u03b1 \u2192 \u03b2 \u00d7 \u03b3} : measurable f \u2194\n  measurable (\u03bb a, (f a).1) \u2227 measurable (\u03bb a, (f a).2) :=\n\u27e8\u03bb hf, \u27e8measurable_fst.comp hf, measurable_snd.comp hf\u27e9, \u03bb h, measurable.prod h.1 h.2\u27e9\n\nomit m\u03b3\n\n@[measurability] lemma measurable_swap :\n  measurable (prod.swap : \u03b1 \u00d7 \u03b2 \u2192 \u03b2 \u00d7 \u03b1) :=\nmeasurable.prod measurable_snd measurable_fst\n\nlemma measurable_swap_iff {m\u03b3 : measurable_space \u03b3} {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} :\n  measurable (f \u2218 prod.swap) \u2194 measurable f :=\n\u27e8\u03bb hf, by { convert hf.comp measurable_swap, ext \u27e8x, y\u27e9, refl }, \u03bb hf, hf.comp measurable_swap\u27e9\n\n@[measurability]\nlemma measurable_set.prod {s : set \u03b1} {t : set \u03b2} (hs : measurable_set s) (ht : measurable_set t) :\n  measurable_set (s \u00d7\u02e2 t) :=\nmeasurable_set.inter (measurable_fst hs) (measurable_snd ht)\n\nlemma measurable_set_prod_of_nonempty {s : set \u03b1} {t : set \u03b2} (h : (s \u00d7\u02e2 t).nonempty) :\n  measurable_set (s \u00d7\u02e2 t) \u2194 measurable_set s \u2227 measurable_set t :=\nbegin\n  rcases h with \u27e8\u27e8x, y\u27e9, hx, hy\u27e9,\n  refine \u27e8\u03bb hst, _, \u03bb h, h.1.prod h.2\u27e9,\n  have : measurable_set ((\u03bb x, (x, y)) \u207b\u00b9' s \u00d7\u02e2 t) := measurable_prod_mk_right hst,\n  have : measurable_set (prod.mk x \u207b\u00b9' s \u00d7\u02e2 t) := measurable_prod_mk_left hst,\n  simp * at *\nend\n\nlemma measurable_set_prod {s : set \u03b1} {t : set \u03b2} :\n  measurable_set (s \u00d7\u02e2 t) \u2194 (measurable_set s \u2227 measurable_set t) \u2228 s = \u2205 \u2228 t = \u2205 :=\nbegin\n  cases (s \u00d7\u02e2 t).eq_empty_or_nonempty with h h,\n  { simp [h, prod_eq_empty_iff.mp h] },\n  { simp [\u2190not_nonempty_iff_eq_empty, prod_nonempty_iff.mp h, measurable_set_prod_of_nonempty h] }\nend\n\nlemma measurable_set_swap_iff {s : set (\u03b1 \u00d7 \u03b2)} :\n  measurable_set (prod.swap \u207b\u00b9' s) \u2194 measurable_set s :=\n\u27e8\u03bb hs, by { convert measurable_swap hs, ext \u27e8x, y\u27e9, refl }, \u03bb hs, measurable_swap hs\u27e9\n\ninstance [measurable_singleton_class \u03b1] [measurable_singleton_class \u03b2] :\n  measurable_singleton_class (\u03b1 \u00d7 \u03b2) :=\n\u27e8\u03bb \u27e8a, b\u27e9, @singleton_prod_singleton _ _ a b \u25b8\n  (measurable_set_singleton a).prod (measurable_set_singleton b)\u27e9\n\nlemma measurable_from_prod_countable [countable \u03b2] [measurable_singleton_class \u03b2]\n  {m\u03b3 : measurable_space \u03b3} {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (hf : \u2200 y, measurable (\u03bb x, f (x, y))) :\n  measurable f :=\nbegin\n  intros s hs,\n  have : f \u207b\u00b9' s = \u22c3 y, ((\u03bb x, f (x, y)) \u207b\u00b9' s) \u00d7\u02e2 ({y} : set \u03b2),\n  { ext1 \u27e8x, y\u27e9,\n    simp [and_assoc, and.left_comm] },\n  rw this,\n  exact measurable_set.Union (\u03bb 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 \u03b1}\n  {f : \u2115 \u2192 \u03b1 \u2192 \u03b2} {p : \u2115 \u2192 \u03b1 \u2192 Prop} [\u2200 n, decidable_pred (p n)]\n  (hf : \u2200 n, measurable (f n)) (hp : \u2200 n, measurable_set {x | p n x}) (h : \u2200 x, \u2203 n, p n x) :\n  measurable (\u03bb x, f (nat.find (h x)) x) :=\nbegin\n  have : measurable (\u03bb (p : \u03b1 \u00d7 \u2115), f p.2 p.1) := measurable_from_prod_countable (\u03bb 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 \u03b1} (t : \u2115 \u2192 set \u03b2)\n  (t_meas : \u2200 n, measurable_set (t n)) (t_disj : pairwise (disjoint on t))\n  (g : \u2115 \u2192 \u03b2 \u2192 \u03b1) (hg : \u2200 n, measurable (g n)) :\n  \u2203 f : \u03b2 \u2192 \u03b1, measurable f \u2227 (\u2200 n x, x \u2208 t n \u2192 f x = g n x) :=\nbegin\n  classical,\n  let p : \u2115 \u2192 \u03b2 \u2192 Prop := \u03bb n x, x \u2208 t n \u222a (\u22c3 k, t k)\u1d9c,\n  have M : \u2200 n, measurable_set {x | p n x} :=\n    \u03bb n, (t_meas n).union (measurable_set.compl (measurable_set.Union t_meas)),\n  have P : \u2200 x, \u2203 n, p n x,\n  { assume x,\n    by_cases H : \u2200 (i : \u2115), x \u2209 t i,\n    { exact \u27e80, or.inr (by simpa only [mem_Inter, compl_Union] using H)\u27e9 },\n    { simp only [not_forall, not_not_mem] at H,\n      rcases H with \u27e8n, hn\u27e9,\n      exact \u27e8n, or.inl hn\u27e9 } },\n  refine \u27e8\u03bb x, g (nat.find (P x)) x, measurable.find hg M P, _\u27e9,\n  assume n x hx,\n  have : x \u2208 t (nat.find (P x)),\n  { have B : x \u2208 t (nat.find (P x)) \u222a (\u22c3 k, t k)\u1d9c := nat.find_spec (P x),\n    have B' : (\u2200 (i : \u2115), x \u2209 t i) \u2194 false,\n    { simp only [iff_false, not_forall, not_not_mem], exact \u27e8n, hx\u27e9 },\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 \u27e8hx, this\u27e9\nend\n\nend prod\n\nsection pi\n\nvariables {\u03c0 : \u03b4 \u2192 Type*} [measurable_space \u03b1]\n\ninstance measurable_space.pi [m : \u03a0 a, measurable_space (\u03c0 a)] : measurable_space (\u03a0 a, \u03c0 a) :=\n\u2a06 a, (m a).comap (\u03bb b, b a)\n\nvariables [\u03a0 a, measurable_space (\u03c0 a)] [measurable_space \u03b3]\n\nlemma measurable_pi_iff {g : \u03b1 \u2192 \u03a0 a, \u03c0 a} :\n  measurable g \u2194 \u2200 a, measurable (\u03bb 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 : \u03b4) : measurable (\u03bb f : \u03a0 a, \u03c0 a, f a) :=\nmeasurable.of_comap_le $ le_supr _ a\n\n@[measurability]\nlemma measurable.eval {a : \u03b4} {g : \u03b1 \u2192 \u03a0 a, \u03c0 a}\n  (hg : measurable g) : measurable (\u03bb x, g x a) :=\n(measurable_pi_apply a).comp hg\n\n@[measurability]\nlemma measurable_pi_lambda (f : \u03b1 \u2192 \u03a0 a, \u03c0 a) (hf : \u2200 a, measurable (\u03bb c, f c a)) :\n  measurable f :=\nmeasurable_pi_iff.mpr hf\n\n/-- The function `update f a : \u03c0 a \u2192 \u03a0 a, \u03c0 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 : \u03a0 (a : \u03b4), \u03c0 a) {a : \u03b4} [decidable_eq \u03b4] : 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 \u03b4} {t : \u03a0 i : \u03b4, set (\u03c0 i)} (hs : s.countable)\n  (ht : \u2200 i \u2208 s, measurable_set (t i)) :\n  measurable_set (s.pi t) :=\nby { rw [pi_def], exact measurable_set.bInter hs (\u03bb i hi, measurable_pi_apply _ (ht i hi)) }\n\nlemma measurable_set.univ_pi [countable \u03b4] {t : \u03a0 i : \u03b4, set (\u03c0 i)}\n  (ht : \u2200 i, measurable_set (t i)) : measurable_set (pi univ t) :=\nmeasurable_set.pi (to_countable _) (\u03bb i _, ht i)\n\nlemma measurable_set_pi_of_nonempty\n  {s : set \u03b4} {t : \u03a0 i, set (\u03c0 i)} (hs : s.countable)\n  (h : (pi s t).nonempty) : measurable_set (pi s t) \u2194 \u2200 i \u2208 s, measurable_set (t i) :=\nbegin\n  classical,\n  rcases h with \u27e8f, hf\u27e9, refine \u27e8\u03bb hst i hi, _, measurable_set.pi hs\u27e9,\n  convert measurable_update f hst, rw [update_preimage_pi hi], exact \u03bb j hj _, hf j hj\nend\n\nlemma measurable_set_pi {s : set \u03b4} {t : \u03a0 i, set (\u03c0 i)} (hs : s.countable) :\n  measurable_set (pi s t) \u2194 (\u2200 i \u2208 s, measurable_set (t i)) \u2228 pi s t = \u2205 :=\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, \u2190 not_nonempty_iff_eq_empty] }\nend\n\ninstance [countable \u03b4] [\u03a0 a, measurable_singleton_class (\u03c0 a)] :\n  measurable_singleton_class (\u03a0 a, \u03c0 a) :=\n\u27e8\u03bb f, univ_pi_singleton f \u25b8 measurable_set.univ_pi (\u03bb t, measurable_set_singleton (f t))\u27e9\n\nvariable (\u03c0)\n\n@[measurability]\nlemma measurable_pi_equiv_pi_subtype_prod_symm (p : \u03b4 \u2192 Prop) [decidable_pred p] :\n  measurable (equiv.pi_equiv_pi_subtype_prod p \u03c0).symm :=\nbegin\n  apply measurable_pi_iff.2 (\u03bb j, _),\n  by_cases hj : p j,\n  { simp only [hj, dif_pos, equiv.pi_equiv_pi_subtype_prod_symm_apply],\n    have : measurable (\u03bb (f : (\u03a0 (i : {x // p x}), \u03c0 \u2191i)), f \u27e8j, hj\u27e9) :=\n      measurable_pi_apply \u27e8j, hj\u27e9,\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 (\u03bb (f : (\u03a0 (i : {x // \u00ac p x}), \u03c0 \u2191i)), f \u27e8j, hj\u27e9) :=\n      measurable_pi_apply \u27e8j, hj\u27e9,\n    exact measurable.comp this measurable_snd }\nend\n\n@[measurability]\nlemma measurable_pi_equiv_pi_subtype_prod (p : \u03b4 \u2192 Prop) [decidable_pred p] :\n  measurable (equiv.pi_equiv_pi_subtype_prod p \u03c0) :=\nbegin\n  refine measurable_prod.2 _,\n  split;\n  { apply measurable_pi_iff.2 (\u03bb j, _),\n    simp only [pi_equiv_pi_subtype_prod_apply, measurable_pi_apply] }\nend\n\nend pi\n\ninstance tprod.measurable_space (\u03c0 : \u03b4 \u2192 Type*) [\u2200 x, measurable_space (\u03c0 x)] :\n  \u2200 (l : list \u03b4), measurable_space (list.tprod \u03c0 l)\n| []        := punit.measurable_space\n| (i :: is) := @prod.measurable_space _ _ _ (tprod.measurable_space is)\n\nsection tprod\n\nopen list\n\nvariables {\u03c0 : \u03b4 \u2192 Type*} [\u2200 x, measurable_space (\u03c0 x)]\n\nlemma measurable_tprod_mk (l : list \u03b4) : measurable (@tprod.mk \u03b4 \u03c0 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 \u03b4] : \u2200 {l : list \u03b4} {i : \u03b4} (hi : i \u2208 l),\n  measurable (\u03bb (v : tprod \u03c0 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 \u03b4] {l : list \u03b4} (h : \u2200 i, i \u2208 l) :\n  measurable (tprod.elim' h : tprod \u03c0 l \u2192 \u03a0 i, \u03c0 i) :=\nmeasurable_pi_lambda _ (\u03bb i, measurable_tprod_elim (h i))\n\nlemma measurable_set.tprod (l : list \u03b4) {s : \u2200 i, set (\u03c0 i)} (hs : \u2200 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 {\u03b1 \u03b2} [m\u2081 : measurable_space \u03b1] [m\u2082 : measurable_space \u03b2] : measurable_space (\u03b1 \u2295 \u03b2) :=\nm\u2081.map sum.inl \u2293 m\u2082.map sum.inr\n\nsection sum\n\n@[measurability] lemma measurable_inl [measurable_space \u03b1] [measurable_space \u03b2] :\n  measurable (@sum.inl \u03b1 \u03b2) :=\nmeasurable.of_le_map inf_le_left\n\n@[measurability] lemma measurable_inr [measurable_space \u03b1] [measurable_space \u03b2] :\n  measurable (@sum.inr \u03b1 \u03b2) :=\nmeasurable.of_le_map inf_le_right\n\nvariables {m : measurable_space \u03b1} {m\u03b2 : measurable_space \u03b2}\n\ninclude m m\u03b2\n\nlemma measurable_sum {m\u03b3 : measurable_space \u03b3} {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3}\n  (hl : measurable (f \u2218 sum.inl)) (hr : measurable (f \u2218 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\u03b3 : measurable_space \u03b3} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3}\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 \u03b1} (hs : measurable_set s) :\n  measurable_set (sum.inl '' s : set (\u03b1 \u2295 \u03b2)) :=\n\u27e8show measurable_set (sum.inl \u207b\u00b9' _), by { rwa [preimage_image_eq], exact (\u03bb a b, sum.inl.inj) },\n  have sum.inr \u207b\u00b9' (sum.inl '' s : set (\u03b1 \u2295 \u03b2)) = \u2205 :=\n    eq_empty_of_subset_empty $ assume x \u27e8y, hy, eq\u27e9, by contradiction,\n  show measurable_set (sum.inr \u207b\u00b9' _), by { rw [this], exact measurable_set.empty }\u27e9\n\nlemma measurable_set_inr_image {s : set \u03b2} (hs : measurable_set s) :\n  measurable_set (sum.inr '' s : set (\u03b1 \u2295 \u03b2)) :=\n\u27e8 have sum.inl \u207b\u00b9' (sum.inr '' s : set (\u03b1 \u2295 \u03b2)) = \u2205 :=\n    eq_empty_of_subset_empty $ assume x \u27e8y, hy, eq\u27e9, by contradiction,\n  show measurable_set (sum.inl \u207b\u00b9' _), by { rw [this], exact measurable_set.empty },\n  show measurable_set (sum.inr \u207b\u00b9' _), by { rwa [preimage_image_eq], exact \u03bb a b, sum.inr.inj }\u27e9\n\nomit m\n\nlemma measurable_set_range_inl [measurable_space \u03b1] :\n  measurable_set (range sum.inl : set (\u03b1 \u2295 \u03b2)) :=\nby { rw [\u2190 image_univ], exact measurable_set.univ.inl_image }\n\nlemma measurable_set_range_inr [measurable_space \u03b1] :\n  measurable_set (range sum.inr : set (\u03b1 \u2295 \u03b2)) :=\nby { rw [\u2190 image_univ], exact measurable_set_inr_image measurable_set.univ }\n\nend sum\n\ninstance {\u03b1} {\u03b2 : \u03b1 \u2192 Type*} [m : \u03a0a, measurable_space (\u03b2 a)] : measurable_space (sigma \u03b2) :=\n\u2a05a, (m a).map (sigma.mk a)\n\nend constructions\n\n/-- A map `f : \u03b1 \u2192 \u03b2` is called a *measurable embedding* if it is injective, measurable, and sends\nmeasurable sets to measurable sets. The latter assumption can be replaced with \u201c`f` has measurable\ninverse `g : range f \u2192 \u03b1`\u201d, 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 {\u03b1 \u03b2 : Type*} [measurable_space \u03b1] [measurable_space \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  Prop :=\n(injective : injective f)\n(measurable : measurable f)\n(measurable_set_image' : \u2200 \u2983s\u2984, measurable_set s \u2192 measurable_set (f '' s))\n\nnamespace measurable_embedding\n\nvariables {m\u03b1 : measurable_space \u03b1} [measurable_space \u03b2] [measurable_space \u03b3]\n  {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3}\n\ninclude m\u03b1\n\nlemma measurable_set_image (hf : measurable_embedding f) {s : set \u03b1} :\n  measurable_set (f '' s) \u2194 measurable_set s :=\n\u27e8\u03bb h, by simpa only [hf.injective.preimage_image] using hf.measurable h,\n  \u03bb h, hf.measurable_set_image' h\u27e9\n\nlemma id : measurable_embedding (id : \u03b1 \u2192 \u03b1) :=\n\u27e8injective_id, measurable_id, \u03bb s hs, by rwa image_id\u27e9\n\nlemma comp (hg : measurable_embedding g) (hf : measurable_embedding f) :\n  measurable_embedding (g \u2218 f) :=\n\u27e8hg.injective.comp hf.injective, hg.measurable.comp hf.measurable,\n  \u03bb s hs, by rwa [\u2190 image_image, hg.measurable_set_image, hf.measurable_set_image]\u27e9\n\nlemma subtype_coe {s : set \u03b1} (hs : measurable_set s) : measurable_embedding (coe : s \u2192 \u03b1) :=\n{ injective := subtype.coe_injective,\n  measurable := measurable_subtype_coe,\n  measurable_set_image' := \u03bb _, measurable_set.subtype_image hs }\n\nlemma measurable_set_range (hf : measurable_embedding f) : measurable_set (range f) :=\nby { rw \u2190 image_univ, exact hf.measurable_set_image' measurable_set.univ }\n\nlemma measurable_set_preimage (hf : measurable_embedding f) {s : set \u03b2} :\n  measurable_set (f \u207b\u00b9' s) \u2194 measurable_set (s \u2229 range f) :=\nby rw [\u2190 image_preimage_eq_inter_range, hf.measurable_set_image]\n\nlemma measurable_range_splitting (hf : measurable_embedding f) :\n  measurable (range_splitting f) :=\n\u03bb s hs, by rwa [preimage_range_splitting hf.injective,\n  \u2190 (subtype_coe hf.measurable_set_range).measurable_set_image, \u2190 image_comp,\n  coe_comp_range_factorization, hf.measurable_set_image]\n\nlemma measurable_extend (hf : measurable_embedding f) {g : \u03b1 \u2192 \u03b3} {g' : \u03b2 \u2192 \u03b3}\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 : \u03b1 \u2192 \u03b3} (hg : measurable g)\n  (hne : \u03b2 \u2192 nonempty \u03b3) :\n  \u2203 g' : \u03b2 \u2192 \u03b3, measurable g' \u2227 g' \u2218 f = g :=\n\u27e8extend f g (\u03bb x, classical.choice (hne x)),\n  hf.measurable_extend hg (measurable_const' $ \u03bb _ _, rfl),\n  funext $ \u03bb x, hf.injective.extend_apply _ _ _\u27e9\n\nlemma measurable_comp_iff (hg : measurable_embedding g) : measurable (g \u2218 f) \u2194 measurable f :=\nbegin\n  refine \u27e8\u03bb H, _, hg.measurable.comp\u27e9,\n  suffices : measurable ((range_splitting g \u2218 range_factorization g) \u2218 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 \u03b1} {s : set \u03b1}\n  (hs : measurable_set s) (hne : s.nonempty) : \u2203 f : \u03b1 \u2192 s, measurable f \u2227 \u2200 x : s, f x = x :=\nlet \u27e8f, hfm, hf\u27e9 := (measurable_embedding.subtype_coe hs).exists_measurable_extend\n  measurable_id (\u03bb _, hne.to_subtype)\nin \u27e8f, hfm, congr_fun hf\u27e9\n\n/-- Equivalences between measurable spaces. Main application is the simplification of measurability\nstatements along measurable equivalences. -/\nstructure measurable_equiv (\u03b1 \u03b2 : Type*) [measurable_space \u03b1] [measurable_space \u03b2] extends \u03b1 \u2243 \u03b2 :=\n(measurable_to_fun : measurable to_equiv)\n(measurable_inv_fun : measurable to_equiv.symm)\n\ninfix ` \u2243\u1d50 `:25 := measurable_equiv\n\nnamespace measurable_equiv\n\nvariables (\u03b1 \u03b2) [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] [measurable_space \u03b4]\n\ninstance : has_coe_to_fun (\u03b1 \u2243\u1d50 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := \u27e8\u03bb e, e.to_fun\u27e9\n\nvariables {\u03b1 \u03b2}\n\n@[simp] lemma coe_to_equiv (e : \u03b1 \u2243\u1d50 \u03b2) : (e.to_equiv : \u03b1 \u2192 \u03b2) = e := rfl\n\n@[measurability]\nprotected lemma measurable (e : \u03b1 \u2243\u1d50 \u03b2) : measurable (e : \u03b1 \u2192 \u03b2) :=\ne.measurable_to_fun\n\n@[simp] lemma coe_mk (e : \u03b1 \u2243 \u03b2) (h1 : measurable e) (h2 : measurable e.symm) :\n  ((\u27e8e, h1, h2\u27e9 : \u03b1 \u2243\u1d50 \u03b2) : \u03b1 \u2192 \u03b2) = e := rfl\n\n/-- Any measurable space is equivalent to itself. -/\ndef refl (\u03b1 : Type*) [measurable_space \u03b1] : \u03b1 \u2243\u1d50 \u03b1 :=\n{ to_equiv := equiv.refl \u03b1,\n  measurable_to_fun := measurable_id, measurable_inv_fun := measurable_id }\n\ninstance : inhabited (\u03b1 \u2243\u1d50 \u03b1) := \u27e8refl \u03b1\u27e9\n\n/-- The composition of equivalences between measurable spaces. -/\ndef trans (ab : \u03b1 \u2243\u1d50 \u03b2) (bc : \u03b2 \u2243\u1d50 \u03b3) :\n  \u03b1 \u2243\u1d50 \u03b3 :=\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 : \u03b1 \u2243\u1d50 \u03b2) : \u03b2 \u2243\u1d50 \u03b1 :=\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 : \u03b1 \u2243\u1d50 \u03b2) : (e.to_equiv.symm : \u03b2 \u2192 \u03b1) = 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 : \u03b1 \u2243\u1d50 \u03b2) : \u03b1 \u2192 \u03b2 := h\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (h : \u03b1 \u2243\u1d50 \u03b2) : \u03b2 \u2192 \u03b1 := h.symm\n\ninitialize_simps_projections measurable_equiv\n  (to_equiv_to_fun \u2192 apply, to_equiv_inv_fun \u2192 symm_apply)\n\nlemma to_equiv_injective : injective (to_equiv : (\u03b1 \u2243\u1d50 \u03b2) \u2192 (\u03b1 \u2243 \u03b2)) :=\nby { rintro \u27e8e\u2081, _, _\u27e9 \u27e8e\u2082, _, _\u27e9 (rfl : e\u2081 = e\u2082), refl }\n\n@[ext] lemma ext {e\u2081 e\u2082 : \u03b1 \u2243\u1d50 \u03b2} (h : (e\u2081 : \u03b1 \u2192 \u03b2) = e\u2082) : e\u2081 = e\u2082 :=\nto_equiv_injective $ equiv.coe_fn_injective h\n\n@[simp] lemma symm_mk (e : \u03b1 \u2243 \u03b2) (h1 : measurable e) (h2 : measurable e.symm) :\n  (\u27e8e, h1, h2\u27e9 : \u03b1 \u2243\u1d50 \u03b2).symm = \u27e8e.symm, h2, h1\u27e9 := rfl\n\nattribute [simps apply to_equiv] trans refl\n\n@[simp] lemma symm_refl (\u03b1 : Type*) [measurable_space \u03b1] : (refl \u03b1).symm = refl \u03b1 := rfl\n\n@[simp] theorem symm_comp_self (e : \u03b1 \u2243\u1d50 \u03b2) : e.symm \u2218 e = id := funext e.left_inv\n\n@[simp] theorem self_comp_symm (e : \u03b1 \u2243\u1d50 \u03b2) : e \u2218 e.symm = id := funext e.right_inv\n\n@[simp] theorem apply_symm_apply (e : \u03b1 \u2243\u1d50 \u03b2) (y : \u03b2) : e (e.symm y) = y := e.right_inv y\n\n@[simp] theorem symm_apply_apply (e : \u03b1 \u2243\u1d50 \u03b2) (x : \u03b1) : e.symm (e x) = x := e.left_inv x\n\n@[simp] theorem symm_trans_self (e : \u03b1 \u2243\u1d50 \u03b2) : e.symm.trans e = refl \u03b2 :=\next e.self_comp_symm\n\n@[simp] theorem self_trans_symm (e : \u03b1 \u2243\u1d50 \u03b2) : e.trans e.symm = refl \u03b1 :=\next e.symm_comp_self\n\nprotected theorem surjective (e : \u03b1 \u2243\u1d50 \u03b2) : surjective e := e.to_equiv.surjective\nprotected theorem bijective (e : \u03b1 \u2243\u1d50 \u03b2) : bijective e := e.to_equiv.bijective\nprotected theorem injective (e : \u03b1 \u2243\u1d50 \u03b2) : injective e := e.to_equiv.injective\n\n@[simp] theorem symm_preimage_preimage (e : \u03b1 \u2243\u1d50 \u03b2) (s : set \u03b2) : e.symm \u207b\u00b9' (e \u207b\u00b9' s) = s :=\ne.to_equiv.symm_preimage_preimage s\n\ntheorem image_eq_preimage (e : \u03b1 \u2243\u1d50 \u03b2) (s : set \u03b1) : e '' s = e.symm \u207b\u00b9' s :=\ne.to_equiv.image_eq_preimage s\n\n@[simp] theorem measurable_set_preimage (e : \u03b1 \u2243\u1d50 \u03b2) {s : set \u03b2} :\n  measurable_set (e \u207b\u00b9' s) \u2194 measurable_set s :=\n\u27e8\u03bb h, by simpa only [symm_preimage_preimage] using e.symm.measurable h, \u03bb h, e.measurable h\u27e9\n\n@[simp] theorem measurable_set_image (e : \u03b1 \u2243\u1d50 \u03b2) {s : set \u03b1} :\n  measurable_set (e '' s) \u2194 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 : \u03b1 \u2243\u1d50 \u03b2) : measurable_embedding e :=\n{ injective := e.injective,\n  measurable := e.measurable,\n  measurable_set_image' := \u03bb s, e.measurable_set_image.2 }\n\n/-- Equal measurable spaces are equivalent. -/\nprotected def cast {\u03b1 \u03b2} [i\u2081 : measurable_space \u03b1] [i\u2082 : measurable_space \u03b2]\n  (h : \u03b1 = \u03b2) (hi : i\u2081 == i\u2082) : \u03b1 \u2243\u1d50 \u03b2 :=\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 : \u03b2 \u2192 \u03b3} (e : \u03b1 \u2243\u1d50 \u03b2) :\n  measurable (f \u2218 e) \u2194 measurable f :=\niff.intro\n  (assume hfe,\n    have measurable (f \u2218 (e.symm.trans e).to_equiv) := hfe.comp e.symm.measurable,\n    by rwa [coe_to_equiv, symm_trans_self] at this)\n  (\u03bb h, h.comp e.measurable)\n\n/-- Any two types with unique elements are measurably equivalent. -/\ndef of_unique_of_unique (\u03b1 \u03b2 : Type*) [measurable_space \u03b1] [measurable_space \u03b2]\n  [unique \u03b1] [unique \u03b2] : \u03b1 \u2243\u1d50 \u03b2 :=\n{ to_equiv := equiv_of_unique \u03b1 \u03b2,\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 : \u03b1 \u2243\u1d50 \u03b2) (cd : \u03b3 \u2243\u1d50 \u03b4) : \u03b1 \u00d7 \u03b3 \u2243\u1d50 \u03b2 \u00d7 \u03b4 :=\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 : \u03b1 \u00d7 \u03b2 \u2243\u1d50 \u03b2 \u00d7 \u03b1 :=\n{ to_equiv := prod_comm \u03b1 \u03b2,\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 : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3 \u2243\u1d50 \u03b1 \u00d7 (\u03b2 \u00d7 \u03b3) :=\n{ to_equiv := prod_assoc \u03b1 \u03b2 \u03b3,\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 : \u03b1 \u2243\u1d50 \u03b2) (cd : \u03b3 \u2243\u1d50 \u03b4) : \u03b1 \u2295 \u03b3 \u2243\u1d50 \u03b2 \u2295 \u03b4 :=\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 \u00d7\u02e2 t \u2243 (s \u00d7 t)` as measurable spaces. -/\ndef set.prod (s : set \u03b1) (t : set \u03b2) : \u21a5(s \u00d7\u02e2 t) \u2243\u1d50 s \u00d7 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 \u03b1 \u2243 \u03b1` as measurable spaces. -/\ndef set.univ (\u03b1 : Type*) [measurable_space \u03b1] : (univ : set \u03b1) \u2243\u1d50 \u03b1 :=\n{ to_equiv := equiv.set.univ \u03b1,\n  measurable_to_fun := measurable_id.subtype_coe,\n  measurable_inv_fun := measurable_id.subtype_mk }\n\n/-- `{a} \u2243 unit` as measurable spaces. -/\ndef set.singleton (a : \u03b1) : ({a} : set \u03b1) \u2243\u1d50 unit :=\n{ to_equiv := equiv.set.singleton a,\n  measurable_to_fun := measurable_const,\n  measurable_inv_fun := measurable_const }\n\n/-- `\u03b1` is equivalent to its image in `\u03b1 \u2295 \u03b2` as measurable spaces. -/\ndef set.range_inl : (range sum.inl : set (\u03b1 \u2295 \u03b2)) \u2243\u1d50 \u03b1 :=\n{ to_fun    := \u03bb ab, match ab with\n    | \u27e8sum.inl a, _\u27e9 := a\n    | \u27e8sum.inr b, p\u27e9 := have false, by { cases p, contradiction }, this.elim\n    end,\n  inv_fun   := \u03bb a, \u27e8sum.inl a, a, rfl\u27e9,\n  left_inv  := by { rintro \u27e8ab, a, rfl\u27e9, refl },\n  right_inv := assume a, rfl,\n  measurable_to_fun  := assume s (hs : measurable_set s),\n    begin\n      refine \u27e8_, hs.inl_image, set.ext _\u27e9,\n      rintros \u27e8ab, a, rfl\u27e9,\n      simp [set.range_inl._match_1]\n    end,\n  measurable_inv_fun := measurable.subtype_mk measurable_inl }\n\n/-- `\u03b2` is equivalent to its image in `\u03b1 \u2295 \u03b2` as measurable spaces. -/\ndef set.range_inr : (range sum.inr : set (\u03b1 \u2295 \u03b2)) \u2243\u1d50 \u03b2 :=\n{ to_fun    := \u03bb ab, match ab with\n    | \u27e8sum.inr b, _\u27e9 := b\n    | \u27e8sum.inl a, p\u27e9 := have false, by { cases p, contradiction }, this.elim\n    end,\n  inv_fun   := \u03bb b, \u27e8sum.inr b, b, rfl\u27e9,\n  left_inv  := by { rintro \u27e8ab, b, rfl\u27e9, refl },\n  right_inv := assume b, rfl,\n  measurable_to_fun  := assume s (hs : measurable_set s),\n    begin\n      refine \u27e8_, measurable_set_inr_image hs, set.ext _\u27e9,\n      rintros \u27e8ab, b, rfl\u27e9,\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 (\u03b1 \u03b2 \u03b3) [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] :\n  (\u03b1 \u2295 \u03b2) \u00d7 \u03b3 \u2243\u1d50 (\u03b1 \u00d7 \u03b3) \u2295 (\u03b2 \u00d7 \u03b3) :=\n{ to_equiv := sum_prod_distrib \u03b1 \u03b2 \u03b3,\n  measurable_to_fun  :=\n  begin\n    refine measurable_of_measurable_union_cover\n      (range sum.inl \u00d7\u02e2 (univ : set \u03b3))\n      (range sum.inr \u00d7\u02e2 (univ : set \u03b3))\n      (measurable_set_range_inl.prod measurable_set.univ)\n      (measurable_set_range_inr.prod measurable_set.univ)\n      (by { rintro \u27e8a|b, c\u27e9; 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 [(\u2218)],\n      convert measurable_inl,\n      ext \u27e8a, c\u27e9, 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 [(\u2218)],\n      convert measurable_inr,\n      ext \u27e8b, c\u27e9, 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 (\u03b1 \u03b2 \u03b3) [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] :\n  \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243\u1d50 (\u03b1 \u00d7 \u03b2) \u2295 (\u03b1 \u00d7 \u03b3) :=\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 (\u03b1 \u03b2 \u03b3 \u03b4)\n  [measurable_space \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] [measurable_space \u03b4] :\n  (\u03b1 \u2295 \u03b2) \u00d7 (\u03b3 \u2295 \u03b4) \u2243\u1d50 ((\u03b1 \u00d7 \u03b3) \u2295 (\u03b1 \u00d7 \u03b4)) \u2295 ((\u03b2 \u00d7 \u03b3) \u2295 (\u03b2 \u00d7 \u03b4)) :=\n(sum_prod_distrib _ _ _).trans $ sum_congr (prod_sum_distrib _ _ _) (prod_sum_distrib _ _ _)\n\nvariables {\u03c0 \u03c0' : \u03b4' \u2192 Type*} [\u2200 x, measurable_space (\u03c0 x)] [\u2200 x, measurable_space (\u03c0' x)]\n\n/-- A family of measurable equivalences `\u03a0 a, \u03b2\u2081 a \u2243\u1d50 \u03b2\u2082 a` generates a measurable equivalence\n  between  `\u03a0 a, \u03b2\u2081 a` and `\u03a0 a, \u03b2\u2082 a`. -/\ndef Pi_congr_right (e : \u03a0 a, \u03c0 a \u2243\u1d50 \u03c0' a) : (\u03a0 a, \u03c0 a) \u2243\u1d50 (\u03a0 a, \u03c0' a) :=\n{ to_equiv := Pi_congr_right (\u03bb a, (e a).to_equiv),\n  measurable_to_fun :=\n    measurable_pi_lambda _ (\u03bb i, (e i).measurable_to_fun.comp (measurable_pi_apply i)),\n  measurable_inv_fun :=\n    measurable_pi_lambda _ (\u03bb 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 \u03b4']\n  {l : list \u03b4'} (hnd : l.nodup) (h : \u2200 i, i \u2208 l) :\n  (\u03a0 i, \u03c0 i) \u2243\u1d50 list.tprod \u03c0 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 `\u03b1` has a unique term, then the type of function `\u03b1 \u2192 \u03b2` is measurably equivalent to `\u03b2`. -/\n@[simps {fully_applied := ff}] def fun_unique (\u03b1 \u03b2 : Type*) [unique \u03b1] [measurable_space \u03b2] :\n  (\u03b1 \u2192 \u03b2) \u2243\u1d50 \u03b2 :=\n{ to_equiv := equiv.fun_unique \u03b1 \u03b2,\n  measurable_to_fun := measurable_pi_apply _,\n  measurable_inv_fun := measurable_pi_iff.2 $ \u03bb b, measurable_id }\n\n/-- The space `\u03a0 i : fin 2, \u03b1 i` is measurably equivalent to `\u03b1 0 \u00d7 \u03b1 1`. -/\n@[simps {fully_applied := ff}] def pi_fin_two (\u03b1 : fin 2 \u2192 Type*) [\u2200 i, measurable_space (\u03b1 i)] :\n  (\u03a0 i, \u03b1 i) \u2243\u1d50 \u03b1 0 \u00d7 \u03b1 1 :=\n{ to_equiv := pi_fin_two_equiv \u03b1,\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 \u27e8measurable_fst, measurable_snd\u27e9 }\n\n/-- The space `fin 2 \u2192 \u03b1` is measurably equivalent to `\u03b1 \u00d7 \u03b1`. -/\n@[simps {fully_applied := ff}] def fin_two_arrow : (fin 2 \u2192 \u03b1) \u2243\u1d50 \u03b1 \u00d7 \u03b1 := pi_fin_two (\u03bb _, \u03b1)\n\n/-- Measurable equivalence between `\u03a0 j : fin (n + 1), \u03b1 j` and\n`\u03b1 i \u00d7 \u03a0 j : fin n, \u03b1 (fin.succ_above i j)`. -/\n@[simps {fully_applied := ff}]\ndef pi_fin_succ_above_equiv {n : \u2115} (\u03b1 : fin (n + 1) \u2192 Type*) [\u03a0 i, measurable_space (\u03b1 i)]\n  (i : fin (n + 1)) :\n  (\u03a0 j, \u03b1 j) \u2243\u1d50 \u03b1 i \u00d7 (\u03a0 j, \u03b1 (i.succ_above j)) :=\n{ to_equiv := pi_fin_succ_above_equiv \u03b1 i,\n  measurable_to_fun := (measurable_pi_apply i).prod_mk $ measurable_pi_iff.2 $\n    \u03bb 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 (\u03c0)\n\n/-- Measurable equivalence between (dependent) functions on a type and pairs of functions on\n`{i // p i}` and `{i // \u00acp i}`. See also `equiv.pi_equiv_pi_subtype_prod`. -/\n@[simps {fully_applied := ff}]\ndef pi_equiv_pi_subtype_prod (p : \u03b4' \u2192 Prop) [decidable_pred p] :\n  (\u03a0 i, \u03c0 i) \u2243\u1d50 ((\u03a0 i : subtype p, \u03c0 i) \u00d7 (\u03a0 i : {i // \u00acp i}, \u03c0 i)) :=\n{ to_equiv := pi_equiv_pi_subtype_prod p \u03c0,\n  measurable_to_fun := measurable_pi_equiv_pi_subtype_prod \u03c0 p,\n  measurable_inv_fun := measurable_pi_equiv_pi_subtype_prod_symm \u03c0 p }\n\n/-- If `s` is a measurable set in a measurable space, that space is equivalent\nto the sum of `s` and `s\u1d9c`.-/\ndef sum_compl {s : set \u03b1} [decidable_pred s] (hs : measurable_set s) : s \u2295 (s\u1d9c : set \u03b1) \u2243\u1d50 \u03b1 :=\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 \u03b1] [measurable_space \u03b2] [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\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 \u03b1) (hf : measurable_embedding f) :\n  s \u2243\u1d50 (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 \u27e8u, hu, rfl\u27e9, 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) : \u03b1 \u2243\u1d50 (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 \u2192 \u03b1} (hf\u2081 : measurable f)\n  (hf\u2082 : measurable_set (range f)) (hg : measurable g)\n  (H : left_inverse g (range_factorization f)) : measurable_embedding f :=\nbegin\n  set e : \u03b1 \u2243\u1d50 range f :=\n    \u27e8\u27e8range_factorization f, g, H, H.right_inverse_of_surjective surjective_onto_range\u27e9,\n      hf\u2081.subtype_mk, hg\u27e9,\n  exact (measurable_embedding.subtype_coe hf\u2082).comp e.measurable_embedding\nend\n\nlemma of_measurable_inverse (hf\u2081 : measurable f)\n  (hf\u2082 : measurable_set (range f)) (hg : measurable g)\n  (H : left_inverse g f) : measurable_embedding f :=\nof_measurable_inverse_on_range hf\u2081 hf\u2082 (hg.comp measurable_subtype_coe) H\n\nopen_locale classical\n\n/-- The **`measurable Schr\u00f6der-Bernstein Theorem**: Given measurable embeddings\n`\u03b1 \u2192 \u03b2` and `\u03b2 \u2192 \u03b1`, we can find a measurable equivalence `\u03b1 \u2243\u1d50 \u03b2`.-/\nnoncomputable\ndef schroeder_bernstein {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\n  (hf : measurable_embedding f)(hg : measurable_embedding g) : \u03b1 \u2243\u1d50 \u03b2 :=\nbegin\n  let F : set \u03b1 \u2192 set \u03b1 := \u03bb A, (g '' (f '' A)\u1d9c)\u1d9c,\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 : \u03a3' A : set \u03b1, measurable_set A \u2227 F A = A,\n  { rcases this with \u27e8A, Ameas, Afp\u27e9,\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\u1d9c = g '' B\u1d9c,\n    { apply compl_injective,\n      rw \u2190 Afp,\n      simp, },\n    rw this,\n    exact (hg.equiv_image _).symm, },\n  have Fmono : \u2200 {A B}, A \u2286 B \u2192 F A \u2286 F B := \u03bb A B hAB,\n    compl_subset_compl.mpr $ set.image_subset _ $\n    compl_subset_compl.mpr $ set.image_subset _ hAB,\n  let X : \u2115 \u2192 set \u03b1 := \u03bb n, F^[n] univ,\n  refine \u27e8Inter X, _, _\u27e9,\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 \u27e8y, hy, rfl\u27e9,\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 \u27e8y, h, rfl\u27e9,\nend\n\nend measurable_embedding\n\nnamespace filter\n\nvariables [measurable_space \u03b1]\n\n/-- A filter `f` is measurably generates if each `s \u2208 f` includes a measurable `t \u2208 f`. -/\nclass is_measurably_generated (f : filter \u03b1) : Prop :=\n(exists_measurable_subset : \u2200 \u2983s\u2984, s \u2208 f \u2192 \u2203 t \u2208 f, measurable_set t \u2227 t \u2286 s)\n\ninstance is_measurably_generated_bot : is_measurably_generated (\u22a5 : filter \u03b1) :=\n\u27e8\u03bb _ _, \u27e8\u2205, mem_bot, measurable_set.empty, empty_subset _\u27e9\u27e9\n\ninstance is_measurably_generated_top : is_measurably_generated (\u22a4 : filter \u03b1) :=\n\u27e8\u03bb s hs, \u27e8univ, univ_mem, measurable_set.univ, \u03bb x _, hs x\u27e9\u27e9\n\nlemma eventually.exists_measurable_mem {f : filter \u03b1} [is_measurably_generated f]\n  {p : \u03b1 \u2192 Prop} (h : \u2200\u1da0 x in f, p x) :\n  \u2203 s \u2208 f, measurable_set s \u2227 \u2200 x \u2208 s, p x :=\nis_measurably_generated.exists_measurable_subset h\n\nlemma eventually.exists_measurable_mem_of_small_sets {f : filter \u03b1} [is_measurably_generated f]\n  {p : set \u03b1 \u2192 Prop} (h : \u2200\u1da0 s in f.small_sets, p s) :\n  \u2203 s \u2208 f, measurable_set s \u2227 p s :=\nlet \u27e8s, hsf, hs\u27e9 := eventually_small_sets.1 h,\n  \u27e8t, htf, htm, hts\u27e9 := is_measurably_generated.exists_measurable_subset hsf\nin \u27e8t, htf, htm, hs t hts\u27e9\n\ninstance inf_is_measurably_generated (f g : filter \u03b1) [is_measurably_generated f]\n  [is_measurably_generated g] :\n  is_measurably_generated (f \u2293 g) :=\nbegin\n  refine \u27e8_\u27e9,\n  rintros t \u27e8sf, hsf, sg, hsg, rfl\u27e9,\n  rcases is_measurably_generated.exists_measurable_subset hsf with \u27e8s'f, hs'f, hmf, hs'sf\u27e9,\n  rcases is_measurably_generated.exists_measurable_subset hsg with \u27e8s'g, hs'g, hmg, hs'sg\u27e9,\n  refine \u27e8s'f \u2229 s'g, inter_mem_inf hs'f hs'g, hmf.inter hmg, _\u27e9,\n  exact inter_subset_inter hs'sf hs'sg\nend\n\nlemma principal_is_measurably_generated_iff {s : set \u03b1} :\n  is_measurably_generated (\ud835\udcdf s) \u2194 measurable_set s :=\nbegin\n  refine \u27e8_, \u03bb hs, \u27e8\u03bb t ht, \u27e8s, mem_principal_self s, hs, ht\u27e9\u27e9\u27e9,\n  rintros \u27e8hs\u27e9,\n  rcases hs (mem_principal_self s) with \u27e8t, ht, htm, hts\u27e9,\n  have : t = s := subset.antisymm hts ht,\n  rwa \u2190 this\nend\n\nalias principal_is_measurably_generated_iff \u2194\n  _ _root_.measurable_set.principal_is_measurably_generated\n\ninstance infi_is_measurably_generated {f : \u03b9 \u2192 filter \u03b1} [\u2200 i, is_measurably_generated (f i)] :\n  is_measurably_generated (\u2a05 i, f i) :=\nbegin\n  refine \u27e8\u03bb s hs, _\u27e9,\n  rw [\u2190 equiv.plift.surjective.infi_comp, mem_infi] at hs,\n  rcases hs with \u27e8t, ht, \u27e8V, hVf, rfl\u27e9\u27e9,\n  choose U hUf hU using \u03bb i, is_measurably_generated.exists_measurable_subset (hVf i),\n  refine \u27e8\u22c2 i : t, U i, _, _, _\u27e9,\n  { rw [\u2190 equiv.plift.surjective.infi_comp, mem_infi],\n    refine \u27e8t, ht, U, hUf, rfl\u27e9 },\n  { haveI := ht.countable.to_encodable,\n    exact measurable_set.Inter (\u03bb i, (hU i).1) },\n  { exact Inter_mono (\u03bb 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 \u03b1)) : Prop :=\n\u2203 (s : \u2115 \u2192 set \u03b1), (\u2200 n, s n \u2208 C) \u2227 (\u22c3 n, s n) = univ\n\nlemma is_countably_spanning_measurable_set [measurable_space \u03b1] :\n  is_countably_spanning {s : set \u03b1 | measurable_set s} :=\n\u27e8\u03bb _, univ, \u03bb _, measurable_set.univ, Union_const _\u27e9\n\nnamespace measurable_set\n\n/-!\n### Typeclasses on `subtype measurable_set`\n-/\n\nvariables [measurable_space \u03b1]\n\ninstance : has_mem \u03b1 (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u03bb a s, a \u2208 (s : set \u03b1)\u27e9\n\n@[simp] lemma mem_coe (a : \u03b1) (s : subtype (measurable_set : set \u03b1 \u2192 Prop)) :\n  a \u2208 (s : set \u03b1) \u2194 a \u2208 s := iff.rfl\n\ninstance : has_emptyc (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u27e8\u2205, measurable_set.empty\u27e9\u27e9\n\n@[simp] lemma coe_empty : \u2191(\u2205 : subtype (measurable_set : set \u03b1 \u2192 Prop)) = (\u2205 : set \u03b1) := rfl\n\ninstance [measurable_singleton_class \u03b1] : has_insert \u03b1 (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u03bb a s, \u27e8has_insert.insert a s, s.prop.insert a\u27e9\u27e9\n\n@[simp] lemma coe_insert [measurable_singleton_class \u03b1] (a : \u03b1)\n  (s : subtype (measurable_set : set \u03b1 \u2192 Prop)) :\n  \u2191(has_insert.insert a s) = (has_insert.insert a s : set \u03b1) := rfl\n\ninstance : has_compl (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u03bb x, \u27e8x\u1d9c, x.prop.compl\u27e9\u27e9\n\n@[simp] lemma coe_compl (s : subtype (measurable_set : set \u03b1 \u2192 Prop)) : \u2191(s\u1d9c) = (s\u1d9c : set \u03b1) := rfl\n\ninstance : has_union (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u03bb x y, \u27e8x \u222a y, x.prop.union y.prop\u27e9\u27e9\n\n@[simp] lemma coe_union (s t : subtype (measurable_set : set \u03b1 \u2192 Prop)) :\n  \u2191(s \u222a t) = (s \u222a t : set \u03b1) := rfl\n\ninstance : has_inter (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u03bb x y, \u27e8x \u2229 y, x.prop.inter y.prop\u27e9\u27e9\n\n@[simp] lemma coe_inter (s t : subtype (measurable_set : set \u03b1 \u2192 Prop)) :\n  \u2191(s \u2229 t) = (s \u2229 t : set \u03b1) := rfl\n\ninstance : has_sdiff (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u03bb x y, \u27e8x \\ y, x.prop.diff y.prop\u27e9\u27e9\n\n@[simp] lemma coe_sdiff (s t : subtype (measurable_set : set \u03b1 \u2192 Prop)) :\n  \u2191(s \\ t) = (s \\ t : set \u03b1) := rfl\n\ninstance : has_bot (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u27e8\u22a5, measurable_set.empty\u27e9\u27e9\n\n@[simp] lemma coe_bot : \u2191(\u22a5 : subtype (measurable_set : set \u03b1 \u2192 Prop)) = (\u22a5 : set \u03b1) := rfl\n\ninstance : has_top (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n\u27e8\u27e8\u22a4, measurable_set.univ\u27e9\u27e9\n\n@[simp] lemma coe_top : \u2191(\u22a4 : subtype (measurable_set : set \u03b1 \u2192 Prop)) = (\u22a4 : set \u03b1) := rfl\n\ninstance : partial_order (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\npartial_order.lift _ subtype.coe_injective\n\ninstance : distrib_lattice (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n{ sup := (\u222a),\n  le_sup_left := \u03bb a b, show (a : set \u03b1) \u2264 a \u2294 b, from le_sup_left,\n  le_sup_right := \u03bb a b, show (b : set \u03b1) \u2264 a \u2294 b, from le_sup_right,\n  sup_le := \u03bb a b c ha hb, show (a \u2294 b : set \u03b1) \u2264 c, from sup_le ha hb,\n  inf := (\u2229),\n  inf_le_left := \u03bb a b, show (a \u2293 b : set \u03b1) \u2264 a, from inf_le_left,\n  inf_le_right := \u03bb a b, show (a \u2293 b : set \u03b1) \u2264 b, from inf_le_right,\n  le_inf := \u03bb a b c ha hb, show (a : set \u03b1) \u2264 b \u2293 c, from le_inf ha hb,\n  le_sup_inf := \u03bb x y z, show ((x \u2294 y) \u2293 (x \u2294 z) : set \u03b1) \u2264 x \u2294 y \u2293 z, from le_sup_inf,\n  .. measurable_set.subtype.partial_order }\n\ninstance : bounded_order (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n{ top := \u22a4,\n  le_top := \u03bb a, show (a : set \u03b1) \u2264 \u22a4, from le_top,\n  bot := \u22a5,\n  bot_le := \u03bb a, show (\u22a5 : set \u03b1) \u2264 a, from bot_le }\n\ninstance : boolean_algebra (subtype (measurable_set : set \u03b1 \u2192 Prop)) :=\n{ sdiff := (\\),\n  compl := has_compl.compl,\n  inf_compl_le_bot := \u03bb a, boolean_algebra.inf_compl_le_bot (a : set \u03b1),\n  top_le_sup_compl := \u03bb a, boolean_algebra.top_le_sup_compl (a : set \u03b1),\n  sdiff_eq := \u03bb 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 : \u2115 \u2192 set \u03b1} {p : \u2115 \u2192 Prop}\n  (h : \u2200 n, p n \u2192 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    (\u03bb n, measurable_set.Union (\u03bb m, measurable_set.Union $ \u03bb hm, h m hm.1)),\nend\n\n@[measurability] lemma measurable_set_bliminf {s : \u2115 \u2192 set \u03b1} {p : \u2115 \u2192 Prop}\n  (h : \u2200 n, p n \u2192 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    (\u03bb n, measurable_set.Inter (\u03bb m, measurable_set.Inter $ \u03bb hm, h m hm.1)),\nend\n\n@[measurability] lemma measurable_set_limsup {s : \u2115 \u2192 set \u03b1} (hs : \u2200 n, measurable_set $ s n) :\n  measurable_set $ filter.limsup s filter.at_top :=\nbegin\n  convert measurable_set_blimsup (\u03bb n h, hs n : \u2200 n, true \u2192 measurable_set (s n)),\n  simp,\nend\n\n@[measurability] lemma measurable_set_liminf {s : \u2115 \u2192 set \u03b1} (hs : \u2200 n, measurable_set $ s n) :\n  measurable_set $ filter.liminf s filter.at_top :=\nbegin\n  convert measurable_set_bliminf (\u03bb n h, hs n : \u2200 n, true \u2192 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 \u03b1 = \u03b1\u1d50\u1d52\u1d56` to be the multiplicative opposite of `\u03b1`. It inherits\nall additive algebraic structures on `\u03b1` (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 `\u03b1` to `\u03b1\u1d50\u1d52\u1d56`.\n\nWe also define `add_opposite \u03b1 = \u03b1\u1d43\u1d52\u1d56` to be the additive opposite of `\u03b1`. It inherits all\nmultiplicative algebraic structures on `\u03b1` (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 `\u03b1` to `\u03b1\u1d43\u1d52\u1d56`.\n\n## Notation\n\n* `\u03b1\u1d50\u1d52\u1d56 = mul_opposite \u03b1`\n* `\u03b1\u1d43\u1d52\u1d56 = add_opposite \u03b1`\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 `\u03b1` and\nreverses left and right in multiplication.-/\n@[to_additive\n      \"Additive opposite of a type. This type inherits all multiplicative structures on\\n`\u03b1` and reverses left and right in addition.\"]\ndef MulOpposite (\u03b1 : Type u) : Type u :=\n  \u03b1\n#align mul_opposite MulOpposite\n#align add_opposite AddOpposite\n-/\n\n-- mathport name: \u00abexpr \u1d50\u1d52\u1d56\u00bb\npostfix:max \"\u1d50\u1d52\u1d56\" => MulOpposite\n\n-- mathport name: \u00abexpr \u1d43\u1d52\u1d56\u00bb\npostfix:max \"\u1d43\u1d52\u1d56\" => AddOpposite\n\nvariable {\u03b1 : Type u}\n\nnamespace MulOpposite\n\n#print MulOpposite.op /-\n/-- The element of `mul_opposite \u03b1` that represents `x : \u03b1`. -/\n@[pp_nodot, to_additive \"The element of `\u03b1\u1d43\u1d52\u1d56` that represents `x : \u03b1`.\"]\ndef op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56 :=\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 `\u03b1` represented by `x : \u03b1\u1d50\u1d52\u1d56`. -/\n@[pp_nodot, to_additive \"The element of `\u03b1` represented by `x : \u03b1\u1d43\u1d52\u1d56`.\"]\ndef unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1 :=\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 : \u03b1) : 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 : \u03b1\u1d50\u1d52\u1d56) : 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 : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) \u2218 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 : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) \u2218 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 {\u03b1 : Type.{u1}} {F : (MulOpposite.{u1} \u03b1) -> Sort.{u2}}, (forall (X : \u03b1), F (MulOpposite.op.{u1} \u03b1 X)) -> (forall (X : MulOpposite.{u1} \u03b1), F X)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {F : (MulOpposite.{u2} \u03b1) -> Sort.{u1}}, (forall (X : \u03b1), F (MulOpposite.op.{u2} \u03b1 X)) -> (forall (X : MulOpposite.{u2} \u03b1), F X)\nCase conversion may be inaccurate. Consider using '#align mul_opposite.rec MulOpposite.rec'\u2093'. -/\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 : \u2200 X : \u03b1\u1d50\u1d52\u1d56, Sort v} (h : \u2200 X, F (op X)) : \u2200 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 `\u03b1` and `\u03b1\u1d50\u1d52\u1d56`. -/\n@[to_additive \"The canonical bijection between `\u03b1` and `\u03b1\u1d43\u1d52\u1d56`.\",\n  simps (config := { fullyApplied := false }) apply symm_apply]\ndef opEquiv : \u03b1 \u2243 \u03b1\u1d50\u1d52\u1d56 :=\n  \u27e8op, unop, unop_op, op_unop\u27e9\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 : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) :=\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 : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) :=\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 : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) :=\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 : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) :=\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 : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) :=\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 : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) :=\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 : \u03b1} : op x = op y \u2194 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 : \u03b1\u1d50\u1d52\u1d56} : unop x = unop y \u2194 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 (\u03b1)\n\n@[to_additive]\ninstance [Nontrivial \u03b1] : Nontrivial \u03b1\u1d50\u1d52\u1d56 :=\n  op_injective.Nontrivial\n\n@[to_additive]\ninstance [Inhabited \u03b1] : Inhabited \u03b1\u1d50\u1d52\u1d56 :=\n  \u27e8op default\u27e9\n\n@[to_additive]\ninstance [Subsingleton \u03b1] : Subsingleton \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.Subsingleton\n\n@[to_additive]\ninstance [Unique \u03b1] : Unique \u03b1\u1d50\u1d52\u1d56 :=\n  Unique.mk' _\n\n@[to_additive]\ninstance [IsEmpty \u03b1] : IsEmpty \u03b1\u1d50\u1d52\u1d56 :=\n  Function.isEmpty unop\n\ninstance [Zero \u03b1] : Zero \u03b1\u1d50\u1d52\u1d56 where zero := op 0\n\n@[to_additive]\ninstance [One \u03b1] : One \u03b1\u1d50\u1d52\u1d56 where one := op 1\n\ninstance [Add \u03b1] : Add \u03b1\u1d50\u1d52\u1d56 where add x y := op (unop x + unop y)\n\ninstance [Sub \u03b1] : Sub \u03b1\u1d50\u1d52\u1d56 where sub x y := op (unop x - unop y)\n\ninstance [Neg \u03b1] : Neg \u03b1\u1d50\u1d52\u1d56 where neg x := op <| -unop x\n\ninstance [InvolutiveNeg \u03b1] : InvolutiveNeg \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.hasNeg \u03b1 with neg_neg := fun a => unop_injective <| neg_neg _ }\n\n@[to_additive]\ninstance [Mul \u03b1] : Mul \u03b1\u1d50\u1d52\u1d56 where mul x y := op (unop y * unop x)\n\n@[to_additive]\ninstance [Inv \u03b1] : Inv \u03b1\u1d50\u1d52\u1d56 where inv x := op <| (unop x)\u207b\u00b9\n\n@[to_additive]\ninstance [InvolutiveInv \u03b1] : InvolutiveInv \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.hasInv \u03b1 with inv_inv := fun a => unop_injective <| inv_inv _ }\n\n@[to_additive]\ninstance (R : Type _) [SMul R \u03b1] : SMul R \u03b1\u1d50\u1d52\u1d56 where smul c x := op (c \u2022 unop x)\n\nsection\n\nvariable (\u03b1)\n\n#print MulOpposite.op_zero /-\n@[simp]\ntheorem op_zero [Zero \u03b1] : op (0 : \u03b1) = 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 \u03b1] : unop (0 : \u03b1\u1d50\u1d52\u1d56) = 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 \u03b1] : op (1 : \u03b1) = 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 \u03b1] : unop (1 : \u03b1\u1d50\u1d52\u1d56) = 1 :=\n  rfl\n#align mul_opposite.unop_one MulOpposite.unop_one\n#align add_opposite.unop_zero AddOpposite.unop_zero\n-/\n\nvariable {\u03b1}\n\n#print MulOpposite.op_add /-\n@[simp]\ntheorem op_add [Add \u03b1] (x y : \u03b1) : 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 \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : 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 \u03b1] (x : \u03b1) : 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 \u03b1] (x : \u03b1\u1d50\u1d52\u1d56) : 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 \u03b1] (x y : \u03b1) : 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 \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : 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 \u03b1] (x : \u03b1) : op x\u207b\u00b9 = (op x)\u207b\u00b9 :=\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 \u03b1] (x : \u03b1\u1d50\u1d52\u1d56) : unop x\u207b\u00b9 = (unop x)\u207b\u00b9 :=\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 \u03b1] (x y : \u03b1) : 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 \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : 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 \u03b1] (c : R) (a : \u03b1) : op (c \u2022 a) = c \u2022 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 \u03b1] (c : R) (a : \u03b1\u1d50\u1d52\u1d56) : unop (c \u2022 a) = c \u2022 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 {\u03b1}\n\n#print MulOpposite.unop_eq_zero_iff /-\n@[simp]\ntheorem unop_eq_zero_iff [Zero \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop = (0 : \u03b1) \u2194 a = (0 : \u03b1\u1d50\u1d52\u1d56) :=\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 \u03b1] (a : \u03b1) : op a = (0 : \u03b1\u1d50\u1d52\u1d56) \u2194 a = (0 : \u03b1) :=\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 \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop \u2260 (0 : \u03b1) \u2194 a \u2260 (0 : \u03b1\u1d50\u1d52\u1d56) :=\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 \u03b1] (a : \u03b1) : op a \u2260 (0 : \u03b1\u1d50\u1d52\u1d56) \u2194 a \u2260 (0 : \u03b1) :=\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 \u03b1] (a : \u03b1\u1d50\u1d52\u1d56) : a.unop = 1 \u2194 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 \u03b1] (a : \u03b1) : op a = 1 \u2194 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 \u03b1] : One \u03b1\u1d43\u1d52\u1d56 where one := op 1\n\n#print AddOpposite.op_one /-\n@[simp]\ntheorem op_one [One \u03b1] : op (1 : \u03b1) = 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 \u03b1] : unop 1 = (1 : \u03b1) :=\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 \u03b1] {a : \u03b1} : op a = 1 \u2194 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 \u03b1] {a : \u03b1\u1d43\u1d52\u1d56} : unop a = 1 \u2194 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 \u03b1] : Mul \u03b1\u1d43\u1d52\u1d56 where mul a b := op (unop a * unop b)\n\n#print AddOpposite.op_mul /-\n@[simp]\ntheorem op_mul [Mul \u03b1] (a b : \u03b1) : 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 \u03b1] (a b : \u03b1\u1d43\u1d52\u1d56) : unop (a * b) = unop a * unop b :=\n  rfl\n#align add_opposite.unop_mul AddOpposite.unop_mul\n-/\n\ninstance [Inv \u03b1] : Inv \u03b1\u1d43\u1d52\u1d56 where inv a := op (unop a)\u207b\u00b9\n\ninstance [InvolutiveInv \u03b1] : InvolutiveInv \u03b1\u1d43\u1d52\u1d56 :=\n  { AddOpposite.hasInv with inv_inv := fun a => unop_injective <| inv_inv _ }\n\n#print AddOpposite.op_inv /-\n@[simp]\ntheorem op_inv [Inv \u03b1] (a : \u03b1) : op a\u207b\u00b9 = (op a)\u207b\u00b9 :=\n  rfl\n#align add_opposite.op_inv AddOpposite.op_inv\n-/\n\n#print AddOpposite.unop_inv /-\n@[simp]\ntheorem unop_inv [Inv \u03b1] (a : \u03b1\u1d43\u1d52\u1d56) : unop a\u207b\u00b9 = (unop a)\u207b\u00b9 :=\n  rfl\n#align add_opposite.unop_inv AddOpposite.unop_inv\n-/\n\ninstance [Div \u03b1] : Div \u03b1\u1d43\u1d52\u1d56 where div a b := op (unop a / unop b)\n\n#print AddOpposite.op_div /-\n@[simp]\ntheorem op_div [Div \u03b1] (a b : \u03b1) : 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 \u03b1] (a b : \u03b1\u1d43\u1d52\u1d56) : 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u2192 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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\n\nsection inducing\n\n/-- A function `f : \u03b1 \u2192 \u03b2` between topological spaces is inducing if the topology on `\u03b1` is induced\nby the topology on `\u03b2` through `f`, meaning that a set `s : set \u03b1` is open iff it is the preimage\nunder `f` of some open set `t : set \u03b2`. -/\n@[mk_iff]\nstructure inducing [t\u03b1 : topological_space \u03b1] [t\u03b2 : topological_space \u03b2] (f : \u03b1 \u2192 \u03b2) : Prop :=\n(induced : t\u03b1 = t\u03b2.induced f)\n\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4]\n\nlemma inducing_id : inducing (@id \u03b1) :=\n\u27e8induced_id.symm\u27e9\n\nprotected lemma inducing.comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : inducing g) (hf : inducing f) :\n  inducing (g \u2218 f) :=\n\u27e8by rw [hf.induced, hg.induced, induced_compose]\u27e9\n\nlemma inducing_of_inducing_compose {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hf : continuous f) (hg : continuous g)\n  (hgf : inducing (g \u2218 f)) : inducing f :=\n\u27e8le_antisymm\n    (by rwa \u2190 continuous_iff_le_induced)\n    (by { rw [hgf.induced, \u2190 continuous_iff_le_induced], apply hg.comp continuous_induced_dom })\u27e9\n\nlemma inducing_iff_nhds {f : \u03b1 \u2192 \u03b2} : inducing f \u2194 \u2200 a, \ud835\udcdd a = comap f (\ud835\udcdd (f a)) :=\n(inducing_iff _).trans (induced_iff_nhds_eq f)\n\nlemma inducing.nhds_eq_comap {f : \u03b1 \u2192 \u03b2} (hf : inducing f) :\n  \u2200 (a : \u03b1), \ud835\udcdd a = comap f (\ud835\udcdd $ f a) :=\ninducing_iff_nhds.1 hf\n\nlemma inducing.nhds_set_eq_comap {f : \u03b1 \u2192 \u03b2} (hf : inducing f) (s : set \u03b1) :\n  \ud835\udcdd\u02e2 s = comap f (\ud835\udcdd\u02e2 (f '' s)) :=\nby simp only [nhds_set, Sup_image, comap_supr, hf.nhds_eq_comap, supr_image]\n\nlemma inducing.map_nhds_eq {f : \u03b1 \u2192 \u03b2} (hf : inducing f) (a : \u03b1) :\n  (\ud835\udcdd a).map f = \ud835\udcdd[range f] (f a) :=\nhf.induced.symm \u25b8 map_nhds_induced_eq a\n\nlemma inducing.map_nhds_of_mem {f : \u03b1 \u2192 \u03b2} (hf : inducing f) (a : \u03b1) (h : range f \u2208 \ud835\udcdd (f a)) :\n  (\ud835\udcdd a).map f = \ud835\udcdd (f a) :=\nhf.induced.symm \u25b8 map_nhds_induced_of_mem h\n\nlemma inducing.image_mem_nhds_within {f : \u03b1 \u2192 \u03b2} (hf : inducing f) {a : \u03b1} {s : set \u03b1}\n  (hs : s \u2208 \ud835\udcdd a) : f '' s \u2208 \ud835\udcdd[range f] (f a) :=\nhf.map_nhds_eq a \u25b8 image_mem_map hs\n\nlemma inducing.tendsto_nhds_iff {\u03b9 : Type*}\n  {f : \u03b9 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} {a : filter \u03b9} {b : \u03b2} (hg : inducing g) :\n  tendsto f a (\ud835\udcdd b) \u2194 tendsto (g \u2218 f) a (\ud835\udcdd (g b)) :=\nby rw [hg.nhds_eq_comap, tendsto_comap_iff]\n\nlemma inducing.continuous_at_iff {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hg : inducing g) {x : \u03b1} :\n  continuous_at f x \u2194 continuous_at (g \u2218 f) x :=\nby simp_rw [continuous_at, inducing.tendsto_nhds_iff hg]\n\nlemma inducing.continuous_iff {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hg : inducing g) :\n  continuous f \u2194 continuous (g \u2218 f) :=\nby simp_rw [continuous_iff_continuous_at, hg.continuous_at_iff]\n\nlemma inducing.continuous_at_iff' {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hf : inducing f) {x : \u03b1}\n  (h : range f \u2208 \ud835\udcdd (f x)) : continuous_at (g \u2218 f) x \u2194 continuous_at g (f x) :=\nby { simp_rw [continuous_at, filter.tendsto, \u2190 hf.map_nhds_of_mem _ h, filter.map_map] }\n\nprotected lemma inducing.continuous {f : \u03b1 \u2192 \u03b2} (hf : inducing f) : continuous f :=\nhf.continuous_iff.mp continuous_id\n\nprotected lemma inducing.inducing_iff {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hg : inducing g) :\n  inducing f \u2194 inducing (g \u2218 f) :=\nbegin\n  refine \u27e8\u03bb h, hg.comp h, \u03bb hgf, inducing_of_inducing_compose _ hg.continuous hgf\u27e9,\n  rw hg.continuous_iff,\n  exact hgf.continuous\nend\n\nlemma inducing.closure_eq_preimage_closure_image {f : \u03b1 \u2192 \u03b2} (hf : inducing f) (s : set \u03b1) :\n  closure s = f \u207b\u00b9' closure (f '' s) :=\nby { ext x, rw [set.mem_preimage, \u2190 closure_induced, hf.induced] }\n\nlemma inducing.is_closed_iff {f : \u03b1 \u2192 \u03b2} (hf : inducing f) {s : set \u03b1} :\n  is_closed s \u2194 \u2203 t, is_closed t \u2227 f \u207b\u00b9' t = s :=\nby rw [hf.induced, is_closed_induced_iff]\n\nlemma inducing.is_closed_iff' {f : \u03b1 \u2192 \u03b2} (hf : inducing f) {s : set \u03b1} :\n  is_closed s \u2194 \u2200 x, f x \u2208 closure (f '' s) \u2192 x \u2208 s :=\nby rw [hf.induced, is_closed_induced_iff']\n\nlemma inducing.is_closed_preimage {f : \u03b1 \u2192 \u03b2} (h : inducing f) (s : set \u03b2) (hs : is_closed s) :\n  is_closed (f \u207b\u00b9' s) :=\n(inducing.is_closed_iff h).mpr \u27e8s, hs, rfl\u27e9\n\nlemma inducing.is_open_iff {f : \u03b1 \u2192 \u03b2} (hf : inducing f) {s : set \u03b1} :\n  is_open s \u2194 \u2203 t, is_open t \u2227 f \u207b\u00b9' t = s :=\nby rw [hf.induced, is_open_induced_iff]\n\nlemma inducing.dense_iff {f : \u03b1 \u2192 \u03b2} (hf : inducing f) {s : set \u03b1} :\n  dense s \u2194 \u2200 x, f x \u2208 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 \u03b1`, `s` is open iff it is the preimage of an open set. -/\n@[mk_iff] structure embedding [t\u03b1 : topological_space \u03b1] [t\u03b2 : topological_space \u03b2] (f : \u03b1 \u2192 \u03b2)\n  extends inducing f : Prop :=\n(inj : injective f)\n\nlemma function.injective.embedding_induced [t : topological_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} (hf : injective f) :\n  @_root_.embedding \u03b1 \u03b2 (t.induced f) t f :=\n{ induced := rfl,\n  inj := hf }\n\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3]\n\nlemma embedding.mk' (f : \u03b1 \u2192 \u03b2) (inj : injective f)\n  (induced : \u2200 a, comap f (\ud835\udcdd (f a)) = \ud835\udcdd a) : embedding f :=\n\u27e8inducing_iff_nhds.2 (\u03bb a, (induced a).symm), inj\u27e9\n\nlemma embedding_id : embedding (@id \u03b1) :=\n\u27e8inducing_id, assume a\u2081 a\u2082 h, h\u27e9\n\nlemma embedding.comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : embedding g) (hf : embedding f) :\n  embedding (g \u2218 f) :=\n{ inj:= assume a\u2081 a\u2082 h, hf.inj $ hg.inj h,\n  ..hg.to_inducing.comp hf.to_inducing }\n\nlemma embedding_of_embedding_compose {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hf : continuous f) (hg : continuous g)\n  (hgf : embedding (g \u2218 f)) : embedding f :=\n{ induced := (inducing_of_inducing_compose hf hg hgf.to_inducing).induced,\n  inj := assume a\u2081 a\u2082 h, hgf.inj $ by simp [h, (\u2218)] }\n\nprotected lemma function.left_inverse.embedding {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\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 \u25b8 embedding_id\n\nlemma embedding.map_nhds_eq {f : \u03b1 \u2192 \u03b2} (hf : embedding f) (a : \u03b1) :\n  (\ud835\udcdd a).map f = \ud835\udcdd[range f] (f a) :=\nhf.1.map_nhds_eq a\n\nlemma embedding.map_nhds_of_mem {f : \u03b1 \u2192 \u03b2}\n  (hf : embedding f) (a : \u03b1) (h : range f \u2208 \ud835\udcdd (f a)) : (\ud835\udcdd a).map f = \ud835\udcdd (f a) :=\nhf.1.map_nhds_of_mem a h\n\nlemma embedding.tendsto_nhds_iff {\u03b9 : Type*}\n  {f : \u03b9 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} {a : filter \u03b9} {b : \u03b2} (hg : embedding g) :\n  tendsto f a (\ud835\udcdd b) \u2194 tendsto (g \u2218 f) a (\ud835\udcdd (g b)) :=\nhg.to_inducing.tendsto_nhds_iff\n\nlemma embedding.continuous_iff {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hg : embedding g) :\n  continuous f \u2194 continuous (g \u2218 f) :=\ninducing.continuous_iff hg.1\n\nlemma embedding.continuous {f : \u03b1 \u2192 \u03b2} (hf : embedding f) : continuous f :=\ninducing.continuous hf.1\n\nlemma embedding.closure_eq_preimage_closure_image {e : \u03b1 \u2192 \u03b2} (he : embedding e) (s : set \u03b1) :\n  closure s = e \u207b\u00b9' closure (e '' s) :=\nhe.1.closure_eq_preimage_closure_image s\n\n/-- The topology induced under an inclusion `f : X \u2192 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 \u2192 Y} (hf : embedding f) : discrete_topology X :=\ndiscrete_topology_iff_nhds.2 $ \u03bb x, by rw [hf.nhds_eq_comap, nhds_discrete, comap_pure,\n  \u2190 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 \u03b2`, `s` is open iff its preimage is an open set. -/\ndef quotient_map {\u03b1 : Type*} {\u03b2 : Type*} [t\u03b1 : topological_space \u03b1] [t\u03b2 : topological_space \u03b2]\n  (f : \u03b1 \u2192 \u03b2) : Prop :=\nsurjective f \u2227 t\u03b2 = t\u03b1.coinduced f\n\nlemma quotient_map_iff {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  quotient_map f \u2194 surjective f \u2227 \u2200 s : set \u03b2, is_open s \u2194 is_open (f \u207b\u00b9' s) :=\nand_congr iff.rfl topological_space_eq_iff\n\nnamespace quotient_map\n\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4]\n  {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2}\n\nprotected lemma id : quotient_map (@id \u03b1) :=\n\u27e8assume a, \u27e8a, rfl\u27e9, coinduced_id.symm\u27e9\n\nprotected lemma comp (hg : quotient_map g) (hf : quotient_map f) :\n  quotient_map (g \u2218 f) :=\n\u27e8hg.left.comp hf.left, by rw [hg.right, hf.right, coinduced_compose]\u27e9\n\nprotected lemma of_quotient_map_compose (hf : continuous f) (hg : continuous g)\n  (hgf : quotient_map (g \u2218 f)) : quotient_map g :=\n\u27e8hgf.1.of_comp,\n  le_antisymm\n    (by { rw [hgf.right, \u2190 continuous_iff_coinduced_le], apply continuous_coinduced_rng.comp hf })\n    (by rwa \u2190 continuous_iff_coinduced_le)\u27e9\n\nlemma of_inverse {g : \u03b2 \u2192 \u03b1} (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 \u25b8 quotient_map.id\n\nprotected lemma continuous_iff (hf : quotient_map f) :\n  continuous g \u2194 continuous (g \u2218 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 \u03b2} :\n  is_open (f \u207b\u00b9' s) \u2194 is_open s :=\n((quotient_map_iff.1 hf).2 s).symm\n\nprotected \n\nend quotient_map\n\n/-- A map `f : \u03b1 \u2192 \u03b2` is said to be an *open map*, if the image of any open `U : set \u03b1`\nis open in `\u03b2`. -/\ndef is_open_map [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2192 \u03b2) :=\n\u2200 U : set \u03b1, is_open U \u2192 is_open (f '' U)\n\nnamespace is_open_map\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {f : \u03b1 \u2192 \u03b2}\n\nprotected lemma id : is_open_map (@id \u03b1) := assume s hs, by rwa [image_id]\n\nprotected lemma comp\n  {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : is_open_map g) (hf : is_open_map f) : is_open_map (g \u2218 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 \u2190 image_univ, exact hf _ is_open_univ }\n\nlemma image_mem_nhds (hf : is_open_map f) {x : \u03b1} {s : set \u03b1} (hx : s \u2208 \ud835\udcdd x) :\n  f '' s \u2208 \ud835\udcdd (f x) :=\nlet \u27e8t, hts, ht, hxt\u27e9 := 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 : \u03b1) : range f \u2208 \ud835\udcdd (f x) :=\nhf.is_open_range.mem_nhds $ mem_range_self _\n\nlemma maps_to_interior (hf : is_open_map f) {s : set \u03b1} {t : set \u03b2} (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 \u03b1) :\n  f '' interior s \u2286 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 : \u03b1) : \ud835\udcdd (f a) \u2264 (\ud835\udcdd a).map f :=\nle_map $ \u03bb s, hf.image_mem_nhds\n\nlemma of_nhds_le (hf : \u2200 a, \ud835\udcdd (f a) \u2264 map f (\ud835\udcdd a)) : is_open_map f :=\n\u03bb s hs, is_open_iff_mem_nhds.2 $ \u03bb b \u27e8a, has, hab\u27e9,\n  hab \u25b8 hf _ (image_mem_map $ is_open.mem_nhds hs has)\n\nlemma of_sections {f : \u03b1 \u2192 \u03b2}\n  (h : \u2200 x, \u2203 g : \u03b2 \u2192 \u03b1, continuous_at g (f x) \u2227 g (f x) = x \u2227 right_inverse g f) :\n  is_open_map f :=\nof_nhds_le $ \u03bb x, let \u27e8g, hgc, hgx, hgf\u27e9 := h x in\ncalc \ud835\udcdd (f x) = map f (map g (\ud835\udcdd (f x))) : by rw [map_map, hgf.comp_eq_id, map_id]\n... \u2264 map f (\ud835\udcdd (g (f x))) : map_mono hgc\n... = map f (\ud835\udcdd x) : by rw hgx\n\nlemma of_inverse {f : \u03b1 \u2192 \u03b2} {f' : \u03b2 \u2192 \u03b1}\n  (h : continuous f') (l_inv : left_inverse f f') (r_inv : right_inverse f f') :\n  is_open_map f :=\nof_sections $ \u03bb x, \u27e8f', h.continuous_at, r_inv _, l_inv\u27e9\n\n/-- A continuous surjective open map is a quotient map. -/\nlemma to_quotient_map {f : \u03b1 \u2192 \u03b2}\n  (open_map : is_open_map f) (cont : continuous f) (surj : surjective f) :\n  quotient_map f :=\nquotient_map_iff.2 \u27e8surj, \u03bb s, \u27e8\u03bb h, h.preimage cont, \u03bb h, surj.image_preimage s \u25b8 open_map _ h\u27e9\u27e9\n\nlemma interior_preimage_subset_preimage_interior (hf : is_open_map f) {s : set \u03b2} :\n  interior (f\u207b\u00b9' s) \u2286 f\u207b\u00b9' (interior s) :=\nhf.maps_to_interior (maps_to_preimage _ _)\n\nlemma preimage_interior_eq_interior_preimage (hf\u2081 : is_open_map f) (hf\u2082 : continuous f)\n  (s : set \u03b2) :\n  f\u207b\u00b9' (interior s) = interior (f\u207b\u00b9' s) :=\nsubset.antisymm\n  (preimage_interior_subset_interior_preimage hf\u2082)\n  (interior_preimage_subset_preimage_interior hf\u2081)\n\nlemma preimage_closure_subset_closure_preimage (hf : is_open_map f) {s : set \u03b2} :\n  f \u207b\u00b9' (closure s) \u2286 closure (f \u207b\u00b9' s) :=\nbegin\n  rw \u2190 compl_subset_compl,\n  simp only [\u2190 interior_compl, \u2190 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 \u03b2) :\n  f \u207b\u00b9' (closure s) = closure (f \u207b\u00b9' 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 \u03b2} :\n  f \u207b\u00b9' (frontier s) \u2286 frontier (f \u207b\u00b9' 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 \u03b2) :\n  f \u207b\u00b9' (frontier s) = frontier (f \u207b\u00b9' 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 \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  is_open_map f \u2194 \u2200(a:\u03b1), \ud835\udcdd (f a) \u2264 (\ud835\udcdd a).map f :=\n\u27e8\u03bb hf, hf.nhds_le, is_open_map.of_nhds_le\u27e9\n\nlemma is_open_map_iff_interior [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  is_open_map f \u2194 \u2200 s, f '' (interior s) \u2286 interior (f '' s) :=\n\u27e8is_open_map.image_interior_subset, \u03bb hs u hu, subset_interior_iff_is_open.mp $\n  calc f '' u = f '' (interior u) : by rw hu.interior_eq\n          ... \u2286 interior (f '' u) : hs u\u27e9\n\n/-- An inducing map with an open range is an open map. -/\nprotected lemma inducing.is_open_map [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2}\n  (hi : inducing f) (ho : is_open (range f)) :\n  is_open_map f :=\nis_open_map.of_nhds_le $ \u03bb x, (hi.map_nhds_of_mem _ $ is_open.mem_nhds ho $ mem_range_self _).ge\n\nsection is_closed_map\nvariables [topological_space \u03b1] [topological_space \u03b2]\n\n/-- A map `f : \u03b1 \u2192 \u03b2` is said to be a *closed map*, if the image of any closed `U : set \u03b1`\nis closed in `\u03b2`. -/\ndef is_closed_map (f : \u03b1 \u2192 \u03b2) := \u2200 U : set \u03b1, is_closed U \u2192 is_closed (f '' U)\n\nend is_closed_map\n\nnamespace is_closed_map\n\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3]\nopen function\n\nprotected lemma id : is_closed_map (@id \u03b1) := assume s hs, by rwa image_id\n\nprotected lemma comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : is_closed_map g) (hf : is_closed_map f) :\n  is_closed_map (g \u2218 f) :=\nby { intros s hs, rw image_comp, exact hg _ (hf _ hs) }\n\nlemma closure_image_subset {f : \u03b1 \u2192 \u03b2} (hf : is_closed_map f) (s : set \u03b1) :\n  closure (f '' s) \u2286 f '' closure s :=\nclosure_minimal (image_subset _ subset_closure) (hf _ is_closed_closure)\n\nlemma of_inverse {f : \u03b1 \u2192 \u03b2} {f' : \u03b2 \u2192 \u03b1}\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' \u207b\u00b9' s = f '' s, by ext x; simp [mem_image_iff_of_inverse r_inv l_inv],\nthis \u25b8 hs.preimage h\n\nlemma of_nonempty {f : \u03b1 \u2192 \u03b2} (h : \u2200 s, is_closed s \u2192 s.nonempty \u2192 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 : \u03b1 \u2192 \u03b2} (hf : is_closed_map f) : is_closed (range f) :=\n@image_univ _ _ f \u25b8 hf _ is_closed_univ\n\nend is_closed_map\n\nlemma inducing.is_closed_map [topological_space \u03b1] [topological_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} (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 \u27e8t, ht, rfl\u27e9,\n  rw image_preimage_eq_inter_range,\n  exact ht.inter h\nend\n\nlemma is_closed_map_iff_closure_image [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  is_closed_map f \u2194 \u2200 s, closure (f '' s) \u2286 f '' closure s :=\n\u27e8is_closed_map.closure_image_subset, \u03bb hs c hc, is_closed_of_closure_subset $\n  calc closure (f '' c) \u2286 f '' (closure c) : hs c\n                    ... = f '' c : by rw hc.closure_eq\u27e9\n\nsection open_embedding\nvariables [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3]\n\n/-- An open embedding is an embedding with open image. -/\n@[mk_iff]\nstructure open_embedding (f : \u03b1 \u2192 \u03b2) extends _root_.embedding f : Prop :=\n(open_range : is_open $ range f)\n\nlemma open_embedding.is_open_map {f : \u03b1 \u2192 \u03b2} (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 : \u03b1 \u2192 \u03b2} (hf : open_embedding f) (a : \u03b1) :\n  map f (\ud835\udcdd a) = \ud835\udcdd (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 : \u03b1 \u2192 \u03b2} (hf : open_embedding f)\n  {s : set \u03b1} : is_open s \u2194 is_open (f '' s) :=\n\u27e8hf.is_open_map s,\n \u03bb h, begin\n   convert \u2190 h.preimage hf.to_embedding.continuous,\n   apply preimage_image_eq _ hf.inj\n end\u27e9\n\nlemma open_embedding.tendsto_nhds_iff {\u03b9 : Type*}\n  {f : \u03b9 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} {a : filter \u03b9} {b : \u03b2} (hg : open_embedding g) :\n  tendsto f a (\ud835\udcdd b) \u2194 tendsto (g \u2218 f) a (\ud835\udcdd (g b)) :=\nhg.to_embedding.tendsto_nhds_iff\n\nlemma open_embedding.continuous {f : \u03b1 \u2192 \u03b2} (hf : open_embedding f) : continuous f :=\nhf.to_embedding.continuous\n\nlemma open_embedding.open_iff_preimage_open {f : \u03b1 \u2192 \u03b2} (hf : open_embedding f)\n  {s : set \u03b2} (hs : s \u2286 range f) : is_open s \u2194 is_open (f \u207b\u00b9' s) :=\nbegin\n  convert \u2190hf.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 : \u03b1 \u2192 \u03b2} (h\u2081 : embedding f)\n  (h\u2082 : is_open_map f) : open_embedding f :=\n\u27e8h\u2081, h\u2082.is_open_range\u27e9\n\nlemma open_embedding_iff_embedding_open {f : \u03b1 \u2192 \u03b2} :\n  open_embedding f \u2194 embedding f \u2227 is_open_map f :=\n\u27e8\u03bb h, \u27e8h.1, h.is_open_map\u27e9, \u03bb h, open_embedding_of_embedding_open h.1 h.2\u27e9\n\nlemma open_embedding_of_continuous_injective_open {f : \u03b1 \u2192 \u03b2} (h\u2081 : continuous f)\n  (h\u2082 : injective f) (h\u2083 : 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 \u03bb a, le_antisymm (h\u2081.tendsto _).le_comap\n    (@comap_map _ _ (\ud835\udcdd a) _ h\u2082 \u25b8 comap_mono (h\u2083.nhds_le _))\nend\n\nlemma open_embedding_iff_continuous_injective_open {f : \u03b1 \u2192 \u03b2} :\n  open_embedding f \u2194 continuous f \u2227 injective f \u2227 is_open_map f :=\n\u27e8\u03bb h, \u27e8h.continuous, h.inj, h.is_open_map\u27e9,\n  \u03bb h, open_embedding_of_continuous_injective_open h.1 h.2.1 h.2.2\u27e9\n\nlemma open_embedding_id : open_embedding (@id \u03b1) :=\n\u27e8embedding_id, is_open_map.id.is_open_range\u27e9\n\nlemma open_embedding.comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2}\n  (hg : open_embedding g) (hf : open_embedding f) : open_embedding (g \u2218 f) :=\n\u27e8hg.1.comp hf.1, (hg.is_open_map.comp hf.is_open_map).is_open_range\u27e9\n\nlemma open_embedding.is_open_map_iff {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : open_embedding g) :\n  is_open_map f \u2194 is_open_map (g \u2218 f) :=\nby simp only [is_open_map_iff_nhds_le, \u2190 @map_map _ _ _ _ f g, \u2190 hg.map_nhds_eq,\n  map_le_map_iff hg.inj]\n\nlemma open_embedding.of_comp_iff (f : \u03b1 \u2192 \u03b2) {g : \u03b2 \u2192 \u03b3} (hg : open_embedding g) :\n  open_embedding (g \u2218 f) \u2194 open_embedding f :=\nby simp only [open_embedding_iff_continuous_injective_open, \u2190 hg.is_open_map_iff,\n  \u2190 hg.1.continuous_iff, hg.inj.of_comp_iff]\n\nlemma open_embedding.of_comp (f : \u03b1 \u2192 \u03b2) {g : \u03b2 \u2192 \u03b3} (hg : open_embedding g)\n  (h : open_embedding (g \u2218 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 \u03b1] [topological_space \u03b2] [topological_space \u03b3]\n\n/-- A closed embedding is an embedding with closed image. -/\n@[mk_iff]\nstructure closed_embedding (f : \u03b1 \u2192 \u03b2) extends _root_.embedding f : Prop :=\n(closed_range : is_closed $ range f)\n\nvariables {f : \u03b1 \u2192 \u03b2}\n\nlemma closed_embedding.tendsto_nhds_iff {\u03b9 : Type*}\n  {g : \u03b9 \u2192 \u03b1} {a : filter \u03b9} {b : \u03b1} (hf : closed_embedding f) :\n  tendsto g a (\ud835\udcdd b) \u2194 tendsto (f \u2218 g) a (\ud835\udcdd (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 \u03b1} : is_closed s \u2194 is_closed (f '' s) :=\n\u27e8hf.is_closed_map s,\n \u03bb h, begin\n   convert \u2190continuous_iff_is_closed.mp hf.continuous _ h,\n   apply preimage_image_eq _ hf.inj\n end\u27e9\n\nlemma closed_embedding.closed_iff_preimage_closed (hf : closed_embedding f)\n  {s : set \u03b2} (hs : s \u2286 range f) : is_closed s \u2194 is_closed (f \u207b\u00b9' s) :=\nbegin\n  convert \u2190hf.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\u2081 : embedding f)\n  (h\u2082 : is_closed_map f) : closed_embedding f :=\n\u27e8h\u2081, by convert h\u2082 univ is_closed_univ; simp\u27e9\n\nlemma closed_embedding_of_continuous_injective_closed (h\u2081 : continuous f)\n  (h\u2082 : injective f) (h\u2083 : is_closed_map f) : closed_embedding f :=\nbegin\n  refine closed_embedding_of_embedding_closed \u27e8\u27e8_\u27e9, h\u2082\u27e9 h\u2083,\n  apply le_antisymm (continuous_iff_le_induced.mp h\u2081) _,\n  intro s',\n  change is_open _ \u2264 is_open _,\n  rw [\u2190is_closed_compl_iff, \u2190is_closed_compl_iff],\n  generalize : s'\u1d9c = s,\n  rw is_closed_induced_iff,\n  refine \u03bb hs, \u27e8f '' s, h\u2083 s hs, _\u27e9,\n  rw preimage_image_eq _ h\u2082\nend\n\nlemma closed_embedding_id : closed_embedding (@id \u03b1) :=\n\u27e8embedding_id, by convert is_closed_univ; apply range_id\u27e9\n\nlemma closed_embedding.comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2}\n  (hg : closed_embedding g) (hf : closed_embedding f) : closed_embedding (g \u2218 f) :=\n\u27e8hg.to_embedding.comp hf.to_embedding, show is_closed (range (g \u2218 f)),\n by rw [range_comp, \u2190hg.closed_iff_image_closed]; exact hf.closed_range\u27e9\n\nlemma closed_embedding.closure_image_eq {f : \u03b1 \u2192 \u03b2} (hf : closed_embedding f) (s : set \u03b1) :\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 \u2192* (V \u2192\u2097[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 \u2192* (V \u2192\u2097[k] V)`.\n-/\nabbrev Representation :=\n  G \u2192* V \u2192\u2097[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 (\u03c1 : 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 \u2192\u2090[k] Module.End k V :=\n  (lift k G _) \u03c1\n#align representation.as_algebra_hom Representation.asAlgebraHom\n\ntheorem asAlgebraHom_def : asAlgebraHom \u03c1 = (lift k G _) \u03c1 :=\n  rfl\n#align representation.as_algebra_hom_def Representation.asAlgebraHom_def\n\n@[simp]\ntheorem asAlgebraHom_single (g : G) (r : k) : asAlgebraHom \u03c1 (Finsupp.single g r) = r \u2022 \u03c1 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 \u03c1 (Finsupp.single g 1) = \u03c1 g := by simp\n#align representation.as_algebra_hom_single_one Representation.asAlgebraHom_single_one\n\ntheorem asAlgebraHom_of (g : G) : asAlgebraHom \u03c1 (of k G g) = \u03c1 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 `\u03c1 : representation k G V`, then `\u03c1.as_module` is a type synonym for `V`,\nwhich we equip with an instance `module (monoid_algebra k G) \u03c1.as_module`.\n\nYou should use `as_module_equiv : \u03c1.as_module \u2243+ V` to translate terms.\n-/\n@[nolint unused_arguments]\ndef AsModule (\u03c1 : Representation k G V) :=\n  V deriving AddCommMonoid,\n  \u00ab./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler module[module] (module.End[module.End] k V)\u00bb\n#align representation.as_module Representation.AsModule\n\ninstance : Inhabited \u03c1.AsModule :=\n  \u27e80\u27e9\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) \u03c1.AsModule :=\n  Module.compHom V (asAlgebraHom \u03c1).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 : \u03c1.AsModule \u2243+ V :=\n  AddEquiv.refl _\n#align representation.as_module_equiv Representation.asModuleEquiv\n\n@[simp]\ntheorem asModuleEquiv_map_smul (r : MonoidAlgebra k G) (x : \u03c1.AsModule) :\n    \u03c1.asModuleEquiv (r \u2022 x) = \u03c1.asAlgebraHom r (\u03c1.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    \u03c1.asModuleEquiv.symm (r \u2022 x) = algebraMap k (MonoidAlgebra k G) r \u2022 \u03c1.asModuleEquiv.symm x :=\n  by\n  apply_fun \u03c1.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    \u03c1.asModuleEquiv.symm (\u03c1 g x) = MonoidAlgebra.of k G g \u2022 \u03c1.asModuleEquiv.symm x :=\n  by\n  apply_fun \u03c1.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 \u2192\u2097[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 \u2192\u2097[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 `\u03c1 : representation k G V`, converting to a module and back again\nwe have a `representation k G (restrict_scalars k (monoid_algebra k G) \u03c1.as_module)`.\nTo compare these, we use the composition of `restrict_scalars_add_equiv` and `\u03c1.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 \u2022 RestrictScalars.addEquiv _ _ _ m) :=\n  by\n  apply MonoidAlgebra.induction_on r\n  \u00b7 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  \u00b7 intro f g fw gw\n    simp only [fw, gw, map_add, add_smul, LinearMap.add_apply]\n  \u00b7 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) \u03c1.AsModule) :\n    ofModule k G \u03c1.AsModule g x =\n      (RestrictScalars.addEquiv _ _ _).symm\n        (\u03c1.asModuleEquiv.symm (\u03c1 g (\u03c1.asModuleEquiv (RestrictScalars.addEquiv _ _ _ x)))) :=\n  by\n  apply_fun RestrictScalars.addEquiv _ _ \u03c1.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 \u2022 m)) =\n      r \u2022 (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 (\u03c1 : Representation k G V)\n\ninstance : AddCommGroup \u03c1.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 \u2192* End(k[H])` in the natural way. -/\nnoncomputable def ofMulAction : Representation k G (H \u2192\u2080 k)\n    where\n  toFun g := Finsupp.lmapDomain k k ((\u00b7 \u2022 \u00b7) 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 ((\u00b7 \u2022 \u00b7) 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 \u2022 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 (\u03c1 : Representation k G V)\n\n@[simp]\ntheorem ofMulAction_apply {H : Type _} [MulAction G H] (g : G) (f : H \u2192\u2080 k) (h : H) :\n    ofMulAction k G H g f h = f (g\u207b\u00b9 \u2022 h) :=\n  by\n  conv_lhs => rw [\u2190 smul_inv_smul g h]\n  let h' := g\u207b\u00b9 \u2022 h\n  change of_mul_action k G H g f (g \u2022 h') = f h'\n  have hg : Function.Injective ((\u00b7 \u2022 \u00b7) g : H \u2192 H) :=\n    by\n    intro h\u2081 h\u2082\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 \u2022 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 [\u2190 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 \u2243\u2097[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 \u2192* Units (V \u2192\u2097[k] V) :=\n  MonoidHom.toHomUnits \u03c1\n#align representation.as_group_hom Representation.asGroupHom\n\ntheorem asGroupHom_apply (g : G) : \u2191(asGroupHom \u03c1 g) = \u03c1 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 (\u03c1V : Representation k G V) (\u03c1W : 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 \u2297[k] W`.\n-/\ndef tprod : Representation k G (V \u2297[k] W)\n    where\n  toFun g := TensorProduct.map (\u03c1V g) (\u03c1W 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: \u00abexpr \u2297 \u00bb\nlocal notation \u03c1V \" \u2297 \" \u03c1W => tprod \u03c1V \u03c1W\n\n@[simp]\ntheorem tprod_apply (g : G) : (\u03c1V \u2297 \u03c1W) g = TensorProduct.map (\u03c1V g) (\u03c1W 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 \u2022 x \u2297\u209c y : (\u03c1V.tprod 1).AsModule) = (r \u2022 x : \u03c1V.AsModule) \u2297\u209c y :=\n  by\n  show as_algebra_hom _ _ _ = as_algebra_hom _ _ _ \u2297\u209c _\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 \u2022 x \u2297\u209c y : ((1 : Representation k G V).tprod \u03c1W).AsModule) = x \u2297\u209c (r \u2022 y : \u03c1W.AsModule) :=\n  by\n  show as_algebra_hom _ _ _ = _ \u2297\u209c 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 (\u03c1V : Representation k G V) (\u03c1W : 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 \u2192\u2097[k] W`, where `G` acts by conjugation.\n-/\ndef linHom : Representation k G (V \u2192\u2097[k] W)\n    where\n  toFun g :=\n    { toFun := fun f => \u03c1W g \u2218\u2097 f \u2218\u2097 \u03c1V g\u207b\u00b9\n      map_add' := fun f\u2081 f\u2082 => 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 \u2192\u2097[k] W) : (linHom \u03c1V \u03c1W) g f = \u03c1W g \u2218\u2097 f \u2218\u2097 \u03c1V g\u207b\u00b9 :=\n  rfl\n#align representation.lin_hom_apply Representation.linHom_apply\n\n/-- The dual of a representation `\u03c1` of `G` on a module `V`, given by `(dual \u03c1) g f = f \u2218\u2097 (\u03c1 g\u207b\u00b9)`,\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 \u2218\u2097 \u03c1V g\u207b\u00b9\n      map_add' := fun f\u2081 f\u2082 => 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 \u03c1V) g = Module.Dual.transpose (\u03c1V g\u207b\u00b9) :=\n  rfl\n#align representation.dual_apply Representation.dual_apply\n\n/-- Given $k$-modules $V, W$, there is a homomorphism $\u03c6 : V^* \u2297 W \u2192 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^* \u2297 W$ and on\n$Hom_k(V, W)$.\nThis lemma says that $\u03c6$ is $G$-linear.\n-/\ntheorem dualTensorHom_comm (g : G) :\n    dualTensorHom k V W \u2218\u2097 TensorProduct.map (\u03c1V.dual g) (\u03c1W g) =\n      (linHom \u03c1V \u03c1W) g \u2218\u2097 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 : \u2115 \u2192 \u2115 := \u03bb x, x + x\ndef square : \u2115 \u2192 \u2115 := \u03bb x, x * x\ndef do_twice : (\u2115 \u2192 \u2115) \u2192 (\u2115 \u2192 \u2115) := \u03bb f x, f (f x)\ndef Do_Twice : ((\u2115 \u2192 \u2115) \u2192 (\u2115 \u2192 \u2115)) \u2192 (\u2115 \u2192 \u2115) \u2192 (\u2115 \u2192 \u2115) := \u03bb f g, (f (f g))\n#reduce Do_Twice do_twice double 2\n\ndef curry {\u03b1 \u03b2 \u03b3 : Type*} (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) : \u03b1 \u2192 \u03b2 \u2192 \u03b3 := \u03bb a b, f (a, b)\ndef uncurry {\u03b1 \u03b2 \u03b3 : Type*} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u03b1 \u00d7 \u03b2 \u2192 \u03b3 := \u03bb \u27e8a, b\u27e9, f a b\n\n-- \"Vector\" type former & related dependent functions\nuniverse u\nconstant vec : Type u \u2192 \u2115 \u2192 Type u\n\nnamespace vec\n  constant empty : \u03a0 (\u03b1 : Type u), vec \u03b1 0\n  constant cons : \u03a0 {\u03b1 : Type u} {n : \u2115}, \u03b1 \u2192 vec \u03b1 n \u2192 vec \u03b1 (n + 1)\n  constant append : \u03a0 {\u03b1 : Type u} {n m : \u2115}, vec \u03b1 m \u2192 vec \u03b1 n \u2192 vec \u03b1 (n + m)\n  constant add : \u03a0 {\u03b1 : Type u} {n : \u2115}, vec \u03b1 n \u2192 vec \u03b1 n \u2192 vec \u03b1 n\n  constant reverse : \u03a0 {\u03b1 : Type u} {n : \u2115}, vec \u03b1 n \u2192 vec \u03b1 n\nend vec\n\n#check vec.empty \u2115\nnoncomputable def v0 := vec.empty \u2115 -- TODO: what is `noncomputable`?\n#check v0\nnoncomputable def v1 := vec.cons 0 v0\n#check v1\nvariable v3 : vec \u2115 3\n#check vec.add v3 v3\n#check vec.reverse v3\n\n-- \"Matrix\" type former & related dependent functions\nconstant matrix : Type u \u2192 \u2115 \u2192 \u2115 \u2192 Type u\n\nnamespace matrix\n  constant add : \u03a0 {\u03b1 : Type u} {n m : \u2115}, matrix \u03b1 m n \u2192 matrix \u03b1 m n \u2192 matrix \u03b1 m n\n  constant mul : \u03a0 {\u03b1 : Type u} {n m k : \u2115}, matrix \u03b1 m k \u2192 matrix \u03b1 k n \u2192 matrix \u03b1 m n\n  constant mulvec : \u03a0 {\u03b1 : Type u} {n m : \u2115}, matrix \u03b1 m n \u2192 vec \u03b1 n \u2192 vec \u03b1 m\nend matrix\n\n#check matrix \u2115 5 3\nvariable m : matrix \u2115 5 3\nvariable m' : matrix \u2115 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 \u2227 and \u2228\nexample : p \u2227 q \u2194 q \u2227 p :=\n  iff.intro\n    (\u03bb \u27e8hp, hq\u27e9, \u27e8hq, hp\u27e9)\n    (\u03bb \u27e8hq, hp\u27e9, \u27e8hp, hq\u27e9)\nexample : p \u2228 q \u2194 q \u2228 p :=\n  iff.intro\n    (\u03bb h, or.elim h (\u03bb hp, or.inr hp) (\u03bb hq, or.inl hq))\n    (\u03bb h, or.elim h (\u03bb hq, or.inr hq) (\u03bb hp, or.inl hp))\n\n-- Associativity of \u2227 and \u2228\nexample : (p \u2227 q) \u2227 r \u2194 p \u2227 (q \u2227 r) :=\n  iff.intro\n    (\u03bb \u27e8\u27e8hp, hq\u27e9, hr\u27e9, \u27e8hp, \u27e8hq, hr\u27e9\u27e9)\n    (\u03bb \u27e8hp, \u27e8hq, hr\u27e9\u27e9, \u27e8\u27e8hp, hq\u27e9, hr\u27e9)\nexample : (p \u2228 q) \u2228 r \u2194 p \u2228 (q \u2228 r) :=\n  iff.intro\n    (\u03bb h, h.elim\n      (\u03bb hpq, hpq.elim or.inl (or.inr \u2218 or.inl))\n      (or.inr \u2218 or.inr))\n    (\u03bb h, h.elim\n      (or.inl \u2218 or.inl)\n      (\u03bb hqr, hqr.elim (or.inl \u2218 or.inr) or.inr))\n\n-- Distributivity\nexample : p \u2227 (q \u2228 r) \u2194 (p \u2227 q) \u2228 (p \u2227 r) :=\n  iff.intro\n    (\u03bb \u27e8hp, hqr\u27e9, hqr.elim (\u03bb hq, or.inl \u27e8hp, hq\u27e9) (\u03bb hr, or.inr \u27e8hp, hr\u27e9))\n    (\u03bb h, h.elim (\u03bb \u27e8hp, hq\u27e9, \u27e8hp, or.inl hq\u27e9) (\u03bb \u27e8hp, hr\u27e9, \u27e8hp, or.inr hr\u27e9))\nexample : p \u2228 (q \u2227 r) \u2194 (p \u2228 q) \u2227 (p \u2228 r) :=\n  iff.intro\n    (\u03bb h, h.elim (\u03bb hp, \u27e8or.inl hp, or.inl hp\u27e9) (\u03bb \u27e8hq, hr\u27e9, \u27e8or.inr hq, or.inr hr\u27e9))\n    (\u03bb \u27e8hpq, hpr\u27e9, hpq.elim or.inl (\u03bb hq, hpr.elim or.inl (\u03bb hr, or.inr \u27e8hq, hr\u27e9)))\n\n-- Other properties\nexample : (p \u2192 (q \u2192 r)) \u2194 (p \u2227 q \u2192 r) :=\n  iff.intro\n    (\u03bb f \u27e8hp, hq\u27e9, f hp hq)\n    (\u03bb f hp hq, f \u27e8hp, hq\u27e9)\nexample : ((p \u2228 q) \u2192 r) \u2194 (p \u2192 r) \u2227 (q \u2192 r) :=\n  iff.intro\n    (\u03bb h, \u27e8h \u2218 or.inl, h \u2218 or.inr\u27e9)\n    (\u03bb \u27e8hpr, hqr\u27e9 hpq, hpq.elim hpr hqr)\nexample : \u00ac(p \u2228 q) \u2194 \u00acp \u2227 \u00acq := \n  iff.intro\n    (\u03bb h, \u27e8h \u2218 or.inl, h \u2218 or.inr\u27e9)\n    (\u03bb \u27e8hnp, hnq\u27e9, (\u03bb h, h.elim hnp hnq))\nexample : \u00acp \u2228 \u00acq \u2192 \u00ac(p \u2227 q) :=\n  (\u03bb h \u27e8hp, hq\u27e9, h.elim (\u03bb hnp, hnp hp) (\u03bb hnq, hnq hq))\nexample : \u00ac(p \u2227 \u00acp) := (\u03bb \u27e8hp, hnp\u27e9, hnp hp)\nexample : p \u2227 \u00acq \u2192 \u00ac(p \u2192 q) := (\u03bb \u27e8hp, hnq\u27e9 hpq, hnq (hpq hp))\nexample : \u00acp \u2192 (p \u2192 q) := (\u03bb hnp hp, (hnp hp).elim)\nexample : (\u00acp \u2228 q) \u2192 (p \u2192 q) := (\u03bb h, h.elim (\u03bb hnp hp, (hnp hp).elim) (\u03bb hq _, hq))\nexample : p \u2228 false \u2194 p := iff.intro (\u03bb h, h.elim id false.elim) or.inl\nexample : p \u2227 false \u2194 false := iff.intro and.right false.elim\nexample : (p \u2192 q) \u2192 (\u00acq \u2192 \u00acp) := (\u03bb 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 \u2192 r \u2228 s) \u2192 ((p \u2192 r) \u2228 (p \u2192 s)) :=\n  (\u03bb h, (em p).elim\n    (\u03bb hp, (h hp).elim (\u03bb hr, or.inl (\u03bb _, hr)) (\u03bb hs, or.inr (\u03bb _, hs)))\n    (\u03bb hnp, or.inl (\u03bb hp, (hnp hp).elim)))\nexample : \u00ac(p \u2227 q) \u2192 \u00acp \u2228 \u00acq :=\n  (\u03bb h, (em p).elim\n    (\u03bb hp, or.inr (\u03bb hq, h \u27e8hp, hq\u27e9))\n    or.inl)\nexample : \u00ac(p \u2192 q) \u2192 p \u2227 \u00acq :=\n  (\u03bb h, and.intro\n    ((em q).elim\n      (\u03bb hq, (h (\u03bb _, hq)).elim)\n      (\u03bb hnq, (em p).elim id (\u03bb hnp, (h (\u03bb hp, (hnp hp).elim)).elim)))\n    (\u03bb hq, h (\u03bb _, hq)))\nexample : (p \u2192 q) \u2192 (\u00acp \u2228 q) :=\n  (\u03bb hpq, (em p).elim (or.inr \u2218 hpq) or.inl)\nexample : (\u00acq \u2192 \u00acp) \u2192 (p \u2192 q) :=\n  (\u03bb h, (em q).elim (\u03bb hq _, hq) (\u03bb hnq hp, (h hnq hp).elim))\nexample : p \u2228 \u00acp := em p\nexample : (((p \u2192 q) \u2192 p) \u2192 p) :=\n  (em p).elim\n    (\u03bb hp _, hp)\n    (\u03bb hnp, (em q).elim\n      (\u03bb hq h, h (\u03bb _, hq))\n      (\u03bb hnq h, h (\u03bb hp, (hnp hp).elim)))\n\n-- Prove \u00ac(p \u2194 \u00acp) without using classical logic.\nexample : \u00ac(p \u2194 \u00acp) :=\n  (\u03bb \u27e8h\u2081, h\u2082\u27e9,\n    (\u03bb hp, h\u2081 hp hp) -- \"Don't eliminate cuts!\" (will make the proof longer)\n      (h\u2082 (\u03bb hp, h\u2081 hp hp)))\n\nend exercise_3_2\n\n\n-- ### Exercise 4\n\nnamespace exercise_4\n\nsection\n  variables (\u03b1 : Type*) (p q : \u03b1 \u2192 Prop)\n\n  example : (\u2200 x, p x \u2227 q x) \u2194 (\u2200 x, p x) \u2227 (\u2200 x, q x) :=\n    iff.intro\n      (\u03bb h, \u27e8(\u03bb x, (h x).left), (\u03bb x, (h x).right)\u27e9)\n      (\u03bb \u27e8h\u2081, h\u2082\u27e9 x, \u27e8h\u2081 x, h\u2082 x\u27e9)\n  example : (\u2200 x, p x \u2192 q x) \u2192 (\u2200 x, p x) \u2192 (\u2200 x, q x) :=\n    \u03bb h\u2081 h\u2082 x, h\u2081 x (h\u2082 x)\n  example : (\u2200 x, p x) \u2228 (\u2200 x, q x) \u2192 \u2200 x, p x \u2228 q x :=\n    \u03bb h x, h.elim (\u03bb h\u2081, or.inl (h\u2081 x)) (\u03bb h\u2081, or.inr (h\u2081 x))\nend\n\nsection\n  variables (\u03b1 : Type*) (p q : \u03b1 \u2192 Prop)\n  variable r : Prop\n\n  -- One direction of the second of these requires classical logic\n  example : \u03b1 \u2192 ((\u2200 x : \u03b1, r) \u2194 r) :=\n    \u03bb x, (iff.intro (\u03bb h, h x) (\u03bb h _, h))\n  example : (\u2200 x, p x \u2228 r) \u2194 (\u2200 x, p x) \u2228 r :=\n    iff.intro\n      (\u03bb h, (classical.em r).elim (or.inr) (\u03bb hnr, or.inl (\u03bb x, (h x).elim id (\u03bb hr, (hnr hr).elim))))\n      (\u03bb h, h.elim (\u03bb h\u2081 x, or.inl (h\u2081 x)) (\u03bb h\u2082 x, or.inr h\u2082))\n  example : (\u2200 x, r \u2192 p x) \u2194 (r \u2192 \u2200 x, p x) :=\n    iff.intro\n      (\u03bb h hr x, h x hr)\n      (\u03bb h x hr, h hr x)\nend\n\nsection\n  variables (men : Type*) (barber : men)\n  variable  (shaves : men \u2192 men \u2192 Prop)\n\n  example (h : \u2200 x : men, shaves barber x \u2194 \u00ac shaves x x) : false :=\n    (h barber).elim\n      (\u03bb (h\u2081 : shaves barber barber \u2192 \u00acshaves barber barber) h\u2082,\n        (\u03bb hs, h\u2081 hs hs) (h\u2082 (\u03bb hs, h\u2081 hs hs)))\nend\n\n-- See: https://discord.com/channels/679792285910827018/707609591940382830/733322519112712362\nsection\n  def prime (n : \u2115) : Prop :=\n    \u2200 (x : \u2115), (\u2203 y, n = x * y) \u2192 x = 1 \u2228 x = n\n\n  def infinitely_many_primes : Prop :=\n    \u2200 (x : \u2115), prime x \u2192 (\u2203 y, prime y \u2227 x < y)\n\n  def Fermat_prime (n : \u2115) : Prop :=\n    prime n \u2227 \u2203 (x : \u2115), n = 2 ^ (2 ^ x) + 1\n\n  def infinitely_many_Fermat_primes : Prop :=\n    \u2200 (x : \u2115), Fermat_prime x \u2192 (\u2203 y, Fermat_prime y \u2227 x < y)\n\n  def goldbach_conjecture : Prop :=\n    \u2200 (n : \u2115), even n \u2192 (2 < n) \u2192 (\u2203 p\u2081 p\u2082, prime p\u2081 \u2227 prime p\u2082 \u2227 n = p\u2081 + p\u2082)\n\n  def Goldbach's_weak_conjecture : Prop :=\n    \u2200 (n : \u2115), odd n \u2192 (5 < n) \u2192 (\u2203 p\u2081 p\u2082 p\u2083, prime p\u2081 \u2227 prime p\u2082 \u2227 prime p\u2083 \u2227 n = p\u2081 + p\u2082 + p\u2083)\n\n  def Fermat's_last_theorem : Prop :=\n    \u2200 (n : \u2115), (2 < n) \u2192 \u2200 (a b c : \u2115), 0 < a \u2192 0 < b \u2192 a ^ n + b ^ n \u2260 c ^ n\nend\n\nsection\n  variables (\u03b1 : Type*) (p q : \u03b1 \u2192 Prop)\n  variable r : Prop\n\n  example : (\u2203 x : \u03b1, r) \u2192 r :=\n    \u03bb \u27e8x, hx\u27e9, hx\n  example (a : \u03b1) : r \u2192 (\u2203 x : \u03b1, r) :=\n    \u03bb h, \u27e8a, h\u27e9\n  example : (\u2203 x, p x \u2227 r) \u2194 (\u2203 x, p x) \u2227 r :=\n    iff.intro\n      (\u03bb \u27e8x, hx, hr\u27e9, \u27e8\u27e8x, hx\u27e9, hr\u27e9)\n      (\u03bb \u27e8\u27e8x, hx\u27e9, hr\u27e9, \u27e8x, \u27e8hx, hr\u27e9\u27e9)\n  example : (\u2203 x, p x \u2228 q x) \u2194 (\u2203 x, p x) \u2228 (\u2203 x, q x) :=\n    iff.intro\n      (\u03bb \u27e8x, hx\u27e9, hx.elim (\u03bb hpx, or.inl \u27e8x, hpx\u27e9) (\u03bb hqx, or.inr \u27e8x, hqx\u27e9))\n      (\u03bb h, h.elim (\u03bb \u27e8x, hx\u27e9, \u27e8x, or.inl hx\u27e9) (\u03bb \u27e8x, hx\u27e9, \u27e8x, or.inr hx\u27e9))\n\n  example : (\u2200 x, p x) \u2194 \u00ac (\u2203 x, \u00ac p x) :=\n    iff.intro\n      (\u03bb h \u27e8x, hx\u27e9, hx (h x))\n      (\u03bb h x, by_contra (\u03bb hx, h \u27e8x, hx\u27e9))\n  example : (\u2203 x, p x) \u2194 \u00ac (\u2200 x, \u00ac p x) :=\n    iff.intro\n      (\u03bb \u27e8x, hx\u27e9 h, h x hx)\n      (\u03bb h, by_contra (\u03bb h\u2081, h (\u03bb x hx, h\u2081 \u27e8x, hx\u27e9)))\n  example : (\u00ac \u2203 x, p x) \u2194 (\u2200 x, \u00ac p x) :=\n    iff.intro\n      (\u03bb h x hx, h \u27e8x, hx\u27e9)\n      (\u03bb h \u27e8x, hx\u27e9, h x hx)\n  example : (\u00ac \u2200 x, p x) \u2194 (\u2203 x, \u00ac p x) :=\n    iff.intro\n      (\u03bb h, by_contra (\u03bb h\u2081, h (\u03bb x, by_contra (\u03bb hx, h\u2081 \u27e8x, hx\u27e9))))\n      (\u03bb \u27e8x, hx\u27e9 h, hx (h x))\n\n  example : (\u2200 x, p x \u2192 r) \u2194 (\u2203 x, p x) \u2192 r :=\n    iff.intro\n      (\u03bb h \u27e8x, hx\u27e9, h x hx)\n      (\u03bb h x hx, h \u27e8x, hx\u27e9)\n  example (a : \u03b1) : (\u2203 x, p x \u2192 r) \u2194 (\u2200 x, p x) \u2192 r :=\n    iff.intro\n      (\u03bb \u27e8x, hx\u27e9 h, hx (h x))\n      (\u03bb h, (em (\u2200 x, p x)).elim\n        (\u03bb h\u2081, \u27e8a, \u03bb _, h h\u2081\u27e9)\n        (\u03bb h\u2081,\n          have h\u2082 : (\u2203 (x : \u03b1), \u00ac(p x)),\n          from by_contra\n            (\u03bb h\u2082, h\u2081 (\u03bb x, by_contra\n              (\u03bb h\u2083, h\u2082 \u27e8x, h\u2083\u27e9))),\n          let \u27e8w, hw\u27e9 := h\u2082 in\n            \u27e8w, (\u03bb hw\u2081, (hw hw\u2081).elim)\u27e9))\n  example (a : \u03b1) : (\u2203 x, r \u2192 p x) \u2194 (r \u2192 \u2203 x, p x) :=\n    iff.intro\n      (\u03bb \u27e8x, hx\u27e9 h, \u27e8x, hx h\u27e9)\n      (\u03bb h, (em r).elim\n        (\u03bb hr, exists.elim (h hr) (\u03bb a ha, \u27e8a, (\u03bb _, ha)\u27e9))\n        (\u03bb hnr, \u27e8a, (\u03bb hr, (hnr hr).elim)\u27e9))\nend\n\nsection\n  variables log exp    : \u211d \u2192 \u211d\n  variable  log_exp_eq : \u2200 x, log (exp x) = x\n  variable  exp_log_eq : \u2200 {x}, x > 0 \u2192 exp (log x) = x\n  variable  exp_pos    : \u2200 x, exp x > 0\n  variable  exp_add    : \u2200 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 : \u211d) : 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 : \u2124) : 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 \u2227 and \u2228\nexample : p \u2227 q \u2194 q \u2227 p :=\nbegin\n  split,\n  { intros h, exact let \u27e8hp, hq\u27e9 := h in \u27e8hq, hp\u27e9, },\n  { intros h, exact let \u27e8hq, hp\u27e9 := h in \u27e8hp, hq\u27e9, },\nend\nexample : p \u2228 q \u2194 q \u2228 p :=\nbegin\n  apply iff.intro,\n  { exact (\u03bb h, h.elim or.inr or.inl), },\n  { exact (\u03bb h, h.elim or.inr or.inl), },\nend\n\n-- Associativity of \u2227 and \u2228\nexample : (p \u2227 q) \u2227 r \u2194 p \u2227 (q \u2227 r) := by {\n  split,\n  { rintros \u27e8\u27e8hp, hq\u27e9, hr\u27e9, exact \u27e8hp, hq, hr\u27e9, },\n  { rintros \u27e8hp, hq, hr\u27e9, exact \u27e8\u27e8hp, hq\u27e9, hr\u27e9, },\n}\nexample : (p \u2228 q) \u2228 r \u2194 p \u2228 (q \u2228 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 \u2227 (q \u2228 r) \u2194 (p \u2227 q) \u2228 (p \u2227 r) := by {\n  split,\n  { rintros \u27e8hp, hq | hr\u27e9,\n      left, exact \u27e8hp, hq\u27e9,\n      right, exact \u27e8hp, hr\u27e9, },\n  { rintros (\u27e8hp, hq\u27e9 | \u27e8hp, hr\u27e9),\n      exact \u27e8hp, or.inl hq\u27e9,\n      exact \u27e8hp, or.inr hr\u27e9, },\n}\nexample : p \u2228 (q \u2227 r) \u2194 (p \u2228 q) \u2227 (p \u2228 r) := by {\n  split,\n  { rintros (hp | \u27e8hq, hr\u27e9),\n      exacts [\u27e8or.inl hp, or.inl hp\u27e9, \u27e8or.inr hq, or.inr hr\u27e9], },\n  { rintros \u27e8hp | hq, hp | hr\u27e9,\n      exacts [or.inl hp, or.inl hp, or.inl hp, or.inr \u27e8hq, hr\u27e9], },\n}\n\n-- Other properties\nexample : (p \u2192 (q \u2192 r)) \u2194 (p \u2227 q \u2192 r) := by {\n  split,\n  { rintros f \u27e8hp, hq\u27e9, exact f hp hq, },\n  { rintros f hp hq, exact f \u27e8hp, hq\u27e9, },\n}\nexample : ((p \u2228 q) \u2192 r) \u2194 (p \u2192 r) \u2227 (q \u2192 r) := by {\n  split,\n  { intros f, split, exacts [f \u2218 or.inl, f \u2218 or.inr], },\n  { rintros \u27e8f, g\u27e9 (hp | hq), exacts [f hp, g hq], },\n}\nexample : \u00ac(p \u2228 q) \u2194 \u00acp \u2227 \u00acq := by sorry -- More examples to experiment on later\nexample : \u00acp \u2228 \u00acq \u2192 \u00ac(p \u2227 q) := by sorry\nexample : \u00ac(p \u2227 \u00acp) := by sorry\nexample : p \u2227 \u00acq \u2192 \u00ac(p \u2192 q) := by sorry\nexample : \u00acp \u2192 (p \u2192 q) := by sorry\nexample : (\u00acp \u2228 q) \u2192 (p \u2192 q) := by sorry\nexample : p \u2228 false \u2194 p := by sorry\nexample : p \u2227 false \u2194 false := by sorry\nexample : (p \u2192 q) \u2192 (\u00acq \u2192 \u00acp) := 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 \u2192 r \u2228 s) \u2192 ((p \u2192 r) \u2228 (p \u2192 s)) := by sorry\nexample : \u00ac(p \u2227 q) \u2192 \u00acp \u2228 \u00acq := by sorry\nexample : \u00ac(p \u2192 q) \u2192 p \u2227 \u00acq := by sorry\nexample : (p \u2192 q) \u2192 (\u00acp \u2228 q) := by sorry\nexample : (\u00acq \u2192 \u00acp) \u2192 (p \u2192 q) := by sorry\nexample : p \u2228 \u00acp := by sorry\nexample : (((p \u2192 q) \u2192 p) \u2192 p) := by sorry\n\n-- Prove \u00ac(p \u2194 \u00acp) without using classical logic.\nexample : \u00ac(p \u2194 \u00acp) := by {\n  rintros \u27e8h\u2081, h\u2082\u27e9,\n  apply h\u2081,\n  { apply h\u2082, intros hp, exact h\u2081 hp hp, },\n  { apply h\u2082, intros hp, exact h\u2081 hp hp, },\n}\n\nend exercise_5_2\nnamespace exercise_5_3\n\nsection\n  variables (\u03b1 : Type*) (p q : \u03b1 \u2192 Prop)\n\n  example : (\u2200 x, p x \u2227 q x) \u2194 (\u2200 x, p x) \u2227 (\u2200 x, q x) := by sorry -- More examples to experiment on later\n  example : (\u2200 x, p x \u2192 q x) \u2192 (\u2200 x, p x) \u2192 (\u2200 x, q x) := by sorry\n  example : (\u2200 x, p x) \u2228 (\u2200 x, q x) \u2192 \u2200 x, p x \u2228 q x := by sorry\nend\n\nsection\n  variables (\u03b1 : Type*) (p q : \u03b1 \u2192 Prop)\n  variable r : Prop\n\n  -- One direction of the second of these requires classical logic\n  example : \u03b1 \u2192 ((\u2200 x : \u03b1, r) \u2194 r) := by sorry\n  example : (\u2200 x, p x \u2228 r) \u2194 (\u2200 x, p x) \u2228 r := by sorry\n  example : (\u2200 x, r \u2192 p x) \u2194 (r \u2192 \u2200 x, p x) := by sorry\nend\n\nsection\n  variables (\u03b1 : Type*) (p q : \u03b1 \u2192 Prop)\n  variable r : Prop\n\n  example : (\u2203 x : \u03b1, r) \u2192 r := by sorry\n  example (a : \u03b1) : r \u2192 (\u2203 x : \u03b1, r) := by sorry\n  example : (\u2203 x, p x \u2227 r) \u2194 (\u2203 x, p x) \u2227 r := by sorry\n  example : (\u2203 x, p x \u2228 q x) \u2194 (\u2203 x, p x) \u2228 (\u2203 x, q x) := by sorry\n\n  example : (\u2200 x, p x) \u2194 \u00ac (\u2203 x, \u00ac p x) := by sorry\n  example : (\u2203 x, p x) \u2194 \u00ac (\u2200 x, \u00ac p x) := by sorry\n  example : (\u00ac \u2203 x, p x) \u2194 (\u2200 x, \u00ac p x) := by sorry\n  example : (\u00ac \u2200 x, p x) \u2194 (\u2203 x, \u00ac p x) := by sorry\n\n  example : (\u2200 x, p x \u2192 r) \u2194 (\u2203 x, p x) \u2192 r := by sorry\n  example (a : \u03b1) : (\u2203 x, p x \u2192 r) \u2194 (\u2200 x, p x) \u2192 r := by sorry\n  example (a : \u03b1) : (\u2203 x, r \u2192 p x) \u2194 (r \u2192 \u2203 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 \u2192 mybool :=\n    @mybool.rec (\u03bb _, mybool) tt ff\n  \n  def band : mybool \u2192 mybool \u2192 mybool :=\n    \u03bb a b, @mybool.rec (\u03bb _, mybool) ff b a\n  \n  def bor : mybool \u2192 mybool \u2192 mybool :=\n    \u03bb a b, @mybool.rec (\u03bb _, mybool) b tt a\n\nend mybool\n\nuniverse u\n\n-- Standard definition for equality\ninductive myeq {\u03b1 : Sort u} (l : \u03b1) : \u03b1 \u2192 Prop\n| refl [] : myeq l\n\nnamespace myeq\n\n  lemma symm : \u03a0 {\u03b1 : Sort u} {x y : \u03b1} (h : myeq x y), myeq y x :=\n    \u03bb \u03b1 x y h, @myeq.rec \u03b1 x -- The subject is `myeq {\u03b1} x`\n      (\u03bb 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 : \u03a0 {\u03b1 : Sort u} {x y z : \u03b1} (h\u2081 : myeq x y) (h\u2082 : myeq y z), myeq x z :=\n    \u03bb \u03b1 x y z h\u2081 h\u2082, @myeq.rec \u03b1 y -- The subject is `myeq {\u03b1} y`\n      (\u03bb r, myeq x r) -- Make a more general claim: given `myeq y r` then `myeq x r`\n      h\u2081              -- Now given `myeq y y` (implicit), prove `myeq x y`\n        z h\u2082          -- Then we could specialise `r` to `z`, and give a `myeq y z` to make `myeq x z`\n  \n  lemma congr : \u03a0 {\u03b1 \u03b2 : Sort u} {x y : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : myeq x y), myeq (f x) (f y) :=\n    \u03bb \u03b1 \u03b2 x y f h, @myeq.rec \u03b1 x\n      (\u03bb r, myeq (f x) (f r))\n      (myeq.refl (f x))\n        y h\n  \n  lemma subst : \u03a0 {\u03b1 : Sort u} {x y : \u03b1} (p : \u03b1 \u2192 Prop) (h\u2081 : myeq x y) (h\u2082 : p x), p y :=\n    \u03bb \u03b1 x y p h\u2081 h\u2082, @myeq.rec \u03b1 x\n      (\u03bb r, p r)\n      h\u2082\n        y h\u2081\n  \n  -- Simplify by removing `@` and abbreviating arguments\n  lemma symm' {\u03b1 : Sort u} {x y : \u03b1} (h : myeq x y) : myeq y x :=\n    myeq.rec (myeq.refl x) h\n  lemma trans' {\u03b1 : Sort u} {x y z : \u03b1} (h\u2081 : myeq x y) (h\u2082 : myeq y z) : myeq x z :=\n    myeq.rec h\u2081 h\u2082\n  lemma congr' {\u03b1 \u03b2 : Sort u} {x y : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : myeq x y) : myeq (f x) (f y) :=\n    myeq.rec (myeq.refl (f x)) h\n  lemma subst' {\u03b1 : Sort u} {x y : \u03b1} (p : \u03b1 \u2192 Prop) (h\u2081 : myeq x y) (h\u2082 : p x) : p y :=\n    myeq.rec h\u2082 h\u2081\n\nend myeq\n\nnamespace mybool\n\n  lemma em : \u03a0 (a : mybool), myeq (bor a (bnot a)) tt :=\n    @mybool.rec\n      (\u03bb 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 : \u03a0 (a b : mybool), myeq (bnot (band a b)) (bor (bnot a) (bnot b)) :=\n    \u03bb a b, @mybool.rec -- By cases on `a`\n      (\u03bb a', myeq (bnot (band a' b)) (bor (bnot a') (bnot b)))\n      (@mybool.rec     -- By cases on `b`\n        (\u03bb 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        (\u03bb 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 (\u03b1 : Type u) : Type u\n| nothing :     maybe\n| just    : \u03b1 \u2192 maybe\n\ninductive inhabited (\u03b1 : Type u) : Type u\n| mk : \u03b1 \u2192 inhabited\n\nnamespace maybe\n\n  -- The \"monad operation\"\n  def bind : \u03a0 {\u03b1 \u03b2 : Type u}, maybe \u03b1 \u2192 (\u03b1 \u2192 maybe \u03b2) \u2192 maybe \u03b2 :=\n    \u03bb \u03b1 \u03b2 ma f, @maybe.rec \u03b1\n      (\u03bb _, maybe \u03b2)\n      (nothing)\n      (\u03bb a, f a)\n        ma\n  \n  -- Partial function composition\n  def compose : \u03a0 {\u03b1 \u03b2 \u03b3 : Type u}, (\u03b2 \u2192 maybe \u03b3) \u2192 (\u03b1 \u2192 maybe \u03b2) \u2192 \u03b1 \u2192 maybe \u03b3 :=\n    \u03bb \u03b1 \u03b2 \u03b3 g f a, @maybe.rec \u03b2\n      (\u03bb _, maybe \u03b3)\n      (nothing)\n      (\u03bb b, g b)\n        (f a)\n  \n  -- Simplified versions\n  def bind' {\u03b1 \u03b2 : Type u} (ma : maybe \u03b1) (f : \u03b1 \u2192 maybe \u03b2) : maybe \u03b2 :=\n    maybe.rec nothing f ma\n  def compose' {\u03b1 \u03b2 \u03b3 : Type u} (g : \u03b2 \u2192 maybe \u03b3) (f : \u03b1 \u2192 maybe \u03b2) (a : \u03b1) : maybe \u03b3 :=\n    maybe.rec nothing g (f a)\n  def compose'' {\u03b1 \u03b2 \u03b3 : Type u} (g : \u03b2 \u2192 maybe \u03b3) (f : \u03b1 \u2192 maybe \u03b2) (a : \u03b1) : maybe \u03b3 :=\n    bind' (f a) g\n\nend maybe\n\nsection\n  def is_even (x : \u2115) : bool := nat.rec_on x tt (\u03bb _, @bool.rec (\u03bb _, bool) bool.tt bool.ff)\n  def filter (x : \u2115) : maybe \u2115 := 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 : \u03a0 {\u03b1 \u03b2 : Type u}\n    (i\u2081 : inhabited \u03b1) (i\u2082 : inhabited \u03b2),\n    inhabited (prod \u03b1 \u03b2) :=\n      \u03bb \u03b1 \u03b2 i\u2081 i\u2082, inhabited.mk (inhabited.rec id i\u2081, inhabited.rec id i\u2082)\n  \n  def inhabited_of_function_to_inhabited : \u03a0 {\u03b1 \u03b2 : Type u}\n    (i : inhabited \u03b2),\n    inhabited (\u03b1 \u2192 \u03b2) :=\n      \u03bb \u03b1 \u03b2 i, inhabited.mk (\u03bb _, inhabited.rec id i)\n   \n  def inhabited_of_function_to_inhabited' : \u03a0 {\u03b1 : Type u} {\u03c4 : \u03b1 \u2192 Type u}\n    (i : \u03a0 (a : \u03b1), inhabited (\u03c4 a)),\n    inhabited (\u03a0 (a : \u03b1), \u03c4 a) :=\n      \u03bb \u03b1 \u03c4 i, inhabited.mk (\u03bb a, inhabited.rec id (i a))\nend\n\ninductive mylist (\u03b1 : Type u) : Type u\n| nil  :              mylist\n| cons : \u03b1 \u2192 mylist \u2192 mylist\n\nnamespace mylist\n  variable {\u03b1 : Type u}\n\n  def append (s t : mylist \u03b1) : mylist \u03b1 :=\n    mylist.rec_on s t (\u03bb a _, \u03bb 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 \u03b1) : nil ++ t = t := eq.refl t\n  theorem cons_append (x : \u03b1) (s t : mylist \u03b1) : x::s ++ t = x::(s ++ t) := eq.refl _\n\n  -- Manual equational rewriting!\n  theorem append_nil (t : mylist \u03b1) : t ++ nil = t :=\n    @mylist.rec_on \u03b1\n      (\u03bb l, l ++ nil = l) t\n      (eq.refl nil)\n      (\u03bb a as, \u03bb ih, (@eq.subst _ (\u03bb 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 \u03b1) : r ++ s ++ t = r ++ (s ++ t) :=\n    @mylist.rec_on \u03b1\n      (\u03bb l, (l ++ s) ++ t = l ++ (s ++ t)) r\n      (eq.refl (s ++ t))\n      (\u03bb a as, \u03bb ih,\n        (@eq.subst _ (\u03bb x, (a::as ++ s) ++ t = a::x) _ _ ih\n          (@eq.subst _ (\u03bb x, (a::as ++ s) ++ t = x) _ _ (cons_append a (as ++ s) t)\n            (@eq.subst _ (\u03bb 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 \u03b1) : r ++ s ++ t = r ++ (s ++ t) :=\n    @mylist.rec_on \u03b1\n      (\u03bb l, (l ++ s) ++ t = l ++ (s ++ t)) r\n      rfl\n      (\u03bb a as, \u03bb ih, (@eq.subst _ (\u03bb x, (a::as ++ s) ++ t = a::x) _ _ ih rfl))\n\nend mylist\n\ninductive mynat : Type\n| zero :                mynat\n| succ : \u03a0 (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 \u2192 mynat \u2192 mynat :=\n    \u03bb a, @mynat.rec\n      (\u03bb r, mynat)\n      a\n      (\u03bb r, \u03bb ar, succ ar)\n\n  #reduce add one two\n\n  def mul : mynat \u2192 mynat \u2192 mynat :=\n    \u03bb a, @mynat.rec\n      (\u03bb r, mynat)\n      zero\n      (\u03bb r, \u03bb ar, add ar a)\n\n  #reduce mul two three\n  #reduce mul three two\n\n  def pred : mynat \u2192 mynat :=\n    @mynat.rec\n      (\u03bb r, mynat)\n      zero\n      (\u03bb r, \u03bb predr, r)\n\n  #reduce pred zero\n  #reduce pred one\n  #reduce pred two\n  #reduce pred three\n\n  def monus : mynat \u2192 mynat \u2192 mynat :=\n    \u03bb a, @mynat.rec\n      (\u03bb r, mynat)\n      a\n      (\u03bb r, \u03bb ar, pred ar)\n\n  #reduce monus three two\n  #reduce monus two three\n\n  def pow : mynat \u2192 mynat \u2192 mynat :=\n    \u03bb a, @mynat.rec\n      (\u03bb _, mynat)\n      one\n      (\u03bb r, \u03bb ar, mul ar a)\n\n  #reduce pow two three\n  #reduce pow three two\n\n  lemma add_zero : \u03a0 (a : mynat), add a zero = a :=\n    \u03bb a, rfl\n\n  lemma add_succ : \u03a0 (a b : mynat), add a (succ b) = succ (add a b) :=\n    \u03bb a b, rfl\n\n  -- More manual equational rewriting...\n  lemma succ_add : \u03a0 (a b : mynat), add (succ a) b = succ (add a b) :=\n    \u03bb a b, @mynat.rec_on\n      (\u03bb n, add (succ a) n = succ (add a n)) b\n      rfl\n      (\u03bb n, \u03bb ih,\n        (@eq.subst _ (\u03bb x, add (succ a) (succ n) = succ x) _ _ ih\n          (eq.refl (add (succ a) (succ n)))))\n\n  lemma zero_add : \u03a0 (a : mynat), add zero a = a :=\n    \u03bb a, @mynat.rec_on\n      (\u03bb n, add zero n = n) a\n      rfl\n      (\u03bb n, \u03bb ih,\n        (@eq.subst _ (\u03bb x, succ (add zero n) = succ x) _ _ ih\n          (eq.refl (succ (add zero n)))))\n\n  lemma add_comm : \u03a0 (a b : mynat), add a b = add b a :=\n    \u03bb a b, @mynat.rec_on\n      (\u03bb n, add a n = add n a) b\n      (eq.symm (zero_add a))\n      (\u03bb n, \u03bb ih,\n        (@eq.subst _ (\u03bb x, succ (add a n) = x) _ _ (eq.symm (succ_add n a))\n          (@eq.subst _ (\u03bb 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 \u25b8\n\n  -- `rw` is incredible...!\n  lemma add_comm' : \u03a0 (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, \u2190 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 {\u03b1 : 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 \u03b1 \u2192 \u2115 :=\n    \u03bb l, mylist.rec 0 (\u03bb _ _, \u03bb (l' : \u2115), l'.succ) l\n  \n  def reverse : mylist \u03b1 \u2192 mylist \u03b1 :=\n    \u03bb l, mylist.rec nil (\u03bb a l, \u03bb 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 : \u03a0 (s t : mylist \u03b1), length (s ++ t) = length s + length t :=\n    \u03bb s t, @mylist.rec_on \u03b1\n      (\u03bb l, length (l ++ t) = length l + length t) s\n      (eq.symm (nat.zero_add t.length))\n      (\u03bb a l, \u03bb ih,\n        (@eq.subst _ (\u03bb x, length (a::l ++ t) = x) _ _ (eq.symm (nat.succ_add (length l) (length t)))\n          (@eq.subst _ (\u03bb x, length (a::l ++ t) = nat.succ x) _ _ ih\n            (@eq.subst _ (\u03bb x, length (a::l ++ t) = length x) _ _ (cons_append a l t)\n              (eq.refl (a::l ++ t).length)))))\n\n  lemma length_reverse : \u03a0 (t : mylist \u03b1), length (reverse t) = length t :=\n    \u03bb t, @mylist.rec_on \u03b1\n      (\u03bb l, length (reverse l) = length l) t\n      rfl\n      (\u03bb a l, \u03bb ih,\n        (@eq.subst _ (\u03bb x, x = (a::l).length) _ _ (eq.symm (length_append l.reverse [a]))\n          (@eq.subst _ (\u03bb x, nat.succ x = (a::l).length) _ _ (eq.symm ih)\n            (eq.refl (a::l).length))))\n\n  lemma append_reverse_eq_reverse_append : \u03a0 (s t : mylist \u03b1), reverse (s ++ t) = reverse t ++ reverse s :=\n    \u03bb s t, @mylist.rec_on \u03b1\n      (\u03bb x, reverse (x ++ t) = reverse t ++ reverse x) s\n      (@eq.subst _ (\u03bb x, reverse t = x) _ _ (eq.symm (append_nil t.reverse)) (eq.refl t.reverse))\n      (\u03bb a l, \u03bb ih,\n        (@eq.subst _ (\u03bb x, reverse (a::l ++ t) = x) _ _ (append_assoc t.reverse l.reverse [a])\n          (@eq.subst _ (\u03bb x, reverse (a::l ++ t) = x ++ [a]) _ _ ih\n            (@eq.subst _ (\u03bb 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 : \u03a0 (t : mylist \u03b1), reverse (reverse t) = t :=\n    \u03bb t, @mylist.rec_on \u03b1\n      (\u03bb x, reverse (reverse x) = x) t\n      rfl\n      (\u03bb a l, \u03bb ih,\n        (@eq.subst _ (\u03bb x, (a::l).reverse.reverse = [a] ++ x) _ _ ih\n          (@eq.subst _ (\u03bb 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 : \u2115 \u2192                       arith_expr\n| var   : \u2115 \u2192                       arith_expr\n| plus  : arith_expr \u2192 arith_expr \u2192 arith_expr\n| times : arith_expr \u2192 arith_expr \u2192 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 : (\u2115 \u2192 \u2115) \u2192 arith_expr \u2192 \u2115 :=\n    \u03bb as e, @arith_expr.rec_on (\u03bb _, \u2115) e\n      id\n      as\n      (\u03bb e1 e2, \u03bb v1 v2, v1 + v2)\n      (\u03bb e1 e2, \u03bb 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 \u2192                        boolean_expr\n| var   : \u2115 \u2192                           boolean_expr\n| not   : boolean_expr \u2192                boolean_expr\n| and   : boolean_expr \u2192 boolean_expr \u2192 boolean_expr\n| or    : boolean_expr \u2192 boolean_expr \u2192 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 : (\u2115 \u2192 bool) \u2192 boolean_expr \u2192 bool :=\n    \u03bb as e, @boolean_expr.rec_on (\u03bb _, bool) e\n      id\n      as\n      (\u03bb e', \u03bb v', bnot v')\n      (\u03bb e1 e2, \u03bb v1 v2, band v1 v2)\n      (\u03bb e1 e2, \u03bb v1 v2, bor v1 v2)\n\n  def size : boolean_expr \u2192 \u2115 :=\n    \u03bb e, @boolean_expr.rec_on (\u03bb _, \u2115) e\n      (\u03bb _, 1)\n      (\u03bb _, 1)\n      (\u03bb e', \u03bb ne', ne' + 1)\n      (\u03bb e1 e2, \u03bb ne1 ne2, ne1 + ne2 + 1)\n      (\u03bb e1 e2, \u03bb ne1 ne2, ne1 + ne2 + 1)\n\n  def depth : boolean_expr \u2192 \u2115 :=\n    \u03bb e, @boolean_expr.rec_on (\u03bb _, \u2115) e\n      (\u03bb _, 1)\n      (\u03bb _, 1)\n      (\u03bb e', \u03bb ne', ne' + 1)\n      (\u03bb e1 e2, \u03bb ne1 ne2, max ne1 ne2 + 1)\n      (\u03bb e1 e2, \u03bb 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 \u2192 \u2115 \u2192 boolean_expr \u2192 boolean_expr :=\n    \u03bb sub ind e, @boolean_expr.rec_on (\u03bb _, boolean_expr) e\n      (\u03bb b, const b)\n      (\u03bb v, ite (v = ind) sub (var v))\n      (\u03bb _, \u03bb e', not e')\n      (\u03bb _ _, \u03bb e1' e2', and e1' e2')\n      (\u03bb _ _, \u03bb 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 \u2192 \u2115 \u2192 Prop\n| even_zero :                            even_odd ff 0\n| even_succ : \u03a0 {n : \u2115}, even_odd ff n \u2192 even_odd tt n.succ\n| odd_succ  : \u03a0 {n : \u2115}, even_odd tt n \u2192 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 \u2218 odd_succ \u2218 even_succ \u2218 odd_succ \u2218 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n  open function\n\n  lemma surjective_comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2}\n    (hg : surjective g) (hf : surjective f) : surjective (g \u2218 f) :=\n    \u03bb c,\n      match hg c with (Exists.intro b hb) :=\n        match hf b with (Exists.intro a ha) :=\n          \u27e8a, (ha.symm \u25b8 hb : g (f a) = c)\u27e9 end end\nend\n\nnamespace hidden\n  open nat\n\n  def add : \u2115 \u2192 \u2115 \u2192 \u2115\n  | a 0        := a\n  | a (succ b) := succ (add a b)\n\n  lemma zero_add : \u03a0 (a : \u2115), add 0 a = a\n  | 0        := rfl\n  | (succ b) := congr_arg succ (zero_add b)\n\n  lemma succ_add : \u03a0 (a b : \u2115), 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 : \u03a0 (a b : \u2115), 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 : \u03a0 (a b c : \u2115), 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 {\u03b1 : Type*}\n\n  def length : list \u03b1 \u2192 \u2115\n  | []        := 0\n  | (x :: xs) := length xs + 1\n  \n  def reverse : list \u03b1 \u2192 list \u03b1\n  | []        := []\n  | (x :: xs) := reverse xs ++ [x]\n  \n  lemma length_append : \u03a0 (s t : list \u03b1), 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, \u2190 nat.add_assoc, length_append]\n\n  lemma length_reverse : \u03a0 (t : list \u03b1), 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 : \u03a0 (s t : list \u03b1), 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 : \u03a0 (t : list \u03b1), 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' {\u03b1 : Sort*} {C : \u03b1 \u2192 Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (hwf : well_founded r) (R : \u03a0 (x : \u03b1), (\u03a0 (y : \u03b1), r y x \u2192 C y) \u2192 C x) :\n      \u03a0 (x : \u03b1), C x :=\n        \u03bb x, @acc.rec_on \u03b1 r C x (hwf.apply x) (\u03bb x' hx', R x')\nend\n\ninductive vector (\u03b1 : Type) : \u2115 \u2192 Type\n| vnil  :                           vector 0\n| vcons : \u03a0 {n : \u2115}, \u03b1 \u2192 vector n \u2192 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 {\u03b1 : Type} {n : \u2115} : vector \u03b1 (n + 1) \u2192 vector \u03b1 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 {\u03b1 : Type*} {n n' : \u2115} (v : vector \u03b1 n') : n' = n + 1 \u2192 vector \u03b1 n :=\n    vector.cases_on v -- Cases on `v` first so you could use that equality\n      (\u03bb (h : 0 = n + 1), nat.no_confusion h)\n      (\u03bb n' (a : \u03b1) (as : vector \u03b1 n') (h : n' + 1 = n + 1),\n        nat.no_confusion h (\u03bb h\u2081 : n' = n, eq.rec_on h\u2081 as))\n\n  def tail' {\u03b1 : Type*} {n : \u2115} (v : vector \u03b1 (n + 1)) : vector \u03b1 n :=\n    tail_aux v rfl\n\n  -- Using EC\n  def append {\u03b1 : Type} : \u03a0 {m : \u2115} (u : vector \u03b1 m) {n : \u2115} (v : vector \u03b1 n), vector \u03b1 (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' {\u03b1 : Type} : \u03a0 {m : \u2115} (u : vector \u03b1 m) {n : \u2115} (v : vector \u03b1 n), vector \u03b1 (n + m) :=\n    \u03bb m u n v,\n      @vector.rec_on _ (\u03bb m' _, vector \u03b1 (n + m')) _ u\n        v\n        (\u03bb 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 : \u2115             \u2192 aexpr\n  | var   : \u2115             \u2192 aexpr\n  | plus  : aexpr \u2192 aexpr \u2192 aexpr\n  | times : aexpr \u2192 aexpr \u2192 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 : \u2115 \u2192 \u2115) : aexpr \u2192 \u2115\n  | (const n)     := n\n  | (var n)       := v n\n  | (plus e\u2081 e\u2082)  := aeval e\u2081 + aeval e\u2082\n  | (times e\u2081 e\u2082) := aeval e\u2081 * aeval e\u2082\n\n  def sample_val : \u2115 \u2192 \u2115\n  | 0 := 5\n  | 1 := 6\n  | _ := 0\n\n  #eval aeval sample_val sample_aexpr\n\n  def simp_const : aexpr \u2192 aexpr\n  | (plus (const n\u2081) (const n\u2082))  := const (n\u2081 + n\u2082)\n  | (times (const n\u2081) (const n\u2082)) := const (n\u2081 * n\u2082)\n  | e                             := e\n\n  def fuse : aexpr \u2192 aexpr\n  | (const n)     := (const n)\n  | (var n)       := (var n)\n  | (plus e\u2081 e\u2082)  := simp_const (plus (fuse e\u2081) (fuse e\u2082))\n  | (times e\u2081 e\u2082) := simp_const (times (fuse e\u2081) (fuse e\u2082))\n\n  theorem simp_const_eq (v : \u2115 \u2192 \u2115) : \u2200 e : aexpr, aeval v (simp_const e) = aeval v e\n  | (const n)     := rfl\n  | (var n)       := rfl\n  | (plus e\u2081 e\u2082)  := by { cases e\u2081; cases e\u2082; refl }\n  | (times e\u2081 e\u2082) := by { cases e\u2081; cases e\u2082; refl }\n\n  theorem fuse_eq (v : \u2115 \u2192 \u2115) : \u2200 e : aexpr, aeval v (fuse e) = aeval v e\n  | (const n)     := rfl\n  | (var n)       := rfl\n  | (plus e\u2081 e\u2082)  :=\n    show aeval v (simp_const (plus (fuse e\u2081) (fuse e\u2082))) = aeval v (plus e\u2081 e\u2082),\n      by { rw simp_const_eq, unfold aeval, rw [fuse_eq, fuse_eq] }\n  | (times e\u2081 e\u2082) :=\n    show aeval v (simp_const (times (fuse e\u2081) (fuse e\u2082))) = aeval v (times e\u2081 e\u2082),\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u2208 F` is arbitrarily well approached by\nimages of elements of norm at most `C * \u2225y\u2225`.\nFor further use, we will only need such an element whose image\nis within distance `\u2225y\u2225/2` of `y`, to apply an iterative process. -/\ntheorem exists_approx_preimage_norm_le {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] (f : continuous_linear_map \ud835\udd5c E F) [complete_space F] (surj : function.surjective \u21d1f) : \u2203 (C : \u211d), \u2203 (H : C \u2265 0), \u2200 (y : F), \u2203 (x : E), dist (coe_fn f x) y \u2264 1 / bit0 1 * norm y \u2227 norm x \u2264 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] (f : continuous_linear_map \ud835\udd5c E F) [complete_space F] [complete_space E] (surj : function.surjective \u21d1f) : \u2203 (C : \u211d), \u2203 (H : C > 0), \u2200 (y : F), \u2203 (x : E), coe_fn f x = y \u2227 norm x \u2264 C * norm y := sorry\n\n/-- The Banach open mapping theorem: a surjective bounded linear map between Banach spaces is\nopen. -/\ntheorem open_mapping {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] (f : continuous_linear_map \ud835\udd5c E F) [complete_space F] [complete_space E] (surj : function.surjective \u21d1f) : is_open_map \u21d1f := 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space F] [complete_space E] (e : linear_equiv \ud835\udd5c E F) (h : continuous \u21d1e) : continuous \u21d1(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space F] [complete_space E] (e : linear_equiv \ud835\udd5c E F) (h : continuous \u21d1e) : continuous_linear_equiv \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space F] [complete_space E] (e : linear_equiv \ud835\udd5c E F) (h : continuous \u21d1e) : \u21d1(to_continuous_linear_equiv_of_continuous e h) = \u21d1e :=\n  rfl\n\n@[simp] theorem coe_fn_to_continuous_linear_equiv_of_continuous_symm {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space F] [complete_space E] (e : linear_equiv \ud835\udd5c E F) (h : continuous \u21d1e) : \u21d1(continuous_linear_equiv.symm (to_continuous_linear_equiv_of_continuous e h)) = \u21d1(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 \u2192L[\ud835\udd5c] F` between two Banach spaces\nto a continuous linear equivalence. -/\ndef of_bijective {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space F] [complete_space E] (f : continuous_linear_map \ud835\udd5c E F) (hinj : continuous_linear_map.ker f = \u22a5) (hsurj : continuous_linear_map.range f = \u22a4) : continuous_linear_equiv \ud835\udd5c E F :=\n  linear_equiv.to_continuous_linear_equiv_of_continuous (linear_equiv.of_bijective (\u2191f) hinj hsurj) sorry\n\n@[simp] theorem coe_fn_of_bijective {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space F] [complete_space E] (f : continuous_linear_map \ud835\udd5c E F) (hinj : continuous_linear_map.ker f = \u22a5) (hsurj : continuous_linear_map.range f = \u22a4) : \u21d1(of_bijective f hinj hsurj) = \u21d1f :=\n  rfl\n\n@[simp] theorem of_bijective_symm_apply_apply {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space F] [complete_space E] (f : continuous_linear_map \ud835\udd5c E F) (hinj : continuous_linear_map.ker f = \u22a5) (hsurj : continuous_linear_map.range f = \u22a4) (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space F] [complete_space E] (f : continuous_linear_map \ud835\udd5c E F) (hinj : continuous_linear_map.ker f = \u22a5) (hsurj : continuous_linear_map.range f = \u22a4) (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\u2093'. -/\ntheorem zero_pow : \u2200 {n : \u2115}, 0 < n \u2192 (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'\u2093'. -/\n@[simp]\ntheorem zero_pow' : \u2200 n : \u2115, n \u2260 0 \u2192 (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\u2093'. -/\ntheorem zero_pow_eq (n : \u2115) : (0 : M) ^ n = if n = 0 then 1 else 0 :=\n  by\n  split_ifs with h\n  \u00b7 rw [h, pow_zero]\n  \u00b7 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\u2093'. -/\ntheorem pow_eq_zero_of_le {x : M} {n m : \u2115} (hn : n \u2264 m) (hx : x ^ n = 0) : x ^ m = 0 := by\n  rw [\u2190 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\u2093'. -/\ntheorem pow_eq_zero [NoZeroDivisors M] {x : M} {n : \u2115} (H : x ^ n = 0) : x = 0 :=\n  by\n  induction' n with n ih\n  \u00b7 rw [pow_zero] at H\n    rw [\u2190 mul_one x, H, MulZeroClass.mul_zero]\n  \u00b7 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\u2093'. -/\n@[simp]\ntheorem pow_eq_zero_iff [NoZeroDivisors M] {a : M} {n : \u2115} (hn : 0 < n) : a ^ n = 0 \u2194 a = 0 :=\n  by\n  refine' \u27e8pow_eq_zero, _\u27e9\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'\u2093'. -/\ntheorem pow_eq_zero_iff' [NoZeroDivisors M] [Nontrivial M] {a : M} {n : \u2115} :\n    a ^ n = 0 \u2194 a = 0 \u2227 n \u2260 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\u2093'. -/\ntheorem pow_ne_zero_iff [NoZeroDivisors M] {a : M} {n : \u2115} (hn : 0 < n) : a ^ n \u2260 0 \u2194 a \u2260 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\u2093'. -/\ntheorem ne_zero_pow {a : M} {n : \u2115} (hn : n \u2260 0) : a ^ n \u2260 0 \u2192 a \u2260 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\u2093'. -/\n@[field_simps]\ntheorem pow_ne_zero [NoZeroDivisors M] {a : M} (n : \u2115) (h : a \u2260 0) : a ^ n \u2260 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\u2093'. -/\ninstance NeZero.pow [NoZeroDivisors M] {x : M} [NeZero x] {n : \u2115} : NeZero (x ^ n) :=\n  \u27e8pow_ne_zero n NeZero.out\u27e9\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\u2093'. -/\ntheorem sq_eq_zero_iff [NoZeroDivisors M] {a : M} : a ^ 2 = 0 \u2194 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\u2093'. -/\n@[simp]\ntheorem zero_pow_eq_zero [Nontrivial M] {n : \u2115} : (0 : M) ^ n = 0 \u2194 0 < n :=\n  by\n  constructor <;> intro h\n  \u00b7 rw [pos_iff_ne_zero]\n    rintro rfl\n    simpa using h\n  \u00b7 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) : \u2200 n : \u2115, 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\u2093 n), Ring.inverse_pow]\n#align ring.inverse_pow Ring.inverse_pow\n-/\n\nend MonoidWithZero\n\nsection CommMonoidWithZero\n\nvariable [CommMonoidWithZero M] {n : \u2115} (hn : 0 < n)\n\ninclude M hn\n\n#print powMonoidWithZeroHom /-\n/-- We define `x \u21a6 x^n` (for positive `n : \u2115`) as a `monoid_with_zero_hom` -/\ndef powMonoidWithZeroHom : M \u2192*\u2080 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\u2093'. -/\n@[simp]\ntheorem coe_powMonoidWithZeroHom : (powMonoidWithZeroHom hn : M \u2192 M) = (\u00b7 ^ 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\u2093'. -/\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\u2093'. -/\ntheorem pow_dvd_pow_iff [CancelCommMonoidWithZero R] {x : R} {n m : \u2115} (h0 : x \u2260 0)\n    (h1 : \u00acIsUnit x) : x ^ n \u2223 x ^ m \u2194 n \u2264 m :=\n  by\n  constructor\n  \u00b7 intro h\n    rw [\u2190 not_lt]\n    intro hmn\n    apply h1\n    have : x ^ m * x \u2223 x ^ m * 1 := by\n      rw [\u2190 pow_succ', mul_one]\n      exact (pow_dvd_pow _ (Nat.succ_le_of_lt hmn)).trans h\n    rwa [mul_dvd_mul_iff_left, \u2190 isUnit_iff_dvd_one] at this\n    apply pow_ne_zero m h0\n  \u00b7 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\u2093'. -/\nprotected theorem RingHom.map_pow (f : R \u2192+* S) (a) : \u2200 n : \u2115, 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\u2093'. -/\ntheorem min_pow_dvd_add {n m : \u2115} {a b c : R} (ha : c ^ n \u2223 a) (hb : c ^ m \u2223 b) :\n    c ^ min n m \u2223 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\u2093'. -/\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'\u2093'. -/\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\u2093'. -/\nalias add_sq \u2190 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\u2093'. -/\ntheorem neg_one_pow_eq_or : \u2200 n : \u2115, (-1 : R) ^ n = 1 \u2228 (-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\u2093'. -/\ntheorem neg_pow (a : R) (n : \u2115) : (-a) ^ n = (-1) ^ n * a ^ n :=\n  neg_one_mul a \u25b8 (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\u2093'. -/\n@[simp]\ntheorem neg_pow_bit0 (a : R) (n : \u2115) : (-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\u2093'. -/\n@[simp]\ntheorem neg_pow_bit1 (a : R) (n : \u2115) : (-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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\nalias neg_sq \u2190 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\u2093'. -/\nalias neg_one_sq \u2190 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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem neg_one_pow_mul_eq_zero_iff {n : \u2115} {r : R} : (-1) ^ n * r = 0 \u2194 r = 0 := by\n  rcases neg_one_pow_eq_or R n with \u27e8\u27e9 <;> 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\u2093'. -/\n@[simp]\ntheorem mul_neg_one_pow_eq_zero_iff {n : \u2115} {r : R} : r * (-1) ^ n = 0 \u2194 r = 0 := by\n  rcases neg_one_pow_eq_or R n with \u27e8\u27e9 <;> 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\u2093'. -/\nprotected theorem Commute.sq_eq_sq_iff_eq_or_eq_neg (h : Commute a b) :\n    a ^ 2 = b ^ 2 \u2194 a = b \u2228 a = -b := by\n  rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem sq_eq_one_iff : a ^ 2 = 1 \u2194 a = 1 \u2228 a = -1 := by\n  rw [\u2190 (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\u2093'. -/\ntheorem sq_ne_one_iff : a ^ 2 \u2260 1 \u2194 a \u2260 1 \u2227 a \u2260 -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\u2093'. -/\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\u2093'. -/\nalias sq_sub_sq \u2190 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\u2093'. -/\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, \u2190 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\u2093'. -/\nalias sub_sq \u2190 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'\u2093'. -/\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, \u2190 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\u2093'. -/\ntheorem sq_eq_sq_iff_eq_or_eq_neg : a ^ 2 = b ^ 2 \u2194 a = b \u2228 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\u2093'. -/\ntheorem eq_or_eq_neg_of_sq_eq_sq (a b : R) : a ^ 2 = b ^ 2 \u2192 a = b \u2228 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\u2093'. -/\nprotected theorem sq_eq_sq_iff_eq_or_eq_neg {a b : R\u02e3} : a ^ 2 = b ^ 2 \u2194 a = b \u2228 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\u2093'. -/\nprotected theorem eq_or_eq_neg_of_sq_eq_sq (a b : R\u02e3) (h : a ^ 2 = b ^ 2) : a = b \u2228 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 \u2192 s) (s \u2192 r)\n\nvariable h : r \u2192 s\n#check t1 (r \u2192 s) (s \u2192 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 {\u03b1 : Type*} {m n : measurable_space \u03b1} \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 \u03b1 M) (hle : m \u2264 n) : @vector_measure \u03b1 m M _ _ :=\n-- { measure_of' := \u03bb 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' := \u03bb i hi, by rw if_neg hi,\n--   m_Union' := \u03bb f hf\u2081 hf\u2082,\n--   begin\n--     have hf\u2081' : \u2200 k, measurable_set[n] (f k) := \u03bb k, hle _ (hf\u2081 k),\n--     convert v.m_Union hf\u2081' hf\u2082,\n--     { ext n, rw if_pos (hf\u2081 n) },\n--     { rw if_pos (@measurable_set.Union _ _ m _ _ hf\u2081) }\n--   end }\n\n-- variables {v : vector_measure \u03b1 M} (hle : m \u2264 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 \u2264 n) : (0 : vector_measure \u03b1 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 \u03b1} (hle : m \u2264 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  {\u03bc : measure \u03b1} (hle : m \u2264 n) {f : \u03b1 \u2192 \u211d} (hf : integrable f \u03bc) \n  {i : set \u03b1} (hi : measurable_set[m] i) : \n  (\u03bc.with_density\u1d65 f).trim hle i = \u222b x in i, f x \u2202\u03bc :=\nby rw [vector_measure.trim_measurable_set_eq hle hi, \n       with_density\u1d65_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 \u00d7 term) \u2192 (list (list nat \u00d7 term) \u00d7 \n  list (list nat \u00d7 term) \u00d7 list (list nat \u00d7 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 \u00d7 term) \u00d7 (list nat \u00d7 term)) \u2192 tactic (list nat \u00d7 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' *\u2081 p1) (o' *\u2081 p2), \n          term.add (t1.mul n') (t2.mul o'))\n\nmeta def elim_var (m) (neg pos : list (list nat \u00d7 term)) : \n  tactic (list (list nat \u00d7 term)) :=\nlet pairs := list.product neg pos in \nmonad.mapm (elim_var_aux m) pairs\n\nmeta def find_contra : list (list nat \u00d7 term) \u2192 tactic (list nat)\n| []            := failed\n| ((\u03c0,\u27e8c,_\u27e9)::l) := if c < 0 then return \u03c0 else find_contra l\n\nmeta def search_core : nat \u2192 list (list nat \u00d7 term) \u2192 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 \u2190 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 (\u03bb t : term, t.snd.length)).max  \n  (ts.map_with_idx (\u03bb m t, ([]{m \u21a6 1}, t)))\n\n@[omega] def comb : list term \u2192 list nat \u2192 term \n| [] []     := \u27e80,[]\u27e9 \n| [] (_::_) := \u27e80,[]\u27e9 \n| (_::_) [] := \u27e80,[]\u27e9 \n| (t::ts) (n::ns) := term.add (t.mul \u2191n) (comb ts ns)\n\nlemma comb_holds {v} :\n  \u2200 {ts} ns, (\u2200 t \u2208 ts, 0 \u2264 term.val v t) \u2192 (0 \u2264 (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 \u2227 \u2200 x \u2208 (comb ts ns).snd, x = (0 : int)\n\nlemma unsat_comb_of (ts ns) : \n(comb ts ns).fst < 0 \u2192 \n(\u2200 x \u2208 (comb ts ns).snd, x = (0 : int)) \u2192 \nunsat_comb ts ns := \nbegin intros h1 h2, exact \u27e8h1,h2\u27e9 end\n\nlemma unsat_of_unsat_comb (ns les) :\n  (unsat_comb les ns) \u2192 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, \u2190 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) \u2192 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\u2081_or {a b : Prop} (h\u2081 : or b (or a bot)) : or b a :=\n                    have h\u2082 : or (or b a) bot, from or.d\u2084 h\u2081,\n                    show or b a, from db\u2081 h\u2082\n\n                theorem  b\u2081 {a : Prop} (h\u2081 : bot) : a :=\n                    have h\u2082 : or bot a, from or.d\u2081 h\u2081,\n                    have h\u2083 : or a bot, from or.d\u2083 h\u2082,\n                    show a, from db\u2081 h\u2083\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- `\u03c3` is the type of the state that the validator affects;\n- `\u03b1` is the output type, which is currently not used (set to [`Unit`]).\n-/\nabbrev Validator\n  (In : Type)\n  (\u03c3 : Type)\n  (\u03b1 : Type)\n:=\n  In \u2192 EStateM String \u03c3 \u03b1\n\n\n\n/-- `M`ulti `Prod`uct, stores a `\u03b2` in `n` nested pairs, all with first elements in `\u03b1`.\n\nFor example, `MProd 3 Nat String` is `Nat \u00d7 (Nat \u00d7 (Nat \u00d7 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  (\u03b1 \u03b2 : Type)\n: Type :=\n  match n with\n  | 0 => \u03b2\n  | n + 1 => \u03b1 \u00d7 (MProd n \u03b1 \u03b2)\n\nexample :\n  MProd 3 Nat String\n  =\n  (Nat \u00d7 Nat \u00d7 Nat \u00d7 String)\n:=\n  rfl\n\n-- pattern matching works too :D\nexample : MProd 3 Nat String \u2192 String\n| (_i, _j, _k, s) => s\n\n\n/-- Builds a `\u03bc (MProd min \u03b1 \u03b2)` from `\u03b1` and `\u03b2` getters. -/\ndef MProd.build\n  {\u03bc : Type \u2192 Type}\n  [Monad \u03bc]\n  (get\u03b1 : \u03bc \u03b1)\n  (get\u03b2 : \u03bc \u03b2)\n  (min : Nat)\n: \u03bc <| MProd min \u03b1 \u03b2 :=\n  match min with\n  | 0 =>\n    get\u03b2\n  | min + 1 =>\n    do\n      let a \u2190 get\u03b1\n      let tail \u2190 MProd.build get\u03b1 get\u03b2 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! \"{\u00b7}]\")\n      |>.getD\n        \"\u221e[\"\n    s! \"[{self.min}, {max}\"\n\nnamespace ArgSpec.Bounds\n  /-- The interval `[min, max]` with `min \u2264 max`. -/\n  def between\n    (min max : Nat)\n    -- (_legal : min \u2264 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, \u221e[` -/\n  def atLeast\n    (min : Nat)\n  : Bounds where\n    min := min\n    max := none\n\n  example : s! \"{atLeast 0}\" = \"[0, \u221e[\" := rfl\n  example : s! \"{atLeast 7}\" = \"[7, \u221e[\" := 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 `\u27e6` (`\\[[`), `\u27e7` (`\\[[`) and `\u221e` (`\\infty`). -/\n  namespace Dsl\n    local syntax \"\u27e6\" term \", \" term \"\u27e7\" : term\n    local syntax \"\u27e6\" term \", \" \"\u221e\" \"\u27e7\" : term\n    macro_rules\n    | `(\u27e6 $min, $max \u27e7) =>\n      `(ArgSpec.Bounds.between $min $max)\n    | `(\u27e6 $min, \u221e \u27e7) =>\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    (\u03c3 : Type)\n    (\u03b1 : Type)\n  : Type :=\n    Validator bounds.MProd \u03c3 \u03b1\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      {\u03c3 : outParam Type}\n    : (bounds.Validator \u03c3 Unit) \u2192 IParseM (EStateM String \u03c3 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 \u2190\n                    MProd.buildExact getArg min\n                  pure <| action input\n        | false =>\n          simp\n          exact\n            fun action =>\n              do\n                let input \u2190\n                  MProd.buildMinOnly getArg getAll bounds.min\n                pure <| action input\n  end MProdBuild\nend ArgSpec.Bounds\n\n\n\nstructure ArgSpec\n  (\u03c3 : Type)\nextends\n  ArgSpec.Bounds\nwhere\n  validator :\n    toBounds.Validator \u03c3 Unit\n\nsection ArgSpec\n  variable\n    {\u03c3 : Type}\n    (self : @&ArgSpec \u03c3)\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 \u03b1 :=\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 (\u03c3 : Type) where\n  desc : String\nderiving Repr, BEq\n\n/-- Adds short and/or long names to [`Flag0`]. -/\nstructure Flag1 (\u03c3 : Type)\nextends Flag0 \u03c3\nwhere\n  short : Option Char\n  long : Option String\nderiving Repr, BEq\n\n/-- Adds cardinality bounds to [`Flag1`]. -/\nstructure Flag2 (\u03c3 : Type)\nextends Flag1 \u03c3\nwhere\n  bounds : ArgSpec.Bounds\nderiving Repr, BEq\n\n/-- Adds arguments specification to [`Flag1`], but **built** from [`Flag2`]. -/\nstructure Flag\n  (\u03c3 : Type)\n-- extends Flag1 \u03c3\nwhere\n  desc : String\n  short : Option Char\n  long : Option String\n  args: ArgSpec \u03c3\n\n\n\nnamespace Flag0\n  variable (self : Flag0 \u03c3)\n\n  /-- Sets the flag's short name. -/\n  def withShort (short : Option Char) : Flag1 \u03c3 := {\n      self with\n        short\n        long := none\n  }\n\n  /-- Sets the flag's long name. -/\n  def withLong (long : Option String) : Flag1 \u03c3 := {\n    self with\n      short := none\n      long\n  }\nend Flag0\n\nnamespace Flag1\n  variable (self : Flag1 \u03c3)\n\n  /-- Sets the flag's short name. -/\n  def withShort (short : Option Char) : Flag1 \u03c3 := {\n    self with short\n  }\n\n  /-- Sets the flag's long name. -/\n  def withLong (long : Option String) : Flag1 \u03c3 := {\n    self with long\n  }\n\n  /-- Specifies the number of arguments expected as an interval. -/\n  def argsIn (bounds : ArgSpec.Bounds) : Flag2 \u03c3 := {\n    self with bounds\n  }\n\n  /-- Specifies an arbitrary number of arguments greater than `min`. -/\n  def argsAtLeast (min : Nat) : Flag2 \u03c3 := {\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 \u03c3 := {\n    self with\n      bounds := ArgSpec.Bounds.atMost max\n  }\n\n  /-- Specifies a precise number of arguments. -/\n  def argsTake (n : Nat) : Flag2 \u03c3 := {\n    self with\n      bounds := ArgSpec.Bounds.exact n\n  }\n\n  def effect\n    (validator : ArgSpec.Bounds.zero.Validator \u03c3 Unit)\n  : Flag \u03c3 := {\n    self with\n      args := \u27e8ArgSpec.Bounds.zero, validator\u27e9\n  }\nend Flag1\n\nnamespace Flag2\n  variable (self : Flag2 \u03c3)\n\n  def effect\n    (validator : self.bounds.Validator \u03c3 Unit)\n  : Flag \u03c3 := {\n    self.toFlag1 with\n      args := \u27e8self.bounds, validator\u27e9\n  }\nend Flag2\n\nnamespace Flag\n  def withDesc (desc : String) : Flag0 \u03c3 :=\n    \u27e8desc\u27e9\n\n  -- def adapt\n  --   (self : Flag \u03c3)\n  --   (adaptor : EStateM String \u03c3 Unit \u2192 EStateM String \u03c3' Unit)\n  -- : Flag \u03c3' :=\n  --   let validator : self.args.bounds.Validator \u03c3' 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  --       \u00b7 simp [h_max] at validator\n  --         simp\n  --         intro input\n  --         apply adaptor\n  --         apply validator input\n  --       \u00b7 simp [h_max] at validator\n  --         simp\n  --         sorry\n  --   let args : ArgSpec \u03c3' :=\n  --     \u27e8self.args.bounds, fun i =>\n  --       adaptor \u2218 self.args.validator\n  --     \u27e9\n  --   { self.toFlag1 with args := \u27e8self.args.bounds, fun i => self.validator i |> adaptor\u27e9 }\nend Flag\n\n\n\nstructure Flags (\u03c3 : Type) where\nprotected innerMk ::\n  flags : Array (Flag \u03c3)\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 \u03c3 :=\n    \u27e8Array.empty, Std.mkHashMap 0, Std.mkHashMap 0\u27e9\n\n  def Flags.debug\n    (flags : Flags \u03c3)\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 \u03c3))\n  : Except String <| Flags \u03c3 :=\n    do\n      let (short, long) \u2190\n        flags.foldlIdx! foldl init\n      pure \u27e8flags, short, long\u27e9\n  where\n    init := (\n      Std.mkHashMap flags.size,\n      Std.mkHashMap flags.size\n    )\n    foldl (state : (HashMap _ _ \u00d7 HashMap _ _)) idx (flag : Flag \u03c3) :=\n      do\n        let (short, long) :=\n          state\n        let short \u2190\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 \u2190\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 \u03c3)\n  : Except String <| Flags \u03c3 :=\n    do\n      let flags \u2190\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  (\u03c3 : Type)\n:=\n  Command (Flags \u03c3)\n\ndef Com.mk\n  {\u03c3 : Type}\n  (name : String)\n  (flags : Flags \u03c3)\n: Com \u03c3 :=\n  \u27e8name, flags\u27e9\n\ndef Com.mkM\n  {\u03bc : Type \u2192 Type}\n  [Monad \u03bc]\n  {\u03c3 : Type}\n  (name : String)\n  (flags : \u03bc <| Flags \u03c3)\n: \u03bc <| Com \u03c3 :=\n  do\n    pure \u27e8name, \u2190flags\u27e9\n\ninstance instInhabitedCom\n  [Inhabited \u03c3]\n: Inhabited <| Com \u03c3 where\n  default := \u27e8\"default\", Flags.empty\u27e9\n\n\n\nsection builder\n  /-- Stores an array of [`Flag`]s. -/\n  abbrev Com.Builder\n    (\u03c3 : Type)\n  :=\n    Command (Array <| Flag \u03c3)\n\n  /-- Empty constructor. -/\n  def Com.Builder.empty\n    (\u03c3 : Type)\n    (name : String)\n  : Com.Builder \u03c3 :=\n    \u27e8name, Array.empty\u27e9\n\n  /-- Pushes a flag. -/\n  def Com.Builder.withFlag\n    (self : Com.Builder \u03c3)\n    (flag : Flag \u03c3)\n  : Com.Builder \u03c3 :=\n    { self with\n      flags := self.flags.push flag\n    }\n\n  /-- Adds some flags. -/\n  def Com.Builder.withFlags\n    (self : Com.Builder \u03c3)\n    (flags : List (Flag \u03c3))\n  : Com.Builder \u03c3 :=\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 \u03c3)\n  : Except String <| Com \u03c3 :=\n    do\n      let flags \u2190\n        Flags.mk self.flags\n      pure \u27e8self.name, flags\u27e9\n\n  /-- Type of flags accepted by a builder. -/\n  protected def Com.Builder.Flag\n    (_self : Com.Builder \u03c3)\n  : Type :=\n    Flag \u03c3\nend builder\n\n\n\nsection Com\n  /-- Constructor for [`Com.Builder`]. -/\n  def Com.mkBuilder\n    (\u03c3 : Type)\n    (name : String)\n  : Com.Builder \u03c3 :=\n    Com.Builder.empty \u03c3 name\n\n  variable\n    (self : Com \u03c3)\n\n  def Com.shortOf\n    (short : String)\n    : IParseM (Flag \u03c3)\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 \u03c3)\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 \u03c3 :=\n  --   do\n  --     let flag \u2190\n  --       self.shortOf short\n      \n    \n\n  -- def Com.run\n  --   (self : Com \u03c3)\n  --   (parser : Parse)\n  -- : ParseM \u03c3 :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes H\u00f6lzl, 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, `\u03b9`, `\u03ba`, `n` and `m` are finite\ntypes used for indexing.\n\n * `linear_map.to_matrix`: given bases `v\u2081 : \u03b9 \u2192 M\u2081` and `v\u2082 : \u03ba \u2192 M\u2082`,\n   the `R`-linear equivalence from `M\u2081 \u2192\u2097[R] M\u2082` to `matrix \u03ba \u03b9 R`\n * `matrix.to_lin`: the inverse of `linear_map.to_matrix`\n * `linear_map.to_matrix'`: the `R`-linear equivalence from `(n \u2192 R) \u2192\u2097[R] (m \u2192 R)`\n   to `matrix n m R` (with the standard basis on `n \u2192 R` and `m \u2192 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 \u2192 R) (m \u2192 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 \u2192 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 \u2192 R) \u2192\u2097[R] (m \u2192 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 \u2192 R) (m \u2192 R)) (matrix m n R) :=\n  linear_equiv.mk\n    (fun (f : linear_map R (n \u2192 R) (m \u2192 R)) (i : m) (j : n) =>\n      coe_fn f (coe_fn (linear_map.std_basis R (fun (\u1fb0 : 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 \u2192 R) \u2192\u2097[R] (m \u2192 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 \u2192 R) (m \u2192 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 \u2192 R) (m \u2192 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 \u2192 R) (m \u2192 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 \u2192 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 \u2192 R) (m \u2192 R)) (g : linear_map R (l \u2192 R) (n \u2192 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 \u2192 R) (m \u2192 R)) (g : linear_map R (m \u2192 R) (m \u2192 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\u2081` and `M\u2082` over a commutative ring `R`, we get a linear\nequivalence between linear maps `M\u2081 \u2192\u2097 M\u2082` 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) : linear_equiv R (linear_map R M\u2081 M\u2082) (matrix m n R) :=\n  linear_equiv.trans (linear_equiv.arrow_congr (is_basis.equiv_fun hv\u2081) (is_basis.equiv_fun hv\u2082)) linear_map.to_matrix'\n\n/-- Given bases of two modules `M\u2081` and `M\u2082` over a commutative ring `R`, we get a linear\nequivalence between matrices over `R` indexed by the bases and linear maps `M\u2081 \u2192\u2097 M\u2082`. -/\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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) : linear_equiv R (matrix m n R) (linear_map R M\u2081 M\u2082) :=\n  linear_equiv.symm (linear_map.to_matrix hv\u2081 hv\u2082)\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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) : linear_equiv.symm (linear_map.to_matrix hv\u2081 hv\u2082) = matrix.to_lin hv\u2081 hv\u2082 :=\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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) : linear_equiv.symm (matrix.to_lin hv\u2081 hv\u2082) = linear_map.to_matrix hv\u2081 hv\u2082 :=\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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) (f : linear_map R M\u2081 M\u2082) : coe_fn (matrix.to_lin hv\u2081 hv\u2082) (coe_fn (linear_map.to_matrix hv\u2081 hv\u2082) 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) (M : matrix m n R) : coe_fn (linear_map.to_matrix hv\u2081 hv\u2082) (coe_fn (matrix.to_lin hv\u2081 hv\u2082) 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) (f : linear_map R M\u2081 M\u2082) (i : m) (j : n) : coe_fn (linear_map.to_matrix hv\u2081 hv\u2082) f i j = coe_fn (is_basis.equiv_fun hv\u2082) (coe_fn f (v\u2081 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) (f : linear_map R M\u2081 M\u2082) (j : n) : matrix.transpose (coe_fn (linear_map.to_matrix hv\u2081 hv\u2082) f) j = coe_fn (is_basis.equiv_fun hv\u2082) (coe_fn f (v\u2081 j)) :=\n  funext fun (i : m) => linear_map.to_matrix_apply hv\u2081 hv\u2082 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) (f : linear_map R M\u2081 M\u2082) (i : m) (j : n) : coe_fn (linear_map.to_matrix hv\u2081 hv\u2082) f i j = coe_fn (coe_fn (is_basis.repr hv\u2082) (coe_fn f (v\u2081 j))) i :=\n  linear_map.to_matrix_apply hv\u2081 hv\u2082 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) (f : linear_map R M\u2081 M\u2082) (j : n) : matrix.transpose (coe_fn (linear_map.to_matrix hv\u2081 hv\u2082) f) j = \u21d1(coe_fn (is_basis.repr hv\u2082) (coe_fn f (v\u2081 j))) :=\n  linear_map.to_matrix_transpose_apply hv\u2081 hv\u2082 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) (M : matrix m n R) (v : M\u2081) : coe_fn (coe_fn (matrix.to_lin hv\u2081 hv\u2082) M) v =\n  finset.sum finset.univ fun (j : m) => matrix.mul_vec M (coe_fn (is_basis.equiv_fun hv\u2081) v) j \u2022 v\u2082 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) (M : matrix m n R) (i : n) : coe_fn (coe_fn (matrix.to_lin hv\u2081 hv\u2082) M) (v\u2081 i) = finset.sum finset.univ fun (j : m) => M j i \u2022 v\u2082 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\u2081 : Type u_5} [add_comm_group M\u2081] [module R M\u2081] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) : coe_fn (linear_map.to_matrix hv\u2081 hv\u2081) 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\u2081 : Type u_5} [add_comm_group M\u2081] [module R M\u2081] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) : coe_fn (matrix.to_lin hv\u2081 hv\u2081) 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) [DecidableEq M\u2081] [DecidableEq M\u2082] (f : linear_map R M\u2081 M\u2082) (k : m) (i : n) : coe_fn (linear_map.to_matrix (is_basis.range hv\u2081) (is_basis.range hv\u2082)) f\n    { val := v\u2082 k, property := set.mem_range_self k } { val := v\u2081 i, property := set.mem_range_self i } =\n  coe_fn (linear_map.to_matrix hv\u2081 hv\u2082) 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) {M\u2083 : Type u_7} [add_comm_group M\u2083] [module R M\u2083] {v\u2083 : l \u2192 M\u2083} (hv\u2083 : is_basis R v\u2083) [DecidableEq m] (f : linear_map R M\u2082 M\u2083) (g : linear_map R M\u2081 M\u2082) : coe_fn (linear_map.to_matrix hv\u2081 hv\u2083) (linear_map.comp f g) =\n  matrix.mul (coe_fn (linear_map.to_matrix hv\u2082 hv\u2083) f) (coe_fn (linear_map.to_matrix hv\u2081 hv\u2082) 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\u2081 : Type u_5} [add_comm_group M\u2081] [module R M\u2081] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) (f : linear_map R M\u2081 M\u2081) (g : linear_map R M\u2081 M\u2081) : coe_fn (linear_map.to_matrix hv\u2081 hv\u2081) (f * g) =\n  matrix.mul (coe_fn (linear_map.to_matrix hv\u2081 hv\u2081) f) (coe_fn (linear_map.to_matrix hv\u2081 hv\u2081) 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\u2081 : Type u_5} {M\u2082 : Type u_6} [add_comm_group M\u2081] [add_comm_group M\u2082] [module R M\u2081] [module R M\u2082] {v\u2081 : n \u2192 M\u2081} (hv\u2081 : is_basis R v\u2081) {v\u2082 : m \u2192 M\u2082} (hv\u2082 : is_basis R v\u2082) {M\u2083 : Type u_7} [add_comm_group M\u2083] [module R M\u2083] {v\u2083 : l \u2192 M\u2083} (hv\u2083 : is_basis R v\u2083) [DecidableEq m] (A : matrix l m R) (B : matrix m n R) : coe_fn (matrix.to_lin hv\u2081 hv\u2083) (matrix.mul A B) =\n  linear_map.comp (coe_fn (matrix.to_lin hv\u2082 hv\u2083) A) (coe_fn (matrix.to_lin hv\u2081 hv\u2082) B) := sorry\n\n/-- From a basis `e : \u03b9 \u2192 M` and a family of vectors `v : \u03b9' \u2192 M`, make the matrix whose columns\nare the vectors `v i` written in the basis `e`. -/\ndef is_basis.to_matrix {\u03b9 : Type u_1} {\u03b9' : Type u_2} [fintype \u03b9] [fintype \u03b9'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) (v : \u03b9' \u2192 M) : matrix \u03b9 \u03b9' R :=\n  fun (i : \u03b9) (j : \u03b9') => coe_fn (is_basis.equiv_fun he) (v j) i\n\nnamespace is_basis\n\n\ntheorem to_matrix_apply {\u03b9 : Type u_1} {\u03b9' : Type u_2} [fintype \u03b9] [fintype \u03b9'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) (v : \u03b9' \u2192 M) (i : \u03b9) (j : \u03b9') : to_matrix he v i j = coe_fn (equiv_fun he) (v j) i :=\n  rfl\n\ntheorem to_matrix_transpose_apply {\u03b9 : Type u_1} {\u03b9' : Type u_2} [fintype \u03b9] [fintype \u03b9'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) (v : \u03b9' \u2192 M) (j : \u03b9') : matrix.transpose (to_matrix he v) j = \u21d1(coe_fn (repr he) (v j)) :=\n  funext fun (_x : \u03b9) => rfl\n\ntheorem to_matrix_eq_to_matrix_constr {\u03b9 : Type u_1} [fintype \u03b9] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) [DecidableEq \u03b9] (v : \u03b9 \u2192 M) : to_matrix he v = coe_fn (linear_map.to_matrix he he) (constr he v) := sorry\n\n@[simp] theorem to_matrix_self {\u03b9 : Type u_1} [fintype \u03b9] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) [DecidableEq \u03b9] : to_matrix he e = 1 := sorry\n\ntheorem to_matrix_update {\u03b9 : Type u_1} {\u03b9' : Type u_2} [fintype \u03b9] [fintype \u03b9'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) (v : \u03b9' \u2192 M) (j : \u03b9') [DecidableEq \u03b9'] (x : M) : to_matrix he (function.update v j x) = matrix.update_column (to_matrix he v) j \u21d1(coe_fn (repr he) x) := sorry\n\n@[simp] theorem sum_to_matrix_smul_self {\u03b9 : Type u_1} {\u03b9' : Type u_2} [fintype \u03b9] [fintype \u03b9'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) (v : \u03b9' \u2192 M) (j : \u03b9') : (finset.sum finset.univ fun (i : \u03b9) => to_matrix he v i j \u2022 e i) = v j := sorry\n\n@[simp] theorem to_lin_to_matrix {\u03b9 : Type u_1} {\u03b9' : Type u_2} [fintype \u03b9] [fintype \u03b9'] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) (v : \u03b9' \u2192 M) [DecidableEq \u03b9'] (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 : \u03b9 \u2192 M`, build a linear equivalence between families of vectors `v : \u03b9 \u2192 M`,\nand matrices, making the matrix whose columns are the vectors `v i` written in the basis `e`. -/\ndef to_matrix_equiv {\u03b9 : Type u_1} [fintype \u03b9] {R : Type u_3} {M : Type u_4} [comm_ring R] [add_comm_group M] [module R M] {e : \u03b9 \u2192 M} (he : is_basis R e) : linear_equiv R (\u03b9 \u2192 M) (matrix \u03b9 \u03b9 R) :=\n  linear_equiv.mk (to_matrix he) sorry sorry\n    (fun (m : matrix \u03b9 \u03b9 R) (j : \u03b9) => finset.sum finset.univ fun (i : \u03b9) => m i j \u2022 e i) sorry sorry\n\nend is_basis\n\n\n@[simp] theorem is_basis_to_matrix_mul_linear_map_to_matrix {\u03b9 : Type u_1} {\u03b9' : Type u_2} [fintype \u03b9] [fintype \u03b9'] {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' : \u03b9' \u2192 M} {c : \u03b9 \u2192 N} {c' : \u03b9' \u2192 N} (hb' : is_basis R b') (hc : is_basis R c) (hc' : is_basis R c') (f : linear_map R M N) [DecidableEq \u03b9'] : 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 {\u03b9 : Type u_1} {\u03b9' : Type u_2} [fintype \u03b9] [fintype \u03b9'] {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 : \u03b9 \u2192 M} {b' : \u03b9' \u2192 M} {c' : \u03b9' \u2192 N} (hb : is_basis R b) (hb' : is_basis R b') (hc' : is_basis R c') (f : linear_map R M N) [DecidableEq \u03b9] [DecidableEq \u03b9'] : 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'] {\u03b9 : Type u_3} [DecidableEq \u03b9] [fintype \u03b9] {v : \u03b9 \u2192 M} {v' : \u03b9 \u2192 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') \u2191f)) := 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'] {\u03b9 : Type u_3} [DecidableEq \u03b9] [fintype \u03b9] {v : \u03b9 \u2192 M} {v' : \u03b9 \u2192 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 \u21d1f sorry sorry \u21d1(coe_fn (matrix.to_lin hv' hv) (coe_fn (linear_map.to_matrix hv hv') f\u207b\u00b9)) 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] {\u03b9 : Type u_3} [DecidableEq \u03b9] [fintype \u03b9] {e : \u03b9 \u2192 M} (he : is_basis R e) : alternating_map R M R \u03b9 :=\n  alternating_map.mk (fun (v : (i : \u03b9) \u2192 (fun (i : \u03b9) => 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] {\u03b9 : Type u_3} [DecidableEq \u03b9] [fintype \u03b9] {e : \u03b9 \u2192 M} (he : is_basis R e) (v : \u03b9 \u2192 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] {\u03b9 : Type u_3} [DecidableEq \u03b9] [fintype \u03b9] {e : \u03b9 \u2192 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] {\u03b9 : Type u_3} [DecidableEq \u03b9] [fintype \u03b9] {e : \u03b9 \u2192 M} (he : is_basis R e) {v : \u03b9 \u2192 M} : is_basis R v \u2194 is_unit (coe_fn (is_basis.det he) v) := sorry\n\n@[simp] theorem linear_map.to_matrix_transpose {K : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {\u03b9\u2081 : Type u_4} {\u03b9\u2082 : Type u_5} [field K] [add_comm_group V\u2081] [vector_space K V\u2081] [add_comm_group V\u2082] [vector_space K V\u2082] [fintype \u03b9\u2081] [fintype \u03b9\u2082] [DecidableEq \u03b9\u2081] [DecidableEq \u03b9\u2082] {B\u2081 : \u03b9\u2081 \u2192 V\u2081} (h\u2081 : is_basis K B\u2081) {B\u2082 : \u03b9\u2082 \u2192 V\u2082} (h\u2082 : is_basis K B\u2082) (u : linear_map K V\u2081 V\u2082) : coe_fn (linear_map.to_matrix (is_basis.dual_basis_is_basis h\u2082) (is_basis.dual_basis_is_basis h\u2081))\n    (coe_fn module.dual.transpose u) =\n  matrix.transpose (coe_fn (linear_map.to_matrix h\u2081 h\u2082) u) := sorry\n\ntheorem linear_map.to_matrix_symm_transpose {K : Type u_1} {V\u2081 : Type u_2} {V\u2082 : Type u_3} {\u03b9\u2081 : Type u_4} {\u03b9\u2082 : Type u_5} [field K] [add_comm_group V\u2081] [vector_space K V\u2081] [add_comm_group V\u2082] [vector_space K V\u2082] [fintype \u03b9\u2081] [fintype \u03b9\u2082] [DecidableEq \u03b9\u2081] [DecidableEq \u03b9\u2082] {B\u2081 : \u03b9\u2081 \u2192 V\u2081} (h\u2081 : is_basis K B\u2081) {B\u2082 : \u03b9\u2082 \u2192 V\u2082} (h\u2082 : is_basis K B\u2082) (M : matrix \u03b9\u2081 \u03b9\u2082 K) : coe_fn (linear_equiv.symm (linear_map.to_matrix (is_basis.dual_basis_is_basis h\u2081) (is_basis.dual_basis_is_basis h\u2082)))\n    (matrix.transpose M) =\n  coe_fn module.dual.transpose (coe_fn (matrix.to_lin h\u2082 h\u2081) 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 \u2192 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 = \u2191(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 \u2192 R) : linear_map.comp (linear_map.proj i) (coe_fn to_lin' (diagonal w)) = w i \u2022 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 \u2192 R) (i : n) : linear_map.comp (coe_fn to_lin' (diagonal w)) (linear_map.std_basis R (fun (\u1fb0 : n) => R) i) =\n  w i \u2022 linear_map.std_basis R (fun (\u1fb0 : 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 \u2192 R) : coe_fn to_lin' (diagonal w) = linear_map.pi fun (i : n) => w i \u2022 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 \u2192 R) (n \u2192 R) :=\n  (fun (h' : is_unit (det P)) =>\n      linear_equiv.mk (linear_map.to_fun (coe_fn to_lin' P)) sorry sorry \u21d1(coe_fn to_lin' (P\u207b\u00b9)) 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) : \u2191(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) : \u2191(linear_equiv.symm (to_linear_equiv P h)) = coe_fn to_lin' (P\u207b\u00b9) :=\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 \u2192 K) (v : n \u2192 K) : rank (coe_fn to_lin' (vec_mul_vec w v)) \u2264 1 := sorry\n\ntheorem ker_diagonal_to_lin' {m : Type u_1} [fintype m] {K : Type u} [field K] [DecidableEq m] (w : m \u2192 K) : linear_map.ker (coe_fn to_lin' (diagonal w)) =\n  supr\n    fun (i : m) =>\n      supr fun (H : i \u2208 set_of fun (i : m) => w i = 0) => linear_map.range (linear_map.std_basis K (fun (\u1fb0 : m) => K) i) := sorry\n\ntheorem range_diagonal {m : Type u_1} [fintype m] {K : Type u} [field K] [DecidableEq m] (w : m \u2192 K) : linear_map.range (coe_fn to_lin' (diagonal w)) =\n  supr\n    fun (i : m) =>\n      supr fun (H : i \u2208 set_of fun (i : m) => w i \u2260 0) => linear_map.range (linear_map.std_basis K (fun (\u1fb0 : 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 \u2192 K) : rank (coe_fn to_lin' (diagonal w)) = \u2191(fintype.card (Subtype fun (i : m) => w i \u2260 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') : matrix m n R \u2243 matrix m' n' R :=\n  equiv.mk (fun (M : matrix m n R) (i : m') (j : n') => M (coe_fn (equiv.symm e\u2098) i) (coe_fn (equiv.symm e\u2099) j))\n    (fun (M : matrix m' n' R) (i : m) (j : n) => M (coe_fn e\u2098 i) (coe_fn e\u2099 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') (M : matrix m n R) : coe_fn (reindex e\u2098 e\u2099) M = fun (i : m') (j : n') => M (coe_fn (equiv.symm e\u2098) i) (coe_fn (equiv.symm e\u2099) 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') (M : matrix m' n' R) : coe_fn (equiv.symm (reindex e\u2098 e\u2099)) M = fun (i : m) (j : n) => M (coe_fn e\u2098 i) (coe_fn e\u2099 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') : linear_equiv R (matrix m n R) (matrix m' n' R) :=\n  linear_equiv.mk (equiv.to_fun (reindex e\u2098 e\u2099)) sorry sorry (equiv.inv_fun (reindex e\u2098 e\u2099)) 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') (M : matrix m n R) : coe_fn (reindex_linear_equiv e\u2098 e\u2099) M = fun (i : m') (j : n') => M (coe_fn (equiv.symm e\u2098) i) (coe_fn (equiv.symm e\u2099) 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') (M : matrix m' n' R) : coe_fn (linear_equiv.symm (reindex_linear_equiv e\u2098 e\u2099)) M = fun (i : m) (j : n) => M (coe_fn e\u2098 i) (coe_fn e\u2099 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') (e\u2097 : l \u2243 l') (M : matrix m n R) (N : matrix n l R) : matrix.mul (coe_fn (reindex_linear_equiv e\u2098 e\u2099) M) (coe_fn (reindex_linear_equiv e\u2099 e\u2097) N) =\n  coe_fn (reindex_linear_equiv e\u2098 e\u2097) (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 \u2243 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 \u2243 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 \u2243 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\u2098 : m \u2243 m') (e\u2099 : n \u2243 n') (M : matrix m n R) : transpose (coe_fn (reindex e\u2098 e\u2099) M) = coe_fn (reindex e\u2099 e\u2098) (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 \u2243 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 \u2243 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 \u2243 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 \u2243 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] {\u03b9 : Type w} [DecidableEq \u03b9] [fintype \u03b9] {b : \u03b9 \u2192 M} (hb : is_basis R b) : linear_map R (linear_map R M M) R :=\n  comp (matrix.trace \u03b9 R R) \u2191(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] {\u03b9 : Type w} [DecidableEq \u03b9] [fintype \u03b9] {b : \u03b9 \u2192 M} (hb : is_basis R b) (f : linear_map R M M) : coe_fn (trace_aux R hb) f = coe_fn (matrix.trace \u03b9 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] {\u03b9 : Type w} [DecidableEq \u03b9] [fintype \u03b9] {b : \u03b9 \u2192 M} (hb : is_basis R b) {\u03ba : Type w} [DecidableEq \u03ba] [fintype \u03ba] {c : \u03ba \u2192 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] {\u03b9 : Type w} [DecidableEq \u03b9] [fintype \u03b9] {b : \u03b9 \u2192 M} (hb : is_basis R b) : trace_aux R (is_basis.range hb) = trace_aux R hb := sorry\n\n/-- where `\u03b9` and `\u03ba` 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] {\u03b9 : Type u_1} [DecidableEq \u03b9] [fintype \u03b9] {b : \u03b9 \u2192 M} (hb : is_basis R b) {\u03ba : Type u_2} [DecidableEq \u03ba] [fintype \u03ba] {c : \u03ba \u2192 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 (\u2203 (s : finset M), is_basis R fun (x : \u21a5\u2191s) => \u2191x)\n    (fun (H : \u2203 (s : finset M), is_basis R fun (x : \u21a5\u2191s) => \u2191x) => trace_aux R sorry)\n    fun (H : \u00ac\u2203 (s : finset M), is_basis R fun (x : \u21a5\u2191s) => \u2191x) => 0\n\ntheorem trace_eq_matrix_trace (R : Type u) [comm_ring R] {M : Type v} [add_comm_group M] [module R M] {\u03b9 : Type w} [fintype \u03b9] [DecidableEq \u03b9] {b : \u03b9 \u2192 M} (hb : is_basis R b) (f : linear_map R M M) : coe_fn (trace R M) f = coe_fn (matrix.trace \u03b9 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 \u2192 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\u2081 : Type u_1} {M\u2082 : Type (max u_2 u_3)} [add_comm_group M\u2081] [module R M\u2081] [add_comm_group M\u2082] [module R M\u2082] (e : linear_equiv R M\u2081 M\u2082) : alg_equiv R (module.End R M\u2081) (module.End R M\u2082) :=\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 \u2192 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 \u2192 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 \u2192 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 \u2192 R) (w : n \u2192 R) (h : \u2200 (u : n \u2192 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 \u2192 R} {w : n \u2192 R} : (\u2200 (u : n \u2192 R), matrix.dot_product v u = matrix.dot_product w u) \u2194 v = w :=\n  { mp := fun (h : \u2200 (u : n \u2192 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 \u2192 R) => h \u25b8 rfl }\n\ntheorem matrix.dot_product_eq_zero {R : Type v} [semiring R] {n : Type w} [fintype n] (v : n \u2192 R) (h : \u2200 (w : n \u2192 R), matrix.dot_product v w = 0) : v = 0 :=\n  matrix.dot_product_eq v 0 fun (u : n \u2192 R) => Eq.symm (h u) \u25b8 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 \u2192 R} : (\u2200 (w : n \u2192 R), matrix.dot_product v w = 0) \u2194 v = 0 :=\n  { mp := fun (h : \u2200 (w : n \u2192 R), matrix.dot_product v w = 0) => matrix.dot_product_eq_zero v h,\n    mpr := fun (h : v = 0) (w : n \u2192 R) => Eq.symm h \u25b8 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+ `\u03c3 : Type*` (indexing the variables)\n\n+ `R : Type*` `[comm_semiring R]` (the coefficients)\n\n-/\n\n\nnamespace MvPolynomial\n\nvariable {\u03c3 : Type _} {\u03c4 : Type _} {\u03c5 : Type _} {R : Type _} [CommSemiring R]\n\n#print MvPolynomial.comap /-\n/-- Given an algebra hom `f : mv_polynomial \u03c3 R \u2192\u2090[R] mv_polynomial \u03c4 R`\nand a variable evaluation `v : \u03c4 \u2192 R`,\n`comap f v` produces a variable evaluation `\u03c3 \u2192 R`.\n-/\nnoncomputable def comap (f : MvPolynomial \u03c3 R \u2192\u2090[R] MvPolynomial \u03c4 R) : (\u03c4 \u2192 R) \u2192 \u03c3 \u2192 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 {\u03c3 : Type.{u1}} {\u03c4 : Type.{u2}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (x : \u03c4 -> R) (i : \u03c3), Eq.{succ u3} R (MvPolynomial.comap.{u1, u2, u3} \u03c3 \u03c4 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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) => (MvPolynomial.{u2, u3} \u03c4 R _inst_1) -> R) ([anonymous].{u3, max u2 u3, u3} R (MvPolynomial.{u2, u3} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) (MvPolynomial.aeval.{u3, u3, u2} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (fun (_x : AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) => (MvPolynomial.{u1, u3} \u03c3 R _inst_1) -> (MvPolynomial.{u2, u3} \u03c4 R _inst_1)) ([anonymous].{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) f (MvPolynomial.X.{u3, u1} R \u03c3 _inst_1 i)))\nbut is expected to have type\n  forall {\u03c3 : Type.{u2}} {\u03c4 : Type.{u1}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgHom.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (x : \u03c4 -> R) (i : \u03c3), Eq.{succ u3} R (MvPolynomial.comap.{u2, u1, u3} \u03c3 \u03c4 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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (fun (_x : MvPolynomial.{u1, u3} \u03c4 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u1, u3} \u03c4 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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) R (SMulZeroClass.toSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (AddMonoid.toZero.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (AddMonoid.toAddZeroClass.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 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} \u03c4 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) R (MvPolynomial.{u1, u3} \u03c4 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} \u03c4 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _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} \u03c4 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)) R (MvPolynomial.{u1, u3} \u03c4 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} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _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} \u03c4 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c4 R _inst_1) R _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{u3} R _inst_1) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (Algebra.id.{u3} R _inst_1)))))) (MvPolynomial.aeval.{u3, u3, u1} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u2, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u3} \u03c3 R _inst_1) => MvPolynomial.{u1, u3} \u03c4 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} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (SMulZeroClass.toSMul.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (AddMonoid.toZero.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (SMulZeroClass.toSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (AddMonoid.toZero.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (AddMonoid.toAddZeroClass.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 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} \u03c4 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)))))) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)))))) (Module.toDistribMulAction.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)))) (Module.toDistribMulAction.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u2 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgHom.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.algHomClass.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) f (MvPolynomial.X.{u3, u2} R \u03c3 _inst_1 i)))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_apply MvPolynomial.comap_apply\u2093'. -/\n@[simp]\ntheorem comap_apply (f : MvPolynomial \u03c3 R \u2192\u2090[R] MvPolynomial \u03c4 R) (x : \u03c4 \u2192 R) (i : \u03c3) :\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 {\u03c3 : Type.{u1}} {R : Type.{u2}} [_inst_1 : CommSemiring.{u2} R] (x : \u03c3 -> R), Eq.{max (succ u1) (succ u2)} (\u03c3 -> R) (MvPolynomial.comap.{u1, u1, u2} \u03c3 \u03c3 R _inst_1 (AlgHom.id.{u2, max u1 u2} R (MvPolynomial.{u1, u2} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u1, u2} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u2, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u2, u2, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u2} R _inst_1))) x) x\nbut is expected to have type\n  forall {\u03c3 : Type.{u2}} {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] (x : \u03c3 -> R), Eq.{max (succ u2) (succ u1)} (\u03c3 -> R) (MvPolynomial.comap.{u2, u2, u1} \u03c3 \u03c3 R _inst_1 (AlgHom.id.{u1, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _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\u2093'. -/\n@[simp]\ntheorem comap_id_apply (x : \u03c3 \u2192 R) : comap (AlgHom.id R (MvPolynomial \u03c3 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 (\u03c3 R)\n\n/- warning: mv_polynomial.comap_id -> MvPolynomial.comap_id is a dubious translation:\nlean 3 declaration is\n  forall (\u03c3 : Type.{u1}) (R : Type.{u2}) [_inst_1 : CommSemiring.{u2} R], Eq.{max (succ u1) (succ u2)} ((\u03c3 -> R) -> \u03c3 -> R) (MvPolynomial.comap.{u1, u1, u2} \u03c3 \u03c3 R _inst_1 (AlgHom.id.{u2, max u1 u2} R (MvPolynomial.{u1, u2} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u1, u2} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u2, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u2, u2, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u2} R _inst_1)))) (id.{max (succ u1) (succ u2)} (\u03c3 -> R))\nbut is expected to have type\n  forall (\u03c3 : Type.{u2}) (R : Type.{u1}) [_inst_1 : CommSemiring.{u1} R], Eq.{max (succ u2) (succ u1)} ((\u03c3 -> R) -> \u03c3 -> R) (MvPolynomial.comap.{u2, u2, u1} \u03c3 \u03c3 R _inst_1 (AlgHom.id.{u1, max u1 u2} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)))) (id.{max (succ u2) (succ u1)} (\u03c3 -> R))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_id MvPolynomial.comap_id\u2093'. -/\ntheorem comap_id : comap (AlgHom.id R (MvPolynomial \u03c3 R)) = id :=\n  by\n  funext x\n  exact comap_id_apply x\n#align mv_polynomial.comap_id MvPolynomial.comap_id\n\nvariable {\u03c3 R}\n\n/- warning: mv_polynomial.comap_comp_apply -> MvPolynomial.comap_comp_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03c3 : Type.{u1}} {\u03c4 : Type.{u2}} {\u03c5 : Type.{u3}} {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] (f : AlgHom.{u4, max u1 u4, max u2 u4} R (MvPolynomial.{u1, u4} \u03c3 R _inst_1) (MvPolynomial.{u2, u4} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (g : AlgHom.{u4, max u2 u4, max u3 u4} R (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.{u3, u4} \u03c5 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} \u03c5 R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R \u03c5 _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R \u03c5 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (x : \u03c5 -> R), Eq.{max (succ u1) (succ u4)} (\u03c3 -> R) (MvPolynomial.comap.{u1, u3, u4} \u03c3 \u03c5 R _inst_1 (AlgHom.comp.{u4, max u1 u4, max u2 u4, max u3 u4} R (MvPolynomial.{u1, u4} \u03c3 R _inst_1) (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.{u3, u4} \u03c5 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} \u03c5 R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R \u03c5 _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R \u03c5 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) g f) x) (MvPolynomial.comap.{u1, u2, u4} \u03c3 \u03c4 R _inst_1 f (MvPolynomial.comap.{u2, u3, u4} \u03c4 \u03c5 R _inst_1 g x))\nbut is expected to have type\n  forall {\u03c3 : Type.{u3}} {\u03c4 : Type.{u2}} {\u03c5 : Type.{u1}} {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] (f : AlgHom.{u4, max u4 u3, max u4 u2} R (MvPolynomial.{u3, u4} \u03c3 R _inst_1) (MvPolynomial.{u2, u4} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (g : AlgHom.{u4, max u4 u2, max u4 u1} R (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.{u1, u4} \u03c5 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} \u03c5 R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R \u03c5 _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R \u03c5 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (x : \u03c5 -> R), Eq.{max (succ u3) (succ u4)} (\u03c3 -> R) (MvPolynomial.comap.{u3, u1, u4} \u03c3 \u03c5 R _inst_1 (AlgHom.comp.{u4, max u4 u3, max u2 u4, max u1 u4} R (MvPolynomial.{u3, u4} \u03c3 R _inst_1) (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.{u1, u4} \u03c5 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} \u03c5 R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R \u03c5 _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R \u03c5 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) g f) x) (MvPolynomial.comap.{u3, u2, u4} \u03c3 \u03c4 R _inst_1 f (MvPolynomial.comap.{u2, u1, u4} \u03c4 \u03c5 R _inst_1 g x))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_comp_apply MvPolynomial.comap_comp_apply\u2093'. -/\ntheorem comap_comp_apply (f : MvPolynomial \u03c3 R \u2192\u2090[R] MvPolynomial \u03c4 R)\n    (g : MvPolynomial \u03c4 R \u2192\u2090[R] MvPolynomial \u03c5 R) (x : \u03c5 \u2192 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  \u00b7 apply eval\u2082_hom_congr rfl rfl\n    rw [AlgHom.comp_apply]\n    suffices g = aeval fun i => g (X i) by rw [\u2190 this]\n    exact aeval_unique g\n  \u00b7 simp only [comap, aeval_eq_eval\u2082_hom, map_eval\u2082_hom, AlgHom.comp_apply]\n    refine' eval\u2082_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 {\u03c3 : Type.{u1}} {\u03c4 : Type.{u2}} {\u03c5 : Type.{u3}} {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] (f : AlgHom.{u4, max u1 u4, max u2 u4} R (MvPolynomial.{u1, u4} \u03c3 R _inst_1) (MvPolynomial.{u2, u4} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (g : AlgHom.{u4, max u2 u4, max u3 u4} R (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.{u3, u4} \u03c5 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} \u03c5 R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R \u03c5 _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R \u03c5 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))), Eq.{max (max (succ u3) (succ u4)) (succ u1) (succ u4)} ((\u03c5 -> R) -> \u03c3 -> R) (MvPolynomial.comap.{u1, u3, u4} \u03c3 \u03c5 R _inst_1 (AlgHom.comp.{u4, max u1 u4, max u2 u4, max u3 u4} R (MvPolynomial.{u1, u4} \u03c3 R _inst_1) (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.{u3, u4} \u03c5 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} \u03c5 R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R \u03c5 _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R \u03c5 _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)} (\u03c5 -> R) (\u03c4 -> R) (\u03c3 -> R) (MvPolynomial.comap.{u1, u2, u4} \u03c3 \u03c4 R _inst_1 f) (MvPolynomial.comap.{u2, u3, u4} \u03c4 \u03c5 R _inst_1 g))\nbut is expected to have type\n  forall {\u03c3 : Type.{u3}} {\u03c4 : Type.{u2}} {\u03c5 : Type.{u1}} {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] (f : AlgHom.{u4, max u4 u3, max u4 u2} R (MvPolynomial.{u3, u4} \u03c3 R _inst_1) (MvPolynomial.{u2, u4} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))) (g : AlgHom.{u4, max u4 u2, max u4 u1} R (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.{u1, u4} \u03c5 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} \u03c5 R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R \u03c5 _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R \u03c5 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1))), Eq.{max (max (succ u3) (succ u1)) (succ u4)} ((\u03c5 -> R) -> \u03c3 -> R) (MvPolynomial.comap.{u3, u1, u4} \u03c3 \u03c5 R _inst_1 (AlgHom.comp.{u4, max u4 u3, max u2 u4, max u1 u4} R (MvPolynomial.{u3, u4} \u03c3 R _inst_1) (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.{u1, u4} \u03c5 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u3, u4} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u4, u3} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u4} (MvPolynomial.{u2, u4} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u4, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u1, u4} \u03c5 R _inst_1) (MvPolynomial.commSemiring.{u4, u1} R \u03c5 _inst_1)) (MvPolynomial.algebra.{u4, u4, u3} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u4} R _inst_1)) (MvPolynomial.algebra.{u4, u4, u1} R R \u03c5 _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)} (\u03c5 -> R) (\u03c4 -> R) (\u03c3 -> R) (MvPolynomial.comap.{u3, u2, u4} \u03c3 \u03c4 R _inst_1 f) (MvPolynomial.comap.{u2, u1, u4} \u03c4 \u03c5 R _inst_1 g))\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_comp MvPolynomial.comap_comp\u2093'. -/\ntheorem comap_comp (f : MvPolynomial \u03c3 R \u2192\u2090[R] MvPolynomial \u03c4 R)\n    (g : MvPolynomial \u03c4 R \u2192\u2090[R] MvPolynomial \u03c5 R) : comap (g.comp f) = comap f \u2218 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 \u03c3 R \u2192\u2090[R] MvPolynomial \u03c3 R) (hf : \u2200 \u03c6, f \u03c6 = \u03c6)\n    (x : \u03c3 \u2192 R) : comap f x = x := by\n  convert comap_id_apply x\n  ext1 \u03c6\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 {\u03c3 : Type.{u1}} {\u03c4 : Type.{u2}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : \u03c3 -> \u03c4) (x : \u03c4 -> R), Eq.{max (succ u1) (succ u3)} (\u03c3 -> R) (MvPolynomial.comap.{u1, u2, u3} \u03c3 \u03c4 R _inst_1 (MvPolynomial.rename.{u1, u2, u3} \u03c3 \u03c4 R _inst_1 f) x) (Function.comp.{succ u1, succ u2, succ u3} \u03c3 \u03c4 R x f)\nbut is expected to have type\n  forall {\u03c3 : Type.{u3}} {\u03c4 : Type.{u1}} {R : Type.{u2}} [_inst_1 : CommSemiring.{u2} R] (f : \u03c3 -> \u03c4) (x : \u03c4 -> R), Eq.{max (succ u3) (succ u2)} (\u03c3 -> R) (MvPolynomial.comap.{u3, u1, u2} \u03c3 \u03c4 R _inst_1 (MvPolynomial.rename.{u3, u1, u2} \u03c3 \u03c4 R _inst_1 f) x) (Function.comp.{succ u3, succ u1, succ u2} \u03c3 \u03c4 R x f)\nCase conversion may be inaccurate. Consider using '#align mv_polynomial.comap_rename MvPolynomial.comap_rename\u2093'. -/\ntheorem comap_rename (f : \u03c3 \u2192 \u03c4) (x : \u03c4 \u2192 R) : comap (rename f) x = x \u2218 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 \u03c3 R \u2243\u2090[R] MvPolynomial \u03c4 R) : (\u03c4 \u2192 R) \u2243 (\u03c3 \u2192 R)\n    where\n  toFun := comap f\n  invFun := comap f.symm\n  left_inv := by\n    intro x\n    rw [\u2190 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 [\u2190 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 {\u03c3 : Type.{u1}} {\u03c4 : Type.{u2}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _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)} (\u03c4 -> R) (\u03c3 -> R)) => (\u03c4 -> R) -> \u03c3 -> R) (MvPolynomial.comapEquiv.{u1, u2, u3} \u03c3 \u03c4 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)} (\u03c4 -> R) (\u03c3 -> R)) (fun (_x : Equiv.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (\u03c4 -> R) (\u03c3 -> R)) => (\u03c4 -> R) -> \u03c3 -> R) (Equiv.hasCoeToFun.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (\u03c4 -> R) (\u03c3 -> R)) (MvPolynomial.comapEquiv.{u1, u2, u3} \u03c3 \u03c4 R _inst_1 f)) (MvPolynomial.comap.{u1, u2, u3} \u03c3 \u03c4 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} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (CoeTC\u2093.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} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.algEquivClass.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) f))\nbut is expected to have type\n  forall {\u03c3 : Type.{u2}} {\u03c4 : Type.{u1}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgEquiv.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))), Eq.{max (max (succ u2) (succ u1)) (succ u3)} (forall (a : \u03c4 -> R), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03c4 -> R) => \u03c3 -> 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)} (\u03c4 -> R) (\u03c3 -> R)) (\u03c4 -> R) (fun (_x : \u03c4 -> R) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03c4 -> R) => \u03c3 -> R) _x) (Equiv.instFunLikeEquiv.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (\u03c4 -> R) (\u03c3 -> R)) (MvPolynomial.comapEquiv.{u2, u1, u3} \u03c3 \u03c4 R _inst_1 f)) (MvPolynomial.comap.{u2, u1, u3} \u03c3 \u03c4 R _inst_1 (AlgHomClass.toAlgHom.{u3, max u2 u3, max u1 u3, max (max u2 u1) u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.instAlgEquivClassAlgEquiv.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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\u2093'. -/\n@[simp]\ntheorem comapEquiv_coe (f : MvPolynomial \u03c3 R \u2243\u2090[R] MvPolynomial \u03c4 R) :\n    (comapEquiv f : (\u03c4 \u2192 R) \u2192 \u03c3 \u2192 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 {\u03c3 : Type.{u1}} {\u03c4 : Type.{u2}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _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)} (\u03c3 -> R) (\u03c4 -> R)) => (\u03c3 -> R) -> \u03c4 -> R) (Equiv.symm.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (\u03c4 -> R) (\u03c3 -> R) (MvPolynomial.comapEquiv.{u1, u2, u3} \u03c3 \u03c4 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)} (\u03c3 -> R) (\u03c4 -> R)) (fun (_x : Equiv.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (\u03c3 -> R) (\u03c4 -> R)) => (\u03c3 -> R) -> \u03c4 -> R) (Equiv.hasCoeToFun.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (\u03c3 -> R) (\u03c4 -> R)) (Equiv.symm.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (\u03c4 -> R) (\u03c3 -> R) (MvPolynomial.comapEquiv.{u1, u2, u3} \u03c3 \u03c4 R _inst_1 f))) (MvPolynomial.comap.{u2, u1, u3} \u03c4 \u03c3 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} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (CoeTC\u2093.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} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) (AlgHom.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.algEquivClass.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))))))) (AlgEquiv.symm.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.{u2, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) f)))\nbut is expected to have type\n  forall {\u03c3 : Type.{u2}} {\u03c4 : Type.{u1}} {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] (f : AlgEquiv.{u3, max u3 u2, max u3 u1} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))), Eq.{max (max (succ u2) (succ u1)) (succ u3)} (forall (a : \u03c3 -> R), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03c3 -> R) => \u03c4 -> 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)} (\u03c3 -> R) (\u03c4 -> R)) (\u03c3 -> R) (fun (_x : \u03c3 -> R) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03c3 -> R) => \u03c4 -> R) _x) (Equiv.instFunLikeEquiv.{max (succ u2) (succ u3), max (succ u1) (succ u3)} (\u03c3 -> R) (\u03c4 -> R)) (Equiv.symm.{max (succ u1) (succ u3), max (succ u2) (succ u3)} (\u03c4 -> R) (\u03c3 -> R) (MvPolynomial.comapEquiv.{u2, u1, u3} \u03c3 \u03c4 R _inst_1 f))) (MvPolynomial.comap.{u1, u2, u3} \u03c4 \u03c3 R _inst_1 (AlgHomClass.toAlgHom.{u3, max u1 u3, max u2 u3, max (max u2 u1) u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.{u2, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.{u2, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _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} \u03c4 R _inst_1) (MvPolynomial.{u2, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1))) R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.{u2, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (AlgEquiv.instAlgEquivClassAlgEquiv.{u3, max u1 u3, max u2 u3} R (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.{u2, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)))) (AlgEquiv.symm.{u3, max u2 u3, max u1 u3} R (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.{u1, u3} \u03c4 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u2 u3} (MvPolynomial.{u2, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c4 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c4 _inst_1)) (MvPolynomial.algebra.{u3, u3, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c4 _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\u2093'. -/\n@[simp]\ntheorem comapEquiv_symm_coe (f : MvPolynomial \u03c3 R \u2243\u2090[R] MvPolynomial \u03c4 R) :\n    ((comapEquiv f).symm : (\u03c3 \u2192 R) \u2192 \u03c4 \u2192 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 {\u03b1 : Type u} [topological_space \u03b1]\nvariables (F : presheaf_of_rings \u03b1) (x : \u03b1)\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 {\u03b1 : Type u} [topological_space \u03b1]\nparameters (F : presheaf_of_rings \u03b1) (x : \u03b1)\n\n-- Add.\n\nprivate def stalk_of_rings_add_aux :\nstalk.elem F.to_presheaf x \u2192\nstalk.elem F.to_presheaf x \u2192\nstalk F.to_presheaf x :=\n\u03bb s t,\n\u27e6{U := s.U \u2229 t.U,\nHxU := \u27e8s.HxU, t.HxU\u27e9,\ns := F.res s.U _ (set.inter_subset_left _ _) s.s +\n     F.res t.U _ (set.inter_subset_right _ _) t.s}\u27e7\n\ninstance stalk_of_rings_has_add : has_add (stalk_of_rings F x) :=\n{ add := quotient.lift\u2082 (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 \u27e8U1, \u27e8HxU1, \u27e8HU1a1U, HU1b1U, HresU1\u27e9\u27e9\u27e9,\n    rcases H2 with \u27e8U2, \u27e8HxU2, \u27e8HU2a2U, HU2b2U, HresU2\u27e9\u27e9\u27e9,\n    apply quotient.sound,\n    use [U1 \u2229 U2, \u27e8HxU1, HxU2\u27e9],\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 \u2229 U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) =\n        (F'.res U1 (U1 \u2229 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 \u2229 U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) =\n        (F'.res U2 (U1 \u2229 U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s)))\n    := by rw HresU2,\n    repeat { rw \u2190(presheaf.Hcomp' F') at HresU1' },\n    repeat { rw \u2190(presheaf.Hcomp' F') at HresU2' },\n    repeat { rw \u2190(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\u2083 a b c _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9 \u27e8W, HxW, sW\u27e9,\n    have HUVWsub : U \u2229 V \u2229 W \u2286 U \u2229 (V \u2229 W)\n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8HxU, \u27e8HxV, HxW\u27e9\u27e9,\n    apply quotient.sound,\n    use [U \u2229 V \u2229 W, \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9],\n    use [set.subset.refl _, HUVWsub],\n    dsimp,\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { erw \u2190presheaf.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\u2082 a b _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9,\n    apply quotient.sound,\n    have HUVUV : U \u2229 V \u2286 U \u2229 V := \u03bb x HxUV, HxUV,\n    have HUVVU : U \u2229 V \u2286 V \u2229 U := \u03bb x \u27e8HxU, HxV\u27e9, \u27e8HxV, HxU\u27e9,\n    use [U \u2229 V, \u27e8HxU, HxV\u27e9, HUVUV, HUVVU],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.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\u27e6{U := opens.univ, HxU := trivial, s:= 0}\u27e7\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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUsub : U \u2286 opens.univ \u2229 U := \u03bb x HxU, \u27e8trivial, HxU\u27e9,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUsub : U \u2286 U \u2229 opens.univ := \u03bb x HxU, \u27e8HxU, trivial\u27e9,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { erw \u2190presheaf.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 \u2192\nstalk F.to_presheaf x :=\n\u03bb s, \u27e6{U := s.U, HxU := s.HxU, s := -s.s}\u27e7\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 \u27e8U, \u27e8HxU, \u27e8HUaU, HUbU, HresU\u27e9\u27e9\u27e9,\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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUUU : U \u2286 U \u2229 U := \u03bb x HxU, \u27e8HxU, HxU\u27e9,\n    have HUuniv : U \u2286 opens.univ := \u03bb x HxU, trivial,\n    use [U, HxU, HUUU, HUuniv],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.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 \u2192\nstalk.elem F.to_presheaf x \u2192\nstalk F.to_presheaf x :=\n\u03bb s t,\n\u27e6{U := s.U \u2229 t.U,\nHxU := \u27e8s.HxU, t.HxU\u27e9,\ns := F.res s.U _ (set.inter_subset_left _ _) s.s *\n     F.res t.U _ (set.inter_subset_right _ _) t.s}\u27e7\n\ninstance stalk_of_rings_has_mul : has_mul (stalk_of_rings F x) :=\n{ mul := quotient.lift\u2082 (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 \u27e8U1, \u27e8HxU1, \u27e8HU1a1U, HU1b1U, HresU1\u27e9\u27e9\u27e9,\n    rcases H2 with \u27e8U2, \u27e8HxU2, \u27e8HU2a2U, HU2b2U, HresU2\u27e9\u27e9\u27e9,\n    apply quotient.sound,\n    use [U1 \u2229 U2, \u27e8HxU1, HxU2\u27e9],\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 \u2229 U2) (set.inter_subset_left _ _) ((F'.res a1.U U1 HU1a1U) (a1.s))) =\n        (F'.res U1 (U1 \u2229 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 \u2229 U2) (set.inter_subset_right _ _) ((F'.res a2.U U2 HU2a2U) (a2.s))) =\n        (F'.res U2 (U1 \u2229 U2) (set.inter_subset_right _ _) ((F'.res b2.U U2 HU2b2U) (b2.s)))\n    := by rw HresU2,\n    repeat { rw \u2190(presheaf.Hcomp' F') at HresU1' },\n    repeat { rw \u2190(presheaf.Hcomp' F') at HresU2' },\n    repeat { rw \u2190(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\u2083 a b c _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9 \u27e8W, HxW, sW\u27e9,\n    have HUVWsub : U \u2229 V \u2229 W \u2286 U \u2229 (V \u2229 W)\n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8HxU, \u27e8HxV, HxW\u27e9\u27e9,\n    apply quotient.sound,\n    use [U \u2229 V \u2229 W, \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9],\n    use [set.subset.refl _, HUVWsub],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw \u2190presheaf.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\u2082 a b _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9,\n    apply quotient.sound,\n    have HUVUV : U \u2229 V \u2286 U \u2229 V := \u03bb x HxUV, HxUV,\n    have HUVVU : U \u2229 V \u2286 V \u2229 U := \u03bb x \u27e8HxU, HxV\u27e9, \u27e8HxV, HxU\u27e9,\n    use [U \u2229 V, \u27e8HxU, HxV\u27e9, HUVUV, HUVVU],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw \u2190presheaf.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\u27e6{U := opens.univ, HxU := trivial, s:= 1}\u27e7\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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUsub : U \u2286 opens.univ \u2229 U := \u03bb x HxU, \u27e8trivial, HxU\u27e9,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw \u2190presheaf.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 \u27e8U, HxU, sU\u27e9,\n    apply quotient.sound,\n    have HUsub : U \u2286 U \u2229 opens.univ := \u03bb x HxU, \u27e8HxU, trivial\u27e9,\n    use [U, HxU, HUsub, set.subset.refl U],\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw \u2190presheaf.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\u2083 a b c _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9 \u27e8W, HxW, sW\u27e9,\n    have HUVWsub : U \u2229 V \u2229 W \u2286 U \u2229 (V \u2229 W)\n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8HxU, \u27e8HxV, HxW\u27e9\u27e9,\n    have HUVWsub2 : U \u2229 V \u2229 W \u2286 U \u2229 V \u2229 (U \u2229 W)\n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8\u27e8HxU, HxV\u27e9, \u27e8HxU, HxW\u27e9\u27e9,\n    apply quotient.sound,\n    use [U \u2229 V \u2229 W, \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, 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 \u2190presheaf.Hcomp' },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.Hcomp' },\n    rw mul_add,\n  end,\n  right_distrib :=\n  begin\n    intros a b c,\n    refine quotient.induction_on\u2083 a b c _,\n    rintros \u27e8U, HxU, sU\u27e9 \u27e8V, HxV, sV\u27e9 \u27e8W, HxW, sW\u27e9,\n    have HUVWrfl : U \u2229 V \u2229 W \u2286 U \u2229 V \u2229 W := \u03bb x Hx, Hx,\n    have HUVWsub : U \u2229 V \u2229 W \u2286 U \u2229 W \u2229 (V \u2229 W)\n    := \u03bb x \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, \u27e8\u27e8HxU, HxW\u27e9, \u27e8HxV, HxW\u27e9\u27e9,\n    apply quotient.sound,\n    use [U \u2229 V \u2229 W, \u27e8\u27e8HxU, HxV\u27e9, HxW\u27e9, 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 \u2190presheaf.Hcomp' },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_mul },\n    repeat { rw (F.res_is_ring_hom _ _ _).map_add },\n    repeat { rw \u2190presheaf.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 {\u03b1 : Type u} [topological_space \u03b1]\nvariables (F : presheaf_of_rings \u03b1) (x : \u03b1)\n\nvariables (S : Type w) [comm_ring S] [decidable_eq S]\nvariables (G : \u03a0 U, x \u2208 U \u2192 F.F U \u2192 S) [HG : \u2200 U, \u2200 (h : x \u2208 U), is_ring_hom (G U h)]\nvariables (hg : \u2200 U V (H : U \u2286 V) r, \u2200 (h : x \u2208 U), G U h (F.res V U H r) = G V (H h) r)\n\ndef to_stalk (U : opens \u03b1) (HxU : x \u2208 U) (s : F.F U) : stalk_of_rings F x\n:= \u27e6{U := U, HxU := HxU, s := s}\u27e7\n\ninstance to_stalk.is_ring_hom (U) (HxU) : is_ring_hom (to_stalk F x U HxU) :=\n{ map_one := quotient.sound $ \u27e8U, HxU, set.subset.refl _, \u03bb 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\u27e9,\n  map_add := \u03bb y z, quotient.sound $ \u27e8U, HxU, set.subset.refl _, \u03bb x Hx, \u27e8Hx, Hx\u27e9,\n    begin\n        erw \u2190(F.res_is_ring_hom _ _ _).map_add,\n        erw presheaf.Hcomp',\n    end\u27e9,\n  map_mul := \u03bb y z, quotient.sound $ \u27e8U, HxU, set.subset.refl _, \u03bb x Hx, \u27e8Hx, Hx\u27e9,\n    begin\n        erw \u2190(F.res_is_ring_hom _ _ _).map_mul,\n        erw presheaf.Hcomp',\n    end\u27e9 }\n\ninclude hg\n\nprotected def to_stalk.rec (y : stalk_of_rings F x) : S :=\nquotient.lift_on' y (\u03bb Us, G Us.1 Us.2 Us.3) $\n\u03bb \u27e8U, HxU, s\u27e9 \u27e8V, HxV, t\u27e9 \u27e8W, HxW, HWU, HWV, Hres\u27e9,\nbegin\n    dsimp,\n    erw [\u2190hg W U HWU s HxW, \u2190hg W V HWV t HxW, Hres],\nend\n/-\nto_stalk.rec : \u03a0 {\u03b1 : Type u} [_inst_1 : topological_space \u03b1] (F : presheaf_of_rings \u03b1) (x : \u03b1) (S : Type w) [_inst_2 : comm_ring S] [_inst_3 : decidable_eq S] (G : \u03a0 (U : opens \u03b1), (F.to_presheaf).F U \u2192 S), (\u2200 (U V : opens \u03b1) (H : U \u2286 V) (r : (F.to_presheaf).F V), G U ((F.to_presheaf).res V U H r) = G V r) \u2192 stalk_of_rings F x \u2192 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 \u25b8 rfl,\n  map_add := \u03bb y z, quotient.induction_on\u2082' y z $ \u03bb \u27e8U, HxU, s\u27e9 \u27e8V, HxV, t\u27e9,\n    begin\n        have HxUV : x \u2208 U \u2229 V := \u27e8HxU, HxV\u27e9,\n        show G (U \u2229 V) HxUV (_ + _) = G _ _ _ + G _ _ _,\n        rw (HG (U \u2229 V) HxUV).map_add,\n        erw \u2190hg (U \u2229 V) U (set.inter_subset_left _ _),\n        erw \u2190hg (U \u2229 V) V (set.inter_subset_right _ _),\n    end,\n  map_mul := \u03bb y z, quotient.induction_on\u2082' y z $ \u03bb \u27e8U, HxU, s\u27e9 \u27e8V, HxV, t\u27e9,\n    begin\n        have HxUV : x \u2208 U \u2229 V := \u27e8HxU, HxV\u27e9,\n        show G (U \u2229 V) HxUV (_ * _) = G _ _ _ * G _ _ _,\n        rw (HG (U \u2229 V) HxUV).map_mul,\n        erw \u2190hg (U \u2229 V) U (set.inter_subset_left _ _),\n        erw \u2190hg (U \u2229 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 \u27f6 Z) (b : Y \u27f6 Z) [mono a] [mono b] :\n  has_limit (cospan a b) :=\nlet \u27e8P, f, haf, i\u27e9 := normal_mono_of_mono a in\nlet \u27e8Q, g, hbg, i'\u27e9 := normal_mono_of_mono b in\nlet \u27e8a', ha'\u27e9 := kernel_fork.is_limit.lift' i (kernel.\u03b9 (prod.lift f g)) $\n    calc kernel.\u03b9 (prod.lift f g) \u226b f\n        = kernel.\u03b9 (prod.lift f g) \u226b prod.lift f g \u226b limits.prod.fst : by rw prod.lift_fst\n    ... = (0 : kernel (prod.lift f g) \u27f6 P \u2a2f Q) \u226b limits.prod.fst : by rw kernel.condition_assoc\n    ... = 0 : zero_comp in\nlet \u27e8b', hb'\u27e9 := kernel_fork.is_limit.lift' i' (kernel.\u03b9 (prod.lift f g)) $\n    calc kernel.\u03b9 (prod.lift f g) \u226b g\n        = kernel.\u03b9 (prod.lift f g) \u226b (prod.lift f g) \u226b limits.prod.snd : by rw prod.lift_snd\n    ... = (0 : kernel (prod.lift f g) \u27f6 P \u2a2f Q) \u226b 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    (\u03bb s, kernel.lift (prod.lift f g) (pullback_cone.snd s \u226b b) $ prod.hom_ext\n      (calc ((pullback_cone.snd s \u226b b) \u226b prod.lift f g) \u226b limits.prod.fst\n            = pullback_cone.snd s \u226b b \u226b f : by simp only [prod.lift_fst, category.assoc]\n        ... = pullback_cone.fst s \u226b a \u226b f : by rw pullback_cone.condition_assoc\n        ... = pullback_cone.fst s \u226b 0 : by rw haf\n        ... = 0 \u226b limits.prod.fst :\n          by rw [comp_zero, zero_comp])\n      (calc ((pullback_cone.snd s \u226b b) \u226b prod.lift f g) \u226b limits.prod.snd\n            = pullback_cone.snd s \u226b b \u226b g : by simp only [prod.lift_snd, category.assoc]\n        ... = pullback_cone.snd s \u226b 0 : by rw hbg\n        ... = 0 \u226b limits.prod.snd :\n          by rw [comp_zero, zero_comp]))\n    (\u03bb s, (cancel_mono a).1 $\n      by { rw kernel_fork.\u03b9_of_\u03b9 at ha', simp [ha', pullback_cone.condition s] })\n    (\u03bb s, (cancel_mono b).1 $\n      by { rw kernel_fork.\u03b9_of_\u03b9 at hb', simp [hb'] })\n    (\u03bb s m h\u2081 h\u2082, (cancel_mono (kernel.\u03b9 (prod.lift f g))).1 $ calc m \u226b kernel.\u03b9 (prod.lift f g)\n          = m \u226b a' \u226b a : by { congr, exact ha'.symm }\n      ... = pullback_cone.fst s \u226b a : by rw [\u2190category.assoc, h\u2081]\n      ... = pullback_cone.snd s \u226b b : pullback_cone.condition s\n      ... = kernel.lift (prod.lift f g) (pullback_cone.snd s \u226b b) _ \u226b kernel.\u03b9 (prod.lift f g) :\n        by rw kernel.lift_\u03b9) }\n\nsection\n\nlocal attribute [instance] pullback_of_mono\n\n/-- The pullback of `(\ud835\udfd9 X, f)` and `(\ud835\udfd9 X, g)` -/\nprivate abbreviation P {X Y : C} (f g : X \u27f6 Y)\n  [mono (prod.lift (\ud835\udfd9 X) f)] [mono (prod.lift (\ud835\udfd9 X) g)] : C :=\npullback (prod.lift (\ud835\udfd9 X) f) (prod.lift (\ud835\udfd9 X) g)\n\n/-- The equalizer of `f` and `g` exists. -/\n@[irreducible]\nlemma has_limit_parallel_pair {X Y : C} (f g : X \u27f6 Y) : has_limit (parallel_pair f g) :=\nhave huv : (pullback.fst : P f g \u27f6 X) = pullback.snd, from\n  calc (pullback.fst : P f g \u27f6 X) = pullback.fst \u226b \ud835\udfd9 _ : eq.symm $ category.comp_id _\n    ... = pullback.fst \u226b prod.lift (\ud835\udfd9 X) f \u226b limits.prod.fst : by rw prod.lift_fst\n    ... = pullback.snd \u226b prod.lift (\ud835\udfd9 X) g \u226b 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 \u27f6 X) \u226b f = pullback.snd \u226b g, from\n  calc (pullback.fst : P f g \u27f6 X) \u226b f\n        = pullback.fst \u226b prod.lift (\ud835\udfd9 X) f \u226b limits.prod.snd : by rw prod.lift_snd\n    ... = pullback.snd \u226b prod.lift (\ud835\udfd9 X) g \u226b limits.prod.snd : by rw pullback.condition_assoc\n    ... = pullback.snd \u226b g : by rw prod.lift_snd,\nhave huu : (pullback.fst : P f g \u27f6 X) \u226b f = pullback.fst \u226b g, by rw [hvu, \u2190huv],\nhas_limit.mk { cone := fork.of_\u03b9 pullback.fst huu,\n  is_limit := fork.is_limit.mk _\n  (\u03bb s, pullback.lift (fork.\u03b9 s) (fork.\u03b9 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  (\u03bb s, by simp only [fork.\u03b9_of_\u03b9, pullback.lift_fst])\n  (\u03bb 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 \u27f6 Y) (Z : C)\n  (l : is_colimit (cokernel_cofork.of_\u03c0 (0 : Y \u27f6 Z) (show f \u226b 0 = 0, by simp))) : epi f :=\n\u27e8\u03bb P u v huv,\n begin\n  obtain \u27e8W, w, hw, hl\u27e9 := normal_mono_of_mono (equalizer.\u03b9 u v),\n  obtain \u27e8m, hm\u27e9 := equalizer.lift' f huv,\n  have hwf : f \u226b w = 0,\n  { rw [\u2190hm, category.assoc, hw, comp_zero] },\n  obtain \u27e8n, hn\u27e9 := cokernel_cofork.is_colimit.desc' l _ hwf,\n  rw [cofork.\u03c0_of_\u03c0, zero_comp] at hn,\n  haveI : is_iso (equalizer.\u03b9 u v),\n  { apply is_iso_limit_cone_parallel_pair_of_eq hn.symm hl },\n  apply (cancel_epi (equalizer.\u03b9 u v)).1,\n  exact equalizer.condition _ _\n end\u27e9\n\nsection\nvariables [has_zero_object C]\nopen_locale zero_object\n\n/-- If `f \u226b g = 0` implies `g = 0` for all `g`, then `g` is a monomorphism. -/\nlemma epi_of_zero_cancel {X Y : C} (f : X \u27f6 Y)\n  (hf : \u2200 (Z : C) (g : Y \u27f6 Z) (hgf : f \u226b 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 \u27f6 Y) (b : X \u27f6 Z) [epi a] [epi b] :\n  has_colimit (span a b) :=\nlet \u27e8P, f, hfa, i\u27e9 := normal_epi_of_epi a in\nlet \u27e8Q, g, hgb, i'\u27e9 := normal_epi_of_epi b in\nlet \u27e8a', ha'\u27e9 := cokernel_cofork.is_colimit.desc' i (cokernel.\u03c0 (coprod.desc f g)) $\n  calc f \u226b cokernel.\u03c0 (coprod.desc f g)\n      = coprod.inl \u226b coprod.desc f g \u226b cokernel.\u03c0 (coprod.desc f g) : by rw coprod.inl_desc_assoc\n  ... = coprod.inl \u226b (0 : P \u2a3f Q \u27f6 cokernel (coprod.desc f g)) : by rw cokernel.condition\n  ... = 0 : has_zero_morphisms.comp_zero _ _ in\nlet \u27e8b', hb'\u27e9 := cokernel_cofork.is_colimit.desc' i' (cokernel.\u03c0 (coprod.desc f g)) $\n  calc g \u226b cokernel.\u03c0 (coprod.desc f g)\n      = coprod.inr \u226b coprod.desc f g \u226b cokernel.\u03c0 (coprod.desc f g) : by rw coprod.inr_desc_assoc\n  ... = coprod.inr \u226b (0 : P \u2a3f Q \u27f6 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.\u03c0_of_\u03c0] at ha' hb', rw [ha', hb'] },\n  is_colimit := pushout_cocone.is_colimit.mk _\n  (\u03bb s, cokernel.desc (coprod.desc f g) (b \u226b pushout_cocone.inr s) $ coprod.hom_ext\n    (calc coprod.inl \u226b coprod.desc f g \u226b b \u226b pushout_cocone.inr s\n          = f \u226b b \u226b pushout_cocone.inr s : by rw coprod.inl_desc_assoc\n      ... = f \u226b a \u226b pushout_cocone.inl s : by rw pushout_cocone.condition\n      ... = 0 \u226b pushout_cocone.inl s : by rw reassoc_of hfa\n      ... = coprod.inl \u226b 0 : by rw [comp_zero, zero_comp])\n    (calc coprod.inr \u226b coprod.desc f g \u226b b \u226b pushout_cocone.inr s\n          = g \u226b b \u226b pushout_cocone.inr s : by rw coprod.inr_desc_assoc\n      ... = 0 \u226b pushout_cocone.inr s : by rw reassoc_of hgb\n      ... = coprod.inr \u226b 0 : by rw [comp_zero, zero_comp]))\n  (\u03bb s, (cancel_epi a).1 $\n    by { rw cokernel_cofork.\u03c0_of_\u03c0 at ha', simp [reassoc_of ha', pushout_cocone.condition s] })\n  (\u03bb s, (cancel_epi b).1 $ by { rw cokernel_cofork.\u03c0_of_\u03c0 at hb', simp [reassoc_of hb'] })\n  (\u03bb s m h\u2081 h\u2082, (cancel_epi (cokernel.\u03c0 (coprod.desc f g))).1 $\n  calc cokernel.\u03c0 (coprod.desc f g) \u226b m\n        = (a \u226b a') \u226b m : by { congr, exact ha'.symm }\n    ... = a \u226b pushout_cocone.inl s : by rw [category.assoc, h\u2081]\n    ... = b \u226b pushout_cocone.inr s : pushout_cocone.condition s\n    ... = cokernel.\u03c0 (coprod.desc f g) \u226b\n            cokernel.desc (coprod.desc f g) (b \u226b pushout_cocone.inr s) _ :\n      by rw cokernel.\u03c0_desc) }\n\n\n\nsection\nlocal attribute [instance] pushout_of_epi\n\n/-- The pushout of `(\ud835\udfd9 Y, f)` and `(\ud835\udfd9 Y, g)`. -/\nprivate abbreviation Q {X Y : C} (f g : X \u27f6 Y)\n  [epi (coprod.desc (\ud835\udfd9 Y) f)] [epi (coprod.desc (\ud835\udfd9 Y) g)] : C :=\npushout (coprod.desc (\ud835\udfd9 Y) f) (coprod.desc (\ud835\udfd9 Y) g)\n\n/-- The coequalizer of `f` and `g` exists. -/\n@[irreducible]\nlemma has_colimit_parallel_pair {X Y : C} (f g : X \u27f6 Y) : has_colimit (parallel_pair f g) :=\nhave huv : (pushout.inl : Y \u27f6 Q f g) = pushout.inr, from\n  calc (pushout.inl : Y \u27f6 Q f g) = \ud835\udfd9 _ \u226b pushout.inl : eq.symm $ category.id_comp _\n    ... = (coprod.inl \u226b coprod.desc (\ud835\udfd9 Y) f) \u226b pushout.inl : by rw coprod.inl_desc\n    ... = (coprod.inl \u226b coprod.desc (\ud835\udfd9 Y) g) \u226b pushout.inr :\n      by simp only [category.assoc, pushout.condition]\n    ... = pushout.inr : by rw [coprod.inl_desc, category.id_comp],\nhave hvu : f \u226b (pushout.inl : Y \u27f6 Q f g) = g \u226b pushout.inr, from\n  calc f \u226b (pushout.inl : Y \u27f6 Q f g)\n        = (coprod.inr \u226b coprod.desc (\ud835\udfd9 Y) f) \u226b pushout.inl : by rw coprod.inr_desc\n    ... = (coprod.inr \u226b coprod.desc (\ud835\udfd9 Y) g) \u226b pushout.inr :\n      by simp only [category.assoc, pushout.condition]\n    ... = g \u226b pushout.inr : by rw coprod.inr_desc,\nhave huu : f \u226b (pushout.inl : Y \u27f6 Q f g) = g \u226b pushout.inl, by rw [hvu, huv],\nhas_colimit.mk { cocone := cofork.of_\u03c0 pushout.inl huu,\n  is_colimit := cofork.is_colimit.mk _\n  (\u03bb s, pushout.desc (cofork.\u03c0 s) (cofork.\u03c0 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  (\u03bb s, by simp only [pushout.inl_desc, cofork.\u03c0_of_\u03c0])\n  (\u03bb 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 \u27f6 Y) (Z : C)\n  (l : is_limit (kernel_fork.of_\u03b9 (0 : Z \u27f6 X) (show 0 \u226b f = 0, by simp))) : mono f :=\n\u27e8\u03bb P u v huv,\n begin\n  obtain \u27e8W, w, hw, hl\u27e9 := normal_epi_of_epi (coequalizer.\u03c0 u v),\n  obtain \u27e8m, hm\u27e9 := coequalizer.desc' f huv,\n  have hwf : w \u226b f = 0,\n  { rw [\u2190hm, reassoc_of hw, zero_comp] },\n  obtain \u27e8n, hn\u27e9 := kernel_fork.is_limit.lift' l _ hwf,\n  rw [fork.\u03b9_of_\u03b9, has_zero_morphisms.comp_zero] at hn,\n  haveI : is_iso (coequalizer.\u03c0 u v),\n  { apply is_iso_colimit_cocone_parallel_pair_of_eq hn.symm hl },\n  apply (cancel_mono (coequalizer.\u03c0 u v)).1,\n  exact coequalizer.condition _ _\n end\u27e9\n\nsection\nvariables [has_zero_object C]\nopen_locale zero_object\n\n/-- If `g \u226b f = 0` implies `g = 0` for all `g`, then `f` is a monomorphism. -/\nlemma mono_of_cancel_zero {X Y : C} (f : X \u27f6 Y)\n  (hf : \u2200 (Z : C) (g : Z \u27f6 X) (hgf : g \u226b 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 {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w}\n\n-- A constructive version of `bijective`.\nstructure Is_equiv (f : \u03b1 \u2192 \u03b2) :=\n(e : \u03b1 \u2243 \u03b2)\n(h : f = e)\n\ninstance (f : \u03b1 \u2192 \u03b2) : subsingleton (Is_equiv f) :=\n\u27e8begin\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\u27e9\n\nlemma Is_equiv.bijective {f : \u03b1 \u2192 \u03b2} (e : Is_equiv f) : function.bijective f :=\nby rw e.h; exact e.e.bijective\n\nlemma Is_equiv.cancel_left {f : \u03b1 \u2192 \u03b2} (e : Is_equiv f) {a : \u03b1} :\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 : \u03b1 \u2192 \u03b2} (e : Is_equiv f) {b : \u03b2} :\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 `\u03b1` to `\u03b9 \u2192\u2080 \u03b1`.\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 `\u2115`-valued finitely supported\n  functions and multisets.\n-/\n\n\nnoncomputable section\n\nopen BigOperators\n\nopen Finset\n\nvariable {\u03b9 \u03b1 : Type _}\n\nnamespace Finsupp\n\n/-! ### Order structures -/\n\n\nsection Zero\n\nvariable [Zero \u03b1]\n\nsection LE\n\nvariable [LE \u03b1]\n\ninstance : LE (\u03b9 \u2192\u2080 \u03b1) :=\n  \u27e8fun f g => \u2200 i, f i \u2264 g i\u27e9\n\n/- warning: finsupp.le_def -> Finsupp.le_def is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Zero.{u2} \u03b1] [_inst_2 : LE.{u2} \u03b1] {f : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1} {g : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1}, Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2) f g) (forall (i : \u03b9), LE.le.{u2} \u03b1 _inst_2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) g i))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Zero.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {f : Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1} {g : Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1}, Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) (Finsupp.instLEFinsupp.{u2, u1} \u03b9 \u03b1 _inst_1 _inst_2) f g) (forall (i : \u03b9), LE.le.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) _inst_2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 _inst_1) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 _inst_1) g i))\nCase conversion may be inaccurate. Consider using '#align finsupp.le_def Finsupp.le_def\u2093'. -/\ntheorem le_def {f g : \u03b9 \u2192\u2080 \u03b1} : f \u2264 g \u2194 \u2200 i, f i \u2264 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 : (\u03b9 \u2192\u2080 \u03b1) \u21aao (\u03b9 \u2192 \u03b1)\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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Zero.{u2} \u03b1] [_inst_2 : LE.{u2} \u03b1] {f : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1} {i : \u03b9}, Eq.{succ u2} \u03b1 (coeFn.{succ (max u1 u2), succ (max u1 u2)} (OrderEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2) (Pi.hasLe.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => _inst_2))) (fun (_x : RelEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1) (LE.le.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2)) (LE.le.{max u1 u2} (\u03b9 -> \u03b1) (Pi.hasLe.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => _inst_2)))) => (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) -> \u03b9 -> \u03b1) (RelEmbedding.hasCoeToFun.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1) (LE.le.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2)) (LE.le.{max u1 u2} (\u03b9 -> \u03b1) (Pi.hasLe.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => _inst_2)))) (Finsupp.orderEmbeddingToFun.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) f i)\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Zero.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {f : Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1} {i : \u03b9}, Eq.{succ u1} \u03b1 (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} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1)) (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) _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} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1)) (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1) (Function.instEmbeddingLikeEmbedding.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1))) (RelEmbedding.toEmbedding.{max u1 u2, max u1 u2} (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.680 : Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) (x._@.Mathlib.Order.Hom.Basic._hyg.682 : Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) => LE.le.{max u1 u2} (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) (Finsupp.instLEFinsupp.{u2, u1} \u03b9 \u03b1 _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 : \u03b9 -> \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.697 : \u03b9 -> \u03b1) => LE.le.{max u2 u1} (\u03b9 -> \u03b1) (Pi.hasLe.{u2, u1} \u03b9 (fun (a._@.Mathlib.Data.Finsupp.Order._hyg.129 : \u03b9) => \u03b1) (fun (i : \u03b9) => _inst_2)) x._@.Mathlib.Order.Hom.Basic._hyg.695 x._@.Mathlib.Order.Hom.Basic._hyg.697) (Finsupp.orderEmbeddingToFun.{u2, u1} \u03b9 \u03b1 _inst_1 _inst_2)) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 _inst_1) f i)\nCase conversion may be inaccurate. Consider using '#align finsupp.order_embedding_to_fun_apply Finsupp.orderEmbeddingToFun_apply\u2093'. -/\n@[simp]\ntheorem orderEmbeddingToFun_apply {f : \u03b9 \u2192\u2080 \u03b1} {i : \u03b9} : 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 \u03b1]\n\ninstance : Preorder (\u03b9 \u2192\u2080 \u03b1) :=\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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Zero.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1], Monotone.{max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1) (Finsupp.preorder.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2) (Pi.preorder.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => _inst_2)) (Finsupp.toFun.{u1, u2} \u03b9 \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : Zero.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Monotone.{max u2 u1, max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 _inst_1) (\u03b9 -> \u03b1) (Finsupp.preorder.{u2, u1} \u03b9 \u03b1 _inst_1 _inst_2) (Pi.preorder.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => _inst_2)) (Finsupp.toFun.{u2, u1} \u03b9 \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align finsupp.monotone_to_fun Finsupp.monotone_toFun\u2093'. -/\ntheorem monotone_toFun : Monotone (Finsupp.toFun : (\u03b9 \u2192\u2080 \u03b1) \u2192 \u03b9 \u2192 \u03b1) := 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 \u03b1] : PartialOrder (\u03b9 \u2192\u2080 \u03b1) :=\n  { Finsupp.preorder with le_antisymm := fun f g hfg hgf => ext fun i => (hfg i).antisymm (hgf i) }\n\ninstance [SemilatticeInf \u03b1] : SemilatticeInf (\u03b9 \u2192\u2080 \u03b1) :=\n  { Finsupp.partialOrder with\n    inf := zipWith (\u00b7 \u2293 \u00b7) 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Zero.{u2} \u03b1] [_inst_2 : SemilatticeInf.{u2} \u03b1] {i : \u03b9} {f : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1} {g : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1}, Eq.{succ u2} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (SemilatticeInf.toHasInf.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (Finsupp.semilatticeInf.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2)) f g) i) (Inf.inf.{u2} \u03b1 (SemilatticeInf.toHasInf.{u2} \u03b1 _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) g i))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Zero.{u2} \u03b1] [_inst_2 : SemilatticeInf.{u2} \u03b1] {i : \u03b9} {f : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1} {g : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1}, Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u1, u2} \u03b9 \u03b1 _inst_1) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (SemilatticeInf.toInf.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (Finsupp.semilatticeInf.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2)) f g) i) (Inf.inf.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (SemilatticeInf.toInf.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) _inst_2) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u1, u2} \u03b9 \u03b1 _inst_1) f i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u1, u2} \u03b9 \u03b1 _inst_1) g i))\nCase conversion may be inaccurate. Consider using '#align finsupp.inf_apply Finsupp.inf_apply\u2093'. -/\n@[simp]\ntheorem inf_apply [SemilatticeInf \u03b1] {i : \u03b9} {f g : \u03b9 \u2192\u2080 \u03b1} : (f \u2293 g) i = f i \u2293 g i :=\n  rfl\n#align finsupp.inf_apply Finsupp.inf_apply\n\ninstance [SemilatticeSup \u03b1] : SemilatticeSup (\u03b9 \u2192\u2080 \u03b1) :=\n  { Finsupp.partialOrder with\n    sup := zipWith (\u00b7 \u2294 \u00b7) 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Zero.{u2} \u03b1] [_inst_2 : SemilatticeSup.{u2} \u03b1] {i : \u03b9} {f : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1} {g : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1}, Eq.{succ u2} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (SemilatticeSup.toHasSup.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (Finsupp.semilatticeSup.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2)) f g) i) (Sup.sup.{u2} \u03b1 (SemilatticeSup.toHasSup.{u2} \u03b1 _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 _inst_1) g i))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : Zero.{u2} \u03b1] [_inst_2 : SemilatticeSup.{u2} \u03b1] {i : \u03b9} {f : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1} {g : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1}, Eq.{succ u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u1, u2} \u03b9 \u03b1 _inst_1) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (SemilatticeSup.toSup.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) (Finsupp.semilatticeSup.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2)) f g) i) (Sup.sup.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (SemilatticeSup.toSup.{u2} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) _inst_2) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u1, u2} \u03b9 \u03b1 _inst_1) f i) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Finsupp.{u1, u2} \u03b9 \u03b1 _inst_1) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u1, u2} \u03b9 \u03b1 _inst_1) g i))\nCase conversion may be inaccurate. Consider using '#align finsupp.sup_apply Finsupp.sup_apply\u2093'. -/\n@[simp]\ntheorem sup_apply [SemilatticeSup \u03b1] {i : \u03b9} {f g : \u03b9 \u2192\u2080 \u03b1} : (f \u2294 g) i = f i \u2294 g i :=\n  rfl\n#align finsupp.sup_apply Finsupp.sup_apply\n\n#print Finsupp.lattice /-\ninstance lattice [Lattice \u03b1] : Lattice (\u03b9 \u2192\u2080 \u03b1) :=\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 \u03b1] : OrderedAddCommMonoid (\u03b9 \u2192\u2080 \u03b1) :=\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 \u03b1] : OrderedCancelAddCommMonoid (\u03b9 \u2192\u2080 \u03b1) :=\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 \u03b1] [ContravariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] :\n    ContravariantClass (\u03b9 \u2192\u2080 \u03b1) (\u03b9 \u2192\u2080 \u03b1) (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7) :=\n  \u27e8fun f g h H x => le_of_add_le_add_left <| H x\u27e9\n\nsection CanonicallyOrderedAddMonoid\n\nvariable [CanonicallyOrderedAddMonoid \u03b1]\n\ninstance : OrderBot (\u03b9 \u2192\u2080 \u03b1) 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1], Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Bot.bot.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (OrderBot.toHasBot.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (Finsupp.orderBot.{u1, u2} \u03b9 \u03b1 _inst_1))) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.zero.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1], Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Bot.bot.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (OrderBot.toBot.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.orderBot.{u2, u1} \u03b9 \u03b1 _inst_1))) (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.zero.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align finsupp.bot_eq_zero Finsupp.bot_eq_zero\u2093'. -/\nprotected theorem bot_eq_zero : (\u22a5 : \u03b9 \u2192\u2080 \u03b1) = 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] (f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (g : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))), Iff (Eq.{succ (max u1 u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (HAdd.hAdd.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (instHAdd.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.add.{u1, u2} \u03b9 \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) f g) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.zero.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))))))) (And (Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) f (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.zero.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))))))) (Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) g (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.zero.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))))))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] (f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (g : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))), Iff (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (HAdd.hAdd.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (instHAdd.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.add.{u2, u1} \u03b9 \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))))) f g) (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.zero.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))))))) (And (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) f (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.zero.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))))))) (Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) g (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.zero.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align finsupp.add_eq_zero_iff Finsupp.add_eq_zero_iff\u2093'. -/\n@[simp]\ntheorem add_eq_zero_iff (f g : \u03b9 \u2192\u2080 \u03b1) : f + g = 0 \u2194 f = 0 \u2227 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] (f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (g : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) {s : Finset.{u1} \u03b9}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) f) s) -> (Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) f g) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) -> (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) g i))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] (f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (g : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) {s : Finset.{u2} \u03b9}, (HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) f) s) -> (Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) f g) (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) -> (LE.le.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (Preorder.toLE.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (PartialOrder.toPreorder.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) g i))))\nCase conversion may be inaccurate. Consider using '#align finsupp.le_iff' Finsupp.le_iff'\u2093'. -/\ntheorem le_iff' (f g : \u03b9 \u2192\u2080 \u03b1) {s : Finset \u03b9} (hf : f.support \u2286 s) : f \u2264 g \u2194 \u2200 i \u2208 s, f i \u2264 g i :=\n  \u27e8fun h s hs => h s, fun h s => by\n    classical exact\n        if H : s \u2208 f.support then h s (hf H) else (not_mem_support_iff.1 H).symm \u25b8 zero_le (g s)\u27e9\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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] (f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (g : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))), Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) f g) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) f)) -> (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) f i) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) g i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] (f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (g : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))), Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) f g) (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) f)) -> (LE.le.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (Preorder.toLE.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (PartialOrder.toPreorder.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (OrderedAddCommMonoid.toPartialOrder.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) i) _inst_1)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) f i) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) g i)))\nCase conversion may be inaccurate. Consider using '#align finsupp.le_iff Finsupp.le_iff\u2093'. -/\ntheorem le_iff (f g : \u03b9 \u2192\u2080 \u03b1) : f \u2264 g \u2194 \u2200 i \u2208 f.support, f i \u2264 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : DecidableRel.{succ u2} \u03b1 (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))], DecidableRel.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (LE.le.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : DecidableRel.{succ u2} \u03b1 (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))], DecidableRel.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddMonoid.toZero.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (LE.le.{max u2 u1} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddMonoid.toZero.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (Finsupp.instLEFinsupp.{u1, u2} \u03b9 \u03b1 (AddMonoid.toZero.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align finsupp.decidable_le Finsupp.decidableLE\u2093'. -/\ninstance decidableLE [DecidableRel (@LE.le \u03b1 _)] : DecidableRel (@LE.le (\u03b9 \u2192\u2080 \u03b1) _) := 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] {i : \u03b9} {x : \u03b1} {f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))}, Iff (LE.le.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.hasLe.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (Finsupp.single.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) i x) f) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) x (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) f i))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] {i : \u03b9} {x : \u03b1} {f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))}, Iff (LE.le.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.instLEFinsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.single.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) i x) f) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) x (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) f i))\nCase conversion may be inaccurate. Consider using '#align finsupp.single_le_iff Finsupp.single_le_iff\u2093'. -/\n@[simp]\ntheorem single_le_iff {i : \u03b9} {x : \u03b1} {f : \u03b9 \u2192\u2080 \u03b1} : single i x \u2264 f \u2194 x \u2264 f i :=\n  (le_iff' _ _ support_single_subset).trans <| by simp\n#align finsupp.single_le_iff Finsupp.single_le_iff\n\nvariable [Sub \u03b1] [OrderedSub \u03b1] {f g : \u03b9 \u2192\u2080 \u03b1} {i : \u03b9} {a b : \u03b1}\n\n/- warning: finsupp.tsub -> Finsupp.tsub is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : Sub.{u2} \u03b1] [_inst_3 : OrderedSub.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (AddZeroClass.toHasAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) _inst_2], Sub.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : Sub.{u2} \u03b1] [_inst_3 : OrderedSub.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (AddZeroClass.toAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) _inst_2], Sub.{max u2 u1} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddMonoid.toZero.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align finsupp.tsub Finsupp.tsub\u2093'. -/\n/-- This is called `tsub` for truncated subtraction, to distinguish it with subtraction in an\nadditive group. -/\ninstance tsub : Sub (\u03b9 \u2192\u2080 \u03b1) :=\n  \u27e8zipWith (fun m n => m - n) (tsub_self 0)\u27e9\n#align finsupp.tsub Finsupp.tsub\n\ninstance : OrderedSub (\u03b9 \u2192\u2080 \u03b1) :=\n  \u27e8fun n m k => forall_congr' fun x => tsub_le_iff_right\u27e9\n\ninstance : CanonicallyOrderedAddMonoid (\u03b9 \u2192\u2080 \u03b1) :=\n  { Finsupp.orderBot,\n    Finsupp.orderedAddCommMonoid with\n    exists_add_of_le := fun f g h => \u27e8g - f, ext fun x => (add_tsub_cancel_of_le <| h x).symm\u27e9\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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : Sub.{u2} \u03b1] [_inst_3 : OrderedSub.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (AddZeroClass.toHasAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) _inst_2] (f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (g : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))), Eq.{succ (max u1 u2)} (\u03b9 -> \u03b1) (coeFn.{succ (max u1 u2), succ (max u1 u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.tsub.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) f g)) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (\u03b9 -> \u03b1) (\u03b9 -> \u03b1) (\u03b9 -> \u03b1) (instHSub.{max u1 u2} (\u03b9 -> \u03b1) (Pi.instSub.{u1, u2} \u03b9 (fun (\u1fb0 : \u03b9) => \u03b1) (fun (i : \u03b9) => _inst_2))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) g))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) _inst_2] (f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (g : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b9), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.tsub.{u2, u1} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) f g)) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (forall (\u1fb0 : \u03b9), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) \u1fb0) (forall (\u1fb0 : \u03b9), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) \u1fb0) (forall (\u1fb0 : \u03b9), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) \u1fb0) (instHSub.{max u2 u1} (forall (\u1fb0 : \u03b9), (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) \u1fb0) (Pi.instSub.{u2, u1} \u03b9 (fun (\u1fb0 : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) \u1fb0) (fun (i : \u03b9) => _inst_2))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) f) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) g))\nCase conversion may be inaccurate. Consider using '#align finsupp.coe_tsub Finsupp.coe_tsub\u2093'. -/\n@[simp]\ntheorem coe_tsub (f g : \u03b9 \u2192\u2080 \u03b1) : \u21d1(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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : Sub.{u2} \u03b1] [_inst_3 : OrderedSub.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (AddZeroClass.toHasAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) _inst_2] (f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (g : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (a : \u03b9), Eq.{succ u2} \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.tsub.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) f g) a) (HSub.hSub.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHSub.{u2} \u03b1 _inst_2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (fun (_x : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) => \u03b9 -> \u03b1) (Finsupp.coeFun.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) g a))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) _inst_2] (f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (g : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (a : \u03b9), Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.tsub.{u2, u1} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) f g) a) (HSub.hSub.{u1, u1, u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) a) ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) a) ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) a) (instHSub.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) a) _inst_2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) \u03b9 (fun (_x : \u03b9) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : \u03b9) => \u03b1) _x) (Finsupp.funLike.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) g a))\nCase conversion may be inaccurate. Consider using '#align finsupp.tsub_apply Finsupp.tsub_apply\u2093'. -/\ntheorem tsub_apply (f g : \u03b9 \u2192\u2080 \u03b1) (a : \u03b9) : (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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : Sub.{u2} \u03b1] [_inst_3 : OrderedSub.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (AddZeroClass.toHasAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) _inst_2] {i : \u03b9} {a : \u03b1} {b : \u03b1}, Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.single.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) i (HSub.hSub.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHSub.{u2} \u03b1 _inst_2) a b)) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.tsub.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) (Finsupp.single.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) i a) (Finsupp.single.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) i b))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) _inst_2] {i : \u03b9} {a : \u03b1} {b : \u03b1}, Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.single.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) i (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 _inst_2) a b)) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.tsub.{u2, u1} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) (Finsupp.single.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) i a) (Finsupp.single.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) i b))\nCase conversion may be inaccurate. Consider using '#align finsupp.single_tsub Finsupp.single_tsub\u2093'. -/\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  \u00b7 rw [tsub_apply, single_eq_same, single_eq_same, single_eq_same]\n  \u00b7 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : Sub.{u2} \u03b1] [_inst_3 : OrderedSub.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (AddZeroClass.toHasAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) _inst_2] {f1 : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))} {f2 : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))}, HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.tsub.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) f1 f2)) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) f1)\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) _inst_2] {f1 : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))} {f2 : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))}, HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.tsub.{u2, u1} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) f1 f2)) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) f1)\nCase conversion may be inaccurate. Consider using '#align finsupp.support_tsub Finsupp.support_tsub\u2093'. -/\ntheorem support_tsub {f1 f2 : \u03b9 \u2192\u2080 \u03b1} : (f1 - f2).support \u2286 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyOrderedAddMonoid.{u2} \u03b1] [_inst_2 : Sub.{u2} \u03b1] [_inst_3 : OrderedSub.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))) (AddZeroClass.toHasAdd.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) _inst_2] [_inst_4 : DecidableEq.{succ u1} \u03b9] {f1 : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))} {f2 : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))}, HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) (SDiff.sdiff.{u1} (Finset.{u1} \u03b9) (Finset.hasSdiff.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b)) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) f1) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) f2)) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1))))) (HSub.hSub.{max u1 u2, max u1 u2, max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (instHSub.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 _inst_1)))))) (Finsupp.tsub.{u1, u2} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) f1 f2))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedAddMonoid.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) _inst_2] [_inst_4 : DecidableEq.{succ u2} \u03b9] {f1 : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))} {f2 : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))}, HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) (SDiff.sdiff.{u2} (Finset.{u2} \u03b9) (Finset.instSDiffFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_4 a b)) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) f1) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) f2)) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (HSub.hSub.{max u2 u1, max u2 u1, max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (instHSub.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1))))) (Finsupp.tsub.{u2, u1} \u03b9 \u03b1 _inst_1 _inst_2 _inst_3)) f1 f2))\nCase conversion may be inaccurate. Consider using '#align finsupp.subset_support_tsub Finsupp.subset_support_tsub\u2093'. -/\ntheorem subset_support_tsub [DecidableEq \u03b9] {f1 f2 : \u03b9 \u2192\u2080 \u03b1} :\n    f1.support \\ f2.support \u2286 (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 \u03b1]\n\n/- warning: finsupp.support_inf -> Finsupp.support_inf is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b9] (f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))) (g : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))), Eq.{succ u1} (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) (Inf.inf.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))) (SemilatticeInf.toHasInf.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))) (Finsupp.semilatticeInf.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) (Lattice.toSemilatticeInf.{u2} \u03b1 (LinearOrder.toLattice.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u2} \u03b1 _inst_1))))) f g)) (Inter.inter.{u1} (Finset.{u1} \u03b9) (Finset.hasInter.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b)) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) f) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) g))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b9] (f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))) (g : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))), Eq.{succ u2} (Finset.{u2} \u03b9) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) (Inf.inf.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))) (Lattice.toInf.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))) (Finsupp.lattice.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u1} \u03b1 _inst_1))))) f g)) (Inter.inter.{u2} (Finset.{u2} \u03b9) (Finset.instInterFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b)) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) f) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) g))\nCase conversion may be inaccurate. Consider using '#align finsupp.support_inf Finsupp.support_inf\u2093'. -/\n@[simp]\ntheorem support_inf [DecidableEq \u03b9] (f g : \u03b9 \u2192\u2080 \u03b1) : (f \u2293 g).support = f.support \u2229 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, \u2190 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b9] (f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))) (g : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))), Eq.{succ u1} (Finset.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) (Sup.sup.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))) (SemilatticeSup.toHasSup.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))) (Finsupp.semilatticeSup.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) (CanonicallyLinearOrderedAddMonoid.semilatticeSup.{u2} \u03b1 _inst_1))) f g)) (Union.union.{u1} (Finset.{u1} \u03b9) (Finset.hasUnion.{u1} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b)) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) f) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) g))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b9] (f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))) (g : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))), Eq.{succ u2} (Finset.{u2} \u03b9) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) (Sup.sup.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))) (SemilatticeSup.toSup.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))) (Finsupp.semilatticeSup.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toLinearOrder.{u1} \u03b1 _inst_1)))))) f g)) (Union.union.{u2} (Finset.{u2} \u03b9) (Finset.instUnionFinset.{u2} \u03b9 (fun (a : \u03b9) (b : \u03b9) => _inst_2 a b)) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) f) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) g))\nCase conversion may be inaccurate. Consider using '#align finsupp.support_sup Finsupp.support_sup\u2093'. -/\n@[simp]\ntheorem support_sup [DecidableEq \u03b9] (f g : \u03b9 \u2192\u2080 \u03b1) : (f \u2294 g).support = f.support \u222a g.support :=\n  by\n  ext\n  simp only [Finset.mem_union, mem_support_iff, sup_apply, Ne.def, \u2190 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 {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u2} \u03b1] {f : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))} {g : Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))}, Iff (Disjoint.{max u1 u2} (Finsupp.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1))))))) (Finsupp.partialOrder.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))) (Finsupp.orderBot.{u1, u2} \u03b9 \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)) f g) (Disjoint.{u1} (Finset.{u1} \u03b9) (Finset.partialOrder.{u1} \u03b9) (Finset.orderBot.{u1} \u03b9) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) f) (Finsupp.support.{u1, u2} \u03b9 \u03b1 (AddZeroClass.toHasZero.{u2} \u03b1 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddCommMonoid.toAddMonoid.{u2} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u2} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u2} \u03b1 _inst_1)))))) g))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedAddMonoid.{u1} \u03b1] {f : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))} {g : Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))}, Iff (Disjoint.{max u2 u1} (Finsupp.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))))) (Finsupp.partialorder.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)))) (Finsupp.orderBot.{u2, u1} \u03b9 \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1)) f g) (Disjoint.{u2} (Finset.{u2} \u03b9) (Finset.partialOrder.{u2} \u03b9) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u2} \u03b9) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) f) (Finsupp.support.{u2, u1} \u03b9 \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (CanonicallyOrderedAddMonoid.toOrderedAddCommMonoid.{u1} \u03b1 (CanonicallyLinearOrderedAddMonoid.toCanonicallyOrderedAddMonoid.{u1} \u03b1 _inst_1))))) g))\nCase conversion may be inaccurate. Consider using '#align finsupp.disjoint_iff Finsupp.disjoint_iff\u2093'. -/\ntheorem disjoint_iff {f g : \u03b9 \u2192\u2080 \u03b1} : Disjoint f g \u2194 Disjoint f.support g.support := by\n  classical\n    rw [disjoint_iff, disjoint_iff, Finsupp.bot_eq_zero, \u2190 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 `\u2115` -/\n\n\nsection Nat\n\n#print Finsupp.sub_single_one_add /-\ntheorem sub_single_one_add {a : \u03b9} {u u' : \u03b9 \u2192\u2080 \u2115} (h : u a \u2260 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 : \u03b9} {u u' : \u03b9 \u2192\u2080 \u2115} (h : u' a \u2260 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 (\u03b1 : Sort u) :=\n\u03a0 (a b : \u03b1), a = b :> \u03b1\n\ndef hset (\u03b1 : Sort u) :=\n\u03a0 {a b : \u03b1} (p q : a = b :> \u03b1), p = q :> a = b :> \u03b1\n\nstructure contr (\u03b1 : Sort u) :=\n(point : \u03b1) (intro : \u03a0 (a : \u03b1), point = a :> \u03b1)\n--  or we can write `idfun ~ \u03bb _, point`\n\ndef LEM := \u03a0 (\u03b1 : Type u), prop \u03b1 \u2192 (\u03b1 + \u00ac\u03b1)\ndef law_of_double_negation :=\n\u03a0 (\u03b1 : Type u), prop \u03b1 \u2192 (\u00ac\u00ac\u03b1 \u2192 \u03b1)\n\ndef LEM_inf := \u03a0 (\u03b1 : Type u), \u03b1 + \u00ac\u03b1\nnotation `LEM\u221e` := LEM_inf\n\ninductive homotopy_level\n| minus_two\n| succ : homotopy_level \u2192 homotopy_level\n\nnotation `\u22122` := homotopy_level.minus_two\nnotation `\u22121` := homotopy_level.succ \u22122\n\ninstance : has_zero homotopy_level := \u27e8homotopy_level.succ \u22121\u27e9\n\ndef level_to_n : homotopy_level \u2192 \u2115\n| homotopy_level.minus_two := 0\n| (homotopy_level.succ n) := level_to_n n + 1\n\ndef n_to_level : \u2115 \u2192 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 \u2192 homotopy_level \u2192 Sort (max 1 u)\n| \u03b1 homotopy_level.minus_two := contr \u03b1\n| \u03b1 (homotopy_level.succ n) := \u03a0 (x y : \u03b1),\n  is_n_type (x = y :> \u03b1) n\n\ndef n_type (n : homotopy_level) :=\n\u03a3' (\u03b1 : Sort u), is_n_type \u03b1 n\nnotation n `-Type` := n_type n\n\ndef contr_impl_prop {\u03b1 : Sort u} (h : contr \u03b1) : prop \u03b1 :=\n\u03bb a b, (h.intro a)\u207b\u00b9 \u2b1d (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 {\u03b1 : Prop} : prop \u03b1 :=\nbegin intros x y, trivial end\n\nsection\n  open types.equiv types.eq\n  def prop_is_set {\u03b1 : Sort u} (r : prop \u03b1) : hset \u03b1 := begin\n    intros x y p q, have g := r x,\n    transitivity, symmetry, apply rewrite_comp,\n    exact (apd g p)\u207b\u00b9 \u2b1d transport_composition p (g x),\n    induction q, apply inv_comp\n  end\n\n  -- unsafe postulate, but it computes\n  def function_extensionality {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v}\n    {f g : \u03a0 x, \u03b2 x} (h : f ~ g) : f = g :> \u03a0 x, \u03b2 x :=\n  support.inclusion $ funext (\u03bb x, support.truncation (h x))\n\n  def contr_is_prop {\u03b1 : Sort u} : prop (contr \u03b1) := 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 \u27e8x, u\u27e9)\n  end\n\n  def prop_is_prop {\u03b1 : Sort u} : prop (prop \u03b1) := begin\n    intros f g,\n    have p := \u03bb 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 (\u03b1 : Sort u) : Prop\n| elem : \u03b1 \u2192 squash\ndef squash.uniq {\u03b1 : Sort u} (a b : squash \u03b1) : a = b :> squash \u03b1 :=\ntypes.eq.rfl\n\ndef K (\u03b1 : Sort u) :=\n\u03a0 (a : \u03b1) (p : a = a :> \u03b1), p = types.eq.refl a :> a = a :> \u03b1\n\ntheorem K_iff_set (\u03b1 : Sort u) : K \u03b1 \u2194 hset \u03b1 := 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 {\u03b1 : Sort u} (h : \u03b1 \u2192 prop \u03b1) : prop \u03b1 :=\n\u03bb a, h a a\n\ndef lem_contr {\u03b1 : Sort u} (h : \u03b1 \u2192 contr \u03b1) : prop \u03b1 :=\n\u03bb a, contr_impl_prop (h a) a\n\ndef is_contr_fiber {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) :=\n\u03a0 (y : \u03b2), 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 {\u03b1 : Sort u} (a : \u03b1) :=\n(point : \u03b1) (intro : a = point :> \u03b1)\n\nnamespace singl\nuniverse u\n\ndef trivial_loop {\u03b1 : Sort u} (a : \u03b1) : singl a :=\n\u27e8a, by reflexivity\u27e9\n\ndef path_from_trivial_loop {\u03b1 : Sort u} {a b : \u03b1}\n  (r : a = b :> \u03b1) : (trivial_loop a) = \u27e8b, r\u27e9 :> singl a :=\nbegin induction r, trivial end\n\ndef singl.eq {\u03b1 : Sort u} {a : \u03b1} (t : singl a) :\n  { point := t.point, intro := t.intro } = t :> singl a :=\nbegin induction t, simp end\n\ndef signl_contr {\u03b1 : Sort u} (a : \u03b1) : structures.contr (singl a) :=\n{ point := trivial_loop a,\n  intro := \u03bb t, path_from_trivial_loop t.intro \u2b1d singl.eq t }\n\ndef singl_prop {\u03b1 : Sort u} (a : \u03b1) : 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 \u2192 Ty \u2192 Ty\n\n-- Arithmetic binary operations\ninductive Const : Type\n| int : Int \u2192 Const\n| bool : Bool \u2192 Const\n--|left : Const \u2192 Ty \u2192 Const\n--|right : Ty \u2192 Const \u2192 Const\n\ninstance intToConst : HasCoe Int Const := \u27e8Const.int\u27e9\ninstance boolToConst : HasCoe Bool Const := \u27e8Const.bool\u27e9\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 \u2192 Exp\n| const  : Const \u2192 Exp\n| uop    : UOp \u2192 Exp \u2192 Exp\n| bop    : BOp \u2192 Exp \u2192 Exp \u2192 Exp\n| cond   : Exp \u2192 Exp \u2192 Exp \u2192 Exp\n| letvar : Var \u2192 Exp \u2192 Exp \u2192 Exp\n--|left  : Exp \u2192 Ty \u2192 Exp\n--|right : Ty \u2192 Exp \u2192 Exp\n--|elim  : Exp \u2192 Ty \u2192 Ty \u2192 Var\n\n\nnamespace Exp\nopen UOp BOp Const\n\nprivate def ci := \u03bb n => const $ int n\nprivate def cb := \u03bb 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 \u2192 Option Const\n\nnamespace Env\n\ndef empty : Env := \u03bb _ => none\ndef extend (\u03c1 : Env) (x : Var) (c:Const) : Env :=\n  \u03bb y => if x == y then some c else (\u03c1 y)\n\nend Env\n\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n-- Interpreter\n-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\nnamespace UOp\n\ndef interp : UOp \u2192 Const \u2192 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 $ \u00ac b\n| _,_ => none\n\nend UOp\n\nnamespace BOp\n\ndef interp : BOp \u2192 Const \u2192 Const \u2192 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 \u2192 Exp \u2192 Option Const\n| \u03c1, var x => \u03c1 x\n| \u03c1, const c => c\n| \u03c1, uop op e => do\n  v \u2190 interp \u03c1 e;\n  UOp.interp op v\n| \u03c1, bop op e\u2081 e\u2082 => do\n  v\u2081 \u2190 interp \u03c1 e\u2081;\n  v\u2082 \u2190 interp \u03c1 e\u2082;\n  BOp.interp op v\u2081 v\u2082\n| \u03c1, cond e\u2081 e\u2082 e\u2083 =>\n  match interp \u03c1 e\u2081 with\n  | some (Const.bool true) => interp \u03c1 e\u2082\n  | some (Const.bool false) => interp \u03c1 e\u2083\n  | _ => none\n| \u03c1, letvar x e\u2081 e\u2082 => do\n  v\u2081 \u2190 interp \u03c1 e\u2081;\n  let \u03c1' := Env.extend \u03c1 x v\u2081;\n  interp \u03c1' e\u2082\n\nend Exp\n\n\ndef TyEnv : Type := Var \u2192 Option Ty\n\nnamespace TyEnv\n\ndef empty : TyEnv := \u03bb _ => none\ndef extend (\u0393 : TyEnv) (x : Var) (t:Ty) : TyEnv :=\n  \u03bb y => if x == y then some t else (\u0393 y)\n\nend TyEnv\n\n\nnamespace Const\n\ndef typeof : Const \u2192 Ty\n| int _ => Ty.int\n| bool _ => Ty.bool\n\nend Const\n\n\nnamespace UOp\n\ndef typeof : UOp \u2192 (Ty \u00d7 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 \u2192 (Ty \u00d7 Ty \u00d7 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 \u2192 Exp \u2192 Ty \u2192 Prop\n| var (\u0393:TyEnv) x t :\n  (\u0393 x) = (some t)\n  \u2192 TypeOf \u0393 (Exp.var x) t\n| const \u0393 c t :\n  Const.typeof c = t\n  \u2192 TypeOf \u0393 (Exp.const c) t\n| uop \u0393 op e t t' :\n  TypeOf \u0393 e t\n  \u2192 UOp.typeof op = (t, t')\n  \u2192 TypeOf \u0393 (Exp.uop op e) t'\n| bop \u0393 op e\u2081 e\u2082 t\u2081 t\u2082 t\u2083 :\n  TypeOf \u0393 e\u2081 t\u2081\n  \u2192 TypeOf \u0393 e\u2082 t\u2082\n  \u2192 BOp.typeof op = (t\u2081, t\u2082, t\u2083)\n  \u2192 TypeOf \u0393 (Exp.bop op e\u2081 e\u2082) t\u2083\n| cond \u0393 e\u2081 e\u2082 e\u2083 t :\n  TypeOf \u0393 e\u2081 Ty.bool\n  \u2192 TypeOf \u0393 e\u2082 t\n  \u2192 TypeOf \u0393 e\u2083 t\n  \u2192 TypeOf \u0393 (Exp.cond e\u2081 e\u2082 e\u2083) t\n| letvar \u0393 x e\u2081 e\u2082 t\u2081 t\u2082 :\n  TypeOf \u0393 e\u2081 t\u2081\n  \u2192 TypeOf (TyEnv.extend \u0393 x t\u2081) e\u2082 t\u2082\n  \u2192 TypeOf \u0393 (Exp.letvar x e\u2081 e\u2082) t\u2082\n\n-- In the given expression, substitute\n-- the constant for the variable.\ndef subst : Exp \u2192 Const \u2192 Var \u2192 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\u2081 e\u2082, c, x => \n  Exp.bop op (subst e\u2081 c x) (subst e\u2082 c x)\n| Exp.cond e\u2081 e\u2082 e\u2083, c, x => \n  Exp.cond (subst e\u2081 c x) (subst e\u2082 c x) (subst e\u2083 c x)\n| Exp.letvar y e\u2081 e\u2082, c, x => \n  let e\u2081' := (subst e\u2081 c x);\n  if x == y then\n    Exp.letvar y e\u2081' e\u2082\n  else\n    Exp.letvar y e\u2081' (subst e\u2082 c x)\n\n-- A single reduction step.\ninductive Step : Exp \u2192 Exp \u2192 Prop \n| uop_red op c\u2081 c\u2082 :\n  UOp.interp op c\u2081 = some c\u2082\n  \u2192 Step (Exp.uop op (Exp.const c\u2081)) (Exp.const c\u2082)\n| bop_red op c\u2081 c\u2082 c\u2083 :\n  BOp.interp op c\u2081 c\u2082 = some c\u2083\n  \u2192 Step (Exp.bop op (Exp.const c\u2081) (Exp.const c\u2082)) (Exp.const c\u2083)\n| cond_congr e\u2081 e\u2081' e\u2082 e\u2083 :\n  Step e\u2081 e\u2081'\n  \u2192 Step (Exp.cond e\u2081 e\u2082 e\u2083) (Exp.cond e\u2081' e\u2082 e\u2083)\n| cond_red e\u2081 e\u2082 :\n  Step (Exp.cond (Exp.const true) e\u2081 e\u2082) e\u2081\n| letvar_congr x e\u2081 e\u2081' e\u2082 :\n  Step e\u2081 e\u2081'\n  \u2192 Step (Exp.letvar x e\u2081 e\u2082) (Exp.letvar x e\u2081' e\u2082)\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 \u2192 Exp \u2192 Prop\n| nil e : \n  Steps e e\n| cons e\u2081 e\u2082 e\u2083 : \n  Step e\u2081 e\u2082\n  \u2192 Steps e\u2082 e\u2083\n  \u2192 Steps e\u2081 e\u2083\n\n\n\ndef env_sat (\u0393:TyEnv) (\u03c1:Env) : Prop := forall x t, \n   (\u0393 x) = some t \n   \u2192 Exists (\u03bb c => (\u03c1 x) = some c \u2227 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 \u2192 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\u2081 t\u2082 c,\n typeof op = (t\u2081, t\u2082)\n \u2192 Const.typeof c = t\u2081\n \u2192 Exists (\u03bb c' => interp op c = some c' \u2227 Const.typeof c' = t\u2082) :=\nbegin\n  intros op t\u2081 t\u2082 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 : \u2115} (F : TypeVec.{u} n \u2192 Type _) [fF : MvFunctor F] [q : MvQPF F]\n  (G : Fin2 n \u2192 TypeVec.{u} m \u2192 Type u) [fG : \u2200 i, MvFunctor <| G i] [q' : \u2200 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} {\u03b1 \u03b2 : TypeVec.{u} m} (f : \u03b1 \u27f9 \u03b2)\n\ninstance [I : Inhabited (F fun i : Fin2 n => G i \u03b1)] : Inhabited (Comp F G \u03b1) :=\n  I\n\n#print MvQPF.Comp.mk /-\n/-- Constructor for functor composition -/\nprotected def mk (x : F fun i => G i \u03b1) : (Comp F G) \u03b1 :=\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) \u03b1) : F fun i => G i \u03b1 :=\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}} {\u03b1 : TypeVec.{u1} m} (x : MvQPF.Comp.{u1, u2} n m F G \u03b1), Eq.{succ u2} (MvQPF.Comp.{u1, u2} n m F G \u03b1) (MvQPF.Comp.mk.{u1, u2} n m F G \u03b1 (MvQPF.Comp.get.{u1, u2} n m F G \u03b1 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}} {\u03b1 : TypeVec.{u2} m} (x : MvQPF.Comp.{u2, u1} n m F G \u03b1), Eq.{succ u1} (MvQPF.Comp.{u2, u1} n m F (fun (i : Fin2 n) => G i) \u03b1) (MvQPF.Comp.mk.{u2, u1} n m F (fun (i : Fin2 n) => G i) \u03b1 (MvQPF.Comp.get.{u2, u1} n m F G \u03b1 x)) x\nCase conversion may be inaccurate. Consider using '#align mvqpf.comp.mk_get MvQPF.Comp.mk_get\u2093'. -/\n@[simp]\nprotected theorem mk_get (x : (Comp F G) \u03b1) : 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}} {\u03b1 : TypeVec.{u1} m} (x : F (fun (i : Fin2 n) => G i \u03b1)), Eq.{succ u2} (F (fun (i : Fin2 n) => G i \u03b1)) (MvQPF.Comp.get.{u1, u2} n m F G \u03b1 (MvQPF.Comp.mk.{u1, u2} n m F G \u03b1 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}} {\u03b1 : TypeVec.{u2} m} (x : F (fun (i : Fin2 n) => G i \u03b1)), Eq.{succ u1} (F (fun (i : Fin2 n) => G i \u03b1)) (MvQPF.Comp.get.{u2, u1} n m F (fun (i : Fin2 n) => G i) \u03b1 (MvQPF.Comp.mk.{u2, u1} n m F (fun (i : Fin2 n) => G i) \u03b1 x)) x\nCase conversion may be inaccurate. Consider using '#align mvqpf.comp.get_mk MvQPF.Comp.get_mk\u2093'. -/\n@[simp]\nprotected theorem get_mk (x : F fun i => G i \u03b1) : 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 \u03b1) \u27f9 fun i : Fin2 n => G i \u03b2 := 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) \u03b1 \u2192 (Comp F G) \u03b2 :=\n  (map fun i => map f : (F fun i => G i \u03b1) \u2192 F fun i => G i \u03b2)\n#align mvqpf.comp.map MvQPF.Comp.map\n-/\n\ninstance : MvFunctor (Comp F G) where map \u03b1 \u03b2 := 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)] {\u03b1 : TypeVec.{u1} m} {\u03b2 : TypeVec.{u1} m} (f : TypeVec.Arrow.{u1, u1} m \u03b1 \u03b2) (x : F (fun (i : Fin2 n) => G i \u03b1)), Eq.{succ u2} (MvQPF.Comp.{u1, u2} n m F (fun (i : Fin2 n) {\u03b1 : TypeVec.{u1} m} => G i \u03b1) \u03b2) (MvFunctor.map.{u1, u2} m (MvQPF.Comp.{u1, u2} n m F (fun (i : Fin2 n) {\u03b1 : TypeVec.{u1} m} => G i \u03b1)) (MvQPF.Comp.mvfunctor.{u1, u2} n m F fF (fun (i : Fin2 n) {\u03b1 : TypeVec.{u1} m} => G i \u03b1) (fun (i : Fin2 n) => fG i)) \u03b1 \u03b2 f (MvQPF.Comp.mk.{u1, u2} n m F (fun (i : Fin2 n) {\u03b1 : TypeVec.{u1} m} => G i \u03b1) \u03b1 x)) (MvQPF.Comp.mk.{u1, u2} n m F (fun (i : Fin2 n) {\u03b1 : TypeVec.{u1} m} => G i \u03b1) \u03b2 (MvFunctor.map.{u1, u2} n F fF (fun (i : Fin2 n) => G i \u03b1) (fun (i : Fin2 n) => G i \u03b2) (fun (i : Fin2 n) (x : G i \u03b1) => MvFunctor.map.{u1, u1} m (fun {\u03b1 : TypeVec.{u1} m} => G i \u03b1) (fG i) \u03b1 \u03b2 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)] {\u03b1 : TypeVec.{u2} m} {\u03b2 : TypeVec.{u2} m} (f : TypeVec.Arrow.{u2, u2} m \u03b1 \u03b2) (x : F (fun (i : Fin2 n) => G i \u03b1)), Eq.{succ u1} (MvQPF.Comp.{u2, u1} n m F (fun (i : Fin2 n) => G i) \u03b2) (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)) \u03b1 \u03b2 f (MvQPF.Comp.mk.{u2, u1} n m F (fun (i : Fin2 n) => G i) \u03b1 x)) (MvQPF.Comp.mk.{u2, u1} n m F (fun (i : Fin2 n) => G i) \u03b2 (MvFunctor.map.{u2, u1} n F fF (fun (i : Fin2 n) => G i \u03b1) (fun (i : Fin2 n) => G i \u03b2) (fun (i : Fin2 n) (x : G i \u03b1) => MvFunctor.map.{u2, u2} m (G i) (fG i) \u03b1 \u03b2 f x) x))\nCase conversion may be inaccurate. Consider using '#align mvqpf.comp.map_mk MvQPF.Comp.map_mk\u2093'. -/\ntheorem map_mk (x : F fun i => G i \u03b1) :\n    f <$$> Comp.mk x = Comp.mk ((fun i (x : G i \u03b1) => 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)] {\u03b1 : TypeVec.{u1} m} {\u03b2 : TypeVec.{u1} m} (f : TypeVec.Arrow.{u1, u1} m \u03b1 \u03b2) (x : MvQPF.Comp.{u1, u2} n m F G \u03b1), Eq.{succ u2} (F (fun (i : Fin2 n) => G i \u03b2)) (MvQPF.Comp.get.{u1, u2} n m F G \u03b2 (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)) \u03b1 \u03b2 f x)) (MvFunctor.map.{u1, u2} n F fF (fun (i : Fin2 n) => G i \u03b1) (fun (i : Fin2 n) => G i \u03b2) (fun (i : Fin2 n) (x : G i \u03b1) => MvFunctor.map.{u1, u1} m (fun {\u03b1 : TypeVec.{u1} m} => G i \u03b1) (fG i) \u03b1 \u03b2 f x) (MvQPF.Comp.get.{u1, u2} n m F G \u03b1 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)] {\u03b1 : TypeVec.{u2} m} {\u03b2 : TypeVec.{u2} m} (f : TypeVec.Arrow.{u2, u2} m \u03b1 \u03b2) (x : MvQPF.Comp.{u2, u1} n m F G \u03b1), Eq.{succ u1} (F (fun (i : Fin2 n) => G i \u03b2)) (MvQPF.Comp.get.{u2, u1} n m F G \u03b2 (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)) \u03b1 \u03b2 f x)) (MvFunctor.map.{u2, u1} n F fF (fun (i : Fin2 n) => G i \u03b1) (fun (i : Fin2 n) => G i \u03b2) (fun (i : Fin2 n) (x : G i \u03b1) => MvFunctor.map.{u2, u2} m (G i) (fG i) \u03b1 \u03b2 f x) (MvQPF.Comp.get.{u2, u1} n m F (fun (i : Fin2 n) => G i) \u03b1 x))\nCase conversion may be inaccurate. Consider using '#align mvqpf.comp.get_map MvQPF.Comp.get_map\u2093'. -/\ntheorem get_map (x : Comp F G \u03b1) :\n    Comp.get (f <$$> x) = (fun i (x : G i \u03b1) => 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 \u03b1 := Comp.mk \u2218 (map fun i => abs) \u2218 abs \u2218 MvPFunctor.comp.get\n  repr \u03b1 :=\n    MvPFunctor.comp.mk \u2218\n      repr \u2218 (map fun i => (repr : G i \u03b1 \u2192 (fun i : Fin2 n => Obj (p (G i)) \u03b1) i)) \u2218 Comp.get\n  abs_repr := by\n    intros\n    simp [(\u00b7 \u2218 \u00b7), MvFunctor.map_map, (\u00b7 \u229a \u00b7), abs_repr]\n  abs_map := by\n    intros\n    simp [(\u00b7 \u2218 \u00b7)]\n    rw [\u2190 abs_map]\n    simp [MvFunctor.id_map, (\u00b7 \u229a \u00b7), 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 {\u03b1 : Type} (a : \u03b1) : \u03b1 \u2192 Type where\n  | refl : EQ a a\n\ndef EQ.trans (h\u2081 : EQ a b) (h\u2082 : EQ b c) : EQ a c := by\n  cases h\u2081; cases h\u2082; constructor\n\ninstance : Trans (@EQ \u03b1) (@EQ \u03b1) (@EQ \u03b1) where\n  trans := EQ.trans\n\ninfix:50 \" \u224b \" => EQ\n\nexample (h\u2081 : EQ a b) (h\u2082 : b = c) (h\u2083 : EQ c d) : EQ a d := by\n  calc a \u224b b := h\u2081\n       _ = c := h\u2082\n       _ \u224b d := h\u2083\n\nexample (h\u2081 : EQ a b) (h\u2082 : b = c) (h\u2083 : EQ c d) : EQ a d := by\n  eggxplosion [h\u2081, h\u2082, h\u2083]\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 `\u210d'`:=(\u27e8upper_half_space , upper_half_plane_is_open\u27e9: open_subs)\n\nlocal notation `\u210d`:=upper_half_plane\n\ninstance : charted_space \u2102 \u2102 := infer_instance\n\ninstance : charted_space \u2102 \u210d' := infer_instance\n\nlocal prefix `\u2191\u2098`:1024 := @coe _ (matrix (fin 2) (fin 2) _) _\n\nlocal notation `GL(` n `, ` R `)`\u207a:= matrix.GL_pos (fin n) R\n\nlocal notation `SL(` n `, ` R `)`:= matrix.special_linear_group (fin n) R\n\nvariable (M : GL(2, \u211d)\u207a)\n\nlemma auxmf2 (a b c : \u2102) : b\u207b\u00b9*c\u207b\u00b9*a=(b*c)\u207b\u00b9*a:=\nbegin\nfield_simp,\nend\n\nlemma aux1 (a b c d e: \u2102) (k : \u2124) : (e^k)\u207b\u00b9*a^(k-1) * (b^k)\u207b\u00b9 * c^(k -1) * d =\n( (b * e)^ k)\u207b\u00b9 * (c * a)^(k-1) * d:=\nbegin\nhave : (b^k)\u207b\u00b9 * ((e)^ k)\u207b\u00b9 * (c)^(k-1) * (a)^(k-1) * d = ( (b * e)^ k)\u207b\u00b9 * (c * a)^(k-1) * d ,\nby  {ring_exp, rw \u2190 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 \u2190this,\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 (\u0393 : subgroup SL(2,\u2124)) (C : GL(2, \u211d)\u207a) (k: \u2124) (f : (\u210d \u2192 \u2102))\n\nlocalized \"notation  f  ` \u2223[`:100 k `]`:0 \u03b3 :100 := slash k \u03b3 f\" in modular_form\n\n--Definition of modular forms:\ndef weakly_modular_weight_k (k : \u2124) (f : \u210d' \u2192 \u2102) :=\n    \u2200 (\u03b3 : SL(2,\u2124)),  (f \u2223[k] (\u03b3 : GL(2, \u211d)\u207a)) = f\n\nlemma zero_weakly_modular (k : \u2124) : weakly_modular_weight_k k (0 : \u210d' \u2192 \u2102) :=\nbegin\nintro \u03b3,\nsimp,\nsorry,\nend\n\ndef one_periodicity (f : \u210d' \u2192 \u2102) := \u2200 (z : \u210d'), extend_by_zero f (z + 1) = extend_by_zero f (z)\n\ndef weakly_modular_submodule_weight_k (k : \u2124) : submodule \u2102 (\u210d' \u2192 \u2102) := {\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 \u03b3,\n    have hff:= hf \u03b3,\n    have hgg:= hg \u03b3,\n    rw slash_add k \u03b3 f g,\n    rw [hff, hgg],\n  },\n  smul_mem' := by {\n    intros c f hf,\n    intro \u03b3,\n    have hff:= hf \u03b3,\n    have : (c \u2022 f)  \u2223[k] \u03b3 = c \u2022 (f  \u2223[k] \u03b3 ),\n    by {apply smul_slash},\n    rw hff at this,\n    apply this,\n  },\n}\n\n\nclass modular_form_weight_k (k : \u2124) (f : \u210d' \u2192 \u2102) : Prop :=\n  (hol : f \u2208 Hol\u210d)\n  (weak : weakly_modular_weight_k k f)\n\n\ndef space_of_modular_forms_weight_k (k : \u2124) : submodule \u2102 (\u210d' \u2192 \u2102) := { \n  carrier := modular_form_weight_k k,\n  add_mem' := \u03bb f g hf hg, \u27e8Hol\u210d.add_mem' hf.hol hg.hol, (weakly_modular_submodule_weight_k k).add_mem' hf.weak hg.weak\u27e9,\n  zero_mem' := \u27e8Hol\u210d.zero_mem', zero_weakly_modular k\u27e9,\n  smul_mem' := \u03bb c f hf, \u27e8\u27e8smul_hol _ _ hf.hol.diff, bounded_at_im_infty.smul _ hf.hol.bdd_at_infty\u27e9,\n    (weakly_modular_submodule_weight_k k).smul_mem' c hf.weak\u27e9,\n  }\n\n\n\n\n-- Definition of modular forms for congruence subgroups:\n\ndef weakly_modular_weight_k_subgroup (k : \u2124) (\u0393 : subgroup SL(2,\u2124)) (f : \u210d' \u2192 \u2102) :=\n  \u2200 (\u03b3 : \u0393),  (f \u2223[k] (\u03b3 : GL(2, \u211d)\u207a)) = f\n\n\nlemma zero_weakly_modular_subgroup (k : \u2124) (\u0393 : subgroup SL(2,\u2124)) : weakly_modular_weight_k_subgroup k \u0393 (0 : \u210d' \u2192 \u2102) :=\nbegin\nintro \u03b3,\nsimp,\nsorry,\nend\n\n\ndef weakly_modular_submodule_weight_k_subgroup (k : \u2124) (\u0393 : subgroup SL(2,\u2124)) : submodule \u2102 (\u210d' \u2192 \u2102) := {\n  carrier := weakly_modular_weight_k_subgroup k \u0393,\n  zero_mem' := by {exact zero_weakly_modular_subgroup k \u0393},\n  add_mem' := by {\n    intros f g hf hg,\n    intro \u03b3,\n    have hff:= hf \u03b3,\n    have hgg:= hg \u03b3,\n    rw slash_add k \u03b3 f g,\n    rw [hff, hgg],\n  },\n  smul_mem' := by {\n    intros c f hf,\n    intro \u03b3,\n    have hff:= hf \u03b3,\n    have : (c \u2022 f)  \u2223[k] \u03b3 = c \u2022 (f  \u2223[k] \u03b3 ),\n    by {apply smul_slash},\n    rw hff at this,\n    apply this,\n  },\n}\n\n--instance : has_mem (\u210d' \u2192 \u2102) (submodule \u2102 (\u210d' \u2192 \u2102)) := \u27e8\u03bb f V, f \u2208 V\u27e9\n\n--Space of modular forms for congruence subgroups:\nclass modular_form_weight_k_subgroup (k : \u2124) (\u0393 : subgroup SL(2,\u2124)) (f : \u210d' \u2192 \u2102) : Prop :=\n  (hol : f \u2208 Hol\u210d)\n  (weak : weakly_modular_weight_k_subgroup k \u0393 f)\n\ndef space_of_modular_forms_weight_k_subgroup (k : \u2124) (\u0393 : subgroup SL(2,\u2124)) : submodule \u2102 (\u210d' \u2192 \u2102) := { \n  carrier := modular_form_weight_k_subgroup k \u0393,\n  add_mem' := \u03bb f g hf hg, \u27e8Hol\u210d.add_mem' hf.hol hg.hol, (weakly_modular_submodule_weight_k_subgroup k \u0393).add_mem' hf.weak hg.weak\u27e9,\n  zero_mem' := \u27e8Hol\u210d.zero_mem', zero_weakly_modular_subgroup k \u0393\u27e9,\n  smul_mem' := \u03bb c f hf, \u27e8\u27e8smul_hol _ _ hf.hol.diff, bounded_at_im_infty.smul _ hf.hol.bdd_at_infty\u27e9,\n    (weakly_modular_submodule_weight_k_subgroup k \u0393).smul_mem' c hf.weak\u27e9,\n  }\n\n-- Definition of meromorphic modular forms:\ndef slash_mer_left (k : \u2124) (\u03b3 : SL(2,\u2124)) (f g : \u210d \u2192 \u2102) (z : \u210d) : \u2102 :=\n  f(\u03b3 \u2022 z) * g(z) * (upper_half_plane.denom \u03b3 z)^(-k)\n\nlemma power_of_diff (k1 k2 : \u2124) (a : \u2102) : a^(k1-k2) = a^k1 * a^(-k2) :=\nbegin\n  \n  sorry,\nend\n\nlemma sep_slash_mer_left (k1 k2 : \u2115) (k : \u2124) (hk : k = k1-k2) (\u03b3 : SL(2,\u2124)) (f g : \u210d \u2192 \u2102) (z : \u210d) : \n  f(\u03b3 \u2022 z) * g(z) * (upper_half_plane.denom \u03b3 z)^(-k) = f(\u03b3 \u2022 z) * (upper_half_plane.denom \u03b3 z)^(-k1 : \u2124) * g(z) * (upper_half_plane.denom \u03b3 z)^(k2) :=\n  begin\n  rw hk,\n  simp only [neg_sub, pow_add],\n  have : (denom \u03b3 z)^((k2 : \u2124)-(k1:\u2124)) = (denom \u03b3 z)^(k2:\u2124) * (denom \u03b3 z)^(-k1 : \u2124),\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 : \u2124) (\u03b3 : SL(2,\u2124)) (f g : \u210d \u2192 \u2102) (z : \u210d) : \u2102 :=\n  f(z) * g(\u03b3 \u2022 z)\n\ndef weakly_meromorphic_modular_weight_k (k : \u2124) (F : Mer\u210d) :=\n  \u2200 (\u03b3 : SL(2,\u2124)), slash_mer_left k \u03b3 F.numerator.val F.denominator.val.val = slash_mer_right k \u03b3 F.numerator.val F.denominator.val.val\n\ninstance mem_mer : has_mem Mer\u210d (submodule \u2102 (\u210d' \u2192 \u2102)) := \u27e8\u03bb F V, F.map \u2208 V\u27e9\n\n--Meromorphic modular form subtype\n\ndef Mer\u210dwm (k : \u2124) :=\n{F : Mer\u210d | weakly_meromorphic_modular_weight_k k F}\n\nlemma Mer\u210dwm_mem (k : \u2124) (F : Mer\u210d) :\n  F \u2208 (Mer\u210dwm k) \u2194  \u2200 (\u03b3 : SL(2,\u2124)), slash_mer_left k \u03b3 F.numerator.val F.denominator.val.val = slash_mer_right k \u03b3 F.numerator.val F.denominator.val.val := \n  iff.rfl\n\n\nlemma Mer\u210d_ap (k : \u2124) (\u0393 : subgroup SL(2,\u2124)) (f : Hol\u210d) (g : non_zero_divisors Hol\u210d) : Mer\u210d :=\nbegin\nexact Mer\u210d.mk f g,\nend\n\nlemma modular_forms_of_Mer\u210dwm (k1 k2 : \u2124) (hk : k = k1-k2)\n(f : Hol\u210d) (g : non_zero_divisors Hol\u210d) (hf : modular_form_weight_k k1 f) (hg : modular_form_weight_k k2 g)\n: Mer\u210d.mk f g \u2208 Mer\u210dwm (k) :=\nbegin\nrw Mer\u210dwm_mem,\nintro \u03b3,\n\nsorry,\nend\n\n\n\n/- def space_of_meromorphic_modular_forms_weight_k (k : \u2124) (\u0393 : subgroup SL(2,\u2124)) : submodule \u2102 (\u210d' \u2192 \u2102) := {\n  carrier := Mer\u210d.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 : \u2124) (\u0393 : subgroup SL(2,\u2124)) (f : \u210d' \u2192 \u2102) :\n  f \u2208 (weakly_modular_submodule_weight_k k \u0393) \u2194  \u2200 (\u03b3 : \u0393), (f \u2223[k] (\u03b3 : GL(2, \u211d)\u207a)) = f := iff.rfl\n\n/--A function `f:\u210d \u2192 \u2102` is modular, of level `\u0393` and weight `k \u2208 \u2124`, if for every matrix in\n `\u03b3 \u2208  \u0393` we have `f(\u03b3  \u2022 z)= (c*z+d)^k f(z)` where `\u03b3= ![![a, b], ![c, d]]`,\n and it acts on `\u210d` via Moebius trainsformations. -/\n@[simp] lemma wmodular_mem' (k : \u2124) (\u0393 : subgroup SL(2,\u2124)) (f : \u210d' \u2192 \u2102) :\n  f \u2208 (weakly_modular_submodule_weight_k k \u0393) \u2194  \u2200 \u03b3 : \u0393, \u2200 z : \u210d,\n  f ((\u03b3 : matrix.GL_pos (fin 2) \u211d) \u2022 z) = ((\u2191\u2098\u03b3 1 0 : \u211d) * z +(\u2191\u2098\u03b3 1 1 : \u211d))^k * f z :=\nbegin\n  simp only [wmodular_mem],\n  split,\n  intros h1 \u03b3 z,\n  have h2:= h1 \u03b3,\n  have h3: (f \u2223[k] \u03b3) z = f z , by {simp_rw h2},\n  rw \u2190 h3,\n  simp_rw slash,\n  rw mul_comm,\n  have h5:= upper_half_plane.denom_ne_zero (\u03b3 : GL(2, \u211d)\u207a) 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 [\u2190int.coe_cast_ring_hom],\n  simp_rw \u2190matrix.special_linear_group.coe_matrix_coe,\n  have := matrix.special_linear_group.det_coe ((\u03b3 : SL(2, \u2124) ) : SL(2, \u211d)),\n  rw this,\n  simp,\n  sorry,\n  intros hf \u03b3,\n  simp_rw slash,\n  ext1,\n  have hff:= hf \u03b3 x,\n  rw hff,\n  rw mul_comm,\n  have h5:= upper_half_plane.denom_ne_zero (\u03b3 : GL(2, \u211d)\u207a) 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 ((\u03b3 : SL(2, \u2124) ) : SL(2, \u211d)),\n  rw this,\n  simp,\n  rw \u2190 mul_assoc,\n  simp_rw h55,\n  simp,\nend\n\nlemma mul_modular  (k_1 k_2 : \u2124) (\u0393 : subgroup SL(2,\u2124)) (f g : \u210d' \u2192 \u2102)\n  (hf : f \u2208 weakly_modular_submodule_weight_k k_1 \u0393)  (hg : g \u2208 weakly_modular_submodule_weight_k k_2 \u0393) :\n  f * g  \u2208 weakly_modular_submodule_weight_k (k_1+k_2) \u0393 :=\nbegin\n  simp only [wmodular_mem', pi.mul_apply, coe_coe] at *,\n  intros \u03b3 z,\n  have hff:= hf \u03b3 z,\n  have hgg:= hg \u03b3 z,\n  rw [hff,hgg],\n  have h5:= upper_half_plane.denom_ne_zero (\u03b3 : GL(2, \u211d)\u207a) 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\u2080 h5 k_1 k_2,\n  rw pown,\n  ring,\nend\n\n/--The extension of a function from `\u210d` to `\u210d'`-/\ndef hol_extn (f : \u210d \u2192 \u2102) : \u210d' \u2192 \u2102 := \u03bb (z : \u210d'), (f (z : \u210d) )\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 : \u2115 \u2192 Type) (rel : \u2115 \u2192 Type)\n        (rel_lhs : \u2200 {n : \u2115}, rel n \u2192 optree op (finord n))\n        (rel_rhs : \u2200 {n : \u2115}, rel n \u2192 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) (\u03b1 : Type u) : Type u :=\n  mk :: (act : \u03a0 {n : \u2115}, th.op n \u2192 vect \u03b1 n \u2192 \u03b1)\n\n-- Model of a theory\nclass model (th : theory) (\u03b1 : Type u) extends premodel th \u03b1 : Type u:=\n  mk :: (haxiom : \u2200 {n : \u2115} (r : th.rel n) (var : finord n \u2192 \u03b1), (th.rel_lhs r).elim @act var = (th.rel_rhs r).elim @act var)\n\ninstance model_is_premodel(th : theory) (\u03b1 : Type _) [ha : model th \u03b1] : premodel th \u03b1 := ha.to_premodel\n\n\nnamespace premodel\n\ndefinition action (th : theory) (\u03b1 : Type _) [premodel th \u03b1] : \u03a0 {n : \u2115}, th.op n \u2192 vect \u03b1 n \u2192 \u03b1 := @premodel.act th \u03b1 _\n\nend premodel\n\n\nnamespace model\n\ndefinition axiom_eq (th : theory) (\u03b1 : Type _) [model th \u03b1] : \u2200 {n : \u2115} (r : th.rel n) (var : finord n \u2192 \u03b1), (th.rel_lhs r).elim (@premodel.act th \u03b1 _) var = (th.rel_rhs r).elim (@premodel.act th \u03b1 _) var := @model.haxiom th \u03b1 _\n\n--- Trivial model; `unit` is always a model of any algebraic theory.\ninstance triv (th : theory) : model th unit :=\n{\n  act := \u03bb _ _ _, (),\n  haxiom :=\n    begin\n      intros,\n      dsimp [premodel.act],\n      have : \u2200 {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) {\u03b1 : Type u} {\u03b2 : Type v} [premodel th \u03b1] [premodel th \u03b2] (f : \u03b1 \u2192 \u03b2) : Prop := \u2200 {n : \u2115} (\u03bc : th.op n) (as : vect \u03b1 n), f (@premodel.act th \u03b1 _ _ \u03bc as) = (@premodel.act th \u03b2 _ _ \u03bc (as.map f))\n\ndefinition morphism (th : theory) (\u03b1 : Type _) (\u03b2 : Type _) [premodel th \u03b1] [premodel th \u03b2] := {f : \u03b1 \u2192 \u03b2 // is_morphism th f}\n\nnamespace morphism\n\nprotected\ndefinition coe_to_fun {th : theory} (\u03b1 : Type _) (\u03b2 : Type _) [premodel th \u03b1] [premodel th \u03b2] : has_coe_to_fun (morphism th \u03b1 \u03b2)  :=\n  {\n    F := \u03bb_, \u03b1 \u2192 \u03b2,\n    coe := subtype.val\n  }\n\nattribute [instance] morphism.coe_to_fun\n\n-- the identity morphism\ndefinition id {th : theory} {\u03b1 : Type _} [premodel th \u03b1] : morphism th \u03b1 \u03b1 :=\n  \u27e8id, by intros n u as; rw [vect.map_id]; refl\u27e9\n\n-- the composition of morphisms\ndefinition comp {th : theory} {\u03b1 \u03b2 \u03b3 : Type _} [premodel th \u03b1] [premodel th \u03b2] [premodel th \u03b3] : morphism th \u03b2 \u03b3 \u2192 morphism th \u03b1 \u03b2 \u2192 morphism th \u03b1 \u03b3 :=\n  \u03bb g f, \u27e8g.val \u2218 f.val, by intros n k cs; unfold function.comp; rw [vect.map_comp,f.property,g.property]\u27e9\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} {\u03b1 \u03b2 : Type _} [premodel th \u03b1] [premodel th \u03b2] {f g : morphism th \u03b1 \u03b2} : f.val = g.val \u2192 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} {\u03b1 \u03b2 : Type _} [premodel th \u03b1] [premodel th \u03b2] (f : morphism th \u03b1 \u03b2) : \u2200 {n : \u2115} {k : th.op n} {ys : vect {b // \u2203 a, f.val a = b} n}, \u2203 a, f.val a = (@premodel.act th \u03b2 _ _ 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 \u03b1 _ _ 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} {\u03b1 \u03b2 : Type _} [premodel th \u03b1] [premodel th \u03b2] (f : morphism th \u03b1 \u03b2) : premodel th {b // \u2203 a, f.val a = b} :=\n  {\n    act :=\n      \u03bb n k xs, \u27e8@premodel.act th \u03b2 _ _ k (vect.map subtype.val xs), image_act f\u27e9\n  }\n\n-- The image of a morphism in a model forms a model\ndefinition image_model {th : theory} {\u03b1 \u03b2 : Type _} [premodel th \u03b1] [model th \u03b2] (f : morphism th \u03b1 \u03b2) : model th {b // \u2203 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 {\u03b1 : Type*} [fintype \u03b1] (X : \u03b1 \u2192 Type*)\n  [\u2200 i, add_comm_group (X i)] :\n  (\u03a0\u2080 i, X i) \u2243+ (\u03a0 i, X i) :=\n{ map_add' := \u03bb x y, by { ext, simp, },\n  ..dfinsupp.equiv_fun_on_fintype }\n\nnamespace AddCommGroup\n\nuniverses v u\n\ndef pi_\u03c0 {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u}) (i) :\n  AddCommGroup.of (\u03a0 i, X i) \u27f6 X i :=\npi.eval_add_monoid_hom _ _\n\ndef pi_fan {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u}) : fan X :=\nfan.mk (AddCommGroup.of $ \u03a0 i, X i)\n(\u03bb b, pi_\u03c0 _ _)\n\ndef pi_lift {\u03b1 : Type v} {Y : AddCommGroup.{max v u}} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f : \u03a0 a, Y \u27f6 X a) : Y \u27f6 AddCommGroup.of (\u03a0 i, X i) :=\n{ to_fun := \u03bb y i, f _ y,\n  map_zero' := by { ext, simp },\n  map_add' := \u03bb x y, by { ext, simp } }\n\n@[simp, reassoc]\nlemma pi_lift_\u03c0 {\u03b1 : Type v} {Y : AddCommGroup.{max v u}} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f : \u03a0 a, Y \u27f6 X a) (i) :\n  pi_lift X f \u226b pi_\u03c0 _ i = f _ := by { ext, refl }\n\nlemma pi_hom_ext {\u03b1 : Type v} {Y : AddCommGroup.{max v u}} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f g : Y \u27f6 AddCommGroup.of (\u03a0 i, X i))\n  (h : \u2200 i, f \u226b pi_\u03c0 _ i = g \u226b pi_\u03c0 _ i) : f = g :=\nby { ext y a, specialize h a, apply_fun (\u03bb e, e y) at h, exact h }\n\ndef is_limit_pi_fan {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u}) :\n  is_limit (pi_fan X) :=\n{ lift := \u03bb S, pi_lift _ $ \u03bb a, S.\u03c0.app \u27e8_\u27e9,\n  fac' := begin\n    rintros S \u27e8j\u27e9,\n    apply pi_lift_\u03c0,\n  end,\n  uniq' := begin\n    intros S m hm,\n    apply pi_hom_ext,\n    intros i,\n    erw [hm \u27e8i\u27e9, pi_lift_\u03c0],\n  end }\n\nnoncomputable\ndef hom_product_comparison\n  {\u03b1 : Type v}\n  (A : AddCommGroup.{max v u})\n  (X : \u03b1 \u2192 AddCommGroup.{max v u}) :\n  AddCommGroup.of (A \u27f6 \u220f X) \u27f6 \u220f (\u03bb i, AddCommGroup.of (A \u27f6 (X i))) :=\nlimits.pi.lift $ \u03bb a, (preadditive_yoneda.flip.obj (opposite.op A)).map (limits.pi.\u03c0 _ _)\n\ninstance is_iso_hom_product_comparison\n  {\u03b1 : Type v}\n  (A : AddCommGroup.{max v u})\n  (X : \u03b1 \u2192 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 : (\u220f \u03bb (i : \u03b1), AddCommGroup.of (A \u27f6 X i)) \u2245 AddCommGroup.of\n    (\u03a0 i, AddCommGroup.of (A \u27f6 X i)) :=\n    (limits.limit.is_limit _).cone_point_unique_up_to_iso\n    (is_limit_pi_fan (\u03bb i, of (A \u27f6 X i))),\n  suffices : is_iso (A.hom_product_comparison X \u226b t.hom),\n  { apply is_iso.of_is_iso_comp_right _ t.hom, exact this },\n  have ht : A.hom_product_comparison X \u226b t.hom =\n    (is_limit_pi_fan (\u03bb i, of (A \u27f6 X i))).lift\n    \u27e8_, discrete.nat_trans $ \u03bb i, (preadditive_yoneda.flip.obj (opposite.op A)).map\n      (limits.pi.\u03c0 _ _)\u27e9,\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 \u27e8j\u27e9,\n    apply_fun (\u03bb e, e j) at h,\n    exact h },\n  { rw epi_iff_surjective,\n    intros f,\n    use limits.pi.lift (\u03bb i, f i),\n    dsimp [is_limit_pi_fan, pi_lift],\n    simp [pi_lift_\u03c0] }\nend\n\ndef direct_sum_\u03c0 {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u}) (i) :\n  AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)) \u27f6 X i :=\n{ to_fun := \u03bb f, let e : \u03a0\u2080 (i : \u03b1), (X i) := f in e i,\n  map_zero' := by simp,\n  map_add' := \u03bb x y, by { dsimp, simp } }\n\ndef direct_sum_fan {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u}) : fan X :=\nfan.mk (AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)))\n(\u03bb b, direct_sum_\u03c0 _ _)\n\nopen_locale classical\n\ndef direct_sum_lift {\u03b1 : Type v} [fintype \u03b1]\n  {Y : AddCommGroup.{max v u}} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f : \u03a0 a, Y \u27f6 X a) :\n  Y \u27f6 AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)) :=\n{ to_fun := \u03bb y, (dfinsupp.add_equiv_pi_on_fintype _).symm $ \u03bb i, f i y,\n  map_zero' := begin\n    simp_rw map_zero,\n    change ((dfinsupp.add_equiv_pi_on_fintype (\u03bb (i : \u03b1), \u21a5(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 (\u03bb (i : \u03b1), \u21a5(X i))).symm)\n      ((\u03bb (i : \u03b1), (f i) x) + (\u03bb (i : \u03b1), (f i) y)) = _,\n    simp,\n  end }\n\n@[simp, reassoc]\nlemma direct_sum_lift_\u03c0 {\u03b1 : Type v} [fintype \u03b1]\n  {Y : AddCommGroup.{max v u}} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f : \u03a0 a, Y \u27f6 X a) (i) :\n  direct_sum_lift X f \u226b direct_sum_\u03c0 _ i = f i :=\nby { ext, refl }\n\nlemma direct_sum_hom_ext {\u03b1 : Type v} [fintype \u03b1]\n  {Y : AddCommGroup.{max v u}} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f g : Y \u27f6 AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)))\n  (h : \u2200 i, f \u226b direct_sum_\u03c0 _ i = g \u226b direct_sum_\u03c0 _ i) :\n  f = g :=\nbegin\n  ext,\n  specialize h i,\n  apply_fun (\u03bb e, e x) at h, exact h\nend\n\ndef is_limit_direct_sum_fan {\u03b1 : Type v} [fintype \u03b1]\n  (X : \u03b1 \u2192 AddCommGroup.{max v u}) : is_limit (direct_sum_fan X) :=\n{ lift := \u03bb S, direct_sum_lift _ $ \u03bb a, S.\u03c0.app \u27e8a\u27e9, -- S.\u03c0.app,\n  fac' := begin\n    rintros S \u27e8j\u27e9,\n    apply direct_sum_lift_\u03c0,\n  end,\n  uniq' := begin\n    intros S m hm,\n    apply direct_sum_hom_ext,\n    intros i,\n    specialize hm \u27e8i\u27e9,\n    erw [hm, direct_sum_lift_\u03c0],\n  end }\n\nnoncomputable theory\n\ndef to_direct_sum {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (i : \u03b1) : X i \u27f6 AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)) :=\ndirect_sum.of (\u03bb i, X i) i\n\ndef direct_sum_punit_iso (A : AddCommGroup.{max v u}) :\n  AddCommGroup.of (direct_sum _ (\u03bb i : punit.{v+1}, A)) \u2245 A :=\n{ hom := direct_sum_\u03c0 _ punit.star,\n  inv := to_direct_sum (\u03bb i, A) punit.star,\n  hom_inv_id' := begin\n    ext \u27e8\u27e9 \u27e8\u27e9,\n    ext t \u27e8\u27e9, -- WAT?\n    dsimp [direct_sum_\u03c0, to_direct_sum],\n    simp,\n  end,\n  inv_hom_id' := begin\n    ext a,\n    dsimp [direct_sum_\u03c0, to_direct_sum],\n    simp,\n  end }\n\ndef direct_sum_\u03b9 {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (i : \u03b1) : X i \u27f6 AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)) :=\ndirect_sum.of _ i\n\ndef direct_sum_desc {\u03b1 : Type v} {Y : AddCommGroup.{max v u}} (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f : \u03a0 i, X i \u27f6 Y) :\n  AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)) \u27f6 Y :=\ndirect_sum.to_add_monoid f\n\n@[simp, reassoc]\nlemma direct_sum_\u03b9_desc {\u03b1 : Type v} {Y : AddCommGroup.{max v u}}\n  (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f : \u03a0 i, X i \u27f6 Y) (i) :\n  direct_sum_\u03b9 X i \u226b direct_sum_desc X f = f _ :=\nby { ext, dsimp [direct_sum_\u03b9, direct_sum_desc], simp }\n\nlemma direct_sum_hom_ext' {\u03b1 : Type v} {Y : AddCommGroup.{max v u}}\n  (X : \u03b1 \u2192 AddCommGroup.{max v u})\n  (f g : AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)) \u27f6 Y)\n  (h : \u2200 i, direct_sum_\u03b9 X i \u226b f = direct_sum_\u03b9 X i \u226b g) :\n  f = g :=\nbegin\n  have hf : f = direct_sum_desc X (\u03bb i, direct_sum_\u03b9 X i \u226b f),\n  { ext t, apply direct_sum.to_add_monoid.unique },\n  have hg : g = direct_sum_desc X (\u03bb i, direct_sum_\u03b9 X i \u226b 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 {\u03b1 : Type v}\n  (X : \u03b1 \u2192 AddCommGroup.{max v u}) : cofan X :=\ncofan.mk _ (direct_sum_\u03b9 _)\n\ndef is_colimit_direct_sum_cofan {\u03b1 : Type v}\n  (X : \u03b1 \u2192 AddCommGroup.{max v u}) : is_colimit (direct_sum_cofan X) :=\n{ desc := \u03bb S, direct_sum_desc X (\u03bb a, S.\u03b9.app \u27e8a\u27e9), -- S.\u03b9.app,\n  fac' := begin\n    rintros X \u27e8j\u27e9,\n    apply direct_sum_\u03b9_desc,\n  end,\n  uniq' := begin\n    intros S m hm,\n    apply direct_sum_hom_ext',\n    intros i,\n    specialize hm \u27e8i\u27e9,\n    erw hm, rw direct_sum_\u03b9_desc,\n  end }\n\nlemma direct_sum_\u03b9_\u03c0 {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u}) (i : \u03b1) :\n  direct_sum_\u03b9.{v u} X i \u226b direct_sum_\u03c0.{v u} X i = \ud835\udfd9 _ :=\nbegin\n  ext,\n  dsimp [direct_sum_\u03b9, direct_sum_\u03c0, 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_\u03b9_\u03c0_of_ne {\u03b1 : Type v} (X : \u03b1 \u2192 AddCommGroup.{max v u}) (i j : \u03b1) (h : i \u2260 j):\n  direct_sum_\u03b9.{v u} X i \u226b direct_sum_\u03c0.{v u} X j = 0 :=\nbegin\n  ext,\n  dsimp [direct_sum_\u03b9, direct_sum_\u03c0, 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 {\u03b1 : Type u} [fintype \u03b1]\n  (X : \u03b1 \u2192 AddCommGroup.{u}) : bicone X :=\n{ X := AddCommGroup.of (direct_sum \u03b1 (\u03bb i, X i)),\n  \u03c0 := direct_sum_\u03c0.{u u} _,\n  \u03b9 := direct_sum_\u03b9.{u u} _,\n  \u03b9_\u03c0 := \u03bb i j, begin\n    ext t,\n    dsimp [direct_sum_\u03b9, direct_sum_\u03c0, 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 {\u03b1 : Type u} [fintype \u03b1]\n  (X : \u03b1 \u2192 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 : \u2115 \u2192 \u2115) (k : \u2115)\n\nexample (h\u2081 : f 0 = 0) (h\u2082 : k = 0) : f k = 0 :=\n  by rw [h\u2082, h\u2081]\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 : \u2124) := n * (n / 2)\n\n/-- Final solution -/\ntheorem final_solution (n : \u2124) : (\u2203 k : \u2115, even (f^[k] n)) \u2194 n \u2260 3 :=\nbegin\n  ---- Go for the contrapositive and prove the easy direction\n  rw [\u2190 not_iff_not, not_not, not_exists, iff.comm]; split,\n  rintros rfl,\n  suffices : \u2200 x : \u2115, 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 : \u2200 {n c : \u2124},\n    c \u2260 0 \u2192 n \u2261 3 [ZMOD 2 * c] \u2192 f n \u2261 3 [ZMOD 2 * c] \u2192 n \u2261 3 [ZMOD 2 * (2 * c)],\n  { intros n h,\n    suffices : \u2200 x k : \u2115, (f^[k] n) \u2261 3 [ZMOD 2 ^ x],\n    { obtain \u27e8x, h0\u27e9 : \u2203 x : \u2115, (n - 3).nat_abs < x :=\n        \u27e8(n - 3).nat_abs.succ, nat.lt_succ_self _\u27e9,\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 [\u2190 int.coe_nat_lt, nat.cast_pow, nat.cast_two, \u2190 int.abs_eq_nat_abs] at h0,\n      rw \u2190 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, \u2190 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 \u2261 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 [\u2190 mul_sub_one, add_sub_cancel', mul_comm c, \u2190 mul_assoc, bit1,\n       mul_dvd_mul_iff_right hc, add_one_mul, dvd_add_right \u27e8d, rfl\u27e9] 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 \u25b8 x.1.zero_mem\n\nsection\nvariables (R) (S : Type v) [comm_ring S]\n\n/-- The prime spectrum of `R \u00d7 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 \u00d7 S) \u2243 prime_spectrum R \u2295 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 \u22a4 :=\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 \u22a4 x.as_ideal :=\nby { cases x, refl }\n\nend\n\n@[ext] lemma ext {x y : prime_spectrum R} :\n  x = y \u2194 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 \u2286 x.as_ideal}\n\n@[simp] lemma mem_zero_locus (x : prime_spectrum R) (s : set R) :\n  x \u2208 zero_locus s \u2194 s \u2286 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\u2a05 (x : prime_spectrum R) (h : x \u2208 t), x.as_ideal\n\nlemma coe_vanishing_ideal (t : set (prime_spectrum R)) :\n  (vanishing_ideal t : set R) = {f : R | \u2200 x : prime_spectrum R, x \u2208 t \u2192 f \u2208 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 \u2208 vanishing_ideal t \u2194 \u2200 x : prime_spectrum R, x \u2208 t \u2192 f \u2208 x.as_ideal :=\nby rw [\u2190 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 \u2286 zero_locus I \u2194 I \u2264 vanishing_ideal t :=\n\u27e8\u03bb h f k, (mem_vanishing_ideal _ _).mpr (\u03bb x j, (mem_zero_locus _ _).mpr (h j) k), \u03bb h,\n  \u03bb x j, (mem_zero_locus _ _).mpr (le_trans h (\u03bb f h, ((mem_vanishing_ideal _ _).mp h) x j))\u27e9\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  (\u03bb I, zero_locus I) (\u03bb t, vanishing_ideal t) :=\n\u03bb 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  (\u03bb s, zero_locus s) (\u03bb 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 \u2286 zero_locus s \u2194 s \u2286 vanishing_ideal t :=\n(gc_set R) s t\n\nend gc\n\nlemma subset_vanishing_ideal_zero_locus (s : set R) :\n  s \u2286 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 \u2264 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 $ \u03bb f,\nbegin\n  rw [mem_vanishing_ideal, ideal.radical_eq_Inf, submodule.mem_Inf],\n  exact \u27e8(\u03bb h x hx, h \u27e8x, hx.2\u27e9 hx.1), (\u03bb h x hx, h x.1 \u27e8hx, x.2\u27e9)\u27e9\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 \u25b8 (gc R).l_u_l_eq_l I\n\nlemma subset_zero_locus_vanishing_ideal (t : set (prime_spectrum R)) :\n  t \u2286 zero_locus (vanishing_ideal t) :=\n(gc R).l_u_le t\n\nlemma zero_locus_anti_mono {s t : set R} (h : s \u2286 t) : zero_locus t \u2286 zero_locus s :=\n(gc_set R).monotone_l h\n\nlemma zero_locus_anti_mono_ideal {s t : ideal R} (h : s \u2264 t) :\n  zero_locus (t : set R) \u2286 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 \u2286 t) :\n  vanishing_ideal t \u2264 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) \u2286 zero_locus (J : set R) \u2194 J \u2264 I.radical :=\n\u27e8\u03bb h, ideal.radical_le_radical_iff.mp (vanishing_ideal_zero_locus_eq_radical I \u25b8\n  vanishing_ideal_zero_locus_eq_radical J \u25b8 vanishing_ideal_anti_mono h),\n\u03bb h, zero_locus_radical I \u25b8 zero_locus_anti_mono_ideal h\u27e9\n\nlemma zero_locus_subset_zero_locus_singleton_iff (f g : R) :\n  zero_locus ({f} : set R) \u2286 zero_locus {g} \u2194 g \u2208 (ideal.span ({f} : set R)).radical :=\nby rw [\u2190 zero_locus_span {f}, \u2190 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 ((\u22a5 : 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 (\u2205 : set R) = set.univ :=\n(gc_set R).l_bot\n\n@[simp] lemma vanishing_ideal_univ :\n  vanishing_ideal (\u2205 : set (prime_spectrum R)) = \u22a4 :=\nby simpa using (gc R).u_top\n\nlemma zero_locus_empty_of_one_mem {s : set R} (h : (1:R) \u2208 s) :\n  zero_locus s = \u2205 :=\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 = \u22a4, { 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) = \u2205 :=\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) = \u2205 \u2194 I = \u22a4 :=\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 \u27e8M, hM, hIM\u27e9,\n    exact \u27e8\u27e8M, hM.is_prime\u27e9, hIM\u27e9 },\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) = \u2205 :=\nzero_locus_empty_of_one_mem (set.mem_univ 1)\n\nlemma zero_locus_sup (I J : ideal R) :\n  zero_locus ((I \u2294 J : ideal R) : set R) = zero_locus I \u2229 zero_locus J :=\n(gc R).l_sup\n\nlemma zero_locus_union (s s' : set R) :\n  zero_locus (s \u222a s') = zero_locus s \u2229 zero_locus s' :=\n(gc_set R).l_sup\n\nlemma vanishing_ideal_union (t t' : set (prime_spectrum R)) :\n  vanishing_ideal (t \u222a t') = vanishing_ideal t \u2293 vanishing_ideal t' :=\n(gc R).u_inf\n\nlemma zero_locus_supr {\u03b9 : Sort*} (I : \u03b9 \u2192 ideal R) :\n  zero_locus ((\u2a06 i, I i : ideal R) : set R) = (\u22c2 i, zero_locus (I i)) :=\n(gc R).l_supr\n\nlemma zero_locus_Union {\u03b9 : Sort*} (s : \u03b9 \u2192 set R) :\n  zero_locus (\u22c3 i, s i) = (\u22c2 i, zero_locus (s i)) :=\n(gc_set R).l_supr\n\nlemma zero_locus_bUnion (s : set (set R)) :\n  zero_locus (\u22c3 s' \u2208 s, s' : set R) = \u22c2 s' \u2208 s, zero_locus s' :=\nby simp only [zero_locus_Union]\n\nlemma vanishing_ideal_Union {\u03b9 : Sort*} (t : \u03b9 \u2192 set (prime_spectrum R)) :\n  vanishing_ideal (\u22c3 i, t i) = (\u2a05 i, vanishing_ideal (t i)) :=\n(gc R).u_infi\n\nlemma zero_locus_inf (I J : ideal R) :\n  zero_locus ((I \u2293 J : ideal R) : set R) = zero_locus I \u222a zero_locus J :=\nset.ext $ \u03bb x, by simpa using x.2.inf_le\n\nlemma union_zero_locus (s s' : set R) :\n  zero_locus s \u222a zero_locus s' = zero_locus ((ideal.span s) \u2293 (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 \u222a zero_locus J :=\nset.ext $ \u03bb 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} \u222a zero_locus {g} :=\nset.ext $ \u03bb x, by simpa using x.2.mul_mem_iff_mem_or_mem\n\n@[simp] lemma zero_locus_pow (I : ideal R) {n : \u2115} (hn : 0 < n) :\n  zero_locus ((I ^ n : ideal R) : set R) = zero_locus I :=\nzero_locus_radical (I ^ n) \u25b8 (I.radical_pow n hn).symm \u25b8 zero_locus_radical I\n\n@[simp] lemma zero_locus_singleton_pow (f : R) (n : \u2115) (hn : 0 < n) :\n  zero_locus ({f ^ n} : set R) = zero_locus {f} :=\nset.ext $ \u03bb 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 \u2294 vanishing_ideal t' \u2264 vanishing_ideal (t \u2229 t') :=\nbegin\n  intros r,\n  rw [submodule.mem_sup, mem_vanishing_ideal],\n  rintro \u27e8f, hf, g, hg, rfl\u27e9 x \u27e8hxt, hxt'\u27e9,\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 \u2208 (zero_locus {f} : set (prime_spectrum R))\u1d9c \u2194 f \u2209 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  (\u27e8set.univ, by simp\u27e9)\n  begin\n    intros Zs h,\n    rw set.sInter_eq_Inter,\n    let f : Zs \u2192 set R := \u03bb i, classical.some (h i.2),\n    have hf : \u2200 i : Zs, \u2191i = zero_locus (f i) := \u03bb i, (classical.some_spec (h i.2)).symm,\n    simp only [hf],\n    exact \u27e8_, zero_locus_Union _\u27e9\n  end\n  (by { rintro _ \u27e8s, rfl\u27e9 _ \u27e8t, rfl\u27e9, exact \u27e8_, (union_zero_locus s t).symm\u27e9 })\n\nlemma is_open_iff (U : set (prime_spectrum R)) :\n  is_open U \u2194 \u2203 s, U\u1d9c = zero_locus s :=\nby simp only [@eq_comm _ U\u1d9c]; refl\n\nlemma is_closed_iff_zero_locus (Z : set (prime_spectrum R)) :\n  is_closed Z \u2194 \u2203 s, Z = zero_locus s :=\nby rw [\u2190 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 \u2194 \u2203 (s : ideal R), Z = zero_locus s :=\n(is_closed_iff_zero_locus _).trans\n  \u27e8\u03bb x, \u27e8_, x.some_spec.trans (zero_locus_span _).symm\u27e9, \u03bb x, \u27e8_, x.some_spec\u27e9\u27e9\n\nlemma is_closed_iff_zero_locus_radical_ideal (Z : set (prime_spectrum R)) :\n  is_closed Z \u2194 \u2203 (s : ideal R), s.radical = s \u2227 Z = zero_locus s :=\n(is_closed_iff_zero_locus_ideal _).trans\n  \u27e8\u03bb x, \u27e8_, ideal.radical_idem _, x.some_spec.trans (zero_locus_radical _).symm\u27e9,\n    \u03bb x, \u27e8_, x.some_spec.2\u27e9\u27e9\n\nlemma is_closed_zero_locus (s : set R) :\n  is_closed (zero_locus s) :=\nby { rw [is_closed_iff_zero_locus], exact \u27e8s, rfl\u27e9 }\n\nlemma is_closed_singleton_iff_is_maximal (x : prime_spectrum R) :\n  is_closed ({x} : set (prime_spectrum R)) \u2194 x.as_ideal.is_maximal :=\nbegin\n  refine (is_closed_iff_zero_locus _).trans \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { obtain \u27e8s, hs\u27e9 := h,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem] at hs,\n    refine \u27e8\u27e8x.2.1, \u03bb I hI, not_not.1 (mt (ideal.exists_le_maximal I) $\n      not_exists.2 (\u03bb J, not_and.2 $ \u03bb hJ hIJ,_))\u27e9\u27e9,\n    exact ne_of_lt (lt_of_lt_of_le hI hIJ) (symm $ congr_arg prime_spectrum.as_ideal\n      (hs.2 \u27e8J, hJ.is_prime\u27e9 (\u03bb r hr, hIJ (le_of_lt hI $ hs.1 hr)))) },\n  { refine \u27e8x.as_ideal.1, _\u27e9,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem],\n    refine \u27e8\u03bb _ h, h, \u03bb y hy, prime_spectrum.ext.2 (h.eq_of_le y.2.ne_top hy).symm\u27e9 }\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' \u27e8ht', ht\u27e9,\n    obtain \u27e8fs, rfl\u27e9 : \u2203 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 \u25b8 (gc R).u_l_u_eq_u t\n\nlemma t1_space_iff_is_field [is_domain R] :\n  t1_space (prime_spectrum R) \u2194 is_field R :=\nbegin\n  refine \u27e8_, \u03bb h, _\u27e9,\n  { introI h,\n    have hbot : ideal.is_prime (\u22a5 : 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 \u27e8\u22a5, hbot\u27e9)) (not_not.2 rfl)) },\n  { refine \u27e8\u03bb x, (is_closed_singleton_iff_is_maximal x).2 _\u27e9,\n    by_cases hx : x.as_ideal = \u22a5,\n    { exact hx.symm \u25b8 @ideal.bot_is_maximal R (@field.to_division_ring _ h.to_field) },\n    { exact absurd h (ring.not_is_field_iff_exists_prime.2 \u27e8x.as_ideal, \u27e8hx, x.2\u27e9\u27e9) } }\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)) \u2194 I.radical.is_prime :=\n(zero_locus_radical I) \u25b8 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, \u2190 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\u2081 h\u2082,\n  rw [\u2190 h\u2082.closure_eq, \u2190 zero_locus_vanishing_ideal_eq_closure,\n    is_irreducible_zero_locus_iff] at h\u2081,\n  use \u27e8_, h\u2081\u27e9,\n  obtain \u27e8s, hs, rfl\u27e9 := (is_closed_iff_zero_locus_radical_ideal _).mp h\u2082,\n  rw is_generic_point_iff_forall_closed h\u2082,\n  intros Z hZ hxZ,\n  obtain \u27e8t, rfl\u27e9 := (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 \u2192+* S) (s : set R) :\n  (\u03bb y, \u27e8ideal.comap f y.as_ideal, infer_instance\u27e9 :\n    prime_spectrum S \u2192 prime_spectrum R) \u207b\u00b9' (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 \u2192+* S) : C(prime_spectrum S, prime_spectrum R) :=\n{ to_fun := \u03bb y, \u27e8ideal.comap f y.as_ideal, infer_instance\u27e9,\n  continuous_to_fun :=\n    begin\n      simp only [continuous_iff_is_closed, is_closed_iff_zero_locus],\n      rintro _ \u27e8s, rfl\u27e9,\n      exact \u27e8_, preimage_comap_zero_locus_aux f s\u27e9\n    end }\n\nvariables (f : R \u2192+* 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 \u2192+* S) (g : S \u2192+* S') :\n  comap (g.comp f) = (comap f).comp (comap g) :=\nrfl\n\nlemma comap_comp_apply (f : R \u2192+* S) (g : S \u2192+* 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) \u207b\u00b9' (zero_locus s) = zero_locus (f '' s) :=\npreimage_comap_zero_locus_aux f s\n\nlemma comap_injective_of_surjective (f : R \u2192+* S) (hf : function.surjective f) :\n  function.injective (comap f) :=\n\u03bb 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 \u2192+* 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 \u2192+* 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 \u2190 is_closed_compl_iff,\n  generalize : U\u1d9c = Z,\n  simp_rw [is_closed_induced_iff, is_closed_iff_zero_locus],\n  split,\n  { rintro \u27e8s, rfl\u27e9,\n    refine \u27e8_,\u27e8(algebra_map R S) \u207b\u00b9' (ideal.span s),rfl\u27e9,_\u27e9,\n    rw [preimage_comap_zero_locus, \u2190 zero_locus_span, \u2190 zero_locus_span s],\n    congr' 1,\n    exact congr_arg submodule.carrier (is_localization.map_comap M S (ideal.span s)) },\n  { rintro \u27e8_, \u27e8t, rfl\u27e9, rfl\u27e9, 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 (\u03bb (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\u27e8localization_comap_inducing S M, localization_comap_injective S M\u27e9\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 \u27e8p, rfl\u27e9 x \u27e8hx\u2081, hx\u2082\u27e9,\n    exact (p.2.1 : \u00ac _)\n      (p.as_ideal.eq_top_of_is_unit_mem hx\u2082 (is_localization.map_units S \u27e8x, hx\u2081\u27e9)) },\n  { intro h,\n    use \u27e8x.as_ideal.map (algebra_map R S),\n      is_localization.is_prime_of_is_prime_disjoint M S _ x.2 h\u27e9,\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 \u2209 x.as_ideal },\n  property := \u27e8{r}, set.ext $ \u03bb x, set.singleton_subset_iff.trans $ not_not.symm\u27e9 }\n\n@[simp] lemma mem_basic_open (f : R) (x : prime_spectrum R) :\n  x \u2208 basic_open f \u2194 f \u2209 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})\u1d9c :=\nset.ext $ \u03bb 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) = \u22a4 :=\ntopological_space.opens.ext $ by simp\n\n@[simp] lemma basic_open_zero : basic_open (0 : R) = \u22a5 :=\ntopological_space.opens.ext $ by simp\n\nlemma basic_open_le_basic_open_iff (f g : R) :\n  basic_open f \u2264 basic_open g \u2194 f \u2208 (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 \u2293 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) \u2264 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) \u2264 basic_open g :=\nby { rw basic_open_mul f g, exact inf_le_right }\n\n@[simp] lemma basic_open_pow (f : R) (n : \u2115) (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 (\u03bb (r : R), (basic_open r : set (prime_spectrum R)))) :=\nbegin\n  apply topological_space.is_topological_basis_of_open_of_nhds,\n  { rintros _ \u27e8r, rfl\u27e9,\n    exact is_open_basic_open },\n  { rintros p U hp \u27e8s, hs\u27e9,\n    rw [\u2190 compl_compl U, set.mem_compl_eq, \u2190 hs, mem_zero_locus, set.not_subset] at hp,\n    obtain \u27e8f, hfs, hfp\u27e9 := hp,\n    refine \u27e8basic_open f, \u27e8f, rfl\u27e9, hfp, _\u27e9,\n    rw [\u2190 set.compl_subset_compl, \u2190 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 \u2190 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 $ \u03bb \u03b9 Z hZc hZ,\nbegin\n  let I : \u03b9 \u2192 ideal R := \u03bb i, vanishing_ideal (Z i),\n  have hI : \u2200 i, Z i = zero_locus (I i) := \u03bb 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, \u2190 set.diff_eq,\n      set.diff_eq_empty, funext hI, \u2190 zero_locus_supr] at hZ,\n  obtain \u27e8n, hn\u27e9 : f \u2208 (\u2a06 (i : \u03b9), I i).radical,\n  { rw \u2190 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 \u27e8s, hs\u27e9,\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, \u2190 set.diff_eq,\n           set.diff_eq_empty, hI, \u2190 zero_locus_supr],\n  rw \u2190 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 \u27e8n, hs\u27e9\nend\n\n@[simp]\nlemma basic_open_eq_bot_iff (f : R) :\n  basic_open f = \u22a5 \u2194 is_nilpotent f :=\nbegin\n  rw [\u2190 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\u2081 h\u2082,\n    exact h\u2081 \u27e8submonoid.mem_powers r, h\u2082\u27e9 },\n  { rintros h\u2081 _ \u27e8\u27e8n, rfl\u27e9, h\u2083\u27e9,\n    exact h\u2081 (x.2.mem_of_pow_mem _ h\u2083) },\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 \u2264 y` if and only if `y \u2208 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 \u2264 y.as_ideal \u2194 x \u2264 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 \u2194 x < y :=\nsubtype.coe_lt_coe\n\nlemma le_iff_mem_closure (x y : prime_spectrum R) :\n  x \u2264 y \u2194 y \u2208 closure ({x} : set (prime_spectrum R)) :=\nby rw [\u2190 as_ideal_le_as_ideal, \u2190 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 \u2264 y \u2194 x \u2933 y :=\nle_iff_mem_closure x y\n\ninstance : t0_space (prime_spectrum R) :=\nby { simp [t0_space_iff_or_not_mem_closure, \u2190 le_iff_mem_closure,\n  \u2190 not_and_distrib, \u2190 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 \u2933 y) :\n  localization.at_prime y.as_ideal \u2192+* 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 \u27e8a, ha\u27e9,\n    rw [\u2190 prime_spectrum.le_iff_specializes, \u2190 as_ideal_le_as_ideal, \u2190 set_like.coe_subset_coe,\n      \u2190 set.compl_subset_compl] at h,\n    exact (is_localization.map_units _ \u27e8a, (show a \u2208 x.as_ideal.prime_compl, from h ha)\u27e9 : _)\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\u27e8maximal_ideal R, (maximal_ideal.is_maximal R).is_prime\u27e9\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 \u2192+* S) : is_local_ring_hom f \u2194 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 \u2192+* 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": "import chess.utils\nimport data.matrix.notation\nimport data.set.finite\n\n/-!\n\n# Definitions and theorems about the chess board field\n\n## Summary\n\nThe field on which chess pieces are placed is a 2D plane, where each\nposition corresponds to a piece index. This is because we think of\ndefining pieces and moves, usually, by indicating which position\nthey are at, and which position they are moved to.\n\n## Main definitions\n\n1. The playfield itself (`playfield`)\n2. Conversion from a `matrix` of (possibly) occupied spaces to a `playfield`\n3. Moving a piece by switching the indices at two specified positions using `move_piece`\n4. Making a sequence of moves at once using `move_sequence`\n\n## Implementation details\n\n1. The `playfield` type itself has no requirements to be finite in any dimension,\nor that the indices used are finite. We represent the actual index wrapped by\n`option`, such that the empty square can be an `option.none`. The playfield definition\nwraps the two types used to define the dimensions of the board into a pair.\n\n2. In the current implementation, the way to construct a `playfield` is to provide\na matrix. This limits the `playfield` to a finite 2D plane. Another possible implementation\nis of a \"sparse matrix\", where for each index, we can look up where the piece is.\nThis now allows for an infinite playfield, but still complicates using infinite pieces.\nFor now, the closely-tied `matrix` definition makes `playfield` a light type wrapper\non top of `matrix`, i.e. a function of two variables.\n\n3. Currently, `move_piece` just swaps the (potentially absent) indices at two positions.\nThis is done by using an `equiv.swap` as an updating function. For now, this means that\nmoves that use `move_piece` are non-capturing. Additionally, no math or other requirements\non the positions or their contents is required. This means that `move_piece` supports a\nmove from a position to itself. A separate `move` is defined in `chess.move` that has\nmore chess-like rule constraints.\n\n4. Index presence on the board is not limited to have each index on at-most-one position.\nPreventing duplication of indices is not enforced by the `playfield` itself. However,\nany given position can hold at-most-one index on it. The actual chess-like rule constraints\nare in `chess.board`.\n\n5. Sequences of moves are implemented on top of `move`s, rather than vice versa (`move`s\nbeing defined as sequences of length one). This *probably* causes a bit of duplication,\nwhich may warrant flipping things later.\n\n-/\n\n-- The height and width of the playfield\nvariables (m n : Type*)\n-- The index type at (possibly) each position\nvariables (\u03b9 : Type*)\n\n/--\nA `playfield m n \u03b9` represents a `matrix (m \u00d7 n) option \u03b9`, which is\na model for a `m \u00d7 n` shaped game board where not every square is\noccupied.\n-/\ndef playfield : Type* := m \u00d7 n \u2192 option \u03b9\n\nsection playfield\n\n-- The dimensions and index type of the playfield can be assumed\nvariables {m n \u03b9}\n\n/--\nA conversion function to turn a bare `matrix` into a `playfield`.\nA `matrix` requires the dimensions to be finite.\n\nAn example empty 3 \u00d7 3 playfield for 4 pieces could be generated by:\n```\nmatrix_to_playfield ((\n  ![![none, none, none],\n    ![none, none, none],\n    ![none, none, none]] : matrix (fin 3) (fin 3) (option (fin 4))\n```\n\nwhere the positions are 0-indexed, with the origin in the top-left,\nfirst dimension for the row, and second dimension for the column\n(0,0) (0,1) (0,2)\n(1,0) (1,1) (1,2)\n(2,0) (2,1) (2,2)\n\n-/\ndef matrix_to_playfield [fintype m] [fintype n]\n  (M : matrix m n (option \u03b9)) : playfield m n \u03b9 :=\n\u03bb \u27e8x, y\u27e9, M x y\n\n-- Provide a short notation to be used for `playfield` construction when\n-- using matrix notation\nnotation `PF` M := matrix_to_playfield M\n\n/--\nA `playfield` is by default `inhabited` by empty squares everywhere.\n-/\ninstance playfield.inhabited : inhabited (playfield m n \u03b9) :=\n\u27e8\u03bb \u27e8x, y\u27e9, none\u27e9\n\n-- Definitions and lemmas in this section will be accessible as `pf.___`\n-- for a `pf : playfield m n \u03b9`\nnamespace playfield\n\nsection repr\n\n-- The size of the \"vectors\" for a `fin n' \u2192 \u03b9`, for `has_repr` definitions\nvariables {m' n' : \u2115}\n-- Require an index to be `repr`esentable to be able to represent a \"vector\" of it\nvariable [has_repr \u03b9]\n\n-- A finite `playfield` is just a uncurried `matrix`.\ninstance playfield_repr_instance :\n  has_repr (playfield (fin n') (fin m') \u03b9) := \u27e8chess.utils.matrix_repr \u2218 function.curry\u27e9\n\nend repr\n\n/--\nA piece, identified by an index, is on the board, if there is any position\nsuch that the index at that position is the one we're inquiring about.\nProviding a `has_mem` instance allows using `ix \u2208 pf` for `ix : \u03b9, pf : playfield m n \u03b9`.\nThis definition does not preclude duplicated indices on the playfield.\nSee \"Implementation details\".\n-/\ninstance : has_mem \u03b9 (playfield m n \u03b9) :=\n\u27e8\u03bb ix p, \u2203 pos, p pos = some ix\u27e9\n\ninstance playfield_decidable_in [fintype m] [fintype n] [decidable_eq \u03b9]\n  {pf : playfield m n \u03b9} {ix : \u03b9} : decidable (ix \u2208 pf) := fintype.decidable_exists_fintype\n\ninstance fintype\n  [fintype m] [fintype n] [decidable_eq m] [decidable_eq n]\n  [fintype \u03b9] :\n  fintype (playfield m n \u03b9) := pi.fintype\n\n-- Fix a `pf : playfield m n \u03b9` to use in definitions and lemmas below\nvariables (pf : playfield m n \u03b9)\n\nsection occupied\n\n/--\nA wrapper to indicate that there is some `ix : \u03b9` such that\nfor a `pf : playfield m n \u03b9`, at `pos : m \u00d7 n`, `pf pos = some ix`.\n-/\n@[reducible] def occupied_at (pos : m \u00d7 n) : Prop := \u2203 ix, pf pos = some ix\n\n/--\nThe predicate that `pf.occupied_at pos` for some pos is decidable\nif the indices `ix : \u03b9` are finite and decidably equal.\n-/\ninstance occupied_at.decidable_pred [fintype \u03b9] [decidable_eq \u03b9] : decidable_pred pf.occupied_at :=\n  set.decidable_set_of (\u03bb (a : m \u00d7 n), \u2203 (ix : \u03b9), pf a = some ix)\n\nvariable {pf}\n\n/--\nA wrapper to indicate that there is some `ix : \u03b9` such that\nfor a `pf : playfield m n \u03b9`, at `pos : m \u00d7 n`, `pf pos = some ix`.\n-/\nlemma occupied_at_def {pos : m \u00d7 n} (h : pf.occupied_at pos) : \u2203 ix, pf pos = some ix := h\n\n/--\nA wrapper to indicate that there is some `ix : \u03b9` such that\nfor a `pf : playfield m n \u03b9`, at `pos : m \u00d7 n`, `pf pos = some ix`.\n-/\nlemma occupied_at_iff {pos : m \u00d7 n} : pf.occupied_at pos \u2194 \u2203 ix, pf pos = some ix := iff.rfl\n\n/--\nA `pos : m \u00d7 n` is unoccupied iff it is `none`.\n-/\nlemma not_occupied_at_iff {pos : m \u00d7 n} : \u00ac pf.occupied_at pos \u2194 pf pos = none :=\nby simp only [option.eq_none_iff_forall_not_mem, not_exists, option.mem_def]\n\n/--\nA `pf : playfield m n \u03b9` maps any occupied `pos` uniquely.\n-/\nlemma occupied_at_unique {pos : m \u00d7 n} (h : pf.occupied_at pos) : \u2203! ix : \u03b9, pf pos = some ix :=\nbegin\n  refine exists_unique_of_exists_of_unique h _,\n  intros _ _ H H',\n  apply option.some.inj,\n  rw [\u2190H, \u2190H']\nend\n\n/--\nIf for some `pf : playfield m n \u03b9`, at `pos : m \u00d7 n`, `pf pos = some ix`,\nthen that is equivalent to `pf.occupied_at pos`.\n-/\nlemma occupied_at_of_some {pos : m \u00d7 n} {ix : \u03b9} (h : pf pos = some ix) :\n  pf.occupied_at pos :=\n\u27e8ix, h\u27e9\n\n/--\nIf for some `pf : playfield m n \u03b9`, at `pos : m \u00d7 n`, `pf.occupied_at pos`,\nthen for a `pos' : m \u00d7 n` such that `pf pos = pf pos'`, we have that\n`pf.occupied_at pos'`.\n-/\nlemma occupied_at_transfer {pos pos' : m \u00d7 n} (h : pf.occupied_at pos) (H : pf pos = pf pos') :\n  pf.occupied_at pos' :=\nexists.elim h (\u03bb ix hix, \u27e8ix, H \u25b8 hix\u27e9)\n\n/--\nIf for some `pf : playfield m n \u03b9`, at `pos : m \u00d7 n`, `pf pos \u2260 none`,\nthen that is equivalent to `pf.occupied_at pos`.\n-/\nlemma occupied_at_of_ne {pos : m \u00d7 n} (hne : pf pos \u2260 none) : pf.occupied_at pos :=\noption.ne_none_iff_exists'.mp hne\n\n/-- A wrapper API for underlying `option.is_some` propositions. -/\nlemma occupied_has_some {pos : m \u00d7 n} :\n  (pf pos).is_some \u2194 pf.occupied_at pos :=\noption.is_some_iff_exists\n\n/-- A wrapper API for converting between inequalities and existentials. -/\nlemma occupied_has_not_none {pos : m \u00d7 n} :\n  pf pos \u2260 none \u2194 pf.occupied_at pos :=\noption.ne_none_iff_exists'\n\n/--\nIf for some `pf : playfield m n \u03b9`, at `pos : m \u00d7 n`, `pf pos = none`,\nthen that is equivalent to `\u00ac pf.occupied_at pos`.\n-/\nlemma not_occupied_has_none {pos : m \u00d7 n} :\n  (pf pos).is_none \u2194 \u00ac pf.occupied_at pos :=\nby simpa only [not_occupied_at_iff] using option.is_none_iff_eq_none\n\nvariable (pf)\n\n/-- The `set` of all positions that are `occupied_at`. -/\ndef occupied_positions : set (m \u00d7 n) := {p : m \u00d7 n | pf.occupied_at p}\n\n/--\nThe `pos : m \u00d7 n` that is in `pf.occupied_positions`\nby definition is the proposition that `pf.occupied_at pos`.\n-/\n@[simp] lemma occupied_positions_in (pos : m \u00d7 n) :\n  pos \u2208 pf.occupied_positions \u2194 pf.occupied_at pos := iff.rfl\n\n/--\nThe predicate that `\u03bb p, p \u2208 pf.occupied_positions` for some pos is\ndecidable if the indices `ix : \u03b9` are finite and decidably equal.\n-/\ninstance occcupied_positions_mem_decidable [fintype \u03b9] [decidable_eq \u03b9] :\n  decidable_pred (\u2208 pf.occupied_positions) :=\noccupied_at.decidable_pred (\u03bb (pos : m \u00d7 n), pf pos)\n\nvariables [fintype m] [fintype n]\n\n/--\nWhen the `playfield` dimensions are all finite,\nthe `occupied_positions`\u2013all positions that are `occupied_at`\u2013is a `fintype`.\n-/\nlemma finite_occupied : pf.occupied_positions.finite :=\nset.finite.of_fintype pf.occupied_positions\n\nvariables [fintype \u03b9] [decidable_eq \u03b9]\n\n/--\nWhen the `playfield` dimensions are all finite,\nthe `occupied_positions_set` of all positions that are `occupied_at` is finite.\n-/\ninstance fintype_occupied : fintype (pf.occupied_positions) :=\nby { unfold occupied_positions, exact set_fintype _ }\n\n/--\nThe `finset` of all positions that are `occupied_at`,\nwhen all the dimensions of the `playfield` are `fintype`.\n-/\ndef occupied_position_finset : finset (m \u00d7 n) := pf.occupied_positions.to_finset\n\nend occupied\n\nsection injective\n\n/-- A `playfield` on which every index that appears, appears only once. -/\ndef some_injective : Prop :=\n\u2200 \u2983a\u2081\u2984, pf.occupied_at a\u2081 \u2192 \u2200 \u2983a\u2082\u2984, pf a\u2081 = pf a\u2082 \u2192 a\u2081 = a\u2082\n\n/-- The injectivity of `some_injective` is equivalent to the `set.inj_on` proposition. -/\nlemma inj_on_occupied : pf.some_injective \u2194 set.inj_on pf pf.occupied_positions :=\n\u27e8\u03bb h _ hp _ _ H, h hp H, \u03bb h _ hp _ H, h hp (occupied_at_transfer hp H) H\u27e9\n\n/--\nExplicitly state that the proposition that `pf.some_injective`\nis `decidable`, when the `\u03b9` is itself `decidable_eq`.\n-/\ninstance some_injective_decidable\n  [fintype m] [fintype n] [decidable_eq m] [decidable_eq n]\n  [fintype \u03b9] [decidable_eq \u03b9] :\n  decidable (pf.some_injective) := fintype.decidable_forall_fintype\n\nvariable (h_inj : pf.some_injective)\ninclude h_inj\n\n/--\nWhen a `pf : playfield m n \u03b9` is `some_injective`,\nif it is occupied at some `pos : m \u00d7 n`, then it\nis injective at that `pos`.\n-/\nprotected lemma inj_iff {pos pos'} (h : pf.occupied_at pos) :\npf pos = pf pos' \u2194 pos = pos' :=\n\u27e8\u03bb H, h_inj h H, congr_arg pf\u27e9\n\n/--\nWhen a `pf : playfield m n \u03b9` is `some_injective`,\nif it is not empty at some `pos : m \u00d7 n`, then it\nis injective at that `pos`.\n-/\nprotected lemma injective {pos pos'} {ix : \u03b9} (h : pf pos = some ix) (h' : pf pos' = some ix) :\n  pos = pos' :=\nbegin\n  apply h_inj,\n  { exact \u27e8_, h\u27e9 },\n  { rw [h, h'] }\nend\n\n/--\nWhen a `pf : playfield m n \u03b9` is `some_injective`, every index\n`ix : \u03b9 \u2208 pf` exists in the `pf` uniquely.\n-/\nlemma unique_of_injective {ix : \u03b9} (h : ix \u2208 pf) :\n  \u2203! pos, pf pos = some ix :=\nbegin\n  refine exists_unique_of_exists_of_unique h _,\n  intros _ _,\n  exact pf.injective h_inj\nend\n\nend injective\n\nsection decidable\n\nvariables [fintype m] [fintype n]\nvariables [fintype \u03b9] [decidable_eq \u03b9]\n\n/--\nThe `occupied_positions` of a `pf : playfield m n \u03b9` are finite\nif the dimensions of the playfield and the indices are finite.\n-/\ninstance occupied_fintype : fintype pf.occupied_positions := subtype.fintype pf.occupied_at\n\nend decidable\n\n/-- A `pos : pf.occupied_positions` can be used as a `pos : m \u00d7 n`. -/\nlemma coe_occ_val {pos : pf.occupied_positions} : (pos : m \u00d7 n) = pos.val := rfl\n\n/--\nA `pos : pf.occupied_positions` has the property\nthat there is an not-necessarily-unique `ix : \u03b9` such that `pf pos = some ix`.\n-/\nlemma exists_of_occupied (pos : pf.occupied_positions) : pf.occupied_at pos :=\npos.property\n\n/--\nA `pos : pf.occupied_positions` has the property\nthat there is a necessarily-unique `ix : \u03b9` such that `pf pos = some ix`.\n-/\nlemma exists_unique_of_occupied (pos : pf.occupied_positions) : \u2203! ix : \u03b9, pf pos = ix :=\noccupied_at_unique (pf.exists_of_occupied pos)\n\n/-- A `pos : pf.occupied_positions` has the property that `pf pos` is occupied. -/\nlemma occupied_is_some (pos : pf.occupied_positions) : (pf pos).is_some :=\noccupied_has_some.mpr pos.property\n\nvariables (pf)\n\n/--\nGiven some `ix : \u03b9` such that for `pf : playfield m n \u03b9` and `pos : m \u00d7 n`,\n`pf pos = some ix`, we can subtype into `pos : pf.occupied_positions`.\n-/\ndef occupied_positions.mk {pos : m \u00d7 n} {ix : \u03b9} (h : pf pos = some ix) : pf.occupied_positions :=\n\u27e8pos, exists.intro ix h\u27e9\n\n/--\nGiven some `ix : \u03b9` such that for `pf : playfield m n \u03b9` and `pos : m \u00d7 n`,\n`pf pos = some ix`, we can subtype into `pos : pf.occupied_positions`.\n-/\nlemma occupied_positions_def {pos : m \u00d7 n} {ix : \u03b9} {h : pf pos = some ix} :\n  pf (occupied_positions.mk pf h) = pf pos := rfl\n\n/-- The injectivity of `pf.some_injective` extends to the `pf.occupied_positions` subtype. -/\nlemma occupied_some_injective (h_inj : pf.some_injective) :\n  \u2200 \u2983a\u2081 a\u2082 : pf.occupied_positions\u2984, pf a\u2081 = pf a\u2082 \u2192 a\u2081 = a\u2082 :=\n\u03bb p p' h, subtype.eq (h_inj p.property h)\n\n/--\nWhen a `pf : playfield m n \u03b9` is `some_injective`, every `pos : pf.occupied_positions`\nmaps to a unique index via `pf pos`.\n-/\nlemma unique_of_occupied (h_inj : pf.some_injective) (pos : pf.occupied_positions) :\n  \u2203! (pos' : pf.occupied_positions), pf pos' = pf pos :=\nbegin\n  use pos,\n  split,\n  { simp only [eq_self_iff_true] },\n  { intros _ h,\n    exact pf.occupied_some_injective h_inj h }\nend\n\nsection index_at\n\nvariables (pos pos' : pf.occupied_positions)\n\nvariables (pf)\n\n/-- Extract the `ix : \u03b9` that is at `pf pos = some ix`. -/\ndef index_at := option.get (occupied_has_some.mpr pos.property)\n\nvariables {pf}\n\n/-- Extract the `ix : \u03b9` that is at `pf pos = some ix`. -/\nlemma index_at_def : pf.index_at pos = option.get (occupied_has_some.mpr pos.property) := rfl\n\n/--\nFor a `pos : pf.occupied_positions`, the wrapped index\ngiven by `pf.index_at pos` is precisely `pf pos`.\n-/\n@[simp] lemma index_at_some : some (pf.index_at pos) = pf pos :=\nby simp only [index_at_def, option.some_get, subtype.val_eq_coe]\n\n/--\nFor a `pos : pf.occupied_positions`, the wrapped index `ix : \u03b9`\ngiven by `pf.index_at pos` is precisely `pf pos`, in iff form.\n-/\n@[simp] lemma index_at_iff {ix : \u03b9} : pf pos = some ix \u2194 pf.index_at pos = ix :=\n\u27e8\u03bb h, option.some.inj (h \u25b8 index_at_some pos), \u03bb h, h \u25b8 (index_at_some pos).symm\u27e9\n\n/--\nFor a `pos : m \u00d7 n`, and the hypothesis that `h : pf pos = some ix`,\nthe index given by `pf.index_at (occupied_positions.mk _ h)` is precisely `ix`.\n-/\n@[simp] lemma index_at_mk {pos : m \u00d7 n} {ix : \u03b9} {h : pf pos = some ix} :\npf.index_at (occupied_positions.mk _ h) = ix :=\nbegin\n  apply option.some.inj,\n  rw \u2190h,\n  simp only [index_at_some, pf.occupied_positions_def],\nend\n\n/-- The index retrieved via `pf.index_at` is known to be in the `pf`. -/\nlemma index_at_in : pf.index_at pos \u2208 pf :=\n\u27e8pos, (index_at_some pos).symm\u27e9\n\n/-- The index retrieved via `pf.index_at` is known to be in the `pf`, in existential format. -/\nlemma index_at_exists : \u2203 pos', pf pos' = some (pf.index_at pos) :=\n\u27e8pos, (index_at_some pos).symm\u27e9\n\n/--\nThe index retrieved via `pf.index_at` is known to be in the `pf`,\nin existential format, operating on the `pf.occupied_positions` subtype.\n-/\nlemma index_at_exists' : \u2203 (pos' : pf.occupied_positions), pf pos' = some (pf.index_at pos) :=\n\u27e8pos, (index_at_some pos).symm\u27e9\n\n/--\nThe index retrieved via `pf.index_at` is known to be unique in the `pf`,\ngiven an injectivity condition via `pf.some_injective`.\n-/\nlemma occupied_unique_of_injective (h_inj : pf.some_injective) :\n  \u2203! (pos' : pf.occupied_positions), pf pos' = some (pf.index_at pos) :=\nbegin\n  refine exists_unique_of_exists_of_unique (index_at_exists' pos) _,\n  intros _ _ h h',\n  apply pf.occupied_some_injective h_inj,\n  rw [h, h']\nend\n\n/--\nIndex retrieval via `pf.index_at` is known to be injective,\ngiven an injectivity condition via `pf.some_injective`.\n-/\nlemma index_at_inj (h_inj : pf.some_injective) {pos pos' : pf.occupied_positions} :\n  pf.index_at pos = pf.index_at pos' \u2194 pos = pos' :=\nbegin\n  split,\n  { intro h,\n    rw \u2190option.some_inj at h,\n    simp only [index_at_some, coe_coe] at h,\n    exact pf.occupied_some_injective h_inj h },\n  { intro h,\n    rw h },\nend\n\n/--\nIndex retrieval via `pf.index_at` is known to be injective,\ngiven an injectivity condition via `pf.some_injective`.\n-/\nlemma index_at.injective (h_inj : pf.some_injective) : function.injective pf.index_at :=\n\u03bb p p' h, (index_at_inj h_inj).mp h\n\n/--\nIndex retrieval via `pf.index_at` is known to be surjective,\ngiven an surjectivity condition via `function.surjective pf`.\n-/\nlemma index_at.surjective (h : function.surjective pf) :\n  function.surjective pf.index_at :=\nbegin\n  intro ix,\n  obtain \u27e8pos, hpos\u27e9 := h ix,\n  use pos,\n  { exact occupied_at_of_some hpos },\n  { apply option.some.inj,\n    simpa only [index_at_some] },\nend\n\n/--\nIndex retrieval via `pf` is known to be surjective,\ngiven an surjectivity condition via `function.surjective pf.index_at`\nand an unoccupied square somewhere.\n-/\nlemma index_at.implies_surjective (h : function.surjective pf.index_at)\n  {unocc_pos : m \u00d7 n} (h_unocc : \u00ac pf.occupied_at unocc_pos) :\n  function.surjective pf :=\nbegin\n  intro ix,\n  cases ix,\n  { use unocc_pos,\n    rwa [\u2190occupied_has_not_none, not_not] at h_unocc },\n  { obtain \u27e8pos, hpos\u27e9 := h ix,\n    use pos,\n    simp only [\u2190hpos, index_at_some] },\nend\n\nend index_at\n\nsection pos_from\n\nvariables (pf)\nvariables (ix : \u03b9)\n\n/--\nA helper subtype definition describing all the positions that match an index.\n\nNo inhabited instance exists because the type could be empty,\nif none of the positions of the playfield have this index.\n-/\n@[nolint has_inhabited_instance]\ndef pos_from_aux : Type* := {pos // pf.index_at pos = ix}\n\ninstance : has_coe (pf.pos_from_aux ix) pf.occupied_positions := \u27e8subtype.val\u27e9\n\n/-- A helper subtype definition describing all the positions that match an index. -/\n@[simp] lemma pos_from_aux_subtype (pos : pf.pos_from_aux ix) :\n  pf.index_at (pos : pf.occupied_positions) = ix := pos.property\n\n/-- A helper set definition describing all the positions that match an index. -/\nlemma pos_from_auxf_set (pos : pf.pos_from_aux ix) :\n  (pos : pf.occupied_positions) \u2208 {pos | pf.index_at pos = ix} := pos.property\n\n/--\nGiven an injectivity condition of `pf.some_injective`, the type\nof `pos : pf.occupied_positions` that identify a particular index is a subsingleton.\n-/\nlemma subsingleton_pos (h_inj : pf.some_injective) : subsingleton (pf.pos_from_aux ix) :=\nbegin\n  refine subsingleton.intro _,\n  intros pos pos',\n  apply subtype.eq,\n  rw \u2190index_at_inj h_inj,\n  simp only [pos_from_aux_subtype, subtype.val_eq_coe]\nend\n\n/--\nGiven a surjectivity condition of `pf.index_at`, the type\nof `pos : pf.occupied_positions` that identify a particular index is a nonempty.\n-/\nlemma nonempty_pos (surj : function.surjective pf.index_at) : nonempty (pf.pos_from_aux ix) :=\nnonempty_subtype.mpr (surj ix)\n\nvariables [fintype m] [fintype n]\nvariables [fintype \u03b9] [decidable_eq \u03b9]\n\n/-- A helper finset definition describing all the positions that match an index. -/\ndef pos_from_auxf : finset pf.occupied_positions := {pos | pf.index_at pos = ix}.to_finset\n\n/-- A helper finset definition describing all the positions that match an index. -/\nlemma pos_from_auxf_finset (pos : pf.pos_from_aux ix) :\n  (pos : pf.occupied_positions) \u2208 pf.pos_from_auxf ix :=\nbegin\n  unfold pos_from_auxf,\n  simp only [set.mem_to_finset],\n  exact pos.property,\nend\n\n/-- A helper finset definition describing all the positions that match an index. -/\n@[simp] lemma pos_from_auxf_in {pos : pf.occupied_positions} (h : pf.index_at pos = ix) :\n  pos \u2208 pf.pos_from_auxf ix :=\nbegin\n  unfold pos_from_auxf,\n  simp only [set.mem_to_finset],\n  exact h,\nend\n\nvariables (h_inj : pf.some_injective) (surj : function.surjective pf.index_at)\ninclude h_inj surj\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`, the type\nof `pos : pf.occupied_positions` that identify a particular index is a unique.\n-/\nlemma unique_pos :\n  \u2203! (pos : pf.occupied_positions), pos \u2208 pf.pos_from_auxf ix \u2227 pf.index_at pos = ix :=\nbegin\n  obtain \u27e8pos, hpos\u27e9 := surj ix,\n  use pos,\n  split,\n  { simp only [hpos, and_true, eq_self_iff_true, pos_from_auxf_in] },\n  { intros pos' h',\n    rw \u2190index_at_inj h_inj,\n    simp only [hpos, h'] }\nend\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nwe can retrieve the `pos : pf.occupied_positions`\nsuch that `pf.index_at pos = ix`.\n-/\ndef pos_from' (ix : \u03b9) : pf.occupied_positions :=\nfinset.choose (\u03bb pos, pf.index_at pos = ix) (pf.pos_from_auxf ix) (pf.unique_pos ix h_inj surj)\n\nvariable {pf}\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nwe can retrieve the `pos : pf.occupied_positions`\nsuch that `pf.index_at pos = ix`.\n-/\nlemma pos_from_def' : pf.pos_from' h_inj surj ix =\n  finset.choose (\u03bb pos, pf.index_at pos = ix) (pf.pos_from_auxf ix) (pf.unique_pos ix h_inj surj) :=\nrfl\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nround-tripping to get the `pf.index_at (pf.pos_from' ix _ _)` is exactly `ix`.\n-/\n@[simp] lemma pos_from_index_at' : pf.index_at (pf.pos_from' h_inj surj ix) = ix :=\nby { rw [pos_from_def'], exact finset.choose_property (\u03bb pos, pf.index_at pos = ix) _ _ }\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nround-tripping to get the `pf (pf.pos_from' ix _ _)` is exactly `some ix`,\nwhich goes through the coercion down to `pos : m \u00d7 n`.\n-/\nlemma pos_from_at' : pf (pf.pos_from' h_inj surj ix) = some ix :=\nby simp only [index_at_iff, pos_from_index_at']\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nthe left inverse of `pf.index_at` is `pf.pos_from'`.\n-/\nlemma pos_from_inv_index_at' : function.left_inverse pf.index_at (pf.pos_from' h_inj surj) :=\n\u03bb ix, pos_from_index_at' ix h_inj surj\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nthe right inverse of `pf.index_at` is `pf.pos_from'`.\n-/\nlemma index_at_inv_pos_from' : function.right_inverse pf.index_at (pf.pos_from' h_inj surj) :=\nfunction.right_inverse_of_injective_of_left_inverse\n  (index_at.injective h_inj)\n  (pos_from_inv_index_at' h_inj surj)\n\nvariable (pf)\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`, the type\nthere exists a `pos : m \u00d7 n' such that `pf pos = some ix`.\n-/\ndef pos_from (ix : \u03b9) : m \u00d7 n := pf.pos_from' h_inj surj ix\n\nvariable {pf}\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`, the type\nthere exists a `pos : m \u00d7 n' such that `pf pos = some ix`.\n-/\nlemma pos_from_def : pf.pos_from h_inj surj ix = pf.pos_from' h_inj surj ix := rfl\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nround-tripping to get the `pf (pf.pos_from ix _ _)` is exactly `some ix`,\n-/\nlemma pos_from_at : pf (pf.pos_from h_inj surj ix) = some ix :=\nby simp only [pos_from_def, index_at_iff, pos_from_index_at']\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nthe position retrieved via `pf.pos_from` means that\nthe `pf` is `occupied_at` it.\n-/\nlemma pos_from_occupied : pf.occupied_at (pf.pos_from h_inj surj ix) :=\n\u27e8ix, pos_from_at _ _ _\u27e9\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nthe partial inverse of `pf.pos_from` is `pf` itself.\n-/\nlemma pos_from_inv : function.is_partial_inv (pf.pos_from h_inj surj) pf :=\nbegin\n  intros ix pos,\n  split,\n  { intro h,\n    apply h_inj,\n    { exact pos_from_occupied _ _ _ },\n    { rw h,\n      exact pos_from_at ix _ _ } },\n  { intro h,\n    rw \u2190h,\n    exact pos_from_at ix _ _ }\nend\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nthe function `pf.pos_from` is injective.\n-/\nlemma pos_from.injective : function.injective (pf.pos_from h_inj surj) :=\nfunction.injective_of_partial_inv (pos_from_inv h_inj surj)\n\nend pos_from\n\nsection equiv\n\nvariables [fintype m] [fintype n]\nvariables [fintype \u03b9] [decidable_eq \u03b9]\nvariables (h_inj : pf.some_injective) (surj : function.surjective pf.index_at)\ninclude h_inj surj\n\n/--\nGiven a surjectivity condition of `pf.index_at`,\nand an injectivity condition of `pf.some_injective`,\nthere is an explicit equivalence from the indices `\u03b9` to\nthe type of positions in `pf.occupied_positions`.\n-/\ndef index_equiv : \u03b9 \u2243 pf.occupied_positions :=\n{ to_fun := pf.pos_from' h_inj surj,\n  inv_fun := pf.index_at,\n  left_inv := pos_from_inv_index_at' h_inj surj,\n  right_inv := index_at_inv_pos_from' h_inj surj}\n\nend equiv\n\n-- To be able to state whether two positions are equal\n-- we need to be able to make the equality on each of the dimensions `decidable`\nvariables [decidable_eq m] [decidable_eq n]\n\nsection move_piece\n\n-- Fix `start_square` and `end_square : m \u00d7 n` to use in definitions and lemmas below\nvariables (start_square end_square : m \u00d7 n)\n\n/--\nMove an (optional) index from `start_square` to `end_square` on a `playfield`,\nswapping the indices at those squares.\n\nDoes not assume anything about occupancy.\n-/\ndef move_piece : playfield m n \u03b9 :=\n\u03bb pos, pf (equiv.swap start_square end_square pos)\n\n/--\nEquivalent to to `move_piece`, but useful for `rewrite`\\ ing.\n-/\nlemma move_piece_def : pf.move_piece start_square end_square =\n    \u03bb pos, pf (equiv.swap start_square end_square pos) := rfl\n\n/--\nMoving an (optional) index that was at `start_square` places it at `end_square`\n-/\n@[simp] lemma move_piece_start :\npf.move_piece start_square end_square start_square = pf end_square :=\nby simp only [move_piece_def, equiv.swap_apply_left]\n\n/--\nMoving an (optional) index that was at `end_square` places it at `start_square`\n-/\n@[simp] lemma move_piece_end :\npf.move_piece start_square end_square end_square = pf start_square :=\nby simp only [move_piece_def, equiv.swap_apply_right]\n\n/--\nMoving an (optional) index retains whatever (optional) indices that were at other squares.\n-/\n@[simp] lemma move_piece_diff\n  {start_square end_square other_square : m \u00d7 n}\n  (ne_start : other_square \u2260 start_square)\n  (ne_end : other_square \u2260 end_square) :\npf.move_piece start_square end_square other_square = pf other_square :=\nby simp only [move_piece_def, equiv.swap_apply_of_ne_of_ne ne_start ne_end]\n\n/--\nThe `pf : playfield m n \u03b9` is `occupied_at start_square` after a `move_piece`\niff it is `occupied_at end_square` before the piece move.\n-/\n@[simp] lemma move_piece_occupied_start :\n(pf.move_piece start_square end_square).occupied_at start_square \u2194 pf.occupied_at end_square :=\nby simp only [occupied_at, move_piece_start]\n\n/--\nThe `pf : playfield m n \u03b9` is `occupied_at end_square` after a `move_piece`\niff it is `occupied_at start_square` before the piece move.\n-/\n@[simp] lemma move_piece_occupied_end :\n(pf.move_piece start_square end_square).occupied_at end_square \u2194 pf.occupied_at start_square :=\nby simp only [occupied_at, move_piece_end]\n\n/--\nThe `pf : playfield m n \u03b9` is `occupied_at other_square` after a `move_piece`,\nfor a `pos` that is neither `start_square` nor `end_square`,\niff it is `occupied_at other_square` before the piece move.\n-/\n@[simp] lemma move_piece_occupied_diff\n  {start_square end_square other_square : m \u00d7 n}\n  (ne_start : other_square \u2260 start_square)\n  (ne_end : other_square \u2260 end_square) :\n(pf.move_piece start_square end_square).occupied_at other_square \u2194 pf.occupied_at other_square :=\nby simp only [occupied_at, pf.move_piece_diff ne_start ne_end]\n\n/-- Pieces do not disappear after a `move_piece`. -/\nlemma retains_pieces (pf : playfield m n \u03b9) (start_square end_square : m \u00d7 n) (ix : \u03b9)\n  (h_pf : ix \u2208 pf) :\n    ix \u2208 pf.move_piece start_square end_square :=\nbegin\n  obtain \u27e8pos, h\u27e9 := h_pf,\n  by_cases hs : pos = start_square;\n  by_cases he : pos = end_square,\n  { use pos,\n    simp [\u2190hs, \u2190h, he] },\n  { use end_square,\n    simp [hs, he, \u2190h] },\n  { use start_square,\n    simp [hs, he, \u2190h] },\n  { use pos,\n    simp [hs, he, \u2190h] }\nend\n\n/--\nEach index that is present on the playfield and appears only once,\nappears only once after a `move_piece`.\n-/\nlemma retains_injectivity (pf : playfield m n \u03b9) (h : pf.some_injective)\n  {start_square end_square : m \u00d7 n} (h_occ : pf.occupied_at start_square) :\n  (pf.move_piece start_square end_square).some_injective :=\nbegin\n  intros pos h_some pos' h_eq,\n  rcases split_eq pos start_square end_square with rfl|rfl|\u27e8hS, hE\u27e9;\n  rcases split_eq pos' start_square end_square with rfl|rfl|\u27e8hS', hE'\u27e9,\n  { refl },\n  { simp only [move_piece_start, move_piece_end] at h_eq,\n    exact h h_occ h_eq.symm },\n  { simp only [move_piece_diff, hS', hE', move_piece_start,\n               move_piece_occupied_start, ne.def, not_false_iff] at h_eq h_some,\n    have : pos' = end_square := (h h_some h_eq).symm,\n    contradiction },\n  { simp only [move_piece_start, move_piece_end] at h_eq,\n    exact (h h_occ h_eq).symm },\n  { refl },\n  { simp only [move_piece_diff _ hS' hE', move_piece_end,\n               move_piece_occupied_end] at h_eq h_some,\n    have : pos' = start_square := (h h_some h_eq).symm,\n    contradiction },\n  { simp only [move_piece_diff, hS, hE, move_piece_start,\n               move_piece_occupied_diff, ne.def, not_false_iff] at h_eq h_some,\n    have : pos = end_square := h h_some h_eq,\n    contradiction },\n  { simp only [move_piece_diff, hS, hE, move_piece_end,\n               move_piece_occupied_diff, ne.def, not_false_iff] at h_eq h_some,\n    have : pos = start_square := h h_some h_eq,\n    contradiction },\n  { simp only [move_piece_diff, hS, hE, hS', hE',\n               move_piece_occupied_diff, ne.def, not_false_iff] at h_eq h_some,\n    exact h h_some h_eq }\nend\n\n/--\nIf every index and the empty square is present in the `pf : playfield m n \u03b9`,\nas given by a `function.surjective pf` proposition, then each index\nis present on the playfield after a `move_piece`.\n-/\nlemma retains_surjectivity (pf : playfield m n \u03b9) (h : function.surjective pf)\n  {start_square end_square : m \u00d7 n} (h_occ : pf.occupied_at start_square) :\n  function.surjective (pf.move_piece start_square end_square) :=\nbegin\n  intro ix,\n  obtain \u27e8six', hsi\u27e9 := h_occ,\n  obtain \u27e8P, hP\u27e9 := h ix,\n  rw \u2190hP,\n  rcases split_eq (P : m \u00d7 n) start_square end_square with H|H|\u27e8hS, hE\u27e9,\n  { use end_square,\n    simp only [move_piece_end, H] },\n  { use start_square,\n    simp only [H, move_piece_start] },\n  { use P,\n    simp only [hS, hE, ne.def, not_false_iff, move_piece_diff] }\nend\n\n/--\nIf every index and the empty square is present in the `pf : playfield m n \u03b9`,\nas given by a `function.surjective pf` proposition, then each index\nis present on the playfield after a `move_piece`.\n-/\nlemma index_at_retains_surjectivity (pf : playfield m n \u03b9) (h : function.surjective pf.index_at)\n  {start_square end_square : m \u00d7 n} (h_occ : pf.occupied_at start_square)  :\n  function.surjective (pf.move_piece start_square end_square).index_at :=\nbegin\n  intro ix,\n  obtain \u27e8P, hP\u27e9 := h ix,\n  simp_rw [\u2190index_at_iff, \u2190hP],\n  rcases split_eq (P : m \u00d7 n) start_square end_square with H|H|\u27e8hS, hE\u27e9,\n  { use end_square,\n    { simpa only [move_piece_occupied_end, occupied_positions_in] using h_occ },\n    { simp only [H, index_at_some, subtype.coe_mk, move_piece_end] } },\n  { use start_square,\n    { simpa only [H, move_piece_occupied_start, occupied_positions_in] using P.property },\n    { simp only [H, move_piece_start, index_at_some, subtype.coe_mk] } },\n  { use P,\n    { simpa only [hS, hE, ne.def, not_false_iff,\n                  move_piece_occupied_diff, occupied_positions_in] using P.property},\n    { simp only [hS, hE, index_at_some, ne.def, not_false_iff,\n                 move_piece_diff, subtype.coe_mk] } }\nend\n\nend move_piece\n\nsection move_sequence\n\n-- The length of the sequence\nvariables {o : \u2115}\n-- Fix a sequence of start and end squares.\nvariables (seq : vector ((m \u00d7 n) \u00d7 (m \u00d7 n)) o)\n\n/-- Make a sequence of `move`s all at once. -/\ndef move_sequence : fin (o + 1) \u2192 playfield m n \u03b9 :=\n(vector.scanl (\u03bb acc (x : prod _ _), move_piece acc x.fst x.snd) pf seq).nth\n\n/--\nEquivalent to to `move_sequence`, but useful for `rewrite`\\ ing.\n-/\nlemma move_sequence_def : pf.move_sequence seq =\n  (vector.scanl (\u03bb acc (x : prod _ _), move_piece acc x.fst x.snd) pf seq).nth := rfl\n\n/--\nThroughout a sequence, moving an (optional) index that was at\n`start_square` places it at `end_square` on the next board.\n-/\nlemma move_sequence_start (e : fin o) :\n((pf.move_sequence seq) e.cast_succ) (seq.nth e).fst = ((pf.move_sequence seq) e.succ) (seq.nth e).snd :=\nby simp only [move_sequence_def, vector.scanl_nth, move_piece_end]\n\n/--\nThroughout a sequence, moving an (optional) index that was at\n`end_square` places it at `start_square` on the next board.\n-/\nlemma move_sequence_end (e : fin o) :\n((pf.move_sequence seq) e.cast_succ) (seq.nth e).snd = ((pf.move_sequence seq) e.succ) (seq.nth e).fst :=\nby simp only [move_sequence_def, vector.scanl_nth, move_piece_start]\n\n/--\nThroughout a sequence, moving an (optional) index retains whatever\n(optional) indices that were at other squares on the next board.\n-/\n@[simp] lemma move_sequence_diff\n  (other_square : m \u00d7 n)\n  (e : fin o)\n  (ne_start : other_square \u2260 (seq.nth e).fst)\n  (ne_end : other_square \u2260 (seq.nth e).snd) :\n  ((pf.move_sequence seq) e.cast_succ) other_square = ((pf.move_sequence seq) e.succ) other_square :=\nby simp only [move_sequence_def, vector.scanl_nth, ne_start, ne_end,\n              ne.def, not_false_iff, move_piece_diff]\n\nend move_sequence\n\nend playfield\n\nend playfield\n", "meta": {"author": "Julian", "repo": "lean-across-the-board", "sha": "f14ec4cde25a3549d522a5fd6703330427fd0c89", "save_path": "github-repos/lean/Julian-lean-across-the-board", "path": "github-repos/lean/Julian-lean-across-the-board/lean-across-the-board-f14ec4cde25a3549d522a5fd6703330427fd0c89/src/chess/playfield.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702642896702, "lm_q2_score": 0.66192288918838, "lm_q1q2_score": 0.4798082196253631}}
{"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 `\u03b1` and `\u03b2` have\n\u03c3-finite measures `\u03bc` resp. `\u03bd` then `\u03b1 \u00d7 \u03b2` can be equipped with a \u03c3-finite measure `\u03bc.prod \u03bd` that\nsatisfies `(\u03bc.prod \u03bd) s = \u222b\u207b x, \u03bd {y | (x, y) \u2208 s} \u2202\u03bc`.\nWe also have `(\u03bc.prod \u03bd) (s \u00d7\u02e2 t) = \u03bc s * \u03bd 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 `\u03bc.prod \u03bd s = \u222b\u207b x, \u03bd {y | (x, y) \u2208 s} \u2202\u03bc`\n  for measurable `s`. `measure_theory.measure.prod_apply_symm` is the reversed version.\n* `measure_theory.measure.prod_prod` states `\u03bc.prod \u03bd (s \u00d7\u02e2 t) = \u03bc s * \u03bd t` for measurable sets\n  `s` and `t`.\n* `measure_theory.lintegral_prod`: Tonelli's theorem. It states that for a measurable function\n  `\u03b1 \u00d7 \u03b2 \u2192 \u211d\u22650\u221e` we have `\u222b\u207b z, f z \u2202(\u03bc.prod \u03bd) = \u222b\u207b x, \u222b\u207b y, f (x, y) \u2202\u03bd \u2202\u03bc`. The version\n  for functions `\u03b1 \u2192 \u03b2 \u2192 \u211d\u22650\u221e` 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 \u21a6 f (x, y)` is integrable for almost every `x`, and\n  * the function `x \u21a6 \u222b \u2225f (x, y)\u2225 dy` is integrable.\n* `measure_theory.integral_prod`: Fubini's theorem. It states that for a integrable function\n  `\u03b1 \u00d7 \u03b2 \u2192 E` (where `E` is a second countable Banach space) we have\n  `\u222b z, f z \u2202(\u03bc.prod \u03bd) = \u222b x, \u222b y, f (x, y) \u2202\u03bd \u2202\u03bc`. 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 (`\u03b1 \u2192 \u03b2 \u2192 \u03b3`) and one for\nfunctions in uncurried form (`\u03b1 \u00d7 \u03b2 \u2192 \u03b3`). 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 {\u03b1 \u03b1' \u03b2 \u03b2' \u03b3 E : Type*}\n\n/-- Rectangles formed by \u03c0-systems form a \u03c0-system. -/\nlemma is_pi_system.prod {C : set (set \u03b1)} {D : set (set \u03b2)} (hC : is_pi_system C)\n  (hD : is_pi_system D) : is_pi_system (image2 (\u00d7\u02e2) C D) :=\nbegin\n  rintro _ \u27e8s\u2081, t\u2081, hs\u2081, ht\u2081, rfl\u27e9 _ \u27e8s\u2082, t\u2082, hs\u2082, ht\u2082, rfl\u27e9 hst,\n  rw [prod_inter_prod] at hst \u22a2, rw [prod_nonempty_iff] at hst,\n  exact mem_image2_of_mem (hC _ hs\u2081 _ hs\u2082 hst.1) (hD _ ht\u2081 _ ht\u2082 hst.2)\nend\n\n/-- Rectangles of countably spanning sets are countably spanning. -/\nlemma is_countably_spanning.prod {C : set (set \u03b1)} {D : set (set \u03b2)}\n  (hC : is_countably_spanning C) (hD : is_countably_spanning D) :\n  is_countably_spanning (image2 (\u00d7\u02e2) C D) :=\nbegin\n  rcases \u27e8hC, hD\u27e9 with \u27e8\u27e8s, h1s, h2s\u27e9, t, h1t, h2t\u27e9,\n  refine \u27e8\u03bb n, (s n.unpair.1) \u00d7\u02e2 (t n.unpair.2), \u03bb n, mem_image2_of_mem (h1s _) (h1t _), _\u27e9,\n  rw [Union_unpair_prod, h2s, h2t, univ_prod_univ]\nend\n\nvariables [measurable_space \u03b1] [measurable_space \u03b1'] [measurable_space \u03b2] [measurable_space \u03b2']\nvariables [measurable_space \u03b3]\nvariables {\u03bc : measure \u03b1} {\u03bd : measure \u03b2} {\u03c4 : measure \u03b3}\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 \u03c3-algebras is the one generated by rectangles, if both generating sets\n  are countably spanning. -/\nlemma generate_from_prod_eq {\u03b1 \u03b2} {C : set (set \u03b1)} {D : set (set \u03b2)}\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 (\u00d7\u02e2) C D) :=\nbegin\n  apply le_antisymm,\n  { refine sup_le _ _; rw [comap_generate_from];\n      apply generate_from_le; rintro _ \u27e8s, hs, rfl\u27e9,\n    { rcases hD with \u27e8t, h1t, h2t\u27e9,\n      rw [\u2190 prod_univ, \u2190 h2t, prod_Union],\n      apply measurable_set.Union,\n      intro n, apply measurable_set_generate_from,\n      exact \u27e8s, t n, hs, h1t n, rfl\u27e9 },\n    { rcases hC with \u27e8t, h1t, h2t\u27e9,\n      rw [\u2190 univ_prod, \u2190 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 _ \u27e8s, t, hs, ht, rfl\u27e9, 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 \u03c3-algebras on `\u03b1` resp. `\u03b2`, then rectangles formed by `C` and `D`\n  generate the \u03c3-algebra on `\u03b1 \u00d7 \u03b2`. -/\nlemma generate_from_eq_prod {C : set (set \u03b1)} {D : set (set \u03b2)} (hC : generate_from C = \u2039_\u203a)\n  (hD : generate_from D = \u2039_\u203a) (h2C : is_countably_spanning C) (h2D : is_countably_spanning D) :\n    generate_from (image2 (\u00d7\u02e2) C D) = prod.measurable_space :=\nby rw [\u2190 hC, \u2190 hD, generate_from_prod_eq h2C h2D]\n\n/-- The product \u03c3-algebra is generated from boxes, i.e. `s \u00d7\u02e2 t` for sets `s : set \u03b1` and\n  `t : set \u03b2`. -/\nlemma generate_from_prod :\n  generate_from (image2 (\u00d7\u02e2) {s : set \u03b1 | measurable_set s} {t : set \u03b2 | 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 \u03c0-system. -/\nlemma is_pi_system_prod :\n  is_pi_system (image2 (\u00d7\u02e2) {s : set \u03b1 | measurable_set s} {t : set \u03b2 | measurable_set t}) :=\nis_pi_system_measurable_set.prod is_pi_system_measurable_set\n\n/-- If `\u03bd` is a finite measure, and `s \u2286 \u03b1 \u00d7 \u03b2` is measurable, then `x \u21a6 \u03bd { y | (x, y) \u2208 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 \u03bd] {s : set (\u03b1 \u00d7 \u03b2)}\n  (hs : measurable_set s) : measurable (\u03bb x, \u03bd (prod.mk x \u207b\u00b9' s)) :=\nbegin\n  refine induction_on_inter generate_from_prod.symm is_pi_system_prod _ _ _ _ hs,\n  { simp [measurable_zero, const_def] },\n  { rintro _ \u27e8s, t, hs, ht, rfl\u27e9, 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 \u03bd _)],\n    exact h2t.const_sub _ },\n  { intros f h1f h2f h3f, simp_rw [preimage_Union],\n    have : \u2200 b, \u03bd (\u22c3 i, prod.mk b \u207b\u00b9' f i) = \u2211' i, \u03bd (prod.mk b \u207b\u00b9' f i) :=\n      \u03bb b, measure_Union (\u03bb i j hij, disjoint.preimage _ (h1f i j hij))\n        (\u03bb i, measurable_prod_mk_left (h2f i)),\n    simp_rw [this], apply measurable.ennreal_tsum h3f },\nend\n\n/-- If `\u03bd` is a \u03c3-finite measure, and `s \u2286 \u03b1 \u00d7 \u03b2` is measurable, then `x \u21a6 \u03bd { y | (x, y) \u2208 s }` is\n  a measurable function. -/\nlemma measurable_measure_prod_mk_left [sigma_finite \u03bd] {s : set (\u03b1 \u00d7 \u03b2)}\n  (hs : measurable_set s) : measurable (\u03bb x, \u03bd (prod.mk x \u207b\u00b9' s)) :=\nbegin\n  have : \u2200 x, measurable_set (prod.mk x \u207b\u00b9' s) := \u03bb x, measurable_prod_mk_left hs,\n  simp only [\u2190 @supr_restrict_spanning_sets _ _ \u03bd, this],\n  apply measurable_supr, intro i,\n  haveI := fact.mk (measure_spanning_sets_lt_top \u03bd i),\n  exact measurable_measure_prod_mk_left_finite hs\nend\n\n/-- If `\u03bc` is a \u03c3-finite measure, and `s \u2286 \u03b1 \u00d7 \u03b2` is measurable, then `y \u21a6 \u03bc { x | (x, y) \u2208 s }` is\n  a measurable function. -/\nlemma measurable_measure_prod_mk_right {\u03bc : measure \u03b1} [sigma_finite \u03bc] {s : set (\u03b1 \u00d7 \u03b2)}\n  (hs : measurable_set s) : measurable (\u03bb y, \u03bc ((\u03bb x, (x, y)) \u207b\u00b9' s)) :=\nmeasurable_measure_prod_mk_left (measurable_set_swap_iff.mpr hs)\n\nlemma measurable.map_prod_mk_left [sigma_finite \u03bd] : measurable (\u03bb x : \u03b1, map (prod.mk x) \u03bd) :=\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 {\u03bc : measure \u03b1} [sigma_finite \u03bc] :\n  measurable (\u03bb y : \u03b2, map (\u03bb x : \u03b1, (x, y)) \u03bc) :=\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 \u03bd] :\n  \u2200 {f : \u03b1 \u00d7 \u03b2 \u2192 \u211d\u22650\u221e} (hf : measurable f), measurable (\u03bb x, \u222b\u207b y, f (x, y) \u2202\u03bd) :=\nbegin\n  have m := @measurable_prod_mk_left,\n  refine measurable.ennreal_induction _ _ _,\n  { intros c s hs, simp only [\u2190 indicator_comp_right],\n    suffices : measurable (\u03bb x, c * \u03bd (prod.mk x \u207b\u00b9' 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 : \u2200 x, monotone (\u03bb n y, f n (x, y)) := \u03bb x i j hij y, h2f hij (x, y),\n    simpa [lintegral_supr (\u03bb 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 \u03bd] {f : \u03b1 \u2192 \u03b2 \u2192 \u211d\u22650\u221e}\n  (hf : measurable (uncurry f)) : measurable (\u03bb x, \u222b\u207b y, f x y \u2202\u03bd) :=\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 \u03bc] {f : \u03b1 \u00d7 \u03b2 \u2192 \u211d\u22650\u221e}\n  (hf : measurable f) : measurable (\u03bb y, \u222b\u207b x, f (x, y) \u2202\u03bc) :=\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 \u03bc] {f : \u03b1 \u2192 \u03b2 \u2192 \u211d\u22650\u221e}\n  (hf : measurable (uncurry f)) : measurable (\u03bb y, \u222b\u207b x, f x y \u2202\u03bc) :=\nhf.lintegral_prod_left'\n\nlemma measurable_set_integrable [sigma_finite \u03bd] [opens_measurable_space E] \u2983f : \u03b1 \u2192 \u03b2 \u2192 E\u2984\n  (hf : measurable (uncurry f)) : measurable_set { x | integrable (f x) \u03bd } :=\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 \u211d 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 \u03bd] \u2983f : \u03b1 \u2192 \u03b2 \u2192 E\u2984\n  (hf : measurable (uncurry f)) : measurable (\u03bb x, \u222b y, f x y \u2202\u03bd) :=\nbegin\n  let s : \u2115 \u2192 simple_func (\u03b1 \u00d7 \u03b2) E := simple_func.approx_on _ hf univ _ (mem_univ 0),\n  let s' : \u2115 \u2192 \u03b1 \u2192 simple_func \u03b2 E := \u03bb n x, (s n).comp (prod.mk x) measurable_prod_mk_left,\n  let f' : \u2115 \u2192 \u03b1 \u2192 E := \u03bb n, {x | integrable (f x) \u03bd}.indicator\n    (\u03bb x, (s' n x).integral \u03bd),\n  have hf' : \u2200 n, measurable (f' n),\n  { intro n, refine measurable.indicator _ (measurable_set_integrable hf),\n    have : \u2200 x, (s' n x).range.filter (\u03bb x, x \u2260 0) \u2286 (s n).range,\n    { intros x, refine finset.subset.trans (finset.filter_subset _ _) _, intro y,\n      simp_rw [simple_func.mem_range], rintro \u27e8z, rfl\u27e9, exact \u27e8(x, z), rfl\u27e9 },\n    simp only [simple_func.integral_eq_sum_of_subset (this _)],\n    refine finset.measurable_sum _ (\u03bb 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 (\ud835\udcdd (\u03bb (x : \u03b1), \u222b (y : \u03b2), f x y \u2202\u03bd)),\n  { rw [tendsto_pi_nhds], intro x,\n    by_cases hfx : integrable (f x) \u03bd,\n    { have : \u2200 n, integrable (s' n x) \u03bd,\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 (\u03bb y, \u2225f x y\u2225 + \u2225f x y\u2225)\n        (\u03bb n, (s' n x).ae_measurable) (hfx.norm.add hfx.norm) _ _,\n      { exact \u03bb n, eventually_of_forall (\u03bb y, simple_func.norm_approx_on_zero_le _ _ (x, y) n) },\n      { exact eventually_of_forall (\u03bb 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 \u03bd] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : measurable f) : measurable (\u03bb x, \u222b y, f (x, y) \u2202\u03bd) :=\nby { rw [\u2190 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 \u03bc] \u2983f : \u03b1 \u2192 \u03b2 \u2192 E\u2984\n  (hf : measurable (uncurry f)) : measurable (\u03bb y, \u222b x, f x y \u2202\u03bc) :=\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 \u03bc] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : measurable f) : measurable (\u03bb y, \u222b x, f (x, y) \u2202\u03bc) :=\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 \u03c3-finite. -/\n@[irreducible] protected def prod (\u03bc : measure \u03b1) (\u03bd : measure \u03b2) : measure (\u03b1 \u00d7 \u03b2) :=\nbind \u03bc $ \u03bb x : \u03b1, map (prod.mk x) \u03bd\n\ninstance prod.measure_space {\u03b1 \u03b2} [measure_space \u03b1] [measure_space \u03b2] : measure_space (\u03b1 \u00d7 \u03b2) :=\n{ volume := volume.prod volume }\n\nvariables {\u03bc \u03bd} [sigma_finite \u03bd]\n\nlemma volume_eq_prod (\u03b1 \u03b2) [measure_space \u03b1] [measure_space \u03b2] :\n  (volume : measure (\u03b1 \u00d7 \u03b2)) = (volume : measure \u03b1).prod (volume : measure \u03b2) :=\nrfl\n\nlemma prod_apply {s : set (\u03b1 \u00d7 \u03b2)} (hs : measurable_set s) :\n  \u03bc.prod \u03bd s = \u222b\u207b x, \u03bd (prod.mk x \u207b\u00b9' s) \u2202\u03bc :=\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 \u03b1) (t : set \u03b2) : \u03bc.prod \u03bd (s \u00d7\u02e2 t) = \u03bc s * \u03bd t :=\nbegin\n  apply le_antisymm,\n  { set ST := (to_measurable \u03bc s) \u00d7\u02e2 (to_measurable \u03bd t),\n    have hSTm : measurable_set ST :=\n      (measurable_set_to_measurable _ _).prod (measurable_set_to_measurable _ _),\n    calc \u03bc.prod \u03bd (s \u00d7\u02e2 t) \u2264 \u03bc.prod \u03bd ST :\n      measure_mono $ set.prod_mono (subset_to_measurable _ _) (subset_to_measurable _ _)\n    ... = \u03bc (to_measurable \u03bc s) * \u03bd (to_measurable \u03bd 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    ... = \u03bc s * \u03bd 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 (\u03bc.prod \u03bd) (s \u00d7\u02e2 t),\n    have hSTm : measurable_set ST := measurable_set_to_measurable _ _,\n    have hST : s \u00d7\u02e2 t \u2286 ST := subset_to_measurable _ _,\n    set f : \u03b1 \u2192 \u211d\u22650\u221e := \u03bb x, \u03bd (prod.mk x \u207b\u00b9' ST),\n    have hfm : measurable f := measurable_measure_prod_mk_left hSTm,\n    set s' : set \u03b1 := {x | \u03bd t \u2264 f x},\n    have hss' : s \u2286 s' := \u03bb x hx, measure_mono (\u03bb y hy, hST $ mk_mem_prod hx hy),\n    calc \u03bc s * \u03bd t \u2264 \u03bc s' * \u03bd t : mul_le_mul_right' (measure_mono hss') _\n    ... = \u222b\u207b x in s', \u03bd t \u2202\u03bc    : by rw [set_lintegral_const, mul_comm]\n    ... \u2264 \u222b\u207b x in s', f x \u2202\u03bc    : set_lintegral_mono measurable_const hfm (\u03bb x, id)\n    ... \u2264 \u222b\u207b x, f x \u2202\u03bc          : lintegral_mono' restrict_le_self le_rfl\n    ... = \u03bc.prod \u03bd ST           : (prod_apply hSTm).symm\n    ... = \u03bc.prod \u03bd (s \u00d7\u02e2 t)     : measure_to_measurable _ }\nend\n\nlemma ae_measure_lt_top {s : set (\u03b1 \u00d7 \u03b2)} (hs : measurable_set s)\n  (h2s : (\u03bc.prod \u03bd) s \u2260 \u221e) : \u2200\u1d50 x \u2202\u03bc, \u03bd (prod.mk x \u207b\u00b9' s) < \u221e :=\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 (\u03b1 \u00d7 \u03b2)}\n  (hs : measurable_set s) (h2s : (\u03bc.prod \u03bd) s \u2260 \u221e) :\n  integrable (\u03bb x, (\u03bd (prod.mk x \u207b\u00b9' s)).to_real) \u03bc :=\nbegin\n  refine \u27e8(measurable_measure_prod_mk_left hs).ennreal_to_real.ae_measurable, _\u27e9,\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 (\u03b1 \u00d7 \u03b2)}\n  (hs : measurable_set s) : \u03bc.prod \u03bd s = 0 \u2194 (\u03bb x, \u03bd (prod.mk x \u207b\u00b9' s)) =\u1d50[\u03bc] 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 (\u03b1 \u00d7 \u03b2)}\n  (h : \u03bc.prod \u03bd s = 0) : (\u03bb x, \u03bd (prod.mk x \u207b\u00b9' s)) =\u1d50[\u03bc] 0 :=\nbegin\n  obtain \u27e8t, hst, mt, ht\u27e9 := exists_measurable_superset_of_null h,\n  simp_rw [measure_prod_null mt] at ht,\n  rw [eventually_le_antisymm_iff],\n  exact \u27e8eventually_le.trans_eq\n    (eventually_of_forall $ \u03bb x, (measure_mono (preimage_mono hst) : _)) ht,\n    eventually_of_forall $ \u03bb x, zero_le _\u27e9\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 : \u03b1 \u00d7 \u03b2 \u2192 Prop} (h : \u2200\u1d50 z \u2202\u03bc.prod \u03bd, p z) :\n  \u2200\u1d50 x \u2202 \u03bc, \u2200\u1d50 y \u2202 \u03bd, p (x, y) :=\nmeasure_ae_null_of_prod_null h\n\n/-- `\u03bc.prod \u03bd` has finite spanning sets in rectangles of finite spanning sets. -/\ndef finite_spanning_sets_in.prod {\u03bd : measure \u03b2} {C : set (set \u03b1)} {D : set (set \u03b2)}\n  (h\u03bc : \u03bc.finite_spanning_sets_in C) (h\u03bd : \u03bd.finite_spanning_sets_in D) :\n  (\u03bc.prod \u03bd).finite_spanning_sets_in (image2 (\u00d7\u02e2) C D) :=\nbegin\n  haveI := h\u03bd.sigma_finite,\n  refine \u27e8\u03bb n, h\u03bc.set n.unpair.1 \u00d7\u02e2 h\u03bd.set n.unpair.2,\n    \u03bb n, mem_image2_of_mem (h\u03bc.set_mem _) (h\u03bd.set_mem _), \u03bb n, _, _\u27e9,\n  { rw [prod_prod],\n    exact mul_lt_top (h\u03bc.finite _).ne (h\u03bd.finite _).ne },\n  { simp_rw [Union_unpair_prod, h\u03bc.spanning, h\u03bd.spanning, univ_prod_univ] }\nend\n\nlemma prod_fst_absolutely_continuous : map prod.fst (\u03bc.prod \u03bd) \u226a \u03bc :=\nbegin\n  refine absolutely_continuous.mk (\u03bb s hs h2s, _),\n  rw [map_apply measurable_fst hs, \u2190 prod_univ, prod_prod, h2s, zero_mul],\nend\n\nlemma prod_snd_absolutely_continuous : map prod.snd (\u03bc.prod \u03bd) \u226a \u03bd :=\nbegin\n  refine absolutely_continuous.mk (\u03bb s hs h2s, _),\n  rw [map_apply measurable_snd hs, \u2190 univ_prod, prod_prod, h2s, mul_zero]\nend\n\nvariables [sigma_finite \u03bc]\n\ninstance prod.sigma_finite : sigma_finite (\u03bc.prod \u03bd) :=\n(\u03bc.to_finite_spanning_sets_in.prod \u03bd.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 \u03c3-algebras. -/\nlemma prod_eq_generate_from {\u03bc : measure \u03b1} {\u03bd : measure \u03b2} {C : set (set \u03b1)}\n  {D : set (set \u03b2)} (hC : generate_from C = \u2039_\u203a)\n  (hD : generate_from D = \u2039_\u203a) (h2C : is_pi_system C) (h2D : is_pi_system D)\n  (h3C : \u03bc.finite_spanning_sets_in C) (h3D : \u03bd.finite_spanning_sets_in D)\n  {\u03bc\u03bd : measure (\u03b1 \u00d7 \u03b2)}\n  (h\u2081 : \u2200 (s \u2208 C) (t \u2208 D), \u03bc\u03bd (s \u00d7\u02e2 t) = \u03bc s * \u03bd t) : \u03bc.prod \u03bd = \u03bc\u03bd :=\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 _ \u27e8s, t, hs, ht, rfl\u27e9, haveI := h3D.sigma_finite,\n    rw [h\u2081 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 {\u03bc\u03bd : measure (\u03b1 \u00d7 \u03b2)}\n  (h : \u2200 s t, measurable_set s \u2192 measurable_set t \u2192 \u03bc\u03bd (s \u00d7\u02e2 t) = \u03bc s * \u03bd t) : \u03bc.prod \u03bd = \u03bc\u03bd :=\nprod_eq_generate_from generate_from_measurable_set generate_from_measurable_set\n  is_pi_system_measurable_set is_pi_system_measurable_set\n  \u03bc.to_finite_spanning_sets_in \u03bd.to_finite_spanning_sets_in (\u03bb s hs t ht, h s t hs ht)\n\nlemma prod_swap : map prod.swap (\u03bc.prod \u03bd) = \u03bd.prod \u03bc :=\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 (\u03b1 \u00d7 \u03b2)} (hs : measurable_set s) :\n  \u03bc.prod \u03bd s = \u222b\u207b y, \u03bc ((\u03bb x, (x, y)) \u207b\u00b9' s) \u2202\u03bd :=\nby { rw [\u2190 prod_swap, map_apply measurable_swap hs],\n     simp only [prod_apply (measurable_swap hs)], refl }\n\nlemma prod_assoc_prod [sigma_finite \u03c4] :\n  map measurable_equiv.prod_assoc ((\u03bc.prod \u03bd).prod \u03c4) = \u03bc.prod (\u03bd.prod \u03c4) :=\nbegin\n  refine (prod_eq_generate_from generate_from_measurable_set generate_from_prod\n    is_pi_system_measurable_set is_pi_system_prod \u03bc.to_finite_spanning_sets_in\n    (\u03bd.to_finite_spanning_sets_in.prod \u03c4.to_finite_spanning_sets_in) _).symm,\n  rintro s hs _ \u27e8t, u, ht, hu, rfl\u27e9, 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 \u03b1) (t : set \u03b2) :\n  (\u03bc.restrict s).prod (\u03bd.restrict t) = (\u03bc.prod \u03bd).restrict (s \u00d7\u02e2 t) :=\nbegin\n  refine prod_eq (\u03bb 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 \u03b1) :\n  (\u03bc.restrict s).prod \u03bd = (\u03bc.prod \u03bd).restrict (s \u00d7\u02e2 (univ : set \u03b2)) :=\nbegin\n  have : \u03bd = \u03bd.restrict set.univ := measure.restrict_univ.symm,\n  rwa [this, measure.prod_restrict, \u2190 this],\nend\n\nlemma prod_dirac (y : \u03b2) : \u03bc.prod (dirac y) = map (\u03bb x, (x, y)) \u03bc :=\nbegin\n  refine prod_eq (\u03bb 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, \u2190 indicator_mul_right _ (\u03bb x, \u03bc s), pi.one_apply, mul_one]\nend\n\nlemma dirac_prod (x : \u03b1) : (dirac x).prod \u03bd = map (prod.mk x) \u03bd :=\nbegin\n  refine prod_eq (\u03bb 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, \u2190 indicator_mul_left _ _ (\u03bb x, \u03bd t), pi.one_apply, one_mul]\nend\n\nlemma dirac_prod_dirac {x : \u03b1} {y : \u03b2} : (dirac x).prod (dirac y) = dirac (x, y) :=\nby rw [prod_dirac, map_dirac measurable_prod_mk_right]\n\nlemma prod_sum {\u03b9 : Type*} [fintype \u03b9] (\u03bd : \u03b9 \u2192 measure \u03b2) [\u2200 i, sigma_finite (\u03bd i)] :\n  \u03bc.prod (sum \u03bd) = sum (\u03bb i, \u03bc.prod (\u03bd i)) :=\nbegin\n  refine prod_eq (\u03bb 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 {\u03b9 : Type*} [fintype \u03b9] (\u03bc : \u03b9 \u2192 measure \u03b1) [\u2200 i, sigma_finite (\u03bc i)] :\n  (sum \u03bc).prod \u03bd = sum (\u03bb i, (\u03bc i).prod \u03bd) :=\nbegin\n  refine prod_eq (\u03bb 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 (\u03bd' : measure \u03b2) [sigma_finite \u03bd'] : \u03bc.prod (\u03bd + \u03bd') = \u03bc.prod \u03bd + \u03bc.prod \u03bd' :=\nby { refine prod_eq (\u03bb s t hs ht, _), simp_rw [add_apply, prod_prod, left_distrib] }\n\nlemma add_prod (\u03bc' : measure \u03b1) [sigma_finite \u03bc'] : (\u03bc + \u03bc').prod \u03bd = \u03bc.prod \u03bd + \u03bc'.prod \u03bd :=\nby { refine prod_eq (\u03bb s t hs ht, _), simp_rw [add_apply, prod_prod, right_distrib] }\n\n@[simp] lemma zero_prod (\u03bd : measure \u03b2) : (0 : measure \u03b1).prod \u03bd = 0 :=\nby { rw measure.prod, exact bind_zero_left _ }\n\n@[simp] lemma prod_zero (\u03bc : measure \u03b1) : \u03bc.prod (0 : measure \u03b2) = 0 :=\nby simp [measure.prod]\n\nlemma map_prod_map {\u03b4} [measurable_space \u03b4] {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b4}\n  {\u03bca : measure \u03b1} {\u03bcc : measure \u03b3} (hfa : sigma_finite (map f \u03bca))\n  (hgc : sigma_finite (map g \u03bcc)) (hf : measurable f) (hg : measurable g) :\n  (map f \u03bca).prod (map g \u03bcc) = map (prod.map f g) (\u03bca.prod \u03bcc) :=\nbegin\n  haveI := hgc.of_map \u03bcc hg,\n  refine prod_eq (\u03bb 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 \u207b\u00b9' s) (g \u207b\u00b9' t)\nend\n\nend measure\n\nnamespace measure_preserving\n\nopen measure\n\nvariables {\u03b4 : Type*} [measurable_space \u03b4] {\u03bca : measure \u03b1} {\u03bcb : measure \u03b2}\n  {\u03bcc : measure \u03b3} {\u03bcd : measure \u03b4}\n\nlemma skew_product [sigma_finite \u03bcb] [sigma_finite \u03bcd]\n  {f : \u03b1 \u2192 \u03b2} (hf : measure_preserving f \u03bca \u03bcb) {g : \u03b1 \u2192 \u03b3 \u2192 \u03b4}\n  (hgm : measurable (uncurry g)) (hg : \u2200\u1d50 x \u2202\u03bca, map (g x) \u03bcc = \u03bcd) :\n  measure_preserving (\u03bb p : \u03b1 \u00d7 \u03b3, (f p.1, g p.1 p.2)) (\u03bca.prod \u03bcc) (\u03bcb.prod \u03bcd) :=\nbegin\n  classical,\n  have : measurable (\u03bb p : \u03b1 \u00d7 \u03b3, (f p.1, g p.1 p.2)) := (hf.1.comp measurable_fst).prod_mk hgm,\n  /- if `\u03bca = 0`, then the lemma is trivial, otherwise we can use `hg`\n  to deduce `sigma_finite \u03bcc`. -/\n  rcases eq_or_ne \u03bca 0 with (rfl|ha),\n  { rw [\u2190 hf.map_eq, zero_prod, (map f).map_zero, zero_prod],\n    exact \u27e8this, (map _).map_zero\u27e9 },\n  haveI : sigma_finite \u03bcc,\n  { rcases (ae_ne_bot.2 ha).nonempty_of_mem hg with \u27e8x, hx : map (g x) \u03bcc = \u03bcd\u27e9,\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 \u27e8this, (prod_eq $ \u03bb s t hs ht, _).symm\u27e9,\n  rw [map_apply this (hs.prod ht)],\n  refine (prod_apply (this $ hs.prod ht)).trans _,\n  have : \u2200\u1d50 x \u2202\u03bca, \u03bcc ((\u03bb y, (f x, g x y)) \u207b\u00b9' (s \u00d7\u02e2 t)) = indicator (f \u207b\u00b9' s) (\u03bb y, \u03bcd t) x,\n  { refine hg.mono (\u03bb 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 : \u03b1 \u2192 \u03b2` sends the measure `\u03bca` to `\u03bcb` and `g : \u03b3 \u2192 \u03b4` sends the measure `\u03bcc` to `\u03bcd`,\nthen `prod.map f g` sends `\u03bca.prod \u03bcc` to `\u03bcb.prod \u03bcd`. -/\nprotected lemma prod [sigma_finite \u03bcb] [sigma_finite \u03bcd] {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b4}\n  (hf : measure_preserving f \u03bca \u03bcb) (hg : measure_preserving g \u03bcc \u03bcd) :\n  measure_preserving (prod.map f g) (\u03bca.prod \u03bcc) (\u03bcb.prod \u03bcd) :=\nhave measurable (uncurry $ \u03bb _ : \u03b1, g), from (hg.1.comp measurable_snd),\nhf.skew_product this $ filter.eventually_of_forall $ \u03bb _, 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 \u03bc] [sigma_finite \u03bd] {f : \u03b2 \u00d7 \u03b1 \u2192 \u03b3}\n  (hf : ae_measurable f (\u03bd.prod \u03bc)) : ae_measurable (\u03bb (z : \u03b1 \u00d7 \u03b2), f z.swap) (\u03bc.prod \u03bd) :=\nby { rw \u2190 prod_swap at hf, exact hf.comp_measurable measurable_swap }\n\nlemma ae_measurable.fst [sigma_finite \u03bd] {f : \u03b1 \u2192 \u03b3}\n  (hf : ae_measurable f \u03bc) : ae_measurable (\u03bb (z : \u03b1 \u00d7 \u03b2), f z.1) (\u03bc.prod \u03bd) :=\nhf.comp_measurable' measurable_fst prod_fst_absolutely_continuous\n\nlemma ae_measurable.snd [sigma_finite \u03bd] {f : \u03b2 \u2192 \u03b3}\n  (hf : ae_measurable f \u03bd) : ae_measurable (\u03bb (z : \u03b1 \u00d7 \u03b2), f z.2) (\u03bc.prod \u03bd) :=\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 \u03bd]\n  [second_countable_topology E] [normed_space \u211d E] [borel_space E] [complete_space E]\n  \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984 (hf : ae_measurable f (\u03bc.prod \u03bd)) : ae_measurable (\u03bb x, \u222b y, f (x, y) \u2202\u03bd) \u03bc :=\n\u27e8\u03bb x, \u222b y, hf.mk f (x, y) \u2202\u03bd, 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 }\u27e9\n\nlemma ae_measurable.prod_mk_left [sigma_finite \u03bd] {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3}\n  (hf : ae_measurable f (\u03bc.prod \u03bd)) : \u2200\u1d50 x \u2202\u03bc, ae_measurable (\u03bb y, f (x, y)) \u03bd := by\n{ filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with x hx\n    using \u27e8\u03bb y, hf.mk f (x, y), hf.measurable_mk.comp measurable_prod_mk_left, hx\u27e9 }\n\nend\n\nnamespace measure_theory\n\n/-! ### The Lebesgue integral on a product -/\n\nvariables [sigma_finite \u03bd]\n\nlemma lintegral_prod_swap [sigma_finite \u03bc] (f : \u03b1 \u00d7 \u03b2 \u2192 \u211d\u22650\u221e)\n  (hf : ae_measurable f (\u03bc.prod \u03bd)) : \u222b\u207b z, f z.swap \u2202(\u03bd.prod \u03bc) = \u222b\u207b z, f z \u2202(\u03bc.prod \u03bd) :=\nby { rw \u2190 prod_swap at hf, rw [\u2190 lintegral_map' hf measurable_swap, prod_swap] }\n\n/-- **Tonelli's Theorem**: For `\u211d\u22650\u221e`-valued measurable functions on `\u03b1 \u00d7 \u03b2`,\n  the integral of `f` is equal to the iterated integral. -/\nlemma lintegral_prod_of_measurable :\n  \u2200 (f : \u03b1 \u00d7 \u03b2 \u2192 \u211d\u22650\u221e) (hf : measurable f), \u222b\u207b z, f z \u2202(\u03bc.prod \u03bd) = \u222b\u207b x, \u222b\u207b y, f (x, y) \u2202\u03bd \u2202\u03bc :=\nbegin\n  have m := @measurable_prod_mk_left,\n  refine measurable.ennreal_induction _ _ _,\n  { intros c s hs, simp only [\u2190 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 : \u2200 x n, measurable (\u03bb y, f n (x, y)) := \u03bb x n, (hf n).comp m,\n    have k2f : \u2200 x, monotone (\u03bb n y, f n (x, y)) := \u03bb x i j hij y, h2f hij (x, y),\n    have lf : \u2200 n, measurable (\u03bb x, \u222b\u207b y, f n (x, y) \u2202\u03bd) := \u03bb n, (hf n).lintegral_prod_right',\n    have l2f : monotone (\u03bb n x, \u222b\u207b y, f n (x, y) \u2202\u03bd) := \u03bb 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 `\u211d\u22650\u221e`-valued almost everywhere measurable functions on `\u03b1 \u00d7 \u03b2`,\n  the integral of `f` is equal to the iterated integral. -/\nlemma lintegral_prod (f : \u03b1 \u00d7 \u03b2 \u2192 \u211d\u22650\u221e) (hf : ae_measurable f (\u03bc.prod \u03bd)) :\n  \u222b\u207b z, f z \u2202(\u03bc.prod \u03bd) = \u222b\u207b x, \u222b\u207b y, f (x, y) \u2202\u03bd \u2202\u03bc :=\nbegin\n  have A : \u222b\u207b z, f z \u2202(\u03bc.prod \u03bd) = \u222b\u207b z, hf.mk f z \u2202(\u03bc.prod \u03bd) :=\n    lintegral_congr_ae hf.ae_eq_mk,\n  have B : \u222b\u207b x, \u222b\u207b y, f (x, y) \u2202\u03bd \u2202\u03bc = \u222b\u207b x, \u222b\u207b y, hf.mk f (x, y) \u2202\u03bd \u2202\u03bc,\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 `\u211d\u22650\u221e`-valued almost everywhere measurable\nfunctions on `\u03b1 \u00d7 \u03b2`,  the integral of `f` is equal to the iterated integral, in reverse order. -/\nlemma lintegral_prod_symm [sigma_finite \u03bc] (f : \u03b1 \u00d7 \u03b2 \u2192 \u211d\u22650\u221e)\n  (hf : ae_measurable f (\u03bc.prod \u03bd)) : \u222b\u207b z, f z \u2202(\u03bc.prod \u03bd) = \u222b\u207b y, \u222b\u207b x, f (x, y) \u2202\u03bc \u2202\u03bd :=\nby { simp_rw [\u2190 lintegral_prod_swap f hf], exact lintegral_prod _ hf.prod_swap }\n\n/-- The symmetric verion of Tonelli's Theorem: For `\u211d\u22650\u221e`-valued measurable\nfunctions on `\u03b1 \u00d7 \u03b2`,  the integral of `f` is equal to the iterated integral, in reverse order. -/\nlemma lintegral_prod_symm' [sigma_finite \u03bc] (f : \u03b1 \u00d7 \u03b2 \u2192 \u211d\u22650\u221e)\n  (hf : measurable f) : \u222b\u207b z, f z \u2202(\u03bc.prod \u03bd) = \u222b\u207b y, \u222b\u207b x, f (x, y) \u2202\u03bc \u2202\u03bd :=\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 \u2983f : \u03b1 \u2192 \u03b2 \u2192 \u211d\u22650\u221e\u2984\n  (hf : ae_measurable (uncurry f) (\u03bc.prod \u03bd)) :\n  \u222b\u207b x, \u222b\u207b y, f x y \u2202\u03bd \u2202\u03bc = \u222b\u207b z, f z.1 z.2 \u2202(\u03bc.prod \u03bd) :=\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 \u03bc] \u2983f : \u03b1 \u2192 \u03b2 \u2192 \u211d\u22650\u221e\u2984\n  (hf : ae_measurable (uncurry f) (\u03bc.prod \u03bd)) :\n  \u222b\u207b x, \u222b\u207b y, f x y \u2202\u03bd \u2202\u03bc = \u222b\u207b z, f z.2 z.1 \u2202(\u03bd.prod \u03bc) :=\n(lintegral_prod_symm _ hf.prod_swap).symm\n\n/-- Change the order of Lebesgue integration. -/\nlemma lintegral_lintegral_swap [sigma_finite \u03bc] \u2983f : \u03b1 \u2192 \u03b2 \u2192 \u211d\u22650\u221e\u2984\n  (hf : ae_measurable (uncurry f) (\u03bc.prod \u03bd)) :\n  \u222b\u207b x, \u222b\u207b y, f x y \u2202\u03bd \u2202\u03bc = \u222b\u207b y, \u222b\u207b x, f x y \u2202\u03bc \u2202\u03bd :=\n(lintegral_lintegral hf).trans (lintegral_prod_symm _ hf)\n\nlemma lintegral_prod_mul {f : \u03b1 \u2192 \u211d\u22650\u221e} {g : \u03b2 \u2192 \u211d\u22650\u221e}\n  (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bd) :\n  \u222b\u207b z, f z.1 * g z.2 \u2202(\u03bc.prod \u03bd) = \u222b\u207b x, f x \u2202\u03bc * \u222b\u207b y, g y \u2202\u03bd :=\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 \u03bc] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) : integrable (f \u2218 prod.swap) (\u03bd.prod \u03bc) :=\n\u27e8hf.ae_measurable.prod_swap,\n  (lintegral_prod_swap _ hf.ae_measurable.ennnorm : _).le.trans_lt hf.has_finite_integral\u27e9\n\nlemma integrable_swap_iff [sigma_finite \u03bc] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984 :\n  integrable (f \u2218 prod.swap) (\u03bd.prod \u03bc) \u2194 integrable f (\u03bc.prod \u03bd) :=\n\u27e8\u03bb hf, by { convert hf.swap, ext \u27e8x, y\u27e9, refl }, \u03bb hf, hf.swap\u27e9\n\nlemma has_finite_integral_prod_iff \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984 (h1f : measurable f) :\n  has_finite_integral f (\u03bc.prod \u03bd) \u2194 (\u2200\u1d50 x \u2202 \u03bc, has_finite_integral (\u03bb y, f (x, y)) \u03bd) \u2227\n    has_finite_integral (\u03bb x, \u222b y, \u2225f (x, y)\u2225 \u2202\u03bd) \u03bc :=\nbegin\n  simp only [has_finite_integral, lintegral_prod_of_measurable _ h1f.ennnorm],\n  have : \u2200 x, \u2200\u1d50 y \u2202\u03bd, 0 \u2264 \u2225f (x, y)\u2225 := \u03bb x, eventually_of_forall (\u03bb 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 : \u2200 {p q r : Prop} (h1 : r \u2192 p), (r \u2194 p \u2227 q) \u2194 (p \u2192 (r \u2194 q)) :=\n  \u03bb p q r h1, by rw [\u2190 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 [\u2190 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' \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984 (h1f : ae_measurable f (\u03bc.prod \u03bd)) :\n  has_finite_integral f (\u03bc.prod \u03bd) \u2194 (\u2200\u1d50 x \u2202 \u03bc, has_finite_integral (\u03bb y, f (x, y)) \u03bd) \u2227\n    has_finite_integral (\u03bb x, \u222b y, \u2225f (x, y)\u2225 \u2202\u03bd) \u03bc :=\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 \u21a6 f (x, y)` is integrable for almost every\n  `x` and the function `x \u21a6 \u222b \u2225f (x, y)\u2225 dy` is integrable. -/\nlemma integrable_prod_iff \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984 (h1f : ae_measurable f (\u03bc.prod \u03bd)) :\n  integrable f (\u03bc.prod \u03bd) \u2194\n    (\u2200\u1d50 x \u2202 \u03bc, integrable (\u03bb y, f (x, y)) \u03bd) \u2227 integrable (\u03bb x, \u222b y, \u2225f (x, y)\u2225 \u2202\u03bd) \u03bc :=\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 \u21a6 f (x, y)` is integrable for almost every\n  `y` and the function `y \u21a6 \u222b \u2225f (x, y)\u2225 dx` is integrable. -/\nlemma integrable_prod_iff' [sigma_finite \u03bc] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984 (h1f : ae_measurable f (\u03bc.prod \u03bd)) :\n  integrable f (\u03bc.prod \u03bd) \u2194\n    (\u2200\u1d50 y \u2202 \u03bd, integrable (\u03bb x, f (x, y)) \u03bc) \u2227 integrable (\u03bb y, \u222b x, \u2225f (x, y)\u2225 \u2202\u03bc) \u03bd :=\nby { convert integrable_prod_iff (h1f.prod_swap) using 1, rw [integrable_swap_iff] }\n\nlemma integrable.prod_left_ae [sigma_finite \u03bc] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) : \u2200\u1d50 y \u2202 \u03bd, integrable (\u03bb x, f (x, y)) \u03bc :=\n((integrable_prod_iff' hf.ae_measurable).mp hf).1\n\nlemma integrable.prod_right_ae [sigma_finite \u03bc] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) : \u2200\u1d50 x \u2202 \u03bc, integrable (\u03bb y, f (x, y)) \u03bd :=\nhf.swap.prod_left_ae\n\nlemma integrable.integral_norm_prod_left \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) : integrable (\u03bb x, \u222b y, \u2225f (x, y)\u2225 \u2202\u03bd) \u03bc :=\n((integrable_prod_iff hf.ae_measurable).mp hf).2\n\nlemma integrable.integral_norm_prod_right [sigma_finite \u03bc] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) : integrable (\u03bb y, \u222b x, \u2225f (x, y)\u2225 \u2202\u03bc) \u03bd :=\nhf.swap.integral_norm_prod_left\n\nend\n\nvariables [second_countable_topology E] [normed_space \u211d E]\n  [complete_space E] [borel_space E]\n\nlemma integrable.integral_prod_left \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) : integrable (\u03bb x, \u222b y, f (x, y) \u2202\u03bd) \u03bc :=\nintegrable.mono hf.integral_norm_prod_left hf.ae_measurable.integral_prod_right' $\n  eventually_of_forall $ \u03bb x, (norm_integral_le_integral_norm _).trans_eq $\n  (norm_of_nonneg $ integral_nonneg_of_ae $ eventually_of_forall $\n  \u03bb y, (norm_nonneg (f (x, y)) : _)).symm\n\nlemma integrable.integral_prod_right [sigma_finite \u03bc] \u2983f : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) : integrable (\u03bb y, \u222b x, f (x, y) \u2202\u03bc) \u03bd :=\nhf.swap.integral_prod_left\n\n/-! ### The Bochner integral on a product -/\n\nvariables [sigma_finite \u03bc]\n\nlemma integral_prod_swap (f : \u03b1 \u00d7 \u03b2 \u2192 E)\n  (hf : ae_measurable f (\u03bc.prod \u03bd)) : \u222b z, f z.swap \u2202(\u03bd.prod \u03bc) = \u222b z, f z \u2202(\u03bc.prod \u03bd) :=\nbegin\n  rw \u2190 prod_swap at hf,\n  rw [\u2190 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 \u211d 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 \u2983f g : \u03b1 \u00d7 \u03b2 \u2192 E\u2984 (F : E \u2192 E')\n  (hf : integrable f (\u03bc.prod \u03bd)) (hg : integrable g (\u03bc.prod \u03bd)) :\n  \u222b x, F (\u222b y, f (x, y) + g (x, y) \u2202\u03bd) \u2202\u03bc = \u222b x, F (\u222b y, f (x, y) \u2202\u03bd + \u222b y, g (x, y) \u2202\u03bd) \u2202\u03bc :=\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 \u2983f g : \u03b1 \u00d7 \u03b2 \u2192 E\u2984 (F : E \u2192 E')\n  (hf : integrable f (\u03bc.prod \u03bd)) (hg : integrable g (\u03bc.prod \u03bd)) :\n  \u222b x, F (\u222b y, f (x, y) - g (x, y) \u2202\u03bd) \u2202\u03bc = \u222b x, F (\u222b y, f (x, y) \u2202\u03bd - \u222b y, g (x, y) \u2202\u03bd) \u2202\u03bc :=\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 \u2983f g : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (F : E \u2192 \u211d\u22650\u221e) (hf : integrable f (\u03bc.prod \u03bd)) (hg : integrable g (\u03bc.prod \u03bd)) :\n  \u222b\u207b x, F (\u222b y, f (x, y) - g (x, y) \u2202\u03bd) \u2202\u03bc = \u222b\u207b x, F (\u222b y, f (x, y) \u2202\u03bd - \u222b y, g (x, y) \u2202\u03bd) \u2202\u03bc :=\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 \u2983f g : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) (hg : integrable g (\u03bc.prod \u03bd)) :\n  \u222b x, \u222b y, f (x, y) + g (x, y) \u2202\u03bd \u2202\u03bc = \u222b x, \u222b y, f (x, y) \u2202\u03bd \u2202\u03bc + \u222b x, \u222b y, g (x, y) \u2202\u03bd \u2202\u03bc :=\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' \u2983f g : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) (hg : integrable g (\u03bc.prod \u03bd)) :\n  \u222b x, \u222b y, (f + g) (x, y) \u2202\u03bd \u2202\u03bc = \u222b x, \u222b y, f (x, y) \u2202\u03bd \u2202\u03bc + \u222b x, \u222b y, g (x, y) \u2202\u03bd \u2202\u03bc :=\nintegral_integral_add hf hg\n\n/-- Double integrals commute with subtraction. -/\nlemma integral_integral_sub \u2983f g : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) (hg : integrable g (\u03bc.prod \u03bd)) :\n  \u222b x, \u222b y, f (x, y) - g (x, y) \u2202\u03bd \u2202\u03bc = \u222b x, \u222b y, f (x, y) \u2202\u03bd \u2202\u03bc - \u222b x, \u222b y, g (x, y) \u2202\u03bd \u2202\u03bc :=\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' \u2983f g : \u03b1 \u00d7 \u03b2 \u2192 E\u2984\n  (hf : integrable f (\u03bc.prod \u03bd)) (hg : integrable g (\u03bc.prod \u03bd)) :\n  \u222b x, \u222b y, (f - g) (x, y) \u2202\u03bd \u2202\u03bc = \u222b x, \u222b y, f (x, y) \u2202\u03bd \u2202\u03bc - \u222b x, \u222b y, g (x, y) \u2202\u03bd \u2202\u03bc :=\nintegral_integral_sub hf hg\n\n/-- The map that sends an L\u00b9-function `f : \u03b1 \u00d7 \u03b2 \u2192 E` to `\u222b\u222bf` is continuous. -/\nlemma continuous_integral_integral :\n  continuous (\u03bb (f : \u03b1 \u00d7 \u03b2 \u2192\u2081[\u03bc.prod \u03bd] E), \u222b x, \u222b y, f (x, y) \u2202\u03bd \u2202\u03bc) :=\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 $ \u03bb h, (L1.integrable_coe_fn h).integral_prod_left) _,\n  simp_rw [\u2190 lintegral_fn_integral_sub (\u03bb x, (nnnorm x : \u211d\u22650\u221e)) (L1.integrable_coe_fn _)\n    (L1.integrable_coe_fn g)],\n  refine tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds _ (\u03bb i, zero_le _) _,\n  { exact \u03bb i, \u222b\u207b x, \u222b\u207b y, nnnorm (i (x, y) - g (x, y)) \u2202\u03bd \u2202\u03bc },\n  swap, { exact \u03bb i, lintegral_mono (\u03bb x, ennnorm_integral_le_lintegral_ennnorm _) },\n  show tendsto (\u03bb (i : \u03b1 \u00d7 \u03b2 \u2192\u2081[\u03bc.prod \u03bd] E),\n    \u222b\u207b x, \u222b\u207b (y : \u03b2), nnnorm (i (x, y) - g (x, y)) \u2202\u03bd \u2202\u03bc) (\ud835\udcdd g) (\ud835\udcdd 0),\n  have : \u2200 (i : \u03b1 \u00d7 \u03b2 \u2192\u2081[\u03bc.prod \u03bd] E), measurable (\u03bb z, (nnnorm (i z - g z) : \u211d\u22650\u221e)) :=\n  \u03bb i, ((Lp.measurable i).sub (Lp.measurable g)).ennnorm,\n  simp_rw [\u2190 lintegral_prod_of_measurable _ (this _), \u2190 L1.of_real_norm_sub_eq_lintegral,\n    \u2190 of_real_zero],\n  refine (continuous_of_real.tendsto 0).comp _,\n  rw [\u2190 tendsto_iff_norm_tendsto_zero], exact tendsto_id\nend\n\n/-- **Fubini's Theorem**: For integrable functions on `\u03b1 \u00d7 \u03b2`,\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 : \u2200 (f : \u03b1 \u00d7 \u03b2 \u2192 E) (hf : integrable f (\u03bc.prod \u03bd)),\n  \u222b z, f z \u2202(\u03bc.prod \u03bd) = \u222b x, \u222b y, f (x, y) \u2202\u03bd \u2202\u03bc :=\nbegin\n  apply integrable.induction,\n  { intros c s hs h2s,\n    simp_rw [integral_indicator hs, \u2190 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 `\u03b1 \u00d7 \u03b2`,\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 : \u03b1 \u00d7 \u03b2 \u2192 E) (hf : integrable f (\u03bc.prod \u03bd)) :\n  \u222b z, f z \u2202(\u03bc.prod \u03bd) = \u222b y, \u222b x, f (x, y) \u2202\u03bc \u2202\u03bd :=\nby { simp_rw [\u2190 integral_prod_swap f hf.ae_measurable], exact integral_prod _ hf.swap }\n\n/-- Reversed version of **Fubini's Theorem**. -/\nlemma integral_integral {f : \u03b1 \u2192 \u03b2 \u2192 E} (hf : integrable (uncurry f) (\u03bc.prod \u03bd)) :\n  \u222b x, \u222b y, f x y \u2202\u03bd \u2202\u03bc = \u222b z, f z.1 z.2 \u2202(\u03bc.prod \u03bd) :=\n(integral_prod _ hf).symm\n\n/-- Reversed version of **Fubini's Theorem** (symmetric version). -/\nlemma integral_integral_symm {f : \u03b1 \u2192 \u03b2 \u2192 E} (hf : integrable (uncurry f) (\u03bc.prod \u03bd)) :\n  \u222b x, \u222b y, f x y \u2202\u03bd \u2202\u03bc = \u222b z, f z.2 z.1 \u2202(\u03bd.prod \u03bc) :=\n(integral_prod_symm _ hf.swap).symm\n\n/-- Change the order of Bochner integration. -/\nlemma integral_integral_swap \u2983f : \u03b1 \u2192 \u03b2 \u2192 E\u2984 (hf : integrable (uncurry f) (\u03bc.prod \u03bd)) :\n  \u222b x, \u222b y, f x y \u2202\u03bd \u2202\u03bc = \u222b y, \u222b x, f x y \u2202\u03bc \u2202\u03bd :=\n(integral_integral hf).trans (integral_prod_symm _ hf)\n\n/-- **Fubini's Theorem** for set integrals. -/\nlemma set_integral_prod (f : \u03b1 \u00d7 \u03b2 \u2192 E) {s : set \u03b1} {t : set \u03b2}\n  (hf : integrable_on f (s \u00d7\u02e2 t) (\u03bc.prod \u03bd)) :\n  \u222b z in s \u00d7\u02e2 t, f z \u2202(\u03bc.prod \u03bd) = \u222b x in s, \u222b y in t, f (x, y) \u2202\u03bd \u2202\u03bc :=\nbegin\n  simp only [\u2190 measure.prod_restrict s t, integrable_on] at hf \u22a2,\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 `\u03b1` with a monoid structure, `single_obj \u03b1` is `unit` type with `category` structure\nsuch that `End (single_obj \u03b1).star` is the monoid `\u03b1`.  This can be extended to a functor `Mon \u2964\nCat`.\n\nIf `\u03b1` is a group, then `single_obj \u03b1` is a groupoid.\n\nAn element `x : \u03b1` can be reinterpreted as an element of `End (single_obj.star \u03b1)` using\n`single_obj.to_End`.\n\n## Implementation notes\n\n- `category_struct.comp` on `End (single_obj.star \u03b1)` is `flip (*)`, not `(*)`. This way\n  multiplication on `End` agrees with the multiplication on `\u03b1`.\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 (\u03b1 : Type u)\n\n/-- One and `flip (*)` become `id` and `comp` for morphisms of the single object category. -/\ninstance category_struct [has_one \u03b1] [has_mul \u03b1] : category_struct (single_obj \u03b1) :=\n{ hom := \u03bb _ _, \u03b1,\n  comp := \u03bb _ _ _ x y, y * x,\n  id := \u03bb _, 1 }\n\n/-- Monoid laws become category laws for the single object category. -/\ninstance category [monoid \u03b1] : category (single_obj \u03b1) :=\n{ comp_id' := \u03bb _ _, one_mul,\n  id_comp' := \u03bb _ _, mul_one,\n  assoc' := \u03bb _ _ _ _ x y z, (mul_assoc z y x).symm }\n\nlemma id_as_one [monoid \u03b1] (x : single_obj \u03b1) : \ud835\udfd9 x = 1 := rfl\n\nlemma comp_as_mul [monoid \u03b1] {x y z : single_obj \u03b1} (f : x \u27f6 y) (g : y \u27f6 z) :\n  f \u226b g = g * f := rfl\n\n/--\nGroupoid structure on `single_obj \u03b1`.\n\nSee <https://stacks.math.columbia.edu/tag/0019>.\n-/\ninstance groupoid [group \u03b1] : groupoid (single_obj \u03b1) :=\n{ inv := \u03bb _ _ x, x\u207b\u00b9,\n  inv_comp' := \u03bb _ _, mul_right_inv,\n  comp_inv' := \u03bb _ _, 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 \u03b1 := quiver.single_obj.star \u03b1\n\n/-- The endomorphisms monoid of the only object in `single_obj \u03b1` is equivalent to the original\n     monoid \u03b1. -/\ndef to_End [monoid \u03b1] : \u03b1 \u2243* End (single_obj.star \u03b1) :=\n{ map_mul' := \u03bb x y, rfl,\n  .. equiv.refl \u03b1 }\n\nlemma to_End_def [monoid \u03b1] (x : \u03b1) : to_End \u03b1 x = x := rfl\n\n/-- There is a 1-1 correspondence between monoid homomorphisms `\u03b1 \u2192 \u03b2` 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 (\u03b1 : Type u) (\u03b2 : Type v) [monoid \u03b1] [monoid \u03b2] :\n  (\u03b1 \u2192* \u03b2) \u2243 (single_obj \u03b1) \u2964 (single_obj \u03b2) :=\n{ to_fun := \u03bb f,\n  { obj := id,\n    map := \u03bb _ _, \u21d1f,\n    map_id' := \u03bb _, f.map_one,\n    map_comp' := \u03bb _ _ _ x y, f.map_mul y x },\n  inv_fun := \u03bb f,\n    { to_fun := @functor.map _ _ _ _ f (single_obj.star \u03b1) (single_obj.star \u03b1),\n      map_one' := f.map_id _,\n      map_mul' := \u03bb x y, f.map_comp y x },\n  left_inv := \u03bb \u27e8f, h\u2081, h\u2082\u27e9, rfl,\n  right_inv := \u03bb f, by cases f; obviously }\n\nlemma map_hom_id (\u03b1 : Type u) [monoid \u03b1] : map_hom \u03b1 \u03b1 (monoid_hom.id \u03b1) = \ud835\udfed _ := rfl\n\nlemma map_hom_comp {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2)\n  {\u03b3 : Type w} [monoid \u03b3] (g : \u03b2 \u2192* \u03b3) :\n  map_hom \u03b1 \u03b3 (g.comp f) = map_hom \u03b1 \u03b2 f \u22d9 map_hom \u03b2 \u03b3 g :=\nrfl\n\n/-- Given a function `f : C \u2192 G` from a category to a group, we get a functor\n    `C \u2964 G` sending any morphism `x \u27f6 y` to `f y * (f x)\u207b\u00b9`. -/\n@[simps] def difference_functor {C G} [category C] [group G] (f : C \u2192 G) : C \u2964 single_obj G :=\n{ obj := \u03bb _, (),\n  map := \u03bb x y _, f y * (f x)\u207b\u00b9,\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, \u2190mul_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 : \u03b1 \u2192 \u03b2` as a functor `(single_obj \u03b1) \u2964 (single_obj \u03b2)`.\nSee also `category_theory.single_obj.map_hom` for an equivalence between these types. -/\n@[reducible] def to_functor {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2) :\n  (single_obj \u03b1) \u2964 (single_obj \u03b2) :=\nsingle_obj.map_hom \u03b1 \u03b2 f\n\n@[simp] lemma id_to_functor (\u03b1 : Type u) [monoid \u03b1] : (id \u03b1).to_functor = \ud835\udfed _ := rfl\n@[simp] lemma comp_to_functor {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2)\n  {\u03b3 : Type w} [monoid \u03b3] (g : \u03b2 \u2192* \u03b3) :\n  (g.comp f).to_functor = f.to_functor \u22d9 g.to_functor :=\nrfl\n\nend monoid_hom\n\nnamespace units\n\nvariables (\u03b1 : Type u) [monoid \u03b1]\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 : \u03b1\u02e3 \u2243* Aut (single_obj.star \u03b1) :=\n(units.map_equiv (single_obj.to_End \u03b1)).trans $\n  Aut.units_End_equiv_Aut _\n\n@[simp] lemma to_Aut_hom (x : \u03b1\u02e3) : (to_Aut \u03b1 x).hom = single_obj.to_End \u03b1 x := rfl\n@[simp] lemma to_Aut_inv (x : \u03b1\u02e3) :\n  (to_Aut \u03b1 x).inv = single_obj.to_End \u03b1 (x\u207b\u00b9 : \u03b1\u02e3) :=\nrfl\nend units\n\nnamespace Mon\n\nopen category_theory\n\n/-- The fully faithful functor from `Mon` to `Cat`. -/\ndef to_Cat : Mon \u2964 Cat :=\n{ obj := \u03bb x, Cat.of (single_obj x),\n  map := \u03bb x y f, single_obj.map_hom x y f }\n\ninstance to_Cat_full : full to_Cat :=\n{ preimage := \u03bb x y, (single_obj.map_hom x y).inv_fun,\n  witness' := \u03bb x y, by apply equiv.right_inv }\n\ninstance to_Cat_faithful : faithful to_Cat :=\n{ map_injective' := \u03bb 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 smt2\n\nlemma int_ctor (n : nat) :\n    int.of_nat n >= 0 :=\nbegin\n    z3\nend\n", "meta": {"author": "leanprover", "repo": "smt2_interface", "sha": "7ff0ce248b68ea4db2a2d4966a97b5786da05ed7", "save_path": "github-repos/lean/leanprover-smt2_interface", "path": "github-repos/lean/leanprover-smt2_interface/smt2_interface-7ff0ce248b68ea4db2a2d4966a97b5786da05ed7/test/int_constructor.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.4797949767924757}}
{"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 [\u2190neg_neg (x*y), neg_mul_eq_mul_neg x y, mul_comm x (-y), add_assoc, \u2190add_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\u2081 : 0 \u2264 a) (h\u2082 : 0 \u2264 b)\n: a*a \u2264 b*b \u2194 a \u2264 b :=\nbegin\n  split,\n  { intro aalebb,\n    have h\u2083 : 0 \u2264 b*b - a*a, linarith,\n    rw difference_of_two_squares b a at h\u2083,\n    rw non_neg_mul_iff_non_neg_and_non_neg_or_non_pos_and_non_pos at h\u2083,\n    cases h\u2083; linarith },\n  { intro aleb,\n    exact mul_le_mul aleb aleb h\u2081 h\u2082, },\nend\n\nlemma pos_mul_iff_pos_and_pos_or_neg_and_neg (a b : R)\n  : 0 < a * b \u2194 (0 < a \u2227 0 < b) \u2228 (a < 0 \u2227 b < 0) :=\nbegin\n  split,\n  { intro h,\n    by_cases h\u2082 : 0 \u2264 a,\n    { by_cases h\u2083 : a = 0,\n      { rw h\u2083 at h, linarith, },\n      { have h\u2084 : 0 < a, from or.elim h\u2082 id (\u03bb aeq0, absurd aeq0.symm h\u2083), \n        have h\u2085 : 0 < b, from (zero_lt_mul_left h\u2084).mp h,\n        exact or.inl \u27e8h\u2084, h\u2085\u27e9, }, },\n    { have h\u2084 : a < 0, linarith,\n      have h\u2085 : b < 0, \n      { by_contra p,\n        rw not_lt_iff_le at p,\n        rw \u2190neg_pos at h\u2084,\n        have h\u2085 : 0 \u2264 (-a) * b, from (zero_le_mul_left h\u2084).mpr p,\n        have h\u2086 : -a * b = -(a*b),\n        { rw [mul_comm (-a), \u2190neg_mul_eq_mul_neg, mul_comm], },\n        rw h\u2086 at h\u2085,\n        linarith, },\n        exact or.inr \u27e8h\u2084, h\u2085\u27e9, }, },\n  { rintro (\u27e8apos, bpos\u27e9 | \u27e8aneg, bneg\u27e9),\n    { exact gt_zero_mul_of_gt_zero_of_gt_zero apos bpos },\n    { rw \u2190neg_mul_neg a b,\n      rw \u2190neg_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\u2081 : 0 < a) (h\u2082 : 0 < b)\n: a*a < b*b \u2194 a < b :=\nbegin\n  split,\n  { intro aalebb,\n    have h\u2083 : 0 < b*b - a*a, linarith,\n    rw difference_of_two_squares b a at h\u2083,\n    rw pos_mul_iff_pos_and_pos_or_neg_and_neg at h\u2083,\n    rcases h\u2083 with \u27e8h\u2083_left, h\u2083_right\u27e9 | \u27e8h\u2083_left, h\u2083_right\u27e9,\n    { linarith, },\n    { have h\u2084 : a < -b, linarith,\n      have h\u2085 : -b < 0, linarith,\n      have h\u2086 : a < 0, from lt_trans h\u2084 h\u2085,\n      have : (0 : R) < 0, from lt_trans h\u2081 h\u2086, \n      linarith, }, },\n  { intro aleb,\n    apply mul_lt_mul,\n    { exact aleb, },\n    { exact le_of_lt aleb, },\n    { exact h\u2081 },\n    { exact le_of_lt h\u2082 }, },\nend\n\nlemma zero_eq_zero : (0 : R) = \u21910 := rfl\n\nlemma one_eq_one : \u21911 = (1 : R) :=\nby rw [coe_nat_succ, \u2190zero_eq_zero, zero_add]\n\nlemma pos_iff_gt_zero (x : R) : pos x \u2194 0 < x := \nby rw [lt_iff_pos_sub, sub_zero]\n\nlemma non_zero_of_pos {x : R} (h : 0 < x) : x \u2260 0 :=\nbegin\n  intro k,\n  rw k at h,\n  exact lt_irrefl h,\nend\n\nlemma coe_zero_inj {m : \u2115} (h : (m : R) = 0) : m = 0 :=\nbegin\n  by_contra k,\n  have h\u2082 : pos(m : R), from pos_nat m k,\n  rw [h, pos_iff_gt_zero (0 : R)] at h\u2082,\n  exact lt_irrefl h\u2082,\nend\n\nlemma coe_non_zero_of_non_zero {m : \u2115} (h : m \u2260 0) : (m : R) \u2260 0 :=\nbegin\n  contrapose! h,\n  exact coe_zero_inj h,\nend\n\nlemma gt_zero_of_ne_zero_nat (n : \u2115) (h : n \u2260 0) : (0 : R) < n :=\nbegin\n  rw [\u2190pos_iff_gt_zero],\n  exact pos_nat n h,\nend\n\nlemma coe_pred (n : \u2115) (h : n \u2260 0) : (\u2191(n-1) : R) = \u2191n - 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 : \u2115} (h : \u2191x = \u2191k + (1 : R)) : (\u2191(x-1) : R)= \u2191k :=\nbegin\n  by_cases xeq0 : x = 0,\n  { exfalso, rw xeq0 at h, \n    change 0 = \u2191k + (1:R) at h,\n    have h\u2082 : \u2191k = -(1 : R),\n    { rw [\u2190zero_add (-1: R), h, add_assoc, add_neg', add_zero], },\n    have h\u2083 : (0 : R) \u2264 \u2191k,\n    { rw le_iff_lt_or_eq,\n      by_cases h\u2084 : k = 0,\n      { rw h\u2084, right, refl, },\n      { left, rw \u2190pos_iff_gt_zero, exact pos_nat k h\u2084, }, },\n    rw h\u2082 at h\u2083,\n    linarith, },\n  { change x \u2260 0 at xeq0,\n    rw coe_pred _ xeq0,\n    linarith, }\nend\n\nlemma coe_inj (m n : \u2115) (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\u2082 : x = 0,\n    { rw [h\u2082, \u2190zero_eq_zero] at hx,\n      have h\u2082 : \u2191k = -(1 : R),\n      { rw [\u2190zero_add (-1: R), hx, add_assoc, add_neg', add_zero], },\n      have h\u2083 : (0 : R) \u2264 \u2191k,\n      { rw le_iff_lt_or_eq,\n        by_cases h\u2084 : k = 0,\n        { rw h\u2084, right, refl, },\n        { left, rw \u2190pos_iff_gt_zero, exact pos_nat k h\u2084, }, },\n      rw h\u2082 at h\u2083,\n      linarith, },\n    { rw coe_pred x h\u2082 at hk, \n      have h\u2083 : \u2191x - (1 : R) = \u2191k, linarith,\n      have h\u2084 : x - 1 = k, from hk h\u2083,\n      rw \u2190h\u2084,\n      cases nat.eq_zero_or_eq_succ_pred x with x0 xsp,\n      { exact absurd x0 h\u2082, },\n      { assumption, }, }, },\nend\n\nlemma coe_monotone (m n : \u2115) (h : m \u2264 n) : (m : R) \u2264 (n : R) :=\nbegin\n  revert n,\n  induction m with k hk,\n  { intros n h,\n    rw [\u2190zero_eq_zero,le_iff_lt_or_eq],\n    by_cases h\u2082 : n = 0,\n    { right, rw [h\u2082, zero_eq_zero], },\n    { left, exact gt_zero_of_ne_zero_nat n h\u2082, }, },\n  { intros x hx,\n    specialize hk (x-1),\n    by_cases h\u2082 : x = 0,\n    { exfalso,\n      rw [h\u2082, \u2190not_lt] at hx,\n      exact hx (nat.succ_pos k), },\n    { rcases nat.exists_eq_succ_of_ne_zero h\u2082 with \u27e8w, h\u27e9,\n      rw coe_nat_succ,\n      rw coe_pred x h\u2082 at hk,\n      rw h at hx hk,\n      suffices h\u2083 : \u2191k \u2264 \u2191(nat.succ w) - (1 : R),\n      { rw h, linarith, },\n      have h\u2083 : nat.succ w - 1 = w := rfl,\n      rw h\u2083 at hk,\n      rw \u2190nat.pred_le_iff at hx,\n      change k \u2264 w at hx,\n      exact hk hx, }, },\nend\n\nlemma coe_monotone' (m n : \u2115) (h : m < n) : (m : R) < (n : R) :=\nbegin\n  have h\u2082 : m \u2264 n, linarith,\n  have h\u2083 : (m : R) \u2264 n, from coe_monotone _ _ h\u2082,\n  rw le_iff_lt_or_eq at h\u2083,\n  cases h\u2083 with mltn meqn,\n  { exact mltn, },\n  { have h\u2083 : m = n, from coe_inj m n meqn, \n    linarith, },\nend\n\nlemma non_neg_of_non_neg (n : \u2115) (h : 0 \u2264 n) : (0 : R) \u2264 \u2191n :=\nbegin\n  rw le_iff_lt_or_eq,\n  by_cases h\u2082 : n = 0,\n  { right, rw [h\u2082, zero_eq_zero], },\n  { left, exact gt_zero_of_ne_zero_nat n h\u2082, }\nend\n\nlemma ge_one_of_non_zero (k : \u2115) (h : k \u2260 0): (1 : R) \u2264 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 \u2190add_zero (1 : R)},\n    by_cases h\u2082 : m = 1,\n    { rw [h\u2082, add_zero, one_eq_one], \n      change (1 : R) \u2264 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\u2083 : m = 0,\n        { right, rw h\u2083, refl, },\n        { left, exact gt_zero_of_ne_zero_nat m h\u2083, }, },\n      { exact le_refl 1, }, }, },\nend\n\nlemma pos_inv_nat_of_non_zero {n : \u2115} (h : n \u2260 0) : (0 : R) < (\u2191n)\u207b\u00b9 :=\nbegin\n  have h\u2082 : (0 : R) < \u2191n, from gt_zero_of_ne_zero_nat n h,\n  have h\u2083 : \u2191n \u2260 (0 : R), from non_zero_of_pos h\u2082,\n  rwa inv_pos h\u2083,\nend\n\ntheorem inv_le_inv {a b : R} (h\u2081 : 0 < a) (h\u2082 : 0 < b) : a\u207b\u00b9 \u2264 b\u207b\u00b9 \u2194 b \u2264 a :=\nbegin\n  have k\u2081 : a \u2260 (0 : R), from non_zero_of_pos h\u2081,\n  have k\u2082 : b \u2260 0, from non_zero_of_pos h\u2082,\n  repeat {rw le_iff_lt_or_eq },\n  split,\n  { rintro (hlt | heq),\n    { left,\n      rwa \u2190inv_lt_inv h\u2081 h\u2082, },\n    { right,\n      rw [\u2190inv_inv' a k\u2081, \u2190inv_inv' b k\u2082, heq], }, },\n  { rintro (hlt | heq),\n    { left, \n      rwa inv_lt_inv h\u2081 h\u2082, },\n    { rw heq, right, refl, }, },\nend\n\nlemma pos_add_inv_nat_of_pos {u : R} {n : \u2115} (h : (0 : R) < u) (h\u2082 : n \u2260 0)\n: (0 : R) < u + (\u2191n)\u207b\u00b9 :=\nbegin\n  rw \u2190add_zero (0 : R),\n  apply add_lt_add h,\n  rw inv_pos (coe_non_zero_of_non_zero h\u2082),\n  exact gt_zero_of_ne_zero_nat n h\u2082,\nend\n\nlemma pos_sub_inv_nat_of_pos {u : R} {n : \u2115} (k\u2084 : (0 : R) < u) (ne0 : n \u2260 0) (k\u2085 : 2 < u*u)\n: (0 : R) < u - (\u2191n)\u207b\u00b9 :=\nbegin\n  by_contra p, \n  have : u \u2264 (\u2191n)\u207b\u00b9, linarith,\n  have h\u2082 : (1 : R) \u2264 (\u2191n), from ge_one_of_non_zero n ne0,\n  have h\u2083 : (0 : R) < \u2191n, {rw \u2190pos_iff_gt_zero, exact pos_nat n ne0},\n  have h\u2084 : (\u2191n)\u207b\u00b9 \u2264 (1 : R)\u207b\u00b9, { rwa inv_le_inv h\u2083 zero_lt_one, },\n  have h\u2085 : u \u2264 (1 : R)\u207b\u00b9, linarith,\n  rw one_inv at h\u2085,\n  have : u * u \u2264 1 * 1, from mul_le_mul h\u2085 h\u2085 (le_of_lt k\u2084) zero_le_one,\n  linarith,\nend\n\n\nlemma lt_sub_inv_nat {u : R} {n : \u2115} (h\u2082 : n \u2260 0)\n: u - (\u2191n)\u207b\u00b9 < 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\u2082)],\n  exact gt_zero_of_ne_zero_nat n h\u2082,\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) \u2227 (x*x < 2)} : set R) :=\nbegin\n  use (2 : R),\n  intros s hs,\n  cases hs with h\u2081 h\u2082, -- `h\u2081 : 0 < s`, `h\u2082 : s * s < 2`, \n  have h\u2084 : (2 : R) < 2 * 2, linarith,\n  have h\u2085 : s * s < 2*2,\n  { apply lt_trans h\u2082 h\u2084, },\n  have : s * s \u2264 2*2, from le_of_lt h\u2085,\n  have h\u2086 : 0 < (2 : R), linarith,\n  have h\u2087 : 0 \u2264 (2 : R), from le_of_lt h\u2086,\n  rwa \u2190square_le_square_iff_le_of_non_neg_of_non_neg _ _ (le_of_lt h\u2081) h\u2087,\nend \n\nlemma one_in_S : (1 : R) \u2208 {x : R | (0 < x) \u2227 (x*x < 2)} :=\n\u27e8by linarith, by linarith\u27e9\n\nlemma non_empty_S : ({x : R | (0 < x) \u2227 (x*x < 2)} : set R) \u2260 \u2205 :=\nbegin\n  have h : (1 : R) \u2208 {x : R | (0 < x) \u2227 (x*x < 2)}, from one_in_S,\n  intro h\u2082,\n  rw h\u2082 at h,\n  exact h,\nend\n\nlemma not_upper_bound_of_exists_nat {u : R} {S : set R} (h : \u2203 n : \u2115, n \u2260 0 \u2227 (u + (\u2191n)\u207b\u00b9 \u2208 S))\n: \u00ac(upper_bound u S) :=\nbegin\n  rcases h with \u27e8n, ne0, hn\u27e9,\n  unfold upper_bound,\n  push_neg,\n  use (u + (\u2191n)\u207b\u00b9),\n  apply and.intro hn,\n  suffices h : (0 : R) + u< (\u2191n)\u207b\u00b9 + u,\n  { rwa [zero_add, add_comm] at h,},\n  apply add_lt_add_iff_right_mpr,\n  have h\u2082 : (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 : \u2203 n : \u2115, n \u2260 0 \u2227 (upper_bound (u - (\u2191n)\u207b\u00b9) S))\n: \u00ac(\u2200 v : R, upper_bound v S \u2192 u \u2264 v) :=\nbegin\n  rcases h with \u27e8n, ne0, hn\u27e9,\n  push_neg,\n  use (u - (\u2191n)\u207b\u00b9),\n  exact and.intro hn (lt_sub_inv_nat ne0),\nend\n\ndef S : set R := {x : R | (0 < x) \u2227 (x*x < 2)}\n\nsection lemmas_for_ub_contra\n\nlemma pos_sub_inv_nat_of_pos {u : R} {n : \u2115} (k\u2084 : (0 : R) < u) (ne0 : n \u2260 0) (k\u2085 : 2 < u*u)\n: (0 : R) < u - (\u2191n)\u207b\u00b9 :=\nbegin\n  by_contra p, \n  have : u \u2264 (\u2191n)\u207b\u00b9, linarith,\n  have h\u2082 : (1 : R) \u2264 (\u2191n), from ge_one_of_non_zero n ne0,\n  have h\u2083 : (0 : R) < \u2191n, {rw \u2190pos_iff_gt_zero, exact pos_nat n ne0},\n  have h\u2084 : (\u2191n)\u207b\u00b9 \u2264 (1 : R)\u207b\u00b9, { rwa inv_le_inv h\u2083 zero_lt_one, },\n  have h\u2085 : u \u2264 (1 : R)\u207b\u00b9, linarith,\n  rw one_inv at h\u2085,\n  have : u * u \u2264 1 * 1, from mul_le_mul h\u2085 h\u2085 (le_of_lt k\u2084) zero_le_one,\n  linarith,\nend\n\nlemma sq_add_inv_ub {u : R} {k : \u2115} (h : k \u2260 0)\n: (u + (\u2191k)\u207b\u00b9)*(u + (\u2191k)\u207b\u00b9) \u2264 u*u + (2*u+1)*(\u2191k)\u207b\u00b9 :=\nbegin\n  rw [add_mul, add_mul, mul_add, mul_add, mul_comm (\u2191k)\u207b\u00b9 u, one_mul, add_assoc],\n  apply add_le_add (le_refl (u* u)),\n  rw [\u2190add_assoc, \u2190two_mul, \u2190mul_assoc],\n  apply add_le_add (le_refl _),\n  have h\u2082 : (k : R) \u2260 0, from coe_non_zero_of_non_zero h,\n  suffices h : (\u2191k)\u207b\u00b9 * (\u2191k)\u207b\u00b9 \u2264 (\u2191k)\u207b\u00b9 * (1 : R),\n  { rwa mul_one at h, },\n  have h\u2083 : (1 : R) \u2264 (\u2191k), from ge_one_of_non_zero k h,\n  have h\u2084 : (\u2191k)\u207b\u00b9 \u2264 (1 : R),\n  { rwa [\u2190one_inv, inv_le_inv (gt_zero_of_ne_zero_nat k h) (zero_lt_one : (0 : R) < 1)], },\n  have h\u2085 : (0 : R) < (\u2191k)\u207b\u00b9, from pos_inv_nat_of_non_zero h,\n  exact mul_le_mul (le_refl (\u2191k)\u207b\u00b9) h\u2084 (le_of_lt h\u2085) (le_of_lt h\u2085),\nend\n\nlemma inequ1 {u : R} (h\u2081 : 0 < u) (h\u2082 : u*u < 2) : (0 : R) < (2*u + 1)\u207b\u00b9 * (2 - u*u) :=\nbegin\n  have h\u2083 : 0 < 2 - u * u, linarith,\n  have h\u2084 : 0 < 2 * u + 1, from add_pos (by linarith) (by linarith),\n  have h\u2085 : 2*u+ 1 \u2260 0, linarith,\n  have h\u2086 : 0 < (2*u + 1)\u207b\u00b9, from (inv_pos h\u2085).mpr h\u2084,\n  exact mul_pos _ _ h\u2086 h\u2083,\nend\n\nlemma inequ2 {u : R} {n : \u2115} (h\u2081 : 0 < u) (h\u2082 : (\u2191n)\u207b\u00b9 < (2 * u + 1)\u207b\u00b9 * (2 - u * u))\n: u * u +  (2 * u + 1) * (\u2191n)\u207b\u00b9 < 2:=\nbegin\n  suffices h : ((2 : R)*u+1) * (\u2191n)\u207b\u00b9 < (2- u * u), linarith,\n  have h\u2084 : 0 < 2 * u + 1, from add_pos (by linarith) (by linarith),\n  have h\u2085 : 2*u+ 1 \u2260 0, linarith,\n  suffices h : (2 * u + 1) * (\u2191n)\u207b\u00b9 < (2 * u + 1) * ((2*u + 1)\u207b\u00b9 * (2 - u * u)),\n  { rwa [\u2190mul_assoc, mul_inv _ h\u2085, one_mul] at h, },\n  exact mul_lt_mul_left_mpr h\u2084 h\u2082,\nend\n\nlemma ub_contra {u : R} (k\u2083 : upper_bound u S) (k\u2084 : (0 : R) < u) (k\u2085 : u * u < 2) : u * u = 2 :=\nbegin\n  suffices h : \u00ac(upper_bound u S), from absurd k\u2083 h,\n  suffices h : \u2203 n : \u2115, (n \u2260 0) \u2227 u + (\u2191n)\u207b\u00b9 \u2208 S, from not_upper_bound_of_exists_nat h,\n  suffices h : \u2203 n : \u2115, (n \u2260 0) \u2227 ((u + (n : R)\u207b\u00b9) * (u + (\u2191n)\u207b\u00b9) < 2),\n  { rcases h with \u27e8n, ne0, hn\u27e9,\n    exact \u27e8n, ne0, pos_add_inv_nat_of_pos k\u2084 ne0, hn\u27e9, },\n  suffices h : \u2203 n : \u2115, n \u2260 0 \u2227 (u*u + ((2 : R)*u + 1)*(\u2191n)\u207b\u00b9) < 2,\n  { rcases h with \u27e8n, ne0, hn\u27e9,\n    exact \u27e8n, ne0, (lt_of_le_of_lt) (sq_add_inv_ub ne0) hn\u27e9, },\n  have k\u2086 : (0 : R) < (2*u + 1)\u207b\u00b9 * (2 - u*u) := inequ1 k\u2084 k\u2085,\n  rcases (inv_lt_of_pos _ k\u2086) with \u27e8n, ne0, h\u2082\u27e9,\n  exact \u27e8n, ne0, (inequ2 k\u2084 h\u2082)\u27e9,\nend\n\nend  lemmas_for_ub_contra\n\nsection lemmas_for_lub_contra\n\nlemma sq_sub_inv_ub {u : R} {k : \u2115} (h\u2081 : 0 < u) (h\u2082 : k \u2260 0)\n: (u - (\u2191k)\u207b\u00b9) * (u - (\u2191k)\u207b\u00b9) > u*u - 2*u*(\u2191k)\u207b\u00b9 :=\nbegin\n  repeat {rw sub_eq_add_neg},\n  rw [mul_add, add_mul, add_mul, mul_comm (-(\u2191k)\u207b\u00b9) u, add_assoc],\n  apply add_lt_add_of_le_of_lt(le_refl (u* u)),\n  rw [\u2190add_assoc, \u2190two_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\u2082) (pos_inv_nat_of_non_zero h\u2082),\nend\n\nlemma lub_contra_subproof1 {u : R} (k\u2084 : (0 : R) < u) (k\u2085 : 2 < u * u)\n(h : \u2203 n : \u2115, (n \u2260 0) \u2227 (2 < (u - (n : R)\u207b\u00b9) * (u - (\u2191n)\u207b\u00b9))) \n: \u2203 (n : \u2115), n \u2260 0 \u2227 upper_bound (u - (\u2191n)\u207b\u00b9) S :=\nbegin\n  rcases h with \u27e8n, ne0, hn\u27e9,\n  use n,\n  apply and.intro ne0,\n  intros x hx,\n  cases hx with xpos xsqlt2,\n  have h\u2083 : x * x < (u - (n : R)\u207b\u00b9) * (u - (\u2191n)\u207b\u00b9), 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\u2084 ne0 k\u2085)).mp h\u2083,\nend\n\nlemma inequ3 {u : R} {n : \u2115} (h\u2081 : 0 < u) (h\u2082 : (\u2191n)\u207b\u00b9 < (2*u)\u207b\u00b9 * (u*u - 2))\n: 2 < u * u - 2 * u * (\u2191n)\u207b\u00b9 :=\nbegin\n  suffices h : 2 * u * (\u2191n)\u207b\u00b9  < u * u - 2, linarith,\n  have h\u2084 : 0 < (2 * u), linarith,\n  have h\u2085 : 2 * u \u2260 0, linarith,\n  suffices h : (2 * u) * (\u2191n)\u207b\u00b9 < (2 * u) * ( (2*u)\u207b\u00b9 *(u*u -2)),\n  { rwa [\u2190mul_assoc, mul_inv _ h\u2085, one_mul] at h, },\n  exact mul_lt_mul_left_mpr h\u2084 h\u2082,\nend\n\nlemma inequ4 {u : R} (h\u2081 : 0 < u) (h\u2082 : 2 < u * u) : 0 < (2*u)\u207b\u00b9 * (u * u - 2):=\nbegin\n  have h\u2083 : 0 < u * u - 2, linarith,\n  have h\u2084 : 0 < 2 * u, linarith,\n  have h\u2085 : 2*u  \u2260 0, linarith,\n  have h\u2086 : 0 < (2*u)\u207b\u00b9, from (inv_pos h\u2085).mpr h\u2084,\n  exact mul_pos _ _ h\u2086 h\u2083,\nend\n\nlemma lub_contra {u : R} (k\u2083 : \u2200 v : R, upper_bound v S \u2192 u \u2264 v) (k\u2084 : (0 : R) < u)\n(k\u2085 : 2 < u * u)\n: u * u = 2 :=\nbegin\n  suffices h : \u00ac(\u2200 v : R, upper_bound v S \u2192 u \u2264 v), from absurd k\u2083 h,\n  suffices h : \u2203 n : \u2115, n \u2260 0 \u2227 (upper_bound (u - (\u2191n)\u207b\u00b9) S), from not_lub_of_exists_nat h,\n  suffices h : \u2203 n : \u2115, (n \u2260 0) \u2227 (2 < (u - (n : R)\u207b\u00b9) * (u - (\u2191n)\u207b\u00b9)),\n  from lub_contra_subproof1 k\u2084 k\u2085 h,\n  suffices h : \u2203 n : \u2115, n \u2260 0 \u2227 2  < u * u - 2 * u * (\u2191n)\u207b\u00b9,\n  { rcases h with \u27e8n, ne0, hn\u27e9,\n    exact \u27e8n, ne0, lt_trans hn (sq_sub_inv_ub k\u2084 ne0)\u27e9 },\n  suffices h : \u2203 n : \u2115, n \u2260 0 \u2227 (\u2191n)\u207b\u00b9 < (2*u)\u207b\u00b9 * (u*u - 2),\n  { rcases h with \u27e8n, ne0, hn\u27e9,\n    exact \u27e8n, ne0, inequ3 k\u2084 hn\u27e9, },\n  have k\u2086 : 0 < (2*u)\u207b\u00b9 * (u * u - 2):= inequ4 k\u2084 k\u2085,\n  exact inv_lt_of_pos _ k\u2086,\nend\n\nend lemmas_for_lub_contra\n\nlemma sqrt_two_exists : (sup S)*(sup S) = (2 : R) :=\nbegin\n  have k\u2082 : ({x : R | (0 < x) \u2227 (x*x < 2)} : set R) \u2260 \u2205, from non_empty_S,\n  have k\u2083 : is_sup (sup S) S, from  sup_is_sup has_upper_bound_S k\u2082,\n  have k\u2084 : \u21910 < sup S,\n  { suffices h : (1 : R) \u2264 sup S,\n    { change (0 : R) < sup S,\n      exact lt_of_lt_of_le zero_lt_one h, },\n    exact k\u2083.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\u2083.left k\u2084 ub.left, },\n  { exact sq_eq.right.left, },\n  { exact lub_contra k\u2083.right k\u2084 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 (\u03b1 : Type _)\n  | nil\n  | cons (hd : \u03b1) (tl : MyList \u03b1)\n\nnamespace MyList\n\nprotected def append : (_ _ : MyList \u03b1) \u2192 MyList \u03b1\n  | nil, ys => ys\n  | cons x xs, ys => cons x (MyList.append xs ys)\n\ninstance : Append (MyList \u03b1) :=\n  \u27e8MyList.append\u27e9\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 \u03b1 \u2192 Prop\n  | cons : NonEmpty (cons x xs)\n\n@[aesop 50%]\ntheorem nonEmpty_append\u2081 {xs : MyList \u03b1} ys :\n    NonEmpty xs \u2192 NonEmpty (xs ++ ys) := by\n  aesop\n\ntheorem nonEmpty_append\u2081' {xs : MyList \u03b1} ys :\n    NonEmpty xs \u2192 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 {\u03b1 : Type _} {xs : MyList \u03b1} ys zs :\n    NonEmpty xs \u2192 NonEmpty (xs ++ ys ++ zs) := by\n  aesop\n\ntheorem nil_not_nonEmpty (xs : MyList \u03b1) : xs = nil \u2192 \u00ac NonEmpty xs := by\n  aesop (add unsafe 10% cases MyList, norm simp Not)\n\n@[simp]\ntheorem append_nil {xs : MyList \u03b1} :\n    xs ++ nil = xs := by\n  induction xs <;> aesop\n\ntheorem append_assoc {xs ys zs : MyList \u03b1} :\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 `\u03a0\u2080 i, \u03b1 i` when `\u03b1` itself is locally\nfinite and calculates the cardinality of its finite intervals.\n-/\n\nopen dfinsupp finset\nopen_locale big_operators pointwise\n\nvariables {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*}\n\nnamespace finset\nvariables [decidable_eq \u03b9] [\u03a0 i, has_zero (\u03b1 i)] {s : finset \u03b9} {f : \u03a0\u2080 i, \u03b1 i}\n  {t : \u03a0 i, finset (\u03b1 i)}\n\n/-- Finitely supported product of finsets. -/\ndef dfinsupp (s : finset \u03b9) (t : \u03a0 i, finset (\u03b1 i)) : finset (\u03a0\u2080 i, \u03b1 i) :=\n(s.pi t).map \u27e8\u03bb f, dfinsupp.mk s $ \u03bb i, f i i.2, begin\n  refine (mk_injective _).comp (\u03bb f g h, _),\n  ext i hi,\n  convert congr_fun h \u27e8i, hi\u27e9,\n  end\u27e9\n\n@[simp] lemma card_dfinsupp (s : finset \u03b9) (t : \u03a0 i, finset (\u03b1 i)) :\n  (s.dfinsupp t).card = \u220f i in s, (t i).card :=\n(card_map _).trans $ card_pi _ _\n\nvariables [\u03a0 i, decidable_eq (\u03b1 i)]\n\nlemma mem_dfinsupp_iff : f \u2208 s.dfinsupp t \u2194 f.support \u2286 s \u2227 \u2200 i \u2208 s, f i \u2208 t i :=\nbegin\n  refine mem_map.trans \u27e8_, _\u27e9,\n  { rintro \u27e8f, hf, rfl\u27e9,\n    refine \u27e8support_mk_subset, \u03bb i hi, _\u27e9,\n    convert mem_pi.1 hf i hi,\n    exact mk_of_mem hi },\n  { refine \u03bb h, \u27e8\u03bb i _, f i, mem_pi.2 h.2, _\u27e9,\n    ext i,\n    dsimp,\n    exact ite_eq_left_iff.2 (\u03bb hi, (not_mem_support_iff.1 $ \u03bb H, hi $ h.1 H).symm) }\nend\n\n/-- When `t` is supported on `s`, `f \u2208 s.dfinsupp t` precisely means that `f` is pointwise in `t`.\n-/\n@[simp] lemma mem_dfinsupp_iff_of_support_subset {t : \u03a0\u2080 i, finset (\u03b1 i)} (ht : t.support \u2286 s) :\n  f \u2208 s.dfinsupp t \u2194 \u2200 i, f i \u2208 t i :=\nbegin\n  refine mem_dfinsupp_iff.trans (forall_and_distrib.symm.trans $ forall_congr $ \u03bb i, \u27e8\u03bb h, _,\n    \u03bb h, \u27e8\u03bb hi, ht $ mem_support_iff.2 $ \u03bb H, mem_support_iff.1 hi _, \u03bb _, h\u27e9\u27e9),\n  { by_cases hi : i \u2208 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 \u03b9] [\u03a0 i, decidable_eq (\u03b1 i)]\n\nsection bundled_singleton\nvariables [\u03a0 i, has_zero (\u03b1 i)] {f : \u03a0\u2080 i, \u03b1 i} {i : \u03b9} {a : \u03b1 i}\n\n/-- Pointwise `finset.singleton` bundled as a `dfinsupp`. -/\ndef singleton (f : \u03a0\u2080 i, \u03b1 i) : \u03a0\u2080 i, finset (\u03b1 i) :=\n\u27e6{ to_fun := \u03bb i, {f i},\n  pre_support := f.support.1,\n  zero := \u03bb i, (ne_or_eq (f i) 0).imp mem_support_iff.2 (congr_arg _) }\u27e7\n\nlemma mem_singleton_apply_iff : a \u2208 f.singleton i \u2194 a = f i := mem_singleton\n\nend bundled_singleton\n\nsection bundled_Icc\nvariables [\u03a0 i, has_zero (\u03b1 i)] [\u03a0 i, partial_order (\u03b1 i)] [\u03a0 i, locally_finite_order (\u03b1 i)]\n  {f g : \u03a0\u2080 i, \u03b1 i} {i : \u03b9} {a : \u03b1 i}\n\n/-- Pointwise `finset.Icc` bundled as a `dfinsupp`. -/\ndef range_Icc (f g : \u03a0\u2080 i, \u03b1 i) : \u03a0\u2080 i, finset (\u03b1 i) :=\n\u27e6{ to_fun := \u03bb i, Icc (f i) (g i),\n  pre_support := f.support.1 + g.support.1,\n  zero := \u03bb i, begin\n    refine or_iff_not_imp_left.2 (\u03bb 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 }\u27e7\n\n@[simp] lemma range_Icc_apply (f g : \u03a0\u2080 i, \u03b1 i) (i : \u03b9) : f.range_Icc g i = Icc (f i) (g i) := rfl\n\nlemma mem_range_Icc_apply_iff : a \u2208 f.range_Icc g i \u2194 f i \u2264 a \u2227 a \u2264 g i := mem_Icc\n\nlemma support_range_Icc_subset : (f.range_Icc g).support \u2286 f.support \u222a g.support :=\nbegin\n  refine \u03bb 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 [\u03a0 i, has_zero (\u03b1 i)]\n\n/-- Given a finitely supported function `f : \u03a0\u2080 i, finset (\u03b1 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 : \u03a0\u2080 i, finset (\u03b1 i)) : finset (\u03a0\u2080 i, \u03b1 i) := f.support.dfinsupp f\n\n@[simp] lemma mem_pi {f : \u03a0\u2080 i, finset (\u03b1 i)} {g : \u03a0\u2080 i, \u03b1 i} : g \u2208 f.pi \u2194 \u2200 i, g i \u2208 f i :=\nmem_dfinsupp_iff_of_support_subset $ subset.refl _\n\n@[simp] lemma card_pi (f : \u03a0\u2080 i, finset (\u03b1 i)) : f.pi.card = f.prod (\u03bb i, (f i).card) :=\nbegin\n  rw [pi, card_dfinsupp],\n  exact finset.prod_congr rfl (\u03bb i _, by simp only [pi.nat_apply, nat.cast_id]),\nend\n\nend pi\n\nsection locally_finite\nvariables [\u03a0 i, partial_order (\u03b1 i)] [\u03a0 i, has_zero (\u03b1 i)] [\u03a0 i, locally_finite_order (\u03b1 i)]\n\ninstance : locally_finite_order (\u03a0\u2080 i, \u03b1 i) :=\nlocally_finite_order.of_Icc (\u03a0\u2080 i, \u03b1 i)\n  (\u03bb f g, (f.support \u222a g.support).dfinsupp $ f.range_Icc g)\n  (\u03bb 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 : \u03a0\u2080 i, \u03b1 i)\n\nlemma card_Icc : (Icc f g).card = \u220f i in f.support \u222a g.support, (Icc (f i) (g i)).card :=\ncard_dfinsupp _ _\n\nlemma card_Ico : (Ico f g).card = \u220f i in f.support \u222a 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 = \u220f i in f.support \u222a 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\u2080 U V W: ftype}--[nonempty U\u2080]\n\n--def img (emb : U\u2080 \u21aa U) :=\n--  \u03bb (X : set U\u2080), 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\u2080 \u21aa U){E : set U} (hE : E = set.range emb) : E \u2243 U\u2080 :=   \nlet h : \u03a0 (y : E), (\u2203 x : U\u2080, emb x = y) := \n  by {rintros \u27e8y,hy\u27e9, rw [hE, set.mem_range] at hy, cases hy with x hx, from \u27e8x, by simp [hx]\u27e9},\n desc : \u03a0 (y : E), {x : U\u2080 // emb x = y} :=   \n  \u03bb y, classical.indefinite_description _ (h y) in \n{ \n  to_fun := \u03bb y, (desc y).val, \n  inv_fun := \u03bb x, \u27e8emb x, by {rw [hE, set.mem_range], from \u27e8x, rfl\u27e9} \u27e9, \n  left_inv := by {intros y, simp_rw (desc y).property, simp}, \n  right_inv := \u03bb x, by {cases emb with f h_inj, from h_inj (desc \u27e8f x,_\u27e9).property},\n}\n-/\n\ndef subset_embed (X : set U) : X \u21aa U := \n{ to_fun := \u03bb x, x.val, \n  inj' := \u03bb x y hxy, subtype.ext hxy}\n\ndef subset_to_subtype {X Y : set U} (hXY : X \u2286 Y) : set Y := \n  \u03bb y, y.val \u2208 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 \u2286 R} \u2243 set (\u27e8R\u27e9 : ftype) :=\n{ to_fun := \u03bb X, {y | y.val \u2208 X.val},\n  inv_fun := \u03bb Y, \u27e8coe '' Y,by {intros y hy, cases hy with x hx, rw \u2190hx.2, exact x.2,} \u27e9,\n  left_inv := begin\n    intro X, ext x, simp only [set.mem_image, subtype.coe_mk],\n    refine \u27e8\u03bb h, _, \u03bb h, \u27e8\u27e8x,_\u27e9,\u27e8_,_\u27e9\u27e9\u27e9, \n    { rcases h with \u27e8x',h\u2081,h\u2082\u27e9, rw \u2190h\u2082, convert h\u2081,}, \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 \u27e8\u03bb h, _, \u03bb h, _\u27e9, \n    {unfold_projs at h, rcases h with \u27e8a,h1,h2\u27e9, simp_rw \u2190h2, convert h1, simp},\n    exact \u27e8\u27e8x,xp\u27e9, \u27e8h,by simp\u27e9\u27e9,   \n  end, }\n\n\n\n\n/-- bundled isomorphism between two matroids -/\nstructure isom (M : matroid U) (N : matroid V) := \n  (bij: U \u2243 V)\n  (rank_preserving : M.r =  N.r \u2218 (set.image bij))\n\ninstance coe_iso_to_fun {M : matroid U} {N : matroid V} : has_coe_to_fun (isom M N) := \n{F := \u03bb (i : isom M N), (U \u2192 V), coe := \u03bb 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\u2081 : isom M N) (i\u2082 : isom N O) : isom M O := \n{\n  bij := equiv.trans i\u2081.bij i\u2082.bij, \n  rank_preserving := \n  begin\n    ext X, rw [i\u2081.rank_preserving, i\u2082.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 \u27e8\u03bb h, \u27e8iso.bij x,\u27e8_,_\u27e9\u27e9,\u03bb h, _\u27e9, \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 \u27e8y,h1,h2\u27e9, rw set.mem_image at h1, rcases h1 with \u27e8x', \u27e8hx'1, hx'2\u27e9\u27e9, rw [\u2190h2,\u2190hx'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\u2080 : ftype}\n  (mat : matroid U\u2080)\n  (emb : U\u2080 \u21aa U)\n\nnamespace emb_mat \n\ndef groundset (N : emb_mat U) : set U := \n  set.range N.emb \n\ndef strongly_iso (N\u2081 N\u2082 : emb_mat U) : Prop := \n  (\u2203 (\u03c6 : isom (N\u2081.mat) (N\u2082.mat)), \u2200 x, N\u2081.emb x = N\u2082.emb (\u03c6 x)) \n\nlemma strong_iso_equiv : \n  equivalence (\u03bb (N\u2081 N\u2082 : emb_mat U), strongly_iso N\u2081 N\u2082) := \nbegin\n  refine \u27e8\u03bb N, _, \u03bb N\u2081 N\u2082 hab, _, \u03bb N\u2081 N\u2082 N\u2083 hab hbc, _\u27e9, \n    {refine \u27e8\u27e8equiv.refl _,_\u27e9,\u03bb X, _\u27e9, \n      {ext X, simp,},\n      {apply congr_arg, unfold_coes, simp} },\n    {cases hab with \u03c6, refine \u27e8inv \u03c6, \u03bb X, _\u27e9, rw [hab_h ((inv \u03c6) X), inv], unfold_coes, simp},\n  cases hab with i\u2081 h\u2081, cases hbc with i\u2082 h\u2082, \n  from \u27e8compose i\u2081 i\u2082, \u03bb X, by {unfold_coes at *, simp [h\u2081,h\u2082,congr_arg, compose]}\u27e9,  \nend\n\nlemma strong_iso_same_groundset (N N' : emb_mat U) :\n  strongly_iso N N' \u2192 N.groundset = N'.groundset  := \nbegin\n  rintros \u27e8h\u2081,h\u2082\u27e9, ext, \n  simp only [groundset, set.mem_range],\n  simp_rw h\u2082, \n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9, \n    {cases h with y hy, from \u27e8_, hy\u27e9},\n  cases h with y hy, use h\u2081.bij.inv_fun y, unfold_coes, simp [hy],\nend \n\n--def pullback_r (N : emb_mat U) : set (N.ground) \u2192 \u2124 := \n--  \u03bb 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 \u2192 \u2124 := \n  \u03bb X, N.mat.r ({x : N.U\u2080 | N.emb x \u2208 X })\n\nlemma pullback_r_eq (N : emb_mat U) (X : set N.U\u2080) : \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 \u27e8\u03bb h, _, \u03bb h, _\u27e9, \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 \u2286 N.ground) (some 0 : option \u2124) (none : option \u2124) \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' \u2192 N.pullback_r = N'.pullback_r :=\nbegin\n  rintros \u27e8\u27e8\u03c6,h\u03c6\u2081\u27e9, h\u03c6\u2082\u27e9, ext X, \n  unfold pullback_r, rw h\u03c6\u2081, \n  dsimp, congr', ext x', \n  simp only [set.mem_image, set.mem_set_of_eq], \n  simp_rw h\u03c6\u2082, \n  refine \u27e8\u03bb h, _, \u03bb h, \u27e8\u03c6.inv_fun x',\u27e8_,by simp\u27e9\u27e9\u27e9, \n    {rcases h with \u27e8x, \u27e8hx\u2081,hx\u2082\u27e9\u27e9, rw \u2190hx\u2082, from hx\u2081,},\n  rw \u2190h\u03c6\u2082, \n  convert h,  \n  rw h\u03c6\u2082, \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\u2080 -/\ndef groundset_equiv (N : emb_mat U){E : set U} (hE : N.groundset = E) : \n  N.U\u2080 \u2243 (\u27e8E\u27e9 : 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 \u2192 \u2124 := \n\n\n\ninstance strong_iso_setoid (U : ftype) : setoid (emb_mat U) := \u27e8strongly_iso, strong_iso_equiv\u27e9 \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 (\u03bb (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 \u2192 set U := quotient.lift  \n  (\u03bb (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 := \u27e8N.groundset\u27e9\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 \u2192 (set U \u2192 \u2124) := quotient.lift \n  (\u03bb (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 \u2192 \u2124) := \n  \u03bb X, N.r ((\u03bb x : N.ground, x.val)'' X )\n\n/-- an equivalence class representative for N -/\ndef rep_spec (N : matroid_in U) : {N\u2080 : emb_mat U // \u27e6N\u2080\u27e7 = 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\u2080 : emb_mat U} (h : \u27e6N\u2080\u27e7 = N) : \n   N\u2080.groundset = N.groundset  := \nby {dsimp only [quotient.mk] at h, rw \u2190h, refl}\n\n\nlemma r_eq_r_inter_groundset (N : matroid_in U) (X : set U) : \n  N.r X = N.r (X \u2229 N.groundset) := \nbegin\n  unfold matroid_in.groundset r emb_mat.pullback_r emb_mat.groundset, \n  rcases rep_spec N with \u27e8N\u2080,h\u27e9,\n  simp [\u2190h],\nend\n\nsection preimages \n\nvariables {N : matroid_in U} {N\u2080 : emb_mat U}\n\n/-- given an equivalence class representative N\u2080, pulls a set X back to the \nftype on which N\u2080 is defined -/\ndef rep_preimage (hN : \u27e6N\u2080\u27e7 = N) (X : set N.ground) :=\n  N\u2080.groundset_equiv (ground_rep hN) \u207b\u00b9' X\n\nlemma rep_preimage_on_size (hN : \u27e6N\u2080\u27e7 = 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 : \u27e6N\u2080\u27e7 = N){X Y : set N.ground} :\n  X \u2286 Y \u2192 rep_preimage hN X \u2286 rep_preimage hN Y := \n\u03bb h, set.preimage_mono h\n\n\nlemma r_rep (hN : \u27e6N\u2080\u27e7 = N) (X : set N.ground) :\n  r_ftype N X = N\u2080.mat.r (rep_preimage hN X) :=\nbegin\n  unfold r_ftype r, \n  simp_rw \u2190hN, \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 \u27e8\u03bb h, _, \u03bb h, _\u27e9, \n  { rcases h with \u27e8y,h,h'\u27e9, simp_rw \u2190h', convert h, simp,},\n  use N\u2080.emb x,\n  { unfold matroid_in.groundset, rw \u2190hN, simp only [quotient.lift_mk], unfold emb_mat.groundset, simp,},\n  exact \u27e8h, by simp\u27e9, \nend \n\nend preimages \n\ndef as_matroid (N : matroid_in U) : matroid N.ground := \n{ \n  r := N.r_ftype,\n  R0 := \u03bb X, let \u27e8N\u2080,h\u27e9 := rep_spec N in by \n  {rw r_rep h X, apply N\u2080.mat.R0, },\n  R1 := \u03bb X, let \u27e8N\u2080,h\u27e9 := rep_spec N in by \n  {rw [r_rep h X, \u2190rep_preimage_on_size h], apply N\u2080.mat.R1,},\n  R2 := \u03bb X Y hXY, let \u27e8N\u2080,h\u27e9 := rep_spec N in by \n  {repeat {rw r_rep h}, apply N\u2080.mat.R2, exact (rep_preimage_on_subset _ hXY),} ,\n  R3 := \u03bb X Y, let \u27e8N\u2080,h\u27e9 := rep_spec N in by \n  {repeat {rw r_rep h}, apply N\u2080.mat.R3,  } \n}\n\nlemma as_matroid_r_eq (N : matroid_in U) : \n  \u2200 X, N.r X = N.as_matroid.r (subset_equiv \u27e8X \u2229 N.groundset, by tidy\u27e9) :=\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 \u27e8\u03bb h, \u27e8\u27e8x,h.2\u27e9,\u27e8\u27e8h.1,h.2\u27e9,by simp\u27e9\u27e9, \u03bb h, _\u27e9,\n  rcases h with \u27e8x',\u27e8h,rfl\u27e9\u27e9, \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 = \u27e6{mat := M.as_matroid, emb := function.embedding.subtype _ }\u27e7 := \nbegin\n  rcases M.rep_spec with \u27e8M\u2080,h\u27e9, rw \u2190h, 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 \u27e8\u27e8_,_\u27e9,\u03bb x, _\u27e9, \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 \u27e8\u03bb h, \u27e8x,h, by simp\u27e9, \u03bb h, _\u27e9, \n    rcases h with \u27e8a,ha,h\u27e9, simp at h, \n    rw \u2190M\u2080.emb.inj' h, exact ha, \n  end,\n  refl, \nend\n\n/- lemma as_matroid_r_eq_subset (N : matroid_in U) :\n  \u2200 X : {X : set U // X \u2286 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\u2080 : emb_mat U) : \n\ndef as_matroid_in (M : matroid U) : matroid_in U := \n  \u27e6{U\u2080 := U, emb := function.embedding.refl U, mat := M}\u27e7\n\n\n\n\ninstance coe_to_matroid_in : has_coe (matroid U) (matroid_in U) := \u27e8\u03bb M, as_matroid_in M\u27e9\n\ndef embed (M : matroid_in U) : M.ground \u21aa U := subset_embed M.groundset \n\ndef subset_embed {M : matroid_in U} {R : set U} (hR : R \u2286 M.groundset) : R \u21aa M.ground :=\n{to_fun  := \u03bb x, \u27e8x.val, by {cases x, tauto}\u27e9,\n inj'    := \u03bb 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 \u2286 M.groundset) : M'.ground \u21aa M'.ground :=\n{to_fun  := \u03bb x, \u27e8x.val, by simp\u27e9,\n inj'    := \u03bb 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 \u2192 M.r = M'.r \u2192 M = M' :=\nbegin\n  intros h h', \n  rw [as_matroid_is_rep M, as_matroid_is_rep M', quotient.sound],  \n  refine \u27e8\u27e8_,_\u27e9,\u03bb x, _\u27e9, \n  {exact {to_fun := \u03bb x, \u27e8x.val, by {rw \u2190h, exact x.property,}\u27e9 , \n          inv_fun := \u03bb x, \u27e8x.val, by {rw h, exact x.property,}\u27e9, \n          left_inv := \u03bb x, by {dsimp only, simp,}, \n          right_inv := \u03bb 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 \u27e8\u03bb hx,_, \u03bb hx, _\u27e9, \n    { rcases hx with \u27e8y,h\u2081,rfl\u27e9, exact \u27e8y,h\u2081, by simp\u27e9,  },\n    rcases hx with \u27e8\u27e8y, hy\u27e9, hy', rfl\u27e9, refine \u27e8\u27e8y,hy\u27e9,\u27e8hy',_\u27e9\u27e9, simp, \n  end,\n  refl, \nend\n\n\n\ndef from_matroid_on_subtype {E : set U} (M : matroid \u27e8E\u27e9) :  matroid_in U := \n\u27e6{mat := M, emb := function.embedding.subtype _}\u27e7\n\nlemma groundset_correct {E : set U} (M : matroid \u27e8E\u27e9) : \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 \u27e8E\u27e9) (X : set U) : \n  (from_matroid_on_subtype M).r X = M.r ((\u03bb x, x.val) '' X) \u2229 {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 \u2286 M.groundset) \u2227 \n  \u2203 C \u2286 M.groundset \\ N.groundset, (\u2200 X \u2286 N.groundset, N.r X = M.r (X \u222a 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\u2080) (M : matroid U) := \n  \u2203 emb : U\u2080 \u21aa U, is_minor_of \u27e6(\u27e8N,emb\u27e9:emb_mat U)\u27e7 M  \n\nlemma minor_trans: transitive (\u03bb (M\u2081 M\u2082 : matroid_in U), is_minor M\u2081 M\u2082) :=\nbegin\n  rintros M\u2081 M\u2082 M\u2083 \u27e8h1,\u27e8C\u2081,hC\u2081,h1'\u27e9\u27e9 \u27e8h2,\u27e8C\u2082,hC\u2082,h2'\u27e9\u27e9, \n  refine \u27e8subset.trans h1 h2,\u27e8C\u2081 \u222a C\u2082,\u27e8_,\u03bb X hX, _\u27e9\u27e9\u27e9, \n  ----\n  { convert set.union_subset_union hC\u2081 hC\u2082, 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\u2081M\u2082: C\u2081 \u2286 M\u2082.groundset := by \n  { intros x hx, simp only [ftype.diff_eq, set.subset_inter_iff] at hC\u2081, tauto,},\n  rw [h1' X hX, h2' (X \u222a C\u2081) _, h2' C\u2081 hC\u2081M\u2082, \u2190union_assoc],  ring,\n  exact union_of_subsets (subset.trans hX h1) hC\u2081M\u2082, \nend\n\n def contract_to_matroid (M : matroid_in U) (C : set U) : matroid \u27e8(M.groundset \\ C : set U)\u27e9 :=\nlet mtype : ftype := \u27e8(M.groundset \\ C : set U)\u27e9, \n\u03c6 : mtype \u2192 U := \u03bb x, x.val  in  \n{ r := \u03bb X, M.r (\u03c6 '' X \u222a 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 \u27e8(M.groundset \\ D : set U)\u27e9  := \nlet mtype : ftype := \u27e8(M.groundset \\ D : set U)\u27e9, \n\u03c6 : mtype \u2192 U := \u03bb x, x.val  in  \n{ r := \u03bb X, M.r (\u03c6 '' 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 \u2229 D = \u2205) (hu : C \u222a D \u2286 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\u2080 := \u27e8(C\u1d9c : set M.ground)\u27e9,\n  mat := sorry,\n  emb := (function.embedding.subtype (\u03bb x, x \u2208 C\u1d9c)).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  --\u2203 C, C \u2229 N.ground = \u2205 \u2227 \u2200 X : set U\u2080, N.mat.r \n\n\n--def is_minor {U : ftype} (N : emb_mat U) (M : matroid U) := \n--  \u2203 C : set U, C \u2229 N.ground = \u2205 \u2227 \u2200 \n\n/-structure emb_minor' (M : matroid U) :=\n  {U\u2080 : ftype}\n  (mat : matroid U\u2080)\n  (emb : U\u2080 \u21aa U)\n  (C : set U)\n  (C_disj : C \u2229 set.range emb = \u2205)\n  (minor_rank : mat.r = \u03bb X, M.r (emb '' X \u222a 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 \u222a N.C)\u1d9c\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 \u2229 N.ground = \u2205 := \nby {rw ground, from N.C_disj,}\n\nlemma D_ground_inter_empty (N : emb_minor M) : \n  N.D \u2229 N.ground = \u2205 := \nby {rw [D], have := C_ground_inter_empty N, set_solver,}\n\nlemma C_D_inter_empty (N : emb_minor M) : \n  N.C \u2229 N.D = \u2205 := \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 \u222a N.D) = N.ground\u1d9c := \nby {rw [D], have := N.C_ground_inter_empty, set_solver,}\n\nlemma emb_minor_r (N : emb_minor M) (X : set N.U\u2080) : \n  N.mat.r X = M.r (N.emb '' X \u222a 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) \u2192 \u2124 := \n  \u03bb 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\u2081 N\u2082 : emb_minor M) : Prop := \n  (\u2203 (\u03c6 : isom (N\u2081.mat) (N\u2082.mat)), \u2200 x, N\u2081.emb x = N\u2082.emb (\u03c6 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 (\u03bb (N\u2081 N\u2082 : emb_minor M), strongly_iso N\u2081 N\u2082) := \nbegin\n  refine \u27e8\u03bb N, _, \u03bb N\u2081 N\u2082 hab, _, \u03bb N\u2081 N\u2082 N\u2083 hab hbc, _\u27e9, \n    {refine \u27e8\u27e8equiv.refl _,_\u27e9,\u03bb X, _\u27e9, \n      {simp [equiv.img], },\n      {apply congr_arg, unfold_coes, simp} },\n    {cases hab with \u03c6, refine \u27e8inv \u03c6, \u03bb X, _\u27e9, rw [hab_h ((inv \u03c6) X), inv], unfold_coes, simp},\n  cases hab with i\u2081 h\u2081, cases hbc with i\u2082 h\u2082, \n  from \u27e8compose i\u2081 i\u2082, \u03bb X, by {unfold_coes at *, simp [h\u2081,h\u2082,congr_arg, compose]}\u27e9,  \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' \u2192 N.ground = N'.ground  := \nbegin\n  rintros \u27e8h\u2081,h\u2082\u27e9, ext, \n  simp only [ground, set.mem_range],\n  simp_rw h\u2082, \n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9, \n    {cases h with y hy, from \u27e8_, hy\u27e9},\n  cases h with y hy, use h\u2081.bij.inv_fun y, unfold_coes, simp [hy],\nend \n\n\ninstance strong_iso_setoid : setoid (emb_minor M) := \u27e8strongly_iso, strong_iso_equiv\u27e9 \n\n\nend emb_minor\n\n\n--variables {M : matroid U} [setoid (emb_minor_of M)]\ndef minor (M : matroid U) := quot (\u03bb (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 \u2192 set U := quotient.lift  \n  (\u03bb (N : emb_minor M), N.ground )\n  (\u03bb 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": "/-\nCS 2120 HOMEWORK #3\nOUT: SUN, SEP 25\nDUE: MON, OCT 3\n\nPURPOSE: The purpose of this homework is to help you understand\nthe material covered up to now on first- and higher-order predicate\nlogic. There are four questions. Each samples your understanding of\nmultiple concepts. You might have to put different ideas from our\nwork together to fully answer the questions. Give yourself time to\nthink about this material. \n\nINSTRUCTIONS: Read and follow the instructions for each question,\nbelow. Edit all of your answers into this file. That's what you'll\nturn in.\n\nCOLLABORATION: You may communicate with each other in general terms\nabout the material we've covered but you are NOT to give or receive\nspecific answers, or hints strong enough to essentially give away any \nanswers, on this homework. Please, do yourselves and your colleagues\na favor and don't tell or take answers. This homework is a key check\non, via preparation for, an upcoming midterm exam.  \n\nNEED HELP: Please don't post answers or partial answers on Piazza or \nany other forum that would substantially give away any part of the \nanswer to any of these questions. That said, freely post any questions\nyou might have, and feel free to offer general answers to questions \nfrom others, on Piazza. TAs answer at least several times a day. \nAttend office hours: Wednesday and Sunday night 7-10. Talk to Sullivan. \nIf you feel deeply lost, email Prof. Sullivan ASAP to for help on how\nbest to proceed. \n-/\n\n/- #1: Logic to English \n\nRead through the new material in 09_20_22_inference_rules.lean, which\nstarts on line 264. After reviewing our all balls blue example, it then\npresents an English-language rendition of our \"demonstration\" that if \nall balls are blue and if b1 and b2 are balls then b1 is blue and b2 \nis blue. Compare the English language proof with the formal version, \npaying attention to how we named and specified the proof that all balls\nare blue. \n\nContinue reading through our formalized version of the story that \neveryone is mortal and so is Socrates so Socrates is mortal. Now \nwrite an English-language version of the proof, using the model from \nthe earlier case of \"all balls blue.\" Don't just do it mindlessly: \nreally think about what you're saying with each word in your proof. \nSee how the English presents the \"story\" of the formal proof in more\nnatural, human, terms.\n\nANSWER HERE: \n\nHere's the formal proof:\n-/\n\nvariable Person : Type\nvariable Socrates : Person\nvariable isMortal : Person \u2192 Prop\nvariable everyoneIsMortal : \u2200 (p : Person), isMortal p\n#check (everyoneIsMortal Socrates)   -- \u2200 elimination!\n\n/-\nSuppose that Socrates is a person and that isMortal is\na predicate taking a person, p, as an argument and\nyielding a proposition, (Mortal p), that we interpret\nas meaning that P is mortal. Next assume that everyone\nis mortal. Our goal is to prove that Socrates is mortal.\nBut this follows simplying by applying the universal\ngeneralization, that everyone is mortal, to the specific\nperson, Socrates, to conclude that Socrates is mortal.  \n\nKS: Review arrow and \u2200 elimination.\n-/\n\n-- \u2200 elimination example\nexample : \n  \u2200 \n    (P : Type) \n    (S : P \u2192 Prop) \n    (ug : \u2200 (p : P), S p)\n    (p : P), \n  S p :=\nbegin\nassume P S ug p,  -- assume we're given arguments\nexact (ug p),     -- universal elimination proves (S p)\nend \n\n-- \u2192 elimination example\nexample :\n  \u2200 \n    (P Q : Prop)\n    (i : P \u2192 Q)\n    (p : P),\n  Q :=\nbegin \n  assume P Q i p, -- assume we're given arguments\n  exact (i p),    -- arrow elimination proves Q\nend \n\n\n/- #2: English to Logic \nFormally model this natural-language \"logic story\" in Lean, using\nthe material we covered in the lecture notes as a model. Here's the\nstory.\n\nIf one person likes a second, and the second likes a third, \nthen the first is jealous of the third. Hint: model \"likes\" and \n\"isJealousOf\" as two two-place predicates.\n\nNow suppose Ed, Hannah, and Mel are people, and that Ed likes \nHannah, and Hannah likes Mel. Write, and use #check to check, an\nexpression that proves that Ed is jealous of Mel. Uncomment the\nfollowing block of expressions then fill in blanks to complete\nthis task.\n-/\n\n-- variable Person : Type                      -- already defined\nvariable Likes : Person \u2192 Person \u2192 Prop        -- a predicate with two Person arguments\nvariable Jealous : Person \u2192 Person \u2192 Prop      -- same thing here  \nvariable Triangle :                            -- note definition extends to next line\n  \u2200 (p1 p2 p3 : Person), Likes p1 p2 \u2192 Likes p2 p3 \u2192 Jealous p1 p3  \nvariables ed hannah mel : Person\nvariable likes_ed_hannah : Likes ed hannah\nvariable likes_hannah_mel : Likes hannah mel\n-- Finally write and use #check to check an expression that proves that ed is \n-- jealous of mel.\n-- TO ANSWER WRITE YOUR EXPRESSION IN PLACE OF THE _ THAT COMES NEXT. \n\n#check Triangle             -- we'll work out the rest in class review\n\n\n/- #3: Proofing a propositions involving \u2200 and \u2228\n\nWrite an English-language  proof of the following proposition, using\nthe methods of inference we've covered. \u2200 (P Q : Prop), P \u2227 Q \u2192 Q \u2228 P. \nDo read that proposition carefully, please.\n\nPROOF: LET P AND Q BE ARBITRARY BUT SPECIFIC PROPOSITIONS. TO PROVE\nP \u2227 Q \u2192 Q \u2228 P, ASSUME P \u2227 Q AS A HYPOTHESIS. BY AND ELIMINATION WE  \nDEDUCE P AND Q. WE NOW PROVE Q \u2228 P BY OR INTRODUCTION ON EITHER SIDE.\nNote that there are two ways to prove the result! We treat any proof\nas equally as good as any other.\n-/\n\n\n/- \nExpress the following proposition formally. Introduce whatever types, values, \npredicates, etc., you need as in the several examples in the classwork. If you\nhave already defined a term above, don't repeat it here. Here's the claim you\nare to formalize: Everyone knows someone who knows someone who knows everyone.\n-/\n\n-- variable Person : Type                 -- defined above\nvariable Knows : Person \u2192 Person \u2192 Prop\ndef foo : Prop := \n    \u2200 (P : Person), \n      (\u2203 (Q : Person), \n        (Knows P Q \u2227 \n          \u2203 (R : Person), \n            (Knows Q R \u2227 \n              (\u2200 (T : Person), \n                Knows R T\n              )\n            )\n        )\n      )", "meta": {"author": "kevinsullivan", "repo": "cs2120f22", "sha": "8710cf4262e905ffe2b1dee165473ee1f940440b", "save_path": "github-repos/lean/kevinsullivan-cs2120f22", "path": "github-repos/lean/kevinsullivan-cs2120f22/cs2120f22-8710cf4262e905ffe2b1dee165473ee1f940440b/src/homeworks/hw3/hw3_key.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5467381519846138, "lm_q2_score": 0.8774767986961403, "lm_q1q2_score": 0.47975004332850274}}
{"text": "/-\nCopyright (c) 2022 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Asta H. From, Jannis Limperg\n-/\n\nimport Aesop\n\nset_option aesop.check.all true\n\nattribute [-simp] List.all_cons List.all_nil List.all_eq_true\n\ntheorem all_cons (P : \u03b1 \u2192 Bool) (x : \u03b1) (xs : List \u03b1) (h : (x :: xs).all P)\n  : P x \u2227 xs.all P := by\n  aesop\n", "meta": {"author": "JLimperg", "repo": "aesop", "sha": "c68fb1d5a9172498230d81d95c61f6461bea6722", "save_path": "github-repos/lean/JLimperg-aesop", "path": "github-repos/lean/JLimperg-aesop/aesop-c68fb1d5a9172498230d81d95c61f6461bea6722/tests/golden/26.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6959583376458152, "lm_q2_score": 0.6893056295505783, "lm_q1q2_score": 0.47972800007192257}}
{"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 `\u03b1 \u2192 Part \u03b2`.\n\n## Definitions\n\n* `PFun \u03b1 \u03b2`: Type of partial functions from `\u03b1` to `\u03b2`. Defined as `\u03b1 \u2192 Part \u03b2` and denoted\n  `\u03b1 \u2192. \u03b2`.\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 `\u03b1 \u2192 \u03b2`, which is a type (`\u03b1` 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 \u2192 Option \u03b2`.\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 : \u03b1 \u2192. \u03b2 \u2295 \u03b1`.\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 \u2192. \u03b2`as a `Set (\u03b1 \u00d7 \u03b2)`.\n* `PFun.graph'`: Graph of a partial function `a \u2192. \u03b2`as a `Rel \u03b1 \u03b2`.\n\n### `PFun \u03b1` 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 \u03b1 \u03b2`, or `\u03b1 \u2192. \u03b2`, is the type of partial functions from\n  `\u03b1` to `\u03b2`. It is defined as `\u03b1 \u2192 part \u03b2`. -/\ndef PFun (\u03b1 \u03b2 : Type _) :=\n  \u03b1 \u2192 Part \u03b2\n#align pfun PFun\n\n-- mathport name: \u00abexpr \u2192. \u00bb\n/-- `\u03b1  \u2192. \u03b2` is notation for the type `PFun \u03b1 \u03b2` of partial functions from `\u03b1` to `\u03b2`.  -/\ninfixr:25 \" \u2192. \" => PFun\n\nnamespace PFun\n\nvariable {\u03b1 \u03b2 \u03b3 \u03b4 \u03b5 \u03b9 : Type _}\n\ninstance : Inhabited (\u03b1 \u2192. \u03b2) :=\n  \u27e8fun _ => Part.none\u27e9\n\n/-- The domain of a partial function -/\ndef Dom (f : \u03b1 \u2192. \u03b2) : Set \u03b1 :=\n  { a | (f a).Dom }\n#align pfun.dom PFun.Dom\n\n@[simp]\ntheorem mem_dom (f : \u03b1 \u2192. \u03b2) (x : \u03b1) : x \u2208 Dom f \u2194 \u2203 y, y \u2208 f x := by simp [Dom, Part.dom_iff_mem]\n#align pfun.mem_dom PFun.mem_dom\n\n@[simp]\ntheorem dom_mk (p : \u03b1 \u2192 Prop) (f : \u2200 a, p a \u2192 \u03b2) : (PFun.Dom fun x => \u27e8p x, f x\u27e9) = { x | p x } :=\n  rfl\n#align pfun.dom_mk PFun.dom_mk\n\ntheorem dom_eq (f : \u03b1 \u2192. \u03b2) : Dom f = { x | \u2203 y, y \u2208 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 : \u03b1 \u2192. \u03b2) (a : \u03b1) : Dom f a \u2192 \u03b2 :=\n  (f a).get\n#align pfun.fn PFun.fn\n\n@[simp]\ntheorem fn_apply (f : \u03b1 \u2192. \u03b2) (a : \u03b1) : 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 : \u03b1 \u2192. \u03b2) [D : DecidablePred (\u00b7 \u2208 Dom f)] (x : \u03b1) : Option \u03b2 :=\n  @Part.toOption _ _ (D x)\n#align pfun.eval_opt PFun.evalOpt\n\n/-- Partial function extensionality -/\ntheorem ext' {f g : \u03b1 \u2192. \u03b2} (H1 : \u2200 a, a \u2208 Dom f \u2194 a \u2208 Dom g) (H2 : \u2200 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 : \u03b1 \u2192. \u03b2} (H : \u2200 a b, b \u2208 f a \u2194 b \u2208 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 : \u03b1 \u2192. \u03b2) (s : f.Dom) : \u03b2 :=\n  f.fn s s.2\n#align pfun.as_subtype PFun.asSubtype\n\n/-- The type of partial functions `\u03b1 \u2192. \u03b2` is equivalent to\nthe type of pairs `(p : \u03b1 \u2192 Prop, f : subtype p \u2192 \u03b2)`. -/\ndef equivSubtype : (\u03b1 \u2192. \u03b2) \u2243 \u03a3p : \u03b1 \u2192 Prop, Subtype p \u2192 \u03b2 :=\n  \u27e8fun f => \u27e8fun a => (f a).Dom, asSubtype f\u27e9, fun f x => \u27e8f.1 x, fun h => f.2 \u27e8x, h\u27e9\u27e9, fun f =>\n    funext fun a => Part.eta _, fun \u27e8p, f\u27e9 => by dsimp ; congr \u27e9\n#align pfun.equiv_subtype PFun.equivSubtype\n\ntheorem asSubtype_eq_of_mem {f : \u03b1 \u2192. \u03b2} {x : \u03b1} {y : \u03b2} (fxy : y \u2208 f x) (domx : x \u2208 f.Dom) :\n    f.asSubtype \u27e8x, domx\u27e9 = 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 : \u03b1 \u2192 \u03b2) : \u03b1 \u2192. \u03b2 := fun a => Part.some (f a)\n#align pfun.lift PFun.lift\n\ninstance : Coe (\u03b1 \u2192 \u03b2) (\u03b1 \u2192. \u03b2) :=\n  \u27e8PFun.lift\u27e9\n\n@[simp]\ntheorem coe_val (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : (f : \u03b1 \u2192. \u03b2) a = Part.some (f a) :=\n  rfl\n#align pfun.coe_val PFun.coe_val\n\n@[simp]\ntheorem dom_coe (f : \u03b1 \u2192 \u03b2) : (f : \u03b1 \u2192. \u03b2).Dom = Set.univ :=\n  rfl\n#align pfun.dom_coe PFun.dom_coe\n\ntheorem lift_injective : Injective (PFun.lift : (\u03b1 \u2192 \u03b2) \u2192 \u03b1 \u2192. \u03b2) := 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 : \u03b1 \u2192. \u03b2) : Set (\u03b1 \u00d7 \u03b2) :=\n  { p | p.2 \u2208 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 : \u03b1 \u2192. \u03b2) : Rel \u03b1 \u03b2 := fun x y => y \u2208 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 : \u03b1 \u2192. \u03b2) : Set \u03b2 :=\n  { b | \u2203 a, b \u2208 f a }\n#align pfun.ran PFun.ran\n\n/-- Restrict a partial function to a smaller domain. -/\ndef restrict (f : \u03b1 \u2192. \u03b2) {p : Set \u03b1} (H : p \u2286 f.Dom) : \u03b1 \u2192. \u03b2 := fun x =>\n  (f x).restrict (x \u2208 p) (@H x)\n#align pfun.restrict PFun.restrict\n\n@[simp]\ntheorem mem_restrict {f : \u03b1 \u2192. \u03b2} {s : Set \u03b1} (h : s \u2286 f.Dom) (a : \u03b1) (b : \u03b2) :\n    b \u2208 f.restrict h a \u2194 a \u2208 s \u2227 b \u2208 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 : \u03b1 \u2192 \u03b2) (s : Set \u03b1) : \u03b1 \u2192. \u03b2 :=\n  (PFun.lift f).restrict s.subset_univ\n#align pfun.res PFun.res\n\ntheorem mem_res (f : \u03b1 \u2192 \u03b2) (s : Set \u03b1) (a : \u03b1) (b : \u03b2) : b \u2208 res f s a \u2194 a \u2208 s \u2227 f a = b := by\n  simp [res, @eq_comm _ b]\n#align pfun.mem_res PFun.mem_res\n\ntheorem res_univ (f : \u03b1 \u2192 \u03b2) : PFun.res f Set.univ = f :=\n  rfl\n#align pfun.res_univ PFun.res_univ\n\ntheorem dom_iff_graph (f : \u03b1 \u2192. \u03b2) (x : \u03b1) : x \u2208 f.Dom \u2194 \u2203 y, (x, y) \u2208 f.graph :=\n  Part.dom_iff_mem\n#align pfun.dom_iff_graph PFun.dom_iff_graph\n\ntheorem lift_graph {f : \u03b1 \u2192 \u03b2} {a b} : (a, b) \u2208 (f : \u03b1 \u2192. \u03b2).graph \u2194 f a = b :=\n  show (\u2203 _ : True, f a = b) \u2194 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 : \u03b2) : \u03b1 \u2192. \u03b2 := fun _ => Part.some x\n#align pfun.pure PFun.pure\n\n/-- The monad `bind` function, pointwise `part.bind` -/\ndef bind (f : \u03b1 \u2192. \u03b2) (g : \u03b2 \u2192 \u03b1 \u2192. \u03b3) : \u03b1 \u2192. \u03b3 := fun a => (f a).bind fun b => g b a\n#align pfun.bind PFun.bind\n\n@[simp]\ntheorem bind_apply (f : \u03b1 \u2192. \u03b2) (g : \u03b2 \u2192 \u03b1 \u2192. \u03b3) (a : \u03b1) : 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 : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192. \u03b2) : \u03b1 \u2192. \u03b3 := fun a => (g a).map f\n#align pfun.map PFun.map\n\ninstance : Monad (PFun \u03b1) where\n  pure := @PFun.pure _\n  bind := @PFun.bind _\n  map := @PFun.map _\n\ninstance : LawfulMonad (PFun \u03b1) := 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 \u03b1) (x : \u03b2) : p \u2286 (@PFun.pure \u03b1 _ x).Dom :=\n  p.subset_univ\n#align pfun.pure_defined PFun.pure_defined\n\ntheorem bind_defined {\u03b1 \u03b2 \u03b3} (p : Set \u03b1) {f : \u03b1 \u2192. \u03b2} {g : \u03b2 \u2192 \u03b1 \u2192. \u03b3} (H1 : p \u2286 f.Dom)\n    (H2 : \u2200 x, p \u2286 (g x).Dom) : p \u2286 (f >>= g).Dom := fun a ha =>\n  (\u27e8H1 ha, H2 _ ha\u27e9 : (f >>= g).Dom a)\n#align pfun.bind_defined PFun.bind_defined\n\n/-- First return map. Transforms a partial function `f : \u03b1 \u2192. \u03b2 \u2295 \u03b1` into the partial function\n`\u03b1 \u2192. \u03b2` which sends `a : \u03b1` to the first value in `\u03b2` it hits by iterating `f`, if such a value\nexists. By abusing notation to illustrate, either `f a` is in the `\u03b2` part of `\u03b2 \u2295 \u03b1` (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 `\u03b1` part of `\u03b2 \u2295 \u03b1` (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 : \u03b1 \u2192. Sum \u03b2 \u03b1) : \u03b1 \u2192. \u03b2 := fun a =>\n  Part.assert (Acc (fun x y => Sum.inr x \u2208 f y) a) $ fun h =>\n    @WellFounded.fixF _ (fun x y => Sum.inr x \u2208 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' \u27e8hf, e\u27e9)\n      a h\n#align pfun.fix PFun.fix\n\ntheorem dom_of_mem_fix {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {a : \u03b1} {b : \u03b2} (h : b \u2208 f.fix a) : (f a).Dom := by\n  let \u27e8h\u2081, h\u2082\u27e9 := Part.mem_assert_iff.1 h\n  rw [WellFounded.fixFEq] at h\u2082 ; exact h\u2082.fst.fst\n#align pfun.dom_of_mem_fix PFun.dom_of_mem_fix\n\ntheorem mem_fix_iff {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {a : \u03b1} {b : \u03b2} :\n    b \u2208 f.fix a \u2194 Sum.inl b \u2208 f a \u2228 \u2203 a', Sum.inr a' \u2208 f a \u2227 b \u2208 f.fix a' :=\n  \u27e8fun h => by\n    let \u27e8h\u2081, h\u2082\u27e9 := Part.mem_assert_iff.1 h\n    rw [WellFounded.fixFEq] at h\u2082\n    simp at h\u2082\n    cases' h\u2082 with h\u2082 h\u2083\n    split at h\u2083 <;> simp at h\u2083\n    next e => subst b; refine' Or.inl \u27e8h\u2082, e\u27e9\n    next e => exact Or.inr \u27e8_, \u27e8_, e\u27e9, Part.mem_assert _ h\u2083\u27e9,\n   fun h => by\n    simp [fix]\n    rcases h with (\u27e8h\u2081, h\u2082\u27e9 | \u27e8a', h, h\u2083\u27e9)\n    \u00b7 refine' \u27e8\u27e8_, fun y h' => _\u27e9, _\u27e9\n      \u00b7 injection Part.mem_unique \u27e8h\u2081, h\u2082\u27e9 h'\n      \u00b7 rw [WellFounded.fixFEq]\n        -- Porting note: used to be simp [h\u2081, h\u2082]\n        apply Part.mem_assert h\u2081\n        split\n        next e =>\n          injection h\u2082.symm.trans e with h; simp [h]\n        next e =>\n          injection h\u2082.symm.trans e\n    \u00b7 simp [fix] at h\u2083\n      cases' h\u2083 with h\u2083 h\u2084\n      refine' \u27e8\u27e8_, fun y h' => _\u27e9, _\u27e9\n      \u00b7 injection Part.mem_unique h h' with e\n        exact e \u25b8 h\u2083\n      \u00b7 cases' h with h\u2081 h\u2082\n        rw [WellFounded.fixFEq]\n        -- Porting note: used to be simp [h\u2081, h\u2082, h\u2084]\n        apply Part.mem_assert h\u2081\n        split\n        next e =>\n          injection h\u2082.symm.trans e\n        next e =>\n          injection h\u2082.symm.trans e; subst a'; exact h\u2084\u27e9\n#align pfun.mem_fix_iff PFun.mem_fix_iff\n\n/-- If advancing one step from `a` leads to `b : \u03b2`, then `f.fix a = b` -/\ntheorem fix_stop {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {b : \u03b2} {a : \u03b1} (hb : Sum.inl b \u2208 f a) : b \u2208 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' : \u03b1`, then `f.fix a = f.fix a'` -/\ntheorem fix_fwd_eq {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {a a' : \u03b1} (ha' : Sum.inr a' \u2208 f a) : f.fix a = f.fix a' := by\n  ext b; constructor\n  \u00b7 intro h\n    obtain h' | \u27e8a, h', e'\u27e9 := mem_fix_iff.1 h <;> cases Part.mem_unique ha' h'\n    exact e'\n  \u00b7 intro h\n    rw [PFun.mem_fix_iff]\n    exact Or.inr \u27e8a', ha', h\u27e9\n#align pfun.fix_fwd_eq PFun.fix_fwd_eq\n\ntheorem fix_fwd {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {b : \u03b2} {a a' : \u03b1} (hb : b \u2208 f.fix a) (ha' : Sum.inr a' \u2208 f a) :\n    b \u2208 f.fix a' := by rwa [\u2190 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 : \u03b1 \u2192 Sort _} {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {b : \u03b2} {a : \u03b1} (h : b \u2208 f.fix a)\n    (H : \u2200 a', b \u2208 f.fix a' \u2192 (\u2200 a'', Sum.inr a'' \u2208 f a' \u2192 C a'') \u2192 C a') : C a := by\n  have h\u2082 := (Part.mem_assert_iff.1 h).snd;\n  -- Porting note: revert/intro trick required to address `generalize_proofs` bug\n  revert h\u2082\n  generalize_proofs h\u2081;\n  intro h\u2082; clear h\n  induction' h\u2081 with a ha IH\n  have h : b \u2208 f.fix a := Part.mem_assert_iff.2 \u27e8\u27e8a, ha\u27e9, h\u2082\u27e9\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 : \u03b1 \u2192 Sort _} {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {b : \u03b2} {a : \u03b1} (h : b \u2208 f.fix a)\n    (H : \u2200 a', b \u2208 f.fix a' \u2192 (\u2200 a'', Sum.inr a'' \u2208 f a' \u2192 C a'') \u2192 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 \u2208 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 : \u03b1 \u2192 Sort _} {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {b : \u03b2} {a : \u03b1}\n    (h : b \u2208 f.fix a) (hbase : \u2200 a_final : \u03b1, Sum.inl b \u2208 f a_final \u2192 C a_final)\n    (hind : \u2200 a\u2080 a\u2081 : \u03b1, b \u2208 f.fix a\u2081 \u2192 Sum.inr a\u2081 \u2208 f a\u2080 \u2192 C a\u2081 \u2192 C a\u2080) : 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 : _ \u2208 f a' := \u27e8_, e\u27e9\n  \u00b7 apply hbase\n    convert e\n    exact Part.mem_unique h (fix_stop e)\n  \u00b7 exact hind _ _ (fix_fwd h e) e (ih _ e)\n#align pfun.fix_induction' PFun.fixInduction'\n\ntheorem fixInduction'_stop {C : \u03b1 \u2192 Sort _} {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {b : \u03b2} {a : \u03b1} (h : b \u2208 f.fix a)\n    (fa : Sum.inl b \u2208 f a) (hbase : \u2200 a_final : \u03b1, Sum.inl b \u2208 f a_final \u2192 C a_final)\n    (hind : \u2200 a\u2080 a\u2081 : \u03b1, b \u2208 f.fix a\u2081 \u2192 Sum.inr a\u2081 \u2208 f a\u2080 \u2192 C a\u2081 \u2192 C a\u2080) :\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 \u2192 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 : \u03b1 \u2192 Sort _} {f : \u03b1 \u2192. Sum \u03b2 \u03b1} {b : \u03b2} {a a' : \u03b1} (h : b \u2208 f.fix a)\n    (h' : b \u2208 f.fix a') (fa : Sum.inr a' \u2208 f a)\n    (hbase : \u2200 a_final : \u03b1, Sum.inl b \u2208 f a_final \u2192 C a_final)\n    (hind : \u2200 a\u2080 a\u2081 : \u03b1, b \u2208 f.fix a\u2081 \u2192 Sum.inr a\u2081 \u2208 f a\u2080 \u2192 C a\u2081 \u2192 C a\u2080) :\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 \u2192 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 : \u03b1 \u2192. \u03b2)\n\n/-- Image of a set under a partial function. -/\ndef image (s : Set \u03b1) : Set \u03b2 :=\n  f.graph'.image s\n#align pfun.image PFun.image\n\ntheorem image_def (s : Set \u03b1) : f.image s = { y | \u2203 x \u2208 s, y \u2208 f x } :=\n  rfl\n#align pfun.image_def PFun.image_def\n\ntheorem mem_image (y : \u03b2) (s : Set \u03b1) : y \u2208 f.image s \u2194 \u2203 x \u2208 s, y \u2208 f x :=\n  Iff.rfl\n#align pfun.mem_image PFun.mem_image\n\n\n\ntheorem image_inter (s t : Set \u03b1) : f.image (s \u2229 t) \u2286 f.image s \u2229 f.image t :=\n  Rel.image_inter _ s t\n#align pfun.image_inter PFun.image_inter\n\ntheorem image_union (s t : Set \u03b1) : f.image (s \u222a t) = f.image s \u222a 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 \u03b2) : Set \u03b1 :=\n  Rel.image (fun x y => x \u2208 f y) s\n#align pfun.preimage PFun.preimage\n\ntheorem Preimage_def (s : Set \u03b2) : f.preimage s = { x | \u2203 y \u2208 s, y \u2208 f x } :=\n  rfl\n#align pfun.preimage_def PFun.Preimage_def\n\n@[simp]\ntheorem mem_preimage (s : Set \u03b2) (x : \u03b1) : x \u2208 f.preimage s \u2194 \u2203 y \u2208 s, y \u2208 f x :=\n  Iff.rfl\n#align pfun.mem_preimage PFun.mem_preimage\n\ntheorem preimage_subset_dom (s : Set \u03b2) : f.preimage s \u2286 f.Dom := fun _ \u27e8y, _, fxy\u27e9 =>\n  Part.dom_iff_mem.mpr \u27e8y, fxy\u27e9\n#align pfun.preimage_subset_dom PFun.preimage_subset_dom\n\ntheorem preimage_mono {s t : Set \u03b2} (h : s \u2286 t) : f.preimage s \u2286 f.preimage t :=\n  Rel.preimage_mono _ h\n#align pfun.preimage_mono PFun.preimage_mono\n\ntheorem preimage_inter (s t : Set \u03b2) : f.preimage (s \u2229 t) \u2286 f.preimage s \u2229 f.preimage t :=\n  Rel.preimage_inter _ s t\n#align pfun.preimage_inter PFun.preimage_inter\n\ntheorem preimage_union (s t : Set \u03b2) : f.preimage (s \u222a t) = f.preimage s \u222a 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 : \u03b1 \u2192 \u03b2) (s : Set \u03b2) : (f : \u03b1 \u2192. \u03b2).preimage s = f \u207b\u00b9' s := by ext ; simp\n#align pfun.coe_preimage PFun.coe_preimage\n\n/-- Core of a set `s : set \u03b2` with respect to a partial function `f : \u03b1 \u2192. \u03b2`. Set of all `a : \u03b1`\nsuch that `f a \u2208 s`, if `f a` is defined. -/\ndef core (s : Set \u03b2) : Set \u03b1 :=\n  f.graph'.core s\n#align pfun.core PFun.core\n\ntheorem core_def (s : Set \u03b2) : f.core s = { x | \u2200 y, y \u2208 f x \u2192 y \u2208 s } :=\n  rfl\n#align pfun.core_def PFun.core_def\n\n@[simp]\ntheorem mem_core (x : \u03b1) (s : Set \u03b2) : x \u2208 f.core s \u2194 \u2200 y, y \u2208 f x \u2192 y \u2208 s :=\n  Iff.rfl\n#align pfun.mem_core PFun.mem_core\n\ntheorem compl_dom_subset_core (s : Set \u03b2) : f.Dom\u1d9c \u2286 f.core s := fun x hx y fxy =>\n  absurd ((mem_dom f x).mpr \u27e8y, fxy\u27e9) hx\n#align pfun.compl_dom_subset_core PFun.compl_dom_subset_core\n\ntheorem core_mono {s t : Set \u03b2} (h : s \u2286 t) : f.core s \u2286 f.core t :=\n  Rel.core_mono _ h\n#align pfun.core_mono PFun.core_mono\n\ntheorem core_inter (s t : Set \u03b2) : f.core (s \u2229 t) = f.core s \u2229 f.core t :=\n  Rel.core_inter _ s t\n#align pfun.core_inter PFun.core_inter\n\ntheorem mem_core_res (f : \u03b1 \u2192 \u03b2) (s : Set \u03b1) (t : Set \u03b2) (x : \u03b1) :\n    x \u2208 (res f s).core t \u2194 x \u2208 s \u2192 f x \u2208 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 : \u03b1 \u2192 \u03b2) (s : Set \u03b1) (t : Set \u03b2) : (res f s).core t = s\u1d9c \u222a f \u207b\u00b9' t := by\n  ext x\n  rw [mem_core_res]\n  by_cases h : x \u2208 s <;> simp [h]\n#align pfun.core_res PFun.core_res\n\nend\n\ntheorem core_restrict (f : \u03b1 \u2192 \u03b2) (s : Set \u03b2) : (f : \u03b1 \u2192. \u03b2).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 : \u03b1 \u2192. \u03b2) (s : Set \u03b2) : f.preimage s \u2286 f.core s :=\n  fun _ \u27e8y, ys, fxy\u27e9 y' fxy' =>\n  have : y = y' := Part.mem_unique fxy fxy'\n  this \u25b8 ys\n#align pfun.preimage_subset_core PFun.preimage_subset_core\n\ntheorem preimage_eq (f : \u03b1 \u2192. \u03b2) (s : Set \u03b2) : f.preimage s = f.core s \u2229 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 \u27e8xcore, xdom\u27e9 =>\n    let y := (f x).get xdom\n    have ys : y \u2208 s := xcore _ (Part.get_mem _)\n    show x \u2208 f.preimage s from \u27e8(f x).get xdom, ys, Part.get_mem _\u27e9\n#align pfun.preimage_eq PFun.preimage_eq\n\ntheorem core_eq (f : \u03b1 \u2192. \u03b2) (s : Set \u03b2) : f.core s = f.preimage s \u222a f.Dom\u1d9c := 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 : \u03b1 \u2192. \u03b2) (s : Set \u03b2) :\n    f.asSubtype \u207b\u00b9' s = Subtype.val \u207b\u00b9' 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 _ \u2208 s \u2194 \u2203 y \u2208 s, y \u2208 f x.val\n  exact\n    Iff.intro (fun h => \u27e8_, h, Part.get_mem _\u27e9) fun \u27e8y, ys, fxy\u27e9 =>\n      have : f.fn x.val x.property \u2208 f x.val := Part.get_mem _\n      Part.mem_unique fxy this \u25b8 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 : \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) : \u03b1 \u2192. Subtype p := fun a => \u27e8p (f a), Subtype.mk _\u27e9\n#align pfun.to_subtype PFun.toSubtype\n\n@[simp]\ntheorem dom_to_subtype (p : \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) : (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 : \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) :\n    toSubtype p f a = \u27e8p (f a), Subtype.mk _\u27e9 :=\n  rfl\n#align pfun.to_subtype_apply PFun.to_subtype_apply\n\ntheorem dom_to_subtype_apply_iff {p : \u03b2 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} {a : \u03b1} :\n    (toSubtype p f a).Dom \u2194 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 : \u03b2 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} {a : \u03b1} {b : Subtype p} :\n    b \u2208 toSubtype p f a \u2194 \u2191b = 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 (\u03b1 : Type _) : \u03b1 \u2192. \u03b1 :=\n  Part.some\n#align pfun.id PFun.id\n\n@[simp]\ntheorem coe_id (\u03b1 : Type _) : ((id : \u03b1 \u2192 \u03b1) : \u03b1 \u2192. \u03b1) = PFun.id \u03b1 :=\n  rfl\n#align pfun.coe_id PFun.coe_id\n\n@[simp]\ntheorem id_apply (a : \u03b1) : PFun.id \u03b1 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 : \u03b2 \u2192. \u03b3) (g : \u03b1 \u2192. \u03b2) : \u03b1 \u2192. \u03b3 := fun a => (g a).bind f\n#align pfun.comp PFun.comp\n\n@[simp]\ntheorem comp_apply (f : \u03b2 \u2192. \u03b3) (g : \u03b1 \u2192. \u03b2) (a : \u03b1) : 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 : \u03b1 \u2192. \u03b2) : (PFun.id \u03b2).comp f = f :=\n  ext fun _ _ => by simp\n#align pfun.id_comp PFun.id_comp\n\n@[simp]\ntheorem comp_id (f : \u03b1 \u2192. \u03b2) : f.comp (PFun.id \u03b1) = f :=\n  ext fun _ _ => by simp\n#align pfun.comp_id PFun.comp_id\n\n@[simp]\ntheorem dom_comp (f : \u03b2 \u2192. \u03b3) (g : \u03b1 \u2192. \u03b2) : (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, \u2190 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 : \u03b2 \u2192. \u03b3) (g : \u03b1 \u2192. \u03b2) (s : Set \u03b3) :\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, \u2190 exists_and_right, \u2190\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 : \u03b2 \u2192. \u03b3) (g : \u03b1 \u2192. \u03b2) (a : Part \u03b1) :\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, \u2190 exists_and_right, \u2190\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 : \u03b3 \u2192. \u03b4) (g : \u03b2 \u2192. \u03b3) (h : \u03b1 \u2192. \u03b2) : (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 : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) : ((g \u2218 f : \u03b1 \u2192 \u03b3) : \u03b1 \u2192. \u03b3) = (g : \u03b2 \u2192. \u03b3).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 : \u03b1 \u2192. \u03b2) (g : \u03b1 \u2192. \u03b3) : \u03b1 \u2192. \u03b2 \u00d7 \u03b3 := fun x =>\n  \u27e8(f x).Dom \u2227 (g x).Dom, fun h => ((f x).get h.1, (g x).get h.2)\u27e9\n#align pfun.prod_lift PFun.prodLift\n\n@[simp]\ntheorem dom_prodLift (f : \u03b1 \u2192. \u03b2) (g : \u03b1 \u2192. \u03b3) :\n    (f.prodLift g).Dom = { x | (f x).Dom \u2227 (g x).Dom } :=\n  rfl\n#align pfun.dom_prod_lift PFun.dom_prodLift\n\ntheorem get_prodLift (f : \u03b1 \u2192. \u03b2) (g : \u03b1 \u2192. \u03b3) (x : \u03b1) (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 : \u03b1 \u2192. \u03b2) (g : \u03b1 \u2192. \u03b3) (x : \u03b1) :\n    f.prodLift g x = \u27e8(f x).Dom \u2227 (g x).Dom, fun h => ((f x).get h.1, (g x).get h.2)\u27e9 :=\n  rfl\n#align pfun.prod_lift_apply PFun.prodLift_apply\n\ntheorem mem_prodLift {f : \u03b1 \u2192. \u03b2} {g : \u03b1 \u2192. \u03b3} {x : \u03b1} {y : \u03b2 \u00d7 \u03b3} :\n    y \u2208 f.prodLift g x \u2194 y.1 \u2208 f x \u2227 y.2 \u2208 g x := by\n  trans \u2203 hp hq, (f x).get hp = y.1 \u2227 (g x).get hq = y.2\n  \u00b7 simp only [prodLift, Part.mem_mk_iff, And.exists, Prod.ext_iff]\n  -- Porting note: was just `[exists_and_left, exists_and_right]`\n  \u00b7 simp only [exists_and_left, exists_and_right, (\u00b7 \u2208 \u00b7), Part.Mem]\n#align pfun.mem_prod_lift PFun.mem_prodLift\n\n/-- Product of partial functions. -/\ndef prodMap (f : \u03b1 \u2192. \u03b3) (g : \u03b2 \u2192. \u03b4) : \u03b1 \u00d7 \u03b2 \u2192. \u03b3 \u00d7 \u03b4 := fun x =>\n  \u27e8(f x.1).Dom \u2227 (g x.2).Dom, fun h => ((f x.1).get h.1, (g x.2).get h.2)\u27e9\n#align pfun.prod_map PFun.prodMap\n\n@[simp]\ntheorem dom_prodMap (f : \u03b1 \u2192. \u03b3) (g : \u03b2 \u2192. \u03b4) :\n    (f.prodMap g).Dom = { x | (f x.1).Dom \u2227 (g x.2).Dom } :=\n  rfl\n#align pfun.dom_prod_map PFun.dom_prodMap\n\ntheorem get_prodMap (f : \u03b1 \u2192. \u03b3) (g : \u03b2 \u2192. \u03b4) (x : \u03b1 \u00d7 \u03b2) (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 : \u03b1 \u2192. \u03b3) (g : \u03b2 \u2192. \u03b4) (x : \u03b1 \u00d7 \u03b2) :\n    f.prodMap g x = \u27e8(f x.1).Dom \u2227 (g x.2).Dom, fun h => ((f x.1).get h.1, (g x.2).get h.2)\u27e9 :=\n  rfl\n#align pfun.prod_map_apply PFun.prodMap_apply\n\ntheorem mem_prodMap {f : \u03b1 \u2192. \u03b3} {g : \u03b2 \u2192. \u03b4} {x : \u03b1 \u00d7 \u03b2} {y : \u03b3 \u00d7 \u03b4} :\n    y \u2208 f.prodMap g x \u2194 y.1 \u2208 f x.1 \u2227 y.2 \u2208 g x.2 := by\n  trans \u2203 hp hq, (f x.1).get hp = y.1 \u2227 (g x.2).get hq = y.2\n  \u00b7 simp only [prodMap, Part.mem_mk_iff, And.exists, Prod.ext_iff]\n  \u00b7 simp only [exists_and_left, exists_and_right, (\u00b7 \u2208 \u00b7), Part.Mem]\n#align pfun.mem_prod_map PFun.mem_prodMap\n\n@[simp]\ntheorem prodLift_fst_comp_snd_comp (f : \u03b1 \u2192. \u03b3) (g : \u03b2 \u2192. \u03b4) :\n    prodLift (f.comp ((Prod.fst : \u03b1 \u00d7 \u03b2 \u2192 \u03b1) : \u03b1 \u00d7 \u03b2 \u2192. \u03b1))\n        (g.comp ((Prod.snd : \u03b1 \u00d7 \u03b2 \u2192 \u03b2) : \u03b1 \u00d7 \u03b2 \u2192. \u03b2)) =\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 \u03b1).prodMap (PFun.id \u03b2) = 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\u2081 : \u03b1 \u2192. \u03b2) (f\u2082 : \u03b2 \u2192. \u03b3) (g\u2081 : \u03b4 \u2192. \u03b5) (g\u2082 : \u03b5 \u2192. \u03b9) :\n    (f\u2082.comp f\u2081).prodMap (g\u2082.comp g\u2081) = (f\u2082.prodMap g\u2082).comp (f\u2081.prodMap g\u2081) := -- by\n  -- Porting note: was `by tidy`, below is a golf'd verson of the `tidy?` proof\n  ext $ \u03bb \u27e8_, _\u27e9 \u27e8_, _\u27e9 =>\n  \u27e8\u03bb \u27e8\u27e8\u27e8h1l1, h1l2\u27e9, \u27e8h1r1, h1r2\u27e9\u27e9, h2\u27e9 => \u27e8\u27e8\u27e8h1l1, h1r1\u27e9, \u27e8h1l2, h1r2\u27e9\u27e9, h2\u27e9,\n   \u03bb \u27e8\u27e8\u27e8h1l1, h1r1\u27e9, \u27e8h1l2, h1r2\u27e9\u27e9, h2\u27e9 => \u27e8\u27e8\u27e8h1l1, h1l2\u27e9, \u27e8h1r1, h1r2\u27e9\u27e9, h2\u27e9\u27e9\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 (\u03b1 : Type) where\n  (output : \u03b1)\n\ninductive MonadResultIs {\u03b1 : Type} : \u03b1 \u2192 Type where\n| mk : (mz : BaseMonad \u03b1) \u2192 MonadResultIs (mz.output)\n\ndef MRret {\u03b1 : Type} (a : \u03b1) := MonadResultIs.mk (BaseMonad.mk a)\n\ndef MRbind {\u03b1 : Type} {a b : \u03b1} {ma mb : BaseMonad \u03b1} : MonadResultIs a \u2192 (\u03b1 \u2192 MonadResultIs b) \u2192 MonadResultIs b :=\n  fun m1 m2 => match m1 with\n               | MonadResultIs.mk mz => m2 (mz.output)\n\ndef MRrun {\u03b1 : Type} {z : \u03b1} {mz : BaseMonad \u03b1} (d : MonadResultIs z) : \u03b1 :=\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 (\u03b1 : Type) : Type := \u03b1 \u2192 Prop\n\ndef retEqPred {\u03b1 : Type} (v : \u03b1) : dPred \u03b1 := fun y => y = v\ndef retEqProof {\u03b1 : Type} (v : \u03b1) : retEqPred v v := show v = v by rfl\n\ndef bindPred {\u03b1 \u03b2 : Type} (p : dPred \u03b1) (f : \u03b1 \u2192 dPred \u03b2) : dPred \u03b2 := fun b => \u2203 (a:\u03b1), p a \u2227 f a b\n\ninductive MonadWithPredicate (\u03b1 : Type) : dPred \u03b1 \u2192 Type where\n| mk : (mz : BaseMonad \u03b1) \u2192 (pf : p mz.output) \u2192 MonadWithPredicate \u03b1 p\n\ndef retMW {\u03b1 : Type} {p : dPred \u03b1} (v : \u03b1) (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 {\u03b1 : Type} {p : dPred \u03b1} {a b : \u03b1} {ma mb : BaseMonad \u03b1} : MonadWithPredicate \u03b1 p \u2192 (\u03b1 \u2192 MonadWithPredicate \u03b1 p) \u2192 MonadWithPredicate \u03b1 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 {\u03b1 : Type} {p\u2081 p\u2082 : dPred \u03b1} : MonadWithPredicate \u03b1 p\u2081 \u2192 (\u03b1 \u2192 MonadWithPredicate \u03b1 p\u2082) \u2192 MonadWithPredicate \u03b1 (fun b => \u2203x, p\u2081 x \u2227 (p\u2082 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 \u2203 x, p\u2081 x \u2227 p\u2082 mz2.output from Exists.intro mz1.output (And.intro pf1 pf2))\n\ndef runPred {\u03b1 : Type} (p : dPred \u03b1) (m : MonadWithPredicate \u03b1 p) : \u2203 x, p x :=\n  match m with\n  | MonadWithPredicate.mk b pf => Exists.intro b.output pf\n\n\n#check show \u2203 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 (\u2203 x, x = 3) from (Exists.intro 3 rfl))\n#check (show (\u2200 a, a = 3 \u2192 retEqPred 3 3) from (fun a (_:a=3) => _))\n#check Exists.elim (show (\u2203 x, x = 3) from (Exists.intro 3 rfl)) (show (\u2200 a, a = 3 \u2192 retEqPred 3 3) from (fun a (_:a=3) => _))\n\n\nexample (h: \u2203 x, retEqPred 3 x \u2227 retEqPred 4 4) : retEqPred 3 3 := by\n  let hx : \u2200 a, retEqPred 3 a \u2227 retEqPred 4 4 \u2192 retEqPred 3 3 := show \u2200a, retEqPred 3 a \u2227 retEqPred 4 4 \u2192 retEqPred 3 3 from (fun a x => show _ from rfl)\n  apply Exists.elim h hx\n\n-- forward transforming predicate\n\ndef fPred (\u03b1 : Type) : Type := Prop \u2192 \u03b1 \u2192 Prop\n\ndef simpleFP {\u03b1 : Type} (v : \u03b1) : fPred \u03b1 := fun (pre:Prop) (a : \u03b1) => pre \u2227 a = v\n\n\ninductive MonadFwdPredicate {\u03b1 : Type} : Prop \u2192 fPred \u03b1 \u2192 Type where\n| mk : (mz : BaseMonad \u03b1) \u2192 (pf : \u2200 (hpre : pre), p pre mz.output) \u2192 MonadFwdPredicate pre p\n\n\ndef retFP {\u03b1 : Type} (v : \u03b1) {pre :Prop} : MonadFwdPredicate pre (@simpleFP \u03b1 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 {\u03b1 :Type} {pre1 : Prop} {p\u2081 p\u2082 : fPred \u03b1} :\n  MonadFwdPredicate pre1 p\u2081 \u2192 (\u03b1 \u2192 MonadFwdPredicate (\u2203a, p\u2081 pre1 a) p\u2082) \u2192 MonadFwdPredicate pre1 (fun pre z => p\u2082 (\u2203a, p\u2081 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 {\u03b1 : Type} {pre1 :Prop} {p\u2081 : fPred \u03b1} (m : MonadFwdPredicate pre1 p\u2081) : pre1 \u2192 \u2203 a, p\u2081 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 (\u03b1 : Type) : Type := (\u03b1 \u2192 Prop) \u2192 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 \u03b1) where\n  monoMap {p\u2081 p\u2082 : \u03b1 \u2192 Prop} : (\u2200 a , p\u2081 a \u2192 p\u2082 a) \u2192 w p\u2081 \u2192 w p\u2082\n\ndef simpleBP {\u03b1 : Type} (v : \u03b1) : bPred \u03b1 := fun (post : \u03b1 \u2192 Prop) => post v\n\ninstance {\u03b1 : Type} {v : \u03b1}: MonoBackward (simpleBP v) where\n  monoMap  {p\u2081 p\u2082 : \u03b1 \u2192 Prop} :=  fun f wp1 => f v wp1\n\ninductive MonadBwdPredicate {\u03b1 : Type} : bPred \u03b1 \u2192 (\u03b1 \u2192 Prop) \u2192 Type where\n| mk : (mz : BaseMonad \u03b1) \u2192 (pf : p post) \u2192 MonadBwdPredicate p post\n\n\n\ndef retBP {\u03b1 : Type} (v : \u03b1) {post : \u03b1 \u2192 Prop} {postpf: post v} : MonadBwdPredicate (@simpleBP \u03b1 v) post:=\n  let bm := BaseMonad.mk v\n  MonadBwdPredicate.mk bm postpf\n\ndef bindBP {\u03b1 : Type} {post1 post2 : \u03b1 \u2192 Prop} {p\u2081 p\u2082 p\u2083 : bPred \u03b1} [MonoBackward p\u2081] :\n  MonadBwdPredicate p\u2081 post1 \u2192 (\u03b1 \u2192 MonadBwdPredicate p\u2082 post2) \u2192 MonadBwdPredicate (fun (p : \u03b1 \u2192 Prop) => p\u2081 (fun a => post1 a \u2227 p\u2082 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 : \u2200 a, post1 a \u2192 post1 a \u2227 p\u2082 post2 := fun a p1 => And.intro p1 pf2\n                                              MonoBackward.monoMap hx pf1)\n\ndef runBP {\u03b1 : Type} {post1 : \u03b1 \u2192 Prop} {p\u2081 : bPred \u03b1} (m : MonadBwdPredicate p\u2081 post1) : p\u2081 post1 :=\n  match m with | MonadBwdPredicate.mk ma pf => pf\n\n#check retBP 3\n\ndef sampleBack := @runBP Nat (fun x => 3 = x \u2192 Eq 3 3) (simpleBP 3) (@retBP Nat 3 _ id)\ndef sampleBack2 : simpleBP 3 fun x => 3 = x \u2192 3 = 3 := runBP (@retBP Nat 3 _ id)\n\n\n-- backward predicate for state monad\n\ndef Top {x : Type} : x \u2192 Prop  := fun _ => True\n\ndef bSPred (s \u03b1 : Type) : Type := (\u03b1 \u00d7 s \u2192 Prop) \u2192 s \u2192 Prop\n\ndef StatePM (s : Type) (\u03b1 : Type) : Type := s \u2192 (\u03b1 \u00d7 s)\n\ninductive MonadBwdState (s : Type) (\u03b1: Type) (p : bSPred s \u03b1) : Type where\n| mk : (ms : StatePM s \u03b1) \u2192 (pf : \u2200 post s, p post s \u2192 post (ms s)) \u2192 MonadBwdState s \u03b1 p\n\n\ndef retBS {s \u03b1 : Type} (a : \u03b1) : MonadBwdState s \u03b1 (fun post s0 => post \u27e8a, s0\u27e9) :=\n  let md : StatePM s \u03b1 := fun s => \u27e8a,s\u27e9\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 \u03b1 \u03b2 : Type} (wc : bSPred s \u03b1) (wf : \u03b1 \u2192 bSPred s \u03b2) : bSPred s \u03b2 :=\n  fun p s0 => wc (fun \u27e8a,s1\u27e9 => wf a p s1) s0\n\n\ndef bindBS {s \u03b1 \u03b2 : Type} {wc : bSPred s \u03b1} {wf : \u03b1 \u2192 bSPred s \u03b2} :\n           MonadBwdState s \u03b1 wc \u2192 ((x : \u03b1) \u2192 MonadBwdState s \u03b2 (wf x)) \u2192 MonadBwdState s \u03b2 (bindWBS wc wf) :=\n  fun m1 f =>\n    match m1 with\n    | MonadBwdState.mk ms1 pf1 =>\n        let mm  := fun s\u2081 =>\n                        let mo1:= ms1 s\u2081\n                        let m2 := f mo1.1\n                        match m2 with\n                        | MonadBwdState.mk ms2 pf2 => ms2 mo1.2\n        let pf3 := fun post s\u2081 bindW =>\n                        let mo1 := ms1 s\u2081\n                        let m2 := f mo1.1\n                        let ms2 := m2.1\n                        let pf2 := m2.2\n                        let \u27e8a\u2082,s\u2083\u27e9 := mm s\u2081  -- 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\u2081 := pf1 postX s\u2081\n                        let postT\u2082 := pf2 post mo1.2\n                        let hh : wc postX s\u2081 := by unfold bindWBS at bindW; assumption\n                        let pf12 := postT\u2081 hh\n                        let hpf12 : postX (ms1 s\u2081) = 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\u2082 hh2\n                        let hme : ms2 = (f (ms1 s\u2081).fst).1 := by simp\n                        let hh3 : ms2 mo1.2 = mm s\u2081:= by simp\n                        by rewrite [\u2190hh3]; 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 `\u2124[` 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 : \u2124[A^m] \u2192 \u2124[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 `\u2124[A^n]`,\nbut it has to be \"universal\".\n\nIn the end, this means that `f` will be a `\u2124`-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 `\u2124`-linear combination `c i 1 * a 1 + ... + c i m * a m`.\nSo a \"basic universal map\" is specified by the `n \u00d7 m`-matrix `c`.\n-/\n\n/-- A `basic_universal_map m n` is an `n \u00d7 m`-matrix.\nIt captures data for a homomorphism `\u2124[A^m] \u2192 \u2124[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 : \u2115) := matrix (fin n) (fin m) \u2124\n\nnamespace basic_universal_map\n\nvariables (A : Type*) [add_comm_group A]\nvariables {k l m n : \u2115} (g : basic_universal_map m n) (f : basic_universal_map l m)\n\ndef pre_eval : basic_universal_map m n \u2192+ A^m \u2192 A^n :=\nadd_monoid_hom.mk' (\u03bb f x i, \u2211 j, f i j \u2022 (x : fin _ \u2192 A) j)\nbegin\n  intros f\u2081 f\u2082,\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 = \u03bb x i, \u2211 j, g i j \u2022 (x : fin _ \u2192 A) j := rfl\n\n/-- `f.eval A` for a `f : basic_universal_map m n`\nis the homomorphism `\u2124[A^m] \u2192+ \u2124[A^n]` induced by matrix multiplication. -/\ndef eval : \u2124[A^m] \u2192+ \u2124[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 \u2192+ basic_universal_map l m \u2192+ basic_universal_map l n :=\nadd_monoid_hom.mk' (\u03bb g, add_monoid_hom.mk' (\u03bb f, matrix.mul g f) $ matrix.mul_add _) $\n  \u03bb g\u2081 g\u2082, 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 : \u2115) : basic_universal_map n n := (1 : matrix (fin n) (fin n) \u2124)\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 : \u2115) : basic_universal_map m n \u2192+ basic_universal_map (N * m) (N * n) :=\nadd_monoid_hom.mk'\n (\u03bb f, matrix.reindex_linear_equiv \u2115 _ fin_prod_fin_equiv fin_prod_fin_equiv (1 \u2297\u2096 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 : \u2115) (f : basic_universal_map m n) :\n  mul N f = matrix.reindex_linear_equiv \u2115 _ fin_prod_fin_equiv fin_prod_fin_equiv (1 \u2297\u2096 f) :=\nrfl\n\nlemma mul_injective (N : \u2115) (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 (\u27e80, hN\u27e9, i)),\n  rw function.funext_iff at H,\n  specialize H (fin_prod_fin_equiv (\u27e80, hN\u27e9, 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 : \u2115) (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, \u2190 matrix.mul_kronecker_mul, matrix.one_mul],\nend\n\ndef one_mul_hom (n) : basic_universal_map (1 * n) n :=\nmatrix.reindex_linear_equiv \u2115 _\n  ((fin_one_equiv.prod_congr $ equiv.refl _).trans $ equiv.punit_prod _)\n  fin_prod_fin_equiv\n  (1 : matrix (fin 1 \u00d7 fin n) _ \u2124)\n\ndef one_mul_inv (n) : basic_universal_map n (1 * n) :=\nmatrix.reindex_linear_equiv \u2115 _\n  fin_prod_fin_equiv\n  ((fin_one_equiv.prod_congr $ equiv.refl _).trans $ equiv.punit_prod _)\n  (1 : matrix (fin 1 \u00d7 fin n) _ \u2124)\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 : \u2115) : basic_universal_map (m * (n * i)) ((m * n) * i) :=\nmatrix.reindex_linear_equiv \u2115 _\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 \u00d7 fin (n * i)) (fin m \u00d7 fin (n * i)) \u2124)\n\ndef mul_mul_inv (m n i : \u2115) : basic_universal_map ((m * n) * i) (m * (n * i)) :=\nmatrix.reindex_linear_equiv \u2115 _\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 \u00d7 fin (n * i)) (fin m \u00d7 fin (n * i)) \u2124)\n\nlemma mul_mul_hom_inv {m n i : \u2115} : 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 : \u2115} : 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 : \u2115} (k : fin N) : matrix punit.{1} (fin N) \u2124 :=\n\u03bb i j, if j = k then 1 else 0\n\ndef proj (n : \u2115) {N : \u2115} (k : fin N) : basic_universal_map (N * n) n :=\nmatrix.reindex_linear_equiv \u2115 _ (equiv.punit_prod _) fin_prod_fin_equiv $\n(proj_aux k) \u2297\u2096 1\n\nlemma proj_comp_mul {N : \u2115} (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  \u2115 _   (equiv.punit_prod (fin n)) (equiv.punit_prod (fin m)))\n    ((1 : matrix punit.{1} punit.{1} \u2124) \u2297\u2096 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 [\u2190matrix.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 [\u2190 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 \u27e8i, i'\u27e9 \u27e8j, j'\u27e9 : 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) \u2297\u2096 (proj_aux b) =\n  matrix.reindex_linear_equiv \u2115 _ (equiv.prod_punit _).symm fin_prod_fin_equiv.symm\n    (proj_aux (fin_prod_fin_equiv (a,b))) :=\nbegin\n  ext \u27e8i, i'\u27e9 \u27e8j, j'\u27e9 : 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, \u2190 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 : \u2115) (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, \u2190 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 [\u2190 ite_and],\n  congr' 1,\n  rw [\u2190 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 `\u2124`-linear combination\nof `basic_universal_map`s.\nIt captures the data for a homomorphism `\u2124[A^m] \u2192 \u2124[A^n]`. -/\n@[derive add_comm_group]\ndef universal_map (m n : \u2115) := \u2124[basic_universal_map m n]\n\nnamespace universal_map\nuniverse variable u\n\nvariables {k l m n : \u2115} (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 `\u2124[A^m] \u2192+ \u2124[A^n]` induced by matrix multiplication\nof the summands occurring in the formal linear combination `f`. -/\ndef eval : universal_map m n \u2192+ \u2124[A^m] \u2192+ \u2124[A^n] :=\nfree_abelian_group.lift $ \u03bb (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 \u2192+ universal_map l m \u2192+ universal_map l n :=\nfree_abelian_group.lift $ \u03bb (g : basic_universal_map m n), free_abelian_group.lift $ \u03bb 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 : \u2115) : 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 : \u2115 := \u2211 g in f.support, (free_abelian_group.coeff g f).nat_abs\n\ndef bound_by (N : \u2115) : Prop := f.bound \u2264 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 : \u2115) : (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 : \u2115}\n  (hf : f.bound_by N) (s : finset (basic_universal_map m n)) :\n  \u2211 g in s, (free_abelian_group.coeff g f).nat_abs \u2264 N :=\nbegin\n  calc \u2211 g in s, (free_abelian_group.coeff g f).nat_abs\n      = \u2211 g in s \u2229 f.support, (free_abelian_group.coeff g f).nat_abs +\n        \u2211 g in s \\ f.support, (free_abelian_group.coeff g f).nat_abs : _\n  ... = \u2211 g in s \u2229 f.support, (free_abelian_group.coeff g f).nat_abs : _\n  ... \u2264 \u2211 g in f.support \u2229 s, (free_abelian_group.coeff g f).nat_abs +\n        \u2211 g in f.support \\ s, (free_abelian_group.coeff g f).nat_abs : _\n  ... \u2264 \u2211 g in f.support, (free_abelian_group.coeff g f).nat_abs : _\n  ... \u2264 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\u2081 f\u2082 : universal_map m n} {N\u2081 N\u2082 : \u2115}\n  (h\u2081 : f\u2081.bound_by N\u2081) (h\u2082 : f\u2082.bound_by N\u2082) :\n  (f\u2081 + f\u2082).bound_by (N\u2081 + N\u2082) :=\nbegin\n  calc (f\u2081 + f\u2082).bound \u2264\n      \u2211 (g : basic_universal_map m n) in support (f\u2081 + f\u2082),\n        ((coeff g f\u2081).nat_abs + (coeff g f\u2082).nat_abs) : finset.sum_le_sum _\n  ... \u2264 N\u2081 + N\u2082 : _,\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\u2081.random_index _) (h\u2082.random_index _) }\nend\n\nlemma bound_by_sum {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 universal_map m n) (N : \u03b9 \u2192 \u2115)\n  (h : \u2200 i \u2208 s, (f i).bound_by (N i)) :\n  (\u2211 i in s, f i).bound_by (\u2211 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 $ \u03bb 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 \u2297 _`.\n-/\n\ndef mul (N : \u2115) : universal_map m n \u2192+ universal_map (N * m) (N * n) :=\nmap (basic_universal_map.mul N)\n\nlemma mul_of (N : \u2115) (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 : \u2115) (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 [\u2190 add_monoid_hom.comp_apply],\n  rw [\u2190 add_monoid_hom.comp_hom_apply_apply, \u2190 add_monoid_hom.comp_hom_apply_apply,\n    \u2190 add_monoid_hom.comp_hom_apply_apply,\n    \u2190 add_monoid_hom.flip_apply _ _ (mul N)],\n  simp only [\u2190 add_monoid_hom.comp_apply],\n  rw [\u2190 add_monoid_hom.comp_hom_apply_apply, \u2190 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 : \u2115) (hN : 0 < N) (f : universal_map m n) (g) :\n  g \u2208 (mul N f).support \u2194 \u2203 g', g' \u2208 f.support \u2227 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 : \u2115) (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 [\u2190 add_monoid_hom.comp_apply],\n  rw [\u2190 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 `\ud835\udfed _`.\n-/\n\ndef sum (n N : \u2115) : universal_map (N * n) n :=\nof (\u2211 i, basic_universal_map.proj n i)\n\ndef proj (n N : \u2115) : universal_map (N * n) n :=\n\u2211 i, of (basic_universal_map.proj n i)\n\nlemma sum_comp_mul (N : \u2115) (f : universal_map m n) :\n  comp (sum n N) (mul N f) = comp f (sum m N) :=\nbegin\n  simp only [\u2190 add_monoid_hom.comp_apply],\n  rw [\u2190 add_monoid_hom.comp_hom_apply_apply, \u2190 add_monoid_hom.flip_apply _ _ (sum m N)],\n  simp only [\u2190 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 : \u2115) (f : universal_map m n) :\n  comp (proj n N) (mul N f) = comp f (proj m N) :=\nbegin\n  simp only [\u2190 add_monoid_hom.comp_apply],\n  rw [\u2190 add_monoid_hom.comp_hom_apply_apply, \u2190 add_monoid_hom.flip_apply _ _ (proj m N)],\n  simp only [\u2190 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 : \u2115) : (proj n N).bound_by N :=\nle_trans (bound_by_sum _ _ _ $ \u03bb 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 : \u2115 \u2192 Prop\nvariable P : \u2115 \u2192 Prop\n\n-- these next five are things that tauto doesn't get\n\nexample : (\u2200 x, P x) \u2227 b \u2192 (\u2200 y, P y) \u2227 P 0 \u2228 b \u2227 P 0 := by finish\nexample : (\u2200 A, A \u2228 \u00acA) \u2192 \u2200 x y : \u2115, x = y \u2228 x \u2260 y := by finish\nexample : \u2200 b1 b2, b1 = b2 \u2194 (b1 = tt \u2194 b2 = tt) := begin intro b1, cases b1; finish [iff_def] end\n\nexample : \u2200 (P Q : nat \u2192 Prop), (\u2200 n, Q n \u2192 P n) \u2192 (\u2200 n, Q n) \u2192 P 2 := by finish\nexample (a b c : Prop) : \u00ac true \u2228 false \u2228 b \u2194 b := by finish\n\nexample : true := by finish\n\nexample : false \u2192 a := by finish\nexample : a \u2192 a := by finish\nexample : (a \u2192 b) \u2192 a \u2192 b := by finish\nexample : \u00ac a \u2192 \u00ac a := by finish\nexample : a \u2192 (false \u2228 a) := by finish\nexample : (a \u2192 b \u2192 c) \u2192 (a \u2192 b) \u2192 a \u2192 c := by finish\nexample : a \u2192 \u00ac a \u2192 (a \u2192 b) \u2192 (a \u2228 b) \u2192 (a \u2227 b) \u2192 a \u2192 false := by finish\nexample : ((a \u2227 b) \u2227 c) \u2192 b := by finish\nexample : ((a \u2192 b) \u2192 c) \u2192 b \u2192 c := by finish\nexample : (a \u2228 b) \u2192 (b \u2228 a) := by finish\nexample : (a \u2192 b \u2227 c) \u2192 (a \u2192 b) \u2228 (a \u2192 c) := by finish\nexample : \u2200 (x0 : a \u2228 b) (x1 : b \u2227 c), a \u2192 b := by finish\nexample : a \u2192 b \u2192 (c \u2228 b) := by finish\nexample : (a \u2227 b \u2192 c) \u2192 b \u2192 a \u2192 c := by finish\nexample : (a \u2228 b \u2192 c) \u2192 a \u2192 c := by finish\nexample : (a \u2228 b \u2192 c) \u2192 b \u2192 c := by finish\nexample : (a \u2227 b) \u2192 (b \u2227 a) := by finish\nexample : (a \u2194 b) \u2192 a \u2192 b := by finish\nexample : a \u2192 \u00ac\u00aca := by finish\nexample : \u00ac\u00ac(a \u2228 \u00aca) := by finish\nexample : \u00ac\u00ac(a \u2228 b \u2192 a \u2228 b) := by finish\nexample : \u00ac\u00ac((\u2200 n, even n) \u2228 \u00ac(\u2200 m, even m)) := by finish\nexample : (\u00ac\u00acb \u2192 b) \u2192 (a \u2192 b) \u2192 \u00ac\u00aca \u2192 b := by finish\nexample : (\u00ac\u00acb \u2192 b) \u2192 (\u00acb \u2192 \u00ac a) \u2192 \u00ac\u00aca \u2192 b := by finish\n\nexample : ((a \u2192 b \u2192 false) \u2192 false) \u2192 (b \u2192 false) \u2192 false := by finish\n\nexample : ((((c \u2192 false) \u2192 a) \u2192 ((b \u2192 false) \u2192 a) \u2192 false) \u2192 false) \u2192\n            (((c \u2192 b \u2192 false) \u2192 false) \u2192 false) \u2192 \u00aca \u2192 a := by finish\n\nexample (p q r : Prop) (a b : nat) : true \u2192 a = a \u2192 q \u2192 q \u2192 p \u2192 p := by finish\nexample : \u2200 (F F' : Prop), F \u2227 F' \u2192 F := by finish\nexample : \u2200 (F1 F2 F3 : Prop), ((\u00acF1 \u2227 F3) \u2228 (F2 \u2227 \u00acF3)) \u2192 (F2 \u2192 F1) \u2192 (F2 \u2192 F3) \u2192  \u00acF2 := by finish\nexample : \u2200 (f : nat \u2192 Prop), f 2 \u2192 \u2203 x, f x := by finish\nexample : true \u2227 true \u2227 true \u2227 true \u2227 true \u2227 true \u2227 true := by finish\nexample : \u2200 (P : nat \u2192 Prop), P 0 \u2192 (P 0 \u2192 P 1) \u2192 (P 1 \u2192 P 2) \u2192 (P 2) := by finish\nexample : \u00ac\u00ac\u00ac\u00ac\u00aca \u2192 \u00ac\u00ac\u00ac\u00ac\u00ac\u00ac\u00ac\u00aca \u2192 false := by finish\nexample : \u2200 n, \u00ac\u00ac(even n \u2228 \u00aceven n) := by finish\nexample : \u2200 (p q r s : Prop) (a b : nat), r \u2228 s \u2192 p \u2228 q \u2192 a = b \u2192 q \u2228 p := by finish\nexample : (\u2200 x, P x) \u2192 (\u2200 y, P y) := by finish\n\n/- TODO(Jeremy): reinstate after simp * at * bug is fixed.\nexample : ((a \u2194 b) \u2192 (b \u2194 c)) \u2192 ((b \u2194 c) \u2192 (c \u2194 a)) \u2192 ((c \u2194 a) \u2192 (a \u2194 b)) \u2192 (a \u2194 b) :=\nby finish [iff_def]\n-/\n\nexample : ((\u00aca \u2228 b) \u2227 (\u00acb \u2228 b) \u2227 (\u00aca \u2228 \u00acb) \u2227 (\u00acb \u2228 \u00acb) \u2192 false) \u2192 \u00ac((a \u2192 b) \u2192 b) \u2192 false := by finish\n\nexample : \u00ac((a \u2192 b) \u2192 b) \u2192 ((\u00acb \u2228 \u00acb) \u2227 (\u00acb \u2228 \u00aca) \u2227 (b \u2228 \u00acb) \u2227 (b \u2228 \u00aca) \u2192 false) \u2192 false := by finish\nexample : (\u00aca \u2194 b) \u2192 (\u00acb \u2194 a) \u2192 (\u00ac\u00aca \u2194 a) := by finish\n\nexample : (\u00ac a \u2194 b) \u2192 (\u00ac (c \u2228 e) \u2194 d \u2227 f) \u2192 (\u00ac (c \u2228 a \u2228 e) \u2194 d \u2227 b \u2227 f) := by finish\n\nexample {A : Type} (p q : A \u2192 Prop) (a b : A) : q a \u2192 p b \u2192 \u2203 x, (p x \u2227 x = b) \u2228 q x := by finish\n\nexample {A : Type} (p q : A \u2192 Prop) (a b : A) : p b \u2192 \u2203 x, q x \u2228 (p x \u2227 x = b) := by finish\n\nexample : \u00ac a \u2192 b \u2192 a \u2192 c := by finish\nexample : a \u2192 b \u2192 b \u2192 \u00ac a \u2192 c := by finish\nexample (a b : nat) : a = b \u2192 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 \u2192 a = c \u2192 b = c := by finish\nexample (p : nat \u2192 Prop) (a b c : nat) : a = b \u2192 a = c \u2192 p b \u2192 p c := by finish\n\nexample (p : Prop) (a b : nat) : a = b \u2192 p \u2192 p := by finish\n\n-- safe should look for contradictions with constructors\nexample (a : nat) : (0 : \u2115) = succ a \u2192 a = a \u2192 false := by finish\nexample (p : Prop) (a b c : nat) : [a, b, c] = [] \u2192 p := by finish\n\nexample (a b c : nat) : succ (succ a) = succ (succ b) \u2192 c = c := by finish\nexample (p : Prop) (a b : nat) : a = b \u2192 b \u2260 a \u2192 p := by finish\nexample : (a \u2194 b) \u2192 ((b \u2194 a) \u2194 (a \u2194 b)) := by finish\nexample (a b c : nat) : b = c \u2192 (a = b \u2194 c = a) := by finish [iff_def]\nexample : \u00ac\u00ac\u00ac\u00ac\u00ac\u00ac\u00ac\u00aca \u2192 \u00ac\u00ac\u00ac\u00ac\u00aca \u2192 false := by finish\nexample (a b c : Prop) : a \u2227 b \u2227 c \u2194 c \u2227 b \u2227 a := by finish\nexample (a b c : Prop) : a \u2227 false \u2227 c \u2194 false := by finish\nexample (a b c : Prop) : a \u2228 false \u2228 b \u2194 b \u2228 a := by finish\nexample : a \u2227 not a \u2194 false := by finish\nexample : a \u2227 b \u2227 true \u2192 b \u2227 a := by finish\nexample (A : Type) (a\u2081 a\u2082 : A) : a\u2081 = a\u2082 \u2192\n  (\u03bb (B : Type) (f : A \u2192 B), f a\u2081) = (\u03bb (B : Type) (f : A \u2192 B), f a\u2082) := by finish\nexample (a : nat) : \u00ac a = a \u2192 false := by finish\nexample (A : Type) (p : Prop) (a b c : A) : a = b \u2192 b \u2260 a \u2192 p := by finish\nexample (p q r s : Prop) : r \u2227 s \u2192 p \u2227 q \u2192 q \u2227 p := by finish\nexample (p q : Prop) : p \u2227 p \u2227 q \u2227 q \u2192 q \u2227 p := by finish\nexample (p : nat \u2192 Prop) (q : nat \u2192 nat \u2192 Prop) :\n  (\u2203 x y, p x \u2227 q x y) \u2192 q 0 0 \u2227 q 1 1 \u2192 (\u2203 x, p x) := by finish\nexample (p q r s : Prop) (a b : nat) : r \u2228 s \u2192 p \u2228 q \u2192 a = b \u2192 q \u2228 p := by finish\nexample (p q r : Prop) (a b : nat) : true \u2192 a = a \u2192 q \u2192 q \u2192 p \u2192 p := by finish\nexample (a b : Prop) : a \u2192 b \u2192 a := by finish\nexample (p q : nat \u2192 Prop) (a b : nat) : p a \u2192 q b \u2192 \u2203 x, p x := by finish\n\nexample : \u2200 b1 b2, b1 && b2 = ff \u2194 (b1 = ff \u2228 b2 = ff) := by finish\nexample : \u2200 b1 b2, b1 && b2 = tt \u2194 (b1 = tt \u2227 b2 = tt) := by finish\nexample : \u2200 b1 b2, b1 || b2 = ff \u2194 (b1 = ff \u2227 b2 = ff) := by finish\nexample : \u2200 b1 b2, b1 || b2 = tt \u2194 (b1 = tt \u2228 b2 = tt) := by finish\nexample : \u2200 b, bnot b = tt \u2194 b = ff := by finish\nexample : \u2200 b, bnot b = ff \u2194 b = tt := by finish\nexample : \u2200 b c, b = c \u2194 \u00ac (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 \u2192 b \u2192 c \u2192 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 \u2192 or3\n| in2 : b \u2192 or3\n| in3 : c \u2192 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\u2081 A\u2082 A\u2083 A\u2084 B\u2081 B\u2082 B\u2083 B\u2084 : Prop)\n-- H first, all pos\n\nexample (H1 : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084)\n  (a1 : A\u2081) (a2 : A\u2082) (a3 : A\u2083) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) : B\u2084 := by finish\nexample (H1 : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084)\n  (a1 : A\u2081) (a2 : A\u2082) (a3 : A\u2083) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2084) : B\u2083 := by finish\nexample (H1 : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084)\n  (a1 : A\u2081) (a2 : A\u2082) (a3 : A\u2083) (n1 : \u00acB\u2081) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084) : B\u2082 := by finish\nexample (H1 : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084)\n  (a1 : A\u2081) (a2 : A\u2082) (a3 : A\u2083) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084) : B\u2081 := by finish\n\nexample (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084)\n  (a1 : A\u2081) (a2 : A\u2082) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084) : \u00acA\u2083 := by finish\nexample (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084)\n  (a1 : A\u2081) (a3 : A\u2083) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084) : \u00acA\u2082 := by finish\nexample (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084)\n  (a2 : A\u2082) (a3 : A\u2083) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084) : \u00acA\u2081 := by finish\n\n-- H last, all pos\nexample (a1 : A\u2081) (a2 : A\u2082) (a3 : A\u2083) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083)\n  (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084) : B\u2084 := by finish\nexample (a1 : A\u2081) (a2 : A\u2082) (a3 : A\u2083) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2084)\n  (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084) : B\u2083 := by finish\nexample (a1 : A\u2081) (a2 : A\u2082) (a3 : A\u2083) (n1 : \u00acB\u2081) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084)\n  (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084) : B\u2082 := by finish\nexample (a1 : A\u2081) (a2 : A\u2082) (a3 : A\u2083) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084)\n  (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084) : B\u2081 := by finish\n\nexample (a1 : A\u2081) (a2 : A\u2082) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084)\n  (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084) : \u00acA\u2083 := by finish\nexample (a1 : A\u2081) (a3 : A\u2083) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084)\n  (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084) : \u00acA\u2082 := by finish\nexample (a2 : A\u2082) (a3 : A\u2083) (n1 : \u00acB\u2081) (n2 : \u00acB\u2082) (n3 : \u00acB\u2083) (n3 : \u00acB\u2084)\n  (H : A\u2081 \u2192 A\u2082 \u2192 A\u2083 \u2192 B\u2081 \u2228 B\u2082 \u2228 B\u2083 \u2228 B\u2084) : \u00acA\u2081 := by finish\n\n-- H first, all neg\nexample (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084)\n  (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b1 : B\u2081) (b2 : B\u2082) (b3 : B\u2083) : \u00acB\u2084 := by finish\nexample (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084)\n  (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b1 : B\u2081) (b2 : B\u2082) (b4 : B\u2084) : \u00acB\u2083 := by finish\nexample (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084)\n  (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b1 : B\u2081) (b3 : B\u2083) (b4 : B\u2084) : \u00acB\u2082 := by finish\nexample (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084)\n  (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b2 : B\u2082) (b3 : B\u2083) (b4 : B\u2084) : \u00acB\u2081 := by finish\n\nexample (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084)\n  (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (b1 : B\u2081) (b2 : B\u2082) (b3 : B\u2083) (b4 : B\u2084) : \u00ac\u00acA\u2083 := by finish\nexample (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084)\n  (n1 : \u00acA\u2081) (n3 : \u00acA\u2083) (b1 : B\u2081) (b2 : B\u2082) (b3 : B\u2083) (b4 : B\u2084) : \u00ac\u00acA\u2082 := by finish\nexample (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084)\n  (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b1 : B\u2081) (b2 : B\u2082) (b3 : B\u2083) (b4 : B\u2084) : \u00ac\u00acA\u2081 := by finish\n\n-- H last, all neg\nexample (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b1 : B\u2081) (b2 : B\u2082) (b3 : B\u2083)\n  (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084) : \u00acB\u2084 := by finish\nexample (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b1 : B\u2081) (b2 : B\u2082) (b4 : B\u2084)\n  (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084) : \u00acB\u2083 := by finish\nexample (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b1 : B\u2081) (b3 : B\u2083) (b4 : B\u2084)\n  (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084) : \u00acB\u2082 := by finish\nexample (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b2 : B\u2082) (b3 : B\u2083) (b4 : B\u2084)\n  (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084) : \u00acB\u2081 := by finish\n\nexample (n1 : \u00acA\u2081) (n2 : \u00acA\u2082) (b1 : B\u2081) (b2 : B\u2082) (b3 : B\u2083) (b4 : B\u2084)\n  (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084) : \u00ac\u00acA\u2083 := by finish\nexample (n1 : \u00acA\u2081) (n3 : \u00acA\u2083) (b1 : B\u2081) (b2 : B\u2082) (b3 : B\u2083) (b4 : B\u2084)\n  (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084) : \u00ac\u00acA\u2082 := by finish\nexample (n2 : \u00acA\u2082) (n3 : \u00acA\u2083) (b1 : B\u2081) (b2 : B\u2082) (b3 : B\u2083) (b4 : B\u2084)\n  (H : \u00acA\u2081 \u2192 \u00acA\u2082 \u2192 \u00acA\u2083 \u2192 \u00acB\u2081 \u2228 \u00acB\u2082 \u2228 \u00acB\u2083 \u2228 \u00acB\u2084) : \u00ac\u00acA\u2081 := by finish\n\nsection club\nvariables Scottish RedSocks WearKilt Married GoOutSunday : Prop\ntheorem NoMember : (\u00acScottish \u2192 RedSocks) \u2192 (WearKilt \u2228 \u00acRedSocks) \u2192 (Married \u2192 \u00acGoOutSunday) \u2192\n                 (GoOutSunday \u2194 Scottish) \u2192 (WearKilt \u2192 Scottish \u2227 Married) \u2192\n                 (Scottish \u2192 WearKilt) \u2192 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 {\u03b1 \u03b2 : 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 \u00d7 X\n#align Bipointed Bipointed\n\nnamespace Bipointed\n\ninstance : CoeSort Bipointed (Type _) :=\n  \u27e8X\u27e9\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 \u00d7 X) : Bipointed :=\n  \u27e8X, to_prod\u27e9\n#align Bipointed.of Bipointed.of\n\n@[simp]\ntheorem coe_of {X : Type _} (to_prod : X \u00d7 X) : \u21a5(of to_prod) = X :=\n  rfl\n#align Bipointed.coe_of Bipointed.coe_of\n\nalias of \u2190 _root_.Prod.Bipointed\n#align prod.Bipointed Prod.Bipointed\n\ninstance : Inhabited Bipointed :=\n  \u27e8of ((), ())\u27e9\n\n/-- Morphisms in `Bipointed`. -/\n@[ext]\nprotected structure Hom (X Y : Bipointed.{u}) : Type u where\n  toFun : X \u2192 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  \u27e8id, rfl, rfl\u27e9\n#align Bipointed.hom.id Bipointed.Hom.id\n\ninstance (X : Bipointed) : Inhabited (Bipointed.Hom X X) :=\n  \u27e8id X\u27e9\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  \u27e8g.toFun \u2218 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]\u27e9\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 := \u27e8@Hom.ext\u27e9\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 \u2964 Bipointed where\n  obj X := \u27e8X, X.toProd.swap\u27e9\n  map f := \u27e8f.toFun, f.map_snd, f.map_fst\u27e9\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 \u224c Bipointed :=\n  CategoryTheory.Equivalence.mk swap swap\n    (NatIso.ofComponents\n      (fun X =>\n        { hom := \u27e8id, rfl, rfl\u27e9\n          inv := \u27e8id, rfl, rfl\u27e9 })\n      fun f => rfl)\n    (NatIso.ofComponents\n      (fun X =>\n        { hom := \u27e8id, rfl, rfl\u27e9\n          inv := \u27e8id, rfl, rfl\u27e9 })\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 \u2964 Pointed where\n  obj X := \u27e8X, X.toProd.1\u27e9\n  map f := \u27e8f.toFun, f.map_fst\u27e9\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 \u2964 Pointed where\n  obj X := \u27e8X, X.toProd.2\u27e9\n  map f := \u27e8f.toFun, f.map_snd\u27e9\n#align Bipointed_to_Pointed_snd bipointedToPointedSnd\n\n@[simp]\ntheorem bipointedToPointedFst_comp_forget :\n    bipointedToPointedFst \u22d9 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 \u22d9 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 \u22d9 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 \u22d9 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} \u2964 Bipointed where\n  obj X := \u27e8X, X.point, X.point\u27e9\n  map f := \u27e8f.toFun, f.map_point, f.map_point\u27e9\n#align Pointed_to_Bipointed pointedToBipointed\n\n/-- The functor from `Pointed` to `Bipointed` which adds a second point. -/\ndef pointedToBipointedFst : Pointed.{u} \u2964 Bipointed where\n  obj X := \u27e8Option X, X.point, none\u27e9\n  map f := \u27e8Option.map f.toFun, congr_arg _ f.map_point, rfl\u27e9\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} \u2964 Bipointed where\n  obj X := \u27e8Option X, none, X.point\u27e9\n  map f := \u27e8Option.map f.toFun, rfl, congr_arg _ f.map_point\u27e9\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 \u22d9 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 \u22d9 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 \u22d9 bipointedToPointedFst \u2245 \ud835\udfed _ :=\n  NatIso.ofComponents\n    (fun X =>\n      { hom := \u27e8id, rfl\u27e9\n        inv := \u27e8id, rfl\u27e9 })\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 \u22d9 bipointedToPointedSnd \u2245 \ud835\udfed _ :=\n  NatIso.ofComponents\n    (fun X =>\n      { hom := \u27e8id, rfl\u27e9\n        inv := \u27e8id, rfl\u27e9 })\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 \u22a3 bipointedToPointedFst :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f => \u27e8f.toFun \u2218 Option.some, f.map_fst\u27e9\n          invFun := fun f => \u27e8fun o => o.elim Y.toProd.2 f.toFun, f.map_point, rfl\u27e9\n          left_inv := fun f => by\n            apply Bipointed.Hom.ext\n            funext x\n            cases x\n            \u00b7 exact f.map_snd.symm\n            \u00b7 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 \u22a3 bipointedToPointedSnd :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f => \u27e8f.toFun \u2218 Option.some, f.map_snd\u27e9\n          invFun := fun f => \u27e8fun o => o.elim Y.toProd.1 f.toFun, rfl, f.map_point\u27e9\n          left_inv := fun f => by\n            apply Bipointed.Hom.ext\n            funext x\n            cases x\n            \u00b7 exact f.map_fst.symm\n            \u00b7 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 {\u03b1 \u03b2 : Type _} {n : \u2115}\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\u2093'. -/\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  \u00b7 refine' cases _ _ i\n    \u00b7 rintro \u27e8\u27e8\u27e9\u27e9\n    \u00b7 intro j _\n      exact \u27e8j, rfl\u27e9\n  \u00b7 rintro \u27e8i, _, rfl\u27e9\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\u2093'. -/\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\u2093'. -/\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  \u00b7 refine' cases _ _ i\n    \u00b7 rintro \u27e8\u27e8\u27e9\u27e9\n    \u00b7 intro i hi\n      refine' \u27e8i, succ_lt_succ_iff.mp hi, rfl\u27e9\n  \u00b7 rintro \u27e8i, hi, rfl\u27e9\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\u2093'. -/\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'\u2093'. -/\ntheorem card_filter_univ_succ' (p : Fin (n + 1) \u2192 Prop) [DecidablePred p] :\n    (univ.filter\u2093 p).card = ite (p 0) 1 0 + (univ.filter\u2093 (p \u2218 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\u2093'. -/\ntheorem card_filter_univ_succ (p : Fin (n + 1) \u2192 Prop) [DecidablePred p] :\n    (univ.filter\u2093 p).card =\n      if p 0 then (univ.filter\u2093 (p \u2218 Fin.succ)).card + 1 else (univ.filter\u2093 (p \u2218 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 \u03b1] (a : \u03b1) (v : Vector \u03b1 n) :\n    (univ.filter\u2093 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  \u00b7 simp\n  \u00b7\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] {\u0393: cx t} {x: var} {v v': t}:\n  cx.lookup \u0393 x v ->\n  cx.lookup \u0393 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 \u2260 cx_elem.mk x v' := begin\n    intro h1,\n    simp at h1,\n    exact h h1,\n  end,\n  let hm := \u0393.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} (\u0393: cx t) (x: var) (v: t):\n  cx.lookup (cx.insert \u0393 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} {\u0393: cx t} {x y: var} {vy v: t}:\n  x \u2260 y ->\n  (cx.lookup (cx.insert \u0393 y vy) x v \u2194 cx.lookup \u0393 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} {\u0393 \u0393': cx t}:\n  \u0393.entries = \u0393'.entries -> \u0393 = \u0393' :=\nbegin\n  cases \u0393,\n  cases \u0393',\n  simp,\n  intro h,\n  exact h,\nend\n\ntheorem useless_insert_twice {t: Type}\n  (\u0393: cx t) (x: var) (v v': t):\n  cx.insert (cx.insert \u0393 x v') x v = cx.insert \u0393 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': \u00ac \u00ac (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 \u2260 x) hm',\n  rw union_emp,\n  rw double_pred,\nend\n\ntheorem insert_comm' {t: Type}\n  {\u0393: cx t} {x y: var} {vx vy: t} {a: cx_elem t}:\n  x \u2260 y ->\n  a \u2208 (cx.insert (cx.insert \u0393 y vy) x vx).entries ->\n  a \u2208 (cx.insert (cx.insert \u0393 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  (\u0393: cx t) (x y: var) (vx vy: t) (h: x \u2260 y):\n  cx.insert (cx.insert \u0393 y vy) x vx =\n  cx.insert (cx.insert \u0393 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\u00e9my Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: R\u00e9my 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 : \u03b9 \u2192 \u03b1 \u2192 \u03b2` with hypothesis\n`hf : \u2200 i, ae_measurable (f i) \u03bc`, and a pointwise property `p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop` such that we\nhave `hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb 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* `\u03bc (ae_seq_set hf p)\u1d9c = 0`\n* `x \u2208 ae_seq_set hf p \u2192 \u2200 i : \u03b9, ae_seq hf hp i x = f i x`\n* `x \u2208 ae_seq_set hf p \u2192 p x (\u03bb n, f n x)`\n-/\n\nopen measure_theory\nopen_locale classical\n\nvariables {\u03b1 \u03b2 \u03b3 \u03b9 : Type*} [measurable_space \u03b1] [measurable_space \u03b2]\n  {f : \u03b9 \u2192 \u03b1 \u2192 \u03b2} {\u03bc : measure \u03b1} {p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop}\n\n/-- If we have the additional hypothesis `\u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)`, this is a measurable set\nwhose complement has measure 0 such that for all `x \u2208 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 (\u03bb n, f n x)`. -/\ndef ae_seq_set (hf : \u2200 i, ae_measurable (f i) \u03bc) (p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop) : set \u03b1 :=\n(to_measurable \u03bc {x | (\u2200 i, f i x = (hf i).mk (f i) x) \u2227 p x (\u03bb n, f n x)}\u1d9c)\u1d9c\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 : \u2200 i, ae_measurable (f i) \u03bc) (p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop) : \u03b9 \u2192 \u03b1 \u2192 \u03b2 :=\n\u03bb i x, ite (x \u2208 ae_seq_set hf p) ((hf i).mk (f i) x) (\u27e8f i x\u27e9 : nonempty \u03b2).some\n\nnamespace ae_seq\n\nsection mem_ae_seq_set\n\nlemma mk_eq_fun_of_mem_ae_seq_set (hf : \u2200 i, ae_measurable (f i) \u03bc) {x : \u03b1}\n  (hx : x \u2208 ae_seq_set hf p) (i : \u03b9) :\n  (hf i).mk (f i) x = f i x :=\nbegin\n  have h_ss : ae_seq_set hf p \u2286 {x | \u2200 i, f i x = (hf i).mk (f i) x},\n  { rw [ae_seq_set, \u2190compl_compl {x | \u2200 i, f i x = (hf i).mk (f i) x}, set.compl_subset_compl],\n    refine set.subset.trans (set.compl_subset_compl.mpr (\u03bb 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 : \u2200 i, ae_measurable (f i) \u03bc) {x : \u03b1}\n  (hx : x \u2208 ae_seq_set hf p) (i : \u03b9) :\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 : \u2200 i, ae_measurable (f i) \u03bc) {x : \u03b1}\n  (hx : x \u2208 ae_seq_set hf p) (i : \u03b9) :\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 : \u2200 i, ae_measurable (f i) \u03bc)\n  {x : \u03b1} (hx : x \u2208 ae_seq_set hf p) :\n  p x (\u03bb n, ae_seq hf p n x) :=\nbegin\n  simp only [ae_seq, hx, if_true],\n  rw funext (\u03bb n, mk_eq_fun_of_mem_ae_seq_set hf hx n),\n  have h_ss : ae_seq_set hf p \u2286 {x | p x (\u03bb n, f n x)},\n  { rw [\u2190compl_compl {x | p x (\u03bb 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 \u03bb 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 : \u2200 i, ae_measurable (f i) \u03bc)\n  {x : \u03b1} (hx : x \u2208 ae_seq_set hf p) :\n  p x (\u03bb n, f n x) :=\nbegin\n  have h_eq : (\u03bb n, f n x) = \u03bb n, ae_seq hf p n x,\n    from funext (\u03bb 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 : \u2200 i, ae_measurable (f i) \u03bc} :\n  measurable_set (ae_seq_set hf p) :=\n(measurable_set_to_measurable _ _).compl\n\nlemma measurable (hf : \u2200 i, ae_measurable (f i) \u03bc) (p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop)\n  (i : \u03b9) :\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\u03b1 : nonempty \u03b1,\n  { exact @measurable_const _ _ _ _ (\u27e8f i h\u03b1.some\u27e9 : nonempty \u03b2).some },\n  { exact measurable_of_not_nonempty h\u03b1 _ }\nend\n\nlemma measure_compl_ae_seq_set_eq_zero [encodable \u03b9] (hf : \u2200 i, ae_measurable (f i) \u03bc)\n  (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) :\n  \u03bc (ae_seq_set hf p)\u1d9c = 0 :=\nbegin\n  rw [ae_seq_set, compl_compl, measure_to_measurable],\n  have hf_eq := \u03bb i, (hf i).ae_eq_mk,\n  simp_rw [filter.eventually_eq, \u2190ae_all_iff] at hf_eq,\n  exact filter.eventually.and hf_eq hp,\nend\n\nlemma ae_seq_eq_mk_ae [encodable \u03b9] (hf : \u2200 i, ae_measurable (f i) \u03bc)\n  (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) :\n  \u2200\u1d50 (a : \u03b1) \u2202\u03bc, \u2200 (i : \u03b9), ae_seq hf p i a = (hf i).mk (f i) a :=\nbegin\n  have h_ss : ae_seq_set hf p \u2286 {a : \u03b1 | \u2200 i, ae_seq hf p i a = (hf i).mk (f i) a},\n    from \u03bb 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 \u03b9] (hf : \u2200 i, ae_measurable (f i) \u03bc)\n  (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) :\n  \u2200\u1d50 (a : \u03b1) \u2202\u03bc, \u2200 (i : \u03b9), ae_seq hf p i a = f i a :=\nbegin\n  have h_ss : {a : \u03b1 | \u00ac\u2200 (i : \u03b9), ae_seq hf p i a = f i a} \u2286 (ae_seq_set hf p)\u1d9c,\n    from \u03bb x, mt (\u03bb 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 \u03b9] (hf : \u2200 i, ae_measurable (f i) \u03bc)\n  (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) (n : \u03b9) :\n  ae_seq hf p n =\u1d50[\u03bc] f n:=\nae_all_iff.mp (ae_seq_eq_fun_ae hf hp) n\n\nlemma supr [complete_lattice \u03b2] [encodable \u03b9]\n  (hf : \u2200 i, ae_measurable (f i) \u03bc) (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) :\n  (\u2a06 n, ae_seq hf p n) =\u1d50[\u03bc] \u2a06 n, f n :=\nbegin\n  simp_rw [filter.eventually_eq, ae_iff, supr_apply],\n  have h_ss : ae_seq_set hf p \u2286 {a : \u03b1 | (\u2a06 (i : \u03b9), ae_seq hf p i a) = \u2a06 (i : \u03b9), f i a},\n  { intros x hx,\n    congr,\n    exact funext (\u03bb 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 \u2192 (p \u2192 q) \u2192 (q \u2192 r) \u2192 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 \u2192 (p \u2192 q) \u2192 (q \u2192 r) \u2192 r := by\nintro _ h1 h2;\napply h2;\napply h1;\nexact a_1 -- error \"unknown identifier\"\n\ntheorem ex3 {a p q r : Prop} : p \u2192 (p \u2192 q) \u2192 (q \u2192 r) \u2192 r := by\nintro _ h1 h2;\napply h2;\napply h1;\nassumption\n\nexample {p q : Prop} (h\u2081 : p \u2192 q) (h\u2082 : p \u2228 q) : q := by\n  cases h\u2082;\n  { apply h\u2081; exact h }; -- error \"unknown identifier\"\n  exact h\n\nset_option tactic.hygienic false in\nexample {p q : Prop} (h\u2081 : p \u2192 q) (h\u2082 : p \u2228 q) : q := by\ncases h\u2082;\n{ apply h\u2081; exact h }; -- hygiene is disabled\nexact h\n\n-- Hygienic versions\nexample {p q : Prop} (h\u2081 : p \u2192 q) (h\u2082 : p \u2228 q) : q := by\ncases h\u2082 with\n| inl h => apply h\u2081; exact h\n| inr h => exact h\n\nexample {p q : Prop} (h\u2081 : p \u2192 q) (h\u2082 : p \u2228 q) : q := by\ncases h\u2082;\n{ apply h\u2081; assumption };\nassumption\n\nexample {p q : Prop} (h\u2081 : p \u2192 q) (h\u2082 : p \u2228 q) : q := by\nmatch h\u2082 with\n| Or.inl _ => apply h\u2081; assumption\n| Or.inr h => exact h\n\nexample {p q : Prop} (h\u2081 : p \u2192 q) (h\u2082 : p \u2228 q) : q := by unhygienic\n  cases h\u2082\n  { apply h\u2081; 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": "import .prop data.buffer.parser\n\nopen parser\n\nnamespace prop\n\nnamespace parser\n\nclass has_vars (\u03b1 : Type) :=\n(var : string \u2192 \u03b1)\n\ninstance : has_vars symb :=\n\u27e8symb.atom\u27e9\n\nvariables {\u03b1 : Type} [is_symb \u03b1] [has_vars \u03b1]\n\n-- whitespace\ndef Ws : parser unit :=\nmany' $ one_of' \" \\t\\x0d\\n\".to_list\n\n-- token\ndef tok (s : string) := str s >> Ws\n\n/-\n-- a variable: a, ..., z, A, ..., Z\ndef Var : parser nat := do \nc \u2190 sat (\u03bb x, _root_.true), \nWs,\nlet n := c.to_nat in\nif 65 \u2264 n \u2227 n \u2264 122 then \n  return n \nelse \n  parser.fail \"not a letter\"\n-/\n\n\ndef is_letter (c : char) :=\nlet n := c.to_nat in 65 \u2264 n \u2227 n \u2264 122\n\ninstance : decidable_pred is_letter := by { delta is_letter, apply_instance }\n\n-- a variable: a, ..., z, A, ..., Z\ndef Var : parser (exp \u03b1) := do \nc \u2190 sat is_letter, \nWs,\nreturn (@exp.cst _ $ has_vars.var _ c.to_string)\n\n-- an atom\ndef Atom : parser (exp \u03b1) := \n(tok \"\u22a4\" >> Ws >> return prop.true) <|>\n(tok \"\u22a5\" >> Ws >> return prop.false) <|>\nVar\n--(do n \u2190 Var, pure (exp.fvr \u03b1 n))\n\nsection formula\nparameters {\u03b2 : Type} [is_symb \u03b2] [has_vars \u03b2] (Form : parser (exp \u03b2))\n\ndef ParenForm : parser (exp \u03b2) :=\ntok \"(\" *> Form <* tok \")\" <* Ws\n    \ndef Form0 : parser (exp \u03b2) :=\n(fix $ \u03bb F, Atom <|> ParenForm <|> (do tok \"\u00ac\", f \u2190 F, pure (prop.not f))) <* Ws\n\ndef Form1 : parser (exp \u03b2) :=\nfix $ \u03bb F, do\n  l \u2190 Form0,\n  (do tok \"\u2227\",\n      r \u2190 F, \n      pure (prop.and l r)) <|>\n    pure l\n\ndef Form2 : parser (exp \u03b2) :=\nfix $ \u03bb F, do\n  l \u2190 Form1,\n  (do tok \"\u2228\",\n      r \u2190 F, \n      pure (prop.or l r)) <|>\n    pure l\n\ndef Form3 : parser (exp \u03b2) :=\nfix $ \u03bb F, do\n  l \u2190 Form2,\n  (do tok \"\u2192\",\n      r \u2190 F, \n      pure (prop.imp l r)) <|>\n    pure l\n\nend formula\n\ndef Form : parser (exp \u03b1) := do\nfix $ \u03bb F, Form3 F\n\ndef Sequent : parser (seq  \u03b1) := do\nl \u2190 sep_by (tok \",\") Form,\ntok \"\u22a2\",\nr \u2190 sep_by (tok \",\") Form,\nreturn (l, r)\n\n/-\ndef parse_prop_to_str (s : string) : string :=\nmatch parser.run (Form : parser (exp symb)) s.to_char_buffer with\n| (sum.inl error)  := error\n| (sum.inr result) := fml2str result\nend\n\ndef ex := parser.run (Form : parser (exp symb)) \"(p \u2227 \u00ac q) \u2192 r \u2228 s\".to_char_buffer\n\n#eval ex\n\ndef ex' := parse_prop_to_str \"(p \u2227 \u00ac q) \u2192 r \u2228 s\"\n\n#eval ex'\n-/\n\nsection\nopen lean\nopen lean.parser\nopen interactive\n\n/-\nmeta def mk_thm (s: string) : tactic unit :=\nlet S := (Sequent : parser (seq symb) in\nmatch parser.run S s.to_char_buffer with\n| (sum.inl error)  := do exact `(_root_.false)\n| (sum.inr sq) := do  exact `(thm sq)\nend\n\ndef thm_type (s : string) := Prop\n\nmeta def mk_thm' : tactic unit :=\ndo `(thm_type %%s) \u2190 target | failed,\n   ss \u2190 eval_expr string s,\n   mk_thm ss \n   \nnotation `!seq` s := (by mk_thm' : thm_type s)\n\n-/\n\n-- I don't know whether this is any better than the other method.\nreserve prefix `!seq `:100\n@[user_notation]\nmeta def sequent_macro (_ : parse $ tk \"!seq\") (s : string) : lean.parser pexpr :=\nlet S := (Sequent : _root_.parser (seq symb)) in\nmatch parser.run S s.to_char_buffer with\n| (sum.inl error)  := do pure ``(_root_.false)\n| (sum.inr sq) := do let sq' := `(sq) in pure ``(thm %%sq')\nend\n\nend\n\n/-\nexample : !seq \"p, q \u22a2 p\" :=\nbegin\n  apply thm.id\nend\n\nexample : !seq \"\u22a2 (p \u2192 q \u2192 r) \u2192 (p \u2192 q) \u2192 p \u2192 r\" :=\nbegin\n  showgoal,\n  apply thm.impr,\n  apply thm.impr,\n  apply thm.impr,\n  apply thm.rl 2, \n  apply thm.impl,\n  apply thm.rl 1, \n  apply thm.id,\n  apply thm.impl,\n  apply thm.impl,\n  apply thm.id,\n  apply thm.id,\n  apply thm.id,\n  showgoal\nend\n\nexample : !seq \"p \u2227 (q \u2192 \u00ac p) \u22a2 \u00ac q\" :=\nbegin\n  apply thm.andl,\n  showgoal\n  sorry\nend\n\ntheorem foo : !seq \"p \u2227 q \u22a2 q \u2227 p\" :=\nbegin\n  apply thm.andl,\n  apply thm.andr,\n  apply thm.rl 1,\n  apply thm.id,\n  apply thm.id, \n  showgoal\nend\n\n-/\n\nend parser\n\n\ndef pp_thm {l r : list (exp symb)} (p : thm (l, r)) : string :=\nsqt2str fml2str l r \n\nend prop", "meta": {"author": "avigad", "repo": "embed", "sha": "0e3612028d4039d29d06239ef03bc50576ca0f8b", "save_path": "github-repos/lean/avigad-embed", "path": "github-repos/lean/avigad-embed/embed-0e3612028d4039d29d06239ef03bc50576ca0f8b/src/parser.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300698514778, "lm_q2_score": 0.6825737214979745, "lm_q1q2_score": 0.47952856424275514}}
{"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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  have h1 : (G.colorable 2) \u2192 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)), from sorry,\n  have h2 : (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) \u2192 (G.colorable 2), from sorry,\n  show (G.colorable 2) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)), from sorry,\nend\n\n--OUTPUT 2\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  {\n    assume h1 : G.colorable 2,\n    have h2 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from sorry,\n    show (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)), from h2,\n  },\n  {\n    assume h1 : (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)),\n    have h2 : G.colorable 2, from sorry,\n    show G.colorable 2, from h2,\n  }\nend\n\n--OUTPUT 3\ntheorem bipartite_iff_two_colorable {V : Type*} (G : simple_graph V) [fintype V] : (G.colorable 2) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  have h1 : (G.colorable 2) \u2192 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)), from sorry,\n  have h2 : (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) \u2192 (G.colorable 2), from sorry,\n  show (G.colorable 2) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)), 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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.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.7025300449389326, "lm_q2_score": 0.6825737279551494, "lm_q1q2_score": 0.4795285517744658}}
{"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 `\u03b1`, in this file we define\n\n* `set.proj_Icc (a b : \u03b1) (h : a \u2264 b)` to be the map `\u03b1 \u2192 [a, b]` sending `(-\u221e, a]` to `a`, `[b, \u221e)`\n  to `b`, and each point `x \u2208 [a, b]` to itself;\n* `set.Icc_extend {a b : \u03b1} (h : a \u2264 b) (f : Icc a b \u2192 \u03b2)` to be the extension of `f` to `\u03b1` defined\n  as `f \u2218 proj_Icc a b h`.\n\nWe also prove some trivial properties of these maps.\n-/\n\nnamespace set\n\n\n/-- Projection of `\u03b1` to the closed interval `[a, b]`. -/\ndef proj_Icc {\u03b1 : Type u_1} [linear_order \u03b1] (a : \u03b1) (b : \u03b1) (h : a \u2264 b) (x : \u03b1) : \u21a5(Icc a b) :=\n  { val := max a (min b x), property := sorry }\n\ntheorem proj_Icc_of_le_left {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1}\n    (hx : x \u2264 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 {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 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 {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1}\n    (hx : b \u2264 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 {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 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 {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1}\n    (hx : x \u2208 Icc a b) : proj_Icc a b h x = { val := x, property := hx } :=\n  sorry\n\n@[simp] theorem proj_Icc_coe {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b)\n    (x : \u21a5(Icc a b)) : proj_Icc a b h \u2191x = x :=\n  subtype.cases_on x fun (x_val : \u03b1) (x_property : x_val \u2208 Icc a b) => proj_Icc_of_mem h x_property\n\ntheorem proj_Icc_surj_on {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) :\n    surj_on (proj_Icc a b h) (Icc a b) univ :=\n  fun (x : \u21a5(Icc a b)) (_x : x \u2208 univ) =>\n    Exists.intro \u2191x { left := subtype.property x, right := proj_Icc_coe h x }\n\ntheorem proj_Icc_surjective {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) :\n    function.surjective (proj_Icc a b h) :=\n  fun (x : \u21a5(Icc a b)) => Exists.intro (\u2191x) (proj_Icc_coe h x)\n\n@[simp] theorem range_proj_Icc {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) :\n    range (proj_Icc a b h) = univ :=\n  function.surjective.range_eq (proj_Icc_surjective h)\n\ntheorem monotone_proj_Icc {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) :\n    monotone (proj_Icc a b h) :=\n  fun (x y : \u03b1) (hxy : x \u2264 y) => max_le_max le_rfl (min_le_min le_rfl hxy)\n\ntheorem strict_mono_incr_on_proj_Icc {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) :\n    strict_mono_incr_on (proj_Icc a b h) (Icc a b) :=\n  sorry\n\n/-- Extend a function `[a, b] \u2192 \u03b2` to a map `\u03b1 \u2192 \u03b2`. -/\ndef Icc_extend {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b)\n    (f : \u21a5(Icc a b) \u2192 \u03b2) : \u03b1 \u2192 \u03b2 :=\n  f \u2218 proj_Icc a b h\n\n@[simp] theorem Icc_extend_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1}\n    (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) : range (Icc_extend h f) = range f :=\n  sorry\n\ntheorem Icc_extend_of_le_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1}\n    (h : a \u2264 b) {x : \u03b1} (f : \u21a5(Icc a b) \u2192 \u03b2) (hx : x \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1}\n    (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1}\n    (h : a \u2264 b) {x : \u03b1} (f : \u21a5(Icc a b) \u2192 \u03b2) (hx : b \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1}\n    (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b)\n    {x : \u03b1} (f : \u21a5(Icc a b) \u2192 \u03b2) (hx : x \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1}\n    (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) (x : \u21a5(Icc a b)) : Icc_extend h f \u2191x = f x :=\n  congr_arg f (proj_Icc_coe h x)\n\nend set\n\n\ntheorem monotone.Icc_extend {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] [preorder \u03b2] {a : \u03b1}\n    {b : \u03b1} (h : a \u2264 b) {f : \u21a5(set.Icc a b) \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1]\n    [preorder \u03b2] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {f : \u21a5(set.Icc a b) \u2192 \u03b2} (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\u2081 v\u2081 \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\u2081) [category C] (D : Type u\u2081) [category D] : category (C \u2295 D) :=\n  category.mk\n\n@[simp] theorem sum_comp_inl (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] {P : C} {Q : C}\n    {R : C} (f : sum.inl P \u27f6 sum.inl Q) (g : sum.inl Q \u27f6 sum.inl R) : f \u226b g = f \u226b g :=\n  rfl\n\n@[simp] theorem sum_comp_inr (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] {P : D} {Q : D}\n    {R : D} (f : sum.inr P \u27f6 sum.inr Q) (g : sum.inr Q \u27f6 sum.inr R) : f \u226b g = f \u226b g :=\n  rfl\n\nnamespace sum\n\n\n/-- `inl_` is the functor `X \u21a6 inl X`. -/\n-- Unfortunate naming here, suggestions welcome.\n\ndef inl_ (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : C \u2964 C \u2295 D :=\n  functor.mk (fun (X : C) => sum.inl X) fun (X Y : C) (f : X \u27f6 Y) => f\n\n/-- `inr_` is the functor `X \u21a6 inr X`. -/\ndef inr_ (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : D \u2964 C \u2295 D :=\n  functor.mk (fun (X : D) => sum.inr X) fun (X Y : D) (f : X \u27f6 Y) => f\n\n/-- The functor exchanging two direct summand categories. -/\ndef swap (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : C \u2295 D \u2964 D \u2295 C :=\n  functor.mk (fun (X : C \u2295 D) => sorry) fun (X Y : C \u2295 D) (f : X \u27f6 Y) => sorry\n\n@[simp] theorem swap_obj_inl (C : Type u\u2081) [category C] (D : Type u\u2081) [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\u2081) [category C] (D : Type u\u2081) [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\u2081) [category C] (D : Type u\u2081) [category D] {X : C} {Y : C}\n    {f : sum.inl X \u27f6 sum.inl Y} : functor.map (swap C D) f = f :=\n  rfl\n\n@[simp] theorem swap_map_inr (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] {X : D} {Y : D}\n    {f : sum.inr X \u27f6 sum.inr Y} : functor.map (swap C D) f = f :=\n  rfl\n\nnamespace swap\n\n\n/-- `swap` gives an equivalence between `C \u2295 D` and `D \u2295 C`. -/\ndef equivalence (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : C \u2295 D \u224c D \u2295 C :=\n  equivalence.mk (swap C D) (swap D C)\n    (nat_iso.of_components (fun (X : C \u2295 D) => eq_to_iso sorry) sorry)\n    (nat_iso.of_components (fun (X : D \u2295 C) => eq_to_iso sorry) sorry)\n\nprotected instance is_equivalence (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] :\n    is_equivalence (swap C D) :=\n  is_equivalence.of_equivalence (equivalence C D)\n\n/-- The double swap on `C \u2295 D` is naturally isomorphic to the identity functor. -/\ndef symmetry (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : swap C D \u22d9 swap D C \u2245 \ud835\udfed :=\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\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C]\n    {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 D) : A \u2295 C \u2964 B \u2295 D :=\n  mk (fun (X : A \u2295 C) => sorry) fun (X Y : A \u2295 C) (f : X \u27f6 Y) => sorry\n\n@[simp] theorem sum_obj_inl {A : Type u\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081}\n    [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 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\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081}\n    [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 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\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081}\n    [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 D) {a : A} {a' : A}\n    (f : sum.inl a \u27f6 sum.inl a') : map (sum F G) f = map F f :=\n  rfl\n\n@[simp] theorem sum_map_inr {A : Type u\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081}\n    [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 D) {c : C} {c' : C}\n    (f : sum.inr c \u27f6 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\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C]\n    {D : Type u\u2081} [category D] {F : A \u2964 B} {G : A \u2964 B} {H : C \u2964 D} {I : C \u2964 D} (\u03b1 : F \u27f6 G)\n    (\u03b2 : H \u27f6 I) : functor.sum F H \u27f6 functor.sum G I :=\n  mk fun (X : A \u2295 C) => sorry\n\n@[simp] theorem sum_app_inl {A : Type u\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081}\n    [category C] {D : Type u\u2081} [category D] {F : A \u2964 B} {G : A \u2964 B} {H : C \u2964 D} {I : C \u2964 D}\n    (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) (a : A) : app (sum \u03b1 \u03b2) (sum.inl a) = app \u03b1 a :=\n  rfl\n\n@[simp] theorem sum_app_inr {A : Type u\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081}\n    [category C] {D : Type u\u2081} [category D] {F : A \u2964 B} {G : A \u2964 B} {H : C \u2964 D} {I : C \u2964 D}\n    (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) (c : C) : app (sum \u03b1 \u03b2) (sum.inr c) = app \u03b2 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 \u2192+ B) :=\n{ smul := \u03bb r f,\n  { to_fun := r \u2022 f,\n    map_zero' := by simp,\n    map_add' := \u03bb x y, by simp [smul_add] },\n  one_smul := \u03bb f, by simp,\n  mul_smul := \u03bb r s f, by simp [mul_smul],\n  smul_add := \u03bb r f g, ext $ \u03bb x, by simp [smul_add],\n  smul_zero := \u03bb r, ext $ \u03bb x, by simp [smul_zero] }\n\n@[simp] lemma coe_smul (r : R) (f : A \u2192+ B) : \u21d1(r \u2022 f) = r \u2022 f := rfl\nlemma smul_apply (r : R) (f : A \u2192+ B) (x : A) : (r \u2022 f) x = r \u2022 f x := rfl\n\ninstance [smul_comm_class R S B] : smul_comm_class R S (A \u2192+ B) :=\n\u27e8\u03bb a b f, ext $ \u03bb x, smul_comm _ _ _\u27e9\n\ninstance [has_scalar R S] [is_scalar_tower R S B] : is_scalar_tower R S (A \u2192+ B) :=\n\u27e8\u03bb a b f, ext $ \u03bb x, smul_assoc _ _ _\u27e9\n\ninstance [distrib_mul_action R\u1d50\u1d52\u1d56 B] [is_central_scalar R B] : is_central_scalar R (A \u2192+ B) :=\n\u27e8\u03bb a b, ext $ \u03bb x, op_smul_eq_smul _ _\u27e9\n\nend\n\ninstance [semiring R] [add_monoid A] [add_comm_monoid B] [module R B] :\n  module R (A \u2192+ B) :=\n{ add_smul := \u03bb r s x, ext $ \u03bb y, by simp [add_smul],\n  zero_smul := \u03bb x, ext $ \u03bb 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 {\u03b1 \u03b2 \u03b3 : Type*}\n\nopen finset function\n\nnamespace set\nvariables {s t : set \u03b1}\n\nlemma to_finset_prod (s : set \u03b1) (t : set \u03b2) [fintype s] [fintype t] [fintype (s \u00d7\u02e2 t)] :\n  (s \u00d7\u02e2 t).to_finset = s.to_finset \u00d7\u02e2 t.to_finset :=\nby { ext, simp }\n\nlemma to_finset_off_diag {s : set \u03b1} [decidable_eq \u03b1] [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 (\u03b1 \u03b2 : Type*) [fintype \u03b1] [fintype \u03b2] : fintype (\u03b1 \u00d7 \u03b2) :=\n\u27e8univ \u00d7\u02e2 univ, \u03bb \u27e8a, b\u27e9, by simp\u27e9\n\n@[simp] lemma finset.univ_product_univ {\u03b1 \u03b2 : Type*} [fintype \u03b1] [fintype \u03b2] :\n  (univ : finset \u03b1) \u00d7\u02e2 (univ : finset \u03b2) = univ :=\nrfl\n\n@[simp] theorem fintype.card_prod (\u03b1 \u03b2 : Type*) [fintype \u03b1] [fintype \u03b2] :\n  fintype.card (\u03b1 \u00d7 \u03b2) = fintype.card \u03b1 * fintype.card \u03b2 :=\ncard_product _ _\n\nsection\nopen_locale classical\n\n@[simp] lemma infinite_prod :\n  infinite (\u03b1 \u00d7 \u03b2) \u2194 infinite \u03b1 \u2227 nonempty \u03b2 \u2228 nonempty \u03b1 \u2227 infinite \u03b2 :=\nbegin\n  refine \u27e8\u03bb H, _, \u03bb H, H.elim (and_imp.2 $ @prod.infinite_of_left \u03b1 \u03b2)\n    (and_imp.2 $ @prod.infinite_of_right \u03b1 \u03b2)\u27e9,\n  rw and.comm, contrapose! H, introI H',\n  rcases infinite.nonempty (\u03b1 \u00d7 \u03b2) with \u27e8a, b\u27e9,\n  haveI := fintype_of_not_infinite (H.1 \u27e8b\u27e9), haveI := fintype_of_not_infinite (H.2 \u27e8a\u27e9),\n  exact H'.false\nend\n\ninstance pi.infinite_of_left {\u03b9 : Sort*} {\u03c0 : \u03b9 \u2192 Sort*} [\u2200 i, nontrivial $ \u03c0 i]\n  [infinite \u03b9] : infinite (\u03a0 i : \u03b9, \u03c0 i) :=\nbegin\n  choose m n hm using \u03bb i, exists_pair_ne (\u03c0 i),\n  refine infinite.of_injective (\u03bb i, m.update i (n i)) (\u03bb x y h, not_not.1 $ \u03bb 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 `\u03c0 i` is infinite and the rest nonempty, the pi type of all `\u03c0` is infinite. -/\nlemma pi.infinite_of_exists_right {\u03b9 : Type*} {\u03c0 : \u03b9 \u2192 Type*} (i : \u03b9)\n  [infinite $ \u03c0 i] [\u2200 i, nonempty $ \u03c0 i] :\n  infinite (\u03a0 i : \u03b9, \u03c0 i) :=\nlet \u27e8m\u27e9 := @pi.nonempty \u03b9 \u03c0 _ in infinite.of_injective _ (update_injective m i)\n\n/-- See `pi.infinite_of_exists_right` for the case that only one `\u03c0 i` is infinite. -/\ninstance pi.infinite_of_right {\u03b9 : Sort*} {\u03c0 : \u03b9 \u2192 Sort*} [\u2200 i, infinite $ \u03c0 i] [nonempty \u03b9] :\n  infinite (\u03a0 i : \u03b9, \u03c0 i) :=\npi.infinite_of_exists_right (classical.arbitrary \u03b9)\n\n/-- Non-dependent version of `pi.infinite_of_left`. -/\ninstance function.infinite_of_left {\u03b9 \u03c0 : Sort*} [nontrivial \u03c0]\n  [infinite \u03b9] : infinite (\u03b9 \u2192 \u03c0) :=\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 {\u03b9 \u03c0 : Sort*} [infinite \u03c0] [nonempty \u03b9] :\n  infinite (\u03b9 \u2192 \u03c0) :=\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 \u2223 b`, as an `enat` or natural with infinity. If `\u2200 n, a ^ n \u2223 b`,\n  then it returns `\u22a4`-/\ndef multiplicity {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] (a : \u03b1) (b : \u03b1) : enat :=\n  enat.find fun (n : \u2115) => \u00aca ^ (n + 1) \u2223 b\n\nnamespace multiplicity\n\n\n/-- `multiplicity.finite a b` indicates that the multiplicity of `a` in `b` is finite. -/\ndef finite {\u03b1 : Type u_1} [comm_monoid \u03b1] (a : \u03b1) (b : \u03b1) :=\n  \u2203 (n : \u2115), \u00aca ^ (n + 1) \u2223 b\n\ntheorem finite_iff_dom {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} : finite a b \u2194 roption.dom (multiplicity a b) :=\n  iff.rfl\n\ntheorem finite_def {\u03b1 : Type u_1} [comm_monoid \u03b1] {a : \u03b1} {b : \u03b1} : finite a b \u2194 \u2203 (n : \u2115), \u00aca ^ (n + 1) \u2223 b :=\n  iff.rfl\n\ntheorem int.coe_nat_multiplicity (a : \u2115) (b : \u2115) : multiplicity \u2191a \u2191b = multiplicity a b := sorry\n\ntheorem not_finite_iff_forall {\u03b1 : Type u_1} [comm_monoid \u03b1] {a : \u03b1} {b : \u03b1} : \u00acfinite a b \u2194 \u2200 (n : \u2115), a ^ n \u2223 b := sorry\n\ntheorem not_unit_of_finite {\u03b1 : Type u_1} [comm_monoid \u03b1] {a : \u03b1} {b : \u03b1} (h : finite a b) : \u00acis_unit a := sorry\n\ntheorem finite_of_finite_mul_left {\u03b1 : Type u_1} [comm_monoid \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} : finite a (b * c) \u2192 finite a c := sorry\n\ntheorem finite_of_finite_mul_right {\u03b1 : Type u_1} [comm_monoid \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} : finite a (b * c) \u2192 finite a b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (finite a (b * c) \u2192 finite a b)) (mul_comm b c))) finite_of_finite_mul_left\n\ntheorem pow_dvd_of_le_multiplicity {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {k : \u2115} : \u2191k \u2264 multiplicity a b \u2192 a ^ k \u2223 b := sorry\n\ntheorem pow_multiplicity_dvd {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} (h : finite a b) : a ^ roption.get (multiplicity a b) h \u2223 b :=\n  pow_dvd_of_le_multiplicity\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191(roption.get (multiplicity a b) h) \u2264 multiplicity a b)) (enat.coe_get h)))\n      (le_refl (multiplicity a b)))\n\ntheorem is_greatest {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {m : \u2115} (hm : multiplicity a b < \u2191m) : \u00aca ^ m \u2223 b := sorry\n\ntheorem is_greatest' {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {m : \u2115} (h : finite a b) (hm : roption.get (multiplicity a b) h < m) : \u00aca ^ m \u2223 b :=\n  is_greatest\n    (eq.mp (Eq._oldrec (Eq.refl (\u2191(roption.get (multiplicity a b) h) < \u2191m)) (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 {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {k : \u2115} (hk : a ^ k \u2223 b) (hsucc : \u00aca ^ (k + 1) \u2223 b) : \u2191k = multiplicity a b := sorry\n\ntheorem unique' {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {k : \u2115} (hk : a ^ k \u2223 b) (hsucc : \u00aca ^ (k + 1) \u2223 b) : k = roption.get (multiplicity a b) (Exists.intro k hsucc) := sorry\n\ntheorem le_multiplicity_of_pow_dvd {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {k : \u2115} (hk : a ^ k \u2223 b) : \u2191k \u2264 multiplicity a b :=\n  le_of_not_gt fun (hk' : \u2191k > multiplicity a b) => is_greatest hk' hk\n\ntheorem pow_dvd_iff_le_multiplicity {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {k : \u2115} : a ^ k \u2223 b \u2194 \u2191k \u2264 multiplicity a b :=\n  { mp := le_multiplicity_of_pow_dvd, mpr := pow_dvd_of_le_multiplicity }\n\ntheorem multiplicity_lt_iff_neg_dvd {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {k : \u2115} : multiplicity a b < \u2191k \u2194 \u00aca ^ k \u2223 b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (multiplicity a b < \u2191k \u2194 \u00aca ^ k \u2223 b)) (propext pow_dvd_iff_le_multiplicity)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (multiplicity a b < \u2191k \u2194 \u00ac\u2191k \u2264 multiplicity a b)) (propext not_le)))\n      (iff.refl (multiplicity a b < \u2191k)))\n\ntheorem eq_some_iff {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {n : \u2115} : multiplicity a b = \u2191n \u2194 a ^ n \u2223 b \u2227 \u00aca ^ (n + 1) \u2223 b := sorry\n\ntheorem eq_top_iff {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} : multiplicity a b = \u22a4 \u2194 \u2200 (n : \u2115), a ^ n \u2223 b := sorry\n\ntheorem one_right {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} (ha : \u00acis_unit a) : multiplicity a 1 = 0 := sorry\n\n@[simp] theorem get_one_right {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} (ha : finite a 1) : roption.get (multiplicity a 1) ha = 0 := sorry\n\n@[simp] theorem multiplicity_unit {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} (b : \u03b1) (ha : is_unit a) : multiplicity a b = \u22a4 :=\n  iff.mpr eq_top_iff fun (_x : \u2115) => iff.mp is_unit_iff_forall_dvd (is_unit.pow _x ha) b\n\n@[simp] theorem one_left {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] (b : \u03b1) : multiplicity 1 b = \u22a4 := sorry\n\ntheorem multiplicity_eq_zero_of_not_dvd {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} (ha : \u00aca \u2223 b) : multiplicity a b = 0 := sorry\n\ntheorem eq_top_iff_not_finite {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} : multiplicity a b = \u22a4 \u2194 \u00acfinite a b :=\n  roption.eq_none_iff'\n\ntheorem multiplicity_le_multiplicity_iff {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1} : multiplicity a b \u2264 multiplicity c d \u2194 \u2200 (n : \u2115), a ^ n \u2223 b \u2192 c ^ n \u2223 d := sorry\n\ntheorem multiplicity_le_multiplicity_of_dvd {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} {c : \u03b1} (hdvd : a \u2223 b) : multiplicity b c \u2264 multiplicity a c :=\n  iff.mpr multiplicity_le_multiplicity_iff fun (n : \u2115) (h : b ^ n \u2223 c) => dvd_trans (pow_dvd_pow_of_dvd hdvd n) h\n\ntheorem dvd_of_multiplicity_pos {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} (h : 0 < multiplicity a b) : a \u2223 b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a \u2223 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 {\u03b1 : Type u_1} [comm_monoid \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} {b : \u03b1} : 0 < multiplicity a b \u2194 a \u2223 b := sorry\n\ntheorem finite_nat_iff {a : \u2115} {b : \u2115} : finite a b \u2194 a \u2260 1 \u2227 0 < b := sorry\n\ntheorem ne_zero_of_finite {\u03b1 : Type u_1} [comm_monoid_with_zero \u03b1] {a : \u03b1} {b : \u03b1} (h : finite a b) : b \u2260 0 := sorry\n\n@[simp] protected theorem zero {\u03b1 : Type u_1} [comm_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] (a : \u03b1) : multiplicity a 0 = \u22a4 := sorry\n\n@[simp] theorem multiplicity_zero_eq_zero_of_ne_zero {\u03b1 : Type u_1} [comm_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] (a : \u03b1) (ha : a \u2260 0) : multiplicity 0 a = 0 :=\n  multiplicity_eq_zero_of_not_dvd (eq.mpr (id (Eq._oldrec (Eq.refl (\u00ac0 \u2223 a)) (propext zero_dvd_iff))) ha)\n\ntheorem min_le_multiplicity_add {\u03b1 : Type u_1} [comm_semiring \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} {a : \u03b1} {b : \u03b1} : min (multiplicity p a) (multiplicity p b) \u2264 multiplicity p (a + b) := sorry\n\n@[simp] protected theorem neg {\u03b1 : Type u_1} [comm_ring \u03b1] [DecidableRel has_dvd.dvd] (a : \u03b1) (b : \u03b1) : multiplicity a (-b) = multiplicity a b := sorry\n\ntheorem multiplicity_add_of_gt {\u03b1 : Type u_1} [comm_ring \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} {a : \u03b1} {b : \u03b1} (h : multiplicity p b < multiplicity p a) : multiplicity p (a + b) = multiplicity p b := sorry\n\ntheorem multiplicity_sub_of_gt {\u03b1 : Type u_1} [comm_ring \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} {a : \u03b1} {b : \u03b1} (h : multiplicity p b < multiplicity p a) : multiplicity p (a - b) = multiplicity p b := sorry\n\ntheorem multiplicity_add_eq_min {\u03b1 : Type u_1} [comm_ring \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} {a : \u03b1} {b : \u03b1} (h : multiplicity p a \u2260 multiplicity p b) : multiplicity p (a + b) = min (multiplicity p a) (multiplicity p b) := sorry\n\ntheorem finite_mul_aux {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] {p : \u03b1} (hp : prime p) {n : \u2115} {m : \u2115} {a : \u03b1} {b : \u03b1} : \u00acp ^ (n + 1) \u2223 a \u2192 \u00acp ^ (m + 1) \u2223 b \u2192 \u00acp ^ (n + m + 1) \u2223 a * b := sorry\n\ntheorem finite_mul {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] {p : \u03b1} {a : \u03b1} {b : \u03b1} (hp : prime p) : finite p a \u2192 finite p b \u2192 finite p (a * b) := sorry\n\ntheorem finite_mul_iff {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] {p : \u03b1} {a : \u03b1} {b : \u03b1} (hp : prime p) : finite p (a * b) \u2194 finite p a \u2227 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 \u2227 finite p b) => finite_mul hp (and.left h) (and.right h) }\n\ntheorem finite_pow {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] {p : \u03b1} {a : \u03b1} (hp : prime p) {k : \u2115} (ha : finite p a) : finite p (a ^ k) := sorry\n\n@[simp] theorem multiplicity_self {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} (ha : \u00acis_unit a) (ha0 : a \u2260 0) : multiplicity a a = 1 := sorry\n\n@[simp] theorem get_multiplicity_self {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {a : \u03b1} (ha : finite a a) : roption.get (multiplicity a a) ha = 1 := sorry\n\nprotected theorem mul' {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} {a : \u03b1} {b : \u03b1} (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 {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} {a : \u03b1} {b : \u03b1} (hp : prime p) : multiplicity p (a * b) = multiplicity p a + multiplicity p b := sorry\n\ntheorem finset.prod {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {\u03b2 : Type u_2} {p : \u03b1} (hp : prime p) (s : finset \u03b2) (f : \u03b2 \u2192 \u03b1) : multiplicity p (finset.prod s fun (x : \u03b2) => f x) = finset.sum s fun (x : \u03b2) => multiplicity p (f x) := sorry\n\nprotected theorem pow' {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} {a : \u03b1} (hp : prime p) (ha : finite p a) {k : \u2115} : roption.get (multiplicity p (a ^ k)) (finite_pow hp ha) = k * roption.get (multiplicity p a) ha := sorry\n\ntheorem pow {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} {a : \u03b1} (hp : prime p) {k : \u2115} : multiplicity p (a ^ k) = k \u2022\u2115 multiplicity p a := sorry\n\ntheorem multiplicity_pow_self {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} (h0 : p \u2260 0) (hu : \u00acis_unit p) (n : \u2115) : multiplicity p (p ^ n) = \u2191n := sorry\n\ntheorem multiplicity_pow_self_of_prime {\u03b1 : Type u_1} [comm_cancel_monoid_with_zero \u03b1] [DecidableRel has_dvd.dvd] {p : \u03b1} (hp : prime p) (n : \u2115) : multiplicity p (p ^ n) = \u2191n :=\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 : \u2115} {a : \u2115} {b : \u2115} (hp : p \u2260 1) (hle : multiplicity p a \u2264 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\u2081 u\u2082 v\u2081 v\u2082 v\u2083 u\u2083 \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\u2081) [category C] (D : Type u\u2082) [category D] :\n    category (C \u2964 D) :=\n  category.mk\n\nnamespace nat_trans\n\n\n@[simp] theorem vcomp_eq_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H) : vcomp \u03b1 \u03b2 = \u03b1 \u226b \u03b2 :=\n  rfl\n\ntheorem vcomp_app' {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D}\n    {H : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H) (X : C) : app (\u03b1 \u226b \u03b2) X = app \u03b1 X \u226b app \u03b2 X :=\n  rfl\n\ntheorem congr_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D}\n    {\u03b1 : F \u27f6 G} {\u03b2 : F \u27f6 G} (h : \u03b1 = \u03b2) (X : C) : app \u03b1 X = app \u03b2 X :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (app \u03b1 X = app \u03b2 X)) h)) (Eq.refl (app \u03b2 X))\n\n@[simp] theorem id_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) (X : C) :\n    app \ud835\udfd9 X = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem comp_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H) (X : C) : app (\u03b1 \u226b \u03b2) X = app \u03b1 X \u226b app \u03b2 X :=\n  rfl\n\ntheorem app_naturality {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] {F : C \u2964 D \u2964 E} {G : C \u2964 D \u2964 E} (T : F \u27f6 G) (X : C) {Y : D} {Z : D} (f : Y \u27f6 Z) :\n    functor.map (functor.obj F X) f \u226b app (app T X) Z =\n        app (app T X) Y \u226b functor.map (functor.obj G X) f :=\n  naturality (app T X) f\n\ntheorem naturality_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] {F : C \u2964 D \u2964 E} {G : C \u2964 D \u2964 E} (T : F \u27f6 G) (Z : D) {X : C} {Y : C} (f : X \u27f6 Y) :\n    app (functor.map F f) Z \u226b app (app T Y) Z = app (app T X) Z \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} (\u03b1 : F \u27f6 G) [\u2200 (X : C), mono (app \u03b1 X)] : mono \u03b1 :=\n  sorry\n\n/-- A natural transformation is an epimorphism if each component is. -/\ntheorem epi_app_of_epi {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D}\n    (\u03b1 : F \u27f6 G) [\u2200 (X : C), epi (app \u03b1 X)] : epi \u03b1 :=\n  sorry\n\n/-- `hcomp \u03b1 \u03b2` is the horizontal composition of natural transformations. -/\ndef hcomp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E]\n    {F : C \u2964 D} {G : C \u2964 D} {H : D \u2964 E} {I : D \u2964 E} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) : F \u22d9 H \u27f6 G \u22d9 I :=\n  mk fun (X : C) => app \u03b2 (functor.obj F X) \u226b functor.map I (app \u03b1 X)\n\ninfixl:80 \" \u25eb \" => Mathlib.category_theory.nat_trans.hcomp\n\n@[simp] theorem hcomp_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] {F : C \u2964 D} {G : C \u2964 D} {H : D \u2964 E} {I : D \u2964 E} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) (X : C) :\n    app (\u03b1 \u25eb \u03b2) X = app \u03b2 (functor.obj F X) \u226b functor.map I (app \u03b1 X) :=\n  rfl\n\n@[simp] theorem hcomp_id_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] {F : C \u2964 D} {G : C \u2964 D} {H : D \u2964 E} (\u03b1 : F \u27f6 G) (X : C) :\n    app (\u03b1 \u25eb \ud835\udfd9) X = functor.map H (app \u03b1 X) :=\n  sorry\n\ntheorem id_hcomp_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] {F : C \u2964 D} {G : C \u2964 D} {H : E \u2964 C} (\u03b1 : F \u27f6 G) (X : E) :\n    app (\ud835\udfd9 \u25eb \u03b1) X = app \u03b1 (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\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E]\n    {F : C \u2964 D} {G : C \u2964 D} {H : C \u2964 D} {I : D \u2964 E} {J : D \u2964 E} {K : D \u2964 E} (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H)\n    (\u03b3 : I \u27f6 J) (\u03b4 : J \u27f6 K) : (\u03b1 \u226b \u03b2) \u25eb (\u03b3 \u226b \u03b4) = \u03b1 \u25eb \u03b3 \u226b \u03b2 \u25eb \u03b4 :=\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\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E]\n    (F : C \u2964 D \u2964 E) : D \u2964 C \u2964 E :=\n  mk\n    (fun (k : D) =>\n      mk (fun (j : C) => obj (obj F j) k) fun (j j' : C) (f : j \u27f6 j') => nat_trans.app (map F f) k)\n    fun (c c' : D) (f : c \u27f6 c') => nat_trans.mk fun (j : C) => map (obj F j) f\n\n@[simp] theorem flip_obj_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] (F : C \u2964 D \u2964 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\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] (F : C \u2964 D \u2964 E) {c : C} {c' : C} (f : c \u27f6 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\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083}\n    [category E] (F : C \u2964 D \u2964 E) {d : D} {d' : D} (f : d \u27f6 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 \u2192 m \u03b2) (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 : \u03b1 \u2192 m Bool) (xs : List \u03b1) :\n    (do for x in xs do\n          let b \u2190 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 [\u2190 ih]; simp\n    apply byCases_Bool_bind <;> simp\n\ntheorem eq_findSomeM_findM [Monad m] [LawfulMonad m] (p : \u03b1 \u2192 m Bool) (xss : List (List \u03b1)) :\n    (do for xs in xss do\n           for x in xs do\n             let b \u2190 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 [\u2190 ih, \u2190 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 : \u03b1 \u2192 m Bool) (xss : List (List \u03b1)) :\n    (do for xs in xss do\n           for x in xs do\n             let b \u2190 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 \u03b1 => xs\n  rename _ = _  => ih\n  rw [\u2190 ih, \u2190 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\u2081 u_1 u_2 u_3 u_4 v\u2081 w\u2081 \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 \u2022 s) \u2022 a = r \u2022 (s \u2022 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 \u2208 I}` is an `R`-basis of `S` and `{cj | j \u2208 J}` is a `S`-basis\nof `A`, then `{bi cj | i \u2208 I, j \u2208 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 (\u21d1polynomial.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 (\u2191(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 : \u2115) [inv : invertible \u2191n] : invertible \u2191n :=\n  invertible.algebra_tower \u2115 R A n\n\ntheorem algebra_map_aeval (R : Type u) (A : Type w) (B : Type u\u2081) [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\u2081) [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 \u21d1(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 (\u21d1(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 (\u21d1(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 \u22a4 (is_scalar_tower.to_alg_hom C D E))\n    (adjoin (\u21a5(subalgebra.map \u22a4 (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 = \u22a4) (hT : adjoin C T = \u22a4) : subalgebra.res C (adjoin E (\u21d1(algebra_map D F) '' S)) = subalgebra.res C (adjoin D (\u21d1(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 : \u21a5S} {p : polynomial R} : coe_fn (polynomial.aeval \u2191x) p = \u2191(coe_fn (polynomial.aeval x) p) :=\n  Eq.symm (is_scalar_tower.algebra_map_aeval R (\u21a5S) 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 \u22a4) (hSA : subalgebra.fg \u22a4) : subalgebra.fg \u22a4 := 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] {\u03b9 : Type v\u2081} {b : \u03b9 \u2192 S} {\u03b9' : Type w\u2081} {c : \u03b9' \u2192 A} (hb : linear_independent R b) (hc : linear_independent S c) : linear_independent R fun (p : \u03b9 \u00d7 \u03b9') => b (prod.fst p) \u2022 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] {\u03b9 : Type v\u2081} {b : \u03b9 \u2192 S} {\u03b9' : Type w\u2081} {c : \u03b9' \u2192 A} (hb : is_basis R b) (hc : is_basis S c) : is_basis R fun (p : \u03b9 \u00d7 \u03b9') => b (prod.fst p) \u2022 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] {\u03b9 : Type u_1} {\u03b9' : Type u_2} {b : \u03b9 \u2192 S} {c : \u03b9' \u2192 A} (hb : is_basis R b) (hc : is_basis S c) (x : A) (ij : \u03b9 \u00d7 \u03b9') : 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] {\u03b9 : Type u_1} {\u03b9' : Type u_2} {b : \u03b9 \u2192 S} {c : \u03b9' \u2192 A} (hb : is_basis R b) (hc : is_basis S c) (x : A) (i : \u03b9) (j : \u03b9') : 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\u2081) (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 \u22a4) (hBC : submodule.fg \u22a4) : \u2203 (B\u2080 : subalgebra A B), subalgebra.fg B\u2080 \u2227 submodule.fg \u22a4 := sorry\n\n/-- Artin--Tate lemma: if A \u2286 B \u2286 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\u2081) (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 \u22a4) (hBC : submodule.fg \u22a4) (hBCi : function.injective \u21d1(algebra_map B C)) : subalgebra.fg \u22a4 := sorry\n\n/-- Restrict the domain of an `alg_hom`. -/\ndef alg_hom.restrict_domain {A : Type w} (B : Type u\u2081) {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\u2081) {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\u2081} {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 \u2243 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 {\u03b1 \u03b2} := @sigma.mk \u03b1 \u03b2\n\nnamespace sigma\n  variables {A : Type _} {A' : Type _} {B : A \u2192 Type _} {B' : A' \u2192 Type _} {C : \u03a0a, B a \u2192 Type _}\n            {D : \u03a0a b, C a b \u2192 Type _}\n            {a a' a'' : A} {b b\u2081 b\u2082 : B a} {b' : B a'} {b'' : B a''} {u v w : \u03a3a, B a}\n\n  @[hott] def destruct := @sigma.cases_on\n\n  /- Paths in a sigma-type -/\n\n  @[hott] protected def eta : \u03a0 (u : \u03a3a, B a), (\u27e8u.1 , u.2\u27e9: sigma _) = u\n  | \u27e8u\u2081, u\u2082\u27e9 := idp\n\n  @[hott] def eta2 : \u03a0 (u : \u03a3a b, C a b), (\u27e8u.1, u.2.1, u.2.2\u27e9: \u03a3 _ _, _) = u\n  | \u27e8u\u2081, u\u2082, u\u2083\u27e9 := idp\n\n  @[hott] def eta3 : \u03a0 (u : \u03a3a b c, D a b c), (\u27e8u.1, u.2.1, u.2.2.1, u.2.2.2\u27e9: \u03a3 _ _ _, _) = u\n  | \u27e8u\u2081, u\u2082, u\u2083, u\u2084\u27e9 := idp\n\n  @[hott] def dpair_eq_dpair (p : a = a') (q : b =[p] b') : (\u27e8a, b\u27e9: \u03a3 _, _) = \u27e8a', b'\u27e9 :=\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\u2081 = b\u2082) : (\u27e8a, b\u2081\u27e9: \u03a3 _, _) = \u27e8a, b\u2082\u27e9 :=\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    : (\u27e8(sigma_eq p q)..1, (sigma_eq p q)..2\u27e9: \u03a3 p, u.2 =[p] v.2) = \u27e8p, q\u27e9 :=\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; \u03bb 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; \u03bb 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 \u2192 Type _} (p : u.1 = v.1) (q : u.2 =[p] v.2)\n    : transport (\u03bbx : 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 (\u03bbx : 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 : \u03a0 (pq : \u03a3(p : u.1 = v.1), u.2 =[p] v.2), u = v\n  | \u27e8pq\u2081, pq\u2082\u27e9 := sigma_eq pq\u2081 pq\u2082\n\n  @[hott] def dpair_sigma_eq_unc : \u03a0 (pq : \u03a3(p : u.1 = v.1), u.2 =[p] v.2),\n    (\u27e8(sigma_eq_unc pq)..1, (sigma_eq_unc pq)..2\u27e9: \u03a3 p, u.2 =[p] v.2) = pq\n  | \u27e8pq\u2081, pq\u2082\u27e9 := dpair_sigma_eq pq\u2081 pq\u2082\n\n  @[hott] def sigma_eq_fst_unc (pq : \u03a3(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 : \u03a3(p : u.1 = v.1), u.2 =[p] v.2) :\n    (sigma_eq_unc pq)..2 =[sigma_eq_fst_unc pq; \u03bb 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 \u27e8p..1, p..2\u27e9 = p :=\n  sigma_eq_eta p\n\n  @[hott] def tr_sigma_eq_fst_unc {B' : A \u2192 Type _}\n    (pq : \u03a3(p : u.1 = v.1), u.2 =[p] v.2)\n      : transport (\u03bbx: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 : \u03a3a, B a)\n      : is_equiv (@sigma_eq_unc A B u v) :=\n  adjointify sigma_eq_unc\n             (\u03bbp, \u27e8p..1, p..2\u27e9)\n             sigma_eq_eta_unc\n             dpair_sigma_eq_unc\n\n  @[hott] def sigma_eq_equiv (u v : \u03a3a, B a)\n    : (u = v) \u2243 (\u03a3(p : u.1 = v.1),  u.2 =[p] v.2) :=\n  (equiv.mk sigma_eq_unc (by apply_instance))\u207b\u00b9\u1d49\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 \u2b1d p2) (q1 \u2b1do q2) = dpair_eq_dpair p1 q1 \u2b1d 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 \u2b1d p2) (q1 \u2b1do q2) = sigma_eq p1 q1 \u2b1d 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 _ _) \u2b1d\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 : \u03a3a, B a)           : (idpath u) ..1 = refl (u.1)      := idp\n  @[hott] def eq_fst_con (p : u = v) (q : v = w) : (p \u2b1d q)  ..1 = (p..1) \u2b1d (q..1) := ap_con _ _ _\n  @[hott] def eq_fst_inv (p : u = v)             : p\u207b\u00b9      ..1 = (p..1)\u207b\u00b9        := 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\u2081 = b\u2082) :\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 \u25b8D c = transport (\u03bbu : 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; \u03bb p, b =[p] b'] q2) : @sigma_eq _ _ \u27e8a,b\u27e9 \u27e8a',b'\u27e9 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; \u03bb 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 : \u03a3(r : p..1 = q..1), p..2 =[r; \u03bb 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 : \u03a0a, B a \u2192 A') (p : a = a') (q : b =[p] b')\n    : @ap _ A' (@sigma.rec _ _ (\u03bb _, 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 : \u03a3(b : B a), C a b)\n    : p \u25b8 bc = \u27e8p \u25b8 bc.1, p \u25b8D bc.2\u27e9 :=\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 \u2192 B \u2192 Type _} (p : a = a')\n    (bc : \u03a3(b : B), C a b) : p \u25b8 bc = \u27e8bc.1, transport (\u03bb a, C a bc.1) p bc.2\u27e9 :=\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 \u2192 Type _} {D : \u03a0 a:A, B a \u2192 C a \u2192 Type _} (p : a = a')\n      (bcd : \u03a3(b : B a) (c : C a), D a b c) : p \u25b8 bcd = \u27e8p \u25b8 bcd.1, p \u25b8 bcd.2.1, p \u25b8D2 bcd.2.2\u27e9 :=\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 : \u03a3(b : B a), C a b)\n    : bc =[p; \u03bb a, \u03a3 b, C a b] \u27e8p \u25b8 bc.1, p \u25b8D bc.2\u27e9 :=\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 : \u03a3(b : B a), C a b) (v : \u03a3(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; \u03bb a, \u03a3 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 : \u03a3(b : B a), C a b) (v : \u03a3(b : B a'), C a' b)\n    (r : u.1 =[p] v.1) (s : @pathover (sigma _) \u27e8a,u.1\u27e9 (\u03bb x, C x.1 x.2) u.2 \u27e8a',v.1\u27e9 (sigma_eq p r) v.2) :\n    u =[p; \u03bb a, \u03a3 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 \u2192 B \u2192 Type _} (p : a = a')\n    (u : \u03a3(b : B), C a b) (v : \u03a3(b : B), C a' b)\n    (r : u.1 = v.1) (s : @pathover (prod _ _) (a,u.1) (\u03bbx, C x.1 x.2) u.2 (a',v.1) (prod.prod_eq p r) v.2) :\n    u =[p; \u03bb a, \u03a3 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 \u2192 Type _} {C : \u03a0a, B a \u2192 Type _}\n    {a a' : A} {p : a = a'} {x : \u03a3b, C a b} {x' : \u03a3b', C a' b'}\n    (q : x =[p; \u03bb a, \u03a3b, 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 \u2192 Type _} (C : \u03a0a, B a \u2192 Type _)\n    {a a' : A} (p : a = a') (x : \u03a3b, C a b) (x' : \u03a3b', C a' b')\n    [\u03a0a b, is_prop (C a b)] : x =[p; \u03bba, \u03a3b, C a b] x' \u2243 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 \u2192 A') (g : \u03a0a, B a \u2192 B' (f a))\n\n  @[hott] def sigma_functor (u : \u03a3a, B a) : \u03a3a', B' a' :=\n  \u27e8f u.1, g u.1 u.2\u27e9\n\n  @[hott] def total {B' : A \u2192 Type _} (g : \u03a0a, B a \u2192 B' a) : (\u03a3a, B a) \u2192 (\u03a3a, B' a) :=\n  sigma_functor id g\n\n  /- Equivalences -/\n  @[hott] def is_equiv_sigma_functor [H1 : is_equiv f] [H2 : \u03a0 a, is_equiv (g a)]\n      : is_equiv (sigma_functor f g) :=\n  adjointify (sigma_functor f g)\n             (sigma_functor f\u207b\u00b9\u1da0 (\u03bb(a' : A') (b' : B' a'),\n               ((g (f\u207b\u00b9\u1da0 a'))\u207b\u00b9\u1da0 (transport B' (right_inv f a')\u207b\u00b9 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\u207b\u00b9\u1da0 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, \u2190 fn_tr_eq_tr_fn (left_inv f a) (\u03bb a, (g a)\u207b\u00b9\u1da0),\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 : \u03a0 a, is_equiv (g a)] : (\u03a3a, B a) \u2243 (\u03a3a', B' a') :=\n  equiv.mk (sigma_functor f g) (is_equiv_sigma_functor _ _)\n\n  @[hott] def sigma_equiv_sigma (Hf : A \u2243 A') (Hg : \u03a0 a, B a \u2243 B' (Hf a)) :\n      (\u03a3a, B a) \u2243 (\u03a3a', B' a') :=\n  sigma_equiv_sigma_of_is_equiv Hf (\u03bb a, Hg a)\n\n  @[hott] def sigma_equiv_sigma_right {B' : A \u2192 Type _} (Hg : \u03a0 a, B a \u2243 B' a)\n    : (\u03a3a, B a) \u2243 \u03a3a, B' a :=\n  sigma_equiv_sigma equiv.rfl Hg\n\n  variable (B)\n  @[hott] def sigma_equiv_sigma_left (Hf : A \u2243 A') :\n    (\u03a3a, B a) \u2243 (\u03a3a', B (Hf\u207b\u00b9\u1da0 a')) :=\n  sigma_equiv_sigma Hf (\u03bb a, equiv_ap B (right_inv Hf\u207b\u00b9\u1da0 a)\u207b\u00b9\u1d56)\n\n  @[hott] def sigma_equiv_sigma_left' (Hf : A' \u2243 A) : (\u03a3a, B (Hf a)) \u2243 (\u03a3a', B a') :=\n  sigma_equiv_sigma Hf (\u03bba, 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 _ _ \u27e8a,b\u27e9 \u27e8a',b'\u27e9 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 \u2243 B \u2192 Type _) :\n    (\u03a3(p : A = B), C (equiv_of_eq p)) \u2243 \u03a3(e : A \u2243 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))\u207b\u00b9 \u2b1d (fn_tr_eq_tr_fn p g u.2)\u207b\u00b9 \u2b1d 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 \u2192 Type _) [H : \u03a0 a, is_contr (B a)]\n      : is_equiv (@fst A B) :=\n  adjointify fst\n             (\u03bba, \u27e8a, center _\u27e9)\n             (\u03bba, idp)\n             (\u03bbu, sigma_eq idp (pathover_idp_of_eq _ (center_eq _)))\n\n  @[hott] def sigma_equiv_of_is_contr_right (B : A \u2192 Type _) [H : \u03a0 a, is_contr (B a)]\n    : (\u03a3a, B a) \u2243 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 \u2192 Type _) [H : is_contr A]\n    : (\u03a3a, B a) \u2243 B (center A) :=\n  equiv.MK\n    (\u03bbu, (center_eq u.1)\u207b\u00b9 \u25b8 u.2)\n    (\u03bbb, \u27e8center _, b\u27e9)\n    begin abstract { intro b, change _ = idpath (center A) \u25b8 b,\n      apply ap (\u03bbx, x \u25b8 b), apply prop_eq_of_is_contr, } end\n    begin abstract { exact \u03bbu, 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 : (\u03a3a, B a) \u2192 Type _)\n    : (\u03a3a b, C \u27e8a, b\u27e9) \u2243 (\u03a3u, C u) :=\n  equiv.mk _ (adjointify\n    (\u03bbav, \u27e8\u27e8av.1, av.2.1\u27e9, av.2.2\u27e9)\n    (\u03bbuc, \u27e8uc.1.1, uc.1.2, by rwr sigma.eta; exact uc.2\u27e9)\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 \u00d7 A') \u2192 Type _) : (\u03a3a a', C (a,a')) \u2243 (\u03a3u, C u) :=\n  equiv.mk _ (adjointify\n    (\u03bbav, \u27e8(av.1, av.2.1), av.2.2\u27e9)\n    (\u03bbuc, \u27e8(uc.1).1, (uc.1).2, by rwr prod.eta; exact uc.2\u27e9)\n    (\u03bb \u27e8\u27e8a,b\u27e9,c\u27e9, idp) (\u03bb \u27e8a,\u27e8b,c\u27e9\u27e9, idp))\n\n  /- Symmetry -/\n\n  @[hott] def comm_equiv_unc (C : A \u00d7 A' \u2192 Type _) : (\u03a3a a', C (a, a')) \u2243 (\u03a3a' a, C (a, a')) :=\n  calc\n    (\u03a3a a', C (a, a')) \u2243 \u03a3u, C u          : assoc_equiv_prod _\n                   ... \u2243 \u03a3v, C (flip v)   : sigma_equiv_sigma (prod.prod_comm_equiv _ _)\n                                              (\u03bb \u27e8a,a'\u27e9, equiv.rfl)\n                   ... \u2243 \u03a3a' a, C (a, a') : by symmetry; exact assoc_equiv_prod (C \u2218 prod.flip)\n\n  @[hott] def sigma_comm_equiv (C : A \u2192 A' \u2192 Type _)\n    : (\u03a3a a', C a a') \u2243 (\u03a3a' a, C a a') :=\n  comm_equiv_unc (\u03bbu, C (fst u) (snd u))\n\n  @[hott] def equiv_prod (A B : Type _) : (\u03a3(a : A), B) \u2243 A \u00d7 B :=\n  equiv.mk _ (adjointify\n    (\u03bbs, (s.1, s.2))\n    (\u03bbp, \u27e8fst p, snd p\u27e9)\n    (\u03bb\u27e8a,b\u27e9, idp) (\u03bb\u27e8a,b\u27e9, idp))\n\n  @[hott] def comm_equiv_nondep (A B : Type _) : (\u03a3(a : A), B) \u2243 \u03a3(b : B), A :=\n  calc\n    (\u03a3(a : A), B) \u2243 A \u00d7 B       : by apply equiv_prod\n              ... \u2243 B \u00d7 A       : by apply prod.prod_comm_equiv\n              ... \u2243 \u03a3(b : B), A : by symmetry; apply equiv_prod\n\n  @[hott] def sigma_assoc_comm_equiv {A : Type _} (B C : A \u2192 Type _)\n    : (\u03a3(v : \u03a3a, B a), C v.1) \u2243 (\u03a3(u : \u03a3a, C a), B u.1) :=\n  calc    (\u03a3(v : \u03a3a, B a), C v.1)\n        \u2243 (\u03a3a (b : B a), C a)     : by symmetry; apply sigma_assoc_equiv (C \u2218 fst)\n    ... \u2243 (\u03a3a (c : C a), B a)     : by apply sigma_equiv_sigma_right; intro a; apply comm_equiv_nondep\n    ... \u2243 (\u03a3(u : \u03a3a, C a), B u.1) : by apply sigma_assoc_equiv (B \u2218 fst)\n\n  /- Interaction with other type constructors -/\n\n  @[hott] def sigma_empty_left (B : empty \u2192 Type _) : (\u03a3x, B x) \u2243 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 _) : (\u03a3(a : A), empty) \u2243 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 \u2192 Type _) : (\u03a3x, B x) \u2243 B star :=\n  sigma_equiv_of_is_contr_left _\n\n  @[hott] def sigma_unit_right (A : Type _) : (\u03a3(a : A), unit) \u2243 A :=\n  sigma_equiv_of_is_contr_right _\n\n  @[hott] def sigma_sum_left (B : A \u228e A' \u2192 Type _)\n    : (\u03a3p, B p) \u2243 (\u03a3a, B (inl a)) \u228e (\u03a3a, 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 \u2192 Type _)\n    : (\u03a3a, B a \u228e C a) \u2243 (\u03a3a, B a) \u228e (\u03a3a, 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 : \u03a0(b : A), a = b \u2192 Type _)\n    : (\u03a3(b : A) (p : a = b), P b p) \u2243 P a idp :=\n  calc\n    (\u03a3(b : A) (p : a = b), P b p) \u2243 (\u03a3(v : \u03a3(b : A), a = b), P v.1 v.2) : by apply sigma_assoc_equiv (\u03bb u, P u.fst u.snd)\n      ... \u2243 P a idp : by apply sigma_equiv_of_is_contr_left (\u03bb v : \u03a3 b, a=b, P v.fst v.snd)\n\n  @[hott] def sigma_sigma_eq_left {A : Type _} (a : A) (P : \u03a0(b : A), b = a \u2192 Type _)\n    : (\u03a3(b : A) (p : b = a), P b p) \u2243 P a idp :=\n  calc\n    (\u03a3(b : A) (p : b = a), P b p) \u2243 (\u03a3(v : \u03a3(b : A), b = a), P v.1 v.2) : by apply sigma_assoc_equiv (\u03bb u : \u03a3 b, b=a, P u.fst u.snd)\n      ... \u2243 P a idp : by apply sigma_equiv_of_is_contr_left (\u03bb v : \u03a3 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 : (\u03a3a, B a) \u2192 Type _)\n    : is_equiv (sigma.rec : (\u03a0a b, C \u27e8a, b\u27e9) \u2192 \u03a0ab, C ab) :=\n  adjointify _ (\u03bb g a b, g \u27e8a, b\u27e9)\n               (\u03bb g, eq_of_homotopy (\u03bb\u27e8a,b\u27e9, idp))\n               (\u03bb f, refl f)\n\n  @[hott] def equiv_sigma_rec (C : (\u03a3a, B a) \u2192 Type _)\n    : (\u03a0(a : A) (b: B a), C \u27e8a, b\u27e9) \u2243 (\u03a0xy, C xy) :=\n  equiv.mk sigma.rec (by apply_instance)\n\n  /- *** The negative universal property. -/\n\n  @[hott] protected def coind_unc (fg : \u03a3(f : \u03a0a, B a), \u03a0a, C a (f a)) (a : A)\n    : \u03a3(b : B a), C a b :=\n  \u27e8fg.1 a, fg.2 a\u27e9\n\n  @[hott] protected def coind (f : \u03a0 a, B a) (g : \u03a0 a, C a (f a)) (a : A) : \u03a3(b : B a), C a b :=\n  sigma.coind_unc \u27e8f, g\u27e9 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 : \u03a0a, B a \u2192 Type _)\n    : is_equiv (@sigma.coind_unc _ _ C) :=\n  adjointify _ (\u03bb h, \u27e8\u03bba, (h a).1, \u03bba, (h a).2\u27e9)\n               (\u03bb h, eq_of_homotopy (\u03bbu, sigma.eta _))\n               (\u03bb\u27e8f,g\u27e9, idp)\n\n  variable (C)\n  @[hott] def sigma_pi_equiv_pi_sigma : (\u03a3(f : \u03a0a, B a), \u03a0a, C a (f a)) \u2243 (\u03a0a, \u03a3b, 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 \u2192 Type _) [H : \u03a0a, is_prop (P a)] :=\n  \u03a3(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 : \u03a0a, is_prop (B a)] {u v : {a | B a}} :\n    u.1 = v.1 \u2192 u = v :=\n  sigma_eq_unc \u2218 inv fst\n\n  @[hott] def is_equiv_subtype_eq [H : \u03a0a, is_prop (B a)] (u v : {a | B a})\n      : is_equiv (subtype_eq : u.1 = v.1 \u2192 u = v) :=\n  is_equiv_compose _ _\n  local attribute [instance] is_equiv_subtype_eq\n\n  @[hott] def equiv_subtype [H : \u03a0a, is_prop (B a)] (u v : {a | B a}) :\n    (u.1 = v.1) \u2243 (u = v) :=\n  equiv.mk subtype_eq (by apply_instance)\n\n  @[hott] def subtype_eq_equiv [H : \u03a0a, is_prop (B a)] (u v : {a | B a}) :\n    (u = v) \u2243 (u.1 = v.1) :=\n  (equiv_subtype u v)\u207b\u00b9\u1d49\n\n  @[hott] def subtype_eq_inv {A : Type _} {B : A \u2192 Type _} [H : \u03a0a, is_prop (B a)] (u v : \u03a3a, B a)\n    : u = v \u2192 u.1 = v.1 :=\n  subtype_eq\u207b\u00b9\u1da0\n\n  @[hott] def is_equiv_subtype_eq_inv {A : Type _} {B : A \u2192 Type _} [H : \u03a0a, is_prop (B a)]\n    (u v : \u03a3a, 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 \u2192 Type _) (n : trunc_index)\n      [HA : is_trunc n A] [HB : \u03a0a, is_trunc n (B a)] : is_trunc n (\u03a3a, 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 \u2192 Prop) (n : trunc_index)\n      [HA : is_trunc (n.+1) A] : is_trunc (n.+1) (\u03a3a, B a) :=\n  @is_trunc_sigma _ (\u03bb a, B a) (n.+1) _ (\u03bba, 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 \u2192 Type _) (H : is_prop (\u03a3a, B a)) {a a' : A}\n    (b : B a) (b' : B a') : a = a' :=\n  (@is_prop.elim (\u03a3a, B a) _ \u27e8a, b\u27e9 \u27e8a', b'\u27e9)..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 \u2192 Type _) [G : pointed A]\n      [H : pointed (P pt)] : pointed (\u03a3x, P x) :=\n  pointed.mk \u27e8pt,pt\u27e9\n\n  @[hott] def psigma {A : Type*} (P : A \u2192 Type*) : Type* :=\n  pointed.mk' (\u03a3a, P a)\n\n  notation `\u03a3*` binders `, ` r:(scoped P, psigma P) := r\n\n  @[hott] def pfst {A : Type*} {B : A \u2192 Type*} : (\u03a3*(x : A), B x) \u2192* A :=\n  pmap.mk fst idp\n\n  @[hott] def psnd {A : Type*} {B : A \u2192 Type*} (v : (\u03a3*(x : A), B x)) : B (pfst.to_fun v) :=\n  snd v\n\n  @[hott] def ptsigma {n : \u2115\u208b\u2082} {A : n-Type*} (P : A \u2192 (n-Type*)) : n-Type* :=\n  ptrunctype.mk' n (\u03a3a, 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 {\u03b1 : Type*} : has_coe_to_sort (set \u03b1) := \u27e8_, \u03bb s, {x // x \u2208 s}\u27e9\nend set\n\nsection set_coe\nuniverse u\nvariables {\u03b1 : Type u}\ntheorem set.set_coe_eq_subtype (s : set \u03b1) :\n  coe_sort.{(u+1) (u+2)} s = {x // x \u2208 s} := rfl\n\n@[simp] theorem set_coe.forall {s : set \u03b1} {p : s \u2192 Prop} :\n  (\u2200 x : s, p x) \u2194 (\u2200 x (h : x \u2208 s), p \u27e8x, h\u27e9) :=\nsubtype.forall\n\n@[simp] theorem set_coe.exists {s : set \u03b1} {p : s \u2192 Prop} :\n  (\u2203 x : s, p x) \u2194 (\u2203 x (h : x \u2208 s), p \u27e8x, h\u27e9) :=\nsubtype.exists\n\n@[simp] theorem set_coe_cast : \u2200 {s t : set \u03b1} (H' : s = t) (H : @eq (Type u) s t) (x : s),\n  cast H x = \u27e8x.1, H' \u25b8 x.2\u27e9\n| s _ rfl _ \u27e8x, h\u27e9 := rfl\n\ntheorem set_coe.ext {s : set \u03b1} {a b : s} : (\u2191a : \u03b1) = \u2191b \u2192 a = b :=\nsubtype.eq\n\ntheorem set_coe.ext_iff {s : set \u03b1} {a b : s} : (\u2191a : \u03b1) = \u2191b \u2194 a = b :=\niff.intro set_coe.ext (assume h, h \u25b8 rfl)\n\nend set_coe\n\nlemma subtype.mem {\u03b1 : Type*} {s : set \u03b1} (p : s) : (p : \u03b1) \u2208 s := p.property\n\nnamespace set\nuniverses u v w x\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b9 : Sort x} {a : \u03b1} {s t : set \u03b1}\n\ninstance : inhabited (set \u03b1) := \u27e8\u2205\u27e9\n\n@[extensionality]\ntheorem ext {a b : set \u03b1} (h : \u2200 x, x \u2208 a \u2194 x \u2208 b) : a = b :=\nfunext (assume x, propext (h x))\n\ntheorem ext_iff (s t : set \u03b1) : s = t \u2194 \u2200 x, x \u2208 s \u2194 x \u2208 t :=\n\u27e8\u03bb h x, by rw h, ext\u27e9\n\n@[trans] theorem mem_of_mem_of_subset {\u03b1 : Type u} {x : \u03b1} {s t : set \u03b1} (hx : x \u2208 s) (h : s \u2286 t) : x \u2208 t :=\nh hx\n\n/- mem and set_of -/\n\n@[simp] theorem mem_set_of_eq {a : \u03b1} {p : \u03b1 \u2192 Prop} : a \u2208 {a | p a} = p a := rfl\n\n@[simp] theorem nmem_set_of_eq {a : \u03b1} {P : \u03b1 \u2192 Prop} : a \u2209 {a : \u03b1 | P a} = \u00ac P a := rfl\n\n@[simp] theorem set_of_mem_eq {s : set \u03b1} : {x | x \u2208 s} = s := rfl\n\ntheorem mem_def {a : \u03b1} {s : set \u03b1} : a \u2208 s \u2194 s a := iff.rfl\n\ninstance decidable_mem (s : set \u03b1) [H : decidable_pred s] : \u2200 a, decidable (a \u2208 s) := H\n\ninstance decidable_set_of (p : \u03b1 \u2192 Prop) [H : decidable_pred p] : decidable_pred {a | p a} := H\n\n@[simp] theorem set_of_subset_set_of {p q : \u03b1 \u2192 Prop} : {a | p a} \u2286 {a | q a} \u2194 (\u2200a, p a \u2192 q a) := iff.rfl\n\n@[simp] lemma sep_set_of {\u03b1} {p q : \u03b1 \u2192 Prop} : {a \u2208 {a | p a } | q a} = {a | p a \u2227 q a} :=\nrfl\n\n@[simp] lemma set_of_mem {\u03b1} {s : set \u03b1} : {a | a \u2208 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 \u03b1} : (s \u2286 t) = \u2200 x, x \u2208 s \u2192 x \u2208 t := rfl\n\n@[refl] theorem subset.refl (a : set \u03b1) : a \u2286 a := assume x, id\n\n@[trans] theorem subset.trans {a b c : set \u03b1} (ab : a \u2286 b) (bc : b \u2286 c) : a \u2286 c :=\nassume x h, bc (ab h)\n\n@[trans] theorem mem_of_eq_of_mem {\u03b1 : Type u} {x y : \u03b1} {s : set \u03b1} (hx : x = y) (h : y \u2208 s) : x \u2208 s :=\nhx.symm \u25b8 h\n\ntheorem subset.antisymm {a b : set \u03b1} (h\u2081 : a \u2286 b) (h\u2082 : b \u2286 a) : a = b :=\next (\u03bb x, iff.intro (\u03bb ina, h\u2081 ina) (\u03bb inb, h\u2082 inb))\n\ntheorem subset.antisymm_iff {a b : set \u03b1} : a = b \u2194 a \u2286 b \u2227 b \u2286 a :=\n\u27e8\u03bb e, e \u25b8 \u27e8subset.refl _, subset.refl _\u27e9,\n \u03bb \u27e8h\u2081, h\u2082\u27e9, subset.antisymm h\u2081 h\u2082\u27e9\n\n-- an alterantive name\ntheorem eq_of_subset_of_subset {a b : set \u03b1} (h\u2081 : a \u2286 b) (h\u2082 : b \u2286 a) : a = b :=\nsubset.antisymm h\u2081 h\u2082\n\ntheorem mem_of_subset_of_mem {s\u2081 s\u2082 : set \u03b1} {a : \u03b1} : s\u2081 \u2286 s\u2082 \u2192 a \u2208 s\u2081 \u2192 a \u2208 s\u2082 :=\nassume h\u2081 h\u2082, h\u2081 h\u2082\n\ntheorem not_subset : (\u00ac s \u2286 t) \u2194 \u2203a, a \u2208 s \u2227 a \u2209 t :=\nby simp [subset_def, classical.not_forall]\n\n/- strict subset -/\n\n/-- `s \u2282 t` means that `s` is a strict subset of `t`, that is, `s \u2286 t` but `s \u2260 t`. -/\ndef strict_subset (s t : set \u03b1) := s \u2286 t \u2227 s \u2260 t\n\ninstance : has_ssubset (set \u03b1) := \u27e8strict_subset\u27e9\n\ntheorem ssubset_def : (s \u2282 t) = (s \u2286 t \u2227 s \u2260 t) := rfl\n\nlemma exists_of_ssubset {\u03b1 : Type u} {s t : set \u03b1} (h : s \u2282 t) : (\u2203x\u2208t, x \u2209 s) :=\nclassical.by_contradiction $ assume hn,\n  have t \u2286 s, from assume a hat, classical.by_contradiction $ assume has, hn \u27e8a, hat, has\u27e9,\n  h.2 $ subset.antisymm h.1 this\n\nlemma ssubset_iff_subset_not_subset {s t : set \u03b1} : s \u2282 t \u2194 s \u2286 t \u2227 \u00ac t \u2286 s :=\nby split; simp [set.ssubset_def, ne.def, set.subset.antisymm_iff] {contextual := tt}\n\ntheorem not_mem_empty (x : \u03b1) : \u00ac (x \u2208 (\u2205 : set \u03b1)) :=\nassume h : x \u2208 \u2205, h\n\n@[simp] theorem not_not_mem [decidable (a \u2208 s)] : \u00ac (a \u2209 s) \u2194 a \u2208 s :=\nnot_not\n\n/- empty set -/\n\ntheorem empty_def : (\u2205 : set \u03b1) = {x | false} := rfl\n\n@[simp] theorem mem_empty_eq (x : \u03b1) : x \u2208 (\u2205 : set \u03b1) = false := rfl\n\n@[simp] theorem set_of_false : {a : \u03b1 | false} = \u2205 := rfl\n\ntheorem eq_empty_iff_forall_not_mem {s : set \u03b1} : s = \u2205 \u2194 \u2200 x, x \u2209 s :=\nby simp [ext_iff]\n\ntheorem ne_empty_of_mem {s : set \u03b1} {x : \u03b1} (h : x \u2208 s) : s \u2260 \u2205 :=\nby { intro hs, rw hs at h, apply not_mem_empty _ h }\n\n@[simp] theorem empty_subset (s : set \u03b1) : \u2205 \u2286 s :=\nassume x, assume h, false.elim h\n\ntheorem subset_empty_iff {s : set \u03b1} : s \u2286 \u2205 \u2194 s = \u2205 :=\nby simp [subset.antisymm_iff]\n\ntheorem eq_empty_of_subset_empty {s : set \u03b1} : s \u2286 \u2205 \u2192 s = \u2205 :=\nsubset_empty_iff.1\n\ntheorem ne_empty_iff_exists_mem {s : set \u03b1} : s \u2260 \u2205 \u2194 \u2203 x, x \u2208 s :=\nby haveI := classical.prop_decidable;\n   simp [eq_empty_iff_forall_not_mem]\n\ntheorem exists_mem_of_ne_empty {s : set \u03b1} : s \u2260 \u2205 \u2192 \u2203 x, x \u2208 s :=\nne_empty_iff_exists_mem.1\n\ntheorem coe_nonempty_iff_ne_empty {s : set \u03b1} : nonempty s \u2194 s \u2260 \u2205 :=\nnonempty_subtype.trans ne_empty_iff_exists_mem.symm\n\n-- TODO: remove when simplifier stops rewriting `a \u2260 b` to `\u00ac a = b`\ntheorem not_eq_empty_iff_exists {s : set \u03b1} : \u00ac (s = \u2205) \u2194 \u2203 x, x \u2208 s :=\nne_empty_iff_exists_mem\n\ntheorem subset_eq_empty {s t : set \u03b1} (h : t \u2286 s) (e : s = \u2205) : t = \u2205 :=\nsubset_empty_iff.1 $ e \u25b8 h\n\ntheorem subset_ne_empty {s t : set \u03b1} (h : t \u2286 s) : t \u2260 \u2205 \u2192 s \u2260 \u2205 :=\nmt (subset_eq_empty h)\n\ntheorem ball_empty_iff {p : \u03b1 \u2192 Prop} :\n  (\u2200 x \u2208 (\u2205 : set \u03b1), p x) \u2194 true :=\nby simp [iff_def]\n\n/- universal set -/\n\ntheorem univ_def : @univ \u03b1 = {x | true} := rfl\n\n@[simp] theorem mem_univ (x : \u03b1) : x \u2208 @univ \u03b1 := trivial\n\ntheorem empty_ne_univ [h : inhabited \u03b1] : (\u2205 : set \u03b1) \u2260 univ :=\nby simp [ext_iff]\n\n@[simp] theorem subset_univ (s : set \u03b1) : s \u2286 univ := \u03bb x H, trivial\n\ntheorem univ_subset_iff {s : set \u03b1} : univ \u2286 s \u2194 s = univ :=\nby simp [subset.antisymm_iff]\n\ntheorem eq_univ_of_univ_subset {s : set \u03b1} : univ \u2286 s \u2192 s = univ :=\nuniv_subset_iff.1\n\ntheorem eq_univ_iff_forall {s : set \u03b1} : s = univ \u2194 \u2200 x, x \u2208 s :=\nby simp [ext_iff]\n\ntheorem eq_univ_of_forall {s : set \u03b1} : (\u2200 x, x \u2208 s) \u2192 s = univ := eq_univ_iff_forall.2\n\n@[simp] lemma univ_eq_empty_iff {\u03b1 : Type*} : (univ : set \u03b1) = \u2205 \u2194 \u00ac nonempty \u03b1 :=\neq_empty_iff_forall_not_mem.trans \u27e8\u03bb H \u27e8x\u27e9, H x trivial, \u03bb H x _, H \u27e8x\u27e9\u27e9\n\nlemma nonempty_iff_univ_ne_empty {\u03b1 : Type*} : nonempty \u03b1 \u2194 (univ : set \u03b1) \u2260 \u2205 :=\nby classical; exact iff_not_comm.1 univ_eq_empty_iff\n\nlemma exists_mem_of_nonempty (\u03b1) : \u2200 [nonempty \u03b1], \u2203x:\u03b1, x \u2208 (univ : set \u03b1)\n| \u27e8x\u27e9 := \u27e8x, trivial\u27e9\n\n@[simp] lemma univ_ne_empty {\u03b1} [h : nonempty \u03b1] : (univ : set \u03b1) \u2260 \u2205 :=\n\u03bb e, univ_eq_empty_iff.1 e h\n\ninstance univ_decidable : decidable_pred (@set.univ \u03b1) :=\n\u03bb x, is_true trivial\n\n/- union -/\n\ntheorem union_def {s\u2081 s\u2082 : set \u03b1} : s\u2081 \u222a s\u2082 = {a | a \u2208 s\u2081 \u2228 a \u2208 s\u2082} := rfl\n\ntheorem mem_union_left {x : \u03b1} {a : set \u03b1} (b : set \u03b1) : x \u2208 a \u2192 x \u2208 a \u222a b := or.inl\n\ntheorem mem_union_right {x : \u03b1} {b : set \u03b1} (a : set \u03b1) : x \u2208 b \u2192 x \u2208 a \u222a b := or.inr\n\ntheorem mem_or_mem_of_mem_union {x : \u03b1} {a b : set \u03b1} (H : x \u2208 a \u222a b) : x \u2208 a \u2228 x \u2208 b := H\n\ntheorem mem_union.elim {x : \u03b1} {a b : set \u03b1} {P : Prop}\n    (H\u2081 : x \u2208 a \u222a b) (H\u2082 : x \u2208 a \u2192 P) (H\u2083 : x \u2208 b \u2192 P) : P :=\nor.elim H\u2081 H\u2082 H\u2083\n\ntheorem mem_union (x : \u03b1) (a b : set \u03b1) : x \u2208 a \u222a b \u2194 x \u2208 a \u2228 x \u2208 b := iff.rfl\n\n@[simp] theorem mem_union_eq (x : \u03b1) (a b : set \u03b1) : x \u2208 a \u222a b = (x \u2208 a \u2228 x \u2208 b) := rfl\n\n@[simp] theorem union_self (a : set \u03b1) : a \u222a a = a :=\next (assume x, or_self _)\n\n@[simp] theorem union_empty (a : set \u03b1) : a \u222a \u2205 = a :=\next (assume x, or_false _)\n\n@[simp] theorem empty_union (a : set \u03b1) : \u2205 \u222a a = a :=\next (assume x, false_or _)\n\ntheorem union_comm (a b : set \u03b1) : a \u222a b = b \u222a a :=\next (assume x, or.comm)\n\ntheorem union_assoc (a b c : set \u03b1) : (a \u222a b) \u222a c = a \u222a (b \u222a c) :=\next (assume x, or.assoc)\n\ninstance union_is_assoc : is_associative (set \u03b1) (\u222a) :=\n\u27e8union_assoc\u27e9\n\ninstance union_is_comm : is_commutative (set \u03b1) (\u222a) :=\n\u27e8union_comm\u27e9\n\ntheorem union_left_comm (s\u2081 s\u2082 s\u2083 : set \u03b1) : s\u2081 \u222a (s\u2082 \u222a s\u2083) = s\u2082 \u222a (s\u2081 \u222a s\u2083) :=\nby finish\n\ntheorem union_right_comm (s\u2081 s\u2082 s\u2083 : set \u03b1) : (s\u2081 \u222a s\u2082) \u222a s\u2083 = (s\u2081 \u222a s\u2083) \u222a s\u2082 :=\nby finish\n\ntheorem union_eq_self_of_subset_left {s t : set \u03b1} (h : s \u2286 t) : s \u222a t = t :=\nby finish [subset_def, ext_iff, iff_def]\n\ntheorem union_eq_self_of_subset_right {s t : set \u03b1} (h : t \u2286 s) : s \u222a t = s :=\nby finish [subset_def, ext_iff, iff_def]\n\n@[simp] theorem subset_union_left (s t : set \u03b1) : s \u2286 s \u222a t := \u03bb x, or.inl\n\n@[simp] theorem subset_union_right (s t : set \u03b1) : t \u2286 s \u222a t := \u03bb x, or.inr\n\ntheorem union_subset {s t r : set \u03b1} (sr : s \u2286 r) (tr : t \u2286 r) : s \u222a t \u2286 r :=\nby finish [subset_def, union_def]\n\n@[simp] theorem union_subset_iff {s t u : set \u03b1} : s \u222a t \u2286 u \u2194 s \u2286 u \u2227 t \u2286 u :=\nby finish [iff_def, subset_def]\n\ntheorem union_subset_union {s\u2081 s\u2082 t\u2081 t\u2082 : set \u03b1} (h\u2081 : s\u2081 \u2286 s\u2082) (h\u2082 : t\u2081 \u2286 t\u2082) : s\u2081 \u222a t\u2081 \u2286 s\u2082 \u222a t\u2082 :=\nby finish [subset_def]\n\ntheorem union_subset_union_left {s\u2081 s\u2082 : set \u03b1} (t) (h : s\u2081 \u2286 s\u2082) : s\u2081 \u222a t \u2286 s\u2082 \u222a t :=\nunion_subset_union h (by refl)\n\ntheorem union_subset_union_right (s) {t\u2081 t\u2082 : set \u03b1} (h : t\u2081 \u2286 t\u2082) : s \u222a t\u2081 \u2286 s \u222a t\u2082 :=\nunion_subset_union (by refl) h\n\n@[simp] theorem union_empty_iff {s t : set \u03b1} : s \u222a t = \u2205 \u2194 s = \u2205 \u2227 t = \u2205 :=\n\u27e8by finish [ext_iff], by finish [ext_iff]\u27e9\n\n/- intersection -/\n\ntheorem inter_def {s\u2081 s\u2082 : set \u03b1} : s\u2081 \u2229 s\u2082 = {a | a \u2208 s\u2081 \u2227 a \u2208 s\u2082} := rfl\n\ntheorem mem_inter_iff (x : \u03b1) (a b : set \u03b1) : x \u2208 a \u2229 b \u2194 x \u2208 a \u2227 x \u2208 b := iff.rfl\n\n@[simp] theorem mem_inter_eq (x : \u03b1) (a b : set \u03b1) : x \u2208 a \u2229 b = (x \u2208 a \u2227 x \u2208 b) := rfl\n\ntheorem mem_inter {x : \u03b1} {a b : set \u03b1} (ha : x \u2208 a) (hb : x \u2208 b) : x \u2208 a \u2229 b :=\n\u27e8ha, hb\u27e9\n\ntheorem mem_of_mem_inter_left {x : \u03b1} {a b : set \u03b1} (h : x \u2208 a \u2229 b) : x \u2208 a :=\nh.left\n\ntheorem mem_of_mem_inter_right {x : \u03b1} {a b : set \u03b1} (h : x \u2208 a \u2229 b) : x \u2208 b :=\nh.right\n\n@[simp] theorem inter_self (a : set \u03b1) : a \u2229 a = a :=\next (assume x, and_self _)\n\n@[simp] theorem inter_empty (a : set \u03b1) : a \u2229 \u2205 = \u2205 :=\next (assume x, and_false _)\n\n@[simp] theorem empty_inter (a : set \u03b1) : \u2205 \u2229 a = \u2205 :=\next (assume x, false_and _)\n\ntheorem inter_comm (a b : set \u03b1) : a \u2229 b = b \u2229 a :=\next (assume x, and.comm)\n\ntheorem inter_assoc (a b c : set \u03b1) : (a \u2229 b) \u2229 c = a \u2229 (b \u2229 c) :=\next (assume x, and.assoc)\n\ninstance inter_is_assoc : is_associative (set \u03b1) (\u2229) :=\n\u27e8inter_assoc\u27e9\n\ninstance inter_is_comm : is_commutative (set \u03b1) (\u2229) :=\n\u27e8inter_comm\u27e9\n\ntheorem inter_left_comm (s\u2081 s\u2082 s\u2083 : set \u03b1) : s\u2081 \u2229 (s\u2082 \u2229 s\u2083) = s\u2082 \u2229 (s\u2081 \u2229 s\u2083) :=\nby finish\n\ntheorem inter_right_comm (s\u2081 s\u2082 s\u2083 : set \u03b1) : (s\u2081 \u2229 s\u2082) \u2229 s\u2083 = (s\u2081 \u2229 s\u2083) \u2229 s\u2082 :=\nby finish\n\n@[simp] theorem inter_subset_left (s t : set \u03b1) : s \u2229 t \u2286 s := \u03bb x H, and.left H\n\n@[simp] theorem inter_subset_right (s t : set \u03b1) : s \u2229 t \u2286 t := \u03bb x H, and.right H\n\ntheorem subset_inter {s t r : set \u03b1} (rs : r \u2286 s) (rt : r \u2286 t) : r \u2286 s \u2229 t :=\nby finish [subset_def, inter_def]\n\n@[simp] theorem subset_inter_iff {s t r : set \u03b1} : r \u2286 s \u2229 t \u2194 r \u2286 s \u2227 r \u2286 t :=\n\u27e8\u03bb h, \u27e8subset.trans h (inter_subset_left _ _), subset.trans h (inter_subset_right _ _)\u27e9,\n \u03bb \u27e8h\u2081, h\u2082\u27e9, subset_inter h\u2081 h\u2082\u27e9\n\n@[simp] theorem inter_univ (a : set \u03b1) : a \u2229 univ = a :=\next (assume x, and_true _)\n\n@[simp] theorem univ_inter (a : set \u03b1) : univ \u2229 a = a :=\next (assume x, true_and _)\n\ntheorem inter_subset_inter_left {s t : set \u03b1} (u : set \u03b1) (H : s \u2286 t) : s \u2229 u \u2286 t \u2229 u :=\nby finish [subset_def]\n\ntheorem inter_subset_inter_right {s t : set \u03b1} (u : set \u03b1) (H : s \u2286 t) : u \u2229 s \u2286 u \u2229 t :=\nby finish [subset_def]\n\ntheorem inter_subset_inter {s\u2081 s\u2082 t\u2081 t\u2082 : set \u03b1} (h\u2081 : s\u2081 \u2286 t\u2081) (h\u2082 : s\u2082 \u2286 t\u2082) : s\u2081 \u2229 s\u2082 \u2286 t\u2081 \u2229 t\u2082 :=\nby finish [subset_def]\n\ntheorem inter_eq_self_of_subset_left {s t : set \u03b1} (h : s \u2286 t) : s \u2229 t = s :=\nby finish [subset_def, ext_iff, iff_def]\n\ntheorem inter_eq_self_of_subset_right {s t : set \u03b1} (h : t \u2286 s) : s \u2229 t = t :=\nby finish [subset_def, ext_iff, iff_def]\n\ntheorem union_inter_cancel_left {s t : set \u03b1} : (s \u222a t) \u2229 s = s :=\nby finish [ext_iff, iff_def]\n\ntheorem union_inter_cancel_right {s t : set \u03b1} : (s \u222a t) \u2229 t = t :=\nby finish [ext_iff, iff_def]\n\n-- TODO(Mario): remove?\ntheorem nonempty_of_inter_nonempty_right {s t : set \u03b1} (h : s \u2229 t \u2260 \u2205) : t \u2260 \u2205 :=\nby finish [ext_iff, iff_def]\n\ntheorem nonempty_of_inter_nonempty_left {s t : set \u03b1} (h : s \u2229 t \u2260 \u2205) : s \u2260 \u2205 :=\nby finish [ext_iff, iff_def]\n\n/- distributivity laws -/\n\ntheorem inter_distrib_left (s t u : set \u03b1) : s \u2229 (t \u222a u) = (s \u2229 t) \u222a (s \u2229 u) :=\next (assume x, and_or_distrib_left)\n\ntheorem inter_distrib_right (s t u : set \u03b1) : (s \u222a t) \u2229 u = (s \u2229 u) \u222a (t \u2229 u) :=\next (assume x, or_and_distrib_right)\n\ntheorem union_distrib_left (s t u : set \u03b1) : s \u222a (t \u2229 u) = (s \u222a t) \u2229 (s \u222a u) :=\next (assume x, or_and_distrib_left)\n\ntheorem union_distrib_right (s t u : set \u03b1) : (s \u2229 t) \u222a u = (s \u222a u) \u2229 (t \u222a u) :=\next (assume x, and_or_distrib_right)\n\n/- insert -/\n\ntheorem insert_def (x : \u03b1) (s : set \u03b1) : insert x s = { y | y = x \u2228 y \u2208 s } := rfl\n\n@[simp] theorem insert_of_has_insert (x : \u03b1) (s : set \u03b1) : has_insert.insert x s = insert x s := rfl\n\n@[simp] theorem subset_insert (x : \u03b1) (s : set \u03b1) : s \u2286 insert x s :=\nassume y ys, or.inr ys\n\ntheorem mem_insert (x : \u03b1) (s : set \u03b1) : x \u2208 insert x s :=\nor.inl rfl\n\ntheorem mem_insert_of_mem {x : \u03b1} {s : set \u03b1} (y : \u03b1) : x \u2208 s \u2192 x \u2208 insert y s := or.inr\n\ntheorem eq_or_mem_of_mem_insert {x a : \u03b1} {s : set \u03b1} : x \u2208 insert a s \u2192 x = a \u2228 x \u2208 s := id\n\ntheorem mem_of_mem_insert_of_ne {x a : \u03b1} {s : set \u03b1} (xin : x \u2208 insert a s) : x \u2260 a \u2192 x \u2208 s :=\nby finish [insert_def]\n\n@[simp] theorem mem_insert_iff {x a : \u03b1} {s : set \u03b1} : x \u2208 insert a s \u2194 (x = a \u2228 x \u2208 s) := iff.rfl\n\n@[simp] theorem insert_eq_of_mem {a : \u03b1} {s : set \u03b1} (h : a \u2208 s) : insert a s = s :=\nby finish [ext_iff, iff_def]\n\ntheorem insert_subset : insert a s \u2286 t \u2194 (a \u2208 t \u2227 s \u2286 t) :=\nby simp [subset_def, or_imp_distrib, forall_and_distrib]\n\ntheorem insert_subset_insert (h : s \u2286 t) : insert a s \u2286 insert a t :=\nassume a', or.imp_right (@h a')\n\ntheorem ssubset_insert {s : set \u03b1} {a : \u03b1} (h : a \u2209 s) : s \u2282 insert a s :=\nby finish [ssubset_def, ext_iff]\n\ntheorem insert_comm (a b : \u03b1) (s : set \u03b1) : insert a (insert b s) = insert b (insert a s) :=\next $ by simp [or.left_comm]\n\ntheorem insert_union : insert a s \u222a t = insert a (s \u222a t) :=\next $ assume a, by simp [or.comm, or.left_comm]\n\n@[simp] theorem union_insert : s \u222a insert a t = insert a (s \u222a t) :=\next $ assume a, by simp [or.comm, or.left_comm]\n\n-- TODO(Jeremy): make this automatic\ntheorem insert_ne_empty (a : \u03b1) (s : set \u03b1) : insert a s \u2260 \u2205 :=\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 : \u03b1 \u2192 Prop} {a : \u03b1} {s : set \u03b1} (h : \u2200 x, x \u2208 insert a s \u2192 P x) :\n  \u2200 x, x \u2208 s \u2192 P x :=\nby finish\n\ntheorem forall_insert_of_forall {P : \u03b1 \u2192 Prop} {a : \u03b1} {s : set \u03b1} (h : \u2200 x, x \u2208 s \u2192 P x) (ha : P a) :\n  \u2200 x, x \u2208 insert a s \u2192 P x :=\nby finish\n\ntheorem ball_insert_iff {P : \u03b1 \u2192 Prop} {a : \u03b1} {s : set \u03b1} :\n  (\u2200 x \u2208 insert a s, P x) \u2194 P a \u2227 (\u2200x \u2208 s, P x) :=\nby finish [iff_def]\n\n/- singletons -/\n\ntheorem singleton_def (a : \u03b1) : ({a} : set \u03b1) = insert a \u2205 := rfl\n\n@[simp] theorem mem_singleton_iff {a b : \u03b1} : a \u2208 ({b} : set \u03b1) \u2194 a = b :=\nby finish [singleton_def]\n\nlemma set_of_eq_eq_singleton {a : \u03b1} : {n | n = a} = {a} := set.ext $ \u03bb n, (set.mem_singleton_iff).symm\n\n-- TODO: again, annotation needed\n@[simp] theorem mem_singleton (a : \u03b1) : a \u2208 ({a} : set \u03b1) := by finish\n\ntheorem eq_of_mem_singleton {x y : \u03b1} (h : x \u2208 ({y} : set \u03b1)) : x = y :=\nby finish\n\n@[simp] theorem singleton_eq_singleton_iff {x y : \u03b1} : {x} = ({y} : set \u03b1) \u2194 x = y :=\nby finish [ext_iff, iff_def]\n\ntheorem mem_singleton_of_eq {x y : \u03b1} (H : x = y) : x \u2208 ({y} : set \u03b1) :=\nby finish\n\ntheorem insert_eq (x : \u03b1) (s : set \u03b1) : insert x s = ({x} : set \u03b1) \u222a s :=\nby finish [ext_iff, or_comm]\n\n@[simp] theorem pair_eq_singleton (a : \u03b1) : ({a, a} : set \u03b1) = {a} :=\nby finish\n\n@[simp] theorem singleton_ne_empty (a : \u03b1) : ({a} : set \u03b1) \u2260 \u2205 := insert_ne_empty _ _\n\n@[simp] theorem singleton_subset_iff {a : \u03b1} {s : set \u03b1} : {a} \u2286 s \u2194 a \u2208 s :=\n\u27e8\u03bbh, h (by simp), \u03bbh b e, by simp at e; simp [*]\u27e9\n\ntheorem set_compr_eq_eq_singleton {a : \u03b1} : {b | b = a} = {a} :=\next $ by simp\n\n@[simp] theorem union_singleton : s \u222a {a} = insert a s :=\nby simp [singleton_def]\n\n@[simp] theorem singleton_union : {a} \u222a s = insert a s :=\nby rw [union_comm, union_singleton]\n\ntheorem singleton_inter_eq_empty : {a} \u2229 s = \u2205 \u2194 a \u2209 s :=\nby simp [eq_empty_iff_forall_not_mem]\n\ntheorem inter_singleton_eq_empty : s \u2229 {a} = \u2205 \u2194 a \u2209 s :=\nby rw [inter_comm, singleton_inter_eq_empty]\n\n/- separation -/\n\ntheorem mem_sep {s : set \u03b1} {p : \u03b1 \u2192 Prop} {x : \u03b1} (xs : x \u2208 s) (px : p x) : x \u2208 {x \u2208 s | p x} :=\n\u27e8xs, px\u27e9\n\n@[simp] theorem mem_sep_eq {s : set \u03b1} {p : \u03b1 \u2192 Prop} {x : \u03b1} : x \u2208 {x \u2208 s | p x} = (x \u2208 s \u2227 p x) := rfl\n\ntheorem mem_sep_iff {s : set \u03b1} {p : \u03b1 \u2192 Prop} {x : \u03b1} : x \u2208 {x \u2208 s | p x} \u2194 x \u2208 s \u2227 p x :=\niff.rfl\n\ntheorem eq_sep_of_subset {s t : set \u03b1} (ssubt : s \u2286 t) : s = {x \u2208 t | x \u2208 s} :=\nby finish [ext_iff, iff_def, subset_def]\n\ntheorem sep_subset (s : set \u03b1) (p : \u03b1 \u2192 Prop) : {x \u2208 s | p x} \u2286 s :=\nassume x, and.left\n\ntheorem forall_not_of_sep_empty {s : set \u03b1} {p : \u03b1 \u2192 Prop} (h : {x \u2208 s | p x} = \u2205) :\n  \u2200 x \u2208 s, \u00ac p x :=\nby finish [ext_iff]\n\n@[simp] lemma sep_univ {\u03b1} {p : \u03b1 \u2192 Prop} : {a \u2208 (univ : set \u03b1) | p a} = {a | p a} :=\nset.ext $ by simp\n\n/- complement -/\n\ntheorem mem_compl {s : set \u03b1} {x : \u03b1} (h : x \u2209 s) : x \u2208 -s := h\n\nlemma compl_set_of {\u03b1} (p : \u03b1 \u2192 Prop) : - {a | p a} = { a | \u00ac p a } := rfl\n\ntheorem not_mem_of_mem_compl {s : set \u03b1} {x : \u03b1} (h : x \u2208 -s) : x \u2209 s := h\n\n@[simp] theorem mem_compl_eq (s : set \u03b1) (x : \u03b1) : x \u2208 -s = (x \u2209 s) := rfl\n\ntheorem mem_compl_iff (s : set \u03b1) (x : \u03b1) : x \u2208 -s \u2194 x \u2209 s := iff.rfl\n\n@[simp] theorem inter_compl_self (s : set \u03b1) : s \u2229 -s = \u2205 :=\nby finish [ext_iff]\n\n@[simp] theorem compl_inter_self (s : set \u03b1) : -s \u2229 s = \u2205 :=\nby finish [ext_iff]\n\n@[simp] theorem compl_empty : -(\u2205 : set \u03b1) = univ :=\nby finish [ext_iff]\n\n@[simp] theorem compl_union (s t : set \u03b1) : -(s \u222a t) = -s \u2229 -t :=\nby finish [ext_iff]\n\n@[simp] theorem compl_compl (s : set \u03b1) : -(-s) = s :=\nby finish [ext_iff]\n\n-- ditto\ntheorem compl_inter (s t : set \u03b1) : -(s \u2229 t) = -s \u222a -t :=\nby finish [ext_iff]\n\n@[simp] theorem compl_univ : -(univ : set \u03b1) = \u2205 :=\nby finish [ext_iff]\n\ntheorem union_eq_compl_compl_inter_compl (s t : set \u03b1) : s \u222a t = -(-s \u2229 -t) :=\nby simp [compl_inter, compl_compl]\n\ntheorem inter_eq_compl_compl_union_compl (s t : set \u03b1) : s \u2229 t = -(-s \u222a -t) :=\nby simp [compl_compl]\n\n@[simp] theorem union_compl_self (s : set \u03b1) : s \u222a -s = univ :=\nby finish [ext_iff]\n\n@[simp] theorem compl_union_self (s : set \u03b1) : -s \u222a s = univ :=\nby finish [ext_iff]\n\ntheorem compl_comp_compl : compl \u2218 compl = @id (set \u03b1) :=\nfunext compl_compl\n\ntheorem compl_subset_comm {s t : set \u03b1} : -s \u2286 t \u2194 -t \u2286 s :=\nby haveI := classical.prop_decidable; exact\nforall_congr (\u03bb a, not_imp_comm)\n\nlemma compl_subset_compl {s t : set \u03b1} : -s \u2286 -t \u2194 t \u2286 s :=\nby rw [compl_subset_comm, compl_compl]\n\ntheorem compl_subset_iff_union {s t : set \u03b1} : -s \u2286 t \u2194 s \u222a t = univ :=\niff.symm $ eq_univ_iff_forall.trans $ forall_congr $ \u03bb a,\nby haveI := classical.prop_decidable; exact or_iff_not_imp_left\n\ntheorem subset_compl_comm {s t : set \u03b1} : s \u2286 -t \u2194 t \u2286 -s :=\nforall_congr $ \u03bb a, imp_not_comm\n\ntheorem subset_compl_iff_disjoint {s t : set \u03b1} : s \u2286 -t \u2194 s \u2229 t = \u2205 :=\niff.trans (forall_congr $ \u03bb a, and_imp.symm) subset_empty_iff\n\ntheorem inter_subset (a b c : set \u03b1) : a \u2229 b \u2286 c \u2194 a \u2286 -b \u222a c :=\nbegin\n  haveI := classical.prop_decidable,\n  split,\n  { intros h x xa, by_cases h' : x \u2208 b, simp [h \u27e8xa, h'\u27e9], simp [h'] },\n  intros h x, rintro \u27e8xa, xb\u27e9, cases h xa, contradiction, assumption\nend\n\n/- set difference -/\n\ntheorem diff_eq (s t : set \u03b1) : s \\ t = s \u2229 -t := rfl\n\n@[simp] theorem mem_diff {s t : set \u03b1} (x : \u03b1) : x \u2208 s \\ t \u2194 x \u2208 s \u2227 x \u2209 t := iff.rfl\n\ntheorem mem_diff_of_mem {s t : set \u03b1} {x : \u03b1} (h1 : x \u2208 s) (h2 : x \u2209 t) : x \u2208 s \\ t :=\n\u27e8h1, h2\u27e9\n\ntheorem mem_of_mem_diff {s t : set \u03b1} {x : \u03b1} (h : x \u2208 s \\ t) : x \u2208 s :=\nh.left\n\ntheorem not_mem_of_mem_diff {s t : set \u03b1} {x : \u03b1} (h : x \u2208 s \\ t) : x \u2209 t :=\nh.right\n\ntheorem union_diff_cancel {s t : set \u03b1} (h : s \u2286 t) : s \u222a (t \\ s) = t :=\nby finish [ext_iff, iff_def, subset_def]\n\ntheorem union_diff_cancel_left {s t : set \u03b1} (h : s \u2229 t \u2286 \u2205) : (s \u222a t) \\ s = t :=\nby finish [ext_iff, iff_def, subset_def]\n\ntheorem union_diff_cancel_right {s t : set \u03b1} (h : s \u2229 t \u2286 \u2205) : (s \u222a t) \\ t = s :=\nby finish [ext_iff, iff_def, subset_def]\n\ntheorem union_diff_left {s t : set \u03b1} : (s \u222a t) \\ s = t \\ s :=\nby finish [ext_iff, iff_def]\n\ntheorem union_diff_right {s t : set \u03b1} : (s \u222a t) \\ t = s \\ t :=\nby finish [ext_iff, iff_def]\n\ntheorem union_diff_distrib {s t u : set \u03b1} : (s \u222a t) \\ u = s \\ u \u222a t \\ u :=\ninter_distrib_right _ _ _\n\ntheorem inter_diff_assoc (a b c : set \u03b1) : (a \u2229 b) \\ c = a \u2229 (b \\ c) :=\ninter_assoc _ _ _\n\ntheorem inter_diff_self (a b : set \u03b1) : a \u2229 (b \\ a) = \u2205 :=\nby finish [ext_iff]\n\ntheorem inter_union_diff (s t : set \u03b1) : (s \u2229 t) \u222a (s \\ t) = s :=\nby finish [ext_iff, iff_def]\n\ntheorem diff_subset (s t : set \u03b1) : s \\ t \u2286 s :=\nby finish [subset_def]\n\ntheorem diff_subset_diff {s\u2081 s\u2082 t\u2081 t\u2082 : set \u03b1} : s\u2081 \u2286 s\u2082 \u2192 t\u2082 \u2286 t\u2081 \u2192 s\u2081 \\ t\u2081 \u2286 s\u2082 \\ t\u2082 :=\nby finish [subset_def]\n\ntheorem diff_subset_diff_left {s\u2081 s\u2082 t : set \u03b1} (h : s\u2081 \u2286 s\u2082) : s\u2081 \\ t \u2286 s\u2082 \\ t :=\ndiff_subset_diff h (by refl)\n\ntheorem diff_subset_diff_right {s t u : set \u03b1} (h : t \u2286 u) : s \\ u \u2286 s \\ t :=\ndiff_subset_diff (subset.refl s) h\n\ntheorem compl_eq_univ_diff (s : set \u03b1) : -s = univ \\ s :=\nby finish [ext_iff]\n\n@[simp] lemma empty_diff {\u03b1 : Type*} (s : set \u03b1) : (\u2205 \\ s : set \u03b1) = \u2205 :=\neq_empty_of_subset_empty $ assume x \u27e8hx, _\u27e9, hx\n\ntheorem diff_eq_empty {s t : set \u03b1} : s \\ t = \u2205 \u2194 s \u2286 t :=\n\u27e8assume h x hx, classical.by_contradiction $ assume : x \u2209 t, show x \u2208 (\u2205 : set \u03b1), from h \u25b8 \u27e8hx, this\u27e9,\n  assume h, eq_empty_of_subset_empty $ assume x \u27e8hx, hnx\u27e9, hnx $ h hx\u27e9\n\n@[simp] theorem diff_empty {s : set \u03b1} : s \\ \u2205 = s :=\next $ assume x, \u27e8assume \u27e8hx, _\u27e9, hx, assume h, \u27e8h, not_false\u27e9\u27e9\n\ntheorem diff_diff {u : set \u03b1} : s \\ t \\ u = s \\ (t \u222a u) :=\next $ by simp [not_or_distrib, and.comm, and.left_comm]\n\nlemma diff_subset_iff {s t u : set \u03b1} : s \\ t \u2286 u \u2194 s \u2286 t \u222a u :=\n\u27e8assume h x xs, classical.by_cases or.inl (assume nxt, or.inr (h \u27e8xs, nxt\u27e9)),\n assume h x \u27e8xs, nxt\u27e9, or.resolve_left (h xs) nxt\u27e9\n\nlemma diff_subset_comm {s t u : set \u03b1} : s \\ t \u2286 u \u2194 s \\ u \u2286 t :=\nby rw [diff_subset_iff, diff_subset_iff, union_comm]\n\n@[simp] theorem insert_diff (h : a \u2208 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 \u03b1} : s \u222a (t \\ s) = s \u222a t :=\nby finish [ext_iff, iff_def]\n\ntheorem diff_union_self {s t : set \u03b1} : (s \\ t) \u222a t = s \u222a t :=\nby rw [union_comm, union_diff_self, union_comm]\n\ntheorem diff_inter_self {a b : set \u03b1} : (b \\ a) \u2229 a = \u2205 :=\next $ by simp [iff_def] {contextual:=tt}\n\ntheorem diff_eq_self {s t : set \u03b1} : s \\ t = s \u2194 t \u2229 s \u2286 \u2205 :=\nby finish [ext_iff, iff_def, subset_def]\n\n@[simp] theorem diff_singleton_eq_self {a : \u03b1} {s : set \u03b1} (h : a \u2209 s) : s \\ {a} = s :=\ndiff_eq_self.2 $ by simp [singleton_inter_eq_empty.2 h]\n\n@[simp] theorem insert_diff_singleton {a : \u03b1} {s : set \u03b1} :\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 \u03b1} : s \\ s = \u2205 := ext $ by simp\n\n/- powerset -/\n\ntheorem mem_powerset {x s : set \u03b1} (h : x \u2286 s) : x \u2208 powerset s := h\n\ntheorem subset_of_mem_powerset {x s : set \u03b1} (h : x \u2208 powerset s) : x \u2286 s := h\n\ntheorem mem_powerset_iff (x s : set \u03b1) : x \u2208 powerset s \u2194 x \u2286 s := iff.rfl\n\n/- inverse image -/\n\n/-- The preimage of `s : set \u03b2` by `f : \u03b1 \u2192 \u03b2`, written `f \u207b\u00b9' s`,\n  is the set of `x : \u03b1` such that `f x \u2208 s`. -/\ndef preimage {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (s : set \u03b2) : set \u03b1 := {x | f x \u2208 s}\n\ninfix ` \u207b\u00b9' `:80 := preimage\n\nsection preimage\nvariables {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3}\n\n@[simp] theorem preimage_empty : f \u207b\u00b9' \u2205 = \u2205 := rfl\n\n@[simp] theorem mem_preimage_eq {s : set \u03b2} {a : \u03b1} : (a \u2208 f \u207b\u00b9' s) = (f a \u2208 s) := rfl\n\ntheorem preimage_mono {s t : set \u03b2} (h : s \u2286 t) : f \u207b\u00b9' s \u2286 f \u207b\u00b9' t :=\nassume x hx, h hx\n\n@[simp] theorem preimage_univ : f \u207b\u00b9' univ = univ := rfl\n\n@[simp] theorem preimage_inter {s t : set \u03b2} : f \u207b\u00b9' (s \u2229 t) = f \u207b\u00b9' s \u2229 f \u207b\u00b9' t := rfl\n\n@[simp] theorem preimage_union {s t : set \u03b2} : f \u207b\u00b9' (s \u222a t) = f \u207b\u00b9' s \u222a f \u207b\u00b9' t := rfl\n\n@[simp] theorem preimage_compl {s : set \u03b2} : f \u207b\u00b9' (- s) = - (f \u207b\u00b9' s) := rfl\n\n@[simp] theorem preimage_diff (f : \u03b1 \u2192 \u03b2) (s t : set \u03b2) :\n  f \u207b\u00b9' (s \\ t) = f \u207b\u00b9' s \\ f \u207b\u00b9' t := rfl\n\n@[simp] theorem preimage_set_of_eq {p : \u03b1 \u2192 Prop} {f : \u03b2 \u2192 \u03b1} : f \u207b\u00b9' {a | p a} = {a | p (f a)} :=\nrfl\n\ntheorem preimage_id {s : set \u03b1} : id \u207b\u00b9' s = s := rfl\n\ntheorem preimage_comp {s : set \u03b3} : (g \u2218 f) \u207b\u00b9' s = f \u207b\u00b9' (g \u207b\u00b9' s) := rfl\n\ntheorem eq_preimage_subtype_val_iff {p : \u03b1 \u2192 Prop} {s : set (subtype p)} {t : set \u03b1} :\n  s = subtype.val \u207b\u00b9' t \u2194 (\u2200x (h : p x), (\u27e8x, h\u27e9 : subtype p) \u2208 s \u2194 x \u2208 t) :=\n\u27e8assume s_eq x h, by rw [s_eq]; simp,\n assume h, ext $ assume \u27e8x, hx\u27e9, by simp [h]\u27e9\n\nend preimage\n\n/- function image -/\n\nsection image\n\ninfix ` '' `:80 := image\n\n/-- Two functions `f\u2081 f\u2082 : \u03b1 \u2192 \u03b2` are equal on `s`\n  if `f\u2081 x = f\u2082 x` for all `x \u2208 a`. -/\n@[reducible] def eq_on (f1 f2 : \u03b1 \u2192 \u03b2) (a : set \u03b1) : Prop :=\n\u2200 x \u2208 a, f1 x = f2 x\n\n-- TODO(Jeremy): use bounded exists in image\n\ntheorem mem_image_iff_bex {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {y : \u03b2} :\n  y \u2208 f '' s \u2194 \u2203 x (_ : x \u2208 s), f x = y := bex_def.symm\n\ntheorem mem_image_eq (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (y: \u03b2) : y \u2208 f '' s = \u2203 x, x \u2208 s \u2227 f x = y := rfl\n\n@[simp] theorem mem_image (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (y : \u03b2) : y \u2208 f '' s \u2194 \u2203 x, x \u2208 s \u2227 f x = y := iff.rfl\n\ntheorem mem_image_of_mem (f : \u03b1 \u2192 \u03b2) {x : \u03b1} {a : set \u03b1} (h : x \u2208 a) : f x \u2208 f '' a :=\n\u27e8_, h, rfl\u27e9\n\ntheorem mem_image_of_injective {f : \u03b1 \u2192 \u03b2} {a : \u03b1} {s : set \u03b1} (hf : injective f) :\n  f a \u2208 f '' s \u2194 a \u2208 s :=\niff.intro\n  (assume \u27e8b, hb, eq\u27e9, (hf eq) \u25b8 hb)\n  (assume h, mem_image_of_mem _ h)\n\ntheorem ball_image_of_ball {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {p : \u03b2 \u2192 Prop}\n  (h : \u2200 x \u2208 s, p (f x)) : \u2200 y \u2208 f '' s, p y :=\nby finish [mem_image_eq]\n\n@[simp] theorem ball_image_iff {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {p : \u03b2 \u2192 Prop} :\n  (\u2200 y \u2208 f '' s, p y) \u2194 (\u2200 x \u2208 s, p (f x)) :=\niff.intro\n  (assume h a ha, h _ $ mem_image_of_mem _ ha)\n  (assume h b \u27e8a, ha, eq\u27e9, eq \u25b8 h a ha)\n\ntheorem mono_image {f : \u03b1 \u2192 \u03b2} {s t : set \u03b1} (h : s \u2286 t) : f '' s \u2286 f '' t :=\nassume x \u27e8y, hy, y_eq\u27e9, y_eq \u25b8 mem_image_of_mem _ $ h hy\n\ntheorem mem_image_elim {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {C : \u03b2 \u2192 Prop} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 C (f x)) :\n \u2200{y : \u03b2}, y \u2208 f '' s \u2192 C y\n| ._ \u27e8a, a_in, rfl\u27e9 := h a a_in\n\ntheorem mem_image_elim_on {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {C : \u03b2 \u2192 Prop} {y : \u03b2} (h_y : y \u2208 f '' s)\n  (h : \u2200 (x : \u03b1), x \u2208 s \u2192 C (f x)) : C y :=\nmem_image_elim h h_y\n\n@[congr] lemma image_congr {f g : \u03b1 \u2192 \u03b2} {s : set \u03b1}\n  (h : \u2200a\u2208s, f a = g a) : f '' s = g '' s :=\nby safe [ext_iff, iff_def]\n\ntheorem image_eq_image_of_eq_on {f\u2081 f\u2082 : \u03b1 \u2192 \u03b2} {s : set \u03b1} (heq : eq_on f\u2081 f\u2082 s) :\n  f\u2081 '' s = f\u2082 '' s :=\nimage_congr heq\n\ntheorem image_comp (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) (a : set \u03b1) : (f \u2218 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, (\u2218)],\n  have h' := h_2 (g a_2),\n  finish\nend -/\n\ntheorem image_subset {a b : set \u03b1} (f : \u03b1 \u2192 \u03b2) (h : a \u2286 b) : f '' a \u2286 f '' b :=\nby finish [subset_def, mem_image_eq]\n\ntheorem image_union (f : \u03b1 \u2192 \u03b2) (s t : set \u03b1) :\n  f '' (s \u222a t) = f '' s \u222a f '' t :=\nby finish [ext_iff, iff_def, mem_image_eq]\n\n@[simp] theorem image_empty (f : \u03b1 \u2192 \u03b2) : f '' \u2205 = \u2205 := ext $ by simp\n\ntheorem image_inter_on {f : \u03b1 \u2192 \u03b2} {s t : set \u03b1} (h : \u2200x\u2208t, \u2200y\u2208s, f x = f y \u2192 x = y) :\n  f '' s \u2229 f '' t = f '' (s \u2229 t) :=\nsubset.antisymm\n  (assume b \u27e8\u27e8a\u2081, ha\u2081, h\u2081\u27e9, \u27e8a\u2082, ha\u2082, h\u2082\u27e9\u27e9,\n    have a\u2082 = a\u2081, from h _ ha\u2082 _ ha\u2081 (by simp *),\n    \u27e8a\u2081, \u27e8ha\u2081, this \u25b8 ha\u2082\u27e9, h\u2081\u27e9)\n  (subset_inter (mono_image $ inter_subset_left _ _) (mono_image $ inter_subset_right _ _))\n\ntheorem image_inter {f : \u03b1 \u2192 \u03b2} {s t : set \u03b1} (H : injective f) :\n  f '' s \u2229 f '' t = f '' (s \u2229 t) :=\nimage_inter_on (assume x _ y _ h, H h)\n\ntheorem image_univ_of_surjective {\u03b9 : Type*} {f : \u03b9 \u2192 \u03b2} (H : surjective f) : f '' univ = univ :=\neq_univ_of_forall $ by simp [image]; exact H\n\n@[simp] theorem image_singleton {f : \u03b1 \u2192 \u03b2} {a : \u03b1} : f '' {a} = {f a} :=\next $ \u03bb x, by simp [image]; rw eq_comm\n\n@[simp] lemma image_eq_empty {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} : f '' s = \u2205 \u2194 s = \u2205 :=\nby simp only [eq_empty_iff_forall_not_mem]; exact\n\u27e8\u03bb H a ha, H _ \u27e8_, ha, rfl\u27e9, \u03bb H b \u27e8_, ha, _\u27e9, H _ ha\u27e9\n\nlemma inter_singleton_ne_empty {\u03b1 : Type*} {s : set \u03b1} {a : \u03b1} : s \u2229 {a} \u2260 \u2205 \u2194 a \u2208 s :=\nby finish  [set.inter_singleton_eq_empty]\n\ntheorem fix_set_compl (t : set \u03b1) : compl t = - t := rfl\n\n-- TODO(Jeremy): there is an issue with - t unfolding to compl t\ntheorem mem_compl_image (t : set \u03b1) (S : set (set \u03b1)) :\n  t \u2208 compl '' S \u2194 -t \u2208 S :=\nbegin\n  suffices : \u2200 x, -x = t \u2194 -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 \u03b1) : id '' s = s := ext $ by simp\n\ntheorem compl_compl_image (S : set (set \u03b1)) :\n  compl '' (compl '' S) = S :=\nby rw [\u2190 image_comp, compl_comp_compl, image_id]\n\ntheorem image_insert_eq {f : \u03b1 \u2192 \u03b2} {a : \u03b1} {s : set \u03b1} :\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 : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\n  (I : left_inverse g f) (s : set \u03b1) : f '' s \u2286 g \u207b\u00b9' s :=\n\u03bb b \u27e8a, h, e\u27e9, e \u25b8 ((I a).symm \u25b8 h : g (f a) \u2208 s)\n\ntheorem preimage_subset_image_of_inverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\n  (I : left_inverse g f) (s : set \u03b2) : f \u207b\u00b9' s \u2286 g '' s :=\n\u03bb b h, \u27e8f b, h, I b\u27e9\n\ntheorem image_eq_preimage_of_inverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\n  (h\u2081 : left_inverse g f) (h\u2082 : right_inverse g f) :\n  image f = preimage g :=\nfunext $ \u03bb s, subset.antisymm\n  (image_subset_preimage_of_inverse h\u2081 s)\n  (preimage_subset_image_of_inverse h\u2082 s)\n\ntheorem mem_image_iff_of_inverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} {b : \u03b2} {s : set \u03b1}\n  (h\u2081 : left_inverse g f) (h\u2082 : right_inverse g f) :\n  b \u2208 f '' s \u2194 g b \u2208 s :=\nby rw image_eq_preimage_of_inverse h\u2081 h\u2082; refl\n\ntheorem image_compl_subset {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (H : injective f) : f '' -s \u2286 -(f '' s) :=\nsubset_compl_iff_disjoint.2 $ by simp [image_inter H]\n\ntheorem subset_image_compl {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (H : surjective f) : -(f '' s) \u2286 f '' -s :=\ncompl_subset_iff_union.2 $\nby rw \u2190 image_union; simp [image_univ_of_surjective H]\n\ntheorem image_compl_eq {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (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 \u03b1} {t : set \u03b2} {f : \u03b1 \u2192 \u03b2} :\n  f '' s \u2286 t \u2194 s \u2286 f \u207b\u00b9' t :=\nball_image_iff\n\ntheorem image_preimage_subset (f : \u03b1 \u2192 \u03b2) (s : set \u03b2) :\n  f '' (f \u207b\u00b9' s) \u2286 s :=\nimage_subset_iff.2 (subset.refl _)\n\ntheorem subset_preimage_image (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) :\n  s \u2286 f \u207b\u00b9' (f '' s) :=\n\u03bb x, mem_image_of_mem f\n\ntheorem preimage_image_eq {f : \u03b1 \u2192 \u03b2} (s : set \u03b1) (h : injective f) : f \u207b\u00b9' (f '' s) = s :=\nsubset.antisymm\n  (\u03bb x \u27e8y, hy, e\u27e9, h e \u25b8 hy)\n  (subset_preimage_image f s)\n\ntheorem image_preimage_eq {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} (h : surjective f) : f '' (f \u207b\u00b9' s) = s :=\nsubset.antisymm\n  (image_preimage_subset f s)\n  (\u03bb x hx, let \u27e8y, e\u27e9 := h x in \u27e8y, (e.symm \u25b8 hx : f y \u2208 s), e\u27e9)\n\nlemma preimage_eq_preimage {f : \u03b2 \u2192 \u03b1} (hf : surjective f) : f \u207b\u00b9' s = preimage f t \u2194 s = t :=\niff.intro\n  (assume eq, by rw [\u2190 @image_preimage_eq \u03b2 \u03b1 f s hf, \u2190 @image_preimage_eq \u03b2 \u03b1 f t hf, eq])\n  (assume eq, eq \u25b8 rfl)\n\nlemma surjective_preimage {f : \u03b2 \u2192 \u03b1} (hf : surjective f) : injective (preimage f) :=\nassume s t, (preimage_eq_preimage hf).1\n\ntheorem compl_image : image (@compl \u03b1) = preimage compl :=\nimage_eq_preimage_of_inverse compl_compl compl_compl\n\ntheorem compl_image_set_of {\u03b1 : Type u} {p : set \u03b1 \u2192 Prop} :\n  compl '' {x | p x} = {x | p (- x)} :=\ncongr_fun compl_image p\n\ntheorem inter_preimage_subset (s : set \u03b1) (t : set \u03b2) (f : \u03b1 \u2192 \u03b2) :\n  s \u2229 f \u207b\u00b9' t \u2286 f \u207b\u00b9' (f '' s \u2229 t) :=\n\u03bb x h, \u27e8mem_image_of_mem _ h.left, h.right\u27e9\n\ntheorem union_preimage_subset (s : set \u03b1) (t : set \u03b2) (f : \u03b1 \u2192 \u03b2) :\n  s \u222a f \u207b\u00b9' t \u2286 f \u207b\u00b9' (f '' s \u222a t) :=\n\u03bb x h, or.elim h (\u03bb l, or.inl $ mem_image_of_mem _ l) (\u03bb r, or.inr r)\n\ntheorem subset_image_union (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (t : set \u03b2) :\n  f '' (s \u222a f \u207b\u00b9' t) \u2286 f '' s \u222a t :=\nimage_subset_iff.2 (union_preimage_subset _ _ _)\n\nlemma preimage_subset_iff {A : set \u03b1} {B : set \u03b2} {f : \u03b1 \u2192 \u03b2} :\n  f\u207b\u00b9' B \u2286 A \u2194 (\u2200 a : \u03b1, f a \u2208 B \u2192 a \u2208 A) := iff.rfl\n\nlemma image_eq_image {f : \u03b1 \u2192 \u03b2} (hf : injective f) : f '' s = f '' t \u2194 s = t :=\niff.symm $ iff.intro (assume eq, eq \u25b8 rfl) $ assume eq,\n  by rw [\u2190 preimage_image_eq s hf, \u2190 preimage_image_eq t hf, eq]\n\nlemma image_subset_image_iff {f : \u03b1 \u2192 \u03b2} (hf : injective f) : f '' s \u2286 f '' t \u2194 s \u2286 t :=\nbegin\n  refine (iff.symm $ iff.intro (image_subset f) $ assume h, _),\n  rw [\u2190 preimage_image_eq s hf, \u2190 preimage_image_eq t hf],\n  exact preimage_mono h\nend\n\nlemma injective_image {f : \u03b1 \u2192 \u03b2} (hf : injective f) : injective (('') f) :=\nassume s t, (image_eq_image hf).1\n\nlemma prod_quotient_preimage_eq_image [s : setoid \u03b1] (g : quotient s \u2192 \u03b2) {h : \u03b1 \u2192 \u03b2}\n  (Hh : h = g \u2218 quotient.mk) (r : set (\u03b2 \u00d7 \u03b2)) :\n  {x : quotient s \u00d7 quotient s | (g x.1, g x.2) \u2208 r} =\n  (\u03bb a : \u03b1 \u00d7 \u03b1, (\u27e6a.1\u27e7, \u27e6a.2\u27e7)) '' ((\u03bb a : \u03b1 \u00d7 \u03b1, (h a.1, h a.2)) \u207b\u00b9' r) :=\nHh.symm \u25b8 set.ext (\u03bb \u27e8a\u2081, a\u2082\u27e9, \u27e8quotient.induction_on\u2082 a\u2081 a\u2082\n  (\u03bb a\u2081 a\u2082 h, \u27e8(a\u2081, a\u2082), h, rfl\u27e9),\n  \u03bb \u27e8\u27e8b\u2081, b\u2082\u27e9, h\u2081, h\u2082\u27e9, show (g a\u2081, g a\u2082) \u2208 r, from\n  have h\u2083 : \u27e6b\u2081\u27e7 = a\u2081 \u2227 \u27e6b\u2082\u27e7 = a\u2082 := prod.ext_iff.1 h\u2082,\n    h\u2083.1 \u25b8 h\u2083.2 \u25b8 h\u2081\u27e9)\n\ndef image_factorization (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) : s \u2192 f '' s :=\n\u03bb p, \u27e8f p.1, mem_image_of_mem f p.2\u27e9\n\nlemma image_factorization_eq {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} :\n  subtype.val \u2218 image_factorization f s = f \u2218 subtype.val :=\nfunext $ \u03bb p, rfl\n\nlemma surjective_onto_image {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} :\n  surjective (image_factorization f s) :=\n\u03bb \u27e8_, \u27e8a, ha, rfl\u27e9\u27e9, \u27e8\u27e8a, ha\u27e9, rfl\u27e9\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 : \u03b9 \u2192 \u03b1}\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 : \u03b9 \u2192 \u03b1) : set \u03b1 := {x | \u2203y, f y = x}\n\n@[simp] theorem mem_range {x : \u03b1} : x \u2208 range f \u2194 \u2203 y, f y = x := iff.rfl\n\ntheorem mem_range_self (i : \u03b9) : f i \u2208 range f := \u27e8i, rfl\u27e9\n\ntheorem forall_range_iff {p : \u03b1 \u2192 Prop} : (\u2200 a \u2208 range f, p a) \u2194 (\u2200 i, p (f i)) :=\n\u27e8assume h i, h (f i) (mem_range_self _), assume h a \u27e8i, (hi : f i = a)\u27e9, hi \u25b8 h i\u27e9\n\ntheorem exists_range_iff {p : \u03b1 \u2192 Prop} : (\u2203 a \u2208 range f, p a) \u2194 (\u2203 i, p (f i)) :=\n\u27e8assume \u27e8a, \u27e8i, eq\u27e9, h\u27e9, \u27e8i, eq.symm \u25b8 h\u27e9, assume \u27e8i, h\u27e9, \u27e8f i, mem_range_self _, h\u27e9\u27e9\n\ntheorem range_iff_surjective : range f = univ \u2194 surjective f :=\neq_univ_iff_forall\n\n@[simp] theorem range_id : range (@id \u03b1) = univ := range_iff_surjective.2 surjective_id\n\n@[simp] theorem image_univ {\u03b9 : Type*} {f : \u03b9 \u2192 \u03b2} : f '' univ = range f :=\next $ by simp [image, range]\n\ntheorem image_subset_range {\u03b9 : Type*} (f : \u03b9 \u2192 \u03b2) (s : set \u03b9) : f '' s \u2286 range f :=\nby rw \u2190 image_univ; exact image_subset _ (subset_univ _)\n\ntheorem range_comp {g : \u03b1 \u2192 \u03b2} : range (g \u2218 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 {\u03b9 : Type*} {f : \u03b9 \u2192 \u03b2} {s : set \u03b2} : range f \u2286 s \u2194 \u2200 y, f y \u2208 s :=\nforall_range_iff\n\nlemma nonempty_of_nonempty_range {\u03b1 : Type*} {\u03b2 : Type*} {f : \u03b1 \u2192 \u03b2} (H : \u00acrange f = \u2205) : nonempty \u03b1 :=\nbegin\n  cases exists_mem_of_ne_empty H with x h,\n  cases mem_range.1 h with y _,\n  exact \u27e8y\u27e9\nend\n\n@[simp] lemma range_eq_empty {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} : range f = \u2205 \u2194 \u00ac nonempty \u03b1 :=\nby rw \u2190 set.image_univ; simp [-set.image_univ]\n\ntheorem image_preimage_eq_inter_range {f : \u03b1 \u2192 \u03b2} {t : set \u03b2} :\n  f '' (f \u207b\u00b9' t) = t \u2229 range f :=\next $ assume x, \u27e8assume \u27e8x, hx, heq\u27e9, heq \u25b8 \u27e8hx, mem_range_self _\u27e9,\n  assume \u27e8hx, \u27e8y, h_eq\u27e9\u27e9, h_eq \u25b8 mem_image_of_mem f $\n    show y \u2208 f \u207b\u00b9' t, by simp [preimage, h_eq, hx]\u27e9\n\nlemma image_preimage_eq_of_subset {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} (hs : s \u2286 range f) :\n  f '' (f \u207b\u00b9' s) = s :=\nby rw [image_preimage_eq_inter_range, inter_eq_self_of_subset_left hs]\n\ntheorem preimage_inter_range {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} : f \u207b\u00b9' (s \u2229 range f) = f \u207b\u00b9' s :=\nset.ext $ \u03bb x, and_iff_left \u27e8x, rfl\u27e9\n\ntheorem preimage_image_preimage {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} :\n  f \u207b\u00b9' (f '' (f \u207b\u00b9' s)) = f \u207b\u00b9' s :=\nby rw [image_preimage_eq_inter_range, preimage_inter_range]\n\n@[simp] theorem quot_mk_range_eq [setoid \u03b1] : range (\u03bbx : \u03b1, \u27e6x\u27e7) = univ :=\nrange_iff_surjective.2 quot.exists_rep\n\nlemma range_const_subset {c : \u03b2} : range (\u03bbx:\u03b1, c) \u2286 {c} :=\nrange_subset_iff.2 $ \u03bb x, or.inl rfl\n\n@[simp] lemma range_const [h : nonempty \u03b1] {c : \u03b2} : range (\u03bbx:\u03b1, c) = {c} :=\nbegin\n  refine subset.antisymm range_const_subset (\u03bby hy, _),\n  rw set.mem_singleton_iff.1 hy,\n  rcases exists_mem_of_nonempty \u03b1 with \u27e8x, _\u27e9,\n  exact mem_range_self x\nend\n\ndef range_factorization (f : \u03b9 \u2192 \u03b2) : \u03b9 \u2192 range f :=\n\u03bb i, \u27e8f i, mem_range_self i\u27e9\n\nlemma range_factorization_eq {f : \u03b9 \u2192 \u03b2} :\n  subtype.val \u2218 range_factorization f = f :=\nfunext $ \u03bb i, rfl\n\nlemma surjective_onto_range : surjective (range_factorization f) :=\n\u03bb \u27e8_, \u27e8i, rfl\u27e9\u27e9, \u27e8i, rfl\u27e9\n\nend range\n\n/-- The set `s` is pairwise `r` if `r x y` for all *distinct* `x y \u2208 s`. -/\ndef pairwise_on (s : set \u03b1) (r : \u03b1 \u2192 \u03b1 \u2192 Prop) := \u2200 x \u2208 s, \u2200 y \u2208 s, x \u2260 y \u2192 r x y\n\ntheorem pairwise_on.mono {s t : set \u03b1} {r}\n  (h : t \u2286 s) (hp : pairwise_on s r) : pairwise_on t r :=\n\u03bb x xt y yt, hp x (h xt) y (h yt)\n\ntheorem pairwise_on.mono' {s : set \u03b1} {r r' : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, r a b \u2192 r' a b) (hp : pairwise_on s r) : pairwise_on s r' :=\n\u03bb 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 {\u03b1 : Type*}\n\nlemma val_image {p : \u03b1 \u2192 Prop} {s : set (subtype p)} :\n  subtype.val '' s = {x | \u2203h : p x, (\u27e8x, h\u27e9 : subtype p) \u2208 s} :=\nset.ext $ assume a,\n\u27e8assume \u27e8\u27e8a', ha'\u27e9, in_s, h_eq\u27e9, h_eq \u25b8 \u27e8ha', in_s\u27e9,\n  assume \u27e8ha, in_s\u27e9, \u27e8\u27e8a, ha\u27e9, in_s, rfl\u27e9\u27e9\n\n@[simp] lemma val_range {p : \u03b1 \u2192 Prop} :\n  set.range (@subtype.val _ p) = {x | p x} :=\nby rw \u2190 set.image_univ; simp [-set.image_univ, val_image]\ntheorem val_image_subset (s : set \u03b1) (t : set (subtype s)) : t.image val \u2286 s :=\n\u03bb x \u27e8y, yt, yvaleq\u27e9, by rw \u2190yvaleq; exact y.property\n\ntheorem val_image_univ (s : set \u03b1) : @val _ s '' set.univ = s :=\nset.eq_of_subset_of_subset (val_image_subset _ _) (\u03bb x xs, \u27e8\u27e8x, xs\u27e9, \u27e8set.mem_univ _, rfl\u27e9\u27e9)\n\ntheorem image_preimage_val (s t : set \u03b1) :\n  (@subtype.val _ s) '' ((@subtype.val _ s) \u207b\u00b9' t) = t \u2229 s :=\nbegin\n  ext x, simp, split,\n  { rintros \u27e8y, ys, yt, yx\u27e9, rw \u2190yx, exact \u27e8yt, ys\u27e9 },\n  rintros \u27e8xt, xs\u27e9, exact \u27e8x, xs, xt, rfl\u27e9\nend\n\ntheorem preimage_val_eq_preimage_val_iff (s t u : set \u03b1) :\n  ((@subtype.val _ s) \u207b\u00b9' t = (@subtype.val _ s) \u207b\u00b9' u) \u2194 (t \u2229 s = u \u2229 s) :=\nbegin\n  rw [\u2190image_preimage_val, \u2190image_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 {\u03b1 : Type*}\n\n@[simp] lemma subtype.val_range {p : \u03b1 \u2192 Prop} :\n  range (@subtype.val _ p) = {x | p x} :=\nby rw \u2190 image_univ; simp [-image_univ, subtype.val_image]\n\n@[simp] lemma range_coe_subtype (s : set \u03b1): range (coe : s \u2192 \u03b1) = s :=\nsubtype.val_range\n\nend range\n\nsection prod\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\nvariables {s s\u2081 s\u2082 : set \u03b1} {t t\u2081 t\u2082 : set \u03b2}\n\n/-- The cartesian product `prod s t` is the set of `(a, b)`\n  such that `a \u2208 s` and `b \u2208 t`. -/\nprotected def prod (s : set \u03b1) (t : set \u03b2) : set (\u03b1 \u00d7 \u03b2) :=\n{p | p.1 \u2208 s \u2227 p.2 \u2208 t}\n\nlemma prod_eq (s : set \u03b1) (t : set \u03b2) : set.prod s t = prod.fst \u207b\u00b9' s \u2229 prod.snd \u207b\u00b9' t := rfl\n\ntheorem mem_prod_eq {p : \u03b1 \u00d7 \u03b2} : p \u2208 set.prod s t = (p.1 \u2208 s \u2227 p.2 \u2208 t) := rfl\n\n@[simp] theorem mem_prod {p : \u03b1 \u00d7 \u03b2} : p \u2208 set.prod s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t := iff.rfl\n\nlemma mk_mem_prod {a : \u03b1} {b : \u03b2} (a_in : a \u2208 s) (b_in : b \u2208 t) : (a, b) \u2208 set.prod s t := \u27e8a_in, b_in\u27e9\n\n@[simp] theorem prod_empty {s : set \u03b1} : set.prod s \u2205 = (\u2205 : set (\u03b1 \u00d7 \u03b2)) :=\next $ by simp [set.prod]\n\n@[simp] theorem empty_prod {t : set \u03b2} : set.prod \u2205 t = (\u2205 : set (\u03b1 \u00d7 \u03b2)) :=\next $ by simp [set.prod]\n\ntheorem insert_prod {a : \u03b1} {s : set \u03b1} {t : set \u03b2} :\n  set.prod (insert a s) t = (prod.mk a '' t) \u222a set.prod s t :=\next begin simp [set.prod, image, iff_def, or_imp_distrib] {contextual := tt}; cc end\n\ntheorem prod_insert {b : \u03b2} {s : set \u03b1} {t : set \u03b2} :\n  set.prod s (insert b t) = ((\u03bba, (a, b)) '' s) \u222a 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 : \u03b3 \u2192 \u03b1} {g : \u03b4 \u2192 \u03b2} :\n  set.prod (preimage f s) (preimage g t) = preimage (\u03bbp, (f p.1, g p.2)) (set.prod s t) := rfl\n\ntheorem prod_mono {s\u2081 s\u2082 : set \u03b1} {t\u2081 t\u2082 : set \u03b2} (hs : s\u2081 \u2286 s\u2082) (ht : t\u2081 \u2286 t\u2082) :\n  set.prod s\u2081 t\u2081 \u2286 set.prod s\u2082 t\u2082 :=\nassume x \u27e8h\u2081, h\u2082\u27e9, \u27e8hs h\u2081, ht h\u2082\u27e9\n\ntheorem prod_inter_prod : set.prod s\u2081 t\u2081 \u2229 set.prod s\u2082 t\u2082 = set.prod (s\u2081 \u2229 s\u2082) (t\u2081 \u2229 t\u2082) :=\nsubset.antisymm\n  (assume \u27e8a, b\u27e9 \u27e8\u27e8ha\u2081, hb\u2081\u27e9, \u27e8ha\u2082, hb\u2082\u27e9\u27e9, \u27e8\u27e8ha\u2081, ha\u2082\u27e9, \u27e8hb\u2081, hb\u2082\u27e9\u27e9)\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 : (\u03bbp:\u03b2\u00d7\u03b1, (p.2, p.1)) '' set.prod t s = set.prod s t :=\next $ assume \u27e8a, b\u27e9, by simp [mem_image_eq, set.prod, and_comm]; exact\n\u27e8 assume \u27e8b', a', \u27e8h_a, h_b\u27e9, h\u27e9, by subst a'; subst b'; assumption,\n  assume h, \u27e8b, a, \u27e8rfl, rfl\u27e9, h\u27e9\u27e9\n\ntheorem image_swap_eq_preimage_swap : image (@prod.swap \u03b1 \u03b2) = preimage prod.swap :=\nimage_eq_preimage_of_inverse prod.swap_left_inverse prod.swap_right_inverse\n\ntheorem prod_image_image_eq {m\u2081 : \u03b1 \u2192 \u03b3} {m\u2082 : \u03b2 \u2192 \u03b4} :\n  set.prod (image m\u2081 s) (image m\u2082 t) = image (\u03bbp:\u03b1\u00d7\u03b2, (m\u2081 p.1, m\u2082 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 {\u03b1 \u03b2 \u03b3 \u03b4} {m\u2081 : \u03b1 \u2192 \u03b3} {m\u2082 : \u03b2 \u2192 \u03b4} :\n  set.prod (range m\u2081) (range m\u2082) = range (\u03bbp:\u03b1\u00d7\u03b2, (m\u2081 p.1, m\u2082 p.2)) :=\next $ by simp [range]\n\n@[simp] theorem prod_singleton_singleton {a : \u03b1} {b : \u03b2} :\n  set.prod {a} {b} = ({(a, b)} : set (\u03b1\u00d7\u03b2)) :=\next $ by simp [set.prod]\n\ntheorem prod_neq_empty_iff {s : set \u03b1} {t : set \u03b2} :\n  set.prod s t \u2260 \u2205 \u2194 (s \u2260 \u2205 \u2227 t \u2260 \u2205) :=\nby simp [not_eq_empty_iff_exists]\n\ntheorem prod_eq_empty_iff {s : set \u03b1} {t : set \u03b2} :\n  set.prod s t = \u2205 \u2194 (s = \u2205 \u2228 t = \u2205) :=\nsuffices (\u00ac set.prod s t \u2260 \u2205) \u2194 (\u00ac s \u2260 \u2205 \u2228 \u00ac t \u2260 \u2205), by simpa only [(\u2260), classical.not_not],\nby classical; rw [prod_neq_empty_iff, not_and_distrib]\n\n@[simp] theorem prod_mk_mem_set_prod_eq {a : \u03b1} {b : \u03b2} {s : set \u03b1} {t : set \u03b2} :\n  (a, b) \u2208 set.prod s t = (a \u2208 s \u2227 b \u2208 t) := rfl\n\n@[simp] theorem univ_prod_univ : set.prod (@univ \u03b1) (@univ \u03b2) = univ :=\next $ assume \u27e8a, b\u27e9, by simp\n\nlemma prod_sub_preimage_iff {W : set \u03b3} {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} :\n  set.prod s t \u2286 f \u207b\u00b9' W \u2194 \u2200 a b, a \u2208 s \u2192 b \u2208 t \u2192 f (a, b) \u2208 W :=\nby simp [subset_def]\n\nend prod\n\nsection pi\nvariables {\u03b1 : Type*} {\u03c0 : \u03b1 \u2192 Type*}\n\ndef pi (i : set \u03b1) (s : \u03a0a, set (\u03c0 a)) : set (\u03a0a, \u03c0 a) := { f | \u2200a\u2208i, f a \u2208 s a }\n\n@[simp] lemma pi_empty_index (s : \u03a0a, set (\u03c0 a)) : pi \u2205 s = univ := by ext; simp [pi]\n\n@[simp] lemma pi_insert_index (a : \u03b1) (i : set \u03b1) (s : \u03a0a, set (\u03c0 a)) :\n  pi (insert a i) s = ((\u03bbf, f a) \u207b\u00b9' s a) \u2229 pi i s :=\nby ext; simp [pi, or_imp_distrib, forall_and_distrib]\n\n@[simp] lemma pi_singleton_index (a : \u03b1) (s : \u03a0a, set (\u03c0 a)) :\n  pi {a} s = ((\u03bbf:(\u03a0a, \u03c0 a), f a) \u207b\u00b9' s a) :=\nby ext; simp [pi]\n\nlemma pi_if {p : \u03b1 \u2192 Prop} [h : decidable_pred p] (i : set \u03b1) (s t : \u03a0a, set (\u03c0 a)) :\n  pi i (\u03bba, if p a then s a else t a) = pi {a \u2208 i | p a} s \u2229 pi {a \u2208 i | \u00ac p a} t :=\nbegin\n  ext f,\n  split,\n  { assume h, split; { rintros a \u27e8hai, hpa\u27e9, simpa [*] using h a } },\n  { rintros \u27e8hs, ht\u27e9 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\u2081`.\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 \u2265 `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 : \u2115 \u2192 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 : \u2115} {R : Type u_1} [comm_ring R] (P : \u2115 \u2192 Prop) (x : witt_vector p R) :\n    witt_vector p R :=\n  mk p fun (n : \u2115) => 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 : \u2115 \u2192 Prop) (n : \u2115) : mv_polynomial \u2115 \u2124 := ite (P n) (mv_polynomial.X n) 0\n\ntheorem coeff_select {p : \u2115} {R : Type u_1} [comm_ring R] (P : \u2115 \u2192 Prop) (x : witt_vector p R)\n    (n : \u2115) : coeff (select P x) n = coe_fn (mv_polynomial.aeval (coeff x)) (select_poly P n) :=\n  sorry\n\ntheorem select_is_poly {p : \u2115} (P : \u2115 \u2192 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 : \u2115) => coeff_select P x i)\n\ntheorem select_add_select_not {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (P : \u2115 \u2192 Prop) (x : witt_vector p R) : select P x + select (fun (i : \u2115) => \u00acP i) x = x :=\n  sorry\n\ntheorem coeff_add_of_disjoint {p : \u2115} [hp : fact (nat.prime p)] (n : \u2115) {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (y : witt_vector p R) (h : \u2200 (n : \u2115), coeff x n = 0 \u2228 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 : \u2115} {R : Type u_1} [comm_ring R] (n : \u2115) : witt_vector p R \u2192 witt_vector p R :=\n  select fun (i : \u2115) => 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 : \u2115} {R : Type u_1} [comm_ring R] (n : \u2115) : witt_vector p R \u2192 witt_vector p R :=\n  select fun (i : \u2115) => n \u2264 i\n\n@[simp] theorem init_add_tail {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (n : \u2115) : init n x + tail n x = x :=\n  sorry\n\n@[simp] theorem init_init {p : \u2115} {R : Type u_1} [comm_ring R] (x : witt_vector p R) (n : \u2115) :\n    init n (init n x) = init n x :=\n  sorry\n\ntheorem init_add {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (y : witt_vector p R) (n : \u2115) :\n    init n (x + y) = init n (init n x + init n y) :=\n  sorry\n\ntheorem init_mul {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (y : witt_vector p R) (n : \u2115) :\n    init n (x * y) = init n (init n x * init n y) :=\n  sorry\n\ntheorem init_neg {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (n : \u2115) : init n (-x) = init n (-init n x) :=\n  sorry\n\ntheorem init_sub {p : \u2115} [hp : fact (nat.prime p)] {R : Type u_1} [comm_ring R]\n    (x : witt_vector p R) (y : witt_vector p R) (n : \u2115) :\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 : \u2115) (n : \u2115) :\n    is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => init n :=\n  select_is_poly fun (i : \u2115) => 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": "import homotopy.basic\nimport covering_space.lift\n\nvariables {X X' Y : Type _} [topological_space X] [topological_space X'] [topological_space Y] \n\nopen_locale unit_interval\n\nexample (p : C(X', X)) (hp : is_covering_map p) (f\u2080 f\u2081 : C(Y, X)) (H : homotopy f\u2080 f\u2081) (f\u2080' : C(Y, X'))\n  (hf\u2080' : p.comp f\u2080' = f\u2080) : C(Y \u00d7 I, X) :=\nsorry\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/lift.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8354835289107307, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4792988603183108}}
{"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 {\u03b1 : Type u} : rbnode \u03b1 \u2192 rbnode \u03b1 \u2192 \u03b1 \u2192 rbnode \u03b1 \u2192 Prop where\n| of_red : \u2200 (l : rbnode \u03b1) (v : \u03b1) (r : rbnode \u03b1), is_node_of (red_node l v r) l v r\n| of_black : \u2200 (l : rbnode \u03b1) (v : \u03b1) (r : rbnode \u03b1), is_node_of (black_node l v r) l v r\n\ndef lift {\u03b1 : Type u} (lt : \u03b1 \u2192 \u03b1 \u2192 Prop) : Option \u03b1 \u2192 Option \u03b1 \u2192 Prop := sorry\n\ninductive is_searchable {\u03b1 : Type u} (lt : \u03b1 \u2192 \u03b1 \u2192 Prop) : rbnode \u03b1 \u2192 Option \u03b1 \u2192 Option \u03b1 \u2192 Prop\n    where\n| leaf_s : \u2200 {lo hi : Option \u03b1}, lift lt lo hi \u2192 is_searchable lt leaf lo hi\n| red_s :\n    \u2200 {l r : rbnode \u03b1} {v : \u03b1} {lo hi : Option \u03b1},\n      is_searchable lt l lo (some v) \u2192\n        is_searchable lt r (some v) hi \u2192 is_searchable lt (red_node l v r) lo hi\n| black_s :\n    \u2200 {l r : rbnode \u03b1} {v : \u03b1} {lo hi : Option \u03b1},\n      is_searchable lt l lo (some v) \u2192\n        is_searchable lt r (some v) hi \u2192 is_searchable lt (black_node l v r) lo hi\n\ntheorem lo_lt_hi {\u03b1 : Type u} {t : rbnode \u03b1} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_trans \u03b1 lt] {lo : Option \u03b1}\n    {hi : Option \u03b1} : is_searchable lt t lo hi \u2192 lift lt lo hi :=\n  sorry\n\ntheorem is_searchable_of_is_searchable_of_incomp {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt]\n    [is_strict_weak_order \u03b1 lt] {t : rbnode \u03b1} {lo : Option \u03b1} {hi : \u03b1} {hi' : \u03b1}\n    (hc : \u00aclt hi' hi \u2227 \u00aclt 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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt]\n    [is_strict_weak_order \u03b1 lt] {t : rbnode \u03b1} {lo : \u03b1} {lo' : \u03b1} {hi : Option \u03b1}\n    (hc : \u00aclt lo' lo \u2227 \u00aclt 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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    [DecidableRel lt] {t : rbnode \u03b1} [is_trans \u03b1 lt] {lo : \u03b1} {hi : Option \u03b1} {lo' : \u03b1}\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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    [DecidableRel lt] {t : rbnode \u03b1} {y : \u03b1} {hi : Option \u03b1}\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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    [DecidableRel lt] {t : rbnode \u03b1} [is_trans \u03b1 lt] {lo : Option \u03b1} {hi : \u03b1} {hi' : \u03b1}\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 {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    [DecidableRel lt] {t : rbnode \u03b1} {lo : Option \u03b1} {y : \u03b1}\n    (hlt : is_searchable lt t lo (some y)) : is_searchable lt t lo none :=\n  sorry\n\ntheorem range {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt] [is_strict_weak_order \u03b1 lt]\n    {t : rbnode \u03b1} {x : \u03b1} {lo : Option \u03b1} {hi : Option \u03b1} :\n    is_searchable lt t lo hi \u2192 mem lt x t \u2192 lift lt lo (some x) \u2227 lift lt (some x) hi :=\n  sorry\n\ntheorem lt_of_mem_left {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt]\n    [is_strict_weak_order \u03b1 lt] {y : \u03b1} {t : rbnode \u03b1} {l : rbnode \u03b1} {r : rbnode \u03b1} {lo : Option \u03b1}\n    {hi : Option \u03b1} :\n    is_searchable lt t lo hi \u2192 is_node_of t l y r \u2192 \u2200 {x : \u03b1}, mem lt x l \u2192 lt x y :=\n  sorry\n\ntheorem lt_of_mem_right {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt]\n    [is_strict_weak_order \u03b1 lt] {y : \u03b1} {t : rbnode \u03b1} {l : rbnode \u03b1} {r : rbnode \u03b1} {lo : Option \u03b1}\n    {hi : Option \u03b1} :\n    is_searchable lt t lo hi \u2192 is_node_of t l y r \u2192 \u2200 {z : \u03b1}, mem lt z r \u2192 lt y z :=\n  sorry\n\ntheorem lt_of_mem_left_right {\u03b1 : Type u} {lt : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel lt]\n    [is_strict_weak_order \u03b1 lt] {y : \u03b1} {t : rbnode \u03b1} {l : rbnode \u03b1} {r : rbnode \u03b1} {lo : Option \u03b1}\n    {hi : Option \u03b1} :\n    is_searchable lt t lo hi \u2192 is_node_of t l y r \u2192 \u2200 {x z : \u03b1}, mem lt x l \u2192 mem lt z r \u2192 lt x z :=\n  sorry\n\ninductive is_red_black {\u03b1 : Type u} : rbnode \u03b1 \u2192 color \u2192 \u2115 \u2192 Prop where\n| leaf_rb : is_red_black leaf color.black 0\n| red_rb :\n    \u2200 {v : \u03b1} {l r : rbnode \u03b1} {n : \u2115},\n      is_red_black l color.black n \u2192\n        is_red_black r color.black n \u2192 is_red_black (red_node l v r) color.red n\n| black_rb :\n    \u2200 {v : \u03b1} {l r : rbnode \u03b1} {n : \u2115} {c\u2081 c\u2082 : color},\n      is_red_black l c\u2081 n \u2192\n        is_red_black r c\u2082 n \u2192 is_red_black (black_node l v r) color.black (Nat.succ n)\n\ntheorem depth_min {\u03b1 : Type u} {c : color} {n : \u2115} {t : rbnode \u03b1} :\n    is_red_black t c n \u2192 depth min t \u2265 n :=\n  sorry\n\ntheorem depth_max' {\u03b1 : Type u} {c : color} {n : \u2115} {t : rbnode \u03b1} :\n    is_red_black t c n \u2192 depth max t \u2264 upper c n :=\n  sorry\n\ntheorem depth_max {\u03b1 : Type u} {c : color} {n : \u2115} {t : rbnode \u03b1} (h : is_red_black t c n) :\n    depth max t \u2264 bit0 1 * n + 1 :=\n  le_trans (depth_max' h) (upper_le c n)\n\ntheorem balanced {\u03b1 : Type u} {c : color} {n : \u2115} {t : rbnode \u03b1} (h : is_red_black t c n) :\n    bit0 1 * depth min t + 1 \u2265 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^\u221e`, 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 \u03b1 := metrizable_space_metric \u03b1` -/\nclass metrizable_space (\u03b1 : Type*) [t : topological_space \u03b1] : Prop :=\n(exists_metric : \u2203 (m : metric_space \u03b1), m.to_uniform_space.to_topological_space = t)\n\n@[priority 100]\ninstance _root_.metric_space.to_metrizable_space {\u03b1 : Type*} [m : metric_space \u03b1] :\n  metrizable_space \u03b1 :=\n\u27e8\u27e8m, rfl\u27e9\u27e9\n\n/-- Construct on a metrizable space a metric compatible with the topology. -/\nnoncomputable def metrizable_space_metric\n  (\u03b1 : Type*) [topological_space \u03b1] [h : metrizable_space \u03b1] :\n  metric_space \u03b1 :=\nh.exists_metric.some.replace_topology h.exists_metric.some_spec.symm\n\n@[priority 100]\ninstance t2_space_of_metrizable_space\n  (\u03b1 : Type*) [topological_space \u03b1] [metrizable_space \u03b1] : t2_space \u03b1 :=\nby { letI : metric_space \u03b1 := metrizable_space_metric \u03b1, apply_instance }\n\ninstance metrizable_space_prod (\u03b1 : Type*) [topological_space \u03b1] [metrizable_space \u03b1]\n  (\u03b2 : Type*) [topological_space \u03b2] [metrizable_space \u03b2] :\n  metrizable_space (\u03b1 \u00d7 \u03b2) :=\nbegin\n  letI : metric_space \u03b1 := metrizable_space_metric \u03b1,\n  letI : metric_space \u03b2 := metrizable_space_metric \u03b2,\n  apply_instance\nend\n\ninstance metrizable_space.subtype {\u03b1 : Type*} [topological_space \u03b1] [metrizable_space \u03b1]\n  (s : set \u03b1) : metrizable_space s :=\nby { letI := metrizable_space_metric \u03b1, 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 {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n  [metrizable_space \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : embedding f) :\n  metrizable_space \u03b1 :=\nbegin\n  letI : metric_space \u03b2 := metrizable_space_metric \u03b2,\n  exact \u27e8\u27e8hf.comap_metric_space f, rfl\u27e9\u27e9\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^\u221e = \u2115 \u2192\u1d47 \u211d`.\n-/\nlemma exists_embedding_l_infty : \u2203 f : X \u2192 (\u2115 \u2192\u1d47 \u211d), embedding f :=\nbegin\n  -- Choose a countable basis, and consider the set `s` of pairs of set `(U, V)` such that `U \u2208 B`,\n  -- `V \u2208 B`, and `closure U \u2286 V`.\n  rcases exists_countable_basis X with \u27e8B, hBc, -, hB\u27e9,\n  set s : set (set X \u00d7 set X) := {UV \u2208 B \u00d7\u02e2 B| closure UV.1 \u2286 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 \u2192\u1d47 \u211d` instead.\n  letI : topological_space s := \u22a5, haveI : discrete_topology s := \u27e8rfl\u27e9,\n  suffices : \u2203 f : X \u2192 (s \u2192\u1d47 \u211d), embedding f,\n  { rcases this with \u27e8f, hf\u27e9,\n    exact \u27e8\u03bb x, (f x).extend (encodable.encode' s) 0, (bounded_continuous_function.isometry_extend\n      (encodable.encode' s) (0 : \u2115 \u2192\u1d47 \u211d)).embedding.comp hf\u27e9 },\n  have hd : \u2200 UV : s, disjoint (closure UV.1.1) (UV.1.2\u1d9c) :=\n    \u03bb UV, disjoint_compl_right.mono_right (compl_subset_compl.2 UV.2.2),\n  -- Choose a sequence of `\u03b5\u2099 > 0`, `n : s`, that is bounded above by `1` and tends to zero\n  -- along the `cofinite` filter.\n  obtain \u27e8\u03b5, \u03b501, h\u03b5\u27e9 : \u2203 \u03b5 : s \u2192 \u211d, (\u2200 UV, \u03b5 UV \u2208 Ioc (0 : \u211d) 1) \u2227 tendsto \u03b5 cofinite (\ud835\udcdd 0),\n  { rcases pos_sum_of_encodable zero_lt_one s with \u27e8\u03b5, \u03b50, c, h\u03b5c, hc1\u27e9,\n    refine \u27e8\u03b5, \u03bb UV, \u27e8\u03b50 UV, _\u27e9, h\u03b5c.summable.tendsto_cofinite_zero\u27e9,\n    exact (le_has_sum h\u03b5c UV $ \u03bb _ _, (\u03b50 _).le).trans hc1 },\n  /- For each `UV = (U, V) \u2208 s` we use Urysohn's lemma to choose a function `f UV` that is equal to\n  zero on `U` and is equal to `\u03b5 UV` on the complement to `V`. -/\n  have : \u2200 UV : s, \u2203 f : C(X, \u211d), eq_on f 0 UV.1.1 \u2227 eq_on f (\u03bb _, \u03b5 UV) UV.1.2\u1d9c \u2227\n    \u2200 x, f x \u2208 Icc 0 (\u03b5 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 \u27e8f, hf\u2080, hf\u2081, hf01\u27e9,\n    exact \u27e8\u03b5 UV \u2022 f, \u03bb x hx, by simp [hf\u2080 (subset_closure hx)], \u03bb x hx, by simp [hf\u2081 hx],\n      \u03bb x, \u27e8mul_nonneg (\u03b501 _).1.le (hf01 _).1, mul_le_of_le_one_right (\u03b501 _).1.le (hf01 _).2\u27e9\u27e9 },\n  choose f hf0 hf\u03b5 hf0\u03b5,\n  have hf01 : \u2200 UV x, f UV x \u2208 Icc (0 : \u211d) 1,\n    from \u03bb UV x, Icc_subset_Icc_right (\u03b501 _).2 (hf0\u03b5 _ _),\n  /- The embedding is given by `F x UV = f UV x`. -/\n  set F : X \u2192 s \u2192\u1d47 \u211d := \u03bb x, \u27e8\u27e8\u03bb UV, f UV x, continuous_of_discrete_topology\u27e9, 1, \u03bb UV\u2081 UV\u2082,\n    real.dist_le_of_mem_Icc_01 (hf01 _ _) (hf01 _ _)\u27e9,\n  have hF : \u2200 x UV, F x UV = f UV x := \u03bb _ _, rfl,\n  refine \u27e8F, embedding.mk' _ (\u03bb x y hxy, _) (\u03bb x, le_antisymm _ _)\u27e9,\n  { /- First we prove that `F` is injective. Indeed, if `F x = F y` and `x \u2260 y`, then we can find\n    `(U, V) \u2208 s` such that `x \u2208 U` and `y \u2209 V`, hence `F x UV = 0 \u2260 \u03b5 UV = F y UV`. -/\n    refine not_not.1 (\u03bb Hne, _), -- `by_contra Hne` timeouts\n    rcases hB.mem_nhds_iff.1 (is_open_ne.mem_nhds Hne) with \u27e8V, hVB, hxV, hVy\u27e9,\n    rcases hB.exists_closure_subset (hB.mem_nhds hVB hxV) with \u27e8U, hUB, hxU, hUV\u27e9,\n    set UV : \u21a5s := \u27e8(U, V), \u27e8hUB, hVB\u27e9, hUV\u27e9,\n    apply (\u03b501 UV).1.ne,\n    calc (0 : \u211d) = F x UV : (hf0 UV hxU).symm\n             ... = F y UV : by rw hxy\n             ... = \u03b5 UV   : hf\u03b5 UV (\u03bb h : y \u2208 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 \u2208 B` such that\n    `x \u2208 V` and `closure V \u2286 U`. Then the preimage of the `(\u03b5 (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 \u27e8hVB, hxV\u27e9,\n    rcases hB.exists_closure_subset (hB.mem_nhds hVB hxV) with \u27e8U, hUB, hxU, hUV\u27e9,\n    set UV : \u21a5s := \u27e8(U, V), \u27e8hUB, hVB\u27e9, hUV\u27e9,\n    refine \u27e8\u03b5 UV, (\u03b501 UV).1, \u03bb y (hy : dist (F y) (F x) < \u03b5 UV), _\u27e9,\n    replace hy : dist (F y UV) (F x UV) < \u03b5 UV,\n      from (bounded_continuous_function.dist_coe_le_dist _).trans_lt hy,\n    contrapose! hy,\n    rw [hF, hF, hf\u03b5 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 `\u03b4 > 0`, consider the set `T` of `(U, V) \u2208 s`\n    such that `\u03b5 (U, V) \u2265 \u03b4`. Since `\u03b5` 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)) \u2264 \u03b4` for any\n    `(U, V) \u2208 T`. For `(U, V) \u2209 T`, the same inequality is true because both `F y (U, V)` and\n    `F x (U, V)` belong to the interval `[0, \u03b5 (U, V)]`. -/\n    refine (nhds_basis_closed_ball.comap _).ge_iff.2 (\u03bb \u03b4 \u03b40, _),\n    have h_fin : finite {UV : s | \u03b4 \u2264 \u03b5 UV}, by simpa only [\u2190 not_lt] using h\u03b5 (gt_mem_nhds \u03b40),\n    have : \u2200\u1da0 y in \ud835\udcdd x, \u2200 UV, \u03b4 \u2264 \u03b5 UV \u2192 dist (F y UV) (F x UV) \u2264 \u03b4,\n    { refine (eventually_all_finite h_fin).2 (\u03bb UV hUV, _),\n      exact (f UV).continuous.tendsto x (closed_ball_mem_nhds _ \u03b40) },\n    refine this.mono (\u03bb y hy, (bounded_continuous_function.dist_le \u03b40.le).2 $ \u03bb UV, _),\n    cases le_total \u03b4 (\u03b5 UV) with hle hle,\n    exacts [hy _ hle, (real.dist_le_of_mem_Icc (hf0\u03b5 _ _) (hf0\u03b5 _ _)).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 \u27e8f, hf\u27e9 := 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 \u03b1` gives us a way to calculate the fixed point\nof function of type `\u03b1 \u2192 \u03b1`. -/\nclass has_fix (\u03b1 : Type u_3) \nwhere\n  fix : (\u03b1 \u2192 \u03b1) \u2192 \u03b1\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] \u22a5`. The limit of this chain is the fixed point of `f`. -/\ndef fix.approx {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (f : ((a : \u03b1) \u2192 roption (\u03b2 a)) \u2192 (a : \u03b1) \u2192 roption (\u03b2 a)) : stream ((a : \u03b1) \u2192 roption (\u03b2 a)) :=\n  sorry\n\n/-- loop body for finding the fixed point of `f` -/\ndef fix_aux {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (f : ((a : \u03b1) \u2192 roption (\u03b2 a)) \u2192 (a : \u03b1) \u2192 roption (\u03b2 a)) {p : \u2115 \u2192 Prop} (i : nat.upto p) (g : (j : nat.upto p) \u2192 i < j \u2192 (a : \u03b1) \u2192 roption (\u03b2 a)) (a : \u03b1) : roption (\u03b2 a) :=\n  f fun (x : \u03b1) => assert (\u00acp (subtype.val i)) fun (h : \u00acp (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. `\u2200 X, f X \u2264 X \u2192 fix f \u2264 X`   (least fixed point)\n-/\nprotected def fix {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (f : ((a : \u03b1) \u2192 roption (\u03b2 a)) \u2192 (a : \u03b1) \u2192 roption (\u03b2 a)) (x : \u03b1) : roption (\u03b2 x) :=\n  assert (\u2203 (i : \u2115), dom sorry) fun (h : \u2203 (i : \u2115), dom sorry) => well_founded.fix sorry (fix_aux f) nat.upto.zero x\n\nprotected theorem fix_def {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (f : ((a : \u03b1) \u2192 roption (\u03b2 a)) \u2192 (a : \u03b1) \u2192 roption (\u03b2 a)) {x : \u03b1} (h' : \u2203 (i : \u2115), dom (fix.approx f i x)) : roption.fix f x = fix.approx f (Nat.succ (nat.find h')) x := sorry\n\ntheorem fix_def' {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (f : ((a : \u03b1) \u2192 roption (\u03b2 a)) \u2192 (a : \u03b1) \u2192 roption (\u03b2 a)) {x : \u03b1} (h' : \u00ac\u2203 (i : \u2115), 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 {\u03b1 : Type u_1} : has_fix (roption \u03b1) :=\n  has_fix.mk fun (f : roption \u03b1 \u2192 roption \u03b1) => roption.fix (fun (x : Unit \u2192 roption \u03b1) (u : Unit) => f (x u)) Unit.unit\n\nend roption\n\n\nnamespace pi\n\n\nprotected instance roption.has_fix {\u03b1 : Type u_1} {\u03b2 : Type u_2} : has_fix (\u03b1 \u2192 roption \u03b2) :=\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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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\u1d52\u1d56` 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 \u226b i` with `i \u226b e = \ud835\udfd9 _` -/\nclass is_idempotent_complete : Prop :=\n(idempotents_split : \u2200 (X : C) (p : X \u27f6 X), p \u226b p = p \u2192\n  \u2203 (Y : C) (i : Y \u27f6 X) (e : X \u27f6 Y), i \u226b e = \ud835\udfd9 Y \u2227 e \u226b 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 \u2194 \u2200 (X : C) (p : X \u27f6 X), p \u226b p = p \u2192 has_equalizer (\ud835\udfd9 X) p :=\nbegin\n  split,\n  { introI,\n    intros X p hp,\n    rcases is_idempotent_complete.idempotents_split X p hp with \u27e8Y, i, e, \u27e8h\u2081, h\u2082\u27e9\u27e9,\n    exact \u27e8nonempty.intro\n      { cone := fork.of_\u03b9 i\n          (show i \u226b \ud835\udfd9 X = i \u226b p, by rw [comp_id, \u2190 h\u2082, \u2190 assoc, h\u2081, id_comp]),\n        is_limit := begin\n          apply fork.is_limit.mk',\n          intro s,\n          refine \u27e8s.\u03b9 \u226b e, _\u27e9,\n          split,\n          { erw [assoc, h\u2082, \u2190 limits.fork.condition s, comp_id], },\n          { intros m hm,\n            rw fork.\u03b9_of_\u03b9 at hm,\n            rw [\u2190 hm],\n            simp only [\u2190 hm, assoc, h\u2081],\n            exact (comp_id m).symm }\n        end }\u27e9, },\n  { intro h,\n    refine \u27e8_\u27e9,\n    intros X p hp,\n    haveI := h X p hp,\n    use equalizer (\ud835\udfd9 X) p,\n    use equalizer.\u03b9 (\ud835\udfd9 X) p,\n    use equalizer.lift p (show p \u226b \ud835\udfd9 X = p \u226b p, by rw [hp, comp_id]),\n    split,\n    { ext,\n      rw [assoc, equalizer.lift_\u03b9, id_comp],\n      conv { to_rhs, erw [\u2190 comp_id (equalizer.\u03b9 (\ud835\udfd9 X) p)], },\n      exact (limits.fork.condition (equalizer.fork (\ud835\udfd9 X) p)).symm, },\n    { rw [equalizer.lift_\u03b9], }, }\nend\n\nvariables {C}\n\n/-- In a preadditive category, when `p : X \u27f6 X` is idempotent,\nthen `\ud835\udfd9 X - p` is also idempotent. -/\nlemma idem_of_id_sub_idem [preadditive C]\n  {X : C} (p : X \u27f6 X) (hp : p \u226b p = p) :\n  (\ud835\udfd9 _ - p) \u226b (\ud835\udfd9 _ - p) = (\ud835\udfd9 _ - 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 \u2194 \u2200 (X : C) (p : X \u27f6 X), p \u226b p = p \u2192 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 (\ud835\udfd9 _ - p) (idem_of_id_sub_idem p hp),\n    convert has_kernel_of_has_equalizer (\ud835\udfd9 X) (\ud835\udfd9 X - p),\n    rw [sub_sub_cancel], },\n  { intros h X p hp,\n    haveI : has_kernel (\ud835\udfd9 _ - p) := h X (\ud835\udfd9 _ - 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} (\u03c6 : X \u2245 X') (p : X \u27f6 X) (p' : X' \u27f6 X')\n  (hpp' : p \u226b \u03c6.hom = \u03c6.hom \u226b p')\n  (h : \u2203 (Y : C) (i : Y \u27f6 X) (e : X \u27f6 Y), i \u226b e = \ud835\udfd9 Y \u2227 e \u226b i = p) :\n  (\u2203 (Y' : C) (i' : Y' \u27f6 X') (e' : X' \u27f6 Y'), i' \u226b e' = \ud835\udfd9 Y' \u2227 e' \u226b i' = p') :=\nbegin\n  rcases h with \u27e8Y, i, e, \u27e8h\u2081, h\u2082\u27e9\u27e9,\n  use [Y, i \u226b \u03c6.hom, \u03c6.inv \u226b e],\n  split,\n  { slice_lhs 2 3 { rw \u03c6.hom_inv_id, },\n    rw [id_comp, h\u2081], },\n  { slice_lhs 2 3 { rw h\u2082, },\n    rw [hpp', \u2190 assoc, \u03c6.inv_hom_id, id_comp], }\nend\n\nlemma split_iff_of_iso {X X' : C} (\u03c6 : X \u2245 X') (p : X \u27f6 X) (p' : X' \u27f6 X')\n  (hpp' : p \u226b \u03c6.hom = \u03c6.hom \u226b p') :\n  (\u2203 (Y : C) (i : Y \u27f6 X) (e : X \u27f6 Y), i \u226b e = \ud835\udfd9 Y \u2227 e \u226b i = p) \u2194\n  (\u2203 (Y' : C) (i' : Y' \u27f6 X') (e' : X' \u27f6 Y'), i' \u226b e' = \ud835\udfd9 Y' \u2227 e' \u226b i' = p') :=\nbegin\n  split,\n  { exact split_imp_of_iso \u03c6 p p' hpp', },\n  { apply split_imp_of_iso \u03c6.symm p' p,\n    rw [\u2190 comp_id p, \u2190 \u03c6.hom_inv_id],\n    slice_rhs 2 3 { rw hpp', },\n    slice_rhs 1 2 { erw \u03c6.inv_hom_id, },\n    simpa only [id_comp], },\nend\n\nlemma equivalence.is_idempotent_complete {D : Type*} [category D] (\u03b5 : C \u224c D)\n  (h : is_idempotent_complete C) : is_idempotent_complete D :=\nbegin\n  refine \u27e8_\u27e9,\n  intros X' p hp,\n  let \u03c6 := \u03b5.counit_iso.symm.app X',\n  erw split_iff_of_iso \u03c6 p (\u03c6.inv \u226b p \u226b \u03c6.hom)\n    (by { slice_rhs 1 2 { rw \u03c6.hom_inv_id, }, rw id_comp,}),\n  rcases is_idempotent_complete.idempotents_split (\u03b5.inverse.obj X') (\u03b5.inverse.map p)\n    (by rw [\u2190 \u03b5.inverse.map_comp, hp]) with \u27e8Y, i, e, \u27e8h\u2081,h\u2082\u27e9\u27e9,\n  use [\u03b5.functor.obj Y, \u03b5.functor.map i, \u03b5.functor.map e],\n  split,\n  { rw [\u2190 \u03b5.functor.map_comp, h\u2081, \u03b5.functor.map_id], },\n  { simpa only [\u2190 \u03b5.functor.map_comp, h\u2082, 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] (\u03b5 : C \u224c D) :\n  is_idempotent_complete C \u2194 is_idempotent_complete D :=\nbegin\n  split,\n  { exact equivalence.is_idempotent_complete \u03b5, },\n  { exact equivalence.is_idempotent_complete \u03b5.symm, },\nend\n\nlemma is_idempotent_complete_of_is_idempotent_complete_opposite\n  (h : is_idempotent_complete C\u1d52\u1d56) : is_idempotent_complete C :=\nbegin\n  refine \u27e8_\u27e9,\n  intros X p hp,\n  rcases is_idempotent_complete.idempotents_split (op X) p.op\n    (by rw [\u2190 op_comp, hp]) with \u27e8Y, i, e, \u27e8h\u2081, h\u2082\u27e9\u27e9,\n  use [Y.unop, e.unop, i.unop],\n  split,\n  { simpa only [\u2190 unop_comp, h\u2081], },\n  { simpa only [\u2190 unop_comp, h\u2082], },\nend\n\nlemma is_idempotent_complete_iff_opposite :\n  is_idempotent_complete C\u1d52\u1d56 \u2194 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\u1d52\u1d56) :=\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 [\u25cf] := \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 : \u2200 t : bintree, (t \u21a3 \u25cf) \u2192 t = \u25cf := \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": "import algebra.module.linear_map\nimport data.real.basic\n\n\nvariables (R : Type*) (M : Type*) (X : Type*) \n[field R] [add_comm_group M] [module R M] [set X]\n[add_comm_group(X -> M)] [module R (X -> M)]\ntheorem cpge_applin_5_a  : \n\u2200 (a : X), \u2203 g : linear_map R (X->M) M, (\u03bbf : X -> M, f a) = g := 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/applications_lineaires/cpge_applin_5_a.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9086179018818864, "lm_q2_score": 0.5273165233795671, "lm_q1q2_score": 0.479129233100793}}
{"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 `\u03b1` with a monoid structure, `single_obj \u03b1` is `unit` type with `category` structure\nsuch that `End (single_obj \u03b1).star` is the monoid `\u03b1`.  This can be extended to a functor `Mon \u2964\nCat`.\n\nIf `\u03b1` is a group, then `single_obj \u03b1` is a groupoid.\n\nAn element `x : \u03b1` can be reinterpreted as an element of `End (single_obj.star \u03b1)` using\n`single_obj.to_End`.\n\n## Implementation notes\n\n- `category_struct.comp` on `End (single_obj.star \u03b1)` is `flip (*)`, not `(*)`. This way\n  multiplication on `End` agrees with the multiplication on `\u03b1`.\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 (\u03b1 : Type u) : Type := unit\n\nnamespace single_obj\n\nvariables (\u03b1 : Type u)\n\n/-- One and `flip (*)` become `id` and `comp` for morphisms of the single object category. -/\ninstance category_struct [has_one \u03b1] [has_mul \u03b1] : category_struct (single_obj \u03b1) :=\n{ hom := \u03bb _ _, \u03b1,\n  comp := \u03bb _ _ _ x y, y * x,\n  id := \u03bb _, 1 }\n\n/-- Monoid laws become category laws for the single object category. -/\ninstance category [monoid \u03b1] : category (single_obj \u03b1) :=\n{ comp_id' := \u03bb _ _, one_mul,\n  id_comp' := \u03bb _ _, mul_one,\n  assoc' := \u03bb _ _ _ _ x y z, (mul_assoc z y x).symm }\n\nlemma id_as_one [monoid \u03b1] (x : single_obj \u03b1) : \ud835\udfd9 x = 1 := rfl\n\nlemma comp_as_mul [monoid \u03b1] {x y z : single_obj \u03b1} (f : x \u27f6 y) (g : y \u27f6 z) :\n  f \u226b g = g * f := rfl\n\n/--\nGroupoid structure on `single_obj \u03b1`.\n\nSee https://stacks.math.columbia.edu/tag/0019.\n-/\ninstance groupoid [group \u03b1] : groupoid (single_obj \u03b1) :=\n{ inv := \u03bb _ _ x, x\u207b\u00b9,\n  inv_comp' := \u03bb _ _, mul_right_inv,\n  comp_inv' := \u03bb _ _, mul_left_inv }\n\n\n\n/-- The single object in `single_obj \u03b1`. -/\nprotected def star : single_obj \u03b1 := unit.star\n\n/-- The endomorphisms monoid of the only object in `single_obj \u03b1` is equivalent to the original\n     monoid \u03b1. -/\ndef to_End [monoid \u03b1] : \u03b1 \u2243* End (single_obj.star \u03b1) :=\n{ map_mul' := \u03bb x y, rfl,\n  .. equiv.refl \u03b1 }\n\nlemma to_End_def [monoid \u03b1] (x : \u03b1) : to_End \u03b1 x = x := rfl\n\n/-- There is a 1-1 correspondence between monoid homomorphisms `\u03b1 \u2192 \u03b2` 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 (\u03b1 : Type u) (\u03b2 : Type v) [monoid \u03b1] [monoid \u03b2] :\n  (\u03b1 \u2192* \u03b2) \u2243 (single_obj \u03b1) \u2964 (single_obj \u03b2) :=\n{ to_fun := \u03bb f,\n  { obj := id,\n    map := \u03bb _ _, \u21d1f,\n    map_id' := \u03bb _, f.map_one,\n    map_comp' := \u03bb _ _ _ x y, f.map_mul y x },\n  inv_fun := \u03bb f,\n    { to_fun := @functor.map _ _ _ _ f (single_obj.star \u03b1) (single_obj.star \u03b1),\n      map_one' := f.map_id _,\n      map_mul' := \u03bb x y, f.map_comp y x },\n  left_inv := \u03bb \u27e8f, h\u2081, h\u2082\u27e9, rfl,\n  right_inv := \u03bb f, by cases f; obviously }\n\nlemma map_hom_id (\u03b1 : Type u) [monoid \u03b1] : map_hom \u03b1 \u03b1 (monoid_hom.id \u03b1) = \ud835\udfed _ := rfl\n\nlemma map_hom_comp {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2)\n  {\u03b3 : Type w} [monoid \u03b3] (g : \u03b2 \u2192* \u03b3) :\n  map_hom \u03b1 \u03b3 (g.comp f) = map_hom \u03b1 \u03b2 f \u22d9 map_hom \u03b2 \u03b3 g :=\nrfl\n\n/-- Given a function `f : C \u2192 G` from a category to a group, we get a functor\n    `C \u2964 G` sending any morphism `x \u27f6 y` to `f y * (f x)\u207b\u00b9`. -/\n@[simps] def difference_functor {C G} [category C] [group G] (f : C \u2192 G) : C \u2964 single_obj G :=\n{ obj := \u03bb _, (),\n  map := \u03bb x y _, f y * (f x)\u207b\u00b9,\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, \u2190mul_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 : \u03b1 \u2192 \u03b2` as a functor `(single_obj \u03b1) \u2964 (single_obj \u03b2)`.\nSee also `category_theory.single_obj.map_hom` for an equivalence between these types. -/\n@[reducible] def to_functor {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2) :\n  (single_obj \u03b1) \u2964 (single_obj \u03b2) :=\nsingle_obj.map_hom \u03b1 \u03b2 f\n\n@[simp] lemma id_to_functor (\u03b1 : Type u) [monoid \u03b1] : (id \u03b1).to_functor = \ud835\udfed _ := rfl\n@[simp] lemma comp_to_functor {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2)\n  {\u03b3 : Type w} [monoid \u03b3] (g : \u03b2 \u2192* \u03b3) :\n  (g.comp f).to_functor = f.to_functor \u22d9 g.to_functor :=\nrfl\n\nend monoid_hom\n\nnamespace units\n\nvariables (\u03b1 : Type u) [monoid \u03b1]\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 \u03b1 \u2243* Aut (single_obj.star \u03b1) :=\n(units.map_equiv (single_obj.to_End \u03b1)).trans $\n  Aut.units_End_equiv_Aut _\n\n@[simp] lemma to_Aut_hom (x : units \u03b1) : (to_Aut \u03b1 x).hom = single_obj.to_End \u03b1 x := rfl\n@[simp] lemma to_Aut_inv (x : units \u03b1) :\n  (to_Aut \u03b1 x).inv = single_obj.to_End \u03b1 (x\u207b\u00b9 : units \u03b1) :=\nrfl\nend units\n\nnamespace Mon\n\nopen category_theory\n\n/-- The fully faithful functor from `Mon` to `Cat`. -/\ndef to_Cat : Mon \u2964 Cat :=\n{ obj := \u03bb x, Cat.of (single_obj x),\n  map := \u03bb x y f, single_obj.map_hom x y f }\n\ninstance to_Cat_full : full to_Cat :=\n{ preimage := \u03bb x y, (single_obj.map_hom x y).inv_fun,\n  witness' := \u03bb x y, by apply equiv.right_inv }\n\ninstance to_Cat_faithful : faithful to_Cat :=\n{ map_injective' := \u03bb 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 ` \u229a `:80 g:80 := category_struct.comp g f\n\n\ndef is_pullback {X : Type v} [category X]\n    {A\u2081 A\u2082 B : X}\n    (f : A\u2081 \u27f6 B) (g : A\u2082 \u27f6 B)\n    {P : X} (p\u2081 : P \u27f6 A\u2081) (p\u2082 : P \u27f6 A\u2082): Prop :=\n    f \u229a p\u2081 = g \u229a p\u2082 \u2227 \n    \u03a0 {Q : X} (q\u2081 : Q \u27f6 A\u2081) (q\u2082 : Q \u27f6 A\u2082),\n        f \u229a q\u2081 = g \u229a q\u2082 \u2192\n            \u2203! h : Q \u27f6 P, q\u2081 = p\u2081 \u229a h \u2227 q\u2082 = p\u2082 \u229a h\n\n\nlemma equalizer_product_is_pullback_cat \n    {X : Type u} [category X]\n    {A\u2081 A\u2082 B P E : X}\n    (f : A\u2081 \u27f6 B) (g : A\u2082 \u27f6 B)\n    (\u03c0\u2081 : P \u27f6 A\u2081) (\u03c0\u2082 : P \u27f6 A\u2082)\n    (pr : is_product A\u2081 A\u2082 \u03c0\u2081 \u03c0\u2082)\n    (e : E \u27f6 P)\n    (eqauliz : is_equalizer (f \u229a \u03c0\u2081) (g \u229a \u03c0\u2082) e) :\n    is_pullback f g\n        (\u03c0\u2081 \u229a e)\n        (\u03c0\u2082 \u229a e) \n    := \n    \u27e8 begin \n        tidy\n     end\n    ,\n    begin\n        intros Q q\u2081 q\u2082 fq\u2081_gq\u2082,\n        let p : Q \u27f6 P := some (pr  Q q\u2081 q\u2082),\n        have spec_p : q\u2081 = \u03c0\u2081 \u229a p \u2227 q\u2082 = \u03c0\u2082 \u229a p := (some_spec (pr Q q\u2081 q\u2082)).1,\n\n        have eq_comp : f \u229a \u03c0\u2081 \u229a p  = g \u229a \u03c0\u2082 \u229a p := \n            calc f \u229a \u03c0\u2081 \u229a p   = f \u229a (\u03c0\u2081 \u229a p)   : by tidy\n                    ...         = f \u229a q\u2081         : by rw \u2190 spec_p.1\n                    ...         = g \u229a q\u2082         : fq\u2081_gq\u2082\n                    ...         = g \u229a (\u03c0\u2082 \u229a p)  : by rw spec_p.2\n                    ...         = g \u229a \u03c0\u2082 \u229a p    : by tidy,\n\n        let h : Q \u27f6 E := some (eqauliz.2 p eq_comp),\n        have spec_h : p = e \u229a h := (some_spec (eqauliz.2 p eq_comp)).1,\n        use h,\n        have h0 : q\u2081 = \u03c0\u2081 \u229a e \u229a h \u2227 q\u2082 = \u03c0\u2082 \u229a e \u229a h :=\n            \u27e8 \n                by simp [spec_h , spec_p.1]\n                ,  \n                by simp [spec_h , spec_p.2]\n            \u27e9 ,\n        split, \n        exact h0,\n        assume (y : Q \u27f6 E) (spec_y : q\u2081 = \u03c0\u2081 \u229a e \u229a y \u2227 q\u2082 = \u03c0\u2082 \u229a e \u229a y),\n        have s0 : \u03c0\u2081 \u229a (e \u229a h) = \u03c0\u2081 \u229a (e \u229a y) := \n            calc \u03c0\u2081 \u229a (e \u229a h) = \u03c0\u2081 \u229a e \u229a h      : by tidy\n                ...            = q\u2081                : eq.symm h0.1\n                ...            = \u03c0\u2081 \u229a e \u229a y      : spec_y.1\n                ...            = \u03c0\u2081 \u229a (e \u229a y)    : by tidy,\n        have s1 : \u03c0\u2082 \u229a (e \u229a h) = \u03c0\u2082 \u229a (e \u229a y) := \n            calc \u03c0\u2082 \u229a (e \u229a h) = \u03c0\u2082 \u229a e \u229a h      : by tidy\n            ...                = q\u2082                : eq.symm h0.2\n            ...                = \u03c0\u2082 \u229a e \u229a y      : spec_y.2\n            ...                = \u03c0\u2082 \u229a (e \u229a y)    : by tidy,\n        have eh_ey : e \u229a h = e \u229a y := \n            jointly_mono A\u2081 A\u2082 P \u03c0\u2081 \u03c0\u2082 pr s0 s1,\n        \n        haveI m_e : mono e := equalizer_is_mono (f \u229a \u03c0\u2081) (g \u229a \u03c0\u2082) e eqauliz,\n        exact left_cancel e (eq.symm eh_ey)\n    end \u27e9 \n\n\n\n\nvariables {A\u2081 A\u2082 B : Type u}\nvariables (f : A\u2081 \u27f6 B) (g : A\u2082 \u27f6 B)\n\nlemma equalizer_product_is_pullback :\n    let P := A\u2081 \u00d7 A\u2082 in \n    let \u03c0\u2081 : P \u2192 A\u2081 := \u03bb ab, ab.1 in\n    let \u03c0\u2082 : P \u2192 A\u2082 := \u03bb ab, ab.2 in\n    let E := equalizer_set (f \u2218 \u03c0\u2081) (g \u2218 \u03c0\u2082) in\n    let e := E \u21aa P in\n\n    is_pullback f g\n        (\u03c0\u2081 \u2218 e)\n        (\u03c0\u2082 \u2218 e) \n    := \n    let P := A\u2081 \u00d7 A\u2082 in \n    let \u03c0\u2081 : P \u2192 A\u2081 := \u03bb ab, ab.1 in\n    let \u03c0\u2082 : P \u2192 A\u2082 := \u03bb ab, ab.2 in\n    let E := equalizer_set (f \u2218 \u03c0\u2081) (g \u2218 \u03c0\u2082) in\n    let e : E \u2192 P := E \u21aa P in\n    \u27e8 begin \n        tidy\n    end\n    ,\n    begin\n        intros Q q\u2081 q\u2082 fq\u2081_gq\u2082,\n        have eq := eqaulizer_set_is_equalizer (f \u2218 \u03c0\u2081) (g \u2218 \u03c0\u2082),\n        have pr := cartesian_product_is_product A\u2081 A\u2082 Q q\u2081 q\u2082,\n        let p : Q \u2192 P := some pr,\n        have spec_p : q\u2081 = \u03c0\u2081 \u2218 p \u2227 q\u2082 = \u03c0\u2082 \u2218 p := (some_spec pr).1,\n\n        have eq_comp : f \u2218 \u03c0\u2081 \u2218 p = g \u2218 \u03c0\u2082 \u2218 p := \n            spec_p.2 \u25b8 (spec_p.1 \u25b8 fq\u2081_gq\u2082),\n\n        let h : Q \u2192 E := some (eq.2 p eq_comp),\n        have spec_h : p = e \u2218 h := (some_spec (eq.2 p eq_comp)).1,\n        use h,\n        split, \n        have h0 : q\u2081 = \u03c0\u2081 \u2218 e \u2218 h \u2227 q\u2082 = \u03c0\u2082 \u2218 e \u2218 h :=\n            \u27e8 \n                by simp [spec_h , spec_p.1]\n                ,  \n                by simp [spec_h , spec_p.2]\n            \u27e9 ,\n        exact h0,\n        assume (y : Q \u2192 E) (hy : q\u2081 = \u03c0\u2081 \u2218 e \u2218 y \u2227 q\u2082 = \u03c0\u2082 \u2218 e \u2218 y),\n        have s0 : \u03c0\u2081 \u2218 e \u2218 h = \u03c0\u2081 \u2218 e \u2218 y := \n                spec_h \u25b8 (spec_p.1 \u25b8 hy.1),\n        have s1 : \u03c0\u2082 \u2218 e \u2218 h = \u03c0\u2082 \u2218 e \u2218 y := \n                spec_h \u25b8 (spec_p.2 \u25b8 hy.2),\n        have eh_ey : e \u2218 h = e \u2218 y := \n            jointly_mono A\u2081 A\u2082 (A\u2081 \u00d7 A\u2082) prod.fst prod.snd \n                (cartesian_product_is_product A\u2081 A\u2082) s0 s1,\n        \n        have elements : \u2200 q, y q = h q :=\n            assume q,\n            have e0 : (e \u2218 y) q = (e \u2218 h) q := \n                by rw eh_ey,\n            (inj_inclusion P E) e0,\n        exact funext elements\n            \n    end \u27e9 \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 `\u03b1`, resulting in `\u03b2`, i.e., `\u03b1 \u2192 ... \u2192 \u03b1 \u2192 \u03b2` -/\nabbrev CurriedFun (\u03b1 : Type u) (\u03b2 : Type v) : Nat \u2192 Type (max u v)\n  | 0   => PUnit.{u+1} \u2192 \u03b2\n  | 1   => \u03b1 \u2192 \u03b2\n  | n+1 => \u03b1 \u2192 CurriedFun \u03b1 \u03b2 n\n\n\n/-- A curried type function of `n` arguments, i.e., `Type u \u2192 Type u \u2192 ... \u2192 Type v` -/\nabbrev CurriedTypeFun : Nat \u2192 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 \u2192 Type v\n\nnamespace TypeFun\n  def reverseArgs : TypeFun n \u2192 TypeFun n :=\n    fun v \u03b1 => v <| Vec.reverse \u03b1 \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} \u2192 TypeFun n \u2192 CurriedTypeFun n\n    | 0,    F => fun _ => F !![]\n    | 1,    F => fun a => F !![a] \n    | _+2,  F => fun a => curriedAux fun \u03b1s => F (\u03b1s ::: a)\n\n  def curried (F : TypeFun n) : CurriedTypeFun n\n    := curriedAux (F.reverseArgs)\n\n\n  def ofCurriedAux : {n : Nat} \u2192 CurriedTypeFun n \u2192 TypeFun n\n    | 0,    F, _ => F PUnit.unit\n    | 1,    F, \u03b1 => F (\u03b1 0)\n    | n+2,  F, \u03b1 => ofCurriedAux (F \u03b1.last) \u03b1.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 \u03b1 => F (\u03b1 ::: 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 `\u211d\u22650`.\n-- But I don't think that is relevant for this project.\n\n/-- A system of complexes of seminormed groups, indexed by `\u211d\u22650`.\nSee also Definition 9.3 of [Analytic]. -/\n@[derive [category_theory.category, category_theory.preadditive]]\ndef system_of_complexes : Type* := \u211d\u22650\u1d52\u1d56 \u2964 (cochain_complex SemiNormedGroup \u2115)\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 \u27f6 M') (g : M' \u27f6 N)\n\ninstance : has_coe_to_fun system_of_complexes (\u03bb C, \u211d\u22650 \u2192 \u2115 \u2192 SemiNormedGroup) :=\n\u27e8\u03bb C c i, (C.obj $ op c).X i\u27e9\n\n/-- `f.apply c i` is application of the natural transformation `f`: $f_c^i : M_c^i \u27f6 N_c^i$. -/\ndef quiver.hom.apply (f : M \u27f6 N) {c : \u211d\u22650} {i : \u2115} : M c i \u27f6 N c i :=\n(f.app (op c)).f i\n\ninstance hom_to_fun : has_coe_to_fun (M \u27f6 N) (\u03bb f, \u03a0 {c : \u211d\u22650} {i : \u2115}, M c i \u2192 N c i) :=\n\u27e8\u03bb f {c} {i} x, f.apply x\u27e9\n\nlemma system_of_complexes.hom_apply (f : M \u27f6 N) {c : \u211d\u22650} {i : \u2115} (x : M c i) : f x = f.apply x :=\nrfl\n\nlemma system_of_complexes.map_sub (f : M \u27f6 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 \u2245 N_c^i$. -/\ndef category_theory.iso.apply (f : M \u2245 N) {c : \u211d\u22650} {i : \u2115} : M c i \u2245 N c i :=\nhomological_complex.hom.iso_app (f.app (op c)) i\n\nnamespace system_of_complexes\n\nvariables (C C\u2081 C\u2082 : system_of_complexes.{u})\n\n/-- `res` is the restriction map `C c' i \u27f6 C c i` for a system of complexes `C`,\nand nonnegative reals `c \u2264 c'`. -/\ndef res {C : system_of_complexes} {c' c : \u211d\u22650} {i : \u2115} [h : fact (c \u2264 c')] : C c' i \u27f6 C c i :=\n(C.map (hom_of_le h.out).op).f i\n\nvariables {c\u2081 c\u2082 c\u2083 : \u211d\u22650} (i j : \u2115)\n\n@[simp] lemma res_comp_res (h\u2081 : fact (c\u2082 \u2264 c\u2081)) (h\u2082 : fact (c\u2083 \u2264 c\u2082)) :\n  @res C _ _ i h\u2081 \u226b @res C _ _ i h\u2082 = @res C _ _ i \u27e8h\u2082.out.trans h\u2081.out\u27e9 :=\nbegin\n  have := (category_theory.functor.map_comp C (hom_of_le h\u2081.out).op (hom_of_le h\u2082.out).op),\n  rw [\u2190 op_comp] at this,\n  delta res,\n  erw this,\n  refl,\nend\n\n@[simp] lemma res_res (h\u2081 : fact (c\u2082 \u2264 c\u2081)) (h\u2082 : fact (c\u2083 \u2264 c\u2082)) (x : C c\u2081 i) :\n  @res C _ _ i h\u2082 (@res C _ _ i h\u2081 x) = @res C _ _ i \u27e8h\u2082.out.trans h\u2081.out\u27e9 x :=\nby { rw \u2190 (C.res_comp_res i h\u2081 h\u2082), refl }\n\n/-- `C.d` is the differential `C c i \u27f6 C c (i+1)` for a system of complexes `C`. -/\ndef d (C : system_of_complexes) {c : \u211d\u22650} (i j : \u2115) : C c i \u27f6 C c j :=\n(C.obj $ op c).d i j\n\nlemma d_eq_zero (c : \u211d\u22650) (h : i + 1 \u2260 j) : (C.d i j : C c i \u27f6 C c j) = 0 :=\n(C.obj $ op c).shape _ _ h\n\nlemma d_eq_zero_apply (c : \u211d\u22650) (h : i + 1 \u2260 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 : \u211d\u22650) (x : C c i) : (C.d i i x) = 0 :=\nd_eq_zero_apply _ _ _ _ i.succ_ne_self _\n\nlemma d_comp_d (c : \u211d\u22650) (i j k : \u2115) : C.d i j \u226b (C.d j k : C c j \u27f6 _) = 0 :=\n(C.obj $ op c).d_comp_d _ _ _\n\n@[simp] lemma d_d (c : \u211d\u22650) (i j k : \u2115) (x : C c i) :\n  C.d j k (C.d i j x) = 0 :=\nshow ((C.d i j) \u226b C.d j k) x = 0, by { rw d_comp_d, refl }\n\nlemma d_comp_res (h : fact (c\u2082 \u2264 c\u2081)) :\n  C.d i j \u226b @res C _ _ _ h = @res C _ _ _ _ \u226b C.d i j :=\n((C.map (hom_of_le h.out).op).comm _ _).symm\n\nlemma d_res (h : fact (c\u2082 \u2264 c\u2081)) (x) :\n  C.d i j (@res C _ _ _ _ x) = @res C _ _ _ h (C.d i j x) :=\nshow (@res C _ _ _ _ \u226b C.d i j) x = (C.d i j \u226b @res C _ _ _ h) x,\nby rw d_comp_res\n\nsection iso\n\nvariables (\u03d5 : M \u2245 N) (c : \u211d\u22650) (i)\n\nlemma apply_hom_eq_hom_apply : (\u03d5.apply.hom : M c i \u27f6 N c i) = \u03d5.hom.apply := rfl\n\nlemma apply_inv_eq_inv_apply : (\u03d5.apply.inv : N c i \u27f6 M c i) = \u03d5.inv.apply := rfl\n\n@[simp] lemma hom_apply_comp_inv_apply :\n  (\u03d5.hom.apply : M c i \u27f6 N c i) \u226b \u03d5.inv.apply = \ud835\udfd9 _ :=\nby rw [\u2190 apply_hom_eq_hom_apply, \u2190 apply_inv_eq_inv_apply, iso.hom_inv_id]\n\n@[simp] lemma inv_apply_comp_hom_apply :\n  (\u03d5.inv.apply : N c i \u27f6 M c i) \u226b \u03d5.hom.apply = \ud835\udfd9 _ :=\nby rw [\u2190 apply_hom_eq_hom_apply, \u2190 apply_inv_eq_inv_apply, iso.inv_hom_id]\n\n@[simp] lemma inv_apply_hom_apply (x : M c i) :\n  \u03d5.inv.apply (\u03d5.hom.apply x) = x :=\nshow ((\u03d5.hom.apply : M c i \u27f6 N c i) \u226b \u03d5.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  \u03d5.hom (\u03d5.inv x) = x :=\nshow ((\u03d5.inv.apply : N c i \u27f6 M c i) \u226b \u03d5.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' : \u211d\u22650} {i i' : \u2115} (hc : c = c') (hi : i = i') :\n  C c i \u27f6 C c' i' :=\neq_to_hom $ by { subst hc, subst hi }\n\nvariables (M M' N)\n\nlemma d_apply (f : M \u27f6 N) {c : \u211d\u22650} {i j : \u2115} (m : M c i) :\n  N.d i j (f m) = f (M.d i j m) :=\nbegin\n  show (_ \u226b N.d i j) m = (M.d i j \u226b _) m,\n  congr' 1,\n  exact (f.app (op c)).comm i j\nend\n\nlemma res_comp_apply (f : M \u27f6 N) (c c' : \u211d\u22650) [h : fact (c \u2264 c')] (i : \u2115) :\n  @res M c' c i _ \u226b f.apply = f.apply \u226b res :=\ncongr_fun (congr_arg homological_complex.hom.f (f.naturality (hom_of_le h.out).op)) i\n\nlemma res_apply (f : M \u27f6 N) (c c' : \u211d\u22650) [h : fact (c \u2264 c')] {i : \u2115} (m : M c' i) :\n  @res N c' c _ _ (f m) = f (res m) :=\nshow (f.apply \u226b (@res N c' c _ _)) m = (@res M c' c _ _ \u226b (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' : \u2200 c i j (h : i + 1 = j), (C.d i j : C c i \u27f6 C c j).norm_noninc)\n(res_norm_noninc : \u2200 c' c i h, (@res C c' c i h).norm_noninc)\n\nlemma admissible.d_norm_noninc (hC : C.admissible) (c : \u211d\u22650) (i j : \u2115) :\n  (C.d i j : C c i \u27f6 _).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 \u27f6 M'} (hadm : M'.admissible)\n  (hiso : \u2200 c i, @isometry (M c i) (M' c i) _ _ f.apply) :\n  M.admissible :=\nbegin\n  refine \u27e8\u03bb c i j h x, _, \u03bb c' c i h x, _\u27e9,\n  { rw [\u2190 (add_monoid_hom_class.isometry_iff_norm _).1 (hiso c i) _,\n      \u2190 (add_monoid_hom_class.isometry_iff_norm _).1 (hiso c j) _, \u2190 system_of_complexes.hom_apply f,\n      \u2190 d_apply],\n    exact hadm.d_norm_noninc _ _ _ _ _ },\n  { rw [\u2190 (add_monoid_hom_class.isometry_iff_norm _).1 (hiso c i) _,\n      \u2190 (add_monoid_hom_class.isometry_iff_norm _).1 (hiso c' i) _, \u2190 system_of_complexes.hom_apply f,\n      \u2190 system_of_complexes.hom_apply f, \u2190 res_apply],\n    exact hadm.res_norm_noninc _ _ _ _ _  }\nend\n\nvariables (M M')\n\n/-- `is_bounded_exact k K m c\u2080` is a predicate on systems of complexes.\n\nA system of complexes `C` is `(k,K)`-exact in degrees `\u2264 m` for `c \u2265 c\u2080`*\nif the following condition is satisfied:\nFor all `c \u2265 c\u2080` and all `x : C (k * c) i` with `i \u2264 m` there is some `y : C c (i-1)`\n(which is defined to be `0` when `i = 0`) such that `\u2225(C.res x) - (C.d y)\u2225 \u2264 K * \u2225C.d x\u2225`.\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 \u27f6 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  \u2203 (i\u2080 j : \u2115) (hi\u2080 : i\u2080 = i - 1) (hj : i + 1 = j)\n    (y : C c i\u2080), \u2225res x - C.d _ _ y\u2225 \u2264 K * \u2225C.d i j x\u2225\n  ```\n  This is a hack around an inconvenience known as dependent type theory hell. -/\ndef is_bounded_exact\n  (k K : \u211d\u22650) (m : \u2115) [hk : fact (1 \u2264 k)] (c\u2080 : \u211d\u22650) : Prop :=\n\u2200 c (hc : fact (c\u2080 \u2264 c)) i (hi : i \u2264 m) (x : C (k * c) i),\n\u2203 (i\u2080 j : \u2115) (hi\u2080 : i\u2080 = i - 1) (hj : i + 1 = j)\n  (y : C c i\u2080), \u2225res x - C.d _ _ y\u2225 \u2264 K * \u2225C.d i j x\u2225\n\n/-- Weak version of `is_bounded_exact`. -/\ndef is_weak_bounded_exact\n  (k K : \u211d\u22650) (m : \u2115) [hk : fact (1 \u2264 k)] (c\u2080 : \u211d\u22650) : Prop :=\n\u2200 c (hc : fact (c\u2080 \u2264 c)) i (hi : i \u2264 m) (x : C (k * c) i) (\u03b5 : \u211d) (h\u03b5 : 0 < \u03b5),\n\u2203 (i\u2080 j : \u2115) (hi\u2080 : i\u2080 = i - 1) (hj : i + 1 = j)\n  (y : C c i\u2080), \u2225res x - C.d _ _ y\u2225 \u2264 K * \u2225C.d i j x\u2225 + \u03b5\n\nnamespace is_weak_bounded_exact\n\nvariables {C C\u2081 C\u2082}\nvariables {k k' K K' : \u211d\u22650} {m m' : \u2115} {c\u2080 c\u2080' : \u211d\u22650} [fact (1 \u2264 k)] [fact (1 \u2264 k')]\n\nlemma of_le (hC : C.is_weak_bounded_exact k K m c\u2080) (hC_adm : C.admissible)\n  (hk : fact (k \u2264 k')) (hK : fact (K \u2264 K')) (hm : m' \u2264 m) (hc\u2080 : fact (c\u2080 \u2264 c\u2080')) :\n  C.is_weak_bounded_exact k' K' m' c\u2080' :=\nbegin\n  intros c hc i hi x \u03b5 \u03b5_pos,\n  haveI : fact (k \u2264 k') := hk,\n  obtain \u27e8i', j, hi', hj, y, hy\u27e9 := hC c \u27e8hc\u2080.out.trans hc.out\u27e9 i (hi.trans hm) (res x) \u03b5 \u03b5_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\u2081.is_weak_bounded_exact k K m c\u2080) (f : C\u2081 \u2245 C\u2082)\n  (hf : \u2200 c i, @isometry (C\u2081 c i) (C\u2082 c i) _ _ (f.hom.apply : C\u2081 c i \u27f6 C\u2082 c i)) :\n  C\u2082.is_weak_bounded_exact k K m c\u2080 :=\nbegin\n  intros c hc i hi x \u03b5 h\u03b5,\n  obtain \u27e8i', j, hi', hj, y, hy\u27e9 := h c hc i hi (f.inv.apply x) \u03b5 h\u03b5,\n  refine \u27e8i', j, hi', hj, f.hom y, _\u27e9,\n  calc  \u2225res x - C\u2082.d _ _ (f.hom y)\u2225\n      = \u2225res x - f.hom (C\u2081.d _ _ y)\u2225 : by rw d_apply\n  ... = \u2225f.hom (f.inv (res x)) - f.hom (C\u2081.d _ _ y)\u2225 : by rw hom_apply_inv_apply\n  ... = \u2225f.hom (f.inv (res x) - C\u2081.d _ _ y)\u2225 : by congr ; exact (system_of_complexes.map_sub _ _ _).symm\n  ... = \u2225f.inv (res x) - C\u2081.d _ _ y\u2225 : normed_add_group_hom.norm_eq_of_isometry (hf _ _) _\n  ... = \u2225res (f.inv x) - C\u2081.d _ _ y\u2225 : by rw res_apply\n  ... \u2264 K * \u2225C\u2081.d _ _ (f.inv x)\u2225 + \u03b5 : hy\n  ... = K * \u2225C\u2082.d _ _ x\u2225 + \u03b5 : _,\n  congr' 2,\n  calc  \u2225C\u2081.d i j (f.inv x)\u2225\n      = \u2225f.inv (C\u2082.d i j x)\u2225 : by rw d_apply\n  ... = \u2225f.hom (f.inv (C\u2082.d _ _ x))\u2225 : (normed_add_group_hom.norm_eq_of_isometry (hf _ _) _).symm\n  ... = \u2225C\u2082.d _ _ x\u2225 : by rw hom_apply_inv_apply\nend\n\nlemma iff_of_iso (f : C\u2081 \u2245 C\u2082)\n  (hf : \u2200 c i, @isometry (C\u2081 c i) (C\u2082 c i) _ _ (f.hom.apply : C\u2081 c i \u27f6 C\u2082 c i)) :\n  C\u2081.is_weak_bounded_exact k K m c\u2080 \u2194 C\u2082.is_weak_bounded_exact k K m c\u2080 :=\nbegin\n  refine \u27e8\u03bb h, h.of_iso f hf, \u03bb h, h.of_iso f.symm _\u27e9,\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 \u2190 normed_add_group_hom.norm_eq_of_isometry (hf c n),\n  simp only [\u2190apply_hom_eq_hom_apply, \u2190apply_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\u2081 C\u2082}\nvariables {k k' K K' : \u211d\u22650} {m m' : \u2115} {c\u2080 c\u2080' : \u211d\u22650} [fact (1 \u2264 k)] [fact (1 \u2264 k')]\n\nlemma of_le (hC : C.is_bounded_exact k K m c\u2080)\n  (hC_adm : C.admissible) (hk : k \u2264 k') (hK : K \u2264 K') (hm : m' \u2264 m) (hc\u2080 : c\u2080 \u2264 c\u2080') :\n  C.is_bounded_exact k' K' m' c\u2080' :=\nbegin\n  intros c hc i hi x,\n  haveI : fact (k \u2264 k') := \u27e8hk\u27e9,\n  obtain \u27e8i', j, hi', hj, y, hy\u27e9 := hC c \u27e8hc\u2080.trans hc.out\u27e9 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\u2081.is_bounded_exact k K m c\u2080) (f : C\u2081 \u2245 C\u2082)\n  (hf : \u2200 c i, @isometry (C\u2081 c i) (C\u2082 c i) _ _ (f.hom.apply : C\u2081 c i \u27f6 C\u2082 c i)) :\n  C\u2082.is_bounded_exact k K m c\u2080 :=\nbegin\n  intros c hc i hi x,\n  obtain \u27e8i', j, hi', hj, y, hy\u27e9 := h c hc i hi (f.inv.apply x),\n  refine \u27e8i', j, hi', hj, f.hom y, _\u27e9,\n  calc  \u2225res x - C\u2082.d _ _ (f.hom y)\u2225\n      = \u2225res x - f.hom (C\u2081.d _ _ y)\u2225 : by rw d_apply\n  ... = \u2225f.hom (f.inv (res x)) - f.hom (C\u2081.d _ _ y)\u2225 : by rw hom_apply_inv_apply\n  ... = \u2225f.hom (f.inv (res x) - C\u2081.d _ _ y)\u2225 : by congr ; exact (system_of_complexes.map_sub _ _ _).symm\n  ... = \u2225f.inv (res x) - C\u2081.d _ _ y\u2225 : normed_add_group_hom.norm_eq_of_isometry (hf _ _) _\n  ... = \u2225res (f.inv x) - C\u2081.d _ _ y\u2225 : by rw res_apply\n  ... \u2264 K * \u2225C\u2081.d _ _ (f.inv x)\u2225 : hy\n  ... = K * \u2225C\u2082.d _ _ x\u2225 : congr_arg _ _,\n  calc  \u2225C\u2081.d i j (f.inv x)\u2225\n      = \u2225f.inv (C\u2082.d i j x)\u2225 : by rw d_apply\n  ... = \u2225f.hom (f.inv (C\u2082.d _ _ x))\u2225 : (normed_add_group_hom.norm_eq_of_isometry (hf _ _) _).symm\n  ... = \u2225C\u2082.d _ _ x\u2225 : by rw hom_apply_inv_apply\nend\n\nend is_bounded_exact\n\nnamespace is_weak_bounded_exact\n\nvariables {C C\u2081 C\u2082}\nvariables {k k' K K' : \u211d\u22650} {m m' : \u2115} {c\u2080 c\u2080' : \u211d\u22650} [fact (1 \u2264 k)] [fact (1 \u2264 k')]\n\nlemma to_exact (hC : C.is_weak_bounded_exact k K m c\u2080)\n  [\u2200 c i, separated_space (C c i)]\n  {\u03b4 : \u211d\u22650} (h\u03b4 : 0 < \u03b4)\n  (H : \u2200 c \u2265 c\u2080, \u2200 i \u2264 m, \u2200 x : C (k * c) i, \u2200 j, i+1 = j \u2192\n    C.d _ j x = 0 \u2192 \u2203 (i\u2080 : \u2115) (hi\u2080 : i\u2080 = i - 1) (y : C c i\u2080), res x = C.d _ _ y) :\n  C.is_bounded_exact k (K + \u03b4) m c\u2080 :=\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 \u27e8i\u2080, hi\u2080, y, hy\u27e9,\n    exact \u27e8i\u2080, _, hi\u2080, rfl, y, by simp [hy, hdx]\u27e9 },\n  { obtain \u27e8i', j, hi', rfl, y, hy\u27e9 :=\n      hC c hc _ hi x (\u03b4*\u2225C.d _ (i+1) x\u2225) (mul_pos (by exact_mod_cast h\u03b4) $ norm_pos_iff'.mpr hdx),\n    refine \u27e8i', _, hi', rfl, y, _\u27e9,\n    have : ((K + \u03b4 : \u211d\u22650) : \u211d) * \u2225C.d _ (i+1) x\u2225\n      = K * \u2225C.d _ (i+1) x\u2225 + \u03b4 * \u2225C.d _ (i+1) x\u2225, 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 \u27f6 M') : Prop :=\n\u2200 c i, (f.apply : M c i \u27f6 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 \u27f6 M'` to functions.\n\nlemma is_quotient.surjective {f : M \u27f6 M'} (h : is_quotient f) {c i} (m' : M' c i) :\n  \u2203 m : M c i, f m = m' := (h c i).surjective m'\n\nlemma is_quotient.norm_lift {f : M \u27f6 M'} (h : is_quotient f) {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5) {c i}\n  (n : M' c i) : \u2203 (m : M c i), f m = n \u2227 \u2225m\u2225 < \u2225n\u2225 + \u03b5 :=\n(h c i).norm_lift h\u03b5 n\n\nlemma is_quotient.norm_le {f : M \u27f6 M'} (h : is_quotient f) {c i} (m : M c i) : \u2225f m\u2225 \u2264 \u2225m\u2225 :=\n(h c i).norm_le _\n\n/-- The quotient of an admissible system of complexes is admissible. -/\nlemma admissible_of_quotient {f : M \u27f6 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 \u03b5 h\u03b5,\n    obtain \u27e8m, hm : f m = m' \u2227 \u2225m\u2225 < \u2225m'\u2225 + \u03b5\u27e9 := hquot.norm_lift h\u03b5 m',\n    rw [\u2190 hm.1, d_apply],\n    calc \u2225f (M.d _ _ m)\u2225 \u2264 \u2225M.d _ _ m\u2225 : hquot.norm_le _\n      ... \u2264 \u2225m\u2225 : hadm.d_norm_noninc _ _ _ _ m\n      ... \u2264 \u2225m'\u2225 + \u03b5 : le_of_lt hm.2\n      ... = \u2225f m\u2225 + \u03b5 : 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 \u03b5 h\u03b5,\n    obtain \u27e8m, hm\u27e9 := hquot.norm_lift h\u03b5 m',\n    rw [\u2190 hm.1, res_apply],\n    calc \u2225f (res m)\u2225 \u2264 \u2225res m\u2225 : hquot.norm_le _\n      ... \u2264 \u2225m\u2225 : hadm.res_norm_noninc c' c _ hc m\n      ... \u2264 \u2225m'\u2225 + \u03b5 : le_of_lt hm.2\n      ... = \u2225f m\u2225 + \u03b5 : by rw [hm.1] }\nend\n\nend quotient\n\n-- move me\ninstance SemiNormedGroup.forget\u2082_Ab : has_forget\u2082 SemiNormedGroup Ab :=\n{ forget\u2082 :=\n  { obj := \u03bb V, AddCommGroup.of V,\n    map := \u03bb _ _ f, f.to_add_monoid_hom },\n  forget_comp := by tidy }\n\ninstance SemiNormedGroup.forget\u2082_Ab_additive : (forget\u2082 SemiNormedGroup Ab).additive := {}\n\ndef to_Ab (C : system_of_complexes) : \u211d\u22650\u1d52\u1d56 \u2964 cochain_complex Ab \u2115 :=\nC \u22d9 functor.map_homological_complex (forget\u2082 _ _) _\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 \u2192+* B` between commutative rings `A` and `B` is *formally smooth*\nif for every surjective square-zero extension of A-algebras `R' \u2192+* R`\n(meaning that the kernel I satisties I\u00b2 = 0)\nthe natural map Hom_A(B,R') \u2192 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 \u2192 B` is *formally smooth* if for every surjective square zero\nmorphism `\u03c6 : R \u2192 R'` of A-algebras, the natural map Hom_A(B,R') \u2192 Hom_A(B, R) is\na surjection. -/\ndef is_formally_smooth {A B : Type} [comm_ring A] [comm_ring B] (f : A \u2192+* 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\u2200 {{R R' : Type}} [comm_ring R] [comm_ring R'], by exactI\n\u2200 [algebra A R] [algebra A R'], by exactI\n-- and for all A-algebra morphisms \u03c6 : R' \u2192 R with square zero\n\u2200 {\u03c6 : R' \u2192\u2090[A] R} (h\u03c61 : \u2200 r : R, \u2203 r' : R', \u03c6 r' = r) \n  (h\u03c62 : \u2200 x y : R', \u03c6 x = 0 \u2192 \u03c6 y = 0 \u2192 x * y = 0),\n-- composing with \u03c6 is a surjection Hom_A(B,R') \u2192 Hom_A(B, R)\nfunction.surjective (\u03c6.comp : (B \u2192\u2090[A] R') \u2192 (B \u2192\u2090[A] R))\n\nlemma is_formally_smooth_id : is_formally_smooth (ring_hom.id A : A \u2192+* A) :=\n\u03bb R R' _ _ _ _ \u03c6 _ _ \u03c8, by resetI; exact \u27e8algebra.of_id A R', subsingleton.elim _ _\u27e9\n\nvariables {C : Type} [comm_ring C]\n\nlemma is_formally_smooth_comp {\u03c6 : A \u2192+* B} (h\u03c6 : is_formally_smooth \u03c6)\n  {\u03c8 : B \u2192+* C} (h\u03c8 : is_formally_smooth \u03c8) : is_formally_smooth (\u03c8.comp \u03c6) :=\nbegin\n  intros R R' _ _ _ _ f hf1 hf2 g,\n  resetI,\n  specialize h\u03c6 hf1 hf2,\n  letI : algebra A B := \u03c6.to_algebra,\n  letI : algebra A C := (\u03c8.comp \u03c6).to_algebra,\n  let \u03c8' : B \u2192\u2090[A] C := \n  { commutes' := \u03bb r, rfl, -- definitional abuse!\n    ..\u03c8 },\n  let \u03c1 := g.comp \u03c8',\n  unfold function.surjective at h\u03c6,\n  specialize h\u03c6 \u03c1,\n  cases h\u03c6 with \u03c3 h\u03c3,\n  -- last four lines can be done  with \n  --  obtain \u27e8\u03c3, h\u03c3\u27e9 := h\u03c6 (g.comp \u03c8'),\n  -- use \u03c3 to make R' into a B-algebra\n  letI : algebra B R' := \u03c3.to_ring_hom.to_algebra,\n  letI : algebra B R := \u03c1.to_ring_hom.to_algebra,\n  let f' : R' \u2192\u2090[B] R :=\n  { commutes' := begin \n-- alternate proof:\n--      rw alg_hom.ext_iff at h\u03c3,\n--      exact h\u03c3,\n      intro r,\n      change _ = \u03c1 r,\n      rw \u2190 h\u03c3,\n      refl,\n    end,\n    ..f.to_ring_hom, },\n  have hf1' : \u2200 (r : R), \u2203 (r' : R'), f' r' = r,\n  exact hf1,\n  have hf2' : \u2200 (x y : R'), f x = 0 \u2192 f y = 0 \u2192 x * y = 0,\n  exact hf2,\n  specialize h\u03c8 hf1' hf2',\n  letI : algebra B C := \u03c8.to_algebra,\n  let g' : C \u2192\u2090[B] R :=\n  { commutes' := begin \n    intro,\n    refl, end,\n    ..g },\n  obtain \u27e8\u03c4, h\u03c4\u27e9 := h\u03c8 g',\n  let \u03c4' : C \u2192\u2090[A] R' :=\n  { commutes' := begin intro r,\n      convert \u03c4.commutes (\u03c6 r),\n      suffices : algebra.of_id A R' = \u03c3.comp (algebra.of_id A B),\n      { rw alg_hom.ext_iff at this,\n        apply this, },\n      apply subsingleton.elim,\n    end,\n    ..\u03c4, },\n  use \u03c4',\n  ext,\n  change _ = g' x,\n  rw \u2190 h\u03c4,\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\u2081 v\u2082 u\u2081 u\u2082\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\u2081}{D : Type u\u2082}\n\nparameter [Category.{v\u2081} C][Category.{v\u2081} D]\n\nparameter {G : D \u2964 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, \u03b1)` is the pair of morphisms `(F \u03b1, \u03b5_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  \u00b7 rw [\u2190 F.map_comp, \u2190 F.map_id]\n    exact congr_arg (fun _ => F.map _) A.unit\n  \u00b7 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, \u03b1)` is the pair of morphisms `(F \u03b1, \u03b5_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 := \u27e8_, _, \u27e8beckSplitCoequalizer A\u27e9\u27e9\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 \u27f6 B) \u2243 (A \u27f6 (comparison adj).obj B) :=\n  calc\n    (comparison_left_adjoint_obj A \u27f6 B) \u2243 { f : F.obj A.A \u27f6 B // _ } :=\n      Cofork.IsColimit.homIso (colimit.isColimit _) B\n    _ \u2243 { g : A.A \u27f6 G.obj B // G.map (F.map g) \u226b G.map (adj.counit.app B) = A.a \u226b g } :=\n      by\n      refine' (adj.homEquiv _ _).subtypeEquiv _\n      intro f\n      rw [\u2190 (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, \u2190 G.map_comp, F.map_comp, category.assoc,\n        adj.counit_naturality, adj.left_triangle_components_assoc]\n      apply eq_comm\n    _ \u2243 (A \u27f6 (comparison adj).obj B) :=\n      { toFun := fun g =>\n          { f := _\n            h' := g.Prop }\n        invFun := fun f => \u27e8f.f, f.h\u27e9\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    [\u2200 A : adj.toMonad.Algebra, HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] :\n    adj.toMonad.Algebra \u2964 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  \u00b7 apply comparison_left_adjoint_hom_equiv\n  \u00b7 intro A B B' g h\n    ext1\n    dsimp [comparison_left_adjoint_hom_equiv]\n    rw [\u2190 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    [\u2200 A : adj.toMonad.Algebra, HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] :\n    left_adjoint_comparison \u22a3 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    [\u2200 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.\u03c0 (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\u03c0 (G.map (coequalizer.\u03c0 (F.map A.a) (adj.counit.app (F.obj A.A))))\n    (by\n      change _ = G.map _ \u226b _\n      rw [\u2190 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_\u03c0 (A : adj.toMonad.Algebra)\n    [HasCoequalizer (F.map A.a) (adj.counit.app (F.obj A.A))] :\n    (unit_cofork A).\u03c0 = G.map (coequalizer.\u03c0 (F.map A.a) (adj.counit.app (F.obj A.A))) :=\n  rfl\n#align category_theory.monad.monadicity_internal.unit_cofork_\u03c0 CategoryTheory.Monad.MonadicityInternal.unitCofork_\u03c0\n\ntheorem comparisonAdjunction_unit_f\n    [\u2200 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.\u03c0_desc]\n  dsimp only [beck_cofork_\u03c0, unit_cofork_\u03c0]\n  rw [comparison_adjunction_unit_f_aux, \u2190 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\u03c0 (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    [\u2200 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.\u03c0 _ _ \u226b coequalizer.desc ((adj.homEquiv _ B).symm (\ud835\udfd9 _)) _ =\n      coequalizer.\u03c0 _ _ \u226b 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\u2081} {D : Type u\u2082}\n\nvariable [Category.{v\u2081} C] [Category.{v\u2081} D]\n\nvariable (G : D \u2964 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] \u2983A B\u2984 (f g : A \u27f6 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  \u00b7 apply preserves_colimit_of_iso_diagram _ (diagramIsoParallelPair.{v\u2081} _).symm\n    dsimp\n    infer_instance\n  \u00b7 apply preserves_colimit_of_iso_diagram _ (diagramIsoParallelPair.{v\u2081} _).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    [\u2200 \u2983A B\u2984 (f g : A \u27f6 B) [G.IsSplitPair f g], HasCoequalizer f g]\n    [\u2200 \u2983A B\u2984 (f g : A \u27f6 B) [G.IsSplitPair f g], PreservesColimit (parallelPair f g) G]\n    [\u2200 \u2983A B\u2984 (f g : A \u27f6 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 \u2964 D := left_adjoint_comparison\n  letI i : is_right_adjoint (comparison (of_right_adjoint G)) := \u27e8_, comparison_adjunction\u27e9\n  constructor\n  let this :\n    \u2200 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    \u00b7 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 : \u2200 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    [\u2200 \u2983A B\u2984 (f g : A \u27f6 B) [G.IsSplitPair f g], CreatesColimit (parallelPair f g) G] :\n    MonadicRightAdjoint G :=\n  by\n  let this : \u2200 \u2983A B\u2984 (f g : A \u27f6 B) [G.is_split_pair f g], has_colimit (parallel_pair f g \u22d9 G) :=\n    by\n    intro A B f g i\n    apply has_colimit_of_iso (diagramIsoParallelPair.{v\u2081} _)\n    change has_coequalizer (G.map f) (G.map g)\n    infer_instance\n  apply monadic_of_has_preserves_reflects_G_split_coequalizers _\n  \u00b7 infer_instance\n  \u00b7 intro A B f g i\n    apply has_colimit_of_created (parallel_pair f g) G\n  \u00b7 intro A B f g i\n    infer_instance\n  \u00b7 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    [\u2200 \u2983A B\u2984 (f g : A \u27f6 B) [G.IsSplitPair f g], HasCoequalizer f g]\n    [\u2200 \u2983A B\u2984 (f g : A \u27f6 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  \u00b7 infer_instance\n  \u00b7 assumption\n  \u00b7 assumption\n  \u00b7 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 [\u2200 \u2983A B\u2984 (f g : A \u27f6 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 \u2964 D := left_adjoint_comparison\n  letI i : is_right_adjoint (comparison (adjunction.of_right_adjoint G)) :=\n    \u27e8_, comparison_adjunction\u27e9\n  constructor\n  let this :\n    \u2200 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    \u00b7 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    \u2200 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": "def f (x : Nat) : Nat :=\n  x + (set_option trace.Meta.synthInstance true in 1)\n\ndef g (x : Nat) : Nat := 0 + x.succ\n\ntheorem ex : f = g := by\n  simp only [f]\n  set_option trace.Meta.Tactic.simp true in simp only [Nat.add_succ, g]\n  simp only [Nat.zero_add]\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/setOptionTermTactic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031738152021788, "lm_q2_score": 0.5964331462646255, "lm_q1q2_score": 0.47903948559839843}}
{"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 \u2192 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 \u2192 duration_expr sp \u2192 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 \u2192 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 \u2192 time_expr sp \u2192 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 +\u1d65 v2))\n      },\n      {\n        exact (duration_expr.lit ((ev v2) +\u1d65 v1))\n      }\n    },\n    { \n      cases v2,\n      {\n        exact (duration_expr.lit ((ev v1) +\u1d65 v2))\n      },\n      {\n        exact (duration_expr.lit ((ev v1) +\u1d65 (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\u2022l)\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 -\u1d65 v2))\n      },\n      {\n        exact (duration_expr.lit (v1 -\u1d65 ev v2))\n      }\n    },\n    { \n      cases v2,\n      {\n        exact (duration_expr.lit ((ev v1) -\u1d65 v2))\n      },\n      {\n        exact (duration_expr.lit ((ev v1) -\u1d65 (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) := \u27e8 add_dur_expr_dur_expr K \u27e9\nlemma add_assoc_dur_expr : \u2200 a b c : duration_expr sp, a + b + c = a + (b + c) := sorry\ninstance add_semigroup_dur_expr : add_semigroup (duration_expr sp) := \u27e8 add_dur_expr_dur_expr K, add_assoc_dur_expr K\u27e9 \n\ndef dur_expr_zero  := duration_expr.lit (mk_duration sp 0)\ninstance has_zero_dur_expr : has_zero (duration_expr sp) := \u27e8dur_expr_zero K\u27e9\n\nlemma zero_add_dur_expr : \u2200 a : duration_expr sp, 0 + a = a := sorry\nlemma add_zero_dur_expr : \u2200 a : duration_expr sp, a + 0 = a := sorry\ninstance add_monoid_dur_expr : add_monoid (duration_expr sp) := \u27e8 \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\u27e9\n\ninstance has_neg_dur_expr : has_neg (duration_expr sp) := \u27e8neg_dur_expr K\u27e9\ninstance has_sub_dur_expr : has_sub (duration_expr sp) := \u27e8 sub_dur_expr_dur_expr K\u27e9 \nlemma sub_eq_add_neg_dur_expr : \u2200 a b : duration_expr sp, a - b = a + -b := sorry\ninstance sub_neg_monoid_dur_expr : sub_neg_monoid (duration_expr sp) := \u27e8 \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\u27e9 \n\nlemma add_left_neg_dur_expr : \u2200 a : duration_expr sp, -a + a = 0 := sorry\ninstance : add_group (duration_expr sp) := \u27e8\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\u27e9 \n\nlemma add_comm_dur_expr : \u2200 a b : duration_expr sp, a + b = b + a := sorry\ninstance add_comm_semigroup_dur_expr : add_comm_semigroup (duration_expr sp) := \u27e8\n    -- add_semigroup\n    add_dur_expr_dur_expr K, \n    add_assoc_dur_expr K,\n    add_comm_dur_expr K,\n\u27e9\n\ninstance add_comm_monoid_dur_expr : add_comm_monoid (duration_expr sp) := \u27e8\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\u27e9\n\ninstance has_scalar_dur_expr : has_scalar K (duration_expr sp) := \u27e8\nsmul_dur_expr K,\n\u27e9\n\nlemma one_smul_dur_expr : \u2200 b : duration_expr sp, (1 : K) \u2022 b = b := sorry\nlemma mul_smul_dur_expr : \u2200 (x y : K) (b : duration_expr sp), (x * y) \u2022 b = x \u2022 y \u2022 b := sorry\ninstance mul_action_dur_expr : mul_action K (duration_expr sp) := \u27e8\none_smul_dur_expr K,\nmul_smul_dur_expr K,\n\u27e9 \n\nlemma smul_add_dur_expr : \u2200(r : K) (x y : duration_expr sp), r \u2022 (x + y) = r \u2022 x + r \u2022 y := sorry\nlemma smul_zero_dur_expr : \u2200(r : K), r \u2022 (0 : duration_expr sp) = 0 := sorry\ninstance distrib_mul_action_K_dur_exprKx : distrib_mul_action K (duration_expr sp) := \u27e8\nsmul_add_dur_expr K,\nsmul_zero_dur_expr K,\n\u27e9 \n\n-- renaming vs template due to clash with name \"s\" for prevailing variable\nlemma add_smul_dur_expr : \u2200 (a b : K) (x : duration_expr sp), (a + b) \u2022 x = a \u2022 x + b \u2022 x := sorry\nlemma zero_smul_dur_expr : \u2200 (x : duration_expr sp), (0 : K) \u2022 x = 0 := sorry\ninstance semimodule_K_durationK : semimodule K (duration_expr sp) := \u27e8 add_smul_dur_expr K, zero_smul_dur_expr  K\u27e9 \n\ninstance add_comm_group_dur_expr : add_comm_group (duration_expr sp) := \u27e8\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\u27e9\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) := \u27e8add_dur_expr_dur_expr K\u27e9\ninstance : has_zero (duration_expr sp) := \u27e8dur_expr_zero K\u27e9\ninstance : has_neg (duration_expr sp) := \u27e8neg_dur_expr K\u27e9\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 \u2192 time_expr sp \u2192 time_expr sp := add_dur_expr_time_expr K\ninstance : has_vadd (duration_expr sp) (time_expr sp) := \u27e8aff_dur_expr_group_action K\u27e9\n\nlemma zero_dur_expr_vadd'_a1 : \u2200 p : time_expr sp, (0 : duration_expr sp) +\u1d65 p = p := sorry\nlemma dur_expr_add_assoc'_a1 : \u2200 (g1 g2 : duration_expr sp) (p : time_expr sp), g1 +\u1d65 (g2 +\u1d65 p) = (g1 + g2) +\u1d65 p := sorry\ninstance dur_expr_add_action: add_action (duration_expr sp) (time_expr sp) := \n\u27e8 aff_dur_expr_group_action K, zero_dur_expr_vadd'_a1 K, dur_expr_add_assoc'_a1  K\u27e9 \n\ndef aff_time_expr_group_sub : time_expr sp \u2192 time_expr sp \u2192 duration_expr sp := sub_time_expr_time_expr K\ninstance time_expr_has_vsub : has_vsub (duration_expr sp) (time_expr sp) := \u27e8 aff_time_expr_group_sub K \u27e9 \n\ninstance : nonempty (time_expr sp) := \u27e8time_expr.lit (mk_time sp  0)\u27e9\n\nlemma time_expr_vsub_vadd_a1 : \u2200 (p1 p2 : (time_expr sp)), (p1 -\u1d65 p2) +\u1d65 p2 = p1 := sorry\nlemma time_expr_vadd_vsub_a1 : \u2200 (g : duration_expr sp) (p : time_expr sp), g +\u1d65 p -\u1d65 p = g := sorry\ninstance aff_time_expr_torsor : add_torsor (duration_expr sp) (time_expr sp) := \n\u27e8 \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\u27e9\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 \u2192 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 \u2192 transform_expr sp1 sp2 \u2192 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\u2022  : K -> d s -> d s\n+\u1d65 : d s -> t s -> t s \n-\u1d65 : 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  \u27e8\n    (\u03bbv, \u27e8mk_vectr sp 1\u27e9),\n    (\u03bbv, \u27e8mk_point sp 0\u27e9),\n    (\u03bbv, sp.time_tr sp2)\n  \u27e9\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  \u27e8 \n    (\u03bbenv_,\u03bbexpr_, \u27e8mk_vectr sp 1\u27e9),\n    (\u03bbenv_,\u03bbexpr_, \u27e8mk_point sp 0\u27e9),\n    (\u03bbenv_,\u03bbexpr_, sp.time_tr sp2),\n  \u27e9\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 : \u2115\u221e} {E : euclidean_space.{u}}\n\n/- topological manifolds -/\nstructure chart (X : Top) (E : euclidean_space) :=\n  (iso : X \u2243\u209c. 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 \u2192. E := c.iso.to_fun\ndef inv_fun (c : chart X E) : E \u2192. 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\u27e8(phomeo.restrict_phomeo s).trans c.iso, omitted, omitted\u27e9\n\nend chart\n\ndef compatible_charts {X : Top} (k : \u2115\u221e) (c\u2081 c\u2082 : chart X E) : Prop :=\nis_smooth k (c\u2082.to_fun \u2218. c\u2081.inv_fun) \u2227 \nis_smooth k (c\u2081.to_fun \u2218. c\u2082.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 : \u22c3\u2080 (chart.domain '' charts) = univ)\n\nnamespace topological_manifold\ninstance : has_coe (topological_manifold E) Top :=\n\u27e8topological_manifold.carrier\u27e9\n\ndef restrict (X : topological_manifold E) {s : set X} (hs : is_open s) : \n  topological_manifold E :=\n\u27e8X.carrier.restrict s, omitted, omitted, chart.restrict hs '' X.charts, omitted\u27e9 \n\nend topological_manifold\n\nstructure differentiable_manifold (k : \u2115\u221e) (E : euclidean_space) extends topological_manifold E :=\n  (compatible : \u2200{{c\u2081 c\u2082}}, c\u2081 \u2208 charts \u2192 c\u2082 \u2208 charts \u2192 compatible_charts k c\u2081 c\u2082)\n\nnamespace euclidean_space\n\n  def to_differentiable_manifold (E : euclidean_space) (k : \u2115\u221e) : differentiable_manifold k E :=\n  \u27e8\u27e8E.to_Top, omitted, omitted, {\u27e8phomeo.rfl, is_open_univ, is_open_univ\u27e9}, omitted\u27e9, omitted\u27e9\n\nend euclidean_space\n\nnamespace differentiable_manifold\n\ninstance : has_coe (differentiable_manifold k E) Top :=\n\u27e8\u03bbX, X.to_topological_manifold.carrier\u27e9\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 | \u2200c' \u2208 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\u27e8X.to_topological_manifold.restrict hs, omitted\u27e9 \n\n\ndef sphere (n : \u2115) : differentiable_manifold \u22a4 (euclidean_space.standard_euclidean_space n) :=\nsorry --\u27e8\u27e8\u27e8subtype _, _\u27e9, _, _, _, _\u27e9, omitted\u27e9\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 \u2192 Y) (A : set (chart X.carrier E)) (B : set (chart Y.carrier E)) : Prop := \n\u2200(c \u2208 A) (c' \u2208 B), is_smooth k (chart.to_fun c' \u2218. pfun.lift f \u2218. chart.inv_fun c)\n\nstructure smooth_map (X Y : differentiable_manifold k E) :=\n  (map : X \u2192 Y)\n  (smooth : respects_charts map X.max_atlas Y.max_atlas)\n\ninfix ` \u2192\u209b `:25 := smooth_map\n\ndef incl (X : differentiable_manifold k E) {s : set X} (hs : is_open s) :\n  restrict X hs \u2192\u209b X :=\n\u27e8subtype.val, omitted\u27e9\n\nlemma respects_charts_local (f : X \u2192 Y) (A : set (chart X.carrier E)) (B : set (chart Y.carrier E))\n  (h : \u2200x : X, \u2203(s : set X) (hs : is_open s), x \u2208 s \u2227 \n    respects_charts (f \u2218 (incl X hs).map) (chart.restrict hs '' A) B) : respects_charts f A B :=\nomitted\n\nlemma respects_charts_subset (f : X \u2192 Y) (A A' : set (chart X.carrier E)) (B B' : set (chart Y.carrier E))\n  (hA : \u22c3\u2080 (chart.domain '' A') \u2286 \u22c3\u2080 (chart.domain '' A)) (hB : \u22c3\u2080 (chart.domain '' B') \u2286 \u22c3\u2080 (chart.domain '' B))\n  (h : respects_charts f A B) : respects_charts f A' B' :=\nomitted\n\nnamespace smooth_map\n\ndef id : X \u2192\u209b X := \u27e8id, omitted\u27e9\ndef comp (g : Y \u2192\u209b Z) (f : X \u2192\u209b Y) : X \u2192\u209b Z := \u27e8g.map \u2218 f.map, omitted\u27e9\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 {\u03b1} [comm_semiring \u03b1] (a x : \u03b1) (n : \u2115) (b : \u03b1) := a * x ^ n + b\n\nmeta structure cache :=\n(\u03b1 : expr)\n(univ : level)\n(comm_semiring_inst : expr)\n\nmeta def mk_cache (e : expr) : tactic cache :=\ndo \u03b1 \u2190 infer_type e,\n   c \u2190 mk_app ``comm_semiring [\u03b1] >>= mk_instance,\n   u \u2190 mk_meta_univ,\n   infer_type \u03b1 >>= unify (expr.sort (level.succ u)),\n   u \u2190 get_univ_assignment u,\n   return \u27e8\u03b1, u, c\u27e9\n\nmeta def cache.cs_app (c : cache) (n : name) : list expr \u2192 expr :=\n(@expr.const tt n [c.univ] c.\u03b1 c.comm_semiring_inst).mk_app\n\nmeta def cache.mk_app (c : cache) (n inst : name) (l : list expr) : tactic expr :=\ndo m \u2190 mk_instance ((expr.const inst [c.univ] : expr) c.\u03b1),\n   return $ (@expr.const tt n [c.univ] c.\u03b1 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 \u00d7 \u2115) (b : horner_expr) : horner_expr\n\nmeta def horner_expr.e : horner_expr \u2192 expr\n| (horner_expr.const e) := e\n| (horner_expr.xadd e _ _ _ _) := e\n\nmeta instance : has_coe horner_expr expr := \u27e8horner_expr.e\u27e9\n\nmeta def horner_expr.xadd' (c : cache) (a : horner_expr) (x : expr) (n : expr \u00d7 \u2115) (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 \u2192 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 \u2192 tactic format\n| (const e) := pp e\n| (xadd e a x (_, n) b) := do\n  pa \u2190 a.pp, pb \u2190 b.pp, px \u2190 pp x,\n  return $ \"(\" ++ pa ++ \") * (\" ++ px ++ \")^\" ++ to_string n ++ \" + \" ++ pb\n\nmeta instance : has_to_tactic_format horner_expr := \u27e8horner_expr.pp\u27e9\n\nmeta def horner_expr.refl_conv (e : horner_expr) : tactic (horner_expr \u00d7 expr) :=\ndo p \u2190 mk_eq_refl e, return (e, p)\n\ntheorem zero_horner {\u03b1} [comm_semiring \u03b1] (x n b) :\n  @horner \u03b1 _ 0 x n b = b :=\nby simp [horner]\n\ntheorem horner_horner {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 n\u2082 b n')\n  (h : n\u2081 + n\u2082 = n') :\n  @horner \u03b1 _ (horner a\u2081 x n\u2081 0) x n\u2082 b = horner a\u2081 x n' b :=\nby simp [h.symm, horner, pow_add, mul_assoc]\n\nmeta def eval_horner (c : cache) : horner_expr \u2192 expr \u2192 expr \u00d7 \u2115 \u2192 horner_expr \u2192 tactic (horner_expr \u00d7 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\u2081 x\u2081 n\u2081 b\u2081) x n b :=\n  if x\u2081 = x \u2227 b\u2081.e.to_nat = some 0 then do\n    (n', h) \u2190 mk_app ``has_add.add [n\u2081.1, n.1] >>= norm_num,\n    return (xadd' c a\u2081 x (n', n\u2081.2 + n.2) b,\n      c.cs_app ``horner_horner [a\u2081, x, n\u2081.1, n.1, b, n', h])\n  else (xadd' c ha x n b).refl_conv\n\ntheorem const_add_horner {\u03b1} [comm_semiring \u03b1] (k a x n b b') (h : k + b = b') :\n  k + @horner \u03b1 _ a x n b = horner a x n b' :=\nby simp [h.symm, horner]\n\ntheorem horner_add_const {\u03b1} [comm_semiring \u03b1] (a x n b k b') (h : b + k = b') :\n  @horner \u03b1 _ a x n b + k = horner a x n b' :=\nby simp [h.symm, horner]\n\ntheorem horner_add_horner_lt {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 k a' b')\n  (h\u2081 : n\u2081 + k = n\u2082) (h\u2082 : (a\u2081 + horner a\u2082 x k 0 : \u03b1) = a') (h\u2083 : b\u2081 + b\u2082 = b') :\n  @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2081 b' :=\nby simp [h\u2082.symm, h\u2083.symm, h\u2081.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]\n\ntheorem horner_add_horner_gt {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 k a' b')\n  (h\u2081 : n\u2082 + k = n\u2081) (h\u2082 : (horner a\u2081 x k 0 + a\u2082 : \u03b1) = a') (h\u2083 : b\u2081 + b\u2082 = b') :\n  @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2082 b' :=\nby simp [h\u2082.symm, h\u2083.symm, h\u2081.symm, horner, pow_add, mul_add, mul_comm, mul_left_comm]\n\ntheorem horner_add_horner_eq {\u03b1} [comm_semiring \u03b1] (a\u2081 x n b\u2081 a\u2082 b\u2082 a' b' t)\n  (h\u2081 : a\u2081 + a\u2082 = a') (h\u2082 : b\u2081 + b\u2082 = b') (h\u2083 : horner a' x n b' = t) :\n  @horner \u03b1 _ a\u2081 x n b\u2081 + horner a\u2082 x n b\u2082 = t :=\nby simp [h\u2083.symm, h\u2082.symm, h\u2081.symm, horner, add_mul, mul_comm]\n\nmeta def eval_add (c : cache) : horner_expr \u2192 horner_expr \u2192 tactic (horner_expr \u00d7 expr)\n| (const e\u2081) (const e\u2082) := do\n  (e, p) \u2190 mk_app ``has_add.add [e\u2081, e\u2082] >>= norm_num,\n  return (const e, p)\n| he\u2081@(const e\u2081) he\u2082@(xadd e\u2082 a x n b) :=\n  if e\u2081.to_nat = some 0 then  do\n    p \u2190 mk_app ``zero_add [e\u2082],\n    return (he\u2082, p)\n  else do\n    (b', h) \u2190 eval_add he\u2081 b,\n    return (xadd' c a x n b',\n      c.cs_app ``const_add_horner [e\u2081, a, x, n.1, b, b', h])\n| he\u2081@(xadd e\u2081 a x n b) he\u2082@(const e\u2082) :=\n  if e\u2082.to_nat = some 0 then do\n    p \u2190 mk_app ``add_zero [e\u2081],\n    return (he\u2081, p)\n  else do\n    (b', h) \u2190 eval_add b he\u2082,\n    return (xadd' c a x n b',\n      c.cs_app ``horner_add_const [a, x, n.1, b, e\u2082, b', h])\n| he\u2081@(xadd e\u2081 a\u2081 x\u2081 n\u2081 b\u2081) he\u2082@(xadd e\u2082 a\u2082 x\u2082 n\u2082 b\u2082) :=\n  if expr.lex_lt x\u2081 x\u2082 then do\n    (b', h) \u2190 eval_add b\u2081 he\u2082,\n    return (xadd' c a\u2081 x\u2081 n\u2081 b',\n      c.cs_app ``horner_add_const [a\u2081, x\u2081, n\u2081.1, b\u2081, e\u2082, b', h])\n  else if x\u2081 \u2260 x\u2082 then do\n    (b', h) \u2190 eval_add he\u2081 b\u2082,\n    return (xadd' c a\u2082 x\u2082 n\u2082 b',\n      c.cs_app ``const_add_horner [e\u2081, a\u2082, x\u2082, n\u2082.1, b\u2082, b', h])\n  else if n\u2081.2 < n\u2082.2 then do\n    let k := n\u2082.2 - n\u2081.2,\n    ek \u2190 expr.of_nat (expr.const `nat []) k,\n    (_, h\u2081) \u2190 mk_app ``has_add.add [n\u2081.1, ek] >>= norm_num,\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    (a', h\u2082) \u2190 eval_add a\u2081 (xadd' c a\u2082 x\u2081 (ek, k) (const \u03b10)),\n    (b', h\u2083) \u2190 eval_add b\u2081 b\u2082,\n    return (xadd' c a' x\u2081 n\u2081 b',\n      c.cs_app ``horner_add_horner_lt [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, ek, a', b', h\u2081, h\u2082, h\u2083])\n  else if n\u2081 \u2260 n\u2082 then do\n    let k := n\u2081.2 - n\u2082.2,\n    ek \u2190 expr.of_nat (expr.const `nat []) k,\n    (_, h\u2081) \u2190 mk_app ``has_add.add [n\u2082.1, ek] >>= norm_num,\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    (a', h\u2082) \u2190 eval_add (xadd' c a\u2081 x\u2081 (ek, k) (const \u03b10)) a\u2082,\n    (b', h\u2083) \u2190 eval_add b\u2081 b\u2082,\n    return (xadd' c a' x\u2081 n\u2082 b',\n      c.cs_app ``horner_add_horner_gt [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, ek, a', b', h\u2081, h\u2082, h\u2083])\n  else do\n    (a', h\u2081) \u2190 eval_add a\u2081 a\u2082,\n    (b', h\u2082) \u2190 eval_add b\u2081 b\u2082,\n    (t, h\u2083) \u2190 eval_horner c a' x\u2081 n\u2081 b',\n    return (t, c.cs_app ``horner_add_horner_eq\n      [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, b\u2082, a', b', t, h\u2081, h\u2082, h\u2083])\n\ntheorem horner_neg {\u03b1} [comm_ring \u03b1] (a x n b a' b')\n  (h\u2081 : -a = a') (h\u2082 : -b = b') :\n  -@horner \u03b1 _ a x n b = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.symm, horner]\n\nmeta def eval_neg (c : cache) : horner_expr \u2192 tactic (horner_expr \u00d7 expr)\n| (const e) := do\n  (e', p) \u2190 mk_app ``has_neg.neg [e] >>= norm_num,\n  return (const e', p)\n| (xadd e a x n b) := do\n  (a', h\u2081) \u2190 eval_neg a,\n  (b', h\u2082) \u2190 eval_neg b,\n  p \u2190 c.mk_app ``horner_neg ``comm_ring [a, x, n.1, b, a', b', h\u2081, h\u2082],\n  return (xadd' c a' x n b', p)\n\ntheorem horner_const_mul {\u03b1} [comm_semiring \u03b1] (c a x n b a' b')\n  (h\u2081 : c * a = a') (h\u2082 : c * b = b') :\n  c * @horner \u03b1 _ a x n b = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.symm, horner, mul_add, mul_assoc]\n\ntheorem horner_mul_const {\u03b1} [comm_semiring \u03b1] (a x n b c a' b')\n  (h\u2081 : a * c = a') (h\u2082 : b * c = b') :\n  @horner \u03b1 _ a x n b * c = horner a' x n b' :=\nby simp [h\u2082.symm, h\u2081.symm, horner, add_mul, mul_right_comm]\n\nmeta def eval_const_mul (c : cache) (k : expr) :\n  horner_expr \u2192 tactic (horner_expr \u00d7 expr)\n| (const e) := do\n  (e', p) \u2190 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\u2081) \u2190 eval_const_mul a,\n  (b', h\u2082) \u2190 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\u2081, h\u2082])\n\ntheorem horner_mul_horner_zero {\u03b1} [comm_semiring \u03b1] (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 aa t)\n  (h\u2081 : @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 * a\u2082 = aa)\n  (h\u2082 : horner aa x n\u2082 0 = t) :\n  horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 0 = t :=\nby rw [\u2190 h\u2082, \u2190 h\u2081];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\ntheorem horner_mul_horner {\u03b1} [comm_semiring \u03b1]\n  (a\u2081 x n\u2081 b\u2081 a\u2082 n\u2082 b\u2082 aa haa ab bb t)\n  (h\u2081 : @horner \u03b1 _ a\u2081 x n\u2081 b\u2081 * a\u2082 = aa)\n  (h\u2082 : horner aa x n\u2082 0 = haa)\n  (h\u2083 : a\u2081 * b\u2082 = ab) (h\u2084 : b\u2081 * b\u2082 = bb)\n  (H : haa + horner ab x n\u2081 bb = t) :\n  horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 b\u2082 = t :=\nby rw [\u2190 H, \u2190 h\u2082, \u2190 h\u2081, \u2190 h\u2083, \u2190 h\u2084];\n   simp [horner, mul_add, mul_comm, mul_left_comm, mul_assoc]\n\nmeta def eval_mul (c : cache) : horner_expr \u2192 horner_expr \u2192 tactic (horner_expr \u00d7 expr)\n| (const e\u2081) (const e\u2082) := do\n  (e', p) \u2190 mk_app ``has_mul.mul [e\u2081, e\u2082] >>= norm_num,\n  return (const e', p)\n| (const e\u2081) e\u2082 :=\n  match e\u2081.to_nat with\n  | (some 0) := do\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    p \u2190 mk_app ``zero_mul [e\u2082],\n    return (const \u03b10, p)\n  | (some 1) := do\n    p \u2190 mk_app ``one_mul [e\u2082],\n    return (e\u2082, p)\n  | _ := eval_const_mul c e\u2081 e\u2082\n  end\n| e\u2081 he\u2082@(const e\u2082) := do\n  p\u2081 \u2190 mk_app ``mul_comm [e\u2081, e\u2082],\n  (e', p\u2082) \u2190 eval_mul he\u2082 e\u2081,\n  p \u2190 mk_eq_trans p\u2081 p\u2082, return (e', p)\n| he\u2081@(xadd e\u2081 a\u2081 x\u2081 n\u2081 b\u2081) he\u2082@(xadd e\u2082 a\u2082 x\u2082 n\u2082 b\u2082) :=\n  if expr.lex_lt x\u2081 x\u2082 then do\n    (a', h\u2081) \u2190 eval_mul a\u2081 he\u2082,\n    (b', h\u2082) \u2190 eval_mul b\u2081 he\u2082,\n    return (xadd' c a' x\u2081 n\u2081 b',\n      c.cs_app ``horner_mul_const [a\u2081, x\u2081, n\u2081.1, b\u2081, e\u2082, a', b', h\u2081, h\u2082])\n  else if x\u2081 \u2260 x\u2082 then do\n    (a', h\u2081) \u2190 eval_mul he\u2081 a\u2082,\n    (b', h\u2082) \u2190 eval_mul he\u2081 b\u2082,\n    return (xadd' c a' x\u2082 n\u2082 b',\n      c.cs_app ``horner_const_mul [e\u2081, a\u2082, x\u2082, n\u2082.1, b\u2082, a', b', h\u2081, h\u2082])\n  else do\n    (aa, h\u2081) \u2190 eval_mul he\u2081 a\u2082,\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    (haa, h\u2082) \u2190 eval_horner c aa x\u2081 n\u2082 (const \u03b10),\n    if b\u2082.e.to_nat = some 0 then\n      return (haa, c.cs_app ``horner_mul_horner_zero\n        [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, n\u2082.1, aa, haa, h\u2081, h\u2082])\n    else do\n      (ab, h\u2083) \u2190 eval_mul a\u2081 b\u2082,\n      (bb, h\u2084) \u2190 eval_mul b\u2081 b\u2082,\n      (t, H) \u2190 eval_add c haa (xadd' c ab x\u2081 n\u2081 bb),\n      return (t, c.cs_app ``horner_mul_horner\n        [a\u2081, x\u2081, n\u2081.1, b\u2081, a\u2082, n\u2082.1, b\u2082, aa, haa, ab, bb, t, h\u2081, h\u2082, h\u2083, h\u2084, H])\n\ntheorem horner_pow {\u03b1} [comm_semiring \u03b1] (a x n m n' a')\n  (h\u2081 : n * m = n') (h\u2082 : a ^ m = a') :\n  @horner \u03b1 _ a x n 0 ^ m = horner a' x n' 0 :=\nby simp [h\u2081.symm, h\u2082.symm, horner, mul_pow, pow_mul]\n\nmeta def eval_pow (c : cache) : horner_expr \u2192 expr \u00d7 \u2115 \u2192 tactic (horner_expr \u00d7 expr)\n| e (_, 0) := do\n  \u03b11 \u2190 expr.of_nat c.\u03b1 1,\n  p \u2190 mk_app ``pow_zero [e],\n  return (const \u03b11, p)\n| e (_, 1) := do\n  p \u2190 mk_app ``pow_one [e],\n  return (e, p)\n| (const e) (e\u2082, m) := do\n  (e', p) \u2190 mk_app ``monoid.pow [e, e\u2082] >>= 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\u2081) \u2190 mk_app ``has_mul.mul [n.1, m.1] >>= norm_num,\n    (a', h\u2082) \u2190 eval_pow a m,\n    \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n    return (xadd' c a' x (n', n.2 * m.2) (const \u03b10),\n      c.cs_app ``horner_pow [a, x, n.1, m.1, n', a', h\u2081, h\u2082])\n  | _ := do\n    e\u2082 \u2190 expr.of_nat N (m.2-1),\n    l \u2190 mk_app ``monoid.pow [e, e\u2082],\n    (tl, hl) \u2190 eval_pow he (e\u2082, m.2-1),\n    (t, p\u2082) \u2190 eval_mul c tl he,\n    hr \u2190 mk_eq_refl e,\n    p\u2082 \u2190 c.mk_app ``norm_num.subst_into_prod ``has_mul [l, e, tl, e, t, hl, hr, p\u2082],\n    p\u2081 \u2190 mk_app ``pow_succ' [e, e\u2082],\n    p \u2190 mk_eq_trans p\u2081 p\u2082,\n    return (t, p)\n  end\n\ntheorem horner_atom {\u03b1} [comm_semiring \u03b1] (x : \u03b1) : x = horner 1 x 1 0 :=\nby simp [horner]\n\nmeta def eval_atom (c : cache) (e : expr) : tactic (horner_expr \u00d7 expr) :=\ndo \u03b10 \u2190 expr.of_nat c.\u03b1 0,\n   \u03b11 \u2190 expr.of_nat c.\u03b1 1,\n   n1 \u2190 expr.of_nat (expr.const `nat []) 1,\n   return (xadd' c (const \u03b11) e (n1, 1) (const \u03b10), c.cs_app ``horner_atom [e])\n\nlemma subst_into_pow {\u03b1} [monoid \u03b1] (l r tl tr t)\n  (prl : (l : \u03b1) = tl) (prr : (r : \u2115) = tr) (prt : tl ^ tr = t) : l ^ r = t :=\nby simp [prl, prr, prt]\n\nlemma unfold_sub {\u03b1} [add_group \u03b1] (a b c : \u03b1)\n  (h : a + -b = c) : a - b = c := h\n\nlemma unfold_div {\u03b1} [division_ring \u03b1] (a b c : \u03b1)\n  (h : a * b\u207b\u00b9 = c) : a / b = c := h\n\nmeta def eval (c : cache) : expr \u2192 tactic (horner_expr \u00d7 expr)\n| `(%%e\u2081 + %%e\u2082) := do\n  (e\u2081', p\u2081) \u2190 eval e\u2081,\n  (e\u2082', p\u2082) \u2190 eval e\u2082,\n  (e', p') \u2190 eval_add c e\u2081' e\u2082',\n  p \u2190 c.mk_app ``norm_num.subst_into_sum ``has_add [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n  return (e', p)\n| `(%%e\u2081 - %%e\u2082) := do\n  e\u2082' \u2190 mk_app ``has_neg.neg [e\u2082],\n  e \u2190 mk_app ``has_add.add [e\u2081, e\u2082'],\n  (e', p) \u2190 eval e,\n  p' \u2190 c.mk_app ``unfold_sub ``add_group [e\u2081, e\u2082, e', p],\n  return (e', p')\n| `(- %%e) := do\n  (e\u2081, p\u2081) \u2190 eval e,\n  (e\u2082, p\u2082) \u2190 eval_neg c e\u2081,\n  p \u2190 c.mk_app ``norm_num.subst_into_neg ``has_neg [e, e\u2081, e\u2082, p\u2081, p\u2082],\n  return (e\u2082, p)\n| `(%%e\u2081 * %%e\u2082) := do\n  (e\u2081', p\u2081) \u2190 eval e\u2081,\n  (e\u2082', p\u2082) \u2190 eval e\u2082,\n  (e', p') \u2190 eval_mul c e\u2081' e\u2082',\n  p \u2190 c.mk_app ``norm_num.subst_into_prod ``has_mul [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n  return (e', p)\n| e@`(has_inv.inv %%_) := (do\n    (e', p) \u2190 norm_num.derive e,\n    e'.to_rat,\n    return (const e', p)) <|> eval_atom c e\n| `(%%e\u2081 / %%e\u2082) := do\n  e\u2082' \u2190 mk_app ``has_inv.inv [e\u2082],\n  e \u2190 mk_app ``has_mul.mul [e\u2081, e\u2082'],\n  (e', p) \u2190 eval e,\n  p' \u2190 c.mk_app ``unfold_div ``division_ring [e\u2081, e\u2082, e', p],\n  return (e', p')\n| e@`(@has_pow.pow _ _ %%P %%e\u2081 %%e\u2082) := do\n  (e\u2082', p\u2082) \u2190 eval e\u2082,\n  match e\u2082'.e.to_nat, P with\n  | some k, `(monoid.has_pow) := do\n    (e\u2081', p\u2081) \u2190 eval e\u2081,\n    (e', p') \u2190 eval_pow c e\u2081' (e\u2082, k),\n    p \u2190 c.mk_app ``subst_into_pow ``monoid [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n    return (e', p)\n  | some k, `(nat.has_pow) := do\n    (e\u2081', p\u2081) \u2190 eval e\u2081,\n    (e', p') \u2190 eval_pow c e\u2081' (e\u2082, k),\n    p\u2083 \u2190 c.mk_app ``subst_into_pow ``monoid [e\u2081, e\u2082, e\u2081', e\u2082', e', p\u2081, p\u2082, p'],\n    p\u2084 \u2190 mk_app ``nat.pow_eq_pow [e\u2081, e\u2082] >>= mk_eq_symm,\n    p \u2190 mk_eq_trans p\u2084 p\u2083,\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 \u00d7 expr) :=\ndo (e', p) \u2190 eval c e, return (e', p)\n\ntheorem horner_def' {\u03b1} [comm_semiring \u03b1] (a x n b) : @horner \u03b1 _ a x n b = x ^ n * a + b :=\nby simp [horner, mul_comm]\n\ntheorem mul_assoc_rev {\u03b1} [semigroup \u03b1] (a b c : \u03b1) : a * (b * c) = a * b * c :=\nby simp [mul_assoc]\n\ntheorem pow_add_rev {\u03b1} [monoid \u03b1] (a b : \u03b1) (m n : \u2115) : a ^ m * a ^ n = a ^ (m + n) :=\nby simp [pow_add]\n\ntheorem pow_add_rev_right {\u03b1} [monoid \u03b1] (a b : \u03b1) (m n : \u2115) : b * a ^ m * a ^ n = b * a ^ (m + n) :=\nby simp [pow_add, mul_assoc]\n\ntheorem add_neg_eq_sub {\u03b1} [add_group \u03b1] (a b : \u03b1) : 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 \u00d7 expr) := do\npow_lemma \u2190 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 \u2190 lemmas.mfoldl simp_lemmas.add_simp simp_lemmas.mk,\n(_, e', pr) \u2190 ext_simplify_core () {}\n  simp_lemmas.mk (\u03bb _, failed) (\u03bb _ _ _ _ e, do\n    c \u2190 mk_cache e,\n    (new_e, pr) \u2190 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' (\u03bb e, norm_num e <|> pow_lemma.rewrite e)\n    end e,\n    guard (\u00ac new_e =\u2090 e),\n    return ((), new_e, some pr, ff))\n   (\u03bb _ _ _ _ _, 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\u2081 = %%e\u2082) \u2190 target,\n  c \u2190 mk_cache e\u2081,\n  (e\u2081', p\u2081) \u2190 eval c e\u2081,\n  (e\u2082', p\u2082) \u2190 eval c e\u2082,\n  is_def_eq e\u2081' e\u2082',\n  p \u2190 mk_eq_symm p\u2082 >>= mk_eq_trans p\u2081,\n  tactic.exact p\n\nmeta def ring.mode : lean.parser ring.normalize_mode :=\nwith_desc \"(SOP|raw|horner)?\" $\ndo mode \u2190 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 \u2190 loc.get_locals,\n   tt \u2190 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 \u2192 q) \u2192 (q \u2192 r) \u2192 p \u2192 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 \u2192+* S) {s : set S} (hs : is_subring s) : is_subring (f \u207b\u00b9' 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 \u2192+* 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 \u2192+* 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\u2081 S\u2082 : set R} (hS\u2081 : is_subring S\u2081) (hS\u2082 : is_subring S\u2082) :\n  is_subring (S\u2081 \u2229 S\u2082) :=\n{ ..is_add_subgroup.inter hS\u2081.to_is_add_subgroup hS\u2082.to_is_add_subgroup,\n  ..is_submonoid.inter hS\u2081.to_is_submonoid hS\u2082.to_is_submonoid }\n\nlemma is_subring.Inter {\u03b9 : Sort*} {S : \u03b9 \u2192 set R} (h : \u2200 y : \u03b9, is_subring (S y)) :\n  is_subring (set.Inter S) :=\n{ ..is_add_subgroup.Inter (\u03bb i, (h i).to_is_add_subgroup),\n  ..is_submonoid.Inter (\u03bb i, (h i).to_is_submonoid) }\n\nlemma is_subring_Union_of_directed {\u03b9 : Type*} [h\u03b9 : nonempty \u03b9]\n  {s : \u03b9 \u2192 set R} (h : \u2200 i, is_subring (s i))\n  (directed : \u2200 i j, \u2203 k, s i \u2286 s k \u2227 s j \u2286 s k) :\n  is_subring (\u22c3i, s i) :=\n{ to_is_add_subgroup := is_add_subgroup_Union_of_directed\n    (\u03bb i, (h i).to_is_add_subgroup) directed,\n  to_is_submonoid := is_submonoid_Union_of_directed (\u03bb 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 \u2208 closure s) :\n  (\u2203 L : list (list R), (\u2200 l \u2208 L, \u2200 x \u2208 l, x \u2208 s \u2228 x = (-1:R)) \u2227 (L.map list.prod).sum = a) :=\nadd_group.in_closure.rec_on h\n  (\u03bb x hx, match x, monoid.exists_list_of_mem_closure hx with\n    | _, \u27e8L, h1, rfl\u27e9 := \u27e8[L], list.forall_mem_singleton.2 (\u03bb r hr, or.inl (h1 r hr)), zero_add _\u27e9\n    end)\n  \u27e8[], list.forall_mem_nil _, rfl\u27e9\n  (\u03bb b _ ih, match b, ih with\n    | _, \u27e8L1, h1, rfl\u27e9 := \u27e8L1.map (list.cons (-1)),\n      \u03bb L2 h2, match L2, list.mem_map.1 h2 with\n        | _, \u27e8L3, h3, rfl\u27e9 := list.forall_mem_cons.2 \u27e8or.inr rfl, h1 L3 h3\u27e9\n        end,\n      by simp only [list.map_map, (\u2218), list.prod_cons, neg_one_mul];\n      exact list.rec_on L1 neg_zero.symm (\u03bb hd tl ih,\n        by rw [list.map_cons, list.sum_cons, ih, list.map_cons, list.sum_cons, neg_add])\u27e9\n    end)\n  (\u03bb r1 r2 hr1 hr2 ih1 ih2, match r1, r2, ih1, ih2 with\n    | _, _, \u27e8L1, h1, rfl\u27e9, \u27e8L2, h2, rfl\u27e9 := \u27e8L1 ++ L2, list.forall_mem_append.2 \u27e8h1, h2\u27e9,\n      by rw [list.map_append, list.sum_append]\u27e9\n    end)\n\n@[elab_as_eliminator]\nprotected theorem in_closure.rec_on {C : R \u2192 Prop} {x : R} (hx : x \u2208 closure s)\n  (h1 : C 1) (hneg1 : C (-1)) (hs : \u2200 z \u2208 s, \u2200 n, C n \u2192 C (z * n))\n  (ha : \u2200 {x y}, C x \u2192 C y \u2192 C (x + y)) : C x :=\nbegin\n  have h0 : C 0 := add_neg_self (1:R) \u25b8 ha h1 hneg1,\n  rcases exists_list_of_mem_closure hx with \u27e8L, HL, rfl\u27e9, 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 : \u2203 L : list R,\n    (\u2200 x \u2208 L, x \u2208 s) \u2227 (list.prod hd = list.prod L \u2228 list.prod hd = -list.prod L),\n  { rcases this with \u27e8L, HL', HP | HP\u27e9,\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 \u27e8[], list.forall_mem_nil _, or.inl rfl\u27e9 },\n  rw list.forall_mem_cons at HL,\n  rcases ih HL.2 with \u27e8L, HL', HP | HP\u27e9; cases HL.1 with hhd hhd,\n  { exact \u27e8hd :: L, list.forall_mem_cons.2 \u27e8hhd, HL'\u27e9, or.inl $\n      by rw [list.prod_cons, list.prod_cons, HP]\u27e9 },\n  { exact \u27e8L, HL', or.inr $ by rw [list.prod_cons, hhd, neg_one_mul, HP]\u27e9 },\n  { exact \u27e8hd :: L, list.forall_mem_cons.2 \u27e8hhd, HL'\u27e9, or.inr $\n      by rw [list.prod_cons, list.prod_cons, HP, neg_mul_eq_mul_neg]\u27e9 },\n  { exact \u27e8L, HL', or.inl $ by rw [list.prod_cons, hhd, HP, neg_one_mul, neg_neg]\u27e9 }\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 := \u03bb a b ha hb, add_group.in_closure.rec_on hb\n    ( \u03bb c hc, add_group.in_closure.rec_on ha\n      ( \u03bb d hd, add_group.subset_closure ((monoid.closure.is_submonoid _).mul_mem hd hc))\n      ( (zero_mul c).symm \u25b8 (add_group.closure.is_add_subgroup _).zero_mem)\n      ( \u03bb d hd hdc, neg_mul_eq_neg_mul d c \u25b8 (add_group.closure.is_add_subgroup _).neg_mem hdc)\n      ( \u03bb d e hd he hdc hec, (add_mul d e c).symm \u25b8\n        ((add_group.closure.is_add_subgroup _).add_mem hdc hec)))\n    ( (mul_zero a).symm \u25b8 (add_group.closure.is_add_subgroup _).zero_mem)\n    ( \u03bb c hc hac, neg_mul_eq_mul_neg a c \u25b8 (add_group.closure.is_add_subgroup _).neg_mem hac)\n    ( \u03bb c d hc hd hac had, (mul_add a c d).symm \u25b8\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 \u2208 s \u2192 a \u2208 closure s :=\nadd_group.mem_closure \u2218 @monoid.subset_closure _ _ _ _\n\ntheorem subset_closure : s \u2286 closure s :=\n\u03bb _, mem_closure\n\ntheorem closure_subset {t : set R} (ht : is_subring t) : s \u2286 t \u2192 closure s \u2286 t :=\n(add_group.closure_subset ht.to_is_add_subgroup) \u2218 (monoid.closure_subset ht.to_is_submonoid)\n\ntheorem closure_subset_iff {s t : set R} (ht : is_subring t) : closure s \u2286 t \u2194 s \u2286 t :=\n(add_group.closure_subset_iff ht.to_is_add_subgroup).trans\n  \u27e8set.subset.trans monoid.subset_closure, monoid.closure_subset ht.to_is_submonoid\u27e9\n\ntheorem closure_mono {s t : set R} (H : s \u2286 t) : closure s \u2286 closure t :=\nclosure_subset closure.is_subring $ set.subset.trans H subset_closure\n\nlemma image_closure {S : Type*} [ring S] (f : R \u2192+* S) (s : set R) :\n  f '' closure s = closure (f '' s) :=\nle_antisymm\n  begin\n    rintros _ \u27e8x, hx, rfl\u27e9,\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 tactic --hide\n\n-- Level name : Boss fight \n\n/-Lemma\nTime for another boss fight!\n-/\nlemma boss_lemma_1 (P Q R : Prop) :\n  (((P \u2192 Q \u2192 Q) \u2192 ((P \u2192 Q) \u2192 Q)) \u2192 R) \u2192\n  ((((P \u2192 P) \u2192 Q) \u2192 (P \u2192 P \u2192 Q)) \u2192 R) \u2192\n  (((P \u2192 P \u2192 Q) \u2192 ((P \u2192 P) \u2192 Q)) \u2192 R) \u2192 R :=\nbegin\n  intros h1 h2 h3,\n  apply h2,\n  intros h1 hP h2,\n  apply h1,\n  intro hP,\n  exact h2,\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/logic13.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.851952809486198, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.47894784935677576}}
{"text": "import group_theory.perm.basic\n\nvariables {\u03b1 \u03b2 \u03b3 : Type*}\n\nnamespace equiv\n\n@[simp] lemma symm_trans (f : \u03b1 \u2243 \u03b2) (g : \u03b2 \u2243 \u03b3) : (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\u2081 v\u2082 u\u2081 u\u2082\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} D]\n\ntheorem hasInitial_of_equivalence (e : D \u2964 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 \u224c D) : HasInitial C \u2194 HasInitial D :=\n  \u27e8fun (_ : HasInitial C) => hasInitial_of_equivalence e.inverse,\n    fun (_ : HasInitial D) => hasInitial_of_equivalence e.functor\u27e9\n#align category_theory.equivalence.has_initial_iff CategoryTheory.Equivalence.hasInitial_iff\n\ntheorem hasTerminal_of_equivalence (e : D \u2964 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 \u224c D) : HasTerminal C \u2194 HasTerminal D :=\n  \u27e8fun (_ : HasTerminal C) => hasTerminal_of_equivalence e.inverse,\n    fun (_ : HasTerminal D) => hasTerminal_of_equivalence e.functor\u27e9\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 \u2192 Y) : Prop\nopaque \u211d : Type\n\n-- Vec Type\nclass Vec (X : Type) extends OfNat X 0, Add X, Sub X, Neg X, HMul \u211d X X where impl : vec_impl X\ninstance : Vec \u211d := sorry\ninstance {X Y} [Vec X] [Vec Y] : Vec (X\u00d7Y) := sorry\ninstance {\u03b1 : Type} [Vec X] : Vec (\u03b1\u2192X) := 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 \u2192 Y) : Prop where impl : smooth_impl f\nclass IsSmooth2 {X Y Z : Type} [Vec X] [Vec Y] [Vec Z] (f : X \u2192 Y \u2192 Z) extends IsSmooth \u03bb (x,y) => f x y\n\n\n-- Differential\nopaque differential (f : X \u2192 Y) : X \u2192 X \u2192 Y := sorry\n\nprefix:max \" \u2202 \" => differential\n\n\n-- SmoothMap\nstructure SmoothMap (X Y) [Vec X] [Vec Y] where\n  val : X \u2192 Y\n  [property : IsSmooth val]\n\ninfix:25 \" \u27ff \" => SmoothMap\n\ninstance {X Y} [Vec X] [Vec Y] : Vec (X \u27ff Y) := sorry\ninstance {X Y} [Vec X] [Vec Y] : CoeFun (X \u27ff Y) (\u03bb _ => X \u2192 Y) := \u27e8\u03bb f => f.val\u27e9\n\ninstance SmoothMap.val.arg_fx.isSmooth {X Y} [Vec X] [Vec Y]\n  : IsSmooth2 (\u03bb (f : X\u27ffY) (x : X) => f x) := sorry\n\n\n-- Lambda notation\nopen Lean.TSyntax.Compat in\nmacro \"\u03bb\"   xs:Lean.explicitBinders \" \u27ff \" 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'] {\u03b1 : Type}\n\n--------------------------------------------------------------------------------\n-- IsSmooth rules\n--------------------------------------------------------------------------------\n\n-- Core I,K,S,C,C' rules for IsSmooth\ninstance IsSmooth_rule_I : IsSmooth (\u03bb x : X => x) := sorry\ninstance IsSmooth_rule_K (x : X) : IsSmooth (\u03bb y : Y => x) := sorry\ninstance IsSmooth_rule_S (f : X \u2192 Y \u2192 Z) (g : X \u2192 Y) [IsSmooth2 f] [IsSmooth g]\n  : IsSmooth (\u03bb x => f x (g x)) := sorry\n\ninstance IsSmooth_rule_C  (f : \u03b1 \u2192 X \u2192 Y) [\u2200 a, IsSmooth (f a)]\n  : IsSmooth \u03bb x a => f a x := sorry\ninstance IsSmooth_rule_C' (f : X \u2192 \u03b1 \u2192 Y) [IsSmooth f] (a : \u03b1)\n  : IsSmooth \u03bb x => f x a := sorry\n\n-- Curry and uncurry for IsSmooth\ninstance IsSmooth_curry (f : X \u2192 Y \u2192 Z)\n  [\u2200 x, IsSmooth (f x)] [IsSmooth \u03bb x => \u03bb y \u27ff f x y]\n  : IsSmooth2 f := IsSmooth2.mk (toIsSmooth := sorry)\n\ninstance IsSmooth_uncurry_y (f : X \u2192 Y \u2192 Z) [IsSmooth2 f] (x : X)\n  : IsSmooth (\u03bb y => f x y) := sorry\ninstance IsSmooth_uncurry_x (f : X \u2192 Y \u2192 Z) [IsSmooth2 f]\n  : IsSmooth (\u03bb x => \u03bb y \u27ff 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 \u2192 Y \u2192 Z) [IsSmooth2 f]\n  (g : W \u2192 X) [IsSmooth g]\n  : IsSmooth (\u03bb w => \u03bb y \u27ff f (g w) y) := sorry\ninstance IsSmooth_uncurry_x_const (f : X \u2192 Z) [IsSmooth f] \n  : IsSmooth (\u03bb (x : X) => \u03bb (y : Y) \u27ff f x) := sorry\n\n--------------------------------------------------------------------------------\n-- Differential rules\n--------------------------------------------------------------------------------\n\n@[simp]\ntheorem differential_rule_I\n  : \u2202 (\u03bb x : X => x)\n    =\n    \u03bb x dx => dx := sorry\n\n@[simp]\ntheorem differential_rule_K (x : X)\n  : \u2202 (\u03bb y : Y => x)\n    =\n    \u03bb y Y => 0 := sorry\n\n@[simp]\ntheorem differential_rule_S\n  (f : X \u2192 Y \u2192 Z) (g : X \u2192 Y) [IsSmooth2 f] [IsSmooth g]\n  : \u2202 (\u03bb x => f x (g x))\n    =\n    \u03bb x dx =>\n      \u2202 f x dx (g x)\n      +\n      \u2202 (f x) (g x) (\u2202 g x dx) := sorry\n\n@[simp]\ntheorem differential_rule_C (f : \u03b1 \u2192 X \u2192 Y) [\u2200 a, IsSmooth (f a)]\n  : \u2202 (\u03bb x a => f a x)\n    =\n    \u03bb x dx a => \u2202 (f a) x dx := sorry\n\n@[simp]\ntheorem differential_rule_C' (f : X \u2192 \u03b1 \u2192 Y) [IsSmooth f] (a : \u03b1)\n  : \u2202 (\u03bb x => f x a)\n    =\n    \u03bb x dx => \u2202 f x dx a := sorry\n\n\n\n-- Some basic properties of addition, multiplication and zero\ninstance : IsSmooth2 (\u03bb x y : X => x + y) := sorry\n@[simp] theorem HAdd.hAdd.arg_x.diff_simp : \u2202 (\u03bb x y : X => x + y) = \u03bb x dx y => dx := sorry\n@[simp] theorem HAdd.hAdd.arg_y.diff_simp (x : X) : \u2202 (\u03bb y : X => x + y) = \u03bb y dy => dy := sorry\n\ninstance : IsSmooth2 (\u03bb (x : \u211d) (y : X) => x * y) := sorry\n@[simp] theorem HMul.hMul.arg_x.diff_simp : \u2202 (\u03bb (x : \u211d) (y : X) => x * y) = \u03bb x dx y => dx * y := sorry\n@[simp] theorem HMul.hMul.arg_y.diff_simp (x : \u211d) : \u2202 (\u03bb y : X => x * y) = \u03bb 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:\u211d) * x = (0:X) := sorry\n\n@[simp] theorem zero_app (a : \u03b1) : (0 : \u03b1 \u2192 X) a = (0 : X) := sorry\n@[simp] theorem differential_zero (f : X \u2192 Y) [IsSmooth f] (x : X): \u2202 f x 0 = 0 := sorry\n\n\n@[simp high] -- prefer this over S rule\ntheorem chain_rule\n  (f : Y \u2192 Z) (g : X \u2192 Y) [IsSmooth f] [IsSmooth g]\n  : \u2202 (\u03bb x => f (g x))\n    =\n    \u03bb x dx => \u2202 f (g x) (\u2202 g x dx) := by simp\n\n@[simp high] -- prefer this over S rule\ntheorem binop_chain_rule {Y\u2081 Y\u2082} [Vec Y\u2081] [Vec Y\u2082]\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 Z) [IsSmooth2 f] \n  (g\u2081 : X \u2192 Y\u2081) [IsSmooth g\u2081]\n  (g\u2082 : X \u2192 Y\u2082) [IsSmooth g\u2082]\n  : \u2202 (\u03bb x => f (g\u2081 x) (g\u2082 x))\n    =\n    \u03bb x dx => \n      \u2202 f (g\u2081 x) (\u2202 g\u2081 x dx) (g\u2082 x)\n      +\n      \u2202 (f (g\u2081 x)) (g\u2082 x) (\u2202 g\u2082 x dx) := \nby \n  funext x dx\n  rw[differential_rule_S (\u03bb x y => f (g\u2081 x) y) g\u2082]; dsimp\n  rw[differential_rule_C]; dsimp\n  rw[differential_rule_S (\u03bb _ x' => f x' (g\u2082 x)) g\u2081]\n  simp\n  done\n\n\n--------------------------------------------------------------------------------\n-- Tests\n--------------------------------------------------------------------------------\n\nnamespace maintests\n\n  variable {\u03b1 \u03b2 \u03b3 : Type}\n\n  variable (f : Y \u2192 Z) (g : X \u2192 Y) [IsSmooth f] [IsSmooth g] (h : X \u2192 X) [IsSmooth h] (h' : Y \u2192 Y) [IsSmooth h']\n  variable (a : \u03b1) (b : \u03b2)\n  variable (F : Y \u2192 \u03b1 \u2192 X) [IsSmooth F]\n  variable (G : X \u2192 \u03b1 \u2192 \u03b2 \u2192 Y) [IsSmooth G]\n  variable (G' : X \u2192 Z \u2192 W \u2192 Y) (z : Z) (w : W) [IsSmooth G']\n  variable (H : \u03b1 \u2192 X \u2192 \u03b2 \u2192 Y) [IsSmooth (H a)]\n  variable (H': \u03b1 \u2192 \u03b2 \u2192 X \u2192 Y) [IsSmooth (H' a b)]\n\n  example : IsSmooth (\u03bb x => g x) := by infer_instance\n  example : IsSmooth (\u03bb x => f (g x)) := by infer_instance\n  example : IsSmooth (\u03bb x => f (g (h (h x)))) := by infer_instance\n  example : IsSmooth (\u03bb (g' : X \u2192 Y) => f \u2218 g') := by unfold Function.comp; infer_instance\n  example : IsSmooth (\u03bb (x : X) => F (g (h x)) a) := by infer_instance\n  example : IsSmooth (f \u2218 g) := by unfold Function.comp; infer_instance\n  example : IsSmooth (\u03bb (f : Y \u2192 Z) (x : X) => (f (g x))) := by infer_instance\n  example : IsSmooth (\u03bb (h'' : X \u2192 X) (x : X) => h (h (h (h'' ((h \u2218 h) (h x)))))) := by infer_instance\n  example : IsSmooth (\u03bb (x : X) => G (h x) a b) := by infer_instance\n  example : IsSmooth (\u03bb (x : X) => H a (h x) b) := by infer_instance\n  example : IsSmooth (\u03bb (x : X) => H' a b (h x)) := by infer_instance\n  example (f : \u03b2 \u2192 Y \u2192 Z) [\u2200 b, IsSmooth (f b)] : IsSmooth (\u03bb (g : \u03b1 \u2192 Y) (b : \u03b2) (a : \u03b1) => f b (g a)) := by infer_instance\n  example (f : X \u2192 X \u2192 Y) [IsSmooth2 f]: IsSmooth (\u03bb x => f x x) := by infer_instance\n  example (f : X \u2192 X \u2192 Y) [IsSmooth2 f]: IsSmooth (\u03bb x => f (h x) x) := by infer_instance\n  example (f : X \u2192 X \u2192 Y) [IsSmooth2 f] : IsSmooth (\u03bb x => f x (h x)) := by infer_instance\n  example : IsSmooth (\u03bb (h : X \u2192 X) (x : X) => H' a b (h x)) := by infer_instance\n  example (f : Y \u2192 Z) (g : X \u2192 Y) [IsSmooth f] [IsSmooth g] : IsSmooth (f \u2218 g) := by unfold Function.comp; infer_instance\n  example (g : \u03b1 \u2192 \u03b2) : IsSmooth (\u03bb (f : \u03b2 \u2192 Z) (a : \u03b1) => (f (g a))) := by infer_instance\n  example (f : Y \u2192 \u03b2 \u2192 Z) (g : X \u2192 Y) (b : \u03b2) [IsSmooth f] [IsSmooth g] : IsSmooth (\u03bb x => f (g x) d) := by infer_instance\n  example (f : Y \u2192 \u03b2 \u2192 Z) (g : X \u2192 Y) (h : X \u2192 X) (b : \u03b2) [IsSmooth f] [IsSmooth g] [IsSmooth h] : IsSmooth (\u03bb x => f (g (h (h x))) d) := by infer_instance\n  example (f : \u03b1 \u2192 Y \u2192 Z) [\u2200 a, IsSmooth (f a)] : IsSmooth (\u03bb y a => f a y) := by infer_instance\n  example (f : \u03b1 \u2192 \u03b2 \u2192 X \u2192 Y) [\u2200 a b, IsSmooth (f a b)] : IsSmooth (\u03bb x b a => f a b x) := by infer_instance\n  example (f : \u03b1 \u2192 \u03b2 \u2192 X \u2192 Y) [\u2200 a b, IsSmooth (f a b)] : IsSmooth (\u03bb x a b => f a b x) := by infer_instance\n  example (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 X \u2192 Y) [\u2200 a b c, IsSmooth (f a b c)] : IsSmooth (\u03bb x a b c => f a b c x) := by infer_instance\n  example (f : X \u2192 X) [IsSmooth f] : IsSmooth (\u03bb (g : X \u2192 X) x => f (f (g x))) := by infer_instance\n  example (f : X \u2192 X \u2192 \u03b2 \u2192 Y) [IsSmooth2 f] : IsSmooth (\u03bb x b => f x x b) := by infer_instance\n  example : IsSmooth (\u03bb (g : X \u2192 Y) (x : X) => F (g (h x)) a) := by infer_instance\n  example : IsSmooth (\u03bb (x : X) => G' (h x) z w) := by infer_instance\n  example (f : X \u2192 X \u2192 \u03b2 \u2192 Y) [IsSmooth2 f]  (b) : IsSmooth (\u03bb x => f x x b) := by infer_instance\n  example : IsSmooth (\u03bb (h : X \u2192 X) (x : X) => G (h x)) := by infer_instance\n\n  example : IsSmooth (\u03bb (h : X \u2192 X) (x : X) => G (h x) a b) := by infer_instance\n  example : IsSmooth (\u03bb (h : X \u2192 X) (x : X) => H a (h x) b) := by infer_instance\n  example : IsSmooth (\u03bb (x : X) => h (F (h' ((h' \u2218 g) (h x))) a)) := by unfold Function.comp; infer_instance\n  set_option synthInstance.maxSize 200 in\n  example : IsSmooth (\u03bb (h'' : X \u2192 X) (x : X) => (h \u2218 h \u2218 h) (h (h'' (h ((h \u2218 h) x))))) := by unfold Function.comp; infer_instance\n\nend maintests\n\n\nnamespace foldtest\n\nvariable {\u03b1 \u03b2 \u03b3 : Type} \nvariable {X : Type} {Y : Type} {Z : Type} [Vec X] [Vec Y] [Vec Z]\n\nvariable (f : X \u2192 X) [IsSmooth f]\n\n\nexample : IsSmooth (\u03bb x => f x) := by infer_instance\nexample : IsSmooth (\u03bb x => x |> f) := by infer_instance\nexample : IsSmooth (\u03bb x => x |> f |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X) x => f (g x)) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X) x => g (f x)) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> g |> g) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X) x => f (f (g x))) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X) x => f (g (f x))) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> g |> g |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X)  x => g (f (f x))) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> g |> f |> g) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> f |> g |> g) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> g |> g |> g) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X)  x => x |> g |> f |> f |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X)  x => x |> f |> g |> f |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> g |> g |> f |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X)  x => x |> f |> f |> g |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> g |> f |> g |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> f |> g |> g |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u27ff X) x => x |> g |> g |> g |> f) := by infer_instance\nexample : IsSmooth (\u03bb (g : X \u2192 X)  x => x |> f |> f |> f |> g) := by infer_instance\n\nend foldtest\n\n\nsection differentiation_tests\n\nvariable {\u03b1 \u03b2 \u03b3 : Type}\nvariable {X Y Z W : Type} [Vec X] [Vec Y] [Vec Z] [Vec W]\nvariable {Y\u2081 Y\u2082 : Type} [Vec Y\u2081] [Vec Y\u2082]\n\n\nexample (f : Y \u2192 Z) [IsSmooth f] (g : X \u2192 Y) [IsSmooth g]\n  : \u2202 (\u03bb x => f (g x)) = \u03bb x dx => \u2202 f (g x) (\u2202 g x dx) := by simp\n\n\nexample (a : \u03b1) (f : Y \u2192 \u03b1 \u2192 Z) [IsSmooth f] (g : X \u2192 Y) [IsSmooth g]\n  : \u2202 (\u03bb x => f (g x) a) = \u03bb x dx => \u2202 f (g x) (\u2202 g x dx) a := by simp\n\nexample (f : Y \u2192 Z) [IsSmooth f]\n  : \u2202 (\u03bb (g : \u03b1 \u2192 Y) (a : \u03b1) => f (g a)) = \u03bb g dg a => \u2202 f (g a) (dg a) := by simp\n\nexample\n  : \u2202 (\u03bb (f : \u03b2 \u2192 Z) (g : \u03b1 \u2192 \u03b2) (a : \u03b1) => f (g a)) = \u03bb f df (g : \u03b1 \u2192 \u03b2) a => df (g a) := by simp\n\nexample (f : Y \u2192 \u03b2 \u2192 Z) (g : X \u2192 Y) [IsSmooth f] [IsSmooth g] (b) \n  : \u2202 (\u03bb x => f (g x) b) = \u03bb x dx => \u2202 f (g x) (\u2202 g x dx) b := by simp\n\nexample (f : Y \u2192 \u03b2 \u2192 Z) [IsSmooth f] (b)\n  : \u2202 (\u03bb (g : \u03b1 \u2192 Y) a => f (g a) b) = \u03bb g dg a => \u2202 f (g a) (dg a) b := by simp\n\nexample (f : \u03b2 \u2192 Y \u2192 Z) (g : \u03b2 \u2192 X \u2192 Y) [\u2200 b, IsSmooth (f b)] [\u2200 b, IsSmooth (g b)]\n  : \u2202 (\u03bb x b => f b (g b x)) = \u03bb x dx b => \u2202 (f b) (g b x) (\u2202 (g b) x dx) := by simp\n\nexample (f : Y \u2192 \u03b2 \u2192 Z) (g : X \u2192 Y) [IsSmooth f] [IsSmooth g]\n  : \u2202 (\u03bb x b => f (g x) b) = \u03bb x dx b => \u2202 f (g x) (\u2202 g x dx) b := by simp\n\nset_option synthInstance.maxSize 300 in\nexample (f : Y \u2192 \u03b2 \u2192 Z) [IsSmooth f]\n  : \u2202 (\u03bb (g : \u03b1 \u2192 Y) a b => f (g a) b) = \u03bb g dg a b => \u2202 f (g a) (dg a) b := by simp\n\nexample (f : Y\u2081 \u2192 \u03b22 \u2192 Z) (g2 : \u03b1 \u2192 \u03b22) [IsSmooth f] (g dg)\n  : \u2202 (\u03bb  (g1 : \u03b1 \u2192 Y\u2081) a => f (g1 a) (g2 a)) g dg = \u03bb a => \u2202 f (g a) (dg a) (g2 a) := by simp\n\nexample (f : \u03b21 \u2192 Y\u2082 \u2192 Z) (g1 : \u03b1 \u2192 \u03b21) [\u2200 y1, IsSmooth (f y1)] \n  : \u2202 (\u03bb (g2 : \u03b1 \u2192 Y\u2082) a => f (g1 a) (g2 a)) = \u03bb g dg a => \u2202 (f (g1 a)) (g a) (dg a) := by simp\n\n\nvariable (f : Y \u2192 Z) [IsSmooth f]\nvariable (g : X \u2192 Y) [IsSmooth g]\nvariable (f1 : X \u2192 X) [IsSmooth f1]\nvariable (f2 : Y \u2192 Y) [IsSmooth f2]\nvariable (f3 : Z \u2192 Z) [IsSmooth f3]\nvariable (F : X \u2192 Y \u2192 Z) [IsSmooth2 F]\nvariable (G : X \u00d7 Y \u2192 Z) [IsSmooth G]\n\nvariable (x dx : X) (y dy : Y) (z dz : Z)\n\nexample : \u2202 (\u03bb x => f (g (f1 x))) x dx = \u2202 f (g (f1 x)) (\u2202 g (f1 x) (\u2202 f1 x dx)) := by simp\n\nexample : \u2202 (\u03bb (x : X) => F x (g x)) x dx = \u2202 F x dx (g x) + \u2202 (F x) (g x) (\u2202 g x dx) := by simp\nexample : \u2202 (\u03bb (x : X) => f3 (F x (g x))) x dx = \u2202 f3 (F x (g x)) (\u2202 F x dx (g x) + \u2202 (F x) (g x) (\u2202 g x dx)) := by simp\nexample g dg x : \u2202 (\u03bb (g : X \u2192 Y) => f (g x)) g dg = \u2202 f (g x) (dg x) := by simp\nexample g dg x : \u2202 (\u03bb (g : X \u2192 Y) (x : X) => F x (g x)) g dg x = \u2202 (F x) (g x) (dg x) := by simp\n\n\n-- The following tests rely on `binop_chain_rule`\n\nexample g dg x : \u2202 (\u03bb (g : X \u2192 X) (y : Y) => F (g x) y) g dg y = \u2202 F (g x) (dg x) y := by simp\nexample g dg y : \u2202 (\u03bb (g : X \u2192 X) (x : X) => F (g x) y) g dg x = \u2202 F (g x) (dg x) y := by simp\n\nexample (r dr : \u211d) : \u2202 (\u03bb x : \u211d => x*x) r dr = dr * r + r * dr := by simp\nexample (r dr : \u211d) : \u2202 (\u03bb x : \u211d => x*x + x) r dr = dr * r + r * dr + dr := by simp\nexample (r dr : \u211d) : \u2202 (\u03bb x : \u211d => x*x*x + x) r dr = (dr * r + r * dr) * r + r * r * dr + dr := by simp\n\nexample (f : X \u2192 \u03b1 \u2192 Y) [IsSmooth f] (a : \u03b1) (y : Y)\n  : \u2202 (fun (x : X) => (f x a) + y)\n    =\n    \u03bb x dx => \u2202 f x dx a := by simp\n\nexample (f g : X \u2192 \u03b1 \u2192 Y) [IsSmooth f] [IsSmooth g]\n  : \u2202 (\u03bb x a => f x a + g x a) \n    =\n    \u03bb x dx a => \u2202 f x dx a + \u2202 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 {\u03b9 \u03b1 \u03b2 : Type _}\n\nsection LinearOrderedSemifield\n\nvariable [LinearOrderedSemifield \u03b1] {a b c d e : \u03b1} {m n : \u2124}\n\n/- warning: order_iso.mul_left\u2080 -> OrderIso.mulLeft\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (OrderIso.{u1, u1} \u03b1 \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (OrderIso.{u1, u1} \u03b1 \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align order_iso.mul_left\u2080 OrderIso.mulLeft\u2080\u2093'. -/\n/-- `equiv.mul_left\u2080` as an order_iso. -/\n@[simps (config := { simpRhs := true })]\ndef OrderIso.mulLeft\u2080 (a : \u03b1) (ha : 0 < a) : \u03b1 \u2243o \u03b1 :=\n  { Equiv.mulLeft\u2080 a ha.ne' with map_rel_iff' := fun _ _ => mul_le_mul_left ha }\n#align order_iso.mul_left\u2080 OrderIso.mulLeft\u2080\n\n/- warning: order_iso.mul_right\u2080 -> OrderIso.mulRight\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (OrderIso.{u1, u1} \u03b1 \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (OrderIso.{u1, u1} \u03b1 \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align order_iso.mul_right\u2080 OrderIso.mulRight\u2080\u2093'. -/\n/-- `equiv.mul_right\u2080` as an order_iso. -/\n@[simps (config := { simpRhs := true })]\ndef OrderIso.mulRight\u2080 (a : \u03b1) (ha : 0 < a) : \u03b1 \u2243o \u03b1 :=\n  { Equiv.mulRight\u2080 a ha.ne' with map_rel_iff' := fun _ _ => mul_le_mul_right ha }\n#align order_iso.mul_right\u2080 OrderIso.mulRight\u2080\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a)\nCase conversion may be inaccurate. Consider using '#align inv_pos inv_pos\u2093'. -/\n@[simp]\ntheorem inv_pos : 0 < a\u207b\u00b9 \u2194 0 < a :=\n  suffices \u2200 a : \u03b1, 0 < a \u2192 0 < a\u207b\u00b9 from \u27e8fun h => inv_inv a \u25b8 this _ h, this a\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align inv_pos_of_pos inv_pos_of_pos\u2093'. -/\nalias inv_pos \u2194 _ 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a)\nCase conversion may be inaccurate. Consider using '#align inv_nonneg inv_nonneg\u2093'. -/\n@[simp]\ntheorem inv_nonneg : 0 \u2264 a\u207b\u00b9 \u2194 0 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align inv_nonneg_of_nonneg inv_nonneg_of_nonneg\u2093'. -/\nalias inv_nonneg \u2194 _ 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align inv_lt_zero inv_lt_zero\u2093'. -/\n@[simp]\ntheorem inv_lt_zero : a\u207b\u00b9 < 0 \u2194 a < 0 := by simp only [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align inv_nonpos inv_nonpos\u2093'. -/\n@[simp]\ntheorem inv_nonpos : a\u207b\u00b9 \u2264 0 \u2194 a \u2264 0 := by simp only [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a)\nCase conversion may be inaccurate. Consider using '#align one_div_pos one_div_pos\u2093'. -/\ntheorem one_div_pos : 0 < 1 / a \u2194 0 < a :=\n  inv_eq_one_div a \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align one_div_neg one_div_neg\u2093'. -/\ntheorem one_div_neg : 1 / a < 0 \u2194 a < 0 :=\n  inv_eq_one_div a \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a)\nCase conversion may be inaccurate. Consider using '#align one_div_nonneg one_div_nonneg\u2093'. -/\ntheorem one_div_nonneg : 0 \u2264 1 / a \u2194 0 \u2264 a :=\n  inv_eq_one_div a \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align one_div_nonpos one_div_nonpos\u2093'. -/\ntheorem one_div_nonpos : 1 / a \u2264 0 \u2194 a \u2264 0 :=\n  inv_eq_one_div a \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align div_pos div_pos\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align div_nonneg div_nonneg\u2093'. -/\ntheorem div_nonneg (ha : 0 \u2264 a) (hb : 0 \u2264 b) : 0 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align div_nonpos_of_nonpos_of_nonneg div_nonpos_of_nonpos_of_nonneg\u2093'. -/\ntheorem div_nonpos_of_nonpos_of_nonneg (ha : a \u2264 0) (hb : 0 \u2264 b) : a / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align div_nonpos_of_nonneg_of_nonpos div_nonpos_of_nonneg_of_nonpos\u2093'. -/\ntheorem div_nonpos_of_nonneg_of_nonpos (ha : 0 \u2264 a) (hb : b \u2264 0) : a / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (forall (n : Int), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (forall (n : Int), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a n))\nCase conversion may be inaccurate. Consider using '#align zpow_nonneg zpow_nonneg\u2093'. -/\ntheorem zpow_nonneg (ha : 0 \u2264 a) : \u2200 n : \u2124, 0 \u2264 a ^ n\n  | (n : \u2115) => 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (forall (n : Int), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (forall (n : Int), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Int \u03b1 (instHPow.{u1, 0} \u03b1 Int (DivInvMonoid.Pow.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a n))\nCase conversion may be inaccurate. Consider using '#align zpow_pos_of_pos zpow_pos_of_pos\u2093'. -/\ntheorem zpow_pos_of_pos (ha : 0 < a) : \u2200 n : \u2124, 0 < a ^ n\n  | (n : \u2115) => 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a c) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a c) b))\nCase conversion may be inaccurate. Consider using '#align le_div_iff le_div_iff\u2093'. -/\ntheorem le_div_iff (hc : 0 < c) : a \u2264 b / c \u2194 a * c \u2264 b :=\n  \u27e8fun h => div_mul_cancel b (ne_of_lt hc).symm \u25b8 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      _ \u2264 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      \u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c a) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c a) b))\nCase conversion may be inaccurate. Consider using '#align le_div_iff' le_div_iff'\u2093'. -/\ntheorem le_div_iff' (hc : 0 < c) : a \u2264 b / c \u2194 c * a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align div_le_iff div_le_iff\u2093'. -/\ntheorem div_le_iff (hb : 0 < b) : a / b \u2264 c \u2194 a \u2264 c * b :=\n  \u27e8fun h =>\n    calc\n      a = a / b * b := by rw [div_mul_cancel _ (ne_of_lt hb).symm]\n      _ \u2264 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      _ \u2264 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      \u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align div_le_iff' div_le_iff'\u2093'. -/\ntheorem div_le_iff' (hb : 0 < b) : a / b \u2264 c \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a c) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a c) b))\nCase conversion may be inaccurate. Consider using '#align lt_div_iff lt_div_iff\u2093'. -/\ntheorem lt_div_iff (hc : 0 < c) : a < b / c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c a) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c a) b))\nCase conversion may be inaccurate. Consider using '#align lt_div_iff' lt_div_iff'\u2093'. -/\ntheorem lt_div_iff' (hc : 0 < c) : a < b / c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a c)))\nCase conversion may be inaccurate. Consider using '#align div_lt_iff div_lt_iff\u2093'. -/\ntheorem div_lt_iff (hc : 0 < c) : b / c < a \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c a)))\nCase conversion may be inaccurate. Consider using '#align div_lt_iff' div_lt_iff'\u2093'. -/\ntheorem div_lt_iff' (hc : 0 < c) : b / c < a \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) a) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) a) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align inv_mul_le_iff inv_mul_le_iff\u2093'. -/\ntheorem inv_mul_le_iff (h : 0 < b) : b\u207b\u00b9 * a \u2264 c \u2194 a \u2264 b * c :=\n  by\n  rw [inv_eq_one_div, mul_comm, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) a) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) a) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align inv_mul_le_iff' inv_mul_le_iff'\u2093'. -/\ntheorem inv_mul_le_iff' (h : 0 < b) : b\u207b\u00b9 * a \u2264 c \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b)) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b)) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align mul_inv_le_iff mul_inv_le_iff\u2093'. -/\ntheorem mul_inv_le_iff (h : 0 < b) : a * b\u207b\u00b9 \u2264 c \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b)) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b)) c) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align mul_inv_le_iff' mul_inv_le_iff'\u2093'. -/\ntheorem mul_inv_le_iff' (h : 0 < b) : a * b\u207b\u00b9 \u2264 c \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a a) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a a) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align div_self_le_one div_self_le_one\u2093'. -/\ntheorem div_self_le_one (a : \u03b1) : a / a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) a) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) a) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align inv_mul_lt_iff inv_mul_lt_iff\u2093'. -/\ntheorem inv_mul_lt_iff (h : 0 < b) : b\u207b\u00b9 * a < c \u2194 a < b * c :=\n  by\n  rw [inv_eq_one_div, mul_comm, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) a) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) a) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align inv_mul_lt_iff' inv_mul_lt_iff'\u2093'. -/\ntheorem inv_mul_lt_iff' (h : 0 < b) : b\u207b\u00b9 * a < c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b)) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b)) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b c)))\nCase conversion may be inaccurate. Consider using '#align mul_inv_lt_iff mul_inv_lt_iff\u2093'. -/\ntheorem mul_inv_lt_iff (h : 0 < b) : a * b\u207b\u00b9 < c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b)) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b)) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align mul_inv_lt_iff' mul_inv_lt_iff'\u2093'. -/\ntheorem mul_inv_lt_iff' (h : 0 < b) : a * b\u207b\u00b9 < c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem inv_pos_le_iff_one_le_mul (ha : 0 < a) : a\u207b\u00b9 \u2264 b \u2194 1 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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'\u2093'. -/\ntheorem inv_pos_le_iff_one_le_mul' (ha : 0 < a) : a\u207b\u00b9 \u2264 b \u2194 1 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem inv_pos_lt_iff_one_lt_mul (ha : 0 < a) : a\u207b\u00b9 < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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'\u2093'. -/\ntheorem inv_pos_lt_iff_one_lt_mul' (ha : 0 < a) : a\u207b\u00b9 < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c b)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) c)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c b)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _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\u2093'. -/\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 \u2264 b) (hc : 0 \u2264 c) (h : a \u2264 c * b) : a / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a c) b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\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 \u2264 b) (hc : 0 \u2264 c) (h : a \u2264 b / c) : a * c \u2264 b :=\n  by\n  obtain rfl | hc := hc.eq_or_lt\n  \u00b7 simpa using hb\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align div_le_one_of_le div_le_one_of_le\u2093'. -/\ntheorem div_le_one_of_le (h : a \u2264 b) (hb : 0 \u2264 b) : a / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align inv_le_inv_of_le inv_le_inv_of_le\u2093'. -/\ntheorem inv_le_inv_of_le (ha : 0 < a) (h : a \u2264 b) : b\u207b\u00b9 \u2264 a\u207b\u00b9 := by\n  rwa [\u2190 one_div a, le_div_iff' ha, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align inv_le_inv inv_le_inv\u2093'. -/\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\u207b\u00b9 \u2264 b\u207b\u00b9 \u2194 b \u2264 a := by\n  rw [\u2190 one_div, div_le_iff ha, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) a))\nCase conversion may be inaccurate. Consider using '#align inv_le inv_le\u2093'. -/\n/-- In a linear ordered field, for positive `a` and `b` we have `a\u207b\u00b9 \u2264 b \u2194 b\u207b\u00b9 \u2264 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\u207b\u00b9 \u2264 b \u2194 b\u207b\u00b9 \u2264 a := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) a)\nCase conversion may be inaccurate. Consider using '#align inv_le_of_inv_le inv_le_of_inv_le\u2093'. -/\ntheorem inv_le_of_inv_le (ha : 0 < a) (h : a\u207b\u00b9 \u2264 b) : b\u207b\u00b9 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a)))\nCase conversion may be inaccurate. Consider using '#align le_inv le_inv\u2093'. -/\ntheorem le_inv (ha : 0 < a) (hb : 0 < b) : a \u2264 b\u207b\u00b9 \u2194 b \u2264 a\u207b\u00b9 := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_inv inv_lt_inv\u2093'. -/\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\u207b\u00b9 < b\u207b\u00b9 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b))\nCase conversion may be inaccurate. Consider using '#align inv_lt_inv_of_lt inv_lt_inv_of_lt\u2093'. -/\ntheorem inv_lt_inv_of_lt (hb : 0 < b) (h : b < a) : a\u207b\u00b9 < b\u207b\u00b9 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) a))\nCase conversion may be inaccurate. Consider using '#align inv_lt inv_lt\u2093'. -/\n/-- In a linear ordered field, for positive `a` and `b` we have `a\u207b\u00b9 < b \u2194 b\u207b\u00b9 < 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\u207b\u00b9 < b \u2194 b\u207b\u00b9 < 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b) a)\nCase conversion may be inaccurate. Consider using '#align inv_lt_of_inv_lt inv_lt_of_inv_lt\u2093'. -/\ntheorem inv_lt_of_inv_lt (ha : 0 < a) (h : a\u207b\u00b9 < b) : b\u207b\u00b9 < 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a)))\nCase conversion may be inaccurate. Consider using '#align lt_inv lt_inv\u2093'. -/\ntheorem lt_inv (ha : 0 < a) (hb : 0 < b) : a < b\u207b\u00b9 \u2194 b < a\u207b\u00b9 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align inv_lt_one inv_lt_one\u2093'. -/\ntheorem inv_lt_one (ha : 1 < a) : a\u207b\u00b9 < 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align one_lt_inv one_lt_inv\u2093'. -/\ntheorem one_lt_inv (h\u2081 : 0 < a) (h\u2082 : a < 1) : 1 < a\u207b\u00b9 := by rwa [lt_inv zero_lt_one h\u2081, 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align inv_le_one inv_le_one\u2093'. -/\ntheorem inv_le_one (ha : 1 \u2264 a) : a\u207b\u00b9 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a))\nCase conversion may be inaccurate. Consider using '#align one_le_inv one_le_inv\u2093'. -/\ntheorem one_le_inv (h\u2081 : 0 < a) (h\u2082 : a \u2264 1) : 1 \u2264 a\u207b\u00b9 := by rwa [le_inv zero_lt_one h\u2081, 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_one_iff_of_pos inv_lt_one_iff_of_pos\u2093'. -/\ntheorem inv_lt_one_iff_of_pos (h\u2080 : 0 < a) : a\u207b\u00b9 < 1 \u2194 1 < a :=\n  \u27e8fun h\u2081 => inv_inv a \u25b8 one_lt_inv (inv_pos.2 h\u2080) h\u2081, inv_lt_one\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (Or (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (Or (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_one_iff inv_lt_one_iff\u2093'. -/\ntheorem inv_lt_one_iff : a\u207b\u00b9 < 1 \u2194 a \u2264 0 \u2228 1 < a :=\n  by\n  cases' le_or_lt a 0 with ha ha\n  \u00b7 simp [ha, (inv_nonpos.2 ha).trans_lt zero_lt_one]\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align one_lt_inv_iff one_lt_inv_iff\u2093'. -/\ntheorem one_lt_inv_iff : 1 < a\u207b\u00b9 \u2194 0 < a \u2227 a < 1 :=\n  \u27e8fun h => \u27e8inv_pos.1 (zero_lt_one.trans h), inv_inv a \u25b8 inv_lt_one h\u27e9, and_imp.2 one_lt_inv\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (Or (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (Or (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align inv_le_one_iff inv_le_one_iff\u2093'. -/\ntheorem inv_le_one_iff : a\u207b\u00b9 \u2264 1 \u2194 a \u2264 0 \u2228 1 \u2264 a :=\n  by\n  rcases em (a = 1) with (rfl | ha)\n  \u00b7 simp [le_rfl]\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) a)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) a)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))\nCase conversion may be inaccurate. Consider using '#align one_le_inv_iff one_le_inv_iff\u2093'. -/\ntheorem one_le_inv_iff : 1 \u2264 a\u207b\u00b9 \u2194 0 < a \u2227 a \u2264 1 :=\n  \u27e8fun h => \u27e8inv_pos.1 (zero_lt_one.trans_le h), inv_inv a \u25b8 inv_le_one h\u27e9, and_imp.2 one_le_inv\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align div_le_div_of_le div_le_div_of_le\u2093'. -/\n@[mono]\ntheorem div_le_div_of_le (hc : 0 \u2264 c) (h : a \u2264 b) : a / c \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) c b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) c b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c))\nCase conversion may be inaccurate. Consider using '#align div_le_div_of_le_left div_le_div_of_le_left\u2093'. -/\n-- Not a `mono` lemma b/c `div_le_div` is strictly more general\ntheorem div_le_div_of_le_left (ha : 0 \u2264 a) (hc : 0 < c) (h : c \u2264 b) : a / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _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\u2093'. -/\ntheorem div_le_div_of_le_of_nonneg (hab : a \u2264 b) (hc : 0 \u2264 c) : a / c \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_of_lt div_lt_div_of_lt\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align div_le_div_right div_le_div_right\u2093'. -/\ntheorem div_le_div_right (hc : 0 < c) : a / c \u2264 b / c \u2194 a \u2264 b :=\n  \u27e8le_imp_le_of_lt_imp_lt <| div_lt_div_of_lt hc, div_le_div_of_le <| hc.le\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_right div_lt_div_right\u2093'. -/\ntheorem div_lt_div_right (hc : 0 < c) : a / c < b / c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) c b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) c b))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_left div_lt_div_left\u2093'. -/\ntheorem div_lt_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b < a / c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) c b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) c b))\nCase conversion may be inaccurate. Consider using '#align div_le_div_left div_le_div_left\u2093'. -/\ntheorem div_le_div_left (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) : a / b \u2264 a / c \u2194 c \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) d) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c d)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) d) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c d)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_iff div_lt_div_iff\u2093'. -/\ntheorem div_lt_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b < c / d \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) d) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c d)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) d) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c d)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c b)))\nCase conversion may be inaccurate. Consider using '#align div_le_div_iff div_le_div_iff\u2093'. -/\ntheorem div_le_div_iff (b0 : 0 < b) (d0 : 0 < d) : a / b \u2264 c / d \u2194 a * d \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) d) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) d b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c d))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) d) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) d b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c d))\nCase conversion may be inaccurate. Consider using '#align div_le_div div_le_div\u2093'. -/\n@[mono]\ntheorem div_le_div (hc : 0 \u2264 c) (hac : a \u2264 c) (hd : 0 < d) (hbd : d \u2264 b) : a / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) d b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) d) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c d))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) d b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) d) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c d))\nCase conversion may be inaccurate. Consider using '#align div_lt_div div_lt_div\u2093'. -/\ntheorem div_lt_div (hac : a < c) (hbd : d \u2264 b) (c0 : 0 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) d b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) d) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c d))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) d b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) d) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c d))\nCase conversion may be inaccurate. Consider using '#align div_lt_div' div_lt_div'\u2093'. -/\ntheorem div_lt_div' (hac : a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c b))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_of_lt_left div_lt_div_of_lt_left\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) a)\nCase conversion may be inaccurate. Consider using '#align div_le_self div_le_self\u2093'. -/\ntheorem div_le_self (ha : 0 \u2264 a) (hb : 1 \u2264 b) : a / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) a)\nCase conversion may be inaccurate. Consider using '#align div_lt_self div_lt_self\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align le_div_self le_div_self\u2093'. -/\ntheorem le_div_self (ha : 0 \u2264 a) (hb\u2080 : 0 < b) (hb\u2081 : b \u2264 1) : a \u2264 a / b := by\n  simpa only [div_one] using div_le_div_of_le_left ha hb\u2080 hb\u2081\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_le_div one_le_div\u2093'. -/\ntheorem one_le_div (hb : 0 < b) : 1 \u2264 a / b \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align div_le_one div_le_one\u2093'. -/\ntheorem div_le_one (hb : 0 < b) : a / b \u2264 1 \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_lt_div one_lt_div\u2093'. -/\ntheorem one_lt_div (hb : 0 < b) : 1 < a / b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align div_lt_one div_lt_one\u2093'. -/\ntheorem div_lt_one (hb : 0 < b) : a / b < 1 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b) a))\nCase conversion may be inaccurate. Consider using '#align one_div_le one_div_le\u2093'. -/\ntheorem one_div_le (ha : 0 < a) (hb : 0 < b) : 1 / a \u2264 b \u2194 1 / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b) a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt one_div_lt\u2093'. -/\ntheorem one_div_lt (ha : 0 < a) (hb : 0 < b) : 1 / a < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a)))\nCase conversion may be inaccurate. Consider using '#align le_one_div le_one_div\u2093'. -/\ntheorem le_one_div (ha : 0 < a) (hb : 0 < b) : a \u2264 1 / b \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a)))\nCase conversion may be inaccurate. Consider using '#align lt_one_div lt_one_div\u2093'. -/\ntheorem lt_one_div (ha : 0 < a) (hb : 0 < b) : a < 1 / b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem one_div_le_one_div_of_le (ha : 0 < a) (h : a \u2264 b) : 1 / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\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, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem le_of_one_div_le_one_div (ha : 0 < a) (h : 1 / a \u2264 1 / b) : b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b)) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b)) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_div_le_one_div one_div_le_one_div\u2093'. -/\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 \u2264 1 / b \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_one_div one_div_lt_one_div\u2093'. -/\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 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align one_lt_one_div one_lt_one_div\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a))\nCase conversion may be inaccurate. Consider using '#align one_le_one_div one_le_one_div\u2093'. -/\ntheorem one_le_one_div (h1 : 0 < a) (h2 : a \u2264 1) : 1 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))))) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) a\nCase conversion may be inaccurate. Consider using '#align add_halves add_halves\u2093'. -/\n/- TODO: Unify `add_halves` and `add_halves'` into a single lemma about\n`division_semiring` + `char_zero` -/\ntheorem add_halves (a : \u03b1) : a / 2 + a / 2 = a := by\n  rw [div_add_div_same, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a a) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a a) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\n-- TODO: Generalize to `division_semiring`\ntheorem add_self_div_two (a : \u03b1) : (a + a) / 2 = a := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))))\nCase conversion may be inaccurate. Consider using '#align half_pos half_pos\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))\nCase conversion may be inaccurate. Consider using '#align one_half_pos one_half_pos\u2093'. -/\ntheorem one_half_pos : (0 : \u03b1) < 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem div_two_lt_of_pos (h : 0 < a) : a / 2 < a :=\n  by\n  rw [div_lt_iff (zero_lt_two' \u03b1)]\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem half_lt_self : 0 < a \u2192 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem half_le_self (ha_nonneg : 0 \u2264 a) : a / 2 \u2264 a :=\n  by\n  by_cases h0 : a = 0\n  \u00b7 simp [h0]\n  \u00b7 rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align one_half_lt_one one_half_lt_one\u2093'. -/\ntheorem one_half_lt_one : (1 / 2 : \u03b1) < 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align two_inv_lt_one two_inv_lt_one\u2093'. -/\ntheorem two_inv_lt_one : (2\u207b\u00b9 : \u03b1) < 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a b) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a b) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b)\nCase conversion may be inaccurate. Consider using '#align left_lt_add_div_two left_lt_add_div_two\u2093'. -/\ntheorem left_lt_add_div_two : a < (a + b) / 2 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a b) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a b) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) a b)\nCase conversion may be inaccurate. Consider using '#align add_div_two_lt_right add_div_two_lt_right\u2093'. -/\ntheorem add_div_two_lt_right : (a + b) / 2 < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) d) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) d c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) d) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem mul_le_mul_of_mul_div_le (h : a * (b / c) \u2264 d) (hc : 0 < c) : b * a \u2264 d * c :=\n  by\n  rw [\u2190 mul_div_assoc] at h\n  rwa [mul_comm b, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1} {e : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c d)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) e) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b e)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) d e)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1} {e : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c d)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) e) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b e)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) c (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem div_mul_le_div_mul_of_div_le_div (h : a / b \u2264 c / d) (he : 0 \u2264 e) :\n    a / (b * e) \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (forall (b : \u03b1), Exists.{succ u1} \u03b1 (fun (c : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b c) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (forall (b : \u03b1), Exists.{succ u1} \u03b1 (fun (c : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b c) a)))\nCase conversion may be inaccurate. Consider using '#align exists_pos_mul_lt exists_pos_mul_lt\u2093'. -/\ntheorem exists_pos_mul_lt {a : \u03b1} (h : 0 < a) (b : \u03b1) : \u2203 c : \u03b1, 0 < c \u2227 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' \u27e8a / max (b + 1) 1, this, _\u27e9\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (forall (b : \u03b1), Exists.{succ u1} \u03b1 (fun (c : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) c a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (forall (b : \u03b1), Exists.{succ u1} \u03b1 (fun (c : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) c a))))\nCase conversion may be inaccurate. Consider using '#align exists_pos_lt_mul exists_pos_lt_mul\u2093'. -/\ntheorem exists_pos_lt_mul {a : \u03b1} (h : 0 < a) (b : \u03b1) : \u2203 c : \u03b1, 0 < c \u2227 b < c * a :=\n  let \u27e8c, hc\u2080, hc\u27e9 := exists_pos_mul_lt h b\n  \u27e8c\u207b\u00b9, inv_pos.2 hc\u2080, by rwa [\u2190 div_eq_inv_mul, lt_div_iff hc\u2080]\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {\u03b2 : Type.{u2}} [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b2 -> \u03b1}, (Monotone.{u2, u1} \u03b2 \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) f) -> (forall {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (Monotone.{u2, u1} \u03b2 \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (fun (x : \u03b2) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (f x) c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {\u03b2 : Type.{u2}} [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b2 -> \u03b1}, (Monotone.{u2, u1} \u03b2 \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) f) -> (forall {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (Monotone.{u2, u1} \u03b2 \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (fun (x : \u03b2) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (f x) c)))\nCase conversion may be inaccurate. Consider using '#align monotone.div_const Monotone.div_const\u2093'. -/\ntheorem Monotone.div_const {\u03b2 : Type _} [Preorder \u03b2] {f : \u03b2 \u2192 \u03b1} (hf : Monotone f) {c : \u03b1}\n    (hc : 0 \u2264 c) : Monotone fun x => f x / c :=\n  by\n  haveI := @LinearOrder.decidableLe \u03b1 _\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {\u03b2 : Type.{u2}} [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b2 -> \u03b1}, (StrictMono.{u2, u1} \u03b2 \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) f) -> (forall {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (StrictMono.{u2, u1} \u03b2 \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (fun (x : \u03b2) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (f x) c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {\u03b2 : Type.{u2}} [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b2 -> \u03b1}, (StrictMono.{u2, u1} \u03b2 \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) f) -> (forall {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (StrictMono.{u2, u1} \u03b2 \u03b1 _inst_2 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (fun (x : \u03b2) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (f x) c)))\nCase conversion may be inaccurate. Consider using '#align strict_mono.div_const StrictMono.div_const\u2093'. -/\ntheorem StrictMono.div_const {\u03b2 : Type _} [Preorder \u03b2] {f : \u03b2 \u2192 \u03b1} (hf : StrictMono f) {c : \u03b1}\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 \u03b1\n    where dense a\u2081 a\u2082 h :=\n    \u27e8(a\u2081 + a\u2082) / 2,\n      calc\n        a\u2081 = (a\u2081 + a\u2081) / 2 := (add_self_div_two a\u2081).symm\n        _ < (a\u2081 + a\u2082) / 2 := div_lt_div_of_lt zero_lt_two (add_lt_add_left h _)\n        ,\n      calc\n        (a\u2081 + a\u2082) / 2 < (a\u2082 + a\u2082) / 2 := div_lt_div_of_lt zero_lt_two (add_lt_add_right h _)\n        _ = a\u2082 := add_self_div_two a\u2082\n        \u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (LinearOrder.min.{u1} \u03b1 (LinearOrderedAddCommMonoid.toLinearOrder.{u1} \u03b1 (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (LinearOrder.min.{u1} \u03b1 (LinearOrderedAddCommMonoid.toLinearOrder.{u1} \u03b1 (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))) a b) c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (Min.min.{u1} \u03b1 (LinearOrderedCommSemiring.toMin.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (Min.min.{u1} \u03b1 (LinearOrderedCommSemiring.toMin.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)) a b) c))\nCase conversion may be inaccurate. Consider using '#align min_div_div_right min_div_div_right\u2093'. -/\ntheorem min_div_div_right {c : \u03b1} (hc : 0 \u2264 c) (a b : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) c) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (LinearOrder.max.{u1} \u03b1 (LinearOrderedAddCommMonoid.toLinearOrder.{u1} \u03b1 (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) b c)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (LinearOrder.max.{u1} \u03b1 (LinearOrderedAddCommMonoid.toLinearOrder.{u1} \u03b1 (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))) a b) c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) c) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (Max.max.{u1} \u03b1 (LinearOrderedCommSemiring.toMax.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (Max.max.{u1} \u03b1 (LinearOrderedCommSemiring.toMax.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)) a b) c))\nCase conversion may be inaccurate. Consider using '#align max_div_div_right max_div_div_right\u2093'. -/\ntheorem max_div_div_right {c : \u03b1} (hc : 0 \u2264 c) (a b : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], StrictAntiOn.{u1, u1} \u03b1 \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (fun (x : \u03b1) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) x) (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], StrictAntiOn.{u1, u1} \u03b1 \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) x) (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align one_div_strict_anti_on one_div_strictAntiOn\u2093'. -/\ntheorem one_div_strictAntiOn : StrictAntiOn (fun x : \u03b1 => 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (forall {m : Nat} {n : Nat}, (LE.le.{0} Nat Nat.hasLe m n) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (forall {m : Nat} {n : Nat}, (LE.le.{0} Nat instLENat m n) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem one_div_pow_le_one_div_pow_of_le (a1 : 1 \u2264 a) {m n : \u2115} (mn : m \u2264 n) :\n    1 / a ^ n \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (forall {m : Nat} {n : Nat}, (LT.lt.{0} Nat Nat.hasLt m n) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (forall {m : Nat} {n : Nat}, (LT.lt.{0} Nat instLTNat m n) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem one_div_pow_lt_one_div_pow_of_lt (a1 : 1 < a) {m n : \u2115} (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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (Antitone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (fun (n : Nat) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (Antitone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (fun (n : Nat) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)))\nCase conversion may be inaccurate. Consider using '#align one_div_pow_anti one_div_pow_anti\u2093'. -/\ntheorem one_div_pow_anti (a1 : 1 \u2264 a) : Antitone fun n : \u2115 => 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (StrictAnti.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (fun (n : Nat) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (StrictAnti.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (fun (n : Nat) => HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)))\nCase conversion may be inaccurate. Consider using '#align one_div_pow_strict_anti one_div_pow_strictAnti\u2093'. -/\ntheorem one_div_pow_strictAnti (a1 : 1 < a) : StrictAnti fun n : \u2115 => 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], StrictAntiOn.{u1, u1} \u03b1 \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (fun (x : \u03b1) => Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) x) (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1], StrictAntiOn.{u1, u1} \u03b1 \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) x) (Set.Ioi.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))\nCase conversion may be inaccurate. Consider using '#align inv_strict_anti_on inv_strictAntiOn\u2093'. -/\ntheorem inv_strictAntiOn : StrictAntiOn (fun x : \u03b1 => x\u207b\u00b9) (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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (forall {m : Nat} {n : Nat}, (LE.le.{0} Nat Nat.hasLe m n) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (forall {m : Nat} {n : Nat}, (LE.le.{0} Nat instLENat m n) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem inv_pow_le_inv_pow_of_le (a1 : 1 \u2264 a) {m n : \u2115} (mn : m \u2264 n) : (a ^ n)\u207b\u00b9 \u2264 (a ^ m)\u207b\u00b9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (forall {m : Nat} {n : Nat}, (LT.lt.{0} Nat Nat.hasLt m n) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (forall {m : Nat} {n : Nat}, (LT.lt.{0} Nat instLTNat m n) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)) (Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _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\u2093'. -/\ntheorem inv_pow_lt_inv_pow_of_lt (a1 : 1 < a) {m n : \u2115} (mn : m < n) : (a ^ n)\u207b\u00b9 < (a ^ m)\u207b\u00b9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (Antitone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (fun (n : Nat) => Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (Antitone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (fun (n : Nat) => Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)))\nCase conversion may be inaccurate. Consider using '#align inv_pow_anti inv_pow_anti\u2093'. -/\ntheorem inv_pow_anti (a1 : 1 \u2264 a) : Antitone fun n : \u2115 => (a ^ n)\u207b\u00b9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (StrictAnti.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (fun (n : Nat) => Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) a) -> (StrictAnti.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (fun (n : Nat) => Inv.inv.{u1} \u03b1 (LinearOrderedSemifield.toInv.{u1} \u03b1 _inst_1) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a n)))\nCase conversion may be inaccurate. Consider using '#align inv_pow_strict_anti inv_pow_strictAnti\u2093'. -/\ntheorem inv_pow_strictAnti (a1 : 1 < a) : StrictAnti fun n : \u2115 => (a ^ n)\u207b\u00b9 := 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {s : Set.{u1} \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) s b) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Set.image.{u1, u1} \u03b1 \u03b1 (fun (b : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a b) s) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {s : Set.{u1} \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) s b) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (Set.image.{u1, u1} \u03b1 \u03b1 (fun (b : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a b) s) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) a b))\nCase conversion may be inaccurate. Consider using '#align is_glb.mul_left IsGLB.mul_left\u2093'. -/\ntheorem IsGLB.mul_left {s : Set \u03b1} (ha : 0 \u2264 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  \u00b7 exact (OrderIso.mulLeft\u2080 _ ha).isGLB_image'.2 hs\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {s : Set.{u1} \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))))) a) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) s b) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Set.image.{u1, u1} \u03b1 \u03b1 (fun (b : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b a) s) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {s : Set.{u1} \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) a) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) s b) -> (IsGLB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (Set.image.{u1, u1} \u03b1 \u03b1 (fun (b : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b a) s) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))) b a))\nCase conversion may be inaccurate. Consider using '#align is_glb.mul_right IsGLB.mul_right\u2093'. -/\ntheorem IsGLB.mul_right {s : Set \u03b1} (ha : 0 \u2264 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 \u03b1] {a b c d : \u03b1} {n : \u2124}\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b)) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b)) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align div_pos_iff div_pos_iff\u2093'. -/\ntheorem div_pos_iff : 0 < a / b \u2194 0 < a \u2227 0 < b \u2228 a < 0 \u2227 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b)))\nCase conversion may be inaccurate. Consider using '#align div_neg_iff div_neg_iff\u2093'. -/\ntheorem div_neg_iff : a / b < 0 \u2194 0 < a \u2227 b < 0 \u2228 a < 0 \u2227 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b)) (Or (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b)) (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b)) (Or (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b)) (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align div_nonneg_iff div_nonneg_iff\u2093'. -/\ntheorem div_nonneg_iff : 0 \u2264 a / b \u2194 0 \u2264 a \u2227 0 \u2264 b \u2228 a \u2264 0 \u2227 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (Or (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))) (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (Or (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))) (And (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b)))\nCase conversion may be inaccurate. Consider using '#align div_nonpos_iff div_nonpos_iff\u2093'. -/\ntheorem div_nonpos_iff : a / b \u2264 0 \u2194 0 \u2264 a \u2227 b \u2264 0 \u2228 a \u2264 0 \u2227 0 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align div_nonneg_of_nonpos div_nonneg_of_nonpos\u2093'. -/\ntheorem div_nonneg_of_nonpos (ha : a \u2264 0) (hb : b \u2264 0) : 0 \u2264 a / b :=\n  div_nonneg_iff.2 <| Or.inr \u27e8ha, hb\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align div_pos_of_neg_of_neg div_pos_of_neg_of_neg\u2093'. -/\ntheorem div_pos_of_neg_of_neg (ha : a < 0) (hb : b < 0) : 0 < a / b :=\n  div_pos_iff.2 <| Or.inr \u27e8ha, hb\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align div_neg_of_neg_of_pos div_neg_of_neg_of_pos\u2093'. -/\ntheorem div_neg_of_neg_of_pos (ha : a < 0) (hb : 0 < b) : a / b < 0 :=\n  div_neg_iff.2 <| Or.inr \u27e8ha, hb\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align div_neg_of_pos_of_neg div_neg_of_pos_of_neg\u2093'. -/\ntheorem div_neg_of_pos_of_neg (ha : 0 < a) (hb : b < 0) : a / b < 0 :=\n  div_neg_iff.2 <| Or.inl \u27e8ha, hb\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a c) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a c) b))\nCase conversion may be inaccurate. Consider using '#align div_le_iff_of_neg div_le_iff_of_neg\u2093'. -/\ntheorem div_le_iff_of_neg (hc : c < 0) : b / c \u2264 a \u2194 a * c \u2264 b :=\n  \u27e8fun h => div_mul_cancel b (ne_of_lt hc) \u25b8 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      _ \u2265 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      \u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c a) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c) a) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c a) b))\nCase conversion may be inaccurate. Consider using '#align div_le_iff_of_neg' div_le_iff_of_neg'\u2093'. -/\ntheorem div_le_iff_of_neg' (hc : c < 0) : b / c \u2264 a \u2194 c * a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a c)))\nCase conversion may be inaccurate. Consider using '#align le_div_iff_of_neg le_div_iff_of_neg\u2093'. -/\ntheorem le_div_iff_of_neg (hc : c < 0) : a \u2264 b / c \u2194 b \u2264 a * c := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c a)))\nCase conversion may be inaccurate. Consider using '#align le_div_iff_of_neg' le_div_iff_of_neg'\u2093'. -/\ntheorem le_div_iff_of_neg' (hc : c < 0) : a \u2264 b / c \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a c) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a c) b))\nCase conversion may be inaccurate. Consider using '#align div_lt_iff_of_neg div_lt_iff_of_neg\u2093'. -/\ntheorem div_lt_iff_of_neg (hc : c < 0) : b / c < a \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c a) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c a) b))\nCase conversion may be inaccurate. Consider using '#align div_lt_iff_of_neg' div_lt_iff_of_neg'\u2093'. -/\ntheorem div_lt_iff_of_neg' (hc : c < 0) : b / c < a \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a c)))\nCase conversion may be inaccurate. Consider using '#align lt_div_iff_of_neg lt_div_iff_of_neg\u2093'. -/\ntheorem lt_div_iff_of_neg (hc : c < 0) : a < b / c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c a)))\nCase conversion may be inaccurate. Consider using '#align lt_div_iff_of_neg' lt_div_iff_of_neg'\u2093'. -/\ntheorem lt_div_iff_of_neg' (hc : c < 0) : a < b / c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) a) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) a) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align inv_le_inv_of_neg inv_le_inv_of_neg\u2093'. -/\ntheorem inv_le_inv_of_neg (ha : a < 0) (hb : b < 0) : a\u207b\u00b9 \u2264 b\u207b\u00b9 \u2194 b \u2264 a := by\n  rw [\u2190 one_div, div_le_iff_of_neg ha, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) b) a))\nCase conversion may be inaccurate. Consider using '#align inv_le_of_neg inv_le_of_neg\u2093'. -/\ntheorem inv_le_of_neg (ha : a < 0) (hb : b < 0) : a\u207b\u00b9 \u2264 b \u2194 b\u207b\u00b9 \u2264 a := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) a)))\nCase conversion may be inaccurate. Consider using '#align le_inv_of_neg le_inv_of_neg\u2093'. -/\ntheorem le_inv_of_neg (ha : a < 0) (hb : b < 0) : a \u2264 b\u207b\u00b9 \u2194 b \u2264 a\u207b\u00b9 := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) a) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) a) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_inv_of_neg inv_lt_inv_of_neg\u2093'. -/\ntheorem inv_lt_inv_of_neg (ha : a < 0) (hb : b < 0) : a\u207b\u00b9 < b\u207b\u00b9 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) b) a))\nCase conversion may be inaccurate. Consider using '#align inv_lt_of_neg inv_lt_of_neg\u2093'. -/\ntheorem inv_lt_of_neg (ha : a < 0) (hb : b < 0) : a\u207b\u00b9 < b \u2194 b\u207b\u00b9 < 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) a)))\nCase conversion may be inaccurate. Consider using '#align lt_inv_of_neg lt_inv_of_neg\u2093'. -/\ntheorem lt_inv_of_neg (ha : a < 0) (hb : b < 0) : a < b\u207b\u00b9 \u2194 b < a\u207b\u00b9 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _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\u2093'. -/\ntheorem div_le_div_of_nonpos_of_le (hc : c \u2264 0) (h : b \u2264 a) : a / c \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _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\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align div_le_div_right_of_neg div_le_div_right_of_neg\u2093'. -/\ntheorem div_le_div_right_of_neg (hc : c < 0) : a / c \u2264 b / c \u2194 b \u2264 a :=\n  \u27e8le_imp_le_of_lt_imp_lt <| div_lt_div_of_neg_of_lt hc, div_le_div_of_nonpos_of_le <| hc.le\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align div_lt_div_right_of_neg div_lt_div_right_of_neg\u2093'. -/\ntheorem div_lt_div_right_of_neg (hc : c < 0) : a / c < b / c \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align one_le_div_of_neg one_le_div_of_neg\u2093'. -/\ntheorem one_le_div_of_neg (hb : b < 0) : 1 \u2264 a / b \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align div_le_one_of_neg div_le_one_of_neg\u2093'. -/\ntheorem div_le_one_of_neg (hb : b < 0) : a / b \u2264 1 \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b))\nCase conversion may be inaccurate. Consider using '#align one_lt_div_of_neg one_lt_div_of_neg\u2093'. -/\ntheorem one_lt_div_of_neg (hb : b < 0) : 1 < a / b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a))\nCase conversion may be inaccurate. Consider using '#align div_lt_one_of_neg div_lt_one_of_neg\u2093'. -/\ntheorem div_lt_one_of_neg (hb : b < 0) : a / b < 1 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b) a))\nCase conversion may be inaccurate. Consider using '#align one_div_le_of_neg one_div_le_of_neg\u2093'. -/\ntheorem one_div_le_of_neg (ha : a < 0) (hb : b < 0) : 1 / a \u2264 b \u2194 1 / b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b) a))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_of_neg one_div_lt_of_neg\u2093'. -/\ntheorem one_div_lt_of_neg (ha : a < 0) (hb : b < 0) : 1 / a < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a)))\nCase conversion may be inaccurate. Consider using '#align le_one_div_of_neg le_one_div_of_neg\u2093'. -/\ntheorem le_one_div_of_neg (ha : a < 0) (hb : b < 0) : a \u2264 1 / b \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a)))\nCase conversion may be inaccurate. Consider using '#align lt_one_div_of_neg lt_one_div_of_neg\u2093'. -/\ntheorem lt_one_div_of_neg (ha : a < 0) (hb : b < 0) : a < 1 / b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b)) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b)) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b)))\nCase conversion may be inaccurate. Consider using '#align one_lt_div_iff one_lt_div_iff\u2093'. -/\ntheorem one_lt_div_iff : 1 < a / b \u2194 0 < b \u2227 b < a \u2228 b < 0 \u2227 a < b :=\n  by\n  rcases lt_trichotomy b 0 with (hb | rfl | hb)\n  \u00b7 simp [hb, hb.not_lt, one_lt_div_of_neg]\n  \u00b7 simp [lt_irrefl, zero_le_one]\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b)) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b)) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a)) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b)))\nCase conversion may be inaccurate. Consider using '#align one_le_div_iff one_le_div_iff\u2093'. -/\ntheorem one_le_div_iff : 1 \u2264 a / b \u2194 0 < b \u2227 b \u2264 a \u2228 b < 0 \u2227 a \u2264 b :=\n  by\n  rcases lt_trichotomy b 0 with (hb | rfl | hb)\n  \u00b7 simp [hb, hb.not_lt, one_le_div_of_neg]\n  \u00b7 simp [lt_irrefl, zero_lt_one.not_le, zero_lt_one]\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b)) (Or (Eq.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b)) (Or (Eq.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a))))\nCase conversion may be inaccurate. Consider using '#align div_lt_one_iff div_lt_one_iff\u2093'. -/\ntheorem div_lt_one_iff : a / b < 1 \u2194 0 < b \u2227 a < b \u2228 b = 0 \u2228 b < 0 \u2227 b < a :=\n  by\n  rcases lt_trichotomy b 0 with (hb | rfl | hb)\n  \u00b7 simp [hb, hb.not_lt, hb.ne, div_lt_one_of_neg]\n  \u00b7 simp [zero_lt_one]\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b)) (Or (Eq.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (Or (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b)) (Or (Eq.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a))))\nCase conversion may be inaccurate. Consider using '#align div_le_one_iff div_le_one_iff\u2093'. -/\ntheorem div_le_one_iff : a / b \u2264 1 \u2194 0 < b \u2227 a \u2264 b \u2228 b = 0 \u2228 b < 0 \u2227 b \u2264 a :=\n  by\n  rcases lt_trichotomy b 0 with (hb | rfl | hb)\n  \u00b7 simp [hb, hb.not_lt, hb.ne, div_le_one_of_neg]\n  \u00b7 simp [zero_le_one]\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\ntheorem one_div_le_one_div_of_neg_of_le (hb : b < 0) (h : a \u2264 b) : 1 / b \u2264 1 / a := by\n  rwa [div_le_iff_of_neg' hb, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\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, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\ntheorem le_of_neg_of_one_div_le_one_div (hb : b < 0) (h : 1 / a \u2264 1 / b) : b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b)) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b)) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\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 \u2264 1 / b \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\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 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a) (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Neg.neg.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) a) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) (Neg.neg.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align one_div_lt_neg_one one_div_lt_neg_one\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a) (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Neg.neg.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) (Neg.neg.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))\nCase conversion may be inaccurate. Consider using '#align one_div_le_neg_one one_div_le_neg_one\u2093'. -/\ntheorem one_div_le_neg_one (h1 : a < 0) (h2 : -1 \u2264 a) : 1 / a \u2264 -1 :=\n  suffices 1 / a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\ntheorem sub_self_div_two (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) a) (Neg.neg.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))))) a) (Neg.neg.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\ntheorem div_two_sub_self (a : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) b a) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))) b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) a b) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) a (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\ntheorem add_sub_div_two_lt (h : a < b) : a + (b - a) / 2 < b := by\n  rwa [\u2190 div_sub_div_same, sub_eq_add_neg, add_comm (b / 2), \u2190 add_assoc, \u2190 sub_eq_add_neg, \u2190\n    lt_sub_iff_add_lt, sub_self_div_two, sub_self_div_two, div_lt_div_right (zero_lt_two' \u03b1)]\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a))) (OfNat.ofNat.{u1} \u03b1 2 (OfNat.mk.{u1} \u03b1 2 (bit0.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (instAtLeastTwoHAddNatInstHAddInstAddNatOfNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a))) (OfNat.ofNat.{u1} \u03b1 2 (instOfNat.{u1} \u03b1 2 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\n/-- An inequality involving `2`. -/\ntheorem sub_one_div_inv_le_two (a2 : 2 \u2264 a) : (1 - 1 / a)\u207b\u00b9 \u2264 2 :=\n  by\n  -- Take inverses on both sides to obtain `2\u207b\u00b9 \u2264 1 - 1 / a`\n  refine' (inv_le_inv_of_le (inv_pos.2 <| zero_lt_two' \u03b1) _).trans_eq (inv_inv (2 : \u03b1))\n  -- move `1 / a` to the left and `1 - 1 / 2 = 1 / 2` to the right to obtain `1 / a \u2264 \u215f 2`\n  refine' (le_sub_iff_add_le.2 (_ : _ + 2\u207b\u00b9 = _).le).trans ((sub_le_sub_iff_left 1).2 _)\n  \u00b7-- show 2\u207b\u00b9 + 2\u207b\u00b9 = 1\n    exact (two_mul _).symm.trans (mul_inv_cancel two_ne_zero)\n  \u00b7-- take inverses on both sides and use the assumption `2 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {s : Set.{u1} \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) -> (IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) s b) -> (IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Set.image.{u1, u1} \u03b1 \u03b1 (fun (b : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b) s) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {s : Set.{u1} \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a) -> (IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) s b) -> (IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (Set.image.{u1, u1} \u03b1 \u03b1 (fun (b : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a b) s) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a b))\nCase conversion may be inaccurate. Consider using '#align is_lub.mul_left IsLUB.mul_left\u2093'. -/\n-- TODO: Generalize to `linear_ordered_semifield`\ntheorem IsLUB.mul_left {s : Set \u03b1} (ha : 0 \u2264 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  \u00b7 exact (OrderIso.mulLeft\u2080 _ ha).isLUB_image'.2 hs\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {s : Set.{u1} \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) -> (IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) s b) -> (IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Set.image.{u1, u1} \u03b1 \u03b1 (fun (b : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a) s) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {s : Set.{u1} \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a) -> (IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) s b) -> (IsLUB.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (Set.image.{u1, u1} \u03b1 \u03b1 (fun (b : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b a) s) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b a))\nCase conversion may be inaccurate. Consider using '#align is_lub.mul_right IsLUB.mul_right\u2093'. -/\n-- TODO: Generalize to `linear_ordered_semifield`\ntheorem IsLUB.mul_right {s : Set \u03b1} (ha : 0 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b d)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _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\u2093'. -/\ntheorem mul_sub_mul_div_mul_neg_iff (hc : c \u2260 0) (hd : d \u2260 0) :\n    (a * d - b * c) / (c * d) < 0 \u2194 a / c < b / d := by\n  rw [mul_comm b c, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b d)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Iff (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _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\u2093'. -/\ntheorem mul_sub_mul_div_mul_nonpos_iff (hc : c \u2260 0) (hd : d \u2260 0) :\n    (a * d - b * c) / (c * d) \u2264 0 \u2194 a / c \u2264 b / d := by\n  rw [mul_comm b c, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b d))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _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\u2093'. -/\n/- warning: mul_sub_mul_div_mul_neg -> mul_sub_mul_div_mul_neg is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b d)) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b d)) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align mul_sub_mul_div_mul_neg mul_sub_mul_div_mul_neg\u2093'. -/\nalias mul_sub_mul_div_mul_neg_iff \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b d))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _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\u2093'. -/\n/- warning: mul_sub_mul_div_mul_nonpos -> mul_sub_mul_div_mul_nonpos is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b d)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}, (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (Ne.{succ u1} \u03b1 d (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b d)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a d) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b c)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) c d)) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))\nCase conversion may be inaccurate. Consider using '#align mul_sub_mul_div_mul_nonpos mul_sub_mul_div_mul_nonpos\u2093'. -/\nalias mul_sub_mul_div_mul_nonpos_iff \u2194\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a) -> (Exists.{succ u1} \u03b1 (fun (c : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a) -> (Exists.{succ u1} \u03b1 (fun (c : \u03b1) => And (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) b c) a) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _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\u2093'. -/\ntheorem exists_add_lt_and_pos_of_lt (h : b < a) : \u2203 c, b + c < a \u2227 0 < c :=\n  \u27e8(a - b) / 2, add_sub_div_two_lt h, div_pos (sub_pos_of_lt h) zero_lt_two\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (forall (\u03b5 : \u03b1), (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) \u03b5 (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (SubNegMonoid.toHasSub.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))) b \u03b5) a)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (forall (\u03b5 : \u03b1), (GT.gt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) \u03b5 (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 (Ring.toSub.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b \u03b5) a)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) b a)\nCase conversion may be inaccurate. Consider using '#align le_of_forall_sub_le le_of_forall_sub_le\u2093'. -/\ntheorem le_of_forall_sub_le (h : \u2200 \u03b5 > 0, b - \u03b5 \u2264 a) : b \u2264 a :=\n  by\n  contrapose! h\n  simpa only [and_comm' ((0 : \u03b1) < _), 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) b) -> (Iff (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b b)) (Eq.{succ u1} \u03b1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b) -> (Iff (Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a a) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b b)) (Eq.{succ u1} \u03b1 a b))\nCase conversion may be inaccurate. Consider using '#align mul_self_inj_of_nonneg mul_self_inj_of_nonneg\u2093'. -/\ntheorem mul_self_inj_of_nonneg (a0 : 0 \u2264 a) (b0 : 0 \u2264 b) : a * a = b * b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (LinearOrder.min.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (LinearOrder.max.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))) a b) c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (Min.min.{u1} \u03b1 (LinearOrderedRing.toMin.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (Max.max.{u1} \u03b1 (LinearOrderedRing.toMax.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\ntheorem min_div_div_right_of_nonpos (hc : c \u2264 0) (a b : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))))) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (LinearOrder.max.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) b c)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (LinearOrder.min.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))) a b) c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {c : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (CommMonoidWithZero.toZero.{u1} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u1} \u03b1 (Semifield.toCommGroupWithZero.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) -> (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (Max.max.{u1} \u03b1 (LinearOrderedRing.toMax.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) b c)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (Min.min.{u1} \u03b1 (LinearOrderedRing.toMin.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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\u2093'. -/\ntheorem max_div_div_right_of_nonpos (hc : c \u2264 0) (a b : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) a)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) a)) (Inv.inv.{u1} \u03b1 (LinearOrderedField.toInv.{u1} \u03b1 _inst_1) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a))\nCase conversion may be inaccurate. Consider using '#align abs_inv abs_inv\u2093'. -/\ntheorem abs_inv (a : \u03b1) : |a\u207b\u00b9| = (|a|)\u207b\u00b9 :=\n  map_inv\u2080 (absHom : \u03b1 \u2192*\u2080 \u03b1) a\n#align abs_inv abs_inv\n\n/- warning: abs_div -> abs_div is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) a b)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b1 (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) a b)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) b))\nCase conversion may be inaccurate. Consider using '#align abs_div abs_div\u2093'. -/\ntheorem abs_div (a b : \u03b1) : |a / b| = |a| / |b| :=\n  map_div\u2080 (absHom : \u03b1 \u2192*\u2080 \u03b1) 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) a)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a))\nCase conversion may be inaccurate. Consider using '#align abs_one_div abs_one_div\u2093'. -/\ntheorem abs_one_div (a : \u03b1) : |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 \u2190 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 \u00d7 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 (\u03b1 : Type u)\n| leaf (a : \u03b1) : Foo\n| node (left : Foo) (right : Foo) : Foo\n| cons (head : \u03b1) (tail : Foo) : Foo\n\ndef Foo.elim {\u03b1 : Type u} (C : Foo \u03b1 \u2192 Foo \u03b1 \u2192 Sort v) (x y : Foo \u03b1)\n  (h\u2081 : forall (a\u2081 a\u2082 : \u03b1), C (Foo.leaf a\u2081) (Foo.leaf a\u2082))\n  (h\u2082 : forall (l\u2081 r\u2081 l\u2082 r\u2082 : Foo \u03b1), C (Foo.node l\u2081 r\u2081) (Foo.node l\u2082 r\u2082))\n  (h\u2083 : forall (h\u2081 t\u2081 h\u2082 t\u2082), C (Foo.cons h\u2081 t\u2081) (Foo.cons h\u2082 t\u2082))\n  (h\u2084 : forall (x y), C x y)\n  : C x y :=\nFoo.casesOn x\n  (fun a\u2081 => Foo.casesOn y\n    (fun a\u2082 => h\u2081 a\u2081 a\u2082)\n    (fun l\u2082 r\u2082 => h\u2084 (Foo.leaf a\u2081) (Foo.node l\u2082 r\u2082))\n    (fun h\u2082 t\u2082 => h\u2084 (Foo.leaf a\u2081) (Foo.cons h\u2082 t\u2082)))\n  (fun l\u2081 r\u2081 => Foo.casesOn y\n    (fun a\u2082    => h\u2084 (Foo.node l\u2081 r\u2081) (Foo.leaf a\u2082))\n    (fun l\u2082 r\u2082 => h\u2082 l\u2081 r\u2081 l\u2082 r\u2082)\n    (fun h\u2082 t\u2082 => h\u2084 (Foo.node l\u2081 r\u2081) (Foo.cons h\u2082 t\u2082)))\n  (fun h\u2081 t\u2081 => Foo.casesOn y\n    (fun a\u2082    => h\u2084 (Foo.cons h\u2081 t\u2081) (Foo.leaf a\u2082))\n    (fun l\u2082 r\u2082 => h\u2084 (Foo.cons h\u2081 t\u2081) (Foo.node l\u2082 r\u2082))\n    (fun h\u2082 t\u2082 => h\u2083 h\u2081 t\u2081 h\u2082 t\u2082))\n\ndef f : List Nat \u2192 List Nat \u2192 List Nat\n| x::xs, _   => []\n| _,     []  => []\n| xs,    ys  => xs ++ ys\n\ndef List.elim (C : List Nat \u2192 List Nat \u2192 Sort v) (xs ys : List Nat)\n  (h\u2081 : forall x xs ys, C (x::xs) ys)\n  (h\u2082 : forall xs,      C xs [])\n  (h\u2083 : forall xs ys,   C xs ys)\n  : C xs ys :=\nList.casesOn xs\n  (List.casesOn ys\n     (h\u2082 [])\n     (fun y ys => h\u2083 [] (y::ys)))\n  (fun x xs => h\u2081 x xs ys)\n\ntheorem List.elim.eq1 (C : List Nat \u2192 List Nat \u2192 Sort v)\n  (h\u2081 : forall x xs ys, C (x::xs) ys)\n  (h\u2082 : forall xs,      C xs [])\n  (h\u2083 : forall xs ys,   C xs ys)\n  (x : Nat) (xs ys : List Nat)\n  : List.elim C (x::xs) ys h\u2081 h\u2082 h\u2083 = h\u2081 x xs ys :=\nrfl\n\ntheorem List.elim.eq2 (C : List Nat \u2192 List Nat \u2192 Sort v)\n  (h\u2081 : forall x xs ys, C (x::xs) ys)\n  (h\u2082 : forall xs,      C xs [])\n  (h\u2083 : forall xs ys,   C xs ys)\n  (xs : List Nat)\n  : (forall x' xs', xs = x'::xs' \u2192 False) \u2192 List.elim C xs [] h\u2081 h\u2082 h\u2083 = h\u2082 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 \u2192 List Nat \u2192 Sort v)\n  (h\u2081 : forall x xs ys, C (x::xs) ys)\n  (h\u2082 : forall xs,      C xs [])\n  (h\u2083 : forall xs ys,   C xs ys)\n  (xs : List Nat) (ys : List Nat)\n  : (forall x' xs', xs = x'::xs' \u2192 False) \u2192 (ys = [] \u2192 False) \u2192 List.elim C xs ys h\u2081 h\u2082 h\u2083 = h\u2083 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 \u2192 List Nat \u2192 Sort v)\n  (h\u2081 : forall x xs ys, C (x::xs) ys)\n  (h\u2082 : forall xs,      C xs [])\n  (h\u2083 : forall xs ys,   C xs ys)\n  (y : Nat) (ys : List Nat)\n  : List.elim C [] (y::ys) h\u2081 h\u2082 h\u2083 = h\u2083 [] (y::ys) :=\nrfl\n\ndef List.elim2 (C : List Nat \u2192 List Nat \u2192 Sort v) (xs ys : List Nat)\n  (h\u2081 : forall x xs ys, C (x::xs) ys)\n  (h\u2082 : forall xs,    (forall (x' : Nat) (xs' : List Nat), xs = x' :: xs' \u2192 False) \u2192 C xs [])\n  (h\u2083 : forall xs ys, (forall (x' : Nat) (xs' : List Nat), xs = x' :: xs' \u2192 False) \u2192 (ys = [] \u2192 False) \u2192 C xs ys)\n  : C xs ys :=\nList.casesOn xs\n  (List.casesOn ys\n     (h\u2082 [] (fun _ _ h => List.noConfusion h))\n     (fun y ys => h\u2083 [] (y::ys) (fun _ _ h => List.noConfusion h) (fun h => List.noConfusion h)))\n  (fun x xs => h\u2081 x xs ys)\n\ndef List.elim3 (C : List Nat \u2192 List Nat \u2192 List Nat \u2192 Sort v) (xs ys zs : List Nat)\n  (h\u2081 : forall zs,       C [] [] zs)\n  (h\u2082 : forall xs ys,    C xs ys [])\n  (h\u2083 : forall xs ys zs, C xs ys zs)\n  : C xs ys zs :=\nList.casesOn xs\n  (List.casesOn ys\n     (h\u2081 zs)\n     (fun y ys => List.casesOn zs\n        (h\u2083 [] (y::ys) [])\n        (fun z zs => h\u2083 [] (y::ys) (z::zs))))\n  (fun x xs =>\n    (List.casesOn zs\n      (h\u2082 (x::xs) ys)\n      (fun z zs => h\u2083 (x::xs) ys (z::zs))))\n\ntheorem List.elim3.eq (C : List Nat \u2192 List Nat \u2192 List Nat \u2192 Sort v)\n  (h\u2081 : forall zs,       C [] [] zs)\n  (h\u2082 : forall xs ys,    C xs ys [])\n  (h\u2083 : forall xs ys zs, C xs ys zs)\n  (xs ys zs : List Nat)\n  : (xs = [] \u2192 ys = [] \u2192 False) \u2192 (zs = [] \u2192 False) \u2192 List.elim3 C xs ys zs h\u2081 h\u2082 h\u2083 = h\u2083 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 \u2192 List Nat \u2192 List Nat \u2192 Sort v)\n  (h\u2081 : forall zs,       C [] [] zs)\n  (h\u2082 : forall xs ys,    C xs ys [])\n  (h\u2083 : 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\u2081 h\u2082 h\u2083 = h\u2083 [] (y::ys) (z::zs) :=\nrfl\n\ntheorem List.elim3.eq.b (C : List Nat \u2192 List Nat \u2192 List Nat \u2192 Sort v)\n  (h\u2081 : forall zs,       C [] [] zs)\n  (h\u2082 : forall xs ys,    C xs ys [])\n  (h\u2083 : 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\u2081 h\u2082 h\u2083 = h\u2083 (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 \u2192+* 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 \u2192+* S} {I : ideal S} {r : S} (hr : r \u2208 I) {p : polynomial R}\n    (hp : polynomial.eval\u2082 f r p \u2208 I) : polynomial.coeff p 0 \u2208 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 \u2192+* S} {I : ideal S} {r : S} (hr : r \u2208 I) {p : polynomial R}\n    (hp : polynomial.eval\u2082 f r p = 0) : polynomial.coeff p 0 \u2208 comap f I :=\n  coeff_zero_mem_comap_of_root_mem_of_eval_mem hr (Eq.symm hp \u25b8 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 \u2192+* S} {I : ideal S} {r : S}\n    (r_non_zero_divisor : \u2200 {x : S}, x * r = 0 \u2192 x = 0) (hr : r \u2208 I) {p : polynomial R}\n    (p_ne_zero : p \u2260 0) (hp : polynomial.eval\u2082 f r p = 0) :\n    \u2203 (i : \u2115), polynomial.coeff p i \u2260 0 \u2227 polynomial.coeff p i \u2208 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 \u2192+* S} {I : ideal S} {r : S} (r_ne_zero : r \u2260 0) (hr : r \u2208 I)\n    {p : polynomial R} (p_ne_zero : p \u2260 0) (hp : polynomial.eval\u2082 f r p = 0) :\n    \u2203 (i : \u2115), polynomial.coeff p i \u2260 0 \u2227 polynomial.coeff p i \u2208 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 \u2192+* S} {I : ideal S} {J : ideal S} [is_prime I]\n    (hIJ : I \u2264 J) {r : S} (hr : r \u2208 \u2191J \\ \u2191I) {p : polynomial R}\n    (p_ne_zero : polynomial.map (quotient.mk (comap f I)) p \u2260 0)\n    (hpI : polynomial.eval\u2082 f r p \u2208 I) :\n    \u2203 (i : \u2115), polynomial.coeff p i \u2208 \u2191(comap f J) \\ \u2191(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 \u2192+* S} {I : ideal S} {r : S} (r_ne_zero : r \u2260 0) (hr : r \u2208 I) {p : polynomial R}\n    (p_ne_zero : p \u2260 0) (hp : polynomial.eval\u2082 f r p = 0) : comap f I \u2260 \u22a5 :=\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 \u2192+* S} {I : ideal S} {J : ideal S} [is_prime I] (hIJ : I \u2264 J) {r : S}\n    (hr : r \u2208 \u2191J \\ \u2191I) {p : polynomial R}\n    (p_ne_zero : polynomial.map (quotient.mk (comap f I)) p \u2260 0) (hp : polynomial.eval\u2082 f r p \u2208 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 \u2260 0) (x_mem : x \u2208 I)\n    (hx : is_algebraic R x) : comap (algebra_map R S) I \u2260 \u22a5 :=\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 \u2260 0) (x_mem : x \u2208 I)\n    (hx : is_integral R x) : comap (algebra_map R S) I \u2260 \u22a5 :=\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 = \u22a5) : I = \u22a5 :=\n  sorry\n\ntheorem mem_of_one_mem {S : Type u_2} [integral_domain S] {I : ideal S} (h : 1 \u2208 I) (x : S) :\n    x \u2208 I :=\n  Eq.symm (iff.mpr (eq_top_iff_one I) h) \u25b8 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 \u2264 J)\n    {x : S} (mem : x \u2208 \u2191J \\ \u2191I) (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 \u2192+* 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 \u2192+* 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 \u21a5(integral_closure R S)}\n    (I_ne_bot : I \u2260 \u22a5) : comap (algebra_map R \u21a5(integral_closure R S)) I \u2260 \u22a5 :=\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 \u21a5(integral_closure R S)} :\n    comap (algebra_map R \u21a5(integral_closure R S)) I = \u22a5 \u2192 I = \u22a5 :=\n  imp_of_not_imp_not (comap (algebra_map R \u21a5(integral_closure R S)) I = \u22a5) (I = \u22a5)\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 \u21a5(integral_closure R S)}\n    {J : ideal \u21a5(integral_closure R S)} [is_prime I] (I_lt_J : I < J) :\n    comap (algebra_map R \u21a5(integral_closure R S)) I <\n        comap (algebra_map R \u21a5(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 \u21a5(integral_closure R S)) [is_prime I]\n    (hI : is_maximal (comap (algebra_map R \u21a5(integral_closure R S)) I)) : is_maximal I :=\n  is_maximal_of_is_integral_of_is_maximal_comap\n    (fun (x : \u21a5(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 \u2264 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) \u2264 P) :\n    \u2203 (Q : ideal S), is_prime Q \u2227 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 \u2264 P) :\n    \u2203 (Q : ideal S), \u2203 (H : Q \u2265 I), is_prime Q \u2227 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 \u2264 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) \u2264 P) :\n    \u2203 (Q : ideal S), is_maximal Q \u2227 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 ) \u2243\u2090[K] \n(polynomial K \u29f8 (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) \u2243\u2090[K] \n(polynomial K \u29f8 (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) \u2243\u2090[K] \n(polynomial K \u29f8 (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) \u2192 ( all_rel_inv A')  \u2192 all_rel_inv (A \u00d7 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 {\u03b9 : Type v} [finite \u03b9] (f : \u03b9 \u2192 ideal R) (hf : \u2200 (i j : \u03b9), i \u2260 j \u2192 f i \u2294 f j = \u22a4) :\n(R \u29f8 \u2a05 (i : \u03b9), f i) \u2243+* \u03a0 (i : \u03b9), R \u29f8 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: \u2203 (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: \u2203 (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 \u2260 0) (hcov : covers_0 e) (ha_in_span : a \u2208 ((ideal.span {e} : ideal A)) ) : \na * e = a \u2227 \n( \u2203 (b : A), b \u2208 ((ideal.span {e} : ideal A)) \u2227 a * b = e)\n\n-- This theorem states that a finite dimensional algebra has a \n-- finite set of atoms with sup = \u22a4:\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\u2203 (s : finset (idempotent_cri A)), (\u2200 e \u2208 s, \u22a5 \u22d6 e) \u2227 boolean_algebra_finset_sup s = \u22a4 \n\nAtoms are pairwise disjoint. Therefore, boolean_algebra_finset_sup s = \u22a4 means\nthat their sum is 1. \n\nWe have the direct sum decomposition of elements (a:A): a = a * 1 = a * \u03a3 a * ei,\nwhere ei are the atoms. This decomposition is unique, because ei \u2260 ej implies ei * ej = 0.\nThis means that A = \u03a0 (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": "/-\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.analysis.specific_limits\nimport Mathlib.PostPort\n\nuniverses u_1 \n\nnamespace Mathlib\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\ntheorem hofer {X : Type u_1} [metric_space X] [complete_space X] (x : X) (\u03b5 : \u211d) (\u03b5_pos : 0 < \u03b5)\n    {\u03d5 : X \u2192 \u211d} (cont : continuous \u03d5) (nonneg : \u2200 (y : X), 0 \u2264 \u03d5 y) :\n    \u2203 (\u03b5' : \u211d),\n        \u2203 (H : \u03b5' > 0),\n          \u2203 (x' : X),\n            \u03b5' \u2264 \u03b5 \u2227\n              dist x' x \u2264 bit0 1 * \u03b5 \u2227\n                \u03b5 * \u03d5 x \u2264 \u03b5' * \u03d5 x' \u2227 \u2200 (y : X), dist x' y \u2264 \u03b5' \u2192 \u03d5 y \u2264 bit0 1 * \u03d5 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/hofer_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7879312056025699, "lm_q2_score": 0.6076631698328916, "lm_q1q2_score": 0.47879677400670945}}
{"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 : \u2115) (x y : \u2115 \u2192 \u211d)\n\nopen_locale big_operators\n\n-- finset.range j = finset.Ico 0 j = [0,j)\n\ndef majorizes_le : Prop :=\n  \u2200 j < d, \u2211 (i : \u2115) in finset.Ico 1 (j.succ), y i \u2264 \u2211 (i : \u2115) in finset.Ico 1 (j.succ), x i\n\ndef majorizes_eq : Prop :=\n  \u2211 (i : \u2115) in finset.Ico 1 (d.succ), y i = \u2211 (i : \u2115) in finset.Ico 1 (d.succ), x i\n\ndef T := \u2211 (j : \u2115) in finset.Ico 1 (d.succ), j \u2022 (y j - x j)\n\nlemma T_one (x y : \u2115 \u2192 \u211d) (h_maj : majorizes_eq d x y) :\n  T d x y = \u2211 (i : \u2115) in finset.Ico 1 (d.succ), \u2211 (j : \u2115) in finset.Ico 1 i, (x j - y j) :=\nbegin\n  rw T,\n  have : \u2200 (j : \u2115), j \u2022 (y j - x j) = \u2211 (i : \u2115) in finset.Ico 1 (j.succ), (y j - x j) :=\n  \u03bb (j : \u2115), 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 : \u2211 (j : \u2115) in finset.Ico 1 (d.succ), \u2211 (i : \u2115) in finset.Ico 1 (j.succ), (y j - x j)\n    = \u2211 (i : \u2115) in finset.Ico 1 (d.succ), \u2211 (j : \u2115) 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, \u2190 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 : \u2115 \u2192 \u211d) (h_maj : majorizes_eq d x y) :\n  T d x y = \u2211 (i : \u2115) in finset.Ico 1 (d.succ), \u2211 (j : \u2115) in finset.Ico 1 i.succ, (x j - y j) :=\nbegin\n  rw T_one d x y h_maj,\n  have : \u2211 (i : \u2115) in finset.Ico 1 d.succ, \u2211 (j : \u2115) in finset.Ico 1 i.succ, (x j - y j) = \n    \u2211 (i : \u2115) in finset.Ico 1 d.succ, (\u2211 (j : \u2115) 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 : \u2115 \u2192 \u211d) (h_d : 1 \u2264 d) (h_maj : majorizes_eq d x y) :\n  T d x y = \u2211 (i : \u2115) in finset.Ico 1 d, \u2211 (j : \u2115) 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 : \u2115 \u2192 \u211d) (h_d : 1 \u2264 d) (h_maj : majorizes_eq d x y) :\n  2 \u2022 (T d x y) = \u2211 (i : \u2115) in finset.Ico 1 d, 2 \u2022 \u2211 (j : \u2115) 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 : \u2115 \u2192 \u211d) (h_d : 1 \u2264 d) :\n  \u2211 (j : \u2115) in finset.Ico 1 d.succ, |x j - y j| = \u2211 (j : \u2115) 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 : \u2115 \u2192 \u211d) (h_d : 1 \u2264 d) (h_maj : majorizes_eq d x y) (h_majle : majorizes_le d x y):\n  |x d - y d| = \u2211 (j : \u2115) in finset.Ico 1 d, (x j - y j) :=\nbegin\n  have : \u2211 (j : \u2115) 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 = \u2211 (j : \u2115) 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 \u2190 this,\n    norm_num,\n    exact h_d,\n  end,\n  rw this,\n  have : \u2211 (j : \u2115) in finset.Ico 1 d, (x j - y j) = - \u2211 (j : \u2115) 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 : \u2115 \u2192 \u211d) (h_d : 1 \u2264 d) (h_maj : majorizes_eq d x y) (h_majle : majorizes_le d x y) :\n  \u2211 (j : \u2115) in finset.Ico 1 d.succ, |x j - y j| = \u2211 (j : \u2115) 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 : \u2115 \u2192 \u211d) (h_d : 1 \u2264 d) (h_majle : majorizes_le d x y) (h_maj : majorizes_eq d x y):\n  \u2211 (j : \u2115) in finset.Ico 1 d, (|x j - y j| + (x j - y j)) \u2264 2 \u2022 (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 \u2264 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 \u2265 2), K' n (even n \u2265 2), T n (n \u2265 1)\n\ninductive Kodaira where\n  | I     : Nat \u2192 Kodaira --for both I0 and In with n > 0\n  | II    : Kodaira\n  | III   : Kodaira\n  | IV    : Kodaira\n  | Is    : Nat \u2192 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 \u2192 Kodaira -- only occurs for n \u2265 2\n  | K'    : Nat \u2192 Kodaira -- only occurs for even n \u2265 2\n  | T     : Nat \u2192 Kodaira -- only occurs for n \u2265 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 \u2194 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 \u2194 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 \u2192 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 \u2192 Type v) (g : Type u' \u2192 Type v') extends functor_pair f g :=\n (f_appl : applicative f)\n (g_appl : applicative g)\n (map_pure_comm : \u2200 {\u03b1 \u03b2}\n            (hp : \u03b1 \u2192 \u03b2)\n            (x : \u03b1),\n    map hp (pure x) = pure (hp x))\n (map_seq_comm : \u2200 {\u03b1 \u03b2 : Type u} {\u03b1' \u03b2' : Type u'}\n            (h : \u03b2 \u2192 \u03b2')\n            (hx : (\u03b1 \u2192 \u03b2) \u2192 (\u03b1' \u2192 \u03b2'))\n            (hy : \u03b1 \u2192 \u03b1')\n            (x : f (\u03b1 \u2192 \u03b2))\n            (y : f \u03b1),\n    (\u2200 F y, hx F (hy y) = h (F y)) \u2192\n    map h (x <*> y) = map hx x <*> map hy y)\n\nsection lemmas\n\nvariables {\u03b1 \u03b2 \u03b3 : Type u}\nvariables {f : Type u \u2192 Type v}\nvariables [applicative f] [is_lawful_applicative f]\n\nopen function applicative is_lawful_applicative\n\nsection\n\nvariables (g : \u03b2 \u2192 \u03b3)\nvariables (x : f (\u03b1 \u2192 \u03b2)) (y : f \u03b1)\n\nlemma  applicative.map_seq_assoc\n: @functor.map f _ _ _ g (x <*> y) = comp g <$> x <*> y :=\nby rw [\u2190 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 : \u03b1 \u2192 \u03b2)\nvariables (x : f (\u03b2 \u2192 \u03b3)) (y : f \u03b1)\n\nlemma applicative.seq_map_comm\n: x <*> g <$> y = flip comp g <$> x <*> y :=\nbegin\n  rw [\u2190 pure_seq_eq_map _ y,seq_assoc,seq_pure,\u2190 comp_map],\n  refl,\nend\n\n-- lemma d\n-- : (has_seq.seq \u2218 functor.map comp : f (\u03b1 \u2192 \u03b2) \u2192 f (\u03b3 \u2192 \u03b1) \u2192 f (\u03b3 \u2192 \u03b2)) = _ :=\n-- begin\n--   apply funext, intro x,\n--   apply funext, intro y,\n--   unfold comp functor.map,\n--   rw [\u2190 right_id comp,functor.map_comp],\n-- end\n\nend\n\nattribute [norm] map_seq\n\n@[norm]\nlemma seq_map {\u03b2 \u03b3 \u03c3 : Type u} (h : \u03c3 \u2192 \u03b2) (x : f (\u03b2 \u2192 \u03b3)) (y : f \u03c3) :\n  x <*> (h <$> y) = (flip comp h) <$> x <*> y :=\nbegin\n  rw [\u2190 pure_seq_eq_map,\u2190 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type u'}\n\ndef pure : \u03b1 \u2192 identity \u03b1 := identity.mk\n\ndef seq : identity (\u03b1 \u2192 \u03b2) \u2192 identity \u03b1 \u2192 identity \u03b2\n  | \u27e8 f \u27e9 \u27e8 x \u27e9 := \u27e8 f x \u27e9\n\nlocal infix <$> := map\nlocal infix <*> := seq\n\nprotected lemma pure_seq_eq_map (g : \u03b1 \u2192 \u03b2) : \u2200 (x : identity \u03b1), pure g <*> x = g <$> x\n  | \u27e8 x \u27e9 := rfl\n\nprotected lemma map_pure (g : \u03b1 \u2192 \u03b2) (x : \u03b1)\n: g <$> pure x = pure (g x) :=\nrfl\n\nprotected lemma seq_pure : \u2200 (g : identity (\u03b1 \u2192 \u03b2)) (x : \u03b1),\n  g <*> pure x = (\u03bb g : \u03b1 \u2192 \u03b2, g x) <$> g\n  | \u27e8 g \u27e9 x := rfl\n\nprotected lemma seq_assoc : \u2200 (x : identity \u03b1) (g : identity (\u03b1 \u2192 \u03b2)) (h : identity (\u03b2 \u2192 \u03b3)),\n  h <*> (g <*> x) = (@comp \u03b1 \u03b2 \u03b3 <$> h) <*> g <*> x\n| \u27e8 x \u27e9 \u27e8 g \u27e9 \u27e8 h \u27e9 := 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 {\u03b1 : Type v} (x : \u03b1)\n: identity.mk x = pure x := rfl\n\nlemma identity.seq_mk {\u03b1 \u03b2 : Type v}  (f : \u03b1 \u2192 \u03b2) (x : \u03b1)\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 \u03b1 \u03b2 \u03b1' \u03b2',\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 \u2192 Type u'} {g : Type v \u2192 Type u}\n\nvariables [applicative f] [applicative g]\nsection\nvariables {\u03b1 \u03b2 \u03b3 : Type v}\n\ndef seq : compose f g (\u03b1 \u2192 \u03b2) \u2192 compose f g \u03b1 \u2192 compose f g \u03b2\n  | \u27e8 h \u27e9 \u27e8 x \u27e9 := \u27e8 has_seq.seq <$> h <*> x \u27e9\n\ndef pure : \u03b1 \u2192 compose f g \u03b1 := compose.mk \u2218 has_pure.pure \u2218 has_pure.pure\nend\n\nvariables [is_lawful_applicative f] [is_lawful_applicative g]\nvariables {\u03b1 \u03b2 \u03b3 : Type v}\n\nlocal infix ` <$> ` := map\nlocal infix ` <*> ` := seq\n\nprotected lemma map_pure (h : \u03b1 \u2192 \u03b2) (x : \u03b1) : (h <$> pure x : compose f g \u03b2) = 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 (\u03b1 \u2192 \u03b2)) (x : \u03b1)\n: h <*> pure x = (\u03bb g : \u03b1 \u2192 \u03b2, 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 : \u2200 (x : compose f g \u03b1) (h\u2080 : compose f g (\u03b1 \u2192 \u03b2)) (h\u2081 : compose f g (\u03b2 \u2192 \u03b3)),\n   h\u2081 <*> (h\u2080 <*> x) = (@comp \u03b1 \u03b2 \u03b3 <$> h\u2081) <*> h\u2080 <*> x\n| \u27e8 x \u27e9 \u27e8 h\u2080 \u27e9 \u27e8 h\u2081 \u27e9 :=\nby { simp! [comp,flip] with norm, }\n\nlemma pure_seq_eq_map (h : \u03b1 \u2192 \u03b2) : \u2200 (x : compose f g \u03b1), pure h <*> x = h <$> x\n  | \u27e8 x \u27e9 :=\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 \u2192 Type u'} {g : Type v \u2192 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 \u2192 Type u'} {g : Type v \u2192 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 {\u03b1 \u03b2 : Type u'}\n  {f : Type u \u2192 Type v} {g : Type u' \u2192 Type u}\n  [applicative f] [applicative g]\n  (h : f (g (\u03b1 \u2192 \u03b2))) (x : f (g \u03b1))\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  \u2192 Type w}  {g  : Type u  \u2192 Type v}\nparameters {f' : Type v' \u2192 Type w'} {g' : Type u' \u2192 Type v'}\nparameters [applicative_pair f f'] [applicative_pair g g']\nparameters {\u03b1 \u03b2 : Type u} {\u03b1' \u03b2' : 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 : \u03b1 \u2192 \u03b2') (x : \u03b1)\n:   functor_pair.map (compose f' g') hp (compose.pure x : compose f g \u03b1)\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 : \u03b2 \u2192 \u03b2') (hx : (\u03b1 \u2192 \u03b2) \u2192 \u03b1' \u2192 \u03b2') (hy : \u03b1 \u2192 \u03b1')\n                   (x : compose f g (\u03b1 \u2192 \u03b2)) (y : compose f g \u03b1)\n                   (H : \u2200 (F : \u03b1 \u2192 \u03b2) (y : \u03b1), 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 \u03b1 \u2192 g \u03b2) := functor.map has_seq.seq x,\n  let h' : g \u03b2 \u2192 g' \u03b2' := (functor_pair.map g' h),\n  let hx' : (g \u03b1 \u2192 g \u03b2) \u2192 g' \u03b1' \u2192 g' \u03b2' := \u03bb F i, functor_pair.map _ h (F sorry),\n  let hy' : g \u03b1 \u2192 g' \u03b1' := functor_pair.map _ hy,\n  let hh := @functor_pair.map g g' _ _ _ h,\n  have H' : (\u2200 (F : g \u03b1 \u2192 g \u03b2) (y : g \u03b1), hx' F (hy' y) = h' (F y)) := sorry,\n  rw @applicative_pair.map_seq_comm f f' _ (g \u03b1) (g \u03b2) (g' \u03b1') (g' \u03b2')\n        h' hx' hy' x' y H',\n  admit,\nend\n\nend applicative_pair\n\nend compose\n\ninstance\n  {f :  Type v  \u2192 Type w}  {g  : Type u  \u2192 Type v}\n  {f' : Type v' \u2192 Type w'} {g' : Type u' \u2192 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 \u2192 Type v} [functor m] {\u03b1 \u03c6 : Type u} (f : \u03b1 \u2192 \u03c6) (ma : m \u03b1) : m \u03c6 :=\nf <$> ma\n\nvariables {m : Type u \u2192 Type v} [applicative m]\ndef lift\u2082\n  {\u03b1\u2081 \u03b1\u2082 \u03c6 : Type u}\n  (f : \u03b1\u2081 \u2192 \u03b1\u2082 \u2192 \u03c6)\n  (ma\u2081 : m \u03b1\u2081) (ma\u2082: m \u03b1\u2082) : m \u03c6 :=\nf <$> ma\u2081 <*> ma\u2082\n\ndef mmap\u2082\n  {\u03b1\u2081 \u03b1\u2082 \u03c6 : Type u}\n  (f : \u03b1\u2081 \u2192 \u03b1\u2082 \u2192 m \u03c6)\n: \u03a0 (ma\u2081 : list \u03b1\u2081) (ma\u2082: list \u03b1\u2082), m (list \u03c6)\n | (x :: xs) (y :: ys) := (::) <$> f x y <*> mmap\u2082 xs ys\n | _ _ := pure []\n\n\ndef lift\u2083\n  {\u03b1\u2081 \u03b1\u2082 \u03b1\u2083 \u03c6 : Type u}\n  (f : \u03b1\u2081 \u2192 \u03b1\u2082 \u2192 \u03b1\u2083 \u2192 \u03c6)\n  (ma\u2081 : m \u03b1\u2081) (ma\u2082: m \u03b1\u2082) (ma\u2083 : m \u03b1\u2083) : m \u03c6 :=\nf <$> ma\u2081 <*> ma\u2082 <*> ma\u2083\n\ndef lift\u2084\n  {\u03b1\u2081 \u03b1\u2082 \u03b1\u2083 \u03b1\u2084 \u03c6 : Type u}\n  (f : \u03b1\u2081 \u2192 \u03b1\u2082 \u2192 \u03b1\u2083 \u2192 \u03b1\u2084 \u2192 \u03c6)\n  (ma\u2081 : m \u03b1\u2081) (ma\u2082: m \u03b1\u2082) (ma\u2083 : m \u03b1\u2083) (ma\u2084 : m \u03b1\u2084) : m \u03c6 :=\nf <$> ma\u2081 <*> ma\u2082 <*> ma\u2083 <*> ma\u2084\n\ndef lift\u2085\n  {\u03b1\u2081 \u03b1\u2082 \u03b1\u2083 \u03b1\u2084 \u03b1\u2085 \u03c6 : Type u}\n  (f : \u03b1\u2081 \u2192 \u03b1\u2082 \u2192 \u03b1\u2083 \u2192 \u03b1\u2084 \u2192 \u03b1\u2085 \u2192 \u03c6)\n  (ma\u2081 : m \u03b1\u2081) (ma\u2082: m \u03b1\u2082) (ma\u2083 : m \u03b1\u2083) (ma\u2084 : m \u03b1\u2084) (ma\u2085 : m \u03b1\u2085) : m \u03c6 :=\nf <$> ma\u2081 <*> ma\u2082 <*> ma\u2083 <*> ma\u2084 <*> ma\u2085\n\nopen nat\nvariables {\u03b1 : Type u}\nvariables {\u03b2 : Type v}\nvariables {\u03b3 : Type w}\n\ndef replicate : \u2115 \u2192 m \u03b1 \u2192 m (list \u03b1)\n | 0 _ := pure []\n | (succ n) m := (::) <$> m <*> replicate n m\n\ndef replicate' : \u2115 \u2192 m \u03b1 \u2192 m punit\n | 0 _ := pure punit.star\n | (succ n) m := m *> replicate' n m\n\ndef mapp (f : \u03b3 \u2192 \u03b2 \u2192 \u03b1) : list (\u03b3 \u00d7 \u03b2) \u2192 list \u03b1\n | [ ] := [ ]\n | ((x,y) :: xs) := f x y :: mapp xs\n\ndef mmapp (f : \u03b3 \u2192 \u03b2 \u2192 m \u03b1) : list (\u03b3 \u00d7 \u03b2) \u2192 m (list \u03b1)\n | [ ] := pure [ ]\n | ((x,y) :: xs) := (::) <$> f x y <*> mmapp xs\n\ndef mmapp' (f : \u03b3 \u2192 \u03b2 \u2192 m \u03b1) : list (\u03b3 \u00d7 \u03b2) \u2192 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 \u201cAdic Spaces\u201d ([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 * `\u2200 x y, v (x + y) \u2264 max (v x) (v y)`\n\n`valuation R \u0393\u2080`is the type of valuations `R \u2192 \u0393\u2080`, with a coercion to the underlying\nfunction. If `v` is a valuation from `R` to `\u0393\u2080` then the induced group\nhomomorphism `units(R) \u2192 \u0393\u2080` is called `unit_map v`.\n\nThe equivalence \"relation\" `is_equiv v\u2081 v\u2082 : Prop` defined in 1.27 of [wedhorn_adic] is not strictly\nspeaking a relation, because `v\u2081 : valuation R \u0393\u2081` and `v\u2082 : valuation R \u0393\u2082` might\nnot have the same type. This corresponds in ZFC to the set-theoretic difficulty\nthat the class of all valuations (as `\u0393\u2080` 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 \u0393\u2080` is `supp v`. If `J` is an ideal of `R`\nwith `h : J \u2286 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 \u0393\u2080`, the type of valuations on `R` with values in `\u0393\u2080`\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\u2080 u\u2081 u\u2082 -- v is used for valuations\n\n/-- The type of \u0393\u2080-valued valuations on R. -/\nstructure valuation (R : Type u_1) (\u0393\u2080 : Type u_2) [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    extends monoid_with_zero_hom R \u0393\u2080 where\n  map_add' : \u2200 (x y : R), to_fun (x + y) \u2264 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 \u2192 \u0393\u2080. -/\nprotected instance has_coe_to_fun (R : Type u_1) (\u0393\u2080 : Type u_2)\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R] : has_coe_to_fun (valuation R \u0393\u2080) :=\n  has_coe_to_fun.mk (fun (_x : valuation R \u0393\u2080) => R \u2192 \u0393\u2080) to_fun\n\n/-- A valuation is coerced to a monoid morphism R \u2192 \u0393\u2080. -/\nprotected instance monoid_with_zero_hom.has_coe (R : Type u_1) (\u0393\u2080 : Type u_2)\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R] :\n    has_coe (valuation R \u0393\u2080) (monoid_with_zero_hom R \u0393\u2080) :=\n  has_coe.mk to_monoid_with_zero_hom\n\n@[simp] theorem coe_coe {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) : \u21d1\u2191v = \u21d1v :=\n  rfl\n\n@[simp] theorem map_zero {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) : coe_fn v 0 = 0 :=\n  map_zero' v\n\n@[simp] theorem map_one {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) : coe_fn v 1 = 1 :=\n  map_one' v\n\n@[simp] theorem map_mul {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) (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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) (x : R) (y : R) :\n    coe_fn v (x + y) \u2264 max (coe_fn v x) (coe_fn v y) :=\n  map_add' v\n\ntheorem map_add_le {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    (v : valuation R \u0393\u2080) {x : R} {y : R} {g : \u0393\u2080} (hx : coe_fn v x \u2264 g) (hy : coe_fn v y \u2264 g) :\n    coe_fn v (x + y) \u2264 g :=\n  le_trans (map_add v x y) (max_le hx hy)\n\ntheorem map_add_lt {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    (v : valuation R \u0393\u2080) {x : R} {y : R} {g : \u0393\u2080} (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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    (v : valuation R \u0393\u2080) {\u03b9 : Type u_3} {s : finset \u03b9} {f : \u03b9 \u2192 R} {g : \u0393\u2080}\n    (hf : \u2200 (i : \u03b9), i \u2208 s \u2192 coe_fn v (f i) \u2264 g) : coe_fn v (finset.sum s fun (i : \u03b9) => f i) \u2264 g :=\n  sorry\n\ntheorem map_sum_lt {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    (v : valuation R \u0393\u2080) {\u03b9 : Type u_3} {s : finset \u03b9} {f : \u03b9 \u2192 R} {g : \u0393\u2080} (hg : g \u2260 0)\n    (hf : \u2200 (i : \u03b9), i \u2208 s \u2192 coe_fn v (f i) < g) : coe_fn v (finset.sum s fun (i : \u03b9) => f i) < g :=\n  sorry\n\ntheorem map_sum_lt' {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    (v : valuation R \u0393\u2080) {\u03b9 : Type u_3} {s : finset \u03b9} {f : \u03b9 \u2192 R} {g : \u0393\u2080} (hg : 0 < g)\n    (hf : \u2200 (i : \u03b9), i \u2208 s \u2192 coe_fn v (f i) < g) : coe_fn v (finset.sum s fun (i : \u03b9) => f i) < g :=\n  map_sum_lt v (ne_of_gt hg) hf\n\n@[simp] theorem map_pow {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) (x : R) (n : \u2115) : 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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    {v\u2081 : valuation R \u0393\u2080} {v\u2082 : valuation R \u0393\u2080} (h : \u2200 (r : R), coe_fn v\u2081 r = coe_fn v\u2082 r) :\n    v\u2081 = v\u2082 :=\n  sorry\n\ntheorem ext_iff {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    {v\u2081 : valuation R \u0393\u2080} {v\u2082 : valuation R \u0393\u2080} : v\u2081 = v\u2082 \u2194 \u2200 (r : R), coe_fn v\u2081 r = coe_fn v\u2082 r :=\n  { mp := fun (h : v\u2081 = v\u2082) (r : R) => congr_arg (fun {v\u2081 : valuation R \u0393\u2080} => coe_fn v\u2081 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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    (v : valuation R \u0393\u2080) : preorder R :=\n  preorder.lift \u21d1v\n\n/-- If `v` is a valuation on a division ring then `v(x) = 0` iff `x = 0`. -/\n@[simp] theorem zero_iff {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] {K : Type u_1}\n    [division_ring K] (v : valuation K \u0393\u2080) {x : K} : coe_fn v x = 0 \u2194 x = 0 :=\n  monoid_with_zero_hom.map_eq_zero (to_monoid_with_zero_hom v)\n\ntheorem ne_zero_iff {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] {K : Type u_1}\n    [division_ring K] (v : valuation K \u0393\u2080) {x : K} : coe_fn v x \u2260 0 \u2194 x \u2260 0 :=\n  monoid_with_zero_hom.map_ne_zero (to_monoid_with_zero_hom v)\n\n@[simp] theorem map_inv {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] {K : Type u_1}\n    [division_ring K] (v : valuation K \u0393\u2080) {x : K} : coe_fn v (x\u207b\u00b9) = (coe_fn v x\u207b\u00b9) :=\n  monoid_with_zero_hom.map_inv' (to_monoid_with_zero_hom v) x\n\ntheorem map_units_inv {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) (x : units R) : coe_fn v \u2191(x\u207b\u00b9) = (coe_fn v \u2191x\u207b\u00b9) :=\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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    (v : valuation R \u0393\u2080) (u : units R) : \u2191(coe_fn (units.map \u2191v) u) = coe_fn v \u2191u :=\n  rfl\n\n@[simp] theorem map_neg {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) (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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) (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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) (x : R) (y : R) :\n    coe_fn v (x - y) \u2264 max (coe_fn v x) (coe_fn v y) :=\n  sorry\n\ntheorem map_add_of_distinct_val {R : Type u_1} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R] (v : valuation R \u0393\u2080) {x : R} {y : R}\n    (h : coe_fn v x \u2260 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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) {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 \u2192 R induces a map valuation R \u0393\u2080 \u2192 valuation S \u0393\u2080 -/\ndef comap {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    {S : Type u_3} [ring S] (f : S \u2192+* R) (v : valuation R \u0393\u2080) : valuation S \u0393\u2080 :=\n  mk (\u21d1v \u2218 \u21d1f) sorry sorry sorry sorry\n\n@[simp] theorem comap_id {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [ring R] (v : valuation R \u0393\u2080) : comap (ring_hom.id R) v = v :=\n  ext fun (r : R) => rfl\n\ntheorem comap_comp {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    (v : valuation R \u0393\u2080) {S\u2081 : Type u_3} {S\u2082 : Type u_4} [ring S\u2081] [ring S\u2082] (f : S\u2081 \u2192+* S\u2082)\n    (g : S\u2082 \u2192+* R) : comap (ring_hom.comp g f) v = comap f (comap g v) :=\n  ext fun (r : S\u2081) => rfl\n\n/-- A \u2264-preserving group homomorphism \u0393\u2080 \u2192 \u0393'\u2080 induces a map valuation R \u0393\u2080 \u2192 valuation R \u0393'\u2080. -/\ndef map {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] {\u0393'\u2080 : Type u_3}\n    [linear_ordered_comm_group_with_zero \u0393'\u2080] [ring R] (f : monoid_with_zero_hom \u0393\u2080 \u0393'\u2080)\n    (hf : monotone \u21d1f) (v : valuation R \u0393\u2080) : valuation R \u0393'\u2080 :=\n  mk (\u21d1f \u2218 \u21d1v) 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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {\u0393'\u2080 : Type u_3} [linear_ordered_comm_group_with_zero \u0393'\u2080] [ring R] (v\u2081 : valuation R \u0393\u2080)\n    (v\u2082 : valuation R \u0393'\u2080) :=\n  \u2200 (r s : R), coe_fn v\u2081 r \u2264 coe_fn v\u2081 s \u2194 coe_fn v\u2082 r \u2264 coe_fn v\u2082 s\n\nnamespace is_equiv\n\n\ntheorem refl {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    {v : valuation R \u0393\u2080} : is_equiv v v :=\n  fun (_x _x_1 : R) => iff.refl (coe_fn v _x \u2264 coe_fn v _x_1)\n\ntheorem symm {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {\u0393'\u2080 : Type u_3} [linear_ordered_comm_group_with_zero \u0393'\u2080] [ring R] {v\u2081 : valuation R \u0393\u2080}\n    {v\u2082 : valuation R \u0393'\u2080} (h : is_equiv v\u2081 v\u2082) : is_equiv v\u2082 v\u2081 :=\n  fun (_x _x_1 : R) => iff.symm (h _x _x_1)\n\ntheorem trans {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {\u0393'\u2080 : Type u_3} [linear_ordered_comm_group_with_zero \u0393'\u2080] {\u0393''\u2080 : Type u_4}\n    [linear_ordered_comm_group_with_zero \u0393''\u2080] [ring R] {v\u2081 : valuation R \u0393\u2080} {v\u2082 : valuation R \u0393'\u2080}\n    {v\u2083 : valuation R \u0393''\u2080} (h\u2081\u2082 : is_equiv v\u2081 v\u2082) (h\u2082\u2083 : is_equiv v\u2082 v\u2083) : is_equiv v\u2081 v\u2083 :=\n  fun (_x _x_1 : R) => iff.trans (h\u2081\u2082 _x _x_1) (h\u2082\u2083 _x _x_1)\n\ntheorem of_eq {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] [ring R]\n    {v : valuation R \u0393\u2080} {v' : valuation R \u0393\u2080} (h : v = v') : is_equiv v v' :=\n  Eq._oldrec refl h\n\ntheorem map {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080] {\u0393'\u2080 : Type u_3}\n    [linear_ordered_comm_group_with_zero \u0393'\u2080] [ring R] {v : valuation R \u0393\u2080} {v' : valuation R \u0393\u2080}\n    (f : monoid_with_zero_hom \u0393\u2080 \u0393'\u2080) (hf : monotone \u21d1f) (inf : function.injective \u21d1f)\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} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {\u0393'\u2080 : Type u_3} [linear_ordered_comm_group_with_zero \u0393'\u2080] [ring R] {v\u2081 : valuation R \u0393\u2080}\n    {v\u2082 : valuation R \u0393'\u2080} {S : Type u_4} [ring S] (f : S \u2192+* R) (h : is_equiv v\u2081 v\u2082) :\n    is_equiv (comap f v\u2081) (comap f v\u2082) :=\n  fun (r s : S) => h (coe_fn f r) (coe_fn f s)\n\ntheorem val_eq {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {\u0393'\u2080 : Type u_3} [linear_ordered_comm_group_with_zero \u0393'\u2080] [ring R] {v\u2081 : valuation R \u0393\u2080}\n    {v\u2082 : valuation R \u0393'\u2080} (h : is_equiv v\u2081 v\u2082) {r : R} {s : R} :\n    coe_fn v\u2081 r = coe_fn v\u2081 s \u2194 coe_fn v\u2082 r = coe_fn v\u2082 s :=\n  sorry\n\ntheorem ne_zero {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    {\u0393'\u2080 : Type u_3} [linear_ordered_comm_group_with_zero \u0393'\u2080] [ring R] {v\u2081 : valuation R \u0393\u2080}\n    {v\u2082 : valuation R \u0393'\u2080} (h : is_equiv v\u2081 v\u2082) {r : R} : coe_fn v\u2081 r \u2260 0 \u2194 coe_fn v\u2082 r \u2260 0 :=\n  eq.mp (Eq._oldrec (Eq.refl (coe_fn v\u2081 r \u2260 0 \u2194 coe_fn v\u2082 r \u2260 coe_fn v\u2082 0)) (map_zero v\u2082))\n    (eq.mp\n      (Eq._oldrec (Eq.refl (coe_fn v\u2081 r \u2260 coe_fn v\u2081 0 \u2194 coe_fn v\u2082 r \u2260 coe_fn v\u2082 0)) (map_zero v\u2081))\n      (not_iff_not_of_iff (val_eq h)))\n\ntheorem Mathlib.valuation.is_equiv_of_map_strict_mono {R : Type u_1} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] {\u0393'\u2080 : Type u_3}\n    [linear_ordered_comm_group_with_zero \u0393'\u2080] [ring R] {v : valuation R \u0393\u2080}\n    (f : monoid_with_zero_hom \u0393\u2080 \u0393'\u2080) (H : strict_mono \u21d1f) :\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 \u2264 coe_fn v y) => strict_mono.monotone H h }\n\ntheorem Mathlib.valuation.is_equiv_of_val_le_one {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] {\u0393'\u2080 : Type u_3}\n    [linear_ordered_comm_group_with_zero \u0393'\u2080] {K : Type u_1} [division_ring K] (v : valuation K \u0393\u2080)\n    (v' : valuation K \u0393'\u2080) (h : \u2200 {x : K}, coe_fn v x \u2264 1 \u2194 coe_fn v' x \u2264 1) : is_equiv v v' :=\n  sorry\n\n/-- The support of a valuation `v : R \u2192 \u0393\u2080` is the ideal of `R` where `v` vanishes. -/\ndef Mathlib.valuation.supp {R : Type u_1} {\u0393\u2080 : Type u_2} [linear_ordered_comm_group_with_zero \u0393\u2080]\n    [comm_ring R] (v : valuation R \u0393\u2080) : 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 \u2208 (supp v : set R) \u2194 v x = 0 := iff.rfl\n\n@[simp] theorem Mathlib.valuation.mem_supp_iff {R : Type u_1} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) (x : R) :\n    x \u2208 supp v \u2194 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} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) :\n    ideal.is_prime (supp v) :=\n  { left :=\n      fun (h : supp v = \u22a4) =>\n        one_ne_zero\n          ((fun (this : 1 = 0) => this)\n            (Eq.trans (Eq.symm (map_one v))\n              ((fun (this : 1 \u2208 supp v) => this)\n                (eq.mpr (id (Eq._oldrec (Eq.refl (1 \u2208 supp v)) h)) trivial)))),\n    right :=\n      fun (x y : R) (hxy : x * y \u2208 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} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) (a : R) {s : R}\n    (h : s \u2208 supp v) : coe_fn v (a + s) = coe_fn v a :=\n  sorry\n\n/-- If `hJ : J \u2286 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} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) {J : ideal R}\n    (hJ : J \u2264 supp v) : ideal.quotient J \u2192 \u0393\u2080 :=\n  fun (q : ideal.quotient J) => quotient.lift_on' q \u21d1v sorry\n\n/-- The extension of valuation v on R to valuation on R/J if J \u2286 supp v -/\ndef Mathlib.valuation.on_quot {R : Type u_1} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) {J : ideal R}\n    (hJ : J \u2264 supp v) : valuation (ideal.quotient J) \u0393\u2080 :=\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} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) {J : ideal R}\n    (hJ : J \u2264 supp v) : comap (ideal.quotient.mk J) (on_quot v hJ) = v :=\n  sorry\n\ntheorem Mathlib.valuation.comap_supp {R : Type u_1} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) {S : Type u_3}\n    [comm_ring S] (f : S \u2192+* R) : supp (comap f v) = ideal.comap f (supp v) :=\n  sorry\n\ntheorem Mathlib.valuation.self_le_supp_comap {R : Type u_1} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (J : ideal R)\n    (v : valuation (ideal.quotient J) \u0393\u2080) : J \u2264 supp (comap (ideal.quotient.mk J) v) :=\n  sorry\n\n@[simp] theorem Mathlib.valuation.comap_on_quot_eq {R : Type u_1} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (J : ideal R)\n    (v : valuation (ideal.quotient J) \u0393\u2080) :\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 \u2286 supp v. -/\ntheorem Mathlib.valuation.supp_quot {R : Type u_1} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) {J : ideal R}\n    (hJ : J \u2264 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} {\u0393\u2080 : Type u_2}\n    [linear_ordered_comm_group_with_zero \u0393\u2080] [comm_ring R] (v : valuation R \u0393\u2080) :\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 \u2964 PresheafedSpace C`,\nwe first build the colimit of the underlying topological spaces,\nas `colimit (F \u22d9 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.\u03b9 (F \u22d9 PresheafedSpace.forget C) j` to `X`.\nSince pushforward is functorial, we obtain a diagram `J \u2964 (presheaf C X)\u1d52\u1d56`\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 \u2964 PresheafedSpace.{v} C) (j) (U) :\n  (F.map (\ud835\udfd9 j)).c.app (op U) =\n    (pushforward.id (F.obj j).presheaf).inv.app (op U) \u226b\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 \u2964 PresheafedSpace.{v} C)\n  [has_colimit F] (U : opens (limits.colimit F).carrier) : J\u1d52\u1d56 \u2964 C :=\n{ obj := \u03bb j, (F.obj (unop j)).presheaf.obj (op ((opens.map (colimit.\u03b9 F (unop j)).base).obj U)),\n  map := \u03bb j k f, (F.map f.unop).c.app _ \u226b (F.obj (unop k)).presheaf.map\n    (eq_to_hom (by { rw [\u2190 colimit.w F f.unop, comp_base], refl })),\n  map_comp' := \u03bb 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, \u2190 (F.obj (unop k)).presheaf.map_comp],\n    erw \u2190 (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)\u1d52\u1d56`.\n-/\n@[simps]\ndef pushforward_diagram_to_colimit (F : J \u2964 PresheafedSpace.{v} C) :\n  J \u2964 (presheaf C (colimit (F \u22d9 PresheafedSpace.forget C)))\u1d52\u1d56 :=\n{ obj := \u03bb j, op ((colimit.\u03b9 (F \u22d9 PresheafedSpace.forget C) j) _* (F.obj j).presheaf),\n  map := \u03bb j j' f,\n  (pushforward_map (colimit.\u03b9 (F \u22d9 PresheafedSpace.forget C) j') (F.map f).c \u226b\n    (pushforward.comp (F.obj j).presheaf ((F \u22d9 PresheafedSpace.forget C).map f)\n      (colimit.\u03b9 (F \u22d9 PresheafedSpace.forget C) j')).inv \u226b\n    (pushforward_eq (colimit.w (F \u22d9 PresheafedSpace.forget C) f) (F.obj j).presheaf).hom).op,\n  map_id' := \u03bb 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' := \u03bb j\u2081 j\u2082 j\u2083 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.\u03b9 (F \u22d9 PresheafedSpace.forget C) j\u2082)).obj (unop U)),\n    -- Now we show the open sets are equal.\n    swap 2,\n    { apply unop_injective,\n      rw \u2190opens.map_comp_obj,\n      congr,\n      exact colimit.w (F \u22d9 PresheafedSpace.forget C) g, },\n    -- Finally, the original goal is now easy:\n    swap 2,\n    { simp, refl, },\n  end, }\n\nvariables [\u2200 X : Top.{v}, has_limits_of_shape J\u1d52\u1d56 (X.presheaf C)]\n\n/--\nAuxiliary definition for `PresheafedSpace.has_colimits`.\n-/\ndef colimit (F : J \u2964 PresheafedSpace.{v} C) : PresheafedSpace C :=\n{ carrier := colimit (F \u22d9 PresheafedSpace.forget C),\n  presheaf := limit (pushforward_diagram_to_colimit F).left_op, }\n\n@[simp] lemma colimit_carrier (F : J \u2964 PresheafedSpace.{v} C) :\n  (colimit F).carrier = limits.colimit (F \u22d9 PresheafedSpace.forget C) := rfl\n\n@[simp] lemma colimit_presheaf (F : J \u2964 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 \u2964 PresheafedSpace.{v} C) : cocone F :=\n{ X := colimit F,\n  \u03b9 :=\n  { app := \u03bb j,\n    { base := colimit.\u03b9 (F \u22d9 PresheafedSpace.forget C) j,\n      c := limit.\u03c0 _ (op j), },\n    naturality' := \u03bb j j' f,\n    begin\n      fapply PresheafedSpace.ext,\n      { ext x,\n        exact colimit.w_apply (F \u22d9 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 \u2190 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\u1d52\u1d56 C]\n\nnamespace colimit_cocone_is_colimit\n\n/--\nAuxiliary definition for `PresheafedSpace.colimit_cocone_is_colimit`.\n-/\ndef desc_c_app (F : J \u2964 PresheafedSpace.{v} C) (s : cocone F) (U : (opens \u21a5(s.X.carrier))\u1d52\u1d56) :\n  s.X.presheaf.obj U \u27f6\n    (colimit.desc (F \u22d9 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, \u03c0 := { app := \u03bb j, _, naturality' := \u03bb j j' f, _, }} \u226b\n      (limit_obj_iso_limit_comp_evaluation _ _).inv,\n  -- We still need to construct the `app` and `naturality'` fields omitted above.\n  { refine (s.\u03b9.app (unop j)).c.app U \u226b (F.obj (unop j)).presheaf.map (eq_to_hom _),\n    dsimp,\n    rw \u2190opens.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.\u03b9_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 \u2964 PresheafedSpace.{v} C) (s : cocone F)\n  {U V : (opens \u21a5(s.X.carrier))\u1d52\u1d56} (i : U \u27f6 V) :\n  s.X.presheaf.map i \u226b desc_c_app F s V =\n  desc_c_app F s U \u226b (colimit.desc (F \u22d9 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_\u03c0, nat_trans.naturality, limit.lift_\u03c0_assoc, eq_to_hom_map, assoc,\n    pushforward_obj_map, nat_trans.naturality_assoc, op_map,\n    limit_obj_iso_limit_comp_evaluation_inv_\u03c0_app_assoc,\n    limit_obj_iso_limit_comp_evaluation_inv_\u03c0_app],\n  dsimp,\n  have w := functor.congr_hom (congr_arg opens.map\n    (colimit.\u03b9_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 \u2964 PresheafedSpace.{v} C) (s : cocone F) : colimit F \u27f6 s.X :=\n{ base := colimit.desc (F \u22d9 PresheafedSpace.forget C) ((PresheafedSpace.forget C).map_cocone s),\n  c :=\n  { app := \u03bb U, desc_c_app F s U,\n    naturality' := \u03bb U V i, desc_c_naturality F s i } }\n\nlemma desc_fac  (F : J \u2964 PresheafedSpace.{v} C) (s : cocone F) (j : J) :\n  (colimit_cocone F).\u03b9.app j \u226b desc F s = s.\u03b9.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 \u2964 PresheafedSpace.{v} C) : is_colimit (colimit_cocone F) :=\n{ desc := \u03bb s, desc F s,\n  fac' := \u03bb s, desc_fac F s,\n  uniq' := \u03bb 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 \u22d9 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.\u03b9_desc_apply, map_cocone_\u03b9_app],\n      rw \u2190 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_\u03c0, eq_to_hom_op, eq_to_hom_map, assoc,\n        limit_obj_iso_limit_comp_evaluation_inv_\u03c0_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.\u03c0 (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 := \u03bb 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 := \u03bb 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 := \u03bb J \ud835\udca5, by exactI\n  { has_colimit := \u03bb 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 := \u03bb J \ud835\udca5, by exactI\n  { preserves_colimit := \u03bb 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 \u2964 PresheafedSpace.{v} C) [has_colimit F]\n  (U : opens (limits.colimit F).carrier) :\n  (limits.colimit F).presheaf.obj (op U) \u2245 limit (componentwise_diagram F U) :=\nbegin\n  refine ((sheaf_iso_of_iso (colimit.iso_colimit_cocone\n    \u27e8_, colimit_cocone_is_colimit F\u27e9).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 \u2190 comp_app,\n    congr' 2,\n    exact \u03b9_preserves_colimits_iso_inv (forget C) F (unop X) },\n  { intros X Y f,\n    change ((F.map f.unop).c.app _ \u226b _ \u226b _) \u226b (F.obj (unop Y)).presheaf.map _ = _ \u226b _,\n    rw Top.presheaf.pushforward.comp_inv_app,\n    erw category.id_comp,\n    rw category.assoc,\n    erw [\u2190 (F.obj (unop Y)).presheaf.map_comp, (F.map f.unop).c.naturality_assoc,\n      \u2190 (F.obj (unop Y)).presheaf.map_comp],\n    congr }\nend\n\n@[simp]\nlemma colimit_presheaf_obj_iso_componentwise_limit_inv_\u03b9_app (F : J \u2964 PresheafedSpace.{v} C)\n  (U : opens (limits.colimit F).carrier) (j : J) :\n  (colimit_presheaf_obj_iso_componentwise_limit F U).inv \u226b (colimit.\u03b9 F j).c.app (op U) =\n    limit.\u03c0 _ (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 [\u2190 functor.map_comp_assoc, nat_trans.naturality],\n  erw \u2190 comp_c_app_assoc,\n  rw congr_app (colimit.iso_colimit_cocone_\u03b9_hom _ _),\n  simp_rw category.assoc,\n  erw [limit_obj_iso_limit_comp_evaluation_inv_\u03c0_app_assoc, lim_map_\u03c0_assoc],\n  convert category.comp_id _,\n  erw \u2190 (F.obj j).presheaf.map_id,\n  iterate 2 { erw \u2190 (F.obj j).presheaf.map_comp },\n  congr\nend\n\n@[simp]\nlemma colimit_presheaf_obj_iso_componentwise_limit_hom_\u03c0 (F : J \u2964 PresheafedSpace.{v} C)\n  (U : opens (limits.colimit F).carrier) (j : J) :\n    (colimit_presheaf_obj_iso_componentwise_limit F U).hom \u226b limit.\u03c0 _ (op j) =\n      (colimit.\u03b9 F j).c.app (op U) :=\nby rw [\u2190 iso.eq_inv_comp, colimit_presheaf_obj_iso_componentwise_limit_inv_\u03b9_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\u00f6f (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 \u211d 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 \u211d E] :=\n(to_fun : \u211d \u2192 E \u2192 E)\n(t_min t_max : \u211d)\n(t\u2080 : Icc t_min t_max)\n(x\u2080 : E)\n(C R L : \u211d\u22650)\n(lipschitz' : \u2200 t \u2208 Icc t_min t_max, lipschitz_on_with L (to_fun t) (closed_ball x\u2080 R))\n(cont : \u2200 x \u2208 closed_ball x\u2080 R, continuous_on (\u03bb t, to_fun t x) (Icc t_min t_max))\n(norm_le' : \u2200 (t \u2208 Icc t_min t_max) (x \u2208 closed_ball x\u2080 R), \u2225to_fun t x\u2225 \u2264 C)\n(C_mul_le_R : (C : \u211d) * max (t_max - t\u2080) (t\u2080 - t_min) \u2264 R)\n\nnamespace picard_lindelof\n\nvariables (v : picard_lindelof E)\n\ninstance : has_coe_to_fun (picard_lindelof E) (\u03bb _, \u211d \u2192 E \u2192 E) := \u27e8to_fun\u27e9\n\ninstance : inhabited (picard_lindelof E) :=\n\u27e8\u27e80, 0, 0, \u27e80, le_rfl, le_rfl\u27e9, 0, 0, 0, 0, \u03bb t ht, (lipschitz_with.const 0).lipschitz_on_with _,\n  \u03bb _ _, by simpa only [pi.zero_apply] using continuous_on_const, \u03bb t ht x hx, norm_zero.le,\n  (zero_mul _).le\u27e9\u27e9\n\nlemma t_min_le_t_max : v.t_min \u2264 v.t_max := v.t\u2080.2.1.trans v.t\u2080.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\u2080 v.R)) :=\nhave continuous_on (uncurry (flip v)) ((closed_ball v.x\u2080 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 : \u211d} (ht : t \u2208 Icc v.t_min v.t_max) {x : E} (hx : x \u2208 closed_ball v.x\u2080 v.R) :\n  \u2225v t x\u2225 \u2264 v.C :=\nv.norm_le' _ ht _ hx\n\n/-- The maximum of distances from `t\u2080` to the endpoints of `[t_min, t_max]`. -/\ndef t_dist : \u211d := max (v.t_max - v.t\u2080) (v.t\u2080 - v.t_min)\n\nlemma t_dist_nonneg : 0 \u2264 v.t_dist := le_max_iff.2 $ or.inl $ sub_nonneg.2 v.t\u2080.2.2\n\nlemma dist_t\u2080_le (t : Icc v.t_min v.t_max) : dist t v.t\u2080 \u2264 v.t_dist :=\nbegin\n  rw [subtype.dist_eq, real.dist_eq],\n  cases le_total t v.t\u2080 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 $\u211d \u2192 [t_{\\min}, t_{\\max}]$ sending $(-\u221e, t_{\\min}]$ to $t_{\\min}$ and $[t_{\\max}, \u221e)$\nto $t_{\\max}$. -/\ndef proj : \u211d \u2192 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 : \u211d} (ht : t \u2208 Icc v.t_min v.t_max) : \u2191(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 $\u03b3 \\colon [t_{\\min}, t_{\\max}] \\to E$ such that $\u03b3(t\u2080) = x\u2080$ and $\u03b3$ is\nLipschitz continuous with constant $C$. The map sending $\u03b3$ to\n$\\mathbf P\u03b3(t)=x\u2080 + \u222b_{t\u2080}^{t} v(\u03c4, \u03b3(\u03c4))\\,d\u03c4$ 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 \u2192 E)\n(map_t\u2080' : to_fun v.t\u2080 = v.x\u2080)\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) (\u03bb _, Icc v.t_min v.t_max \u2192 E) := \u27e8to_fun\u27e9\n\ninstance : inhabited v.fun_space :=\n\u27e8\u27e8\u03bb _, v.x\u2080, rfl, (lipschitz_with.const _).weaken (zero_le _)\u27e9\u27e9\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 \u21aa C(Icc v.t_min v.t_max, E) :=\n\u27e8\u03bb f, \u27e8f, f.continuous\u27e9, \u03bb f g h, by { cases f, cases g, simpa using h }\u27e9\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) := \u27e8rfl\u27e9\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\u2080 = v.x\u2080 \u2227 lipschitz_with v.C f} :=\nbegin\n  ext f, split,\n  { rintro \u27e8\u27e8f, hf\u2080, hf_lip\u27e9, rfl\u27e9, exact \u27e8hf\u2080, hf_lip\u27e9 },\n  { rcases f with \u27e8f, hf\u27e9, rintro \u27e8hf\u2080, hf_lip\u27e9, exact \u27e8\u27e8f, hf\u2080, hf_lip\u27e9, rfl\u27e9 }\nend\n\nlemma map_t\u2080 : f v.t\u2080 = v.x\u2080 := f.map_t\u2080'\n\nprotected lemma mem_closed_ball (t : Icc v.t_min v.t_max) : f t \u2208 closed_ball v.x\u2080 v.R :=\ncalc dist (f t) v.x\u2080 = dist (f t) (f.to_fun v.t\u2080) : by rw f.map_t\u2080'\n                 ... \u2264 v.C * dist t v.t\u2080          : f.lipschitz.dist_le_mul _ _\n                 ... \u2264 v.C * v.t_dist             : mul_le_mul_of_nonneg_left (v.dist_t\u2080_le _) v.C.2\n                 ... \u2264 v.R                        : v.C_mul_le_R\n\n/-- Given a curve $\u03b3 \\colon [t_{\\min}, t_{\\max}] \u2192 E$, `v_comp` is the function\n$F(t)=v(\u03c0 t, \u03b3(\u03c0 t))$, where `\u03c0` is the projection $\u211d \u2192 [t_{\\min}, t_{\\max}]$. The integral of this\nfunction is the image of `\u03b3` under the contracting map we are going to define below. -/\ndef v_comp (t : \u211d) : 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 (\u03bb x, _),\n  exact \u27e8(v.proj x).2, f.mem_closed_ball _\u27e9\nend\n\nlemma norm_v_comp_le (t : \u211d) : \u2225f.v_comp t\u2225 \u2264 v.C :=\nv.norm_le (v.proj t).2 $ f.mem_closed_ball _\n\nlemma dist_apply_le_dist (f\u2081 f\u2082 : fun_space v) (t : Icc v.t_min v.t_max) :\n  dist (f\u2081 t) (f\u2082 t) \u2264 dist f\u2081 f\u2082 :=\n@continuous_map.dist_apply_le_dist _ _ _ _ _ f\u2081.to_continuous_map f\u2082.to_continuous_map _\n\nlemma dist_le_of_forall {f\u2081 f\u2082 : fun_space v} {d : \u211d} (h : \u2200 t, dist (f\u2081 t) (f\u2082 t) \u2264 d) :\n  dist f\u2081 f\u2082 \u2264 d :=\n(@continuous_map.dist_le_iff_of_nonempty _ _ _ _ _ f\u2081.to_continuous_map f\u2082.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 \u2192 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\u2081 t\u2082 : \u211d) :\n  interval_integrable f.v_comp volume t\u2081 t\u2082 :=\n(f.continuous_v_comp).interval_integrable _ _\n\nvariables [second_countable_topology E] [complete_space E]\n\n/-- The Picard-Lindel\u00f6f 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 := \u03bb t, v.x\u2080 + \u222b \u03c4 : \u211d in v.t\u2080..t, f.v_comp \u03c4,\n  map_t\u2080' := by rw [integral_same, add_zero],\n  lipschitz' := lipschitz_with.of_dist_le_mul $ \u03bb t\u2081 t\u2082,\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 (\u03bb 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\u2080 + \u222b \u03c4 : \u211d in v.t\u2080..t, f.v_comp \u03c4 := rfl\n\nlemma has_deriv_within_at_next (t : Icc v.t_min v.t_max) :\n  has_deriv_within_at (f.next \u2218 v.proj) (v t (f t)) (Icc v.t_min v.t_max) t :=\nbegin\n  haveI : fact ((t : \u211d) \u2208 Icc v.t_min v.t_max) := \u27e8t.2\u27e9,\n  simp only [(\u2218), next_apply],\n  refine has_deriv_within_at.const_add _ _,\n  have : has_deriv_within_at (\u03bb t : \u211d, \u222b \u03c4 in v.t\u2080..t, f.v_comp \u03c4) (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\u2081 f\u2082 : fun_space v} {n : \u2115} {d : \u211d}\n  (h : \u2200 t, dist (f\u2081 t) (f\u2082 t) \u2264 (v.L * |t - v.t\u2080|) ^ n / n! * d) (t : Icc v.t_min v.t_max) :\n  dist (next f\u2081 t) (next f\u2082 t) \u2264 (v.L * |t - v.t\u2080|) ^ (n + 1) / (n + 1)! * d :=\nbegin\n  simp only [dist_eq_norm, next_apply, add_sub_add_left_eq_sub,\n    \u2190 interval_integral.integral_sub (interval_integrable_v_comp _ _ _)\n      (interval_integrable_v_comp _ _ _), norm_integral_eq_norm_integral_Ioc] at *,\n  calc \u2225\u222b \u03c4 in \u0399 (v.t\u2080 : \u211d) t, f\u2081.v_comp \u03c4 - f\u2082.v_comp \u03c4\u2225\n      \u2264 \u222b \u03c4 in \u0399 (v.t\u2080 : \u211d) t, v.L * ((v.L * |\u03c4 - v.t\u2080|) ^ 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 (\u03bb \u03c4 h\u03c4, _),\n        refine (v.lipschitz_on_with (v.proj \u03c4).2).norm_sub_le_of_le\n          (f\u2081.mem_closed_ball _) (f\u2082.mem_closed_ball _) ((h _).trans_eq _),\n        rw v.proj_of_mem,\n        exact (interval_subset_Icc v.t\u2080.2 t.2 $ Ioc_subset_Icc_self h\u03c4) }\n    end\n  ... = (v.L * |t - v.t\u2080|) ^ (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 : \u211d), nat.factorial_succ, nat.cast_mul, nat.cast_succ, mul_inv\u2080, mul_assoc]\nend\n\nlemma dist_iterate_next_apply_le (f\u2081 f\u2082 : fun_space v) (n : \u2115) (t : Icc v.t_min v.t_max) :\n  dist (next^[n] f\u2081 t) (next^[n] f\u2082 t) \u2264 (v.L * |t - v.t\u2080|) ^ n / n! * dist f\u2081 f\u2082 :=\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\u2081 f\u2082 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\u2081 f\u2082 : fun_space v) (n : \u2115) :\n  dist (next^[n] f\u2081) (next^[n] f\u2082) \u2264 (v.L * v.t_dist) ^ n / n! * dist f\u2081 f\u2082 :=\nbegin\n  refine dist_le_of_forall (\u03bb t, (dist_iterate_next_apply_le _ _ _ _).trans _),\n  have : 0 \u2264 dist f\u2081 f\u2082 := dist_nonneg,\n  have : |(t - v.t\u2080 : \u211d)| \u2264 v.t_dist := v.dist_t\u2080_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  \u2203 (N : \u2115) K, contracting_with K ((fun_space.next : v.fun_space \u2192 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 \u27e8N, hN\u27e9,\n  have : (0 : \u211d) \u2264 (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 \u27e8N, \u27e8_, this\u27e9, hN,\n    lipschitz_with.of_dist_le_mul (\u03bb f g, fun_space.dist_iterate_next_le f g N)\u27e9\nend\n\nlemma exists_fixed : \u2203 f : v.fun_space, f.next = f :=\nlet \u27e8N, K, hK\u27e9 := exists_contracting_iterate v in \u27e8_, hK.is_fixed_pt_fixed_point_iterate\u27e9\n\nend\n\n/-- Picard-Lindel\u00f6f (Cauchy-Lipschitz) theorem. -/\nlemma exists_solution :\n  \u2203 f : \u211d \u2192 E, f v.t\u2080 = v.x\u2080 \u2227 \u2200 t \u2208 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 := \u27e8rfl\u27e9,\n  rcases v.exists_fixed with \u27e8f, hf\u27e9,\n  refine \u27e8f \u2218 v.proj, _, \u03bb t ht, _\u27e9,\n  { simp only [(\u2218), proj_coe, f.map_t\u2080] },\n  { simp only [(\u2218), 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\u00f6f (Cauchy-Lipschitz) theorem. -/\nlemma exists_forall_deriv_within_Icc_eq_of_lipschitz_of_continuous\n  [complete_space E] [second_countable_topology E]\n  {v : \u211d \u2192 E \u2192 E} {t_min t\u2080 t_max : \u211d} (ht\u2080 : t\u2080 \u2208 Icc t_min t_max)\n  (x\u2080 : E) {C R : \u211d} (hR : 0 \u2264 R) {L : \u211d\u22650}\n  (Hlip : \u2200 t \u2208 Icc t_min t_max, lipschitz_on_with L (v t) (closed_ball x\u2080 R))\n  (Hcont : \u2200 x \u2208 closed_ball x\u2080 R, continuous_on (\u03bb t, v t x) (Icc t_min t_max))\n  (Hnorm : \u2200 (t \u2208 Icc t_min t_max) (x \u2208 closed_ball x\u2080 R), \u2225v t x\u2225 \u2264 C)\n  (Hmul_le : C * max (t_max - t\u2080) (t\u2080 - t_min) \u2264 R) :\n  \u2203 f : \u211d \u2192 E, f t\u2080 = x\u2080 \u2227 \u2200 t \u2208 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 \u211d\u22650 using ((norm_nonneg _).trans $ Hnorm t\u2080 ht\u2080 x\u2080 (mem_closed_ball_self hR)),\n  lift R to \u211d\u22650 using hR,\n  lift t\u2080 to Icc t_min t_max using ht\u2080,\n  exact picard_lindelof.exists_solution\n    \u27e8v, t_min, t_max, t\u2080, x\u2080, C, R, L, Hlip, Hcont, Hnorm, Hmul_le\u27e9\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\u00e9my Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: R\u00e9my 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# \u2112p space and Lp space\n\nThis file describes properties of almost everywhere measurable functions with finite seminorm,\ndenoted by `snorm f p \u03bc` and defined for `p:ennreal` as `0` if `p=0`, `(\u222b \u2225f a\u2225^p \u2202\u03bc) ^ (1/p)` for\n`0 < p < \u221e` and `ess_sup \u2225f\u2225 \u03bc` for `p=\u221e`.\n\nThe Prop-valued `mem_\u2112p f p \u03bc` states that a function `f : \u03b1 \u2192 E` has finite seminorm.\nThe space `Lp \u03b1 E p \u03bc` is the subtype of elements of `\u03b1 \u2192\u2098[\u03bc] E` (see ae_eq_fun) such that\n`snorm f p \u03bc` is finite. For `1 \u2264 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 \u03bc` : `(\u222b \u2225f a\u2225^p \u2202\u03bc) ^ (1/p)` for `f : \u03b1 \u2192 F` and `p : \u211d`, where `\u03b1` is a  measurable\n  space and `F` is a normed group.\n* `snorm_ess_sup f \u03bc` : seminorm in `\u2112\u221e`, equal to the essential supremum `ess_sup \u2225f\u2225 \u03bc`.\n* `snorm f p \u03bc` : for `p : ennreal`, seminorm in `\u2112p`, equal to `0` for `p=0`, to `snorm' f p \u03bc`\n  for `0 < p < \u221e` and to `snorm_ess_sup f \u03bc` for `p = \u221e`.\n\n* `mem_\u2112p f p \u03bc` : property that the function `f` is almost everywhere measurable and has finite\n  p-seminorm for measure `\u03bc` (`snorm f p \u03bc < \u221e`)\n* `Lp E p \u03bc` : elements of `\u03b1 \u2192\u2098[\u03bc] E` (see ae_eq_fun) such that `snorm f p \u03bc` is finite. Defined\n  as an `add_subgroup` of `\u03b1 \u2192\u2098[\u03bc] E`.\n\n-/\n\nnamespace measure_theory\n\n\n/-- `(\u222b \u2225f a\u2225^p \u2202\u03bc) ^ (1/p)`, which is a seminorm on the space of measurable functions for which\nthis quantity is finite -/\ndef snorm' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] (f : \u03b1 \u2192 F) (p : \u211d)\n    (\u03bc : measure \u03b1) : ennreal :=\n  (lintegral \u03bc fun (a : \u03b1) => \u2191(nnnorm (f a)) ^ p) ^ (1 / p)\n\n/-- seminorm for `\u2112\u221e`, equal to the essential supremum of `\u2225f\u2225`. -/\ndef snorm_ess_sup {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] (f : \u03b1 \u2192 F)\n    (\u03bc : measure \u03b1) : ennreal :=\n  ess_sup (fun (x : \u03b1) => \u2191(nnnorm (f x))) \u03bc\n\n/-- `\u2112p` seminorm, equal to `0` for `p=0`, to `(\u222b \u2225f a\u2225^p \u2202\u03bc) ^ (1/p)` for `0 < p < \u221e` and to\n`ess_sup \u2225f\u2225 \u03bc` for `p = \u221e`. -/\ndef snorm {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] [normed_group F] (f : \u03b1 \u2192 F)\n    (q : ennreal) (\u03bc : measure \u03b1) : ennreal :=\n  ite (q = 0) 0 (ite (q = \u22a4) (snorm_ess_sup f \u03bc) (snorm' f (ennreal.to_real q) \u03bc))\n\ntheorem snorm_eq_snorm' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {q : ennreal} (hq_ne_zero : q \u2260 0) (hq_ne_top : q \u2260 \u22a4) {f : \u03b1 \u2192 F} :\n    snorm f q \u03bc = snorm' f (ennreal.to_real q) \u03bc :=\n  sorry\n\n@[simp] theorem snorm_exponent_top {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} : snorm f \u22a4 \u03bc = snorm_ess_sup f \u03bc :=\n  sorry\n\n/-- The property that `f:\u03b1\u2192E` is ae_measurable and `(\u222b \u2225f a\u2225^p \u2202\u03bc)^(1/p)` is finite -/\ndef mem_\u2112p {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] [measurable_space E] [normed_group E]\n    (f : \u03b1 \u2192 E) (p : ennreal) (\u03bc : measure \u03b1) :=\n  ae_measurable f \u2227 snorm f p \u03bc < \u22a4\n\ntheorem lintegral_rpow_nnnorm_eq_rpow_snorm' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp0_lt : 0 < p) :\n    (lintegral \u03bc fun (a : \u03b1) => \u2191(nnnorm (f a)) ^ p) = snorm' f p \u03bc ^ p :=\n  sorry\n\ntheorem mem_\u2112p_one_iff_integrable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {f : \u03b1 \u2192 E} : mem_\u2112p f 1 \u03bc \u2194 integrable f :=\n  sorry\n\ntheorem mem_\u2112p.snorm_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} {f : \u03b1 \u2192 E} (hfp : mem_\u2112p f q \u03bc) :\n    snorm f q \u03bc < \u22a4 :=\n  and.right hfp\n\ntheorem mem_\u2112p.snorm_ne_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} {f : \u03b1 \u2192 E} (hfp : mem_\u2112p f q \u03bc) :\n    snorm f q \u03bc \u2260 \u22a4 :=\n  ne_of_lt (and.right hfp)\n\ntheorem lintegral_rpow_nnnorm_lt_top_of_snorm'_lt_top {\u03b1 : Type u_1} {F : Type u_3}\n    [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp0_lt : 0 < p)\n    (hfp : snorm' f p \u03bc < \u22a4) : (lintegral \u03bc fun (a : \u03b1) => \u2191(nnnorm (f a)) ^ p) < \u22a4 :=\n  sorry\n\n@[simp] theorem snorm'_exponent_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} : snorm' f 0 \u03bc = 1 :=\n  sorry\n\n@[simp] theorem snorm_exponent_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [normed_group F] {f : \u03b1 \u2192 F} : snorm f 0 \u03bc = 0 :=\n  sorry\n\ntheorem mem_\u2112p_zero_iff_ae_measurable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {f : \u03b1 \u2192 E} :\n    mem_\u2112p f 0 \u03bc \u2194 ae_measurable f :=\n  sorry\n\n@[simp] theorem snorm'_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} (hp0_lt : 0 < p) : snorm' 0 p \u03bc = 0 :=\n  sorry\n\n@[simp] theorem snorm'_zero' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} (hp0_ne : p \u2260 0) (h\u03bc : \u03bc \u2260 0) : snorm' 0 p \u03bc = 0 :=\n  sorry\n\n@[simp] theorem snorm_ess_sup_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [normed_group F] : snorm_ess_sup 0 \u03bc = 0 :=\n  sorry\n\n@[simp] theorem snorm_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {q : ennreal} : snorm 0 q \u03bc = 0 :=\n  sorry\n\ntheorem zero_mem_\u2112p {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} : mem_\u2112p 0 q \u03bc :=\n  { left := measurable.ae_measurable measurable_zero,\n    right := eq.mpr (id (Eq._oldrec (Eq.refl (snorm 0 q \u03bc < \u22a4)) snorm_zero)) ennreal.coe_lt_top }\n\ntheorem snorm'_measure_zero_of_pos {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp_pos : 0 < p) : snorm' f p 0 = 0 :=\n  sorry\n\ntheorem snorm'_measure_zero_of_exponent_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    [normed_group F] {f : \u03b1 \u2192 F} : snorm' f 0 0 = 1 :=\n  sorry\n\ntheorem snorm'_measure_zero_of_neg {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp_neg : p < 0) : snorm' f p 0 = \u22a4 :=\n  sorry\n\n@[simp] theorem snorm_ess_sup_measure_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    [normed_group F] {f : \u03b1 \u2192 F} : snorm_ess_sup f 0 = 0 :=\n  sorry\n\n@[simp] theorem snorm_measure_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    [normed_group F] {q : ennreal} {f : \u03b1 \u2192 F} : snorm f q 0 = 0 :=\n  sorry\n\ntheorem snorm'_const {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} (c : F) (hp_pos : 0 < p) :\n    snorm' (fun (x : \u03b1) => c) p \u03bc = \u2191(nnnorm c) * coe_fn \u03bc set.univ ^ (1 / p) :=\n  sorry\n\ntheorem snorm'_const' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} [finite_measure \u03bc] (c : F) (hc_ne_zero : c \u2260 0) (hp_ne_zero : p \u2260 0) :\n    snorm' (fun (x : \u03b1) => c) p \u03bc = \u2191(nnnorm c) * coe_fn \u03bc set.univ ^ (1 / p) :=\n  sorry\n\ntheorem snorm_ess_sup_const {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] (c : F) (h\u03bc : \u03bc \u2260 0) : snorm_ess_sup (fun (x : \u03b1) => c) \u03bc = \u2191(nnnorm c) :=\n  sorry\n\ntheorem snorm'_const_of_probability_measure {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (c : F) (hp_pos : 0 < p) [probability_measure \u03bc] :\n    snorm' (fun (x : \u03b1) => c) p \u03bc = \u2191(nnnorm c) :=\n  sorry\n\ntheorem snorm_const {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {q : ennreal} (c : F) (h0 : q \u2260 0) (h\u03bc : \u03bc \u2260 0) :\n    snorm (fun (x : \u03b1) => c) q \u03bc = \u2191(nnnorm c) * coe_fn \u03bc set.univ ^ (1 / ennreal.to_real q) :=\n  sorry\n\ntheorem snorm_const' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {q : ennreal} (c : F) (h0 : q \u2260 0) (h_top : q \u2260 \u22a4) :\n    snorm (fun (x : \u03b1) => c) q \u03bc = \u2191(nnnorm c) * coe_fn \u03bc set.univ ^ (1 / ennreal.to_real q) :=\n  sorry\n\ntheorem mem_\u2112p_const {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} (c : E) [finite_measure \u03bc] :\n    mem_\u2112p (fun (a : \u03b1) => c) q \u03bc :=\n  sorry\n\ntheorem snorm'_congr_ae {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} {g : \u03b1 \u2192 F}\n    (hfg : filter.eventually_eq (measure.ae \u03bc) f g) : snorm' f p \u03bc = snorm' g p \u03bc :=\n  sorry\n\ntheorem snorm_ess_sup_congr_ae {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {f : \u03b1 \u2192 F} {g : \u03b1 \u2192 F} (hfg : filter.eventually_eq (measure.ae \u03bc) f g) :\n    snorm_ess_sup f \u03bc = snorm_ess_sup g \u03bc :=\n  sorry\n\ntheorem snorm_congr_ae {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {q : ennreal} {f : \u03b1 \u2192 F} {g : \u03b1 \u2192 F}\n    (hfg : filter.eventually_eq (measure.ae \u03bc) f g) : snorm f q \u03bc = snorm g q \u03bc :=\n  sorry\n\ntheorem mem_\u2112p.ae_eq {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E}\n    (hfg : filter.eventually_eq (measure.ae \u03bc) f g) (hf_Lp : mem_\u2112p f q \u03bc) : mem_\u2112p g q \u03bc :=\n  sorry\n\ntheorem mem_\u2112p_congr_ae {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E}\n    (hfg : filter.eventually_eq (measure.ae \u03bc) f g) : mem_\u2112p f q \u03bc \u2194 mem_\u2112p g q \u03bc :=\n  { mp := fun (h : mem_\u2112p f q \u03bc) => mem_\u2112p.ae_eq hfg h,\n    mpr := fun (h : mem_\u2112p g q \u03bc) => mem_\u2112p.ae_eq (filter.eventually_eq.symm hfg) h }\n\ntheorem snorm'_eq_zero_of_ae_zero {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} (hp0_lt : 0 < p)\n    (hf_zero : filter.eventually_eq (measure.ae \u03bc) f 0) : snorm' f p \u03bc = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (snorm' f p \u03bc = 0)) (snorm'_congr_ae hf_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (snorm' 0 p \u03bc = 0)) (snorm'_zero hp0_lt))) (Eq.refl 0))\n\ntheorem snorm'_eq_zero_of_ae_zero' {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (hp0_ne : p \u2260 0) (h\u03bc : \u03bc \u2260 0) {f : \u03b1 \u2192 F}\n    (hf_zero : filter.eventually_eq (measure.ae \u03bc) f 0) : snorm' f p \u03bc = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (snorm' f p \u03bc = 0)) (snorm'_congr_ae hf_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (snorm' 0 p \u03bc = 0)) (snorm'_zero' hp0_ne h\u03bc))) (Eq.refl 0))\n\ntheorem ae_eq_zero_of_snorm'_eq_zero {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : \u211d} [opens_measurable_space E]\n    {f : \u03b1 \u2192 E} (hp0 : 0 \u2264 p) (hf : ae_measurable f) (h : snorm' f p \u03bc = 0) :\n    filter.eventually_eq (measure.ae \u03bc) f 0 :=\n  sorry\n\ntheorem snorm'_eq_zero_iff {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {p : \u211d} [opens_measurable_space E] (hp0_lt : 0 < p)\n    {f : \u03b1 \u2192 E} (hf : ae_measurable f) :\n    snorm' f p \u03bc = 0 \u2194 filter.eventually_eq (measure.ae \u03bc) 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 {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1]\n    [normed_group F] (f : \u03b1 \u2192 F) (\u03bc : measure \u03b1) :\n    filter.eventually (fun (x : \u03b1) => \u2191(nnnorm (f x)) \u2264 snorm_ess_sup f \u03bc) (measure.ae \u03bc) :=\n  ennreal.ae_le_ess_sup fun (x : \u03b1) => \u2191(nnnorm (f x))\n\ntheorem snorm_ess_sup_eq_zero_iff {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {f : \u03b1 \u2192 F} :\n    snorm_ess_sup f \u03bc = 0 \u2194 filter.eventually_eq (measure.ae \u03bc) f 0 :=\n  sorry\n\ntheorem snorm_eq_zero_iff {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} [opens_measurable_space E] {f : \u03b1 \u2192 E}\n    (hf : ae_measurable f) (h0 : q \u2260 0) :\n    snorm f q \u03bc = 0 \u2194 filter.eventually_eq (measure.ae \u03bc) f 0 :=\n  sorry\n\n@[simp] theorem snorm'_neg {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} {f : \u03b1 \u2192 F} : snorm' (-f) p \u03bc = snorm' f p \u03bc :=\n  sorry\n\n@[simp] theorem snorm_neg {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {q : ennreal} {f : \u03b1 \u2192 F} : snorm (-f) q \u03bc = snorm f q \u03bc :=\n  sorry\n\ntheorem mem_\u2112p.neg {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : \u03b1 \u2192 E}\n    (hf : mem_\u2112p f q \u03bc) : mem_\u2112p (-f) q \u03bc :=\n  sorry\n\ntheorem snorm'_le_snorm'_mul_rpow_measure_univ {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] {p : \u211d} {q : \u211d}\n    (hp0_lt : 0 < p) (hpq : p \u2264 q) {f : \u03b1 \u2192 E} (hf : ae_measurable f) :\n    snorm' f p \u03bc \u2264 snorm' f q \u03bc * coe_fn \u03bc set.univ ^ (1 / p - 1 / q) :=\n  sorry\n\ntheorem snorm'_le_snorm_ess_sup_mul_rpow_measure_univ {\u03b1 : Type u_1} {F : Type u_3}\n    [measurable_space \u03b1] {\u03bc : measure \u03b1} [normed_group F] {p : \u211d} (hp_pos : 0 < p) {f : \u03b1 \u2192 F} :\n    snorm' f p \u03bc \u2264 snorm_ess_sup f \u03bc * coe_fn \u03bc set.univ ^ (1 / p) :=\n  sorry\n\ntheorem snorm'_le_snorm'_of_exponent_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1]\n    [measurable_space E] [normed_group E] [borel_space E] {p : \u211d} {q : \u211d} (hp0_lt : 0 < p)\n    (hpq : p \u2264 q) (\u03bc : measure \u03b1) [probability_measure \u03bc] {f : \u03b1 \u2192 E} (hf : ae_measurable f) :\n    snorm' f p \u03bc \u2264 snorm' f q \u03bc :=\n  sorry\n\ntheorem snorm'_le_snorm_ess_sup {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} (hp_pos : 0 < p) {f : \u03b1 \u2192 F} [probability_measure \u03bc] :\n    snorm' f p \u03bc \u2264 snorm_ess_sup f \u03bc :=\n  sorry\n\ntheorem snorm_le_snorm_of_exponent_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] {p : ennreal}\n    {q : ennreal} (hpq : p \u2264 q) [probability_measure \u03bc] {f : \u03b1 \u2192 E} (hf : ae_measurable f) :\n    snorm f p \u03bc \u2264 snorm f q \u03bc :=\n  sorry\n\ntheorem snorm'_lt_top_of_snorm'_lt_top_of_exponent_le {\u03b1 : Type u_1} {E : Type u_2}\n    [measurable_space \u03b1] {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E]\n    {p : \u211d} {q : \u211d} [finite_measure \u03bc] {f : \u03b1 \u2192 E} (hf : ae_measurable f)\n    (hfq_lt_top : snorm' f q \u03bc < \u22a4) (hp_nonneg : 0 \u2264 p) (hpq : p \u2264 q) : snorm' f p \u03bc < \u22a4 :=\n  sorry\n\ntheorem mem_\u2112p.mem_\u2112p_of_exponent_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] [borel_space E] {p : ennreal}\n    {q : ennreal} [finite_measure \u03bc] {f : \u03b1 \u2192 E} (hfq : mem_\u2112p f q \u03bc) (hpq : p \u2264 q) :\n    mem_\u2112p f p \u03bc :=\n  sorry\n\ntheorem mem_\u2112p.integrable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] (hq1 : 1 \u2264 q) {f : \u03b1 \u2192 E}\n    [finite_measure \u03bc] (hfq : mem_\u2112p f q \u03bc) : integrable f :=\n  iff.mp mem_\u2112p_one_iff_integrable (mem_\u2112p.mem_\u2112p_of_exponent_le hfq hq1)\n\ntheorem snorm'_add_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {p : \u211d} [borel_space E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E}\n    (hf : ae_measurable f) (hg : ae_measurable g) (hp1 : 1 \u2264 p) :\n    snorm' (f + g) p \u03bc \u2264 snorm' f p \u03bc + snorm' g p \u03bc :=\n  sorry\n\ntheorem snorm_ess_sup_add_le {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {f : \u03b1 \u2192 F} {g : \u03b1 \u2192 F} :\n    snorm_ess_sup (f + g) \u03bc \u2264 snorm_ess_sup f \u03bc + snorm_ess_sup g \u03bc :=\n  sorry\n\ntheorem snorm_add_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E}\n    (hf : ae_measurable f) (hg : ae_measurable g) (hq1 : 1 \u2264 q) :\n    snorm (f + g) q \u03bc \u2264 snorm f q \u03bc + snorm g q \u03bc :=\n  sorry\n\ntheorem snorm_add_lt_top_of_one_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : \u03b1 \u2192 E}\n    {g : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc) (hg : mem_\u2112p g q \u03bc) (hq1 : 1 \u2264 q) : snorm (f + g) q \u03bc < \u22a4 :=\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 {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1]\n    {\u03bc : measure \u03b1} [measurable_space E] [normed_group E] {p : \u211d} [borel_space E] {f : \u03b1 \u2192 E}\n    {g : \u03b1 \u2192 E} (hf : ae_measurable f) (hg : ae_measurable g) (hf_snorm : snorm' f p \u03bc < \u22a4)\n    (hg_snorm : snorm' g p \u03bc < \u22a4) (hp_pos : 0 < p) (hp1 : p \u2264 1) : snorm' (f + g) p \u03bc < \u22a4 :=\n  sorry\n\ntheorem snorm_add_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E}\n    (hf : mem_\u2112p f q \u03bc) (hg : mem_\u2112p g q \u03bc) : snorm (f + g) q \u03bc < \u22a4 :=\n  sorry\n\ntheorem mem_\u2112p.add {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E]\n    [topological_space.second_countable_topology E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc)\n    (hg : mem_\u2112p g q \u03bc) : mem_\u2112p (f + g) q \u03bc :=\n  { left := ae_measurable.add (and.left hf) (and.left hg), right := snorm_add_lt_top hf hg }\n\ntheorem mem_\u2112p.sub {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} [borel_space E]\n    [topological_space.second_countable_topology E] {f : \u03b1 \u2192 E} {g : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc)\n    (hg : mem_\u2112p g q \u03bc) : mem_\u2112p (f - g) q \u03bc :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (mem_\u2112p (f - g) q \u03bc)) (sub_eq_add_neg f g)))\n    (mem_\u2112p.add hf (mem_\u2112p.neg hg))\n\ntheorem snorm'_const_smul {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {p : \u211d} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c F] {f : \u03b1 \u2192 F} (c : \ud835\udd5c)\n    (hp0_lt : 0 < p) : snorm' (c \u2022 f) p \u03bc = \u2191(nnnorm c) * snorm' f p \u03bc :=\n  sorry\n\ntheorem snorm_ess_sup_const_smul {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c F] {f : \u03b1 \u2192 F} (c : \ud835\udd5c) :\n    snorm_ess_sup (c \u2022 f) \u03bc = \u2191(nnnorm c) * snorm_ess_sup f \u03bc :=\n  sorry\n\ntheorem snorm_const_smul {\u03b1 : Type u_1} {F : Type u_3} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [normed_group F] {q : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c F] {f : \u03b1 \u2192 F}\n    (c : \ud835\udd5c) : snorm (c \u2022 f) q \u03bc = \u2191(nnnorm c) * snorm f q \u03bc :=\n  sorry\n\ntheorem mem_\u2112p.const_smul {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {q : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c]\n    [normed_space \ud835\udd5c E] [borel_space E] {f : \u03b1 \u2192 E} (hf : mem_\u2112p f q \u03bc) (c : \ud835\udd5c) :\n    mem_\u2112p (c \u2022 f) q \u03bc :=\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' {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {p : \u211d} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c] [normed_space \ud835\udd5c E]\n    [opens_measurable_space E] [measurable_space \ud835\udd5c] [opens_measurable_space \ud835\udd5c] {q : \u211d} {r : \u211d}\n    {f : \u03b1 \u2192 E} (hf : ae_measurable f) {\u03c6 : \u03b1 \u2192 \ud835\udd5c} (h\u03c6 : ae_measurable \u03c6) (hp0_lt : 0 < p)\n    (hpq : p < q) (hpqr : 1 / p = 1 / q + 1 / r) :\n    snorm' (\u03c6 \u2022 f) p \u03bc \u2264 snorm' \u03c6 q \u03bc * snorm' f r \u03bc :=\n  sorry\n\n/-! ### Lp space\n\nThe space of equivalence classes of measurable functions for which `snorm f p \u03bc < \u22a4`.\n-/\n\n@[simp] theorem snorm_ae_eq_fun {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {p : ennreal} {f : \u03b1 \u2192 E} (hf : ae_measurable f) :\n    snorm (\u21d1(ae_eq_fun.mk f hf)) p \u03bc = snorm f p \u03bc :=\n  snorm_congr_ae (ae_eq_fun.coe_fn_mk f hf)\n\ntheorem mem_\u2112p.snorm_mk_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] {p : ennreal} {f : \u03b1 \u2192 E} (hfp : mem_\u2112p f p \u03bc) :\n    snorm (\u21d1(ae_eq_fun.mk f (and.left hfp))) p \u03bc < \u22a4 :=\n  sorry\n\n/-- Lp space -/\ndef Lp {\u03b1 : Type u_1} (E : Type u_2) [measurable_space \u03b1] [measurable_space E] [normed_group E]\n    [borel_space E] [topological_space.second_countable_topology E] (p : ennreal) (\u03bc : measure \u03b1) :\n    add_subgroup (ae_eq_fun \u03b1 E \u03bc) :=\n  add_subgroup.mk (set_of fun (f : ae_eq_fun \u03b1 E \u03bc) => snorm (\u21d1f) p \u03bc < \u22a4) sorry sorry sorry\n\n/-- make an element of Lp from a function verifying `mem_\u2112p` -/\ndef mem_\u2112p.to_Lp {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] [measurable_space E]\n    [normed_group E] [borel_space E] [topological_space.second_countable_topology E] (f : \u03b1 \u2192 E)\n    {p : ennreal} {\u03bc : measure \u03b1} (h_mem_\u2112p : mem_\u2112p f p \u03bc) : \u21a5(Lp E p \u03bc) :=\n  { val := ae_eq_fun.mk f sorry, property := mem_\u2112p.snorm_mk_lt_top h_mem_\u2112p }\n\ntheorem mem_\u2112p.coe_fn_to_Lp {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] [measurable_space E]\n    [normed_group E] [borel_space E] [topological_space.second_countable_topology E] {\u03bc : measure \u03b1}\n    {p : ennreal} {f : \u03b1 \u2192 E} (hf : mem_\u2112p f p \u03bc) :\n    filter.eventually_eq (measure.ae \u03bc) (\u21d1(mem_\u2112p.to_Lp f hf)) f :=\n  ae_eq_fun.coe_fn_mk f (mem_\u2112p.to_Lp._proof_1 f hf)\n\nnamespace Lp\n\n\ntheorem mem_Lp_iff_snorm_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ae_eq_fun \u03b1 E \u03bc} :\n    f \u2208 Lp E p \u03bc \u2194 snorm (\u21d1f) p \u03bc < \u22a4 :=\n  iff.refl (f \u2208 Lp E p \u03bc)\n\ntheorem antimono {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] [finite_measure \u03bc] {p : ennreal} {q : ennreal}\n    (hpq : p \u2264 q) : Lp E q \u03bc \u2264 Lp E p \u03bc :=\n  fun (f : ae_eq_fun \u03b1 E \u03bc) (hf : f \u2208 Lp E q \u03bc) =>\n    and.right (mem_\u2112p.mem_\u2112p_of_exponent_le { left := ae_eq_fun.ae_measurable f, right := hf } hpq)\n\ntheorem coe_fn_mk {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : ae_eq_fun \u03b1 E \u03bc}\n    (hf : snorm (\u21d1f) p \u03bc < \u22a4) :\n    filter.eventually_eq (measure.ae \u03bc) \u21d1{ val := f, property := hf } \u21d1f :=\n  sorry\n\ntheorem snorm_lt_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) :\n    snorm (\u21d1f) p \u03bc < \u22a4 :=\n  subtype.prop f\n\ntheorem snorm_ne_top {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) :\n    snorm (\u21d1f) p \u03bc \u2260 \u22a4 :=\n  has_lt.lt.ne (snorm_lt_top f)\n\ntheorem measurable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) :\n    measurable \u21d1f :=\n  ae_eq_fun.measurable (subtype.val f)\n\ntheorem ae_measurable {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) :\n    ae_measurable \u21d1f :=\n  ae_eq_fun.ae_measurable (subtype.val f)\n\ntheorem mem_\u2112p {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) :\n    mem_\u2112p (\u21d1f) p \u03bc :=\n  { left := ae_measurable f, right := subtype.prop f }\n\ntheorem coe_fn_zero {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\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 \u03bc) (\u21d10) 0 :=\n  ae_eq_fun.coe_fn_zero\n\ntheorem coe_fn_neg {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)} :\n    filter.eventually_eq (measure.ae \u03bc) (\u21d1(-f)) (-\u21d1f) :=\n  ae_eq_fun.coe_fn_neg \u2191f\n\ntheorem coe_fn_add {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)}\n    {g : \u21a5(Lp E p \u03bc)} : filter.eventually_eq (measure.ae \u03bc) (\u21d1(f + g)) (\u21d1f + \u21d1g) :=\n  ae_eq_fun.coe_fn_add (subtype.val f) (subtype.val g)\n\ntheorem coe_fn_sub {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)}\n    {g : \u21a5(Lp E p \u03bc)} : filter.eventually_eq (measure.ae \u03bc) (\u21d1(f - g)) (\u21d1f - \u21d1g) :=\n  ae_eq_fun.coe_fn_sub \u2191f \u2191g\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} (\u03b1 : Type u_1)\n    [measurable_space \u03b1] (\u03bc : measure \u03b1) (c : E) [finite_measure \u03bc] :\n    ae_eq_fun.const \u03b1 c \u2208 Lp E p \u03bc :=\n  mem_\u2112p.snorm_mk_lt_top (mem_\u2112p_const c)\n\nprotected instance has_norm {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} : has_norm \u21a5(Lp E p \u03bc) :=\n  has_norm.mk fun (f : \u21a5(Lp E p \u03bc)) => ennreal.to_real (snorm (\u21d1f) p \u03bc)\n\ntheorem norm_def {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} (f : \u21a5(Lp E p \u03bc)) :\n    norm f = ennreal.to_real (snorm (\u21d1f) p \u03bc) :=\n  rfl\n\n@[simp] theorem norm_zero {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\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 {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)} (hp : 0 < p) :\n    norm f = 0 \u2194 f = 0 :=\n  sorry\n\n@[simp] theorem norm_neg {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {f : \u21a5(Lp E p \u03bc)} :\n    norm (-f) = norm f :=\n  sorry\n\nprotected instance normed_group {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} [hp : fact (1 \u2264 p)] :\n    normed_group \u21a5(Lp E p \u03bc) :=\n  normed_group.of_core \u21a5(Lp E p \u03bc) sorry\n\ntheorem mem_Lp_const_smul {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c]\n    [normed_space \ud835\udd5c E] (c : \ud835\udd5c) (f : \u21a5(Lp E p \u03bc)) : c \u2022 \u2191f \u2208 Lp E p \u03bc :=\n  sorry\n\nprotected instance has_scalar {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c]\n    [normed_space \ud835\udd5c E] : has_scalar \ud835\udd5c \u21a5(Lp E p \u03bc) :=\n  has_scalar.mk\n    fun (c : \ud835\udd5c) (f : \u21a5(Lp E p \u03bc)) => { val := c \u2022 \u2191f, property := mem_Lp_const_smul c f }\n\ntheorem coe_fn_smul {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c]\n    [normed_space \ud835\udd5c E] {f : \u21a5(Lp E p \u03bc)} {c : \ud835\udd5c} :\n    filter.eventually_eq (measure.ae \u03bc) (\u21d1(c \u2022 f)) (c \u2022 \u21d1f) :=\n  ae_eq_fun.coe_fn_smul c \u2191f\n\nprotected instance semimodule {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c]\n    [normed_space \ud835\udd5c E] : semimodule \ud835\udd5c \u21a5(Lp E p \u03bc) :=\n  semimodule.mk sorry sorry\n\ntheorem norm_const_smul {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c]\n    [normed_space \ud835\udd5c E] (c : \ud835\udd5c) (f : \u21a5(Lp E p \u03bc)) : norm (c \u2022 f) = norm c * norm f :=\n  sorry\n\nprotected instance normed_space {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure \u03b1}\n    [measurable_space E] [normed_group E] [borel_space E]\n    [topological_space.second_countable_topology E] {p : ennreal} {\ud835\udd5c : Type u_4} [normed_field \ud835\udd5c]\n    [normed_space \ud835\udd5c E] [fact (1 \u2264 p)] : normed_space \ud835\udd5c \u21a5(Lp E p \u03bc) :=\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\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable section\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nnamespace CategoryTheory.Functor\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} 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 \u2964 D) : Prop where\n  /-- For any pair objects `F (0: X \u27f6  Y) = (0 : F X \u27f6  F Y)` -/\n  map_zero : \u2200 X Y : C, F.map (0 : X \u27f6 Y) = 0 := by aesop\n#align category_theory.functor.preserves_zero_morphisms CategoryTheory.Functor.PreservesZeroMorphisms\n\n@[simp]\nprotected theorem map_zero (F : C \u2964 D) [PreservesZeroMorphisms F] (X Y : C) :\n    F.map (0 : X \u27f6 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 \u2964 D) [PreservesZeroMorphisms F] [Faithful F] {X Y : C} (f : X \u27f6 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 \u2964 D) [PreservesZeroMorphisms F] [Faithful F] {X Y : C} {f : X \u27f6 Y} :\n    F.map f = 0 \u2194 f = 0 :=\n  \u27e8F.zero_of_map_zero _, by\n    rintro rfl\n    exact F.map_zero _ _\u27e9\n#align category_theory.functor.map_eq_zero_iff CategoryTheory.Functor.map_eq_zero_iff\n\ninstance (priority := 100) preservesZeroMorphisms_of_isLeftAdjoint (F : C \u2964 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 \u27f6 Y) = F.map 0 \u226b F.map (adj.unit.app Y) \u226b adj.counit.app (F.obj Y) := ?_\n      _ = F.map 0 \u226b F.map ((rightAdjoint F).map (0 : F.obj X \u27f6 _)) \u226b adj.counit.app (F.obj Y) := ?_\n      _ = 0 := ?_\n    \u00b7 rw [Adjunction.left_triangle_components]\n      exact (Category.comp_id _).symm\n    \u00b7 simp only [\u2190 Category.assoc, \u2190 F.map_comp, zero_comp]\n    \u00b7 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 \u2964 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 \u27f6 Y) = adj.unit.app (G.obj X) \u226b G.map (adj.counit.app X) \u226b G.map 0 := ?_\n      _ = adj.unit.app (G.obj X) \u226b G.map ((leftAdjoint G).map (0 : _ \u27f6 G.obj X)) \u226b G.map 0 := ?_\n      _ = 0 := ?_\n    \u00b7 rw [Adjunction.right_triangle_components_assoc]; simp only [id_obj,Category.id_comp]\n    \u00b7 simp only [\u2190 G.map_comp, comp_zero]\n    \u00b7 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 \u2964 D) [Full F] :\n    PreservesZeroMorphisms F where\n  map_zero X Y :=\n    calc\n      F.map (0 : X \u27f6 Y) = F.map (0 \u226b F.preimage (0 : F.obj Y \u27f6 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 \u2964 D)\n\n/-- A functor that preserves zero morphisms also preserves the zero object. -/\n@[simps]\ndef mapZeroObject [PreservesZeroMorphisms F] : F.obj 0 \u2245 0 where\n  hom := 0\n  inv := 0\n  hom_inv_id := by rw [\u2190 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 \u2245 0) : PreservesZeroMorphisms F where\n  map_zero X Y :=\n    calc\n      F.map (0 : X \u27f6 Y) = F.map (0 : X \u27f6 0) \u226b F.map 0 := by rw [\u2190 Functor.map_comp, comp_zero]\n      _ = F.map 0 \u226b (i.hom \u226b i.inv) \u226b 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 \u226a\u226b\n      PreservesInitial.iso F \u226a\u226b 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 \u226a\u226b\n      PreservesTerminal.iso F \u226a\u226b 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 \u226a\u226b mapZeroObject F \u226a\u226b 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 \u226a\u226b\n      (mapZeroObject F).symm \u226a\u226b (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 \u22a3 G` with counit `\u03b5`, the pair\n`(FG\u03b5_B, \u03b5_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\u2082 u u\u2082\n\nvariables {C : Type u} [category.{v} C]\nvariables {D : Type u\u2082} [category.{v\u2082} D]\nvariables {A B : C} {f g : A \u27f6 B}\n\n/--\nThe pair `f g : A \u27f6 B` is reflexive if there is a morphism `B \u27f6 A` which is a section for both.\n-/\nclass is_reflexive_pair (f g : A \u27f6 B) : Prop :=\n(common_section [] : \u2203 (s : B \u27f6 A), s \u226b f = \ud835\udfd9 B \u2227 s \u226b g = \ud835\udfd9 B)\n\n/--\nThe pair `f g : A \u27f6 B` is coreflexive if there is a morphism `B \u27f6 A` which is a retraction for both.\n-/\nclass is_coreflexive_pair (f g : A \u27f6 B) : Prop :=\n(common_retraction [] : \u2203 (s : B \u27f6 A), f \u226b s = \ud835\udfd9 A \u2227 g \u226b s = \ud835\udfd9 A)\n\nlemma is_reflexive_pair.mk' (s : B \u27f6 A) (sf : s \u226b f = \ud835\udfd9 B) (sg : s \u226b g = \ud835\udfd9 B) :\n  is_reflexive_pair f g :=\n\u27e8\u27e8s, sf, sg\u27e9\u27e9\n\nlemma is_coreflexive_pair.mk' (s : B \u27f6 A) (fs : f \u226b s = \ud835\udfd9 A) (gs : g \u226b s = \ud835\udfd9 A) :\n  is_coreflexive_pair f g :=\n\u27e8\u27e8s, fs, gs\u27e9\u27e9\n\n/-- Get the common section for a reflexive pair. -/\nnoncomputable def common_section (f g : A \u27f6 B) [is_reflexive_pair f g] : B \u27f6 A :=\n(is_reflexive_pair.common_section f g).some\n\n@[simp, reassoc]\nlemma section_comp_left (f g : A \u27f6 B) [is_reflexive_pair f g] :\n  common_section f g \u226b f = \ud835\udfd9 B :=\n(is_reflexive_pair.common_section f g).some_spec.1\n\n@[simp, reassoc]\nlemma section_comp_right (f g : A \u27f6 B) [is_reflexive_pair f g] :\n  common_section f g \u226b g = \ud835\udfd9 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 \u27f6 B) [is_coreflexive_pair f g] :\n  B \u27f6 A :=\n(is_coreflexive_pair.common_retraction f g).some\n\n@[simp, reassoc]\nlemma left_comp_retraction (f g : A \u27f6 B) [is_coreflexive_pair f g] :\n  f \u226b common_retraction f g = \ud835\udfd9 A :=\n(is_coreflexive_pair.common_retraction f g).some_spec.1\n\n@[simp, reassoc]\nlemma right_comp_retraction (f g : A \u27f6 B) [is_coreflexive_pair f g] :\n  g \u226b common_retraction f g = \ud835\udfd9 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 \u27f6 A} {q : A \u27f6 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 \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G)\n\n/-- For an adjunction `F \u22a3 G` with counit `\u03b5`, the pair `(FG\u03b5_B, \u03b5_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 [\u2190 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 : \u2200 \u2983A B : C\u2984 (f g : A \u27f6 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 : \u2200 \u2983A B : C\u2984 (f g : A \u27f6 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 \u27f6 B} (r : B \u27f6 A)\n  (rf : r \u226b f = \ud835\udfd9 _) (rg : r \u226b g = \ud835\udfd9 _) :\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 \u27f6 B} (r : B \u27f6 A)\n  (fr : f \u226b r = \ud835\udfd9 _) (gr : g \u226b r = \ud835\udfd9 _) :\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 := \u03bb 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 := \u03bb 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 \u27e8\u27e9 notation without much benefit.\n-/\n\nnamespace Geo\n\nclass HasOn (\u03b1 : Type) := (on : Point \u2192 \u03b1 \u2192 Prop)\ndef on {\u03b1 : Type} [HasOn \u03b1] : Point \u2192 \u03b1 \u2192 Prop := HasOn.on\n\nclass HasInOrderOn (\u03b1 : Type) := (inOrderOn: List Point \u2192 \u03b1 \u2192 Prop)\ndef inOrderOn {\u03b1 : Type} [HasInOrderOn \u03b1] : List Point \u2192 \u03b1 \u2192 Prop := HasInOrderOn.inOrderOn\n\nsection\nvariables {\u03b1 \u03b2 : Type} [HasOn \u03b1] [HasOn \u03b2]\n\ndef allOn (ps : List Point) (x : \u03b1) : Prop := ps.allP (flip on x)\n\ndef intersectAt (x : \u03b1) (y : \u03b2) : Set Point := \u03bb p => on p x \u2227 on p y\ndef intersectAt\u2082 (x : \u03b1) (y : \u03b2) (p\u2081 p\u2082 : Point) : Prop :=\nintersectAt x y p\u2081 \u2227 intersectAt x y p\u2082 \u2227 p\u2081 \u2260 p\u2082\ndef intersect (x : \u03b1) (y : \u03b2) : Prop := Exists (intersectAt x y)\n\ndef allIntersectAt (xs : List \u03b1) : Set Point := \u03bb p => xs.allP (on p)\ndef allIntersect (xs : List \u03b1) : Prop := Exists (allIntersectAt xs)\n\ndef allIntersectAt\u2082 (xs : List \u03b1) (ys : List \u03b2) : Set Point :=\n\u03bb p => xs.allP (on p) \u2227 ys.allP (on p)\ndef allIntersect\u2082 (xs : List \u03b1) (ys : List \u03b2) : Prop :=\nExists (allIntersectAt\u2082 xs ys)\n\ndef intersectAtMany (x : \u03b1) (y : \u03b2) (ps : List Point) : Prop :=\nps.allP (\u03bb p => intersectAt x y p)\n\ndef tangentAt (x : \u03b1) (y : \u03b2) : Set Point := unique (intersectAt x y)\ndef tangent (x : \u03b1) (y : \u03b2) : Prop := Exists (tangentAt x y)\n\nend\n\nclass HasInside (\u03b1 : Type) := (inside : Point \u2192 \u03b1 \u2192 Prop)\ndef inside {\u03b1 : Type} [HasInside \u03b1] : Point \u2192 \u03b1 \u2192 Prop := HasInside.inside\n\nclass HasReflect (\u03b1 \u03b2 : Type) : Type := (reflect : \u03b1 \u2192 \u03b2 \u2192 \u03b1)\ndef reflect {\u03b1 \u03b2 : Type} [HasReflect \u03b1 \u03b2] : \u03b1 \u2192 \u03b2 \u2192 \u03b1 := HasReflect.reflect\n\nclass HasUnsignedArea (\u03b1 : Type) : Type := (uarea : \u03b1 \u2192 \u211d\u2265)\ndef uarea {\u03b1 : Type} [HasUnsignedArea \u03b1] : \u03b1 \u2192 \u211d\u2265 := HasUnsignedArea.uarea\n\nclass HasSignedArea (\u03b1 : Type) : Type := (sarea : \u03b1 \u2192 \u211d)\ndef sarea {\u03b1 : Type} [HasSignedArea \u03b1] : \u03b1 \u2192 \u211d  := HasSignedArea.sarea\n\nclass HasLength (\u03b1 : Type) := (ulen : \u03b1 \u2192 \u211d\u2265)\ndef ulen {\u03b1 : Type} [HasLength \u03b1] : \u03b1 \u2192 \u211d\u2265 := HasLength.ulen\n\nstructure Line : Type := (p\u2081 p\u2082 : Point)\n\nnamespace Line\n\ndef same (l\u2081 l\u2082 : Line) : Prop := WIP\n\ndef wf : Line \u2192 Prop\n| \u27e8a, b\u27e9 => a \u2260 b\n\nprotected def on (p : Point) : Line \u2192 Prop\n| \u27e8a, b\u27e9 => a \u2260 b \u2227 Analytic.coll p a b -- TODO: bundle NDGs like this?\ninstance : HasOn Line := \u27e8Line.on\u27e9\n\nprotected def inOrderOn (ps : List Point) : Line \u2192 Prop := WIP\ninstance : HasInOrderOn Line := \u27e8Line.inOrderOn\u27e9\n\nnoncomputable def reflectPL (p : Point) (l : Line) : Point := WIP -- ARITH\nnoncomputable def reflectLL (l\u2081 l\u2082 : Line) : Line := WIP -- ARITH\nnoncomputable instance ReflectPL : HasReflect Point Line := \u27e8reflectPL\u27e9\nnoncomputable instance ReflectLL : HasReflect Line Line := \u27e8reflectLL\u27e9\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 \u2192 Point \u2192 Point \u2192 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\u2081 l\u2082 : Line) : Prop :=\nl\u2081.wf \u2227 l\u2082.wf \u2227 Analytic.para l\u2081.p\u2081 l\u2081.p\u2082 l\u2082.p\u2081 l\u2082.p\u2082\n\ndef perp (l\u2081 l\u2082 : Line) : Prop :=\nl\u2081.wf \u2227 l\u2082.wf \u2227 Analytic.perp l\u2081.p\u2081 l\u2081.p\u2082 l\u2082.p\u2081 l\u2082.p\u2082\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 := \u27e8Seg.on\u27e9\n\ndef strictlyBtw (p\u2081 p\u2082 p\u2083 : Point) : Prop :=\non p\u2081 (Seg.mk p\u2082 p\u2083) \u2227 p\u2081 \u2260 p\u2082 \u2227 p\u2081 \u2260 p\u2083\n\nprotected def inOrderOn (ps : List Point) : Seg \u2192 Prop := WIP\ninstance : HasInOrderOn Seg := \u27e8Seg.inOrderOn\u27e9\n\nprotected noncomputable def ulen (l : Seg) : \u211d\u2265 :=\n\u27e8Analytic.dist l.src l.dst, Analytic.distGe0 _ _\u27e9\n\nnoncomputable instance : HasLength Seg := \u27e8Seg.ulen\u27e9\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\u2081 l\u2082 : Seg) : Prop := ulen l\u2081 = ulen l\u2082\n\nend Seg\n\nnoncomputable def perpBis (l : Seg) : Line := \u27e8Seg.midp l, perpTo (Seg.midp l) l.dst\u27e9\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 := \u27e8Ray.on\u27e9\n\nprotected def inOrderOn (ps : List Point) : Ray \u2192 Prop := WIP\ninstance : HasInOrderOn Ray := \u27e8Ray.inOrderOn\u27e9\n\ndef toLine (l : Ray) : Line := \u27e8l.src, l.dst\u27e9\ninstance : HasCoe Ray Line := \u27e8toLine\u27e9\n\nend Ray\n\nstructure Circle : Type := (origin : Point) (radius : \u211d\u208a)\n\nnamespace Circle\n\nprotected def on (p : Point) (\u0393 : Circle) : Prop :=\n\u0393.radius = \u27e8Analytic.dist p \u0393.origin, Analytic.distGe0 _ _\u27e9\n\ninstance : HasOn Circle := \u27e8Circle.on\u27e9\n\nprotected def inOrderOn (ps : List Point) : Circle \u2192 Prop := WIP\ninstance : HasInOrderOn Circle := \u27e8Circle.inOrderOn\u27e9\n\nprotected def inside (p : Point) (\u0393 : Circle) : Prop :=\n\u0393.radius > \u27e8Analytic.dist p \u0393.origin, Analytic.distGe0 _ _\u27e9\n\ninstance : HasInside Circle := \u27e8Circle.inside\u27e9\n\nnoncomputable def diameter (\u0393 : Circle) : \u211d\u208a := \u0393.radius * 2\ndef isDiameter (p\u2081 p\u2082 : Point) (\u0393 : Circle) : Prop :=\non p\u2081 \u0393 \u2227 on p\u2082 \u0393 \u2227 Seg.isMidpoint (\u0393.origin) \u27e8p\u2081, p\u2082\u27e9\n\nprotected noncomputable def uarea (\u0393 : Circle) : \u211d\u2265 :=\n\u03c0 * \u0393.radius^2\n\nnoncomputable instance : HasUnsignedArea Circle := \u27e8Circle.uarea\u27e9\n\nnoncomputable def lineTangentAtP (\u0393 : Circle) (p : Point) : Line := WIP\n\nprotected noncomputable def buildOP (origin p : Point) : Circle := WIP\nprotected noncomputable def buildPPP (p\u2081 p\u2082 p\u2083 : Point) : Circle := WIP\nprotected noncomputable def buildDiam (p\u2081 p\u2082 : Point) : Circle :=\nCircle.buildOP (Seg.midp \u27e8p\u2081, p\u2082\u27e9) p\u2081\n\ndef isOrigin (p : Point) (\u0393 : Circle) : Prop := p = \u0393.origin\n\nend Circle\n\nnoncomputable def cycl (ps : List Point) : Prop :=\nExists (\u03bb (\u0393 : Circle) => allOn ps \u0393)\n\nstructure Arc (\u0393 : Circle) : Type := (src dst avoid : Point)\n\nnamespace Arc\n\nvariable {\u0393 : Circle}\n\nprotected def on (p : Point) (arc : Arc \u0393) : Prop := WIP -- ARITH\ninstance: HasOn (Arc \u0393) := \u27e8Arc.on\u27e9\n\nprotected noncomputable def ulen (arc : Arc \u0393) : \u211d\u2265 := WIP -- ARITH\nnoncomputable instance : HasLength (Arc \u0393) := \u27e8Arc.ulen\u27e9\n\nnoncomputable def buildMinor (\u0393 : Circle) : Point \u2192 Point \u2192 Arc \u0393 := WIP\nnoncomputable def buildMajor (\u0393 : Circle) : Point \u2192 Point \u2192 Arc \u0393 := WIP\n\nprotected noncomputable def midp (a : Arc \u0393) : Point := WIP\nprotected def isMidpoint (p : Point) (a : Arc \u0393) : Prop := p = a.midp\n\nend Arc\n\ndef isChord (\u0393 : Circle) (l : Seg) : Prop := on l.src \u0393 \u2227 on l.dst \u0393\n\nopen Triple (cmap any all)\n\ndef Angle : Type := Triple Point\n\nnoncomputable def uangle : Angle \u2192 \u211d2\u03c0 := WIP\nnoncomputable def dangle : Angle \u2192 \u211d\u03c0  := WIP\n\nnamespace Angle\n\nnoncomputable def bisector : Angle \u2192 Line := WIP\ndef isBisector (l : Line) (ang : Angle) : Prop := WIP\n\ndef isRight : Angle \u2192 Prop := WIP\n\nend Angle\n\ndef Triangle : Type := Triple Point\n\nnamespace Triangle\n\nprotected def mk (A B C : Point) : Triangle := \u27e8A, B, C\u27e9\n\nprotected noncomputable def buildLLL (ls : Triple Line) : Triangle := WIP\n\nprotected def on : Point \u2192 Triangle \u2192 Prop := WIP\n\ninstance : HasOn Triangle := \u27e8Triangle.on\u27e9\n\nprotected def inside : Point \u2192 Triangle \u2192 Prop := WIP\ninstance : HasInside Triangle := \u27e8Triangle.inside\u27e9\n\nprotected noncomputable def uarea : Triangle \u2192 \u211d\u208a := WIP\nnoncomputable instance : HasUnsignedArea Triangle := \u27e8Triangle.uarea\u27e9\n\nprotected noncomputable def sarea : Triangle \u2192 \u211d := WIP\nnoncomputable instance : HasSignedArea Triangle := \u27e8Triangle.sarea\u27e9\n\ndef sides : Triangle \u2192 Triple Seg\n| \u27e8A, B, C\u27e9 => \u27e8\u27e8B, C\u27e9, \u27e8C, A\u27e9, \u27e8A, B\u27e9\u27e9\n\ndef vertices : Triangle \u2192 Triple Point\n| \u27e8A, B, C\u27e9 => \u27e8A, B, C\u27e9\n\nnoncomputable def sideLengths (tri : Triangle) : Triple \u211d\u2265 :=\nulen <$> sides tri\n\ndef esides : Triangle \u2192 Triple Line\n| \u27e8A, B, C\u27e9 => \u27e8\u27e8B, C\u27e9, \u27e8C, A\u27e9, \u27e8A, B\u27e9\u27e9\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 \u27e8B, C, A\u27e9 => \u27e8A, B, C\u27e9\n\ndef isRight (tri : Triangle) : Prop :=\nTriple.any Angle.isRight tri.angles\n\nnoncomputable def uangles (tri : Triangle) : Triple \u211d2\u03c0 :=\nuangle <$> tri.angles\n\nnoncomputable def dangles (tri : Triangle) : Triple \u211d\u03c0  :=\ndangle <$> tri.angles\n\nnoncomputable def altitudes : Triangle \u2192 Triple Seg :=\ncmap $ \u03bb tri => \u27e8tri.A, foot tri.A \u27e8tri.B, tri.C\u27e9\u27e9\n\nnoncomputable def medians : Triangle \u2192 Triple Seg :=\ncmap $ \u03bb tri => \u27e8tri.A, Seg.midp \u27e8tri.B, tri.C\u27e9\u27e9\n\nnoncomputable def circumcenter  : Triangle \u2192 Point := WIP\nnoncomputable def incenter      : Triangle \u2192 Point := WIP\nnoncomputable def orthocenter   : Triangle \u2192 Point := WIP\nnoncomputable def centroid      : Triangle \u2192 Point := WIP\nnoncomputable def excenters     : Triangle \u2192 Triple Point := WIP\n\ndef isIncenter (p : Point) (tri : Triangle) : Prop := p = tri.incenter\n\nprotected noncomputable def circumcircle  : Triangle \u2192 Circle := WIP\n-- ryankrue: excircles.A ought to be the excircle across from X in a triangle \u27e8X, Y, Z\u27e9\nnoncomputable def excircles     : Triangle \u2192 Triple Circle := WIP\nnoncomputable def incircle      : Triangle \u2192 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 \u27e8Ta, Tb, Tc\u27e9\nnoncomputable def gergonneTriangle : Triangle \u2192 Triangle := WIP\n\nnoncomputable def circumradius   : Triangle \u2192 \u211d\u208a := WIP\nnoncomputable def inradius       : Triangle \u2192 \u211d\u208a := WIP\nnoncomputable def exradii        : Triangle \u2192 Triple \u211d\u208a := WIP\n\nnoncomputable def pedalTriangle  : Triangle \u2192 Point \u2192 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 (\u03bb (tri : Triangle) => tri.A = l.src \u2227 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 := \u27e8A, B, C, D\u27e9\n\nprotected def on : Point \u2192 Quadrilateral \u2192 Prop := WIP\n\ninstance : HasOn Quadrilateral := \u27e8Quadrilateral.on\u27e9\n\nprotected def inside : Point \u2192 Quadrilateral \u2192 Prop := WIP\ninstance : HasInside Quadrilateral := \u27e8Quadrilateral.inside\u27e9\n\nprotected noncomputable def uarea : Quadrilateral \u2192 \u211d\u208a := WIP\nnoncomputable instance : HasUnsignedArea Quadrilateral := \u27e8Quadrilateral.uarea\u27e9\n\nprotected noncomputable def sarea : Quadrilateral \u2192 \u211d := WIP\nnoncomputable instance : HasSignedArea Quadrilateral := \u27e8Quadrilateral.sarea\u27e9\n\ndef sides : Quadrilateral \u2192 Quadruple Seg\n| \u27e8A, B, C, D\u27e9 => \u27e8\u27e8A, B\u27e9, \u27e8B, C\u27e9, \u27e8C, D\u27e9, \u27e8D, A\u27e9\u27e9\n\nnoncomputable def sideLengths (quad : Quadrilateral) : Quadruple \u211d\u2265 :=\nulen <$> sides quad\n\ndef esides : Quadrilateral \u2192 Quadruple Line\n| \u27e8A, B, C, D\u27e9 => \u27e8\u27e8A, B\u27e9, \u27e8B, C\u27e9, \u27e8C, D\u27e9, \u27e8D, A\u27e9\u27e9\n\nnoncomputable def angles : Quadrilateral \u2192 Quadruple Angle\n| \u27e8A, B, C, D\u27e9 => \u27e8\u27e8D, A, B\u27e9, \u27e8A, B, C\u27e9, \u27e8B, C, D\u27e9, \u27e8C, D, A\u27e9\u27e9\n\nnoncomputable def uangles (quad : Quadrilateral) : Quadruple \u211d2\u03c0 :=\nuangle <$> quad.angles\n\nnoncomputable def dangles (quad : Quadrilateral) : Quadruple \u211d\u03c0  :=\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 \u2192 Prop\n| \u27e8A, B, C, D\u27e9 => on D (Circle.buildPPP A B C)\ndef convex   : Quadrilateral \u2192 Prop := WIP\ndef regular  : Quadrilateral \u2192 Prop := WIP\ndef harmonic : Quadrilateral \u2192 Prop := WIP\n\ndef parallelogram (quad : Quadrilateral) : Prop :=\nconvex quad \u2227 para quad.esides.A quad.esides.C \u2227 para quad.esides.B quad.esides.D\n\ndef trapezoid (quad : Quadrilateral) : Prop :=\nconvex quad \u2227 (para quad.esides.A quad.esides.C \u2228 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 \u2265 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 \u211d\u2265 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 \u2192 Prop := WIP\ndef regular : Polygon n \u2192 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 \u00d7 Seg) (n / 2) := WIP\n\nend Polygon\n\n/- UNCOMMENT for >2 types intersecting\nnamespace WithInst\n\ndef ListWithInst (\u03d5 : \u2200 (\u03b1 : Type), Type) : Type 1 := List (Sigma (\u03bb \u03b3 => \u03d5 \u03b3 \u00d7 \u03b3))\ndef allIntersectAt\u2082 (xs : ListWithInst HasOn) : Set Point :=\n\u03bb p => xs.allP (\u03bb \u27e8\u03b1, \u27e8inst, x\u27e9\u27e9 => on p x)\ndef allIntersect\u2082 (xs : ListWithInst HasOn) : Prop := Exists (allIntersectAt\u2082 xs)\n\ndef intersectElem {\u03b1 : Type} [inst : HasOn \u03b1] (x : \u03b1) : Sigma (\u03bb \u03b3 => HasOn \u03b3 \u00d7 \u03b3) := \u27e8\u03b1, \u27e8inst, x\u27e9\u27e9\n--def examplePolymorphicSpec (a b c : Point) : Prop :=\nallIntersect\u2082 [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 : \u211d} [hT : fact (0 < T)]\ninclude hT\n\nlemma closed_ball_ae_eq_ball {x : add_circle T} {\u03b5 : \u211d} :\n  closed_ball x \u03b5 =\u1d50[volume] ball x \u03b5 :=\nbegin\n  cases le_or_lt \u03b5 0 with h\u03b5 h\u03b5,\n  { rw [ball_eq_empty.mpr h\u03b5, ae_eq_empty, volume_closed_ball,\n      min_eq_right (by linarith [hT.out] : 2 * \u03b5 \u2264 T), ennreal.of_real_eq_zero],\n    exact mul_nonpos_of_nonneg_of_nonpos zero_le_two h\u03b5, },\n  { suffices : volume (closed_ball x \u03b5) \u2264 volume (ball x \u03b5),\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 (\u03bb \u03b4, volume (closed_ball x \u03b4)) (\ud835\udcdd[<] \u03b5) (\ud835\udcdd $ volume (closed_ball x \u03b5)),\n    { simp_rw volume_closed_ball,\n      refine ennreal.tendsto_of_real (tendsto.min tendsto_const_nhds $ tendsto.const_mul _ _),\n      convert (@monotone_id \u211d _).tendsto_nhds_within_Iio \u03b5,\n      simp, },\n    refine le_of_tendsto this (mem_nhds_within_Iio_iff_exists_Ioo_subset.mpr \u27e80, h\u03b5, \u03bb r hr, _\u27e9),\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 : \u2115`. 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 =\u1d50[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 \u2264 (n : \u211d), { 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  { -- `\u2200 (g : G), g \u2260 0 \u2192 ae_disjoint volume (g +\u1d65 I) I`\n    rintros \u27e8g, hg\u27e9 hg',\n    replace hg' : g \u2260 0, by simpa only [ne.def, add_subgroup.mk_eq_zero_iff] using hg',\n    change ae_disjoint volume (g +\u1d65 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 +\u1d65 B = ball (g + x) (T / (2 * n)),\n    { rw [add_comm g x, \u2190 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, \u2190 add_div, \u2190 add_div, add_self_div_two,\n      div_le_iff' (by positivity : 0 < (n : \u211d)), \u2190 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  { -- `\u2200 (g : G), quasi_measure_preserving (has_vadd.vadd g) volume volume`\n    exact (\u03bb g, quasi_measure_preserving_add_left volume g), },\n  { -- `volume univ \u2264 \u2211' (g : G), volume (g +\u1d65 I)`\n    replace hI : I =\u1d50[volume] closed_ball x (T / (2 * \u2191n)) :=\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, \u2190 ennreal.of_real_nsmul, mul_div, mul_div_mul_comm,\n      div_self (@two_ne_zero \u211d _ _ _ _), 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 +\u1d65 s : set $ add_circle T) =\u1d50[volume] s)\n  (hI : I =\u1d50[volume] ball x (T / (2 * add_order_of u))) :\n  volume s = add_order_of u \u2022 volume (s \u2229 I) :=\nbegin\n  let G := add_subgroup.zmultiples u,\n  haveI : fintype G := @fintype.of_finite _ hu.finite_zmultiples,\n  have hsG : \u2200 (g : G), (g +\u1d65 s : set $ add_circle T) =\u1d50[volume] s,\n  { rintros \u27e8y, hy\u27e9, 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\u2081 u\u2082 v\u2081 v\u2082 u\u2083 v\u2083 \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 `\u03b1 : F \u2245 G`, then `a.app X : F.obj X \u2245 G.obj X`,\nand building natural isomorphisms from components:\n*\n```\nnat_iso.of_components\n  (app : \u2200 X : C, F.obj X \u2245 G.obj X)\n  (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), F.map f \u226b (app Y).hom = (app X).hom \u226b G.map f) :\nF \u2245 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 `\u03b1.app` -/\n@[simp] theorem app_hom {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : hom (app \u03b1 X) = nat_trans.app (hom \u03b1) X :=\n  Eq.refl (hom (app \u03b1 X))\n\n@[simp] theorem hom_inv_id_app_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) {X' : D} (f' : functor.obj F X \u27f6 X') :\n    nat_trans.app (hom \u03b1) X \u226b nat_trans.app (inv \u03b1) X \u226b f' = f' :=\n  sorry\n\n@[simp] theorem inv_hom_id_app_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) {X' : D} (f' : functor.obj G X \u27f6 X') :\n    nat_trans.app (inv \u03b1) X \u226b nat_trans.app (hom \u03b1) X \u226b f' = f' :=\n  sorry\n\nend iso\n\n\nnamespace nat_iso\n\n\n@[simp] theorem trans_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : F \u2245 G) (\u03b2 : G \u2245 H) (X : C) :\n    iso.app (\u03b1 \u226a\u226b \u03b2) X = iso.app \u03b1 X \u226a\u226b iso.app \u03b2 X :=\n  rfl\n\ntheorem app_hom {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D}\n    (\u03b1 : F \u2245 G) (X : C) : iso.hom (iso.app \u03b1 X) = nat_trans.app (iso.hom \u03b1) X :=\n  rfl\n\ntheorem app_inv {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D}\n    (\u03b1 : F \u2245 G) (X : C) : iso.inv (iso.app \u03b1 X) = nat_trans.app (iso.inv \u03b1) X :=\n  rfl\n\nprotected instance hom_app_is_iso {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : is_iso (nat_trans.app (iso.hom \u03b1) X) :=\n  is_iso.mk (nat_trans.app (iso.inv \u03b1) X)\n\nprotected instance inv_app_is_iso {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : is_iso (nat_trans.app (iso.inv \u03b1) X) :=\n  is_iso.mk (nat_trans.app (iso.hom \u03b1) X)\n\n/-!\nUnfortunately we need a separate set of cancellation lemmas for components of natural isomorphisms,\nbecause the `simp` normal form is `\u03b1.hom.app X`, rather than `\u03b1.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\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {X : C} {Z : D} (g : functor.obj G X \u27f6 Z)\n    (g' : functor.obj G X \u27f6 Z) :\n    nat_trans.app (iso.hom \u03b1) X \u226b g = nat_trans.app (iso.hom \u03b1) X \u226b g' \u2194 g = g' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_inv_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {X : C} {Z : D} (g : functor.obj F X \u27f6 Z)\n    (g' : functor.obj F X \u27f6 Z) :\n    nat_trans.app (iso.inv \u03b1) X \u226b g = nat_trans.app (iso.inv \u03b1) X \u226b g' \u2194 g = g' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_hom_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {X : D} {Y : C} (f : X \u27f6 functor.obj F Y)\n    (f' : X \u27f6 functor.obj F Y) :\n    f \u226b nat_trans.app (iso.hom \u03b1) Y = f' \u226b nat_trans.app (iso.hom \u03b1) Y \u2194 f = f' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_inv_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {X : D} {Y : C} (f : X \u27f6 functor.obj G Y)\n    (f' : X \u27f6 functor.obj G Y) :\n    f \u226b nat_trans.app (iso.inv \u03b1) Y = f' \u226b nat_trans.app (iso.inv \u03b1) Y \u2194 f = f' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_hom_right_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {W : D} {X : D} {X' : D} {Y : C} (f : W \u27f6 X)\n    (g : X \u27f6 functor.obj F Y) (f' : W \u27f6 X') (g' : X' \u27f6 functor.obj F Y) :\n    f \u226b g \u226b nat_trans.app (iso.hom \u03b1) Y = f' \u226b g' \u226b nat_trans.app (iso.hom \u03b1) Y \u2194 f \u226b g = f' \u226b g' :=\n  sorry\n\n@[simp] theorem cancel_nat_iso_inv_right_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {W : D} {X : D} {X' : D} {Y : C} (f : W \u27f6 X)\n    (g : X \u27f6 functor.obj G Y) (f' : W \u27f6 X') (g' : X' \u27f6 functor.obj G Y) :\n    f \u226b g \u226b nat_trans.app (iso.inv \u03b1) Y = f' \u226b g' \u226b nat_trans.app (iso.inv \u03b1) Y \u2194 f \u226b g = f' \u226b g' :=\n  sorry\n\ntheorem naturality_1 {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D}\n    {X : C} {Y : C} (\u03b1 : F \u2245 G) (f : X \u27f6 Y) :\n    nat_trans.app (iso.inv \u03b1) X \u226b functor.map F f \u226b nat_trans.app (iso.hom \u03b1) Y = functor.map G f :=\n  sorry\n\ntheorem naturality_2 {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D}\n    {X : C} {Y : C} (\u03b1 : F \u2245 G) (f : X \u27f6 Y) :\n    nat_trans.app (iso.hom \u03b1) X \u226b functor.map G f \u226b nat_trans.app (iso.inv \u03b1) 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} (\u03b1 : F \u27f6 G) [(X : C) \u2192 is_iso (nat_trans.app \u03b1 X)] : is_iso \u03b1 :=\n  is_iso.mk (nat_trans.mk fun (X : C) => inv (nat_trans.app \u03b1 X))\n\n/--\nThe components of a natural isomorphism are isomorphisms.\n-/\nprotected instance is_iso_app_of_is_iso {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u27f6 G) [is_iso \u03b1] (X : C) : is_iso (nat_trans.app \u03b1 X) :=\n  is_iso.mk (nat_trans.app (inv \u03b1) 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D}\n    (app : (X : C) \u2192 functor.obj F X \u2245 functor.obj G X)\n    (naturality :\n      \u2200 {X Y : C} (f : X \u27f6 Y),\n        functor.map F f \u226b iso.hom (app Y) = iso.hom (app X) \u226b functor.map G f) :\n    F \u2245 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : C \u2964 D} (app' : (X : C) \u2192 functor.obj F X \u2245 functor.obj G X)\n    (naturality :\n      \u2200 {X Y : C} (f : X \u27f6 Y),\n        functor.map F f \u226b iso.hom (app' Y) = iso.hom (app' X) \u226b 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\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (app : (X : C) \u2192 functor.obj F X \u2245 functor.obj G X)\n    (naturality :\n      \u2200 {X Y : C} (f : X \u27f6 Y),\n        functor.map F f \u226b iso.hom (app Y) = iso.hom (app X) \u226b 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\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : C \u2964 D} (app : (X : C) \u2192 functor.obj F X \u2245 functor.obj G X)\n    (naturality :\n      \u2200 {X Y : C} (f : X \u27f6 Y),\n        functor.map F f \u226b iso.hom (app Y) = iso.hom (app X) \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E]\n    {F : C \u2964 D} {G : C \u2964 D} {H : D \u2964 E} {I : D \u2964 E} (\u03b1 : F \u2245 G) (\u03b2 : H \u2245 I) : F \u22d9 H \u2245 G \u22d9 I :=\n  iso.mk (iso.hom \u03b1 \u25eb iso.hom \u03b2) (iso.inv \u03b1 \u25eb iso.inv \u03b2)\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\u2081 : Monoid.{u1} M}} {{m\u2082 : Monoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Monoid.mul.{u1} M m\u2081) (Monoid.mul.{u1} M m\u2082)) -> (Eq.{succ u1} (Monoid.{u1} M) m\u2081 m\u2082)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m\u2081 : Monoid.{u1} M}} {{m\u2082 : Monoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M m\u2081))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M m\u2082)))) -> (Eq.{succ u1} (Monoid.{u1} M) m\u2081 m\u2082)\nCase conversion may be inaccurate. Consider using '#align monoid.ext Monoid.ext\u2093'. -/\n@[ext, to_additive]\ntheorem Monoid.ext {M : Type u} \u2983m\u2081 m\u2082 : Monoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\n  by\n  have h\u2081 : (@Monoid.toMulOneClass _ m\u2081).one = (@Monoid.toMulOneClass _ m\u2082).one :=\n    congr_arg (@MulOneClass.one M) (MulOneClass.ext h_mul)\n  set f : @MonoidHom M M (@Monoid.toMulOneClass _ m\u2081) (@Monoid.toMulOneClass _ m\u2082) :=\n    { toFun := id\n      map_one' := h\u2081\n      map_mul' := fun x y => congr_fun (congr_fun h_mul x) y }\n  have hpow : m\u2081.npow = m\u2082.npow := by\n    ext (n x)\n    exact @MonoidHom.map_pow M M m\u2081 m\u2082 f x n\n  cases m\u2081\n  cases m\u2082\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 \u27e8\u27e9 \u27e8\u27e9 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\u2081 : CommMonoid.{u1} M}} {{m\u2082 : CommMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (CommMonoid.mul.{u1} M m\u2081) (CommMonoid.mul.{u1} M m\u2082)) -> (Eq.{succ u1} (CommMonoid.{u1} M) m\u2081 m\u2082)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m\u2081 : CommMonoid.{u1} M}} {{m\u2082 : 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\u2081)))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M (CommMonoid.toMonoid.{u1} M m\u2082))))) -> (Eq.{succ u1} (CommMonoid.{u1} M) m\u2081 m\u2082)\nCase conversion may be inaccurate. Consider using '#align comm_monoid.ext CommMonoid.ext\u2093'. -/\n@[ext, to_additive]\ntheorem CommMonoid.ext {M : Type _} \u2983m\u2081 m\u2082 : CommMonoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 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\u2081 : LeftCancelMonoid.{u1} M}} {{m\u2082 : LeftCancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (LeftCancelMonoid.mul.{u1} M m\u2081) (LeftCancelMonoid.mul.{u1} M m\u2082)) -> (Eq.{succ u1} (LeftCancelMonoid.{u1} M) m\u2081 m\u2082)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m\u2081 : LeftCancelMonoid.{u1} M}} {{m\u2082 : 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\u2081)))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M m\u2082))))) -> (Eq.{succ u1} (LeftCancelMonoid.{u1} M) m\u2081 m\u2082)\nCase conversion may be inaccurate. Consider using '#align left_cancel_monoid.ext LeftCancelMonoid.ext\u2093'. -/\n@[ext, to_additive]\ntheorem LeftCancelMonoid.ext {M : Type u} \u2983m\u2081 m\u2082 : LeftCancelMonoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) :\n    m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 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\u2081 : RightCancelMonoid.{u1} M}} {{m\u2082 : RightCancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (RightCancelMonoid.mul.{u1} M m\u2081) (RightCancelMonoid.mul.{u1} M m\u2082)) -> (Eq.{succ u1} (RightCancelMonoid.{u1} M) m\u2081 m\u2082)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m\u2081 : RightCancelMonoid.{u1} M}} {{m\u2082 : 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\u2081)))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (RightCancelSemigroup.toSemigroup.{u1} M (RightCancelMonoid.toRightCancelSemigroup.{u1} M m\u2082))))) -> (Eq.{succ u1} (RightCancelMonoid.{u1} M) m\u2081 m\u2082)\nCase conversion may be inaccurate. Consider using '#align right_cancel_monoid.ext RightCancelMonoid.ext\u2093'. -/\n@[ext, to_additive]\ntheorem RightCancelMonoid.ext {M : Type u} \u2983m\u2081 m\u2082 : RightCancelMonoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) :\n    m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 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\u2081 : CancelMonoid.{u1} M}} {{m\u2082 : CancelMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (CancelMonoid.mul.{u1} M m\u2081) (CancelMonoid.mul.{u1} M m\u2082)) -> (Eq.{succ u1} (CancelMonoid.{u1} M) m\u2081 m\u2082)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m\u2081 : CancelMonoid.{u1} M}} {{m\u2082 : 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\u2081))))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M (CancelMonoid.toLeftCancelMonoid.{u1} M m\u2082)))))) -> (Eq.{succ u1} (CancelMonoid.{u1} M) m\u2081 m\u2082)\nCase conversion may be inaccurate. Consider using '#align cancel_monoid.ext CancelMonoid.ext\u2093'. -/\n@[ext, to_additive]\ntheorem CancelMonoid.ext {M : Type _} \u2983m\u2081 m\u2082 : CancelMonoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) :\n    m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 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\u2081 : CancelCommMonoid.{u1} M}} {{m\u2082 : CancelCommMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (CancelCommMonoid.mul.{u1} M m\u2081) (CancelCommMonoid.mul.{u1} M m\u2082)) -> (Eq.{succ u1} (CancelCommMonoid.{u1} M) m\u2081 m\u2082)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m\u2081 : CancelCommMonoid.{u1} M}} {{m\u2082 : 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\u2081))))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (LeftCancelSemigroup.toSemigroup.{u1} M (LeftCancelMonoid.toLeftCancelSemigroup.{u1} M (CancelCommMonoid.toLeftCancelMonoid.{u1} M m\u2082)))))) -> (Eq.{succ u1} (CancelCommMonoid.{u1} M) m\u2081 m\u2082)\nCase conversion may be inaccurate. Consider using '#align cancel_comm_monoid.ext CancelCommMonoid.ext\u2093'. -/\n@[ext, to_additive]\ntheorem CancelCommMonoid.ext {M : Type _} \u2983m\u2081 m\u2082 : CancelCommMonoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) :\n    m\u2081 = m\u2082 :=\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\u2081 : DivInvMonoid.{u1} M}} {{m\u2082 : DivInvMonoid.{u1} M}}, (Eq.{succ u1} (M -> M -> M) (DivInvMonoid.mul.{u1} M m\u2081) (DivInvMonoid.mul.{u1} M m\u2082)) -> (Eq.{succ u1} (M -> M) (DivInvMonoid.inv.{u1} M m\u2081) (DivInvMonoid.inv.{u1} M m\u2082)) -> (Eq.{succ u1} (DivInvMonoid.{u1} M) m\u2081 m\u2082)\nbut is expected to have type\n  forall {M : Type.{u1}} {{m\u2081 : DivInvMonoid.{u1} M}} {{m\u2082 : 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\u2081)))) (Mul.mul.{u1} M (Semigroup.toMul.{u1} M (Monoid.toSemigroup.{u1} M (DivInvMonoid.toMonoid.{u1} M m\u2082))))) -> (Eq.{succ u1} (M -> M) (Inv.inv.{u1} M (DivInvMonoid.toInv.{u1} M m\u2081)) (Inv.inv.{u1} M (DivInvMonoid.toInv.{u1} M m\u2082))) -> (Eq.{succ u1} (DivInvMonoid.{u1} M) m\u2081 m\u2082)\nCase conversion may be inaccurate. Consider using '#align div_inv_monoid.ext DivInvMonoid.ext\u2093'. -/\n@[ext, to_additive]\ntheorem DivInvMonoid.ext {M : Type _} \u2983m\u2081 m\u2082 : DivInvMonoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul)\n    (h_inv : m\u2081.inv = m\u2082.inv) : m\u2081 = m\u2082 :=\n  by\n  have h\u2081 : (@DivInvMonoid.toMonoid _ m\u2081).one = (@DivInvMonoid.toMonoid _ m\u2082).one :=\n    congr_arg (@Monoid.one M) (Monoid.ext h_mul)\n  set f : @MonoidHom M M (by letI := m\u2081 <;> infer_instance) (by letI := m\u2082 <;> infer_instance) :=\n    { toFun := id\n      map_one' := h\u2081\n      map_mul' := fun x y => congr_fun (congr_fun h_mul x) y }\n  have hpow : (@DivInvMonoid.toMonoid _ m\u2081).npow = (@DivInvMonoid.toMonoid _ m\u2082).npow :=\n    congr_arg (@Monoid.npow M) (Monoid.ext h_mul)\n  have hzpow : m\u2081.zpow = m\u2082.zpow := by\n    ext (m x)\n    exact @MonoidHom.map_zpow' M M m\u2081 m\u2082 f (congr_fun h_inv) x m\n  have hdiv : m\u2081.div = m\u2082.div := by\n    ext (a b)\n    exact @map_div' M M _ m\u2081 m\u2082 _ f (congr_fun h_inv) a b\n  cases m\u2081\n  cases m\u2082\n  congr\n  exacts[h_mul, h\u2081, 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\u2081 : Group.{u1} G}} {{g\u2082 : Group.{u1} G}}, (Eq.{succ u1} (G -> G -> G) (Group.mul.{u1} G g\u2081) (Group.mul.{u1} G g\u2082)) -> (Eq.{succ u1} (Group.{u1} G) g\u2081 g\u2082)\nbut is expected to have type\n  forall {G : Type.{u1}} {{g\u2081 : Group.{u1} G}} {{g\u2082 : 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\u2081))))) (Mul.mul.{u1} G (Semigroup.toMul.{u1} G (Monoid.toSemigroup.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G g\u2082)))))) -> (Eq.{succ u1} (Group.{u1} G) g\u2081 g\u2082)\nCase conversion may be inaccurate. Consider using '#align group.ext Group.ext\u2093'. -/\n@[ext, to_additive]\ntheorem Group.ext {G : Type _} \u2983g\u2081 g\u2082 : Group G\u2984 (h_mul : g\u2081.mul = g\u2082.mul) : g\u2081 = g\u2082 :=\n  by\n  set f :=\n    @MonoidHom.mk' G G (by letI := g\u2081 <;> infer_instance) g\u2082 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\u2081 (@Group.toDivisionMonoid _ g\u2082) 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\u2081 : CommGroup.{u1} G}} {{g\u2082 : CommGroup.{u1} G}}, (Eq.{succ u1} (G -> G -> G) (CommGroup.mul.{u1} G g\u2081) (CommGroup.mul.{u1} G g\u2082)) -> (Eq.{succ u1} (CommGroup.{u1} G) g\u2081 g\u2082)\nbut is expected to have type\n  forall {G : Type.{u1}} {{g\u2081 : CommGroup.{u1} G}} {{g\u2082 : 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\u2081)))))) (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\u2082))))))) -> (Eq.{succ u1} (CommGroup.{u1} G) g\u2081 g\u2082)\nCase conversion may be inaccurate. Consider using '#align comm_group.ext CommGroup.ext\u2093'. -/\n@[ext, to_additive]\ntheorem CommGroup.ext {G : Type _} \u2983g\u2081 g\u2082 : CommGroup G\u2984 (h_mul : g\u2081.mul = g\u2082.mul) : g\u2081 = g\u2082 :=\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 \u2124} (f : X \u27f6 Y) (g : Y \u27f6 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\u2081 X\u2082 Y\u2081 Y\u2082 : A}\n  (f\u2081\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2081\u2082 : X\u2081 \u27f6 Y\u2082) (f\u2082\u2081 : X\u2082 \u27f6 Y\u2081) (f\u2082\u2082 : X\u2082 \u27f6 Y\u2082) :\n  biprod.lift (biprod.desc f\u2081\u2081 f\u2082\u2081) (biprod.desc f\u2081\u2082 f\u2082\u2082) =\n  biprod.desc (biprod.lift f\u2081\u2081 f\u2081\u2082) (biprod.lift f\u2082\u2081 f\u2082\u2082) :=\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 \u27f6 X) (g : X \u27f6 Y) (h : X \u27f6 Z) :\n  f \u226b biprod.lift g h = biprod.lift (f \u226b g) (f \u226b 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 \u27f6 Y) (g : Y \u27f6 Z) (w : f \u226b g = 0) :\n  f \u226b factor_thru_image g = 0 :=\nby rw [\u2190 cancel_mono (limits.image.\u03b9 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b4 : Type w}\n\ninstance {\u03b1} [inhabited \u03b1] : inhabited (stream \u03b1) :=\n\u27e8stream.const default\u27e9\n\nprotected theorem eta (s : stream \u03b1) : head s :: tail s = s :=\nfunext (\u03bb i, begin cases i; refl end)\n\n@[simp] theorem nth_zero_cons (a : \u03b1) (s : stream \u03b1) : nth (a :: s) 0 = a := rfl\n\ntheorem head_cons (a : \u03b1) (s : stream \u03b1) : head (a :: s) = a := rfl\n\ntheorem tail_cons (a : \u03b1) (s : stream \u03b1) : tail (a :: s) = s := rfl\n\ntheorem tail_drop (n : nat) (s : stream \u03b1) : tail (drop n s) = drop n (tail s) :=\nfunext (\u03bb i, begin unfold tail drop, simp [nth, nat.add_comm, nat.add_left_comm] end)\n\ntheorem nth_drop (n m : nat) (s : stream \u03b1) : nth (drop m s) n = nth s (n + m) := rfl\n\ntheorem tail_eq_drop (s : stream \u03b1) : tail s = drop 1 s := rfl\n\ntheorem drop_drop (n m : nat) (s : stream \u03b1) : drop n (drop m s) = drop (n+m) s :=\nfunext (\u03bb i, begin unfold drop, rw nat.add_assoc end)\n\ntheorem nth_succ (n : nat) (s : stream \u03b1) : nth s (succ n) = nth (tail s) n := rfl\n\n@[simp] lemma nth_succ_cons (n : nat) (s : stream \u03b1) (x : \u03b1) : nth (x :: s) n.succ = nth s n := rfl\n\ntheorem drop_succ (n : nat) (s : stream \u03b1) : drop (succ n) s = drop n (tail s) := rfl\n\n@[simp] lemma head_drop {\u03b1} (a : stream \u03b1) (n : \u2115) : (a.drop n).head = a.nth n :=\nby simp only [drop, head, nat.zero_add, stream.nth]\n\n@[ext] protected theorem ext {s\u2081 s\u2082 : stream \u03b1} : (\u2200 n, nth s\u2081 n = nth s\u2082 n) \u2192 s\u2081 = s\u2082 :=\nassume h, funext h\n\nlemma cons_injective2 : function.injective2 (cons : \u03b1 \u2192 stream \u03b1 \u2192 stream \u03b1) :=\n\u03bb x y s t h, \u27e8by rw [\u2190nth_zero_cons x s, h, nth_zero_cons],\n  stream.ext (\u03bb n, by rw [\u2190nth_succ_cons n _ x, h, nth_succ_cons])\u27e9\n\nlemma cons_injective_left (s : stream \u03b1) : function.injective (\u03bb x, cons x s) :=\ncons_injective2.left _\n\nlemma cons_injective_right (x : \u03b1) : function.injective (cons x) :=\ncons_injective2.right _\n\ntheorem all_def (p : \u03b1 \u2192 Prop) (s : stream \u03b1) : all p s = \u2200 n, p (nth s n) := rfl\n\ntheorem any_def (p : \u03b1 \u2192 Prop) (s : stream \u03b1) : any p s = \u2203 n, p (nth s n) := rfl\n\ntheorem mem_cons (a : \u03b1) (s : stream \u03b1) : a \u2208 (a::s) :=\nexists.intro 0 rfl\n\ntheorem mem_cons_of_mem {a : \u03b1} {s : stream \u03b1} (b : \u03b1) : a \u2208 s \u2192 a \u2208 b :: s :=\nassume \u27e8n, h\u27e9,\nexists.intro (succ n) (by rw [nth_succ, tail_cons, h])\n\ntheorem eq_or_mem_of_mem_cons {a b : \u03b1} {s : stream \u03b1} : a \u2208 b::s \u2192 a = b \u2228 a \u2208 s :=\nassume \u27e8n, h\u27e9,\nbegin\n  cases n with n',\n  { left, exact h },\n  { right, rw [nth_succ, tail_cons] at h, exact \u27e8n', h\u27e9 }\nend\n\ntheorem mem_of_nth_eq {n : nat} {s : stream \u03b1} {a : \u03b1} : a = nth s n \u2192 a \u2208 s :=\nassume h, exists.intro n h\n\nsection map\nvariable (f : \u03b1 \u2192 \u03b2)\n\ntheorem drop_map (n : nat) (s : stream \u03b1) : drop n (map f s) = map f (drop n s) :=\nstream.ext (\u03bb i, rfl)\n\ntheorem nth_map (n : nat) (s : stream \u03b1) : nth (map f s) n = f (nth s n) := rfl\n\ntheorem tail_map (s : stream \u03b1) : tail (map f s) = map f (tail s) :=\nbegin rw tail_eq_drop, refl end\n\ntheorem head_map (s : stream \u03b1) : head (map f s) = f (head s) := rfl\n\ntheorem map_eq (s : stream \u03b1) : map f s = f (head s) :: map f (tail s) :=\nby rw [\u2190 stream.eta (map f s), tail_map, head_map]\n\ntheorem map_cons (a : \u03b1) (s : stream \u03b1) : map f (a :: s) = f a :: map f s :=\nbegin rw [\u2190 stream.eta (map f (a :: s)), map_eq], refl end\n\ntheorem map_id (s : stream \u03b1) : map id s = s := rfl\n\ntheorem map_map (g : \u03b2 \u2192 \u03b4) (f : \u03b1 \u2192 \u03b2) (s : stream \u03b1) : map g (map f s) = map (g \u2218 f) s := rfl\n\ntheorem map_tail (s : stream \u03b1) : map f (tail s) = tail (map f s) := rfl\n\ntheorem mem_map {a : \u03b1} {s : stream \u03b1} : a \u2208 s \u2192 f a \u2208 map f s :=\nassume \u27e8n, h\u27e9,\nexists.intro n (by rw [nth_map, h])\n\ntheorem exists_of_mem_map {f} {b : \u03b2} {s : stream \u03b1} : b \u2208 map f s \u2192 \u2203 a, a \u2208 s \u2227 f a = b :=\nassume \u27e8n, h\u27e9, \u27e8nth s n, \u27e8n, rfl\u27e9, h.symm\u27e9\nend map\n\nsection zip\nvariable (f : \u03b1 \u2192 \u03b2 \u2192 \u03b4)\n\ntheorem drop_zip (n : nat) (s\u2081 : stream \u03b1) (s\u2082 : stream \u03b2) :\n  drop n (zip f s\u2081 s\u2082) = zip f (drop n s\u2081) (drop n s\u2082) :=\nstream.ext (\u03bb i, rfl)\n\ntheorem nth_zip (n : nat) (s\u2081 : stream \u03b1) (s\u2082 : stream \u03b2) :\n  nth (zip f s\u2081 s\u2082) n = f (nth s\u2081 n) (nth s\u2082 n) := rfl\n\ntheorem head_zip (s\u2081 : stream \u03b1) (s\u2082 : stream \u03b2) : head (zip f s\u2081 s\u2082) = f (head s\u2081) (head s\u2082) := rfl\n\ntheorem tail_zip (s\u2081 : stream \u03b1) (s\u2082 : stream \u03b2) :\n  tail (zip f s\u2081 s\u2082) = zip f (tail s\u2081) (tail s\u2082) := rfl\n\ntheorem zip_eq (s\u2081 : stream \u03b1) (s\u2082 : stream \u03b2) :\n  zip f s\u2081 s\u2082 = f (head s\u2081) (head s\u2082) :: zip f (tail s\u2081) (tail s\u2082) :=\nbegin rw [\u2190 stream.eta (zip f s\u2081 s\u2082)], refl end\n\n@[simp] lemma nth_enum (s : stream \u03b1) (n : \u2115) : nth (enum s) n = (n, s.nth n) := rfl\n\nlemma enum_eq_zip (s : stream \u03b1) : enum s = zip prod.mk nats s := rfl\n\nend zip\n\ntheorem mem_const (a : \u03b1) : a \u2208 const a :=\nexists.intro 0 rfl\n\ntheorem const_eq (a : \u03b1) : const a = a :: const a :=\nbegin\n  apply stream.ext, intro n,\n  cases n; refl\nend\n\ntheorem tail_const (a : \u03b1) : tail (const a) = const a :=\nsuffices tail (a :: const a) = const a, by rwa [\u2190 const_eq] at this, rfl\n\ntheorem map_const (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : map f (const a) = const (f a) := rfl\n\ntheorem nth_const (n : nat) (a : \u03b1) : nth (const a) n = a := rfl\n\ntheorem drop_const (n : nat) (a : \u03b1) : drop n (const a) = const a :=\nstream.ext (\u03bb i, rfl)\n\ntheorem head_iterate (f : \u03b1 \u2192 \u03b1) (a : \u03b1) : head (iterate f a) = a := rfl\n\ntheorem tail_iterate (f : \u03b1 \u2192 \u03b1) (a : \u03b1) : 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 : \u03b1 \u2192 \u03b1) (a : \u03b1) : iterate f a = a :: iterate f (f a) :=\nbegin\n  rw [\u2190 stream.eta (iterate f a)],\n  rw tail_iterate, refl\nend\n\ntheorem nth_zero_iterate (f : \u03b1 \u2192 \u03b1) (a : \u03b1) : nth (iterate f a) 0 = a := rfl\n\ntheorem nth_succ_iterate (n : nat) (f : \u03b1 \u2192 \u03b1) (a : \u03b1) :\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 \u03b1 \u2192 stream \u03b1 \u2192 Prop)\n  local infix ` ~ `:50 := R\n\n  def is_bisimulation := \u2200 \u2983s\u2081 s\u2082\u2984, s\u2081 ~ s\u2082 \u2192 head s\u2081 = head s\u2082 \u2227 tail s\u2081 ~ tail s\u2082\n\n  theorem nth_of_bisim (bisim : is_bisimulation R) :\n    \u2200 {s\u2081 s\u2082} n, s\u2081 ~ s\u2082 \u2192 nth s\u2081 n = nth s\u2082 n \u2227 drop (n+1) s\u2081 ~ drop (n+1) s\u2082\n  | s\u2081 s\u2082 0     h := bisim h\n  | s\u2081 s\u2082 (n+1) h :=\n    match bisim h with\n    | \u27e8h\u2081, trel\u27e9 := 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) : \u2200 {s\u2081 s\u2082}, s\u2081 ~ s\u2082 \u2192 s\u2081 = s\u2082 :=\n  \u03bb s\u2081 s\u2082 r, stream.ext (\u03bb n, and.elim_left (nth_of_bisim R bisim n r))\nend bisim\n\ntheorem bisim_simple (s\u2081 s\u2082 : stream \u03b1) :\n  head s\u2081 = head s\u2082 \u2192 s\u2081 = tail s\u2081 \u2192 s\u2082 = tail s\u2082 \u2192 s\u2081 = s\u2082 :=\nassume hh ht\u2081 ht\u2082, eq_of_bisim\n  (\u03bb s\u2081 s\u2082, head s\u2081 = head s\u2082 \u2227 s\u2081 = tail s\u2081 \u2227 s\u2082 = tail s\u2082)\n  (\u03bb s\u2081 s\u2082 \u27e8h\u2081, h\u2082, h\u2083\u27e9,\n    begin\n      constructor, exact h\u2081, rw [\u2190 h\u2082, \u2190 h\u2083], repeat { constructor }; assumption\n    end)\n  (and.intro hh (and.intro ht\u2081 ht\u2082))\n\ntheorem coinduction {s\u2081 s\u2082 : stream \u03b1} :\n  head s\u2081 = head s\u2082 \u2192 (\u2200 (\u03b2 : Type u) (fr : stream \u03b1 \u2192 \u03b2), fr s\u2081 = fr s\u2082 \u2192\n    fr (tail s\u2081) = fr (tail s\u2082)) \u2192 s\u2081 = s\u2082 :=\nassume hh ht,\n  eq_of_bisim\n    (\u03bb s\u2081 s\u2082, head s\u2081 = head s\u2082 \u2227 \u2200 (\u03b2 : Type u) (fr : stream \u03b1 \u2192 \u03b2), fr s\u2081 = fr s\u2082 \u2192\n      fr (tail s\u2081) = fr (tail s\u2082))\n    (\u03bb s\u2081 s\u2082 h,\n      have h\u2081 : head s\u2081 = head s\u2082,               from and.elim_left h,\n      have h\u2082 : head (tail s\u2081) = head (tail s\u2082), from and.elim_right h \u03b1 (@head \u03b1) h\u2081,\n      have h\u2083 : \u2200 (\u03b2 : Type u) (fr : stream \u03b1 \u2192 \u03b2),\n        fr (tail s\u2081) = fr (tail s\u2082) \u2192 fr (tail (tail s\u2081)) = fr (tail (tail s\u2082)),\n      from \u03bb \u03b2 fr, and.elim_right h \u03b2 (\u03bb s, fr (tail s)),\n      and.intro h\u2081 (and.intro h\u2082 h\u2083))\n    (and.intro hh ht)\n\ntheorem iterate_id (a : \u03b1) : iterate id a = const a :=\ncoinduction\n  rfl\n  (\u03bb \u03b2 fr ch, begin rw [tail_iterate, tail_const], exact ch end)\n\nlocal attribute [reducible] stream\ntheorem map_iterate (f : \u03b1 \u2192 \u03b1) (a : \u03b1) : 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 : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b1) (a : \u03b1) : corec f g a = map f (iterate g a) := rfl\n\ntheorem corec_eq (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b1) (a : \u03b1) : 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 : \u03b1) : corec id id a = const a :=\nby rw [corec_def, map_id, iterate_id]\n\ntheorem corec_id_f_eq_iterate (f : \u03b1 \u2192 \u03b1) (a : \u03b1) : corec id f a = iterate f a := rfl\nend corec\n\nsection corec'\n\ntheorem corec'_eq (f : \u03b1 \u2192 \u03b2 \u00d7 \u03b1) (a : \u03b1) : corec' f a = (f a).1 :: corec' f (f a).2 :=\ncorec_eq _ _ _\n\nend corec'\n\ntheorem unfolds_eq (g : \u03b1 \u2192 \u03b2) (f : \u03b1 \u2192 \u03b1) (a : \u03b1) : unfolds g f a = g a :: unfolds g f (f a) :=\nbegin unfold unfolds, rw [corec_eq] end\n\ntheorem nth_unfolds_head_tail : \u2200 (n : nat) (s : stream \u03b1), 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 : \u2200 (s : stream \u03b1), unfolds head tail s = s :=\n\u03bb s, stream.ext (\u03bb n, nth_unfolds_head_tail n s)\n\ntheorem interleave_eq (s\u2081 s\u2082 : stream \u03b1) : s\u2081 \u22c8 s\u2082 = head s\u2081 :: head s\u2082 :: (tail s\u2081 \u22c8 tail s\u2082) :=\nbegin\n  unfold interleave corec_on, rw corec_eq, dsimp, rw corec_eq, refl\nend\n\ntheorem tail_interleave (s\u2081 s\u2082 : stream \u03b1) : tail (s\u2081 \u22c8 s\u2082) = s\u2082 \u22c8 (tail s\u2081) :=\nbegin unfold interleave corec_on, rw corec_eq, refl end\n\ntheorem interleave_tail_tail (s\u2081 s\u2082 : stream \u03b1) : tail s\u2081 \u22c8 tail s\u2082 = tail (tail (s\u2081 \u22c8 s\u2082)) :=\nbegin rw [interleave_eq s\u2081 s\u2082], refl end\n\ntheorem nth_interleave_left : \u2200 (n : nat) (s\u2081 s\u2082 : stream \u03b1), nth (s\u2081 \u22c8 s\u2082) (2 * n) = nth s\u2081 n\n| 0        s\u2081 s\u2082 := rfl\n| (succ n) s\u2081 s\u2082 :=\n  begin\n    change nth (s\u2081 \u22c8 s\u2082) (succ (succ (2*n))) = nth s\u2081 (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 : \u2200 (n : nat) (s\u2081 s\u2082 : stream \u03b1), nth (s\u2081 \u22c8 s\u2082) (2*n+1) = nth s\u2082 n\n| 0        s\u2081 s\u2082 := rfl\n| (succ n) s\u2081 s\u2082 :=\n  begin\n    change nth (s\u2081 \u22c8 s\u2082) (succ (succ (2*n+1))) = nth s\u2082 (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 : \u03b1} {s\u2081 : stream \u03b1} (s\u2082 : stream \u03b1) : a \u2208 s\u2081 \u2192 a \u2208 s\u2081 \u22c8 s\u2082 :=\nassume \u27e8n, h\u27e9,\nexists.intro (2*n) (by rw [h, nth_interleave_left])\n\ntheorem mem_interleave_right {a : \u03b1} {s\u2081 : stream \u03b1} (s\u2082 : stream \u03b1) : a \u2208 s\u2082 \u2192 a \u2208 s\u2081 \u22c8 s\u2082 :=\nassume \u27e8n, h\u27e9,\nexists.intro (2*n+1) (by rw [h, nth_interleave_right])\n\ntheorem odd_eq (s : stream \u03b1) : odd s = even (tail s) := rfl\n\ntheorem head_even (s : stream \u03b1) : head (even s) = head s := rfl\n\ntheorem tail_even (s : stream \u03b1) : tail (even s) = even (tail (tail s)) :=\nbegin unfold even, rw corec_eq, refl end\n\ntheorem even_cons_cons (a\u2081 a\u2082 : \u03b1) (s : stream \u03b1) : even (a\u2081 :: a\u2082 :: s) = a\u2081 :: even s :=\nbegin unfold even, rw corec_eq, refl end\n\ntheorem even_tail (s : stream \u03b1) : even (tail s) = odd s := rfl\n\ntheorem even_interleave (s\u2081 s\u2082 : stream \u03b1) : even (s\u2081 \u22c8 s\u2082) = s\u2081 :=\neq_of_bisim\n  (\u03bb s\u2081' s\u2081, \u2203 s\u2082, s\u2081' = even (s\u2081 \u22c8 s\u2082))\n  (\u03bb s\u2081' s\u2081 \u27e8s\u2082, h\u2081\u27e9,\n    begin\n      rw h\u2081,\n      constructor,\n       {refl},\n       {exact \u27e8tail s\u2082, by rw [interleave_eq, even_cons_cons, tail_cons]\u27e9}\n    end)\n  (exists.intro s\u2082 rfl)\n\ntheorem interleave_even_odd (s\u2081 : stream \u03b1) : even s\u2081 \u22c8 odd s\u2081 = s\u2081 :=\neq_of_bisim\n  (\u03bb s' s, s' = even s \u22c8 odd s)\n  (\u03bb s' s (h : s' = even s \u22c8 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 : \u2200 (n : nat) (s : stream \u03b1), 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 : \u2200 (n : nat) (s : stream \u03b1), nth (odd s) n = nth s (2 * n + 1) :=\n\u03bb n s, begin rw [odd_eq, nth_even], refl end\n\ntheorem mem_of_mem_even (a : \u03b1) (s : stream \u03b1) : a \u2208 even s \u2192 a \u2208 s :=\nassume \u27e8n, h\u27e9,\nexists.intro (2*n) (by rw [h, nth_even])\n\ntheorem mem_of_mem_odd (a : \u03b1) (s : stream \u03b1) : a \u2208 odd s \u2192 a \u2208 s :=\nassume \u27e8n, h\u27e9,\nexists.intro (2*n+1) (by rw [h, nth_odd])\n\ntheorem nil_append_stream (s : stream \u03b1) : append_stream [] s = s := rfl\n\ntheorem cons_append_stream (a : \u03b1) (l : list \u03b1) (s : stream \u03b1) :\n  append_stream (a::l) s = a :: append_stream l s := rfl\n\ntheorem append_append_stream :\n  \u2200 (l\u2081 l\u2082 : list \u03b1) (s : stream \u03b1), (l\u2081 ++ l\u2082) ++\u209b s = l\u2081 ++\u209b (l\u2082 ++\u209b s)\n| []               l\u2082 s := rfl\n| (list.cons a l\u2081) l\u2082 s := by rw [list.cons_append, cons_append_stream, cons_append_stream,\n                                  append_append_stream]\n\ntheorem map_append_stream (f : \u03b1 \u2192 \u03b2) :\n  \u2200 (l : list \u03b1) (s : stream \u03b1), map f (l ++\u209b s) = list.map f l ++\u209b 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 : \u2200 (l : list \u03b1) (s : stream \u03b1), drop l.length (l ++\u209b 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 \u03b1) : [head s] ++\u209b tail s = s :=\nby rw [cons_append_stream, nil_append_stream, stream.eta]\n\ntheorem mem_append_stream_right : \u2200 {a : \u03b1} (l : list \u03b1) {s : stream \u03b1}, a \u2208 s \u2192 a \u2208 l ++\u209b s\n| a []              s h := h\n| a (list.cons b l) s h :=\n  have ih : a \u2208 l ++\u209b s, from mem_append_stream_right l h,\n  mem_cons_of_mem _ ih\n\ntheorem mem_append_stream_left : \u2200 {a : \u03b1} {l : list \u03b1} (s : stream \u03b1), a \u2208 l \u2192 a \u2208 l ++\u209b 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    (\u03bb (aeqb : a = b), exists.intro 0 aeqb)\n    (\u03bb (ainl : a \u2208 l), mem_cons_of_mem b (mem_append_stream_left s ainl))\n\n@[simp] theorem take_zero (s : stream \u03b1) : take 0 s = [] := rfl\n\n@[simp] theorem take_succ (n : nat) (s : stream \u03b1) :\n  take (succ n) s = head s :: take n (tail s) := rfl\n\n@[simp] theorem length_take (n : \u2115) (s : stream \u03b1) : (take n s).length = n :=\nby induction n generalizing s; simp *\n\ntheorem nth_take_succ : \u2200 (n : nat) (s : stream \u03b1), 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  \u2200 (n : nat) (s : stream \u03b1), 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\u2081 s\u2082 : stream \u03b1) : (\u2200 (n : nat), take n s\u2081 = take n s\u2082) \u2192 s\u2081 = s\u2082 :=\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\u2081 : some (nth s\u2081 (succ n)) = some (nth s\u2082 (succ n)),\n    { rw [\u2190 nth_take_succ, \u2190 nth_take_succ, h (succ (succ n))] },\n    injection h\u2081 }\nend\n\nprotected lemma cycle_g_cons (a : \u03b1) (a\u2081 : \u03b1) (l\u2081 : list \u03b1) (a\u2080 : \u03b1) (l\u2080 : list \u03b1) :\n              stream.cycle_g (a, a\u2081::l\u2081, a\u2080, l\u2080) = (a\u2081, l\u2081, a\u2080, l\u2080) := rfl\n\ntheorem cycle_eq : \u2200 (l : list \u03b1) (h : l \u2260 []), cycle l h = l ++\u209b cycle l h\n| []              h := absurd rfl h\n| (list.cons a l) h :=\n  have gen : \u2200 l' a', corec stream.cycle_f stream.cycle_g (a', l', a, l) =\n    (a' :: l') ++\u209b corec stream.cycle_f stream.cycle_g (a, l, a, l),\n    begin\n      intro l',\n      induction l' with a\u2081 l\u2081 ih,\n        {intros, rw [corec_eq], refl},\n        {intros, rw [corec_eq, stream.cycle_g_cons, ih a\u2081], refl}\n    end,\n  gen l a\n\ntheorem mem_cycle {a : \u03b1} {l : list \u03b1} : \u2200 (h : l \u2260 []), a \u2208 l \u2192 a \u2208 cycle l h :=\nassume h ainl, begin rw [cycle_eq], exact mem_append_stream_left _ ainl end\n\ntheorem cycle_singleton (a : \u03b1) (h : [a] \u2260 []) : cycle [a] h = const a :=\ncoinduction\n  rfl\n  (\u03bb \u03b2 fr ch, by rwa [cycle_eq, const_eq])\n\ntheorem tails_eq (s : stream \u03b1) : tails s = tail s :: tails (tail s) :=\nby unfold tails; rw [corec_eq]; refl\n\ntheorem nth_tails : \u2200 (n : nat) (s : stream \u03b1), 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 \u03b1) : tails s = iterate tail (tail s) := rfl\n\ntheorem inits_core_eq (l : list \u03b1) (s : stream \u03b1) :\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 \u03b1) :\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 \u03b1) :\n  inits (tail s) = inits_core [head (tail s)] (tail (tail s)) := rfl\n\n\n\ntheorem nth_inits : \u2200 (n : nat) (s : stream \u03b1), 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, \u2190 ih, tail_inits, inits_tail, cons_nth_inits_core] }\nend\n\ntheorem inits_eq (s : stream \u03b1) : 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 \u03b1) : 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 \u03b1) : pure id \u229b s = s := rfl\ntheorem composition (g : stream (\u03b2 \u2192 \u03b4)) (f : stream (\u03b1 \u2192 \u03b2)) (s : stream \u03b1) :\n  pure comp \u229b g \u229b f \u229b s = g \u229b (f \u229b s) := rfl\ntheorem homomorphism (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : pure f \u229b pure a = pure (f a) := rfl\ntheorem interchange (fs : stream (\u03b1 \u2192 \u03b2)) (a : \u03b1) :\n  fs \u229b pure a = pure (\u03bb f : \u03b1 \u2192 \u03b2, f a) \u229b fs := rfl\ntheorem map_eq_apply (f : \u03b1 \u2192 \u03b2) (s : stream \u03b1) : map f s = pure f \u229b 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 \u00abDivseq2\u00bb\n\nopen Nat\n\nnamespace divseq2\n  theorem h\u2080\u2083 (m : Nat) : 18 * (2 * m) + 13 = succ (succ (succ (succ ((succ ((succ (m * 3 * 2)) * 2)) * 3)))) := by linarith\n  theorem h\u2080\u2084 (m : Nat) : 9 * (4 * m + 1) + 16 = succ (succ (succ (succ ((succ ((succ ((succ (m * 3)) * 2)) * 2)) * 3)))) := by linarith\n  --theorem h\u2080\u20851 (m : Nat) : 36 * m + 37 = succ (succ (succ (succ ((succ ((succ ((succ (succ (m * 3))) * 2)) * 2)) * 3)))) := by linarith\n  axiom   h\u2080\u2085 (m : Nat) : (9 * (8 * m + 7) + 11) / 2 = succ (succ (succ (succ ((succ ((succ ((succ (succ (m * 3))) * 2)) * 2)) * 3))))\n  axiom   h\u2080\u2086 (l : Nat) : (16 * l + 3) + (16 * l + 3 - 3) / 8 + 1 = succ (succ (succ (succ (l * 3 * 2 * 3))))\n  axiom   h\u2080\u2087 (l : Nat) : 8 * l + 4 + (8 * l + 4 - 4) / 4 * 5 + 6 = succ (succ (succ (succ (((succ (l * 3)) * 2) * 3))))\n  axiom   h\u2080\u2088 (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\u2081\u2082 (l : Nat) : 9 * (2 * l) + 6 = succ (succ (succ ((succ (l * 3 * 2)) * 3))) := by linarith\n  axiom   h\u2081\u2083 (l : Nat) : (9 * (4 * l + 1) + 15) / 2 = succ (succ (succ ((succ ((succ (l * 3)) * 2)) * 3)))\n  axiom   h\u2081\u2084 (l : Nat) : (9 * (8 * l + 7) + 9) / 4 = succ (succ (succ ((succ ((succ (succ (l * 3))) * 2)) * 3)))\n  -- \u5341\u5206\u6761\u4ef6\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\u2080\u2083 m) p3; p4\n    | SingleLimited.is04 m p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ _ p3 _ _ _ => have p4 := Eq.subst (h\u2080\u2084 m) p3; p4\n    | SingleLimited.is05 m p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ _ _ p3 _ _ => have p4 := Eq.subst (h\u2080\u2085 m) p3; p4\n    | SingleLimited.is06 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ p3 _ _ _ _ _ _ => have p4 := Eq.subst (h\u2080\u2086 l) p3; p4\n    | SingleLimited.is07 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ p3 _ _ _ _ _ => have p4 := Eq.subst (h\u2080\u2087 l) p3; p4\n    | SingleLimited.is08 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ p3 _ _ _ _ => have p4 := Eq.subst (h\u2080\u2088 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\u2081\u2082 l) p3; p4\n    | SingleLimited.is13 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ _ _ _ p3 _ => have p4 := Eq.subst (h\u2081\u2083 l) p3; p4\n    | SingleLimited.is14 l p2 => match p2 with\n      | ExtsLimited.is _ _ _ _ _ _ _ _ _ _ _ _ _ p3 => have p4 := Eq.subst (h\u2081\u2084 l) p3; p4\n\n  theorem m\u2080\u2082\u2081 (l : Nat) : l < succ (succ (succ (succ (succ (l * 2 * 2) * 3)))) := by linarith\n  theorem m\u2080\u2083\u2081 (m : Nat) : 2 * m < succ (succ (succ (succ (succ (succ (m * 3 * 2) * 2) * 3)))) := by linarith\n  theorem m\u2080\u2084\u2081 (m : Nat) : 4 * m + 1 < succ (succ (succ (succ (succ (succ (succ (m * 3) * 2) * 2) * 3)))) := by linarith\n  theorem m\u2080\u2085\u2081 (m : Nat) : 8 * m + 7 < succ (succ (succ (succ (succ (succ (succ (succ (m * 3)) * 2) * 2) * 3)))) := by linarith\n  theorem m\u2080\u2086\u2081 (l : Nat) : 16 * l + 3 < succ (succ (succ (succ (l * 3 * 2 * 3)))) := by linarith\n  theorem m\u2080\u2087\u2081 (l : Nat) : 8 * l + 4 < succ (succ (succ (succ (succ (l * 3) * 2 * 3)))) := by linarith\n  theorem m\u2080\u2088\u2081 (l : Nat) : 4 * l + 3 < succ (succ (succ (succ (succ (succ (l * 3)) * 2 * 3)))) := by linarith\n  theorem m\u2080\u2089\u2081 (j : Nat) : j < succ (succ (j * 3)) := by linarith\n  theorem m\u2081\u2081\u2081 (k : Nat) : k < succ (succ (succ (k * 2 * 3))) := by linarith\n  theorem m\u2081\u2082\u2081 (l : Nat) : 2 * l < succ (succ (succ (succ (l * 3 * 2) * 3))) := by linarith\n  theorem m\u2081\u2083\u2081 (l : Nat) : 4 * l + 1 < succ (succ (succ (succ (succ (l * 3) * 2) * 3))) := by linarith\n  theorem m\u2081\u2084\u2081 (l : Nat) : 8 * l + 7 < succ (succ (succ (succ (succ (succ (l * 3)) * 2) * 3))) := by linarith\n  def makeLimitedDivSeq (x : Nat) (rs : \u2200 x\u2081, x\u2081 < x \u2192 SingleLimited x\u2081) : 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\u2080\u2089\u2081 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\u2081\u2081\u2081 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\u2081\u2082\u2081 l); have ext := singleToExts (2 * l) sin;\n              exact SingleLimited.is12 l ext;\n          | threeOne l  =>\n              have sin := rs (4 * l + 1) (m\u2081\u2083\u2081 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\u2081\u2084\u2081 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\u2080\u2086\u2081 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\u2080\u2087\u2081 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\u2080\u2088\u2081 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\u2080\u2082\u2081 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\u2080\u2083\u2081 m); have ext := singleToExts (2 * m) sin;\n                exact SingleLimited.is03 m ext;\n            | threeOne m  =>\n                have sin := rs (4 * m + 1) (m\u2080\u2084\u2081 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\u2080\u2085\u2081 m); have ext := singleToExts (8 * m + 7) sin;\n                exact SingleLimited.is05 m ext;\n  -- \u6700\u7d42\u7684\u306a\u5b9a\u7406\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) 2020 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\n\nuniverse u v w\n\n@[inline] def id {\u03b1 : Sort u} (a : \u03b1) : \u03b1 := a\n\n@[inline] def Function.comp {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b4 : Sort w} (f : \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b4 :=\n  fun x => f (g x)\n\n@[inline] def Function.const {\u03b1 : Sort u} (\u03b2 : Sort v) (a : \u03b1) : \u03b2 \u2192 \u03b1 :=\n  fun x => a\n\nset_option checkBinderAnnotations false in\n@[reducible] def inferInstance {\u03b1 : Sort u} [i : \u03b1] : \u03b1 := i\nset_option checkBinderAnnotations false in\n@[reducible] def inferInstanceAs (\u03b1 : Sort u) [i : \u03b1] : \u03b1 := i\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\ninductive PUnit : Sort u where\n  | unit : PUnit\n\n/-- An abbreviation for `PUnit.{0}`, its most common instantiation.\n    This Type should be preferred over `PUnit` where possible to avoid\n    unnecessary universe parameters. -/\nabbrev Unit : Type := PUnit\n\n@[matchPattern] abbrev Unit.unit : Unit := PUnit.unit\n\n/-- Auxiliary unsafe constant used by the Compiler when erasing proofs from code. -/\nunsafe axiom lcProof {\u03b1 : Prop} : \u03b1\n\n/-- Auxiliary unsafe constant used by the Compiler to mark unreachable code. -/\nunsafe axiom lcUnreachable {\u03b1 : Sort u} : \u03b1\n\ninductive True : Prop where\n  | intro : True\n\ninductive False : Prop\n\ninductive Empty : Type\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\ninductive PEmpty : Sort u where\n\ndef Not (a : Prop) : Prop := a \u2192 False\n\n@[macroInline] def False.elim {C : Sort u} (h : False) : C :=\n  False.rec (fun _ => C) h\n\n@[macroInline] def absurd {a : Prop} {b : Sort v} (h\u2081 : a) (h\u2082 : Not a) : b :=\n  False.elim (h\u2082 h\u2081)\n\ninductive Eq {\u03b1 : Sort u} (a : \u03b1) : \u03b1 \u2192 Prop where\n  | refl {} : Eq a a\n\n@[simp] abbrev Eq.ndrec.{u1, u2} {\u03b1 : Sort u2} {a : \u03b1} {motive : \u03b1 \u2192 Sort u1} (m : motive a) {b : \u03b1} (h : Eq a b) : motive b :=\n  Eq.rec (motive := fun \u03b1 _ => motive \u03b1) m h\n\n@[matchPattern] def rfl {\u03b1 : Sort u} {a : \u03b1} : Eq a a := Eq.refl a\n\n@[simp] theorem id_eq (a : \u03b1) : Eq (id a) a := rfl\n\ntheorem Eq.subst {\u03b1 : Sort u} {motive : \u03b1 \u2192 Prop} {a b : \u03b1} (h\u2081 : Eq a b) (h\u2082 : motive a) : motive b :=\n  Eq.ndrec h\u2082 h\u2081\n\ntheorem Eq.symm {\u03b1 : Sort u} {a b : \u03b1} (h : Eq a b) : Eq b a :=\n  h \u25b8 rfl\n\ntheorem Eq.trans {\u03b1 : Sort u} {a b c : \u03b1} (h\u2081 : Eq a b) (h\u2082 : Eq b c) : Eq a c :=\n  h\u2082 \u25b8 h\u2081\n\n@[macroInline] def cast {\u03b1 \u03b2 : Sort u} (h : Eq \u03b1 \u03b2) (a : \u03b1) : \u03b2 :=\n  Eq.rec (motive := fun \u03b1 _ => \u03b1) a h\n\ntheorem congrArg {\u03b1 : Sort u} {\u03b2 : Sort v} {a\u2081 a\u2082 : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : Eq a\u2081 a\u2082) : Eq (f a\u2081) (f a\u2082) :=\n  h \u25b8 rfl\n\ntheorem congr {\u03b1 : Sort u} {\u03b2 : Sort v} {f\u2081 f\u2082 : \u03b1 \u2192 \u03b2} {a\u2081 a\u2082 : \u03b1} (h\u2081 : Eq f\u2081 f\u2082) (h\u2082 : Eq a\u2081 a\u2082) : Eq (f\u2081 a\u2081) (f\u2082 a\u2082) :=\n  h\u2081 \u25b8 h\u2082 \u25b8 rfl\n\ntheorem congrFun {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {f g : (x : \u03b1) \u2192  \u03b2 x} (h : Eq f g) (a : \u03b1) : Eq (f a) (g a) :=\n  h \u25b8 rfl\n\n/-\nInitialize the Quotient Module, which effectively adds the following definitions:\n\nconstant Quot {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Sort u\n\nconstant Quot.mk {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : Quot r\n\nconstant Quot.lift {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) :\n  (\u2200 a b : \u03b1, r a b \u2192 Eq (f a) (f b)) \u2192 Quot r \u2192 \u03b2\n\nconstant Quot.ind {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Quot r \u2192 Prop} :\n  (\u2200 a : \u03b1, \u03b2 (Quot.mk r a)) \u2192 \u2200 q : Quot r, \u03b2 q\n-/\ninit_quot\n\ninductive HEq {\u03b1 : Sort u} (a : \u03b1) : {\u03b2 : Sort u} \u2192 \u03b2 \u2192 Prop where\n  | refl {} : HEq a a\n\n@[matchPattern] protected def HEq.rfl {\u03b1 : Sort u} {a : \u03b1} : HEq a a :=\n  HEq.refl a\n\ntheorem eq_of_heq {\u03b1 : Sort u} {a a' : \u03b1} (h : HEq a a') : Eq a a' :=\n  have : (\u03b1 \u03b2 : Sort u) \u2192 (a : \u03b1) \u2192 (b : \u03b2) \u2192 HEq a b \u2192 (h : Eq \u03b1 \u03b2) \u2192 Eq (cast h a) b :=\n    fun \u03b1 \u03b2 a b h\u2081 =>\n      HEq.rec (motive := fun {\u03b2} (b : \u03b2) (h : HEq a b) => (h\u2082 : Eq \u03b1 \u03b2) \u2192 Eq (cast h\u2082 a) b)\n        (fun (h\u2082 : Eq \u03b1 \u03b1) => rfl)\n        h\u2081\n  this \u03b1 \u03b1 a a' h rfl\n\nstructure Prod (\u03b1 : Type u) (\u03b2 : Type v) where\n  fst : \u03b1\n  snd : \u03b2\n\nattribute [unbox] Prod\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` can be propositions.\n   We use this Type internally to automatically generate the brecOn recursor. -/\nstructure PProd (\u03b1 : Sort u) (\u03b2 : Sort v) where\n  fst : \u03b1\n  snd : \u03b2\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` are in the same universe. -/\nstructure MProd (\u03b1 \u03b2 : Type u) where\n  fst : \u03b1\n  snd : \u03b2\n\nstructure And (a b : Prop) : Prop where\n  intro :: (left : a) (right : b)\n\ninductive Or (a b : Prop) : Prop where\n  | inl (h : a) : Or a b\n  | inr (h : b) : Or a b\n\ntheorem Or.intro_left (b : Prop) (h : a) : Or a b :=\n  Or.inl h\n\ntheorem Or.intro_right (a : Prop) (h : b) : Or a b :=\n  Or.inr h\n\ntheorem Or.elim {c : Prop} (h : Or a b) (left : a \u2192 c) (right : b \u2192 c) : c :=\n  match h with\n  | Or.inl h => left h\n  | Or.inr h => right h\n\ninductive Bool : Type where\n  | false : Bool\n  | true : Bool\n\nexport Bool (false true)\n\n/- Remark: Subtype must take a Sort instead of Type because of the axiom strongIndefiniteDescription. -/\nstructure Subtype {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) where\n  val : \u03b1\n  property : p val\n\n/-- Gadget for optional parameter support. -/\n@[reducible] def optParam (\u03b1 : Sort u) (default : \u03b1) : Sort u := \u03b1\n\n/-- Gadget for marking output parameters in type classes. -/\n@[reducible] def outParam (\u03b1 : Sort u) : Sort u := \u03b1\n\n/-- Auxiliary Declaration used to implement the notation (a : \u03b1) -/\n@[reducible] def typedExpr (\u03b1 : Sort u) (a : \u03b1) : \u03b1 := a\n\n/-- Auxiliary Declaration used to implement the named patterns `x@h:p` -/\n@[reducible] def namedPattern {\u03b1 : Sort u} (x a : \u03b1) (h : Eq x a) : \u03b1 := a\n\n/- Auxiliary axiom used to implement `sorry`. -/\n@[extern \"lean_sorry\", neverExtract]\naxiom sorryAx (\u03b1 : Sort u) (synthetic := true) : \u03b1\n\ntheorem eq_false_of_ne_true : {b : Bool} \u2192 Not (Eq b true) \u2192 Eq b false\n  | true, h => False.elim (h rfl)\n  | false, h => rfl\n\ntheorem eq_true_of_ne_false : {b : Bool} \u2192 Not (Eq b false) \u2192 Eq b true\n  | true, h => rfl\n  | false, h => False.elim (h rfl)\n\ntheorem ne_false_of_eq_true : {b : Bool} \u2192 Eq b true \u2192 Not (Eq b false)\n  | true, _  => fun h => Bool.noConfusion h\n  | false, h => Bool.noConfusion h\n\ntheorem ne_true_of_eq_false : {b : Bool} \u2192 Eq b false \u2192 Not (Eq b true)\n  | true, h  => Bool.noConfusion h\n  | false, _ => fun h => Bool.noConfusion h\n\nclass Inhabited (\u03b1 : Sort u) where\n  mk {} :: (default : \u03b1)\n\nexport Inhabited (default)\n\nclass inductive Nonempty (\u03b1 : Sort u) : Prop where\n  | intro (val : \u03b1) : Nonempty \u03b1\n\naxiom Classical.choice {\u03b1 : Sort u} : Nonempty \u03b1 \u2192 \u03b1\n\nprotected def Nonempty.elim {\u03b1 : Sort u} {p : Prop} (h\u2081 : Nonempty \u03b1) (h\u2082 : \u03b1 \u2192 p) : p :=\n  h\u2082 h\u2081.1\n\ninstance {\u03b1 : Sort u} [Inhabited \u03b1] : Nonempty \u03b1 :=\n  \u27e8default\u27e9\n\nnoncomputable def Classical.ofNonempty {\u03b1 : Sort u} [Nonempty \u03b1] : \u03b1 :=\n  Classical.choice inferInstance\n\ninstance (\u03b1 : Sort u) {\u03b2 : Sort v} [Nonempty \u03b2] : Nonempty (\u03b1 \u2192 \u03b2) :=\n  Nonempty.intro fun _ => Classical.ofNonempty\n\ninstance (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(a : \u03b1) \u2192 Nonempty (\u03b2 a)] : Nonempty ((a : \u03b1) \u2192 \u03b2 a) :=\n  Nonempty.intro fun _ => Classical.ofNonempty\n\ninstance : Inhabited (Sort u) where\n  default := PUnit\n\ninstance (\u03b1 : Sort u) {\u03b2 : Sort v} [Inhabited \u03b2] : Inhabited (\u03b1 \u2192 \u03b2) where\n  default := fun _ => default\n\ninstance (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(a : \u03b1) \u2192 Inhabited (\u03b2 a)] : Inhabited ((a : \u03b1) \u2192 \u03b2 a) where\n  default := fun _ => default\n\nderiving instance Inhabited for Bool\n\n/-- Universe lifting operation from Sort to Type -/\nstructure PLift (\u03b1 : Sort u) : Type u where\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and PLift \u03b1 -/\ntheorem PLift.up_down {\u03b1 : Sort u} : \u2200 (b : PLift \u03b1), Eq (up (down b)) b\n  | up a => rfl\n\ntheorem PLift.down_up {\u03b1 : Sort u} (a : \u03b1) : Eq (down (up a)) a :=\n  rfl\n\n/- Pointed types -/\ndef NonemptyType := Subtype fun \u03b1 : Type u => Nonempty \u03b1\n\nabbrev NonemptyType.type (type : NonemptyType.{u}) : Type u :=\n  type.val\n\ninstance : Inhabited NonemptyType.{u} where\n  default := \u27e8PUnit.{u+1}, Nonempty.intro \u27e8\u27e9\u27e9\n\n/-- Universe lifting operation -/\nstructure ULift.{r, s} (\u03b1 : Type s) : Type (max s r) where\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and ULift.{v} \u03b1 -/\ntheorem ULift.up_down {\u03b1 : Type u} : \u2200 (b : ULift.{v} \u03b1), Eq (up (down b)) b\n  | up a => rfl\n\ntheorem ULift.down_up {\u03b1 : Type u} (a : \u03b1) : Eq (down (up.{v} a)) a :=\n  rfl\n\nclass inductive Decidable (p : Prop) where\n  | isFalse (h : Not p) : Decidable p\n  | isTrue  (h : p) : Decidable p\n\n@[inlineIfReduce, nospecialize] def Decidable.decide (p : Prop) [h : Decidable p] : Bool :=\n  Decidable.casesOn (motive := fun _ => Bool) h (fun _ => false) (fun _ => true)\n\nexport Decidable (isTrue isFalse decide)\n\nabbrev DecidablePred {\u03b1 : Sort u} (r : \u03b1 \u2192 Prop) :=\n  (a : \u03b1) \u2192 Decidable (r a)\n\nabbrev DecidableRel {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :=\n  (a b : \u03b1) \u2192 Decidable (r a b)\n\nabbrev DecidableEq (\u03b1 : Sort u) :=\n  (a b : \u03b1) \u2192 Decidable (Eq a b)\n\ndef decEq {\u03b1 : Sort u} [s : DecidableEq \u03b1] (a b : \u03b1) : Decidable (Eq a b) :=\n  s a b\n\ntheorem decide_eq_true : [s : Decidable p] \u2192 p \u2192 Eq (decide p) true\n  | isTrue  _, _   => rfl\n  | isFalse h\u2081, h\u2082 => absurd h\u2082 h\u2081\n\ntheorem decide_eq_false : [s : Decidable p] \u2192 Not p \u2192 Eq (decide p) false\n  | isTrue  h\u2081, h\u2082 => absurd h\u2081 h\u2082\n  | isFalse h, _   => rfl\n\ntheorem of_decide_eq_true [s : Decidable p] : Eq (decide p) true \u2192 p := fun h =>\n  match (generalizing := false) s with\n  | isTrue  h\u2081 => h\u2081\n  | isFalse h\u2081 => absurd h (ne_true_of_eq_false (decide_eq_false h\u2081))\n\ntheorem of_decide_eq_false [s : Decidable p] : Eq (decide p) false \u2192 Not p := fun h =>\n  match (generalizing := false) s with\n  | isTrue  h\u2081 => absurd h (ne_false_of_eq_true (decide_eq_true h\u2081))\n  | isFalse h\u2081 => h\u2081\n\n@[inline] instance : DecidableEq Bool :=\n  fun a b => match a, b with\n   | false, false => isTrue rfl\n   | false, true  => isFalse (fun h => Bool.noConfusion h)\n   | true, false  => isFalse (fun h => Bool.noConfusion h)\n   | true, true   => isTrue rfl\n\nclass BEq (\u03b1 : Type u) where\n  beq : \u03b1 \u2192 \u03b1 \u2192 Bool\n\nopen BEq (beq)\n\ninstance [DecidableEq \u03b1] : BEq \u03b1 where\n  beq a b := decide (Eq a b)\n\n-- We use \"dependent\" if-then-else to be able to communicate the if-then-else condition\n-- to the branches\n@[macroInline] def dite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t : c \u2192 \u03b1) (e : Not c \u2192 \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h e t\n\n/- if-then-else -/\n\n@[macroInline] def ite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t e : \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h (fun _ => e) (fun _ => t)\n\n@[macroInline] instance {p q} [dp : Decidable p] [dq : Decidable q] : Decidable (And p q) :=\n  match dp with\n  | isTrue  hp =>\n    match dq with\n    | isTrue hq  => isTrue \u27e8hp, hq\u27e9\n    | isFalse hq => isFalse (fun h => hq (And.right h))\n  | isFalse hp =>\n    isFalse (fun h => hp (And.left h))\n\n@[macroInline] instance [dp : Decidable p] [dq : Decidable q] : Decidable (Or p q) :=\n  match dp with\n  | isTrue  hp => isTrue (Or.inl hp)\n  | isFalse hp =>\n    match dq with\n    | isTrue hq  => isTrue (Or.inr hq)\n    | isFalse hq =>\n      isFalse fun h => match h with\n        | Or.inl h => hp h\n        | Or.inr h => hq h\n\ninstance [dp : Decidable p] : Decidable (Not p) :=\n  match dp with\n  | isTrue hp  => isFalse (absurd hp)\n  | isFalse hp => isTrue hp\n\n/- Boolean operators -/\n\n@[macroInline] def cond {\u03b1 : Type u} (c : Bool) (x y : \u03b1) : \u03b1 :=\n  match c with\n  | true  => x\n  | false => y\n\n@[macroInline] def or (x y : Bool) : Bool :=\n  match x with\n  | true  => true\n  | false => y\n\n@[macroInline] def and (x y : Bool) : Bool :=\n  match x with\n  | false => false\n  | true  => y\n\n@[inline] def not : Bool \u2192 Bool\n  | true  => false\n  | false => true\n\ninductive Nat where\n  | zero : Nat\n  | succ (n : Nat) : Nat\n\ninstance : Inhabited Nat where\n  default := Nat.zero\n\n/- For numeric literals notation -/\nclass OfNat (\u03b1 : Type u) (n : Nat) where\n  ofNat : \u03b1\n\n@[defaultInstance 100] /- low prio -/\ninstance (n : Nat) : OfNat Nat n where\n  ofNat := n\n\nclass LE (\u03b1 : Type u) where le : \u03b1 \u2192 \u03b1 \u2192 Prop\nclass LT (\u03b1 : Type u) where lt : \u03b1 \u2192 \u03b1 \u2192 Prop\n\n@[reducible] def GE.ge {\u03b1 : Type u} [LE \u03b1] (a b : \u03b1) : Prop := LE.le b a\n@[reducible] def GT.gt {\u03b1 : Type u} [LT \u03b1] (a b : \u03b1) : Prop := LT.lt b a\n\n@[inline] def max [LT \u03b1] [DecidableRel (@LT.lt \u03b1 _)] (a b : \u03b1) : \u03b1 :=\n  ite (LT.lt b a) a b\n\n@[inline] def min [LE \u03b1] [DecidableRel (@LE.le \u03b1 _)] (a b : \u03b1) : \u03b1 :=\n  ite (LE.le a b) a b\n\n/-- Transitive chaining of proofs, used e.g. by `calc`. -/\nclass Trans (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (s : \u03b2 \u2192 \u03b3 \u2192 Prop) (t : outParam (\u03b1 \u2192 \u03b3 \u2192 Prop)) where\n  trans : r a b \u2192 s b c \u2192 t a c\n\nexport Trans (trans)\n\ninstance (r : \u03b1 \u2192 \u03b3 \u2192 Prop) : Trans Eq r r where\n  trans heq h' := heq \u25b8 h'\n\ninstance (r : \u03b1 \u2192 \u03b2 \u2192 Prop) : Trans r Eq r where\n  trans h' heq := heq \u25b8 h'\n\nclass HAdd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAdd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HSub (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hSub : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HMul (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hMul : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HDiv (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hDiv : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HMod (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hMod : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HPow (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hPow : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HAppend (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAppend : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HOrElse (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hOrElse : \u03b1 \u2192 (Unit \u2192 \u03b2) \u2192 \u03b3\n\nclass HAndThen (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAndThen : \u03b1 \u2192 (Unit \u2192 \u03b2) \u2192 \u03b3\n\nclass HAnd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAnd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HXor (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hXor : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HOr (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hOr : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HShiftLeft (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hShiftLeft : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HShiftRight (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hShiftRight : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass Add (\u03b1 : Type u) where\n  add : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Sub (\u03b1 : Type u) where\n  sub : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Mul (\u03b1 : Type u) where\n  mul : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Neg (\u03b1 : Type u) where\n  neg : \u03b1 \u2192 \u03b1\n\nclass Div (\u03b1 : Type u) where\n  div : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Mod (\u03b1 : Type u) where\n  mod : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Pow (\u03b1 : Type u) (\u03b2 : Type v) where\n  pow : \u03b1 \u2192 \u03b2 \u2192 \u03b1\n\nclass Append (\u03b1 : Type u) where\n  append : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass OrElse (\u03b1 : Type u) where\n  orElse  : \u03b1 \u2192 (Unit \u2192 \u03b1) \u2192 \u03b1\n\nclass AndThen (\u03b1 : Type u) where\n  andThen : \u03b1 \u2192 (Unit \u2192 \u03b1) \u2192 \u03b1\n\nclass AndOp (\u03b1 : Type u) where\n  and : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Xor (\u03b1 : Type u) where\n  xor : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass OrOp (\u03b1 : Type u) where\n  or : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Complement (\u03b1 : Type u) where\n  complement : \u03b1 \u2192 \u03b1\n\nclass ShiftLeft (\u03b1 : Type u) where\n  shiftLeft : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass ShiftRight (\u03b1 : Type u) where\n  shiftRight : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n@[defaultInstance]\ninstance [Add \u03b1] : HAdd \u03b1 \u03b1 \u03b1 where\n  hAdd a b := Add.add a b\n\n@[defaultInstance]\ninstance [Sub \u03b1] : HSub \u03b1 \u03b1 \u03b1 where\n  hSub a b := Sub.sub a b\n\n@[defaultInstance]\ninstance [Mul \u03b1] : HMul \u03b1 \u03b1 \u03b1 where\n  hMul a b := Mul.mul a b\n\n@[defaultInstance]\ninstance [Div \u03b1] : HDiv \u03b1 \u03b1 \u03b1 where\n  hDiv a b := Div.div a b\n\n@[defaultInstance]\ninstance [Mod \u03b1] : HMod \u03b1 \u03b1 \u03b1 where\n  hMod a b := Mod.mod a b\n\n@[defaultInstance]\ninstance [Pow \u03b1 \u03b2] : HPow \u03b1 \u03b2 \u03b1 where\n  hPow a b := Pow.pow a b\n\n@[defaultInstance]\ninstance [Append \u03b1] : HAppend \u03b1 \u03b1 \u03b1 where\n  hAppend a b := Append.append a b\n\n@[defaultInstance]\ninstance [OrElse \u03b1] : HOrElse \u03b1 \u03b1 \u03b1 where\n  hOrElse a b := OrElse.orElse a b\n\n@[defaultInstance]\ninstance [AndThen \u03b1] : HAndThen \u03b1 \u03b1 \u03b1 where\n  hAndThen a b := AndThen.andThen a b\n\n@[defaultInstance]\ninstance [AndOp \u03b1] : HAnd \u03b1 \u03b1 \u03b1 where\n  hAnd a b := AndOp.and a b\n\n@[defaultInstance]\ninstance [Xor \u03b1] : HXor \u03b1 \u03b1 \u03b1 where\n  hXor a b := Xor.xor a b\n\n@[defaultInstance]\ninstance [OrOp \u03b1] : HOr \u03b1 \u03b1 \u03b1 where\n  hOr a b := OrOp.or a b\n\n@[defaultInstance]\ninstance [ShiftLeft \u03b1] : HShiftLeft \u03b1 \u03b1 \u03b1 where\n  hShiftLeft a b := ShiftLeft.shiftLeft a b\n\n@[defaultInstance]\ninstance [ShiftRight \u03b1] : HShiftRight \u03b1 \u03b1 \u03b1 where\n  hShiftRight a b := ShiftRight.shiftRight a b\n\nopen HAdd (hAdd)\nopen HMul (hMul)\nopen HPow (hPow)\nopen HAppend (hAppend)\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_add\"]\nprotected def Nat.add : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, Nat.zero   => a\n  | a, Nat.succ b => Nat.succ (Nat.add a b)\n\ninstance : Add Nat where\n  add := Nat.add\n\n/- We mark the following definitions as pattern to make sure they can be used in recursive equations,\n   and reduced by the equation Compiler. -/\nattribute [matchPattern] Nat.add Add.add HAdd.hAdd Neg.neg\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_mul\"]\nprotected def Nat.mul : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0          => 0\n  | a, Nat.succ b => Nat.add (Nat.mul a b) a\n\ninstance : Mul Nat where\n  mul := Nat.mul\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_pow\"]\nprotected def Nat.pow (m : @& Nat) : (@& Nat) \u2192 Nat\n  | 0      => 1\n  | succ n => Nat.mul (Nat.pow m n) m\n\ninstance : Pow Nat Nat where\n  pow := Nat.pow\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_dec_eq\"]\ndef Nat.beq : (@& Nat) \u2192 (@& Nat) \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => false\n  | succ n, zero   => false\n  | succ n, succ m => beq n m\n\ntheorem Nat.eq_of_beq_eq_true : {n m : Nat} \u2192 Eq (beq n m) true \u2192 Eq n m\n  | zero,   zero,   h => rfl\n  | zero,   succ m, h => Bool.noConfusion h\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : Eq (beq n m) true := h\n    have : Eq n m := eq_of_beq_eq_true this\n    this \u25b8 rfl\n\ntheorem Nat.ne_of_beq_eq_false : {n m : Nat} \u2192 Eq (beq n m) false \u2192 Not (Eq n m)\n  | zero,   zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | zero,   succ m, h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, zero,   h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have : Eq (beq n m) false := h\u2081\n    Nat.noConfusion h\u2082 (fun h\u2082 => absurd h\u2082 (ne_of_beq_eq_false this))\n\n@[extern \"lean_nat_dec_eq\"]\nprotected def Nat.decEq (n m : @& Nat) : Decidable (Eq n m) :=\n  match h:beq n m with\n  | true  => isTrue (eq_of_beq_eq_true h)\n  | false => isFalse (ne_of_beq_eq_false h)\n\n@[inline] instance : DecidableEq Nat := Nat.decEq\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_dec_le\"]\ndef Nat.ble : @& Nat \u2192 @& Nat \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => true\n  | succ n, zero   => false\n  | succ n, succ m => ble n m\n\nprotected inductive Nat.le (n : Nat) : Nat \u2192 Prop\n  | refl     : Nat.le n n\n  | step {m} : Nat.le n m \u2192 Nat.le n (succ m)\n\ninstance : LE Nat where\n  le := Nat.le\n\nprotected def Nat.lt (n m : Nat) : Prop :=\n  Nat.le (succ n) m\n\ninstance : LT Nat where\n  lt := Nat.lt\n\ntheorem Nat.not_succ_le_zero : \u2200 (n : Nat), LE.le (succ n) 0 \u2192 False\n  | 0,      h => nomatch h\n  | succ n, h => nomatch h\n\ntheorem Nat.not_lt_zero (n : Nat) : Not (LT.lt n 0) :=\n  not_succ_le_zero n\n\ntheorem Nat.zero_le : (n : Nat) \u2192 LE.le 0 n\n  | zero   => Nat.le.refl\n  | succ n => Nat.le.step (zero_le n)\n\ntheorem Nat.succ_le_succ : LE.le n m \u2192 LE.le (succ n) (succ m)\n  | Nat.le.refl   => Nat.le.refl\n  | Nat.le.step h => Nat.le.step (succ_le_succ h)\n\ntheorem Nat.zero_lt_succ (n : Nat) : LT.lt 0 (succ n) :=\n  succ_le_succ (zero_le n)\n\ntheorem Nat.le_step (h : LE.le n m) : LE.le n (succ m) :=\n  Nat.le.step h\n\nprotected theorem Nat.le_trans {n m k : Nat} : LE.le n m \u2192 LE.le m k \u2192 LE.le n k\n  | h,  Nat.le.refl    => h\n  | h\u2081, Nat.le.step h\u2082 => Nat.le.step (Nat.le_trans h\u2081 h\u2082)\n\nprotected theorem Nat.lt_trans {n m k : Nat} (h\u2081 : LT.lt n m) : LT.lt m k \u2192 LT.lt n k :=\n  Nat.le_trans (le_step h\u2081)\n\ntheorem Nat.le_succ (n : Nat) : LE.le n (succ n) :=\n  Nat.le.step Nat.le.refl\n\ntheorem Nat.le_succ_of_le {n m : Nat} (h : LE.le n m) : LE.le n (succ m) :=\n  Nat.le_trans h (le_succ m)\n\nprotected theorem Nat.le_refl (n : Nat) : LE.le n n :=\n  Nat.le.refl\n\ntheorem Nat.succ_pos (n : Nat) : LT.lt 0 (succ n) :=\n  zero_lt_succ n\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"lean_nat_sub(#1, lean_box(1))\"]\ndef Nat.pred : (@& Nat) \u2192 Nat\n  | 0      => 0\n  | succ a => a\n\ntheorem Nat.pred_le_pred : {n m : Nat} \u2192 LE.le n m \u2192 LE.le (pred n) (pred m)\n  | _,           _, Nat.le.refl   => Nat.le.refl\n  | 0,      succ m, Nat.le.step h => h\n  | succ n, succ m, Nat.le.step h => Nat.le_trans (le_succ _) h\n\ntheorem Nat.le_of_succ_le_succ {n m : Nat} : LE.le (succ n) (succ m) \u2192 LE.le n m :=\n  pred_le_pred\n\ntheorem Nat.le_of_lt_succ {m n : Nat} : LT.lt m (succ n) \u2192 LE.le m n :=\n  le_of_succ_le_succ\n\nprotected theorem Nat.eq_or_lt_of_le : {n m: Nat} \u2192 LE.le n m \u2192 Or (Eq n m) (LT.lt n m)\n  | zero,   zero,   h => Or.inl rfl\n  | zero,   succ n, h => Or.inr (Nat.succ_le_succ (Nat.zero_le _))\n  | succ n, zero,   h => absurd h (not_succ_le_zero _)\n  | succ n, succ m, h =>\n    have : LE.le n m := Nat.le_of_succ_le_succ h\n    match Nat.eq_or_lt_of_le this with\n    | Or.inl h => Or.inl (h \u25b8 rfl)\n    | Or.inr h => Or.inr (succ_le_succ h)\n\nprotected theorem Nat.lt_or_ge (n m : Nat) : Or (LT.lt n m) (GE.ge n m) :=\n  match m with\n  | zero   => Or.inr (zero_le n)\n  | succ m =>\n    match Nat.lt_or_ge n m with\n    | Or.inl h => Or.inl (le_succ_of_le h)\n    | Or.inr h =>\n      match Nat.eq_or_lt_of_le h with\n      | Or.inl h1 => Or.inl (h1 \u25b8 Nat.le_refl _)\n      | Or.inr h1 => Or.inr h1\n\ntheorem Nat.not_succ_le_self : (n : Nat) \u2192 Not (LE.le (succ n) n)\n  | 0      => not_succ_le_zero _\n  | succ n => fun h => absurd (le_of_succ_le_succ h) (not_succ_le_self n)\n\nprotected theorem Nat.lt_irrefl (n : Nat) : Not (LT.lt n n) :=\n  Nat.not_succ_le_self n\n\nprotected theorem Nat.lt_of_le_of_lt {n m k : Nat} (h\u2081 : LE.le n m) (h\u2082 : LT.lt m k) : LT.lt n k :=\n  Nat.le_trans (Nat.succ_le_succ h\u2081) h\u2082\n\nprotected theorem Nat.le_antisymm {n m : Nat} (h\u2081 : LE.le n m) (h\u2082 : LE.le m n) : Eq n m :=\n  match h\u2081 with\n  | Nat.le.refl   => rfl\n  | Nat.le.step h => absurd (Nat.lt_of_le_of_lt h h\u2082) (Nat.lt_irrefl n)\n\nprotected theorem Nat.lt_of_le_of_ne {n m : Nat} (h\u2081 : LE.le n m) (h\u2082 : Not (Eq n m)) : LT.lt n m :=\n  match Nat.lt_or_ge n m with\n  | Or.inl h\u2083 => h\u2083\n  | Or.inr h\u2083 => absurd (Nat.le_antisymm h\u2081 h\u2083) h\u2082\n\ntheorem Nat.le_of_ble_eq_true (h : Eq (Nat.ble n m) true) : LE.le n m :=\n  match n, m with\n  | 0,      _      => Nat.zero_le _\n  | succ _, succ _ => Nat.succ_le_succ (le_of_ble_eq_true h)\n\ntheorem Nat.ble_self_eq_true : (n : Nat) \u2192 Eq (Nat.ble n n) true\n  | 0      => rfl\n  | succ n => ble_self_eq_true n\n\ntheorem Nat.ble_succ_eq_true : {n m : Nat} \u2192 Eq (Nat.ble n m) true \u2192 Eq (Nat.ble n (succ m)) true\n  | 0,      _,      _ => rfl\n  | succ n, succ m, h => ble_succ_eq_true (n := n) h\n\ntheorem Nat.ble_eq_true_of_le (h : LE.le n m) : Eq (Nat.ble n m) true :=\n  match h with\n  | Nat.le.refl   => Nat.ble_self_eq_true n\n  | Nat.le.step h => Nat.ble_succ_eq_true (ble_eq_true_of_le h)\n\ntheorem Nat.not_le_of_not_ble_eq_true (h : Not (Eq (Nat.ble n m) true)) : Not (LE.le n m) :=\n  fun h' => absurd (Nat.ble_eq_true_of_le h') h\n\n@[extern \"lean_nat_dec_le\"]\ninstance Nat.decLe (n m : @& Nat) : Decidable (LE.le n m) :=\n  dite (Eq (Nat.ble n m) true) (fun h => isTrue (Nat.le_of_ble_eq_true h)) (fun h => isFalse (Nat.not_le_of_not_ble_eq_true h))\n\n@[extern \"lean_nat_dec_lt\"]\ninstance Nat.decLt (n m : @& Nat) : Decidable (LT.lt n m) :=\n  decLe (succ n) m\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_sub\"]\nprotected def Nat.sub : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0      => a\n  | a, succ b => pred (Nat.sub a b)\n\ninstance : Sub Nat where\n  sub := Nat.sub\n\n@[extern \"lean_system_platform_nbits\"] constant System.Platform.getNumBits : Unit \u2192 Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=\n  fun _ => \u27e864, Or.inr rfl\u27e9 -- inhabitant\n\ndef System.Platform.numBits : Nat :=\n  (getNumBits ()).val\n\ntheorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=\n  (getNumBits ()).property\n\nstructure Fin (n : Nat) where\n  val  : Nat\n  isLt : LT.lt val n\n\ntheorem Fin.eq_of_val_eq {n} : \u2200 {i j : Fin n}, Eq i.val j.val \u2192 Eq i j\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Fin.val_eq_of_eq {n} {i j : Fin n} (h : Eq i j) : Eq i.val j.val :=\n  h \u25b8 rfl\n\ntheorem Fin.ne_of_val_ne {n} {i j : Fin n} (h : Not (Eq i.val j.val)) : Not (Eq i j) :=\n  fun h' => absurd (val_eq_of_eq h') h\n\ninstance (n : Nat) : DecidableEq (Fin n) :=\n  fun i j =>\n    match decEq i.val j.val with\n    | isTrue h  => isTrue (Fin.eq_of_val_eq h)\n    | isFalse h => isFalse (Fin.ne_of_val_ne h)\n\ninstance {n} : LT (Fin n) where\n  lt a b := LT.lt a.val b.val\n\ninstance {n} : LE (Fin n) where\n  le a b := LE.le a.val b.val\n\ninstance Fin.decLt {n} (a b : Fin n) : Decidable (LT.lt a b)  := Nat.decLt ..\ninstance Fin.decLe {n} (a b : Fin n) : Decidable (LE.le a b) := Nat.decLe ..\n\ndef UInt8.size : Nat := 256\nstructure UInt8 where\n  val : Fin UInt8.size\n\nattribute [extern \"lean_uint8_of_nat_mk\"] UInt8.mk\nattribute [extern \"lean_uint8_to_nat\"] UInt8.val\n\n@[extern \"lean_uint8_of_nat\"]\ndef UInt8.ofNatCore (n : @& Nat) (h : LT.lt n UInt8.size) : UInt8 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_uint8_dec_eq\"]\ndef UInt8.decEq (a b : UInt8) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt8.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt8 := UInt8.decEq\n\ninstance : Inhabited UInt8 where\n  default := UInt8.ofNatCore 0 (by decide)\n\ndef UInt16.size : Nat := 65536\nstructure UInt16 where\n  val : Fin UInt16.size\n\nattribute [extern \"lean_uint16_of_nat_mk\"] UInt16.mk\nattribute [extern \"lean_uint16_to_nat\"] UInt16.val\n\n@[extern \"lean_uint16_of_nat\"]\ndef UInt16.ofNatCore (n : @& Nat) (h : LT.lt n UInt16.size) : UInt16 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_uint16_dec_eq\"]\ndef UInt16.decEq (a b : UInt16) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt16.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt16 := UInt16.decEq\n\ninstance : Inhabited UInt16 where\n  default := UInt16.ofNatCore 0 (by decide)\n\ndef UInt32.size : Nat := 4294967296\nstructure UInt32 where\n  val : Fin UInt32.size\n\nattribute [extern \"lean_uint32_of_nat_mk\"] UInt32.mk\nattribute [extern \"lean_uint32_to_nat\"] UInt32.val\n\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNatCore (n : @& Nat) (h : LT.lt n UInt32.size) : UInt32 := {\n  val := { val := n, isLt := h }\n}\n\n@[extern \"lean_uint32_to_nat\"]\ndef UInt32.toNat (n : UInt32) : Nat := n.val.val\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_uint32_dec_eq\"]\ndef UInt32.decEq (a b : UInt32) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt32.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt32 := UInt32.decEq\n\ninstance : Inhabited UInt32 where\n  default := UInt32.ofNatCore 0 (by decide)\n\ninstance : LT UInt32 where\n  lt a b := LT.lt a.val b.val\n\ninstance : LE UInt32 where\n  le a b := LE.le a.val b.val\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_uint32_dec_lt\"]\ndef UInt32.decLt (a b : UInt32) : Decidable (LT.lt a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LT.lt n m))\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_uint32_dec_le\"]\ndef UInt32.decLe (a b : UInt32) : Decidable (LE.le a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LE.le n m))\n\ninstance (a b : UInt32) : Decidable (LT.lt a b) := UInt32.decLt a b\ninstance (a b : UInt32) : Decidable (LE.le a b) := UInt32.decLe a b\n\ndef UInt64.size : Nat := 18446744073709551616\nstructure UInt64 where\n  val : Fin UInt64.size\n\nattribute [extern \"lean_uint64_of_nat_mk\"] UInt64.mk\nattribute [extern \"lean_uint64_to_nat\"] UInt64.val\n\n@[extern \"lean_uint64_of_nat\"]\ndef UInt64.ofNatCore (n : @& Nat) (h : LT.lt n UInt64.size) : UInt64 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_uint64_dec_eq\"]\ndef UInt64.decEq (a b : UInt64) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt64.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt64 := UInt64.decEq\n\ninstance : Inhabited UInt64 where\n  default := UInt64.ofNatCore 0 (by decide)\n\ndef USize.size : Nat := hPow 2 System.Platform.numBits\n\ntheorem usize_size_eq : Or (Eq USize.size 4294967296) (Eq USize.size 18446744073709551616) :=\n  show Or (Eq (hPow 2 System.Platform.numBits) 4294967296) (Eq (hPow 2 System.Platform.numBits) 18446744073709551616) from\n  match System.Platform.numBits, System.Platform.numBits_eq with\n  | _, Or.inl rfl => Or.inl (by decide)\n  | _, Or.inr rfl => Or.inr (by decide)\n\nstructure USize where\n  val : Fin USize.size\n\nattribute [extern \"lean_usize_of_nat_mk\"] USize.mk\nattribute [extern \"lean_usize_to_nat\"] USize.val\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNatCore (n : @& Nat) (h : LT.lt n USize.size) : USize := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_usize_dec_eq\"]\ndef USize.decEq (a b : USize) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h =>isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => USize.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq USize := USize.decEq\n\ninstance : Inhabited USize where\n  default := USize.ofNatCore 0 (match USize.size, usize_size_eq with\n    | _, Or.inl rfl => by decide\n    | _, Or.inr rfl => by decide)\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNat32 (n : @& Nat) (h : LT.lt n 4294967296) : USize := {\n  val := {\n    val  := n\n    isLt := match USize.size, usize_size_eq with\n      | _, Or.inl rfl => h\n      | _, Or.inr rfl => Nat.lt_trans h (by decide)\n  }\n}\n\nabbrev Nat.isValidChar (n : Nat) : Prop :=\n  Or (LT.lt n 0xd800) (And (LT.lt 0xdfff n) (LT.lt n 0x110000))\n\nabbrev UInt32.isValidChar (n : UInt32) : Prop :=\n  n.toNat.isValidChar\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   : UInt32\n  valid : val.isValidChar\n\nprivate theorem isValidChar_UInt32 {n : Nat} (h : n.isValidChar) : LT.lt n UInt32.size :=\n  match h with\n  | Or.inl h      => Nat.lt_trans h (by decide)\n  | Or.inr \u27e8_, h\u27e9 => Nat.lt_trans h (by decide)\n\n@[extern \"lean_uint32_of_nat\"]\ndef Char.ofNatAux (n : @& Nat) (h : n.isValidChar) : Char :=\n  { val := \u27e8{ val := n, isLt := isValidChar_UInt32 h }\u27e9, valid := h }\n\n@[noinline, matchPattern]\ndef Char.ofNat (n : Nat) : Char :=\n  dite (n.isValidChar)\n    (fun h => Char.ofNatAux n h)\n    (fun _ => { val := \u27e8{ val := 0, isLt := by decide }\u27e9, valid := Or.inl (by decide) })\n\ntheorem Char.eq_of_val_eq : \u2200 {c d : Char}, Eq c.val d.val \u2192 Eq c d\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Char.val_eq_of_eq : \u2200 {c d : Char}, Eq c d \u2192 Eq c.val d.val\n  | _, _, rfl => rfl\n\ntheorem Char.ne_of_val_ne {c d : Char} (h : Not (Eq c.val d.val)) : Not (Eq c d) :=\n  fun h' => absurd (val_eq_of_eq h') h\n\ntheorem Char.val_ne_of_ne {c d : Char} (h : Not (Eq c d)) : Not (Eq c.val d.val) :=\n  fun h' => absurd (eq_of_val_eq h') h\n\ninstance : DecidableEq Char :=\n  fun c d =>\n    match decEq c.val d.val with\n    | isTrue h  => isTrue (Char.eq_of_val_eq h)\n    | isFalse h => isFalse (Char.ne_of_val_ne h)\n\ndef Char.utf8Size (c : Char) : UInt32 :=\n  let v := c.val\n  ite (LE.le v (UInt32.ofNatCore 0x7F (by decide)))\n    (UInt32.ofNatCore 1 (by decide))\n    (ite (LE.le v (UInt32.ofNatCore 0x7FF (by decide)))\n      (UInt32.ofNatCore 2 (by decide))\n      (ite (LE.le v (UInt32.ofNatCore 0xFFFF (by decide)))\n        (UInt32.ofNatCore 3 (by decide))\n        (UInt32.ofNatCore 4 (by decide))))\n\ninductive Option (\u03b1 : Type u) where\n  | none : Option \u03b1\n  | some (val : \u03b1) : Option \u03b1\n\nattribute [unbox] Option\n\nexport Option (none some)\n\ninstance {\u03b1} : Inhabited (Option \u03b1) where\n  default := none\n\n@[macroInline] def Option.getD : Option \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  | some x, _ => x\n  | none,   e => e\n\ninductive List (\u03b1 : Type u) where\n  | nil : List \u03b1\n  | cons (head : \u03b1) (tail : List \u03b1) : List \u03b1\n\ninstance {\u03b1} : Inhabited (List \u03b1) where\n  default := List.nil\n\nprotected def List.hasDecEq {\u03b1: Type u} [DecidableEq \u03b1] : (a b : List \u03b1) \u2192 Decidable (Eq a b)\n  | nil,       nil       => isTrue rfl\n  | cons a as, nil       => isFalse (fun h => List.noConfusion h)\n  | nil,       cons b bs => isFalse (fun h => List.noConfusion h)\n  | cons a as, cons b bs =>\n    match decEq a b with\n    | isTrue hab  =>\n      match List.hasDecEq as bs with\n      | isTrue habs  => isTrue (hab \u25b8 habs \u25b8 rfl)\n      | isFalse nabs => isFalse (fun h => List.noConfusion h (fun _ habs => absurd habs nabs))\n    | isFalse nab => isFalse (fun h => List.noConfusion h (fun hab _ => absurd hab nab))\n\ninstance {\u03b1 : Type u} [DecidableEq \u03b1] : DecidableEq (List \u03b1) := List.hasDecEq\n\n@[specialize]\ndef List.foldl {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) : (init : \u03b1) \u2192 List \u03b2 \u2192 \u03b1\n  | a, nil      => a\n  | a, cons b l => foldl f (f a b) l\n\ndef List.set : List \u03b1 \u2192 Nat \u2192 \u03b1 \u2192 List \u03b1\n  | cons a as, 0,          b => cons b as\n  | cons a as, Nat.succ n, b => cons a (set as n b)\n  | nil,       _,          _ => nil\n\ndef List.length : List \u03b1 \u2192 Nat\n  | nil       => 0\n  | cons a as => HAdd.hAdd (length as) 1\n\ndef List.lengthTRAux : List \u03b1 \u2192 Nat \u2192 Nat\n  | nil,       n => n\n  | cons a as, n => lengthTRAux as (Nat.succ n)\n\ndef List.lengthTR (as : List \u03b1) : Nat :=\n  lengthTRAux as 0\n\n@[simp] theorem List.length_cons {\u03b1} (a : \u03b1) (as : List \u03b1) : Eq (cons a as).length as.length.succ :=\n  rfl\n\ndef List.concat {\u03b1 : Type u} : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1\n  | nil,       b => cons b nil\n  | cons a as, b => cons a (concat as b)\n\ndef List.get {\u03b1 : Type u} : (as : List \u03b1) \u2192 (i : Nat) \u2192 LT.lt i as.length \u2192 \u03b1\n  | nil,       i,          h => absurd h (Nat.not_lt_zero _)\n  | cons a as, 0,          h => a\n  | cons a as, Nat.succ i, h =>\n    have : LT.lt i.succ as.length.succ := length_cons .. \u25b8 h\n    get as i (Nat.le_of_succ_le_succ this)\n\nstructure String where\n  data : List Char\n\nattribute [extern \"lean_string_mk\"] String.mk\nattribute [extern \"lean_string_data\"] String.data\n\n@[extern \"lean_string_dec_eq\"]\ndef String.decEq (s\u2081 s\u2082 : @& String) : Decidable (Eq s\u2081 s\u2082) :=\n  match s\u2081, s\u2082 with\n  | \u27e8s\u2081\u27e9, \u27e8s\u2082\u27e9 =>\n    dite (Eq s\u2081 s\u2082) (fun h => isTrue (congrArg _ h)) (fun h => isFalse (fun h' => String.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq String := String.decEq\n\n/-- A byte position in a `String`. Internally, `String`s are UTF-8 encoded.\nCodepoint positions (counting the Unicode codepoints rather than bytes)\nare represented by plain `Nat`s instead.\nIndexing a `String` by a byte position is constant-time, while codepoint\npositions need to be translated internally to byte positions in linear-time. -/\nabbrev String.Pos := Nat\n\nstructure Substring where\n  str : String\n  startPos : String.Pos\n  stopPos : String.Pos\n\ninstance : Inhabited Substring where\n  default := \u27e8\"\", 0, 0\u27e9\n\n@[inline] def Substring.bsize : Substring \u2192 Nat\n  | \u27e8_, b, e\u27e9 => e.sub b\n\ndef String.csize (c : Char) : Nat :=\n  c.utf8Size.toNat\n\nprivate def String.utf8ByteSizeAux : List Char \u2192 Nat \u2192 Nat\n  | List.nil,       r => r\n  | List.cons c cs, r => utf8ByteSizeAux cs (hAdd r (csize c))\n\n@[extern \"lean_string_utf8_byte_size\"]\ndef String.utf8ByteSize : (@& String) \u2192 Nat\n  | \u27e8s\u27e9 => utf8ByteSizeAux s 0\n\n@[inline] def String.bsize (s : String) : Nat :=\n  utf8ByteSize s\n\n@[inline] def String.toSubstring (s : String) : Substring := {\n  str      := s\n  startPos := 0\n  stopPos  := s.bsize\n}\n\nunsafe def unsafeCast {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) : \u03b2 :=\n  ULift.down.{max u v} (cast lcProof (ULift.up.{max u v} a))\n\n@[neverExtract, extern \"lean_panic_fn\"]\nconstant panicCore {\u03b1 : Type u} [Inhabited \u03b1] (msg : String) : \u03b1\n\n/-\n  This is workaround for `panic` occurring in monadic code. See issue #695.\n  The `panicCore` definition cannot be specialized since it is an extern.\n  When `panic` occurs in monadic code, the `Inhabited \u03b1` parameter depends on a `[inst : Monad m]` instance.\n  The `inst` parameter will not be eliminated during specialization if it occurs inside of a binder (to avoid work duplication), and\n  will prevent the the actual monad from being \"copied\" to the code being specialized. When we reimplement the specializer, we\n  may consider copying `inst` if it also occurs outside binders or if it is an instance.\n-/\n@[noinline, neverExtract]\ndef panic {\u03b1 : Type u} [Inhabited \u03b1] (msg : String) : \u03b1 :=\n  panicCore msg\n\n-- TODO: this be applied directly to `Inhabited`'s definition when we remove the above workaround\nattribute [nospecialize] Inhabited\n\n/-\nThe Compiler has special support for arrays.\nThey are implemented using dynamic arrays: https://en.wikipedia.org/wiki/Dynamic_array\n-/\nstructure Array (\u03b1 : Type u) where\n  data : List \u03b1\n\nattribute [extern \"lean_array_data\"] Array.data\nattribute [extern \"lean_array_mk\"] Array.mk\n\n/- The parameter `c` is the initial capacity -/\n@[extern \"lean_mk_empty_array_with_capacity\"]\ndef Array.mkEmpty {\u03b1 : Type u} (c : @& Nat) : Array \u03b1 := {\n  data := List.nil\n}\n\ndef Array.empty {\u03b1 : Type u} : Array \u03b1 :=\n  mkEmpty 0\n\n@[reducible, extern \"lean_array_get_size\"]\ndef Array.size {\u03b1 : Type u} (a : @& Array \u03b1) : Nat :=\n a.data.length\n\n@[extern \"lean_array_fget\"]\ndef Array.get {\u03b1 : Type u} (a : @& Array \u03b1) (i : @& Fin a.size) : \u03b1 :=\n  a.data.get i.val i.isLt\n\n@[inline] def Array.getD (a : Array \u03b1) (i : Nat) (v\u2080 : \u03b1) : \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.get \u27e8i, h\u27e9) (fun _ => v\u2080)\n\n/- \"Comfortable\" version of `fget`. It performs a bound check at runtime. -/\n@[extern \"lean_array_get\"]\ndef Array.get! {\u03b1 : Type u} [Inhabited \u03b1] (a : @& Array \u03b1) (i : @& Nat) : \u03b1 :=\n  Array.getD a i default\n\ndef Array.getOp {\u03b1 : Type u} [Inhabited \u03b1] (self : Array \u03b1) (idx : Nat) : \u03b1 :=\n  self.get! idx\n\n@[extern \"lean_array_push\"]\ndef Array.push {\u03b1 : Type u} (a : Array \u03b1) (v : \u03b1) : Array \u03b1 := {\n  data := List.concat a.data v\n}\n\n@[extern \"lean_array_fset\"]\ndef Array.set (a : Array \u03b1) (i : @& Fin a.size) (v : \u03b1) : Array \u03b1 := {\n  data := a.data.set i.val v\n}\n\n@[inline] def Array.setD (a : Array \u03b1) (i : Nat) (v : \u03b1) : Array \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.set \u27e8i, h\u27e9 v) (fun _ => a)\n\n@[extern \"lean_array_set\"]\ndef Array.set! (a : Array \u03b1) (i : @& Nat) (v : \u03b1) : Array \u03b1 :=\n  Array.setD a i v\n\n-- Slower `Array.append` used in quotations.\nprotected def Array.appendCore {\u03b1 : Type u}  (as : Array \u03b1) (bs : Array \u03b1) : Array \u03b1 :=\n  let rec loop (i : Nat) (j : Nat) (as : Array \u03b1) : Array \u03b1 :=\n    dite (LT.lt j bs.size)\n      (fun hlt =>\n        match i with\n        | 0           => as\n        | Nat.succ i' => loop i' (hAdd j 1) (as.push (bs.get \u27e8j, hlt\u27e9)))\n      (fun _ => as)\n  loop bs.size 0 as\n\n@[inlineIfReduce]\ndef List.toArrayAux : List \u03b1 \u2192 Array \u03b1 \u2192 Array \u03b1\n  | nil,       r => r\n  | cons a as, r => toArrayAux as (r.push a)\n\n@[inlineIfReduce]\ndef List.redLength : List \u03b1 \u2192 Nat\n  | nil       => 0\n  | cons _ as => as.redLength.succ\n\n@[inline, matchPattern, export lean_list_to_array]\ndef List.toArray (as : List \u03b1) : Array \u03b1 :=\n  as.toArrayAux (Array.mkEmpty as.redLength)\n\nclass Bind (m : Type u \u2192 Type v) where\n  bind : {\u03b1 \u03b2 : Type u} \u2192 m \u03b1 \u2192 (\u03b1 \u2192 m \u03b2) \u2192 m \u03b2\n\nexport Bind (bind)\n\nclass Pure (f : Type u \u2192 Type v) where\n  pure {\u03b1 : Type u} : \u03b1 \u2192 f \u03b1\n\nexport Pure (pure)\n\nclass Functor (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  map      : {\u03b1 \u03b2 : Type u} \u2192 (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n  mapConst : {\u03b1 \u03b2 : Type u} \u2192 \u03b1 \u2192 f \u03b2 \u2192 f \u03b1 := Function.comp map (Function.const _)\n\nclass Seq (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seq  : {\u03b1 \u03b2 : Type u} \u2192 f (\u03b1 \u2192 \u03b2) \u2192 (Unit \u2192 f \u03b1) \u2192 f \u03b2\n\nclass SeqLeft (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seqLeft : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 (Unit \u2192 f \u03b2) \u2192 f \u03b1\n\nclass SeqRight (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seqRight : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 (Unit \u2192 f \u03b2) \u2192 f \u03b2\n\nclass Applicative (f : Type u \u2192 Type v) extends Functor f, Pure f, Seq f, SeqLeft f, SeqRight f where\n  map      := fun x y => Seq.seq (pure x) fun _ => y\n  seqLeft  := fun a b => Seq.seq (Functor.map (Function.const _) a) b\n  seqRight := fun a b => Seq.seq (Functor.map (Function.const _ id) a) b\n\nclass Monad (m : Type u \u2192 Type v) extends Applicative m, Bind m : Type (max (u+1) v) where\n  map      f x := bind x (Function.comp pure f)\n  seq      f x := bind f fun y => Functor.map y (x ())\n  seqLeft  x y := bind x fun a => bind (y ()) (fun _ => pure a)\n  seqRight x y := bind x fun _ => y ()\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] : Inhabited (\u03b1 \u2192 m \u03b1) where\n  default := pure\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] [Inhabited \u03b1] : Inhabited (m \u03b1) where\n  default := pure default\n\n-- A fusion of Haskell's `sequence` and `map`\ndef Array.sequenceMap {\u03b1 : Type u} {\u03b2 : Type v} {m : Type v \u2192 Type w} [Monad m] (as : Array \u03b1) (f : \u03b1 \u2192 m \u03b2) : m (Array \u03b2) :=\n  let rec loop (i : Nat) (j : Nat) (bs : Array \u03b2) : m (Array \u03b2) :=\n    dite (LT.lt j as.size)\n      (fun hlt =>\n        match i with\n        | 0           => pure bs\n        | Nat.succ i' => Bind.bind (f (as.get \u27e8j, hlt\u27e9)) fun b => loop i' (hAdd j 1) (bs.push b))\n      (fun _ => pure bs)\n  loop as.size 0 Array.empty\n\n/-- A Function for lifting a computation from an inner Monad to an outer Monad.\n    Like [MonadTrans](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Class.html),\n    but `n` does not have to be a monad transformer.\n    Alternatively, an implementation of [MonadLayer](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLayer) without `layerInvmap` (so far). -/\nclass MonadLift (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadLift`.\n    `monadLift` is used to transitively lift monadic computations such as `StateT.get` or `StateT.put s`.\n    Corresponds to [MonadLift](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLift). -/\nclass MonadLiftT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\nexport MonadLiftT (monadLift)\n\nabbrev liftM := @monadLift\n\ninstance (m n o) [MonadLift n o] [MonadLiftT m n] : MonadLiftT m o where\n  monadLift x := MonadLift.monadLift (m := n) (monadLift x)\n\ninstance (m) : MonadLiftT m m where\n  monadLift x := x\n\n/-- A functor in the category of monads. Can be used to lift monad-transforming functions.\n    Based on pipes' [MFunctor](https://hackage.haskell.org/package/pipes-2.4.0/docs/Control-MFunctor.html),\n    but not restricted to monad transformers.\n    Alternatively, an implementation of [MonadTransFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadTransFunctor). -/\nclass MonadFunctor (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadFunctor`.\n    `monadMap` is used to transitively lift Monad morphisms -/\nclass MonadFunctorT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\nexport MonadFunctorT (monadMap)\n\ninstance (m n o) [MonadFunctor n o] [MonadFunctorT m n] : MonadFunctorT m o where\n  monadMap f := MonadFunctor.monadMap (m := n) (monadMap (m := m) f)\n\ninstance monadFunctorRefl (m) : MonadFunctorT m m where\n  monadMap f := f\n\ninductive Except (\u03b5 : Type u) (\u03b1 : Type v) where\n  | error : \u03b5 \u2192 Except \u03b5 \u03b1\n  | ok    : \u03b1 \u2192 Except \u03b5 \u03b1\n\nattribute [unbox] Except\n\ninstance {\u03b5 : Type u} {\u03b1 : Type v} [Inhabited \u03b5] : Inhabited (Except \u03b5 \u03b1) where\n  default := Except.error default\n\n/-- An implementation of [MonadError](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Except.html#t:MonadError) -/\nclass MonadExceptOf (\u03b5 : Type u) (m : Type v \u2192 Type w) where\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\nabbrev throwThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (e : \u03b5) : m \u03b1 :=\n  MonadExceptOf.throw e\n\nabbrev tryCatchThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (x : m \u03b1) (handle : \u03b5 \u2192 m \u03b1) : m \u03b1 :=\n  MonadExceptOf.tryCatch x handle\n\n/-- Similar to `MonadExceptOf`, but `\u03b5` is an outParam for convenience -/\nclass MonadExcept (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) where\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\nexport MonadExcept (throw tryCatch)\n\ninstance (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) [MonadExceptOf \u03b5 m] : MonadExcept \u03b5 m where\n  throw    := throwThe \u03b5\n  tryCatch := tryCatchThe \u03b5\n\nnamespace MonadExcept\nvariable {\u03b5 : Type u} {m : Type v \u2192 Type w}\n\n@[inline] protected def orElse [MonadExcept \u03b5 m] {\u03b1 : Type v} (t\u2081 : m \u03b1) (t\u2082 : Unit \u2192 m \u03b1) : m \u03b1 :=\n  tryCatch t\u2081 fun _ => t\u2082 ()\n\ninstance [MonadExcept \u03b5 m] {\u03b1 : Type v} : OrElse (m \u03b1) where\n  orElse := MonadExcept.orElse\n\nend MonadExcept\n\n/-- An implementation of [ReaderT](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Reader.html#t:ReaderT) -/\ndef ReaderT (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) : Type (max u v) :=\n  \u03c1 \u2192 m \u03b1\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) [Inhabited (m \u03b1)] : Inhabited (ReaderT \u03c1 m \u03b1) where\n  default := fun _ => default\n\n@[inline] def ReaderT.run {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u} (x : ReaderT \u03c1 m \u03b1) (r : \u03c1) : m \u03b1 :=\n  x r\n\nnamespace ReaderT\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u}\n\ninstance  : MonadLift m (ReaderT \u03c1 m) where\n  monadLift x := fun _ => x\n\ninstance (\u03b5) [MonadExceptOf \u03b5 m] : MonadExceptOf \u03b5 (ReaderT \u03c1 m) where\n  throw e  := liftM (m := m) (throw e)\n  tryCatch := fun x c r => tryCatchThe \u03b5 (x r) (fun e => (c e) r)\n\nend\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] {\u03b1 \u03b2 : Type u}\n\n@[inline] protected def read : ReaderT \u03c1 m \u03c1 :=\n  pure\n\n@[inline] protected def pure (a : \u03b1) : ReaderT \u03c1 m \u03b1 :=\n  fun r => pure a\n\n@[inline] protected def bind (x : ReaderT \u03c1 m \u03b1) (f : \u03b1 \u2192 ReaderT \u03c1 m \u03b2) : ReaderT \u03c1 m \u03b2 :=\n  fun r => bind (x r) fun a => f a r\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : ReaderT \u03c1 m \u03b1) : ReaderT \u03c1 m \u03b2 :=\n  fun r => Functor.map f (x r)\n\ninstance : Monad (ReaderT \u03c1 m) where\n  pure := ReaderT.pure\n  bind := ReaderT.bind\n  map  := ReaderT.map\n\ninstance (\u03c1 m) [Monad m] : MonadFunctor m (ReaderT \u03c1 m) where\n  monadMap f x := fun ctx => f (x ctx)\n\n@[inline] protected def adapt {\u03c1' : Type u} [Monad m] {\u03b1 : Type u} (f : \u03c1' \u2192 \u03c1) : ReaderT \u03c1 m \u03b1 \u2192 ReaderT \u03c1' m \u03b1 :=\n  fun x r => x (f r)\n\nend\nend ReaderT\n\n/-- An implementation of [MonadReader](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Reader-Class.html#t:MonadReader).\n    It does not contain `local` because this Function cannot be lifted using `monadLift`.\n    Instead, the `MonadReaderAdapter` class provides the more general `adaptReader` Function.\n\n    Note: This class can be seen as a simplification of the more \"principled\" definition\n    ```\n    class MonadReader (\u03c1 : outParam (Type u)) (n : Type u \u2192 Type u) where\n      lift {\u03b1 : Type u} : ({m : Type u \u2192 Type u} \u2192 [Monad m] \u2192 ReaderT \u03c1 m \u03b1) \u2192 n \u03b1\n    ```\n    -/\nclass MonadReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  read : m \u03c1\n\n@[inline] def readThe (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadReaderOf \u03c1 m] : m \u03c1 :=\n  MonadReaderOf.read\n\n/-- Similar to `MonadReaderOf`, but `\u03c1` is an outParam for convenience -/\nclass MonadReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  read : m \u03c1\n\nexport MonadReader (read)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadReaderOf \u03c1 m] : MonadReader \u03c1 m where\n  read := readThe \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadReaderOf \u03c1 m] : MonadReaderOf \u03c1 n where\n  read := liftM (m := m) read\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadReaderOf \u03c1 (ReaderT \u03c1 m) where\n  read := ReaderT.read\n\nclass MonadWithReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\n@[inline] def withTheReader (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadWithReaderOf \u03c1 m] {\u03b1 : Type u} (f : \u03c1 \u2192 \u03c1) (x : m \u03b1) : m \u03b1 :=\n  MonadWithReaderOf.withReader f x\n\nclass MonadWithReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadWithReader (withReader)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadWithReaderOf \u03c1 m] : MonadWithReader \u03c1 m where\n  withReader := withTheReader \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type v} [MonadFunctor m n] [MonadWithReaderOf \u03c1 m] : MonadWithReaderOf \u03c1 n where\n  withReader f := monadMap (m := m) (withTheReader \u03c1 f)\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadWithReaderOf \u03c1 (ReaderT \u03c1 m) where\n  withReader f x := fun ctx => x (f ctx)\n\n/-- An implementation of [MonadState](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-State-Class.html).\n    In contrast to the Haskell implementation, we use overlapping instances to derive instances\n    automatically from `monadLift`. -/\nclass MonadStateOf (\u03c3 : Type u) (m : Type u \u2192 Type v) where\n  /- Obtain the top-most State of a Monad stack. -/\n  get : m \u03c3\n  /- Set the top-most State of a Monad stack. -/\n  set : \u03c3 \u2192 m PUnit\n  /- Map the top-most State of a Monad stack.\n\n     Note: `modifyGet f` may be preferable to `do s <- get; let (a, s) := f s; put s; pure a`\n     because the latter does not use the State linearly (without sufficient inlining). -/\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadStateOf (set)\n\nabbrev getThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] : m \u03c3 :=\n  MonadStateOf.get\n\n@[inline] abbrev modifyThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  MonadStateOf.modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] abbrev modifyGetThe {\u03b1 : Type u} (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : m \u03b1 :=\n  MonadStateOf.modifyGet f\n\n/-- Similar to `MonadStateOf`, but `\u03c3` is an outParam for convenience -/\nclass MonadState (\u03c3 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  get : m \u03c3\n  set : \u03c3 \u2192 m PUnit\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadState (get modifyGet)\n\ninstance (\u03c3 : Type u) (m : Type u \u2192 Type v) [MonadStateOf \u03c3 m] : MonadState \u03c3 m where\n  set         := MonadStateOf.set\n  get         := getThe \u03c3\n  modifyGet f := MonadStateOf.modifyGet f\n\n@[inline] def modify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] def getModify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] [Monad m] (f : \u03c3 \u2192 \u03c3) : m \u03c3 :=\n  modifyGet fun s => (s, f s)\n\n-- NOTE: The Ordering of the following two instances determines that the top-most `StateT` Monad layer\n-- will be picked first\ninstance {\u03c3 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadStateOf \u03c3 m] : MonadStateOf \u03c3 n where\n  get         := liftM (m := m) MonadStateOf.get\n  set       s := liftM (m := m) (MonadStateOf.set s)\n  modifyGet f := monadLift (m := m) (MonadState.modifyGet f)\n\nnamespace EStateM\n\ninductive Result (\u03b5 \u03c3 \u03b1 : Type u) where\n  | ok    : \u03b1 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n  | error : \u03b5 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nvariable {\u03b5 \u03c3 \u03b1 : Type u}\n\ninstance [Inhabited \u03b5] [Inhabited \u03c3] : Inhabited (Result \u03b5 \u03c3 \u03b1) where\n  default := Result.error default default\n\nend EStateM\n\nopen EStateM (Result) in\ndef EStateM (\u03b5 \u03c3 \u03b1 : Type u) := \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nnamespace EStateM\n\nvariable {\u03b5 \u03c3 \u03b1 \u03b2 : Type u}\n\ninstance [Inhabited \u03b5] : Inhabited (EStateM \u03b5 \u03c3 \u03b1) where\n  default := fun s => Result.error default s\n\n@[inline] protected def pure (a : \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.ok a s\n\n@[inline] protected def set (s : \u03c3) : EStateM \u03b5 \u03c3 PUnit := fun _ =>\n  Result.ok \u27e8\u27e9 s\n\n@[inline] protected def get : EStateM \u03b5 \u03c3 \u03c3 := fun s =>\n  Result.ok s s\n\n@[inline] protected def modifyGet (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  match f s with\n  | (a, s) => Result.ok a s\n\n@[inline] protected def throw (e : \u03b5) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.error e s\n\n/-- Auxiliary instance for saving/restoring the \"backtrackable\" part of the state. -/\nclass Backtrackable (\u03b4 : outParam (Type u)) (\u03c3 : Type u) where\n  save    : \u03c3 \u2192 \u03b4\n  restore : \u03c3 \u2192 \u03b4 \u2192 \u03c3\n\n@[inline] protected def tryCatch {\u03b4} [Backtrackable \u03b4 \u03c3] {\u03b1} (x : EStateM \u03b5 \u03c3 \u03b1) (handle : \u03b5 \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s\n  match x s with\n  | Result.error e s => handle e (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] protected def orElse {\u03b4} [Backtrackable \u03b4 \u03c3] (x\u2081 : EStateM \u03b5 \u03c3 \u03b1) (x\u2082 : Unit \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s;\n  match x\u2081 s with\n  | Result.error _ s => x\u2082 () (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] def adaptExcept {\u03b5' : Type u} (f : \u03b5 \u2192 \u03b5') (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5' \u03c3 \u03b1 := fun s =>\n  match x s with\n  | Result.error e s => Result.error (f e) s\n  | Result.ok a s    => Result.ok a s\n\n@[inline] protected def bind (x : EStateM \u03b5 \u03c3 \u03b1) (f : \u03b1 \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => f a s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => Result.ok (f a) s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def seqRight (x : EStateM \u03b5 \u03c3 \u03b1) (y : Unit \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok _ s    => y () s\n  | Result.error e s => Result.error e s\n\ninstance : Monad (EStateM \u03b5 \u03c3) where\n  bind     := EStateM.bind\n  pure     := EStateM.pure\n  map      := EStateM.map\n  seqRight := EStateM.seqRight\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : OrElse (EStateM \u03b5 \u03c3 \u03b1) where\n  orElse := EStateM.orElse\n\ninstance : MonadStateOf \u03c3 (EStateM \u03b5 \u03c3) where\n  set       := EStateM.set\n  get       := EStateM.get\n  modifyGet := EStateM.modifyGet\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : MonadExceptOf \u03b5 (EStateM \u03b5 \u03c3) where\n  throw    := EStateM.throw\n  tryCatch := EStateM.tryCatch\n\n@[inline] def run (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Result \u03b5 \u03c3 \u03b1 :=\n  x s\n\n@[inline] def run' (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Option \u03b1 :=\n  match run x s with\n  | Result.ok v _   => some v\n  | Result.error .. => none\n\n@[inline] def dummySave : \u03c3 \u2192 PUnit := fun _ => \u27e8\u27e9\n\n@[inline] def dummyRestore : \u03c3 \u2192 PUnit \u2192 \u03c3 := fun s _ => s\n\n/- Dummy default instance -/\ninstance nonBacktrackable : Backtrackable PUnit \u03c3 where\n  save    := dummySave\n  restore := dummyRestore\n\nend EStateM\n\nclass Hashable (\u03b1 : Sort u) where\n  hash : \u03b1 \u2192 UInt64\n\nexport Hashable (hash)\n\n@[extern \"lean_uint64_to_usize\"]\nconstant UInt64.toUSize (u : UInt64) : USize\n\n@[extern \"lean_usize_to_uint64\"]\nconstant USize.toUInt64 (u : USize) : UInt64\n\n@[extern \"lean_uint64_mix_hash\"]\nconstant mixHash (u\u2081 u\u2082 : UInt64) : UInt64\n\n@[extern \"lean_string_hash\"]\nprotected constant String.hash (s : @& String) : UInt64\n\ninstance : Hashable String where\n  hash := String.hash\n\nnamespace Lean\n\n/- Hierarchical names -/\ninductive Name where\n  | anonymous : Name\n  | str : Name \u2192 String \u2192 UInt64 \u2192 Name\n  | num : Name \u2192 Nat \u2192 UInt64 \u2192 Name\n\ninstance : Inhabited Name where\n  default := Name.anonymous\n\nprotected def Name.hash : Name \u2192 UInt64\n  | Name.anonymous => UInt64.ofNatCore 1723 (by decide)\n  | Name.str p s h => h\n  | Name.num p v h => h\n\ninstance : Hashable Name where\n  hash := Name.hash\n\nnamespace Name\n\n@[export lean_name_mk_string]\ndef mkStr (p : Name) (s : String) : Name :=\n  Name.str p s (mixHash (hash p) (hash s))\n\n@[export lean_name_mk_numeral]\ndef mkNum (p : Name) (v : Nat) : Name :=\n  Name.num p v (mixHash (hash p) (dite (LT.lt v UInt64.size) (fun h => UInt64.ofNatCore v h) (fun _ => UInt64.ofNatCore 17 (by decide))))\n\ndef mkSimple (s : String) : Name :=\n  mkStr Name.anonymous s\n\n@[extern \"lean_name_eq\"]\nprotected def beq : (@& Name) \u2192 (@& Name) \u2192 Bool\n  | anonymous,   anonymous   => true\n  | str p\u2081 s\u2081 _, str p\u2082 s\u2082 _ => and (BEq.beq s\u2081 s\u2082) (Name.beq p\u2081 p\u2082)\n  | num p\u2081 n\u2081 _, num p\u2082 n\u2082 _ => and (BEq.beq n\u2081 n\u2082) (Name.beq p\u2081 p\u2082)\n  | _,           _           => false\n\ninstance : BEq Name where\n  beq := Name.beq\n\nprotected def append : Name \u2192 Name \u2192 Name\n  | n, anonymous => n\n  | n, str p s _ => Name.mkStr (Name.append n p) s\n  | n, num p d _ => Name.mkNum (Name.append n p) d\n\ninstance : Append Name where\n  append := Name.append\n\nend Name\n\n/- Syntax -/\n\n/-- Source information of tokens. -/\ninductive SourceInfo where\n  /-\n    Token from original input with whitespace and position information.\n    `leading` will be inferred after parsing by `Syntax.updateLeading`. During parsing,\n    it is not at all clear what the preceding token was, especially with backtracking. -/\n  | original (leading : Substring) (pos : String.Pos) (trailing : Substring) (endPos : String.Pos)\n  /-\n    Synthesized token (e.g. from a quotation) annotated with a span from the original source.\n    In the delaborator, we \"misuse\" this constructor to store synthetic positions identifying\n    subterms. -/\n  | synthetic (pos : String.Pos) (endPos : String.Pos)\n  /- Synthesized token without position information. -/\n  | protected none\n\ninstance : Inhabited SourceInfo := \u27e8SourceInfo.none\u27e9\n\nnamespace SourceInfo\n\ndef getPos? (info : SourceInfo) (originalOnly := false) : Option String.Pos :=\n  match info, originalOnly with\n  | original (pos := pos) ..,  _     => some pos\n  | synthetic (pos := pos) .., false => some pos\n  | _,                         _     => none\n\nend SourceInfo\n\nabbrev SyntaxNodeKind := Name\n\n/- Syntax AST -/\n\n/--\nSyntax objects used by the parser, macro expander, delaborator, etc.\n-/\ninductive Syntax where\n  | missing : Syntax\n  | /--\n  Node in the syntax tree.\n\n  The `info` field is used by the delaborator\n  to store the position of the subexpression\n  corresponding to this node.\n  The parser sets the `info` field to `none`.\n\n  (Remark: the `node` constructor\n  did not have an `info` field in previous versions.\n  This caused a bug in the interactive widgets,\n  where the popup for `a + b` was the same as for `a`.\n  The delaborator used to associate subexpressions\n  with pretty-printed syntax by setting\n  the (string) position of the first atom/identifier\n  to the (expression) position of the subexpression.\n  For example, both `a` and `a + b`\n  have the same first identifier,\n  and so their infos got mixed up.)\n  -/ node   (info : SourceInfo) (kind : SyntaxNodeKind) (args : Array Syntax) : Syntax\n  | atom   (info : SourceInfo) (val : String) : Syntax\n  | ident  (info : SourceInfo) (rawVal : Substring) (val : Name) (preresolved : List (Prod Name (List String))) : Syntax\n\ninstance : Inhabited Syntax where\n  default := Syntax.missing\n\n/- Builtin kinds -/\ndef choiceKind : SyntaxNodeKind := `choice\ndef nullKind : SyntaxNodeKind := `null\ndef groupKind : SyntaxNodeKind := `group\ndef identKind : SyntaxNodeKind := `ident\ndef strLitKind : SyntaxNodeKind := `strLit\ndef charLitKind : SyntaxNodeKind := `charLit\ndef numLitKind : SyntaxNodeKind := `numLit\ndef scientificLitKind : SyntaxNodeKind := `scientificLit\ndef nameLitKind : SyntaxNodeKind := `nameLit\ndef fieldIdxKind : SyntaxNodeKind := `fieldIdx\ndef interpolatedStrLitKind : SyntaxNodeKind := `interpolatedStrLitKind\ndef interpolatedStrKind : SyntaxNodeKind := `interpolatedStrKind\n\nnamespace Syntax\n\ndef getKind (stx : Syntax) : SyntaxNodeKind :=\n  match stx with\n  | Syntax.node _ k args => k\n  -- We use these \"pseudo kinds\" for antiquotation kinds.\n  -- For example, an antiquotation `$id:ident` (using Lean.Parser.Term.ident)\n  -- is compiled to ``if stx.isOfKind `ident ...``\n  | Syntax.missing     => `missing\n  | Syntax.atom _ v    => Name.mkSimple v\n  | Syntax.ident ..    => identKind\n\ndef setKind (stx : Syntax) (k : SyntaxNodeKind) : Syntax :=\n  match stx with\n  | Syntax.node info _ args => Syntax.node info k args\n  | _                       => stx\n\ndef isOfKind (stx : Syntax) (k : SyntaxNodeKind) : Bool :=\n  beq stx.getKind k\n\ndef getArg (stx : Syntax) (i : Nat) : Syntax :=\n  match stx with\n  | Syntax.node _ _ args => args.getD i Syntax.missing\n  | _                    => Syntax.missing\n\n-- Add `stx[i]` as sugar for `stx.getArg i`\n@[inline] def getOp (self : Syntax) (idx : Nat) : Syntax :=\n  self.getArg idx\n\ndef getArgs (stx : Syntax) : Array Syntax :=\n  match stx with\n  | Syntax.node _ _ args => args\n  | _                    => Array.empty\n\ndef getNumArgs (stx : Syntax) : Nat :=\n  match stx with\n  | Syntax.node _ _ args => args.size\n  | _                    => 0\n\ndef isMissing : Syntax \u2192 Bool\n  | Syntax.missing => true\n  | _ => false\n\ndef isNodeOf (stx : Syntax) (k : SyntaxNodeKind) (n : Nat) : Bool :=\n  and (stx.isOfKind k) (beq stx.getNumArgs n)\n\ndef isIdent : Syntax \u2192 Bool\n  | ident _ _ _ _ => true\n  | _             => false\n\ndef getId : Syntax \u2192 Name\n  | ident _ _ val _ => val\n  | _               => Name.anonymous\n\ndef matchesNull (stx : Syntax) (n : Nat) : Bool :=\n  isNodeOf stx nullKind n\n\ndef matchesIdent (stx : Syntax) (id : Name) : Bool :=\n  and stx.isIdent (beq stx.getId id)\n\ndef matchesLit (stx : Syntax) (k : SyntaxNodeKind) (val : String) : Bool :=\n  match stx with\n  | Syntax.node _ k' args => and (beq k k') (match args.getD 0 Syntax.missing with\n    | Syntax.atom _ val' => beq val val'\n    | _                  => false)\n  | _                     => false\n\ndef setArgs (stx : Syntax) (args : Array Syntax) : Syntax :=\n  match stx with\n  | node info k _ => node info k args\n  | stx           => stx\n\ndef setArg (stx : Syntax) (i : Nat) (arg : Syntax) : Syntax :=\n  match stx with\n  | node info k args => node info k (args.setD i arg)\n  | stx              => stx\n\n/-- Retrieve the left-most node or leaf's info in the Syntax tree. -/\npartial def getHeadInfo? : Syntax \u2192 Option SourceInfo\n  | atom info _   => some info\n  | ident info .. => some info\n  | node SourceInfo.none _ args   =>\n    let rec loop (i : Nat) : Option SourceInfo :=\n      match decide (LT.lt i args.size) with\n      | true => match getHeadInfo? (args.get! i) with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | node info _ _ => some info\n  | _             => none\n\n/-- Retrieve the left-most leaf's info in the Syntax tree, or `none` if there is no token. -/\npartial def getHeadInfo (stx : Syntax) : SourceInfo :=\n  match stx.getHeadInfo? with\n  | some info => info\n  | none      => SourceInfo.none\n\ndef getPos? (stx : Syntax) (originalOnly := false) : Option String.Pos :=\n  stx.getHeadInfo.getPos? originalOnly\n\npartial def getTailPos? (stx : Syntax) (originalOnly := false) : Option String.Pos :=\n  match stx, originalOnly with\n  | atom (SourceInfo.original (endPos := pos) ..) ..,    _    => some pos\n  | atom (SourceInfo.synthetic (endPos := pos) ..) _,  false  => some pos\n  | ident (SourceInfo.original (endPos := pos) ..) .., _      => some pos\n  | ident (SourceInfo.synthetic (endPos := pos) ..) .., false => some pos\n  | node (SourceInfo.original (endPos := pos) ..) ..,    _    => some pos\n  | node (SourceInfo.synthetic (endPos := pos) ..) .., false  => some pos\n  | node _ _ args,                                        _     =>\n    let rec loop (i : Nat) : Option String.Pos :=\n      match decide (LT.lt i args.size) with\n      | true => match getTailPos? (args.get! ((args.size.sub i).sub 1)) originalOnly with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | _, _ => none\n\n/--\n  An array of syntax elements interspersed with separators. Can be coerced to/from `Array Syntax` to automatically\n  remove/insert the separators. -/\nstructure SepArray (sep : String) where\n  elemsAndSeps : Array Syntax\n\nend Syntax\n\ndef SourceInfo.fromRef (ref : Syntax) : SourceInfo :=\n  match ref.getPos?, ref.getTailPos? with\n  | some pos, some tailPos => SourceInfo.synthetic pos tailPos\n  | _,        _            => SourceInfo.none\n\ndef mkAtom (val : String) : Syntax :=\n  Syntax.atom SourceInfo.none val\n\ndef mkAtomFrom (src : Syntax) (val : String) : Syntax :=\n  Syntax.atom (SourceInfo.fromRef src) val\n\n/- Parser descriptions -/\n\ninductive ParserDescr where\n  | const  (name : Name)\n  | unary  (name : Name) (p : ParserDescr)\n  | binary (name : Name) (p\u2081 p\u2082 : ParserDescr)\n  | node (kind : SyntaxNodeKind) (prec : Nat) (p : ParserDescr)\n  | trailingNode (kind : SyntaxNodeKind) (prec lhsPrec : Nat) (p : ParserDescr)\n  | symbol (val : String)\n  | nonReservedSymbol (val : String) (includeIdent : Bool)\n  | cat (catName : Name) (rbp : Nat)\n  | parser (declName : Name)\n  | nodeWithAntiquot (name : String) (kind : SyntaxNodeKind) (p : ParserDescr)\n  | sepBy  (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n  | sepBy1 (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n\ninstance : Inhabited ParserDescr where\n  default := ParserDescr.symbol \"\"\n\nabbrev TrailingParserDescr := ParserDescr\n\n/-\nRuntime support for making quotation terms auto-hygienic, by mangling identifiers\nintroduced by them with a \"macro scope\" supplied by the context. Details to appear in a\npaper soon.\n-/\n\nabbrev MacroScope := Nat\n/-- Macro scope used internally. It is not available for our frontend. -/\ndef reservedMacroScope := 0\n/-- First macro scope available for our frontend -/\ndef firstFrontendMacroScope := hAdd reservedMacroScope 1\n\nclass MonadRef (m : Type \u2192 Type) where\n  getRef      : m Syntax\n  withRef {\u03b1} : Syntax \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadRef (getRef)\n\ninstance (m n : Type \u2192 Type) [MonadLift m n] [MonadFunctor m n] [MonadRef m] : MonadRef n where\n  getRef        := liftM (getRef : m _)\n  withRef ref x := monadMap (m := m) (MonadRef.withRef ref) x\n\ndef replaceRef (ref : Syntax) (oldRef : Syntax) : Syntax :=\n  match ref.getPos? with\n  | some _ => ref\n  | _      => oldRef\n\n@[inline] def withRef {m : Type \u2192 Type} [Monad m] [MonadRef m] {\u03b1} (ref : Syntax) (x : m \u03b1) : m \u03b1 :=\n  bind getRef fun oldRef =>\n  let ref := replaceRef ref oldRef\n  MonadRef.withRef ref x\n\n/-- A monad that supports syntax quotations. Syntax quotations (in term\n    position) are monadic values that when executed retrieve the current \"macro\n    scope\" from the monad and apply it to every identifier they introduce\n    (independent of whether this identifier turns out to be a reference to an\n    existing declaration, or an actually fresh binding during further\n    elaboration). We also apply the position of the result of `getRef` to each\n    introduced symbol, which results in better error positions than not applying\n    any position. -/\nclass MonadQuotation (m : Type \u2192 Type) extends MonadRef m where\n  -- Get the fresh scope of the current macro invocation\n  getCurrMacroScope : m MacroScope\n  getMainModule     : m Name\n  /- Execute action in a new macro invocation context. This transformer should be\n     used at all places that morally qualify as the beginning of a \"macro call\",\n     e.g. `elabCommand` and `elabTerm` in the case of the elaborator. However, it\n     can also be used internally inside a \"macro\" if identifiers introduced by\n     e.g. different recursive calls should be independent and not collide. While\n     returning an intermediate syntax tree that will recursively be expanded by\n     the elaborator can be used for the same effect, doing direct recursion inside\n     the macro guarded by this transformer is often easier because one is not\n     restricted to passing a single syntax tree. Modelling this helper as a\n     transformer and not just a monadic action ensures that the current macro\n     scope before the recursive call is restored after it, as expected. -/\n  withFreshMacroScope {\u03b1 : Type} : m \u03b1 \u2192 m \u03b1\n\nexport MonadQuotation (getCurrMacroScope getMainModule withFreshMacroScope)\n\ndef MonadRef.mkInfoFromRefPos [Monad m] [MonadRef m] : m SourceInfo :=\n  return SourceInfo.fromRef (\u2190 getRef)\n\ninstance {m n : Type \u2192 Type} [MonadFunctor m n] [MonadLift m n] [MonadQuotation m] : MonadQuotation n where\n  getCurrMacroScope   := liftM (m := m) getCurrMacroScope\n  getMainModule       := liftM (m := m) getMainModule\n  withFreshMacroScope := monadMap (m := m) withFreshMacroScope\n\n/-\nWe represent a name with macro scopes as\n```\n<actual name>._@.(<module_name>.<scopes>)*.<module_name>._hyg.<scopes>\n```\nExample: suppose the module name is `Init.Data.List.Basic`, and name is `foo.bla`, and macroscopes [2, 5]\n```\nfoo.bla._@.Init.Data.List.Basic._hyg.2.5\n```\n\nWe may have to combine scopes from different files/modules.\nThe main modules being processed is always the right most one.\nThis situation may happen when we execute a macro generated in\nan imported file in the current file.\n```\nfoo.bla._@.Init.Data.List.Basic.2.1.Init.Lean.Expr_hyg.4\n```\n\nThe delimiter `_hyg` is used just to improve the `hasMacroScopes` performance.\n-/\n\ndef Name.hasMacroScopes : Name \u2192 Bool\n  | str _ s _   => beq s \"_hyg\"\n  | num p _   _ => hasMacroScopes p\n  | _           => false\n\nprivate def eraseMacroScopesAux : Name \u2192 Name\n  | Name.str p s _   => match beq s \"_@\" with\n    | true  => p\n    | false => eraseMacroScopesAux p\n  | Name.num p _ _   => eraseMacroScopesAux p\n  | Name.anonymous   => Name.anonymous\n\n@[export lean_erase_macro_scopes]\ndef Name.eraseMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => eraseMacroScopesAux n\n  | false => n\n\nprivate def simpMacroScopesAux : Name \u2192 Name\n  | Name.num p i _ => Name.mkNum (simpMacroScopesAux p) i\n  | n              => eraseMacroScopesAux n\n\n/- Helper function we use to create binder names that do not need to be unique. -/\n@[export lean_simp_macro_scopes]\ndef Name.simpMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => simpMacroScopesAux n\n  | false => n\n\nstructure MacroScopesView where\n  name       : Name\n  imported   : Name\n  mainModule : Name\n  scopes     : List MacroScope\n\ninstance : Inhabited MacroScopesView where\n  default := \u27e8default, default, default, default\u27e9\n\ndef MacroScopesView.review (view : MacroScopesView) : Name :=\n  match view.scopes with\n  | List.nil      => view.name\n  | List.cons _ _ =>\n    let base := (Name.mkStr (hAppend (hAppend (Name.mkStr view.name \"_@\") view.imported) view.mainModule) \"_hyg\")\n    view.scopes.foldl Name.mkNum base\n\nprivate def assembleParts : List Name \u2192 Name \u2192 Name\n  | List.nil,                      acc => acc\n  | List.cons (Name.str _ s _) ps, acc => assembleParts ps (Name.mkStr acc s)\n  | List.cons (Name.num _ n _) ps, acc => assembleParts ps (Name.mkNum acc n)\n  | _,                             acc => panic \"Error: unreachable @ assembleParts\"\n\nprivate def extractImported (scps : List MacroScope) (mainModule : Name) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := mainModule, imported := assembleParts parts Name.anonymous, scopes := scps }\n    | false => extractImported scps mainModule p (List.cons n parts)\n  | n@(Name.num p str _), parts => extractImported scps mainModule p (List.cons n parts)\n  | _,                    _     => panic \"Error: unreachable @ extractImported\"\n\nprivate def extractMainModule (scps : List MacroScope) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := assembleParts parts Name.anonymous, imported := Name.anonymous, scopes := scps }\n    | false => extractMainModule scps p (List.cons n parts)\n  | n@(Name.num p num _), acc => extractImported scps (assembleParts acc Name.anonymous) n List.nil\n  | _,                    _   => panic \"Error: unreachable @ extractMainModule\"\n\nprivate def extractMacroScopesAux : Name \u2192 List MacroScope \u2192 MacroScopesView\n  | Name.num p scp _, acc => extractMacroScopesAux p (List.cons scp acc)\n  | Name.str p str _, acc => extractMainModule acc p List.nil -- str must be \"_hyg\"\n  | _,                _   => panic \"Error: unreachable @ extractMacroScopesAux\"\n\n/--\n  Revert all `addMacroScope` calls. `v = extractMacroScopes n \u2192 n = v.review`.\n  This operation is useful for analyzing/transforming the original identifiers, then adding back\n  the scopes (via `MacroScopesView.review`). -/\ndef extractMacroScopes (n : Name) : MacroScopesView :=\n  match n.hasMacroScopes with\n  | true  => extractMacroScopesAux n List.nil\n  | false => { name := n, scopes := List.nil, imported := Name.anonymous, mainModule := Name.anonymous }\n\ndef addMacroScope (mainModule : Name) (n : Name) (scp : MacroScope) : Name :=\n  match n.hasMacroScopes with\n  | true =>\n    let view := extractMacroScopes n\n    match beq view.mainModule mainModule with\n    | true  => Name.mkNum n scp\n    | false =>\n      { view with\n        imported   := view.scopes.foldl Name.mkNum (hAppend view.imported view.mainModule)\n        mainModule := mainModule\n        scopes     := List.cons scp List.nil\n      }.review\n  | false =>\n    Name.mkNum (Name.mkStr (hAppend (Name.mkStr n \"_@\") mainModule) \"_hyg\") scp\n\n@[inline] def MonadQuotation.addMacroScope {m : Type \u2192 Type} [MonadQuotation m] [Monad m] (n : Name) : m Name :=\n  bind getMainModule     fun mainModule =>\n  bind getCurrMacroScope fun scp =>\n  pure (Lean.addMacroScope mainModule n scp)\n\ndef defaultMaxRecDepth := 512\n\ndef maxRecDepthErrorMessage : String :=\n  \"maximum recursion depth has been reached (use `set_option maxRecDepth <num>` to increase limit)\"\n\nnamespace Macro\n\n/- References -/\nprivate constant MethodsRefPointed : NonemptyType.{0}\n\nprivate def MethodsRef : Type := MethodsRefPointed.type\n\ninstance : Nonempty MethodsRef := MethodsRefPointed.property\n\nstructure Context where\n  methods        : MethodsRef\n  mainModule     : Name\n  currMacroScope : MacroScope\n  currRecDepth   : Nat := 0\n  maxRecDepth    : Nat := defaultMaxRecDepth\n  ref            : Syntax\n\ninductive Exception where\n  | error             : Syntax \u2192 String \u2192 Exception\n  | unsupportedSyntax : Exception\n\nstructure State where\n  macroScope : MacroScope\n  traceMsgs  : List (Prod Name String) := List.nil\n  deriving Inhabited\n\nend Macro\n\nabbrev MacroM := ReaderT Macro.Context (EStateM Macro.Exception Macro.State)\n\nabbrev Macro := Syntax \u2192 MacroM Syntax\n\nnamespace Macro\n\ninstance : MonadRef MacroM where\n  getRef     := bind read fun ctx => pure ctx.ref\n  withRef    := fun ref x => withReader (fun ctx => { ctx with ref := ref }) x\n\ndef addMacroScope (n : Name) : MacroM Name :=\n  bind read fun ctx =>\n  pure (Lean.addMacroScope ctx.mainModule n ctx.currMacroScope)\n\ndef throwUnsupported {\u03b1} : MacroM \u03b1 :=\n  throw Exception.unsupportedSyntax\n\ndef throwError {\u03b1} (msg : String) : MacroM \u03b1 :=\n  bind getRef fun ref =>\n  throw (Exception.error ref msg)\n\ndef throwErrorAt {\u03b1} (ref : Syntax) (msg : String) : MacroM \u03b1 :=\n  withRef ref (throwError msg)\n\n@[inline] protected def withFreshMacroScope {\u03b1} (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind (modifyGet (fun s => (s.macroScope, { s with macroScope := hAdd s.macroScope 1 }))) fun fresh =>\n  withReader (fun ctx => { ctx with currMacroScope := fresh }) x\n\n@[inline] def withIncRecDepth {\u03b1} (ref : Syntax) (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind read fun ctx =>\n  match beq ctx.currRecDepth ctx.maxRecDepth with\n  | true  => throw (Exception.error ref maxRecDepthErrorMessage)\n  | false => withReader (fun ctx => { ctx with currRecDepth := hAdd ctx.currRecDepth 1 }) x\n\ninstance : MonadQuotation MacroM where\n  getCurrMacroScope ctx := pure ctx.currMacroScope\n  getMainModule     ctx := pure ctx.mainModule\n  withFreshMacroScope   := Macro.withFreshMacroScope\n\nstructure Methods where\n  expandMacro?      : Syntax \u2192 MacroM (Option Syntax)\n  getCurrNamespace  : MacroM Name\n  hasDecl           : Name \u2192 MacroM Bool\n  resolveNamespace? : Name \u2192 MacroM (Option Name)\n  resolveGlobalName : Name \u2192 MacroM (List (Prod Name (List String)))\n  deriving Inhabited\n\nunsafe def mkMethodsImp (methods : Methods) : MethodsRef :=\n  unsafeCast methods\n\n@[implementedBy mkMethodsImp]\nconstant mkMethods (methods : Methods) : MethodsRef\n\ninstance : Inhabited MethodsRef where\n  default := mkMethods default\n\nunsafe def getMethodsImp : MacroM Methods :=\n  bind read fun ctx => pure (unsafeCast (ctx.methods))\n\n@[implementedBy getMethodsImp] constant getMethods : MacroM Methods\n\n/-- `expandMacro? stx` return `some stxNew` if `stx` is a macro, and `stxNew` is its expansion. -/\ndef expandMacro? (stx : Syntax) : MacroM (Option Syntax) := do\n  (\u2190 getMethods).expandMacro? stx\n\n/-- Return `true` if the environment contains a declaration with name `declName` -/\ndef hasDecl (declName : Name) : MacroM Bool := do\n  (\u2190 getMethods).hasDecl declName\n\ndef getCurrNamespace : MacroM Name := do\n  (\u2190 getMethods).getCurrNamespace\n\ndef resolveNamespace? (n : Name) : MacroM (Option Name) := do\n  (\u2190 getMethods).resolveNamespace? n\n\ndef resolveGlobalName (n : Name) : MacroM (List (Prod Name (List String))) := do\n  (\u2190 getMethods).resolveGlobalName n\n\ndef trace (clsName : Name) (msg : String) : MacroM Unit := do\n  modify fun s => { s with traceMsgs := List.cons (Prod.mk clsName msg) s.traceMsgs }\n\nend Macro\n\nexport Macro (expandMacro?)\n\nnamespace PrettyPrinter\n\nabbrev UnexpandM := ReaderT Syntax (EStateM Unit Unit)\n\n/--\n  Function that tries to reverse macro expansions as a post-processing step of delaboration.\n  While less general than an arbitrary delaborator, it can be declared without importing `Lean`.\n  Used by the `[appUnexpander]` attribute. -/\n-- a `kindUnexpander` could reasonably be added later\nabbrev Unexpander := Syntax \u2192 UnexpandM Syntax\n\ninstance : MonadQuotation UnexpandM where\n  getRef              := read\n  withRef ref x       := withReader (fun _ => ref) x\n  -- unexpanders should not need to introduce new names\n  getCurrMacroScope   := pure 0\n  getMainModule       := pure `_fakeMod\n  withFreshMacroScope := id\n\nend PrettyPrinter\n\nend Lean\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/stage0/src/Init/Prelude.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6688802603710086, "lm_q2_score": 0.7154240079185319, "lm_q1q2_score": 0.4785329966922181}}
{"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 `\u2124[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 `\u2124[i]` if and only if it is `3` mod `4`\n\n## Notations\n\nThis file uses the local notation `\u2124[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 := \u2124\u221a(-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 \u2192+* \u2102 := coe_fn zsqrtd.lift { val := complex.I, property := sorry }\n\nprotected instance complex.has_coe : has_coe gaussian_int \u2102 := has_coe.mk \u21d1to_complex\n\ntheorem to_complex_def (x : gaussian_int) : \u2191x = \u2191(zsqrtd.re x) + \u2191(zsqrtd.im x) * complex.I := rfl\n\ntheorem to_complex_def' (x : \u2124) (y : \u2124) : \u2191(zsqrtd.mk x y) = \u2191x + \u2191y * complex.I := sorry\n\ntheorem to_complex_def\u2082 (x : gaussian_int) : \u2191x = complex.mk \u2191(zsqrtd.re x) \u2191(zsqrtd.im x) := sorry\n\n@[simp] theorem to_real_re (x : gaussian_int) : \u2191(zsqrtd.re x) = complex.re \u2191x := sorry\n\n@[simp] theorem to_real_im (x : gaussian_int) : \u2191(zsqrtd.im x) = complex.im \u2191x := sorry\n\n@[simp] theorem to_complex_re (x : \u2124) (y : \u2124) : complex.re \u2191(zsqrtd.mk x y) = \u2191x := sorry\n\n@[simp] theorem to_complex_im (x : \u2124) (y : \u2124) : complex.im \u2191(zsqrtd.mk x y) = \u2191y := sorry\n\n@[simp] theorem to_complex_add (x : gaussian_int) (y : gaussian_int) : \u2191(x + y) = \u2191x + \u2191y :=\n  ring_hom.map_add to_complex x y\n\n@[simp] theorem to_complex_mul (x : gaussian_int) (y : gaussian_int) : \u2191(x * y) = \u2191x * \u2191y :=\n  ring_hom.map_mul to_complex x y\n\n@[simp] theorem to_complex_one : \u21911 = 1 := ring_hom.map_one to_complex\n\n@[simp] theorem to_complex_zero : \u21910 = 0 := ring_hom.map_zero to_complex\n\n@[simp] theorem to_complex_neg (x : gaussian_int) : \u2191(-x) = -\u2191x := ring_hom.map_neg to_complex x\n\n@[simp] theorem to_complex_sub (x : gaussian_int) (y : gaussian_int) : \u2191(x - y) = \u2191x - \u2191y :=\n  ring_hom.map_sub to_complex x y\n\n@[simp] theorem to_complex_inj {x : gaussian_int} {y : gaussian_int} : \u2191x = \u2191y \u2194 x = y := sorry\n\n@[simp] theorem to_complex_eq_zero {x : gaussian_int} : \u2191x = 0 \u2194 x = 0 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2191x = 0 \u2194 x = 0)) (Eq.symm to_complex_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191x = \u21910 \u2194 x = 0)) (propext to_complex_inj)))\n      (iff.refl (x = 0)))\n\n@[simp] theorem nat_cast_real_norm (x : gaussian_int) :\n    \u2191(zsqrtd.norm x) = coe_fn complex.norm_sq \u2191x :=\n  sorry\n\n@[simp] theorem nat_cast_complex_norm (x : gaussian_int) :\n    \u2191(zsqrtd.norm x) = \u2191(coe_fn complex.norm_sq \u2191x) :=\n  sorry\n\ntheorem norm_nonneg (x : gaussian_int) : 0 \u2264 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 \u2194 x = 0 := sorry\n\ntheorem norm_pos {x : gaussian_int} : 0 < zsqrtd.norm x \u2194 x \u2260 0 := sorry\n\n@[simp] theorem coe_nat_abs_norm (x : gaussian_int) :\n    \u2191(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 {\u03b1 : Type u_1} [ring \u03b1] (x : gaussian_int) :\n    \u2191(int.nat_abs (zsqrtd.norm x)) = \u2191(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 : \u211a := rat.of_int (zsqrtd.norm y)\u207b\u00b9;\n  let c : \u2124\u221a(-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 (\u2191(zsqrtd.re (x * zsqrtd.conj y)) / \u2191(zsqrtd.norm y)))\n          (round (\u2191(zsqrtd.im (x * zsqrtd.conj y)) / \u2191(zsqrtd.norm y))) :=\n  sorry\n\ntheorem to_complex_div_re (x : gaussian_int) (y : gaussian_int) :\n    complex.re \u2191(x / y) = \u2191(round (complex.re (\u2191x / \u2191y))) :=\n  sorry\n\ntheorem to_complex_div_im (x : gaussian_int) (y : gaussian_int) :\n    complex.im \u2191(x / y) = \u2191(round (complex.im (\u2191x / \u2191y))) :=\n  sorry\n\ntheorem norm_sq_le_norm_sq_of_re_le_of_im_le {x : \u2102} {y : \u2102}\n    (hre : abs (complex.re x) \u2264 abs (complex.re y))\n    (him : abs (complex.im x) \u2264 abs (complex.im y)) :\n    coe_fn complex.norm_sq x \u2264 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 (\u2191x / \u2191y - \u2191(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 \u2260 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 \u2260 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 \u2260 0) :\n    int.nat_abs (zsqrtd.norm x) \u2264 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 \u2218 zsqrtd.norm)) sorry nat_abs_norm_mod_lt\n    sorry\n\ntheorem mod_four_eq_three_of_nat_prime_of_prime (p : \u2115) [hp : fact (nat.prime p)] (hpi : prime \u2191p) :\n    p % bit0 (bit0 1) = bit1 1 :=\n  sorry\n\ntheorem sum_two_squares_of_nat_prime_of_not_irreducible (p : \u2115) [hp : fact (nat.prime p)]\n    (hpi : \u00acirreducible \u2191p) : \u2203 (a : \u2115), \u2203 (b : \u2115), a ^ bit0 1 + b ^ bit0 1 = p :=\n  sorry\n\ntheorem prime_of_nat_prime_of_mod_four_eq_three (p : \u2115) [hp : fact (nat.prime p)]\n    (hp3 : p % bit0 (bit0 1) = bit1 1) : prime \u2191p :=\n  sorry\n\n/-- A prime natural number is prime in `\u2124[i]` if and only if it is `3` mod `4` -/\ntheorem prime_iff_mod_four_eq_three_of_nat_prime (p : \u2115) [hp : fact (nat.prime p)] :\n    prime \u2191p \u2194 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 : \u03a0 n : nat, Type) (functions : \u03a0  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  : \u2115 \u2192 Type \n| bvar : \u2115 \u2192 preterm 0\n| fvar : string \u2192 preterm 0\n| func : \u2200 {n : nat}, L.functions n \u2192 preterm n\n| apply : \u2200 {n : nat}, preterm (n + 1) \u2192 preterm 0 \u2192 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 : \u2200 {l}, preterm l \u2192 \u2115 \u2192 \u2115 \u2192 preterm l\n-- | _ (var L k) n m := if m \u2264 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 : \u2200 {l}, preterm l \u2192 term \u2192 \u2115 \u2192 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 : \u03a0 n : \u2115, preterm n \u2192 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 \u222a free_vars_preterm 0 t2)\n\ndef free_vars_term : term \u2192 list string := free_vars_preterm 0\n\nlemma free_var_preterm_coercionl (n : \u2115) (t1 : preterm (n+1)) (t2 : term) : {x : string // x \u2208 (free_vars_preterm (n+1) t1)} \u2192 {x : string // x \u2208 (free_vars_preterm n (apply t1 t2))} := sorry\n\ndef substitute_preterm : \u03a0 n : \u2115, \u03a0 (t : preterm n), term \u2192 {x : string // x \u2208 (free_vars_preterm n t)} \u2192 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 : \u2115 \u2192 Type \n| true : preformula 0\n| false : preformula 0\n| equal : (term L)  \u2192 (term L) \u2192 preformula 0\n| rel : \u2200 {n : nat}, L.relations n \u2192 preformula n\n| apprel : \u2200 {n : nat}, preformula (n + 1) \u2192 (term L) \u2192 preformula n\n| imp : preformula 0 \u2192 preformula 0 \u2192 preformula 0\n| all : preformula 0 \u2192 preformula 0\nopen preformula\ndef formula := preformula 0\n\ndef free_vars_preformula : \u03a0 n : \u2115, preformula n \u2192 list string\n| _ (true L) := []\n| _ (false L) := []\n| _ (equal t1 t2) := free_vars_term L t1 \u222a free_vars_term L t2\n| _ (@rel L n R) := []\n| _ (@apprel L n \u03c8 t) := free_vars_preformula _ \u03c8 \u222a free_vars_term L t\n| _ (imp \u03d5 \u03c8) := free_vars_preformula _ \u03d5 \u222a free_vars_preformula _ \u03c8\n| _ (all \u03c8) := free_vars_preformula _ \u03c8\n\ndef free_vars_formula : formula \u2192 list string := free_vars_preformula 0\n\n-- def raise_depth_formula : \u2200 {l}, preformula l \u2192 \u2115 \u2192 \u2115 \u2192 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 : \u2200 {l}, preformula l \u2192 (term L) \u2192 \u2115 \u2192 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 : \u03a0 n : \u2115, \u03a0 (\u03c8 : preformula n), term \u2192 {x : string // x \u2208 (free_vars_preformula _ \u03c8)} \u2192 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 \u2964 D` for the type of all functors from `C` to `D`.\n(Unfortunately the `\u21d2` 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\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\u2081) [category.{v\u2081} C] (D : Type u\u2082) [category.{v\u2082} D]\n  extends prefunctor C D : Type (max v\u2081 v\u2082 u\u2081 u\u2082) :=\n(map_id'   : \u2200 (X : C), map (\ud835\udfd9 X) = \ud835\udfd9 (obj X) . obviously)\n(map_comp' : \u2200 {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z), map (f \u226b g) = (map f) \u226b (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 \u2964 a similar precedence to \u2192 (25).\n-- For example, `C \u00d7 D \u2964 E` should parse as `(C \u00d7 D) \u2964 E` not `C \u00d7 (D \u2964 E)`.\ninfixr ` \u2964 `: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\u2081) [category.{v\u2081} C]\n\n/-- `\ud835\udfed C` is the identity functor on a category `C`. -/\nprotected def id : C \u2964 C :=\n{ obj := \u03bb X, X,\n  map := \u03bb _ _ f, f }\n\nnotation `\ud835\udfed` := functor.id -- Type this as `\\sb1`\n\ninstance : inhabited (C \u2964 C) := \u27e8functor.id C\u27e9\n\nvariable {C}\n\n@[simp] lemma id_obj (X : C) : (\ud835\udfed C).obj X = X := rfl\n@[simp] lemma id_map {X Y : C} (f : X \u27f6 Y) : (\ud835\udfed C).map f = f := rfl\nend\n\nsection\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n          {D : Type u\u2082} [category.{v\u2082} D]\n          {E : Type u\u2083} [category.{v\u2083} E]\n\n/--\n`F \u22d9 G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\ndef comp (F : C \u2964 D) (G : D \u2964 E) : C \u2964 E :=\n{ obj := \u03bb X, G.obj (F.obj X),\n  map := \u03bb _ _ f, G.map (F.map f) }\n\ninfixr ` \u22d9 `:80 := comp\n\n@[simp] lemma comp_obj (F : C \u2964 D) (G : D \u2964 E) (X : C) : (F \u22d9 G).obj X = G.obj (F.obj X) := rfl\n@[simp] lemma comp_map (F : C \u2964 D) (G : D \u2964 E) {X Y : C} (f : X \u27f6 Y) :\n  (F \u22d9 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 \u2964 D) : F \u22d9 (\ud835\udfed D) = F := by cases F; refl\nprotected lemma id_comp (F : C \u2964 D) : (\ud835\udfed C) \u22d9 F = F := by cases F; refl\n\n@[simp] lemma map_dite (F : C \u2964 D) {X Y : C} {P : Prop} [decidable P]\n  (f : P \u2192 (X \u27f6 Y)) (g : \u00acP \u2192 (X \u27f6 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 (\u03c6 \u03c8 : nnf) (\u0393\u2081 \u0393\u2082 \u0394 \u039b: list nnf) {st : Type}\nvariables (k : S4 st) (s : st)\nopen list\n\ntheorem sat_subset (h\u2081 : \u0393\u2081 \u2286 \u0393\u2082) (h\u2082 : sat k s \u0393\u2082) : sat k s \u0393\u2081 :=\n\u03bb x hx, h\u2082 _ (h\u2081 hx)\n\ntheorem sat_sublist (h\u2081 : \u0393\u2081 <+ \u0393\u2082) (h\u2082 :sat k s \u0393\u2082) : sat k s \u0393\u2081 := \nsat_subset _ _ _ _ (sublist.subset h\u2081) h\u2082\n\ntheorem sat_append (h\u2081 : sat k s \u0393\u2081) (h\u2082 : sat k s \u0393\u2082) : sat k s (\u0393\u2081 ++ \u0393\u2082) :=\nbegin\n  intros \u03c6 h, rw mem_append at h, cases h,\n  apply h\u2081 _ h, apply h\u2082 _ h\nend\n\ntheorem unsat_contra  {\u0394 n} : var n \u2208 \u0394 \u2192  neg n \u2208 \u0394 \u2192  unsatisfiable \u0394:= \nbegin\n  intros h\u2081 h\u2082, intros v hsat, intros s hsat,\n  have := hsat _ h\u2081, have := hsat _ h\u2082, simpa\nend\n\ntheorem unsat_contra_seqt {\u0394 : sseqt} {n} : var n \u2208 \u0394.m \u2192  neg n \u2208 \u0394.m \u2192  unsatisfiable (\u0394.m ++ \u0394.b):= \nbegin\n  intros h\u2081 h\u2082, intros st m, intros s hsat,\n  have := unsat_contra h\u2081 h\u2082,\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 \u03c6 \u03c8) \u2194 (force k s \u03c6) \u2227 (force k s \u03c8) := \nby split; {intro, simpa}\n\ntheorem sat_of_sat_erase (h\u2081 : sat k s $ \u0394.erase \u03c6) (h\u2082 : force k s \u03c6) : sat k s \u0394 := \nbegin\n  intro \u03c8, intro h,\n  by_cases (\u03c8 = \u03c6),\n  {rw h, assumption},\n  {have : \u03c8 \u2208 \u0394.erase \u03c6,\n   rw mem_erase_of_ne, assumption, exact h,\n   apply h\u2081, assumption}\nend\n\ntheorem unsat_and_of_unsat_split \n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : unsatisfiable $ \u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)) : \n        unsatisfiable \u0394 :=\nbegin\n  intro st, intros, intro h,\n  apply h\u2082, swap 3, exact k, swap, exact s,\n  intro e, intro he,\n  cases he,\n  {rw he, have := h _ h\u2081, rw sat_of_and at this, exact this.1},\n  {cases he, \n    {rw he, have := h _ h\u2081, rw sat_of_and at this, exact this.2}, \n    {have := h _ h\u2081, apply h, apply mem_of_mem_erase he} }\nend\n\ntheorem unsat_and_of_unsat_split_seqt {\u0393}\n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : unsatisfiable $ (\u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)++\u0393)) : \n        unsatisfiable (\u0394++\u0393) :=\nbegin\n  intro st, intros, intro h,\n  apply h\u2082, swap 3, exact k, swap, exact s,\n  intro e, intro he,\n  cases he,\n  {rw he, have := h _ (mem_append_left _ h\u2081), rw sat_of_and at this, exact this.1},\n  {cases he, \n    {rw he, have := h _ (mem_append_left _ h\u2081), rw sat_of_and at this, exact this.2},\n    {have := h _ (mem_append_left _ h\u2081), apply h, apply mem_of_mem_erase, rw erase_append_left, exact he, exact h\u2081} }\nend\n\ntheorem sat_and_of_sat_split\n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : sat k s $ \u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)) : \n        sat k s \u0394 := \nbegin\n  intro e, intro he,\n  by_cases (e = and \u03c6 \u03c8),\n  { rw h, dsimp, split, repeat {apply h\u2082, simp} },\n  { have : e \u2208 \u0394.erase (and \u03c6 \u03c8),\n      { rw mem_erase_of_ne, repeat { assumption } },\n    apply h\u2082, simp [this] }\nend\n\ntheorem sat_and_of_sat_split_seqt {\u0393}\n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : sat k s $ (\u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)++\u0393)) : \n        sat k s (\u0394++\u0393) := \nbegin\n  intro e, intro he,\n  by_cases (e = and \u03c6 \u03c8),\n  { rw h, dsimp, split, repeat {apply h\u2082, simp} },\n  { have : e \u2208 \u0394.erase (and \u03c6 \u03c8) ++ \u0393,\n      { rw \u2190erase_append_left, rw mem_erase_of_ne, repeat {assumption} },\n    apply h\u2082, simp [this] }\nend\n\ntheorem sat_split_of_sat_and_seqt {\u0393}\n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : sat k s (\u0394++\u0393)) : \n        sat k s $ (\u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)++\u0393) := \nbegin\n  intros e he, rw mem_append at he, cases he,\n  have : force k s (and \u03c6 \u03c8), {apply h\u2082, simp [h\u2081]}, 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\u2082, rw mem_append, left, apply mem_of_mem_erase he}\n  },\n  {apply h\u2082, rw mem_append, right, exact he}\nend\n\ntheorem unsat_or_of_unsat_split_seqt {\u0393}\n        (h : or \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2081 : unsatisfiable $ (\u03c6 :: \u0394.erase (nnf.or \u03c6 \u03c8)++\u0393)) \n        (h\u2082 : unsatisfiable $ (\u03c8 :: \u0394.erase (nnf.or \u03c6 \u03c8)++\u0393)) : \n        unsatisfiable $ (\u0394++\u0393) := \nbegin\n  intro, intros, intro hsat,\n  have := hsat _ (mem_append_left _ h),\n  dsimp at this,\n  cases this,\n  {apply h\u2081, 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\u2082, 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 \u03c6 \u03c8 \u2208 \u0394) \n        (hl : sat k s $ \u03c6 :: \u0394.erase (nnf.or \u03c6 \u03c8)) :\n        sat k s \u0394 := \nbegin\n  intros e he,\n  by_cases (e = or \u03c6 \u03c8),\n  { rw h, dsimp, left, apply hl, simp},\n  {have : e \u2208 \u0394.erase (or \u03c6 \u03c8),\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 \u03c6 \u03c8 \u2208 \u0394) \n        (hl : sat k s $ \u03c8 :: \u0394.erase (nnf.or \u03c6 \u03c8)) :\n        sat k s \u0394 := \nbegin\n  intros e he,\n  by_cases (e = or \u03c6 \u03c8),\n  { rw h, dsimp, right, apply hl, simp},\n  { have : e \u2208 \u0394.erase (or \u03c6 \u03c8),\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 \u03c6) : force k s \u03c6 \n:= by apply h; apply k.refl\n\ntheorem force_box_box_of_force_box : force k s (box \u03c6) \u2192 force k s (box (box \u03c6)) :=\nby intros h s\u2081 rs\u2081 s\u2082 rs\u2082; apply h; apply k.trans rs\u2081 rs\u2082\n\ntheorem unsat_of_unsat_box_new\n        (h\u2081 : box \u03c6 \u2208 \u0394) \n        (h\u2082 : unsatisfiable $ (\u03c6 :: \u0394.erase (box \u03c6)) ++ box \u03c6 :: \u039b) : \n        unsatisfiable (\u0394 ++ \u039b) :=\nbegin\n  intros st k s h,\n  apply h\u2082, 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 \u03c6), simp [h\u2081]},\n    {apply h, rw mem_append, left, apply mem_of_mem_erase he }},\n  {cases he, \n    {rw \u2190he at h\u2081, apply h, rw mem_append, left, exact h\u2081},\n    {apply h, rw mem_append, right, assumption}}\nend\n\ntheorem sat_copy_of_sat_box_new\n        (h\u2081 : box \u03c6 \u2208 \u0394) \n        (h\u2082 : sat k s $ (\u03c6 :: \u0394.erase (box \u03c6)) ++ box \u03c6 :: \u039b) : \n        sat k s (\u0394 ++ \u039b) :=\nbegin\n  intros \u03c8 h\u03c6,\n  rw mem_append at h\u03c6,\n  cases h\u03c6,\n  {by_cases heq : \u03c8 = box \u03c6, \n    {rw heq, apply h\u2082 (box \u03c6), simp}, \n    {have := mem_erase_of_ne heq, rw \u2190this at h\u03c6, apply h\u2082, simp, right, left, exact h\u03c6}},\n  {apply h\u2082, simp, repeat {right}, exact h\u03c6}\nend\n\ntheorem unsat_of_unsat_box_dup\n        (h\u2081 : box \u03c6 \u2208 \u0394)\n        (h\u2083 : unsatisfiable $ (\u03c6 :: \u0394.erase (box \u03c6)) ++ \u039b) : \n        unsatisfiable (\u0394 ++ \u039b) :=\nbegin\n  intros st k s h,\n  apply h\u2083, 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 \u03c6), simp [h\u2081]},\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 (\u0393 : sseqt) : list sseqt :=\n@list.pmap _ _ (\u03bb \u03c6, \u03c6 \u2209 \u0393.h \u2227 dia \u03c6 \u2208 \u0393.m)\n(\u03bb d h,\n({s := some {d := d, b := \u0393.b},\na := {d := d, b := \u0393.b} :: \u0393.a,\nh := d :: \u0393.h,\nm := d :: \u0393.b,\nndh := begin rw list.nodup_cons, split, exact h.1, exact \u0393.ndh end,\nsph := begin apply list.cons_subperm_of_mem, apply \u0393.ndh, exact h.1, apply mem_closure_dia, apply \u0393.sbm, exact h.2,  exact \u0393.sph end,\nsbm := begin rw list.cons_subset, split, apply mem_closure_dia, apply \u0393.sbm, exact h.2, apply list.subperm.subset, exact \u0393.spb end,\nha  := begin intros \u03c6 h, cases h with l r, rw l, simp, right, apply \u0393.ha, exact r end,\nps\u2081 := begin simp [dsig] end,\nps\u2082 := begin simp [bsig] end,\n.. \u0393} : sseqt))\n(filter_undia \u0393.h \u0393.m)\n(begin\nintros \u03c6 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 (\u0393 : sseqt) : \u2200 (i : sseqt),  i \u2208 unmodal_seqt \u0393 \u2192 (prod.measure_lex' sseqt_size i \u0393) := \nlist.pmapp _ _ \nbegin \nintros \u03c6 h hmem,\nright, left,\napply length_sub_lt_of_nodup_subperm,\n{apply \u0393.sph},\n{apply mem_closure_dia, apply \u0393.sbm, exact h.2},\n{exact h.1},\n{exact \u0393.ndh}\nend \n_\n\ndef sat_unmodal_of_sat {\u0393 : sseqt} : \u2200 (i : sseqt),  i \u2208 unmodal_seqt \u0393 \u2192 \n(\u2200 {st : Type} (k : S4 st) s, \nsat k s (\u0393.m ++ \u0393.b) \u2192 \u2203 s', sat k s' (i.m ++ i.b)) :=\nlist.pmapp _ _\nbegin\nintros \u03c6 hninh hmem st k s h,\nhave hd : force k s (dia \u03c6), \n  { apply h, rw mem_append, left, exact hninh.2 }, \nhave hb : \u2200 \u03c6 \u2208 \u0393.b, force k s (box \u03c6), \n  { intros \u03b3 h\u03b3, \n    have := box_only_ex \u0393.hb h\u03b3, cases this with w hw,\n    rw hw, apply force_box_box_of_force_box,\n    have := h _ (mem_append_right _ h\u03b3), rw hw at this, exact this},\nrcases hd with \u27e8w, hrw, hfw\u27e9,\nsplit, swap, exact w,\nintros \u03c8 h\u03c8, simp at h\u03c8, cases h\u03c8,\n{rw h\u03c8, exact hfw},\n{apply hb, exact h\u03c8, exact hrw}\nend\n_\n\ndef unsat_of_unsat_unmodal {\u0393 : sseqt} (i : sseqt) : i \u2208 unmodal_seqt \u0393 \u2227 unsatisfiable (i.m ++ i.b) \u2192 unsatisfiable (\u0393.m ++ \u0393.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 (\u0393 : sseqt) : \u2200 (i : sseqt),  i \u2208 unmodal_seqt \u0393 \u2192 (\u2200 \u03c6, box \u03c6 \u2208 \u0393.b \u2192 box \u03c6 \u2208 i.m) := \nlist.pmapp _ _ begin intros \u03c6 h hmem \u03c8 h\u03c8, right, exact h\u03c8 end _\n\ndef mem_unmodal_seqt (\u0393 : sseqt) (\u03c6) (h : \u03c6 \u2209 \u0393.h \u2227 dia \u03c6 \u2208 \u0393.m) : \u2203 (i : sseqt), i \u2208 unmodal_seqt \u0393 \u2227 \u03c6 \u2208 i.m := \nbegin\nsplit, swap,\n{exact \n({s := some {d := \u03c6, b := \u0393.b},\na := {d := \u03c6, b := \u0393.b} :: \u0393.a,\nh := \u03c6 :: \u0393.h,\nm := \u03c6 :: \u0393.b,\nndh := begin rw list.nodup_cons, split, exact h.1, exact \u0393.ndh end,\nsph := begin apply list.cons_subperm_of_mem, apply \u0393.ndh, exact h.1, apply mem_closure_dia, apply \u0393.sbm, exact h.2,  exact \u0393.sph end,\nsbm := begin rw list.cons_subset, split, apply mem_closure_dia, apply \u0393.sbm, exact h.2, apply list.subperm.subset, exact \u0393.spb end,\nha  := begin intros \u03c6 h, cases h with l r, rw l, simp, right, apply \u0393.ha, exact r end,\nps\u2081 := begin intro, simp [dsig] end,\nps\u2082 := begin intro, simp [bsig] end,\n.. \u0393} : sseqt)},\n{ dsimp [unmodal_seqt], split,\n  {let mf := (\u03bb (d : nnf) (h : d \u2209 \u0393.h \u2227 dia d \u2208 \u0393.m),\n      ({s := some {d := d, b := \u0393.b},\n       a := {d := d, b := \u0393.b} :: \u0393.a,\n       h := d :: \u0393.h,\n       m := d :: \u0393.b,\n       ndh := begin rw list.nodup_cons, split, exact h.1, exact \u0393.ndh end,\n       sph := begin apply list.cons_subperm_of_mem, apply \u0393.ndh, exact h.1, apply mem_closure_dia, apply \u0393.sbm, exact h.2,  exact \u0393.sph end,\n       sbm := begin rw list.cons_subset, split, apply mem_closure_dia, apply \u0393.sbm, exact h.2, apply list.subperm.subset, exact \u0393.spb end,\n       ha  := begin intros \u03c6 h, cases h with l r, rw l, simp, right, apply \u0393.ha, exact r end,\n       ps\u2081 := begin simp [dsig] end,\n       ps\u2082 := begin simp [bsig] end,\n       .. \u0393} :sseqt)),\n  have hmem := mem_filter_undia_left _ _ _ h.2 h.1,\n  have hf : \u2200 (y : nnf), y \u2208 filter_undia (\u0393.h) (\u0393.m) \u2192 y \u2209 \u0393.h \u2227 dia y \u2208 \u0393.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 (\u0393 : sseqt) : \u2200 (i : sseqt),  i \u2208 unmodal_seqt \u0393 \u2192 (\u2200 a, a \u2208 i.a \u2192 some a = i.s \u2228 a \u2208 \u0393.a) := \nlist.pmapp _ _ \nbegin \nintros \u03c6 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 {\u0393 \u0394} (i : and_instance \u0393 \u0394) (h : unsatisfiable \u0394) : unsatisfiable \u0393 := \nby cases i; { apply unsat_and_of_unsat_split, repeat {assumption} }\n\ntheorem unsat_of_closed_and_seqt {\u0393 \u0394} (i : and_instance_seqt \u0393 \u0394) (h : unsatisfiable (\u0394.m++\u0394.b)) : unsatisfiable (\u0393.m++\u0393.b) := \nby cases i; {apply unsat_and_of_unsat_split_seqt, repeat {assumption} }\n\ntheorem unsat_of_closed_or_seqt {\u0393\u2081 \u0393\u2082 \u0394 : sseqt} (i : or_instance_seqt \u0394 \u0393\u2081 \u0393\u2082) \n(h\u2081 : unsatisfiable (\u0393\u2081.m++\u0393\u2081.b)) \n(h\u2082 : unsatisfiable (\u0393\u2082.m++\u0393\u2082.b)) : \nunsatisfiable (\u0394.m++\u0394.b) :=\nby cases i; {apply unsat_or_of_unsat_split_seqt, repeat { assumption }}\n\ntheorem unsat_of_closed_box_new {\u0393 \u0394} (i : box_new_instance_seqt \u0393 \u0394) (h : unsatisfiable $ (\u0394.m++\u0394.b)) : unsatisfiable (\u0393.m++\u0393.b) := \nby cases i; { apply unsat_of_unsat_box_new, repeat { assumption } }\n\ntheorem unsat_of_closed_box_dup {\u0393 \u0394} (i : box_dup_instance_seqt \u0393 \u0394) (h : unsatisfiable $ (\u0394.m++\u0394.b)) : unsatisfiable (\u0393.m++\u0393.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\u2082 \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 \u2192 walking_cospan \u2192 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 \u27f6 one := wide_pullback_shape.hom.term walking_pair.left\n\n/-- The identity arrows of the walking cospan. -/\ndef hom.inr : right \u27f6 one := wide_pullback_shape.hom.term walking_pair.right\n\ndef hom.id (X : walking_cospan) : X \u27f6 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 \u27f6 Y) :=\n  subsingleton.intro\n    fun (a b : X \u27f6 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 \u2192 walking_span \u2192 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 \u27f6 left := wide_pushout_shape.hom.init walking_pair.left\n\n/-- The identity arrows of the walking span. -/\ndef hom.snd : zero \u27f6 right := wide_pushout_shape.hom.init walking_pair.right\n\ndef hom.id (X : walking_span) : X \u27f6 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 \u27f6 Y) :=\n  subsingleton.intro\n    fun (a b : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z) :\n    walking_cospan \u2964 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 \u27f6 Y) (g : X \u27f6 Z) :\n    walking_span \u2964 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 \u27f6 Z)\n    (g : Y \u27f6 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 \u27f6 Y)\n    (g : X \u27f6 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 \u27f6 Z)\n    (g : Y \u27f6 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 \u27f6 Y)\n    (g : X \u27f6 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 \u27f6 Z)\n    (g : Y \u27f6 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 \u27f6 Y)\n    (g : X \u27f6 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 \u27f6 Z)\n    (g : Y \u27f6 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 \u27f6 Y)\n    (g : X \u27f6 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 \u27f6 Z)\n    (g : Y \u27f6 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 \u27f6 Y)\n    (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z)\n    (w : walking_cospan) : functor.map (cospan f g) (walking_cospan.hom.id w) = \ud835\udfd9 :=\n  rfl\n\ntheorem span_map_id {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z)\n    (w : walking_span) : functor.map (span f g) (walking_span.hom.id w) = \ud835\udfd9 :=\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 \u2964 C) :\n    F \u2245 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 \u2964 C) :\n    F \u2245 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 \u27f6 Z` and\n    `g : Y \u27f6 Z`.-/\ndef pullback_cone {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Z) (g : Y \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z}\n    (t : pullback_cone f g) : cone.X t \u27f6 X :=\n  nat_trans.app (cone.\u03c0 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 \u27f6 Z} {g : Y \u27f6 Z}\n    (t : pullback_cone f g) : cone.X t \u27f6 Y :=\n  nat_trans.app (cone.\u03c0 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 \u27f6 Z} {g : Y \u27f6 Z}\n    (t : pullback_cone f g) (lift : (s : cone (cospan f g)) \u2192 cone.X s \u27f6 cone.X t)\n    (fac_left : \u2200 (s : pullback_cone f g), lift s \u226b fst t = fst s)\n    (fac_right : \u2200 (s : pullback_cone f g), lift s \u226b snd t = snd s)\n    (uniq :\n      \u2200 (s : pullback_cone f g) (m : cone.X s \u27f6 cone.X t),\n        (\u2200 (j : walking_cospan), m \u226b nat_trans.app (cone.\u03c0 t) j = nat_trans.app (cone.\u03c0 s) j) \u2192\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 \u27f6 Z} {g : Y \u27f6 Z}\n    (t : pullback_cone f g)\n    (create :\n      (s : pullback_cone f g) \u2192\n        Subtype\n          fun (l : cone.X s \u27f6 cone.X t) =>\n            l \u226b fst t = fst s \u2227\n              l \u226b snd t = snd s \u2227\n                \u2200 {m : cone.X s \u27f6 cone.X t}, m \u226b fst t = fst s \u2192 m \u226b snd t = snd s \u2192 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 \u27f6 X` and `snd : W \u27f6 Y`\n    such that `fst \u226b f = snd \u226b g`. -/\n@[simp] theorem mk_\u03c0_app {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}\n    {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) (j : walking_cospan) :\n    nat_trans.app (cone.\u03c0 (mk fst snd eq)) j =\n        option.cases_on j (fst \u226b f) fun (j' : walking_pair) => walking_pair.cases_on j' fst snd :=\n  Eq.refl (nat_trans.app (cone.\u03c0 (mk fst snd eq)) j)\n\n@[simp] theorem mk_\u03c0_app_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z}\n    {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n    nat_trans.app (cone.\u03c0 (mk fst snd eq)) walking_cospan.left = fst :=\n  rfl\n\n@[simp] theorem mk_\u03c0_app_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z}\n    {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n    nat_trans.app (cone.\u03c0 (mk fst snd eq)) walking_cospan.right = snd :=\n  rfl\n\n@[simp] theorem mk_\u03c0_app_one {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z}\n    {g : Y \u27f6 Z} {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n    nat_trans.app (cone.\u03c0 (mk fst snd eq)) walking_cospan.one = fst \u226b f :=\n  rfl\n\n@[simp] theorem mk_fst {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}\n    {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b 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 \u27f6 Z} {g : Y \u27f6 Z}\n    {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b 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 \u27f6 Z} {g : Y \u27f6 Z}\n    (t : pullback_cone f g) {X' : C} (f' : Z \u27f6 X') : fst t \u226b f \u226b f' = snd t \u226b g \u226b 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 \u27f6 Z} {g : Y \u27f6 Z}\n    (t : pullback_cone f g) {W : C} {k : W \u27f6 cone.X t} {l : W \u27f6 cone.X t}\n    (h\u2080 : k \u226b fst t = l \u226b fst t) (h\u2081 : k \u226b snd t = l \u226b snd t) (j : walking_cospan) :\n    k \u226b nat_trans.app (cone.\u03c0 t) j = l \u226b nat_trans.app (cone.\u03c0 t) j :=\n  sorry\n\ntheorem is_limit.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}\n    {t : pullback_cone f g} (ht : is_limit t) {W : C} {k : W \u27f6 cone.X t} {l : W \u27f6 cone.X t}\n    (h\u2080 : k \u226b fst t = l \u226b fst t) (h\u2081 : k \u226b snd t = l \u226b snd t) : k = l :=\n  is_limit.hom_ext ht (equalizer_ext t h\u2080 h\u2081)\n\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W \u27f6 X` and `k : W \u27f6 Y` are such that\n    `h \u226b f = k \u226b g`, then we have `l : W \u27f6 t.X` satisfying `l \u226b fst t = h` and `l \u226b snd t = k`.\n    -/\ndef is_limit.lift' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}\n    {t : pullback_cone f g} (ht : is_limit t) {W : C} (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) :\n    Subtype fun (l : W \u27f6 cone.X t) => l \u226b fst t = h \u2227 l \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} {W : C}\n    {fst : W \u27f6 X} {snd : W \u27f6 Y} (eq : fst \u226b f = snd \u226b g)\n    (lift : (s : pullback_cone f g) \u2192 cone.X s \u27f6 W)\n    (fac_left : \u2200 (s : pullback_cone f g), lift s \u226b fst = fst s)\n    (fac_right : \u2200 (s : pullback_cone f g), lift s \u226b snd = snd s)\n    (uniq :\n      \u2200 (s : pullback_cone f g) (m : cone.X s \u27f6 W),\n        m \u226b fst = fst s \u2192 m \u226b snd = snd s \u2192 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 \u27f6 Z} {g : Y \u27f6 Z} {W : C}\n    {h : W \u27f6 X} {k : W \u27f6 Y} {comm : h \u226b f = k \u226b 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 `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y) [mono f] :\n    is_limit (mk \ud835\udfd9 \ud835\udfd9 (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 `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y)\n    (t : is_limit (mk \ud835\udfd9 \ud835\udfd9 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 \u27f6 Y` and\n    `g : X \u27f6 Z`.-/\ndef pushout_cocone {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : X \u27f6 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 \u27f6 Y} {g : X \u27f6 Z}\n    (t : pushout_cocone f g) : Y \u27f6 cocone.X t :=\n  nat_trans.app (cocone.\u03b9 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 \u27f6 Y} {g : X \u27f6 Z}\n    (t : pushout_cocone f g) : Z \u27f6 cocone.X t :=\n  nat_trans.app (cocone.\u03b9 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 \u27f6 Y} {g : X \u27f6 Z}\n    (t : pushout_cocone f g) (desc : (s : pushout_cocone f g) \u2192 cocone.X t \u27f6 cocone.X s)\n    (fac_left : \u2200 (s : pushout_cocone f g), inl t \u226b desc s = inl s)\n    (fac_right : \u2200 (s : pushout_cocone f g), inr t \u226b desc s = inr s)\n    (uniq :\n      \u2200 (s : pushout_cocone f g) (m : cocone.X t \u27f6 cocone.X s),\n        (\u2200 (j : walking_span), nat_trans.app (cocone.\u03b9 t) j \u226b m = nat_trans.app (cocone.\u03b9 s) j) \u2192\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 \u27f6 Y} {g : X \u27f6 Z}\n    (t : pushout_cocone f g)\n    (create :\n      (s : pushout_cocone f g) \u2192\n        Subtype\n          fun (l : cocone.X t \u27f6 cocone.X s) =>\n            inl t \u226b l = inl s \u2227\n              inr t \u226b l = inr s \u2227\n                \u2200 {m : cocone.X t \u27f6 cocone.X s}, inl t \u226b m = inl s \u2192 inr t \u226b m = inr s \u2192 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 \u27f6 W` and `inr : Z \u27f6 W` such\n    that `f \u226b inl = g \u21a0 inr`. -/\ndef mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {W : C}\n    (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) : pushout_cocone f g :=\n  cocone.mk W\n    (nat_trans.mk\n      fun (j : walking_span) =>\n        option.cases_on j (f \u226b inl) fun (j' : walking_pair) => walking_pair.cases_on j' inl inr)\n\n@[simp] theorem mk_\u03b9_app_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y}\n    {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n    nat_trans.app (cocone.\u03b9 (mk inl inr eq)) walking_span.left = inl :=\n  rfl\n\n@[simp] theorem mk_\u03b9_app_right {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y}\n    {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n    nat_trans.app (cocone.\u03b9 (mk inl inr eq)) walking_span.right = inr :=\n  rfl\n\n@[simp] theorem mk_\u03b9_app_zero {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y}\n    {g : X \u27f6 Z} {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n    nat_trans.app (cocone.\u03b9 (mk inl inr eq)) walking_span.zero = f \u226b inl :=\n  rfl\n\n@[simp] theorem mk_inl {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z}\n    {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b 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 \u27f6 Y} {g : X \u27f6 Z}\n    {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b 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 \u27f6 Y} {g : X \u27f6 Z}\n    (t : pushout_cocone f g) {X' : C} (f' : cocone.X t \u27f6 X') : f \u226b inl t \u226b f' = g \u226b inr t \u226b 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 \u27f6 Y} {g : X \u27f6 Z}\n    (t : pushout_cocone f g) {W : C} {k : cocone.X t \u27f6 W} {l : cocone.X t \u27f6 W}\n    (h\u2080 : inl t \u226b k = inl t \u226b l) (h\u2081 : inr t \u226b k = inr t \u226b l) (j : walking_span) :\n    nat_trans.app (cocone.\u03b9 t) j \u226b k = nat_trans.app (cocone.\u03b9 t) j \u226b l :=\n  sorry\n\ntheorem is_colimit.hom_ext {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z}\n    {t : pushout_cocone f g} (ht : is_colimit t) {W : C} {k : cocone.X t \u27f6 W} {l : cocone.X t \u27f6 W}\n    (h\u2080 : inl t \u226b k = inl t \u226b l) (h\u2081 : inr t \u226b k = inr t \u226b l) : k = l :=\n  is_colimit.hom_ext ht (coequalizer_ext t h\u2080 h\u2081)\n\n/-- If `t` is a colimit pushout cocone over `f` and `g` and `h : Y \u27f6 W` and `k : Z \u27f6 W` are\n    morphisms satisfying `f \u226b h = g \u226b k`, then we have a factorization `l : t.X \u27f6 W` such that\n    `inl t \u226b l = h` and `inr t \u226b l = k`. -/\ndef is_colimit.desc' {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z}\n    {t : pushout_cocone f g} (ht : is_colimit t) {W : C} (h : Y \u27f6 W) (k : Z \u27f6 W)\n    (w : f \u226b h = g \u226b k) : Subtype fun (l : cocone.X t \u27f6 W) => inl t \u226b l = h \u2227 inr t \u226b 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 \u27f6 Y} {g : X \u27f6 Z} {W : C}\n    {inl : Y \u27f6 W} {inr : Z \u27f6 W} (eq : f \u226b inl = g \u226b inr)\n    (desc : (s : pushout_cocone f g) \u2192 W \u27f6 cocone.X s)\n    (fac_left : \u2200 (s : pushout_cocone f g), inl \u226b desc s = inl s)\n    (fac_right : \u2200 (s : pushout_cocone f g), inr \u226b desc s = inr s)\n    (uniq :\n      \u2200 (s : pushout_cocone f g) (m : W \u27f6 cocone.X s),\n        inl \u226b m = inl s \u2192 inr \u226b m = inr s \u2192 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 \u27f6 Y} {g : X \u27f6 Z}\n    {W : C} {h : Y \u27f6 W} {k : Z \u27f6 W} {comm : f \u226b h = g \u226b 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 \u2964 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_\u03c0 {C : Type u} [category C] {F : walking_cospan \u2964 C}\n    (t :\n      pullback_cone (functor.map F walking_cospan.hom.inl) (functor.map F walking_cospan.hom.inr)) :\n    cone.\u03c0 (cone.of_pullback_cone t) = cone.\u03c0 t \u226b iso.inv (diagram_iso_cospan F) :=\n  Eq.refl (cone.\u03c0 (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 \u2964 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 \u2964 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 \u2964 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 \u2964 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 \u2964 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 \u2964 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) \u226b cocone.\u03b9 t)\n\n/--\n`has_pullback f g` represents a particular choice of limiting cone\nfor the pair of morphisms `f : X \u27f6 Z` and `g : Y \u27f6 Z`.\n-/\n/--\ndef has_pullback {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y` and `g : X \u27f6 Z`.\n-/\ndef has_pushout {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z}\n    [has_pullback f g] : pullback f g \u27f6 X :=\n  limit.\u03c0 (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 \u27f6 Z} {g : Y \u27f6 Z}\n    [has_pullback f g] : pullback f g \u27f6 Y :=\n  limit.\u03c0 (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 \u27f6 Y} {g : X \u27f6 Z}\n    [has_pushout f g] : Y \u27f6 pushout f g :=\n  colimit.\u03b9 (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 \u27f6 Y} {g : X \u27f6 Z}\n    [has_pushout f g] : Z \u27f6 pushout f g :=\n  colimit.\u03b9 (span f g) walking_span.right\n\n/-- A pair of morphisms `h : W \u27f6 X` and `k : W \u27f6 Y` satisfying `h \u226b f = k \u226b g` induces a morphism\n    `pullback.lift : W \u27f6 pullback f g`. -/\ndef pullback.lift {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}\n    [has_pullback f g] (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : W \u27f6 pullback f g :=\n  limit.lift (cospan f g) (pullback_cone.mk h k w)\n\n/-- A pair of morphisms `h : Y \u27f6 W` and `k : Z \u27f6 W` satisfying `f \u226b h = g \u226b k` induces a morphism\n    `pushout.desc : pushout f g \u27f6 W`. -/\ndef pushout.desc {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z}\n    [has_pushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : pushout f g \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) {X' : C}\n    (f' : X \u27f6 X') : pullback.lift h k w \u226b pullback.fst \u226b f' = h \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) {X' : C}\n    (f' : Y \u27f6 X') : pullback.lift h k w \u226b pullback.snd \u226b f' = k \u226b 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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) {X' : C}\n    (f' : W \u27f6 X') : pushout.inl \u226b pushout.desc h k w \u226b f' = h \u226b 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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) {X' : C}\n    (f' : W \u27f6 X') : pushout.inr \u226b pushout.desc h k w \u226b f' = k \u226b f' :=\n  sorry\n\n/-- A pair of morphisms `h : W \u27f6 X` and `k : W \u27f6 Y` satisfying `h \u226b f = k \u226b g` induces a morphism\n    `l : W \u27f6 pullback f g` such that `l \u226b pullback.fst = h` and `l \u226b pullback.snd = k`. -/\ndef pullback.lift' {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}\n    [has_pullback f g] (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) :\n    Subtype fun (l : W \u27f6 pullback f g) => l \u226b pullback.fst = h \u2227 l \u226b pullback.snd = k :=\n  { val := pullback.lift h k w, property := sorry }\n\n/-- A pair of morphisms `h : Y \u27f6 W` and `k : Z \u27f6 W` satisfying `f \u226b h = g \u226b k` induces a morphism\n    `l : pushout f g \u27f6 W` such that `pushout.inl \u226b l = h` and `pushout.inr \u226b l = k`. -/\ndef pullback.desc' {C : Type u} [category C] {W : C} {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z}\n    [has_pushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) :\n    Subtype fun (l : pushout f g \u27f6 W) => pushout.inl \u226b l = h \u2227 pushout.inr \u226b 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 \u27f6 Z} {g : Y \u27f6 Z}\n    [has_pullback f g] : pullback.fst \u226b f = pullback.snd \u226b 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 \u27f6 Y}\n    {g : X \u27f6 Z} [has_pushout f g] {X' : C} (f' : pushout f g \u27f6 X') :\n    f \u226b pushout.inl \u226b f' = g \u226b pushout.inr \u226b 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 \u27f6 Z} {g : Y \u27f6 Z}\n    [has_pullback f g] {W : C} {k : W \u27f6 pullback f g} {l : W \u27f6 pullback f g}\n    (h\u2080 : k \u226b pullback.fst = l \u226b pullback.fst) (h\u2081 : k \u226b pullback.snd = l \u226b pullback.snd) : k = l :=\n  limit.hom_ext (pullback_cone.equalizer_ext (limit.cone (cospan f g)) h\u2080 h\u2081)\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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Z} {g : Y \u27f6 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 \u27f6 Z} {g : Y \u27f6 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 \u27f6 Y} {g : X \u27f6 Z}\n    [has_pushout f g] {W : C} {k : pushout f g \u27f6 W} {l : pushout f g \u27f6 W}\n    (h\u2080 : pushout.inl \u226b k = pushout.inl \u226b l) (h\u2081 : pushout.inr \u226b k = pushout.inr \u226b l) : k = l :=\n  colimit.hom_ext (pushout_cocone.coequalizer_ext (colimit.cocone (span f g)) h\u2080 h\u2081)\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 \u27f6 Y}\n    {g : X \u27f6 Z} [has_pushout f g] [epi g] : epi pushout.inl :=\n  epi.mk\n    fun (W : C) (u v : pushout f g \u27f6 W) (h : pushout.inl \u226b u = pushout.inl \u226b 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 \u27f6 W) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : X \u27f6 W) (e_2 : \u1fb0 = \u1fb0_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (g \u226b pushout.inr \u226b u) (f \u226b pushout.inl \u226b v)\n                  (Eq.trans (Eq.symm (pushout.condition_assoc u))\n                    ((fun (\u1fb0 \u1fb0_1 : X \u27f6 Y) (e_1 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : Y \u27f6 W) (e_2 : \u1fb0_2 = \u1fb0_3) =>\n                        congr (congr_arg category_struct.comp e_1) e_2)\n                      f f (Eq.refl f) (pushout.inl \u226b u) (pushout.inl \u226b v) h))\n                  (g \u226b pushout.inr \u226b v) (f \u226b pushout.inl \u226b v) (Eq.symm (pushout.condition_assoc v)))\n                (propext (eq_self_iff_true (f \u226b pushout.inl \u226b 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 \u27f6 Y}\n    {g : X \u27f6 Z} [has_pushout f g] [epi f] : epi pushout.inr :=\n  epi.mk\n    fun (W : C) (u v : pushout f g \u27f6 W) (h : pushout.inr \u226b u = pushout.inr \u226b 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 \u27f6 W) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : X \u27f6 W) (e_2 : \u1fb0 = \u1fb0_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (f \u226b pushout.inl \u226b u) (g \u226b pushout.inr \u226b v)\n                  (Eq.trans (pushout.condition_assoc u)\n                    ((fun (\u1fb0 \u1fb0_1 : X \u27f6 Z) (e_1 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : Z \u27f6 W) (e_2 : \u1fb0_2 = \u1fb0_3) =>\n                        congr (congr_arg category_struct.comp e_1) e_2)\n                      g g (Eq.refl g) (pushout.inr \u226b u) (pushout.inr \u226b v) h))\n                  (f \u226b pushout.inl \u226b v) (g \u226b pushout.inr \u226b v) (pushout.condition_assoc v))\n                (propext (eq_self_iff_true (g \u226b pushout.inr \u226b 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\u2082} [category D]\n    (G : C \u2964 D) (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g]\n    [has_pullback (functor.map G f) (functor.map G g)] :\n    functor.obj G (pullback f g) \u27f6 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\u2082} [category D] (G : C \u2964 D) (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g]\n    [has_pullback (functor.map G f) (functor.map G g)] {X' : D} (f' : functor.obj G X \u27f6 X') :\n    pullback_comparison G f g \u226b pullback.fst \u226b f' = functor.map G pullback.fst \u226b 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\u2082} [category D] (G : C \u2964 D) (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g]\n    [has_pullback (functor.map G f) (functor.map G g)] {X' : D} (f' : functor.obj G Y \u27f6 X') :\n    pullback_comparison G f g \u226b pullback.snd \u226b f' = functor.map G pullback.snd \u226b 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\u2082} [category D] (G : C \u2964 D) (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g]\n    [has_pullback (functor.map G f) (functor.map G g)] {W : C} {h : W \u27f6 X} {k : W \u27f6 Y}\n    (w : h \u226b f = k \u226b g) {X' : D} (f' : pullback (functor.map G f) (functor.map G g) \u27f6 X') :\n    functor.map G (pullback.lift h k w) \u226b pullback_comparison G f g \u226b 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 \u27f6 functor.obj G Z) (e_1 : a = a_1)\n                    (\u1fb0 \u1fb0_1 : functor.obj G W \u27f6 functor.obj G Z) (e_2 : \u1fb0 = \u1fb0_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (functor.map G h \u226b functor.map G f) (functor.map G (k \u226b g))\n                  (Eq.trans (Eq.symm (functor.map_comp G h f))\n                    ((fun (c : C \u2964 D) {X Y : C} (\u1fb0 \u1fb0_1 : X \u27f6 Y) (e_4 : \u1fb0 = \u1fb0_1) =>\n                        congr_arg (functor.map c) e_4)\n                      G (h \u226b f) (k \u226b g) w))\n                  (functor.map G k \u226b functor.map G g) (functor.map G (k \u226b g))\n                  (Eq.symm (functor.map_comp G k g))))\n              (Eq.refl (functor.map G (k \u226b g)))) \u226b\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    [\u2200 {X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}, has_limit (cospan f g)] : has_pullbacks C :=\n  has_limits_of_shape.mk\n    fun (F : walking_cospan \u2964 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    [\u2200 {X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z}, has_colimit (span f g)] : has_pushouts C :=\n  has_colimits_of_shape.mk fun (F : walking_span \u2964 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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  \u27e8fun X => X.toLat\u27e9\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 (\u03b1 : Type _) [Lattice \u03b1] [BoundedOrder \u03b1] : BddLat :=\n  \u27e8\u27e8\u03b1\u27e9\u27e9\n#align BddLat.of BddLat.of\n\n@[simp]\ntheorem coe_of (\u03b1 : Type _) [Lattice \u03b1] [BoundedOrder \u03b1] : \u21a5(of \u03b1) = \u03b1 :=\n  rfl\n#align BddLat.coe_of BddLat.coe_of\n\ninstance : Inhabited BddLat :=\n  \u27e8of PUnit\u27e9\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 := \u27e8coeSort, fun X Y => coeFn, fun X => rfl, fun X Y Z f g => rfl\u27e9\n  forget_faithful := \u27e8fun X Y => by convert FunLike.coe_injective\u27e9\n\ninstance hasForgetToBddOrd : HasForget\u2082 BddLat BddOrd\n    where forget\u2082 :=\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\u2082 BddLat Lat\n    where forget\u2082 :=\n    { obj := fun X => \u27e8X\u27e9\n      map := fun X Y => BoundedLatticeHom.toLatticeHom }\n#align BddLat.has_forget_to_Lat BddLat.hasForgetToLat\n\ninstance hasForgetToSemilatSup : HasForget\u2082 BddLat SemilatSup\n    where forget\u2082 :=\n    { obj := fun X => \u27e8X\u27e9\n      map := fun X Y => BoundedLatticeHom.toSupBotHom }\n#align BddLat.has_forget_to_SemilatSup BddLat.hasForgetToSemilatSup\n\ninstance hasForgetToSemilatInf : HasForget\u2082 BddLat SemilatInf\n    where forget\u2082 :=\n    { obj := fun X => \u27e8X\u27e9\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) : \u21a5((forget\u2082 BddLat BddOrd).obj X) = \u21a5X :=\n  rfl\n#align BddLat.coe_forget_to_BddOrd BddLat.coe_forget_to_bddOrd\n\n@[simp]\ntheorem coe_forget_to_lat (X : BddLat) : \u21a5((forget\u2082 BddLat Lat).obj X) = \u21a5X :=\n  rfl\n#align BddLat.coe_forget_to_Lat BddLat.coe_forget_to_lat\n\n@[simp]\ntheorem coe_forget_to_semilatSup (X : BddLat) : \u21a5((forget\u2082 BddLat SemilatSup).obj X) = \u21a5X :=\n  rfl\n#align BddLat.coe_forget_to_SemilatSup BddLat.coe_forget_to_semilatSup\n\n@[simp]\ntheorem coe_forget_to_semilatInf (X : BddLat) : \u21a5((forget\u2082 BddLat SemilatInf).obj X) = \u21a5X :=\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\u2082 BddLat Lat \u22d9 forget\u2082 Lat PartOrd = forget\u2082 BddLat BddOrd \u22d9 forget\u2082 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\u2082 BddLat SemilatSup \u22d9 forget\u2082 SemilatSup PartOrd =\n      forget\u2082 BddLat BddOrd \u22d9 forget\u2082 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\u2082 BddLat SemilatInf \u22d9 forget\u2082 SemilatInf PartOrd =\n      forget\u2082 BddLat BddOrd \u22d9 forget\u2082 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 {\u03b1 \u03b2 : BddLat.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2\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 \u2964 BddLat where\n  obj X := of X\u1d52\u1d48\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 \u224c 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 \u22d9 forget\u2082 BddLat BddOrd = forget\u2082 BddLat BddOrd \u22d9 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 \u22d9 forget\u2082 BddLat Lat = forget\u2082 BddLat Lat \u22d9 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 \u22d9 forget\u2082 BddLat SemilatSup = forget\u2082 BddLat SemilatInf \u22d9 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 \u22d9 forget\u2082 BddLat SemilatInf = forget\u2082 BddLat SemilatSup \u22d9 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 data.real.basic\n\nexample (x y : \u211d) : x + y = y + x := by simp", "meta": {"author": "kbuzzard", "repo": "xena", "sha": "cd2f0b5e948b7171dbafc5cb519a3220d318bd9d", "save_path": "github-repos/lean/kbuzzard-xena", "path": "github-repos/lean/kbuzzard-xena/xena-cd2f0b5e948b7171dbafc5cb519a3220d318bd9d/Examples/real_stuff.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8397339676722392, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.47852462796055556}}
{"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 {\u03b1 : Type u} [comm_ring \u03b1]\nparameters (I : set \u03b1) [hi : is_ideal I]\nparameters (P : set \u03b1) [hp : is_prime_ideal P]\nparameters (hip : I \u2286 P)\ninclude hi hp hip\n\nprivate theorem find_minimal_prime_ideal_aux :\n  \u2203 (M : {S // I \u2286 S \u2227 S \u2286 P \u2227 is_prime_ideal S}), \u2200 x, x \u2264 M \u2192 x = M :=\n@@zorn.zorn' (order_dual {S // I \u2286 S \u2227 S \u2286 P \u2227 is_prime_ideal S})\n_\n\u27e8\u27e8P, hip, set.subset.refl P, hp\u27e9\u27e9 $\n\u03bb c x hxc hc, \u27e8\u27e8{y | \u2200 S : {S // I \u2286 S \u2227 S \u2286 P \u2227 is_prime_ideal S}, S \u2208 c \u2192 y \u2208 S.val},\n  \u03bb z hz S hsc, S.2.1 hz,\n  \u03bb z hz, x.2.2.1 $ hz x hxc,\n  { zero_ := \u03bb S hsc, @@is_ideal.zero _ S.1\n      S.2.2.2.to_is_proper_ideal.to_is_ideal,\n    add_ := \u03bb 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 := \u03bb 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 := \u03bb h, @is_proper_ideal.ne_univ \u03b1 _ x.1 x.2.2.2.1 $\n      @is_submodule.univ_of_one_mem \u03b1 _ 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 := \u03bb x y hxy,\n      or_iff_not_and_not.2 $ \u03bb \u27e8hx, hy\u27e9,\n      let \u27e8Sx, hsx\u27e9 := not_forall.1 hx in\n      let \u27e8hxc, hxs\u27e9 := not_imp.1 hsx in\n      let \u27e8Sy, hsy\u27e9 := not_forall.1 hy in\n      let \u27e8hyc, hys\u27e9 := not_imp.1 hsy in\n      or.cases_on (hc Sx Sy hxc hyc)\n        (\u03bb 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        (\u03bb 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) }\u27e9,\n\u03bb S hsc z hz, hz S hsc\u27e9\n\ndef find_minimal_prime_ideal : set \u03b1 :=\n(classical.some find_minimal_prime_ideal_aux).1\n\ntheorem find_minimal_prime_ideal.ideal_contains : I \u2286 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 \u2286 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 \u03b1) [hs : is_prime_ideal S]\n  (his : I \u2286 S) (hsm : S \u2286 find_minimal_prime_ideal) :\n  S = find_minimal_prime_ideal :=\ncongr_arg subtype.val $\nclassical.some_spec\n  find_minimal_prime_ideal_aux\n  \u27e8S, his, set.subset.trans hsm find_minimal_prime_ideal.contains_prime, hs\u27e9 hsm\n\nprivate theorem find_minimal_prime_ideal_aux' :\n  \u2203 (M : {S // I \u2286 S \u2227 is_prime_ideal S}), \u2200 x, x \u2264 M \u2192 x = M :=\n@@zorn.zorn' (order_dual {S // I \u2286 S \u2227 is_prime_ideal S})\n_\n\u27e8\u27e8P, hip, hp\u27e9\u27e9 $\n\u03bb c x hxc hc, \u27e8\u27e8{y | \u2200 S : {S // I \u2286 S \u2227 is_prime_ideal S}, S \u2208 c \u2192 y \u2208 S.val},\n  \u03bb z hz S hsc, S.2.1 hz,\n  { zero_ := \u03bb S hsc, @@is_ideal.zero _ S.1\n      S.2.2.to_is_proper_ideal.to_is_ideal,\n    add_ := \u03bb 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 := \u03bb 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 := \u03bb h, @is_proper_ideal.ne_univ \u03b1 _ x.1 x.2.2.1 $\n      @is_submodule.univ_of_one_mem \u03b1 _ 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 := \u03bb x y hxy,\n      or_iff_not_and_not.2 $ \u03bb \u27e8hx, hy\u27e9,\n      let \u27e8Sx, hsx\u27e9 := not_forall.1 hx in\n      let \u27e8hxc, hxs\u27e9 := not_imp.1 hsx in\n      let \u27e8Sy, hsy\u27e9 := not_forall.1 hy in\n      let \u27e8hyc, hys\u27e9 := not_imp.1 hsy in\n      or.cases_on (hc Sx Sy hxc hyc)\n        (\u03bb 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        (\u03bb hSyx, hys $ hSyx $ or.resolve_left\n           (@@is_prime_ideal.mem_or_mem_of_mul_mem _ Sx.2.2 $ hxy Sx hxc)\n           hxs) }\u27e9,\n\u03bb S hsc z hz, hz S hsc\u27e9\n\ndef find_minimal_prime_ideal' : set \u03b1 :=\n(classical.some find_minimal_prime_ideal_aux').1\n\ntheorem find_minimal_prime_ideal'.ideal_contains : I \u2286 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 \u03b1) [hs : is_prime_ideal S]\n  (his : I \u2286 S) (hsm : S \u2286 find_minimal_prime_ideal') :\n  S = find_minimal_prime_ideal' :=\ncongr_arg subtype.val $\nclassical.some_spec\n  find_minimal_prime_ideal_aux'\n  \u27e8S, his, hs\u27e9 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 order.filter.basic\n\nopen filter\n\n/- Turn off trace messages so they don't pollute the test build: -/\nset_option trace.silence_library_search true\n\nexample {\u03b1 \u03b2 \u03b3 : Type*} {A : filter \u03b1} {B : filter \u03b2} {C : filter \u03b3} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3}\n  (hf : tendsto f A B) (hg : tendsto g B C) : tendsto (g \u2218 f) A C :=\ncalc\nmap (g \u2218 f) A = map g (map f A) : by library_search\n          ... \u2264 map g B         : by library_search!\n          ... \u2264 C               : by library_search!\n", "meta": {"author": "JLimperg", "repo": "aesop3", "sha": "a4a116f650cc7403428e72bd2e2c4cda300fe03f", "save_path": "github-repos/lean/JLimperg-aesop3", "path": "github-repos/lean/JLimperg-aesop3/aesop3-a4a116f650cc7403428e72bd2e2c4cda300fe03f/test/library_search/filter.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.782662489091802, "lm_q2_score": 0.611381973294151, "lm_q1q2_score": 0.47850573700425786}}
{"text": "/-example : 1 + 2222 = 2223 :=\nbegin\n  reflexivity\nend\n\ntheorem foo : 1 + (2222222222222 : nat)  = 2222222222223 :=\nbegin\n  reflexivity\nend\n-/\n\ntheorem bar : 100003 + 100003 = 200006 :=\nrfl\n\n\n", "meta": {"author": "avigad", "repo": "embed", "sha": "0e3612028d4039d29d06239ef03bc50576ca0f8b", "save_path": "github-repos/lean/avigad-embed", "path": "github-repos/lean/avigad-embed/embed-0e3612028d4039d29d06239ef03bc50576ca0f8b/src/test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7826624789529376, "lm_q2_score": 0.6113819732941511, "lm_q1q2_score": 0.478505730805539}}
{"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 : \u2115} (p\u2081 : 0 < n) (p\u2082 : n < 5) (w : fin n \u2192 fin n \u2192 \u2124) (a : \u2200 x y, w x y = - w y x) (u : \u2200 a b c d, a \u2260 b \u2192 w a b = w c d \u2192 (a = c \u2227 b = d)) (id: \u2115)\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 \u27e8\u27e8nat.zero_lt_one, dec_trivial, \u03bb x y, 0, dec_trivial, dec_trivial, 0\u27e9 , 0\u27e9\n\nstructure graph_embedding := (g\u2081 : graph) (g\u2082 : graph) (f : fin g\u2081.n \u2192 fin g\u2082.n) (x : fin g\u2082.n) (p : finset.univ \\ finset.image f finset.univ = {x}) (e : \u2200 a b, g\u2081.w a b = g\u2082.w (f a) (f b))\n\ndef special1 (e : graph_embedding) (v : fin e.g\u2081.n) (p : e.g\u2082.w (e.f v) e.x \u2260 0) : graph := \n  \u27e8zero_lt_two, dec_trivial,\n    ![![0, |e.g\u2082.w (e.f v) e.x|], ![-|e.g\u2082.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\u2082.w (e.f v) e.x|.div2 - 1)\u27e9\n\ndef special2 (e : graph_embedding) (v : fin e.g\u2081.n) : fin 2 := \n  (ite (e.g\u2082.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 (\u03bb g: graph, list.of_fn (\u03bb v, Pos \u27e8g, v\u27e9))) ++ \n  -- at most one literal selected for each graph\n  join (D.map (\u03bb g: graph, direct_amo (list.of_fn (\u03bb v, Pos \u27e8g, v\u27e9)))) ++\n  -- binary gamma for each embedding\n  join (E.map (\u03bb e, (list.reduce_option (list.of_fn (\u03bb v, (dite (e.g\u2082.w (e.f v) e.x = 0) (\u03bb _, none) (\u03bb _x, some [Neg \u27e8special1 e v _x, special2 e v\u27e9, Neg \u27e8e.g\u2081, v\u27e9, Pos \u27e8e.g\u2082, e.f v\u27e9])))) )))\n\n--#eval (encoding [\u27e81, nat.zero_lt_one, \u03bb x y, 0\u27e9] nil)\n\ndef binary_gamma (E : list graph_embedding) (f : \u03a0 g : graph, fin g.n) := \u2200 e : graph_embedding, e \u2208 E \u2192 (\u2200 x : (e.g\u2082.w (e.f (f e.g\u2081)) e.x \u2260 0), (f (special1 e (f e.g\u2081) x)) = (special2 e (f e.g\u2081)) \u2192 (f e.g\u2082 = e.f (f e.g\u2081)))\n\nlemma lemma1 {n : \u2115} (a : \u00ac n = 1) (b : \u00ac n \u2265 2) : n = 0 := by omega\n\ntheorem encodes_binary_gamma : \u2200 D E f, binary_gamma E f \u2192 (((encoding D E).eval (\u03bb \u27e8g, v\u27e9, 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 (\u27e8g, gd, h\u27e9 | \u27e8g, gd, hcl\u27e9 | \u27e8e, ee, h\u27e9),\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 (\u03bb v, Pos (pointed_graph.mk g v)))) \u2265 2,\n    {\n      rcases exists_double_flip_eq_of_mem h hcl with \u27e8lit\u2081, lit\u2082, rfl\u27e9,\n      rcases distinct_iff_mem.mpr hcl with \u27e8i, j, hi, hj, hij, rfl, rfl\u27e9,\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 (\u03bb 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\u2082.w (e.f y) e.x = 0),\n    rw dite_eq_left_iff.mpr (\u03bb nP, by_contra (\u03bb _, nP h)) at h2,\n    simp at h2,\n    exfalso,\n    exact h2,\n    change (dite (e.g\u2082.w (e.f y) e.x = 0) (\u03bb _, none) (\u03bb (_x : \u00ace.g\u2082.w (e.f y) e.x = 0), some [Neg (pointed_graph.mk (special1 e y h) (special2 e y)), Neg \u27e8e.g\u2081, y\u27e9, Pos \u27e8e.g\u2082, e.f y\u27e9])) = some cl at h2,\n    \n    rw dite_eq_right_iff.mpr (\u03bb P, by_contra (\u03bb _, 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 \u2194 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 \u22a4 x y :=\n  iff.mpr (submodule.quotient.eq \u22a4) 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 \u22a5 x y \u2194 x = y := sorry\n\ntheorem mono {R : Type u_1} [ring R] {M : Type u_2} [add_comm_group M] [module R M] {U\u2081 : submodule R M} {U\u2082 : submodule R M} {x : M} {y : M} (HU : U\u2081 \u2264 U\u2082) (hxy : smodeq U\u2081 x y) : smodeq U\u2082 x y :=\n  iff.mpr (submodule.quotient.eq U\u2082) (HU (iff.mp (submodule.quotient.eq U\u2081) 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\u2081 : M} {x\u2082 : M} {y\u2081 : M} {y\u2082 : M} (hxy\u2081 : smodeq U x\u2081 y\u2081) (hxy\u2082 : smodeq U x\u2082 y\u2082) : smodeq U (x\u2081 + x\u2082) (y\u2081 + y\u2082) := 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 \u2022 x) (c \u2022 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 \u2194 x \u2208 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) \u2208 V) => this)\n      (Eq.symm (linear_map.map_sub f x y) \u25b8 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u03b4 s`, the open thickening by radius `\u03b4` of a set `s` in a pseudo emetric space.\n* `cthickening \u03b4 s`, the closed thickening by radius `\u03b4` 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 {\u03b1 : Type u} {\u03b2 : Type v} [pseudo_emetric_space \u03b1] [pseudo_emetric_space \u03b2] {x y : \u03b1}\n{s t : set \u03b1} {\u03a6 : \u03b1 \u2192 \u03b2}\n\n/-! ### Distance of a point to a set as a function into `\u211d\u22650\u221e`. -/\n\n/-- The minimal edistance of a point to a set -/\ndef inf_edist (x : \u03b1) (s : set \u03b1) : \u211d\u22650\u221e := \u2a05 y \u2208 s, edist x y\n\n@[simp] lemma inf_edist_empty : inf_edist x \u2205 = \u221e := infi_emptyset\n\nlemma le_inf_edist {d} : d \u2264 inf_edist x s \u2194 \u2200 y \u2208 s, d \u2264 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 \u222a t) = inf_edist x s \u2293 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 \u2208 s) : inf_edist x s \u2264 edist x y := infi\u2082_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 \u2208 s) : inf_edist x s = 0 :=\nnonpos_iff_eq_zero.1 $ @edist_self _ _ x \u25b8 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 \u2286 t) : inf_edist x t \u2264 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 : \u211d\u22650\u221e} : inf_edist x s < r \u2194 \u2203 y \u2208 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 \u2264 inf_edist y s + edist x y :=\ncalc (\u2a05 z \u2208 s, edist x z) \u2264 \u2a05 z \u2208 s, edist y z + edist x y :\n  infi\u2082_mono $ \u03bb z hz, (edist_triangle _ _ _).trans_eq (add_comm _ _)\n... = (\u2a05 z \u2208 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 (\u03bbx, 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 (\u03bb\u03b5 \u03b5pos h, _),\n  have \u03b50 : 0 < (\u03b5 / 2 : \u211d\u22650\u221e) := by simpa [pos_iff_ne_zero] using \u03b5pos,\n  have : inf_edist x (closure s) < inf_edist x (closure s) + \u03b5/2,\n    from ennreal.lt_add_right h.ne \u03b50.ne',\n  rcases inf_edist_lt_iff.mp this with \u27e8y, ycs, hy\u27e9,\n  -- y : \u03b1,  ycs : y \u2208 closure s,  hy : edist x y < inf_edist x (closure s) + \u2191\u03b5 / 2\n  rcases emetric.mem_closure_iff.1 ycs (\u03b5/2) \u03b50 with \u27e8z, zs, dyz\u27e9,\n  -- z : \u03b1,  zs : z \u2208 s,  dyz : edist y z < \u2191\u03b5 / 2\n  calc inf_edist x s \u2264 edist x z : inf_edist_le_edist_of_mem zs\n        ... \u2264 edist x y + edist y z : edist_triangle _ _ _\n        ... \u2264 (inf_edist x (closure s) + \u03b5 / 2) + (\u03b5/2) : add_le_add (le_of_lt hy) (le_of_lt dyz)\n        ... = inf_edist x (closure s) + \u2191\u03b5 : 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 \u2208 closure s \u2194 inf_edist x s = 0 :=\n\u27e8\u03bb h, by { rw \u2190 inf_edist_closure, exact inf_edist_zero_of_mem h },\n\u03bb h, emetric.mem_closure_iff.2 $ \u03bb \u03b5 \u03b5pos, inf_edist_lt_iff.mp $ by rwa h\u27e9\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 \u2208 s \u2194 inf_edist x s = 0 :=\nbegin\n  convert \u2190 mem_closure_iff_inf_edist_zero,\n  exact h.closure_eq\nend\n\nlemma disjoint_closed_ball_of_lt_inf_edist {r : \u211d\u22650\u221e} (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 \u2264 edist x y : inf_edist_le_edist_of_mem h'y\n  ... \u2264 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\u03a6 : isometry \u03a6) :\n  inf_edist (\u03a6 x) (\u03a6 '' t) = inf_edist x t :=\nby simp only [inf_edist, infi_image, h\u03a6.edist_eq]\n\nlemma _root_.is_open.exists_Union_is_closed {U : set \u03b1} (hU : is_open U) :\n  \u2203 F : \u2115 \u2192 set \u03b1, (\u2200 n, is_closed (F n)) \u2227 (\u2200 n, F n \u2286 U) \u2227 ((\u22c3 n, F n) = U) \u2227 monotone F :=\nbegin\n  obtain \u27e8a, a_pos, a_lt_one\u27e9 : \u2203 (a : \u211d\u22650\u221e), 0 < a \u2227 a < 1 := exists_between (ennreal.zero_lt_one),\n  let F := \u03bb (n : \u2115), (\u03bb x, inf_edist x U\u1d9c) \u207b\u00b9' (Ici (a^n)),\n  have F_subset : \u2200 n, F n \u2286 U,\n  { assume n x hx,\n    have : inf_edist x U\u1d9c \u2260 0 := ((ennreal.pow_pos a_pos _).trans_le hx).ne',\n    contrapose! this,\n    exact inf_edist_zero_of_mem this },\n  refine \u27e8F, \u03bb n, is_closed.preimage continuous_inf_edist is_closed_Ici, F_subset, _, _\u27e9,\n  show monotone F,\n  { assume m n hmn x hx,\n    simp only [mem_Ici, mem_preimage] at hx \u22a2,\n    apply le_trans (ennreal.pow_le_pow_of_le_one a_lt_one.le hmn) hx },\n  show (\u22c3 n, F n) = U,\n  { refine subset.antisymm (by simp only [Union_subset_iff, F_subset, forall_const]) (\u03bb x hx, _),\n    have : \u00ac(x \u2208 U\u1d9c), 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\u1d9c, by simpa [pos_iff_ne_zero] using this,\n    have : filter.tendsto (\u03bb n, a^n) at_top (\ud835\udcdd 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 \u27e8n, hn\u27e9,\n    simp only [mem_Union, mem_Ici, mem_preimage],\n    exact \u27e8n, hn.le\u27e9 },\nend\n\nlemma _root_.is_compact.exists_inf_edist_eq_edist (hs : is_compact s) (hne : s.nonempty) (x : \u03b1) :\n  \u2203 y \u2208 s, inf_edist x s = edist x y :=\nbegin\n  have A : continuous (\u03bb y, edist x y) := continuous_const.edist continuous_id,\n  obtain \u27e8y, ys, hy\u27e9 : \u2203 y \u2208 s, \u2200 z, z \u2208 s \u2192 edist x y \u2264 edist x z :=\n    hs.exists_forall_le hne A.continuous_on,\n  exact \u27e8y, ys, le_antisymm (inf_edist_le_edist_of_mem ys) (by rwa le_inf_edist)\u27e9\nend\n\nend inf_edist --section\n\n/-! ### The Hausdorff distance as a function into `\u211d\u22650\u221e`. -/\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 {\u03b1 : Type u} [pseudo_emetric_space \u03b1] (s t : set \u03b1) : \u211d\u22650\u221e :=\n(\u2a06 x \u2208 s, inf_edist x t) \u2294 (\u2a06 y \u2208 t, inf_edist y s)\n\nlemma Hausdorff_edist_def {\u03b1 : Type u} [pseudo_emetric_space \u03b1] (s t : set \u03b1) :\n  Hausdorff_edist s t = (\u2a06 x \u2208 s, inf_edist x t) \u2294 (\u2a06 y \u2208 t, inf_edist y s) :=\nby rw Hausdorff_edist\n\nsection Hausdorff_edist\n\nvariables {\u03b1 : Type u} {\u03b2 : Type v} [pseudo_emetric_space \u03b1] [pseudo_emetric_space \u03b2]\n          {x y : \u03b1} {s t u : set \u03b1} {\u03a6 : \u03b1 \u2192 \u03b2}\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 \u03bb 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 : \u211d\u22650\u221e}\n  (H1 : \u2200x \u2208 s, inf_edist x t \u2264 r) (H2 : \u2200x \u2208 t, inf_edist x s \u2264 r) :\n  Hausdorff_edist s t \u2264 r :=\nbegin\n  simp only [Hausdorff_edist, sup_le_iff, supr_le_iff],\n  exact \u27e8H1, H2\u27e9\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 : \u211d\u22650\u221e}\n  (H1 : \u2200x \u2208 s, \u2203y \u2208 t, edist x y \u2264 r) (H2 : \u2200x \u2208 t, \u2203y \u2208 s, edist x y \u2264 r) :\n  Hausdorff_edist s t \u2264 r :=\nbegin\n  refine Hausdorff_edist_le_of_inf_edist _ _,\n  { assume x xs,\n    rcases H1 x xs with \u27e8y, yt, hy\u27e9,\n    exact le_trans (inf_edist_le_edist_of_mem yt) hy },\n  { assume x xt,\n    rcases H2 x xt with \u27e8y, ys, hy\u27e9,\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 \u2208 s) : inf_edist x t \u2264 Hausdorff_edist s t :=\nbegin\n  rw Hausdorff_edist_def,\n  refine le_trans _ le_sup_left,\n  exact le_supr\u2082 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 : \u211d\u22650\u221e} (h : x \u2208 s)\n  (H : Hausdorff_edist s t < r) : \u2203 y \u2208 t, edist x y < r :=\ninf_edist_lt_iff.mp $ calc\n  inf_edist x t \u2264 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 \u2264 inf_edist x s + Hausdorff_edist s t :=\nennreal.le_of_forall_pos_le_add $ \u03bb\u03b5 \u03b5pos h, begin\n  have \u03b50 : (\u03b5 / 2 : \u211d\u22650\u221e) \u2260 0 := by simpa [pos_iff_ne_zero] using \u03b5pos,\n  have : inf_edist x s < inf_edist x s + \u03b5/2 :=\n    ennreal.lt_add_right (ennreal.add_lt_top.1 h).1.ne \u03b50,\n  rcases inf_edist_lt_iff.mp this with \u27e8y, ys, dxy\u27e9,\n  -- y : \u03b1,  ys : y \u2208 s,  dxy : edist x y < inf_edist x s + \u2191\u03b5 / 2\n  have : Hausdorff_edist s t < Hausdorff_edist s t + \u03b5/2 :=\n    ennreal.lt_add_right (ennreal.add_lt_top.1 h).2.ne \u03b50,\n  rcases exists_edist_lt_of_Hausdorff_edist_lt ys this with \u27e8z, zt, dyz\u27e9,\n  -- z : \u03b1,  zt : z \u2208 t,  dyz : edist y z < Hausdorff_edist s t + \u2191\u03b5 / 2\n  calc inf_edist x t \u2264 edist x z : inf_edist_le_edist_of_mem zt\n    ... \u2264 edist x y + edist y z : edist_triangle _ _ _\n    ... \u2264 (inf_edist x s + \u03b5/2) + (Hausdorff_edist s t + \u03b5/2) : add_le_add dxy.le dyz.le\n    ... = inf_edist x s + Hausdorff_edist s t + \u03b5 :\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 \u03a6) :\n  Hausdorff_edist (\u03a6 '' s) (\u03a6 '' 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 \u2264 diam (s \u222a t) :=\nbegin\n  rcases hs with \u27e8x, xs\u27e9,\n  rcases ht with \u27e8y, yt\u27e9,\n  refine Hausdorff_edist_le_of_mem_edist _ _,\n  { intros z hz,\n    exact \u27e8y, yt, edist_le_diam_of_mem (subset_union_left _ _ hz) (subset_union_right _ _ yt)\u27e9 },\n  { intros z hz,\n    exact \u27e8x, xs, edist_le_diam_of_mem (subset_union_right _ _ hz) (subset_union_left _ _ xs)\u27e9 }\nend\n\n/-- The Hausdorff distance satisfies the triangular inequality -/\nlemma Hausdorff_edist_triangle : Hausdorff_edist s u \u2264 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 \u2200x \u2208 s, inf_edist x u \u2264 Hausdorff_edist s t + Hausdorff_edist t u, from \u03bbx xs, calc\n    inf_edist x u \u2264 inf_edist x t + Hausdorff_edist t u : inf_edist_le_inf_edist_add_Hausdorff_edist\n    ... \u2264 Hausdorff_edist s t + Hausdorff_edist t u :\n      add_le_add_right (inf_edist_le_Hausdorff_edist_of_mem  xs) _,\n  show \u2200x \u2208 u, inf_edist x s \u2264 Hausdorff_edist s t + Hausdorff_edist t u, from \u03bbx xu, calc\n    inf_edist x s \u2264 inf_edist x t + Hausdorff_edist t s : inf_edist_le_inf_edist_add_Hausdorff_edist\n    ... \u2264 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 \u2194 closure s = closure t :=\ncalc Hausdorff_edist s t = 0 \u2194 s \u2286 closure t \u2227 t \u2286 closure s :\n  by simp only [Hausdorff_edist_def, ennreal.sup_eq_zero, ennreal.supr_eq_zero,\n    \u2190 mem_closure_iff_inf_edist_zero, subset_def]\n... \u2194 closure s = closure t :\n  \u27e8\u03bb h, subset.antisymm (closure_minimal h.1 is_closed_closure)\n     (closure_minimal h.2 is_closed_closure),\n   \u03bb h, \u27e8h \u25b8 subset_closure, h.symm \u25b8 subset_closure\u27e9\u27e9\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\u2081 : Hausdorff_edist (closure s) t = Hausdorff_edist s t :=\nbegin\n  refine le_antisymm _ _,\n  { calc  _ \u2264 Hausdorff_edist (closure s) s + Hausdorff_edist s t : Hausdorff_edist_triangle\n    ... = Hausdorff_edist s t : by simp [Hausdorff_edist_comm] },\n  { calc _ \u2264 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\u2082 : 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 \u2194 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 \u2205 = \u221e :=\nbegin\n  rcases ne with \u27e8x, xs\u27e9,\n  have : inf_edist x \u2205 \u2264 Hausdorff_edist s \u2205 := 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 \u2260 \u22a4) :\n  t.nonempty :=\nt.eq_empty_or_nonempty.elim (\u03bb ht, (fin $ ht.symm \u25b8 Hausdorff_edist_empty hs).elim) id\n\nlemma empty_or_nonempty_of_Hausdorff_edist_ne_top (fin : Hausdorff_edist s t \u2260 \u22a4) :\n  s = \u2205 \u2227 t = \u2205 \u2228 s.nonempty \u2227 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 \u27e8hs, ht\u27e9 },\n    { rw Hausdorff_edist_comm at fin,\n      exact or.inr \u27e8nonempty_of_Hausdorff_edist_ne_top ht fin, ht\u27e9 } },\n  { exact or.inr \u27e8hs, nonempty_of_Hausdorff_edist_ne_top hs fin\u27e9 }\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 `\u211d` (which is only conditionally complete), we use the notions in `\u211d\u22650\u221e`\nformulated in terms of the edistance, and coerce them to `\u211d`.\nThen their properties follow readily from the corresponding properties in `\u211d\u22650\u221e`,\nmodulo some tedious rewriting of inequalities from one to the other. -/\n\nnamespace metric\nsection\nvariables {\u03b1 : Type u} {\u03b2 : Type v} [pseudo_metric_space \u03b1] [pseudo_metric_space \u03b2]\n  {s t u : set \u03b1} {x y : \u03b1} {\u03a6 : \u03b1 \u2192 \u03b2}\nopen emetric\n\n/-! ### Distance of a point to a set as a function into `\u211d`. -/\n\n/-- The minimal distance of a point to a set -/\ndef inf_dist (x : \u03b1) (s : set \u03b1) : \u211d := ennreal.to_real (inf_edist x s)\n\n/-- the minimal distance is always nonnegative -/\nlemma inf_dist_nonneg : 0 \u2264 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 \u221e instead, use `inf_edist`, which takes values in \u211d\u22650\u221e) -/\n@[simp] lemma inf_dist_empty : inf_dist x \u2205 = 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 \u2260 \u22a4 :=\nbegin\n  rcases h with \u27e8y, hy\u27e9,\n  apply lt_top_iff_ne_top.1,\n  calc inf_edist x s \u2264 edist x y : inf_edist_le_edist_of_mem hy\n       ... < \u22a4 : 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 \u2208 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 \u2208 s) : inf_dist x s \u2264 dist x y :=\nbegin\n  rw [dist_edist, inf_dist,\n    ennreal.to_real_le_to_real (inf_edist_ne_top \u27e8_, h\u27e9) (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 \u2286 t) (hs : s.nonempty) :\n  inf_dist x t \u2264 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 : \u211d} (hs : s.nonempty) :\n  inf_dist x s < r \u2194 \u2203 y \u2208 s, dist x y < r :=\nby simp_rw [inf_dist, \u2190 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 _ _), \u2190 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 \u2264 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        \u2190 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 \u2209 s :=\n\u03bb 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 $ \u03bb 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 : \u211d} (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 (\u03bbx, inf_dist x s) :=\nlipschitz_with.of_le_add $ \u03bb 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 (\u03bbx, 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 \u2208 closure s) : inf_dist x s = 0 :=\nby { rw \u2190 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 \u2208 closure s \u2194 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 \u2208 s \u2194 inf_dist x s = 0 :=\nby rw [\u2190mem_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 \u2209 s \u2194 0 < inf_dist x s :=\nbegin\n  rw \u2190 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\u03a6 : isometry \u03a6) :\n  inf_dist (\u03a6 x) (\u03a6 '' t) = inf_dist x t :=\nby simp [inf_dist, inf_edist_image h\u03a6]\n\nlemma inf_dist_inter_closed_ball_of_mem (h : y \u2208 s) :\n  inf_dist x (s \u2229 closed_ball x (dist y x)) = inf_dist x s :=\nbegin\n  replace h : y \u2208 s \u2229 closed_ball x (dist y x) := \u27e8h, mem_closed_ball.2 le_rfl\u27e9,\n  refine le_antisymm _ (inf_dist_le_inf_dist_of_subset (inter_subset_left _ _) \u27e8y, h\u27e9),\n  refine not_lt.1 (\u03bb hlt, _),\n  rcases (inf_dist_lt_iff \u27e8y, h.1\u27e9).mp hlt with \u27e8z, hzs, hz\u27e9,\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 \u27e8hzs, hle\u27e9) },\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 : \u03b1) :\n  \u2203 y \u2208 s, inf_dist x s = dist x y :=\nlet \u27e8y, hys, hy\u27e9 := h.exists_inf_edist_eq_edist hne x\nin \u27e8y, hys, by rw [inf_dist, dist_edist, hy]\u27e9\n\nlemma _root_.is_closed.exists_inf_dist_eq_dist [proper_space \u03b1]\n  (h : is_closed s) (hne : s.nonempty) (x : \u03b1) :\n  \u2203 y \u2208 s, inf_dist x s = dist x y :=\nbegin\n  rcases hne with \u27e8z, hz\u27e9,\n  rw \u2190 inf_dist_inter_closed_ball_of_mem hz,\n  set t := s \u2229 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 := \u27e8z, hz, mem_closed_ball.2 le_rfl\u27e9,\n  obtain \u27e8y, \u27e8hys, hyx\u27e9, hyd\u27e9 : \u2203 y \u2208 t, inf_dist x t = dist x y :=\n    htc.exists_inf_dist_eq_dist htne x,\n  exact \u27e8y, hys, hyd\u27e9\nend\n\nlemma exists_mem_closure_inf_dist_eq_dist [proper_space \u03b1] (hne : s.nonempty) (x : \u03b1) :\n  \u2203 y \u2208 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 `\u211d\u22650`. -/\n\n/-- The minimal distance of a point to a set as a `\u211d\u22650` -/\ndef inf_nndist (x : \u03b1) (s : set \u03b1) : \u211d\u22650 := ennreal.to_nnreal (inf_edist x s)\n@[simp] lemma coe_inf_nndist : (inf_nndist x s : \u211d) = inf_dist x s := rfl\n\n/-- The minimal distance to a set (as `\u211d\u22650`) is Lipschitz in point with constant 1 -/\nlemma lipschitz_inf_nndist_pt (s : set \u03b1) : lipschitz_with 1 (\u03bbx, inf_nndist x s) :=\nlipschitz_with.of_le_add $ \u03bb x y, inf_dist_le_inf_dist_add_dist\n\n/-- The minimal distance to a set (as `\u211d\u22650`) is uniformly continuous in point -/\nlemma uniform_continuous_inf_nndist_pt (s : set \u03b1) :\n  uniform_continuous (\u03bbx, inf_nndist x s) :=\n(lipschitz_inf_nndist_pt s).uniform_continuous\n\n/-- The minimal distance to a set (as `\u211d\u22650`) is continuous in point -/\nlemma continuous_inf_nndist_pt (s : set \u03b1) : continuous (\u03bbx, inf_nndist x s) :=\n(uniform_continuous_inf_nndist_pt s).continuous\n\n/-! ### The Hausdorff distance as a function into `\u211d`. -/\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 \u03b1) : \u211d := ennreal.to_real (Hausdorff_edist s t)\n\n/-- The Hausdorff distance is nonnegative -/\nlemma Hausdorff_dist_nonneg : 0 \u2264 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 \u2260 \u22a4 :=\nbegin\n  rcases hs with \u27e8cs, hcs\u27e9,\n  rcases ht with \u27e8ct, hct\u27e9,\n  rcases (bounded_iff_subset_ball ct).1 bs with \u27e8rs, hrs\u27e9,\n  rcases (bounded_iff_subset_ball cs).1 bt with \u27e8rt, hrt\u27e9,\n  have : Hausdorff_edist s t \u2264 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 \u2264 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 \u2264 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 \u221e instead, use `Hausdorff_edist`, which takes values in \u211d\u22650\u221e) -/\n@[simp] lemma Hausdorff_dist_empty : Hausdorff_dist s \u2205 = 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 \u221e instead, use `Hausdorff_edist`, which takes values in \u211d\u22650\u221e) -/\n@[simp] lemma Hausdorff_dist_empty' : Hausdorff_dist \u2205 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 : \u211d} (hr : 0 \u2264 r)\n  (H1 : \u2200x \u2208 s, inf_dist x t \u2264 r) (H2 : \u2200x \u2208 t, inf_dist x s \u2264 r) :\n  Hausdorff_dist s t \u2264 r :=\nbegin\n  by_cases h1 : Hausdorff_edist s t = \u22a4,\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 \u2264 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, \u2190 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, \u2190 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, \u2190 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 : \u211d} (hr : 0 \u2264 r)\n  (H1 : \u2200x \u2208 s, \u2203y \u2208 t, dist x y \u2264 r) (H2 : \u2200x \u2208 t, \u2203y \u2208 s, dist x y \u2264 r) :\n  Hausdorff_dist s t \u2264 r :=\nbegin\n  apply Hausdorff_dist_le_of_inf_dist hr,\n  { assume x xs,\n    rcases H1 x xs with \u27e8y, yt, hy\u27e9,\n    exact le_trans (inf_dist_le_dist_of_mem yt) hy },\n  { assume x xt,\n    rcases H2 x xt with \u27e8y, ys, hy\u27e9,\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 \u2264 diam (s \u222a t) :=\nbegin\n  rcases hs with \u27e8x, xs\u27e9,\n  rcases ht with \u27e8y, yt\u27e9,\n  refine Hausdorff_dist_le_of_mem_dist diam_nonneg _ _,\n  { exact  \u03bbz hz, \u27e8y, yt, dist_le_diam_of_mem (bounded_union.2 \u27e8bs, bt\u27e9)\n      (subset_union_left _ _ hz) (subset_union_right _ _ yt)\u27e9 },\n  { exact \u03bbz hz, \u27e8x, xs, dist_le_diam_of_mem (bounded_union.2 \u27e8bs, bt\u27e9)\n      (subset_union_right _ _ hz) (subset_union_left _ _ xs)\u27e9 }\nend\n\n/-- The distance to a set is controlled by the Hausdorff distance -/\nlemma inf_dist_le_Hausdorff_dist_of_mem (hx : x \u2208 s) (fin : Hausdorff_edist s t \u2260 \u22a4) :\n  inf_dist x t \u2264 Hausdorff_dist s t :=\nbegin\n  have ht : t.nonempty := nonempty_of_Hausdorff_edist_ne_top \u27e8x, hx\u27e9 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 : \u211d} (h : x \u2208 s) (H : Hausdorff_dist s t < r)\n  (fin : Hausdorff_edist s t \u2260 \u22a4) : \u2203y\u2208t, 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, \u2190 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 \u27e8y, hy, yr\u27e9,\n  rw [edist_dist, ennreal.of_real_lt_of_real_iff r0] at yr,\n  exact \u27e8y, hy, yr\u27e9\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 : \u211d} (h : y \u2208 t) (H : Hausdorff_dist s t < r)\n  (fin : Hausdorff_edist s t \u2260 \u22a4) : \u2203x\u2208s, 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 \u2260 \u22a4) :\n  inf_dist x t \u2264 inf_dist x s + Hausdorff_dist s t :=\nbegin\n  rcases empty_or_nonempty_of_Hausdorff_edist_ne_top fin with \u27e8hs,ht\u27e9|\u27e8hs,ht\u27e9,\n  { simp only [hs, ht, Hausdorff_dist_empty, inf_dist_empty, zero_add] },\n  rw [inf_dist, inf_dist, Hausdorff_dist, \u2190 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 \u27e8inf_edist_ne_top hs, fin\u27e9 }\nend\n\n/-- The Hausdorff distance is invariant under isometries -/\nlemma Hausdorff_dist_image (h : isometry \u03a6) :\n  Hausdorff_dist (\u03a6 '' s) (\u03a6 '' 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 \u2260 \u22a4) :\n  Hausdorff_dist s u \u2264 Hausdorff_dist s t + Hausdorff_dist t u :=\nbegin\n  by_cases Hausdorff_edist s u = \u22a4,\n  { calc Hausdorff_dist s u = 0 + 0 : by simp [Hausdorff_dist, h]\n         ... \u2264 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 < \u22a4 := calc\n      Hausdorff_edist t u \u2264 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      ... < \u22a4 : lt_top_iff_ne_top.mpr $ ennreal.add_ne_top.mpr \u27e8fin, h\u27e9,\n    rw [Hausdorff_dist, Hausdorff_dist, Hausdorff_dist,\n        \u2190 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 \u2260 \u22a4) :\n  Hausdorff_dist s u \u2264 Hausdorff_dist s t + Hausdorff_dist t u :=\nbegin\n  rw Hausdorff_edist_comm at fin,\n  have I : Hausdorff_dist u s \u2264 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\u2081 : 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\u2082 : 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 \u2260 \u22a4) :\n  Hausdorff_dist s t = 0 \u2194 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 \u2260 \u22a4) : Hausdorff_dist s t = 0 \u2194 s = t :=\nby simp [\u2190Hausdorff_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 {\u03b1 : Type u} [pseudo_emetric_space \u03b1]\n\nopen emetric\n\n/-- The (open) `\u03b4`-thickening `thickening \u03b4 E` of a subset `E` in a pseudo emetric space consists\nof those points that are at distance less than `\u03b4` from some point of `E`. -/\ndef thickening (\u03b4 : \u211d) (E : set \u03b1) : set \u03b1 := {x : \u03b1 | inf_edist x E < ennreal.of_real \u03b4}\n\n/-- The (open) thickening equals the preimage of an open interval under `inf_edist`. -/\nlemma thickening_eq_preimage_inf_edist (\u03b4 : \u211d) (E : set \u03b1) :\n  thickening \u03b4 E = (\u03bb x, inf_edist x E) \u207b\u00b9' (Iio (ennreal.of_real \u03b4)) := rfl\n\n/-- The (open) thickening is an open set. -/\nlemma is_open_thickening {\u03b4 : \u211d} {E : set \u03b1} : is_open (thickening \u03b4 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 (\u03b4 : \u211d) : thickening \u03b4 (\u2205 : set \u03b1) = \u2205 :=\nby simp only [thickening, set_of_false, inf_edist_empty, not_top_lt]\n\n/-- The (open) thickening `thickening \u03b4 E` of a fixed subset `E` is an increasing function of the\nthickening radius `\u03b4`. -/\nlemma thickening_mono {\u03b4\u2081 \u03b4\u2082 : \u211d} (hle : \u03b4\u2081 \u2264 \u03b4\u2082) (E : set \u03b1) :\n  thickening \u03b4\u2081 E \u2286 thickening \u03b4\u2082 E :=\npreimage_mono (Iio_subset_Iio (ennreal.of_real_le_of_real hle))\n\n/-- The (open) thickening `thickening \u03b4 E` with a fixed thickening radius `\u03b4` is\nan increasing function of the subset `E`. -/\nlemma thickening_subset_of_subset (\u03b4 : \u211d) {E\u2081 E\u2082 : set \u03b1} (h : E\u2081 \u2286 E\u2082) :\n  thickening \u03b4 E\u2081 \u2286 thickening \u03b4 E\u2082 :=\n\u03bb _ hx, lt_of_le_of_lt (inf_edist_le_inf_edist_of_subset h) hx\n\nlemma mem_thickening_iff_exists_edist_lt {\u03b4 : \u211d} (E : set \u03b1) (x : \u03b1) :\n  x \u2208 thickening \u03b4 E \u2194 \u2203 z \u2208 E, edist x z < ennreal.of_real \u03b4 :=\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) `\u03b4`-thickening of a subset `E` if and only if\nit is at distance less than `\u03b4` from some point of `E`. -/\nlemma mem_thickening_iff {\u03b4 : \u211d} (E : set X) (x : X) :\n  x \u2208 thickening \u03b4 E \u2194 (\u2203 z \u2208 E, dist x z < \u03b4) :=\nbegin\n  have key_iff : \u2200 (z : X), edist x z < ennreal.of_real \u03b4 \u2194 dist x z < \u03b4,\n  { intros z,\n    rw dist_edist,\n    have d_lt_top : edist x z < \u221e, 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) \u03b4 (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 (\u03b4 : \u211d) (x : X) :\n  thickening \u03b4 ({x} : set X) = ball x \u03b4 :=\nby { ext, simp [mem_thickening_iff] }\n\n/-- The (open) `\u03b4`-thickening `thickening \u03b4 E` of a subset `E` in a metric space equals the\nunion of balls of radius `\u03b4` centered at points of `E`. -/\nlemma thickening_eq_bUnion_ball {\u03b4 : \u211d} {E : set X} :\n  thickening \u03b4 E = \u22c3 x \u2208 E, ball x \u03b4 :=\nby { ext x, rw mem_Union\u2082, exact mem_thickening_iff E x, }\n\nlemma bounded.thickening {\u03b4 : \u211d} {E : set X} (h : bounded E) :\n  bounded (thickening \u03b4 E) :=\nbegin\n  refine bounded_iff_mem_bounded.2 (\u03bb x hx, _),\n  rcases h.subset_ball x with \u27e8R, hR\u27e9,\n  refine (bounded_iff_subset_ball x).2 \u27e8R + \u03b4, _\u27e9,\n  assume y hy,\n  rcases (mem_thickening_iff _ _).1 hy with \u27e8z, zE, hz\u27e9,\n  calc dist y x \u2264 dist z x + dist y z : by { rw add_comm, exact dist_triangle _ _ _ }\n  ... \u2264 R + \u03b4 : add_le_add (hR zE) hz.le\nend\n\nend thickening --section\n\nsection cthickening\n\nvariables {\u03b1 : Type*} [pseudo_emetric_space \u03b1]\n\nopen emetric\n\n/-- The closed `\u03b4`-thickening `cthickening \u03b4 E` of a subset `E` in a pseudo emetric space consists\nof those points that are at infimum distance at most `\u03b4` from `E`. -/\ndef cthickening (\u03b4 : \u211d) (E : set \u03b1) : set \u03b1 := {x : \u03b1 | inf_edist x E \u2264 ennreal.of_real \u03b4}\n\nlemma mem_cthickening_of_edist_le (x y : \u03b1) (\u03b4 : \u211d) (E : set \u03b1) (h : y \u2208 E)\n  (h' : edist x y \u2264 ennreal.of_real \u03b4) :\n  x \u2208 cthickening \u03b4 E :=\n(inf_edist_le_edist_of_mem h).trans h'\n\nlemma mem_cthickening_of_dist_le {\u03b1 : Type*} [pseudo_metric_space \u03b1]\n  (x y : \u03b1) (\u03b4 : \u211d) (E : set \u03b1) (h : y \u2208 E) (h' : dist x y \u2264 \u03b4) :\n  x \u2208 cthickening \u03b4 E :=\nbegin\n  apply mem_cthickening_of_edist_le x y \u03b4 E h,\n  rw edist_dist,\n  exact ennreal.of_real_le_of_real h',\nend\n\nlemma cthickening_eq_preimage_inf_edist (\u03b4 : \u211d) (E : set \u03b1) :\n  cthickening \u03b4 E = (\u03bb x, inf_edist x E) \u207b\u00b9' (Iic (ennreal.of_real \u03b4)) := rfl\n\n/-- The closed thickening is a closed set. -/\nlemma is_closed_cthickening {\u03b4 : \u211d} {E : set \u03b1} : is_closed (cthickening \u03b4 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 (\u03b4 : \u211d) : cthickening \u03b4 (\u2205 : set \u03b1) = \u2205 :=\nby simp only [cthickening, ennreal.of_real_ne_top, set_of_false, inf_edist_empty, top_le_iff]\n\nlemma cthickening_of_nonpos {\u03b4 : \u211d} (h\u03b4 : \u03b4 \u2264 0) (E : set \u03b1) :\n  cthickening \u03b4 E = closure E :=\nby { ext x, simp [mem_closure_iff_inf_edist_zero, cthickening, ennreal.of_real_eq_zero.2 h\u03b4] }\n\n/-- The closed thickening with radius zero is the closure of the set. -/\n@[simp] lemma cthickening_zero (E : set \u03b1) : cthickening 0 E = closure E :=\ncthickening_of_nonpos le_rfl E\n\n/-- The closed thickening `cthickening \u03b4 E` of a fixed subset `E` is an increasing function of\nthe thickening radius `\u03b4`. -/\nlemma cthickening_mono {\u03b4\u2081 \u03b4\u2082 : \u211d} (hle : \u03b4\u2081 \u2264 \u03b4\u2082) (E : set \u03b1) :\n  cthickening \u03b4\u2081 E \u2286 cthickening \u03b4\u2082 E :=\npreimage_mono (Iic_subset_Iic.mpr (ennreal.of_real_le_of_real hle))\n\n@[simp] lemma cthickening_singleton {\u03b1 : Type*} [pseudo_metric_space \u03b1]\n  (x : \u03b1) {\u03b4 : \u211d} (h\u03b4 : 0 \u2264 \u03b4) :\n  cthickening \u03b4 ({x} : set \u03b1) = closed_ball x \u03b4 :=\nby { ext y, simp [cthickening, edist_dist, ennreal.of_real_le_of_real_iff h\u03b4] }\n\nlemma closed_ball_subset_cthickening_singleton {\u03b1 : Type*} [pseudo_metric_space \u03b1]\n  (x : \u03b1) (\u03b4 : \u211d) :\n  closed_ball x \u03b4 \u2286 cthickening \u03b4 ({x} : set \u03b1) :=\nbegin\n  rcases lt_or_le \u03b4 0 with h\u03b4|h\u03b4,\n  { simp only [closed_ball_eq_empty.mpr h\u03b4, empty_subset] },\n  { simp only [cthickening_singleton x h\u03b4] }\nend\n\n/-- The closed thickening `cthickening \u03b4 E` with a fixed thickening radius `\u03b4` is\nan increasing function of the subset `E`. -/\nlemma cthickening_subset_of_subset (\u03b4 : \u211d) {E\u2081 E\u2082 : set \u03b1} (h : E\u2081 \u2286 E\u2082) :\n  cthickening \u03b4 E\u2081 \u2286 cthickening \u03b4 E\u2082 :=\n\u03bb _ hx, le_trans (inf_edist_le_inf_edist_of_subset h) hx\n\nlemma cthickening_subset_thickening {\u03b4\u2081 : \u211d\u22650} {\u03b4\u2082 : \u211d} (hlt : (\u03b4\u2081 : \u211d) < \u03b4\u2082) (E : set \u03b1) :\n  cthickening \u03b4\u2081 E \u2286 thickening \u03b4\u2082 E :=\n\u03bb _ hx, lt_of_le_of_lt hx ((ennreal.of_real_lt_of_real_iff (lt_of_le_of_lt \u03b4\u2081.prop hlt)).mpr hlt)\n\n/-- The closed thickening `cthickening \u03b4\u2081 E` is contained in the open thickening `thickening \u03b4\u2082 E`\nif the radius of the latter is positive and larger. -/\nlemma cthickening_subset_thickening' {\u03b4\u2081 \u03b4\u2082 : \u211d} (\u03b4\u2082_pos : 0 < \u03b4\u2082) (hlt : \u03b4\u2081 < \u03b4\u2082) (E : set \u03b1) :\n  cthickening \u03b4\u2081 E \u2286 thickening \u03b4\u2082 E :=\n\u03bb _ hx, lt_of_le_of_lt hx ((ennreal.of_real_lt_of_real_iff \u03b4\u2082_pos).mpr hlt)\n\n/-- The open thickening `thickening \u03b4 E` is contained in the closed thickening `cthickening \u03b4 E`\nwith the same radius. -/\nlemma thickening_subset_cthickening (\u03b4 : \u211d) (E : set \u03b1) :\n  thickening \u03b4 E \u2286 cthickening \u03b4 E :=\nby { intros x hx, rw [thickening, mem_set_of_eq] at hx, exact hx.le, }\n\nlemma thickening_subset_cthickening_of_le {\u03b4\u2081 \u03b4\u2082 : \u211d} (hle : \u03b4\u2081 \u2264 \u03b4\u2082) (E : set \u03b1) :\n  thickening \u03b4\u2081 E \u2286 cthickening \u03b4\u2082 E :=\n(thickening_subset_cthickening \u03b4\u2081 E).trans (cthickening_mono hle E)\n\nlemma bounded.cthickening {\u03b1 : Type*} [pseudo_metric_space \u03b1] {\u03b4 : \u211d} {E : set \u03b1} (h : bounded E) :\n  bounded (cthickening \u03b4 E) :=\nbegin\n  have : bounded (thickening (max (\u03b4 + 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 (\u03b4 : \u211d) (E : set \u03b1) :\n  thickening \u03b4 E \u2286 interior (cthickening \u03b4 E) :=\n(subset_interior_iff_open.mpr (is_open_thickening)).trans\n  (interior_mono (thickening_subset_cthickening \u03b4 E))\n\nlemma closure_thickening_subset_cthickening (\u03b4 : \u211d) (E : set \u03b1) :\n  closure (thickening \u03b4 E) \u2286 cthickening \u03b4 E :=\n(closure_mono (thickening_subset_cthickening \u03b4 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 (\u03b4 : \u211d) (E : set \u03b1) :\n  closure E \u2286 cthickening \u03b4 E :=\nby { rw \u2190 cthickening_of_nonpos (min_le_right \u03b4 0), exact cthickening_mono (min_le_left \u03b4 0) E, }\n\n/-- The (open) thickening of a set contains the closure of the set. -/\nlemma closure_subset_thickening {\u03b4 : \u211d} (\u03b4_pos : 0 < \u03b4) (E : set \u03b1) :\n  closure E \u2286 thickening \u03b4 E :=\nby { rw \u2190 cthickening_zero, exact cthickening_subset_thickening' \u03b4_pos \u03b4_pos E, }\n\n/-- A set is contained in its own (open) thickening. -/\nlemma self_subset_thickening {\u03b4 : \u211d} (\u03b4_pos : 0 < \u03b4) (E : set \u03b1) :\n  E \u2286 thickening \u03b4 E :=\n(@subset_closure _ _ E).trans (closure_subset_thickening \u03b4_pos E)\n\n/-- A set is contained in its own closed thickening. -/\nlemma self_subset_cthickening {\u03b4 : \u211d} (E : set \u03b1) :\n  E \u2286 cthickening \u03b4 E :=\nsubset_closure.trans (closure_subset_cthickening \u03b4 E)\n\nlemma cthickening_eq_Inter_cthickening' {\u03b4 : \u211d}\n  (s : set \u211d) (hs\u03b4 : s \u2286 Ioi \u03b4) (hs : \u2200 \u03b5, \u03b4 < \u03b5 \u2192 (s \u2229 (Ioc \u03b4 \u03b5)).nonempty) (E : set \u03b1) :\n  cthickening \u03b4 E = \u22c2 \u03b5 \u2208 s, cthickening \u03b5 E :=\nbegin\n  apply subset.antisymm,\n  { exact subset_Inter\u2082 (\u03bb _ h\u03b5, cthickening_mono (le_of_lt (hs\u03b4 h\u03b5)) 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 \u03b7 \u03b7_pos _,\n    rcases hs (\u03b4 + \u03b7) (lt_add_of_pos_right _ (nnreal.coe_pos.mpr \u03b7_pos)) with \u27e8\u03b5, \u27e8hs\u03b5, h\u03b5\u27e9\u27e9,\n    apply ((hx \u03b5 hs\u03b5).trans (ennreal.of_real_le_of_real h\u03b5.2)).trans,\n    rw ennreal.coe_nnreal_eq \u03b7,\n    exact ennreal.of_real_add_le, },\nend\n\nlemma cthickening_eq_Inter_cthickening {\u03b4 : \u211d} (E : set \u03b1) :\n  cthickening \u03b4 E = \u22c2 (\u03b5 : \u211d) (h : \u03b4 < \u03b5), cthickening \u03b5 E :=\nbegin\n  apply cthickening_eq_Inter_cthickening' (Ioi \u03b4) rfl.subset,\n  simp_rw inter_eq_right_iff_subset.mpr Ioc_subset_Ioi_self,\n  exact \u03bb _ h\u03b5, nonempty_Ioc.mpr h\u03b5,\nend\n\nlemma cthickening_eq_Inter_thickening' {\u03b4 : \u211d} (\u03b4_nn : 0 \u2264 \u03b4)\n  (s : set \u211d) (hs\u03b4 : s \u2286 Ioi \u03b4) (hs : \u2200 \u03b5, \u03b4 < \u03b5 \u2192 (s \u2229 (Ioc \u03b4 \u03b5)).nonempty) (E : set \u03b1) :\n  cthickening \u03b4 E = \u22c2 \u03b5 \u2208 s, thickening \u03b5 E :=\nbegin\n  refine (subset_Inter\u2082 $ \u03bb \u03b5 h\u03b5, _).antisymm _,\n  { obtain \u27e8\u03b5', hs\u03b5', h\u03b5'\u27e9 := hs \u03b5 (hs\u03b4 h\u03b5),\n    have ss := cthickening_subset_thickening' (lt_of_le_of_lt \u03b4_nn h\u03b5'.1) h\u03b5'.1 E,\n    exact ss.trans (thickening_mono h\u03b5'.2 E), },\n  { rw cthickening_eq_Inter_cthickening' s hs\u03b4 hs E,\n    exact Inter\u2082_mono (\u03bb \u03b5 h\u03b5, thickening_subset_cthickening \u03b5 E) }\nend\n\nlemma cthickening_eq_Inter_thickening {\u03b4 : \u211d} (\u03b4_nn : 0 \u2264 \u03b4) (E : set \u03b1) :\n  cthickening \u03b4 E = \u22c2 (\u03b5 : \u211d) (h : \u03b4 < \u03b5), thickening \u03b5 E :=\nbegin\n  apply cthickening_eq_Inter_thickening' \u03b4_nn (Ioi \u03b4) rfl.subset,\n  simp_rw inter_eq_right_iff_subset.mpr Ioc_subset_Ioi_self,\n  exact \u03bb _ h\u03b5, nonempty_Ioc.mpr h\u03b5,\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 \u03b1)\n  (s : set \u211d) (hs : \u2200 \u03b5, 0 < \u03b5 \u2192 (s \u2229 (Ioc 0 \u03b5)).nonempty) :\n  closure E = \u22c2 \u03b4 \u2208 s, cthickening \u03b4 E :=\nbegin\n  by_cases hs\u2080 : s \u2286 Ioi 0,\n  { rw \u2190 cthickening_zero, apply cthickening_eq_Inter_cthickening' _ hs\u2080 hs, },\n  obtain \u27e8\u03b4, h\u03b4s, \u03b4_nonpos\u27e9 := not_subset.mp hs\u2080,\n  rw [set.mem_Ioi, not_lt] at \u03b4_nonpos,\n  apply subset.antisymm,\n  { exact subset_Inter\u2082 (\u03bb \u03b5 _, closure_subset_cthickening \u03b5 E), },\n  { rw \u2190 cthickening_of_nonpos \u03b4_nonpos E,\n    exact bInter_subset_of_mem h\u03b4s, },\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 \u03b1) :\n  closure E = \u22c2 (\u03b4 : \u211d) (h : 0 < \u03b4), cthickening \u03b4 E :=\nby { rw \u2190 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 \u03b1)\n  (s : set \u211d) (hs\u2080 : s \u2286 Ioi 0) (hs : \u2200 \u03b5, 0 < \u03b5 \u2192 (s \u2229 (Ioc 0 \u03b5)).nonempty) :\n  closure E = \u22c2 \u03b4 \u2208 s, thickening \u03b4 E :=\nby { rw \u2190 cthickening_zero, apply cthickening_eq_Inter_thickening' le_rfl _ hs\u2080 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 \u03b1) :\n  closure E = \u22c2 (\u03b4 : \u211d) (h : 0 < \u03b4), thickening \u03b4 E :=\nby { rw \u2190 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 \u03b1) {\u03b4 : \u211d} (\u03b4_pos : 0 < \u03b4) :\n  frontier (thickening \u03b4 E) \u2286 {x : \u03b1 | inf_edist x E = ennreal.of_real \u03b4} :=\nbegin\n  have singleton_preim :\n    {x : \u03b1 | inf_edist x E = ennreal.of_real \u03b4 } = (\u03bb x , inf_edist x E) \u207b\u00b9' {ennreal.of_real \u03b4},\n  { simp only [preimage, mem_singleton_iff] },\n  rw [thickening_eq_preimage_inf_edist, singleton_preim,\n      \u2190 (frontier_Iio' \u27e8(0 : \u211d\u22650\u221e), ennreal.of_real_pos.mpr \u03b4_pos\u27e9)],\n  exact continuous_inf_edist.frontier_preimage_subset (Iio (ennreal.of_real \u03b4)),\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 \u03b1) {\u03b4 : \u211d} :\n  frontier (cthickening \u03b4 E) \u2286 {x : \u03b1 | inf_edist x E = ennreal.of_real \u03b4} :=\nbegin\n  have singleton_preim :\n    {x : \u03b1 | inf_edist x E = ennreal.of_real \u03b4 } = (\u03bb x , inf_edist x E) \u207b\u00b9' {ennreal.of_real \u03b4},\n  { simp only [preimage, mem_singleton_iff] },\n  rw [cthickening_eq_preimage_inf_edist, singleton_preim,\n      \u2190 frontier_Iic' \u27e8\u221e, ennreal.of_real_lt_top\u27e9],\n  exact continuous_inf_edist.frontier_preimage_subset (Iic (ennreal.of_real \u03b4)),\nend\n\n/-- The closed ball of radius `\u03b4` centered at a point of `E` is included in the closed\nthickening of `E`. -/\nlemma closed_ball_subset_cthickening {\u03b1 : Type*} [pseudo_metric_space \u03b1]\n  {x : \u03b1} {E : set \u03b1} (hx : x \u2208 E) (\u03b4 : \u211d) :\n  closed_ball x \u03b4 \u2286 cthickening \u03b4 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 \u03b4` over\n`x \u2208 E`. -/\nlemma _root_.is_compact.cthickening_eq_bUnion_closed_ball\n  {\u03b1 : Type*} [pseudo_metric_space \u03b1] {\u03b4 : \u211d} {E : set \u03b1} (hE : is_compact E) (h\u03b4 : 0 \u2264 \u03b4) :\n  cthickening \u03b4 E = \u22c3 x \u2208 E, closed_ball x \u03b4 :=\nbegin\n  rcases eq_empty_or_nonempty E with rfl|hne,\n  { simp only [cthickening_empty, Union_false, Union_empty] },\n  refine subset.antisymm (\u03bb x hx, _) (Union\u2082_subset $ \u03bb x hx, closed_ball_subset_cthickening hx _),\n  obtain \u27e8y, yE, hy\u27e9 : \u2203 y \u2208 E, emetric.inf_edist x E = edist x y :=\n    hE.exists_inf_edist_eq_edist hne _,\n  have D1 : edist x y \u2264 ennreal.of_real \u03b4 := (le_of_eq hy.symm).trans hx,\n  have D2 : dist x y \u2264 \u03b4,\n  { rw edist_dist at D1,\n    exact (ennreal.of_real_le_of_real_iff h\u03b4).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      `\u2200 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) \u2190 pure ty.get_app_fn | fail \"not a structure\",\n     env \u2190 get_env,\n     fields \u2190 env.structure_fields n <|> fail \"not a structre\",\n     [ctor] \u2190 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 $ \u03bb f, (pexpr.mk_field_macro (pexpr.of_raw_expr $ var 0) f).to_raw_expr)\n       (var 0),\n     proof_ty \u2190 to_expr (pexpr.of_raw_expr proof_ty),\n     prod.snd <$> solve_aux proof_ty (do x \u2190 intro `_, cases x, reflexivity)\nend tactic\n\nnamespace tactic.interactive\n  open expr tactic\n\n  private meta def common_app_prefix : expr \u2192 expr \u2192 tactic expr\n  | (app e\u2081 e\u2081') (app e\u2082 e\u2082') := (is_def_eq e\u2081 e\u2082 *> pure e\u2081) <|> common_app_prefix e\u2081 e\u2082\n  | e\u2081           e\u2082           := fail \"no common head symbol\"\n\n  /-- Given a goal of form `f a\u2081 ... a\u2099 == f a\u2081' ... a\u2099'`, this tactic breaks it down to subgoals\n      `a\u2081 == a\u2081'`, ...\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 \u2190 target,\n     (lhs, rhs) \u2190 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 \u2190 common_app_prefix lhs rhs,\n     l \u2190 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) \u2190 target | fail \"goal is not an equality\",\n     ty \u2190 infer_type lhs,\n     eta \u2190 mk_struct_eta ty,\n     apply ``(@eq.rec _ _ (\u03bb lhs, lhs = %%rhs) _ _ %%(app eta lhs)),\n     ```(%%new_lhs = %%rhs) \u2190 target,\n     apply ``(@eq.rec _ _ (\u03bb rhs, %%new_lhs = rhs) _ _ %%(app eta rhs)),\n     congr_args\nend tactic.interactive\n\nstructure X { a : Type } ( b : a \u00d7 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 `\u230b`: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 _ (\u03bb r, _) (\u03bb x y hx hy, _) (\u03bb 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_\u03b9_mul, map_sub, reverse.map_mul, reverse_\u03b9],\n    rw \u2190hx,\n    rw \u2190change_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) ` \u22cf `: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 \u2192 Type u}\n\nvariable [Traversable t] [IsLawfulTraversable t]\n\nvariable (F G : Type u \u2192 Type u)\n\nvariable [Applicative F] [LawfulApplicative F]\n\nvariable [Applicative G] [LawfulApplicative G]\n\nvariable {\u03b1 \u03b2 \u03b3 : Type u}\n\nvariable (g : \u03b1 \u2192 F \u03b2)\n\nvariable (h : \u03b2 \u2192 G \u03b3)\n\nvariable (f : \u03b2 \u2192 \u03b3)\n\n/-- The natural applicative transformation from the identity functor\nto `F`, defined by `pure : \u03a0 {\u03b1}, \u03b1 \u2192 F \u03b1`. -/\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 {\u03b1} (x : id \u03b1) : PureTransformation F x = pure x :=\n  rfl\n#align traversable.pure_transformation_apply Traversable.pureTransformation_apply\n\nvariable {F G} (x : t \u03b2)\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 \u2218 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 \u03b1) : map f <$> traverse g x = traverse (map f \u2218 g) x := by\n  rw [map_eq_traverse_id f]\n  refine' (comp_traverse (pure \u2218 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 : \u03b2 \u2192 F \u03b3) (g : \u03b1 \u2192 \u03b2) (x : t \u03b1) :\n    traverse f (g <$> x) = traverse (f \u2218 g) x := by\n  rw [@map_eq_traverse_id t _ _ _ _ g]\n  refine' (comp_traverse (G := Id) f (pure \u2218 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 \u03b1) : traverse pure x = (pure x : F (t \u03b1)) := 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 \u03b1) : 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 \u03b1))) :\n    sequence (Comp.mk <$> x) = Comp.mk (sequence <$> sequence x) := by\n  simp [sequence, traverse_map]; rw [\u2190 comp_traverse]; simp [map_id]\n#align traversable.comp_sequence Traversable.comp_sequence\n\ntheorem naturality' (\u03b7 : ApplicativeTransformation F G) (x : t (F \u03b1)) :\n    \u03b7 (sequence x) = sequence (@\u03b7 _ <$> x) := by simp [sequence, naturality, traverse_map]\n#align traversable.naturality' Traversable.naturality'\n\n@[functor_norm]\ntheorem traverse_id : traverse pure = (pure : t \u03b1 \u2192 Id (t \u03b1)) := by\n  ext\n  exact id_traverse _\n#align traversable.traverse_id Traversable.traverse_id\n\n@[functor_norm]\ntheorem traverse_comp (g : \u03b1 \u2192 F \u03b2) (h : \u03b2 \u2192 G \u03b3) :\n    traverse (Comp.mk \u2218 map h \u2218 g) =\n      (Comp.mk \u2218 map (traverse h) \u2218 traverse g : t \u03b1 \u2192 Comp F G (t \u03b3)) := by\n  ext\n  exact comp_traverse _ _ _\n#align traversable.traverse_comp Traversable.traverse_comp\n\ntheorem traverse_eq_map_id' (f : \u03b2 \u2192 \u03b3) :\n  traverse (m := Id) (pure \u2218 f) = pure \u2218 (map f : t \u03b2 \u2192 t \u03b3) := 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 : \u03b1 \u2192 \u03b2) (h : \u03b2 \u2192 G \u03b3) :\n    traverse (h \u2218 g) = (traverse h \u2218 map g : t \u03b1 \u2192 G (t \u03b3)) := by\n  ext\n  rw [comp_apply, traverse_map]\n#align traversable.traverse_map' Traversable.traverse_map'\n\ntheorem map_traverse' (g : \u03b1 \u2192 G \u03b2) (h : \u03b2 \u2192 \u03b3) :\n    traverse (map h \u2218 g) = (map (map h) \u2218 traverse g : t \u03b1 \u2192 G (t \u03b3)) := by\n  ext\n  rw [comp_apply, map_traverse]\n#align traversable.map_traverse' Traversable.map_traverse'\n\ntheorem naturality_pf (\u03b7 : ApplicativeTransformation F G) (f : \u03b1 \u2192 F \u03b2) :\n    traverse (@\u03b7 _ \u2218 f) = @\u03b7 _ \u2218 (traverse f : t \u03b1 \u2192 F (t \u03b2)) := 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 {\u03b1 : 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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem mul_subset {S : Submonoid M} (hs : s \u2286 S) (ht : t \u2286 S) : s * t \u2286 S :=\n  by\n  rintro _ \u27e8p, q, hp, hq, rfl\u27e9\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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem mul_subset_closure (hs : s \u2286 u) (ht : t \u2286 u) : s * t \u2286 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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem coe_mul_self_eq (s : Submonoid M) : (s : Set M) * s = s :=\n  by\n  ext x\n  refine' \u27e8_, fun h => \u27e8x, 1, h, s.one_mem, mul_one x\u27e9\u27e9\n  rintro \u27e8a, b, ha, hb, rfl\u27e9\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\u2093'. -/\n@[to_additive]\ntheorem closure_mul_le (S T : Set M) : closure (S * T) \u2264 closure S \u2294 closure T :=\n  inf\u209b_le fun x \u27e8s, t, hs, ht, hx\u27e9 =>\n    hx \u25b8\n      (closure S \u2294 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\u2093.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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem sup_eq_closure (H K : Submonoid M) : H \u2294 K = closure (H * K) :=\n  le_antisymm\n    (sup_le (fun h hh => subset_closure \u27e8h, 1, hh, K.one_mem, mul_one h\u27e9) fun k hk =>\n      subset_closure \u27e81, k, H.one_mem, hk, one_mul k\u27e9)\n    (by conv_rhs => rw [\u2190 closure_eq H, \u2190 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\u2093'. -/\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 \u2208 closure s) : \u2203 n : \u2115, r ^ n \u2022 x \u2208 closure (r \u2022 s) :=\n  by\n  apply @closure_induction N _ s (fun x : N => \u2203 n : \u2115, r ^ n \u2022 x \u2208 closure (r \u2022 s)) _ hx\n  \u00b7 intro x hx\n    exact \u27e81, subset_closure \u27e8_, hx, by rw [pow_one]\u27e9\u27e9\n  \u00b7 exact \u27e80, by simpa using one_mem _\u27e9\n  \u00b7 rintro x y \u27e8nx, hx\u27e9 \u27e8ny, hy\u27e9\n    use nx + ny\n    convert mul_mem hx hy\n    rw [pow_add, smul_mul_assoc, mul_smul, mul_comm, \u2190 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)\u207b\u00b9\n      one_mem' :=\n        show (1 : G)\u207b\u00b9 \u2208 S by\n          rw [inv_one]\n          exact S.one_mem\n      mul_mem' := fun a b (ha : a\u207b\u00b9 \u2208 S) (hb : b\u207b\u00b9 \u2208 S) =>\n        show (a * b)\u207b\u00b9 \u2208 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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem coe_inv (S : Submonoid G) : \u2191S\u207b\u00b9 = (S : Set G)\u207b\u00b9 :=\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\u2093'. -/\n@[simp, to_additive]\ntheorem mem_inv {g : G} {S : Submonoid G} : g \u2208 S\u207b\u00b9 \u2194 g\u207b\u00b9 \u2208 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\u2093'. -/\n@[simp, to_additive]\ntheorem inv_le_inv (S T : Submonoid G) : S\u207b\u00b9 \u2264 T\u207b\u00b9 \u2194 S \u2264 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\u2093'. -/\n@[to_additive]\ntheorem inv_le (S T : Submonoid G) : S\u207b\u00b9 \u2264 T \u2194 S \u2264 T\u207b\u00b9 :=\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\u2093'. -/\n/-- `submonoid.has_inv` as an order isomorphism. -/\n@[to_additive \" `add_submonoid.has_neg` as an order isomorphism \", simps]\ndef invOrderIso : Submonoid G \u2243o 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\u2093'. -/\n@[to_additive]\ntheorem closure_inv (s : Set G) : closure s\u207b\u00b9 = (closure s)\u207b\u00b9 :=\n  by\n  apply le_antisymm\n  \u00b7 rw [closure_le, coe_inv, \u2190 Set.inv_subset, inv_inv]\n    exact subset_closure\n  \u00b7 rw [inv_le, closure_le, coe_inv, \u2190 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\u2093'. -/\n@[simp, to_additive]\ntheorem inv_inf (S T : Submonoid G) : (S \u2293 T)\u207b\u00b9 = S\u207b\u00b9 \u2293 T\u207b\u00b9 :=\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\u2093'. -/\n@[simp, to_additive]\ntheorem inv_sup (S T : Submonoid G) : (S \u2294 T)\u207b\u00b9 = S\u207b\u00b9 \u2294 T\u207b\u00b9 :=\n  (invOrderIso : Submonoid G \u2243o 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\u2093'. -/\n@[simp, to_additive]\ntheorem inv_bot : (\u22a5 : Submonoid G)\u207b\u00b9 = \u22a5 :=\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\u2093'. -/\n@[simp, to_additive]\ntheorem inv_top : (\u22a4 : Submonoid G)\u207b\u00b9 = \u22a4 :=\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\u1d62 /-\n@[simp, to_additive]\ntheorem inv_inf\u1d62 {\u03b9 : Sort _} (S : \u03b9 \u2192 Submonoid G) : (\u2a05 i, S i)\u207b\u00b9 = \u2a05 i, (S i)\u207b\u00b9 :=\n  (invOrderIso : Submonoid G \u2243o Submonoid G).map_inf\u1d62 _\n#align submonoid.inv_infi Submonoid.inv_inf\u1d62\n#align add_submonoid.neg_infi AddSubmonoid.neg_inf\u1d62\n-/\n\n/- warning: submonoid.inv_supr -> Submonoid.inv_sup\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {G : Type.{u1}} [_inst_3 : Group.{u1} G] {\u03b9 : Sort.{u2}} (S : \u03b9 -> (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\u1d62.{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)))))) \u03b9 (fun (i : \u03b9) => S i))) (sup\u1d62.{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)))))) \u03b9 (fun (i : \u03b9) => 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] {\u03b9 : Sort.{u2}} (S : \u03b9 -> (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\u1d62.{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)))))) \u03b9 (fun (i : \u03b9) => S i))) (sup\u1d62.{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)))))) \u03b9 (fun (i : \u03b9) => 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\u1d62\u2093'. -/\n@[simp, to_additive]\ntheorem inv_sup\u1d62 {\u03b9 : Sort _} (S : \u03b9 \u2192 Submonoid G) : (\u2a06 i, S i)\u207b\u00b9 = \u2a06 i, (S i)\u207b\u00b9 :=\n  (invOrderIso : Submonoid G \u2243o Submonoid G).map_sup\u1d62 _\n#align submonoid.inv_supr Submonoid.inv_sup\u1d62\n#align add_submonoid.neg_supr AddSubmonoid.neg_sup\u1d62\n\nend Submonoid\n\nnamespace Submonoid\n\nsection Monoid\n\nvariable [Monoid \u03b1] [MulDistribMulAction \u03b1 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 \u03b1 (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\u2081 a\u2082 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (a : \u03b1) (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\u2093.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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 _inst_3 _inst_4)) a S)) (SMul.smul.{u1, u2} \u03b1 (Set.{u2} M) (Set.smulSet.{u1, u2} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 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\u2093.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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (a : \u03b1) (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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 _inst_3 _inst_4))) a S)) (HSMul.hSMul.{u1, u2, u2} \u03b1 (Set.{u2} M) (Set.{u2} M) (instHSMul.{u1, u2} \u03b1 (Set.{u2} M) (Set.smulSet.{u1, u2} \u03b1 M (MulAction.toSMul.{u1, u2} \u03b1 M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 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\u2093'. -/\n@[simp]\ntheorem coe_pointwise_smul (a : \u03b1) (S : Submonoid M) : \u2191(a \u2022 S) = a \u2022 (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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (m : M) (a : \u03b1) (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} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1 _inst_4)) a m) (SMul.smul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 _inst_3 _inst_4)) a S))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (m : M) (a : \u03b1) (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} \u03b1 M M (instHSMul.{u1, u2} \u03b1 M (MulAction.toSMul.{u1, u2} \u03b1 M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1 _inst_4))) a m) (HSMul.hSMul.{u1, u2, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 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\u2093'. -/\ntheorem smul_mem_pointwise_smul (m : M) (a : \u03b1) (S : Submonoid M) : m \u2208 S \u2192 a \u2022 m \u2208 a \u2022 S :=\n  (Set.smul_mem_smul_set : _ \u2192 _ \u2208 a \u2022 (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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (m : M) (a : \u03b1) (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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1 _inst_4)) a s) m)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (m : M) (a : \u03b1) (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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 M M (instHSMul.{u1, u2} \u03b1 M (MulAction.toSMul.{u1, u2} \u03b1 M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 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\u2093'. -/\ntheorem mem_smul_pointwise_iff_exists (m : M) (a : \u03b1) (S : Submonoid M) :\n    m \u2208 a \u2022 S \u2194 \u2203 s : M, s \u2208 S \u2227 a \u2022 s = m :=\n  (Set.mem_smul_set : m \u2208 a \u2022 (S : Set M) \u2194 _)\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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (a : \u03b1), Eq.{succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (SMul.smul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (a : \u03b1), Eq.{succ u2} (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (HSMul.hSMul.{u1, u2, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 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\u2093'. -/\n@[simp]\ntheorem smul_bot (a : \u03b1) : a \u2022 (\u22a5 : Submonoid M) = \u22a5 :=\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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (a : \u03b1) (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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 _inst_3 _inst_4)) a S) (SMul.smul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 _inst_3 _inst_4)) a T))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] (a : \u03b1) (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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 _inst_3 _inst_4))) a S) (HSMul.hSMul.{u1, u2, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 _inst_3 _inst_4))) a T))\nCase conversion may be inaccurate. Consider using '#align submonoid.smul_sup Submonoid.smul_sup\u2093'. -/\ntheorem smul_sup (a : \u03b1) (S T : Submonoid M) : a \u2022 (S \u2294 T) = a \u2022 S \u2294 a \u2022 T :=\n  map_sup _ _ _\n#align submonoid.smul_sup Submonoid.smul_sup\n\n#print Submonoid.smul_closure /-\ntheorem smul_closure (a : \u03b1) (s : Set M) : a \u2022 closure s = closure (a \u2022 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1] [_inst_5 : MulDistribMulAction.{u1, u2} (MulOpposite.{u1} \u03b1) M (MulOpposite.monoid.{u1} \u03b1 _inst_3) _inst_1] [_inst_6 : IsCentralScalar.{u1, u2} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M _inst_3 (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M _inst_3 _inst_1 _inst_4)) (MulAction.toHasSmul.{u1, u2} (MulOpposite.{u1} \u03b1) M (MulOpposite.monoid.{u1} \u03b1 _inst_3) (MulDistribMulAction.toMulAction.{u1, u2} (MulOpposite.{u1} \u03b1) M (MulOpposite.monoid.{u1} \u03b1 _inst_3) _inst_1 _inst_5))], IsCentralScalar.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 _inst_3 _inst_4)) (MulAction.toHasSmul.{u1, u2} (MulOpposite.{u1} \u03b1) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulOpposite.monoid.{u1} \u03b1 _inst_3) (Submonoid.pointwiseMulAction.{u1, u2} (MulOpposite.{u1} \u03b1) M _inst_1 (MulOpposite.monoid.{u1} \u03b1 _inst_3) _inst_5))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : Monoid.{u2} \u03b1] [_inst_4 : MulDistribMulAction.{u2, u1} \u03b1 M _inst_3 _inst_1] [_inst_5 : MulDistribMulAction.{u2, u1} (MulOpposite.{u2} \u03b1) M (MulOpposite.monoid.{u2} \u03b1 _inst_3) _inst_1] [_inst_6 : IsCentralScalar.{u2, u1} \u03b1 M (MulAction.toSMul.{u2, u1} \u03b1 M _inst_3 (MulDistribMulAction.toMulAction.{u2, u1} \u03b1 M _inst_3 _inst_1 _inst_4)) (MulAction.toSMul.{u2, u1} (MulOpposite.{u2} \u03b1) M (MulOpposite.monoid.{u2} \u03b1 _inst_3) (MulDistribMulAction.toMulAction.{u2, u1} (MulOpposite.{u2} \u03b1) M (MulOpposite.monoid.{u2} \u03b1 _inst_3) _inst_1 _inst_5))], IsCentralScalar.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) _inst_3 (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 _inst_3 _inst_4)) (MulAction.toSMul.{u2, u1} (MulOpposite.{u2} \u03b1) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulOpposite.monoid.{u2} \u03b1 _inst_3) (Submonoid.pointwiseMulAction.{u2, u1} (MulOpposite.{u2} \u03b1) M _inst_1 (MulOpposite.monoid.{u2} \u03b1 _inst_3) _inst_5))\nCase conversion may be inaccurate. Consider using '#align submonoid.pointwise_central_scalar Submonoid.pointwise_isCentralScalar\u2093'. -/\ninstance pointwise_isCentralScalar [MulDistribMulAction \u03b1\u1d50\u1d52\u1d56 M] [IsCentralScalar \u03b1 M] :\n    IsCentralScalar \u03b1 (Submonoid M) :=\n  \u27e8fun a S => (congr_arg fun f : Monoid.End M => S.map f) <| MonoidHom.ext <| op_smul_eq_smul _\u27e9\n#align submonoid.pointwise_central_scalar Submonoid.pointwise_isCentralScalar\n\nend Monoid\n\nsection Group\n\nvariable [Group \u03b1] [MulDistribMulAction \u03b1 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1 _inst_4)) a x) (SMul.smul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 M M (instHSMul.{u1, u2} \u03b1 M (MulAction.toSMul.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1 _inst_4))) a x) (HSMul.hSMul.{u1, u2, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem smul_mem_pointwise_smul_iff {a : \u03b1} {S : Submonoid M} {x : M} : a \u2022 x \u2208 a \u2022 S \u2194 x \u2208 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1 _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) x) S)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 M M (instHSMul.{u1, u2} \u03b1 M (MulAction.toSMul.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1 _inst_4))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _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\u2093'. -/\ntheorem mem_pointwise_smul_iff_inv_smul_mem {a : \u03b1} {S : Submonoid M} {x : M} :\n    x \u2208 a \u2022 S \u2194 a\u207b\u00b9 \u2022 x \u2208 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1 _inst_4)) a x) S)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _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} \u03b1 M M (instHSMul.{u1, u2} \u03b1 M (MulAction.toSMul.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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\u2093'. -/\ntheorem mem_inv_pointwise_smul_iff {a : \u03b1} {S : Submonoid M} {x : M} : x \u2208 a\u207b\u00b9 \u2022 S \u2194 a \u2022 x \u2208 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4)) a S) (SMul.smul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4))) a S) (HSMul.hSMul.{u1, u2, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem pointwise_smul_le_pointwise_smul_iff {a : \u03b1} {S T : Submonoid M} : a \u2022 S \u2264 a \u2022 T \u2194 S \u2264 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) T))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_3)))) a) T))\nCase conversion may be inaccurate. Consider using '#align submonoid.pointwise_smul_subset_iff Submonoid.pointwise_smul_subset_iff\u2093'. -/\ntheorem pointwise_smul_subset_iff {a : \u03b1} {S T : Submonoid M} : a \u2022 S \u2264 T \u2194 S \u2264 a\u207b\u00b9 \u2022 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 {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) S) T)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1} {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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (instHSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toSMul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_3)))) a) S) T)\nCase conversion may be inaccurate. Consider using '#align submonoid.subset_pointwise_smul_iff Submonoid.subset_pointwise_smul_iff\u2093'. -/\ntheorem subset_pointwise_smul_iff {a : \u03b1} {S T : Submonoid M} : S \u2264 a \u2022 T \u2194 a\u207b\u00b9 \u2022 S \u2264 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 \u03b1] [MulDistribMulAction \u03b1 M]\n\nopen Pointwise\n\n/- warning: submonoid.smul_mem_pointwise_smul_iff\u2080 -> Submonoid.smul_mem_pointwise_smul_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1 _inst_4)) a x) (SMul.smul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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 {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : MulDistribMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 M M (instHSMul.{u2, u1} \u03b1 M (MulAction.toSMul.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1 _inst_4))) a x) (HSMul.hSMul.{u2, u1, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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\u2080 Submonoid.smul_mem_pointwise_smul_iff\u2080\u2093'. -/\n@[simp]\ntheorem smul_mem_pointwise_smul_iff\u2080 {a : \u03b1} (ha : a \u2260 0) (S : Submonoid M) (x : M) :\n    a \u2022 x \u2208 a \u2022 S \u2194 x \u2208 S :=\n  smul_mem_smul_set_iff\u2080 ha (S : Set M) x\n#align submonoid.smul_mem_pointwise_smul_iff\u2080 Submonoid.smul_mem_pointwise_smul_iff\u2080\n\n/- warning: submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080 -> Submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1 _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) x) S))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : MulDistribMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 M M (instHSMul.{u2, u1} \u03b1 M (MulAction.toSMul.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1 _inst_4))) (Inv.inv.{u2} \u03b1 (GroupWithZero.toInv.{u2} \u03b1 _inst_3) a) x) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080 Submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080\u2093'. -/\ntheorem mem_pointwise_smul_iff_inv_smul_mem\u2080 {a : \u03b1} (ha : a \u2260 0) (S : Submonoid M) (x : M) :\n    x \u2208 a \u2022 S \u2194 a\u207b\u00b9 \u2022 x \u2208 S :=\n  mem_smul_set_iff_inv_smul_mem\u2080 ha (S : Set M) x\n#align submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080 Submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080\n\n/- warning: submonoid.mem_inv_pointwise_smul_iff\u2080 -> Submonoid.mem_inv_pointwise_smul_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 M (MulAction.toHasSmul.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1 _inst_4)) a x) S))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : MulDistribMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u2} \u03b1 (GroupWithZero.toInv.{u2} \u03b1 _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} \u03b1 M M (instHSMul.{u2, u1} \u03b1 M (MulAction.toSMul.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (MulDistribMulAction.toMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1 _inst_4))) a x) S))\nCase conversion may be inaccurate. Consider using '#align submonoid.mem_inv_pointwise_smul_iff\u2080 Submonoid.mem_inv_pointwise_smul_iff\u2080\u2093'. -/\ntheorem mem_inv_pointwise_smul_iff\u2080 {a : \u03b1} (ha : a \u2260 0) (S : Submonoid M) (x : M) :\n    x \u2208 a\u207b\u00b9 \u2022 S \u2194 a \u2022 x \u2208 S :=\n  mem_inv_smul_set_iff\u2080 ha (S : Set M) x\n#align submonoid.mem_inv_pointwise_smul_iff\u2080 Submonoid.mem_inv_pointwise_smul_iff\u2080\n\n/- warning: submonoid.pointwise_smul_le_pointwise_smul_iff\u2080 -> Submonoid.pointwise_smul_le_pointwise_smul_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_4)) a S) (SMul.smul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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 {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : MulDistribMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_4))) a S) (HSMul.hSMul.{u2, u1, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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\u2080 Submonoid.pointwise_smul_le_pointwise_smul_iff\u2080\u2093'. -/\n@[simp]\ntheorem pointwise_smul_le_pointwise_smul_iff\u2080 {a : \u03b1} (ha : a \u2260 0) {S T : Submonoid M} :\n    a \u2022 S \u2264 a \u2022 T \u2194 S \u2264 T :=\n  set_smul_subset_set_smul_iff\u2080 ha\n#align submonoid.pointwise_smul_le_pointwise_smul_iff\u2080 Submonoid.pointwise_smul_le_pointwise_smul_iff\u2080\n\n/- warning: submonoid.pointwise_smul_le_iff\u2080 -> Submonoid.pointwise_smul_le_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) T)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : MulDistribMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u2} \u03b1 (GroupWithZero.toInv.{u2} \u03b1 _inst_3) a) T)))\nCase conversion may be inaccurate. Consider using '#align submonoid.pointwise_smul_le_iff\u2080 Submonoid.pointwise_smul_le_iff\u2080\u2093'. -/\ntheorem pointwise_smul_le_iff\u2080 {a : \u03b1} (ha : a \u2260 0) {S T : Submonoid M} : a \u2022 S \u2264 T \u2194 S \u2264 a\u207b\u00b9 \u2022 T :=\n  set_smul_subset_iff\u2080 ha\n#align submonoid.pointwise_smul_le_iff\u2080 Submonoid.pointwise_smul_le_iff\u2080\n\n/- warning: submonoid.le_pointwise_smul_iff\u2080 -> Submonoid.le_pointwise_smul_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {M : Type.{u2}} [_inst_1 : Monoid.{u2} M] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : MulDistribMulAction.{u1, u2} \u03b1 M (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MulAction.toHasSmul.{u1, u2} \u03b1 (Submonoid.{u2} M (Monoid.toMulOneClass.{u2} M _inst_1)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u1, u2} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) S) T))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {M : Type.{u1}} [_inst_1 : Monoid.{u1} M] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : MulDistribMulAction.{u2, u1} \u03b1 M (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_1] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (instHSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MulAction.toSMul.{u2, u1} \u03b1 (Submonoid.{u1} M (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (Submonoid.pointwiseMulAction.{u2, u1} \u03b1 M _inst_1 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u2} \u03b1 (GroupWithZero.toInv.{u2} \u03b1 _inst_3) a) S) T))\nCase conversion may be inaccurate. Consider using '#align submonoid.le_pointwise_smul_iff\u2080 Submonoid.le_pointwise_smul_iff\u2080\u2093'. -/\ntheorem le_pointwise_smul_iff\u2080 {a : \u03b1} (ha : a \u2260 0) {S T : Submonoid M} : S \u2264 a \u2022 T \u2194 a\u207b\u00b9 \u2022 S \u2264 T :=\n  subset_set_smul_iff\u2080 ha\n#align submonoid.le_pointwise_smul_iff\u2080 Submonoid.le_pointwise_smul_iff\u2080\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\u2093'. -/\n@[to_additive]\ntheorem mem_closure_inv {G : Type _} [Group G] (S : Set G) (x : G) :\n    x \u2208 Submonoid.closure S\u207b\u00b9 \u2194 x\u207b\u00b9 \u2208 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 \u03b1] [DistribMulAction \u03b1 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 \u03b1 (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\u2081 a\u2082 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (a : \u03b1) (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\u2093.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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 _inst_3 _inst_4)) a S)) (SMul.smul.{u1, u2} \u03b1 (Set.{u2} A) (Set.smulSet.{u1, u2} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 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\u2093.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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (a : \u03b1) (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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 _inst_3 _inst_4))) a S)) (HSMul.hSMul.{u1, u2, u2} \u03b1 (Set.{u2} A) (Set.{u2} A) (instHSMul.{u1, u2} \u03b1 (Set.{u2} A) (Set.smulSet.{u1, u2} \u03b1 A (SMulZeroClass.toSMul.{u1, u2} \u03b1 A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 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\u2093'. -/\n@[simp]\ntheorem coe_pointwise_smul (a : \u03b1) (S : AddSubmonoid A) : \u2191(a \u2022 S) = a \u2022 (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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (m : A) (a : \u03b1) (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} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A _inst_3 _inst_2 _inst_4))) a m) (SMul.smul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 _inst_3 _inst_4)) a S))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (m : A) (a : \u03b1) (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} \u03b1 A A (instHSMul.{u1, u2} \u03b1 A (SMulZeroClass.toSMul.{u1, u2} \u03b1 A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A _inst_3 _inst_2 _inst_4)))) a m) (HSMul.hSMul.{u1, u2, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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\u2093'. -/\ntheorem smul_mem_pointwise_smul (m : A) (a : \u03b1) (S : AddSubmonoid A) : m \u2208 S \u2192 a \u2022 m \u2208 a \u2022 S :=\n  (Set.smul_mem_smul_set : _ \u2192 _ \u2208 a \u2022 (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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (m : A) (a : \u03b1) (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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A _inst_3 _inst_2 _inst_4))) a s) m)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (m : A) (a : \u03b1) (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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 A A (instHSMul.{u1, u2} \u03b1 A (SMulZeroClass.toSMul.{u1, u2} \u03b1 A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 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\u2093'. -/\ntheorem mem_smul_pointwise_iff_exists (m : A) (a : \u03b1) (S : AddSubmonoid A) :\n    m \u2208 a \u2022 S \u2194 \u2203 s : A, s \u2208 S \u2227 a \u2022 s = m :=\n  (Set.mem_smul_set : m \u2208 a \u2022 (S : Set A) \u2194 _)\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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (a : \u03b1), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SMul.smul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (a : \u03b1), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (HSMul.hSMul.{u1, u2, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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\u2093'. -/\n@[simp]\ntheorem smul_bot (a : \u03b1) : a \u2022 (\u22a5 : AddSubmonoid A) = \u22a5 :=\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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (a : \u03b1) (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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 _inst_3 _inst_4)) a S) (SMul.smul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 _inst_3 _inst_4)) a T))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (a : \u03b1) (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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 _inst_3 _inst_4))) a S) (HSMul.hSMul.{u1, u2, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 _inst_3 _inst_4))) a T))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.smul_sup AddSubmonoid.smul_sup\u2093'. -/\ntheorem smul_sup (a : \u03b1) (S T : AddSubmonoid A) : a \u2022 (S \u2294 T) = a \u2022 S \u2294 a \u2022 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (a : \u03b1) (s : Set.{u2} A), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (SMul.smul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 (Set.{u2} A) (Set.smulSet.{u1, u2} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A _inst_3 _inst_2 _inst_4)))) a s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] (a : \u03b1) (s : Set.{u2} A), Eq.{succ u2} (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (HSMul.hSMul.{u1, u2, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 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} \u03b1 (Set.{u2} A) (Set.{u2} A) (instHSMul.{u1, u2} \u03b1 (Set.{u2} A) (Set.smulSet.{u1, u2} \u03b1 A (SMulZeroClass.toSMul.{u1, u2} \u03b1 A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A _inst_3 _inst_2 _inst_4))))) a s))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.smul_closure AddSubmonoid.smul_closure\u2093'. -/\n@[simp]\ntheorem smul_closure (a : \u03b1) (s : Set A) : a \u2022 closure s = closure (a \u2022 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Monoid.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A _inst_3 _inst_2] [_inst_5 : DistribMulAction.{u1, u2} (MulOpposite.{u1} \u03b1) A (MulOpposite.monoid.{u1} \u03b1 _inst_3) _inst_2] [_inst_6 : IsCentralScalar.{u1, u2} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A _inst_3 _inst_2 _inst_4))) (SMulZeroClass.toHasSmul.{u1, u2} (MulOpposite.{u1} \u03b1) A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} (MulOpposite.{u1} \u03b1) A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} (MulOpposite.{u1} \u03b1) A (MulOpposite.monoid.{u1} \u03b1 _inst_3) _inst_2 _inst_5)))], IsCentralScalar.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 _inst_3 _inst_4)) (MulAction.toHasSmul.{u1, u2} (MulOpposite.{u1} \u03b1) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulOpposite.monoid.{u1} \u03b1 _inst_3) (AddSubmonoid.pointwiseMulAction.{u1, u2} (MulOpposite.{u1} \u03b1) A _inst_2 (MulOpposite.monoid.{u1} \u03b1 _inst_3) _inst_5))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : Monoid.{u2} \u03b1] [_inst_4 : DistribMulAction.{u2, u1} \u03b1 A _inst_3 _inst_2] [_inst_5 : DistribMulAction.{u2, u1} (MulOpposite.{u2} \u03b1) A (MulOpposite.monoid.{u2} \u03b1 _inst_3) _inst_2] [_inst_6 : IsCentralScalar.{u2, u1} \u03b1 A (SMulZeroClass.toSMul.{u2, u1} \u03b1 A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} \u03b1 A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} \u03b1 A _inst_3 _inst_2 _inst_4))) (SMulZeroClass.toSMul.{u2, u1} (MulOpposite.{u2} \u03b1) A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} (MulOpposite.{u2} \u03b1) A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} (MulOpposite.{u2} \u03b1) A (MulOpposite.monoid.{u2} \u03b1 _inst_3) _inst_2 _inst_5)))], IsCentralScalar.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) _inst_3 (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 _inst_3 _inst_4)) (MulAction.toSMul.{u2, u1} (MulOpposite.{u2} \u03b1) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulOpposite.monoid.{u2} \u03b1 _inst_3) (AddSubmonoid.pointwiseMulAction.{u2, u1} (MulOpposite.{u2} \u03b1) A _inst_2 (MulOpposite.monoid.{u2} \u03b1 _inst_3) _inst_5))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pointwise_central_scalar AddSubmonoid.pointwise_isCentralScalar\u2093'. -/\ninstance pointwise_isCentralScalar [DistribMulAction \u03b1\u1d50\u1d52\u1d56 A] [IsCentralScalar \u03b1 A] :\n    IsCentralScalar \u03b1 (AddSubmonoid A) :=\n  \u27e8fun a S =>\n    (congr_arg fun f : AddMonoid.End A => S.map f) <| AddMonoidHom.ext <| op_smul_eq_smul _\u27e9\n#align add_submonoid.pointwise_central_scalar AddSubmonoid.pointwise_isCentralScalar\n\nend Monoid\n\nsection Group\n\nvariable [Group \u03b1] [DistribMulAction \u03b1 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2 _inst_4))) a x) (SMul.smul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 A A (instHSMul.{u1, u2} \u03b1 A (SMulZeroClass.toSMul.{u1, u2} \u03b1 A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2 _inst_4)))) a x) (HSMul.hSMul.{u1, u2, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem smul_mem_pointwise_smul_iff {a : \u03b1} {S : AddSubmonoid A} {x : A} : a \u2022 x \u2208 a \u2022 S \u2194 x \u2208 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2 _inst_4))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) x) S)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 A A (instHSMul.{u1, u2} \u03b1 A (SMulZeroClass.toSMul.{u1, u2} \u03b1 A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2 _inst_4)))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _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\u2093'. -/\ntheorem mem_pointwise_smul_iff_inv_smul_mem {a : \u03b1} {S : AddSubmonoid A} {x : A} :\n    x \u2208 a \u2022 S \u2194 a\u207b\u00b9 \u2022 x \u2208 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2 _inst_4))) a x) S)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _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} \u03b1 A A (instHSMul.{u1, u2} \u03b1 A (SMulZeroClass.toSMul.{u1, u2} \u03b1 A (AddMonoid.toZero.{u2} A _inst_2) (DistribSMul.toSMulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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\u2093'. -/\ntheorem mem_inv_pointwise_smul_iff {a : \u03b1} {S : AddSubmonoid A} {x : A} : x \u2208 a\u207b\u00b9 \u2022 S \u2194 a \u2022 x \u2208 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4)) a S) (SMul.smul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4))) a S) (HSMul.hSMul.{u1, u2, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem pointwise_smul_le_pointwise_smul_iff {a : \u03b1} {S T : AddSubmonoid A} :\n    a \u2022 S \u2264 a \u2022 T \u2194 S \u2264 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) T))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_3)))) a) T))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pointwise_smul_le_iff AddSubmonoid.pointwise_smul_le_iff\u2093'. -/\ntheorem pointwise_smul_le_iff {a : \u03b1} {S T : AddSubmonoid A} : a \u2022 S \u2264 T \u2194 S \u2264 a\u207b\u00b9 \u2022 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 {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) S) T)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : Group.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1} {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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (instHSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toSMul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u1} \u03b1 (InvOneClass.toInv.{u1} \u03b1 (DivInvOneMonoid.toInvOneClass.{u1} \u03b1 (DivisionMonoid.toDivInvOneMonoid.{u1} \u03b1 (Group.toDivisionMonoid.{u1} \u03b1 _inst_3)))) a) S) T)\nCase conversion may be inaccurate. Consider using '#align add_submonoid.le_pointwise_smul_iff AddSubmonoid.le_pointwise_smul_iff\u2093'. -/\ntheorem le_pointwise_smul_iff {a : \u03b1} {S T : AddSubmonoid A} : S \u2264 a \u2022 T \u2194 a\u207b\u00b9 \u2022 S \u2264 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 \u03b1] [DistribMulAction \u03b1 A]\n\nopen Pointwise\n\n/- warning: add_submonoid.smul_mem_pointwise_smul_iff\u2080 -> AddSubmonoid.smul_mem_pointwise_smul_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2 _inst_4))) a x) (SMul.smul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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 {\u03b1 : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : DistribMulAction.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 A A (instHSMul.{u2, u1} \u03b1 A (SMulZeroClass.toSMul.{u2, u1} \u03b1 A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} \u03b1 A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2 _inst_4)))) a x) (HSMul.hSMul.{u2, u1, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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\u2080 AddSubmonoid.smul_mem_pointwise_smul_iff\u2080\u2093'. -/\n@[simp]\ntheorem smul_mem_pointwise_smul_iff\u2080 {a : \u03b1} (ha : a \u2260 0) (S : AddSubmonoid A) (x : A) :\n    a \u2022 x \u2208 a \u2022 S \u2194 x \u2208 S :=\n  smul_mem_smul_set_iff\u2080 ha (S : Set A) x\n#align add_submonoid.smul_mem_pointwise_smul_iff\u2080 AddSubmonoid.smul_mem_pointwise_smul_iff\u2080\n\n/- warning: add_submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080 -> AddSubmonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2 _inst_4))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) x) S))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : DistribMulAction.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 A A (instHSMul.{u2, u1} \u03b1 A (SMulZeroClass.toSMul.{u2, u1} \u03b1 A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} \u03b1 A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2 _inst_4)))) (Inv.inv.{u2} \u03b1 (GroupWithZero.toInv.{u2} \u03b1 _inst_3) a) x) S))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080 AddSubmonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080\u2093'. -/\ntheorem mem_pointwise_smul_iff_inv_smul_mem\u2080 {a : \u03b1} (ha : a \u2260 0) (S : AddSubmonoid A) (x : A) :\n    x \u2208 a \u2022 S \u2194 a\u207b\u00b9 \u2022 x \u2208 S :=\n  mem_smul_set_iff_inv_smul_mem\u2080 ha (S : Set A) x\n#align add_submonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080 AddSubmonoid.mem_pointwise_smul_iff_inv_smul_mem\u2080\n\n/- warning: add_submonoid.mem_inv_pointwise_smul_iff\u2080 -> AddSubmonoid.mem_inv_pointwise_smul_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _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} \u03b1 A (SMulZeroClass.toHasSmul.{u1, u2} \u03b1 A (AddZeroClass.toHasZero.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (DistribSMul.toSmulZeroClass.{u1, u2} \u03b1 A (AddMonoid.toAddZeroClass.{u2} A _inst_2) (DistribMulAction.toDistribSMul.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2 _inst_4))) a x) S))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : DistribMulAction.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u2} \u03b1 (GroupWithZero.toInv.{u2} \u03b1 _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} \u03b1 A A (instHSMul.{u2, u1} \u03b1 A (SMulZeroClass.toSMul.{u2, u1} \u03b1 A (AddMonoid.toZero.{u1} A _inst_2) (DistribSMul.toSMulZeroClass.{u2, u1} \u03b1 A (AddMonoid.toAddZeroClass.{u1} A _inst_2) (DistribMulAction.toDistribSMul.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2 _inst_4)))) a x) S))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.mem_inv_pointwise_smul_iff\u2080 AddSubmonoid.mem_inv_pointwise_smul_iff\u2080\u2093'. -/\ntheorem mem_inv_pointwise_smul_iff\u2080 {a : \u03b1} (ha : a \u2260 0) (S : AddSubmonoid A) (x : A) :\n    x \u2208 a\u207b\u00b9 \u2022 S \u2194 a \u2022 x \u2208 S :=\n  mem_inv_smul_set_iff\u2080 ha (S : Set A) x\n#align add_submonoid.mem_inv_pointwise_smul_iff\u2080 AddSubmonoid.mem_inv_pointwise_smul_iff\u2080\n\n/- warning: add_submonoid.pointwise_smul_le_pointwise_smul_iff\u2080 -> AddSubmonoid.pointwise_smul_le_pointwise_smul_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_4)) a S) (SMul.smul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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 {\u03b1 : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : DistribMulAction.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_4))) a S) (HSMul.hSMul.{u2, u1, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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\u2080 AddSubmonoid.pointwise_smul_le_pointwise_smul_iff\u2080\u2093'. -/\n@[simp]\ntheorem pointwise_smul_le_pointwise_smul_iff\u2080 {a : \u03b1} (ha : a \u2260 0) {S T : AddSubmonoid A} :\n    a \u2022 S \u2264 a \u2022 T \u2194 S \u2264 T :=\n  set_smul_subset_set_smul_iff\u2080 ha\n#align add_submonoid.pointwise_smul_le_pointwise_smul_iff\u2080 AddSubmonoid.pointwise_smul_le_pointwise_smul_iff\u2080\n\n/- warning: add_submonoid.pointwise_smul_le_iff\u2080 -> AddSubmonoid.pointwise_smul_le_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) T)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : DistribMulAction.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u2} \u03b1 (GroupWithZero.toInv.{u2} \u03b1 _inst_3) a) T)))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.pointwise_smul_le_iff\u2080 AddSubmonoid.pointwise_smul_le_iff\u2080\u2093'. -/\ntheorem pointwise_smul_le_iff\u2080 {a : \u03b1} (ha : a \u2260 0) {S T : AddSubmonoid A} :\n    a \u2022 S \u2264 T \u2194 S \u2264 a\u207b\u00b9 \u2022 T :=\n  set_smul_subset_iff\u2080 ha\n#align add_submonoid.pointwise_smul_le_iff\u2080 AddSubmonoid.pointwise_smul_le_iff\u2080\n\n/- warning: add_submonoid.le_pointwise_smul_iff\u2080 -> AddSubmonoid.le_pointwise_smul_iff\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {A : Type.{u2}} [_inst_2 : AddMonoid.{u2} A] [_inst_3 : GroupWithZero.{u1} \u03b1] [_inst_4 : DistribMulAction.{u1, u2} \u03b1 A (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u1} \u03b1 a (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _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} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MulAction.toHasSmul.{u1, u2} \u03b1 (AddSubmonoid.{u2} A (AddMonoid.toAddZeroClass.{u2} A _inst_2)) (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u1, u2} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_3)) _inst_4)) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _inst_3)) a) S) T))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {A : Type.{u1}} [_inst_2 : AddMonoid.{u1} A] [_inst_3 : GroupWithZero.{u2} \u03b1] [_inst_4 : DistribMulAction.{u2, u1} \u03b1 A (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_2] {a : \u03b1}, (Ne.{succ u2} \u03b1 a (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (MonoidWithZero.toZero.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _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} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (instHSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MulAction.toSMul.{u2, u1} \u03b1 (AddSubmonoid.{u1} A (AddMonoid.toAddZeroClass.{u1} A _inst_2)) (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) (AddSubmonoid.pointwiseMulAction.{u2, u1} \u03b1 A _inst_2 (MonoidWithZero.toMonoid.{u2} \u03b1 (GroupWithZero.toMonoidWithZero.{u2} \u03b1 _inst_3)) _inst_4))) (Inv.inv.{u2} \u03b1 (GroupWithZero.toInv.{u2} \u03b1 _inst_3) a) S) T))\nCase conversion may be inaccurate. Consider using '#align add_submonoid.le_pointwise_smul_iff\u2080 AddSubmonoid.le_pointwise_smul_iff\u2080\u2093'. -/\ntheorem le_pointwise_smul_iff\u2080 {a : \u03b1} (ha : a \u2260 0) {S T : AddSubmonoid A} :\n    S \u2264 a \u2022 T \u2194 a\u207b\u00b9 \u2022 S \u2264 T :=\n  subset_set_smul_iff\u2080 ha\n#align add_submonoid.le_pointwise_smul_iff\u2080 AddSubmonoid.le_pointwise_smul_iff\u2080\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  \u27e8(Nat.castAddMonoidHom R).mrange\u27e9\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\u2093.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\u2093'. -/\ntheorem natCast_mem_one (n : \u2115) : (n : R) \u2208 (1 : AddSubmonoid R) :=\n  \u27e8_, rfl\u27e9\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\u2093.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\u2093'. -/\n@[simp]\ntheorem mem_one {x : R} : x \u2208 (1 : AddSubmonoid R) \u2194 \u2203 n : \u2115, \u2191n = 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 \u2208 S` and `t \u2208 T`. -/\ninstance : Mul (AddSubmonoid R) :=\n  \u27e8fun M N => \u2a06 s : M, N.map <| AddMonoidHom.mul s.1\u27e9\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\u2093'. -/\ntheorem mul_mem_mul {M N : AddSubmonoid R} {m n : R} (hm : m \u2208 M) (hn : n \u2208 N) : m * n \u2208 M * N :=\n  (le_sup\u1d62 _ \u27e8m, hm\u27e9 : _ \u2264 M * N) \u27e8n, hn, rfl\u27e9\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\u2093'. -/\ntheorem mul_le {M N P : AddSubmonoid R} : M * N \u2264 P \u2194 \u2200 m \u2208 M, \u2200 n \u2208 N, m * n \u2208 P :=\n  \u27e8fun H m hm n hn => H <| mul_mem_mul hm hn, fun H =>\n    sup\u1d62_le fun \u27e8m, hm\u27e9 => map_le_iff_le_comap.2 fun n hn => H m hm n hn\u27e9\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\u2093'. -/\n@[elab_as_elim]\nprotected theorem mul_induction_on {M N : AddSubmonoid R} {C : R \u2192 Prop} {r : R} (hr : r \u2208 M * N)\n    (hm : \u2200 m \u2208 M, \u2200 n \u2208 N, C (m * n)) (ha : \u2200 x y, C x \u2192 C y \u2192 C (x + y)) : C r :=\n  (@mul_le _ _ _ _\n        \u27e8C, ha, by simpa only [MulZeroClass.zero_mul] using hm _ (zero_mem _) _ (zero_mem _)\u27e9).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\u2093'. -/\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  \u00b7 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 \u27e8_, _, \u2039_\u203a, \u2039_\u203a, rfl\u27e9\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  \u00b7 rw [closure_le]\n    rintro _ \u27e8a, b, ha, hb, rfl\u27e9\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\u2093.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\u2093.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\u2093'. -/\ntheorem mul_eq_closure_mul_set (M N : AddSubmonoid R) : M * N = closure (M * N) := by\n  rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem mul_bot (S : AddSubmonoid R) : S * \u22a5 = \u22a5 :=\n  eq_bot_iff.2 <|\n    mul_le.2 fun m hm n hn => by rw [AddSubmonoid.mem_bot] at hn\u22a2 <;> 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\u2093'. -/\n@[simp]\ntheorem bot_mul (S : AddSubmonoid R) : \u22a5 * S = \u22a5 :=\n  eq_bot_iff.2 <|\n    mul_le.2 fun m hm n hn => by rw [AddSubmonoid.mem_bot] at hm\u22a2 <;> 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\u2093'. -/\n@[mono]\ntheorem mul_le_mul {M N P Q : AddSubmonoid R} (hmp : M \u2264 P) (hnq : N \u2264 Q) : M * N \u2264 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\u2093'. -/\ntheorem mul_le_mul_left {M N P : AddSubmonoid R} (h : M \u2264 N) : M * P \u2264 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\u2093'. -/\ntheorem mul_le_mul_right {M N P : AddSubmonoid R} (h : N \u2264 P) : M * N \u2264 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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem mul_subset_mul {M N : AddSubmonoid R} : (\u2191M : Set R) * (\u2191N : Set R) \u2286 (\u2191(M * N) : Set R) :=\n  by\n  rintro _ \u27e8i, j, hi, hj, rfl\u27e9\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\u2093'. -/\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, \u2190 neg_mul] at *\n      \u00b7 exact mul_mem_mul hm hn\n      \u00b7 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, \u2190 mul_neg] at *\n      \u00b7 exact mul_mem_mul hm hn\n      \u00b7 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 := (\u00b7 * \u00b7)\n  one_mul M := by rw [one_eq_closure_one_set, \u2190 closure_eq M, closure_mul_closure, one_mul]\n  mul_one M := by rw [one_eq_closure_one_set, \u2190 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 := (\u00b7 * \u00b7)\n  mul_assoc M N P :=\n    le_antisymm\n      (mul_le.2 fun mn hmn p hp =>\n        suffices M * N \u2264 (M * (N * P)).comap (AddMonoidHom.mulRight p) from this hmn\n        mul_le.2 fun m hm n hn =>\n          show m * n * p \u2208 M * (N * P) from\n            (mul_assoc m n p).symm \u25b8 mul_mem_mul hm (mul_mem_mul hn hp))\n      (mul_le.2 fun m hm np hnp =>\n        suffices N * P \u2264 (M * N * P).comap (AddMonoidHom.mulLeft m) from this hnp\n        mul_le.2 fun n hn p hp =>\n          show m * (n * p) \u2208 M * N * P from mul_assoc m n p \u25b8 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 := (\u00b7 * \u00b7) }\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\u2093'. -/\ntheorem closure_pow (s : Set R) : \u2200 n : \u2115, 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\u2093.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\u2093'. -/\ntheorem pow_eq_closure_pow_set (s : AddSubmonoid R) (n : \u2115) : s ^ n = closure ((s : Set R) ^ n) :=\n  by rw [\u2190 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\u2093.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\u2093.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\u2093'. -/\ntheorem pow_subset_pow {s : AddSubmonoid R} {n : \u2115} : (\u2191s : Set R) ^ n \u2286 \u2191(s ^ n) :=\n  (pow_eq_closure_pow_set s n).symm \u25b8 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 \u03b1] {s : Set \u03b1}\n\n/- warning: set.is_pwo.submonoid_closure -> Set.IsPwo.submonoid_closure is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_3 : OrderedCancelCommMonoid.{u1} \u03b1] {s : Set.{u1} \u03b1}, (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelCommMonoid.toPartialOrder.{u1} \u03b1 _inst_3))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3))))))))) x)) -> (Set.IsPwo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelCommMonoid.toPartialOrder.{u1} \u03b1 _inst_3)) s) -> (Set.IsPwo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelCommMonoid.toPartialOrder.{u1} \u03b1 _inst_3)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Submonoid.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3)))))) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Submonoid.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3)))))) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Submonoid.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3)))))) (Set.{u1} \u03b1) (SetLike.Set.hasCoeT.{u1, u1} (Submonoid.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3)))))) \u03b1 (Submonoid.setLike.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3))))))))) (Submonoid.closure.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3))))) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_3 : OrderedCancelCommMonoid.{u1} \u03b1] {s : Set.{u1} \u03b1}, (forall (x : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelCommMonoid.toPartialOrder.{u1} \u03b1 _inst_3))) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (RightCancelMonoid.toOne.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3)))))) x)) -> (Set.IsPwo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelCommMonoid.toPartialOrder.{u1} \u03b1 _inst_3)) s) -> (Set.IsPwo.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelCommMonoid.toPartialOrder.{u1} \u03b1 _inst_3)) (SetLike.coe.{u1, u1} (Submonoid.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3)))))) \u03b1 (Submonoid.instSetLikeSubmonoid.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3)))))) (Submonoid.closure.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (RightCancelMonoid.toMonoid.{u1} \u03b1 (CancelMonoid.toRightCancelMonoid.{u1} \u03b1 (CancelCommMonoid.toCancelMonoid.{u1} \u03b1 (OrderedCancelCommMonoid.toCancelCommMonoid.{u1} \u03b1 _inst_3))))) s)))\nCase conversion may be inaccurate. Consider using '#align set.is_pwo.submonoid_closure Set.IsPwo.submonoid_closure\u2093'. -/\n@[to_additive]\ntheorem submonoid_closure (hpos : \u2200 x : \u03b1, x \u2208 s \u2192 1 \u2264 x) (h : s.IsPwo) :\n    IsPwo (Submonoid.closure s : Set \u03b1) :=\n  by\n  rw [Submonoid.closure_eq_image_prod]\n  refine' (h.partially_well_ordered_on_sublist_forall\u2082 (\u00b7 \u2264 \u00b7)).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 (\u03b1 : Type u) (\u03b2 : Type v)\n| mk : \u03b1 \u2192 \u03b2 \u2192 Prod \u03b1 \u03b2\n\ninductive Sum (\u03b1 : Type u) (\u03b2 : Type v) where\n| inl : \u03b1 \u2192 Sum \u03b1 \u03b2\n| inr : \u03b2 \u2192 Sum \u03b1 \u03b2\n\ndef fst {\u03b1 : Type u} {\u03b2 : Type v} (p : Prod \u03b1 \u03b2) : \u03b1 :=\n  match p with\n  | Prod.mk a b => a\n\ndef snd {\u03b1 : Type u} {\u03b2 : Type v} (p : Prod \u03b1 \u03b2) : \u03b2 :=\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 \u00d7 Nat) : Nat :=\n  Prod.casesOn (motive := \u03bb _ => Nat) p (\u03bb 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 := \u03bb _ => Nat) s (\u03bb n => 2 * n) (\u03bb 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 (\u03b1 : Type u) (\u03b2 : Type v)\n| mk (fst : \u03b1) (snd : \u03b2) : Prod \u03b1 \u03b2\n\ninductive Sum (\u03b1 : Type u) (\u03b2 : Type v)\n| inl (a : \u03b1) : Sum \u03b1 \u03b2\n| inr (b : \u03b2) : Sum \u03b1 \u03b2\n\nend named_arguments\n\nnamespace structures\n\nstructure Prod (\u03b1 : Type u) (\u03b2 : Type v) where\n  mk :: (fst : \u03b1) (snd : \u03b2)\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 \u2192 carrier \u2192 carrier\n  mul_assoc : \u2200 a b c, mul (mul a b) c = mul a (mul b c)\n\nend structures\n\nnamespace more_std_examples\n\ninductive Sigma {\u03b1 : Type u} (\u03b2 : \u03b1 \u2192 Type v) where\n| mk : (a : \u03b1) \u2192 \u03b2 a \u2192 Sigma \u03b2\n\ninductive Option (\u03b1 : Type u) where\n| none : Option \u03b1\n| some : \u03b1 \u2192 Option \u03b1\n\ninductive Inhabited (\u03b1 : Type u) where\n| mk : \u03b1 \u2192 Inhabited \u03b1\n\nend more_std_examples\n\n-- Exercises\n-- develop a notion of composition of partial functions\ndef compose\n    {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n    (f : \u03b2 \u2192 Option \u03b3) (g : \u03b1 \u2192 Option \u03b2) (x : \u03b1) : Option \u03b3 :=\n  match g x with\n  | some (y : \u03b2) => f y\n  | none => none\n\n-- show that it behaves as expected\ndef partial_id {\u03b1 : Type u} : \u03b1 \u2192 Option \u03b1 := some\ndef partial_none {\u03b1 : Type u} : \u03b1 \u2192 Option \u03b1 := \u03bb _ => 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    {\u03b1 : Type u} {\u03b2 : Type v} (ia : Inhabited \u03b1) (ib : Inhabited \u03b2)\n    : Inhabited (\u03b1 \u00d7 \u03b2) :=\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    {\u03b1 : Type u} {\u03b2 : Type v} (ib : Inhabited \u03b2)\n    : Inhabited (\u03b1 \u2192 \u03b2) :=\n  let (Inhabited.mk b) := ib\n  Inhabited.mk (\u03bb _ => 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 \u2192 b \u2192 And a b\n\ninductive Or (a b : Prop) : Prop where\n| inl : a \u2192 Or a b\n| inr : b \u2192 Or a b\n\ninductive Exists {\u03b1 : Type u} (q : \u03b1 \u2192 Prop) : Prop where\n| intro : \u2200 (a : \u03b1), q a \u2192 Exists q\n\ninductive Subtype {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) where\n| mk : (x : \u03b1) \u2192 p x \u2192 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 \u2192 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 := \u03bb 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 := \u03bb x => 0 + x = x)\n    n\n    rfl\n    (\u03bb 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 := \u03bb k => (m + n) + k = m + (n + k)) k\n  \u00b7 show (m + n) + 0 = m + (n + 0)\n    rfl\n  \u00b7 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 := \u03bb k => (m + n) + k = m + (n + k)) k\n  \u00b7 rfl\n  \u00b7 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 := \u03bb x => succ n + x = succ (n + x))\n  \u00b7 show succ n + 0 = succ (n + 0)\n    rfl\n  \u00b7 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 := \u03bb x => m + x = x + m) n\n  \u00b7 show m + 0 = 0 + m\n    rw [Nat.zero_add, Nat.add_zero]\n  \u00b7 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 := \u03bb x => succ n + x = succ (n + x))\n  \u00b7 simp\n  \u00b7 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 := \u03bb x => m + x = x + m) n\n  \u00b7 simp\n  \u00b7 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 (\u03b1 : Type u) where\n| nil : List \u03b1\n| cons : \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\n\nnamespace List\n\ndef append (as bs : List \u03b1) : List \u03b1 :=\n  match as with\n  | nil => bs\n  | cons a as => cons a (append as bs)\n\ntheorem nil_append (as : List \u03b1) : append nil as = as := rfl\n\ntheorem cons_append\n    (a : \u03b1) (as bs : List \u03b1) : append (cons a as) bs = cons a (append as bs) :=\n  rfl\n\ntheorem append_nil (as : List \u03b1) : append as nil = as := by\n  apply List.recOn (motive := \u03bb xs => append xs nil = xs) as\n  \u00b7 show append nil nil = nil\n    rfl\n  \u00b7 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 \u03b1)\n    : append (append as bs) cs = append as (append bs cs) := by\n  apply List.recOn\n      (motive := \u03bb xs => append (append xs bs) cs = append xs (append bs cs))\n      as\n  \u00b7 show append (append nil bs) cs = append nil (append bs cs)\n    rfl\n  \u00b7 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 \u03b1) : 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 \u03b1) : length (append as bs) = length as + length bs := by\n  apply List.recOn\n      (motive := \u03bb xs => length (append xs bs) = length xs + length bs)\n      as\n  \u00b7 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  \u00b7 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 [\u2190Nat.succ_add]\n      _ = length (cons a as) + length bs   := rfl\n\nend List\n\ninductive BinaryTree where\n| leaf : BinaryTree\n| node : BinaryTree \u2192 BinaryTree \u2192 BinaryTree\n\ninductive CBTree where\n| leaf : CBTree\n| sup : (Nat \u2192 CBTree) \u2192 CBTree\n\nnamespace CBTree\n\ndef succ (t : CBTree) : CBTree :=\n  sup (\u03bb _ => t)\n\ndef toCBTree : Nat \u2192 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 \u2192 Prop) (hz : p 0) (hs : \u2200 n, p (Nat.succ n)) : \u2200 n, p n := by\n  intro n\n  cases n\n  \u00b7 exact hz -- goal is p 0\n  \u00b7 apply hs -- goal is a : \u2115 \u22a2 p (succ a)\n\nopen Nat\n\nexample (n : Nat) (h : n \u2260 0) : succ (pred n) = n := by\n  cases n with\n  | zero =>\n    -- goal: h : 0 \u2260 0 \u22a2 succ (pred 0) = 0\n    apply absurd rfl h\n  | succ m =>\n    -- second goal: h : succ m \u2260 0 \u22a2 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 (\u03b1 : Type) (n : Nat) :=\n  { as : List \u03b1 // as.length = n }\n\ndef f {n : Nat} (t : Tuple \u03b1 n) : Nat := by\n  cases n; exact 3; exact 7\n\ndef myTuple : Tuple Nat 3 :=\n  \u27e8[0, 1, 2], rfl\u27e9\n\nexample : f myTuple = 7 :=\n  rfl\n\nend cases_tuple\n\nnamespace cases_multi\n\ninductive Foo where\n| bar\u2081 : Nat \u2192 Nat \u2192 Foo\n| bar\u2082 : Nat \u2192 Nat \u2192 Nat \u2192 Foo\n\ndef silly (x : Foo) : Nat := by\n  cases x with\n  | bar\u2081 a b => exact b\n  | bar\u2082 c d e => exact e\n\nend cases_multi\n\nnamespace cases_multi_swap\n\ninductive Foo where\n| bar\u2081 : Nat \u2192 Nat \u2192 Foo\n| bar\u2082 : Nat \u2192 Nat \u2192 Nat \u2192 Foo\n\ndef silly (x : Foo) : Nat := by\n  cases x with\n  | bar\u2082 c d e => exact e\n  | bar\u2081 a b => exact b\n\nend cases_multi_swap\n\nnamespace case_tactic\n\ninductive Foo where\n| bar\u2081 : Nat \u2192 Nat \u2192 Foo\n| bar\u2082 : Nat \u2192 Nat \u2192 Nat \u2192 Foo\n\ndef silly (x : Foo) : Nat := by\n  cases x\n  case bar\u2082 c d e => exact e\n  case bar\u2081 a b => exact b\n\nend case_tactic\n\nnamespace case_tactic_swap\n\ninductive Foo where\n| bar\u2081 : Nat \u2192 Nat \u2192 Foo\n| bar\u2082 : Nat \u2192 Nat \u2192 Nat \u2192 Foo\n\ndef silly (x : Foo) : Nat := by\n  cases x\n  case bar\u2081 a b => exact b\n  case bar\u2082 c d e => exact e\n\nend case_tactic_swap\n\nexample\n    (p : Nat \u2192 Prop) (hz : p 0) (hs : \u2200 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 : \u2115 \u22a2 p (succ a)\n\nexample\n    (p : Nat \u2192 Prop) (hz : p 0) (hs : \u2200 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\u2081 : m < n \u2192 p) (h\u2082 : m \u2265 n \u2192 p) : p := by\n  cases Nat.lt_or_ge m n\n  case inl hlt => exact h\u2081 hlt\n  case inr hge => exact h\u2082 hge\n\nexample (p : Prop) (m n : Nat) (h\u2081 : m < n \u2192 p) (h\u2082 : m \u2265 n \u2192 p) : p := by\n  have h : m < n \u2228 m \u2265 n := Nat.lt_or_ge m n\n  cases h\n  case inl hlt => exact h\u2081 hlt\n  case inr hge => exact h\u2082 hge\n\n#check Nat.sub_self\n\nexample (m n : Nat) : m - n = 0 \u2228 m \u2260 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\u2081 ih =>\n    rw [Nat.mod_eq_sub_mod h\u2081.2]\n    exact ih h\n  | base x y h\u2081 =>\n    have : \u00ac 0 < y \u2228 \u00ac y \u2264 x := Iff.mp (Decidable.not_and_iff_or_not ..) h\u2081\n    cases this with\n    | inl h\u2081 => exact absurd h h\u2081\n    | inr h\u2081 =>\n      have hgt : y > x := Nat.gt_of_not_le h\u2081\n      rw [\u2190 Nat.mod_eq_of_lt hgt] at hgt\n      assumption  \n\nexample :\n    (\u03bb (x : Nat \u00d7 Nat) (y : Nat \u00d7 Nat) => x.1 + y.2) =\n    (\u03bb (x : Nat \u00d7 Nat) (z : Nat \u00d7 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 (\u03b1 : Type u) : Nat \u2192 Type u where\n| nil : Vector \u03b1 0\n| cons : \u03b1 \u2192 {n : Nat} \u2192 Vector \u03b1 n \u2192 Vector \u03b1 (n + 1)\n\ninductive Eq {\u03b1 : Sort u} (a : \u03b1) : \u03b1 \u2192 Prop where\n| refl {} : Eq a a\n\n#check @Eq.rec\n\ntheorem subst\n    {\u03b1 : Type u} {a b : \u03b1} {p : \u03b1 \u2192 Prop} (h\u2081 : Eq a b) (h\u2082 : p a) : p b :=\n  match h\u2081 with\n  | Eq.refl _ => h\u2082\n\nsection\nset_option pp.all true\n#print subst\n#print subst.match_1\n#print Eq.casesOn\nend\n\ntheorem symm {\u03b1 : Type u} {a b : \u03b1} (h : Eq a b) : Eq b a :=\n  match h with\n  | Eq.refl _ => Eq.refl _\n\ntheorem trans {\u03b1 : Type u} {a b c : \u03b1} (h\u2081 : Eq a b) (h\u2082 : Eq b c) : Eq a c := by\n  cases h\u2082 with\n  | refl => exact h\u2081\n  \ntheorem congr\n    {\u03b1 \u03b2 : Type u} {a b : \u03b1} (f : \u03b1 \u2192 \u03b2) (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 \u2192 Prop where\n  | even_zero : Even 0\n  | even_succ : {n : Nat} \u2192 Odd n \u2192 Even (n + 1)\n\n  inductive Odd : Nat \u2192 Prop where\n  | odd_succ : {n : Nat} \u2192 Even n \u2192 Odd (n + 1)\nend\n\nmutual\n  inductive Tree (\u03b1 : Type u) where\n  | node : \u03b1 \u2192 TreeList \u03b1 \u2192 Tree \u03b1\n\n  inductive TreeList (\u03b1 : Type u) where\n  | nil : TreeList \u03b1\n  | cons : Tree \u03b1 \u2192 TreeList \u03b1 \u2192 TreeList \u03b1\nend\n\ninductive BetterTree (\u03b1 : Type u) where\n| mk : \u03b1 \u2192 List (BetterTree \u03b1) \u2192 BetterTree \u03b1\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 \u03b1) : Nat :=\n  match xs with\n  | [] => 0\n  | x :: xs => 1 + length xs\n\ndef reverse_helper (xs : List \u03b1) (acc : List \u03b1) : List \u03b1 :=\n  match xs with\n  | [] => acc\n  | x :: xs => reverse_helper xs (x :: acc)\n\ndef reverse (xs : List \u03b1) : List \u03b1 :=\n  reverse_helper xs []\n\ntheorem length_nil : length ([] : List \u03b1) = 0 := rfl\n\ntheorem length_cons\n    {x : \u03b1} {xs : List \u03b1} : length (x :: xs) = 1 + length xs := rfl\n\ntheorem reverse_nil : reverse ([] : List \u03b1) = [] := rfl\n\ntheorem reverse_helper_append\n    {xs : List \u03b1} : \u2200 ys, reverse_helper xs ys = reverse xs ++ ys := by\n  induction xs\n  case nil =>\n    show \u2200 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 : \u2200 ys, reverse_helper xs ys = reverse xs ++ ys := ih\n    show \u2200 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 : \u03b1} {xs ys : List \u03b1}\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 : \u03b1} : 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 \u03b1} : 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 \u03b1} : 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 \u03b1} : 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 \u03b1} : 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 \u2192 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 \u2192 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 => (\u00b7 && \u00b7)\n      | BinOp.Or => (\u00b7 || \u00b7)\n      | BinOp.Implies => \u03bb p q => p && !q\n      | BinOp.Iff => (\u00b7 == \u00b7)\n    boolOp (eval vars p) (eval vars q)\n\nexample : eval (\u03bb _ : String => false) (const true) = true := rfl\nexample : eval (\u03bb v => v == \"x\") (var \"x\") = true := rfl\nexample : eval (\u03bb v => v == \"x\") (var \"y\") = false := rfl\nexample : eval (\u03bb v => v == \"x\") (not (var \"x\")) = false := rfl\n\nexample \n  : eval (\u03bb v => v == \"x\" || v == \"y\") (and (var \"x\") (var \"y\")) = true\n  := rfl\n\nexample\n  : eval (\u03bb v => v == \"x\" || v != \"y\") (and (var \"x\") (var \"y\")) = false\n  := rfl\n\nexample\n  : eval (\u03bb 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": "example (P Q : Prop) : Q \u2192 (P \u2228 Q) :=\nbegin\nintro q,\nright,\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/level06.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943805178139, "lm_q2_score": 0.6654105653819835, "lm_q1q2_score": 0.47816029302067475}}
{"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 \u2192 \u2124` is non-negative if the image (under `f`) of `G \u2265 0` is bounded below. -/\nprotected def nonneg (f : AlmostHom G) : Prop := \u2203 a : \u2124 , \u2200 x : G, x \u2265 0 \u2192 f x \u2265 a\n/-- An almost-homomorphism `f : G \u2192 \u2124` is non-positive if the image (under `f`) of `G \u2265 0` is bounded above (unused). -/\nprotected def nonpos (f : AlmostHom G) : Prop := \u2203 b : \u2124 , \u2200 x : G, x \u2265 0 \u2192 f x \u2264 b\n/-- `f \u2264 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 \u2264 0; simp only [Left.neg_nonpos_iff]\n  le_trans p q r:= by\n                    intro hpq hqr\n                    let \u27e8a, hpq\u27e9 := hpq; let \u27e8b, hqr\u27e9 := hqr\n                    use a+b; intro x hx\n                    simp only [sub_reduces_to_fun, Pi.sub_apply, ge_iff_le] at hpq hqr \u22a2 \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        \u2983g : AlmostHom G\u2984 (h : \u2203 bound : \u2115, Bounded g bound)\n    : f.nonneg \u2192 (f + g).nonneg := by\n  intro hf\n  let \u27e8bound, hb\u27e9 := h\n  rw [Bounded] at hb\n  let \u27e8a, ha\u27e9 := hf\n  use a - bound; intro x hx\n  have hb : -bound \u2264 g.toFun x := by\n    simp only [\u2190Int.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 \u2192 (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 \u2264 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 \u2192 g.nonneg \u2192 (f + g).nonneg := by\n  intro hf hg\n  let \u27e8a, ha\u27e9 := hf; let \u27e8b, hb\u27e9 := 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 : \u2124) : -a.natAbs \u2264 a := by\n  simp only [\u2190Int.ofNat_le, Int.coe_natAbs]\n  exact neg_abs_le_self a\n\nprivate lemma neg_le_natAbs (a : \u2124) : -a \u2264 a.natAbs := by\n  simp only [\u2190Int.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 \u2192 (-f).nonneg \u2192 (\u2203 bound : \u2115, Bounded f bound) := by\n  intro hf hf'\n  let \u27e8a, ha\u27e9 := hf; let \u27e8b, hb\u27e9 := hf'\n  let \u27e8bound, hf\u27e9 := 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 \u2265 0)\n  \u00b7 have h' : f x \u2264 -b := by\n      rw [le_neg]\n      exact hb x hx\n    let h'' := ha x hx\n    simp only [\u2190Int.ofNat_le, Int.coe_natAbs, abs_le]\n    apply And.intro\n    \u00b7 have hga : a.natAbs \u2264 nb := by\n        simp only [add_assoc, le_add_iff_nonneg_right, zero_le]\n      have hga : -nb \u2264 -(\u2191a.natAbs : \u2124) := by\n        simp only [\u2190Int.ofNat_le] at hga\n        simp only [neg_le_neg, hga]\n      linarith [neg_natAbs_le a]\n    \u00b7 have hgb : Int.natAbs b \u2264 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 [\u2190Int.ofNat_le] at hgb\n      have nbe : \u2191(Int.natAbs b + Int.natAbs a + bound + Int.natAbs (toFun f 0)) = (\u2191nb : \u2124)  := by\n        simp only [add_comm, Nat.cast_add, Int.coe_natAbs]\n      linarith [neg_natAbs_le b]\n  \u00b7 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 \u2192 (-f).nonneg \u2192 f \u2208 boundedAlmostHoms G := by\n  intro hf hf'\n  let \u27e8bound, hb\u27e9 := 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 \u2228 (-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 (\u03bb f g h \u21a6 by\n  rw [QuotientAddGroup.leftRel_apply] at h\n  let x : boundedAlmostHoms G := \u27e8-f + g, h\u27e9\n  have h\u2081 : g = f + x := by\n    simp only [add_neg_cancel_left]\n  have h\u2082 : f = g + -x := by\n    simp only [neg_add_rev, neg_neg, add_neg_cancel_left]\n  apply propext\n  apply Iff.intro\n  \u00b7 intro hf\n    rw [h\u2081]\n    apply AlmostHom.bounded_plus_nonneg_nonneg x hf\n  \u00b7 intro hg\n    rw [h\u2082]\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 \u2192 g.nonneg \u2192 (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 \u2192 (-f).nonneg \u2192 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 \u2228 (-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 \u00b7.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 \u2124) 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 := \u0394 0\ndef Y := \u0394 1\ndef Z := \u0394 2\ndef W := \u0394 0  -- W and X are the same variable\n\n-- an interpretation\n\ndef init : nat_var \u2192 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 \u2124-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) \u2964 CommRing\u1d52\u1d56`: 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) \u21a5(CommRing.of K) := by {dsimp, apply_instance}\ninstance : is_fraction_ring (ring_of_function N) \u21a5(CommRing.of K) := by {dsimp, apply_instance}\ninstance : field \u21a5(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 \u2124 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\u1d52\u1d56 :=\n{ obj := \u03bb s,  op (CommRing.of K),\n  map := \u03bb s s' \u03bc, quiver.hom.op (ring_equiv.to_ring_hom (\u03bc.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) \u2964 CommRing\u1d52\u1d56 :=\n{ obj := \u03bb s, (mutation_prefunctor N K).obj s,\n  map := \u03bb s s' \u03b3, compose_path ((mutation_prefunctor N K).map_path \u03b3),\n  map_id' := \u03bb \u03b3, by refl,\n  map_comp' := by {rintros, simp} }\n\n@[simp] lemma mutation_functor.obj_eq_ring (\u03b3 : paths (multiset N)) : \n(mutation_functor N K).obj \u03b3 = 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 (\u03b3 : @under _ (mutation_paths N) s) : K \u2192+* K :=\nlet g := quiver.hom.unop ((under.post (mutation_functor N K)).obj \u03b3).hom in by simpa using g\n\ndef upper_cluster_algebra := \u2a05 \u03b3, (laurent_subring N K).map (field_hom_of_under_mutation_path s \u03b3)\n\ndef vector.is_monomial_at := { m : module.dual \u2124 N | \u2200 v \u2208 s, m v \u2265 0 }\n\ndef is_monomial_at := { f : K | \u2203 m : module.dual \u2124 N, f = z m \u2227 vector.is_monomial_at s m }\n\ndef cluster_monomials : set K := \n\u22c3 \u03b3, field_hom_of_under_mutation_path s \u03b3 '' is_monomial_at (\u03b3.right)\n\ndef cluster_algebra : subring K := subring.closure (cluster_monomials s)\n\ndef laurent_phenomenon : Prop := (cluster_algebra s : subring K) \u2264 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\u2081 u\u2082 v\u2081 v\u2082 \n\nnamespace Mathlib\n\n/-!\n# Monoidal structure on `C \u2964 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 \u2964 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 \u2964 D`, when `D` is monoidal.\n -/\ndef tensor_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] (F : C \u2964 D) (G : C \u2964 D) : C \u2964 D :=\n  functor.mk (fun (X : C) => functor.obj F X \u2297 functor.obj G X)\n    fun (X Y : C) (f : X \u27f6 Y) => functor.map F f \u2297 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\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {F' : C \u2964 D} {G' : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : F' \u27f6 G') : tensor_obj F F' \u27f6 tensor_obj G G' :=\n  nat_trans.mk fun (X : C) => nat_trans.app \u03b1 X \u2297 nat_trans.app \u03b2 X\n\nend functor_category\n\n\n/--\nWhen `C` is any category, and `D` is a monoidal category,\nthe functor category `C \u2964 D` has a natural pointwise monoidal structure,\nwhere `(F \u2297 G).obj X = F.obj X \u2297 G.obj X`.\n-/\nprotected instance functor_category_monoidal {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] : monoidal_category (C \u2964 D) :=\n  monoidal_category.mk (fun (F G : C \u2964 D) => functor_category.tensor_obj F G)\n    (fun (F G F' G' : C \u2964 D) (\u03b1 : F \u27f6 G) (\u03b2 : F' \u27f6 G') => functor_category.tensor_hom \u03b1 \u03b2)\n    (functor.obj (functor.const C) \ud835\udfd9_) (fun (F G H : C \u2964 D) => nat_iso.of_components (fun (X : C) => \u03b1_) sorry)\n    (fun (F : C \u2964 D) => nat_iso.of_components (fun (X : C) => \u03bb_) sorry)\n    fun (F : C \u2964 D) => nat_iso.of_components (fun (X : C) => \u03c1_) sorry\n\n@[simp] theorem tensor_unit_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {X : C} : functor.obj \ud835\udfd9_ X = \ud835\udfd9_ :=\n  rfl\n\n@[simp] theorem tensor_unit_map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {X : C} {Y : C} {f : X \u27f6 Y} : functor.map \ud835\udfd9_ f = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem tensor_obj_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {X : C} : functor.obj (F \u2297 G) X = functor.obj F X \u2297 functor.obj G X :=\n  rfl\n\n@[simp] theorem tensor_obj_map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {X : C} {Y : C} {f : X \u27f6 Y} : functor.map (F \u2297 G) f = functor.map F f \u2297 functor.map G f :=\n  rfl\n\n@[simp] theorem tensor_hom_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {F' : C \u2964 D} {G' : C \u2964 D} {\u03b1 : F \u27f6 G} {\u03b2 : F' \u27f6 G'} {X : C} : nat_trans.app (\u03b1 \u2297 \u03b2) X = nat_trans.app \u03b1 X \u2297 nat_trans.app \u03b2 X :=\n  rfl\n\n@[simp] theorem left_unitor_hom_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {X : C} : nat_trans.app (iso.hom \u03bb_) X = iso.hom \u03bb_ :=\n  rfl\n\n@[simp] theorem left_unitor_inv_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {X : C} : nat_trans.app (iso.inv \u03bb_) X = iso.inv \u03bb_ :=\n  rfl\n\n@[simp] theorem right_unitor_hom_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {X : C} : nat_trans.app (iso.hom \u03c1_) X = iso.hom \u03c1_ :=\n  rfl\n\n@[simp] theorem right_unitor_inv_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {X : C} : nat_trans.app (iso.inv \u03c1_) X = iso.inv \u03c1_ :=\n  rfl\n\n@[simp] theorem associator_hom_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {H : C \u2964 D} {X : C} : nat_trans.app (iso.hom \u03b1_) X = iso.hom \u03b1_ :=\n  rfl\n\n@[simp] theorem associator_inv_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {H : C \u2964 D} {X : C} : nat_trans.app (iso.inv \u03b1_) X = iso.inv \u03b1_ :=\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 \u2964 D`\nis also braided.\n-/\nprotected instance functor_category_braided {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] [braided_category D] : braided_category (C \u2964 D) :=\n  braided_category.mk fun (F G : C \u2964 D) => nat_iso.of_components (fun (X : C) => \u03b2_) 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 \u2964 D`\nis also symmetric.\n-/\nprotected instance functor_category_symmetric {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D] [symmetric_category D] : symmetric_category (C \u2964 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 \u03b9 : Type*} [category C] [preadditive C] {c : complex_shape \u03b9}\n\ndef homotopy_category.lift {K L : homological_complex C c}\n  (\u03c6 : (homotopy_category.quotient _ _).obj K \u27f6 (homotopy_category.quotient _ _).obj L) :\n  K \u27f6 L := quot.out \u03c6\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\u2081 g\u2081 f\u2082 g\u2082 \u27e8h\u2081\u27e9 \u27e8h\u2082\u27e9,\n    refine \u27e8homotopy.add h\u2081 h\u2082\u27e9, },\n  { rintros X Y f g \u27e8h\u27e9,\n    exact \u27e8homotopy.equiv_sub_zero.symm\n      (by simpa only [neg_sub_neg] using homotopy.equiv_sub_zero h.symm)\u27e9, },\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 (\ud835\udfd9 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 \u2124} (\u03c6 : K \u27f6 L)\n\nnamespace cochain_complex\n\n@[simps mor\u2081 mor\u2082 mor\u2083]\ndef mapping_cone.triangle : triangle (cochain_complex C \u2124) :=\ntriangle.mk \u03c6 (mapping_cone.inr \u03c6) (mapping_cone.\u03b4 \u03c6)\n\nsection\nvariables {K\u2081 K\u2082 L\u2081 L\u2082 : cochain_complex C \u2124}\n  [\u2200 p, has_binary_biproduct (K\u2081.X (p+1-(0 : \u2124))) (L\u2081.X p)]\n  [\u2200 p, has_binary_biproduct (K\u2082.X (p+1-(0 : \u2124))) (L\u2082.X p)]\n  (f\u2081 : K\u2081 \u27f6 L\u2081) (f\u2082 : K\u2082 \u27f6 L\u2082) (\u03c4\u2081 : K\u2081 \u27f6 K\u2082) (\u03c4\u2082 : L\u2081 \u27f6 L\u2082) (comm : f\u2081 \u226b \u03c4\u2082 = \u03c4\u2081 \u226b f\u2082)\n\n@[simps]\ndef mapping_cone.triangle_map : mapping_cone.triangle f\u2081 \u27f6 mapping_cone.triangle f\u2082 :=\n{ hom\u2081 := \u03c4\u2081,\n  hom\u2082 := \u03c4\u2082,\n  hom\u2083 := mapping_cone.map _ _ _ _ comm,\n  comm\u2081' := comm,\n  comm\u2082' := mapping_cone.inr_comp_map _ _ _ _ comm,\n  comm\u2083' := (mapping_cone.map_comp_\u03b4 _ _ _ _ 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  (\u03a6 : C \u2964 D) [\u03a6.additive]:\n  (functor.map_triangle (\u03a6.map_homological_complex (complex_shape.up \u2124))).obj\n    (mapping_cone.triangle \u03c6) \u2245 mapping_cone.triangle ((\u03a6.map_homological_complex _).map \u03c6) :=\nbegin\n  refine triangle.mk_iso _ _ (iso.refl _) (iso.refl _) (mapping_cone.map_iso \u03c6 \u03a6) _ _ _,\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, \u2190 \u03a6.map_comp, \u03a6.map_zero, \u03a6.map_id],\n    tauto, },\n  { ext n,\n    dsimp [mapping_cone.\u03b4, 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 [\u03a6.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 \u2124)) :=\ntriangle.mk ((homotopy_category.quotient _ _).map \u03c6) (mapping_cone.\u03b9' \u03c6) (mapping_cone.\u03b4' \u03c6)\n\nvariable (C)\n\ndef distinguished_triangles : set (triangle (homotopy_category C (complex_shape.up \u2124))) :=\n\u03bb T, \u2203 (K L : cochain_complex C \u2124) (\u03c6 : K \u27f6 L),\n  nonempty (T \u2245 mapping_cone_triangle' \u03c6)\n\nvariable {C}\n\nlemma mapping_cone_triangle'_distinguished :\n  mapping_cone_triangle' \u03c6 \u2208 distinguished_triangles C :=\n\u27e8_, _, \u03c6, nonempty.intro (iso.refl _)\u27e9\n\ninstance shift_functor_additive (n : \u2124) :\n  (category_theory.shift_functor (homotopy_category C (complex_shape.up \u2124)) n).additive := { }\n\nlemma isomorphic_distinguished\n  (T\u2081 : triangle (homotopy_category C (complex_shape.up \u2124)))\n  (h\u2081 : T\u2081 \u2208 distinguished_triangles C)\n  (T\u2082 : triangle (homotopy_category C (complex_shape.up \u2124)))\n  (e : T\u2082 \u2245 T\u2081) : T\u2082 \u2208 distinguished_triangles C :=\nbegin\n  obtain \u27e8K, L, \u03c6, \u27e8e'\u27e9\u27e9 := h\u2081,\n  exact \u27e8K, L, \u03c6, \u27e8e \u226a\u226b e'\u27e9\u27e9,\nend\n\nlemma contractible_distinguished\n  (X : homotopy_category C (complex_shape.up \u2124)) :\n  contractible_triangle X \u2208 distinguished_triangles C :=\nbegin\n  cases X,\n  refine \u27e8_, _, \ud835\udfd9 X, \u27e8_\u27e9\u27e9,\n  have h : is_zero ((homotopy_category.quotient _ _).obj (mapping_cone (\ud835\udfd9 X))),\n  { refine is_zero_of_homotopy_id_zero _ _,\n    exact mapping_cone.desc_homotopy _ _ _ 0 (mapping_cone.inl (\ud835\udfd9 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' (\ud835\udfd9 X)).mor\u2083) 0, contractible_triangle_mor\u2083, zero_comp, comp_zero]),\nend\n\nlemma distinguished_cocone_triangle\n  (X Y : homotopy_category C (complex_shape.up \u2124)) (f : X \u27f6 Y) :\n  \u2203 (Z : homotopy_category C (complex_shape.up \u2124)) (g : Y \u27f6 Z)\n    (h : Z \u27f6 X\u27e6(1 : \u2124)\u27e7), triangle.mk f g h \u2208 distinguished_triangles C :=\nbegin\n  cases X,\n  cases Y,\n  obtain \u27e8\u03c6, rfl\u27e9 := quotient.functor_map_surjective _ _ f,\n  exact \u27e8_ ,_ ,_ , mapping_cone_triangle'_distinguished \u03c6\u27e9,\nend\n\nopen cochain_complex.hom_complex\n\nlemma complete_distinguished_triangle_morphism'\n  {K\u2081 L\u2081 K\u2082 L\u2082 : cochain_complex C \u2124} (\u03c6\u2081 : K\u2081 \u27f6 L\u2081) (\u03c6\u2082 : K\u2082 \u27f6 L\u2082)\n  (a : K\u2081 \u27f6 K\u2082) (b : L\u2081 \u27f6 L\u2082) (hab : homotopy (\u03c6\u2081 \u226b b) (a \u226b \u03c6\u2082)) :\n  \u2203 (c : mapping_cone \u03c6\u2081 \u27f6 mapping_cone \u03c6\u2082),\n    nonempty (homotopy (mapping_cone.inr \u03c6\u2081 \u226b c) (b \u226b mapping_cone.inr \u03c6\u2082)) \u2227\n      nonempty (homotopy (mapping_cone.\u03b4 \u03c6\u2081 \u226b a\u27e61\u27e7') (c \u226b mapping_cone.\u03b4 \u03c6\u2082)) :=\nbegin\n  obtain \u27e8z, hz\u27e9 := (equiv_homotopy _ _) hab, clear hab,\n  refine \u27e8_, _, _\u27e9,\n  refine mapping_cone.desc _\n    (z.comp (cochain.of_hom (mapping_cone.inr \u03c6\u2082)) (add_zero _).symm +\n      (cochain.of_hom a).comp (mapping_cone.inl \u03c6\u2082) (zero_add _).symm)\n    (b \u226b mapping_cone.inr \u03c6\u2082) _,\n  { simp only [\u03b4_comp_of_second_is_zero_cochain _ _ _ (neg_add_self 1),\n      cocycle.\u03b4_cochain_of_hom, cochain.comp_zero, zero_add, \u2190 assoc,\n      cochain.of_hom_comp (\u03c6\u2081 \u226b b), hz, cochain.add_comp, \u03b4_add, \u2190 cochain.of_hom_comp],\n    simp only [add_zero, add_left_neg, \u03b4_comp_of_first_is_zero_cochain, mapping_cone.\u03b4_inl,\n      cochain.of_hom_comp, cocycle.\u03b4_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.\u03b4, 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.\u03b4_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\u2081 T\u2082 : triangle (homotopy_category C (complex_shape.up \u2124)))\n  (h\u2081 : T\u2081 \u2208 distinguished_triangles C) (h\u2082 : T\u2082 \u2208 distinguished_triangles C)\n  (a : T\u2081.obj\u2081 \u27f6 T\u2082.obj\u2081) (b : T\u2081.obj\u2082 \u27f6 T\u2082.obj\u2082)\n  (comm\u2081 : T\u2081.mor\u2081 \u226b b = a \u226b T\u2082.mor\u2081) :\n  \u2203 (c : T\u2081.obj\u2083 \u27f6 T\u2082.obj\u2083), T\u2081.mor\u2082 \u226b c = b \u226b T\u2082.mor\u2082 \u2227\n    T\u2081.mor\u2083 \u226b a\u27e6(1 : \u2124)\u27e7' = c \u226b T\u2082.mor\u2083 :=\nbegin\n  obtain \u27e8K\u2081, L\u2081, \u03c6\u2081, \u27e8e\u2081\u27e9\u27e9 := h\u2081,\n  obtain \u27e8K\u2082, L\u2082, \u03c6\u2082, \u27e8e\u2082\u27e9\u27e9 := h\u2082,\n  obtain \u27e8c, \u27e8h\u2081\u27e9, \u27e8h\u2082\u27e9\u27e9 := complete_distinguished_triangle_morphism' \u03c6\u2081 \u03c6\u2082\n    (quot.out (e\u2081.inv.hom\u2081 \u226b a \u226b e\u2082.hom.hom\u2081)) (quot.out (e\u2081.inv.hom\u2082 \u226b b \u226b e\u2082.hom.hom\u2082))\n    (homotopy_of_eq _ _ begin\n      simp only [functor.map_comp, quotient_map_out, category.assoc],\n      erw [reassoc_of e\u2081.inv.comm\u2081, reassoc_of comm\u2081, e\u2082.hom.comm\u2081],\n      refl,\n    end),\n  replace h\u2081 := eq_of_homotopy _ _ h\u2081,\n  replace h\u2082 := eq_of_homotopy _ _ h\u2082,\n  refine \u27e8e\u2081.hom.hom\u2083 \u226b (homotopy_category.quotient _ _).map c \u226b e\u2082.inv.hom\u2083, _, _\u27e9,\n  { simp only [functor.map_comp, quotient_map_out, category.assoc] at h\u2081,\n    erw [reassoc_of e\u2081.hom.comm\u2082, reassoc_of h\u2081, e\u2082.inv.comm\u2082],\n    simp only [triangle.hom_inv_id_hom\u2082_assoc], },\n  { erw [functor.map_comp, quotient_map_shift] at h\u2082,\n    simp only [quotient_map_out, functor.map_comp] at h\u2082,\n    simp only [category.assoc, \u2190 e\u2082.inv.comm\u2083],\n    erw [\u2190 reassoc_of h\u2082, \u2190 reassoc_of e\u2081.hom.comm\u2083],\n    simp only [\u2190 functor.map_comp, triangle.hom_inv_id_hom\u2081, category.comp_id,\n      triangle.hom_inv_id_hom\u2081_assoc], },\nend\n\n@[simps]\ndef rotate_distinguished_triangle_homotopy_equiv {K L : cochain_complex C \u2124} (\u03c6 : K \u27f6 L) :\n  homotopy_equiv (K\u27e6(1 : \u2124)\u27e7) (mapping_cone (mapping_cone.inr \u03c6)) :=\n{ hom := mapping_cone.lift _\n    (-cocycle.left_shift (cocycle.of_hom \u03c6) 1 1 (zero_add 1).symm)\n    (-(mapping_cone.inl \u03c6).left_shift 1 0 (neg_add_self 1).symm)\n    begin\n      simp only [\u03b4_neg, mapping_cone.\u03b4_inl, cochain.\u03b4_left_shift\n        (mapping_cone.inl \u03c6) 1 _ 0 _ (neg_add_self 1).symm (zero_add 1).symm,\n        \u03b5_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, \u03b5_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.\u03b4 \u03c6)\n    (by simp only [\u03b4_zero, mapping_cone.inr_\u03b4, 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.\u03b4, mapping_cone.\u03b4_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, \u03b5_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 \u27e8-(mapping_cone.snd (mapping_cone.inr \u03c6)).comp ((mapping_cone.snd \u03c6).comp\n      (mapping_cone.inl (mapping_cone.inr \u03c6)) (zero_add (-1)).symm) (zero_add (-1)).symm, _\u27e9,\n    rw mapping_cone.cochain_ext _ _ (neg_add_self 1).symm,\n    split,\n    { simp only [cochain.of_hom_comp, \u2190 cochain.comp_assoc_of_second_is_zero_cochain,\n        mapping_cone.inl_desc, cochain.zero_comp,\n        \u03b4_comp_of_first_is_zero_cochain _ _ _ (neg_add_self 1),\n        mapping_cone.\u03b4_inl, cochain.comp_add, \u2190 cochain.comp_assoc_of_third_is_zero_cochain,\n        mapping_cone.inl_comp_snd, cochain.zero_comp, zero_add, cochain.comp_id,\n        \u03b4_comp_of_first_is_zero_cochain _ _ _ (zero_add 1), \u03b5_0, one_smul, \u03b5_neg, \u03b5_1,\n        neg_smul, cochain.comp_neg, cochain.add_comp, neg_zero, neg_neg,\n        \u2190 cochain.comp_assoc _ _ _ (neg_add_self 1).symm (add_neg_self 1).symm\n        (show (-1 : \u2124) = -1+1+(-1), by linarith), mapping_cone.\u03b4_snd, cochain.neg_comp,\n        mapping_cone.inl_comp_fst, cochain.id_comp,\n        mapping_cone.inr_comp_snd, \u03b4_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, \u03b4_neg,\n        \u03b4_comp_of_first_is_zero_cochain, mapping_cone.\u03b4_inl, mapping_cone.\u03b4_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, \u03b5_neg, \u03b5_1,\n        mapping_cone.\u03b4, mapping_cone.\u03b4_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, \u03b5_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 : \u2124)).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 \u03c6 p _ rfl)),\n        preadditive.sub_comp, id_comp],\n      abel, },\n  end, }\n\nlemma rotate_distinguished_triangle\u2081 (T : triangle (homotopy_category C (complex_shape.up \u2124)))\n  (hT : T \u2208 distinguished_triangles C) : T.rotate \u2208 distinguished_triangles C :=\nbegin\n  obtain \u27e8K, L, \u03c6, \u27e8e\u27e9\u27e9:= hT,\n  suffices : (mapping_cone_triangle' \u03c6).rotate \u2208 distinguished_triangles C,\n  { exact isomorphic_distinguished _ this _ ((rotate _).map_iso e), },\n  refine \u27e8_,_, mapping_cone.inr \u03c6, \u27e8triangle.mk_iso _ _ (iso.refl _) (iso.refl _)\n    (iso_of_homotopy_equiv (rotate_distinguished_triangle_homotopy_equiv \u03c6))\n    (by tidy) (eq_of_homotopy _ _ _) (eq_of_homotopy _ _ (homotopy.of_eq _))\u27e9\u27e9,\n  { rw id_comp,\n    symmetry,\n    equiv_rw equiv_homotopy  _ _,\n    refine \u27e8(mapping_cone.snd \u03c6).comp (mapping_cone.inl (mapping_cone.inr \u03c6)) (zero_add _).symm,\n      _\u27e9,\n    simp only [\u03b4_comp_of_first_is_zero_cochain _ _ _ (neg_add_self 1),\n      mapping_cone.\u03b4_inl, cochain.of_hom_comp, mapping_cone.\u03b4_snd,\n      subtype.val_eq_coe, mapping_cone.cochain_ext _ _ (neg_add_self 1).symm,\n      cochain.comp_add],\n    split,\n    { simp only [\u2190 cochain.comp_assoc_of_first_is_zero_cochain,\n        \u2190 cochain.comp_assoc_of_second_is_zero_cochain,\n        \u2190 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, \u03b5_neg, \u03b5_1, neg_smul, neg_neg, one_smul,\n        \u2190 cochain.comp_assoc _ _ _ (neg_add_self 1).symm (add_neg_self 1).symm\n        (show (-1 : \u2124) =-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.\u03b4, mapping_cone.\u03b4_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, \u03b5_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.\u03b4,\n          cocycle.cochain_of_hom_hom_of_eq_coe, cocycle.right_shift_coe,\n          mapping_cone.\u03b4_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, \u03b5_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 [\u2190 cochain.comp_assoc_of_first_is_zero_cochain, mapping_cone.inr_comp_snd,\n        cochain.id_comp, cochain.comp_zsmul, mapping_cone.\u03b4,\n        \u2190 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.\u03b4_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.\u03b4_as_cocycle_coe,\n      shift_functor_map_f', mapping_cone.\u03b4,\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, \u03b5_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 \u2124))) (n : \u2124) :\n  triangle (homotopy_category C (complex_shape.up \u2124)) :=\ntriangle.mk (\u03b5 n \u2022 T.mor\u2081\u27e6n\u27e7') (\u03b5 n \u2022 T.mor\u2082\u27e6n\u27e7') (\u03b5 n \u2022 T.mor\u2083\u27e6n\u27e7' \u226b (shift_comm T.obj\u2081 1 n).hom)\n\ninstance cochain_complex_shift_functor_additive (n : \u2124) :\n  (category_theory.shift_functor (cochain_complex C \u2124) n).additive := { }\n\ninstance has_comm_shift :\n  (homotopy_category.quotient C (complex_shape.up \u2124)).has_comm_shift \u2124 :=\nquotient.functor_comm_shift _\n\ndef induced_triangle (T : triangle (cochain_complex C \u2124)) :\n  triangle (homotopy_category C (complex_shape.up \u2124)) :=\n(homotopy_category.quotient _ _).map_triangle.obj T\n\ndef mapping_cone_induced_triangle_iso :\n  induced_triangle (mapping_cone.triangle \u03c6) \u2245 mapping_cone_triangle' \u03c6 :=\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 \u2124} (\u03c6 : K \u27f6 L) (n : \u2124) :\n  (mapping_cone \u03c6)\u27e6n\u27e7 \u2245 mapping_cone (\u03c6\u27e6n\u27e7') :=\n{ hom := mapping_cone.lift _\n      (\u03b5 ((n*(n+1))/2) \u2022 cocycle.right_shift (cocycle.left_shift\n        (mapping_cone.fst \u03c6) n (n+1) (by linarith)) n 1 (by linarith))\n      (\u03b5 ((n*(n+1))/2) \u2022 ((mapping_cone.snd \u03c6).left_shift n n\n        (zero_add n).symm).right_shift n 0 (zero_add n).symm) begin\n    simp only [\u03b4_zsmul, cochain.\u03b4_right_shift _ n _ 0 1 (zero_add n).symm (add_comm n 1),\n      cochain.\u03b4_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_\u03b5_self, mul_one, mapping_cone.\u03b4_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      (\u03b5 ((n*(n+1))/2) \u2022 ((mapping_cone.inl \u03c6).left_shift n (n-1) (by linarith)).right_shift n (-1) (by linarith))\n      ((mapping_cone.inr \u03c6)\u27e6n\u27e7') begin\n    simp only [\u03b4_zsmul, cochain.of_hom_comp, cochain.\u03b4_right_shift _ _ _ _ _ _ (zero_add n).symm,\n      cochain.\u03b4_left_shift _ _ _ _ _ _ (zero_add n).symm, mapping_cone.\u03b4_inl,\n      cochain.right_shift_smul, smul_smul, mul_\u03b5_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, \u03b5_add, \u03b5_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, \u2190 mul_assoc (\u03b5 n)],\n    simp only [mul_\u03b5_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, \u2190 mapping_cone.id \u03c6 (p+n) (p+1+n) (by linarith)],\n    simp only [\u03b5_add, \u03b5_even _ (even_mul_pred n), \u03b5_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 \u2190 mul_assoc, },\n      simpa only [mul_\u03b5_self, one_mul, one_smul], },\n    { simp only [mul_succ_div_two, \u03b5_mul_self, \u03b5_add],\n      conv_lhs { congr, rw [mul_assoc, \u2190 mul_assoc (\u03b5 n)], },\n      simp only [mul_\u03b5_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, \u03b5_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          \u03b5_even _ (even_mul_succ n), \u03b5_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 \u2190 mul_assoc, },\n        simp only [mul_\u03b5_self, one_mul, one_smul], },\n      { simp only [preadditive.comp_zsmul, mapping_cone.inr_desc_f_assoc,\n          shift_functor_obj_X_iso, \u03b5_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, \u03b5_add, \u03b5_mul_self, mul_succ_div_two, mul_assoc],\n        conv_lhs { congr, congr, skip, rw \u2190 mul_assoc, },\n        simpa only [mul_\u03b5_self, one_mul, one_smul], }, },\n  end, }\n\ndef shift_mapping_cone_triangle_iso {K L : cochain_complex C \u2124} (\u03c6 : K \u27f6 L) (n : \u2124) :\n  (triangle.shift_functor _ n).obj (mapping_cone.triangle \u03c6) \u2245 mapping_cone.triangle (\u03c6\u27e6n\u27e7') :=\nbegin\n  refine triangle.mk_iso _ _ (iso.refl _) (preadditive.mul_iso ((-1)^n) (iso.refl _))\n    (shift_mapping_cone_iso \u03c6 n) _ _ _,\n  { dsimp [triangle.shift_functor],\n    simp only [comp_id, id_comp, preadditive.comp_zsmul, smul_smul,\n      \u2190 units.coe_mul, \u2190 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, \u03b5_add, mul_assoc],\n    conv_lhs { congr, skip, rw [\u2190 mul_assoc, mul_\u03b5_self, one_mul], },\n    rw [\u03b5_mul_self, mul_\u03b5_self], },\n  { ext p : 2,\n    dsimp [triangle.shift_functor, mapping_cone.triangle],\n    simp only [preadditive.zsmul_comp, mapping_cone.lift_f (\u03c6\u27e6n\u27e7') _ _ _ p _ rfl,\n      mapping_cone.\u03b4, cocycle.hom_of_f, shift_functor_add_comm_hom_app_f,\n      cocycle.right_shift_coe, mapping_cone.\u03b4_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, \u03b5_add, \u03b5_even _ (even_mul_succ n), one_mul, \u2190 mul_assoc,\n      mul_\u03b5_self], },\nend\n\nlemma shift_distinguished_triangles (T : triangle (homotopy_category C (complex_shape.up \u2124)))\n  (hT : T \u2208 distinguished_triangles C) (n : \u2124) :\n  (triangle.shift_functor _ n).obj T \u2208 distinguished_triangles C :=\nbegin\n  obtain \u27e8K, L, \u03c6, \u27e8e\u27e9\u27e9:= hT,\n  suffices : (triangle.shift_functor _ n).obj (mapping_cone_triangle' \u03c6)\n    \u2208 distinguished_triangles C,\n  { exact isomorphic_distinguished _ this _ (functor.map_iso _ e), },\n  exact \u27e8K\u27e6n\u27e7, L\u27e6n\u27e7, \u03c6\u27e6n\u27e7',\n    \u27e8(triangle.shift_functor (homotopy_category C (complex_shape.up \u2124)) n).map_iso\n    (mapping_cone_induced_triangle_iso \u03c6).symm \u226a\u226b\n    ((triangle.shift_functor_comm\n      ((homotopy_category.quotient C (complex_shape.up \u2124))) n).app _).symm \u226a\u226b\n    (homotopy_category.quotient _ _).map_triangle.map_iso (shift_mapping_cone_triangle_iso \u03c6 n) \u226a\u226b\n    (mapping_cone_induced_triangle_iso _)\u27e9\u27e9,\nend\n\nlemma rotate_distinguished_triangle (T : triangle (homotopy_category C (complex_shape.up \u2124))) :\n  T \u2208 distinguished_triangles C \u2194 T.rotate \u2208 distinguished_triangles C :=\nbegin\n  split,\n  { exact rotate_distinguished_triangle\u2081 T, },\n  { intro h,\n    replace h := rotate_distinguished_triangle\u2081 _ (rotate_distinguished_triangle\u2081 _ h),\n    replace h := shift_distinguished_triangles _ h (-1),\n    refine isomorphic_distinguished _ h _ _,\n    exact (triangle.shift_functor_zero _).symm.app T \u226a\u226b\n      (triangle.shift_functor_iso_of_eq _ (by linarith)).app T \u226a\u226b\n      (triangle.shift_functor_add _ 1 (-1)).app T \u226a\u226b\n      (triangle.shift_functor _ (-1)).map_iso ((triangle.shift_functor_one_iso _).app T), },\nend\n\ninstance : pretriangulated (homotopy_category C (complex_shape.up \u2124)) :=\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 \u2124))) :\n  (T \u2208 dist_triang (homotopy_category C (complex_shape.up \u2124)))\n  \u2194 \u2203 (K L : cochain_complex C \u2124) (\u03c6 : K \u27f6 L),\n    nonempty (T \u2245\n      (homotopy_category.quotient _ _).map_triangle.obj (mapping_cone.triangle \u03c6)) :=\nbegin\n  split,\n  { rintros \u27e8K, L, \u03c6, \u27e8e\u27e9\u27e9,\n    exact \u27e8K, L, \u03c6, \u27e8e \u226a\u226b (mapping_cone_induced_triangle_iso \u03c6).symm\u27e9\u27e9, },\n  { rintro \u27e8K, L, \u03c6, \u27e8e\u27e9\u27e9,\n    exact \u27e8K, L, \u03c6, \u27e8e \u226a\u226b (mapping_cone_induced_triangle_iso \u03c6)\u27e9\u27e9, },\nend\n\nlemma triangle_distinguished_iff' (T : triangle (homotopy_category C (complex_shape.up \u2124))) :\n  (T \u2208 dist_triang (homotopy_category C (complex_shape.up \u2124))) \u2194\n  \u2203 (K L : cochain_complex C \u2124) (\u03c6 : K \u27f6 L), nonempty (T \u2245\n      (homotopy_category.quotient _ _).map_triangle.obj (mapping_cone.triangle \u03c6).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 \u27e8K, L, \u03c6, \u27e8e\u27e9\u27e9 := hT,\n    exact \u27e8K, L, \u03c6, \u27e8(triangle_rotation _).counit_iso.symm.app T \u226a\u226b\n      (pretriangulated.rotate _).map_iso e \u226a\u226b\n      (homotopy_category.quotient _ _).map_triangle_rotate.app _\u27e9\u27e9, },\n  { rintro \u27e8K, L, \u03c6, \u27e8e\u27e9\u27e9,\n    suffices : T.inv_rotate \u2208 dist_triang _,\n    { exact pretriangulated.isomorphic_distinguished _ (rot_of_dist_triangle _ _ this) _\n        ((triangle_rotation _).counit_iso.symm.app T), },\n    refine \u27e8K, L, \u03c6, \u27e8(pretriangulated.inv_rotate _).map_iso e \u226a\u226b (inv_rotate _).map_iso\n        (((homotopy_category.quotient _ _).map_triangle_rotate).symm.app _ \u226a\u226b\n        (rotate _).map_iso (mapping_cone_induced_triangle_iso \u03c6)) \u226a\u226b\n      (triangle_rotation _).unit_iso.symm.app _\u27e9\u27e9, },\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\u2081 v\u2082 u\u2081 u\u2082\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\nvariables {D : Type u\u2082} [category.{v\u2082} D]\nvariables (G : C \u2964 D)\n\nnamespace category_theory.limits\n\nvariables {J : Type w} (f : J \u2192 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 : \u03a0 j, P \u27f6 f j) :\n  is_limit (G.map_cone (fan.mk P g)) \u2243\n  is_limit (fan.mk _ (\u03bb j, G.map (g j)) : fan (\u03bb 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 (\u03bb j, iso.refl (G.obj (f j.as))),\n  refine cones.ext (iso.refl _) (\u03bb 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 : \u03a0 j, P \u27f6 f j) (t : is_limit (fan.mk _ g)) :\n  is_limit (fan.mk (G.obj P) (\u03bb j, G.map (g j)) : fan (\u03bb 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 : \u03a0 j, P \u27f6 f j) (t : is_limit (fan.mk _ (\u03bb j, G.map (g j)) : fan (\u03bb 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 _ (\u03bb (j : J), G.map (pi.\u03c0 f j)) : fan (\u03bb j, G.obj (f j))) :=\nis_limit_fan_mk_obj_of_is_limit G f _ (product_is_product _)\n\nvariables [has_product (\u03bb (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 (\u03bb (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 (\u220f f) \u2245 \u220f (\u03bb 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 \u2190 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 : \u03a0 j, f j \u27f6 P) :\n  is_colimit (G.map_cocone (cofan.mk P g)) \u2243\n  is_colimit (cofan.mk _ (\u03bb j, G.map (g j)) : cofan (\u03bb 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 (\u03bb j, iso.refl (G.obj (f j.as))),\n  refine cocones.ext (iso.refl _) (\u03bb 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 : \u03a0 j, f j \u27f6 P) (t : is_colimit (cofan.mk _ g)) :\n  is_colimit (cofan.mk (G.obj P) (\u03bb j, G.map (g j)) : cofan (\u03bb 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 : \u03a0 j, f j \u27f6 P)\n  (t : is_colimit (cofan.mk _ (\u03bb j, G.map (g j)) : cofan (\u03bb 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 _ (\u03bb (j : J), G.map (sigma.\u03b9 f j)) : cofan (\u03bb j, G.obj (f j))) :=\nis_colimit_cofan_mk_obj_of_is_colimit G f _ (coproduct_is_coproduct _)\n\nvariables [has_coproduct (\u03bb (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 (\u03bb (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 (\u2210 f) \u2245 \u2210 (\u03bb 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 \u2190 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 : \u2115) [h : char_p R p] : char_p (polynomial R) p :=\nlet \u27e8h\u27e9 := h in \u27e8\u03bb n, by rw [\u2190 C.map_nat_cast, \u2190 C_0, C_inj, h]\u27e9\n\nvariables (R : Type u) [comm_ring R]\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree \u2264 `n`. -/\ndef degree_le (n : with_bot \u2115) : submodule R (polynomial R) :=\n\u2a05 k : \u2115, \u2a05 h : \u2191k > n, (lcoeff R k).ker\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degree_lt (n : \u2115) : submodule R (polynomial R) :=\n\u2a05 k : \u2115, \u2a05 h : k \u2265 n, (lcoeff R k).ker\n\nvariable {R}\n\ntheorem mem_degree_le {n : with_bot \u2115} {f : polynomial R} :\n  f \u2208 degree_le R n \u2194 degree f \u2264 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 \u2115} (H : m \u2264 n) :\n  degree_le R m \u2264 degree_le R n :=\n\u03bb f hf, mem_degree_le.2 (le_trans (mem_degree_le.1 hf) H)\n\ntheorem degree_le_eq_span_X_pow {n : \u2115} :\n  degree_le R n = submodule.span R \u2191((finset.range (n+1)).image (\u03bb n, (X : polynomial R)^n)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_le.1 hp,\n    rw [\u2190 finsupp.sum_single p, finsupp.sum],\n    refine submodule.sum_mem _ (\u03bb k hk, _),\n    show monomial _ _ \u2208 _,\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 \u27e8_, finset.mem_range.2 (nat.lt_succ_of_le this), rfl\u27e9) },\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 : \u2115} {f : polynomial R} :\n  f \u2208 degree_lt R n \u2194 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 : \u2115} (H : m \u2264 n) :\n  degree_lt R m \u2264 degree_lt R n :=\n\u03bb 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 : \u2115} :\n  degree_lt R n = submodule.span R \u2191((finset.range n).image (\u03bb n, X^n) : finset (polynomial R)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_lt.1 hp,\n    rw [\u2190 finsupp.sum_single p, finsupp.sum],\n    refine submodule.sum_mem _ (\u03bb k hk, _),\n    show monomial _ _ \u2208 _,\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 \u27e8_, finset.mem_range.2 this, rfl\u27e9) },\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 \u2192 F`. -/\ndef degree_lt_equiv (F : Type*) [field F] (n : \u2115) : degree_lt F n \u2243\u2097[F] (fin n \u2192 F) :=\n{ to_fun := \u03bb p n, (\u2191p : polynomial F).coeff n,\n  inv_fun := \u03bb f, \u27e8\u2211 i : fin n, monomial i (f i),\n    (degree_lt F n).sum_mem (\u03bb 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)))\u27e9,\n  map_add' := \u03bb p q, by { ext, rw [submodule.coe_add, coeff_add], refl },\n  map_smul' := \u03bb x p, by { ext, rw [submodule.coe_smul, coeff_smul], refl },\n  left_inv :=\n  begin\n    rintro \u27e8p, hp\u27e9, 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, \u2190 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 [\u2190 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 (\u2191p.frange : set R)) :=\n\u27e8p.support, \u03bb i, \u27e8p.to_fun i,\n  if H : p.to_fun i = 0 then H.symm \u25b8 is_add_submonoid.zero_mem\n  else ring.subset_closure $ finsupp.mem_frange.2 \u27e8H, i, rfl\u27e9\u27e9,\n\u03bb i, finsupp.mem_support_iff.trans (not_iff_not_of_iff \u27e8\u03bb H, subtype.eq H, subtype.mk.inj\u27e9)\u27e9\n\n@[simp] theorem coeff_restriction {p : polynomial R} {n : \u2115} :\n  \u2191(coeff (restriction p) n) = coeff p n := rfl\n\n@[simp] theorem coeff_restriction' {p : polynomial R} {n : \u2115} :\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 $ \u03bb 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) \u2194 monic p :=\n\u27e8\u03bb H, congr_arg subtype.val H, \u03bb H, subtype.eq H\u27e9\n\n@[simp] theorem restriction_zero : restriction (0 : polynomial R) = 0 := rfl\n\n@[simp] theorem restriction_one : restriction (1 : polynomial R) = 1 :=\next $ \u03bb i, subtype.eq $ by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs; refl\n\nvariables {S : Type v} [ring S] {f : R \u2192+* S} {x : S}\n\ntheorem eval\u2082_restriction {p : polynomial R} :\n  eval\u2082 f x p = eval\u2082 (f.comp (is_subring.subtype _)) x p.restriction :=\nby { dsimp only [eval\u2082_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 : \u2191p.frange \u2286 T) : polynomial T :=\n\u27e8p.support, \u03bb i, \u27e8p.to_fun i,\n  if H : p.to_fun i = 0 then H.symm \u25b8 is_add_submonoid.zero_mem\n  else hp $ finsupp.mem_frange.2 \u27e8H, i, rfl\u27e9\u27e9,\n\u03bb i, finsupp.mem_support_iff.trans (not_iff_not_of_iff \u27e8\u03bb H, subtype.eq H, subtype.mk.inj\u27e9)\u27e9\n\nvariables (hp : \u2191p.frange \u2286 T)\ninclude hp\n\n@[simp] theorem coeff_to_subring {n : \u2115} : \u2191(coeff (to_subring p T hp) n) = coeff p n := rfl\n\n@[simp] theorem coeff_to_subring' {n : \u2115} : (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) \u2194 monic p :=\n\u27e8\u03bb H, congr_arg subtype.val H, \u03bb H, subtype.eq H\u27e9\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 $ \u03bb 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 $ \u03bb 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\u27e8p.support, subtype.val \u2218 p.to_fun,\n\u03bb n, finsupp.mem_support_iff.trans (not_iff_not_of_iff\n  \u27e8\u03bb h, congr_arg subtype.val h, \u03bb h, subtype.eq h\u27e9)\u27e9\n\n@[simp] theorem frange_of_subring {p : polynomial T} :\n  \u2191(p.of_subring T).frange \u2286 T :=\n\u03bb y H, let \u27e8hy, x, hx\u27e9 := finsupp.mem_frange.1 H in hx \u25b8 (p.to_fun x).2\n\nend polynomial\n\nvariables {R : Type u} {\u03c3 : 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 : \u2200 (n : \u2115), (p.coeff n) \u2208 I.comap C) : p \u2208 I :=\nsum_C_mul_X_eq p \u25b8 submodule.sum_mem I (\u03bb 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 \u2208 (ideal.map C I : ideal (polynomial R)) \u2194 \u2200 n : \u2115, f.coeff n \u2208 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 [\u2190 hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [h] } },\n    { simp },\n    { exact \u03bb f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine \u03bb f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (\u03bb c hc, I.smul_mem (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw \u2190 sum_monomial_eq f,\n    refine (I.map C : ideal (polynomial R)).sum_mem (\u03bb 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  \u2200 a \u2208 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\u2082_C_mk_eq_zero {I : ideal R} :\n  \u2200 f \u2208 (map C I : ideal (polynomial R)), eval\u2082_ring_hom (C.comp (quotient.mk I)) X f = 0 :=\nbegin\n  intros a ha,\n  rw \u2190 sum_monomial_eq a,\n  dsimp,\n  rw eval\u2082_sum,\n  refine finset.sum_eq_zero (\u03bb n hn, _),\n  dsimp,\n  rw eval\u2082_monomial (C.comp (quotient.mk I)) X,\n  refine mul_eq_zero_of_left (polynomial.ext (\u03bb 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) \u2243+* (map C I : ideal (polynomial R)).quotient :=\n{ to_fun := eval\u2082_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\u2082_ring_hom (C.comp (quotient.mk I)) X) eval\u2082_C_mk_eq_zero,\n  map_mul' := \u03bb f g, by simp,\n  map_add' := \u03bb 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 \u27e8x\u27e9,\n      simp [monomial_eq_smul_X, C_mul'] }\n  end,\n  right_inv := begin\n    rintro \u27e8f\u27e9,\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, \u2190 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 \u2192 R[x] \u2192 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] \u2192 R'[x]`.\n  In particular we can map `I` across this map, to get `I'` and a new map `R' \u2192 R'[x] \u2192 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 \u2208 (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 \u2264 I,\n  { refine \u03bb f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (\u03bb n, _),\n    rw [mem_comap, \u2190 quotient.eq_zero_iff_mem, \u2190 ring_hom.comp_apply],\n    rw [ring_hom.mem_ker, coe_map_ring_hom] at hf,\n    replace hf := congr_arg (\u03bb (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 \u27e8x, hx'\u27e9 := x,\n  obtain \u27e8y, rfl\u27e9 := (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) \u2208 (I.map (polynomial.map_ring_hom i)),\n  { obtain \u27e8f, hf\u27e9 := 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 \u25b8 I.add_mem (hi' _ : (C y - f) \u2208 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 : \u00ac is_field (polynomial R) :=\nbegin\n  by_contradiction hR,\n  by_cases hR' : \u2203 (x y : R), x \u2260 y,\n  { haveI : nontrivial R := let \u27e8x, y, hxy\u27e9 := hR' in nontrivial_of_ne x y hxy,\n    obtain \u27e8p, hp\u27e9 := 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) \u25b8 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 \u27e8x, y, hxy\u27e9 := hR.exists_pair_ne in hxy (polynomial.ext (\u03bb 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 \u2208 I) : x = 0 :=\nbegin\n  refine classical.by_contradiction (\u03bb hx0, hI.ne_top ((eq_top_iff_one I).2 _)),\n  obtain \u27e8y, hy\u27e9 := hR.mul_inv_cancel hx0,\n  convert I.smul_mem (C y) hx,\n  rw [smul_eq_mul, \u2190 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' := \u03bb _ _, I.add_mem,\n  smul_mem' := \u03bb c x H, by { rw [\u2190 C_mul'], exact I.mul_mem_left _ H } }\n\nvariables {I : ideal (polynomial R)}\ntheorem mem_of_polynomial (x) : x \u2208 I.of_polynomial \u2194 x \u2208 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 \u2264 `n`. -/\ndef degree_le (n : with_bot \u2115) : submodule R (polynomial R) :=\ndegree_le R n \u2293 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 \u2264 `n`. -/\ndef leading_coeff_nth (n : \u2115) : ideal R :=\n(I.degree_le n).map $ lcoeff R n\n\ntheorem mem_leading_coeff_nth (n : \u2115) (x) :\n  x \u2208 I.leading_coeff_nth n \u2194 \u2203 p \u2208 I, degree p \u2264 n \u2227 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 \u27e8p, \u27e8hpdeg, hpI\u27e9, rfl\u27e9,\n    cases lt_or_eq_of_le hpdeg with hpdeg hpdeg,\n    { refine \u27e80, I.zero_mem, bot_le, _\u27e9,\n      rw [leading_coeff_zero, eq_comm],\n      exact coeff_eq_zero_of_degree_lt hpdeg },\n    { refine \u27e8p, hpI, le_of_eq hpdeg, _\u27e9,\n      rw [leading_coeff, nat_degree, hpdeg], refl } },\n  { rintro \u27e8p, hpI, hpdeg, rfl\u27e9,\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 \u27e8p * X ^ (n - nat_degree p), \u27e8_, I.mul_mem_right _ hpI\u27e9, _\u27e9,\n    { apply le_trans (degree_mul_le _ _) _,\n      apply le_trans (add_le_add (degree_le_nat_degree) (degree_X_pow_le _)) _,\n      rw [\u2190 with_bot.coe_add, this],\n      exact le_refl _ },\n    { rw [leading_coeff, \u2190 coeff_mul_X_pow p (n - nat_degree p), this] } }\nend\n\ntheorem mem_leading_coeff_nth_zero (x) :\n  x \u2208 I.leading_coeff_nth 0 \u2194 C x \u2208 I :=\n(mem_leading_coeff_nth _ _ _).trans\n\u27e8\u03bb \u27e8p, hpI, hpdeg, hpx\u27e9, by rwa [\u2190 hpx, leading_coeff,\n  nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg),\n  \u2190 eq_C_of_degree_le_zero hpdeg],\n\u03bb hx, \u27e8C x, hx, degree_C_le, leading_coeff_C x\u27e9\u27e9\n\ntheorem leading_coeff_nth_mono {m n : \u2115} (H : m \u2264 n) :\n  I.leading_coeff_nth m \u2264 I.leading_coeff_nth n :=\nbegin\n  intros r hr,\n  simp only [set_like.mem_coe, mem_leading_coeff_nth] at hr \u22a2,\n  rcases hr with \u27e8p, hpI, hpdeg, rfl\u27e9,\n  refine \u27e8p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow\u27e9,\n  refine le_trans (degree_mul_le _ _) _,\n  refine le_trans (add_le_add hpdeg (degree_X_pow_le _)) _,\n  rw [\u2190 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\u2a06 n : \u2115, I.leading_coeff_nth n\n\ntheorem mem_leading_coeff (x) :\n  x \u2208 I.leading_coeff \u2194 \u2203 p \u2208 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 \u27e8i, p, hpI, hpdeg, rfl\u27e9, exact \u27e8p, hpI, rfl\u27e9 },\n    rintro \u27e8p, hpI, rfl\u27e9, exact \u27e8nat_degree p, p, hpI, degree_le_nat_degree, rfl\u27e9 },\n  intros i j, exact \u27e8i + j, I.leading_coeff_nth_mono (nat.le_add_right _ _),\n    I.leading_coeff_nth_mono (nat.le_add_left _ _)\u27e9\nend\n\ntheorem is_fg_degree_le [is_noetherian_ring R] (n : \u2115) :\n  submodule.fg (I.degree_le n) :=\nis_noetherian_submodule_left.1 (is_noetherian_of_fg_of_noetherian _\n  \u27e8_, degree_le_eq_span_X_pow.symm\u27e9) _\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      \u27e8\u03bb p, (if p = 0 then \u22a4 else \u2191p.degree, p.leading_coeff), _\u27e9\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 \u27e8ane0, \u27e8c, \u27e8not_unit_c, rfl\u27e9\u27e9\u27e9,\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 \u2260 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 _ \u27e8_, \u27e8c.leading_coeff, (\u03bb unit_c, not_unit_c _), rfl\u27e9\u27e9,\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          \u2190 with_bot.coe_add, with_bot.coe_lt_coe],\n      exact lt_add_of_pos_right _ (nat.pos_of_ne_zero (\u03bb h, hdeg (h.symm \u25b8 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 \u27e8assume 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) \u27e8_, \u27e80, rfl\u27e9\u27e9 in\nhave hm : M \u2208 set.range I.leading_coeff_nth := well_founded.min_mem _ _ _,\nlet \u27e8N, HN\u27e9 := hm, \u27e8s, hs\u27e9 := I.is_fg_degree_le N in\nhave hm2 : \u2200 k, I.leading_coeff_nth k \u2264 M := \u03bb k, or.cases_on (le_or_lt k N)\n  (\u03bb h, HN \u25b8 I.leading_coeff_nth_mono h)\n  (\u03bb h x hx, classical.by_contradiction $ \u03bb hxm,\n    have \u00acM < I.leading_coeff_nth k, by refine well_founded.not_lt_min\n      (well_founded_submodule_gt _ _) _ _ _; exact \u27e8k, rfl\u27e9,\n    this \u27e8HN \u25b8 I.leading_coeff_nth_mono (le_of_lt h), \u03bb H, hxm (H hx)\u27e9),\nhave hs2 : \u2200 {x}, x \u2208 I.degree_le N \u2192 x \u2208 ideal.span (\u2191s : set (polynomial R)),\nfrom hs \u25b8 \u03bb x hx, submodule.span_induction hx (\u03bb _ hx, ideal.subset_span hx) (ideal.zero_mem _)\n  (\u03bb _ _, ideal.add_mem _) (\u03bb c f hf, f.C_mul' c \u25b8 ideal.mul_mem_left _ _ hf),\n\u27e8s, le_antisymm\n  (ideal.span_le.2 $ \u03bb x hx, have x \u2208 I.degree_le N, from hs \u25b8 submodule.subset_span hx, this.2) $\nbegin\n  have : submodule.span (polynomial R) \u2191s = ideal.span \u2191s, 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 \u27e8polynomial.mem_degree_le.2\n      (le_trans polynomial.degree_le_nat_degree $ with_bot.coe_le_coe.2 h), hp\u27e9 },\n  { have hp0 : p \u2260 0,\n    { rintro rfl, cases hn, exact nat.not_lt_zero _ h },\n    have : (0 : R) \u2260 1,\n    { intro h, apply hp0, ext i, refine (mul_one _).symm.trans _,\n      rw [\u2190 h, mul_zero], refl },\n    haveI : nontrivial R := \u27e8\u27e80, 1, this\u27e9\u27e9,\n    have : p.leading_coeff \u2208 I.leading_coeff_nth N,\n    { rw HN, exact hm2 k ((I.mem_leading_coeff_nth _ _).2\n        \u27e8_, hp, hn \u25b8 polynomial.degree_le_nat_degree, rfl\u27e9) },\n    rw I.mem_leading_coeff_nth at this,\n    rcases this with \u27e8q, hq, hdq, hlqp\u27e9,\n    have hq0 : q \u2260 0,\n    { intro H, rw [\u2190 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 [\u2190 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 [\u2190 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 \u2190 sub_add_cancel p (q * polynomial.X ^ (k - q.nat_degree)),\n    refine (ideal.span \u2191s).add_mem _ ((ideal.span \u2191s).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 \u27e8polynomial.mem_degree_le.2 hdq, hq\u27e9 }\nend\u27e9\u27e9\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) : \u2203 g, irreducible g \u2227 g \u2223 f :=\nwf_dvd_monoid.exists_irreducible_factor\n  (\u03bb huf, ne_of_gt hf $ degree_eq_zero_of_is_unit huf)\n  (\u03bb hf0, not_lt_of_lt hf $ hf0.symm \u25b8 (@degree_zero R _).symm \u25b8 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) : \u2203 g, irreducible g \u2227 g \u2223 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 \u2260 0) : \u2203 g, irreducible g \u2227 g \u2223 f :=\nexists_irreducible_of_nat_degree_pos $ nat.pos_of_ne_zero hf\n\nlemma linear_independent_powers_iff_eval\u2082\n  (f : M \u2192\u2097[R] M) (v : M) :\n  linear_independent R (\u03bb n : \u2115, (f ^ n) v)\n    \u2194 \u2200 (p : polynomial R), aeval f p v = 0 \u2192 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 \u2192\u2097[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 \u27e8p', q', hpq'\u27e9,\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 (\u03bb p : polynomial R, aeval f p v) hpq'.symm,\nend\n\nlemma sup_aeval_range_eq_top_of_coprime\n  (f : M \u2192\u2097[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  (aeval f p).range \u2294 (aeval f q).range = \u22a4 :=\nbegin\n  rw eq_top_iff,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with \u27e8p', q', hpq'\u27e9,\n  use aeval f (p * p') v,\n  use linear_map.mem_range.2 \u27e8aeval f p' v, by simp only [linear_map.mul_apply, aeval_mul]\u27e9,\n  use aeval f (q * q') v,\n  use linear_map.mem_range.2 \u27e8aeval f q' v, by simp only [linear_map.mul_apply, aeval_mul]\u27e9,\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add]\n    using congr_arg (\u03bb p : polynomial R, aeval f p v) hpq'\nend\n\nlemma sup_ker_aeval_le_ker_aeval_mul {f : M \u2192\u2097[R] M} {p q : polynomial R} :\n  (aeval f p).ker \u2294 (aeval f q).ker \u2264 (aeval f (p * q)).ker :=\nbegin\n  intros v hv,\n  rcases submodule.mem_sup.1 hv with \u27e8x, hx, y, hy, hxy\u27e9,\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, \u2190hxy, 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 \u2192\u2097[R] M) {p q : polynomial R} (hpq : is_coprime p q) :\n  (aeval f p).ker \u2294 (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 \u27e8p', q', hpq'\u27e9,\n  have h_eval\u2082_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\u2082_pqq' := calc\n    aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v :\n      by rw [\u2190mul_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\u2082_qpp' h_eval\u2082_pqq',\n  refine \u27e8aeval f (q * q') v, linear_map.mem_ker.1 h_eval\u2082_pqq',\n          aeval f (p * p') v, linear_map.mem_ker.1 h_eval\u2082_qpp', _\u27e9,\n  rw [add_comm, mul_comm p p', mul_comm q q'],\n  simpa using congr_arg (\u03bb 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  \u2200 {n : \u2115}, 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 \u03c3] [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial \u03c3 R) :=\n@is_noetherian_ring_of_ring_equiv (mv_polynomial (fin (fintype.card \u03c3)) R) _ _ _\n  (rename_equiv R (fintype.equiv_fin \u03c3).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  \u2200 (n : \u2115), 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) (\u03c3 : Type v) [comm_ring R] [fintype \u03c3]\n  (hR : is_integral_domain R) : is_integral_domain (mv_polynomial \u03c3 R) :=\n@ring_equiv.is_integral_domain _ (mv_polynomial (fin $ fintype.card \u03c3) R) _ _\n  (mv_polynomial.is_integral_domain_fin _ hR _)\n  (rename_equiv R (fintype.equiv_fin \u03c3)).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) (\u03c3 : Type v) [integral_domain R] [fintype \u03c3] :\n  integral_domain (mv_polynomial \u03c3 R) :=\n@is_integral_domain.to_integral_domain _ _ $ mv_polynomial.is_integral_domain_fintype R \u03c3 $\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] {\u03c3 : Type v}\n  (p q : mv_polynomial \u03c3 R) (h : p * q = 0) : p = 0 \u2228 q = 0 :=\nbegin\n  obtain \u27e8s, p, rfl\u27e9 := exists_finset_rename p,\n  obtain \u27e8t, q, rfl\u27e9 := exists_finset_rename q,\n  have :\n    rename (subtype.map id (finset.subset_union_left s t) : {x // x \u2208 s} \u2192 {x // x \u2208 s \u222a t}) p *\n    rename (subtype.map id (finset.subset_union_right s t) : {x // x \u2208 t} \u2192 {x // x \u2208 s \u222a t}) q = 0,\n  { apply rename_injective _ subtype.val_injective, simpa using h },\n  letI := mv_polynomial.integral_domain_fintype R {x // x \u2208 (s \u222a 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} {\u03c3 : Type v} [integral_domain R] :\n  integral_domain (mv_polynomial \u03c3 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 := \u27e80, 1, \u03bb H,\n  begin\n    have : eval\u2082 (ring_hom.id _) (\u03bb s, (0:R)) (0 : mv_polynomial \u03c3 R) =\n      eval\u2082 (ring_hom.id _) (\u03bb s, (0:R)) (1 : mv_polynomial \u03c3 R),\n    { congr, exact H },\n    simpa,\n  end\u27e9,\n  .. (by apply_instance : comm_ring (mv_polynomial \u03c3 R)) }\n\nlemma map_mv_polynomial_eq_eval\u2082 {S : Type*} [comm_ring S] [fintype \u03c3]\n  (\u03d5 : mv_polynomial \u03c3 R \u2192+* S) (p : mv_polynomial \u03c3 R) :\n  \u03d5 p = mv_polynomial.eval\u2082 (\u03d5.comp mv_polynomial.C) (\u03bb s, \u03d5 (mv_polynomial.X s)) p :=\nbegin\n  refine trans (congr_arg \u03d5 (mv_polynomial.as_sum p)) _,\n  rw [mv_polynomial.eval\u2082_eq', \u03d5.map_sum],\n  congr,\n  ext,\n  simp only [monomial_eq, \u03d5.map_pow, \u03d5.map_prod, \u03d5.comp_apply, \u03d5.map_mul, finsupp.prod_pow],\nend\n\nlemma quotient_map_C_eq_zero {I : ideal R} {i : R} (hi : i \u2208 I) :\n  (ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial \u03c3 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 \u03c3 R)) (p : mv_polynomial \u03c3 R)\n  (hcoe : \u2200 (m : \u03c3 \u2192\u2080 \u2115), p.coeff m \u2208 I.comap C) : p \u2208 I :=\nbegin\n  rw as_sum p,\n  suffices : \u2200 m \u2208 p.support, monomial m (mv_polynomial.coeff m p) \u2208 I,\n  { exact submodule.sum_mem I this },\n  intros m hm,\n  rw [\u2190 mul_one (coeff m p), \u2190 C_mul_monomial],\n  suffices : C (coeff m p) \u2208 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 \u03c3 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 \u03c3 R} :\n  f \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 R)) \u2194 \u2200 (m : \u03c3 \u2192\u2080 \u2115), f.coeff m \u2208 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 [\u2190 hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [ne.symm h] } },\n    { simp },\n   { exact \u03bb f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine \u03bb f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (\u03bb c hc, I.smul_mem (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw as_sum f,\n    suffices : \u2200 m \u2208 f.support, monomial m (coeff m f) \u2208\n      (ideal.map C I : ideal (mv_polynomial \u03c3 R)),\n    { exact submodule.sum_mem _ this },\n    intros m hm,\n    rw [\u2190 mul_one (coeff m f), \u2190 C_mul_monomial],\n    suffices : C (coeff m f) \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 R)),\n    { exact ideal.mul_mem_right _ _ this },\n    apply ideal.mem_map_of_mem _,\n    exact hf m }\nend\n\nlemma eval\u2082_C_mk_eq_zero {I : ideal R} {a : mv_polynomial \u03c3 R}\n  (ha : a \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 R))) :\n  eval\u2082_hom (C.comp (ideal.quotient.mk I)) X a = 0 :=\nbegin\n  rw as_sum a,\n  rw [coe_eval\u2082_hom, eval\u2082_sum],\n  refine finset.sum_eq_zero (\u03bb n hn, _),\n  simp only [eval\u2082_monomial, function.comp_app, ring_hom.coe_comp],\n  refine mul_eq_zero_of_left _ _,\n  suffices : coeff n a \u2208 I,\n  { rw [\u2190 @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 \u03c3 I.quotient` is isomorphic as an\n`R`-algebra to the quotient of `mv_polynomial \u03c3 R` by the ideal generated by `I`. -/\ndef quotient_equiv_quotient_mv_polynomial (I : ideal R) :\n  mv_polynomial \u03c3 I.quotient \u2243\u2090[R] (ideal.map C I : ideal (mv_polynomial \u03c3 R)).quotient :=\n{ to_fun := eval\u2082_hom (ideal.quotient.lift I ((ideal.quotient.mk (ideal.map C I : ideal\n    (mv_polynomial \u03c3 R))).comp C) (\u03bb i hi, quotient_map_C_eq_zero hi))\n    (\u03bb i, ideal.quotient.mk (ideal.map C I : ideal (mv_polynomial \u03c3 R)) (X i)),\n  inv_fun := ideal.quotient.lift (ideal.map C I : ideal (mv_polynomial \u03c3 R))\n    (eval\u2082_hom (C.comp (ideal.quotient.mk I)) X) (\u03bb a ha, eval\u2082_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 \u27e8r\u27e9,\n      rw [coe_eval\u2082_hom, eval\u2082_C],\n      simp only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, ideal.quotient.lift_mk,\n        ideal.quotient.mk_eq_mk, bind\u2082_C_right, ring_hom.coe_comp] },\n    { simp_intros p q hp hq only [ring_hom.map_add, mv_polynomial.coe_eval\u2082_hom, coe_eval\u2082_hom,\n        mv_polynomial.eval\u2082_add, mv_polynomial.eval\u2082_hom_eq_bind\u2082, eval\u2082_hom_eq_bind\u2082],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval\u2082_hom_eq_bind\u2082, coe_eval\u2082_hom],\n      simp only [hp, eval\u2082_hom_eq_bind\u2082, coe_eval\u2082_hom, ideal.quotient.lift_mk, bind\u2082_X_right,\n        eval\u2082_mul, ring_hom.map_mul, eval\u2082_X] }\n  end,\n  right_inv := begin\n    rintro \u27e8f\u27e9,\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\u2082_hom_C] },\n    { simp_intros p q hp hq only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, eval\u2082_add,\n        ring_hom.map_add, coe_eval\u2082_hom, ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk],\n      rw [hp, hq] },\n    { simp_intros p i hp only [eval\u2082_hom_eq_bind\u2082, submodule.quotient.quot_mk_eq_mk, coe_eval\u2082_hom,\n        ideal.quotient.lift_mk, ideal.quotient.mk_eq_mk, bind\u2082_X_right, eval\u2082_mul, ring_hom.map_mul,\n        eval\u2082_X],\n      simp only [hp] }\n  end,\n  commutes' := \u03bb r, eval\u2082_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 \u2192 B) {a b : A} :\n  path A a b \u2192 path B (f a) (f b) :=\n\u03bb p, path.abs (\u03bb i, f (p @@ i))\n(by rw app0) (by rw app1)\n\nlemma apd {A : Type} {B : A \u2192 Type} {f : \u03a0 x, B x} {a b : A} :\n  \u03a0 p : path A a b, pathd (\u03bb i, B (p @@ i)) (f (p @@ i0)) (f (p @@ i1)) :=\n\u03bb p, pathd.abs (\u03bb i, f (p @@ i))\n(by rw app0) (by rw app1)\n\ntheorem funext {A B : Type} {f g : A \u2192 B} : \n  (\u2200 x, path B (f x) (g x)) \u2192 path (A \u2192 B) f g :=\n\u03bb h, path.abs (\u03bb i x, ((h x) @@ i))\n(funext (\u03bb x, app0 (h x))) (funext (\u03bb 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 \u2192\u2090[R] A`: the canonical map from `R` to `A`, as an `alg_hom`.\n\n## Notations\n\n* `A \u2192\u2090[R] B` : `R`-algebra homomorphism from `A` to `B`.\n-/\n\n\nopen BigOperators\n\nuniverse u v w u\u2081 v\u2081\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' : \u2200 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: \u00abexpr \u2192\u2090 \u00bb\ninfixr:25 \" \u2192\u2090 \" => AlgHom _\n\n-- mathport name: \u00abexpr \u2192\u2090[ ] \u00bb\nnotation:25 A \" \u2192\u2090[\" 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 : \u2200 (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  { \u2039AlgHomClass F R A B\u203a with\n    map_smul\u209b\u2097 := 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 \u2192\u2090[R] B)\n    where coe f :=\n    { (f : A \u2192+* 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\u2081} {D : Type v\u2081}\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 \u2192\u2090[R] B) fun _ => A \u2192 B :=\n  \u27e8AlgHom.toFun\u27e9\n\ninitialize_simps_projections AlgHom (toFun \u2192 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\u2093.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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) \u1fb0) (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\u2093'. -/\n@[simp, protected]\ntheorem coe_coe {F : Type _} [AlgHomClass F R A B] (f : F) : \u21d1(f : A \u2192\u2090[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\u2093'. -/\n@[simp]\ntheorem toFun_eq_coe (f : A \u2192\u2090[R] B) : f.toFun = f :=\n  rfl\n#align alg_hom.to_fun_eq_coe AlgHom.toFun_eq_coe\n\ninstance : AlgHomClass (A \u2192\u2090[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\u2093'. -/\ninstance coeOutRingHom : Coe (A \u2192\u2090[R] B) (A \u2192+* B) :=\n  \u27e8AlgHom.toRingHom\u27e9\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\u2093'. -/\ninstance coeOutMonoidHom : Coe (A \u2192\u2090[R] B) (A \u2192* B) :=\n  \u27e8fun f => \u2191(f : A \u2192+* B)\u27e9\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\u2093'. -/\ninstance coeOutAddMonoidHom : Coe (A \u2192\u2090[R] B) (A \u2192+ B) :=\n  \u27e8fun f => \u2191(f : A \u2192+* B)\u27e9\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\u2081 : 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\u2082 : 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\u2083 : 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\u2084 : 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\u2085 : 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\u2081 h\u2082 h\u2083 h\u2084 h\u2085)) 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\u2081 : 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\u2082 : 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\u2081) (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\u2081) 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\u2081) y))) (h\u2083 : 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\u2081) h\u2082)) (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\u2084 : 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\u2081) h\u2082)) (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\u2081) h\u2082)) 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\u2081) h\u2082)) y))) (h\u2085 : 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\u2081) h\u2082) h\u2083 h\u2084))) (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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) \u1fb0) (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\u2081) h\u2082) h\u2083 h\u2084) h\u2085)) f\nCase conversion may be inaccurate. Consider using '#align alg_hom.coe_mk AlgHom.coe_mks\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_mks {f : A \u2192 B} (h\u2081 h\u2082 h\u2083 h\u2084 h\u2085) : \u21d1(\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085\u27e9 : A \u2192\u2090[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\u2093.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\u2093'. -/\n-- make the coercion the simp-normal form\n@[simp]\ntheorem toRingHom_eq_coe (f : A \u2192\u2090[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\u2093.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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) \u1fb0) (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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_toRingHom (f : A \u2192\u2090[R] B) : \u21d1(f : A \u2192+* 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\u2093.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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : A) => B) \u1fb0) (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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_toMonoidHom (f : A \u2192\u2090[R] B) : \u21d1(f : A \u2192* 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\u2093.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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) \u1fb0) (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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_toAddMonoidHom (f : A \u2192\u2090[R] B) : \u21d1(f : A \u2192+ B) = f :=\n  rfl\n#align alg_hom.coe_to_add_monoid_hom AlgHom.coe_toAddMonoidHom\n\nvariable (\u03c6 : A \u2192\u2090[R] B)\n\n#print AlgHom.coe_fn_injective /-\ntheorem coe_fn_injective : @Function.Injective (A \u2192\u2090[R] B) (A \u2192 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 {\u03c6\u2081 \u03c6\u2082 : A \u2192\u2090[R] B} : (\u03c6\u2081 : A \u2192 B) = \u03c6\u2082 \u2194 \u03c6\u2081 = \u03c6\u2082 :=\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\u2093.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\u2093'. -/\ntheorem coe_ringHom_injective : Function.Injective (coe : (A \u2192\u2090[R] B) \u2192 A \u2192+* B) := fun \u03c6\u2081 \u03c6\u2082 H =>\n  coe_fn_injective <| show ((\u03c6\u2081 : A \u2192+* B) : A \u2192 B) = ((\u03c6\u2082 : A \u2192+* B) : A \u2192 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\u2093.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\u2093'. -/\ntheorem coe_monoidHom_injective : Function.Injective (coe : (A \u2192\u2090[R] B) \u2192 A \u2192* 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\u2093.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\u2093'. -/\ntheorem coe_addMonoidHom_injective : Function.Injective (coe : (A \u2192\u2090[R] B) \u2192 A \u2192+ 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 {\u03c6\u2081 \u03c6\u2082 : A \u2192\u2090[R] B} (H : \u03c6\u2081 = \u03c6\u2082) (x : A) : \u03c6\u2081 x = \u03c6\u2082 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 (\u03c6 : A \u2192\u2090[R] B) {x y : A} (h : x = y) : \u03c6 x = \u03c6 y :=\n  FunLike.congr_arg \u03c6 h\n#align alg_hom.congr_arg AlgHom.congr_arg\n-/\n\n#print AlgHom.ext /-\n@[ext]\ntheorem ext {\u03c6\u2081 \u03c6\u2082 : A \u2192\u2090[R] B} (H : \u2200 x, \u03c6\u2081 x = \u03c6\u2082 x) : \u03c6\u2081 = \u03c6\u2082 :=\n  FunLike.ext _ _ H\n#align alg_hom.ext AlgHom.ext\n-/\n\n#print AlgHom.ext_iff /-\ntheorem ext_iff {\u03c6\u2081 \u03c6\u2082 : A \u2192\u2090[R] B} : \u03c6\u2081 = \u03c6\u2082 \u2194 \u2200 x, \u03c6\u2081 x = \u03c6\u2082 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 \u2192\u2090[R] B} (h\u2081 h\u2082 h\u2083 h\u2084 h\u2085) : (\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085\u27e9 : A \u2192\u2090[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) : \u03c6 (algebraMap R A r) = algebraMap R B r :=\n  \u03c6.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] (\u03c6 : 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\u2093.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))))) \u03c6) (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] (\u03c6 : 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)) \u03c6) (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\u2093'. -/\ntheorem comp_algebraMap : (\u03c6 : A \u2192+* B).comp (algebraMap R A) = algebraMap R B :=\n  RingHom.ext <| \u03c6.commutes\n#align alg_hom.comp_algebra_map AlgHom.comp_algebraMap\n\n#print AlgHom.map_add /-\nprotected theorem map_add (r s : A) : \u03c6 (r + s) = \u03c6 r + \u03c6 s :=\n  map_add _ _ _\n#align alg_hom.map_add AlgHom.map_add\n-/\n\n#print AlgHom.map_zero /-\nprotected theorem map_zero : \u03c6 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) : \u03c6 (x * y) = \u03c6 x * \u03c6 y :=\n  map_mul _ _ _\n#align alg_hom.map_mul AlgHom.map_mul\n-/\n\n#print AlgHom.map_one /-\nprotected theorem map_one : \u03c6 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 : \u2115) : \u03c6 (x ^ n) = \u03c6 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) : \u03c6 (r \u2022 x) = r \u2022 \u03c6 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] (\u03c6 : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {\u03b9 : Type.{u4}} (f : \u03b9 -> A) (s : Finset.{u4} \u03b9), 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) \u03c6 (Finset.sum.{u2, u4} A \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) s (fun (x : \u03b9) => f x))) (Finset.sum.{u3, u4} B \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) s (fun (x : \u03b9) => 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) \u03c6 (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] (\u03c6 : AlgHom.{u2, u3, u4} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {\u03b9 : Type.{u1}} (f : \u03b9 -> A) (s : Finset.{u1} \u03b9), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (Finset.sum.{u3, u1} A \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) s (fun (x : \u03b9) => 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))))) \u03c6 (Finset.sum.{u3, u1} A \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} A (Semiring.toNonAssocSemiring.{u3} A _inst_2))) s (fun (x : \u03b9) => f x))) (Finset.sum.{u4, u1} B \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} B (Semiring.toNonAssocSemiring.{u4} B _inst_3))) s (fun (x : \u03b9) => 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))))) \u03c6 (f x)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_sum AlgHom.map_sum\u2093'. -/\nprotected theorem map_sum {\u03b9 : Type _} (f : \u03b9 \u2192 A) (s : Finset \u03b9) :\n    \u03c6 (\u2211 x in s, f x) = \u2211 x in s, \u03c6 (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] (\u03c6 : AlgHom.{u1, u2, u3} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {\u03b1 : Type.{u4}} [_inst_10 : Zero.{u4} \u03b1] {\u03b9 : Type.{u5}} (f : Finsupp.{u5, u4} \u03b9 \u03b1 _inst_10) (g : \u03b9 -> \u03b1 -> 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) \u03c6 (Finsupp.sum.{u5, u4, u2} \u03b9 \u03b1 A _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} A (Semiring.toNonAssocSemiring.{u2} A _inst_2))) f g)) (Finsupp.sum.{u5, u4, u3} \u03b9 \u03b1 B _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} B (Semiring.toNonAssocSemiring.{u3} B _inst_3))) f (fun (i : \u03b9) (a : \u03b1) => 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) \u03c6 (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] (\u03c6 : AlgHom.{u3, u4, u5} R A B _inst_1 _inst_2 _inst_3 _inst_6 _inst_7) {\u03b1 : Type.{u2}} [_inst_10 : Zero.{u2} \u03b1] {\u03b9 : Type.{u1}} (f : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_10) (g : \u03b9 -> \u03b1 -> A), Eq.{succ u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (Finsupp.sum.{u1, u2, u4} \u03b9 \u03b1 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))))) \u03c6 (Finsupp.sum.{u1, u2, u4} \u03b9 \u03b1 A _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u4} A (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} A (Semiring.toNonAssocSemiring.{u4} A _inst_2))) f g)) (Finsupp.sum.{u1, u2, u5} \u03b9 \u03b1 B _inst_10 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u5} B (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} B (Semiring.toNonAssocSemiring.{u5} B _inst_3))) f (fun (i : \u03b9) (a : \u03b1) => 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))))) \u03c6 (g i a)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_finsupp_sum AlgHom.map_finsupp_sum\u2093'. -/\nprotected theorem map_finsupp_sum {\u03b1 : Type _} [Zero \u03b1] {\u03b9 : Type _} (f : \u03b9 \u2192\u2080 \u03b1) (g : \u03b9 \u2192 \u03b1 \u2192 A) :\n    \u03c6 (f.Sum g) = f.Sum fun i a => \u03c6 (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) : \u03c6 (bit0 x) = bit0 (\u03c6 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) : \u03c6 (bit1 x) = bit1 (\u03c6 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'\u2093'. -/\n/-- If a `ring_hom` is `R`-linear, then it is an `alg_hom`. -/\ndef mk' (f : A \u2192+* B) (h : \u2200 (c : R) (x), f (c \u2022 x) = c \u2022 f x) : A \u2192\u2090[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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) \u1fb0) (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'\u2093'. -/\n@[simp]\ntheorem coe_mk' (f : A \u2192+* B) (h : \u2200 (c : R) (x), f (c \u2022 x) = c \u2022 f x) : \u21d1(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 \u2192\u2090[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 : \u21d1(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\u2093.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\u2093'. -/\n@[simp]\ntheorem id_toRingHom : (AlgHom.id R A : A \u2192+* 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 (\u03c6\u2081 : B \u2192\u2090[R] C) (\u03c6\u2082 : A \u2192\u2090[R] B) : A \u2192\u2090[R] C :=\n  { \u03c6\u2081.toRingHom.comp \u2191\u03c6\u2082 with\n    commutes' := fun r : R => by rw [\u2190 \u03c6\u2081.commutes, \u2190 \u03c6\u2082.commutes] <;> rfl }\n#align alg_hom.comp AlgHom.comp\n-/\n\n#print AlgHom.coe_comp /-\n@[simp]\ntheorem coe_comp (\u03c6\u2081 : B \u2192\u2090[R] C) (\u03c6\u2082 : A \u2192\u2090[R] B) : \u21d1(\u03c6\u2081.comp \u03c6\u2082) = \u03c6\u2081 \u2218 \u03c6\u2082 :=\n  rfl\n#align alg_hom.coe_comp AlgHom.coe_comp\n-/\n\n#print AlgHom.comp_apply /-\ntheorem comp_apply (\u03c6\u2081 : B \u2192\u2090[R] C) (\u03c6\u2082 : A \u2192\u2090[R] B) (p : A) : \u03c6\u2081.comp \u03c6\u2082 p = \u03c6\u2081 (\u03c6\u2082 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] (\u03c6\u2081 : AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) (\u03c6\u2082 : 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\u2093.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 \u03c6\u2081 \u03c6\u2082)) (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\u2093.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))))) \u03c6\u2081) ((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\u2093.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))))) \u03c6\u2082))\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] (\u03c6\u2081 : AlgHom.{u1, u3, u4} R B C _inst_1 _inst_3 _inst_4 _inst_7 _inst_8) (\u03c6\u2082 : 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 \u03c6\u2081 \u03c6\u2082)) (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)) \u03c6\u2081) (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)) \u03c6\u2082))\nCase conversion may be inaccurate. Consider using '#align alg_hom.comp_to_ring_hom AlgHom.comp_toRingHom\u2093'. -/\ntheorem comp_toRingHom (\u03c6\u2081 : B \u2192\u2090[R] C) (\u03c6\u2082 : A \u2192\u2090[R] B) :\n    (\u03c6\u2081.comp \u03c6\u2082 : A \u2192+* C) = (\u03c6\u2081 : B \u2192+* C).comp \u2191\u03c6\u2082 :=\n  rfl\n#align alg_hom.comp_to_ring_hom AlgHom.comp_toRingHom\n\n#print AlgHom.comp_id /-\n@[simp]\ntheorem comp_id : \u03c6.comp (AlgHom.id R A) = \u03c6 :=\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 \u03c6 = \u03c6 :=\n  ext fun x => rfl\n#align alg_hom.id_comp AlgHom.id_comp\n-/\n\n#print AlgHom.comp_assoc /-\ntheorem comp_assoc (\u03c6\u2081 : C \u2192\u2090[R] D) (\u03c6\u2082 : B \u2192\u2090[R] C) (\u03c6\u2083 : A \u2192\u2090[R] B) :\n    (\u03c6\u2081.comp \u03c6\u2082).comp \u03c6\u2083 = \u03c6\u2081.comp (\u03c6\u2082.comp \u03c6\u2083) :=\n  ext fun x => rfl\n#align alg_hom.comp_assoc AlgHom.comp_assoc\n-/\n\n#print AlgHom.toLinearMap /-\n/-- R-Alg \u2964 R-Mod -/\ndef toLinearMap : A \u2192\u2097[R] B where\n  toFun := \u03c6\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] (\u03c6 : 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 \u03c6) 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) \u03c6 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] (\u03c6 : 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 \u03c6) 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))))) \u03c6 p)\nCase conversion may be inaccurate. Consider using '#align alg_hom.to_linear_map_apply AlgHom.toLinearMap_apply\u2093'. -/\n@[simp]\ntheorem toLinearMap_apply (p : A) : \u03c6.toLinearMap p = \u03c6 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 : _ \u2192 A \u2192\u2097[R] B) := fun \u03c6\u2081 \u03c6\u2082 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 \u2192\u2090[R] B) (g : B \u2192\u2090[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\u2093'. -/\n/-- Promote a `linear_map` to an `alg_hom` by supplying proofs about the behavior on `1` and `*`. -/\n@[simps]\ndef ofLinearMap (f : A \u2192\u2097[R] B) (map_one : f 1 = 1) (map_mul : \u2200 x y, f (x * y) = f x * f y) :\n    A \u2192\u2090[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] (\u03c6 : 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 \u03c6) (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 \u03c6) (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 \u03c6) 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 \u03c6) 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 \u03c6) map_one map_mul) \u03c6\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] (\u03c6 : 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 \u03c6) (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 \u03c6) (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 \u03c6) 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 \u03c6) 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 \u03c6) map_one map_mul) \u03c6\nCase conversion may be inaccurate. Consider using '#align alg_hom.of_linear_map_to_linear_map AlgHom.ofLinearMap_toLinearMap\u2093'. -/\n@[simp]\ntheorem ofLinearMap_toLinearMap (map_one) (map_mul) :\n    ofLinearMap \u03c6.toLinearMap map_one map_mul = \u03c6 :=\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\u2093'. -/\n@[simp]\ntheorem toLinearMap_ofLinearMap (f : A \u2192\u2097[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\u2093'. -/\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] (\u03c6 : 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) \u03c6 (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) \u03c6 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] (\u03c6 : 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))))) \u03c6 (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))))) \u03c6 x))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_smul_of_tower AlgHom.map_smul_of_tower\u2093'. -/\ntheorem map_smul_of_tower {R'} [SMul R' A] [SMul R' B] [LinearMap.CompatibleSMul A B R' R] (r : R')\n    (x : A) : \u03c6 (r \u2022 x) = r \u2022 \u03c6 x :=\n  \u03c6.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) : \u03c6 s.Prod = (s.map \u03c6).Prod :=\n  \u03c6.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 \u2192\u2090[R] A) where\n  mul := comp\n  mul_assoc \u03d5 \u03c8 \u03c7 := rfl\n  one := AlgHom.id R A\n  one_mul \u03d5 := ext fun x => rfl\n  mul_one \u03d5 := 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 \u2192\u2090[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 (\u03c6 \u03c8 : A \u2192\u2090[R] A) (x : A) : (\u03c6 * \u03c8) x = \u03c6 (\u03c8 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\u2093'. -/\ntheorem algebraMap_eq_apply (f : A \u2192\u2090[R] B) {y : R} {x : A} (h : algebraMap R A y = x) :\n    algebraMap R B y = f x :=\n  h \u25b8 (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] (\u03c6 : A \u2192\u2090[R] B)\n\n#print AlgHom.map_multiset_prod /-\nprotected theorem map_multiset_prod (s : Multiset A) : \u03c6 s.Prod = (s.map \u03c6).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)] (\u03c6 : 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) {\u03b9 : Type.{u4}} (f : \u03b9 -> A) (s : Finset.{u4} \u03b9), 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) \u03c6 (Finset.prod.{u2, u4} A \u03b9 (CommSemiring.toCommMonoid.{u2} A _inst_2) s (fun (x : \u03b9) => f x))) (Finset.prod.{u3, u4} B \u03b9 (CommSemiring.toCommMonoid.{u3} B _inst_3) s (fun (x : \u03b9) => 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) \u03c6 (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)] (\u03c6 : 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) {\u03b9 : Type.{u1}} (f : \u03b9 -> A) (s : Finset.{u1} \u03b9), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (Finset.prod.{u3, u1} A \u03b9 (CommSemiring.toCommMonoid.{u3} A _inst_2) s (fun (x : \u03b9) => 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))))) \u03c6 (Finset.prod.{u3, u1} A \u03b9 (CommSemiring.toCommMonoid.{u3} A _inst_2) s (fun (x : \u03b9) => f x))) (Finset.prod.{u4, u1} B \u03b9 (CommSemiring.toCommMonoid.{u4} B _inst_3) s (fun (x : \u03b9) => 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))))) \u03c6 (f x)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_prod AlgHom.map_prod\u2093'. -/\nprotected theorem map_prod {\u03b9 : Type _} (f : \u03b9 \u2192 A) (s : Finset \u03b9) :\n    \u03c6 (\u220f x in s, f x) = \u220f x in s, \u03c6 (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)] (\u03c6 : 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) {\u03b1 : Type.{u4}} [_inst_6 : Zero.{u4} \u03b1] {\u03b9 : Type.{u5}} (f : Finsupp.{u5, u4} \u03b9 \u03b1 _inst_6) (g : \u03b9 -> \u03b1 -> 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) \u03c6 (Finsupp.prod.{u5, u4, u2} \u03b9 \u03b1 A _inst_6 (CommSemiring.toCommMonoid.{u2} A _inst_2) f g)) (Finsupp.prod.{u5, u4, u3} \u03b9 \u03b1 B _inst_6 (CommSemiring.toCommMonoid.{u3} B _inst_3) f (fun (i : \u03b9) (a : \u03b1) => 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) \u03c6 (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)] (\u03c6 : 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) {\u03b1 : Type.{u2}} [_inst_6 : Zero.{u2} \u03b1] {\u03b9 : Type.{u1}} (f : Finsupp.{u1, u2} \u03b9 \u03b1 _inst_6) (g : \u03b9 -> \u03b1 -> A), Eq.{succ u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) (Finsupp.prod.{u1, u2, u4} \u03b9 \u03b1 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))))) \u03c6 (Finsupp.prod.{u1, u2, u4} \u03b9 \u03b1 A _inst_6 (CommSemiring.toCommMonoid.{u4} A _inst_2) f g)) (Finsupp.prod.{u1, u2, u5} \u03b9 \u03b1 B _inst_6 (CommSemiring.toCommMonoid.{u5} B _inst_3) f (fun (i : \u03b9) (a : \u03b1) => 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))))) \u03c6 (g i a)))\nCase conversion may be inaccurate. Consider using '#align alg_hom.map_finsupp_prod AlgHom.map_finsupp_prod\u2093'. -/\nprotected theorem map_finsupp_prod {\u03b1 : Type _} [Zero \u03b1] {\u03b9 : Type _} (f : \u03b9 \u2192\u2080 \u03b1) (g : \u03b9 \u2192 \u03b1 \u2192 A) :\n    \u03c6 (f.Prod g) = f.Prod fun i a => \u03c6 (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] (\u03c6 : A \u2192\u2090[R] B)\n\n#print AlgHom.map_neg /-\nprotected theorem map_neg (x) : \u03c6 (-x) = -\u03c6 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) : \u03c6 (x - y) = \u03c6 x - \u03c6 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 `\u2115`-algebra homomorphism. -/\ndef toNatAlgHom [Semiring R] [Semiring S] (f : R \u2192+* S) : R \u2192\u2090[\u2115] 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\u2093'. -/\n/-- Reinterpret a `ring_hom` as a `\u2124`-algebra homomorphism. -/\ndef toIntAlgHom [Ring R] [Ring S] [Algebra \u2124 R] [Algebra \u2124 S] (f : R \u2192+* S) : R \u2192\u2090[\u2124] 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 `\u211a`-algebra homomorphism. This actually yields an equivalence,\nsee `ring_hom.equiv_rat_alg_hom`. -/\ndef toRatAlgHom [Ring R] [Ring S] [Algebra \u211a R] [Algebra \u211a S] (f : R \u2192+* S) : R \u2192\u2090[\u211a] 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\u2093.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\u2093'. -/\n@[simp]\ntheorem toRatAlgHom_toRingHom [Ring R] [Ring S] [Algebra \u211a R] [Algebra \u211a S] (f : R \u2192+* S) :\n    \u2191f.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\u2093.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\u2093'. -/\n@[simp]\ntheorem AlgHom.toRingHom_toRatAlgHom [Ring R] [Ring S] [Algebra \u211a R] [Algebra \u211a S] (f : R \u2192\u2090[\u211a] S) :\n    (f : R \u2192+* 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 `\u211a`-algebra homomorphisms. -/\n@[simps]\ndef RingHom.equivRatAlgHom [Ring R] [Ring S] [Algebra \u211a R] [Algebra \u211a S] : (R \u2192+* S) \u2243 (R \u2192\u2090[\u211a] 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 \u2192\u2090[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\u2093'. -/\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 \u2192\u2090[R] A :=\n  {\n    MulSemiringAction.toRingHom _ _\n      m with\n    toFun := fun a => m \u2022 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\u2093'. -/\ntheorem toAlgHom_injective [FaithfulSMul M A] :\n    Function.Injective (MulSemiringAction.toAlgHom R A : M \u2192 A \u2192\u2090[R] A) := fun m\u2081 m\u2082 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 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.nat.basic\nimport Mathlib.algebra.ordered_group\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# `with_bot \u2115`\n\nLemmas about the type of natural numbers with a bottom element adjoined.\n-/\n\nnamespace nat\n\n\ntheorem with_bot.add_eq_zero_iff {n : with_bot \u2115} {m : with_bot \u2115} : n + m = 0 \u2194 n = 0 \u2227 m = 0 :=\n  sorry\n\ntheorem with_bot.add_eq_one_iff {n : with_bot \u2115} {m : with_bot \u2115} :\n    n + m = 1 \u2194 n = 0 \u2227 m = 1 \u2228 n = 1 \u2227 m = 0 :=\n  sorry\n\n@[simp] theorem with_bot.coe_nonneg {n : \u2115} : 0 \u2264 \u2191n :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (0 \u2264 \u2191n)) (Eq.symm with_bot.coe_zero)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u21910 \u2264 \u2191n)) (propext with_bot.coe_le_coe))) (zero_le n))\n\n@[simp] theorem with_bot.lt_zero_iff (n : with_bot \u2115) : n < 0 \u2194 n = \u22a5 := 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/nat/with_bot_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7461389930307512, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.478003391629636}}
{"text": "/-\nCopyright (c) 2018 Johannes H\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 `\u03b2` has a\ngroup structure and `\u03b1 \u2243 \u03b2` then `\u03b1` 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 {\u03b1 : Type u} {\u03b2 : Type v}\n\nnamespace Equiv\n\nsection Instances\n\nvariable (e : \u03b1 \u2243 \u03b2)\n\n/-- Transfer `has_one` across an `equiv` -/\n@[reducible, to_additive \"Transfer `has_zero` across an `equiv`\"]\nprotected def hasOne [One \u03b2] : One \u03b1 :=\n  \u27e8e.symm 1\u27e9\n#align equiv.has_one Equiv.hasOne\n#align equiv.has_zero Equiv.hasZero\n\n@[to_additive]\ntheorem one_def [One \u03b2] : @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 \u03b2] : Mul \u03b1 :=\n  \u27e8fun x y => e.symm (e x * e y)\u27e9\n#align equiv.has_mul Equiv.hasMul\n#align equiv.has_add Equiv.hasAdd\n\n@[to_additive]\ntheorem mul_def [Mul \u03b2] (x y : \u03b1) : @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 \u03b2] : Div \u03b1 :=\n  \u27e8fun x y => e.symm (e x / e y)\u27e9\n#align equiv.has_div Equiv.hasDiv\n#align equiv.has_sub Equiv.hasSub\n\n@[to_additive]\ntheorem div_def [Div \u03b2] (x y : \u03b1) : @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 \u03b2] : Inv \u03b1 :=\n  \u27e8fun x => e.symm (e x)\u207b\u00b9\u27e9\n#align equiv.has_inv Equiv.hasInv\n#align equiv.has_neg Equiv.hasNeg\n\n@[to_additive]\ntheorem inv_def [Inv \u03b2] (x : \u03b1) : @Inv.inv _ (Equiv.hasInv e) x = e.symm (e x)\u207b\u00b9 :=\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 \u03b2] : SMul R \u03b1 :=\n  \u27e8fun r x => e.symm (r \u2022 e x)\u27e9\n#align equiv.has_smul Equiv.hasSmul\n\ntheorem smul_def {R : Type _} [SMul R \u03b2] (r : R) (x : \u03b1) :\n    @SMul.smul _ _ (e.SMul R) r x = e.symm (r \u2022 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 \u03b2 N] : Pow \u03b1 N :=\n  \u27e8fun x n => e.symm (e x ^ n)\u27e9\n#align equiv.has_pow Equiv.hasPow\n#align equiv.has_smul Equiv.hasSmul\n\ntheorem pow_def {N : Type _} [Pow \u03b2 N] (n : N) (x : \u03b1) :\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 : \u03b1 \u2243 \u03b2` gives a multiplicative equivalence `\u03b1 \u2243* \u03b2`\nwhere the multiplicative structure on `\u03b1` is\nthe one obtained by transporting a multiplicative structure on `\u03b2` back along `e`.\n-/\n@[to_additive\n      \"An equivalence `e : \u03b1 \u2243 \u03b2` gives a additive equivalence `\u03b1 \u2243+ \u03b2`\\nwhere the additive structure on `\u03b1` is\\nthe one obtained by transporting an additive structure on `\u03b2` back along `e`.\"]\ndef mulEquiv (e : \u03b1 \u2243 \u03b2) [Mul \u03b2] :\n    letI := Equiv.hasMul e\n    \u03b1 \u2243* \u03b2 :=\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 : \u03b1 \u2243 \u03b2) [Mul \u03b2] (a : \u03b1) : (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 : \u03b1 \u2243 \u03b2) [Mul \u03b2] (b : \u03b2) :\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 : \u03b1 \u2243 \u03b2` gives a ring equivalence `\u03b1 \u2243+* \u03b2`\nwhere the ring structure on `\u03b1` is\nthe one obtained by transporting a ring structure on `\u03b2` back along `e`.\n-/\ndef ringEquiv (e : \u03b1 \u2243 \u03b2) [Add \u03b2] [Mul \u03b2] :\n    by\n    letI := Equiv.hasAdd e\n    letI := Equiv.hasMul e\n    exact \u03b1 \u2243+* \u03b2 := 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 : \u03b1 \u2243 \u03b2) [Add \u03b2] [Mul \u03b2] (a : \u03b1) : (ringEquiv e) a = e a :=\n  rfl\n#align equiv.ring_equiv_apply Equiv.ringEquiv_apply\n\ntheorem ringEquiv_symm_apply (e : \u03b1 \u2243 \u03b2) [Add \u03b2] [Mul \u03b2] (b : \u03b2) :\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 \u03b2] : Semigroup \u03b1 :=\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 \u03b2] : SemigroupWithZero \u03b1 :=\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 \u03b2] : CommSemigroup \u03b1 :=\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 \u03b2] : MulZeroClass \u03b1 :=\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 \u03b2] : MulOneClass \u03b1 :=\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 \u03b2] : MulZeroOneClass \u03b1 :=\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 \u03b2] : Monoid \u03b1 :=\n  by\n  let one := e.One\n  let mul := e.Mul\n  let pow := e.Pow \u2115\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 \u03b2] : CommMonoid \u03b1 :=\n  by\n  let one := e.One\n  let mul := e.Mul\n  let pow := e.Pow \u2115\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 \u03b2] : Group \u03b1 :=\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 \u2115\n  let zpow := e.Pow \u2124\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 \u03b2] : CommGroup \u03b1 :=\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 \u2115\n  let zpow := e.Pow \u2124\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 \u03b2] :\n    NonUnitalNonAssocSemiring \u03b1 := by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let nsmul := e.SMul \u2115\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 \u03b2] : NonUnitalSemiring \u03b1 :=\n  by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let nsmul := e.SMul \u2115\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 \u03b2] : AddMonoidWithOne \u03b1 :=\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 \u03b2] : AddGroupWithOne \u03b1 :=\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 \u03b2] : NonAssocSemiring \u03b1 :=\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 \u03b2] : Semiring \u03b1 :=\n  by\n  let mul := e.Mul\n  let add_monoid_with_one := e.AddMonoidWithOne\n  let npow := e.Pow \u2115\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 \u03b2] : NonUnitalCommSemiring \u03b1 :=\n  by\n  let zero := e.Zero\n  let add := e.Add\n  let mul := e.Mul\n  let nsmul := e.SMul \u2115\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 \u03b2] : CommSemiring \u03b1 :=\n  by\n  let mul := e.Mul\n  let add_monoid_with_one := e.AddMonoidWithOne\n  let npow := e.Pow \u2115\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 \u03b2] : NonUnitalNonAssocRing \u03b1 :=\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 \u2115\n  let zsmul := e.SMul \u2124\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 \u03b2] : NonUnitalRing \u03b1 :=\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 \u2115\n  let zsmul := e.SMul \u2124\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 \u03b2] : NonAssocRing \u03b1 :=\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 \u03b2] : Ring \u03b1 := by\n  let mul := e.Mul\n  let add_group_with_one := e.AddGroupWithOne\n  let npow := e.Pow \u2115\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 \u03b2] : NonUnitalCommRing \u03b1 :=\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 \u2115\n  let zsmul := e.SMul \u2124\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 \u03b2] : CommRing \u03b1 :=\n  by\n  let mul := e.Mul\n  let add_group_with_one := e.AddGroupWithOne\n  let npow := e.Pow \u2115\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 \u03b2] : Nontrivial \u03b1 :=\n  e.Surjective.Nontrivial\n#align equiv.nontrivial Equiv.nontrivial\n\n/-- Transfer `is_domain` across an `equiv` -/\n@[reducible]\nprotected theorem isDomain [Ring \u03b1] [Ring \u03b2] [IsDomain \u03b2] (e : \u03b1 \u2243+* \u03b2) : IsDomain \u03b1 :=\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 \u03b2] : HasRatCast \u03b1 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 \u03b2] : DivisionRing \u03b1 :=\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 \u2115\n  let zpow := e.Pow \u2124\n  let rat_cast := e.HasRatCast\n  let qsmul := e.SMul \u211a\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 \u03b2] : Field \u03b1 :=\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 \u2115\n  let zpow := e.Pow \u2124\n  let rat_cast := e.HasRatCast\n  let qsmul := e.SMul \u211a\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 : \u03b1 \u2243 \u03b2) [MulAction R \u03b2] : MulAction R \u03b1 :=\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 : \u03b1 \u2243 \u03b2) [AddCommMonoid \u03b2] :\n    letI := Equiv.addCommMonoid e\n    \u2200 [DistribMulAction R \u03b2], DistribMulAction R \u03b1 :=\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 \u03b1)\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 : \u03b1 \u2243 \u03b2) [AddCommMonoid \u03b2] :\n    letI := Equiv.addCommMonoid e\n    \u2200 [Module R \u03b2], Module R \u03b1 :=\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 \u03b1)\n#align equiv.module Equiv.module\n\n/-- An equivalence `e : \u03b1 \u2243 \u03b2` gives a linear equivalence `\u03b1 \u2243\u2097[R] \u03b2`\nwhere the `R`-module structure on `\u03b1` is\nthe one obtained by transporting an `R`-module structure on `\u03b2` back along `e`.\n-/\ndef linearEquiv (e : \u03b1 \u2243 \u03b2) [AddCommMonoid \u03b2] [Module R \u03b2] :\n    by\n    letI := Equiv.addCommMonoid e\n    letI := Equiv.module R e\n    exact \u03b1 \u2243\u2097[R] \u03b2 := 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 : \u03b1 \u2243 \u03b2) [Semiring \u03b2] :\n    letI := Equiv.semiring e\n    \u2200 [Algebra R \u03b2], Algebra R \u03b1 :=\n  by\n  intros\n  fapply RingHom.toAlgebra'\n  \u00b7 exact ((RingEquiv e).symm : \u03b2 \u2192+* \u03b1).comp (algebraMap R \u03b2)\n  \u00b7 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 : \u03b1 \u2243 \u03b2` gives an algebra equivalence `\u03b1 \u2243\u2090[R] \u03b2`\nwhere the `R`-algebra structure on `\u03b1` is\nthe one obtained by transporting an `R`-algebra structure on `\u03b2` back along `e`.\n-/\ndef algEquiv (e : \u03b1 \u2243 \u03b2) [Semiring \u03b2] [Algebra R \u03b2] :\n    by\n    letI := Equiv.semiring e\n    letI := Equiv.algebra R e\n    exact \u03b1 \u2243\u2090[R] \u03b2 := 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 \u00a9 2019 -/\nimport ..equate\nopen robot\nuniverse u\n\nattribute [equate] is_group_hom.mul\n\nsection additive_groups\n    variables {\u03b1 : Type u} [add_comm_group \u03b1] {u v w x y z : \u03b1}\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 : \u2115}\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 : \u2115}\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 : \u2115}\n    @[equate] lemma my_inv_pow : (a\u207b\u00b9)^n = (a^n)\u207b\u00b9 :=\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] {\u03c6 : H \u2192 G} {\u03c8 : G \u2192 H} {x y z h : G}\n    example : (x * z) * (z\u207b\u00b9 * y) = x * y -- [FIXME] finds an overly long soln\n    := by equate\n    example : x * y = (x * z) * (z\u207b\u00b9 * y) -- [NOTE] this is an out-of-scope problem\n    := by equate\n    -- example : x * y = (x * z\u00b2) * (z\u207b\u00b2 * y)\n    -- := by equate\n    def conj (h x : G) := h * x * h \u207b\u00b9\n    @[equate] lemma conj_def : conj h x = h * x * h \u207b\u00b9 := 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)\u207b\u00b9 = conj h (x\u207b\u00b9):=\n    by equate\n    example {h : G} : (conj h x\u207b\u00b9) = (conj h x)\u207b\u00b9 :=\n    by equate -- [FIXME]\n    example : x * y\u207b\u00b9 = (y * x\u207b\u00b9)\u207b\u00b9\n    := by equate\n    example :  (y * x\u207b\u00b9)\u207b\u00b9 = x * y\u207b\u00b9\n    := by equate\n    example [is_group_hom \u03c6] [is_group_hom \u03c8] {x y : G}\n        : is_group_hom (\u03c6 \u2218 \u03c8) := \u27e8\u03bb x y, by equate\u27e9\n    example\n        [is_group_hom \u03c6]\n        (i1 : \u2200 x, \u03c6(\u03c8 x) = x)\n        (i2 : \u2200 x, \u03c8(\u03c6 x) = x) {x y : G}\n        : is_group_hom \u03c8 :=\n    \u27e8\u03bb a b, by equate\u27e9\nend group_homs1\n\nsection group_homs3\n    lemma is_group_hom_mul_2 {\u03b1 \u03b2} [group \u03b1] [comm_group \u03b2]\n    (f g : \u03b1 \u2192 \u03b2) [is_group_hom f] [is_group_hom g] :\n    is_group_hom (\u03bba, f a * g a) :=\n    \u27e8assume a b, by equate\u27e9\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 : \u211d \u2192 Prop} {q : \u211d \u2192 Prop} : \n  (\u2200 x, p x \u2192 q x) \u2192 (\u2200\u1d50 x : \u211d, p x) \u2192 (\u2200\u1d50 x : \u211d, q x) :=\nbegin\n  intros hpq hpae,\n  have h : {x | \u00ac q x} \u2286 {x | \u00ac 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: \u211d \u2192 \u211d) (a : \u211d) (b : \u211d) {\u03bc : measure_theory.measure \u211d}:\n  measure_theory.locally_integrable f \u03bc \u2192 interval_integrable f \u03bc a b :=\nbegin\n  sorry,\nend\n\nlemma lebesgue_measure_translation_invariant {\u03bc : measure_theory.outer_measure \u211d} (p : \u211d \u2192 Prop) {x : \u211d} :\n  \u03bc {y : \u211d | p y} = \u03bc {y : \u211d | 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) : \u03b1 :=\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 `\u03b1`, or `\u2115` 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 `\u03b1`. -/\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This uses\nthe instance cache corresponding to `\u2115`, 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 `\u2115` and\n`\u211a` 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (x : \u03b1) (n : \u2115) (b : \u03b1) : horner 0 x n b = b := sorry\n\ntheorem horner_horner {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (n\u2082 : \u2115) (b : \u03b1) (n' : \u2115) (h : n\u2081 + n\u2082 = n') : horner (horner a\u2081 x n\u2081 0) x n\u2082 b = horner a\u2081 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (k : \u03b1) (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) (b' : \u03b1) (h : k + b = b') : k + horner a x n b = horner a x n b' := sorry\n\ntheorem horner_add_const {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) (k : \u03b1) (b' : \u03b1) (h : b + k = b') : horner a x n b + k = horner a x n b' := sorry\n\ntheorem horner_add_horner_lt {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (b\u2081 : \u03b1) (a\u2082 : \u03b1) (n\u2082 : \u2115) (b\u2082 : \u03b1) (k : \u2115) (a' : \u03b1) (b' : \u03b1) (h\u2081 : n\u2081 + k = n\u2082) (h\u2082 : a\u2081 + horner a\u2082 x k 0 = a') (h\u2083 : b\u2081 + b\u2082 = b') : horner a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2081 b' := sorry\n\ntheorem horner_add_horner_gt {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (b\u2081 : \u03b1) (a\u2082 : \u03b1) (n\u2082 : \u2115) (b\u2082 : \u03b1) (k : \u2115) (a' : \u03b1) (b' : \u03b1) (h\u2081 : n\u2082 + k = n\u2081) (h\u2082 : horner a\u2081 x k 0 + a\u2082 = a') (h\u2083 : b\u2081 + b\u2082 = b') : horner a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2082 b' := sorry\n\ntheorem horner_add_horner_eq {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n : \u2115) (b\u2081 : \u03b1) (a\u2082 : \u03b1) (b\u2082 : \u03b1) (a' : \u03b1) (b' : \u03b1) (t : \u03b1) (h\u2081 : a\u2081 + a\u2082 = a') (h\u2082 : b\u2081 + b\u2082 = b') (h\u2083 : horner a' x n b' = t) : horner a\u2081 x n b\u2081 + horner a\u2082 x n b\u2082 = t := sorry\n\n/-- Evaluate `a + b` where `a` and `b` are already in normal form. -/\ntheorem horner_neg {\u03b1 : Type u_1} [comm_ring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) (a' : \u03b1) (b' : \u03b1) (h\u2081 : -a = a') (h\u2082 : -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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (c : \u03b1) (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) (a' : \u03b1) (b' : \u03b1) (h\u2081 : c * a = a') (h\u2082 : c * b = b') : c * horner a x n b = horner a' x n b' := sorry\n\ntheorem horner_mul_const {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) (c : \u03b1) (a' : \u03b1) (b' : \u03b1) (h\u2081 : a * c = a') (h\u2082 : 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (b\u2081 : \u03b1) (a\u2082 : \u03b1) (n\u2082 : \u2115) (aa : \u03b1) (t : \u03b1) (h\u2081 : horner a\u2081 x n\u2081 b\u2081 * a\u2082 = aa) (h\u2082 : horner aa x n\u2082 0 = t) : horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 0 = t := sorry\n\ntheorem horner_mul_horner {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (b\u2081 : \u03b1) (a\u2082 : \u03b1) (n\u2082 : \u2115) (b\u2082 : \u03b1) (aa : \u03b1) (haa : \u03b1) (ab : \u03b1) (bb : \u03b1) (t : \u03b1) (h\u2081 : horner a\u2081 x n\u2081 b\u2081 * a\u2082 = aa) (h\u2082 : horner aa x n\u2082 0 = haa) (h\u2083 : a\u2081 * b\u2082 = ab) (h\u2084 : b\u2081 * b\u2082 = bb) (H : haa + horner ab x n\u2081 bb = t) : horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 b\u2082 = t := sorry\n\n/-- Evaluate `a * b` where `a` and `b` are in normal form. -/\ntheorem horner_pow {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (m : \u2115) (n' : \u2115) (a' : \u03b1) (h\u2081 : n * m = n') (h\u2082 : a ^ m = a') : horner a x n 0 ^ m = horner a' x n' 0 := sorry\n\ntheorem pow_succ {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (n : \u2115) (b : \u03b1) (c : \u03b1) (h\u2081 : a ^ n = b) (h\u2082 : b * a = c) : a ^ (n + 1) = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = c)) (Eq.symm h\u2082)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = b * a)) (Eq.symm h\u2081)))\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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (x : \u03b1) : x = horner 1 x 1 0 := sorry\n\n/-- Evaluate `a` where `a` is an atom. -/\ntheorem subst_into_pow {\u03b1 : Type u_1} [monoid \u03b1] (l : \u03b1) (r : \u2115) (tl : \u03b1) (tr : \u2115) (t : \u03b1) (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 {\u03b1 : Type u_1} [add_group \u03b1] (a : \u03b1) (b : \u03b1) (c : \u03b1) (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 {\u03b1 : Type u_1} [division_ring \u03b1] (a : \u03b1) (b : \u03b1) (c : \u03b1) (h : a * (b\u207b\u00b9) = 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\u207b\u00b9) = 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' {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) : horner a x n b = x ^ n * a + b := sorry\n\ntheorem mul_assoc_rev {\u03b1 : Type u_1} [semigroup \u03b1] (a : \u03b1) (b : \u03b1) (c : \u03b1) : a * (b * c) = a * b * c := sorry\n\ntheorem pow_add_rev {\u03b1 : Type u_1} [monoid \u03b1] (a : \u03b1) (m : \u2115) (n : \u2115) : a ^ m * a ^ n = a ^ (m + n) := sorry\n\ntheorem pow_add_rev_right {\u03b1 : Type u_1} [monoid \u03b1] (a : \u03b1) (b : \u03b1) (m : \u2115) (n : \u2115) : b * a ^ m * a ^ n = b * a ^ (m + n) := sorry\n\ntheorem add_neg_eq_sub {\u03b1 : Type u_1} [add_group \u03b1] (a : \u03b1) (b : \u03b1) : 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\u00e9goire\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 \u2964 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 \u2964 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  : \u03a0 (s : cone F), s.X \u27f6 t.X)\n(fac'  : \u2200 (s : cone F) (j : J), lift s \u226b t.\u03c0.app j = s.\u03c0.app j . obviously)\n(uniq' : \u2200 (s : cone F) (m : s.X \u27f6 t.X) (w : \u2200 j : J, m \u226b t.\u03c0.app j = s.\u03c0.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\u27e8by intros P Q; cases P; cases Q; congr; ext; solve_by_elim\u27e9\n\n/-- Given a natural transformation `\u03b1 : F \u27f6 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 \u2964 C} (s : cone F) {t : cone G} (P : is_limit t)\n  (\u03b1 : F \u27f6 G) : s.X \u27f6 t.X :=\nP.lift ((cones.postcompose \u03b1).obj s)\n\n@[simp, reassoc] lemma map_\u03c0 {F G : J \u2964 C} (c : cone F) {d : cone G} (hd : is_limit d)\n  (\u03b1 : F \u27f6 G) (j : J) : hd.map c \u03b1 \u226b d.\u03c0.app j = c.\u03c0.app j \u226b \u03b1.app j :=\nfac _ _ _\n\nlemma lift_self {c : cone F} (t : is_limit c) : t.lift c = \ud835\udfd9 c.X :=\n(t.uniq _ _ (\u03bb 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 \u27f6 t :=\n{ hom := h.lift s }\n\nlemma uniq_cone_morphism {s t : cone F} (h : is_limit t) {f f' : s \u27f6 t} :\n  f = f' :=\nhave \u2200 {g : s \u27f6 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 : \u03a0 (s : cone F), s \u27f6 t)\n  (uniq' : \u2200 (s : cone F) (m : s \u27f6 t), m = lift s) : is_limit t :=\n{ lift := \u03bb s, (lift s).hom,\n  uniq' := \u03bb 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 \u2245 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 \u27f6 t) : is_iso f :=\n\u27e8\u27e8P.lift_cone_morphism t, \u27e8P.uniq_cone_morphism, Q.uniq_cone_morphism\u27e9\u27e9\u27e9\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 \u2245 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 \u226b t.\u03c0.app j = s.\u03c0.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 \u226b s.\u03c0.app j = t.\u03c0.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 \u226b (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 \u226b (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 \u2245 t) : is_limit t :=\nis_limit.mk_cone_morphism\n  (\u03bb s, P.lift_cone_morphism s \u226b i.hom)\n  (\u03bb s m, by rw \u2190i.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 \u2245 t) (s) :\n  (P.of_iso_limit i).lift s = P.lift s \u226b 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 \u2245 t) : is_limit r \u2243 is_limit t :=\n{ to_fun := \u03bb h, h.of_iso_limit i,\n  inv_fun := \u03bb 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 \u2245 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 \u2245 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 \u27f6 t.X) :\n  m = h.lift { X := W, \u03c0 := { app := \u03bb b, m \u226b t.\u03c0.app b } } :=\nh.uniq { X := W, \u03c0 := { app := \u03bb b, m \u226b t.\u03c0.app b } } m (\u03bb 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 \u27f6 t.X}\n  (w : \u2200 j, f \u226b t.\u03c0.app j = f' \u226b t.\u03c0.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 \u2964 D}\n  (h : cone G \u2964 cone F) [is_right_adjoint h] {c : cone G} (t : is_limit c) :\n  is_limit (h.obj c) :=\nmk_cone_morphism\n  (\u03bb s, (adjunction.of_right_adjoint h).hom_equiv s c (t.lift_cone_morphism _))\n  (\u03bb 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 \u2964 D}\n  (h : cone G \u224c cone F) {c : cone G} :\n  is_limit (h.functor.obj c) \u2243 is_limit c :=\n{ to_fun := \u03bb 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 \u2964 D}\n  (h : cone G \u224c 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 \u226b\n      (h.functor.inv.map (P.lift_cone_morphism (h.functor.obj s))).hom) \u226b\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 \u2964 C} (\u03b1 : F \u2245 G) (c : cone F) :\n  is_limit ((cones.postcompose \u03b1.hom).obj c) \u2243 is_limit c :=\nof_cone_equiv (cones.postcompose_equivalence \u03b1)\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 \u2964 C} (\u03b1 : F \u2245 G) (c : cone G) :\n  is_limit ((cones.postcompose \u03b1.inv).obj c) \u2243 is_limit c :=\npostcompose_hom_equiv \u03b1.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 \u2964 C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F \u2245 G) : s.X \u2245 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 \u2964 C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F \u2245 G) (j : J) :\n  (cone_points_iso_of_nat_iso P Q w).hom \u226b t.\u03c0.app j = s.\u03c0.app j \u226b w.hom.app j :=\nby simp\n\n@[reassoc]\nlemma cone_points_iso_of_nat_iso_inv_comp {F G : J \u2964 C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F \u2245 G) (j : J) :\n  (cone_points_iso_of_nat_iso P Q w).inv \u226b s.\u03c0.app j = t.\u03c0.app j \u226b w.inv.app j :=\nby simp\n\n@[reassoc]\nlemma lift_comp_cone_points_iso_of_nat_iso_hom {F G : J \u2964 C} {r s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F \u2245 G) :\n  P.lift r \u226b (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 \u224c 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 \u224c K`,\n* the triangle of functors commutes up to a natural isomorphism: `e.functor \u22d9 G \u2245 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 \u2964 C} {s : cone F} {G : K \u2964 C} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (e : J \u224c K) (w : e.functor \u22d9 G \u2245 F) : s.X \u2245 t.X :=\nlet w' : e.inverse \u22d9 F \u2245 G := (iso_whisker_left e.inverse w).symm \u226a\u226b 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_\u03c0, limits.cones.postcompose_obj_\u03c0, 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, \u2190functor.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 \u27f6 X` is the same as\n  a cone on `F` with vertex `W`. -/\ndef hom_iso (h : is_limit t) (W : C) : (W \u27f6 t.X) \u2245 ((const J).obj W \u27f6 F) :=\n{ hom := \u03bb f, (t.extend f).\u03c0,\n  inv := \u03bb \u03c0, h.lift { X := W, \u03c0 := \u03c0 },\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 \u27f6 t.X) :\n  (is_limit.hom_iso h W).hom f = (t.extend f).\u03c0 := 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 \u2245 F.cones :=\nnat_iso.of_components (\u03bb 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 \u27f6 t.X) : Type v) \u2245 { p : \u03a0 j, W \u27f6 F.obj j // \u2200 {j j'} (f : j \u27f6 j'), p j \u226b F.map f = p j' } :=\nh.hom_iso W \u226a\u226b\n{ hom := \u03bb \u03c0,\n  \u27e8\u03bb j, \u03c0.app j, \u03bb j j' f,\n   by convert \u2190(\u03c0.naturality f).symm; apply id_comp\u27e9,\n  inv := \u03bb p,\n  { app := \u03bb j, p.1 j,\n    naturality' := \u03bb j j' f, begin dsimp, rw [id_comp], exact (p.2 f).symm end } }\n\n/-- If G : C \u2192 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 \u2964 D) [faithful G]\n  (ht : is_limit (G.map_cone t)) (lift : \u03a0 (s : cone F), s.X \u27f6 t.X)\n  (h : \u2200 s, G.map (lift s) = ht.lift (G.map_cone s)) : is_limit t :=\n{ lift := lift,\n  fac' := \u03bb s j, by apply G.map_injective; rw [G.map_comp, h]; apply ht.fac,\n  uniq' := \u03bb s m w, begin\n    apply G.map_injective, rw h,\n    refine ht.uniq (G.map_cone s) _ (\u03bb j, _),\n    convert \u2190congr_arg (\u03bb 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 \u2964 C} {F G : C \u2964 D} (h : F \u2245 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 \u2245 \u03a0 s, unique (s \u27f6 t) :=\n{ hom := \u03bb h s,\n  { default := h.lift_cone_morphism s,\n    uniq := \u03bb _, h.uniq_cone_morphism },\n  inv := \u03bb h,\n  { lift := \u03bb s, (h s).default.hom,\n    uniq' := \u03bb s f w, congr_arg cone_morphism.hom ((h s).uniq \u27e8f, w\u27e9) } }\n\nnamespace of_nat_iso\nvariables {X : C} (h : yoneda.obj X \u2245 F.cones)\n\n/-- If `F.cones` is represented by `X`, each morphism `f : Y \u27f6 X` gives a cone with cone point\n`Y`. -/\ndef cone_of_hom {Y : C} (f : Y \u27f6 X) : cone F :=\n{ X := Y, \u03c0 := h.hom.app (op Y) f }\n\n/-- If `F.cones` is represented by `X`, each cone `s` gives a morphism `s.X \u27f6 X`. -/\ndef hom_of_cone (s : cone F) : s.X \u27f6 X := h.inv.app (op s.X) s.\u03c0\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_\u03c0,\nend\n\n@[simp] lemma hom_of_cone_of_hom {Y : C} (f : Y \u27f6 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 (\ud835\udfd9 X)\n\n/-- If `F.cones` is represented by `X`, the cone corresponding to a morphism `f : Y \u27f6 X` is\nthe limit cone extended by `f`. -/\nlemma cone_of_hom_fac {Y : C} (f : Y \u27f6 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) (\ud835\udfd9 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 \u2190cone_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 \u2245 F.cones) :\n  is_limit (limit_cone h) :=\n{ lift := \u03bb s, hom_of_cone h s,\n  fac' := \u03bb s j,\n  begin\n    have h := cone_fac h s,\n    cases s,\n    injection h with h\u2081 h\u2082,\n    simp only [heq_iff_eq] at h\u2082,\n    conv_rhs { rw \u2190 h\u2082 }, refl,\n  end,\n  uniq' := \u03bb s m w,\n  begin\n    rw \u2190hom_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  : \u03a0 (s : cocone F), t.X \u27f6 s.X)\n(fac'  : \u2200 (s : cocone F) (j : J), t.\u03b9.app j \u226b desc s = s.\u03b9.app j . obviously)\n(uniq' : \u2200 (s : cocone F) (m : t.X \u27f6 s.X) (w : \u2200 j : J, t.\u03b9.app j \u226b m = s.\u03b9.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\u27e8by intros P Q; cases P; cases Q; congr; ext; solve_by_elim\u27e9\n\n/-- Given a natural transformation `\u03b1 : F \u27f6 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 \u2964 C} {s : cocone F} (P : is_colimit s) (t : cocone G)\n  (\u03b1 : F \u27f6 G) : s.X \u27f6 t.X :=\nP.desc ((cocones.precompose \u03b1).obj t)\n\n@[simp, reassoc]\nlemma \u03b9_map {F G : J \u2964 C} {c : cocone F} (hc : is_colimit c) (d : cocone G) (\u03b1 : F \u27f6 G)\n  (j : J) : c.\u03b9.app j \u226b is_colimit.map hc d \u03b1 = \u03b1.app j \u226b d.\u03b9.app j :=\nfac _ _ _\n\n@[simp]\nlemma desc_self {t : cocone F} (h : is_colimit t) : h.desc t = \ud835\udfd9 t.X :=\n(h.uniq _ _ (\u03bb 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 \u27f6 s :=\n{ hom := h.desc s }\n\nlemma uniq_cocone_morphism {s t : cocone F} (h : is_colimit t) {f f' : t \u27f6 s} :\n  f = f' :=\nhave \u2200 {g : t \u27f6 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 : \u03a0 (s : cocone F), t \u27f6 s)\n  (uniq' : \u2200 (s : cocone F) (m : t \u27f6 s), m = desc s) : is_colimit t :=\n{ desc := \u03bb s, (desc s).hom,\n  uniq' := \u03bb 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 \u2245 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 \u27f6 t) : is_iso f :=\n\u27e8\u27e8Q.desc_cocone_morphism s, \u27e8P.uniq_cocone_morphism, Q.uniq_cocone_morphism\u27e9\u27e9\u27e9\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 \u2245 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.\u03b9.app j \u226b (cocone_point_unique_up_to_iso P Q).hom = t.\u03b9.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.\u03b9.app j \u226b (cocone_point_unique_up_to_iso P Q).inv = s.\u03b9.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 \u226b 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 \u226b 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 \u2245 t) : is_colimit t :=\nis_colimit.mk_cocone_morphism\n  (\u03bb s, i.inv \u226b P.desc_cocone_morphism s)\n  (\u03bb 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 \u2245 t) (s) :\n  (P.of_iso_colimit i).desc s = i.inv.hom \u226b 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 \u2245 t) : is_colimit r \u2243 is_colimit t :=\n{ to_fun := \u03bb h, h.of_iso_colimit i,\n  inv_fun := \u03bb 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 \u2245 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 \u2245 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 \u27f6 W) :\n  m = h.desc { X := W, \u03b9 := { app := \u03bb b, t.\u03b9.app b \u226b m,\n    naturality' := by intros; erw [\u2190assoc, t.\u03b9.naturality, comp_id, comp_id] } } :=\nh.uniq { X := W, \u03b9 := { app := \u03bb b, t.\u03b9.app b \u226b m, naturality' := _ } } m (\u03bb 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 \u27f6 W}\n  (w : \u2200 j, t.\u03b9.app j \u226b f = t.\u03b9.app j \u226b 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 \u2964 D}\n  (h : cocone G \u2964 cocone F) [is_left_adjoint h] {c : cocone G} (t : is_colimit c) :\n  is_colimit (h.obj c) :=\nmk_cocone_morphism\n  (\u03bb s, ((adjunction.of_left_adjoint h).hom_equiv c s).symm (t.desc_cocone_morphism _))\n  (\u03bb 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 \u2964 D}\n  (h : cocone G \u224c cocone F) {c : cocone G} :\n  is_colimit (h.functor.obj c) \u2243 is_colimit c :=\n{ to_fun := \u03bb 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 \u2964 D}\n  (h : cocone G \u224c 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 \u226b\n    (h.inverse.map (P.desc_cocone_morphism (h.functor.obj s))).hom \u226b\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 \u2964 D}\n  (h : cocone G \u224c 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 \u226b (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 \u2964 C} (\u03b1 : F \u2245 G) (c : cocone G) :\n  is_colimit ((cocones.precompose \u03b1.hom).obj c) \u2243 is_colimit c :=\nof_cocone_equiv (cocones.precompose_equivalence \u03b1)\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 \u2964 C} (\u03b1 : F \u2245 G) (c : cocone F) :\n  is_colimit ((cocones.precompose \u03b1.inv).obj c) \u2243 is_colimit c :=\nprecompose_hom_equiv \u03b1.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 \u2964 C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F \u2245 G) : s.X \u2245 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 \u2964 C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F \u2245 G) (j : J) :\n  s.\u03b9.app j \u226b (cocone_points_iso_of_nat_iso P Q w).hom = w.hom.app j \u226b t.\u03b9.app j :=\nby simp\n\n@[reassoc]\nlemma comp_cocone_points_iso_of_nat_iso_inv {F G : J \u2964 C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F \u2245 G) (j : J) :\n  t.\u03b9.app j \u226b (cocone_points_iso_of_nat_iso P Q w).inv = w.inv.app j \u226b s.\u03b9.app j :=\nby simp\n\n@[reassoc]\nlemma cocone_points_iso_of_nat_iso_hom_desc {F G : J \u2964 C} {s : cocone F} {r t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F \u2245 G) :\n  (cocone_points_iso_of_nat_iso P Q w).hom \u226b 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 \u224c 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 \u224c K`,\n* the triangle of functors commutes up to a natural isomorphism: `e.functor \u22d9 G \u2245 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 \u2964 C} {s : cocone F} {G : K \u2964 C} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (e : J \u224c K) (w : e.functor \u22d9 G \u2245 F) : s.X \u2245 t.X :=\nlet w' : e.inverse \u22d9 F \u2245 G := (iso_whisker_left e.inverse w).symm \u226a\u226b 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_\u03b9, fac, inv_fun_id_assoc_inv_app, whisker_left_app, assoc,\n      comp_id, limits.cocones.precompose_obj_\u03b9, fac_assoc, nat_trans.comp_app],\n    rw [counit_inv_app_functor, \u2190functor.comp_map, \u2190w.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 \u27f6 W` is the same as\n  a cocone on `F` with vertex `W`. -/\ndef hom_iso (h : is_colimit t) (W : C) : (t.X \u27f6 W) \u2245 (F \u27f6 (const J).obj W) :=\n{ hom := \u03bb f, (t.extend f).\u03b9,\n  inv := \u03bb \u03b9, h.desc { X := W, \u03b9 := \u03b9 },\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 \u27f6 W) :\n  (is_colimit.hom_iso h W).hom f = (t.extend f).\u03b9 := 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) \u2245 F.cocones :=\nnat_iso.of_components (is_colimit.hom_iso h) (by intros; ext; dsimp; rw \u2190assoc; 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 \u27f6 W) : Type v) \u2245\n    { p : \u03a0 j, F.obj j \u27f6 W // \u2200 {j j' : J} (f : j \u27f6 j'), F.map f \u226b p j' = p j } :=\nh.hom_iso W \u226a\u226b\n{ hom := \u03bb \u03b9,\n  \u27e8\u03bb j, \u03b9.app j, \u03bb j j' f,\n   by convert \u2190(\u03b9.naturality f); apply comp_id\u27e9,\n  inv := \u03bb p,\n  { app := \u03bb j, p.1 j,\n    naturality' := \u03bb j j' f, begin dsimp, rw [comp_id], exact (p.2 f) end } }\n\n/-- If G : C \u2192 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 \u2964 D) [faithful G]\n  (ht : is_colimit (G.map_cocone t)) (desc : \u03a0 (s : cocone F), t.X \u27f6 s.X)\n  (h : \u2200 s, G.map (desc s) = ht.desc (G.map_cocone s)) : is_colimit t :=\n{ desc := desc,\n  fac' := \u03bb s j, by apply G.map_injective; rw [G.map_comp, h]; apply ht.fac,\n  uniq' := \u03bb s m w, begin\n    apply G.map_injective, rw h,\n    refine ht.uniq (G.map_cocone s) _ (\u03bb j, _),\n    convert \u2190congr_arg (\u03bb 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 \u2964 C} {F G : C \u2964 D} (h : F \u2245 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 \u2245 \u03a0 s, unique (t \u27f6 s) :=\n{ hom := \u03bb h s,\n  { default := h.desc_cocone_morphism s,\n    uniq := \u03bb _, h.uniq_cocone_morphism },\n  inv := \u03bb h,\n  { desc := \u03bb s, (h s).default.hom,\n    uniq' := \u03bb s f w, congr_arg cocone_morphism.hom ((h s).uniq \u27e8f, w\u27e9) } }\n\nnamespace of_nat_iso\nvariables {X : C} (h : coyoneda.obj (op X) \u2245 F.cocones)\n\n/-- If `F.cocones` is corepresented by `X`, each morphism `f : X \u27f6 Y` gives a cocone with cone\npoint `Y`. -/\ndef cocone_of_hom {Y : C} (f : X \u27f6 Y) : cocone F :=\n{ X := Y, \u03b9 := h.hom.app Y f }\n\n/-- If `F.cocones` is corepresented by `X`, each cocone `s` gives a morphism `X \u27f6 s.X`. -/\ndef hom_of_cocone (s : cocone F) : X \u27f6 s.X := h.inv.app s.X s.\u03b9\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_\u03b9,\nend\n\n@[simp] lemma hom_of_cocone_of_hom {Y : C} (f : X \u27f6 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 (\ud835\udfd9 X)\n\n/-- If `F.cocones` is corepresented by `X`, the cocone corresponding to a morphism `f : Y \u27f6 X` is\nthe colimit cocone extended by `f`. -/\nlemma cocone_of_hom_fac {Y : C} (f : X \u27f6 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) (\ud835\udfd9 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 \u2190cocone_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) \u2245 F.cocones) :\n  is_colimit (colimit_cocone h) :=\n{ desc := \u03bb s, hom_of_cocone h s,\n  fac' := \u03bb s j,\n  begin\n    have h := cocone_fac h s,\n    cases s,\n    injection h with h\u2081 h\u2082,\n    simp only [heq_iff_eq] at h\u2082,\n    conv_rhs { rw \u2190 h\u2082 }, refl,\n  end,\n  uniq' := \u03bb s m w,\n  begin\n    rw \u2190hom_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 `\u03a0 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\u2093'. -/\ninstance algebra : Algebra R (A \u00d7 B) :=\n  { Prod.module,\n    RingHom.prod (algebraMap R A)\n      (algebraMap R\n        B) with\n    commutes' := by\n      rintro r \u27e8a, b\u27e9\n      dsimp\n      rw [commutes r a, commutes r b]\n    smul_def' := by\n      rintro r \u27e8a, b\u27e9\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\u2093'. -/\n@[simp]\ntheorem algebraMap_apply (r : R) : algebraMap R (A \u00d7 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\u2093'. -/\n/-- First projection as `alg_hom`. -/\ndef fst : A \u00d7 B \u2192\u2090[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\u2093'. -/\n/-- Second projection as `alg_hom`. -/\ndef snd : A \u00d7 B \u2192\u2090[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\u2093'. -/\n/-- The `pi.prod` of two morphisms is a morphism. -/\n@[simps]\ndef prod (f : A \u2192\u2090[R] B) (g : A \u2192\u2090[R] C) : A \u2192\u2090[R] B \u00d7 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 (\u1fb0 : A) => B) (fun (\u1fb0 : 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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => Prod.{u2, u1} B C) \u1fb0) (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 (\u1fb0 : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => B) \u1fb0) (fun (\u1fb0 : A) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : A) => C) \u1fb0) (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\u2093'. -/\ntheorem coe_prod (f : A \u2192\u2090[R] B) (g : A \u2192\u2090[R] C) : \u21d1(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\u2093'. -/\n@[simp]\ntheorem fst_prod (f : A \u2192\u2090[R] B) (g : A \u2192\u2090[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\u2093'. -/\n@[simp]\ntheorem snd_prod (f : A \u2192\u2090[R] B) (g : A \u2192\u2090[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\u2093'. -/\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\u2093'. -/\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 \u2192\u2090[R] B) \u00d7 (A \u2192\u2090[R] C) \u2243 (A \u2192\u2090[R] B \u00d7 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 \u00d7 X | p.1 \u2264 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 \u00d7 X | p.1 \u2264 p.2} :=\nis_definable_le.definable_le'\n\nlemma definable_le {f : Y \u2192 X} (hf : def_fun S f) {g : Y \u2192 X} (hg : def_fun S g) :\n  def_set S {p : Y | f p \u2264 g p} :=\n(hf.prod' hg).preimage definable_le'\n\nend has_le\n\n/-- In a partial order, `\u2264` is definable if `<` is. -/\nlemma is_definable_le_of_definable_lt [partial_order X] (h : def_set S {p : X \u00d7 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 \u00d7 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 \u2192 X} (hf : def_fun S f) {g : Y \u2192 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 \u2192 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 \u2190 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 `\u266e` := by abstract { blast }\n\n@[pointwise] lemma {u v} pair_equality {\u03b1 : Type u} {\u03b2 : Type v} { X: \u03b1 \u00d7 \u03b2 }: (X^.fst, X^.snd) = X := begin induction X, blast end\n@[pointwise] lemma {u v} pair_equality_1 {\u03b1 : Type u} {\u03b2 : Type v} { X: \u03b1 \u00d7 \u03b2 } { A : \u03b1 } ( p : A = X^.fst ) : (A, X^.snd) = X := begin induction X, blast end\n@[pointwise] lemma {u v} pair_equality_2 {\u03b1 : Type u} {\u03b2 : Type v} { X: \u03b1 \u00d7 \u03b2 } { B : \u03b2 } ( p : B = X^.snd ) : (X^.fst, B) = X := begin induction X, blast end\nattribute [pointwise] subtype.eq\n\ndef {u} auto_cast {\u03b1 \u03b2 : Type u} {h : \u03b1 = \u03b2} (a : \u03b1) := cast h a\n@[simp] lemma {u} auto_cast_identity {\u03b1 : Type u} (a : \u03b1) : @auto_cast \u03b1 \u03b1 \u266e a = a := \u266e\nnotation `\u27e6` p `\u27e7` := @auto_cast _ _ \u266e p\n\nuniverse variables u v u1 v1 u2 v2\n\nstructure Category :=\n  (Obj : Type u)\n  (Hom : Obj \u2192 Obj \u2192 Type v) \n  (identity : \u03a0 X : Obj, Hom X X)\n  (compose  : \u03a0 { X Y Z : Obj }, Hom X Y \u2192 Hom Y Z \u2192 Hom X Z)\n\n  (left_identity  : \u2200 { X Y : Obj } (f : Hom X Y), compose (identity _) f = f)\n  (right_identity : \u2200 { X Y : Obj } (f : Hom X Y), compose f (identity _) = f)\n  (associativity  : \u2200 { 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 \u2192 D^.Obj)\n  (onMorphisms : \u03a0 { X Y : C^.Obj },\n                C^.Hom X Y \u2192 D^.Hom (onObjects X) (onObjects Y))\n  (identities : \u2200 (X : C^.Obj),\n    onMorphisms (C^.identity X) = D^.identity (onObjects X))\n  (functoriality : \u2200 { 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   := \u03bb f, C^.Obj -> D^.Obj,\n  coe := Functor.onObjects }\n\nstructure NaturalTransformation { C D : Category } ( F G : Functor C D ) :=\n  (components: \u03a0 X : C^.Obj, D^.Hom (F X) (G X))\n  (naturality: \u2200 { 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   := \u03bb f, \u03a0 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  ( \u03b1 : NaturalTransformation F G )\n  ( \u03b2 : NaturalTransformation G H ) : NaturalTransformation F H :=\n  {\n    components := \u03bb X, D^.compose (\u03b1 X) (\u03b2 X),\n    naturality := begin\n                    blast,\n                    begin[smt]\n                      -- -- This doesn't work (\"invalid expression\"):\n                      eblast_using [ D^.associativity, \u03b1^.naturality, \u03b2^.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 \u2192+* 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' : \u2200 (I : ideal R), I.radical = I \u2192 I.jacobson = I)\n\ntheorem is_jacobson_iff {R} [comm_ring R] :\n  is_jacobson R \u2194 \u2200 (I : ideal R), I.radical = I \u2192 I.jacobson = I :=\n\u27e8\u03bb h, h.1, \u03bb h, \u27e8h\u27e9\u27e9\n\ntheorem is_jacobson.out {R} [comm_ring R] :\n  is_jacobson R \u2192 \u2200 {I : ideal R}, I.radical = I \u2192 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 \u2194 \u2200 P : ideal R, is_prime P \u2192 P.jacobson = P :=\nbegin\n  refine is_jacobson_iff.trans \u27e8\u03bb h I hI, h I (is_prime.radical hI), _\u27e9,\n  refine \u03bb h I hI, le_antisymm (\u03bb x hx, _) (\u03bb x hx, mem_Inf.mpr (\u03bb _ hJ, hJ.left hx)),\n  rw [\u2190 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 [\u2190 h P hP.right, mem_Inf],\n  exact \u03bb J hJ, hx \u27e8le_trans hP.left hJ.left, hJ.right\u27e9\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 \u22a4 in the set `M` of maximal ideals is equivalent, but makes some proofs cleaner. -/\nlemma is_jacobson_iff_Inf_maximal : is_jacobson R \u2194\n  \u2200 {I : ideal R}, I.is_prime \u2192 \u2203 M : set (ideal R), (\u2200 J \u2208 M, is_maximal J \u2228 J = \u22a4) \u2227 I = Inf M :=\n\u27e8\u03bb H I h, eq_jacobson_iff_Inf_maximal.1 (H.out (is_prime.radical h)),\n  \u03bb H, is_jacobson_iff_prime_eq.2 (\u03bb P hP, eq_jacobson_iff_Inf_maximal.2 (H hP))\u27e9\n\nlemma is_jacobson_iff_Inf_maximal' : is_jacobson R \u2194\n  \u2200 {I : ideal R}, I.is_prime \u2192 \u2203 M : set (ideal R),\n  (\u2200 (J \u2208 M) (K : ideal R), J < K \u2192 K = \u22a4) \u2227 I = Inf M :=\n\u27e8\u03bb H I h, eq_jacobson_iff_Inf_maximal'.1 (H.out (is_prime.radical h)),\n  \u03bb H, is_jacobson_iff_prime_eq.2 (\u03bb P hP, eq_jacobson_iff_Inf_maximal'.2 (H hP))\u27e9\n\nlemma radical_eq_jacobson [H : is_jacobson R] (I : ideal R) : I.radical = I.jacobson :=\nle_antisymm (le_Inf (\u03bb J \u27e8hJ, hJ_max\u27e9, (is_prime.radical_le_iff hJ_max.is_prime).mpr hJ))\n            ((H.out (radical_idem I)) \u25b8 (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\u27e8\u03bb I hI, or.rec_on (eq_bot_or_top I)\n(\u03bb h, le_antisymm\n  (Inf_le \u27e8le_of_eq rfl, (eq.symm h) \u25b8 bot_is_maximal\u27e9)\n  ((eq.symm h) \u25b8 bot_le))\n(\u03bb h, by rw [h, jacobson_eq_top_iff])\u27e9\n\ntheorem is_jacobson_of_surjective [H : is_jacobson R] :\n  (\u2203 (f : R \u2192+* S), function.surjective f) \u2192 is_jacobson S :=\nbegin\n  rintros \u27e8f, hf\u27e9,\n  rw is_jacobson_iff_Inf_maximal,\n  intros p hp,\n  use map f '' {J : ideal R | comap f p \u2264 J \u2227 J.is_maximal },\n  use \u03bb j \u27e8J, hJ, hmap\u27e9, hmap \u25b8 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 [\u2190 comap_radical, is_prime.radical hp])).symm\n    \u25b8 (map_comap_of_surjective f hf p).symm,\n  exact eq.trans this (map_Inf hf (\u03bb J \u27e8hJ, _\u27e9, le_trans (ideal.ker_le_comap f) hJ)),\nend\n\n@[priority 100]\ninstance is_jacobson_quotient [is_jacobson R] : is_jacobson (R \u29f8 I) :=\nis_jacobson_of_surjective \u27e8quotient.mk I, (by rintro \u27e8x\u27e9; use x; refl)\u27e9\n\nlemma is_jacobson_iso (e : R \u2243+* S) : is_jacobson R \u2194 is_jacobson S :=\n\u27e8\u03bb h, @is_jacobson_of_surjective _ _ _ _ h \u27e8(e : R \u2192+* S), e.surjective\u27e9,\n  \u03bb h, @is_jacobson_of_surjective _ _ _ _ h \u27e8(e.symm : S \u2192+* R), e.symm.surjective\u27e9\u27e9\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 = \u22a4,\n  { simp [comap_eq_top_iff.1 hP_top] },\n  { haveI : nontrivial (R \u29f8 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, \u2190 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 (\u03bb 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 \u2192+* 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) \u2191I \u2194 y \u2209 I.1 :=\nbegin\n  refine \u27e8\u03bb h, set.disjoint_left.1 h (mem_powers _), \u03bb h, (disjoint_iff).mpr (eq_bot_iff.mpr _)\u27e9,\n  rintros x \u27e8\u27e8n, rfl\u27e9, hx'\u27e9,\n  rw [\u2190 hI] at hx',\n  exact absurd (hI \u25b8 mem_radical_of_pow_mem hx' : y \u2208 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 \u2194 (comap (algebra_map R S) J).is_maximal \u2227 y \u2209 ideal.comap (algebra_map R S) J :=\nbegin\n  split,\n  { refine \u03bb h, \u27e8_, \u03bb hy, h.ne_top (ideal.eq_top_of_is_unit_mem _ hy\n      (map_units _ \u27e8y, submonoid.mem_powers _\u27e9))\u27e9,\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 \u2209 (comap (algebra_map R S) J).1 :=\n      set.disjoint_left.1 hJ.right (submonoid.mem_powers _),\n    erw [\u2190 H.out (is_prime.radical hJ.left), mem_Inf] at this,\n    push_neg at this,\n    rcases this with \u27e8I, hI, hI'\u27e9,\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 \u2264 map (algebra_map R S) I :=\n        (map_comap (submonoid.powers y) S J) \u25b8 (map_mono hI.left),\n      exact absurd (h.1.2 _ (lt_of_le_of_ne this hJ)) hI_p.1 } },\n  { refine \u03bb h, \u27e8\u27e8\u03bb hJ, h.1.ne_top (eq_top_iff.2 _), \u03bb I hI, _\u27e9\u27e9,\n    { rwa [eq_top_iff, \u2190 (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 _ \u27e8comap_mono (le_of_lt hI), _\u27e9),\n      rwa [map_comap (powers y) S I, map_top] at this,\n      refine \u03bb hI', hI.right _,\n      rw [\u2190 map_comap (powers y) S I, \u2190 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 \u2209 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 \u27e8hI, hy\u27e9\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} \u2243o {p : ideal R // p.is_maximal \u2227 y \u2209 p} :=\n{ to_fun := \u03bb p,\n    \u27e8ideal.comap (algebra_map R S) p.1, (is_maximal_iff_is_maximal_disjoint S y p.1).1 p.2\u27e9,\n  inv_fun := \u03bb p,\n    \u27e8ideal.map (algebra_map R S) p.1, is_maximal_of_is_maximal_disjoint y p.1 p.2.1 p.2.2\u27e9,\n  left_inv := \u03bb J, subtype.eq (map_comap (powers y) S J),\n  right_inv := \u03bb 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' := \u03bb I I', \u27e8\u03bb h, (show I.val \u2264 I'.val,\n    from (map_comap (powers y) S I.val) \u25b8 (map_comap (powers y) S I'.val) \u25b8 (ideal.map_mono h)),\n    \u03bb h x hx, h hx\u27e9 }\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 \u03bb P' hP', le_antisymm _ le_jacobson,\n  obtain \u27e8hP', hPM\u27e9 := (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' \u2264 I \u2227 I.is_maximal \u2227 y \u2209 I } \u2264\n    comap (algebra_map R S) P',\n  { intros x hx,\n    have hxy : x * y \u2208 (comap (algebra_map R S) P').jacobson,\n    { rw [ideal.jacobson, mem_Inf],\n      intros J hJ,\n      by_cases y \u2208 J,\n      { exact J.mul_mem_left x h },\n      { exact J.mul_mem_right y ((mem_Inf.1 hx) \u27e8hJ.left, \u27e8hJ.right, h\u27e9\u27e9) } },\n    rw hP at hxy,\n    cases hP'.mem_or_mem hxy with hxy hxy,\n    { exact hxy },\n    { exact (hPM \u27e8submonoid.mem_powers _, hxy\u27e9).elim } },\n  refine le_trans _ this,\n  rw [ideal.jacobson, comap_Inf', Inf_eq_infi],\n  refine infi_le_infi_of_subset (\u03bb I hI, \u27e8map (algebra_map R S) I, \u27e8_, _\u27e9\u27e9),\n  { exact \u27e8le_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\u27e9 },\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\u2098 S\u2098 : Type*} [comm_ring R\u2098] [comm_ring S\u2098]\n\n/-- If `I` is a prime ideal of `polynomial R` and `pX \u2208 I` is a non-constant polynomial,\n  then the map `R \u2192+* 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 \u2208 P)\n  [algebra (R \u29f8 P.comap (C : R \u2192+* _)) R\u2098]\n  [is_localization.away (pX.map (quotient.mk (P.comap C))).leading_coeff R\u2098]\n  [algebra (R[X] \u29f8 P) S\u2098]\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] \u29f8 P)) S\u2098] :\n  (is_localization.map S\u2098 (quotient_map P C le_rfl)\n    ((submonoid.powers (pX.map (quotient.mk (P.comap C))).leading_coeff).le_comap_map) : R\u2098 \u2192+* _)\n    .is_integral :=\nbegin\n  let P' : ideal R := P.comap C,\n  let M : submonoid (R \u29f8 P') :=\n  submonoid.powers (pX.map (quotient.mk (P.comap C))).leading_coeff,\n  let M' : submonoid (R[X] \u29f8 P) :=\n  (submonoid.powers (pX.map (quotient.mk (P.comap C))).leading_coeff).map (quotient_map P C le_rfl),\n  let \u03c6 : R \u29f8 P' \u2192+* R[X] \u29f8 P := quotient_map P C le_rfl,\n  let \u03c6' := is_localization.map S\u2098 \u03c6 M.le_comap_map,\n  have h\u03c6' : \u03c6.comp (quotient.mk P') = (quotient.mk P).comp C := rfl,\n  intro p,\n  obtain \u27e8\u27e8p', \u27e8q, hq\u27e9\u27e9, hp\u27e9 := is_localization.surj M' p,\n  suffices : \u03c6'.is_integral_elem (algebra_map _ _ p'),\n  { obtain \u27e8q', hq', rfl\u27e9 := hq,\n    obtain \u27e8q'', hq''\u27e9 := is_unit_iff_exists_inv'.1 (is_localization.map_units R\u2098 (\u27e8q', hq'\u27e9 : M)),\n    refine \u03c6'.is_integral_of_is_integral_mul_unit p (algebra_map _ _ (\u03c6 q')) q'' _ (hp.symm \u25b8 this),\n    convert trans (trans (\u03c6'.map_mul _ _).symm (congr_arg \u03c6' hq'')) \u03c6'.map_one using 2,\n    rw [\u2190 \u03c6'.comp_apply, is_localization.map_comp, ring_hom.comp_apply, subtype.coe_mk] },\n  refine is_integral_of_mem_closure''\n    (((algebra_map _ S\u2098).comp (quotient.mk P)) '' (insert X {p | p.degree \u2264 0})) _ _ _,\n  { rintros x \u27e8p, hp, rfl\u27e9,\n    refine hp.rec_on (\u03bb hy, _) (\u03bb hy, _),\n    { refine hy.symm \u25b8 (\u03c6.is_integral_elem_localization_at_leading_coeff ((quotient.mk P) X)\n        (pX.map (quotient.mk P')) _ M \u27e81, pow_one _\u27e9),\n      rwa [eval\u2082_map, h\u03c6', \u2190 hom_eval\u2082, quotient.eq_zero_iff_mem, eval\u2082_C_X] },\n    { rw [set.mem_set_of_eq, degree_le_zero_iff] at hy,\n      refine hy.symm \u25b8 \u27e8X - C (algebra_map _ _ ((quotient.mk P') (p.coeff 0))), monic_X_sub_C _, _\u27e9,\n      simp only [eval\u2082_sub, eval\u2082_C, eval\u2082_X],\n      rw [sub_eq_zero, \u2190 \u03c6'.comp_apply, is_localization.map_comp],\n      refl } },\n  { obtain \u27e8p, rfl\u27e9 := quotient.mk_surjective p',\n    refine polynomial.induction_on p\n      (\u03bb r, subring.subset_closure $ set.mem_image_of_mem _ (or.inr degree_C_le))\n      (\u03bb _ _ h1 h2, _) (\u03bb 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, \u2190 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 \u2192 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\u2098 S\u2098 : Type*) [comm_ring R\u2098] [comm_ring S\u2098]\n  (\u03c6 : R \u2192+* S) (h\u03c6 : function.injective \u03c6) (x : R) (hx : x \u2260 0)\n  [algebra R R\u2098] [is_localization.away x R\u2098]\n  [algebra S S\u2098] [is_localization ((submonoid.powers x).map \u03c6 : submonoid S) S\u2098]\n  (h\u03c6' : ring_hom.is_integral\n    (is_localization.map S\u2098 \u03c6 (submonoid.powers x).le_comap_map : R\u2098 \u2192+* S\u2098)) :\n  (\u22a5 : ideal S).jacobson = (\u22a5 : ideal S) :=\nbegin\n  have hM : ((submonoid.powers x).map \u03c6 : submonoid S) \u2264 non_zero_divisors S :=\n    map_le_non_zero_divisors_of_injective \u03c6 h\u03c6 (powers_le_non_zero_divisors_of_no_zero_divisors hx),\n  letI : is_domain S\u2098 := is_localization.is_domain_of_le_non_zero_divisors _ hM,\n  let \u03c6' : R\u2098 \u2192+* S\u2098 := is_localization.map _ \u03c6 (submonoid.powers x).le_comap_map,\n  suffices : \u2200 I : ideal S\u2098, I.is_maximal \u2192 (I.comap (algebra_map S S\u2098)).is_maximal,\n  { have h\u03d5' : comap (algebra_map S S\u2098) (\u22a5 : ideal S\u2098) = (\u22a5 : ideal S),\n    { rw [\u2190 ring_hom.ker_eq_comap_bot, \u2190 ring_hom.injective_iff_ker_eq_bot],\n      exact is_localization.injective S\u2098 hM },\n    have hS\u2098 : is_jacobson S\u2098 := is_jacobson_of_is_integral' \u03c6' h\u03c6' (is_jacobson_localization x),\n    refine eq_bot_iff.mpr (le_trans _ (le_of_eq h\u03d5')),\n    rw [\u2190 hS\u2098.out radical_bot_of_is_domain, comap_jacobson],\n    exact Inf_le_Inf (\u03bb j hj, \u27e8bot_le, let \u27e8J, hJ\u27e9 := hj in hJ.2 \u25b8 this J hJ.1.2\u27e9) },\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\u2098)).is_prime := comap_is_prime _ I,\n  haveI : (I.comap \u03c6').is_prime := comap_is_prime \u03c6' I,\n  haveI : (\u22a5 : ideal (S \u29f8 I.comap (algebra_map S S\u2098))).is_prime := bot_prime,\n  have hcomm: \u03c6'.comp (algebra_map R R\u2098) = (algebra_map S S\u2098).comp \u03c6 := is_localization.map_comp _,\n  let f := quotient_map (I.comap (algebra_map S S\u2098)) \u03c6 le_rfl,\n  let g := quotient_map I (algebra_map S S\u2098) le_rfl,\n  have := is_maximal_comap_of_is_integral_of_is_maximal' \u03c6' h\u03c6' I\n    (by convert hI; casesI _inst_4; refl),\n  have := ((is_maximal_iff_is_maximal_disjoint R\u2098 x _).1 this).left,\n  have : ((I.comap (algebra_map S S\u2098)).comap \u03c6).is_maximal,\n  { rwa [comap_comap, hcomm, \u2190 comap_comap] at this },\n  rw \u2190 bot_quotient_is_maximal_iff at this \u22a2,\n  refine is_maximal_of_is_integral_of_is_maximal_comap' f _ \u22a5\n    ((eq_bot_iff.2 (comap_bot_le_of_injective f quotient_map_injective)).symm \u25b8 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 \u25b8\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\u2098\n      (by rwa [comap_comap, hcomm, \u2190 bot_quotient_is_maximal_iff])))\n      (ring_hom.is_integral_quotient_of_is_integral _ h\u03c6'))),\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 : \u2200 (x : R), C x \u2208 P \u2192 x = 0) :\n  P.jacobson = P :=\nbegin\n  by_cases Pb : P = \u22a5,\n  { exact Pb.symm \u25b8 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 \u2192+* R[X])).is_prime := comap_is_prime C P,\n    obtain \u27e8p, pP, p0\u27e9 := exists_nonzero_mem_of_ne_bot Pb hP,\n    let x := (polynomial.map (quotient.mk (comap (C : R \u2192+* _) P)) p).leading_coeff,\n    have hx : x \u2260 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] \u29f8 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 (\u03bb I, _),\n  introI hI,\n  let R' : subring (R[X] \u29f8 I) := ((quotient.mk I).comp C).range,\n  let i : R \u2192+* R' := ((quotient.mk I).comp C).range_restrict,\n  have hi : function.surjective (i : R \u2192 R') := ((quotient.mk I).comp C).range_restrict_surjective,\n  have hi' : (polynomial.map_ring_hom i : R[X] \u2192+* R'[X]).ker \u2264 I,\n  { refine \u03bb f hf, polynomial_mem_ideal_of_coeff_mem_ideal I f (\u03bb n, _),\n    replace hf := congr_arg (\u03bb (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, \u2190 quotient.eq_zero_iff_mem, \u2190 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 [\u2190 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 \u27e8i, hi\u27e9)\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] \u2194 is_jacobson R :=\nbegin\n  refine \u27e8_, is_jacobson_polynomial_of_is_jacobson\u27e9,\n  introI H,\n  exact is_jacobson_of_surjective \u27e8eval\u2082_ring_hom (ring_hom.id _) 1, \u03bb x,\n    \u27e8C x, by simp only [coe_eval\u2082_ring_hom, ring_hom.id_apply, eval\u2082_C]\u27e9\u27e9,\nend\n\ninstance [is_jacobson R] : is_jacobson R[X] :=\nis_jacobson_polynomial_iff_is_jacobson.mpr \u2039is_jacobson R\u203a\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' : \u2200 (x : R), C x \u2208 P \u2192 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 \u27e8m, hm\u27e9 := submodule.nonzero_mem_of_bot_lt (bot_lt_of_maximal P polynomial_not_is_field),\n  have : (m : R[X]) \u2260 0, rwa [ne.def, submodule.coe_eq_zero],\n  let \u03c6 : R \u29f8 P.comap C \u2192+* R[X] \u29f8 P := quotient_map P C le_rfl,\n  let M : submonoid (R \u29f8 P.comap C) :=\n    submonoid.powers ((m : R[X]).map (quotient.mk (P.comap C : ideal R))).leading_coeff,\n  rw \u2190 bot_quotient_is_maximal_iff,\n  have hp0 : ((m : R[X]).map (quotient.mk (P.comap C : ideal R))).leading_coeff \u2260 0 :=\n    \u03bb hp0', this $ map_injective (quotient.mk (P.comap C : ideal R))\n      ((quotient.mk (P.comap C : ideal R)).injective_iff.2 (\u03bb x hx,\n      by rwa [quotient.eq_zero_iff_mem, (by rwa eq_bot_iff : (P.comap C : ideal R) = \u22a5)] at hx))\n      (by simpa only [leading_coeff_eq_zero, polynomial.map_zero] using hp0'),\n  have hM : (0 : R \u29f8 P.comap C) \u2209 M := \u03bb \u27e8n, hn\u27e9, hp0 (pow_eq_zero hn),\n  suffices : (\u22a5 : ideal (localization M)).is_maximal,\n  { rw \u2190 is_localization.comap_map_of_is_prime_disjoint M (localization M) \u22a5 bot_prime\n        (\u03bb x hx, hM (hx.2 \u25b8 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] \u29f8 P) := M.map \u03c6,\n  have hM' : (0 : R[X] \u29f8 P) \u2209 M' :=\n    \u03bb \u27e8z, hz\u27e9, hM (quotient_map_injective (trans hz.2 \u03c6.map_zero.symm) \u25b8 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 : (\u22a5 : 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' _ _ \u22a5 this,\n    apply is_integral_is_localization_polynomial_quotient P _ (submodule.coe_mem m) },\n  rw (map_bot.symm : (\u22a5 : ideal (localization M')) =\n                     map (algebra_map (R[X] \u29f8 P) (localization M')) \u22a5),\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 [\u2190 quotient.maximal_ideal_iff_is_field_quotient, \u2190 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' : \u2200 (x : R), C x \u2208 P \u2192 x = 0) :\n  ((quotient.mk P).comp C : R \u2192+* R[X] \u29f8 P).is_integral :=\nbegin\n  refine (is_integral_quotient_map_iff _).mp _,\n  let P' : ideal R := P.comap C,\n  obtain \u27e8pX, hpX, hp0\u27e9 :=\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 \u29f8 P') := submonoid.powers (pX.map (quotient.mk P')).leading_coeff,\n  let \u03c6 : R \u29f8 P' \u2192+* R[X] \u29f8 P := quotient_map P C le_rfl,\n  haveI hp'_prime : P'.is_prime := comap_is_prime C P,\n  have hM : (0 : R \u29f8 P') \u2209 M := \u03bb \u27e8n, hn\u27e9, hp0 $ leading_coeff_eq_zero.mp (pow_eq_zero hn),\n  let M' : submonoid (R[X] \u29f8 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' \u2264 _, from le_non_zero_divisors_of_no_zero_divisors (\u03bb hM', hM _)),\n    exact (let \u27e8z, zM, z0\u27e9 := hM' in (quotient_map_injective (trans z0 \u03c6.map_zero.symm)) \u25b8 zM) },\n  { rw \u2190 is_localization.map_comp M.le_comap_map,\n    refine ring_hom.is_integral_trans (algebra_map (R \u29f8 P') (localization M))\n      (is_localization.map _ _ M.le_comap_map) _ _,\n    { exact (algebra_map (R \u29f8 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 \u2192 R[X]/P` is an integral map. -/\nlemma quotient_mk_comp_C_is_integral_of_jacobson :\n  ((quotient.mk P).comp C : R \u2192+* R[X] \u29f8 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] \u2192+* polynomial (R \u29f8 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 \u03bb p hp, polynomial_mem_ideal_of_coeff_mem_ideal P p (\u03bb 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 \u2190 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' _ _ (\u03bb 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    (\u03bb h, absurd (trans (h \u25b8 hPJ : P = comap f \u22a4) comap_top : P = \u22a4) hP.ne_top) id },\n  { apply_instance, },\n  { obtain \u27e8z, rfl\u27e9 := 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 \u2192+* R[X])).is_maximal :=\nbegin\n  rw [\u2190 @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) \u22a5 ((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] \u2192+* 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] \u29f8 f.ker \u2192+* S := ideal.quotient.lift f.ker f (\u03bb _ h, h),\n  have hfg : (g.comp (quotient.mk f.ker)) = f := ring_hom_ext' rfl rfl,\n  rw [\u2190 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 [\u2190 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  \u2200 (n : \u2115), 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 \u2265 I} = Inf {P prime | P \u2265 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] {\u03b9 : Type*} [fintype \u03b9] [is_jacobson R] :\n  is_jacobson (mv_polynomial \u03b9 R) :=\nbegin\n  haveI := classical.dec_eq \u03b9,\n  let e := fintype.equiv_fin \u03b9,\n  rw is_jacobson_iso (rename_equiv R e).to_ring_equiv,\n  exact is_jacobson_mv_polynomial_fin _\nend\n\nvariables {n : \u2115}\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 \u2192+* mv_polynomial _ R \u29f8 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 [\u2190 fin_succ_equiv_comp_C_eq_C, \u2190 ring_hom.comp_assoc, \u2190 ring_hom.comp_assoc,\n      \u2190 quotient_map_comp_mk le_rfl, ring_hom.comp_assoc (polynomial.C),\n      \u2190 quotient_map_comp_mk le_rfl, ring_hom.comp_assoc, ring_hom.comp_assoc,\n      \u2190 quotient_map_comp_mk le_rfl, \u2190 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 \u2190 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  {\u03c3 : Type*} [fintype \u03c3] {S : Type*} [field S] (f : mv_polynomial \u03c3 R \u2192+* S)\n  (hf : function.surjective f) : (f.comp C).is_integral :=\nbegin\n  haveI := classical.dec_eq \u03c3,\n  obtain \u27e8e\u27e9 := fintype.trunc_equiv_fin \u03c3,\n  let f' : mv_polynomial (fin _) R \u2192+* 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 \u29f8 f'.ker \u2192+* S := ideal.quotient.lift f'.ker f' (\u03bb _ h, h),\n    have hfg : (g.comp (quotient.mk f'.ker)) = f' := ring_hom_ext (\u03bb r, rfl) (\u03bb i, rfl),\n    rw [\u2190 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 \u2190 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 (\u03bb 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 (\u03b1 : Type*) extends order_top \u03b1, order_bot \u03b1\n\nnamespace bounded_partial_order\nsection\n\n  parameters {\u03b1 : Type*} [bl : bounded_lattice \u03b1]\n\n  -- A bounded lattice is a bounded partial order.\n  instance of_top_bot : bounded_partial_order \u03b1 :=\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 {\u03b1 : Type*} [preorder \u03b1] (a c : \u03b1) : Prop :=\na < c \u2227 \u00ac \u2203 b, a < b \u2227 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 (\u03b1 : Type*) extends order_bot \u03b1 :=\n(grade : \u03b1 \u2192 \u2115)\n(grade_bot_eq_zero : grade \u22a5 = 0)\n(lt_grade_of_lt : \u2200 {a b : \u03b1}, a < b \u2192 grade a < grade b)\n(eq_p1_of_cover : \u2200 {a b : \u03b1}, covers a b \u2192 grade a + 1 = grade b)\n\nnamespace graded\nsection\n\n  parameters {\u03b1 : Type*} [graded \u03b1]\n\n  /-- If `a \u2264 b`, then `grade a \u2264 grade b`. -/\n  theorem le_grade_of_le : \u2200 {a b : \u03b1}, a \u2264 b \u2192 graded.grade a \u2264 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 = \u22a5`. -/\n  theorem eq_bot_of_grade_eq_zero {a : \u03b1} : grade a = 0 \u2192 a = \u22a5 :=\n  begin\n    contrapose,\n    intro a_ne_bot,\n    have h : grade a > grade (\u22a5 : \u03b1) :=  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 (\u03b1 : Type*) extends bounded_partial_order \u03b1, graded \u03b1\n\nnamespace graded_bounded_partial_order\nsection\n\n  parameters {\u03b1 : Type*} [graded_bounded_partial_order \u03b1] (a : \u03b1)\n\n  /-- If `grade a = grade \u22a4`, then `a = \u22a4`. -/\n  theorem eq_top_of_grade_eq_grade_top : graded.grade a = graded.grade (\u22a4 : \u03b1) \u2192 a = \u22a4 :=\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 \u22a4]`. -/\n  theorem grade_mem_Iic : graded.grade a \u2208 set.Iic (graded.grade (\u22a4 : \u03b1)) :=\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 : \u03b1 \u2192 fin (grade (\u22a4 : \u03b1) + 1) := \n  \u03bb a, \u27e8graded.grade a, nat.lt_succ_iff.mpr (graded.le_grade_of_le (le_top a))\u27e9\n\nend\nend graded_bounded_partial_order\n\nnamespace flag\nsection\n\n  variables {\u03b1 : Type*} [graded_bounded_partial_order \u03b1] {f f' : set \u03b1}\n\n  /-- A flag is a maximal chain. -/\n  def is_flag (c : set \u03b1) : 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 \u03b1) : Prop :=\n  is_flag f \u2192 is_flag f' \u2192 #(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 : \u03b1) : is_flag f \u2192 e \u2209 f \u2192 \u00ac(\u2200 a \u2208 f, a \u2260 e \u2192 a < e \u2228 e < a) :=\n  begin\n    -- We define `f' = f \u222a {e}`.\n    intros ff e_nmem_f h,\n    let f' := f \u222a {e},\n    have hf' : \u2200 a \u2208 f', a \u2208 f \u2228 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 \u2260 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 \u27e8set.subset_union_left f {e}, f_ne_f'\u27e9,\n  end\n\n  -- Any flag contains the bottom face `\u22a5`.\n  theorem bot_in_flag : is_flag f \u2192 \u22a5 \u2208 f :=\n  begin\n    -- We use the `flag_extend` lemma.\n    intro ff,\n    by_contra bot_nmem_f,\n    apply flag_extend \u22a5 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 `\u22a4`.\n  theorem top_in_flag : is_flag f \u2192 \u22a4 \u2208 f :=\n  begin\n    -- We use the `flag_extend` lemma.\n    intro ff,\n    by_contra top_nmem_f,\n    apply flag_extend \u22a4 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 {\u03b1 : Type*} [graded_bounded_partial_order \u03b1] {f : set \u03b1} (ff : flag.is_flag f) : Type* := f\n\nnamespace flag_faces\nsection\n\n  parameters {\u03b1 : Type*} [graded_bounded_partial_order \u03b1] {f : set \u03b1} {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 \u2194 a.val = b.val := subtype.ext_iff_val\n\n  -- Subtyping preserves inequality and viceversa.\n  lemma ne_iff_subtype : a \u2260 b \u2194 a.val \u2260 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 := \u03bb a b, a.val \u2264 b.val,\n    le_refl := \u03bb a, le_refl a.val,\n    le_trans := \u03bb _ _ _ a_le_b b_le_c, le_trans a_le_b b_le_c,\n    le_antisymm := \u03bb _ _ 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 \u2194 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 \u2260 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 := \u27e8\u22a5, flag.bot_in_flag ff\u27e9,\n    bot_le := \u03bb _, bot_le,\n\n    top := \u27e8\u22a4, flag.top_in_flag ff\u27e9,\n    le_top := \u03bb _, @le_top \u03b1 _ _,\n\n    grade := \u03bb 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 \u27e8a_lt_c, hne\u27e9,\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 \u27e8bv, av_lt_bv, bv_lt_cv\u27e9,\n      apply hne,\n\n      -- To use the `flag_extend` lemma, we must prove that any `x \u2208 f` is comparable to `b`.\n      have bv_mem_f : bv \u2208 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 := \u27e8xv, x_mem_f\u27e9,\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 \u2264 a \u2228 c \u2264 x := begin\n          by_cases x_le_a : x \u2264 a, {\n            exact or.inl x_le_a,\n          },\n          by_cases c_le_x : c \u2264 x, {\n            exact or.inr c_le_x,\n          },\n          exfalso,\n          exact hne \u27e8x, not_le.mp x_le_a, not_le.mp c_le_x\u27e9,\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 := \u27e8bv, bv_mem_f\u27e9,\n      exact \u27e8b, (lt_iff_subtype a b).mpr av_lt_bv, (lt_iff_subtype b c).mpr bv_lt_cv\u27e9,\n    end,\n\n    ..of_partial_order,\n  }\n\nend\nend flag_faces\n\nnamespace flag\nsection\n\n  variables {\u03b1 : Type*} [graded_bounded_partial_order \u03b1] {f f' : set \u03b1}\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 \u207b\u00b9' 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 \u2286 to_flag_faces ff :=\n  \u03bb 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 \u2286 s \u2192 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 \u27e8ch, _, sch\u27e9,\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 \u27e8_, a_mem_ff, av_eq_x\u27e9,\n      exact set.mem_of_eq_of_mem (eq.symm av_eq_x) a_mem_ff,\n    },\n    intro x_mem_f,\n    use \u27e8x, x_mem_f\u27e9,\n    use x_mem_f,\n  end\n\n  /-- The set of grades of a flag. -/\n  def flag_grades (f : set \u03b1): set \u2115 := {n | \u2203 a \u2208 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 \u2192 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 \u2192 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 \u22a4]`. -/\n  theorem flag_grades_maps_to (ff : is_flag f) : set.maps_to graded.grade f (set.Iic (graded.grade (\u22a4 : \u03b1))) :=\n  \u03bb _ _,  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 \u27e8a, a_mem_f\u27e9 \u27e8b, b_mem_f\u27e9).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 \u22a4 + 1)`. -/\n  def fin_grade_inj (ff : is_flag f) : flag_faces ff \u21aa fin (graded.grade (\u22a4 : \u03b1) + 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 \u22a4]` and its inverse image under `grade`, onto `f`.\n    let I := set.Iic (graded.grade (\u22a4 : \u03b1)),\n    let I_fin := set.finite_le_nat (graded.grade (\u22a4 : \u03b1)),\n    let f' : set (flag_faces ff) := graded.grade \u207b\u00b9' 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) \u2115 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) \u2115 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  \u27e8flag_fintype ff\u27e9\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 (\u22a4 : \u03b1)) :=\n  begin\n    let G := flag_grades f,\n    let N := graded.grade (\u22a4 : \u03b1),\n    let I := set.Iic N,\n\n    -- Every flag grade is between `0` and `N`.\n    have G_in_I : G \u2286 I := begin\n      rintros _ \u27e8_, a_mem_f, ga_eq_f\u27e9,\n      rw \u2190ga_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 \u2286 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] \u2229 G` and prove that it's finite and non-empty.\n      let Sm := (set.Iic n) \u2229 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 \u27e8zero_le n, \u27e8\u22a5, bot_in_flag ff, graded.grade_bot_eq_zero\u27e9\u27e9,\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 \u2194 \u00ac m \u2260 n := not_not.symm,\n        rw \u2190h at m_eq_n,\n        rw \u2190m_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 : \u2200 k : \u2115, k \u2208 set.Ioo m n \u2192 k \u2209 G := begin\n        intros k k_mem_i,\n        by_contra k_mem_G,\n        have k_le_m : k \u2264 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, \u221e] \u2229 G`.\n      let SM := (set.Ici n) \u2229 G,\n      have SM_non : SM.nonempty := \u27e8N, set.mem_inter n_mem_I \u27e8\u22a4, top_in_flag ff, rfl\u27e9\u27e9,\n\n      -- We build the smallest grade in `G` that's greater than `N`.\n      let M : \u2115 := 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 \u2194 \u00ac n \u2260 M := not_not.symm,\n        rw \u2190h 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 : \u2200 k : \u2115, k \u2208 set.Ico n M \u2192 k \u2209 G := begin\n        intros k k_mem_i,\n        by_contra k_mem_G,\n        have k_ge_m : k \u2265 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 := \u27e8a, a_mem_f\u27e9,\n      let c : flag_faces ff := \u27e8c, c_mem_f\u27e9,\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 \u2190ga_eq_m at m_lt_M,\n        rw \u2190gc_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 : \u00ac \u2203 b, a < b \u2227 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 \u2190ga_eq_m,\n          exact graded.lt_grade_of_lt a_lt_b,\n        end,\n        have g_lt_M : g < M := begin\n          rw \u2190gc_eq_M,\n          exact graded.lt_grade_of_lt b_lt_c,\n        end,\n        have g_mem_G : g \u2208 G := \u27e8b.val, subtype.mem b, rfl\u27e9,\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 \u27e8a_lt_c, C\u27e9,\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 \u22a4]`. -/\n  theorem flag_grades_surj_on (ff : is_flag f) : set.surj_on graded.grade f (set.Iic (graded.grade (\u22a4 : \u03b1))) :=\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 \u22a4]`. -/\n  theorem flag_grades_surj_on' (ff : is_flag f) : set.surj_on graded.grade (to_flag_faces ff) (set.Iic (graded.grade (\u22a4 : \u03b1))) :=\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 \u22a4]`. -/\n  theorem flag_grades_bij_on (ff : is_flag f) : set.bij_on graded.grade f (set.Iic (graded.grade (\u22a4 : \u03b1))) :=\n  \u27e8flag_grades_maps_to ff, flag_grades_inj_on ff, flag_grades_surj_on ff\u27e9\n\n  /-- Flag grades are bijective from a flag onto `[0, grade \u22a4]`. -/\n  theorem flag_grades_bij_on' (ff : is_flag f) : set.bij_on graded.grade (to_flag_faces ff) (set.Iic (graded.grade (\u22a4 : \u03b1))) :=\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 (\u22a4 : \u03b1) + 1) \u2192 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 \u2243 fin (graded.grade (\u22a4 : \u03b1) + 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)] : \u2115 := 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 (\u22a4 : \u03b1) + 1 :=\n  begin\n    let N := graded.grade (\u22a4 : \u03b1),\n    rw \u2190fintype.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\u2081 := flag_card_eq_grade_top_p1 ff,\n    rw \u2190(flag_card_eq_grade_top_p1 ff') at h\u2081,\n    exact h\u2081,\n  end\n\n  /-- Flag adjacency in an abstract polytope is commutative. -/\n  theorem flag_adj_comm : flag.is_flag f \u2192 flag.is_flag f' \u2192 flag.flag_adj f f' \u2192 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 {\u03b1 : Type*} [graded_bounded_partial_order \u03b1] {f : set \u03b1} {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 : \u2200 {n : \u2115} (a : flag_faces ff), graded.grade a \u2264 n \u2192 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 : \u22a5 \u2264 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 (\u03b1 : Type*) extends (graded_bounded_partial_order \u03b1) :=\n(diamond : \u2200 {a b : \u03b1}, grade a + 2 = grade b \u2192 #(set.Ioo a b) = 2)\n\nset_option old_structure_cmd true\n\nnamespace abstract_polytope\n\n  variables {\u03b1 : Type*} [abstract_polytope \u03b1] {f f' : set \u03b1}\n\n  def grade : \u2115 := graded.grade (\u22a4 : \u03b1)\n\n  -- Any nontrivial section contains a vertex.\n  theorem section_vertex (a b : \u03b1) : b < a \u2192 \u2203 c \u2208 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 \u2203 c : \u03b1, b < c \u2227 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 : \u2203 (d \u2208 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 \u2264 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 \u03c3 R`,\n\n* `mv_polynomial.bind\u2081` and `mv_polynomial.join\u2081` operate on the variable type `\u03c3`.\n* `mv_polynomial.bind\u2082` and `mv_polynomial.join\u2082` operate on the coefficient type `R`.\n\n- `mv_polynomial.bind\u2081 f \u03c6` with `f : \u03c3 \u2192 mv_polynomial \u03c4 R` and `\u03c6 : mv_polynomial \u03c3 R`,\n  is the polynomial `\u03c6(f 1, ..., f i, ...) : mv_polynomial \u03c4 R`.\n- `mv_polynomial.join\u2081 \u03c6` with `\u03c6 : mv_polynomial (mv_polynomial \u03c3 R) R` collapses `\u03c6` to\n  a `mv_polynomial \u03c3 R`, by evaluating `\u03c6` under the map `X f \u21a6 f` for `f : mv_polynomial \u03c3 R`.\n  In other words, if you have a polynomial `\u03c6` in a set of variables indexed by a polynomial ring,\n  you evaluate the polynomial in these indexing polynomials.\n- `mv_polynomial.bind\u2082 f \u03c6` with `f : R \u2192+* mv_polynomial \u03c3 S` and `\u03c6 : mv_polynomial \u03c3 R`\n  is the `mv_polynomial \u03c3 S` obtained from `\u03c6` by mapping the coefficients of `\u03c6` through `f`\n  and considering the resulting polynomial as polynomial expression in `mv_polynomial \u03c3 R`.\n- `mv_polynomial.join\u2082 \u03c6` with `\u03c6 : mv_polynomial \u03c3 (mv_polynomial \u03c3 R)` collapses `\u03c6` to\n  a `mv_polynomial \u03c3 R`, by considering `\u03c6` as polynomial expression in `mv_polynomial \u03c3 R`.\n\nThese operations themselves have algebraic structure: `mv_polynomial.bind\u2081`\nand `mv_polynomial.join\u2081` are algebra homs and\n`mv_polynomial.bind\u2082` and `mv_polynomial.join\u2082` 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\u2081`, `join\u2081`) 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\u2081`, `join\u2081`) 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 {\u03c3 : Type*} {\u03c4 : Type*}\nvariables {R S T : Type*} [comm_semiring R] [comm_semiring S] [comm_semiring T]\n\n/--\n`bind\u2081` is the \"left hand side\" bind operation on `mv_polynomial`, operating on the variable type.\nGiven a polynomial `p : mv_polynomial \u03c3 R` and a map `f : \u03c3 \u2192 mv_polynomial \u03c4 R` taking variables\nin `p` to polynomials in the variable type `\u03c4`, `bind\u2081 f p` replaces each variable in `p` with\nits value under `f`, producing a new polynomial in `\u03c4`. The coefficient type remains the same.\nThis operation is an algebra hom.\n-/\ndef bind\u2081 (f : \u03c3 \u2192 mv_polynomial \u03c4 R) : mv_polynomial \u03c3 R \u2192\u2090[R] mv_polynomial \u03c4 R :=\naeval f\n\n/--\n`bind\u2082` is the \"right hand side\" bind operation on `mv_polynomial`,\noperating on the coefficient type.\nGiven a polynomial `p : mv_polynomial \u03c3 R` and\na map `f : R \u2192 mv_polynomial \u03c3 S` taking coefficients in `p` to polynomials over a new ring `S`,\n`bind\u2082 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\u2082 (f : R \u2192+* mv_polynomial \u03c3 S) : mv_polynomial \u03c3 R \u2192+* mv_polynomial \u03c3 S :=\neval\u2082_hom f X\n\n/--\n`join\u2081` is the monadic join operation corresponding to `mv_polynomial.bind\u2081`. Given a polynomial `p`\nwith coefficients in `R` whose variables are polynomials in `\u03c3` with coefficients in `R`,\n`join\u2081 p` collapses `p` to a polynomial with variables in `\u03c3` and coefficients in `R`.\nThis operation is an algebra hom.\n-/\ndef join\u2081 : mv_polynomial (mv_polynomial \u03c3 R) R \u2192\u2090[R] mv_polynomial \u03c3 R :=\naeval id\n\n/--\n`join\u2082` is the monadic join operation corresponding to `mv_polynomial.bind\u2082`. Given a polynomial `p`\nwith variables in `\u03c3` whose coefficients are polynomials in `\u03c3` with coefficients in `R`,\n`join\u2082 p` collapses `p` to a polynomial with variables in `\u03c3` and coefficients in `R`.\nThis operation is a ring hom.\n-/\ndef join\u2082 : mv_polynomial \u03c3 (mv_polynomial \u03c3 R) \u2192+* mv_polynomial \u03c3 R :=\neval\u2082_hom (ring_hom.id _) X\n\n@[simp] lemma aeval_eq_bind\u2081 (f : \u03c3 \u2192 mv_polynomial \u03c4 R) :\n  aeval f = bind\u2081 f := rfl\n\n@[simp] lemma eval\u2082_hom_C_eq_bind\u2081 (f : \u03c3 \u2192 mv_polynomial \u03c4 R) :\n  eval\u2082_hom C f = bind\u2081 f := rfl\n\n@[simp] lemma eval\u2082_hom_eq_bind\u2082 (f : R \u2192+* mv_polynomial \u03c3 S) :\n  eval\u2082_hom f X = bind\u2082 f := rfl\n\nsection\nvariables (\u03c3 R)\n@[simp] lemma aeval_id_eq_join\u2081 :\n  aeval id = @join\u2081 \u03c3 R _ := rfl\n\nlemma eval\u2082_hom_C_id_eq_join\u2081 (\u03c6 : mv_polynomial (mv_polynomial \u03c3 R) R) :\n  eval\u2082_hom C id \u03c6 = join\u2081 \u03c6 := rfl\n\n@[simp] lemma eval\u2082_hom_id_X_eq_join\u2082 :\n  eval\u2082_hom (ring_hom.id _) X = @join\u2082 \u03c3 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\u2081 eval\u2082_hom_C_eq_bind\u2081 eval\u2082_hom_eq_bind\u2082\n                        aeval_id_eq_join\u2081 eval\u2082_hom_id_X_eq_join\u2082\n\n@[simp]\nlemma bind\u2081_X_right (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (i : \u03c3) : bind\u2081 f (X i) = f i :=\naeval_X f i\n\n@[simp]\nlemma bind\u2082_X_right (f : R \u2192+* mv_polynomial \u03c3 S) (i : \u03c3) : bind\u2082 f (X i) = X i :=\neval\u2082_hom_X' f X i\n\n@[simp]\nlemma bind\u2081_X_left : bind\u2081 (X : \u03c3 \u2192 mv_polynomial \u03c3 R) = alg_hom.id R _ :=\nby { ext1 i, simp }\n\nvariable (f : \u03c3 \u2192 mv_polynomial \u03c4 R)\n\n@[simp]\nlemma bind\u2081_C_right (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (x) : bind\u2081 f (C x) = C x :=\nby simp [bind\u2081, algebra_map_eq]\n\n@[simp]\nlemma bind\u2082_C_right (f : R \u2192+* mv_polynomial \u03c3 S) (r : R) : bind\u2082 f (C r) = f r :=\neval\u2082_hom_C f X r\n\n@[simp]\nlemma bind\u2082_C_left : bind\u2082 (C : R \u2192+* mv_polynomial \u03c3 R) = ring_hom.id _ :=\nby { ext : 2; simp }\n\n@[simp]\nlemma bind\u2082_comp_C (f : R \u2192+* mv_polynomial \u03c3 S) :\n  (bind\u2082 f).comp C = f :=\nring_hom.ext $ bind\u2082_C_right _\n\n@[simp]\nlemma join\u2082_map (f : R \u2192+* mv_polynomial \u03c3 S) (\u03c6 : mv_polynomial \u03c3 R) :\n  join\u2082 (map f \u03c6) = bind\u2082 f \u03c6 :=\nby simp only [join\u2082, bind\u2082, eval\u2082_hom_map_hom, ring_hom.id_comp]\n\n@[simp]\nlemma join\u2082_comp_map (f : R \u2192+* mv_polynomial \u03c3 S) :\n  join\u2082.comp (map f) = bind\u2082 f :=\nring_hom.ext $ join\u2082_map _\n\nlemma aeval_id_rename (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (p : mv_polynomial \u03c3 R) :\n  aeval id (rename f p) = aeval f p :=\nby rw [aeval_rename, function.comp.left_id]\n\n@[simp]\nlemma join\u2081_rename (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (\u03c6 : mv_polynomial \u03c3 R) :\n  join\u2081 (rename f \u03c6) = bind\u2081 f \u03c6 :=\naeval_id_rename _ _\n\n@[simp]\nlemma bind\u2081_id : bind\u2081 (@id (mv_polynomial \u03c3 R)) = join\u2081 := rfl\n\n@[simp]\nlemma bind\u2082_id : bind\u2082 (ring_hom.id (mv_polynomial \u03c3 R)) = join\u2082 := rfl\n\nlemma bind\u2081_bind\u2081 {\u03c5 : Type*} (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (g : \u03c4 \u2192 mv_polynomial \u03c5 R)\n  (\u03c6 : mv_polynomial \u03c3 R) :\n  (bind\u2081 g) (bind\u2081 f \u03c6) = bind\u2081 (\u03bb i, bind\u2081 g (f i)) \u03c6 :=\nby simp [bind\u2081, \u2190 comp_aeval]\n\nlemma bind\u2081_comp_bind\u2081 {\u03c5 : Type*} (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (g : \u03c4 \u2192 mv_polynomial \u03c5 R) :\n  (bind\u2081 g).comp (bind\u2081 f) = bind\u2081 (\u03bb i, bind\u2081 g (f i)) :=\nby { ext1, apply bind\u2081_bind\u2081 }\n\nlemma bind\u2082_comp_bind\u2082 (f : R \u2192+* mv_polynomial \u03c3 S) (g : S \u2192+* mv_polynomial \u03c3 T) :\n  (bind\u2082 g).comp (bind\u2082 f) = bind\u2082 ((bind\u2082 g).comp f) :=\nby { ext : 2; simp }\n\nlemma bind\u2082_bind\u2082 (f : R \u2192+* mv_polynomial \u03c3 S) (g : S \u2192+* mv_polynomial \u03c3 T)\n  (\u03c6 : mv_polynomial \u03c3 R) :\n  (bind\u2082 g) (bind\u2082 f \u03c6) = bind\u2082 ((bind\u2082 g).comp f) \u03c6 :=\nring_hom.congr_fun (bind\u2082_comp_bind\u2082 f g) \u03c6\n\nlemma rename_comp_bind\u2081 {\u03c5 : Type*} (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (g : \u03c4 \u2192 \u03c5) :\n  (rename g).comp (bind\u2081 f) = bind\u2081 (\u03bb i, rename g $ f i) :=\nby { ext1 i, simp }\n\nlemma rename_bind\u2081 {\u03c5 : Type*} (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (g : \u03c4 \u2192 \u03c5) (\u03c6 : mv_polynomial \u03c3 R) :\n  rename g (bind\u2081 f \u03c6) = bind\u2081 (\u03bb i, rename g $ f i) \u03c6 :=\nalg_hom.congr_fun (rename_comp_bind\u2081 f g) \u03c6\n\nlemma map_bind\u2082 (f : R \u2192+* mv_polynomial \u03c3 S) (g : S \u2192+* T) (\u03c6 : mv_polynomial \u03c3 R) :\n  map g (bind\u2082 f \u03c6) = bind\u2082 ((map g).comp f) \u03c6 :=\nbegin\n  simp only [bind\u2082, eval\u2082_comp_right, coe_eval\u2082_hom, eval\u2082_map],\n  congr' 1 with : 1,\n  simp only [function.comp_app, map_X]\nend\n\nlemma bind\u2081_comp_rename {\u03c5 : Type*} (f : \u03c4 \u2192 mv_polynomial \u03c5 R) (g : \u03c3 \u2192 \u03c4) :\n  (bind\u2081 f).comp (rename g) = bind\u2081 (f \u2218 g) :=\nby { ext1 i, simp }\n\nlemma bind\u2081_rename {\u03c5 : Type*} (f : \u03c4 \u2192 mv_polynomial \u03c5 R) (g : \u03c3 \u2192 \u03c4) (\u03c6 : mv_polynomial \u03c3 R) :\n  bind\u2081 f (rename g \u03c6) = bind\u2081 (f \u2218 g) \u03c6 :=\nalg_hom.congr_fun (bind\u2081_comp_rename f g) \u03c6\n\nlemma bind\u2082_map (f : S \u2192+* mv_polynomial \u03c3 T) (g : R \u2192+* S) (\u03c6 : mv_polynomial \u03c3 R) :\n  bind\u2082 f (map g \u03c6) = bind\u2082 (f.comp g) \u03c6 :=\nby simp [bind\u2082]\n\n@[simp]\nlemma map_comp_C (f : R \u2192+* S) : (map f).comp (C : R \u2192+* mv_polynomial \u03c3 R) = C.comp f :=\nby { ext1, apply map_C }\n\n-- mixing the two monad structures\n\n\nlemma map_bind\u2081 (f : R \u2192+* S) (g : \u03c3 \u2192 mv_polynomial \u03c4 R) (\u03c6 : mv_polynomial \u03c3 R) :\n  map f (bind\u2081 g \u03c6) = bind\u2081 (\u03bb (i : \u03c3), (map f) (g i)) (map f \u03c6) :=\nby { rw [hom_bind\u2081, map_comp_C, \u2190 eval\u2082_hom_map_hom], refl }\n\n@[simp]\nlemma eval\u2082_hom_comp_C (f : R \u2192+* S) (g : \u03c3 \u2192 S) :\n  (eval\u2082_hom f g).comp C = f :=\nby { ext1 r, exact eval\u2082_C f g r }\n\nlemma eval\u2082_hom_bind\u2081 (f : R \u2192+* S) (g : \u03c4 \u2192 S) (h : \u03c3 \u2192 mv_polynomial \u03c4 R)\n  (\u03c6 : mv_polynomial \u03c3 R) :\n  eval\u2082_hom f g (bind\u2081 h \u03c6) = eval\u2082_hom f (\u03bb i, eval\u2082_hom f g (h i)) \u03c6 :=\nby rw [hom_bind\u2081, eval\u2082_hom_comp_C]\n\nlemma aeval_bind\u2081 [algebra R S] (f : \u03c4 \u2192 S) (g : \u03c3 \u2192 mv_polynomial \u03c4 R) (\u03c6 : mv_polynomial \u03c3 R) :\n  aeval f (bind\u2081 g \u03c6) = aeval (\u03bb i, aeval f (g i)) \u03c6 :=\neval\u2082_hom_bind\u2081 _ _ _ _\n\nlemma aeval_comp_bind\u2081 [algebra R S] (f : \u03c4 \u2192 S) (g : \u03c3 \u2192 mv_polynomial \u03c4 R) :\n  (aeval f).comp (bind\u2081 g) = aeval (\u03bb i, aeval f (g i)) :=\nby { ext1, apply aeval_bind\u2081 }\n\nlemma eval\u2082_hom_comp_bind\u2082 (f : S \u2192+* T) (g : \u03c3 \u2192 T) (h : R \u2192+* mv_polynomial \u03c3 S) :\n  (eval\u2082_hom f g).comp (bind\u2082 h) = eval\u2082_hom ((eval\u2082_hom f g).comp h) g :=\nby { ext : 2; simp }\n\nlemma eval\u2082_hom_bind\u2082 (f : S \u2192+* T) (g : \u03c3 \u2192 T) (h : R \u2192+* mv_polynomial \u03c3 S)\n  (\u03c6 : mv_polynomial \u03c3 R) :\n  eval\u2082_hom f g (bind\u2082 h \u03c6) = eval\u2082_hom ((eval\u2082_hom f g).comp h) g \u03c6 :=\nring_hom.congr_fun (eval\u2082_hom_comp_bind\u2082 f g h) \u03c6\n\nlemma aeval_bind\u2082 [algebra S T] (f : \u03c3 \u2192 T) (g : R \u2192+* mv_polynomial \u03c3 S) (\u03c6 : mv_polynomial \u03c3 R) :\n  aeval f (bind\u2082 g \u03c6) = eval\u2082_hom ((\u2191(aeval f : _ \u2192\u2090[S] _) : _ \u2192+* _).comp g) f \u03c6 :=\neval\u2082_hom_bind\u2082 _ _ _ _\n\nlemma eval\u2082_hom_C_left (f : \u03c3 \u2192 mv_polynomial \u03c4 R) : eval\u2082_hom C f = bind\u2081 f := rfl\n\nlemma bind\u2081_monomial (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (d : \u03c3 \u2192\u2080 \u2115) (r : R) :\n  bind\u2081 f (monomial d r) = C r * \u220f i in d.support, f i ^ d i :=\nby simp only [monomial_eq, alg_hom.map_mul, bind\u2081_C_right, finsupp.prod,\n  alg_hom.map_prod, alg_hom.map_pow, bind\u2081_X_right]\n\nlemma bind\u2082_monomial (f : R \u2192+* mv_polynomial \u03c3 S) (d : \u03c3 \u2192\u2080 \u2115) (r : R) :\n  bind\u2082 f (monomial d r) = f r * monomial d 1 :=\nby simp only [monomial_eq, ring_hom.map_mul, bind\u2082_C_right, finsupp.prod,\n  ring_hom.map_prod, ring_hom.map_pow, bind\u2082_X_right, C_1, one_mul]\n\n@[simp]\nlemma bind\u2082_monomial_one (f : R \u2192+* mv_polynomial \u03c3 S) (d : \u03c3 \u2192\u2080 \u2115) :\n  bind\u2082 f (monomial d 1) = monomial d 1 :=\nby rw [bind\u2082_monomial, f.map_one, one_mul]\n\nsection\nopen_locale classical\n\nlemma vars_bind\u2081 (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (\u03c6 : mv_polynomial \u03c3 R) :\n  (bind\u2081 f \u03c6).vars \u2286 \u03c6.vars.bUnion (\u03bb i, (f i).vars) :=\nbegin\n  calc (bind\u2081 f \u03c6).vars\n      = (\u03c6.support.sum (\u03bb (x : \u03c3 \u2192\u2080 \u2115), (bind\u2081 f) (monomial x (coeff x \u03c6)))).vars :\n        by { rw [\u2190 alg_hom.map_sum, \u2190 \u03c6.as_sum], }\n  ... \u2264 \u03c6.support.bUnion (\u03bb (i : \u03c3 \u2192\u2080 \u2115), ((bind\u2081 f) (monomial i (coeff i \u03c6))).vars) :\n        vars_sum_subset _ _\n  ... = \u03c6.support.bUnion (\u03bb (d : \u03c3 \u2192\u2080 \u2115), (C (coeff d \u03c6) * \u220f i in d.support, f i ^ d i).vars) :\n        by simp only [bind\u2081_monomial]\n  ... \u2264 \u03c6.support.bUnion (\u03bb (d : \u03c3 \u2192\u2080 \u2115), d.support.bUnion (\u03bb i, (f i).vars)) : _ -- proof below\n  ... \u2264 \u03c6.vars.bUnion (\u03bb (i : \u03c3), (f i).vars) : _, -- proof below\n  { apply finset.bUnion_mono,\n    intros d hd,\n    calc (C (coeff d \u03c6) * \u220f (i : \u03c3) in d.support, f i ^ d i).vars\n        \u2264 (C (coeff d \u03c6)).vars \u222a (\u220f (i : \u03c3) in d.support, f i ^ d i).vars : vars_mul _ _\n    ... \u2264 (\u220f (i : \u03c3) 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    ... \u2264 d.support.bUnion (\u03bb (i : \u03c3), (f i ^ d i).vars) : vars_prod _\n    ... \u2264 d.support.bUnion (\u03bb (i : \u03c3), (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 \u27e8d, hd, \u27e8i, hi, hj\u27e9\u27e9,\n    exact \u27e8i, (mem_vars _).mpr \u27e8d, hd, hi\u27e9, hj\u27e9 }\nend\nend\n\nlemma mem_vars_bind\u2081 (f : \u03c3 \u2192 mv_polynomial \u03c4 R) (\u03c6 : mv_polynomial \u03c3 R) {j : \u03c4}\n  (h : j \u2208 (bind\u2081 f \u03c6).vars) :\n  \u2203 (i : \u03c3), i \u2208 \u03c6.vars \u2227 j \u2208 (f i).vars :=\nby simpa only [exists_prop, finset.mem_bUnion, mem_support_iff, ne.def] using vars_bind\u2081 f \u03c6 h\n\ninstance monad : monad (\u03bb \u03c3, mv_polynomial \u03c3 R) :=\n{ map := \u03bb \u03b1 \u03b2 f p, rename f p,\n  pure := \u03bb _, X,\n  bind := \u03bb _ _ p f, bind\u2081 f p }\n\ninstance is_lawful_functor : is_lawful_functor (\u03bb \u03c3, mv_polynomial \u03c3 R) :=\n{ id_map := by intros; simp [(<$>)],\n  comp_map := by intros; simp [(<$>)] }\n\ninstance is_lawful_monad : is_lawful_monad (\u03bb \u03c3, mv_polynomial \u03c3 R) :=\n{ pure_bind := by intros; simp [pure, bind],\n  bind_assoc := by intros; simp [bind, \u2190 bind\u2081_comp_bind\u2081] }\n\n/-\nPossible TODO for the future:\nEnable the following definitions, and write a lot of supporting lemmas.\n\ndef bind (f : R \u2192+* mv_polynomial \u03c4 S) (g : \u03c3 \u2192 mv_polynomial \u03c4 S) :\n  mv_polynomial \u03c3 R \u2192+* mv_polynomial \u03c4 S :=\neval\u2082_hom f g\n\ndef join (f : R \u2192+* S) : mv_polynomial (mv_polynomial \u03c3 R) S \u2192\u2090[S] mv_polynomial \u03c3 S :=\naeval (map f)\n\ndef ajoin [algebra R S] : mv_polynomial (mv_polynomial \u03c3 R) S \u2192\u2090[S] mv_polynomial \u03c3 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 {\u03c9 \u03c0 : OrdinalDate} : \u03c9 <= \u03c0 \u2192 \u03c9.toYmd <= \u03c0.toYmd := sorry\n\ntheorem Ymd.toOrdinalDate_monotonic {d\u2081 d\u2082 : Ymd} : d\u2081 <= d\u2082 \u2192 d\u2081.toOrdinalDate <= d\u2082.toOrdinalDate := sorry\n\ntheorem OrdinalDate.toScalarDate_monotonic {\u03c9 \u03c0 : OrdinalDate} : \u03c9 <= \u03c0 \u2192 \u03c9.toScalarDate <= \u03c0.toScalarDate := sorry\n\ntheorem ScalarDate.toOrdinalDate_monotonic {d1 d2 : ScalarDate} : d1 <= d2 \u2192 d1.toOrdinalDate <= d2.toOrdinalDate := sorry\n\ntheorem Ymd.toScalarDate_monotonic {y1 y2 : Ymd} : y1 <= y2 \u2192 y1.toScalarDate <= y2.toScalarDate := \n  OrdinalDate.toScalarDate_monotonic \u2218 Ymd.toOrdinalDate_monotonic\n\ntheorem ScalarDate.toYmd_monotonic {d1 d2 : ScalarDate} : d1 <= d2 \u2192 d1.toYmd <= d2.toYmd :=\n  OrdinalDate.toYmd_monotonic \u2218 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 \u222a 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 \u2286 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 \u2208 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 \u2192+* subfield_generated K S :=\n\u27e8\n  (\u03bb a, \u27e8 algebra_map K L a , subset_closure_base K S a\u27e9 ),\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\u27e9\n\ninstance has_scalar : has_scalar K (subfield_generated K S) :=\n\u27e8 \u03bb a r, (ring_hom K S a) * r \u27e9\n-- #check algebra\n\n@[simp] instance algebra : algebra K (subfield_generated K S) :=\n\u27e8\n  ring_hom K S ,\n  \u03bb r, field.mul_comm (ring_hom K S r),\n  (\u03bb r x, rfl) ,\n\u27e9\n\n@[simp] noncomputable def eval {n : \u2115} (as : fin n \u2192 L) (has : \u03a0 k, as k \u2208 S) :\n  mv_polynomial (fin n) K \u2192+* subfield_generated K S :=\n  mv_polynomial.eval\u2082_hom (algebra_map K (subfield_generated K S))\n    (\u03bb k, \u27e8 as k , subfield_generated.subset_closure_set K S (has k) \u27e9)\n\nlemma eval_proj {n : \u2115} (as : fin n \u2192 L) (has : \u03a0 k, as k \u2208 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 : \u2115} (as : fin n \u2192 L) (has : \u03a0 k, as k \u2208 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  (\u03bb 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\u2082_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\u2082_hom, subfield.coe_add, ring_hom.to_fun_eq_coe,\n     mv_polynomial.eval\u2082_add, mv_polynomial.eval_map, subtype.val_eq_coe],\n  simp only [eval, mv_polynomial.coe_eval\u2082_hom, subfield.coe_add, ring_hom.to_fun_eq_coe,\n     mv_polynomial.eval\u2082_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\u2082_hom, subfield_generated,\n    mv_polynomial.eval_map, subfield_generated.algebra,\n    subtype.coe_mk, mul_eq_mul_right_iff, mv_polynomial.eval\u2082_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\u2082_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\u03a0 (n : \u2115) (f : mv_polynomial (fin n) K) (as : fin n \u2192 L),\n(\u03a0 k, as k \u2208 S) \u2192 mv_polynomial.eval as (f : mv_polynomial (fin n) L) = 0 \u2192 f = 0\n\nlemma indep_subset (S T : set L) (hST : S \u2286 T) : indep K T \u2192 indep K S :=\nbegin\n  intros hT _ f as has hf,\n  have has' : \u03a0 k, as k \u2208 T := \u03bb k, hST (has k),\n  exact hT _ f as has' hf,\nend\n\n\nlemma indep_empty : indep K (\u2205 : 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 \u2190 mv_polynomial.C_0,\n  rw (mv_polynomial.C_inj L),\n  rw \u2190 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 \u2190 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 : \u03a0 (S : set L) (hS : S \u2208 c), indep K S) :\n  indep K \u22c3\u2080 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 \u2227 \u03a0 (S : set L), indep K S \u2192 B \u2286 S \u2192 S = B\n\nlemma extend_to_basis_aux (S : set L) (hindS : indep K S) :\n  \u2203 (B : set L) (H : B \u2208 {T : set L | S \u2286 T \u2227 indep K T}),\n  S \u2286 B \u2227 \u03a0 (T : set L), T \u2208 {T : set L | S \u2286 T \u2227 indep K T} \u2192 B \u2286 T \u2192 T = B :=\n(@zorn.zorn_subset_nonempty L { T : set L | S \u2286 T \u2227 indep K T }\n  (\u03bb c hcsub hchain hc0,\n    \u27e8\n      -- the upper bound by taking union\n      \u22c3\u2080 c ,\n      \u27e8\n        let hScup : S \u2286 \u22c3\u2080 c :=\n        begin\n          cases hc0 with T hT,\n          cases hcsub hT with hST hand,\n          have hTcup : T \u2286 \u22c3\u2080 c := \u03bb t ht , \u27e8 T , hT , ht \u27e9,\n          exact set.subset.trans hST hTcup,\n        end in\n        \u27e8 -- the upper bound is in the set\n          hScup ,\n          indep_sUnion_chain K hchain hc0 (\u03bb S hs, (hcsub hs).2)\n        \u27e9 ,\n        (\u03bb S hS s hs, \u27e8 S , hS , hs \u27e9) -- showing the maximal element is in the set\n      \u27e9\n    \u27e9\n  )\n  S -- give U for the set being non-empty\n  \u27e8 set.subset.refl _ , hindS \u27e9)\n\nlemma subfield_mem (a : L) (K : subfield L) (haK : a \u2208 K) :\n  a = algebra_map K L (\u27e8 a , haK \u27e9 : K) := rfl\n\nlemma is_algebraic_subfield {a : L} {K : subfield L} (haK : a \u2208 K) : is_algebraic K a :=\n\u27e8\n  polynomial.X - polynomial.C (\u27e8 a , haK \u27e9 : 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 \u2190 subfield_mem a K haK,\n    simp,\n  end\n\u27e9\n\n-- #check @mv_polynomial.map_injective\n-- -- mv_polynomial.eval\u2082 polynomial.C bs (\u21d1(mv_polynomial.map (subfield_generated.ring_hom K B)) f)\n\n-- #check @ring_hom.injective\n\n-- #check @mv_polynomial.eval\u2082\n\n-- #check mv_polynomial.eval\u2082_zero\n-- --\n-- #check polynomial.as_sum_range\n\nlemma mv_polynomial.zero_iff {K : Type u} {R : Type v} {\u03c3 : Type v0} [field K] [comm_semiring R]\n  [nontrivial R] (f : K \u2192+* R) (p : mv_polynomial \u03c3 K) : p = 0 \u2194 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\u2082\n\n-- #check mv_polynomial.mv_polynomial_equiv_mv_polynomial\n\nlemma insert_dependent_to_is_algebraic_aux {n : \u2115} {S : set L} {a : L} :\n  (\u2203 (p : mv_polynomial (fin n.succ) K) (as : fin n.succ \u2192 L) (has : \u2200 (k : fin n.succ), as k \u2208 S \u222a {a})\n    (hp : (mv_polynomial.eval as) p = 0), p \u2260 0)\n  \u2192\n  (\u2203 (p : polynomial (mv_polynomial (fin n) K)) (as : fin n \u2192 L)\n    (has : \u2200 (k : fin n), as k \u2208 S)\n    (hp : (polynomial.aeval a) (polynomial.map (subfield_generated.eval K S as has) p) = 0), p \u2260 0) :=\nsorry\n\n-- should really be iff\nlemma insert_dependent_to_is_algebraic (S : set L) (hS : indep K S) (a : L) :\n  \u00ac indep K (S \u222a {a}) \u2192 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 \u2192+* 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 \u2190 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--   \u00ac indep K (S \u222a {a}) \u2192 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 \u2192 polynomial (subfield_generated K S) :=\n--     \u03bb k, @decidable.by_cases (as k \u2208 S) (polynomial (subfield_generated K S)) _\n--       (\u03bb h, polynomial.C\n--         (\u27e8 as k , subfield_generated.subset_closure_set K S h \u27e9 : subfield_generated K S))\n--       (\u03bb _, polynomial.X),\n--     let p : polynomial (subfield_generated K S) :=\n--       mv_polynomial.eval\u2082 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 \u2190 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 \u222a {x}),\n  {\n    -- if B \u222a {x} is independent then x \u2208 B since B is a basis\n    have hBx := hB.2 (B \u222a {x}) hind (by simp),\n    -- hence x \u2208 K(B) and is independent over K(B)\n    have hxBx : x \u2208 subfield_generated K B,\n    {apply subfield.subset_closure, left, rw \u2190 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    \u2203 (B : set L), S \u2286 B \u2227 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 \u27e8 set.subset.trans hSB hBT , hindT \u27e9,\n    }\n  }\nend\n\nlemma basis_ex : \u2203 (B : set L), basis K B :=\nbegin\n  cases extend_to_basis K L \u2205 (indep_empty K) with B hB,\n  use B,\n  exact hB.2,\nend\n\nlemma basis_some : set L := @classical.some (set L) (\u03bb 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 \u2192 indep K S1 \u2192 equiv S0 S1 \u2192\n  subfield_generated K S0 \u2243+* 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 \u2243+* K1 \u2192\n  is_algebraic K0 L0 \u2192 is_algebraic K1 L1 \u2192 L0 \u2243+* 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 \u2192 transcendent.basis K B1 \u2192\n  equiv B0 B1\n  \u2192 L0 \u2243+* 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  \u00ac a \u2194 a \u2192 false :=\nby refl\n\n@[simp] lemma not_not_iff (a : Prop) [decidable a] :\n  \u00ac\u00ac a \u2194 a :=\nby by_cases a; simp [h]\n\n@[simp] lemma and_imp_distrib (a b c : Prop) :\n  (a \u2227 b \u2192 c) \u2194 (a \u2192 b \u2192 c) :=\niff.intro\n  (assume h ha hb, h \u27e8ha, hb\u27e9)\n  (assume h \u27e8ha, hb\u27e9, h ha hb)\n\n@[simp] lemma or_imp_distrib {a b c : Prop} :\n  a \u2228 b \u2192 c \u2194 (a \u2192 c) \u2227 (b \u2192 c) :=\niff.intro\n  (assume h,\n   \u27e8assume ha, h (or.intro_left _ ha), assume hb, h (or.intro_right _ hb)\u27e9)\n  (assume \u27e8ha, hb\u27e9 h, match h with or.inl h := ha h | or.inr h := hb h end)\n\n@[simp] lemma exists_imp_distrib {\u03b1 : Sort*} {p : \u03b1 \u2192 Prop} {a : Prop} :\n  ((\u2203x, p x) \u2192 a) \u2194 (\u2200x, p x \u2192 a) :=\niff.intro\n  (assume h hp ha, h \u27e8hp, ha\u27e9)\n  (assume h \u27e8hp, ha\u27e9, h hp ha)\n\nlemma and_exists {\u03b1 : Sort*} {p : \u03b1 \u2192 Prop} {a : Prop} :\n  (a \u2227 (\u2203x, p x)) \u2194 (\u2203x, a \u2227 p x) :=\niff.intro\n  (assume \u27e8ha, x, hp\u27e9, \u27e8x, ha, hp\u27e9)\n  (assume \u27e8x, ha, hp\u27e9, \u27e8ha, x, hp\u27e9)\n\n@[simp] lemma exists_false {\u03b1 : Sort*} :\n  (\u2203x : \u03b1, false) \u2194 false :=\niff.intro (assume \u27e8a, f\u27e9, 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 \u2218 int.neg = id :=\nbegin\n  apply funext,\n  apply neg_neg\nend\n\n\n/-! ## Reflexive Transitive Closure -/\n\nnamespace rtc\n\ninductive star {\u03b1 : Sort*} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : \u03b1 \u2192 Prop\n| refl {}    : star a\n| tail {b c} : star b \u2192 r b c \u2192 star c\n\nattribute [refl] star.refl\n\nnamespace star\n\nvariables {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a b c d : \u03b1}\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 {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {b : \u03b1}\n  {P : \u2200a : \u03b1, star r a b \u2192 Prop} {a : \u03b1} (h : star r a b)\n  (refl : P b refl)\n  (head : \u2200{a c} (h' : r a c) (h : star r c b), P c h \u2192 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 \u2200a a', r a a' \u2192 star r a' b \u2192 P a' _ \u2192 P a _, from\n      assume a a' hab hbc, head hab _ }\nend\n\nlemma trans_induction_on {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {p : \u2200{a b : \u03b1}, star r a b \u2192 Prop} {a b : \u03b1} (h : star r a b)\n    (ih\u2081 : \u2200a, @p a a refl) (ih\u2082 : \u2200{a b} (h : r a b), p (single h))\n    (ih\u2083 : \u2200{a b c} (h\u2081 : star r a b) (h\u2082 : star r b c), p h\u2081 \u2192\n       p h\u2082 \u2192 p (h\u2081.trans h\u2082)) :\n  p h :=\nbegin\n  induction' h,\n  case refl {\n    exact ih\u2081 a },\n  case tail : b c hab hbc ih {\n    exact ih\u2083 hab (single hbc) (ih ih\u2081 @ih\u2082 @ih\u2083) (ih\u2082 hbc) }\nend\n\nlemma lift {\u03b2 : Sort*} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (h : \u2200a b, r a b \u2192 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 \u2218 h _ _)\n  (assume a b c _ _, trans)\n\nlemma mono {p : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n  (\u2200a b, r a b \u2192 p a b) \u2192 star r a b \u2192 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 \u2192 \u2115\n\ndef state.update (name : string) (val : \u2115) (s : state) : state :=\n\u03bbname', if name' = name then val else s name'\n\nnotation s `{` name ` \u21a6 ` val `}` := state.update name val s\n\ninstance : has_emptyc state :=\n{ emptyc := \u03bb_, 0 }\n\n@[simp] lemma update_apply (name : string) (val : \u2115) (s : state) :\n  s{name \u21a6 val} name = val :=\nif_pos rfl\n\n@[simp] lemma update_apply_ne (name name' : string) (val : \u2115) (s : state)\n    (h : name' \u2260 name . tactic.dec_trivial) :\n  s{name \u21a6 val} name' = s name' :=\nif_neg h\n\n@[simp] lemma update_override (name : string) (val\u2081 val\u2082 : \u2115) (s : state) :\n  s{name \u21a6 val\u2082}{name \u21a6 val\u2081} = s{name \u21a6 val\u2081} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp [h]\nend\n\n@[simp] lemma update_swap (name\u2081 name\u2082 : string) (val\u2081 val\u2082 : \u2115) (s : state)\n    (h : name\u2081 \u2260 name\u2082 . tactic.dec_trivial) :\n  s{name\u2082 \u21a6 val\u2082}{name\u2081 \u21a6 val\u2081} = s{name\u2081 \u21a6 val\u2081}{name\u2082 \u21a6 val\u2082} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name\u2081;\n    by_cases name' = name\u2082;\n    simp * at *\nend\n\n@[simp] lemma update_id (name : string) (s : state) :\n  s{name \u21a6 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 : \u2115) :\n  (\u03bb_, val){name \u21a6 val} = (\u03bb_, val) :=\nby apply funext; simp\n\nexample (s : state) :\n  s{\"a\" \u21a6 0}{\"a\" \u21a6 2} = s{\"a\" \u21a6 2} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" \u21a6 0}{\"b\" \u21a6 2} = s{\"b\" \u21a6 2}{\"a\" \u21a6 0} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" \u21a6 s \"a\"}{\"b\" \u21a6 0} = s{\"b\" \u21a6 0} :=\nby simp\n\n\n/-! ## Relations -/\n\ndef Id {\u03b1 : Type} : set (\u03b1 \u00d7 \u03b1) :=\n{ab | prod.snd ab = prod.fst ab}\n\n@[simp] lemma mem_Id {\u03b1 : Type} (a b : \u03b1) :\n  (a, b) \u2208 @Id \u03b1 \u2194 b = a :=\nby refl\n\ndef comp {\u03b1 : Type} (r\u2081 r\u2082 : set (\u03b1 \u00d7 \u03b1)) : set (\u03b1 \u00d7 \u03b1) :=\n{ac | \u2203b, (prod.fst ac, b) \u2208 r\u2081 \u2227 (b, prod.snd ac) \u2208 r\u2082}\n\ninfixl ` \u25ef ` : 90 := comp\n\n@[simp] lemma mem_comp {\u03b1 : Type} (r\u2081 r\u2082 : set (\u03b1 \u00d7 \u03b1))\n    (a b : \u03b1) :\n  (a, b) \u2208 r\u2081 \u25ef r\u2082 \u2194 (\u2203c, (a, c) \u2208 r\u2081 \u2227 (c, b) \u2208 r\u2082) :=\nby refl\n\ndef restrict {\u03b1 : Type} (r : set (\u03b1 \u00d7 \u03b1)) (p : \u03b1 \u2192 Prop) :\n  set (\u03b1 \u00d7 \u03b1) :=\n{ab | ab \u2208 r \u2227 p (prod.fst ab)}\n\ninfixl ` \u21c3 ` : 90 := restrict\n\n@[simp] lemma mem_restrict {\u03b1 : Type} (r : set (\u03b1 \u00d7 \u03b1))\n    (p : \u03b1 \u2192 Prop) (a b : \u03b1) :\n  (a, b) \u2208 r \u21c3 p \u2194 (a, b) \u2208 r \u2227 p a :=\nby refl\n\n\n/-! ## Setoids -/\n\ndef equivalence_rel : Type \u2192 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\u00f6ving. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henrik B\u00f6ving, 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 `\u2200 i j : \u2115, i \u2264 j` has a `Testable` instance because `\u2115`\nis sampleable and `i \u2264 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 : \u2115\n  y : \u2115\n  h : x \u2264 y\n  deriving Repr\n```\nHow do we test a property about `MyType`? For instance, let us consider\n`Testable.check $ \u2200 a b : MyType, a.y \u2264 b.x \u2192 a.x \u2264 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 := \u03bb \u27e8x,y,h\u27e9 =>\n    let proxy := Shrinkable.shrink (x, y - x)\n    proxy.map (\u03bb \u27e8\u27e8fst, snd\u27e9, ha\u27e9 => \u27e8\u27e8fst, fst + snd, sorry\u27e9, sorry\u27e9)\n\ninstance : SampleableExt MyType :=\n  SampleableExt.mkSelfContained do\n    let x \u2190 SampleableExt.interpSample Nat\n    let xyDiff \u2190 SampleableExt.interpSample Nat\n    pure $ \u27e8x, x + xyDiff, sorry\u27e9\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) \u2192 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 : \u2115 \u2192 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 : \u00ac p \u2192 (List String) \u2192 \u2115 \u2192 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 \u2192 TestResult p\n  | gaveUp : Nat \u2192 TestResult p\n  | failure : \u00ac p \u2192 List String \u2192 Nat \u2192 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 := \"\u22ef\"\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 \u2192 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) := \u27e8toString\u27e9\n\n/-- Applicative combinator proof carrying test results. -/\ndef combine {p q : Prop} : PSum Unit (p \u2192 q) \u2192 PSum Unit p \u2192 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 \u2192 TestResult q \u2192 TestResult (p \u2227 q)\n| failure h xs n, _ => failure (\u03bb h2 => h h2.left) xs n\n| _, failure h xs n => failure (\u03bb 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 \u2192 TestResult q \u2192 TestResult (p \u2228 q)\n| failure h1 xs n, failure h2 ys m =>\n  let h3 := \u03bb 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 \u2192 p`, then `\u00ac p \u2192 \u00ac q` which means that testing `p` can allow us\nto find counter-examples to `q`. -/\ndef imp (h : q \u2192 p) (r : TestResult p)\n    (p : PSum Unit (p \u2192 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 \u2194 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 \u2192 p) (r : TestResult p)\n    (p : PSum Unit (p \u2192 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 \u03b3] (var : String) (x : \u03b3) (h : q \u2192 p) (r : TestResult p)\n    (p : PSum Unit (p \u2192 q) := PSum.inl ()) : TestResult q  :=\n  addInfo s!\"{var} := {repr x}\" h r p\n\ndef isFailure : TestResult p \u2192 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 \u2192 Bool \u2192 Gen (TestResult p) := Testable.run\n\n/-- A `dbgTrace` with special formatting -/\ndef slimTrace [Pure m] (s : String) : m PUnit := dbgTrace s!\"[SlimCheck: {s}]\" (\u03bb _ => pure ())\n\ninstance andTestable [Testable p] [Testable q] : Testable (p \u2227 q) where\n  run := \u03bb cfg min => do\n    let xp \u2190 runProp p cfg min\n    let xq \u2190 runProp q cfg min\n    pure $ and xp xq\n\ninstance orTestable [Testable p] [Testable q] : Testable (p \u2228 q) where\n  run := \u03bb cfg min => do\n    let xp \u2190 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 \u2190 runProp q cfg min\n      pure $ or xp xq\n\ninstance iffTestable [Testable ((p \u2227 q) \u2228 (\u00ac p \u2227 \u00ac q))] : Testable (p \u2194 q) where\n  run := \u03bb cfg min => do\n    let h \u2190 runProp ((p \u2227 q) \u2228 (\u00ac p \u2227 \u00ac q)) cfg min\n    pure $ iff iff_iff_and_or_not_and_not h\n\ninstance decGuardTestable [PrintableProp p] [Decidable p] {\u03b2 : p \u2192 Prop} [\u2200 h, Testable (\u03b2 h)] :\n    Testable (NamedBinder var $ \u2200 h, \u03b2 h) where\n  run := \u03bb cfg min => do\n    if h : p then\n      let res := (runProp (\u03b2 h) cfg min)\n      let s := printProp p\n      (\u03bb r => addInfo s!\"guard: {s}\" (\u00b7 $ h) r (PSum.inr $ \u03bb q _ => q)) <$> res\n    else if cfg.traceDiscarded || cfg.traceSuccesses then\n      let res := (\u03bb _ => 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 \u2192 Prop} [Testable (f Int)] :\n    Testable (NamedBinder var $ \u2200 x, f x) where\n  run := \u03bb cfg min => do\n    let r \u2190 runProp (f Int) cfg min\n    pure $ addVarInfo var \"\u2124\" (\u00b7 $ 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 \u2192 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 \u03b1] {\u03b2 : \u03b1 \u2192 Prop} [\u2200 x, Testable (\u03b2 x)] (cfg : Configuration)\n    (var : String) (x : SampleableExt.proxy \u03b1) (n : Nat) :\n    OptionT Gen (\u03a3 x, TestResult (\u03b2 (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 \u27e8candidate, h\u27e9 in candidates do\n    if cfg.traceShrinkCandidates then\n      slimTrace s!\"Trying {var} := {repr candidate}\"\n    let res \u2190 OptionT.lift $ Testable.runProp (\u03b2 (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 \u2190(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 \u03b1] {\u03b2 : \u03b1 \u2192 Prop} [\u2200 x, Testable (\u03b2 x)] (cfg : Configuration)\n    (var : String) (x : SampleableExt.proxy \u03b1) (r : TestResult (\u03b2 $ SampleableExt.interp x)) :\n    Gen (\u03a3 x, TestResult (\u03b2 $ SampleableExt.interp x)) := do\n  if cfg.traceShrink then\n     slimTrace \"Shrink\"\n     slimTrace s!\"Attempting to shrink {var} := {repr x}\"\n  let res \u2190 OptionT.run $ minimizeAux cfg var x 0\n  pure $ res.getD \u27e8x, r\u27e9\n\n/-- Test a universal property by creating a sample of the right type and instantiating the\nbound variable with it. -/\ninstance varTestable [SampleableExt \u03b1] {\u03b2 : \u03b1 \u2192 Prop} [\u2200 x, Testable (\u03b2 x)] :\n    Testable (NamedBinder var $ \u2200 x : \u03b1, \u03b2 x) where\n  run := \u03bb cfg min => do\n    let x \u2190 SampleableExt.sample\n    if cfg.traceSuccesses || cfg.traceDiscarded then\n      slimTrace s!\"{var} := {repr x}\"\n    let r \u2190 Testable.runProp (\u03b2 $ SampleableExt.interp x) cfg false\n    let \u27e8finalX, finalR\u27e9 \u2190\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 $ \u27e8x, r\u27e9\n      else\n        pure $ \u27e8x, r\u27e9\n    pure $ addVarInfo var finalX (\u00b7 $ SampleableExt.interp finalX) finalR\n\n/-- Test a universal property about propositions -/\ninstance propVarTestable {\u03b2 : Prop \u2192 Prop} [\u2200 b : Bool, Testable (\u03b2 b)] :\n  Testable (NamedBinder var $ \u2200 p : Prop, \u03b2 p)\nwhere\n  run := \u03bb cfg min =>\n    imp (\u03bb h (b : Bool) => h b) <$> Testable.runProp (NamedBinder var $ \u2200 b : Bool, \u03b2 b) cfg min\n\ninstance (priority := high) unusedVarTestable [Nonempty \u03b1] [Testable \u03b2] :\n  Testable (NamedBinder var $ \u2200 _x : \u03b1, \u03b2)\nwhere\n  run := \u03bb cfg min => do\n    if cfg.traceDiscarded || cfg.traceSuccesses then\n      slimTrace s!\"{var} is unused\"\n    let r \u2190 Testable.runProp \u03b2 cfg min\n    let finalR := addInfo s!\"{var} is irrelevant (unused)\" id r\n    pure $ imp (\u00b7 $ Classical.ofNonempty) finalR (PSum.inr $ \u03bb x _ => x)\n\ninstance (priority := low) decidableTestable {p : Prop} [PrintableProp p] [Decidable p] :\n    Testable p where\n  run := \u03bb _ _ =>\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 \u03b1] {x y : \u03b1} : PrintableProp (x = y) where\n  printProp := s!\"{repr x} = {repr y}\"\n\ninstance Ne.printableProp [Repr \u03b1] {x y : \u03b1} : PrintableProp (x \u2260 y) where\n  printProp := s!\"{repr x} \u2260 {repr y}\"\n\ninstance LE.printableProp [Repr \u03b1] [LE \u03b1] {x y : \u03b1} : PrintableProp (x \u2264 y) where\n  printProp := s!\"{repr x} \u2264 {repr y}\"\n\ninstance LT.printableProp [Repr \u03b1] [LT \u03b1] {x y : \u03b1} : PrintableProp (x < y) where\n  printProp := s!\"{repr x} < {repr y}\"\n\ninstance And.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x \u2227 y) where\n  printProp := s!\"{printProp x} \u2227 {printProp y}\"\n\ninstance Or.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x \u2228 y) where\n  printProp := s!\"{printProp x} \u2228 {printProp y}\"\n\ninstance Iff.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x \u2194 y) where\n  printProp := s!\"{printProp x} \u2194 {printProp y}\"\n\ninstance Imp.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x \u2192 y) where\n  printProp := s!\"{printProp x} \u2192 {printProp y}\"\n\ninstance Not.printableProp [PrintableProp x] : PrintableProp (\u00acx) where\n  printProp := s!\"\u00ac{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 \u2192 Rand (TestResult p)\n| 0 => pure $ TestResult.gaveUp 1\n| n+1 => do\n  let r \u2190 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 \u2192 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 \u2192 Nat \u2192 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 \u2190 retry (ReaderT.run (Testable.runProp p cfg true) \u27e8size\u27e9) 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 $ \u03bb 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 `\u22a2 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 \u2190 getMainGoal\n  let goalType \u2190 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 \u2190 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 (\u2200 (x y z a : Nat) (h1 : 3 < x) (h2 : 3 < y), x - y = y - x)\n--   Configuration.verbose\n-- #eval Testable.check (\u2200 x : Nat, \u2200 y : Nat, x + y = y + x) Configuration.verbose\n-- #eval Testable.check (\u2200 (x : (Nat \u00d7 Nat)), x.fst - x.snd - 10 = x.snd - x.fst - 10)\n--   Configuration.verbose\n-- #eval Testable.check (\u2200 (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 `\u2115`-indexed chain complex `P.complex` of projective objects,\nalong with a chain map `P.\u03c0` 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 `\u03c0` 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 \u27f6 Y` admits a lift to a chain map `P.complex \u27f6 Q.complex`.\n(It is a lift in the sense that\nthe projection maps `P.\u03c0` and `Q.\u03c0` 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 \u2964 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 `\u2115`-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 `\u03c0` 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 `\u2115`-indexed chain complex\n  (equipped with `projective` and `exact` instances)\n* `projective_resolution.\u03c0 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 `\u03c0` is a quasi-iso).\n-/\n@[nolint has_nonempty_instance]\nstructure ProjectiveResolution (Z : C) :=\n(complex : chain_complex C \u2115)\n(\u03c0 : homological_complex.hom complex ((chain_complex.single\u2080 C).obj Z))\n(projective : \u2200 n, projective (complex.X n) . tactic.apply_instance)\n(exact\u2080 : exact (complex.d 1 0) (\u03c0.f 0))\n(exact : \u2200 n, exact (complex.d (n+2) (n+1)) (complex.d (n+1) n))\n(epi : epi (\u03c0.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 : \u2200 Z : C, has_projective_resolution Z)\n\nattribute [instance, priority 100] has_projective_resolutions.out\n\nend\n\nnamespace ProjectiveResolution\n\n@[simp] lemma \u03c0_f_succ {Z : C} (P : ProjectiveResolution Z) (n : \u2115) :\n  P.\u03c0.f (n+1) = 0 :=\nbegin\n  apply zero_of_target_iso_zero,\n  dsimp, refl,\nend\n\n@[simp] lemma complex_d_comp_\u03c0_f_zero {Z : C} (P : ProjectiveResolution Z) :\n  P.complex.d 1 0 \u226b P.\u03c0.f 0 = 0 :=\nP.exact\u2080.w\n\n@[simp] lemma complex_d_succ_comp {Z : C} (P : ProjectiveResolution Z) (n : \u2115) :\n  P.complex.d (n + 2) (n + 1) \u226b P.complex.d (n + 1) n = 0 :=\n(P.exact _).w\n\ninstance {Z : C} (P : ProjectiveResolution Z) (n : \u2115) : category_theory.epi (P.\u03c0.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\u2080 C).obj Z,\n  \u03c0 := \ud835\udfd9 ((chain_complex.single\u2080 C).obj Z),\n  projective := \u03bb n, begin\n    cases n,\n    { dsimp, apply_instance, },\n    { dsimp, apply_instance, },\n  end,\n  exact\u2080 := by { dsimp, exact exact_zero_mono _ },\n  exact := \u03bb 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 \u27f6 Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  P.complex.X 0 \u27f6 Q.complex.X 0 :=\nfactor_thru (P.\u03c0.f 0 \u226b f) (Q.\u03c0.f 0)\n\n/-- Auxiliary construction for `lift`. -/\ndef lift_f_one {Y Z : C} (f : Y \u27f6 Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  P.complex.X 1 \u27f6 Q.complex.X 1 :=\nexact.lift (P.complex.d 1 0 \u226b lift_f_zero f P Q) (Q.complex.d 1 0) (Q.\u03c0.f 0) Q.exact\u2080\n  (by simp [lift_f_zero, P.exact\u2080.w_assoc])\n\n/-- Auxiliary lemma for `lift`. -/\n@[simp] lemma lift_f_one_zero_comm\n  {Y Z : C} (f : Y \u27f6 Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  lift_f_one f P Q \u226b Q.complex.d 1 0 = P.complex.d 1 0 \u226b 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 : \u2115) (g : P.complex.X n \u27f6 Q.complex.X n) (g' : P.complex.X (n+1) \u27f6 Q.complex.X (n+1))\n  (w : g' \u226b Q.complex.d (n+1) n = P.complex.d (n+1) n \u226b g) :\n  \u03a3' g'' : P.complex.X (n+2) \u27f6 Q.complex.X (n+2),\n    g'' \u226b Q.complex.d (n+2) (n+1) = P.complex.d (n+2) (n+1) \u226b g' :=\n\u27e8exact.lift\n  (P.complex.d (n+2) (n+1) \u226b g') ((Q.complex.d (n+2) (n+1))) (Q.complex.d (n+1) n) (Q.exact _)\n  (by simp [w]), (by simp)\u27e9\n\n/-- A morphism in `C` lifts to a chain map between projective resolutions. -/\ndef lift {Y Z : C} (f : Y \u27f6 Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  P.complex \u27f6 Q.complex :=\nchain_complex.mk_hom _ _ (lift_f_zero f _ _) (lift_f_one f _ _) (lift_f_one_zero_comm f _ _)\n  (\u03bb n \u27e8g, g', w\u27e9, 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 \u27f6 Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n  lift f P Q \u226b Q.\u03c0 = P.\u03c0 \u226b (chain_complex.single\u2080 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 \u27f6 Q.complex)\n  (comm : f \u226b Q.\u03c0 = 0) : P.complex.X 0 \u27f6 Q.complex.X 1 :=\nexact.lift (f.f 0) (Q.complex.d 1 0) (Q.\u03c0.f 0) Q.exact\u2080\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 \u27f6 Q.complex)\n  (comm : f \u226b Q.\u03c0 = 0) : P.complex.X 1 \u27f6 Q.complex.X 2 :=\nexact.lift\n  (f.f 1 - P.complex.d 1 0 \u226b 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 \u27f6 Q.complex) (n : \u2115)\n  (g : P.complex.X n \u27f6 Q.complex.X (n + 1)) (g' : P.complex.X (n + 1) \u27f6 Q.complex.X (n + 2))\n  (w : f.f (n + 1) = P.complex.d (n + 1) n \u226b g + g' \u226b Q.complex.d (n + 2) (n + 1)) :\n  P.complex.X (n + 2) \u27f6 Q.complex.X (n + 3) :=\nexact.lift\n  (f.f (n+2) - P.complex.d (n+2) (n+1) \u226b 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 \u27f6 Q.complex)\n  (comm : f \u226b Q.\u03c0 = 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  (\u03bb n \u27e8g, g', w\u27e9, \u27e8lift_homotopy_zero_succ f n g g' w, by simp [lift_homotopy_zero_succ, w]\u27e9)\n\n/-- Two lifts of the same morphism are homotopic. -/\ndef lift_homotopy {Y Z : C} (f : Y \u27f6 Z) {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n  (g h : P.complex \u27f6 Q.complex)\n  (g_comm : g \u226b Q.\u03c0 = P.\u03c0 \u226b (chain_complex.single\u2080 C).map f)\n  (h_comm : h \u226b Q.\u03c0 = P.\u03c0 \u226b (chain_complex.single\u2080 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 (\ud835\udfd9 X) P P) (\ud835\udfd9 P.complex) :=\nby { apply lift_homotopy (\ud835\udfd9 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 \u27f6 Y) (g : Y \u27f6 Z)\n  (P : ProjectiveResolution X) (Q : ProjectiveResolution Y) (R : ProjectiveResolution Z) :\n  homotopy (lift (f \u226b g) P R) (lift f P Q \u226b lift g Q R) :=\nby { apply lift_homotopy (f \u226b 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 (\ud835\udfd9 X) P Q,\n  inv := lift (\ud835\udfd9 X) Q P,\n  homotopy_hom_inv_id := begin\n    refine (lift_comp_homotopy (\ud835\udfd9 X) (\ud835\udfd9 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 (\ud835\udfd9 X) (\ud835\udfd9 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_\u03c0 {X : C} (P Q : ProjectiveResolution X) :\n  (homotopy_equiv P Q).hom \u226b Q.\u03c0 = P.\u03c0 :=\nby simp [homotopy_equiv]\n\n@[simp, reassoc] lemma homotopy_equiv_inv_\u03c0 {X : C} (P Q : ProjectiveResolution X) :\n  (homotopy_equiv P Q).inv \u226b P.\u03c0 = Q.\u03c0 :=\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 \u2115 :=\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.\u03c0 (Z : C) [has_projective_resolution Z] :\n  projective_resolution Z \u27f6 (chain_complex.single\u2080 C).obj Z :=\n(has_projective_resolution.out Z).some.\u03c0\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 \u27f6 Y)\n  [has_projective_resolution X] [has_projective_resolution Y] :\n  projective_resolution X \u27f6 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(`\u2115`-indexed chain complexes and chain maps up to homotopy).\n-/\ndef projective_resolutions : C \u2964 homotopy_category C (complex_shape.down \u2115) :=\n{ obj := \u03bb X, (homotopy_category.quotient _ _).obj (projective_resolution X),\n  map := \u03bb X Y f, (homotopy_category.quotient _ _).map (projective_resolution.lift f),\n  map_id' := \u03bb X, begin\n    rw \u2190(homotopy_category.quotient _ _).map_id,\n    apply homotopy_category.eq_of_homotopy,\n    apply ProjectiveResolution.lift_id_homotopy,\n  end,\n  map_comp' := \u03bb X Y Z f g, begin\n    rw \u2190(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 : \u2115} (F : TypeVec n \u2192 Type _) where\n  map : \u2200 {\u03b1 \u03b2 : TypeVec n}, \u03b1 \u27f9 \u03b2 \u2192 F \u03b1 \u2192 F \u03b2\n#align mvfunctor MvFunctor\n-/\n\n-- mathport name: mvfunctor.map\nscoped[MvFunctor] infixr:100 \" <$$> \" => MvFunctor.map\n\nvariable {n : \u2115}\n\nnamespace MvFunctor\n\nvariable {\u03b1 \u03b2 \u03b3 : TypeVec.{u} n} {F : TypeVec.{u} n \u2192 Type v} [MvFunctor F]\n\n#print MvFunctor.LiftP /-\n/-- predicate lifting over multivariate functors -/\ndef LiftP {\u03b1 : TypeVec n} (p : \u2200 i, \u03b1 i \u2192 Prop) (x : F \u03b1) : Prop :=\n  \u2203 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 {\u03b1 : TypeVec n} (r : \u2200 {i}, \u03b1 i \u2192 \u03b1 i \u2192 Prop) (x y : F \u03b1) : Prop :=\n  \u2203 u : F fun i => { p : \u03b1 i \u00d7 \u03b1 i // r p.fst p.snd },\n    (fun i (t : { p : \u03b1 i \u00d7 \u03b1 i // r p.fst p.snd }) => t.val.fst) <$$> u = x \u2227\n      (fun i (t : { p : \u03b1 i \u00d7 \u03b1 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 \u03b1` and a projection `i` of type vector `\u03b1`, `supp x i` is the set\nof `\u03b1.i` contained in `x` -/\ndef supp {\u03b1 : TypeVec n} (x : F \u03b1) (i : Fin2 n) : Set (\u03b1 i) :=\n  { y : \u03b1 i | \u2200 \u2983p\u2984, LiftP p x \u2192 p i y }\n#align mvfunctor.supp MvFunctor.supp\n-/\n\n#print MvFunctor.of_mem_supp /-\ntheorem of_mem_supp {\u03b1 : TypeVec n} {x : F \u03b1} {p : \u2200 \u2983i\u2984, \u03b1 i \u2192 Prop} (h : LiftP p x) (i : Fin2 n) :\n    \u2200 y \u2208 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 : \u2115} (F : TypeVec n \u2192 Type _) [MvFunctor F] : Prop where\n  id_map : \u2200 {\u03b1 : TypeVec n} (x : F \u03b1), TypeVec.id <$$> x = x\n  comp_map :\n    \u2200 {\u03b1 \u03b2 \u03b3 : TypeVec n} (g : \u03b1 \u27f9 \u03b2) (h : \u03b2 \u27f9 \u03b3) (x : F \u03b1), (h \u229a 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 {\u03b1 \u03b2 \u03b3 : TypeVec.{u} n}\n\nvariable {F : TypeVec.{u} n \u2192 Type v} [MvFunctor F]\n\nvariable (p : \u03b1 \u27f9 repeat n Prop) (r : \u03b1 \u2297 \u03b1 \u27f9 repeat n Prop)\n\n#print MvFunctor.LiftP' /-\n/-- adapt `mvfunctor.liftp` to accept predicates as arrows -/\ndef LiftP' : F \u03b1 \u2192 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 \u03b1 \u2192 F \u03b1 \u2192 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 \u03b1) : 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 \u03b1) : (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 : \u03b1 \u27f9 \u03b2) (h : \u03b2 \u27f9 \u03b3) (x : F \u03b1) : h <$$> g <$$> x = (h \u229a 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 \u03b1 \u2192 Prop} {q : F \u03b2 \u2192 Prop} (f : \u03b1 \u27f9 \u03b2) (g : \u03b2 \u27f9 \u03b1)\n    (h\u2080 : f \u229a g = id) (h\u2081 : \u2200 u : F \u03b1, p u \u2194 q (f <$$> u)) : (\u2203 u : F \u03b1, p u) \u2194 \u2203 u : F \u03b2, q u :=\n  by\n  constructor <;> rintro \u27e8u, h\u2082\u27e9 <;> [use f <$$> u, use g <$$> u]\n  \u00b7 apply (h\u2081 u).mp h\u2082\n  \u00b7 apply (h\u2081 _).mpr _\n    simp only [MvFunctor.map_map, h\u2080, LawfulMvFunctor.id_map, h\u2082]\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 \u03b1) : LiftP' p x \u2194 \u2203 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 \u03b1) :\n    LiftR' r x y \u2194\n      \u2203 u : F (Subtype_ r),\n        (TypeVec.prod.fst \u229a subtypeVal r) <$$> u = x \u2227\n          (TypeVec.prod.snd \u229a 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) \u2192 Type _} [MvFunctor F] [LawfulMvFunctor F] {\u03b1 : TypeVec.{u} n}\n\nvariable (p : \u03b1 \u27f9 repeat n Prop) (r : \u03b1 \u2297 \u03b1 \u27f9 repeat n Prop)\n\nopen MvFunctor\n\nvariable {\u03b2 : Type u}\n\nvariable (pp : \u03b2 \u2192 Prop)\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprivate def f :\n    \u2200 n \u03b1,\n      (fun i : Fin2 (n + 1) => { p_1 // ofRepeat (PredLast' \u03b1 pp i p_1) }) \u27f9 fun i : Fin2 (n + 1) =>\n        { p_1 : (\u03b1 ::: \u03b2) i // PredLast \u03b1 pp p_1 }\n  | _, \u03b1, Fin2.fs i, x =>\n    \u27e8x.val, cast (by simp only [pred_last] <;> erw [const_iff_true]) x.property\u27e9\n  | _, \u03b1, Fin2.fz, x => \u27e8x.val, x.property\u27e9\n#align mvfunctor.f mvfunctor.f\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprivate def g :\n    \u2200 n \u03b1,\n      (fun i : Fin2 (n + 1) => { p_1 : (\u03b1 ::: \u03b2) i // PredLast \u03b1 pp p_1 }) \u27f9 fun i : Fin2 (n + 1) =>\n        { p_1 // ofRepeat (PredLast' \u03b1 pp i p_1) }\n  | _, \u03b1, Fin2.fs i, x =>\n    \u27e8x.val, cast (by simp only [pred_last] <;> erw [const_iff_true]) x.property\u27e9\n  | _, \u03b1, Fin2.fz, x => \u27e8x.val, x.property\u27e9\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] {\u03b1 : TypeVec.{u1} n} {\u03b2 : Type.{u1}} (p : \u03b2 -> Prop) (x : F (TypeVec.append1.{u1} n \u03b1 \u03b2)), 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 \u03b1 \u03b2) F _inst_1 (TypeVec.PredLast'.{u1} n \u03b1 \u03b2 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 \u03b1 \u03b2 i) (TypeVec.PredLast.{u1} n \u03b1 \u03b2 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] {\u03b1 : TypeVec.{u2} n} {\u03b2 : Type.{u2}} (p : \u03b2 -> Prop) (x : F (TypeVec.append1.{u2} n \u03b1 \u03b2)), 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 \u03b1 \u03b2) F _inst_1 (TypeVec.PredLast'.{u2} n \u03b1 \u03b2 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 \u03b1 \u03b2 i) (TypeVec.PredLast.{u2} n \u03b1 \u03b2 p) x)\nCase conversion may be inaccurate. Consider using '#align mvfunctor.liftp_last_pred_iff MvFunctor.LiftP_PredLast_iff\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem LiftP_PredLast_iff {\u03b2} (p : \u03b2 \u2192 Prop) (x : F (\u03b1 ::: \u03b2)) :\n    LiftP' (PredLast' _ p) x \u2194 LiftP (PredLast _ p) x :=\n  by\n  dsimp only [liftp, liftp']\n  apply exists_iff_exists_of_mono F (f _ n \u03b1) (g _ n \u03b1)\n  \u00b7 ext (i\u27e8x, _\u27e9)\n    cases i <;> rfl\n  \u00b7 intros\n    rw [MvFunctor.map_map, (\u00b7 \u229a \u00b7)]\n    congr <;> ext (i\u27e8x, _\u27e9) <;> cases i <;> rfl\n#align mvfunctor.liftp_last_pred_iff MvFunctor.LiftP_PredLast_iff\n\nopen Function\n\nvariable (rr : \u03b2 \u2192 \u03b2 \u2192 Prop)\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprivate def f :\n    \u2200 n \u03b1,\n      (fun i : Fin2 (n + 1) =>\n          { p_1 : _ \u00d7 _ // ofRepeat (RelLast' \u03b1 rr i (TypeVec.prod.mk _ p_1.fst p_1.snd)) }) \u27f9\n        fun i : Fin2 (n + 1) => { p_1 : (\u03b1 ::: \u03b2) i \u00d7 _ // RelLast \u03b1 rr p_1.fst p_1.snd }\n  | _, \u03b1, Fin2.fs i, x =>\n    \u27e8x.val, cast (by simp only [rel_last] <;> erw [repeat_eq_iff_eq]) x.property\u27e9\n  | _, \u03b1, Fin2.fz, x => \u27e8x.val, x.property\u27e9\n#align mvfunctor.f mvfunctor.f\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\nprivate def g :\n    \u2200 n \u03b1,\n      (fun i : Fin2 (n + 1) => { p_1 : (\u03b1 ::: \u03b2) i \u00d7 _ // RelLast \u03b1 rr p_1.fst p_1.snd }) \u27f9\n        fun i : Fin2 (n + 1) =>\n        { p_1 : _ \u00d7 _ // ofRepeat (RelLast' \u03b1 rr i (TypeVec.prod.mk _ p_1.1 p_1.2)) }\n  | _, \u03b1, Fin2.fs i, x =>\n    \u27e8x.val, cast (by simp only [rel_last] <;> erw [repeat_eq_iff_eq]) x.property\u27e9\n  | _, \u03b1, Fin2.fz, x => \u27e8x.val, x.property\u27e9\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] {\u03b1 : TypeVec.{u1} n} {\u03b2 : Type.{u1}} (rr : \u03b2 -> \u03b2 -> Prop) (x : F (TypeVec.append1.{u1} n \u03b1 \u03b2)) (y : F (TypeVec.append1.{u1} n \u03b1 \u03b2)), 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 \u03b1 \u03b2) F _inst_1 (TypeVec.RelLast'.{u1} n \u03b1 \u03b2 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 \u03b1 \u03b2 i) (TypeVec.RelLast.{u1} n \u03b1 \u03b2 \u03b2 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] {\u03b1 : TypeVec.{u2} n} {\u03b2 : Type.{u2}} (rr : \u03b2 -> \u03b2 -> Prop) (x : F (TypeVec.append1.{u2} n \u03b1 \u03b2)) (y : F (TypeVec.append1.{u2} n \u03b1 \u03b2)), 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 \u03b1 \u03b2) F _inst_1 (TypeVec.RelLast'.{u2} n \u03b1 \u03b2 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 \u03b1 \u03b2 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 \u03b1 \u03b2 \u03b2 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\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem LiftR_RelLast_iff (x y : F (\u03b1 ::: \u03b2)) :\n    LiftR' (RelLast' _ rr) x y \u2194 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  \u00b7 ext (i\u27e8x, _\u27e9) : 2\n    cases i <;> rfl\n  \u00b7 intros\n    rw [MvFunctor.map_map, MvFunctor.map_map, (\u00b7 \u229a \u00b7), (\u00b7 \u229a \u00b7)]\n    congr <;> ext (i\u27e8x, _\u27e9) <;> 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 \u2192 Type v} -- The family of types already equiped with instances\nvariables (x y : \u03a0 i, f i) (i : I)\n\ninstance has_zero [\u2200 i, has_zero $ f i] : has_zero (\u03a0 i : I, f i) := \u27e8\u03bb i, 0\u27e9\n@[simp] lemma zero_apply [\u2200 i, has_zero $ f i] : (0 : \u03a0 i, f i) i = 0 := rfl\n\ninstance has_one [\u2200 i, has_one $ f i] : has_one (\u03a0 i : I, f i) := \u27e8\u03bb i, 1\u27e9\n@[simp] lemma one_apply [\u2200 i, has_one $ f i] : (1 : \u03a0 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 [\u2200 i, has_add $ f i] : has_add (\u03a0 i : I, f i) := \u27e8\u03bb x y, \u03bb i, x i + y i\u27e9\n@[simp] lemma add_apply [\u2200 i, has_add $ f i] : (x + y) i = x i + y i := rfl\n\ninstance has_mul [\u2200 i, has_mul $ f i] : has_mul (\u03a0 i : I, f i) := \u27e8\u03bb x y, \u03bb i, x i * y i\u27e9\n@[simp] lemma mul_apply [\u2200 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 [\u2200 i, has_inv $ f i] : has_inv (\u03a0 i : I, f i) := \u27e8\u03bb x, \u03bb i, (x i)\u207b\u00b9\u27e9\n@[simp] lemma inv_apply [\u2200 i, has_inv $ f i] : x\u207b\u00b9 i = (x i)\u207b\u00b9 := rfl\n\ninstance has_neg [\u2200 i, has_neg $ f i] : has_neg (\u03a0 i : I, f i) := \u27e8\u03bb x, \u03bb i, -(x i)\u27e9\n@[simp] lemma neg_apply [\u2200 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 {\u03b1 : Type*} [\u2200 i, has_scalar \u03b1 $ f i] : has_scalar \u03b1 (\u03a0 i : I, f i) := \u27e8\u03bb s x, \u03bb i, s \u2022 (x i)\u27e9\n@[simp] lemma smul_apply {\u03b1 : Type*} [\u2200 i, has_scalar \u03b1 $ f i] (s : \u03b1) : (s \u2022 x) i = s \u2022 x i := rfl\n\ninstance semigroup          [\u2200 i, semigroup          $ f i] : semigroup          (\u03a0 i : I, f i) := by pi_instance\ninstance comm_semigroup     [\u2200 i, comm_semigroup     $ f i] : comm_semigroup     (\u03a0 i : I, f i) := by pi_instance\ninstance monoid             [\u2200 i, monoid             $ f i] : monoid             (\u03a0 i : I, f i) := by pi_instance\ninstance comm_monoid        [\u2200 i, comm_monoid        $ f i] : comm_monoid        (\u03a0 i : I, f i) := by pi_instance\ninstance group              [\u2200 i, group              $ f i] : group              (\u03a0 i : I, f i) := by pi_instance\ninstance comm_group         [\u2200 i, comm_group         $ f i] : comm_group         (\u03a0 i : I, f i) := by pi_instance\ninstance add_semigroup      [\u2200 i, add_semigroup      $ f i] : add_semigroup      (\u03a0 i : I, f i) := by pi_instance\ninstance add_comm_semigroup [\u2200 i, add_comm_semigroup $ f i] : add_comm_semigroup (\u03a0 i : I, f i) := by pi_instance\ninstance add_monoid         [\u2200 i, add_monoid         $ f i] : add_monoid         (\u03a0 i : I, f i) := by pi_instance\ninstance add_comm_monoid    [\u2200 i, add_comm_monoid    $ f i] : add_comm_monoid    (\u03a0 i : I, f i) := by pi_instance\ninstance add_group          [\u2200 i, add_group          $ f i] : add_group          (\u03a0 i : I, f i) := by pi_instance\ninstance add_comm_group     [\u2200 i, add_comm_group     $ f i] : add_comm_group     (\u03a0 i : I, f i) := by pi_instance\ninstance ring               [\u2200 i, ring               $ f i] : ring               (\u03a0 i : I, f i) := by pi_instance\ninstance comm_ring          [\u2200 i, comm_ring          $ f i] : comm_ring          (\u03a0 i : I, f i) := by pi_instance\n\ninstance mul_action     (\u03b1) {m : monoid \u03b1}                                      [\u2200 i, mul_action \u03b1 $ f i]     : mul_action \u03b1 (\u03a0 i : I, f i) :=\n{ smul := \u03bb c f i, c \u2022 f i,\n  mul_smul := \u03bb r s f, funext $ \u03bb i, mul_smul _ _ _,\n  one_smul := \u03bb f, funext $ \u03bb i, one_smul \u03b1 _ }\n\ninstance distrib_mul_action (\u03b1) {m : monoid \u03b1}         [\u2200 i, add_monoid $ f i]      [\u2200 i, distrib_mul_action \u03b1 $ f i] : distrib_mul_action \u03b1 (\u03a0 i : I, f i) :=\n{ smul_zero := \u03bb c, funext $ \u03bb i, smul_zero _,\n  smul_add := \u03bb c f g, funext $ \u03bb i, smul_add _ _ _,\n  ..pi.mul_action _ }\n\nvariables (I f)\n\ninstance semimodule     (\u03b1) {r : semiring \u03b1}       [\u2200 i, add_comm_monoid $ f i] [\u2200 i, semimodule \u03b1 $ f i]     : semimodule \u03b1 (\u03a0 i : I, f i) :=\n{ add_smul := \u03bb c f g, funext $ \u03bb i, add_smul _ _ _,\n  zero_smul := \u03bb f, funext $ \u03bb i, zero_smul \u03b1 _,\n  ..pi.distrib_mul_action _ }\n\nvariables {I f}\n\ninstance module         (\u03b1) {r : ring \u03b1}           [\u2200 i, add_comm_group $ f i]  [\u2200 i, module \u03b1 $ f i]         : module \u03b1 (\u03a0 i : I, f i)       := {..pi.semimodule I f \u03b1}\n\ninstance vector_space   (\u03b1) {r : discrete_field \u03b1} [\u2200 i, add_comm_group $ f i]  [\u2200 i, vector_space \u03b1 $ f i]   : vector_space \u03b1 (\u03a0 i : I, f i) := {..pi.module \u03b1}\n\ninstance left_cancel_semigroup [\u2200 i, left_cancel_semigroup $ f i] : left_cancel_semigroup (\u03a0 i : I, f i) :=\nby pi_instance\n\ninstance add_left_cancel_semigroup [\u2200 i, add_left_cancel_semigroup $ f i] : add_left_cancel_semigroup (\u03a0 i : I, f i) :=\nby pi_instance\n\ninstance right_cancel_semigroup [\u2200 i, right_cancel_semigroup $ f i] : right_cancel_semigroup (\u03a0 i : I, f i) :=\nby pi_instance\n\ninstance add_right_cancel_semigroup [\u2200 i, add_right_cancel_semigroup $ f i] : add_right_cancel_semigroup (\u03a0 i : I, f i) :=\nby pi_instance\n\ninstance ordered_cancel_comm_monoid [\u2200 i, ordered_cancel_comm_monoid $ f i] : ordered_cancel_comm_monoid (\u03a0 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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Type*} [\u2200a, monoid (\u03b2 a)] (a : \u03b1) :\n  \u2200 (l : list (\u03a0a, \u03b2 a)), l.prod a = (l.map (\u03bbf:\u03a0a, \u03b2 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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Type*} [\u2200a, comm_monoid (\u03b2 a)] (a : \u03b1)\n  (s : multiset (\u03a0a, \u03b2 a)) : s.prod a = (s.map (\u03bbf:\u03a0a, \u03b2 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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Type*} {\u03b3} [\u2200a, comm_monoid (\u03b2 a)] (a : \u03b1)\n  (s : finset \u03b3) (g : \u03b3 \u2192 \u03a0a, \u03b2 a) : s.prod g a = s.prod (\u03bbc, g c a) :=\nshow (s.val.map g).prod a = (s.val.map (\u03bbc, g c a)).prod,\n  by rw [multiset_prod_apply, multiset.map_map]\n\ndef is_ring_hom_pi\n  {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v} [R : \u03a0 a : \u03b1, ring (\u03b2 a)]\n  {\u03b3 : Type w} [ring \u03b3]\n  (f : \u03a0 a : \u03b1, \u03b3 \u2192 \u03b2 a) [Rh : \u03a0 a : \u03b1, is_ring_hom (f a)] :\n  is_ring_hom (\u03bb 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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*} {p q : \u03b1 \u00d7 \u03b2}\n\ninstance [has_add \u03b1] [has_add \u03b2] : has_add (\u03b1 \u00d7 \u03b2) :=\n\u27e8\u03bbp q, (p.1 + q.1, p.2 + q.2)\u27e9\n@[to_additive prod.has_add]\ninstance [has_mul \u03b1] [has_mul \u03b2] : has_mul (\u03b1 \u00d7 \u03b2) :=\n\u27e8\u03bbp q, (p.1 * q.1, p.2 * q.2)\u27e9\n\n@[simp, to_additive prod.fst_add]\nlemma fst_mul [has_mul \u03b1] [has_mul \u03b2] : (p * q).1 = p.1 * q.1 := rfl\n@[simp, to_additive prod.snd_add]\nlemma snd_mul [has_mul \u03b1] [has_mul \u03b2] : (p * q).2 = p.2 * q.2 := rfl\n@[simp, to_additive prod.mk_add_mk]\nlemma mk_mul_mk [has_mul \u03b1] [has_mul \u03b2] (a\u2081 a\u2082 : \u03b1) (b\u2081 b\u2082 : \u03b2) :\n  (a\u2081, b\u2081) * (a\u2082, b\u2082) = (a\u2081 * a\u2082, b\u2081 * b\u2082) := rfl\n\ninstance [has_zero \u03b1] [has_zero \u03b2] : has_zero (\u03b1 \u00d7 \u03b2) := \u27e8(0, 0)\u27e9\n@[to_additive prod.has_zero]\ninstance [has_one \u03b1] [has_one \u03b2] : has_one (\u03b1 \u00d7 \u03b2) := \u27e8(1, 1)\u27e9\n\n@[simp, to_additive prod.fst_zero]\nlemma fst_one [has_one \u03b1] [has_one \u03b2] : (1 : \u03b1 \u00d7 \u03b2).1 = 1 := rfl\n@[simp, to_additive prod.snd_zero]\nlemma snd_one [has_one \u03b1] [has_one \u03b2] : (1 : \u03b1 \u00d7 \u03b2).2 = 1 := rfl\n@[to_additive prod.zero_eq_mk]\nlemma one_eq_mk [has_one \u03b1] [has_one \u03b2] : (1 : \u03b1 \u00d7 \u03b2) = (1, 1) := rfl\n\ninstance [has_neg \u03b1] [has_neg \u03b2] : has_neg (\u03b1 \u00d7 \u03b2) := \u27e8\u03bbp, (- p.1, - p.2)\u27e9\n@[to_additive prod.has_neg]\ninstance [has_inv \u03b1] [has_inv \u03b2] : has_inv (\u03b1 \u00d7 \u03b2) := \u27e8\u03bbp, (p.1\u207b\u00b9, p.2\u207b\u00b9)\u27e9\n\n@[simp, to_additive prod.fst_neg]\nlemma fst_inv [has_inv \u03b1] [has_inv \u03b2] : (p\u207b\u00b9).1 = (p.1)\u207b\u00b9 := rfl\n@[simp, to_additive prod.snd_neg]\nlemma snd_inv [has_inv \u03b1] [has_inv \u03b2] : (p\u207b\u00b9).2 = (p.2)\u207b\u00b9 := rfl\n@[to_additive prod.neg_mk]\nlemma inv_mk [has_inv \u03b1] [has_inv \u03b2] (a : \u03b1) (b : \u03b2) : (a, b)\u207b\u00b9 = (a\u207b\u00b9, b\u207b\u00b9) := rfl\n\ninstance [add_semigroup \u03b1] [add_semigroup \u03b2] : add_semigroup (\u03b1 \u00d7 \u03b2) :=\n{ add_assoc := assume a b c, mk.inj_iff.mpr \u27e8add_assoc _ _ _, add_assoc _ _ _\u27e9,\n  .. prod.has_add }\n@[to_additive prod.add_semigroup]\ninstance [semigroup \u03b1] [semigroup \u03b2] : semigroup (\u03b1 \u00d7 \u03b2) :=\n{ mul_assoc := assume a b c, mk.inj_iff.mpr \u27e8mul_assoc _ _ _, mul_assoc _ _ _\u27e9,\n  .. prod.has_mul }\n\ninstance [add_monoid \u03b1] [add_monoid \u03b2] : add_monoid (\u03b1 \u00d7 \u03b2) :=\n{ zero_add := assume a, prod.rec_on a $ \u03bba b, mk.inj_iff.mpr \u27e8zero_add _, zero_add _\u27e9,\n  add_zero := assume a, prod.rec_on a $ \u03bba b, mk.inj_iff.mpr \u27e8add_zero _, add_zero _\u27e9,\n  .. prod.add_semigroup, .. prod.has_zero }\n@[to_additive prod.add_monoid]\ninstance [monoid \u03b1] [monoid \u03b2] : monoid (\u03b1 \u00d7 \u03b2) :=\n{ one_mul := assume a, prod.rec_on a $ \u03bba b, mk.inj_iff.mpr \u27e8one_mul _, one_mul _\u27e9,\n  mul_one := assume a, prod.rec_on a $ \u03bba b, mk.inj_iff.mpr \u27e8mul_one _, mul_one _\u27e9,\n  .. prod.semigroup, .. prod.has_one }\n\ninstance [add_group \u03b1] [add_group \u03b2] : add_group (\u03b1 \u00d7 \u03b2) :=\n{ add_left_neg := assume a, mk.inj_iff.mpr \u27e8add_left_neg _, add_left_neg _\u27e9,\n  .. prod.add_monoid, .. prod.has_neg }\n@[to_additive prod.add_group]\ninstance [group \u03b1] [group \u03b2] : group (\u03b1 \u00d7 \u03b2) :=\n{ mul_left_inv := assume a, mk.inj_iff.mpr \u27e8mul_left_inv _, mul_left_inv _\u27e9,\n  .. prod.monoid, .. prod.has_inv }\n\ninstance [add_comm_semigroup \u03b1] [add_comm_semigroup \u03b2] : add_comm_semigroup (\u03b1 \u00d7 \u03b2) :=\n{ add_comm := assume a b, mk.inj_iff.mpr \u27e8add_comm _ _, add_comm _ _\u27e9,\n  .. prod.add_semigroup }\n@[to_additive prod.add_comm_semigroup]\ninstance [comm_semigroup \u03b1] [comm_semigroup \u03b2] : comm_semigroup (\u03b1 \u00d7 \u03b2) :=\n{ mul_comm := assume a b, mk.inj_iff.mpr \u27e8mul_comm _ _, mul_comm _ _\u27e9,\n  .. prod.semigroup }\n\ninstance [add_comm_monoid \u03b1] [add_comm_monoid \u03b2] : add_comm_monoid (\u03b1 \u00d7 \u03b2) :=\n{ .. prod.add_comm_semigroup, .. prod.add_monoid }\n@[to_additive prod.add_comm_monoid]\ninstance [comm_monoid \u03b1] [comm_monoid \u03b2] : comm_monoid (\u03b1 \u00d7 \u03b2) :=\n{ .. prod.comm_semigroup, .. prod.monoid }\n\ninstance [add_comm_group \u03b1] [add_comm_group \u03b2] : add_comm_group (\u03b1 \u00d7 \u03b2) :=\n{ .. prod.add_comm_semigroup, .. prod.add_group }\n@[to_additive prod.add_comm_group]\ninstance [comm_group \u03b1] [comm_group \u03b2] : comm_group (\u03b1 \u00d7 \u03b2) :=\n{ .. prod.comm_semigroup, .. prod.group }\n\n@[to_additive fst.is_add_monoid_hom]\nlemma fst.is_monoid_hom [monoid \u03b1] [monoid \u03b2] : is_monoid_hom (prod.fst : \u03b1 \u00d7 \u03b2 \u2192 \u03b1) :=\nby refine_struct {..}; simp\n@[to_additive snd.is_add_monoid_hom]\nlemma snd.is_monoid_hom [monoid \u03b1] [monoid \u03b2] : is_monoid_hom (prod.snd : \u03b1 \u00d7 \u03b2 \u2192 \u03b2) :=\nby refine_struct {..}; simp\n\n@[to_additive fst.is_add_group_hom]\nlemma fst.is_group_hom [group \u03b1] [group \u03b2] : is_group_hom (prod.fst : \u03b1 \u00d7 \u03b2 \u2192 \u03b1) :=\nby refine_struct {..}; simp\n@[to_additive snd.is_add_group_hom]\nlemma snd.is_group_hom [group \u03b1] [group \u03b2] : is_group_hom (prod.snd : \u03b1 \u00d7 \u03b2 \u2192 \u03b2) :=\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 \u03b1] [comm_monoid \u03b2] {t : finset \u03b3} {f : \u03b3 \u2192 \u03b1 \u00d7 \u03b2} :\n  (t.prod f).1 = t.prod (\u03bbc, (f c).1) :=\n(finset.prod_hom prod.fst).symm\n\n@[to_additive prod.snd_sum]\nlemma snd_prod [comm_monoid \u03b1] [comm_monoid \u03b2] {t : finset \u03b3} {f : \u03b3 \u2192 \u03b1 \u00d7 \u03b2} :\n  (t.prod f).2 = t.prod (\u03bbc, (f c).2) :=\n(finset.prod_hom prod.snd).symm\n\ninstance [semiring \u03b1] [semiring \u03b2] : semiring (\u03b1 \u00d7 \u03b2) :=\n{ zero_mul := \u03bb a, mk.inj_iff.mpr \u27e8zero_mul _, zero_mul _\u27e9,\n  mul_zero := \u03bb a, mk.inj_iff.mpr \u27e8mul_zero _, mul_zero _\u27e9,\n  left_distrib := \u03bb a b c, mk.inj_iff.mpr \u27e8left_distrib _ _ _, left_distrib _ _ _\u27e9,\n  right_distrib := \u03bb a b c, mk.inj_iff.mpr \u27e8right_distrib _ _ _, right_distrib _ _ _\u27e9,\n  ..prod.add_comm_monoid, ..prod.monoid }\n\ninstance [ring \u03b1] [ring \u03b2] : ring (\u03b1 \u00d7 \u03b2) :=\n{ ..prod.add_comm_group, ..prod.semiring }\n\ninstance [comm_ring \u03b1] [comm_ring \u03b2] : comm_ring (\u03b1 \u00d7 \u03b2) :=\n{ ..prod.ring, ..prod.comm_monoid }\n\ninstance [nonzero_comm_ring \u03b1] [comm_ring \u03b2] : nonzero_comm_ring (\u03b1 \u00d7 \u03b2) :=\n{ zero_ne_one := mt (congr_arg prod.fst) zero_ne_one,\n  ..prod.comm_ring }\n\ninstance fst.is_semiring_hom [semiring \u03b1] [semiring \u03b2] : is_semiring_hom (prod.fst : \u03b1 \u00d7 \u03b2 \u2192 \u03b1) :=\nby refine_struct {..}; simp\ninstance snd.is_semiring_hom [semiring \u03b1] [semiring \u03b2] : is_semiring_hom (prod.snd : \u03b1 \u00d7 \u03b2 \u2192 \u03b2) :=\nby refine_struct {..}; simp\n\ninstance fst.is_ring_hom [ring \u03b1] [ring \u03b2] : is_ring_hom (prod.fst : \u03b1 \u00d7 \u03b2 \u2192 \u03b1) :=\nby refine_struct {..}; simp\ninstance snd.is_ring_hom [ring \u03b1] [ring \u03b2] : is_ring_hom (prod.snd : \u03b1 \u00d7 \u03b2 \u2192 \u03b2) :=\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 \u03b2] (a : \u03b1) : \u03b1 \u00d7 \u03b2 := (a, 0)\n\n/-- Right injection function for the inner product -/\ndef inr [has_zero \u03b1] (b : \u03b2) : \u03b1 \u00d7 \u03b2 := (0, b)\n\nlemma injective_inl [has_zero \u03b2] : function.injective (inl : \u03b1 \u2192 \u03b1 \u00d7 \u03b2) :=\nassume x y h, (prod.mk.inj_iff.mp h).1\n\nlemma injective_inr [has_zero \u03b1] : function.injective (inr : \u03b2 \u2192 \u03b1 \u00d7 \u03b2) :=\nassume x y h, (prod.mk.inj_iff.mp h).2\n\n@[simp] lemma inl_eq_inl [has_zero \u03b2] {a\u2081 a\u2082 : \u03b1} : (inl a\u2081 : \u03b1 \u00d7 \u03b2) = inl a\u2082 \u2194 a\u2081 = a\u2082 :=\niff.intro (assume h, injective_inl h) (assume h, h \u25b8 rfl)\n\n@[simp] lemma inr_eq_inr [has_zero \u03b1] {b\u2081 b\u2082 : \u03b2} : (inr b\u2081 : \u03b1 \u00d7 \u03b2) = inr b\u2082 \u2194 b\u2081 = b\u2082 :=\niff.intro (assume h, injective_inr h) (assume h, h \u25b8 rfl)\n\n@[simp] lemma inl_eq_inr [has_zero \u03b1] [has_zero \u03b2] {a : \u03b1} {b : \u03b2} :\n  inl a = inr b \u2194 a = 0 \u2227 b = 0 :=\nby constructor; simp [inl, inr] {contextual := tt}\n\n@[simp] lemma inr_eq_inl [has_zero \u03b1] [has_zero \u03b2] {a : \u03b1} {b : \u03b2} :\n  inr b = inl a \u2194 a = 0 \u2227 b = 0 :=\nby constructor; simp [inl, inr] {contextual := tt}\n\n@[simp] lemma fst_inl [has_zero \u03b2] (a : \u03b1) : (inl a : \u03b1 \u00d7 \u03b2).1 = a := rfl\n@[simp] lemma snd_inl [has_zero \u03b2] (a : \u03b1) : (inl a : \u03b1 \u00d7 \u03b2).2 = 0 := rfl\n@[simp] lemma fst_inr [has_zero \u03b1] (b : \u03b2) : (inr b : \u03b1 \u00d7 \u03b2).1 = 0 := rfl\n@[simp] lemma snd_inr [has_zero \u03b1] (b : \u03b2) : (inr b : \u03b1 \u00d7 \u03b2).2 = b := rfl\n\ninstance [has_scalar \u03b1 \u03b2] [has_scalar \u03b1 \u03b3] : has_scalar \u03b1 (\u03b2 \u00d7 \u03b3) := \u27e8\u03bba p, (a \u2022 p.1, a \u2022 p.2)\u27e9\n\n@[simp] theorem smul_fst [has_scalar \u03b1 \u03b2] [has_scalar \u03b1 \u03b3]\n  (a : \u03b1) (x : \u03b2 \u00d7 \u03b3) : (a \u2022 x).1 = a \u2022 x.1 := rfl\n@[simp] theorem smul_snd [has_scalar \u03b1 \u03b2] [has_scalar \u03b1 \u03b3]\n  (a : \u03b1) (x : \u03b2 \u00d7 \u03b3) : (a \u2022 x).2 = a \u2022 x.2 := rfl\n@[simp] theorem smul_mk [has_scalar \u03b1 \u03b2] [has_scalar \u03b1 \u03b3]\n  (a : \u03b1) (b : \u03b2) (c : \u03b3) : a \u2022 (b, c) = (a \u2022 b, a \u2022 c) := rfl\n\ninstance {r : semiring \u03b1} [add_comm_monoid \u03b2] [add_comm_monoid \u03b3]\n  [semimodule \u03b1 \u03b2] [semimodule \u03b1 \u03b3] : semimodule \u03b1 (\u03b2 \u00d7 \u03b3) :=\n{ smul_add  := assume a p\u2081 p\u2082, mk.inj_iff.mpr \u27e8smul_add _ _ _, smul_add _ _ _\u27e9,\n  add_smul  := assume a p\u2081 p\u2082, mk.inj_iff.mpr \u27e8add_smul _ _ _, add_smul _ _ _\u27e9,\n  mul_smul  := assume a\u2081 a\u2082 p, mk.inj_iff.mpr \u27e8mul_smul _ _ _, mul_smul _ _ _\u27e9,\n  one_smul  := assume \u27e8b, c\u27e9, mk.inj_iff.mpr \u27e8one_smul _ _, one_smul _ _\u27e9,\n  zero_smul := assume \u27e8b, c\u27e9, mk.inj_iff.mpr \u27e8zero_smul _ _, zero_smul _ _\u27e9,\n  smul_zero := assume a, mk.inj_iff.mpr \u27e8smul_zero _, smul_zero _\u27e9,\n  .. prod.has_scalar }\n\ninstance {r : ring \u03b1} [add_comm_group \u03b2] [add_comm_group \u03b3]\n  [module \u03b1 \u03b2] [module \u03b1 \u03b3] : module \u03b1 (\u03b2 \u00d7 \u03b3) := {}\n\ninstance {r : discrete_field \u03b1} [add_comm_group \u03b2] [add_comm_group \u03b3]\n  [vector_space \u03b1 \u03b2] [vector_space \u03b1 \u03b3] : vector_space \u03b1 (\u03b2 \u00d7 \u03b3) := {}\n\nend prod\n\nnamespace finset\n\n@[to_additive finset.prod_mk_sum]\nlemma prod_mk_prod {\u03b1 \u03b2 \u03b3 : Type*} [comm_monoid \u03b1] [comm_monoid \u03b2] (s : finset \u03b3)\n  (f : \u03b3 \u2192 \u03b1) (g : \u03b3 \u2192 \u03b2) : (s.prod f, s.prod g) = s.prod (\u03bb x, (f x, g x)) :=\nby haveI := classical.dec_eq \u03b3; 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 : \u2124} (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 [\u2190h, 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 : \u2124) \u2260 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 : \u2115) [hp : fact p.prime] :\n  \u2203 (a b : \u2124) (k : \u2115), a^2 + b^2 + 1 = k * p \u2227 k < p :=\nhp.1.eq_two_or_odd.elim (\u03bb hp2, hp2.symm \u25b8 \u27e81, 0, 1, rfl, dec_trivial\u27e9) $ \u03bb hp1,\nlet \u27e8a, b, hab\u27e9 := zmod.sq_add_sq p (-1) in\nhave hab' : (p : \u2124) \u2223 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 \u27e8k, hk\u27e9 := hab' in\nhave hk0 : 0 \u2264 k, from nonneg_of_mul_nonneg_right\n  (by rw \u2190 hk; exact (add_nonneg (add_nonneg (sq_nonneg _) (sq_nonneg _)) zero_le_one))\n  (int.coe_nat_pos.2 hp.1.pos),\n\u27e8a.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 [\u2190 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      ... \u2264 (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 [\u2190 nat.mod_add_div p 2] }, ring })\n    (show 0 \u2264 p, from nat.zero_le _)\u27e9\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 : \u2124}\n  (h : a^2 + b^2 + c^2 + d^2 = 2 * m) : \u2203 w x y z : \u2124, w^2 + x^2 + y^2 + z^2 = m :=\nhave \u2200 f : fin 4 \u2192 zmod 2, (f 0)^2 + (f 1)^2 + (f 2)^2 + (f 3)^2 = 0 \u2192\n    \u2203 i : (fin 4), (f i)^2 + f (swap i 0 1)^2 = 0 \u2227 f (swap i 0 2)^2 + f (swap i 0 3)^2 = 0,\n  from dec_trivial,\nlet f : fin 4 \u2192 \u2124 :=\n  vector.nth (a ::\u1d65 b ::\u1d65 c ::\u1d65 d ::\u1d65 vector.nil) in\nlet \u27e8i, h\u03c3\u27e9 := this (\u03bb x, coe (f x)) (by rw [\u2190 @zero_mul (zmod 2) _ m,\n  \u2190 show ((2 : \u2124) : zmod 2) = 0, from rfl,\n  \u2190 int.cast_mul, \u2190 h]; simp only [int.cast_add, int.cast_pow]; refl) in\nlet \u03c3 := swap i 0 in\nhave h01 : 2 \u2223 f (\u03c3 0) ^ 2 + f (\u03c3 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\u03c3.1,\nhave h23 : 2 \u2223 f (\u03c3 2) ^ 2 + f (\u03c3 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\u03c3.2,\nlet \u27e8x, hx\u27e9 := h01 in let \u27e8y, hy\u27e9 := h23 in\n\u27e8(f (\u03c3 0) - f (\u03c3 1)) / 2, (f (\u03c3 0) + f (\u03c3 1)) / 2, (f (\u03c3 2) - f (\u03c3 3)) / 2, (f (\u03c3 2) + f (\u03c3 3)) / 2,\n  begin\n    rw [\u2190 int.sq_add_sq_of_two_mul_sq_add_sq hx.symm, add_assoc,\n      \u2190 int.sq_add_sq_of_two_mul_sq_add_sq hy.symm,\n      \u2190 mul_right_inj' (show (2 : \u2124) \u2260 0, from dec_trivial), \u2190 h, mul_add, \u2190 hx, \u2190 hy],\n    have : \u2211 x, f (\u03c3 x)^2 = \u2211 x, f x^2,\n    { conv_rhs { rw \u2190equiv.sum_comp \u03c3 } },\n    simpa only [fin.sum_univ_four, add_assoc] using this,\n  end\u27e9\n\nprivate lemma prime_sum_four_squares (p : \u2115) [hp : fact p.prime] :\n  \u2203 a b c d : \u2124, a^2 + b^2 + c^2 + d^2 = p :=\nhave hm : \u2203 m < p, 0 < m \u2227 \u2203 a b c d : \u2124, a^2 + b^2 + c^2 + d^2 = m * p,\n  from let \u27e8a, b, k, hk\u27e9 := exists_sq_add_sq_add_one_eq_k p in\n  \u27e8k, hk.2, nat.pos_of_ne_zero $\n    (\u03bb 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\u27e9,\nlet m := nat.find hm in\nlet \u27e8a, b, c, d, (habcd : a^2 + b^2 + c^2 + d^2 = m * p)\u27e9 := (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  (\u03bb hm2 : m % 2 = 0,\n    let \u27e8k, hk\u27e9 := 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 \u27e8lt_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 })\u27e9)\n  (\u03bb hm2 : m % 2 = 1,\n    if hm1 : m = 1 then \u27e8a, b, c, d, by simp only [hm1, habcd, int.coe_nat_one, one_mul]\u27e9\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 : \u2115),\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 : \u2115) : hnat_abs\n        ... \u2264 ((m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 + (m / 2) ^ 2 : \u2115) :\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 : \u2115) ^ 2 : by simp only [bit0_mul, one_mul, two_smul,\n                                                  nat.cast_add, nat.cast_pow, add_assoc]\n        ... < 4 * (m / 2 : \u2115) ^ 2 + ((4 * (m / 2) : \u2115) * (m % 2 : \u2115) + (m % 2 : \u2115)^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 [\u2190 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 : \u2124) : zmod m) =\n          ((a^2 + b^2 + c^2 + d^2 : \u2124) : zmod m),\n        by push_cast,\n      have hwxyz0 : ((w^2 + x^2 + y^2 + z^2 : \u2124) : zmod m) = 0,\n        by rw [hwxyzabcd, habcd, int.cast_mul, cast_coe_nat, zmod.nat_cast_self, zero_mul],\n      let \u27e8n, hn\u27e9 := ((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 (\u03bb hn0,\n        have hwxyz0 : (w.nat_abs^2 + x.nat_abs^2 + y.nat_abs^2 + z.nat_abs^2 : \u2115) = 0,\n          by { rw [\u2190 int.coe_nat_eq_zero, \u2190 hnat_abs], rwa [hn0, mul_zero] at hn },\n        have habcd0 : (m : \u2124) \u2223 a \u2227 (m : \u2124) \u2223 b \u2227 (m : \u2124) \u2223 c \u2227 (m : \u2124) \u2223 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 \u27e8ma, hma\u27e9 := habcd0.1,     \u27e8mb, hmb\u27e9 := habcd0.2.1,\n            \u27e8mc, hmc\u27e9 := habcd0.2.2.1, \u27e8md, hmd\u27e9 := habcd0.2.2.2 in\n        have hmdvdp : m \u2223 p,\n          from int.coe_nat_dvd.1 \u27e8ma^2 + mb^2 + mc^2 + md^2,\n            (mul_right_inj' (show (m : \u2124) \u2260 0, from int.coe_nat_ne_zero.2 hm0.1)).1 $\n              by { rw [\u2190 habcd, hma, hmb, hmc, hmd], ring }\u27e9,\n        (hp.1.eq_one_or_self_of_dvd _ hmdvdp).elim hm1\n        (\u03bb hmeqp, by simpa [lt_irrefl, hmeqp] using hmp)),\n      have hawbxcydz : ((m : \u2115) : \u2124) \u2223 a * w + b * x + c * y + d * z,\n        from (char_p.int_cast_eq_zero_iff (zmod m) m _).1 $\n          by { rw [\u2190 hwxyz0], simp_rw [sq], push_cast },\n      have haxbwczdy : ((m : \u2115) : \u2124) \u2223 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 : \u2115) : \u2124) \u2223 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 : \u2115) : \u2124) \u2223 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 \u27e8s, hs\u27e9 := hawbxcydz, \u27e8t, ht\u27e9 := haxbwczdy, \u27e8u, hu\u27e9 := haybzcwdx, \u27e8v, hv\u27e9 := hazbycxdw in\n      have hn_nonneg : 0 \u2264 n,\n        from nonneg_of_mul_nonneg_right\n          (by { erw [\u2190 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, \u2190 hn, \u2190 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 : \u2124) \u2260 0, from pow_ne_zero 2\n            (int.coe_nat_ne_zero.2 hm0.1))).1 $\n          calc (m : \u2124)^2 * (s^2 + t^2 + u^2 + v^2) = ((m : \u2115) * s)^2 + ((m : \u2115) * t)^2 +\n              ((m : \u2115) * u)^2 + ((m : \u2115) * 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 \u27e8lt_trans hnm hmp, hn0, s, t, u, v, hstuv\u27e9)\n\n/-- **Four squares theorem** -/\nlemma sum_four_squares : \u2200 n : \u2115, \u2203 a b c d : \u2115, a^2 + b^2 + c^2 + d^2 = n\n| 0 := \u27e80, 0, 0, 0, rfl\u27e9\n| 1 := \u27e81, 0, 0, 0, rfl\u27e9\n| n@(k+2) :=\nhave hm : fact (min_fac (k+2)).prime := \u27e8min_fac_prime dec_trivial\u27e9,\nhave n / min_fac n < n := factors_lemma,\nlet \u27e8a, b, c, d, h\u2081\u27e9 := show \u2203 a b c d : \u2124, a^2 + b^2 + c^2 + d^2 = min_fac n,\n  by exactI prime_sum_four_squares (min_fac (k+2)) in\nlet \u27e8w, x, y, z, h\u2082\u27e9 := sum_four_squares (n / min_fac n) in\n\u27e8(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 [\u2190 int.coe_nat_inj', \u2190 nat.mul_div_cancel' (min_fac_dvd (k+2)), int.coe_nat_mul, \u2190 h\u2081, \u2190 h\u2082],\n    simp [sum_four_sq_mul_sum_four_sq],\n  end\u27e9\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 \u27f6 Spec \u0393(X)` is an\n  isomorphism.\n* `algebraic_geometry.Scheme.iso_Spec`: The canonical isomorphism `X \u2245 Spec \u0393(X)` for an affine\n  scheme.\n* `algebraic_geometry.AffineScheme.equiv_CommRing`: The equivalence of categories\n  `AffineScheme \u224c CommRing\u1d52\u1d56` given by `AffineScheme.Spec : CommRing\u1d52\u1d56 \u2964 AffineScheme` and\n  `AffineScheme.\u0393 : AffineScheme\u1d52\u1d56 \u2964 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 \ud835\udcaa\u2093(U) \u27f6 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 \u27f6 Spec \u0393(X)` is an isomorphism. -/\nclass IsAffine (X : Scheme) : Prop where\n  affine : IsIso (\u0393Spec.adjunction.Unit.app X)\n#align algebraic_geometry.is_affine AlgebraicGeometry.IsAffine\n\nattribute [instance] is_affine.affine\n\n/-- The canonical isomorphism `X \u2245 Spec \u0393(X)` for an affine scheme. -/\ndef Scheme.isoSpec (X : Scheme) [IsAffine X] : X \u2245 Scheme.spec.obj (op <| Scheme.\u0393.obj <| op X) :=\n  asIso (\u0393Spec.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  \u27e8X, @mem_essImage_of_unit_isIso _ _ _ _ h.1\u27e9\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 \u27f6 Y) :\n    AffineScheme.of X \u27f6 AffineScheme.of Y :=\n  f\n#align algebraic_geometry.AffineScheme.of_hom AlgebraicGeometry.AffineScheme.ofHom\n\ntheorem mem_spec_essImage (X : Scheme) : X \u2208 Scheme.spec.essImage \u2194 IsAffine X :=\n  \u27e8fun h => \u27e8Functor.essImage.unit_isIso h\u27e9, fun h => @mem_essImage_of_unit_isIso _ _ _ X h.1\u27e9\n#align algebraic_geometry.mem_Spec_ess_image AlgebraicGeometry.mem_spec_essImage\n\ninstance isAffineAffineScheme (X : AffineScheme.{u}) : IsAffine X.obj :=\n  \u27e8Functor.essImage.unit_isIso X.property\u27e9\n#align algebraic_geometry.is_affine_AffineScheme AlgebraicGeometry.isAffineAffineScheme\n\ninstance specIsAffine (R : CommRingCat\u1d52\u1d56) : IsAffine (Scheme.spec.obj R) :=\n  AlgebraicGeometry.isAffineAffineScheme \u27e8_, Scheme.spec.obj_mem_essImage R\u27e9\n#align algebraic_geometry.Spec_is_affine AlgebraicGeometry.specIsAffine\n\ntheorem isAffineOfIso {X Y : Scheme} (f : X \u27f6 Y) [IsIso f] [h : IsAffine Y] : IsAffine X :=\n  by\n  rw [\u2190 mem_Spec_ess_image] at h\u22a2\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\u1d52\u1d56 \u2964 AffineScheme :=\n  Scheme.spec.toEssImage deriving Full, Faithful, EssSurj\n#align algebraic_geometry.AffineScheme.Spec AlgebraicGeometry.AffineScheme.spec\n\n/-- The forgetful functor `AffineScheme \u2964 Scheme`. -/\n@[simps]\ndef forgetToScheme : AffineScheme \u2964 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 \u0393 : AffineScheme\u1d52\u1d56 \u2964 CommRingCat :=\n  forgetToScheme.op \u22d9 Scheme.\u0393\n#align algebraic_geometry.AffineScheme.\u0393 AlgebraicGeometry.AffineScheme.\u0393\n\n/-- The category of affine schemes is equivalent to the category of commutative rings. -/\ndef equivCommRing : AffineScheme \u224c CommRingCat\u1d52\u1d56 :=\n  equivEssImageOfReflective.symm\n#align algebraic_geometry.AffineScheme.equiv_CommRing AlgebraicGeometry.AffineScheme.equivCommRing\n\ninstance \u0393IsEquiv : IsEquivalence \u0393.{u} :=\n  haveI : is_equivalence \u0393.{u}.rightOp.op := is_equivalence.of_equivalence equiv_CommRing.op\n  (functor.is_equivalence_trans \u0393.{u}.rightOp.op (op_op_equivalence _).Functor : _)\n#align algebraic_geometry.AffineScheme.\u0393_is_equiv AlgebraicGeometry.AffineScheme.\u0393IsEquiv\n\ninstance : HasColimits AffineScheme.{u} :=\n  haveI := Adjunction.has_limits_of_equivalence.{u} \u0393.{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 \u0393.{u}\n  haveI : has_limits AffineScheme.{u}\u1d52\u1d56\u1d52\u1d56 := limits.has_limits_op_of_has_colimits\n  exact adjunction.has_limits_of_equivalence (op_op_equivalence AffineScheme.{u}).inverse\n\nnoncomputable instance : PreservesLimits \u0393.{u}.rightOp :=\n  @Adjunction.isEquivalencePreservesLimits _ _ \u0393.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 \u22d9 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 \u27f6 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 (\u22a4 : Opens X.carrier) :=\n  by\n  convert range_is_affine_open_of_open_immersion (\ud835\udfd9 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 \u2208 (U : Set X.carrier))\n  obtain \u27e8S, hS, hxS, hSU\u27e9 := X.affine_basis_cover_is_basis.exists_subset_of_mem_open hU U.is_open\n  refine' \u27e8\u27e8S, X.affine_basis_cover_is_basis.is_open hS\u27e9, _, hxS, hSU\u27e9\n  rcases hS with \u27e8i, rfl\u27e9\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 \ud835\udcaa\u2093(U) \u27f6 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) \u27f6 X :=\n  by\n  haveI : is_affine (X.restrict U.open_embedding) := hU\n  have : U.open_embedding.is_open_map.functor.obj \u22a4 = 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 \u226b\n      (X.restrict U.open_embedding).isoSpec.inv \u226b 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 [\u2190 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 [\u2190 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 \u22a4 = 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 \u27f6 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 \u226b 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 \u27f6 Y) [H : IsOpenImmersion f]\n    (U : Opens X.carrier) : IsAffineOpen (H.openFunctor.obj U) \u2194 IsAffineOpen U :=\n  by\n  refine' \u27e8fun hU => @is_affine_of_iso _ _ hU, fun hU => hU.image_isOpenImmersion f\u27e9\n  refine' (is_open_immersion.iso_of_range_eq (X.of_restrict _ \u226b f) (Y.of_restrict _) _).Hom\n  \u00b7 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  \u00b7 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  \u27e8(top_isAffineOpen X).IsCompact\u27e9\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 = \u22a4 :=\n  by\n  ext1\n  change hU.from_Spec.1.base \u207b\u00b9' (U : Set X.carrier) = Set.univ\n  rw [\u2190 hU.from_Spec_range, \u2190 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 (\ud835\udfd9 (op U))).op = \ud835\udfd9 _ := 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\u0393Identity_hom_app_fromSpec {X : Scheme} {U : Opens X.carrier}\n    (hU : IsAffineOpen U) :\n    spec\u0393Identity.Hom.app (X.Presheaf.obj <| op U) \u226b 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\u2081 := Spec_\u0393_identity.hom.naturality (X.presheaf.map (eq_to_hom U.open_embedding_obj_top).op)\n  rw [\u2190 is_iso.comp_inv_eq] at e\u2081\n  have e\u2082 := \u0393_Spec.adjunction_unit_app_app_top (X.restrict U.open_embedding)\n  erw [\u2190 e\u2082] at e\u2081\n  simp only [functor.id_map, Quiver.Hom.unop_op, functor.comp_map, \u2190 functor.map_inv, \u2190 op_inv,\n    LocallyRingedSpace.\u0393_map, category.assoc, functor.right_op_map, inv_eq_to_hom] at e\u2081\n  delta is_affine_open.from_Spec Scheme.iso_Spec\n  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app, \u2190 e\u2081]\n  simp_rw [category.assoc]\n  erw [\u2190 X.presheaf.map_comp_assoc]\n  rw [\u2190 op_comp]\n  have e\u2083 :\n    U.open_embedding.is_open_map.adjunction.counit.app U \u226b 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\u2084 : X.presheaf.map _ \u226b _ = _ :=\n    (as_iso (\u0393_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\u2083, e\u2084, \u2190 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_\u0393_identity_hom_app_from_Spec AlgebraicGeometry.IsAffineOpen.spec\u0393Identity_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\u0393Identity.inv.app (X.Presheaf.obj <| op U) \u226b\n        (Scheme.spec.obj _).Presheaf.map (eqToHom hU.fromSpec_base_preimage).op :=\n  by rw [\u2190 hU.Spec_\u0393_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 \u226b\n        hU.from_Spec)\n  ext1\n  have :\n    hU.from_Spec.val.base '' (hU.from_Spec.val.base \u207b\u00b9' (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, \u2190 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 = \u22a4 :=\n    by\n    ext1\n    change hU.from_Spec.1.base \u207b\u00b9' (U : Set X.carrier) = Set.univ\n    rw [\u2190 hU.from_Spec_range, \u2190 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 : \u2200 s, (opens.map hU.from_Spec.val.base).obj U \u2293 s = s := fun s => this.symm \u25b8 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 [\u2190 comp_apply]\n  congr 2\n  rw [iso.eq_inv_comp]\n  erw [hU.Spec_\u0393_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 \u22a4))\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, \u2190\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.\u0393.obj (op X)) :\n    (Opens.map X.isoSpec.Hom.1.base).obj (PrimeSpectrum.basicOpen f) = X.basicOpen f :=\n  by\n  rw [\u2190 basic_open_eq_of_affine]\n  trans\n    (opens.map X.iso_Spec.hom.1.base).obj\n      ((Scheme.Spec.obj (op (Scheme.\u0393.obj (op X)))).basicOpen\n        ((inv (X.iso_Spec.hom.1.c.app (op ((opens.map (inv X.iso_Spec.hom).val.base).obj \u22a4))))\n          ((X.presheaf.map (eq_to_hom _)) f)))\n  congr\n  \u00b7 rw [\u2190 is_iso.inv_eq_inv, is_iso.inv_inv, is_iso.iso.inv_inv, nat_iso.app_hom]\n    erw [\u2190 \u0393_Spec.adjunction_unit_app_app_top]\n    rfl\n  \u00b7 rw [eq_to_hom_map]\n    rfl\n  \u00b7 dsimp\n    congr\n  \u00b7 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 \u22a4) \u2192 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  \u00b7 rintro \u27e8_, \u27e8x, rfl\u27e9, rfl\u27e9\n    refine' \u27e8_, \u27e8_, \u27e8x, rfl\u27e9, rfl\u27e9, _\u27e9\n    exact congr_arg opens.carrier (X.map_prime_spectrum_basic_open_of_affine x)\n  \u00b7 rintro \u27e8_, \u27e8_, \u27e8x, rfl\u27e9, rfl\u27e9, rfl\u27e9\n    refine' \u27e8_, \u27e8x, rfl\u27e9, _\u27e9\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 : \u2191x \u2208 U) :\n    \u2203 f : X.Presheaf.obj (op U), X.basicOpen f \u2264 V \u2227 \u2191x \u2208 X.basicOpen f :=\n  by\n  haveI : is_affine _ := hU\n  obtain \u27e8_, \u27e8_, \u27e8r, rfl\u27e9, rfl\u27e9, h\u2081, h\u2082\u27e9 :=\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 \u27e8x, h\u27e9\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 [\u2190 Scheme.basic_open_res_eq _ _ (eq_to_hom U.open_embedding_obj_top).op]\n    rw [\u2190 comp_apply, \u2190 CategoryTheory.Functor.map_comp, \u2190 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 [\u2190 this]\n  exact \u27e8set.image_subset_iff.mpr h\u2082, Set.mem_image_of_mem _ h\u2081\u27e9\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 : _ \u27f6 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\u0393Identity.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 [\u2190 comp_apply]\n  congr\n  erw [\u2190 hU.Spec_\u0393_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 `\u0393(\ud835\udcaa\u2093, D(f)) \u27f6 \u0393(Spec \ud835\udcaa\u2093(U), D(Spec_\u0393_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) \u27f6\n      (Scheme.spec.obj <| op <| X.Presheaf.obj (op U)).Presheaf.obj\n        (op <| Scheme.basicOpen _ <| spec\u0393Identity.inv.app (X.Presheaf.obj (op U)) f) :=\n  hU.fromSpec.1.c.app (op <| X.basicOpen f) \u226b\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  \u00b7 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 \u226b\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 _ \u226b basic_open_sections_to_affine hU f \u226b _ = _\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, \u2190 functor.map_comp, \u2190 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 \u22a4)) :\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 \u27f6 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 \u0393RestrictAlgebra {X : Scheme} {Y : TopCat} {f : Y \u27f6 X.carrier} (hf : OpenEmbedding f) :\n    Algebra (Scheme.\u0393.obj (op X)) (Scheme.\u0393.obj (op <| X.restrict hf)) :=\n  (Scheme.\u0393.map (X.of_restrict hf).op).toAlgebra\n#align algebraic_geometry.\u0393_restrict_algebra AlgebraicGeometry.\u0393RestrictAlgebra\n\ninstance \u0393_restrict_is_localization (X : Scheme.{u}) [IsAffine X] (r : Scheme.\u0393.obj (op X)) :\n    IsLocalization.Away r (Scheme.\u0393.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.\u0393_restrict_is_localization AlgebraicGeometry.\u0393_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    \u2203 f' : X.Presheaf.obj (op U), X.basicOpen f' = X.basicOpen g :=\n  by\n  haveI := is_localization_basic_open hU f\n  obtain \u27e8x, \u27e8_, n, rfl\u27e9, rfl\u27e9 := 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 \u2208 U \u2293 V) :\n    \u2203 (f : X.Presheaf.obj <| op U)(g : X.Presheaf.obj <| op V),\n      X.basicOpen f = X.basicOpen g \u2227 x \u2208 X.basicOpen f :=\n  by\n  obtain \u27e8f, hf\u2081, hf\u2082\u27e9 := hU.exists_basic_open_le \u27e8x, hx.2\u27e9 hx.1\n  obtain \u27e8g, hg\u2081, hg\u2082\u27e9 := hV.exists_basic_open_le \u27e8x, hf\u2082\u27e9 hx.2\n  obtain \u27e8f', hf'\u27e9 :=\n    basic_open_basic_open_is_basic_open hU f (X.presheaf.map (hom_of_le hf\u2081 : _ \u27f6 V).op g)\n  replace hf' := (hf'.trans (RingedSpace.basic_open_res _ _ _)).trans (inf_eq_right.mpr hg\u2081)\n  exact \u27e8f', g, hf', hf'.symm \u25b8 hg\u2082\u27e9\n#align algebraic_geometry.exists_basic_open_le_affine_inter AlgebraicGeometry.exists_basicOpen_le_affine_inter\n\n/-- The prime ideal of `\ud835\udcaa\u2093(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 \u22a4 = 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 [\u2190 Scheme.comp_val_base_apply, \u2190 Scheme.comp_val_base_apply]\n  simpa only [\u2190 functor.map_comp_assoc, \u2190 functor.map_comp, \u2190 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 (\u0393Spec.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 \u22a4 \u27f6\n                U.OpenEmbedding.IsOpenMap.Functor.obj ((Opens.map U.inclusion).obj U)).op \u226b\n        toSpec\u0393 (X.Presheaf.obj <| op (U.OpenEmbedding.IsOpenMap.Functor.obj \u22a4)) \u226b\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 _ \u27f6 \u22a4).op :=\n  by\n  have e :\n    (opens.map (inv (\u0393_Spec.adjunction.unit.app (X.restrict U.open_embedding))).1.base).obj\n        ((opens.map U.inclusion).obj U) =\n      \u22a4 :=\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    \u0393_Spec.adjunction_unit_app_app_top]\n  simp only [category.assoc, eq_to_hom_op]\n  erw [\u2190 functor.map_comp_assoc]\n  rw [eq_to_hom_trans, eq_to_hom_refl, CategoryTheory.Functor.map_id, category.id_comp]\n  erw [Spec_\u0393_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 := \u27e8x\u27e9\n  rcases x with \u27e8x, hx\u27e9\n  let y := hU.prime_ideal_of \u27e8x, hx\u27e9\n  have : hU.from_Spec.val.base y = x := hU.from_Spec_prime_ideal_of \u27e8x, hx\u27e9\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 _ \u27e8_, _\u27e9).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 [\u2190 category.assoc]\n  erw [\u2190 X.presheaf.map_comp, Spec_\u0393_naturality_assoc]\n  congr 1\n  simp only [\u2190 category.assoc]\n  trans _ \u226b (structure_sheaf (X.presheaf.obj <| op U)).Presheaf.germ \u27e8_, _\u27e9\n  \u00b7 rfl\n  convert(structure_sheaf (X.presheaf.obj <| op U)).Presheaf.germ_res (hom_of_le le_top)\n      \u27e8_, _\u27e9 using\n    2\n  rw [category.assoc]\n  erw [nat_trans.naturality]\n  rw [\u2190 LocallyRingedSpace.\u0393_map_op, \u2190 LocallyRingedSpace.\u0393.map_comp_assoc, \u2190 op_comp]\n  erw [\u2190 Scheme.Spec.map_comp]\n  rw [\u2190 op_comp, \u2190 X.presheaf.map_comp]\n  trans\n    LocallyRingedSpace.\u0393.map (Quiver.Hom.op <| Scheme.Spec.map (X.presheaf.map (\ud835\udfd9 (op U))).op) \u226b _\n  \u00b7 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  \u27e8X.basicOpen f, U.Prop.basicOpen_is_affine f\u27e9\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 [\u2190 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 [\u2190 comp_apply, \u2190 comp_apply, category.assoc, \u2190 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    \u2190 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    (\u2a06 f : s, X.basicOpen (f : X.Presheaf.obj <| op U)) = U \u2194 Ideal.span s = \u22a4 :=\n  by\n  trans (\u22c3 i : s, (PrimeSpectrum.basicOpen i.1).1) = Set.univ\n  trans\n    hU.from_Spec.1.base \u207b\u00b9' (\u2a06 f : s, X.basic_open (f : X.presheaf.obj <| op U)).1 =\n      hU.from_Spec.1.base \u207b\u00b9' U.1\n  \u00b7 refine' \u27e8fun h => by rw [h], _\u27e9\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\u1d62_subset_iff, SetCoe.forall, opens.coe_supr]\n    intro x hx\n    exact X.basic_open_le x\n  \u00b7 simp only [opens.supr_def, Subtype.coe_mk, Set.preimage_union\u1d62, Subtype.val_eq_coe]\n    congr 3\n    \u00b7 ext1 x\n      exact congr_arg opens.carrier (hU.from_Spec_map_basic_open _)\n    \u00b7 exact congr_arg opens.carrier hU.from_Spec_base_preimage\n  \u00b7 simp only [opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]\n    rw [\u2190 Set.compl_inter\u1d62, Set.compl_univ_iff, \u2190 PrimeSpectrum.zeroLocus_union\u1d62, \u2190\n      PrimeSpectrum.zeroLocus_empty_iff_eq_top, PrimeSpectrum.zeroLocus_span]\n    simp only [Set.union\u1d62_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 \u2264 \u2a06 f : s, X.basicOpen (f : X.Presheaf.obj <| op U)) \u2194 Ideal.span s = \u22a4 :=\n  by\n  rw [\u2190 hU.basic_open_union_eq_self_iff, @comm _ Eq]\n  refine' \u27e8fun h => le_antisymm h _, le_of_eq\u27e9\n  simp only [sup\u1d62_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 \u2192 Prop}\n    (hP\u2081 : \u2200 (U : X.affineOpens) (f : X.Presheaf.obj <| op U.1), P U \u2192 P (X.affineBasicOpen f))\n    (hP\u2082 :\n      \u2200 (U : X.affineOpens) (s : Finset (X.Presheaf.obj <| op U))\n        (hs : Ideal.span (s : Set (X.Presheaf.obj <| op U)) = \u22a4),\n        (\u2200 f : s, P (X.affineBasicOpen f.1)) \u2192 P U)\n    (hS : (\u22c3 i : S, i : Set X.carrier) = Set.univ) (hS' : \u2200 U : S, P U) : P V := by\n  classical\n    have :\n      \u2200 x : V, \u2203 f : X.presheaf.obj <| op V.1, \u2191x \u2208 X.basic_open f \u2227 P (X.affine_basic_open f) :=\n      by\n      intro x\n      have : \u2191x \u2208 (Set.univ : Set X.carrier) := trivial\n      rw [\u2190 hS] at this\n      obtain \u27e8W, hW\u27e9 := set.mem_Union.mp this\n      obtain \u27e8f, g, e, hf\u27e9 := exists_basic_open_le_affine_inter V.prop W.1.Prop x \u27e8x.prop, hW\u27e9\n      refine' \u27e8f, hf, _\u27e9\n      convert hP\u2081 _ g (hS' W) using 1\n      ext1\n      exact e\n    choose f hf\u2081 hf\u2082 using this\n    suffices Ideal.span (Set.range f) = \u22a4\n      by\n      obtain \u27e8t, ht\u2081, ht\u2082\u27e9 := (Ideal.span_eq_top_iff_finite _).mp this\n      apply hP\u2082 V t ht\u2082\n      rintro \u27e8i, hi\u27e9\n      obtain \u27e8x, rfl\u27e9 := ht\u2081 hi\n      exact hf\u2082 x\n    rw [\u2190 V.prop.self_le_basic_open_union_iff]\n    intro x hx\n    rw [sup\u1d62_range', opens.mem_supr]\n    exact \u27e8_, hf\u2081 \u27e8x, hx\u27e9\u27e9\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-\u03c0\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 `\u03c9', holding the definitions of species. Species invocations\n      `D(a\u0305)' 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 \u03c0-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 \u03c0-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 : \u2115 \u2192 context \u2192 context\n\n/-- A reference to a species definition within the global definition context. -/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive reference : \u2115 \u2192 context \u2192 Type\n| zero   {\u03c9 : context} (n : \u2115) : reference n (context.extend n \u03c9)\n| extend {\u03c9 : context} {n m : \u2115} : reference n \u03c9 \u2192 reference n (context.extend m \u03c9)\n\n/-- The set of names within the continuous \u03c0-calculus. -/\n@[derive decidable_eq, nolint has_inhabited_instance]\ninductive name : context \u2192 Type\n| zero   {\u0393} {n : \u2115} : fin n \u2192 name (context.extend n \u0393)\n| extend {\u0393} {n : \u2115} : name \u0393 \u2192 name (context.extend n \u0393)\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 \u2192 Type\n| zero   {\u0393} {n} : level (context.extend n \u0393)\n| extend {\u0393} {n} : level \u0393 \u2192 level (context.extend n \u0393)\n\n\n/-- Get the variable level/depth. This doesn't have much use aside for pretty-printing. -/\nprotected def reference.level : \u2200 {\u0393 n}, reference \u0393 n \u2192 \u2115\n| \u0393 n (reference.zero _) := 0\n| \u0393 n (reference.extend r) := 1 + reference.level r\n\ninstance {\u0393 n} : has_repr (reference \u0393 n) := \u27e8 \u03bb x, repr (reference.level x) \u27e9\n\nnamespace name\n  /-- Get the variable index. This doesn't have much use aside for pretty-printing. -/\n  protected def idx : \u2200 {\u0393}, name \u0393 \u2192 \u2115\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 : \u2200 {\u0393}, name \u0393 \u2192 \u2115\n  | ._ (name.zero a) := 0\n  | ._ (name.extend a) := 1 + level a\n\n  instance {\u0393} : has_repr (name \u0393) := \u27e8 \u03bb x, repr (name.level x) ++ \".\" ++ repr (name.idx x) \u27e9\n\n  /-- Get the level of this name. -/\n  def to_level : \u2200 {\u0393}, name \u0393 \u2192 level \u0393\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 : \u2200 {\u0393}, level \u0393 \u2192 name \u0393 \u2192 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 {\u0393} : has_mem (level \u0393) (name \u0393) := \u27e8 at_level \u27e9\n\n    private def at_level_decide :\n      \u2200 {\u0393} (l : level \u0393) (a : name \u0393), 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 {\u0393} {l} {a : name \u0393} : 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 : \u2200 {\u0393} (a : name \u0393), name.to_level a \u2208 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 \u2209 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 \u0393 \u2192 name \u0394' 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 {\u0393 \u0394} {n}\n        (P : level (context.extend n \u0393) \u2192 Prop)\n        (\u03c1 : \u03a0 (x : name \u0393), P (level.extend (name.to_level x)) \u2192 name \u0394)\n      : \u03a0 (x : name (context.extend n \u0393)), P (name.to_level x) \u2192 name (context.extend n \u0394)\n    | (zero idx) p := zero idx\n    | (extend a) p := extend (\u03c1 a p)\n\n    /-- Extending with `id' does nothing. -/\n    lemma ext_with_identity :\n      \u2200 {\u0393} {n : \u2115}\n        (P : level (context.extend n \u0393) \u2192 Prop)\n        (a : name (context.extend n \u0393)) (p : P (name.to_level a))\n      , ext_with P (\u03bb x _, x) a p = a\n    | \u0393 n P (zero lt) _ := rfl\n    | \u0393 n P (extend a) _ := rfl\n\n    /-- Extending with `id' is equivalent to the identity function. -/\n    lemma ext_with_id {\u0393} {n : \u2115} (P : level (context.extend n \u0393) \u2192 Prop)\n      : ext_with P (\u03bb x _, x) = \u03bb x _, x\n      := funext $ \u03bb 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 {\u0393 \u0394} {n} (\u03c1 : name \u0393 \u2192 name \u0394)\n      : name (context.extend n \u0393) \u2192 name (context.extend n \u0394)\n    | a := ext_with (\u03bb _, true) (\u03bb x p, \u03c1 x) a true.intro\n\n    /-- Extending with the identity does nothing. -/\n    lemma ext_identity {\u0393} {n : \u2115} (a : name (context.extend n \u0393))\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 : \u2200 {\u0393} {n : \u2115}, @ext \u0393 \u0393 n id = id\n    | \u0393 n := funext ext_identity\n\n    /-- Composing extensions is equivalent extending a composition. -/\n    lemma ext_with_compose :\n      \u2200 {\u0393 \u0394 \u03b7} {n : \u2115}\n        (P : level (context.extend n \u0393) \u2192 Prop)\n        (\u03c1 : \u03a0 (x : name \u0393), P (level.extend (name.to_level x)) \u2192 name \u0394)\n        (\u03c3 : name \u0394 \u2192 name \u03b7)\n        (a : name (context.extend n \u0393)) (p : P (name.to_level a))\n      , ext \u03c3 (ext_with P \u03c1 a p) = ext_with P (\u03bb a p, \u03c3 (\u03c1 a p)) a p\n    | \u0393 \u0394 \u03b7 n P \u03c1 \u03c3 (zero lt) _ := rfl\n    | \u0393 \u0394 \u03b7 n P \u03c1 \u03c3 (extend a) _ := rfl\n\n    /-- Composing extensions is equivalent extending a composition. -/\n    lemma ext_with_comp {\u0393 \u0394 \u03b7} {n : \u2115}\n        (P : level (context.extend n \u0393) \u2192 Prop)\n        (\u03c1 : \u03a0 (x : name \u0393), P (level.extend (name.to_level x)) \u2192 name \u0394)\n        (\u03c3 : name \u0394 \u2192 name \u03b7)\n      : (\u03bb a p, ext \u03c3 (ext_with P \u03c1 a p)) = ext_with P (\u03bb a p, \u03c3 (\u03c1 a p))\n      := funext $ \u03bb a, funext (ext_with_compose P \u03c1 \u03c3 a)\n\n    /-- Composing simple extensions is equivalent extending a composition. -/\n    lemma ext_compose {\u0393 \u0394 \u03b7} (\u03c1 : name \u0393 \u2192 name \u0394) (\u03c3 : name \u0394 \u2192 name \u03b7) {n : \u2115}\n        (a : name (context.extend n \u0393))\n      : ext \u03c3 (ext \u03c1 a) = ext (\u03c3 \u2218 \u03c1) a\n      := ext_with_compose (\u03bb _, true) (\u03bb x _, \u03c1 x) \u03c3 a true.intro\n\n    /-- Composing simple extensions is equivalent extending a composition. -/\n    lemma ext_comp {\u0393 \u0394 \u03b7} (\u03c1 : name \u0393 \u2192 name \u0394) (\u03c3 : name \u0394 \u2192 name \u03b7) {n : \u2115}\n      : (ext \u03c3 \u2218 ext \u03c1) = @ext _ _ n (\u03c3 \u2218 \u03c1)\n      := funext (ext_compose \u03c1 \u03c3)\n\n    /-- Extending then renaming with an extended function, is equivalent to\n        renaming then extending. -/\n    lemma ext_extend {\u0393 \u0394} {n : \u2115} (\u03c1 : name \u0393 \u2192 name \u0394)\n      : (ext \u03c1 \u2218 extend) = (@extend \u0394 n \u2218 \u03c1) := funext (\u03bb x, rfl)\n\n    lemma ext_zero {\u0393 \u0394} {n : \u2115} (\u03c1 : name \u0393 \u2192 name \u0394)\n      : (ext \u03c1 \u2218 zero) = (@zero \u0394 n) := funext (\u03bb 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 {\u0393 \u0394} {n}\n        (P : level (context.extend n \u0393) \u2192 Prop)\n        (\u03c1 : name \u0393 \u2192 name \u0394)\n      : (ext_with P (\u03bb a _, \u03c1 a))\n      = (\u03bb a _, name.ext_with (\u03bb _x, true) (\u03bb x _, \u03c1 x) a true.intro)\n      := funext $ \u03bb a, funext $ \u03bb free, by { cases a; from rfl }\n\n    lemma ext.inj {\u0393 \u0394 n} {\u03c1 : name \u0393 \u2192 name \u0394} (inj : function.injective \u03c1)\n      : function.injective (@ext \u0393 \u0394 n \u03c1)\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 \u03bd(_) terms. -/\n    def swap {\u0393} {M N : \u2115}\n      : name (context.extend M (context.extend N \u0393))\n      \u2192 name (context.extend N (context.extend M \u0393))\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 {\u0393 \u0394} {\u03c1 : name \u0393 \u2192 name \u0394} {m n : \u2115}\n      : (ext (ext \u03c1) \u2218 swap)\n      = (swap \u2218 @ext _ _ n (@ext _ _ m \u03c1))\n      := funext $ \u03bb \u03b1,\n        match \u03b1 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 {\u0393} {m n : \u2115}\n      : (@name.swap \u0393 m n \u2218 name.extend) = (name.ext name.extend)\n      := funext $ \u03bb 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 {\u0393} {m n : \u2115}\n      : (@name.swap \u0393 m n \u2218 name.ext name.extend) = name.extend\n      := funext $ \u03bb a, by { cases a; from rfl }\n\n    /-- Swapping twice does nothing. -/\n    lemma swap_swap_identity :\n      \u2200 {\u0393} {a b : \u2115} (a : name (context.extend b (context.extend a \u0393)))\n      , name.swap (name.swap a) = a\n      | \u0393 a b (name.zero _) := rfl\n      | \u0393 a b (name.extend (name.zero _)) := rfl\n      | \u0393 a b (name.extend (name.extend _)) := rfl\n\n    /-- Swapping twice gives the identity. -/\n    lemma swap_swap :\n      \u2200 {\u0393} {a b : \u2115}\n      , (@name.swap \u0393 a b) \u2218 name.swap = id\n      | \u0393 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 {\u0393} {b} (bs : vector (name \u0393) b)\n      : name (context.extend b \u0393) \u2192 name \u0393\n    | (zero idx) := vector.nth bs idx\n    | (extend e) := e\n\n    lemma mk_apply_rename\n        {\u0393 \u0394} {b} (\u03c1 : name \u0393 \u2192 name \u0394) {bs : vector (name \u0393) b}\n      : \u03c1 \u2218 mk_apply bs = mk_apply (vector.map \u03c1 bs) \u2218 name.ext \u03c1\n      := funext $ \u03bb a,\n        by { cases a; simp only [mk_apply, ext, ext_with, vector.nth_map, function.comp] }\n\n    lemma mk_apply_ext {\u0393} {b} {bs : vector (name \u0393) b}\n      : mk_apply bs \u2218 (@extend \u0393 b) = id\n      := funext $\u03bb \u03b1, by { cases \u03b1; 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 {\u0393} {n}\n        (P : level (context.extend n \u0393) \u2192 Prop) (p : (\u00ac P level.zero))\n      : \u03a0 a, P (name.to_level a) \u2192 name \u0393\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 {\u0393} {n}\n      (P : level (context.extend n \u0393) \u2192 Prop) (p : (\u00ac P level.zero))\n      : (\u03bb a f, name.extend (drop_var P p a f)) = \u03bb a _, a\n      := funext $ \u03bb a, funext $ \u03bb 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 : \u2115} : name (context.extend n context.nil) \u2192 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 := \u27e80\u27e9\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 := \u27e8(dt.nanos.fdiv oneDayNanos) + 1\u27e9\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 \u2227 d <= m.numDays y := by decide) : TaiDateTime := \n    \u27e8oneDayNanos * ((Ymd.mk y m d hd.left hd.right).toScalarDate.day - 1)\u27e9 \n\ndef TaiDateTime.fromYmdsn \n  (y : Year) \n  (m : Month) \n  (d : Nat) \n  (s : Nat)\n  (n : Nat)\n  (hd : 1 <= d \u2227 d <= m.numDays y := by decide) : TaiDateTime := \n    \u27e8(TaiDateTime.fromYmd y m d hd).nanos + (oneSecondNanos * s) + n\u27e9 \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 : \u2200 {d1 d2 : TaiDateTime} (h : d1.nanos = d2.nanos), d1 = d2\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem TaiDateTime.val_ne_of_ne : \u2200 {d1 d2 : TaiDateTime} (h : d1 \u2260 d2), d1.nanos \u2260 d2.nanos\n| \u27e8x\u27e9, \u27e8y\u27e9, 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\u2081 d\u2082 : TaiDateTime) : (d\u2081 <= d\u2082) = (d\u2081.nanos <= d\u2082.nanos) := rfl\n@[simp] theorem TaiDateTime.lt_def (d\u2081 d\u2082 : TaiDateTime) : (d\u2081 < d\u2082) = (d\u2081.nanos < d\u2082.nanos) := rfl\n\ninstance instDecidableLETaiDateTime (d\u2081 d\u2082 : TaiDateTime) : Decidable (d\u2081 <= d\u2082) := inferInstanceAs (Decidable <| d\u2081.nanos <= d\u2082.nanos)\ninstance instDecidableLTTaiDateTime (d\u2081 d\u2082 : TaiDateTime) : Decidable (d\u2081 < d\u2082) := inferInstanceAs (Decidable <| d\u2081.nanos < d\u2082.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 \u2192 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 \u27e8y, m, d, _, _\u27e9 := dt.toYmd\n    let t : String := ToString.toString <| NaiveClockTime.mk (Fin.ofInt'' (dt.nanos % (\u2191oneDayNanos)))\n    s!\"{y}/{m.toNat}/{d}; {t}\"\n\n@[reducible]\ndef TaiDateTime.dateEq : TaiDateTime \u2192 TaiDateTime \u2192 Prop\n| n\u2081, n\u2082 => n\u2081.toScalarDate = n\u2082.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  \u27e8TaiDateTime.dateEq, TaiDateTime.dateEq.Equivalence\u27e9\n\ninstance (d\u2081 d\u2082 : TaiDateTime) : Decidable <| d\u2081.dateEq d\u2082 := inferInstance\n\ninstance {n : Nat} : OfNat TaiDateTime n where\n  ofNat := \u27e8n\u27e9\n\ninstance : HAdd TaiDateTime SignedDuration TaiDateTime where\n  hAdd da du := \u27e8da.nanos + du.val\u27e9\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 = \u27e8d.nanos + dur.val\u27e9 := rfl\ntheorem TaiDateTime.hAdd_signed_def_rev (d : TaiDateTime) (dur : SignedDuration) : dur + d = \u27e8d.nanos + dur.val\u27e9 := 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 := \u27e8da.nanos + du.val\u27e9\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 = \u27e8d.nanos + dur.val\u27e9 := rfl\n\ninstance : HSub TaiDateTime UnsignedDuration TaiDateTime where\n  hSub da du := \u27e8da.nanos - du.val\u27e9\n\ntheorem TaiDateTime.hSub_unsigned_def (d : TaiDateTime) (dur : UnsignedDuration) : d - dur = \u27e8d.nanos - dur.val\u27e9 := 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  \u27e8days + clockTime.nanos.val\u27e9\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 \u27f6 Z) (g : Y \u27f6 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 \u226b f.map_residue_field T.x)\n        (Z.residue_field_of_eq T.hy \u226b g.map_residue_field T.y)\n.\ndef triplet.Spec_residue_field_tensor_to :\n  Scheme.Spec.obj (op T.residue_field_tensor) \u27f6 pullback f g :=\npullback.lift (Scheme.Spec.map pushout.inl.op \u226b X.from_Spec_residue_field T.x)\n              (Scheme.Spec.map pushout.inr.op \u226b Y.from_Spec_residue_field T.y)\nbegin\n  have := @pushout.condition _ _ _ _ _ (Z.residue_field_of_eq T.hx \u226b f.map_residue_field T.x)\n    (Z.residue_field_of_eq T.hy \u226b g.map_residue_field T.y) _,\n  replace this := congr_arg (\u03bb f, Z.residue_field_of_eq T.hx.symm \u226b 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, \u2190 Scheme.hom.map_residue_field_from_Spec_residue_field,\n    \u2190 Scheme.Spec.map_comp_assoc, \u2190 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 \u27f6 X).1.base t,\n  y := (pullback.snd : pullback f g \u27f6 Y).1.base t,\n  z := (limit.\u03c0 _ walking_cospan.one : pullback f g \u27f6 Z).1.base t,\n  hx := by { rw [limit.\u03c0, pullback_cone.condition_one (limit.cone (cospan f g))], refl },\n  hy := by { rw [limit.\u03c0, 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 \u27f6 Scheme.residue_field _ t :=\npushout.desc\n  ((pullback.fst : pullback f g \u27f6 _).map_residue_field t)\n  ((pullback.snd : pullback f g \u27f6 _).map_residue_field t)\nbegin\n  dsimp only [triplet_of_pullback_x, triplet_of_pullback_y],\n  rw [category.assoc, category.assoc, \u2190 Scheme.hom.map_residue_field_comp,\n    \u2190 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) \u22a5\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 \u226b\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      \u2190 functor.map_comp_assoc, \u2190 op_comp, residue_field_tensor_of_pullback_to,\n      pushout.inl_desc, \u2190 Scheme.hom.map_residue_field_from_Spec_residue_field], refl },\n  { rw [category.assoc, triplet.Spec_residue_field_tensor_to, pullback.lift_snd,\n      \u2190 functor.map_comp_assoc, \u2190 op_comp, residue_field_tensor_of_pullback_to,\n      pushout.inr_desc, \u2190 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 \u226b\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\u2081 T\u2082 : triplet f g}\n  (hx : T\u2081.x = T\u2082.x) (hy : T\u2081.y = T\u2082.y) : T\u2081 = T\u2082 :=\nbegin\n  cases T\u2081, cases T\u2082, dsimp only at hx hy, substs hx hy T\u2081_hx T\u2082_hx\nend\n\nlemma triplet_ext_iff {T\u2081 T\u2082 : triplet f g} :\n  T\u2081 = T\u2082 \u2194 T\u2081.x = T\u2082.x \u2227 T\u2081.y = T\u2082.y :=\nbegin\n  split, { rintro rfl, exact \u27e8rfl, rfl\u27e9 }, { intro h, exact triplet_ext h.1 h.2 }\nend\n\ndef triplet.residue_field_tensor_of_eq {T\u2081 T\u2082 : triplet f g} (e : T\u2081 = T\u2082) :\n  T\u2081.residue_field_tensor \u27f6 T\u2082.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\u2081 T\u2082 : triplet f g} (e : T\u2081 = T\u2082) :\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\u2081 T\u2082 T\u2083 : triplet f g} (e : T\u2081 = T\u2082) (e' : T\u2082 = T\u2083) :\n  triplet.residue_field_tensor_of_eq e \u226b 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) = \ud835\udfd9 _ :=\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 [\u2190 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 [\u2190 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) \u226b\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 \u2190 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 \u226b\n    residue_field_tensor_of_pullback_to _ \u226b\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 \u226b 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 [\u2190 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, \u2190 category.assoc, op_comp, functor.map_comp,\n      \u2190 triplet.eq_from_Spec_residue_field_aux],\n    refl },\n  { have : T.Spec_residue_field_tensor_to \u226b 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 [\u2190 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, \u2190 category.assoc, op_comp, functor.map_comp,\n      \u2190 triplet.eq_from_Spec_residue_field_aux],\n    refl },\nend\n.\nlemma carrier_equiv_eq\n  {T\u2081 T\u2082 : \u03a3 T : triplet f g, prime_spectrum T.residue_field_tensor} :\n  T\u2081 = T\u2082 \u2194 \u2203 e : T\u2081.1 = T\u2082.1, prime_spectrum.comap\n    (triplet.residue_field_tensor_of_eq e.symm) T\u2081.2 = T\u2082.2 :=\nbegin\n  split,\n  { rintro rfl, refine \u27e8rfl, _\u27e9, rw triplet.residue_field_tensor_of_eq_id, ext, refl },\n  { cases T\u2081, cases T\u2082, dsimp, rintro \u27e8rfl, rfl\u27e9, 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 \u2243 \u03a3 T : triplet f g, prime_spectrum T.residue_field_tensor :=\n{ to_fun := \u03bb t, \u27e8_, residue_field_tensor_prime_ideal t\u27e9,\n  inv_fun := \u03bb 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 \u27e8T, p\u27e9,\n    apply carrier_equiv_eq.mpr \u27e8_, _\u27e9; dsimp,\n    { ext; dsimp only [triplet_of_pullback_x, triplet_of_pullback_y],\n      { rw [\u2190 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 [\u2190 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) \u22a5 = \u22a5 :=\n        subsingleton.elim _ _,\n      rw [\u2190 this, \u2190 prime_spectrum.comap_comp_apply, \u2190 prime_spectrum.comap_comp_apply],\n      convert_to\n        (Scheme.Spec.map (triplet.residue_field_tensor_of_eq _ \u226b\n          residue_field_tensor_of_pullback_to _ \u226b\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 \u27e8v, \u27e8hv\u27e9\u27e9 := basis.exists_basis K M,\n  obtain \u27e8w, \u27e8hw\u27e9\u27e9 := basis.exists_basis K N,\n  haveI := hv.index_nonempty,\n  haveI := hw.index_nonempty,\n  exact \u27e8\u27e8_, _, (hv.tensor_product hw).ne_zero (classical.arbitrary _)\u27e9\u27e9\nend\n\nlemma CommRing.pushout_nontrivial {A B C : CommRing.{u}} (hA : is_field A) (f : A \u27f6 B) (g : A \u27f6 C)\n  [nontrivial B] [nontrivial C] : nontrivial.{u} (pushout f g : _) :=\nbegin\n  delta pushout,\n  apply_with (@@equiv.nontrivial (colimit.iso_colimit_cocone \u27e8_, CommRing.pushout_cocone_is_colimit\n    f g\u27e9).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\u27e8\u27e8_, (ideal.exists_maximal R).some_spec.is_prime\u27e9\u27e9\n\nvariables {f g}\n\nlemma triplet.exists_preimage (T : triplet f g) :\n  \u2203 t : (pullback f g).carrier,\n    (pullback.fst : _ \u27f6 X).1.base t = T.x \u2227 (pullback.snd : _ \u27f6 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 \u27e8t, ht\u27e9 := (carrier_equiv f g).surjective \u27e8T, classical.arbitrary _\u27e9,\n  rw (show T = ((carrier_equiv f g) t).1, by rw ht),\n  exact \u27e8t, rfl, rfl\u27e9,\nend\n\nlemma range_fst :\n  set.range (pullback.fst : pullback f g \u27f6 X).1.base = f.1.base \u207b\u00b9' set.range g.1.base :=\nbegin\n  apply le_antisymm,\n  { rintro _ \u27e8y, rfl\u27e9,\n    refine \u27e8(pullback.snd : pullback f g \u27f6 Y).1.base y, _\u27e9,\n    rw [\u2190 Scheme.comp_val_base_apply, \u2190 Scheme.comp_val_base_apply, pullback.condition] },\n  { rintro x \u27e8y, hxy\u27e9,\n    obtain \u27e8t, rfl : _ = x, -\u27e9 := triplet.exists_preimage \u27e8x, y, _, hxy.symm, rfl\u27e9,\n    exact \u27e8_, rfl\u27e9 }\nend\n\nlemma range_snd :\n  set.range (pullback.snd : pullback f g \u27f6 Y).1.base = g.1.base \u207b\u00b9' set.range f.1.base :=\nbegin\n  apply le_antisymm,\n  { rintro _ \u27e8y, rfl\u27e9,\n    refine \u27e8(pullback.fst : pullback f g \u27f6 X).1.base y, _\u27e9,\n    rw [\u2190 Scheme.comp_val_base_apply, \u2190 Scheme.comp_val_base_apply, pullback.condition] },\n  { rintro x \u27e8y, hxy\u27e9,\n    obtain \u27e8t, -, rfl : _ = x\u27e9 := triplet.exists_preimage \u27e8y, x, _, hxy, rfl\u27e9,\n    exact \u27e8_, rfl\u27e9 }\nend\n\nlemma range_to_base :\n    set.range (pullback.fst \u226b f : pullback f g \u27f6 Z).1.base =\n      set.range f.1.base \u2229 set.range g.1.base :=\nbegin\n  apply le_antisymm,\n  { rintro _ \u27e8x, rfl\u27e9,\n    refine \u27e8\u27e8_, rfl\u27e9, _\u27e9,\n    rw pullback.condition,\n    exact \u27e8_, rfl\u27e9 },\n  { rintro z \u27e8\u27e8x, hx\u27e9, \u27e8y, hy\u27e9\u27e9,\n    obtain \u27e8t, ht : _ = x, -\u27e9 := triplet.exists_preimage \u27e8x, y, z, hx, hy\u27e9,\n    substs hx ht,\n    exact \u27e8_, rfl\u27e9 }\nend\n\nlemma range_map {X Y S X' Y' S' : Scheme} (f : X \u27f6 S) (g : Y \u27f6 S) (f' : X' \u27f6 S')\n  (g' : Y' \u27f6 S') (i\u2081 : X \u27f6 X') (i\u2082 : Y \u27f6 Y') (i\u2083 : S \u27f6 S') (e\u2081 : f \u226b i\u2083 = i\u2081 \u226b f')\n  (e\u2082 : g \u226b i\u2083 = i\u2082 \u226b g') [mono i\u2083] :\n  set.range (pullback.map f g f' g' i\u2081 i\u2082 i\u2083 e\u2081 e\u2082).1.base = \n  (pullback.fst : pullback f' g' \u27f6 X').val.base \u207b\u00b9' set.range i\u2081.val.base \u2229\n  (pullback.snd : pullback f' g' \u27f6 Y').val.base \u207b\u00b9' set.range i\u2082.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 \u22d9 forget Top).map\n    (pullback_fst_fst_iso f g f' g' i\u2081 i\u2082 i\u2083 e\u2081 e\u2082).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  (\u2203 (V1 V2 : set G), \u2200 (v1 v2 : G), (v1,v2) \u2208 G \u2192 (v1 \u2208 V1 \u2227 v2 \u2208 V2) \u2228 (v1 \u2208 V2 \u2227 v2 \u2208 V1)) \u2194 \n  (\u2203 (V1 V2 : set G), \u2200 (v1 v2 : G), (v1,v2) \u2208 G \u2192 (v1 \u2208 V1 \u2227 v2 \u2208 V2) \u2228 (v1 \u2208 V2 \u2227 v2 \u2208 V1)) :=\nbegin\n  split,\n  assume h1 : \u2203 (V1 V2 : set G), \u2200 (v1 v2 : G), (v1,v2) \u2208 G \u2192 (v1 \u2208 V1 \u2227 v2 \u2208 V2) \u2228 (v1 \u2208 V2 \u2227 v2 \u2208 V1),\n  exact h1,\n  assume h2 : \u2203 (V1 V2 : set G), \u2200 (v1 v2 : G), (v1,v2) \u2208 G \u2192 (v1 \u2208 V1 \u2227 v2 \u2208 V2) \u2228 (v1 \u2208 V2 \u2227 v2 \u2208 V1),\n  exact h2,\nend\n\n--OUTPUT 2\ntheorem bipartite_iff_two_colorable {G : Type*} [graph G] : bipartite G \u2194 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 \u2192 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 B \u2192 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, G.adj u v \u2192 u \u2208 A \u2227 v \u2208 B \u2228 u \u2208 B \u2227 v \u2208 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, G.adj u v \u2192 u \u2208 A \u2227 v \u2208 B \u2228 u \u2208 B \u2227 v \u2208 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, G.adj u v \u2192 u \u2208 A \u2227 v \u2208 B \u2228 u \u2208 B \u2227 v \u2208 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, G.adj u v \u2192 u \u2208 A \u2227 v \u2208 B \u2228 u \u2208 B \u2227 v \u2208 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, G.adj u v \u2192 u \u2208 A \u2227 v \u2208 B \u2228 u \u2208 B \u2227 v \u2208 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac 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 : \u2203 A B : set G.vertex, \u2200 v : G.vertex, v \u2208 A \u2228 v \u2208 B \u2227 \u2200 u v : G.vertex, u \u2208 A \u2227 v \u2208 A \u2192 \u00ac G.adj u v \u2227 \u2200 u v : G.vertex, u \u2208 B \u2227 v \u2208 B \u2192 \u00ac G.adj u v \u2227 \u2200 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 \u2194 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 \u2192 \u2200 (red : set G) (blue : set G), (\u2200 a : G, a \u2208 red \u2228 a \u2208 blue) \u2227 (\u2200 a b : G, a \u2208 red \u2227 b \u2208 red \u2192 \u00ac (a,b) \u2208 G.edges) \u2227 (\u2200 a b : G, a \u2208 blue \u2227 b \u2208 blue \u2192 \u00ac (a,b) \u2208 G.edges) \u2192 bipartite G, from by {\n    assume h2colorable : two_colorable G,\n    assume (red : set G) (blue : set G),\n    assume hredblue : (\u2200 a : G, a \u2208 red \u2228 a \u2208 blue) \u2227 (\u2200 a b : G, a \u2208 red \u2227 b \u2208 red \u2192 \u00ac (a,b) \u2208 G.edges) \u2227 (\u2200 a b : G, a \u2208 blue \u2227 b \u2208 blue \u2192 \u00ac (a,b) \u2208 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 : \u2200 a : G, a \u2208 red \u2192 a \u2208 G.vertices, from by {\n      assume a : G,\n      assume hreda : a \u2208 red,\n      show a \u2208 G.vertices, from by {\n        have hredbluea : a \u2208 red \u2228 a \u2208 blue, from by {apply hredblue.left,exact a},\n        cases hredbluea,\n        exact hreda,\n        exact hredbluea,\n      },\n    },\n    have hblue : \u2200 a : G, a \u2208 blue \u2192 a \u2208 G.vertices, from by {\n      assume a : G,\n      assume hbluea : a \u2208 blue,\n      show a \u2208 G.vertices, from by {\n        have hredbluea : a \u2208 red \u2228 a \u2208 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 : \u2200 a b : G, a \u2208 red \u2227 b \u2208 red \u2192 \u00ac (a,b) \u2208 G.edges, from by {\n      assume a b : G,\n      assume hredred : a \u2208 red \u2227 b \u2208 red,\n      show \u00ac (a,b) \u2208 G.edges, from by {\n        apply hredblue.right.left,\n        exact hredred,\n      },\n    },\n    have hblueblue : \u2200 a b : G, a \u2208 blue \u2227 b \u2208 blue \u2192 \u00ac (a,b) \u2208 G.edges, from by {\n      assume a b : G,\n      assume hblueblue : a \u2208 blue \u2227 b \u2208 blue,\n      show \u00ac (a,b) \u2208 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 : \u2200 a b : G, (a,b) \u2208 G.edges \u2192 a \u2208 red \u2227 b \u2208 blue \u2228 a \u2208 blue \u2227 b \u2208 red, from by {\n      assume a b : G,\n      assume hredblueedges : (a,b) \u2208 G.edges,\n      show a \u2208 red \u2227 b \u2208 blue \u2228 a \u2208 blue \u2227 b \u2208 red, from by {\n        have hredbluea : a \u2208 red \u2228 a \u2208 blue, from by {apply hredblue.left,exact a},\n        have hredblueb : b \u2208 red \u2228 b \u2208 blue, from by {apply hredblue.left,exact b},\n        cases hredbluea,\n        cases hredblueb,\n        have hredred : a \u2208 red \u2227 b \u2208 red, from by {split,exact hredbluea,exact hredblueb},\n        have hredrededges : \u00ac (a,b) \u2208 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 \u2208 blue \u2227 b \u2208 blue, from by {split,exact hredbluea,exact hredblueb},\n        have hblueblueedges : \u00ac (a,b) \u2208 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 \u2192 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 : \u2200 a : G, a \u2208 hbipartite.left \u2228 a \u2208 hbipartite.right, from by {\n      assume a : G,\n      show a \u2208 hbipartite.left \u2228 a \u2208 hbipartite.right, from by {\n        have hredblueedges : \u2200 a b : G, (a,b) \u2208 G.edges \u2192 a \u2208 hbipartite.left \u2227 b \u2208 hbipartite.right \u2228 a \u2208 hbipartite.right \u2227 b \u2208 hbipartite.left, from by {\n          assume a b : G,\n          assume hredblueedges : (a,b) \u2208 G.edges,\n          show a \u2208 hbipartite.left \u2227 b \u2208 hbipartite.right \u2228 a \u2208 hbipartite.right \u2227 b \u2208 hbipartite.left, from by {\n            apply hbipartite.right.right,\n            exact hredblueedges,\n          },\n        },\n        have hredbluea : a \u2208 hbipartite.left \u2228 a \u2208 hbipartite.right, from by {\n          cases a,\n          have hredblueedges : (a,a) \u2208 G.edges, from by {apply G.self_loop,exact a},\n          have hredbluea : a \u2208 hbipartite.left \u2227 a \u2208 hbipartite.right \u2228 a \u2208 hbipartite.right \u2227 a \u2208 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 : \u2200 a b : G, a \u2208 hbipartite.left \u2227 b \u2208 hbipartite.left \u2192 \u00ac (a,b) \u2208 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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\u00f3n relacionP es inversa por la derecha de la funci\u00f3n cociente\n-- Jos\u00e9 A. Alonso Jim\u00e9nez\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 : \u2200 X \u2208 Bloques, (X : set A).nonempty)\n(Hrecubren  : \u2200 a, \u2203 X \u2208 Bloques, a \u2208 X)\n(Hdisjuntos : \u2200 X Y \u2208 Bloques, (X \u2229 Y : set A).nonempty \u2192 X = Y)\n\nnamespace particion\n\nvariable  {A : Type}\nvariables {X Y : set A}\nvariable  {P : particion A}\nvariable  (R : A \u2192 A \u2192 Prop)\n\ndef clase (a : A) :=\n  {b : A | R b a}\n\ndef clases : (A \u2192 A \u2192 Prop) \u2192 set (set A) :=\n  \u03bb R, {B : set A | \u2203 x : A, B = clase R x}\n\nlemma pertenece_clase_syss\n  {a b : A}\n  : b \u2208 clase R a \u2194 R b a :=\nby refl\n\nlemma clases_no_vacias\n  (hR: equivalence R)\n  : \u2200 (X : set A), X \u2208 clases R \u2192 X.nonempty :=\nbegin\n  rintros _ \u27e8a, rfl\u27e9,\n  use a,\n  rw pertenece_clase_syss,\n  apply hR.1,\nend\n\nlemma clases_recubren\n  (hR: equivalence R)\n  : \u2200 a, \u2203 X \u2208 clases R, a \u2208 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 \u2192 A \u2192 Prop}\n  (hR: equivalence R)\n  {a b : A}\n  : a \u2208 clase R b \u2192 clase R a \u2286 clase R b :=\n\u03bb hab z hza, hR.2.2 hza hab\n\nlemma clases_iguales_si_pertenece\n  {R : A \u2192 A \u2192 Prop}\n  (hR: equivalence R)\n  {a b : A}\n  : a \u2208 clase R b \u2192 clase R a = clase R b :=\n\u03bb 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  : \u2200 X Y \u2208 clases R, (X \u2229 Y : set A).nonempty \u2192 X = Y :=\nbegin\n  rintros X \u27e8a, rfl\u27e9 Y \u27e8b, rfl\u27e9 \u27e8c, hca, hcb\u27e9,\n  exact clases_iguales_si_pertenece hR (hR.2.2 (hR.2.1 hca) hcb),\nend\n\ndef cociente : {R : A \u2192 A \u2192 Prop // equivalence R} \u2192 particion A :=\n  \u03bb R, { Bloques    := {B : set A | \u2203 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) \u2192 (A \u2192 A \u2192 Prop) :=\n  \u03bb P a b, \u2200 X \u2208 Bloques P, a \u2208 X \u2192 b \u2208 X\n\nlemma reflexiva\n  (P : particion A)\n  : reflexive (relacion P) :=\n\u03bb a X hXC haX, haX\n\nlemma iguales_si_comun\n  (hX : X \u2208 Bloques P)\n  (hY : Y \u2208 Bloques P)\n  {a : A}\n  (haX : a \u2208 X)\n  (haY : a \u2208 Y)\n  : X = Y :=\nHdisjuntos P X hX Y hY \u27e8a, haX, haY\u27e9\n\nlemma pertenece_si_pertenece\n  (hX : X \u2208 Bloques P)\n  (hY : Y \u2208 Bloques P)\n  {a b : A}\n  (haX : a \u2208 X)\n  (haY : a \u2208 Y)\n  (hbX : b \u2208 X)\n  : b \u2208 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 \u27e8Y, hY, haY\u27e9 := 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\u03bb a b c hab hbc X hX haX, hbc X hX (hab X hX haX)\n\ndef relacionP : particion A \u2192 {R : A \u2192 A \u2192 Prop // equivalence R} :=\n  \u03bb P, \u27e8\u03bb a b, \u2200 X \u2208 Bloques P, a \u2208 X \u2192 b \u2208 X,\n        \u27e8reflexiva P, simetrica P, transitiva P\u27e9\u27e9\n\n-- 1\u00aa demostraci\u00f3n\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 \u27e8X, hX, haX\u27e9,\n    convert hX,\n    ext b,\n    rw pertenece_clase_syss,\n    split,\n    { intro hba,\n      rcases Hrecubren P b with \u27e8Y, hY, hbY\u27e9,\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 \u27e8a, ha\u27e9,\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 \u27e8Y, hY, hbY\u27e9,\n      specialize hba Y hY hbY,\n      exact pertenece_si_pertenece hY hX hba ha hbY, }}\nend\n\n-- 2\u00aa demostraci\u00f3n\nlemma inversa_dcha :\n  function.right_inverse relacionP (@cociente A) :=\nbegin\n  intro P,\n  ext X,\n  show (\u2203 (a : A), X = clase _ a) \u2194 X \u2208 Bloques P,\n  split,\n  { rintro \u27e8a, rfl\u27e9,\n    obtain \u27e8X, hX, haX\u27e9 := Hrecubren P a,\n    convert hX,\n    ext b,\n    rw pertenece_clase_syss,\n    split,\n    { intro hba,\n      obtain \u27e8Y, hY, hbY\u27e9 := 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 \u27e8a, ha\u27e9,\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 \u27e8Y, hY, hbY\u27e9 := 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 \u2115` 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 \u2115) : option \u2115 :=\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 {\u03b1 : Type} {\u03b2 : Type} :\n  option \u03b1 \u2192 (\u03b1 \u2192 option \u03b2) \u2192 option \u03b2\n| option.none     _ := option.none\n| (option.some a) f := f a\n\ndef sum_2_5_7\u2082 (ns : list \u2115) : option \u2115 :=\nbind_opt (list.nth ns 1)\n  (\u03bbn2, bind_opt (list.nth ns 4)\n     (\u03bbn5, bind_opt (list.nth ns 6)\n        (\u03bbn7, 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\u2083 (ns : list \u2115) : option \u2115 :=\nbind (list.nth ns 1)\n  (\u03bbn2, bind (list.nth ns 4)\n     (\u03bbn5, bind (list.nth ns 6)\n        (\u03bbn7, pure (n2 + n5 + n7))))\n\n/-! Syntactic sugar:\n\n    `ma >>= f` := `bind ma f` -/\n\n#check (>>=)\n\ndef sum_2_5_7\u2084 (ns : list \u2115) : option \u2115 :=\nlist.nth ns 1 >>=\n  \u03bbn2, list.nth ns 4 >>=\n    \u03bbn5, list.nth ns 6 >>=\n      \u03bbn7, pure (n2 + n5 + n7)\n\n/-! Syntactic sugar:\n\n    `do a \u2190 ma, t` := `ma >>= (\u03bba, t)`\n    `do ma, t`     := `ma >>= (\u03bb_, t)` -/\n\ndef sum_2_5_7\u2085 (ns : list \u2115) : option \u2115 :=\ndo n2 \u2190 list.nth ns 1,\n  do n5 \u2190 list.nth ns 4,\n    do n7 \u2190 list.nth ns 6,\n      pure (n2 + n5 + n7)\n\n/-! The `do`s can be combined: -/\n\ndef sum_2_5_7\u2086 (ns : list \u2115) : option \u2115 :=\ndo\n  n2 \u2190 list.nth ns 1,\n  n5 \u2190 list.nth ns 4,\n  n7 \u2190 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 `\u03b1` (i.e., `m \u03b1`) equipped with two distinguished operations:\n\n    `pure {\u03b1 : Type} : \u03b1 \u2192 m \u03b1`\n    `bind {\u03b1 \u03b2 : Type} : m \u03b1 \u2192 (\u03b1 \u2192 m \u03b2) \u2192 m \u03b2`\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 \u03b2` monad, not a `m \u03b1` monad).\n\nThere is no general way to extract the data from the monad, i.e., to obtain an\n`\u03b1` from an `m \u03b1`.\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 \u03b1`       | no effect\n`option \u03b1`   | simple exceptions\n`\u03c3 \u2192 \u03b1 \u00d7 \u03c3`  | threading through a state of type `\u03c3`\n`set \u03b1`      | nondeterministic computation returning `\u03b1` values\n`t \u2192 \u03b1`      | reading elements of type `t` (e.g., a configuration)\n`\u2115 \u00d7 \u03b1`      | adjoining running time (e.g., to model algorithmic complexity)\n`string \u00d7 \u03b1` | adjoining text output (e.g., for logging)\n`prob \u03b1`     | probability (e.g., using random number generators)\n`io \u03b1`       | interaction with the operating system\n`tactic \u03b1`   | interaction with the proof assistant\n\nAll of the above are type constructors `m` are parameterized by a type `\u03b1`.\n\nSome effects can be combined (e.g., `option (t \u2192 \u03b1)`).\n\nSome effects are not executable (e.g., `set \u03b1`, `prob \u03b1`). 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 {\u03b1 \u03b2 : Type} : (\u03b1 \u2192 m \u03b2) \u2192 list \u03b1 \u2192 m (list \u03b2)`, 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' \u2190 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 \u2190 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 \u2190 do {\n        a \u2190 x,\n        f a },\n      g b\n  =\n    do\n      a \u2190 x,\n      b \u2190 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\u2014or here, by a type constructor `m : Type \u2192 Type`. -/\n\n@[class] structure lawful_monad (m : Type \u2192 Type)\n  extends has_bind m, has_pure m : Type 1 :=\n(pure_bind {\u03b1 \u03b2 : Type} (a : \u03b1) (f : \u03b1 \u2192 m \u03b2) :\n   (pure a >>= f) = f a)\n(bind_pure {\u03b1 : Type} (ma : m \u03b1) :\n   (ma >>= pure) = ma)\n(bind_assoc {\u03b1 \u03b2 \u03b3 : Type} (f : \u03b1 \u2192 m \u03b2) (g : \u03b2 \u2192 m \u03b3)\n     (ma : m \u03b1) :\n   ((ma >>= f) >>= g) = (ma >>= (\u03bba, 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 {\u03b1 : Type} : \u03b1 \u2192 id \u03b1 :=\nid\n\ndef id.bind {\u03b1 \u03b2 : Type} : id \u03b1 \u2192 (\u03b1 \u2192 id \u03b2) \u2192 id \u03b2\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 \u03b1 \u03b2 a f,\n      refl\n    end,\n  bind_pure  :=\n    begin\n      intros \u03b1 m,\n      refl\n    end,\n  bind_assoc :=\n    begin\n      intros \u03b1 \u03b2 \u03b3 f g m,\n      refl\n    end\n}\n\n\n/-! ## Exceptions -/\n\ndef option.pure {\u03b1 : Type} : \u03b1 \u2192 option \u03b1 :=\noption.some\n\ndef option.bind {\u03b1 \u03b2 : Type} :\n  option \u03b1 \u2192 (\u03b1 \u2192 option \u03b2) \u2192 option \u03b2\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 \u03b1 \u03b2 a f,\n      refl\n    end,\n  bind_pure  :=\n    begin\n      intros \u03b1 m,\n      cases m,\n      { refl },\n      { refl }\n    end,\n  bind_assoc :=\n    begin\n      intros \u03b1 \u03b2 \u03b3 f g m,\n      cases m,\n      { refl },\n      { refl }\n    end }\n\ndef option.throw {\u03b1 : Type} : option \u03b1 :=\noption.none\n\ndef option.catch {\u03b1 : Type} :\n  option \u03b1 \u2192 option \u03b1 \u2192 option \u03b1\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 (\u03c3 \u03b1 : Type) :=\n\u03c3 \u2192 \u03b1 \u00d7 \u03c3\n\ndef action.read {\u03c3 : Type} : action \u03c3 \u03c3\n| s := (s, s)\n\ndef action.write {\u03c3 : Type} (s : \u03c3) : action \u03c3 unit\n| _ := ((), s)\n\ndef action.pure {\u03c3 \u03b1 : Type} (a : \u03b1) : action \u03c3 \u03b1\n| s := (a, s)\n\ndef action.bind {\u03c3 : Type} {\u03b1 \u03b2 : Type} (ma : action \u03c3 \u03b1)\n    (f : \u03b1 \u2192 action \u03c3 \u03b2) :\n  action \u03c3 \u03b2\n| s :=\n  match ma s with\n  | (a, s') := f a s'\n  end\n\n@[instance] def action.lawful_monad {\u03c3 : Type} :\n  lawful_monad (action \u03c3) :=\n{ pure       := @action.pure \u03c3,\n  bind       := @action.bind \u03c3,\n  pure_bind  :=\n    begin\n      intros \u03b1 \u03b2 a f,\n      apply funext,\n      intro s,\n      refl\n    end,\n  bind_pure  :=\n    begin\n      intros \u03b1 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 \u03b1 \u03b2 \u03b3 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 \u2115 \u2192 action \u2115 (list \u2115)\n| []        := pure []\n| (n :: ns) :=\n  do\n    prev \u2190 action.read,\n    if n < prev then\n      diff_list ns\n    else\n      do\n        action.write n,\n        ns' \u2190 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 {\u03b1 : Type} : \u03b1 \u2192 set \u03b1\n| a := {a}\n\ndef set.bind {\u03b1 \u03b2 : Type} : set \u03b1 \u2192 (\u03b1 \u2192 set \u03b2) \u2192 set \u03b2\n| A f := {b | \u2203a, a \u2208 A \u2227 b \u2208 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 \u03b1 \u03b2 a f,\n      simp [set.pure, set.bind]\n    end,\n  bind_pure  :=\n    begin\n      intros \u03b1 m,\n      simp [set.pure, set.bind]\n    end,\n  bind_assoc :=\n    begin\n      intros \u03b1 \u03b2 \u03b3 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 `\u2227`, `\u2228`, `\u2194`, and\n`\u2203` in hypotheses and introduction of `\u2227`, `\u2194`, and `\u2203` 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 \u2192 Type} [lawful_monad m] {\u03b1 \u03b2 : Type}\n    (f : \u03b1 \u2192 m \u03b2) :\n  list \u03b1 \u2192 m (list \u03b2)\n| []        := pure []\n| (a :: as) :=\n  do\n    b \u2190 f a,\n    bs \u2190 mmap as,\n    pure (b :: bs)\n\nlemma mmap_append {m : Type \u2192 Type} [lawful_monad m]\n    {\u03b1 \u03b2 : Type} (f : \u03b1 \u2192 m \u03b2) :\n  \u2200as as' : list \u03b1, mmap f (as ++ as') =\n    do\n      bs \u2190 mmap f as,\n      bs' \u2190 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 {\u03b1 : Type} (xss : list (list \u03b1)) (n : \u2115) :\n  option (list \u03b1) :=\nmmap (\u03bbxs, 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, Ya\u00ebl 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 : \u2115 \u2192 \u03b1`, this new sequence will be `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 \u2294 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 \u2294 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 `\u2115`.\nRelated to the TODO in the module docstring of `order.partial_sups`.\n-/\n\nvariables {\u03b1 \u03b2 : Type*}\n\nsection generalized_boolean_algebra\nvariables [generalized_boolean_algebra \u03b1]\n\n/-- If `f : \u2115 \u2192 \u03b1` 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 : \u2115 \u2192 \u03b1) : \u2115 \u2192 \u03b1\n| 0       := f 0\n| (n + 1) := f (n + 1) \\ (partial_sups f n)\n\n@[simp] lemma disjointed_zero (f : \u2115 \u2192 \u03b1) : disjointed f 0 = f 0 := rfl\n\nlemma disjointed_succ (f : \u2115 \u2192 \u03b1) (n : \u2115) :\n  disjointed f (n + 1) = f (n + 1) \\ (partial_sups f n) :=\nrfl\n\nlemma disjointed_le_id : disjointed \u2264 (id : (\u2115 \u2192 \u03b1) \u2192 \u2115 \u2192 \u03b1) :=\nbegin\n  rintro f n,\n  cases n,\n  { refl },\n  { exact sdiff_le }\nend\n\nlemma disjointed_le (f : \u2115 \u2192 \u03b1) : disjointed f \u2264 f := disjointed_le_id f\n\nlemma disjoint_disjointed (f : \u2115 \u2192 \u03b1) : pairwise (disjoint on disjointed f) :=\nbegin\n  refine (symmetric.pairwise_on disjoint.symm _).2 (\u03bb 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 : \u2115 \u2192 \u03b1} {p : \u03b1 \u2192 Sort*} (hdiff : \u2200 \u2983t i\u2984, p t \u2192 p (t \\ f i)) :\n  \u2200 \u2983n\u2984, p (f n) \u2192 p (disjointed f n)\n| 0       := id\n| (n + 1) := \u03bb h,\n  begin\n    suffices H : \u2200 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, \u2190sdiff_sdiff_left],\n    exact hdiff ih,\n  end\n\n@[simp] lemma disjointed_rec_zero {f : \u2115 \u2192 \u03b1} {p : \u03b1 \u2192 Sort*} (hdiff : \u2200 \u2983t i\u2984, p t \u2192 p (t \\ f i))\n  (h\u2080 : p (f 0)) :\n  disjointed_rec hdiff h\u2080 = h\u2080 := rfl\n\n-- TODO: Find a useful statement of `disjointed_rec_succ`.\n\nlemma monotone.disjointed_eq {f : \u2115 \u2192 \u03b1} (hf : monotone f) (n : \u2115) :\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 : \u2115 \u2192 \u03b1) :\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 : \u2115 \u2192 \u03b1} (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 [\u2190partial_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 : \u2200 m \u2264 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, \u2190disjoint_iff, \u2190disjoint_iff],\n  exact \u27e8ih (nat.le_of_succ_le hm), hdisj (nat.lt_succ_of_le hm).ne\u27e9,\nend\n\nend generalized_boolean_algebra\n\nsection complete_boolean_algebra\nvariables [complete_boolean_algebra \u03b1]\n\nlemma supr_disjointed (f : \u2115 \u2192 \u03b1) : (\u2a06 n, disjointed f n) = (\u2a06 n, f n) :=\nsupr_eq_supr_of_partial_sups_eq_partial_sups (partial_sups_disjointed f)\n\nlemma disjointed_eq_inf_compl (f : \u2115 \u2192 \u03b1) (n : \u2115) :\n  disjointed f n = f n \u2293 (\u2a05 i < n, (f i)\u1d9c) :=\nbegin\n  cases n,\n  { rw [disjointed_zero, eq_comm, inf_eq_left],\n    simp_rw le_infi_iff,\n    exact \u03bb 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 : \u2115 \u2192 set \u03b1) (n : \u2115) : disjointed f n \u2286 f n :=\ndisjointed_le f n\n\nlemma Union_disjointed {f : \u2115 \u2192 set \u03b1} : (\u22c3 n, disjointed f n) = (\u22c3 n, f n) :=\nsupr_disjointed f\n\nlemma disjointed_eq_inter_compl (f : \u2115 \u2192 set \u03b1) (n : \u2115) :\n  disjointed f n = f n \u2229 (\u22c2 i < n, (f i)\u1d9c) :=\ndisjointed_eq_inf_compl f n\n\nlemma preimage_find_eq_disjointed (s : \u2115 \u2192 set \u03b1) (H : \u2200 x, \u2203 n, x \u2208 s n)\n  [\u2200 x n, decidable (x \u2208 s n)] (n : \u2115) :\n  (\u03bb x, nat.find (H x)) \u207b\u00b9' {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 `\u207b\u00b9`\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 `\u207b\u00b9`,\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) : \u2191(to_subalgebra S) = \u2191S :=\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) : \u2191(to_subfield S) = \u2191S :=\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) => \u21a5(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 \u2208 \u2191S\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 : \u2200 (x : K), coe_fn (algebra_map K L) x \u2208 s) (ho : 1 \u2208 s) (hm : \u2200 {a b : L}, a \u2208 s \u2192 b \u2208 s \u2192 a * b \u2208 s) (hz : 0 \u2208 s) (ha : \u2200 {a b : L}, a \u2208 s \u2192 b \u2208 s \u2192 a + b \u2208 s) (hn : \u2200 {x : L}, x \u2208 s \u2192 -x \u2208 s) (hi : \u2200 (x : L), x \u2208 s \u2192 x\u207b\u00b9 \u2208 s) (x : L) : x \u2208 mk s ho hm hz ha hK hn hi \u2194 x \u2208 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 \u2208 \u2191S \u2194 x \u2208 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 \u2208 to_subalgebra s \u2194 x \u2208 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 \u2208 to_subfield s \u2194 x \u2208 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 : \u2191s = \u2191t) : 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 \u2194 \u2191s = \u2191t :=\n  { mp := fun (h : s = t) => h \u25b8 rfl, mpr := fun (h : \u2191s = \u2191t) => 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 : \u2200 (x : L), x \u2208 S \u2194 x \u2208 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 \u2208 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 \u2208 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 \u2208 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 \u2208 S \u2192 y \u2208 S \u2192 x * y \u2208 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 \u2208 S \u2192 \u2200 {x : K}, x \u2022 y \u2208 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 \u2208 S \u2192 y \u2208 S \u2192 x + y \u2208 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 \u2208 S) (hy : y \u2208 S) : x - y \u2208 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 \u2208 S \u2192 -x \u2208 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 \u2208 S \u2192 x\u207b\u00b9 \u2208 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 \u2208 S) (hy : y \u2208 S) : x / y \u2208 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} : (\u2200 (x : L), x \u2208 l \u2192 x \u2208 S) \u2192 list.prod l \u2208 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} : (\u2200 (x : L), x \u2208 l \u2192 x \u2208 S) \u2192 list.sum l \u2208 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) : (\u2200 (a : L), a \u2208 m \u2192 a \u2208 S) \u2192 multiset.prod m \u2208 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) : (\u2200 (a : L), a \u2208 m \u2192 a \u2208 S) \u2192 multiset.sum m \u2208 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) {\u03b9 : Type u_3} {t : finset \u03b9} {f : \u03b9 \u2192 L} (h : \u2200 (c : \u03b9), c \u2208 t \u2192 f c \u2208 S) : (finset.prod t fun (i : \u03b9) => f i) \u2208 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) {\u03b9 : Type u_3} {t : finset \u03b9} {f : \u03b9 \u2192 L} (h : \u2200 (c : \u03b9), c \u2208 t \u2192 f c \u2208 S) : (finset.sum t fun (i : \u03b9) => f i) \u2208 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 \u2208 S) (n : \u2124) : x ^ n \u2208 S :=\n  int.cases_on n (fun (n : \u2115) => is_submonoid.pow_mem hx)\n    fun (n : \u2115) => 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 \u2208 S) (n : \u2124) : n \u2022\u2124 x \u2208 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 : \u2124) : \u2191n \u2208 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 : \u2200 (x : L), x \u2208 S \u2192 x\u207b\u00b9 \u2208 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 : \u2200 (x : L), x \u2208 S \u2192 x\u207b\u00b9 \u2208 S) : intermediate_field.to_subalgebra (subalgebra.to_intermediate_field S inv_mem) = S :=\n  subalgebra.ext\n    fun (x : L) => iff.refl (x \u2208 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 : \u2200 (x : L), x \u2208 intermediate_field.to_subalgebra S \u2192 x\u207b\u00b9 \u2208 S) : subalgebra.to_intermediate_field (intermediate_field.to_subalgebra S) inv_mem = S :=\n  intermediate_field.ext\n    fun (x : L) => iff.refl (x \u2208 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 : \u2200 (x : K), coe_fn (algebra_map K L) x \u2208 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 \u21a5S :=\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 : \u21a5S) (y : \u21a5S) : \u2191(x + y) = \u2191x + \u2191y :=\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 : \u21a5S) : \u2191(-x) = -\u2191x :=\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 : \u21a5S) (y : \u21a5S) : \u2191(x * y) = \u2191x * \u2191y :=\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 : \u21a5S) : \u2191(x\u207b\u00b9) = (\u2191x\u207b\u00b9) :=\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) : \u21910 = 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) : \u21911 = 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 \u21a5S :=\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 (\u21a5S) 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 (\u21a5S) L :=\n  is_scalar_tower.subalgebra' K L L (to_subalgebra S)\n\n/-- If `f : L \u2192+* L'` fixes `K`, `S.map f` is the intermediate field between `L'` and `K`\nsuch that `x \u2208 S \u2194 f x \u2208 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 (\u21a5S) 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) : \u21d1(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 \u2208 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) => \u2191S \u2286 \u2191T)\n    (preorder.lt._default fun (S T : intermediate_field K L) => \u2191S \u2286 \u2191T) 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 \u21d1(algebra_map K L) \u2286 \u2191S :=\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) \u2264 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 \u2264 to_subalgebra S' \u2194 S \u2264 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' \u2194 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 \u21a5F) : 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 (\u21a5F) 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 \u21a5F) (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 (\u21a5F) 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 (\u21a5F) L} {x : L} : x \u2208 \u2191E \u2194 x \u2208 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 (\u21a5F) L} : algebra K \u21a5E :=\n  algebra.mk (ring_hom.mk \u21d1(ring_hom.comp (algebra_map \u21a5F \u21a5E) (algebra_map K \u21a5F)) 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 (\u21a5F) L} : is_scalar_tower K \u21a5F \u21a5E := 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 (\u21a5F) L) : alg_equiv K \u21a5\u2191E \u21a5E :=\n  alg_equiv.mk (fun (x : \u21a5\u2191E) => x) (fun (x : \u21a5E) => 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 \u21a5F :=\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 (\u21a5F) L :=\n  finite_dimensional.right K (\u21a5F) 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 \u21a5(to_subalgebra F) = vector_space.dim K \u21a5F :=\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 \u21a5(to_subalgebra F) = finite_dimensional.findim K \u21a5F :=\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 \u2194 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 \u2264 E) (h_findim : finite_dimensional.findim K \u21a5E \u2264 finite_dimensional.findim K \u21a5F) : 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 \u2264 E) (h_findim : finite_dimensional.findim K \u21a5F = finite_dimensional.findim K \u21a5E) : 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 \u2264 E) (h_findim : finite_dimensional.findim (\u21a5F) L \u2264 finite_dimensional.findim (\u21a5E) 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 \u2264 E) (h_findim : finite_dimensional.findim (\u21a5F) L = finite_dimensional.findim (\u21a5E) 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 \u2243o 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 \u2208 coe_fn (subalgebra_equiv_intermediate_field alg) S \u2194 x \u2208 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 \u2208 coe_fn (order_iso.symm (subalgebra_equiv_intermediate_field alg)) S \u2194 x \u2208 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 \u03b1`\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 \u03b1 \u2243 option \u03b2` constructed from `e : \u03b1 \u2243 \u03b2` by sending `none` to\n  `none`, and applying a `e` elsewhere.\n* `equiv.remove_none`: the `\u03b1 \u2243 \u03b2` constructed from `option \u03b1 \u2243 option \u03b2` by removing `none` from\n  both sides.\n-/\n\n\nnamespace Equiv\n\nopen Option\n\nvariable {\u03b1 \u03b2 \u03b3 : 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 : \u03b1 \u2243 \u03b2) : Option \u03b1 \u2243 Option \u03b2\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 \u25b8 congr_fun Option.map_id x\n  right_inv x := (Option.map_map _ _ _).trans <| e.self_comp_symm.symm \u25b8 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 \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (e : Equiv.{succ u1, succ u2} \u03b1 \u03b2), Eq.{max 1 (max (succ u2) (succ u1)) (succ u1) (succ u2)} (Equiv.{succ u2, succ u1} (Option.{u2} \u03b2) (Option.{u1} \u03b1)) (Equiv.symm.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2) (Equiv.optionCongr.{u1, u2} \u03b1 \u03b2 e)) (Equiv.optionCongr.{u2, u1} \u03b2 \u03b1 (Equiv.symm.{succ u1, succ u2} \u03b1 \u03b2 e))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (e : Equiv.{succ u2, succ u1} \u03b1 \u03b2), Eq.{max (succ u2) (succ u1)} (Equiv.{succ u1, succ u2} (Option.{u1} \u03b2) (Option.{u2} \u03b1)) (Equiv.symm.{succ u2, succ u1} (Option.{u2} \u03b1) (Option.{u1} \u03b2) (Equiv.optionCongr.{u2, u1} \u03b1 \u03b2 e)) (Equiv.optionCongr.{u1, u2} \u03b2 \u03b1 (Equiv.symm.{succ u2, succ u1} \u03b1 \u03b2 e))\nCase conversion may be inaccurate. Consider using '#align equiv.option_congr_symm Equiv.optionCongr_symm\u2093'. -/\n@[simp]\ntheorem optionCongr_symm (e : \u03b1 \u2243 \u03b2) : (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (e\u2081 : Equiv.{succ u1, succ u2} \u03b1 \u03b2) (e\u2082 : Equiv.{succ u2, succ u3} \u03b2 \u03b3), Eq.{max 1 (max (succ u1) (succ u3)) (succ u3) (succ u1)} (Equiv.{succ u1, succ u3} (Option.{u1} \u03b1) (Option.{u3} \u03b3)) (Equiv.trans.{succ u1, succ u2, succ u3} (Option.{u1} \u03b1) (Option.{u2} \u03b2) (Option.{u3} \u03b3) (Equiv.optionCongr.{u1, u2} \u03b1 \u03b2 e\u2081) (Equiv.optionCongr.{u2, u3} \u03b2 \u03b3 e\u2082)) (Equiv.optionCongr.{u1, u3} \u03b1 \u03b3 (Equiv.trans.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 e\u2081 e\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (e\u2081 : Equiv.{succ u3, succ u2} \u03b1 \u03b2) (e\u2082 : Equiv.{succ u2, succ u1} \u03b2 \u03b3), Eq.{max (succ u3) (succ u1)} (Equiv.{succ u3, succ u1} (Option.{u3} \u03b1) (Option.{u1} \u03b3)) (Equiv.trans.{succ u3, succ u2, succ u1} (Option.{u3} \u03b1) (Option.{u2} \u03b2) (Option.{u1} \u03b3) (Equiv.optionCongr.{u3, u2} \u03b1 \u03b2 e\u2081) (Equiv.optionCongr.{u2, u1} \u03b2 \u03b3 e\u2082)) (Equiv.optionCongr.{u3, u1} \u03b1 \u03b3 (Equiv.trans.{succ u3, succ u2, succ u1} \u03b1 \u03b2 \u03b3 e\u2081 e\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.option_congr_trans Equiv.optionCongr_trans\u2093'. -/\n@[simp]\ntheorem optionCongr_trans (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b2 \u2243 \u03b3) :\n    (optionCongr e\u2081).trans (optionCongr e\u2082) = optionCongr (e\u2081.trans e\u2082) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}} (e : Equiv.{succ u1, succ u1} \u03b1 \u03b2), Eq.{succ u1} (Equiv.{succ u1, succ u1} (Option.{u1} \u03b1) (Option.{u1} \u03b2)) (Equiv.optionCongr.{u1, u1} \u03b1 \u03b2 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}))) \u03b1 \u03b2 e)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}} (e : Equiv.{succ u1, succ u1} \u03b1 \u03b2), Eq.{succ u1} (Equiv.{succ u1, succ u1} (Option.{u1} \u03b1) (Option.{u1} \u03b2)) (Equiv.optionCongr.{u1, u1} \u03b1 \u03b2 e) (EquivFunctor.mapEquiv.{u1, u1} Option.{u1} (EquivFunctor.ofLawfulFunctor.{u1, u1} Option.{u1} instFunctorOption.{u1} instLawfulFunctorOptionInstFunctorOption.{u1}) \u03b1 \u03b2 e)\nCase conversion may be inaccurate. Consider using '#align equiv.option_congr_eq_equiv_function_map_equiv Equiv.optionCongr_eq_equivFunctor_mapEquiv\u2093'. -/\n/-- When `\u03b1` and `\u03b2` are in the same universe, this is the same as the result of\n`equiv_functor.map_equiv`. -/\ntheorem optionCongr_eq_equivFunctor_mapEquiv {\u03b1 \u03b2 : Type _} (e : \u03b1 \u2243 \u03b2) :\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 \u03b1 \u2243 Option \u03b2)\n\nprivate def remove_none_aux (x : \u03b1) : \u03b2 :=\n  if h : (e (some x)).isSome then Option.get h\n  else\n    Option.get <|\n      show (e none).isSome by\n        rw [\u2190 Option.ne_none_iff_isSome]\n        intro hn\n        rw [Option.not_isSome_iff_eq_none, \u2190 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 : \u03b1} (h : \u2203 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 : \u03b1} (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 : \u03b1) : 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      \u00b7 rw [remove_none_aux_none _ h1]\n        exact (e.eq_symm_apply.mpr h2).symm\n      \u00b7 rw [remove_none_aux_some _ \u27e8_, h2\u27e9] at h1\n        simpa using h1\n      \u00b7 rw [remove_none_aux_none _ h2] at h1\n        simpa using h1\n      \u00b7 rw [remove_none_aux_some _ \u27e8_, h1\u27e9]\n        rw [remove_none_aux_some _ \u27e8_, h2\u27e9]\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 : \u03b1 \u2243 \u03b2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (e : Equiv.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2)), Eq.{max 1 (max (succ u2) (succ u1)) (succ u1) (succ u2)} (Equiv.{succ u2, succ u1} \u03b2 \u03b1) (Equiv.symm.{succ u1, succ u2} \u03b1 \u03b2 (Equiv.removeNone.{u1, u2} \u03b1 \u03b2 e)) (Equiv.removeNone.{u2, u1} \u03b2 \u03b1 (Equiv.symm.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2) e))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (e : Equiv.{succ u2, succ u1} (Option.{u2} \u03b1) (Option.{u1} \u03b2)), Eq.{max (succ u2) (succ u1)} (Equiv.{succ u1, succ u2} \u03b2 \u03b1) (Equiv.symm.{succ u2, succ u1} \u03b1 \u03b2 (Equiv.removeNone.{u2, u1} \u03b1 \u03b2 e)) (Equiv.removeNone.{u1, u2} \u03b2 \u03b1 (Equiv.symm.{succ u2, succ u1} (Option.{u2} \u03b1) (Option.{u1} \u03b2) e))\nCase conversion may be inaccurate. Consider using '#align equiv.remove_none_symm Equiv.removeNone_symm\u2093'. -/\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 : \u03b1} (h : \u2203 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 : \u03b1} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (e : Equiv.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2)), Iff (Eq.{succ u1} (Option.{u1} \u03b1) (coeFn.{max 1 (max (succ u2) (succ u1)) (succ u1) (succ u2), max (succ u2) (succ u1)} (Equiv.{succ u2, succ u1} (Option.{u2} \u03b2) (Option.{u1} \u03b1)) (fun (_x : Equiv.{succ u2, succ u1} (Option.{u2} \u03b2) (Option.{u1} \u03b1)) => (Option.{u2} \u03b2) -> (Option.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u2, succ u1} (Option.{u2} \u03b2) (Option.{u1} \u03b1)) (Equiv.symm.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2) e) (Option.none.{u2} \u03b2)) (Option.none.{u1} \u03b1)) (Eq.{succ u2} (Option.{u2} \u03b2) (coeFn.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1), max (succ u1) (succ u2)} (Equiv.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2)) (fun (_x : Equiv.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2)) => (Option.{u1} \u03b1) -> (Option.{u2} \u03b2)) (Equiv.hasCoeToFun.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2)) e (Option.none.{u1} \u03b1)) (Option.none.{u2} \u03b2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (e : Equiv.{succ u2, succ u1} (Option.{u2} \u03b1) (Option.{u1} \u03b2)), Iff (Eq.{succ u2} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u1} \u03b2) => Option.{u2} \u03b1) (Option.none.{u1} \u03b2)) (FunLike.coe.{max (succ u2) (succ u1), succ u1, succ u2} (Equiv.{succ u1, succ u2} (Option.{u1} \u03b2) (Option.{u2} \u03b1)) (Option.{u1} \u03b2) (fun (_x : Option.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u1} \u03b2) => Option.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u2} (Option.{u1} \u03b2) (Option.{u2} \u03b1)) (Equiv.symm.{succ u2, succ u1} (Option.{u2} \u03b1) (Option.{u1} \u03b2) e) (Option.none.{u1} \u03b2)) (Option.none.{u2} \u03b1)) (Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} \u03b1) => Option.{u1} \u03b2) (Option.none.{u2} \u03b1)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Equiv.{succ u2, succ u1} (Option.{u2} \u03b1) (Option.{u1} \u03b2)) (Option.{u2} \u03b1) (fun (_x : Option.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Option.{u2} \u03b1) => Option.{u1} \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u1} (Option.{u2} \u03b1) (Option.{u1} \u03b2)) e (Option.none.{u2} \u03b1)) (Option.none.{u1} \u03b2))\nCase conversion may be inaccurate. Consider using '#align equiv.option_symm_apply_none_iff Equiv.option_symm_apply_none_iff\u2093'. -/\n@[simp]\ntheorem option_symm_apply_none_iff : e.symm none = none \u2194 e none = none :=\n  \u27e8fun h => by simpa using (congr_arg e h).symm, fun h => by simpa using (congr_arg e.symm h).symm\u27e9\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 : \u03b1} : some (removeNone e x) = e none \u2194 e.symm none = some x :=\n  by\n  cases' h : e (some x) with a\n  \u00b7 rw [remove_none_none _ h]\n    simpa using (congr_arg e.symm h).symm\n  \u00b7 rw [remove_none_some _ \u27e8a, h\u27e9]\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (e : Equiv.{succ u1, succ u2} \u03b1 \u03b2), Eq.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1)} (Equiv.{succ u1, succ u2} \u03b1 \u03b2) (Equiv.removeNone.{u1, u2} \u03b1 \u03b2 (Equiv.optionCongr.{u1, u2} \u03b1 \u03b2 e)) e\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (e : Equiv.{succ u2, succ u1} \u03b1 \u03b2), Eq.{max (succ u2) (succ u1)} (Equiv.{succ u2, succ u1} \u03b1 \u03b2) (Equiv.removeNone.{u2, u1} \u03b1 \u03b2 (Equiv.optionCongr.{u2, u1} \u03b1 \u03b2 e)) e\nCase conversion may be inaccurate. Consider using '#align equiv.remove_none_option_congr Equiv.removeNone_optionCongr\u2093'. -/\n@[simp]\ntheorem removeNone_optionCongr (e : \u03b1 \u2243 \u03b2) : removeNone e.optionCongr = e :=\n  Equiv.ext fun x => Option.some_injective _ <| removeNone_some _ \u27e8e x, by simp [EquivFunctor.map]\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : 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} \u03b1 \u03b2) (Equiv.{succ u1, succ u2} (Option.{u1} \u03b1) (Option.{u2} \u03b2)) (Equiv.optionCongr.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}}, Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (Equiv.{succ u2, succ u1} \u03b1 \u03b2) (Equiv.{succ u2, succ u1} (Option.{u2} \u03b1) (Option.{u1} \u03b2)) (Equiv.optionCongr.{u2, u1} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align equiv.option_congr_injective Equiv.optionCongr_injective\u2093'. -/\ntheorem optionCongr_injective : Function.Injective (optionCongr : \u03b1 \u2243 \u03b2 \u2192 Option \u03b1 \u2243 Option \u03b2) :=\n  Function.LeftInverse.injective removeNone_optionCongr\n#align equiv.option_congr_injective Equiv.optionCongr_injective\n\n#print Equiv.optionSubtype /-\n/-- Equivalences between `option \u03b1` and `\u03b2` that send `none` to `x` are equivalent to\nequivalences between `\u03b1` and `{y : \u03b2 // y \u2260 x}`. -/\ndef optionSubtype [DecidableEq \u03b2] (x : \u03b2) :\n    { e : Option \u03b1 \u2243 \u03b2 // e none = x } \u2243 (\u03b1 \u2243 { y : \u03b2 // y \u2260 x })\n    where\n  toFun e :=\n    { toFun := fun a => \u27e8e a, ((EquivLike.injective _).ne_iff' e.property).2 (some_ne_none _)\u27e9\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 [\u2190 some_inj, some_get, \u2190 coe_def]\n        exact symm_apply_apply (e : Option \u03b1 \u2243 \u03b2) a\n      right_inv := fun b => by\n        ext\n        simp\n        exact apply_symm_apply _ _ }\n  invFun e :=\n    \u27e8{  toFun := fun a => casesOn' a x (coe \u2218 e)\n        invFun := fun b => if h : b = x then none else e.symm \u27e8b, h\u27e9\n        left_inv := fun a => by\n          cases a; \u00b7 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\u27e9\n  left_inv e := by\n    ext a\n    cases a\n    \u00b7 simpa using e.property.symm\n    \u00b7 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 \u03b2] (x : \u03b2) (e : { e : Option \u03b1 \u2243 \u03b2 // e none = x })\n    (a : \u03b1) (h) : optionSubtype x e a = \u27e8(e : Option \u03b1 \u2243 \u03b2) a, h\u27e9 :=\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 \u03b2] (x : \u03b2)\n    (e : { e : Option \u03b1 \u2243 \u03b2 // e none = x }) (a : \u03b1) :\n    \u2191(optionSubtype x e a) = (e : Option \u03b1 \u2243 \u03b2) 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 \u03b2] (x : \u03b2)\n    (e : { e : Option \u03b1 \u2243 \u03b2 // e none = x }) (b : { y : \u03b2 // y \u2260 x }) :\n    \u2191((optionSubtype x e).symm b) = (e : Option \u03b1 \u2243 \u03b2).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 \u03b2] (x : \u03b2) (e : \u03b1 \u2243 { y : \u03b2 // y \u2260 x })\n    (a : \u03b1) : (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 \u03b2] (x : \u03b2) (e : \u03b1 \u2243 { y : \u03b2 // y \u2260 x })\n    (a : \u03b1) : (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 \u03b2] (x : \u03b2) (e : \u03b1 \u2243 { y : \u03b2 // y \u2260 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 \u03b2] (x : \u03b2) (e : \u03b1 \u2243 { y : \u03b2 // y \u2260 x })\n    (b : { y : \u03b2 // y \u2260 x }) : ((optionSubtype x).symm e : Option \u03b1 \u2243 \u03b2).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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 (\u03b1 : Type u_1) \nextends filter \u03b1\nwhere\n  ne_bot' : filter.ne_bot _to_filter\n  le_of_le : \u2200 (g : filter \u03b1), filter.ne_bot g \u2192 g \u2264 _to_filter \u2192 _to_filter \u2264 g\n\nnamespace ultrafilter\n\n\nprotected instance filter.has_coe_t {\u03b1 : Type u} : has_coe_t (ultrafilter \u03b1) (filter \u03b1) :=\n  has_coe_t.mk ultrafilter.to_filter\n\nprotected instance has_mem {\u03b1 : Type u} : has_mem (set \u03b1) (ultrafilter \u03b1) :=\n  has_mem.mk fun (s : set \u03b1) (f : ultrafilter \u03b1) => s \u2208 \u2191f\n\ntheorem unique {\u03b1 : Type u} (f : ultrafilter \u03b1) {g : filter \u03b1} (h : g \u2264 \u2191f) (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 = \u2191f :=\n  le_antisymm h (ultrafilter.le_of_le f g hne h)\n\nprotected instance ne_bot {\u03b1 : Type u} (f : ultrafilter \u03b1) : filter.ne_bot \u2191f :=\n  ultrafilter.ne_bot' f\n\n@[simp] theorem mem_coe {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} : s \u2208 \u2191f \u2194 s \u2208 f :=\n  iff.rfl\n\ntheorem coe_injective {\u03b1 : Type u} : function.injective coe := sorry\n\n@[simp] theorem coe_le_coe {\u03b1 : Type u} {f : ultrafilter \u03b1} {g : ultrafilter \u03b1} : \u2191f \u2264 \u2191g \u2194 f = g :=\n  { mp := fun (h : \u2191f \u2264 \u2191g) => coe_injective (unique g h), mpr := fun (h : f = g) => h \u25b8 le_rfl }\n\n@[simp] theorem coe_inj {\u03b1 : Type u} {f : ultrafilter \u03b1} {g : ultrafilter \u03b1} : \u2191f = \u2191g \u2194 f = g :=\n  function.injective.eq_iff coe_injective\n\ntheorem ext {\u03b1 : Type u} {f : ultrafilter \u03b1} {g : ultrafilter \u03b1} (h : \u2200 (s : set \u03b1), s \u2208 f \u2194 s \u2208 g) : f = g :=\n  coe_injective (filter.ext h)\n\ntheorem le_of_inf_ne_bot {\u03b1 : Type u} (f : ultrafilter \u03b1) {g : filter \u03b1} (hg : filter.ne_bot (\u2191f \u2293 g)) : \u2191f \u2264 g :=\n  le_of_inf_eq (unique f inf_le_left)\n\ntheorem le_of_inf_ne_bot' {\u03b1 : Type u} (f : ultrafilter \u03b1) {g : filter \u03b1} (hg : filter.ne_bot (g \u2293 \u2191f)) : \u2191f \u2264 g :=\n  le_of_inf_ne_bot f (eq.mpr (id (Eq._oldrec (Eq.refl (filter.ne_bot (\u2191f \u2293 g))) inf_comm)) hg)\n\n@[simp] theorem compl_not_mem_iff {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} : \u00acs\u1d9c \u2208 f \u2194 s \u2208 f := sorry\n\n@[simp] theorem frequently_iff_eventually {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} : filter.frequently (fun (x : \u03b1) => p x) \u2191f \u2194 filter.eventually (fun (x : \u03b1) => p x) \u2191f :=\n  compl_not_mem_iff\n\ntheorem Mathlib.filter.frequently.eventually {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} : filter.frequently (fun (x : \u03b1) => p x) \u2191f \u2192 filter.eventually (fun (x : \u03b1) => p x) \u2191f :=\n  iff.mp frequently_iff_eventually\n\ntheorem compl_mem_iff_not_mem {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} : s\u1d9c \u2208 f \u2194 \u00acs \u2208 f :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s\u1d9c \u2208 f \u2194 \u00acs \u2208 f)) (Eq.symm (propext compl_not_mem_iff))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u00acs\u1d9c\u1d9c \u2208 f \u2194 \u00acs \u2208 f)) (compl_compl s))) (iff.refl (\u00acs \u2208 f)))\n\n/-- If `s\u1d9c \u2209 f \u2194 s \u2208 f`, then `f` is an ultrafilter. The other implication is given by\n`ultrafilter.compl_not_mem_iff`.  -/\ndef of_compl_not_mem_iff {\u03b1 : Type u} (f : filter \u03b1) (h : \u2200 (s : set \u03b1), \u00acs\u1d9c \u2208 f \u2194 s \u2208 f) : ultrafilter \u03b1 :=\n  mk f sorry sorry\n\ntheorem nonempty_of_mem {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} (hs : s \u2208 f) : set.nonempty s :=\n  filter.nonempty_of_mem_sets hs\n\ntheorem ne_empty_of_mem {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} (hs : s \u2208 f) : s \u2260 \u2205 :=\n  set.nonempty.ne_empty (nonempty_of_mem hs)\n\n@[simp] theorem empty_not_mem {\u03b1 : Type u} {f : ultrafilter \u03b1} : \u00ac\u2205 \u2208 f :=\n  filter.empty_nmem_sets \u2191f\n\ntheorem mem_or_compl_mem {\u03b1 : Type u} (f : ultrafilter \u03b1) (s : set \u03b1) : s \u2208 f \u2228 s\u1d9c \u2208 f :=\n  iff.mpr or_iff_not_imp_left (iff.mpr compl_mem_iff_not_mem)\n\nprotected theorem em {\u03b1 : Type u} (f : ultrafilter \u03b1) (p : \u03b1 \u2192 Prop) : filter.eventually (fun (x : \u03b1) => p x) \u2191f \u2228 filter.eventually (fun (x : \u03b1) => \u00acp x) \u2191f :=\n  mem_or_compl_mem f (set_of fun (x : \u03b1) => p x)\n\ntheorem eventually_or {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} : filter.eventually (fun (x : \u03b1) => p x \u2228 q x) \u2191f \u2194\n  filter.eventually (fun (x : \u03b1) => p x) \u2191f \u2228 filter.eventually (fun (x : \u03b1) => q x) \u2191f := sorry\n\ntheorem union_mem_iff {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set \u03b1} {t : set \u03b1} : s \u222a t \u2208 f \u2194 s \u2208 f \u2228 t \u2208 f :=\n  eventually_or\n\ntheorem eventually_not {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} : filter.eventually (fun (x : \u03b1) => \u00acp x) \u2191f \u2194 \u00acfilter.eventually (fun (x : \u03b1) => p x) \u2191f :=\n  compl_mem_iff_not_mem\n\ntheorem eventually_imp {\u03b1 : Type u} {f : ultrafilter \u03b1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} : filter.eventually (fun (x : \u03b1) => p x \u2192 q x) \u2191f \u2194\n  filter.eventually (fun (x : \u03b1) => p x) \u2191f \u2192 filter.eventually (fun (x : \u03b1) => q x) \u2191f := sorry\n\ntheorem finite_sUnion_mem_iff {\u03b1 : Type u} {f : ultrafilter \u03b1} {s : set (set \u03b1)} (hs : set.finite s) : \u22c3\u2080s \u2208 f \u2194 \u2203 (t : set \u03b1), \u2203 (H : t \u2208 s), t \u2208 f := sorry\n\ntheorem finite_bUnion_mem_iff {\u03b1 : Type u} {\u03b2 : Type v} {f : ultrafilter \u03b1} {is : set \u03b2} {s : \u03b2 \u2192 set \u03b1} (his : set.finite is) : (set.Union fun (i : \u03b2) => set.Union fun (H : i \u2208 is) => s i) \u2208 f \u2194 \u2203 (i : \u03b2), \u2203 (H : i \u2208 is), s i \u2208 f := sorry\n\n/-- Pushforward for ultrafilters. -/\ndef map {\u03b1 : Type u} {\u03b2 : Type v} (m : \u03b1 \u2192 \u03b2) (f : ultrafilter \u03b1) : ultrafilter \u03b2 :=\n  of_compl_not_mem_iff (filter.map m \u2191f) sorry\n\n@[simp] theorem coe_map {\u03b1 : Type u} {\u03b2 : Type v} (m : \u03b1 \u2192 \u03b2) (f : ultrafilter \u03b1) : \u2191(map m f) = filter.map m \u2191f :=\n  rfl\n\n@[simp] theorem mem_map {\u03b1 : Type u} {\u03b2 : Type v} {m : \u03b1 \u2192 \u03b2} {f : ultrafilter \u03b1} {s : set \u03b2} : s \u2208 map m f \u2194 m \u207b\u00b9' s \u2208 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 {\u03b1 : Type u} {\u03b2 : Type v} {m : \u03b1 \u2192 \u03b2} (u : ultrafilter \u03b2) (inj : function.injective m) (large : set.range m \u2208 u) : ultrafilter \u03b1 :=\n  mk (filter.comap m \u2191u) sorry sorry\n\n/-- The principal ultrafilter associated to a point `x`. -/\nprotected instance has_pure : Pure ultrafilter :=\n  { pure := fun (\u03b1 : Type u_1) (a : \u03b1) => of_compl_not_mem_iff (pure a) sorry }\n\n@[simp] theorem mem_pure_sets {\u03b1 : Type u} {a : \u03b1} {s : set \u03b1} : s \u2208 pure a \u2194 a \u2208 s :=\n  iff.rfl\n\nprotected instance inhabited {\u03b1 : Type u} [Inhabited \u03b1] : Inhabited (ultrafilter \u03b1) :=\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 {\u03b1 : Type u} {\u03b2 : Type v} (f : ultrafilter \u03b1) (m : \u03b1 \u2192 ultrafilter \u03b2) : ultrafilter \u03b2 :=\n  of_compl_not_mem_iff (filter.bind \u2191f fun (x : \u03b1) => \u2191(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 (\u03b1 \u03b2 : Type u_1) => map \u2218 function.const \u03b2 }\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 (\u03b1 \u03b2 : Type u_1) (a : \u03b1) (f : \u03b1 \u2192 ultrafilter \u03b2) => coe_injective (filter.pure_bind a (coe \u2218 f)))\n    fun (\u03b1 \u03b2 \u03b3 : Type u_1) (f : ultrafilter \u03b1) (m\u2081 : \u03b1 \u2192 ultrafilter \u03b2) (m\u2082 : \u03b2 \u2192 ultrafilter \u03b3) =>\n      coe_injective (filter.filter_eq rfl)\n\n/-- The ultrafilter lemma: Any proper filter is contained in an ultrafilter. -/\ntheorem exists_le {\u03b1 : Type u} (f : filter \u03b1) [h : filter.ne_bot f] : \u2203 (u : ultrafilter \u03b1), \u2191u \u2264 f := sorry\n\ntheorem Mathlib.filter.exists_ultrafilter_le {\u03b1 : Type u} (f : filter \u03b1) [h : filter.ne_bot f] : \u2203 (u : ultrafilter \u03b1), \u2191u \u2264 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 {\u03b1 : Type u} (f : filter \u03b1) [filter.ne_bot f] : ultrafilter \u03b1 :=\n  classical.some (exists_le f)\n\ntheorem of_le {\u03b1 : Type u} (f : filter \u03b1) [filter.ne_bot f] : \u2191(of f) \u2264 f :=\n  classical.some_spec (exists_le f)\n\ntheorem of_coe {\u03b1 : Type u} (f : ultrafilter \u03b1) : of \u2191f = f :=\n  iff.mp coe_inj (unique f (of_le \u2191f))\n\ntheorem exists_ultrafilter_of_finite_inter_nonempty {\u03b1 : Type u} (S : set (set \u03b1)) (cond : \u2200 (T : finset (set \u03b1)), \u2191T \u2286 S \u2192 set.nonempty (\u22c2\u2080\u2191T)) : \u2203 (F : ultrafilter \u03b1), S \u2286 filter.sets (ultrafilter.to_filter F) := sorry\n\nend ultrafilter\n\n\nnamespace filter\n\n\ntheorem mem_iff_ultrafilter {\u03b1 : Type u} {s : set \u03b1} {f : filter \u03b1} : s \u2208 f \u2194 \u2200 (g : ultrafilter \u03b1), \u2191g \u2264 f \u2192 s \u2208 g := sorry\n\ntheorem le_iff_ultrafilter {\u03b1 : Type u} {f\u2081 : filter \u03b1} {f\u2082 : filter \u03b1} : f\u2081 \u2264 f\u2082 \u2194 \u2200 (g : ultrafilter \u03b1), \u2191g \u2264 f\u2081 \u2192 \u2191g \u2264 f\u2082 := sorry\n\n/-- A filter equals the intersection of all the ultrafilters which contain it. -/\ntheorem supr_ultrafilter_le_eq {\u03b1 : Type u} (f : filter \u03b1) : (supr fun (g : ultrafilter \u03b1) => supr fun (hg : \u2191g \u2264 f) => \u2191g) = f := sorry\n\n/-- The `tendsto` relation can be checked on ultrafilters. -/\ntheorem tendsto_iff_ultrafilter {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (l\u2081 : filter \u03b1) (l\u2082 : filter \u03b2) : tendsto f l\u2081 l\u2082 \u2194 \u2200 (g : ultrafilter \u03b1), \u2191g \u2264 l\u2081 \u2192 tendsto f (\u2191g) l\u2082 := sorry\n\ntheorem exists_ultrafilter_iff {\u03b1 : Type u} {f : filter \u03b1} : (\u2203 (u : ultrafilter \u03b1), \u2191u \u2264 f) \u2194 ne_bot f := sorry\n\ntheorem forall_ne_bot_le_iff {\u03b1 : Type u} {g : filter \u03b1} {p : filter \u03b1 \u2192 Prop} (hp : monotone p) : (\u2200 (f : filter \u03b1), ne_bot f \u2192 f \u2264 g \u2192 p f) \u2194 \u2200 (f : ultrafilter \u03b1), \u2191f \u2264 g \u2192 p \u2191f := sorry\n\n/-- The ultrafilter extending the cofinite filter. -/\ndef hyperfilter (\u03b1 : Type u) [infinite \u03b1] : ultrafilter \u03b1 :=\n  ultrafilter.of cofinite\n\ntheorem hyperfilter_le_cofinite {\u03b1 : Type u} [infinite \u03b1] : \u2191(hyperfilter \u03b1) \u2264 cofinite :=\n  ultrafilter.of_le cofinite\n\n@[simp] theorem bot_ne_hyperfilter {\u03b1 : Type u} [infinite \u03b1] : \u22a5 \u2260 \u2191(hyperfilter \u03b1) :=\n  ne.symm ((fun (this : ne_bot \u2191(hyperfilter \u03b1)) => this) (ultrafilter.ne_bot (hyperfilter \u03b1)))\n\ntheorem nmem_hyperfilter_of_finite {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1} (hf : set.finite s) : \u00acs \u2208 hyperfilter \u03b1 :=\n  fun (hy : s \u2208 hyperfilter \u03b1) => compl_not_mem_sets hy (hyperfilter_le_cofinite (set.finite.compl_mem_cofinite hf))\n\ntheorem Mathlib.set.finite.nmem_hyperfilter {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1} (hf : set.finite s) : \u00acs \u2208 hyperfilter \u03b1 :=\n  nmem_hyperfilter_of_finite\n\ntheorem compl_mem_hyperfilter_of_finite {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1} (hf : set.finite s) : s\u1d9c \u2208 hyperfilter \u03b1 :=\n  iff.mpr ultrafilter.compl_mem_iff_not_mem (set.finite.nmem_hyperfilter hf)\n\ntheorem Mathlib.set.finite.compl_mem_hyperfilter {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1} (hf : set.finite s) : s\u1d9c \u2208 hyperfilter \u03b1 :=\n  compl_mem_hyperfilter_of_finite\n\ntheorem mem_hyperfilter_of_finite_compl {\u03b1 : Type u} [infinite \u03b1] {s : set \u03b1} (hf : set.finite (s\u1d9c)) : s \u2208 hyperfilter \u03b1 :=\n  compl_compl s \u25b8 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\u2081, t\u2082)`\nsuch that `t\u2081 + t\u2082 = s`. These pairs are counted with multiplicities.\n-/\n\n\nnamespace Multiset\n\nopen List\n\nvariable {\u03b1 \u03b2 : Type _}\n\n#print Multiset.antidiagonal /-\n/-- The antidiagonal of a multiset `s` consists of all pairs `(t\u2081, t\u2082)`\n    such that `t\u2081 + t\u2082 = s`. These pairs are counted with multiplicities. -/\ndef antidiagonal (s : Multiset \u03b1) : Multiset (Multiset \u03b1 \u00d7 Multiset \u03b1) :=\n  Quot.liftOn s (fun l => (revzip (powersetAux l) : Multiset (Multiset \u03b1 \u00d7 Multiset \u03b1)))\n    fun l\u2081 l\u2082 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 \u03b1) : @antidiagonal \u03b1 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 \u03b1) : @antidiagonal \u03b1 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\u2081, t\u2082)` of multisets is contained in `antidiagonal s`\n    if and only if `t\u2081 + t\u2082 = s`. -/\n@[simp]\ntheorem mem_antidiagonal {s : Multiset \u03b1} {x : Multiset \u03b1 \u00d7 Multiset \u03b1} :\n    x \u2208 antidiagonal s \u2194 x.1 + x.2 = s :=\n  Quotient.inductionOn s fun l => by\n    simp [antidiagonal_coe]; refine' \u27e8fun h => revzip_powerset_aux h, fun h => _\u27e9\n    haveI := Classical.decEq \u03b1\n    simp [revzip_powerset_aux_lemma l revzip_powerset_aux, h.symm]\n    cases' x with x\u2081 x\u2082\n    dsimp only\n    exact \u27e8x\u2081, le_add_right _ _, by rw [add_tsub_cancel_left x\u2081 x\u2082]\u27e9\n#align multiset.mem_antidiagonal Multiset.mem_antidiagonal\n-/\n\n#print Multiset.antidiagonal_map_fst /-\n@[simp]\ntheorem antidiagonal_map_fst (s : Multiset \u03b1) : (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 \u03b1) : (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 \u03b1 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 : \u03b1) (s) :\n    antidiagonal (a ::\u2098 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 [\u2190 zip_map, \u2190 zip_map, zip_append, (_ : _ ++ _ = _)]\n    \u00b7 congr <;> simp; \u00b7 simp\n#align multiset.antidiagonal_cons Multiset.antidiagonal_cons\n-/\n\n#print Multiset.antidiagonal_eq_map_powerset /-\ntheorem antidiagonal_eq_map_powerset [DecidableEq \u03b1] (s : Multiset \u03b1) :\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  \u00b7 simp only [antidiagonal_zero, powerset_zero, zero_tsub, map_singleton]\n  \u00b7 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 {\u03b1 : Type.{u1}} (s : Multiset.{u1} \u03b1), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.orderedCancelAddCommMonoid.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.orderedCancelAddCommMonoid.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.orderedCancelAddCommMonoid.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.antidiagonal.{u1} \u03b1 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} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} \u03b1) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} \u03b1) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (s : Multiset.{u1} \u03b1), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) => Nat) (Multiset.antidiagonal.{u1} \u03b1 s)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (fun (_x : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))))))))) (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} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)))))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) (Multiset.antidiagonal.{u1} \u03b1 s)) (HPow.hPow.{0, 0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) => Nat) (Multiset.antidiagonal.{u1} \u03b1 s)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) s) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) => Nat) (Multiset.antidiagonal.{u1} \u03b1 s)) (instHPow.{0, 0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) => Nat) (Multiset.antidiagonal.{u1} \u03b1 s)) ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) s) instPowNat) (OfNat.ofNat.{0} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1))) => Nat) (Multiset.antidiagonal.{u1} \u03b1 s)) 2 (instOfNatNat 2)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} \u03b1) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} \u03b1) s))\nCase conversion may be inaccurate. Consider using '#align multiset.card_antidiagonal Multiset.card_antidiagonal\u2093'. -/\n@[simp]\ntheorem card_antidiagonal (s : Multiset \u03b1) : card (antidiagonal s) = 2 ^ card s := by\n  have := card_powerset s <;> rwa [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CommSemiring.{u2} \u03b2] {s : Multiset.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, Eq.{succ u2} \u03b2 (Multiset.prod.{u2} \u03b2 (CommSemiring.toCommMonoid.{u2} \u03b2 _inst_1) (Multiset.map.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) => HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b2 (CommSemiring.toSemiring.{u2} \u03b2 _inst_1)))))) (f a) (g a)) s)) (Multiset.sum.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b2 (CommSemiring.toSemiring.{u2} \u03b2 _inst_1)))) (Multiset.map.{u1, u2} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)) \u03b2 (fun (p : Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)) => HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b2 (CommSemiring.toSemiring.{u2} \u03b2 _inst_1)))))) (Multiset.prod.{u2} \u03b2 (CommSemiring.toCommMonoid.{u2} \u03b2 _inst_1) (Multiset.map.{u1, u2} \u03b1 \u03b2 f (Prod.fst.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) p))) (Multiset.prod.{u2} \u03b2 (CommSemiring.toCommMonoid.{u2} \u03b2 _inst_1) (Multiset.map.{u1, u2} \u03b1 \u03b2 g (Prod.snd.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) p)))) (Multiset.antidiagonal.{u1} \u03b1 s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CommSemiring.{u2} \u03b2] {s : Multiset.{u1} \u03b1} {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2}, Eq.{succ u2} \u03b2 (Multiset.prod.{u2} \u03b2 (CommSemiring.toCommMonoid.{u2} \u03b2 _inst_1) (Multiset.map.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) => HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (Distrib.toAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b2 (CommSemiring.toSemiring.{u2} \u03b2 _inst_1)))))) (f a) (g a)) s)) (Multiset.sum.{u2} \u03b2 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b2 (CommSemiring.toSemiring.{u2} \u03b2 _inst_1)))) (Multiset.map.{u1, u2} (Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)) \u03b2 (fun (p : Prod.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1)) => HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b2 (CommSemiring.toSemiring.{u2} \u03b2 _inst_1))))) (Multiset.prod.{u2} \u03b2 (CommSemiring.toCommMonoid.{u2} \u03b2 _inst_1) (Multiset.map.{u1, u2} \u03b1 \u03b2 f (Prod.fst.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) p))) (Multiset.prod.{u2} \u03b2 (CommSemiring.toCommMonoid.{u2} \u03b2 _inst_1) (Multiset.map.{u1, u2} \u03b1 \u03b2 g (Prod.snd.{u1, u1} (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) p)))) (Multiset.antidiagonal.{u1} \u03b1 s)))\nCase conversion may be inaccurate. Consider using '#align multiset.prod_map_add Multiset.prod_map_add\u2093'. -/\ntheorem prod_map_add [CommSemiring \u03b2] {s : Multiset \u03b1} {f g : \u03b1 \u2192 \u03b2} :\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  \u00b7 simp\n  \u00b7 intro a s ih\n    have := @sum_map_mul_left \u03b1 \u03b2 _\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 \ud835\udc9c`.\n\nIn `src/algebraic_geometry/topology.lean`, we have given a topology on `projective_spectrum \ud835\udc9c`; in\nthis file we will construct a sheaf on `projective_spectrum \ud835\udc9c`.\n\n## Notation\n- `R` is a commutative semiring;\n- `A` is a commutative ring and an `R`-algebra;\n- `\ud835\udc9c : \u2115 \u2192 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 : \u03a0 x : U, homogeneous_localization \ud835\udc9c x` such that `f` is locally expressible as ratio of two\nelements of the *same grading*, i.e. `\u2200 y \u2208 U, \u2203 (V \u2286 U) (i : \u2115) (a b \u2208 \ud835\udc9c i), \u2200 z \u2208 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  `\u03a0 x : U, homogeneous_localization \ud835\udc9c x`.\n* `algebraic_geometry.Proj.structure_sheaf`: the sheaf with `U \u21a6 sections_subring U` and natural\n  restriction map.\n\nThen we establish that `Proj \ud835\udc9c` is a `LocallyRingedSpace`:\n* `algebraic_geometry.Proj.stalk_iso'`: for any `x : projective_spectrum \ud835\udc9c`, the stalk of\n  `Proj.structure_sheaf` at `x` is isomorphic to `homogeneous_localization \ud835\udc9c 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 (\ud835\udc9c : \u2115 \u2192 submodule R A) [graded_algebra \ud835\udc9c]\n\nlocal notation `at ` x := homogeneous_localization.at_prime \ud835\udc9c x.as_homogeneous_ideal.to_ideal\n\nnamespace projective_spectrum.structure_sheaf\n\nvariables {\ud835\udc9c}\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 \ud835\udc9c)} (f : \u03a0 x : U, at x.1) : Prop :=\n\u2203 (i : \u2115) (r s : \ud835\udc9c i),\n  \u2200 x : U, \u2203 (s_nin : s.1 \u2209 x.1.as_homogeneous_ideal),\n  (f x) = quotient.mk' \u27e8i, r, s, s_nin\u27e9\n\nvariables (\ud835\udc9c)\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 (\u03bb (x : projective_spectrum.Top \ud835\udc9c), at x) :=\n{ pred := \u03bb U f, is_fraction f,\n  res := by rintros V U i f \u27e8j, r, s, w\u27e9; exact \u27e8j, r, s, \u03bb y, w (i y)\u27e9 }\n\n/--\nWe will define the structure sheaf as the subsheaf of all dependent functions in\n`\u03a0 x : U, homogeneous_localization \ud835\udc9c x` consisting of those functions which can locally be expressed\nas a ratio of `A` of same grading.-/\ndef is_locally_fraction : local_predicate (\u03bb (x : projective_spectrum.Top \ud835\udc9c), at x) :=\n(is_fraction_prelocal \ud835\udc9c).sheafify\n\nnamespace section_subring\nvariable {\ud835\udc9c}\n\nopen submodule set_like.graded_monoid homogeneous_localization\n\nlemma zero_mem' (U : (opens (projective_spectrum.Top \ud835\udc9c))\u1d52\u1d56) :\n  (is_locally_fraction \ud835\udc9c).pred (0 : \u03a0 x : unop U, at x.1) :=\n\u03bb x, \u27e8unop U, x.2, \ud835\udfd9 (unop U), \u27e80, \u27e80, zero_mem _\u27e9, \u27e81, one_mem\u27e9, \u03bb y, \u27e8_, rfl\u27e9\u27e9\u27e9\n\nlemma one_mem' (U : (opens (projective_spectrum.Top \ud835\udc9c))\u1d52\u1d56) :\n  (is_locally_fraction \ud835\udc9c).pred (1 : \u03a0 x : unop U, at x.1) :=\n\u03bb x, \u27e8unop U, x.2, \ud835\udfd9 (unop U), \u27e80, \u27e81, one_mem\u27e9, \u27e81, one_mem\u27e9, \u03bb y, \u27e8_, rfl\u27e9\u27e9\u27e9\n\nlemma add_mem' (U : (opens (projective_spectrum.Top \ud835\udc9c))\u1d52\u1d56)\n  (a b : \u03a0 x : unop U, at x.1)\n  (ha : (is_locally_fraction \ud835\udc9c).pred a) (hb : (is_locally_fraction \ud835\udc9c).pred b) :\n  (is_locally_fraction \ud835\udc9c).pred (a + b) := \u03bb x,\nbegin\n  rcases ha x with \u27e8Va, ma, ia, ja, \u27e8ra, ra_mem\u27e9, \u27e8sa, sa_mem\u27e9, wa\u27e9,\n  rcases hb x with \u27e8Vb, mb, ib, jb, \u27e8rb, rb_mem\u27e9, \u27e8sb, sb_mem\u27e9, wb\u27e9,\n  refine \u27e8Va \u2293 Vb, \u27e8ma, mb\u27e9, opens.inf_le_left _ _ \u226b ia, ja + jb,\n    \u27e8sb * ra + sa * rb, add_mem (add_comm jb ja \u25b8 mul_mem sb_mem ra_mem : sb * ra \u2208 \ud835\udc9c (ja + jb))\n      (mul_mem sa_mem rb_mem)\u27e9,\n    \u27e8sa * sb, mul_mem sa_mem sb_mem\u27e9, \u03bb y, \u27e8\u03bb h, _, _\u27e9\u27e9,\n  { cases (y : projective_spectrum.Top \ud835\udc9c).is_prime.mem_or_mem h with h h,\n    { obtain \u27e8nin, -\u27e9 := (wa \u27e8y, (opens.inf_le_left Va Vb y).2\u27e9), exact nin h },\n    { obtain \u27e8nin, -\u27e9 := (wb \u27e8y, (opens.inf_le_right Va Vb y).2\u27e9), exact nin h } },\n  { simp only [add_mul, map_add, pi.add_apply, ring_hom.map_mul, ext_iff_val, add_val],\n    obtain \u27e8nin1, hy1\u27e9 := (wa (opens.inf_le_left Va Vb y)),\n    obtain \u27e8nin2, hy2\u27e9 := (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, \u2190 subtype.val_eq_coe, add_comm, mul_comm sa sb], }\nend\n\n\n\nlemma mul_mem' (U : (opens (projective_spectrum.Top \ud835\udc9c))\u1d52\u1d56)\n  (a b : \u03a0 x : unop U, at x.1)\n  (ha : (is_locally_fraction \ud835\udc9c).pred a) (hb : (is_locally_fraction \ud835\udc9c).pred b) :\n  (is_locally_fraction \ud835\udc9c).pred (a * b) := \u03bb x,\nbegin\n  rcases ha x with \u27e8Va, ma, ia, ja, \u27e8ra, ra_mem\u27e9, \u27e8sa, sa_mem\u27e9, wa\u27e9,\n  rcases hb x with \u27e8Vb, mb, ib, jb, \u27e8rb, rb_mem\u27e9, \u27e8sb, sb_mem\u27e9, wb\u27e9,\n  refine \u27e8Va \u2293 Vb, \u27e8ma, mb\u27e9, opens.inf_le_left _ _ \u226b ia, ja + jb,\n    \u27e8ra * rb, set_like.mul_mem_graded ra_mem rb_mem\u27e9,\n    \u27e8sa * sb, set_like.mul_mem_graded sa_mem sb_mem\u27e9, \u03bb y, \u27e8\u03bb h, _, _\u27e9\u27e9,\n  { cases (y : projective_spectrum.Top \ud835\udc9c).is_prime.mem_or_mem h with h h,\n    { choose nin hy using wa \u27e8y, (opens.inf_le_left Va Vb y).2\u27e9, exact nin h },\n    { choose nin hy using wb \u27e8y, (opens.inf_le_right Va Vb y).2\u27e9, 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 \u22a2,\n    erw [mul_val, hy1, hy2],\n    simpa only [val_mk', mk_mul, \u2190 subtype.val_eq_coe] }\nend\n\nend section_subring\n\nsection\n\nopen section_subring\n\nvariable {\ud835\udc9c}\n/--The functions satisfying `is_locally_fraction` form a subring of all dependent functions\n`\u03a0 x : U, homogeneous_localization \ud835\udc9c x`.-/\ndef sections_subring (U : (opens (projective_spectrum.Top \ud835\udc9c))\u1d52\u1d56) : subring (\u03a0 x : unop U, at x.1) :=\n{ carrier := { f | (is_locally_fraction \ud835\udc9c).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 \ud835\udc9c):=\nsubsheaf_to_Types (is_locally_fraction \ud835\udc9c)\n\ninstance comm_ring_structure_sheaf_in_Type_obj (U : (opens (projective_spectrum.Top \ud835\udc9c))\u1d52\u1d56) :\n  comm_ring ((structure_sheaf_in_Type \ud835\udc9c).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 \ud835\udc9c) :=\n{ obj := \u03bb U, CommRing.of ((structure_sheaf_in_Type \ud835\udc9c).1.obj U),\n  map := \u03bb U V i,\n  { to_fun := ((structure_sheaf_in_Type \ud835\udc9c).1.map i),\n    map_zero' := rfl,\n    map_add' := \u03bb x y, rfl,\n    map_one' := rfl,\n    map_mul' := \u03bb 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 \ud835\udc9c \u22d9 (forget CommRing) \u2245 (structure_sheaf_in_Type \ud835\udc9c).1 :=\nnat_iso.of_components (\u03bb 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` \ud835\udc9c, valued in `CommRing`.-/\ndef Proj.structure_sheaf : sheaf CommRing (projective_spectrum.Top \ud835\udc9c) :=\n\u27e8structure_presheaf_in_CommRing \ud835\udc9c,\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 \ud835\udc9c).symm\n      (structure_sheaf_in_Type \ud835\udc9c).cond)\u27e9\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 \ud835\udc9c)) (i : V \u27f6 U)\n  (s : (Proj.structure_sheaf \ud835\udc9c).1.obj (op U)) (x : V) :\n  ((Proj.structure_sheaf \ud835\udc9c).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 \ud835\udc9c),\n  presheaf := (Proj.structure_sheaf \ud835\udc9c).1,\n  is_sheaf := (Proj.structure_sheaf \ud835\udc9c).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 \ud835\udc9c)) (x : projective_spectrum.Top \ud835\udc9c)\n  (hx : x \u2208 U) :\n  (Proj.structure_sheaf \ud835\udc9c).1.obj (op U) \u27f6 CommRing.of (at x) :=\n{ to_fun := \u03bb s, (s.1 \u27e8x, hx\u27e9 : _),\n  map_one' := rfl,\n  map_mul' := \u03bb _ _, rfl,\n  map_zero' := rfl,\n  map_add' := \u03bb _ _, 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 \ud835\udc9c) :\n  (Proj.structure_sheaf \ud835\udc9c).presheaf.stalk x \u27f6 CommRing.of (at x) :=\nlimits.colimit.desc (((open_nhds.inclusion x).op) \u22d9 (Proj.structure_sheaf \ud835\udc9c).1)\n  { X := _,\n    \u03b9 :=\n    { app := \u03bb U, open_to_localization \ud835\udc9c ((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 \ud835\udc9c)) (x : U) :\n  (Proj.structure_sheaf \ud835\udc9c).presheaf.germ x \u226b stalk_to_fiber_ring_hom \ud835\udc9c x =\n  open_to_localization \ud835\udc9c U x x.2 :=\nlimits.colimit.\u03b9_desc _ _\n\n@[simp] lemma stalk_to_fiber_ring_hom_germ' (U : opens (projective_spectrum.Top \ud835\udc9c))\n  (x : projective_spectrum.Top \ud835\udc9c) (hx : x \u2208 U) (s : (Proj.structure_sheaf \ud835\udc9c).1.obj (op U)) :\n  stalk_to_fiber_ring_hom \ud835\udc9c x\n    ((Proj.structure_sheaf \ud835\udc9c).presheaf.germ \u27e8x, hx\u27e9 s) = (s.1 \u27e8x, hx\u27e9 : _) :=\nring_hom.ext_iff.1 (germ_comp_stalk_to_fiber_ring_hom \ud835\udc9c U \u27e8x, hx\u27e9 : _) s\n\n@[simp] lemma stalk_to_fiber_ring_hom_germ (U : opens (projective_spectrum.Top \ud835\udc9c)) (x : U)\n  (s : (Proj.structure_sheaf \ud835\udc9c).1.obj (op U)) :\n  stalk_to_fiber_ring_hom \ud835\udc9c x ((Proj.structure_sheaf \ud835\udc9c).presheaf.germ x s) = s.1 x :=\nby { cases x, exact stalk_to_fiber_ring_hom_germ' \ud835\udc9c U _ _ _ }\n\nlemma homogeneous_localization.mem_basic_open (x : projective_spectrum.Top \ud835\udc9c) (f : at x) :\n  x \u2208 projective_spectrum.basic_open \ud835\udc9c f.denom :=\nby { rw projective_spectrum.mem_basic_open, exact f.denom_mem }\n\nvariable (\ud835\udc9c)\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 \ud835\udc9c) :\n  \u03a0 (f : at x),\n    (Proj.structure_sheaf \ud835\udc9c).1.obj (op (projective_spectrum.basic_open \ud835\udc9c f.denom)) :=\n\u03bb f, \u27e8\u03bb y, quotient.mk' \u27e8f.deg, \u27e8f.num, f.num_mem_deg\u27e9, \u27e8f.denom, f.denom_mem_deg\u27e9, y.2\u27e9,\n  \u03bb y, \u27e8projective_spectrum.basic_open \ud835\udc9c f.denom, y.2,\n    \u27e8\ud835\udfd9 _, \u27e8f.deg, \u27e8\u27e8f.num, f.num_mem_deg\u27e9, \u27e8f.denom, f.denom_mem_deg\u27e9,\n      \u03bb z, \u27e8z.2, rfl\u27e9\u27e9\u27e9\u27e9\u27e9\u27e9\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 \ud835\udc9c) :\n  (at x) \u2192 (Proj.structure_sheaf \ud835\udc9c).presheaf.stalk x :=\n\u03bb f, (Proj.structure_sheaf \ud835\udc9c).presheaf.germ\n  (\u27e8x, homogeneous_localization.mem_basic_open _ x f\u27e9 : 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 \ud835\udc9c) :\n  (Proj.structure_sheaf \ud835\udc9c).presheaf.stalk x \u2243+* CommRing.of (at x)  :=\nring_equiv.of_bijective (stalk_to_fiber_ring_hom _ x)\n\u27e8\u03bb z1 z2 eq1, begin\n  obtain \u27e8u1, memu1, s1, rfl\u27e9 := (Proj.structure_sheaf \ud835\udc9c).presheaf.germ_exist x z1,\n  obtain \u27e8u2, memu2, s2, rfl\u27e9 := (Proj.structure_sheaf \ud835\udc9c).presheaf.germ_exist x z2,\n  obtain \u27e8v1, memv1, i1, \u27e8j1, \u27e8a1, a1_mem\u27e9, \u27e8b1, b1_mem\u27e9, hs1\u27e9\u27e9 := s1.2 \u27e8x, memu1\u27e9,\n  obtain \u27e8v2, memv2, i2, \u27e8j2, \u27e8a2, a2_mem\u27e9, \u27e8b2, b2_mem\u27e9, hs2\u27e9\u27e9 := s2.2 \u27e8x, memu2\u27e9,\n  obtain \u27e8b1_nin_x, eq2\u27e9 := hs1 \u27e8x, memv1\u27e9,\n  obtain \u27e8b2_nin_x, eq3\u27e9 := hs2 \u27e8x, memv2\u27e9,\n  dsimp only at eq1 eq2 eq3,\n  erw [stalk_to_fiber_ring_hom_germ \ud835\udc9c u1 \u27e8x, memu1\u27e9 s1,\n    stalk_to_fiber_ring_hom_germ \ud835\udc9c u2 \u27e8x, memu2\u27e9 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 \u27e8\u27e8c, hc\u27e9, eq3\u27e9 := eq3,\n  simp only [\u2190 subtype.val_eq_coe] at eq3,\n  have eq3' : \u2200 (y : projective_spectrum.Top \ud835\udc9c)\n    (hy : y \u2208 projective_spectrum.basic_open \ud835\udc9c b1 \u2293\n      projective_spectrum.basic_open \ud835\udc9c b2 \u2293\n      projective_spectrum.basic_open \ud835\udc9c c),\n    (localization.mk a1\n      \u27e8b1, show b1 \u2209 y.as_homogeneous_ideal,\n        by rw \u2190projective_spectrum.mem_basic_open;\n          exact le_of_hom (opens.inf_le_left _ _ \u226b opens.inf_le_left _ _) hy\u27e9 :\n            localization.at_prime y.1.to_ideal) =\n    localization.mk a2\n      \u27e8b2, show b2 \u2209 y.as_homogeneous_ideal,\n        by rw \u2190projective_spectrum.mem_basic_open;\n        exact le_of_hom (opens.inf_le_left _ _ \u226b opens.inf_le_right _ _) hy\u27e9,\n  { intros y hy,\n    rw [localization.mk_eq_mk', is_localization.eq],\n    exact \u27e8\u27e8c, show c \u2209 y.as_homogeneous_ideal, by rw \u2190projective_spectrum.mem_basic_open;\n      exact le_of_hom (opens.inf_le_right _ _) hy\u27e9, eq3\u27e9 },\n  refine presheaf.germ_ext (Proj.structure_sheaf \ud835\udc9c).1\n    (projective_spectrum.basic_open _ b1 \u2293\n      projective_spectrum.basic_open _ b2 \u2293\n      projective_spectrum.basic_open _ c \u2293 v1 \u2293 v2)\n    \u27e8\u27e8\u27e8\u27e8b1_nin_x, b2_nin_x\u27e9, hc\u27e9, memv1\u27e9, memv2\u27e9\n    (opens.inf_le_left _ _ \u226b opens.inf_le_right _ _ \u226b i1) (opens.inf_le_right _ _ \u226b i2) _,\n  rw subtype.ext_iff_val,\n  ext1 y,\n  simp only [res_apply],\n  obtain \u27e8b1_nin_y, eq6\u27e9 := hs1 \u27e8_, le_of_hom (opens.inf_le_left _ _ \u226b opens.inf_le_right _ _) y.2\u27e9,\n  obtain \u27e8b2_nin_y, eq7\u27e9 := hs2 \u27e8_, le_of_hom (opens.inf_le_right _ _) y.2\u27e9,\n  simp only at eq6 eq7,\n  erw [eq6, eq7, quotient.eq],\n  change localization.mk _ _ = localization.mk _ _,\n  exact eq3' _ \u27e8\u27e8le_of_hom (opens.inf_le_left _ _ \u226b opens.inf_le_left _ _ \u226b\n      opens.inf_le_left _ _ \u226b opens.inf_le_left _ _) y.2,\n    le_of_hom (opens.inf_le_left _ _ \u226b opens.inf_le_left _ _ \u226b\n      opens.inf_le_left _ _ \u226b opens.inf_le_right _ _) y.2\u27e9,\n    le_of_hom (opens.inf_le_left _ _ \u226b opens.inf_le_left _ _ \u226b\n      opens.inf_le_right _ _) y.2\u27e9,\nend, function.surjective_iff_has_right_inverse.mpr \u27e8homogeneous_localization_to_stalk \ud835\udc9c x,\n  \u03bb f, begin\n    rw homogeneous_localization_to_stalk,\n    erw stalk_to_fiber_ring_hom_germ \ud835\udc9c\n      (projective_spectrum.basic_open \ud835\udc9c f.denom) \u27e8x, _\u27e9 (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\u27e9\u27e9\n\n/--`Proj` of a graded ring as a `LocallyRingedSpace`-/\ndef Proj.to_LocallyRingedSpace : LocallyRingedSpace :=\n{ local_ring := \u03bb x, @@ring_equiv.local_ring _\n    (show local_ring (at x), from infer_instance) _\n    (Proj.stalk_iso' \ud835\udc9c x).symm,\n  ..(Proj.to_SheafedSpace \ud835\udc9c) }\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* \u2192 Type* \u2192 Type*` along with a bimap which turns `F \u03b1 \u03b2` into\n`F \u03b1' \u03b2'` given two functions `\u03b1 \u2192 \u03b1'` and `\u03b2 \u2192 \u03b2'`. It further\n* respects the identity: `bimap id id = id`\n* composes in the obvious way: `(bimap f' g') \u2218 (bimap f g) = bimap (f' \u2218 f) (g' \u2218 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\u2080 u\u2081 u\u2082 v\u2080 v\u2081 v\u2082\n\nopen function\n\n/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/\nclass bifunctor (F : Type u\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082) :=\n(bimap : \u03a0 {\u03b1 \u03b1' \u03b2 \u03b2'}, (\u03b1 \u2192 \u03b1') \u2192 (\u03b2 \u2192 \u03b2') \u2192 F \u03b1 \u03b2 \u2192 F \u03b1' \u03b2')\nexport bifunctor ( bimap )\n\n/-- Bifunctor. This typeclass asserts that a lawless `bifunctor` is lawful. -/\nclass is_lawful_bifunctor (F : Type u\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082) [bifunctor F] :=\n(id_bimap : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), bimap id id x = x)\n(bimap_bimap : \u03a0 {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 \u03b2\u2080 \u03b2\u2081 \u03b2\u2082} (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b1\u2081 \u2192 \u03b1\u2082)\n  (g : \u03b2\u2080 \u2192 \u03b2\u2081) (g' : \u03b2\u2081 \u2192 \u03b2\u2082) (x : F \u03b1\u2080 \u03b2\u2080),\n  bimap f' g' (bimap f g x) = bimap (f' \u2218 f) (g' \u2218 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\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082} [bifunctor F]\n\nnamespace bifunctor\n\n/-- Left map of a bifunctor. -/\n@[reducible] def fst {\u03b1 \u03b1' \u03b2} (f : \u03b1 \u2192 \u03b1') : F \u03b1 \u03b2 \u2192 F \u03b1' \u03b2 := bimap f id\n\n/-- Right map of a bifunctor. -/\n@[reducible] def snd {\u03b1 \u03b2 \u03b2'} (f : \u03b2 \u2192 \u03b2') : F \u03b1 \u03b2 \u2192 F \u03b1 \u03b2' := bimap id f\n\nvariable [is_lawful_bifunctor F]\n\n@[higher_order fst_id]\nlemma id_fst : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), fst id x = x :=\n@id_bimap _ _ _\n\n@[higher_order snd_id]\nlemma id_snd : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), 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 {\u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081}\n  (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b2\u2080 \u2192 \u03b2\u2081) (x : F \u03b1\u2080 \u03b2\u2080) :\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 {\u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081}\n  (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b2\u2080 \u2192 \u03b2\u2081) (x : F \u03b1\u2080 \u03b2\u2080) :\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 {\u03b1 \u03b2\u2080 \u03b2\u2081 \u03b2\u2082}\n  (g : \u03b2\u2080 \u2192 \u03b2\u2081) (g' : \u03b2\u2081 \u2192 \u03b2\u2082) (x : F \u03b1 \u03b2\u2080) :\n  snd g' (snd g x) = snd (g' \u2218 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 := (\u03bb \u03b1 \u03b1' \u03b2 \u03b2 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 := (\u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (bimap f' f x : F \u03b2' \u03b1')) }\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 {\u03b1} : functor (F \u03b1) :=\n{ map := \u03bb _ _, snd }\n\n@[priority 10]\ninstance bifunctor.is_lawful_functor [is_lawful_bifunctor F] {\u03b1} : is_lawful_functor (F \u03b1) :=\nby refine {..}; intros; simp [functor.map] with functor_norm\n\nsection bicompl\n\nvariables (G : Type* \u2192 Type u\u2080) (H : Type* \u2192 Type u\u2081) [functor G] [functor H]\n\ninstance : bifunctor (bicompl F G H) :=\n{ bimap := \u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (bimap (map f) (map f') x : F (G \u03b1') (H \u03b2')) }\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\u2082 \u2192 Type*) [functor G]\n\ninstance : bifunctor (bicompr G F) :=\n{ bimap := \u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (map (bimap f f') x : G (F \u03b1' \u03b2')) }\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 := \u03bb X, rfun.r X,\n  R0 := \u03bb X, rfun.R0 X,\n  R1 := \u03bb X, by {simp only [subftype_coe_size], from rfun.R1 X},\n  R2 := \u03bb X Y, by {intros H, simp, apply rfun.R2, simp at H, apply H,},\n  R3 := \u03bb 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 : \u03b1 \u2192 \u03b2) (s : set \u03b1) : set \u03b2 :=\n-- {b | \u2203 a, a \u2208 s \u2227 f a = b}\n\n--let f := (embed.from_subftype R).f in \n--\u27e8\u03bb X, rfun.r X, \u03bb X, rfun.R0 X, \u03bb X, rfun.R1 X, \u03bb X Y, rfun.R2 X Y, \u03bb X Y, rfun.R3 X Y\u27e9 \n\n@[simp] def restrict_nested_pair {B : ftype} {R\u2080 R : set B} (h : R\u2080 \u2286 R) (rfun : rankfun (subftype R)) : rankfun (subftype R\u2080)  := \nlet f := embed.from_nested_pair h in \n{ \n  r := \u03bb X, rfun.r (f.img X),\n  R0 := \u03bb X, rfun.R0 (f.img X),\n  R1 := \u03bb X, by {rw \u2190f.on_size, from rfun.R1 (f.img X)},\n  R2 := \u03bb X Y hXY, rfun.R2 _ _ (f.on_subset hXY), \n  R3 := \u03bb X Y, by {have := rfun.R3 (f.img X) (f.img Y), rw [\u2190f.on_union, \u2190f.on_inter] at this, from this},\n}\n\n--\u27e8\u03bb X, rfun.r (f X), \u03bb X, rfun.R0 (f X), \u03bb X, rfun.R1 (f X), \u03bb X Y, rfun.R2 (f X) (f Y), \u03bb X Y, rfun.R3 (f X) (f Y)\u27e9 \n@[simp] def corestrict_subset {U : ftype} (R : set U) (M : rankfun U)  : rankfun (subftype R) := \nlet C := R\u1d9c, f := embed.from_subftype R in \n\u27e8 \n  \u03bb X_foo, M.r ((X_foo : set U) \u222a C) - M.r C,\n  \u03bb X, by {rw sub_nonneg, exact M.R2 C (X \u222a C) (subset_union_right X C)},\n  \u03bb X, by {simp only, linarith [M.R0 (X \u2229 C), M.R3 X C, M.R1 X, subftype_coe_size X]},\n  \u03bb X Y hXY, by {simp only, linarith [M.R2 (X \u222a C) (Y \u222a C) (subset_union_subset_left _ _ C (f.on_subset hXY))]}, \n  \u03bb X Y, by\n  {\n    suffices : M.r (coe (X \u222a Y) \u222a C) + M.r (coe (X \u2229 Y) \u222a C) \u2264 M.r (X \u222a C) + M.r (Y \u222a C), \n      by {simp only, linarith}, \n    simp only [subftype_coe_inter, subftype_coe_union], \n    have h := M.R3 (X \u222a C) (Y \u222a C), \n    rw [\u2190union_distrib_right, \u2190union_distrib_union_left] at h,  \n    assumption,\n  },\n\u27e9 \n\n@[simp] def corestrict_nested_pair {B : ftype} {R\u2080 R\u2081 : set B} (h : R\u2080 \u2286 R\u2081) (M : rankfun (subftype R\u2081)) : rankfun (subftype R\u2080)  := \nlet \n  r := M.r, \n  f := (embed.from_nested_pair h),  \n  \u03c6 := f.img, \n  C := (\u03c6 (set.univ))\u1d9c in \n\u27e8\n  \u03bb X, r (\u03c6 X \u222a C) - r C, \n  \u03bb X, by {rw sub_nonneg, exact M.R2 C (\u03c6 X \u222a C) (subset_union_right (\u03c6 X) C)}, \n  \u03bb X, by {simp only, linarith [f.on_size X, M.R0 ((\u03c6 X) \u2229 C), M.R3 (\u03c6 X) C, M.R1 (\u03c6 X)]}, \n  \u03bb X Y hXY, by {simp only, linarith [M.R2 ((\u03c6 X) \u222a C) ((\u03c6 Y) \u222a C) (subset_union_subset_left _ _ C (f.on_subset hXY))]}, \n  \u03bb X Y, by \n  {\n    simp only, \n    suffices : M.r (\u03c6 (X \u222a Y) \u222a C) + M.r (\u03c6 (X \u2229 Y) \u222a C) \u2264 M.r ((\u03c6 X) \u222a C) + M.r ((\u03c6 Y) \u222a C), by linarith, \n    have h := M.R3 ((f.img X) \u222a C) ((f.img Y) \u222a C), \n    rw [\u2190union_distrib_right, \u2190union_distrib_union_left, \u2190f.on_inter, \u2190f.on_union] at h, \n    from h, \n  },\n\u27e9\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 \u2192 Type\n| self                       : minor_on univ\n| restrict   (X : set U) {E : set U} : (X \u2286 E) \u2192 minor_on E \u2192 minor_on X\n| corestrict (X : set U) {E : set U} : (X \u2286 E) \u2192 minor_on E \u2192 minor_on X\nopen minor_on\n\n\ndef to_minor : \u03a0 {E : set U}, minor_on E \u2192 rankfun U \u2192 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 \u222a (univ \\ A)) - M.r (univ \\ A) :=\nby simp [to_minor]\n\nlemma switch_restrict_corestrict {M : rankfun U} (A Z : set U) (hAZ : A \u2286 Z) : \n  to_minor (restrict A hAZ ((corestrict Z (subset_univ Z)) self)) M = to_minor (corestrict A (subset_union_left A Z\u1d9c) ((restrict (A \u222a Z\u1d9c) (subset_univ (A \u222a Z\u1d9c))) self)) M :=\n  let f := (embed.from_subftype A).f, hAZc := subset_union_left A Z\u1d9c, hAZc_univ := subset_univ (A \u222a Z\u1d9c) in \n  begin\n    \n    ext X, \n    have set_eq : (A \u222a Z\u1d9c) \\ A = univ \\ Z \n      := by {rw [diff_eq, inter_distrib_right, \u2190compl_union, union_comm Z, \n                subset_iff_union_eq_left.mp hAZ], simp},\n    set M' := (to_minor (corestrict A hAZc (restrict (A \u222a Z\u1d9c) hAZc_univ self)) M) with hM', \n\n    have RHS : M'.r X = M.r (X \u222a ((A \u222a Z\u1d9c) \\ A)) - M.r ((A \u222a Z\u1d9c) \\ 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 \u2286 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 : \u2200 (J : set U) (hJ : J \u2286 A), (J \u222a (Z\\A))\u1d9c = (A \\ J) \u222a (univ \\ Z) := \n      \u03bb J hJ, by rw [compl_union, univ_diff, compl_diff, diff_eq, inter_distrib_left, \u2190compl_union, subset_iff_union_eq_left.mp (subset.trans hJ hAZ), inter_comm, union_comm], \n    have hset : size ((X:set U) \u2229 (Z \\ A)) = 0 := by \n    {\n      suffices : ((X:set U) \u2229 (Z \\ A)) = \u2205, \n      rw this, exact size_empty U,\n      have := coe_set_is_subset X, \n      tidy, \n    },\n    have hempty : (Z\\A)\u1d9c = A \u222a (univ \\ Z) := \n      by {rw [\u2190empty_union (Z\\A), hJ \u2205 (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) \u222a (Z\\A)) + M.r ((X \u222a (Z\\A))\u1d9c) - M.r univ) - (size (Z\\A) + M.r (Z\\A)\u1d9c - M.r univ )       \n            : by {simp [to_minor, dual], } \n       ... = size (X:set U) + M.r ((X \u222a (Z\\A))\u1d9c) - M.r  (Z\\A)\u1d9c                                                   \n            : by linarith [size_modular (X :set U) (Z\\A), hset, emb.on_size X]\n       ... = size (X:set U) + M.r ((A \\ X) \u222a (univ \\ Z)) - M.r (A \u222a (univ \\ Z))                                        \n            : by {congr', finish}\n       ... = size (X:set U) + (M.r ((A \\ X) \u222a (univ \\ Z)) - M.r (univ \\ Z)) - (M.r (A \u222a (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 \u2190switch_restrict_corestrict, assumption,         \n  end\n\nlemma dual_corestrict_restrict {M : rankfun U} (A Z : set U) (hAZ : A \u2286 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 \u2190(dual_dual M), rw [\u2190dual_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 [\u2190(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 [\u2190(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 \u2286 Z) : \n  to_minor (corestrict A hAZ ((restrict Z (subset_univ Z)) self)) M = to_minor (restrict A (subset_union_left A Z\u1d9c) ((corestrict (A \u222a Z\u1d9c) (subset_univ (A \u222a Z\u1d9c))) self)) M :=\n  by {nth_rewrite 0 \u2190(dual_dual M), rw [\u2190dual_restrict_corestrict, switch_restrict_corestrict, dual_corestrict_restrict, dual_dual]}\n\n\nlemma restrict_restrict (M : rankfun U) (A Z : set U) (hAZ : A \u2286 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 \u2286 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 \u2190(dual_dual M), \n    have := dual_restrict (dual M) A, \n    \n    --unfold to_minor at *,\n    \n    \n    \n    --\u2190dual_restrict, \n    /-let U' := subftype Z, \n    let expr := ((corestrict univ (subset_refl univ) self) : minor_on (univ : set U')),\n    let M\u2080 := to_minor expr, \n    have := corestrict_univ M\u2080 expr-/\n    --have := @corestrict_univ (subftype Z) M\u2080 univ expr, \n    --nth_rewrite 0 \u2190(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 \u2286 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' \u2286 A) (hAZ : A \u2286 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' \u2286 A) (hAZ : A \u2286 Z) : \n  to_minor (corestrict Z' hZ'A (reduced_expr A Z hAZ) ) M = to_minor (reduced_expr Z' (Z' \u222a (Z \\ A)) (subset_union_left Z' _)) M := \n  let  J  := Z' \u222a (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') \u222a (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, \u2190compl_union Z', \n          (subset_iff_union_eq_left.mp (subset.trans hZ'A hAZ)), compl_compl, union_comm Z\u1d9c, 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 \u222a (A \\ Z') \u222a (univ \\ Z)) - M.r (univ \\ Z) - (M.r ((A \\ Z') \u222a (univ \\ Z)) - M.r (univ \\ Z)) : rfl  \n      ...  = M.r (X \u222a (A \\ Z') \u222a (univ \\ Z)) - M.r ((A \\ Z') \u222a (univ \\ Z))                                : by linarith\n      ...  = M.r (X \u222a (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  \u2203 (Z : set U) (hZ : E \u2286 Z), \n  to_minor (reduced_expr E Z hZ) M = to_minor expr M := \nbegin\n  induction expr with X\u2081 E\u2081 hX\u2081E\u2081 minor_expr IH \n                    X\u2081 A\u2081 hX\u2081A\u2081 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 \u27e8Z, \u27e8hE\u2081Z, h\u27e9\u27e9,\n    use Z, use subset.trans hX\u2081E\u2081 hE\u2081Z, \n    rw \u2190 restriction_of_reduced,\n    dunfold to_minor,\n    rw h,\n  },\n  /-corestrict-/\n  {\n    rcases IH with \u27e8Z, \u27e8hA\u2081Z, h\u27e9\u27e9,\n    use X\u2081 \u222a (Z \\ A\u2081), use subset_union_left X\u2081 _,\n    rw \u2190corestriction_of_reduced _ _ _ hX\u2081A\u2081 hA\u2081Z,\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  (\u2203 (C D : set U) (hCD : C \u2229 D = \u2205),  \n    (C \u222a D)\u1d9c = E \n    \u2227 ((to_minor (contract_delete C D hCD) M) \u2245 (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  (\u2203 (C D : set U) (hCD : C \u2229 D = \u2205),  \n    (C \u222a D)\u1d9c = E \u2227\n    is_indep M C \u2227 is_coindep M D \n    \u2227 ((to_minor (contract_delete C D hCD) M) \u2245 (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) \u2192 \n  \u2203 z, z \u2208 Z \u2227 M.r X < M.r (X \u222a z) := \nlet \n    hcr    : Z \\ X \u2286 X \u222a Z         := subset.trans (diff_subset Z X) (subset_union_right X Z),\n    hr     : X \u222a Z \u2286 univ             :=  subset_univ (X \u222a Z),  \n    hdiff  : (X \u222a Z) \\ (Z \\ X) = X := union_diff_diff _ _,\n    hunion : (Z \\ X) \u222a X = X \u222a 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 \u222a Z then corestrict to Z-X\n  let M' := to_minor (corestrict (Z \\ X) hcr (restrict (X \u222a Z) hr self)) M, \n  -- simplified rank function of M' \n  have hrM' : \u2200 (J : subftype (Z \\ X)), M'.r J = M.r (J \u222a X) - M.r (X) := \n    by {intros J, calc _  = M.r (J \u222a ((X \u222a Z) \\ (Z \\ X))) - M.r ((X \u222a 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 \u2260 0 := by linarith [by calc M'.r univ = _ : hr'univ ... \u2265 M.r Z - M.r X : by linarith [M.R2 Z (X \u222a 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": "/-\nCopyright (c) 2022 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Asta H. From, Jannis Limperg\n-/\n\n-- This test checks whether the output of trace.aesop.proof is\n-- copy-and-pastable. When the test breaks because Aesop's output has changed,\n-- please copy-and-paste the output to All.split_cons\u2082 and check whether it\n-- still works.\n\nimport Aesop\n\n@[aesop safe [constructors, (cases (patterns := [All _ [], All _ (_ :: _)]))]]\ninductive All (P : \u03b1 \u2192 Prop) : List \u03b1 \u2192 Prop\n  | nil : All P []\n  | cons {x xs} : P x \u2192 All P xs \u2192 All P (x :: xs)\n\ntheorem All.split_cons (P : \u03b1 \u2192 Prop) (x : \u03b1) (xs : List \u03b1) (h : All P (x :: xs))\n  : P x \u2227 All P xs := by\n  set_option trace.aesop.proof true in\n  aesop\n\nset_option linter.unusedVariables false in\ntheorem All.split_cons\u2082 (P : \u03b1 \u2192 Prop) (x : \u03b1) (xs : List \u03b1) (h : All P (x :: xs))\n  : P x \u2227 All P xs :=\n      (fun (h_1 : All P (x :: xs)) =>\n          ((fun (h_2 : All P (x :: xs)) =>\n                (All.casesOn (P := P) (motive := fun a x_1 => x :: xs = a \u2192 HEq h x_1 \u2192 P x \u2227 All P xs) h_2\n                    (fun h_1 => List.noConfusion h_1) fun {x_1} {xs_1} a a_1 h_1 =>\n                    List.noConfusion h_1 fun head_eq =>\n                      Eq.ndrec (motive := fun {x_1} =>\n                        \u2200 (a : P x_1), xs = xs_1 \u2192 HEq h (All.cons (P := P) a a_1) \u2192 P x \u2227 All P xs)\n                        (fun a tail_eq =>\n                          Eq.ndrec (motive := fun {xs_1} =>\n                            \u2200 (a_1 : All P xs_1), HEq h (All.cons (P := P) a a_1) \u2192 P x \u2227 All P xs)\n                            (fun a_1 h_1 =>\n                              Eq.ndrec (motive := fun h => P x \u2227 All P xs)\n                                (of_eq_true (Eq.trans (congr (congrArg And (eq_true a)) (eq_true a_1)) (and_self True)))\n                                (Eq.symm (eq_of_heq h_1)))\n                            tail_eq a_1)\n                        head_eq a :\n                  x :: xs = x :: xs \u2192 HEq h h_2 \u2192 P x \u2227 All P xs))\n              h_1 :\n            x :: xs = x :: xs \u2192 HEq h h_1 \u2192 P x \u2227 All P xs))\n        h (Eq.refl (x :: xs)) (HEq.refl h)\n", "meta": {"author": "JLimperg", "repo": "aesop", "sha": "c68fb1d5a9172498230d81d95c61f6461bea6722", "save_path": "github-repos/lean/JLimperg-aesop", "path": "github-repos/lean/JLimperg-aesop/aesop-c68fb1d5a9172498230d81d95c61f6461bea6722/tests/golden/27.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7577943712746406, "lm_q2_score": 0.6297746213017459, "lm_q1q2_score": 0.4772396631940814}}
{"text": "\nuniverses u\n\ndef f {\u03b1 : Type u} [BEq \u03b1] (xs : List \u03b1) (y : \u03b1) : \u03b1 := 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\u27e8fun a b => a.key == b.key\u27e9\n\ntheorem ex1 : f (\u03b1 := S) [\u27e81, 2\u27e9, \u27e83, 4\u27e9, \u27e85, 6\u27e9] \u27e83, 0\u27e9 = \u27e83, 4\u27e9 :=\nrfl\n\ntheorem ex2 : f (\u03b1 := S) [\u27e81, 2\u27e9, \u27e83, 4\u27e9, \u27e85, 6\u27e9] \u27e84, 10\u27e9 = \u27e84, 10\u27e9 :=\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 \u2964 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) [\ud835\udca5 : SmallCategory J] [@FinCategory J \ud835\udca5] : @HasLimitsOfShape J \ud835\udca5 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 : \u2200 (J : Type w) {\ud835\udca5 : SmallCategory J} (_ : @FinCategory J \ud835\udca5), 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 \u2964 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) [\ud835\udca5 : SmallCategory J] [@FinCategory J \ud835\udca5] : @HasColimitsOfShape J \ud835\udca5 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 : \u2200 (J : Type w) {\ud835\udca5 : SmallCategory J} (_ : @FinCategory J \ud835\udca5), 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' \u2205 [WalkingParallelPairHom.id one].toFinset)\n  complete := by\n    rintro (_|_) <;> simp\n    \u00b7 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 \u27f6 j')\n    where\n  elems := by\n    cases' j' with j'\n    \u00b7 cases' j with j\n      \u00b7 exact {Hom.id none}\n      \u00b7 exact {Hom.term j}\n    \u00b7 by_cases some j' = j\n      \u00b7 rw [h]\n        exact {Hom.id j}\n      \u00b7 exact \u2205\n  complete := by\n    rintro (_|_)\n    \u00b7 cases j <;> simp\n    \u00b7 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 \u27f6 j') where\n  elems := by\n    cases' j with j\n    \u00b7 cases' j' with j'\n      \u00b7 exact {Hom.id none}\n      \u00b7 exact {Hom.init j'}\n    \u00b7 by_cases some j = j'\n      \u00b7 rw [h]\n        exact {Hom.id j'}\n      \u00b7 exact \u2205\n  complete := by\n    rintro (_|_)\n    \u00b7 cases j <;> simp\n    \u00b7 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  \u27e8fun _ _ => HasFiniteLimits.out _\u27e9\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  \u27e8fun _ _ => HasFiniteColimits.out _\u27e9\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 {\u03b1 \u03b2 \u03b3 : 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 : \u03b1) (i : spec.\u03b9) (t : spec.domain i) (oa oa' : oracle_comp spec \u03b1)\n  (ob ob' : \u03b1 \u2192 oracle_comp spec \u03b2) (oc : \u03b2 \u2192 oracle_comp spec \u03b3) (s : S) (f : \u03b1 \u2192 \u03b2)\n\nsection monad\n\nlemma support_simulate_map_bind (g : \u03b2 \u2192 \u03b3) : (simulate so (g <$> (oa >>= ob)) s).support =\n  \u22c3 x \u2208 (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  = \u22c3 x \u2208 (simulate so oa s).support, (simulate so (oc (f $ prod.fst x)) x.2).support :=\nbegin\n  refine set.ext (\u03bb 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 \u27e8\u03bb h, let \u27e8x, y, hy, hxy, hx\u27e9 := h in \u27e8y, hy, by simpa only [\u2190 hxy] using hx\u27e9,\n    \u03bb h, let \u27e8x, hx, hz\u27e9 := h in \u27e8(f x.1, x.2), x, hx, rfl, hz\u27e9\u27e9,\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 : \u03a0 (\u03b1 : Type), oracle_comp spec \u03b1 \u2192 S \u2192 set (\u03b1 \u00d7 S)}\n  (so : sim_oracle spec spec' S) (oa : oracle_comp spec \u03b1) (s : S)\n  (h_ret : \u2200 \u03b1 a s, supp \u03b1 (return a) s = {(a, s)})\n  (h_bind : \u2200 \u03b1 \u03b2 (oa : oracle_comp spec \u03b1) (ob : \u03b1 \u2192 oracle_comp spec \u03b2) s,\n    supp \u03b2 (oa >>= ob) s = \u22c3 x \u2208 (supp \u03b1 oa s), supp \u03b2 (ob $ prod.fst x) $ prod.snd x)\n  (h_query : \u2200 i t s, supp (spec.range i) (query i t) s = (so i (t, s)).support) :\n  (simulate so oa s).support = supp \u03b1 oa s :=\nbegin\n  induction oa using oracle_comp.induction_on with \u03b1 a \u03b1 \u03b2 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 : \u03a0 (\u03b1 : Type), oracle_comp spec \u03b1 \u2192 S \u2192 set \u03b1}\n  (so : sim_oracle spec spec' S) (oa : oracle_comp spec \u03b1) (s : S)\n  (h_ret : \u2200 \u03b1 a s, supp \u03b1 (return a) s = {a})\n  (h_bind : \u2200 \u03b1 \u03b2 (oa : oracle_comp spec \u03b1) (ob : \u03b1 \u2192 oracle_comp spec \u03b2) s,\n    supp \u03b2 (oa >>= ob) s = \u22c3 x \u2208 (simulate so oa s).support, supp \u03b2 (ob $ prod.fst x) $ prod.snd x)\n  (h_query : \u2200 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 \u03b1 oa s :=\nbegin\n  induction oa using oracle_comp.induction_on with \u03b1 a \u03b1 \u03b2 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, \u2190hob, 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 \u2192 Prop)\n  (s : S) (hs : P s) (oa : oracle_comp spec \u03b1) (x : \u03b1 \u00d7 S) (hx : x \u2208 (simulate so oa s).support)\n  (hso : \u2200 i t s, \u2200 x \u2208 (so i (t, s)).support, P s \u2192 P (prod.snd x)) : P x.2 :=\nbegin\n  induction oa using oracle_comp.induction_on with \u03b1 a \u03b1 \u03b2 oa ob hoa hob i' t' generalizing s,\n  { rw [support_simulate_return, set.mem_singleton_iff] at hx,\n    exact hx.symm \u25b8 hs },\n  { rw [mem_support_simulate_bind_iff] at hx,\n    obtain \u27e8a, s', ha, ha'\u27e9 := 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 \u2286 prod.fst \u207b\u00b9' oa.support :=\nbegin\n  rw [set.preimage],\n  induction oa using oracle_comp.induction_on with \u03b1 a \u03b1 \u03b2 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 (\u03bb x, set.Union_subset (\u03bb hx, _)),\n    simp only [support_bind, set.mem_Union, exists_prop],\n    refine \u03bb b hb, \u27e8x.1, hoa s hx, hob x.1 x.2 hb\u27e9 },\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 \u2286 oa.support :=\nbegin\n  refine (support_simulate' so oa s).symm \u25b8 \u03bb x hx, _,\n  obtain \u27e8y, hy, rfl\u27e9 := (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 : \u03b1 \u00d7 S) (hx : x \u2208 (simulate so oa s).support) :\n  x.1 \u2208 oa.support := by simpa using (support_simulate_subset_preimage_support so oa s hx)\n\nlemma mem_support_of_mem_support_simulate' (x : \u03b1)\n  (hx : x \u2208 (simulate' so oa s).support) : x \u2208 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\u209b` 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 : \u2200 i t s, prod.fst '' (so i (t, s)).support = \u22a4) :\n  (simulate' so oa s).support = oa.support :=\nbegin\n  refine set.eq_of_subset_of_subset (support_simulate'_subset_support so oa s) (\u03bb x hx, _),\n  induction oa using oracle_comp.induction_on with \u03b1 a \u03b1 \u03b2 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 \u22a2,\n    obtain \u27e8a, ha, hx\u27e9 := hx,\n    specialize hoa a ha s,\n    rw [support_simulate', set.mem_image] at hoa,\n    obtain \u27e8\u27e8a', s'\u27e9, ha', ha''\u27e9 := hoa,\n    exact \u27e8(a', s'), ha', hob a' x (let this : a = a' := ha''.symm in this \u25b8 hx) s'\u27e9 },\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 : \u2200 i t s s', prod.fst '' (so i (t, s)).support = prod.fst '' (so' i (t, s')).support)\n  (oa : oracle_comp spec \u03b1) (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 \u03b1 a \u03b1 \u03b2 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 \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n    { obtain \u27e8\u27e8a, t\u27e9, hoa', hob'\u27e9 := h,\n      have : \u2203 u, (a, u) \u2208 (simulate so oa s).support := \u27e8t, hoa'\u27e9,\n      rw [\u2190 mem_support_simulate'_iff_exists_state, hoa s s',\n        mem_support_simulate'_iff_exists_state] at this,\n      obtain \u27e8t', ht'\u27e9 := this,\n      exact \u27e8(a, t'), ht', hob a t t' \u25b8 hob'\u27e9 },\n    { obtain \u27e8\u27e8a, t\u27e9, hoa', hob'\u27e9 := h,\n      have : \u2203 u, (a, u) \u2208 (simulate so' oa s').support := \u27e8t, hoa'\u27e9,\n      rw [\u2190 mem_support_simulate'_iff_exists_state, \u2190 hoa s s',\n        mem_support_simulate'_iff_exists_state] at this,\n      obtain \u27e8t', ht'\u27e9 := this,\n      exact \u27e8(a, t'), ht', (hob a t' t).symm \u25b8 hob'\u27e9 } },\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 : \u2200 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 _ (\u03bb _ _ _ _ _, _) (\u03bb _ _ _, _),\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 : \u2200 i t s, (\u22c3 x \u2208 (so i (t, s)).support, (so' i (t, prod.snd x)).support) =\n    (so i (t, s)).support) (s : S) (oa : oracle_comp spec \u03b1) :\n  (simulate so oa s >>= \u03bb x, simulate so' oa x.2).support = (simulate so oa s).support :=\nbegin\n  refine symm (support_simulate_eq_induction so oa s (\u03bb \u03b1 a s, _) _ _),\n  { simp only [simulate_return, support_bind_return, support_return, set.image_singleton] },\n  { intros \u03b1 \u03b2 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] {\u03b6 : K}\n\nopen_locale number_field\n\nopen polynomial algebra\n\nlocal notation `R` := \ud835\udcde K\n\nnamespace is_cyclotomic_extension.rat\n\nvariables {p : \u2115+} {k : \u2115} [hp : fact (p : \u2115).prime] [char_zero K]\n\ninclude hp\n\nlemma zeta_sub_one_prime [is_cyclotomic_extension {p ^ (k + 1)} \u211a K]\n  (h\u03b6 : is_primitive_root \u03b6 \u2191(p ^ (k + 1))) (hodd : p \u2260 2) :\n  prime (\u27e8\u03b6 - 1, subalgebra.sub_mem _ (h\u03b6.is_integral (p ^ _).pos) (subalgebra.one_mem _)\u27e9 : R) :=\nbegin\n  letI := is_cyclotomic_extension.number_field {p ^ (k + 1)} \u211a K,\n  letI := is_cyclotomic_extension.is_galois (p ^ (k + 1)) \u211a K,\n  rw [\u2190 h\u03b6.sub_one_integral_power_basis_gen],\n  refine prime_of_norm_prime _,\n  rw [h\u03b6.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\u03b6.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 [\u2190 ring_equiv.coe_to_ring_hom]\nend\n\nlemma zeta_sub_one_prime' [h : is_cyclotomic_extension {p} \u211a K] (h\u03b6 : is_primitive_root \u03b6 p)\n  (hodd : p \u2260 2) :\n  prime (\u27e8\u03b6 - 1, subalgebra.sub_mem _ (h\u03b6.is_integral p.pos) (subalgebra.one_mem _)\u27e9 : 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 \u2192 Q) \u2192 (\u00ac Q \u2192 \u00ac 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 \u03b1 is nonempty to construct the strategy\nvariables {\u03b1 \u03b2 : Type*} [inhabited \u03b1] {G : game \u03b1 \u03b2} (\u03c3 : quasi_strategy G)\n\ndef choice_map (f : \u03b2 \u2192 set \u03b1) : \u03b2 \u2192 \u03b1 :=\n\u03bb b, if h : (f b).nonempty then h.some else inhabited.default\n\nlemma choice_map_def (f : \u03b2 \u2192 set \u03b1) : \u2200 b, (f  b).nonempty \u2192 choice_map f b \u2208 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 \u03b1 \u2192 \u03b1 :=\n  choice_map (\u03bb t, {a | t.concat a \u2208 \u03c3.positions})\n\nlemma strategy_map_of_quasi_strategy_def :\n  \u2200 t \u2208 \u03c3.positions, concat t (strategy_map_of_quasi_strategy \u03c3 t) \u2208 \u03c3.positions :=\nbegin\n  intros t tpos,\n  change strategy_map_of_quasi_strategy \u03c3 t \u2208 {a | t.concat a \u2208 \u03c3.positions},\n  unfold strategy_map_of_quasi_strategy,\n  apply choice_map_def,\n  by_cases G.turn t = \u03c3.player,\n  { exact (\u03c3.is_quasi_strategy t tpos).1 h, },\n  use inhabited.default,\n  exact (\u03c3.is_quasi_strategy t tpos).2 h inhabited.default,\nend\n\ndef level_by_level_subtree_of_quasi_strategy :\n  \u2115 \u2192 set (list \u03b1)\n| 0     := \u03bb t, t \u2208 \u03c3.positions \u2227 t = nil\n| (n+1) := \u03bb t, t \u2208 \u03c3.positions\n                \u2227 (t.init \u2208 \u03c3.positions\n                    \u2192 t.init \u2208 level_by_level_subtree_of_quasi_strategy n)\n                \u2227 (t.init \u2208 \u03c3.positions \u2192 G.turn t.init = \u03c3.player\n                    \u2192 t.ilast = strategy_map_of_quasi_strategy \u03c3 t.init)\n\ndef subtree_of_quasi_strategy : set (list \u03b1) :=\n  \u22c3 n, level_by_level_subtree_of_quasi_strategy \u03c3 n\n\nlemma subtree_of_quasi_strategy_def {G : game \u03b1 \u03b2} {\u03c3 : quasi_strategy G} {t : list \u03b1} :\n  t \u2208 subtree_of_quasi_strategy \u03c3 \u2194 t \u2208 level_by_level_subtree_of_quasi_strategy \u03c3 t.length :=\nbegin\n  unfold subtree_of_quasi_strategy,\n  rw mem_Union,\n  refine \u27e8_, \u03bb h, \u27e8t.length, h\u27e9\u27e9,\n  induction h : t.length generalizing t,\n  { rw eq_nil_of_length_eq_zero h,\n    rintros \u27e8k, hk\u27e9,\n    cases k,\n    exact hk,\n    use [hk.1, rfl], },\n  rintros \u27e8k, hk\u27e9,\n  cases k,\n  { rw hk.2 at h, contradiction, },\n  by_cases hinit : t.init \u2208 \u03c3.positions,\n  { have : t.init.length = n,\n    { change t.init.length = n.succ - 1,\n      rw \u2190 h,\n      apply length_init, },\n    use hk.1,\n    split,\n    { intros _, exact ih this \u27e8k, (hk.2.1 hinit)\u27e9, },\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 \u03b1} :\n  t \u2208 subtree_of_quasi_strategy \u03c3 \u2192 t \u2208 \u03c3.positions :=\nbegin\n  rw subtree_of_quasi_strategy_def,\n  cases t with h t,\n  { exact \u03bb h, h.1, },\n  exact \u03bb h, h.1,\nend\n\nlemma list.init_concat : \u2200 (l : list \u03b1) (a : \u03b1), (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 : \u2200 (l : list \u03b1) (a : \u03b1), (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 [\u2190 cons_append, \u2190 concat_append, append_nil],\n                                apply list.ilast_concat, }\n\nlemma list.nil_of_prefix_init {l : list \u03b1} : l <+: l.init \u2192 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 := \u03c3.player,\n  positions := subtree_of_quasi_strategy \u03c3,\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 \u03c3 nil,\n        rw subtree_of_quasi_strategy_def,\n        use strategy_map_of_quasi_strategy_def \u03c3 nil ht.1,\n        split,\n        { intros _,\n          change nil \u2208 level_by_level_subtree_of_quasi_strategy \u03c3 0,\n          use [ht.1, rfl], },\n        intros _ _,\n        exact rfl, },\n      intros turn a,\n      rw subtree_of_quasi_strategy_def,\n      use [(\u03c3.is_quasi_strategy nil ht.1).2 turn a],\n      split,\n      { intros _,\n        change nil \u2208 level_by_level_subtree_of_quasi_strategy \u03c3 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 \u2190 h,\n    rw hn at ht,\n    rcases ht with \u27e8ht, \u27e8tinit, tplay\u27e9\u27e9,\n    split,\n    { intros turn,\n      use strategy_map_of_quasi_strategy \u03c3 t,\n      rw subtree_of_quasi_strategy_def,\n      simp only [length_concat],\n      use strategy_map_of_quasi_strategy_def \u03c3 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 [(\u03c3.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 \u03c3) :=\nbegin\n  intros t tpos tturn,\n  use strategy_map_of_quasi_strategy \u03c3 t,\n  split,\n  { change t.concat (strategy_map_of_quasi_strategy \u03c3 t) \u2208 (subtree_of_quasi_strategy \u03c3),\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 \u2190 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 \u2208 subtree_of_quasi_strategy \u03c3 at tapos,\n  rw [subtree_of_quasi_strategy_def, length_concat] at tapos,\n  rcases tapos with \u27e8_, \u27e8_, h\u27e9\u27e9,\n  rw [list.init_concat, list.ilast_concat] at h,\n  exact h (position_of_position_subtree \u03c3 tpos) tturn,\nend\n\nlemma in_subtree_of_quasi_strategy (s : list \u03b1) :\n  s \u2208 \u03c3.positions \u2227 (s \u2260 nil \u2192 s.init \u2209 \u03c3.positions) \u2192 s \u2208 subtree_of_quasi_strategy \u03c3 :=\nbegin\n  rintros \u27e8hs, hsinit\u27e9,\n  rw subtree_of_quasi_strategy_def,\n  cases s,\n  { use hs, },\n  use hs,\n  have : s_hd :: s_tl \u2260 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 \u03b1) :\n  s_quasi_strategy \u03c3 s \u2192 s_quasi_strategy (strategy_of_quasi_strategy \u03c3) 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 \u2208 \u03c3.positions,\n  { apply position_of_position_subtree \u03c3 tpos, },\n  exact hs.2 t this,\nend\n\nvariables (X : (\u2115 \u2192 \u03b1) \u2192 \u03b2)\n\ntheorem winning_strategy_of_winning_quasi_strategy :\n  winning \u03c3 X \u2192 winning (strategy_of_quasi_strategy \u03c3) X :=\nbegin\n  intros winning,\n  intros f fplay,\n  change X f = \u03c3.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 `\u2124`.\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 \u2264 n) : ((n - m : \u2115) : R) = n - m :=\n  eq_sub_of_add_eq <| by rw [\u2190 cast_add, Nat.sub_add_cancel h]\n#align nat.cast_sub Nat.cast_sub\u2093\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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_pred : \u2200 {n}, 0 < n \u2192 ((n - 1 : \u2115) : 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 : \u2115) : (-[n+1] : R) = -(n + 1 : \u2115) :=\n  AddGroupWithOne.intCast_negSucc n\n#align int.cast_neg_succ_of_nat Int.cast_negSucc\u2093\n\n@[simp, norm_cast]\ntheorem cast_zero : ((0 : \u2124) : R) = 0 :=\n  (cast_ofNat 0).trans Nat.cast_zero\n#align int.cast_zero Int.cast_zero\u2093\n\n@[simp, norm_cast]\ntheorem cast_ofNat (n : \u2115) : ((n : \u2124) : R) = n :=\n  cast_ofNat _\n#align int.cast_coe_nat Int.cast_ofNat\u2093\n\n@[simp, norm_cast]\ntheorem cast_one : ((1 : \u2124) : R) = 1 :=\n  show (((1 : \u2115) : \u2124) : R) = 1 by simp\n#align int.cast_one Int.cast_one\u2093\n\n@[simp, norm_cast]\ntheorem cast_neg : \u2200 n, ((-n : \u2124) : R) = -n\n  | (0 : \u2115) => by erw [cast_zero, neg_zero]\n  | (n + 1 : \u2115) => 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\u2093\n\n@[simp]\ntheorem cast_subNatNat (m n) : ((Int.subNatNat m n : \u2124) : R) = m - n :=\n  by\n  unfold sub_nat_nat; cases e : n - m\n  \u00b7 simp only [sub_nat_nat, cast_of_nat]\n    simp [e, Nat.le_of_sub_eq_zero e]\n  \u00b7\n    rw [sub_nat_nat, cast_neg_succ_of_nat, Nat.add_one, \u2190 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\u2093\n\n#print Int.negOfNat_eq /-\ntheorem negOfNat_eq (n : \u2115) : negOfNat n = -(n : \u2124) := 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem cast_negOfNat (n : \u2115) : ((negOfNat n : \u2124) : 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 : \u2200 m n, ((m + n : \u2124) : R) = m + n\n  | (m : \u2115), (n : \u2115) => by simp [\u2190 Int.ofNat_add]\n  | (m : \u2115), -[n+1] => by erw [cast_sub_nat_nat, cast_coe_nat, cast_neg_succ_of_nat, sub_eq_add_neg]\n  | -[m+1], (n : \u2115) => 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, \u2190 Nat.cast_add, \u2190 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, \u2190 neg_add_rev, \u2190\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\u2093\n\n@[simp, norm_cast]\ntheorem cast_sub (m n) : ((m - n : \u2124) : R) = m - n := by simp [Int.sub_eq_add_neg, sub_eq_add_neg]\n#align int.cast_sub Int.cast_sub\u2093\n\n#print Int.ofNat_bit0 /-\n@[simp, norm_cast]\ntheorem ofNat_bit0 (n : \u2115) : (\u2191(bit0 n) : \u2124) = bit0 \u2191n :=\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 : \u2115) : (\u2191(bit1 n) : \u2124) = bit1 \u2191n :=\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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_bit0 (n : \u2124) : ((bit0 n : \u2124) : 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_bit1 (n : \u2124) : ((bit1 n : \u2124) : 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\u2093.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\u2093'. -/\ntheorem cast_two : ((2 : \u2124) : 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\u2093.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\u2093'. -/\ntheorem cast_three : ((3 : \u2124) : 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\u2093.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\u2093'. -/\ntheorem cast_four : ((4 : \u2124) : 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 `\u03b1 \u2192 \u03b1 \u2192 ... \u2192 \u03b1`. -/\ndef arity (\u03b1 : Type u) : nat \u2192 Type u\n| 0     := \u03b1\n| (n+1) := \u03b1 \u2192 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 (\u03b1 : Type u) (A : \u03b1 \u2192 pSet) : pSet\n\nnamespace pSet\n\n/-- The underlying type of a pre-set -/\ndef type : pSet \u2192 Type u\n| \u27e8\u03b1, A\u27e9 := \u03b1\n\n/-- The underlying pre-set family of a pre-set -/\ndef func : \u03a0 (x : pSet), x.type \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := A\n\ntheorem mk_type_func : \u03a0 (x : pSet), mk x.type x.func = x\n| \u27e8\u03b1, A\u27e9 := 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 (\u03bb\u03b1 z m \u27e8\u03b2, B\u27e9, (\u2200a, \u2203b, m a (B b)) \u2227 (\u2200b, \u2203a, m a (B b))) x y\n\ntheorem equiv.refl (x) : equiv x x :=\npSet.rec_on x $ \u03bb\u03b1 A IH, \u27e8\u03bba, \u27e8a, IH a\u27e9, \u03bba, \u27e8a, IH a\u27e9\u27e9\n\ntheorem equiv.euc {x} : \u03a0 {y z}, equiv x y \u2192 equiv z y \u2192 equiv x z :=\npSet.rec_on x $ \u03bb\u03b1 A IH y, pSet.cases_on y $ \u03bb\u03b2 B \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 \u27e8\u03b3\u03b2, \u03b2\u03b3\u27e9,\n\u27e8\u03bba, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a, \u27e8c, bc\u27e9 := \u03b2\u03b3 b in \u27e8c, IH a ab bc\u27e9,\n  \u03bbc, let \u27e8b, cb\u27e9 := \u03b3\u03b2 c, \u27e8a, ba\u27e9 := \u03b2\u03b1 b in \u27e8a, IH a ba cb\u27e9\u27e9\n\ntheorem equiv.symm {x y} : equiv x y \u2192 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\u27e8pSet.equiv, equiv.refl, \u03bbx y, equiv.symm, \u03bbx y z, equiv.trans\u27e9\n\nprotected def subset : pSet \u2192 pSet \u2192 Prop\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u2200a, \u2203b, equiv (A a) (B b)\n\ninstance : has_subset pSet := \u27e8pSet.subset\u27e9\n\ntheorem equiv.ext : \u03a0 (x y : pSet), equiv x y \u2194 (x \u2286 y \u2227 y \u2286 x)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 :=\n  \u27e8\u03bb\u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9, \u27e8\u03b1\u03b2, \u03bbb, let \u27e8a, h\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.symm h\u27e9\u27e9,\n    \u03bb\u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9, \u27e8\u03b1\u03b2, \u03bbb, let \u27e8a, h\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.symm h\u27e9\u27e9\u27e9\n\ntheorem subset.congr_left : \u03a0 {x y z : pSet}, equiv x y \u2192 (x \u2286 z \u2194 y \u2286 z)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 :=\n  \u27e8\u03bb\u03b1\u03b3 b, let \u27e8a, ba\u27e9 := \u03b2\u03b1 b, \u27e8c, ac\u27e9 := \u03b1\u03b3 a in \u27e8c, equiv.trans (equiv.symm ba) ac\u27e9,\n    \u03bb\u03b2\u03b3 a, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a, \u27e8c, bc\u27e9 := \u03b2\u03b3 b in \u27e8c, equiv.trans ab bc\u27e9\u27e9\n\ntheorem subset.congr_right : \u03a0 {x y z : pSet}, equiv x y \u2192 (z \u2286 x \u2194 z \u2286 y)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b3, \u0393\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 :=\n  \u27e8\u03bb\u03b3\u03b1 c, let \u27e8a, ca\u27e9 := \u03b3\u03b1 c, \u27e8b, ab\u27e9 := \u03b1\u03b2 a in \u27e8b, equiv.trans ca ab\u27e9,\n    \u03bb\u03b3\u03b2 c, let \u27e8b, cb\u27e9 := \u03b3\u03b2 c, \u27e8a, ab\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.trans cb (equiv.symm ab)\u27e9\u27e9\n\n/-- `x \u2208 y` as pre-sets if `x` is extensionally equivalent to a member\n  of the family `y`. -/\ndef mem : pSet \u2192 pSet \u2192 Prop\n| x \u27e8\u03b2, B\u27e9 := \u2203b, equiv x (B b)\ninstance : has_mem pSet.{u} pSet.{u} := \u27e8mem\u27e9\n\ntheorem mem.mk {\u03b1: Type u} (A : \u03b1 \u2192 pSet) (a : \u03b1) : A a \u2208 mk \u03b1 A :=\nshow mem (A a) \u27e8\u03b1, A\u27e9, from \u27e8a, equiv.refl (A a)\u27e9\n\ntheorem mem.ext : \u03a0 {x y : pSet.{u}}, (\u2200w:pSet.{u}, w \u2208 x \u2194 w \u2208 y) \u2192 equiv x y\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 h := \u27e8\u03bba, (h (A a)).1 (mem.mk A a),\n    \u03bbb, let \u27e8a, ha\u27e9 := (h (B b)).2 (mem.mk B b) in \u27e8a, equiv.symm ha\u27e9\u27e9\n\ntheorem mem.congr_right : \u03a0 {x y : pSet.{u}}, equiv x y \u2192 (\u2200{w:pSet.{u}}, w \u2208 x \u2194 w \u2208 y)\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9 w :=\n  \u27e8\u03bb\u27e8a, ha\u27e9, let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8b, equiv.trans ha hb\u27e9,\n    \u03bb\u27e8b, hb\u27e9, let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8a, equiv.euc hb ha\u27e9\u27e9\n\ntheorem equiv_iff_mem {x y : pSet.{u}} : equiv x y \u2194 (\u2200{w:pSet.{u}}, w \u2208 x \u2194 w \u2208 y) :=\n\u27e8mem.congr_right, match x, y with\n| \u27e8\u03b1, A\u27e9, \u27e8\u03b2, B\u27e9, h := \u27e8\u03bb a, h.1 (mem.mk A a), \u03bb b,\n  let \u27e8a, h\u27e9 := h.2 (mem.mk B b) in \u27e8a, h.symm\u27e9\u27e9\nend\u27e9\n\ntheorem mem.congr_left : \u03a0 {x y : pSet.{u}}, equiv x y \u2192 (\u2200{w : pSet.{u}}, x \u2208 w \u2194 y \u2208 w)\n| x y h \u27e8\u03b1, A\u27e9 := \u27e8\u03bb\u27e8a, ha\u27e9, \u27e8a, equiv.trans (equiv.symm h) ha\u27e9, \u03bb\u27e8a, ha\u27e9, \u27e8a, equiv.trans h ha\u27e9\u27e9\n\n/-- Convert a pre-set to a `set` of pre-sets. -/\ndef to_set (u : pSet.{u}) : set pSet.{u} := {x | x \u2208 u}\n\n/-- Two pre-sets are equivalent iff they have the same members. -/\ntheorem equiv.eq {x y : pSet} : equiv x y \u2194 to_set x = to_set y :=\nequiv_iff_mem.trans (set.ext_iff _ _).symm\n\ninstance : has_coe pSet (set pSet) := \u27e8to_set\u27e9\n\n/-- The empty pre-set -/\nprotected def empty : pSet := \u27e8ulift empty, \u03bbe, match e with end\u27e9\n\ninstance : has_emptyc pSet := \u27e8pSet.empty\u27e9\n\ntheorem mem_empty (x : pSet.{u}) : x \u2209 (\u2205:pSet.{u}) := \u03bbe, match e with end\n\n/-- Insert an element into a pre-set -/\nprotected def insert : pSet \u2192 pSet \u2192 pSet\n| u \u27e8\u03b1, A\u27e9 := \u27e8option \u03b1, \u03bbo, option.rec u A o\u27e9\n\ninstance : has_insert pSet pSet := \u27e8pSet.insert\u27e9\n\n/-- The n-th von Neumann ordinal -/\ndef of_nat : \u2115 \u2192 pSet\n| 0     := \u2205\n| (n+1) := pSet.insert (of_nat n) (of_nat n)\n\n/-- The von Neumann ordinal \u03c9 -/\ndef omega : pSet := \u27e8ulift \u2115, \u03bbn, of_nat n.down\u27e9\n\n/-- The separation operation `{x \u2208 a | p x}` -/\nprotected def sep (p : set pSet) : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8{a // p (A a)}, \u03bbx, A x.1\u27e9\n\ninstance : has_sep pSet pSet := \u27e8pSet.sep\u27e9\n\n/-- The powerset operator -/\ndef powerset : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8set \u03b1, \u03bbp, \u27e8{a // p a}, \u03bbx, A x.1\u27e9\u27e9\n\ntheorem mem_powerset : \u03a0 {x y : pSet}, y \u2208 powerset x \u2194 y \u2286 x\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u27e8\u03bb\u27e8p, e\u27e9, (subset.congr_left e).2 $ \u03bb\u27e8a, pa\u27e9, \u27e8a, equiv.refl (A a)\u27e9,\n  \u03bb\u03b2\u03b1, \u27e8{a | \u2203b, equiv (B b) (A a)}, \u03bbb, let \u27e8a, ba\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, b, ba\u27e9, ba\u27e9,\n    \u03bb\u27e8a, b, ba\u27e9, \u27e8b, ba\u27e9\u27e9\u27e9\n\n/-- The set union operator -/\ndef Union : pSet \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8\u03a3x, (A x).type, \u03bb\u27e8x, y\u27e9, (A x).func y\u27e9\n\ntheorem mem_Union : \u03a0 {x y : pSet.{u}}, y \u2208 Union x \u2194 \u2203 z:pSet.{u}, \u2203_:z \u2208 x, y \u2208 z\n| \u27e8\u03b1, A\u27e9 y :=\n  \u27e8\u03bb\u27e8\u27e8a, c\u27e9, (e : equiv y ((A a).func c))\u27e9,\n    have func (A a) c \u2208 mk (A a).type (A a).func, from mem.mk (A a).func c,\n    \u27e8_, mem.mk _ _, (mem.congr_left e).2 (by rwa mk_type_func at this)\u27e9,\n  \u03bb\u27e8\u27e8\u03b2, B\u27e9, \u27e8a, (e:equiv (mk \u03b2 B) (A a))\u27e9, \u27e8b, yb\u27e9\u27e9,\n    by rw \u2190(mk_type_func (A a)) at e; exact\n    let \u27e8\u03b2t, t\u03b2\u27e9 := e, \u27e8c, bc\u27e9 := \u03b2t b in \u27e8\u27e8a, c\u27e9, equiv.trans yb bc\u27e9\u27e9\n\n/-- The image of a function -/\ndef image (f : pSet.{u} \u2192 pSet.{u}) : pSet.{u} \u2192 pSet\n| \u27e8\u03b1, A\u27e9 := \u27e8\u03b1, \u03bba, f (A a)\u27e9\n\ntheorem mem_image {f : pSet.{u} \u2192 pSet.{u}} (H : \u2200{x y}, equiv x y \u2192 equiv (f x) (f y)) :\n  \u03a0 {x y : pSet.{u}}, y \u2208 image f x \u2194 \u2203z \u2208 x, equiv y (f z)\n| \u27e8\u03b1, A\u27e9 y := \u27e8\u03bb\u27e8a, ya\u27e9, \u27e8A a, mem.mk A a, ya\u27e9, \u03bb\u27e8z, \u27e8a, za\u27e9, yz\u27e9, \u27e8a, equiv.trans yz (H za)\u27e9\u27e9\n\n/-- Universe lift operation -/\nprotected def lift : pSet.{u} \u2192 pSet.{max u v}\n| \u27e8\u03b1, A\u27e9 := \u27e8ulift \u03b1, \u03bb\u27e8x\u27e9, lift (A x)\u27e9\n\n/-- Embedding of one universe in another -/\ndef embed : pSet.{max (u+1) v} := \u27e8ulift.{v u+1} pSet, \u03bb\u27e8x\u27e9, pSet.lift.{u (max (u+1) v)} x\u27e9\n\ntheorem lift_mem_embed : \u03a0 (x : pSet.{u}), pSet.lift.{u (max (u+1) v)} x \u2208 embed.{u v} :=\n\u03bbx, \u27e8\u27e8x\u27e9, equiv.refl _\u27e9\n\n/-- Function equivalence is defined so that `f ~ g` iff\n  `\u2200 x y, x ~ y \u2192 f x ~ g y`. This extends to equivalence of n-ary\n  functions. -/\ndef arity.equiv : \u03a0 {n}, arity pSet.{u} n \u2192 arity pSet.{u} n \u2192 Prop\n| 0     a b := equiv a b\n| (n+1) a b := \u2200 x y, equiv x y \u2192 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\u27e8f.1 x, f.2 _ _ $ equiv.refl x\u27e9\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 : \u03a0 {n} {a b c : resp n}, resp.equiv a b \u2192 resp.equiv c b \u2192 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 \u03bbx 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\u27e8resp.equiv, resp.refl, \u03bbx y h, resp.euc (resp.refl y) h, \u03bbx y z h1 h2, resp.euc h1 $ resp.euc (resp.refl z) h2\u27e9\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 : \u03a0 {n}, { f : resp n \u2192 arity Set.{u} n // \u2200 (a b : resp n), resp.equiv a b \u2192 f a = f b }\n| 0     := \u27e8\u03bba, \u27e6a.1\u27e7, \u03bba b h, quotient.sound h\u27e9\n| (n+1) := let F : resp (n + 1) \u2192 arity Set (n + 1) := \u03bba, @quotient.lift _ _ pSet.setoid\n    (\u03bbx, eval_aux.1 (a.f x)) (\u03bbb c h, eval_aux.2 _ _ (a.2 _ _ h)) in\n  \u27e8F, \u03bbb c h, funext $ @quotient.ind _ _ (\u03bbq, F b q = F c q) $ \u03bbz,\n  eval_aux.2 (resp.f b z) (resp.f c z) (h _ _ (equiv.refl z))\u27e9\n\n/-- An equivalence-respecting function yields an n-ary Set function. -/\ndef eval (n) : resp n \u2192 arity Set.{u} n := eval_aux.1\n\n@[simp] theorem eval_val {n f x} : (@eval (n+1) f : Set \u2192 arity Set n) \u27e6x\u27e7 = 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 \u2192 Type (u+1)\n| mk (f) : definable (resp.eval _ f)\nattribute [instance] definable.mk\n\ndef definable.eq_mk {n} (f) : \u03a0 {s : arity Set.{u} n} (H : resp.eval _ f = s), definable n s\n| ._ rfl := \u27e8f\u27e9\n\ndef definable.resp {n} : \u03a0 (s : arity Set.{u} n) [definable n s], resp n\n| ._ \u27e8f\u27e9 := f\n\ntheorem definable.eq {n} : \u03a0 (s : arity Set.{u} n) [H : definable n s], (@definable.resp n s H).eval _ = s\n| ._ \u27e8f\u27e9 := rfl\n\nend pSet\n\nnamespace classical\nopen pSet\n\nnoncomputable theorem all_definable : \u03a0 {n} (F : arity Set.{u} n), definable n F\n| 0     F := let p := @quotient.exists_rep pSet _ F in\n              definable.eq_mk \u27e8some p, equiv.refl _\u27e9 (some_spec p)\n| (n+1) (F : arity Set.{u} (n + 1)) := begin\n    have I := \u03bbx, (all_definable (F x)),\n    refine definable.eq_mk \u27e8\u03bbx:pSet, (@definable.resp _ _ (I \u27e6x\u27e7)).1, _\u27e9 _,\n    { dsimp [arity.equiv],\n      introsI x y h,\n      rw @quotient.sound pSet _ _ _ h,\n      exact (definable.resp (F \u27e6y\u27e7)).2 },\n    exact funext (\u03bbq, quotient.induction_on q $ \u03bbx,\n      by simp [resp.f]; exact @definable.eq _ (F \u27e6x\u27e7) (I \u27e6x\u27e7))\n  end\n\nend classical\n\nnamespace Set\nopen pSet\n\ndef mk : pSet \u2192 Set := quotient.mk\n\n@[simp] theorem mk_eq (x : pSet) : @eq Set \u27e6x\u27e7 (mk x) := rfl\n\ndef mem : Set \u2192 Set \u2192 Prop :=\nquotient.lift\u2082 pSet.mem\n  (\u03bbx y x' y' hx hy, propext (iff.trans (mem.congr_left hx) (mem.congr_right hy)))\n\ninstance : has_mem Set Set := \u27e8mem\u27e9\n\n/-- Convert a ZFC set into a `set` of sets -/\ndef to_set (u : Set.{u}) : set Set.{u} := {x | x \u2208 u}\n\nprotected def subset (x y : Set.{u}) :=\n\u2200 \u2983z\u2984, z \u2208 x \u2192 z \u2208 y\n\ninstance has_subset : has_subset Set :=\n\u27e8Set.subset\u27e9\n\ntheorem subset_iff : \u03a0 (x y : pSet), mk x \u2286 mk y \u2194 x \u2286 y\n| \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 := \u27e8\u03bbh a, @h \u27e6A a\u27e7 (mem.mk A a),\n  \u03bbh z, quotient.induction_on z (\u03bbz \u27e8a, za\u27e9, let \u27e8b, ab\u27e9 := h a in \u27e8b, equiv.trans za ab\u27e9)\u27e9\n\ntheorem ext {x y : Set.{u}} : (\u2200z:Set.{u}, z \u2208 x \u2194 z \u2208 y) \u2192 x = y :=\nquotient.induction_on\u2082 x y (\u03bbu v h, quotient.sound (mem.ext (\u03bbw, h \u27e6w\u27e7)))\n\ntheorem ext_iff {x y : Set.{u}} : (\u2200z:Set.{u}, z \u2208 x \u2194 z \u2208 y) \u2194 x = y :=\n\u27e8ext, \u03bbh, by simp [h]\u27e9\n\n/-- The empty set -/\ndef empty : Set := mk \u2205\ninstance : has_emptyc Set := \u27e8empty\u27e9\ninstance : inhabited Set := \u27e8\u2205\u27e9\n\n@[simp] theorem mem_empty (x) : x \u2209 (\u2205:Set.{u}) :=\nquotient.induction_on x pSet.mem_empty\n\ntheorem eq_empty (x : Set.{u}) : x = \u2205 \u2194 \u2200y:Set.{u}, y \u2209 x :=\n\u27e8\u03bbh, by rw h; exact mem_empty,\n\u03bbh, ext (\u03bby, \u27e8\u03bbyx, absurd yx (h y), \u03bby0, absurd y0 (mem_empty _)\u27e9)\u27e9\n\n/-- `insert x y` is the set `{x} \u222a y` -/\nprotected def insert : Set \u2192 Set \u2192 Set :=\nresp.eval 2 \u27e8pSet.insert, \u03bbu v uv \u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bbo, match o with\n   | some a := let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8some b, hb\u27e9\n   | none := \u27e8none, uv\u27e9\n   end, \u03bbo, match o with\n   | some b := let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8some a, ha\u27e9\n   | none := \u27e8none, uv\u27e9\n   end\u27e9\u27e9\n\ninstance : has_insert Set Set := \u27e8Set.insert\u27e9\n\n@[simp] theorem mem_insert {x y z : Set.{u}} : x \u2208 insert y z \u2194 x = y \u2228 x \u2208 z :=\nquotient.induction_on\u2083 x y z\n (\u03bbx y \u27e8\u03b1, A\u27e9, show x \u2208 pSet.mk (option \u03b1) (\u03bbo, option.rec y A o) \u2194\n    mk x = mk y \u2228 x \u2208 pSet.mk \u03b1 A, from\n  \u27e8\u03bbm, match m with\n  | \u27e8some a, ha\u27e9 := or.inr \u27e8a, ha\u27e9\n  | \u27e8none, h\u27e9 := or.inl (quotient.sound h)\n  end, \u03bbm, match m with\n  | or.inr \u27e8a, ha\u27e9 := \u27e8some a, ha\u27e9\n  | or.inl h := \u27e8none, quotient.exact h\u27e9\n  end\u27e9)\n\n@[simp] theorem mem_singleton {x y : Set.{u}} : x \u2208 @singleton Set.{u} Set.{u} _ _ y \u2194 x = y :=\niff.trans mem_insert \u27e8\u03bbo, or.rec (\u03bbh, h) (\u03bbn, absurd n (mem_empty _)) o, or.inl\u27e9\n\n@[simp] theorem mem_singleton' {x y : Set.{u}} : x \u2208 @insert Set.{u} Set.{u} _ y \u2205 \u2194 x = y := mem_singleton\n\n@[simp] theorem mem_pair {x y z : Set.{u}} : x \u2208 ({y, z} : Set) \u2194 x = y \u2228 x = z :=\niff.trans mem_insert $ iff.trans or.comm $ let m := @mem_singleton x y in \u27e8or.imp_left m.1, or.imp_left m.2\u27e9\n\n/-- `omega` is the first infinite von Neumann ordinal -/\ndef omega : Set := mk omega\n\n@[simp] theorem omega_zero : \u2205 \u2208 omega :=\nshow pSet.mem \u2205 pSet.omega, from \u27e8\u27e80\u27e9, equiv.refl _\u27e9\n\n@[simp] theorem omega_succ {n} : n \u2208 omega.{u} \u2192 insert n n \u2208 omega.{u} :=\nquotient.induction_on n (\u03bbx \u27e8\u27e8n\u27e9, h\u27e9, \u27e8\u27e8n+1\u27e9,\n  have Set.insert \u27e6x\u27e7 \u27e6x\u27e7 = Set.insert \u27e6of_nat n\u27e7 \u27e6of_nat n\u27e7, by rw (@quotient.sound pSet _ _ _ h),\n  quotient.exact this\u27e9)\n\n/-- `{x \u2208 a | p x}` is the set of elements in `a` satisfying `p` -/\nprotected def sep (p : Set \u2192 Prop) : Set \u2192 Set :=\nresp.eval 1 \u27e8pSet.sep (\u03bby, p \u27e6y\u27e7), \u03bb\u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bb\u27e8a, pa\u27e9, let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in \u27e8\u27e8b, by rwa \u2190(@quotient.sound pSet _ _ _ hb)\u27e9, hb\u27e9,\n   \u03bb\u27e8b, pb\u27e9, let \u27e8a, ha\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, by rwa (@quotient.sound pSet _ _ _ ha)\u27e9, ha\u27e9\u27e9\u27e9\n\ninstance : has_sep Set Set := \u27e8Set.sep\u27e9\n\n@[simp] theorem mem_sep {p : Set.{u} \u2192 Prop} {x y : Set.{u}} : y \u2208 {y \u2208 x | p y} \u2194 y \u2208 x \u2227 p y :=\nquotient.induction_on\u2082 x y (\u03bb\u27e8\u03b1, A\u27e9 y,\n  \u27e8\u03bb\u27e8\u27e8a, pa\u27e9, h\u27e9, \u27e8\u27e8a, h\u27e9, by rw (@quotient.sound pSet _ _ _ h); exact pa\u27e9,\n  \u03bb\u27e8\u27e8a, h\u27e9, pa\u27e9, \u27e8\u27e8a, by rw \u2190(@quotient.sound pSet _ _ _ h); exact pa\u27e9, h\u27e9\u27e9)\n\n/-- The powerset operation, the collection of subsets of a set -/\ndef powerset : Set \u2192 Set :=\nresp.eval 1 \u27e8powerset, \u03bb\u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8\u03bbp, \u27e8{b | \u2203a, p a \u2227 equiv (A a) (B b)},\n    \u03bb\u27e8a, pa\u27e9, let \u27e8b, ab\u27e9 := \u03b1\u03b2 a in \u27e8\u27e8b, a, pa, ab\u27e9, ab\u27e9,\n    \u03bb\u27e8b, a, pa, ab\u27e9, \u27e8\u27e8a, pa\u27e9, ab\u27e9\u27e9,\n   \u03bbq, \u27e8{a | \u2203b, q b \u2227 equiv (A a) (B b)},\n    \u03bb\u27e8a, b, qb, ab\u27e9, \u27e8\u27e8b, qb\u27e9, ab\u27e9,\n    \u03bb\u27e8b, qb\u27e9, let \u27e8a, ab\u27e9 := \u03b2\u03b1 b in \u27e8\u27e8a, b, qb, ab\u27e9, ab\u27e9\u27e9\u27e9\u27e9\n\n@[simp] theorem mem_powerset {x y : Set} : y \u2208 powerset x \u2194 y \u2286 x :=\nquotient.induction_on\u2082 x y (\u03bb\u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9,\n  show (\u27e8\u03b2, B\u27e9 : pSet) \u2208 (pSet.powerset \u27e8\u03b1, A\u27e9) \u2194 _,\n    by simp [mem_powerset, subset_iff])\n\ntheorem Union_lem {\u03b1 \u03b2 : Type u} (A : \u03b1 \u2192 pSet) (B : \u03b2 \u2192 pSet)\n  (\u03b1\u03b2 : \u2200a, \u2203b, equiv (A a) (B b)) : \u2200a, \u2203b, (equiv ((Union \u27e8\u03b1, A\u27e9).func a) ((Union \u27e8\u03b2, B\u27e9).func b))\n| \u27e8a, c\u27e9 := let \u27e8b, hb\u27e9 := \u03b1\u03b2 a in\n  begin\n    induction ea : A a with \u03b3 \u0393,\n    induction eb : B b with \u03b4 \u0394,\n    rw [ea, eb] at hb,\n    cases hb with \u03b3\u03b4 \u03b4\u03b3,\n    exact\n    let c : type (A a) := c, \u27e8d, hd\u27e9 := \u03b3\u03b4 (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    \u27e8\u27e8b, eq.rec d (eq.symm eb)\u27e9, this\u27e9\n  end\n\n/-- The union operator, the collection of elements of elements of a set -/\ndef Union : Set \u2192 Set :=\nresp.eval 1 \u27e8pSet.Union, \u03bb\u27e8\u03b1, A\u27e9 \u27e8\u03b2, B\u27e9 \u27e8\u03b1\u03b2, \u03b2\u03b1\u27e9,\n  \u27e8Union_lem A B \u03b1\u03b2, \u03bba, exists.elim (Union_lem B A (\u03bbb,\n    exists.elim (\u03b2\u03b1 b) (\u03bbc hc, \u27e8c, equiv.symm hc\u27e9)) a) (\u03bbb hb, \u27e8b, equiv.symm hb\u27e9)\u27e9\u27e9\n\nnotation `\u22c3` := Union\n\n@[simp] theorem mem_Union {x y : Set.{u}} : y \u2208 Union x \u2194 \u2203 z \u2208 x, y \u2208 z :=\nquotient.induction_on\u2082 x y (\u03bbx y, iff.trans mem_Union\n  \u27e8\u03bb\u27e8z, h\u27e9, \u27e8\u27e6z\u27e7, h\u27e9, \u03bb\u27e8z, h\u27e9, quotient.induction_on z (\u03bbz h, \u27e8z, h\u27e9) h\u27e9)\n\n@[simp] theorem Union_singleton {x : Set.{u}} : Union {x} = x :=\next $ \u03bby, by simp; exact \u27e8\u03bb\u27e8z, zx, yz\u27e9, by subst z; exact yz, \u03bbyx, \u27e8x, by simp, yx\u27e9\u27e9\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} := \u22c3 {x, y}\n\n/-- The binary intersection operation -/\nprotected def inter (x y : Set.{u}) : Set.{u} := {z \u2208 x | z \u2208 y}\n\n/-- The set difference operation -/\nprotected def diff (x y : Set.{u}) : Set.{u} := {z \u2208 x | z \u2209 y}\n\ninstance : has_union Set := \u27e8Set.union\u27e9\ninstance : has_inter Set := \u27e8Set.inter\u27e9\ninstance : has_sdiff Set := \u27e8Set.diff\u27e9\n\n@[simp] theorem mem_union {x y z : Set.{u}} : z \u2208 x \u222a y \u2194 z \u2208 x \u2228 z \u2208 y :=\niff.trans mem_Union\n \u27e8\u03bb\u27e8w, wxy, zw\u27e9, match mem_pair.1 wxy with\n  | or.inl wx := or.inl (by rwa \u2190wx)\n  | or.inr wy := or.inr (by rwa \u2190wy)\n  end, \u03bbzxy, match zxy with\n  | or.inl zx := \u27e8x, mem_pair.2 (or.inl rfl), zx\u27e9\n  | or.inr zy := \u27e8y, mem_pair.2 (or.inr rfl), zy\u27e9\n  end\u27e9\n\n@[simp] theorem mem_inter {x y z : Set.{u}} : z \u2208 x \u2229 y \u2194 z \u2208 x \u2227 z \u2208 y :=\n@@mem_sep (\u03bbz:Set.{u}, z \u2208 y)\n\n@[simp] theorem mem_diff {x y z : Set.{u}} : z \u2208 x \\ y \u2194 z \u2208 x \u2227 z \u2209 y :=\n@@mem_sep (\u03bbz:Set.{u}, z \u2209 y)\n\ntheorem induction_on {p : Set \u2192 Prop} (x) (h : \u2200x, (\u2200y \u2208 x, p y) \u2192 p x) : p x :=\nquotient.induction_on x $ \u03bbu, pSet.rec_on u $ \u03bb\u03b1 A IH, h _ $ \u03bby,\nshow @has_mem.mem _ _ Set.has_mem y \u27e6\u27e8\u03b1, A\u27e9\u27e7 \u2192 p y, from\nquotient.induction_on y (\u03bbv \u27e8a, ha\u27e9, by rw (@quotient.sound pSet _ _ _ ha); exact IH a)\n\ntheorem regularity (x : Set.{u}) (h : x \u2260 \u2205) : \u2203 y \u2208 x, x \u2229 y = \u2205 :=\nclassical.by_contradiction $ \u03bbne, h $ (eq_empty x).2 $ \u03bby,\ninduction_on y $ \u03bbz (IH : \u2200w:Set.{u}, w \u2208 z \u2192 w \u2209 x), show z \u2209 x, from \u03bbzx,\nne \u27e8z, zx, (eq_empty _).2 (\u03bbw wxz, let \u27e8wx, wz\u27e9 := mem_inter.1 wxz in IH w wz wx)\u27e9\n\n/-- The image of a (definable) set function -/\ndef image (f : Set \u2192 Set) [H : definable 1 f] : Set \u2192 Set :=\nlet r := @definable.resp 1 f _ in\nresp.eval 1 \u27e8image r.1, \u03bbx y e, mem.ext $ \u03bbz,\n  iff.trans (mem_image r.2) $ iff.trans (by exact\n   \u27e8\u03bb\u27e8w, h1, h2\u27e9, \u27e8w, (mem.congr_right e).1 h1, h2\u27e9,\n    \u03bb\u27e8w, h1, h2\u27e9, \u27e8w, (mem.congr_right e).2 h1, h2\u27e9\u27e9) $\n  iff.symm (mem_image r.2)\u27e9\n\ntheorem image.mk : \u03a0 (f : Set.{u} \u2192 Set.{u}) [H : definable 1 f] (x) {y} (h : y \u2208 x), f y \u2208 @image f H x\n| ._ \u27e8F\u27e9 x y := quotient.induction_on\u2082 x y $ \u03bb\u27e8\u03b1, A\u27e9 y \u27e8a, ya\u27e9, \u27e8a, F.2 _ _ ya\u27e9\n\n@[simp] theorem mem_image : \u03a0 {f : Set.{u} \u2192 Set.{u}} [H : definable 1 f] {x y : Set.{u}}, y \u2208 @image f H x \u2194 \u2203z \u2208 x, f z = y\n| ._ \u27e8F\u27e9 x y := quotient.induction_on\u2082 x y $ \u03bb\u27e8\u03b1, A\u27e9 y,\n  \u27e8\u03bb\u27e8a, ya\u27e9, \u27e8\u27e6A a\u27e7, mem.mk A a, eq.symm $ quotient.sound ya\u27e9,\n  \u03bb\u27e8z, hz, e\u27e9, e \u25b8 image.mk _ _ hz\u27e9\n\n/-- Kuratowski ordered pair -/\ndef pair (x y : Set.{u}) : Set.{u} := {{x}, {x, y}}\n\n/-- A subset of pairs `{(a, b) \u2208 x \u00d7 y | p a b}` -/\ndef pair_sep (p : Set.{u} \u2192 Set.{u} \u2192 Prop) (x y : Set.{u}) : Set.{u} :=\n{z \u2208 powerset (powerset (x \u222a y)) | \u2203a \u2208 x, \u2203b \u2208 y, z = pair a b \u2227 p a b}\n\n@[simp] theorem mem_pair_sep {p} {x y z : Set.{u}} : z \u2208 pair_sep p x y \u2194 \u2203a \u2208 x, \u2203b \u2208 y, z = pair a b \u2227 p a b := by\nrefine iff.trans mem_sep \u27e8and.right, \u03bbe, \u27e8_, e\u27e9\u27e9; exact\nlet \u27e8a, ax, b, bY, ze, pab\u27e9 := e in by rw ze; exact\nmem_powerset.2 (\u03bbu uz, mem_powerset.2 $ (mem_pair.1 uz).elim\n  (\u03bbua, by rw ua; exact \u03bbv vu, by rw mem_singleton.1 vu; exact mem_union.2 (or.inl ax))\n  (\u03bbuab, by rw uab; exact \u03bbv vu, (mem_pair.1 vu).elim\n    (\u03bbva, by rw va; exact mem_union.2 (or.inl ax))\n    (\u03bbvb, 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' \u2227 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' \u2208 ({x} : Set),\n      { rw h, simp },\n      simp at m, simp [*] } },\n  subst x',\n  have he : y = x \u2192 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' \u2208 ({x} : Set) := by rw \u2190 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 \u2208 x, b \u2208 y}` -/\ndef prod : Set.{u} \u2192 Set.{u} \u2192 Set.{u} := pair_sep (\u03bba b, true)\n\n@[simp] theorem mem_prod {x y z : Set.{u}} : z \u2208 prod x y \u2194 \u2203a \u2208 x, \u2203b \u2208 y, z = pair a b :=\nby simp [prod]\n\n@[simp] theorem pair_mem_prod {x y a b : Set.{u}} : pair a b \u2208 prod x y \u2194 a \u2208 x \u2227 b \u2208 y :=\n\u27e8\u03bbh, let \u27e8a', a'x, b', b'y, e\u27e9 := mem_prod.1 h in\n  match a', b', pair_inj e, a'x, b'y with ._, ._, \u27e8rfl, rfl\u27e9, ax, bY := \u27e8ax, bY\u27e9 end,\n\u03bb\u27e8ax, bY\u27e9, by simp; exact \u27e8a, ax, b, bY, rfl\u27e9\u27e9\n\n/-- `is_func x y f` is the assertion `f : x \u2192 y` where `f` is a ZFC function\n  (a set of ordered pairs) -/\ndef is_func (x y f : Set.{u}) : Prop :=\nf \u2286 prod x y \u2227 \u2200z:Set.{u}, z \u2208 x \u2192 \u2203! w, pair z w \u2208 f\n\n/-- `funs x y` is `y ^ x`, the set of all set functions `x \u2192 y` -/\ndef funs (x y : Set.{u}) : Set.{u} :=\n{f \u2208 powerset (prod x y) | is_func x y f}\n\n@[simp] theorem mem_funs {x y f : Set.{u}} : f \u2208 funs x y \u2194 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 \u2192 Set) [H : definable 1 f] : definable 1 (\u03bby, 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 \u2208 x` to `f a` -/\nnoncomputable def map (f : Set \u2192 Set) [H : definable 1 f] : Set \u2192 Set :=\nimage (\u03bby, pair y (f y))\n\n@[simp] theorem mem_map {f : Set \u2192 Set} [H : definable 1 f] {x y : Set} : y \u2208 map f x \u2194 \u2203z \u2208 x, pair z (f z) = y :=\nmem_image\n\ntheorem map_unique {f : Set.{u} \u2192 Set.{u}} [H : definable 1 f] {x z : Set.{u}} (zx : z \u2208 x) : \u2203! w, pair z w \u2208 map f x :=\n\u27e8f z, image.mk _ _ zx, \u03bby yx, let \u27e8w, wx, we\u27e9 := mem_image.1 yx, \u27e8wz, fy\u27e9 := pair_inj we in by rw[\u2190fy, wz]\u27e9\n\n@[simp] theorem map_is_func {f : Set \u2192 Set} [H : definable 1 f] {x y : Set} : is_func x y (map f x) \u2194 \u2200z \u2208 x, f z \u2208 y :=\n\u27e8\u03bb\u27e8ss, h\u27e9 z zx, let \u27e8t, t1, t2\u27e9 := h z zx in by rw (t2 (f z) (image.mk _ _ zx)); exact (pair_mem_prod.1 (ss t1)).right,\n\u03bbh, \u27e8\u03bby yx, let \u27e8z, zx, ze\u27e9 := mem_image.1 yx in by rw \u2190ze; exact pair_mem_prod.2 \u27e8zx, h z zx\u27e9,\n     \u03bbz, map_unique\u27e9\u27e9\n\nend Set\n\ndef Class := set Set\n\nnamespace Class\n\ninstance : has_subset Class     := \u27e8set.subset\u27e9\ninstance : has_sep Set Class    := \u27e8set.sep\u27e9\ninstance : has_emptyc Class     := \u27e8\u03bb a, false\u27e9\ninstance : has_insert Set Class := \u27e8set.insert\u27e9\ninstance : has_union Class      := \u27e8set.union\u27e9\ninstance : has_inter Class      := \u27e8set.inter\u27e9\ninstance : has_neg Class        := \u27e8set.compl\u27e9\ninstance : has_sdiff Class      := \u27e8set.diff\u27e9\n\n/-- Coerce a set into a class -/\ndef of_Set (x : Set.{u}) : Class.{u} := {y | y \u2208 x}\ninstance : has_coe Set Class := \u27e8of_Set\u27e9\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} \u2192 Prop) (A : Class.{u}) : Prop := \u2203x, \u2191x = A \u2227 p x\n\n/-- `A \u2208 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 := \u27e8Class.mem\u27e9\n\ntheorem mem_univ {A : Class.{u}} : A \u2208 univ.{u} \u2194 \u2203 x : Set.{u}, \u2191x = A :=\nexists_congr $ \u03bbx, 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 | \u2191y \u2208 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 \u2208 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 `\u22c3` := Union\n\ntheorem of_Set.inj {x y : Set.{u}} (h : (x : Class.{u}) = y) : x = y :=\nSet.ext $ \u03bbz, by change (x : Class.{u}) z \u2194 (y : Class.{u}) z; simp [*]\n\n@[simp] theorem to_Set_of_Set (p : Set.{u} \u2192 Prop) (x : Set.{u}) : to_Set p x \u2194 p x :=\n\u27e8\u03bb\u27e8y, yx, py\u27e9, by rwa of_Set.inj yx at py, \u03bbpx, \u27e8x, rfl, px\u27e9\u27e9\n\n@[simp] theorem mem_hom_left (x : Set.{u}) (A : Class.{u}) : (x : Class.{u}) \u2208 A \u2194 A x :=\nto_Set_of_Set _ _\n\n@[simp] theorem mem_hom_right (x y : Set.{u}) : (y : Class.{u}) x \u2194 x \u2208 y := iff.refl _\n\n@[simp] theorem subset_hom (x y : Set.{u}) : (x : Class.{u}) \u2286 y \u2194 x \u2286 y := iff.refl _\n\n@[simp] theorem sep_hom (p : Set.{u} \u2192 Prop) (x : Set.{u}) : (\u2191{y \u2208 x | p y} : Class.{u}) = {y \u2208 x | p y} :=\nset.ext $ \u03bby, Set.mem_sep\n\n@[simp] theorem empty_hom : \u2191(\u2205 : Set.{u}) = (\u2205 : Class.{u}) :=\nset.ext $ \u03bby, show _ \u2194 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) = \u2191(insert x y) :=\nset.ext $ \u03bbz, iff.symm Set.mem_insert\n\n@[simp] theorem union_hom (x y : Set.{u}) : (x : Class.{u}) \u222a y = (x \u222a y : Set.{u}) :=\nset.ext $ \u03bbz, iff.symm Set.mem_union\n\n@[simp] theorem inter_hom (x y : Set.{u}) : (x : Class.{u}) \u2229 y = (x \u2229 y : Set.{u}) :=\nset.ext $ \u03bbz, 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 $ \u03bbz, iff.symm Set.mem_diff\n\n@[simp] theorem powerset_hom (x : Set.{u}) : powerset.{u} x = Set.powerset x :=\nset.ext $ \u03bbz, iff.symm Set.mem_powerset\n\n@[simp] theorem Union_hom (x : Set.{u}) : Union.{u} x = Set.Union x :=\nset.ext $ \u03bbz, by refine iff.trans _ (iff.symm Set.mem_Union); exact\n\u27e8\u03bb\u27e8._, \u27e8a, rfl, ax\u27e9, za\u27e9, \u27e8a, ax, za\u27e9, \u03bb\u27e8a, ax, za\u27e9, \u27e8_, \u27e8a, rfl, ax\u27e9, za\u27e9\u27e9\n\n/-- The definite description operator, which is {x} if `{a | p a} = {x}`\n  and \u2205 otherwise -/\ndef iota (p : Set \u2192 Prop) : Class := Union {x | \u2200y, p y \u2194 y = x}\n\ntheorem iota_val (p : Set \u2192 Prop) (x : Set) (H : \u2200y, p y \u2194 y = x) : iota p = \u2191x :=\nset.ext $ \u03bby, \u27e8\u03bb\u27e8._, \u27e8x', rfl, h\u27e9, yx'\u27e9, by rwa \u2190((H x').1 $ (h x').2 rfl), \u03bbyx, \u27e8_, \u27e8x, rfl, H\u27e9, yx\u27e9\u27e9\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 \u2192 Prop) \u2192 Set` function. -/\ntheorem iota_ex (p) : iota.{u} p \u2208 univ.{u} :=\nmem_univ.2 $ or.elim (classical.em $ \u2203x, \u2200y, p y \u2194 y = x)\n (\u03bb\u27e8x, h\u27e9, \u27e8x, eq.symm $ iota_val p x h\u27e9)\n (\u03bbhn, \u27e8\u2205, by simp; exact set.ext (\u03bbz, \u27e8false.rec _, \u03bb\u27e8._, \u27e8x, rfl, H\u27e9, zA\u27e9, hn \u27e8x, H\u27e9\u27e9)\u27e9)\n\n/-- Function value -/\ndef fval (F A : Class.{u}) : Class.{u} := iota (\u03bby, to_Set (\u03bbx, F (Set.pair x y)) A)\ninfixl `\u2032`:100 := fval\n\ntheorem fval_ex (F A : Class.{u}) : F \u2032 A \u2208 univ.{u} := iota_ex _\n\nend Class\n\nnamespace Set\n\n@[simp] theorem map_fval {f : Set.{u} \u2192 Set.{u}} [H : pSet.definable 1 f] {x y : Set.{u}} (h : y \u2208 x) :\n  (Set.map f x \u2032 y : Class.{u}) = f y :=\nClass.iota_val _ _ (\u03bbz, by simp; exact\n  \u27e8\u03bb\u27e8w, wz, pr\u27e9, let \u27e8wy, fw\u27e9 := Set.pair_inj pr in by rw[\u2190fw, wy],\n  \u03bbe, by cases e; exact \u27e8_, h, rfl\u27e9\u27e9)\n\nvariables (x : Set.{u}) (h : \u2205 \u2209 x)\n\n/-- A choice function on the set of nonempty sets `x` -/\nnoncomputable def choice : Set := @map (\u03bby, classical.epsilon (\u03bbz, z \u2208 y)) (classical.all_definable _) x\n\ninclude h\ntheorem choice_mem_aux (y : Set.{u}) (yx : y \u2208 x) : classical.epsilon (\u03bbz:Set.{u}, z \u2208 y) \u2208 y :=\n@classical.epsilon_spec _ (\u03bbz:Set.{u}, z \u2208 y) $ classical.by_contradiction $ \u03bbn, h $\nby rwa \u2190((eq_empty y).2 $ \u03bbz zx, n \u27e8z, zx\u27e9)\n\ntheorem choice_is_func : is_func x (Union x) (choice x) :=\n(@map_is_func _ (classical.all_definable _) _ _).2 $ \u03bby yx, by simp; exact \u27e8y, yx, choice_mem_aux x h y yx\u27e9\n\ntheorem choice_mem (y : Set.{u}) (yx : y \u2208 x) : (choice x \u2032 y : Class.{u}) \u2208 (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^\u03c9)) \u00d7 \u03c9 \u2192 2 -/\n\n/- The underlying type of the Cohen poset is the type of finite partial functions from (set $ set \u03c9) \u00d7 \u03c9 \u2192 Prop -/\nvariable {\u03b7 : cardinal}\n\ndef cohen_poset := {f : ((pSet.ordinal.mk \u03b7.ord).type \u00d7 \u2115) \u2192. Prop | set.finite (pfun.dom f)}\n\n-- TODO replace all instances of set $ set \u2115 with a generic \"B\"\nnoncomputable instance B_decidable_eq : decidable_eq (set $ set \u2115) := \u03bb _ _, classical.prop_decidable _\n\nnamespace pfun\n/- Two partial functions are equal if their graphs are equal -/\nlemma ext_graph {\u03b1 \u03b2 : Type*} (f g : \u03b1 \u2192. \u03b2) (h_graph : f.graph = g.graph) : f = g :=\n  pfun.ext $ \u03bb _ _, iff_of_eq (congr_fun h_graph (_,_))\n\nlemma graph_empty_iff_dom_empty {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) : f.graph = \u2205 \u2194 f.dom = \u2205 :=\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 {\u03b1 \u03b2 : Type*} (\u0393 : set (\u03b1 \u00d7 \u03b2)) : Prop :=\n  \u2200 a b\u2081 b\u2082, (a, b\u2081) \u2208 \u0393 \u2192 (a, b\u2082) \u2208 \u0393 \u2192 b\u2081 = b\u2082\n\nlemma congr_arg {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) : \u2200 {x} {y} (h\u2081 : x \u2208 f.dom) (h\u2082 : y \u2208 f.dom)\n  (h_eq : x = y), fn f x h\u2081 = fn f y h\u2082 :=\nby intros; congr; assumption\n\nlemma functional_subset {\u03b1 \u03b2 : Type*} (\u0393 \u0393': set (\u03b1 \u00d7 \u03b2)) (h_\u0393' : \u0393' \u2286 \u0393) (h_\u0393 : functional \u0393) : functional \u0393' :=\n  \u03bb _ _ _ _ _, by apply h_\u0393; tidy\n\n/-- The graph of a pfun is always functional -/\nlemma graph_functional {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) : functional f.graph := by tidy\n\n/-- Given a partial functional relation, turn it into a pfun -/\nnoncomputable def of_graph {\u03b1 \u03b2 : Type*} (\u0393 : set (\u03b1 \u00d7 \u03b2)) (h_\u0393 : functional \u0393) : \u03b1 \u2192. \u03b2 :=\n  \u03bb a, \u27e8\u2203 c \u2208 \u0393, (prod.fst c) = a, \u03bb h, @prod.snd \u03b1 \u03b2 $ (classical.indefinite_description _ h).val\u27e9\n\nlemma of_graph_property {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) (a : \u03b1) (h : \u2203 c \u2208 \u0393, (prod.fst c) = a) : \u2203 (H : \u0393 (classical.indefinite_description _ h)), (classical.indefinite_description _ h).val.fst = a :=\n  by apply (classical.indefinite_description _ h).property\n\nlemma of_graph_get {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) (a : \u03b1) : \u2200 h,\n(of_graph \u0393 h_\u0393 a).get h = (classical.indefinite_description _ h).val.snd :=\n  by intro; refl\n\nlemma of_graph_val {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) (a : \u03b1) (h : \u2203 c \u2208 \u0393, (prod.fst c) = a) (c' \u2208 \u0393) (h' : c'.1 = a) :\n  @prod.snd \u03b1 \u03b2 (classical.indefinite_description _ h).val = c'.snd :=\nbegin\n  let c'', swap, change (prod.snd c'' = c'.snd),\n  apply h_\u0393 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 {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) : (of_graph \u0393 h_\u0393).graph = \u0393 :=\nbegin\n  ext, rcases x with \u27e8a,b\u27e9, 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 _ _ \u0393 _ a _ (a,b) _;\n  try{assumption}; refl\nend\n\n@[simp]lemma of_graph_graph {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} : of_graph (f.graph) (graph_functional f) = f :=\n  by apply ext_graph; rw[graph_of_graph]\n\n@[simp]lemma dom_of_graph {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) : (of_graph \u0393 h_\u0393).dom = (prod.fst '' \u0393) :=\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 {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (p : \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) (h_\u0393' : functional $ \u0393 \u222a {p}) : (of_graph (\u0393 \u222a {p}) h_\u0393').dom = (of_graph \u0393 h_\u0393).dom \u222a {p.fst} :=\n  by simp[dom_of_graph, set.image_insert_eq]\n\nlemma in_dom_of_in_graph {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} : \u2200 {a} {b}, (a,b) \u2208 f.graph \u2192 a \u2208 f.dom :=\n  by {intros a b H, apply (pfun.dom_iff_graph _ a).mpr, exact \u27e8b,H\u27e9}\n\nlemma lift_graph' {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} {a : \u03b1} {b : \u03b2} (h_a : a \u2208 f.dom) : (a,b) \u2208 f.graph \u2194 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 \u03b7) :=\n{ le := \u03bb f g, g.val.graph \u2286 f.val.graph,\n  lt := \u03bb f g, g.val.graph \u2286 f.val.graph \u2227 \u00ac f.val.graph \u2286 g.val.graph,\n  le_refl := \u03bb _, by unfold has_le.le,\n  le_trans := by {intros, apply set.subset.trans, exact a_2, assumption},\n  lt_iff_le_not_le := \u03bb _ _, iff.refl _,\n  le_antisymm := \u03bb 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 {\u03b1 : Type*} [partial_order \u03b1] (a b : \u03b1) := \u00ac \u2203 c, c \u2264 a \u2227 c \u2264 b\n\ndef antichain {\u03b1 : Type*} [partial_order \u03b1] (s : set \u03b1) := \u2200 x \u2208 s, \u2200 y \u2208 s, (x \u2260 y) \u2192 incompatible x y\n\nlemma antichain_subset {\u03b1 : Type*} [partial_order \u03b1] {s s' : set \u03b1} {h : s' \u2286 s} {hs : antichain s} : antichain s' :=\nby {intros _ _ _ _, intro H, apply hs _ _ _ _, tidy}\n\ndef countable_chain_condition (\u03b1 : Type*) [partial_order \u03b1] := \u2200 s : set \u03b1, antichain s \u2192 set.countable s\n\n@[simp]lemma univ_singletons {\u03b1 : Type*} :  set.Union (\u03bb a, {a}) = (set.univ : set \u03b1) :=\nby tidy\n\nlemma set_is_union_of_fibers {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) : s = set.Union (\u03bb b, f \u207b\u00b9'{b} \u2229 s) := by ext; simp\n\nlemma univ_is_union_of_fibers {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) : @set.univ \u03b1 = set.Union (\u03bb b, f\u207b\u00b9' {b}) :=\n  begin [smt] eblast_using [set.preimage_Union, @set.preimage_univ \u03b1 \u03b2 f, univ_singletons] end\n\nlemma countable_of_injection_to_countable {\u03b1 \u03b2 : Type*} {s : set \u03b1} {s' : set \u03b2} (f : s \u2192 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 \u27e8this_w \u2218 f,_\u27e9, exact function.injective_comp (this_h) hf\nend\n\nlemma countable_of_bijection_with_countable {\u03b1 \u03b2 : Type*} {s : set \u03b1} {s' : set \u03b2} {f : s \u2192 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 {\u03b1 \u03b2 : Type*} {s : set \u03b1} {s' : set \u03b2}\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 {\u03b1 : Type*} (s : set \u03b1) : equiv s (@set.univ s) :=\nby {refine \u27e8\u03bb x, \u27e8x, (by trivial)\u27e9, \u03bb x, x.val, _, _\u27e9, tidy}\n\n/- an (s : set \u03b1) is countable if (set.univ : set s) is countable -/\nlemma countable_of_countable_univ {\u03b1 : Type*} (s : set \u03b1) : set.countable s \u2194 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 {\u03b1 : Type*} {s' : set \u03b1} {s : set \u03b1} {t : set s'} (h : s = (subtype.val '' t)) {h_ctbl : set.countable s} : set.countable t :=\nbegin\n  let f : t \u2192 s := \u03bb x,\n    begin refine \u27e8x.val, _\u27e9, 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\u2081 a\u2082 a, cases a\u2082, cases a\u2081, cases a\u2081_val, cases a\u2082_val, simp at *, assumption\nend\n\nlemma countable_of_countable_fibers {\u03b1 \u03b2 : Type*} (s : set \u03b1) (f : s \u2192 \u03b2) [encodable \u03b2] (H : \u2200 b : \u03b2, set.countable (f \u207b\u00b9' {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' {\u03b1 \u03b2 : Type*} (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) [encodable \u03b2] (H : \u2200 b : \u03b2, set.countable ((f \u207b\u00b9' {b}) \u2229 s)) : set.countable s :=\nby {rw[set_is_union_of_fibers f s], exact set.countable_Union H}\n\nlemma countable_of_countable_fibers'' {\u03b1 \u03b2 : Type*} (s : set \u03b1) (f : s \u2192 \u03b2) [encodable \u03b2] (H : \u2200 b : \u03b2, set.countable ((f \u207b\u00b9' {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 : \u00ac 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 \u27e8Prop_to_bool,by {intro b, cases b, exact false, exact true},_,_\u27e9,\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 \u03b7) \u2192 \u2115 :=\n  \u03bb p, finset.card $ set.finite.to_finset p.property\n\nlemma size_of_domain_fiber {n} {p : @cohen_poset \u03b7} (h : p \u2208 @size_of_domain \u03b7 \u207b\u00b9' {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 \u03b7)) (b) (m) := (b,m) \u2208 (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 : \u2115) : set (@cohen_poset \u03b7) :=\n  {p : (@cohen_poset \u03b7) | \u2203 b, is_defined p b m}\n\nnamespace finset\n\nlemma empty_of_empty {\u03b1 : Type*} {s : set \u03b1} {h : set.finite s} : set.finite.to_finset h = \u2205 \u2192 s = \u2205 :=\nbegin\n  intro H, rw[set.eq_empty_iff_forall_not_mem], intros x Hx,\n  suffices : x \u2208 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 \u03b7)} (h : size_of_domain p = 0) : p.val.dom = \u2205 :=\nbegin\n  have : set.finite.to_finset p.property = \u2205, 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 \u03b7)} (h : size_of_domain p \u2260 0) : nonempty p.val.dom :=\nbegin\n  have : set.finite.to_finset p.property \u2260 \u2205, 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 \u27e8(by assumption), this\u27e9},\n    exact finset.card_eq_zero.mpr h},\n  have := finset.exists_mem_of_ne_empty this, cases this, apply nonempty.intro,\n  refine \u27e8this_w,_\u27e9, cases this_w, cases p, simp at this_h, assumption\nend\n\nlemma nonempty_domain_defined (p : (@cohen_poset \u03b7)) (h : 0 < size_of_domain p) : \u2203 m,\n  is_defined_at m p :=\nbegin\n  suffices : nonempty p.val.dom, by {have := classical.choice this, cases this,\n  refine \u27e8this_val.2, \u27e8this_val.1,_\u27e9\u27e9, 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 \u03b7 \u207b\u00b9' {n} \u2286 \u22c3 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 \u27e8this.val.snd, \u27e8this.val.fst, (by tidy)\u27e9\u27e9},\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 \u03b7 \u207b\u00b9' {0} :=\nbegin\n  refine \u27e8\u03bb a b, _\u27e9, rcases a with \u27e8\u27e8p_a, H_f_a\u27e9, H_a\u27e9, rcases b with \u27e8\u27e8p_b, H_f_b\u27e9, H_b\u27e9, congr,\n  have := (pfun.graph_empty_iff_dom_empty _).mpr (@empty_of_size_of_domain_0 \u03b7 _\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 \u03b7 _\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 {\u03b1 : Type*} {s s' : set \u03b1} (h_sub : s \u2286 s') [subsingleton s'] : subsingleton s :=\nbegin\n  refine \u27e8\u03bb a b, _\u27e9, have : \u2200 a b : s', a = b, by apply subsingleton.elim,\n  let f : s \u2192 s' := \u03bb x, \u27e8x.val, h_sub _\u27e9,\n  suffices : f a = f b, by tidy, apply this, exact x.property\nend\n\nlemma size_of_domain_0_inter_subsingleton : \u2200 (a : set (@cohen_poset \u03b7)), subsingleton \u21a5((size_of_domain \u207b\u00b9' {0}) \u2229 a) :=\n\u03bb a, subsingleton_of_subset_of_subsingleton\n     (by apply set.inter_subset_left : size_of_domain \u207b\u00b9' {0} \u2229 a \u2286 size_of_domain \u207b\u00b9' {0})\n\nlemma countable_subsingleton {\u03b1 : Type*} (s : set \u03b1) (h : subsingleton s) : set.countable s :=\n  set.countable_iff_exists_injective.mpr $ \u27e8\u03bb _, 0, \u03bb _ _, dec_trivial\u27e9\n\n-- lemma cover_Union_eq {\u03b1 \u03b9 : Type*} {s : set \u03b1} {t : \u03b9 \u2192 set \u03b1} {h : s \u2286 (\u22c3 (i : \u03b9), t i)} :\n-- s = \u22c3 i, s \u2229 t i :=\n--   by {rw[<-set.inter_Union_left], ext, split; intros, exact \u27e8a, h a\u27e9, exact a.left}\n\nlemma inter_subset_left' {\u03b1 : Type*} {s t u : set \u03b1} {h : t \u2286 u} : s \u2229 t \u2286 u :=\n  \u03bb _ \u27e8_,_\u27e9, by solve_by_elim\n\nlemma inter_subset_right' {\u03b1 : Type*} {s t u : set \u03b1} {h : t \u2286 u} : t \u2229 s \u2286 u :=\n  \u03bb _ \u27e8_,_\u27e9, by solve_by_elim\n\nsection one_point_restriction\n\n/- Given x : \u03b1, return the set \u03bb a, a \u2260 x -/\n@[simp, reducible]def not_x {\u03b1 : Type*} (x : \u03b1) : set \u03b1 := \u03bb a, a \u2260 x\n\ndef finite_of_inter_not_x {\u03b1 : Type*} {s : set \u03b1} (h : set.finite s) {x : \u03b1} : set.finite $ s \u2229 not_x x := by {apply set.finite_subset, exact h, apply inter_subset_right', trivial}\n\ndef roption_indicator {\u03b1 : Type*} (s : set \u03b1) : \u03b1 \u2192 roption \u03b1 :=\n  \u03bb x, \u27e8x \u2208 s, \u03bb _, x\u27e9\n\ndef pfun.restriction {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) (s : set \u03b1) : \u03b1 \u2192. \u03b2\n:= \u03bb x, do y <- roption_indicator s x, f y\n\nlemma pfun.domain_restriction {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} {s : set \u03b1} : (pfun.restriction f s).dom = f.dom \u2229 s :=\n  by ext; split; intro a; cases a; fsplit; assumption\n\nend one_point_restriction\n-- def one_point_restriction (p : (@cohen_poset \u03b7)) : \u2200(x), x \u2208 p.val.dom \u2192 (@cohen_poset \u03b7) :=\n-- \u03bb x H, \u27e8pfun.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}\u27e9\n\n-- def one_point_restriction' (p : (@cohen_poset \u03b7)) : \u2200 (x), (@cohen_poset \u03b7) :=\n-- \u03bb x, \u27e8pfun.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}\u27e9\n\n-- lemma one_point_restriction_domain {p : (@cohen_poset \u03b7)} {x} (h : x \u2208 p.val.dom) : (one_point_restriction p x h).val.dom = p.val.dom \u2229 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 \u03b7)} {x} : (one_point_restriction' p x).val.dom = p.val.dom \u2229 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 \u03b7)} {x} {h_x : x \u2208 p.val.dom} : \u2200 y, y \u2208 (one_point_restriction p x h_x).val.graph \u2194 (y \u2208 p.val.graph \u2227 (prod.fst y \u2260 x)) := sorry\n\n-- -- lemma one_point_restriction_graph' {p : (@cohen_poset \u03b7)} {x} : (one_point_restriction' p x).val.graph = {y \u2208 p.val.graph | y.fst \u2208 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 \u03b7)} {x} {h : x \u2208 p.val.dom} {y} : y \u2208 (one_point_restriction p x h).val.dom \u2194 (y \u2208 p.val.dom) \u2227 y \u2260 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 \u03b7)} {x} {y} : y \u2208 (one_point_restriction' p x ).val.dom \u2194 (y \u2208 p.val.dom) \u2227 y \u2260 x :=\n--   by simp[one_point_restriction_domain', not_x]; finish\n\n-- lemma one_point_restriction_domain'_subset {p : (@cohen_poset \u03b7)} {x} : (one_point_restriction' p x).val.dom \u2286 p.val.dom :=\n--   \u03bb y, by finish\n\n-- lemma one_point_restriction_domain_subset {p : (@cohen_poset \u03b7)} {x} {h_x : x \u2208 p.val.dom} : (one_point_restriction p x h_x).val.dom \u2286 p.val.dom :=\n--   \u03bb y, by finish\n\n\n-- lemma one_point_restriction_domain_coe {p : (@cohen_poset \u03b7)} {x} {h : x \u2208 p.val.dom} : p.val.dom = \u2191(set.finite.to_finset p.property) := by simp\n\n-- lemma one_point_restriction_finset_rewrite {p : (@cohen_poset \u03b7)} {x} {h : x \u2208 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 \u2229 not_x x) := by simp[one_point_restriction_domain]\n\n-- lemma one_point_restriction_finset_rewrite_property {p : (@cohen_poset \u03b7)} {x} {h : x \u2208 p.val.dom} : \u2200 y, y \u2208 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 \u2229 not_x x\n-- ) \u2194 y \u2260 x \u2227 y \u2208 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 \u27e8a.right,_\u27e9, apply a.left, swap, exact y, simp*}\n-- end\n\n-- lemma one_point_restriction_erase {p : (@cohen_poset \u03b7)} {x} {h : x \u2208 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 \u2115) \u00d7 \u2115, 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 \u03b7)) (h : size_of_domain p = n + 1) (x) (h_x : x \u2208 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\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} (h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom) (h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom) (q : Prop) (h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q) (h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q) (c : (@cohen_poset \u03b7)) : (@cohen_poset \u03b7) :=\n--   (one_point_restriction' (one_point_restriction' c t\u2081) t\u2082)\n\n-- lemma aux_c''_dom {p\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} {h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom} {h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom} {q : Prop} {h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q} {h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q} {c : (@cohen_poset \u03b7)} : \u2200 (x), x \u2208 (aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val.dom \u2192 x \u2260 t\u2081 \u2227 x \u2260 t\u2082 :=\n-- \u03bb x Hx, \u27e8by {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\u2082, exact Hx},\n--          by {apply ((in_one_point_restriction'_of_in_dom_and_not_x).mp _).right, exact (one_point_restriction' c t\u2081), exact Hx}\u27e9\n\n-- lemma aux_c''_dom_of {p\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} {h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom} {h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom} {q : Prop} {h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q} {h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q} {c : (@cohen_poset \u03b7)} : \u2200 (x), x \u2260 t\u2081 \u2227 x \u2260 t\u2082 \u2192 x \u2208 c.val.dom \u2192 x \u2208 (aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val.dom :=\n-- begin\n--   intros x Hx H'x, rcases Hx with \u27e8Hx_r, Hx_l\u27e9, dsimp[aux_c''],\n--   repeat{rw[one_point_restriction_domain']}, finish\n-- end\n\n-- lemma aux_c''_graph_of {p\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} {h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom} {h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom} {q : Prop} {h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q} {h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q} {c : (@cohen_poset \u03b7)} : \u2200 x, (x \u2208 c.val.graph \u2227 (prod.fst x \u2260 t\u2081 ) \u2227 (prod.fst x \u2260 t\u2082)) \u2194 x \u2208 (aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val.graph := sorry\n\n-- lemma aux_c''_dom_finite {p\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} {h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom} {h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom} {q : Prop} {h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q} {h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q} {c : (@cohen_poset \u03b7)} : set.finite (aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 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-- -- \u03bb x Hx, \u27e8by {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\u2082, exact Hx},\n-- --          by {apply ((in_one_point_restriction'_of_in_dom_and_not_x).mp _).right, exact (one_point_restriction' c t\u2081), exact Hx}\u27e9\n\n-- /- Let p\u2081 and p\u2082 be two partial functions such that there is a point (b\u2081,m) for p\u2081 and a point (b\u2082, m) for p\u2082 where p\u2081 and p\u2082 have the same value.\n--     Suppose that the one-point restrictions of p\u2081 and p\u2082 with respect to (b\u2081,m) and (b\u2082,m) have a common refinement c.\n--     Then c (after making sure (b\u2081, m) and (b\u2082,m) are not in its domain) extended by (b\u2081,m) and (b\u2082,m) is a common refinement for p\u2081 and p\u2082. -/\n\n-- /-- the graph of the extension of c by (b\u2081,m) and (b\u2082,m) -/\n-- def one_point_restriction_refinement_extension_graph {p\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} (h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom) (h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom) (q : Prop) (h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q) (h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q) (c : (@cohen_poset \u03b7)) :=\n--   ((aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val.graph \u222a {(t\u2081,q)} \u222a {(t\u2082,q)})\n\n-- lemma one_point_restriction_refinement_extension_graph_functional {p\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} (h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom) (h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom) (q : Prop) (h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q) (h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q) (c : (@cohen_poset \u03b7)) (h_c_left : c \u2264 (one_point_restriction p\u2081 t\u2081 h_t\u2081)) (h_c_right : c \u2264 (one_point_restriction p\u2082 t\u2082 h_t\u2082)) :\n--   pfun.functional $ one_point_restriction_refinement_extension_graph h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c :=\n-- begin\n--   intros x q\u2081 q\u2082 H\u2081 H\u2082, let c' := (aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c), cases H\u2081; cases H\u2082; cases H\u2081; cases H\u2082,\n--   apply pfun.graph_functional (aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val, exact H\u2081, exact H\u2082,\n--   {have : x \u2208 c'.val.dom,\n--     by {apply (pfun.dom_iff_graph c'.val x).mpr, exact \u27e8q\u2081, H\u2081\u27e9}, have := (aux_c''_dom x this).left, suffices : x = t\u2081, by contradiction, repeat{cases H\u2082}, refl},\n--   {repeat{cases H\u2081}, suffices : t\u2081 \u2260 t\u2081, by contradiction, have : t\u2081 \u2208 c'.val.dom,\n--    by {apply (pfun.dom_iff_graph c'.val t\u2081).mpr, exact \u27e8q\u2082, H\u2082\u27e9},\n--    exact (aux_c''_dom t\u2081 this).left},\n--   {cases H\u2081; cases H\u2081; cases H\u2082; cases H\u2082, cc},\n--   {repeat{cases H\u2082}, suffices : t\u2082 \u2260 t\u2082, by contradiction, have : t\u2082 \u2208 c'.val.dom,\n--    by {apply (pfun.dom_iff_graph c'.val t\u2082).mpr, exact \u27e8q\u2081, H\u2081\u27e9},\n--    exact (aux_c''_dom t\u2082 this).right},\n--   {cases H\u2082},\n--   {repeat{cases H\u2081}, cases H\u2082, refl},\n--   {cases H\u2082},\n--   {repeat{cases H\u2081}, suffices : t\u2082 \u2260 t\u2082, by contradiction, have : t\u2082 \u2208 c'.val.dom,\n--    by {apply (pfun.dom_iff_graph c'.val t\u2082).mpr, refine \u27e8_,_\u27e9, exact q\u2082, exact H\u2082},\n--    exact (aux_c''_dom t\u2082 this).right}, {repeat{cases H\u2082}, cases H\u2081, refl},\n--   {cases H\u2081}, {cases H\u2081}, {cc}, {cases H\u2082}, {cases H\u2081}, {cases H\u2081},\n-- end\n\n-- /-- the graph of the extension of c by (b\u2081,m) and (b\u2082,m) contains the graphs of p\u2081 and p\u2082 -/\n-- lemma one_point_restriction_refinement_extension_graph_extends {p\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} (h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom) (h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom) (q : Prop) (h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q) (h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q) (c : (@cohen_poset \u03b7)) (h_c_left : c \u2264 (one_point_restriction p\u2081 t\u2081 h_t\u2081)) (h_c_right : c \u2264 (one_point_restriction p\u2082 t\u2082 h_t\u2082)) : p\u2081.val.graph \u2286 (one_point_restriction_refinement_extension_graph h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c) \u2227 p\u2082.val.graph \u2286 (one_point_restriction_refinement_extension_graph h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c) :=\n-- begin\n--   split; intros x Hx; rcases x with \u27e8x, q'\u27e9;\n--   dsimp[one_point_restriction_refinement_extension_graph],\n--   suffices : ((x, q') \u2208 pfun.graph ((aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val)) \u2228 ((x, q') \u2208 {(t\u2081, q)} \u2228\n--     (x, q') \u2208 {(t\u2082, q)}), by rwa[or_assoc],\n--   let H, swap, change _ \u2228 H, haveI : decidable H := by apply classical.prop_decidable _,\n--   by_cases H,\n--     {apply or.elim h, exact \u03bb A, or.inr $ or.inl $ A,\n--                       exact \u03bb 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 \u27e8_, _\u27e9,\n\n-- -- dsimp[H] at h, rw[not_or_distrib] at h,\n-- --      have Hx' : (x,q') \u2208 (c.val).graph,\n-- --        by {apply h_c_left, apply (one_point_restriction_graph (x,q')).mpr,\n-- --        refine \u27e8(by assumption), _\u27e9, change x \u2260 t\u2081, cases h, intro hx, apply h_left, rw[hx], simp,\n-- --               apply (pfun.graph_functional p\u2081.val), exact Hx,\n-- --               rw[hx], apply (pfun.lift_graph' _).mpr, exact h_val\u2081},\n-- --      apply or.inl, have : x \u2208 p\u2081.val.dom, by apply (pfun.dom_iff_graph _ x).mpr; exact \u27e8q', Hx\u27e9,\n-- --      have : x \u2208 ((aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val).dom,\n-- --        by {apply aux_c''_dom_of, {split, {change x \u2260 t\u2081, cases h, intro hx,\n-- --           apply h_left, rw[hx], simp, apply (pfun.graph_functional p\u2081.val), exact Hx,\n-- --           rw[hx], apply (pfun.lift_graph' _).mpr, exact h_val\u2081}, {change x \u2260 t\u2082, cases h, intro hx, apply h_right, rw[hx], simp, apply (pfun.graph_functional p\u2082.val), repeat{sorry} -- exact Hx, rw[hx], apply (pfun.lift_graph' _).mpr, exact h_val\u2082\n-- --               }}, {apply (pfun.dom_iff_graph _ x).mpr, exact \u27e8q', Hx'\u27e9}},\n\n--     },\n--   -- by_cases H, repeat{sorry}\n--   -- have : ((x, q') \u2208 {(t\u2081, q)} \u2228 (x, q') \u2208 {(t\u2082, q)}) \u2192 (x,q') \u2209 pfun.graph ((aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val),\n--   -- by {intros H\u2081 H\u2082, have : x \u2208 (aux_c'' h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c).val.dom,\n--   --    by {apply (pfun.dom_iff_graph _ x).mpr, exact \u27e8q', H\u2082\u27e9}, have := aux_c''_dom x this,\n--   --    cases H\u2081, have : (x,q') = (t\u2081, q), from set.eq_of_mem_singleton (by assumption), finish,\n--   --    have : (x,q') = (t\u2082, q), from set.eq_of_mem_singleton (by assumption), finish},\n--   repeat{sorry}\n\n-- end\n\n-- /-- the extension of c by (b\u2081, m) and (b\u2082,m) has finite domain -/\n-- lemma one_point_restriction_refinement_extension_finite {p\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} (h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom) (h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom) (q : Prop) (h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q) (h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q) (c : (@cohen_poset \u03b7)) (h_c_left : c \u2264 (one_point_restriction p\u2081 t\u2081 h_t\u2081)) (h_c_right : c \u2264 (one_point_restriction p\u2082 t\u2082 h_t\u2082)) : set.finite (pfun.of_graph (one_point_restriction_refinement_extension_graph h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 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\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 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\u2081 p\u2082 : (@cohen_poset \u03b7)} {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} (h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom) (h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom) (q : Prop) (h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q) (h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q) (c : (@cohen_poset \u03b7)) (h_c_left : c \u2264 (one_point_restriction p\u2081 t\u2081 h_t\u2081)) (h_c_right : c \u2264 (one_point_restriction p\u2082 t\u2082 h_t\u2082)) : (@cohen_poset \u03b7) :=\n--   \u27e8pfun.of_graph (one_point_restriction_refinement_extension_graph h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c) (by {apply one_point_restriction_refinement_extension_graph_functional, repeat{assumption}}),\n--    (by {apply one_point_restriction_refinement_extension_finite, repeat{assumption}})\u27e9\n\n-- lemma one_point_restriction_refinement_extension_spec (p\u2081 p\u2082 : (@cohen_poset \u03b7)) {t\u2081 t\u2082 : (set $ set \u2115) \u00d7 \u2115} {h_t\u2081 : t\u2081 \u2208 p\u2081.val.dom} {h_t\u2082 : t\u2082 \u2208 p\u2082.val.dom} {q : Prop} {h_val\u2081 : pfun.fn p\u2081.val t\u2081 h_t\u2081 = q} {h_val\u2082 : pfun.fn p\u2082.val t\u2082 h_t\u2082 = q} {c : (@cohen_poset \u03b7)} (h_c_left : c \u2264 (one_point_restriction p\u2081 t\u2081 h_t\u2081)) (h_c_right : c \u2264 (one_point_restriction p\u2082 t\u2082 h_t\u2082)) : \u2203 c' : (@cohen_poset \u03b7), c' \u2264 p\u2081 \u2227 c' \u2264 p\u2082 :=\n-- begin\n--   refine \u27e8by {fapply one_point_restriction_refinement_extension h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 c,\n--              repeat{assumption}}, _\u27e9,\n--   have := one_point_restriction_refinement_extension_graph_extends h_t\u2081 h_t\u2082 q h_val\u2081 h_val\u2082 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\u2081 p\u2082 : (@cohen_poset \u03b7)} (h_incompat : incompatible p\u2081 p\u2082) : \u2203 w \u2208 p\u2081.val.dom \u2229 p\u2082.val.dom, pfun.fn (p\u2081.val) w (by exact H.left) \u2260 pfun.fn (p\u2082.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\u2081 p\u2082 : (@cohen_poset \u03b7)} (h_incompat : incompatible p\u2081 p\u2082) : \u2203 w q\u2081 q\u2082, (w,q\u2081) \u2208 p\u2081.val.graph \u2227 (w,q\u2082) \u2208 p\u2082.val.graph \u2227 q\u2081 \u2260 q\u2082 := sorry\n\n-- end one_point_restriction\n\n-- lemma congr_neq {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192 \u03b2} {x' y' : \u03b1} {x y : \u03b2} {h_x : f x' = x} {h_y : f y' = y} {h_neq : x \u2260 y} : x' \u2260 y' := \u03bb _, by {cc}\n\n-- lemma coe_subtype_injective {\u03b1 : Type*} {s : set \u03b1} {x y : s} : (\u2191x = (\u2191y : \u03b1)) \u2192 x = y :=\n--   \u03bb 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 \u03b7)_ccc : countable_chain_condition (@cohen_poset \u03b7) :=\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 \u2286 \u22c3 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 : \u2200 p : A_n_m, \u2203 b : (set $ set \u2115), (b,m) \u2208 (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 \u2192 Prop :=\n-- --              \u03bb (p : \u21a5A_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 \u2192 (@cohen_poset \u03b7) :=\n-- --            \u03bb 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 \u27e8c, \u27e8H_cx,H_cy\u27e9\u27e9,\n-- --                rcases H_x with \u27e8x', H_x'\u27e9, rcases H_y with \u27e8y', H_y'\u27e9,\n-- --                have h_neq : x' \u2260 y',\n-- --                  by {apply congr_neq, exact H_x'.right, exact H_y'.right, exact H_neq},\n-- --                have : \u2191x' \u2260 \u2191y', 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 \u27e8w,q\u2081,q\u2082, \u27e8H\u2081,\u27e8H\u2082,H\u2083\u27e9\u27e9\u27e9,\n-- --                have w_not_t\u2081 : w \u2260 (wit (x'), m),\n-- --                  by {intro H_eq, have := pfun.congr_arg (subtype.val (\u2191x'))\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\u2082 : w.fst \u2260 wit (y'), by sorry,\n-- --                have w_in_red_1 : (w,q\u2081) \u2208 (x).val.graph, by sorry,\n-- --                have w_in_red_2 : (w,q\u2082) \u2208 (y).val.graph, by sorry,\n-- --                have w_in_c_1 : (w,q\u2081) \u2208 c.val.graph, from H_cx w_in_red_1,\n-- --                have w_in_c_2 : (w,q\u2082) \u2208 c.val.graph, from H_cy w_in_red_2,\n-- --                suffices : q\u2081 = q\u2082, 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 \u207b\u00b9' {n} \u2229 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 \u21a5A_n_m := \u03bb _ _, classical.prop_decidable _,\n-- --               by_cases x' = y', exact \u03bb _, \u2039x' = y'\u203a, 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 (\u2191x') (\u2191y'),\n-- --               have : red x' \u2264 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 : \u2115) : bin_op \u2192 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 \u2265 m)\n| GtOp    := VBool (n > m)\n| LeOp    := VBool (n \u2264 m)\n| LtOp    := VBool (n < m)\n| EqOp    := VBool (n = m)\n\ndef subst (v : val) (x : string) : exp \u2192 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\u2081 e\u2082) := EOp op (subst e\u2081) (subst e\u2082)\n| (EVal v) := (EVal v)\n\ndef remove (name : string) : list (string \u00d7 val) \u2192 list (string \u00d7 val)\n| [] := []\n| ((x, v) :: nv') := if x = name then remove nv' else (x, v) :: remove nv'\n\ndef big_subst : list (string \u00d7 val) \u2192 exp \u2192 exp\n| [] expr := expr\n| ((x, v) :: nv') e := big_subst nv' (subst v x e)\n\ninductive big_step : exp \u2192 val \u2192 Prop\n| RunVal {v} : big_step (EVal v) v\n| RunOp {op e\u2099 e\u2098 n m}\n    (_ : big_step e\u2099 (VNat n))\n    (_ : big_step e\u2098 (VNat m))\n  : big_step (EOp op e\u2099 e\u2098) (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 ` \u27f9 ` : 30 := big_step\n\ndef at_least {\u03b1 : Type} (n : \u2115) : list \u03b1 \u2192 Prop\n| (l : list \u03b1) := l.length \u2265 n\n\nlemma at_least_refl {\u03b1 : Type} {l : list \u03b1} : at_least l.length l :=\nby rw [at_least]; exact nat.le_refl (l.length)\n\ninductive bound : string \u2192 val \u2192 list (string \u00d7 val) \u2192 Prop\n| bhead {x v env}     : bound x v ((x, v) :: env)\n| btail {x y v u env} : x \u2260 y \u2192 bound x v env \u2192 bound x v (\u27e8y, u\u27e9 :: env)\n\ninductive vm_big_step : \n  list (string \u00d7 val) \u00d7 list instruction \u00d7 list val \u2192 list val \u2192 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 : \u2115} \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 (\u27e8x, v\u27e9 :: 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 (\u27e8x, v\u27e9 :: env, ICloseScope :: instrs, stack) res\n\ninfix ` \u27f9\u1d65\u2098 ` : 50 := vm_big_step\n\n-- big-step semantics including resulting environment\ninductive env_big_step :\n    list (string \u00d7 val) \u00d7 list instruction \u00d7 list val \n  \u2192 list (string \u00d7 val) \u00d7 list val \u2192 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 : \u2115} \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 (\u27e8x, v\u27e9 :: 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 (\u27e8x, v\u27e9 :: env, ICloseScope :: instrs, stack) res\n\ninfix ` \u27f9\u2099\u1d65 ` : 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\u2081 u\u2082 v\u2081 v\u2082 \n\nnamespace Mathlib\n\n/-!\n# Monoidal structure on `C \u2964 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 \u2964 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 \u2964 D`, when `D` is monoidal.\n -/\ndef tensor_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D]\n    (F : C \u2964 D) (G : C \u2964 D) : C \u2964 D :=\n  functor.mk (fun (X : C) => functor.obj F X \u2297 functor.obj G X)\n    fun (X Y : C) (f : X \u27f6 Y) => functor.map F f \u2297 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\u2081} [category C] {D : Type u\u2082} [category D] [monoidal_category D]\n    {F : C \u2964 D} {G : C \u2964 D} {F' : C \u2964 D} {G' : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : F' \u27f6 G') :\n    tensor_obj F F' \u27f6 tensor_obj G G' :=\n  nat_trans.mk fun (X : C) => nat_trans.app \u03b1 X \u2297 nat_trans.app \u03b2 X\n\nend functor_category\n\n\n/--\nWhen `C` is any category, and `D` is a monoidal category,\nthe functor category `C \u2964 D` has a natural pointwise monoidal structure,\nwhere `(F \u2297 G).obj X = F.obj X \u2297 G.obj X`.\n-/\nprotected instance functor_category_monoidal {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] : monoidal_category (C \u2964 D) :=\n  monoidal_category.mk (fun (F G : C \u2964 D) => functor_category.tensor_obj F G)\n    (fun (F G F' G' : C \u2964 D) (\u03b1 : F \u27f6 G) (\u03b2 : F' \u27f6 G') => functor_category.tensor_hom \u03b1 \u03b2)\n    (functor.obj (functor.const C) \ud835\udfd9_)\n    (fun (F G H : C \u2964 D) => nat_iso.of_components (fun (X : C) => \u03b1_) sorry)\n    (fun (F : C \u2964 D) => nat_iso.of_components (fun (X : C) => \u03bb_) sorry)\n    fun (F : C \u2964 D) => nat_iso.of_components (fun (X : C) => \u03c1_) sorry\n\n@[simp] theorem tensor_unit_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {X : C} : functor.obj \ud835\udfd9_ X = \ud835\udfd9_ :=\n  rfl\n\n@[simp] theorem tensor_unit_map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {X : C} {Y : C} {f : X \u27f6 Y} : functor.map \ud835\udfd9_ f = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem tensor_obj_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {X : C} :\n    functor.obj (F \u2297 G) X = functor.obj F X \u2297 functor.obj G X :=\n  rfl\n\n@[simp] theorem tensor_obj_map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {X : C} {Y : C} {f : X \u27f6 Y} :\n    functor.map (F \u2297 G) f = functor.map F f \u2297 functor.map G f :=\n  rfl\n\n@[simp] theorem tensor_hom_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {F' : C \u2964 D} {G' : C \u2964 D} {\u03b1 : F \u27f6 G}\n    {\u03b2 : F' \u27f6 G'} {X : C} : nat_trans.app (\u03b1 \u2297 \u03b2) X = nat_trans.app \u03b1 X \u2297 nat_trans.app \u03b2 X :=\n  rfl\n\n@[simp] theorem left_unitor_hom_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {X : C} : nat_trans.app (iso.hom \u03bb_) X = iso.hom \u03bb_ :=\n  rfl\n\n@[simp] theorem left_unitor_inv_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {X : C} : nat_trans.app (iso.inv \u03bb_) X = iso.inv \u03bb_ :=\n  rfl\n\n@[simp] theorem right_unitor_hom_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {X : C} : nat_trans.app (iso.hom \u03c1_) X = iso.hom \u03c1_ :=\n  rfl\n\n@[simp] theorem right_unitor_inv_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {X : C} : nat_trans.app (iso.inv \u03c1_) X = iso.inv \u03c1_ :=\n  rfl\n\n@[simp] theorem associator_hom_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {H : C \u2964 D} {X : C} :\n    nat_trans.app (iso.hom \u03b1_) X = iso.hom \u03b1_ :=\n  rfl\n\n@[simp] theorem associator_inv_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] {F : C \u2964 D} {G : C \u2964 D} {H : C \u2964 D} {X : C} :\n    nat_trans.app (iso.inv \u03b1_) X = iso.inv \u03b1_ :=\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 \u2964 D`\nis also braided.\n-/\nprotected instance functor_category_braided {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] [braided_category D] : braided_category (C \u2964 D) :=\n  braided_category.mk fun (F G : C \u2964 D) => nat_iso.of_components (fun (X : C) => \u03b2_) 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 \u2964 D`\nis also symmetric.\n-/\nprotected instance functor_category_symmetric {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] [symmetric_category D] : symmetric_category (C \u2964 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u2192 name \u2192 expr\n| (local_const n _ bi d) pp := local_const n pp bi d\n| e n := e\n\nprivate meta def elim_or : \u2115 \u2192 expr \u2192 tactic (list expr)\n| 0       h := fail \"zero cases\"\n| 1       h := return [h]\n| (n + 1) h := do\n  [(_, [hl], []), (_, [hr], [])] \u2190 induction h, -- there should be no dependent terms\n  [gl, gr] \u2190 get_goals,\n  set_goals [gr],\n  hsr \u2190 elim_or n hr,\n  gsr \u2190 get_goals,\n  set_goals (gl :: gsr),\n  return (hl :: hsr)\n\nprivate meta def dest_or : expr \u2192 tactic (list expr) | e := do\n  `(%%a \u2228 %%b) \u2190 whnf e | return [e],\n  lb \u2190 dest_or b,\n  return (a :: lb)\n\nprivate meta def match_perms (pat : pattern) : expr \u2192 tactic (list $ list expr) | t :=\n  (do\n    m \u2190 match_pattern pat t,\n    guard (m.2.all expr.is_local_constant),\n    return [m.2]) <|>\n  (do\n    `(%%l \u2228 %%r) \u2190 whnf t,\n    m \u2190 match_pattern pat l,\n    rs \u2190 match_perms r,\n    return (m.2 :: rs))\n\nprivate meta def update_type : expr \u2192 expr \u2192 expr\n| (local_const n pp bi d) t := local_const n pp bi t\n| e t := e\n\nprivate meta def intron' : \u2115 \u2192 tactic (list expr)\n| 0       := return []\n| (i + 1) := do\n  n \u2190 intro1,\n  ls \u2190 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 \u0393 \u2b1d vars \u2b1d cases \u22a2 \u2200deps, \u2026\n  nr \u2190 revert_lst (vars' ++ [h_cases]),\n  vars \u2190 intron' vars'.length,\n  h_cases \u2190 intro h_cases.local_pp_name,\n\n  cases \u2190 infer_type h_cases,\n  h_fst_case \u2190\n    mk_local_def h_cases.local_pp_name\n      (fst_case.instantiate_locals $ (vars'.zip vars).map $ \u03bb\u27e8o, n\u27e9, (o.local_uniq_name, n)),\n  ((), pr) \u2190 solve_aux cases (repeat $ exact h_fst_case <|> left >> skip),\n\n  t \u2190 target,\n  fixed_vars \u2190 vars.mmap (\u03bbv, do t \u2190 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]) \u2190 local_proof `this t' (do\n    clear h_cases,\n    vars.mmap clear,\n    intron nr),\n\n  h\u2080 :: hs \u2190 elim_or perms.length h_cases,\n\n  solve1 (do\n    exact (h.mk_app $ vars ++ [h\u2080])),\n\n  focus ((hs.zip perms.tail).map $ \u03bb\u27e8h_case, perm\u27e9, do\n    let p_v := (vars'.zip vars).map (\u03bb\u27e8p, v\u27e9, (p.local_uniq_name, v)),\n    let p := perm.map (\u03bbp, p.instantiate_locals p_v),\n    note `this none (h.mk_app $ p ++ [h_case]),\n    clear h,\n    return ()),\n  gs \u2190 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)) \u2192 tactic (list (list expr))\n| none                    := return []\n| (some [])               := return []\n| (some perms@(p\u2080 :: ps)) := do\n  (guard p\u2080.nodup <|>\n    fail \"No permutation `xs_i` in `using [xs_1, \u2026, xs_n]` should contain the same variable twice.\"),\n  (guard (perms.all $ \u03bbp, p.perm p\u2080) <|>\n    fail \"The permutations `xs_i` in `using [xs_1, \u2026, xs_n]` must be permutations of the same variables.\"),\n  perms.mmap (\u03bbp, 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  `\u22a2 p xs_0 \u2228 \u22ef \u2228 p xs_n`\nThe main goal, i.e. the goal reduced to `xs_0`:\n  `(h : p xs_0) \u22a2 g xs_0`\nThe invariant goals, i.e. `g` is invariant under `xs_i`:\n  `(h : p xs_i) (this : g xs_0) \u22a2 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\u2080 \u2228 (p\u2081 \u2228 p\u2082)`. In many cases\nthe invariant goals can be solved by AC rewriting using `cc` etc.\n\nExample:\n  On a state `(n m : \u2115) \u22a2 p n m` the tactic `wlog h : n \u2264 m using [n m, m n]` produces the following\n  states:\n    `(n m : \u2115) \u22a2 n \u2264 m \u2228 m \u2264 n`\n    `(n m : \u2115) (h : n \u2264 m) \u22a2 p n m`\n    `(n m : \u2115) (h : m \u2264 n) (this : p n m) \u22a2 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, \u2026, xsn]`\n  Results in the case goal `p xs0 \u2228 \u22ef \u2228 ps xsn`, the main goal `(case : p xs0) \u22a2 g xs0` and the\n  invariance goals `(case : p xsi) (this : g xs0) \u22a2 g xsi`.\n\n(2) `wlog : p xs0 := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 \u2228 \u22ef \u2228 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 \u2228 \u22ef \u2228 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 \u2228 R y x`. If `R` is \u2264, 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*) <|> (\u03bbx, [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 \u2190 parse_permutations perms,\n(pat, cases_pr, cases_goal, vars, perms) \u2190 (match cases with\n| some r := do\n  vars::_ \u2190 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 \u2190 to_expr r,\n  cases_pr \u2190 (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 \u2190 infer_type cases_pr,\n  (pat, perms') \u2190 match pat with\n  | some pat := do\n    pat \u2190 to_expr pat,\n    let vars' := vars.filter $ \u03bbv, v.occurs pat,\n    case_pat \u2190 mk_pattern [] vars' pat [] vars',\n    perms' \u2190 match_perms case_pat cases,\n    return (pat, perms')\n  | none := do\n    (p :: ps) \u2190 dest_or cases,\n    let vars' := vars.filter $ \u03bbv, v.occurs p,\n    case_pat \u2190 mk_pattern [] vars' p [] vars',\n    perms' \u2190 (p :: ps).mmap (\u03bbp, do m \u2190 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 $ \u03bbp, p.all $ \u03bbv, v.is_local_constant \u2227 v.local_uniq_name \u2208 vars_name) <|>\n    fail \"Cases contains variables not declared in `using x y z`\",\n  perms \u2190 (if perms.length = 1\n    then do\n      return (perms'.map $ \u03bbp, p ++ vars.filter (\u03bbv, p.all (\u03bbv', v'.local_uniq_name \u2260 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 \u2190 return pat | fail \"Either specify cases or a pattern with permutations\",\n  pat \u2190 to_expr pat,\n  (do\n    [x, y] \u2190 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' \u2264 %%y') \u2190 return pat,\n      (cases_pr, []) \u2190 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]) \u2190 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 \u2265 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') \u2190 return perms,\n    let names := vars.map local_uniq_name,\n    let cases := mk_or_lst (pat :: perms'.map (\u03bbp, pat.instantiate_locals (names.zip p))),\n    (cases_pr, [g]) \u2190 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 \u03bbi, `invariant else \u03bbi, mk_simple_name (\"invariant_\" ++ to_string (i + 1))),\nwith_enable_tags $ tactic.focus1 $ do\n  t \u2190 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 (\u03bbi, 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 \u2190 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\u00f6ving. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henrik B\u00f6ving, 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 `\u2200 i j : \u2115, i \u2264 j` has a `Checkable` instance because `\u2115`\nis sampleable and `i \u2264 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 : \u2115\n  y : \u2115\n  h : x \u2264 y\n  deriving Repr\n```\nHow do we test a property about `MyType`? For instance, let us consider\n`Checkable.check $ \u2200 a b : MyType, a.y \u2264 b.x \u2192 a.x \u2264 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 := \u03bb \u27e8x,y,h\u27e9 =>\n    let proxy := Shrinkable.shrink (x, y - x)\n    proxy.map (\u03bb \u27e8\u27e8fst, snd\u27e9, ha\u27e9 => \u27e8\u27e8fst, fst + snd, sorry\u27e9, sorry\u27e9)\ninstance : SampleableExt MyType :=\n  SampleableExt.mkSelfContained do\n    let x \u2190 SampleableExt.interpSample Nat\n    let xyDiff \u2190 SampleableExt.interpSample Nat\n    pure $ \u27e8x, x + xyDiff, sorry\u27e9\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) \u2192 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 : \u2115 \u2192 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 : \u00ac p \u2192 (List String) \u2192 \u2115 \u2192 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 \u2192 TestResult p\n  | gaveUp : Nat \u2192 TestResult p\n  | failure : \u00ac p \u2192 List String \u2192 Nat \u2192 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 := \"\u22ef\"\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 \u2192 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) := \u27e8toString\u27e9\n\n/-- Applicative combinator proof carrying test results. -/\ndef combine {p q : Prop} : PSum Unit (p \u2192 q) \u2192 PSum Unit p \u2192 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 \u2192 TestResult q \u2192 TestResult (p \u2227 q)\n| failure h xs n, _ => failure (\u03bb h2 => h h2.left) xs n\n| _, failure h xs n => failure (\u03bb 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 \u2192 TestResult q \u2192 TestResult (p \u2228 q)\n| failure h1 xs n, failure h2 ys m =>\n  let h3 := \u03bb 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 \u2192 p`, then `\u00ac p \u2192 \u00ac q` which means that testing `p` can allow us\nto find counter-examples to `q`. -/\ndef imp (h : q \u2192 p) (r : TestResult p)\n    (p : PSum Unit (p \u2192 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 \u2194 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 \u2192 p) (r : TestResult p)\n    (p : PSum Unit (p \u2192 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 \u03b3] (var : String) (x : \u03b3) (h : q \u2192 p) (r : TestResult p)\n    (p : PSum Unit (p \u2192 q) := PSum.inl ()) : TestResult q  :=\n  addInfo s!\"{var} := {repr x}\" h r p\n\ndef isFailure : TestResult p \u2192 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 \u2192 Bool \u2192 Gen (TestResult p) := Checkable.run\n\n/-- A `dbgTrace` with special formatting -/\ndef slimTrace [Pure m] (s : String) : m PUnit := dbgTrace s!\"[SlimCheck: {s}]\" (\u03bb _ => pure ())\n\ninstance andCheckable [Checkable p] [Checkable q] : Checkable (p \u2227 q) where\n  run := \u03bb cfg min => do\n    let xp \u2190 runProp p cfg min\n    let xq \u2190 runProp q cfg min\n    pure $ and xp xq\n\ninstance orCheckable [Checkable p] [Checkable q] : Checkable (p \u2228 q) where\n  run := \u03bb cfg min => do\n    let xp \u2190 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 \u2190 runProp q cfg min\n      pure $ or xp xq\n\n-- TODO(Winston): Move\nprotected theorem key : (a \u2194 b) \u2194 (a \u2227 b) \u2228 (\u00ac a \u2227 \u00ac b) :=\nby constructor\n   \u00b7 intro h; rw [h]\n     by_cases h : b\n     \u00b7 exact Or.inl <| And.intro h h\n     \u00b7 exact Or.inr <| And.intro h h\n   \u00b7 intro h\n     match h with\n     | Or.inl h => exact Iff.intro (\u03bb _ => h.2) (\u03bb _ => h.1)\n     | Or.inr h => exact Iff.intro (\u03bb a => False.elim $ h.1 a) (\u03bb b => False.elim $ h.2 b)\n\ninstance iffCheckable [Checkable ((p \u2227 q) \u2228 (\u00ac p \u2227 \u00ac q))] : Checkable (p \u2194 q) where\n  run := \u03bb cfg min => do\n    let h \u2190 runProp ((p \u2227 q) \u2228 (\u00ac p \u2227 \u00ac q)) cfg min\n    pure $ iff Checkable.key h\n\ninstance decGuardCheckable [PrintableProp p] [Decidable p] {\u03b2 : p \u2192 Prop} [\u2200 h, Checkable (\u03b2 h)] : Checkable (NamedBinder var $ \u2200 h, \u03b2 h) where\n  run := \u03bb cfg min => do\n    if h : p then\n      let res := (runProp (\u03b2 h) cfg min)\n      let s := printProp p\n      (\u03bb r => addInfo s!\"guard: {s}\" (\u00b7 $ h) r (PSum.inr $ \u03bb q _ => q)) <$> res\n    else if cfg.traceDiscarded || cfg.traceSuccesses then\n      let res := (\u03bb _ => 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 \u2192 Prop} [Checkable (f Int)] : Checkable (NamedBinder var $ \u2200 x, f x) where\n  run := \u03bb cfg min => do\n    let r \u2190 runProp (f Int) cfg min\n    pure $ addVarInfo var \"\u2124\" (\u00b7 $ 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 \u2192 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 \u03b1))]: Inhabited (OptionT m \u03b1) 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 \u03b1] {\u03b2 : \u03b1 \u2192 Prop} [\u2200 x, Checkable (\u03b2 x)] (cfg : Configuration) (var : String)\n    (x : SampleableExt.proxy \u03b1) (n : Nat) : OptionT Gen (\u03a3 x, TestResult (\u03b2 (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 \u2190 OptionT.lift $ Checkable.runProp (\u03b2 (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 \u03b1 _ \u03b2 _ cfg var candidate (n + 1)\n      return \u2190 (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 \u03b1] {\u03b2 : \u03b1 \u2192 Prop} [\u2200 x, Checkable (\u03b2 x)] (cfg : Configuration) (var : String)\n    (x : SampleableExt.proxy \u03b1) (r : TestResult (\u03b2 $ SampleableExt.interp x)) : Gen (\u03a3 x, TestResult (\u03b2 $ SampleableExt.interp x)) := do\n  if cfg.traceShrink then\n     slimTrace \"Shrink\"\n     slimTrace s!\"Attempting to shrink {var} := {repr x}\"\n  let res \u2190 OptionT.run $ minimizeAux cfg var x 0\n  pure $ res.getD \u27e8x, r\u27e9\n\n/-- Test a universal property by creating a sample of the right type and instantiating the\nbound variable with it. -/\ninstance varCheckable [SampleableExt \u03b1] {\u03b2 : \u03b1 \u2192 Prop} [\u2200 x, Checkable (\u03b2 x)] : Checkable (NamedBinder var $ \u2200 x : \u03b1, \u03b2 x) where\n  run := \u03bb cfg min => do\n    let x \u2190 SampleableExt.sample\n    if cfg.traceSuccesses || cfg.traceDiscarded then\n      slimTrace s!\"{var} := {repr x}\"\n    let r \u2190 Checkable.runProp (\u03b2 $ SampleableExt.interp x) cfg false\n    let \u27e8finalX, finalR\u27e9 \u2190 \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 $ \u27e8x, r\u27e9\n      else\n        pure $ \u27e8x, r\u27e9\n    pure $ addVarInfo var finalX (\u00b7 $ SampleableExt.interp finalX) finalR\n\n/-- Test a universal property about propositions -/\ninstance propVarCheckable {\u03b2 : Prop \u2192 Prop} [\u2200 b : Bool, Checkable (\u03b2 b)] :\n  Checkable (NamedBinder var $ \u2200 p : Prop, \u03b2 p)\nwhere\n  run := \u03bb cfg min =>\n    imp (\u03bb h (b : Bool) => h b) <$> Checkable.runProp (NamedBinder var $ \u2200 b : Bool, \u03b2 b) cfg min\n\ninstance (priority := high) unusedVarCheckable [Nonempty \u03b1] [Checkable \u03b2] :\n  Checkable (NamedBinder var $ \u2200 _x : \u03b1, \u03b2)\nwhere\n  run := \u03bb cfg min => do\n    if cfg.traceDiscarded || cfg.traceSuccesses then\n      slimTrace s!\"{var} is unused\"\n    let r \u2190 Checkable.runProp \u03b2 cfg min\n    let finalR := addInfo s!\"{var} is irrelevant (unused)\" id r\n    pure $ imp (\u00b7 $ Classical.ofNonempty) finalR (PSum.inr $ \u03bb x _ => x)\n\ninstance (priority := low) decidableCheckable {p : Prop} [PrintableProp p] [Decidable p] : Checkable p where\n  run := \u03bb _ _ =>\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 \u03b1] {x y : \u03b1} : PrintableProp (x = y) where\n  printProp := s!\"{repr x} = {repr y}\"\n\ninstance Ne.printableProp [Repr \u03b1] {x y : \u03b1} : PrintableProp (x \u2260 y) where\n  printProp := s!\"{repr x} \u2260 {repr y}\"\n\ninstance LE.printableProp [Repr \u03b1] [LE \u03b1] {x y : \u03b1} : PrintableProp (x \u2264 y) where\n  printProp := s!\"{repr x} \u2264 {repr y}\"\n\ninstance LT.printableProp [Repr \u03b1] [LT \u03b1] {x y : \u03b1} : PrintableProp (x < y) where\n  printProp := s!\"{repr x} < {repr y}\"\n\ninstance And.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x \u2227 y) where\n  printProp := s!\"{printProp x} \u2227 {printProp y}\"\n\ninstance Or.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x \u2228 y) where\n  printProp := s!\"{printProp x} \u2228 {printProp y}\"\n\ninstance Iff.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x \u2194 y) where\n  printProp := s!\"{printProp x} \u2194 {printProp y}\"\n\ninstance Imp.printableProp [PrintableProp x] [PrintableProp y]  : PrintableProp (x \u2192 y) where\n  printProp := s!\"{printProp x} \u2192 {printProp y}\"\n\ninstance Not.printableProp [PrintableProp x] : PrintableProp (\u00acx) where\n  printProp := s!\"\u00ac{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 \u2192 Rand (TestResult p)\n| 0 => pure $ TestResult.gaveUp 1\n| n+1 => do\n  let r \u2190 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 \u2192 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 \u2192 Nat \u2192 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 \u2190 retry (ReaderT.run (Checkable.runProp p cfg true) \u27e8size\u27e9) 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 $ \u03bb 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 `\u22a2 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 \u2190 (\u2190 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 \u2190 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 (\u2200 (x y z a : Nat) (h1 : 3 < x) (h2 : 3 < y), x - y = y - x) Configuration.verbose\n-- #eval Checkable.check (\u2200 x : Nat, \u2200 y : Nat, x + y = y + x) Configuration.verbose\n-- #eval Checkable.check (\u2200 (x : (Nat \u00d7 Nat)), x.fst - x.snd - 10 = x.snd - x.fst - 10) Configuration.verbose\n-- #eval Checkable.check (\u2200 (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 {\u03b1 : Type*} (p : \u03b1 \u2192 Prop) [fintype \u03b1] : fintype {a // p a} :=\nset_fintype p\n\ninstance {\u03b1 : Type*} [fintype \u03b1] (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : fintype (quot r) :=\nof_surjective (quot.mk r) (\u03bb x, quot.exists_rep _)\n\nlemma finset.sum_const {\u03b1 \u03b2 : Type*} [decidable_eq \u03b1] [add_comm_monoid \u03b2] \n    (s : finset \u03b1) (b : \u03b2) : finset.sum s (\u03bb a, b) = add_monoid.smul b (finset.card s) :=\nfinset.induction_on s (by simp) $ \u03bb a s h hi,\nby simp [finset.sum_insert h, finset.card_insert_of_not_mem h, hi, smul_succ]\n\ntheorem card_quot {\u03b1 : Type*} [fintype \u03b1] (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : \n    card \u03b1 = (finset.univ : finset (quot r)).sum (\u03bb x, card {a // quot.mk r a = x}) :=\ncard_sigma (\u03bb x, {a // quot.mk r a = x}) \u25b8\ncard_congr \u27e8\u03bb x, \u27e8quot.mk r x, \u27e8x, rfl\u27e9\u27e9, \u03bb x, x.2, \u03bb _, rfl, \u03bb \u27e8_, _, \u27e8_\u27e9\u27e9, rfl\u27e9\n\ninstance {\u03b1 : Type*} [fintype \u03b1] (s : setoid \u03b1) : fintype (quotient s) := quot.fintype s.r\n\ntheorem card_quotient {\u03b1 : Type*} [fintype \u03b1] (s : setoid \u03b1) :\n    card \u03b1 = (finset.univ : finset (quotient s)).sum (\u03bb x, card {a // \u27e6a\u27e7 = x}) := card_quot s.r\n\ninstance {\u03b1 : Type*} [fintype \u03b1] : fintype (set \u03b1) := pi.fintype\n\nsection\nvariable {\u03b1 : Type*}\nopen function set finset\n\nset_option pp.implicit true\n#print eq.drec_on\nlemma set.card_eq_zero {\u03b1 : Type*} {s : set \u03b1} [hf : fintype s] : card s = 0 \u2194 s = \u2205 :=\n\u27e8\u03bb h, by_contradiction $ \u03bb h\u2081, let \u27e8x, hx\u27e9 := set.exists_mem_of_ne_empty h\u2081 in\nfinset.not_mem_empty (\u27e8x, hx\u27e9 : s) $ finset.card_eq_zero.1 h \u25b8 finset.mem_univ (\u27e8x, hx\u27e9 : s),\n\u03bb h, by rw \u2190 set.empty_card; congr; assumption\u27e9 \n\nlemma set.to_finset_union_distrib {\u03b1 : Type*} (s t : set \u03b1) [hs : fintype s] [ht : fintype t] :\n@set.to_finset \u03b1 (s \u222a t) (classical.choice $ set.finite_union \u27e8hs\u27e9 \u27e8ht\u27e9) = set.to_finset s \u222a set.to_finset t :=\nfinset.ext.2 $ \u03bb x, by simp [set.mem_to_finset, finset.mem_union]\n\nlemma set.card_disjoint_union {\u03b1 : Type*} {s t : set \u03b1} (hs : fintype s) (ht : fintype t) (hst : disjoint s t) :\n    @finset.card (s \u222a t : set \u03b1) (classical.choice $ set.finite_union \u27e8hs\u27e9 \u27e8ht\u27e9) = card s + card t :=\nbegin\n  have h := set.card_fintype_of_finset _ (@set.mem_to_finset _ s hs),\n  have h\u2081 : \u2200 {s : set \u03b1} (hs : fintype s), @card s hs =  @card \u21a5s (@set.fintype_of_finset \u03b1 s (@set.to_finset \u03b1 s hs) (@set.mem_to_finset _ s hs)) := \u03bb s hs, by congr,\n  have h\u2083 := set.card_fintype_of_finset _ (@set.mem_to_finset _ t ht),\n  have h\u2084 := set.card_fintype_of_finset _ (@set.mem_to_finset _ _ (classical.choice $ set.finite_union \u27e8hs\u27e9 \u27e8ht\u27e9)),\n  rw [h\u2081 hs, h\u2081 ht, h\u2081 (classical.choice $ set.finite_union \u27e8hs\u27e9 \u27e8ht\u27e9), h, h\u2083, h\u2084, 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 _ _ (\u03bb r h\u2081, hp == (h\u2081 \u25b8 hp : r)) _\n(propext \u27e8\u03bb h, hq, \u03bb h, hp\u27e9) (heq.refl _)\n\nclass subgroup {\u03b1 : Type*} [group \u03b1] (s : set \u03b1) : Prop :=\n(one_mem : (1 : \u03b1) \u2208 s)\n(mul_mem : \u2200 {x y}, x \u2208 s \u2192 y \u2208 s \u2192 x * y \u2208 s)\n(inv_mem : \u2200 {x}, x \u2208 s \u2192 x\u207b\u00b9 \u2208 s)\nend\nnamespace subgroup\nvariables {\u03b1 : Type*} [g : group \u03b1]\ninclude g\n\ninstance group (s : set \u03b1) [subgroup s] : group s :=\n{ mul := \u03bb \u27e8x, hx\u27e9 \u27e8y, hy\u27e9, \u27e8x * y, mul_mem hx hy\u27e9,\n  mul_assoc := \u03bb \u27e8x, hx\u27e9 \u27e8y, hy\u27e9 \u27e8z, hz\u27e9, subtype.eq $ mul_assoc _ _ _,\n  one := \u27e81, one_mem s\u27e9,\n  one_mul := \u03bb \u27e8x, hx\u27e9, subtype.eq $ one_mul _,\n  mul_one := \u03bb \u27e8x, hx\u27e9, subtype.eq $ mul_one _,\n  inv := \u03bb \u27e8x, hx\u27e9, \u27e8x\u207b\u00b9, inv_mem hx\u27e9,\n  mul_left_inv := \u03bb \u27e8x, hx\u27e9, subtype.eq $ mul_left_inv _ }\n\n@[simp] lemma coe_one (S : set \u03b1) [subgroup S] : ((1 : S) : \u03b1) = 1 := rfl\n\n@[simp] lemma coe_mul {S : set \u03b1} [subgroup S] : \u2200 a b : S, ((a * b : S) : \u03b1) = (a : \u03b1) * (b : \u03b1) :=\n\u03bb \u27e8a, ha\u27e9 \u27e8b, hb\u27e9, rfl\n\n@[simp] lemma coe_inv {S : set \u03b1} [subgroup S] : \u2200 a : S, ((a\u207b\u00b9 : S) : \u03b1) = (a : \u03b1)\u207b\u00b9 := \n\u03bb \u27e8a, ha\u27e9, rfl\n\n@[simp] lemma coe_pow {S : set \u03b1} [subgroup S] (a : S) (n : \u2115) : ((monoid.pow a n : S) : \u03b1) = monoid.pow a n := \nby induction n; simp[pow_succ, *]\n\n@[simp] lemma coe_gpow {S : set \u03b1} [subgroup S] (a : S) (i : \u2124) : ((gpow a i : S) : \u03b1) = gpow a i :=\nby cases i; simp\n\nend subgroup\n\nsection cyclic \n\nclass cyclic_group (\u03b1 : Type*) extends group \u03b1 :=\n(cyclic : \u2203 a, \u2200 b : \u03b1, \u2203 i : \u2124, a^i = b)\n\ninstance cyclic_group.comm_group {\u03b1 : Type*} [h : cyclic_group \u03b1] : comm_group \u03b1 := \n{ mul_comm :=\n  \u03bb x y, let \u27e8a, ha\u27e9 := cyclic_group.cyclic \u03b1 in\n         let \u27e8i, hi\u27e9 := ha x in\n         let \u27e8j, hj\u27e9 := ha y in\n         hi \u25b8 hj \u25b8 gpow_mul_comm a i j,\n  ..h }\n\nvariables {\u03b1 : Type*} [group \u03b1]\n\ndef cycle (a : \u03b1) := {b : \u03b1 | \u2203 i : \u2124, a^i = b}\n\ninstance [fintype \u03b1] (a : \u03b1) : fintype (cycle a) := set_fintype _\n\ninstance (a : \u03b1) : subgroup (cycle a) := \n{ one_mem := \u27e80, by simp\u27e9,\n  inv_mem := \u03bb b \u27e8i, hi\u27e9, \u27e8-i, hi \u25b8 gpow_neg _ _\u27e9,\n  mul_mem := \u03bb b c \u27e8i, hi\u27e9 \u27e8j, hj\u27e9, \u27e8i + j, hi \u25b8 (hj \u25b8 (gpow_add _ _ _))\u27e9 }\n\ninstance (a : \u03b1) : cyclic_group (cycle a) :=\n{ cyclic := \u27e8\u27e8a, 1, pow_one _\u27e9, \u03bb \u27e8b, \u27e8i, hi\u27e9\u27e9, \n\u27e8i, subtype.eq ((subgroup.coe_gpow (\u27e8a, _\u27e9 : cycle a) i).trans hi)\u27e9 \u27e9 }\n\nlemma mem_cycle_self (a : \u03b1) [fintype (cycle a)] : a \u2208 cycle a := \u27e81, by simp\u27e9\n\nlemma exists_int_pow_eq_one_of_finite_cycle (a : \u03b1) [fintype (cycle a)] : \u2203 i : \u2124, i \u2260 0 \u2227 a^i = 1 :=\nby_contradiction $ \u03bb h, @not_injective_nat_fintype _ _ _ \n(\u03bb n, (\u27e8a^(nat.succ n), \u27e8int.nat_abs (nat.succ n), by rw [int.nat_abs_of_nat] \u27e9 \u27e9 : cycle a)) $\nhave h : \u2200 i : \u2124, \u00ac(i \u2260 0 \u2227 a^i = 1) := not_exists.mp h,\nhave h\u2081 : \u2200 (i : \u2124), a^i = 1 \u2192 \u00aci \u2260 0 := \u03bb i, not_and'.mp (h i),\n\u03bb m n hmn, have hmn' : a^(nat.succ m) =a^(nat.succ n) := subtype.mk.inj hmn,\nbegin \n  rw [\u2190 sub_add_cancel ((nat.succ m) : \u2124) (nat.succ n), gpow_add, \u2190 mul_right_inj (a^nat.succ n)\u207b\u00b9,\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\u2081 _ hmn') \nend\n\nlemma exists_nat_pow_eq_one_of_finite_cycle (a : \u03b1) [fintype (cycle a)] :\n    \u2203 n : \u2115, 0 < n \u2227 monoid.pow a n = 1 :=\nlet \u27e8i, hi\u27e9 := exists_int_pow_eq_one_of_finite_cycle a in\n\u27e8int.nat_abs i, \u27e8int.nat_abs_pos_of_ne_zero hi.1,\nor.by_cases (int.nat_abs_eq i) \n(\u03bb h, by rw h at hi; exact (gpow_coe_nat _ _).symm.trans hi.2) \n(\u03bb h, by rw [h, gpow_neg] at hi; exact (gpow_coe_nat _ _).symm.trans (inv_eq_one.1 hi.2)) \u27e9 \u27e9\n\ndef ord (a : \u03b1) [fintype (cycle a)] := nat.find $ exists_nat_pow_eq_one_of_finite_cycle a\n\nvariables (a : \u03b1) [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 : \u03b1} [fintype (cycle a)] {n : \u2115} (ha0 : 0 < n) (han : monoid.pow a n = 1) : ord a \u2264 n :=\nnat.find_min' (exists_nat_pow_eq_one_of_finite_cycle a) \u27e8ha0, han\u27e9\n\nlemma lt_ord {a : \u03b1} [fintype (cycle a)] {n : \u2115} (hn : n < ord a) : n = 0 \u2228 monoid.pow a n \u2260 1 :=\nhave h : \u00ac0 < n \u2228 \u00ac 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 : \u2124) : (ord a : \u2124) \u2223 i \u2194 a^i = 1 :=\n\u27e8\u03bb h\u2081, let \u27e8k, hk\u27e9 := exists_eq_mul_right_of_dvd h\u2081 in by simp [hk, gpow_mul, pow_ord],\n\u03bb h\u2081, by_contradiction $ \u03bb h\u2082,\nbegin \n  rw int.dvd_iff_mod_eq_zero at h\u2082,\n  have h\u2083 : gpow a (i % \u2191(ord a)) = 1,\n  { rw \u2190 int.mod_add_div i (ord a) at h\u2081,\n    simp [gpow_add, gpow_mul] at h\u2081,\n    exact h\u2081 },\n  have hzc := int.coe_nat_ne_zero.2 (ne_of_lt (ord_pos a)).symm,\n  have h\u2084 : (int.nat_abs (i % ord a) : \u2124) = (i % ord a) := \n    int.nat_abs_of_nonneg (int.mod_nonneg _ hzc),\n  have h\u2085 : monoid.pow a (int.nat_abs (i % \u2191(ord a))) = 1 := by rwa [\u2190 gpow_coe_nat, h\u2084],\n  have h\u2086 : (ord a : \u2124) \u2264 (i % \u2191(ord a)) := by rw [\u2190 h\u2084, int.coe_nat_le];\n    exact ord_le (int.nat_abs_pos_of_ne_zero h\u2082) h\u2085,\n  have h\u2087 := int.mod_lt i hzc,\n  rw abs_of_nonneg (int.coe_nat_le.2 (nat.zero_le _)) at h\u2087,\n  exact not_le_of_gt h\u2087 h\u2086,\nend\u27e9\n\nlemma ord_dvd_nat_iff (n : \u2115) : ord a \u2223 n \u2194 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 : \u2124) (a : \u03b1) (hi : i \u2260 0) (h : a^i = 1) : fintype (cycle a) :=\nfintype.of_surjective\n(\u03bb n : fin (int.nat_abs i), (\u27e8monoid.pow a n.val, n.val, by simp\u27e9 : cycle a)) $\n\u03bb \u27e8b, j, hj\u27e9, have hji : 0 \u2264 j % i := int.mod_nonneg _ hi,\n\u27e8\u27e8int.nat_abs (j % i), \nby rw [\u2190 int.coe_nat_lt, int.nat_abs_of_nonneg hji, \u2190 int.abs_eq_nat_abs];\nexact int.mod_lt _ hi\u27e9, \nsubtype.eq $ show monoid.pow a (int.nat_abs (j % i)) = b,\nby rw [\u2190 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\u27e9\n\n-- lemma ord_eq_cycle_card (a : \u03b1) [fintype (cycle a)] : ord a = card (cycle a) :=\n-- card_fin (ord a) \u25b8 card_congr\n-- \u27e8\u03bb (n : fin (ord a)), (\u27e8monoid.pow a n.val, \u27e8n.val, by simp\u27e9\u27e9 : cycle a),\n-- \u03bb \u27e8b, hb\u27e9, have ho : (0 : \u2124) < ord a := int.coe_nat_lt.2 (ord_pos a),\n-- have h\u2081 : classical.some hb % \u2191(ord a) \u2265 0 := int.mod_nonneg _ (ne_of_lt ho).symm,\n-- \u27e8int.nat_abs (classical.some hb % (ord a : \u2124)),\n-- int.coe_nat_lt.1 ((int.nat_abs_of_nonneg h\u2081).symm \u25b8 int.mod_lt_of_pos _ ho)\u27e9,\n-- \u03bb \u27e8n, hn\u27e9, begin cases lt_ord hn with h h,\n-- simp [h],\n--  end,sorry\u27e9\n\n-- too long\n\nlemma ord_eq_cycle_card (a : \u03b1) [fintype (cycle a)] : ord a = fintype.card (cycle a) :=\nfintype.card_fin (ord a) \u25b8 (fintype.card_congr $ equiv.of_bijective $ \nshow function.bijective (\u03bb (n : fin (ord a)), (\u27e8monoid.pow a n.val, \u27e8n.val, by simp\u27e9\u27e9 : cycle a)), from\n\u27e8\u03bb 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 \u2264 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 [\u2190 nat.sub_add_cancel h, \u2190 one_mul (monoid.pow a m), pow_add, mul_right_inj] at h_1,\n  have h\u2081 := 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, \u03bb \u27e8x, \u27e8i, hi\u27e9 \u27e9, -- surjective proof\nhave ho : (ord a : \u2124) \u2260 0 := int.coe_nat_ne_zero.2 (ne_of_lt (ord_pos _)).symm,\nhave hio : (int.to_nat (i % \u2191(ord a)) : \u2124) = i % ord a := int.to_nat_of_nonneg (int.mod_nonneg _ ho),\n\u27e8\u27e8int.to_nat (i % (ord a : \u2124)), int.coe_nat_lt.1 $ \nby rw [hio, \u2190 abs_of_nonneg (int.coe_nat_le.2 (nat.zero_le (ord a))), int.mod_abs];\nexact int.mod_lt _ ho\u27e9,\nbegin\n  simp,\n  rw [\u2190 gpow_coe_nat, hio, int.mod_def],\n  simp [gpow_add, gpow_mul, gpow_neg, hi]\nend\u27e9\u27e9)\n#print ord_eq_cycle_card\nend cyclic\n\nsection coset\n\nopen subgroup\n\nvariables {\u03b1 : Type*} [group \u03b1] (S : set \u03b1) [subgroup S]\n\ndef lcoset (b : \u03b1) := {a : \u03b1 | \u2203 s \u2208 S, b * s = a}\n\ndef rcoset (b : \u03b1) := {a : \u03b1 | \u2203 s \u2208 S, s * b = a}\n\nlemma lcoset_eq {S : set \u03b1} [subgroup S] {a b : \u03b1} : b \u2208 lcoset S a \u2192 lcoset S a = lcoset S b :=\n\u03bb \u27e8sa, hSsa, hsa\u27e9, set.ext $ \u03bb x, \n\u27e8\u03bb \u27e8sb, hSsb, hsb\u27e9, \u27e8sa\u207b\u00b9 * sb, \u27e8mul_mem (inv_mem hSsa) hSsb, hsa \u25b8 by simpa [mul_assoc] \u27e9 \u27e9,\n\u03bb \u27e8sb, hSsb, hsb\u27e9, \u27e8sa * sb, \u27e8mul_mem hSsa hSsb, mul_assoc a sa sb \u25b8 hsa.symm \u25b8 hsb \u27e9 \u27e9 \u27e9 \n\nlemma rcoset_eq {S : set \u03b1} [subgroup S] {a b : \u03b1} : b \u2208 rcoset S a \u2192 rcoset S a = rcoset S b :=\n\u03bb \u27e8sa, hSsa, hsa\u27e9, set.ext $ \u03bb x, \n\u27e8\u03bb \u27e8sb, hSsb, hsb\u27e9, \u27e8sb * sa\u207b\u00b9, \u27e8mul_mem hSsb (inv_mem hSsa), hsa \u25b8 by simpa [mul_assoc] \u27e9 \u27e9,\n\u03bb \u27e8sb, hSsb, hsb\u27e9, \u27e8sb * sa, \u27e8mul_mem hSsb hSsa, (mul_assoc sb sa a).symm \u25b8 hsa.symm \u25b8 hsb \u27e9 \u27e9 \u27e9 \n\n@[simp] lemma mem_lcoset_self (a : \u03b1) : a \u2208 lcoset S a := \u27e81, one_mem _, mul_one _\u27e9\n\n@[simp] lemma mem_rcoset_self (a : \u03b1) : a \u2208 rcoset S a := \u27e81, one_mem _, one_mul _\u27e9\n\nlemma lcoset_card [fintype \u03b1] (a : \u03b1) : card (lcoset S a) = fintype.card S :=\nfintype.card_congr $ @equiv.of_bijective (lcoset S a) S \n(\u03bb x, \u27e8a\u207b\u00b9 * x, let \u27e8y, hyS, (hy : a * y = x)\u27e9 := x.2 in by rwa \u2190 hy; simpa\u27e9) \n\u27e8\u03bb x y h, by simp at h; exact subtype.eq h, \u03bb x, \u27e8 \u27e8a * x, \u27e8x, \u27e8x.2, rfl\u27e9 \u27e9 \u27e9, by simp \u27e9 \u27e9\n\nlemma rcoset_card [fintype \u03b1] (a : \u03b1) : card (rcoset S a) = fintype.card S :=\nfintype.card_congr $ @equiv.of_bijective (rcoset S a) S \n(\u03bb x, \u27e8x * a\u207b\u00b9, let \u27e8y, hyS, (hy : y *  a = x)\u27e9 := x.2 in by rwa \u2190 hy; simpa\u27e9) \n\u27e8\u03bb x y h, by simp at h; exact subtype.eq h, \u03bb x, \u27e8 \u27e8x * a, \u27e8x, \u27e8x.2, rfl\u27e9 \u27e9 \u27e9, by simp \u27e9 \u27e9\n\ninstance lcoset_setoid : setoid \u03b1 := \n{ r := \u03bb a b, b \u2208 lcoset S a,\n  iseqv := \u27e8mem_lcoset_self S,\n  \u03bb a b h, by rw \u2190 lcoset_eq h; exact mem_lcoset_self S a,\n  \u03bb a b c hab hbc, by rwa lcoset_eq hab\u27e9 }\n\ndef index [fintype \u03b1] := card (quotient (lcoset_setoid S))\n\ntheorem lagrange [fintype \u03b1] : card \u03b1 = card S * index S :=\nhave h : (\u03bb x : quotient (lcoset_setoid S), card {a // \u27e6a\u27e7 = x}) = (\u03bb x, card S) := \n  funext (\u03bb x, begin\n    simp only [@eq_comm _ _ x],\n    rw [\u2190 quot.out_eq x, \u2190 lcoset_card S (quot.out x)],\n    congr,\n    exact set.ext (\u03bb 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 {\u03b1 : Type*} [group \u03b1] [fintype \u03b1] (a : \u03b1) : card \u03b1 = ord a * index (cycle a) :=\n(ord_eq_cycle_card a).symm \u25b8 lagrange _\n\n@[simp] lemma pow_card {\u03b1 : Type*} [group \u03b1] [fintype \u03b1] (a : \u03b1) : monoid.pow a (card \u03b1) = 1 :=\n(ord_dvd_nat_iff _ _).1 $ (card_eq_ord_mul_index a).symm \u25b8 dvd_mul_right _ _\n\nopen equiv\n\nnamespace perm\nvariables {\u03b1 : Type*}\n\nlemma mul_apply (a b : perm \u03b1) (x : \u03b1) : (a * b) x = (a (b x)) := rfl\n\n@[simp] lemma one_apply (x : \u03b1) : (1 : perm \u03b1) x = x := rfl\n\ninstance [decidable_eq \u03b1] (h : fintype \u03b1): fintype (perm \u03b1) := \nfintype.of_equiv {y : (\u03b1 \u2192 \u03b1) \u00d7 (\u03b1 \u2192 \u03b1) // function.left_inverse y.2 y.1 \u2227 function.right_inverse y.2 y.1}\n\u27e8\u03bb x, \u27e8x.1.1, x.1.2, x.2.1, x.2.2\u27e9, \u03bb x, \u27e8\u27e8x.1, x.2\u27e9, \u27e8x.3, x.4\u27e9\u27e9, \u03bb \u27e8\u27e8_, _\u27e9, _, _\u27e9, rfl, \u03bb \u27e8_, _, _, _\u27e9, rfl\u27e9\n\ninstance perm.cycle.fintype [h : fintype \u03b1] (a : perm \u03b1) : fintype (cycle a) := @cycle.fintype (perm \u03b1) _ (perm.fintype h) a\n\ndef support (a : perm \u03b1) : set \u03b1 := {x : \u03b1 | a x \u2260 x}\n\nexample (f g : perm \u03b1) : support (g * f * g\u207b\u00b9) = set.image g (support f) :=\nset.ext $ \u03bb y, \u27e8\u03bb h : _ \u2260 _, \u27e8g\u207b\u00b9 y, \u03bb h\u2081, by\n  rw [mul_apply, mul_apply, h\u2081, \u2190 mul_apply, mul_inv_self] at h;\n  exact h rfl,\nshow (g * g\u207b\u00b9) y = y,by rw mul_inv_self; refl\u27e9, \n\u03bb \u27e8x, (hx : _ \u2260 _ \u2227 _)\u27e9, show _ \u2260 _, from\nbegin \n  rw [mul_apply, \u2190 hx.2, \u2190 mul_apply, \u2190 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\u27e9\n\ndef disjoint (a b : perm \u03b1) := _root_.disjoint (support a) (support b)\n\nlemma disjoint_or {a b : perm \u03b1} : disjoint a b \u2194 \u2200 x : \u03b1, a x = x \u2228 b x = x :=\nhave h : disjoint a b \u2194 \u2200 x : \u03b1, \u00ac (a x \u2260 x \u2227 b x \u2260 x) := \n  \u27e8\u03bb (h : (\u03bb x, a x \u2260 x \u2227 b x \u2260 x : set \u03b1) = \u2205) x, \n  show x \u2209 {x : \u03b1 | a x \u2260 x \u2227 b x \u2260 x}, by rw h; simp, \n\u03bb h, set.ext $ \u03bb x, \u27e8\u03bb h\u2081, absurd h\u2081 (h x), \u03bb h\u2081, absurd h\u2081 (set.not_mem_empty _)\u27e9\u27e9,\nby rw h; simp only [or_iff_not_and_not]\n\nlemma disjoint_comm {a b : perm \u03b1} (hd : disjoint a b) : a * b = b * a := \nequiv.ext _ _ $ \u03bb x, show a (b x) = b (a x), from or.by_cases (disjoint_or.1 hd x) \n(\u03bb h, h.symm \u25b8 or.by_cases (disjoint_or.1 hd $ b x) (\u03bb h\u2081, h\u2081) (\u03bb h\u2081, ((equiv.bijective b).1 h\u2081).symm \u25b8 h))\n(\u03bb h, h.symm \u25b8 or.by_cases (disjoint_or.1 hd $ a x) (\u03bb h\u2081, ((equiv.bijective a).1 h\u2081.symm) \u25b8 h.symm) (\u03bb h\u2081, h\u2081.symm))\n\nlemma eq_one_of_support_eq_empty {a : perm \u03b1} [fintype (support a)] (h : support a = \u2205) : a = 1 :=\next _ _ $ \u03bb x, have hx : x \u2209 support a := h.symm \u25b8 set.not_mem_empty x, not_not.1 hx\n\nlemma exists_mem_support_of_ne_one {a : perm \u03b1} (h : a \u2260 1) : \u2203 x : \u03b1, x \u2208 support a :=\nby_contradiction $ \u03bb h\u2081, h $ ext _ _ $ by simp [support, *] at *\n\ndef same_cycle (a : perm \u03b1) (x y : \u03b1) := \u2203 i : \u2124, (a^i) x = y\n\n@[refl] lemma same_cycle.refl {a : perm \u03b1} (x : \u03b1) : same_cycle a x x := \u27e80, by rw gpow_zero; refl\u27e9\n\n@[symm] lemma same_cycle.symm {a : perm \u03b1} {x y : \u03b1} (h : same_cycle a x y) : same_cycle a y x :=\nlet \u27e8i, hi\u27e9 := h in \u27e8-i, by rw [\u2190 hi, \u2190mul_apply, \u2190 gpow_add, neg_add_self, gpow_zero, one_apply] \u27e9 \n\n@[trans] lemma same_cycle.trans {a : perm \u03b1} {x y z : \u03b1} (hxy : same_cycle a x y) (hyz : same_cycle a y z)\n    : same_cycle a x z :=\nlet \u27e8i, hi\u27e9 := hxy in let \u27e8j, hj\u27e9 := hyz in \u27e8j + i, begin rw [gpow_add, mul_apply, hi], simp [hi, hj] end\u27e9\n\nlemma same_cycle_apply {a : perm \u03b1} {x y : \u03b1} (h : same_cycle a x y) (i : \u2124) : same_cycle a ((a^i) x) y :=\nsame_cycle.trans (same_cycle.symm (\u27e8i, rfl\u27e9 : same_cycle a x ((a^i) x))) h\n\ndef cycle_of (a : perm \u03b1) (x : \u03b1) : perm \u03b1 :=\n{ to_fun   := \u03bb y, ite (same_cycle a x y) (a y) y,\n  inv_fun  := \u03bb y, ite (same_cycle a x y) (a\u207b\u00b9 y) y,\n  left_inv := \u03bb y, dite (same_cycle a x y)\n  (\u03bb h, have h\u2081 : same_cycle a x (a y) := same_cycle.symm (same_cycle_apply (same_cycle.symm h) 1), \n    by simp [h, h\u2081]; rw [\u2190 mul_apply, inv_mul_self, one_apply]) \n  (\u03bb h, by simp [h]),\n  right_inv := \u03bb y, dite (same_cycle a x y) \n  (\u03bb h, have h\u2081 : same_cycle a x (a\u207b\u00b9 y) := same_cycle.symm (same_cycle_apply (same_cycle.symm h) (-1)),\n    by simp [h, h\u2081]; rw [\u2190 mul_apply, mul_inv_self, one_apply]) \n  (\u03bb h, by simp [h]) }\n\ndef is_cycle (a : perm \u03b1) := a \u2260 1 \u2227 \u2200 x y : \u03b1, x \u2208 support a \u2192 y \u2208 support a \u2192 same_cycle a x y\n\nlemma support_disjoint_mul {a b : perm \u03b1} (h : disjoint a b) : support (a * b) = support a \u222a support b :=\nset.ext $ \u03bb x, or.by_cases (disjoint_or.1 h x) \n(\u03bb h\u2081, \u27e8\u03bb h\u2082, or.inr (have h\u2082 : b (a x) \u2260 x := by rw disjoint_comm h at h\u2082; exact h\u2082, by rw h\u2081 at h\u2082; exact h\u2082),\n\u03bb h\u2082, by rw disjoint_comm h; exact show b (a x) \u2260 x, by rw h\u2081; exact or.resolve_left h\u2082 (not_not.2 h\u2081)\u27e9) \n(\u03bb h\u2081, \u27e8\u03bb (h\u2082 : a (b x) \u2260 x), or.inl $ by rw h\u2081 at h\u2082; exact h\u2082,\n\u03bb h\u2082, show a (b x) \u2260 x, by rw h\u2081; exact or.resolve_right h\u2082 (not_not.2 h\u2081)\u27e9)\n\nlemma exists_disjoint_factors [fintype \u03b1] (a : perm \u03b1) (h : \u00ac is_cycle a) (h\u2081 : a \u2260 1) :\n    \u2203 b c : perm \u03b1, disjoint b c \u2227 b * c = a \u2227 card (support b) < card (support a) \u2227 \n    card (support c) < card (support a) :=\nbegin\n  suffices : \u2200 (n : \u2115) (a : perm \u03b1), \u00ac is_cycle a \u2192 a \u2260 1 \u2192 card (support a) \u2264 n \u2192 \n      \u2203 b c : perm \u03b1, disjoint b c \u2227 b * c = a \u2227 card (support b) < card (support a) \u2227 \n      card (support c) < card (support a),\n  exact this (card (support a)) a h h\u2081 (le_refl _),\n  assume n,\n  induction n with n hi,\n  { assume a h h\u2081 h\u2082,\n    exact absurd (eq_one_of_support_eq_empty (set.card_eq_zero.1 (nat.eq_zero_of_le_zero h\u2082))) h\u2081 },\n  { assume a h h\u2081 h\u2082,\n    cases exists_mem_support_of_ne_one h\u2081 with x hx,\n    \n     }\nend\n\n-- lemma product_disjoint [fintype \u03b1] (a : perm \u03b1) : \u2203 l : list (perm \u03b1), (\u2200 b \u2208 l, is_cycle b \u2227 b \u2260 1) \u2227 (\u2200 b c \u2208 l, disjoint b c) \u2227 list.prod l = a :=\n-- begin\n--   suffices : \u2200 (n : \u2115) (a : perm \u03b1), ord a \u2264 n \u2192 \u2203 l : list (perm \u03b1), (\u2200 b \u2208 l, is_cycle b \u2227 b \u2260 1) \u2227 (\u2200 b c \u2208 l, disjoint b c) \u2227 list.prod l = a,\n--   { exact this (ord a) a (le_refl _) },\n--   assume n,\n--   induction n with n hi,\n--   { exact \u03bb 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 \u03b1 \u2192 Prop where\n  | nil      : Palindrome []\n  | single   : (a : \u03b1) \u2192 Palindrome [a]\n  | sandwish : (a : \u03b1) \u2192 Palindrome as \u2192 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) \u2192 (a = [] \u2227 b = [] \u2227 c=d) := by\n  {\n    intro h,\n    have h1 : a=[] := by\n    {\n      rw [\u2190list.length_eq_zero, \u2190le_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 [\u2190h],\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\u00e9my 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 \u03bc := integrable f (\u03bc.restrict s)` and prove theorems like\n`integrable_on_union : integrable_on f (s \u222a t) \u03bc \u2194 integrable_on f s \u03bc \u2227 integrable_on f t \u03bc`.\n\nNext we define a predicate `integrable_at_filter (f : \u03b1 \u2192 E) (l : filter \u03b1) (\u03bc : measure \u03b1)`\nsaying that `f` is integrable at some set `s \u2208 l` and prove that a measurable function is integrable\nat `l` with respect to `\u03bc` provided that `f` is bounded above at `l \u2293 \u03bc.ae` and `\u03bc` 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 {\u03b1 \u03b2 E F : Type*} [measurable_space \u03b1]\n\nsection\n\nvariables [topological_space \u03b2] {l l' : filter \u03b1} {f g : \u03b1 \u2192 \u03b2} {\u03bc \u03bd : measure \u03b1}\n\n/-- A function `f` is strongly measurable at a filter `l` w.r.t. a measure `\u03bc` if it is\nae strongly measurable w.r.t. `\u03bc.restrict s` for some `s \u2208 l`. -/\ndef strongly_measurable_at_filter (f : \u03b1 \u2192 \u03b2) (l : filter \u03b1) (\u03bc : measure \u03b1 . volume_tac) :=\n\u2203 s \u2208 l, ae_strongly_measurable f (\u03bc.restrict s)\n\n@[simp] lemma strongly_measurable_at_bot {f : \u03b1 \u2192 \u03b2} : strongly_measurable_at_filter f \u22a5 \u03bc :=\n\u27e8\u2205, mem_bot, by simp\u27e9\n\nprotected lemma strongly_measurable_at_filter.eventually (h : strongly_measurable_at_filter f l \u03bc) :\n  \u2200\u1da0 s in l.lift' powerset, ae_strongly_measurable f (\u03bc.restrict s) :=\n(eventually_lift'_powerset' $ \u03bb 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 \u03bc) (h' : l' \u2264 l) :\n  strongly_measurable_at_filter f l' \u03bc :=\nlet \u27e8s, hsl, hs\u27e9 := h in \u27e8s, h' hsl, hs\u27e9\n\nprotected lemma measure_theory.ae_strongly_measurable.strongly_measurable_at_filter\n  (h : ae_strongly_measurable f \u03bc) :\n  strongly_measurable_at_filter f l \u03bc :=\n\u27e8univ, univ_mem, by rwa measure.restrict_univ\u27e9\n\nlemma ae_strongly_measurable.strongly_measurable_at_filter_of_mem\n  {s} (h : ae_strongly_measurable f (\u03bc.restrict s)) (hl : s \u2208 l) :\n  strongly_measurable_at_filter f l \u03bc :=\n\u27e8s, hl, h\u27e9\n\nprotected lemma measure_theory.strongly_measurable.strongly_measurable_at_filter\n  (h : strongly_measurable f) :\n  strongly_measurable_at_filter f l \u03bc :=\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 : \u03b1 \u2192 E} {s : set \u03b1}\n  {\u03bc : measure \u03b1} {C}  (hs : \u03bc s < \u221e) (hf : \u2200\u1d50 x \u2202(\u03bc.restrict s), \u2225f x\u2225 \u2264 C) :\n  has_finite_integral f (\u03bc.restrict s) :=\nby haveI : is_finite_measure (\u03bc.restrict s) := \u27e8by rwa [measure.restrict_apply_univ]\u27e9;\n  exact has_finite_integral_of_bounded hf\n\nvariables [normed_group E] {f g : \u03b1 \u2192 E} {s t : set \u03b1} {\u03bc \u03bd : measure \u03b1}\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 : \u03b1 \u2192 E) (s : set \u03b1) (\u03bc : measure \u03b1 . volume_tac) : Prop :=\nintegrable f (\u03bc.restrict s)\n\nlemma integrable_on.integrable (h : integrable_on f s \u03bc) :\n  integrable f (\u03bc.restrict s) := h\n\n@[simp] lemma integrable_on_empty : integrable_on f \u2205 \u03bc :=\nby simp [integrable_on, integrable_zero_measure]\n\n@[simp] lemma integrable_on_univ : integrable_on f univ \u03bc \u2194 integrable f \u03bc :=\nby rw [integrable_on, measure.restrict_univ]\n\nlemma integrable_on_zero : integrable_on (\u03bb _, (0:E)) s \u03bc := integrable_zero _ _ _\n\n@[simp] lemma integrable_on_const {C : E} : integrable_on (\u03bb _, C) s \u03bc \u2194 C = 0 \u2228 \u03bc s < \u221e :=\nintegrable_const_iff.trans $ by rw [measure.restrict_apply_univ]\n\nlemma integrable_on.mono (h : integrable_on f t \u03bd) (hs : s \u2286 t) (h\u03bc : \u03bc \u2264 \u03bd) :\n  integrable_on f s \u03bc :=\nh.mono_measure $ measure.restrict_mono hs h\u03bc\n\nlemma integrable_on.mono_set (h : integrable_on f t \u03bc) (hst : s \u2286 t) :\n  integrable_on f s \u03bc :=\nh.mono hst le_rfl\n\nlemma integrable_on.mono_measure (h : integrable_on f s \u03bd) (h\u03bc : \u03bc \u2264 \u03bd) :\n  integrable_on f s \u03bc :=\nh.mono (subset.refl _) h\u03bc\n\nlemma integrable_on.mono_set_ae (h : integrable_on f t \u03bc) (hst : s \u2264\u1d50[\u03bc] t) :\n  integrable_on f s \u03bc :=\nh.integrable.mono_measure $ measure.restrict_mono_ae hst\n\nlemma integrable_on.congr_set_ae (h : integrable_on f t \u03bc) (hst : s =\u1d50[\u03bc] t) :\n  integrable_on f s \u03bc :=\nh.mono_set_ae hst.le\n\nlemma integrable_on.congr_fun' (h : integrable_on f s \u03bc) (hst : f =\u1d50[\u03bc.restrict s] g) :\n  integrable_on g s \u03bc :=\nintegrable.congr h hst\n\nlemma integrable_on.congr_fun (h : integrable_on f s \u03bc) (hst : eq_on f g s)\n  (hs : measurable_set s) :\n  integrable_on g s \u03bc :=\nh.congr_fun' ((ae_restrict_iff' hs).2 (eventually_of_forall hst))\n\nlemma integrable.integrable_on (h : integrable f \u03bc) : integrable_on f s \u03bc :=\nh.mono_measure $ measure.restrict_le_self\n\nlemma integrable.integrable_on' (h : integrable f (\u03bc.restrict s)) : integrable_on f s \u03bc :=\nh\n\nlemma integrable_on.restrict (h : integrable_on f s \u03bc) (hs : measurable_set s) :\n  integrable_on f s (\u03bc.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 \u222a t) \u03bc) : integrable_on f s \u03bc :=\nh.mono_set $ subset_union_left _ _\n\nlemma integrable_on.right_of_union (h : integrable_on f (s \u222a t) \u03bc) : integrable_on f t \u03bc :=\nh.mono_set $ subset_union_right _ _\n\nlemma integrable_on.union (hs : integrable_on f s \u03bc) (ht : integrable_on f t \u03bc) :\n  integrable_on f (s \u222a t) \u03bc :=\n(hs.add_measure ht).mono_measure $ measure.restrict_union_le _ _\n\n@[simp] lemma integrable_on_union :\n  integrable_on f (s \u222a t) \u03bc \u2194 integrable_on f s \u03bc \u2227 integrable_on f t \u03bc :=\n\u27e8\u03bb h, \u27e8h.left_of_union, h.right_of_union\u27e9, \u03bb h, h.1.union h.2\u27e9\n\n@[simp] lemma integrable_on_singleton_iff {x : \u03b1} [measurable_singleton_class \u03b1] :\n  integrable_on f {x} \u03bc \u2194 f x = 0 \u2228 \u03bc {x} < \u221e :=\nbegin\n  have : f =\u1d50[\u03bc.restrict {x}] (\u03bb 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 \u03b2} (hs : finite s)\n  {t : \u03b2 \u2192 set \u03b1} : integrable_on f (\u22c3 i \u2208 s, t i) \u03bc \u2194 \u2200 i \u2208 s, integrable_on f (t i) \u03bc :=\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 \u03b2} {t : \u03b2 \u2192 set \u03b1} :\n  integrable_on f (\u22c3 i \u2208 s, t i) \u03bc \u2194 \u2200 i \u2208 s, integrable_on f (t i) \u03bc :=\nintegrable_on_finite_Union s.finite_to_set\n\n@[simp] lemma integrable_on_fintype_Union [fintype \u03b2] {t : \u03b2 \u2192 set \u03b1} :\n  integrable_on f (\u22c3 i, t i) \u03bc \u2194 \u2200 i, integrable_on f (t i) \u03bc :=\nby simpa using @integrable_on_finset_Union _ _ _ _ _ f \u03bc finset.univ t\n\nlemma integrable_on.add_measure (h\u03bc : integrable_on f s \u03bc) (h\u03bd : integrable_on f s \u03bd) :\n  integrable_on f s (\u03bc + \u03bd) :=\nby { delta integrable_on, rw measure.restrict_add, exact h\u03bc.integrable.add_measure h\u03bd }\n\n@[simp] lemma integrable_on_add_measure :\n  integrable_on f s (\u03bc + \u03bd) \u2194 integrable_on f s \u03bc \u2227 integrable_on f s \u03bd :=\n\u27e8\u03bb h, \u27e8h.mono_measure (measure.le_add_right le_rfl),\n  h.mono_measure (measure.le_add_left le_rfl)\u27e9,\n  \u03bb h, h.1.add_measure h.2\u27e9\n\nlemma _root_.measurable_embedding.integrable_on_map_iff [measurable_space \u03b2] {e : \u03b1 \u2192 \u03b2}\n  (he : measurable_embedding e) {f : \u03b2 \u2192 E} {\u03bc : measure \u03b1} {s : set \u03b2} :\n  integrable_on f s (measure.map e \u03bc) \u2194 integrable_on (f \u2218 e) (e \u207b\u00b9' s) \u03bc :=\nby simp only [integrable_on, he.restrict_map, he.integrable_map_iff]\n\nlemma integrable_on_map_equiv [measurable_space \u03b2] (e : \u03b1 \u2243\u1d50 \u03b2) {f : \u03b2 \u2192 E} {\u03bc : measure \u03b1}\n  {s : set \u03b2} :\n  integrable_on f s (measure.map e \u03bc) \u2194 integrable_on (f \u2218 e) (e \u207b\u00b9' s) \u03bc :=\nby simp only [integrable_on, e.restrict_map, integrable_map_equiv e]\n\nlemma measure_preserving.integrable_on_comp_preimage [measurable_space \u03b2] {e : \u03b1 \u2192 \u03b2} {\u03bd}\n  (h\u2081 : measure_preserving e \u03bc \u03bd) (h\u2082 : measurable_embedding e) {f : \u03b2 \u2192 E} {s : set \u03b2} :\n  integrable_on (f \u2218 e) (e \u207b\u00b9' s) \u03bc \u2194 integrable_on f s \u03bd :=\n(h\u2081.restrict_preimage_emb h\u2082 s).integrable_comp_emb h\u2082\n\nlemma measure_preserving.integrable_on_image [measurable_space \u03b2] {e : \u03b1 \u2192 \u03b2} {\u03bd}\n  (h\u2081 : measure_preserving e \u03bc \u03bd) (h\u2082 : measurable_embedding e) {f : \u03b2 \u2192 E} {s : set \u03b1} :\n  integrable_on f (e '' s) \u03bd \u2194  integrable_on (f \u2218 e) s \u03bc :=\n((h\u2081.restrict_image_emb h\u2082 s).integrable_comp_emb h\u2082).symm\n\nlemma integrable_indicator_iff (hs : measurable_set s) :\n  integrable (indicator s f) \u03bc \u2194 integrable_on f s \u03bc :=\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 \u03bc) (hs : measurable_set s) :\n  integrable (indicator s f) \u03bc :=\n(integrable_indicator_iff hs).2 h\n\nlemma integrable.indicator (h : integrable f \u03bc) (hs : measurable_set s) :\n  integrable (indicator s f) \u03bc :=\nh.integrable_on.indicator hs\n\nlemma integrable_indicator_const_Lp {E} [normed_group E]\n  {p : \u211d\u22650\u221e} {s : set \u03b1} (hs : measurable_set s) (h\u03bcs : \u03bc s \u2260 \u221e) (c : E) :\n  integrable (indicator_const_Lp p hs h\u03bcs c) \u03bc :=\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\u03bcs,\nend\n\nlemma integrable_on_iff_integable_of_support_subset {f : \u03b1 \u2192 E} {s : set \u03b1}\n  (h1s : support f \u2286 s) (h2s : measurable_set s) :\n  integrable_on f s \u03bc \u2194 integrable f \u03bc :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, h.integrable_on\u27e9,\n  rwa [\u2190 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 : \u211d\u22650\u221e} {s : set \u03b1} (f : Lp E p \u03bc) (hp : 1 \u2264 p) (h\u03bcs : \u03bc s \u2260 \u221e) :\n  integrable_on f s \u03bc :=\nbegin\n  refine mem_\u2112p_one_iff_integrable.mp _,\n  have h\u03bc_restrict_univ : (\u03bc.restrict s) set.univ < \u221e,\n    by simpa only [set.univ_inter, measurable_set.univ, measure.restrict_apply, lt_top_iff_ne_top],\n  haveI h\u03bc_finite : is_finite_measure (\u03bc.restrict s) := \u27e8h\u03bc_restrict_univ\u27e9,\n  exact ((Lp.mem_\u2112p _).restrict s).mem_\u2112p_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 \u2208 l`. Equivalently, it is eventually integrable on `s` in `l.lift' powerset`. -/\ndef integrable_at_filter (f : \u03b1 \u2192 E) (l : filter \u03b1) (\u03bc : measure \u03b1 . volume_tac) :=\n\u2203 s \u2208 l, integrable_on f s \u03bc\n\nvariables {l l' : filter \u03b1}\n\nprotected lemma integrable_at_filter.eventually (h : integrable_at_filter f l \u03bc) :\n  \u2200\u1da0 s in l.lift' powerset, integrable_on f s \u03bc :=\nby { refine (eventually_lift'_powerset' $ \u03bb s t hst ht, _).2 h, exact ht.mono_set hst }\n\nlemma integrable_at_filter.filter_mono (hl : l \u2264 l') (hl' : integrable_at_filter f l' \u03bc) :\n  integrable_at_filter f l \u03bc :=\nlet \u27e8s, hs, hsf\u27e9 := hl' in \u27e8s, hl hs, hsf\u27e9\n\nlemma integrable_at_filter.inf_of_left (hl : integrable_at_filter f l \u03bc) :\n  integrable_at_filter f (l \u2293 l') \u03bc :=\nhl.filter_mono inf_le_left\n\nlemma integrable_at_filter.inf_of_right (hl : integrable_at_filter f l \u03bc) :\n  integrable_at_filter f (l' \u2293 l) \u03bc :=\nhl.filter_mono inf_le_right\n\n@[simp] lemma integrable_at_filter.inf_ae_iff {l : filter \u03b1} :\n  integrable_at_filter f (l \u2293 \u03bc.ae) \u03bc \u2194 integrable_at_filter f l \u03bc :=\nbegin\n  refine \u27e8_, \u03bb h, h.filter_mono inf_le_left\u27e9,\n  rintros \u27e8s, \u27e8t, ht, u, hu, rfl\u27e9, hf\u27e9,\n  refine \u27e8t, ht, _\u27e9,\n  refine hf.integrable.mono_measure (\u03bb v hv, _),\n  simp only [measure.restrict_apply hv],\n  refine measure_mono_ae (mem_of_superset hu $ \u03bb x hx, _),\n  exact \u03bb \u27e8hv, ht\u27e9, \u27e8hv, \u27e8ht, hx\u27e9\u27e9\nend\n\nalias integrable_at_filter.inf_ae_iff \u2194 measure_theory.integrable_at_filter.of_inf_ae _\n\n/-- If `\u03bc` 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 \u03b1} [is_measurably_generated l]\n  (hfm : strongly_measurable_at_filter f l \u03bc) (h\u03bc : \u03bc.finite_at_filter l)\n  (hf : l.is_bounded_under (\u2264) (norm \u2218 f)) :\n  integrable_at_filter f l \u03bc :=\nbegin\n  obtain \u27e8C, hC\u27e9 : \u2203 C, \u2200\u1da0 s in (l.lift' powerset), \u2200 x \u2208 s, \u2225f x\u2225 \u2264 C,\n    from hf.imp (\u03bb C hC, eventually_lift'_powerset.2 \u27e8_, hC, \u03bb t, id\u27e9),\n  rcases (hfm.eventually.and (h\u03bc.eventually.and hC)).exists_measurable_mem_of_lift'\n    with \u27e8s, hsl, hsm, hfm, h\u03bc, hC\u27e9,\n  refine \u27e8s, hsl, \u27e8hfm, has_finite_integral_restrict_of_bounded h\u03bc _\u27e9\u27e9,\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 \u03b1} [is_measurably_generated l] (hfm : strongly_measurable_at_filter f l \u03bc)\n  (h\u03bc : \u03bc.finite_at_filter l) {b} (hf : tendsto f (l \u2293 \u03bc.ae) (\ud835\udcdd b)) :\n  integrable_at_filter f l \u03bc :=\n(h\u03bc.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 \u2190\n  filter.tendsto.integrable_at_filter_ae\n\nlemma measure.finite_at_filter.integrable_at_filter_of_tendsto {l : filter \u03b1}\n  [is_measurably_generated l] (hfm : strongly_measurable_at_filter f l \u03bc)\n  (h\u03bc : \u03bc.finite_at_filter l) {b} (hf : tendsto f l (\ud835\udcdd b)) :\n  integrable_at_filter f l \u03bc :=\nh\u03bc.integrable_at_filter hfm hf.norm.is_bounded_under_le\n\nalias measure.finite_at_filter.integrable_at_filter_of_tendsto \u2190 filter.tendsto.integrable_at_filter\n\nlemma integrable_add_of_disjoint {f g : \u03b1 \u2192 E}\n  (h : disjoint (support f) (support g)) (hf : strongly_measurable f) (hg : strongly_measurable g) :\n  integrable (f + g) \u03bc \u2194 integrable f \u03bc \u2227 integrable g \u03bc :=\nbegin\n  refine \u27e8\u03bb hfg, \u27e8_, _\u27e9, \u03bb h, h.1.add h.2\u27e9,\n  { rw \u2190 indicator_add_eq_left h, exact hfg.indicator hf.measurable_set_support },\n  { rw \u2190 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`\u03bc.restrict s`. -/\nlemma continuous_on.ae_measurable [topological_space \u03b1] [opens_measurable_space \u03b1]\n  [measurable_space \u03b2] [topological_space \u03b2] [borel_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1} (hf : continuous_on f s) (hs : measurable_set s) :\n  ae_measurable f (\u03bc.restrict s) :=\nbegin\n  nontriviality \u03b1, inhabit \u03b1,\n  have : piecewise s f (\u03bb _, f default) =\u1d50[\u03bc.restrict s] f := piecewise_ae_eq_restrict hs,\n  refine \u27e8piecewise s f (\u03bb _, f default), _, this.symm\u27e9,\n  apply measurable_of_is_open,\n  assume t ht,\n  obtain \u27e8u, u_open, hu\u27e9 : \u2203 (u : set \u03b1), is_open u \u2227 f \u207b\u00b9' t \u2229 s = u \u2229 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 `\u03bc.restrict s`. -/\nlemma continuous_on.ae_strongly_measurable_of_is_separable\n  [topological_space \u03b1] [metrizable_space \u03b1] [opens_measurable_space \u03b1]\n  [topological_space \u03b2] [metrizable_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1} (hf : continuous_on f s) (hs : measurable_set s)\n  (h's : topological_space.is_separable s) :\n  ae_strongly_measurable f (\u03bc.restrict s) :=\nbegin\n  letI := metrizable_space_metric \u03b1,\n  borelize \u03b2,\n  rw ae_strongly_measurable_iff_ae_measurable_separable,\n  refine \u27e8hf.ae_measurable hs, f '' s, hf.is_separable_image h's, _\u27e9,\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 `\u03bc.restrict s` when either the source space or the target space is second-countable. -/\nlemma continuous_on.ae_strongly_measurable\n  [topological_space \u03b1] [topological_space \u03b2] [h : second_countable_topology_either \u03b1 \u03b2]\n  [opens_measurable_space \u03b1] [metrizable_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1} (hf : continuous_on f s) (hs : measurable_set s) :\n  ae_strongly_measurable f (\u03bc.restrict s) :=\nbegin\n  borelize \u03b2,\n  refine ae_strongly_measurable_iff_ae_measurable_separable.2 \u27e8hf.ae_measurable hs, f '' s, _,\n    mem_of_superset (self_mem_ae_restrict hs) (subset_preimage_image _ _)\u27e9,\n  casesI h.out,\n  { let f' : s \u2192 \u03b2 := 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 \u03b1] [metrizable_space \u03b1]\n  [opens_measurable_space \u03b1] {\u03bc : measure \u03b1} [is_locally_finite_measure \u03bc]\n  {a : \u03b1} {t : set \u03b1} {f : \u03b1 \u2192 E} (hft : continuous_on f t) (ht : measurable_set t)\n  (h't : topological_space.is_separable t) (ha : a \u2208 t) :\n  integrable_at_filter f (\ud835\udcdd[t] a) \u03bc :=\nbegin\n  haveI : (\ud835\udcdd[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _,\n  exact (hft a ha).integrable_at_filter \u27e8_, self_mem_nhds_within,\n    hft.ae_strongly_measurable_of_is_separable ht h't\u27e9 (\u03bc.finite_at_nhds_within _ _),\nend\n\nlemma continuous_on.integrable_at_nhds_within\n  [topological_space \u03b1] [second_countable_topology_either \u03b1 E]\n  [opens_measurable_space \u03b1] {\u03bc : measure \u03b1} [is_locally_finite_measure \u03bc]\n  {a : \u03b1} {t : set \u03b1} {f : \u03b1 \u2192 E} (hft : continuous_on f t) (ht : measurable_set t) (ha : a \u2208 t) :\n  integrable_at_filter f (\ud835\udcdd[t] a) \u03bc :=\nbegin\n  haveI : (\ud835\udcdd[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _,\n  exact (hft a ha).integrable_at_filter \u27e8_, self_mem_nhds_within, hft.ae_strongly_measurable ht\u27e9\n    (\u03bc.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`\ud835\udcdd x` for all `x \u2208 s` if either the source space or the target space is second-countable. -/\nlemma continuous_on.strongly_measurable_at_filter [topological_space \u03b1]\n  [opens_measurable_space \u03b1] [topological_space \u03b2] [metrizable_space \u03b2]\n  [second_countable_topology_either \u03b1 \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1}\n  (hs : is_open s) (hf : continuous_on f s) :\n  \u2200 x \u2208 s, strongly_measurable_at_filter f (\ud835\udcdd x) \u03bc :=\n\u03bb x hx, \u27e8s, is_open.mem_nhds hs hx, hf.ae_strongly_measurable hs.measurable_set\u27e9\n\nlemma continuous_at.strongly_measurable_at_filter\n  [topological_space \u03b1] [opens_measurable_space \u03b1] [second_countable_topology_either \u03b1 E]\n  {f : \u03b1 \u2192 E} {s : set \u03b1} {\u03bc : measure \u03b1} (hs : is_open s) (hf : \u2200 x \u2208 s, continuous_at f x) :\n  \u2200 x \u2208 s, strongly_measurable_at_filter f (\ud835\udcdd x) \u03bc :=\ncontinuous_on.strongly_measurable_at_filter hs $ continuous_at.continuous_on hf\n\nlemma continuous.strongly_measurable_at_filter [topological_space \u03b1] [opens_measurable_space \u03b1]\n  [topological_space \u03b2] [metrizable_space \u03b2] [second_countable_topology_either \u03b1 \u03b2]\n  {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (\u03bc : measure \u03b1) (l : filter \u03b1) :\n  strongly_measurable_at_filter f l \u03bc :=\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  `\ud835\udcdd[s] x` for all `x`. -/\nlemma continuous_on.strongly_measurable_at_filter_nhds_within {\u03b1 \u03b2 : Type*} [measurable_space \u03b1]\n  [topological_space \u03b1] [opens_measurable_space \u03b1] [topological_space \u03b2] [metrizable_space \u03b2]\n  [second_countable_topology_either \u03b1 \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1}\n  (hf : continuous_on f s) (hs : measurable_set s) (x : \u03b1) :\n  strongly_measurable_at_filter f (\ud835\udcdd[s] x) \u03bc :=\n\u27e8s, self_mem_nhds_within, hf.ae_strongly_measurable hs\u27e9\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 [\u2190 add_assoc] at h,\n  rw [add_right_cancel_iff] at h,\n  nth_rewrite 1 add_comm at h,\n  simp_rw [\u2190 add_assoc] at h,\n  nth_rewrite 2 add_comm at h,\n  simp_rw [\u2190 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 [\u2190 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 \u211d E] [inner_product_space \u211d F] {x : E}\n\nlemma eventually_is_conformal_map_of_eventually_conformal {f : E \u2192 F} \n  (hf : \u2200\u1da0 x' in \ud835\udcdd x, conformal_at f x') : \u2200\u1da0 x' in \ud835\udcdd x, is_conformal_map (fderiv \u211d f x') :=\nhf.mono (\u03bb y hy, conformal_at_iff_is_conformal_map_fderiv.mp hy)\n\nlemma A {f' : E \u2192L[\u211d] F} (h : is_conformal_map f') {u v : E} :\n  \u27eau, v\u27eb = 0 \u2194 \u27eaf' u, f' v\u27eb = 0 :=\nbegin\n  rcases (is_conformal_map_iff _).mp h with \u27e8c, p, q\u27e9,\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 \u2192 (E \u2192L[\u211d] F)} {u v : E} (huv : \u27eau, v\u27eb = 0) \n  (h : \u2200\u1da0 x' in \ud835\udcdd x, is_conformal_map $ f' x') :\n  (\u03bb x, \u27eaf' x u, f' x v\u27eb) =\u1da0[\ud835\udcdd x] \u03bb x, (0 : \u211d) :=\nbegin\n  apply (filter.eventually_of_forall $ \u03bb x, huv).mp,\n  simp only [congr_arg],\n  rcases filter.eventually_iff_exists_mem.mp h with \u27e8s, hs, hys\u27e9,\n  exact filter.eventually_iff_exists_mem.mpr \u27e8s, hs, \u03bb y hy p, (A $ hys y hy).mp p\u27e9\nend\n\nlemma B {f' : E \u2192L[\u211d] F} {K : submodule \u211d E} \n  (hf : function.surjective f') (h : is_conformal_map f') :\n  (K\u15ee).map (f' : E \u2192\u2097[\u211d] F) = (K.map f')\u15ee :=\nbegin\n  ext1 y'',\n  simp only [mem_map, mem_orthogonal],\n  split,\n  { rintros \u27e8u, hu, huy\u27e9,\n    intros v hv,\n    rcases hv with \u27e8z, hz, hzv\u27e9,\n    rw [\u2190 huy, \u2190 hzv, continuous_linear_map.coe_coe, \u2190 A h],\n    exact hu z hz },\n  { intros H,\n    rcases hf y'' with \u27e8y', hy'\u27e9,\n    refine \u27e8y', \u03bb u hu, _, hy'\u27e9,\n    rw [A h, hy'],\n    exact H (f' u) \u27e8u, hu, rfl\u27e9 }\nend\n\nlemma C {f' : E \u2192L[\u211d] F} (hf : function.surjective f') (h : is_conformal_map f') {u v : E} {w : F}\n  (H : \u2200 (t : E), t \u2208 (span \u211d ({u} \u222a {v} : set E))\u15ee \u2192 \u27eaw, f' t\u27eb = 0) :\n  w \u2208 (span \u211d ({f' u} \u222a {f' v} : set F)) :=\nbegin\n  have triv\u2081 : {f' u} \u222a {f' v} = f' '' ({u} \u222a {v}) :=\n    by simp only [image_union, image_singleton],\n  rw [triv\u2081, \u2190 continuous_linear_map.coe_coe, \u2190 map_span],\n  have triv\u2082 : is_complete (span \u211d ({u} \u222a {v} : set E) : set E),\n  { haveI : finite_dimensional \u211d (span \u211d ({u} \u222a {v} : set E)) :=\n      finite_dimensional.span_of_finite \u211d ((finite_singleton _).union $ finite_singleton _),\n    exact complete_of_finite_dimensional _ },\n  haveI : complete_space (span \u211d ({u} \u222a {v} : set E)) := triv\u2082.complete_space_coe,\n  rw [\u2190 orthogonal_orthogonal (span \u211d ({u} \u222a {v} : set E)), B hf h, mem_orthogonal],\n  intros y hy,\n  rw [mem_map] at hy,\n  rcases hy with \u27e8y', hy', Hy'\u27e9,\n  rw [real_inner_comm, \u2190 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 \u211d E] [normed_group F] [normed_space \u211d F] \n  {f : E \u2192 F} {f' : E \u2192 (E \u2192L[\u211d] F)} {y u : E} (hf : \u2200\u1da0 (x : E) in \ud835\udcdd y, has_fderiv_at f (f' x) x)\n  (hf' : differentiable_at \u211d f' y) : fderiv \u211d (\u03bb x, f' x u) y = fderiv \u211d f' y u :=\nbegin\n  have : (\u03bb x, f' x u) = \u03bb x, ((apply \u211d _ _) \u2218 f') x :=\n    by simp only [function.comp_app, apply_apply],\n  simp only [this, congr_arg],\n  rw fderiv.comp _ (apply \u211d F u).differentiable_at hf',\n  ext1 v,\n  simp only [(apply \u211d 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 \u211d E] [normed_group F] [normed_space \u211d F]  \n  {f' : E \u2192 E \u2192L[\u211d] F} {f'' : E \u2192 (E \u2192L[\u211d] E \u2192L[\u211d] F)} {y u v w : E} \n  (hf : \u2200\u1da0 (x : E) in \ud835\udcdd y, has_fderiv_at f' (f'' x) x) (hf' : differentiable_at \u211d f'' y) :\n  fderiv \u211d (\u03bb x, f'' x u v) y w = fderiv \u211d f'' y w u v :=\nbegin\n  have triv : (\u03bb x, f'' x u v) = \u03bb x, ((apply \u211d _ _) \u2218 \n    (\u03bb x', f'' x' u)) x :=\n    by simp only [function.comp_app, apply_apply],\n  simp only [triv],\n  rw [fderiv.comp _ (apply \u211d 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 \u211d F v).fderiv, apply_apply, function.comp_app],\n  exact (apply \u211d (E \u2192L[\u211d] F) u).differentiable_at.comp _ hf'\nend\n\nlemma is_open.is_const_of_fderiv_eq_zero {E F \ud835\udd5c : Type*} [normed_group E] [normed_space \u211d E] \n  [is_R_or_C \ud835\udd5c] [normed_space \ud835\udd5c E] [is_scalar_tower \u211d \ud835\udd5c E] [normed_group F] [normed_space \ud835\udd5c F] \n  {f : E \u2192 F} {s : set E} (hs : is_open s) (hs' : is_connected s) (hf : differentiable_on \ud835\udd5c f s) \n  (h : \u2200 x \u2208 s, fderiv \ud835\udd5c f x = 0) {x y : E} (hx : x \u2208 s) (hy : y \u2208 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\u2081 : S.nonempty := \u27e8\u27e8x, hx\u27e9, rfl\u27e9,\n  have triv\u2082 := continuous_on_iff_continuous_restrict.mp hf.continuous_on,\n  have minor\u2081 : is_closed S := is_closed_eq triv\u2082 continuous_const,\n  have minor\u2082 : 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 \u27e8\u03b5, h\u03b5, hball\u27e9,\n    have subminor\u2081 : \u2200 (x' : E), x' \u2208 metric.ball t.1 \u03b5 \u2192 \n      fderiv_within \ud835\udd5c f (metric.ball t.1 \u03b5) x' = 0 := \n    \u03bb 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\u2082 : coe\u207b\u00b9' (metric.ball t.1 \u03b5) \u2286 S :=\n    \u03bb a ha, begin\n      have := (convex_ball t.1 \u03b5).is_const_of_fderiv_within_eq_zero (hf.mono hball) \n        subminor\u2081 ha (metric.mem_ball_self h\u03b5),\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 \u27e8coe\u207b\u00b9' (metric.ball t.1 \u03b5), subminor\u2082, \n      metric.is_open_ball.preimage continuous_subtype_coe, _\u27e9,\n    simp only [subtype.val_eq_coe],\n    exact metric.mem_ball_self h\u03b5\n  end,\n  have key : f y = f x := begin\n    suffices new : (\u27e8y, hy\u27e9 : s) \u2208 S,\n    { exact new },\n    { rw eq_univ_of_nonempty_clopen triv\u2081 \u27e8minor\u2082, minor\u2081\u27e9,\n      exact mem_univ _ }\n  end,\n  exact key.symm\nend\n\nlemma is_open.eq_sub_add_of_fderiv_eq_fderiv {E F \ud835\udd5c : Type*} [normed_group E] [normed_space \u211d E] \n  [is_R_or_C \ud835\udd5c] [normed_space \ud835\udd5c E] [is_scalar_tower \u211d \ud835\udd5c E] [normed_group F] [normed_space \ud835\udd5c F] \n  {f g : E \u2192 F} {s : set E} (hs : is_open s) (hs' : is_connected s) \n  (hf : differentiable_on \ud835\udd5c f s) (hg : differentiable_on \ud835\udd5c g s) \n  (h : \u2200 x \u2208 s, fderiv \ud835\udd5c f x = fderiv \ud835\udd5c g x) {x\u2080 : E} (hx\u2080 : x\u2080 \u2208 s) :\n  \u2200 x \u2208 s, f x = g x - g x\u2080 + f x\u2080 :=\nbegin\n  refine \u03bb x hx, sub_eq_zero.mp _,\n  rw [sub_add_eq_add_sub, \u2190 add_sub],\n  have triv\u2081 : f x\u2080 - (g x\u2080 + (f x\u2080 - g x\u2080)) = 0 := by simp,\n  rw \u2190 triv\u2081,\n  have triv\u2082 : differentiable_on \ud835\udd5c (\u03bb y, f y - (g y + (f x\u2080 - g x\u2080))) s := hf.sub (hg.add_const _),\n  refine hs.is_const_of_fderiv_eq_zero hs' triv\u2082 (\u03bb y hy, _) hx hx\u2080,\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 \ud835\udd5c : Type*} [normed_group E] [normed_space \u211d E] \n  [is_R_or_C \ud835\udd5c] [normed_space \ud835\udd5c E] [is_scalar_tower \u211d \ud835\udd5c E] [normed_group F] [normed_space \ud835\udd5c F] \n  {f g : E \u2192 F} {s : set E} (hs : is_open s) (hs' : is_connected s) \n  (hf : differentiable_on \ud835\udd5c f s) (hg : differentiable_on \ud835\udd5c g s) \n  (h : \u2200 x \u2208 s, fderiv \ud835\udd5c f x = fderiv \ud835\udd5c g x) :\n  \u2203 y\u2080, \u2200 x \u2208 s, f x = g x - y\u2080 :=\nlet \u27e8x\u2080, hx\u2080\u27e9 := hs'.nonempty in \u27e8- (f x\u2080 - g x\u2080), \u03bb x hx, \n  by simpa [sub_neg, sub_add] using hs.eq_sub_add_of_fderiv_eq_fderiv hs' hf hg h hx\u2080 x hx\u27e9\n\n-- lemma is_open.exists_of_fderiv_eq_fderiv_of_has_fderiv_at \n--   {E F \ud835\udd5c : Type*} [normed_group E] [normed_space \u211d E] [is_R_or_C \ud835\udd5c] \n--   [normed_space \ud835\udd5c E] [is_scalar_tower \u211d \ud835\udd5c E] [normed_group F] [normed_space \ud835\udd5c F] \n--   {f g : E \u2192 F} {f'} {s : set E} (hs : is_open s) (hs' : is_connected s) \n--   (hf : differentiable_on \ud835\udd5c f s) (hg : differentiable_on \ud835\udd5c g s) \n--   (h : \u2200 x \u2208 s, fderiv \ud835\udd5c f x = fderiv \ud835\udd5c g x) :\n--   \u2203 x\u2080 \u2208 s, \u2200 x \u2208 s, f x = g x - g x\u2080 + f x\u2080 :=\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 \u211d E] [normed_space \u211d F] {f : E \u2192 F}\n\nlemma D21 {y : E} {n : \u2115} (hf : times_cont_diff_at \u211d n.succ f y) :\n  \u2200\u1da0 (x : E) in \ud835\udcdd y, has_fderiv_at f (fderiv \u211d f x) x :=\nbegin\n  rcases times_cont_diff_at_succ_iff_has_fderiv_at.mp hf with \u27e8f', \u27e8s, hs, hxs\u27e9, hf'\u27e9,\n  have minor\u2081 : \u2200 (x : E), x \u2208 s \u2192 differentiable_at \u211d f x := \u03bb x hx, \u27e8f' x, hxs x hx\u27e9,\n  have minor\u2082 : \u2200 (x : E), x \u2208 s \u2192 has_fderiv_at f (fderiv \u211d f x) x := \n    \u03bb x hx, (minor\u2081 x hx).has_fderiv_at,\n  rw filter.eventually_iff_exists_mem,\n  exact \u27e8s, hs, minor\u2082\u27e9\nend\n\nlemma D22 {y : E} {n : \u2115} (hf : times_cont_diff_at \u211d n.succ f y) :\n  times_cont_diff_at \u211d n (fderiv \u211d f) y :=\nbegin\n  have triv\u2081 : (n : with_top \u2115) \u2264 n + 1 := \n    by { apply with_top.coe_le_coe.mpr, exact nat.le_succ _ },\n  have triv\u2082 : (1 : with_top \u2115) \u2264 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 \u27e8f', \u27e8s, hs, hxs\u27e9, hf'\u27e9,\n  have minor\u2081 : \u2200 (x : E), x \u2208 s \u2192 differentiable_at \u211d f x := \u03bb x hx, \u27e8f' x, hxs x hx\u27e9,\n  have minor\u2082 : set.eq_on (fderiv \u211d f) f' s,\n  { intros x hxmem,\n    have := (hf.differentiable_at triv\u2082).has_fderiv_at,\n    exact (minor\u2081 x hxmem).has_fderiv_at.unique (hxs x hxmem) },\n  exact hf'.congr_of_eventually_eq (filter.eventually_eq_of_mem hs minor\u2082)\nend\n\nlemma D23 {y : E} {n : \u2115} (hn : 0 < n) (hf : times_cont_diff_at \u211d (n + 1) f y) :\n  differentiable_at \u211d (fderiv \u211d 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 : \u2115} (hn : 0 < n) (hf : times_cont_diff_at \u211d (n + 1) f y) (u : E) :\n  differentiable_at \u211d (\u03bb x, fderiv \u211d f x u) y :=\n(apply \u211d F u).differentiable_at.comp _ (D23 hn hf)\n\nlemma third_order_symmetric {x u v w : E} (hf' : \u2200\u1da0 x' in \ud835\udcdd x, times_cont_diff_at \u211d 3 f x') :\n  fderiv \u211d (fderiv \u211d $ fderiv \u211d f) x w u v = fderiv \u211d (fderiv \u211d $ fderiv \u211d f) x v u w :=\nbegin\n  have minor\u2081 : \u2200\u1da0 x' in \ud835\udcdd x, has_fderiv_at ((apply \u211d _ u) \u2218 (fderiv \u211d f)) \n    ((apply \u211d _ u).comp $ fderiv \u211d (fderiv \u211d f) x') x' :=\n    hf'.mono (\u03bb y hy, (apply \u211d F u).has_fderiv_at.comp _ (D23 zero_lt_two hy).has_fderiv_at),\n  have minor\u2082 : (\u03bb x', (apply \u211d _ u).comp $ fderiv \u211d (fderiv \u211d f) x') =\u1da0[\ud835\udcdd x] \u03bb x',\n    (((apply \u211d (E \u2192L[\u211d] F)) u) \u2218 fderiv \u211d (fderiv \u211d f)) x' :=\n  hf'.mono (\u03bb 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 \u211d (E \u2192L[\u211d] 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\u2081 (key.congr_of_eventually_eq minor\u2082) 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 \u211d E] [inner_product_space \u211d F] {f : E \u2192 F}\n\nlemma D' (u v w : E) {y : E} {n : \u2115} (hn : 0 < n) (hf : times_cont_diff_at \u211d (n + 1) f y)  :\n  fderiv \u211d (\u03bb x, \u27eafderiv \u211d f x u, fderiv \u211d f x v\u27eb) y w = \n  \u27eafderiv \u211d (fderiv \u211d f) y u w, fderiv \u211d f y v\u27eb + \n  \u27eafderiv \u211d f y u, fderiv \u211d (fderiv \u211d f) y v w\u27eb :=\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 : \u2200\u1da0 x' in \ud835\udcdd x, conformal_at f x') {f' : E \u2192 (E \u2192L[\u211d] F)} \n  (Hf : \u2200 (x' : E), is_conformal_map $ f' x') (Heven : fderiv \u211d f =\u1da0[\ud835\udcdd 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 \u211d 2 f x) {u v w : E} \n  (huv : \u27eau, v\u27eb = 0) (hwu : \u27eaw, u\u27eb = 0) (hwv : \u27eaw, v\u27eb = 0) :\n  \u27eafderiv \u211d (fderiv \u211d f) x u v, fderiv \u211d f x w\u27eb = 0 :=\nbegin\n  rw real_inner_comm at hwv,\n  have m\u2081 := D' u v w zero_lt_one hf',\n  have m\u2082 := D' v w u zero_lt_one hf',\n  have m\u2083 := D' w u v zero_lt_one hf',\n  rw [(A' huv conf_diff).fderiv_eq] at m\u2081,\n  rw [(A' hwv conf_diff).fderiv_eq] at m\u2082,\n  rw [(A' hwu conf_diff).fderiv_eq] at m\u2083,\n  rw [fderiv_const, pi.zero_apply, continuous_linear_map.zero_apply] at m\u2081 m\u2082 m\u2083,\n  rw add_comm at m\u2081 m\u2083,\n  nth_rewrite 0 real_inner_comm at m\u2083 m\u2081,\n  nth_rewrite 1 real_inner_comm at m\u2081,\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\u2082,\n  rw [second_derivative_symmetric_of_eventually (D21 hf') (D23 zero_lt_one hf').has_fderiv_at w v] \n      at m\u2083,\n  have triv\u2082 : \u2200 {a b c : \u211d}, a + b = 0 \u2192 b + c = 0 \u2192 a + c = 0 \u2192 a = 0 :=\n  \u03bb a b c hab hbc hac, begin\n    rw [\u2190 hab, \u2190 zero_add (a + b), \u2190 hac, \u2190 add_assoc, \u2190 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 \u2190 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\u2082 m\u2083.symm m\u2081.symm m\u2082.symm\nend\n\nlemma G'' (hf' : times_cont_diff_at \u211d 2 f x)\n  (h : function.surjective (fderiv \u211d f x)) {u v : E} (huv : \u27eau, v\u27eb = 0) :\n  fderiv \u211d (fderiv \u211d f) x u v \u2208 span \u211d ({fderiv \u211d f x u} \u222a {fderiv \u211d f x v} : set F) := \nbegin\n  refine C h conf_diff' (\u03bb t ht, _),\n  rw mem_orthogonal at ht,\n  have triv\u2081 : u \u2208 span \u211d ({u} \u222a {v} : set E) := subset_span (or.intro_left _ $ mem_singleton _),\n  have triv\u2082 : v \u2208 span \u211d ({u} \u222a {v} : set E) := subset_span (or.intro_right _ $ mem_singleton _),\n  have minor\u2081 := ht u triv\u2081,\n  have minor\u2082 := ht v triv\u2082,\n  rw real_inner_comm at minor\u2081 minor\u2082,\n  exact D hf hf' huv minor\u2081 minor\u2082\nend\n\nlemma G' (hf' : times_cont_diff_at \u211d 2 f x) \n  (h : function.surjective (fderiv \u211d f x)) {u v : E} (huv : \u27eau, v\u27eb = 0) : \n  fderiv \u211d (fderiv \u211d f) x u v = \n  (\u27eafderiv \u211d f x u, fderiv \u211d (fderiv \u211d f) x u v\u27eb / \u2191\u2225fderiv \u211d f x u\u2225 ^ 2) \u2022 fderiv \u211d f x u +\n  (\u27eafderiv \u211d f x v, fderiv \u211d (fderiv \u211d f) x u v\u27eb / \u2191\u2225fderiv \u211d f x v\u2225 ^ 2) \u2022 fderiv \u211d f x v :=\nbegin\n  rw [\u2190 orthogonal_projection_singleton, \u2190 orthogonal_projection_singleton],\n  have := G'' hf hf' h huv,\n  rw [span_union, mem_sup] at this,\n  rcases this with \u27e8p\u2081, hp\u2081, p\u2082, hp\u2082, hp\u2081p\u2082\u27e9,\n  have triv\u2081 : fderiv \u211d (fderiv \u211d f) x u v - p\u2082 = p\u2081 := \n    by rw [\u2190 hp\u2081p\u2082, \u2190 add_sub, sub_self, add_zero],\n  have triv\u2082 : fderiv \u211d (fderiv \u211d f) x u v - p\u2081 = p\u2082 := \n    by { rw [\u2190 hp\u2081p\u2082, add_comm], rw [\u2190 add_sub, sub_self, add_zero] },\n  rcases mem_span_singleton.mp hp\u2081 with \u27e8s\u2081, hs\u2081\u27e9,\n  rcases mem_span_singleton.mp hp\u2082 with \u27e8s\u2082, hs\u2082\u27e9,\n  have key\u2081 : \u2200 (w : F), w \u2208  span \u211d ({fderiv \u211d f x u} : set F) \u2192\n    \u27eafderiv \u211d (fderiv \u211d f) x u v - p\u2081, w\u27eb = 0 :=\n  \u03bb w hw, begin\n    rcases mem_span_singleton.mp hw with \u27e8s', hs'\u27e9,\n    rw [\u2190 hs', triv\u2082, \u2190 hs\u2082, 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\u2082 : \u2200 (w : F), w \u2208  span \u211d ({fderiv \u211d f x v} : set F) \u2192\n    \u27eafderiv \u211d (fderiv \u211d f) x u v - p\u2082, w\u27eb = 0 :=\n  \u03bb w hw, begin\n    rcases mem_span_singleton.mp hw with \u27e8s', hs'\u27e9,\n    rw [\u2190 hs', triv\u2081, \u2190 hs\u2081, 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\u2081 key\u2081, \n      eq_orthogonal_projection_of_mem_of_inner_eq_zero hp\u2082 key\u2082],\n  exact hp\u2081p\u2082.symm\nend\n\ninclude Hf Heven\n\nlemma G [nontrivial E] (hf' : times_cont_diff_at \u211d 2 f x) (u v : E)  : \n  \u27eafderiv \u211d (fderiv \u211d f) x u v, fderiv \u211d f x u\u27eb + \n  \u27eafderiv \u211d f x u, fderiv \u211d (fderiv \u211d f) x u v\u27eb =\n  2 * ((similarity_factor_sqrt x conf_diff') * \n  (fderiv \u211d (\u03bb y, similarity_factor_sqrt y $ Hf y) x v) * \u27eau, u\u27eb) :=\nbegin\n  rcases filter.eventually_eq_iff_exists_mem.mp Heven with \u27e8s, hs, heq\u27e9,\n  rw \u2190 D' u u v zero_lt_one hf',\n  have : (\u03bb (y : E), \u27eafderiv \u211d f y u, fderiv \u211d f y u\u27eb) =\u1da0[\ud835\udcdd x] \n    (\u03bb y, \u27eau, u\u27eb * id y) \u2218 (\u03bb y, similarity_factor y $ Hf y),\n  { rw filter.eventually_eq_iff_exists_mem,\n    refine \u27e8s, hs, _\u27e9,\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\u2081 := (D22 hf').congr_of_eventually_eq Heven.symm,\n  have minor\u2082 := (similarity_factor_times_cont_diff_at x Hf minor\u2081).differentiable_at \n    (le_of_eq rfl),\n  have minor\u2083 := (similarity_factor_sqrt_times_cont_diff_at x Hf minor\u2081).differentiable_at \n    (le_of_eq rfl),\n  rw [this.fderiv_eq, fderiv.comp _ (differentiable_at_id.const_mul _) minor\u2082, \n      fderiv_const_mul differentiable_at_id \u27eau, u\u27eb, fderiv_id],\n  rw \u2190 similarity_factor_sqrt_eq Hf,\n  simp only [pow_two], \n  rw [fderiv_mul minor\u2083 minor\u2083, 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 \u2260 0) (hf' : times_cont_diff_at \u211d 2 f x) : \n  \u27eafderiv \u211d (fderiv \u211d f) x u v, fderiv \u211d f x u\u27eb / \u27eau, u\u27eb = \n  similarity_factor_sqrt x conf_diff' * (fderiv \u211d (\u03bb 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, \u2190 two_mul, real_inner_comm] at key,\n  have triv : \u27eau, u\u27eb \u2260 0 := \u03bb 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 \u2260 0) (hf' : times_cont_diff_at \u211d 2 f x) : \n  \u27eafderiv \u211d f x u, fderiv \u211d (fderiv \u211d f) x u v\u27eb / \u2225fderiv \u211d f x u\u2225 ^ 2 =\n  (fderiv \u211d (\u03bb y, similarity_factor_sqrt y $ Hf y) x v) *\n  similarity_factor_sqrt_inv x conf_diff' :=\nbegin\n  rw [pow_two, \u2190 real_inner_self_eq_norm_sq],\n  have triv\u2081 : \u27eau, u\u27eb \u2260 0 := \u03bb W, hu (inner_self_eq_zero.mp W),\n  rw [\u2190 div_mul_div_cancel _ triv\u2081,\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\u2081, (similarity_factor_sqrt_prop x conf_diff').1],\n  ring\nend\n\nlemma GG2 {u v : E} (hv : v \u2260 0) (hf' : times_cont_diff_at \u211d 2 f x) :\n  \u27eafderiv \u211d f x v, fderiv \u211d (fderiv \u211d f) x u v\u27eb / \u2225fderiv \u211d f x v\u2225 ^ 2 =\n  (fderiv \u211d (\u03bb 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 \u2208 s) \n  (hs : is_open s) (hu : u \u2260 0) (hv : v \u2260 0) (huv : \u27eau, v\u27eb = 0)\n  (hf' : \u2200 y \u2208 s, times_cont_diff_at \u211d 2 f y) (h : \u2200 y \u2208 s, function.surjective (fderiv \u211d f y)) : \n  (\u03bb x', (similarity_factor_sqrt_inv x' $ Hf x') \u2022 (fderiv \u211d (fderiv \u211d f) x' u v) +\n  (fderiv \u211d (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x' v) \u2022 fderiv \u211d f x' u + \n  (fderiv \u211d (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x' u) \u2022 fderiv \u211d f x' v) =\u1da0[\ud835\udcdd x] \n  \u03bb x', (0 : F) :=\nbegin\n  haveI : nontrivial E := nontrivial_of_ne u 0 hu,\n  rcases eventually_iff_exists_mem.mp hf with \u27e8s\u2081, hs\u2081, hy\u2081\u27e9,\n  rcases eventually_eq_iff_exists_mem.mp Heven with \u27e8s\u2082, hs\u2082, hy\u2082\u27e9,\n  have triv\u2081 : (s\u2081 \u2229 s\u2082) \u2229 s \u2208 \ud835\udcdd x := inter_mem (inter_mem hs\u2081 hs\u2082) \n    (hs.mem_nhds hxs),\n  rcases mem_nhds_iff.mp triv\u2081 with \u27e8t, ht, hxt\u2081, hxt\u2082\u27e9,\n  refine eventually_eq_of_mem (hxt\u2081.mem_nhds hxt\u2082) (\u03bb y hy, _),\n  have minor\u2081 : \u2200\u1da0 x' in \ud835\udcdd y, conformal_at f x' :=\n    eventually_iff_exists_mem.mpr \u27e8t, hxt\u2081.mem_nhds hy, \u03bb y' hy', hy\u2081 y' (ht hy').1.1\u27e9,\n  have minor\u2082 : fderiv \u211d f =\u1da0[\ud835\udcdd y] f' :=\n    eventually_iff_exists_mem.mpr \u27e8t, hxt\u2081.mem_nhds hy, \u03bb y' hy', hy\u2082 (ht hy').1.2\u27e9,\n  simp only [congr_arg],\n  have key\u2081 := (hf' y (ht hy).2),\n  have key\u2082 := h y (ht hy).2,\n  have minor\u2083 := (D22 key\u2081).congr_of_eventually_eq minor\u2082.symm,\n  have key := similarity_factor_sqrt_inv_fderiv y Hf zero_lt_one minor\u2083,\n  rw [G' minor\u2081 key\u2081 key\u2082 huv, key],\n  simp only [is_R_or_C.coe_real_eq_id, _root_.id],\n  rw [GG1 minor\u2081 Hf minor\u2082 hu key\u2081, GG2 minor\u2081 Hf minor\u2082 hv key\u2081],\n  simp only [smul_add, smul_smul, pi.neg_apply, pi.mul_apply, congr_arg],\n  rw [\u2190 similarity_factor_sqrt_inv_eq', inv_pow', inv_inv', pow_two],\n  rw similarity_factor_sqrt_inv_eq_of_eq (Hf y) minor\u2082.symm.self_of_nhds,\n  nth_rewrite 1 add_comm,\n  simp only [\u2190 add_assoc, \u2190 add_smul, add_assoc, \u2190 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 \u2260 0) (hf' : \u2200\u1da0 x' in \ud835\udcdd x, times_cont_diff_at \u211d 3 f x') :\n  fderiv \u211d (\u03bb x, (fderiv \u211d (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x v) \u2022 \n  fderiv \u211d f x u) x w = fderiv \u211d (fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) x w v \u2022 \n  fderiv \u211d f x u + fderiv \u211d (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x v \u2022 \n  fderiv \u211d (fderiv \u211d f) x w u :=\nbegin\n  haveI : nontrivial E := nontrivial_of_ne u 0 hu,\n  have minor\u2080 := 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\u2081 := hf.mono (\u03bb x' hx', hx'.differentiable_at.has_fderiv_at),\n  have minor\u2082 := D23 zero_lt_two hf'.self_of_nhds,\n  have minor\u2083 : \u2200\u1da0 x' in \ud835\udcdd x, times_cont_diff_at \u211d 2 (fderiv \u211d f) x' := hf'.mono (\u03bb a ha, D22 ha),\n  have minor\u2084 : \u2200\u1da0 x' in \ud835\udcdd x, has_fderiv_at (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) \n    (fderiv \u211d (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x') x' :=\n    D21 (similarity_factor_sqrt_inv_times_cont_diff_at _ Hf $\n    minor\u2083.self_of_nhds.congr_of_eventually_eq Heven.symm),\n  have minor\u2085 := D23 zero_lt_one minor\u2080,\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\u2081 minor\u2082, DD1 minor\u2084 minor\u2085], \n  simp only [congr_arg],\n  rw [second_derivative_symmetric_of_eventually minor\u2081 minor\u2082.has_fderiv_at,\n      second_derivative_symmetric_of_eventually minor\u2084 minor\u2085.has_fderiv_at, add_comm],\n  exact DD2 zero_lt_one (similarity_factor_sqrt_inv_times_cont_diff_at _ \n    Hf $ minor\u2083.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 \u2260 0) (hf' : times_cont_diff_at \u211d 4 f x) :\n  fderiv \u211d (\u03bb x', (similarity_factor_sqrt_inv x' $ Hf x') \u2022 fderiv \u211d (fderiv \u211d f) x' u v) x w \n  = fderiv \u211d (\u03bb x', similarity_factor_sqrt_inv x' $ Hf x') x w \u2022 \n  fderiv \u211d (fderiv \u211d f) x u v + similarity_factor_sqrt_inv x conf_diff' \u2022\n  fderiv \u211d (fderiv \u211d $ fderiv \u211d 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 \u211d F v).differentiable_at.comp _ \n    ((apply \u211d (E \u2192L[\u211d] F) u).differentiable_at.comp _ $ D23 zero_lt_two $ D22 hf'),\nend\n\nlemma J2' {u : E} (v w : E) (hu : u \u2260 0) (hf' : \u2200\u1da0 x' in \ud835\udcdd x, times_cont_diff_at \u211d 4 f x') :\n  fderiv \u211d (\u03bb x', (similarity_factor_sqrt_inv x' $ Hf x') \u2022 fderiv \u211d (fderiv \u211d f) x' u v) x w \n  = fderiv \u211d (\u03bb x', similarity_factor_sqrt_inv x' $ Hf x') x w \u2022 \n  fderiv \u211d (fderiv \u211d f) x u v + similarity_factor_sqrt_inv x conf_diff' \u2022\n  fderiv \u211d (fderiv \u211d $ fderiv \u211d f) x v u w :=\nby rw [J2 hf Hf Heven v w hu hf'.self_of_nhds, \n       third_order_symmetric (hf'.mono $ \u03bb 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 \u2260 0) (huv : \u27eau, v\u27eb = 0) (huw : \u27eau, w\u27eb = 0) (hwv : \u27eaw, v\u27eb = 0)\n  (hf' : \u2200\u1da0 x' in \ud835\udcdd x, times_cont_diff_at \u211d 4 f x') \n  (h : \u2200\u1da0 x' in \ud835\udcdd x , function.surjective (fderiv \u211d f x')) :\n  fderiv \u211d (fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) x v u = 0 :=\nbegin\n  by_cases hv : v \u2260 0; by_cases hu : u \u2260 0,\n  { have triv\u2081 : (2 : with_top \u2115) \u2264 4,\n    { apply with_top.coe_le_coe.mpr,\n      norm_num },\n    have triv\u2082 : (3 : with_top \u2115) \u2264 4,\n    { apply with_top.coe_le_coe.mpr,\n      norm_num },\n    have triv\u2083 : (1 : with_top \u2115) \u2264 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\u2081 := 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\u2082 := hf.mono (\u03bb x' hx', hx'.differentiable_at.has_fderiv_at),\n    have minor\u2083 : \u2200\u1da0 x' in \ud835\udcdd x, times_cont_diff_at \u211d 2 (fderiv \u211d f) x' := \n      hf'.mono (\u03bb a ha, D22 $ ha.of_le triv\u2082),\n    have minor\u2084 : \u2200\u1da0 x' in \ud835\udcdd x, has_fderiv_at (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) \n      (fderiv \u211d (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x') x' :=\n      D21 (similarity_factor_sqrt_inv_times_cont_diff_at _ Hf $\n      minor\u2083.self_of_nhds.congr_of_eventually_eq Heven.symm),\n    rcases eventually_iff_exists_mem.mp hf' with \u27e8s\u2081, hs\u2081, hy\u2081\u27e9,\n    rcases eventually_iff_exists_mem.mp h with \u27e8s\u2082, hs\u2082, hy\u2082\u27e9,\n    rcases mem_nhds_iff.mp (inter_mem hs\u2081 hs\u2082) with \u27e8t, ht, Ht\u2081, Ht\u2082\u27e9,\n    have m\u2081 : fderiv \u211d _ _ w = (0 : F),\n    { rw (GGG_eventually_eq hf Hf Heven Ht\u2082 Ht\u2081 hu hv huv \n      (\u03bb y' hy', (hy\u2081 y' (ht hy').1).of_le triv\u2081) $ \u03bb y' hy', hy\u2082 y' (ht hy').2).fderiv_eq,\n      simp only [congr_arg, fderiv_const, pi.zero_apply, zero_apply] },\n    have m\u2082 : fderiv \u211d _ _ v = (0 : F),\n    { rw (GGG_eventually_eq hf Hf Heven Ht\u2082 Ht\u2081 hu hw huw\n      (\u03bb y' hy', (hy\u2081 y' (ht hy').1).of_le triv\u2081) $ \u03bb y' hy', hy\u2082 y' (ht hy').2).fderiv_eq,\n      simp only [congr_arg, fderiv_const, pi.zero_apply, zero_apply] },\n    rw \u2190 m\u2082 at m\u2081,\n    have diff\u2081 := (apply \u211d \u211d u).differentiable_at.comp _ (D23 zero_lt_two minor\u2081),\n    have diff\u2081' := (apply \u211d \u211d v).differentiable_at.comp _ (D23 zero_lt_two minor\u2081),\n    have diff\u2081'' := (apply \u211d \u211d w).differentiable_at.comp _ (D23 zero_lt_two minor\u2081),\n    have diff\u2082 := (apply \u211d F v).differentiable_at.comp _ \n      ((D22 hf'.self_of_nhds).differentiable_at triv\u2083),\n    have diff\u2082' := (apply \u211d F u).differentiable_at.comp _ \n      ((D22 hf'.self_of_nhds).differentiable_at triv\u2083),\n    have diff\u2082'' := (apply \u211d F w).differentiable_at.comp _ \n      ((D22 hf'.self_of_nhds).differentiable_at triv\u2083),\n    have diff\u2083 := (apply \u211d F v).differentiable_at.comp _ \n      ((apply \u211d (E \u2192L[\u211d] F) u).differentiable_at.comp _ $ D23 zero_lt_two $ D22 hf'.self_of_nhds),\n    have diff\u2083' := (apply \u211d F w).differentiable_at.comp _ \n      ((apply \u211d (E \u2192L[\u211d] F) u).differentiable_at.comp _ $ D23 zero_lt_two $ D22 hf'.self_of_nhds),\n    have diff_mk\u2081 := diff\u2081.smul diff\u2082,\n    have diff_mk\u2081' := diff\u2081.smul diff\u2082'',\n    have diff_mk\u2082 := diff\u2081'.smul diff\u2082',\n    have diff_mk\u2082' := diff\u2081''.smul diff\u2082',\n    have diff_mk\u2083 := (minor\u2081.differentiable_at triv\u2083).smul diff\u2083,\n    have diff_mk\u2083' := (minor\u2081.differentiable_at triv\u2083).smul diff\u2083',\n    simp only [congr_arg, function.comp_app, apply_apply] at \n      diff_mk\u2081 diff_mk\u2081' diff_mk\u2082 diff_mk\u2082' diff_mk\u2083 diff_mk\u2083',\n    have times\u2081 := hf'.mono (\u03bb a ha, ha.of_le triv\u2082), \n    rw [fderiv_add (diff_mk\u2083.add diff_mk\u2082) diff_mk\u2081, fderiv_add diff_mk\u2083 diff_mk\u2082,\n        fderiv_add (diff_mk\u2083'.add diff_mk\u2082') diff_mk\u2081', fderiv_add diff_mk\u2083' diff_mk\u2082'] at m\u2081,\n    simp only [add_apply] at m\u2081,\n    rw [J1 hf Hf Heven v w hu times\u2081, J1 hf Hf Heven u w hv times\u2081,\n        J1 hf Hf Heven w v hu times\u2081, J1 hf Hf Heven u v hw times\u2081] at m\u2081,\n    rw [J2' hf Hf Heven v w hu hf', J2 hf Hf Heven w v hu hf'.self_of_nhds] at m\u2081,\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\u2081,\n    rw second_derivative_symmetric_of_eventually minor\u2084 \n      (D23 zero_lt_two minor\u2081).has_fderiv_at at m\u2081,\n    clear minor\u2081 minor\u2082 minor\u2083 minor\u2084 m\u2082 diff\u2081 diff\u2081' diff\u2081'' diff\u2082 diff\u2082' diff\u2082'' diff\u2083 \n      diff\u2083' diff_mk\u2081 diff_mk\u2081' diff_mk\u2082 diff_mk\u2082' diff_mk\u2083 diff_mk\u2083' times\u2081,\n    -- if I don't make a `quick1` lemma the there will be a time-out failure.\n    have key := quick1 m\u2081,\n    clear m\u2081,\n    have triv\u2084 : \u27eafderiv \u211d f x w, fderiv \u211d f x w\u27eb \u2260 0 := \n      \u03bb W, (hw $ inner_self_eq_zero.mp $ (A conf_diff').mpr W),\n    rw [\u2190 mul_div_cancel \n        (fderiv \u211d (fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) x v u) triv\u2084],\n    simp only [congr_arg] at key,\n    rw [\u2190 real_inner_smul_right, \u2190 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 \u211d E] [inner_product_space \u211d F] {f : E \u2192 F}\n  {s : set E} (hs : is_open s) (hfs : \u2200 x \u2208 s, conformal_at f x) \n  (hf's : \u2200 x \u2208 s, times_cont_diff_at \u211d 4 f x) \n  (hsurj : \u2200 x \u2208 s , function.surjective (fderiv \u211d f x))\n  {f' : E \u2192 (E \u2192L[\u211d] F)} (Hf : \u2200 (x' : E), is_conformal_map $ f' x')\n  (Hevens : \u2200 x \u2208 s, fderiv \u211d f x = f' x)\n\ndef to_sym_bilin_form (x : E) : bilin_form \u211d E :=\n{ bilin := \u03bb u v, fderiv \u211d (fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) x v u,\n  bilin_add_left := \u03bb x y z, by simp only [map_add],\n  bilin_smul_left := \u03bb s x y, by simp only [map_smul, smul_eq_mul],\n  bilin_add_right := \u03bb x y z, by simp only [map_add, add_apply],\n  bilin_smul_right := \u03bb 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 \u2208 s) :\n  sym_bilin_form.is_sym (to_sym_bilin_form Hf x) :=\n\u03bb u v, begin\n  have Heven := eventually_eq_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx, \u03bb a ha, Hevens a ha\u27e9,\n  have minor\u2081 := 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\u2082 : \u2200\u1da0 x' in \ud835\udcdd x, has_fderiv_at (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) \n    (fderiv \u211d (\u03bb 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\u2082 (D23 zero_lt_two minor\u2081).has_fderiv_at]\nend\n\ninclude hfs hsurj\n\nlemma hB (hrank3 : \u2200 (u v : E), \u2203 w, w \u2260 0 \u2227 \u27eau, w\u27eb = 0 \u2227 \u27eaw, v\u27eb = 0) : \n  \u2200 x' (hx' : x' \u2208 s) u' v', \u27eau', v'\u27eb = 0 \u2192 to_sym_bilin_form Hf x' u' v' = 0 :=\n\u03bb x' hx' u' v' huv', begin\n  have hf := eventually_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx', \u03bb a ha, hfs a ha\u27e9,\n  have Heven := eventually_eq_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx', \u03bb a ha, Hevens a ha\u27e9,\n  have hf' := eventually_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx', \u03bb a ha, hf's a ha\u27e9,\n  have h := eventually_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx', \u03bb a ha, hsurj a ha\u27e9,\n  simp only [to_sym_bilin_form],\n  rcases hrank3 u' v' with \u27e8w', hw', huw', hwv'\u27e9,\n  exact tot1 hf Hf Heven hw' huv' huw' hwv' hf' h\nend\n\nvariables [complete_space E] [nontrivial E] \n  (hrank3 : \u2200 (u v : E), \u2203 w, w \u2260 0 \u2227 \u27eau, w\u27eb = 0 \u2227 \u27eaw, v\u27eb = 0)\n\nlemma diff_bilin {x : E} (hx : x \u2208 s) :\n  differentiable_at \u211d (\u03bb x', bilin_form_factor (hB hs hfs hf's hsurj Hf Hevens hrank3) \n  (\u03bb y hy, is_sym_to_sym_bilin_form hs hf's Hf Hevens hy) x') x :=\nbegin\n  rcases hrank3 0 0 with \u27e8w\u2080, hw\u2080, _\u27e9,\n  have hb := hB hs hfs hf's hsurj Hf Hevens hrank3,\n  have hb' := \u03bb y hy, is_sym_to_sym_bilin_form hs hf's Hf Hevens hy,\n  have triv\u2081 : \u27eaw\u2080, w\u2080\u27eb \u2260 0 := \u03bb W, hw\u2080 (inner_self_eq_zero.mp W),\n  have minor\u2081 : (\u03bb x', to_sym_bilin_form Hf x' w\u2080 w\u2080 / \u27eaw\u2080, w\u2080\u27eb) =\u1da0[\ud835\udcdd x] \n    \u03bb x', (bilin_form_factor hb hb' x'),\n  { refine eventually_eq_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx, \u03bb y hy, _\u27e9,\n    simp only [congr_arg, bilin_form_factor_prop hb hb' hy],\n    rw mul_div_cancel _ triv\u2081 },\n  simp only [to_sym_bilin_form, bilin_form.coe_fn_mk] at minor\u2081,\n  refine differentiable_at.congr_of_eventually_eq _ minor\u2081.symm,\n  simp only [div_eq_mul_inv, \u2190 smul_eq_mul],\n  apply differentiable_at.smul_const,\n  have Heven := eventually_eq_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx, \u03bb a ha, Hevens a ha\u27e9,\n  have triv\u2082 : (\u03bb x', fderiv \u211d (fderiv \u211d $ \u03bb y, \n    similarity_factor_sqrt_inv y $ Hf y) x' w\u2080 w\u2080) = (apply \u211d _ w\u2080) \u2218 \n    (\u03bb x', fderiv \u211d (fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) x' w\u2080),\n  { ext1,\n    simp only [apply_apply, function.comp_app] },\n  rw triv\u2082,\n  refine (apply \u211d \u211d w\u2080).differentiable_at.comp _ (DD2 zero_lt_one (D22 _) w\u2080),\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\u2081` := hB hs hfs hf's hsurj Hf Hevens hrank3\" in liouville_do_not_use\nlocalized \"notation `H\u2082` := \u03bb 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 \u2208 s) (u v : E) :\n  (\u03bb x', fderiv \u211d (fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) x' v u) =\u1da0[\ud835\udcdd x] \n  \u03bb x', (bilin_form_factor H\u2081 H\u2082 x') * \u27eau, v\u27eb :=\neventually_eq_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx, \u03bb y hy,\n  by simpa [to_sym_bilin_form, bilin_form.coe_fn_congr] using bilin_form_factor_prop H\u2081 H\u2082 hy u v\u27e9\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  \u2203 (c : \u211d), \u2200 x (hx : x \u2208 s), bilin_form_factor H\u2081 H\u2082 x = c :=\nbegin\n  rcases hs'.nonempty with \u27e8x\u2080, hx\u2080\u27e9,\n  refine \u27e8bilin_form_factor H\u2081 H\u2082 x\u2080, \u03bb x hx, _\u27e9,\n  have : \u2200 y \u2208 s, fderiv \u211d (\u03bb x', bilin_form_factor H\u2081 H\u2082 x') y = 0 :=\n  \u03bb y hy, begin\n    have triv\u2081 : \u2200\u1da0 x' in \ud835\udcdd y, \n      times_cont_diff_at \u211d 3 (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x' :=\n      eventually_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hy, \u03bb 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 \u27e8s, hs.mem_nhds hx', \u03bb a ha, Hevens a ha\u27e9).symm)\u27e9,\n    have minor\u2081 := fderiv_fderiv_eq_bilin_form_factor_mul hs hfs hf's hsurj Hf Hevens hrank3 hy,\n    have minor\u2082 := diff_bilin hs hfs hf's hsurj Hf Hevens hrank3 hy,\n    have minor\u2083 : \u2200 u v w, \n      fderiv \u211d (fderiv \u211d $ fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) y w u v =\n      fderiv \u211d (\u03bb x', bilin_form_factor H\u2081 H\u2082 x') y w * \u27eau, v\u27eb :=\n    \u03bb u v w, begin\n      have Heven := eventually_eq_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hy, \u03bb a ha, Hevens a ha\u27e9,\n      have subkey\u2081 := 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 [\u2190 DD1' subkey\u2081 (D23 zero_lt_one $ D22 triv\u2081.self_of_nhds), (minor\u2081 v u).fderiv_eq, \n          fderiv_mul_const minor\u2082, 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 \u27e8w, hw, hvw, _\u27e9,\n    have key_aux : fderiv \u211d (\u03bb x', bilin_form_factor H\u2081 H\u2082 x') y w \u2022 v -\n      fderiv \u211d (\u03bb x', bilin_form_factor H\u2081 H\u2082 x') y v \u2022 w = 0 :=\n    by rw [\u2190 inner_self_eq_zero, inner_sub_right, real_inner_smul_right, real_inner_smul_right,\n           \u2190 minor\u2083, \u2190 minor\u2083, third_order_symmetric triv\u2081, sub_self],\n    have key := eq_of_sub_eq_zero key_aux,\n    have minor\u2085 : (fderiv \u211d (\u03bb x', bilin_form_factor H\u2081 H\u2082 x') y v) *\n      (fderiv \u211d (\u03bb x', bilin_form_factor H\u2081 H\u2082 x') y v) * \u27eaw, w\u27eb = 0 :=\n    by rw [mul_assoc, \u2190 real_inner_smul_left, \u2190 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      (\u03bb W, hw $ inner_self_eq_zero.mp W) minor\u2085)\n  end,\n  exact hs.is_const_of_fderiv_eq_zero hs' (\u03bb x' hx', \n    (diff_bilin hs hfs hf's hsurj Hf Hevens hrank3 hx').differentiable_within_at) this hx hx\u2080\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 \u211d E] [inner_product_space \u211d F] {f : E \u2192 F}\n  {s : set E} (hs : is_open s) (hs' : is_connected s) (hfs : \u2200 x \u2208 s, conformal_at f x) \n  (hf's : \u2200 x \u2208 s, times_cont_diff_at \u211d 4 f x) \n  (hsurj : \u2200 x \u2208 s , function.surjective (fderiv \u211d f x))\n  {f' : E \u2192 (E \u2192L[\u211d] F)} (Hf : \u2200 (x' : E), is_conformal_map $ f' x')\n  (Hevens : \u2200 x \u2208 s, fderiv \u211d f x = f' x)\n\nvariables [complete_space E] [nontrivial E] \n  (hrank3 : \u2200 (u v : E), \u2203 w, w \u2260 0 \u2227 \u27eau, w\u27eb = 0 \u2227 \u27eaw, v\u27eb = 0)\n\nlocalized \"notation `H\u2081` := hB hs hfs hf's hsurj Hf Hevens hrank3\" in liouville_do_not_use\nlocalized \"notation `H\u2082` := \u03bb 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 : \u2200 x \u2208 s, bilin_form_factor H\u2081 H\u2082 x \u2260 0) :\n  \u2203 (\u03b1 \u03b2 : \u211d) (h\u03b1 : \u03b1 \u2260 0) (x\u2080 : E), \n  \u2200 x \u2208 s, similarity_factor_sqrt_inv x (Hf x) = \u03b1 * \u2225x - x\u2080\u2225 ^ 2 + \u03b2 :=\nbegin\n  rcases is_const_bilin_form_factor hs hfs hf's hsurj Hf Hevens hrank3 hs' with \u27e8c, hc\u27e9,\n  have key\u2081 : \u2200 x \u2208 s, \n    fderiv \u211d (fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) x =\n    fderiv \u211d (\u03bb y, c \u2022 to_dual y) x :=\n  \u03bb x hx, begin\n    ext v u,\n    have triv\u2081 := (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\u2081,\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\u2081, smul_eq_mul, real_inner_comm, hc x hx]\n  end,\n  have triv\u2081 := \u03bb y (hy : y \u2208 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    \u27e8s, hs.mem_nhds hy, \u03bb a ha, Hevens a ha\u27e9).symm).differentiable_within_at,\n  rcases hs.exists_of_fderiv_eq_fderiv hs' triv\u2081 \n    (\u03bb y hy, (continuous_linear_equiv.differentiable_within_at _).const_smul _) key\u2081 with \u27e8map, h\u27e9,\n  simp only [congr_arg] at h,\n  have Hc : c \u2260 0 :=\n  \u03bb W, begin\n    rcases hs'.nonempty with \u27e8x', hx'\u27e9,\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\u2080 := to_dual.symm (c\u207b\u00b9 \u2022 map),\n  have triv\u2083 : c \u2022 to_dual x\u2080 = map := \n    by simp only [x\u2080, to_dual.apply_symm_apply, smul_inv_smul' Hc],\n  simp only [\u2190 triv\u2083, \u2190 smul_sub, \u2190 to_dual.map_sub] at h,\n  have key\u2082 : \u2200 x \u2208 s,\n    fderiv \u211d (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x = \n    fderiv \u211d (\u03bb y, c / 2 * \u27eaid y - x\u2080, id y\u27eb - (c / 2) * to_dual x\u2080 (y - x\u2080)) x :=\n  \u03bb x hx, begin\n    ext1 v,\n    rw [h x hx, fderiv_sub (((differentiable_at_id.sub_const x\u2080).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\u2080).inner differentiable_at_id)],\n    rw [smul_apply, sub_apply, smul_apply, \n        fderiv_inner_apply (differentiable_at_id.sub_const x\u2080) 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\u2084 := \u03bb 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    \u27e8s, hs.mem_nhds hy, \u03bb a ha, Hevens a ha\u27e9).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\u2084 _ key\u2082 with \u27e8\u03b2, H\u27e9,\n  simp only [congr_arg, _root_.id] at H,\n  refine \u27e8c / 2, -\u03b2, div_ne_zero Hc two_ne_zero, x\u2080, \u03bb x hx, _\u27e9,\n  convert H x hx,\n  simp only [smul_eq_mul, to_dual_apply],\n  rw [real_inner_comm, \u2190 mul_sub, \u2190 inner_sub_left, real_inner_self_eq_norm_sq, pow_two],\n  intros y hy,\n  refine ((((differentiable_at_id.sub_const x\u2080).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 : \u2203 x \u2208 s, bilin_form_factor H\u2081 H\u2082 x = 0) :\n  \u2203 (\u03b2 : \u211d) (x\u2080 : E), \n  \u2200 x \u2208 s, similarity_factor_sqrt_inv x (Hf x) = \u27eax, x\u2080\u27eb + \u03b2 :=\nbegin\n  rcases is_const_bilin_form_factor hs hfs hf's hsurj Hf Hevens hrank3 hs' with \u27e8c, hc\u27e9,\n  have key\u2081 : \u2200 x \u2208 s, \n    fderiv \u211d (fderiv \u211d $ \u03bb y, similarity_factor_sqrt_inv y $ Hf y) x =\n    fderiv \u211d (\u03bb y, c \u2022 to_dual y) x :=\n  \u03bb x hx, begin\n    ext v u,\n    have triv\u2081 := (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\u2081,\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\u2081, smul_eq_mul, real_inner_comm, hc x hx]\n  end,\n  have triv\u2081 := \u03bb y (hy : y \u2208 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    \u27e8s, hs.mem_nhds hy, \u03bb a ha, Hevens a ha\u27e9).symm).differentiable_within_at,\n  rcases hs.exists_of_fderiv_eq_fderiv hs' triv\u2081 \n    (\u03bb y hy, (continuous_linear_equiv.differentiable_within_at _).const_smul _) key\u2081 with \u27e8map, h\u27e9,\n  simp only [congr_arg] at h,\n  have Hc : c = 0 :=\n  begin\n    rcases hzero with \u27e8x'', hx'', Hx''\u27e9,\n    rwa hc x'' hx'' at Hx'',\n  end,\n  simp only [Hc, zero_smul, zero_sub] at h,\n  have key\u2082 : \u2200 x \u2208 s,\n    fderiv \u211d (\u03bb y, similarity_factor_sqrt_inv y $ Hf y) x =\n    fderiv \u211d (-map : E \u2192L[\u211d] \u211d) x :=\n  \u03bb x hx, by ext1 v; rw [h x hx, (-map).fderiv],\n  have triv\u2084 := \u03bb 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    \u27e8s, hs.mem_nhds hy, \u03bb a ha, Hevens a ha\u27e9).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\u2084 (continuous_linear_map.differentiable_on _) \n    key\u2082 with \u27e8\u03b2, H\u27e9,\n  refine \u27e8-\u03b2, to_dual.symm (-map), \u03bb x hx, _\u27e9,\n  rw [real_inner_comm, \u2190 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 \u211d E] [complete_space E] [nontrivial E] \n  -- {f' : E \u2192 (E \u2192L[\u211d] F)} (Hf : \u2200 (x' : E), is_conformal_map $ f' x')\n  -- (Hevens : \u2200 x \u2208 s, fderiv \u211d f x = f' x)\n\n-- def def_helper (f : E \u2192 E) (s : set E) (x : E) :=\n-- if x \u2208 s then fderiv \u211d f x else id \u211d E\n\n-- lemma def_helper_eq (f : local_homeomorph E E) (s : set E) {x : E} (hx : x \u2208 s) :\n--   fderiv \u211d 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 \u2286 f.source) (hfs : \u2200 x \u2208 s, conformal_at f x) \n  (hf's : \u2200 x \u2208 s, times_cont_diff_at \u211d 4 f x) \n  (hsurj : \u2200 x \u2208 s , function.surjective (fderiv \u211d 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 \u2208 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 \u2208 s) : E \u2243L[\u211d] E :=\ncontinuous_linear_equiv.of_bijective (fderiv \u211d 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 \u2208 s) :\n  (bijective_differentials hfs hsurj hx : E \u2192L[\u211d] E) = fderiv \u211d f x :=\nby simp only [bijective_differentials, continuous_linear_equiv.coe_of_bijective]\n\nlemma bijective_differentials2 {x : E} (hx : x \u2208 s) :\n  has_fderiv_at f (bijective_differentials hfs hsurj hx : E \u2192L[\u211d] 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\u207b\u00b9 then so is Hom(\u039b, M)\n\nHere \u039b is a polyhedral lattice, and the T\u207b\u00b9 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 : \u2124) \u2208 filtration \u2124 1 :=\nby simp only [nnnorm_one, mem_filtration_iff]\n\nsection\n\nvariables {\u039b : Type*} [polyhedral_lattice \u039b]\nvariables {M : Type*} [pseudo_normed_group M]\n\nlemma generates_norm.add_monoid_hom_mem_filtration_iff {\u03b9 : Type} [fintype \u03b9]\n  {l : \u03b9 \u2192 \u039b} (hl : generates_norm l) (x : \u039b \u2192+ M) (c : \u211d\u22650) :\n  x \u2208 filtration (\u039b \u2192+ M) c \u2194 \u2200 i, x (l i) \u2208 filtration M (c * \u2225l i\u2225\u208a) :=\nbegin\n  refine \u27e8\u03bb H i, H (le_refl \u2225l i\u2225\u208a), _\u27e9,\n  intros H c' l' hl',\n  obtain \u27e8c\u1d62, h1, h2\u27e9 := hl.generates_nnnorm l',\n  rw [h1, x.map_sum],\n  refine filtration_mono _ (sum_mem_filtration _ (\u03bb i, c * c\u1d62 i * \u2225l i\u2225\u208a) _ _),\n  { calc \u2211 i, c * c\u1d62 i * \u2225l i\u2225\u208a\n        = c * \u2211 i, c\u1d62 i * \u2225l i\u2225\u208a : by simp only [mul_assoc, \u2190 finset.mul_sum]\n    ... = c * \u2225l'\u2225\u208a : by rw h2\n    ... \u2264 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\u1d62 i) _ _ (H i),\nend\n\nend\n\nnamespace polyhedral_lattice\n\nvariables (\u039b : Type*) (r' : \u211d\u22650) (M : Type*) [polyhedral_lattice \u039b]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M]\n\ninclude r'\n\nnamespace add_monoid_hom\n\nvariables {\u039b r' M} (c : \u211d\u22650)\n\ndef incl (c : \u211d\u22650) : filtration (\u039b \u2192+ M) c \u2192 \u03a0 l : \u039b, filtration M (c * \u2225l\u2225\u208a) :=\n\u03bb f l, \u27e8f l, f.2 $ mem_filtration_nnnorm _\u27e9\n\n@[simp] lemma coe_incl_apply (f : filtration (\u039b \u2192+ M) c) (l : \u039b) :\n  (incl c f l : M) = f l :=\nrfl\n\nvariables (\u039b r' M)\n\nlemma incl_injective : function.injective (@incl \u039b 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 (\u039b \u2192+ M) c) :=\ntopological_space.induced (incl c) infer_instance\n\nlemma incl_embedding : embedding (@incl \u039b r' M _ _ c) :=\n{ induced := rfl,\n  inj := incl_injective \u039b r' M c }\n\nlemma incl_inducing : inducing (@incl \u039b r' M _ _ c) := \u27e8rfl\u27e9\n\nlemma incl_continuous : continuous (@incl \u039b r' M _ _ c) :=\n(incl_inducing _ _ _ _).continuous\n\ninstance : t2_space (filtration (\u039b \u2192+ M) c) :=\n(incl_embedding \u039b r' M c).t2_space\n\ninstance : totally_disconnected_space (filtration (\u039b \u2192+ M) c) :=\n{ is_totally_disconnected_univ := (incl_embedding \u039b r' M c).is_totally_disconnected $\n    is_totally_disconnected_of_totally_disconnected_space _ }\n\nlemma incl_range_eq :\n  (set.range (@incl \u039b r' M _ _ c)) =\n    \u22c2 l\u2081 l\u2082, {f | (cast_le (f (l\u2081 + l\u2082)) : filtration M (c * (\u2225l\u2081\u2225\u208a + \u2225l\u2082\u2225\u208a))) =\n    cast_le (add' (f l\u2081, f l\u2082))} :=\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 \u27e8\u27e8f, hf\u27e9, rfl\u27e9 l\u2081 l\u2082,\n    exact f.map_add _ _ },\n  { intro h,\n    refine \u27e8\u27e8add_monoid_hom.mk' (\u03bb l, f l) h, _\u27e9, _\u27e9,\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 \u039b r' M _ _ c))) :=\nbegin\n  rw incl_range_eq,\n  apply is_closed_Inter,\n  intro l\u2081,\n  apply is_closed_Inter,\n  intro l\u2082,\n  apply is_closed_eq,\n  { exact (continuous_cast_le _ _).comp (continuous_apply (l\u2081 + l\u2082)) },\n  { exact (continuous_cast_le _ _).comp ((continuous_add' _ _).comp\n          ((continuous_apply l\u2081).prod_mk (continuous_apply l\u2082))) },\nend\n\ninstance : compact_space (filtration (\u039b \u2192+ M) c) :=\n{ compact_univ :=\n  begin\n    rw \u2190 (incl_inducing \u039b 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  (\u03d5 : X \u2192 (filtration (\u039b \u2192+ M) c)) :\n  continuous \u03d5 \u2194 \u2200 l : \u039b, continuous (\u03bb x, incl c (\u03d5 x) l) :=\nbegin\n  rw (incl_inducing \u039b 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 (\u039b \u2192+ M) :=\n{ continuous_add' :=\n  begin\n    intros c\u2081 c\u2082,\n    rw continuous_iff,\n    intro l,\n    have step1 :=\n      ((continuous_apply l).comp (incl_continuous \u039b r' M c\u2081)).prod_map\n      ((continuous_apply l).comp (incl_continuous \u039b r' M c\u2082)),\n    have step2 := (continuous_add' (c\u2081 * \u2225l\u2225\u208a) (c\u2082 * \u2225l\u2225\u208a)),\n    have := step2.comp step1,\n    refine (@continuous_cast_le _ _ _ _ (id _)).comp this,\n    rw add_mul, exact \u27e8le_rfl\u27e9\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 \u039b r' M c)),\n  end,\n  continuous_cast_le :=\n  begin\n    introsI c\u2081 c\u2082 h,\n    rw continuous_iff,\n    intro l,\n    exact (continuous_cast_le _ _).comp ((continuous_apply l).comp (incl_continuous \u039b r' M c\u2081))\n  end,\n  .. add_monoid_hom.pseudo_normed_group }\n\nend add_monoid_hom\n\nvariables {\u039b r' M}\n\nopen profinitely_filtered_pseudo_normed_group_with_Tinv\n\ndef Tinv' : (\u039b \u2192+ M) \u2192+ (\u039b \u2192+ M) :=\nadd_monoid_hom.comp_hom\n  (@Tinv r' M _).to_add_monoid_hom\n\n@[simp] lemma Tinv'_apply (f : \u039b \u2192+ M) (l : \u039b) :\n  Tinv' f l = Tinv (f l) := rfl\n\nlemma Tinv'_mem_filtration (c : \u211d\u22650) (f : \u039b \u2192+ M) (hf : f \u2208 filtration (\u039b \u2192+ M) c) :\n  Tinv' f \u2208 filtration (\u039b \u2192+ M) (r'\u207b\u00b9 * 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 (\u039b 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 (\u039b \u2192+ M) (\u039b \u2192+ M) :=\ncomphaus_filtered_pseudo_normed_group_hom.mk' Tinv'\nbegin\n  refine \u27e8r'\u207b\u00b9, \u03bb c, \u27e8Tinv'_mem_filtration c, _\u27e9\u27e9,\n  rw add_monoid_hom.continuous_iff,\n  intro l,\n  haveI : \u2200 a, fact (a \u2264 r' * (r'\u207b\u00b9 * a)) :=\n    \u03bb a, \u27e8by simp [mul_inv_cancel_left\u2080 (ne_of_gt (fact.out _ : 0 < r'))]\u27e9,\n  refine (@continuous_cast_le _ _ _ _ (id _)).comp\n    ((@Tinv\u2080_continuous r' M _ (c * \u2225l\u2225\u208a) (r'\u207b\u00b9 * (c * \u2225l\u2225\u208a)) _).comp\n    ((continuous_apply l).comp (add_monoid_hom.incl_continuous \u039b r' M c))),\n  rw mul_assoc, exact \u27e8le_rfl\u27e9\nend\n\ninstance : profinitely_filtered_pseudo_normed_group_with_Tinv r' (\u039b \u2192+ M) :=\n{ Tinv := Tinv \u039b r' M,\n  Tinv_mem_filtration := Tinv'_mem_filtration,\n  .. add_monoid_hom.profinitely_filtered_pseudo_normed_group \u039b r' M }\n\n@[simp] lemma Tinv_apply (x : \u039b \u2192+ M) (l : \u039b) :\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 : \u03b1 \u2192 \u03b2 \u2192 Prop`), we can bound the number of edges\nbetween `s : Finset \u03b1` and `t : Finset \u03b2` by the minimum/maximum of edges over all `a \u2208 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 {\u03b1 \u03b2 : Type _}\n\n/-! ### Bipartite graph -/\n\n\nnamespace Finset\n\nsection Bipartite\n\nvariable (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (s : Finset \u03b1) (t : Finset \u03b2) (a a' : \u03b1) (b b' : \u03b2)\n  [DecidablePred (r a)] [\u2200 a, Decidable (r a b)] {m n : \u2115}\n\n/-- Elements of `s` which are \"below\" `b` according to relation `r`. -/\ndef bipartiteBelow : Finset \u03b1 := s.filter fun a \u21a6 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 \u03b2 := 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 \u03b1) = { a \u2208 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 \u03b2) = { b \u2208 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 : \u03b1} : a \u2208 s.bipartiteBelow r b \u2194 a \u2208 s \u2227 r a b := mem_filter\n#align finset.mem_bipartite_below Finset.mem_bipartiteBelow\n\n@[simp]\ntheorem mem_bipartiteAbove {b : \u03b2} : b \u2208 t.bipartiteAbove r a \u2194 b \u2208 t \u2227 r a b := mem_filter\n#align finset.mem_bipartite_above Finset.mem_bipartiteAbove\n\ntheorem sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow [\u2200 a b, Decidable (r a b)] :\n    (\u2211 a in s, (t.bipartiteAbove r a).card) = \u2211 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 [\u2200 a b, Decidable (r a b)]\n    (hm : \u2200 a \u2208 s, m \u2264 (t.bipartiteAbove r a).card)\n    (hn : \u2200 b \u2208 t, (s.bipartiteBelow r b).card \u2264 n) : s.card * m \u2264 t.card * n :=\n  calc\n    _ \u2264 \u2211 a in s, (t.bipartiteAbove r a).card := s.card_nsmul_le_sum _ _ hm\n    _ = \u2211 b in t, (s.bipartiteBelow r b).card :=\n      sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow _\n    _ \u2264 _ := 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' [\u2200 a b, Decidable (r a b)]\n    (hn : \u2200 b \u2208 t, n \u2264 (s.bipartiteBelow r b).card)\n    (hm : \u2200 a \u2208 s, (t.bipartiteAbove r a).card \u2264 m) : t.card * n \u2264 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 [\u2200 a b, Decidable (r a b)]\n    (hm : \u2200 a \u2208 s, (t.bipartiteAbove r a).card = m)\n    (hn : \u2200 b \u2208 t, (s.bipartiteBelow r b).card = n) : s.card * m = t.card * n :=\n  (card_mul_le_card_mul _ (fun a ha \u21a6 (hm a ha).ge) fun b hb \u21a6 (hn b hb).le).antisymm <|\n    card_mul_le_card_mul' _ (fun a ha \u21a6 (hn a ha).ge) fun b hb \u21a6 (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 : \u2200 b \u2208 t, \u2203 a, a \u2208 s \u2227 r a b)\n    (hs : \u2200 a \u2208 s, ({ b \u2208 t | r a b } : Set \u03b2).Subsingleton) : t.card \u2264 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 \u03b1] [Fintype \u03b2] {r : \u03b1 \u2192 \u03b2 \u2192 Prop}\n\ntheorem card_le_card_of_leftTotal_unique (h\u2081 : LeftTotal r) (h\u2082 : LeftUnique r) :\n    Fintype.card \u03b1 \u2264 Fintype.card \u03b2 :=\n  card_le_card_of_forall_subsingleton r (by simpa using h\u2081) fun b _ a\u2081 ha\u2081 a\u2082 ha\u2082 \u21a6 h\u2082 ha\u2081.2 ha\u2082.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\u2081 : RightTotal r) (h\u2082 : RightUnique r) :\n    Fintype.card \u03b2 \u2264 Fintype.card \u03b1 :=\n  card_le_card_of_forall_subsingleton' r (by simpa using h\u2081) fun b _ a\u2081 ha\u2081 a\u2082 ha\u2082 \u21a6 h\u2082 ha\u2081.2 ha\u2082.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 `\u03b1`, in this file we define\n\n* `set.proj_Icc (a b : \u03b1) (h : a \u2264 b)` to be the map `\u03b1 \u2192 [a, b]` sending `(-\u221e, a]` to `a`, `[b, \u221e)`\n  to `b`, and each point `x \u2208 [a, b]` to itself;\n* `set.Icc_extend {a b : \u03b1} (h : a \u2264 b) (f : Icc a b \u2192 \u03b2)` to be the extension of `f` to `\u03b1` defined\n  as `f \u2218 proj_Icc a b h`.\n\nWe also prove some trivial properties of these maps.\n-/\n\nnamespace set\n\n\n/-- Projection of `\u03b1` to the closed interval `[a, b]`. -/\ndef proj_Icc {\u03b1 : Type u_1} [linear_order \u03b1] (a : \u03b1) (b : \u03b1) (h : a \u2264 b) (x : \u03b1) : \u21a5(Icc a b) :=\n  { val := max a (min b x), property := sorry }\n\ntheorem proj_Icc_of_le_left {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1} (hx : x \u2264 a) : proj_Icc a b h x = { val := a, property := iff.mpr left_mem_Icc h } := sorry\n\n@[simp] theorem proj_Icc_left {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 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 {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1} (hx : b \u2264 x) : proj_Icc a b h x = { val := b, property := iff.mpr right_mem_Icc h } := sorry\n\n@[simp] theorem proj_Icc_right {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 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 {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1} (hx : x \u2208 Icc a b) : proj_Icc a b h x = { val := x, property := hx } := sorry\n\n@[simp] theorem proj_Icc_coe {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) (x : \u21a5(Icc a b)) : proj_Icc a b h \u2191x = x :=\n  subtype.cases_on x fun (x_val : \u03b1) (x_property : x_val \u2208 Icc a b) => proj_Icc_of_mem h x_property\n\ntheorem proj_Icc_surj_on {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) : surj_on (proj_Icc a b h) (Icc a b) univ :=\n  fun (x : \u21a5(Icc a b)) (_x : x \u2208 univ) => Exists.intro \u2191x { left := subtype.property x, right := proj_Icc_coe h x }\n\ntheorem proj_Icc_surjective {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) : function.surjective (proj_Icc a b h) :=\n  fun (x : \u21a5(Icc a b)) => Exists.intro (\u2191x) (proj_Icc_coe h x)\n\n@[simp] theorem range_proj_Icc {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) : range (proj_Icc a b h) = univ :=\n  function.surjective.range_eq (proj_Icc_surjective h)\n\ntheorem monotone_proj_Icc {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) : monotone (proj_Icc a b h) :=\n  fun (x y : \u03b1) (hxy : x \u2264 y) => max_le_max le_rfl (min_le_min le_rfl hxy)\n\ntheorem strict_mono_incr_on_proj_Icc {\u03b1 : Type u_1} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) : strict_mono_incr_on (proj_Icc a b h) (Icc a b) := sorry\n\n/-- Extend a function `[a, b] \u2192 \u03b2` to a map `\u03b1 \u2192 \u03b2`. -/\ndef Icc_extend {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) : \u03b1 \u2192 \u03b2 :=\n  f \u2218 proj_Icc a b h\n\n@[simp] theorem Icc_extend_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) : range (Icc_extend h f) = range f := sorry\n\ntheorem Icc_extend_of_le_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1} (f : \u21a5(Icc a b) \u2192 \u03b2) (hx : x \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1} (f : \u21a5(Icc a b) \u2192 \u03b2) (hx : b \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {x : \u03b1} (f : \u21a5(Icc a b) \u2192 \u03b2) (hx : x \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) (f : \u21a5(Icc a b) \u2192 \u03b2) (x : \u21a5(Icc a b)) : Icc_extend h f \u2191x = f x :=\n  congr_arg f (proj_Icc_coe h x)\n\nend set\n\n\ntheorem monotone.Icc_extend {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] [preorder \u03b2] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {f : \u21a5(set.Icc a b) \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] [preorder \u03b2] {a : \u03b1} {b : \u03b1} (h : a \u2264 b) {f : \u21a5(set.Icc a b) \u2192 \u03b2} (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\u2081 u\u2082 u\u2083 u\u2084 \n\nnamespace Mathlib\n\n/-!\n# General operations on functions\n-/\n\nnamespace function\n\n\n/-- Composition of functions: `(f \u2218 g) x = f (g x)`. -/\ndef comp {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} (f : \u03b2 \u2192 \u03c6) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03c6 :=\n  fun (x : \u03b1) => f (g x)\n\n/-- Composition of dependent functions: `(f \u2218' 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 {\u03b1 : Sort u\u2081} {\u03b2 : \u03b1 \u2192 Sort u\u2082} {\u03c6 : {x : \u03b1} \u2192 \u03b2 x \u2192 Sort u\u2083}\n    (f : {x : \u03b1} \u2192 (y : \u03b2 x) \u2192 \u03c6 y) (g : (x : \u03b1) \u2192 \u03b2 x) (x : \u03b1) : \u03c6 (g x) :=\n  f (g x)\n\ninfixr:90 \" \u2218 \" => Mathlib.function.comp\n\ninfixr:80 \" \u2218' \" => Mathlib.function.dcomp\n\ndef comp_right {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b2 \u2192 \u03b2 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2) : \u03b2 \u2192 \u03b1 \u2192 \u03b2 :=\n  fun (b : \u03b2) (a : \u03b1) => f b (g a)\n\ndef comp_left {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b2 \u2192 \u03b2 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b2 \u2192 \u03b2 :=\n  fun (a : \u03b1) (b : \u03b2) => f (g a) b\n\n/-- Given functions `f : \u03b2 \u2192 \u03b2 \u2192 \u03c6` and `g : \u03b1 \u2192 \u03b2`, produce a function `\u03b1 \u2192 \u03b1 \u2192 \u03c6` that evaluates\n`g` on each argument, then applies `f` to the results. Can be used, e.g., to transfer a relation\nfrom `\u03b2` to `\u03b1`. -/\ndef on_fun {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} (f : \u03b2 \u2192 \u03b2 \u2192 \u03c6) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b1 \u2192 \u03c6 :=\n  fun (x y : \u03b1) => f (g x) (g y)\n\ndef combine {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} {\u03b4 : Sort u\u2084} {\u03b6 : Sort u\u2081} (f : \u03b1 \u2192 \u03b2 \u2192 \u03c6)\n    (op : \u03c6 \u2192 \u03b4 \u2192 \u03b6) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b4) : \u03b1 \u2192 \u03b2 \u2192 \u03b6 :=\n  fun (x : \u03b1) (y : \u03b2) => op (f x y) (g x y)\n\n/-- Constant `\u03bb _, a`. -/\ndef const {\u03b1 : Sort u\u2081} (\u03b2 : Sort u\u2082) (a : \u03b1) : \u03b2 \u2192 \u03b1 := fun (x : \u03b2) => a\n\ndef swap {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : \u03b1 \u2192 \u03b2 \u2192 Sort u\u2083} (f : (x : \u03b1) \u2192 (y : \u03b2) \u2192 \u03c6 x y) (y : \u03b2)\n    (x : \u03b1) : \u03c6 x y :=\n  f x y\n\ndef app {\u03b1 : Sort u\u2081} {\u03b2 : \u03b1 \u2192 Sort u\u2082} (f : (x : \u03b1) \u2192 \u03b2 x) (x : \u03b1) : \u03b2 x := f x\n\ninfixl:2 \" on \" => Mathlib.function.on_fun\n\ntheorem left_id {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) : id \u2218 f = f := rfl\n\ntheorem right_id {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) : f \u2218 id = f := rfl\n\n@[simp] theorem comp_app {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} (f : \u03b2 \u2192 \u03c6) (g : \u03b1 \u2192 \u03b2) (a : \u03b1) :\n    comp f g a = f (g a) :=\n  rfl\n\ntheorem comp.assoc {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} {\u03b4 : Sort u\u2084} (f : \u03c6 \u2192 \u03b4) (g : \u03b2 \u2192 \u03c6)\n    (h : \u03b1 \u2192 \u03b2) : (f \u2218 g) \u2218 h = f \u2218 g \u2218 h :=\n  rfl\n\n@[simp] theorem comp.left_id {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) : id \u2218 f = f := rfl\n\n@[simp] theorem comp.right_id {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) : f \u2218 id = f := rfl\n\ntheorem comp_const_right {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} (f : \u03b2 \u2192 \u03c6) (b : \u03b2) :\n    f \u2218 const \u03b1 b = const \u03b1 (f b) :=\n  rfl\n\n/-- A function `f : \u03b1 \u2192 \u03b2` is called injective if `f x = f y` implies `x = y`. -/\ndef injective {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) := \u2200 {a\u2081 a\u2082 : \u03b1}, f a\u2081 = f a\u2082 \u2192 a\u2081 = a\u2082\n\ntheorem injective.comp {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} {g : \u03b2 \u2192 \u03c6} {f : \u03b1 \u2192 \u03b2}\n    (hg : injective g) (hf : injective f) : injective (g \u2218 f) :=\n  fun (a\u2081 a\u2082 : \u03b1) (h : comp g f a\u2081 = comp g f a\u2082) => hf (hg h)\n\n/-- A function `f : \u03b1 \u2192 \u03b2` is calles surjective if every `b : \u03b2` is equal to `f a`\nfor some `a : \u03b1`. -/\ndef surjective {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) := \u2200 (b : \u03b2), \u2203 (a : \u03b1), f a = b\n\ntheorem surjective.comp {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} {g : \u03b2 \u2192 \u03c6} {f : \u03b1 \u2192 \u03b2}\n    (hg : surjective g) (hf : surjective f) : surjective (g \u2218 f) :=\n  sorry\n\n/-- A function is called bijective if it is both injective and surjective. -/\ndef bijective {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) := injective f \u2227 surjective f\n\ntheorem bijective.comp {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03c6 : Sort u\u2083} {g : \u03b2 \u2192 \u03c6} {f : \u03b1 \u2192 \u03b2} :\n    bijective g \u2192 bijective f \u2192 bijective (g \u2218 f) :=\n  sorry\n\n/-- `left_inverse g f` means that g is a left inverse to f. That is, `g \u2218 f = id`. -/\ndef left_inverse {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (g : \u03b2 \u2192 \u03b1) (f : \u03b1 \u2192 \u03b2) := \u2200 (x : \u03b1), g (f x) = x\n\n/-- `has_left_inverse f` means that `f` has an unspecified left inverse. -/\ndef has_left_inverse {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) :=\n  \u2203 (finv : \u03b2 \u2192 \u03b1), left_inverse finv f\n\n/-- `right_inverse g f` means that g is a right inverse to f. That is, `f \u2218 g = id`. -/\ndef right_inverse {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (g : \u03b2 \u2192 \u03b1) (f : \u03b1 \u2192 \u03b2) := left_inverse f g\n\n/-- `has_right_inverse f` means that `f` has an unspecified right inverse. -/\ndef has_right_inverse {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} (f : \u03b1 \u2192 \u03b2) :=\n  \u2203 (finv : \u03b2 \u2192 \u03b1), right_inverse finv f\n\ntheorem left_inverse.injective {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {g : \u03b2 \u2192 \u03b1} {f : \u03b1 \u2192 \u03b2} :\n    left_inverse g f \u2192 injective f :=\n  fun (h : left_inverse g f) (a b : \u03b1) (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 {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {f : \u03b1 \u2192 \u03b2} :\n    has_left_inverse f \u2192 injective f :=\n  fun (h : has_left_inverse f) =>\n    exists.elim h fun (finv : \u03b2 \u2192 \u03b1) (inv : left_inverse finv f) => left_inverse.injective inv\n\ntheorem right_inverse_of_injective_of_left_inverse {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {f : \u03b1 \u2192 \u03b2}\n    {g : \u03b2 \u2192 \u03b1} (injf : injective f) (lfg : left_inverse f g) : right_inverse f g :=\n  fun (x : \u03b1) => (fun (h : f (g (f x)) = f x) => injf h) (lfg (f x))\n\ntheorem right_inverse.surjective {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\n    (h : right_inverse g f) : surjective f :=\n  fun (y : \u03b2) => Exists.intro (g y) (h y)\n\ntheorem has_right_inverse.surjective {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {f : \u03b1 \u2192 \u03b2} :\n    has_right_inverse f \u2192 surjective f :=\n  fun (\u1fb0 : has_right_inverse f) =>\n    Exists.dcases_on \u1fb0\n      fun (\u1fb0_w : \u03b2 \u2192 \u03b1) (\u1fb0_h : right_inverse \u1fb0_w f) =>\n        idRhs (surjective f) (right_inverse.surjective \u1fb0_h)\n\ntheorem left_inverse_of_surjective_of_right_inverse {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {f : \u03b1 \u2192 \u03b2}\n    {g : \u03b2 \u2192 \u03b1} (surjf : surjective f) (rfg : right_inverse f g) : left_inverse f g :=\n  fun (y : \u03b2) =>\n    exists.elim (surjf y)\n      fun (x : \u03b1) (hx : f x = y) => Eq.trans (Eq.trans (hx \u25b8 rfl) (Eq.symm (rfg x) \u25b8 rfl)) hx\n\ntheorem injective_id {\u03b1 : Sort u\u2081} : injective id := fun (a\u2081 a\u2082 : \u03b1) (h : id a\u2081 = id a\u2082) => h\n\ntheorem surjective_id {\u03b1 : Sort u\u2081} : surjective id := fun (a : \u03b1) => Exists.intro a rfl\n\ntheorem bijective_id {\u03b1 : Sort u\u2081} : bijective id :=\n  { left := injective_id, right := surjective_id }\n\nend function\n\n\nnamespace function\n\n\n/-- Interpret a function on `\u03b1 \u00d7 \u03b2` as a function with two arguments. -/\ndef curry {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} {\u03c6 : Type u\u2083} : (\u03b1 \u00d7 \u03b2 \u2192 \u03c6) \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03c6 :=\n  fun (f : \u03b1 \u00d7 \u03b2 \u2192 \u03c6) (a : \u03b1) (b : \u03b2) => f (a, b)\n\n/-- Interpret a function with two arguments as a function on `\u03b1 \u00d7 \u03b2` -/\ndef uncurry {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} {\u03c6 : Type u\u2083} : (\u03b1 \u2192 \u03b2 \u2192 \u03c6) \u2192 \u03b1 \u00d7 \u03b2 \u2192 \u03c6 :=\n  fun (f : \u03b1 \u2192 \u03b2 \u2192 \u03c6) (a : \u03b1 \u00d7 \u03b2) => f (prod.fst a) (prod.snd a)\n\n@[simp] theorem curry_uncurry {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} {\u03c6 : Type u\u2083} (f : \u03b1 \u2192 \u03b2 \u2192 \u03c6) :\n    curry (uncurry f) = f :=\n  rfl\n\n@[simp] theorem uncurry_curry {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} {\u03c6 : Type u\u2083} (f : \u03b1 \u00d7 \u03b2 \u2192 \u03c6) :\n    uncurry (curry f) = f :=\n  sorry\n\nprotected theorem left_inverse.id {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} {g : \u03b2 \u2192 \u03b1} {f : \u03b1 \u2192 \u03b2}\n    (h : left_inverse g f) : g \u2218 f = id :=\n  funext h\n\nprotected def right_inverse.id {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} {g : \u03b2 \u2192 \u03b1} {f : \u03b1 \u2192 \u03b2}\n    (h : right_inverse g f) : f \u2218 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 (\u00b7, 1)\n\n#eval (\u00b7, \u00b7) 1 2\n\n#eval (\u00b7, \u00b7, \u00b7) 1 2 3\n\ntheorem ex1 : [1, 2, 3].map (\u00b7, 1) = [(1, 1), (2, 1), (3, 1)] :=\n  rfl\n\ntheorem ex2 : (\u00b7, \u00b7) 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 {\u03b2 : Type*} [partial_order \u03b2] {a b : \u03b2} : (\u2200\u0393 : \u03b2, \u0393 \u2264 a \u2192 \u0393 \u2264 b) \u2194 a \u2264 b :=\n\u27e8 lattice.poset_yoneda, \u03bb h \u0393, lattice.poset_yoneda_inv \u0393 h\u27e9\n\nlemma poset_coyoneda_iff {\u03b2 : Type*} [partial_order \u03b2] {a b : \u03b2} :\n  (\u2200\u0393 : \u03b2, a \u2264 \u0393 \u2192 b \u2264 \u0393) \u2194 b \u2264 a :=\n\u27e8\u03bb h, h a (le_refl a), \u03bb h \u0393 h', le_trans h h'\u27e9\n\nnamespace set\n\ntheorem subset_Inter_iff {\u03b1 \u03b2} {t : set \u03b2} {s : \u03b1 \u2192 set \u03b2} : t \u2286 (\u22c2 i, s i) \u2194 \u2200 i, t \u2286 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 {\u03b1} {p : \u03b1 \u2192 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 (\u03b9 : Type u) (a : cardinal.{max u v}) :\n  sum (\u03bb _:\u03b9, a) = lift.{_ v} (mk \u03b9) * a :=\nquotient.induction_on a $ \u03bb \u03b1, by simp; exact\n  quotient.sound \u27e8(equiv.sigma_equiv_prod _ _).trans (equiv.prod_congr equiv.ulift.symm (by refl))\u27e9\n\ntheorem sum_le_sup_lift {\u03b9 : Type u} (f : \u03b9 \u2192 cardinal.{max u v}) :\n  sum f \u2264 lift.{_ v} (mk \u03b9) * sup f :=\nby rw \u2190 sum_const_lift; exact sum_le_sum _ _ (le_sup _)\n\n-- TODO: replace mk_Union_le_sum_mk\ntheorem mk_Union_le_sum_mk' {\u03b9 : Type u} {\u03b1 : Type (max u v)} {f : \u03b9 \u2192 set \u03b1} :\n  mk (set.Union f) \u2264 sum (\u03bb i, mk (f i)) :=\ncalc mk (set.Union f) \u2264 mk (\u03a3 i, f i) : mk_le_of_surjective (set.surjective_sigma_to_Union f)\n  ... = sum (\u03bb i, mk (f i)) : (sum_mk _).symm\n\nlemma mk_Union_le_lift {\u03b9 : Type u} {\u03b1 : Type (max u v)} (f : \u03b9 \u2192 set \u03b1) :\n  mk (set.Union f) \u2264 lift.{_ v} (mk \u03b9) * cardinal.sup (\u03bb 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 {\u03b9 : Type u} (f : \u03b9 \u2192 ordinal.{max u v}) {c : ordinal}\n  (H1 : cardinal.lift.{_ v} (mk \u03b9) < c.cof) (H2 : \u2200 i, f i < c) : sup f < c :=\nbegin\n  apply lt_of_le_of_ne,\n  { rw [sup_le], exact \u03bb 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 {\u03b9 : Type u} (f : \u03b9 \u2192 cardinal.{max u v}) {c : cardinal.{max u v}}\n  (H1 : cardinal.lift.{_ v} (cardinal.mk \u03b9) < c.ord.cof)\n  (H2 : \u2200 i, f i < c) : cardinal.sup f < c :=\nby { rw [\u2190ord_lt_ord, \u2190sup_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 {\u03b1} [topological_space \u03b1] {B : set (set \u03b1)}\n  (hB : is_topological_basis B) {s : set \u03b1} {x : \u03b1} : x \u2208 interior s \u2194 \u2203 t \u2286 s, t \u2208 B \u2227 x \u2208 t :=\nbegin\n  rw [mem_interior], split,\n  { rintro \u27e8t, h1t, h2t, h3t\u27e9,\n    rcases mem_basis_subset_of_mem_open hB h3t h2t with \u27e8u, h1u, h2u, h3u\u27e9,\n    exact \u27e8u, set.subset.trans h3u h1t, h1u, h2u\u27e9 },\n  { rintro \u27e8t, h1t, h2t, h3t\u27e9, exact \u27e8t, h1t, is_open_of_is_topological_basis hB h2t, h3t\u27e9 }\nend\n\nend topological_space\n\nopen lattice topological_space cardinal pSet\n\nnoncomputable theory\n\nlocal notation `\u2135\u2081` := (card_ex $ aleph 1 : pSet)\n\nlocal infix ` \u27f9 `:65 := lattice.imp\n\nlocal infix ` \u21d4 `: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 \u2194 p \u2228 q) \u2194 (q \u2192 p) :=\n\u27e8 \u03bb h hq, h.2 (or.inr hq), \u03bb h, \u27e8or.inl, \u03bb h', h'.elim id h\u27e9\u27e9\n\n@[simp] lemma iff_or_self_right {p q : Prop} : (p \u2194 q \u2228 p) \u2194 (q \u2192 p) :=\nby simp [or.comm]\n\n@[simp] lemma and_iff_self_right {p q : Prop} : (p \u2227 q \u2194 p) \u2194 (p \u2192 q) :=\n\u27e8 \u03bb h hp, (h.mpr hp).2, \u03bb h, \u27e8and.left, \u03bb hp, \u27e8hp, h hp\u27e9\u27e9\u27e9\n\n@[simp] lemma and_iff_self_left {p q : Prop} : (p \u2227 q \u2194 q) \u2194 (q \u2192 p) :=\nby { rw [and.comm], exact and_iff_self_right }\n\nlemma and_or_and_not {p q r : Prop} : p \u2227 (q \u2228 (r \u2227 \u00ac p)) \u2194 p \u2227 q :=\nby simp [and_or_distrib_left, and.comm, and.assoc.symm]\n\nlemma or_and_iff_or {p q r : Prop} : (p \u2228 (q \u2227 r) \u2194 p \u2228 q) \u2194 (q \u2192 p \u2228 r) :=\n\u27e8 \u03bb h hq, (h.2 (or.inr hq)).imp id and.right,\n  \u03bb h, \u27e8\u03bb h', h'.imp id and.left, \u03bb h', h'.elim or.inl $ \u03bb hq, (h hq).imp id $ \u03bb hr, \u27e8hq, hr\u27e9\u27e9\u27e9\n\nlemma and_or_iff_and {p q r : Prop} : (p \u2227 (q \u2228 r) \u2194 p \u2227 r) \u2194 (p \u2192 q \u2192 r) :=\n\u27e8 \u03bb h hp hq, (h.mp \u27e8hp, or.inl hq\u27e9).2,\n  \u03bb h, \u27e8\u03bb h', \u27e8h'.1, h'.2.elim (h h'.1) id\u27e9, and.imp id or.inr\u27e9\u27e9\n\nlemma or_not_iff (p q : Prop) [decidable q] : (p \u2228 \u00ac q) \u2194 (q \u2192 p) :=\nby { rw [imp_iff_not_or, or_comm] }\n\nlemma eq_iff_eq_of_eq_left {\u03b1} {x y z : \u03b1} (h : x = y) : x = z \u2194 y = z :=\nby rw [h]\n\nlemma eq_iff_eq_of_eq_right {\u03b1} {x y z : \u03b1} (h : x = y) : z = x \u2194 z = y :=\nby rw [h]\n\nnamespace roption\n\nvariables {\u03b1 : Type*} {o\u2081 o\u2082 : roption \u03b1} {x : \u03b1}\n/-- The intersection of two partial functions -/\ndef inter (o\u2081 o\u2082 : roption \u03b1) : roption \u03b1 :=\n\u27e8 \u2203(x : \u03b1), x \u2208 o\u2081 \u2227 x \u2208 o\u2082,\n  \u03bb h, o\u2081.get $ dom_iff_mem.2 $ let \u27e8x, h1x, h2x\u27e9 := h in \u27e8x, h1x\u27e9\u27e9\n\ninstance : has_inter (roption \u03b1) := \u27e8roption.inter\u27e9\n\nlemma dom_inter : (o\u2081 \u2229 o\u2082).dom \u2194 \u2203(x : \u03b1), x \u2208 o\u2081 \u2227 x \u2208 o\u2082 := iff.refl _\nlemma get_inter (h : \u2203(x : \u03b1), x \u2208 o\u2081 \u2227 x \u2208 o\u2082) :\n  \u2203(h' : o\u2081.dom), (o\u2081 \u2229 o\u2082).get h = o\u2081.get h' := \u27e8_, rfl\u27e9\n\n@[simp] lemma mem_inter : x \u2208 o\u2081 \u2229 o\u2082 \u2194 x \u2208 o\u2081 \u2227 x \u2208 o\u2082 :=\nbegin\n  split,\n  { intro h, rw [mem_eq] at h, rcases h with \u27e8\u27e8x, h1x, h2x\u27e9, rfl\u27e9,\n    cases get_inter \u27e8x, h1x, h2x\u27e9 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, \u2190 h2x], apply get_mem },\n  { rintro \u27e8h1, h2\u27e9, use \u27e8x, h1, h2\u27e9,\n    cases get_inter \u27e8x, h1, h2\u27e9 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 {\u03b9 : Sort*} {\u03b1 : Type*} {\u03b2 : Type*} {f f\u2081 f\u2082 : \u03b1 \u2192. \u03b2}\n\nlemma mem_dom_iff_dom (f : \u03b1 \u2192. \u03b2) (x : \u03b1) : x \u2208 dom f \u2194 (f x).dom :=\nby simp [dom, set.mem_def]\n\nlemma mem_dom_of_mem {f : \u03b1 \u2192. \u03b2} {x : \u03b1} {y : \u03b2} (h : y \u2208 f x) : x \u2208 dom f :=\n(mem_dom f x).2 \u27e8y, h\u27e9\n\nlemma some_fn {f : \u03b1 \u2192. \u03b2} {x : \u03b1} (h : x \u2208 f.dom) : roption.some (f.fn x h) = f x :=\nroption.some_get h\n\nlemma fn_mem {f : \u03b1 \u2192. \u03b2} {x : \u03b1} (h : x \u2208 f.dom) : f.fn x h \u2208 f x :=\nroption.get_mem h\n\nlemma mem_iff_fn_eq {x : \u03b1} {y : \u03b2} : y \u2208 f x \u2194 \u2203 h : x \u2208 f.dom, f.fn x h = y :=\nby refl\n\nlemma fn_eq_iff_mem {x : \u03b1} {y : \u03b2} (h : x \u2208 f.dom) : f.fn x h = y \u2194 y \u2208 f x :=\nby simp [mem_iff_fn_eq, h]\n\nlemma fn_eq_of_mem {x : \u03b1} {y : \u03b2} (h1 : y \u2208 f x) (h2 : x \u2208 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 : \u03b1 \u2192 \u03b2} {x : \u03b1} {y : \u03b2} : y \u2208 (f : \u03b1 \u2192. \u03b2) x \u2194 f x = y :=\nby simp [eq_comm]\n\nlemma lift_eq_some_iff {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {y : \u03b2} : (f : \u03b1 \u2192. \u03b2) x = roption.some y \u2194 f x = y :=\nby simp\n\n@[simp] lemma fn_lift (f : \u03b1 \u2192 \u03b2) (x : \u03b1) : (f : \u03b1 \u2192. \u03b2).fn x trivial = f x :=\nby simp [fn_eq_iff_mem]\n\n/-- The empty partial function -/\ndef empty : \u03b1 \u2192. \u03b2 := \u03bb x, roption.none\n\n@[simp] lemma dom_empty : (empty : \u03b1 \u2192. \u03b2).dom = \u2205 := rfl\n@[simp] lemma empty_def (x : \u03b1) : (empty : \u03b1 \u2192. \u03b2) x = none := rfl\nlemma not_mem_empty (x : \u03b1) (y : \u03b2) : y \u2209 (pfun.empty : \u03b1 \u2192. \u03b2) x := roption.not_mem_none _\n\n/- Two partial functions are equal if their graphs are equal -/\nlemma ext_graph {\u03b1 \u03b2 : Type*} (f g : \u03b1 \u2192. \u03b2) (h_graph : f.graph = g.graph) : f = g :=\n  pfun.ext $ \u03bb _ _, iff_of_eq $ congr_fun h_graph (_,_)\n\nlemma graph_empty_iff_dom_empty {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) : f.graph = \u2205 \u2194 f.dom = \u2205 :=\nbegin\n  have := dom_iff_graph f,\n  split; intro; ext; safe, exact this _ _ \u2039_\u203a\nend\n\n/-- A functional graph is a univalent graph -/\ndef functional {\u03b1 \u03b2 : Type*} (\u0393 : set (\u03b1 \u00d7 \u03b2)) : Prop :=\n  \u2200 a b\u2081 b\u2082, (a, b\u2081) \u2208 \u0393 \u2192 (a, b\u2082) \u2208 \u0393 \u2192 b\u2081 = b\u2082\n\nlemma congr_arg {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) : \u2200 {x} {y} (h\u2081 : x \u2208 f.dom) (h\u2082 : y \u2208 f.dom)\n  (h_eq : x = y), fn f x h\u2081 = fn f y h\u2082 :=\nby intros; congr; assumption\n\nlemma functional_subset {\u03b1 \u03b2 : Type*} (\u0393 \u0393': set (\u03b1 \u00d7 \u03b2)) (h_\u0393' : \u0393' \u2286 \u0393) (h_\u0393 : functional \u0393) : functional \u0393' :=\n  \u03bb _ _ _ _ _, by apply h_\u0393; tidy\n\n/-- The graph of a pfun is always functional -/\nlemma graph_functional {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) : functional f.graph := by tidy\n\n/-- Given a partial functional relation, turn it into a pfun -/\nnoncomputable def of_graph {\u03b1 \u03b2 : Type*} (\u0393 : set (\u03b1 \u00d7 \u03b2)) (h_\u0393 : functional \u0393) : \u03b1 \u2192. \u03b2 :=\n  \u03bb a, \u27e8\u2203 c \u2208 \u0393, (prod.fst c) = a, \u03bb h, @prod.snd \u03b1 \u03b2 $ (classical.indefinite_description _ h).val\u27e9\n\nlemma of_graph_property {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) (a : \u03b1) (h : \u2203 c \u2208 \u0393, (prod.fst c) = a) : \u2203 (H : \u0393 (classical.indefinite_description _ h)), (classical.indefinite_description _ h).val.fst = a :=\n  by apply (classical.indefinite_description _ h).property\n\nlemma of_graph_get {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) (a : \u03b1) : \u2200 h,\n(of_graph \u0393 h_\u0393 a).get h = (classical.indefinite_description _ h).val.snd :=\n  by intro; refl\n\nlemma of_graph_val {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) (a : \u03b1) (h : \u2203 c \u2208 \u0393, (prod.fst c) = a) (c' \u2208 \u0393) (h' : c'.1 = a) :\n  @prod.snd \u03b1 \u03b2 (classical.indefinite_description _ h).val = c'.snd :=\nbegin\n  let c'', swap, change (prod.snd c'' = c'.snd),\n  apply h_\u0393 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 {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) : (of_graph \u0393 h_\u0393).graph = \u0393 :=\nbegin\n  ext, rcases x with \u27e8a,b\u27e9, 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 _ _ \u0393 _ a _ (a,b) _;\n  try{assumption}; refl\nend\n\n@[simp] lemma of_graph_graph {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} : of_graph (f.graph) (graph_functional f) = f :=\n  by apply ext_graph; rw [graph_of_graph]\n\n@[simp] lemma dom_of_graph {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) : (of_graph \u0393 h_\u0393).dom = (prod.fst '' \u0393) :=\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 {\u03b1 \u03b2 : Type*} (\u0393 : set $ \u03b1 \u00d7 \u03b2) (p : \u03b1 \u00d7 \u03b2) (h_\u0393 : functional \u0393) (h_\u0393' : functional $ \u0393 \u222a {p}) : (of_graph (\u0393 \u222a {p}) h_\u0393').dom = (of_graph \u0393 h_\u0393).dom \u222a {p.fst} :=\n  by simp[dom_of_graph, set.image_insert_eq]\n\nlemma in_dom_of_in_graph {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} : \u2200 {a} {b}, (a,b) \u2208 f.graph \u2192 a \u2208 f.dom :=\n  by {intros a b H, apply (pfun.dom_iff_graph _ a).mpr, exact \u27e8b,H\u27e9}\n\nlemma lift_graph' {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} {a : \u03b1} {b : \u03b2} (h_a : a \u2208 f.dom) : (a,b) \u2208 f.graph \u2194 pfun.fn f a h_a = b := by tidy\n\n/-- The intersection of two partial functions -/\ndef inter (f\u2081 f\u2082 : \u03b1 \u2192. \u03b2) : \u03b1 \u2192. \u03b2 :=\n\u03bb x, f\u2081 x \u2229 f\u2082 x\n\ninstance : has_inter (\u03b1 \u2192. \u03b2) := \u27e8pfun.inter\u27e9\n\n@[simp] lemma mem_inter {x : \u03b1} {y : \u03b2} : y \u2208 (f\u2081 \u2229 f\u2082) x \u2194 y \u2208 f\u2081 x \u2227 y \u2208 f\u2082 x :=\nroption.mem_inter\n\n/-- f\u2081 is a subset, or subfunction of f\u2082: if `f\u2081 x = some y` then `f\u2082 x = some y` -/\ndef subfun (f\u2081 f\u2082 : \u03b1 \u2192. \u03b2) : Prop := \u2200 x y, y \u2208 f\u2081 x \u2192 y \u2208 f\u2082 x\n\ninstance : partial_order (\u03b1 \u2192. \u03b2) :=\n{ le := subfun,\n  le_refl := \u03bb f x y hy, hy,\n  le_trans := \u03bb f g h hfg hgh x y hy, hgh x y (hfg x y hy),\n  le_antisymm := \u03bb f g h1 h2, pfun.ext $ \u03bb x y, \u27e8h1 x y, h2 x y\u27e9 }\n\ninstance : semilattice_inf_bot (\u03b1 \u2192. \u03b2) :=\n{ le := subfun,\n  le_refl := \u03bb f x y hy, hy,\n  le_trans := \u03bb f g h hfg hgh x y hy, hgh x y (hfg x y hy),\n  le_antisymm := \u03bb f g h1 h2, pfun.ext $ \u03bb x y, \u27e8h1 x y, h2 x y\u27e9,\n  bot := pfun.empty,\n  bot_le := \u03bb f x y hy, false.elim $ roption.not_mem_none y hy,\n  inf := pfun.inter,\n  inf_le_left := \u03bb f g x y hy, (mem_inter.1 hy).1,\n  inf_le_right := \u03bb f g x y hy, (mem_inter.1 hy).2,\n  le_inf := \u03bb f g h hfg hfh x y hf, mem_inter.2 \u27e8hfg x y hf, hfh x y hf\u27e9 }\n\nlemma le_def : f\u2081 \u2264 f\u2082 \u2194 \u2200 x y, y \u2208 f\u2081 x \u2192 y \u2208 f\u2082 x := by refl\n\nlemma dom_subset_dom_of_le (h : f\u2081 \u2264 f\u2082) : f\u2081.dom \u2286 f\u2082.dom :=\n\u03bb x hx, mem_dom_of_mem (h x (f\u2081.fn x hx) (fn_mem hx))\n\nlemma eq_some_of_subfun (h : f\u2081 \u2264 f\u2082) {x : \u03b1} {y : \u03b2} (h1 : f\u2081 x = roption.some y) :\n  f\u2082 x = roption.some y :=\nby { rw [roption.eq_some_iff] at h1 \u22a2, exact h x y h1 }\n\nlemma fn_eq_of_subfun (h : f\u2081 \u2264 f\u2082) {x : \u03b1} {y : \u03b2} (h1 : x \u2208 f\u2081.dom)\n  (h2 : f\u2081.fn x h1 = y) (h3 : x \u2208 f\u2082.dom) : f\u2082.fn x h3 = y :=\nby { apply fn_eq_of_mem, apply h, rw [mem_iff_fn_eq], exact \u27e8h1, h2\u27e9 }\n\nlemma le_lift {f : \u03b1 \u2192. \u03b2} {g : \u03b1 \u2192 \u03b2} : f \u2264 (g : \u03b1 \u2192. \u03b2) \u2194 \u2200 x y, y \u2208 f x \u2192 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\u2081 f\u2082 : \u03b1 \u2192. \u03b2) : Prop :=\n\u2200(x : \u03b1), x \u2208 f\u2081.dom \u2192 x \u2208 f\u2082.dom \u2192 f\u2081 x = f\u2082 x\n\nlemma compatible_def : compatible f\u2081 f\u2082 \u2194 \u2200(x : \u03b1), x \u2208 f\u2081.dom \u2192 x \u2208 f\u2082.dom \u2192 f\u2081 x = f\u2082 x :=\nby refl\n\nlemma mem_of_compatible (h : compatible f\u2081 f\u2082) {x : \u03b1} {y : \u03b2} (h1 : y \u2208 f\u2081 x) (h2 : x \u2208 f\u2082.dom) :\n  y \u2208 f\u2082 x :=\nby { convert h1, symmetry, exact h x (mem_dom_of_mem h1) h2 }\n\n@[refl] lemma compatible_refl : compatible f f := \u03bb x h1x h2x, rfl\n\nlemma compatible_comm : compatible f\u2081 f\u2082 \u2194 compatible f\u2082 f\u2081 :=\nby { simp [compatible_def, eq_comm, imp.swap] }\n\nlemma compatible_of_le (h : f\u2081 \u2264 f\u2082) : compatible f\u2081 f\u2082 :=\nbegin\n  intros x h1x h2x, apply roption.ext, intro y, split; intro hy, exact h x y hy,\n  have := h x (f\u2081.fn x h1x) (fn_mem h1x),\n  convert fn_mem h1x,\n  rw [\u2190 roption.some_inj, \u2190 roption.eq_some_iff.2 hy, \u2190 roption.eq_some_iff.2 this]\nend\n\n/-- The sup of two functions f\u2081 and f\u2082. Corresponds to the set-theoretic union of f\u2081 and f\u2082 as\n  long as f\u2081 and f\u2082 are compatible. If they are not compatible, the values of f\u2081 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\u2081.dom` is decidable). -/\ndef sup (f\u2081 f\u2082 : \u03b1 \u2192. \u03b2) : \u03b1 \u2192. \u03b2 :=\n\u03bb a, if a \u2208 f\u2081.dom then f\u2081 a else f\u2082 a\n\ninstance : has_sup (\u03b1 \u2192. \u03b2) := \u27e8pfun.sup\u27e9\n\n@[simp] lemma sup_eq_of_mem {x : \u03b1} (h : x \u2208 f\u2081.dom) : (f\u2081 \u2294 f\u2082) x = f\u2081 x :=\nby { dsimp [pfun.lattice.has_sup, pfun.sup], simp [h] }\n\n@[simp] lemma sup_eq_of_nmem {x : \u03b1} (h : x \u2209 f\u2081.dom) : (f\u2081 \u2294 f\u2082) x = f\u2082 x :=\nby { dsimp [pfun.lattice.has_sup, pfun.sup], simp [h] }\n\n@[simp] lemma dom_sup (f\u2081 f\u2082 : \u03b1 \u2192. \u03b2) : (f\u2081 \u2294 f\u2082).dom = f\u2081.dom \u222a f\u2082.dom :=\nby { ext x, by_cases hx : x \u2208 f\u2081.dom; simp [mem_dom_iff_dom] at hx; simp [mem_dom_iff_dom, hx] }\n\nlemma subset_dom_sup_left (f\u2081 f\u2082 : \u03b1 \u2192. \u03b2) : f\u2081.dom \u2286 (f\u2081 \u2294 f\u2082).dom := by simp\nlemma subset_dom_sup_right (f\u2081 f\u2082 : \u03b1 \u2192. \u03b2) : f\u2082.dom \u2286 (f\u2081 \u2294 f\u2082).dom := by simp\n\nlemma mem_sup {x : \u03b1} {y : \u03b2} : y \u2208 (f\u2081 \u2294 f\u2082) x \u2194 y \u2208 f\u2081 x \u2228 (y \u2208 f\u2082 x \u2227 x \u2209 f\u2081.dom) :=\nbegin\n  by_cases hx : x \u2208 f\u2081.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 : \u03b1} {y : \u03b2} (h : compatible f\u2081 f\u2082) :\n  y \u2208 (f\u2081 \u2294 f\u2082) x \u2194 y \u2208 f\u2081 x \u2228 y \u2208 f\u2082 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\u2081 f\u2082 : \u03b1 \u2192. \u03b2} :\n  (f\u2081 \u2294 f\u2082).restrict (subset_dom_sup_left f\u2081 f\u2082) = f\u2081 :=\nbegin\n  apply pfun.ext, intros x y, simp [mem_sup, and_or_and_not],\n  show y \u2208 f\u2081 x \u2192 x \u2208 dom f\u2081, rw [mem_dom], intro hy, exact \u27e8y, hy\u27e9\nend\n\nlemma sup_restrict_right {f\u2081 f\u2082 : \u03b1 \u2192. \u03b2} (h : compatible f\u2081 f\u2082) :\n  (f\u2081 \u2294 f\u2082).restrict (subset_dom_sup_right f\u2081 f\u2082) = f\u2082 :=\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\u2081 f\u2082 : \u03b1 \u2192. \u03b2) : f\u2081 \u2264 f\u2081 \u2294 f\u2082 :=\nby { intros x y hy, rw [mem_sup], exact or.inl hy }\n\nlemma le_sup_right (h : compatible f\u2081 f\u2082) : f\u2082 \u2264 f\u2081 \u2294 f\u2082 :=\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 : \u03b9 \u2192 \u03b1 \u2192. \u03b2) : \u03b1 \u2192. \u03b2 :=\n\u03bb x, if h : \u2203 i, x \u2208 dom (f i) then f (classical.some h) x else roption.none\n\n-- TODO: define Sup instance\n\nlemma Sup_helper {f : \u03b9 \u2192 \u03b1 \u2192. \u03b2} {x : \u03b1} :\n  (\u2203i, x \u2208 (f i).dom) \u2194 (\u2203i, x \u2208 (f i).dom \u2227 Sup f x = f i x) :=\n\u27e8\u03bb h, \u27e8classical.some h, classical.some_spec h, dif_pos h\u27e9, \u03bb\u27e8i, h, _\u27e9, \u27e8i, h\u27e9\u27e9\n\nlemma Sup_helper2 {f : \u03b9 \u2192 \u03b1 \u2192. \u03b2} {x : \u03b1} :\n  (\u2203i, x \u2208 (f i).dom) \u2194 (\u2203i (h : x \u2208 (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 [\u2190 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 : \u03b9 \u2192 \u03b1 \u2192. \u03b2) : (Sup f).dom = set.Union (\u03bb (i : \u03b9), (f i).dom) :=\nbegin\n  ext x, rw [set.mem_Union], by_cases hx : \u2203i, x \u2208 (f i).dom,\n  { simp only [hx, iff_true], rw [Sup_helper2] at hx, rcases hx with \u27e8i, hx, h\u27e9,\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 : \u03b9 \u2192 \u03b1 \u2192. \u03b2) (i : \u03b9) : (f i).dom \u2286 (Sup f).dom :=\nby { rw [dom_Sup], apply set.subset_Union (\u03bb i, (f i).dom) }\n\nlemma Sup_eq_of_mem {f : \u03b9 \u2192 \u03b1 \u2192. \u03b2} {x : \u03b1} {i : \u03b9} (hf : \u2200i j, compatible (f i) (f j))\n  (h : x \u2208 (f i).dom) : Sup f x = f i x :=\nbegin\n  have : \u2203 i, x \u2208 (f i).dom := \u27e8i, h\u27e9, rw [Sup_helper] at this, rcases this with \u27e8j, hj, h2j\u27e9,\n  rw [h2j], exact hf j i x hj h\nend\n\nlemma Sup_eq_of_nmem {f : \u03b9 \u2192 \u03b1 \u2192. \u03b2} {x : \u03b1} (h : \u2200 i, x \u2209 (f i).dom) :\n  Sup f x = roption.none :=\nby { dsimp [pfun.Sup], simp [h] }\n\nlemma mem_Sup {f : \u03b9 \u2192 \u03b1 \u2192. \u03b2} {x : \u03b1} {y : \u03b2} (hf : \u2200i j, compatible (f i) (f j)) :\n  y \u2208 Sup f x \u2194 \u2203 i, y \u2208 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 \u27e8i, hi\u27e9, rwa [Sup_eq_of_mem hf (mem_dom_of_mem hi)] }\nend\n\nlemma Sup_restrict {f : \u03b9 \u2192 \u03b1 \u2192. \u03b2} (hf : \u2200i j, compatible (f i) (f j)) (i : \u03b9) :\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 \u27e8hx, j, hj\u27e9, exact mem_of_compatible (hf j i) hj hx },\n  { intro hy, exact \u27e8mem_dom_of_mem hy, i, hy\u27e9 }\nend\n\nlemma le_Sup {f : \u03b9 \u2192 \u03b1 \u2192. \u03b2} (hf : \u2200i j, compatible (f i) (f j)) (i : \u03b9) : f i \u2264 Sup f :=\nby { intros x y hy, rw [mem_Sup hf], exact \u27e8i, hy\u27e9 }\n\nlemma Sup_le {f : \u03b9 \u2192 \u03b1 \u2192. \u03b2} (hf : \u2200i j, compatible (f i) (f j))\n  {g : \u03b1 \u2192. \u03b2} : Sup f \u2264 g \u2194 \u2200i, f i \u2264 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 \u2192. Y} {x : X} {Hx : x \u2208 f.dom} :\n  (fn f x Hx) \u2208 f.ran :=\nby use x; tidy\n\nlemma mk_ran_le_mk_dom {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192. \u03b2) : # f.ran \u2264 # f.dom :=\nbegin\n  refine mk_le_of_surjective _,\n  { exact \u03bb \u27e8x,H\u27e9, \u27e8fn f x H, by apply fn_mem_ran\u27e9},\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 \u2039_\u203a \u2039_\u203a, 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 : \u03b1) (y : \u03b2) : \u03b1 \u2192. \u03b2 :=\n\u03bb a, { dom := a = x, get := \u03bb _, y }\n\n@[simp] lemma fn_singleton {x x' : \u03b1} {y : \u03b2} (H_a : x' = x) :\n  fn (singleton x y) x' H_a = y := by refl\n\n@[simp] lemma mem_singleton {x x' : \u03b1} {y y' : \u03b2} :\n  y' \u2208 singleton x y x' \u2194 x = x' \u2227 y = y' :=\nbegin\n  split,\n  { intro h, rw [roption.mem_eq] at h, rcases h with \u27e8h, rfl\u27e9, exact \u27e8h.symm, rfl\u27e9 },\n  { rintro \u27e8rfl, rfl\u27e9, exact \u27e8rfl, rfl\u27e9 }\nend\n\n@[simp] lemma singleton_eq_some {x : \u03b1} {y : \u03b2} : singleton x y x = roption.some y :=\nby simp [roption.eq_some_iff]\n\n@[simp] lemma dom_singleton {x : \u03b1} {y : \u03b2} : (singleton x y).dom = {x} :=\nby { ext x', simp [singleton, mem_dom_iff_dom] }\n\nlemma mk_dom_singleton {x : \u03b1} {y : \u03b2} : # (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 : \u03b1 \u2192. \u03b2) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b2 :=\n\u03bb x, if hx : x \u2208 f.dom then f.fn x hx else g x\n\nlemma extend_via_pos {f : \u03b1 \u2192. \u03b2} {g : \u03b1 \u2192 \u03b2} {x : \u03b1} (h : x \u2208 f.dom) :\n  extend_via f g x = f.fn x h :=\nby simp [h, extend_via]\n\nlemma extend_via_neg {f : \u03b1 \u2192. \u03b2} {g : \u03b1 \u2192 \u03b2} {x : \u03b1} (h : x \u2209 f.dom) :\n  extend_via f g x = g x :=\nby simp [h, extend_via]\n\nlemma le_extend_via (f : \u03b1 \u2192. \u03b2) (g : \u03b1 \u2192 \u03b2) : f \u2264 \u2191(extend_via f g) :=\n\u03bb 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 \u2192. Y and a point y : Y, define an extension g of f to X such that g(x) = y whenever x \u2209 f.dom\n-/\nnoncomputable def trivial_extension (f : \u03b1 \u2192. \u03b2) (y : \u03b2) : \u03b1 \u2192 \u03b2 :=\nextend_via f (\u03bb _, y)\n\nlemma trivial_extension_pos {f : \u03b1 \u2192. \u03b2} {y : \u03b2} {x : \u03b1} (h : x \u2208 f.dom) :\n  trivial_extension f y x = f.fn x h :=\nextend_via_pos h\n\nlemma trivial_extension_neg {f : \u03b1 \u2192. \u03b2} {y : \u03b2} {x : \u03b1} (h : x \u2209 f.dom) :\n  trivial_extension f y x = y :=\nextend_via_neg h\n\nlemma le_trivial_extension (f : \u03b1 \u2192. \u03b2) (y : \u03b2) : f \u2264 \u2191(trivial_extension f y) :=\nle_extend_via _ _\n\nend pfun\n\nsection collapse_poset\n\nstructure collapse_poset (X Y : Type u) (\u03ba : cardinal.{u}) : Type u :=\n(f        : X \u2192. Y)\n(Hc       : #f.dom < \u03ba)\n\ndef collapse_poset.empty {\u03b1 \u03b2 : Type u} {\u03ba : cardinal} (h : 0 < \u03ba) : collapse_poset \u03b1 \u03b2 \u03ba :=\n{ f := pfun.empty,\n  Hc := by simp [h] }\n\nopen pfun\n\nvariables {X Y : Type u} {\u03ba : cardinal.{u}}\n\nlemma collapse_poset.mk_ran_lt (p : collapse_poset X Y \u03ba) : # p.f.ran < \u03ba :=\nlt_of_le_of_lt (mk_ran_le_mk_dom p.f) p.Hc\n\ndef collapse_poset.inter (p\u2081 p\u2082 : collapse_poset X Y \u03ba) : collapse_poset X Y \u03ba :=\n{ f := p\u2081.f \u2293 p\u2082.f,\n  Hc := lt_of_le_of_lt (mk_le_mk_of_subset $ dom_subset_dom_of_le inf_le_left) p\u2081.Hc }\n\nnoncomputable def collapse_poset.union (p\u2081 p\u2082 : collapse_poset X Y \u03ba) (h : omega \u2264 \u03ba) :\n  collapse_poset X Y \u03ba :=\n{ f := p\u2081.f \u2294 p\u2082.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\u2081.Hc p\u2082.Hc) } }\n\nlemma exists_mem_compl_dom_of_unctbl (p : collapse_poset X Y \u03ba) (H_card : \u03ba \u2264 #X) :\n  \u2203 x : X, x \u2209 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 \u03ba) (H_card : \u03ba \u2264 #Y) :\n  \u2203 y : Y, y \u2209 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 \u03ba) : set (X \u2192 Y) :=\n{f | p.f \u2264 (f : X \u2192. Y)}\n\n@[simp] lemma collapse_poset.principal_open_empty (h : 0 < \u03ba) :\n  collapse_poset.principal_open (collapse_poset.empty h : collapse_poset X Y \u03ba) = 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 \u03ba} {f : X \u2192 Y} :\n  f \u2208 collapse_poset.principal_open p \u2194 \u2200 x y, y \u2208 p.f x \u2192 f x = y :=\nle_lift\n\nlemma mem_principal_open_iff' {p : collapse_poset X Y \u03ba} {f : X \u2192 Y} :\n  f \u2208 collapse_poset.principal_open p \u2194 \u2200 (x : X) (H_x : x \u2208 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 \u03ba} {f : X \u2192 Y} :\n  f \u2208 - collapse_poset.principal_open p \u2194 \u2203x (H_x : x \u2208 p.f.dom), f x \u2260 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 \u03ba} {f : X \u2192 Y} {x : X}\n  (H : f \u2208 collapse_poset.principal_open p) : x \u2208 p.f.dom \u2192 f x \u2208 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 {\u03b9 : Type u} (p : \u03b9 \u2192 collapse_poset X Y \u03ba) (h : #\u03b9 < (ord \u03ba).cof)\n  (h\u03ba : cardinal.omega \u2264 \u03ba) : collapse_poset X Y \u03ba :=\n\u27e8Sup $ \u03bb 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\u03ba (lt_of_lt_of_le h (ordinal.cof_ord_le \u03ba)),\n    exact ordinal.sup_lt _ h (\u03bb i, collapse_poset.Hc _)\n  end\u27e9\n\ndef collapse_poset.Sup_lift {\u03b9 : Type u} {X Y : Type (max u v)} {\u03ba : cardinal.{max u v}}\n  (p : \u03b9 \u2192 collapse_poset X Y \u03ba)\n  (h : cardinal.lift.{_ v} #\u03b9 < (ord \u03ba).cof)\n  (h\u03ba : cardinal.omega \u2264 \u03ba) : collapse_poset X Y \u03ba :=\n\u27e8Sup $ \u03bb 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\u03ba (lt_of_lt_of_le h (ordinal.cof_ord_le \u03ba)),\n    refine ordinal.sup_lt_lift _ h (\u03bb i, collapse_poset.Hc _)\n  end\u27e9\n\ndef collapse_space : topological_space (X \u2192 Y) :=\ngenerate_from $\n  (collapse_poset.principal_open : collapse_poset X Y cardinal.omega.succ \u2192 set (X \u2192 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\u03ba : 1 < \u03ba) : collapse_poset X Y \u03ba :=\n{ f := singleton x y,\n  Hc := by simp [h\u03ba] }\n\n@[simp] lemma singleton_collapse_poset_principal_open {x : X} {y : Y} {h\u03ba : 1 < \u03ba} :\n  principal_open (singleton_collapse_poset x y h\u03ba) = {g : X \u2192 Y | g x = y} :=\nbegin\n  ext f, refine \u27e8_,_\u27e9; 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\u03ba : 1 < \u03ba) (p : collapse_poset X Y \u03ba) :\n  \u2203 {\u03b9 : Type u} (s : \u03b9 \u2192 collapse_poset X Y \u03ba),\n    set.Union (\u03bb i : \u03b9, principal_open $ s i) = - principal_open p :=\nbegin\n  use {pr : X \u00d7 Y // \u2203 H_mem : pr.1 \u2208 p.f.dom, pr.2 \u2260 fn p.f pr.1 H_mem },\n  use (\u03bb s, singleton_collapse_poset s.1.1 s.1.2 h\u03ba),\n  ext f, split; intro H,\n    { intro H_mem,\n      rcases H with \u27e8P, \u27e8\u27e8\u27e8x',y'\u27e9, \u27e8H_mem\u2081, H_neq\u27e9\u27e9, rfl\u27e9, H_mem\u2082\u27e9,\n      dsimp at H_neq H_mem\u2082,\n      apply H_neq,\n      rw [\u2190 show f x' = y', by simpa using H_mem\u2082],\n      rw mem_principal_open_iff'.mp H_mem _ _ },\n    { rw [mem_compl_principal_open_iff] at H, rcases H with \u27e8x, Hx, H_neq\u27e9,\n      suffices this : \u2203 (a : X) (H_mem : (a, f a).fst \u2208 dom (p.f)), \u00acf a = fn (p.f) a H_mem,\n      { simp [this] },\n      exact \u27e8_, by use \u2039_\u203a\u27e9 }\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 \u27e8\u03b9, \u27e8s, Hu\u27e9\u27e9,\n     rw [is_closed, \u2190 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\u03ba : omega \u2264 \u03ba) {p\u2081 p\u2082 : collapse_poset X Y \u03ba}\n  (H : compatible p\u2081.f p\u2082.f) :\n  principal_open p\u2081 \u2229 principal_open p\u2082 = principal_open (p\u2081.union p\u2082 h\u03ba) :=\nbegin\n  ext f,\n  simp [mem_principal_open_iff],\n  rw [\u2190 forall_and_distrib], apply forall_congr, intro x,\n  rw [\u2190 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 \u2192 Y) :=\ninsert (\u2205 : set (X \u2192 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 \u27e8\u03bb P HP P' HP' f H_mem_inter, _,_,_\u27e9,\n    { rw [collapse_space_basis] at HP HP',\n      cases HP; cases HP',\n\n      { suffices this : f \u2208 (\u2205 : set $ X \u2192 Y),\n          by {cases this}, substs HP, cases H_mem_inter, exact \u2039_\u203a },\n      { suffices this : f \u2208 (\u2205 : set $ X \u2192 Y),\n          by {cases this}, substs HP, cases H_mem_inter, exact \u2039_\u203a },\n      { suffices this : f \u2208 (\u2205 : set $ X \u2192 Y),\n          by {cases this}, substs HP', cases H_mem_inter, exact \u2039_\u203a },\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 \u2229 principal_open y'),\n      refine \u27e8_,\u27e8\u2039_\u203a,(by refl)\u27e9\u27e9,\n      { by_cases H_compat : compatible y.f y'.f,\n        { right, refine \u27e8_,\u27e8trivial, _\u27e9\u27e9, exact y.union y' (le_of_lt (lt_succ_self _)),\n        rwa [inter_principal_open] },\n        { suffices this : principal_open y \u2229 principal_open y' = \u2205,\n            by {rw [this], exact or.inl rfl },\n          ext g; split; intro H,\n            { exfalso, cases H with H\u2081 H\u2082, rw [mem_principal_open_iff] at H\u2081 H\u2082,\n              rw [compatible] at H_compat,\n              push_neg at H_compat, rcases H_compat with \u27e8x, Hx\u2081, Hx\u2082, Hx\u2083\u27e9,\n              apply Hx\u2083, rw [\u2190 some_fn Hx\u2081, \u2190 some_fn Hx\u2082],\n              rw [\u2190 H\u2081 x _ (fn_mem Hx\u2081), \u2190 H\u2082 x _ (fn_mem Hx\u2082)] },\n            { cases H }}}},\n\n    { refine le_antisymm (\u03bb _ _, trivial) _,\n      intros f _a, refine \u27e8_,_\u27e9,\n      { exact (principal_open (collapse_poset.empty zero_lt_omega_succ)) },\n      { refine \u27e8by {rw [collapse_space_basis], right, exact set.mem_image_univ},_\u27e9, 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 \u2039_\u203a },\n        { exact is_open_univ },\n        { apply generate_open.inter, exact \u2039_\u203a, exact \u2039_\u203a },\n        { apply generate_open.sUnion, intros S HS, solve_by_elim }},\n      { refine generate_from_mono _, exact \u03bb _ _, or.inr \u2039_\u203a }}\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 \u2192 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 \u03ba} {y : Y}\n  : (trivial_extension p.f y) \u2208 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 {\u03b1 : Type*} [nontrivial_complete_boolean_algebra \u03b1]\n\n-- any \u03c9-indexed downward chain in D has an intersection in D\ndef omega_closed (D : set \u03b1) : Prop :=\n\u2200 (s : \u2115 \u2192 \u03b1) (s_sub_D : \u2200n, s n \u2208 D) (H_nonzero : \u2200 n, \u22a5 < s n) (H_chain : \u2200 n, s (n+1) \u2264 s n), (\u2a05n, s n) \u2208 D\n\ndef dense_subset {\u03b1 : Type*} [order_bot \u03b1] (D : set \u03b1) : Prop :=\n\u22a5 \u2209 D \u2227 \u2200x, \u22a5 < x \u2192 \u2203 y \u2208 D, y \u2264 x\n\n@[reducible]def dense_omega_closed_subset (D : set \u03b1) : Prop :=\ndense_subset D \u2227 omega_closed D\n\nvariable (\u03b1)\ndef has_dense_omega_closed_subset : Prop :=\n\u2203 D : set \u03b1, dense_omega_closed_subset D\n\nvariable {\u03b1}\n\nlemma nonzero_of_mem_dense_omega_closed_subset {x : \u03b1} {D : set \u03b1} (H : dense_omega_closed_subset D) (H_mem : x \u2208 D) : \u22a5 < 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 : \u2115 \u2192 \u03b1} {D : set \u03b1} (H : dense_omega_closed_subset D) (H_chain : \u2200 n, s (n + 1) \u2264 s n) (H_mem : \u2200 n, s n \u2208 D) : \u22a5 < \u2a05 n, s n :=\nbegin\n  apply nonzero_of_mem_dense_omega_closed_subset H, refine H.right s \u2039_\u203a _ \u2039_\u203a,\n  intro n, specialize H_mem n, from nonzero_of_mem_dense_omega_closed_subset H \u2039_\u203a\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 \u2192 Y) collapse_space\n\nvariables {X Y}\n\n@[instance, priority 9001] def collapse_algebra_boolean_algebra [nonempty (X \u2192 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\u27e8collapse_poset.principal_open p, collapse_poset.is_regular_principal_open p\u27e9\n\nlocal notation `\u03b9`:65 := collapse_poset.inclusion\n\nlemma collapse_poset_dense_basis : \u2200 T \u2208 collapse_space_basis X Y,\n  \u2200 h_nonempty : T \u2260 \u2205, \u2203 p : collapse_poset X Y cardinal.omega.succ, (\u03b9 p).val \u2286 T :=\nbegin\n  intros T H_mem_basis _,\n  refine or.elim H_mem_basis (\u03bb _, (false.elim (absurd \u2039T = \u2205\u203a \u2039_\u203a))) (\u03bb H, _),\n  rcases H with \u27e8_,\u27e8_,H\u2082\u27e9\u27e9, exact \u27e8\u2039_\u203a, by simp[H\u2082, collapse_poset.inclusion]\u27e9\nend\n\nlemma collapse_poset_dense [nonempty (X \u2192 Y)] {b : collapse_algebra X Y}\n  (H : \u22a5 < b) : \u2203 p : collapse_poset X Y cardinal.omega.succ, \u03b9 p \u2264 b :=\nbegin\n  cases (classical.choice (classical.nonempty_of_not_empty _ H.right.symm)) with S_wit H_wit,\n  change \u2203 p, (\u03b9 p).val \u2286 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 \u27e8v, Hv\u2081, Hv\u2082, Hv\u2083\u27e9,\n  have : v \u2260 \u2205, by {intro H, rw [H] at Hv\u2082, cases Hv\u2082},\n  cases (collapse_poset_dense_basis \u2039_\u203a \u2039_\u203a \u2039_\u203a) with p H_p, exact \u27e8p, set.subset.trans H_p \u2039_\u203a\u27e9\nend\n\n/- note: the hypothesis in this lemma almost always implies that q.f \u2264 p.f, except when `Y` is a singleton -/\ndef compatible_of_inclusion_le_inclusion [nonempty $ X \u2192 Y]\n  {p q : collapse_poset X Y cardinal.omega.succ} (h : \u03b9 p \u2264 \u03b9 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 [\u2190 pfun.some_fn px, \u2190 pfun.some_fn qx, this]\nend\n\nlocal postfix `\u1d56`:80 := perp\n\nlemma principal_open_eq_infi_of_eq_inter [nonempty $ X \u2192 Y] {I : Type*} {s : I \u2192 collapse_algebra X Y}\n  {s_infty : collapse_algebra X Y} (H_eq_inter: s_infty.val = \u22c2n, (s n).val)\n  : s_infty = \u2a05 n, s n :=\nbegin\n  rw subtype.ext, rw fst_infi',\n  have s_infty_p_p : s_infty.val = s_infty.val\u1d56\u1d56,\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 \u2192 Y] :\n  dense_omega_closed_subset (set.range \u03b9 : set (collapse_algebra X Y)) :=\nbegin\n  refine \u27e8\u27e8_, _\u27e9, _\u27e9,\n  { rintro \u27e8p, hp\u27e9, 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 \u2260 \u2205 := ho.2.symm,\n    rcases nonempty_basis_subset collapse_space_basis_spec h2o (is_open_of_is_regular o.2)\n      with \u27e8u, hu, h2u, h3u\u27e9,\n    rcases or.resolve_left hu h2u with \u27e8u', hu', rfl\u27e9,\n    refine \u27e8\u03b9 u', set.mem_range_self u', h3u\u27e9 },\n  { intros f hf h2f h3f, choose g hg using hf,\n    simp only [(hg _).symm] at h3f h2f \u22a2, 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 \u27e8P, _\u27e9,\n    have : \u2200 {{i j : \u2115}}, i \u2264 j \u2192 \u03b9 (g j) \u2264 \u03b9 (g i),\n    { intros i j h, induction h, exact le_refl _, exact le_trans (h3f _) h_ih },\n    have : \u2200 (i j : \u2115), 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 \u27e8_,_\u27e9; intro H,\n      { rw set.mem_Inter, intro k,\n        rw mem_principal_open_iff at H \u22a2, intros x y Hy,\n        apply H, dsimp[P, collapse_poset.Sup_lift],\n        rw (pfun.mem_Sup \u2039_\u203a), use k, from \u2039_\u203a},\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 \u2039_\u203a) at H_mem,\n        simp only [mem_principal_open_iff] at H, finish }}\nend\n\nend collapse_poset_dense\n\nlocal notation `\ud835\udd39` := collapse_algebra ((\u2135\u2081 : pSet).type) (powerset omega : pSet).type\n\ninstance nonempty_aleph_one_powerset_omega : nonempty $ ((\u2135\u2081).type) \u2192 (powerset omega).type :=\n\u27e8\u03bb _, by {unfold pSet.omega, exact \u03bb _, false}\u27e9\n\ndef collapse_boolean_algebra : nontrivial_complete_boolean_algebra \ud835\udd39 :=\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    \u2200 (x : \u21a5(PresheafedSpace.carrier (SheafedSpace.to_PresheafedSpace _to_SheafedSpace))),\n      local_ring\n        \u21a5(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) => \u21a5(to_Top X)\n\n-- PROJECT: how about a typeclass \"has_structure_sheaf\" to mediate the \ud835\udcaa 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 \ud835\udcaa (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 \u27f6 to_SheafedSpace Y) =>\n      \u2200 (x : \u21a5(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.\ud835\udcaa.stalk` here?\n\ndef stalk (X : LocallyRingedSpace) (x : \u21a5X) : 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 \u27f6 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 \u27f6 Y) (x : \u21a5X) :\n    stalk Y (coe_fn (PresheafedSpace.hom.base (subtype.val f)) x) \u27f6 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 \u27f6 Y) (x : \u21a5X) : 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 := \ud835\udfd9, 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 \u226b 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 \u2964 SheafedSpace CommRing :=\n  category_theory.functor.mk (fun (X : LocallyRingedSpace) => to_SheafedSpace X)\n    fun (X Y : LocallyRingedSpace) (f : X \u27f6 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 \u27f6 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 \u0393 : LocallyRingedSpace\u1d52\u1d56 \u2964 CommRing :=\n  category_theory.functor.op forget_to_SheafedSpace \u22d9 SheafedSpace.\u0393\n\ntheorem \u0393_def : \u0393 = category_theory.functor.op forget_to_SheafedSpace \u22d9 SheafedSpace.\u0393 := rfl\n\n@[simp] theorem \u0393_obj (X : LocallyRingedSpace\u1d52\u1d56) :\n    category_theory.functor.obj \u0393 X =\n        category_theory.functor.obj\n          (PresheafedSpace.presheaf\n            (SheafedSpace.to_PresheafedSpace (to_SheafedSpace (opposite.unop X))))\n          (opposite.op \u22a4) :=\n  rfl\n\ntheorem \u0393_obj_op (X : LocallyRingedSpace) :\n    category_theory.functor.obj \u0393 (opposite.op X) =\n        category_theory.functor.obj\n          (PresheafedSpace.presheaf (SheafedSpace.to_PresheafedSpace (to_SheafedSpace X)))\n          (opposite.op \u22a4) :=\n  rfl\n\n@[simp] theorem \u0393_map {X : LocallyRingedSpace\u1d52\u1d56} {Y : LocallyRingedSpace\u1d52\u1d56} (f : X \u27f6 Y) :\n    category_theory.functor.map \u0393 f =\n        category_theory.nat_trans.app\n            (PresheafedSpace.hom.c (subtype.val (category_theory.has_hom.hom.unop f)))\n            (opposite.op \u22a4) \u226b\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))) \u22a4)) :=\n  rfl\n\ntheorem \u0393_map_op {X : LocallyRingedSpace} {Y : LocallyRingedSpace} (f : X \u27f6 Y) :\n    category_theory.functor.map \u0393 (category_theory.has_hom.hom.op f) =\n        category_theory.nat_trans.app (PresheafedSpace.hom.c (subtype.val f)) (opposite.op \u22a4) \u226b\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)) \u22a4)) :=\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) \u2964 (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 \u2964 D` is cover_lifting, then\n  `Ran G.op` (`\u209au`) as a functor `(C\u1d52\u1d56 \u2964 A) \u2964 (D\u1d52\u1d56 \u2964 A)` of presheaves maps sheaves to sheaves.\n* `category_theory.pullback_copullback_adjunction`: If `G : (C, J) \u2964 (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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\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) \u2964 (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 \u2964 D) : Prop :=\n(cover_lift : \u2200 {U : C} {S : sieve (G.obj U)} (hS : S \u2208 K (G.obj U)), S.functor_pullback G \u2208 J U)\n\n/-- The identity functor on a site is cover-lifting. -/\nlemma id_cover_lifting : cover_lifting J J (\ud835\udfed _) := \u27e8\u03bb _ _ h, by simpa using h\u27e9\n\nvariables {J K}\n\n/-- The composition of two cover-lifting functors are cover-lifting -/\nlemma comp_cover_lifting {F : C \u2964 D} (hu : cover_lifting J K F) {G : D \u2964 E}\n  (hv : cover_lifting K L G) : cover_lifting J L (F \u22d9 G) :=\n\u27e8\u03bb _ S h, hu.cover_lift (hv.cover_lift h)\u27e9\n\nend cover_lifting\n\n/-!\nWe will now prove that `Ran G.op` (`\u209au`) 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, `\u2286` denotes the homs on `C` and `D` as in the topological analogy.\nBy definition, the presheaf `\ud835\udca2 : D\u1d52\u1d56 \u2964 A` is a sheaf if for every sieve `S` of `U : D`, and every\ncompatible family of morphisms `X \u27f6 \ud835\udca2(V)` for each `V \u2286 U : S` with a fixed source `X`,\nwe can glue them into a morphism `X \u27f6 \ud835\udca2(U)`.\n\nSince the presheaf `\ud835\udca2 := (Ran G.op).obj \u2131.val` is defined via `\ud835\udca2(U) = lim_{G(V) \u2286 U} \u2131(V)`, for\ngluing the family `x` into a `X \u27f6 \ud835\udca2(U)`, it suffices to provide a `X \u27f6 \u2131(Y)` for each\n`G(Y) \u2286 U`. This can be done since `{ Y' \u2286 Y : G(Y') \u2286 U \u2208 S}` is a covering sieve for `Y` on\n`C` (by the cover-lifting property of `G`). Thus the morphisms `X \u27f6 \ud835\udca2(G(Y')) \u27f6 \u2131(Y')` can be\nglued into a morphism `X \u27f6 \u2131(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 \u27f6 \ud835\udca2(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 \u2964 D} (hu : cover_lifting J K G) (\u2131 : Sheaf J A)\nvariables {X : A} {U : D} (S : sieve U) (hS : S \u2208 K U)\n\ninstance (X : D\u1d52\u1d56) : 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 \u2131.val \u22d9 coyoneda.obj (op X)))\nvariables (hx : x.compatible)\n\n/-- The family of morphisms `X \u27f6 \ud835\udca2(G(Y')) \u27f6 \u2131(Y')` defined on `{ Y' \u2286 Y : G(Y') \u2286 U \u2208 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 _ \u27f6 _, from whisker_right ((Ran.adjunction A G.op).counit.app \u2131.val)\n    (coyoneda.obj (op X))))\n\n@[simp] lemma pulledback_family_apply (Y : structured_arrow (op U) G.op) {W} {f : W \u27f6 _} (Hf) :\n  pulledback_family \u2131 S x Y f Hf =\n    x (G.map f \u226b Y.hom.unop) Hf \u226b ((Ran.adjunction A G.op).counit.app \u2131.val).app (op W) := rfl\n\nvariables {x} {S}\ninclude hu hS hx\n\n/-- Given a `G(Y) \u2286 U`, we can find a unique section `X \u27f6 \u2131(Y)` that agrees with `x`. -/\ndef get_section (Y : structured_arrow (op U) G.op) : X \u27f6 \u2131.val.obj Y.right :=\nbegin\n  let hom_sh := whisker_right ((Ran.adjunction A G.op).counit.app \u2131.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 (\u2131.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 \u2131 S x Y).is_amalgamation (get_section hu \u2131 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 \u2131 S x Y).is_amalgamation y) : y = get_section hu \u2131 hS hx Y :=\nbegin\n  apply is_sheaf_for.is_separated_for _ (pulledback_family \u2131 S x Y),\n  { exact H },\n  { apply get_section_is_amalgamation },\n  { exact \u2131.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 \u27f6 Z) :\n  get_section hu \u2131 hS hx Y \u226b \u2131.val.map f.right = get_section hu \u2131 hS hx Z :=\nbegin\n  apply get_section_is_unique,\n  intros V' fV' hV',\n  have eq : Z.hom = Y.hom \u226b (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 \u2131 hS hx Y (fV' \u226b 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 _ \u226b 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 \u2131.val (op U)) :=\n{ X := X, \u03c0 := { app := \u03bb Y, get_section hu \u2131 hS hx Y, naturality' := \u03bb Y Z f, by tidy } }\n\n@[simp] lemma glued_limit_cone_\u03c0_app (W) : (glued_limit_cone hu \u2131 hS hx).\u03c0.app W =\n  get_section hu \u2131 hS hx W := rfl\n\n/-- The section obtained by passing `glued_limit_cone` into `category_theory.limits.limit.lift`. -/\ndef glued_section : X \u27f6 ((Ran G.op).obj \u2131.val).obj (op U) :=\nlimit.lift _ (glued_limit_cone hu \u2131 hS hx)\n\n/--\nA helper lemma for the following two lemmas. Basically stating that if the section `y : X \u27f6 \ud835\udca2(V)`\ncoincides with `x` on `G(V')` for all `G(V') \u2286 V \u2208 S`, then `X \u27f6 \ud835\udca2(V) \u27f6 \u2131(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 \u27f6 U) (y : X \u27f6 ((Ran G.op).obj \u2131.val).obj (op V)) (W)\n  (H : \u2200 {V'} {fV : G.obj V' \u27f6 V} (hV), y \u226b ((Ran G.op).obj \u2131.val).map fV.op = x (fV \u226b f) hV) :\n  y \u226b limit.\u03c0 (Ran.diagram G.op \u2131.val (op V)) W =\n    (glued_limit_cone hu \u2131 hS hx).\u03c0.app ((structured_arrow.map f.op).obj W) :=\nbegin\n  dsimp only [glued_limit_cone_\u03c0_app],\n  apply get_section_is_unique hu \u2131 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 \u226b ((Ran G.op).obj \u2131.val).map (G.map fV' \u226b W.hom.unop).op =\n    x (G.map fV' \u226b W.hom.unop \u226b f) (by simpa only using hV'),\n  { convert H (show S ((G.map fV' \u226b W.hom.unop) \u226b 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, \u2190 this, op_comp,\n    Ran_obj_map, nat_trans.id_app],\n  erw [category.id_comp, limit.pre_\u03c0],\n  congr,\n  convert limit.w (Ran.diagram G.op \u2131.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 \u2131 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_\u03c0,\n  symmetry,\n  convert helper hu \u2131 hS hx _ (x fV hV) _ _ using 1,\n  intros V' fV' hV',\n  convert hx (fV') (\ud835\udfd9 _) 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 \u2131 hS hx :=\nbegin\n  unfold glued_section limit.lift,\n  ext W,\n  erw limit.lift_\u03c0,\n  convert helper hu \u2131 hS hx (\ud835\udfd9 _) 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 \u2964 D} (hG : cover_lifting J K G) (\u2131 : Sheaf J A) :\n  presheaf.is_sheaf K ((Ran G.op).obj \u2131.val) :=\nbegin\n  intros X U S hS x hx,\n  split, swap,\n  { apply Ran_is_sheaf_of_cover_lifting.glued_section hG \u2131 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 \u2964 D} (hG : cover_lifting J K G) :\n  Sheaf J A \u2964 Sheaf K A :=\n{ obj := \u03bb \u2131, \u27e8(Ran G.op).obj \u2131.val, Ran_is_sheaf_of_cover_lifting hG \u2131\u27e9,\n  map := \u03bb _ _ f, \u27e8(Ran G.op).map f.val\u27e9,\n  map_id' := \u03bb \u2131, Sheaf.hom.ext _ _ $ (Ran G.op).map_id \u2131.val,\n  map_comp' := \u03bb _ _ _ 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 \u2964 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 \u22a3 sites.copullback A Hl :=\n{ hom_equiv := \u03bb X Y,\n  { to_fun := \u03bb f, \u27e8(Ran.adjunction A G.op).hom_equiv X.val Y.val f.val\u27e9,\n    inv_fun := \u03bb f, \u27e8((Ran.adjunction A G.op).hom_equiv X.val Y.val).symm f.val\u27e9,\n    left_inv := \u03bb f, by { ext1, dsimp, rw [equiv.symm_apply_apply] },\n    right_inv := \u03bb f, by { ext1, dsimp, rw [equiv.apply_symm_apply] } },\n  unit := { app := \u03bb X, \u27e8(Ran.adjunction A G.op).unit.app X.val\u27e9,\n    naturality' := \u03bb _ _ f, Sheaf.hom.ext _ _ $ (Ran.adjunction A G.op).unit.naturality f.val },\n  counit := { app := \u03bb X, \u27e8(Ran.adjunction A G.op).counit.app X.val\u27e9,\n    naturality' := \u03bb _ _ f, Sheaf.hom.ext _ _ $ (Ran.adjunction A G.op).counit.naturality f.val },\n  hom_equiv_unit' := \u03bb X Y f, by { ext1, apply (Ran.adjunction A G.op).hom_equiv_unit },\n  hom_equiv_counit' := \u03bb 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 : \u211d) : (\u2200 \u03b5 > 0, |x - y| \u2264 \u03b5) \u2192 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  \u27e80, Nat.pos_pow_of_pos _ <| by decide\u27e9\n\ninstance : Inhabited (BitVec w) := \u27e8BitVec.zero w\u27e9\n\nopaque BitVec.xor {w : Nat} : BitVec w \u2192 BitVec w \u2192 BitVec w\n\ndef polyAdd {w : Nat} : BitVec w \u2192 BitVec w \u2192 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 \u2260 0 \u2192 x/x = 1\n\ntheorem ex (x : Nat) (h : x \u2260 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 \u2190 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 \u27f6 C`,\n* a family of functions between 1-morphisms `F.map : (a \u27f6 b) \u2192 (F.obj a \u27f6 F.obj b)`,\n* a family of functions between 2-morphisms `F.map\u2082 : (f \u27f6 g) \u2192 (F.map f \u27f6 F.map g)`,\n* a family of 2-morphisms `F.mapId a : F.map (\ud835\udfd9 a) \u27f6 \ud835\udfd9 (F.obj a)`,\n* a family of 2-morphisms `F.mapComp f g : F.map (f \u226b g) \u27f6 F.map f \u226b 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\u2082_whiskerLeft` and\n  `map\u2082_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 := \u03bb a => (G.mapFunctor _ _).mapIso (F.mapId a) \u226a\u226b G.mapId (F.obj a),\n  mapCompIso := \u03bb f g =>\n    (G.mapFunctor _ _).mapIso (F.mapComp f g) \u226a\u226b 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\u2081 w\u2082 w\u2083 v\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nsection\n\nvariable {B : Type u\u2081} [Quiver.{v\u2081 + 1} B] [\u2200 a b : B, Quiver.{w\u2081 + 1} (a \u27f6 b)]\n\nvariable {C : Type u\u2082} [Quiver.{v\u2082 + 1} C] [\u2200 a b : C, Quiver.{w\u2082 + 1} (a \u27f6 b)]\n\nvariable {D : Type u\u2083} [Quiver.{v\u2083 + 1} D] [\u2200 a b : D, Quiver.{w\u2083 + 1} (a \u27f6 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\u2081) [Quiver.{v\u2081 + 1} B] [\u2200 a b : B, Quiver.{w\u2081 + 1} (a \u27f6 b)]\n  (C : Type u\u2082) [Quiver.{v\u2082 + 1} C] [\u2200 a b : C, Quiver.{w\u2082 + 1} (a \u27f6 b)] extends\n  Prefunctor B C where\n  map\u2082 {a b : B} {f g : a \u27f6 b} : (f \u27f6 g) \u2192 (map f \u27f6 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\u2082\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  \u27e8toPrefunctor\u27e9\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\u2081) [Quiver.{v\u2081 + 1} B] [\u2200 a b : B, Quiver.{w\u2081 + 1} (a \u27f6 b)] : PrelaxFunctor B B :=\n  { Prefunctor.id B with map\u2082 := fun \u03b7 => \u03b7 }\n#align category_theory.prelax_functor.id CategoryTheory.PrelaxFunctor.id\n\ninstance : Inhabited (PrelaxFunctor B B) :=\n  \u27e8PrelaxFunctor.id B\u27e9\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 \u2191G with map\u2082 := fun \u03b7 => by exact G.map\u2082 (F.map\u2082 \u03b7) }\n#align category_theory.prelax_functor.comp CategoryTheory.PrelaxFunctor.comp\n\nend PrelaxFunctor\n\nend\n\nsection\n\nvariable {B : Type u\u2081} [Bicategory.{w\u2081, v\u2081} B] {C : Type u\u2082} [Bicategory.{w\u2082, v\u2082} C]\n\nvariable {D : Type u\u2083} [Bicategory.{w\u2083, v\u2083} 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\u2082AssociatorAux (obj : B \u2192 C) (map : \u2200 {X Y : B}, (X \u27f6 Y) \u2192 (obj X \u27f6 obj Y))\n--    (map\u2082 : \u2200 {a b : B} {f g : a \u27f6 b}, (f \u27f6 g) \u2192 (map f \u27f6 map g))\n--    (map_comp : \u2200 {a b c : B} (f : a \u27f6 b) (g : b \u27f6 c), map (f \u226b g) \u27f6 map f \u226b map g) {a b c d : B}\n--    (f : a \u27f6 b) (g : b \u27f6 c) (h : c \u27f6 d) : Prop := ...\n\n#noalign category_theory.oplax_functor.map\u2082_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\u2082`.\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 (\ud835\udfd9 a) \u27f6 \ud835\udfd9 (F.obj a)` and `F.map (f \u226b g) \u27f6 F.map f \u226b F.map g`.\n\n`F.map\u2082` 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\u2081) [Bicategory.{w\u2081, v\u2081} B] (C : Type u\u2082)\n  [Bicategory.{w\u2082, v\u2082} C] extends PrelaxFunctor B C where\n  mapId (a : B) : map (\ud835\udfd9 a) \u27f6 \ud835\udfd9 (obj a)\n  mapComp {a b c : B} (f : a \u27f6 b) (g : b \u27f6 c) : map (f \u226b g) \u27f6 map f \u226b map g\n  mapComp_naturality_left :\n    \u2200 {a b c : B} {f f' : a \u27f6 b} (\u03b7 : f \u27f6 f') (g : b \u27f6 c),\n      map\u2082 (\u03b7 \u25b7 g) \u226b mapComp f' g = mapComp f g \u226b map\u2082 \u03b7 \u25b7 map g := by\n    aesop_cat\n  mapComp_naturality_right :\n    \u2200 {a b c : B} (f : a \u27f6 b) {g g' : b \u27f6 c} (\u03b7 : g \u27f6 g'),\n      map\u2082 (f \u25c1 \u03b7) \u226b mapComp f g' = mapComp f g \u226b map f \u25c1 map\u2082 \u03b7 := by\n    aesop_cat\n  map\u2082_id : \u2200 {a b : B} (f : a \u27f6 b), map\u2082 (\ud835\udfd9 f) = \ud835\udfd9 (map f) := by aesop\n  map\u2082_comp :\n    \u2200 {a b : B} {f g h : a \u27f6 b} (\u03b7 : f \u27f6 g) (\u03b8 : g \u27f6 h), map\u2082 (\u03b7 \u226b \u03b8) = map\u2082 \u03b7 \u226b map\u2082 \u03b8 := by\n    aesop_cat\n  -- porting note: `map\u2082_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\u2082_associator :\n    \u2200 {a b c d : B} (f : a \u27f6 b) (g : b \u27f6 c) (h : c \u27f6 d),\n      map\u2082 (\u03b1_ f g h).hom \u226b mapComp f (g \u226b h) \u226b map f \u25c1 mapComp g h =\n    mapComp (f \u226b g) h \u226b mapComp f g \u25b7 map h \u226b (\u03b1_ (map f) (map g) (map h)).hom := by\n    aesop_cat\n  map\u2082_leftUnitor :\n    \u2200 {a b : B} (f : a \u27f6 b),\n      map\u2082 (\u03bb_ f).hom = mapComp (\ud835\udfd9 a) f \u226b mapId a \u25b7 map f \u226b (\u03bb_ (map f)).hom := by\n    aesop_cat\n  map\u2082_rightUnitor :\n    \u2200 {a b : B} (f : a \u27f6 b),\n      map\u2082 (\u03c1_ f).hom = mapComp f (\ud835\udfd9 b) \u226b map f \u25c1 mapId b \u226b (\u03c1_ (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\u2082_id' CategoryTheory.OplaxFunctor.map\u2082_id\n#align category_theory.oplax_functor.map\u2082_comp' CategoryTheory.OplaxFunctor.map\u2082_comp\n#align category_theory.oplax_functor.map\u2082_associator' CategoryTheory.OplaxFunctor.map\u2082_associator\n#align category_theory.oplax_functor.map\u2082_left_unitor CategoryTheory.OplaxFunctor.map\u2082_leftUnitor\n#align category_theory.oplax_functor.map\u2082_left_unitor' CategoryTheory.OplaxFunctor.map\u2082_leftUnitor\n#align category_theory.oplax_functor.map\u2082_right_unitor CategoryTheory.OplaxFunctor.map\u2082_rightUnitor\n#align category_theory.oplax_functor.map\u2082_right_unitor' CategoryTheory.OplaxFunctor.map\u2082_rightUnitor\n\ninitialize_simps_projections OplaxFunctor (+toPrelaxFunctor, -obj, -map, -map\u2082)\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\u2082_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\u2082_associator\n\n-- the simpNF linter complains that `map\u2082_leftUnitor_assoc` etc can be\n-- proved with `simp` so I move them here\nattribute [reassoc] map\u2082_leftUnitor map\u2082_comp map\u2082_rightUnitor\nattribute [simp] map\u2082_leftUnitor map\u2082_comp map\u2082_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\u2082_id\n  CategoryTheory.OplaxFunctor.map\u2082_comp\n  CategoryTheory.OplaxFunctor.map\u2082_associator\n  CategoryTheory.OplaxFunctor.map\u2082_leftUnitor\n  CategoryTheory.OplaxFunctor.map\u2082_rightUnitor\n\ninstance hasCoeToPrelax : Coe (OplaxFunctor B C) (PrelaxFunctor B C) :=\n  \u27e8toPrelaxFunctor\u27e9\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\u2082` relating\n-- `PrelaxFunctor.map\u2082` to nonexistent `OplaxFunctor.map\u2082`\n#noalign category_theory.oplax_functor.to_prelax_functor_map\u2082\n\n/-- Function between 1-morphisms as a functor. -/\n@[simps]\ndef mapFunctor (a b : B) : (a \u27f6 b) \u2964 (F.obj a \u27f6 F.obj b)\n    where\n  obj f := F.map f\n  map \u03b7 := F.map\u2082 \u03b7\n#align category_theory.oplax_functor.map_functor CategoryTheory.OplaxFunctor.mapFunctor\n\n/-- The identity oplax functor. -/\n@[simps]\ndef id (B : Type u\u2081) [Bicategory.{w\u2081, v\u2081} B] : OplaxFunctor B B :=\n  { PrelaxFunctor.id B with\n    mapId := fun a => \ud835\udfd9 (\ud835\udfd9 a)\n    mapComp := fun f g => \ud835\udfd9 (f \u226b g)\n  }\n#align category_theory.oplax_functor.id CategoryTheory.OplaxFunctor.id\n\ninstance : Inhabited (OplaxFunctor B B) :=\n  \u27e8id B\u27e9\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) \u226b G.mapId (F.obj a)\n    mapComp := fun f g => by\n      exact (G.mapFunctor _ _).map (F.mapComp f g) \u226b G.mapComp (F.map f) (F.map g)\n    mapComp_naturality_left := fun \u03b7 g =>\n      by\n      dsimp\n      rw [\u2190 map\u2082_comp_assoc, mapComp_naturality_left, map\u2082_comp_assoc, mapComp_naturality_left,\n        assoc]\n    mapComp_naturality_right := fun \u03b7 =>\n      by\n      dsimp\n      intros\n      rw [\u2190 map\u2082_comp_assoc, mapComp_naturality_right, map\u2082_comp_assoc, mapComp_naturality_right,\n        assoc]\n    map\u2082_associator := fun f g h => by\n      dsimp\n      -- porting note: if you use the `map\u2082_associator_aux` hack in the definition of\n      -- `map\u2082_associator` then the `simp only` call below does not seem to apply `map\u2082_associator`\n      simp only [map\u2082_associator, \u2190 map\u2082_comp_assoc, \u2190 mapComp_naturality_right_assoc,\n        whiskerLeft_comp, assoc]\n      simp only [map\u2082_associator, map\u2082_comp, mapComp_naturality_left_assoc, comp_whiskerRight,\n        assoc]\n    map\u2082_leftUnitor := fun f => by\n      dsimp\n      simp only [map\u2082_leftUnitor, map\u2082_comp, mapComp_naturality_left_assoc, comp_whiskerRight,\n        assoc]\n    map\u2082_rightUnitor := fun f => by\n      dsimp\n      simp only [map\u2082_rightUnitor, map\u2082_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 (\ud835\udfd9 a) \u2245 \ud835\udfd9 (F.obj a)\n  mapCompIso {a b c : B} (f : a \u27f6 b) (g : b \u27f6 c) : F.map (f \u226b g) \u2245 F.map f \u226b F.map g\n  mapIdIso_hom : \u2200 {a : B}, (mapIdIso a).hom = F.mapId a := by aesop_cat\n  mapCompIso_hom :\n    \u2200 {a b c : B} (f : a \u27f6 b) (g : b \u27f6 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\u2082AssociatorAux (obj : B \u2192 C) (map : \u2200 {X Y : B}, (X \u27f6 Y) \u2192 (obj X \u27f6 obj Y))\n--     (map\u2082 : \u2200 {a b : B} {f g : a \u27f6 b}, (f \u27f6 g) \u2192 (map f \u27f6 map g))\n--    (map_comp : \u2200 {a b c : B} (f : a \u27f6 b) (g : b \u27f6 c), map (f \u226b g) \u2245 map f \u226b map g) {a b c d : B}\n--     (f : a \u27f6 b) (g : b \u27f6 c) (h : c \u27f6 d) : Prop :=\n--   map\u2082 (\u03b1_ f g h).hom =\n--     (map_comp (f \u226b g) h).hom \u226b\n--       (map_comp f g).hom \u25b7 map h \u226b\n--        (\u03b1_ (map f) (map g) (map h)).hom \u226b map f \u25c1 (map_comp g h).inv \u226b (map_comp f (g \u226b h)).inv\n#noalign category_theory.pseudofunctor.map\u2082_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\u2082`.\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 (\ud835\udfd9 a) \u2245 \ud835\udfd9 (F.obj a)` and `F.map (f \u226b g) \u2245 F.map f \u226b F.map g`.\n\n`F.map\u2082` 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\u2081) [Bicategory.{w\u2081, v\u2081} B] (C : Type u\u2082)\n  [Bicategory.{w\u2082, v\u2082} C] extends PrelaxFunctor B C where\n  mapId (a : B) : map (\ud835\udfd9 a) \u2245 \ud835\udfd9 (obj a)\n  mapComp {a b c : B} (f : a \u27f6 b) (g : b \u27f6 c) : map (f \u226b g) \u2245 map f \u226b map g\n  map\u2082_id : \u2200 {a b : B} (f : a \u27f6 b), map\u2082 (\ud835\udfd9 f) = \ud835\udfd9 (map f) := by aesop_cat\n  map\u2082_comp :\n    \u2200 {a b : B} {f g h : a \u27f6 b} (\u03b7 : f \u27f6 g) (\u03b8 : g \u27f6 h), map\u2082 (\u03b7 \u226b \u03b8) = map\u2082 \u03b7 \u226b map\u2082 \u03b8 := by\n    aesop_cat\n  map\u2082_whisker_left :\n    \u2200 {a b c : B} (f : a \u27f6 b) {g h : b \u27f6 c} (\u03b7 : g \u27f6 h),\n      map\u2082 (f \u25c1 \u03b7) = (mapComp f g).hom \u226b map f \u25c1 map\u2082 \u03b7 \u226b (mapComp f h).inv := by\n    aesop_cat\n  map\u2082_whisker_right :\n    \u2200 {a b c : B} {f g : a \u27f6 b} (\u03b7 : f \u27f6 g) (h : b \u27f6 c),\n      map\u2082 (\u03b7 \u25b7 h) = (mapComp f h).hom \u226b map\u2082 \u03b7 \u25b7 map h \u226b (mapComp g h).inv := by\n    aesop_cat\n  map\u2082_associator :\n    \u2200 {a b c d : B} (f : a \u27f6 b) (g : b \u27f6 c) (h : c \u27f6 d),\n      map\u2082 (\u03b1_ f g h).hom = (mapComp (f \u226b g) h).hom \u226b (mapComp f g).hom \u25b7 map h \u226b\n      (\u03b1_ (map f) (map g) (map h)).hom \u226b map f \u25c1 (mapComp g h).inv \u226b\n      (mapComp f (g \u226b h)).inv := by\n    aesop_cat\n  map\u2082_left_unitor :\n    \u2200 {a b : B} (f : a \u27f6 b),\n      map\u2082 (\u03bb_ f).hom = (mapComp (\ud835\udfd9 a) f).hom \u226b (mapId a).hom \u25b7 map f \u226b (\u03bb_ (map f)).hom := by\n    aesop_cat\n  map\u2082_right_unitor :\n    \u2200 {a b : B} (f : a \u27f6 b),\n      map\u2082 (\u03c1_ f).hom = (mapComp f (\ud835\udfd9 b)).hom \u226b map f \u25c1 (mapId b).hom \u226b (\u03c1_ (map f)).hom := by\n    aesop_cat\n#align category_theory.pseudofunctor CategoryTheory.Pseudofunctor\n\ninitialize_simps_projections Pseudofunctor (+toPrelaxFunctor, -obj, -map, -map\u2082)\n\nnamespace Pseudofunctor\n\n-- porting note: was `[reassoc.1]` for some reason?\nattribute [reassoc]\n  map\u2082_comp map\u2082_whisker_left map\u2082_whisker_right map\u2082_associator map\u2082_left_unitor map\u2082_right_unitor\n\nattribute [simp]\n  map\u2082_id map\u2082_comp map\u2082_whisker_left map\u2082_whisker_right map\u2082_associator map\u2082_left_unitor\n  map\u2082_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\u2082_id\n  CategoryTheory.Pseudofunctor.map\u2082_comp\n  CategoryTheory.Pseudofunctor.map\u2082_whisker_left\n  CategoryTheory.Pseudofunctor.map\u2082_whisker_right\n  CategoryTheory.Pseudofunctor.map\u2082_associator\n  CategoryTheory.Pseudofunctor.map\u2082_left_unitor\n  CategoryTheory.Pseudofunctor.map\u2082_right_unitor\n\ninstance hasCoeToPrelaxFunctor : Coe (Pseudofunctor B C) (PrelaxFunctor B C) :=\n  \u27e8toPrelaxFunctor\u27e9\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\u2082` relating\n-- `PrelaxFunctor.map\u2082` to nonexistent `Pseudofunctor.map\u2082`\n#noalign category_theory.pseudofunctor.to_prelax_functor_map\u2082\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  \u27e8toOplax\u27e9\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\u2082 related `OplaxFunctor.map\u2082` to `Pseudofunctor.map\u2082` but neither\n-- of these exist\n#noalign category_theory.pseudofunctor.to_oplax_map\u2082\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 \u27f6 b) (g : b \u27f6 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 \u27f6 b) \u2964 (F.obj a \u27f6 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\u2081) [Bicategory.{w\u2081, v\u2081} B] : Pseudofunctor B B :=\n  { PrelaxFunctor.id B with\n    mapId := fun a => Iso.refl (\ud835\udfd9 a)\n    mapComp := fun f g => Iso.refl (f \u226b g) }\n#align category_theory.pseudofunctor.id CategoryTheory.Pseudofunctor.id\n\ninstance : Inhabited (Pseudofunctor B B) :=\n  \u27e8id B\u27e9\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) \u226a\u226b G.mapId (F.obj a)\n    mapComp := fun f g =>\n      (G.mapFunctor _ _).mapIso (F.mapComp f g) \u226a\u226b 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\u2082_whisker_left := fun f g h \u03b7 => by\n      dsimp\n      rw [F'.mapCompIso_hom f g, \u2190 F.mapComp_naturality_right_assoc, \u2190 F'.mapCompIso_hom f h,\n        hom_inv_id, comp_id]\n    map\u2082_whisker_right := fun \u03b7 h => by\n      dsimp\n      rw [F'.mapCompIso_hom _ h, \u2190 F.mapComp_naturality_left_assoc, \u2190 F'.mapCompIso_hom _ h,\n        hom_inv_id, comp_id]\n    map\u2082_associator := fun f g h => by\n      dsimp\n      rw [F'.mapCompIso_hom (f \u226b g) h, F'.mapCompIso_hom f g, \u2190 F.map\u2082_associator_assoc, \u2190\n        F'.mapCompIso_hom f (g \u226b h), \u2190 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) [\u2200 a, IsIso (F.mapId a)]\n    [\u2200 {a b c} (f : a \u27f6 b) (g : b \u27f6 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\u2082_whisker_left := fun f g h \u03b7 => by\n      dsimp\n      rw [\u2190 assoc, IsIso.eq_comp_inv, F.mapComp_naturality_right]\n    map\u2082_whisker_right := fun \u03b7 h => by\n      dsimp\n      rw [\u2190 assoc, IsIso.eq_comp_inv, F.mapComp_naturality_left]\n    map\u2082_associator := fun f g h => by\n      dsimp\n      simp only [\u2190 assoc]\n      rw [IsIso.eq_comp_inv, \u2190 inv_whiskerLeft, IsIso.eq_comp_inv]\n      simp only [assoc, F.map\u2082_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\u00eda In\u00e9s de Frutos-Fern\u00e1ndez. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Mar\u00eda In\u00e9s de Frutos-Fern\u00e1ndez\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 \u2208 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 \u2208 R` is less than or equal to `multiplicative.of_add (-n)` if and only if `v\u207f` divides the\n  ideal `(r)`.\n- `is_dedekind_domain.height_one_spectrum.int_valuation_exists_uniformizer` : There exists `\u03c0 \u2208 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 \u2208 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 `\u03c0 \u2208 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\u00f6lich, *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 \u2208 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) : \u2124\u2098\u2080 :=\nif r = 0 then 0 else multiplicative.of_add\n  (-(associates.mk v.as_ideal).count (associates.mk (ideal.span {r} : ideal R)).factors : \u2124)\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 \u2260 0) : v.int_valuation_def r = (multiplicative.of_add\n  (-(associates.mk v.as_ideal).count (associates.mk (ideal.span {r} : ideal R)).factors : \u2124)) :=\nif_neg hr\n\n/-- Nonzero elements have nonzero adic valuation. -/\nlemma int_valuation_ne_zero (x : R) (hx : x \u2260 0) : v.int_valuation_def x \u2260 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 \u2260 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 \u2264 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, \u2190 with_zero.coe_one, \u2190 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 \u2208 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 \u2194 v.as_ideal \u2223 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 [\u2190 with_zero.coe_one, \u2190 of_add_zero, with_zero.coe_lt_coe, of_add_lt, neg_lt_zero,\n      \u2190 int.coe_nat_zero, int.coe_nat_lt, zero_lt_iff],\n    have h : (ideal.span {r} : ideal R) \u2260 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 \u2208 R` is less than `multiplicative.of_add (-n)` if and only if\n`v\u207f` divides the ideal `(r)`. -/\nlemma int_valuation_le_pow_iff_dvd (r : R) (n : \u2115) :\n  v.int_valuation_def r \u2264 multiplicative.of_add (-(n : \u2124)) \u2194 v.as_ideal^n \u2223 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      \u2190 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) \u2260 0), ideal.span_singleton_one,\n  \u2190 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), \u2190 with_zero.coe_mul, with_zero.coe_inj,\n        \u2190 of_add_add, \u2190 ideal.span_singleton_mul_span_singleton, \u2190 associates.mk_mul_mk, \u2190 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 : \u2115} :  multiplicative.of_add(-c : \u2124) \u2264\n  max (multiplicative.of_add(-a : \u2124)) (multiplicative.of_add(-b : \u2124)) \u2194 min a b \u2264 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, \u2190 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) \u2264\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 \u2208 v.as_ideal ^ (nmin),\n      { rw [\u2190 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 \u2208 v.as_ideal ^ nmin,\n      { rw [\u2190 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 \u2264 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 \u2124\u2098\u2080 :=\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 `\u03c0 \u2208 R` with `v`-adic valuation `multiplicative.of_add (-1)`. -/\nlemma int_valuation_exists_uniformizer :\n  \u2203 (\u03c0 : R), v.int_valuation_def \u03c0 = multiplicative.of_add (-1 : \u2124) :=\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 \u2190 ideal.dvd_not_unit_iff_lt,\n    exact \u27e8v.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\u27e9 } ,\n  obtain \u27e8\u03c0, mem, nmem\u27e9 := set_like.exists_of_lt hlt,\n  have h\u03c0 : associates.mk (ideal.span {\u03c0}) \u2260 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 \u03c0,\n  rw [int_valuation_def, if_neg (associates.mk_ne_zero'.mp h\u03c0), with_zero.coe_inj],\n  apply congr_arg,\n  rw [neg_inj, \u2190 int.coe_nat_one, int.coe_nat_inj'],\n  rw [\u2190 ideal.dvd_span_singleton, \u2190 associates.mk_le_mk_iff_dvd_iff] at mem nmem,\n  rw [\u2190 pow_one (associates.mk v.as_ideal), associates.prime_pow_dvd_iff_le h\u03c0 hv] at mem,\n  rw [associates.mk_pow, associates.prime_pow_dvd_iff_le h\u03c0 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 \u2208 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 \u2124\u2098\u2080 :=\nv.int_valuation.extend_to_localization (\u03bb r hr, set.mem_compl $ v.int_valuation_ne_zero' \u27e8r, hr\u27e9) K\n\nlemma valuation_def (x : K) : v.valuation x = v.int_valuation.extend_to_localization\n  (\u03bb r hr, set.mem_compl (v.int_valuation_ne_zero' \u27e8r, hr\u27e9)) K x :=\nrfl\n\n/-- The `v`-adic valuation of `r/s \u2208 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) \u2264 1 :=\nby { rw valuation_of_algebra_map, exact v.int_valuation_le_one r }\n\n/-- The `v`-adic valuation of `r \u2208 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 \u2194 v.as_ideal \u2223 ideal.span {r} :=\nby { rw valuation_of_algebra_map, exact v.int_valuation_lt_one_iff_dvd r }\n\nvariable (K)\n/-- There exists `\u03c0 \u2208 K` with `v`-adic valuation `multiplicative.of_add (-1)`. -/\nlemma valuation_exists_uniformizer :\n  \u2203 (\u03c0 : K), v.valuation \u03c0 = multiplicative.of_add (-1 : \u2124) :=\nbegin\n  obtain \u27e8r, hr\u27e9 := 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)) \u2260 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 \u2124\u2098\u2080 := 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) := \u27e80\u27e9\n\ninstance valued_adic_completion : valued (v.adic_completion K) \u2124\u2098\u2080 :=\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) := \u27e80\u27e9\n\nvariables (R K)\n\nlemma mem_adic_completion_integers {x : v.adic_completion K} :\n  x \u2208 v.adic_completion_integers K \u2194 (valued.v x : \u2124\u2098\u2080) \u2264 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  (\u2191(r \u2022 x) : v.adic_completion K) = r \u2022 (\u2191x : 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  \u21d1(algebra_map R $ v.adic_completion K) = coe \u2218 algebra_map R K :=\nrfl\n\nlemma algebra_map_adic_completion :\n  \u21d1(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      := \u03bb r x, \u27e8r \u2022 (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\u27e9,\n  to_fun    := \u03bb r, \u27e8coe $ algebra_map R K r, by simpa only [mem_adic_completion_integers,\n    valued.valued_completion_apply] using v.valuation_le_one _\u27e9,\n  map_one'  := by simp only [map_one]; refl,\n  map_mul'  := \u03bb 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'  := \u03bb 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' := \u03bb r x, by rw mul_comm,\n  smul_def' := \u03bb 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  (\u2191(r \u2022 x) : v.adic_completion K) = r \u2022 (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 := \u03bb c x hcx,\n  begin\n    rw [algebra.smul_def, mul_eq_zero] at hcx,\n    refine hcx.imp_left (\u03bb hc, _),\n    letI : uniform_space K := v.adic_valued.to_uniform_space,\n    rw \u2190 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 := \u03bb 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\u2070 = R \\ {0}` (i.e. the field of fractions).\n * `fractional_ideal R\u2070 K` is the type of fractional ideals in the field of fractions\n * `has_div (fractional_ideal R\u2070 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 \u2286 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 `(+) := (\u2294)` and `\u22a5 := 0`,\nin order to re-use their respective proof terms.\nWe can still use `simp` to show `\u2191I + \u2191J = \u2191(I + J)` and `\u2191\u22a5 = \u21910`.\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\u2070`,\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 \u2286 R` for some `a \u2260 0`. -/\ndef is_fractional (I : submodule R P) :=\n\u2203 a \u2208 S, \u2200 b \u2208 I, is_integer R (a \u2022 b)\n\nvariables (S P)\n\n/-- The fractional ideals of a domain `R` are ideals of `R` divided by some `a \u2208 R`.\n\n  More precisely, let `P` be a localization of `R` at some submonoid `S`,\n  then a fractional ideal `I \u2286 P` is an `R`-submodule of `P`,\n  such that there is a nonzero `a : R` with `a I \u2286 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 `\u2203 a, a I \u2286 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 \u2192 submodule R P`\n(which we use to define `coe : ideal R \u2192 fractional_ideal S P`,\nreferred to as `coe_ideal` in theorem names).\n-/\ninstance : has_coe (fractional_ideal S P) (submodule R P) := \u27e8\u03bb I, I.val\u27e9\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 := \u03bb I, \u2191(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 \u2208 (I : submodule R P) \u2194 x \u2208 I :=\niff.rfl\n\n@[ext] lemma ext {I J : fractional_ideal S P} : (\u2200 x, x \u2208 I \u2194 x \u2208 J) \u2192 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 = \u2191p) : fractional_ideal S P :=\n\u27e8submodule.copy p s hs, by { convert p.is_fractional, ext, simp only [hs], refl }\u27e9\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 \u2192 submodule R P) :=\nsubtype.coe_injective\n\nlemma is_fractional_of_le_one (I : submodule R P) (h : I \u2264 1) :\n  is_fractional S I :=\nbegin\n  use [1, S.one_mem],\n  intros b hb,\n  rw one_smul,\n  obtain \u27e8b', b'_mem, rfl\u27e9 := 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 \u2264 J) : is_fractional S I :=\nbegin\n  obtain \u27e8a, a_mem, ha\u27e9 := 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 \u2192 submodule R P`,\nwhich is not to be confused with the `coe : fractional_ideal S P \u2192 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\u27e8\u03bb I, \u27e8coe_submodule P I, is_fractional_of_le_one _\n  (by simpa using coe_submodule_mono P (le_top : I \u2264 \u22a4))\u27e9\u27e9\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 \u2208 (I : fractional_ideal S P) \u2194 \u2203 x', x' \u2208 I \u2227 algebra_map R P x' = x :=\nmem_coe_submodule _ _\n\nlemma mem_coe_ideal_of_mem {x : R} {I : ideal R} (hx : x \u2208 I) :\n  algebra_map R P x \u2208 (I : fractional_ideal S P) :=\n(mem_coe_ideal S).mpr \u27e8x, hx, rfl\u27e9\n\nlemma coe_ideal_le_coe_ideal' [is_localization S P] (h : S \u2264 non_zero_divisors R)\n  {I J : ideal R} : (I : fractional_ideal S P) \u2264 J \u2194 I \u2264 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\u2070 K) \u2264 J \u2194 I \u2264 J :=\nis_fraction_ring.coe_submodule_le_coe_submodule\n\ninstance : has_zero (fractional_ideal S P) := \u27e8(0 : ideal R)\u27e9\n\n@[simp] lemma mem_zero_iff {x : P} : x \u2208 (0 : fractional_ideal S P) \u2194 x = 0 :=\n\u27e8(\u03bb \u27e8x', x'_mem_zero, x'_eq_x\u27e9,\n   have x'_eq_zero : x' = 0 := x'_mem_zero,\n   by simp [x'_eq_x.symm, x'_eq_zero]),\n (\u03bb hx, \u27e80, rfl, by simp [hx]\u27e9)\u27e9\n\nvariables {S}\n\n@[simp, norm_cast] lemma coe_zero : \u2191(0 : fractional_ideal S P) = (\u22a5 : submodule R P) :=\nsubmodule.ext $ \u03bb _, mem_zero_iff S\n\n@[simp, norm_cast] lemma coe_to_fractional_ideal_bot : ((\u22a5 : 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 \u2264 non_zero_divisors R) :\n  (\u2203 x', x' \u2208 I \u2227 algebra_map R P x' = algebra_map R P x) \u2194 x \u2208 I :=\n\u27e8\u03bb \u27e8x', hx', eq\u27e9, is_localization.injective _ h eq \u25b8 hx', \u03bb h, \u27e8x, h, rfl\u27e9\u27e9\n\nvariables {P}\n\nlemma coe_to_fractional_ideal_injective (h : S \u2264 non_zero_divisors R) :\n  function.injective (coe : ideal R \u2192 fractional_ideal S P) :=\n\u03bb I J heq, have\n  \u2200 (x : R), algebra_map R P x \u2208 (I : fractional_ideal S P) \u2194\n             algebra_map R P x \u2208 (J : fractional_ideal S P) :=\n\u03bb x, heq \u25b8 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 \u2264 non_zero_divisors R) :\n  (I : fractional_ideal S P) = 0 \u2194 I = (\u22a5 : ideal R) :=\n\u27e8\u03bb h, coe_to_fractional_ideal_injective hS h,\n \u03bb h, by rw [h, coe_to_fractional_ideal_bot]\u27e9\n\nlemma coe_to_fractional_ideal_ne_zero {I : ideal R} (hS : S \u2264 non_zero_divisors R) :\n  (I : fractional_ideal S P) \u2260 0 \u2194 I \u2260 (\u22a5 : 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) = \u22a5 \u2194 I = 0 :=\n\u27e8\u03bb h, coe_to_submodule_injective (by simp [h]),\n \u03bb h, by simp [h]\u27e9\n\nlemma coe_to_submodule_ne_bot {I : fractional_ideal S P} :\n  \u2191I \u2260 (\u22a5 : submodule R P) \u2194 I \u2260 0 :=\nnot_iff_not.mpr coe_to_submodule_eq_bot\n\ninstance : inhabited (fractional_ideal S P) := \u27e80\u27e9\n\ninstance : has_one (fractional_ideal S P) :=\n\u27e8(\u22a4 : ideal R)\u27e9\n\nvariables (S)\n\n@[simp, norm_cast] lemma coe_ideal_top : ((\u22a4 : ideal R) : fractional_ideal S P) = 1 :=\nrfl\n\nlemma mem_one_iff {x : P} : x \u2208 (1 : fractional_ideal S P) \u2194 \u2203 x' : R, algebra_map R P x' = x :=\niff.intro (\u03bb \u27e8x', _, h\u27e9, \u27e8x', h\u27e9) (\u03bb \u27e8x', h\u27e9, \u27e8x', \u27e8\u27e9, h\u27e9)\n\nlemma coe_mem_one (x : R) : algebra_map R P x \u2208 (1 : fractional_ideal S P) :=\n(mem_one_iff S).mpr \u27e8x, rfl\u27e9\n\nlemma one_mem_one : (1 : P) \u2208 (1 : fractional_ideal S P) :=\n(mem_one_iff S).mpr \u27e81, ring_hom.map_one _\u27e9\n\nvariables {S}\n\n/-- `(1 : fractional_ideal S P)` is defined as the R-submodule `f(R) \u2264 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  \u2191(1 : fractional_ideal S P) = coe_submodule P (\u22a4 : ideal R) :=\nrfl\n\n@[simp, norm_cast] lemma coe_one :\n  (\u2191(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) \u2264 (J : submodule R P) \u2194 I \u2264 J :=\niff.rfl\n\nlemma zero_le (I : fractional_ideal S P) : 0 \u2264 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 : (\u22a5 : fractional_ideal S P) = 0 :=\nrfl\n\n@[simp] lemma le_zero_iff {I : fractional_ideal S P} : I \u2264 0 \u2194 I = 0 :=\nle_bot_iff\n\nlemma eq_zero_iff {I : fractional_ideal S P} : I = 0 \u2194 (\u2200 x \u2208 I, x = (0 : P)) :=\n\u27e8 (\u03bb h x hx, by simpa [h, mem_zero_iff] using hx),\n  (\u03bb h, le_bot_iff.mp (\u03bb x hx, (mem_zero_iff S).mpr (h x hx))) \u27e9\n\nlemma fractional_sup (I J : fractional_ideal S P) : is_fractional S (I \u2294 J : submodule R P) :=\nbegin\n  rcases I.is_fractional with \u27e8aI, haI, hI\u27e9,\n  rcases J.is_fractional with \u27e8aJ, haJ, hJ\u27e9,\n  use aI * aJ,\n  use S.mul_mem haI haJ,\n  intros b hb,\n  rcases mem_sup.mp hb with \u27e8bI, hbI, bJ, hbJ, rfl\u27e9,\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 \u2293 J : submodule R P) :=\nbegin\n  rcases I.is_fractional with \u27e8aI, haI, hI\u27e9,\n  use aI,\n  use haI,\n  intros b hb,\n  rcases mem_inf.mp hb with \u27e8hbI, hbJ\u27e9,\n  exact hI b hbI\nend\n\ninstance lattice : lattice (fractional_ideal S P) :=\n{ inf := \u03bb I J, \u27e8I \u2293 J, fractional_inf I J\u27e9,\n  sup := \u03bb I J, \u27e8I \u2294 J, fractional_sup I J\u27e9,\n  inf_le_left := \u03bb I J, show (I \u2293 J : submodule R P) \u2264 I, from inf_le_left,\n  inf_le_right := \u03bb I J, show (I \u2293 J : submodule R P) \u2264 J, from inf_le_right,\n  le_inf := \u03bb I J K hIJ hIK, show (I : submodule R P) \u2264 J \u2293 K, from le_inf hIJ hIK,\n  le_sup_left := \u03bb I J, show (I : submodule R P) \u2264 I \u2294 J, from le_sup_left,\n  le_sup_right := \u03bb I J, show (J : submodule R P) \u2264 I \u2294 J, from le_sup_right,\n  sup_le := \u03bb I J K hIK hJK, show (I \u2294 J : submodule R P) \u2264 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) := \u27e8(\u2294)\u27e9\n\n@[simp]\nlemma sup_eq_add (I J : fractional_ideal S P) : I \u2294 J = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_add (I J : fractional_ideal S P) : (\u2191(I + J) : submodule R P) = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_ideal_sup (I J : ideal R) : \u2191(I \u2294 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 \u27e8I, aI, haI, hI\u27e9,\n  rcases J with \u27e8J, aJ, haJ, hJ\u27e9,\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 \u27e8n', hn'\u27e9 := hJ n hn,\n    rw [mul_smul, mul_comm m, \u2190 smul_mul_assoc, \u2190 hn', \u2190 algebra.smul_def],\n    apply hI,\n    exact submodule.smul_mem _ _ hm },\n  { rw smul_zero,\n    exact \u27e80, ring_hom.map_zero _\u27e9 },\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\u27e8I * J, fractional_mul I J\u27e9\n\nlocal attribute [semireducible] mul\n\ninstance : has_mul (fractional_ideal S P) := \u27e8\u03bb I J, mul I J\u27e9\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) : (\u2191(I * J) : submodule R P) = I * J := rfl\n\n@[simp, norm_cast]\nlemma coe_ideal_mul (I J : ideal R) : (\u2191(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\u03bb J J' h, mul_le.mpr (\u03bb x hx y hy, mul_mem_mul hx (h hy))\n\nlemma mul_right_mono (I : fractional_ideal S P) : monotone (\u03bb J, J * I) :=\n\u03bb J J' h, mul_le.mpr (\u03bb 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 \u2208 I) (hj : j \u2208 J) :\n  i * j \u2208 I * J := submodule.mul_mem_mul hi hj\n\nlemma mul_le {I J K : fractional_ideal S P} :\n  I * J \u2264 K \u2194 (\u2200 (i \u2208 I) (j \u2208 J), i * j \u2208 K) :=\nsubmodule.mul_le\n\n@[elab_as_eliminator] protected theorem mul_induction_on\n  {I J : fractional_ideal S P}\n  {C : P \u2192 Prop} {r : P} (hr : r \u2208 I * J)\n  (hm : \u2200 (i \u2208 I) (j \u2208 J), C (i * j))\n  (h0 : C 0) (ha : \u2200 x y, C x \u2192 C y \u2192 C (x + y))\n  (hs : \u2200 (r : R) x, C x \u2192 C (r \u2022 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 := \u03bb I J K, sup_assoc,\n  add_comm := \u03bb I J, sup_comm,\n  add_zero := \u03bb I, sup_bot_eq,\n  zero_add := \u03bb I, bot_sup_eq,\n  mul_assoc := \u03bb I J K, coe_to_submodule_injective (submodule.mul_assoc _ _ _),\n  mul_comm := \u03bb I J, coe_to_submodule_injective (submodule.mul_comm _ _),\n  mul_one := \u03bb I, begin\n    ext,\n    split; intro h,\n    { apply mul_le.mpr _ h,\n      rintros x hx y \u27e8y', y'_mem_R, rfl\u27e9,\n      convert submodule.smul_mem _ y' hx,\n      rw [mul_comm, eq_comm],\n      exact algebra.smul_def y' x },\n    { have : x * 1 \u2208 (I * 1) := mul_mem_mul h (one_mem_one _),\n      rwa [mul_one] at this }\n  end,\n  one_mul := \u03bb I, begin\n    ext,\n    split; intro h,\n    { apply mul_le.mpr _ h,\n      rintros x \u27e8x', x'_mem_R, rfl\u27e9 y hy,\n      convert submodule.smul_mem _ x' hy,\n      rw eq_comm,\n      exact algebra.smul_def x' y },\n    { have : 1 * x \u2208 (1 * I) := mul_mem_mul (one_mem_one _) h,\n      rwa one_mul at this }\n  end,\n  mul_zero := \u03bb I, eq_zero_iff.mpr (\u03bb x hx, submodule.mul_induction_on hx\n    (\u03bb x hx y hy, by simp [(mem_zero_iff S).mp hy])\n    rfl\n    (\u03bb x y hx hy, by simp [hx, hy])\n    (\u03bb r x hx, by simp [hx])),\n  zero_mul := \u03bb I, eq_zero_iff.mpr (\u03bb x hx, submodule.mul_induction_on hx\n    (\u03bb x hx y hy, by simp [(mem_zero_iff S).mp hx])\n    rfl\n    (\u03bb x y hx hy, by simp [hx, hy])\n    (\u03bb r x hx, by simp [hx])),\n  left_distrib := \u03bb I J K, coe_to_submodule_injective (mul_add _ _ _),\n  right_distrib := \u03bb 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 \u2264 J) (J' : fractional_ideal S P) :\n  J' + I \u2264 J' + J :=\nsup_le_sup_left hIJ J'\n\nlemma mul_le_mul_left {I J : fractional_ideal S P} (hIJ : I \u2264 J) (J' : fractional_ideal S P) :\n  J' * I \u2264 J' * J :=\nmul_le.mpr (\u03bb k hk j hj, mul_mem_mul hk (hIJ hj))\n\nlemma le_self_mul_self {I : fractional_ideal S P} (hI: 1 \u2264 I) : I \u2264 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 \u2264 1) : I * I \u2264 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) \u2264 1 :=\n\u03bb x hx, let \u27e8y, _, hy\u27e9 := (fractional_ideal.mem_coe_ideal S).mp hx\n  in (fractional_ideal.mem_one_iff S).mpr \u27e8y, hy\u27e9\n\nlemma le_one_iff_exists_coe_ideal {J : fractional_ideal S P} :\n  J \u2264 (1 : fractional_ideal S P) \u2194 \u2203 (I : ideal R), \u2191I = J :=\nbegin\n  split,\n  { intro hJ,\n    refine \u27e8\u27e8{x : R | algebra_map R P x \u2208 J}, _, _, _\u27e9, _\u27e9,\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, \u2190 algebra.smul_def],\n      exact J.val.smul_mem c hx },\n    { ext x,\n      split,\n      { rintros \u27e8y, hy, eq_y\u27e9,\n        rwa \u2190 eq_y },\n      { intro hx,\n        obtain \u27e8y, eq_x\u27e9 := (fractional_ideal.mem_one_iff S).mp (hJ hx),\n        rw \u2190 eq_x at *,\n        exact \u27e8y, hx, rfl\u27e9 } } },\n  { rintro \u27e8I, hI\u27e9,\n    rw \u2190 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 \u2192 fractional_ideal S P` as a ring hom -/\n@[simps]\ndef coe_ideal_hom : ideal R \u2192+* 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 \u2192\u2090[R] P') (I : fractional_ideal S P) :\n  is_fractional S (submodule.map g.to_linear_map I) :=\nbegin\n  rcases I with \u27e8I, a, a_nonzero, hI\u27e9,\n  use [a, a_nonzero],\n  intros b hb,\n  obtain \u27e8b', b'_mem, hb'\u27e9 := submodule.mem_map.mp hb,\n  obtain \u27e8x, hx\u27e9 := hI b' b'_mem,\n  use x,\n  erw [\u2190g.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 \u2192\u2090[R] P') :\n  fractional_ideal S P \u2192 fractional_ideal S P' :=\n\u03bb I, \u27e8submodule.map g.to_linear_map I, fractional_map g I\u27e9\n\n@[simp, norm_cast] lemma coe_map (g : P \u2192\u2090[R] P') (I : fractional_ideal S P) :\n  \u2191(map g I) = submodule.map g.to_linear_map I := rfl\n\n@[simp] lemma mem_map {I : fractional_ideal S P} {g : P \u2192\u2090[R] P'}\n  {y : P'} : y \u2208 I.map g \u2194 \u2203 x, x \u2208 I \u2227 g x = y :=\nsubmodule.mem_map\n\nvariables (I J : fractional_ideal S P) (g : P \u2192\u2090[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' \u2192\u2090[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 \u27e8_, \u27e8y, hy, rfl\u27e9, rfl\u27e9,\n    exact \u27e8y, hy, (g.commutes y).symm\u27e9 },\n  { rintro \u27e8y, hy, rfl\u27e9,\n    exact \u27e8_, \u27e8y, hy, rfl\u27e9, g.commutes y\u27e9 },\nend\n\n@[simp] lemma map_one :\n  (1 : fractional_ideal S P).map g = 1 :=\nmap_coe_ideal g \u22a4\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 \u2243\u2090[R] P') :\n  (I.map (g : P \u2192\u2090[R] P')).map (g.symm : P' \u2192\u2090[R] P) = I :=\nby rw [\u2190map_comp, g.symm_comp, map_id]\n\n@[simp] lemma map_symm_map (I : fractional_ideal S P') (g : P \u2243\u2090[R] P') :\n  (I.map (g.symm : P' \u2192\u2090[R] P)).map (g : P \u2192\u2090[R] P') = I :=\nby rw [\u2190map_comp, g.comp_symm, map_id]\n\nlemma map_mem_map {f : P \u2192\u2090[R] P'} (h : function.injective f) {x : P} {I : fractional_ideal S P} :\n  f x \u2208 map f I \u2194 x \u2208 I :=\nmem_map.trans \u27e8\u03bb \u27e8x', hx', x'_eq\u27e9, h x'_eq \u25b8 hx', \u03bb h, \u27e8x, h, rfl\u27e9\u27e9\n\nlemma map_injective (f : P \u2192\u2090[R] P') (h : function.injective f) :\n  function.injective (map f : fractional_ideal S P \u2192 fractional_ideal S P') :=\n\u03bb I J hIJ, fractional_ideal.ext (\u03bb x, (fractional_ideal.map_mem_map h).symm.trans\n  (hIJ.symm \u25b8 fractional_ideal.map_mem_map h))\n\n/-- If `g` is an equivalence, `map g` is an isomorphism -/\ndef map_equiv (g : P \u2243\u2090[R] P') :\n  fractional_ideal S P \u2243+* fractional_ideal S P' :=\n{ to_fun := map g,\n  inv_fun := map g.symm,\n  map_add' := \u03bb I J, map_add I J _,\n  map_mul' := \u03bb I J, map_mul I J _,\n  left_inv := \u03bb I, by { rw [\u2190map_comp, alg_equiv.symm_comp, map_id] },\n  right_inv := \u03bb I, by { rw [\u2190map_comp, alg_equiv.comp_symm, map_id] } }\n\n@[simp] lemma coe_fun_map_equiv (g : P \u2243\u2090[R] P') :\n  (map_equiv g : fractional_ideal S P \u2192 fractional_ideal S P') = map g :=\nrfl\n\n@[simp] lemma map_equiv_apply (g : P \u2243\u2090[R] P') (I : fractional_ideal S P) :\n  map_equiv g I = map \u2191g I := rfl\n\n@[simp] lemma map_equiv_symm (g : P \u2243\u2090[R] P') :\n  ((map_equiv g).symm : fractional_ideal S P' \u2243+* _) = 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 (\u03bb x, by simp)\n\nlemma is_fractional_span_iff {s : set P} :\n  is_fractional S (span R s) \u2194 \u2203 a \u2208 S, \u2200 (b : P), b \u2208 s \u2192 is_integer R (a \u2022 b) :=\n\u27e8\u03bb \u27e8a, a_mem, h\u27e9, \u27e8a, a_mem, \u03bb b hb, h b (subset_span hb)\u27e9,\n \u03bb \u27e8a, a_mem, h\u27e9, \u27e8a, a_mem, \u03bb b hb, span_induction hb\n   h\n   (by { rw smul_zero, exact is_integer_zero })\n   (\u03bb x y hx hy, by { rw smul_add, exact is_integer_add hx hy })\n   (\u03bb s x hx, by { rw smul_comm, exact is_integer_smul hx })\u27e9\u27e9\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 \u27e8I, rfl\u27e9,\n  rcases exist_integer_multiples_of_finset S I with \u27e8\u27e8s, hs1\u27e9, hs\u27e9,\n  rw is_fractional_span_iff,\n  exact \u27e8s, hs1, hs\u27e9,\nend\n\nomit loc\n\nlemma mem_span_mul_finite_of_mem_mul {I J : fractional_ideal S P} {x : P} (hx : x \u2208 I * J) :\n  \u2203 (T T' : finset P), (T : set P) \u2286 I \u2227 (T' : set P) \u2286 J \u2227 x \u2208 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) \u2194 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) \u2208 (I * \u2191I\u207b\u00b9 : fractional_ideal S P),\n  { rw units.mul_inv, exact one_mem_one _ },\n  obtain \u27e8T, T', hT, hT', one_mem\u27e9 := mem_span_mul_finite_of_mem_mul this,\n  refine \u27e8T, submodule.span_eq_of_le _ hT _\u27e9,\n  rw [\u2190 one_mul \u2191I, \u2190 mul_one (span R \u2191T)],\n  conv_rhs { rw [\u2190 fractional_ideal.coe_one, \u2190 units.mul_inv I, fractional_ideal.coe_mul,\n                 mul_comm \u2191\u2191I, \u2190 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 \u27e8I, rfl\u27e9, 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 \u2190 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 \u2243+* fractional_ideal S P' :=\nmap_equiv\n  { commutes' := \u03bb 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 \u2208 canonical_equiv S P P' I \u2194\n    \u2203 y \u2208 I, is_localization.map P' (ring_hom.id R)\n      (\u03bb y (hy : y \u2208 S), show ring_hom.id R y \u2208 S, from hy) (y : P) = x :=\nbegin\n  rw [canonical_equiv, map_equiv_apply, mem_map],\n  exact \u27e8\u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9, \u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9\u27e9\nend\n\n@[simp] lemma canonical_equiv_symm :\n  (canonical_equiv S P P').symm = canonical_equiv S P' P :=\nring_equiv.ext $ \u03bb I, set_like.ext_iff.mpr $ \u03bb x,\nby { rw [mem_canonical_equiv_apply, canonical_equiv, map_equiv_symm, map_equiv,\n         ring_equiv.coe_mk, mem_map],\n    exact \u27e8\u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9, \u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9\u27e9 }\n\n@[simp] lemma canonical_equiv_flip (I) :\n  canonical_equiv S P P' (canonical_equiv S P' P I) = I :=\nby rw [\u2190canonical_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\u2070 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\u2070 K} (h : K \u2192\u2090[R] K')\n\n/-- Nonzero fractional ideals contain a nonzero integer. -/\nlemma exists_ne_zero_mem_is_integer [nontrivial R] (hI : I \u2260 0) :\n  \u2203 x \u2260 (0 : R), algebra_map R K x \u2208 I :=\nbegin\n  obtain \u27e8y, y_mem, y_not_mem\u27e9 := set_like.exists_of_lt\n    (by simpa only using bot_lt_iff_ne_bot.mpr hI),\n  have y_ne_zero : y \u2260 0 := by simpa using y_not_mem,\n  obtain \u27e8z, \u27e8x, hx\u27e9\u27e9 := exists_integer_multiple R\u2070 y,\n  refine \u27e8x, _, _\u27e9,\n  { rw [ne.def, \u2190 @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 \u2260 0) : I.map h \u2260 0 :=\nbegin\n  obtain \u27e8x, x_ne_zero, hx\u27e9 := 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 \u27e8algebra_map R K x, hx, h.commutes x\u27e9,\nend\n\n@[simp] lemma map_eq_zero_iff [nontrivial R] : I.map h = 0 \u2194 I = 0 :=\n\u27e8imp_of_not_imp_not _ _ (map_ne_zero _),\n \u03bb hI, hI.symm \u25b8 map_zero h\u27e9\n\nlemma coe_ideal_injective :\n  function.injective (coe : ideal R \u2192 fractional_ideal R\u2070 K) :=\ninjective_of_le_imp_le _ (\u03bb _ _, (coe_ideal_le_coe_ideal _).mp)\n\n@[simp]\nlemma coe_ideal_eq_zero_iff\n  {I : ideal R} : (I : fractional_ideal R\u2070 K) = 0 \u2194 I = \u22a5 :=\nby { rw \u2190 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\u2070 K) \u2260 0 \u2194 I \u2260 \u22a5 :=\nnot_iff_not.mpr coe_ideal_eq_zero_iff\n\nlemma coe_ideal_ne_zero\n  {I : ideal R} (hI : I \u2260 \u22a5) : (I : fractional_ideal R\u2070 K) \u2260 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\u2081 : Type*} [comm_ring R\u2081] {K : Type*} [field K]\nvariables [algebra R\u2081 K] [frac : is_fraction_ring R\u2081 K]\n\ninstance : nontrivial (fractional_ideal R\u2081\u2070 K) :=\n\u27e8\u27e80, 1, \u03bb h,\n  have this : (1 : K) \u2208 (0 : fractional_ideal R\u2081\u2070 K) :=\n    by { rw \u2190 (algebra_map R\u2081 K).map_one, simpa only [h] using coe_mem_one R\u2081\u2070 1 },\n  one_ne_zero ((mem_zero_iff _).mp this)\u27e9\u27e9\n\nlemma ne_zero_of_mul_eq_one (I J : fractional_ideal R\u2081\u2070 K) (h : I * J = 1) : I \u2260 0 :=\n\u03bb hI, @zero_ne_one (fractional_ideal R\u2081\u2070 K) _ _ (by { convert h, simp [hI], })\n\nvariables [is_domain R\u2081]\n\ninclude frac\n\nlemma fractional_div_of_nonzero {I J : fractional_ideal R\u2081\u2070 K} (h : J \u2260 0) :\n  is_fractional R\u2081\u2070 (I / J : submodule R\u2081 K) :=\nbegin\n  rcases I with \u27e8I, aI, haI, hI\u27e9,\n  rcases J with \u27e8J, aJ, haJ, hJ\u27e9,\n  obtain \u27e8y, mem_J, not_mem_zero\u27e9 := set_like.exists_of_lt\n    (by simpa only using bot_lt_iff_ne_bot.mpr h),\n  obtain \u27e8y', hy'\u27e9 := hJ y mem_J,\n  use (aI * y'),\n  split,\n  { apply (non_zero_divisors R\u2081).mul_mem haI (mem_non_zero_divisors_iff_ne_zero.mpr _),\n    intro y'_eq_zero,\n    have : algebra_map R\u2081 K aJ * y = 0,\n    { rw [\u2190 algebra.smul_def, \u2190hy', y'_eq_zero, ring_hom.map_zero] },\n    have y_zero := (mul_eq_zero.mp this).resolve_left\n      (mt ((algebra_map R\u2081 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\u2081\u2070).mpr y_zero) },\n  intros b hb,\n  convert hI _ (hb _ (submodule.smul_mem _ aJ mem_J)) using 1,\n  rw [\u2190 hy', mul_comm b, \u2190 algebra.smul_def, mul_smul]\nend\n\nnoncomputable instance fractional_ideal_has_div :\n  has_div (fractional_ideal R\u2081\u2070 K) :=\n\u27e8 \u03bb I J, if h : J = 0 then 0 else \u27e8I / J, fractional_div_of_nonzero h\u27e9 \u27e9\n\nvariables {I J : fractional_ideal R\u2081\u2070 K} [ J \u2260 0 ]\n\n@[simp] lemma div_zero {I : fractional_ideal R\u2081\u2070 K} :\n  I / 0 = 0 :=\ndif_pos rfl\n\nlemma div_nonzero {I J : fractional_ideal R\u2081\u2070 K} (h : J \u2260 0) :\n  (I / J) = \u27e8I / J, fractional_div_of_nonzero h\u27e9 :=\ndif_neg h\n\n@[simp] lemma coe_div {I J : fractional_ideal R\u2081\u2070 K} (hJ : J \u2260 0) :\n  (\u2191(I / J) : submodule R\u2081 K) = \u2191I / (\u2191J : submodule R\u2081 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\u2081\u2070 K} : I * (1 / I) \u2264 1 :=\nbegin\n  by_cases hI : I = 0,\n  { rw [hI, div_zero, mul_zero],\n    exact zero_le 1 },\n  { rw [\u2190 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\u2081\u2070 K} (hI : I \u2264 (1 : fractional_ideal R\u2081\u2070 K)) :\n  I \u2264 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 [\u2190 coe_le_coe, coe_mul, coe_div hI_nz, coe_one],\n    rw [\u2190 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\u2081\u2070 K} (hJ' : J' \u2260 0) :\n  I \u2264 J / J' \u2194 \u2200 (x \u2208 I) (y \u2208 J'), x * y \u2208 J :=\n\u27e8 \u03bb h x hx, (mem_div_iff_of_nonzero hJ').mp (h hx),\n  \u03bb h x hx, (mem_div_iff_of_nonzero hJ').mpr (h x hx) \u27e9\n\nlemma le_div_iff_mul_le {I J J' : fractional_ideal R\u2081\u2070 K} (hJ' : J' \u2260 0) :\n  I \u2264 J / J' \u2194 I * J' \u2264 J :=\nbegin\n  rw div_nonzero hJ',\n  convert submodule.le_div_iff_mul_le using 1,\n  rw [\u2190 coe_mul, coe_le_coe]\nend\n\n@[simp] lemma div_one {I : fractional_ideal R\u2081\u2070 K} : I / 1 = I :=\nbegin\n  rw [div_nonzero (@one_ne_zero (fractional_ideal R\u2081\u2070 K) _ _)],\n  ext,\n  split; intro h,\n  { simpa using mem_div_iff_forall_mul_mem.mp h 1\n      ((algebra_map R\u2081 K).map_one \u25b8 coe_mem_one R\u2081\u2070 1) },\n  { apply mem_div_iff_forall_mul_mem.mpr,\n    rintros y \u27e8y', _, rfl\u27e9,\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\u2081\u2070 K) (h : I * J = 1) :\n  J = 1 / I :=\nbegin\n  have hI : I \u2260 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 \u2190 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\u2081\u2070 K} :\n  I * (1 / I) = 1 \u2194 \u2203 J, I * J = 1 :=\n\u27e8\u03bb h, \u27e8(1 / I), h\u27e9, \u03bb \u27e8J, hJ\u27e9, by rwa [\u2190 eq_one_div_of_mul_eq_one I J hJ]\u27e9\n\nvariables {K' : Type*} [field K'] [algebra R\u2081 K'] [is_fraction_ring R\u2081 K']\n\n@[simp] lemma map_div (I J : fractional_ideal R\u2081\u2070 K) (h : K \u2243\u2090[R\u2081] K') :\n  (I / J).map (h : K \u2192\u2090[R\u2081] 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\u2081\u2070 K) (h : K \u2243\u2090[R\u2081] K') :\n  (1 / I).map (h : K \u2192\u2090[R\u2081] K') = 1 / I.map h :=\nby rw [map_div, map_one]\n\nend quotient\n\nsection field\n\nvariables {R\u2081 K L : Type*} [comm_ring R\u2081] [is_domain R\u2081] [field K] [field L]\nvariables [algebra R\u2081 K] [is_fraction_ring R\u2081 K] [algebra K L] [is_fraction_ring K L]\n\nlemma eq_zero_or_one (I : fractional_ideal K\u2070 L) : I = 0 \u2228 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 \u27e8n, d, rfl\u27e9 := is_localization.mk'_surjective K\u2070 x,\n    refine \u27e8n / d, _\u27e9,\n    rw [ring_hom.map_div, is_fraction_ring.mk'_eq_div] },\n  { rintro \u27e8x, rfl\u27e9,\n    obtain \u27e8y, y_ne, y_mem\u27e9 := fractional_ideal.exists_ne_zero_mem_is_integer hI,\n    rw [\u2190 div_mul_cancel x y_ne, ring_hom.map_mul, \u2190 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\u2081) (I : fractional_ideal R\u2081\u2070 K) : I = 0 \u2228 I = 1 :=\nbegin\n  letI : field R\u2081 := hF.to_field R\u2081,\n  -- TODO can this be less ugly?\n  exact @eq_zero_or_one R\u2081 K _ _ _ (by { unfreezingI {cases _inst_4}, convert _inst_9 }) I\nend\n\nend field\n\nsection principal_ideal_ring\n\nvariables {R\u2081 : Type*} [comm_ring R\u2081] {K : Type*} [field K]\nvariables [algebra R\u2081 K] [is_fraction_ring R\u2081 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 \u27e8a, ha\u27e9 := exists_integer_multiple S x in\nis_fractional_span_iff.mpr \u27e8a, a.2, \u03bb x' hx', (set.mem_singleton_iff.mp hx').symm \u25b8 ha\u27e9\n\nvariables (S)\n\n/-- `span_singleton x` is the fractional ideal generated by `x` if `0 \u2209 S` -/\n@[irreducible]\ndef span_singleton (x : P) : fractional_ideal S P :=\n\u27e8span R {x}, is_fractional_span_singleton x\u27e9\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 \u2208 span_singleton S y \u2194 \u2203 (z : R), z \u2022 y = x :=\nsubmodule.mem_span_singleton\n\nlemma mem_span_singleton_self (x : P) :\n  x \u2208 span_singleton S x :=\n(mem_span_singleton S).mpr \u27e81, one_smul _ _\u27e9\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 \u2191I).symm\n\nlemma is_principal_iff (I : fractional_ideal S P) :\n  is_principal (I : submodule R P) \u2194 \u2203 x, I = span_singleton S x :=\n\u27e8\u03bb h, \u27e8@generator _ _ _ _ _ \u2191I h, @eq_span_singleton_of_principal _ _ _ _ _ _ _ I h\u27e9,\n \u03bb \u27e8x, hx\u27e9, { principal := \u27e8x, trans (congr_arg _ hx) (coe_span_singleton _ x)\u27e9 } \u27e9\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 \u2194 y = 0 :=\n\u27e8\u03bb h, span_eq_bot.mp (by simpa using congr_arg subtype.val h : span R {y} = \u22a5) y (mem_singleton y),\n \u03bb h, by simp [h] \u27e9\n\nlemma span_singleton_ne_zero_iff {y : P} : span_singleton S y \u2260 0 \u2194 y \u2260 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  (\u2191(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 \u27e8y', hy', rfl\u27e9,\n    obtain \u27e8x', rfl\u27e9 := submodule.mem_span_singleton.mp hy',\n    use x',\n    rw [smul_eq_mul, ring_hom.map_mul, algebra.smul_def] },\n  { rintros \u27e8y', rfl\u27e9,\n    refine \u27e8y' * x, submodule.mem_span_singleton.mpr \u27e8y', rfl\u27e9, _\u27e9,\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      (\u03bb y (hy : y \u2208 S), show ring_hom.id R y \u2208 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 \u27e8x', hx', rfl\u27e9 := (mem_canonical_equiv_apply _ _ _).mp h,\n    obtain \u27e8z, rfl\u27e9 := (mem_span_singleton _).mp hx',\n    use z,\n    rw is_localization.map_smul,\n    refl },\n  { rw mem_canonical_equiv_apply,\n    obtain \u27e8z, rfl\u27e9 := (mem_span_singleton _).mp h,\n    use z \u2022 x,\n    use (mem_span_singleton _).mpr \u27e8z, rfl\u27e9,\n    simp [is_localization.map_smul] }\nend\n\nlemma mem_singleton_mul {x y : P} {I : fractional_ideal S P} :\n  y \u2208 span_singleton S x * I \u2194 \u2203 y' \u2208 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 \u27e8a, ha\u27e9 := (mem_span_singleton S).mp hx',\n      use [a \u2022 y', submodule.smul_mem I a hy'],\n      rw [\u2190ha, algebra.mul_smul_comm, algebra.smul_mul_assoc] },\n    { exact \u27e80, submodule.zero_mem I, (mul_zero x).symm\u27e9 },\n    { rintros _ _ \u27e8y, hy, rfl\u27e9 \u27e8y', hy', rfl\u27e9,\n      exact \u27e8y + y', submodule.add_mem I hy hy', (mul_add _ _ _).symm\u27e9 },\n    { rintros r _ \u27e8y', hy', rfl\u27e9,\n      exact \u27e8r \u2022 y', submodule.smul_mem I r hy', (algebra.mul_smul_comm _ _ _).symm \u27e9 } },\n  { rintros \u27e8y', hy', rfl\u27e9,\n    exact mul_mem_mul ((mem_span_singleton S).mpr \u27e81, one_smul _ _\u27e9) hy' }\nend\n\nomit loc\n\nvariables (K)\n\nlemma mk'_mul_coe_ideal_eq_coe_ideal {I J : ideal R\u2081} {x y : R\u2081} (hy : y \u2208 R\u2081\u2070) :\n  span_singleton R\u2081\u2070 (is_localization.mk' K x \u27e8y, hy\u27e9) * I = (J : fractional_ideal R\u2081\u2070 K) \u2194\n  ideal.span {x} * I = ideal.span {y} * J :=\nbegin\n  have inj : function.injective (coe : ideal R\u2081 \u2192 fractional_ideal R\u2081\u2070 K) :=\n    fractional_ideal.coe_ideal_injective,\n  have : span_singleton R\u2081\u2070 (is_localization.mk' _ (1 : R\u2081) \u27e8y, hy\u27e9) *\n           span_singleton R\u2081\u2070 (algebra_map R\u2081 K y) = 1,\n  { rw [span_singleton_mul_span_singleton, mul_comm, \u2190 is_localization.mk'_eq_mul_mk'_one,\n        is_localization.mk'_self, span_singleton_one] },\n  let y' : units (fractional_ideal R\u2081\u2070 K) := units.mk_of_mul_eq_one _ _ this,\n  have coe_y' : \u2191y' = span_singleton R\u2081\u2070 (is_localization.mk' K (1 : R\u2081) \u27e8y, hy\u27e9) := 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    \u2190mul_assoc, span_singleton_mul_span_singleton, \u2190mul_assoc, span_singleton_mul_span_singleton,\n    mul_comm (mk' _ _ _), \u2190 is_localization.mk'_eq_mul_mk'_one,\n    mul_comm (mk' _ _ _), \u2190 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\u2081} {z : K} :\n  span_singleton R\u2081\u2070 z * (I : fractional_ideal R\u2081\u2070 K) = J \u2194\n  ideal.span {((is_localization.sec R\u2081\u2070 z).1 : R\u2081)} * I =\n    ideal.span {(is_localization.sec R\u2081\u2070 z).2} * J :=\n-- `erw` to deal with the distinction between `y` and `\u27e8y.1, y.2\u27e9`\nby erw [\u2190 mk'_mul_coe_ideal_eq_coe_ideal K (is_localization.sec R\u2081\u2070 z).2.prop,\n        is_localization.mk'_sec K z]\n\nvariables [is_domain R\u2081]\n\nlemma one_div_span_singleton (x : K) :\n  1 / span_singleton R\u2081\u2070 x = span_singleton R\u2081\u2070 (x\u207b\u00b9) :=\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\u2081\u2070 K) (d : K) :\n  J / span_singleton R\u2081\u2070 d = span_singleton R\u2081\u2070 (d\u207b\u00b9) * J :=\nbegin\n  rw \u2190 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\u2081\u2070 d \u2260 0 := mt span_singleton_eq_zero_iff.mp hd,\n  apply le_antisymm,\n  { intros x hx,\n    rw [\u2190 mem_coe, coe_div h_spand, submodule.mem_div_iff_forall_mul_mem] at hx,\n    specialize hx d (mem_span_singleton_self R\u2081\u2070 d),\n    have h_xd : x = d\u207b\u00b9 * (x * d), { field_simp },\n    rw [\u2190 mem_coe, coe_mul, one_div_span_singleton, h_xd],\n    exact submodule.mul_mem_mul (mem_span_singleton_self R\u2081\u2070 _) 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\u2081\u2070 K) :\n  \u2203 (a : R\u2081) (aI : ideal R\u2081), a \u2260 0 \u2227 I = span_singleton R\u2081\u2070 (algebra_map R\u2081 K a)\u207b\u00b9 * aI :=\nbegin\n  obtain \u27e8a_inv, nonzero, ha\u27e9 := I.is_fractional,\n  have nonzero := mem_non_zero_divisors_iff_ne_zero.mp nonzero,\n  have map_a_nonzero : algebra_map R\u2081 K a_inv \u2260 0 :=\n    mt is_fraction_ring.to_map_eq_zero_iff.mp nonzero,\n  refine \u27e8a_inv,\n          submodule.comap (algebra.linear_map R\u2081 K)\n            \u2191(span_singleton R\u2081\u2070 (algebra_map R\u2081 K a_inv) * I),\n          nonzero,\n          ext (\u03bb x, iff.trans \u27e8_, _\u27e9 mem_singleton_mul.symm)\u27e9,\n  { intro hx,\n    obtain \u27e8x', hx'\u27e9 := ha x hx,\n    rw algebra.smul_def at hx',\n    refine \u27e8algebra_map R\u2081 K x', (mem_coe_ideal _).mpr \u27e8x', mem_singleton_mul.mpr _, rfl\u27e9, _\u27e9,\n    { exact \u27e8x, hx, hx'\u27e9 },\n    { rw [hx', \u2190 mul_assoc, inv_mul_cancel map_a_nonzero, one_mul] } },\n  { rintros \u27e8y, hy, rfl\u27e9,\n    obtain \u27e8x', hx', rfl\u27e9 := (mem_coe_ideal _).mp hy,\n    obtain \u27e8y', hy', hx'\u27e9 := mem_singleton_mul.mp hx',\n    rw algebra.linear_map_apply at hx',\n    rwa [hx', \u2190mul_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\u2070 K) : (I : submodule R K).is_principal :=\nbegin\n  obtain \u27e8a, aI, -, ha\u27e9 := exists_eq_span_singleton_mul I,\n  use (algebra_map R K a)\u207b\u00b9 * algebra_map R K (generator aI),\n  suffices : I = span_singleton R\u2070 ((algebra_map R K a)\u207b\u00b9 * algebra_map R K (generator aI)),\n  { exact congr_arg subtype.val this },\n  conv_lhs { rw [ha, \u2190span_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 \u2264 span_singleton S x * J \u2194 \u2200 zI \u2208 I, \u2203 zJ \u2208 J, x * zJ = zI :=\nshow (\u2200 {zI} (hzI : zI \u2208 I), zI \u2208 span_singleton _ x * J) \u2194 \u2200 zI \u2208 I, \u2203 zJ \u2208 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 \u2264 J \u2194 \u2200 z \u2208 I, x * z \u2208 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 \u27e81, one_smul _ _\u27e9 zI hzI },\n  { rintros h _ \u27e8z, rfl\u27e9 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 \u2194 (\u2200 zI \u2208 I, \u2203 zJ \u2208 J, x * zJ = zI) \u2227 \u2200 z \u2208 J, x * z \u2208 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\u2081 : Type*} [comm_ring R\u2081]\nvariables {K : Type*} [field K] [algebra R\u2081 K] [frac : is_fraction_ring R\u2081 K]\n\nlocal attribute [instance] classical.prop_decidable\n\nlemma is_noetherian_zero : is_noetherian R\u2081 (0 : fractional_ideal R\u2081\u2070 K) :=\nis_noetherian_submodule.mpr (\u03bb I (hI : I \u2264 (0 : fractional_ideal R\u2081\u2070 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\u2081\u2070 K} :\n  is_noetherian R\u2081 I \u2194 \u2200 J \u2264 I, (J : submodule R\u2081 K).fg :=\nis_noetherian_submodule.trans \u27e8\u03bb h J hJ, h _ hJ, \u03bb h J hJ, h \u27e8J, is_fractional_of_le hJ\u27e9 hJ\u27e9\n\nlemma is_noetherian_coe_to_fractional_ideal [_root_.is_noetherian_ring R\u2081] (I : ideal R\u2081) :\n  is_noetherian R\u2081 (I : fractional_ideal R\u2081\u2070 K) :=\nbegin\n  rw is_noetherian_iff,\n  intros J hJ,\n  obtain \u27e8J, rfl\u27e9 := 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\u2081]\n\nlemma is_noetherian_span_singleton_inv_to_map_mul (x : R\u2081) {I : fractional_ideal R\u2081\u2070 K}\n  (hI : is_noetherian R\u2081 I) :\n  is_noetherian R\u2081 (span_singleton R\u2081\u2070 (algebra_map R\u2081 K x)\u207b\u00b9 * I : fractional_ideal R\u2081\u2070 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\u2081 K x \u2260 0,\n    from mt ((algebra_map R\u2081 K).injective_iff.mp (is_fraction_ring.injective _ _) x) hx,\n  have h_spanx : span_singleton R\u2081\u2070 (algebra_map R\u2081 K x) \u2260 0,\n    from span_singleton_ne_zero_iff.mpr h_gx,\n\n  rw is_noetherian_iff at \u22a2 hI,\n  intros J hJ,\n  rw [\u2190 div_span_singleton, le_div_iff_mul_le h_spanx] at hJ,\n  obtain \u27e8s, hs\u27e9 := hI _ hJ,\n  use s * {(algebra_map R\u2081 K x)\u207b\u00b9},\n  rw [finset.coe_mul, finset.coe_singleton, \u2190 span_mul_span, hs, \u2190 coe_span_singleton R\u2081\u2070,\n      \u2190 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\u2081] (I : fractional_ideal R\u2081\u2070 K) :\n  is_noetherian R\u2081 I :=\nbegin\n  obtain \u27e8d, J, h_nzd, rfl\u27e9 := 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\u27e8_, is_fractional_adjoin_integral S x hx\u27e9\n\nlemma mem_adjoin_integral_self :\n  x \u2208 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 \u2243\u2097[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 \u2243\u2090[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 \u2192\u2097[R] B` to `A \u2192\u2097[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 \u2192\u2097[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 \u2192\u2097[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 `\u211a`-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 \u2243\u2097[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 \u2022 x = ((algebra_map R S c) \u2022 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 \u2022 x)\n  = (algebra_map R S t) \u2022 restrict_scalars.linear_equiv R S M x :=\nrfl\n\ninstance : is_scalar_tower R S (restrict_scalars R S M) :=\n\u27e8\u03bb r S M, by { rw [algebra.smul_def, mul_smul], refl }\u27e9\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 \u2243\u2090[S] A`. -/\ndef restrict_scalars.alg_equiv : restrict_scalars R S A \u2243\u2090[S] A := alg_equiv.refl\n\nvariables [comm_semiring R] [algebra R S]\n\n/-- `R \u27f6 S` induces `S-Alg \u2964 R-Alg` -/\ninstance : algebra R (restrict_scalars R S A) :=\n{ smul := (\u2022),\n  commutes' := \u03bb r x, algebra.commutes _ _,\n  smul_def' := \u03bb _ _, 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u2264 n.choose r \u2264 e^r n^r/r^r` in the future.\n\n## Main declarations\n\n* `nat.choose_le_pow`: `n.choose r \u2264 n^r / r!`\n* `nat.pow_le_choose`: `(n + 1 - r)^r / r! \u2264 n.choose r`. Beware of the fishy \u2115-subtraction.\n-/\n\n\nopen Nat\n\nvariable {\u03b1 : Type _} [LinearOrderedSemifield \u03b1]\n\nnamespace Nat\n\n/- warning: nat.choose_le_pow -> Nat.choose_le_pow is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (r : Nat) (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) (Nat.choose n r)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) n) r) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) (Nat.factorial r)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (r : Nat) (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))) (Nat.choose n r)) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) n r)) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))) (Nat.factorial r)))\nCase conversion may be inaccurate. Consider using '#align nat.choose_le_pow Nat.choose_le_pow\u2093'. -/\ntheorem choose_le_pow (r n : \u2115) : (n.choose r : \u03b1) \u2264 n ^ r / r ! :=\n  by\n  rw [le_div_iff']\n  \u00b7 norm_cast\n    rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (r : Nat) (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))) (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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 \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) (Nat.factorial r))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))))))))) (Nat.choose n r))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemifield.{u1} \u03b1] (r : Nat) (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _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} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))) (Nat.factorial r))) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (DivisionSemiring.toSemiring.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 _inst_1)))) (Nat.choose n r))\nCase conversion may be inaccurate. Consider using '#align nat.pow_le_choose Nat.pow_le_choose\u2093'. -/\n-- horrific casting is due to \u2115-subtraction\ntheorem pow_le_choose (r n : \u2115) : ((n + 1 - r : \u2115) ^ r : \u03b1) / r ! \u2264 n.choose r :=\n  by\n  rw [div_le_iff']\n  \u00b7 norm_cast\n    rw [\u2190 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 \ud835\udd42\n  {\u03b1 : Sort u}\n  {\u03b2 : Sort v}\n  (val : \u03b2)\n: \u03b1 \u2192 \u03b2 :=\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 \u2192 Sort osem))\n  (Arrow : Object \u2192 Object \u2192 Sort a)\n  (ASem : outParam (Object \u2192 Object \u2192 Sort asem))\nwhere\n  --- Arrow composition.\n  compose {\u03b1 \u03b2 \u03b3} :\n    Arrow \u03b2 \u03b3 \u2192 Arrow \u03b1 \u03b2 \u2192 Arrow \u03b1 \u03b3\n\n  --- Arrow concretization.\n  aConcrete :\n    (A : Arrow \u03b1 \u03b2) \u2192 ASem \u03b1 \u03b2\n\n  -- aConcrete_distributive\n  --   {\u03b1 \u03b2 \u03b3}\n  --   (f : Arrow \u03b2 \u03b3)\n  --   (g : Arrow \u03b1 \u03b2)\n  -- : aConcrete (compose f g) = compose (aConcrete f) (aConcrete g)\n\n  --- Arrow composition is associative.\n  compose_assoc {\u03b1 \u03b2 \u03b3 \u03b4} (f : Arrow \u03b3 \u03b4) (g : Arrow \u03b2 \u03b3) (h : Arrow \u03b1 \u03b2) :\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 {\u03b1 : outParam Object} :\n    Arrow \u03b1 \u03b1\n  --- `id \u2218 f` is `f`.\n  id_compose (f : Arrow \u03b1 \u03b2) :\n    aConcrete (compose id f) = aConcrete f\n  --- `f \u2218 id` is `f`.\n  compose_id (f : Arrow \u03b1 \u03b2) :\n    aConcrete (compose f id) = aConcrete f\n\n\nclass Cat.Abstract\n  (Object : Sort o)\n  (Arrow : Object \u2192 Object \u2192 Sort a)\nextends\n  Cat Object (\ud835\udd42 Object) Arrow Arrow\nwhere\n  aConcrete a := a\n\n\n\n--- Nice notation for `Cat.Arrow`, enter `\\r=`.\ninfixr:80 \" \u21d2 \" => Cat.Arrow\n--- Usual function composition.\ninfixr:80 \" \u2218c \" => 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\u2081 b\u2082 : 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\u2081 o\u2082 : Cat.three.Object)\n\n--- Category **3** with three objects `A`, `B` and `C`.\n---\n--- Besides the three identity arrows, we have `A \u2192 B`, `B \u2192 C`, and `C \u2192 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 \u03b1 \u03b2 => Arrow \u03b2 \u03b1) 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\u2081 : Cat O\u2081 OSem\u2081 A\u2081 ASem\u2081)\n  (cat\u2082 : Cat O\u2082 OSem\u2082 A\u2082 ASem\u2082)\n: Cat\n  (PProd O\u2081 O\u2082)\n  (fun \u27e8o\u2081, o\u2082\u27e9 => OSem\u2081 o\u2081 \u00d7 OSem\u2082 o\u2082)\n  (fun \u27e8\u03b1\u2081, \u03b1\u2082\u27e9 \u27e8\u03b2\u2081, \u03b2\u2082\u27e9 => PProd (A\u2081 \u03b1\u2081 \u03b2\u2081) (A\u2082 \u03b1\u2082 \u03b2\u2082))\n  (fun \u27e8\u03b1\u2081, \u03b1\u2082\u27e9 \u27e8\u03b2\u2081, \u03b2\u2082\u27e9 => PProd (ASem\u2081 \u03b1\u2081 \u03b2\u2081) (ASem\u2082 \u03b1\u2082 \u03b2\u2082))\nwhere\n  aConcrete a :=\n    \u27e8cat\u2081.aConcrete a.1, cat\u2082.aConcrete a.2\u27e9\n  compose f g :=\n    \u27e8cat\u2081.compose f.1 g.1, cat\u2082.compose f.2 g.2\u27e9\n  compose_assoc {\u03b1 \u03b2 \u03b3 \u03b4} f g h :=\n    let res : _ \u2227 _ :=\n      \u27e8cat\u2081.compose_assoc f.1 g.1 h.1, cat\u2082.compose_assoc f.2 g.2 h.2\u27e9\n    by\n      simp [res]\n  id :=\n    \u27e8cat\u2081.id, cat\u2082.id\u27e9\n  id_compose f :=\n    let res : _ \u2227 _ :=\n      \u27e8cat\u2081.id_compose f.1, cat\u2082.id_compose f.2\u27e9\n    by\n      simp [res]\n  compose_id f :=\n    let res : _ \u2227 _ :=\n      \u27e8cat\u2081.compose_id f.1, cat\u2082.compose_id f.2\u27e9\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 \u2192 Object \u2192 Sort asem}\n\n    (A : Object \u2192 Object \u2192 Sort a)\n\n\n\n  inductive Obj\n    (A : Object \u2192 Object \u2192 Sort a)\n  : Sort (max 1 o a)\n    | mk : A \u03b1 \u03b2 \u2192 Obj A\n\n  def Obj.dom : Obj A \u2192 Object\n    | @Obj.mk _ _ \u03b1 _\u03b2 _ =>\n      \u03b1\n  def Obj.cod : Obj A \u2192 Object\n    | @Obj.mk _ _ _\u03b1 \u03b2 _ =>\n      \u03b2\n  def Obj.get : Obj A \u2192 ((\u03b1 : Object) \u00d7' (\u03b2 : Object) \u00d7' A \u03b1 \u03b2)\n    | @Obj.mk _ _ \u03b1 \u03b2 a =>\n      \u27e8\u03b1, \u03b2, a\u27e9\n  def Obj.getFun : (self : Obj A) \u2192 A self.dom self.cod\n    | @Obj.mk _ _ _\u03b1 _\u03b2 a =>\n      a\n\n  def Obj.Concrete\n    (ASem : Object \u2192 Object \u2192 Sort asem)\n    (self : Obj A)\n  : Sort asem :=\n    ASem self.dom self.cod\n\n\n\n  variable\n    {OSem : Object \u2192 Sort osem}\n    (cat : Cat Object OSem A ASem)\n\n  structure Arrow\n    (\u03b1 \u03b2 : Obj A)\n  : Sort (max 1 o a)\n  where\n    a : A \u03b1.dom \u03b2.dom\n    b : A \u03b1.cod \u03b2.cod\n    legal :\n      let f :=\n        \u03b1.getFun\n      let f' :=\n        \u03b2.getFun\n      cat.compose f' a\n      =\n      cat.compose b f\n\n  def Arrow.Concrete\n    (ASem : Object \u2192 Object \u2192 Sort asem)\n    (\u03b1 \u03b2 : Obj A)\n  : Sort asem :=\n    ASem \u03b1.dom \u03b2.cod\n\n  def Arrow.concrete\n    (self : Arrow A (cat := cat) \u03b1 \u03b2)\n  : ASem \u03b1.dom \u03b2.cod :=\n    let a :=\n      self.a (cat := cat)\n    let f' :=\n      \u03b2.getFun\n    cat.compose f' a\n    |> cat.aConcrete\n\n  def Arrow.compose\n    {\u03b1 \u03b2 \u03b3}\n    (f : Arrow A cat \u03b2 \u03b3)\n    (g : Arrow A cat \u03b1 \u03b2)\n  : Arrow A cat \u03b1 \u03b3 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\u27f6` (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 {\u03b1 : Type u}\nvariable {n : \u2115}\n\nlocal infix `++`:65 := vector.append\n\n-- Simplify map_accumr\u2082 over empty lists\n@[simp]\ntheorem map_accumr\u2082_nil\n  {\u03b1 \u03b2 \u03b3 \u03c6 : Type}\n  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b3 \u00d7 \u03c6)\n  (x : vector \u03b1 0)\n  (y : vector \u03b2 0)\n  (i\u2080 : \u03b3)\n: map_accumr\u2082 f x y i\u2080 = (i\u2080, nil) :=\nbegin\n  simp [length_zero_vector_is_nil x, length_zero_vector_is_nil y\n       , nil, map_accumr\u2082, list.map_accumr\u2082],\n  apply congr_arg,\n  apply vector.eq,\n  simp,\nend\n\n-- Simplify map_accumr\u2082 over appending single element to end of lists\n@[simp]\ntheorem map_accumr\u2082_append1\n  {n : \u2115}\n  {\u03b1 \u03b2 \u03b3 \u03c6 : Type}\n  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b3 \u00d7 \u03c6)\n  (x : vector \u03b1 n) (a : \u03b1)\n  (y : vector \u03b2 n) (b : \u03b2)\n  (c : \u03b3)\n: map_accumr\u2082 f (x ++ cons a nil) (y ++ cons b nil) c =\n  let r := f a b c in\n  let z := map_accumr\u2082 f x y (r.fst) in\n  \u27e8 z.fst, z.snd ++ cons r.snd nil\u27e9 :=\nbegin\n  -- Reduce to proof about list.map_accumr\u2082 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\u2082],\n  simp [list.map_accumr\u2082_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 {\u03b1 \u03b9 \u03b2 : 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 : \u03b9 \u2192 set \u03b1)\n  (f : \u03a0 i (x : S i), \u03b2)\n  (hf : \u2200 i j (x : \u03b1) (hxi : x \u2208 S i) (hxj : x \u2208 S j), f i \u27e8x, hxi\u27e9 = f j \u27e8x, hxj\u27e9)\n  (T : set \u03b1) (hT : T \u2286 Union S) (x : T) : \u03b2 :=\nlet i := classical.indefinite_description _ (mem_Union.1 (hT x.prop)) in\nf i \u27e8x, i.prop\u27e9\n\nvariables\n  {S : \u03b9 \u2192 set \u03b1}\n  {f : \u03a0 i (x : S i), \u03b2}\n  {hf : \u2200 i j (x : \u03b1) (hxi : x \u2208 S i) (hxj : x \u2208 S j), f i \u27e8x, hxi\u27e9 = f j \u27e8x, hxj\u27e9}\n  {T : set \u03b1} {hT : T \u2286 Union S} (hT' : T = Union S)\n\n@[simp] lemma Union_lift_mk\n  {i : \u03b9} (x : S i) (hx : (x : \u03b1) \u2208 T) :\n  Union_lift S f hf T hT \u27e8x, hx\u27e9 = 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 : \u03b9} (x : S i)\n  (h : S i \u2286 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 : \u03b9} (hx : (x : \u03b1) \u2208 S i) :\n  Union_lift S f hf T hT x = f i \u27e8x, hx\u27e9 :=\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 : \u03a0 i, S i) (hci : \u2200 i, (ci i : \u03b1) = c) (c\u03b2 : \u03b2)\n  (h : \u2200 i, f i (ci i) = c\u03b2) : Union_lift S f hf T hT c = c\u03b2 :=\nlet \u27e8i, hi\u27e9 := set.mem_Union.1 (hT c.prop) in\nhave (ci i) = \u27e8c, hi\u27e9, from subtype.ext (hci i),\nby rw [Union_lift_of_mem _ hi, \u2190 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 \u2192 T) (ui : \u03a0 i, S i \u2192 S i)\n  (hui : \u2200 i (x : S i), u (set.inclusion (show S i \u2286 T, from hT'.symm \u25b8 set.subset_Union S i) x)\n    = set.inclusion (show S i \u2286 T, from hT'.symm \u25b8 set.subset_Union S i) (ui i x))\n  (u\u03b2 : \u03b2 \u2192 \u03b2)\n  (h : \u2200 i (x : S i), (f i (ui i x)) = u\u03b2 (f i x))\n  (x : T) :\n  Union_lift S f hf T (le_of_eq hT') (u x) = u\u03b2 (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, \u2190 h i],\n  have : x = (set.inclusion (set.subset_Union S i) \u27e8x, hi\u27e9), { cases x, refl },\n  have hx' : (set.inclusion (set.subset_Union S i) (ui i \u27e8x, hi\u27e9) : \u03b1) \u2208 S i,\n    from (ui i \u27e8x, hi\u27e9).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 (\u2264) S) (op : T \u2192 T \u2192 T) (opi : \u03a0 i, S i \u2192 S i \u2192 S i)\n  (hopi : \u2200 i x y, set.inclusion (show S i \u2286 T, from hT'.symm \u25b8 set.subset_Union S i) (opi i x y) =\n    op (set.inclusion (show S i \u2286 T, from hT'.symm \u25b8 set.subset_Union S i) x)\n       (set.inclusion (show S i \u2286 T, from hT'.symm \u25b8 set.subset_Union S i) y))\n  (op\u03b2 : \u03b2 \u2192 \u03b2 \u2192 \u03b2)\n  (h : \u2200 i (x y : S i), (f i (opi i x y)) = op\u03b2 (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\u03b2 (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 \u27e8k, hik, hjk\u27e9,\n  rw [Union_lift_of_mem x (hik hi), Union_lift_of_mem y (hjk hj), \u2190 h k],\n  have hx : x = (set.inclusion (set.subset_Union S k) \u27e8x, hik hi\u27e9), { cases x, refl },\n  have hy : y = (set.inclusion (set.subset_Union S k) \u27e8y, hjk hj\u27e9), { cases y, refl },\n  have hxy : (set.inclusion (set.subset_Union S k) (opi k \u27e8x, hik hi\u27e9 \u27e8y, hjk hj\u27e9) : \u03b1) \u2208 S k,\n    from (opi k \u27e8x, hik hi\u27e9 \u27e8y, hjk hj\u27e9).prop,\n  conv_lhs { rw [hx, hy, \u2190 hopi, Union_lift_of_mem _ hxy] },\n  simp only [coe_inclusion, subtype.coe_eta]\nend\n\nend Union_lift\n\nvariables\n  {S : \u03b9 \u2192 set \u03b1}\n  {f : \u03a0 i (x : S i), \u03b2}\n  {hf : \u2200 i j (x : \u03b1) (hxi : x \u2208 S i) (hxj : x \u2208 S j), f i \u27e8x, hxi\u27e9 = f j \u27e8x, hxj\u27e9}\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 : \u03b9 \u2192 set \u03b1)\n  (f : \u03a0 i (x : S i), \u03b2)\n  (hf : \u2200 i j (x : \u03b1) (hxi : x \u2208 S i) (hxj : x \u2208 S j), f i \u27e8x, hxi\u27e9 = f j \u27e8x, hxj\u27e9)\n  (hS : Union S = univ) (a : \u03b1) : \u03b2 :=\nUnion_lift S f hf univ (hS \u25b8 set.subset.refl _) \u27e8a, trivial\u27e9\n\n@[simp] lemma lift_cover_coe {i : \u03b9} (x : S i) : lift_cover S f hf hS x = f i x :=\nUnion_lift_mk x _\n\nlemma lift_cover_of_mem {i : \u03b9} {x : \u03b1} (hx : (x : \u03b1) \u2208 S i) :\n  lift_cover S f hf hS x = f i \u27e8x, hx\u27e9 :=\nUnion_lift_of_mem \u27e8x, trivial\u27e9 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 : \u03b1 \u2192 \u03b2` at a filter `l : filter \u03b1` is the equivalence class of `f`\nwith respect to the equivalence relation `eventually_eq l`: `f \u2248 g` means `\u2200\u1da0 x in l, f x = g x`.\n\n## Main definitions\n\nWe define\n\n* `germ l \u03b2` to be the space of germs of functions `\u03b1 \u2192 \u03b2` at a filter `l : filter \u03b1`;\n* coercion from `\u03b1 \u2192 \u03b2` to `germ l \u03b2`: `(f : germ l \u03b2)` is the germ of `f : \u03b1 \u2192 \u03b2`\n  at `l : filter \u03b1`; this coercion is declared as `has_coe_t`, so it does not require an explicit\n  up arrow `\u2191`;\n* coercion from `\u03b2` to `germ l \u03b2`: `(\u2191c : germ l \u03b2)` is the germ of the constant function\n  `\u03bb x:\u03b1, c` at a filter `l`; this coercion is declared as `has_lift_t`, so it requires an explicit\n  up arrow `\u2191`, see [TPiL][TPiL_coe] for details.\n* `map (F : \u03b2 \u2192 \u03b3) (f : germ l \u03b2)` to be the composition of a function `F` and a germ `f`;\n* `map\u2082 (F : \u03b2 \u2192 \u03b3 \u2192 \u03b4) (f : germ l \u03b2) (g : germ l \u03b3)` to be the germ of `\u03bb x, F (f x) (g x)`\n  at `l`;\n* `f.tendsto lb`: we say that a germ `f : germ l \u03b2` 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 \u03b2` and a function\n  `g : \u03b3 \u2192 \u03b1` (resp., a germ `g : germ lc \u03b1`), if `g` tends to `l` along `lc`, then the composition\n  `f \u2218 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 \u03b2).lift_pred p` means `\u2200\u1da0 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 : \u03b2 \u2192 \u03b3) : germ l \u03b2 \u2192 germ l \u03b3` sending each germ `f` to `F \u2218 f`.\n\nFor each of the following structures we prove that if `\u03b2` has this structure, then so does\n`germ l \u03b2`:\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' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [ne_bot l] {a : \u03b2} {b : \u03b2} : filter.eventually (fun (x : \u03b1) => a = b) l \u2194 a = b :=\n  eventually_const\n\ntheorem const_eventually_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [ne_bot l] {a : \u03b2} {b : \u03b2} : (eventually_eq l (fun (_x : \u03b1) => a) fun (_x : \u03b1) => b) \u2194 a = b :=\n  const_eventually_eq'\n\ntheorem eventually_eq.comp_tendsto {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} {f : \u03b1 \u2192 \u03b2} {f' : \u03b1 \u2192 \u03b2} (H : eventually_eq l f f') {g : \u03b3 \u2192 \u03b1} {lc : filter \u03b3} (hg : tendsto g lc l) : eventually_eq lc (f \u2218 g) (f' \u2218 g) :=\n  tendsto.eventually hg H\n\n/-- Setoid used to define the space of germs. -/\ndef germ_setoid {\u03b1 : Type u_1} (l : filter \u03b1) (\u03b2 : Type u_2) : setoid (\u03b1 \u2192 \u03b2) :=\n  setoid.mk (eventually_eq l) sorry\n\n/-- The space of germs of functions `\u03b1 \u2192 \u03b2` at a filter `l`. -/\ndef germ {\u03b1 : Type u_1} (l : filter \u03b1) (\u03b2 : Type u_2) :=\n  quotient (germ_setoid l \u03b2)\n\nnamespace germ\n\n\nprotected instance has_coe_t {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} : has_coe_t (\u03b1 \u2192 \u03b2) (germ l \u03b2) :=\n  has_coe_t.mk quotient.mk'\n\nprotected instance has_lift_t {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} : has_lift_t \u03b2 (germ l \u03b2) :=\n  has_lift_t.mk fun (c : \u03b2) => \u2191fun (x : \u03b1) => c\n\n@[simp] theorem quot_mk_eq_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} (l : filter \u03b1) (f : \u03b1 \u2192 \u03b2) : Quot.mk setoid.r f = \u2191f :=\n  rfl\n\n@[simp] theorem mk'_eq_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} (l : filter \u03b1) (f : \u03b1 \u2192 \u03b2) : quotient.mk' f = \u2191f :=\n  rfl\n\ntheorem induction_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} (f : germ l \u03b2) {p : germ l \u03b2 \u2192 Prop} (h : \u2200 (f : \u03b1 \u2192 \u03b2), p \u2191f) : p f :=\n  quotient.induction_on' f h\n\ntheorem induction_on\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (f : germ l \u03b2) (g : germ l \u03b3) {p : germ l \u03b2 \u2192 germ l \u03b3 \u2192 Prop} (h : \u2200 (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3), p \u2191f \u2191g) : p f g :=\n  quotient.induction_on\u2082' f g h\n\ntheorem induction_on\u2083 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {l : filter \u03b1} (f : germ l \u03b2) (g : germ l \u03b3) (h : germ l \u03b4) {p : germ l \u03b2 \u2192 germ l \u03b3 \u2192 germ l \u03b4 \u2192 Prop} (H : \u2200 (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) (h : \u03b1 \u2192 \u03b4), p \u2191f \u2191g \u2191h) : p f g h :=\n  quotient.induction_on\u2083' f g h H\n\n/-- Given a map `F : (\u03b1 \u2192 \u03b2) \u2192 (\u03b3 \u2192 \u03b4)` that sends functions eventually equal at `l` to functions\neventually equal at `lc`, returns a map from `germ l \u03b2` to `germ lc \u03b4`. -/\ndef map' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {l : filter \u03b1} {lc : filter \u03b3} (F : (\u03b1 \u2192 \u03b2) \u2192 \u03b3 \u2192 \u03b4) (hF : relator.lift_fun (eventually_eq l) (eventually_eq lc) F F) : germ l \u03b2 \u2192 germ lc \u03b4 :=\n  quotient.map' F hF\n\n/-- Given a germ `f : germ l \u03b2` and a function `F : (\u03b1 \u2192 \u03b2) \u2192 \u03b3` sending eventually equal functions\nto the same value, returns the value `F` takes on functions having germ `f` at `l`. -/\ndef lift_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {\u03b3 : Sort u_3} (f : germ l \u03b2) (F : (\u03b1 \u2192 \u03b2) \u2192 \u03b3) (hF : relator.lift_fun (eventually_eq l) Eq F F) : \u03b3 :=\n  quotient.lift_on' f F hF\n\n@[simp] theorem map'_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {l : filter \u03b1} {lc : filter \u03b3} (F : (\u03b1 \u2192 \u03b2) \u2192 \u03b3 \u2192 \u03b4) (hF : relator.lift_fun (eventually_eq l) (eventually_eq lc) F F) (f : \u03b1 \u2192 \u03b2) : map' F hF \u2191f = \u2191(F f) :=\n  rfl\n\n@[simp] theorem coe_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} : \u2191f = \u2191g \u2194 eventually_eq l f g :=\n  quotient.eq'\n\ntheorem Mathlib.filter.eventually_eq.germ_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} : eventually_eq l f g \u2192 \u2191f = \u2191g :=\n  iff.mpr coe_eq\n\n/-- Lift a function `\u03b2 \u2192 \u03b3` to a function `germ l \u03b2 \u2192 germ l \u03b3`. -/\ndef map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (op : \u03b2 \u2192 \u03b3) : germ l \u03b2 \u2192 germ l \u03b3 :=\n  map' (function.comp op) sorry\n\n@[simp] theorem map_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (op : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) : map op \u2191f = \u2191(op \u2218 f) :=\n  rfl\n\n@[simp] theorem map_id {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} : map id = id :=\n  funext fun (x : germ l \u03b2) => quot.induction_on x fun (f : \u03b1 \u2192 \u03b2) => Eq.refl (map id (Quot.mk setoid.r f))\n\ntheorem map_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {l : filter \u03b1} (op\u2081 : \u03b3 \u2192 \u03b4) (op\u2082 : \u03b2 \u2192 \u03b3) (f : germ l \u03b2) : map op\u2081 (map op\u2082 f) = map (op\u2081 \u2218 op\u2082) f :=\n  induction_on f fun (f : \u03b1 \u2192 \u03b2) => rfl\n\n/-- Lift a binary function `\u03b2 \u2192 \u03b3 \u2192 \u03b4` to a function `germ l \u03b2 \u2192 germ l \u03b3 \u2192 germ l \u03b4`. -/\ndef map\u2082 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {l : filter \u03b1} (op : \u03b2 \u2192 \u03b3 \u2192 \u03b4) : germ l \u03b2 \u2192 germ l \u03b3 \u2192 germ l \u03b4 :=\n  quotient.map\u2082' (fun (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) (x : \u03b1) => op (f x) (g x)) sorry\n\n@[simp] theorem map\u2082_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {l : filter \u03b1} (op : \u03b2 \u2192 \u03b3 \u2192 \u03b4) (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) : map\u2082 op \u2191f \u2191g = \u2191fun (x : \u03b1) => op (f x) (g x) :=\n  rfl\n\n/-- A germ at `l` of maps from `\u03b1` to `\u03b2` tends to `lb : filter \u03b2` if it is represented by a map\nwhich tends to `lb` along `l`. -/\nprotected def tendsto {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} (f : germ l \u03b2) (lb : filter \u03b2) :=\n  lift_on f (fun (f : \u03b1 \u2192 \u03b2) => tendsto f l lb) sorry\n\n@[simp] theorem coe_tendsto {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {f : \u03b1 \u2192 \u03b2} {lb : filter \u03b2} : germ.tendsto (\u2191f) lb \u2194 tendsto f l lb :=\n  iff.rfl\n\ntheorem Mathlib.filter.tendsto.germ_tendsto {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {f : \u03b1 \u2192 \u03b2} {lb : filter \u03b2} : tendsto f l lb \u2192 germ.tendsto (\u2191f) lb :=\n  iff.mpr coe_tendsto\n\n/-- Given two germs `f : germ l \u03b2`, and `g : germ lc \u03b1`, where `l : filter \u03b1`, if `g` tends to `l`,\nthen the composition `f \u2218 g` is well-defined as a germ at `lc`. -/\ndef comp_tendsto' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (f : germ l \u03b2) {lc : filter \u03b3} (g : germ lc \u03b1) (hg : germ.tendsto g l) : germ lc \u03b2 :=\n  lift_on f (fun (f : \u03b1 \u2192 \u03b2) => map f g) sorry\n\n@[simp] theorem coe_comp_tendsto' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (f : \u03b1 \u2192 \u03b2) {lc : filter \u03b3} {g : germ lc \u03b1} (hg : germ.tendsto g l) : comp_tendsto' (\u2191f) g hg = map f g :=\n  rfl\n\n/-- Given a germ `f : germ l \u03b2` and a function `g : \u03b3 \u2192 \u03b1`, where `l : filter \u03b1`, if `g` tends\nto `l` along `lc : filter \u03b3`, then the composition `f \u2218 g` is well-defined as a germ at `lc`. -/\ndef comp_tendsto {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (f : germ l \u03b2) {lc : filter \u03b3} (g : \u03b3 \u2192 \u03b1) (hg : tendsto g lc l) : germ lc \u03b2 :=\n  comp_tendsto' f (\u2191g) (tendsto.germ_tendsto hg)\n\n@[simp] theorem coe_comp_tendsto {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (f : \u03b1 \u2192 \u03b2) {lc : filter \u03b3} {g : \u03b3 \u2192 \u03b1} (hg : tendsto g lc l) : comp_tendsto (\u2191f) g hg = \u2191(f \u2218 g) :=\n  rfl\n\n@[simp] theorem comp_tendsto'_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (f : germ l \u03b2) {lc : filter \u03b3} {g : \u03b3 \u2192 \u03b1} (hg : tendsto g lc l) : comp_tendsto' f (\u2191g) (tendsto.germ_tendsto hg) = comp_tendsto f g hg :=\n  rfl\n\n@[simp] theorem const_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [ne_bot l] {a : \u03b2} {b : \u03b2} : \u2191a = \u2191b \u2194 a = b :=\n  iff.trans coe_eq const_eventually_eq\n\n@[simp] theorem map_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (l : filter \u03b1) (a : \u03b2) (f : \u03b2 \u2192 \u03b3) : map f \u2191a = \u2191(f a) :=\n  rfl\n\n@[simp] theorem map\u2082_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} (l : filter \u03b1) (b : \u03b2) (c : \u03b3) (f : \u03b2 \u2192 \u03b3 \u2192 \u03b4) : map\u2082 f \u2191b \u2191c = \u2191(f b c) :=\n  rfl\n\n@[simp] theorem const_comp_tendsto {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (b : \u03b2) {lc : filter \u03b3} {g : \u03b3 \u2192 \u03b1} (hg : tendsto g lc l) : comp_tendsto (\u2191b) g hg = \u2191b :=\n  rfl\n\n@[simp] theorem const_comp_tendsto' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (b : \u03b2) {lc : filter \u03b3} {g : germ lc \u03b1} (hg : germ.tendsto g l) : comp_tendsto' (\u2191b) g hg = \u2191b :=\n  induction_on g (fun (_x : \u03b3 \u2192 \u03b1) (_x_1 : germ.tendsto (\u2191_x) l) => rfl) hg\n\n/-- Lift a predicate on `\u03b2` to `germ l \u03b2`. -/\ndef lift_pred {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} (p : \u03b2 \u2192 Prop) (f : germ l \u03b2) :=\n  lift_on f (fun (f : \u03b1 \u2192 \u03b2) => filter.eventually (fun (x : \u03b1) => p (f x)) l) sorry\n\n@[simp] theorem lift_pred_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {p : \u03b2 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} : lift_pred p \u2191f \u2194 filter.eventually (fun (x : \u03b1) => p (f x)) l :=\n  iff.rfl\n\ntheorem lift_pred_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {p : \u03b2 \u2192 Prop} {x : \u03b2} (hx : p x) : lift_pred p \u2191x :=\n  eventually_of_forall fun (y : \u03b1) => hx\n\n@[simp] theorem lift_pred_const_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [ne_bot l] {p : \u03b2 \u2192 Prop} {x : \u03b2} : lift_pred p \u2191x \u2194 p x :=\n  eventually_const\n\n/-- Lift a relation `r : \u03b2 \u2192 \u03b3 \u2192 Prop` to `germ l \u03b2 \u2192 germ l \u03b3 \u2192 Prop`. -/\ndef lift_rel {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} (r : \u03b2 \u2192 \u03b3 \u2192 Prop) (f : germ l \u03b2) (g : germ l \u03b3) :=\n  quotient.lift_on\u2082' f g (fun (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) => filter.eventually (fun (x : \u03b1) => r (f x) (g x)) l) sorry\n\n@[simp] theorem lift_rel_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} {r : \u03b2 \u2192 \u03b3 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} : lift_rel r \u2191f \u2191g \u2194 filter.eventually (fun (x : \u03b1) => r (f x) (g x)) l :=\n  iff.rfl\n\ntheorem lift_rel_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} {r : \u03b2 \u2192 \u03b3 \u2192 Prop} {x : \u03b2} {y : \u03b3} (h : r x y) : lift_rel r \u2191x \u2191y :=\n  eventually_of_forall fun (_x : \u03b1) => h\n\n@[simp] theorem lift_rel_const_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {l : filter \u03b1} [ne_bot l] {r : \u03b2 \u2192 \u03b3 \u2192 Prop} {x : \u03b2} {y : \u03b3} : lift_rel r \u2191x \u2191y \u2194 r x y :=\n  eventually_const\n\nprotected instance inhabited {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [Inhabited \u03b2] : Inhabited (germ l \u03b2) :=\n  { default := \u2191Inhabited.default }\n\nprotected instance has_add {\u03b1 : Type u_1} {l : filter \u03b1} {M : Type u_5} [Add M] : Add (germ l M) :=\n  { add := map\u2082 Add.add }\n\n@[simp] theorem coe_add {\u03b1 : Type u_1} {l : filter \u03b1} {M : Type u_5} [Add M] (f : \u03b1 \u2192 M) (g : \u03b1 \u2192 M) : \u2191(f + g) = \u2191f + \u2191g :=\n  rfl\n\nprotected instance has_one {\u03b1 : Type u_1} {l : filter \u03b1} {M : Type u_5} [HasOne M] : HasOne (germ l M) :=\n  { one := \u21911 }\n\n@[simp] theorem coe_zero {\u03b1 : Type u_1} {l : filter \u03b1} {M : Type u_5} [HasZero M] : \u21910 = 0 :=\n  rfl\n\nprotected instance add_semigroup {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {M : Type u_5} [monoid M] (l : filter \u03b1) : (\u03b1 \u2192 M) \u2192* 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 {\u03b1 : Type u_1} {l : filter \u03b1} {M : Type u_5} [monoid M] : \u21d1(coe_mul_hom l) = coe :=\n  rfl\n\nprotected instance add_comm_monoid {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {G : Type u_6} [Neg G] : Neg (germ l G) :=\n  { neg := map Neg.neg }\n\n@[simp] theorem coe_neg {\u03b1 : Type u_1} {l : filter \u03b1} {G : Type u_6} [Neg G] (f : \u03b1 \u2192 G) : \u2191(-f) = -\u2191f :=\n  rfl\n\nprotected instance has_div {\u03b1 : Type u_1} {l : filter \u03b1} {M : Type u_5} [Div M] : Div (germ l M) :=\n  { div := map\u2082 Div.div }\n\n@[simp] theorem coe_div {\u03b1 : Type u_1} {l : filter \u03b1} {M : Type u_5} [Div M] (f : \u03b1 \u2192 M) (g : \u03b1 \u2192 M) : \u2191(f / g) = \u2191f / \u2191g :=\n  rfl\n\nprotected instance sub_neg_add_monoid {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {R : Type u_5} [nontrivial R] [ne_bot l] : nontrivial (germ l R) :=\n  sorry\n\nprotected instance mul_zero_class {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {R : Type u_5} [distrib R] : distrib (germ l R) :=\n  distrib.mk Mul.mul Add.add sorry sorry\n\nprotected instance semiring {\u03b1 : Type u_1} {l : filter \u03b1} {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 `(\u03b1 \u2192 R) \u2192 germ l R` as a `ring_hom`. -/\ndef coe_ring_hom {\u03b1 : Type u_1} {R : Type u_5} [semiring R] (l : filter \u03b1) : (\u03b1 \u2192 R) \u2192+* germ l R :=\n  ring_hom.mk coe sorry sorry sorry sorry\n\n@[simp] theorem coe_coe_ring_hom {\u03b1 : Type u_1} {l : filter \u03b1} {R : Type u_5} [semiring R] : \u21d1(coe_ring_hom l) = coe :=\n  rfl\n\nprotected instance ring {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {M : Type u_5} [has_scalar M \u03b2] : has_scalar M (germ l \u03b2) :=\n  has_scalar.mk fun (c : M) => map (has_scalar.smul c)\n\nprotected instance has_scalar' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {M : Type u_5} [has_scalar M \u03b2] : has_scalar (germ l M) (germ l \u03b2) :=\n  has_scalar.mk (map\u2082 has_scalar.smul)\n\n@[simp] theorem coe_smul {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {M : Type u_5} [has_scalar M \u03b2] (c : M) (f : \u03b1 \u2192 \u03b2) : \u2191(c \u2022 f) = c \u2022 \u2191f :=\n  rfl\n\n@[simp] theorem coe_smul' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {M : Type u_5} [has_scalar M \u03b2] (c : \u03b1 \u2192 M) (f : \u03b1 \u2192 \u03b2) : \u2191(c \u2022 f) = \u2191c \u2022 \u2191f :=\n  rfl\n\nprotected instance mul_action {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {M : Type u_5} [monoid M] [mul_action M \u03b2] : mul_action M (germ l \u03b2) :=\n  mul_action.mk sorry sorry\n\nprotected instance mul_action' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {M : Type u_5} [monoid M] [mul_action M \u03b2] : mul_action (germ l M) (germ l \u03b2) :=\n  mul_action.mk sorry sorry\n\nprotected instance distrib_mul_action {\u03b1 : Type u_1} {l : filter \u03b1} {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' {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {l : filter \u03b1} {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' {\u03b1 : Type u_1} {l : filter \u03b1} {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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [HasLessEq \u03b2] : HasLessEq (germ l \u03b2) :=\n  { LessEq := lift_rel LessEq }\n\n@[simp] theorem coe_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} [HasLessEq \u03b2] : \u2191f \u2264 \u2191g \u2194 eventually_le l f g :=\n  iff.rfl\n\ntheorem le_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [HasLessEq \u03b2] : LessEq = lift_rel LessEq :=\n  rfl\n\ntheorem const_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [HasLessEq \u03b2] {x : \u03b2} {y : \u03b2} (h : x \u2264 y) : \u2191x \u2264 \u2191y :=\n  lift_rel_const h\n\n@[simp] theorem const_le_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [HasLessEq \u03b2] [ne_bot l] {x : \u03b2} {y : \u03b2} : \u2191x \u2264 \u2191y \u2194 x \u2264 y :=\n  lift_rel_const_iff\n\nprotected instance preorder {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [preorder \u03b2] : preorder (germ l \u03b2) :=\n  preorder.mk LessEq (fun (a b : germ l \u03b2) => a \u2264 b \u2227 \u00acb \u2264 a) sorry sorry\n\nprotected instance partial_order {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [partial_order \u03b2] : partial_order (germ l \u03b2) :=\n  partial_order.mk LessEq preorder.lt sorry sorry sorry\n\nprotected instance has_bot {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [has_bot \u03b2] : has_bot (germ l \u03b2) :=\n  has_bot.mk \u2191\u22a5\n\n@[simp] theorem const_bot {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [has_bot \u03b2] : \u2191\u22a5 = \u22a5 :=\n  rfl\n\nprotected instance order_bot {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [order_bot \u03b2] : order_bot (germ l \u03b2) :=\n  order_bot.mk \u22a5 LessEq partial_order.lt sorry sorry sorry sorry\n\nprotected instance has_top {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [has_top \u03b2] : has_top (germ l \u03b2) :=\n  has_top.mk \u2191\u22a4\n\n@[simp] theorem const_top {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [has_top \u03b2] : \u2191\u22a4 = \u22a4 :=\n  rfl\n\nprotected instance order_top {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [order_top \u03b2] : order_top (germ l \u03b2) :=\n  order_top.mk \u22a4 LessEq partial_order.lt sorry sorry sorry sorry\n\nprotected instance has_sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [has_sup \u03b2] : has_sup (germ l \u03b2) :=\n  has_sup.mk (map\u2082 has_sup.sup)\n\n@[simp] theorem const_sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [has_sup \u03b2] (a : \u03b2) (b : \u03b2) : \u2191(a \u2294 b) = \u2191a \u2294 \u2191b :=\n  rfl\n\nprotected instance has_inf {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [has_inf \u03b2] : has_inf (germ l \u03b2) :=\n  has_inf.mk (map\u2082 has_inf.inf)\n\n@[simp] theorem const_inf {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [has_inf \u03b2] (a : \u03b2) (b : \u03b2) : \u2191(a \u2293 b) = \u2191a \u2293 \u2191b :=\n  rfl\n\nprotected instance semilattice_sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [semilattice_sup \u03b2] : semilattice_sup (germ l \u03b2) :=\n  semilattice_sup.mk has_sup.sup partial_order.le partial_order.lt sorry sorry sorry sorry sorry sorry\n\nprotected instance semilattice_inf {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [semilattice_inf \u03b2] : semilattice_inf (germ l \u03b2) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [semilattice_inf_bot \u03b2] : semilattice_inf_bot (germ l \u03b2) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [semilattice_sup_bot \u03b2] : semilattice_sup_bot (germ l \u03b2) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [semilattice_inf_top \u03b2] : semilattice_inf_top (germ l \u03b2) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [semilattice_sup_top \u03b2] : semilattice_sup_top (germ l \u03b2) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [lattice \u03b2] : lattice (germ l \u03b2) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [bounded_lattice \u03b2] : bounded_lattice (germ l \u03b2) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [ordered_cancel_add_comm_monoid \u03b2] : ordered_cancel_add_comm_monoid (germ l \u03b2) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {l : filter \u03b1} [ordered_add_comm_group \u03b2] : ordered_add_comm_group (germ l \u03b2) :=\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 \u27f6 Y` is locally of finite type if for each affine `U \u2286 Y` and\n`V \u2286 f \u207b\u00b9' U`, The induced map `\u0393(Y, U) \u27f6 \u0393(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 \u27f6 Y)\n\n/-- A morphism of schemes `f : X \u27f6 Y` is locally of finite type if for each affine `U \u2286 Y` and\n`V \u2286 f \u207b\u00b9' U`, The induced map `\u0393(Y, U) \u27f6 \u0393(X, V)` is of finite type.\n-/\n@[mk_iff]\nclass LocallyOfFiniteType (f : X \u27f6 Y) : Prop where\n  finiteType_of_affine_subset :\n    \u2200 (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 \u2264 (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 \u27f6 Y)\n    [IsOpenImmersion f] : LocallyOfFiniteType f :=\n  locallyOfFiniteType_eq.symm \u25b8 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 \u25b8 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 \u27f6 Y) (g : Y \u27f6 Z)\n    [hf : LocallyOfFiniteType f] [hg : LocallyOfFiniteType g] : LocallyOfFiniteType (f \u226b 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 \u27f6 Y) (g : Y \u27f6 Z)\n    [hf : LocallyOfFiniteType (f \u226b 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 \u27f6 Y)\n    (\ud835\udcb0 : Scheme.OpenCover.{u} Y) [\u2200 i, IsAffine (\ud835\udcb0.obj i)]\n    (\ud835\udcb0' : \u2200 i, Scheme.OpenCover.{u} ((\ud835\udcb0.pullbackCover f).obj i)) [\u2200 i j, IsAffine ((\ud835\udcb0' i).obj j)] :\n    LocallyOfFiniteType f \u2194 \u2200 i j, (Scheme.\u0393.map ((\ud835\udcb0' i).map j \u226b pullback.snd).op).FiniteType :=\n  locallyOfFiniteType_eq.symm \u25b8 RingHom.finiteType_is_local.affine_openCover_iff f \ud835\udcb0 \ud835\udcb0'\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 \u27f6 Y)\n    (\ud835\udcb0 : Scheme.OpenCover.{u} X) : LocallyOfFiniteType f \u2194 \u2200 i, LocallyOfFiniteType (\ud835\udcb0.map i \u226b f) :=\n  locallyOfFiniteType_eq.symm \u25b8 RingHom.finiteType_is_local.source_openCover_iff f \ud835\udcb0\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 \u27f6 Y)\n    (\ud835\udcb0 : Scheme.OpenCover.{u} Y) :\n    LocallyOfFiniteType f \u2194 \u2200 i, LocallyOfFiniteType (pullback.snd : pullback f (\ud835\udcb0.map i) \u27f6 _) :=\n  locallyOfFiniteType_eq.symm \u25b8 RingHom.finiteType_is_local.isLocalAffineLocally.openCover_iff f \ud835\udcb0\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 \u25b8\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 \u2124 \u2102) = (complex.has_scalar : has_scalar \u2124 \u2102) :=\nrfl\n\nexample (\u03b1 \u03b2 : Type*) [add_monoid \u03b1] [add_monoid \u03b2] :\n  (prod.has_scalar : has_scalar \u2115 (\u03b1 \u00d7 \u03b2)) = add_monoid.has_scalar_nat := rfl\n\nexample (\u03b1 \u03b2 : Type*) [sub_neg_monoid \u03b1] [sub_neg_monoid \u03b2] :\n  (prod.has_scalar : has_scalar \u2124 (\u03b1 \u00d7 \u03b2)) = sub_neg_monoid.has_scalar_int := rfl\n\nexample (\u03b1 : Type*) (\u03b2 : \u03b1 \u2192 Type*) [\u03a0 a, add_monoid (\u03b2 a)] :\n  (pi.has_scalar : has_scalar \u2115 (\u03a0 a, \u03b2 a)) = add_monoid.has_scalar_nat := rfl\n\nexample (\u03b1 : Type*) (\u03b2 : \u03b1 \u2192 Type*) [\u03a0 a, sub_neg_monoid (\u03b2 a)] :\n  (pi.has_scalar : has_scalar \u2124 (\u03a0 a, \u03b2 a)) = sub_neg_monoid.has_scalar_int := rfl\n\nsection units\n\nexample (\u03b1 : Type*) [monoid \u03b1] :\n  (units.mul_action : mul_action (units \u03b1) (\u03b1 \u00d7 \u03b1)) = prod.mul_action := rfl\n\nexample (R \u03b1 : Type*) (\u03b2 : \u03b1 \u2192 Type*) [monoid R] [\u03a0 i, mul_action R (\u03b2 i)] :\n  (units.mul_action : mul_action (units R) (\u03a0 i, \u03b2 i)) = pi.mul_action _ := rfl\n\nexample (R \u03b1 : Type*) (\u03b2 : \u03b1 \u2192 Type*) [monoid R] [semiring \u03b1] [distrib_mul_action R \u03b1] :\n  (units.distrib_mul_action : distrib_mul_action (units R) (polynomial \u03b1)) =\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 {\u03b1 : Type*} [comm_monoid \u03b1] :\n  (units.mul_action' : mul_action (units \u03b1) (units \u03b1)) = 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 ` \u22b9 `:59 := nat.mul\nlocal infix ` \u2193 `:59 := pow\nlocal infix ` \u2296 `:59 := pow\nexample : 2 \u22b9 3 = 6 := rfl\nexample : 2 \u2193 3 = 8 := rfl\nexample : 2 \u2296 3 = 8 := rfl\nexample {n m : \u2115} (h : n < m) : n \u2264 m := by { success_if_fail { simp [h] }, exact le_of_lt h }\nsection\nlocalized \"infix (name := plus) ` \u22b9 `:59 := nat.add\" in nat\nlocalized \"infix (name := down) ` \u2193 `:59 := nat.mul\" in nat\nlocalized \"infix (name := minus) ` \u2296 `:59 := nat.mul\" in nat.mul\nlocalized \"attribute [simp] le_of_lt\" in le\nexample : 2 \u22b9 3 = 5 := rfl\nexample : 2 \u2193 3 = 6 := rfl\nexample : 2 \u2296 3 = 6 := rfl\nexample {n m : \u2115} (h : n < m) : n \u2264 m := by { simp [h] }\nend\n\nsection\nexample : 2 \u22b9 3 = 6 := rfl\nexample : 2 \u2193 3 = 8 := rfl\nexample : 2 \u2296 3 = 8 := rfl\nexample {n m : \u2115} (h : n < m) : n \u2264 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 \u22b9 3 = 5 := rfl\nexample : 2 \u2193 3 = 6 := rfl\nexample : 2 \u2296 3 = 8 := rfl\n\nopen_locale nat.mul\nexample : 2 \u22b9 3 = 5 := rfl\nexample : 2 \u2193 3 = 6 := rfl\nexample : 2 \u2296 3 = 6 := rfl\nend\n\nsection\nopen_locale nat.mul nat nat.mul le\nexample : 2 \u22b9 3 = 5 := rfl\nexample : 2 \u2193 3 = 6 := rfl\nexample : 2 \u2296 3 = 6 := rfl\nexample {n m : \u2115} (h : n < m) : n \u2264 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 \u2192 \u2115\n| 'A' := 1\n| 'B' := 2\n| _   := 3\n\n#print foo._main\n\ninductive data\n| const (n : \u2115) : data\n| var (n : \u2115) : data\n| plus s t : data\n| times s t : data\n\nopen data\n\ndef eval (v : list \u2115): data \u2192 option \u2115\n| (const n) := n\n| (var n) := v.nth n\n| (plus s t) := (eval s).bind (\u03bb s, (eval t).map (\u03bb t, s + t))\n| (times s t) := (eval s).bind (\u03bb s, (eval t).map (\u03bb 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 {\u03b1 : Type}\n\n/- this and the next makes simp way more powerful -/\nlocal attribute [simp]\ndef len : list \u03b1 \u2192 \u2115\n| (x::xs) := 1 + len xs\n| _ := 0\n\nlocal attribute [simp]\ndef rev : list \u03b1 \u2192 list \u03b1\n| (x::xs) := rev xs ++ [x]\n| _ := []\n\n@[simp]\ndef rev' : list \u03b1 \u2192 list \u03b1 \u2192 list \u03b1\n| [] r := r\n| (x::xs) r := rev' xs (x::r)\n\n@[simp]\ndef rev_tl (as : list \u03b1) : list \u03b1 := rev' as []\n\n-- @[simp]\n-- lemma rev'_cons (a : \u03b1) (as : list \u03b1) (xs: list \u03b1):\n--   rev' (a :: as) xs = rev' as (a::xs) := by induction as; simp\n\nlemma rev'_app : \u2200 as rs xs : list \u03b1,\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 \u03b1) : 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 \u03b1) : 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 : \u03b1) (xs : list \u03b1) :\n  len (x::xs) = 1 + len xs := by simp\n\nlocal attribute [simp]\ntheorem len_app (s : list \u03b1) (t : list \u03b1) :\n  len (s ++ t) = len s + len t := by induction s; simp [*, add_assoc]\n\ntheorem len_rev : \u2200 as : list \u03b1, len (rev as) = len as\n| (a::as) := by simp [*, add_comm]\n| [] := rfl\n\ntheorem len_rev' (as : list \u03b1) : len (rev as) = len as :=\n  by induction as; simp [*, add_comm]\n\nopen nat\n\ntheorem zero_add' : \u2200 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 : \u2115 \u2192 list \u2115\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 (\u03b1 : Type u) : nat \u2192 Type u\n| nil {} : vector 0\n| cons   : \u03a0 {n}, \u03b1 \u2192 vector n \u2192 vector (n+1)\n\nnamespace vector\nlocal notation h :: t := cons h t\n\n#check @vector.cases_on\n-- \u03a0 {\u03b1 : Type}\n--   {C : \u03a0 (a : \u2115), vector \u03b1 a \u2192 Type}\n--   {a : \u2115}\n--   (n : vector \u03b1 a),\n--   (e1 : C 0 nil)\n--   (e2 : \u03a0 {n : \u2115} (a : \u03b1) (a_1 : vector \u03b1 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 {\u03b1 : Type} {n m : \u2115} (v : vector \u03b1 m) :\n    m = n + 1 \u2192 vector \u03b1 n :=\nvector.cases_on v\n  (assume H : 0 = n + 1, nat.no_confusion H)\n  (assume m (a : \u03b1) w : vector \u03b1 m,\n    assume H : m + 1 = n + 1,\n      nat.no_confusion H (\u03bb H1 : m = n, eq.rec_on H1 w))\n\ndef tail' {\u03b1 : Type} {n : \u2115} (v : vector \u03b1 (n+1)) :\n  vector \u03b1 n :=\ntail_aux v rfl\n\ndef head {\u03b1 : Type} : \u03a0 {n}, vector \u03b1 (n+1) \u2192 \u03b1\n| n (h :: t) := h\n\ndef tail {\u03b1 : Type} : \u03a0 {n}, vector \u03b1 (n+1) \u2192 vector \u03b1 n\n| n (h :: t) := t\n\nlemma eta {\u03b1 : Type} :\n  \u2200 {n} (v : vector \u03b1 (n+1)), head v :: tail v = v\n| n (h :: t) := rfl\n\ndef map {\u03b1 \u03b2 \u03b3 : Type} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :\n  \u03a0 {n}, vector \u03b1 n \u2192 vector \u03b2 n \u2192 vector \u03b3 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 {\u03b1 \u03b2 : Type} :\n  \u03a0 {n}, vector \u03b1 n \u2192 vector \u03b2 n \u2192 vector (\u03b1 \u00d7 \u03b2) n\n| 0     nil       nil       := nil\n| (n+1) (a :: va) (b :: vb) := (a, b) :: zip va vb\n\nend vector\n\nvariable p : \u03b1 \u2192 bool\n\ndef is_not_zero (m : \u2115) : bool :=\nmatch m with\n| 0     := ff\n| (n+1) := tt\nend\n\ndef filter : list \u03b1 \u2192 list \u03b1\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\u2081 : \u2115 \u00d7 \u2115 \u2192 \u2115\n| (m, n) := m + n\n\ndef bar\u2082 (p : \u2115 \u00d7 \u2115) : \u2115 :=\nmatch p with (m, n) := m + n end\n\ndef bar\u2083 : \u2115 \u00d7 \u2115 \u2192 \u2115 :=\n\u03bb \u27e8m, n\u27e9, m + n\n\ndef bar\u2084 (p : \u2115 \u00d7 \u2115) : \u2115 :=\nlet \u27e8m, n\u27e9 := 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 :\u2200 y:\u2115, \u2203 x:\u2115, x-2=y:=\u03bb y,exists.intro (y+2) rfl\n#print classical.some\nnoncomputable def test2 : \u2115 \u2192 \u2115 :=\u03bb y, classical.some (test1 y)\ntheorem test3 : \u2200 y:\u2115,test2 y-2=y:=\u03bb 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": "import .var \n\n-- some arithmetic variables\ndef X : var nat := var.mk 0\ndef Y : var nat := var.mk 1\ndef Z : var nat := var.mk 2\n\n-- some Boolean variables\ndef P : var bool := var.mk 0\ndef Q : var bool := var.mk 1\ndef R : var bool := var.mk 2\n\n-- test our var_eq function\nexample : var_eq X X = tt := rfl\nexample : var_eq X Y = ff := rfl", "meta": {"author": "kevinsullivan", "repo": "complogic-s21", "sha": "99039501b770248c8ceb39890be5dfe129dc1082", "save_path": "github-repos/lean/kevinsullivan-complogic-s21", "path": "github-repos/lean/kevinsullivan-complogic-s21/complogic-s21-99039501b770248c8ceb39890be5dfe129dc1082/src/inClassNotes/final/var_test.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506526772884, "lm_q2_score": 0.6261241772283034, "lm_q1q2_score": 0.47626176406573917}}
{"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 \u03b1`: turns any multiplicative structure on `\u03b1` into the corresponding\n  additive structure on `additive \u03b1`;\n* `multiplicative \u03b1`: turns any additive structure on `\u03b1` into the corresponding\n  multiplicative structure on `multiplicative \u03b1`.\n\nWe also define instances `additive.*` and `multiplicative.*` that actually transfer the structures.\n-/\n\nuniverses u v\nvariables {\u03b1 : Type u} {\u03b2 : Type v}\n\n/-- If `\u03b1` carries some multiplicative structure, then `additive \u03b1` carries the corresponding\nadditive structure. -/\ndef additive (\u03b1 : Type*) := \u03b1\n/-- If `\u03b1` carries some additive structure, then `multiplicative \u03b1` carries the corresponding\nmultiplicative structure. -/\ndef multiplicative (\u03b1 : Type*) := \u03b1\n\nnamespace additive\n\n/-- Reinterpret `x : \u03b1` as an element of `additive \u03b1`. -/\ndef of_mul : \u03b1 \u2243 additive \u03b1 := \u27e8\u03bb x, x, \u03bb x, x, \u03bb x, rfl, \u03bb x, rfl\u27e9\n\n/-- Reinterpret `x : additive \u03b1` as an element of `\u03b1`. -/\ndef to_mul : additive \u03b1 \u2243 \u03b1 := of_mul.symm\n\n@[simp] lemma of_mul_symm_eq : (@of_mul \u03b1).symm = to_mul := rfl\n\n@[simp] lemma to_mul_symm_eq : (@to_mul \u03b1).symm = of_mul := rfl\n\nend additive\n\nnamespace multiplicative\n\n/-- Reinterpret `x : \u03b1` as an element of `multiplicative \u03b1`. -/\ndef of_add : \u03b1 \u2243 multiplicative \u03b1 := \u27e8\u03bb x, x, \u03bb x, x, \u03bb x, rfl, \u03bb x, rfl\u27e9\n\n/-- Reinterpret `x : multiplicative \u03b1` as an element of `\u03b1`. -/\ndef to_add : multiplicative \u03b1 \u2243 \u03b1 := of_add.symm\n\n@[simp] lemma of_add_symm_eq : (@of_add \u03b1).symm = to_add := rfl\n\n@[simp] \n\nend multiplicative\n\n@[simp] lemma to_add_of_add (x : \u03b1) : (multiplicative.of_add x).to_add = x := rfl\n@[simp] lemma of_add_to_add (x : multiplicative \u03b1) : multiplicative.of_add x.to_add = x := rfl\n\n@[simp] lemma to_mul_of_mul (x : \u03b1) : (additive.of_mul x).to_mul = x := rfl\n@[simp] lemma of_mul_to_mul (x : additive \u03b1) : additive.of_mul x.to_mul = x := rfl\n\ninstance [inhabited \u03b1] : inhabited (additive \u03b1) := \u27e8additive.of_mul (default \u03b1)\u27e9\ninstance [inhabited \u03b1] : inhabited (multiplicative \u03b1) := \u27e8multiplicative.of_add (default \u03b1)\u27e9\n\ninstance [nontrivial \u03b1] : nontrivial (additive \u03b1) :=\nadditive.of_mul.injective.nontrivial\n\ninstance [nontrivial \u03b1] : nontrivial (multiplicative \u03b1) :=\nmultiplicative.of_add.injective.nontrivial\n\ninstance additive.has_add [has_mul \u03b1] : has_add (additive \u03b1) :=\n{ add := \u03bb x y, additive.of_mul (x.to_mul * y.to_mul) }\n\ninstance [has_add \u03b1] : has_mul (multiplicative \u03b1) :=\n{ mul := \u03bb x y, multiplicative.of_add (x.to_add + y.to_add) }\n\n@[simp] lemma of_add_add [has_add \u03b1] (x y : \u03b1) :\n  multiplicative.of_add (x + y) = multiplicative.of_add x * multiplicative.of_add y :=\nrfl\n\n@[simp] lemma to_add_mul [has_add \u03b1] (x y : multiplicative \u03b1) :\n  (x * y).to_add = x.to_add + y.to_add :=\nrfl\n\n@[simp] lemma of_mul_mul [has_mul \u03b1] (x y : \u03b1) :\n  additive.of_mul (x * y) = additive.of_mul x + additive.of_mul y :=\nrfl\n\n@[simp] lemma to_mul_add [has_mul \u03b1] (x y : additive \u03b1) :\n  (x + y).to_mul = x.to_mul * y.to_mul :=\nrfl\n\ninstance [semigroup \u03b1] : add_semigroup (additive \u03b1) :=\n{ add_assoc := @mul_assoc \u03b1 _,\n  ..additive.has_add }\n\ninstance [add_semigroup \u03b1] : semigroup (multiplicative \u03b1) :=\n{ mul_assoc := @add_assoc \u03b1 _,\n  ..multiplicative.has_mul }\n\ninstance [comm_semigroup \u03b1] : add_comm_semigroup (additive \u03b1) :=\n{ add_comm := @mul_comm _ _,\n  ..additive.add_semigroup }\n\ninstance [add_comm_semigroup \u03b1] : comm_semigroup (multiplicative \u03b1) :=\n{ mul_comm := @add_comm _ _,\n  ..multiplicative.semigroup }\n\ninstance [left_cancel_semigroup \u03b1] : add_left_cancel_semigroup (additive \u03b1) :=\n{ add_left_cancel := @mul_left_cancel _ _,\n  ..additive.add_semigroup }\n\ninstance [add_left_cancel_semigroup \u03b1] : left_cancel_semigroup (multiplicative \u03b1) :=\n{ mul_left_cancel := @add_left_cancel _ _,\n  ..multiplicative.semigroup }\n\ninstance [right_cancel_semigroup \u03b1] : add_right_cancel_semigroup (additive \u03b1) :=\n{ add_right_cancel := @mul_right_cancel _ _,\n  ..additive.add_semigroup }\n\ninstance [add_right_cancel_semigroup \u03b1] : right_cancel_semigroup (multiplicative \u03b1) :=\n{ mul_right_cancel := @add_right_cancel _ _,\n  ..multiplicative.semigroup }\n\ninstance [has_one \u03b1] : has_zero (additive \u03b1) := \u27e8additive.of_mul 1\u27e9\n\n@[simp] lemma of_mul_one [has_one \u03b1] : @additive.of_mul \u03b1 1 = 0 := rfl\n\n@[simp] lemma of_mul_eq_zero {A : Type*} [has_one A] {x : A} :\n  additive.of_mul x = 0 \u2194 x = 1 := iff.rfl\n\n@[simp] lemma to_mul_zero [has_one \u03b1] : (0 : additive \u03b1).to_mul = 1 := rfl\n\ninstance [has_zero \u03b1] : has_one (multiplicative \u03b1) := \u27e8multiplicative.of_add 0\u27e9\n\n@[simp] lemma of_add_zero [has_zero \u03b1] : @multiplicative.of_add \u03b1 0 = 1 := rfl\n\n@[simp] lemma of_add_eq_one {A : Type*} [has_zero A] {x : A} :\n  multiplicative.of_add x = 1 \u2194 x = 0 := iff.rfl\n\n@[simp] lemma to_add_one [has_zero \u03b1] : (1 : multiplicative \u03b1).to_add = 0 := rfl\n\ninstance [mul_one_class \u03b1] : add_zero_class (additive \u03b1) :=\n{ zero     := 0,\n  add      := (+),\n  zero_add := one_mul,\n  add_zero := mul_one }\n\ninstance [add_zero_class \u03b1] : mul_one_class (multiplicative \u03b1) :=\n{ one     := 1,\n  mul     := (*),\n  one_mul := zero_add,\n  mul_one := add_zero }\n\ninstance [h : monoid \u03b1] : add_monoid (additive \u03b1) :=\n{ zero     := 0,\n  add      := (+),\n  nsmul    := @npow \u03b1 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 \u03b1] : monoid (multiplicative \u03b1) :=\n{ one     := 1,\n  mul     := (*),\n  npow   := @nsmul \u03b1 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 \u03b1] : add_left_cancel_monoid (additive \u03b1) :=\n{ .. additive.add_monoid, .. additive.add_left_cancel_semigroup }\n\ninstance [add_left_cancel_monoid \u03b1] : left_cancel_monoid (multiplicative \u03b1) :=\n{ .. multiplicative.monoid, .. multiplicative.left_cancel_semigroup }\n\ninstance [right_cancel_monoid \u03b1] : add_right_cancel_monoid (additive \u03b1) :=\n{ .. additive.add_monoid, .. additive.add_right_cancel_semigroup }\n\ninstance [add_right_cancel_monoid \u03b1] : right_cancel_monoid (multiplicative \u03b1) :=\n{ .. multiplicative.monoid, .. multiplicative.right_cancel_semigroup }\n\ninstance [comm_monoid \u03b1] : add_comm_monoid (additive \u03b1) :=\n{ .. additive.add_monoid, .. additive.add_comm_semigroup }\n\ninstance [add_comm_monoid \u03b1] : comm_monoid (multiplicative \u03b1) :=\n{ ..multiplicative.monoid, .. multiplicative.comm_semigroup }\n\ninstance [has_inv \u03b1] : has_neg (additive \u03b1) := \u27e8\u03bb x, multiplicative.of_add x.to_mul\u207b\u00b9\u27e9\n\n@[simp] lemma of_mul_inv [has_inv \u03b1] (x : \u03b1) : additive.of_mul x\u207b\u00b9 = -(additive.of_mul x) := rfl\n\n@[simp] lemma to_mul_neg [has_inv \u03b1] (x : additive \u03b1) : (-x).to_mul = x.to_mul\u207b\u00b9 := rfl\n\ninstance [has_neg \u03b1] : has_inv (multiplicative \u03b1) := \u27e8\u03bb x, additive.of_mul (-x.to_add)\u27e9\n\n@[simp] lemma of_add_neg [has_neg \u03b1] (x : \u03b1) :\n  multiplicative.of_add (-x) = (multiplicative.of_add x)\u207b\u00b9 := rfl\n\n@[simp] lemma to_add_inv [has_neg \u03b1] (x : multiplicative \u03b1) :\n  (x\u207b\u00b9).to_add = -x.to_add := rfl\n\ninstance additive.has_sub [has_div \u03b1] : has_sub (additive \u03b1) :=\n{ sub := \u03bb x y, additive.of_mul (x.to_mul / y.to_mul) }\n\ninstance multiplicative.has_div [has_sub \u03b1] : has_div (multiplicative \u03b1) :=\n{ div := \u03bb x y, multiplicative.of_add (x.to_add - y.to_add) }\n\n@[simp] lemma of_add_sub [has_sub \u03b1] (x y : \u03b1) :\n  multiplicative.of_add (x - y) = multiplicative.of_add x / multiplicative.of_add y :=\nrfl\n\n@[simp] lemma to_add_div [has_sub \u03b1] (x y : multiplicative \u03b1) :\n  (x / y).to_add = x.to_add - y.to_add :=\nrfl\n\n@[simp] lemma of_mul_div [has_div \u03b1] (x y : \u03b1) :\n  additive.of_mul (x / y) = additive.of_mul x - additive.of_mul y :=\nrfl\n\n@[simp] lemma to_mul_sub [has_div \u03b1] (x y : additive \u03b1) :\n  (x - y).to_mul = x.to_mul / y.to_mul :=\nrfl\n\ninstance [div_inv_monoid \u03b1] : sub_neg_monoid (additive \u03b1) :=\n{ sub_eq_add_neg := @div_eq_mul_inv \u03b1 _,\n  gsmul := @gpow \u03b1 _,\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 \u03b1] : div_inv_monoid (multiplicative \u03b1) :=\n{ div_eq_mul_inv := @sub_eq_add_neg \u03b1 _,\n  gpow := @gsmul \u03b1 _,\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 \u03b1] : add_group (additive \u03b1) :=\n{ add_left_neg := @mul_left_inv \u03b1 _,\n  .. additive.sub_neg_monoid }\n\ninstance [add_group \u03b1] : group (multiplicative \u03b1) :=\n{ mul_left_inv := @add_left_neg \u03b1 _,\n  .. multiplicative.div_inv_monoid }\n\ninstance [comm_group \u03b1] : add_comm_group (additive \u03b1) :=\n{ .. additive.add_group, .. additive.add_comm_monoid }\n\ninstance [add_comm_group \u03b1] : comm_group (multiplicative \u03b1) :=\n{ .. multiplicative.group, .. multiplicative.comm_monoid }\n\n/-- Reinterpret `\u03b1 \u2192+ \u03b2` as `multiplicative \u03b1 \u2192* multiplicative \u03b2`. -/\ndef add_monoid_hom.to_multiplicative [add_zero_class \u03b1] [add_zero_class \u03b2] :\n  (\u03b1 \u2192+ \u03b2) \u2243 (multiplicative \u03b1 \u2192* multiplicative \u03b2) :=\n\u27e8\u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb x, by { ext, refl, }, \u03bb x, by { ext, refl, }\u27e9\n\n/-- Reinterpret `\u03b1 \u2192* \u03b2` as `additive \u03b1 \u2192+ additive \u03b2`. -/\ndef monoid_hom.to_additive [mul_one_class \u03b1] [mul_one_class \u03b2] :\n  (\u03b1 \u2192* \u03b2) \u2243 (additive \u03b1 \u2192+ additive \u03b2) :=\n\u27e8\u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb x, by { ext, refl, }, \u03bb x, by { ext, refl, }\u27e9\n\n/-- Reinterpret `additive \u03b1 \u2192+ \u03b2` as `\u03b1 \u2192* multiplicative \u03b2`. -/\ndef add_monoid_hom.to_multiplicative' [mul_one_class \u03b1] [add_zero_class \u03b2] :\n  (additive \u03b1 \u2192+ \u03b2) \u2243 (\u03b1 \u2192* multiplicative \u03b2) :=\n\u27e8\u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb x, by { ext, refl, }, \u03bb x, by { ext, refl, }\u27e9\n\n/-- Reinterpret `\u03b1 \u2192* multiplicative \u03b2` as `additive \u03b1 \u2192+ \u03b2`. -/\ndef monoid_hom.to_additive' [mul_one_class \u03b1] [add_zero_class \u03b2] :\n  (\u03b1 \u2192* multiplicative \u03b2) \u2243 (additive \u03b1 \u2192+ \u03b2) :=\nadd_monoid_hom.to_multiplicative'.symm\n\n/-- Reinterpret `\u03b1 \u2192+ additive \u03b2` as `multiplicative \u03b1 \u2192* \u03b2`. -/\ndef add_monoid_hom.to_multiplicative'' [add_zero_class \u03b1] [mul_one_class \u03b2] :\n  (\u03b1 \u2192+ additive \u03b2) \u2243 (multiplicative \u03b1 \u2192* \u03b2) :=\n\u27e8\u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb f, \u27e8f.1, f.2, f.3\u27e9, \u03bb x, by { ext, refl, }, \u03bb x, by { ext, refl, }\u27e9\n\n/-- Reinterpret `multiplicative \u03b1 \u2192* \u03b2` as `\u03b1 \u2192+ additive \u03b2`. -/\ndef monoid_hom.to_additive'' [add_zero_class \u03b1] [mul_one_class \u03b2] :\n  (multiplicative \u03b1 \u2192* \u03b2) \u2243 (\u03b1 \u2192+ additive \u03b2) :=\nadd_monoid_hom.to_multiplicative''.symm\n\n/-- If `\u03b1` has some multiplicative structure and coerces to a function,\nthen `additive \u03b1` 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 {\u03b1 : Type*} [has_coe_to_fun \u03b1] :\n  has_coe_to_fun (additive \u03b1) :=\n\u27e8\u03bb a, has_coe_to_fun.F a.to_mul, \u03bb a, coe_fn a.to_mul\u27e9\n\n/-- If `\u03b1` has some additive structure and coerces to a function,\nthen `multiplicative \u03b1` 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 {\u03b1 : Type*} [has_coe_to_fun \u03b1] :\n  has_coe_to_fun (multiplicative \u03b1) :=\n\u27e8\u03bb a, has_coe_to_fun.F a.to_add, \u03bb a, coe_fn a.to_add\u27e9\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 {\u03b1 \u03b2 : Type _} [DecidableEq \u03b1]\n\n/-! ### dedup -/\n\n\n#print Multiset.dedup /-\n/-- `dedup s` removes duplicates from `s`, yielding a `nodup` multiset. -/\ndef dedup (s : Multiset \u03b1) : Multiset \u03b1 :=\n  Quot.liftOn s (fun l => (l.dedup : Multiset \u03b1)) 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 \u03b1) : @dedup \u03b1 _ 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 \u03b1 _ 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 : \u03b1} {s : Multiset \u03b1} : a \u2208 dedup s \u2194 a \u2208 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 : \u03b1} {s : Multiset \u03b1} : a \u2208 s \u2192 dedup (a ::\u2098 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 : \u03b1} {s : Multiset \u03b1} : a \u2209 s \u2192 dedup (a ::\u2098 s) = a ::\u2098 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Multiset.{u1} \u03b1), LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1))) (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (s : Multiset.{u1} \u03b1), LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1))) (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s) s\nCase conversion may be inaccurate. Consider using '#align multiset.dedup_le Multiset.dedup_le\u2093'. -/\ntheorem dedup_le (s : Multiset \u03b1) : dedup s \u2264 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 \u03b1) : dedup s \u2286 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 \u03b1) : s \u2286 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 \u03b1} : dedup s \u2286 t \u2194 s \u2286 t :=\n  \u27e8Subset.trans (subset_dedup _), Subset.trans (dedup_subset _)\u27e9\n#align multiset.dedup_subset' Multiset.dedup_subset'\n-/\n\n#print Multiset.subset_dedup' /-\n@[simp]\ntheorem subset_dedup' {s t : Multiset \u03b1} : s \u2286 dedup t \u2194 s \u2286 t :=\n  \u27e8fun h => Subset.trans h (dedup_subset _), fun h => Subset.trans h (subset_dedup _)\u27e9\n#align multiset.subset_dedup' Multiset.subset_dedup'\n-/\n\n#print Multiset.nodup_dedup /-\n@[simp]\ntheorem nodup_dedup (s : Multiset \u03b1) : 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 \u03b1} : dedup s = s \u2194 Nodup s :=\n  \u27e8fun e => e \u25b8 nodup_dedup s, Quot.inductionOn s fun l h => congr_arg coe h.dedup\u27e9\n#align multiset.dedup_eq_self Multiset.dedup_eq_self\n-/\n\nalias dedup_eq_self \u2194 _ nodup.dedup\n#align multiset.nodup.dedup Multiset.Nodup.dedup\n\n#print Multiset.count_dedup /-\ntheorem count_dedup (m : Multiset \u03b1) (a : \u03b1) : m.dedup.count a = if a \u2208 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 \u03b1} : 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 \u03b2] (m : Multiset \u03b1) (f : \u03b1 \u2192 Multiset \u03b2) :\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 \u03b1} : dedup s = 0 \u2194 s = 0 :=\n  \u27e8fun h => eq_zero_of_subset_zero <| h \u25b8 subset_dedup _, fun h => h.symm \u25b8 dedup_zero\u27e9\n#align multiset.dedup_eq_zero Multiset.dedup_eq_zero\n-/\n\n#print Multiset.dedup_singleton /-\n@[simp]\ntheorem dedup_singleton {a : \u03b1} : dedup ({a} : Multiset \u03b1) = {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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Multiset.{u1} \u03b1} {t : Multiset.{u1} \u03b1}, Iff (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1))) s (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t)) (And (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1))) s t) (Multiset.Nodup.{u1} \u03b1 s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Multiset.{u1} \u03b1} {t : Multiset.{u1} \u03b1}, Iff (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1))) s (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t)) (And (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1))) s t) (Multiset.Nodup.{u1} \u03b1 s))\nCase conversion may be inaccurate. Consider using '#align multiset.le_dedup Multiset.le_dedup\u2093'. -/\ntheorem le_dedup {s t : Multiset \u03b1} : s \u2264 dedup t \u2194 s \u2264 t \u2227 Nodup s :=\n  \u27e8fun h => \u27e8le_trans h (dedup_le _), nodup_of_le h (nodup_dedup _)\u27e9, fun \u27e8l, d\u27e9 =>\n    (le_iff_subset d).2 <| Subset.trans (subset_of_le l) (subset_dedup _)\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Multiset.{u1} \u03b1}, Iff (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1))) s (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)) (Multiset.Nodup.{u1} \u03b1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Multiset.{u1} \u03b1}, Iff (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1))) s (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s)) (Multiset.Nodup.{u1} \u03b1 s)\nCase conversion may be inaccurate. Consider using '#align multiset.le_dedup_self Multiset.le_dedup_self\u2093'. -/\ntheorem le_dedup_self {s : Multiset \u03b1} : s \u2264 dedup s \u2194 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 \u03b1} : dedup s = dedup t \u2194 \u2200 a, a \u2208 s \u2194 a \u2208 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 \u03b2] (f : \u03b1 \u2192 \u03b2) (s : Multiset \u03b1) :\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Multiset.{u1} \u03b1} {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} \u03b1) (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (SMul.smul.{0, u1} Nat (Multiset.{u1} \u03b1) (AddMonoid.SMul.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) n s)) (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Multiset.{u1} \u03b1} {n : Nat}, (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{succ u1} (Multiset.{u1} \u03b1) (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (HSMul.hSMul.{0, u1, u1} Nat (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (instHSMul.{0, u1} Nat (Multiset.{u1} \u03b1) (AddMonoid.SMul.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) n s)) (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s))\nCase conversion may be inaccurate. Consider using '#align multiset.dedup_nsmul Multiset.dedup_nsmul\u2093'. -/\n@[simp]\ntheorem dedup_nsmul {s : Multiset \u03b1} {n : \u2115} (h0 : n \u2260 0) : (n \u2022 s).dedup = s.dedup :=\n  by\n  ext a\n  by_cases h : a \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Multiset.{u1} \u03b1} {t : Multiset.{u1} \u03b1}, (Multiset.Nodup.{u1} \u03b1 s) -> (Iff (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1))) s (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t)) (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1))) s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Multiset.{u1} \u03b1} {t : Multiset.{u1} \u03b1}, (Multiset.Nodup.{u1} \u03b1 s) -> (Iff (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1))) s (Multiset.dedup.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) t)) (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1))) s t))\nCase conversion may be inaccurate. Consider using '#align multiset.nodup.le_dedup_iff_le Multiset.Nodup.le_dedup_iff_le\u2093'. -/\ntheorem Nodup.le_dedup_iff_le {s t : Multiset \u03b1} (hno : s.Nodup) : s \u2264 t.dedup \u2194 s \u2264 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 {\u03b1 : Type.{u1}} {s : Multiset.{u1} \u03b1} {t : Multiset.{u1} \u03b1} {n : Nat}, (Multiset.Nodup.{u1} \u03b1 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} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1))) s (SMul.smul.{0, u1} Nat (Multiset.{u1} \u03b1) (AddMonoid.SMul.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) n t)) (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1))) s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Multiset.{u1} \u03b1} {t : Multiset.{u1} \u03b1} {n : Nat}, (Multiset.Nodup.{u1} \u03b1 s) -> (Ne.{1} Nat n (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Iff (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1))) s (HSMul.hSMul.{0, u1, u1} Nat (Multiset.{u1} \u03b1) (Multiset.{u1} \u03b1) (instHSMul.{0, u1} Nat (Multiset.{u1} \u03b1) (AddMonoid.SMul.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) n t)) (LE.le.{u1} (Multiset.{u1} \u03b1) (Preorder.toLE.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1))) s t))\nCase conversion may be inaccurate. Consider using '#align multiset.nodup.le_nsmul_iff_le Multiset.Nodup.le_nsmul_iff_le\u2093'. -/\ntheorem Multiset.Nodup.le_nsmul_iff_le {\u03b1 : Type _} {s t : Multiset \u03b1} {n : \u2115} (h : s.Nodup)\n    (hn : n \u2260 0) : s \u2264 n \u2022 t \u2194 s \u2264 t := by\n  classical\n    rw [\u2190 h.le_dedup_iff_le, Iff.comm, \u2190 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 : \u2200 {x : F}, x \u2208 S \u2192 x\u207b\u00b9 \u2208 S\n#align is_subfield IsSubfield\n\ntheorem IsSubfield.div_mem {S : Set F} (hS : IsSubfield S) {x y : F} (hx : x \u2208 S) (hy : y \u2208 S) :\n    x / y \u2208 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 : \u2124} {s : Set F} (hs : IsSubfield s) (h : a \u2208 s) :\n    a ^ n \u2208 s := by\n  cases' n with n n\n  \u00b7 suffices a ^ (n : \u2124) \u2208 s by exact this\n    rw [zpow_ofNat]\n    exact hs.toIsSubring.toIsSubmonoid.pow_mem h\n  \u00b7 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 _ \u21a6 trivial }\n#align univ.is_subfield Univ.isSubfield\n\ntheorem Preimage.isSubfield {K : Type _} [Field K] (f : F \u2192+* K) {s : Set K} (hs : IsSubfield s) :\n    IsSubfield (f \u207b\u00b9' s) :=\n  { f.isSubring_preimage hs.toIsSubring with\n    inv_mem := fun {a} (ha : f a \u2208 s) \u21a6 show f a\u207b\u00b9 \u2208 s by\n      rw [map_inv\u2080]\n      exact hs.inv_mem ha }\n#align preimage.is_subfield Preimage.isSubfield\n\ntheorem Image.isSubfield {K : Type _} [Field K] (f : F \u2192+* K) {s : Set F} (hs : IsSubfield s) :\n    IsSubfield (f '' s) :=\n  { f.isSubring_image hs.toIsSubring with\n    inv_mem := fun \u27e8x, xmem, ha\u27e9 \u21a6 \u27e8x\u207b\u00b9, hs.inv_mem xmem, ha \u25b8 map_inv\u2080 f x\u27e9 }\n#align image.is_subfield Image.isSubfield\n\ntheorem Range.isSubfield {K : Type _} [Field K] (f : F \u2192+* K) : IsSubfield (Set.range f) := by\n  rw [\u2190 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 | \u2203 y \u2208 Ring.closure S, \u2203 z \u2208 Ring.closure S, y / z = x }\n#align field.closure Field.closure\n\nvariable {S}\n\ntheorem ring_closure_subset : Ring.closure S \u2286 closure S :=\n  fun x hx \u21a6 \u27e8x, hx, 1, Ring.closure.isSubring.toIsSubmonoid.one_mem, div_one x\u27e9\n#align field.ring_closure_subset Field.ring_closure_subset\n\ntheorem closure.isSubmonoid : IsSubmonoid (closure S) :=\n  { mul_mem := by\n      rintro _ _ \u27e8p, hp, q, hq, hq0, rfl\u27e9 \u27e8r, hr, s, hs, hs0, rfl\u27e9\n      exact \u27e8p * 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\u27e9\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 \u27e8p, hp, q, hq, rfl\u27e9\n      rcases id hb with \u27e8r, hr, s, hs, rfl\u27e9\n      by_cases hq0 : q = 0\n      \u00b7 rwa [hq0, div_zero, zero_add]\n      by_cases hs0 : s = 0\n      \u00b7 rwa [hs0, div_zero, add_zero]\n      exact \u27e8p * 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\u27e9\n    zero_mem := ring_closure_subset Ring.closure.isSubring.toIsAddSubgroup.toIsAddSubmonoid.zero_mem\n    neg_mem := by\n      rintro _ \u27e8p, hp, q, hq, rfl\u27e9\n      exact \u27e8-p, Ring.closure.isSubring.toIsAddSubgroup.neg_mem hp, q, hq, neg_div q p\u27e9\n    inv_mem := by\n      rintro _ \u27e8p, hp, q, hq, rfl\u27e9\n      exact \u27e8q, hq, p, hp, (inv_div _ _).symm\u27e9 }\n#align field.closure.is_subfield Field.closure.isSubfield\n\ntheorem mem_closure {a : F} (ha : a \u2208 S) : a \u2208 closure S :=\n  ring_closure_subset <| Ring.mem_closure ha\n#align field.mem_closure Field.mem_closure\n\ntheorem subset_closure : S \u2286 closure S :=\n  fun _ \u21a6 mem_closure\n#align field.subset_closure Field.subset_closure\n\ntheorem closure_subset {T : Set F} (hT : IsSubfield T) (H : S \u2286 T) : closure S \u2286 T := by\n  rintro _ \u27e8p, hp, q, hq, hq0, rfl\u27e9\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 \u2286 t \u2194 s \u2286 t :=\n  \u27e8Set.Subset.trans subset_closure, closure_subset ht\u27e9\n#align field.closure_subset_iff Field.closure_subset_iff\n\ntheorem closure_mono {s t : Set F} (H : s \u2286 t) : closure s \u2286 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\u1d62_of_directed {\u03b9 : Type _} [Nonempty \u03b9] {s : \u03b9 \u2192 Set F}\n    (hs : \u2200 i, IsSubfield (s i)) (directed : \u2200 i j, \u2203 k, s i \u2286 s k \u2227 s j \u2286 s k) :\n    IsSubfield (\u22c3 i, s i) :=\n  { inv_mem := fun hx \u21a6\n      let \u27e8i, hi\u27e9 := Set.mem_union\u1d62.1 hx\n      Set.mem_union\u1d62.2 \u27e8i, (hs i).inv_mem hi\u27e9\n    toIsSubring := isSubring_union\u1d62_of_directed (fun i \u21a6 (hs i).toIsSubring) directed }\n#align is_subfield_Union_of_directed isSubfield_union\u1d62_of_directed\n\ntheorem IsSubfield.inter {S\u2081 S\u2082 : Set F} (hS\u2081 : IsSubfield S\u2081) (hS\u2082 : IsSubfield S\u2082) :\n    IsSubfield (S\u2081 \u2229 S\u2082) :=\n  { IsSubring.inter hS\u2081.toIsSubring hS\u2082.toIsSubring with\n    inv_mem := fun hx \u21a6 \u27e8hS\u2081.inv_mem hx.1, hS\u2082.inv_mem hx.2\u27e9 }\n#align is_subfield.inter IsSubfield.inter\n\ntheorem IsSubfield.inter\u1d62 {\u03b9 : Sort _} {S : \u03b9 \u2192 Set F} (h : \u2200 y : \u03b9, IsSubfield (S y)) :\n    IsSubfield (Set.inter\u1d62 S) :=\n  { IsSubring.inter\u1d62 fun y \u21a6 (h y).toIsSubring with\n    inv_mem := fun hx \u21a6 Set.mem_inter\u1d62.2 fun y \u21a6 (h y).inv_mem <| Set.mem_inter\u1d62.1 hx y }\n#align is_subfield.Inter IsSubfield.inter\u1d62\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 \u2190 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 \u2190 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 \u2190 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 \u2190 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              := \u03bb a b, up (down a + down b),\n--   neg              := \u03bb a, up (- down a),\n--   one              := up 1,\n--   mul              := \u03bb a b, up (down a * down b),\n--   inv              := \u03bb a, up ((down a)\u207b\u00b9),\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 : \u2200 p : polynomial k, p.monic \u2192 irreducible p \u2192 nat_degree p \u2260 0 \u2192 \u2203 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 \u27e8 1 , rfl \u27e9,\n  },\n  apply H p hmonic hirr hdeg,\nend\n\nlemma of_nat_degree_ne_zero_exists_root {k : Type*} [field k]\n  (H : \u2200 p : polynomial k, nat_degree p \u2260 0 \u2192 \u2203 x, p.eval x = 0) :\n  is_alg_closed k :=\nof_exists_root_nat_degree $ \u03bb _ _ hdeg, H _\n\nend is_alg_closed\n\nnamespace algebraic_closure\n\nsection zmod\n\nvariables (p : \u2115) [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) \u2192+* (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 {\u03b1 \u03b2 : Type _}\n\nnamespace Nat\n\n#print Nat.castAddMonoidHom /-\n/-- `coe : \u2115 \u2192 \u03b1` as an `add_monoid_hom`. -/\ndef castAddMonoidHom (\u03b1 : Type _) [AddMonoidWithOne \u03b1] : \u2115 \u2192+ \u03b1\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 {\u03b1 : Type.{u1}} [_inst_1 : AddMonoidWithOne.{u1} \u03b1], Eq.{succ u1} ((fun (_x : AddMonoidHom.{0, u1} Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))) => Nat -> \u03b1) (Nat.castAddMonoidHom.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{0, u1} Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))) (fun (_x : AddMonoidHom.{0, u1} Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))) => Nat -> \u03b1) (AddMonoidHom.hasCoeToFun.{0, u1} Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))) (Nat.castAddMonoidHom.{u1} \u03b1 _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : AddMonoidWithOne.{u1} \u03b1], Eq.{succ u1} (forall (a : Nat), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => \u03b1) a) (FunLike.coe.{succ u1, 1, succ u1} (AddMonoidHom.{0, u1} Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))) Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Nat) => \u03b1) _x) (AddHomClass.toFunLike.{u1, 0, u1} (AddMonoidHom.{0, u1} Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))) Nat \u03b1 (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddZeroClass.toAdd.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))) (AddMonoidHomClass.toAddHomClass.{u1, 0, u1} (AddMonoidHom.{0, u1} Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))) Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1)) (AddMonoidHom.addMonoidHomClass.{0, u1} Nat \u03b1 (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 _inst_1))))) (Nat.castAddMonoidHom.{u1} \u03b1 _inst_1)) (Nat.cast.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align nat.coe_cast_add_monoid_hom Nat.coe_castAddMonoidHom\u2093'. -/\n@[simp]\ntheorem coe_castAddMonoidHom [AddMonoidWithOne \u03b1] : (castAddMonoidHom \u03b1 : \u2115 \u2192 \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] (m : Nat) (n : Nat), Eq.{succ u1} \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) m n)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))) m) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))) n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] (m : Nat) (n : Nat), Eq.{succ u1} \u03b1 (Nat.cast.{u1} \u03b1 (NonAssocSemiring.toNatCast.{u1} \u03b1 _inst_1) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) m n)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Nat.cast.{u1} \u03b1 (NonAssocSemiring.toNatCast.{u1} \u03b1 _inst_1) m) (Nat.cast.{u1} \u03b1 (NonAssocSemiring.toNatCast.{u1} \u03b1 _inst_1) n))\nCase conversion may be inaccurate. Consider using '#align nat.cast_mul Nat.cast_mul\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_mul [NonAssocSemiring \u03b1] (m n : \u2115) : ((m * n : \u2115) : \u03b1) = 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 : \u2115 \u2192 \u03b1` as a `ring_hom` -/\ndef castRingHom (\u03b1 : Type _) [NonAssocSemiring \u03b1] : \u2115 \u2192+* \u03b1 :=\n  { castAddMonoidHom \u03b1 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1], Eq.{succ u1} ((fun (_x : RingHom.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) => Nat -> \u03b1) (Nat.castRingHom.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (RingHom.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) (fun (_x : RingHom.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) => Nat -> \u03b1) (RingHom.hasCoeToFun.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) (Nat.castRingHom.{u1} \u03b1 _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1], Eq.{succ u1} (forall (a : Nat), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Nat) => \u03b1) a) (FunLike.coe.{succ u1, 1, succ u1} (RingHom.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) Nat (fun (_x : Nat) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Nat) => \u03b1) _x) (MulHomClass.toFunLike.{u1, 0, u1} (RingHom.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) Nat \u03b1 (NonUnitalNonAssocSemiring.toMul.{0} Nat (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring))) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (NonUnitalRingHomClass.toMulHomClass.{u1, 0, u1} (RingHom.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) Nat \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{0} Nat (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1) (RingHomClass.toNonUnitalRingHomClass.{u1, 0, u1} (RingHom.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1) Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1 (RingHom.instRingHomClassRingHom.{0, u1} Nat \u03b1 (Semiring.toNonAssocSemiring.{0} Nat Nat.semiring) _inst_1)))) (Nat.castRingHom.{u1} \u03b1 _inst_1)) (Nat.cast.{u1} \u03b1 (NonAssocSemiring.toNatCast.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align nat.coe_cast_ring_hom Nat.coe_castRingHom\u2093'. -/\n@[simp]\ntheorem coe_castRingHom [NonAssocSemiring \u03b1] : (castRingHom \u03b1 : \u2115 \u2192 \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] (n : Nat) (x : \u03b1), Commute.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))) n) x\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] (n : Nat) (x : \u03b1), Commute.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (Nat.cast.{u1} \u03b1 (NonAssocSemiring.toNatCast.{u1} \u03b1 _inst_1) n) x\nCase conversion may be inaccurate. Consider using '#align nat.cast_commute Nat.cast_commute\u2093'. -/\ntheorem cast_commute [NonAssocSemiring \u03b1] (n : \u2115) (x : \u03b1) : Commute (\u2191n) 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] (n : Nat) (x : \u03b1), Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))) n) x) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)))) x ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))) n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] (n : Nat) (x : \u03b1), Eq.{succ u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Nat.cast.{u1} \u03b1 (NonAssocSemiring.toNatCast.{u1} \u03b1 _inst_1) n) x) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) x (Nat.cast.{u1} \u03b1 (NonAssocSemiring.toNatCast.{u1} \u03b1 _inst_1) n))\nCase conversion may be inaccurate. Consider using '#align nat.cast_comm Nat.cast_comm\u2093'. -/\ntheorem cast_comm [NonAssocSemiring \u03b1] (n : \u2115) (x : \u03b1) : (n : \u03b1) * 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] (x : \u03b1) (n : Nat), Commute.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) x ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] (x : \u03b1) (n : Nat), Commute.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) x (Nat.cast.{u1} \u03b1 (NonAssocSemiring.toNatCast.{u1} \u03b1 _inst_1) n)\nCase conversion may be inaccurate. Consider using '#align nat.commute_cast Nat.commute_cast\u2093'. -/\ntheorem commute_cast [NonAssocSemiring \u03b1] (x : \u03b1) (n : \u2115) : Commute x n :=\n  (n.cast_commute x).symm\n#align nat.commute_cast Nat.commute_cast\n\nsection OrderedSemiring\n\nvariable [OrderedSemiring \u03b1]\n\n#print Nat.mono_cast /-\n@[mono]\ntheorem mono_cast : Monotone (coe : \u2115 \u2192 \u03b1) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} \u03b1] (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))))) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} \u03b1] (n : Nat), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedSemiring.toPartialOrder.{u1} \u03b1 _inst_1))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1))))) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)) n)\nCase conversion may be inaccurate. Consider using '#align nat.cast_nonneg Nat.cast_nonneg\u2093'. -/\n@[simp]\ntheorem cast_nonneg (n : \u2115) : 0 \u2264 (n : \u03b1) :=\n  @Nat.cast_zero \u03b1 _ \u25b8 mono_cast (Nat.zero_le n)\n#align nat.cast_nonneg Nat.cast_nonneg\n\nsection Nontrivial\n\nvariable [Nontrivial \u03b1]\n\n/- warning: nat.cast_add_one_pos -> Nat.cast_add_one_pos is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} \u03b1] [_inst_2 : Nontrivial.{u1} \u03b1] (n : Nat), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))))) n) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} \u03b1] [_inst_2 : Nontrivial.{u1} \u03b1] (n : Nat), LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedSemiring.toPartialOrder.{u1} \u03b1 _inst_1))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1))))) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)) n) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (Semiring.toOne.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align nat.cast_add_one_pos Nat.cast_add_one_pos\u2093'. -/\ntheorem cast_add_one_pos (n : \u2115) : 0 < (n : \u03b1) + 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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} \u03b1] [_inst_2 : Nontrivial.{u1} \u03b1] {n : Nat}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 _inst_1)))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1)))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedSemiring.{u1} \u03b1] [_inst_2 : Nontrivial.{u1} \u03b1] {n : Nat}, Iff (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedSemiring.toPartialOrder.{u1} \u03b1 _inst_1))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _inst_1))))) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem cast_pos {n : \u2115} : (0 : \u03b1) < n \u2194 0 < n := by cases n <;> simp [cast_add_one_pos]\n#align nat.cast_pos Nat.cast_pos\n\nend Nontrivial\n\nvariable [CharZero \u03b1] {m n : \u2115}\n\n#print Nat.strictMono_cast /-\ntheorem strictMono_cast : StrictMono (coe : \u2115 \u2192 \u03b1) :=\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 : \u2115 \u2192 \u03b1` as an `order_embedding` -/\n@[simps (config := { fullyApplied := false })]\ndef castOrderEmbedding : \u2115 \u21aao \u03b1 :=\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 : \u03b1) \u2264 n \u2194 m \u2264 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 : \u03b1) < n \u2194 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 : \u03b1) \u2194 1 < n := by rw [\u2190 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 \u2264 (n : \u03b1) \u2194 1 \u2264 n := by rw [\u2190 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 : \u03b1) < 1 \u2194 n = 0 := by\n  rw [\u2190 cast_one, cast_lt, lt_succ_iff, \u2190 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 : \u03b1) \u2264 1 \u2194 n \u2264 1 := by rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1)))))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) _inst_2] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1))))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))] (m : Nat) (n : Nat), Eq.{succ u1} \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) m n)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 _inst_2) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))) m) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1)))))))))) n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedSemiring.toPartialOrder.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1))))) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _inst_1))))))) _inst_2] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Data.Nat.Cast.Basic._hyg.923 : \u03b1) (x._@.Mathlib.Data.Nat.Cast.Basic._hyg.925 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (OrderedSemiring.toSemiring.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Data.Nat.Cast.Basic._hyg.940 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedSemiring.toPartialOrder.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 _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} \u03b1 (Nat.cast.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toNatCast.{u1} \u03b1 _inst_1) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) m n)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 _inst_2) (Nat.cast.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toNatCast.{u1} \u03b1 _inst_1) m) (Nat.cast.{u1} \u03b1 (CanonicallyOrderedCommSemiring.toNatCast.{u1} \u03b1 _inst_1) n))\nCase conversion may be inaccurate. Consider using '#align nat.cast_tsub Nat.cast_tsub\u2093'. -/\n/-- A version of `nat.cast_sub` that works for `\u211d\u22650` and `\u211a\u22650`. Note that this proof doesn't work\nfor `\u2115\u221e` and `\u211d\u22650\u221e`, so we use type-specific lemmas for these types. -/\n@[simp, norm_cast]\ntheorem cast_tsub [CanonicallyOrderedCommSemiring \u03b1] [Sub \u03b1] [OrderedSub \u03b1]\n    [ContravariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] (m n : \u2115) : \u2191(m - n) = (m - n : \u03b1) :=\n  by\n  cases' le_total m n with h h\n  \u00b7 rw [tsub_eq_zero_of_le h, cast_zero, tsub_eq_zero_of_le]\n    exact mono_cast h\n  \u00b7 rcases le_iff_exists_add'.mp h with \u27e8m, rfl\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} \u03b1] {a : Nat} {b : Nat}, Eq.{succ u1} \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))))))))) (LinearOrder.min.{0} Nat Nat.linearOrder a b)) (LinearOrder.min.{u1} \u03b1 (LinearOrderedAddCommMonoid.toLinearOrder.{u1} \u03b1 (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} \u03b1 _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))))))))) a) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))))))))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} \u03b1] {a : Nat} {b : Nat}, Eq.{succ u1} \u03b1 (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))) (Min.min.{0} Nat instMinNat a b)) (Min.min.{u1} \u03b1 (LinearOrderedSemiring.toMin.{u1} \u03b1 _inst_1) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))) a) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))) b))\nCase conversion may be inaccurate. Consider using '#align nat.cast_min Nat.cast_min\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_min [LinearOrderedSemiring \u03b1] {a b : \u2115} : (\u2191(min a b) : \u03b1) = min a b :=\n  (@mono_cast \u03b1 _).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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} \u03b1] {a : Nat} {b : Nat}, Eq.{succ u1} \u03b1 ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))))))))) (LinearOrder.max.{0} Nat Nat.linearOrder a b)) (LinearOrder.max.{u1} \u03b1 (LinearOrderedAddCommMonoid.toLinearOrder.{u1} \u03b1 (LinearOrderedSemiring.toLinearOrderedAddCommMonoid.{u1} \u03b1 _inst_1)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))))))))) a) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))))))))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedSemiring.{u1} \u03b1] {a : Nat} {b : Nat}, Eq.{succ u1} \u03b1 (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))) (Max.max.{0} Nat Nat.instMaxNat a b)) (Max.max.{u1} \u03b1 (LinearOrderedSemiring.toMax.{u1} \u03b1 _inst_1) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))) a) (Nat.cast.{u1} \u03b1 (Semiring.toNatCast.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 _inst_1))) b))\nCase conversion may be inaccurate. Consider using '#align nat.cast_max Nat.cast_max\u2093'. -/\n@[simp, norm_cast]\ntheorem cast_max [LinearOrderedSemiring \u03b1] {a b : \u2115} : (\u2191(max a b) : \u03b1) = max a b :=\n  (@mono_cast \u03b1 _).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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} \u03b1] (a : Nat), Eq.{succ u1} \u03b1 (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 _inst_1))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 _inst_1))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 _inst_1))))))))) a)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 _inst_1))))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedRing.{u1} \u03b1] (a : Nat), Eq.{succ u1} \u03b1 (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 _inst_1))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 _inst_1)))))) (Nat.cast.{u1} \u03b1 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 _inst_1)))) a)) (Nat.cast.{u1} \u03b1 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 _inst_1)))) a)\nCase conversion may be inaccurate. Consider using '#align nat.abs_cast Nat.abs_cast\u2093'. -/\n@[simp, norm_cast]\ntheorem abs_cast [LinearOrderedRing \u03b1] (a : \u2115) : |(a : \u03b1)| = 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 \u03b1] {m n : \u2115} (h : m \u2223 n) : (m : \u03b1) \u2223 (n : \u03b1) :=\n  map_dvd (Nat.castRingHom \u03b1) h\n#align nat.coe_nat_dvd Nat.coe_nat_dvd\n-/\n\nalias coe_nat_dvd \u2190 _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'\u2093'. -/\ntheorem ext_nat' [AddMonoid A] [AddMonoidHomClass F \u2115 A] (f g : F) (h : f 1 = g 1) : f = g :=\n  FunLike.ext f g <| by\n    apply Nat.rec\n    \u00b7 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\u2093'. -/\n@[ext]\ntheorem AddMonoidHom.ext_nat [AddMonoid A] : \u2200 {f g : \u2115 \u2192+ A}, \u2200 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 \u2115 A] (f : F) (h1 : f 1 = 1) : \u2200 n : \u2115, 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    \u2200 n : \u2115, 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 \u2115 A] (f g : F) (h_pos : \u2200 {n : \u2115}, 0 < n \u2192 f n = g n) :\n    f = g := by\n  apply FunLike.ext\n  rintro (_ | n)\n  \u00b7 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\u2093'. -/\n@[ext]\ntheorem MonoidWithZeroHom.ext_nat : \u2200 {f g : \u2115 \u2192*\u2080 A}, (\u2200 {n : \u2115}, 0 < n \u2192 f n = g n) \u2192 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 \u2115 R] (f : F) : \u2200 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem map_natCast [RingHomClass F R S] (f : F) : \u2200 n : \u2115, 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 \u2115 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\u2093.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\u2093.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\u2093'. -/\ntheorem NeZero.nat_of_injective {n : \u2115} [h : NeZero (n : R)] [RingHomClass F R S] {f : F}\n    (hf : Function.Injective f) : NeZero (n : S) :=\n  \u27e8fun h => NeZero.natCast_ne n R <| hf <| by simpa only [map_natCast, map_zero] \u27e9\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\u2093.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\u2093.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\u2093'. -/\ntheorem NeZero.nat_of_neZero {R S} [Semiring R] [Semiring S] {F} [RingHomClass F R S] (f : F)\n    {n : \u2115} [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 : \u2115 \u2192+* 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 : \u2115) : \u2191n = 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 \u2115 = RingHom.id \u2115 :=\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 (\u2115 \u2192+* 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 {\u03c0 : \u03b1 \u2192 Type _} [\u2200 a, NatCast (\u03c0 a)]\n\ninstance : NatCast (\u2200 a, \u03c0 a) := by refine_struct { .. } <;> pi_instance_derive_field\n\n#print Pi.nat_apply /-\ntheorem nat_apply (n : \u2115) (a : \u03b1) : (n : \u2200 a, \u03c0 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 {\u03b1 : Type.{u1}} {\u03c0 : \u03b1 -> Type.{u2}} [_inst_1 : forall (a : \u03b1), NatCast.{u2} (\u03c0 a)] (n : Nat), Eq.{max (succ u1) (succ u2)} (forall (a : \u03b1), \u03c0 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 : \u03b1), \u03c0 a) (HasLiftT.mk.{1, max (succ u1) (succ u2)} Nat (forall (a : \u03b1), \u03c0 a) (CoeTC\u2093.coe.{1, max (succ u1) (succ u2)} Nat (forall (a : \u03b1), \u03c0 a) (Nat.castCoe.{max u1 u2} (forall (a : \u03b1), \u03c0 a) (Pi.hasNatCast.{u1, u2} \u03b1 (fun (a : \u03b1) => \u03c0 a) (fun (a : \u03b1) => _inst_1 a))))) n) (fun (_x : \u03b1) => (fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat (\u03c0 _x) (HasLiftT.mk.{1, succ u2} Nat (\u03c0 _x) (CoeTC\u2093.coe.{1, succ u2} Nat (\u03c0 _x) (Nat.castCoe.{u2} (\u03c0 _x) (_inst_1 _x)))) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03c0 : \u03b1 -> Type.{u1}} [_inst_1 : forall (a : \u03b1), NatCast.{u1} (\u03c0 a)] (n : Nat), Eq.{max (succ u2) (succ u1)} (forall (a : \u03b1), \u03c0 a) (Nat.cast.{max u2 u1} (forall (a : \u03b1), \u03c0 a) (Pi.natCast.{u2, u1} \u03b1 (fun (a : \u03b1) => \u03c0 a) (fun (a : \u03b1) => _inst_1 a)) n) (fun (_x : \u03b1) => Nat.cast.{u1} (\u03c0 _x) (_inst_1 _x) n)\nCase conversion may be inaccurate. Consider using '#align pi.coe_nat Pi.coe_nat\u2093'. -/\n@[simp]\ntheorem coe_nat (n : \u2115) : (n : \u2200 a, \u03c0 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : NatCast.{u3} \u03b3] (n : Nat), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Sum.elim.{u1, u2, succ u3} \u03b1 \u03b2 \u03b3 ((fun (a : Type) (b : Sort.{max (succ u1) (succ u3)}) [self : HasLiftT.{1, max (succ u1) (succ u3)} a b] => self.0) Nat (\u03b1 -> \u03b3) (HasLiftT.mk.{1, max (succ u1) (succ u3)} Nat (\u03b1 -> \u03b3) (CoeTC\u2093.coe.{1, max (succ u1) (succ u3)} Nat (\u03b1 -> \u03b3) (Nat.castCoe.{max u1 u3} (\u03b1 -> \u03b3) (Pi.hasNatCast.{u1, u3} \u03b1 (fun (\u1fb0 : \u03b1) => \u03b3) (fun (a : \u03b1) => _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 (\u03b2 -> \u03b3) (HasLiftT.mk.{1, max (succ u2) (succ u3)} Nat (\u03b2 -> \u03b3) (CoeTC\u2093.coe.{1, max (succ u2) (succ u3)} Nat (\u03b2 -> \u03b3) (Nat.castCoe.{max u2 u3} (\u03b2 -> \u03b3) (Pi.hasNatCast.{u2, u3} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b3) (fun (a : \u03b2) => _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} \u03b1 \u03b2) -> \u03b3) (HasLiftT.mk.{1, max (max (succ u1) (succ u2)) (succ u3)} Nat ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (CoeTC\u2093.coe.{1, max (max (succ u1) (succ u2)) (succ u3)} Nat ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Nat.castCoe.{max (max u1 u2) u3} ((Sum.{u1, u2} \u03b1 \u03b2) -> \u03b3) (Pi.hasNatCast.{max u1 u2, u3} (Sum.{u1, u2} \u03b1 \u03b2) (fun (\u1fb0 : Sum.{u1, u2} \u03b1 \u03b2) => \u03b3) (fun (a : Sum.{u1, u2} \u03b1 \u03b2) => _inst_1))))) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : NatCast.{u1} \u03b3] (n : Nat), Eq.{max (max (succ u3) (succ u2)) (succ u1)} ((Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) (Sum.elim.{u3, u2, succ u1} \u03b1 \u03b2 \u03b3 (Nat.cast.{max u3 u1} (\u03b1 -> \u03b3) (Pi.natCast.{u3, u1} \u03b1 (fun (a._@.Mathlib.Data.Nat.Cast.Basic._hyg.2266 : \u03b1) => \u03b3) (fun (a : \u03b1) => _inst_1)) n) (Nat.cast.{max u2 u1} (\u03b2 -> \u03b3) (Pi.natCast.{u2, u1} \u03b2 (fun (a._@.Mathlib.Data.Nat.Cast.Basic._hyg.2273 : \u03b2) => \u03b3) (fun (a : \u03b2) => _inst_1)) n)) (Nat.cast.{max (max u3 u2) u1} ((Sum.{u3, u2} \u03b1 \u03b2) -> \u03b3) (Pi.natCast.{max u3 u2, u1} (Sum.{u3, u2} \u03b1 \u03b2) (fun (a._@.Mathlib.Data.Sum.Basic._hyg.1871 : Sum.{u3, u2} \u03b1 \u03b2) => \u03b3) (fun (a : Sum.{u3, u2} \u03b1 \u03b2) => _inst_1)) n)\nCase conversion may be inaccurate. Consider using '#align sum.elim_nat_cast_nat_cast Sum.elim_natCast_natCast\u2093'. -/\ntheorem Sum.elim_natCast_natCast {\u03b1 \u03b2 \u03b3 : Type _} [NatCast \u03b3] (n : \u2115) :\n    Sum.elim (n : \u03b1 \u2192 \u03b3) (n : \u03b2 \u2192 \u03b3) = n :=\n  @Sum.elim_lam_const_lam_const \u03b1 \u03b2 \u03b3 n\n#align sum.elim_nat_cast_nat_cast Sum.elim_natCast_natCast\n\nnamespace Pi\n\nvariable {\u03c0 : \u03b1 \u2192 Type _} [\u2200 a, AddMonoidWithOne (\u03c0 a)]\n\ninstance : AddMonoidWithOne (\u2200 a, \u03c0 a) := by refine_struct { .. } <;> pi_instance_derive_field\n\nend Pi\n\n/-! ### Order dual -/\n\n\nopen OrderDual\n\ninstance [h : NatCast \u03b1] : NatCast \u03b1\u1d52\u1d48 :=\n  h\n\ninstance [h : AddMonoidWithOne \u03b1] : AddMonoidWithOne \u03b1\u1d52\u1d48 :=\n  h\n\ninstance [h : AddCommMonoidWithOne \u03b1] : AddCommMonoidWithOne \u03b1\u1d52\u1d48 :=\n  h\n\n#print toDual_natCast /-\n@[simp]\ntheorem toDual_natCast [NatCast \u03b1] (n : \u2115) : toDual (n : \u03b1) = n :=\n  rfl\n#align to_dual_nat_cast toDual_natCast\n-/\n\n#print ofDual_natCast /-\n@[simp]\ntheorem ofDual_natCast [NatCast \u03b1] (n : \u2115) : (ofDual n : \u03b1) = n :=\n  rfl\n#align of_dual_nat_cast ofDual_natCast\n-/\n\n/-! ### Lexicographic order -/\n\n\ninstance [h : NatCast \u03b1] : NatCast (Lex \u03b1) :=\n  h\n\ninstance [h : AddMonoidWithOne \u03b1] : AddMonoidWithOne (Lex \u03b1) :=\n  h\n\ninstance [h : AddCommMonoidWithOne \u03b1] : AddCommMonoidWithOne (Lex \u03b1) :=\n  h\n\n#print toLex_natCast /-\n@[simp]\ntheorem toLex_natCast [NatCast \u03b1] (n : \u2115) : toLex (n : \u03b1) = n :=\n  rfl\n#align to_lex_nat_cast toLex_natCast\n-/\n\n#print ofLex_natCast /-\n@[simp]\ntheorem ofLex_natCast [NatCast \u03b1] (n : \u2115) : (ofLex n : \u03b1) = 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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u22a3 F` between two functors `G : C \u2964 D`\nand `F : D \u2964 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 \u2964 D} {F : D \u2964 C}\n\nnamespace comm_sq\n\nsection\nvariables {A B : C} {X Y : D} {i : A \u27f6 B} {p : X \u27f6 Y} {u : G.obj A \u27f6 X} {v : G.obj B \u27f6 Y}\n  (sq : comm_sq u (G.map i) p v) (adj : G \u22a3 F)\n\ninclude sq\n\n/-- When we have an adjunction `G \u22a3 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\u27e8begin\n  simp only [adjunction.hom_equiv_unit, assoc, \u2190 F.map_comp, sq.w],\n  rw [F.map_comp, adjunction.unit_naturality_assoc],\nend\u27e9\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 \u2243 (sq.right_adjoint adj).lift_struct :=\n{ to_fun := \u03bb l,\n  { l := adj.hom_equiv _ _ l.l,\n    fac_left' := by rw [\u2190 adj.hom_equiv_naturality_left, l.fac_left],\n    fac_right' := by rw [\u2190 adjunction.hom_equiv_naturality_right, l.fac_right], },\n  inv_fun := \u03bb l,\n  { l := (adj.hom_equiv _ _).symm l.l,\n    fac_left' := begin\n      rw [\u2190 adjunction.hom_equiv_naturality_left_symm, l.fac_left],\n      apply (adj.hom_equiv _ _).left_inv,\n    end,\n    fac_right' := begin\n      rw [\u2190 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) \u2194 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 \u27f6 B} {p : X \u27f6 Y} {u : A \u27f6 F.obj X} {v : B \u27f6 F.obj Y}\n  (sq : comm_sq u i (F.map p) v) (adj : G \u22a3 F)\n\ninclude sq\n\n/-- When we have an adjunction `G \u22a3 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\u27e8begin\n  simp only [adjunction.hom_equiv_counit, assoc,\n    \u2190 G.map_comp_assoc, \u2190 sq.w],\n  rw [G.map_comp, assoc, adjunction.counit_naturality],\nend\u27e9\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 \u2243 (sq.left_adjoint adj).lift_struct :=\n{ to_fun := \u03bb l,\n  { l := (adj.hom_equiv _ _).symm l.l,\n    fac_left' := by rw [\u2190 adj.hom_equiv_naturality_left_symm, l.fac_left],\n    fac_right' := by rw [\u2190 adj.hom_equiv_naturality_right_symm, l.fac_right], },\n  inv_fun := \u03bb l,\n  { l := (adj.hom_equiv _ _) l.l,\n    fac_left' := begin\n      rw [\u2190 adj.hom_equiv_naturality_left, l.fac_left],\n      apply (adj.hom_equiv _ _).right_inv,\n    end,\n    fac_right' := begin\n      rw [\u2190 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) \u2194 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 \u22a3 F) {A B : C} {X Y : D} (i : A \u27f6 B) (p : X \u27f6 Y) :\n  has_lifting_property (G.map i) p \u2194 has_lifting_property i (F.map p) :=\nbegin\n  split; introI; constructor; intros f g sq,\n  { rw \u2190 sq.left_adjoint_has_lift_iff adj,\n    apply_instance, },\n  { rw \u2190 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 \u2964 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 \u2964 D) :=\n{ hom_group := \u03bb F G,\n  { add := \u03bb \u03b1 \u03b2,\n    { app := \u03bb X, \u03b1.app X + \u03b2.app X,\n      naturality' := by { intros, rw [comp_add, add_comp, \u03b1.naturality, \u03b2.naturality] } },\n    zero := { app := \u03bb X, 0, naturality' := by { intros, rw [zero_comp, comp_zero] } },\n    neg := \u03bb \u03b1,\n    { app := \u03bb X, -\u03b1.app X,\n      naturality' := by { intros, rw [comp_neg, neg_comp, \u03b1.naturality] } },\n    sub := \u03bb \u03b1 \u03b2,\n    { app := \u03bb X, \u03b1.app X - \u03b2.app X,\n      naturality' := by { intros, rw [comp_sub, sub_comp, \u03b1.naturality, \u03b2.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 \u2964 D}\n\n/-- Application of a natural transformation at a fixed object,\nas group homomorphism -/\n@[simps] def app_hom (X : C) : (F \u27f6 G) \u2192+ (F.obj X \u27f6 G.obj X) :=\n{ to_fun := \u03bb \u03b1, \u03b1.app X,\n  map_zero' := rfl,\n  map_add' := \u03bb _ _, rfl }\n\n@[simp] lemma app_zero (X : C) : (0 : F \u27f6 G).app X = 0 := rfl\n\n@[simp] \n\n@[simp] lemma app_sub (X : C) (\u03b1 \u03b2 : F \u27f6 G) : (\u03b1 - \u03b2).app X = \u03b1.app X - \u03b2.app X := rfl\n\n@[simp] lemma app_neg (X : C) (\u03b1 : F \u27f6 G) : (-\u03b1).app X = -\u03b1.app X := rfl\n\n@[simp] lemma app_nsmul (X : C) (\u03b1 : F \u27f6 G) (n : \u2115) : (n \u2022 \u03b1).app X = n \u2022 \u03b1.app X :=\n(app_hom X).map_nsmul \u03b1 n\n\n@[simp] lemma app_zsmul (X : C) (\u03b1 : F \u27f6 G) (n : \u2124) : (n \u2022 \u03b1).app X = n \u2022 \u03b1.app X :=\n(app_hom X : (F \u27f6 G) \u2192+ (F.obj X \u27f6 G.obj X)).map_zsmul \u03b1 n\n\n@[simp] lemma app_sum {\u03b9 : Type*} (s : finset \u03b9) (X : C) (\u03b1 : \u03b9 \u2192 (F \u27f6 G)) :\n  (\u2211 i in s, \u03b1 i).app X = \u2211 i in s, ((\u03b1 i).app X) :=\nby { rw [\u2190 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* `\u03b1 \u27f9 \u03b2`    - n-tuples of maps\n* `f \u229a g`     - composition\n\nAlso, support functions for operating with n-tuples of types, such as:\n\n* `append1 \u03b1 \u03b2`    - append type `\u03b2` to n-tuple `\u03b1` to obtain an (n+1)-tuple\n* `drop \u03b1`         - drops the last element of an (n+1)-tuple\n* `last \u03b1`         - 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 \u03b1.drop \u03b1.last` is propositionally equal to `\u03b1` 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 : \u2115) := fin2 n \u2192 Type u_1\n\nprotected instance typevec.inhabited {n : \u2115} : 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 : \u2115} (\u03b1 : typevec n) (\u03b2 : typevec n) := (i : fin2 n) \u2192 \u03b1 i \u2192 \u03b2 i\n\nprotected instance arrow.inhabited {n : \u2115} (\u03b1 : typevec n) (\u03b2 : typevec n)\n    [(i : fin2 n) \u2192 Inhabited (\u03b2 i)] : Inhabited (arrow \u03b1 \u03b2) :=\n  { default := fun (_x : fin2 n) (_x_1 : \u03b1 _x) => Inhabited.default }\n\n/-- identity of arrow composition -/\ndef id {n : \u2115} {\u03b1 : typevec n} : arrow \u03b1 \u03b1 := fun (i : fin2 n) (x : \u03b1 i) => x\n\n/-- arrow composition in the category of `typevec` -/\ndef comp {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} {\u03b3 : typevec n} (g : arrow \u03b2 \u03b3) (f : arrow \u03b1 \u03b2) :\n    arrow \u03b1 \u03b3 :=\n  fun (i : fin2 n) (x : \u03b1 i) => g i (f i x)\n\n@[simp] theorem id_comp {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} (f : arrow \u03b1 \u03b2) : comp id f = f :=\n  rfl\n\n@[simp] theorem comp_id {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} (f : arrow \u03b1 \u03b2) : comp f id = f :=\n  rfl\n\ntheorem comp_assoc {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} {\u03b3 : typevec n} {\u03b4 : typevec n}\n    (h : arrow \u03b3 \u03b4) (g : arrow \u03b2 \u03b3) (f : arrow \u03b1 \u03b2) : 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 : \u2115} (\u03b1 : typevec n) (\u03b2 : 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 : \u2115} (\u03b1 : typevec (n + 1)) : typevec n := fun (i : fin2 n) => \u03b1 (fin2.fs i)\n\n/-- take the last value of a `(n+1)-length` vector -/\ndef last {n : \u2115} (\u03b1 : typevec (n + 1)) := \u03b1 fin2.fz\n\nprotected instance last.inhabited {n : \u2115} (\u03b1 : typevec (n + 1)) [Inhabited (\u03b1 fin2.fz)] :\n    Inhabited (last \u03b1) :=\n  { default := Inhabited.default }\n\ntheorem drop_append1 {n : \u2115} {\u03b1 : typevec n} {\u03b2 : Type u_1} {i : fin2 n} : drop (\u03b1 ::: \u03b2) i = \u03b1 i :=\n  rfl\n\n@[simp] theorem drop_append1' {n : \u2115} {\u03b1 : typevec n} {\u03b2 : Type u_1} : drop (\u03b1 ::: \u03b2) = \u03b1 :=\n  funext fun (x : fin2 n) => drop_append1\n\ntheorem last_append1 {n : \u2115} {\u03b1 : typevec n} {\u03b2 : Type u_1} : last (\u03b1 ::: \u03b2) = \u03b2 := rfl\n\n@[simp] theorem append1_drop_last {n : \u2115} (\u03b1 : typevec (n + 1)) : drop \u03b1 ::: last \u03b1 = \u03b1 := sorry\n\n/-- cases on `(n+1)-length` vectors -/\ndef append1_cases {n : \u2115} {C : typevec (n + 1) \u2192 Sort u}\n    (H : (\u03b1 : typevec n) \u2192 (\u03b2 : Type u_1) \u2192 C (\u03b1 ::: \u03b2)) (\u03b3 : typevec (n + 1)) : C \u03b3 :=\n  eq.mpr sorry (H (drop \u03b3) (last \u03b3))\n\n@[simp] theorem append1_cases_append1 {n : \u2115} {C : typevec (n + 1) \u2192 Sort u}\n    (H : (\u03b1 : typevec n) \u2192 (\u03b2 : Type u_1) \u2192 C (\u03b1 ::: \u03b2)) (\u03b1 : typevec n) (\u03b2 : Type u_1) :\n    append1_cases H (\u03b1 ::: \u03b2) = H \u03b1 \u03b2 :=\n  rfl\n\n/-- append an arrow and a function for arbitrary source and target\ntype vectors -/\ndef split_fun {n : \u2115} {\u03b1 : typevec (n + 1)} {\u03b1' : typevec (n + 1)} (f : arrow (drop \u03b1) (drop \u03b1'))\n    (g : last \u03b1 \u2192 last \u03b1') : arrow \u03b1 \u03b1' :=\n  sorry\n\n/-- append an arrow and a function as well as their respective source\nand target types / typevecs -/\ndef append_fun {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : Type u_1} {\u03b2' : Type u_2}\n    (f : arrow \u03b1 \u03b1') (g : \u03b2 \u2192 \u03b2') : arrow (\u03b1 ::: \u03b2) (\u03b1' ::: \u03b2') :=\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 : \u2115} {\u03b1 : typevec (n + 1)} {\u03b2 : typevec (n + 1)} (f : arrow \u03b1 \u03b2) :\n    arrow (drop \u03b1) (drop \u03b2) :=\n  fun (i : fin2 n) => f (fin2.fs i)\n\n/-- split off the last function of an arrow -/\ndef last_fun {n : \u2115} {\u03b1 : typevec (n + 1)} {\u03b2 : typevec (n + 1)} (f : arrow \u03b1 \u03b2) :\n    last \u03b1 \u2192 last \u03b2 :=\n  f fin2.fz\n\n/-- arrow in the category of `0-length` vectors -/\ndef nil_fun {\u03b1 : typevec 0} {\u03b2 : typevec 0} : arrow \u03b1 \u03b2 := fun (i : fin2 0) => fin2.elim0 i\n\ntheorem eq_of_drop_last_eq {n : \u2115} {\u03b1 : typevec (n + 1)} {\u03b2 : typevec (n + 1)} {f : arrow \u03b1 \u03b2}\n    {g : arrow \u03b1 \u03b2} (h\u2080 : drop_fun f = drop_fun g) (h\u2081 : last_fun f = last_fun g) : f = g :=\n  sorry\n\n@[simp] theorem drop_fun_split_fun {n : \u2115} {\u03b1 : typevec (n + 1)} {\u03b1' : typevec (n + 1)}\n    (f : arrow (drop \u03b1) (drop \u03b1')) (g : last \u03b1 \u2192 last \u03b1') : drop_fun (split_fun f g) = f :=\n  rfl\n\n/-- turn an equality into an arrow -/\ndef arrow.mp {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} (h : \u03b1 = \u03b2) : arrow \u03b1 \u03b2 := sorry\n\n/-- turn an equality into an arrow, with reverse direction -/\ndef arrow.mpr {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} (h : \u03b1 = \u03b2) : arrow \u03b2 \u03b1 := sorry\n\n/-- decompose a vector into its prefix appended with its last element -/\ndef to_append1_drop_last {n : \u2115} {\u03b1 : typevec (n + 1)} : arrow \u03b1 (drop \u03b1 ::: last \u03b1) :=\n  arrow.mpr (append1_drop_last \u03b1)\n\n/-- stitch two bits of a vector back together -/\ndef from_append1_drop_last {n : \u2115} {\u03b1 : typevec (n + 1)} : arrow (drop \u03b1 ::: last \u03b1) \u03b1 :=\n  arrow.mp (append1_drop_last \u03b1)\n\n@[simp] theorem last_fun_split_fun {n : \u2115} {\u03b1 : typevec (n + 1)} {\u03b1' : typevec (n + 1)}\n    (f : arrow (drop \u03b1) (drop \u03b1')) (g : last \u03b1 \u2192 last \u03b1') : last_fun (split_fun f g) = g :=\n  rfl\n\n@[simp] theorem drop_fun_append_fun {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : Type u_1}\n    {\u03b2' : Type u_2} (f : arrow \u03b1 \u03b1') (g : \u03b2 \u2192 \u03b2') : drop_fun (f ::: g) = f :=\n  rfl\n\n@[simp] theorem last_fun_append_fun {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : Type u_1}\n    {\u03b2' : Type u_2} (f : arrow \u03b1 \u03b1') (g : \u03b2 \u2192 \u03b2') : last_fun (f ::: g) = g :=\n  rfl\n\ntheorem split_drop_fun_last_fun {n : \u2115} {\u03b1 : typevec (n + 1)} {\u03b1' : typevec (n + 1)}\n    (f : arrow \u03b1 \u03b1') : split_fun (drop_fun f) (last_fun f) = f :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem split_fun_inj {n : \u2115} {\u03b1 : typevec (n + 1)} {\u03b1' : typevec (n + 1)}\n    {f : arrow (drop \u03b1) (drop \u03b1')} {f' : arrow (drop \u03b1) (drop \u03b1')} {g : last \u03b1 \u2192 last \u03b1'}\n    {g' : last \u03b1 \u2192 last \u03b1'} (H : split_fun f g = split_fun f' g') : f = f' \u2227 g = g' :=\n  sorry\n\ntheorem append_fun_inj {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : Type u_1} {\u03b2' : Type u_2}\n    {f : arrow \u03b1 \u03b1'} {f' : arrow \u03b1 \u03b1'} {g : \u03b2 \u2192 \u03b2'} {g' : \u03b2 \u2192 \u03b2'} :\n    f ::: g = f' ::: g' \u2192 f = f' \u2227 g = g' :=\n  split_fun_inj\n\ntheorem split_fun_comp {n : \u2115} {\u03b1\u2080 : typevec (n + 1)} {\u03b1\u2081 : typevec (n + 1)} {\u03b1\u2082 : typevec (n + 1)}\n    (f\u2080 : arrow (drop \u03b1\u2080) (drop \u03b1\u2081)) (f\u2081 : arrow (drop \u03b1\u2081) (drop \u03b1\u2082)) (g\u2080 : last \u03b1\u2080 \u2192 last \u03b1\u2081)\n    (g\u2081 : last \u03b1\u2081 \u2192 last \u03b1\u2082) :\n    split_fun (comp f\u2081 f\u2080) (g\u2081 \u2218 g\u2080) = comp (split_fun f\u2081 g\u2081) (split_fun f\u2080 g\u2080) :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem append_fun_comp_split_fun {n : \u2115} {\u03b1 : typevec n} {\u03b3 : typevec n} {\u03b2 : Type u_1}\n    {\u03b4 : Type u_2} {\u03b5 : typevec (n + 1)} (f\u2080 : arrow (drop \u03b5) \u03b1) (f\u2081 : arrow \u03b1 \u03b3) (g\u2080 : last \u03b5 \u2192 \u03b2)\n    (g\u2081 : \u03b2 \u2192 \u03b4) : comp (f\u2081 ::: g\u2081) (split_fun f\u2080 g\u2080) = split_fun (comp f\u2081 f\u2080) (g\u2081 \u2218 g\u2080) :=\n  Eq.symm (split_fun_comp f\u2080 f\u2081 g\u2080 g\u2081)\n\ntheorem append_fun_comp {n : \u2115} {\u03b1\u2080 : typevec n} {\u03b1\u2081 : typevec n} {\u03b1\u2082 : typevec n} {\u03b2\u2080 : Type u_1}\n    {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3} (f\u2080 : arrow \u03b1\u2080 \u03b1\u2081) (f\u2081 : arrow \u03b1\u2081 \u03b1\u2082) (g\u2080 : \u03b2\u2080 \u2192 \u03b2\u2081)\n    (g\u2081 : \u03b2\u2081 \u2192 \u03b2\u2082) : comp f\u2081 f\u2080 ::: g\u2081 \u2218 g\u2080 = comp (f\u2081 ::: g\u2081) (f\u2080 ::: g\u2080) :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem append_fun_comp' {n : \u2115} {\u03b1\u2080 : typevec n} {\u03b1\u2081 : typevec n} {\u03b1\u2082 : typevec n} {\u03b2\u2080 : Type u_1}\n    {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3} (f\u2080 : arrow \u03b1\u2080 \u03b1\u2081) (f\u2081 : arrow \u03b1\u2081 \u03b1\u2082) (g\u2080 : \u03b2\u2080 \u2192 \u03b2\u2081)\n    (g\u2081 : \u03b2\u2081 \u2192 \u03b2\u2082) : comp (f\u2081 ::: g\u2081) (f\u2080 ::: g\u2080) = comp f\u2081 f\u2080 ::: g\u2081 \u2218 g\u2080 :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem nil_fun_comp {\u03b1\u2080 : typevec 0} (f\u2080 : arrow \u03b1\u2080 fin2.elim0) : comp nil_fun f\u2080 = f\u2080 :=\n  funext fun (x : fin2 0) => fin2.elim0 x\n\ntheorem append_fun_comp_id {n : \u2115} {\u03b1 : typevec n} {\u03b2\u2080 : Type u_1} {\u03b2\u2081 : Type u_1} {\u03b2\u2082 : Type u_1}\n    (g\u2080 : \u03b2\u2080 \u2192 \u03b2\u2081) (g\u2081 : \u03b2\u2081 \u2192 \u03b2\u2082) : id ::: g\u2081 \u2218 g\u2080 = comp (id ::: g\u2081) (id ::: g\u2080) :=\n  eq_of_drop_last_eq rfl rfl\n\n@[simp] theorem drop_fun_comp {n : \u2115} {\u03b1\u2080 : typevec (n + 1)} {\u03b1\u2081 : typevec (n + 1)}\n    {\u03b1\u2082 : typevec (n + 1)} (f\u2080 : arrow \u03b1\u2080 \u03b1\u2081) (f\u2081 : arrow \u03b1\u2081 \u03b1\u2082) :\n    drop_fun (comp f\u2081 f\u2080) = comp (drop_fun f\u2081) (drop_fun f\u2080) :=\n  rfl\n\n@[simp] theorem last_fun_comp {n : \u2115} {\u03b1\u2080 : typevec (n + 1)} {\u03b1\u2081 : typevec (n + 1)}\n    {\u03b1\u2082 : typevec (n + 1)} (f\u2080 : arrow \u03b1\u2080 \u03b1\u2081) (f\u2081 : arrow \u03b1\u2081 \u03b1\u2082) :\n    last_fun (comp f\u2081 f\u2080) = last_fun f\u2081 \u2218 last_fun f\u2080 :=\n  rfl\n\ntheorem append_fun_aux {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : Type u_1} {\u03b2' : Type u_2}\n    (f : arrow (\u03b1 ::: \u03b2) (\u03b1' ::: \u03b2')) : drop_fun f ::: last_fun f = f :=\n  eq_of_drop_last_eq rfl rfl\n\ntheorem append_fun_id_id {n : \u2115} {\u03b1 : typevec n} {\u03b2 : 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 {\u03b2 : typevec 0 \u2192 Sort u_2} (f : \u03b2 fin2.elim0) (v : typevec 0) : \u03b2 v :=\n  cast sorry f\n\n/-- cases distinction for (n+1)-length type vector -/\nprotected def cases_cons (n : \u2115) {\u03b2 : typevec (n + 1) \u2192 Sort u_2}\n    (f : (t : Type u_1) \u2192 (v : typevec n) \u2192 \u03b2 (v ::: t)) (v : typevec (n + 1)) : \u03b2 v :=\n  cast sorry (f (last v) (drop v))\n\nprotected theorem cases_nil_append1 {\u03b2 : typevec 0 \u2192 Sort u_2} (f : \u03b2 fin2.elim0) :\n    typevec.cases_nil f fin2.elim0 = f :=\n  rfl\n\nprotected theorem cases_cons_append1 (n : \u2115) {\u03b2 : typevec (n + 1) \u2192 Sort u_2}\n    (f : (t : Type u_1) \u2192 (v : typevec n) \u2192 \u03b2 (v ::: t)) (v : typevec n) (\u03b1 : Type u_1) :\n    typevec.cases_cons n f (v ::: \u03b1) = f \u03b1 v :=\n  rfl\n\n/-- cases distinction for an arrow in the category of 0-length type vectors -/\ndef typevec_cases_nil\u2083 {\u03b2 : (v : typevec 0) \u2192 (v' : typevec 0) \u2192 arrow v v' \u2192 Sort u_3}\n    (f : \u03b2 fin2.elim0 fin2.elim0 nil_fun) (v : typevec 0) (v' : typevec 0) (fs : arrow v v') :\n    \u03b2 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\u2083 (n : \u2115)\n    {\u03b2 : (v : typevec (n + 1)) \u2192 (v' : typevec (n + 1)) \u2192 arrow v v' \u2192 Sort u_3}\n    (F :\n      (t : Type u_1) \u2192\n        (t' : Type u_2) \u2192\n          (f : t \u2192 t') \u2192\n            (v : typevec n) \u2192\n              (v' : typevec n) \u2192 (fs : arrow v v') \u2192 \u03b2 (v ::: t) (v' ::: t') (fs ::: f))\n    (v : typevec (n + 1)) (v' : typevec (n + 1)) (fs : arrow v v') : \u03b2 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\u2082 {\u03b2 : arrow fin2.elim0 fin2.elim0 \u2192 Sort u_3} (f : \u03b2 nil_fun) :\n    (f : arrow fin2.elim0 fin2.elim0) \u2192 \u03b2 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\u2082 (n : \u2115) (t : Type u_1) (t' : Type u_2) (v : typevec n) (v' : typevec n)\n    {\u03b2 : arrow (v ::: t) (v' ::: t') \u2192 Sort u_3}\n    (F : (f : t \u2192 t') \u2192 (fs : arrow v v') \u2192 \u03b2 (fs ::: f)) (fs : arrow (v ::: t) (v' ::: t')) :\n    \u03b2 fs :=\n  eq.mpr sorry (F (last_fun fs) (drop_fun fs))\n\ntheorem typevec_cases_nil\u2082_append_fun {\u03b2 : arrow fin2.elim0 fin2.elim0 \u2192 Sort u_3} (f : \u03b2 nil_fun) :\n    typevec_cases_nil\u2082 f nil_fun = f :=\n  rfl\n\ntheorem typevec_cases_cons\u2082_append_fun (n : \u2115) (t : Type u_1) (t' : Type u_2) (v : typevec n)\n    (v' : typevec n) {\u03b2 : arrow (v ::: t) (v' ::: t') \u2192 Sort u_3}\n    (F : (f : t \u2192 t') \u2192 (fs : arrow v v') \u2192 \u03b2 (fs ::: f)) (f : t \u2192 t') (fs : arrow v v') :\n    typevec_cases_cons\u2082 n t t' v v' F (fs ::: f) = F f fs :=\n  rfl\n\n/- for lifting predicates and relations -/\n\n/-- `pred_last \u03b1 p x` predicates `p` of the last element of `x : \u03b1.append1 \u03b2`. -/\ndef pred_last {n : \u2115} (\u03b1 : typevec n) {\u03b2 : Type u_1} (p : \u03b2 \u2192 Prop) {i : fin2 (n + 1)} :\n    append1 \u03b1 \u03b2 i \u2192 Prop :=\n  sorry\n\n/-- `rel_last \u03b1 r x y` says that `p` the last elements of `x y : \u03b1.append1 \u03b2` are related by `r` and\nall the other elements are equal. -/\ndef rel_last {n : \u2115} (\u03b1 : typevec n) {\u03b2 : Type u_1} {\u03b3 : Type u_1} (r : \u03b2 \u2192 \u03b3 \u2192 Prop)\n    {i : fin2 (n + 1)} : append1 \u03b1 \u03b2 i \u2192 append1 \u03b1 \u03b3 i \u2192 Prop :=\n  sorry\n\n/-- `repeat n t` is a `n-length` type vector that contains `n` occurences of `t` -/\ndef repeat (n : \u2115) (t : Type u_1) : typevec n := sorry\n\n/-- `prod \u03b1 \u03b2` is the pointwise product of the components of `\u03b1` and `\u03b2` -/\ndef prod {n : \u2115} (\u03b1 : typevec n) (\u03b2 : typevec n) : typevec n := sorry\n\n/-- `const x \u03b1` is an arrow that ignores its source and constructs a `typevec` that\ncontains nothing but `x` -/\nprotected def const {\u03b2 : Type u_1} (x : \u03b2) {n : \u2115} (\u03b1 : typevec n) : arrow \u03b1 (repeat n \u03b2) := sorry\n\n/-- vector of equality on a product of vectors -/\ndef repeat_eq {n : \u2115} (\u03b1 : typevec n) : arrow (prod \u03b1 \u03b1) (repeat n Prop) := sorry\n\ntheorem const_append1 {\u03b2 : Type u_1} {\u03b3 : Type u_2} (x : \u03b3) {n : \u2115} (\u03b1 : typevec n) :\n    typevec.const x (\u03b1 ::: \u03b2) = typevec.const x \u03b1 ::: fun (_x : \u03b2) => x :=\n  sorry\n\ntheorem eq_nil_fun {\u03b1 : typevec 0} {\u03b2 : typevec 0} (f : arrow \u03b1 \u03b2) : f = nil_fun := sorry\n\ntheorem id_eq_nil_fun {\u03b1 : typevec 0} : id = nil_fun := sorry\n\ntheorem const_nil {\u03b2 : Type u_1} (x : \u03b2) (\u03b1 : typevec 0) : typevec.const x \u03b1 = nil_fun := sorry\n\ntheorem repeat_eq_append1 {\u03b2 : Type u_1} {n : \u2115} (\u03b1 : typevec n) :\n    repeat_eq (\u03b1 ::: \u03b2) = split_fun (repeat_eq \u03b1) (function.uncurry Eq) :=\n  sorry\n\ntheorem repeat_eq_nil (\u03b1 : typevec 0) : repeat_eq \u03b1 = nil_fun := sorry\n\n/-- predicate on a type vector to constrain only the last object -/\ndef pred_last' {n : \u2115} (\u03b1 : typevec n) {\u03b2 : Type u_1} (p : \u03b2 \u2192 Prop) :\n    arrow (\u03b1 ::: \u03b2) (repeat (n + 1) Prop) :=\n  split_fun (typevec.const True \u03b1) p\n\n/-- predicate on the product of two type vectors to constrain only their last object -/\ndef rel_last' {n : \u2115} (\u03b1 : typevec n) {\u03b2 : Type u_1} (p : \u03b2 \u2192 \u03b2 \u2192 Prop) :\n    arrow (prod (\u03b1 ::: \u03b2) (\u03b1 ::: \u03b2)) (repeat (n + 1) Prop) :=\n  split_fun (repeat_eq \u03b1) (function.uncurry p)\n\n/-- given `F : typevec.{u} (n+1) \u2192 Type u`, `curry F : Type u \u2192 typevec.{u} \u2192 Type u`,\ni.e. its first argument can be fed in separately from the rest of the vector of arguments -/\ndef curry {n : \u2115} (F : typevec (n + 1) \u2192 Type u_1) (\u03b1 : Type u) (\u03b2 : typevec n) := F (\u03b2 ::: \u03b1)\n\nprotected instance curry.inhabited {n : \u2115} (F : typevec (n + 1) \u2192 Type u_1) (\u03b1 : Type u)\n    (\u03b2 : typevec n) [I : Inhabited (F (\u03b2 ::: \u03b1))] : Inhabited (curry F \u03b1 \u03b2) :=\n  I\n\n/-- arrow to remove one element of a `repeat` vector -/\ndef drop_repeat (\u03b1 : Type u_1) {n : \u2115} : arrow (drop (repeat (Nat.succ n) \u03b1)) (repeat n \u03b1) := sorry\n\n/-- projection for a repeat vector -/\ndef of_repeat {\u03b1 : Type u_1} {n : \u2115} {i : fin2 n} : repeat n \u03b1 i \u2192 \u03b1 := sorry\n\ntheorem const_iff_true {n : \u2115} {\u03b1 : typevec n} {i : fin2 n} {x : \u03b1 i} {p : Prop} :\n    of_repeat (typevec.const p \u03b1 i x) \u2194 p :=\n  sorry\n\n-- variables  {F : typevec.{u} n \u2192 Type*} [mvfunctor F]\n\n/-- left projection of a `prod` vector -/\ndef prod.fst {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} : arrow (prod \u03b1 \u03b2) \u03b1 := sorry\n\n/-- right projection of a `prod` vector -/\ndef prod.snd {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} : arrow (prod \u03b1 \u03b2) \u03b2 := sorry\n\n/-- introduce a product where both components are the same -/\ndef prod.diag {n : \u2115} {\u03b1 : typevec n} : arrow \u03b1 (prod \u03b1 \u03b1) := sorry\n\n/-- constructor for `prod` -/\ndef prod.mk {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} (i : fin2 n) : \u03b1 i \u2192 \u03b2 i \u2192 prod \u03b1 \u03b2 i := sorry\n\n@[simp] theorem prod_fst_mk {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} (i : fin2 n) (a : \u03b1 i)\n    (b : \u03b2 i) : prod.fst i (prod.mk i a b) = a :=\n  sorry\n\n@[simp] theorem prod_snd_mk {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} (i : fin2 n) (a : \u03b1 i)\n    (b : \u03b2 i) : prod.snd i (prod.mk i a b) = b :=\n  sorry\n\n/-- `prod` is functorial -/\nprotected def prod.map {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : typevec n} {\u03b2' : typevec n} :\n    arrow \u03b1 \u03b2 \u2192 arrow \u03b1' \u03b2' \u2192 arrow (prod \u03b1 \u03b1') (prod \u03b2 \u03b2') :=\n  sorry\n\ntheorem fst_prod_mk {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : typevec n} {\u03b2' : typevec n}\n    (f : arrow \u03b1 \u03b2) (g : arrow \u03b1' \u03b2') : comp prod.fst (prod.map f g) = comp f prod.fst :=\n  sorry\n\ntheorem snd_prod_mk {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : typevec n} {\u03b2' : typevec n}\n    (f : arrow \u03b1 \u03b2) (g : arrow \u03b1' \u03b2') : comp prod.snd (prod.map f g) = comp g prod.snd :=\n  sorry\n\ntheorem fst_diag {n : \u2115} {\u03b1 : typevec n} : comp prod.fst prod.diag = id := sorry\n\ntheorem snd_diag {n : \u2115} {\u03b1 : typevec n} : comp prod.snd prod.diag = id := sorry\n\ntheorem repeat_eq_iff_eq {n : \u2115} {\u03b1 : typevec n} {i : fin2 n} {x : \u03b1 i} {y : \u03b1 i} :\n    of_repeat (repeat_eq \u03b1 i (prod.mk i x y)) \u2194 x = y :=\n  sorry\n\n/-- given a predicate vector `p` over vector `\u03b1`, `subtype_ p` is the type of vectors\nthat contain an `\u03b1` that satisfies `p` -/\ndef subtype_ {n : \u2115} {\u03b1 : typevec n} (p : arrow \u03b1 (repeat n Prop)) : typevec n := sorry\n\n/-- projection on `subtype_` -/\ndef subtype_val {n : \u2115} {\u03b1 : typevec n} (p : arrow \u03b1 (repeat n Prop)) : arrow (subtype_ p) \u03b1 :=\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 : \u2115} {\u03b1 : typevec n} (p : arrow \u03b1 (repeat n Prop)) :\n    arrow (fun (i : fin2 n) => Subtype fun (x : \u03b1 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 : \u2115} {\u03b1 : typevec n} (p : arrow \u03b1 (repeat n Prop)) :\n    arrow (subtype_ p) fun (i : fin2 n) => Subtype fun (x : \u03b1 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 : \u2115} {\u03b1 : typevec n} (p : arrow (prod \u03b1 \u03b1) (repeat n Prop)) :\n    arrow\n        (fun (i : fin2 n) =>\n          Subtype fun (x : \u03b1 i \u00d7 \u03b1 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 : \u2115} {\u03b1 : typevec n} (p : arrow (prod \u03b1 \u03b1) (repeat n Prop)) :\n    arrow (subtype_ p)\n        fun (i : fin2 n) =>\n          Subtype fun (x : \u03b1 i \u00d7 \u03b1 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 : \u2115} {\u03b1 : typevec n} : arrow \u03b1 (subtype_ (repeat_eq \u03b1)) := sorry\n\ntheorem subtype_val_nil {\u03b1 : typevec 0} (ps : arrow \u03b1 (repeat 0 Prop)) : subtype_val ps = nil_fun :=\n  sorry\n\ntheorem diag_sub_val {n : \u2115} {\u03b1 : typevec n} :\n    comp (subtype_val (repeat_eq \u03b1)) diag_sub = prod.diag :=\n  sorry\n\ntheorem prod_id {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} : prod.map id id = id := sorry\n\ntheorem append_prod_append_fun {n : \u2115} {\u03b1 : typevec n} {\u03b1' : typevec n} {\u03b2 : typevec n}\n    {\u03b2' : typevec n} {\u03c6 : Type u} {\u03c6' : Type u} {\u03c8 : Type u} {\u03c8' : Type u} {f\u2080 : arrow \u03b1 \u03b1'}\n    {g\u2080 : arrow \u03b2 \u03b2'} {f\u2081 : \u03c6 \u2192 \u03c6'} {g\u2081 : \u03c8 \u2192 \u03c8'} :\n    prod.map f\u2080 g\u2080 ::: prod.map f\u2081 g\u2081 = prod.map (f\u2080 ::: f\u2081) (g\u2080 ::: g\u2081) :=\n  sorry\n\n@[simp] theorem drop_fun_diag {n : \u2115} {\u03b1 : typevec (n + 1)} : drop_fun prod.diag = prod.diag :=\n  sorry\n\n@[simp] theorem drop_fun_subtype_val {n : \u2115} {\u03b1 : typevec (n + 1)}\n    (p : arrow \u03b1 (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 : \u2115} {\u03b1 : typevec (n + 1)}\n    (p : arrow \u03b1 (repeat (n + 1) Prop)) : last_fun (subtype_val p) = subtype.val :=\n  rfl\n\n@[simp] theorem drop_fun_to_subtype {n : \u2115} {\u03b1 : typevec (n + 1)}\n    (p : arrow \u03b1 (repeat (n + 1) Prop)) :\n    drop_fun (to_subtype p) = to_subtype fun (i : fin2 n) (x : \u03b1 (fin2.fs i)) => p (fin2.fs i) x :=\n  sorry\n\n@[simp] theorem last_fun_to_subtype {n : \u2115} {\u03b1 : typevec (n + 1)}\n    (p : arrow \u03b1 (repeat (n + 1) Prop)) : last_fun (to_subtype p) = id :=\n  sorry\n\n@[simp] theorem drop_fun_of_subtype {n : \u2115} {\u03b1 : typevec (n + 1)}\n    (p : arrow \u03b1 (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 : \u2115} {\u03b1 : typevec (n + 1)}\n    (p : arrow \u03b1 (repeat (n + 1) Prop)) : last_fun (of_subtype p) = id :=\n  sorry\n\n@[simp] theorem drop_fun_rel_last {n : \u2115} {\u03b1 : typevec n} {\u03b2 : Type u_1} (R : \u03b2 \u2192 \u03b2 \u2192 Prop) :\n    drop_fun (rel_last' \u03b1 R) = repeat_eq \u03b1 :=\n  rfl\n\n@[simp] theorem drop_fun_prod {n : \u2115} {\u03b1 : typevec (n + 1)} {\u03b1' : typevec (n + 1)}\n    {\u03b2 : typevec (n + 1)} {\u03b2' : typevec (n + 1)} (f : arrow \u03b1 \u03b2) (f' : arrow \u03b1' \u03b2') :\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 : \u2115} {\u03b1 : typevec (n + 1)} {\u03b1' : typevec (n + 1)}\n    {\u03b2 : typevec (n + 1)} {\u03b2' : typevec (n + 1)} (f : arrow \u03b1 \u03b2) (f' : arrow \u03b1' \u03b2') :\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 : \u2115} {\u03b1 : typevec (n + 1)} :\n    drop_fun from_append1_drop_last = id :=\n  rfl\n\n@[simp] theorem last_fun_from_append1_drop_last {n : \u2115} {\u03b1 : typevec (n + 1)} :\n    last_fun from_append1_drop_last = id :=\n  rfl\n\n@[simp] theorem drop_fun_id {n : \u2115} {\u03b1 : typevec (n + 1)} : drop_fun id = id := rfl\n\n@[simp] theorem prod_map_id {n : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n} : prod.map id id = id := sorry\n\n@[simp] theorem subtype_val_diag_sub {n : \u2115} {\u03b1 : typevec n} :\n    comp (subtype_val (repeat_eq \u03b1)) diag_sub = prod.diag :=\n  sorry\n\n@[simp] theorem to_subtype_of_subtype {n : \u2115} {\u03b1 : typevec n} (p : arrow \u03b1 (repeat n Prop)) :\n    comp (to_subtype p) (of_subtype p) = id :=\n  sorry\n\n@[simp] theorem subtype_val_to_subtype {n : \u2115} {\u03b1 : typevec n} (p : arrow \u03b1 (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 : \u2115} {\u03b1 : typevec n} {\u03b2 : typevec n}\n    (p : arrow \u03b1 (repeat n Prop)) (f : arrow \u03b2 (subtype_ p)) :\n    comp (to_subtype p) (comp (of_subtype fun (i : fin2 n) (x : \u03b1 i) => p i x) f) = f :=\n  sorry\n\n@[simp] theorem to_subtype'_of_subtype' {n : \u2115} {\u03b1 : typevec n}\n    (r : arrow (prod \u03b1 \u03b1) (repeat n Prop)) : comp (to_subtype' r) (of_subtype' r) = id :=\n  sorry\n\ntheorem subtype_val_to_subtype' {n : \u2115} {\u03b1 : typevec n} (r : arrow (prod \u03b1 \u03b1) (repeat n Prop)) :\n    comp (subtype_val r) (to_subtype' r) =\n        fun (i : fin2 n)\n          (x :\n          Subtype fun (x : \u03b1 i \u00d7 \u03b1 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 \u00ab09_lib\u00bb\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\u00e9montrer de nombreux\nth\u00e9or\u00e8mes parmi les plus subtils de Math 101 : la caract\u00e9risation\ns\u00e9quentielle des bornes sup\u00e9rieures, l'\u00e9quivalence entre continuit\u00e9\ns\u00e9quentielle et continuit\u00e9, le fait que toute fonction continue sur un segment\nest major\u00e9e et atteint son maximum, et enfin le th\u00e9or\u00e8me des valeurs\ninterm\u00e9diaires.\n\nIl est inutile d'aborder cette feuille sans \u00eatre \u00e0 l'aise avec les feuilles\npr\u00e9c\u00e9dentes (\u00e0 l'exception de la feuille 7bis facultative). R\u00e9viser les\nfeuilles pr\u00e9c\u00e9dentes et poser des questions est toujours une bonne id\u00e9e.\n\nOn commence par un \u00e9chauffement, une variante du\n\n  lim_le (hu : limite_suite u x) (ineg : \u2200 n, u n \u2264 y) : x \u2264 y\n\nde la feuille 8, avec l'autre in\u00e9galit\u00e9 et seulement \u00e0 partir d'un certain rang.\n\nOn rappelle qu'on a la commande linarith' qui est une version l\u00e9g\u00e8rement\nam\u00e9lior\u00e9e de linarith (cf. feuille 8).\n\nOn pourra aussi utiliser les lemmes habituels :\n\n  abs_inferieur_ssi (x y : \u211d) : |x| \u2264 y \u2194 -y \u2264 x \u2227 x \u2264 y\n\n  superieur_max_ssi (p q r) : r \u2265 max p q  \u2194 r \u2265 p \u2227 r \u2265 q\n\n  inferieur_max_gauche p q : p \u2264 max p q\n\n  inferieur_max_droite p q : q \u2264 max p q\n\nainsi que le lemme\n\n  inferieur_si_inferieur_plus_eps : (\u2200 \u03b5 > 0, y \u2264 x + \u03b5) \u2192  y \u2264 x\n\nd\u00e9montr\u00e9 dans la feuille 8\n-/\n\n-- Si u tend vers x et y \u2264 u_n pour n assez grand n alors y \u2264 x.\nlemma le_lim {x y : \u211d} {u : \u2115 \u2192 \u211d} (hu : limite_suite u x)\n  (ineg : \u2203 N, \u2200 n \u2265 N, y \u2264 u n) : y \u2264 x :=\nbegin\n  sorry\nend\n\n/-\nLe premier objectif s\u00e9rieux de cette feuille est de d\u00e9montrer la caract\u00e9risation\ns\u00e9quentielle des bornes sup\u00e9rieures. Pour cela, et pour les objectifs suivants,\nnous aurons besoin de pas mal de choses des feuilles pr\u00e9c\u00e9dentes, et de\nquelques extras.\n\nNous avons d\u00e9montr\u00e9 dans la feuille 5 qu'une suite constante converge vers\nsa valeur :\n\n  lim_constante (x : \u211d) : limite_suite (\u03bb n, x) x\n\net le th\u00e9or\u00e8me des gendarmes :\n\n  gendarmes (lim_u : limite_suite u l) (lim_w : limite_suite w l)\n    (hu : \u2200 n, u n \u2264 v n) (hw : \u2200 n, v n \u2264 w n)  : limite_suite v l\n\nDans la feuille 8, nous avons introduit les deux d\u00e9finitions :\n\n  Le r\u00e9el x est un majorant de l'ensemble de r\u00e9els A :\n  def majorant (A : set \u211d) (x : \u211d) := \u2200 a \u2208 A, a \u2264 x\n\n  Le r\u00e9el x est une  borne sup\u00e9rieure de l'ensemble de r\u00e9els A :\n  def borne_sup (A : set \u211d) (x : \u211d) := majorant A x \u2227 \u2200 y, majorant A y \u2192 x \u2264 y\n\net montr\u00e9 que si un r\u00e9el x est borne sup\u00e9rieure d'un ensemble de r\u00e9els 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) : \u2200 y, y < x \u2192 \u2203 a \u2208 A, y < a :=\n\nDans les exercices suivants, on pourra aussi utiliser les lemmes\n\n  inv_succ_pos : \u2200 n : \u2115, 1/(n + 1 : \u211d) > 0\n\n  limite_inv_succ :  \u2200 \u03b5 > 0, \u2203 N : \u2115, \u2200 n \u2265 N, 1/(n + 1 : \u211d) \u2264 \u03b5\n\net les cons\u00e9quences faciles suivantes de limite_inv_succ :\n\n  limite_si_inferieur_un_sur (h : \u2200 n, |u n - x| \u2264 1/(n+1)) : limite_suite u x\n\n  lim_plus_un_sur (x : \u211d) : limite_suite (\u03bb n, x + 1/(n+1)) x\n\n  lim_moins_un_sur (x : \u211d) : limite_suite (\u03bb n, x - 1/(n+1)) x\n\nLa structure de la d\u00e9monstration est offerte. Les accolades servent \u00e0\nd\u00e9limiter les objectifs interm\u00e9diaires, tout en faisant provisoirement\ndispara\u00eetre l'affichage des objectifs en attente. Il ne faut surtout pas\nles supprimer, sous peine de se perdre irr\u00e9m\u00e9diablement.\n\nEnfin on notera l'apparition dans la structure de d\u00e9monstration ci-dessous\nde la commande \u00ab choose \u00bb. Cette commande est d\u00e9crite dans la derni\u00e8re section\ndu chapitre 3 du cours, intitul\u00e9e \u00ab Utilisation d'un \u2200x, \u2203y et axiome du choix \u00bb\n(qu'il convient donc de relire ou de lire), mais n'\u00e9tait pas encore apparue\ndans les exercices.\n-/\n\n-- Un r\u00e9el x est borne sup\u00e9rieure d'un ensemble de r\u00e9els A ssi il est\n-- majorant de A et il existe une suite d'\u00e9l\u00e9ments de A qui tend vers x.\nlemma borne_sup_ssi (A : set \u211d) (x : \u211d) :\n(borne_sup A x) \u2194 (majorant A x \u2227 \u2203 u : \u2115 \u2192 \u211d, limite_suite u x \u2227 \u2200 n, u n \u2208 A ) :=\nbegin\n  split,\n  { intro h,\n    split,\n    {\n      sorry\n    },\n    { have : \u2200 n : \u2115, \u2203 a \u2208 A, x - 1/(n+1) < a,\n      { intros n,\n        have : 1/(n+1 : \u211d) > 0,\n          exact inv_succ_pos n,\n        sorry\n      },\n      choose u hu using this,\n      sorry\n  } },\n  { rintro \u27e8maj, u, limu, u_in\u27e9, -- 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\u00e9finition de la\ncontinuit\u00e9 d'une fonction de \u211d dans \u211d en un point de \u211d.\n-/\n\n/-- La fonction `f` est continue en `x\u2080`. -/\ndef continue_en (f : \u211d \u2192 \u211d) (x\u2080 : \u211d) : Prop :=\n\u2200 \u03b5 > 0, \u2203 \u03b4 > 0, \u2200 x, |x - x\u2080| \u2264 \u03b4 \u2192 |f x - f x\u2080| \u2264 \u03b5\n\n-- Dans la suite, f d\u00e9signera une fonction de \u211d dans \u211d, x\u2080 un r\u00e9el et u\n-- une suite de r\u00e9els\nvariables {f : \u211d \u2192 \u211d} {x\u2080 : \u211d} {u : \u2115 \u2192 \u211d}\n\n/-\nOn commence par un \u00e9chauffement concernant d\u00e9finition de la continuit\u00e9.\n-/\n\n/-- Une fonction continue en x\u2080 est s\u00e9quentiellement continue en x\u2080 -/\nlemma seq_continue_si_continue (hf : continue_en f x\u2080)\n  (hu : limite_suite u x\u2080) : limite_suite (f \u2218 u) (f x\u2080) :=\nbegin\n  sorry\nend\n\n/-\nLa r\u00e9ciproque de du lemme pr\u00e9c\u00e9dent est vraie aussi :\nLa continuit\u00e9 s\u00e9quentielle en x\u2080 implique la continuit\u00e9 en x\u2080.\nMais la d\u00e9monstration est moins courte. On pourra s'inspirer de\nla d\u00e9monstration de borne_sup_ssi (et du poly de math 101 !).\n-/\nexample :\n  (\u2200 u : \u2115 \u2192 \u211d, limite_suite u x\u2080 \u2192 limite_suite (f \u2218 u) (f x\u2080)) \u2192\n  continue_en f x\u2080 :=\nbegin\n  sorry\nend\n\n/-\nDans la suite, \u00e9tant donn\u00e9s deux r\u00e9els,\non utilise la notation habituelle [a, b] pour d\u00e9signer 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\u00e9finition d'un segment assure le\nlemme suivant (dont l'utilisation est rarement n\u00e9cessaire vu qu'il ne fait que\nd\u00e9plier une d\u00e9finition).\n-/\n\nlemma dans_segment {a b x : \u211d}  : x \u2208 [a, b] \u2194 a \u2264 x \u2227 x \u2264 b :=\niff.rfl -- cette ligne signifie : \u00ab C'est \u00e9quivalent par d\u00e9finition. \u00bb\n\n/-\nNous avons vu dans la feuille 6 les d\u00e9finitions et le lemme :\n\nUne extraction est une fonction strictement croissante de \u2115 dans \u2115 :\n\n  def extraction (\u03c6 : \u2115 \u2192 \u2115) := \u2200 n m, n < m \u2192 \u03c6 n < \u03c6 m\n\nUn r\u00e9el a est valeur d'adh\u00e9rence d'une suite u s'il\nexiste une suite extraite de u qui tend vers a.\n\n  def valeur_adherence (u : \u2115 \u2192 \u211d) (a : \u211d) :=\n    \u2203 \u03c6, extraction \u03c6 \u2227 limite_suite (u \u2218 \u03c6) a\n\nToute extraction est sup\u00e9rieure \u00e0 l'identit\u00e9 :\n\n  extraction_superieur_id : extraction \u03c6 \u2192 \u2200 n, n \u2264 \u03c6 n\n\nEt dans la feuille 8 la d\u00e9finition et le lemme :\n\nLa suite u tend vers +\u221e.\n\n  def limite_infinie_suite (u : \u2115 \u2192 \u211d) := \u2200 A, \u2203 N, \u2200 n \u2265 N, u n \u2265 A\n\nSi u tend vers +\u221e alors u ne tend vers aucune limite finie\n\n  limite_infinie_pas_finie : limite_infinie_suite u \u2192 \u2200 l, \u00ac limite_suite u l\n-/\n\n-- Dans la suite, \u03c6 sera une fonction de \u2115 dans \u2115\nvariables {\u03c6 : \u2115 \u2192 \u2115}\n\n\n/-- Si `u` tend vers `+\u221e` alors toutes ses suites extraites tendent vers `+\u221e`. -/\nlemma limite_infinie_extraction_si_limite\n  (h : limite_infinie_suite u) (h\u03c6 : extraction \u03c6) :\nlimite_infinie_suite (u \u2218 \u03c6) :=\nbegin\n  sorry\nend\n\nlemma limite_infinie_gendarme {u v : \u2115 \u2192 \u211d} (hu : limite_infinie_suite u)\n(huv : \u2200 n, u n \u2264 v n) : limite_infinie_suite v :=\nbegin\n  sorry\nend\n\n/-\nDans la suite, on pourra aussi utiliser le th\u00e9or\u00e8me de Bolzano-Weirstrass :\n\nToute suite \u00e0 valeur dans un segment [a, b] admet une valeur d'adh\u00e9rence\ndans [a, b].\n\n  bolzano_weierstrass (h : \u2200 n, u n \u2208 [a, b]) :\n    \u2203 c \u2208 [a, b], valeur_adherence u c\n\nCe th\u00e9or\u00e8me se d\u00e9montre \u00e0 partir du th\u00e9or\u00e8me de la borne sup\u00e9rieure, mais il\nfaut construire une suite par r\u00e9currence, ce que nous n'avons pas appris \u00e0\nfaire dans Lean.\n\nOn pourra utiliser aussi le lemme suivant, qui lui est \u00e9vident\n\n  limite_suite_id : limite_infinie_suite (\u03bb n, n)\n-/\n\n-- Toute fonction continue sur un segment y est major\u00e9e.\nlemma majoree_segment {f : \u211d \u2192 \u211d} {a b : \u211d} (hf : \u2200 x \u2208 [a, b], continue_en f x) :\n\u2203 M, \u2200 x \u2208 [a, b], f x \u2264 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\u2080 alors -f est aussi continue en x\u2080\nlemma continue_opposee {f : \u211d \u2192 \u211d} {x\u2080 : \u211d} (h : continue_en f x\u2080) :\n  continue_en (\u03bb x, -f x) x\u2080 :=\nbegin\n  sorry\nend\n\n-- Toute fonction continue sur un segment y est minor\u00e9e.\nlemma minoree_segment {f : \u211d \u2192 \u211d} {a b : \u211d} (hf : \u2200 x \u2208 [a, b], continue_en f x) :\n\u2203 m, \u2200 x \u2208 [a, b], m \u2264 f x :=\nbegin\n  have : \u2203 M, \u2200 x \u2208 [a, b], -f x \u2264 M,\n  {\n    sorry\n  },\n  sorry\nend\n\n/-\nNous avons d\u00e9montr\u00e9 dans la feuille 5 qu'une suite a au plus une limite :\n\n unicite_limite : limite_suite u l \u2192 limite_suite u l' \u2192 l = l'\n\net d\u00e9montr\u00e9 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\u03c6 : extraction \u03c6) :\n    limite_suite (u \u2218 \u03c6) l\n\nOn admet une version du th\u00e9or\u00e8me de la borne sup\u00e9rieure (qu'on ne peut pas\nd\u00e9montrer sans construire les nombres r\u00e9els ou admettre un autre th\u00e9or\u00e8me\naussi fort) :\n\nsup_segment {a b : \u211d} {A : set \u211d} (hnonvide : \u2203 x, x \u2208 A) (h : A \u2286 [a, b]) :\n  \u2203 x \u2208 [a, b], borne_sup A x\n\nDans l'exercice suivant, il peut \u00eatre utile de d\u00e9montrer une inclusion\nentre ensembles A et B de nombres r\u00e9els.\nPar d\u00e9finition, A \u2286 B signifie : \u2200 x, x \u2208 A \u2192 x \u2208 B.\nOn peut donc commencer la d\u00e9monstration de A \u2286 B par \u00ab intros x x_dans_A \u00bb\nqui fait appara\u00eetre \u00ab x : \u211d \u00bb et \u00ab x_dans_A : x \u2208 A  \u00bb dans le contexte,\npuis d\u00e9montrer x \u2208 B.\n\nOn remarquera aussi l'utilisation de la notation\n  {x | P x}\nqui d\u00e9signe l'ensemble des x v\u00e9rifiant le pr\u00e9dicat P.\nPar exemple, la d\u00e9finition du segment [a, b] est :\n[a, b] = { x | a \u2264 x \u2227 x \u2264 b }\n\nAinsi l'\u00e9nonc\u00e9 x' \u2208 { x | P x} signifie P x', par d\u00e9finition.\n\nLa structure de la d\u00e9monstration suivante vous est offerte. On notera aussi\nau passage (mais sans n\u00e9cessairement essayer de les retenir) l'apparition\nde plusieurs commandes Lean permettant de rassembler en une ligne une\nfastidieuse s\u00e9rie de intros et cases. Toutes ces d\u00e9monstrations peuvent\nse faire sans commande nouvelle, mais leur complexit\u00e9 justifie d'investir\ndans des raccourcis.\n-/\n\n/-- Toute fonction continue sur un segment non vide y admet un maximum. -/\nexample {a b : \u211d} (hab : a \u2264 b) (hf : \u2200 x \u2208 [a, b], continue_en f x) :\n\u2203 x\u2080 \u2208 [a, b], \u2200 x \u2208 [a, b], f x \u2264 f x\u2080 :=\nbegin\n  cases minoree_segment hf with m hm,\n  cases majoree_segment hf with M hM,\n  let A := {y | \u2203 x \u2208 [a, b], y = f x}, -- A est l'image de [a, b] par f\n  -- La commande obtain n'est pas \u00e0 retenir, c'est un raccourci\n  -- pour un have et deux cases\n  obtain \u27e8y\u2080, y_dans, y_sup\u27e9 : \u2203 y\u2080 \u2208 [m, M], borne_sup A y\u2080,\n  {\n    sorry\n  }, -- Bien observer le contexte apr\u00e8s ce obtain\n  rw borne_sup_ssi at y_sup,\n  -- encore un raccourci pour remplacer trois cases\n  rcases y_sup with \u27e8y_maj, u, lim_u, u_dans\u27e9,\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\u00e8se hufv par une derni\u00e8re commande exotique\n  replace hufv : u = f \u2218 v := funext hufv,\n  sorry\nend\n\n-- Malheureusement linarith ne fait pas tout seul le lemme suivant\nlemma stupide {a b x : \u211d} (h : x \u2208 [a, b]) (h' : x \u2260 b) : x < b :=\nlt_of_le_of_ne h.right h'\n\n/-\nEt maintenant le boss final...\n-/\n\n/-- Le th\u00e9or\u00e8me des valeurs interm\u00e9diaires -/\nexample (f : \u211d \u2192 \u211d) (hf : \u2200 x, continue_en f x) (h\u2080 : f 0 < 0) (h\u2081 : f 1 > 0) :\n\u2203 x\u2080 \u2208 [0, 1], f x\u2080 = 0 :=\nbegin\n  let A := { x | x \u2208 [0, 1] \u2227 f x < 0},\n  have ex_x\u2080 : \u2203 x\u2080 \u2208 [0, 1], borne_sup A x\u2080,\n  {\n    sorry\n  },\n  rcases ex_x\u2080 with \u27e8x\u2080, x\u2080_dans, x\u2080_sup\u27e9,\n  use [x\u2080, x\u2080_dans],\n  have : f x\u2080 \u2264 0,\n  {\n    sorry\n  },\n  have x\u2080_1: x\u2080 < 1,\n  {\n    sorry\n  },\n  have : f x\u2080 \u2265 0,\n  { have dans : \u2203 N : \u2115, \u2200 n \u2265 N, x\u2080 + 1/(n+1) \u2208 [0, 1],\n    { have : \u2203 N : \u2115, \u2200 n\u2265 N, 1/(n+1 : \u211d) \u2264 (1-x\u2080)/2,\n      {\n        sorry\n      },\n      sorry\n    },\n    have pas_dans : \u2200 n : \u2115, x\u2080 + 1/(n+1) \u2209 A,\n    -- Par d\u00e9finition, x \u2209 A signifie \u00ab non (x \u2208 A) \u00bb.\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 {\u03b1 : Type} [inhabited \u03b1] (P : \u03b1 \u2192 Prop) : \u03b1 :=\nif h : \u2203 (x : \u03b1), P x then h.some else default\n\ndef reduce {\u03b1 : Type} [inhabited \u03b1] (f : \u03b1 \u2192 \u03b1) (x : \u03b1) : \u03b1 := get_some\n(\u03bb (r : \u03b1), \u2203 (n : \u2115), (f^[n]) x = r \u2227 (f^[n + 1]) x = r)\n\ndef digits (n : \u2115) : list \u2115 := get_some\n(\u03bb (ds : list \u2115), (\u2200 (d \u2208 ds), d \u2264 9) \u2227 ds.foldl (\u03bb a d, a * 10 + d) 0 = n)\n\ndef digits_sum (n : \u2115) : \u2115 := (digits n).sum\ndef digital_root (n : \u2115) : \u2115 := reduce digits_sum n\n\nlemma digital_root_eq {n : \u2115} :\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 : \u2115}\n  (h : n % 9 = 3 \u2228 n % 9 = 6) : 3 \u2223 n :=\nbegin\n  have h\u2081 : n % 9 % 3 = 0, { cases h; rw h; dec_trivial },\n  rw nat.mod_mod_of_dvd at h\u2081, swap, { dec_trivial },\n  exact nat.dvd_of_mod_eq_zero h\u2081,\nend\n\nlemma num_3_dvd_of_mod_9_eq_3 {n : \u2115} (h : n % 9 = 3) : 3 \u2223 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 : \u2115} (h : n % 9 = 6) : 3 \u2223 n :=\nnum_3_dvd_of_mod_9_eq_3_or_6 (or.inr h)\n\nlemma prime_mod_9 {n : \u2115}\n  (h\u2081 : 3 < n)\n  (h\u2082 : prime n) :\n  n % 9 \u2208 ({1, 2, 4, 5, 7, 8} : set \u2115) :=\nbegin\n  rw \u2190nat.prime_iff at h\u2082, replace h\u2082 := h\u2082.2,\n  obtain \u27e8n, rfl\u27e9 := nat.exists_eq_add_of_lt h\u2081,\n  let k := n + 4, replace h\u2081 : 3 + n + 1 = k, { rw [add_comm 3, add_assoc] },\n  generalize hm : k % 9 = m, rw h\u2081 at h\u2082 \u22a2, rw hm, replace h\u2081 : m < 9,\n  { rw \u2190hm, exact nat.mod_lt _ dec_trivial }, cases m,\n  { specialize h\u2082 3 (k / 3), have h\u2083 : 3 * 3 \u2223 k := nat.dvd_of_mod_eq_zero hm,\n    have h\u2084 : k / 3 * 3 = k := nat.div_mul_cancel (dvd_of_mul_left_dvd h\u2083),\n    rw mul_comm at h\u2084, specialize h\u2082 h\u2084.symm, simp at h\u2082, rw h\u2082 at h\u2084,\n    rw \u2190h\u2084 at h\u2083, contrapose h\u2083, dec_trivial },\n  cases m, { simp }, cases m, { simp }, cases m,\n  { specialize h\u2082 3 (k / 3), have h\u2083 : 3 \u2223 k := num_3_dvd_of_mod_9_eq_3 hm,\n    have h\u2084 : k / 3 * 3 = k := nat.div_mul_cancel h\u2083, rw mul_comm at h\u2084,\n    specialize h\u2082 h\u2084.symm, simp at h\u2082, rw h\u2082 at h\u2084, cases h\u2084 },\n  cases m, { simp }, cases m, { simp }, cases m,\n  { specialize h\u2082 3 (k / 3), have h\u2083 : 3 \u2223 k := num_3_dvd_of_mod_9_eq_6 hm,\n    have h\u2084 : k / 3 * 3 = k := nat.div_mul_cancel h\u2083, rw mul_comm at h\u2084,\n    specialize h\u2082 h\u2084.symm, simp at h\u2082,rw h\u2082 at h\u2084, cases h\u2084 },\n  cases m, { simp }, cases m, { simp },\n  change m + 9 < 9 at h\u2081, contrapose! h\u2081, exact le_add_self,\nend\n\nexample {n : \u2115}\n  (h\u2081 : 3 < n)\n  (h\u2082 : prime n)\n  (h\u2083 : 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, \u2190nat.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\u2081 (lt_add_of_pos_right n dec_trivial),\n    replace h\u2082 := prime_mod_9 h\u2081 h\u2082, replace h\u2083 := prime_mod_9 hn h\u2083,\n    rw nat.add_mod at h\u2083, rcases h\u2082 with h | h | h | h | h | h; change _ = _ at h;\n    { rw h at h\u2083, contrapose h\u2083, 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 data.real.basic\nimport topology.continuous_function.polynomial\nimport data.polynomial.basic\nimport data.polynomial.ring_division\n\ntheorem Canadian_MO_Problem_5_1971 (P : polynomial \u2124) : polynomial.to_continuous_map_on P (\u22a4 : set \u211d) \u211d \n-> P.roots \u2229 (\u22a4 : set \u2124) = \u2205  := sorry\n\n\n\n\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/1971-Canadian_MO-Problem_5.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.803173777511623, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.4760142718900801}}
{"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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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) \u2192 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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 : \u2200 (A B : Type*) (h : (A \u2295 B) = V), (G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) \u2192 (\u2200 (a b : A), \u00ac (G.adj a b)), from\n      begin\n        assume (A B : Type*) (h : (A \u2295 B) = V) (h5 : (G \u2264 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 : \u2200 (A B : Type*) (h : (A \u2295 B) = V), (G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) \u2192 (\u2200 (a b : B), \u00ac (G.adj a b)), from\n      begin\n        assume (A B : Type*) (h : (A \u2295 B) = V) (h13 : (G \u2264 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 : \u2200 (A B : Type*) (h : (A \u2295 B) = V), (G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) \u2192 (\u2200 (a b : A \u2295 B), (G.adj a b) \u2192 (\u2203 (a' b' : A \u2295 B), (a = a') \u2227 (b = b') \u2227 (a' \u2208 A) \u2227 (b' \u2208 B))), from\n      begin\n        assume (A B : Type*) (h : (A \u2295 B) = V) (h21 : (G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B))),\n        assume (a b : A \u2295 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 \u2208 A \u2295 B) \u2227 (b \u2208 A \u2295 B), from by auto [h22, h27],\n        have h29 : (a \u2208 A) \u2228 (a \u2208 B), from by auto [h28.left],\n        have h30 : (b \u2208 A) \u2228 (b \u2208 B), from by auto [h28.right],\n        have h31 : (a \u2208 A) \u2227 (b \u2208 B), from by auto [h29, h30, h4, h12, h21],\n        have h32 : (a \u2208 A) \u2227 (b \u2208 B) \u2192 (\u2203 (a' b' : A \u2295 B), (a = a') \u2227 (b = b') \u2227 (a' \u2208 A) \u2227 (b' \u2208 B)), from by auto [h31],\n        show (\u2203 (a' b' : A \u2295 B), (a = a') \u2227 (b = b') \u2227 (a' \u2208 A) \u2227 (b' \u2208 B)), from by auto [h32],\n      end,\n      have h33 : \u2200 (A B : Type*) (h : (A \u2295 B) = V), (G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) \u2192 (\u2200 (a b : A \u2295 B), (G.adj a b) \u2192 (\u2203 (a' b' : A \u2295 B), (a = a') \u2227 (b = b') \u2227 (a' \u2208 B) \u2227 (b' \u2208 A))), from\n      begin\n        assume (A B : Type*) (h : (A \u2295 B) = V) (h34 : (G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B))),\n        assume (a b : A \u2295 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 \u2208 A \u2295 B) \u2227 (b \u2208 A \u2295 B), from by auto [h35, h40],\n        have h42 : (a \u2208 A) \u2228 (a \u2208 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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": "\n\n\ndef vars := [(\"x\", \u2115), (\"y\", bool)]\n\n\ndef f : string \u2192 nat \n| \"x\" := 1\n| _ := 0\n\nexample (s : string) : s \u2260 \"x\" \u2192 f s = 0 :=\nbegin\nintro h,\nby_cases s = \"x\",\n\nend\n\ndef vars' : string \u2192 Type \n| \"x\" := \u2115 \n| \"y\" := bool\n| _ := unit\n\n\n\n\n#print vars'._main\n\n\ndef point : \u03a0 v, option (vars' v)\n| \"x\" := some (0 : \u2115)\n| \"y\" := some tt\n| _ := none\n\n\n.\n(p : problem)\ndo\n  constr <- p.get_constr \"c\"\n  ", "meta": {"author": "skbaek", "repo": "cvx", "sha": "c50c790c9116f9fac8dfe742903a62bdd7292c15", "save_path": "github-repos/lean/skbaek-cvx", "path": "github-repos/lean/skbaek-cvx/cvx-c50c790c9116f9fac8dfe742903a62bdd7292c15/src/alex_playground/monad.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.793105951184112, "lm_q2_score": 0.600188359260205, "lm_q1q2_score": 0.4760129595606964}}
{"text": "import topology.constructions\n\nopen topological_space\n\nlemma pi_induced_induced {\u03b9 : Sort*} {X Y : \u03b9 \u2192 Type*} [t : \u03a0 i : \u03b9, topological_space $ Y i]\n (f : \u03a0 i, X i \u2192 Y i) : @Pi.topological_space \u03b9 X (\u03bb i, induced (f i) (t i)) =\n  induced (\u03bb (x : \u03a0 i, X i), (\u03bb j,  f j (x j) : \u03a0 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\u2082 : Type*} [semiring R] [semiring R\u2082] {M : Type*} {M\u2082 : Type*}\n{\u03c4\u2081\u2082 : R \u2192+* R\u2082}\n\nsection comap\n\nvariables [add_comm_monoid M] [module R M] [add_comm_monoid M\u2082] [module R\u2082 M\u2082]\n(f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082) {p p' : submodule R M} {q q' : submodule R\u2082 M\u2082} \n\nlemma ker_eq_comap : f.ker = comap f \u22a5 := rfl\n\nlemma ker_le_comap {f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082} : f.ker \u2264 comap f q := comap_mono bot_le\n\nsection ring_hom_surjective\n\nvariable [ring_hom_surjective \u03c4\u2081\u2082]\n\n-- This should not be primed (to match the map equivalent).\n\nlemma comap_le_comap_iff' : comap f q \u2264 comap f q' \u2194 f.range \u2293 q \u2264 q' := \nby rw [\u2190 map_le_iff_le_comap, map_comap_eq]\n\nlemma comap_range : comap f (f.range) = \u22a4 := submodule.eq_top_iff'.mpr (\u03bb _, \u27e8_, rfl\u27e9)\n\nlemma comap_eq_comap_range_inf : comap f q = comap f (f.range \u2293 q) :=\nby rw [comap_inf, comap_range, top_inf_eq]\n\nlemma comap_le_ker_iff : comap f q \u2264 f.ker \u2194 f.range \u2293 q = \u22a5 :=\nby rw [ker_eq_comap, comap_le_comap_iff', le_bot_iff]\n\nlemma comap_eq_ker_iff : comap f q = f.ker \u2194 f.range \u2293 q = \u22a5 :=\n\u27e8 \u03bb h, (comap_le_ker_iff _).mp (le_of_eq h),\n  \u03bb h, le_antisymm ((comap_le_ker_iff _).mpr h) ker_le_comap\u27e9\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 \u03c4\u2081\u2082]\nsection monoids\n\nvariables [add_comm_monoid M] [module R M] [add_comm_monoid M\u2082] [module R\u2082 M\u2082]\n(f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082) {p p' : submodule R M} {q q' : submodule R\u2082 M\u2082}\n\nlemma map_ker : map f (f.ker) = \u22a5 := (submodule.eq_bot_iff _).mpr\n(\u03bb x h, by rcases (mem_map.mp h) with \u27e8_, p, l\u27e9; exact l \u25b8 (mem_ker.mp p) )\n\nlemma map_eq_map_sup_ker : map f p = map f (p \u2294 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\u2082] [module R\u2082 M\u2082]\n(f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082) {p p' : submodule R M} {q q' : submodule R\u2082 M\u2082}\n\nlemma range_le_map_iff : f.range \u2264 map f p \u2194 p \u2294 f.ker = \u22a4 :=\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 \u2194 p \u2294 f.ker = \u22a4 :=\n\u27e8 \u03bb h, (range_le_map_iff _).mp (le_of_eq h),\n  \u03bb h, le_antisymm ((range_le_map_iff _).mpr h) map_le_range\u27e9\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\u2082] [module R M] [module R\u2082 M\u2082] \n{f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082} (p p' : submodule R M) (q q' : submodule R\u2082 M\u2082) \n\ndef compatible (f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082) (p) (q) : Prop := p \u2264 comap f q\n\nlemma cmptble_def {p q} : f.compatible p q \u2194 p \u2264 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 \u22a5 := le_refl _\n\nlemma cmptble_of_cmptble_of_dom_le {p p' q}\n(hp : p' \u2264 p) (hf : f.compatible p q) : f.compatible p' q := \u03bb _ hx, hf (hp hx)\n\nlemma cmptble_of_cmptble_of_cod_le {p q q'}\n(hq : q \u2264 q') (hf : f.compatible p q) : f.compatible p q' := \u03bb _ hx, hq (hf hx)\n\nlemma cmptble_of_cmptble_of_dom_le_of_cod_le {p q p' q'}\n(hp : p' \u2264 p) (hq : q \u2264 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 \u22a4 \u22a4 := \ncmptble_of_cmptble_of_dom_le (le_refl _) (cmptble_comap \u22a4)\n\nlemma cmptble_cod_top {p} : f.compatible p \u22a4 :=\ncmptble_of_cmptble_of_dom_le le_top cmptble_dom_cod_top \n\nlemma cmptble_cod_bot_iff {p} : f.compatible p \u22a5 \u2194 p \u2264 f.ker :=\nby rw cmptble_def; refl\n\nsection ring_hom_surjective\nvariables [ring_hom_surjective \u03c4\u2081\u2082]\n\nlemma cmptble_def' {p q} : f.compatible p q \u2194 map f p \u2264 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 \u22a4 f.range := \nby rw \u2190map_top; exact cmptble_of_cmptble_of_cod_le (le_refl _) (cmptble_map \u22a4)\n\nlemma cmptble_dom_top_iff {q} : f.compatible \u22a4 q \u2194 f.range \u2264 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 \u2194 \u2200 x, x \u2208 p \u2192 f x \u2208 q := by refl\n\nlemma cmptble_dom_top_iff' {q} : f.compatible \u22a4 q \u2194 \u2200 x, f x \u2208 q :=\n\u27e8\u03bb h _, h mem_top, \u03bb h x _, h x\u27e9\n\nlemma cmptble_cod_bot_iff' {p} : f.compatible p \u22a5 \u2194 \u2200 x \u2208 p, f x = 0 :=\nby rw cmptble_cod_bot_iff; refl\n\n-- Should be equivalent to the existing restrict.\ndef restrict' (f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082) {p} {q} (hf : f.compatible p q) : p \u2192\u209b\u2097[\u03c4\u2081\u2082] q := { \n  to_fun := \u03bb x, \u27e8f x, hf x.2\u27e9,\n  map_add' := by { simp_rw [  subtype.ext_iff, submodule.coe_add,\n                              map_add, submodule.coe_mk], exact \u03bb _ _, rfl},\n  map_smul' := by { simp_rw [ subtype.ext_iff, submodule.coe_smul,\n                              map_smul\u209b\u2097, submodule.coe_mk], exact \u03bb _ _, rfl} }\n\nlemma restrict'_apply {p} {q} {hf : f.compatible p q} {x} : (f.restrict' hf x : M\u2082) = 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 \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082) (p : submodule R M) : p \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082 := \ntop_equiv.to_linear_map.comp (f.restrict' cmptble_cod_top)\n\nlemma dom_restrict''_apply {f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082} {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 \u22a4 q :=\nby rw cmptble_dom_top_iff'; exact \u03bb x, hf x.2\n\ndef cod_restrict' (f : M \u2192\u209b\u2097[\u03c4\u2081\u2082] M\u2082) {q} (hf : f.compatible \u22a4 q) : M \u2192\u209b\u2097[\u03c4\u2081\u2082] q := \n(f.restrict' hf).comp top_equiv.symm.to_linear_map\n\nlemma cod_restrict'_apply {q} {hq : f.compatible \u22a4 q} {x} : (f.cod_restrict' hq x : M\u2082) = 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 \u22a4 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(_ \u29f8 (p \u2293 f.ker).comap p.subtype) \u2243\u2097[R] p.map f\nrank f.range \u2294 q + rank q.comap f = rank M + rank q\n(?) corank q = corank q.comap f + corank (f.range \u2294 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 (\u211d \u00d7 \u211d) := metric.closed_ball (0 : \u211d \u00d7 \u211d) 1\ndef circle : set (\u211d \u00d7 \u211d) := metric.sphere (0 : \u211d \u00d7 \u211d) 1\ndef pt : \u211d \u00d7 \u211d := (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\u27e8subtype.mk pt (by simp [pt, disk, norm])\u27e9\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 \u2243\u209c circle := {\n  to_fun := \u03bbx, subtype.mk (\u2191x) (begin rw \u2190 frontier_disk_eq_circle, simp, end),\n  inv_fun := \u03bbx, subtype.mk (\u2191x) (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 {\u03b1 : Type} [topological_space \u03b1] (X : set \u03b1) :\n  is_closed X \u2192 frontier X \u2286 X :=\nbegin\n  intro hclosed,\n  have hfx_sub_fxd : frontier X \u2286 X \\ interior X :=\n    by rw is_closed.frontier_eq hclosed,\n  have hfxd_sub_x : X \\ interior X \u2286 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 \u2286 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 \u2208 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 _ (\u03bb_, true),\n      apply exists.intro,\n      tautology,\n\n      sorry,\n      -- exact {\n      --   to_fun := sorry, --\u03bbt, (\u2191x) + t * (\u2191(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 _ (\u03bb_, true),\n      apply exists.intro,\n      tautology,\n\n      let x_ang : \u211d := sorry,\n      let y_ang : \u211d := sorry,\n      exact {\n        to_fun := \u03bbt,\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 : (\u220f function.const I (\u27e8R\u27e9 : Module R)) \u27f6 (\u220f function.const J (\u27e8R\u27e9 : Module R)))\n-- (g : (\u220f function.const J (\u27e8R\u27e9 : Module R) \u27f6 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}) -- (\ud835\udcd5 : sheaf_of_module X.presheaf)\n\ndef sheaf_of_module.as_SheafedSpace {T : Top} {\ud835\udcde : presheaf CommRing T} (\ud835\udcd5 : sheaf_of_module \ud835\udcde)\n  : SheafedSpace Ab :=\n{ carrier := T,\n  presheaf := \ud835\udcd5.self,\n  is_sheaf := \ud835\udcd5.is_sheaf }\n\ndef RingedSpace.sheaf : sheaf CommRing X.carrier := \u27e8X.presheaf, X.is_sheaf\u27e9\ndef RingedSpace.sheaf_of_Ab : sheaf Ab X.carrier :=\n\u27e8{ obj := \u03bb U, \u27e8X.presheaf.obj U\u27e9,\n   map := \u03bb U V inc, X.presheaf.map inc,\n   map_id' := sorry,\n   map_comp' := sorry }, sorry\u27e9.\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} (\ud835\udcde : sheaf CommRing T) : sheaf_of_module \ud835\udcde.1 :=\n{ self :=\n  { obj := \u03bb V, \u27e8\ud835\udcde.1.obj V\u27e9,\n    map := \u03bb U V inc, \ud835\udcde.1.map inc,\n    map_id' := \u03bb V, sorry,\n    map_comp' := \u03bb U V W incUV incVW, sorry },\n  is_sheaf := sorry,\n  compatible := \u03bb 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 `\ud835\udcd5` is an `\ud835\udcde`-module, then we say `\ud835\udcd5` is quasicoherent if and only if for every `x : X`, there is\nan `x \u2208 U : opens X` such that there is an exact sequence of sheaves of abelian group of the following:\n\n```\n\u2a01_{i : I} (\ud835\udcde|U) \u27f6 \u2a01_{j : J} (\ud835\udcde|U) \u27f6 \ud835\udcd5|U \u27f6 0\n```\n-/\nvariable {X}\nstructure sheaf_of_module.free_presentation_at (\ud835\udcd5 : sheaf_of_module X.presheaf) (x : X) :=\n(U : opens X)\n(mem : x \u2208 U)\n(I J : Type u)\n(f : (\u220f function.const I ((SheafedSpace.restrict (RingedSpace.SheafedSpace_of_Ab X) (opens.open_embedding U))).sheaf) \u27f6 \n    (\u220f function.const J ((SheafedSpace.restrict (RingedSpace.SheafedSpace_of_Ab X) (opens.open_embedding U))).sheaf))\n(g : (\u220f function.const J ((SheafedSpace.restrict (RingedSpace.SheafedSpace_of_Ab X) (opens.open_embedding U))).sheaf) \u27f6\n (SheafedSpace.restrict (\ud835\udcd5.as_SheafedSpace) (opens.open_embedding U)).sheaf)\n[exact1 : exact f g]\n[exact2 : exact g (0 : _ \u27f6 0)].\n\ndef sheaf_of_module.is_quasicoherent (\ud835\udcd5 : sheaf_of_module X.presheaf) : Prop :=\n\u2200 (x : X), nonempty (sheaf_of_module.free_presentation_at \ud835\udcd5 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 := \u03bb F1 F2, F1.sheaf \u27f6 F2.sheaf,\n  id := \u03bb F, \ud835\udfd9 _,\n  comp := \u03bb F1 F2 F3 f12 f23, f12 \u226b f23,\n  id_comp' := \u03bb F1 F2 f, by simp,\n  comp_id' := \u03bb F1 F2 f, by simp,\n  assoc' := \u03bb F1 F2 F3 F4 f12 f23 f34, by simp }.\n\nvariable {X}\ndef zero_morphism (F G : quasicoherent_sheaf_of_module X) : F \u27f6 G := (0 : F.sheaf \u27f6 G.sheaf)\n\ninstance : limits.has_zero_morphisms (quasicoherent_sheaf_of_module X) :=\n{ has_zero := \u03bb F G, \u27e8zero_morphism F G\u27e9,\n  comp_zero' := \u03bb 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 \u226b 0) x = 0,\n    simp only [limits.comp_zero, AddCommGroup.zero_apply],\n  end,\n  zero_comp' := \u03bb 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 \u226b 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 := \u03bb x, nonempty.intro\n{ U := \u22a4,\n  mem := trivial,\n  I := punit,\n  J := punit,\n  f := \ud835\udfd9 _,\n  g := 0,\n  exact1 := \u27e8by ext, \u27e8\u03bb 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\u27e9\u27e9,\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 \u27e8X.presheaf, X.is_sheaf\u27e9).is_quasicoherent := \u03bb x, nonempty.intro\n{ U := \u22a4,\n  mem := trivial,\n  I := punit,\n  J := ulift bool,\n  f := category_theory.limits.pi.lift \n    (\u03bb b, match (ulift.down b) with\n    | tt := category_theory.limits.pi.\u03c0 _ (punit.star)\n    | ff := 0\n    end),\n  g := category_theory.limits.pi.\u03c0 _ (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 `\u2192+*`, for\nmorphisms between semirings or rings. For example use `\u03c6 : A \u2192+* 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 {\u03b1 : Type u}\n\n/-- Predicate for semiring homomorphisms (deprecated -- use the bundled `ring_hom` version). -/\nstructure is_semiring_hom {\u03b1 : Type u} {\u03b2 : Type v} [semiring \u03b1] [semiring \u03b2] (f : \u03b1 \u2192 \u03b2) : Prop :=\n(map_zero [] : f 0 = 0)\n(map_one [] : f 1 = 1)\n(map_add [] : \u2200 {x y}, f (x + y) = f x + f y)\n(map_mul [] : \u2200 {x y}, f (x * y) = f x * f y)\n\nnamespace is_semiring_hom\n\nvariables {\u03b2 : Type v} [semiring \u03b1] [semiring \u03b2]\nvariables {f : \u03b1 \u2192 \u03b2} (hf : is_semiring_hom f) {x y : \u03b1}\n\n/-- The identity map is a semiring homomorphism. -/\nlemma id : is_semiring_hom (@id \u03b1) := by refine {..}; intros; refl\n\n/-- The composition of two semiring homomorphisms is a semiring homomorphism. -/\nlemma comp (hf : is_semiring_hom f) {\u03b3} [semiring \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : is_semiring_hom g) :\n  is_semiring_hom (g \u2218 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 := \u03bb x y, by simp [map_add hf, map_add hg],\n  map_mul := \u03bb 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{ ..\u2039is_semiring_hom f\u203a }\n\n/-- A semiring homomorphism is a monoid homomorphism. -/\nlemma to_is_monoid_hom (hf : is_semiring_hom f) : is_monoid_hom f :=\n{ ..\u2039is_semiring_hom f\u203a }\n\nend is_semiring_hom\n\n/-- Predicate for ring homomorphisms (deprecated -- use the bundled `ring_hom` version). -/\nstructure is_ring_hom {\u03b1 : Type u} {\u03b2 : Type v} [ring \u03b1] [ring \u03b2] (f : \u03b1 \u2192 \u03b2) : Prop :=\n(map_one [] : f 1 = 1)\n(map_mul [] : \u2200 {x y}, f (x * y) = f x * f y)\n(map_add [] : \u2200 {x y}, f (x + y) = f x + f y)\n\nnamespace is_ring_hom\n\nvariables {\u03b2 : Type v} [ring \u03b1] [ring \u03b2]\n\n/-- A map of rings that is a semiring homomorphism is also a ring homomorphism. -/\nlemma of_semiring {f : \u03b1 \u2192 \u03b2} (H : is_semiring_hom f) : is_ring_hom f := {..H}\n\nvariables {f : \u03b1 \u2192 \u03b2} (hf : is_ring_hom f) {x y : \u03b1}\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 \u03b1) := 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) {\u03b3} [ring \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : is_ring_hom g) :\n  is_ring_hom (g \u2218 f) :=\n{ map_add := \u03bb x y, by simp [map_add hf]; rw map_add hg; refl,\n  map_mul := \u03bb 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, ..\u2039is_ring_hom f\u203a }\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 {\u03b2 : Type v} {\u03b3 : Type w} [r\u03b1 : semiring \u03b1] [r\u03b2 : semiring \u03b2]\n\nnamespace ring_hom\n\nsection\ninclude r\u03b1 r\u03b2\n\n/-- Interpret `f : \u03b1 \u2192 \u03b2` with `is_semiring_hom f` as a ring homomorphism. -/\ndef of {f : \u03b1 \u2192 \u03b2} (hf : is_semiring_hom f) : \u03b1 \u2192+* \u03b2 :=\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 : \u03b1 \u2192 \u03b2} (hf : is_semiring_hom f) : \u21d1(of hf) = f := rfl\n\nlemma to_is_semiring_hom (f : \u03b1 \u2192+* \u03b2) : 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 {\u03b1 \u03b3} [ring \u03b1] [ring \u03b3] (g : \u03b1 \u2192+* \u03b3) : 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 Quiz9\nimport Sets.Basic\nimport Lean.Elab.Print\nimport Lean.Elab.Command\n\nopen Set \n\nvariable {\u03b1 : Type}\nvariable (X Y : Set \u03b1)\n\ntheorem desiredType1 : X \u2229 X\u1d9c = \u2205 := sorry \n\ntheorem desiredType2 : X \u222a X\u1d9c = Univ := sorry \n\ntheorem desiredType3 : X\u1d9c \u222a X = Univ := sorry \n\nopen Lean\nopen Lean.Meta\nopen Lean.Elab.Command\n\ndef n : String := \"3\"\n\ndef problem : String := \"problem\"++n\n\ndef desired : String := \"desiredType\"++n\n\ndef collectAxiomsOf (constName : Name) : MetaM (List String) := do\n  let env \u2190 getEnv\n  let (_, s) := ((CollectAxioms.collect constName).run env).run {}\n  let a := s.axioms.toList.map toString\n  return a\n\n#eval isDefEq (Expr.const desired []) (Expr.const problem [])\n#eval collectAxiomsOf problem\n", "meta": {"author": "UofSC-Fall-2022-Math-300-H01", "repo": "quiz9", "sha": "95d0b3fdfbb0190af5e011d7213a55a35fc079ee", "save_path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-quiz9", "path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-quiz9/quiz9-95d0b3fdfbb0190af5e011d7213a55a35fc079ee/_Tests/Problem3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7879311956428946, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4758567318345001}}
{"text": "import data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 := begin\n    ext,\n    split,\n    {\n      assume h,\n      cases h with h1 h2,\n      rcases h2 with \u27e8n, hn\u27e9,\n      use [n, hn],\n    },{\n      assume h,\n      cases h with h1 h2,\n      use 0,\n      unfold closure,\n      use {x : \u2124 | (\u03b1 * x) - \u2191x},\n      use h2,\n      rw \u2190 h1,\n      rw set.mem_Icc,\n      linarith,\n    }\nend\n\n--OUTPUT 2\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j),\n  from\n    begin\n      assume i j hij,\n      assume h2 : int.fract (\u03b1 * \u2191i) = int.fract (\u03b1 * \u2191j),\n      have h3 : \u03b1 * \u2191i = \u03b1 * \u2191j, from by auto [int.fract_eq] using [h2],\n      have h4 : \u03b1 = (\u2191i - \u2191j)*\u207b\u00b9*(\u2191i - \u2191j), from by auto using [h3, mul_eq_inv_mul_left, zero_ne_one, h\u03b1_irrat],\n      have h5 : \u03b1 = (\u2191j - \u2191i)*\u207b\u00b9*(\u2191j - \u2191i), from by auto [h4],\n      have h6 : \u03b1 = (\u2191j - \u2191i)*\u207b\u00b9*(\u2191i - \u2191j), from by auto [h5, mul_comm],\n      have h7 : \u03b1 = (\u2191j - \u2191i)*\u207b\u00b9*(\u2191i - \u2191j), from by auto [h6, h4, mul_comm],\n      have h8 : \u03b1 = (\u2191j - \u2191i)*\u207b\u00b9, from by auto [h7, one_mul],\n      have h9 : \u03b1 = (\u2191i - \u2191j)*\u207b\u00b9, from by auto [h8, mul_comm],\n      have h10 : (\u2191j - \u2191i)*\u207b\u00b9 = (\u2191i - \u2191j)*\u207b\u00b9, from by auto [h9, h8],\n      have h11 : (\u2191j - \u2191i) = (\u2191i - \u2191j), from by auto using [inv_eq_inv],\n      rw h11 at hij,\n      exact absurd hij dec_trivial,\n    end,\n  have h2 : \u2200 i j \u2208 @set.univ \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191 i) \u2260 int.fract (\u03b1 * \u2191 j), from by auto [h1],\n  have h3 : \u2200 i : \u2124, i \u2208 @set.univ \u2124 \u2192 i \u2260 0, from by auto [eq_zero_iff_iff_neg_eq_zero],\n  \n  have h4 : \u2200 (x y : \u2124) (hx : x \u2208 @set.univ \u2124) (hy : y \u2208 @set.univ \u2124), \u2203 (n : \u2124), n \u2260 0 \u2227 int.fract (n * x) = int.fract (n * y),\n  from\n    begin\n      assume (x y : \u2124) (hx : x \u2208 @set.univ \u2124) (hy : y \u2208 @set.univ \u2124),\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 \u2190 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 : \u2200 i \u2208 @set.univ \u2124, \u2203 n : \u2115, \u2200 j \u2208 @set.univ \u2124, j \u2260 i \u2192 int.fract (\u2191 n * i) \u2260 int.fract (\u2191 n * j),\n  from\n    begin\n      assume i hi,\n      cases nat.find (\u03bb n, \u2200 j \u2208 @set.univ \u2124, j \u2260 i \u2192 int.fract (\u2191n * i) \u2260 int.fract (\u2191n * j)) with h6 h7,\n      use h6,\n      assume j hj,\n      assume h8 : j \u2260 i,\n      have h9 : \u2200 (x y : \u2124) (hx : x \u2208 @set.univ \u2124) (hy : y \u2208 @set.univ \u2124), \u2203 (n : \u2124), n \u2260 0 \u2227 int.fract (n * x) = int.fract (n * y), from by auto [h4],\n      have h10 : \u2203 (n : \u2124), n \u2260 0 \u2227 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 \u2260 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 \u2264 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 : \u2200 i j \u2208 @set.univ \u2124, i \u2260 j \u2192 \u2203 n : \u2115, \u2200 k \u2208 @set.univ \u2124, k \u2260 i \u2192 k \u2260 j \u2192 int.fract (\u2191 n * i) \u2260 int.fract (\u2191 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 : (\u03bb (k : \u2115), k^2) \u2208 set.range (\u03bb (n : \u2115), n^2), from by auto [pow_two],\n      have h4 : \u2203 (n : \u2115), int.nat_abs (\u2191n * i - \u2191n * j) < int.nat_abs (\u2191n * i),\n      from\n        begin\n          cases set.never_equal_to_this : (\u03bb (n : \u2115), int.nat_abs (\u2191n * i - \u2191n * j) < int.nat_abs (\u2191n * i)) with h5 h6,\n          { use 1,\n            rw h6,\n            have h7 : int.nat_abs (\u2191(1) * i - \u2191(1) * j) < int.nat_abs (\u2191(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 (\u2191(1) * i - \u2191(1) * j) < int.nat_abs (\u2191(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 : \u2203 (n : \u2115), int.nat_abs (\u2191n * i - \u2191n * j) < int.nat_abs (\u2191n * 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 (\u2191(n+1) * i) \u2260 int.fract (\u2191(n+1) * j),\n      from by auto [h1, h2, hk, hj, hi, h7],\n      have h9 : int.nat_abs (int.fract (\u2191(n+1) * i - int.fract (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have seq_limit : (\u2124 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2124 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5,\n\n  have h1 : set.Icc 0 1 = (closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124))) \u222a (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 \u2286 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)),\n  from by auto [h1],\n\n  have h3 : closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) \u2286 set.Icc 0 1,\n  from by auto [h1],\n\n  have h4 : \u2200 (i j : \u2124),  i \u2260 j \u2192 ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) i) \u2260 ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) j),\n  from by auto [h\u03b1_irrat.uniq_diff_rat_of_irrat],\n\n  have h5 : \u2200 (i j : \u2124),  i \u2260 j \u2192 0 \u2209 ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (set.Iio i j)),\n  from by auto [h4],\n\n  have h6 : ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (set.Iio 0 1)) \u2286 ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)),\n  from by auto [fractional_parts_rational],\n\n  have h7 : 0 \u2209 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (set.Iio 0 1)), \n  from by auto [h5, h6],\n\n  have h8 : \u2200 {x : \u2124}, (int.fract (\u03b1 * \u2191x)) \u2208 set.Iio 0 1, \n  from by auto [mul_nonneg, mul_nonpos, int.coe_nat_nonneg, int.coe_nat_nonneg],\n\n  have h9 : \u2200 {x : \u2124}, (int.fract (\u03b1 * \u2191x)) \u2208 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), \n  from by auto [h8, set.mem_closure_iff_nhds],\n\n  have h10 : \u2200 {x : \u2124}, (int.fract (\u03b1 * \u2191x)) \u2208 set.Ioc 0 1, \n  from by auto [h8, set.mem_Ioc_iff],\n\n  have h11 : \u2200 {x : \u2124}, (int.fract (\u03b1 * \u2191x)) \u2208 set.Icc 0 1, \n  from by auto [h10, set.mem_Icc_iff],\n\n  have h12 : \u2200 {x : \u2124}, (int.fract (\u03b1 * \u2191x)) \u2208 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), \n  from by auto [h11, h3],\n\n  have h13 : \u2200 {x : \u2124}, (int.fract (\u03b1 * \u2191x)) \u2208 set.Icc 0 1, \n  from by auto [h12, h3],\n\n  have h14 : closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) \u2286 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 ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), \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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 m n, m \u2260 n \u2192 (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) m \u2260 (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) n, \n  from by auto [int.fract_def, irrational_iff_not_rat, irrational_iff_sqrt_not_rat] {precedence := decimal},\n\n  let S : set \u211d := (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124),\n  have h2 : \u2200 x : \u2124, (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) x \u2208 S := by auto [set.mem_image],\n  have h3 : \u2203! e : S, \u2200 a : S, e \u2208 closure a \u2192 a \u2286 S := by auto [set.separation],\n\n  have h4 : \u2200 x : \u2124, \u2203 b : S, x \u2208 b := by auto [set.mem_image],\n\n  have h5 : infinite S := by auto [set.finite_univ, h1, infinite],\n  have h6 : \u2203 l : \u211d, 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 : \u2203 (l : \u211d), is_limit_point S l \u2227 l \u2208 set.Icc 0 1, from by auto [is_limit_point_iff_exists_sequence],\n  have h8 : \u2203! l : \u211d, is_limit_point S l \u2227 l \u2208 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 : \u2200 y \u2208 set.Icc 0 1, \u2203 (\u03b5 : \u211d) > 0, \u2200 x, x \u2208 S \u2192 |x - y| < \u03b5,  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 ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h0 : \u2200 m n : \u2124, m \u2260 n \u2192 (int.fract (\u03b1*\u2191m)) \u2260 (int.fract (\u03b1* \u2191n)), from by {assume m n h1, assume h2, have h3 : (\u03b1*\u2191m-int.fract (\u03b1* \u2191m)) \u2260 (\u03b1* \u2191n-int.fract (\u03b1* \u2191n)), from by auto [int.fract_eq_iff_eq, h1, h\u03b1_irrat], linarith [h2]},\n  have h1 : \u2200 x y : \u2124, (int.fract (\u03b1 * \u2191x)) = (int.fract (\u03b1 * \u2191y)) \u2194 x = y, from by {auto [int.fract_eq_iff_eq, h\u03b1_irrat]},\n  have h2 : (set.Icc (0:\u211d) 1) \u2229 ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124), from by auto [fract_bounded, int.fract_lt_one, int.fract_nonneg],\n  have h3 : (set.Icc (0:\u211d) 1) \u2286 (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124), from by auto [fract_bounded, int.fract_lt_one, int.fract_nonneg],\n  have h4 : (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124) \u2286  (set.Icc (0:\u211d) 1), from by auto [fract_bounded, int.fract_lt_one, int.fract_nonneg],\n  have h5 : (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124) \u2286 closure (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124), from by auto using [set.subset_closure],\n  have h6 : \u2200\u2080 m : \u2124, 0 \u2264 int.fract (\u03b1 * \u2191m), from by intros m hm;exact int.fract_nonneg (\u03b1 * \u2191m),\n  have h6' : \u2200\u2080 m : \u2124, int.fract (\u03b1 * \u2191m) \u2264 1, from by intros m hm;exact int.fract_lt_one (\u03b1 * \u2191m),\n  have h7 : submodule.span \u211d (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))) = 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 \u211d (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)))) \u2286 closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), from by auto using [set.subset_closure],\n  have h9 : closure (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124) = closure (submodule.span \u211d (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)))), from by auto [closure_span,h7,h5,h8],\n  have h10 : closure (\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124) = set.Icc (0:\u211d) 1, from by auto [h9, closure_Icc],\n  show closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1, by auto [h10,h3] using [set.subset_closure]\nend\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 {\u03b1 : \u211d} (q : \u211d) :\n  let seq : \u2115 \u2192 \u211d :=  \u03bb (n : \u2115), (q ^ n)*\u03b1 in\n  \u2200 \u03b1, \u2203 lim : \u211d, 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 {\u03b1 : \u211d} (h\u03b1_alg : algebraic \u03b1) : \u2203 n : \u2115, \u03b1 = n\u207b\u00b9 := 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 {\u03b1 : \u211d} (h\u03b1_root_of_unity : is_root_of_unity \u03b1) : algebraic \u03b1 := 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 {\u03b1 : \u211d} (h\u03b1_root_of_unity : is_root_of_unity \u03b1) : \u2203 n : \u2115, \u03b1 = n\u207b\u00b9 := 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 {\u03b1 : \u211d} (h\u03b1_root_of_unity : is_root_of_unity \u03b1) : transcendental \u03b1 := \nbegin\n  sorry\nend\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n    let S : set \u211d := (\u03bb (n : \u2124), (int.fract (\u03b1 * \u2191n)) : \u2124 \u2192 \u211d) '' (@set.univ \u2124),\n    have h1 : S.infinite, \n    from by auto [@set.infinite_of_nonempty \u2124] using [set.Ico_nonempty],\n    have h2 : \u2203 \u2983a b : \u211d\u2984, 0 < a \u2227 a < b \u2227 b < 1 \u2227 \u2200 \u2983x : \u211d\u2984, a < x \u2227 x < b \u2192 \u2203 \u2983m : \u2124\u2984, x \u2208 S, \n    from exists_pair_in_interval_with_common_neighbours h1,\n    -- (\u230a x\u230b + 1 \u2260 \u230a b\u230b \u2227 \u230a x\u230b \u2260 \u230a b\u230b) \u2192 \n    have h3 : \u2200 (x : \u211d) \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs ((b : \u211d) - x) + 1) (int.nat_abs (((b : \u211d) - x) + 2) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < b - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) a \u2208 S, \n    from exists_int_in_set h2,\n    have h4 : \u2200 (x : \u211d) (m1 : \u2124), (\u2203 \u2983m : \u2124\u2984, 0 < m \u2227 m < b - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) m1 \u2208 S) \n    \u2194 (0 < m1 \u2227 (\u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < b - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) (m1 - n) \u2208 S)), \n    from exists_neighbour h2,\n    have h5 : \u2200 (x : \u211d) (m1 : \u2124), (\u2203 \u2983m : \u2124\u2984, 0 < m \u2227 m < 1 - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) m1 \u2208 S) \n    \u2194 (0 < m1 \u2227 (\u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < 1 - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) (m1 - n) \u2208 S)), \n    from exists_neighbour_1 h2,\n    have h6 : \u2200 (x : \u211d) \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs (((1 : \u211d) - x) + 2) + 1) (int.nat_abs (((1 : \u211d) - x) + 1) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < 1 - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) a \u2208 S, \n    from exists_int_in_set_1 h2,\n    have h7 : \u2200 (x : \u211d) (m1 : \u2124), (\u2203 \u2983m : \u2124\u2984, 0 < m \u2227 m < x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) m1 \u2208 S) \n    \u2194 (0 < m1 \u2227 (\u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) (m1 + n) \u2208 S)), \n    from exists_neighbour_0 h2,\n    have h8 : \u2200 (x : \u211d) \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs (x + 1) + 1) (int.nat_abs (x + 2) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) a \u2208 S, \n    from exists_int_in_set_0 h2,\n    have h9 : \u2200 (x : \u211d) \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs ((b : \u211d) - x) + 1) (int.nat_abs (((b : \u211d) - x) + 1) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < b - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) a \u2208 S, \n    from exists_int_in_set_3 h2,\n    have h10 : \u2200 \u2983x : \u211d\u2984, x < b \u2192 \u2200 \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs ((b - x) + 1) + 1) (int.nat_abs ((b - x) + 2) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < b - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) a \u2208 S, \n    from int_in_set_2 h2,\n    have h11 : \u2203 \u2983x : \u211d\u2984, 0 < x \u2227 x < 1 \u2227 \u2200 \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs (x + 1) + 1) (int.nat_abs (x + 2) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) a \u2208 S, \n    from exists_x_int_in_set_3 h2,\n    have h12 : \u2203 \u2983x : \u211d\u2984, 0 < x \u2227 x < 1 \u2227 \u2200 \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs (x + 1) + 1) (int.nat_abs (x + 2) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < 1 - x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) a \u2208 S, \n    from exists_x_int_in_set_4 h2,\n    have h13 : \u2203 \u2983x : \u211d\u2984, 0 < x \u2227 x < 1 \u2227 \u2200 \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs ((x : \u211d) + 1) + 1) (int.nat_abs ((x : \u211d) + 2) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < x \u2227 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) a \u2208 S, \n    from exists_x_int_in_set_5 h2,\n    have h14 : \u2203 \u2983x : \u211d\u2984, 0 < x \u2227 x < 1 \u2227 \u2200 \u2983a : \u2124\u2984, a \u2208 set.Ico (int.nat_abs ((x : \u211d) + 1) + 1) (int.nat_abs ((x : \u211d) + 2) + 1) \n    \u2192 \u2203 \u2983n : \u2124\u2984, 0 < n \u2227 n < 1 - x \u2227 (\u03bb\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 := \nbegin\n  have h1 : (\u2200 (n m : \u2124), n \u2260 m \u2192 (int.fract (\u03b1 * \u2191n)) \u2260 (int.fract (\u03b1 * \u2191m))),\n  from\n  begin\n    assume (n m : \u2124) (hnm : n \u2260 m),\n    assume h1 : (int.fract (\u03b1 * \u2191n)) = (int.fract (\u03b1 * \u2191m)),\n    rw h1,\n    have h2 : \u03b1 = (int.fract (\u03b1 * \u2191n)) + (int.fract (\u03b1 * \u2191m)),\n    from by linarith,\n    have h3 : \u03b1 = (int.fract (\u03b1 * \u2191n)) + (int.fract (\u03b1 * \u2191n)),\n    from by linarith,\n    have h4 : \u03b1 = n * \u03b1 + (int.fract (\u03b1 * \u2191n)),\n    from by linarith,\n    have h5 : \u03b1 = m * \u03b1 + (int.fract (\u03b1 * \u2191n)),\n    from by linarith,\n    have h6 : \u03b1 = n * \u03b1 + m * \u03b1,\n    from by linarith,\n    have h7 : (n - m) * \u03b1 = 0,\n    from by linarith,\n    have h8 : (n - m) = 0,\n    from by linarith,\n    contradiction,\n  end,\n\n  have h2 : \u2203 (N : \u2115), \u2200 (n : \u2115), n \u2265 N \u2192 (int.fract (\u03b1^(n+1))) = 0,\n  from\n  begin\n    apply exists.intro (1),\n    assume (n : \u2115) (hn : n \u2265 1),\n    have h3 : \u2191(n + 1) \u2208 (set.range (succ)),\n    from set.mem_range_self _,\n    have h4 : \u2191(n + 1) > 0,\n    from by linarith [hn],\n    have h5 : (int.fract (\u03b1^(\u2191(n + 1)))) = 0,\n    from by linarith [h4],\n    show (int.fract (\u03b1^(n+1))) = 0,\n    from by linarith,\n  end,\n\n  have h3 : \u2203 (n : \u2115), n \u2265 1 \u2227 (int.fract (\u03b1^(n+1))) = 0,\n  from exists.intro 1 (and.intro (nat.le_succ 1) (by linarith)),\n\n  have h4 : \u2200 (n : \u2115), n \u2265 1 \u2192 (int.fract (\u03b1^(n+1))) = 0,\n  from \n  begin\n    assume (n : \u2115) (hn : n \u2265 1),\n    cases h2 with N h2,\n    cases h2 n with hnN h2,\n    show (int.fract (\u03b1^(n+1))) = 0,\n    from by linarith,\n  end,\n\n  have h5 : \u2200 (n : \u2115), n \u2265 1 \u2192 \u2203 (k : \u2124), (int.fract (\u03b1^(n+1))) = k,\n  from\n  begin\n    assume (n : \u2115) (hn : n \u2265 1),\n    have h6 : (int.fract (\u03b1^(n+1))) = 0,\n    from by linarith,\n    show \u2203 (k : \u2124), (int.fract (\u03b1^(n+1))) = k,\n    from by linarith,\n  end,\n\n  have h6 : \u2200 (n : \u2115), n \u2265 1 \u2192 \u2200 (m : \u2115), m \u2265 1 \u2192 \u2203 (k : \u2124), (int.fract (\u03b1^(n+1))) = k,\n  from\n  begin\n    assume (n m : \u2115) (hn : n \u2265 1) (hm : m \u2265 1),\n    have h4 : \u2203 (k : \u2124), (int.fract (\u03b1^(n+1))) = k,\n    from by linarith,\n    show \u2203 (k : \u2124), (int.fract (\u03b1^(n+1))) = k,\n    from by linarith [h4],\n  end,\n\n  have h7 : \u2200 (n : \u2115), \u2200 (m : \u2115), n \u2265 1 \u2192  m \u2265 1 \u2192 \u2203 (x y : \u2124), (int.fract (\u03b1^(n+1))) = x \u2227 ((int.fract (\u03b1^(m+1))) = y),\n  from\n  begin\n    assume (n m : \u2115) (hn : n \u2265 1) (hm : m \u2265 1),\n    cases h4 n hn with x hx,\n    cases h4 m hm with y hy,\n    have h6 : ((int.fract (\u03b1^(n+1))) = x \u2227 ((int.fract (\u03b1^(m+1))) = y)),\n    from by linarith,\n    show \u2203 (x y : \u2124), (int.fract (\u03b1^(n+1))) = x \u2227 ((int.fract (\u03b1^(m+1))) = y),\n    from by linarith [h6],\n  end,\n\n  have h8 : \u2200 (n : \u2115), \u2203 (x : \u2124), (int.fract (\u03b1^(n+1))) = x,\n  from\n  begin\n    assume (n : \u2115),\n    cases h7 n n (le_refl n) (le_refl n) with x hx,\n    show \u2203 (x : \u2124), (int.fract (\u03b1^(n+1))) = x,\n    from by linarith [hx],\n  end,\n\n  have h9 : \u2200 (n : \u2115), \u2203 (x : \u2124), (int.fract (\u03b1^(n+1))) = x,\n  from by auto [h8],\n\n  have h10 : \u2203 (N : \u2115), \u2200 (n : \u2115), n \u2265 N \u2192 (int.fract (\u03b1^(n+1))) = 0,\n  from by auto [h2],\n\n  have h11 : \u2200 (n : \u2115), \u2200 (m : \u2115), n \u2265 1 \u2192 m \u2265 1 \u2192 int.fract (\u03b1^(n+1)) \u2264 int.fract (\u03b1^(m+1)),\n  from\n  begin\n    assume (n m : \u2115) (hn : n \u2265 1) (hm : m \u2265 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 (\u03b1^(n+1)) \u2264 k,\n    from by linarith,\n    show int.fract (\u03b1^(n+1)) \u2264 int.fract (\u03b1^(m+1)),\n    from by linarith [hmN, hmN],\n  end,\n\n  have h12 : \u2200 (n : \u2115), \u2203 (m : \u2115), (int.fract (\u03b1^(n+1))) = int.fract (\u03b1^(m+1)),\n  from\n  begin\n    assume (n : \u2115),\n    cases classical.em (n = 0) with hn hn,\n    show \u2203 (m : \u2115), (int.fract (\u03b1^(n+1))) = int.fract (\u03b1^(m+1)),\n    from by linarith [hn],\n    assume hn : n \u2260 0,\n    cases h2 with N h2,\n    cases h2 n with hnN h2,\n    have h13 : int.fract (\u03b1^(n+1)) = 0,\n    from by linarith,\n    have h14 : n + 1 \u2265 N + 1,\n    from by linarith [nat.succ_le_succ],\n    have h15 : int.fract (\u03b1^(n+1)) = int.fract ((\u03b1 ^ (N+1))),\n    from by linarith,\n   \nend --Needs more than 2000 tokens!\n\n--OUTPUT 9\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 := \nbegin\n   have h1 : real.sqrt(2) \u2209 \u211a, from by simpa,\n\n   have h2 : irrational (real.sqrt 2) := by exact h1,\n\n   have h3 : \u2203 a b, a \u2208 (\u03bb (m : \u2124), int.fract (sqrt 2 * \u2191m)) '' set.univ \u2227 \n   b \u2208 (\u03bb (m : \u2124), int.fract (sqrt 2 * \u2191m)) '' set.univ \u2227 a \u2260 b,\n   from by auto [h2, int.fract_ne_zero],\n\n   have h4 : closure ((\u03bb (m : \u2124), int.fract (sqrt 2 * \u2191m)) '' (@set.univ \u2124)) \u2260 \u2205,\n   from by auto [set.mem_closure_iff, h3],\n\n   have h5 : (\u03bb (m : \u2124), int.fract (sqrt 2 * \u2191m)) '' (@set.univ \u2124) \u2286 set.Icc 0 1,\n   from by auto [int.fract_le_one],\n\n   have h6 : closure ((\u03bb (m : \u2124), int.fract (sqrt 2 * \u2191m)) '' (@set.univ \u2124)) \u2286 set.Icc 0 1,\n   from by auto [set.closure_mono],\n   \n   have h7 : set.Icc 0 1 \u2286 closure ((\u03bb (m : \u2124), int.fract (sqrt 2 * \u2191m)) '' (@set.univ \u2124)),\n   from by auto [set.mem_Icc, set.mem_closure_iff],\n\n   have h8 : set.Icc 0 1 = closure ((\u03bb (m : \u2124), int.fract (sqrt 2 * \u2191m)) '' (@set.univ \u2124)),\n   from by auto [set.subset_iff, h4, h5, h6, h7],\n\n   show closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1,\n   from by simp [h8, mul_comm],\nend\n\n--OUTPUT 10\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 \u2208 univ, \n        from \u27e8int.fract_int x, by simp [x]\u27e9,\n        obtain \u27e8q\u2080, hq\u2080, hq\u2080_in\u27e9 : \u2203 (q : \u2124), x < q + 1 \u2227 q \u2208 univ, from exists_nat_one_lt hx_in,\n        have h\u03b1_pos : 0 < \u03b1, from hx_in.2.1,\n        have hx_nonneg : 0 \u2264 x, from hx_in.2.2,\n        obtain \u27e8\u27e8q\u2081, hq\u2081_in, hq\u2081\u27e9, \u27e8q\u2082, hq\u2082_in, hq\u2082\u27e9\u27e9 : \u2203 (q\u2081 q\u2082 : \u2124), x < q\u2081 \u2227 q\u2081 \u2208 univ \u2227 q\u2082 \u2264 x \u2227 q\u2082 \u2208 univ, \n        from exists_nat_add_one_lt hq\u2080_in,\n        have hq\u2081_nat : 0 < q\u2081, from hq\u2081,\n        have hq\u2082_nat : 0 < q\u2082, from lt_of_le_of_lt hq\u2082.2 hq\u2082,\n        have hx_nat : 0 < x, from lt_of_le_of_lt hq\u2082.2 hq\u2082,\n        have hq_pos : 0 < (q\u2081 + q\u2082 : \u2124), from add_pos hq\u2081_nat hq\u2082_nat,\n        have hqpos_nat : 0 < \u2191(q\u2081 + q\u2082), from hq_pos,\n        have hrecip : (\u2191(q\u2081 + q\u2082))\u207b\u00b9 > 0, from recip_pos hqpos_nat,\n        obtain \u27e8N, hN\u27e9 : \u2203 (N : \u2115), \u2200 (n : \u2115), n \u2265 N \u2192 |(\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u03b1 - \u2191(q\u2081 + q\u2082)\u207b\u00b9 * (q\u2081 + q\u2082 : \u2124) * \u2191n| < 1, from exists_rational_neighbourhood h\u03b1_irrat h\u03b1_pos,\n        have h1 : |(\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u03b1 - \u2191(q\u2081 + q\u2082)\u207b\u00b9 * (q\u2081 + q\u2082 : \u2124) * \u2191N| < 1, from hN N (le_refl N),\n        have h2 : |(\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u03b1 - \u2191(q\u2081 + q\u2082)\u207b\u00b9 * (q\u2081 + q\u2082 : \u2124) * \u2191N| \u2264 1, from h1,\n        have h3 : 1 \u2264 (\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u2191(q\u2081 + q\u2082), from by {rw mul_one, exact le_refl _},\n        have h4 : \u2191(q\u2081 + q\u2082)\u207b\u00b9 * \u2191(q\u2081 + q\u2082) \u2264 (\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u2191(q\u2081 + q\u2082), from le_refl _,\n        have h5 : (\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u2191(q\u2081 + q\u2082) \u2264 1, from le_of_le_of_ge h4 h3,\n        have h6 : (\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u2191(q\u2081 + q\u2082) \u2264 |(\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u03b1 - \u2191(q\u2081 + q\u2082)\u207b\u00b9 * (q\u2081 + q\u2082 : \u2124) * \u2191N|, from le_of_le_of_ge h5 h2,\n        have h7 : -((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u2191(q\u2081 + q\u2082)) \u2264 |(\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u03b1 - \u2191(q\u2081 + q\u2082)\u207b\u00b9 * (q\u2081 + q\u2082 : \u2124) * \u2191N|, from le_of_le_of_ge (neg_le_neg_of_le h6) (neg_nonpos_of_nonneg hq_pos),\n        have h8 : -((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u2191(q\u2081 + q\u2082)) \u2264 -1, from le_of_le_of_ge h7 h5,\n        have h9 : -((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u2191(q\u2081 + q\u2082)) \u2264 -1, from h8,\n        have h10 : -1 \u2264 (\u2191(q\u2081 + q\u2082))\u207b\u00b9 * \u2191(q\u2081 + q\u2082), from le_of_le_of_ge h9 h3,\n        have h11 : -1 \u2264 (\u2191(q\u2081 + q\u2082))\u207b\u00b9 * (q\u2081 + q\u2082), from by {rw mul_comm, exact h10},\n        have h12 : -((\u2191(q\u2081 + q\u2082))\u207b\u00b9) \u2264 -((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * (q\u2081 + q\u2082))\u207b\u00b9, from by {rw neg_inv_of_neg_of_pos hq_pos, exact h11},\n        have h13 : -((\u2191(q\u2081 + q\u2082))\u207b\u00b9) \u2264 -((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * (q\u2081 + q\u2082))\u207b\u00b9, from h12,\n        have h14 : -((\u2191(q\u2081 + q\u2082))\u207b\u00b9) * ((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * (q\u2081 + q\u2082)) \u2264 ((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * (q\u2081 + q\u2082)) * (-((\u2191(q\u2081 + q\u2082))\u207b\u00b9)), from mul_le_mul_of_nonneg_left h13 (le_of_lt hrecip),\n        have h15 : -1 \u2264 ((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * (q\u2081 + q\u2082)) * (-((\u2191(q\u2081 + q\u2082))\u207b\u00b9)), from h14,\n        have h16 : -(\u2191(q\u2081 + q\u2082)\u207b\u00b9) \u2264 ((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * (q\u2081 + q\u2082)) * (-((\u2191(q\u2081 + q\u2082))\u207b\u00b9)), from h15,\n        have h17 : -(\u2191(q\u2081 + q\u2082)\u207b\u00b9) \u2264 ((\u2191(q\u2081 + q\u2082))\u207b\u00b9 * (q\u2081 + q\u2082)) * (-1), from h16,\n        have h18 : -(\u2191(q\u2081 + q\u2082)\u207b\u00b9) \u2264 (\u2191(q\u2081 + q\u2082\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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from by auto [h2],\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from by auto [abs_sub_lt_iff] using [linarith],\n  \n  assume (h7 : \u03b5 > 0),\n\n  cases h2 \u03b5 h7 with N1 h8,\n  cases h3 \u03b5 h7 with N2 h9,\n  let N := max N1 N2,\n  use N,\n\n  have h10 : \u2200 n > N, n > N1 \u2227 n > N2 := by auto [lt_of_le_of_lt, le_max_left, le_max_right],\n  \n  have h11 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \n  from by auto [h8, h10, h5, h9],\n\n  have h15 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \n  from by auto [h11] using [linarith],\n\n  show  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 {\u03b9 : Type} {gri : ground_interpretation \u03b9}\nlocal notation `\ud835\udd3d` := formula \u03b9 gri\nlocal notation `\ud835\udd4b` := type \u03b9 gri\n\n-- structure majorizability :=\n-- (\ud835\udd44 : \ud835\udd4b \u2192 \ud835\udd4b)\n-- (\ud835\udd44_inh : \u2200 {\u03c3 : \ud835\udd4b}, \u2225\ud835\udd44 \u03c3\u2225)\n-- (\ud835\udd44_\ud835\udd46 : \ud835\udd44 \ud835\udd46 = \ud835\udd46)\n-- (\ud835\udd44_app : \u2200 (\u03c3 \u03c4 : \ud835\udd4b), \ud835\udd44 (\u03c3 \u21a3 \u03c4) = ((\ud835\udd44 \u03c3) \u21a3 (\ud835\udd44 \u03c4)))\n-- (majorizable : \u2200 {\u03c3 : \ud835\udd4b}, \u2225\u03c3\u2225 \u2192 Prop)\n-- (majorizes : \u2200 {\u03c3 : \ud835\udd4b}, \u2225\u03c3\u2225 \u2192 \u2225\ud835\udd44 \u03c3\u2225 \u2192 Prop)\n-- (majorizer : \u2200 {\u03c3 : \ud835\udd4b} (x : \u2225\u03c3\u2225), {x' : \u2225\ud835\udd44 \u03c3\u2225 // majorizable x \u2192 majorizes x x'})\n-- (majorizer_app : \u2200 (\u03c3 \u03c4 : \ud835\udd4b) (x : \u03c3) (x' : \ud835\udd44 \u03c3) (y : \u03c3 \u21a3 \u03c4) (y' : \ud835\udd44 (\u03c3 \u21a3 \u03c4)), majorizes x x' \u2192 majorizes y y' \u2192 majorizes (y x) (y' x'))\n\nclass maj_type (\ud835\udd44 : \ud835\udd4b \u2192 \ud835\udd4b) :=\n(\ud835\udd44_\ud835\udd46 : \ud835\udd44 \ud835\udd46 = \ud835\udd46)\n(\ud835\udd44_app (\u03c3 \u03c4 : \ud835\udd4b) : \ud835\udd44 (\u03c3 \u21a3 \u03c4) = (\ud835\udd44 \u03c3 \u21a3 \ud835\udd44 \u03c4))\n\nattribute [simp] maj_type.\ud835\udd44_app\n\n@[simp]\nlemma l' {\ud835\udd44 : \ud835\udd4b \u2192 \ud835\udd4b} [maj_type \ud835\udd44] : \u2225\ud835\udd44 \ud835\udd46\u2225 = \u2115 := sorry\n\n@[simp]\nlemma l {\ud835\udd44 : \ud835\udd4b \u2192 \ud835\udd4b} [maj_type \ud835\udd44] {\u03c3 \u03c4 : \ud835\udd4b} : \u2225\ud835\udd44 (\u03c3 \u21a3 \u03c4)\u2225 = (\u2225\ud835\udd44 \u03c3\u2225 \u2192 \u2225\ud835\udd44 \u03c4\u2225) := sorry\n\ninstance i {\ud835\udd44 : \ud835\udd4b \u2192 \ud835\udd4b} [maj_type \ud835\udd44] : linear_order \u2225\ud835\udd44 \ud835\udd46\u2225 := by {\n  simp only [l'],\n  exact nat.linear_order,\n}\n\nstructure majorizability (\ud835\udd44 : \ud835\udd4b \u2192 \ud835\udd4b) [maj_type \ud835\udd44] :=\n(majorizes : \u2200 {\u03c3 : \ud835\udd4b}, \u2225\u03c3\u2225 \u2192 \u2225\ud835\udd44 \u03c3\u2225 \u2192 Prop)\n(majorizes_le : \u2200 {x : \u2225\ud835\udd46\u2225} {x' : \u2225\ud835\udd44 \ud835\udd46\u2225}, majorizes x x' \u2192 x \u2264 type.cast (maj_type.\ud835\udd44_\ud835\udd46) x')\n(majorizes_app : \u2200 {\u03c3 \u03c4 : \ud835\udd4b} (x : \u2225\u03c3\u2225) (x' : \u2225\ud835\udd44 \u03c3\u2225) (y : \u2225\u03c3 \u21a3 \u03c4\u2225) (y' : \u2225\ud835\udd44 (\u03c3 \u21a3 \u03c4)\u2225), \n  majorizes x x' \u2192 majorizes y y' \u2192 majorizes (y x) ((type.cast (maj_type.\ud835\udd44_app _ _) y') x'))\n(majorizer : \u03a0 {\u03c3 : \ud835\udd4b}, \u2225\u03c3\u2225 \u2192 \u2225\ud835\udd44 \u03c3\u2225)\n(majorizer_majorizes : \u2200 {\u03c3 : \ud835\udd4b} (x : \u2225\u03c3\u2225), majorizes x (majorizer x))\n-- attribute [simp, reducible] majorizability.\ud835\udd44_\ud835\udd46\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\u00f6lzl, 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} {\u03b9 : Type x} {k : Type y} {A : Type z} {a b : R}\n  {m n : \u2115}\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\u2093'. -/\n@[elab_as_elim]\nprotected theorem induction_on {M : R[X] \u2192 Prop} (p : R[X]) (h_C : \u2200 a, M (C a))\n    (h_add : \u2200 p q, M p \u2192 M q \u2192 M (p + q))\n    (h_monomial : \u2200 (n : \u2115) (a : R), M (C a * X ^ n) \u2192 M (C a * X ^ (n + 1))) : M p :=\n  by\n  have A : \u2200 {n : \u2115} {a}, M (C a * X ^ n) := by\n    intro n a\n    induction' n with n ih\n    \u00b7 simp only [pow_zero, mul_one, h_C]\n    \u00b7 exact h_monomial _ _ ih\n  have B : \u2200 s : Finset \u2115, M (s.Sum fun n : \u2115 => C (p.coeff n) * X ^ n) :=\n    by\n    apply Finset.induction\n    \u00b7 convert h_C 0\n      exact C_0.symm\n    \u00b7 intro n s ns ih\n      rw [sum_insert ns]\n      exact h_add _ _ A ih\n  rw [\u2190 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'\u2093'. -/\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] \u2192 Prop} (p : R[X]) (h_add : \u2200 p q, M p \u2192 M q \u2192 M (p + q))\n    (h_monomial : \u2200 (n : \u2115) (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\u2093'. -/\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 : \u2200 i : \u2115, C (f.coeff i) \u2208 I) :\n    Ideal.span { g | \u2203 i, g = C (f.coeff i) } \u2264 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\u2093'. -/\ntheorem mem_span_C_coeff : f \u2208 Ideal.span { g : R[X] | \u2203 i : \u2115, g = C (coeff f i) } :=\n  by\n  let p := Ideal.span { g : R[X] | \u2203 i : \u2115, 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) \u2208 p := by\n    apply subset_span\n    simp\n  have : monomial n (1 : R) \u2022 C (coeff f n) \u2208 p := p.smul_mem _ this\n  convert this using 1\n  simp only [monomial_mul_C, one_mul, smul_eq_mul]\n  rw [\u2190 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\u2093'. -/\ntheorem exists_C_coeff_not_mem : f \u2209 I \u2192 \u2203 i : \u2115, C (coeff f i) \u2209 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\u00f6nne, 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 : \u211d} (h\u2081 : x \u2260 -1) (h\u2082 : x \u2260 1) :\n    HasStrictDerivAt arcsin (1 / sqrt (1 - x ^ 2)) x \u2227 ContDiffAt \u211d \u22a4 arcsin x :=\n  by\n  cases' h\u2081.lt_or_lt with h\u2081 h\u2081\n  \u00b7 have : 1 - x ^ 2 < 0 := by nlinarith [h\u2081]\n    rw [sqrt_eq_zero'.2 this.le, div_zero]\n    have : arcsin =\u1da0[\ud835\udcdd x] fun _ => -(\u03c0 / 2) :=\n      (gt_mem_nhds h\u2081).mono fun y hy => arcsin_of_le_neg_one hy.le\n    exact\n      \u27e8(hasStrictDerivAt_const _ _).congr_of_eventuallyEq this.symm,\n        cont_diff_at_const.congr_of_eventually_eq this\u27e9\n  cases' h\u2082.lt_or_lt with h\u2082 h\u2082\n  \u00b7 have : 0 < sqrt (1 - x ^ 2) := sqrt_pos.2 (by nlinarith [h\u2081, h\u2082])\n    simp only [\u2190 cos_arcsin, one_div] at this\u22a2\n    exact\n      \u27e8sin_local_homeomorph.has_strict_deriv_at_symm \u27e8h\u2081, h\u2082\u27e9 this.ne' (has_strict_deriv_at_sin _),\n        sin_local_homeomorph.cont_diff_at_symm_deriv this.ne' \u27e8h\u2081, h\u2082\u27e9 (has_deriv_at_sin _)\n          cont_diff_sin.cont_diff_at\u27e9\n  \u00b7 have : 1 - x ^ 2 < 0 := by nlinarith [h\u2082]\n    rw [sqrt_eq_zero'.2 this.le, div_zero]\n    have : arcsin =\u1da0[\ud835\udcdd x] fun _ => \u03c0 / 2 := (lt_mem_nhds h\u2082).mono fun y hy => arcsin_of_one_le hy.le\n    exact\n      \u27e8(hasStrictDerivAt_const _ _).congr_of_eventuallyEq this.symm,\n        cont_diff_at_const.congr_of_eventually_eq this\u27e9\n#align real.deriv_arcsin_aux Real.deriv_arcsin_aux\n\ntheorem hasStrictDerivAt_arcsin {x : \u211d} (h\u2081 : x \u2260 -1) (h\u2082 : x \u2260 1) :\n    HasStrictDerivAt arcsin (1 / sqrt (1 - x ^ 2)) x :=\n  (deriv_arcsin_aux h\u2081 h\u2082).1\n#align real.has_strict_deriv_at_arcsin Real.hasStrictDerivAt_arcsin\n\ntheorem hasDerivAt_arcsin {x : \u211d} (h\u2081 : x \u2260 -1) (h\u2082 : x \u2260 1) :\n    HasDerivAt arcsin (1 / sqrt (1 - x ^ 2)) x :=\n  (hasStrictDerivAt_arcsin h\u2081 h\u2082).HasDerivAt\n#align real.has_deriv_at_arcsin Real.hasDerivAt_arcsin\n\ntheorem contDiffAt_arcsin {x : \u211d} (h\u2081 : x \u2260 -1) (h\u2082 : x \u2260 1) {n : \u2115\u221e} : ContDiffAt \u211d n arcsin x :=\n  (deriv_arcsin_aux h\u2081 h\u2082).2.of_le le_top\n#align real.cont_diff_at_arcsin Real.contDiffAt_arcsin\n\ntheorem hasDerivWithinAt_arcsin_Ici {x : \u211d} (h : x \u2260 -1) :\n    HasDerivWithinAt arcsin (1 / sqrt (1 - x ^ 2)) (Ici x) x :=\n  by\n  rcases em (x = 1) with (rfl | h')\n  \u00b7\n    convert(hasDerivWithinAt_const _ _ (\u03c0 / 2)).congr _ _ <;>\n      simp (config := { contextual := true }) [arcsin_of_one_le]\n  \u00b7 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 : \u211d} (h : x \u2260 1) :\n    HasDerivWithinAt arcsin (1 / sqrt (1 - x ^ 2)) (Iic x) x :=\n  by\n  rcases em (x = -1) with (rfl | h')\n  \u00b7\n    convert(hasDerivWithinAt_const _ _ (-(\u03c0 / 2))).congr _ _ <;>\n      simp (config := { contextual := true }) [arcsin_of_le_neg_one]\n  \u00b7 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 : \u211d} :\n    DifferentiableWithinAt \u211d arcsin (Ici x) x \u2194 x \u2260 -1 :=\n  by\n  refine' \u27e8_, fun h => (has_deriv_within_at_arcsin_Ici h).DifferentiableWithinAt\u27e9\n  rintro h rfl\n  have : sin \u2218 arcsin =\u1da0[\ud835\udcdd[\u2265] (-1 : \u211d)] id := by\n    filter_upwards [Icc_mem_nhdsWithin_Ici\n        \u27e8le_rfl, neg_lt_self (zero_lt_one' \u211d)\u27e9]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 : \u211d} :\n    DifferentiableWithinAt \u211d arcsin (Iic x) x \u2194 x \u2260 1 :=\n  by\n  refine' \u27e8fun h => _, fun h => (has_deriv_within_at_arcsin_Iic h).DifferentiableWithinAt\u27e9\n  rw [\u2190 neg_neg x, \u2190 image_neg_Ici] at h\n  have := (h.comp (-x) differentiable_within_at_id.neg (maps_to_image _ _)).neg\n  simpa [(\u00b7 \u2218 \u00b7), differentiable_within_at_arcsin_Ici] using this\n#align real.differentiable_within_at_arcsin_Iic Real.differentiableWithinAt_arcsin_Iic\n\ntheorem differentiableAt_arcsin {x : \u211d} : DifferentiableAt \u211d arcsin x \u2194 x \u2260 -1 \u2227 x \u2260 1 :=\n  \u27e8fun h =>\n    \u27e8differentiableWithinAt_arcsin_Ici.1 h.DifferentiableWithinAt,\n      differentiableWithinAt_arcsin_Iic.1 h.DifferentiableWithinAt\u27e9,\n    fun h => (hasDerivAt_arcsin h.1 h.2).DifferentiableAt\u27e9\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 \u2260 -1 \u2227 x \u2260 1\n  \u00b7 exact (has_deriv_at_arcsin h.1 h.2).deriv\n  \u00b7 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 \u211d arcsin ({-1, 1}\u1d9c) := fun x hx =>\n  (differentiableAt_arcsin.2\n      \u27e8fun h => hx (Or.inl h), fun h => hx (Or.inr h)\u27e9).DifferentiableWithinAt\n#align real.differentiable_on_arcsin Real.differentiableOn_arcsin\n\ntheorem contDiffOn_arcsin {n : \u2115\u221e} : ContDiffOn \u211d n arcsin ({-1, 1}\u1d9c) := 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 : \u211d} {n : \u2115\u221e} : ContDiffAt \u211d n arcsin x \u2194 n = 0 \u2228 x \u2260 -1 \u2227 x \u2260 1 :=\n  \u27e8fun 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 \u25b8 (contDiff_zero.2 continuous_arcsin).ContDiffAt) fun hx =>\n      contDiffAt_arcsin hx.1 hx.2\u27e9\n#align real.cont_diff_at_arcsin_iff Real.contDiffAt_arcsin_iff\n\nend Arcsin\n\nsection Arccos\n\ntheorem hasStrictDerivAt_arccos {x : \u211d} (h\u2081 : x \u2260 -1) (h\u2082 : x \u2260 1) :\n    HasStrictDerivAt arccos (-(1 / sqrt (1 - x ^ 2))) x :=\n  (hasStrictDerivAt_arcsin h\u2081 h\u2082).const_sub (\u03c0 / 2)\n#align real.has_strict_deriv_at_arccos Real.hasStrictDerivAt_arccos\n\ntheorem hasDerivAt_arccos {x : \u211d} (h\u2081 : x \u2260 -1) (h\u2082 : x \u2260 1) :\n    HasDerivAt arccos (-(1 / sqrt (1 - x ^ 2))) x :=\n  (hasDerivAt_arcsin h\u2081 h\u2082).const_sub (\u03c0 / 2)\n#align real.has_deriv_at_arccos Real.hasDerivAt_arccos\n\ntheorem contDiffAt_arccos {x : \u211d} (h\u2081 : x \u2260 -1) (h\u2082 : x \u2260 1) {n : \u2115\u221e} : ContDiffAt \u211d n arccos x :=\n  contDiffAt_const.sub (contDiffAt_arcsin h\u2081 h\u2082)\n#align real.cont_diff_at_arccos Real.contDiffAt_arccos\n\ntheorem hasDerivWithinAt_arccos_Ici {x : \u211d} (h : x \u2260 -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 : \u211d} (h : x \u2260 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 : \u211d} :\n    DifferentiableWithinAt \u211d arccos (Ici x) x \u2194 x \u2260 -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 : \u211d} :\n    DifferentiableWithinAt \u211d arccos (Iic x) x \u2194 x \u2260 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 : \u211d} : DifferentiableAt \u211d arccos x \u2194 x \u2260 -1 \u2227 x \u2260 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 \u211d arccos ({-1, 1}\u1d9c) :=\n  differentiableOn_arcsin.const_sub _\n#align real.differentiable_on_arccos Real.differentiableOn_arccos\n\ntheorem contDiffOn_arccos {n : \u2115\u221e} : ContDiffOn \u211d n arccos ({-1, 1}\u1d9c) :=\n  contDiffOn_const.sub contDiffOn_arcsin\n#align real.cont_diff_on_arccos Real.contDiffOn_arccos\n\ntheorem contDiffAt_arccos_iff {x : \u211d} {n : \u2115\u221e} : ContDiffAt \u211d n arccos x \u2194 n = 0 \u2228 x \u2260 -1 \u2227 x \u2260 1 :=\n  by\n  refine' Iff.trans \u27e8fun h => _, fun h => _\u27e9 cont_diff_at_arcsin_iff <;>\n    simpa [arccos] using (@contDiffAt_const _ _ _ _ _ _ _ _ _ _ (\u03c0 / 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 {\u03b1 : Type u} [has_betweenness \u03b1]\n\n@[reducible]\ndef generates (b : set \u03b1) (s : set \u03b1) (h : is_affine s) : Prop :=\naffine_hull b = s\n\ntheorem generates.of_span {s : set \u03b1} (h : is_affine s) : generates s s h :=\nh\n\n@[reducible]\ndef generators {s : set \u03b1} (h : is_affine s) : set (set \u03b1) :=\n{b | generates b s h}\n\nnamespace generators\n\ntheorem self_gens {s : set \u03b1} : \u2200 h : is_affine s, s \u2208 generators h :=\ngenerates.of_span\n\ntheorem is_nonempty {s : set \u03b1} (h : is_affine s) : (generators h).nonempty :=\n\u27e8s, self_gens h\u27e9\n\nend generators\n\n@[reducible]\ndef is_basis {s : set \u03b1} {h : is_affine s} (b : generators h) : Prop :=\n\u2200 b' \u2208 generators h, #b \u2264 #b'\n\n@[reducible]\ndef bases {s : set \u03b1} (h : is_affine s) : set (@generators s h) :=\nis_basis\n\nend\n\nprotected def {u} bases.univ (\u03b1 : Type u) [has_betweenness \u03b1] : set (generators is_affine.univ) :=\n@bases \u03b1 _ _ _\n\nsection\nuniverse u\n\ntheorem cardinal.le_mk_le_iff_ex_sub_right {\u03b1 : Type u} {s t : set \u03b1} (h : #s \u2264 #t) :\n  \u2203 s' \u2286 t, #s' = #s :=\nbegin\n  rw cardinal.le_mk_iff_exists_subset at h,\n  rcases h with \u27e8s', _, _\u27e9,\n  exact \u27e8s', \u2039_\u203a, \u2039_\u203a\u27e9\nend\n\nparameters {\u03b1 : Type u} [has_betweenness \u03b1]\n\nnamespace bases\n\ntheorem is_nonempty {s : set \u03b1} (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 \u27e8\u27e8w, h\u27e9, trivial\u27e9 },\n  let f := \u03bb l r : generators h, #l < #r,\n  rcases well_founded.has_min (inv_image.wf _ cardinal.wf) _ gne with \u27e8b, _, hb\u27e9,\n  refine \u27e8b, \u03bb b' hb', _\u27e9,\n  specialize hb \u27e8b', hb'\u27e9 trivial,\n  change \u00ac _ < _ at hb,\n  simp at hb,\n  assumption\nend\n\ninstance {s : set \u03b1} (h : is_affine s) : nonempty (bases h) :=\n\u27e8\u27e8(is_nonempty h).some, (is_nonempty h).some_mem\u27e9\u27e9\n\ndef basis_card {s : set \u03b1} (h : is_affine s) : cardinal :=\n#(nonempty h).some\n\ntheorem all_bases_same_card {s : set \u03b1} {h : is_affine s} (b : bases h) : #b = basis_card h :=\nbegin\n  rcases b with \u27e8\u27e8g, hg\u27e9, hbg\u27e9,\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 \u03b1} (hs : is_affine s) (g : generators _ hs) :\n  \u2203 (s' : set \u03b1) (b : bases hs), s' \u222a b = g :=\nbegin\n  by_cases hg : is_basis _ _ g, { exact \u27e8\u2205, \u27e8g, hg\u27e9, by simp\u27e9 },\n  rw is_basis at hg, push_neg at hg,\n  rcases hg with \u27e8b, hbg, \u27e8hb : _ \u2264 #g.val, hb' : \u00ac (#g.val \u2264 _)\u27e9\u27e9,\n  by_contra h,\n  push_neg at h,\n  specialize h b,\nend\n\n--theorem ex_subgen {s : set \u03b1} {hs : is_affine s} {g : generators _ hs} (h : )\n\ntheorem ex_basis_sub_gen {s : set \u03b1} (hs : is_affine s) (g : generators _ hs) :\n  \u2203 b : bases hs, b.val.val \u2286 g.val :=\nbegin\n  by_cases hg : is_basis _ _ g, { exact \u27e8\u27e8g, hg\u27e9, set.subset.rfl\u27e9 },\n  rw is_basis at hg, push_neg at hg,\n  rcases hg with \u27e8b, hbg, \u27e8hb : _ \u2264 #g.val, hb' : \u00ac (#g.val \u2264 _)\u27e9\u27e9,\n  rw cardinal.le_mk_iff_exists_subset at hb hb',\n  rcases hb with \u27e8w, hw, hw'\u27e9,\n  push_neg at hb',\n  refine \u27e8\u27e8\u27e8w, _\u27e9, _\u27e9, hw\u27e9,\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\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable section\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nnamespace CategoryTheory.Functor\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} 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 \u2964 D) : Prop where\n  map_zero' : \u2200 X Y : C, F.map (0 : X \u27f6 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\u2093'. -/\n@[simp]\nprotected theorem map_zero (F : C \u2964 D) [PreservesZeroMorphisms F] (X Y : C) :\n    F.map (0 : X \u27f6 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\u2093'. -/\ntheorem zero_of_map_zero (F : C \u2964 D) [PreservesZeroMorphisms F] [Faithful F] {X Y : C} (f : X \u27f6 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\u2093'. -/\ntheorem map_eq_zero_iff (F : C \u2964 D) [PreservesZeroMorphisms F] [Faithful F] {X Y : C} {f : X \u27f6 Y} :\n    F.map f = 0 \u2194 f = 0 :=\n  \u27e8F.zero_of_map_zero _, by\n    rintro rfl\n    exact F.map_zero _ _\u27e9\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 \u2964 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 \u27f6 Y) = F.map 0 \u226b F.map (adj.unit.app Y) \u226b adj.counit.app (F.obj Y) := _\n      _ = F.map 0 \u226b F.map ((right_adjoint F).map (0 : F.obj X \u27f6 _)) \u226b adj.counit.app (F.obj Y) := _\n      _ = 0 := _\n      \n    \u00b7 rw [adjunction.left_triangle_components]\n      exact (category.comp_id _).symm\n    \u00b7 simp only [\u2190 category.assoc, \u2190 F.map_comp, zero_comp]\n    \u00b7 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 \u2964 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 \u27f6 Y) = adj.unit.app (G.obj X) \u226b G.map (adj.counit.app X) \u226b G.map 0 := _\n      _ = adj.unit.app (G.obj X) \u226b G.map ((left_adjoint G).map (0 : _ \u27f6 G.obj X)) \u226b G.map 0 := _\n      _ = 0 := _\n      \n    \u00b7 rw [adjunction.right_triangle_components_assoc]\n    \u00b7 simp only [\u2190 G.map_comp, comp_zero]\n    \u00b7 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 \u2964 D) [Full F] :\n    PreservesZeroMorphisms F\n    where map_zero' X Y :=\n    calc\n      F.map (0 : X \u27f6 Y) = F.map (0 \u226b F.preimage (0 : F.obj Y \u27f6 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 \u2964 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\u2093'. -/\n/-- A functor that preserves zero morphisms also preserves the zero object. -/\n@[simps]\ndef mapZeroObject [PreservesZeroMorphisms F] : F.obj 0 \u2245 0\n    where\n  Hom := 0\n  inv := 0\n  hom_inv_id' := by rw [\u2190 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\u2093'. -/\ntheorem preservesZeroMorphisms_of_map_zero_object (i : F.obj 0 \u2245 0) : PreservesZeroMorphisms F :=\n  {\n    map_zero' := fun X Y =>\n      calc\n        F.map (0 : X \u27f6 Y) = F.map (0 : X \u27f6 0) \u226b F.map 0 := by rw [\u2190 functor.map_comp, comp_zero]\n        _ = F.map 0 \u226b (i.Hom \u226b i.inv) \u226b 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 \u226a\u226b\n      PreservesInitial.iso F \u226a\u226b 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 \u226a\u226b\n      PreservesTerminal.iso F \u226a\u226b 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 \u226a\u226b mapZeroObject F \u226a\u226b 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 \u226a\u226b\n      (mapZeroObject F).symm \u226a\u226b (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 : \u2115)  [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) \u2102_[p]\n\ndef B_HT := (Cp_x_y  p) \u29f8 (ideal.span {(X 0 * X 1 - 1)} : ideal (Cp_x_y  p))\n\n\ninstance O_C_p_mod_p.char_p : char_p (\ud835\udcde_\u2102_[p] \u29f8 (ideal.span{p} : ideal \ud835\udcde_\u2102_[p])) p := sorry\ndef E := ring.perfection (\ud835\udcde_\u2102_[p] \u29f8 (ideal.span{p} : ideal \ud835\udcde_\u2102_[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) \u2102_[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 \u27f6 Y) \u2192 (F.obj X \u27f6 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 \u2964 D) [F.additive] : Prop :=\n(map_smul' : \u03a0 {X Y : C} {f : X \u27f6 Y} {r : R}, F.map (r \u2022 f) = r \u2022 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 \u2964 D) [additive F] [linear R F]\n\n@[simp]\nlemma map_smul {X Y : C} (r : R) (f : X \u27f6 Y) : F.map (r \u2022 f) = r \u2022 F.map f :=\nfunctor.linear.map_smul'\n\ninstance : linear R (\ud835\udfed C) :=\n{}\n\ninstance {E : Type*} [category E] [preadditive E] [category_theory.linear R E]\n  (G : D \u2964 E) [additive G] [linear R G]:\n  linear R (F \u22d9 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 \u27f6 Y) \u2192\u2097[R] (F.obj X \u27f6 F.obj Y) :=\n{ map_smul' := \u03bb r f, F.map_smul r f,\n  ..F.map_add_hom }\n\nlemma coe_map_linear_map {X Y : C} : \u21d1(F.map_linear_map R : (X \u27f6 Y) \u2192\u2097[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 \u2192 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 \u2964 D) [additive F]\n\ninstance nat_linear : F.linear \u2115 :=\n{ map_smul' := \u03bb X Y f r, F.map_add_hom.map_nsmul f r, }\n\ninstance int_linear : F.linear \u2124 :=\n{ map_smul' := \u03bb X Y f r, F.map_add_hom.map_zsmul f r, }\n\nvariables [category_theory.linear \u211a C] [category_theory.linear \u211a D]\n\ninstance rat_linear : F.linear \u211a :=\n{ map_smul' := \u03bb 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 \u224c D) [e.functor.additive] [e.functor.linear R] :\n  e.inverse.linear R :=\n{ map_smul' := \u03bb 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u211a 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, \u211a, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\nnamespace rat\nvariable {\u03b1 : Type*}\nopen_locale rat\n\nsection with_div_ring\nvariable [division_ring \u03b1]\n\n/-- Construct the canonical injection from `\u211a` 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 \u211a \u03b1 := \u27e8\u03bb r, r.1 / r.2\u27e9\n\n@[simp] theorem cast_of_int (n : \u2124) : (of_int n : \u03b1) = n :=\nshow (n / (1:\u2115) : \u03b1) = n, by rw [nat.cast_one, div_one]\n\n@[simp, norm_cast] theorem cast_coe_int (n : \u2124) : ((n : \u211a) : \u03b1) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp, norm_cast] theorem cast_coe_nat (n : \u2115) : ((n : \u211a) : \u03b1) = n := cast_coe_int n\n\n@[simp, norm_cast] theorem cast_zero : ((0 : \u211a) : \u03b1) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp, norm_cast] theorem cast_one : ((1 : \u211a) : \u03b1) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem cast_commute (r : \u211a) (a : \u03b1) : commute \u2191r a :=\n(r.1.cast_commute a).div_left (r.2.cast_commute a)\n\ntheorem cast_comm (r : \u211a) (a : \u03b1) : (r : \u03b1) * a = a * r :=\n(cast_commute r a).eq\n\ntheorem commute_cast (a : \u03b1) (r : \u211a) : commute a r :=\n(r.cast_commute a).symm\n\n@[norm_cast] theorem cast_mk_of_ne_zero (a b : \u2124)\n  (b0 : (b:\u03b1) \u2260 0) : (a /. b : \u03b1) = a / b :=\nbegin\n  have b0' : b \u2260 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:\u03b1) \u2260 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:\u2124) \u2223 b, by rwa e at dd) with k ke,\n    have : (b:\u03b1) = (d:\u03b1) * (k:\u03b1), {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 : \u2124 \u2192 \u03b1) ((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 : \u03b1) = n / d,\n  rw [div_eq_mul_inv, eq_div_iff_mul_eq d0, mul_assoc, (d.commute_cast _).eq,\n      \u2190 mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\n@[norm_cast] theorem cast_add_of_ne_zero : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m + n : \u211a) : \u03b1) = m + n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', add_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * (d\u2082 * (d\u2082\u207b\u00b9 * d\u2081\u207b\u00b9)) +\n    n\u2082 * (d\u2081 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9 : \u03b1) = n\u2081 * d\u2081\u207b\u00b9 + n\u2082 * d\u2082\u207b\u00b9,\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\u20810, d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820]} },\n  rw [\u2190 mul_assoc (d\u2082:\u03b1), mul_inv_cancel d\u20820, one_mul,\n      (nat.cast_commute _ _).eq], simp [d\u20810, mul_assoc]\nend\n\n@[simp, norm_cast] theorem cast_neg : \u2200 n, ((-n : \u211a) : \u03b1) = -n\n| \u27e8n, d, h, c\u27e9 := show (\u2191-n / d : \u03b1) = -(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 : \u211a}\n  (m0 : (m.denom : \u03b1) \u2260 0) (n0 : (n.denom : \u03b1) \u2260 0) : ((m - n : \u211a) : \u03b1) = m - n :=\nhave ((-n).denom : \u03b1) \u2260 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 : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m * n : \u211a) : \u03b1) = m * n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', mul_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * ((n\u2082 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9) : \u03b1) = n\u2081 * (d\u2081\u207b\u00b9 * (n\u2082 * d\u2082\u207b\u00b9)),\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\u20810, d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820]} },\n  rw [(d\u2081.commute_cast (_:\u03b1)).inv_right'.eq]\nend\n\n@[norm_cast] theorem cast_inv_of_ne_zero : \u2200 {n : \u211a},\n  (n.num : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9\n| \u27e8n, d, h, c\u27e9 := \u03bb (n0 : (n:\u03b1) \u2260 0) (d0 : (d:\u03b1) \u2260 0), begin\n  have n0' : (n:\u2124) \u2260 0 := \u03bb e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb 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 : \u211a} (md : (m.denom : \u03b1) \u2260 0)\n  (nn : (n.num : \u03b1) \u2260 0) (nd : (n.denom : \u03b1) \u2260 0) : ((m / n : \u211a) : \u03b1) = m / n :=\nhave (n\u207b\u00b9.denom : \u2124) \u2223 n.num,\nby conv in n\u207b\u00b9.denom { rw [\u2190(@num_denom n), inv_def] };\n   apply denom_dvd,\nhave (n\u207b\u00b9.denom : \u03b1) = 0 \u2192 (n.num : \u03b1) = 0, from\n\u03bb h, let \u27e8k, e\u27e9 := this in\n  by have := congr_arg (coe : \u2124 \u2192 \u03b1) 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 \u03b1] : \u2200 {m n : \u211a}, (m : \u03b1) = n \u2194 m = n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := begin\n  refine \u27e8\u03bb h, _, congr_arg _\u27e9,\n  have d\u20810 : d\u2081 \u2260 0 := ne_of_gt h\u2081,\n  have d\u20820 : d\u2082 \u2260 0 := ne_of_gt h\u2082,\n  have d\u2081a : (d\u2081:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20810,\n  have d\u2082a : (d\u2082:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20820,\n  rw [num_denom', num_denom'] at h \u22a2,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d\u20810, d\u20820] at h \u22a2,\n  rwa [eq_div_iff_mul_eq d\u2082a, division_def, mul_assoc, (d\u2081.cast_commute (d\u2082:\u03b1)).inv_left'.eq,\n    \u2190 mul_assoc, \u2190 division_def, eq_comm, eq_div_iff_mul_eq d\u2081a, eq_comm,\n    \u2190 int.cast_coe_nat, \u2190 int.cast_mul, \u2190 int.cast_coe_nat, \u2190 int.cast_mul,\n    int.cast_inj, \u2190 mk_eq (int.coe_nat_ne_zero.2 d\u20810) (int.coe_nat_ne_zero.2 d\u20820)] at h\nend\n\ntheorem cast_injective [char_zero \u03b1] : function.injective (coe : \u211a \u2192 \u03b1)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) = 0 \u2194 n = 0 :=\nby rw [\u2190 cast_zero, cast_inj]\n\ntheorem cast_ne_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) \u2260 0 \u2194 n \u2260 0 :=\nnot_congr cast_eq_zero\n\n@[simp, norm_cast] theorem cast_add [char_zero \u03b1] (m n) :\n  ((m + n : \u211a) : \u03b1) = 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 \u03b1] (m n) :\n  ((m - n : \u211a) : \u03b1) = 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 \u03b1] (m n) :\n  ((m * n : \u211a) : \u03b1) = 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 \u03b1] (n : \u211a) :\n  ((bit0 n : \u211a) : \u03b1) = bit0 n :=\ncast_add _ _\n\n@[simp, norm_cast] theorem cast_bit1 [char_zero \u03b1] (n : \u211a) :\n  ((bit1 n : \u211a) : \u03b1) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\nvariable (\u03b1)\n\n/-- Coercion `\u211a \u2192 \u03b1` as a `ring_hom`. -/\ndef cast_hom [char_zero \u03b1] : \u211a \u2192+* \u03b1 := \u27e8coe, cast_one, cast_mul, cast_zero, cast_add\u27e9\n\nvariable {\u03b1}\n\n@[simp] lemma coe_cast_hom [char_zero \u03b1] : \u21d1(cast_hom \u03b1) = coe := rfl\n\n@[simp, norm_cast] theorem cast_inv [char_zero \u03b1] (n) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\n(cast_hom \u03b1).map_inv _\n\n@[simp, norm_cast] theorem cast_div [char_zero \u03b1] (m n) :\n  ((m / n : \u211a) : \u03b1) = m / n :=\n(cast_hom \u03b1).map_div _ _\n\n@[norm_cast] theorem cast_mk [char_zero \u03b1] (a b : \u2124) : ((a /. b) : \u03b1) = a / b :=\nby simp only [mk_eq_div, cast_div, cast_coe_int]\n\n@[simp, norm_cast] theorem cast_pow [char_zero \u03b1] (q) (k : \u2115) :\n  ((q ^ k : \u211a) : \u03b1) = q ^ k :=\n(cast_hom \u03b1).map_pow q k\n\nend with_div_ring\n\n@[simp, norm_cast] theorem cast_nonneg [linear_ordered_field \u03b1] : \u2200 {n : \u211a}, 0 \u2264 (n : \u03b1) \u2194 0 \u2264 n\n| \u27e8n, d, h, c\u27e9 :=\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 \u03b1] {m n : \u211a} : (m : \u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw [\u2190 sub_nonneg, \u2190 cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp, norm_cast] theorem cast_lt [linear_ordered_field \u03b1] {m n : \u211a} : (m : \u03b1) < n \u2194 m < n :=\nby simpa [-cast_le] using not_congr (@cast_le \u03b1 _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) \u2264 0 \u2194 n \u2264 0 :=\nby rw [\u2190 cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field \u03b1] {n : \u211a} : (0 : \u03b1) < n \u2194 0 < n :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) < 0 \u2194 n < 0 :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp, norm_cast] theorem cast_id : \u2200 n : \u211a, \u2191n = n\n| \u27e8n, d, h, c\u27e9 := by rw [num_denom', cast_mk, mk_eq_div]\n\n@[simp, norm_cast] theorem cast_min [linear_ordered_field \u03b1] {a b : \u211a} :\n  (\u2191(min a b) : \u03b1) = min a b :=\nby by_cases a \u2264 b; simp [h, min]\n\n@[simp, norm_cast] theorem cast_max [linear_ordered_field \u03b1] {a b : \u211a} :\n  (\u2191(max a b) : \u03b1) = max a b :=\nby by_cases b \u2264 a; simp [h, max]\n\n@[simp, norm_cast] theorem cast_abs [linear_ordered_field \u03b1] {q : \u211a} :\n  ((abs q : \u211a) : \u03b1) = 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 : \u211a \u2192+* k) (r : \u211a) : f r = r :=\ncalc f r = f (r.1 / r.2) : by rw [\u2190 int.cast_coe_nat, \u2190 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 \u2192+* k') (r : \u211a) :\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 : \u211a \u2192+* R) : f = g :=\nbegin\n  ext r,\n  refine rat.num_denom_cases_on' r _,\n  intros a b b0,\n  let \u03c6 : \u2124 \u2192+* R := f.comp (int.cast_ring_hom \u211a),\n  let \u03c8 : \u2124 \u2192+* R := g.comp (int.cast_ring_hom \u211a),\n  rw [rat.mk_eq_div, int.cast_coe_nat],\n  have b0' : (b:\u211a) \u2260 0 := nat.cast_ne_zero.2 b0,\n  have : \u2200 n : \u2124, f n = g n := \u03bb n, show \u03c6 n = \u03c8 n, by rw [\u03c6.ext_int \u03c8],\n  calc f (a * b\u207b\u00b9)\n      = f a * f b\u207b\u00b9 * (g (b:\u2124) * g b\u207b\u00b9) :\n        by rw [int.cast_coe_nat, \u2190 g.map_mul, mul_inv_cancel b0', g.map_one, mul_one, f.map_mul]\n  ... = g a * f b\u207b\u00b9 * (f (b:\u2124) * g b\u207b\u00b9) : by rw [this a, \u2190 this b]\n  ... = g (a * b\u207b\u00b9) :\n        by rw [int.cast_coe_nat, mul_assoc, \u2190 mul_assoc (f b\u207b\u00b9),\n              \u2190 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 (\u211a \u2192+* R) :=\n\u27e8ring_hom.ext_rat\u27e9\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 `\u03c6`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : monoid_with_zero_hom \u211a M}\n  (same_on_int : f.comp (int.cast_ring_hom \u211a).to_monoid_with_zero_hom =\n    g.comp (int.cast_ring_hom \u211a).to_monoid_with_zero_hom) : f = g :=\nbegin\n  have same_on_int' : \u2200 k : \u2124, f k = g k := congr_fun same_on_int,\n  ext x,\n  rw [\u2190 @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 `\u03c6` and its value on `-1` completely determine `\u03c6`. -/\ntheorem ext_rat_on_pnat {f g : monoid_with_zero_hom \u211a M}\n  (same_on_neg_one : f (-1) = g (-1)) (same_on_pnat : \u2200 n : \u2115, 0 < n \u2192 f n = g n) : f = g :=\next_rat $ ext_int' (by simpa) \u2039_\u203a\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 {\u03b1 \u03b2 \u03b3 \u03b4 : 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 \u03b1) \u2192 multiset \u03b1 := sum\n\nlemma coe_join : \u2200 L : list (list \u03b1),\n  join (L.map (@coe _ (multiset \u03b1) _) : multiset (multiset \u03b1)) = L.join\n| []       := rfl\n| (l :: L) := congr_arg (\u03bb s : multiset \u03b1, \u2191l + s) (coe_join L)\n\n@[simp] lemma join_zero : @join \u03b1 0 = 0 := rfl\n@[simp] lemma join_cons (s S) : @join \u03b1 (s ::\u2098 S) = s + join S := sum_cons _ _\n@[simp] lemma join_add (S T) : @join \u03b1 (S + T) = join S + join T := sum_add _ _\n@[simp] lemma singleton_join (a) : join ({a} : multiset (multiset \u03b1)) = a := sum_singleton _\n\n@[simp] lemma mem_join {a S} : a \u2208 @join \u03b1 S \u2194 \u2203 s \u2208 S, a \u2208 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 \u03b1 S) = sum (map card S) :=\nmultiset.induction_on S (by simp) (by simp)\n\nlemma rel_join {r : \u03b1 \u2192 \u03b2 \u2192 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 : \u03b1) (s t : multiset \u03b1) (f g : \u03b1 \u2192 multiset \u03b2)\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 \u03b1) (f : \u03b1 \u2192 multiset \u03b2) : multiset \u03b2 := (s.map f).join\n\n@[simp] lemma coe_bind (l : list \u03b1) (f : \u03b1 \u2192 list \u03b2) : @bind \u03b1 \u03b2 l (\u03bb a, f a) = l.bind f :=\nby rw [list.bind, \u2190coe_join, list.map_map]; refl\n\n@[simp] lemma zero_bind : bind 0 f = 0 := rfl\n@[simp] lemma cons_bind : (a ::\u2098 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 (\u03bb a, 0 : \u03b1 \u2192 multiset \u03b2) = 0 := by simp [bind, join, nsmul_zero]\n@[simp] lemma bind_add : s.bind (\u03bb a, f a + g a) = s.bind f + s.bind g := by simp [bind, join]\n\n@[simp] lemma bind_cons (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 multiset \u03b2) :\n  s.bind (\u03bb a, f a ::\u2098 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 : \u03b1 \u2192 \u03b2) : s.bind (\u03bb x, ({f x} : multiset \u03b2)) = 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 : \u03b1 \u2192 multiset \u03b2} : b \u2208 bind s f \u2194 \u2203 a \u2208 s, b \u2208 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 \u2218 f)).sum := by simp [bind]\n\nlemma bind_congr {f g : \u03b1 \u2192 multiset \u03b2} {m : multiset \u03b1} :\n  (\u2200 a \u2208 m, f a = g a) \u2192 bind m f = bind m g :=\nby simp [bind] {contextual := tt}\n\nlemma bind_hcongr {\u03b2' : Type*} {m : multiset \u03b1} {f : \u03b1 \u2192 multiset \u03b2} {f' : \u03b1 \u2192 multiset \u03b2'}\n  (h : \u03b2 = \u03b2') (hf : \u2200a \u2208 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 \u03b1) (n : \u03b1 \u2192 multiset \u03b2) (f : \u03b2 \u2192 \u03b3) :\n  map f (bind m n) = bind m (\u03bb a, map f (n a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map (m : multiset \u03b1) (n : \u03b2 \u2192 multiset \u03b3) (f : \u03b1 \u2192 \u03b2) :\n  bind (map f m) n = bind m (\u03bb a, n (f a)) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_assoc {s : multiset \u03b1} {f : \u03b1 \u2192 multiset \u03b2} {g : \u03b2 \u2192 multiset \u03b3} :\n  (s.bind f).bind g = s.bind (\u03bb a, (f a).bind g) :=\nmultiset.induction_on s (by simp) (by simp {contextual := tt})\n\nlemma bind_bind (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 multiset \u03b3} :\n  (bind m $ \u03bb a, bind n $ \u03bb b, f a b) = (bind n $ \u03bb b, bind m $ \u03bb a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\nlemma bind_map_comm (m : multiset \u03b1) (n : multiset \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  (bind m $ \u03bb a, n.map $ \u03bb b, f a b) = (bind n $ \u03bb b, m.map $ \u03bb a, f a b) :=\nmultiset.induction_on m (by simp) (by simp {contextual := tt})\n\n@[simp, to_additive]\nlemma prod_bind [comm_monoid \u03b2] (s : multiset \u03b1) (t : \u03b1 \u2192 multiset \u03b2) :\n  (s.bind t).prod = (s.map $ \u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop} {s t} {f : \u03b1 \u2192 multiset \u03b3} {g : \u03b2 \u2192 multiset \u03b4}\n  (h : (r \u21d2 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 (\u03bb a ha b hb hr, h hr) }\n\nlemma count_sum [decidable_eq \u03b1] {m : multiset \u03b2} {f : \u03b2 \u2192 multiset \u03b1} {a : \u03b1} :\n  count a (map f m).sum = sum (m.map $ \u03bb b, count a $ f b) :=\nmultiset.induction_on m (by simp) ( by simp)\n\nlemma count_bind [decidable_eq \u03b1] {m : multiset \u03b2} {f : \u03b2 \u2192 multiset \u03b1} {a : \u03b1} :\n  count a (bind m f) = sum (m.map $ \u03bb b, count a $ f b) := count_sum\n\nlemma le_bind {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192 multiset \u03b2} (S : multiset \u03b1) {x : \u03b1} (hx : x \u2208 S) :\n  f x \u2264 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 \u27e8x, hx, rfl\u27e9\nend\nend bind\n\n/-! ### Product of two multisets -/\n\nsection product\nvariables (a : \u03b1) (b : \u03b2) (s : multiset \u03b1) (t : multiset \u03b2)\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 \u03b1) (t : multiset \u03b2) : multiset (\u03b1 \u00d7 \u03b2) := s.bind $ \u03bb a, t.map $ prod.mk a\n\n@[simp] lemma coe_product (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) : @product \u03b1 \u03b2 l\u2081 l\u2082 = l\u2081.product l\u2082 :=\nby { rw [product, list.product, \u2190coe_bind], simp }\n\n@[simp] lemma zero_product : @product \u03b1 \u03b2 0 t = 0 := rfl\n--TODO: Add `product_zero`\n\n@[simp] lemma cons_product : (a ::\u2098 s).product t = map (prod.mk a) t + s.product t :=\nby simp [product]\n\n@[simp] lemma product_singleton : ({a} : multiset \u03b1).product ({b} : multiset \u03b2) = {(a, b)} :=\nby simp only [product, bind_singleton, map_singleton]\n\n@[simp] lemma add_product (s t : multiset \u03b1) (u : multiset \u03b2) :\n  (s + t).product u = s.product u + product t u :=\nby simp [product]\n\n@[simp] lemma product_add (s : multiset \u03b1) : \u2200 t u : multiset \u03b2,\n  s.product (t + u) = s.product t + s.product u :=\nmultiset.induction_on s (\u03bb t u, rfl) $ \u03bb a s IH t u,\n  by rw [cons_product, IH]; simp; cc\n\n@[simp] lemma mem_product {s t} : \u2200 {p : \u03b1 \u00d7 \u03b2}, p \u2208 @product \u03b1 \u03b2 s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 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, (\u2218), mul_comm]\n\nend product\n\n/-! ### Disjoint sum of multisets -/\n\nsection sigma\nvariables {\u03c3 : \u03b1 \u2192 Type*} (a : \u03b1) (s : multiset \u03b1) (t : \u03a0 a, multiset (\u03c3 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 \u03b1) (t : \u03a0 a, multiset (\u03c3 a)) : multiset (\u03a3 a, \u03c3 a) :=\ns.bind $ \u03bb a, (t a).map $ sigma.mk a\n\n@[simp] lemma coe_sigma (l\u2081 : list \u03b1) (l\u2082 : \u03a0 a, list (\u03c3 a)) :\n  @multiset.sigma \u03b1 \u03c3 l\u2081 (\u03bb a, l\u2082 a) = l\u2081.sigma l\u2082 :=\nby rw [multiset.sigma, list.sigma, \u2190coe_bind]; simp\n\n@[simp] lemma zero_sigma : @multiset.sigma \u03b1 \u03c3 0 t = 0 := rfl\n\n@[simp] lemma cons_sigma : (a ::\u2098 s).sigma t = (t a).map (sigma.mk a) + s.sigma t :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_singleton (b : \u03b1 \u2192 \u03b2) :\n  ({a} : multiset \u03b1).sigma (\u03bb a, ({b a} : multiset \u03b2)) = {\u27e8a, b a\u27e9} := rfl\n\n@[simp] lemma add_sigma (s t : multiset \u03b1) (u : \u03a0 a, multiset (\u03c3 a)) :\n  (s + t).sigma u = s.sigma u + t.sigma u :=\nby simp [multiset.sigma]\n\n@[simp] lemma sigma_add : \u2200 t u : \u03a0 a, multiset (\u03c3 a),\n  s.sigma (\u03bb a, t a + u a) = s.sigma t + s.sigma u :=\nmultiset.induction_on s (\u03bb t u, rfl) $ \u03bb a s IH t u,\n  by rw [cons_sigma, IH]; simp; cc\n\n@[simp] lemma mem_sigma {s t} : \u2200 {p : \u03a3 a, \u03c3 a},\n  p \u2208 @multiset.sigma \u03b1 \u03c3 s t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t p.1\n| \u27e8a, b\u27e9 := by simp [multiset.sigma, and_assoc, and.left_comm]\n\n@[simp] lemma card_sigma :\n  card (s.sigma t) = sum (map (\u03bb a, card (t a)) s) :=\nby simp [multiset.sigma, (\u2218)]\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 : \u2115 \u2192 \u2115 \u2192 \u2115\nvariable hg : g 0 0 = 0\n\ntheorem gex1 : \u2203 x, g x x = x := \u27e80, hg\u27e9\ntheorem gex2 : \u2203 x, g x 0 = x := \u27e80, hg\u27e9\ntheorem gex3 : \u2203 x, g 0 0 = x := \u27e80, hg\u27e9\ntheorem gex4 : \u2203 x, g x x = 0 := \u27e80, hg\u27e9\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 \u2102 M]\n  [NormedAlgebra \u2102 M] [StarModule \u2102 M] where\n  exists_predual :\n    \u2203 (X : Type u)(_ : NormedAddCommGroup X)(_ : NormedSpace \u2102 X)(_ : CompleteSpace X),\n      Nonempty (NormedSpace.Dual \u2102 X \u2243\u2097\u1d62\u22c6[\u2102] 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 \u2192L[\u2102] H` form a `von_neumann_algebra`\n(although we will later construct the instance `wstar_algebra (H \u2192L[\u2102] H)`),\nand instead will use `\u22a4 : von_neumann_algebra H`.\n-/\n@[nolint has_nonempty_instance]\nstructure VonNeumannAlgebra (H : Type u) [NormedAddCommGroup H] [InnerProductSpace \u2102 H]\n  [CompleteSpace H] extends StarSubalgebra \u2102 (H \u2192L[\u2102] 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 \u2192L[\u2102] 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 \u2102 H] [CompleteSpace H]\n\ninstance : SetLike (VonNeumannAlgebra H) (H \u2192L[\u2102] H) :=\n  \u27e8VonNeumannAlgebra.carrier, fun S T h => by cases S <;> cases T <;> congr \u27e9\n\ninstance : StarMemClass (VonNeumannAlgebra H) (H \u2192L[\u2102] H) where star_mem s a := s.star_mem'\n\ninstance : SubringClass (VonNeumannAlgebra H) (H \u2192L[\u2102] 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 \u2208 s.toStarSubalgebra from neg_mem ha\n\n@[simp]\ntheorem mem_carrier {S : VonNeumannAlgebra H} {x : H \u2192L[\u2102] H} :\n    x \u2208 S.carrier \u2194 x \u2208 (S : Set (H \u2192L[\u2102] H)) :=\n  Iff.rfl\n#align von_neumann_algebra.mem_carrier VonNeumannAlgebra.mem_carrier\n\n@[ext]\ntheorem ext {S T : VonNeumannAlgebra H} (h : \u2200 x, x \u2208 S \u2194 x \u2208 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 \u2192L[\u2102] 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 \u2102 (S : Set (H \u2192L[\u2102] H)) fun a (ha : a \u2208 S) =>\n      (star_mem ha : _) with\n    carrier := Set.centralizer (S : Set (H \u2192L[\u2102] 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    \u2191S.commutant = Set.centralizer (S : Set (H \u2192L[\u2102] 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 \u2192L[\u2102] H} :\n    z \u2208 S.commutant \u2194 \u2200 g \u2208 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 : \u2200 P, \u00ac(P \u2194 \u00acP) :=\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 (\u03b1 : Type u) (\u03b2 : Type v) :=\n  \u03b1 \u2192 \u03b2\n\ndef select {\u03b1 : Type u} {\u03b2 : Type v} (a : array \u03b1 \u03b2) (i : \u03b1) : \u03b2 :=\n  a i\n\ntheorem arrayext {\u03b1 : Type u} {\u03b2 : Type v} (a\u2081 : array \u03b1 \u03b2) (a\u2082 : array \u03b1 \u03b2) : (\u2200 (i : \u03b1), select a\u2081 i = select a\u2082 i) \u2192 a\u2081 = a\u2082 :=\n  funext\n\ndef store {\u03b1 : Type u} {\u03b2 : Type v} [DecidableEq \u03b1] (a : array \u03b1 \u03b2) (i : \u03b1) (v : \u03b2) : array \u03b1 \u03b2 :=\n  fun (j : \u03b1) => ite (j = i) v (select a j)\n\n@[simp] theorem select_store {\u03b1 : Type u} {\u03b2 : Type v} [DecidableEq \u03b1] (a : array \u03b1 \u03b2) (i : \u03b1) (v : \u03b2) : select (store a i v) i = v := sorry\n\n@[simp] theorem select_store_ne {\u03b1 : Type u} {\u03b2 : Type v} [DecidableEq \u03b1] (a : array \u03b1 \u03b2) (i : \u03b1) (j : \u03b1) (v : \u03b2) : j \u2260 i \u2192 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 \u03b2\u03b7\n\ndef head_step (f g: utlc) := \u03b2.head_step f g \u2228 \u03b7.head_step f g\n\ninstance : has_\u03b2\u03b7_reduction utlc := \u27e8 reduction_step_of head_step \u27e9\n\ntheorem step_iff (f g: utlc): f \u2192\u03b2\u03b7 g \u2194 f \u2192\u03b2 g \u2228 f \u2192\u03b7 g :=\nbegin\n  induction f generalizing g;\n  simp only [lambda_notation, dot_notation, has_\u03b2\u03b7_reduction.step] at *,\n  { simp [head_step] },\n  { simp [lambda_reduction_step_iff, head_step, \u03b7.lambda_step_iff, \u03b2.lambda_step_iff, f_ih,\n      and_or_distrib_left, exists_or_distrib,\n      @or.left_comm _ (f_f = g \u2191\u00b9 0 \u00b7 \u21930)] },\n  { simp [dot_reduction_step_iff, head_step, \u03b7.dot_step_iff', \u03b2.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 \u21a0\u03b2 g \u2192 f \u21a0\u03b2\u03b7 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 \u21a0\u03b7 g \u2192 f \u21a0\u03b2\u03b7 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 := \u03b2.head_reduced f \u2227 \u03b7.head_reduced f\n\ndef reduced := reduced_of head_reduced\n\ntheorem reduced_iff_no_reduction {f: utlc}: reduced f \u2194 \u2200 g, \u00ac f \u2192\u03b2\u03b7 g :=\nbegin\n  apply reduced_iff_not_reduction_step,\n  intro f,\n  simp [head_reduced, head_step, \u03b2.head_reduced_iff_not_head_step, \u03b7.head_reduced_iff_not_head_step,\n    forall_and_distrib, not_or_distrib],\nend \n\nend \u03b2\u03b7\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 \u2192 q \u2192 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 \u27f6 N)\n\ndef cokernel_cocone : cofork f 0 :=\ncokernel_cofork.of_\u03c0 (up f.range.mkq) $ comp_mkq _\n\ndef cokernel_is_colimit : is_colimit (cokernel_cocone f) :=\ncofork.is_colimit.mk _\n  (\u03bb s, f.range.liftq (cofork.\u03c0 s) $ range_le_ker_iff.2 $ cokernel_cofork.condition s)\n  (\u03bb s, f.range.liftq_mkq (cofork.\u03c0 s) _)\n  (\u03bb 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\u27e8\u03bb _ _ f, \u27e8cokernel_cocone f, cokernel_is_colimit f\u27e9\u27e9\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 \u00d7 N) (fst R M N) (snd R M N),\n  is_limit :=\n  { lift := \u03bb s, prod (s.\u03c0.app walking_pair.left) (s.\u03c0.app walking_pair.right),\n    fac' := \u03bb s j, walking_pair.cases_on j (fst_prod _ _) (snd_prod _ _),\n    uniq' := \u03bb s m h,\n    begin\n      ext,\n      rw prod_apply,\n      { rw \u2190h walking_pair.left, refl },\n      { rw \u2190h 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 \u00d7 N) (inl R M N) (inr R M N),\n  is_colimit :=\n  { desc := \u03bb s, coprod (s.\u03b9.app walking_pair.left) (s.\u03b9.app walking_pair.right),\n    fac' := \u03bb s j, walking_pair.cases_on j (coprod_inl _ _) (coprod_inr _ _),\n    uniq' := \u03bb s m h,\n    begin\n      ext,\n      erw [coprod_apply, \u2190h walking_pair.left, \u2190h walking_pair.right,\n        binary_cofan.mk_\u03b9_app_left, binary_cofan.mk_\u03b9_app_right, comp_apply, comp_apply, \u2190map_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' := \u03bb P Q R f f' g,\n    show (f + f') \u226b g = f \u226b g + f' \u226b g, by ext; simp,\n  distrib_right' := \u03bb P Q R f g g',\n    show f \u226b (g + g') = f \u226b g + f \u226b 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 := \u03bb 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 := \u03bb 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 \u27f6 Y) (g : Y \u27f6 Z)\n\nlemma exact_is_exact : exact f g \u2194 f.range = g.ker :=\n\u27e8\u03bb h, le_antisymm (range_le_ker_iff.2 h.1) (ker_le_range_iff.2 h.2),\n \u03bb h, \u27e8range_le_ker_iff.1 $ le_of_eq h, ker_le_range_iff.1 $ le_of_eq h.symm\u27e9\u27e9\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": "/-\nCopyright (c) 2020 Kevin Buzzard. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Kevin Buzzard, Bryan Gin-ge Chen, Robert Y. Lewis, Scott Morrison\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.tactic.doc_commands\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n\n# Core tactic documentation\n\nThis file adds the majority of the interactive tactics from core Lean (i.e. pre-mathlib) to\nthe API documentation.\n\n## TODO\n\n* Make a PR to core changing core docstrings to the docstrings below,\nand also changing the docstrings of `cc`, `simp` and `conv` to the ones\nalready in the API docs.\n\n* SMT tactics are currently not documented.\n\n* `rsimp` and `constructor_matching` are currently not documented.\n\n* `dsimp` deserves better documentation.\n-/\n\n/-- Proves a goal of the form `s = t` when `s` and `t` are expressions built up out of a binary\noperation, and equality can be proved using associativity and commutativity of that operation. -/\n/--\n`by_cases p` splits the main goal into two cases, assuming `h : p` in the first branch, and\n`h : \u00ac p` in the second branch. You can specify the name of the new hypothesis using the syntax\n`by_cases h : p`.\n\nIf `p` is not already decidable, `by_cases` will use the instance `classical.prop_decidable p`.\n-/\n/--\nIf the target of the main goal is a proposition `p`, `by_contra h` reduces the goal to proving\n`false` using the additional hypothesis `h : \u00ac p`. If `h` is omitted, a name is generated\nautomatically.\n\nThis tactic requires that `p` is decidable. To ensure that all propositions are decidable via\nclassical reasoning, use `open_locale classical`\n(or `local attribute [instance, priority 10] classical.prop_decidable` if you are not using\nmathlib).\n-/\n/--\n`cases_matching p` applies the `cases` tactic to a hypothesis `h : type`\nif `type` matches the pattern `p`.\n\n`cases_matching [p_1, ..., p_n]` applies the `cases` tactic to a hypothesis `h : type`\nif `type` matches one of the given patterns.\n\n`cases_matching* p` is a more efficient and compact version\nof `focus1 { repeat { cases_matching p } }`.\nIt is more efficient because the pattern is compiled once.\n\n`casesm` is shorthand for `cases_matching`.\n\nExample: The following tactic destructs all conjunctions and disjunctions in the current context.\n```\ncases_matching* [_ \u2228 _, _ \u2227 _]\n```\n-/\n/--\n* `cases_type I` applies the `cases` tactic to a hypothesis `h : (I ...)`\n* `cases_type I_1 ... I_n` applies the `cases` tactic to a hypothesis\n  `h : (I_1 ...)` or ... or `h : (I_n ...)`\n* `cases_type* I` is shorthand for `focus1 { repeat { cases_type I } }`\n* `cases_type! I` only applies `cases` if the number of resulting subgoals is <= 1.\n\nExample: The following tactic destructs all conjunctions and disjunctions in the current context.\n```\ncases_type* or and\n```\n-/\n/--\nClose goals of the form `n \u2260 m` when `n` and `m` have type `nat`, `char`, `string`, `int`\nor `fin sz`, and they are literals. It also closes goals of the form `n < m`, `n > m`, `n \u2264 m` and\n`n \u2265 m` for `nat`. If the goal is of the form `n = m`, then it tries to close it using reflexivity.\n\nIn mathlib, consider using `norm_num` instead for numeric types.\n-/\n/--\nThe `congr` tactic attempts to identify both sides of an equality goal `A = B`,\nleaving as new goals the subterms of `A` and `B` which are not definitionally equal.\nExample: suppose the goal is `x * f y = g w * f z`. Then `congr` will produce two goals:\n`x = g w` and `y = z`.\n\nIf `x y : t`, and an instance `subsingleton t` is in scope, then any goals of the form\n`x = y` are solved automatically.\n\nNote that `congr` can be over-aggressive at times; the `congr'` tactic in mathlib\nprovides a more refined approach, by taking a parameter that limits the recursion depth.\n-/\n/--\nA variant of `rw` that uses the unifier more aggressively, unfolding semireducible definitions.\n-/\n/--\n`existsi e` will instantiate an existential quantifier in the target with `e` and leave the\ninstantiated body as the new target. More generally, it applies to any inductive type with one\nconstructor and at least two arguments, applying the constructor with `e` as the first argument\nand leaving the remaining arguments as goals.\n\n`existsi [e\u2081, ..., e\u2099]` iteratively does the same for each expression in the list.\n\nNote: in mathlib, the `use` tactic is an equivalent tactic which sometimes is smarter with\nunification.\n-/\n/--\nApply function extensionality and introduce new hypotheses.\nThe tactic `funext` will keep applying new the `funext` lemma until the goal target is not reducible\nto\n```\n  |-  ((fun x, ...) = (fun x, ...))\n```\nThe variant `funext h\u2081 ... h\u2099` applies `funext` `n` times, and uses the given identifiers to name\nthe new hypotheses.\n\nNote also the mathlib tactic `ext`, which applies as many extensionality lemmas as possible.\n-/\n/--\nIf the current goal is a Pi/forall `\u2200 x : t, u` (resp. `let x := t in u`) then `intro` puts\n`x : t` (resp. `x := t`) in the local context. The new subgoal target is `u`.\n\nIf the goal is an arrow `t \u2192 u`, then it puts `h : t` in the local context and the new goal\ntarget is `u`.\n\nIf the goal is neither a Pi/forall nor begins with a let binder, the tactic `intro` applies the\ntactic `whnf` until an introduction can be applied or the goal is not head reducible. In the latter\ncase, the tactic fails.\n\nThe variant `intro z` uses the identifier `z` to name the new hypothesis.\n\nThe variant `intros` will keep introducing new hypotheses until the goal target is not a Pi/forall\nor let binder.\n\nThe variant `intros h\u2081 ... h\u2099` introduces `n` new hypotheses using the given identifiers to name\nthem.\n-/\n/--\n`left` applies the first constructor when the type of the target is an inductive data type with\ntwo constructors.\n\nSimilarly, `right` applies the second constructor.\n-/\n/--\n`let h : t := p` adds the hypothesis `h : t := p` to the current goal if `p` a term of type `t`.\nIf `t` is omitted, it will be inferred.\n\n`let h : t` adds the hypothesis `h : t := ?M` to the current goal and opens a new subgoal `?M : t`.\nThe new subgoal becomes the main goal. If `t` is omitted, it will be replaced by a fresh\nmetavariable.\n\nIf `h` is omitted, the name `this` is used.\n\nNote the related mathlib tactic `set a := t with h`, which adds the hypothesis `h : a = t` to\nthe local context and replaces `t` with `a` everywhere it can.\n-/\n/--\nThis tactic applies to a goal whose target has the form `t ~ u` where `~` is a reflexive relation,\nthat is, a relation which has a reflexivity lemma tagged with the attribute `[refl]`.\nThe tactic checks whether `t` and `u` are definitionally equal and then solves the goal.\n-/\n/--\n`rw e` applies an equation or iff `e` as a rewrite rule to the main goal. If `e` is preceded by\nleft arrow (`\u2190` or `<-`), the rewrite is applied in the reverse direction. If `e` is a defined\nconstant, then the equational lemmas associated with `e` are used. This provides a convenient\nway to unfold `e`.\n\n`rw [e\u2081, ..., e\u2099]` applies the given rules sequentially.\n\n`rw e at l` rewrites `e` at location(s) `l`, where `l` is either `*` or a list of hypotheses\nin the local context. In the latter case, a turnstile `\u22a2` or `|-` can also be used, to signify\nthe target of the goal.\n\n`rewrite` is synonymous with `rw`.\n-/\n/- conv mode tactics -/\n\n/--\nNavigate to the left-hand-side of a relation.\nA goal of `| a = b` will turn into the the goal `| a`.\n-/\n/--\nNavigate to the right-hand-side of a relation.\nA goal of `| a = b` will turn into the the goal `| b`.\n-/\n/--\nNavigate into every argument of the current head function.\nA target of `| (a * b) * c` will turn into the two targets `| a * b` and `| c`.\n-/\n/--\nNavigate into the contents of top-level `\u03bb` binders.\nA target of `| \u03bb a, a + b` will turn into the target `| a + b` and introduce `a` into the local\ncontext.\nIf there are multiple binders, all of them will be entered, and if there are none, this tactic is a no-op.\n-/\n/--\nNavigate into the first scope matching the expression.\n\nFor a target of `| \u2200 c, a + (b + c) = 1`, `find (b + _) { ... }` will run the tactics within the\n`{}` with a target of `| b + c`.\n-/\n/--\nNavigate into the numbered scopes matching the expression.\n\nFor a target of `| \u03bb c, 10 * c + 20 * c + 30 * c`, `for (_ * _) [1, 3] { ... }` will run the\ntactics within the `{}` with first a target of `| 10 * c`, then a target of `| 30 * c`.\n-/\n/--\nEnd conversion of the current goal. This is often what is needed when muscle memory would type `sorry`.\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/lean_core_docs.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6224593452091672, "lm_q2_score": 0.7634837635542924, "lm_q1q2_score": 0.4752376035398355}}
{"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 \u2192 A) : A :=\n  @dite _ _ (classical.dec P) (\u03bb p, f p) (\u03bb _, 0)\n\nlemma if_p_true {A : Type} [has_zero A] {P : Prop} {f : P \u2192 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 \u2192 A} (p : \u00acP) : 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 \u2192 B}\n    (s : set A) (P : A \u2192 Prop) (p : \u2200 a, a \u2208 s \u2192 P a)\n    : \u2200 a, a \u2208 s \u2192 if_p (P a) (\u03bb _, 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 \u2208 s\nlemma if_p_const {A B : Type} [has_zero B] {f : A \u2192 B} (s : set A)\n    : \u2200 a : A, a \u2208 s \u2192 if_p (a \u2208 s) (\u03bb _, 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 \u2260 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 \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  --Let A be an open covering of R^n.\n  assume A : set (set (euclidean_space \u211d (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 : \u2203 C : set (set (euclidean_space \u211d (fin n))), is_open_cover C \u2227 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 : \u2200 (m : \u2115), \u2203 Bm : set (euclidean_space \u211d (fin n)), is_open Bm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Bm \u2194 \u2203 (a : \u211d) (b : fin n), (a > 0) \u2227 (\u2200 (i : fin n), abs (x i - b i) < a),\n    {\n      assume m : \u2115,\n      let Bm : set (euclidean_space \u211d (fin n)),\n      let hBm : is_open Bm,\n      let hBm1 : \u2200 x : euclidean_space \u211d (fin n), x \u2208 Bm \u2194 \u2203 (a : \u211d) (b : fin n), (a > 0) \u2227 (\u2200 (i : fin n), abs (x i - b i) < a),\n      {\n        assume x : euclidean_space \u211d (fin n),\n        split,\n        {\n          assume h1 : x \u2208 Bm,\n          let a : \u211d,\n          let b : fin n,\n          have h2 : \u2203 (a : \u211d) (b : fin n), (a > 0) \u2227 (\u2200 (i : fin n), abs (x i - b i) < a),\n          {\n            have h2a : \u2203 (a : \u211d) (b : fin n), abs (x i - b i) < a, from by auto [h1],\n            have h2b : \u2203 (a : \u211d) (b : fin n), ((a > 0) \u2227 (\u2200 (i : fin n), abs (x i - b i) < a)), from by auto [h2a],\n            exact h2b,\n          },\n          have h3 : \u2203! (a : \u211d) (b : fin n), ((a > 0) \u2227 (\u2200 (i : fin n), abs (x i - b i) < a)), from by auto [h2],\n          have h4 : \u2203 (a : \u211d) (b : fin n), ((a > 0) \u2227 (\u2200 (i : fin n), abs (x i - b i) < a)), from by auto [exists_unique.exists, h3],\n          exact h4,\n        },\n        {\n          assume h1 : \u2203 (a : \u211d) (b : fin n), (a > 0) \u2227 (\u2200 (i : fin n), abs (x i - b i) < a),\n          let a : \u211d,\n          let b : fin n,\n          have h2 : a > 0 \u2227 \u2200 (i : fin n), abs (x i - b i) < a, from by auto [h1],\n          have h3 : x \u2208 Bm, from by auto [h2],\n          exact h3,\n        },\n      },\n      exact hBm1,\n    },\n    have h1b : \u2200 (m : \u2115), \u2203 Bm : set (euclidean_space \u211d (fin n)), is_open Bm \u2227 \u2200 x : euclidean_space \u211d (fin n), x \u2208 Bm \u2194 \u2203 (a : \u211d) (b : fin n), (a > 0) \u2227 (\u2200 (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 : \u2200 (m : \u2115), \u2203 Cm : set (set (euclidean_space \u211d (fin n))), is_open_cover Cm \u2227 (\u2200 (U : set (euclidean_space \u211d (fin n))), U \u2208 Cm \u2194 (\u2203 (V : set (euclidean_space \u211d (fin n))), V \u2208 A \u2227 U = V \u2229 (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 : \u2115,\n      let Cm : set (set (euclidean_space \u211d (fin n))),\n      let hCm : is_open_cover Cm,\n      let hCm1 : \u2200 (U : set (euclidean_space\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  intros A HA,\n  have B0 : set (euclidean_space \u211d (fin n)) := \u2205,\n  have Bm : \u2200 m : \u2115, set (euclidean_space \u211d (fin n)) := \u03bb m, ball (0 : euclidean_space \u211d (fin n)) m,\n  have B : \u2200 m : \u2115, set (euclidean_space \u211d (fin n)) := \u03bb m, closure (Bm m),\n  have Cm : \u2200 (m : \u2115) (A : set (euclidean_space \u211d (fin n))), \n    \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 HA), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from\n  begin\n    assume (m : \u2115) (A : set (euclidean_space \u211d (fin n))),\n    have h1 : (Bm m) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h2 : (Bm (m-1)) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h3 : (Bm m) \u2286 A, from by auto [set.subset_inter_iff, set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h4 : (Bm (m-1)) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h5 : \u2203 (C : set (euclidean_space \u211d (fin n))), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from by auto [set.exists_inter_of_subset],\n    show \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 HA), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from by auto [set.exists_of_mem_of_subset, set.exists.elim] using [h5],\n  end,\n  have Cm' : \u2200 (m : \u2115) (A : set (euclidean_space \u211d (fin n))), \n    \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 HA), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from\n  begin\n    assume (m : \u2115) (A : set (euclidean_space \u211d (fin n))),\n    have h1 : (Bm m) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h2 : (Bm (m-1)) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h3 : (Bm m) \u2286 A, from by auto [set.subset_inter_iff, set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h4 : (Bm (m-1)) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h5 : \u2203 (C : set (euclidean_space \u211d (fin n))), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from by auto [set.exists_inter_of_subset],\n    show \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 HA), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from by auto [set.exists_of_mem_of_subset, set.exists.elim] using [h5],\n  end,\n  have Cm'' : \u2200 (m : \u2115) (A : set (euclidean_space \u211d (fin n))), \n    \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 HA), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from\n  begin\n    assume (m : \u2115) (A : set (euclidean_space \u211d (fin n))),\n    have h1 : (Bm m) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h2 : (Bm (m-1)) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h3 : (Bm m) \u2286 A, from by auto [set.subset_inter_iff, set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h4 : (Bm (m-1)) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h5 : \u2203 (C : set (euclidean_space \u211d (fin n))), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from by auto [set.exists_inter_of_subset],\n    show \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 HA), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from by auto [set.exists_of_mem_of_subset, set.exists.elim] using [h5],\n  end,\n  have Cm''' : \u2200 (m : \u2115) (A : set (euclidean_space \u211d (fin n))), \n    \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 HA), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from\n  begin\n    assume (m : \u2115) (A : set (euclidean_space \u211d (fin n))),\n    have h1 : (Bm m) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h2 : (Bm (m-1)) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h3 : (Bm m) \u2286 A, from by auto [set.subset_inter_iff, set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h4 : (Bm (m-1)) \u2229 A \u2260 \u2205, from by auto [set.inter_ne_empty_iff, set.mem_of_mem_closure],\n    have h5 : \u2203 (C : set (euclidean_space \u211d (fin n))), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from by auto [set.exists_inter_of_subset],\n    show \u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 HA), (Bm m) \u2286 C \u2227 (Bm (m-1)) \u2229 C = \u2205, from by auto [set.exists_of_mem_of_subset, set.ex\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open_cover A),\n  have h1 : \u2200 (x : \u211d) (n : \u2115), \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1), from \n  begin\n    assume (x : \u211d) (n : \u2115),\n    have h1 : \u2203 m : \u2115, (x \u2264 m), from exists_nat.of_le (le_of_lt ((x : \u211d) + 1)),\n    have h2 : \u2203 m : \u2115, (m \u2264 x + 1), from exists_nat.of_le (le_add_right x 1),\n    have h3 : \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 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 : \u2200 (x : \u211d) (n : \u2115), \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n), from \n  begin\n    assume (x : \u211d) (n : \u2115),\n    have h1 : \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1), from h1 x n,\n    cases h1 with m hm,\n    have h2 : \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 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 : \u2200 (x : \u211d) (n : \u2115), \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 m \u2264 n), from \n  begin\n    assume (x : \u211d) (n : \u2115),\n    have h1 : \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n), from h2 x n,\n    cases h1 with m hm,\n    have h2 : \u2200 (n : \u2115), x \u2264 n \u2192 m \u2264 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 : \u2200 (x : \u211d) (n : \u2115), \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 m \u2264 n \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x + 1 \u2264 n), from\n  begin\n    assume (x : \u211d) (n : \u2115),\n    have h1 : \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 m \u2264 n), from h3 x n,\n    cases h1 with m hm,\n    have h2 : \u2200 (n : \u2115), m \u2264 n \u2192 x + 1 \u2264 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 : \u2200 (x : \u211d) (n : \u2115), \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 m \u2264 n \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x + 1 \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 x + 1 \u2264 n), from\n  begin\n    assume (x : \u211d) (n : \u2115),\n    have h1 : \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 m \u2264 n \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x + 1 \u2264 n), from h4 x n,\n    cases h1 with m hm,\n    have h2 : \u2200 (n : \u2115), x \u2264 n \u2192 x + 1 \u2264 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 : \u2200 (x : \u211d) (n : \u2115), \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 m \u2264 n \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x + 1 \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 x + 1 \u2264 n \u2227 \u2200 (n : \u2115), x + 1 \u2264 n \u2192 m \u2264 n), from\n  begin\n    assume (x : \u211d) (n : \u2115),\n    have h1 : \u2203 m : \u2115, (x \u2264 m \u2227 m \u2264 x + 1 \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 m \u2264 n \u2227 \u2200 (n : \u2115), m \u2264 n \u2192 x + 1 \u2264 n \u2227 \u2200 (n : \u2115), x \u2264 n \u2192 x + 1 \u2264 n), from h5 x n,\n    cases h1 with m hm,\n    have h2 : \u2200 (n : \u2115), x + 1 \u2264 n \u2192 m \u2264 n\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  have h1 : \u2200 A : set (euclidean_space \u211d (fin n)), is_open A \u2192 is_open (A \u2229 (univ : set (euclidean_space \u211d (fin n)))), from by auto [set.inter_univ],\n  have h2 : \u2200 m : \u2115, is_open (set.Iio (m : \u211d) \u2229 (univ : set (euclidean_space \u211d (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 : \u2200 m : \u2115, is_open (set.Icc (m : \u211d) (m + 1) \u2229 (univ : set (euclidean_space \u211d (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 : \u211d) \u2229 (univ : set (euclidean_space \u211d (fin n)))) \u2286 (set.Icc (0 : \u211d) 1 \u2229 (univ : set (euclidean_space \u211d (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 : \u211d) 1 \u2229 (univ : set (euclidean_space \u211d (fin n)))) \u2286 (set.Iio (0 : \u211d) \u2229 (univ : set (euclidean_space \u211d (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 : \u211d) \u2229 (univ : set (euclidean_space \u211d (fin n)))), from by auto [h2, h3, h4, h5],\n  have h7 : \u2200 m : \u2115, is_open (set.Ico (m : \u211d) (m + 1) \u2229 (univ : set (euclidean_space \u211d (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 : \u211d) 1 \u2229 (univ : set (euclidean_space \u211d (fin n)))), from by auto [h7],\n  have h9 : \u2200 m : \u2115, is_open (set.Icc (m : \u211d) (m + 1) \u2229 (univ : set (euclidean_space \u211d (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 : \u2200 m : \u2115, is_open (set.Icc (m : \u211d) (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 : \u2200 m : \u2115, is_open (set.Iio (m : \u211d)), 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 : \u2200 m : \u2115, is_open (set.Ico (m : \u211d)), 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 : \u2200 m : \u2115, is_open (set.Icc (m : \u211d) (m + 1) \u2229 (univ : set (euclidean_space \u211d (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 : \u2200 m : \u2115, is_open (set.Icc (m : \u211d) (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 : \u2200 m : \u2115, is_open (set.Ico (m : \u211d) (m + 1) \u2229 (univ : set (euclidean_space \u211d (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 : \u2200 m : \u2115, is_open (set.Ico (m : \u211d) (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 \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  let A := \u03bb (a : \u211d), {b : \u211d | a < b},\n  have h1 : \u2200 (a : \u211d), is_open (A a), from by auto [is_open_lt],\n  let B := \u03bb (a : \u211d), {b : \u211d | b < a},\n  have h2 : \u2200 (a : \u211d), is_open (B a), from by auto [is_open_gt],\n  have h3 : \u2200 (a : \u211d), is_open (A a) \u2227 is_open (B a), from by auto [h1, h2],\n  have h4 : \u2200 (a : \u211d) (h : a > 0), \u2203 b : \u211d, b > a, from by auto [h1],\n  have h5 : \u2200 (a : \u211d) (h : a < 0), \u2203 b : \u211d, b < a, from by auto [h2],\n  have h6 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b \u2260 a, from by auto [h4, h5],\n  have h7 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h8 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h9 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h10 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h11 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h12 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h13 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h14 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h15 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h16 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h17 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h18 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h19 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h20 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h21 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h22 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h23 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h24 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h25 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h26 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h27 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h28 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h29 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h30 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h31 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h32 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h33 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h34 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h35 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h36 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h37 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h38 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h39 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h40 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h41 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h42 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h43 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h44 : \u2200 (a : \u211d) (h : a \u2260 0), \u2203 b : \u211d, b = a, from by auto [h4, h5],\n  have h45\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  have h1 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2208 (\ud835\udcdd (0 : \u211d ^ n)), from by auto [nhds_zero, set.mem_nhds_sets_iff, set.mem_ball],\n  have h2 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2208 (\ud835\udcdd (0 : \u211d ^ n)), from by auto [nhds_zero, set.mem_nhds_sets_iff, set.mem_ball],\n  have h3 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 < m} \u2208 (\ud835\udcdd (0 : \u211d ^ n)), from by auto [nhds_zero, set.mem_nhds_sets_iff, set.mem_ball],\n  have h4 : \u2200 m : \u2115, {x : \u211d ^ n // m < \u2225x\u2225} \u2208 (\ud835\udcdd (0 : \u211d ^ n)), from by auto [nhds_zero, set.mem_nhds_sets_iff, set.mem_ball],\n  have h5 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h6 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h7 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h8 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h9 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h10 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h11 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h12 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h13 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h14 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h15 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h16 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h17 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h18 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h19 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h20 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h21 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h22 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n  have h23 : \u2200 m : \u2115, {x : \u211d ^ n // \u2225x\u2225 \u2264 m \u2227 \u2225x\u2225 < m + 1} = {x : \u211d ^ n // \u2225x\u2225 \u2264 m} \u2229 {x : \u211d ^ n // \u2225x\u2225 < m + 1}, from by auto,\n  have h24 : \u2200 m : \u2115, {x : \u211d ^ n // m \u2264 \u2225x\u2225 \u2227 m + 1 < \u2225x\u2225} = {x : \u211d ^ n // m \u2264 \u2225x\u2225} \u2229 {x : \u211d ^ n // m + 1 < \u2225x\u2225}, from by auto,\n \nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  let A : set (euclidean_space \u211d (fin n)) \u2192 Prop := \u03bb x, (is_open x),\n  let S : set (euclidean_space \u211d (fin n)) := univ,\n  let T : set (euclidean_space \u211d (fin n)) \u2192 Prop := \u03bb x, (is_open x) \u2227 cover S x \u2227 locally_finite x,\n  let U : set (euclidean_space \u211d (fin n)) \u2192 Prop := \u03bb x, (is_open x) \u2227 cover S x,\n  let C : set (euclidean_space \u211d (fin n)) \u2192 Prop := \u03bb x, (is_open x) \u2227 locally_finite x,\n  have h1 : S \u2208 \ud835\udcab (euclidean_space \u211d (fin n)), from by auto [set.univ_mem_powerset],\n  have h2 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C), from by auto [set.is_open_of_mem_powerset],\n  have h3 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C, from by auto [set.is_open_of_mem_powerset, set.cover_univ, set.univ_mem_powerset],\n  have h4 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2227 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 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 locally_finite C, from by auto [set.is_open_of_mem_powerset, set.locally_finite_of_mem_powerset],\n  have h6 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2227 locally_finite C \u2194 (is_open C) \u2227 cover S C, from by auto [iff_iff_iff_iff],\n  have h7 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2227 locally_finite C \u2194 (is_open C) \u2227 locally_finite C, from by auto [iff_iff_iff_iff],\n  have h8 : T = U \u2228 T = C, from by auto [set.ext],\n  have h9 : (\u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2227 locally_finite C) \u2194 (\u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C), from by auto [h6],\n  have h10 : (\u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2227 locally_finite C) \u2194 (\u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 locally_finite C), from by auto [h7],\n  have h11 : (\u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2227 locally_finite C) \u2194 (\u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C) \u2228 (\u2203 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 locally_finite C), from by auto [h8, h9, h10, exists_or_distrib],\n  have h12 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C, from by auto [set.is_open_of_mem_powerset, set.cover_univ, set.univ_mem_powerset],\n  have h13 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 locally_finite C, from by auto [set.is_open_of_mem_powerset, set.locally_finite_of_mem_powerset],\n  have h14 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2228 (is_open C) \u2227 locally_finite C, from by auto [h11],\n  have h15 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2228 (is_open C) \u2227 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 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2228 (is_open C) \u2227 locally_finite C, from by auto [h15, set.ext],\n  have h17 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2228 (is_open C) \u2227 locally_finite C, from by auto [h16, set.ext],\n  have h18 : \u2200 (C : set (euclidean_space \u211d (fin n))) (hC : C \u2208 \ud835\udcab (euclidean_space \u211d (fin n))), (is_open C) \u2227 cover S C \u2228 (is_open C) \u2227 locally_finite C, from by auto [h17, set.\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (fin n)) :=\nbegin\n  assume (A : set (euclidean_space \u211d (fin n))) (hA : is_open A),\n  have h1 : is_open (\u22c3 (m : \u2115), (\u03bb (x : euclidean_space \u211d (fin n)), (\u2203 (m : \u2115), \u2200 (i : fin n), abs (x $ i) \u2264 m)) \u207b\u00b9' {m} \u2229 A) := by auto [is_open_Inter, is_open_Ball, is_open_Union, is_open_Inter, is_open_Ball, is_open_Union],\n  have h2 :  (\u22c3 (m : \u2115), (\u03bb (x : euclidean_space \u211d (fin n)), (\u2203 (m : \u2115), \u2200 (i : fin n), abs (x $ i) \u2264 m)) \u207b\u00b9' {m} \u2229 A) = A, from by auto [ext_iff],\n\n  show \u2203 (B : set (euclidean_space \u211d (fin n))), is_open B \u2227 is_locally_finite B \u2227 \u22c3 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from by auto [h2],\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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  \u211dn_paracompact (n : \u2115) : paracompact_space (euclidean_space \u211d (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\u2081 v\u2082 u\u2081 u\u2082 l u\u2083 v\u2083 \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 \u22a3 G` represents the data of an adjunction between two functors\n`F : C \u2964 D` and `G : D \u2964 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\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) (G : D \u2964 C) \nwhere\n  hom_equiv : (X : C) \u2192 (Y : D) \u2192 (functor.obj F X \u27f6 Y) \u2243 (X \u27f6 functor.obj G Y)\n  unit : \ud835\udfed \u27f6 F \u22d9 G\n  counit : G \u22d9 F \u27f6 \ud835\udfed\n  hom_equiv_unit' : autoParam\n  (\u2200 {X : C} {Y : D} {f : functor.obj F X \u27f6 Y}, coe_fn (hom_equiv X Y) f = nat_trans.app unit X \u226b 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  (\u2200 {X : C} {Y : D} {g : X \u27f6 functor.obj G Y},\n    coe_fn (equiv.symm (hom_equiv X Y)) g = functor.map F g \u226b 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 \" \u22a3 \" => Mathlib.category_theory.adjunction\n\n/-- A class giving a chosen right adjoint to the functor `left`. -/\nclass is_left_adjoint {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (left : C \u2964 D) \nwhere\n  right : D \u2964 C\n  adj : left \u22a3 right\n\n/-- A class giving a chosen left adjoint to the functor `right`. -/\nclass is_right_adjoint {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (right : D \u2964 C) \nwhere\n  left : C \u2964 D\n  adj : left \u22a3 right\n\n/-- Extract the left adjoint from the instance giving the chosen adjoint. -/\ndef left_adjoint {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (R : D \u2964 C) [is_right_adjoint R] : C \u2964 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\u2081} [category C] {D : Type u\u2082} [category D] (L : C \u2964 D) [is_left_adjoint L] : D \u2964 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\u2081} [category C] {D : Type u\u2082} [category D] (left : C \u2964 D) [is_left_adjoint left] : left \u22a3 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\u2081} [category C] {D : Type u\u2082} [category D] (right : C \u2964 D) [is_right_adjoint right] : left_adjoint right \u22a3 right :=\n  is_right_adjoint.adj\n\nnamespace adjunction\n\n\n@[simp] theorem hom_equiv_unit {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (c : F \u22a3 G) {X : C} {Y : D} {f : functor.obj F X \u27f6 Y} : coe_fn (hom_equiv c X Y) f = nat_trans.app (unit c) X \u226b functor.map G f := sorry\n\n@[simp] theorem hom_equiv_counit {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (c : F \u22a3 G) {X : C} {Y : D} {g : X \u27f6 functor.obj G Y} : coe_fn (equiv.symm (hom_equiv c X Y)) g = functor.map F g \u226b nat_trans.app (counit c) Y := sorry\n\n@[simp] theorem hom_equiv_naturality_left_symm {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {X' : C} {X : C} {Y : D} (f : X' \u27f6 X) (g : X \u27f6 functor.obj G Y) : coe_fn (equiv.symm (hom_equiv adj X' Y)) (f \u226b g) = functor.map F f \u226b coe_fn (equiv.symm (hom_equiv adj X Y)) g := sorry\n\n@[simp] theorem hom_equiv_naturality_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {X' : C} {X : C} {Y : D} (f : X' \u27f6 X) (g : functor.obj F X \u27f6 Y) : coe_fn (hom_equiv adj X' Y) (functor.map F f \u226b g) = f \u226b coe_fn (hom_equiv adj X Y) g := sorry\n\n@[simp] theorem hom_equiv_naturality_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {X : C} {Y : D} {Y' : D} (f : functor.obj F X \u27f6 Y) (g : Y \u27f6 Y') : coe_fn (hom_equiv adj X Y') (f \u226b g) = coe_fn (hom_equiv adj X Y) f \u226b functor.map G g := sorry\n\n@[simp] theorem hom_equiv_naturality_right_symm {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {X : C} {Y : D} {Y' : D} (f : X \u27f6 functor.obj G Y) (g : Y \u27f6 Y') : coe_fn (equiv.symm (hom_equiv adj X Y')) (f \u226b functor.map G g) = coe_fn (equiv.symm (hom_equiv adj X Y)) f \u226b g := sorry\n\n@[simp] theorem left_triangle {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) : whisker_right (unit adj) F \u226b whisker_left F (counit adj) = nat_trans.id (\ud835\udfed \u22d9 F) := sorry\n\n@[simp] theorem right_triangle {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) : whisker_left G (unit adj) \u226b whisker_right (counit adj) G = nat_trans.id (G \u22d9 \ud835\udfed) := sorry\n\n@[simp] theorem left_triangle_components_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {X : C} {X' : D} (f' : functor.obj \ud835\udfed (functor.obj F X) \u27f6 X') : functor.map F (nat_trans.app (unit adj) X) \u226b nat_trans.app (counit adj) (functor.obj F X) \u226b f' = f' := sorry\n\n@[simp] theorem right_triangle_components {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {Y : D} : nat_trans.app (unit adj) (functor.obj G Y) \u226b functor.map G (nat_trans.app (counit adj) Y) = \ud835\udfd9 :=\n  congr_arg (fun (t : nat_trans (G \u22d9 \ud835\udfed) (G \u22d9 \ud835\udfed)) => nat_trans.app t Y) (right_triangle adj)\n\n@[simp] theorem counit_naturality {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {X : D} {Y : D} (f : X \u27f6 Y) : functor.map F (functor.map G f) \u226b nat_trans.app (counit adj) Y = nat_trans.app (counit adj) X \u226b f :=\n  nat_trans.naturality (counit adj) f\n\n@[simp] theorem unit_naturality {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {X : C} {Y : C} (f : X \u27f6 Y) : nat_trans.app (unit adj) X \u226b functor.map G (functor.map F f) = f \u226b nat_trans.app (unit adj) Y :=\n  Eq.symm (nat_trans.naturality (unit adj) f)\n\ntheorem hom_equiv_apply_eq {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {A : C} {B : D} (f : functor.obj F A \u27f6 B) (g : A \u27f6 functor.obj G B) : coe_fn (hom_equiv adj A B) f = g \u2194 f = coe_fn (equiv.symm (hom_equiv adj A B)) g := sorry\n\ntheorem eq_hom_equiv_apply {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {A : C} {B : D} (f : functor.obj F A \u27f6 B) (g : A \u27f6 functor.obj G B) : g = coe_fn (hom_equiv adj A B) f \u2194 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\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) (G : D \u2964 C) \nwhere\n  hom_equiv : (X : C) \u2192 (Y : D) \u2192 (functor.obj F X \u27f6 Y) \u2243 (X \u27f6 functor.obj G Y)\n  hom_equiv_naturality_left_symm' : autoParam\n  (\u2200 {X' X : C} {Y : D} (f : X' \u27f6 X) (g : X \u27f6 functor.obj G Y),\n    coe_fn (equiv.symm (hom_equiv X' Y)) (f \u226b g) = functor.map F f \u226b 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  (\u2200 {X : C} {Y Y' : D} (f : functor.obj F X \u27f6 Y) (g : Y \u27f6 Y'),\n    coe_fn (hom_equiv X Y') (f \u226b g) = coe_fn (hom_equiv X Y) f \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (c : core_hom_equiv F G) {X' : C} {X : C} {Y : D} (f : X' \u27f6 X) (g : X \u27f6 functor.obj G Y) : coe_fn (equiv.symm (hom_equiv c X' Y)) (f \u226b g) = functor.map F f \u226b coe_fn (equiv.symm (hom_equiv c X Y)) g := sorry\n\n@[simp] theorem hom_equiv_naturality_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (c : core_hom_equiv F G) {X : C} {Y : D} {Y' : D} (f : functor.obj F X \u27f6 Y) (g : Y \u27f6 Y') : coe_fn (hom_equiv c X Y') (f \u226b g) = coe_fn (hom_equiv c X Y) f \u226b functor.map G g := sorry\n\n@[simp] theorem hom_equiv_naturality_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : core_hom_equiv F G) {X' : C} {X : C} {Y : D} (f : X' \u27f6 X) (g : functor.obj F X \u27f6 Y) : coe_fn (hom_equiv adj X' Y) (functor.map F f \u226b g) = f \u226b coe_fn (hom_equiv adj X Y) g := sorry\n\n@[simp] theorem hom_equiv_naturality_right_symm {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : core_hom_equiv F G) {X : C} {Y : D} {Y' : D} (f : X \u27f6 functor.obj G Y) (g : Y \u27f6 Y') : coe_fn (equiv.symm (hom_equiv adj X Y')) (f \u226b functor.map G g) = coe_fn (equiv.symm (hom_equiv adj X Y)) f \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) (G : D \u2964 C) \nwhere\n  unit : \ud835\udfed \u27f6 F \u22d9 G\n  counit : G \u22d9 F \u27f6 \ud835\udfed\n  left_triangle' : autoParam (whisker_right unit F \u226b iso.hom (functor.associator F G F) \u226b whisker_left F counit = nat_trans.id (\ud835\udfed \u22d9 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 \u226b iso.inv (functor.associator G F G) \u226b whisker_right counit G = nat_trans.id (G \u22d9 \ud835\udfed))\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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (c : core_unit_counit F G) : whisker_right (unit c) F \u226b iso.hom (functor.associator F G F) \u226b whisker_left F (counit c) = nat_trans.id (\ud835\udfed \u22d9 F) := sorry\n\n@[simp] theorem right_triangle {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (c : core_unit_counit F G) : whisker_left G (unit c) \u226b iso.inv (functor.associator G F G) \u226b whisker_right (counit c) G = nat_trans.id (G \u22d9 \ud835\udfed) := 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 \u27f6 Y` and `X \u27f6 G.obj Y`. -/\n@[simp] theorem mk_of_hom_equiv_counit_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 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 \ud835\udfed Y)) \ud835\udfd9 :=\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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 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\u2081} [category C] : \ud835\udfed \u22a3 \ud835\udfed :=\n  mk (fun (X Y : C) => equiv.refl (functor.obj \ud835\udfed X \u27f6 Y)) \ud835\udfd9 \ud835\udfd9\n\n-- Satisfy the inhabited linter.\n\nprotected instance inhabited {C : Type u\u2081} [category C] : Inhabited (\ud835\udfed \u22a3 \ud835\udfed) :=\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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {F' : C \u2964 D} (iso : F \u2245 F') {X : C} {Y : D} (g : functor.obj F' X \u27f6 Y) : coe_fn (equiv.symm (equiv_homset_left_of_nat_iso iso)) g = nat_trans.app (iso.hom iso) X \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] {G : D \u2964 C} {G' : D \u2964 C} (iso : G \u2245 G') {X : C} {Y : D} (f : X \u27f6 functor.obj G Y) : coe_fn (equiv_homset_right_of_nat_iso iso) f = f \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} {H : D \u2964 C} (adj : F \u22a3 H) (iso : F \u2245 G) : G \u22a3 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} {H : D \u2964 C} (adj : F \u22a3 G) (iso : G \u2245 H) : F \u22a3 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (h : F \u2245 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (h : F \u2245 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} {E : Type u\u2083} [\u2130 : category E] (H : D \u2964 E) (I : E \u2964 D) (adj\u2081 : F \u22a3 G) (adj\u2082 : H \u22a3 I) : F \u22d9 H \u22a3 I \u22d9 G :=\n  mk (fun (X : C) (Z : E) => equiv.trans (hom_equiv adj\u2082 (functor.obj F X) Z) (hom_equiv adj\u2081 X (functor.obj I Z)))\n    (unit adj\u2081 \u226b whisker_left F (whisker_right (unit adj\u2082) G) \u226b iso.inv (functor.associator F (H \u22d9 I) G))\n    (iso.hom (functor.associator I G (F \u22d9 H)) \u226b whisker_left I (whisker_right (counit adj\u2081) H) \u226b counit adj\u2082)\n\n/-- If `F` and `G` are left adjoints then `F \u22d9 G` is a left adjoint too. -/\nprotected instance left_adjoint_of_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [\u2130 : category E] (F : C \u2964 D) (G : D \u2964 E) [Fl : is_left_adjoint F] [Gl : is_left_adjoint G] : is_left_adjoint (F \u22d9 G) :=\n  is_left_adjoint.mk (is_left_adjoint.right G \u22d9 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 \u22d9 G` is a right adjoint too. -/\nprotected instance right_adjoint_of_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [\u2130 : category E] {F : C \u2964 D} {G : D \u2964 E} [Fr : is_right_adjoint F] [Gr : is_right_adjoint G] : is_right_adjoint (F \u22d9 G) :=\n  is_right_adjoint.mk (is_right_adjoint.left G \u22d9 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 \u2192 C, it suffices to give the object part\n\n-- of a functor F : C \u2192 D together with isomorphisms Hom(FX, Y) \u2243\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 \u27f6 Y` and `X \u27f6 G.obj Y` satisfying a naturality law\n`he : \u2200 X Y Y' g h, e X Y' (h \u226b g) = e X Y h \u226b G.map g`.\nDual to `right_adjoint_of_equiv`. -/\n@[simp] theorem left_adjoint_of_equiv_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {G : D \u2964 C} {F_obj : C \u2192 D} (e : (X : C) \u2192 (Y : D) \u2192 (F_obj X \u27f6 Y) \u2243 (X \u27f6 functor.obj G Y)) (he : \u2200 (X : C) (Y Y' : D) (g : Y \u27f6 Y') (h : F_obj X \u27f6 Y), coe_fn (e X Y') (h \u226b g) = coe_fn (e X Y) h \u226b functor.map G g) : \u2200 (\u1fb0 : C), functor.obj (left_adjoint_of_equiv e he) \u1fb0 = F_obj \u1fb0 :=\n  fun (\u1fb0 : C) => Eq.refl (functor.obj (left_adjoint_of_equiv e he) \u1fb0)\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\u2081} [category C] {D : Type u\u2082} [category D] {G : D \u2964 C} {F_obj : C \u2192 D} (e : (X : C) \u2192 (Y : D) \u2192 (F_obj X \u27f6 Y) \u2243 (X \u27f6 functor.obj G Y)) (he : \u2200 (X : C) (Y Y' : D) (g : Y \u27f6 Y') (h : F_obj X \u27f6 Y), coe_fn (e X Y') (h \u226b g) = coe_fn (e X Y) h \u226b 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 \u27f6 Y` and `X \u27f6 G_obj Y` satisfying a naturality law\n`he : \u2200 X Y Y' g h, e X' Y (F.map f \u226b g) = f \u226b e X Y g`.\nDual to `left_adjoint_of_equiv`. -/\n@[simp] theorem right_adjoint_of_equiv_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G_obj : D \u2192 C} (e : (X : C) \u2192 (Y : D) \u2192 (functor.obj F X \u27f6 Y) \u2243 (X \u27f6 G_obj Y)) (he : \u2200 (X' X : C) (Y : D) (f : X' \u27f6 X) (g : functor.obj F X \u27f6 Y),\n  coe_fn (e X' Y) (functor.map F f \u226b g) = f \u226b coe_fn (e X Y) g) : \u2200 (\u1fb0 : D), functor.obj (right_adjoint_of_equiv e he) \u1fb0 = G_obj \u1fb0 :=\n  fun (\u1fb0 : D) => Eq.refl (functor.obj (right_adjoint_of_equiv e he) \u1fb0)\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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G_obj : D \u2192 C} (e : (X : C) \u2192 (Y : D) \u2192 (functor.obj F X \u27f6 Y) \u2243 (X \u27f6 G_obj Y)) (he : \u2200 (X' X : C) (Y : D) (f : X' \u27f6 X) (g : functor.obj F X \u27f6 Y),\n  coe_fn (e X' Y) (functor.map F f \u226b g) = f \u226b 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)) \ud835\udfd9 :=\n  Eq.refl (coe_fn (equiv.symm (e (G_obj Y) Y)) \ud835\udfd9)\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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) [(X : C) \u2192 is_iso (nat_trans.app (unit adj) X)] [(Y : D) \u2192 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\u2081} [category C] {D : Type u\u2082} [category D] {G : D \u2964 C} [is_right_adjoint G] [(X : C) \u2192 is_iso (nat_trans.app (unit (of_right_adjoint G)) X)] [(Y : D) \u2192 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\u2081} [category C] {D : Type u\u2082} [category D] (e : C \u224c D) : functor e \u22a3 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\u2081} [category C] {D : Type u\u2082} [category D] (E : C \u2964 D) [is_equivalence E] : E \u22a3 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 `\u03c0\u2080 X \u2192 X _[0]` and `X _[n] \u2192 X _[n+1]` which\nbehave formally like an extra degeneracy `\u03c3 (-1)`. It can be thought as a datum\nassociated to the augmented simplicial set `X \u2192 \u03c0\u2080 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 \u2964 D`\n- `sSet.augmented.standard_simplex.extra_degeneracy`: the standard `n`-simplex has\nan extra degeneracy\n- `arrow.augmented_cech_nerve.extra_degeneracy`: the \u010cech 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 `\u03c3 (-1)`. -/\n@[ext]\nstructure extra_degeneracy (X : simplicial_object.augmented C) :=\n(s' : point.obj X \u27f6 (drop.obj X) _[0])\n(s : \u03a0 (n : \u2115), (drop.obj X) _[n] \u27f6 (drop.obj X) _[n+1])\n(s'_comp_\u03b5' : s' \u226b X.hom.app (op [0]) = \ud835\udfd9 _)\n(s\u2080_comp_\u03b4\u2081' : s 0 \u226b (drop.obj X).\u03b4 1 = X.hom.app (op [0]) \u226b s')\n(s_comp_\u03b4\u2080' : \u03a0 (n : \u2115), s n \u226b (drop.obj X).\u03b4 0 = \ud835\udfd9 _)\n(s_comp_\u03b4' : \u03a0 (n : \u2115) (i : fin (n+2)), s (n+1) \u226b (drop.obj X).\u03b4 i.succ =\n  (drop.obj X).\u03b4 i \u226b s n)\n(s_comp_\u03c3' : \u03a0 (n : \u2115) (i : fin (n+1)), s n \u226b (drop.obj X).\u03c3 i.succ =\n  (drop.obj X).\u03c3 i \u226b s (n+1))\n\nnamespace extra_degeneracy\n\nrestate_axiom s'_comp_\u03b5'\nrestate_axiom s\u2080_comp_\u03b4\u2081'\nrestate_axiom s_comp_\u03b4\u2080'\nrestate_axiom s_comp_\u03b4'\nrestate_axiom s_comp_\u03c3'\nattribute [reassoc] s'_comp_\u03b5 s\u2080_comp_\u03b4\u2081 s_comp_\u03b4\u2080 s_comp_\u03b4 s_comp_\u03c3\nattribute [simp] s'_comp_\u03b5 s_comp_\u03b4\u2080\n\n/-- If `ed` is an extra degeneracy for `X : simplicial_object.augmented C` and\n`F : C \u2964 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 \u2964 D) :\n  extra_degeneracy (((whiskering _ _).obj F).obj X) :=\n{ s' := F.map ed.s',\n  s := \u03bb n, F.map (ed.s n),\n  s'_comp_\u03b5' := by { dsimp, erw [comp_id, \u2190 F.map_comp, ed.s'_comp_\u03b5, F.map_id], },\n  s\u2080_comp_\u03b4\u2081' := by { dsimp, erw [comp_id, \u2190 F.map_comp, \u2190 F.map_comp, ed.s\u2080_comp_\u03b4\u2081], },\n  s_comp_\u03b4\u2080' := \u03bb n, by { dsimp, erw [\u2190 F.map_comp, ed.s_comp_\u03b4\u2080, F.map_id], },\n  s_comp_\u03b4' := \u03bb n i, by { dsimp, erw [\u2190 F.map_comp, \u2190 F.map_comp, ed.s_comp_\u03b4], refl, },\n  s_comp_\u03c3' := \u03bb n i, by { dsimp, erw [\u2190 F.map_comp, \u2190 F.map_comp, ed.s_comp_\u03c3], 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 \u2245 Y) (ed : extra_degeneracy X) :\n  extra_degeneracy Y :=\n{ s' := (point.map_iso e).inv \u226b ed.s' \u226b (drop.map_iso e).hom.app (op [0]),\n  s := \u03bb n, (drop.map_iso e).inv.app (op [n]) \u226b ed.s n \u226b (drop.map_iso e).hom.app (op [n+1]),\n  s'_comp_\u03b5' := by simpa only [functor.map_iso, assoc, w\u2080, ed.s'_comp_\u03b5_assoc]\n    using (point.map_iso e).inv_hom_id,\n  s\u2080_comp_\u03b4\u2081' := begin\n    have h := w\u2080 e.inv,\n    dsimp at h \u22a2,\n    simp only [assoc, \u2190 simplicial_object.\u03b4_naturality, ed.s\u2080_comp_\u03b4\u2081_assoc, reassoc_of h],\n  end,\n  s_comp_\u03b4\u2080' := \u03bb n, begin\n    have h := ed.s_comp_\u03b4\u2080',\n    dsimp at \u22a2 h,\n    simpa only [assoc, \u2190 simplicial_object.\u03b4_naturality, reassoc_of h]\n      using congr_app (drop.map_iso e).inv_hom_id (op [n]),\n  end,\n  s_comp_\u03b4' := \u03bb n i, begin\n    have h := ed.s_comp_\u03b4' n i,\n    dsimp at \u22a2 h,\n    simp only [assoc, \u2190 simplicial_object.\u03b4_naturality, reassoc_of h,\n      \u2190 simplicial_object.\u03b4_naturality_assoc],\n  end,\n  s_comp_\u03c3' := \u03bb n i, begin\n    have h := ed.s_comp_\u03c3' n i,\n    dsimp at \u22a2 h,\n    simp only [assoc, \u2190 simplicial_object.\u03c3_naturality, reassoc_of h,\n      \u2190 simplicial_object.\u03c3_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 \u2192 X`\nis a map `fin (n+1) \u2192 X` which sends `0` to `0` and `i.succ` to `f i`. -/\ndef shift_fun {n : \u2115} {X : Type*} [has_zero X] (f : fin n \u2192 X) (i : fin (n+1)) : X :=\ndite (i = 0) (\u03bb h, 0) (\u03bb h, f (i.pred h))\n\n@[simp]\nlemma shift_fun_0 {n : \u2115} {X : Type*} [has_zero X] (f : fin n \u2192 X) : shift_fun f 0 = 0 := rfl\n\n@[simp]\nlemma shift_fun_succ {n : \u2115} {X : Type*} [has_zero X] (f : fin n \u2192 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] \u2192 \u0394` 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 : \u2115} {\u0394 : simplex_category} (f : [n] \u27f6 \u0394) : [n+1] \u27f6 \u0394 := simplex_category.hom.mk\n{ to_fun := shift_fun f.to_order_hom,\n  monotone' := \u03bb i\u2081 i\u2082 hi, begin\n    by_cases h\u2081 : i\u2081 = 0,\n    { subst h\u2081,\n      simp only [shift_fun_0, fin.zero_le], },\n    { have h\u2082 : i\u2082 \u2260 0 := by { intro h\u2082, subst h\u2082, exact h\u2081 (le_antisymm hi (fin.zero_le _)), },\n      cases fin.eq_succ_of_ne_zero h\u2081 with j\u2081 hj\u2081,\n      cases fin.eq_succ_of_ne_zero h\u2082 with j\u2082 hj\u2082,\n      substs hj\u2081 hj\u2082,\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 (\u0394 : simplex_category) :\n  simplicial_object.augmented.extra_degeneracy (standard_simplex.obj \u0394) :=\n{ s' := \u03bb x, simplex_category.hom.mk (order_hom.const _ 0),\n  s := \u03bb n f, shift f,\n  s'_comp_\u03b5' := by { ext1 j, fin_cases j, },\n  s\u2080_comp_\u03b4\u2081' := by { ext x j, fin_cases j, refl, },\n  s_comp_\u03b4\u2080' := \u03bb n, begin\n    ext \u03c6 i : 4,\n    dsimp [simplicial_object.\u03b4, simplex_category.\u03b4, sSet.standard_simplex],\n    simp only [shift_fun_succ],\n  end,\n  s_comp_\u03b4' := \u03bb n i, begin\n    ext \u03c6 j : 4,\n    dsimp [simplicial_object.\u03b4, simplex_category.\u03b4, 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_\u03c3' := \u03bb n i, begin\n    ext \u03c6 j : 4,\n    dsimp [simplicial_object.\u03c3, simplex_category.\u03c3, sSet.standard_simplex],\n    by_cases j = 0,\n    { subst h,\n      simpa only [shift_fun_0] using shift_fun_0 \u03c6.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 (\u0394 : simplex_category) :\n  nonempty (simplicial_object.augmented.extra_degeneracy (standard_simplex.obj \u0394)) :=\n\u27e8standard_simplex.extra_degeneracy \u0394\u27e9\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  [\u2200 n : \u2115, has_wide_pullback f.right (\u03bb i : fin (n+1), f.left) (\u03bb i, f.hom)]\n  (S : split_epi f.hom)\n\ninclude S\n\n/-- The extra degeneracy map on the \u010cech 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 : \u2115) :\n  f.cech_nerve.obj (op [n]) \u27f6 f.cech_nerve.obj (op [n + 1]) :=\nwide_pullback.lift (wide_pullback.base _)\n  (\u03bb i, dite (i = 0) (\u03bb h, wide_pullback.base _ \u226b S.section_)\n    (\u03bb h, wide_pullback.\u03c0 _ (i.pred h)))\n  (\u03bb i, begin\n    split_ifs,\n    { subst h,\n      simp only [assoc, split_epi.id, comp_id], },\n    { simp only [wide_pullback.\u03c0_arrow], },\n  end)\n\n@[simp]\nlemma extra_degeneracy.s_comp_\u03c0_0 (n : \u2115) :\n  extra_degeneracy.s f S n \u226b wide_pullback.\u03c0 _ 0 = wide_pullback.base _ \u226b S.section_ :=\nby { dsimp [extra_degeneracy.s], simpa only [wide_pullback.lift_\u03c0], }\n\n@[simp]\nlemma extra_degeneracy.s_comp_\u03c0_succ (n : \u2115) (i : fin (n+1)) :\n  extra_degeneracy.s f S n \u226b wide_pullback.\u03c0 _ i.succ = wide_pullback.\u03c0 _ i :=\nbegin\n  dsimp [extra_degeneracy.s],\n  simp only [wide_pullback.lift_\u03c0],\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 : \u2115) :\n  extra_degeneracy.s f S n \u226b wide_pullback.base _ = wide_pullback.base _ :=\nby apply wide_pullback.lift_base\n\n/-- The augmented \u010cech 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_ \u226b wide_pullback.lift f.hom (\u03bb i, \ud835\udfd9 _) (\u03bb i, by rw id_comp),\n  s := \u03bb n, extra_degeneracy.s f S n,\n  s'_comp_\u03b5' :=\n    by simp only [augmented_cech_nerve_hom_app, assoc, wide_pullback.lift_base, split_epi.id],\n  s\u2080_comp_\u03b4\u2081' := begin\n    dsimp [cech_nerve, simplicial_object.\u03b4, simplex_category.\u03b4],\n    ext j,\n    { fin_cases j,\n      simpa only [assoc, wide_pullback.lift_\u03c0, comp_id] using extra_degeneracy.s_comp_\u03c0_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_\u03b4\u2080' := \u03bb n, begin\n    dsimp [cech_nerve, simplicial_object.\u03b4, simplex_category.\u03b4],\n    ext j,\n    { simpa only [assoc, wide_pullback.lift_\u03c0, id_comp]\n        using extra_degeneracy.s_comp_\u03c0_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_\u03b4' := \u03bb n i, begin\n    dsimp [cech_nerve, simplicial_object.\u03b4, simplex_category.\u03b4],\n    ext j,\n    { simp only [assoc, wide_pullback.lift_\u03c0],\n      by_cases j = 0,\n      { subst h,\n        erw [fin.succ_succ_above_zero, extra_degeneracy.s_comp_\u03c0_0, extra_degeneracy.s_comp_\u03c0_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_\u03c0_succ,\n          extra_degeneracy.s_comp_\u03c0_succ],\n        dsimp,\n        simp only [wide_pullback.lift_\u03c0], }, },\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_\u03c3' := \u03bb n i, begin\n    dsimp [cech_nerve, simplicial_object.\u03c3, simplex_category.\u03c3],\n    ext j,\n    { simp only [assoc, wide_pullback.lift_\u03c0],\n      by_cases j = 0,\n      { subst h,\n        erw [extra_degeneracy.s_comp_\u03c0_0, extra_degeneracy.s_comp_\u03c0_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_\u03c0_succ,\n          extra_degeneracy.s_comp_\u03c0_succ],\n        dsimp,\n        simp only [wide_pullback.lift_\u03c0], }, },\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\u2080 C).obj (point.obj X)) :=\n{ hom := alternating_face_map_complex.\u03b5.app X,\n  inv := (chain_complex.from_single\u2080_equiv _ _).inv_fun ed.s',\n  homotopy_inv_hom_id := homotopy.of_eq (by { ext, exact ed.s'_comp_\u03b5, }),\n  homotopy_hom_inv_id :=\n  { hom := \u03bb i j, begin\n      by_cases i+1 = j,\n      { exact (-ed.s i) \u226b eq_to_hom (by congr'), },\n      { exact 0, },\n    end,\n    zero' := \u03bb i j hij, begin\n      split_ifs,\n      { exfalso, exact hij h, },\n      { simp only [eq_self_iff_true], },\n    end,\n    comm := \u03bb 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\u2080_equiv, chain_complex.to_single\u2080_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, \u2190 s\u2080_comp_\u03b4\u2081,\n          s_comp_\u03b4\u2080, 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\u2080_equiv, chain_complex.from_single\u2080_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_\u03b4\u2080, 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_\u03b4, zsmul_neg],\n        rw [add_comm (-\ud835\udfd9 _), 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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R`, where `I\u2081 : R\u2081 \u2192+* R` and `I\u2082 : R\u2082 \u2192+* R` are ring homomorphisms and\n`M\u2081` is a module over `R\u2081` and `M\u2082` is a module over `R\u2082`.\nSesquilinear forms are the special case that `M\u2081 = M\u2082`, `R\u2081 = R\u2082 = R`, and `I\u2081 = ring_hom.id R`.\nTaking additionally `I\u2082 = 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\u2081 R\u2082 R\u2083 M M\u2081 M\u2082 K K\u2081 K\u2082 V V\u2081 V\u2082 n: Type*}\n\nnamespace linear_map\n\n/-! ### Orthogonal vectors -/\n\nsection comm_ring\n\n-- the `\u2097` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariables [comm_semiring R] [comm_semiring R\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  [comm_semiring R\u2082] [add_comm_monoid M\u2082] [module R\u2082 M\u2082]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2082 \u2192+* R} {I\u2081' : R\u2081 \u2192+* R}\n\n/-- The proposition that two elements of a sesquilinear form space are orthogonal -/\ndef is_ortho (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x y) : Prop := B x y = 0\n\nlemma is_ortho_def {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} {x y} :\n  B.is_ortho x y \u2194 B x y = 0 := iff.rfl\n\nlemma is_ortho_zero_left (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x) : is_ortho B (0 : M\u2081) x :=\n  by { dunfold is_ortho, rw [ map_zero B, zero_apply] }\n\nlemma is_ortho_zero_right (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x) : is_ortho B x (0 : M\u2082) :=\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 \u2260 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\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2081'] R) (v : n \u2192 M\u2081) : Prop :=\npairwise (B.is_ortho on v)\n\nlemma is_Ortho_def {n : Type*} {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2081'] R} {v : n \u2192 M\u2081} :\n  B.is_Ortho v \u2194 \u2200 i j : n, i \u2260 j \u2192 B (v i) (v j) = 0 := iff.rfl\n\nend comm_ring\nsection field\n\nvariables [field K] [field K\u2081] [add_comm_group V\u2081] [module K\u2081 V\u2081]\n  [field K\u2082] [add_comm_group V\u2082] [module K\u2082 V\u2082]\n  {I\u2081 : K\u2081 \u2192+* K} {I\u2082 : K\u2082 \u2192+* K} {I\u2081' : K\u2081 \u2192+* K}\n  {J\u2081 : K \u2192+* K} {J\u2082 : K \u2192+* K}\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J\u2081 is invertible\nlemma ortho_smul_left {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2082 \u2192\u209b\u2097[I\u2082] K} {x y} {a : K\u2081} (ha : a \u2260 0) :\n  (is_ortho B x y) \u2194 (is_ortho B (a \u2022 x) y) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smul\u209b\u2097\u2082, H, smul_zero]},\n  { rw [map_smul\u209b\u2097\u2082, smul_eq_zero] at H,\n    cases H,\n    { rw I\u2081.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\u2082 is invertible\nlemma ortho_smul_right {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2082 \u2192\u209b\u2097[I\u2082] K} {x y} {a : K\u2082} {ha : a \u2260 0} :\n(is_ortho B x y) \u2194 (is_ortho B x (a \u2022 y)) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smul\u209b\u2097, H, smul_zero] },\n  { rw [map_smul\u209b\u2097, 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) \u2260 0`. -/\nlemma linear_independent_of_is_Ortho {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2081 \u2192\u209b\u2097[I\u2081'] K} {v : n \u2192 V\u2081}\n  (hv\u2081 : B.is_Ortho v) (hv\u2082 : \u2200 i, \u00ac B.is_ortho (v i) (v i)) : linear_independent K\u2081 v :=\nbegin\n  classical,\n  rw linear_independent_iff',\n  intros s w hs i hi,\n  have : B (s.sum $ \u03bb (i : n), w i \u2022 v i) (v i) = 0,\n  { rw [hs, map_zero, zero_apply] },\n  have hsum : s.sum (\u03bb (j : n), I\u2081(w j) * B (v j) (v i)) = I\u2081(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\u2081 _ _ hij, mul_zero], },\n  simp_rw [B.map_sum\u2082, map_smul\u209b\u2097\u2082, smul_eq_mul, hsum] at this,\n  apply I\u2081.map_eq_zero.mp,\n  exact eq_zero_of_ne_zero_of_mul_right_eq_zero (hv\u2082 i) this,\nend\n\nend field\n\nvariables [comm_ring R] [add_comm_group M] [module R M]\n  [comm_ring R\u2081] [add_comm_group M\u2081] [module R\u2081 M\u2081]\n  {I : R \u2192+* R} {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2081 \u2192+* R}\n  {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R}\n  {B' : M \u2192\u2097[R] M \u2192\u209b\u2097[I] R}\n\n/-! ### Reflexive bilinear forms -/\n\n/-- The proposition that a sesquilinear form is reflexive -/\ndef is_refl (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : Prop :=\n  \u2200 (x y), B x y = 0 \u2192 B y x = 0\n\nnamespace is_refl\n\nvariable (H : B.is_refl)\n\nlemma eq_zero : \u2200 {x y}, B x y = 0 \u2192 B y x = 0 := \u03bb x y, H x y\n\nlemma ortho_comm {x y} : is_ortho B x y \u2194 is_ortho B y x := \u27e8eq_zero H, eq_zero H\u27e9\n\nend is_refl\n\n/-! ### Symmetric bilinear forms -/\n\n/-- The proposition that a sesquilinear form is symmetric -/\ndef is_symm (B : M \u2192\u2097[R] M \u2192\u209b\u2097[I] R) : Prop :=\n  \u2200 (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 := \u03bb x y H1, by { rw [\u2190H], simp [H1] }\n\nlemma ortho_comm {x y} : is_ortho B' x y \u2194 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\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : Prop := \u2200 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 [\u2190neg H, h, neg_zero],\nend\n\nlemma ortho_comm {x y} : is_ortho B x y \u2194 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\u2081] [add_comm_group M\u2081] [module R\u2081 M\u2081]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2081 \u2192+* R}\n  {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] 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\u2081 M\u2081) (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : submodule R\u2081 M\u2081 :=\n{ carrier := { m | \u2200 n \u2208 N, B.is_ortho n m },\n  zero_mem' := \u03bb x _, B.is_ortho_zero_right x,\n  add_mem' := \u03bb 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' := \u03bb c x hx n hn,\n    by rw [linear_map.is_ortho, linear_map.map_smul\u209b\u2097, show B n x = 0, by exact hx n hn,\n        smul_zero] }\n\nvariables {N L : submodule R\u2081 M\u2081}\n\n@[simp] lemma mem_orthogonal_bilin_iff {m : M\u2081} :\n  m \u2208 N.orthogonal_bilin B \u2194 \u2200 n \u2208 N, B.is_ortho n m := iff.rfl\n\nlemma orthogonal_bilin_le (h : N \u2264 L) : L.orthogonal_bilin B \u2264 N.orthogonal_bilin B :=\n\u03bb _ hn l hl, hn l (h hl)\n\nlemma le_orthogonal_bilin_orthogonal_bilin (b : B.is_refl) :\n  N \u2264 (N.orthogonal_bilin B).orthogonal_bilin B :=\n\u03bb 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\u2081] [add_comm_group V\u2081] [module K\u2081 V\u2081]\n  {J : K \u2192+* K} {J\u2081 : K\u2081 \u2192+* K} {J\u2081' : K\u2081 \u2192+* K}\n\n-- \u2193 This lemma only applies in fields as we require `a * b = 0 \u2192 a = 0 \u2228 b = 0`\nlemma span_singleton_inf_orthogonal_eq_bot\n  (B : V\u2081 \u2192\u209b\u2097[J\u2081] V\u2081 \u2192\u209b\u2097[J\u2081'] K) (x : V\u2081) (hx : \u00ac B.is_ortho x x) :\n  (K\u2081 \u2219 x) \u2293 submodule.orthogonal_bilin (K\u2081 \u2219 x) B = \u22a5 :=\nbegin\n  rw \u2190 finset.coe_singleton,\n  refine eq_bot_iff.2 (\u03bb y h, _),\n  rcases mem_span_finset.1 h.1 with \u27e8\u03bc, rfl\u27e9,\n  have := h.2 x _,\n  { rw finset.sum_singleton at this \u22a2,\n    suffices h\u03bczero : \u03bc x = 0,\n    { rw [h\u03bczero, zero_smul, submodule.mem_bot] },\n    change B x (\u03bc x \u2022 x) = 0 at this, rw [map_smul\u209b\u2097, smul_eq_mul] at this,\n    exact or.elim (zero_eq_mul.mp this.symm)\n    (\u03bb y, by { simp at y, exact y })\n    (\u03bb hfalse, false.elim $ hx hfalse) },\n  { rw submodule.mem_span; exact \u03bb _ hp, hp $ finset.mem_singleton_self _ }\nend\n\n-- \u2193 This lemma only applies in fields since we use the `mul_eq_zero`\nlemma orthogonal_span_singleton_eq_to_lin_ker {B : V \u2192\u2097[K] V \u2192\u209b\u2097[J] K} (x : V) :\n  submodule.orthogonal_bilin (K \u2219 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 \u03bb h, h x \u27e81, one_smul _ _\u27e9 },\n  { rintro h _ \u27e8z, rfl\u27e9,\n    rw [is_ortho, map_smul\u209b\u2097\u2082, 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 \u2192\u2097[K] V \u2192\u2097[K] K}\n  {x : V} (hx : \u00ac B.is_ortho x x) :\n  (K \u2219 x) \u2294 submodule.orthogonal_bilin (K \u2219 x) B = \u22a4 :=\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 \u2260 0`, the span of the singleton of `x`\n  is complement to its orthogonal complement. -/\nlemma is_compl_span_singleton_orthogonal {B : V \u2192\u2097[K] V \u2192\u2097[K] K}\n  {x : V} (hx : \u00ac B.is_ortho x x) : is_compl (K \u2219 x) (submodule.orthogonal_bilin (K \u2219 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 `\u03b1`.\nIt is isomorphic to the polynomial ring over \u2124 with variables\nin `\u03b1`\n\n## Main definitions\n\n* `free_comm_ring \u03b1`     : the free commutative ring on a type \u03b1\n* `lift_hom (f : \u03b1 \u2192 R)` : the ring hom `free_comm_ring \u03b1 \u2192+* R` induced by functoriality from `f`.\n* `map (f : \u03b1 \u2192 \u03b2)`      : the ring hom `free_comm_ring \u03b1 \u2192*+ free_comm_ring \u03b2` 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 : \u03b1 \u2192 free_comm_ring \u03b1`\n* `lift_hom (f : \u03b1 \u2192 R) : free_comm_ring \u03b1 \u2192+* R`\n* `map (f : \u03b1 \u2192 \u03b2) : free_comm_ring \u03b1 \u2192+* free_comm_ring \u03b2`\n\n* `free_comm_ring_equiv_mv_polynomial_int : free_comm_ring \u03b1 \u2243+* mv_polynomial \u03b1 \u2124` :\n    `free_comm_ring \u03b1` is isomorphic to a polynomial ring.\n\n\n\n## Implementation notes\n\n`free_comm_ring \u03b1` is implemented not using `mv_polynomial` but\ndirectly as the free abelian group on `multiset \u03b1`, the type\nof monomials in this free commutative ring.\n\n## Tags\n\nfree commutative ring, free ring\n-/\n\n/-- `free_comm_ring \u03b1` is the free commutative ring on the type `\u03b1`. -/\ndef free_comm_ring (\u03b1 : Type u) := free_abelian_group (multiplicative (multiset \u03b1))\n\nnamespace free_comm_ring\n\n\n/-- The structure of a commutative ring on `free_comm_ring \u03b1`. -/\nprotected instance comm_ring (\u03b1 : Type u) : comm_ring (free_comm_ring \u03b1) :=\n  free_abelian_group.comm_ring (multiplicative (multiset \u03b1))\n\nprotected instance inhabited (\u03b1 : Type u) : Inhabited (free_comm_ring \u03b1) := { default := 0 }\n\n/-- The canonical map from `\u03b1` to the free commutative ring on `\u03b1`. -/\ndef of {\u03b1 : Type u} (x : \u03b1) : free_comm_ring \u03b1 := free_abelian_group.of \u2191[x]\n\ntheorem of_injective {\u03b1 : Type u} : function.injective of :=\n  function.injective.comp free_abelian_group.of_injective\n    fun (x y : \u03b1) => iff.mp (iff.trans multiset.coe_eq_coe list.singleton_perm_singleton)\n\nprotected theorem induction_on {\u03b1 : Type u} {C : free_comm_ring \u03b1 \u2192 Prop} (z : free_comm_ring \u03b1)\n    (hn1 : C (-1)) (hb : \u2200 (b : \u03b1), C (of b))\n    (ha : \u2200 (x y : free_comm_ring \u03b1), C x \u2192 C y \u2192 C (x + y))\n    (hm : \u2200 (x y : free_comm_ring \u03b1), C x \u2192 C y \u2192 C (x * y)) : C z :=\n  sorry\n\n/-- Lift a map `\u03b1 \u2192 R` to a additive group homomorphism `free_comm_ring \u03b1 \u2192 R`.\nFor a version producing a bundled homomorphism, see `lift_hom`. -/\ndef lift {\u03b1 : Type u} {R : Type v} [comm_ring R] (f : \u03b1 \u2192 R) : free_comm_ring \u03b1 \u2192+* R :=\n  ring_hom.mk\n    (add_monoid_hom.to_fun\n      (free_abelian_group.lift\n        fun (s : multiplicative (multiset \u03b1)) =>\n          multiset.prod (multiset.map f (coe_fn multiplicative.to_add s))))\n    sorry sorry sorry sorry\n\n@[simp] theorem lift_of {\u03b1 : Type u} {R : Type v} [comm_ring R] (f : \u03b1 \u2192 R) (x : \u03b1) :\n    coe_fn (lift f) (of x) = f x :=\n  sorry\n\n@[simp] theorem lift_comp_of {\u03b1 : Type u} {R : Type v} [comm_ring R] (f : free_comm_ring \u03b1 \u2192+* R) :\n    lift (\u21d1f \u2218 of) = f :=\n  sorry\n\n/-- A map `f : \u03b1 \u2192 \u03b2` produces a ring homomorphism `free_comm_ring \u03b1 \u2192+* free_comm_ring \u03b2`. -/\ndef map {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) : free_comm_ring \u03b1 \u2192+* free_comm_ring \u03b2 :=\n  lift (of \u2218 f)\n\n@[simp] theorem map_of {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (x : \u03b1) :\n    coe_fn (map f) (of x) = of (f x) :=\n  lift_of (of \u2218 f) x\n\n/-- `is_supported x s` means that all monomials showing up in `x` have variables in `s`. -/\ndef is_supported {\u03b1 : Type u} (x : free_comm_ring \u03b1) (s : set \u03b1) := x \u2208 ring.closure (of '' s)\n\ntheorem is_supported_upwards {\u03b1 : Type u} {x : free_comm_ring \u03b1} {s : set \u03b1} {t : set \u03b1}\n    (hs : is_supported x s) (hst : s \u2286 t) : is_supported x t :=\n  ring.closure_mono (set.monotone_image hst) hs\n\ntheorem is_supported_add {\u03b1 : Type u} {x : free_comm_ring \u03b1} {y : free_comm_ring \u03b1} {s : set \u03b1}\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 {\u03b1 : Type u} {x : free_comm_ring \u03b1} {s : set \u03b1} (hxs : is_supported x s) :\n    is_supported (-x) s :=\n  is_add_subgroup.neg_mem hxs\n\ntheorem is_supported_sub {\u03b1 : Type u} {x : free_comm_ring \u03b1} {y : free_comm_ring \u03b1} {s : set \u03b1}\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 {\u03b1 : Type u} {x : free_comm_ring \u03b1} {y : free_comm_ring \u03b1} {s : set \u03b1}\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 {\u03b1 : Type u} {s : set \u03b1} : is_supported 0 s := is_add_submonoid.zero_mem\n\ntheorem is_supported_one {\u03b1 : Type u} {s : set \u03b1} : is_supported 1 s := is_submonoid.one_mem\n\ntheorem is_supported_int {\u03b1 : Type u} {i : \u2124} {s : set \u03b1} : is_supported (\u2191i) s := sorry\n\n/-- The restriction map from `free_comm_ring \u03b1` to `free_comm_ring s` where `s : set \u03b1`, defined\n  by sending all variables not in `s` to zero. -/\ndef restriction {\u03b1 : Type u} (s : set \u03b1) [decidable_pred s] :\n    free_comm_ring \u03b1 \u2192+* free_comm_ring \u21a5s :=\n  lift\n    fun (p : \u03b1) =>\n      dite (p \u2208 s) (fun (H : p \u2208 s) => of { val := p, property := H }) fun (H : \u00acp \u2208 s) => 0\n\n@[simp] theorem restriction_of {\u03b1 : Type u} (s : set \u03b1) [decidable_pred s] (p : \u03b1) :\n    coe_fn (restriction s) (of p) =\n        dite (p \u2208 s) (fun (H : p \u2208 s) => of { val := p, property := H }) fun (H : \u00acp \u2208 s) => 0 :=\n  lift_of\n    (fun (p : \u03b1) =>\n      dite (p \u2208 s) (fun (H : p \u2208 s) => of { val := p, property := H }) fun (H : \u00acp \u2208 s) => 0)\n    p\n\ntheorem is_supported_of {\u03b1 : Type u} {p : \u03b1} {s : set \u03b1} : is_supported (of p) s \u2194 p \u2208 s := sorry\n\ntheorem map_subtype_val_restriction {\u03b1 : Type u} {x : free_comm_ring \u03b1} (s : set \u03b1)\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 {\u03b1 : Type u} (x : free_comm_ring \u03b1) :\n    \u2203 (s : set \u03b1), set.finite s \u2227 is_supported x s :=\n  sorry\n\ntheorem exists_finset_support {\u03b1 : Type u} (x : free_comm_ring \u03b1) :\n    \u2203 (s : finset \u03b1), is_supported x \u2191s :=\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 `\u03b1` to the free commutative ring\n    generated by `\u03b1`. -/\ndef to_free_comm_ring {\u03b1 : Type u_1} : free_ring \u03b1 \u2192+* free_comm_ring \u03b1 := lift free_comm_ring.of\n\nprotected instance free_comm_ring.has_coe (\u03b1 : Type u) : has_coe (free_ring \u03b1) (free_comm_ring \u03b1) :=\n  has_coe.mk \u21d1to_free_comm_ring\n\nprotected instance coe.is_ring_hom (\u03b1 : Type u) : is_ring_hom coe :=\n  ring_hom.is_ring_hom to_free_comm_ring\n\n@[simp] protected theorem coe_zero (\u03b1 : Type u) : \u21910 = 0 := rfl\n\n@[simp] protected theorem coe_one (\u03b1 : Type u) : \u21911 = 1 := rfl\n\n@[simp] protected theorem coe_of {\u03b1 : Type u} (a : \u03b1) : \u2191(of a) = free_comm_ring.of a :=\n  lift_of free_comm_ring.of a\n\n@[simp] protected theorem coe_neg {\u03b1 : Type u} (x : free_ring \u03b1) : \u2191(-x) = -\u2191x :=\n  ring_hom.map_neg (lift free_comm_ring.of) x\n\n@[simp] protected theorem coe_add {\u03b1 : Type u} (x : free_ring \u03b1) (y : free_ring \u03b1) :\n    \u2191(x + y) = \u2191x + \u2191y :=\n  ring_hom.map_add (lift free_comm_ring.of) x y\n\n@[simp] protected theorem coe_sub {\u03b1 : Type u} (x : free_ring \u03b1) (y : free_ring \u03b1) :\n    \u2191(x - y) = \u2191x - \u2191y :=\n  ring_hom.map_sub (lift free_comm_ring.of) x y\n\n@[simp] protected theorem coe_mul {\u03b1 : Type u} (x : free_ring \u03b1) (y : free_ring \u03b1) :\n    \u2191(x * y) = \u2191x * \u2191y :=\n  ring_hom.map_mul (lift free_comm_ring.of) x y\n\nprotected theorem coe_surjective (\u03b1 : Type u) : function.surjective coe := sorry\n\ntheorem coe_eq (\u03b1 : Type u) : coe = Functor.map fun (l : List \u03b1) => \u2191l := 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 \u2243 S` as a ring equivalence `R \u2243+* S`. -/\ndef of' {R : Type u_1} {S : Type u_2} [ring R] [ring S] (e : R \u2243 S) [is_ring_hom \u21d1e] : R \u2243+* 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 \u03b1 has size at most 1 then the natural map from the free ring on `\u03b1` to the\n    free commutative ring on `\u03b1` is an isomorphism of rings. -/\ndef subsingleton_equiv_free_comm_ring (\u03b1 : Type u) [subsingleton \u03b1] :\n    free_ring \u03b1 \u2243+* free_comm_ring \u03b1 :=\n  of' (functor.map_equiv free_abelian_group (multiset.subsingleton_equiv \u03b1))\n\nprotected instance comm_ring (\u03b1 : Type u) [subsingleton \u03b1] : comm_ring (free_ring \u03b1) :=\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 `\u03b1` is isomorphic to the polynomial ring over \u2124 with\n    variables in `\u03b1` -/\ndef free_comm_ring_equiv_mv_polynomial_int (\u03b1 : Type u) : free_comm_ring \u03b1 \u2243+* mv_polynomial \u03b1 \u2124 :=\n  ring_equiv.mk (\u21d1(free_comm_ring.lift fun (a : \u03b1) => mv_polynomial.X a))\n    (mv_polynomial.eval\u2082 (int.cast_ring_hom (free_comm_ring \u03b1)) free_comm_ring.of) sorry sorry sorry\n    sorry\n\n/-- The free commutative ring on the empty type is isomorphic to `\u2124`. -/\ndef free_comm_ring_pempty_equiv_int : free_comm_ring pempty \u2243+* \u2124 :=\n  ring_equiv.trans (free_comm_ring_equiv_mv_polynomial_int pempty)\n    (mv_polynomial.pempty_ring_equiv \u2124)\n\n/-- The free commutative ring on a type with one term is isomorphic to `\u2124[X]`. -/\ndef free_comm_ring_punit_equiv_polynomial_int : free_comm_ring PUnit \u2243+* polynomial \u2124 :=\n  ring_equiv.trans (free_comm_ring_equiv_mv_polynomial_int PUnit) (mv_polynomial.punit_ring_equiv \u2124)\n\n/-- The free ring on the empty type is isomorphic to `\u2124`. -/\ndef free_ring_pempty_equiv_int : free_ring pempty \u2243+* \u2124 :=\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 `\u2124[X]`. -/\ndef free_ring_punit_equiv_polynomial_int : free_ring PUnit \u2243+* polynomial \u2124 :=\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 \u2964 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\u2081 u u\u2081 u\u2082 -- 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 : \u2200 (X Y : C), \u2203 Z (f : X \u27f6 Z) (g : Y \u27f6 Z), true)\n(cocone_maps : \u2200 \u2983X Y : C\u2984 (f g : X \u27f6 Y), \u2203 Z (h : Y \u27f6 Z), f \u226b h = g \u226b 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  (\u03b1 : Type u) [semilattice_sup \u03b1] : is_filtered_or_empty \u03b1 :=\n{ cocone_objs := \u03bb X Y, \u27e8X \u2294 Y, hom_of_le le_sup_left, hom_of_le le_sup_right, trivial\u27e9,\n  cocone_maps := \u03bb X Y f g, \u27e8Y, \ud835\udfd9 _, (by ext)\u27e9, }\n\n@[priority 100]\ninstance is_filtered_of_semilattice_sup_nonempty\n  (\u03b1 : Type u) [semilattice_sup \u03b1] [nonempty \u03b1] : is_filtered \u03b1 := {}\n\n@[priority 100]\ninstance is_filtered_or_empty_of_directed_le (\u03b1 : Type u) [preorder \u03b1] [is_directed \u03b1 (\u2264)] :\n  is_filtered_or_empty \u03b1 :=\n{ cocone_objs := \u03bb X Y, let \u27e8Z, h1, h2\u27e9 := exists_ge_ge X Y in\n    \u27e8Z, hom_of_le h1, hom_of_le h2, trivial\u27e9,\n  cocone_maps := \u03bb X Y f g, \u27e8Y, \ud835\udfd9 _, by simp\u27e9 }\n\n@[priority 100]\ninstance is_filtered_of_directed_le_nonempty  (\u03b1 : Type u) [preorder \u03b1] [is_directed \u03b1 (\u2264)]\n  [nonempty \u03b1] :\n  is_filtered \u03b1 := {}\n\n-- Sanity checks\nexample (\u03b1 : Type u) [semilattice_sup \u03b1] [order_bot \u03b1] : is_filtered \u03b1 := by apply_instance\nexample (\u03b1 : Type u) [semilattice_sup \u03b1] [order_top \u03b1] : is_filtered \u03b1 := 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 \u27f6 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' \u27f6 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 \u27f6 j'`, is an arbitrary choice of object\nwhich admits a morphism `coeq_hom f f' : j' \u27f6 coeq f f'` such that\n`coeq_condition : f \u226b coeq_hom f f' = f' \u226b coeq_hom f f'`.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq {j j' : C} (f f' : j \u27f6 j') : C :=\n(is_filtered_or_empty.cocone_maps f f').some\n\n/--\n`coeq_hom f f'`, for morphisms `f f' : j \u27f6 j'`, is an arbitrary choice of morphism\n`coeq_hom f f' : j' \u27f6 coeq f f'` such that\n`coeq_condition : f \u226b coeq_hom f f' = f' \u226b coeq_hom f f'`.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq_hom {j j' : C} (f f' : j \u27f6 j') : j' \u27f6 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 \u27f6 j'`, is the proof that\n`f \u226b coeq_hom f f' = f' \u226b coeq_hom f f'`.\n-/\n@[simp, reassoc]\nlemma coeq_condition {j j' : C} (f f' : j \u27f6 j') : f \u226b coeq_hom f f' = f' \u226b 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) : \u2203 (S : C), \u2200 {X}, X \u2208 O \u2192 _root_.nonempty (X \u27f6 S) :=\nbegin\n  classical,\n  apply finset.induction_on O,\n  { exact \u27e8is_filtered.nonempty.some, (by rintros - \u27e8\u27e9)\u27e9, },\n  { rintros X O' nm \u27e8S', w'\u27e9,\n    use max X S',\n    rintros Y mY,\n    obtain rfl|h := eq_or_ne Y X,\n    { exact \u27e8left_to_max _ _\u27e9, },\n    { exact \u27e8(w' (finset.mem_of_mem_insert_of_ne mY h)).some \u226b right_to_max _ _\u27e9, }, }\nend\n\nvariables (O : finset C) (H : finset (\u03a3' (X Y : C) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 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 \u27f6 S` from each `X`,\nsuch that the triangles commute: `f \u226b T Y = T X`, for `f : X \u27f6 Y` in the `finset`.\n-/\nlemma sup_exists :\n  \u2203 (S : C) (T : \u03a0 {X : C}, X \u2208 O \u2192 (X \u27f6 S)), \u2200 {X Y : C} (mX : X \u2208 O) (mY : Y \u2208 O) {f : X \u27f6 Y},\n    (\u27e8X, Y, mX, mY, f\u27e9 : (\u03a3' (X Y : C) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y)) \u2208 H \u2192 f \u226b T mY = T mX :=\nbegin\n  classical,\n  apply finset.induction_on H,\n  { obtain \u27e8S, f\u27e9 := sup_objs_exists O,\n    refine \u27e8S, \u03bb X mX, (f mX).some, _\u27e9,\n    rintros - - - - - \u27e8\u27e9, },\n  { rintros \u27e8X, Y, mX, mY, f\u27e9 H' nmf \u27e8S', T', w'\u27e9,\n    refine \u27e8coeq (f \u226b T' mY) (T' mX), \u03bb Z mZ, T' mZ \u226b coeq_hom (f \u226b T' mY) (T' mX), _\u27e9,\n    intros X' Y' mX' mY' f' mf',\n    rw [\u2190category.assoc],\n    by_cases h : X = X' \u2227 Y = Y',\n    { rcases h with \u27e8rfl, rfl\u27e9,\n      by_cases hf : f = f',\n      { subst hf,\n        apply coeq_condition, },\n      { rw @w' _ _ mX mY f' (by simpa [hf \u2218 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 \u27e8rfl, h\u27e9 := h,\n      rw [heq_iff_eq, psigma.mk.inj_iff] at h,\n      exact \u27e8rfl, h.1.symm\u27e9 }, },\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 \u2208 O) :\n  X \u27f6 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 \u2208 O) (mY : Y \u2208 O) {f : X \u27f6 Y}\n  (mf : (\u27e8X, Y, mX, mY, f\u27e9 : \u03a3' (X Y : C) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y) \u2208 H) :\n  f \u226b 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 \u2964 C` with `fin_category J`,\nthere exists a cocone over `F`.\n-/\nlemma cocone_nonempty (F : J \u2964 C) : _root_.nonempty (cocone F) :=\nbegin\n  classical,\n  let O := (finset.univ.image F.obj),\n  let H : finset (\u03a3' (X Y : C) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y) :=\n    finset.univ.bUnion (\u03bb X : J, finset.univ.bUnion (\u03bb Y : J, finset.univ.image (\u03bb f : X \u27f6 Y,\n      \u27e8F.obj X, F.obj Y, by simp, by simp, F.map f\u27e9))),\n  obtain \u27e8Z, f, w\u27e9 := sup_exists O H,\n  refine \u27e8\u27e8Z, \u27e8\u03bb X, f (by simp), _\u27e9\u27e9\u27e9,\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 \u27e8j, rfl, j', g, (by simp)\u27e9,\nend\n\n/--\nAn arbitrary choice of cocone over `F : J \u2964 C`, for `fin_category J` and `is_filtered C`.\n-/\nnoncomputable def cocone (F : J \u2964 C) : cocone F :=\n(cocone_nonempty F).some\n\nvariables {D : Type u\u2081} [category.{v\u2081} D]\n\n/--\nIf `C` is filtered, and we have a functor `R : C \u2964 D` with a left adjoint, then `D` is filtered.\n-/\nlemma of_right_adjoint {L : D \u2964 C} {R : C \u2964 D} (h : L \u22a3 R) : is_filtered D :=\n{ cocone_objs := \u03bb X Y,\n    \u27e8_, h.hom_equiv _ _ (left_to_max _ _), h.hom_equiv _ _ (right_to_max _ _), \u27e8\u27e9\u27e9,\n  cocone_maps := \u03bb X Y f g,\n    \u27e8_, h.hom_equiv _ _ (coeq_hom _ _),\n     by rw [\u2190 h.hom_equiv_naturality_left, \u2190 h.hom_equiv_naturality_left, coeq_condition]\u27e9,\n  nonempty := is_filtered.nonempty.map R.obj }\n\n/-- If `C` is filtered, and we have a right adjoint functor `R : C \u2964 D`, then `D` is filtered. -/\nlemma of_is_right_adjoint (R : C \u2964 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 \u224c D) : is_filtered D :=\nof_right_adjoint h.symm.to_adjunction\n\nsection special_shapes\n\n/--\n`max\u2083 j\u2081 j\u2082 j\u2083` is an arbitrary choice of object to the right of `j\u2081`, `j\u2082` and `j\u2083`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def max\u2083 (j\u2081 j\u2082 j\u2083 : C) : C := max (max j\u2081 j\u2082) j\u2083\n\n/--\n`first_to_max\u2083 j\u2081 j\u2082 j\u2083` is an arbitrarily choice of morphism from `j\u2081` to `max\u2083 j\u2081 j\u2082 j\u2083`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def first_to_max\u2083 (j\u2081 j\u2082 j\u2083 : C) : j\u2081 \u27f6 max\u2083 j\u2081 j\u2082 j\u2083 :=\nleft_to_max j\u2081 j\u2082 \u226b left_to_max (max j\u2081 j\u2082) j\u2083\n\n/--\n`second_to_max\u2083 j\u2081 j\u2082 j\u2083` is an arbitrarily choice of morphism from `j\u2082` to `max\u2083 j\u2081 j\u2082 j\u2083`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def second_to_max\u2083 (j\u2081 j\u2082 j\u2083 : C) : j\u2082 \u27f6 max\u2083 j\u2081 j\u2082 j\u2083 :=\nright_to_max j\u2081 j\u2082 \u226b left_to_max (max j\u2081 j\u2082) j\u2083\n\n/--\n`third_to_max\u2083 j\u2081 j\u2082 j\u2083` is an arbitrarily choice of morphism from `j\u2083` to `max\u2083 j\u2081 j\u2082 j\u2083`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def third_to_max\u2083 (j\u2081 j\u2082 j\u2083 : C) : j\u2083 \u27f6 max\u2083 j\u2081 j\u2082 j\u2083 :=\nright_to_max (max j\u2081 j\u2082) j\u2083\n\n/--\n`coeq\u2083 f g h`, for morphisms `f g h : j\u2081 \u27f6 j\u2082`, is an arbitrary choice of object\nwhich admits a morphism `coeq\u2083_hom f g h : j\u2082 \u27f6 coeq\u2083 f g h` such that\n`coeq\u2083_condition\u2081`, `coeq\u2083_condition\u2082` and `coeq\u2083_condition\u2083` are satisfied.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq\u2083 {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) : C :=\ncoeq (coeq_hom f g \u226b left_to_max (coeq f g) (coeq g h))\n  (coeq_hom g h \u226b right_to_max (coeq f g) (coeq g h))\n\n/--\n`coeq\u2083_hom f g h`, for morphisms `f g h : j\u2081 \u27f6 j\u2082`, is an arbitrary choice of morphism\n`j\u2082 \u27f6 coeq\u2083 f g h` such that `coeq\u2083_condition\u2081`, `coeq\u2083_condition\u2082` and `coeq\u2083_condition\u2083`\nare satisfied. Its existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq\u2083_hom {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) : j\u2082 \u27f6 coeq\u2083 f g h :=\ncoeq_hom f g \u226b left_to_max (coeq f g) (coeq g h) \u226b\ncoeq_hom (coeq_hom f g \u226b left_to_max (coeq f g) (coeq g h))\n  (coeq_hom g h \u226b right_to_max (coeq f g) (coeq g h))\n\nlemma coeq\u2083_condition\u2081 {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) :\n  f \u226b coeq\u2083_hom f g h = g \u226b coeq\u2083_hom f g h :=\nbegin\n  dsimp [coeq\u2083_hom],\n  slice_lhs 1 2 { rw coeq_condition f g },\n  simp only [category.assoc],\nend\n\nlemma coeq\u2083_condition\u2082 {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) :\n  g \u226b coeq\u2083_hom f g h = h \u226b coeq\u2083_hom f g h :=\nbegin\n  dsimp [coeq\u2083_hom],\n  slice_lhs 2 4 { rw [\u2190 category.assoc, coeq_condition _ _] },\n  slice_rhs 2 4 { rw [\u2190 category.assoc, coeq_condition _ _] },\n  slice_lhs 1 3 { rw [\u2190 category.assoc, coeq_condition _ _] },\n  simp only [category.assoc],\nend\n\nlemma coeq\u2083_condition\u2083 {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) :\n  f \u226b coeq\u2083_hom f g h = h \u226b coeq\u2083_hom f g h :=\neq.trans (coeq\u2083_condition\u2081 f g h) (coeq\u2083_condition\u2082 f g h)\n\n/--\nGiven a \"bowtie\" of morphisms\n```\n j\u2081   j\u2082\n |\\  /|\n | \\/ |\n | /\\ |\n |/  \\\u2223\n vv  vv\n k\u2081  k\u2082\n```\nin a filtered category, we can construct an object `s` and two morphisms from `k\u2081` and `k\u2082` to `s`,\nmaking the resulting squares commute.\n-/\nlemma bowtie {j\u2081 j\u2082 k\u2081 k\u2082 : C}\n  (f\u2081 : j\u2081 \u27f6 k\u2081) (g\u2081 : j\u2081 \u27f6 k\u2082) (f\u2082 : j\u2082 \u27f6 k\u2081) (g\u2082 : j\u2082 \u27f6 k\u2082) :\n  \u2203 (s : C) (\u03b1 : k\u2081 \u27f6 s) (\u03b2 : k\u2082 \u27f6 s), f\u2081 \u226b \u03b1 = g\u2081 \u226b \u03b2 \u2227 f\u2082 \u226b \u03b1 = g\u2082 \u226b \u03b2 :=\nbegin\n  let sa := max k\u2081 k\u2082,\n  let sb := coeq (f\u2081 \u226b left_to_max _ _) (g\u2081 \u226b right_to_max _ _),\n  let sc := coeq (f\u2082 \u226b left_to_max _ _) (g\u2082 \u226b right_to_max _ _),\n  let sd := max sb sc,\n  let s := coeq ((coeq_hom _ _ : sa \u27f6 sb) \u226b left_to_max _ _)\n    ((coeq_hom _ _ : sa \u27f6 sc) \u226b right_to_max _ _),\n  use s,\n  fsplit,\n  exact left_to_max k\u2081 k\u2082 \u226b coeq_hom _ _ \u226b left_to_max sb sc \u226b coeq_hom _ _,\n  fsplit,\n  exact right_to_max k\u2081 k\u2082 \u226b coeq_hom _ _ \u226b right_to_max sb sc \u226b coeq_hom _ _,\n  fsplit,\n  { slice_lhs 1 3 { rw [\u2190category.assoc, coeq_condition], },\n    slice_lhs 3 5 { rw [\u2190category.assoc, coeq_condition], },\n    simp only [category.assoc], },\n  { slice_lhs 3 5 { rw [\u2190category.assoc, coeq_condition], },\n    slice_lhs 1 3 { rw [\u2190category.assoc, coeq_condition], },\n    simp only [category.assoc], }\nend\n\n/--\nGiven a \"tulip\" of morphisms\n```\n j\u2081    j\u2082    j\u2083\n |\\   / \\   / |\n | \\ /   \\ /  |\n |  vv    vv  |\n \\  k\u2081    k\u2082 /\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\u2081`, `k\u2082` and `l`\nto `s`, making the resulting sqaures commute.\n-/\nlemma tulip {j\u2081 j\u2082 j\u2083 k\u2081 k\u2082 l : C} (f\u2081 : j\u2081 \u27f6 k\u2081) (f\u2082 : j\u2082 \u27f6 k\u2081) (f\u2083 : j\u2082 \u27f6 k\u2082) (f\u2084 : j\u2083 \u27f6 k\u2082)\n  (g\u2081 : j\u2081 \u27f6 l) (g\u2082 : j\u2083 \u27f6 l) :\n  \u2203 (s : C) (\u03b1 : k\u2081 \u27f6 s) (\u03b2 : l \u27f6 s) (\u03b3 : k\u2082 \u27f6 s),\n    f\u2081 \u226b \u03b1 = g\u2081 \u226b \u03b2 \u2227 f\u2082 \u226b \u03b1 = f\u2083 \u226b \u03b3 \u2227 f\u2084 \u226b \u03b3 = g\u2082 \u226b \u03b2 :=\nbegin\n  let sa := max\u2083 k\u2081 l k\u2082,\n  let sb := coeq (f\u2081 \u226b first_to_max\u2083 k\u2081 l k\u2082) (g\u2081 \u226b second_to_max\u2083 k\u2081 l k\u2082),\n  let sc := coeq (f\u2082 \u226b first_to_max\u2083 k\u2081 l k\u2082) (f\u2083 \u226b third_to_max\u2083 k\u2081 l k\u2082),\n  let sd := coeq (f\u2084 \u226b third_to_max\u2083 k\u2081 l k\u2082) (g\u2082 \u226b second_to_max\u2083 k\u2081 l k\u2082),\n  let se := max\u2083 sb sc sd,\n  let sf := coeq\u2083 (coeq_hom _ _ \u226b first_to_max\u2083 sb sc sd)\n    (coeq_hom _ _ \u226b second_to_max\u2083 sb sc sd) (coeq_hom _ _ \u226b third_to_max\u2083 sb sc sd),\n  use sf,\n  use first_to_max\u2083 k\u2081 l k\u2082 \u226b coeq_hom _ _ \u226b first_to_max\u2083 sb sc sd \u226b coeq\u2083_hom _ _ _,\n  use second_to_max\u2083 k\u2081 l k\u2082 \u226b coeq_hom _ _ \u226b second_to_max\u2083 sb sc sd \u226b coeq\u2083_hom _ _ _,\n  use third_to_max\u2083 k\u2081 l k\u2082 \u226b coeq_hom _ _ \u226b third_to_max\u2083 sb sc sd \u226b coeq\u2083_hom _ _ _,\n  fsplit,\n  slice_lhs 1 3 { rw [\u2190 category.assoc, coeq_condition] },\n  slice_lhs 3 6 { rw [\u2190 category.assoc, coeq\u2083_condition\u2081] },\n  simp only [category.assoc],\n  fsplit,\n  slice_lhs 3 6 { rw [\u2190 category.assoc, coeq\u2083_condition\u2081] },\n  slice_lhs 1 3 { rw [\u2190 category.assoc, coeq_condition] },\n  slice_rhs 3 6 { rw [\u2190 category.assoc, \u2190 coeq\u2083_condition\u2082] },\n  simp only [category.assoc],\n  slice_rhs 3 6 { rw [\u2190 category.assoc, coeq\u2083_condition\u2082] },\n  slice_rhs 1 3 { rw [\u2190 category.assoc, \u2190 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 : \u2200 (X Y : C), \u2203 W (f : W \u27f6 X) (g : W \u27f6 Y), true)\n(cocone_maps : \u2200 \u2983X Y : C\u2984 (f g : X \u27f6 Y), \u2203 W (h : W \u27f6 X), h \u226b f = h \u226b 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  (\u03b1 : Type u) [semilattice_inf \u03b1] : is_cofiltered_or_empty \u03b1 :=\n{ cocone_objs := \u03bb X Y, \u27e8X \u2293 Y, hom_of_le inf_le_left, hom_of_le inf_le_right, trivial\u27e9,\n  cocone_maps := \u03bb X Y f g, \u27e8X, \ud835\udfd9 _, (by ext)\u27e9, }\n\n@[priority 100]\ninstance is_cofiltered_of_semilattice_inf_nonempty\n  (\u03b1 : Type u) [semilattice_inf \u03b1] [nonempty \u03b1] : is_cofiltered \u03b1 := {}\n\n@[priority 100]\ninstance is_cofiltered_or_empty_of_directed_ge (\u03b1 : Type u) [preorder \u03b1]\n  [is_directed \u03b1 (\u2265)] :\n  is_cofiltered_or_empty \u03b1 :=\n{ cocone_objs := \u03bb X Y, let \u27e8Z, hX, hY\u27e9 := exists_le_le X Y in\n    \u27e8Z, hom_of_le hX, hom_of_le hY, trivial\u27e9,\n  cocone_maps := \u03bb X Y f g, \u27e8X, \ud835\udfd9 _, by simp\u27e9 }\n\n@[priority 100]\ninstance is_cofiltered_of_directed_ge_nonempty  (\u03b1 : Type u) [preorder \u03b1] [is_directed \u03b1 (\u2265)]\n  [nonempty \u03b1] :\n  is_cofiltered \u03b1 := {}\n\n-- Sanity checks\nexample (\u03b1 : Type u) [semilattice_inf \u03b1] [order_bot \u03b1] : is_cofiltered \u03b1 := by apply_instance\nexample (\u03b1 : Type u) [semilattice_inf \u03b1] [order_top \u03b1] : is_cofiltered \u03b1 := 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' \u27f6 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' \u27f6 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 \u27f6 j'`, is an arbitrary choice of object\nwhich admits a morphism `eq_hom f f' : eq f f' \u27f6 j` such that\n`eq_condition : eq_hom f f' \u226b f = eq_hom f f' \u226b f'`.\nIts existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def eq {j j' : C} (f f' : j \u27f6 j') : C :=\n(is_cofiltered_or_empty.cocone_maps f f').some\n\n/--\n`eq_hom f f'`, for morphisms `f f' : j \u27f6 j'`, is an arbitrary choice of morphism\n`eq_hom f f' : eq f f' \u27f6 j` such that\n`eq_condition : eq_hom f f' \u226b f = eq_hom f f' \u226b f'`.\nIts existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def eq_hom {j j' : C} (f f' : j \u27f6 j') : eq f f' \u27f6 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 \u27f6 j'`, is the proof that\n`eq_hom f f' \u226b f = eq_hom f f' \u226b f'`.\n-/\n@[simp, reassoc]\nlemma eq_condition {j j' : C} (f f' : j \u27f6 j') : eq_hom f f' \u226b f = eq_hom f f' \u226b 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) : \u2203 (S : C), \u2200 {X}, X \u2208 O \u2192 _root_.nonempty (S \u27f6 X) :=\nbegin\n  classical,\n  apply finset.induction_on O,\n  { exact \u27e8is_cofiltered.nonempty.some, (by rintros - \u27e8\u27e9)\u27e9, },\n  { rintros X O' nm \u27e8S', w'\u27e9,\n    use min X S',\n    rintros Y mY,\n    obtain rfl|h := eq_or_ne Y X,\n    { exact \u27e8min_to_left _ _\u27e9, },\n    { exact \u27e8min_to_right _ _ \u226b (w' (finset.mem_of_mem_insert_of_ne mY h)).some\u27e9, }, }\nend\n\nvariables (O : finset C) (H : finset (\u03a3' (X Y : C) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 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 \u27f6 X` from each `X`,\nsuch that the triangles commute: `T X \u226b f = T Y`, for `f : X \u27f6 Y` in the `finset`.\n-/\nlemma inf_exists :\n  \u2203 (S : C) (T : \u03a0 {X : C}, X \u2208 O \u2192 (S \u27f6 X)), \u2200 {X Y : C} (mX : X \u2208 O) (mY : Y \u2208 O) {f : X \u27f6 Y},\n    (\u27e8X, Y, mX, mY, f\u27e9 : (\u03a3' (X Y : C) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y)) \u2208 H \u2192 T mX \u226b f = T mY :=\nbegin\n  classical,\n  apply finset.induction_on H,\n  { obtain \u27e8S, f\u27e9 := inf_objs_exists O,\n    refine \u27e8S, \u03bb X mX, (f mX).some, _\u27e9,\n    rintros - - - - - \u27e8\u27e9, },\n  { rintros \u27e8X, Y, mX, mY, f\u27e9 H' nmf \u27e8S', T', w'\u27e9,\n    refine \u27e8eq (T' mX \u226b f) (T' mY), \u03bb Z mZ, eq_hom (T' mX \u226b f) (T' mY) \u226b T' mZ, _\u27e9,\n    intros X' Y' mX' mY' f' mf',\n    rw [category.assoc],\n    by_cases h : X = X' \u2227 Y = Y',\n    { rcases h with \u27e8rfl, rfl\u27e9,\n      by_cases hf : f = f',\n      { subst hf,\n        apply eq_condition, },\n      { rw @w' _ _ mX mY f' (by simpa [hf \u2218 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 \u27e8rfl, h\u27e9 := h,\n      rw [heq_iff_eq, psigma.mk.inj_iff] at h,\n      exact \u27e8rfl, h.1.symm\u27e9 }, },\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 \u2208 O) :\n  inf O H \u27f6 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 \u2208 O) (mY : Y \u2208 O) {f : X \u27f6 Y}\n  (mf : (\u27e8X, Y, mX, mY, f\u27e9 : \u03a3' (X Y : C) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y) \u2208 H) :\n  inf_to O H mX \u226b 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 \u2964 C` with `fin_category J`,\nthere exists a cone over `F`.\n-/\nlemma cone_nonempty (F : J \u2964 C) : _root_.nonempty (cone F) :=\nbegin\n  classical,\n  let O := (finset.univ.image F.obj),\n  let H : finset (\u03a3' (X Y : C) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y) :=\n    finset.univ.bUnion (\u03bb X : J, finset.univ.bUnion (\u03bb Y : J, finset.univ.image (\u03bb f : X \u27f6 Y,\n      \u27e8F.obj X, F.obj Y, by simp, by simp, F.map f\u27e9))),\n  obtain \u27e8Z, f, w\u27e9 := inf_exists O H,\n  refine \u27e8\u27e8Z, \u27e8\u03bb X, f (by simp), _\u27e9\u27e9\u27e9,\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 \u27e8j, rfl, j', g, (by simp)\u27e9,\nend\n\n/--\nAn arbitrary choice of cone over `F : J \u2964 C`, for `fin_category J` and `is_cofiltered C`.\n-/\nnoncomputable def cone (F : J \u2964 C) : cone F :=\n(cone_nonempty F).some\n\nvariables {D : Type u\u2081} [category.{v\u2081} D]\n\n/--\nIf `C` is cofiltered, and we have a functor `L : C \u2964 D` with a right adjoint,\nthen `D` is cofiltered.\n-/\nlemma of_left_adjoint {L : C \u2964 D} {R : D \u2964 C} (h : L \u22a3 R) : is_cofiltered D :=\n{ cocone_objs := \u03bb X Y,\n    \u27e8L.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 _ _), \u27e8\u27e9\u27e9,\n  cocone_maps := \u03bb X Y f g,\n    \u27e8L.obj (eq (R.map f) (R.map g)), (h.hom_equiv _ _).symm (eq_hom _ _),\n     by rw [\u2190 h.hom_equiv_naturality_right_symm, \u2190 h.hom_equiv_naturality_right_symm,\n       eq_condition]\u27e9,\n  nonempty := is_cofiltered.nonempty.map L.obj }\n\n/-- If `C` is cofiltered, and we have a left adjoint functor `L : C \u2964 D`, then `D` is cofiltered. -/\n\n\n/-- Being cofiltered is preserved by equivalence of categories. -/\nlemma of_equivalence (h : C \u224c 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\u1d52\u1d56 :=\n{ cocone_objs := \u03bb X Y, \u27e8op (is_filtered.max X.unop Y.unop),\n    (is_filtered.left_to_max _ _).op, (is_filtered.right_to_max _ _).op, trivial\u27e9,\n  cocone_maps := \u03bb X Y f g, \u27e8op (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        \u2190 op_comp, \u2190 op_comp],\n      congr' 1,\n      exact is_filtered.coeq_condition f.unop g.unop,\n    end\u27e9,\n  nonempty := \u27e8op is_filtered.nonempty.some\u27e9 }\n\ninstance is_filtered_op_of_is_cofiltered [is_cofiltered C] : is_filtered C\u1d52\u1d56 :=\n{ cocone_objs := \u03bb X Y, \u27e8op (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\u27e9,\n  cocone_maps := \u03bb X Y f g, \u27e8op (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        \u2190 op_comp, \u2190 op_comp],\n      congr' 1,\n      exact is_cofiltered.eq_condition f.unop g.unop,\n    end\u27e9,\n  nonempty := \u27e8op is_cofiltered.nonempty.some\u27e9 }\n\nend opposite\n\nsection ulift\n\ninstance [is_filtered C] : is_filtered (ulift.{u\u2082} C) :=\nis_filtered.of_equivalence ulift.equivalence\n\ninstance [is_cofiltered C] : is_cofiltered (ulift.{u\u2082} 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 \u2260 b' and 'a \u2264 b' --\n-------------------------------------------\n-------------------------------------------\n-- This is achieved by the following sequence of tactics:\n-- * make_ineq  take \"a \u2264 b\" and \"a' \u2260 b'\" and try to make \"a < b\"\n-- * extract_gt extract the list of inequalities \"a \u2264 b\" from a list of expressions\n-- * extract_non_eq does the same for \"a \u2260 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 {\u03b1: Type} [linear_order \u03b1] (a b : \u03b1) : \u00ac a = b \u2194 (a < b \u2228 b < a) :=\nbegin\n    todo\nend\n\n/- Unused? -/\nlemma definition.useful_abs {\u03b1: Type} [decidable_linear_ordered_add_comm_group \u03b1] (a: \u03b1) :\nabs a = if a \u2265 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  {\u03b1 : Type} [has_to_tactic_format \u03b1] (a : \u03b1) : 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 \u2192 bool\n| (const a a_1) := (a = cst_name)\n| (app a a_1) := (contain_cst a) \u2228 (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) \u00d7 expr \u2192 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 \u2190 tactic.target, e \u2190 infer_type target,\n    b \u2190 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 \u2190 tactic.target, e \u2190 infer_type target,\n    b \u2190 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 \u2190 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    | `(\u00ac(%%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) \u2192 string\n-- (l: list string) : string :=\n-- list.foldl (\u03bb (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 \u2190 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 \u2192 tactic string \u2192 tactic string\n| 0       my_tactic := return \"\"\n| (n + 1) my_tactic := do -- trace \"(iterating tactic...)\",\n    first_code \u2190 my_tactic, l \u2190 num_goals,\n    match first_code, l with\n    | \"\", _  := return \"\"\n    | s, 0   := return s\n    | _ , _  := do\n        remaining_code \u2190 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) \u2192 tactic string \n| []                  := return \"\"\n| (first_tac :: tail) :=  do\n    first_code \u2190 first_tac, l \u2190 num_goals,\n    match first_code, l with\n    | s, 0   := return s\n    | _ , _  := do\n        remaining_code \u2190 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) \u2192 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 \u2190 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 \u2190 my_tactic, \n    tactic.trace $ \"EFFECTIVE CODE LEAN n\u00b0\" ++ 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 {\u03b1 : Type} [linear_ordered_field \u03b1] (a:\u03b1) :\n0 < a \u2192 0 < a\u207b\u00b9 := 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 \u2190 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 \u2190 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\u2260b` into `a<b or b<a`, then split cases. -/\nmeta def develop_neq : tactic string :=\n    -- do ineq \u2190 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 \u00d7 bool) \u2192 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 \u00d7 string) \u2192 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 \u00d7 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 \u2264 n_0 \u2228 n_0 \u2264 n_1\"\n    -- with norm_num, solves \"n_0 \u2264 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 \u2190 target_lt_or_gt, t_abs \u2190 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 \u03b1) (f : \u03b1 \u2192 \u03b2) (a : \u03b1)` is `f a` if `a \u2208 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 `\u03bbx, 1`.\n\n## Tags\nindicator, characteristic\n-/\n\nnamespace set\n\n\n/-- `indicator s f a` is `f a` if `a \u2208 s`, `0` otherwise.  -/\ndef indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b2 :=\n  fun (x : \u03b1) => ite (x \u2208 s) (f x) 0\n\n@[simp] theorem piecewise_eq_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} : piecewise s f 0 = indicator s f :=\n  rfl\n\ntheorem indicator_apply {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : indicator s f a = ite (a \u2208 s) (f a) 0 :=\n  rfl\n\n@[simp] theorem indicator_of_mem {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {a : \u03b1} (h : a \u2208 s) (f : \u03b1 \u2192 \u03b2) : indicator s f a = f a :=\n  if_pos h\n\n@[simp] theorem indicator_of_not_mem {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {a : \u03b1} (h : \u00aca \u2208 s) (f : \u03b1 \u2192 \u03b2) : indicator s f a = 0 :=\n  if_neg h\n\ntheorem indicator_eq_zero_or_self {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : indicator s f a = 0 \u2228 indicator s f a = f a :=\n  dite (a \u2208 s) (fun (h : a \u2208 s) => Or.inr (indicator_of_mem h f)) fun (h : \u00aca \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {a : \u03b1} (h : indicator s f a \u2260 0) : a \u2208 s :=\n  iff.mp not_imp_comm (fun (hn : \u00aca \u2208 s) => indicator_of_not_mem hn f) h\n\ntheorem eq_on_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} : eq_on (indicator s f) f s :=\n  fun (x : \u03b1) (hx : x \u2208 s) => indicator_of_mem hx f\n\ntheorem support_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} : function.support (indicator s f) \u2286 s :=\n  fun (x : \u03b1) (hx : x \u2208 function.support (indicator s f)) =>\n    not.imp_symm (fun (h : \u00acx \u2208 s) => indicator_of_not_mem h f) hx\n\n@[simp] theorem indicator_apply_eq_self {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {a : \u03b1} : indicator s f a = f a \u2194 \u00aca \u2208 s \u2192 f a = 0 :=\n  iff.trans ite_eq_left_iff\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u00aca \u2208 s \u2192 0 = f a \u2194 \u00aca \u2208 s \u2192 f a = 0)) (propext eq_comm)))\n      (iff.refl (\u00aca \u2208 s \u2192 0 = f a)))\n\n@[simp] theorem indicator_eq_self {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} : indicator s f = f \u2194 function.support f \u2286 s := sorry\n\n@[simp] theorem indicator_support {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {f : \u03b1 \u2192 \u03b2} : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {a : \u03b1} : indicator s f a = 0 \u2194 a \u2208 s \u2192 f a = 0 :=\n  ite_eq_right_iff\n\n@[simp] theorem indicator_eq_zero {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} : (indicator s f = fun (x : \u03b1) => 0) \u2194 disjoint (function.support f) s := sorry\n\n@[simp] theorem indicator_eq_zero' {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} : indicator s f = 0 \u2194 disjoint (function.support f) s :=\n  indicator_eq_zero\n\n@[simp] theorem indicator_range_comp {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {\u03b9 : Sort u_2} (f : \u03b9 \u2192 \u03b1) (g : \u03b1 \u2192 \u03b2) : indicator (range f) g \u2218 f = g \u2218 f :=\n  piecewise_range_comp f (fun (x : \u03b1) => g x) fun (x : \u03b1) => 0\n\ntheorem indicator_congr {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (h : \u2200 (a : \u03b1), a \u2208 s \u2192 f a = g a) : indicator s f = indicator s g := sorry\n\n@[simp] theorem indicator_univ {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] (f : \u03b1 \u2192 \u03b2) : indicator univ f = f :=\n  iff.mpr indicator_eq_self (subset_univ (function.support f))\n\n@[simp] theorem indicator_empty {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] (f : \u03b1 \u2192 \u03b2) : indicator \u2205 f = fun (a : \u03b1) => 0 :=\n  iff.mpr indicator_eq_zero (disjoint_empty (function.support f))\n\n@[simp] theorem indicator_zero {\u03b1 : Type u_1} (\u03b2 : Type u_3) [HasZero \u03b2] (s : set \u03b1) : (indicator s fun (x : \u03b1) => 0) = fun (x : \u03b1) => 0 := sorry\n\n@[simp] theorem indicator_zero' {\u03b1 : Type u_1} (\u03b2 : Type u_3) [HasZero \u03b2] {s : set \u03b1} : indicator s 0 = 0 :=\n  indicator_zero \u03b2 s\n\ntheorem indicator_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] (s : set \u03b1) (t : set \u03b1) (f : \u03b1 \u2192 \u03b2) : indicator s (indicator t f) = indicator (s \u2229 t) f := sorry\n\ntheorem comp_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} {\u03b3 : Type u_4} [HasZero \u03b2] (h : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) {s : set \u03b1} {x : \u03b1} : h (indicator s f x) = piecewise s (h \u2218 f) (function.const \u03b1 (h 0)) x :=\n  comp_piecewise s h\n\ntheorem indicator_comp_right {\u03b1 : Type u_1} {\u03b2 : Type u_3} {\u03b3 : Type u_4} [HasZero \u03b2] {s : set \u03b1} (f : \u03b3 \u2192 \u03b1) {g : \u03b1 \u2192 \u03b2} {x : \u03b3} : indicator (f \u207b\u00b9' s) (g \u2218 f) x = indicator s g (f x) := sorry\n\ntheorem indicator_comp_of_zero {\u03b1 : Type u_1} {\u03b2 : Type u_3} {\u03b3 : Type u_4} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} [HasZero \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : g 0 = 0) : indicator s (g \u2218 f) = g \u2218 indicator s f := sorry\n\ntheorem indicator_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (B : set \u03b2) : indicator s f \u207b\u00b9' B = s \u2229 f \u207b\u00b9' B \u222a s\u1d9c \u2229 (fun (a : \u03b1) => 0) \u207b\u00b9' B :=\n  piecewise_preimage s f 0 B\n\ntheorem indicator_preimage_of_not_mem {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) {t : set \u03b2} (ht : \u00ac0 \u2208 t) : indicator s f \u207b\u00b9' t = s \u2229 f \u207b\u00b9' t := sorry\n\ntheorem mem_range_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {r : \u03b2} {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} : r \u2208 range (indicator s f) \u2194 r = 0 \u2227 s \u2260 univ \u2228 r \u2208 f '' s := sorry\n\ntheorem indicator_rel_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {a : \u03b1} {r : \u03b2 \u2192 \u03b2 \u2192 Prop} (h0 : r 0 0) (ha : a \u2208 s \u2192 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\u2022 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 {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] {\u03b3 : Type u_2} [add_comm_monoid \u03b3] (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b3) {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : s\u2081 \u2286 s\u2082) (hg : \u2200 (a : \u03b1), g a 0 = 0) : (finset.sum s\u2081 fun (i : \u03b1) => g i (f i)) = finset.sum s\u2082 fun (i : \u03b1) => g i (indicator (\u2191s\u2081) 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 {\u03b1 : Type u_1} {\u03b3 : Type u_2} [add_comm_monoid \u03b3] (f : \u03b1 \u2192 \u03b3) {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : s\u2081 \u2286 s\u2082) : (finset.sum s\u2081 fun (i : \u03b1) => f i) = finset.sum s\u2082 fun (i : \u03b1) => indicator (\u2191s\u2081) f i :=\n  sum_indicator_subset_of_eq_zero (fun (i : \u03b1) => f i) (fun (a : \u03b1) (b : \u03b3) => b) h fun (_x : \u03b1) => rfl\n\ntheorem indicator_union_of_not_mem_inter {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] {s : set \u03b1} {t : set \u03b1} {a : \u03b1} (h : \u00aca \u2208 s \u2229 t) (f : \u03b1 \u2192 \u03b2) : indicator (s \u222a t) f a = indicator s f a + indicator t f a := sorry\n\ntheorem indicator_union_of_disjoint {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] {s : set \u03b1} {t : set \u03b1} (h : disjoint s t) (f : \u03b1 \u2192 \u03b2) : indicator (s \u222a t) f = fun (a : \u03b1) => indicator s f a + indicator t f a := sorry\n\ntheorem indicator_add {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2) : (indicator s fun (a : \u03b1) => f a + g a) = fun (a : \u03b1) => indicator s f a + indicator s g a := sorry\n\n@[simp] theorem indicator_compl_add_self_apply {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : indicator (s\u1d9c) f a + indicator s f a = f a := sorry\n\n@[simp] theorem indicator_compl_add_self {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) : indicator (s\u1d9c) f + indicator s f = f :=\n  funext (indicator_compl_add_self_apply s f)\n\n@[simp] theorem indicator_self_add_compl_apply {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : indicator s f a + indicator (s\u1d9c) f a = f a := sorry\n\n@[simp] theorem indicator_self_add_compl {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) : indicator s f + indicator (s\u1d9c) f = f :=\n  funext (indicator_self_add_compl_apply s f)\n\nprotected instance is_add_monoid_hom.indicator {\u03b1 : Type u_1} (\u03b2 : Type u_3) [add_monoid \u03b2] (s : set \u03b1) : is_add_monoid_hom fun (f : \u03b1 \u2192 \u03b2) => indicator s f :=\n  is_add_monoid_hom.mk (indicator_zero \u03b2 s)\n\ntheorem indicator_smul {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] {\ud835\udd5c : Type u_5} [monoid \ud835\udd5c] [distrib_mul_action \ud835\udd5c \u03b2] (s : set \u03b1) (r : \ud835\udd5c) (f : \u03b1 \u2192 \u03b2) : (indicator s fun (x : \u03b1) => r \u2022 f x) = fun (x : \u03b1) => r \u2022 indicator s f x := sorry\n\ntheorem indicator_add_eq_left {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (h : univ \u2286 f \u207b\u00b9' singleton 0 \u222a g \u207b\u00b9' singleton 0) : indicator (f \u207b\u00b9' singleton 0\u1d9c) (f + g) = f := sorry\n\ntheorem indicator_add_eq_right {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_monoid \u03b2] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (h : univ \u2286 f \u207b\u00b9' singleton 0 \u222a g \u207b\u00b9' singleton 0) : indicator (g \u207b\u00b9' singleton 0\u1d9c) (f + g) = g := sorry\n\nprotected instance is_add_group_hom.indicator {\u03b1 : Type u_1} (\u03b2 : Type u_3) [add_group \u03b2] (s : set \u03b1) : is_add_group_hom fun (f : \u03b1 \u2192 \u03b2) => indicator s f :=\n  is_add_group_hom.mk\n\ntheorem indicator_neg {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_group \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) : (indicator s fun (a : \u03b1) => -f a) = fun (a : \u03b1) => -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 {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_group \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2) : (indicator s fun (a : \u03b1) => f a - g a) = fun (a : \u03b1) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_3} [add_group \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) : indicator (s\u1d9c) f = f - indicator s f :=\n  eq_sub_of_add_eq (indicator_compl_add_self s f)\n\ntheorem indicator_finset_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b2] {\u03b9 : Type u_3} (I : finset \u03b9) (s : set \u03b1) (f : \u03b9 \u2192 \u03b1 \u2192 \u03b2) : indicator s (finset.sum I fun (i : \u03b9) => f i) = finset.sum I fun (i : \u03b9) => indicator s (f i) := sorry\n\ntheorem indicator_finset_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [add_comm_monoid \u03b2] {\u03b9 : Type u_3} (I : finset \u03b9) (s : \u03b9 \u2192 set \u03b1) {f : \u03b1 \u2192 \u03b2} : (\u2200 (i : \u03b9), i \u2208 I \u2192 \u2200 (j : \u03b9), j \u2208 I \u2192 i \u2260 j \u2192 s i \u2229 s j = \u2205) \u2192\n  indicator (Union fun (i : \u03b9) => Union fun (H : i \u2208 I) => s i) f =\n    fun (a : \u03b1) => finset.sum I fun (i : \u03b9) => indicator (s i) f a := sorry\n\ntheorem indicator_mul {\u03b1 : Type u_1} {\u03b2 : Type u_3} [mul_zero_class \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2) : (indicator s fun (a : \u03b1) => f a * g a) = fun (a : \u03b1) => indicator s f a * indicator s g a := sorry\n\ntheorem indicator_mul_left {\u03b1 : Type u_1} {\u03b2 : Type u_3} [mul_zero_class \u03b2] {a : \u03b1} (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2) : indicator s (fun (a : \u03b1) => f a * g a) a = indicator s f a * g a := sorry\n\ntheorem indicator_mul_right {\u03b1 : Type u_1} {\u03b2 : Type u_3} [mul_zero_class \u03b2] {a : \u03b1} (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2) : indicator s (fun (a : \u03b1) => f a * g a) a = f a * indicator s g a := sorry\n\ntheorem indicator_prod_one {\u03b1 : Type u_1} {\u03b1' : Type u_2} {\u03b2 : Type u_3} [monoid_with_zero \u03b2] {s : set \u03b1} {t : set \u03b1'} {x : \u03b1} {y : \u03b1'} : indicator (set.prod s t) 1 (x, y) = indicator s 1 x * indicator t 1 y := sorry\n\ntheorem indicator_nonneg' {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] [preorder \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {a : \u03b1} (h : a \u2208 s \u2192 0 \u2264 f a) : 0 \u2264 indicator s f a := sorry\n\ntheorem indicator_nonneg {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] [preorder \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} (h : \u2200 (a : \u03b1), a \u2208 s \u2192 0 \u2264 f a) (a : \u03b1) : 0 \u2264 indicator s f a :=\n  indicator_nonneg' (h a)\n\ntheorem indicator_nonpos' {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] [preorder \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {a : \u03b1} (h : a \u2208 s \u2192 f a \u2264 0) : indicator s f a \u2264 0 := sorry\n\ntheorem indicator_nonpos {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] [preorder \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} (h : \u2200 (a : \u03b1), a \u2208 s \u2192 f a \u2264 0) (a : \u03b1) : indicator s f a \u2264 0 :=\n  indicator_nonpos' (h a)\n\ntheorem indicator_le' {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] [preorder \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (hfg : \u2200 (a : \u03b1), a \u2208 s \u2192 f a \u2264 g a) (hg : \u2200 (a : \u03b1), \u00aca \u2208 s \u2192 0 \u2264 g a) : indicator s f \u2264 g := sorry\n\ntheorem indicator_le_indicator {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] [preorder \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {a : \u03b1} (h : f a \u2264 g a) : indicator s f a \u2264 indicator s g a :=\n  indicator_rel_indicator (le_refl 0) fun (_x : a \u2208 s) => h\n\ntheorem indicator_le_indicator_of_subset {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] [preorder \u03b2] {s : set \u03b1} {t : set \u03b1} {f : \u03b1 \u2192 \u03b2} (h : s \u2286 t) (hf : \u2200 (a : \u03b1), 0 \u2264 f a) (a : \u03b1) : indicator s f a \u2264 indicator t f a := sorry\n\ntheorem indicator_le_self' {\u03b1 : Type u_1} {\u03b2 : Type u_3} [HasZero \u03b2] [preorder \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} (hf : \u2200 (x : \u03b1), \u00acx \u2208 s \u2192 0 \u2264 f x) : indicator s f \u2264 f :=\n  indicator_le' (fun (_x : \u03b1) (_x_1 : _x \u2208 s) => le_refl (f _x)) hf\n\ntheorem indicator_le_self {\u03b1 : Type u_1} {\u03b2 : Type u_2} [canonically_ordered_add_monoid \u03b2] (s : set \u03b1) (f : \u03b1 \u2192 \u03b2) : indicator s f \u2264 f :=\n  indicator_le_self' fun (_x : \u03b1) (_x_1 : \u00ac_x \u2208 s) => zero_le (f _x)\n\ntheorem indicator_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} [canonically_ordered_add_monoid \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (hfg : \u2200 (a : \u03b1), a \u2208 s \u2192 f a \u2264 g a) : indicator s f \u2264 g :=\n  indicator_le' hfg fun (_x : \u03b1) (_x_1 : \u00ac_x \u2208 s) => zero_le (g _x)\n\ntheorem indicator_Union_apply {\u03b1 : Type u_1} {\u03b9 : Sort u_2} {\u03b2 : Type u_3} [complete_lattice \u03b2] [HasZero \u03b2] (h0 : \u22a5 = 0) (s : \u03b9 \u2192 set \u03b1) (f : \u03b1 \u2192 \u03b2) (x : \u03b1) : indicator (Union fun (i : \u03b9) => s i) f x = supr fun (i : \u03b9) => indicator (s i) f x := sorry\n\nend set\n\n\ntheorem add_monoid_hom.map_indicator {\u03b1 : Type u_1} {M : Type u_2} {N : Type u_3} [add_monoid M] [add_monoid N] (f : M \u2192+ N) (s : set \u03b1) (g : \u03b1 \u2192 M) (x : \u03b1) : coe_fn f (set.indicator s g x) = set.indicator s (\u21d1f \u2218 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 (\u03b1 : Type) where\n  V: List \u03b1\n  E: List (\u03b1 \u00d7 \u03b1)\n  deriving Repr\n\nnamespace Graph\ndef from_edges {\u03b1 : Type} [BEq \u03b1] (e : List (\u03b1 \u00d7 \u03b1)) : Graph \u03b1 :=\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 \u03b1] (g : Graph \u03b1) : \u03b1 \u2192 Bool := g.V.elem\ndef contains_edge_directed [BEq \u03b1] (g : Graph \u03b1) : (\u03b1 \u00d7 \u03b1) \u2192 Bool := g.E.elem\ndef contains_edge [BEq \u03b1] (g : Graph \u03b1) (a b : \u03b1) : Bool :=\n  (g.contains_edge_directed (a, b)) \u2228 (g.contains_edge_directed (b, a))\n\ndef add_vert [BEq \u03b1] (g : Graph \u03b1) (v : \u03b1) : Graph \u03b1 :=\n  match (g.V.elem v) with\n  | true => g\n  | false => Graph.mk (v::g.V) g.E\n\ndef add_edge [BEq \u03b1] (g : Graph \u03b1) (a b : \u03b1) : Graph \u03b1 :=\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 \u00d7 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 \u00d7 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 \u2227 (stack acc acc' iolen).O.length = acc'.O.length := by\n  rewrite [stack]\n  simp\n\ndef acc_brick : Brick \u2192 Acc \u2192 Acc\n  | Vert,  \u27e8n, i, o, e\u27e9 => \u27e8n+2, n::i,        (n+1)::o,        \u27e8n, n+1\u27e9::e\u27e9\n  | Cap,   \u27e8n, i, o, e\u27e9 => \u27e8n+2, i,           (n+1)::n::o,     \u27e8n, n+1\u27e9::e\u27e9\n  | Cup,   \u27e8n, i, o, e\u27e9 => \u27e8n+2, (n+1)::n::i, o,               \u27e8n, n+1\u27e9::e\u27e9\n  | Over,  \u27e8n, i, o, e\u27e9 => \u27e8n+4, (n+1)::n::i, (n+3)::(n+2)::o, \u27e8n, n+3\u27e9::\u27e8n+1, n+2\u27e9::e\u27e9\n  | Under, \u27e8n, i, o, e\u27e9 => \u27e8n+4, (n+1)::n::i, (n+3)::(n+2)::o, \u27e8n, n+3\u27e9::\u27e8n+1, n+2\u27e9::e\u27e9\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    \u2227 ((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    \u2227 ((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 [\u2190Bricks.domain, \u2190Bricks.codomain]\n    apply And.intro\n    case left =>\n      rewrite [Nat.add_comm hd.domain _, \u2190Nat.add_assoc]\n      rewrite [acc_brick_io.left, hind.left]\n      rfl\n    case right =>\n      rewrite [Nat.add_comm hd.codomain _, \u2190Nat.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 [\u2190ht.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) \u2192 (acc: Acc) \u2192 (domeq: t.domain = acc.O.length) \u2192 Acc\n  | \u27e8[], _\u27e9, acc, _ => acc\n  | \u27e8bs::w, prop\u27e9, acc, domeq => acc_tangle_aux bs w prop acc domeq\n\n\ndef subgraphsAux {\u03b1 : Type} [BEq \u03b1] (gs : List (Graph \u03b1)) : List (\u03b1 \u00d7 \u03b1) \u2192 List (Graph \u03b1)\n  | [] => gs\n  | (a, b)::e =>\n      let vnew := match gs.partition (fun vs => (vs.contains_vert a) \u2228 (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 {\u03b1 : Type} [BEq \u03b1] (g : Graph \u03b1) : List (Graph \u03b1) :=\n  subgraphsAux (g.V.map (fun v => Graph.mk [v] [])) g.E\n\ntheorem ind_subgraph_idempotent [BEq \u03b1] {g : Graph \u03b1} :\n  (hlen : 0 < (subgraphs g).length)\n  \u2192 subgraphs ((subgraphs g)[0]) = [(subgraphs g)[0]] := sorry\n\nnamespace Example\ndef g : Graph Nat := Graph.from_edges [\u27e80, 1\u27e9]\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 := \u27e80, [], List.iota t.domain, []\u27e9\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  \u27e8unknot, by simp [isTangle]\u27e9\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  \u27e8trefoil, by simp [isTangle]\u27e9\n\n#eval List.iota ltrefoil.domain\n#eval Graph.acc_tangle ltrefoil \u27e80, [], List.iota ltrefoil.domain, []\u27e9 (Eq.symm List.iota_length_eq_n)\n#eval Graph.subgraphs (Graph.from_edges [\u27e80,1\u27e9, \u27e81,2\u27e9, \u27e82,0\u27e9])\n#eval Graph.subgraphs (Graph.from_edges (Graph.acc_tangle ltrefoil \u27e80, [], List.iota ltrefoil.domain, []\u27e9 (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  \u27e8hopf_link, by simp [isTangle]\u27e9\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 \u03b1` as a structure containing a term `a : \u03b1` for any type `\u03b1`,\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 \u27f6 Y` in `discrete \u03b1` as `X = Y`,\none might define it as `plift (X = Y)`.\nIn fact, to allow `discrete \u03b1` to be a `small_category`\n(i.e. with morphisms in the same universe as the objects),\nwe actually define the hom type `X \u27f6 Y` as `ulift (plift (X = Y))`.\n\n`discrete.functor` promotes a function `f : I \u2192 C` (for any category `C`) to a functor\n`discrete.functor f : discrete I \u2964 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\u2081 v\u2082 v\u2083 u\u2081 u\u2081' u\u2082 u\u2083\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 \u03b1` and `\u03b1`. Otherwise there is too much API leakage.\n@[ext] structure discrete (\u03b1 : Type u\u2081) :=\n(as : \u03b1)\n\n@[simp] lemma discrete.mk_as {\u03b1 : Type u\u2081} (X : discrete \u03b1) : discrete.mk X.as = X :=\nby { ext, refl, }\n\n/-- `discrete \u03b1` is equivalent to the original type `\u03b1`.-/\n@[simps] def discrete_equiv {\u03b1 : Type u\u2081} : discrete \u03b1 \u2243 \u03b1 :=\n{ to_fun := discrete.as,\n  inv_fun := discrete.mk,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\ninstance {\u03b1 : Type u\u2081} [decidable_eq \u03b1] : decidable_eq (discrete \u03b1) :=\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 \u27f6 Y` as `ulift (plift (X = Y))`.\n\nSee <https://stacks.math.columbia.edu/tag/001A>\n-/\ninstance discrete_category (\u03b1 : Type u\u2081) : small_category (discrete \u03b1) :=\n{ hom  := \u03bb X Y, ulift (plift (X.as = Y.as)),\n  id   := \u03bb X, ulift.up (plift.up rfl),\n  comp := \u03bb X Y Z g f, by { cases X, cases Y, cases Z, rcases f with \u27e8\u27e8\u27e8\u27e9\u27e9\u27e9, exact g } }\n\nnamespace discrete\n\nvariables {\u03b1 : Type u\u2081}\n\ninstance [inhabited \u03b1] : inhabited (discrete \u03b1) :=\n\u27e8\u27e8default\u27e9\u27e9\n\ninstance [subsingleton \u03b1] : subsingleton (discrete \u03b1) :=\n\u27e8by { intros, ext, apply subsingleton.elim, }\u27e9\n\n/-- A simple tactic to run `cases` on any `discrete \u03b1` hypotheses. -/\nmeta def _root_.tactic.discrete_cases : tactic unit :=\n`[cases_matching* [discrete _, (_ : discrete _) \u27f6 (_ : discrete _), plift _]]\n\nrun_cmd add_interactive [``tactic.discrete_cases]\n\nlocal attribute [tidy] tactic.discrete_cases\n\ninstance [unique \u03b1] : unique (discrete \u03b1) :=\nunique.mk' (discrete \u03b1)\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 \u03b1` to a morphism `X \u27f6 Y`\nin the discrete category. -/\nabbreviation eq_to_hom {X Y : discrete \u03b1} (h : X.as = Y.as) : X \u27f6 Y :=\neq_to_hom (by { ext, exact h, })\n\n/-- Promote an equation between the wrapped terms in `X Y : discrete \u03b1` to an isomorphism `X \u2245 Y`\nin the discrete category. -/\nabbreviation eq_to_iso {X Y : discrete \u03b1} (h : X.as = Y.as) : X \u2245 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 : \u03b1} (h : a = b) : discrete.mk a \u27f6 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 : \u03b1} (h : a = b) : discrete.mk a \u2245 discrete.mk b :=\neq_to_iso h\n\n@[simp] lemma id_def (X : discrete \u03b1) : ulift.up (plift.up (eq.refl X.as)) = \ud835\udfd9 X := rfl\n\nvariables {C : Type u\u2082} [category.{v\u2082} C]\n\ninstance {I : Type u\u2081} {i j : discrete I} (f : i \u27f6 j) : is_iso f :=\n\u27e8\u27e8eq_to_hom (eq_of_hom f).symm, by tidy\u27e9\u27e9\n\n/--\nAny function `I \u2192 C` gives a functor `discrete I \u2964 C`.\n-/\ndef functor {I : Type u\u2081} (F : I \u2192 C) : discrete I \u2964 C :=\n{ obj := F \u2218 discrete.as,\n  map := \u03bb X Y f, by { discrete_cases, cases f, exact \ud835\udfd9 (F X), } }\n\n@[simp] lemma functor_obj  {I : Type u\u2081} (F : I \u2192 C) (i : I) :\n  (discrete.functor F).obj (discrete.mk i) = F i := rfl\n\nlemma functor_map  {I : Type u\u2081} (F : I \u2192 C) {i : discrete I} (f : i \u27f6 i) :\n  (discrete.functor F).map f = \ud835\udfd9 (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\u2081} {J : Type u\u2081'} (f : J \u2192 C) (g : I \u2192 J) :\n  discrete.functor (f \u2218 g) \u2245 discrete.functor (discrete.mk \u2218 g) \u22d9 discrete.functor f :=\nnat_iso.of_components (\u03bb 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\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u27f6 G.obj i) : F \u27f6 G :=\n{ app := f,\n  naturality' := \u03bb 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\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u2245 G.obj i) : F \u2245 G :=\nnat_iso.of_components f (\u03bb X Y g, by { discrete_cases, cases g, simp, })\n\n@[simp]\nlemma nat_iso_app {I : Type u\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u2245 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\u2081} {F : discrete I \u2964 C} :\n  F \u2245 discrete.functor (F.obj \u2218 discrete.mk) :=\nnat_iso $ \u03bb 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\u2081} {D : Type u\u2083} [category.{v\u2083} D]\n (F : I \u2192 C) (G : C \u2964 D) : discrete.functor F \u22d9 G \u2245 discrete.functor (G.obj \u2218 F) :=\nnat_iso $ \u03bb 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\u2081} {J : Type u\u2082} (e : I \u2243 J) : discrete I \u224c discrete J :=\n{ functor := discrete.functor (discrete.mk \u2218 (e : I \u2192 J)),\n  inverse := discrete.functor (discrete.mk \u2218 (e.symm : J \u2192 I)),\n  unit_iso := discrete.nat_iso (\u03bb i, eq_to_iso (by { discrete_cases, simp })),\n  counit_iso := discrete.nat_iso (\u03bb 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 {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (h : discrete \u03b1 \u224c discrete \u03b2) : \u03b1 \u2243 \u03b2 :=\n{ to_fun := discrete.as \u2218 h.functor.obj \u2218 discrete.mk,\n  inv_fun := discrete.as \u2218 h.inverse.obj \u2218 discrete.mk,\n  left_inv := \u03bb a, by simpa using eq_of_hom (h.unit_iso.app (discrete.mk a)).2,\n  right_inv := \u03bb 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\u2081}\n\nopen opposite\n\n/-- A discrete category is equivalent to its opposite category. -/\n@[simps functor_obj_as inverse_obj]\nprotected def opposite (\u03b1 : Type u\u2081) : (discrete \u03b1)\u1d52\u1d56 \u224c discrete \u03b1 :=\nlet F : discrete \u03b1 \u2964 (discrete \u03b1)\u1d52\u1d56 := discrete.functor (\u03bb x, op (discrete.mk x)) in\nbegin\n  refine equivalence.mk (functor.left_op F) F _\n    (discrete.nat_iso $ \u03bb X, by { discrete_cases, simp [F] }),\n  refine nat_iso.of_components (\u03bb X, by { tactic.op_induction', discrete_cases, simp [F], }) _,\n  tidy\nend\n\nvariables {C : Type u\u2082} [category.{v\u2082} C]\n\n@[simp] lemma functor_map_id\n  (F : discrete J \u2964 C) {j : discrete J} (f : j \u27f6 j) : F.map f = \ud835\udfd9 (F.obj j) :=\nbegin\n  have h : f = \ud835\udfd9 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) \u222a S)\n\nlemma adjoin.field_mem (x : F) : algebra_map F E x \u2208 adjoin F S :=\nfield.mem_closure (or.inl (set.mem_range_self x))\n\nlemma adjoin.field_subset : set.range (algebra_map F E) \u2286 adjoin F S :=\nbegin\n    intros x hx,\n    cases hx with f hf,\n    rw \u2190hf,\n    exact adjoin.field_mem F S f,\nend\n\ninstance adjoin.field_coe : has_coe_t F (adjoin F S) :=\n{coe := \u03bb x, \u27e8algebra_map F E x, adjoin.field_mem F S x\u27e9}\n\nlemma adjoin.set_mem (x : S) : \u2191x \u2208 adjoin F S :=\nfield.mem_closure (or.inr (subtype.mem x))\n\nlemma adjoin.set_subset : S \u2286 adjoin F S :=\n\u03bb x hx, adjoin.set_mem F S \u27e8x,hx\u27e9\n\ninstance adjoin.set_coe : has_coe_t S (adjoin F S) :=\n{coe := \u03bb x, \u27e8\u2191x, adjoin.set_mem F S x\u27e9}\n\nlemma adjoin.mono (T : set E) (h : S \u2286 T) : adjoin F S \u2286 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 \u2286 adjoin F S :=\n\u03bb x hx, adjoin.field_mem F S \u27e8x, hx\u27e9\n\nlemma adjoin_contains_subset {T : set E} {H : T \u2286 S} : T \u2286 adjoin F S :=\nbegin\n    intros x hx,\n    exact adjoin.set_mem F S \u27e8x,H hx\u27e9,\nend\n\ninstance adjoin.is_algebra : algebra F (adjoin F S) := {\n    smul := \u03bb x y, \u27e8algebra_map F E x, adjoin.field_mem F S x\u27e9 * y,\n    to_fun := \u03bb x, \u27e8algebra_map F E x, adjoin.field_mem F S x\u27e9,\n    map_one' := by simp only [ring_hom.map_one];refl,\n    map_mul' := \u03bb x y, by simp only [ring_hom.map_mul];refl,\n    map_zero' := by simp only [ring_hom.map_zero];refl,\n    map_add' := \u03bb x y, by simp only [ring_hom.map_add];refl,\n    commutes' := \u03bb x y, by rw mul_comm,\n    smul_def' := \u03bb 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' := \u03bb 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) \u2243\u2097[F] (adjoin_as_submodule F S) := {\n    to_fun := \u03bb x, x,\n    map_add' := \u03bb x y, rfl,\n    map_smul' :=\n    begin\n        intros x y,\n        ext1,\n        change _ = x \u2022 \u2191y,\n        rw algebra.smul_def,\n        rw algebra.smul_def,\n        refl,\n    end,\n    inv_fun := \u03bb x, x,\n    left_inv := \u03bb x, rfl,\n    right_inv := \u03bb x, rfl,\n}\n\nlemma adjoin_subset {T : set E} [is_subfield T] (HF : set.range (algebra_map F E) \u2286 T) (HS : S \u2286 T) : adjoin F S \u2286 T :=\nbegin\n    apply field.closure_subset,\n    rw set.union_subset_iff,\n    exact \u27e8HF,HS\u27e9,\nend\n\n/-- If S \u2286 F[T] then F[S] \u2286 F[T] -/\nlemma adjoin_subset' {T : set E} (HT : S \u2286 adjoin F T) : adjoin F S \u2286 adjoin F T :=\nadjoin_subset F S (adjoin.field_subset F T) HT\n\nlemma set_range_subset {T\u2081 T\u2082 : set E} [is_subfield T\u2081] [is_subfield T\u2082] {hyp : T\u2081 \u2286 T\u2082} :\nset.range (algebra_map T\u2081 E) \u2286 T\u2082 :=\nbegin\n    intros x hx,\n    cases hx with f hf,\n    rw \u2190hf,\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 \u2192 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 \u27e8\u27e8y, \u27e8z, rfl\u27e9\u27e9, rfl\u27e9,\n        exact \u27e8z, rfl\u27e9,\n    },\n    {   exact \u03bb hx, \u27e8\u27e8x, hx\u27e9, rfl\u27e9, },\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 \u2286 F} : T \u2286 adjoin F S :=\n\u03bb x hx, adjoin.field_mem F S \u27e8x,HT hx\u27e9\n\nlemma adjoin_twice (T : set E) : adjoin (adjoin F S) T = adjoin F (S \u222a 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') \u2223 (minimal_polynomial hx).map(algebra_map F (adjoin F S)),\n    apply minimal_polynomial.dvd,\n    dsimp[polynomial.aeval],\n    rw polynomial.eval\u2082_map,\n    rw \u2190 adjoin.composition,\n    apply minimal_polynomial.aeval,\n    cases key with q hq,\n    apply polynomial.separable.of_mul_left,\n    rw \u2190hq,\n    exact polynomial.separable.map hs,\nend\n\nvariables (\u03b1 : E) (h : is_integral F \u03b1)\n\n-- Let's try out this notation?\nnotation K`[`:std.prec.max_plus \u03b2`]` := adjoin K (@singleton _ _ set.has_singleton \u03b2)\nnotation K`[`:std.prec.max_plus \u03b2 `,` \u03b3`]` := adjoin K {\u03b2,\u03b3}\n-- This notation would allow us to write F[\u03b1, \u03b2] for adjoin_simple (adjoin_simple F \u03b1) \u03b2\n-- notation K`\u27e8`L:(foldr `,` (x M, adjoin_simple M x) K `\u27e9`) := L \n-- notation K`[[` binders `]]`s:(scoped \u03b2, set.insert \u03b2) := adjoin K s\n\nlemma adjoin_simple_contains_element : \u03b1 \u2208 F[\u03b1] :=\nadjoin.set_mem F {\u03b1} (\u27e8\u03b1,set.mem_singleton \u03b1\u27e9 : ({\u03b1} : set E))\n\ninstance adjoin_is_algebra : algebra F F[\u03b1] :=\nadjoin.is_algebra F {\u03b1}\n\ndef adjoin_simple_as_submodule : submodule F E :=\nadjoin_as_submodule F {\u03b1}\n\ndefinition adjoin_simple_as_submodule_equiv : F[\u03b1] \u2243\u2097[F] (adjoin_simple_as_submodule F \u03b1) :=\nadjoin_as_submodule_equiv F {\u03b1}\n\n/-- A subfield of E that contains F and \u03b1 also contains F[\u03b1] -/\nlemma adjoin_simple_subset {T : set E} [is_subfield T] (HF : set.range (algebra_map F E) \u2286 T) (H\u03b1 : \u03b1 \u2208 T) : F[\u03b1] \u2286 T :=\nadjoin_subset F {\u03b1} HF (set.singleton_subset_iff.mpr H\u03b1)\n\n/-- If \u03b1 is in F[T] then F[\u03b1] \u2286 F[T] -/\nlemma adjoin_simple_subset' {T : set E} (HT : \u03b1 \u2208 adjoin F T) : F[\u03b1] \u2286 adjoin F T :=\nadjoin_subset' F {\u03b1} (set.singleton_subset_iff.mpr HT)\n\n--generator of F(\u03b1)\ndef adjoin_simple.gen : F[\u03b1] := \u27e8\u03b1, adjoin_simple_contains_element F \u03b1\u27e9\n\nlemma adjoin_simple.gen_eq_alpha : algebra_map F[\u03b1] E (adjoin_simple.gen F \u03b1) = \u03b1 := 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[\u03b1]. -/\nlemma adjoin_simple_gen_nontrivial {\u03b1 : E} (h\u03b1 : \u03b1 \u2209 set.range (algebra_map F E)) :\n    adjoin_simple.gen F \u03b1 \u2209 set.range (algebra_map F F[\u03b1]) :=\nbegin\n    revert h\u03b1,\n    contrapose!,\n    rintros \u27e8x, hx\u27e9,\n    injections_and_clear,\n    use x, assumption,\nend\n\nlemma adjoin_simple_twice (\u03b2 : E) : F[\u03b1][\u03b2] = adjoin F {\u03b1,\u03b2} :=\nadjoin_twice _ _ _\n\ndef submodule_restrict_field (\u03b1 : E) (p : submodule F[\u03b1] 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 {\u03b1},\n        rw ring_hom.comp_apply,\n        rw \u2190algebra.smul_def,\n        exact p.smul_mem' _ hx,\n    end\n}\n\ninstance adjoin_simple_algebra_tower : is_scalar_tower F (F[\u03b1]) E :=\nadjoin_algebra_tower F {\u03b1}\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 \u2286 t) (hs : s.infinite) : t.infinite :=\nmt (\u03bb 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] (\u03b1 : E) :\n    finite_dimensional F[\u03b1] 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[\u03b1] B = \u22a4,\n    {   ext,\n        simp only [submodule.mem_top, iff_true],\n        have hx : x \u2208 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 \u03b1 p),\n        rw subtype.range_coe,\n        exact hp, },\n    rw \u2190 key,\n    apply finite_dimensional.span_of_finite F[\u03b1] hB.2,\nend\n\ninstance adjoin_findim_of_findim_base [F_findim : finite_dimensional F E] (\u03b1 : E) :\n    finite_dimensional F F[\u03b1] :=\nbegin\n    have h := finite_dimensional.finite_dimensional_submodule (adjoin_simple_as_submodule F \u03b1),\n    exact linear_equiv.finite_dimensional (adjoin_simple_as_submodule_equiv F \u03b1).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] : (\u2203 x : E, x \u2209 set.range (algebra_map F E)) \u2192\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 \u27e81, one_ne_zero\u27e9,\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 \u2192 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 \u27e8_, s_spans\u27e9 := set_is_basis_of_linear_independent_of_card_eq_findim s_lin_ind s_card,\n    have x_in_span_one : x \u2208 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 \u27e8a, ha\u27e9 := submodule.mem_span_singleton.mp x_in_span_one,\n    exact \u27e8a, by rw [\u2190 ha, algebra.smul_def, mul_one]\u27e9,\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] {\u03b1 : E} (h\u03b1 : \u03b1 \u2209 set.range (algebra_map F E)) :\n    findim F[\u03b1] E < findim F E :=\nbegin\n    rw \u2190 findim_mul_findim F F[\u03b1] E,\n    have : 0 < findim F[\u03b1] E := findim_pos_iff_exists_ne_zero.mpr \u27e81, one_ne_zero\u27e9,\n    have : adjoin_simple.gen F \u03b1 \u2209 set.range (algebra_map F F[\u03b1]) := adjoin_simple_gen_nontrivial F h\u03b1,\n    have : findim F F[\u03b1] > 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 (\u03bb (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'] (\u03b1' : E') (h\u03b1' : (minimal_polynomial h).eval\u2082 (algebra_map F E') \u03b1' = 0)\n\nnoncomputable def quotient_embedding_ring_hom :\n(adjoin_root (minimal_polynomial h)) \u2192+* E' :=\nadjoin_root.lift (algebra_map F E') \u03b1' h\u03b1'\n\nnoncomputable def quotient_embedding : (adjoin_root (minimal_polynomial h)) \u2192\u2090[F] E' := {\n    to_fun := (quotient_embedding_ring_hom F \u03b1 h \u03b1' h\u03b1').to_fun,\n    map_one' := (quotient_embedding_ring_hom F \u03b1 h \u03b1' h\u03b1').map_one',\n    map_mul' := (quotient_embedding_ring_hom F \u03b1 h \u03b1' h\u03b1').map_mul',\n    map_zero' := (quotient_embedding_ring_hom F \u03b1 h \u03b1' h\u03b1').map_zero',\n    map_add' := (quotient_embedding_ring_hom F \u03b1 h \u03b1' h\u03b1').map_add',\n    commutes' :=\n    begin\n        intro r,\n        change (quotient_embedding_ring_hom F \u03b1 h \u03b1' h\u03b1') r = _,\n        exact adjoin_root.lift_of,\n    end\n}\n\n@[simp] lemma quotient_embedding_of_field (f : F) : quotient_embedding F \u03b1 h \u03b1' h\u03b1' f = algebra_map F E' f :=\nbegin\n    change quotient_embedding_ring_hom F \u03b1 h \u03b1' h\u03b1' f = algebra_map F E' f,\n    exact adjoin_root.lift_of,\nend\n\n@[simp] lemma quotient_embedding_of_root : quotient_embedding F \u03b1 h \u03b1' h\u03b1' (adjoin_root.root (minimal_polynomial h)) = \u03b1' :=\nbegin\n    change quotient_embedding_ring_hom F \u03b1 h \u03b1' h\u03b1' (adjoin_root.root (minimal_polynomial h)) = \u03b1',\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\u2082 (algebra_map F F[\u03b1]) (adjoin_simple.gen F \u03b1) (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 {\u03b1} at eval,\n    have h := polynomial.hom_eval\u2082 (minimal_polynomial h) (algebra_map F F[\u03b1]) (algebra_map F[\u03b1] E) (adjoin_simple.gen F \u03b1),\n    rw adjoin_simple.gen_eq_alpha at h,\n    rw \u2190h at eval,\n    exact eval,\nend\n\nnoncomputable def quotient_to_adjunction_algebra_hom : (adjoin_root (minimal_polynomial h)) \u2192\u2090[F] F[\u03b1] :=\nquotient_embedding F \u03b1 h (adjoin_simple.gen F \u03b1) (adjoin_simple.eval_gen F \u03b1 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 \u2192\u2090[F] B) (h : function.bijective f) : A \u2243\u2090[F] B :=\n{ .. f, .. equiv.of_bijective _ h }\n\nnoncomputable def quotient_to_adjunction : adjoin_root (minimal_polynomial h) \u2243\u2090[F] F[\u03b1] :=\nalgebra_equiv_of_bij_hom' F (quotient_to_adjunction_algebra_hom F \u03b1 h)\nbegin\n    set f := (algebra_map F[\u03b1] E).comp((quotient_to_adjunction_algebra_hom F \u03b1 h) : (adjoin_root (minimal_polynomial h)) \u2192+* F[\u03b1]),\n    split,\n    apply ring_hom.injective,\n    have inclusion : (set.range (algebra_map F E) \u222a {\u03b1}) \u2286 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 \u2190hy,\n    use y,\n    dsimp[f,quotient_to_adjunction_algebra_hom],\n    rw quotient_embedding_of_field F \u03b1 h (adjoin_simple.gen F \u03b1) (adjoin_simple.eval_gen F \u03b1 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 \u03b1 h (adjoin_simple.gen F \u03b1) (adjoin_simple.eval_gen F \u03b1 h),\n    refl,\n    have key : F[\u03b1] \u2286 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 \u03b1 h f = f :=\nquotient_embedding_of_field F \u03b1 h (adjoin_simple.gen F \u03b1) (adjoin_simple.eval_gen F \u03b1 h) f\n\n@[simp] lemma quotient_to_adjunction_of_root : quotient_to_adjunction F \u03b1 h (adjoin_root.root (minimal_polynomial h)) = adjoin_simple.gen F \u03b1 :=\nquotient_embedding_of_root F \u03b1 h (adjoin_simple.gen F \u03b1) (adjoin_simple.eval_gen F \u03b1 h)\n\nnoncomputable def adjunction_embedding : F[\u03b1] \u2192\u2090[F] E' :=\n(quotient_embedding F \u03b1 h \u03b1' h\u03b1').comp((quotient_to_adjunction F \u03b1 h).symm)\n\n@[simp] lemma adjunction_embedding_of_field (f : F) : adjunction_embedding F \u03b1 h \u03b1' h\u03b1' f = algebra_map F E' f :=\nbegin\n    dsimp[adjunction_embedding],\n    rw \u2190quotient_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 \u03b1 h \u03b1' h\u03b1' (adjoin_simple.gen F \u03b1) = \u03b1' :=\nbegin\n    dsimp[adjunction_embedding],\n    rw \u2190quotient_to_adjunction_of_root,\n    rw alg_equiv.symm_apply_apply,\n    rw quotient_embedding_of_root,\nend\n\nvariables (\u03d5 \u03c8 : (adjoin F S) \u2192+* E')\n\ndef adjoin_equalizer : set (adjoin F S) :=\n(\u03bb f, \u03d5 f = \u03c8 f)\n\ninstance to_adjunction_embedding_equalizer_is_subfield : is_subfield (adjoin_equalizer F S \u03d5 \u03c8) := {\n    zero_mem :=\n    begin\n        change \u03d5 0 = \u03c8 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 \u03d5 a = \u03c8 a at ha,\n        change \u03d5 b = \u03c8 b at hb,\n        change \u03d5 (a + b) = \u03c8 (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 \u03d5 a = \u03c8 a at ha,\n        change \u03d5 (-a) = \u03c8 (-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 \u03d5 1 = \u03c8 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 \u03d5 a = \u03c8 a at ha,\n        change \u03d5 b = \u03c8 b at hb,\n        change \u03d5 (a * b) = \u03c8 (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 \u03d5 a = \u03c8 a at ha,\n        change \u03d5 a\u207b\u00b9 = \u03c8 a\u207b\u00b9,\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 \u03d5 \u03c8) : set E) := {\n    zero_mem := \u27e80,\u27e8is_add_submonoid.zero_mem,rfl\u27e9\u27e9,\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[\u2190ha'.2,\u2190hb'.2],\n        exact \u27e8a'+b',\u27e8is_add_submonoid.add_mem ha'.1 hb'.1,rfl\u27e9\u27e9,\n    end,\n    neg_mem :=\n    begin\n        intros a ha,\n        cases ha with a' ha',\n        rw \u2190ha'.2,\n        exact \u27e8-a',\u27e8is_add_subgroup.neg_mem ha'.1,rfl\u27e9\u27e9,\n    end,\n    one_mem := \u27e81,\u27e8is_submonoid.one_mem,rfl\u27e9\u27e9,\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[\u2190ha'.2,\u2190hb'.2],\n        exact \u27e8a'*b',\u27e8is_submonoid.mul_mem ha'.1 hb'.1,rfl\u27e9\u27e9,\n    end,\n    inv_mem :=\n    begin\n        intros a ha,\n        cases ha with a' ha',\n        rw \u2190ha'.2,\n        exact \u27e8a'\u207b\u00b9,\u27e8is_subfield.inv_mem ha'.1,rfl\u27e9\u27e9,\n    end\n}\n\nlemma ring_hom_determined_by_generators (hF : \u2200 f : F, \u03d5 f = \u03c8 f) (hS : \u2200 s : S, \u03d5 s = \u03c8 s) : \u03d5 = \u03c8 :=\nbegin\n    suffices key : adjoin F S \u2286 coe '' adjoin_equalizer F S \u03d5 \u03c8,\n    ext,\n    specialize key (subtype.mem x),\n    cases key with y hy,\n    rw \u2190subtype.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 \u27e8\u2191y,\u27e8hF y,hy\u27e9\u27e9,\n    intros x hx,\n    exact \u27e8\u27e8x,adjoin.set_mem F S \u27e8x,hx\u27e9\u27e9,\u27e8hS \u27e8x,hx\u27e9,rfl\u27e9\u27e9,\nend\n\nvariable (\u03b9 : F[\u03b1] \u2192\u2090[F] E') \n\nlemma adjunction_embedding_classification_aux : polynomial.eval\u2082 (algebra_map F E') (\u03b9 (adjoin_simple.gen F \u03b1)) (minimal_polynomial h) = 0 :=\nbegin\n    have key2 : ((\u03b9 : F[\u03b1] \u2192+* E').comp(algebra_map F F[\u03b1]) = 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 \u2190key2,\n    change polynomial.eval\u2082 ((\u03b9 : F[\u03b1] \u2192+* E').comp(algebra_map F F[\u03b1])) ((\u03b9 : F[\u03b1] \u2192+* E') (adjoin_simple.gen F \u03b1)) (minimal_polynomial h) = 0,\n    rw \u2190polynomial.hom_eval\u2082 (minimal_polynomial h) (algebra_map F F[\u03b1]) (\u03b9 : F[\u03b1] \u2192+* E') (adjoin_simple.gen F \u03b1),\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[\u03b1] \u2192\u2090[F] E' :=\nadjunction_embedding F \u03b1 h (\u03b9 (adjoin_simple.gen F \u03b1)) (adjunction_embedding_classification_aux F \u03b1 h \u03b9)\n\n--proves that every map F(\u03b1) \u2192 E' is comes from adjunction_embedding\nlemma adjunction_embedding_classification : \u03b9 = to_adjunction_embedding F \u03b1 h \u03b9 :=\nbegin\n    have key := ring_hom_determined_by_generators F {\u03b1} (\u03b9 : F[\u03b1] \u2192+* E') (to_adjunction_embedding F \u03b1 h \u03b9 : F[\u03b1] \u2192+* E'),\n    have hF : \u2200 f : F, \u03b9 f = to_adjunction_embedding F \u03b1 h \u03b9 f,\n    intro f,\n    dsimp[to_adjunction_embedding],\n    rw adjunction_embedding_of_field,\n    exact alg_hom.commutes \u03b9 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' : (\u2191s : adjoin F {\u03b1}) = adjoin_simple.gen F \u03b1,\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 \u03b1)) = (minimal_polynomial h).nat_degree :=\nbegin\n    have algequiv : adjoin_root (minimal_polynomial h) \u2243\u2090[F] adjoin_simple F \u03b1 := quotient_to_adjunction F \u03b1 h,\n    have linequiv : adjoin_root (minimal_polynomial h) \u2243\u2097[F] adjoin_simple F \u03b1,\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 \u03b1) c) * (algequiv x)),\n    rw[algequiv.map_mul,\u2190algequiv.commutes],\n    refl,\n    exact algequiv.inv_fun,\n    exact algequiv.left_inv,\n    exact algequiv.right_inv,\n    rw \u2190 @linear_equiv.findim_eq F (adjoin_root (minimal_polynomial h)) _ _ _ (adjoin_simple F \u03b1) _ _ linequiv (quotient_degree_finite F \u03b1 h),\n    exact quotient_degree F \u03b1 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 `\u03b1`, we take the colimit of the filtered\ndiagram of all coproducts of finite subsets of `\u03b1`.\n\nWe also deduce the dual statement by invoking the original statement in `C\u1d52\u1d56`.\n-/\n\n\nuniverse w v u\n\nnoncomputable section\n\nopen CategoryTheory\n\nvariable {C : Type u} [Category.{v} C] {\u03b1 : 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 \u03b1 \u2964 C` lifts to a functor\n    `finset (discrete \u03b1) \u2964 C` by taking coproducts. -/\n@[simps]\ndef liftToFinset [HasFiniteCoproducts C] (F : Discrete \u03b1 \u2964 C) : Finset (Discrete \u03b1) \u2964 C\n    where\n  obj s := \u2210 fun x : s => F.obj x\n  map s t h := Sigma.desc fun y => Sigma.\u03b9 (fun x : t => F.obj x) \u27e8y, h.down.down y.2\u27e9\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 \u03b1] (F : Discrete \u03b1 \u2964 C) : ColimitCocone F\n    where\n  Cocone :=\n    { pt := colimit (liftToFinset F)\n      \u03b9 :=\n        Discrete.natTrans fun j =>\n          @Sigma.\u03b9 _ _ _ (fun x : ({j} : Finset (Discrete \u03b1)) => F.obj x) _ \u27e8j, by simp\u27e9 \u226b\n            colimit.\u03b9 (liftToFinset F) {j} }\n  IsColimit :=\n    { desc := fun s =>\n        colimit.desc (liftToFinset F)\n          { pt := s.pt\n            \u03b9 := { app := fun t => Sigma.desc fun x => s.\u03b9.app x } }\n      uniq := fun s m h => by\n        ext (t\u27e8\u27e8j, hj\u27e9\u27e9)\n        convert h j using 1\n        \u00b7 simp [\u2190 colimit.w (lift_to_finset F) \u27e8\u27e8Finset.singleton_subset_iff.2 hj\u27e9\u27e9]\n          rfl\n        \u00b7 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 \u03b1 => by\n  classical exact \u27e8fun F => has_colimit.mk (lift_to_finset_colimit_cocone F)\u27e9\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\u1d52\u1d56 := 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, Ya\u00ebl 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 : \u2115 \u2192 \u03b1`, this new sequence will be `f 0`, `f 1 \\ f 0`, `f 2 \\ (f 0 \u2294 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 \u2294 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 `\u2115`.\nRelated to the TODO in the module docstring of `order.partial_sups`.\n-/\n\n\nvariable {\u03b1 \u03b2 : Type _}\n\nsection GeneralizedBooleanAlgebra\n\nvariable [GeneralizedBooleanAlgebra \u03b1]\n\n#print disjointed /-\n/-- If `f : \u2115 \u2192 \u03b1` 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 : \u2115 \u2192 \u03b1) : \u2115 \u2192 \u03b1\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 : \u2115 \u2192 \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} \u03b1] (f : Nat -> \u03b1) (n : Nat), Eq.{succ u1} \u03b1 (disjointed.{u1} \u03b1 _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} \u03b1 (GeneralizedBooleanAlgebra.toHasSdiff.{u1} \u03b1 _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 \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeSup.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (fun (_x : OrderHom.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeSup.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) => Nat -> \u03b1) (OrderHom.hasCoeToFun.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeSup.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (partialSups.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) f) n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} \u03b1] (f : Nat -> \u03b1) (n : Nat), Eq.{succ u1} \u03b1 (disjointed.{u1} \u03b1 _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} \u03b1 (GeneralizedBooleanAlgebra.toSDiff.{u1} \u03b1 _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 \u03b1 (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeSup.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))))) (partialSups.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) f) n))\nCase conversion may be inaccurate. Consider using '#align disjointed_succ disjointed_succ\u2093'. -/\ntheorem disjointed_succ (f : \u2115 \u2192 \u03b1) (n : \u2115) : 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 \u2264 (id : (\u2115 \u2192 \u03b1) \u2192 \u2115 \u2192 \u03b1) :=\n  by\n  rintro f n\n  cases n\n  \u00b7 rfl\n  \u00b7 exact sdiff_le\n#align disjointed_le_id disjointed_le_id\n-/\n\n#print disjointed_le /-\ntheorem disjointed_le (f : \u2115 \u2192 \u03b1) : disjointed f \u2264 f :=\n  disjointed_le_id f\n#align disjointed_le disjointed_le\n-/\n\n#print disjoint_disjointed /-\ntheorem disjoint_disjointed (f : \u2115 \u2192 \u03b1) : Pairwise (Disjoint on disjointed f) :=\n  by\n  refine' (Symmetric.pairwise_on Disjoint.symm _).2 fun m n h => _\n  cases n\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} \u03b1] {f : Nat -> \u03b1} {p : \u03b1 -> Sort.{u2}}, (forall {{t : \u03b1}} {{i : Nat}}, (p t) -> (p (SDiff.sdiff.{u1} \u03b1 (GeneralizedBooleanAlgebra.toHasSdiff.{u1} \u03b1 _inst_1) t (f i)))) -> (forall {{n : Nat}}, (p (f n)) -> (p (disjointed.{u1} \u03b1 _inst_1 f n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} \u03b1] {f : Nat -> \u03b1} {p : \u03b1 -> Sort.{u2}}, (forall {{t : \u03b1}} {{i : Nat}}, (p t) -> (p (SDiff.sdiff.{u1} \u03b1 (GeneralizedBooleanAlgebra.toSDiff.{u1} \u03b1 _inst_1) t (f i)))) -> (forall {{n : Nat}}, (p (f n)) -> (p (disjointed.{u1} \u03b1 _inst_1 f n)))\nCase conversion may be inaccurate. Consider using '#align disjointed_rec disjointedRec\u2093'. -/\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 : \u2115 \u2192 \u03b1} {p : \u03b1 \u2192 Sort _} (hdiff : \u2200 \u2983t i\u2984, p t \u2192 p (t \\ f i)) :\n    \u2200 \u2983n\u2984, p (f n) \u2192 p (disjointed f n)\n  | 0 => id\n  | n + 1 => fun h => by\n    suffices H : \u2200 k, p (f (n + 1) \\ partialSups f k)\n    \u00b7 exact H n\n    rintro k\n    induction' k with k ih\n    \u00b7 exact hdiff h\n    rw [partialSups_succ, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} \u03b1] {f : Nat -> \u03b1} {p : \u03b1 -> Sort.{u2}} (hdiff : forall {{t : \u03b1}} {{i : Nat}}, (p t) -> (p (SDiff.sdiff.{u1} \u03b1 (GeneralizedBooleanAlgebra.toHasSdiff.{u1} \u03b1 _inst_1) t (f i)))) (h\u2080 : p (f (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))), Eq.{u2} (p (disjointed.{u1} \u03b1 _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} \u03b1 _inst_1 (fun (i : Nat) => f i) (fun (t : \u03b1) => p t) hdiff (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))) h\u2080) h\u2080\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} \u03b1] {f : Nat -> \u03b1} {p : \u03b1 -> Sort.{u2}} (hdiff : forall {{t : \u03b1}} {{i : Nat}}, (p t) -> (p (SDiff.sdiff.{u1} \u03b1 (GeneralizedBooleanAlgebra.toSDiff.{u1} \u03b1 _inst_1) t (f i)))) (h\u2080 : p (f (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))), Eq.{u2} (p (disjointed.{u1} \u03b1 _inst_1 (fun (i : Nat) => f i) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))) (disjointedRec.{u1, u2} \u03b1 _inst_1 (fun (i : Nat) => f i) (fun (t : \u03b1) => p t) hdiff (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) h\u2080) h\u2080\nCase conversion may be inaccurate. Consider using '#align disjointed_rec_zero disjointedRec_zero\u2093'. -/\n@[simp]\ntheorem disjointedRec_zero {f : \u2115 \u2192 \u03b1} {p : \u03b1 \u2192 Sort _} (hdiff : \u2200 \u2983t i\u2984, p t \u2192 p (t \\ f i))\n    (h\u2080 : p (f 0)) : disjointedRec hdiff h\u2080 = h\u2080 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} \u03b1] {f : Nat -> \u03b1}, (Monotone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring))) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))))) f) -> (forall (n : Nat), Eq.{succ u1} \u03b1 (disjointed.{u1} \u03b1 _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} \u03b1 (GeneralizedBooleanAlgebra.toHasSdiff.{u1} \u03b1 _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 {\u03b1 : Type.{u1}} [_inst_1 : GeneralizedBooleanAlgebra.{u1} \u03b1] {f : Nat -> \u03b1}, (Monotone.{0, u1} Nat \u03b1 (PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring)) (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (GeneralizedBooleanAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))))) f) -> (forall (n : Nat), Eq.{succ u1} \u03b1 (disjointed.{u1} \u03b1 _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} \u03b1 (GeneralizedBooleanAlgebra.toSDiff.{u1} \u03b1 _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\u2093'. -/\n-- TODO: Find a useful statement of `disjointed_rec_succ`.\ntheorem Monotone.disjointed_eq {f : \u2115 \u2192 \u03b1} (hf : Monotone f) (n : \u2115) :\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 : \u2115 \u2192 \u03b1) : partialSups (disjointed f) = partialSups f :=\n  by\n  ext n\n  induction' n with k ih\n  \u00b7 rw [partialSups_zero, partialSups_zero, disjointed_zero]\n  \u00b7 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 : \u2115 \u2192 \u03b1} (hdisj : Pairwise (Disjoint on d))\n    (hsups : partialSups d = partialSups f) : d = disjointed f :=\n  by\n  ext n\n  cases n\n  \u00b7 rw [\u2190 partialSups_zero d, hsups, partialSups_zero, disjointed_zero]\n  suffices h : d n.succ = partialSups d n.succ \\ partialSups d n\n  \u00b7 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 : \u2200 m \u2264 n, Disjoint (partialSups d m) (d n.succ)\n  \u00b7 exact h n le_rfl\n  rintro m hm\n  induction' m with m ih\n  \u00b7 exact hdisj (Nat.succ_ne_zero _).symm\n  rw [partialSups_succ, disjoint_iff, inf_sup_right, sup_eq_bot_iff, \u2190 disjoint_iff, \u2190 disjoint_iff]\n  exact \u27e8ih (Nat.le_of_succ_le hm), hdisj (Nat.lt_succ_of_le hm).Ne\u27e9\n#align disjointed_unique disjointed_unique\n-/\n\nend GeneralizedBooleanAlgebra\n\nsection CompleteBooleanAlgebra\n\nvariable [CompleteBooleanAlgebra \u03b1]\n\n/- warning: supr_disjointed -> sup\u1d62_disjointed is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CompleteBooleanAlgebra.{u1} \u03b1] (f : Nat -> \u03b1), Eq.{succ u1} \u03b1 (sup\u1d62.{u1, 1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))) Nat (fun (n : Nat) => disjointed.{u1} \u03b1 (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} \u03b1 (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} \u03b1 _inst_1)) f n)) (sup\u1d62.{u1, 1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))) Nat (fun (n : Nat) => f n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CompleteBooleanAlgebra.{u1} \u03b1] (f : Nat -> \u03b1), Eq.{succ u1} \u03b1 (sup\u1d62.{u1, 1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))) Nat (fun (n : Nat) => disjointed.{u1} \u03b1 (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} \u03b1 (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} \u03b1 _inst_1)) f n)) (sup\u1d62.{u1, 1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))) Nat (fun (n : Nat) => f n))\nCase conversion may be inaccurate. Consider using '#align supr_disjointed sup\u1d62_disjointed\u2093'. -/\ntheorem sup\u1d62_disjointed (f : \u2115 \u2192 \u03b1) : (\u2a06 n, disjointed f n) = \u2a06 n, f n :=\n  sup\u1d62_eq_sup\u1d62_of_partialSups_eq_partialSups (partialSups_disjointed f)\n#align supr_disjointed sup\u1d62_disjointed\n\n/- warning: disjointed_eq_inf_compl -> disjointed_eq_inf_compl is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CompleteBooleanAlgebra.{u1} \u03b1] (f : Nat -> \u03b1) (n : Nat), Eq.{succ u1} \u03b1 (disjointed.{u1} \u03b1 (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} \u03b1 (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} \u03b1 _inst_1)) f n) (Inf.inf.{u1} \u03b1 (SemilatticeInf.toHasInf.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))))) (f n) (inf\u1d62.{u1, 1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))) Nat (fun (i : Nat) => inf\u1d62.{u1, 0} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))) (LT.lt.{0} Nat Nat.hasLt i n) (fun (H : LT.lt.{0} Nat Nat.hasLt i n) => HasCompl.compl.{u1} \u03b1 (BooleanAlgebra.toHasCompl.{u1} \u03b1 (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} \u03b1 _inst_1)) (f i)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CompleteBooleanAlgebra.{u1} \u03b1] (f : Nat -> \u03b1) (n : Nat), Eq.{succ u1} \u03b1 (disjointed.{u1} \u03b1 (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} \u03b1 (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} \u03b1 _inst_1)) f n) (Inf.inf.{u1} \u03b1 (Lattice.toInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1)))))) (f n) (inf\u1d62.{u1, 1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))) Nat (fun (i : Nat) => inf\u1d62.{u1, 0} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (CompleteLattice.toConditionallyCompleteLattice.{u1} \u03b1 (Order.Coframe.toCompleteLattice.{u1} \u03b1 (CompleteDistribLattice.toCoframe.{u1} \u03b1 (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} \u03b1 _inst_1))))) (LT.lt.{0} Nat instLTNat i n) (fun (H : LT.lt.{0} Nat instLTNat i n) => HasCompl.compl.{u1} \u03b1 (BooleanAlgebra.toHasCompl.{u1} \u03b1 (CompleteBooleanAlgebra.toBooleanAlgebra.{u1} \u03b1 _inst_1)) (f i)))))\nCase conversion may be inaccurate. Consider using '#align disjointed_eq_inf_compl disjointed_eq_inf_compl\u2093'. -/\ntheorem disjointed_eq_inf_compl (f : \u2115 \u2192 \u03b1) (n : \u2115) : disjointed f n = f n \u2293 \u2a05 i < n, f i\u1d9c :=\n  by\n  cases n\n  \u00b7 rw [disjointed_zero, eq_comm, inf_eq_left]\n    simp_rw [le_inf\u1d62_iff]\n    exact fun i hi => (i.not_lt_zero hi).elim\n  simp_rw [disjointed_succ, partialSups_eq_bsup\u1d62, sdiff_eq, compl_sup\u1d62]\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 {\u03b1 : Type.{u1}} (f : Nat -> (Set.{u1} \u03b1)) (n : Nat), HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (disjointed.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) f n) (f n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Nat -> (Set.{u1} \u03b1)) (n : Nat), HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (disjointed.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) f n) (f n)\nCase conversion may be inaccurate. Consider using '#align disjointed_subset disjointed_subset\u2093'. -/\ntheorem disjointed_subset (f : \u2115 \u2192 Set \u03b1) (n : \u2115) : disjointed f n \u2286 f n :=\n  disjointed_le f n\n#align disjointed_subset disjointed_subset\n\n/- warning: Union_disjointed -> union\u1d62_disjointed is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {f : Nat -> (Set.{u1} \u03b1)}, Eq.{succ u1} (Set.{u1} \u03b1) (Set.union\u1d62.{u1, 1} \u03b1 Nat (fun (n : Nat) => disjointed.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) f n)) (Set.union\u1d62.{u1, 1} \u03b1 Nat (fun (n : Nat) => f n))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Nat -> (Set.{u1} \u03b1)}, Eq.{succ u1} (Set.{u1} \u03b1) (Set.union\u1d62.{u1, 1} \u03b1 Nat (fun (n : Nat) => disjointed.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) f n)) (Set.union\u1d62.{u1, 1} \u03b1 Nat (fun (n : Nat) => f n))\nCase conversion may be inaccurate. Consider using '#align Union_disjointed union\u1d62_disjointed\u2093'. -/\ntheorem union\u1d62_disjointed {f : \u2115 \u2192 Set \u03b1} : (\u22c3 n, disjointed f n) = \u22c3 n, f n :=\n  sup\u1d62_disjointed f\n#align Union_disjointed union\u1d62_disjointed\n\n/- warning: disjointed_eq_inter_compl -> disjointed_eq_inter_compl is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} (f : Nat -> (Set.{u1} \u03b1)) (n : Nat), Eq.{succ u1} (Set.{u1} \u03b1) (disjointed.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) f n) (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) (f n) (Set.inter\u1d62.{u1, 1} \u03b1 Nat (fun (i : Nat) => Set.inter\u1d62.{u1, 0} \u03b1 (LT.lt.{0} Nat Nat.hasLt i n) (fun (H : LT.lt.{0} Nat Nat.hasLt i n) => HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) (f i)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Nat -> (Set.{u1} \u03b1)) (n : Nat), Eq.{succ u1} (Set.{u1} \u03b1) (disjointed.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) f n) (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.instInterSet.{u1} \u03b1) (f n) (Set.inter\u1d62.{u1, 1} \u03b1 Nat (fun (i : Nat) => Set.inter\u1d62.{u1, 0} \u03b1 (LT.lt.{0} Nat instLTNat i n) (fun (H : LT.lt.{0} Nat instLTNat i n) => HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) (f i)))))\nCase conversion may be inaccurate. Consider using '#align disjointed_eq_inter_compl disjointed_eq_inter_compl\u2093'. -/\ntheorem disjointed_eq_inter_compl (f : \u2115 \u2192 Set \u03b1) (n : \u2115) : disjointed f n = f n \u2229 \u22c2 i < n, f i\u1d9c :=\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 {\u03b1 : Type.{u1}} (s : Nat -> (Set.{u1} \u03b1)) (H : forall (x : \u03b1), Exists.{1} Nat (fun (n : Nat) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (s n))) [_inst_1 : forall (x : \u03b1) (n : Nat), Decidable (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (s n))] (n : Nat), Eq.{succ u1} (Set.{u1} \u03b1) (Set.preimage.{u1, 0} \u03b1 Nat (fun (x : \u03b1) => Nat.find (fun (n : Nat) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) 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} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (s : Nat -> (Set.{u1} \u03b1)) (H : forall (x : \u03b1), Exists.{1} Nat (fun (n : Nat) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x (s n))) [_inst_1 : forall (x : \u03b1) (n : Nat), Decidable (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x (s n))] (n : Nat), Eq.{succ u1} (Set.{u1} \u03b1) (Set.preimage.{u1, 0} \u03b1 Nat (fun (x : \u03b1) => Nat.find (fun (n : Nat) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) 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} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s n)\nCase conversion may be inaccurate. Consider using '#align preimage_find_eq_disjointed preimage_find_eq_disjointed\u2093'. -/\ntheorem preimage_find_eq_disjointed (s : \u2115 \u2192 Set \u03b1) (H : \u2200 x, \u2203 n, x \u2208 s n)\n    [\u2200 x n, Decidable (x \u2208 s n)] (n : \u2115) : (fun x => Nat.find (H x)) \u207b\u00b9' {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 \u27f6 Y`, or `eq_to_iso h : X \u2245 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n-- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nopen opposite\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n\n/--\nAn equality `X = Y` gives us a morphism `X \u27f6 Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `\ud835\udfd9 _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_hom {X Y : C} (p : X = Y) : X \u27f6 Y := by rw p; exact \ud835\udfd9 _\n\n@[simp] lemma eq_to_hom_refl (X : C) (p : X = X) : eq_to_hom p = \ud835\udfd9 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 \u226b 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 \u27f6 Z) :\n  (congr_arg (\u03bb W : C, W \u27f6 Z) p).mpr q = eq_to_hom p \u226b 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 \u27f6 Y) (q : Z = Y) :\n  (congr_arg (\u03bb W : C, X \u27f6 W) q).mpr p = p \u226b eq_to_hom q.symm :=\nby { cases q, simp, }\n\n/--\nAn equality `X = Y` gives us an isomorphism `X \u2245 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 \u2245 Y :=\n\u27e8eq_to_hom p, eq_to_hom p.symm, by simp, by simp\u27e9\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\u1d52\u1d56} (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\u2082} [category.{v\u2082} 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 \u2964 D} (h_obj : \u2200 X, F.obj X = G.obj X)\n  (h_map : \u2200 X Y f, F.map f = eq_to_hom (h_obj X) \u226b G.map f \u226b 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 \u27f6 X) (g : Y \u27f6 Z) (h : W = Y) (h' : X = Z) :\n  f = eq_to_hom h \u226b g \u226b eq_to_hom h'.symm \u2194 f == g :=\nby { cases h, cases h', simp }\n\n/-- Proving equality between functors using heterogeneous equality. -/\nlemma hext {F G : C \u2964 D} (h_obj : \u2200 X, F.obj X = G.obj X)\n  (h_map : \u2200 X Y (f : X \u27f6 Y), F.map f == G.map f) : F = G :=\nfunctor.ext h_obj (\u03bb _ _ 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 \u2964 D} (h : F = G) (X) : F.obj X = G.obj X :=\nby subst h\n\nlemma congr_hom {F G : C \u2964 D} (h : F = G) {X Y} (f : X \u27f6 Y) :\n  F.map f = eq_to_hom (congr_obj h X) \u226b G.map f \u226b 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\u2083} [category.{v\u2083} E] {F G : C \u2964 D} {X Y Z : C} {f : X \u27f6 Y} {g : Y \u27f6 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 \u226b g) == G.map (f \u226b g) :=\nby { rw [F.map_comp, G.map_comp], congr' }\n\nlemma map_comp_heq' (hobj : \u2200 X : C, F.obj X = G.obj X)\n  (hmap : \u2200 {X Y} (f : X \u27f6 Y), F.map f == G.map f) :\n  F.map (f \u226b g) == G.map (f \u226b g) :=\nby rw functor.hext hobj (\u03bb _ _, hmap)\n\nlemma precomp_map_heq (H : E \u2964 C)\n  (hmap : \u2200 {X Y} (f : X \u27f6 Y), F.map f == G.map f) {X Y : E} (f : X \u27f6 Y) :\n  (H \u22d9 F).map f == (H \u22d9 G).map f := hmap _\n\nlemma postcomp_map_heq (H : D \u2964 E) (hx : F.obj X = G.obj X) (hy : F.obj Y = G.obj Y)\n  (hmap : F.map f == G.map f) : (F \u22d9 H).map f == (G \u22d9 H).map f :=\nby { dsimp, congr' }\n\nlemma postcomp_map_heq' (H : D \u2964 E) (hobj : \u2200 X : C, F.obj X = G.obj X)\n  (hmap : \u2200 {X Y} (f : X \u27f6 Y), F.map f == G.map f) :\n  (F \u22d9 H).map f == (G \u22d9 H).map f :=\nby rw functor.hext hobj (\u03bb _ _, hmap)\n\nlemma hcongr_hom {F G : C \u2964 D} (h : F = G) {X Y} (f : X \u27f6 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 \u2964 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 \u2964 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 \u2964 D} (h : F = G) (X : C) :\n  (eq_to_hom h : F \u27f6 G).app X = eq_to_hom (functor.congr_obj h X) :=\nby subst h; refl\n\nlemma nat_trans.congr {F G : C \u2964 D} (\u03b1 : F \u27f6 G) {X Y : C} (h : X = Y) :\n  \u03b1.app X = F.map (eq_to_hom h) \u226b \u03b1.app Y \u226b G.map (eq_to_hom h.symm) :=\nby { rw [\u03b1.naturality_assoc], simp }\n\nlemma eq_conj_eq_to_hom {X Y : C} (f : X \u27f6 Y) :\n  f = eq_to_hom rfl \u226b f \u226b eq_to_hom rfl :=\nby simp only [category.id_comp, eq_to_hom_refl, category.comp_id]\n\nlemma dcongr_arg {\u03b9 : Type*} {F G : \u03b9 \u2192 C} (\u03b1 : \u2200 i, F i \u27f6 G i) {i j : \u03b9} (h : i = j) :\n  \u03b1 i = eq_to_hom (congr_arg F h) \u226b \u03b1 j \u226b 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\u1d52\u1d56 \u2964 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\u1d52\u1d56` 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 \u2964 Type` which is faithful, reflects isomorphisms\n  and preserves limits, then `P : C^op \u2964 A` is a sheaf iff the underlying presheaf of types\n  `P \u22d9 s : C^op \u2964 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\u1d52\u1d56 \u2964 A) : Prop :=\n\u2200 X : A, presieve.is_sheaf J (P \u22d9 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\u1d52\u1d56 \u2964 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 \u2964 (C\u1d52\u1d56 \u2964 A) :=\nfull_subcategory_inclusion (presheaf.is_sheaf J)\n\nlemma is_sheaf_iff_is_sheaf_of_type (P : C\u1d52\u1d56 \u2964 Type v) :\n  presheaf.is_sheaf J P \u2194 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 \u27e8\u03bb x, (hP S hS).amalgamate (\u03bb Z f hf, z f hf x) _, _, _\u27e9,\n    { intros Y\u2081 Y\u2082 Z g\u2081 g\u2082 f\u2081 f\u2082 hf\u2081 hf\u2082 h,\n      exact congr_fun (hz g\u2081 g\u2082 hf\u2081 hf\u2082 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, \u2190 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) \u224c SheafOfTypes J :=\n{ functor :=\n  { obj := \u03bb S, \u27e8S.1, (is_sheaf_iff_is_sheaf_of_type _ _).1 S.2\u27e9,\n    map := \u03bb S\u2081 S\u2082 f, f },\n  inverse :=\n  { obj := \u03bb S, \u27e8S.1, (is_sheaf_iff_is_sheaf_of_type _ _).2 S.2\u27e9,\n    map := \u03bb S\u2081 S\u2082 f, f },\n  unit_iso := nat_iso.of_components (\u03bb X, \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by tidy, by tidy\u27e9) (by tidy),\n  counit_iso := nat_iso.of_components (\u03bb X, \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by tidy, by tidy\u27e9) (by tidy) }\n\ninstance : inhabited (Sheaf (\u22a5 : grothendieck_topology C) (Type v)) :=\n\u27e8(Sheaf_equiv_SheafOfTypes _).inverse.obj (default _)\u27e9\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\u1d52\u1d56 \u2964 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\u220f (\u03bb (f : \u03a3 V, {f : V \u27f6 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) \u27f6 first_obj R P :=\npi.lift (\u03bb 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\u220f (\u03bb (fg : (\u03a3 V, {f : V \u27f6 U // R f}) \u00d7 (\u03a3 W, {g : W \u27f6 U // R g})),\n  P.obj (op (pullback fg.1.2.1 fg.2.2.1)))\n\n/-- The map `pr\u2080*` of https://stacks.math.columbia.edu/tag/00VM. -/\ndef first_map : first_obj R P \u27f6 second_obj R P :=\npi.lift (\u03bb fg, pi.\u03c0 _ _ \u226b P.map pullback.fst.op)\n\n/-- The map `pr\u2081*` of https://stacks.math.columbia.edu/tag/00VM. -/\ndef second_map : first_obj R P \u27f6 second_obj R P :=\npi.lift (\u03bb fg, pi.\u03c0 _ _ \u226b P.map pullback.snd.op)\n\nlemma w : fork_map R P \u226b first_map R P = fork_map R P \u226b second_map R P :=\nbegin\n  apply limit.hom_ext,\n  rintro \u27e8\u27e8Y, f, hf\u27e9, \u27e8Z, g, hg\u27e9\u27e9,\n  simp only [first_map, second_map, fork_map, limit.lift_\u03c0, limit.lift_\u03c0_assoc, assoc,\n    fan.mk_\u03c0_app, subtype.coe_mk, subtype.val_eq_coe],\n  rw [\u2190 P.map_comp, \u2190 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\u1d52\u1d56 \u2964 A) : Prop := \u2200 (U : C) (R : presieve U) (hR : generate R \u2208 J U),\nnonempty (is_limit (fork.of_\u03b9 _ (w R P)))\n\n/-- (Implementation). An auxiliary lemma to convert between sheaf conditions. -/\ndef is_sheaf_for_is_sheaf_for' (P : C\u1d52\u1d56 \u2964 A) (s : A \u2964 Type v)\n  [\u03a0 J, preserves_limits_of_shape (discrete J) s] (U : C) (R : presieve U) :\n  is_limit (s.map_cone (fork.of_\u03b9 _ (w R P))) \u2243\n    is_limit (fork.of_\u03b9 _ (equalizer.presieve.w (P \u22d9 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_\u03c0, map_lift_pi_comparison, assoc, fan.mk_\u03c0_app, functor.map_comp],\n        erw pi_comparison_comp_\u03c0_assoc },\n      { ext : 1,\n        dsimp [equalizer.presieve.second_map, second_map],\n        simp only [limit.lift_\u03c0, map_lift_pi_comparison, assoc, fan.mk_\u03c0_app, functor.map_comp],\n        erw pi_comparison_comp_\u03c0_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 \u2194 is_sheaf' J P :=\nbegin\n  split,\n  { intros h U R hR,\n    refine \u27e8_\u27e9,\n    apply coyoneda_jointly_reflects_limits,\n    intro X,\n    have q : presieve.is_sheaf_for (P \u22d9 coyoneda.obj X) _ := h X.unop _ hR,\n    rw \u2190presieve.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 \u27e8_\u27e9,\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 \u2964 Type v` preserves limits and\nreflects isomorphisms, and `A` has limits, an `A`-valued presheaf `P : C\u1d52\u1d56 \u2964 A` is a sheaf iff its\nunderlying `Type`-valued presheaf `P \u22d9 s : C\u1d52\u1d56 \u2964 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 \u2964 Type v)\n  [has_limits A] [preserves_limits s] [reflects_isomorphisms s] :\n  is_sheaf J P \u2194 is_sheaf J (P \u22d9 s) :=\nbegin\n  rw [is_sheaf_iff_is_sheaf', is_sheaf_iff_is_sheaf'],\n  apply forall_congr (\u03bb U, _),\n  apply ball_congr (\u03bb R hR, _),\n  letI : reflects_limits s := reflects_limits_of_reflects_isomorphisms,\n  have : is_limit (s.map_cone (fork.of_\u03b9 _ (w R P))) \u2243 is_limit (fork.of_\u03b9 _ (w R (P \u22d9 s))) :=\n    is_sheaf_for_is_sheaf_for' P s U R,\n  rw \u2190equiv.nonempty_iff_nonempty this,\n  split,\n  { exact nonempty.map (\u03bb t, is_limit_of_preserves s t) },\n  { exact nonempty.map (\u03bb 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 (\u03b1 : Type*) [complete_lattice \u03b1] : CompleteLat := bundled.of \u03b1\n\n@[simp] lemma coe_of (\u03b1 : Type*) [complete_lattice \u03b1] : \u21a5(of \u03b1) = \u03b1 := rfl\n\ninstance : inhabited CompleteLat := \u27e8of punit\u27e9\n\ninstance : bundled_hom @complete_lattice_hom :=\n{ to_fun := \u03bb _ _ _ _, coe_fn,\n  id := @complete_lattice_hom.id,\n  comp := @complete_lattice_hom.comp,\n  hom_ext := \u03bb 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\u2082 CompleteLat BddLat :=\n{ forget\u2082 := { obj := \u03bb X, BddLat.of X,\n               map := \u03bb 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 {\u03b1 \u03b2 : CompleteLat.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2 :=\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 \u2964 CompleteLat :=\n{ obj := \u03bb X, of X\u1d52\u1d48, map := \u03bb 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 \u224c CompleteLat :=\nequivalence.mk dual dual\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n\nend CompleteLat\n\nlemma CompleteLat_dual_comp_forget_to_BddLat :\n  CompleteLat.dual \u22d9 forget\u2082 CompleteLat BddLat =\n    forget\u2082 CompleteLat BddLat \u22d9 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 {\u03b1 : Type _}\n\nnamespace WithTop\n\nvariable [DecidableEq \u03b1]\n\ninstance : DecidableEq (WithTop \u03b1) := instDecidableEqOption\n\nsection Mul\n\nvariable [Zero \u03b1] [Mul \u03b1]\n\ninstance : MulZeroClass (WithTop \u03b1) where\n  zero := 0\n  mul m n := if m = 0 \u2228 n = 0 then 0 else Option.map\u2082 (\u00b7 * \u00b7) 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 \u03b1} :\n    a * b = (if a = 0 \u2228 b = 0 then 0 else Option.map\u2082 (\u00b7 * \u00b7) a b : WithTop \u03b1) :=\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 : (\u22a4 * \u22a4 : WithTop \u03b1) = \u22a4 := by simp [mul_def]; rfl\n#align with_top.top_mul_top WithTop.top_mul_top\n\ntheorem mul_top' (a : WithTop \u03b1) : a * \u22a4 = if a = 0 then 0 else \u22a4 := 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 \u03b1} (h : a \u2260 0) : a * \u22a4 = \u22a4 := by rw [mul_top', if_neg h]\n#align with_top.mul_top WithTop.mul_top\n\ntheorem top_mul' (a : WithTop \u03b1) : \u22a4 * a = if a = 0 then 0 else \u22a4 := 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 \u03b1} (h : a \u2260 0) : \u22a4 * a = \u22a4 := 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 \u03b1} : a * b = \u22a4 \u2194 a \u2260 0 \u2227 b = \u22a4 \u2228 a = \u22a4 \u2227 b \u2260 0 := by\n  rw [mul_def, ite_eq_iff, \u2190 none_eq_top, Option.map\u2082_eq_none_iff]\n  have ha : a = 0 \u2192 a \u2260 none := fun h => h.symm \u25b8 zero_ne_top\n  have hb : b = 0 \u2192 b \u2260 none := fun h => h.symm \u25b8 zero_ne_top\n  tauto\n#align with_top.mul_eq_top_iff WithTop.mul_eq_top_iff\n\ntheorem mul_lt_top' [LT \u03b1] {a b : WithTop \u03b1} (ha : a < \u22a4) (hb : b < \u22a4) : a * b < \u22a4 := 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 \u03b1] {a b : WithTop \u03b1} (ha : a \u2260 \u22a4) (hb : b \u2260 \u22a4) : a * b < \u22a4 :=\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 \u03b1] : NoZeroDivisors (WithTop \u03b1) := by\n  refine \u27e8fun h\u2081 => Decidable.by_contradiction <| fun h\u2082 => ?_\u27e9\n  rw [mul_def, if_neg h\u2082] at h\u2081\n  rcases Option.mem_map\u2082_iff.1 h\u2081 with \u27e8a, b, (rfl : _ = _), (rfl : _ = _), hab\u27e9\n  exact h\u2082 ((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 \u03b1]\n\n@[simp, norm_cast]\ntheorem coe_mul {a b : \u03b1} : (\u2191(a * b) : WithTop \u03b1) = a * b := by\n  by_cases ha : a = 0\n  \u00b7 simp [ha]\n  \u00b7 by_cases hb : b = 0\n    \u00b7 simp [hb]\n    \u00b7 simp [*, mul_def]\n      rfl\n#align with_top.coe_mul WithTop.coe_mul\n\ntheorem mul_coe {b : \u03b1} (hb : b \u2260 0) : \u2200 {a : WithTop \u03b1},\n    a * (b : WithTop \u03b1) = a.bind fun a : \u03b1 => \u2191(a * b)\n  | none =>\n    show (if (\u22a4 : WithTop \u03b1) = 0 \u2228 (b : WithTop \u03b1) = 0 then 0 else \u22a4 : WithTop \u03b1) = \u22a4 by simp [hb]\n  | Option.some a => by\n    rw [some_eq_coe, \u2190 coe_mul]\n    rfl\n#align with_top.mul_coe WithTop.mul_coe\n\n@[simp]\ntheorem untop'_zero_mul (a b : WithTop \u03b1) : (a * b).untop' 0 = a.untop' 0 * b.untop' 0 := by\n  by_cases ha : a = 0; \u00b7 rw [ha, zero_mul, \u2190 coe_zero, untop'_coe, zero_mul]\n  by_cases hb : b = 0; \u00b7 rw [hb, mul_zero, \u2190 coe_zero, untop'_coe, mul_zero]\n  induction a using WithTop.recTopCoe; \u00b7 rw [top_mul hb, untop'_top, zero_mul]\n  induction b using WithTop.recTopCoe; \u00b7 rw [mul_top ha, untop'_top, mul_zero]\n  rw [\u2190 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 \u03b1` is needed here as otherwise we have `1 * \u22a4 = \u22a4` but also `0 * \u22a4 = 0`. -/\ninstance [MulZeroOneClass \u03b1] [Nontrivial \u03b1] : MulZeroOneClass (WithTop \u03b1) :=\n  { WithTop.instMulZeroClassWithTop with\n    mul := (\u00b7 * \u00b7)\n    one := 1, zero := 0\n    one_mul := fun a =>\n      match a with\n      | \u22a4 => mul_top (mt coe_eq_coe.1 one_ne_zero)\n      | (a : \u03b1) => by rw [\u2190 coe_one, \u2190 coe_mul, one_mul],\n    mul_one := fun a =>\n      match a with\n      | \u22a4 => top_mul (mt coe_eq_coe.1 one_ne_zero)\n      | (a : \u03b1) => by rw [\u2190 coe_one, \u2190 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 \u2192*\u2080 S)\n    (hf : Function.Injective f) : WithTop R \u2192*\u2080 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 : \u2200 z, map f z = 0 \u2194 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      \u00b7 simp\n      rcases Decidable.eq_or_ne y 0 with (rfl | hy)\n      \u00b7 simp\n      induction' x using WithTop.recTopCoe with x\n      \u00b7 simp [hy, this]\n      induction' y using WithTop.recTopCoe with y\n      \u00b7 have : (f x : WithTop S) \u2260 0 := by simpa [hf.eq_iff' (map_zero f)] using hx\n        simp [mul_top hx, mul_top this]\n      \u00b7 simp only [map_coe, \u2190 coe_mul, map_mul] } -- porting note: todo: `simp [\u2190 coe_mul]` fails\n#align monoid_with_zero_hom.with_top_map MonoidWithZeroHom.withTopMap\n\ninstance [SemigroupWithZero \u03b1] [NoZeroDivisors \u03b1] : SemigroupWithZero (WithTop \u03b1) :=\n  { WithTop.instMulZeroClassWithTop with\n    mul := (\u00b7 * \u00b7)\n    zero := 0\n    mul_assoc := fun a b c => by\n      rcases eq_or_ne a 0 with (rfl | ha); \u00b7 simp only [zero_mul]\n      rcases eq_or_ne b 0 with (rfl | hb); \u00b7 simp only [zero_mul, mul_zero]\n      rcases eq_or_ne c 0 with (rfl | hc); \u00b7 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; \u00b7 simp [hb, hc]\n      induction' b using WithTop.recTopCoe with b; \u00b7 simp [mul_top ha, top_mul hc]\n      induction' c using WithTop.recTopCoe with c\n      \u00b7 rw [mul_top hb, mul_top ha]\n        rw [\u2190 coe_zero, ne_eq, coe_eq_coe] at ha hb\n        simp [ha, hb]\n      simp only [\u2190 coe_mul, mul_assoc] }\n\ninstance monoidWithZero [MonoidWithZero \u03b1] [NoZeroDivisors \u03b1] [Nontrivial \u03b1] :\n    MonoidWithZero (WithTop \u03b1) :=\n  { WithTop.instMulZeroOneClassWithTop, WithTop.instSemigroupWithZeroWithTop with }\n\ninstance commMonoidWithZero [CommMonoidWithZero \u03b1] [NoZeroDivisors \u03b1] [Nontrivial \u03b1] :\n    CommMonoidWithZero (WithTop \u03b1) :=\n  { WithTop.monoidWithZero with\n    mul := (\u00b7 * \u00b7)\n    zero := 0,\n    mul_comm := fun _ _ => ite_congr (propext or_comm) (fun _ => rfl)\n      (fun _ => Option.map\u2082_comm mul_comm) }\n\nvariable [CanonicallyOrderedCommSemiring \u03b1]\n\nprivate theorem distrib' (a b c : WithTop \u03b1) : (a + b) * c = a * c + b * c := by\n  induction' c using WithTop.recTopCoe with c\n  \u00b7 by_cases ha : a = 0 <;> simp [ha]\n  \u00b7 by_cases hc : c = 0\n    \u00b7 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 \u03b1] : CommSemiring (WithTop \u03b1) :=\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 \u03b1] : CanonicallyOrderedCommSemiring (WithTop \u03b1) :=\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 \u2192+* S) (hf : Function.Injective f) : WithTop R \u2192+* 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 \u03b1]\n\ninstance : DecidableEq (WithBot \u03b1) := instDecidableEqOption\n\nsection Mul\n\nvariable [Zero \u03b1] [Mul \u03b1]\n\ninstance : MulZeroClass (WithBot \u03b1) :=\n  WithTop.instMulZeroClassWithTop\n\ntheorem mul_def {a b : WithBot \u03b1} :\n    a * b = if a = 0 \u2228 b = 0 then (0 : WithBot \u03b1) else Option.map\u2082 (\u00b7 * \u00b7) a b :=\n  rfl\n#align with_bot.mul_def WithBot.mul_def\n\n@[simp]\ntheorem mul_bot {a : WithBot \u03b1} (h : a \u2260 0) : a * \u22a5 = \u22a5 :=\n  WithTop.mul_top h\n#align with_bot.mul_bot WithBot.mul_bot\n\n@[simp]\ntheorem bot_mul {a : WithBot \u03b1} (h : a \u2260 0) : \u22a5 * a = \u22a5 :=\n  WithTop.top_mul h\n#align with_bot.bot_mul WithBot.bot_mul\n\n@[simp]\ntheorem bot_mul_bot : (\u22a5 * \u22a5 : WithBot \u03b1) = \u22a5 :=\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 \u03b1} : a * b = \u22a5 \u2194 a \u2260 0 \u2227 b = \u22a5 \u2228 a = \u22a5 \u2227 b \u2260 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 \u03b1] {a b : WithBot \u03b1} (ha : \u22a5 < a) (hb : \u22a5 < b) : \u22a5 < a * b :=\n  WithTop.mul_lt_top' (\u03b1 := \u03b1\u1d52\u1d48) ha hb\n#align with_bot.bot_lt_mul' WithBot.bot_lt_mul'\n\ntheorem bot_lt_mul [LT \u03b1] {a b : WithBot \u03b1} (ha : a \u2260 \u22a5) (hb : b \u2260 \u22a5) : \u22a5 < a * b :=\n  WithTop.mul_lt_top (\u03b1 := \u03b1\u1d52\u1d48) ha hb\n#align with_bot.bot_lt_mul WithBot.bot_lt_mul\n\nend Mul\n\nsection MulZeroClass\n\nvariable [MulZeroClass \u03b1]\n\n@[simp, norm_cast] -- porting note: added `simp`\ntheorem coe_mul {a b : \u03b1} : (\u2191(a * b) : WithBot \u03b1) = a * b :=\n  WithTop.coe_mul\n#align with_bot.coe_mul WithBot.coe_mul\n\ntheorem mul_coe {b : \u03b1} (hb : b \u2260 0) {a : WithBot \u03b1} :\n    a * (b : WithBot \u03b1) = a.bind fun a : \u03b1 => \u2191(a * b) :=\n  WithTop.mul_coe hb\n#align with_bot.mul_coe WithBot.mul_coe\n\nend MulZeroClass\n\n/-- `Nontrivial \u03b1` is needed here as otherwise we have `1 * \u22a5 = \u22a5` but also `= 0 * \u22a5 = 0`. -/\ninstance [MulZeroOneClass \u03b1] [Nontrivial \u03b1] : MulZeroOneClass (WithBot \u03b1) :=\n  WithTop.instMulZeroOneClassWithTop\n\ninstance [MulZeroClass \u03b1] [NoZeroDivisors \u03b1] : NoZeroDivisors (WithBot \u03b1) :=\n  WithTop.noZeroDivisors\n\ninstance [SemigroupWithZero \u03b1] [NoZeroDivisors \u03b1] : SemigroupWithZero (WithBot \u03b1) :=\n  WithTop.instSemigroupWithZeroWithTop\n\ninstance [MonoidWithZero \u03b1] [NoZeroDivisors \u03b1] [Nontrivial \u03b1] : MonoidWithZero (WithBot \u03b1) :=\n  WithTop.monoidWithZero\n\ninstance commMonoidWithZero [CommMonoidWithZero \u03b1] [NoZeroDivisors \u03b1] [Nontrivial \u03b1] :\n    CommMonoidWithZero (WithBot \u03b1) :=\n  WithTop.commMonoidWithZero\n\ninstance commSemiring [CanonicallyOrderedCommSemiring \u03b1] [Nontrivial \u03b1] :\n    CommSemiring (WithBot \u03b1) :=\n  WithTop.commSemiring\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [PosMulMono \u03b1] : PosMulMono (WithBot \u03b1) :=\n  \u27e8by\n    intro \u27e8x, x0\u27e9 a b h\n    simp only [Subtype.coe_mk]\n    rcases eq_or_ne x 0 with rfl | x0'\n    \u00b7 simp\n    lift x to \u03b1\n    \u00b7 rintro rfl\n      exact (WithBot.bot_lt_coe (0 : \u03b1)).not_le x0\n    induction a using WithBot.recBotCoe\n    \u00b7 simp_rw [mul_bot x0', bot_le]\n    induction b using WithBot.recBotCoe\n    \u00b7 exact absurd h (bot_lt_coe _).not_le\n    simp only [\u2190 coe_mul, coe_le_coe] at *\n    norm_cast at x0\n    exact mul_le_mul_of_nonneg_left h x0 \u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [MulPosMono \u03b1] : MulPosMono (WithBot \u03b1) :=\n  \u27e8by\n    intro \u27e8x, x0\u27e9 a b h\n    simp only [Subtype.coe_mk]\n    rcases eq_or_ne x 0 with rfl | x0'\n    \u00b7 simp\n    lift x to \u03b1\n    \u00b7 rintro rfl\n      exact (WithBot.bot_lt_coe (0 : \u03b1)).not_le x0\n    induction a using WithBot.recBotCoe\n    \u00b7 simp_rw [bot_mul x0', bot_le]\n    induction b using WithBot.recBotCoe\n    \u00b7 exact absurd h (bot_lt_coe _).not_le\n    simp only [\u2190 coe_mul, coe_le_coe] at *\n    norm_cast at x0\n    exact mul_le_mul_of_nonneg_right h x0 \u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [PosMulStrictMono \u03b1] : PosMulStrictMono (WithBot \u03b1) :=\n  \u27e8by\n    intro \u27e8x, x0\u27e9 a b h\n    simp only [Subtype.coe_mk]\n    lift x to \u03b1 using x0.ne_bot\n    induction b using WithBot.recBotCoe\n    \u00b7 exact absurd h not_lt_bot\n    induction a using WithBot.recBotCoe\n    \u00b7 simp_rw [mul_bot x0.ne.symm, \u2190 coe_mul, bot_lt_coe]\n    simp only [\u2190 coe_mul, coe_lt_coe] at *\n    norm_cast at x0\n    exact mul_lt_mul_of_pos_left h x0 \u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [MulPosStrictMono \u03b1] : MulPosStrictMono (WithBot \u03b1) :=\n  \u27e8by\n    intro \u27e8x, x0\u27e9 a b h\n    simp only [Subtype.coe_mk]\n    lift x to \u03b1 using x0.ne_bot\n    induction b using WithBot.recBotCoe\n    \u00b7 exact absurd h not_lt_bot\n    induction a using WithBot.recBotCoe\n    \u00b7 simp_rw [bot_mul x0.ne.symm, \u2190 coe_mul, bot_lt_coe]\n    simp only [\u2190 coe_mul, coe_lt_coe] at *\n    norm_cast at x0\n    exact mul_lt_mul_of_pos_right h x0 \u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [PosMulReflectLT \u03b1] : PosMulReflectLT (WithBot \u03b1) :=\n  \u27e8by\n    intro \u27e8x, x0\u27e9 a b h\n    simp only [Subtype.coe_mk] at h\n    rcases eq_or_ne x 0 with rfl | x0'\n    \u00b7 simp at h\n    lift x to \u03b1\n    \u00b7 rintro rfl\n      exact (WithBot.bot_lt_coe (0 : \u03b1)).not_le x0\n    induction b using WithBot.recBotCoe\n    \u00b7 rw [mul_bot x0'] at h\n      exact absurd h bot_le.not_lt\n    induction a using WithBot.recBotCoe\n    \u00b7 exact WithBot.bot_lt_coe _\n    simp only [\u2190 coe_mul, coe_lt_coe] at *\n    norm_cast at x0\n    exact lt_of_mul_lt_mul_left h x0 \u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [MulPosReflectLT \u03b1] : MulPosReflectLT (WithBot \u03b1) :=\n  \u27e8by\n    intro \u27e8x, x0\u27e9 a b h\n    simp only [Subtype.coe_mk] at h\n    rcases eq_or_ne x 0 with rfl | x0'\n    \u00b7 simp at h\n    lift x to \u03b1\n    \u00b7 rintro rfl\n      exact (WithBot.bot_lt_coe (0 : \u03b1)).not_le x0\n    induction b using WithBot.recBotCoe\n    \u00b7 rw [bot_mul x0'] at h\n      exact absurd h bot_le.not_lt\n    induction a using WithBot.recBotCoe\n    \u00b7 exact WithBot.bot_lt_coe _\n    simp only [\u2190 coe_mul, coe_lt_coe] at *\n    norm_cast at x0\n    exact lt_of_mul_lt_mul_right h x0 \u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [PosMulMonoRev \u03b1] : PosMulMonoRev (WithBot \u03b1) :=\n  \u27e8by\n    intro \u27e8x, x0\u27e9 a b h\n    simp only [Subtype.coe_mk] at h\n    lift x to \u03b1 using x0.ne_bot\n    induction a using WithBot.recBotCoe\n    \u00b7 exact bot_le\n    induction b using WithBot.recBotCoe\n    \u00b7 rw [mul_bot x0.ne.symm, \u2190 coe_mul] at h\n      exact absurd h (bot_lt_coe _).not_le\n    simp only [\u2190 coe_mul, coe_le_coe] at *\n    norm_cast at x0\n    exact le_of_mul_le_mul_left h x0 \u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [MulPosMonoRev \u03b1] : MulPosMonoRev (WithBot \u03b1) :=\n  \u27e8by\n    intro \u27e8x, x0\u27e9 a b h\n    simp only [Subtype.coe_mk] at h\n    lift x to \u03b1 using x0.ne_bot\n    induction a using WithBot.recBotCoe\n    \u00b7 exact bot_le\n    induction b using WithBot.recBotCoe\n    \u00b7 rw [bot_mul x0.ne.symm, \u2190 coe_mul] at h\n      exact absurd h (bot_lt_coe _).not_le\n    simp only [\u2190 coe_mul, coe_le_coe] at *\n    norm_cast at x0\n    exact le_of_mul_le_mul_right h x0 \u27e9\n\ninstance orderedCommSemiring [CanonicallyOrderedCommSemiring \u03b1] [Nontrivial \u03b1] :\n    OrderedCommSemiring (WithBot \u03b1) :=\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\u00f6lzl, 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\u2081 u\u2082 v v\u2081 v\u2082 v\u2083 w x y l\n\nopen_locale big_operators\n\nvariables (\u03b9 : Type u) (\u03b2 : \u03b9 \u2192 Type v) {\u03b2\u2081 : \u03b9 \u2192 Type v\u2081} {\u03b2\u2082 : \u03b9 \u2192 Type v\u2082}\n\nnamespace dfinsupp\n\nvariable [\u03a0 i, has_zero (\u03b2 i)]\n\nstructure pre : Type (max u v) :=\n(to_fun : \u03a0 i, \u03b2 i)\n(pre_support : multiset \u03b9)\n(zero : \u2200 i, i \u2208 pre_support \u2228 to_fun i = 0)\n\ninstance inhabited_pre : inhabited (pre \u03b9 \u03b2) :=\n\u27e8\u27e8\u03bb i, 0, \u2205, \u03bb i, or.inr rfl\u27e9\u27e9\n\ninstance : setoid (pre \u03b9 \u03b2) :=\n{ r := \u03bb x y, \u2200 i, x.to_fun i = y.to_fun i,\n  iseqv := \u27e8\u03bb f i, rfl, \u03bb f g H i, (H i).symm,\n    \u03bb f g h H1 H2 i, (H1 i).trans (H2 i)\u27e9 }\n\nend dfinsupp\n\nvariable {\u03b9}\n/-- A dependent function `\u03a0 i, \u03b2 i` with finite support. -/\n@[reducible]\ndef dfinsupp [\u03a0 i, has_zero (\u03b2 i)] : Type* :=\nquotient (dfinsupp.pre.setoid \u03b9 \u03b2)\nvariable {\u03b2}\n\nnotation `\u03a0\u2080` binders `, ` r:(scoped f, dfinsupp f) := r\ninfix ` \u2192\u209a `:25 := dfinsupp\n\nnamespace dfinsupp\n\nsection basic\nvariables [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i, has_zero (\u03b2\u2081 i)] [\u03a0 i, has_zero (\u03b2\u2082 i)]\n\ninstance : has_coe_to_fun (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8\u03bb _, \u03a0 i, \u03b2 i, \u03bb f, quotient.lift_on f pre.to_fun $ \u03bb _ _, funext\u27e9\n\ninstance : has_zero (\u03a0\u2080 i, \u03b2 i) := \u27e8\u27e6\u27e80, \u2205, \u03bb i, or.inr rfl\u27e9\u27e7\u27e9\ninstance : inhabited (\u03a0\u2080 i, \u03b2 i) := \u27e80\u27e9\n\n@[simp] lemma coe_zero : \u21d1(0 : \u03a0\u2080 i, \u03b2 i) = 0 := rfl\nlemma zero_apply (i : \u03b9) : (0 : \u03a0\u2080 i, \u03b2 i) i = 0 := rfl\n\nlemma coe_fn_injective : @function.injective (\u03a0\u2080 i, \u03b2 i) (\u03a0 i, \u03b2 i) coe_fn :=\n\u03bb f g H, quotient.induction_on\u2082 f g (\u03bb _ _ H, quotient.sound H) (congr_fun H)\n\n@[ext] lemma ext {f g : \u03a0\u2080 i, \u03b2 i} (H : \u2200 i, f i = g i) : f = g :=\ncoe_fn_injective (funext H)\n\n/-- The composition of `f : \u03b2\u2081 \u2192 \u03b2\u2082` and `g : \u03a0\u2080 i, \u03b2\u2081 i` is\n  `map_range f hf g : \u03a0\u2080 i, \u03b2\u2082 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 : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (hf : \u2200 i, f i 0 = 0) (g : \u03a0\u2080 i, \u03b2\u2081 i) : \u03a0\u2080 i, \u03b2\u2082 i :=\nquotient.lift_on g (\u03bb x, \u27e6(\u27e8\u03bb i, f i (x.1 i), x.2,\n  \u03bb i, or.cases_on (x.3 i) or.inl $ \u03bb H, or.inr $ by rw [H, hf]\u27e9 : pre \u03b9 \u03b2\u2082)\u27e7) $ \u03bb x y H,\nquotient.sound $ \u03bb i, by simp only [H i]\n\n@[simp] lemma map_range_apply\n  (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (hf : \u2200 i, f i 0 = 0) (g : \u03a0\u2080 i, \u03b2\u2081 i) (i : \u03b9) :\n  map_range f hf g i = f i (g i) :=\nquotient.induction_on g $ \u03bb x, rfl\n\n@[simp] lemma map_range_id (h : \u2200 i, id (0 : \u03b2\u2081 i) = 0 := \u03bb i, rfl) (g : \u03a0\u2080 (i : \u03b9), \u03b2\u2081 i) :\n  map_range (\u03bb i, (id : \u03b2\u2081 i \u2192 \u03b2\u2081 i)) h g = g :=\nby { ext, simp only [map_range_apply, id.def] }\n\nlemma map_range_comp (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (f\u2082 : \u03a0 i, \u03b2 i \u2192 \u03b2\u2081 i)\n  (hf : \u2200 i, f i 0 = 0) (hf\u2082 : \u2200 i, f\u2082 i 0 = 0) (h : \u2200 i, (f i \u2218 f\u2082 i) 0 = 0)\n  (g : \u03a0\u2080 (i : \u03b9), \u03b2 i) :\n  map_range (\u03bb i, f i \u2218 f\u2082 i) h g = map_range f hf (map_range f\u2082 hf\u2082 g) :=\nby { ext, simp only [map_range_apply] }\n\n@[simp] lemma map_range_zero (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (hf : \u2200 i, f i 0 = 0) :\n  map_range f hf (0 : \u03a0\u2080 i, \u03b2\u2081 i) = 0 :=\nby { ext, simp only [map_range_apply, coe_zero, pi.zero_apply, hf] }\n\n/-- Let `f i` be a binary operation `\u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i` such that `f i 0 0 = 0`.\nThen `zip_with f hf` is a binary operation `\u03a0\u2080 i, \u03b2\u2081 i \u2192 \u03a0\u2080 i, \u03b2\u2082 i \u2192 \u03a0\u2080 i, \u03b2 i`. -/\ndef zip_with (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i) (hf : \u2200 i, f i 0 0 = 0)\n  (g\u2081 : \u03a0\u2080 i, \u03b2\u2081 i) (g\u2082 : \u03a0\u2080 i, \u03b2\u2082 i) : (\u03a0\u2080 i, \u03b2 i) :=\nbegin\n  refine quotient.lift_on\u2082 g\u2081 g\u2082 (\u03bb x y, \u27e6(\u27e8\u03bb i, f i (x.1 i) (y.1 i), x.2 + y.2,\n    \u03bb i, _\u27e9 : pre \u03b9 \u03b2)\u27e7) _,\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 \u03bb x\u2081 x\u2082 y\u2081 y\u2082 H1 H2, quotient.sound $ \u03bb i, by simp only [H1 i, H2 i]\nend\n\n@[simp] lemma zip_with_apply\n  (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i) (hf : \u2200 i, f i 0 0 = 0) (g\u2081 : \u03a0\u2080 i, \u03b2\u2081 i) (g\u2082 : \u03a0\u2080 i, \u03b2\u2082 i) (i : \u03b9) :\n  zip_with f hf g\u2081 g\u2082 i = f i (g\u2081 i) (g\u2082 i) :=\nquotient.induction_on\u2082 g\u2081 g\u2082 $ \u03bb _ _, rfl\n\nend basic\n\nsection algebra\n\ninstance [\u03a0 i, add_zero_class (\u03b2 i)] : has_add (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8zip_with (\u03bb _, (+)) (\u03bb _, add_zero 0)\u27e9\n\nlemma add_apply [\u03a0 i, add_zero_class (\u03b2 i)] (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\n  (g\u2081 + g\u2082) i = g\u2081 i + g\u2082 i :=\nzip_with_apply _ _ g\u2081 g\u2082 i\n\n@[simp] lemma coe_add [\u03a0 i, add_zero_class (\u03b2 i)] (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i) :\n  \u21d1(g\u2081 + g\u2082) = g\u2081 + g\u2082 :=\nfunext $ add_apply g\u2081 g\u2082\n\ninstance [\u03a0 i, add_zero_class (\u03b2 i)] : add_zero_class (\u03a0\u2080 i, \u03b2 i) :=\n{ zero      := 0,\n  add       := (+),\n  zero_add  := \u03bb f, ext $ \u03bb i, by simp only [add_apply, zero_apply, zero_add],\n  add_zero  := \u03bb f, ext $ \u03bb i, by simp only [add_apply, zero_apply, add_zero] }\n\ninstance [\u03a0 i, add_monoid (\u03b2 i)] : add_monoid (\u03a0\u2080 i, \u03b2 i) :=\n{ add_monoid .\n  zero      := 0,\n  add       := (+),\n  add_assoc := \u03bb f g h, ext $ \u03bb i, by simp only [add_apply, add_assoc],\n  .. dfinsupp.add_zero_class }\n\ninstance is_add_monoid_hom [\u03a0 i, add_zero_class (\u03b2 i)] {i : \u03b9} :\n  is_add_monoid_hom (\u03bb g : \u03a0\u2080 i : \u03b9, \u03b2 i, g i) :=\n{ map_add := \u03bb f g, add_apply f g i, map_zero := zero_apply i }\n\ninstance [\u03a0 i, add_group (\u03b2 i)] : has_neg (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8\u03bb f, f.map_range (\u03bb _, has_neg.neg) (\u03bb _, neg_zero)\u27e9\n\ninstance [\u03a0 i, add_comm_monoid (\u03b2 i)] : add_comm_monoid (\u03a0\u2080 i, \u03b2 i) :=\n{ add_comm := \u03bb f g, ext $ \u03bb i, by simp only [add_apply, add_comm],\n  .. dfinsupp.add_monoid }\n\nlemma neg_apply [\u03a0 i, add_group (\u03b2 i)] (g : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) : (- g) i = - g i :=\nmap_range_apply _ _ g i\n\n@[simp] lemma coe_neg [\u03a0 i, add_group (\u03b2 i)] (g : \u03a0\u2080 i, \u03b2 i) : \u21d1(- g) = - g :=\nfunext $ neg_apply g\n\ninstance [\u03a0 i, add_group (\u03b2 i)] : add_group (\u03a0\u2080 i, \u03b2 i) :=\n{ add_left_neg := \u03bb f, ext $ \u03bb i, by simp only [add_apply, neg_apply, zero_apply, add_left_neg],\n  .. dfinsupp.add_monoid,\n  .. (infer_instance : has_neg (\u03a0\u2080 i, \u03b2 i)) }\n\nlemma sub_apply [\u03a0 i, add_group (\u03b2 i)] (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\n  (g\u2081 - g\u2082) i = g\u2081 i - g\u2082 i :=\nby rw [sub_eq_add_neg]; simp [sub_eq_add_neg]\n\n@[simp] lemma coe_sub [\u03a0 i, add_group (\u03b2 i)] (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i) :\n  \u21d1(g\u2081 - g\u2082) = g\u2081 - g\u2082 :=\nfunext $ sub_apply g\u2081 g\u2082\n\ninstance [\u03a0 i, add_comm_group (\u03b2 i)] : add_comm_group (\u03a0\u2080 i, \u03b2 i) :=\n{ add_comm := \u03bb f g, ext $ \u03bb 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 {\u03b3 : Type w} [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] :\n  has_scalar \u03b3 (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8\u03bbc v, v.map_range (\u03bb _, (\u2022) c) (\u03bb _, smul_zero _)\u27e9\n\nlemma smul_apply {\u03b3 : Type w} [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)]\n  [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] (b : \u03b3) (v : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\n  (b \u2022 v) i = b \u2022 (v i) :=\nmap_range_apply _ _ v i\n\n@[simp] lemma coe_smul {\u03b3 : Type w} [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)]\n  [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] (b : \u03b3) (v : \u03a0\u2080 i, \u03b2 i) :\n  \u21d1(b \u2022 v) = b \u2022 v :=\nfunext $ smul_apply b v\n\ninstance {\u03b3 : Type w} {\u03b4 : Type*} [monoid \u03b3] [monoid \u03b4]\n  [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b4 (\u03b2 i)]\n  [\u03a0 i, smul_comm_class \u03b3 \u03b4 (\u03b2 i)] :\n  smul_comm_class \u03b3 \u03b4 (\u03a0\u2080 i, \u03b2 i) :=\n{ smul_comm := \u03bb r s m, ext $ \u03bb i, by simp only [smul_apply, smul_comm r s (m i)] }\n\ninstance {\u03b3 : Type w} {\u03b4 : Type*} [monoid \u03b3] [monoid \u03b4]\n  [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b4 (\u03b2 i)]\n  [has_scalar \u03b3 \u03b4] [\u03a0 i, is_scalar_tower \u03b3 \u03b4 (\u03b2 i)] :\n  is_scalar_tower \u03b3 \u03b4 (\u03a0\u2080 i, \u03b2 i) :=\n{ smul_assoc := \u03bb r s m, ext $ \u03bb 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 {\u03b3 : Type w} [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] :\n  distrib_mul_action \u03b3 (\u03a0\u2080 i, \u03b2 i) :=\n{ smul_zero := \u03bb c, ext $ \u03bb i, by simp only [smul_apply, smul_zero, zero_apply],\n  smul_add := \u03bb c x y, ext $ \u03bb i, by simp only [add_apply, smul_apply, smul_add],\n  one_smul := \u03bb x, ext $ \u03bb i, by simp only [smul_apply, one_smul],\n  mul_smul := \u03bb r s x, ext $ \u03bb 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 {\u03b3 : Type w} [semiring \u03b3] [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i, module \u03b3 (\u03b2 i)] :\n  module \u03b3 (\u03a0\u2080 i, \u03b2 i) :=\n{ zero_smul := \u03bb c, ext $ \u03bb i, by simp only [smul_apply, zero_smul, zero_apply],\n  add_smul := \u03bb c x y, ext $ \u03bb 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 [\u03a0 i, has_zero (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p] (f : \u03a0\u2080 i, \u03b2 i) : \u03a0\u2080 i, \u03b2 i :=\nquotient.lift_on f (\u03bb x, \u27e6(\u27e8\u03bb i, if p i then x.1 i else 0, x.2,\n  \u03bb i, or.cases_on (x.3 i) or.inl $ \u03bb H, or.inr $ by rw [H, if_t_t]\u27e9 : pre \u03b9 \u03b2)\u27e7) $ \u03bb x y H,\nquotient.sound $ \u03bb i, by simp only [H i]\n\n@[simp] lemma filter_apply [\u03a0 i, has_zero (\u03b2 i)]\n  (p : \u03b9 \u2192 Prop) [decidable_pred p] (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) :\n  f.filter p i = if p i then f i else 0 :=\nquotient.induction_on f $ \u03bb x, rfl\n\nlemma filter_apply_pos [\u03a0 i, has_zero (\u03b2 i)]\n  {p : \u03b9 \u2192 Prop} [decidable_pred p] (f : \u03a0\u2080 i, \u03b2 i) {i : \u03b9} (h : p i) :\n  f.filter p i = f i :=\nby simp only [filter_apply, if_pos h]\n\nlemma filter_apply_neg [\u03a0 i, has_zero (\u03b2 i)]\n  {p : \u03b9 \u2192 Prop} [decidable_pred p] (f : \u03a0\u2080 i, \u03b2 i) {i : \u03b9} (h : \u00ac p i) :\n  f.filter p i = 0 :=\nby simp only [filter_apply, if_neg h]\n\nlemma filter_pos_add_filter_neg [\u03a0 i, add_zero_class (\u03b2 i)] (f : \u03a0\u2080 i, \u03b2 i)\n  (p : \u03b9 \u2192 Prop) [decidable_pred p] :\n  f.filter p + f.filter (\u03bbi, \u00ac p i) = f :=\next $ \u03bb 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 [\u03a0 i, has_zero (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p]\n  (f : \u03a0\u2080 i, \u03b2 i) : \u03a0\u2080 i : subtype p, \u03b2 i :=\nbegin\n  fapply quotient.lift_on f,\n  { intro x,\n    refine \u27e6\u27e8\u03bb i, x.1 (i : \u03b9),\n      (x.2.filter p).attach.map $ \u03bb j, \u27e8j, (multiset.mem_filter.1 j.2).2\u27e9, _\u27e9\u27e7,\n    refine \u03bb i, or.cases_on (x.3 i) (\u03bb H, _) or.inr,\n    left, rw multiset.mem_map, refine \u27e8\u27e8i, multiset.mem_filter.2 \u27e8H, i.2\u27e9\u27e9, _, subtype.eta _ _\u27e9,\n    apply multiset.mem_attach },\n  intros x y H,\n  exact quotient.sound (\u03bb i, H i)\nend\n\n@[simp] lemma subtype_domain_zero [\u03a0 i, has_zero (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p] :\n  subtype_domain p (0 : \u03a0\u2080 i, \u03b2 i) = 0 :=\nrfl\n\n@[simp] lemma subtype_domain_apply [\u03a0 i, has_zero (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {i : subtype p} {v : \u03a0\u2080 i, \u03b2 i} :\n  (subtype_domain p v) i = v i :=\nquotient.induction_on v $ \u03bb x, rfl\n\n@[simp] lemma subtype_domain_add [\u03a0 i, add_zero_class (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {v v' : \u03a0\u2080 i, \u03b2 i} :\n  (v + v').subtype_domain p = v.subtype_domain p + v'.subtype_domain p :=\next $ \u03bb i, by simp only [add_apply, subtype_domain_apply]\n\ninstance subtype_domain.is_add_monoid_hom [\u03a0 i, add_zero_class (\u03b2 i)]\n  {p : \u03b9 \u2192 Prop} [decidable_pred p] :\n  is_add_monoid_hom (subtype_domain p : (\u03a0\u2080 i : \u03b9, \u03b2 i) \u2192 \u03a0\u2080 i : subtype p, \u03b2 i) :=\n{ map_add := \u03bb _ _, subtype_domain_add, map_zero := subtype_domain_zero }\n\n@[simp]\nlemma subtype_domain_neg [\u03a0 i, add_group (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p] {v : \u03a0\u2080 i, \u03b2 i} :\n  (- v).subtype_domain p = - v.subtype_domain p :=\next $ \u03bb i, by simp only [neg_apply, subtype_domain_apply]\n\n@[simp] lemma subtype_domain_sub [\u03a0 i, add_group (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {v v' : \u03a0\u2080 i, \u03b2 i} :\n  (v - v').subtype_domain p = v.subtype_domain p - v'.subtype_domain p :=\next $ \u03bb i, by simp only [sub_apply, subtype_domain_apply]\n\nend filter_and_subtype_domain\n\n\nvariable [dec : decidable_eq \u03b9]\ninclude dec\n\nsection basic\nvariable [\u03a0 i, has_zero (\u03b2 i)]\n\nomit dec\nlemma finite_support (f : \u03a0\u2080 i, \u03b2 i) : set.finite {i | f i \u2260 0} :=\nbegin\n  classical,\n  exact quotient.induction_on f (\u03bb x, x.2.to_finset.finite_to_set.subset (\u03bb i H,\n    multiset.mem_to_finset.2 ((x.3 i).resolve_right H)))\nend\ninclude dec\n\n/-- Create an element of `\u03a0\u2080 i, \u03b2 i` from a finset `s` and a function `x`\ndefined on this `finset`. -/\ndef mk (s : finset \u03b9) (x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 (i : \u03b9)) : \u03a0\u2080 i, \u03b2 i :=\n\u27e6\u27e8\u03bb i, if H : i \u2208 s then x \u27e8i, H\u27e9 else 0, s.1,\n\u03bb i, if H : i \u2208 s then or.inl H else or.inr $ dif_neg H\u27e9\u27e7\n\n@[simp] lemma mk_apply {s : finset \u03b9} {x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i} {i : \u03b9} :\n  (mk s x : \u03a0 i, \u03b2 i) i = if H : i \u2208 s then x \u27e8i, H\u27e9 else 0 :=\nrfl\n\ntheorem mk_injective (s : finset \u03b9) : function.injective (@mk \u03b9 \u03b2 _ _ s) :=\nbegin\n  intros x y H,\n  ext i,\n  have h1 : (mk s x : \u03a0 i, \u03b2 i) i = (mk s y : \u03a0 i, \u03b2 i) i, {rw H},\n  cases i with i hi,\n  change i \u2208 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 : \u03a0\u2080 i, \u03b2 i` sends `i` to `b`\nand all other points to `0`. -/\ndef single (i : \u03b9) (b : \u03b2 i) : \u03a0\u2080 i, \u03b2 i :=\nmk {i} $ \u03bb 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 : \u03a0\u2080 i, \u03b2 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' \u2208 ({i} : finset \u03b9) := finset.mem_singleton.2 h.symm,\n    simp only [mk_apply, dif_pos h, dif_pos h1], refl },\n  { have h1 : i' \u2209 ({i} : finset \u03b9) := 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 : \u03a0\u2080 i, \u03b2 i) = 0 :=\nquotient.sound $ \u03bb j, if H : j \u2208 ({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 : \u03a0\u2080 i, \u03b2 i) i = b :=\nby simp only [single_apply, dif_pos rfl]\n\nlemma single_eq_of_ne {i i' b} (h : i \u2260 i') : (single i b : \u03a0\u2080 i, \u03b2 i) i' = 0 :=\nby simp only [single_apply, dif_neg h]\n\nlemma single_injective {i} : function.injective (single i : \u03b2 i \u2192 \u03a0\u2080 i, \u03b2 i) :=\n\u03bb x y H, congr_fun (mk_injective _ H) \u27e8i, by simp\u27e9\n\n/-- Like `finsupp.single_eq_single_iff`, but with a `heq` due to dependent types -/\nlemma single_eq_single_iff (i j : \u03b9) (xi : \u03b2 i) (xj : \u03b2 j) :\n  dfinsupp.single i xi = dfinsupp.single j xj \u2194 i = j \u2227 xi == xj \u2228 xi = 0 \u2227 xj = 0 :=\nbegin\n  split,\n  { intro h,\n    by_cases hij : i = j,\n    { subst hij,\n      exact or.inl \u27e8rfl, heq_of_eq (dfinsupp.single_injective h)\u27e9, },\n    { have h_coe : \u21d1(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 \u27e8hci, hcj.symm\u27e9, }, },\n  { rintros (\u27e8hi, hxi\u27e9 | \u27e8hi, hj\u27e9),\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 : \u03b2 i} {xj : \u03b2 j} (h : (\u27e8i, xi\u27e9 : sigma \u03b2) = \u27e8j, xj\u27e9) :\n  dfinsupp.single i xi = dfinsupp.single j xj :=\nby { cases h, refl }\n\n/-- Redefine `f i` to be `0`. -/\ndef erase (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) : \u03a0\u2080 i, \u03b2 i :=\nquotient.lift_on f (\u03bb x, \u27e6(\u27e8\u03bb j, if j = i then 0 else x.1 j, x.2,\n\u03bb j, or.cases_on (x.3 j) or.inl $ \u03bb H, or.inr $ by simp only [H, if_t_t]\u27e9 : pre \u03b9 \u03b2)\u27e7) $ \u03bb x y H,\nquotient.sound $ \u03bb 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 : \u03b9} {f : \u03a0\u2080 i, \u03b2 i} :\n  (f.erase i) j = if j = i then 0 else f j :=\nquotient.induction_on f $ \u03bb x, rfl\n\n@[simp] lemma erase_same {i : \u03b9} {f : \u03a0\u2080 i, \u03b2 i} : (f.erase i) i = 0 :=\nby simp\n\nlemma erase_ne {i i' : \u03b9} {f : \u03a0\u2080 i, \u03b2 i} (h : i' \u2260 i) : (f.erase i) i' = f i' :=\nby simp [h]\n\nend basic\n\nsection add_monoid\n\nvariable [\u03a0 i, add_zero_class (\u03b2 i)]\n\n@[simp] lemma single_add {i : \u03b9} {b\u2081 b\u2082 : \u03b2 i} : single i (b\u2081 + b\u2082) = single i b\u2081 + single i b\u2082 :=\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 (\u03b2)\n\n/-- `dfinsupp.single` as an `add_monoid_hom`. -/\n@[simps] def single_add_hom (i : \u03b9) : \u03b2 i \u2192+ \u03a0\u2080 i, \u03b2 i :=\n{ to_fun := single i, map_zero' := single_zero, map_add' := \u03bb _ _, single_add }\n\nvariables {\u03b2}\n\nlemma single_add_erase {i : \u03b9} {f : \u03a0\u2080 i, \u03b2 i} : single i (f i) + f.erase i = f :=\next $ \u03bb 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 : \u03b9} {f : \u03a0\u2080 i, \u03b2 i} : f.erase i + single i (f i) = f :=\next $ \u03bb 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 : (\u03a0\u2080 i, \u03b2 i) \u2192 Prop} (f : \u03a0\u2080 i, \u03b2 i)\n  (h0 : p 0) (ha : \u2200i b (f : \u03a0\u2080 i, \u03b2 i), f i = 0 \u2192 b \u2260 0 \u2192 p f \u2192 p (single i b + f)) :\n  p f :=\nbegin\n  refine quotient.induction_on f (\u03bb 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 \u2208 s,\n  { have H2 : \u2200 j, j \u2208 s \u2228 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 : (\u27e6{to_fun := f, pre_support := i ::\u2098 s, zero := H}\u27e7 : \u03a0\u2080 i, \u03b2 i)\n      = \u27e6{to_fun := f, pre_support := s, zero := H2}\u27e7,\n    { exact quotient.sound (\u03bb i, rfl) },\n    rw H3, apply ih },\n  have H2 : p (erase i \u27e6{to_fun := f, pre_support := i ::\u2098 s, zero := H}\u27e7),\n  { dsimp only [erase, quotient.lift_on_mk],\n    have H2 : \u2200 j, j \u2208 s \u2228 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 : (\u27e6{to_fun := \u03bb (j : \u03b9), ite (j = i) 0 (f j),\n         pre_support := i ::\u2098 s, zero := _}\u27e7 : \u03a0\u2080 i, \u03b2 i)\n      = \u27e6{to_fun := \u03bb (j : \u03b9), ite (j = i) 0 (f j), pre_support := s, zero := H2}\u27e7 :=\n      quotient.sound (\u03bb i, rfl),\n    rw H3, apply ih },\n  have H3 : single i _ + _ = (\u27e6{to_fun := f, pre_support := i ::\u2098 s, zero := H}\u27e7 : \u03a0\u2080 i, \u03b2 i) :=\n    single_add_erase,\n  rw \u2190 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\u2082 {p : (\u03a0\u2080 i, \u03b2 i) \u2192 Prop} (f : \u03a0\u2080 i, \u03b2 i)\n  (h0 : p 0) (ha : \u2200i b (f : \u03a0\u2080 i, \u03b2 i), f i = 0 \u2192 b \u2260 0 \u2192 p f \u2192 p (f + single i b)) :\n  p f :=\ndfinsupp.induction f h0 $ \u03bb 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 (\u22c3 i : \u03b9, set.range (single i : \u03b2 i \u2192 (\u03a0\u2080 i, \u03b2 i))) = \u22a4 :=\ntop_unique $ \u03bb x hx, (begin\n  apply dfinsupp.induction x,\n  exact add_submonoid.zero_mem _,\n  exact \u03bb a b f ha hb hf, add_submonoid.add_mem _\n    (add_submonoid.subset_closure $ set.mem_Union.2 \u27e8a, set.mem_range_self _\u27e9) hf\nend)\n\n/-- If two additive homomorphisms from `\u03a0\u2080 i, \u03b2 i` are equal on each `single a b`, then\nthey are equal. -/\nlemma add_hom_ext {\u03b3 : Type w} [add_zero_class \u03b3] \u2983f g : (\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b3\u2984\n  (H : \u2200 (i : \u03b9) (y : \u03b2 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 (\u03bb f hf, _),\n  simp only [set.mem_Union, set.mem_range] at hf,\n  rcases hf with \u27e8x, y, rfl\u27e9,\n  apply H\nend\n\n/-- If two additive homomorphisms from `\u03a0\u2080 i, \u03b2 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' {\u03b3 : Type w} [add_zero_class \u03b3] \u2983f g : (\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b3\u2984\n  (H : \u2200 x, f.comp (single_add_hom \u03b2 x) = g.comp (single_add_hom \u03b2 x)) :\n  f = g :=\nadd_hom_ext $ \u03bb x, add_monoid_hom.congr_fun (H x)\n\nend add_monoid\n\n@[simp] lemma mk_add [\u03a0 i, add_zero_class (\u03b2 i)] {s : finset \u03b9} {x y : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i} :\n  mk s (x + y) = mk s x + mk s y :=\next $ \u03bb i, by simp only [add_apply, mk_apply]; split_ifs; [refl, rw zero_add]\n\n@[simp] lemma mk_zero [\u03a0 i, has_zero (\u03b2 i)] {s : finset \u03b9} :\n  mk s (0 : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1) = 0 :=\next $ \u03bb i, by simp only [mk_apply]; split_ifs; refl\n\n@[simp] lemma mk_neg [\u03a0 i, add_group (\u03b2 i)] {s : finset \u03b9} {x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1} :\n  mk s (-x) = -mk s x :=\next $ \u03bb i, by simp only [neg_apply, mk_apply]; split_ifs; [refl, rw neg_zero]\n\n@[simp] lemma mk_sub [\u03a0 i, add_group (\u03b2 i)] {s : finset \u03b9} {x y : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1} :\n  mk s (x - y) = mk s x - mk s y :=\next $ \u03bb i, by simp only [sub_apply, mk_apply]; split_ifs; [refl, rw sub_zero]\n\ninstance [\u03a0 i, add_group (\u03b2 i)] {s : finset \u03b9} : is_add_group_hom (@mk \u03b9 \u03b2 _ _ s) :=\n{ map_add := \u03bb _ _, mk_add }\n\nsection\nvariables (\u03b3 : Type w) [semiring \u03b3] [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i, module \u03b3 (\u03b2 i)]\ninclude \u03b3\n\n@[simp] lemma mk_smul {s : finset \u03b9} {c : \u03b3} (x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1) :\n  mk s (c \u2022 x) = c \u2022 mk s x :=\next $ \u03bb i, by simp only [smul_apply, mk_apply]; split_ifs; [refl, rw smul_zero]\n\n@[simp] lemma single_smul {i : \u03b9} {c : \u03b3} {x : \u03b2 i} :\n  single i (c \u2022 x) = c \u2022 single i x :=\next $ \u03bb i, by simp only [smul_apply, single_apply]; split_ifs; [cases h, rw smul_zero]; refl\n\nend\n\nsection support_basic\n\nvariables [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n\n/-- Set `{i | f x \u2260 0}` as a `finset`. -/\ndef support (f : \u03a0\u2080 i, \u03b2 i) : finset \u03b9 :=\nquotient.lift_on f (\u03bb x, x.2.to_finset.filter $ \u03bb i, x.1 i \u2260 0) $\nbegin\n  intros x y Hxy,\n  ext i, split,\n  { intro H,\n    rcases finset.mem_filter.1 H with \u27e8h1, h2\u27e9,\n    rw Hxy i at h2,\n    exact finset.mem_filter.2 \u27e8multiset.mem_to_finset.2 $ (y.3 i).resolve_right h2, h2\u27e9 },\n  { intro H,\n    rcases finset.mem_filter.1 H with \u27e8h1, h2\u27e9,\n    rw \u2190 Hxy i at h2,\n    exact finset.mem_filter.2 \u27e8multiset.mem_to_finset.2 $ (x.3 i).resolve_right h2, h2\u27e9 },\nend\n\n@[simp] theorem support_mk_subset {s : finset \u03b9} {x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1} :\n  (mk s x).support \u2286 s :=\n\u03bb i H, multiset.mem_to_finset.1 (finset.mem_filter.1 H).1\n\n@[simp] theorem mem_support_to_fun (f : \u03a0\u2080 i, \u03b2 i) (i) : i \u2208 f.support \u2194 f i \u2260 0 :=\nbegin\n  refine quotient.induction_on f (\u03bb 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 : \u03a0\u2080 i, \u03b2 i) : f = mk f.support (\u03bb i, f i) :=\nbegin\n  change f = mk f.support (\u03bb i, f i.1),\n  ext i,\n  by_cases h : f i \u2260 0; [skip, rw [not_not] at h];\n    simp [h]\nend\n\n@[simp] lemma support_zero : (0 : \u03a0\u2080 i, \u03b2 i).support = \u2205 := rfl\n\nlemma mem_support_iff (f : \u03a0\u2080 i, \u03b2 i) : \u2200i:\u03b9, i \u2208 f.support \u2194 f i \u2260 0 :=\nf.mem_support_to_fun\n\n@[simp] lemma support_eq_empty {f : \u03a0\u2080 i, \u03b2 i} : f.support = \u2205 \u2194 f = 0 :=\n\u27e8\u03bb H, ext $ by simpa [finset.ext_iff] using H, by simp {contextual:=tt}\u27e9\n\ninstance decidable_zero : decidable_pred (eq (0 : \u03a0\u2080 i, \u03b2 i)) :=\n\u03bb f, decidable_of_iff _ $ support_eq_empty.trans eq_comm\n\nlemma support_subset_iff {s : set \u03b9} {f : \u03a0\u2080 i, \u03b2 i} :\n  \u2191f.support \u2286 s \u2194 (\u2200i\u2209s, f i = 0) :=\nby simp [set.subset_def];\n   exact forall_congr (assume i, not_imp_comm)\n\nlemma support_single_ne_zero {i : \u03b9} {b : \u03b2 i} (hb : b \u2260 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 : \u03b9} {b : \u03b2 i} : (single i b).support \u2286 {i} :=\nsupport_mk_subset\n\nsection map_range_and_zip_with\n\nvariables [\u03a0 i, has_zero (\u03b2\u2081 i)] [\u03a0 i, has_zero (\u03b2\u2082 i)]\n\nlemma map_range_def [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i} {hf : \u2200 i, f i 0 = 0} {g : \u03a0\u2080 i, \u03b2\u2081 i} :\n  map_range f hf g = mk g.support (\u03bb i, f i.1 (g i.1)) :=\nbegin\n  ext i,\n  by_cases h : g i \u2260 0; simp at h; simp [h, hf]\nend\n\n@[simp] lemma map_range_single {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i} {hf : \u2200 i, f i 0 = 0} {i : \u03b9} {b : \u03b2\u2081 i} :\n  map_range f hf (single i b) = single i (f i b) :=\ndfinsupp.ext $ \u03bb i', by by_cases i = i'; [{subst i', simp}, simp [h, hf]]\n\nvariables [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)] [\u03a0 i (x : \u03b2\u2082 i), decidable (x \u2260 0)]\n\nlemma support_map_range {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i} {hf : \u2200 i, f i 0 = 0} {g : \u03a0\u2080 i, \u03b2\u2081 i} :\n  (map_range f hf g).support \u2286 g.support :=\nby simp [map_range_def]\n\nlemma zip_with_def {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i} {hf : \u2200 i, f i 0 0 = 0}\n  {g\u2081 : \u03a0\u2080 i, \u03b2\u2081 i} {g\u2082 : \u03a0\u2080 i, \u03b2\u2082 i} :\n  zip_with f hf g\u2081 g\u2082 = mk (g\u2081.support \u222a g\u2082.support) (\u03bb i, f i.1 (g\u2081 i.1) (g\u2082 i.1)) :=\nbegin\n  ext i,\n  by_cases h1 : g\u2081 i \u2260 0; by_cases h2 : g\u2082 i \u2260 0;\n    simp only [not_not, ne.def] at h1 h2; simp [h1, h2, hf]\nend\n\nlemma support_zip_with {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i} {hf : \u2200 i, f i 0 0 = 0}\n  {g\u2081 : \u03a0\u2080 i, \u03b2\u2081 i} {g\u2082 : \u03a0\u2080 i, \u03b2\u2082 i} :\n  (zip_with f hf g\u2081 g\u2082).support \u2286 g\u2081.support \u222a g\u2082.support :=\nby simp [zip_with_def]\n\nend map_range_and_zip_with\n\nlemma erase_def (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) :\n  f.erase i = mk (f.support.erase i) (\u03bb j, f j.1) :=\nby { ext j, by_cases h1 : j = i; by_cases h2 : f j \u2260 0; simp at h2; simp [h1, h2] }\n\n@[simp] lemma support_erase (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) :\n  (f.erase i).support = f.support.erase i :=\nby { ext j, by_cases h1 : j = i; by_cases h2 : f j \u2260 0; simp at h2; simp [h1, h2] }\n\nsection filter_and_subtype_domain\n\nvariables {p : \u03b9 \u2192 Prop} [decidable_pred p]\n\nlemma filter_def (f : \u03a0\u2080 i, \u03b2 i) :\n  f.filter p = mk (f.support.filter p) (\u03bb i, f i.1) :=\nby ext i; by_cases h1 : p i; by_cases h2 : f i \u2260 0;\n simp at h2; simp [h1, h2]\n\n@[simp] lemma support_filter (f : \u03a0\u2080 i, \u03b2 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 : \u03a0\u2080 i, \u03b2 i) :\n  f.subtype_domain p = mk (f.support.subtype p) (\u03bb i, f i) :=\nby ext i; by_cases h1 : p i; by_cases h2 : f i \u2260 0;\ntry {simp at h2}; dsimp; simp [h1, h2, \u2190 subtype.val_eq_coe]\n\n@[simp] lemma support_subtype_domain {f : \u03a0\u2080 i, \u03b2 i} :\n  (subtype_domain p f).support = f.support.subtype p :=\nby ext i; by_cases h1 : p i; by_cases h2 : f i \u2260 0;\ntry {simp at h2}; dsimp; simp [h1, h2]\n\nend filter_and_subtype_domain\n\nend support_basic\n\nlemma support_add [\u03a0 i, add_zero_class (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  {g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i} :\n  (g\u2081 + g\u2082).support \u2286 g\u2081.support \u222a g\u2082.support :=\nsupport_zip_with\n\n@[simp] lemma support_neg [\u03a0 i, add_group (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  {f : \u03a0\u2080 i, \u03b2 i} :\n  support (-f) = support f :=\nby ext i; simp\n\nlemma support_smul {\u03b3 : Type w} [semiring \u03b3] [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i, module \u03b3 (\u03b2 i)]\n  [\u03a0 ( i : \u03b9) (x : \u03b2 i), decidable (x \u2260 0)]\n  (b : \u03b3) (v : \u03a0\u2080 i, \u03b2 i) : (b \u2022 v).support \u2286 v.support :=\nsupport_map_range\n\ninstance [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i, decidable_eq (\u03b2 i)] : decidable_eq (\u03a0\u2080 i, \u03b2 i) :=\nassume f g, decidable_of_iff (f.support = g.support \u2227 (\u2200i\u2208f.support, f i = g i))\n  \u27e8assume \u27e8h\u2081, h\u2082\u27e9, ext $ assume i,\n      if h : i \u2208 f.support then h\u2082 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\u2081, g.mem_support_iff, not_not] at h,\n        by rw [hf, hg],\n    by intro h; subst h; simp\u27e9\n\nsection prod_and_sum\n\nvariables {\u03b3 : 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 [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] [add_comm_monoid \u03b3]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 \u03b3) : \u03b3 :=\n\u2211 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 [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 \u03b3) : \u03b3 :=\n\u220f i in f.support, g i (f i)\n\n@[to_additive]\nlemma prod_map_range_index {\u03b2\u2081 : \u03b9 \u2192 Type v\u2081} {\u03b2\u2082 : \u03b9 \u2192 Type v\u2082}\n  [\u03a0 i, has_zero (\u03b2\u2081 i)] [\u03a0 i, has_zero (\u03b2\u2082 i)]\n  [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)] [\u03a0 i (x : \u03b2\u2082 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i} {hf : \u2200 i, f i 0 = 0} {g : \u03a0\u2080 i, \u03b2\u2081 i} {h : \u03a0 i, \u03b2\u2082 i \u2192 \u03b3}\n  (h0 : \u2200i, h i 0 = 1) :\n  (map_range f hf g).prod h = g.prod (\u03bbi 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 [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {h : \u03a0 i, \u03b2 i \u2192 \u03b3} : (0 : \u03a0\u2080 i, \u03b2 i).prod h = 1 :=\nrfl\n\n@[to_additive]\nlemma prod_single_index [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  {i : \u03b9} {b : \u03b2 i} {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_zero : h i 0 = 1) :\n  (single i b).prod h = h i b :=\nbegin\n  by_cases h : b \u2260 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 [\u03a0 i, add_group (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  {g : \u03a0\u2080 i, \u03b2 i} {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h0 : \u2200i, h i 0 = 1) :\n  (-g).prod h = g.prod (\u03bbi b, h i (- b)) :=\nprod_map_range_index h0\n\nomit dec\n@[to_additive]\nlemma prod_comm {\u03b9\u2081 \u03b9\u2082 : Sort*} {\u03b2\u2081 : \u03b9\u2081 \u2192 Type*} {\u03b2\u2082 : \u03b9\u2082 \u2192 Type*}\n  [decidable_eq \u03b9\u2081] [decidable_eq \u03b9\u2082] [\u03a0 i, has_zero (\u03b2\u2081 i)] [\u03a0 i, has_zero (\u03b2\u2082 i)]\n  [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)] [\u03a0 i (x : \u03b2\u2082 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  (f\u2081 : \u03a0\u2080 i, \u03b2\u2081 i) (f\u2082 : \u03a0\u2080 i, \u03b2\u2082 i) (h : \u03a0 i, \u03b2\u2081 i \u2192 \u03a0 i, \u03b2\u2082 i \u2192 \u03b3) :\n  f\u2081.prod (\u03bb i\u2081 x\u2081, f\u2082.prod $ \u03bb i\u2082 x\u2082, h i\u2081 x\u2081 i\u2082 x\u2082) =\n  f\u2082.prod (\u03bb i\u2082 x\u2082, f\u2081.prod $ \u03bb i\u2081 x\u2081, h i\u2081 x\u2081 i\u2082 x\u2082) := finset.prod_comm\n\n@[simp] lemma sum_apply {\u03b9\u2081 : Type u\u2081} [decidable_eq \u03b9\u2081] {\u03b2\u2081 : \u03b9\u2081 \u2192 Type v\u2081}\n  [\u03a0 i\u2081, has_zero (\u03b2\u2081 i\u2081)] [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  {f : \u03a0\u2080 i\u2081, \u03b2\u2081 i\u2081} {g : \u03a0 i\u2081, \u03b2\u2081 i\u2081 \u2192 \u03a0\u2080 i, \u03b2 i} {i\u2082 : \u03b9} :\n  (f.sum g) i\u2082 = f.sum (\u03bbi\u2081 b, g i\u2081 b i\u2082) :=\n(f.support.sum_hom (\u03bbf : \u03a0\u2080 i, \u03b2 i, f i\u2082)).symm\ninclude dec\n\nlemma support_sum {\u03b9\u2081 : Type u\u2081} [decidable_eq \u03b9\u2081] {\u03b2\u2081 : \u03b9\u2081 \u2192 Type v\u2081}\n  [\u03a0 i\u2081, has_zero (\u03b2\u2081 i\u2081)] [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  {f : \u03a0\u2080 i\u2081, \u03b2\u2081 i\u2081} {g : \u03a0 i\u2081, \u03b2\u2081 i\u2081 \u2192 \u03a0\u2080 i, \u03b2 i} :\n  (f.sum g).support \u2286 f.support.bUnion (\u03bbi, (g i (f i)).support) :=\nhave \u2200i\u2081 : \u03b9, f.sum (\u03bb (i : \u03b9\u2081) (b : \u03b2\u2081 i), (g i b) i\u2081) \u2260 0 \u2192\n    (\u2203 (i : \u03b9\u2081), f i \u2260 0 \u2227 \u00ac (g i (f i)) i\u2081 = 0),\n  from assume i\u2081 h,\n  let \u27e8i, hi, ne\u27e9 := finset.exists_ne_zero_of_sum_ne_zero h in\n  \u27e8i, (f.mem_support_iff i).mp hi, ne\u27e9,\nby simpa [finset.subset_iff, mem_support_iff, finset.mem_bUnion, sum_apply] using this\n\n@[simp, to_additive] lemma prod_one [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {f : \u03a0\u2080 i, \u03b2 i} :\n  f.prod (\u03bbi b, (1 : \u03b3)) = 1 :=\nfinset.prod_const_one\n\n@[simp, to_additive] lemma prod_mul [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {f : \u03a0\u2080 i, \u03b2 i} {h\u2081 h\u2082 : \u03a0 i, \u03b2 i \u2192 \u03b3} :\n  f.prod (\u03bbi b, h\u2081 i b * h\u2082 i b) = f.prod h\u2081 * f.prod h\u2082 :=\nfinset.prod_mul_distrib\n\n@[simp, to_additive] lemma prod_inv [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_group \u03b3] {f : \u03a0\u2080 i, \u03b2 i} {h : \u03a0 i, \u03b2 i \u2192 \u03b3} :\n  f.prod (\u03bbi b, (h i b)\u207b\u00b9) = (f.prod h)\u207b\u00b9 :=\nf.support.prod_hom (@has_inv.inv \u03b3 _)\n\n@[to_additive]\nlemma prod_add_index [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {f g : \u03a0\u2080 i, \u03b2 i}\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_zero : \u2200i, h i 0 = 1) (h_add : \u2200i b\u2081 b\u2082, h i (b\u2081 + b\u2082) = h i b\u2081 * h i b\u2082) :\n  (f + g).prod h = f.prod h * g.prod h :=\nhave f_eq : \u220f i in f.support \u222a 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 : \u220f i in f.support \u222a 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 \u220f i in (f + g).support, h i ((f + g) i) =\n      \u220f i in f.support \u222a g.support, h i ((f + g) i) :\n    finset.prod_subset support_add $\n      by simp [mem_support_iff, h_zero] {contextual := tt}\n  ... = (\u220f i in f.support \u222a g.support, h i (f i)) *\n      (\u220f i in f.support \u222a 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3] (\u03c6 : \u03a0 i, \u03b2 i \u2192+ \u03b3) :\n  (\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b3 :=\n{ to_fun := (\u03bb f,\n    quotient.lift_on f (\u03bb x, \u2211 i in x.2.to_finset, \u03c6 i (x.1 i)) $ \u03bb x y H,\n    begin\n      have H1 : x.2.to_finset \u2229 y.2.to_finset \u2286 x.2.to_finset, from finset.inter_subset_left _ _,\n      have H2 : x.2.to_finset \u2229 y.2.to_finset \u2286 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 \u2190 H i,\n        simp only [multiset.mem_to_finset] at H1 H2,\n        rw [(x.3 i).resolve_left (mt (\u03bb 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 (\u03bb x, _),\n    refine quotient.induction_on g (\u03bb y, _),\n    change \u2211 i in _, _ = (\u2211 i in _, _) + (\u2211 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (\u03c6 : \u03a0 i, \u03b2 i \u2192+ \u03b3) (i) (x : \u03b2 i) : sum_add_hom \u03c6 (single i x) = \u03c6 i x :=\n(add_zero _).trans $ congr_arg (\u03c6 i) $ show (if H : i \u2208 ({i} : finset _) then x else 0) = x,\nfrom dif_pos $ finset.mem_singleton_self i\n\n@[simp] lemma sum_add_hom_comp_single [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) (i : \u03b9) :\n  (sum_add_hom f).comp (single_add_hom \u03b2 i) = f i :=\nadd_monoid_hom.ext $ \u03bb 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 [\u03a0 i, add_zero_class (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [add_comm_monoid \u03b3] (\u03c6 : \u03a0 i, \u03b2 i \u2192+ \u03b3) (f : \u03a0\u2080 i, \u03b2 i) :\n  sum_add_hom \u03c6 f = f.sum (\u03bb x, \u03c6 x) :=\nbegin\n  refine quotient.induction_on f (\u03bb x, _),\n  change \u2211 i in _, _ = (\u2211 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 {\u03b9\u2081 \u03b9\u2082 : Sort*} {\u03b2\u2081 : \u03b9\u2081 \u2192 Type*} {\u03b2\u2082 : \u03b9\u2082 \u2192 Type*} {\u03b3 : Type*}\n  [decidable_eq \u03b9\u2081] [decidable_eq \u03b9\u2082] [\u03a0 i, add_zero_class (\u03b2\u2081 i)] [\u03a0 i, add_zero_class (\u03b2\u2082 i)]\n  [add_comm_monoid \u03b3]\n  (f\u2081 : \u03a0\u2080 i, \u03b2\u2081 i) (f\u2082 : \u03a0\u2080 i, \u03b2\u2082 i) (h : \u03a0 i j, \u03b2\u2081 i \u2192+ \u03b2\u2082 j \u2192+ \u03b3) :\n  sum_add_hom (\u03bb i\u2082, sum_add_hom (\u03bb i\u2081, h i\u2081 i\u2082) f\u2081) f\u2082 =\n  sum_add_hom (\u03bb i\u2081, sum_add_hom (\u03bb i\u2082, (h i\u2081 i\u2082).flip) f\u2082) f\u2081 :=\nbegin\n  refine quotient.induction_on\u2082 f\u2081 f\u2082 (\u03bb x\u2081 x\u2082, _),\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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3] :\n  (\u03a0 i, \u03b2 i \u2192+ \u03b3) \u2243+ ((\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b3) :=\n{ to_fun := sum_add_hom,\n  inv_fun := \u03bb F i, F.comp (single_add_hom \u03b2 i),\n  left_inv := \u03bb x, by { ext, simp },\n  right_inv := \u03bb \u03c8, by { ext, simp },\n  map_add' := \u03bb 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 [\u03a0 i, add_comm_monoid (\u03b2 i)] :\n  lift_add_hom (single_add_hom \u03b2) = add_monoid_hom.id (\u03a0\u2080 i, \u03b2 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) (i : \u03b9) (x : \u03b2 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) (i : \u03b9) :\n  (lift_add_hom f).comp (single_add_hom \u03b2 i) = f i :=\nby simp\n\n/-- The `dfinsupp` version of `finsupp.comp_lift_add_hom`,-/\nlemma comp_lift_add_hom {\u03b4 : Type*} [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  [add_comm_monoid \u03b4] (g : \u03b3 \u2192+ \u03b4) (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) :\n  g.comp (lift_add_hom f) = lift_add_hom (\u03bb a, g.comp (f a)) :=\nlift_add_hom.symm_apply_eq.1 $ funext $ \u03bb 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3] :\n  sum_add_hom (\u03bb i, (0 : \u03b2 i \u2192+ \u03b3)) = 0 :=\n(lift_add_hom : (\u03a0 i, \u03b2 i \u2192+ \u03b3) \u2243+ _).map_zero\n\n@[simp]\nlemma sum_add_hom_add [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (g : \u03a0 i, \u03b2 i \u2192+ \u03b3) (h : \u03a0 i, \u03b2 i \u2192+ \u03b3) :\n  sum_add_hom (\u03bb 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 [\u03a0 i, add_comm_monoid (\u03b2 i)] :\n  sum_add_hom (single_add_hom \u03b2) = add_monoid_hom.id _ :=\nlift_add_hom_single_add_hom\n\nlemma comp_sum_add_hom {\u03b4 : Type*} [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  [add_comm_monoid \u03b4] (g : \u03b3 \u2192+ \u03b4) (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) :\n  g.comp (sum_add_hom f) = sum_add_hom (\u03bb a, g.comp (f a)) :=\ncomp_lift_add_hom _ _\n\nlemma sum_sub_index [\u03a0 i, add_group (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [add_comm_group \u03b3] {f g : \u03a0\u2080 i, \u03b2 i}\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_sub : \u2200i b\u2081 b\u2082, h i (b\u2081 - b\u2082) = h i b\u2081 - h i b\u2082) :\n  (f - g).sum h = f.sum h - g.sum h :=\nbegin\n  have := (lift_add_hom (\u03bb 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 {\u03b3 : Type w} {\u03b1 : Type x}\n  [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3]\n  {s : finset \u03b1} {g : \u03b1 \u2192 \u03a0\u2080 i, \u03b2 i}\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_zero : \u2200i, h i 0 = 1) (h_add : \u2200i b\u2081 b\u2082, h i (b\u2081 + b\u2082) = h i b\u2081 * h i b\u2082) :\n  \u220f i in s, (g i).prod h = (\u2211 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  {\u03b9\u2081 : Type u\u2081} [decidable_eq \u03b9\u2081] {\u03b2\u2081 : \u03b9\u2081 \u2192 Type v\u2081}\n  [\u03a0 i\u2081, has_zero (\u03b2\u2081 i\u2081)] [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3]\n  {f : \u03a0\u2080 i\u2081, \u03b2\u2081 i\u2081} {g : \u03a0 i\u2081, \u03b2\u2081 i\u2081 \u2192 \u03a0\u2080 i, \u03b2 i}\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_zero : \u2200i, h i 0 = 1) (h_add : \u2200i b\u2081 b\u2082, h i (b\u2081 + b\u2082) = h i b\u2081 * h i b\u2082) :\n  (f.sum g).prod h = f.prod (\u03bbi b, (g i b).prod h) :=\n(prod_finset_sum_index h_zero h_add).symm\n\n@[simp] lemma sum_single [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] {f : \u03a0\u2080 i, \u03b2 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 [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {v : \u03a0\u2080 i, \u03b2 i} {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (hp : \u2200 x \u2208 v.support, p x) :\n  (v.subtype_domain p).prod (\u03bbi b, h i b) = v.prod h :=\nfinset.prod_bij (\u03bbp _, p)\n  (by simp) (by simp)\n  (assume \u27e8a\u2080, ha\u2080\u27e9 \u27e8a\u2081, ha\u2081\u27e9, by simp)\n  (\u03bb i hi, \u27e8\u27e8i, hp i hi\u27e9, by simpa using hi, rfl\u27e9)\n\nomit dec\nlemma subtype_domain_sum [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  {s : finset \u03b3} {h : \u03b3 \u2192 \u03a0\u2080 i, \u03b2 i} {p : \u03b9 \u2192 Prop} [decidable_pred p] :\n  (\u2211 c in s, h c).subtype_domain p = \u2211 c in s, (h c).subtype_domain p :=\neq.symm (s.sum_hom _)\n\nlemma subtype_domain_finsupp_sum {\u03b4 : \u03b3 \u2192 Type x} [decidable_eq \u03b3]\n  [\u03a0 c, has_zero (\u03b4 c)] [\u03a0 c (x : \u03b4 c), decidable (x \u2260 0)]\n  [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {s : \u03a0\u2080 c, \u03b4 c} {h : \u03a0 c, \u03b4 c \u2192 \u03a0\u2080 i, \u03b2 i} :\n  (s.sum h).subtype_domain p = s.sum (\u03bbc 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 [\u03a0 i, add_zero_class (\u03b2 i)] [\u03a0 i, add_zero_class (\u03b2\u2081 i)] [\u03a0 i, add_zero_class (\u03b2\u2082 i)]\n\nlemma map_range_add (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (hf : \u2200 i, f i 0 = 0)\n  (hf' : \u2200 i x y, f i (x + y) = f i x + f i y) (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2\u2081 i):\n  map_range f hf (g\u2081 + g\u2082) = map_range f hf g\u2081 + map_range f hf g\u2082 :=\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 : \u03a0 i, \u03b2\u2081 i \u2192+ \u03b2\u2082 i) : (\u03a0\u2080 i, \u03b2\u2081 i) \u2192+ (\u03a0\u2080 i, \u03b2\u2082 i) :=\n{ to_fun := map_range (\u03bb i x, f i x) (\u03bb i, (f i).map_zero),\n  map_zero' := map_range_zero _ _,\n  map_add' := map_range_add _ _ (\u03bb i, (f i).map_add) }\n\n@[simp]\nlemma map_range.add_monoid_hom_id :\n  map_range.add_monoid_hom (\u03bb i, add_monoid_hom.id (\u03b2\u2082 i)) = add_monoid_hom.id _ :=\nadd_monoid_hom.ext map_range_id\n\nlemma map_range.add_monoid_hom_comp (f : \u03a0 i, \u03b2\u2081 i \u2192+ \u03b2\u2082 i) (f\u2082 : \u03a0 i, \u03b2 i \u2192+ \u03b2\u2081 i):\n  map_range.add_monoid_hom (\u03bb i, (f i).comp (f\u2082 i)) =\n    (map_range.add_monoid_hom f).comp (map_range.add_monoid_hom f\u2082) :=\nadd_monoid_hom.ext $ map_range_comp (\u03bb i x, f i x) (\u03bb i x, f\u2082 i x) _ _ _\n\n/-- `dfinsupp.map_range.add_monoid_hom` as an `add_equiv`. -/\n@[simps apply]\ndef map_range.add_equiv (e : \u03a0 i, \u03b2\u2081 i \u2243+ \u03b2\u2082 i) : (\u03a0\u2080 i, \u03b2\u2081 i) \u2243+ (\u03a0\u2080 i, \u03b2\u2082 i) :=\n{ to_fun := map_range (\u03bb i x, e i x) (\u03bb i, (e i).map_zero),\n  inv_fun := map_range (\u03bb i x, (e i).symm x) (\u03bb i, (e i).symm.map_zero),\n  left_inv := \u03bb x, by rw \u2190map_range_comp; { simp_rw add_equiv.symm_comp_self, simp },\n  right_inv := \u03bb x, by rw \u2190map_range_comp; { simp_rw add_equiv.self_comp_symm, simp },\n  .. map_range.add_monoid_hom (\u03bb i, (e i).to_add_monoid_hom) }\n\n@[simp]\nlemma map_range.add_equiv_refl :\n  (map_range.add_equiv $ \u03bb i, add_equiv.refl (\u03b2\u2081 i)) = add_equiv.refl _ :=\nadd_equiv.ext map_range_id\n\nlemma map_range.add_equiv_trans (f : \u03a0 i, \u03b2 i \u2243+ \u03b2\u2081 i) (f\u2082 : \u03a0 i, \u03b2\u2081 i \u2243+ \u03b2\u2082 i):\n  map_range.add_equiv (\u03bb i, (f i).trans (f\u2082 i)) =\n    (map_range.add_equiv f).trans (map_range.add_equiv f\u2082) :=\nadd_equiv.ext $ map_range_comp (\u03bb i x, f\u2082 i x) (\u03bb i x, f i x) _ _ _\n\n@[simp]\nlemma map_range.add_equiv_symm (e : \u03a0 i, \u03b2\u2081 i \u2243+ \u03b2\u2082 i) :\n  (map_range.add_equiv e).symm = map_range.add_equiv (\u03bb 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 \u03b9]\n\nnamespace monoid_hom\nvariables {R S : Type*}\nvariables [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n\n@[simp, to_additive]\nlemma map_dfinsupp_prod [comm_monoid R] [comm_monoid S]\n  (h : R \u2192* S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R) :\n  h (f.prod g) = f.prod (\u03bb a b, h (g a b)) := h.map_prod _ _\n\n@[to_additive]\nlemma coe_dfinsupp_prod [monoid R] [comm_monoid S]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R \u2192* S) :\n  \u21d1(f.prod g) = f.prod (\u03bb a b, (g a b)) := coe_prod _ _\n\n@[simp, to_additive]\nlemma dfinsupp_prod_apply [monoid R] [comm_monoid S]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R \u2192* S) (r : R) :\n  (f.prod g) r = f.prod (\u03bb 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] [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  (h : R \u2192+ S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ R) :\n  h (sum_add_hom g f) = sum_add_hom (\u03bb 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] [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ R \u2192+ S) (r : R) :\n  (sum_add_hom g f) r = sum_add_hom (\u03bb 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] [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ R \u2192+ S) :\n  \u21d1(sum_add_hom g f) = sum_add_hom (\u03bb 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 \u2192 B} {a a' a\u2081 a\u2082 a\u2083 a\u2084 : A} {b b' : B}\n\n  @[hott] theorem ap_is_constant_eq (p : \u03a0x, 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)))\u207b\u00b9 \u2b1d\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\u2081 q\u2081 : a\u2081 = a\u2082} {p\u2082 q\u2082 : a\u2082 = a\u2083} (r\u2081 : p\u2081 = q\u2081) (r\u2082 : p\u2082 = q\u2082)\n    : square (ap (ap f) (r\u2081 \u25fe r\u2082))\n             (ap (ap f) r\u2081 \u25fe ap (ap f) r\u2082)\n             (ap_con f p\u2081 p\u2082)\n             (ap_con f q\u2081 q\u2082) :=\n  by induction r\u2082;induction r\u2081;exact hrfl\n\n  @[hott] theorem ap_con_right_inv_sq {A B : Type _} {a1 a2 : A} (f : A \u2192 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\u207b\u00b9 \u2b1d 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 \u2192 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\u207b\u00b9 p \u2b1d 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 \u2192 C) (f : A \u2192 B) {a a' : A}\n    {p\u2081 p\u2082 : a = a'} (q : p\u2081 = p\u2082) :\n    square (ap_compose g f p\u2081) (ap_compose g f p\u2082) (ap02 (g \u2218 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\u2081 p\u2082 : a = a'} (q : p\u2081 = p\u2082) :\n    square (ap_id p\u2081) (ap_id p\u2082) (ap02 id q) q :=\n  by induction q; exact vrfl\n\n  @[hott] theorem ap_ap_is_constant {A B C : Type _} (g : B \u2192 C) {f : A \u2192 B} {b : B}\n    (p : \u03a0x, 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 \u2218 f) (\u03bba, ap g (p a)) q))\n           (ap_compose g f q)\u207b\u00b9\n           (ap_con _ _ _ \u2b1d 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 \u2192 D) (g : B \u2192 C) (f : A \u2192 B)\n    {x y : A} (p : x = y) :\n    square (ap_compose (h \u2218 g) f p)\n           (ap (ap h) (ap_compose g f p))\n           (ap_compose h (g \u2218 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 \u2192 C) (f : A \u2192 B)\n    {x y : A} (p : x = y) :\n    square (ap_compose g f p\u207b\u00b9)\n           (inverse2 (ap_compose g f p) \u2b1d (ap_inv g (ap f p))\u207b\u00b9)\n           (ap_inv (g \u2218 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 \u2192 C) (f : A \u2192 B) (p : a\u2081 = a\u2082) (q : a\u2082 = a\u2083) :\n    square (ap_compose g f (p \u2b1d q))\n           (ap_compose g f p \u25fe ap_compose g f q \u2b1d (ap_con g (ap f p) (ap f q))\u207b\u00b9)\n           (ap_con (g \u2218 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 \u2192 C) (f : A \u2192 B)\n    {x y : A} {p q : x = y} (r : p = q) :\n    square (ap (ap (g \u2218 f)) r)\n           (ap (ap g \u2218 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\u2081 = a\u2082} (r : p \u2b1d q\u207b\u00b9 = idp) :\n    whisker_right q\u207b\u00b9 (eq_of_con_inv_eq_idp r) \u2b1d 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 \u2192 B) {p q : a\u2081 = a\u2082} (r : p \u2b1d q\u207b\u00b9 = idp)\n  : ap02 f (eq_of_con_inv_eq_idp r) =\n           eq_of_con_inv_eq_idp (whisker_left _ (ap_inv _ _)\u207b\u00b9 \u2b1d (ap_con _ _ _)\u207b\u00b9 \u2b1d 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\u2081 = a\u2082} (r : p = p') (s : q = q')\n    (t : p' \u2b1d q'\u207b\u00b9 = idp)\n  : eq_of_con_inv_eq_idp (r \u25fe inverse2 s \u2b1d t) = r \u2b1d eq_of_con_inv_eq_idp t \u2b1d s\u207b\u00b9 :=\n  by induction s; induction r; induction q; reflexivity\n\n  @[hott] def naturality_apd_eq {A : Type _} {B : A \u2192 Type _} {a a\u2082 : A} {f g : \u03a0a, B a}\n    (H : f ~ g) (p : a = a\u2082)\n    : apd f p = concato_eq (eq_concato (H a) (apd g p)) (H a\u2082)\u207b\u00b9 :=\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 \u2192 Type _} {x y : A} (q : x = y) (u : P x) :\n    con_tr idp q u = ap (\u03bbp, p \u25b8 u) (idp_con q) :=\n  by induction q;reflexivity\n\n  @[hott] def whisker_left_idp_con_eq_assoc\n    {A : Type _} {a\u2081 a\u2082 a\u2083 : A} (p : a\u2081 = a\u2082) (q : a\u2082 = a\u2083)\n    : whisker_left p (idp_con q)\u207b\u00b9 = 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\u207b\u00b2 \u2b1d 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 \u2192 Type _} (f : \u03a0\u2983a\u2984, B a \u2192 C a) {a\u2081 a\u2082 : A}\n    (p : a\u2081 = a\u2082) (q : a\u2082 = a\u2081) (r : p \u2b1d q = idp) (b : B a\u2081) :\n    cast (ap C q) (f (cast (ap B p) b)) = f b :=\n  have q\u207b\u00b9 = p, from inv_eq_of_idp_eq_con r\u207b\u00b9,\n  begin induction this, induction q, reflexivity end\n\n  @[hott] def ap011_ap_square_right {A B C : Type _} (f : A \u2192 B \u2192 C) {a a' : A} (p : a = a')\n    {b\u2081 b\u2082 b\u2083 : B} {q\u2081\u2082 : b\u2081 = b\u2082} {q\u2082\u2083 : b\u2082 = b\u2083} {q\u2081\u2083 : b\u2081 = b\u2083} (r : q\u2081\u2082 \u2b1d q\u2082\u2083 = q\u2081\u2083) :\n    square (ap011 f p q\u2081\u2082) (ap (\u03bbx, f x b\u2083) p) (ap (f a) q\u2081\u2083) (ap (f a') q\u2082\u2083) :=\n  by induction r; induction q\u2082\u2083; induction q\u2081\u2082; induction p; exact ids\n\n  @[hott] def ap011_ap_square_left {A B C : Type _} (f : B \u2192 A \u2192 C) {a a' : A} (p : a = a')\n    {b\u2081 b\u2082 b\u2083 : B} {q\u2081\u2082 : b\u2081 = b\u2082} {q\u2082\u2083 : b\u2082 = b\u2083} {q\u2081\u2083 : b\u2081 = b\u2083} (r : q\u2081\u2082 \u2b1d q\u2082\u2083 = q\u2081\u2083) :\n    square (ap011 f q\u2081\u2082 p) (ap (f b\u2083) p) (ap (\u03bbx, f x a) q\u2081\u2083) (ap (\u03bbx, f x a') q\u2082\u2083) :=\n  by induction r; induction q\u2082\u2083; induction q\u2081\u2082; 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 \u25fe h') \u25fe h'') (h \u25fe (h' \u25fe 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\u207b\u00b2 \u25fe 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 \u25fe h') (h' \u25fe 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 \u2192 b = b) (p : a = a') :\n    ap (\u03bba, g a \u2b1d h a) p = ap g p \u25fe ap h p :=\n  by induction p; reflexivity\n\n  @[hott] def ap_eq_ap011 {A B C X : Type _} (f : A \u2192 B \u2192 C) (g : X \u2192 A) (h : X \u2192 B) {x x' : X}\n    (p : x = x') : ap (\u03bbx, 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 \u2192 B}\n    (h : is_weakly_constant f) {a a' : A} (p : a = a') : ap f p = (h a a)\u207b\u00b9 \u2b1d h a a' :=\n  by induction p; exact (con.left_inv _)\u207b\u00b9\n\n  @[hott] def ap_is_constant_idp {A B : Type _} {f : A \u2192 B} {b : B} (p : \u03a0a, f a = b) {a : A} (q : a = a)\n    (r : q = idp) : ap_is_constant f p q = ap02 f r \u2b1d (con.right_inv (p a))\u207b\u00b9 :=\n  by hinduction r using eq.rec_symm; exact (idp_con _)\u207b\u00b9\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 \u25fe q\u207b\u00b2 \u2b1d 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\u2081 b\u2082 b\u2083 : B} (q : b\u2082 = b\u2083) (f : A \u2192 b\u2081 = b\u2082)\n    (p : a = a') : whisker_right q (ap f p) = ap (\u03bba, f a \u2b1d q) p :=\n  by induction p; reflexivity\n\n  @[hott] def ap02_ap_constant {A B C : Type _} {a a' : A} (f : B \u2192 C) (b : B) (p : a = a') :\n    square (ap_constant p (f b)) (ap02 f (ap_constant p b)) (ap_compose f (\u03bbx, 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 \u2192 B) (p : a = a') :\n    square (ap_constant p c) (ap_constant (ap f p) c) (ap_compose (\u03bbx, 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 (\u03bbx, 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 \u2190 Meta.IndPredBelow.getBelowIndices ctorName\n  if actualIndices != indices then\n    throwError \"wrong indices for {ctorName}: {actualIndices} \u225f {indices}\"\n\nnamespace Ex\ninductive LE : Nat \u2192 Nat \u2192 Prop\n  | refl : LE n n\n  | succ : LE n m \u2192 LE n m.succ\n#eval checkGetBelowIndices ``LE.refl #[1]\n#eval checkGetBelowIndices ``LE.succ #[1, 2, 3]\n\ndef typeOf {\u03b1 : Sort u} (a : \u03b1) := \u03b1\n\ntheorem LE_brecOn : typeOf @LE.brecOn =\n\u2200 {motive : (a a_1 : Nat) \u2192 LE a a_1 \u2192 Prop} {a a_1 : Nat} (x : LE a a_1),\n  (\u2200 (a a_2 : Nat) (x : LE a a_2), @LE.below motive a a_2 x \u2192 motive a a_2 x) \u2192 motive a a_1 x := rfl\n\ntheorem LE.trans : LE m n \u2192 LE n o \u2192 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 \u2192 LE n o \u2192 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 \u2192 Prop\n  | zero : Even 0\n  | ss   : Even n \u2192 Even n.succ.succ\n#eval checkGetBelowIndices ``Even.zero #[]\n#eval checkGetBelowIndices ``Even.ss #[1, 2]\n\ntheorem Even_brecOn : typeOf @Even.brecOn = \u2200 {motive : (a : Nat) \u2192 Even a \u2192 Prop} {a : Nat} (x : Even a),\n  (\u2200 (a : Nat) (x : Even a), @Even.below motive a x \u2192 motive a x) \u2192 motive a x := rfl\n\ntheorem Even.add : Even n \u2192 Even m \u2192 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 \u2192 Even m \u2192 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 [\u2190 Nat.mul_assoc, Nat.mul_comm n m, Nat.mul_assoc]\n\ninductive Power2 : Nat \u2192 Prop\n  | base : Power2 1\n  | ind  : Power2 n \u2192 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 = \u2200 {motive : (a : Nat) \u2192 Power2 a \u2192 Prop} {a : Nat} (x : Power2 a),\n  (\u2200 (a : Nat) (x : Power2 a), @Power2.below motive a x \u2192 motive a x) \u2192 motive a x := rfl\n\ntheorem Power2.mul : Power2 n \u2192 Power2 m \u2192 Power2 (n*m) := by\n  intro h1 h2\n  induction h2 with\n  | base      => simp_all\n  | ind h2 ih => exact mul_left_comm .. \u25b8 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 \u2192 Power2 m \u2192 Power2 (n*m)\n--  | h1, base => by simp_all\n--  | h1, ind h2 => mul_left_comm .. \u25b8 ind (mul' h1 h2)\n\ninductive tm : Type :=\n  | C : Nat \u2192 tm\n  | P : tm \u2192 tm \u2192 tm\n\nopen tm\n\nset_option hygiene false in\ninfixl:40 \" ==> \" => step\ninductive step : tm \u2192 tm \u2192 Prop :=\n  | ST_PlusConstConst : \u2200 n1 n2,\n      P (C n1) (C n2) ==> C (n1 + n2)\n  | ST_Plus1 : \u2200 t1 t1' t2,\n      t1 ==> t1' \u2192\n      P t1 t2 ==> P t1' t2\n  | ST_Plus2 : \u2200 n1 t2 t2',\n      t2 ==> t2' \u2192\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 \u2192 X \u2192 Prop) :=\n  \u2200 x y1 y2 : X, R x y1 \u2192 R x y2 \u2192 y1 = y2\n\ntheorem step_deterministic' : deterministic step := \u03bb x y\u2081 y\u2082 hy\u2081 hy\u2082 =>\n  @step.brecOn (\u03bb s t st => \u2200 y\u2082, s ==> y\u2082 \u2192 t = y\u2082) _ _ hy\u2081 (\u03bb s t st hy\u2081 y\u2082 hy\u2082 =>\n    match hy\u2081, hy\u2082 with\n    | step.below.ST_PlusConstConst _ _, step.ST_PlusConstConst _ _ => rfl\n    | step.below.ST_Plus1 _ _ _ hy\u2081 ih, step.ST_Plus1 _ t\u2081' _ _ => by rw [\u2190ih t\u2081']; assumption\n    | step.below.ST_Plus1 _ _ _ hy\u2081 ih, step.ST_Plus2 _ _ _ _ => by cases hy\u2081\n    | step.below.ST_Plus2 _ _ _ _ ih, step.ST_Plus2 _ _ t\u2082 _ => by rw [\u2190ih t\u2082]; assumption\n    | step.below.ST_Plus2 _ _ _ hy\u2081 _, step.ST_PlusConstConst _ _ => by cases hy\u2081\n    ) y\u2082 hy\u2082\n\nsection NestedRecursion\n\naxiom f : Nat \u2192 Nat\n\ninductive is_nat : Nat -> Prop\n| Z : is_nat 0\n| S {n} : is_nat n \u2192 is_nat (f n)\n#eval checkGetBelowIndices ``is_nat.Z #[]\n#eval checkGetBelowIndices ``is_nat.S #[1, 2]\n\naxiom P : Nat \u2192 Prop\naxiom F0 : P 0\naxiom F1 : P (f 0)\naxiom FS {n : Nat} : P n \u2192 P (f (f n))\n\n-- we would like to write this\n-- theorem foo : \u2200 {n}, is_nat n \u2192 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' : \u2200 {n}, is_nat n \u2192 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\u2082 => 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) (\u03b5 : \u211d) (\u03b5_pos : 0 < \u03b5)\n  {\u03d5 : X \u2192 \u211d} (cont : continuous \u03d5) (nonneg : \u2200 y, 0 \u2264 \u03d5 y) :\n  \u2203 (\u03b5' > 0) (x' : X), \u03b5' \u2264 \u03b5 \u2227\n                       d x' x \u2264 2*\u03b5 \u2227\n                       \u03b5 * \u03d5(x) \u2264 \u03b5' * \u03d5 x' \u2227\n                       \u2200 y, d x' y \u2264 \u03b5' \u2192 \u03d5 y \u2264 2*\u03d5 x' :=\nbegin\n  by_contradiction H,\n  have reformulation : \u2200 x' (k : \u2115), \u03b5 * \u03d5 x \u2264 \u03b5 / 2 ^ k * \u03d5 x' \u2194 2^k * \u03d5 x \u2264 \u03d5 x',\n  { intros x' k,\n    rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left \u03b5_pos, mul_comm],\n    exact pow_pos (by norm_num) k, },\n  -- Now let's specialize to `\u03b5/2^k`\n  replace H : \u2200 k : \u2115, \u2200 x', d x' x \u2264 2 * \u03b5 \u2227 2^k * \u03d5 x \u2264 \u03d5 x' \u2192\n    \u2203 y, d x' y \u2264 \u03b5/2^k \u2227 2 * \u03d5 x' < \u03d5 y,\n  { intros k x',\n    push_neg at H,\n    simpa [reformulation] using\n      H (\u03b5/2^k) (by simp [\u03b5_pos, zero_lt_two]) x' (by simp [\u03b5_pos, zero_lt_two, one_le_two]) },\n  clear reformulation,\n  haveI : nonempty X := \u27e8x\u27e9,\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 : \u2115 \u2192 X := \u03bb 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    \u2200 n,\n      d (u n) x \u2264 2 * \u03b5 \u2227 2^n * \u03d5 x \u2264 \u03d5 (u n) \u2192\n      d (u n) (u $ n + 1) \u2264 \u03b5 / 2 ^ n \u2227 2 * \u03d5 (u n) < \u03d5 (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 : \u2200 n, d (u n) (u (n + 1)) \u2264 \u03b5 / 2 ^ n \u2227 2 * \u03d5 (u n) < \u03d5 (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, \u03b5_pos.le, le_refl] using hu },\n    have A : d (u (n+1)) x \u2264 2 * \u03b5,\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          \u2264 \u2211 i in r, d (u i) (u $ i+1) : dist_le_range_sum_dist u (n + 1)\n      ... \u2264 \u2211 i in r, \u03b5/2^i             : sum_le_sum (\u03bb i i_in, (IH i $ nat.lt_succ_iff.mp $\n                                                                  finset.mem_range.mp i_in).1)\n      ... = \u2211 i in r, (1/2)^i*\u03b5         : by { congr' with i, field_simp }\n      ... = (\u2211 i in r, (1/2)^i)*\u03b5       : finset.sum_mul.symm\n      ... \u2264 2*\u03b5                         : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                            (le_of_lt \u03b5_pos), },\n    have B : 2^(n+1) * \u03d5 x \u2264 \u03d5 (u (n + 1)),\n    { refine @geom_le (\u03d5 \u2218 u) _ zero_le_two (n + 1) (\u03bb m hm, _),\n      exact (IH _ $ nat.lt_add_one_iff.1 hm).2.le },\n    exact hu (n+1) \u27e8A, B\u27e9, },\n  cases forall_and_distrib.mp key with key\u2081 key\u2082,\n  clear hu key,\n  -- Hence u is Cauchy\n  have cauchy_u : cauchy_seq u,\n  { refine cauchy_seq_of_le_geometric _ \u03b5 one_half_lt_one (\u03bb n, _),\n    simpa only [one_div, inv_pow\u2080] using key\u2081 n },\n  -- So u converges to some y\n  obtain \u27e8y, limy\u27e9 : \u2203 y, tendsto u at_top (\ud835\udcdd y),\n    from complete_space.complete cauchy_u,\n  -- And \u03d5 \u2218 u goes to +\u221e\n  have lim_top : tendsto (\u03d5 \u2218 u) at_top at_top,\n  { let v := \u03bb n, (\u03d5 \u2218 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\u2080 : 0 < v 0,\n    { have : 0 \u2264 \u03d5 (u 0) := nonneg x,\n      calc 0 \u2264 2 * \u03d5 (u 0) : by linarith\n      ... < \u03d5 (u (0 + 1)) : key\u2082 0 },\n    apply tendsto_at_top_of_geom_le hv\u2080 one_lt_two,\n    exact \u03bb n, (key\u2082 (n+1)).le },\n  -- But \u03d5 \u2218 u also needs to go to \u03d5(y)\n  have lim : tendsto (\u03d5 \u2218 u) at_top (\ud835\udcdd (\u03d5 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\u2081 v\u2082 u\u2081 u\u2082 -- morphism levels before object levels. See note [category_theory universes].\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} 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 \u2964 D) (G : D \u2964 C) (h : G.op \u22a3 F.op) : F \u22a3 G :=\nadjunction.mk_of_hom_equiv\n{ hom_equiv := \u03bb 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 \u2964 D) (G : D\u1d52\u1d56 \u2964 C\u1d52\u1d56) (h : G \u22a3 F.op) : F \u22a3 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\u1d52\u1d56 \u2964 D\u1d52\u1d56) (G : D \u2964 C) (h : G.op \u22a3 F) : F.unop \u22a3 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\u1d52\u1d56 \u2964 D\u1d52\u1d56) (G : D\u1d52\u1d56 \u2964 C\u1d52\u1d56) (h : G \u22a3 F) : F.unop \u22a3 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 \u2964 D) (G : D \u2964 C) (h : G \u22a3 F) : F.op \u22a3 G.op :=\nadjunction.mk_of_hom_equiv\n{ hom_equiv := \u03bb 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\u1d52\u1d56 \u2964 D\u1d52\u1d56) (G : D \u2964 C) (h : G \u22a3 F.unop) : F \u22a3 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 \u2964 D) (G : D\u1d52\u1d56 \u2964 C\u1d52\u1d56) (h : G.unop \u22a3 F) : F.op \u22a3 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\u1d52\u1d56 \u2964 D\u1d52\u1d56) (G : D\u1d52\u1d56 \u2964 C\u1d52\u1d56) (h : G.unop \u22a3 F.unop) : F \u22a3 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 \u22d9 coyoneda \u2245 F'.op \u22d9 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 \u2964 D} {G : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G):\n  F.op \u22d9 coyoneda \u2245 F'.op \u22d9 coyoneda :=\nnat_iso.of_components\n  (\u03bb X, nat_iso.of_components\n    (\u03bb 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 \u2964 D} {G : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G) : F \u2245 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 \u2964 D} {G : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 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 \u2964 D} {G : D \u2964 C} (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G) :\n  adj1.unit \u226b whisker_right (left_adjoint_uniq adj1 adj2).hom G = adj2.unit :=\nbegin\n  ext x,\n  rw [nat_trans.comp_app, \u2190 hom_equiv_left_adjoint_uniq_hom_app adj1 adj2],\n  simp [-hom_equiv_left_adjoint_uniq_hom_app, \u2190G.map_comp]\nend\n\n@[simp, reassoc]\nlemma unit_left_adjoint_uniq_hom_app {F F' : C \u2964 D} {G : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G) (x : C) :\n  adj1.unit.app x \u226b G.map ((left_adjoint_uniq adj1 adj2).hom.app x) = adj2.unit.app x :=\nby { rw \u2190 unit_left_adjoint_uniq_hom adj1 adj2, refl }\n\n@[simp, reassoc]\nlemma left_adjoint_uniq_hom_counit {F F' : C \u2964 D} {G : D \u2964 C} (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G) :\n  whisker_left G (left_adjoint_uniq adj1 adj2).hom \u226b 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)) \u226b adj1.counit.app (F'.obj (G.obj x)) \u226b\n    adj2.counit.app x \u226b f = adj1.counit.app x \u226b f,\n  { erw [\u2190 adj1.counit.naturality, \u2190 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 \u2964 D} {G : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G) (x : D) :\n  (left_adjoint_uniq adj1 adj2).hom.app (G.obj x) \u226b adj2.counit.app x = adj1.counit.app x :=\nby { rw \u2190 left_adjoint_uniq_hom_counit adj1 adj2, refl }\n\n@[simp]\nlemma left_adjoint_uniq_inv_app {F F' : C \u2964 D} {G : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 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 \u2964 D} {G : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G) (adj3 : F'' \u22a3 G) :\n  (left_adjoint_uniq adj1 adj2).hom \u226b (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 \u2964 D} {G : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G) (adj3 : F'' \u22a3 G) (x : C) :\n  (left_adjoint_uniq adj1 adj2).hom.app x \u226b (left_adjoint_uniq adj2 adj3).hom.app x =\n    (left_adjoint_uniq adj1 adj3).hom.app x :=\nby { rw \u2190 left_adjoint_uniq_trans adj1 adj2 adj3, refl }\n\n@[simp]\nlemma left_adjoint_uniq_refl {F : C \u2964 D} {G : D \u2964 C} (adj1 : F \u22a3 G) :\n  (left_adjoint_uniq adj1 adj1).hom = \ud835\udfd9 _ :=\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 \u2964 D} {G G' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F \u22a3 G') : G \u2245 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 \u2964 D} {G G' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F \u22a3 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 \u2964 D} {G G' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F \u22a3 G') (x : C) :\n  adj1.unit.app x \u226b (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 \u2964 D} {G G' : D \u2964 C} (adj1 : F \u22a3 G) (adj2 : F \u22a3 G') :\n  adj1.unit \u226b 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 \u2964 D} {G G' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F \u22a3 G') (x : D) :\n  F.map ((right_adjoint_uniq adj1 adj2).hom.app x) \u226b 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 \u2964 D} {G G' : D \u2964 C} (adj1 : F \u22a3 G) (adj2 : F \u22a3 G') :\n  whisker_right (right_adjoint_uniq adj1 adj2).hom F \u226b adj2.counit = adj1.counit :=\nby { ext, simp }\n\n@[simp]\nlemma right_adjoint_uniq_inv_app {F : C \u2964 D} {G G' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F \u22a3 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 \u2964 D} {G G' G'' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F \u22a3 G') (adj3 : F \u22a3 G'') (x : D) :\n  (right_adjoint_uniq adj1 adj2).hom.app x \u226b (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 \u2964 D} {G G' G'' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F \u22a3 G') (adj3 : F \u22a3 G'') :\n  (right_adjoint_uniq adj1 adj2).hom \u226b (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 \u2964 D} {G : D \u2964 C} (adj1 : F \u22a3 G) :\n  (right_adjoint_uniq adj1 adj1).hom = \ud835\udfd9 _ :=\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 \u2964 D} {G G' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G') (l : F \u2245 F') :\n  G \u2245 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 \u2964 D} {G G' : D \u2964 C}\n  (adj1 : F \u22a3 G) (adj2 : F' \u22a3 G') (r : G \u2245 G') :\n  F \u2245 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u03b1`, for example, is obtained by requiring both the\ninstances `add_monoid \u03b1` and `has_continuous_add \u03b1`. -/\nclass has_continuous_add (M : Type u_5) [topological_space M] [Add M] where\n  continuous_add : continuous fun (p : M \u00d7 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 `\u03b1`, for example, is obtained by requiring both the instances `monoid \u03b1`\nand `has_continuous_mul \u03b1`. -/\nclass has_continuous_mul (M : Type u_5) [topological_space M] [Mul M] where\n  continuous_mul : continuous fun (p : M \u00d7 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 \u00d7 M) => prod.fst p + prod.snd p :=\n  has_continuous_add.continuous_add\n\ntheorem continuous.mul {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Mul M]\n    [has_continuous_mul M] [topological_space \u03b1] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} (hf : continuous f)\n    (hg : continuous g) : continuous fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] [topological_space \u03b1] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} {s : set \u03b1}\n    (hf : continuous_on f s) (hg : continuous_on g s) :\n    continuous_on (fun (x : \u03b1) => 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 \u00d7 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 {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} {x : filter \u03b1} {a : M} {b : M}\n    (hf : filter.tendsto f x (nhds a)) (hg : filter.tendsto g x (nhds b)) :\n    filter.tendsto (fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Mul M]\n    [has_continuous_mul M] (b : M) {c : M} {f : \u03b1 \u2192 M} {l : filter \u03b1}\n    (h : filter.tendsto (fun (k : \u03b1) => f k) l (nhds c)) :\n    filter.tendsto (fun (k : \u03b1) => b * f k) l (nhds (b * c)) :=\n  filter.tendsto.mul tendsto_const_nhds h\n\ntheorem tendsto.add_const {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] (b : M) {c : M} {f : \u03b1 \u2192 M} {l : filter \u03b1}\n    (h : filter.tendsto (fun (k : \u03b1) => f k) l (nhds c)) :\n    filter.tendsto (fun (k : \u03b1) => f k + b) l (nhds (c + b)) :=\n  filter.tendsto.add h tendsto_const_nhds\n\ntheorem continuous_at.add {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] [topological_space \u03b1] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} {x : \u03b1}\n    (hf : continuous_at f x) (hg : continuous_at g x) :\n    continuous_at (fun (x : \u03b1) => f x + g x) x :=\n  filter.tendsto.add hf hg\n\ntheorem continuous_within_at.add {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M]\n    [has_continuous_add M] [topological_space \u03b1] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} {s : set \u03b1} {x : \u03b1}\n    (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) :\n    continuous_within_at (fun (x : \u03b1) => 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 \u00d7 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 : \u2200 (x\u2080 : M), nhds x\u2080 = filter.map (fun (x : M) => x\u2080 * x) (nhds 1))\n    (hright : \u2200 (x\u2080 : M), nhds x\u2080 = filter.map (fun (x : M) => x * x\u2080) (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 : \u2200 (x\u2080 : M), nhds x\u2080 = filter.map (fun (x : M) => x\u2080 * 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 \u2191s + closure \u2191s \u2286 closure \u2191s :=\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 \u2191s * closure \u2191s = closure \u2191s :=\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 \u2191s) 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 \u2264 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 \u2191(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 \u2264 t) (ht : is_closed \u2191t) :\n    submonoid.topological_closure s \u2264 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 \u2208 nhds 0) :\n    \u2203 (V : set M), is_open V \u2227 0 \u2208 V \u2227 \u2200 (v : M), v \u2208 V \u2192 \u2200 (w : M), w \u2208 V \u2192 v + w \u2208 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 \u2208 nhds 0) :\n    \u2203 (V : set M), \u2203 (H : V \u2208 nhds 0), \u2200 (v : M), v \u2208 V \u2192 \u2200 (w : M), w \u2208 V \u2192 v + w \u2208 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 \u2208 nhds 1) :\n    \u2203 (V : set M),\n        \u2203 (H : V \u2208 nhds 1), \u2200 {v w s t : M}, v \u2208 V \u2192 w \u2208 V \u2192 s \u2208 V \u2192 t \u2208 V \u2192 v * w * s * t \u2208 u :=\n  sorry\n\n/-- Given a neighborhood `U` of `1` there is an open neighborhood `V` of `1`\nsuch that `VV \u2286 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 \u2208 nhds 1) :\n    \u2203 (V : set M), is_open V \u2227 1 \u2208 V \u2227 V * V \u2286 U :=\n  sorry\n\ntheorem tendsto_list_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M]\n    [add_monoid M] [has_continuous_add M] {f : \u03b2 \u2192 \u03b1 \u2192 M} {x : filter \u03b1} {a : \u03b2 \u2192 M} (l : List \u03b2) :\n    (\u2200 (c : \u03b2), c \u2208 l \u2192 filter.tendsto (f c) x (nhds (a c))) \u2192\n        filter.tendsto (fun (b : \u03b1) => list.sum (list.map (fun (c : \u03b2) => f c b) l)) x\n          (nhds (list.sum (list.map a l))) :=\n  sorry\n\ntheorem continuous_list_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M]\n    [add_monoid M] [has_continuous_add M] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1 \u2192 M} (l : List \u03b2)\n    (h : \u2200 (c : \u03b2), c \u2208 l \u2192 continuous (f c)) :\n    continuous fun (a : \u03b1) => list.sum (list.map (fun (c : \u03b2) => f c a) l) :=\n  iff.mpr continuous_iff_continuous_at\n    fun (x : \u03b1) =>\n      tendsto_list_sum l fun (c : \u03b2) (hc : c \u2208 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 : \u2115) : continuous fun (a : M) => a ^ n :=\n  sorry\n\ntheorem continuous.pow {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [monoid M]\n    [has_continuous_mul M] {f : \u03b1 \u2192 M} [topological_space \u03b1] (h : continuous f) (n : \u2115) :\n    continuous fun (b : \u03b1) => 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 \u2191S) : \u2191S \u2208 nhds 1 :=\n  mem_nhds_sets oS (submonoid.one_mem S)\n\ntheorem tendsto_multiset_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M]\n    [comm_monoid M] [has_continuous_mul M] {f : \u03b2 \u2192 \u03b1 \u2192 M} {x : filter \u03b1} {a : \u03b2 \u2192 M}\n    (s : multiset \u03b2) :\n    (\u2200 (c : \u03b2), c \u2208 s \u2192 filter.tendsto (f c) x (nhds (a c))) \u2192\n        filter.tendsto (fun (b : \u03b1) => multiset.prod (multiset.map (fun (c : \u03b2) => f c b) s)) x\n          (nhds (multiset.prod (multiset.map a s))) :=\n  sorry\n\ntheorem tendsto_finset_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M]\n    [add_comm_monoid M] [has_continuous_add M] {f : \u03b2 \u2192 \u03b1 \u2192 M} {x : filter \u03b1} {a : \u03b2 \u2192 M}\n    (s : finset \u03b2) :\n    (\u2200 (c : \u03b2), c \u2208 s \u2192 filter.tendsto (f c) x (nhds (a c))) \u2192\n        filter.tendsto (fun (b : \u03b1) => finset.sum s fun (c : \u03b2) => f c b) x\n          (nhds (finset.sum s fun (c : \u03b2) => a c)) :=\n  tendsto_multiset_sum (finset.val s)\n\ntheorem continuous_multiset_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M]\n    [comm_monoid M] [has_continuous_mul M] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1 \u2192 M} (s : multiset \u03b2) :\n    (\u2200 (c : \u03b2), c \u2208 s \u2192 continuous (f c)) \u2192\n        continuous fun (a : \u03b1) => multiset.prod (multiset.map (fun (c : \u03b2) => f c a) s) :=\n  sorry\n\ntheorem continuous_finset_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M]\n    [comm_monoid M] [has_continuous_mul M] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1 \u2192 M} (s : finset \u03b2) :\n    (\u2200 (c : \u03b2), c \u2208 s \u2192 continuous (f c)) \u2192\n        continuous fun (a : \u03b1) => finset.prod s fun (c : \u03b2) => 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": "/-\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-/\nprelude\nimport init.num init.relation\n\ndefinition pair [constructor] := @prod.mk\nnotation A \u00d7 B := prod A B\n-- notation for n-ary tuples\nnotation `(` h `, ` t:(foldl `, ` (e r, prod.mk r e) h) `)` := t\n\nnamespace prod\n  notation `pr\u2081` := pr1\n  notation `pr\u2082` := pr2\n\n  namespace ops\n  postfix `.1`:(max+1) := pr1\n  postfix `.2`:(max+1) := pr2\n  end ops\n\n  definition destruct [reducible] := @prod.cases_on\n\n  section\n  variables {A B : Type}\n  lemma pr1.mk (a : A) (b : B) : pr1 (mk a b) = a := rfl\n  lemma pr2.mk (a : A) (b : B) : pr2 (mk a b) = b := rfl\n  lemma eta : \u2200 (p : A \u00d7 B), mk (pr1 p) (pr2 p) = p\n  | (a, b) := rfl\n  end\n\nend prod\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/init/prod.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7371581684030623, "lm_q1q2_score": 0.47489579953676}}
{"text": "import logic.funrel\n\n/-!\n * bool supported on a truth value.\n--/\n\n@[reducible]\ndefinition subbool (p : Prop) : Type := {b // p \u2228 b=ff}\n\ninstance (p : Prop) : inhabited (subbool p) := inhabited.mk \u27e8ff,or.inr rfl\u27e9\ninstance (p : Prop) : has_zero (subbool p) := has_zero.mk \u27e8ff,or.inr rfl\u27e9\ninstance (p : Prop) : decidable_eq (subbool p) :=\n  \u03bb a b, @decidable.cases_on (a.val=b.val) (\u03bb_, decidable (a=b)) (bool.decidable_eq a.val b.val) (\u03bb hn, is_false (\u03bb (h : a=b), hn (congr (@rfl _ subtype.val) h))) (\u03bb 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 := \u27e8ff,or.inr rfl\u27e9\n\n@[reducible,inline]\nprotected\ndefinition tt {p : Prop} : p \u2192 subbool p := \u03bb h, \u27e8tt,or.inl h\u27e9\n\n@[reducible]\nprotected\ndefinition and {p : Prop} : subbool p \u2192 subbool p \u2192 subbool p\n| \u27e8tt,hl\u27e9 \u27e8tt,_\u27e9 := \u27e8tt,or.elim hl or.inl (\u03bb tf, bool.no_confusion tf)\u27e9\n| _ _ := \u27e8ff,or.inr rfl\u27e9\n\n@[reducible]\nprotected\ndefinition or {p : Prop} : subbool p \u2192 subbool p \u2192 subbool p\n| \u27e8ff,_\u27e9 \u27e8ff,_\u27e9 := \u27e8ff, by right; refl\u27e9\n| \u27e8ff,_\u27e9 \u27e8tt,qt\u27e9 := \u27e8tt, qt.elim _root_.or.inl (\u03bb tf, bool.no_confusion tf)\u27e9\n| \u27e8tt,qt\u27e9 \u27e8ff,_\u27e9 := \u27e8tt, qt.elim _root_.or.inl (\u03bb tf, bool.no_confusion tf)\u27e9\n| \u27e8tt,qt\u27e9 \u27e8tt,_\u27e9 := \u27e8tt, qt.elim _root_.or.inl (\u03bb tf, bool.no_confusion tf)\u27e9\n\n@[reducible]\ndefinition xor {p : Prop} : subbool p \u2192 subbool p \u2192 subbool p\n| \u27e8ff,_\u27e9 \u27e8ff,_\u27e9 := \u27e8ff, or.inr rfl\u27e9\n| \u27e8ff,_\u27e9 \u27e8tt,qt\u27e9 := \u27e8tt, or.elim qt or.inl (\u03bb tf, bool.no_confusion tf)\u27e9\n| \u27e8tt,qt\u27e9 \u27e8ff,_\u27e9 := \u27e8tt, or.elim qt or.inl (\u03bb tf, bool.no_confusion tf)\u27e9\n| \u27e8tt,_\u27e9 \u27e8tt,_\u27e9 := \u27e8ff, or.inr rfl\u27e9\n\n@[simp]\nprotected\nlemma xor_ff {p : Prop} (a : subbool p) : xor a \u27e8ff,or.inr rfl\u27e9 = a :=\n  by cases a; cases a_val; unfold xor\n\n@[simp]\nprotected\nlemma ff_xor {p : Prop} (a : subbool p) : xor \u27e8ff,or.inr rfl\u27e9 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 = \u27e8ff,or.inr rfl\u27e9 :=\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 \u2192 q) : subbool p \u2192 subbool q\n| \u27e8a,ha\u27e9 := \u27e8a, ha.elim (or.inl \u2218 hpq) or.inr\u27e9\n\n@[reducible,inline]\ndefinition to_bool {p : Prop} : subbool p \u2192 bool := subtype.val\n\n@[reducible]\ndefinition from_bool (p : Prop) : bool \u2192 subbool true := \u03bb x, \u27e8x,or.inl true.intro\u27e9\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 (\u03b9 Q m * x) = f m (foldr Q f hf n x)`.\n\nFor example, `foldr f hf n (r \u2022 \u03b9 R u + \u03b9 R v * \u03b9 R w) = r \u2022 f u n + f v (f w n)`. -/\ndef foldr (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf : \u2200 m x, f m (f m x) = Q m \u2022 x) :\n  N \u2192\u2097[R] clifford_algebra Q \u2192\u2097[R] N :=\n(clifford_algebra.lift Q \u27e8f, \u03bb v, linear_map.ext $ hf v\u27e9).to_linear_map.flip\n\n@[simp] lemma foldr_\u03b9 (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf) (n : N) (m : M) :\n  foldr Q f hf n (\u03b9 Q m) = f m n :=\nlinear_map.congr_fun (lift_\u03b9_apply _ _ _) n\n\n@[simp] lemma foldr_algebra_map (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf) (n : N) (r : R) :\n  foldr Q f hf n (algebra_map R _ r) = r \u2022 n :=\nlinear_map.congr_fun (alg_hom.commutes _ r) n\n\n@[simp] lemma foldr_one (f : M \u2192\u2097[R] N \u2192\u2097[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 \u2192\u2097[R] N \u2192\u2097[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_\u03b9 (l : list M) (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf) (n : N):\n  foldr Q f hf n (l.map $ \u03b9 Q).prod = list.foldr (\u03bb 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_\u03b9, 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 (\u03b9 Q m * x) = f m (foldl Q f hf n x)`.\n\nFor example, `foldl f hf n (r \u2022 \u03b9 R u + \u03b9 R v * \u03b9 R w) = r \u2022 f u n + f v (f w n)`. -/\ndef foldl (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf : \u2200 m x, f m (f m x) = Q m \u2022 x) :\n  N \u2192\u2097[R] clifford_algebra Q \u2192\u2097[R] N :=\nlinear_map.compl\u2082 (foldr Q f hf) reverse\n\n@[simp] lemma foldl_reverse (f : M \u2192\u2097[R] N \u2192\u2097[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 \u2192\u2097[R] N \u2192\u2097[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_\u03b9 (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf) (n : N) (m : M) :\n  foldl Q f hf n (\u03b9 Q m) = f m n :=\nby rw [\u2190foldr_reverse, reverse_\u03b9, foldr_\u03b9]\n\n@[simp] lemma foldl_algebra_map (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf) (n : N) (r : R) :\n  foldl Q f hf n (algebra_map R _ r) = r \u2022 n :=\nby rw [\u2190foldr_reverse, reverse.commutes, foldr_algebra_map]\n\n@[simp] lemma foldl_one (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf) (n : N) :\n  foldl Q f hf n 1 = n :=\nby rw [\u2190foldr_reverse, reverse.map_one, foldr_one]\n\n@[simp] lemma foldl_mul (f : M \u2192\u2097[R] N \u2192\u2097[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 [\u2190foldr_reverse, \u2190foldr_reverse, \u2190foldr_reverse, reverse.map_mul, foldr_mul]\n\n/-- This lemma demonstrates the origin of the `foldl` name. -/\nlemma foldl_prod_map_\u03b9 (l : list M) (f : M \u2192\u2097[R] N \u2192\u2097[R] N) (hf) (n : N):\n  foldl Q f hf n (l.map $ \u03b9 Q).prod = list.foldl (\u03bb m n, f n m) n l :=\nby rw [\u2190foldr_reverse, reverse_prod_map_\u03b9, \u2190list.map_reverse, foldr_prod_map_\u03b9, list.foldr_reverse]\n\nend foldl\n\nlemma right_induction {P : clifford_algebra Q \u2192 Prop}\n  (hr : \u2200 r : R, P (algebra_map _ _ r))\n  (h_add : \u2200 x y, P x \u2192 P y \u2192 P (x + y))\n  (h_\u03b9_mul : \u2200 m x, P x \u2192 P (x * \u03b9 Q m)) : \u2200 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 \u2208 \u22a4 := submodule.mem_top,\n  rw \u2190supr_\u03b9_range_eq_top at this,\n  apply submodule.supr_induction _ this (\u03bb i x hx, _) _ h_add,\n  { refine submodule.pow_induction_on_right _ hr h_add (\u03bb x px m, _) hx,\n    rintro \u27e8m, rfl\u27e9,\n    exact h_\u03b9_mul _ _ px },\n  { simpa only [map_zero] using hr 0}\nend\n\nlemma left_induction {P : clifford_algebra Q \u2192 Prop}\n  (hr : \u2200 r : R, P (algebra_map _ _ r))\n  (h_add : \u2200 x y, P x \u2192 P y \u2192 P (x + y))\n  (h_mul_\u03b9 : \u2200 x m, P x \u2192 P (\u03b9 Q m * x)) : \u2200 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_\u03b9] using h_mul_\u03b9 _ _ hx },\nend\n\n/-! ### Versions with extra state -/\n/-- Auxiliary definition for `clifford_algebra.foldr'` -/\ndef foldr'_aux (f : M \u2192\u2097[R] clifford_algebra Q \u00d7 N \u2192\u2097[R] N) :\n  M \u2192\u2097[R] module.End R (clifford_algebra Q \u00d7 N) :=\nbegin\n  have v_mul := (algebra.lmul R (clifford_algebra Q)).to_linear_map \u2218\u2097 (\u03b9 Q),\n  have l := v_mul.compl\u2082 (linear_map.fst _ _ N),\n  exact { to_fun := \u03bb m, (l m).prod (f m),\n          map_add' := \u03bb v\u2082 v\u2082, linear_map.ext $ \u03bb x, prod.ext\n            (linear_map.congr_fun (l.map_add _ _) x) (linear_map.congr_fun (f.map_add _ _) x),\n          map_smul' := \u03bb c v, linear_map.ext $ \u03bb 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 \u2192\u2097[R] clifford_algebra Q \u00d7 N \u2192\u2097[R] N) (m : M) (x_fx) :\n    foldr'_aux Q f m x_fx = (\u03b9 Q m * x_fx.1, f m x_fx) := rfl\n\nlemma foldr'_aux_foldr'_aux (f : M \u2192\u2097[R] clifford_algebra Q \u00d7 N \u2192\u2097[R] N)\n  (hf : \u2200 m x fx, f m (\u03b9 Q m * x, f m (x, fx)) = Q m \u2022 fx)\n  (v : M) (x_fx) :\n  foldr'_aux Q f v (foldr'_aux Q f v x_fx) = Q v \u2022 x_fx :=\nbegin\n  cases x_fx with x fx,\n  simp only [foldr'_aux_apply_apply],\n  rw [\u2190mul_assoc, \u03b9_sq_scalar, \u2190 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 (\u03b9 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 \u2192\u2097[R] clifford_algebra Q \u00d7 N \u2192\u2097[R] N)\n  (hf : \u2200 m x fx, f m (\u03b9 Q m * x, f m (x, fx)) = Q m \u2022 fx)\n  (n : N) :\n  clifford_algebra Q \u2192\u2097[R] N :=\nlinear_map.snd _ _ _ \u2218\u2097 foldr Q (foldr'_aux Q f) (foldr'_aux_foldr'_aux Q _ hf) (1, n)\n\nlemma foldr'_algebra_map (f : M \u2192\u2097[R] clifford_algebra Q \u00d7 N \u2192\u2097[R] N)\n  (hf : \u2200 m x fx, f m (\u03b9 Q m * x, f m (x, fx)) = Q m \u2022 fx) (n r) :\n  foldr' Q f hf n (algebra_map R _ r) = r \u2022 n :=\ncongr_arg prod.snd (foldr_algebra_map _ _ _ _ _)\n\nlemma foldr'_\u03b9 (f : M \u2192\u2097[R] clifford_algebra Q \u00d7 N \u2192\u2097[R] N)\n  (hf : \u2200 m x fx, f m (\u03b9 Q m * x, f m (x, fx)) = Q m \u2022 fx) (n m) :\n  foldr' Q f hf n (\u03b9 Q m) = f m (1, n) :=\ncongr_arg prod.snd (foldr_\u03b9 _ _ _ _ _)\n\nlemma foldr'_\u03b9_mul (f : M \u2192\u2097[R] clifford_algebra Q \u00d7 N \u2192\u2097[R] N)\n  (hf : \u2200 m x fx, f m (\u03b9 Q m * x, f m (x, fx)) = Q m \u2022 fx) (n m) (x) :\n  foldr' Q f hf n (\u03b9 Q m * x) = f m (x, foldr' Q f hf n x) :=\nbegin\n  dsimp [foldr'],\n  rw [foldr_mul, foldr_\u03b9, 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_\u03b9, 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 : \u2115)\n\n/-- `nE(F)` is a subgroup of `\u03b9\u209a\u207b\u00b9(nE(K))`. -/\nlemma range_le_comap_range : (E\u27eeF\u27ef\u2b1dn) \u2264 add_subgroup.comap \u03b9\u209a E\u27eeK\u27ef\u2b1dn :=\nby { rintro P \u27e8Q, hQ\u27e9, rw [\u2190 hQ], exact \u27e8\u03b9\u209a Q, (map_nsmul \u03b9\u209a Q n).symm\u27e9 }\n\n/-- The kernel `\u03a6` of the cokernel map `E(F)/nE(F) \u2192 E(K)/nE(K)` induced by `\u03b9\u209a : E(F) \u21aa E(K)`. -/\ndef \u03a6 (E : EllipticCurve F) (K : Type u) [field K] [algebra F K] : add_subgroup E\u27eeF\u27ef/n :=\n(quotient_add_group.map _ _ _ $ @range_le_comap_range _ _ _ K _ _ n).ker\n\n/-- If `[P] \u2208 \u03a6`, then `\u03b9\u209a(P) \u2208 nE(K)`. -/\nlemma \u03a6_mem_range (P : \u03a6 n E K) : \u03b9\u209a (quot.out P.val) \u2208 E\u27eeK\u27ef\u2b1dn :=\nbegin\n  cases P with P hP,\n  change (quotient_add_group.lift _ ((quotient_add_group.mk' _).comp _) _) P = 0 at hP,\n  rw [\u2190 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 `\u03ba : \u03a6 \u2192 H\u00b9(Gal(K/F), E(K)[n])` induced by the inflation-restriction exact sequence. -/\ndef \u03ba : \u03a6 n E K \u2192 (K \u2243\u2090[F] K) \u2192 E\u27eeK\u27ef[n] :=\n\u03bb P \u03c3, \u27e8\u03c3 \u2022 (\u03a6_mem_range n P).some - (\u03a6_mem_range n P).some,\nbegin\n  change n \u2022 (\u03c3 \u2022 _ - _ : E\u27eeK\u27ef) = 0,\n  rw [smul_sub, mul_by.map_smul],\n  change \u03c3 \u2022 mul_by n _ - mul_by n _ = 0,\n  rw [(\u03a6_mem_range n P).some_spec, sub_eq_zero],\n  revert \u03c3,\n  change \u03b9\u209a (quot.out P.val) \u2208 E\u27eeK\u27ef^F,\n  rw [point_gal.fixed.eq],\n  exact \u27e8quot.out P.val, rfl\u27e9\nend\u27e9\n\n/-- `\u03ba` is injective. -/\nlemma \u03ba.injective : function.injective $ @\u03ba _ _ E K _ _ n _ _ :=\nbegin\n  intros P\u2081_ P\u2082_ hP_,\n  let P\u2081 := quot.out P\u2081_.val,\n  let P\u2082 := quot.out P\u2082_.val,\n  have hP\u2081 : \u2203 Q\u2081 : E\u27eeK\u27ef, n \u2022 Q\u2081 = \u03b9\u209a P\u2081 := \u03a6_mem_range n P\u2081_,\n  have hP\u2082 : \u2203 Q\u2082 : E\u27eeK\u27ef, n \u2022 Q\u2082 = \u03b9\u209a P\u2082 := \u03a6_mem_range n P\u2082_,\n  have hP : hP\u2081.some - hP\u2082.some \u2208 (\u03b9\u209a : E\u27eeF\u27ef \u2192+ E\u27eeK\u27ef).range :=\n  begin\n    rw [\u2190 point_gal.fixed.eq],\n    intro \u03c3,\n    rw [smul_sub, sub_eq_sub_iff_sub_eq_sub],\n    injection (congr_fun hP_) \u03c3\n  end,\n  cases hP with Q hQ,\n  apply_fun ((\u2022) n) at hQ,\n  rw [smul_sub, hP\u2081.some_spec, hP\u2082.some_spec] at hQ,\n  rw [\u2190 P\u2081_.eta P\u2081_.property, \u2190 P\u2082_.eta P\u2082_.property, subtype.mk_eq_mk, \u2190 quotient.out_equiv_out],\n  change \u2203 S : E\u27eeF\u27ef, n \u2022 S = -P\u2081 + P\u2082,\n  existsi [-Q],\n  apply_fun (\u03b9\u209a : E\u27eeF\u27ef \u2192+ E\u27eeK\u27ef) using point_hom.injective,\n  rw [\u2190 neg_inj, \u2190 map_neg, smul_neg, neg_neg, map_nsmul, \u2190 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\u27eeK\u27ef/2) \u2192 fintype E\u27eeF\u27ef/2 :=\nadd_group.fintype_of_ker_codom $ fintype.of_injective (\u03ba 2) (\u03ba.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 : \u2115) : finset $ primes K :=\n@set.to_finset _ {p : primes K | (p.valuation ((F\u2191K)E.disc_unit) \u2260 1) \u2228 (p.valuation ((\u2124\u2191K)n) < 1)}\nbegin\n  sorry\nend\n\nvariables [number_field F] [number_field K] [algebra F\u27eeE[2]\u27ef K] [is_scalar_tower F F\u27eeE[2]\u27ef K]\n\nnotation K\u27eeE; n\u27ef\u00b2 := K\u27ee@bad_primes _ _ E _ _ _ infer_instance n, n\u27ef\u00b2\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\u2081 : E.a\u2081 = 0) (ha\u2083 : E.a\u2083 = 0)\nvariables {a b c : K} (h3 : (cubic.map (F\u2191K) $ \u03c8\u2082_x E F).roots = {a, b, c})\n\ninclude ha\u2081 ha\u2083 h3\n\nlocal notation n`\u2b1d`K := (zpow_group_hom n : K\u02e3 \u2192* K\u02e3).range\n\n/-- The complete 2-descent function `\u03b4 : E(K) \u2192 K\u02e3/(K\u02e3)\u00b2 \u00d7 K\u02e3/(K\u02e3)\u00b2`. -/\ndef \u03b4.to_fun : E\u27eeK\u27ef \u2192 (K\u02e3 \u29f8 (2\u2b1dK)) \u00d7 (K\u02e3 \u29f8 (2\u2b1dK))\n| 0            := 1\n| (some x y w) :=\nif ha : x = a then\n  (units.mk0 ((a - c) * (a - b)\u207b\u00b9) $ mul_ne_zero (sub_ne_zero.mpr (\u03c8\u2082_x.roots_ne h3).2.1) $\n    inv_ne_zero $ sub_ne_zero.mpr (\u03c8\u2082_x.roots_ne h3).1,\n  units.mk0 (a - b) $ sub_ne_zero.mpr (\u03c8\u2082_x.roots_ne h3).1)\nelse if hb : x = b then\n  (units.mk0 (b - a) $ sub_ne_zero.mpr (\u03c8\u2082_x.roots_ne h3).1.symm,\n  units.mk0 ((b - c) * (b - a)\u207b\u00b9) $ mul_ne_zero (sub_ne_zero.mpr (\u03c8\u2082_x.roots_ne h3).2.2) $\n    inv_ne_zero $ sub_ne_zero.mpr (\u03c8\u2082_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\u2081 ha\u2083 h3\n\n-- Input: explicit computation\n/-- The complete 2-descent homomorphism `\u03b4 : E(K) \u2192 K\u02e3/(K\u02e3)\u00b2 \u00d7 K\u02e3/(K\u02e3)\u00b2`. -/\ndef \u03b4 : E\u27eeK\u27ef \u2192+ additive ((K\u02e3 \u29f8 (2\u2b1dK)) \u00d7 (K\u02e3 \u29f8 (2\u2b1dK))) :=\n{ to_fun    := \u03b4.to_fun ha\u2081 ha\u2083 h3,\n  map_zero' := rfl,\n  map_add'  := sorry }\n\n@[simp] lemma \u03b4.map_zero : \u03b4 ha\u2081 ha\u2083 h3 (0 : E\u27eeK\u27ef) = 0 := (\u03b4 ha\u2081 ha\u2083 h3).map_zero'\n\n@[simp] lemma \u03b4.map_add (P Q : E\u27eeK\u27ef) : \u03b4 ha\u2081 ha\u2083 h3 (P + Q) = \u03b4 ha\u2081 ha\u2083 h3 P + \u03b4 ha\u2081 ha\u2083 h3 Q :=\n(\u03b4 ha\u2081 ha\u2083 h3).map_add' P Q\n\n-- Input: constructive proof for `ker \u03b4 = 2E(K)`\nlemma \u03b4.ker : (\u03b4 ha\u2081 ha\u2083 h3).ker = E\u27eeK\u27ef\u2b1d2 :=\nbegin\n  ext P,\n  split,\n  { intro hP,\n    cases P with x y w,\n    { exact \u27e80, rfl\u27e9 },\n    { change \u03b4.to_fun ha\u2081 ha\u2083 h3 _ = 1 at hP,\n      simp only [\u03b4.to_fun] at hP,\n      split_ifs at hP,\n      { sorry },\n      { sorry },\n      { sorry } } },\n  { rintro \u27e8Q, hQ\u27e9,\n    rw [\u2190 hQ],\n    change \u03b4 ha\u2081 ha\u2083 h3 (2 \u2022 Q) = 0,\n    rw [map_nsmul],\n    change ((\u03b4 ha\u2081 ha\u2083 h3 Q).1 ^ 2, (\u03b4 ha\u2081 ha\u2083 h3 Q).2 ^ 2) = 1,\n    apply prod.ext,\n    all_goals { rw [\u2190 quotient_group.out_eq' (\u03b4 ha\u2081 ha\u2083 h3 Q).1,\n                    \u2190 quotient_group.out_eq' (\u03b4 ha\u2081 ha\u2083 h3 Q).2],\n                exact (quotient_group.eq_one_iff _).mpr \u27e8quot.out _, rfl\u27e9 } }\nend\n\n-- Input: local analysis for `im \u03b4 \u2264 K(E; 2) \u00d7 K(E; 2)`\nlemma \u03b4.range_le : (\u03b4 ha\u2081 ha\u2083 h3).range \u2264 K\u27eeE; 2\u27ef\u00b2 :=\nbegin\n  sorry\nend\n\n/-- The lift `\u03b4' : E(K)/2E(K) \u2192 K(E; 2) \u00d7 K(E; 2)` of `\u03b4`. -/\ndef \u03b4.lift : (E\u27eeK\u27ef/2) \u2192+ K\u27eeE; 2\u27ef\u00b2 :=\n(add_subgroup.inclusion $ \u03b4.range_le ha\u2081 ha\u2083 h3).comp $\n  (quotient_add_group.range_ker_lift $ \u03b4 ha\u2081 ha\u2083 h3).comp $\n  (quotient_add_group.equiv_quotient_of_eq $ \u03b4.ker ha\u2081 ha\u2083 h3).symm.to_add_monoid_hom\n\nlemma \u03b4.lift.injective : function.injective $ @\u03b4.lift _ _ _ K _ _ _ _ _ _ ha\u2081 ha\u2083 _ _ _ h3 :=\nbegin\n  apply function.injective.comp,\n  { intros x y hxy,\n    rw [\u2190 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 (\u03b4 ha\u2081 ha\u2083 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\u27eeE[2]\u27ef := char_zero_of_injective_algebra_map (F\u2191F\u27eeE[2]\u27ef).injective\n\n/-- A splitting field of a number field is a number field. -/\ninstance : number_field F\u27eeE[2]\u27ef :=\n@number_field.mk _ _ _ $ @finite_dimensional.trans _ F _ _ _ _ _ _\n  (@algebra.to_module _ _ _ _ $ @algebra_rat F\u27eeE[2]\u27ef _ _) (by convert is_scalar_tower.rat) _ _\n\n/-- A splitting field of a number field is Galois. -/\ninstance : is_galois F F\u27eeE[2]\u27ef := \u27e8\u27e9\n\n/-- The weak Mordell-Weil theorem for `n = 2` assuming `E[2] \u2282 E(F)`: `E(F)/2E(F)` is finite. -/\ninstance coker_2_of_rat_E\u2082.fintype (ha\u2081 : E.a\u2081 = 0) (ha\u2083 : E.a\u2083 = 0) : fintype E\u27eeF\u27eeE[2]\u27ef\u27ef/2 :=\nfintype.of_injective _ $ \u03b4.lift.injective ha\u2081 ha\u2083\n  ((cubic.splits_iff_roots_eq_three $ \u03c8\u2082_x.a_ne_zero E F).mp $ \u03c8\u2082_x.splits F\u27eeE[2]\u27ef)\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\u27eeF\u27ef/2 :=\nbegin\n  apply @coker_2_of_fg_extension.fintype _ _ E F\u27eeE[2]\u27ef,\n  apply @fintype.of_equiv _ _ (@coker_2_of_rat_E\u2082.fintype _ _ E.cov\u2098 _ (cov\u2098.a\u2081 E) (cov\u2098.a\u2083 E)),\n  apply (quotient_add_group.quotient_equiv_of_equiv _ 2).to_equiv,\n  rw [\u2190 \u03c8\u2082_x.eq_cov\u2098],\n  apply cov\u2098.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\u27eeF\u27ef := 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (ha : irrational \u03b1) : \n\u2200 \u03b5 > 0, \u2203 N : \u2115, \u2200 n : \u2115, n \u2265 N \u2192 \u2203 m : \u2124, |((m : \u211d) * \u03b1) % 1 - \u03b5| < \u03b5 :=\nbegin\n  assume (\u03b5 : \u211d) (h\u03b5 : \u03b5 > 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 : \u2200 (i j : \u2124), i \u2260 j \u2192 ((i : \u211d) * \u03b1) % 1 \u2260 ((j : \u211d) * \u03b1) % 1, from sorry,\n\n  -- If this were not true, then\n  have h2 : ((i : \u211d) * \u03b1) % 1 = ((j : \u211d) * \u03b1) % 1 \u2192 i = j, from sorry,\n\n  -- Then\n  have h3 : ((i : \u211d) * \u03b1) % 1 = ((j : \u211d) * \u03b1) % 1 \u2192 irrational \u03b1, 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 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h5 : \u2200 (i j : \u2124), i \u2260 j \u2192 ((i : \u211d) * \u03b1) % 1 \u2260 ((j : \u211d) * \u03b1) % 1, from sorry,\n  have h6 : \u2200 (i : \u2124), \u2203 (j : \u2124), ((j : \u211d) * \u03b1) % 1 \u2260 ((i : \u211d) * \u03b1) % 1, from sorry,\n  have h7 : \u2200 (i : \u2124), \u2203 (j : \u2124), ((j : \u211d) * \u03b1) % 1 \u2260 ((i : \u211d) * \u03b1) % 1, from sorry,\n  have h8 : \u2200 (i : \u2124), \u2203 (j : \u2124), ((j : \u211d) * \u03b1) % 1 \u2260 ((i : \u211d) * \u03b1) % 1, from sorry,\n  have h9 : \u2203 (i : \u2124), \u2203 (j : \u2124), ((j : \u211d) * \u03b1) % 1 \u2260 ((i : \u211d) * \u03b1) % 1, from sorry,\n  have h10 : set.Icc 0 1 \u2260 \u2205, from sorry,\n  -- have h4 : \u2203 (i : \u2124), \u2203 (j : \u2124), ((j : \u211d) * \u03b1) % 1 \u2260 ((i : \u211d) * \u03b1) % 1, from sorry,\n  have h11 : \u221e, from sorry,\n  have h12 : ((j : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h13 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h14 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h15 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h16 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h17 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h18 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h19 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h20 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h21 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h22 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h23 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h24 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h25 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h26 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h27 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h28 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h29 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h30 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h31 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h32 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h33 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h34 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h35 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h36 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h37 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h38 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h39 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h40 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h41 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h42 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h43 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) % 1 \u2208 set.Icc 0 1, from sorry,\n  have h44 : \u2200 (i : \u2124), ((i : \u211d) * \u03b1) %\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_irrational_orbit (\u03b1 : \u211d) : \n  (\u2200 (i j : \u2124), i \u2260 j \u2192 \u00ac(\u03b1 * i - \u230a\u03b1 * i\u230b = \u03b1 * j - \u230a\u03b1 * j\u230b)) \n  \u2192 \u2200 x : \u211d, x \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \n  \u2192 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \u2227 abs (y - x) < \u03b5 \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 : \u2200 (i j : \u2124), i \u2260 j \u2192 \u00ac(\u03b1 * i - \u230a\u03b1 * i\u230b = \u03b1 * j - \u230a\u03b1 * j\u230b)),\n  assume (x : \u211d) (h2 : x \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b)),\n  assume (\u03b5 : \u211d) (h3 : \u03b5 > 0),\n\n  --$S:=\\{\\{i \\alpha\\} \\mid i \\in \\mathbb{Z}\\}$ is an infinite subset of $\\left[0,1\\right]$.\n  have h4 : \u2200 (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b), from sorry,\n  have h5 : set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \u2260 \u2205, from sorry,\n  have h6 : set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \u2286 set.Icc 0 1, from sorry,\n\n  --By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h7 : \u2200 (B : set \u211d), B \u2260 \u2205 \u2192 B \u2286 set.Icc 0 1 \u2192 \u2203 (l : \u211d), l \u2208 set.Icc 0 1 \u2227 (\u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (x : \u211d), x \u2208 B \u2227 abs (l - x) < \u03b5), from sorry,\n  have h8 : \u2203 (l : \u211d), l \u2208 set.Icc 0 1 \u2227 (\u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (x : \u211d), x \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \u2227 abs (l - x) < \u03b5), from sorry,\n\n  --One can thus find pairs of elements of $S$ that are arbitrarily close. \n  have h9 : \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (x y : \u211d), x \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \u2227 y \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \u2227 abs (x - y) < \u03b5, 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 : \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (x : \u211d), x \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \u2227 abs x < \u03b5, from sorry,\n\n  --To show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. \n  show \u2203 (y : \u211d), y \u2208 set.range (\u03bb (i : \u2124), \u03b1 * i - \u230a\u03b1 * i\u230b) \u2227 abs (y - x) < \u03b5, from sorry,\nend\n\n--OUTPUT 4\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=irrational_orbit_dense {\u03b1 : Type*} [discrete_linear_ordered_field \u03b1] (\u03b1 : \u03b1) (h \u22a2 : \u00ac is_rat \u03b1) :\n  \u2200 (\u03b5 : \u03b1) (\u03b5_pos : 0 < \u03b5) (y : \u03b1) (y_in : 0 \u2264 y \u2227 y < 1), \u2203 x : \u03b1, x \u2208 {n \u2022 \u03b1 | n : \u2124} \u2227 |y - x| < \u03b5 :=\nbegin\n  assume \u03b5 (\u03b5_pos : 0 < \u03b5) y (y_in : 0 \u2264 y \u2227 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 : \u2200 (i j : \u2124) (h_ne : i \u2260 j), (i \u2022 \u03b1) - (i\u2022\u03b1).to_int \u2260 (j \u2022 \u03b1) - (j\u2022\u03b1).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 : \u2200 (i j : \u2124) (h_ne : i \u2260 j), (i \u2022 \u03b1) - (i\u2022\u03b1).to_int = (j \u2022 \u03b1) - (j\u2022\u03b1).to_int \u2192\n    (\u03b1 = (i \u2022 \u03b1).to_int - (j \u2022 \u03b1).to_int) / (i - j) \u2228 (\u03b1 = (j \u2022 \u03b1).to_int - (i \u2022 \u03b1).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 \u2022 \u03b1 | n : \u2124} \u2286 {x : \u03b1 | 0 \u2264 x \u2227 x < 1}, from sorry,\n  have h4 : \u2203 x : \u03b1, x \u2208 {n \u2022 \u03b1 | n : \u2124}, from sorry,\n  have h5 : {n \u2022 \u03b1 | n : \u2124} \u2260 \u2205, from sorry,\n  have h6 : {n \u2022 \u03b1 | n : \u2124} \u2286 {x : \u03b1 | 0 \u2264 x \u2227 x < 1}, from sorry,\n  have h7 : \u2200 (x : \u03b1), x \u2208 {n \u2022 \u03b1 | n : \u2124} \u2192 0 \u2264 x \u2227 x < 1, from sorry,\n  have h8 : \u2203 (x : \u03b1), x \u2208 {n \u2022 \u03b1 | n : \u2124} \u2227 0 \u2264 x \u2227 x < 1, from sorry,\n  have h9 : \u2200 (x : \u03b1), x \u2208 {n \u2022 \u03b1 | n : \u2124} \u2192 x \u2264 1, from sorry,\n  have h10 : \u2203 (x : \u03b1), x \u2208 {n \u2022 \u03b1 | n : \u2124} \u2227 x \u2264 1, from sorry,\n  have h11 : {n \u2022 \u03b1 | n : \u2124} \u2286 {x : \u03b1 | x \u2264 1}, from sorry,\n  have h12 : {n \u2022 \u03b1 | n : \u2124} \u2286 \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1), from sorry,\n  have h13 : \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2286 {x : \u03b1 | 0 \u2264 x \u2227 x < 1}, from sorry,\n  have h14 : \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2260 \u2205, from sorry,\n  have h15 : \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2286 {x : \u03b1 | 0 \u2264 x \u2227 x < 1}, from sorry,\n  have h16 : \u2200 (x : \u03b1), x \u2208 \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2192 0 \u2264 x \u2227 x < 1, from sorry,\n  have h17 : \u2203 (x : \u03b1), x \u2208 \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2227 0 \u2264 x \u2227 x < 1, from sorry,\n  have h18 : \u2200 (x : \u03b1), x \u2208 \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2192 x \u2264 1, from sorry,\n  have h19 : \u2203 (x : \u03b1), x \u2208 \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2227 x \u2264 1, from sorry,\n  have h20 : \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2286 {x : \u03b1 | x \u2264 1}, from sorry,\n\n  -- By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h21 : \u2203 (x : \u03b1), x \u2208 \u2191({n \u2022 \u03b1 | n : \u2124} : set \u03b1) \u2227 \u2200 (\u03b5 : \u03b1) (\u03b5_pos : 0 < \u03b5), \u2203 (N : \u2124), \u2200 (n : \u2124), n > N \u2192 |x - (n\u2022\u03b1)| < \u03b5, 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 : \u2200 (\u03b5 : \u03b1) (\u03b5_pos : 0 < \u03b5), \u2203 (i j : \u2124) (h_ne : i \u2260 j), |x - (i\u2022\u03b1)| < \u03b5 \u2227 |x - (j\u2022\u03b1)| < \u03b5, from sorry,\n  cases h23 \u03b5 \u03b5_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 : \u2200 (i j : \u2124) (h_ne : i \u2260 j), |(i\u2022\u03b1) - (j\u2022\u03b1)| \u2208 {n \u2022 \u03b1 | n : \u2124}, from sorry,\n  have h30 : \u2200 (\u03b5 : \u03b1) (\u03b5_pos : 0 < \u03b5), \u2203 (N : \u2124), \u2200 (n : \u2124), n > N \u2192 |(0:\u03b1) - (n\u2022\u03b1)| < \u03b5, from sorry,\n\n  -- To show that $S$ is dense in $[0, 1]$, consider $y \\in[0,1]$, and $\\epsilon>0$. \n  have h31 : \u2200 (y : \u03b1) (h_in : 0 \u2264 y \u2227 y < 1) (\u03b5 : \u03b1) (\u03b5_pos : 0 < \u03b5), \u2203 (x : \u03b1), x \u2208 {n \u2022 \u03b1 | n : \u2124} \u2227 |y - x| < \u03b5, 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 : \u2200 (y : \u03b1) (h_in : 0 \u2264 y \u2227 y < 1) (\u03b5 : \u03b1) (\u03b5_pos : 0 < \u03b5), \u2203 (x : \u03b1), x \u2208 {n \u2022 \u03b1 | n : \u2124} \u2227 |y - x| < \u03b5, from sorry,\n  show \u2203 (x : \u03b1), x \u2208 {n \u2022 \u03b1 | n : \u2124} \u2227 |y - x| < \u03b5, from sorry,\nend\n\n--OUTPUT 5\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h1 : \u00ac \u2203 x : \u211d, \u03b1 = x/x) : \n\u2200 y \u2208 Icc 0 1, \u2203 x : \u211d, \u2203 i : \u2124, y = x \u2227 x = i * \u03b1 :=\nbegin\n  assume y h2,\n  have h3 : \u2200 i j : \u2124, i \u2260 j \u2192 i * \u03b1 \u2260 j * \u03b1, from sorry,\n  have h4 : \u2200 i : \u2124, i * \u03b1 \u2260 0, from sorry, \n  have h5 : \u2203 x : \u211d, \u2203 i : \u2124, \u2200 i : \u2124, x \u2260 i * \u03b1, from sorry,\n  have h6 : \u2200 i : \u2124, \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h7 : \u2203 N : \u2115, \u2200 i : \u2124, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h8 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h9 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h10 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h11 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h12 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h13 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h14 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h15 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h16 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h17 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h18 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h19 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h20 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h21 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h22 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h23 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h24 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h25 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h26 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h27 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h28 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h29 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h30 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h31 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h32 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h33 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h34 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h35 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h36 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h37 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h38 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h39 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h40 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h41 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h42 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h43 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h44 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h45 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h46 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192 \u2203 x : \u211d, x \u2260 i * \u03b1, from sorry,\n  have h47 : \u2203 N : \u2115, \u2200 i : \u2115, i \u2265 N \u2192\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u00ac is_rat \u03b1) : \n  \u2203 (S : set \u211d), \u2200 (x : \u211d), x \u2208 S \u2192 0 \u2264 x \u2227 x < 1 \u2227 \u2200 y : \u211d, 0 \u2264 y \u2227 y < 1 \u2192 \u2203 (x : \u211d), x \u2208 S \u2227 |y - x| < 1 :=\nbegin\n  -- Let $\\alpha$ be an irrational number.\n  assume \u03b1,\n  assume h\u03b1 : \u00ac is_rat \u03b1,\n\n  -- Then for distinct $i, j \\in \\mathbb{Z}$, we must have $\\{i \\alpha\\} \\neq\\{j \\alpha\\}$.\n  have h2 : \u2200 (i j : \u2124), i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, \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 : \u2200 (i j : \u2124), i \u2260 j \u2192 (\u03b1 = (floor i \u03b1 - floor j \u03b1) / (i - j) \u2192 (\u03b1 \u2208 \u211a)), \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 : \u2203 (S : set \u211d), \u2200 (x : \u211d), x \u2208 S \u2192 0 \u2264 x \u2227 x < 1 \u2227 \u2200 (y : \u211d), y \u2208 S \u2192 0 \u2264 y \u2227 y < 1 \u2227 \u2200 (i j : \u2124), i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, \n  from sorry,\n\n  -- By the Bolzano-Weierstrass theorem, $S$ has a limit point in $[0, 1]$.\n  have h5 : \u2203 (S : set \u211d), \u2200 (x : \u211d), x \u2208 S \u2192 0 \u2264 x \u2227 x < 1 \u2227 \u2200 (y : \u211d), y \u2208 S \u2192 0 \u2264 y \u2227 y < 1 \u2227 \u2200 (i j : \u2124), i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1} \u2227 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 S \u2227 |x - y| < \u03b5, \n  from sorry,\n\n  -- One can thus find pairs of elements of $S$ that are arbitrarily close.\n  have h6 : \u2203 (S : set \u211d), \u2200 (x : \u211d), x \u2208 S \u2192 0 \u2264 x \u2227 x < 1 \u2227 \u2200 (y : \u211d), y \u2208 S \u2192 0 \u2264 y \u2227 y < 1 \u2227 \u2200 (i j : \u2124), i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1} \u2227 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 S \u2227 |x - y| < \u03b5 \u2227 \u2200 (x y : \u211d), x \u2208 S \u2227 y \u2208 S \u2192 \u2203 (\u03b5 : \u211d), \u03b5 > 0 \u2227 |x - y| < \u03b5, \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 : \u2203 (S : set \u211d), \u2200 (x : \u211d), x \u2208 S \u2192 0 \u2264 x \u2227 x < 1 \u2227 \u2200 (y : \u211d), y \u2208 S \u2192 0 \u2264 y \u2227 y < 1 \u2227 \u2200 (i j : \u2124), i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1} \u2227 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 S \u2227 |x - y| < \u03b5 \u2227 \u2200 (x y : \u211d), x \u2208 S \u2227 y \u2208 S \u2192 \u2203 (\u03b5 : \u211d), \u03b5 > 0 \u2227 |x - y| < \u03b5 \u2227 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 S \u2227 |x - y| < \u03b5, \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 : \u2203 (S : set \u211d), \u2200 (x : \u211d), x \u2208 S \u2192 0 \u2264 x \u2227 x < 1 \u2227 \u2200 (y : \u211d), y \u2208 S \u2192 0 \u2264 y \u2227 y < 1 \u2227 \u2200 (i j : \u2124), i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1} \u2227 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 S \u2227 |x - y| < \u03b5 \u2227 \u2200 (x y : \u211d), x \u2208 S \u2227 y \u2208 S \u2192 \u2203 (\u03b5 : \u211d), \u03b5 > 0 \u2227 |x - y| < \u03b5 \u2227 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 S \u2227 |x - y| < \u03b5 \u2227 \u2200 (y : \u211d), 0 \u2264 y \u2227 y < 1 \u2192 \u2203 (x : \u211d), x \u2208 S \u2227 \u2203 (\u03b5 : \u211d), \u03b5 > 0 \u2227 |y - x| < \u03b5, \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 : \u2203 (S : set \u211d), \u2200 (x : \u211d), x \u2208 S \u2192 0 \u2264 x \u2227 x < 1 \u2227 \u2200 (y : \u211d), y \u2208 S \u2192 0 \u2264 y \u2227 y < 1 \u2227 \u2200 (i j : \u2124), i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1} \u2227 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 S \u2227 |x - y| < \u03b5 \u2227 \u2200 (x y : \u211d), x \u2208 S \u2227 y \u2208 S \u2192 \u2203 (\u03b5 : \u211d), \u03b5 > 0 \u2227 |x - y| < \u03b5 \u2227 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (y : \u211d), y \u2208 S \u2227 |x - y| < \u03b5 \u2227 \u2200 (y : \u211d), 0 \u2264 y \u2227 y < 1 \u2192 \u2203 (x : \u211d), x \u2208 S \u2227 \u2203 (\u03b5 : \u211d), \u03b5 > 0 \u2227 |y - x| < \u03b5 \u2227 \u2200 (y : \u211d), 0 \u2264 y \u2227 y < 1 \u2192 \u2203 (x : \u211d), x \u2208 S \u2227 \u2200 (\u03b5 : \u211d), \u03b5 > 0 \u2192 \u2203 (n : \u2115), |y - ({n * x} % 1) | < \u03b5, \n  from sorry,\n\n  -- QED\n  show \u2203 (S : set\nend --Needs more than 2000 tokens!\n\n--OUTPUT 7\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit : \u2200 (\u03b1 : \u211d) (h\u03b1 : \u00ac is_rat \u03b1), \u2200 y \u2208 set.Icc 0 1, \u2203 x \u2208 set.Icc 0 1, \u2203 N : \u2124, \n\u2200 (\u03b5 : \u211d) (h\u03b5 : \u03b5 > 0), |y - (N : \u211d) * x| < \u03b5 :=\nbegin\n  assume \u03b1 h\u03b1 y h1,\n  have h2 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h3 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h4 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h5 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h6 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h7 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h8 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h9 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h10 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n\n  have h11 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h12 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h13 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h14 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h15 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h16 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h17 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h18 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h19 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h20 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h21 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h22 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h23 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h24 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h25 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h26 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h27 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h28 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h29 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h30 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h31 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h32 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h33 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h34 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h35 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h36 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h37 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h38 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h39 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h40 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h41 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h42 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h43 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h44 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h45 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h46 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h47 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h48 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h49 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h50 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h51 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h52 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h53 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h54 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\n  have h55 : \u2200 i j : \u2124, i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from sorry,\nend --Needs more than 2000 tokens!\n\n--OUTPUT 8\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_irrational_orbit {\u03b1 : Type*} [decidable_linear_order \u03b1] (\u03b1 : \u211a) : \u2200 \u03b5 > 0, \u2203 n : \u2124, |n*\u03b1 - (n*\u03b1).floor| < \u03b5 :=\nbegin\n  assume \u03b5,\n  assume h1 : \u03b5 > 0,\n  have h2 : \u2203 n : \u2124, |n*\u03b1 - (n*\u03b1).floor| < \u03b5, from sorry,\n  show \u2203 n : \u2124, |n*\u03b1 - (n*\u03b1).floor| < \u03b5, 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from sorry,\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : \u03b5 > 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 \u03b5 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 \u03b5 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 : \u2200 n > N, n > N1 \u2227 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 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \n  from sorry,\n    \n  --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n  have h15 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \n  from sorry,\n\n  --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n  --Hence the result\n  show  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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\u2081 v\u2082 u u\u2081 u\u2082\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\nvariables {D : Type u\u2082} [category.{v\u2082} D]\nvariables (G : C \u2964 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\u2081} X)) \u2243 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 (\u22a4_ C)) :=\nterminal_is_terminal.is_terminal_obj G (\u22a4_ 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\u27e8\u03bb F,\nbegin\n  haveI := has_limit.mk \u27e8_, is_limit_of_has_terminal_of_preserves_limit G\u27e9,\n  apply has_limit_of_iso F.unique_from_empty.symm,\nend\u27e9\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 \u22a4 \u27f6 \u22a4`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_is_iso\n  (f : G.obj (\u22a4_ C) \u27f6 \u22a4_ 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 \u22a4 \u2245 \u22a4`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_iso\n  (f : G.obj (\u22a4_ C) \u2245 \u22a4_ 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 (\u22a4_ C) \u2245 \u22a4_ 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 \u2190 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\u2081} X)) \u2243 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 (\u22a5_ C)) :=\ninitial_is_initial.is_initial_obj G (\u22a5_ 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\u27e8\u03bb F,\nbegin\n  haveI := has_colimit.mk \u27e8_, is_colimit_of_has_initial_of_preserves_colimit G\u27e9,\n  apply has_colimit_of_iso F.unique_from_empty,\nend\u27e9\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 `\u22a5 \u27f6 G.obj \u22a5`, then `G` preserves initial objects. -/\ndef preserves_initial_of_is_iso\n  (f : \u22a5_ D \u27f6 G.obj (\u22a5_ 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 `\u22a5 \u2245 G.obj \u22a5 `, then `G` preserves initial objects. -/\ndef preserves_initial_of_iso\n  (f : \u22a5_ D \u2245 G.obj (\u22a5_ 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 (\u22a5_ C) \u2245 \u22a5_ 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 \u2190 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\u2082`,\n  shows that if `r` is partially well-ordered on `s`, then `list.sublist_forall\u2082` 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 {\u03b1 : 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 \u03b1) (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop :=\nwell_founded (\u03bb (a : s) (b : s), r a b)\n\nlemma well_founded_on_iff {s : set \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n  s.well_founded_on r \u2194 well_founded (\u03bb (a b : \u03b1), r a b \u2227 a \u2208 s \u2227 b \u2208 s) :=\nbegin\n  have f : rel_embedding (\u03bb (a : s) (b : s), r a b) (\u03bb (a b : \u03b1), r a b \u2227 a \u2208 s \u2227 b \u2208 s) :=\n    \u27e8\u27e8coe, subtype.coe_injective\u27e9, \u03bb a b, by simp\u27e9,\n  refine \u27e8\u03bb h, _, f.well_founded\u27e9,\n  rw well_founded.well_founded_iff_has_min,\n  intros t ht,\n  by_cases hst : (s \u2229 t).nonempty,\n  { rw \u2190 subtype.preimage_coe_nonempty at hst,\n    rcases well_founded.well_founded_iff_has_min.1 h (coe \u207b\u00b9' t) hst with \u27e8\u27e8m, ms\u27e9, mt, hm\u27e9,\n    exact \u27e8m, mt, \u03bb x xt \u27e8xm, xs, ms\u27e9, hm \u27e8x, xs\u27e9 xt xm\u27e9 },\n  { rcases ht with \u27e8m, mt\u27e9,\n    exact \u27e8m, mt, \u03bb x xt \u27e8xm, xs, ms\u27e9, hst \u27e8m, \u27e8ms, mt\u27e9\u27e9\u27e9 }\nend\n\nlemma well_founded_on.induction {s : set \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (hs : s.well_founded_on r) {x : \u03b1}\n  (hx : x \u2208 s) {P : \u03b1 \u2192 Prop} (hP : \u2200 (y \u2208 s), (\u2200 (z \u2208 s), r z y \u2192 P z) \u2192 P y) :\n  P x :=\nbegin\n  let Q : s \u2192 Prop := \u03bb y, P y,\n  change Q \u27e8x, hx\u27e9,\n  refine well_founded.induction hs \u27e8x, hx\u27e9 _,\n  rintros \u27e8y, ys\u27e9 ih,\n  exact hP _ ys (\u03bb z zs zy, ih \u27e8z, zs\u27e9 zy),\nend\n\ninstance is_strict_order.subset {s : set \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_strict_order \u03b1 r] :\n  is_strict_order \u03b1 (\u03bb (a b : \u03b1), r a b \u2227 a \u2208 s \u2227 b \u2208 s) :=\n{ to_is_irrefl := \u27e8\u03bb a con, irrefl_of r a con.1 \u27e9,\n  to_is_trans := \u27e8\u03bb a b c ab bc, \u27e8trans_of r ab.1 bc.1, ab.2.1, bc.2.2\u27e9 \u27e9 }\n\ntheorem well_founded_on_iff_no_descending_seq {s : set \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_strict_order \u03b1 r] :\n  s.well_founded_on r \u2194 \u2200 (f : ((>) : \u2115 \u2192 \u2115 \u2192 Prop) \u21aar r), \u00ac (range f) \u2286 s :=\nbegin\n  rw [well_founded_on_iff, rel_embedding.well_founded_iff_no_descending_seq],\n  refine \u27e8\u03bb h f con, begin\n      refine h.elim' \u27e8\u27e8f, f.injective\u27e9, \u03bb a b, _\u27e9,\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, \u03bb h, \u27e8\u03bb con, _\u27e9\u27e9,\n  rcases con with \u27e8f, hf\u27e9,\n  have hfs' : \u2200 n : \u2115, f n \u2208 s := \u03bb n, (hf.2 n.lt_succ_self).2.2,\n  refine h \u27e8f, \u03bb a b, _\u27e9 (\u03bb n hn, _),\n  { rw \u2190 hf,\n    exact \u27e8\u03bb h, \u27e8h, hfs' _, hfs' _\u27e9, \u03bb h, h.1\u27e9 },\n  { rcases set.mem_range.1 hn with \u27e8m, hm\u27e9,\n    rw \u2190 hm,\n    apply hfs' }\nend\n\nsection has_lt\nvariables [has_lt \u03b1]\n\n/-- `s.is_wf` indicates that `<` is well-founded when restricted to `s`. -/\ndef is_wf (s : set \u03b1) : Prop := well_founded_on s (<)\n\nlemma is_wf_univ_iff : is_wf (univ : set \u03b1) \u2194 well_founded ((<) : \u03b1 \u2192 \u03b1 \u2192 Prop) :=\nby simp [is_wf, well_founded_on_iff]\n\nvariables {s t : set \u03b1}\n\ntheorem is_wf.mono (h : is_wf t) (st : s \u2286 t) : is_wf s :=\nbegin\n  rw [is_wf, well_founded_on_iff] at *,\n  refine subrelation.wf (\u03bb x y xy, _) h,\n  exact \u27e8xy.1, st xy.2.1, st xy.2.2\u27e9,\nend\nend has_lt\n\nsection partial_order\nvariables [partial_order \u03b1] {s t : set \u03b1} {a : \u03b1}\n\ntheorem is_wf_iff_no_descending_seq :\n  is_wf s \u2194 \u2200 (f : (order_dual \u2115) \u21aao \u03b1), \u00ac (range f) \u2286 s :=\nbegin\n  haveI : is_strict_order \u03b1 (\u03bb (a b : \u03b1), a < b \u2227 a \u2208 s \u2227 b \u2208 s) :=\n  { to_is_irrefl := \u27e8\u03bb x con, lt_irrefl x con.1\u27e9,\n    to_is_trans := \u27e8\u03bb a b c ab bc, \u27e8lt_trans ab.1 bc.1, ab.2.1, bc.2.2\u27e9\u27e9, },\n  rw [is_wf, well_founded_on_iff_no_descending_seq],\n  exact \u27e8\u03bb h f, h f.lt_embedding, \u03bb h f, h (order_embedding.of_strict_mono\n    f (\u03bb _ _, f.map_rel_iff.2))\u27e9,\nend\n\ntheorem is_wf.union (hs : is_wf s) (ht : is_wf t) : is_wf (s \u222a t) :=\nbegin\n  classical,\n  rw [is_wf_iff_no_descending_seq] at *,\n  rintros f fst,\n  have h : infinite (f \u207b\u00b9' s) \u2228 infinite (f \u207b\u00b9' t),\n  { have h : infinite (univ : set \u2115) := infinite_univ,\n    have hpre : f \u207b\u00b9' (s \u222a t) = set.univ,\n    { rw [\u2190 image_univ, image_subset_iff, univ_subset_iff] at fst,\n      exact fst },\n    rw preimage_union at hpre,\n    rw \u2190 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 [\u2190 infinite_coe_iff, \u2190 infinite_coe_iff] at h,\n  cases h with inf inf; haveI := inf,\n  { apply hs ((nat.order_embedding_of_set (f \u207b\u00b9' s)).dual.trans f),\n    change range (function.comp f (nat.order_embedding_of_set (f \u207b\u00b9' s))) \u2286 s,\n    rw [range_comp, image_subset_iff],\n      simp },\n  { apply ht ((nat.order_embedding_of_set (f \u207b\u00b9' t)).dual.trans f),\n    change range (function.comp f (nat.order_embedding_of_set (f \u207b\u00b9' t))) \u2286 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) : Prop :=\n  \u2200 (f : \u2115 \u2192 \u03b1), range f \u2286 s \u2192 \u2203 (m n : \u2115), m < n \u2227 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 \u03b1] (s) : Prop :=\npartially_well_ordered_on s ((\u2264) : \u03b1 \u2192 \u03b1 \u2192 Prop)\n\ntheorem partially_well_ordered_on.mono {s t : set \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (ht : t.partially_well_ordered_on r) (hsub : s \u2286 t) :\n  s.partially_well_ordered_on r :=\n\u03bb f hf, ht f (set.subset.trans hf hsub)\n\ntheorem partially_well_ordered_on.image_of_monotone_on {s : set \u03b1}\n  {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Type*} {r' : \u03b2 \u2192 \u03b2 \u2192 Prop}\n  (hs : s.partially_well_ordered_on r) {f : \u03b1 \u2192 \u03b2}\n  (hf : \u2200 a1 a2 : \u03b1, a1 \u2208 s \u2192 a2 \u2208 s \u2192 r a1 a2 \u2192 r' (f a1) (f a2)) :\n  (f '' s).partially_well_ordered_on r' :=\n\u03bb g hg, begin\n  have h := \u03bb (n : \u2115), ((mem_image _ _ _).1 (hg (mem_range_self n))),\n  obtain \u27e8m, n, hlt, hmn\u27e9 := hs (\u03bb n, classical.some (h n)) _,\n  { refine \u27e8m, n, hlt, _\u27e9,\n    rw [\u2190 (classical.some_spec (h m)).2,\n      \u2190 (classical.some_spec (h n)).2],\n    exact hf _ _ (classical.some_spec (h m)).1 (classical.some_spec (h n)).1 hmn },\n  { rintros _ \u27e8n, rfl\u27e9,\n    exact (classical.some_spec (h n)).1 }\nend\n\nsection partial_order\nvariables {s : set \u03b1} {t : set \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n\ntheorem partially_well_ordered_on.exists_monotone_subseq [is_refl \u03b1 r] [is_trans \u03b1 r]\n  (h : s.partially_well_ordered_on r) (f : \u2115 \u2192 \u03b1) (hf : range f \u2286 s) :\n  \u2203 (g : \u2115 \u21aao \u2115), \u2200 m n : \u2115, m \u2264 n \u2192 r (f (g m)) (f (g n)) :=\nbegin\n  obtain \u27e8g, h1 | h2\u27e9 := exists_increasing_or_nonincreasing_subseq r f,\n  { refine \u27e8g, \u03bb m n hle, _\u27e9,\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 \u27e8m, n, hlt, hle\u27e9 := h (f \u2218 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 \u03b1 r] [is_trans \u03b1 r] :\n  s.partially_well_ordered_on r \u2194\n    \u2200 f : \u2115 \u2192 \u03b1, range f \u2286 s \u2192 \u2203 (g : \u2115 \u21aao \u2115), \u2200 m n : \u2115, m \u2264 n \u2192 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 \u27e8g, gmon\u27e9 := h f hf,\n    refine \u27e8g 0, g 1, g.lt_iff_lt.2 zero_lt_one, gmon _ _ zero_le_one\u27e9, }\nend\n\nlemma partially_well_ordered_on.well_founded_on [is_partial_order \u03b1 r]\n  (h : s.partially_well_ordered_on r) :\n  s.well_founded_on (\u03bb a b, r a b \u2227 a \u2260 b) :=\nbegin\n  haveI : is_strict_order \u03b1 (\u03bb a b, r a b \u2227 a \u2260 b) :=\n  { to_is_irrefl := \u27e8\u03bb a con, con.2 rfl\u27e9,\n    to_is_trans := \u27e8\u03bb a b c ab bc, \u27e8trans ab.1 bc.1,\n      \u03bb ac, ab.2 (antisymm ab.1 (ac.symm \u25b8 bc.1))\u27e9\u27e9 },\n  rw well_founded_on_iff_no_descending_seq,\n  intros f con,\n  obtain \u27e8m, n, hlt, hle\u27e9 := 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 \u03b1]\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 : \u2115 \u2192 \u03b1) (hf : range f \u2286 s) :\n  \u2203 (g : \u2115 \u21aao \u2115), monotone (f \u2218 g) :=\nh.exists_monotone_subseq f hf\n\ntheorem is_pwo_iff_exists_monotone_subseq :\n  s.is_pwo \u2194\n    \u2200 f : \u2115 \u2192 \u03b1, range f \u2286 s \u2192 \u2203 (g : \u2115 \u21aao \u2115), monotone (f \u2218 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 \u27e8g1, h1\u27e9 := hs (prod.fst \u2218 f) _,\n  swap,\n  { rw [range_comp, image_subset_iff],\n    refine subset.trans hf _,\n    rintros \u27e8x1, x2\u27e9 hx,\n    simp only [mem_preimage, hx.1] },\n  obtain \u27e8g2, h2\u27e9 := ht (prod.snd \u2218 f \u2218 g1) _,\n  refine \u27e8g2.trans g1, \u03bb m n mn, _\u27e9,\n  swap,\n  { rw [range_comp, image_subset_iff],\n    refine subset.trans (range_comp_subset_range _ _) (subset.trans hf _),\n    rintros \u27e8x1, x2\u27e9 hx,\n    simp only [mem_preimage, hx.2] },\n  simp only [rel_embedding.coe_trans, function.comp_app],\n  exact \u27e8h1 (g2.le_iff_le.2 mn), h2 mn\u27e9,\nend\n\ntheorem is_pwo.image_of_monotone {\u03b2 : Type*} [partial_order \u03b2]\n  (hs : s.is_pwo) {f : \u03b1 \u2192 \u03b2} (hf : monotone f) :\n  is_pwo (f '' s) :=\nhs.image_of_monotone_on (\u03bb _ _ _ _ ab, hf ab)\n\ntheorem is_pwo.union (hs : is_pwo s) (ht : is_pwo t) : is_pwo (s \u222a t) :=\nbegin\n  classical,\n  rw [is_pwo_iff_exists_monotone_subseq] at *,\n  rintros f fst,\n  have h : infinite (f \u207b\u00b9' s) \u2228 infinite (f \u207b\u00b9' t),\n  { have h : infinite (univ : set \u2115) := infinite_univ,\n    have hpre : f \u207b\u00b9' (s \u222a t) = set.univ,\n    { rw [\u2190 image_univ, image_subset_iff, univ_subset_iff] at fst,\n      exact fst },\n    rw preimage_union at hpre,\n    rw \u2190 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 [\u2190 infinite_coe_iff, \u2190 infinite_coe_iff] at h,\n  cases h with inf inf; haveI := inf,\n  { obtain \u27e8g, hg\u27e9 := hs (f \u2218 (nat.order_embedding_of_set (f \u207b\u00b9' s))) _,\n    { rw [function.comp.assoc, \u2190 rel_embedding.coe_trans] at hg,\n      exact \u27e8_, hg\u27e9 },\n    rw [range_comp, image_subset_iff],\n    simp },\n  { obtain \u27e8g, hg\u27e9 := ht (f \u2218 (nat.order_embedding_of_set (f \u207b\u00b9' t))) _,\n    { rw [function.comp.assoc, \u2190 rel_embedding.coe_trans] at hg,\n      exact \u27e8_, hg\u27e9 },\n    rw [range_comp, image_subset_iff],\n    simp }\nend\n\nend partial_order\n\ntheorem is_wf.is_pwo [linear_order \u03b1] {s : set \u03b1}\n  (hs : s.is_wf) : s.is_pwo :=\n\u03bb f hf, begin\n  rw [is_wf, well_founded_on_iff] at hs,\n  have hrange : (range f).nonempty := \u27e8f 0, mem_range_self 0\u27e9,\n  let a := hs.min (range f) hrange,\n  obtain \u27e8m, hm\u27e9 := hs.min_mem (range f) hrange,\n  refine \u27e8m, m.succ, m.lt_succ_self, le_of_not_lt (\u03bb con, _)\u27e9,\n  rw hm at con,\n  apply hs.not_lt_min (range f) hrange (mem_range_self m.succ)\n    \u27e8con, hf (mem_range_self m.succ), hf _\u27e9,\n  rw \u2190 hm,\n  apply mem_range_self,\nend\n\ntheorem is_wf_iff_is_pwo [linear_order \u03b1] {s : set \u03b1} :\n  s.is_wf \u2194 s.is_pwo :=\n\u27e8is_wf.is_pwo, is_pwo.is_wf\u27e9\n\nend set\n\nnamespace finset\n\n@[simp]\ntheorem partially_well_ordered_on {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_refl \u03b1 r] (f : finset \u03b1) :\n  set.partially_well_ordered_on (\u2191f : set \u03b1) 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 \u27e8m, n, gmgn, hne\u27e9 := hinj,\n    cases lt_or_gt_of_ne hne with hlt hlt;\n    { refine \u27e8_, _, hlt, _\u27e9,\n      rw gmgn,\n      exact refl_of r _, } }\nend\n\n@[simp]\ntheorem is_pwo [partial_order \u03b1] (f : finset \u03b1) :\n  set.is_pwo (\u2191f : set \u03b1) :=\nf.partially_well_ordered_on\n\n@[simp]\ntheorem well_founded_on {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_strict_order \u03b1 r] (f : finset \u03b1) :\n  set.well_founded_on (\u2191f : set \u03b1) 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 \u03b1] (f : finset \u03b1) : set.is_wf (\u2191f : set \u03b1) :=\nf.is_pwo.is_wf\n\nend finset\n\nnamespace set\nvariables [partial_order \u03b1] {s : set \u03b1} {a : \u03b1}\n\ntheorem finite.is_pwo (h : s.finite) : s.is_pwo :=\nbegin\n  rw \u2190 h.coe_to_finset,\n  exact h.to_finset.is_pwo,\nend\n\n@[simp]\ntheorem fintype.is_pwo [fintype \u03b1] : s.is_pwo := (finite.of_fintype s).is_pwo\n\n@[simp]\ntheorem is_pwo_empty : is_pwo (\u2205 : set \u03b1) :=\nfinite_empty.is_pwo\n\n@[simp]\ntheorem is_pwo_singleton (a) : is_pwo ({a} : set \u03b1) :=\n(finite_singleton a).is_pwo\n\ntheorem is_pwo.insert (a) (hs : is_pwo s) : is_pwo (insert a s) :=\nby { rw \u2190 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) : \u03b1 :=\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 \u2208 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 \u2208 s) : \u00ac a < hs.min hn :=\nhs.not_lt_min univ (nonempty_iff_univ_nonempty.1 hn.to_subtype) (mem_univ (\u27e8a, ha\u27e9 : s))\n\n@[simp]\nlemma is_wf_min_singleton (a) {hs : is_wf ({a} : set \u03b1)} {hn : ({a} : set \u03b1).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 {\u03b9 : Type*} [partial_order \u03b1] (f : finset \u03b9) (g : \u03b9 \u2192 set \u03b1)\n  (hf : \u2200 i : \u03b9, i \u2208 f \u2192 (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 (\u03bb s' s'f, hsf _\n      (finset.mem_insert_of_mem s'f))) }\nend\n\n@[simp]\ntheorem finset.is_pwo_sup {\u03b9 : Type*} [partial_order \u03b1] (f : finset \u03b9) (g : \u03b9 \u2192 set \u03b1)\n  (hf : \u2200 i : \u03b9, i \u2208 f \u2192 (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 (\u03bb s' s'f, hsf _\n      (finset.mem_insert_of_mem s'f))) }\nend\n\nnamespace set\nvariables [linear_order \u03b1] {s t : set \u03b1} {a : \u03b1}\n\nlemma is_wf.min_le\n  (hs : s.is_wf) (hn : s.nonempty) (ha : a \u2208 s) : hs.min hn \u2264 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 \u2264 hs.min hn \u2194 \u2200 b, b \u2208 s \u2192 a \u2264 b :=\n\u27e8\u03bb ha b hb, le_trans ha (hs.min_le hn hb), \u03bb h, h _ (hs.min_mem _)\u27e9\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 \u2286 t) :\n  ht.min htn \u2264 hs.min hsn :=\n(is_wf.le_min_iff _ _).2 (\u03bb 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 \u03b1} {t : set \u03b1}\n\n@[to_additive]\ntheorem is_pwo.mul [ordered_cancel_comm_monoid \u03b1] (hs : s.is_pwo) (ht : t.is_pwo) :\n  is_pwo (s * t) :=\nbegin\n  rw \u2190 image_mul_prod,\n  exact (is_pwo.prod hs ht).image_of_monotone (\u03bb _ _ h, mul_le_mul' h.1 h.2),\nend\n\nvariable [linear_ordered_cancel_comm_monoid \u03b1]\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 \u27e8_, _, hs.min_mem _, ht.min_mem _, rfl\u27e9)) _,\n  rw is_wf.le_min_iff,\n  rintros _ \u27e8x, y, hx, hy, rfl\u27e9,\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 : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : set \u03b1) (f : \u2115 \u2192 \u03b1) : Prop :=\nset.range f \u2286 s \u2227 \u2200 (m n : \u2115), m < n \u2192 \u00ac r (f m) (f n)\n\nlemma iff_forall_not_is_bad_seq (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : set \u03b1) :\n  s.partially_well_ordered_on r \u2194\n    \u2200 f, \u00ac is_bad_seq r s f :=\nbegin\n  rw [set.partially_well_ordered_on],\n  apply forall_congr (\u03bb 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) \u2264 rk (g n)`. -/\ndef is_min_bad_seq (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (rk : \u03b1 \u2192 \u2115) (s : set \u03b1) (n : \u2115) (f : \u2115 \u2192 \u03b1) : Prop :=\n  \u2200 g : \u2115 \u2192 \u03b1, (\u2200 (m : \u2115), m < n \u2192 f m = g m) \u2192 rk (g n) < rk (f n) \u2192 \u00ac 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) (rk : \u03b1 \u2192 \u2115) (s : set \u03b1)\n  (n : \u2115) (f : \u2115 \u2192 \u03b1) (hf : is_bad_seq r s f) :\n  { g : \u2115 \u2192 \u03b1 // (\u2200 (m : \u2115), m < n \u2192 f m = g m) \u2227 is_bad_seq r s g \u2227 is_min_bad_seq r rk s n g } :=\nbegin\n  classical,\n  have h : \u2203 (k : \u2115) (g : \u2115 \u2192 \u03b1), (\u2200 m, m < n \u2192 f m = g m) \u2227 is_bad_seq r s g\n        \u2227 rk (g n) = k :=\n  \u27e8_, f, \u03bb _ _, rfl, hf, rfl\u27e9,\n  obtain \u27e8h1, h2, h3\u27e9 := classical.some_spec (nat.find_spec h),\n  refine \u27e8classical.some (nat.find_spec h), h1, by convert h2, \u03bb g hg1 hg2 con, _\u27e9,\n  refine nat.find_min h _ \u27e8g, \u03bb m mn, (h1 m mn).trans (hg1 m mn), by convert con, rfl\u27e9,\n  rwa \u2190 h3,\nend\n\nlemma exists_min_bad_of_exists_bad (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (rk : \u03b1 \u2192 \u2115) (s : set \u03b1) :\n  (\u2203 f, is_bad_seq r s f) \u2192 \u2203 f, is_bad_seq r s f \u2227 \u2200 n, is_min_bad_seq r rk s n f :=\nbegin\n  rintro \u27e8f0, (hf0 : is_bad_seq r s f0)\u27e9,\n  let fs : \u03a0 (n : \u2115), { f :  \u2115 \u2192 \u03b1 // is_bad_seq r s f \u2227 is_min_bad_seq r rk s n f },\n  { refine nat.rec _ _,\n    { exact \u27e8(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\u27e9, },\n    { exact \u03bb n fn, \u27e8(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\u27e9 } },\n  have h : \u2200 m n, m \u2264 n \u2192 (fs m).1 m = (fs n).1 m,\n  { intros m n mn,\n    obtain \u27e8k, rfl\u27e9 := 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 \u27e8\u03bb n, (fs n).1 n, \u27e8set.range_subset_iff.2 (\u03bb n, ((fs n).2).1.1 (mem_range_self n)),\n    \u03bb m n mn, _\u27e9, \u03bb n g hg1 hg2, _\u27e9,\n  { dsimp,\n    rw [\u2190 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 (\u03bb m mn, eq.trans _ (hg1 m mn)) (lt_of_lt_of_le hg2 (le_refl _)),\n    rw \u2190 h m n (le_of_lt mn) },\nend\n\nlemma iff_not_exists_is_min_bad_seq {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (rk : \u03b1 \u2192 \u2115) {s : set \u03b1} :\n  s.partially_well_ordered_on r \u2194 \u00ac \u2203 f, is_bad_seq r s f \u2227 \u2200 n, is_min_bad_seq r rk s n f :=\nbegin\n  rw [iff_forall_not_is_bad_seq, \u2190 not_exists, not_congr],\n  split,\n  { apply exists_min_bad_of_exists_bad },\n  rintro \u27e8f, hf1, hf2\u27e9,\n  exact \u27e8f, hf1\u27e9,\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\u2082 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\u2082 r l\u2081 l\u2082` whenever `l\u2081` related pointwise by `r` to a sublist of `l\u2082`.  -/\nlemma partially_well_ordered_on_sublist_forall\u2082 (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [is_refl \u03b1 r] [is_trans \u03b1 r]\n  {s : set \u03b1} (h : s.partially_well_ordered_on r) :\n  { l : list \u03b1 | \u2200 x, x \u2208 l \u2192 x \u2208 s }.partially_well_ordered_on (list.sublist_forall\u2082 r) :=\nbegin\n  rcases s.eq_empty_or_nonempty with rfl | \u27e8as, has\u27e9,\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 \u03b1 := \u27e8as\u27e9,\n  rw [iff_not_exists_is_min_bad_seq (list.length)],\n  rintro \u27e8f, hf1, hf2\u27e9,\n  have hnil : \u2200 n, f n \u2260 list.nil :=\n    \u03bb n con, (hf1).2 n n.succ n.lt_succ_self (con.symm \u25b8 list.sublist_forall\u2082.nil),\n  obtain \u27e8g, hg\u27e9 := h.exists_monotone_subseq (list.head \u2218 f) _,\n  swap, { simp only [set.range_subset_iff, function.comp_apply],\n    exact \u03bb n, hf1.1 (set.mem_range_self n) _ (list.head_mem_self (hnil n)) },\n  have hf' := hf2 (g 0) (\u03bb n, if n < g 0 then f n else list.tail (f (g (n - g 0))))\n    (\u03bb m hm, (if_pos hm).symm) _,\n  swap, { simp only [if_neg (lt_irrefl (g 0)), tsub_self],\n    rw [list.length_tail, \u2190 nat.pred_eq_sub_one],\n    exact nat.pred_lt (\u03bb con, hnil _ (list.length_eq_zero.1 con)) },\n  rw [is_bad_seq] at hf',\n  push_neg at hf',\n  obtain \u27e8m, n, mn, hmn\u27e9 := 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 \u27e8n', rfl\u27e9 := 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\u2082_self _) },\n    { rw [\u2190 (tsub_lt_iff_left (le_of_not_lt hm))] at mn,\n      apply hf1.2 _ _ (g.lt_iff_lt.2 mn),\n      rw [\u2190 list.cons_head_tail (hnil (g (m - g 0))), \u2190 list.cons_head_tail (hnil (g n'))],\n      exact list.sublist_forall\u2082.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 \u03b1] {s : set \u03b1} (hpos : \u2200 x : \u03b1, x \u2208 s \u2192 1 \u2264 x)\n  (h : s.is_pwo) : is_pwo ((submonoid.closure s) : set \u03b1) :=\nbegin\n  have hl : ((submonoid.closure s) : set \u03b1) \u2286 list.prod '' { l : list \u03b1 | \u2200 x, x \u2208 l \u2192 x \u2208 s },\n  { intros x hx,\n    rw set_like.mem_coe at hx,\n    refine submonoid.closure_induction hx (\u03bb x hx, \u27e8_, \u03bb y hy, _, list.prod_singleton\u27e9)\n      \u27e8_, \u03bb y hy, (list.not_mem_nil _ hy).elim, list.prod_nil\u27e9 _,\n    { rwa list.mem_singleton.1 hy },\n    rintros _ _ \u27e8l, hl, rfl\u27e9 \u27e8l', hl', rfl\u27e9,\n    refine \u27e8_, \u03bb y hy, _, list.prod_append\u27e9,\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\u2082 (\u2264)).image_of_monotone_on _).mono hl,\n  intros l1 l2 hl1 hl2 h12,\n  obtain \u27e8l, hll1, hll2\u27e9 := list.sublist_forall\u2082_iff.1 h12,\n  refine le_trans (list.rel_prod (le_refl 1) (\u03bb a b ab c d cd, mul_le_mul' ab cd) hll1) _,\n  obtain \u27e8l', hl'\u27e9 := hll2.exists_perm_append,\n  rw [hl'.prod_eq, list.prod_append, \u2190 mul_one l.prod, mul_assoc, one_mul],\n  apply mul_le_mul_left',\n  have hl's := \u03bb 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, \u2190 one_mul (1 : \u03b1)],\n  exact mul_le_mul' (hpos x1 (hl's x1 (list.mem_cons_self x1 x2)))\n    (x3 (\u03bb 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 \u03b1] (s t : set \u03b1) (a : \u03b1) : set (\u03b1 \u00d7 \u03b1) :=\n{ x | x.1 * x.2 = a \u2227 x.1 \u2208 s \u2227 x.2 \u2208 t }\n\nnamespace mul_antidiagonal\n\n@[simp, to_additive]\nlemma mem_mul_antidiagonal [monoid \u03b1] {s t : set \u03b1} {a : \u03b1} {x : \u03b1 \u00d7 \u03b1} :\n  x \u2208 mul_antidiagonal s t a \u2194 x.1 * x.2 = a \u2227 x.1 \u2208 s \u2227 x.2 \u2208 t := iff.refl _\n\nsection cancel_comm_monoid\nvariables [cancel_comm_monoid \u03b1] {s t : set \u03b1} {a : \u03b1}\n\n@[to_additive]\nlemma fst_eq_fst_iff_snd_eq_snd {x y : (mul_antidiagonal s t a)} :\n  (x : \u03b1 \u00d7 \u03b1).fst = (y : \u03b1 \u00d7 \u03b1).fst \u2194 (x : \u03b1 \u00d7 \u03b1).snd = (y : \u03b1 \u00d7 \u03b1).snd :=\n\u27e8\u03bb 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, \u03bb 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\u27e9\n\n@[to_additive]\nlemma eq_of_fst_eq_fst {x y : (mul_antidiagonal s t a)}\n  (h : (x : \u03b1 \u00d7 \u03b1).fst = (y : \u03b1 \u00d7 \u03b1).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 : \u03b1 \u00d7 \u03b1).snd = (y : \u03b1 \u00d7 \u03b1).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 \u03b1] (s t : set \u03b1) (a : \u03b1)\n\n@[to_additive]\nlemma eq_of_fst_le_fst_of_snd_le_snd {x y : (mul_antidiagonal s t a)}\n  (h1 : (x : \u03b1 \u00d7 \u03b1).fst \u2264 (y : \u03b1 \u00d7 \u03b1).fst) (h2 : (x : \u03b1 \u00d7 \u03b1).snd \u2264 (y : \u03b1 \u00d7 \u03b1).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 [\u2190 set.infinite] at h,\n  have h1 : (mul_antidiagonal s t a).partially_well_ordered_on (prod.fst \u207b\u00b9'o (\u2264)),\n  { intros f hf,\n    refine hs (prod.fst \u2218 f) _,\n    rw range_comp,\n    rintros _ \u27e8\u27e8x, y\u27e9, hxy, rfl\u27e9,\n    exact (mem_mul_antidiagonal.1 (hf hxy)).2.1 },\n  have h2 : (mul_antidiagonal s t a).partially_well_ordered_on (prod.snd \u207b\u00b9'o (\u2264)),\n  { intros f hf,\n    refine ht (prod.snd \u2218 f) _,\n    rw range_comp,\n    rintros _ \u27e8\u27e8x, y\u27e9, hxy, rfl\u27e9,\n    exact (mem_mul_antidiagonal.1 (hf hxy)).2.2 },\n  obtain \u27e8g, hg\u27e9 := h1.exists_monotone_subseq (\u03bb x, h.nat_embedding _ x) _,\n  swap, { rintro _ \u27e8k, rfl\u27e9,\n    exact ((infinite.nat_embedding (s.mul_antidiagonal t a) h) _).2 },\n  obtain \u27e8m, n, mn, h2'\u27e9 := h2 (\u03bb x, (h.nat_embedding _) (g x)) _,\n  swap, { rintro _ \u27e8k, rfl\u27e9,\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 \u03b1] {s t : set \u03b1}\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 \u03b1]\nvariables {s t : set \u03b1} (hs : s.is_pwo) (ht : t.is_pwo) (a : \u03b1)\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 (\u03b1 \u00d7 \u03b1) :=\n(set.mul_antidiagonal.finite_of_is_pwo hs ht a).to_finset\n\nvariables {hs} {ht} {u : set \u03b1} {hu : u.is_pwo} {a} {x : \u03b1 \u00d7 \u03b1}\n\n@[simp, to_additive]\nlemma mem_mul_antidiagonal :\n  x \u2208 mul_antidiagonal hs ht a \u2194 x.1 * x.2 = a \u2227 x.1 \u2208 s \u2227 x.2 \u2208 t :=\nby simp [mul_antidiagonal]\n\n@[to_additive]\nlemma mul_antidiagonal_mono_left (hus : u \u2286 s) :\n  (finset.mul_antidiagonal hu ht a) \u2286 (finset.mul_antidiagonal hs ht a) :=\n\u03bb x hx, begin\n  rw mem_mul_antidiagonal at *,\n  exact \u27e8hx.1, hus hx.2.1, hx.2.2\u27e9,\nend\n\n@[to_additive]\nlemma mul_antidiagonal_mono_right (hut : u \u2286 t) :\n  (finset.mul_antidiagonal hs hu a) \u2286 (finset.mul_antidiagonal hs ht a) :=\n\u03bb x hx, begin\n  rw mem_mul_antidiagonal at *,\n  exact \u27e8hx.1, hx.2.1, hut hx.2.2\u27e9,\nend\n\n@[to_additive]\nlemma support_mul_antidiagonal_subset_mul :\n  { a : \u03b1 | (mul_antidiagonal hs ht a).nonempty } \u2286 s * t :=\n(\u03bb x \u27e8\u27e8a1, a2\u27e9, ha\u27e9, begin\n  obtain \u27e8hmul, h1, h2\u27e9 := mem_mul_antidiagonal.1 ha,\n  exact \u27e8a1, a2, h1, h2, hmul\u27e9,\nend)\n\n@[to_additive]\ntheorem is_pwo_support_mul_antidiagonal :\n  { a : \u03b1 | (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 {\u03b1} [linear_ordered_cancel_comm_monoid \u03b1] {s t : set \u03b1}\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 \u27e8a1, a2\u27e9,\n  rw [mem_mul_antidiagonal, finset.mem_singleton, prod.ext_iff],\n  split,\n  { rintro \u27e8hast, has, hat\u27e9,\n    cases eq_or_lt_of_le (hs.min_le hns has) with heq hlt,\n    { refine \u27e8heq.symm, _\u27e9,\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 \u27e8ha1, ha2\u27e9,\n    rw [ha1, ha2],\n    exact \u27e8rfl, hs.min_mem _, ht.min_mem _\u27e9 }\nend\n\nend finset\n\nlemma well_founded.is_wf [has_lt \u03b1] (h : well_founded ((<) : \u03b1 \u2192 \u03b1 \u2192 Prop)) (s : set \u03b1) :\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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u2265 3`, `a\u2081, ..., a\u2099` be strictly positive integers such that `a\u1d62 \u2223 a\u1d62\u208b\u2081 + a\u1d62\u208a\u2081` for\n`i = 2, ..., n - 1`. Show that $\\sum_{i=1}^{n-1}\\dfrac{a_0a_n}{a_ia_{i+1}} \u2208 \\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 : \u2115` whose cast to `\u03b1` is the sum we want.\n\nIn mathlib, `\u2115` starts at `0`. To make the indexing cleaner, we use `a\u2080, ..., a\u2099\u208b\u2081` instead of\n`a\u2081, ..., a\u2099`. Similarly, it's nicer to not use substraction of naturals, so we replace\n`a\u1d62 \u2223 a\u1d62\u208b\u2081 + a\u1d62\u208a\u2081` by `a\u1d62\u208a\u2081 \u2223 a\u1d62 + a\u1d62\u208a\u2082`.\n\nWe don't actually have to work in `\u211a` or `\u211d`. 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 : \u2115 \u2192 \u2115`.\n\nIn the proof itself, we replace `n : \u2115, 1 \u2264 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 : \u2115`, `a : \u2115 \u2192 \u2115`, `\u2200 i \u2264 n, 0 < a i`, `\u2200 i, i + 2 \u2264 n \u2192 a\u1d62\u208a\u2081 \u2223 a\u1d62 + a\u1d62\u208a\u2082` (read `\u2192` as\n\"implies\"). Then there exists `b : \u2115` 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\u2099\u208a\u2081 \u2223 a\u2099 * b - a\u2080` 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\u2080 * 1 - a\u2080 = 0` is clearly divisible by `a\u2081`.\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} \u00d7 \\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} \u00d7 b + a_0 / a_{n+1}\n      = (a_n + a_{n+2}) / a_{n+1} \u00d7 b - (a_n b - a_0)(a_{n+1})$$\n    which is a natural because `(a\u2099 + a\u2099\u208a\u2082)/a\u2099\u208a\u2081`, `b` and `(a\u2099 * b - a\u2080)/a\u2099\u208a\u2081` are (plus an\n    annoying inequality, or the fact that the original sum is positive because its terms are).\n  * Divisibility condition:\n    `a\u2099\u208a\u2081 * ((a\u2099 + a\u2099\u208a\u2082)/a\u2099\u208a\u2081 * b - (a\u2099 * b - a\u2080)/a\u2099\u208a\u2081) - a\u2080 = a\u2099\u208a\u2081a\u2099\u208a\u2082b` is divisible by `a\u2099\u208a\u2082`.\n-/\n\nopen_locale big_operators\n\nvariables {\u03b1 : Type*} [linear_ordered_field \u03b1]\n\ntheorem week3_p1 (n : \u2115) (a : \u2115 \u2192 \u2115) (a_pos : \u2200 i \u2264 n, 0 < a i)\n  (ha : \u2200 i, i + 2 \u2264 n \u2192 a (i + 1) \u2223 a i + a (i + 2)) :\n  \u2203 b : \u2115, (b : \u03b1) = \u2211 i in finset.range n, (a 0 * a n)/(a i * a (i + 1)) :=\nbegin\n  -- Treat separately `n = 0` and `n \u2265 1`\n  cases n,\n  /- Case `n = 0`\n  The sum is trivially equal to `0` -/\n  { exact \u27e80, by rw [nat.cast_zero, finset.sum_range_zero]\u27e9 }, -- `\u27e8Claim it, Prove it\u27e9`\n  /- Case `n \u2265 1`. We replace `n` by `n + 1` everywhere to make this inequality explicit\n  Set up the stronger induction hypothesis -/\n  suffices h : \u2203 b : \u2115, (b : \u03b1) = \u2211 i in finset.range (n + 1), (a 0 * a (n + 1))/(a i * a (i + 1))\n           \u2227 a (n + 1) \u2223 a n * b - a 0,\n  { obtain \u27e8b, hb, -\u27e9 := h,\n    exact \u27e8b, hb\u27e9 },\n  simp_rw \u2190@nat.cast_pos \u03b1 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 \u27e81, _, _\u27e9,\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 \u27e8b, hb, han\u27e9 := ih (\u03bb i hi, ha i $ nat.le_succ_of_le hi)\n    (\u03bb i hi, a_pos i $ nat.le_succ_of_le hi),\n  specialize ha n le_rfl,\n  have ha\u2080 : a 0 \u2264 a n * b, -- Needing this is an artifact of `\u2115`-substraction.\n  { rw [\u2190@nat.cast_le \u03b1, nat.cast_mul, hb, \u2190div_le_iff' (a_pos _ $ n.le_succ.trans $ nat.le_succ _),\n      \u2190mul_div_mul_right _ _ (a_pos _ $ nat.le_succ _).ne'],\n    suffices h : \u2200 i, i \u2208 finset.range (n + 1) \u2192 0 \u2264 (a 0 : \u03b1) * a (n + 1) / (a i * a (i + 1)),\n    { exact finset.single_le_sum h (finset.self_mem_range_succ n) },\n    refine (\u03bb i _, div_nonneg _ _); refine mul_nonneg _ _; exact nat.cast_nonneg _ },\n  -- Claim that the sum equals `(a\u2099 + a\u2099\u208a\u2082)/a\u2099\u208a\u2081 * b - (a\u2099 * b - a\u2080)/a\u2099\u208a\u2081`\n  refine \u27e8(a n + a (n + 2))/ a (n + 1) * b - (a n * b - a 0) / a (n + 1), _, _\u27e9,\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) : \u2115) : \u03b1)\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 [\u2190mul_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    ... = \u2211 (i : \u2115) 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 [\u2190mul_div_assoc, \u2190mul_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, \u2190 mul_assoc, nat.mul_div_cancel' ha, add_mul,\n      nat.mul_div_cancel' han, add_tsub_tsub_cancel ha\u2080, 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 {\u03b1 \u03b2 : Type*}\n\nopen finset\n\ninstance (\u03b1 : Type u) (\u03b2 : Type v) [fintype \u03b1] [fintype \u03b2] : fintype (\u03b1 \u2295 \u03b2) :=\n{ elems := univ.disj_sum univ,\n  complete := by rintro (_ | _); simp }\n\n@[simp] lemma finset.univ_disj_sum_univ {\u03b1 \u03b2 : Type*} [fintype \u03b1] [fintype \u03b2] :\n  univ.disj_sum univ = (univ : finset (\u03b1 \u2295 \u03b2)) :=\nrfl\n\n@[simp] theorem fintype.card_sum [fintype \u03b1] [fintype \u03b2] :\n  fintype.card (\u03b1 \u2295 \u03b2) = fintype.card \u03b1 + fintype.card \u03b2 :=\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 : \u03b1) (h : fintype {b // b \u2260 a}) : fintype \u03b1 :=\nfintype.of_bijective (sum.elim (coe : {b // b = a} \u2192 \u03b1) (coe : {b // b \u2260 a} \u2192 \u03b1)) $\n  by { classical, exact (equiv.sum_compl (= a)).bijective }\n\nlemma image_subtype_ne_univ_eq_image_erase [fintype \u03b1] [decidable_eq \u03b2] (k : \u03b2) (b : \u03b1 \u2192 \u03b2) :\n  image (\u03bb i : {a // b a \u2260 k}, b \u2191i) 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 \u27e8a, _, ha\u27e9,\n    subst ha,\n    exact \u27e8\u27e8a, ne_of_mem_erase hi\u27e9, mem_univ _, rfl\u27e9 }\nend\n\nlemma image_subtype_univ_ssubset_image_univ [fintype \u03b1] [decidable_eq \u03b2] (k : \u03b2) (b : \u03b1 \u2192 \u03b2)\n  (hk : k \u2208 image b univ) (p : \u03b2 \u2192 Prop) [decidable_pred p] (hp : \u00ac p k) :\n  image (\u03bb i : {a // p (b a)}, b \u2191i) univ \u2282 image b univ :=\nbegin\n  split,\n  { intros x hx,\n    rcases mem_image.1 hx with \u27e8y, _, hy\u27e9,\n    exact hy \u25b8 mem_image_of_mem b (mem_univ y) },\n  { intros h,\n    rw mem_image at hk,\n    rcases hk with \u27e8k', _, hk'\u27e9, subst hk',\n    have := h (mem_image_of_mem b (mem_univ k')),\n    rw mem_image at this,\n    rcases this with \u27e8j, hj, hj'\u27e9,\n    exact hp (hj' \u25b8 j.2) }\nend\n\n/-- Any injection from a finset `s` in a fintype `\u03b1` to a finset `t` of the same cardinality as `\u03b1`\ncan be extended to a bijection between `\u03b1` and `t`. -/\nlemma finset.exists_equiv_extend_of_card_eq [fintype \u03b1] [decidable_eq \u03b2] {t : finset \u03b2}\n  (h\u03b1t : fintype.card \u03b1 = t.card) {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} (hfst : s.image f \u2286 t)\n  (hfs : set.inj_on f s) :\n  \u2203 g : \u03b1 \u2243 t, \u2200 i \u2208 s, (g i : \u03b2) = f i :=\nbegin\n  classical,\n  induction s using finset.induction with a s has H generalizing f,\n  { obtain \u27e8e\u27e9 : nonempty (\u03b1 \u2243 \u21a5t) := by rwa [\u2190 fintype.card_eq, fintype.card_coe],\n    use e,\n    simp },\n  have hfst' : finset.image f s \u2286 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 \u27e8g', hg'\u27e9 := H hfst' hfs',\n  have hfat : f a \u2208 t := hfst (mem_image_of_mem _ (s.mem_insert_self a)),\n  use g'.trans (equiv.swap (\u27e8f a, hfat\u27e9 : 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 `\u03b1` to a finset `t` of the same cardinality as `\u03b1`\ncan be extended to a bijection between `\u03b1` and `t`. -/\nlemma set.maps_to.exists_equiv_extend_of_card_eq [fintype \u03b1] {t : finset \u03b2}\n  (h\u03b1t : fintype.card \u03b1 = t.card) {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} (hfst : s.maps_to f t)\n  (hfs : set.inj_on f s) :\n  \u2203 g : \u03b1 \u2243 t, \u2200 i \u2208 s, (g i : \u03b2) = f i :=\nbegin\n  classical,\n  let s' : finset \u03b1 := s.to_finset,\n  have hfst' : s'.image f \u2286 t := by simpa [\u2190 finset.coe_subset] using hfst,\n  have hfs' : set.inj_on f s' := by simpa using hfs,\n  obtain \u27e8g, hg\u27e9 := finset.exists_equiv_extend_of_card_eq h\u03b1t hfst' hfs',\n  refine \u27e8g, \u03bb i hi, _\u27e9,\n  apply hg,\n  simpa using hi,\nend\n\nlemma fintype.card_subtype_or (p q : \u03b1 \u2192 Prop)\n  [fintype {x // p x}] [fintype {x // q x}] [fintype {x // p x \u2228 q x}] :\n  fintype.card {x // p x \u2228 q x} \u2264 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 : \u03b1 \u2192 Prop) (h : disjoint p q)\n  [fintype {x // p x}] [fintype {x // q x}] [fintype {x // p x \u2228 q x}] :\n  fintype.card {x // p x \u2228 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 (\u03b1 \u2295 \u03b2) \u2194 infinite \u03b1 \u2228 infinite \u03b2 :=\nbegin\n  refine \u27e8\u03bb H, _, \u03bb H, H.elim (@sum.infinite_of_left \u03b1 \u03b2) (@sum.infinite_of_right \u03b1 \u03b2)\u27e9,\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  \u00b7 simp[h, h', Nat.mod_eq_of_lt]\n  \u00b7 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 : \u2115) (hp : Nat.Prime p) : ((a + b) ^ p) % p = (a ^ p + b ^ p)%p := by\n  rw[\u2190 Nat.ModEq]\n  rw[add_pow]\n  rw[Nat.ModEq.comm]\n  have h1 : {0, p} \u2286  Finset.range (p + 1) := by \n    rw[Finset.subset_iff]\n    simp \n  rw[\u2190Finset.sum_sdiff h1 ]\n  have h2 : 0 \u2260 p := by \n    sorry\n  rw[Finset.sum_pair h2] \n  simp \n  rw[Nat.modEq_iff_dvd']\n  rw[Nat.sub_add_eq,\u2190 Nat.add_assoc]\n  simp[\u2190 Nat.add_le_add_left]\n  sorry\n\n\ntheorem fermat_little_theorem (p : \u2115) (hp : Nat.Prime p) (a : \u2115) : 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 {\u03b1 : Type}\nvariable [comm_semigroup_with_zero \u03b1]\n\n/- The relation used to prove congruence of encapsulation-/\ninductive R_encap {x\u2081 y\u2081 : mcrl2 \u03b1} {A : set \u03b1} (R : mcrl2 \u03b1 \u2192 mcrl2 \u03b1 \u2192 Prop) :\nmcrl2 \u03b1 \u2192 mcrl2 \u03b1 \u2192 Prop\n| R {x y} (h : R x y) : R_encap x y\n| basel : R_encap (encap A x\u2081) (encap A y\u2081)\n| baser : R_encap (encap A y\u2081) (encap A x\u2081)\n| step {x y} (h : R x y) : R_encap (encap A x) (encap A y)\n\ntheorem R_encap.symm {x\u2081 y\u2081 A R} (R_symm : symmetric R) :\nsymmetric (@R_encap \u03b1 _ x\u2081 y\u2081 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\u2081 x\u2082 : mcrl2 \u03b1} {A} (h : x\u2081 \u2248 x\u2082) : \n(encap A x\u2081) \u2248 (encap A x\u2082) :=\nbegin\n  rcases h with \u27e8R, Rx, R_bisim\u27e9,\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\u2081 h\u2082, \n    cases h\u2081,\n    { have h : \u2203y', transition y a y' \u2227 option.rel R x' y',\n      by exact bisim_lift R_bisim h\u2081_h h\u2082,\n      rcases h with \u27e8w, haw, hRw\u27e9,\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\u2082,\n      have h : \u2203y', transition x\u2082 a y' \u2227 option.rel R h\u2082_y y',\n      by exact bisim_lift R_bisim Rx h\u2082_h\u2082,\n      rcases h with \u27e8w, haw, hRw\u27e9,\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\u2082,\n      have h : \u2203y', transition x\u2081 a y' \u2227 option.rel R h\u2082_y y',\n      by exact bisim_lift R_bisim (R_bisim.right Rx) h\u2082_h\u2082,\n      rcases h with \u27e8w, haw, hRw\u27e9,\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\u2082,\n      have h : \u2203y', transition h\u2081_y a y' \u2227 option.rel R h\u2082_y y',\n      by exact bisim_lift R_bisim h\u2081_h h\u2082_h\u2082,\n      rcases h with \u27e8w, haw, hRw\u27e9,\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 : \u03a0 {n}, set (finvec n R) \u2192 Prop\n| 0     s := s = set.univ\n| (n+1) s := \u2203 (s\u2080 : set (finvec n R)) (h : cell s\u2080),\n                  s = {x | x.init \u2208 s\u2080}\n              \u2228\n              (\u2203 (f : finvec n R \u2192 R) (hf : def_fun S f),\n                  s = {x | x.init \u2208 s\u2080 \u2227 x (fin.last n) = f x.init}\n                \u2228 s = {x | x.init \u2208 s\u2080 \u2227 x (fin.last n) \u2208 set.Ioi (f x.init)}\n                \u2228 s = {x | x.init \u2208 s\u2080 \u2227 x (fin.last n) \u2208 set.Iio (f x.init)})\n              \u2228\n              (\u2203 (f g : finvec n R \u2192 R) (hf : def_fun S f) (hg : def_fun S g),\n                (\u2200 x\u2080 \u2208 s\u2080, f x\u2080 < g x\u2080) \u2227\n                  s = {x | x.init \u2208 s\u2080 \u2227 x (fin.last n) \u2208 set.Ioo (f x.init) (g x.init)})\n\nlemma init_definable (n : \u2115) :\n  def_fun S (finvec.init : finvec (n+1) R \u2192 finvec n R) :=\nbegin\n  sorry\nend\n\nlemma cell.definable : \u2200 {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 \u27e8s\u2080, hs\u2080, H|H|H\u27e9 := hs,\n  { cases H,\n    show def_set S (finvec.init \u207b\u00b9' s\u2080), sorry },\n  sorry,\n  sorry,\nend\n\ndef decomposition : \u03a0 {n} (C : set (set (finvec n R))), Prop\n| 0     C := C = {set.univ}\n| (n+1) C := C.finite \u2227 setoid.is_partition C\n            \u2227 \u2200 s \u2208 C, S.cell s\n            \u2227 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 \u2192 option ordering \u2192 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 \u2192 \u00ac 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 \u2192 \u00ac 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 \u2192 \u00ac 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 \u00d7 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 \u00d7 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 \u00d7 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 := \u27e8zero\u27e9\n\ninstance eq_dec : decidable_eq float := sorry'\n\n/- Arithmetic operations -/\n\nprotected def neg : float \u2192 float := sorry' /- opposite (change sign) -/\ndef abs : float \u2192 float := sorry' /- absolute value (set sign to [+]) -/\nprotected def add : float \u2192 float \u2192 float := sorry' /- addition -/\nprotected def sub : float \u2192 float \u2192 float := sorry' /- subtraction -/\nprotected def mul : float \u2192 float \u2192 float := sorry' /- multiplication -/\nprotected def div : float \u2192 float \u2192 float := sorry' /- division -/\ndef cmp (c:comparison) (f1 f2 : float) : bool := /- comparison -/\ncmp_of_comparison c sorry'\n\ninstance : has_add float := \u27e8float.add\u27e9\ninstance : has_neg float := \u27e8float.neg\u27e9\ninstance : has_sub float := \u27e8float.sub\u27e9\ninstance : has_mul float := \u27e8float.mul\u27e9\ninstance : has_div float := \u27e8float.div\u27e9\n\n/- Conversions -/\n\ndef of_single : float32 \u2192 float := sorry'\ndef to_single : float \u2192 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 := \u27e8of_int\u27e9\ninstance coe_int64_float : has_coe int64 float := \u27e8of_long\u27e9\n\ndef from_parsed (base : pos_num) (intPart : pos_num) (expPart : \u2124) : 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 \u2192 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) : \u00ac is_nan x \u2228 \u00ac is_nan y \u2192 x + y = y + x := sorry'\n\ntheorem mul_comm (x y) : \u00ac is_nan x \u2228 \u00ac is_nan y \u2192 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 \u2192 option float := sorry'\n\ntheorem div_mul_inverse (x y z) : exact_inverse y = some z \u2192 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 \u2192 \u00ac 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 \u2192 \u00ac 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 \u2192 \u00ac 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 \u2192 of_intu x = of_int x := sorry'\n\ntheorem of_intu_of_int_2 (x) : \u00ac word.ltu x half32 \u2192 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) \u2192 to_intu x = some n \u2192 to_int x = some n := sorry'\n\ntheorem to_intu_to_int_2 (x n) : \u00ac cmp Clt x (of_intu half32) \u2192 to_intu x = some n \u2192\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) : \u2124) = 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)) \u2192\n  of_longu x = of_long x := sorry'\n\ntheorem of_longu_of_long_2 (x) :\n  \u00ac word.ltu x (repr (@half_modulus W64)) \u2192\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 \u00d7 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 := \u27e8zero\u27e9\n\ninstance eq_dec : decidable_eq float32 := sorry'\n\n/- Arithmetic operations -/\n\nprotected def neg : float32 \u2192 float32 := sorry' /- opposite (change sign) -/\ndef abs : float32 \u2192 float32 := sorry' /- absolute value (set sign to [+]) -/\nprotected def add : float32 \u2192 float32 \u2192 float32 := sorry' /- addition -/\nprotected def sub : float32 \u2192 float32 \u2192 float32 := sorry' /- subtraction -/\nprotected def mul : float32 \u2192 float32 \u2192 float32 := sorry' /- multiplication -/\nprotected def div : float32 \u2192 float32 \u2192 float32 := sorry' /- division -/\ndef cmp (c:comparison) (f1 f2 : float32) : bool := /- comparison -/\ncmp_of_comparison c sorry'\n\ninstance : has_add float32 := \u27e8float32.add\u27e9\ninstance : has_neg float32 := \u27e8float32.neg\u27e9\ninstance : has_sub float32 := \u27e8float32.sub\u27e9\ninstance : has_mul float32 := \u27e8float32.mul\u27e9\ninstance : has_div float32 := \u27e8float32.div\u27e9\n\n/- Conversions -/\n\ndef of_double : float \u2192 float32 := float.to_single\ndef to_double : float32 \u2192 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 : \u2124) : 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 \u2192 bool := sorry'\n\n/- ** Properties -/\n\n/- Commutativity properties of addition and multiplication. -/\n\ntheorem add_comm (x y) : \u00ac is_nan x \u2228 \u00ac is_nan y \u2192 x + y = y + x := sorry'\n\ntheorem mul_comm (x y) : \u00ac is_nan x \u2228 \u00ac is_nan y \u2192 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 \u2192 option float32 := sorry'\n\ntheorem div_mul_inverse (x y z) : exact_inverse y = some z \u2192 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 \u2192 \u00ac 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 \u2192 \u00ac 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 \u2192 \u00ac 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 \u2192 float.to_int (to_double f) = some n := sorry'\n\ntheorem to_intu_double (f n) : to_intu f = some n \u2192 float.to_intu (to_double f) = some n := sorry'\n\ntheorem to_long_double (f n) : to_long f = some n \u2192 float.to_long (to_double f) = some n := sorry'\n\ntheorem to_longu_double (f n) : to_longu f = some n \u2192 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 \u2264 2^53 \u2192\n  of_longu n = of_double (float.of_longu n) := sorry'\n\ntheorem of_longu_double_2 (n) : 2^36 \u2264 unsigned n \u2192\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 \u2264 2^53 \u2192\n  of_long n = of_double (float.of_long n) := sorry'\n\ntheorem of_long_double_2 (n) : 2^36 \u2264 (signed n).nat_abs \u2192\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 \u03b1`, the partial values of a type.\n`o : Part \u03b1` carries a proposition `o.Dom`, its domain, along with a function `get : o.Dom \u2192 \u03b1`, 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 \u03b1` behaves the same as `Option \u03b1` except that `o : Option \u03b1` is decidably `none` or `some a`\nfor some `a : \u03b1`, while the domain of `o : Part \u03b1` 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 \u03b1` and `Part \u03b1` are classically equivalent. In general, `Part \u03b1` is bigger than `Option \u03b1`.\nIn current mathlib, `Part \u2115`, aka `PartENat`, is used to move decidability of the order to\ndecidability of `PartENat.find` (which is the smallest natural satisfying a predicate, or `\u221e` 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 \u03b1` to a `Part \u03b1` by sending `none` to `none` and `some a` to\n  `some a`.\n* `Part.toOption`: Converts a `Part \u03b1` with a decidable domain to an `Option \u03b1`.\n* `Part.equivOption`: Classical equivalence between `Part \u03b1` and `Option \u03b1`.\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 \u03b1` by `p : Prop` so long as\n  `p \u2192 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 : \u03b1`, `o : Part \u03b1`, `a \u2208 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 \u03b1` is the type of \"partial values\" of type `\u03b1`. It\n  is similar to `Option \u03b1` except the domain condition can be an\n  arbitrary proposition, not necessarily decidable. -/\nstructure Part.{u} (\u03b1 : 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 \u2192 \u03b1\n#align part Part\n\nnamespace Part\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _}\n\n/-- Convert a `Part \u03b1` with a decidable domain to an option -/\ndef toOption (o : Part \u03b1) [Decidable o.Dom] : Option \u03b1 :=\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 \u03b1) [Decidable o.Dom] : o.toOption.isSome \u2194 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 \u03b1) [Decidable o.Dom] : o.toOption.isNone \u2194 \u00aco.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' : \u2200 {o p : Part \u03b1} (_ : o.Dom \u2194 p.Dom) (_ : \u2200 h\u2081 h\u2082, o.get h\u2081 = p.get h\u2082), o = p\n  | \u27e8od, o\u27e9, \u27e8pd, p\u27e9, 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 : \u2200 o : Part \u03b1, (\u27e8o.Dom, fun h => o.get h\u27e9 : Part \u03b1) = o\n  | \u27e8_, _\u27e9 => rfl\n#align part.eta Part.eta\n\n/-- `a \u2208 o` means that `o` is defined and equal to `a` -/\nprotected def Mem (a : \u03b1) (o : Part \u03b1) : Prop :=\n  \u2203 h, o.get h = a\n#align part.mem Part.Mem\n\ninstance : Membership \u03b1 (Part \u03b1) :=\n  \u27e8Part.Mem\u27e9\n\ntheorem mem_eq (a : \u03b1) (o : Part \u03b1) : (a \u2208 o) = \u2203 h, o.get h = a :=\n  rfl\n#align part.mem_eq Part.mem_eq\n\ntheorem dom_iff_mem : \u2200 {o : Part \u03b1}, o.Dom \u2194 \u2203 y, y \u2208 o\n  | \u27e8_, f\u27e9 => \u27e8fun h => \u27e8f h, h, rfl\u27e9, fun \u27e8_, h, rfl\u27e9 => h\u27e9\n#align part.dom_iff_mem Part.dom_iff_mem\n\ntheorem get_mem {o : Part \u03b1} (h) : get o h \u2208 o :=\n  \u27e8_, rfl\u27e9\n#align part.get_mem Part.get_mem\n\n@[simp]\ntheorem mem_mk_iff {p : Prop} {o : p \u2192 \u03b1} {a : \u03b1} : a \u2208 Part.mk p o \u2194 \u2203 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 \u03b1} (H : \u2200 a, a \u2208 o \u2194 a \u2208 p) : o = p :=\n  (ext' \u27e8fun h => ((H _).1 \u27e8h, rfl\u27e9).fst, fun h => ((H _).2 \u27e8h, rfl\u27e9).fst\u27e9) fun _ _ =>\n    ((H _).2 \u27e8_, rfl\u27e9).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 \u03b1 :=\n  \u27e8False, False.rec\u27e9\n#align part.none Part.none\n\ninstance : Inhabited (Part \u03b1) :=\n  \u27e8none\u27e9\n\n@[simp]\ntheorem not_mem_none (a : \u03b1) : a \u2209 @none \u03b1 := 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 : \u03b1) : Part \u03b1 :=\n  \u27e8True, fun _ => a\u27e9\n#align part.some Part.some\n\n@[simp]\ntheorem some_dom (a : \u03b1) : (some a).Dom :=\n  trivial\n#align part.some_dom Part.some_dom\n\ntheorem mem_unique : \u2200 {a b : \u03b1} {o : Part \u03b1}, a \u2208 o \u2192 b \u2208 o \u2192 a = b\n  | _, _, \u27e8_, _\u27e9, \u27e8_, rfl\u27e9, \u27e8_, rfl\u27e9 => rfl\n#align part.mem_unique Part.mem_unique\n\ntheorem Mem.left_unique : Relator.LeftUnique ((\u00b7 \u2208 \u00b7) : \u03b1 \u2192 Part \u03b1 \u2192 Prop) := fun _ _ _ =>\n  mem_unique\n#align part.mem.left_unique Part.Mem.left_unique\n\ntheorem get_eq_of_mem {o : Part \u03b1} {a} (h : a \u2208 o) (h') : get o h' = a :=\n  mem_unique \u27e8_, rfl\u27e9 h\n#align part.get_eq_of_mem Part.get_eq_of_mem\n\nprotected theorem subsingleton (o : Part \u03b1) : Set.Subsingleton { a | a \u2208 o } := fun _ ha _ hb =>\n  mem_unique ha hb\n#align part.subsingleton Part.subsingleton\n\n@[simp]\ntheorem get_some {a : \u03b1} (ha : (some a).Dom) : get (some a) ha = a :=\n  rfl\n#align part.get_some Part.get_some\n\ntheorem mem_some (a : \u03b1) : a \u2208 some a :=\n  \u27e8trivial, rfl\u27e9\n#align part.mem_some Part.mem_some\n\n@[simp]\ntheorem mem_some_iff {a b} : b \u2208 (some a : Part \u03b1) \u2194 b = a :=\n  \u27e8fun \u27e8_, e\u27e9 => e.symm, fun e => \u27e8trivial, e.symm\u27e9\u27e9\n#align part.mem_some_iff Part.mem_some_iff\n\ntheorem eq_some_iff {a : \u03b1} {o : Part \u03b1} : o = some a \u2194 a \u2208 o :=\n  \u27e8fun e => e.symm \u25b8 mem_some _, fun \u27e8h, e\u27e9 => e \u25b8 ext' (iff_true_intro h) fun _ _ => rfl\u27e9\n#align part.eq_some_iff Part.eq_some_iff\n\ntheorem eq_none_iff {o : Part \u03b1} : o = none \u2194 \u2200 a, a \u2209 o :=\n  \u27e8fun e => e.symm \u25b8 not_mem_none, fun h => ext (by simpa)\u27e9\n#align part.eq_none_iff Part.eq_none_iff\n\ntheorem eq_none_iff' {o : Part \u03b1} : o = none \u2194 \u00aco.Dom :=\n  \u27e8fun e => e.symm \u25b8 id, fun h => eq_none_iff.2 fun _ h' => h h'.fst\u27e9\n#align part.eq_none_iff' Part.eq_none_iff'\n\n@[simp]\ntheorem not_none_dom : \u00ac(none : Part \u03b1).Dom :=\n  id\n#align part.not_none_dom Part.not_none_dom\n\n@[simp]\ntheorem some_ne_none (x : \u03b1) : some x \u2260 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 : \u03b1) : none \u2260 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 \u03b1} : o \u2260 none \u2194 \u2203 x, o = some x := by\n  constructor\n  \u00b7 rw [Ne, eq_none_iff', not_not]\n    exact fun h => \u27e8o.get h, eq_some_iff.2 (get_mem h)\u27e9\n  \u00b7 rintro \u27e8x, rfl\u27e9\n    apply some_ne_none\n#align part.ne_none_iff Part.ne_none_iff\n\ntheorem eq_none_or_eq_some (o : Part \u03b1) : o = none \u2228 \u2203 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 \u03b1) := 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 : \u03b1} : Part.some a = some b \u2194 a = b :=\n  some_injective.eq_iff\n#align part.some_inj Part.some_inj\n\n@[simp]\ntheorem some_get {a : Part \u03b1} (ha : a.Dom) : Part.some (Part.get a ha) = a :=\n  Eq.symm (eq_some_iff.2 \u27e8ha, rfl\u27e9)\n#align part.some_get Part.some_get\n\ntheorem get_eq_iff_eq_some {a : Part \u03b1} {ha : a.Dom} {b : \u03b1} : a.get ha = b \u2194 a = some b :=\n  \u27e8fun h => by simp [h.symm], fun h => by simp [h]\u27e9\n#align part.get_eq_iff_eq_some Part.get_eq_iff_eq_some\n\ntheorem get_eq_get_of_eq (a : Part \u03b1) (ha : a.Dom) {b : Part \u03b1} (h : a = b) :\n    a.get ha = b.get (h \u25b8 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 \u03b1} {a : \u03b1} (h : o.Dom) : o.get h = a \u2194 a \u2208 o :=\n  \u27e8fun H => \u27e8h, H\u27e9, fun \u27e8_, H\u27e9 => H\u27e9\n#align part.get_eq_iff_mem Part.get_eq_iff_mem\n\ntheorem eq_get_iff_mem {o : Part \u03b1} {a : \u03b1} (h : o.Dom) : a = o.get h \u2194 a \u2208 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 \u03b1).Dom] : (none : Part \u03b1).toOption = Option.none :=\n  dif_neg id\n#align part.none_to_option Part.none_toOption\n\n@[simp]\ntheorem some_toOption (a : \u03b1) [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 \u03b1).Dom :=\n  instDecidableFalse\n#align part.none_decidable Part.noneDecidable\n\ninstance someDecidable (a : \u03b1) : Decidable (some a).Dom :=\n  instDecidableTrue\n#align part.some_decidable Part.someDecidable\n\n/-- Retrieves the value of `a : part \u03b1` if it exists, and return the provided default value\notherwise. -/\ndef getOrElse (a : Part \u03b1) [Decidable a.Dom] (d : \u03b1) :=\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 \u03b1) (h : a.Dom) [Decidable a.Dom] (d : \u03b1) :\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 \u03b1) (h : \u00aca.Dom) [Decidable a.Dom] (d : \u03b1) :\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 : \u03b1) [Decidable (none : Part \u03b1).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 : \u03b1) (d : \u03b1) [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 \u03b1} [Decidable o.Dom] {a : \u03b1} : a \u2208 toOption o \u2194 a \u2208 o := by\n  unfold toOption\n  by_cases h : o.Dom <;> simp [h]\n  \u00b7 exact \u27e8fun h => \u27e8_, h\u27e9, fun \u27e8_, h\u27e9 => h\u27e9\n  \u00b7 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 \u03b1} [Decidable o.Dom] {a : \u03b1} :\n    toOption o = Option.some a \u2194 a \u2208 o :=\n  by rw [\u2190 Option.mem_def, mem_toOption]\n\nprotected theorem Dom.toOption {o : Part \u03b1} [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 \u03b1} [Decidable a.Dom] : a.toOption = Option.none \u2194 \u00aca.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 {\u03b1 \u03b2 : Type _} (a : Part \u03b1) [Decidable a.Dom] (b : \u03b2) (f : \u03b1 \u2192 \u03b2) :\n    a.toOption.elim b f = if h : a.Dom then f (a.get h) else b := by\n  split_ifs with h\n  \u00b7 rw [h.toOption]\n    rfl\n  \u00b7 rw [Part.toOption_eq_none_iff.2 h]\n    rfl\n#align part.elim_to_option Part.elim_toOption\n\n/-- Converts an `Option \u03b1` into a `Part \u03b1`. -/\ndef ofOption : Option \u03b1 \u2192 Part \u03b1\n  | Option.none => none\n  | Option.some a => some a\n#align part.of_option Part.ofOption\n\n@[simp]\ntheorem mem_ofOption {a : \u03b1} : \u2200 {o : Option \u03b1}, a \u2208 ofOption o \u2194 a \u2208 o\n  | Option.none => \u27e8fun h => h.fst.elim, fun h => Option.noConfusion h\u27e9\n  | Option.some _ => \u27e8fun h => congr_arg Option.some h.snd, fun h => \u27e8trivial, Option.some.inj h\u27e9\u27e9\n#align part.mem_of_option Part.mem_ofOption\n\n@[simp]\ntheorem ofOption_dom {\u03b1} : \u2200 o : Option \u03b1, (ofOption o).Dom \u2194 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 {\u03b1} (o : Option \u03b1) : ofOption o = \u27e8_, @Option.get _ o\u27e9 :=\n  Part.ext' (ofOption_dom o) fun h\u2081 h\u2082 => by\n    cases o\n    . simp at h\u2082\n    . rfl\n#align part.of_option_eq_get Part.ofOption_eq_get\n\ninstance : Coe (Option \u03b1) (Part \u03b1) :=\n  \u27e8ofOption\u27e9\n\ntheorem mem_coe {a : \u03b1} {o : Option \u03b1} : a \u2208 (o : Part \u03b1) \u2194 a \u2208 o :=\n  mem_ofOption\n#align part.mem_coe Part.mem_coe\n\n@[simp]\n\n\n@[simp]\ntheorem coe_some (a : \u03b1) : (Option.some a : Part \u03b1) = some a :=\n  rfl\n#align part.coe_some Part.coe_some\n\n@[elab_as_elim]\nprotected theorem induction_on {P : Part \u03b1 \u2192 Prop} (a : Part \u03b1) (hnone : P none)\n    (hsome : \u2200 a : \u03b1, P (some a)) : P a :=\n  (Classical.em a.Dom).elim (fun h => Part.some_get h \u25b8 hsome _) fun h =>\n    (eq_none_iff'.2 h).symm \u25b8 hnone\n#align part.induction_on Part.induction_on\n\ninstance ofOptionDecidable : \u2200 o : Option \u03b1, 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 \u03b1) : 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 \u03b1) [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 \u03b1` is (classically) equivalent to `Option \u03b1`. -/\nnoncomputable def equivOption : Part \u03b1 \u2243 Option \u03b1 :=\n  haveI := Classical.dec\n  \u27e8fun o => toOption o, ofOption, fun o => of_toOption o, fun o =>\n    Eq.trans (by dsimp; congr ) (to_ofOption o)\u27e9\n#align part.equiv_option Part.equivOption\n\n/-- We give `Part \u03b1` the order where everything is greater than `none`. -/\ninstance : PartialOrder (Part\n        \u03b1) where\n  le x y := \u2200 i, i \u2208 x \u2192 i \u2208 y\n  le_refl x y := id\n  le_trans x y z f g i := g _ \u2218 f _\n  le_antisymm x y f g := Part.ext fun z => \u27e8f _, g _\u27e9\n\ninstance : OrderBot (Part \u03b1) where\n  bot := none\n  bot_le := by\n    introv x\n    rintro \u27e8\u27e8_\u27e9, _\u27e9\n\ntheorem le_total_of_le_of_le {x y : Part \u03b1} (z : Part \u03b1) (hx : x \u2264 z) (hy : y \u2264 z) :\n    x \u2264 y \u2228 y \u2264 x := by\n  rcases Part.eq_none_or_eq_some x with (h | \u27e8b, h\u2080\u27e9)\n  \u00b7 rw [h]\n    left\n    apply OrderBot.bot_le _\n  right; intro b' h\u2081\n  rw [Part.eq_some_iff] at h\u2080\n  have hx := hx _ h\u2080; have hy := hy _ h\u2081\n  have hx := Part.mem_unique hx hy; subst hx\n  exact h\u2080\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 \u2192 Part \u03b1) : Part \u03b1 :=\n  \u27e8\u2203 h : p, (f h).Dom, fun ha => (f ha.fst).get ha.snd\u27e9\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 \u03b1) (g : \u03b1 \u2192 Part \u03b2) : Part \u03b2 :=\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 : \u03b1 \u2192 \u03b2) (o : Part \u03b1) : Part \u03b2 :=\n  \u27e8o.Dom, f \u2218 o.get\u27e9\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 : \u03b1 \u2192 \u03b2) {o : Part \u03b1} : \u2200 {a}, a \u2208 o \u2192 f a \u2208 map f o\n  | _, \u27e8_, rfl\u27e9 => \u27e8_, rfl\u27e9\n#align part.mem_map Part.mem_map\n\n@[simp]\ntheorem mem_map_iff (f : \u03b1 \u2192 \u03b2) {o : Part \u03b1} {b} : b \u2208 map f o \u2194 \u2203 a \u2208 o, f a = b :=\n  \u27e8fun hb => match b, hb with\n    | _, \u27e8_, rfl\u27e9 => \u27e8_, \u27e8_, rfl\u27e9, rfl\u27e9,\n    fun \u27e8_, h\u2081, h\u2082\u27e9 => h\u2082 \u25b8 mem_map f h\u2081\u27e9\n#align part.mem_map_iff Part.mem_map_iff\n\n@[simp]\ntheorem map_none (f : \u03b1 \u2192 \u03b2) : 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 : \u03b1 \u2192 \u03b2) (a : \u03b1) : 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 \u2192 Part \u03b1} : \u2200 {a} (h : p), a \u2208 f h \u2192 a \u2208 assert p f\n  | _, x, \u27e8h, rfl\u27e9 => \u27e8\u27e8x, h\u27e9, rfl\u27e9\n#align part.mem_assert Part.mem_assert\n\n@[simp]\ntheorem mem_assert_iff {p : Prop} {f : p \u2192 Part \u03b1} {a} : a \u2208 assert p f \u2194 \u2203 h : p, a \u2208 f h :=\n  \u27e8fun ha => match a, ha with\n    | _, \u27e8_, rfl\u27e9 => \u27e8_, \u27e8_, rfl\u27e9\u27e9,\n    fun \u27e8_, h\u27e9 => mem_assert _ h\u27e9\n#align part.mem_assert_iff Part.mem_assert_iff\n\ntheorem assert_pos {p : Prop} {f : p \u2192 Part \u03b1} (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  \u00b7 simp only [h, h', exists_prop_of_true]\n  \u00b7 aesop\n#align part.assert_pos Part.assert_pos\n\ntheorem assert_neg {p : Prop} {f : p \u2192 Part \u03b1} (h : \u00acp) : assert p f = none := by\n  dsimp [assert, none]; congr\n  \u00b7 simp only [h, not_false_iff, exists_prop_of_false]\n  \u00b7 apply Function.hfunext\n    \u00b7 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 \u03b1} {g : \u03b1 \u2192 Part \u03b2} : \u2200 {a b}, a \u2208 f \u2192 b \u2208 g a \u2192 b \u2208 f.bind g\n  | _, _, \u27e8h, rfl\u27e9, \u27e8h\u2082, rfl\u27e9 => \u27e8\u27e8h, h\u2082\u27e9, rfl\u27e9\n#align part.mem_bind Part.mem_bind\n\n@[simp]\ntheorem mem_bind_iff {f : Part \u03b1} {g : \u03b1 \u2192 Part \u03b2} {b} : b \u2208 f.bind g \u2194 \u2203 a \u2208 f, b \u2208 g a :=\n  \u27e8fun hb => match b, hb with\n    | _, \u27e8\u27e8_, _\u27e9, rfl\u27e9 => \u27e8_, \u27e8_, rfl\u27e9, \u27e8_, rfl\u27e9\u27e9,\n    fun \u27e8_, h\u2081, h\u2082\u27e9 => mem_bind h\u2081 h\u2082\u27e9\n#align part.mem_bind_iff Part.mem_bind_iff\n\nprotected theorem Dom.bind {o : Part \u03b1} (h : o.Dom) (f : \u03b1 \u2192 Part \u03b2) : o.bind f = f (o.get h) := by\n  ext b\n  simp only [Part.mem_bind_iff, exists_prop]\n  refine' \u27e8_, fun hb => \u27e8o.get h, Part.get_mem _, hb\u27e9\u27e9\n  rintro \u27e8a, ha, hb\u27e9\n  rwa [Part.get_eq_of_mem ha]\n#align part.dom.bind Part.Dom.bind\n\ntheorem Dom.of_bind {f : \u03b1 \u2192 Part \u03b2} {a : Part \u03b1} (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 : \u03b1 \u2192 Part \u03b2) : 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 : \u03b1) (f : \u03b1 \u2192 Part \u03b2) : (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 \u03b1} {a : \u03b1} (h : a \u2208 o) (f : \u03b1 \u2192 Part \u03b2) : 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 : \u03b1 \u2192 \u03b2) (x : Part \u03b1) : x.bind (some \u2218 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 : \u03b1 \u2192 Part \u03b2) (o : Part \u03b1) [Decidable o.Dom] [\u2200 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  \u00b7 simp_rw [h.toOption, h.bind]\n    rfl\n  \u00b7 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 {\u03b3} (f : Part \u03b1) (g : \u03b1 \u2192 Part \u03b2) (k : \u03b2 \u2192 Part \u03b3) :\n    (f.bind g).bind k = f.bind fun x => (g x).bind k :=\n  ext fun a => by\n    simp;\n      exact\n        \u27e8fun \u27e8_, \u27e8_, h\u2081, h\u2082\u27e9, h\u2083\u27e9 => \u27e8_, h\u2081, _, h\u2082, h\u2083\u27e9, fun \u27e8_, h\u2081, _, h\u2082, h\u2083\u27e9 =>\n          \u27e8_, \u27e8_, h\u2081, h\u2082\u27e9, h\u2083\u27e9\u27e9\n#align part.bind_assoc Part.bind_assoc\n\n@[simp]\ntheorem bind_map {\u03b3} (f : \u03b1 \u2192 \u03b2) (x) (g : \u03b2 \u2192 Part \u03b3) :\n    (map f x).bind g = x.bind fun y => g (f y) := by rw [\u2190 bind_some_eq_map, bind_assoc]; simp\n#align part.bind_map Part.bind_map\n\n@[simp]\ntheorem map_bind {\u03b3} (f : \u03b1 \u2192 Part \u03b2) (x : Part \u03b1) (g : \u03b2 \u2192 \u03b3) :\n    map g (x.bind f) = x.bind fun y => map g (f y) := by\n  rw [\u2190 bind_some_eq_map, bind_assoc]; simp [bind_some_eq_map]\n#align part.map_bind Part.map_bind\n\ntheorem map_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) (o : Part \u03b1) : map g (map f o) = map (g \u2218 f) o := by\n  erw [\u2190 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 : \u03b1 \u2192 \u03b1} (H : \u2200 x : \u03b1, 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 \u03b1) : 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 : \u03b1) : pure a = some a :=\n  rfl\n#align part.pure_eq_some Part.pure_eq_some\n\n@[simp]\ntheorem ret_eq_some (a : \u03b1) : (return a : Part \u03b1) = some a :=\n  rfl\n#align part.ret_eq_some Part.ret_eq_some\n\n@[simp]\ntheorem map_eq_map {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (o : Part \u03b1) : f <$> o = map f o :=\n  rfl\n#align part.map_eq_map Part.map_eq_map\n\n@[simp]\ntheorem bind_eq_bind {\u03b1 \u03b2} (f : Part \u03b1) (g : \u03b1 \u2192 Part \u03b2) : f >>= g = f.bind g :=\n  rfl\n#align part.bind_eq_bind Part.bind_eq_bind\n\ntheorem bind_le {\u03b1} (x : Part \u03b1) (f : \u03b1 \u2192 Part \u03b2) (y : Part \u03b2) :\n    x >>= f \u2264 y \u2194 \u2200 a, a \u2208 x \u2192 f a \u2264 y := by\n  constructor <;> intro h\n  \u00b7 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  \u00b7 intro b h'\n    simp only [exists_prop, bind_eq_bind, mem_bind_iff] at h'\n    rcases h' with \u27e8a, h\u2080, h\u2081\u27e9\n    apply h _ h\u2080 _ h\u2081\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 \u03b1) (H : p \u2192 o.Dom) : Part \u03b1 :=\n  \u27e8p, fun h => o.get (H h)\u27e9\n#align part.restrict Part.restrict\n\n@[simp]\ntheorem mem_restrict (p : Prop) (o : Part \u03b1) (h : p \u2192 o.Dom) (a : \u03b1) :\n    a \u2208 restrict p o h \u2194 p \u2227 a \u2208 o := by\n  dsimp [restrict, mem_eq]; constructor\n  \u00b7 rintro \u27e8h\u2080, h\u2081\u27e9\n    exact \u27e8h\u2080, \u27e8_, h\u2081\u27e9\u27e9\n  rintro \u27e8h\u2080, _, h\u2082\u27e9; exact \u27e8h\u2080, h\u2082\u27e9\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 \u03b1) : \u03b1 :=\n  o.get lcProof\n#align part.unwrap Part.unwrap\n\ntheorem assert_defined {p : Prop} {f : p \u2192 Part \u03b1} : \u2200 h : p, (f h).Dom \u2192 (assert p f).Dom :=\n  Exists.intro\n#align part.assert_defined Part.assert_defined\n\ntheorem bind_defined {f : Part \u03b1} {g : \u03b1 \u2192 Part \u03b2} :\n    \u2200 h : f.Dom, (g (f.get h)).Dom \u2192 (f.bind g).Dom :=\n  assert_defined\n#align part.bind_defined Part.bind_defined\n\n@[simp]\ntheorem bind_dom {f : Part \u03b1} {g : \u03b1 \u2192 Part \u03b2} : (f.bind g).Dom \u2194 \u2203 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 \u03b1` inherited from `\u03b1`.\n@[to_additive]\ninstance [One \u03b1] : One (Part \u03b1) where one := pure 1\n\n@[to_additive]\ninstance [Mul \u03b1] : Mul (Part \u03b1) where mul a b := (\u00b7 * \u00b7) <$> a <*> b\n\n@[to_additive]\ninstance [Inv \u03b1] : Inv (Part \u03b1) where inv := map Inv.inv\n\n@[to_additive]\ninstance [Div \u03b1] : Div (Part \u03b1) where div a b := (\u00b7 / \u00b7) <$> a <*> b\n\ninstance [Mod \u03b1] : Mod (Part \u03b1) where mod a b := (\u00b7 % \u00b7) <$> a <*> b\n\ninstance [Append \u03b1] : Append (Part \u03b1) where append a b := (\u00b7 ++ \u00b7) <$> a <*> b\n\ninstance [Inter \u03b1] : Inter (Part \u03b1) where inter a b := (\u00b7 \u2229 \u00b7) <$> a <*> b\n\ninstance [Union \u03b1] : Union (Part \u03b1) where union a b := (\u00b7 \u222a \u00b7) <$> a <*> b\n\ninstance [SDiff \u03b1] : SDiff (Part \u03b1) where sdiff a b := (\u00b7 \\ \u00b7) <$> a <*> b\n\nsection\n-- Porting note : new theorems to unfold definitions\ntheorem mul_def [Mul \u03b1] (a b : Part \u03b1) : a * b = bind a fun y \u21a6 map (y * .) b := rfl\ntheorem one_def [One \u03b1] : (1 : Part \u03b1) = some 1 := rfl\ntheorem inv_def [Inv \u03b1] (a : Part \u03b1) : a\u207b\u00b9 = Part.map (. \u207b\u00b9) a := rfl\ntheorem div_def [Div \u03b1] (a b : Part \u03b1) : a / b = bind a fun y => map (y / .) b := rfl\ntheorem mod_def [Mod \u03b1] (a b : Part \u03b1) : a % b = bind a fun y => map (y % .) b := rfl\ntheorem append_def [Append \u03b1] (a b : Part \u03b1) : a ++ b = bind a fun y => map (y ++ .) b := rfl\ntheorem inter_def [Inter \u03b1] (a b : Part \u03b1) : a \u2229 b = bind a fun y => map (y \u2229 .) b := rfl\ntheorem union_def [Union \u03b1] (a b : Part \u03b1) : a \u222a b = bind a fun y => map (y \u222a .) b := rfl\ntheorem sdiff_def [SDiff \u03b1] (a b : Part \u03b1) : a \\ b = bind a fun y => map (y \\ .) b := rfl\n\nend\n\n@[to_additive]\ntheorem one_mem_one [One \u03b1] : (1 : \u03b1) \u2208 (1 : Part \u03b1) :=\n  \u27e8trivial, rfl\u27e9\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 \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma * mb \u2208 a * b := \u27e8\u27e8ha.1, hb.1\u27e9, by simp [\u2190 ha.2, \u2190 hb.2]; rfl\u27e9\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 \u03b1] {a b : Part \u03b1} (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 \u03b1] {a b : Part \u03b1} (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 \u03b1] (a b : Part \u03b1) (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 \u03b1] (a b : \u03b1) : 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 \u03b1] (a : Part \u03b1) (ma : \u03b1) (ha : ma \u2208 a) : ma\u207b\u00b9 \u2208 a\u207b\u00b9 :=\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 \u03b1] (a : \u03b1) : (some a)\u207b\u00b9 = some a\u207b\u00b9 :=\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 \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma / mb \u2208 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 \u03b1] {a b : Part \u03b1} (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 \u03b1] {a b : Part \u03b1} (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 \u03b1] (a b : Part \u03b1) (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 \u03b1] (a b : \u03b1) : 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 \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma % mb \u2208 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 \u03b1] {a b : Part \u03b1} (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 \u03b1] {a b : Part \u03b1} (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 \u03b1] (a b : Part \u03b1) (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 \u03b1] (a b : \u03b1) : 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 \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma ++ mb \u2208 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 \u03b1] {a b : Part \u03b1} (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 \u03b1] {a b : Part \u03b1} (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 \u03b1] (a b : Part \u03b1) (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 \u03b1] (a b : \u03b1) : 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 \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma \u2229 mb \u2208 a \u2229 b := by simp [inter_def]; aesop\n#align part.inter_mem_inter Part.inter_mem_inter\n\ntheorem left_dom_of_inter_dom [Inter \u03b1] {a b : Part \u03b1} (hab : Dom (a \u2229 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 \u03b1] {a b : Part \u03b1} (hab : Dom (a \u2229 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 \u03b1] (a b : Part \u03b1) (hab : Dom (a \u2229 b)) :\n    (a \u2229 b).get hab = a.get (left_dom_of_inter_dom hab) \u2229 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 \u03b1] (a b : \u03b1) : some a \u2229 some b = some (a \u2229 b) :=\n  by simp [inter_def]\n#align part.some_inter_some Part.some_inter_some\n\ntheorem union_mem_union [Union \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma \u222a mb \u2208 a \u222a b := by simp [union_def]; aesop\n#align part.union_mem_union Part.union_mem_union\n\ntheorem left_dom_of_union_dom [Union \u03b1] {a b : Part \u03b1} (hab : Dom (a \u222a 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 \u03b1] {a b : Part \u03b1} (hab : Dom (a \u222a 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 \u03b1] (a b : Part \u03b1) (hab : Dom (a \u222a b)) :\n    (a \u222a b).get hab = a.get (left_dom_of_union_dom hab) \u222a 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 \u03b1] (a b : \u03b1) : some a \u222a some b = some (a \u222a b) := by simp [union_def]\n#align part.some_union_some Part.some_union_some\n\ntheorem sdiff_mem_sdiff [SDiff \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma \\ mb \u2208 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 \u03b1] {a b : Part \u03b1} (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 \u03b1] {a b : Part \u03b1} (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 \u03b1] (a b : Part \u03b1) (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 \u03b1] (a b : \u03b1) : 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 {\u03b1 : Type _} {\u03b2 : Type _} [Encodable \u03b2]\n\n/- warning: encodable.supr_decode\u2082 -> Encodable.sup\u1d62_decode\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Encodable.{u2} \u03b2] [_inst_2 : CompleteLattice.{u1} \u03b1] (f : \u03b2 -> \u03b1), Eq.{succ u1} \u03b1 (sup\u1d62.{u1, 1} \u03b1 (CompleteSemilatticeSup.toHasSup.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeSup.{u1} \u03b1 _inst_2)) Nat (fun (i : Nat) => sup\u1d62.{u1, succ u2} \u03b1 (CompleteSemilatticeSup.toHasSup.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeSup.{u1} \u03b1 _inst_2)) \u03b2 (fun (b : \u03b2) => sup\u1d62.{u1, 0} \u03b1 (CompleteSemilatticeSup.toHasSup.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeSup.{u1} \u03b1 _inst_2)) (Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b (Encodable.decode\u2082.{u2} \u03b2 _inst_1 i)) (fun (H : Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b (Encodable.decode\u2082.{u2} \u03b2 _inst_1 i)) => f b)))) (sup\u1d62.{u1, succ u2} \u03b1 (CompleteSemilatticeSup.toHasSup.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeSup.{u1} \u03b1 _inst_2)) \u03b2 (fun (b : \u03b2) => f b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Encodable.{u1} \u03b2] [_inst_2 : CompleteLattice.{u2} \u03b1] (f : \u03b2 -> \u03b1), Eq.{succ u2} \u03b1 (sup\u1d62.{u2, 1} \u03b1 (CompleteLattice.toSupSet.{u2} \u03b1 _inst_2) Nat (fun (i : Nat) => sup\u1d62.{u2, succ u1} \u03b1 (CompleteLattice.toSupSet.{u2} \u03b1 _inst_2) \u03b2 (fun (b : \u03b2) => sup\u1d62.{u2, 0} \u03b1 (CompleteLattice.toSupSet.{u2} \u03b1 _inst_2) (Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b (Encodable.decode\u2082.{u1} \u03b2 _inst_1 i)) (fun (H : Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b (Encodable.decode\u2082.{u1} \u03b2 _inst_1 i)) => f b)))) (sup\u1d62.{u2, succ u1} \u03b1 (CompleteLattice.toSupSet.{u2} \u03b1 _inst_2) \u03b2 (fun (b : \u03b2) => f b))\nCase conversion may be inaccurate. Consider using '#align encodable.supr_decode\u2082 Encodable.sup\u1d62_decode\u2082\u2093'. -/\ntheorem sup\u1d62_decode\u2082 [CompleteLattice \u03b1] (f : \u03b2 \u2192 \u03b1) :\n    (\u2a06 (i : \u2115) (b \u2208 decode\u2082 \u03b2 i), f b) = \u2a06 b, f b :=\n  by\n  rw [sup\u1d62_comm]\n  simp [mem_decode\u2082]\n#align encodable.supr_decode\u2082 Encodable.sup\u1d62_decode\u2082\n\n/- warning: encodable.Union_decode\u2082 -> Encodable.union\u1d62_decode\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Encodable.{u2} \u03b2] (f : \u03b2 -> (Set.{u1} \u03b1)), Eq.{succ u1} (Set.{u1} \u03b1) (Set.union\u1d62.{u1, 1} \u03b1 Nat (fun (i : Nat) => Set.union\u1d62.{u1, succ u2} \u03b1 \u03b2 (fun (b : \u03b2) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b (Encodable.decode\u2082.{u2} \u03b2 _inst_1 i)) (fun (H : Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b (Encodable.decode\u2082.{u2} \u03b2 _inst_1 i)) => f b)))) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b2 (fun (b : \u03b2) => f b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Encodable.{u1} \u03b2] (f : \u03b2 -> (Set.{u2} \u03b1)), Eq.{succ u2} (Set.{u2} \u03b1) (Set.union\u1d62.{u2, 1} \u03b1 Nat (fun (i : Nat) => Set.union\u1d62.{u2, succ u1} \u03b1 \u03b2 (fun (b : \u03b2) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b (Encodable.decode\u2082.{u1} \u03b2 _inst_1 i)) (fun (H : Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b (Encodable.decode\u2082.{u1} \u03b2 _inst_1 i)) => f b)))) (Set.union\u1d62.{u2, succ u1} \u03b1 \u03b2 (fun (b : \u03b2) => f b))\nCase conversion may be inaccurate. Consider using '#align encodable.Union_decode\u2082 Encodable.union\u1d62_decode\u2082\u2093'. -/\ntheorem union\u1d62_decode\u2082 (f : \u03b2 \u2192 Set \u03b1) : (\u22c3 (i : \u2115) (b \u2208 decode\u2082 \u03b2 i), f b) = \u22c3 b, f b :=\n  sup\u1d62_decode\u2082 f\n#align encodable.Union_decode\u2082 Encodable.union\u1d62_decode\u2082\n\n/- warning: encodable.Union_decode\u2082_cases -> Encodable.union\u1d62_decode\u2082_cases is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Encodable.{u2} \u03b2] {f : \u03b2 -> (Set.{u1} \u03b1)} {C : (Set.{u1} \u03b1) -> Prop}, (C (EmptyCollection.emptyCollection.{u1} (Set.{u1} \u03b1) (Set.hasEmptyc.{u1} \u03b1))) -> (forall (b : \u03b2), C (f b)) -> (forall {n : Nat}, C (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b2 (fun (b : \u03b2) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b (Encodable.decode\u2082.{u2} \u03b2 _inst_1 n)) (fun (H : Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b (Encodable.decode\u2082.{u2} \u03b2 _inst_1 n)) => f b))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Encodable.{u1} \u03b2] {f : \u03b2 -> (Set.{u2} \u03b1)} {C : (Set.{u2} \u03b1) -> Prop}, (C (EmptyCollection.emptyCollection.{u2} (Set.{u2} \u03b1) (Set.instEmptyCollectionSet.{u2} \u03b1))) -> (forall (b : \u03b2), C (f b)) -> (forall {n : Nat}, C (Set.union\u1d62.{u2, succ u1} \u03b1 \u03b2 (fun (b : \u03b2) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b (Encodable.decode\u2082.{u1} \u03b2 _inst_1 n)) (fun (H : Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b (Encodable.decode\u2082.{u1} \u03b2 _inst_1 n)) => f b))))\nCase conversion may be inaccurate. Consider using '#align encodable.Union_decode\u2082_cases Encodable.union\u1d62_decode\u2082_cases\u2093'. -/\n@[elab_as_elim]\ntheorem union\u1d62_decode\u2082_cases {f : \u03b2 \u2192 Set \u03b1} {C : Set \u03b1 \u2192 Prop} (H0 : C \u2205) (H1 : \u2200 b, C (f b)) {n} :\n    C (\u22c3 b \u2208 decode\u2082 \u03b2 n, f b) :=\n  match decode\u2082 \u03b2 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\u2082_cases Encodable.union\u1d62_decode\u2082_cases\n\n/- warning: encodable.Union_decode\u2082_disjoint_on -> Encodable.union\u1d62_decode\u2082_disjoint_on is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Encodable.{u2} \u03b2] {f : \u03b2 -> (Set.{u1} \u03b1)}, (Pairwise.{u2} \u03b2 (Function.onFun.{succ u2, succ u1, 1} \u03b2 (Set.{u1} \u03b1) Prop (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)))) f)) -> (Pairwise.{0} Nat (Function.onFun.{1, succ u1, 1} Nat (Set.{u1} \u03b1) Prop (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)))) (fun (i : Nat) => Set.union\u1d62.{u1, succ u2} \u03b1 \u03b2 (fun (b : \u03b2) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b (Encodable.decode\u2082.{u2} \u03b2 _inst_1 i)) (fun (H : Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b (Encodable.decode\u2082.{u2} \u03b2 _inst_1 i)) => f b)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Encodable.{u1} \u03b2] {f : \u03b2 -> (Set.{u2} \u03b1)}, (Pairwise.{u1} \u03b2 (Function.onFun.{succ u1, succ u2, 1} \u03b2 (Set.{u2} \u03b1) Prop (Disjoint.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} \u03b1) (Preorder.toLE.{u2} (Set.{u2} \u03b1) (PartialOrder.toPreorder.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1))))))) f)) -> (Pairwise.{0} Nat (Function.onFun.{1, succ u2, 1} Nat (Set.{u2} \u03b1) Prop (Disjoint.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} \u03b1) (Preorder.toLE.{u2} (Set.{u2} \u03b1) (PartialOrder.toPreorder.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1))))))) (fun (i : Nat) => Set.union\u1d62.{u2, succ u1} \u03b1 \u03b2 (fun (b : \u03b2) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b (Encodable.decode\u2082.{u1} \u03b2 _inst_1 i)) (fun (H : Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b (Encodable.decode\u2082.{u1} \u03b2 _inst_1 i)) => f b)))))\nCase conversion may be inaccurate. Consider using '#align encodable.Union_decode\u2082_disjoint_on Encodable.union\u1d62_decode\u2082_disjoint_on\u2093'. -/\ntheorem union\u1d62_decode\u2082_disjoint_on {f : \u03b2 \u2192 Set \u03b1} (hd : Pairwise (Disjoint on f)) :\n    Pairwise (Disjoint on fun i => \u22c3 b \u2208 decode\u2082 \u03b2 i, f b) :=\n  by\n  rintro i j ij\n  refine' disjoint_left.mpr fun x => _\n  suffices \u2200 a, encode a = i \u2192 x \u2208 f a \u2192 \u2200 b, encode b = j \u2192 x \u2209 f b by simpa [decode\u2082_eq_some]\n  rintro a rfl ha b rfl hb\n  exact (hd (mt (congr_arg encode) ij)).le_bot \u27e8ha, hb\u27e9\n#align encodable.Union_decode\u2082_disjoint_on Encodable.union\u1d62_decode\u2082_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 : \u2115 \u2192. \u2115} {g : \u2115 \u2192. \u2115} (hf : partrec f) (hg : partrec g) : \u2203 (h : \u2115 \u2192. \u2115),\n  partrec h \u2227\n    \u2200 (a : \u2115), (\u2200 (x : \u2115), x \u2208 h a \u2192 x \u2208 f a \u2228 x \u2208 g a) \u2227 (roption.dom (h a) \u2194 roption.dom (f a) \u2228 roption.dom (g a)) := sorry\n\nend nat.partrec\n\n\nnamespace partrec\n\n\ntheorem merge' {\u03b1 : Type u_1} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03c3] {f : \u03b1 \u2192. \u03c3} {g : \u03b1 \u2192. \u03c3} (hf : partrec f) (hg : partrec g) : \u2203 (k : \u03b1 \u2192. \u03c3),\n  partrec k \u2227\n    \u2200 (a : \u03b1), (\u2200 (x : \u03c3), x \u2208 k a \u2192 x \u2208 f a \u2228 x \u2208 g a) \u2227 (roption.dom (k a) \u2194 roption.dom (f a) \u2228 roption.dom (g a)) := sorry\n\ntheorem merge {\u03b1 : Type u_1} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03c3] {f : \u03b1 \u2192. \u03c3} {g : \u03b1 \u2192. \u03c3} (hf : partrec f) (hg : partrec g) (H : \u2200 (a : \u03b1) (x : \u03c3), x \u2208 f a \u2192 \u2200 (y : \u03c3), y \u2208 g a \u2192 x = y) : \u2203 (k : \u03b1 \u2192. \u03c3), partrec k \u2227 \u2200 (a : \u03b1) (x : \u03c3), x \u2208 k a \u2194 x \u2208 f a \u2228 x \u2208 g a := sorry\n\ntheorem cond {\u03b1 : Type u_1} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03c3] {c : \u03b1 \u2192 Bool} {f : \u03b1 \u2192. \u03c3} {g : \u03b1 \u2192. \u03c3} (hc : computable c) (hf : partrec f) (hg : partrec g) : partrec fun (a : \u03b1) => cond (c a) (f a) (g a) := sorry\n\ntheorem sum_cases {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03c3 : Type u_4} [primcodable \u03b1] [primcodable \u03b2] [primcodable \u03b3] [primcodable \u03c3] {f : \u03b1 \u2192 \u03b2 \u2295 \u03b3} {g : \u03b1 \u2192 \u03b2 \u2192. \u03c3} {h : \u03b1 \u2192 \u03b3 \u2192. \u03c3} (hf : computable f) (hg : partrec\u2082 g) (hh : partrec\u2082 h) : partrec fun (a : \u03b1) => 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 {\u03b1 : Type u_1} [primcodable \u03b1] (p : \u03b1 \u2192 Prop) :=\n  Exists (computable fun (a : \u03b1) => 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 {\u03b1 : Type u_1} [primcodable \u03b1] (p : \u03b1 \u2192 Prop) :=\n  partrec fun (a : \u03b1) => roption.assert (p a) fun (_x : p a) => roption.some Unit.unit\n\ntheorem computable_pred.of_eq {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} (hp : computable_pred p) (H : \u2200 (a : \u03b1), p a \u2194 q a) : computable_pred q :=\n  (funext fun (a : \u03b1) => propext (H a)) \u25b8 hp\n\nnamespace computable_pred\n\n\ntheorem computable_iff {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} : computable_pred p \u2194 \u2203 (f : \u03b1 \u2192 Bool), computable f \u2227 p = fun (a : \u03b1) => \u21a5(f a) := sorry\n\nprotected theorem not {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} (hp : computable_pred p) : computable_pred fun (a : \u03b1) => \u00acp a := sorry\n\ntheorem to_re {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} (hp : computable_pred p) : re_pred p := sorry\n\ntheorem rice (C : set (\u2115 \u2192. \u2115)) (h : computable_pred fun (c : nat.partrec.code) => nat.partrec.code.eval c \u2208 C) {f : \u2115 \u2192. \u2115} {g : \u2115 \u2192. \u2115} (hf : nat.partrec f) (hg : nat.partrec g) (fC : f \u2208 C) : g \u2208 C := sorry\n\ntheorem rice\u2082 (C : set nat.partrec.code) (H : \u2200 (cf cg : nat.partrec.code), nat.partrec.code.eval cf = nat.partrec.code.eval cg \u2192 (cf \u2208 C \u2194 cg \u2208 C)) : (computable_pred fun (c : nat.partrec.code) => c \u2208 C) \u2194 C = \u2205 \u2228 C = set.univ := sorry\n\ntheorem halting_problem (n : \u2115) : \u00accomputable_pred fun (c : nat.partrec.code) => roption.dom (nat.partrec.code.eval c n) :=\n  fun (\u1fb0 : computable_pred fun (c : nat.partrec.code) => roption.dom (nat.partrec.code.eval c n)) =>\n    idRhs ((fun (n : \u2115) => roption.none) \u2208 set_of fun (f : \u2115 \u2192. \u2115) => roption.dom (f n))\n      (rice (set_of fun (f : \u2115 \u2192. \u2115) => roption.dom (f n)) \u1fb0 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 {\u03b1 : Type u_1} [primcodable \u03b1] {p : \u03b1 \u2192 Prop} [decidable_pred p] : computable_pred p \u2194 re_pred p \u2227 re_pred fun (a : \u03b1) => \u00acp a := sorry\n\nend computable_pred\n\n\nnamespace nat\n\n\n/-- A simplified basis for `partrec`. -/\ninductive partrec' : {n : \u2115} \u2192 (vector \u2115 n \u2192. \u2115) \u2192 Prop\nwhere\n| prim : \u2200 {n : \u2115} {f : vector \u2115 n \u2192 \u2115}, primrec' f \u2192 partrec' \u2191f\n| comp : \u2200 {m n : \u2115} {f : vector \u2115 n \u2192. \u2115} (g : fin n \u2192 vector \u2115 m \u2192. \u2115),\n  partrec' f \u2192\n    (\u2200 (i : fin n), partrec' (g i)) \u2192 partrec' fun (v : vector \u2115 m) => (vector.m_of_fn fun (i : fin n) => g i v) >>= f\n| rfind : \u2200 {n : \u2115} {f : vector \u2115 (n + 1) \u2192 \u2115},\n  partrec' \u2191f \u2192 partrec' fun (v : vector \u2115 n) => rfind fun (n_1 : \u2115) => roption.some (to_bool (f (n_1::\u1d65v) = 0))\n\nend nat\n\n\nnamespace nat.partrec'\n\n\ntheorem to_part {n : \u2115} {f : vector \u2115 n \u2192. \u2115} (pf : partrec' f) : partrec f := sorry\n\ntheorem of_eq {n : \u2115} {f : vector \u2115 n \u2192. \u2115} {g : vector \u2115 n \u2192. \u2115} (hf : partrec' f) (H : \u2200 (i : vector \u2115 n), f i = g i) : partrec' g :=\n  funext H \u25b8 hf\n\ntheorem of_prim {n : \u2115} {f : vector \u2115 n \u2192 \u2115} (hf : primrec f) : partrec' \u2191f :=\n  prim (primrec'.of_prim hf)\n\ntheorem head {n : \u2115} : partrec' \u2191vector.head :=\n  prim primrec'.head\n\ntheorem tail {n : \u2115} {f : vector \u2115 n \u2192. \u2115} (hf : partrec' f) : partrec' fun (v : vector \u2115 (Nat.succ n)) => f (vector.tail v) := sorry\n\nprotected theorem bind {n : \u2115} {f : vector \u2115 n \u2192. \u2115} {g : vector \u2115 (n + 1) \u2192. \u2115} (hf : partrec' f) (hg : partrec' g) : partrec' fun (v : vector \u2115 n) => roption.bind (f v) fun (a : \u2115) => g (a::\u1d65v) := sorry\n\nprotected theorem map {n : \u2115} {f : vector \u2115 n \u2192. \u2115} {g : vector \u2115 (n + 1) \u2192 \u2115} (hf : partrec' f) (hg : partrec' \u2191g) : partrec' fun (v : vector \u2115 n) => roption.map (fun (a : \u2115) => g (a::\u1d65v)) (f v) := sorry\n\n/-- Analogous to `nat.partrec'` for `\u2115`-valued functions, a predicate for partial recursive\n  vector-valued functions.-/\ndef vec {n : \u2115} {m : \u2115} (f : vector \u2115 n \u2192 vector \u2115 m) :=\n  \u2200 (i : fin m), partrec' \u2191fun (v : vector \u2115 n) => vector.nth (f v) i\n\ntheorem vec.prim {n : \u2115} {m : \u2115} {f : vector \u2115 n \u2192 vector \u2115 m} (hf : primrec'.vec f) : vec f :=\n  fun (i : fin m) => prim (hf i)\n\nprotected theorem nil {n : \u2115} : vec fun (_x : vector \u2115 n) => vector.nil :=\n  fun (i : fin 0) => fin.elim0 i\n\nprotected theorem cons {n : \u2115} {m : \u2115} {f : vector \u2115 n \u2192 \u2115} {g : vector \u2115 n \u2192 vector \u2115 m} (hf : partrec' \u2191f) (hg : vec g) : vec fun (v : vector \u2115 n) => f v::\u1d65g v := sorry\n\ntheorem idv {n : \u2115} : vec id :=\n  vec.prim primrec'.idv\n\ntheorem comp' {n : \u2115} {m : \u2115} {f : vector \u2115 m \u2192. \u2115} {g : vector \u2115 n \u2192 vector \u2115 m} (hf : partrec' f) (hg : vec g) : partrec' fun (v : vector \u2115 n) => f (g v) := sorry\n\ntheorem comp\u2081 {n : \u2115} (f : \u2115 \u2192. \u2115) {g : vector \u2115 n \u2192 \u2115} (hf : partrec' fun (v : vector \u2115 1) => f (vector.head v)) (hg : partrec' \u2191g) : partrec' fun (v : vector \u2115 n) => f (g v) := sorry\n\ntheorem rfind_opt {n : \u2115} {f : vector \u2115 (n + 1) \u2192 \u2115} (hf : partrec' \u2191f) : partrec' fun (v : vector \u2115 n) => rfind_opt fun (a : \u2115) => denumerable.of_nat (Option \u2115) (f (a::\u1d65v)) := sorry\n\ntheorem of_part {n : \u2115} {f : vector \u2115 n \u2192. \u2115} : partrec f \u2192 partrec' f := sorry\n\ntheorem part_iff {n : \u2115} {f : vector \u2115 n \u2192. \u2115} : partrec' f \u2194 partrec f :=\n  { mp := to_part, mpr := of_part }\n\ntheorem part_iff\u2081 {f : \u2115 \u2192. \u2115} : (partrec' fun (v : vector \u2115 1) => f (vector.head v)) \u2194 partrec f := sorry\n\ntheorem part_iff\u2082 {f : \u2115 \u2192 \u2115 \u2192. \u2115} : (partrec' fun (v : vector \u2115 (bit0 1)) => f (vector.head v) (vector.head (vector.tail v))) \u2194 partrec\u2082 f := sorry\n\ntheorem vec_iff {m : \u2115} {n : \u2115} {f : vector \u2115 m \u2192 vector \u2115 n} : vec f \u2194 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 : \u2115\u221e) (C : \u2115) (f : V \u2192 V') :=\n  \u2200 \u2983x y : V\u2984, \u2200 \u2983a : \u2115\u221e\u2984, G.edist x y < a \u2192 G'.edist (f x) (f y) < K * a + C\n\ndef coarse_equal_with (K : \u2115\u221e) (f g : V \u2192 V'):=\n  \u2200 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 (\u03c6 : G \u2192g G') : coarse_lipschitz_with G G' 1 0 \u03c6 := by {\n  intros x y a h,\n  cases le_iff_lt_or_eq.mp (simple_graph.hom.edist_le \u03c6 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 \u2192 V'} {K K' : \u2115\u221e} {C C' : \u2115} (hK : K \u2264 K') (hC : C \u2264 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 \u2192 V') (g : V' \u2192 V'')\n  {K K' : \u2115\u221e} {C C' : \u2115}\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 \u2218 f) := by {\n    intros _ _ a hdist,\n    refine lt_of_le_of_lt' _ (hg (hf hdist)),\n    rw [enat.coe_add, \u2190 add_assoc, mul_add, \u2190 mul_assoc, enat.coe_mul],\n    refine add_le_add _ (le_refl _),\n    by_cases h : K' = \u22a4,\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 \u2192 V') \u2192 Sort*} (C : \u2115) :\n  (\u2200 (f : V \u2192 V') (hf : coarse_lipschitz_with G G' \u22a4 C f), P f) \u2192\n  (\u2200 (f : V \u2192 V') (K : \u2115\u221e) (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 \u2192 V') {C : \u2115} :\n  (coarse_lipschitz_with G G' \u22a4 C f) \u2194 (\u2200 x y : V, G.reachable x y \u2192 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 \u2192 V'} {k : \u2115\u221e} {c : \u2115} (hf : coarse_lipschitz_with G G' k c f) (K : set V) :\n  coarse_lipschitz_with (G.induce K\u1d9c) G' k c (f \u2218 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 \u2286 K') {f : \u21a5(K)\u1d9c \u2192 V'} {k : \u2115\u221e} {c : \u2115}\n  (hf : coarse_lipschitz_with (G.out K) G' k c f) :\n    coarse_lipschitz_with (G.out K') G' k c (f \u2218 (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 \u2286 L') {f : V \u2192 \u21a5L'\u1d9c} {k : \u2115\u221e} {c : \u2115}\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) \u2218 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 \u2192 V'} {k : \u2115\u221e} {c : \u2115} (hf : coarse_lipschitz_with G G' k c f) :\n  G.connected_component \u2192 G'.connected_component :=\n    simple_graph.connected_component.lift (\u03bb 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 \u2286 K') {f : \u21a5(K)\u1d9c \u2192 V'} {k : \u2115\u221e} {c : \u2115}\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 \u2286 L') {f : V \u2192 \u21a5(\u2191L')\u1d9c} {k : \u2115\u221e} {c : \u2115}\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 \u2192 V') {K : set V} {L : set V'} (h : f\u207b\u00b9' L \u2286 K) : K\u1d9c \u2192 L\u1d9c :=\n  \u03bb \u27e8k, hk\u27e9, \u27e8f k, \u03bb hL, hk (h hL)\u27e9\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') (\u03c6 : V \u2192 V') :=\n  (\u03ba : \u2115\u221e) (C : \u2115)\n  (finset_mapping : finset V' \u2192 finset V)\n  (finset_inv_sub : \u2200 L : finset V', \u03c6 \u207b\u00b9' (L : set V') \u2286 (finset_mapping L : set V))\n  (induced_coarse_lipschitz : \u2200 L : finset V',\n    coarse_lipschitz_with (G.induce (finset_mapping L)\u1d9c) (G'.induce L\u1d9c)\n      \u03ba C (induce_out \u03c6 (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 \u2192 V') :=\n  (\u03ba : \u2115\u221e)\n  (finset_mapping : finset V' \u2192 finset V)\n  (finset_inv_subl : \u2200 L : finset V', f\u207b\u00b9' (L : set V') \u2286 (finset_mapping L : set V))\n  (finset_inv_subr : \u2200 L : finset V', g\u207b\u00b9' (L : set V') \u2286 (finset_mapping L : set V))\n  (induced_coarse_equal : \u2200 L : finset V', coarse_equal_with (G'.induce L\u1d9c) \u03ba\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)\u1d52\u1d56} (h : K.unop \u2286 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 \u2192 V'} (fcoarse : coarse_map G G' f) : G.end \u2192 G'.end := by\n  {\n    rintro e,\n    refine \u27e8\u03bb L, _, _\u27e9,\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)\u1d52\u1d56 := opposite.op (\n        (fcoarse.finset_mapping L.unop) \u222a (fcoarse.finset_mapping L'.unop)),\n      have hL : (opposite.op $ fcoarse.finset_mapping L.unop).unop \u2286 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 \u2286 K.unop := by {\n        simp only [opposite.unop_op], apply finset.subset_union_right, },\n      dsimp,\n      rw [\u2190 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 \u2192 V'} (hclose : coarse_close G G' f g) : coarse_map G G' f := \n{ \u03ba := hclose.\u03ba,\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 \u2192 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 : \u2115)\n  (C : G.comp_out K)\n  (c : V) (cC : c \u2208 C) (c' : V) :\n  c \u2209 (G.closed_neighborhood K m) \u2192 G.edist c c' \u2264 m \u2192 c' \u2208 C :=\nbegin\n  rintro cnK,\n  sorry,\n/-rintro cnK,\n  obtain \u27e8w,wm\u27e9 := reachable.exists_walk_of_dist (Gpc c c'), rw \u2190wm,\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 \u27e8x,xw,xK\u27e9 := h,\n    rw [list.mem_to_finset,walk.mem_support_iff_exists_append] at xw,\n    obtain \u27e8cx,_,rfl\u27e9 := 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 \u2192 V'} {k : \u2115\u221e}\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 \u2192 V'} {k : \u2115\u221e}\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)\u1d52\u1d56 := opposite.op (\n        (fcoarse.finset_mapping L.unop) \u222a (gcoarse.finset_mapping L.unop)),\n    have hfL : (opposite.op $ fcoarse.finset_mapping L.unop).unop \u2286 K.unop := sorry,\n    have hgL : (opposite.op $ gcoarse.finset_mapping L.unop).unop \u2286 K.unop := sorry,\n    rw [\u2190 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      \u27e8v, sorry\u27e9,\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": "def f (x : Nat) : IO Nat := do\nIO.println \"hello world\"\nlet aux (y : Nat) (z : Nat) : IO Nat := do\n  IO.println \"aux started\"\n  IO.println s!\"y: {y}, z: {z}\"\n  pure (x+y)\ndiscard <| aux x\n  (x + 1) -- It is part of the application since it is indented\ndiscard <| aux x (x -- parentheses use `withoutPosition`\n-1)\ndiscard <| aux x x;\n  aux x\n x\n\n#eval f 10\n\ndef g (xs : List Nat) : StateT Nat Id Nat := do\nlet mut xs := xs\nif xs.isEmpty then\n  xs := [\u2190 get]\ndbg_trace \">>> xs: {xs}\"\nreturn xs.length\n\n#eval g [1, 2, 3] |>.run' 10\n#eval g [] |>.run' 10\n\ntheorem ex1 : (g [1, 2, 4, 5] |>.run' 0) = 4 :=\nrfl\n\ntheorem ex2 : (g [] |>.run' 0) = 1 :=\nrfl\n\ndef h (x : Nat) (y : Nat) : Nat := do\nlet mut x := x\nlet mut y := y\nif x > 0 then\n  let y' := x + 1\n  x := y'\nelse\n  y := y + 1\nreturn x + y\n\ntheorem ex3 (y : Nat) : h 0 y = 0 + (y + 1) :=\nrfl\n\ntheorem ex4 (y : Nat) : h 1 y = (1 + 1) + y :=\nrfl\n\ndef sumOdd (xs : List Nat) (threshold : Nat) : Nat := do\nlet mut sum := 0\nfor x in xs do\n  if x % 2 == 1 then\n    sum := sum + x\n  if sum > threshold then\n    break\n  unless x % 2 == 1 do\n    continue\n  dbg_trace \">> x: {x}\"\nreturn sum\n\n#eval sumOdd [1, 2, 3, 4, 5, 6, 7, 9, 11, 101] 10\n\ntheorem ex5 : sumOdd [1, 2, 3, 4, 5, 6, 7, 9, 11, 101] 10 = 16 :=\nrfl\n\n-- We need `Id.run` because we still have `Monad Option`\ndef find? (xs : List Nat) (p : Nat \u2192 Bool) : Option Nat := Id.run do\nlet mut result := none\nfor x in xs do\n  if p x then\n    result := x\n    break\nreturn result\n\ndef sumDiff (ps : List (Nat \u00d7 Nat)) : Nat := do\nlet mut sum := 0\nfor (x, y) in ps do\n  sum := sum + x - y\nreturn sum\n\ntheorem ex7 : sumDiff [(2, 1), (10, 5)] = 6 :=\nrfl\n\ndef f1 (x : Nat) : IO Unit := do\nlet rec loop : Nat \u2192 IO Unit\n  | 0   => pure ()\n  | x+1 => do IO.println x; loop x\nloop x\n\n#eval f1 10\n\npartial def f2 (x : Nat) : IO Unit := do\nlet rec\n  isEven : Nat \u2192 Bool\n    | 0   => true\n    | x+1 => isOdd x,\n  isOdd : Nat \u2192 Bool\n    | 0   => false\n    | x+1 => isEven x\nIO.println (\"isOdd(\" ++ toString x ++ \"): \" ++ toString (isOdd x))\n\n#eval f2 11\n#eval f2 10\n\ndef split (xs : List Nat) : List Nat \u00d7 List Nat := do\nlet mut evens := []\nlet mut odds  := []\nfor x in xs.reverse do\n  if x % 2 == 0 then\n    evens := x :: evens\n  else\n    odds := x :: odds\nreturn (evens, odds)\n\ntheorem ex8 : split [1, 2, 3, 4] = ([2, 4], [1, 3]) :=\nrfl\n\ndef f3 (x : Nat) : IO Bool := do\nlet y \u2190 cond (x == 0) (do IO.println \"hello\"; true) false;\n!y\n\ndef f4 (x y : Nat) : Nat \u00d7 Nat := do\n  let mut (x, y) := (x, y)\n  match x with\n  | 0 => y := y + 1\n  | _ => x := x + y\n  return (x, y)\n\n#eval f4 0 10\n#eval f4 5 10\n\ntheorem ex9 (y : Nat) : f4 0 y = (0, y+1) :=\nrfl\n\ntheorem ex10 (x y : Nat) : f4 (x+1) y = ((x+1)+y, y) :=\nrfl\n\ndef f5 (x y : Nat) : Nat \u00d7 Nat := do\n  let mut (x, y) := (x, y)\n  match x with\n  | 0   => y := y + 1\n  | z+1 => dbg_trace \"z: {z}\"; x := x + y\n  return (x, y)\n\n#eval f5 5 6\n\ntheorem ex11 (x y : Nat) : f5 (x+1) y = ((x+1)+y, y) :=\nrfl\n\ndef f6 (x : Nat) : Nat := do\n  let mut x := x\n  if x > 10 then\n    return 0\n  x := x + 1\n  return x\n\ntheorem ex12 : f6 11 = 0 :=\nrfl\n\ntheorem ex13 : f6 5 = 6 :=\nrfl\n\ndef findOdd (xs : List Nat) : Nat := do\nfor x in xs do\n  if x % 2 == 1 then\n    return x\nreturn 0\n\ntheorem ex14 : findOdd [2, 4, 5, 8, 7] = 5 :=\nrfl\n\ntheorem ex15 : findOdd [2, 4, 8, 10] = 0 :=\nrfl\n\ndef f7 (ref : IO.Ref (Option (Nat \u00d7 Nat))) : IO Nat := do\nlet some (x, y) \u2190 ref.get | pure 100\nIO.println (toString x ++ \", \" ++ toString y)\nreturn x+y\n\ndef f7Test : IO Unit := do\nunless (\u2190 f7 (\u2190 IO.mkRef (some (10, 20)))) == 30 do throw $ IO.userError \"unexpected\"\nunless (\u2190 f7 (\u2190 IO.mkRef none)) == 100 do throw $ IO.userError \"unexpected\"\n\n#eval f7Test\n\ndef f8 (x : Nat) : IO Nat := do\nlet y \u2190\n  if x == 0 then\n    IO.println \"x is zero\"\n    return 100 --  returns from the `do`-block\n  else\n    pure (x + 1)\nIO.println (\"y: \" ++ toString y)\nreturn y\n\ndef f8Test : IO Unit := do\nunless (\u2190 f8 0) == 100 do throw $ IO.userError \"unexpected\"\nunless (\u2190 f8 1) == 2 do throw $ IO.userError \"unexpected\"\n\n#eval f8Test\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/doNotation2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.600188359260205, "lm_q2_score": 0.7905303260722198, "lm_q1q2_score": 0.47446709935072046}}
{"text": "example {a : Type u} {s t : list \u03b1} : 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    \u03bb 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\u2081 J\u2082 C : Type*} [category C] (X : J\u2082 \u2192 C) [has_product X] (e : J\u2081 \u2243 J\u2082)\n\ndef fan_of_equiv : fan (X \u2218 e) := fan.mk (\u220f X)\n(\u03bb j, pi.\u03c0 _ (e j))\n\n@[simp]\nlemma fan_of_equiv_proj (j : J\u2081) : (fan_of_equiv X e).proj j = pi.\u03c0 _ (e j) := rfl\n\nlemma fan.congr_proj {J : Type*} {F : J \u2192 C} (s : fan F)\n  {j\u2081 j\u2082 : J} (h : j\u2081 = j\u2082) : s.proj j\u2081 \u226b eq_to_hom (by rw h) = s.proj j\u2082 :=\nby { subst h, rw [eq_to_hom_refl, comp_id], }\n\nlemma cone.congr_\u03c0 {J : Type*} [category J] {F : J \u2964 C} (s : cone F)\n  {j\u2081 j\u2082 : J} (h : j\u2081 = j\u2082) : s.\u03c0.app j\u2081 \u226b eq_to_hom (by rw h) = (s.\u03c0.app j\u2082 : s.X \u27f6 _) :=\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 _ (\u03bb s, pi.lift (\u03bb j\u2082,s.proj (e.symm j\u2082) \u226b eq_to_hom (by simp)))\n(\u03bb s j, begin\n  simp only [fan_of_equiv_proj, limit.lift_\u03c0, fan.mk_\u03c0_app],\n  exact fan.congr_proj _ (by simp),\nend)\n(\u03bb s m hm, begin\n  ext j\u2082,\n  discrete_cases,\n  simp only [limit.lift_\u03c0, fan.mk_\u03c0_app, \u2190 hm, assoc],\n  congr' 1,\n  dsimp,\n  symmetry,\n  have h : discrete.mk (e (e.symm j\u2082)) = discrete.mk j\u2082 := by simp,\n  apply cone.congr_\u03c0 _ h,\nend)\n\nlemma has_product_of_equiv : has_product (X \u2218 e) :=\n\u27e8nonempty.intro \u27e8_, is_limit_fan_of_equiv X e\u27e9\u27e9\n\nlemma product_iso_of_equiv [has_product (X \u2218 e)] : \u220f (X \u2218 e) \u2245 \u220f 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 \u2192 C) [has_product X] [has_product (\u03bb j, X (some j))]\n  [has_binary_product (\u220f (\u03bb j, X (some j))) (X none)] :\n  (\u220f X) \u2245 (\u220f (\u03bb j, X (some j))) \u2a2f (X none) :=\n{ hom := limits.prod.lift (pi.lift (\u03bb j, pi.\u03c0 _ (some j))) (pi.\u03c0 _ none),\n  inv := pi.lift (by { rintro (_|j), exacts [prod.snd, prod.fst \u226b pi.\u03c0 _ j], } ),\n  hom_inv_id' := begin\n    ext,\n    discrete_cases,\n    rcases j with (_|j),\n    { simp only [assoc, limit.lift_\u03c0, fan.mk_\u03c0_app, prod.lift_snd, id_comp], },\n    { simp only [assoc, limit.lift_\u03c0, fan.mk_\u03c0_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_\u03c0, fan.mk_\u03c0_app, prod.lift_fst, assoc, id_comp], },\n    { simp only [prod.comp_lift, limit.lift_\u03c0, fan.mk_\u03c0_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 \u2192\u2097\u2045R\u2046 L'` for a morphism of Lie algebras,\n * `L \u2243\u2097\u2045R\u2046 L'` for an equivalence of Lie algebras,\n * `M \u2192\u2097\u2045R,L\u2046 N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`,\n * `M \u2243\u2097\u2045R,L\u2046 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\u2081 w\u2082\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  : \u2200 (x y z : L), \u2045x + y, z\u2046 = \u2045x, z\u2046 + \u2045y, z\u2046)\n(lie_add  : \u2200 (x y z : L), \u2045x, y + z\u2046 = \u2045x, y\u2046 + \u2045x, z\u2046)\n(lie_self : \u2200 (x : L), \u2045x, x\u2046 = 0)\n(leibniz_lie : \u2200 (x y z : L), \u2045x, \u2045y, z\u2046\u2046 = \u2045\u2045x, y\u2046, z\u2046 + \u2045y, \u2045x, z\u2046\u2046)\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 : \u2200 (t : R) (x y : L), \u2045x, t \u2022 y\u2046 = t \u2022 \u2045x, y\u2046)\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     : \u2200 (x y : L) (m : M), \u2045x + y, m\u2046 = \u2045x, m\u2046 + \u2045y, m\u2046)\n(lie_add     : \u2200 (x : L) (m n : M), \u2045x, m + n\u2046 = \u2045x, m\u2046 + \u2045x, n\u2046)\n(leibniz_lie : \u2200 (x y : L) (m : M), \u2045x, \u2045y, m\u2046\u2046 = \u2045\u2045x, y\u2046, m\u2046 + \u2045y, \u2045x, m\u2046\u2046)\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 : \u2200 (t : R) (x : L) (m : M), \u2045t \u2022 x, m\u2046 = t \u2022 \u2045x, m\u2046)\n(lie_smul : \u2200 (t : R) (x : L) (m : M), \u2045x, t \u2022 m\u2046 = t \u2022 \u2045x, m\u2046)\n\nsection basic_properties\n\nvariables {R : Type u} {L : Type v} {M : Type w} {N : Type w\u2081}\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 : \u2045x + y, m\u2046 = \u2045x, m\u2046 + \u2045y, m\u2046 := lie_ring_module.add_lie x y m\n\n@[simp] lemma lie_add : \u2045x, m + n\u2046 = \u2045x, m\u2046 + \u2045x, n\u2046 := lie_ring_module.lie_add x m n\n\n@[simp] lemma smul_lie : \u2045t \u2022 x, m\u2046 = t \u2022 \u2045x, m\u2046 := lie_module.smul_lie t x m\n\n@[simp] lemma lie_smul : \u2045x, t \u2022 m\u2046 = t \u2022 \u2045x, m\u2046 := lie_module.lie_smul t x m\n\nlemma leibniz_lie : \u2045x, \u2045y, m\u2046\u2046 = \u2045\u2045x, y\u2046, m\u2046 + \u2045y, \u2045x, m\u2046\u2046 := lie_ring_module.leibniz_lie x y m\n\n@[simp] lemma lie_zero : \u2045x, 0\u2046 = (0 : M) := (add_monoid_hom.mk' _ (lie_add x)).map_zero\n\n@[simp] lemma zero_lie : \u2045(0 : L), m\u2046 = 0 :=\n(add_monoid_hom.mk' (\u03bb (x : L), \u2045x, m\u2046) (\u03bb x y, add_lie x y m)).map_zero\n\n@[simp] lemma lie_self : \u2045x, x\u2046 = 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 : -\u2045y, x\u2046 = \u2045x, y\u2046 :=\nhave h : \u2045x + y, x\u2046 + \u2045x + y, y\u2046 = 0, { rw \u2190 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 := \u03bb t x m, by rw [\u2190lie_skew, \u2190lie_skew x m, lie_algebra.lie_smul, smul_neg],\n  lie_smul := by apply lie_algebra.lie_smul, }\n\n@[simp] lemma neg_lie : \u2045-x, m\u2046 = -\u2045x, m\u2046 :=\nby { rw [\u2190sub_eq_zero, sub_neg_eq_add, \u2190add_lie], simp, }\n\n@[simp] lemma lie_neg : \u2045x, -m\u2046 = -\u2045x, m\u2046 :=\nby { rw [\u2190sub_eq_zero, sub_neg_eq_add, \u2190lie_add], simp, }\n\n@[simp] lemma sub_lie : \u2045x - y, m\u2046 = \u2045x, m\u2046 - \u2045y, m\u2046 :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma lie_sub : \u2045x, m - n\u2046 = \u2045x, m\u2046 - \u2045x, n\u2046 :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma nsmul_lie (n : \u2115) : \u2045n \u2022 x, m\u2046 = n \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_nsmul \u27e8\u03bb (x : L), \u2045x, m\u2046, zero_lie m, \u03bb _ _, add_lie _ _ _\u27e9 _ _\n\n@[simp] lemma lie_nsmul (n : \u2115) : \u2045x, n \u2022 m\u2046 = n \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_nsmul \u27e8\u03bb (m : M), \u2045x, m\u2046, lie_zero x, \u03bb _ _, lie_add _ _ _\u27e9 _ _\n\n@[simp] lemma zsmul_lie (a : \u2124) : \u2045a \u2022 x, m\u2046 = a \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_zsmul \u27e8\u03bb (x : L), \u2045x, m\u2046, zero_lie m, \u03bb _ _, add_lie _ _ _\u27e9 _ _\n\n@[simp] lemma lie_zsmul (a : \u2124) : \u2045x, a \u2022 m\u2046 = a \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_zsmul \u27e8\u03bb (m : M), \u2045x, m\u2046, lie_zero x, \u03bb _ _, lie_add _ _ _\u27e9 _ _\n\n@[simp] lemma lie_lie : \u2045\u2045x, y\u2046, m\u2046 = \u2045x, \u2045y, m\u2046\u2046 - \u2045y, \u2045x, m\u2046\u2046 :=\nby rw [leibniz_lie, add_sub_cancel]\n\nlemma lie_jacobi : \u2045x, \u2045y, z\u2046\u2046 + \u2045y, \u2045z, x\u2046\u2046 + \u2045z, \u2045x, y\u2046\u2046 = 0 :=\nby { rw [\u2190 neg_neg \u2045x, y\u2046, lie_neg z, lie_skew y x, \u2190 lie_skew, lie_lie], abel, }\n\ninstance lie_ring.int_lie_algebra : lie_algebra \u2124 L :=\n{ lie_smul := \u03bb n x y, lie_zsmul x y n, }\n\ninstance : lie_ring_module L (M \u2192\u2097[R] N) :=\n{ bracket     := \u03bb x f,\n  { to_fun    := \u03bb m, \u2045x, f m\u2046 - f \u2045x, m\u2046,\n    map_add'  := \u03bb m n, by { simp only [lie_add, linear_map.map_add], abel, },\n    map_smul' := \u03bb t m, by simp only [smul_sub, linear_map.map_smul, lie_smul, ring_hom.id_apply] },\n  add_lie     := \u03bb 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     := \u03bb x f g, by\n    { ext n, simp only [linear_map.coe_mk, lie_add, linear_map.add_apply], abel, },\n  leibniz_lie := \u03bb 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 \u2192\u2097[R] N) (x : L) (m : M) :\n  \u2045x, f\u2046 m = \u2045x, f m\u2046 - f \u2045x, m\u2046 :=\nrfl\n\ninstance : lie_module R L (M \u2192\u2097[R] N) :=\n{ smul_lie := \u03bb 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 := \u03bb 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 \u2192\u2097[R] L' :=\n(map_lie' : \u2200 {x y : L}, to_fun \u2045x, y\u2046 = \u2045to_fun x, to_fun y\u2046)\n\nattribute [nolint doc_blame] lie_hom.to_linear_map\n\nnotation L ` \u2192\u2097\u2045`:25 R:25 `\u2046 `:0 L':0 := lie_hom R L L'\n\nnamespace lie_hom\n\nvariables {R : Type u} {L\u2081 : Type v} {L\u2082 : Type w} {L\u2083 : Type w\u2081}\nvariables [comm_ring R]\nvariables [lie_ring L\u2081] [lie_algebra R L\u2081]\nvariables [lie_ring L\u2082] [lie_algebra R L\u2082]\nvariables [lie_ring L\u2083] [lie_algebra R L\u2083]\n\ninstance : has_coe (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192\u2097[R] L\u2082) := \u27e8lie_hom.to_linear_map\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (\u03bb _, L\u2081 \u2192 L\u2082) := \u27e8\u03bb f, f.to_linear_map.to_fun\u27e9\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\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082 := h\n\ninitialize_simps_projections lie_hom (to_linear_map_to_fun \u2192 apply)\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : ((f : L\u2081 \u2192\u2097[R] L\u2082) : L\u2081 \u2192 L\u2082) = f :=\nrfl\n\n@[simp] lemma to_fun_eq_coe (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f.to_fun = \u21d1f := rfl\n\n@[simp] lemma map_smul (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (c : R) (x : L\u2081) : f (c \u2022 x) = c \u2022 f x :=\nlinear_map.map_smul (f : L\u2081 \u2192\u2097[R] L\u2082) c x\n\n@[simp] lemma map_add (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : L\u2081 \u2192\u2097[R] L\u2082) x y\n\n@[simp] lemma map_sub (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : L\u2081 \u2192\u2097[R] L\u2082) x y\n\n@[simp] lemma map_neg (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x : L\u2081) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : L\u2081 \u2192\u2097[R] L\u2082) x\n\n@[simp] lemma map_lie (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f \u2045x, y\u2046 = \u2045f x, f y\u2046 := lie_hom.map_lie' f\n\n@[simp] lemma map_zero (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f 0 = 0 := (f : L\u2081 \u2192\u2097[R] L\u2082).map_zero\n\n/-- The identity map is a morphism of Lie algebras. -/\ndef id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081 :=\n{ map_lie' := \u03bb x y, rfl,\n  .. (linear_map.id : L\u2081 \u2192\u2097[R] L\u2081) }\n\n@[simp] lemma coe_id : ((id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) : L\u2081 \u2192 L\u2081) = _root_.id := rfl\n\nlemma id_apply (x : L\u2081) : (id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) x = x := rfl\n\n/-- The constant 0 map is a Lie algebra morphism. -/\ninstance : has_zero (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e8{ map_lie' := by simp, ..(0 : L\u2081 \u2192\u2097[R] L\u2082)}\u27e9\n\n@[norm_cast, simp] lemma coe_zero : ((0 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = 0 := rfl\n\nlemma zero_apply (x : L\u2081) : (0 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) x = 0 := rfl\n\n/-- The identity map is a Lie algebra morphism. -/\ninstance : has_one (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) := \u27e8id\u27e9\n\n@[simp] lemma coe_one : ((1 : (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081)) : L\u2081 \u2192 L\u2081) = _root_.id := rfl\n\nlemma one_apply (x : L\u2081) : (1 : (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081)) x = x := rfl\n\ninstance : inhabited (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e80\u27e9\n\nlemma coe_injective : @function.injective (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192 L\u2082) coe_fn :=\nby rintro \u27e8\u27e8f, _\u27e9\u27e9 \u27e8\u27e8g, _\u27e9\u27e9 \u27e8h\u27e9; congr\n\n@[ext] lemma ext {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} (h : \u2200 x, f x = g x) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} : f = g \u2194 \u2200 x, f x = g x :=\n\u27e8by { rintro rfl x, refl }, ext\u27e9\n\nlemma congr_fun {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} (h : f = g) (x : L\u2081) : f x = g x := h \u25b8 rfl\n\n@[simp] lemma mk_coe (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h\u2081 h\u2082 h\u2083) :\n  (\u27e8\u27e8f, h\u2081, h\u2082\u27e9, h\u2083\u27e9 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : L\u2081 \u2192 L\u2082) (h\u2081 h\u2082 h\u2083) :\n  ((\u27e8\u27e8f, h\u2081, h\u2082\u27e9, h\u2083\u27e9 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = f := rfl\n\n/-- The composition of morphisms is a morphism. -/\ndef comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192\u2097\u2045R\u2046 L\u2083 :=\n{ map_lie' := \u03bb x y, by { change f (g \u2045x, y\u2046) = \u2045f (g x), f (g y)\u2046, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x : L\u2081) :\n  f.comp g x = f (g x) := rfl\n\n@[norm_cast, simp]\nlemma coe_comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) :\n  (f.comp g : L\u2081 \u2192 L\u2083) = f \u2218 g :=\nrfl\n\n@[norm_cast, simp]\nlemma coe_linear_map_comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) :\n  (f.comp g : L\u2081 \u2192\u2097[R] L\u2083) = (f : L\u2082 \u2192\u2097[R] L\u2083).comp (g : L\u2081 \u2192\u2097[R] L\u2082) :=\nrfl\n\n@[simp] lemma comp_id (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f.comp (id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) = f :=\nby { ext, refl, }\n\n@[simp] lemma id_comp (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : (id : L\u2082 \u2192\u2097\u2045R\u2046 L\u2082).comp f = f :=\nby { ext, refl, }\n\n/-- The inverse of a bijective morphism is a morphism. -/\ndef inverse (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (g : L\u2082 \u2192 L\u2081)\n  (h\u2081 : function.left_inverse g f) (h\u2082 : function.right_inverse g f) : L\u2082 \u2192\u2097\u2045R\u2046 L\u2081 :=\n{ map_lie' := \u03bb x y,\n  calc g \u2045x, y\u2046 = g \u2045f (g x), f (g y)\u2046 : by { conv_lhs { rw [\u2190h\u2082 x, \u2190h\u2082 y], }, }\n            ... = g (f \u2045g x, g y\u2046) : by rw map_lie\n            ... = \u2045g x, g y\u2046 : (h\u2081 _),\n  ..linear_map.inverse f.to_linear_map g h\u2081 h\u2082 }\n\nend lie_hom\n\nsection module_pull_back\n\nvariables {R : Type u} {L\u2081 : Type v} {L\u2082 : Type w} (M : Type w\u2081)\nvariables [comm_ring R]  [lie_ring L\u2081] [lie_algebra R L\u2081] [lie_ring L\u2082] [lie_algebra R L\u2082]\nvariables [add_comm_group M] [lie_ring_module L\u2082 M]\nvariables (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082)\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\u2081 M :=\n{ bracket     := \u03bb x m, \u2045f x, m\u2046,\n  lie_add     := \u03bb x, lie_add (f x),\n  add_lie     := \u03bb x y m, by simp only [lie_hom.map_add, add_lie],\n  leibniz_lie := \u03bb 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\u2081) (m : M) :\n  by haveI := lie_ring_module.comp_lie_hom M f; exact\n  \u2045x, m\u2046 = \u2045f x, m\u2046 :=\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\u2082 M] :\n  @lie_module R L\u2081 M _ _ _ _ _ (lie_ring_module.comp_lie_hom M f) :=\n{ smul_lie := \u03bb t x m, by simp only [smul_lie, lie_hom.map_smul],\n  lie_smul := \u03bb 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 \u2192\u2097\u2045R\u2046 L' :=\n(inv_fun   : L' \u2192 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 ` \u2243\u2097\u2045`:50 R `\u2046 ` L' := lie_equiv R L L'\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L\u2081 : Type v} {L\u2082 : Type w} {L\u2083 : Type w\u2081}\nvariables [comm_ring R] [lie_ring L\u2081] [lie_ring L\u2082] [lie_ring L\u2083]\nvariables [lie_algebra R L\u2081] [lie_algebra R L\u2082] [lie_algebra R L\u2083]\n\n/-- Consider an equivalence of Lie algebras as a linear equivalence. -/\ndef to_linear_equiv (f : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2243\u2097[R] L\u2082 := { ..f.to_lie_hom, ..f }\n\ninstance has_coe_to_lie_hom : has_coe (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e8to_lie_hom\u27e9\ninstance has_coe_to_linear_equiv : has_coe (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2243\u2097[R] L\u2082) := \u27e8to_linear_equiv\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (\u03bb _, L\u2081 \u2192 L\u2082) := \u27e8\u03bb e, e.to_lie_hom.to_fun\u27e9\n\n@[simp, norm_cast] lemma coe_to_lie_hom (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = e :=\nrfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) :\n  ((e : L\u2081 \u2243\u2097[R] L\u2082) : L\u2081 \u2192 L\u2082) = e := rfl\n\n@[simp] lemma to_linear_equiv_mk (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (g h\u2081 h\u2082) :\n  (mk f g h\u2081 h\u2082 : L\u2081 \u2243\u2097[R] L\u2082) = { inv_fun := g, left_inv := h\u2081, right_inv := h\u2082, .. f } := rfl\n\nlemma coe_linear_equiv_injective : injective (coe : (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) \u2192 (L\u2081 \u2243\u2097[R] L\u2082)) :=\nbegin\n  intros f\u2081 f\u2082 h, cases f\u2081, cases f\u2082, 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\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192 L\u2082) coe_fn :=\nlinear_equiv.coe_injective.comp coe_linear_equiv_injective\n\n@[ext] lemma ext {f g : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082} (h : \u2200 x, f x = g x) : f = g := coe_injective $ funext h\n\ninstance : has_one (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) :=\n\u27e8{ map_lie' := \u03bb x y, rfl,\n  ..(1 : L\u2081 \u2243\u2097[R] L\u2081)}\u27e9\n\n@[simp] lemma one_apply (x : L\u2081) : (1 : (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081)) x = x := rfl\n\ninstance : inhabited (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) := \u27e81\u27e9\n\n/-- Lie algebra equivalences are reflexive. -/\n@[refl]\ndef refl : L\u2081 \u2243\u2097\u2045R\u2046 L\u2081 := 1\n\n@[simp] lemma refl_apply (x : L\u2081) : (refl : L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) x = x := rfl\n\n/-- Lie algebra equivalences are symmetric. -/\n@[symm]\ndef symm (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : L\u2082 \u2243\u2097\u2045R\u2046 L\u2081 :=\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\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.symm.symm = e :=\nby { ext, refl }\n\n@[simp] lemma apply_symm_apply (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : \u2200 x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : \u2200 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\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) : L\u2081 \u2243\u2097\u2045R\u2046 L\u2083 :=\n{ ..lie_hom.comp e\u2082.to_lie_hom e\u2081.to_lie_hom,\n  ..linear_equiv.trans e\u2081.to_linear_equiv e\u2082.to_linear_equiv }\n\n@[simp] lemma self_trans_symm (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.trans e.symm = refl :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.symm.trans e = refl :=\ne.symm.self_trans_symm\n\n@[simp] lemma trans_apply (e\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) (x : L\u2081) :\n  (e\u2081.trans e\u2082) x = e\u2082 (e\u2081 x) := rfl\n\n@[simp] lemma symm_trans (e\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) :\n  (e\u2081.trans e\u2082).symm = e\u2082.symm.trans e\u2081.symm := rfl\n\nprotected lemma bijective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.bijective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\ne.to_linear_equiv.bijective\n\nprotected lemma injective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.injective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\ne.to_linear_equiv.injective\n\nprotected lemma surjective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.surjective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\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\u2081 \u2192\u2097\u2045R\u2046 L\u2082)\n  (h : function.bijective f) : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082 :=\n{ to_fun   := f,\n  map_lie' := f.map_lie,\n  .. (linear_equiv.of_bijective (f : L\u2081 \u2192\u2097[R] L\u2082) h), }\n\nend lie_equiv\n\nsection lie_module_morphisms\n\nvariables (R : Type u) (L : Type v) (M : Type w) (N : Type w\u2081) (P : Type w\u2082)\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 \u2192\u2097[R] N :=\n(map_lie' : \u2200 {x : L} {m : M}, to_fun \u2045x, m\u2046 = \u2045x, to_fun m\u2046)\n\nattribute [nolint doc_blame] lie_module_hom.to_linear_map\n\nnotation M ` \u2192\u2097\u2045`:25 R,L:25 `\u2046 `: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 \u2192\u2097\u2045R,L\u2046 N) (M \u2192\u2097[R] N) := \u27e8lie_module_hom.to_linear_map\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M \u2192\u2097\u2045R,L\u2046 N) (\u03bb _, M \u2192 N) := \u27e8\u03bb f, f.to_linear_map.to_fun\u27e9\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : M \u2192\u2097\u2045R,L\u2046 N) : ((f : M \u2192\u2097[R] N) : M \u2192 N) = f :=\nrfl\n\n@[simp] lemma map_smul (f : M \u2192\u2097\u2045R,L\u2046 N) (c : R) (x : M) : f (c \u2022 x) = c \u2022 f x :=\nlinear_map.map_smul (f : M \u2192\u2097[R] N) c x\n\n@[simp] lemma map_add (f : M \u2192\u2097\u2045R,L\u2046 N) (x y : M) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : M \u2192\u2097[R] N) x y\n\n@[simp] lemma map_sub (f : M \u2192\u2097\u2045R,L\u2046 N) (x y : M) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : M \u2192\u2097[R] N) x y\n\n@[simp] lemma map_neg (f : M \u2192\u2097\u2045R,L\u2046 N) (x : M) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : M \u2192\u2097[R] N) x\n\n@[simp] lemma map_lie (f : M \u2192\u2097\u2045R,L\u2046 N) (x : L) (m : M) : f \u2045x, m\u2046 = \u2045x, f m\u2046 :=\nlie_module_hom.map_lie' f\n\nlemma map_lie\u2082 (f : M \u2192\u2097\u2045R,L\u2046 N \u2192\u2097[R] P) (x : L) (m : M) (n : N) :\n  \u2045x, f m n\u2046 = f \u2045x, m\u2046 n + f m \u2045x, n\u2046 :=\nby simp only [sub_add_cancel, map_lie, lie_hom.lie_apply]\n\n@[simp] lemma map_zero (f : M \u2192\u2097\u2045R,L\u2046 N) : f 0 = 0 :=\nlinear_map.map_zero (f : M \u2192\u2097[R] N)\n\n/-- The identity map is a morphism of Lie modules. -/\ndef id : M \u2192\u2097\u2045R,L\u2046 M :=\n{ map_lie' := \u03bb x m, rfl,\n  .. (linear_map.id : M \u2192\u2097[R] M) }\n\n@[simp] lemma coe_id : ((id : M \u2192\u2097\u2045R,L\u2046 M) : M \u2192 M) = _root_.id := rfl\n\nlemma id_apply (x : M) : (id : M \u2192\u2097\u2045R,L\u2046 M) x = x := rfl\n\n/-- The constant 0 map is a Lie module morphism. -/\ninstance : has_zero (M \u2192\u2097\u2045R,L\u2046 N) := \u27e8{ map_lie' := by simp, ..(0 : M \u2192\u2097[R] N) }\u27e9\n\n@[norm_cast, simp] lemma coe_zero : ((0 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = 0 := rfl\n\nlemma zero_apply (m : M) : (0 : M \u2192\u2097\u2045R,L\u2046 N) m = 0 := rfl\n\n/-- The identity map is a Lie module morphism. -/\ninstance : has_one (M \u2192\u2097\u2045R,L\u2046 M) := \u27e8id\u27e9\n\ninstance : inhabited (M \u2192\u2097\u2045R,L\u2046 N) := \u27e80\u27e9\n\nlemma coe_injective : @function.injective (M \u2192\u2097\u2045R,L\u2046 N) (M \u2192 N) coe_fn :=\nby { rintros \u27e8\u27e8f, _\u27e9\u27e9 \u27e8\u27e8g, _\u27e9\u27e9 \u27e8h\u27e9, congr, }\n\n@[ext] lemma ext {f g : M \u2192\u2097\u2045R,L\u2046 N} (h : \u2200 m, f m = g m) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : M \u2192\u2097\u2045R,L\u2046 N} : f = g \u2194 \u2200 m, f m = g m :=\n\u27e8by { rintro rfl m, refl, }, ext\u27e9\n\nlemma congr_fun {f g : M \u2192\u2097\u2045R,L\u2046 N} (h : f = g) (x : M) : f x = g x := h \u25b8 rfl\n\n@[simp] lemma mk_coe (f : M \u2192\u2097\u2045R,L\u2046 N) (h) :\n  (\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : M \u2192\u2097[R] N) (h) :\n  ((\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = f :=\nby { ext, refl, }\n\n@[norm_cast, simp] lemma coe_linear_mk (f : M \u2192\u2097[R] N) (h) :\n  ((\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192\u2097[R] N) = f :=\nby { ext, refl, }\n\n/-- The composition of Lie module morphisms is a morphism. -/\ndef comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192\u2097\u2045R,L\u2046 P :=\n{ map_lie' := \u03bb x m, by { change f (g \u2045x, m\u2046) = \u2045x, f (g m)\u2046, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) :\n  f.comp g m = f (g m) := rfl\n\n@[norm_cast, simp] lemma coe_comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) :\n  (f.comp g : M \u2192 P) = f \u2218 g :=\nrfl\n\n@[norm_cast, simp] lemma coe_linear_map_comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) :\n  (f.comp g : M \u2192\u2097[R] P) = (f : N \u2192\u2097[R] P).comp (g : M \u2192\u2097[R] N) :=\nrfl\n\n/-- The inverse of a bijective morphism of Lie modules is a morphism of Lie modules. -/\ndef inverse (f : M \u2192\u2097\u2045R,L\u2046 N) (g : N \u2192 M)\n  (h\u2081 : function.left_inverse g f) (h\u2082 : function.right_inverse g f) : N \u2192\u2097\u2045R,L\u2046 M :=\n{ map_lie' := \u03bb x n,\n    calc g \u2045x, n\u2046 = g \u2045x, f (g n)\u2046 : by rw h\u2082\n              ... = g (f \u2045x, g n\u2046) : by rw map_lie\n              ... = \u2045x, g n\u2046 : (h\u2081 _),\n  ..linear_map.inverse f.to_linear_map g h\u2081 h\u2082 }\n\ninstance : has_add (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ add := \u03bb f g, { map_lie' := by simp, ..((f : M \u2192\u2097[R] N) + (g : M \u2192\u2097[R] N)) }, }\n\ninstance : has_sub (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ sub := \u03bb f g, { map_lie' := by simp, ..((f : M \u2192\u2097[R] N) - (g : M \u2192\u2097[R] N)) }, }\n\ninstance : has_neg (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ neg := \u03bb f, { map_lie' := by simp, ..(-(f : (M \u2192\u2097[R] N))) }, }\n\n@[norm_cast, simp] lemma coe_add (f g : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(f + g) = f + g := rfl\n\nlemma add_apply (f g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (f + g) m = f m + g m := rfl\n\n@[norm_cast, simp] lemma coe_sub (f g : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(f - g) = f - g := rfl\n\nlemma sub_apply (f g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (f - g) m = f m - g m := rfl\n\n@[norm_cast, simp] lemma coe_neg (f : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(-f) = -f := rfl\n\nlemma neg_apply (f : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (-f) m = -(f m) := rfl\n\ninstance has_nsmul : has_smul \u2115 (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ smul := \u03bb n f, { map_lie' := \u03bb x m, by simp, ..(n \u2022 (f : M \u2192\u2097[R] N)) } }\n\n@[norm_cast, simp] lemma coe_nsmul (n : \u2115) (f : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(n \u2022 f) = n \u2022 f := rfl\n\nlemma nsmul_apply (n : \u2115) (f : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (n \u2022 f) m = n \u2022 f m := rfl\n\ninstance has_zsmul : has_smul \u2124 (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ smul := \u03bb z f, { map_lie' := \u03bb x m, by simp, ..(z \u2022 (f : M \u2192\u2097[R] N)) } }\n\n@[norm_cast, simp] lemma coe_zsmul (z : \u2124) (f : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(z \u2022 f) = z \u2022 f := rfl\n\nlemma zsmul_apply (z : \u2124) (f : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (z \u2022 f) m = z \u2022 f m := rfl\n\ninstance : add_comm_group (M \u2192\u2097\u2045R,L\u2046 N) :=\ncoe_injective.add_comm_group _\n  coe_zero coe_add coe_neg coe_sub (\u03bb _ _, coe_nsmul _ _) (\u03bb _ _, coe_zsmul _ _)\n\ninstance : has_smul R (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ smul := \u03bb t f, { map_lie' := by simp, ..(t \u2022 (f : M \u2192\u2097[R] N)) }, }\n\n@[norm_cast, simp] lemma coe_smul (t : R) (f : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(t \u2022 f) = t \u2022 f := rfl\n\nlemma smul_apply (t : R) (f : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (t \u2022 f) m = t \u2022 (f m) := rfl\n\ninstance : module R (M \u2192\u2097\u2045R,L\u2046 N) :=\nfunction.injective.module R \u27e8\u03bb f, f.to_linear_map.to_fun, rfl, coe_add\u27e9 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 \u2192\u2097\u2045R,L\u2046 N :=\n(inv_fun   : N \u2192 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 ` \u2243\u2097\u2045`:25 R,L:25 `\u2046 `: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 \u2243\u2097\u2045R,L\u2046 N) : M \u2243\u2097[R] N := { ..e }\n\n/-- View an equivalence of Lie modules as a type level equivalence. -/\n@[ancestor]\ndef to_equiv (e : M \u2243\u2097\u2045R,L\u2046 N) : M \u2243 N := { ..e }\n\ninstance has_coe_to_equiv : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2243 N) := \u27e8to_equiv\u27e9\ninstance has_coe_to_lie_module_hom : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2192\u2097\u2045R,L\u2046 N) := \u27e8to_lie_module_hom\u27e9\ninstance has_coe_to_linear_equiv : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2243\u2097[R] N) := \u27e8to_linear_equiv\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M \u2243\u2097\u2045R,L\u2046 N) (\u03bb _, M \u2192 N) := \u27e8\u03bb e, e.to_lie_module_hom.to_fun\u27e9\n\nlemma injective (e : M \u2243\u2097\u2045R,L\u2046 N) : function.injective e := e.to_equiv.injective\n\n@[simp] lemma coe_mk (f : M \u2192\u2097\u2045R,L\u2046 N) (inv_fun h\u2081 h\u2082) :\n  ((\u27e8f, inv_fun, h\u2081, h\u2082\u27e9 : M \u2243\u2097\u2045R,L\u2046 N) : M \u2192 N) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_lie_module_hom (e : M \u2243\u2097\u2045R,L\u2046 N) :\n  ((e : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = e := rfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : M \u2243\u2097\u2045R,L\u2046 N) : ((e : M \u2243\u2097[R] N) : M \u2192 N) = e :=\nrfl\n\nlemma to_equiv_injective : function.injective (to_equiv : (M \u2243\u2097\u2045R,L\u2046 N) \u2192 M \u2243 N) :=\n\u03bb e\u2081 e\u2082 h, begin\n  rcases e\u2081 with \u27e8\u27e8\u27e9\u27e9, rcases e\u2082 with \u27e8\u27e8\u27e9\u27e9,\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\u2081 e\u2082 : M \u2243\u2097\u2045R,L\u2046 N) (h : \u2200 m, e\u2081 m = e\u2082 m) : e\u2081 = e\u2082 :=\nto_equiv_injective (equiv.ext h)\n\ninstance : has_one (M \u2243\u2097\u2045R,L\u2046 M) := \u27e8{ map_lie' := \u03bb x m, rfl, ..(1 : M \u2243\u2097[R] M) }\u27e9\n\n@[simp] lemma one_apply (m : M) : (1 : (M \u2243\u2097\u2045R,L\u2046 M)) m = m := rfl\n\ninstance : inhabited (M \u2243\u2097\u2045R,L\u2046 M) := \u27e81\u27e9\n\n/-- Lie module equivalences are reflexive. -/\n@[refl] def refl : M \u2243\u2097\u2045R,L\u2046 M := 1\n\n@[simp] lemma refl_apply (m : M) : (refl : M \u2243\u2097\u2045R,L\u2046 M) m = m := rfl\n\n/-- Lie module equivalences are syemmtric. -/\n@[symm] def symm (e : M \u2243\u2097\u2045R,L\u2046 N) : N \u2243\u2097\u2045R,L\u2046 M :=\n{ ..lie_module_hom.inverse e.to_lie_module_hom e.inv_fun e.left_inv e.right_inv,\n  ..(e : M \u2243\u2097[R] N).symm }\n\n@[simp] lemma apply_symm_apply (e : M \u2243\u2097\u2045R,L\u2046 N) : \u2200 x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : M \u2243\u2097\u2045R,L\u2046 N) : \u2200 x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n@[simp] lemma symm_symm (e : M \u2243\u2097\u2045R,L\u2046 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\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) : M \u2243\u2097\u2045R,L\u2046 P :=\n{ ..lie_module_hom.comp e\u2082.to_lie_module_hom e\u2081.to_lie_module_hom,\n  ..linear_equiv.trans e\u2081.to_linear_equiv e\u2082.to_linear_equiv }\n\n@[simp] lemma trans_apply (e\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) (m : M) :\n  (e\u2081.trans e\u2082) m = e\u2082 (e\u2081 m) := rfl\n\n@[simp] lemma symm_trans (e\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) :\n  (e\u2081.trans e\u2082).symm = e\u2082.symm.trans e\u2081.symm := rfl\n\n@[simp] lemma self_trans_symm (e : M \u2243\u2097\u2045R,L\u2046 N) : e.trans e.symm = refl :=\next _ _ e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : M \u2243\u2097\u2045R,L\u2046 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 `\u2210 V i j \u21c9 \u2210 U i`, so that the general colimit API\n    can be used.\n* `category_theory.glue_data.\u03b9`: The immersion `\u03b9 i : U i \u27f6 glued` for each `i : J`.\n\n## Main results\n\n* `algebraic_geometry.PresheafedSpace.glue_data.\u03b9_is_open_immersion`: The map `\u03b9 i : U i \u27f6 glued`\n  is an open immersion for each `i : J`.\n* `algebraic_geometry.PresheafedSpace.glue_data.\u03b9_jointly_surjective` : The underlying maps of\n  `\u03b9 i : U i \u27f6 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 `\u03b9 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 `\u0393(\ud835\udcaa_{U_i}, U) \u27f6 \u0393(\ud835\udcaa_X, \u03b9 i '' U)` for each `U \u2286 U i`.\nSince `\u0393(\ud835\udcaa_X, \u03b9 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`\u03b9_inv_app_\u03c0_app : \u0393(\ud835\udcaa_{U_i}, U) \u27f6 \u0393(\ud835\udcaa_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 `\u0393(\ud835\udcaa_{U_i}, U) \u27f6 \u0393(\ud835\udcaa_{U_j}, _)` is given by the composition\nof the red arrows, and the map `\u0393(\ud835\udcaa_{U_i}, U) \u27f6 \u0393(\ud835\udcaa_{V_{jk}}, _)` is given by the composition of the\nblue arrows. To lift this into a map from `\u0393(\ud835\udcaa_X, \u03b9 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 \u00d7 J \u2192 PresheafedSpace C` rather than `J \u2192 J \u2192 PresheafedSpace C` to\n  connect to the limits library easier.)\n4. An open immersion `f i j : V i j \u27f6 U i` for each `i j : \u03b9`.\n5. A transition map `t i j : V i j \u27f6 V j i` for each `i j : \u03b9`.\nsuch that\n6. `f i i` is an isomorphism.\n7. `t i i` is the identity.\n8. `V i j \u00d7[U i] V i k \u27f6 V i j \u27f6 V j i` factors through `V j k \u00d7[U j] V j i \u27f6 V j i` via some\n    `t' : V i j \u00d7[U i] V i k \u27f6 V j k \u00d7[U j] V j i`.\n9. `t' i j k \u226b t' j k i \u226b t' k i j = \ud835\udfd9 _`.\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 : \u2200 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: \u00abexpr\ud835\udda3\u00bb\nlocal notation \"\ud835\udda3\" => D.toGlueData\n\n-- mathport name: \u00abexpr\u03c0\u2081 , , \u00bb\nlocal notation \"\u03c0\u2081 \" i \", \" j \", \" k => @pullback.fst _ _ _ _ _ (D.f i j) (D.f i k) _\n\n-- mathport name: \u00abexpr\u03c0\u2082 , , \u00bb\nlocal notation \"\u03c0\u2082 \" i \", \" j \", \" k => @pullback.snd _ _ _ _ _ (D.f i j) (D.f i k) _\n\n-- mathport name: \u00abexpr\u03c0\u2081\u207b\u00b9 , , \u00bb\nlocal notation \"\u03c0\u2081\u207b\u00b9 \" i \", \" j \", \" k =>\n  (PresheafedSpace.IsOpenImmersion.pullbackFstOfRight (D.f i j) (D.f i k)).invApp\n\n-- mathport name: \u00abexpr\u03c0\u2082\u207b\u00b9 , , \u00bb\nlocal notation \"\u03c0\u2082\u207b\u00b9 \" 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 := \ud835\udda3.mapGlueData (forget C) }\n#align algebraic_geometry.PresheafedSpace.glue_data.to_Top_glue_data AlgebraicGeometry.PresheafedSpace.GlueData.toTopGlueData\n\ntheorem \u03b9_openEmbedding [HasLimits C] (i : D.J) : OpenEmbedding (\ud835\udda3.\u03b9 i).base :=\n  by\n  rw [\u2190 show _ = (\ud835\udda3.\u03b9 i).base from \ud835\udda3.\u03b9_gluedIso_inv (PresheafedSpace.forget _) _]\n  exact\n    OpenEmbedding.comp\n      (TopCat.homeoOfIso (\ud835\udda3.gluedIso (PresheafedSpace.forget _)).symm).OpenEmbedding\n      (D.to_Top_glue_data.\u03b9_open_embedding i)\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03b9_open_embedding AlgebraicGeometry.PresheafedSpace.GlueData.\u03b9_openEmbedding\n\ntheorem pullback_base (i j k : D.J) (S : Set (D.V (i, j)).carrier) :\n    (\u03c0\u2082 i, j, k) '' ((\u03c0\u2081 i, j, k) \u207b\u00b9' S) = D.f i k \u207b\u00b9' (D.f i j '' S) :=\n  by\n  have eq\u2081 : _ = (\u03c0\u2081 i, j, k).base := preserves_pullback.iso_hom_fst (forget C) _ _\n  have eq\u2082 : _ = (\u03c0\u2082 i, j, k).base := preserves_pullback.iso_hom_snd (forget C) _ _\n  rw [coe_to_fun_eq, coe_to_fun_eq, \u2190 eq\u2081, \u2190 eq\u2082, 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 [\u2190 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 \u226b (D.f i k).c.app _ =\n      (\u03c0\u2081 i, j, k).c.app (op U) \u226b\n        (\u03c0\u2082\u207b\u00b9 i, j, k) (unop _) \u226b\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 [\u2190 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 [(\u03c0\u2081 i, j, k).c.naturality_assoc, reassoc_of this, \u2190 functor.map_comp_assoc,\n    is_open_immersion.inv_naturality_assoc, is_open_immersion.app_inv_app_assoc, \u2190\n    (D.V (i, k)).Presheaf.map_comp, \u2190 (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    \u2203 eq,\n      (\u03c0\u2082\u207b\u00b9 i, j, k) U \u226b (D.t k i).c.app _ \u226b (D.V (k, i)).Presheaf.map (eqToHom Eq) =\n        (D.t' k i j).c.app _ \u226b (\u03c0\u2081\u207b\u00b9 k, j, i) (unop _) :=\n  by\n  constructor\n  rw [\u2190 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 [\u2190 category.assoc]\n  erw [\u2190 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 [\u2190 (\ud835\udda3.V (k, i)).Presheaf.map_comp, eq_to_hom_map (functor.op _), eq_to_hom_op,\n    eq_to_hom_trans]\n  rintro x \u27e8y, hy, eq\u27e9\n  replace eq := concrete_category.congr_arg (\ud835\udda3.t i k).base Eq\n  change ((\u03c0\u2082 i, j, k) \u226b D.t i k).base y = (D.t k i \u226b D.t i k).base x at eq\n  rw [\ud835\udda3.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) \u226b \u03c0\u2081 k, i, j).base y = _\n  congr 2\n  rw [is_iso.inv_comp_eq, \ud835\udda3.t_fac_assoc, \ud835\udda3.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    (\u03c0\u2082\u207b\u00b9 i, j, k) U \u226b (D.t k i).c.app _ =\n      (D.t' k i j).c.app _ \u226b\n        (\u03c0\u2081\u207b\u00b9 k, j, i) (unop _) \u226b\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 [\u2190 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 \u03b9_image_preimage_eq (i j : D.J) (U : Opens (D.U i).carrier) :\n    (Opens.map (\ud835\udda3.\u03b9 j).base).obj ((D.\u03b9_openEmbedding i).IsOpenMap.Functor.obj U) =\n      (D.f_open j i).openFunctor.obj\n        ((Opens.map (\ud835\udda3.t j i).base).obj ((Opens.map (\ud835\udda3.f i j).base).obj U)) :=\n  by\n  ext1\n  dsimp only [opens.map_coe, IsOpenMap.functor_obj_coe]\n  rw [\u2190 show _ = (\ud835\udda3.\u03b9 i).base from \ud835\udda3.\u03b9_gluedIso_inv (PresheafedSpace.forget _) i, \u2190\n    show _ = (\ud835\udda3.\u03b9 j).base from \ud835\udda3.\u03b9_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 [\u2190 Set.image_comp]\n  change (D.t i j \u226b D.t j i).base '' _ = _\n  rw [\ud835\udda3.t_inv]\n  \u00b7 simp\n  \u00b7 change Function.Bijective (TopCat.homeoOfIso (as_iso _))\n    exact Homeomorph.bijective _\n    infer_instance\n  \u00b7 rw [\u2190 TopCat.mono_iff_injective]\n    infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03b9_image_preimage_eq AlgebraicGeometry.PresheafedSpace.GlueData.\u03b9_image_preimage_eq\n\n/-- (Implementation). The map `\u0393(\ud835\udcaa_{U_i}, U) \u27f6 \u0393(\ud835\udcaa_{U_j}, \ud835\udda3.\u03b9 j \u207b\u00b9' (\ud835\udda3.\u03b9 i '' U))` -/\ndef opensImagePreimageMap (i j : D.J) (U : Opens (D.U i).carrier) :\n    (D.U i).Presheaf.obj (op U) \u27f6 (D.U j).Presheaf.obj _ :=\n  (D.f i j).c.app (op U) \u226b\n    (D.t j i).c.app _ \u226b\n      (D.f_open j i).invApp (unop _) \u226b\n        (\ud835\udda3.U j).Presheaf.map (eqToHom (D.\u03b9_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    \u2203 eq,\n      D.opensImagePreimageMap i j U \u226b (D.f j k).c.app _ =\n        ((\u03c0\u2081 j, i, k) \u226b D.t j i \u226b D.f i j).c.app (op U) \u226b\n          (\u03c0\u2082\u207b\u00b9 j, i, k) (unop _) \u226b (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 [\u2190 (D.V (j, k)).Presheaf.map_comp]\n  simp_rw [\u2190 category.assoc]\n  erw [\u2190 comp_c_app, \u2190 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 \u226b (D.f j k).c.app _ =\n      ((\u03c0\u2081 j, i, k) \u226b D.t j i \u226b D.f i j).c.app (op U) \u226b\n        (\u03c0\u2082\u207b\u00b9 j, i, k) (unop _) \u226b\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' : _ \u27f6 X') :\n    D.opensImagePreimageMap i j U \u226b (D.f j k).c.app _ \u226b f' =\n      ((\u03c0\u2081 j, i, k) \u226b D.t j i \u226b D.f i j).c.app (op U) \u226b\n        (\u03c0\u2082\u207b\u00b9 j, i, k) (unop _) \u226b\n          (D.V (j, k)).Presheaf.map (eqToHom (opensImagePreimageMap_app' D i j k U).some) \u226b f' :=\n  by\n  simpa only [category.assoc] using\n    congr_arg (fun g => g \u226b 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 \u2286 U\u1d62`, the sheaf component of\nthe image `\u03b9 '' U` in the glued space is the limit of this diagram. -/\nabbrev diagramOverOpen {i : D.J} (U : Opens (D.U i).carrier) : (WalkingMultispan _ _)\u1d52\u1d56 \u2964 C :=\n  componentwiseDiagram \ud835\udda3.diagram.multispan ((D.\u03b9_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\u03c0 {i : D.J} (U : Opens (D.U i).carrier) (j : D.J) :=\n  limit.\u03c0 (D.diagramOverOpen U) (op (WalkingMultispan.right j))\n#align algebraic_geometry.PresheafedSpace.glue_data.diagram_over_open_\u03c0 AlgebraicGeometry.PresheafedSpace.GlueData.diagramOverOpen\u03c0\n\n/-- (Implementation) We construct the map `\u0393(\ud835\udcaa_{U_i}, U) \u27f6 \u0393(\ud835\udcaa_V, U_V)` for each `V` in the gluing\ndiagram. We will lift these maps into `\u03b9_inv_app`. -/\ndef \u03b9InvApp\u03c0App {i : D.J} (U : Opens (D.U i).carrier) (j) :\n    (\ud835\udda3.U i).Presheaf.obj (op U) \u27f6 (D.diagramOverOpen U).obj (op j) :=\n  by\n  rcases j with (\u27e8j, k\u27e9 | j)\n  \u00b7 refine'\n      D.opens_image_preimage_map i j U \u226b (D.f j k).c.app _ \u226b (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 \u226b \ud835\udda3.\u03b9 j).base \u207b\u00b9' _ = _\n    congr 3\n    exact colimit.w \ud835\udda3.diagram.multispan (walking_multispan.hom.fst (j, k))\n  \u00b7 exact D.opens_image_preimage_map i j U\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03b9_inv_app_\u03c0_app AlgebraicGeometry.PresheafedSpace.GlueData.\u03b9InvApp\u03c0App\n\n/-- (Implementation) The natural map `\u0393(\ud835\udcaa_{U_i}, U) \u27f6 \u0393(\ud835\udcaa_X, \ud835\udda3.\u03b9 i '' U)`.\nThis forms the inverse of `(\ud835\udda3.\u03b9 i).c.app (op U)`. -/\ndef \u03b9InvApp {i : D.J} (U : Opens (D.U i).carrier) :\n    (D.U i).Presheaf.obj (op U) \u27f6 limit (D.diagramOverOpen U) :=\n  limit.lift (D.diagramOverOpen U)\n    { pt := (D.U i).Presheaf.obj (op U)\n      \u03c0 :=\n        { app := fun j => D.\u03b9InvApp\u03c0App 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 \u27f6 X := f'.unop\n            have : f' = f.op := rfl\n            clear_value f\n            subst this\n            rcases f with (_ | \u27e8j, k\u27e9 | \u27e8j, k\u27e9)\n            \u00b7 erw [category.id_comp, CategoryTheory.Functor.map_id]\n              rw [category.comp_id]\n            \u00b7 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 \u226b\n                  (D.f j k).c.app _ \u226b (D.V (j, k)).Presheaf.map (eq_to_hom _) =\n                D.opens_image_preimage_map _ _ _ \u226b\n                  ((D.f k j).c.app _ \u226b (D.t j k).c.app _) \u226b (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 [\u2190 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 \u226b (\u03c0\u2081 k, i, j) \u226b D.t k i \u226b \ud835\udda3.f i k =\n                (pullback_symmetry _ _).Hom \u226b (\u03c0\u2081 j, i, k) \u226b D.t j i \u226b D.f i j :=\n              by\n              rw [\u2190 \ud835\udda3.t_fac_assoc, \ud835\udda3.t'_comp_eq_pullbackSymmetry_assoc,\n                pullback_symmetry_hom_comp_snd_assoc, pullback.condition, \ud835\udda3.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 [\u2190 is_iso.eq_inv_comp]\n            erw [is_open_immersion.inv_inv_app]\n            simp_rw [category.assoc]\n            erw [nat_trans.naturality_assoc, \u2190 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 [\u2190 (D.V (j, k)).Presheaf.map_comp]\n            congr } }\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03b9_inv_app AlgebraicGeometry.PresheafedSpace.GlueData.\u03b9InvApp\n\n/-- `\u03b9_inv_app` is the left inverse of `D.\u03b9 i` on `U`. -/\ntheorem \u03b9InvApp_\u03c0 {i : D.J} (U : Opens (D.U i).carrier) :\n    \u2203 eq, D.\u03b9InvApp U \u226b D.diagramOverOpen\u03c0 U i = (D.U i).Presheaf.map (eqToHom Eq) :=\n  by\n  constructor\n  delta \u03b9_inv_app\n  rw [limit.lift_\u03c0]\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, \u2190 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 _), \u2190 functor.map_comp]\n  rw [set.range_iff_surjective.mpr _]\n  \u00b7 simp\n  \u00b7 rw [\u2190 TopCat.epi_iff_surjective]\n    infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03b9_inv_app_\u03c0 AlgebraicGeometry.PresheafedSpace.GlueData.\u03b9InvApp_\u03c0\n\n/-- The `eq_to_hom` given by `\u03b9_inv_app_\u03c0`. -/\nabbrev \u03b9InvApp\u03c0EqMap {i : D.J} (U : Opens (D.U i).carrier) :=\n  (D.U i).Presheaf.map (eqToIso (D.\u03b9InvApp_\u03c0 U).some).inv\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03b9_inv_app_\u03c0_eq_map AlgebraicGeometry.PresheafedSpace.GlueData.\u03b9InvApp\u03c0EqMap\n\n/-- `\u03b9_inv_app` is the right inverse of `D.\u03b9 i` on `U`. -/\ntheorem \u03c0_\u03b9InvApp_\u03c0 (i j : D.J) (U : Opens (D.U i).carrier) :\n    D.diagramOverOpen\u03c0 U i \u226b D.\u03b9InvApp\u03c0EqMap U \u226b D.\u03b9InvApp U \u226b D.diagramOverOpen\u03c0 U j =\n      D.diagramOverOpen\u03c0 U j :=\n  by\n  rw [\u2190\n    cancel_mono\n      ((componentwise_diagram \ud835\udda3.diagram.multispan _).map\n          (Quiver.Hom.op (walking_multispan.hom.snd (i, j))) \u226b\n        \ud835\udfd9 _)]\n  simp_rw [category.assoc]\n  rw [limit.w_assoc]\n  erw [limit.lift_\u03c0_assoc]\n  rw [category.comp_id, category.comp_id]\n  change _ \u226b _ \u226b (_ \u226b _) \u226b _ = _\n  rw [congr_app (D.t_id _), id_c_app]\n  simp_rw [category.assoc]\n  rw [\u2190 functor.map_comp_assoc, is_open_immersion.inv_naturality_assoc]\n  erw [is_open_immersion.app_inv_app_assoc]\n  iterate 3 rw [\u2190 functor.map_comp_assoc]\n  rw [nat_trans.naturality_assoc]\n  erw [\u2190 (D.V (i, j)).Presheaf.map_comp]\n  convert limit.w (componentwise_diagram \ud835\udda3.diagram.multispan _)\n      (Quiver.Hom.op (walking_multispan.hom.fst (i, j)))\n  \u00b7 rw [category.comp_id]\n    apply (config := { instances := false }) mono_comp\n    change mono ((_ \u226b D.f j i).c.app _)\n    rw [comp_c_app]\n    apply (config := { instances := false }) mono_comp\n    erw [D.\u03b9_image_preimage_eq i j U]\n    all_goals infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03c0_\u03b9_inv_app_\u03c0 AlgebraicGeometry.PresheafedSpace.GlueData.\u03c0_\u03b9InvApp_\u03c0\n\n/-- `\u03b9_inv_app` is the inverse of `D.\u03b9 i` on `U`. -/\ntheorem \u03c0_\u03b9InvApp_eq_id (i : D.J) (U : Opens (D.U i).carrier) :\n    D.diagramOverOpen\u03c0 U i \u226b D.\u03b9InvApp\u03c0EqMap U \u226b D.\u03b9InvApp U = \ud835\udfd9 _ :=\n  by\n  ext j\n  induction j using Opposite.rec\n  rcases j with (\u27e8j, k\u27e9 | \u27e8j\u27e9)\n  \u00b7 rw [\u2190\n      limit.w (componentwise_diagram \ud835\udda3.diagram.multispan _)\n        (Quiver.Hom.op (walking_multispan.hom.fst (j, k))),\n      \u2190 category.assoc, category.id_comp]\n    congr 1\n    simp_rw [category.assoc]\n    apply \u03c0_\u03b9_inv_app_\u03c0\n  \u00b7 simp_rw [category.assoc]\n    rw [category.id_comp]\n    apply \u03c0_\u03b9_inv_app_\u03c0\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03c0_\u03b9_inv_app_eq_id AlgebraicGeometry.PresheafedSpace.GlueData.\u03c0_\u03b9InvApp_eq_id\n\ninstance componentwise_diagram_\u03c0_isIso (i : D.J) (U : Opens (D.U i).carrier) :\n    IsIso (D.diagramOverOpen\u03c0 U i) :=\n  by\n  use D.\u03b9_inv_app_\u03c0_eq_map U \u226b D.\u03b9_inv_app U\n  constructor\n  \u00b7 apply \u03c0_\u03b9_inv_app_eq_id\n  \u00b7 rw [category.assoc, (D.\u03b9_inv_app_\u03c0 _).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_\u03c0_is_iso AlgebraicGeometry.PresheafedSpace.GlueData.componentwise_diagram_\u03c0_isIso\n\ninstance \u03b9IsOpenImmersion (i : D.J) : IsOpenImmersion (\ud835\udda3.\u03b9 i)\n    where\n  base_open := D.\u03b9_openEmbedding i\n  c_iso U := by\n    erw [\u2190 colimit_presheaf_obj_iso_componentwise_limit_hom_\u03c0]\n    infer_instance\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03b9_is_open_immersion AlgebraicGeometry.PresheafedSpace.GlueData.\u03b9IsOpenImmersion\n\n/-- The following diagram is a pullback, i.e. `V\u1d62\u2c7c` is the intersection of `U\u1d62` and `U\u2c7c` in `X`.\n\nV\u1d62\u2c7c \u27f6 U\u1d62\n |      |\n \u2193      \u2193\n U\u2c7c \u27f6 X\n-/\ndef vPullbackConeIsLimit (i j : D.J) : IsLimit (\ud835\udda3.vPullbackCone i j) :=\n  PullbackCone.isLimitAux' _ fun s => by\n    refine' \u27e8_, _, _, _\u27e9\n    \u00b7 refine' PresheafedSpace.is_open_immersion.lift (D.f i j) s.fst _\n      erw [\u2190 D.to_Top_glue_data.preimage_range j i]\n      have :\n        s.fst.base \u226b D.to_Top_glue_data.to_glue_data.\u03b9 i =\n          s.snd.base \u226b D.to_Top_glue_data.to_glue_data.\u03b9 j :=\n        by\n        rw [\u2190 \ud835\udda3.\u03b9_gluedIso_hom (PresheafedSpace.forget _) _, \u2190\n          \ud835\udda3.\u03b9_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 [\u2190 Set.image_subset_iff, \u2190 Set.image_univ, \u2190 Set.image_comp, Set.image_univ, \u2190 coe_comp,\n        this, coe_comp, \u2190 Set.image_univ, Set.image_comp]\n      exact Set.image_subset_range _ _\n    \u00b7 apply is_open_immersion.lift_fac\n    \u00b7 rw [\u2190 cancel_mono (\ud835\udda3.\u03b9 j), category.assoc, \u2190 (\ud835\udda3.vPullbackCone i j).condition]\n      conv_rhs => rw [\u2190 s.condition]\n      erw [is_open_immersion.lift_fac_assoc]\n    \u00b7 intro m e\u2081 e\u2082\n      rw [\u2190 cancel_mono (D.f i j)]\n      erw [e\u2081]\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 \u03b9_jointly_surjective (x : \ud835\udda3.glued) : \u2203 (i : D.J)(y : D.U i), (\ud835\udda3.\u03b9 i).base y = x :=\n  \ud835\udda3.\u03b9_jointly_surjective (PresheafedSpace.forget _ \u22d9 CategoryTheory.forget TopCat) x\n#align algebraic_geometry.PresheafedSpace.glue_data.\u03b9_jointly_surjective AlgebraicGeometry.PresheafedSpace.GlueData.\u03b9_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 \u00d7 J \u2192 SheafedSpace C` rather than `J \u2192 J \u2192 SheafedSpace C` to\n  connect to the limits library easier.)\n4. An open immersion `f i j : V i j \u27f6 U i` for each `i j : \u03b9`.\n5. A transition map `t i j : V i j \u27f6 V j i` for each `i j : \u03b9`.\nsuch that\n6. `f i i` is an isomorphism.\n7. `t i i` is the identity.\n8. `V i j \u00d7[U i] V i k \u27f6 V i j \u27f6 V j i` factors through `V j k \u00d7[U j] V j i \u27f6 V j i` via some\n    `t' : V i j \u00d7[U i] V i k \u27f6 V j k \u00d7[U j] V j i`.\n9. `t' i j k \u226b t' j k i \u226b t' k i j = \ud835\udfd9 _`.\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 : \u2200 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: \u00abexpr\ud835\udda3\u00bb\nlocal notation \"\ud835\udda3\" => 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 := \ud835\udda3.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    \ud835\udda3.glued.toPresheafedSpace \u2245 D.toPresheafedSpaceGlueData.toGlueData.glued :=\n  \ud835\udda3.gluedIso forgetToPresheafedSpace\n#align algebraic_geometry.SheafedSpace.glue_data.iso_PresheafedSpace AlgebraicGeometry.SheafedSpace.GlueData.isoPresheafedSpace\n\ntheorem \u03b9_isoPresheafedSpace_inv (i : D.J) :\n    D.toPresheafedSpaceGlueData.toGlueData.\u03b9 i \u226b D.isoPresheafedSpace.inv = \ud835\udda3.\u03b9 i :=\n  \ud835\udda3.\u03b9_gluedIso_inv _ _\n#align algebraic_geometry.SheafedSpace.glue_data.\u03b9_iso_PresheafedSpace_inv AlgebraicGeometry.SheafedSpace.GlueData.\u03b9_isoPresheafedSpace_inv\n\ninstance \u03b9_isOpenImmersion (i : D.J) : IsOpenImmersion (\ud835\udda3.\u03b9 i) :=\n  by\n  rw [\u2190 D.\u03b9_iso_PresheafedSpace_inv]\n  infer_instance\n#align algebraic_geometry.SheafedSpace.glue_data.\u03b9_is_open_immersion AlgebraicGeometry.SheafedSpace.GlueData.\u03b9_isOpenImmersion\n\ntheorem \u03b9_jointly_surjective (x : \ud835\udda3.glued) : \u2203 (i : D.J)(y : D.U i), (\ud835\udda3.\u03b9 i).base y = x :=\n  \ud835\udda3.\u03b9_jointly_surjective (SheafedSpace.forget _ \u22d9 CategoryTheory.forget TopCat) x\n#align algebraic_geometry.SheafedSpace.glue_data.\u03b9_jointly_surjective AlgebraicGeometry.SheafedSpace.GlueData.\u03b9_jointly_surjective\n\n/-- The following diagram is a pullback, i.e. `V\u1d62\u2c7c` is the intersection of `U\u1d62` and `U\u2c7c` in `X`.\n\nV\u1d62\u2c7c \u27f6 U\u1d62\n |      |\n \u2193      \u2193\n U\u2c7c \u27f6 X\n-/\ndef vPullbackConeIsLimit (i j : D.J) : IsLimit (\ud835\udda3.vPullbackCone i j) :=\n  \ud835\udda3.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 \u00d7 J \u2192 LocallyRingedSpace` rather than `J \u2192 J \u2192 LocallyRingedSpace` to\n  connect to the limits library easier.)\n4. An open immersion `f i j : V i j \u27f6 U i` for each `i j : \u03b9`.\n5. A transition map `t i j : V i j \u27f6 V j i` for each `i j : \u03b9`.\nsuch that\n6. `f i i` is an isomorphism.\n7. `t i i` is the identity.\n8. `V i j \u00d7[U i] V i k \u27f6 V i j \u27f6 V j i` factors through `V j k \u00d7[U j] V j i \u27f6 V j i` via some\n    `t' : V i j \u00d7[U i] V i k \u27f6 V j k \u00d7[U j] V j i`.\n9. `t' i j k \u226b t' j k i \u226b t' k i j = \ud835\udfd9 _`.\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 : \u2200 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: \u00abexpr\ud835\udda3\u00bb\nlocal notation \"\ud835\udda3\" => 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 := \ud835\udda3.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 : \ud835\udda3.glued.toSheafedSpace \u2245 D.toSheafedSpaceGlueData.toGlueData.glued :=\n  \ud835\udda3.gluedIso forgetToSheafedSpace\n#align algebraic_geometry.LocallyRingedSpace.glue_data.iso_SheafedSpace AlgebraicGeometry.LocallyRingedSpace.GlueData.isoSheafedSpace\n\ntheorem \u03b9_isoSheafedSpace_inv (i : D.J) :\n    D.toSheafedSpaceGlueData.toGlueData.\u03b9 i \u226b D.isoSheafedSpace.inv = (\ud835\udda3.\u03b9 i).1 :=\n  \ud835\udda3.\u03b9_gluedIso_inv forgetToSheafedSpace i\n#align algebraic_geometry.LocallyRingedSpace.glue_data.\u03b9_iso_SheafedSpace_inv AlgebraicGeometry.LocallyRingedSpace.GlueData.\u03b9_isoSheafedSpace_inv\n\ninstance \u03b9_isOpenImmersion (i : D.J) : IsOpenImmersion (\ud835\udda3.\u03b9 i) :=\n  by\n  delta is_open_immersion\n  rw [\u2190 D.\u03b9_iso_SheafedSpace_inv]\n  apply PresheafedSpace.is_open_immersion.comp\n#align algebraic_geometry.LocallyRingedSpace.glue_data.\u03b9_is_open_immersion AlgebraicGeometry.LocallyRingedSpace.GlueData.\u03b9_isOpenImmersion\n\ninstance (i j k : D.J) : PreservesLimit (cospan (\ud835\udda3.f i j) (\ud835\udda3.f i k)) forgetToSheafedSpace :=\n  inferInstance\n\ntheorem \u03b9_jointly_surjective (x : \ud835\udda3.glued) : \u2203 (i : D.J)(y : D.U i), (\ud835\udda3.\u03b9 i).1.base y = x :=\n  \ud835\udda3.\u03b9_jointly_surjective\n    ((LocallyRingedSpace.forgetToSheafedSpace \u22d9 SheafedSpace.forget _) \u22d9 forget TopCat) x\n#align algebraic_geometry.LocallyRingedSpace.glue_data.\u03b9_jointly_surjective AlgebraicGeometry.LocallyRingedSpace.GlueData.\u03b9_jointly_surjective\n\n/-- The following diagram is a pullback, i.e. `V\u1d62\u2c7c` is the intersection of `U\u1d62` and `U\u2c7c` in `X`.\n\nV\u1d62\u2c7c \u27f6 U\u1d62\n |      |\n \u2193      \u2193\n U\u2c7c \u27f6 X\n-/\ndef vPullbackConeIsLimit (i j : D.J) : IsLimit (\ud835\udda3.vPullbackCone i j) :=\n  \ud835\udda3.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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 `\u0393\u2080 : chain_complex C \u2115 \u2964 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, `\u0393\u2080.obj K` is a simplicial object which\nsends `\u0394 : simplex_category\u1d52\u1d56` to a certain coproduct indexed by the set\n`splitting.index_set \u0394` whose elements consists of epimorphisms `e : \u0394.unop \u27f6 \u0394'.unop`\n(with `\u0394' : simplex_category\u1d52\u1d56`); the summand attached to such an `e` is `K.X \u0394'.unop.len`.\nBy construction, `\u0393\u2080.obj K` is a split simplicial object whose splitting is `\u0393\u2080.splitting K`.\n\nWe also construct `\u0393\u2082 : karoubi (chain_complex C \u2115) \u2964 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 \u2115) (f : K \u27f6 K')\n  {\u0394'' \u0394' \u0394 : simplex_category} (i' : \u0394'' \u27f6 \u0394') [mono i'] (i : \u0394' \u27f6 \u0394) [mono i]\n\n/-- `is_\u03b4\u2080 i` is a simple condition used to check whether a monomorphism `i` in\n`simplex_category` identifies to the coface map `\u03b4 0`. -/\n@[nolint unused_arguments]\ndef is_\u03b4\u2080 {\u0394 \u0394' : simplex_category} (i : \u0394' \u27f6 \u0394) [mono i] : Prop :=\n(\u0394.len = \u0394'.len+1) \u2227 (i.to_order_hom 0 \u2260 0)\n\nnamespace is_\u03b4\u2080\n\nlemma iff {j : \u2115} {i : fin (j+2)} : is_\u03b4\u2080 (simplex_category.\u03b4 i) \u2194 i = 0 :=\nbegin\n  split,\n  { rintro \u27e8h\u2081, h\u2082\u27e9,\n    by_contradiction,\n    exact h\u2082 (fin.succ_above_ne_zero_zero h), },\n  { rintro rfl,\n    exact \u27e8rfl, fin.succ_ne_zero _\u27e9, },\nend\n\nlemma eq_\u03b4\u2080 {n : \u2115} {i : [n] \u27f6 [n+1]} [mono i] (hi : is_\u03b4\u2080 i) :\n  i = simplex_category.\u03b4 0 :=\nbegin\n  unfreezingI { obtain \u27e8j, rfl\u27e9 := simplex_category.eq_\u03b4_of_mono i, },\n  rw iff at hi,\n  rw hi,\nend\n\nend is_\u03b4\u2080\n\nnamespace \u0393\u2080\n\nnamespace obj\n\n/-- In the definition of `(\u0393\u2080.obj K).obj \u0394` as a direct sum indexed by `A : splitting.index_set \u0394`,\nthe summand `summand K \u0394 A` is `K.X A.1.len`. -/\ndef summand (\u0394 : simplex_category\u1d52\u1d56) (A : splitting.index_set \u0394) : C := K.X A.1.unop.len\n\n/-- The functor `\u0393\u2080` sends a chain complex `K` to the simplicial object which\nsends `\u0394` to the direct sum of the objects `summand K \u0394 A` for all `A : splitting.index_set \u0394` -/\ndef obj\u2082 (K : chain_complex C \u2115) (\u0394 : simplex_category\u1d52\u1d56) [has_finite_coproducts C] : C :=\n\u2210 (\u03bb (A : splitting.index_set \u0394), summand K \u0394 A)\n\nnamespace termwise\n\n/-- A monomorphism `i : \u0394' \u27f6 \u0394` induces a morphism `K.X \u0394.len \u27f6 K.X \u0394'.len` which\nis the identity if `\u0394 = \u0394'`, the differential on the complex `K` if `i = \u03b4 0`, and\nzero otherwise. -/\ndef map_mono (K : chain_complex C \u2115) {\u0394' \u0394 : simplex_category} (i : \u0394' \u27f6 \u0394) [mono i] :\n  K.X \u0394.len \u27f6 K.X \u0394'.len :=\nbegin\n  by_cases \u0394 = \u0394',\n  { exact eq_to_hom (by congr'), },\n  { by_cases is_\u03b4\u2080 i,\n    { exact K.d \u0394.len \u0394'.len, },\n    { exact 0, }, },\nend\n\nvariable (\u0394)\n\nlemma map_mono_id : map_mono K (\ud835\udfd9 \u0394) = \ud835\udfd9 _ :=\nby { unfold map_mono, simp only [eq_self_iff_true, eq_to_hom_refl, dite_eq_ite, if_true], }\n\nvariable {\u0394}\n\nlemma map_mono_\u03b4\u2080' (hi : is_\u03b4\u2080 i) : map_mono K i = K.d \u0394.len \u0394'.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_\u03b4\u2080 {n : \u2115} : map_mono K (\u03b4 (0 : fin (n+2))) = K.d (n+1) n :=\nmap_mono_\u03b4\u2080' K _ (by rw is_\u03b4\u2080.iff)\n\nlemma map_mono_eq_zero (h\u2081 : \u0394 \u2260 \u0394') (h\u2082 : \u00acis_\u03b4\u2080 i) : map_mono K i = 0 :=\nby { unfold map_mono, rw ne.def at h\u2081, split_ifs, refl, }\n\nvariables {K K'}\n\n@[simp, reassoc]\nlemma map_mono_naturality : map_mono K i \u226b f.f \u0394'.len = f.f \u0394.len \u226b 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 \u226b map_mono K i' = map_mono K (i' \u226b i) :=\nbegin\n  /- case where i : \u0394' \u27f6 \u0394 is the identity -/\n  by_cases h\u2081 : \u0394 = \u0394',\n  { unfreezingI { subst h\u2081, },\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' : \u0394'' \u27f6 \u0394' is the identity -/\n  by_cases h\u2082 : \u0394' = \u0394'',\n  { unfreezingI { subst h\u2082, },\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 \u27e8k, hk\u27e9 := nat.exists_eq_add_of_lt (len_lt_of_mono i h\u2081),\n  obtain \u27e8k', hk'\u27e9 := nat.exists_eq_add_of_lt (len_lt_of_mono i' h\u2082),\n  have eq : \u0394.len = \u0394''.len + (k+k'+2) := by linarith,\n  rw map_mono_eq_zero K (i' \u226b 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 \u226b d = 0 -/\n  by_cases h\u2083 : is_\u03b4\u2080 i,\n  { by_cases h\u2084 : is_\u03b4\u2080 i',\n    { rw [map_mono_\u03b4\u2080' K i h\u2083, map_mono_\u03b4\u2080' K i' h\u2084,\n        homological_complex.d_comp_d], },\n    { simp only [map_mono_eq_zero K i' h\u2082 h\u2084, comp_zero], }, },\n  { simp only [map_mono_eq_zero K i h\u2081 h\u2083, zero_comp], },\nend\n\nend termwise\n\nvariable [has_finite_coproducts C]\n\n/-- The simplicial morphism on the simplicial object `\u0393\u2080.obj K` induced by\na morphism `\u0394' \u2192 \u0394` in `simplex_category` is defined on each summand\nassociated to an `A : \u0393_index_set \u0394` in terms of the epi-mono factorisation\nof `\u03b8 \u226b A.e`. -/\ndef map (K : chain_complex C \u2115) {\u0394' \u0394 : simplex_category\u1d52\u1d56} (\u03b8 : \u0394 \u27f6 \u0394') :\n  obj\u2082 K \u0394 \u27f6 obj\u2082 K \u0394' :=\nsigma.desc (\u03bb A, termwise.map_mono K (image.\u03b9 (\u03b8.unop \u226b A.e)) \u226b\n  (sigma.\u03b9 (summand K \u0394') (A.pull \u03b8)))\n\n@[reassoc]\nlemma map_on_summand\u2080 {\u0394 \u0394' : simplex_category\u1d52\u1d56} (A : splitting.index_set \u0394) {\u03b8 : \u0394 \u27f6 \u0394'}\n  {\u0394'' : simplex_category} {e : \u0394'.unop \u27f6 \u0394''} {i : \u0394'' \u27f6 A.1.unop} [epi e] [mono i]\n  (fac : e \u226b i = \u03b8.unop \u226b A.e) :\n  (sigma.\u03b9 (summand K \u0394) A) \u226b map K \u03b8 =\n    termwise.map_mono K i \u226b sigma.\u03b9 (summand K \u0394') (splitting.index_set.mk e) :=\nbegin\n  simp only [map, colimit.\u03b9_desc, cofan.mk_\u03b9_app],\n  have h := simplex_category.image_eq fac,\n  unfreezingI { subst h, },\n  congr,\n  { exact simplex_category.image_\u03b9_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\u2080' {\u0394 \u0394' : simplex_category\u1d52\u1d56} (A : splitting.index_set \u0394) (\u03b8 : \u0394 \u27f6 \u0394') :\n  (sigma.\u03b9 (summand K \u0394) A) \u226b map K \u03b8 =\n    termwise.map_mono K (image.\u03b9 (\u03b8.unop \u226b A.e)) \u226b sigma.\u03b9 (summand K _) (A.pull \u03b8) :=\nmap_on_summand\u2080 K A (A.fac_pull \u03b8)\n\nend obj\n\nvariable [has_finite_coproducts C]\n\n/-- The functor `\u0393\u2080 : chain_complex C \u2115 \u2964 simplicial_object C`, on objects. -/\n@[simps]\ndef obj (K : chain_complex C \u2115) : simplicial_object C :=\n{ obj := \u03bb \u0394, obj.obj\u2082 K \u0394,\n  map := \u03bb \u0394 \u0394' \u03b8, obj.map K \u03b8,\n  map_id' := \u03bb \u0394, begin\n    ext A,\n    cases A,\n    have fac : A.e \u226b \ud835\udfd9 A.1.unop = (\ud835\udfd9 \u0394).unop \u226b A.e := by rw [unop_id, comp_id, id_comp],\n    erw [obj.map_on_summand\u2080 K A fac, obj.termwise.map_mono_id, id_comp, comp_id],\n    unfreezingI { rcases A with \u27e8\u0394', \u27e8e, he\u27e9\u27e9, },\n    refl,\n  end,\n  map_comp' := \u03bb \u0394'' \u0394' \u0394 \u03b8' \u03b8, begin\n    ext A,\n    cases A,\n    have fac : \u03b8.unop \u226b \u03b8'.unop \u226b A.e = (\u03b8' \u226b \u03b8).unop \u226b A.e := by rw [unop_comp, assoc],\n    rw [\u2190 image.fac (\u03b8'.unop \u226b A.e), \u2190 assoc,\n      \u2190 image.fac (\u03b8.unop \u226b factor_thru_image (\u03b8'.unop \u226b A.e)), assoc] at fac,\n    simpa only [obj.map_on_summand\u2080'_assoc K A \u03b8', obj.map_on_summand\u2080' K _ \u03b8,\n      obj.termwise.map_mono_comp_assoc, obj.map_on_summand\u2080 K A fac],\n  end }\n\nlemma splitting_map_eq_id (\u0394 : simplex_category\u1d52\u1d56) :\n  (simplicial_object.splitting.map (\u0393\u2080.obj K)\n    (\u03bb (n : \u2115), sigma.\u03b9 (\u0393\u2080.obj.summand K (op [n])) (splitting.index_set.id (op [n]))) \u0394)\n    = \ud835\udfd9 _ :=\nbegin\n  ext A,\n  discrete_cases,\n  induction \u0394 using opposite.rec,\n  induction \u0394 with n,\n  dsimp,\n  simp only [colimit.\u03b9_desc, cofan.mk_\u03b9_app, comp_id, \u0393\u2080.obj_map],\n  rw [\u0393\u2080.obj.map_on_summand\u2080 K\n    (simplicial_object.splitting.index_set.id A.1) (show A.e \u226b \ud835\udfd9 _ = A.e.op.unop \u226b \ud835\udfd9 _, by refl),\n    \u0393\u2080.obj.termwise.map_mono_id, A.ext'],\n  apply id_comp,\nend\n\n/-- By construction, the simplicial `\u0393\u2080.obj K` is equipped with a splitting. -/\ndef splitting (K : chain_complex C \u2115) : simplicial_object.splitting (\u0393\u2080.obj K) :=\n{ N := \u03bb n, K.X n,\n  \u03b9 := \u03bb n, sigma.\u03b9 (\u0393\u2080.obj.summand K (op [n])) (splitting.index_set.id (op [n])),\n  map_is_iso' := \u03bb \u0394, begin\n    rw \u0393\u2080.splitting_map_eq_id,\n    apply is_iso.id,\n  end, }\n\n@[simp]\nlemma splitting_iso_hom_eq_id (\u0394 : simplex_category\u1d52\u1d56) : ((splitting K).iso \u0394).hom = \ud835\udfd9 _ :=\nsplitting_map_eq_id K \u0394\n\n@[reassoc]\nlemma obj.map_on_summand {\u0394 \u0394' : simplex_category\u1d52\u1d56} (A : splitting.index_set \u0394) (\u03b8 : \u0394 \u27f6 \u0394')\n  {\u0394'' : simplex_category}\n  {e : \u0394'.unop \u27f6 \u0394''} {i : \u0394'' \u27f6 A.1.unop} [epi e] [mono i]\n  (fac : e \u226b i = \u03b8.unop \u226b A.e) : (\u0393\u2080.splitting K).\u03b9_summand A \u226b (\u0393\u2080.obj K).map \u03b8 =\n  \u0393\u2080.obj.termwise.map_mono K i \u226b (\u0393\u2080.splitting K).\u03b9_summand (splitting.index_set.mk e) :=\nbegin\n  dsimp only [simplicial_object.splitting.\u03b9_summand,\n    simplicial_object.splitting.\u03b9_coprod],\n  simp only [assoc, \u0393\u2080.splitting_iso_hom_eq_id, id_comp, comp_id],\n  exact \u0393\u2080.obj.map_on_summand\u2080 K A fac,\nend\n\n@[reassoc]\nlemma obj.map_on_summand' {\u0394 \u0394' : simplex_category\u1d52\u1d56} (A : splitting.index_set \u0394) (\u03b8 : \u0394 \u27f6 \u0394') :\n  (splitting K).\u03b9_summand A \u226b (obj K).map \u03b8 =\n    obj.termwise.map_mono K (image.\u03b9 (\u03b8.unop \u226b A.e)) \u226b (splitting K).\u03b9_summand (A.pull \u03b8) :=\nby { apply obj.map_on_summand, apply image.fac, }\n\n@[reassoc]\nlemma obj.map_mono_on_summand_id {\u0394 \u0394' : simplex_category} (i : \u0394' \u27f6 \u0394) [mono i] :\n  (splitting K).\u03b9_summand (splitting.index_set.id (op \u0394)) \u226b (obj K).map i.op =\n  obj.termwise.map_mono K i \u226b (splitting K).\u03b9_summand (splitting.index_set.id (op \u0394')) :=\nobj.map_on_summand K (splitting.index_set.id (op \u0394)) i.op (rfl : \ud835\udfd9 _ \u226b i = i \u226b \ud835\udfd9 _)\n\n@[reassoc]\nlemma obj.map_epi_on_summand_id {\u0394 \u0394' : simplex_category } (e : \u0394' \u27f6 \u0394) [epi e] :\n  (\u0393\u2080.splitting K).\u03b9_summand (splitting.index_set.id (op \u0394)) \u226b (\u0393\u2080.obj K).map e.op =\n    (\u0393\u2080.splitting K).\u03b9_summand (splitting.index_set.mk e) :=\nby simpa only [\u0393\u2080.obj.map_on_summand K (splitting.index_set.id (op \u0394)) e.op\n    (rfl : e \u226b \ud835\udfd9 \u0394 = e \u226b \ud835\udfd9 \u0394), \u0393\u2080.obj.termwise.map_mono_id] using id_comp _\n\n/-- The functor `\u0393\u2080 : chain_complex C \u2115 \u2964 simplicial_object C`, on morphisms. -/\n@[simps]\ndef map {K K' : chain_complex C \u2115} (f : K \u27f6 K') : obj K \u27f6 obj K' :=\n{ app := \u03bb \u0394, (\u0393\u2080.splitting K).desc \u0394 (\u03bb A, f.f A.1.unop.len \u226b (\u0393\u2080.splitting K').\u03b9_summand A),\n  naturality' := \u03bb \u0394' \u0394 \u03b8, begin\n    apply (\u0393\u2080.splitting K).hom_ext',\n    intro A,\n    simp only [(splitting K).\u03b9_desc_assoc, obj.map_on_summand'_assoc K _ \u03b8,\n      (splitting K).\u03b9_desc, assoc, obj.map_on_summand' K' _ \u03b8],\n    apply obj.termwise.map_mono_naturality_assoc,\n  end, }\n\nend \u0393\u2080\n\nvariable [has_finite_coproducts C]\n\n/-- The functor `\u0393\u2080' : chain_complex C \u2115 \u2964 simplicial_object.split C`\nthat induces `\u0393\u2080 : chain_complex C \u2115 \u2964 simplicial_object C`, which\nshall be the inverse functor of the Dold-Kan equivalence for\nabelian or pseudo-abelian categories. -/\n@[simps]\ndef \u0393\u2080' : chain_complex C \u2115 \u2964 simplicial_object.split C :=\n{ obj := \u03bb K, simplicial_object.split.mk' (\u0393\u2080.splitting K),\n  map := \u03bb K K' f,\n  { F := \u0393\u2080.map f,\n    f := f.f,\n    comm' := \u03bb n, by { dsimp, simpa only [\u2190 splitting.\u03b9_summand_id,\n      (\u0393\u2080.splitting K).\u03b9_desc], }, }, }\n\n/-- The functor `\u0393\u2080 : chain_complex C \u2115 \u2964 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 \u0393\u2080 : chain_complex C \u2115 \u2964 simplicial_object C := \u0393\u2080' \u22d9 split.forget _\n\n\n/-- The extension of `\u0393\u2080 : chain_complex C \u2115 \u2964 simplicial_object C`\non the idempotent completions. It shall be an equivalence of categories\nfor any additive category `C`. -/\n@[simps]\ndef \u0393\u2082 : karoubi (chain_complex C \u2115) \u2964 karoubi (simplicial_object C) :=\n(category_theory.idempotents.functor_extension\u2082 _ _).obj \u0393\u2080\n\nlemma higher_faces_vanish.on_\u0393\u2080_summand_id (K : chain_complex C \u2115) (n : \u2115) :\n  higher_faces_vanish (n+1) ((\u0393\u2080.splitting K).\u03b9_summand (splitting.index_set.id (op [n+1]))) :=\nbegin\n  intros j hj,\n  have eq := \u0393\u2080.obj.map_mono_on_summand_id K (simplex_category.\u03b4 j.succ),\n  rw [\u0393\u2080.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 \u03bb h, fin.succ_ne_zero j (by simpa only [is_\u03b4\u2080.iff] using h), },\n  exact eq,\nend\n\n@[simp, reassoc]\nlemma P_infty_on_\u0393\u2080_splitting_summand_eq_self\n  (K : chain_complex C \u2115) {n : \u2115} :\n  (\u0393\u2080.splitting K).\u03b9_summand (splitting.index_set.id (op [n])) \u226b (P_infty : K[\u0393\u2080.obj K] \u27f6 _).f n =\n    (\u0393\u2080.splitting K).\u03b9_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_\u0393\u2080_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 {\u03b1 : Type u} {o n m : \u2115} {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' \u03b1)` to\nprevent immediate decay to a function. -/\nunsafe instance matrix.reflect [reflected_univ.{u}] [reflected_univ.{u_1}] [reflected_univ.{u_2}]\n    [reflected _ \u03b1] [reflected _ m'] [reflected _ n'] [h : has_reflect (m' \u2192 n' \u2192 \u03b1)] :\n    has_reflect (Matrix m' n' \u03b1) := 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\u2082\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\u2083\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 {\u03b1 : Type} (p : parser \u03b1) : parser (\u03a3m n, Fin m \u2192 Fin n \u2192 \u03b1) := 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 \u03b1)) \u2115) :=-- 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    \u2190-- empty columns\n      p\n  match which with\n    | Sum.inl l => do\n      let h::tl \u2190 pure l\n      let n := h\n      let l : List (Vector \u03b1 n) \u2190\n        l fun row =>\n            if h : row = n then pure (\u27e8row, h\u27e9 : Vector \u03b1 n)\n            else interaction_monad.fail \"Rows must be of equal length\"\n      pure \u27e8l, n, fun i j => (l _ i).get? j\u27e9\n    | Sum.inr n => pure \u27e80, n, finZeroElim\u27e9\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 {\u03b1 : Type} [has_reflect \u03b1] [reflected _ \u03b1] :\n    has_reflect (\u03a3m n : \u2115, Fin m \u2192 Fin n \u2192 \u03b1) :=\n  @sigma.reflect.{0, 0} _ _ \u2115 (fun m => \u03a3n, Fin m \u2192 Fin n \u2192 \u03b1) _ _ _ fun i =>\n    @sigma.reflect.{0, 0} _ _ \u2115 _ _ _ _ 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 \u27e8m, n, entries\u27e9 := val\n  let entry_vals := pi_fin.to_pexpr (pi_fin.to_pexpr \u2218 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 : \u2115)\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 \u03b1] : Repr (Matrix (Fin m) (Fin n) \u03b1)\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' \u2192 \u03b1) (B : Fin m \u2192 n' \u2192 \u03b1) (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 \u2192 n' \u2192 \u03b1) (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 \u2192 n' \u2192 \u03b1) (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 \u03b1] [Mul \u03b1]\n\n@[simp]\ntheorem dotProduct_empty (v w : Fin 0 \u2192 \u03b1) : dotProduct v w = 0 :=\n  Finset.sum_empty\n#align matrix.dot_product_empty Matrix.dotProduct_empty\n\n@[simp]\ntheorem cons_dotProduct (x : \u03b1) (v : Fin n \u2192 \u03b1) (w : Fin n.succ \u2192 \u03b1) :\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 \u2192 \u03b1) (x : \u03b1) (w : Fin n \u2192 \u03b1) :\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 : \u03b1) (v : Fin n \u2192 \u03b1) (y : \u03b1) (w : Fin n \u2192 \u03b1) :\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 \u2192 \u03b1) : col v = vecEmpty :=\n  empty_eq _\n#align matrix.col_empty Matrix.col_empty\n\n@[simp]\ntheorem col_cons (x : \u03b1) (u : Fin m \u2192 \u03b1) : 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 \u2192 \u03b1) = fun _ => vecEmpty :=\n  by\n  ext\n  rfl\n#align matrix.row_empty Matrix.row_empty\n\n@[simp]\ntheorem row_cons (x : \u03b1) (u : Fin m \u2192 \u03b1) : 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) \u03b1) : A\u1d40 = 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' \u03b1) : A\u1d40 = 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' \u2192 \u03b1) (A : Matrix (Fin m) n' \u03b1) :\n    (of (vecCons v A))\u1d40 = of fun i => vecCons (v i) (A\u1d40 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) \u03b1) :\n    vecHead (of.symm A\u1d40) = vecHead \u2218 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) \u03b1) : vecTail (of.symm A\u1d40) = (vecTail \u2218 A)\u1d40 :=\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 \u03b1]\n\n@[simp]\ntheorem empty_mul [Fintype n'] (A : Matrix (Fin 0) n' \u03b1) (B : Matrix n' o' \u03b1) : A \u2b1d 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) \u03b1) (B : Matrix (Fin 0) o' \u03b1) : A \u2b1d 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' \u03b1) (B : Matrix n' (Fin 0) \u03b1) :\n    A \u2b1d 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' \u03b1) (B : Matrix n' o' \u03b1) (i : Fin m)\n    (j : o') : (A \u2b1d B) i.succ j = (of (vecTail (of.symm A)) \u2b1d 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' \u2192 \u03b1) (A : Fin m \u2192 n' \u2192 \u03b1) (B : Matrix n' o' \u03b1) :\n    of (vecCons v A) \u2b1d B = of (vecCons (vecMul v B) (of.symm (of A \u2b1d B))) :=\n  by\n  ext (i j)\n  refine' Fin.cases _ _ i\n  \u00b7 rfl\n  simp [mul_val_succ]\n#align matrix.cons_mul Matrix.cons_mul\n\nend Mul\n\nsection VecMul\n\nvariable [Semiring \u03b1]\n\n@[simp]\ntheorem empty_vecMul (v : Fin 0 \u2192 \u03b1) (B : Matrix (Fin 0) o' \u03b1) : 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' \u2192 \u03b1) (B : Matrix n' (Fin 0) \u03b1) : vecMul v B = ![] :=\n  empty_eq _\n#align matrix.vec_mul_empty Matrix.vecMul_empty\n\n@[simp]\ntheorem cons_vecMul (x : \u03b1) (v : Fin n \u2192 \u03b1) (B : Fin n.succ \u2192 o' \u2192 \u03b1) :\n    vecMul (vecCons x v) (of B) = x \u2022 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 \u2192 \u03b1) (w : o' \u2192 \u03b1) (B : Fin n \u2192 o' \u2192 \u03b1) :\n    vecMul v (of <| vecCons w B) = vecHead v \u2022 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 : \u03b1) (v : Fin n \u2192 \u03b1) (w : o' \u2192 \u03b1) (B : Fin n \u2192 o' \u2192 \u03b1) :\n    vecMul (vecCons x v) (of <| vecCons w B) = x \u2022 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 \u03b1]\n\n@[simp]\ntheorem empty_mulVec [Fintype n'] (A : Matrix (Fin 0) n' \u03b1) (v : n' \u2192 \u03b1) : 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) \u03b1) (v : Fin 0 \u2192 \u03b1) : 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' \u2192 \u03b1) (A : Fin m \u2192 n' \u2192 \u03b1) (w : n' \u2192 \u03b1) :\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 {\u03b1} [CommSemiring \u03b1] (A : m' \u2192 Fin n.succ \u2192 \u03b1) (x : \u03b1) (v : Fin n \u2192 \u03b1) :\n    mulVec (of A) (vecCons x v) = x \u2022 vecHead \u2218 A + mulVec (of (vecTail \u2218 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 \u03b1]\n\n@[simp]\ntheorem empty_vecMulVec (v : Fin 0 \u2192 \u03b1) (w : n' \u2192 \u03b1) : vecMulVec v w = ![] :=\n  empty_eq _\n#align matrix.empty_vec_mul_vec Matrix.empty_vecMulVec\n\n@[simp]\ntheorem vecMulVec_empty (v : m' \u2192 \u03b1) (w : Fin 0 \u2192 \u03b1) : 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 : \u03b1) (v : Fin m \u2192 \u03b1) (w : n' \u2192 \u03b1) :\n    vecMulVec (vecCons x v) w = vecCons (x \u2022 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' \u2192 \u03b1) (x : \u03b1) (w : Fin n \u2192 \u03b1) :\n    vecMulVec v (vecCons x w) = fun i => v i \u2022 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 \u03b1]\n\n@[simp]\ntheorem smul_mat_empty {m' : Type _} (x : \u03b1) (A : Fin 0 \u2192 m' \u2192 \u03b1) : x \u2022 A = ![] :=\n  empty_eq _\n#align matrix.smul_mat_empty Matrix.smul_mat_empty\n\n@[simp]\ntheorem smul_mat_cons (x : \u03b1) (v : n' \u2192 \u03b1) (A : Fin m \u2192 n' \u2192 \u03b1) :\n    x \u2022 vecCons v A = vecCons (x \u2022 v) (x \u2022 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' \u03b1) (row : Fin 0 \u2192 m') (col : o' \u2192 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' \u03b1) (i : m') (row : Fin m \u2192 m') (col : o' \u2192 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 \u03b1] [One \u03b1]\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem one_fin_two :\n    (1 : Matrix (Fin 2) (Fin 2) \u03b1) =\n      \u00abexpr!![ \u00bb\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 `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem one_fin_three :\n    (1 : Matrix (Fin 3) (Fin 3) \u03b1) =\n      \u00abexpr!![ \u00bb\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 `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem eta_fin_two (A : Matrix (Fin 2) (Fin 2) \u03b1) :\n    A =\n      \u00abexpr!![ \u00bb\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 `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem eta_fin_three (A : Matrix (Fin 3) (Fin 3) \u03b1) :\n    A =\n      \u00abexpr!![ \u00bb\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 `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem mul_fin_two [AddCommMonoid \u03b1] [Mul \u03b1] (a\u2081\u2081 a\u2081\u2082 a\u2082\u2081 a\u2082\u2082 b\u2081\u2081 b\u2081\u2082 b\u2082\u2081 b\u2082\u2082 : \u03b1) :\n    \u00abexpr!![ \u00bb\n          \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" \u2b1d\n        \u00abexpr!![ \u00bb\n          \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" =\n      \u00abexpr!![ \u00bb\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 `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr!![ \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation -/\ntheorem mul_fin_three [AddCommMonoid \u03b1] [Mul \u03b1]\n    (a\u2081\u2081 a\u2081\u2082 a\u2081\u2083 a\u2082\u2081 a\u2082\u2082 a\u2082\u2083 a\u2083\u2081 a\u2083\u2082 a\u2083\u2083 b\u2081\u2081 b\u2081\u2082 b\u2081\u2083 b\u2082\u2081 b\u2082\u2082 b\u2082\u2083 b\u2083\u2081 b\u2083\u2082 b\u2083\u2083 : \u03b1) :\n    \u00abexpr!![ \u00bb\n          \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" \u2b1d\n        \u00abexpr!![ \u00bb\n          \"./././Mathport/Syntax/Translate/Expr.lean:387:14: unsupported user notation matrix.notation\" =\n      \u00abexpr!![ \u00bb\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, \u2190 add_assoc]\n#align matrix.mul_fin_three Matrix.mul_fin_three\n\ntheorem vec2_eq {a\u2080 a\u2081 b\u2080 b\u2081 : \u03b1} (h\u2080 : a\u2080 = b\u2080) (h\u2081 : a\u2081 = b\u2081) : ![a\u2080, a\u2081] = ![b\u2080, b\u2081] := by\n  subst_vars\n#align matrix.vec2_eq Matrix.vec2_eq\n\ntheorem vec3_eq {a\u2080 a\u2081 a\u2082 b\u2080 b\u2081 b\u2082 : \u03b1} (h\u2080 : a\u2080 = b\u2080) (h\u2081 : a\u2081 = b\u2081) (h\u2082 : a\u2082 = b\u2082) :\n    ![a\u2080, a\u2081, a\u2082] = ![b\u2080, b\u2081, b\u2082] := by subst_vars\n#align matrix.vec3_eq Matrix.vec3_eq\n\ntheorem vec2_add [Add \u03b1] (a\u2080 a\u2081 b\u2080 b\u2081 : \u03b1) : ![a\u2080, a\u2081] + ![b\u2080, b\u2081] = ![a\u2080 + b\u2080, a\u2081 + b\u2081] := 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 \u03b1] (a\u2080 a\u2081 a\u2082 b\u2080 b\u2081 b\u2082 : \u03b1) :\n    ![a\u2080, a\u2081, a\u2082] + ![b\u2080, b\u2081, b\u2082] = ![a\u2080 + b\u2080, a\u2081 + b\u2081, a\u2082 + b\u2082] := 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 \u03b1] (x : R) (a\u2080 a\u2081 : \u03b1) : x \u2022 ![a\u2080, a\u2081] = ![x \u2022 a\u2080, x \u2022 a\u2081] :=\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 \u03b1] (x : R) (a\u2080 a\u2081 a\u2082 : \u03b1) :\n    x \u2022 ![a\u2080, a\u2081, a\u2082] = ![x \u2022 a\u2080, x \u2022 a\u2081, x \u2022 a\u2082] := by\n  rw [smul_cons, smul_cons, smul_cons, smul_empty]\n#align matrix.smul_vec3 Matrix.smul_vec3\n\nvariable [AddCommMonoid \u03b1] [Mul \u03b1]\n\ntheorem vec2_dot_product' {a\u2080 a\u2081 b\u2080 b\u2081 : \u03b1} : ![a\u2080, a\u2081] \u2b1d\u1d65 ![b\u2080, b\u2081] = a\u2080 * b\u2080 + a\u2081 * b\u2081 := 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 \u2192 \u03b1) : v \u2b1d\u1d65 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\u2080 a\u2081 a\u2082 b\u2080 b\u2081 b\u2082 : \u03b1} :\n    ![a\u2080, a\u2081, a\u2082] \u2b1d\u1d65 ![b\u2080, b\u2081, b\u2082] = a\u2080 * b\u2080 + a\u2081 * b\u2081 + a\u2082 * b\u2082 := 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 \u2192 \u03b1) : v \u2b1d\u1d65 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 \u2192 B) (s : finset A) : finset B :=\nquot.lift_on s\n  (\u03bb l, to_finset (list.map f l.1))\n  (\u03bb l\u2081 l\u2082 p, quot.sound (perm.perm_erase_dup_of_perm (perm.perm_map _ p)))\n\n\ninfix `'` := image\n\ntheorem image_empty (f : A \u2192 B) : image f empty = empty := rfl\n\ntheorem mem_image_of_mem (f : A \u2192 B) {s : finset A} {a : A} : a \u2208 s \u2192 f a \u2208 image f s :=\nquot.induction_on s (take l, assume H : a \u2208 l.1, mem_to_finset (mem_map f H))\n\ntheorem mem_image {f : A \u2192 B} {s : finset A} {a : A} {b : B}\n    (H1 : a \u2208 s) (H2 : f a = b) :\n  b \u2208 image f s :=\neq.subst H2 (mem_image_of_mem f H1)\n\ntheorem exists_of_mem_image {f : A \u2192 B} {s : finset A} {b : B} :\n  b \u2208 image f s \u2192 \u2203a, a \u2208 s \u2227 f a = b :=\nquot.induction_on s\n  (take l, assume H : b \u2208 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 \u2192 B) {s : finset A} {y : B} : y \u2208 image f s \u2194 \u2203x, x \u2208 s \u2227 f x = y :=\niff.intro exists_of_mem_image\n  (assume H, let \u27e8x,H\u2081,H\u2082\u27e9 := H in mem_image H\u2081 H\u2082)\n\ntheorem mem_image_eq (f : A \u2192 B) {s : finset A} {y : B} : y \u2208 image f s = \u2203x, x \u2208 s \u2227 f x = y :=\npropext (mem_image_iff f)\n\ntheorem mem_image_of_mem_image_of_subset {f : A \u2192 B} {s t : finset A} {y : B}\n    (H1 : y \u2208 image f s) (H2 : s \u2286 t) : y \u2208 image f t :=\nlet \u27e8x, H3, H4\u27e9 := exists_of_mem_image H1 in\nhave H5 : x \u2208 t, from mem_of_subset_of_mem H2 H3,\nshow y \u2208 image f t, from mem_image H5 H4\n\ntheorem image_insert [h' : decidable_eq A] (f : A \u2192 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 \u2208 image f (insert a s),\n    let \u27e8x,H1l,H1r\u27e9 := exists_of_mem_image H in\n    have x = a \u2228 x \u2208 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 \u2208 insert (f a) (image f s), from eq.subst this (mem_insert _ _))\n      (suppose x \u2208 s,\n        have f x \u2208 image f s, from mem_image_of_mem f this,\n        show y \u2208 insert (f a) (image f s), from eq.subst H1r (mem_insert_of_mem _ this)))\n  (suppose y \u2208 insert (f a) (image f s),\n    have y = f a \u2228 y \u2208 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 \u2208 image f (insert a s), from mem_image_of_mem f (mem_insert _ _),\n        show y \u2208 image f (insert a s), by rw eq;exact this)\n      (suppose y \u2208 image f s,\n        show y \u2208 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 \u2192 C} {g : A \u2192 B} {s : finset A} :\n  image (f\u2218g) s = image f (image g s) :=\next (take z, iff.intro\n  (suppose z \u2208 image (f\u2218g) s,\n   let \u27e8x,Hx,Hgfx\u27e9 := exists_of_mem_image this in\n    by rewrite -Hgfx; apply mem_image_of_mem _ (mem_image_of_mem _ Hx))\n  (suppose z \u2208 image f (image g s),\n   let \u27e8y,Hy,Hfy\u27e9 := exists_of_mem_image this in\n   let \u27e8x,Hx,Hgx\u27e9 := 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 \u2192 B) (H : a \u2286 b) : image f a \u2286 image f b :=\nsubset_of_forall\n  (take y, assume Hy : y \u2208 image f a,\n    let \u27e8x,Hx\u2081,Hx\u2082\u27e9 := exists_of_mem_image Hy in\n    mem_image (mem_of_subset_of_mem H Hx\u2081) Hx\u2082)\n\ntheorem image_union [h' : decidable_eq A] (f : A \u2192 B) (s t : finset A) :\n  image f (s \u222a t) = image f s \u222a image f t :=\next (take y, iff.intro\n  (assume H : y \u2208 image f (s \u222a t),\n   let \u27e8x,xst,fxy\u27e9 := 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 \u2208 image f s \u222a image f t,\n    or.elim (mem_or_mem_of_mem_union H)\n      (assume yifs : y \u2208 image f s,\n        let \u27e8x,xs,fxy\u27e9 := exists_of_mem_image yifs in\n        mem_image (mem_union_l xs) fxy)\n      (assume yift : y \u2208 image f t,\n        let \u27e8x,xt,fxy\u27e9 := 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 \u2192 Prop) [decp : decidable_pred p] (s : finset A) {x : A}\ninclude decp\n\ndefinition sep : finset A :=\nquot.lift_on s\n  (\u03bbl, to_finset_of_nodup\n    (list.filter p l.1)\n    (list.nodup_filter p l.2))\n(\u03bb l\u2081 l\u2082 u, quot.sound (perm.perm_filter u))\n\n-- notation [priority finset.prio] `{` binder ` \u2208 ` 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 \u2208 sep p s \u2192 p x :=\nquot.induction_on s (take l, list.of_mem_filter)\n\ntheorem mem_of_mem_sep : x \u2208 sep p s \u2192 x \u2208 s :=\nquot.induction_on s (take l, list.mem_of_mem_filter)\n\ntheorem mem_sep_of_mem {x : A} : x \u2208 s \u2192 p x \u2192 x \u2208 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 \u2208 sep p s \u2194 x \u2208 s \u2227 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 \u2208 sep p s = (x \u2208 s \u2227 p x) :=\npropext (mem_sep_iff _ _)\n\nvariable t : finset A\n\ntheorem mem_sep_union_iff : x \u2208 sep p (s \u222a t) \u2194 x \u2208 sep p s \u2228 x \u2208 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 \u2286 t) : s = sep (\u03bb x, x \u2208 s) t := \next (take x, iff.intro\n  (suppose x \u2208 s, mem_sep_of_mem (mem_of_subset_of_mem ssubt this) this)\n  (suppose x \u2208 sep (\u03bb x, x \u2208 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 (\u03bb x, x \u2209 t) s\ninfix ` \\ ` := diff\n\ntheorem mem_of_mem_diff {s t : finset A} {x : A} (H : x \u2208 s \\ t) : x \u2208 s :=\nmem_of_mem_sep H\n\ntheorem not_mem_of_mem_diff {s t : finset A} {x : A} (H : x \u2208 s \\ t) : x \u2209 t :=\n@of_mem_sep _ _ _ _ _ _ H\n\ntheorem mem_diff {s t : finset A} {x : A} (H1 : x \u2208 s) (H2 : x \u2209 t) : x \u2208 s \\ t :=\nmem_sep_of_mem H1 H2\n\ntheorem mem_diff_iff (s t : finset A) (x : A) : x \u2208 s \\ t \u2194 x \u2208 s \u2227 x \u2209 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 \u2208 s \\ t = (x \u2208 s \u2227 x \u2209 t) :=\npropext (mem_diff_iff _ _ _)\n\ntheorem union_diff_cancel {s t : finset A} (H : s \u2286 t) : s \u222a (t \\ s) = t :=\next (take x, iff.intro\n  (suppose x \u2208 s \u222a (t \\ s),\n    or.elim (mem_or_mem_of_mem_union this)\n      (suppose x \u2208 s, mem_of_subset_of_mem H this)\n      (suppose x \u2208 t \\ s, mem_of_mem_diff this))\n  (assume h,\n    decidable.by_cases\n      (suppose x \u2208 s, mem_union_left _ this)\n      (suppose x \u2209 s, mem_union_right _ (mem_diff h this))))\n\ntheorem diff_union_cancel {s t : finset A} (H : s \u2286 t) : (t \\ s) \u222a s = t :=\n@eq.subst _ (\u03bb 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 {\u03b1} {a b : \u03b1} {motive : (b : \u03b1) \u2192 a = b \u2192 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 {\u03b1} {a b : \u03b1} {motive : \u03b1 \u2192 Sort _} (t : motive a) (h : a = b) : Eq.ndrec t h = cast (h \u25b8 rfl) t := by cases h; rfl\n\ntheorem eqNdrec_symm {\u03b1} {motive : \u03b1 \u2192 Sort _} {a b : \u03b1} (h : a = b) (x : motive a) (y : motive b) : Eq.ndrec x h = y \u2194 x = Eq.ndrec y h.symm := by cases h; exact Iff.rfl\n\n@[elim_casts] theorem cast_irrel {\u03b1 \u03b2} (h\u2081 h\u2082 : \u03b1 = \u03b2) (a : \u03b1) : cast h\u2081 a = cast h\u2082 a := rfl\n\n@[elim_casts] theorem cast_refl {\u03b1} (a : \u03b1) : cast rfl a = a := rfl\n\n@[elim_casts] theorem cast_trans {\u03b1 \u03b2 \u03b3} (h\u2081 : \u03b1 = \u03b2) (h\u2082 : \u03b2 = \u03b3) (a : \u03b1) : cast h\u2082 (cast h\u2081 a) = cast (Eq.trans h\u2081 h\u2082) a := by cases h\u2081; cases h\u2082; rfl\n\n@[elim_casts] theorem cast_symm {\u03b1 \u03b2} (h : \u03b1 = \u03b2) (a : \u03b1) (b : \u03b2) : cast h a = b \u2194 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\u00f6lzl, Mario Carneiro, Anne Baanen,\n  Fr\u00e9d\u00e9ric 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 \u03c3 M M\u2082`, `M \u2192\u209b\u2097[\u03c3] M\u2082` : a semilinear map between two `Module`s. Here,\n  `\u03c3` is a `RingHom` from `R` to `R\u2082` and an `f : M \u2192\u209b\u2097[\u03c3] M\u2082` satisfies\n  `f (c \u2022 x) = (\u03c3 c) \u2022 (f x)`. We recover plain linear maps by choosing `\u03c3` to be `RingHom.id R`.\n  This is denoted by `M \u2192\u2097[R] M\u2082`. We also add the notation `M \u2192\u2097\u22c6[R] M\u2082` for star-linear maps.\n\n* `IsLinearMap R f` : predicate saying that `f : M \u2192 M\u2082` 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\u2097`, `g\u2097`, 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\u2081 : Type _} {R\u2082 : Type _} {R\u2083 : Type _}\nvariable {k : Type _} {S : Type _} {S\u2083 : Type _} {T : Type _}\nvariable {M : Type _} {M\u2081 : Type _} {M\u2082 : Type _} {M\u2083 : Type _}\nvariable {N\u2081 : Type _} {N\u2082 : Type _} {N\u2083 : Type _} {\u03b9 : 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 \u2022 x) = c \u2022 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\u2082 : Type w} [Semiring R] [AddCommMonoid M]\n  [AddCommMonoid M\u2082] [Module R M] [Module R M\u2082] (f : M \u2192 M\u2082) : Prop where\n  /-- A linear map preserves addition. -/\n  map_add : \u2200 x y, f (x + y) = f x + f y\n  /-- A linear map preserves scalar multiplication. -/\n  map_smul : \u2200 (c : R) (x), f (c \u2022 x) = c \u2022 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 `\u03c3 : R \u2192+* S`\nis semilinear if it satisfies the two properties `f (x + y) = f x + f y` and\n`f (c \u2022 x) = (\u03c3 c) \u2022 f x`. Elements of `LinearMap \u03c3 M M\u2082` (available under the notation\n`M \u2192\u209b\u2097[\u03c3] M\u2082`) are bundled versions of such maps. For plain linear maps (i.e. for which\n`\u03c3 = RingHom.id R`), the notation `M \u2192\u2097[R] M\u2082` 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] (\u03c3 : R \u2192+* S) (M : Type _)\n    (M\u2082 : Type _) [AddCommMonoid M] [AddCommMonoid M\u2082] [Module R M] [Module S M\u2082] extends\n    AddHom M M\u2082 where\n  /-- A linear map preserves scalar multiplication.\n  We prefer the spelling `_root_.map_smul` instead. -/\n  map_smul' : \u2200 (r : R) (x : M), toFun (r \u2022 x) = \u03c3 r \u2022 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: \u00abexpr \u2192\u209b\u2097[ ] \u00bb\n/-- `M \u2192\u209b\u2097[\u03c3] N` is the type of `\u03c3`-semilinear maps from `M` to `N`. -/\nnotation:25 M \" \u2192\u209b\u2097[\" \u03c3:25 \"] \" M\u2082:0 => LinearMap \u03c3 M M\u2082\n\n/-- `M \u2192\u2097[R] N` is the type of `R`-linear maps from `M` to `N`. -/\n-- mathport name: \u00abexpr \u2192\u2097[ ] \u00bb\nnotation:25 M \" \u2192\u2097[\" R:25 \"] \" M\u2082:0 => LinearMap (RingHom.id R) M M\u2082\n\n/-- `M \u2192\u2097\u22c6[R] N` is the type of `R`-conjugate-linear maps from `M` to `N`. -/\n-- mathport name: \u00abexpr \u2192\u2097\u22c6[ ] \u00bb\nnotation:25 M \" \u2192\u2097\u22c6[\" R:25 \"] \" M\u2082:0 => LinearMap (starRingEnd R) M M\u2082\n\n/-- `SemilinearMapClass F \u03c3 M M\u2082` asserts `F` is a type of bundled `\u03c3`-semilinear maps `M \u2192 M\u2082`.\n\nSee also `LinearMapClass F R M M\u2082` for the case where `\u03c3` is the identity map on `R`.\n\nA map `f` between an `R`-module and an `S`-module over a ring homomorphism `\u03c3 : R \u2192+* S`\nis semilinear if it satisfies the two properties `f (x + y) = f x + f y` and\n`f (c \u2022 x) = (\u03c3 c) \u2022 f x`. -/\nclass SemilinearMapClass (F : Type _) {R S : outParam (Type _)} [Semiring R] [Semiring S]\n  (\u03c3 : outParam (R \u2192+* S)) (M M\u2082 : outParam (Type _)) [AddCommMonoid M] [AddCommMonoid M\u2082]\n  [Module R M] [Module S M\u2082] extends AddHomClass F M M\u2082 where\n  /-- A semilinear map preserves scalar multiplication up to some ring homomorphism `\u03c3`.\n  See also `_root_.map_smul` for the case where `\u03c3` is the identity. -/\n  map_smul\u209b\u2097 : \u2200 (f : F) (r : R) (x : M), f (r \u2022 x) = \u03c3 r \u2022 f x\n#align semilinear_map_class SemilinearMapClass\n\nend\n\n-- Porting note: `dangerousInstance` linter has become smarter about `outParam`s\n-- `\u03c3` becomes a metavariable but that's fine because it's an `outParam`\n-- attribute [nolint dangerousInstance] SemilinearMapClass.toAddHomClass\n\nexport SemilinearMapClass (map_smul\u209b\u2097)\n\nattribute [simp] map_smul\u209b\u2097\n\n/-- `LinearMapClass F R M M\u2082` asserts `F` is a type of bundled `R`-linear maps `M \u2192 M\u2082`.\n\nThis is an abbreviation for `semilinear_map_class F (RingHom.id R) M M\u2082`.\n-/\nabbrev LinearMapClass (F : Type _) (R M M\u2082 : outParam (Type _)) [Semiring R] [AddCommMonoid M]\n    [AddCommMonoid M\u2082] [Module R M] [Module R M\u2082] :=\n  SemilinearMapClass F (RingHom.id R) M M\u2082\n#align linear_map_class LinearMapClass\n\nnamespace SemilinearMapClass\n\nvariable (F : Type _)\nvariable {_ : Semiring R} {_ : Semiring S}\nvariable {_ : AddCommMonoid M} {_ : AddCommMonoid M\u2081} {_ : AddCommMonoid M\u2082} {_ : AddCommMonoid M\u2083}\nvariable {_ : AddCommMonoid N\u2081} {_ : AddCommMonoid N\u2082} {_ : AddCommMonoid N\u2083}\nvariable {_ : Module R M} {_ : Module R M\u2082} {_ : Module S M\u2083}\nvariable {\u03c3 : R \u2192+* S}\n\n-- Porting note: the `dangerousInstance` linter has become smarter about `outParam`s\n-- @[nolint dangerousInstance] -- `\u03c3` is an `outParam` so it's not dangerous\ninstance (priority := 100) addMonoidHomClass [SemilinearMapClass F \u03c3 M M\u2083] :\n    AddMonoidHomClass F M M\u2083 :=\n  { SemilinearMapClass.toAddHomClass with\n    coe := fun f \u21a6 (f : M \u2192 M\u2083)\n    map_zero := fun f \u21a6\n      show f 0 = 0 by\n        rw [\u2190 zero_smul R (0 : M), map_smul\u209b\u2097]\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\u2082] :\n    DistribMulActionHomClass F R M M\u2082 :=\n  { SemilinearMapClass.addMonoidHomClass F with\n    coe := fun f \u21a6 (f : M \u2192 M\u2082)\n    map_smul := fun f c x \u21a6 by rw [map_smul\u209b\u2097, RingHom.id_apply] }\n\nvariable {F} (f : F) [i : SemilinearMapClass F \u03c3 M M\u2083]\n\ntheorem map_smul_inv {\u03c3' : S \u2192+* R} [RingHomInvPair \u03c3 \u03c3'] (c : S) (x : M) :\n    c \u2022 f x = f (\u03c3' c \u2022 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\u2081] [AddCommMonoid M\u2082] [AddCommMonoid M\u2083]\n\nvariable [AddCommMonoid N\u2081] [AddCommMonoid N\u2082] [AddCommMonoid N\u2083]\n\nvariable [Module R M] [Module R M\u2082] [Module S M\u2083]\n\nvariable {\u03c3 : R \u2192+* S}\n\ninstance : SemilinearMapClass (M \u2192\u209b\u2097[\u03c3] M\u2083) \u03c3 M M\u2083 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\u209b\u2097 := 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 {\u03c3 : R \u2192+* S} : FunLike (M \u2192\u209b\u2097[\u03c3] M\u2083) M (\u03bb _ \u21a6 M\u2083) :=\n  { AddHomClass.toFunLike with }\n\n/-- The `DistribMulActionHom` underlying a `LinearMap`. -/\ndef toDistribMulActionHom (f : M \u2192\u2097[R] M\u2082) : DistribMulActionHom R M M\u2082 :=\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 \u2192\u209b\u2097[\u03c3] M\u2083) : \u21d1f.toAddHom = f := rfl\n\n-- porting note: no longer a `simp`\ntheorem toFun_eq_coe {f : M \u2192\u209b\u2097[\u03c3] M\u2083} : f.toFun = (f : M \u2192 M\u2083) := rfl\n#align linear_map.to_fun_eq_coe LinearMap.toFun_eq_coe\n\n@[ext]\ntheorem ext {f g : M \u2192\u209b\u2097[\u03c3] M\u2083} (h : \u2200 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 \u2192\u209b\u2097[\u03c3] M\u2083) (f' : M \u2192 M\u2083) (h : f' = \u21d1f) : M \u2192\u209b\u2097[\u03c3] M\u2083\n    where\n  toFun := f'\n  map_add' := h.symm \u25b8 f.map_add'\n  map_smul' := h.symm \u25b8 f.map_smul'\n#align linear_map.copy LinearMap.copy\n\n@[simp]\ntheorem coe_copy (f : M \u2192\u209b\u2097[\u03c3] M\u2083) (f' : M \u2192 M\u2083) (h : f' = \u21d1f) : \u21d1(f.copy f' h) = f' :=\n  rfl\n#align linear_map.coe_copy LinearMap.coe_copy\n\ntheorem copy_eq (f : M \u2192\u209b\u2097[\u03c3] M\u2083) (f' : M \u2192 M\u2083) (h : f' = \u21d1f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align linear_map.copy_eq LinearMap.copy_eq\n\ninitialize_simps_projections LinearMap (toFun \u2192 apply)\n\n@[simp]\ntheorem coe_mk {\u03c3 : R \u2192+* S} (f : AddHom M M\u2083) (h) :\n    ((LinearMap.mk f h : M \u2192\u209b\u2097[\u03c3] M\u2083) : M \u2192 M\u2083) = 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 {\u03c3 : R \u2192+* S} (f : AddHom M M\u2083) (h) :\n    ((LinearMap.mk f h : M \u2192\u209b\u2097[\u03c3] M\u2083) : AddHom M M\u2083) = f :=\n  rfl\n\n/-- Identity map as a `LinearMap` -/\ndef id : M \u2192\u2097[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 \u2192\u2097[R] M) : M \u2192 M) = _root_.id :=\n  rfl\n#align linear_map.id_coe LinearMap.id_coe\n\nend\n\nsection\n\nvariable [AddCommMonoid M] [AddCommMonoid M\u2081] [AddCommMonoid M\u2082] [AddCommMonoid M\u2083]\n\nvariable [AddCommMonoid N\u2081] [AddCommMonoid N\u2082] [AddCommMonoid N\u2083]\n\nvariable [Module R M] [Module R M\u2082] [Module S M\u2083]\n\nvariable (\u03c3 : R \u2192+* S)\n\nvariable (f\u2097 g\u2097 : M \u2192\u2097[R] M\u2082) (f g : M \u2192\u209b\u2097[\u03c3] M\u2083)\n\ntheorem isLinear : IsLinearMap R f\u2097 :=\n  \u27e8f\u2097.map_add', f\u2097.map_smul'\u27e9\n#align linear_map.is_linear LinearMap.isLinear\n\nvariable {f\u2097 g\u2097 f g \u03c3}\n\ntheorem coe_injective : Injective (FunLike.coe : (M \u2192\u209b\u2097[\u03c3] M\u2083) \u2192 _) :=\n  FunLike.coe_injective\n#align linear_map.coe_injective LinearMap.coe_injective\n\nprotected theorem congr_arg {x x' : M} : x = x' \u2192 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 \u2194 \u2200 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 \u2192\u209b\u2097[\u03c3] M\u2083) (h) : (LinearMap.mk f h : M \u2192\u209b\u2097[\u03c3] M\u2083) = f :=\n  ext fun _ \u21a6 rfl\n#align linear_map.mk_coe LinearMap.mk_coe\n\nvariable (f\u2097 g\u2097 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\u209b\u2097` for `LinearMap`s without specifying\n-- `map_smul\u209b\u2097 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\u209b\u2097 (c : R) (x : M) : f (c \u2022 x) = \u03c3 c \u2022 f x :=\n  map_smul\u209b\u2097 f c x\n#align linear_map.map_smul\u209b\u2097 LinearMap.map_smul\u209b\u2097\n\nprotected theorem map_smul (c : R) (x : M) : f\u2097 (c \u2022 x) = c \u2022 f\u2097 x :=\n  map_smul f\u2097 c x\n#align linear_map.map_smul LinearMap.map_smul\n\nprotected theorem map_smul_inv {\u03c3' : S \u2192+* R} [RingHomInvPair \u03c3 \u03c3'] (c : S) (x : M) :\n    c \u2022 f x = f (\u03c3' c \u2022 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 \u2194 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\u2083 \u03c3) {F : Type _} (h : F)\n\n@[simp]\ntheorem _root_.image_smul_set\u209b\u2097 [SemilinearMapClass F \u03c3 M M\u2083] (c : R) (s : Set M) :\n    h '' (c \u2022 s) = \u03c3 c \u2022 h '' s := by\n  apply Set.Subset.antisymm\n  \u00b7 rintro x \u27e8y, \u27e8z, zs, rfl\u27e9, rfl\u27e9\n    exact \u27e8h z, Set.mem_image_of_mem _ zs, (map_smul\u209b\u2097 _ _ _).symm\u27e9\n  \u00b7 rintro x \u27e8y, \u27e8z, hz, rfl\u27e9, rfl\u27e9\n    exact (Set.mem_image _ _ _).2 \u27e8c \u2022 z, Set.smul_mem_smul_set hz, map_smul\u209b\u2097 _ _ _\u27e9\n#align image_smul_set\u209b\u2097 image_smul_set\u209b\u2097\n\ntheorem _root_.preimage_smul_set\u209b\u2097 [SemilinearMapClass F \u03c3 M M\u2083] {c : R} (hc : IsUnit c)\n    (s : Set M\u2083) :\n    h \u207b\u00b9' (\u03c3 c \u2022 s) = c \u2022 h \u207b\u00b9' s := by\n  apply Set.Subset.antisymm\n  \u00b7 rintro x \u27e8y, ys, hy\u27e9\n    refine' \u27e8(hc.unit.inv : R) \u2022 x, _, _\u27e9\n    \u00b7\n      simp only [\u2190 hy, smul_smul, Set.mem_preimage, Units.inv_eq_val_inv, map_smul\u209b\u2097 h, \u2190 map_mul,\n        IsUnit.val_inv_mul, one_smul, map_one, ys]\n    \u00b7 simp only [smul_smul, IsUnit.mul_val_inv, one_smul, Units.inv_eq_val_inv]\n  \u00b7 rintro x \u27e8y, hy, rfl\u27e9\n    refine' \u27e8h y, hy, by simp only [RingHom.id_apply, map_smul\u209b\u2097 h]\u27e9\n#align preimage_smul_set\u209b\u2097 preimage_smul_set\u209b\u2097\n\nvariable (R M\u2082)\n\ntheorem _root_.image_smul_set [LinearMapClass F R M M\u2082] (c : R) (s : Set M) :\n    h '' (c \u2022 s) = c \u2022 h '' s :=\n  image_smul_set\u209b\u2097 _ _ _ h c s\n#align image_smul_set image_smul_set\n\ntheorem _root_.preimage_smul_set [LinearMapClass F R M M\u2082] {c : R} (hc : IsUnit c) (s : Set M\u2082) :\n    h \u207b\u00b9' (c \u2022 s) = c \u2022 h \u207b\u00b9' s :=\n  preimage_smul_set\u209b\u2097 _ _ _ h hc s\n#align preimage_smul_set preimage_smul_set\n\nend Pointwise\n\nvariable (M M\u2082)\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 \u2022` 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\u2082]\n  [Module S M\u2082] where\n  /-- Scalar multiplication by `R` of `M` can be moved through linear maps. -/\n  map_smul : \u2200 (f\u2097 : M \u2192\u2097[S] M\u2082) (c : R) (x : M), f\u2097 (c \u2022 x) = c \u2022 f\u2097 x\n#align linear_map.compatible_smul LinearMap.CompatibleSMul\n\nvariable {M M\u2082}\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\u2082] [Module S M\u2082] [IsScalarTower R S M\u2082] :\n    CompatibleSMul M M\u2082 R S :=\n  \u27e8fun f\u2097 c x \u21a6 by rw [\u2190 smul_one_smul S c x, \u2190 smul_one_smul S c (f\u2097 x), map_smul]\u27e9\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\u2082]\n    [Module S M\u2082] [CompatibleSMul M M\u2082 R S] (f\u2097 : M \u2192\u2097[S] M\u2082) (c : R) (x : M) :\n    f\u2097 (c \u2022 x) = c \u2022 f\u2097 x :=\n  CompatibleSMul.map_smul f\u2097 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 \u2192+ M\u2083 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 : \u21d1f.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\u2082] [CompatibleSMul M M\u2082 R S]\n\n/-- If `M` and `M\u2082` 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\u2082` is `R`-linear.\n\nSee also `LinearMap.map_smul_of_tower`. -/\n@[coe] def restrictScalars (f\u2097 : M \u2192\u2097[S] M\u2082) : M \u2192\u2097[R] M\u2082 where\n  toFun := f\u2097\n  map_add' := f\u2097.map_add\n  map_smul' := f\u2097.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 \u2192\u2097[S] M\u2082) (M \u2192\u2097[R] M\u2082) :=\n  \u27e8restrictScalars R\u27e9\n#align linear_map.coe_is_scalar_tower LinearMap.coeIsScalarTower\n\n@[simp, norm_cast]\ntheorem coe_restrictScalars (f : M \u2192\u2097[S] M\u2082) : ((f : M \u2192\u2097[R] M\u2082) : M \u2192 M\u2082) = f :=\n  rfl\n#align linear_map.coe_restrict_scalars LinearMap.coe_restrictScalars\n\ntheorem restrictScalars_apply (f\u2097 : M \u2192\u2097[S] M\u2082) (x) : restrictScalars R f\u2097 x = f\u2097 x :=\n  rfl\n#align linear_map.restrict_scalars_apply LinearMap.restrictScalars_apply\n\ntheorem restrictScalars_injective :\n    Function.Injective (restrictScalars R : (M \u2192\u2097[S] M\u2082) \u2192 M \u2192\u2097[R] M\u2082) := fun _ _ h \u21a6\n  ext (LinearMap.congr_fun h : _)\n#align linear_map.restrict_scalars_injective LinearMap.restrictScalars_injective\n\n@[simp]\ntheorem restrictScalars_inj (f\u2097 g\u2097 : M \u2192\u2097[S] M\u2082) :\n    f\u2097.restrictScalars R = g\u2097.restrictScalars R \u2194 f\u2097 = g\u2097 :=\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 \u2192\u209b\u2097[\u03c3] M\u2083) \u2192 M \u2192+ M\u2083) := fun f\u2097 g\u2097 h \u21a6\n  ext <| (FunLike.congr_fun h : \u2200 x, f\u2097.toAddMonoidHom x = g\u2097.toAddMonoidHom x)\n#align linear_map.to_add_monoid_hom_injective LinearMap.toAddMonoidHom_injective\n\n/-- If two `\u03c3`-linear maps from `R` are equal on `1`, then they are equal. -/\n@[ext high]\ntheorem ext_ring {f g : R \u2192\u209b\u2097[\u03c3] M\u2083} (h : f 1 = g 1) : f = g :=\n  ext fun x \u21a6 by rw [\u2190 mul_one x, \u2190 smul_eq_mul, f.map_smul\u209b\u2097, g.map_smul\u209b\u2097, h]\n#align linear_map.ext_ring LinearMap.ext_ring\n\ntheorem ext_ring_iff {\u03c3 : R \u2192+* R} {f g : R \u2192\u209b\u2097[\u03c3] M} : f = g \u2194 f 1 = g 1 :=\n  \u27e8fun h \u21a6 h \u25b8 rfl, ext_ring\u27e9\n#align linear_map.ext_ring_iff LinearMap.ext_ring_iff\n\n@[ext high]\ntheorem ext_ring_op {\u03c3 : R\u1d50\u1d52\u1d56 \u2192+* S} {f g : R \u2192\u209b\u2097[\u03c3] M\u2083} (h : f (1 : R) = g (1 : R)) :\n    f = g :=\n  ext fun x \u21a6 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 [\u2190 one_mul x, \u2190 op_smul_eq_mul]\n    refine (f.map_smul\u209b\u2097 (MulOpposite.op x) 1).trans ?_\n    rw [h]\n    exact (g.map_smul\u209b\u2097 (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 \u2192+* S) : R \u2192\u209b\u2097[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\u2081] [Semiring R\u2082] [Semiring R\u2083]\nvariable [AddCommMonoid M] [AddCommMonoid M\u2081] [AddCommMonoid M\u2082] [AddCommMonoid M\u2083]\nvariable {module_M\u2081 : Module R\u2081 M\u2081} {module_M\u2082 : Module R\u2082 M\u2082} {module_M\u2083 : Module R\u2083 M\u2083}\nvariable {\u03c3\u2081\u2082 : R\u2081 \u2192+* R\u2082} {\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083} {\u03c3\u2081\u2083 : R\u2081 \u2192+* R\u2083}\nvariable [RingHomCompTriple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083]\nvariable (f : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083) (g : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082)\n\n/-- Composition of two linear maps is a linear map -/\ndef comp : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2083] M\u2083 where\n  toFun := f \u2218 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\u209b\u2097, RingHomCompTriple.comp_apply]\n#align linear_map.comp LinearMap.comp\n\n-- mathport name: \u00abexpr \u2218\u2097 \u00bb\nset_option quotPrecheck false in -- Porting note: error message suggested to do this\n/-- `\u2218\u2097` 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 \" \u2218\u2097 \" =>\n  @LinearMap.comp _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ (RingHom.id _) (RingHom.id _) (RingHom.id _)\n    RingHomCompTriple.ids\n\ntheorem comp_apply (x : M\u2081) : 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\u2081 \u2192 M\u2083) = f \u2218 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 _ \u21a6 rfl\n#align linear_map.comp_id LinearMap.comp_id\n\n@[simp]\ntheorem id_comp : id.comp f = f :=\n  LinearMap.ext fun _ \u21a6 rfl\n#align linear_map.id_comp LinearMap.id_comp\n\nvariable {f g} {f' : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083} {g' : M\u2081 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082}\n\ntheorem cancel_right (hg : Function.Surjective g) : f.comp g = f'.comp g \u2194 f = f' :=\n  \u27e8fun h \u21a6 ext <| hg.forall.2 (ext_iff.1 h), fun h \u21a6 h \u25b8 rfl\u27e9\n#align linear_map.cancel_right LinearMap.cancel_right\n\ntheorem cancel_left (hf : Function.Injective f) : f.comp g = f.comp g' \u2194 g = g' :=\n  \u27e8fun h \u21a6 ext fun x \u21a6 hf <| by rw [\u2190 comp_apply, h, comp_apply], fun h \u21a6 h \u25b8 rfl\u27e9\n#align linear_map.cancel_left LinearMap.cancel_left\n\nend\n\nvariable [AddCommMonoid M] [AddCommMonoid M\u2081] [AddCommMonoid M\u2082] [AddCommMonoid M\u2083]\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\u2082] {\u03c3 : R \u2192+* S} {\u03c3' : S \u2192+* R} [RingHomInvPair \u03c3 \u03c3']\n    (f : M \u2192\u209b\u2097[\u03c3] M\u2082) (g : M\u2082 \u2192 M) (h\u2081 : LeftInverse g f) (h\u2082 : RightInverse g f) : M\u2082 \u2192\u209b\u2097[\u03c3'] M :=\n  by\n  dsimp [LeftInverse, Function.RightInverse] at h\u2081 h\u2082\n  exact\n    { toFun := g\n      map_add' := fun x y \u21a6 by rw [\u2190 h\u2081 (g (x + y)), \u2190 h\u2081 (g x + g y)] ; simp [h\u2082]\n      map_smul' := fun a b \u21a6 by\n        dsimp only\n        rw [\u2190 h\u2081 (g (a \u2022 b)), \u2190 h\u2081 (\u03c3' a \u2022 g b)]\n        simp [h\u2082] }\n#align linear_map.inverse LinearMap.inverse\n\nend AddCommMonoid\n\nsection AddCommGroup\n\nvariable [Semiring R] [Semiring S] [AddCommGroup M] [AddCommGroup M\u2082]\n\nvariable {module_M : Module R M} {module_M\u2082 : Module S M\u2082} {\u03c3 : R \u2192+* S}\n\nvariable (f : M \u2192\u209b\u2097[\u03c3] M\u2082)\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\u2082] :\n    CompatibleSMul M M\u2082 \u2124 S :=\n  \u27e8fun f\u2097 c x \u21a6 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]\u27e9\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\u2082]\n    [Semiring S] [Module S M] [Module S M\u2082] [CompatibleSMul M M\u2082 R S] : CompatibleSMul M M\u2082 R\u02e3 S :=\n  \u27e8fun f\u2097 c x \u21a6 (CompatibleSMul.map_smul f\u2097 (c : R) x : _)\u27e9\n#align linear_map.compatible_smul.units LinearMap.CompatibleSMul.units\n\nend AddCommGroup\n\nend LinearMap\n\nnamespace Module\n\n/-- `g : R \u2192+* 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 \u2192+* S) :\n    letI := compHom S g; R \u2192\u2097[R] S :=\nletI := compHom S g\n{ toFun := (g : R \u2192 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\u2082] [Module R M] [Module R M\u2082]\n\n/-- A `DistribMulActionHom` between two modules is a linear map. -/\n@[coe]\ndef toLinearMap (f\u2097 : M \u2192+[R] M\u2082) : M \u2192\u2097[R] M\u2082 :=\n  { f\u2097 with }\n#align distrib_mul_action_hom.to_linear_map DistribMulActionHom.toLinearMap\n\ninstance : Coe (M \u2192+[R] M\u2082) (M \u2192\u2097[R] M\u2082) :=\n  \u27e8toLinearMap\u27e9\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 \u2192+[R] M\u2082) : ((f : M \u2192\u2097[R] M\u2082) : M \u2192 M\u2082) = f :=\n  rfl\n#align distrib_mul_action_hom.coe_to_linear_map DistribMulActionHom.coe_toLinearMap\n\ntheorem toLinearMap_injective {f g : M \u2192+[R] M\u2082} (h : (f : M \u2192\u2097[R] M\u2082) = (g : M \u2192\u2097[R] M\u2082)) :\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\u2082]\nvariable [Module R M] [Module R M\u2082]\n\n/-- Convert an `IsLinearMap` predicate to a `LinearMap` -/\ndef mk' (f : M \u2192 M\u2082) (H : IsLinearMap R f) : M \u2192\u2097[R] M\u2082\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 \u2192 M\u2082} (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 \u21a6 c \u2022 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 \u21a6 c \u2022 a :=\n  IsLinearMap.mk (fun x y \u21a6 add_smul x y a) fun x y \u21a6 mul_smul x y a\n#align is_linear_map.is_linear_map_smul' IsLinearMap.isLinearMap_smul'\n\nvariable {f : M \u2192 M\u2082} (lin : IsLinearMap R f)\n\ntheorem map_zero : f (0 : M) = (0 : M\u2082) :=\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\u2082]\nvariable [Module R M] [Module R M\u2082]\n\ntheorem isLinearMap_neg : IsLinearMap R fun z : M \u21a6 -z :=\n  IsLinearMap.mk neg_add fun x y \u21a6 (smul_neg x y).symm\n#align is_linear_map.is_linear_map_neg IsLinearMap.isLinearMap_neg\n\nvariable {f : M \u2192 M\u2082} (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 \u2192\u2097[R] M\n#align module.End Module.End\n\n/-- Reinterpret an additive homomorphism as a `\u2115`-linear map. -/\ndef AddMonoidHom.toNatLinearMap [AddCommMonoid M] [AddCommMonoid M\u2082] (f : M \u2192+ M\u2082) : M \u2192\u2097[\u2115] M\u2082\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\u2082] :\n    Function.Injective (@AddMonoidHom.toNatLinearMap M M\u2082 _ _) :=\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 `\u2124`-linear map. -/\ndef AddMonoidHom.toIntLinearMap [AddCommGroup M] [AddCommGroup M\u2082] (f : M \u2192+ M\u2082) : M \u2192\u2097[\u2124] M\u2082\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\u2082] :\n    Function.Injective (@AddMonoidHom.toIntLinearMap M M\u2082 _ _) :=\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\u2082] (f : M \u2192+ M\u2082) :\n    \u21d1f.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 `\u211a`-linear map. -/\ndef AddMonoidHom.toRatLinearMap [AddCommGroup M] [Module \u211a M] [AddCommGroup M\u2082] [Module \u211a M\u2082]\n    (f : M \u2192+ M\u2082) : M \u2192\u2097[\u211a] M\u2082 :=\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 \u211a M] [AddCommGroup M\u2082]\n    [Module \u211a M\u2082] : Function.Injective (@AddMonoidHom.toRatLinearMap M M\u2082 _ _ _ _) :=\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 \u211a M] [AddCommGroup M\u2082]\n    [Module \u211a M\u2082] (f : M \u2192+ M\u2082) : \u21d1f.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\u2082] [Semiring R\u2083]\nvariable [AddCommMonoid M] [AddCommMonoid M\u2082] [AddCommMonoid M\u2083]\nvariable [Module R M] [Module R\u2082 M\u2082] [Module R\u2083 M\u2083]\nvariable {\u03c3\u2081\u2082 : R \u2192+* R\u2082} {\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083} {\u03c3\u2081\u2083 : R \u2192+* R\u2083} [RingHomCompTriple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083]\nvariable [Monoid S] [DistribMulAction S M\u2082] [SMulCommClass R\u2082 S M\u2082]\nvariable [Monoid S\u2083] [DistribMulAction S\u2083 M\u2083] [SMulCommClass R\u2083 S\u2083 M\u2083]\nvariable [Monoid T] [DistribMulAction T M\u2082] [SMulCommClass R\u2082 T M\u2082]\n\ninstance : SMul S (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\n  \u27e8fun a f \u21a6\n    { toFun := a \u2022 (f : M \u2192 M\u2082)\n      map_add' := fun x y \u21a6 by simp only [Pi.smul_apply, f.map_add, smul_add]\n      map_smul' := fun c x \u21a6 by simp [Pi.smul_apply, smul_comm] }\u27e9\n\n@[simp]\ntheorem smul_apply (a : S) (f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) (x : M) : (a \u2022 f) x = a \u2022 f x :=\n  rfl\n#align linear_map.smul_apply LinearMap.smul_apply\n\ntheorem coe_smul (a : S) (f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) : (a \u2022 f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) = a \u2022 (f : M \u2192 M\u2082) :=\n  rfl\n#align linear_map.coe_smul LinearMap.coe_smul\n\ninstance [SMulCommClass S T M\u2082] : SMulCommClass S T (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\n  \u27e8fun _ _ _ \u21a6 ext fun _ \u21a6 smul_comm _ _ _\u27e9\n\n-- example application of this instance: if S -> T -> R are homomorphisms of commutative rings and\n-- M and M\u2082 are R-modules then the S-module and T-module structures on Hom_R(M,M\u2082) are compatible.\ninstance [SMul S T] [IsScalarTower S T M\u2082] : IsScalarTower S T (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082)\n    where smul_assoc _ _ _ := ext fun _ \u21a6 smul_assoc _ _ _\n\ninstance [DistribMulAction S\u1d50\u1d52\u1d56 M\u2082] [SMulCommClass R\u2082 S\u1d50\u1d52\u1d56 M\u2082] [IsCentralScalar S M\u2082] :\n    IsCentralScalar S (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) where op_smul_eq_smul _ _ := ext fun _ \u21a6 op_smul_eq_smul _ _\n\nend SMul\n\n/-! ### Arithmetic on the codomain -/\n\n\nsection Arithmetic\n\nvariable [Semiring R\u2081] [Semiring R\u2082] [Semiring R\u2083]\nvariable [AddCommMonoid M] [AddCommMonoid M\u2082] [AddCommMonoid M\u2083]\nvariable [AddCommGroup N\u2081] [AddCommGroup N\u2082] [AddCommGroup N\u2083]\nvariable [Module R\u2081 M] [Module R\u2082 M\u2082] [Module R\u2083 M\u2083]\nvariable [Module R\u2081 N\u2081] [Module R\u2082 N\u2082] [Module R\u2083 N\u2083]\nvariable {\u03c3\u2081\u2082 : R\u2081 \u2192+* R\u2082} {\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083} {\u03c3\u2081\u2083 : R\u2081 \u2192+* R\u2083} [RingHomCompTriple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083]\n\n/-- The constant 0 map is linear. -/\ninstance : Zero (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\n  \u27e8{  toFun := 0\n      map_add' := by simp\n      map_smul' := by simp }\u27e9\n\n@[simp]\ntheorem zero_apply (x : M) : (0 : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) x = 0 :=\n  rfl\n#align linear_map.zero_apply LinearMap.zero_apply\n\n@[simp]\ntheorem comp_zero (g : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083) : (g.comp (0 : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) : M \u2192\u209b\u2097[\u03c3\u2081\u2083] M\u2083) = 0 :=\n  ext fun c \u21a6 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 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) : ((0 : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083).comp f : M \u2192\u209b\u2097[\u03c3\u2081\u2083] M\u2083) = 0 :=\n  rfl\n#align linear_map.zero_comp LinearMap.zero_comp\n\ninstance : Inhabited (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\n  \u27e80\u27e9\n\n@[simp]\ntheorem default_def : (default : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) = 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 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\n  \u27e8fun f g \u21a6\n    { toFun := f + g\n      map_add' := by simp [add_comm, add_left_comm]\n      map_smul' := by simp [smul_add] }\u27e9\n\n@[simp]\n\n\ntheorem add_comp (f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) (g h : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083) :\n    ((h + g).comp f : M \u2192\u209b\u2097[\u03c3\u2081\u2083] M\u2083) = h.comp f + g.comp f :=\n  rfl\n#align linear_map.add_comp LinearMap.add_comp\n\ntheorem comp_add (f g : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) (h : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083) :\n    (h.comp (f + g) : M \u2192\u209b\u2097[\u03c3\u2081\u2083] M\u2083) = h.comp f + h.comp g :=\n  ext fun _ \u21a6 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 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\n  FunLike.coe_injective.addCommMonoid _ rfl (fun _ _ \u21a6 rfl) fun _ _ \u21a6 rfl\n\n/-- The negation of a linear map is linear. -/\ninstance : Neg (M \u2192\u209b\u2097[\u03c3\u2081\u2082] N\u2082) :=\n  \u27e8fun f \u21a6\n    { toFun := -f\n      map_add' := by simp [add_comm]\n      map_smul' := by simp }\u27e9\n\n@[simp]\ntheorem neg_apply (f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] N\u2082) (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 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) (g : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] N\u2083) : (-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 \u2192\u209b\u2097[\u03c3\u2081\u2082] N\u2082) (g : N\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] N\u2083) : g.comp (-f) = -g.comp f :=\n  ext fun _ \u21a6 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 \u2192\u209b\u2097[\u03c3\u2081\u2082] N\u2082) :=\n  \u27e8fun f g \u21a6\n    { toFun := f - g\n      map_add' := fun x y \u21a6 by simp only [Pi.sub_apply, map_add, add_sub_add_comm]\n      map_smul' := fun r x \u21a6 by simp [Pi.sub_apply, map_smul, smul_sub] }\u27e9\n\n@[simp]\ntheorem sub_apply (f g : M \u2192\u209b\u2097[\u03c3\u2081\u2082] N\u2082) (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 \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) (g h : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] N\u2083) :\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 \u2192\u209b\u2097[\u03c3\u2081\u2082] N\u2082) (h : N\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] N\u2083) :\n    h.comp (g - f) = h.comp g - h.comp f :=\n  ext fun _ \u21a6 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 \u2192\u209b\u2097[\u03c3\u2081\u2082] N\u2082) :=\n  FunLike.coe_injective.addCommGroup _ rfl (fun _ _ \u21a6 rfl) (fun _ \u21a6 rfl) (fun _ _ \u21a6 rfl)\n    (fun _ _ \u21a6 rfl) fun _ _ \u21a6 rfl\n\nend Arithmetic\n\nsection Actions\n\nvariable [Semiring R] [Semiring R\u2082] [Semiring R\u2083]\nvariable [AddCommMonoid M] [AddCommMonoid M\u2082] [AddCommMonoid M\u2083]\nvariable [Module R M] [Module R\u2082 M\u2082] [Module R\u2083 M\u2083]\nvariable {\u03c3\u2081\u2082 : R \u2192+* R\u2082} {\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083} {\u03c3\u2081\u2083 : R \u2192+* R\u2083} [RingHomCompTriple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083]\n\nsection SMul\n\nvariable [Monoid S] [DistribMulAction S M\u2082] [SMulCommClass R\u2082 S M\u2082]\nvariable [Monoid S\u2083] [DistribMulAction S\u2083 M\u2083] [SMulCommClass R\u2083 S\u2083 M\u2083]\nvariable [Monoid T] [DistribMulAction T M\u2082] [SMulCommClass R\u2082 T M\u2082]\n\ninstance : DistribMulAction S (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082)\n    where\n  one_smul _ := ext fun _ \u21a6 one_smul _ _\n  mul_smul _ _ _ := ext fun _ \u21a6 mul_smul _ _ _\n  smul_add _ _ _ := ext fun _ \u21a6 smul_add _ _ _\n  smul_zero _ := ext fun _ \u21a6 smul_zero _\n\ntheorem smul_comp (a : S\u2083) (g : M\u2082 \u2192\u209b\u2097[\u03c3\u2082\u2083] M\u2083) (f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :\n    (a \u2022 g).comp f = a \u2022 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\u2082] [Module R M\u2083] [SMulCommClass R S M\u2082] [DistribMulAction S M\u2083]\n    [SMulCommClass R S M\u2083] [CompatibleSMul M\u2083 M\u2082 S R] (g : M\u2083 \u2192\u2097[R] M\u2082) (a : S) (f : M \u2192\u2097[R] M\u2083) :\n    g.comp (a \u2022 f) = a \u2022 g.comp f :=\n  ext fun _ \u21a6 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\u2082] [SMulCommClass R\u2082 S M\u2082]\n\ninstance : Module S (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082)\n    where\n  add_smul _ _ _ := ext fun _ \u21a6 add_smul _ _ _\n  zero_smul _ := ext fun _ \u21a6 zero_smul _ _\n\ninstance [NoZeroSMulDivisors S M\u2082] : NoZeroSMulDivisors S (M \u2192\u209b\u2097[\u03c3\u2081\u2082] M\u2082) :=\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\u2081] [Module R M] [Module R N\u2081]\n\ninstance : One (Module.End R M) :=\n  \u27e8LinearMap.id\u27e9\n\ninstance : Mul (Module.End R M) :=\n  \u27e8LinearMap.comp\u27e9\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 : \u21d1(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) : \u21d1(f * g) = f \u2218 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 := (\u00b7 * \u00b7)\n  one := (1 : M \u2192\u2097[R] M)\n  mul_assoc f g h := LinearMap.ext fun x \u21a6 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 := (\u00b7 * \u00b7)\n    one := (1 : M \u2192\u2097[R] M)\n    zero := (0 : M \u2192\u2097[R] M)\n    add := (\u00b7 + \u00b7)\n    mul_zero := comp_zero\n    zero_mul := zero_comp\n    left_distrib := fun _ _ _ \u21a6 comp_add _ _ _\n    right_distrib := fun _ _ _ \u21a6 add_comp _ _ _\n    natCast := fun n \u21a6 n \u2022 (1 : M \u2192\u2097[R] M)\n    natCast_zero := zero_smul \u2115 (1 : M \u2192\u2097[R] M)\n    natCast_succ := fun n \u21a6 (AddMonoid.nsmul_succ n (1 : M \u2192\u2097[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 : \u2115) (m : M) : (\u2191n : Module.End R M) m = n \u2022 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\u2081) :=\n  { Module.End.semiring, LinearMap.addCommGroup with\n    mul := (\u00b7 * \u00b7)\n    one := (1 : N\u2081 \u2192\u2097[R] N\u2081)\n    zero := (0 : N\u2081 \u2192\u2097[R] N\u2081)\n    add := (\u00b7 + \u00b7)\n    intCast := fun z \u21a6 z \u2022 (1 : N\u2081 \u2192\u2097[R] N\u2081)\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 : \u2124) (m : N\u2081) : (z : Module.End R N\u2081) m = z \u2022 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  \u27e8smul_comp\u27e9\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  \u27e8fun s _ _ \u21a6 (comp_smul _ s _).symm\u27e9\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 \u2192\u2097[R] M`) on `M`.\n\nThis generalizes `Function.End.applyMulAction`. -/\ninstance applyModule : Module (Module.End R M) M\n    where\n  smul := (\u00b7 <| \u00b7)\n  smul_zero := LinearMap.map_zero\n  smul_add := LinearMap.map_add\n  add_smul := LinearMap.add_apply\n  zero_smul := (LinearMap.zero_apply : \u2200 m, (0 : M \u2192\u2097[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 \u2022 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  \u27e8LinearMap.ext\u27e9\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  \u27e8fun _ _ _ \u21a6 rfl\u27e9\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 \u2192\u2097[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 \u2192* 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 \u2192+* 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 _ _ \u21a6 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\u1d50\u1d52\u1d56` to `Module.End R R` induced by the right\nmultiplication. -/\n@[simps]\ndef moduleEndSelf : R\u1d50\u1d52\u1d56 \u2243+* Module.End R R :=\n  { Module.toModuleEnd R R with\n    toFun := DistribMulAction.toLinearMap R R\n    invFun := fun f \u21a6 MulOpposite.op (f 1)\n    left_inv := mul_one\n    right_inv := fun _ \u21a6 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\u1d50\u1d52\u1d56 R` induced by the left\nmultiplication. -/\n@[simps]\ndef moduleEndSelfOp : R \u2243+* Module.End R\u1d50\u1d52\u1d56 R :=\n  { Module.toModuleEnd _ _ with\n    toFun := DistribMulAction.toLinearMap _ _\n    invFun := fun f \u21a6 f 1\n    left_inv := mul_one\n    right_inv := fun _ \u21a6 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 : \u2115) [AddCommMonoid N\u2081] [Module R N\u2081] :\n    (\u2191n : Module.End R N\u2081) = Module.toModuleEnd R N\u2081 n :=\n  rfl\n#align module.End.nat_cast_def Module.End.natCast_def\n\ntheorem End.intCast_def (z : \u2124) [AddCommGroup N\u2081] [Module R N\u2081] :\n    (z : Module.End R N\u2081) = Module.toModuleEnd R N\u2081 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 `\ud835\udd4e R \u2192+* \ud835\udd4e R`.\nIt turns out that this endomorphism can be described by polynomials over `\u2124`\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 : \ud835\udd4e R \u2192 \ud835\udd4e 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : mv_polynomial \u2115 \u211a :=\n  coe_fn (mv_polynomial.bind\u2081 (witt_polynomial p \u211a \u2218 fun (n : \u2115) => n + 1)) (X_in_terms_of_W p \u211a n)\n\ntheorem bind\u2081_frobenius_poly_rat_witt_polynomial (p : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : coe_fn (mv_polynomial.bind\u2081 (frobenius_poly_rat p)) (witt_polynomial p \u211a n) = witt_polynomial p \u211a (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 : \u2115) [hp : fact (nat.prime p)] : \u2115 \u2192 mv_polynomial \u2115 \u2124 :=\n  sorry\n\ntheorem frobenius_poly_aux_eq (p : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : frobenius_poly_aux p n =\n  mv_polynomial.X (n + 1) -\n    finset.sum (finset.range n)\n      fun (i : \u2115) =>\n        finset.sum (finset.range (p ^ (n - i)))\n          fun (j : \u2115) =>\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                \u2191(nat.choose (p ^ (n - i)) (j + 1) /\n                      p ^ (n - i - pnat_multiplicity p { val := j + 1, property := nat.succ_pos j }) *\n                    \u2191p ^ (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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : mv_polynomial \u2115 \u2124 :=\n  mv_polynomial.X n ^ p + coe_fn mv_polynomial.C \u2191p * frobenius_poly_aux p n\n\n/-\nOur next goal is to prove\n```\nlemma map_frobenius_poly (n : \u2115) :\n  mv_polynomial.map (int.cast_ring_hom \u211a) (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\u2081 (p : \u2115) [hp : fact (nat.prime p)] (n : \u2115) (j : \u2115) (hj : j < p ^ n) : p ^ (n - pnat_multiplicity p { val := j + 1, property := nat.succ_pos j }) \u2223 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\u2082 (p : \u2115) [hp : fact (nat.prime p)] {n : \u2115} {i : \u2115} {j : \u2115} (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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : coe_fn (mv_polynomial.map (int.cast_ring_hom \u211a)) (frobenius_poly p n) = frobenius_poly_rat p n := sorry\n\ntheorem frobenius_poly_zmod (p : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : 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\u2081_frobenius_poly_witt_polynomial (p : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : coe_fn (mv_polynomial.bind\u2081 (frobenius_poly p)) (witt_polynomial p \u2124 n) = witt_polynomial p \u2124 (n + 1) := sorry\n\n/-- `frobenius_fun` is the function underlying the ring endomorphism\n`frobenius : \ud835\udd4e R \u2192+* frobenius \ud835\udd4e R`. -/\ndef frobenius_fun {p : \u2115} {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 : \u2115) => coe_fn (mv_polynomial.aeval (coeff x)) (frobenius_poly p n)\n\ntheorem coeff_frobenius_fun {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : \u2115) : 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 : \u2115) [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 : \u2115) => coeff_frobenius_fun x n\n\ntheorem ghost_component_frobenius_fun {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (n : \u2115) (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 : \ud835\udd4e R \u2192+* \ud835\udd4e R`.\n\nThe underlying function of this morphism is `witt_vector.frobenius_fun`.\n-/\ndef frobenius {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] : witt_vector p R \u2192+* witt_vector p R :=\n  ring_hom.mk frobenius_fun sorry sorry sorry sorry\n\ntheorem coeff_frobenius {p : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (x : witt_vector p R) (n : \u2115) : 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 : \u2115} {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] (n : \u2115) (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 : \u2115) [hp : fact (nat.prime p)] : is_poly p fun (R : Type u_1) (_Rcr : comm_ring R) => \u21d1frobenius :=\n  frobenius_fun_is_poly p\n\n@[simp] theorem coeff_frobenius_char_p (p : \u2115) {R : Type u_1} [hp : fact (nat.prime p)] [comm_ring R] [char_p R p] (x : witt_vector p R) (n : \u2115) : coeff (coe_fn frobenius x) n = coeff x n ^ p := sorry\n\ntheorem frobenius_eq_map_frobenius (p : \u2115) {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 : \u2115) [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\u2081 : \u2115} (g : Game pw) (a\u2081 : A pw\u2081) : Game pw\u2081 :=\n{g with a := a\u2081}\n\ndef Game.set_D {pw : \u2115} (g : Game pw) (d\u2081 : D) : Game pw :=\n{g with d := d\u2081}\n\ndef Game.set_players {pw pw\u2081 : \u2115} (g : Game pw)\n  (a\u2081 : A pw\u2081) (d\u2081 : D) : Game pw\u2081 :=\n(g.set_A a\u2081).set_D d\u2081\n\ndef Game.set_prev_moves {pw : \u2115} (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 : \u2115} (g : Game pw) :=\n\u2203 (n : \u2115), \u00ac(g.play n).act\n\ndef D_hws_at (pw : \u2115) (s : State) :=\n\u2203 (d : D), \u2200 (a : A pw), (init_game a d s).D_wins\n\ndef D_hws (pw : \u2115) := D_hws_at pw state\u2080\n\n-----\n\ndef simulate {pw : \u2115} (a : A pw) (d : D) (n : \u2115) : Game pw :=\n(init_game a d state\u2080).play n\n\ndef all_s {pw : \u2115} (a : A pw) (d : D) (P : State \u2192 Prop) :=\n\u2200 (n : \u2115), P (simulate a d n).s\n\ndef all_b {pw : \u2115} (a : A pw) (d : D) (P : Board \u2192 Prop) :=\nall_s a d (\u03bb s, P s.board)\n\ndef any_s {pw : \u2115} (a : A pw) (d : D) (P : State \u2192 Prop) :=\n\u00acall_s a d (\u03bb s, \u00acP s)\n\ndef any_b {pw : \u2115} (a : A pw) (d : D) (P : Board \u2192 Prop) :=\nany_s a d (\u03bb s, P s.board)\n\ndef D_wins_in {pw : \u2115} (a : A pw) (d : D) (n : \u2115) :=\n\u2200 (k : \u2115), n \u2264 k \u2192 \u00ac(simulate a d k).act\n\ndef valid_A_state (pw : \u2115) (s : State) :=\n\u2203 (a : A pw) (d : D) (n : \u2115) hs, (play_D_move_at (simulate a d n) hs).s = s\n\ndef valid_D_state (pw : \u2115) (s : State) :=\n\u2203 (a : A pw) (d : D) (n : \u2115), (simulate a d n).s = s\n\ndef valid_state (pw : \u2115) (s : State) :=\nvalid_D_state pw s\n\n-----\n\nlemma not_A_wins_at {pw : \u2115} {g : Game pw} :\n  \u00acg.A_wins \u2194 g.D_wins :=\nby simp [Game.A_wins, Game.D_wins]\n\nlemma not_D_wins_at {pw : \u2115} {g : Game pw} :\n  \u00acg.D_wins \u2194 g.A_wins :=\nby simp [Game.A_wins, Game.D_wins]\n\nlemma play_at_succ {pw n : \u2115} {g : Game pw} :\n  g.play n.succ = g.play_move.play n :=\nfunction.iterate_succ_apply _ _ _\n\nlemma play_at_succ' {pw n : \u2115} {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 : \u2115} {g : Game pw}\n  (h : g.A_wins) {n : \u2115} : (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 : \u2115} {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 : \u2115} {g : Game pw} :\n  (play_A_move_at g).a = g.a \u2227 (play_A_move_at g).d = g.d :=\nby { rw [play_A_move_at], split_ifs; exact \u27e8rfl, rfl\u27e9 }\n\nlemma play_D_move_at_players_eq {pw : \u2115} {g : Game pw} {hs} :\n  (play_D_move_at g hs).a = g.a \u2227 (play_D_move_at g hs).d = g.d :=\nby { rw [play_D_move_at], exact \u27e8rfl, rfl\u27e9 }\n\nlemma play_move_at_players_eq {pw : \u2115} {g : Game pw} :\n  g.play_move.a = g.a \u2227 g.play_move.d = g.d :=\nbegin\n  rw [Game.play_move], split_ifs, swap, exact \u27e8rfl, rfl\u27e9,\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 \u27e8rfl, rfl\u27e9,\nend\n\nlemma play_move_at_players_eq' {pw : \u2115} {g : Game pw} {hs} :\n  (play_A_move_at (play_D_move_at g hs)).a = g.a \u2227\n  (play_A_move_at (play_D_move_at g hs)).d = g.d :=\nby { rw play_A_move_at, split_ifs; exact \u27e8rfl, rfl\u27e9 }\n\nlemma play_at_players_eq {pw n : \u2115} {g : Game pw} :\n  (g.play n).a = g.a \u2227 (g.play n).d = g.d :=\nbegin\n  induction n with n ih,\n  { exact \u27e8rfl, rfl\u27e9 },\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 : \u2115} {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 : \u2115} {g : Game pw}\n  (h : \u00acg.act) :\n  g.play_move = g :=\ndif_neg h\n\nlemma play_A_move_hvm {pw : \u2115} {g : Game pw} (hs)\n  (h : A_has_valid_move pw g.s.board) :\n  \u2203 h, play_A_move_at g = play_A_move_at' g.a g hs h :=\nby exact \u27e8_, dif_pos \u27e8hs, h\u27e9\u27e9\n\nlemma play_A_move_at_set_D {pw : \u2115}\n  {g : Game pw} {d\u2081 : D} :\n  play_A_move_at (g.set_D d\u2081) = (play_A_move_at g).set_D d\u2081 :=\nby { simp_rw play_A_move_at, split_ifs; refl }\n\nlemma play_D_move_at_set_A {pw pw\u2081 : \u2115}\n  {g : Game pw} {a\u2081 : A pw\u2081} {hs} :\n  play_D_move_at (g.set_A a\u2081) hs =\n  (play_D_move_at g hs).set_A a\u2081 :=\nrfl\n\nlemma A_has_valid_move_at_play_D_move {pw : \u2115} {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\u2081,\n  { exact h\u2081.2 },\n  { cases h },\nend\n\n-----\n\nlemma act_of_act_play_move {pw : \u2115} {g : Game pw}\n  (h : g.play_move.act) : g.act :=\nby { rw Game.play_move at h, split_ifs at h with h\u2081; assumption }\n\nlemma act_play_of_act_play_succ {pw n : \u2115} {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 : \u2115} {g : Game pw}\n  (h\u2081 : n \u2264 m) (h\u2082 : (g.play m).act) : (g.play n).act :=\nbegin\n  induction' h\u2081,\n  { exact h\u2082 },\n  { rw play_at_succ' at h\u2082, exact ih (act_of_act_play_move h\u2082) },\nend\n\nlemma hist_len_play_A_move_at' {pw pw\u2081 : \u2115} {g : Game pw}\n  {a\u2081 : A pw\u2081} {h\u2081 h\u2082} :\n  (play_A_move_at' a\u2081 g h\u2081 h\u2082).s.len = g.s.len.succ :=\nhist_len_apply_A_move\n\nlemma hist_len_play_D_move_at {pw : \u2115} {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 : \u2115} {g : Game pw} :\n  g.s.len \u2264 (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 : \u2115} {g : Game pw} {hs} :\n  g.s.len \u2264 (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 : \u2115} {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 : \u2115} {g : Game pw} :\n  g.s.len \u2264 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\u2081,\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 _ \u2264 (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 : \u2115} {g : Game pw} :\n  g.s.len \u2264 (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\u2081 : \u2115} {g : Game pw}\n  {a\u2081 : A pw\u2081} {d\u2081 : D} :\n  (g.set_A a\u2081).set_D d\u2081 = (g.set_D d\u2081).set_A a\u2081 :=\nrfl\n\nlemma play_move_eq_set_state_of_act_next {pw : \u2115} {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 : \u2115} {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 : \u2115} {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 \u2194 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 (\u2200 n, (g'.play n).act) \u2194 (\u2200 n, ((g.play n).set_players a' d').act),\n  suffices h : \u2200 {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\u2081 := g.play n,\n  let g\u2081' := g\u2081.set_players a' d',\n  simp_rw play_at_succ', rw ih, clear ih,\n  change (g\u2081.set_players a' d').play_move = g\u2081.play_move.set_players a' d',\n  simp_rw Game.play_move,\n  split_ifs, swap, { refl },\n  have h\u2081 : play_D_move_at (g\u2081.set_players a' d') h =\n    (play_D_move_at g\u2081 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\u2081.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 \u27e8_, snoc_eq_snoc_iff.mpr \u27e8rfl, rfl\u27e9, rfl\u27e9,\n    change (g\u2081.set_D d').s with g\u2081.s,\n    congr' 1, generalize_proofs, change d'.f g\u2081.s h with dite _ _ _,\n    split_ifs with h\u2082,\n    { exfalso, contrapose! h\u2082, clear h\u2082,\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\u2081, clear h\u2081,\n  let g\u2082 : Game pw := _, change (play_D_move_at g\u2081 h) with g\u2082,\n  have h\u2081 : play_A_move_at (g\u2082.set_A a') =\n    (play_A_move_at g\u2082).set_A a',\n  { simp_rw play_A_move_at,\n    change dite (g\u2082.act \u2227 A_has_valid_move pw g\u2082.s.board) _ _ = _,\n    split_ifs with hx, swap, { refl },\n    change (g\u2082.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\u2082.set_A a').s with g\u2082.s at hx \u22a2,\n    change _ = apply_A_move _ _,\n    simp [apply_A_move, apply_move],\n    generalize_proofs hy hz,\n    change a'.f g\u2082.s h hy with dite _ _ _,\n    split_ifs with h\u2082,\n    { exfalso, contrapose! h\u2082, clear h\u2082,\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\u2081],\nend\n\nlemma A_set_move_A_wins_iff {pw : \u2115} {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 \u2194 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 : \u2115} {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 \u2194 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 : \u2115} {g : Game pw} : g.play 1 = g.play_move := rfl\n\n-----\n\n@[simp]\nlemma init_game_act {pw : \u2115}\n  {a : A pw} {d : D} {s : State} :\n  (init_game a d s).act \u2194 s.act := by refl\n\nlemma init_game_play_move {pw : \u2115}\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 : \u2115} {g : Game pw} :\n  g.finish.s.len = g.s.len := rfl\n\nlemma hist_len_le_play_move {pw : \u2115} {g : Game pw} :\n  g.s.len \u2264 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 : \u2115} {g : Game pw} :\n  g.s.len \u2264 (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 : \u2115} {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 : \u2115} {g : Game pw}\n  (h : g.play_move.act) :\n  \u2203 s' hs hs' hvm, s' = apply_D_move g.s (g.d.f g.s hs).m \u2227\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\u2081,\n    { exact h\u2081.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 \u27e8hs, hvm\u27e9 }, refl,\nend\n\nlemma act_play_move_of_A_hvm {pw : \u2115} {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\u2081; tauto }\n\n@[simp] lemma init_game_a_eq {pw : \u2115} {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 : \u2115} {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 : \u2115} {a : A pw} {d : D} {s : State} :\n  (init_game a d s).s = s := rfl\n\n@[simp] lemma set_state_s {pw : \u2115} {g : Game pw} {s : State} :\n  (g.set_state s).s = s := rfl\n\n-----\n\nlemma valid_state\u2080 {pw : \u2115} : valid_state pw state\u2080 :=\n\u27e8default, default, 0, rfl\u27e9\n\nlemma valid_A_state_play_D_move {pw : \u2115} {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 \u27e8a, d, n, h\u27e9,\n  let d\u2081 := d.set_move g.s (g.d.f g.s hs),\n  refine \u27e8a, d\u2081, n, _\u27e9,\n  have h\u2082 : (simulate a d\u2081 n).s = g.s,\n  {\n    revert hs,\n    rw \u2190h, clear h,\n    let s : State := _,\n    change (simulate a d n).s with s,\n    rintro hs d\u2081,\n    change s with (simulate a d n).s,\n    sorry\n  },\n  sorry {\n    simp [h, h\u2082],\n    use hs,\n    generalize_proofs h\u2083,\n    simp_rw [play_D_move_eq, set_state_s],\n    rw (_ : (simulate a d\u2081 n).d = d\u2081),\n    swap,\n    {\n      exact play_at_players_eq.2,\n    },\n    congr' 2,\n    {\n      rw h\u2082,\n    },\n    {\n      revert h\u2083,\n      rw h\u2082,\n      exact \u03bb _, heq_of_eq D_set_move_eq,\n    },\n  },\nend\n\nlemma valid_state_play_A_move {pw : \u2115} {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 : \u2115} {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\u2081,\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 : \u2115} {g : Game pw} {hs} :\n  (play_D_move_at g hs).act \u2194 g.act := by refl\n\n@[simp]\nlemma play_D_move_s {pw : \u2115} {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 {\u03b9 \u03b9' \u03b9\u2081 \u03b9\u2082 : Type*}\n\nnamespace complex_shape\n\n/-- An embedding `embedding c\u2081 c\u2082` between two complex shapes `\u03b9\u2081` and `\u03b9\u2082` is\nan injection `\u03b9\u2081 \u2192 \u03b9\u2082` 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\u2081 : complex_shape \u03b9\u2081) (c\u2082 : complex_shape \u03b9\u2082) :=\n(f : \u03b9\u2081 \u2192 \u03b9\u2082)\n(r : \u03b9\u2082 \u2192 option \u03b9\u2081)\n(eq_some : \u2200 i\u2082 i\u2081, r i\u2082 = some i\u2081 \u2194 f i\u2081 = i\u2082)\n(c : \u2200 \u2983i j\u2984, c\u2081.rel i j \u2192 c\u2082.rel (f i) (f j))\n\nnamespace embedding\n\n/-- extra condition which shall be useful to compare homology -/\ndef c_iff {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) : Prop :=\n\u2200 (i j), c\u2081.rel i j \u2194 c\u2082.rel (e.f i) (e.f j)\n\nlemma r_f {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (i : \u03b9\u2081) :\n  e.r (e.f i) = some i := by rw e.eq_some\n\nlemma r_none {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (i : \u03b9\u2082)\n  (hi: \u00ac\u2203 (i\u2081 : \u03b9\u2081), i = e.f i\u2081) : e.r i = none :=\nbegin\n  classical,\n  by_contra hi2,\n  apply hi,\n  obtain \u27e8j, hj\u27e9 := 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 `\u2124` to `option \u2115` which is `some n` on `n : \u2115 : \u2124` and `none otherwise. -/\ndef pos_int_to_onat : \u2124 \u2192 option \u2115\n| (n:\u2115)  := n\n| -[1+n] := none\n\n/-- The map from `\u2124` to `option \u2115` which is `some n` on `-(n : \u2115 : \u2124)` and `none otherwise. -/\ndef neg_int_to_onat : \u2124 \u2192 option \u2115\n| 0       := (0:\u2115)\n| (n+1:\u2115) := none\n| -[1+n]  := (n+1:\u2115)\n\n/-- The obvious embedding from the \u2115-indexed \"cohomological\" complex `* \u2192 * \u2192 * \u2192 ...`\n  to the corresponding \u2124-indexed complex. -/\ndef nat_up_int_up : embedding (complex_shape.up \u2115) (complex_shape.up \u2124) :=\n{ f := coe,\n  r := pos_int_to_onat,\n  eq_some := begin\n    rintro (i|i) i',\n    { split; { rintro \u27e8rfl\u27e9, refl }, },\n    { split; { rintro \u27e8\u27e9, } }\n  end,\n  c := by { rintro i j (rfl : _ = _), dsimp, refl } }\n\n/-- The obvious embedding from the \u2115-indexed \"homological\" complex `* \u2190 * \u2190 * \u2190 ...`\n  to the corresponding \u2124-indexed homological complex. -/\ndef nat_down_int_down : embedding (complex_shape.down \u2115) (complex_shape.down \u2124) :=\n{ f := coe,\n  r := pos_int_to_onat,\n  eq_some := begin\n    rintro (i|i) i',\n    { split; { rintro \u27e8rfl\u27e9, refl }, },\n    { split; { rintro \u27e8\u27e9, } }\n  end,\n  c := by { rintro i j (rfl : _ = _), dsimp, refl } }\n\n/-- Obvious embedding from the `\u2115`-indexed homological complex `* \u2190 * \u2190 * ...`\n  to `\u2124`-indexed cohomological complex ` ... \u2192 * \u2192 * \u2192 ...` sending $n$ to $-n$\n  on the corresponding map `\u2115 \u2192 \u2124`. -/\ndef nat_down_int_up : embedding (complex_shape.down \u2115) (complex_shape.up \u2124) :=\n{ f := -coe,\n  r := neg_int_to_onat,\n  eq_some := begin\n    rintro ((_|i)|i) (_|i'),\n    any_goals { split; { rintro \u27e8\u27e9, } },\n    any_goals { split; { rintro \u27e8rfl\u27e9, 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 \u2190 int.coe_nat_eq_coe_nat_iff,\n    simp only [int.coe_nat_succ],\n    linarith, },\nend\n\n/-- Obvious embedding from the `\u2115`-indexed cohomological complex `* \u2192 * \u2192 * ...`\n  to `\u2124`-indexed homological complex ` ... \u2190 * \u2190 * \u2190 ...` sending $n$ to $-n$\n  on the corresponding map `\u2115 \u2192 \u2124`. -/\ndef nat_up_int_down : embedding (complex_shape.up \u2115) (complex_shape.down \u2124) :=\n{ f := -coe,\n  r := neg_int_to_onat,\n  eq_some := begin\n    rintro ((_|i)|i) (_|i'),\n    any_goals { split; { rintro \u27e8\u27e9, } },\n    any_goals { split; { rintro \u27e8rfl\u27e9, 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\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082}\nvariables {c\u03b9 : complex_shape \u03b9} {c\u03b9' : complex_shape \u03b9'}\n\nvariables {\ud835\udc9e : Type*} [category \ud835\udc9e] [preadditive \ud835\udc9e] [has_zero_object \ud835\udc9e] -- 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 `\u03b9` of our complex,\nto the larger type `option \u03b9`, with `none` being sent to `zero`.\n\n-/\nvariable (X : homological_complex \ud835\udc9e c\u03b9)\n\n\n/-- If `\ud835\udc9e` is an abelian category,  and `(X\u1d62)\u1d62` is a `\ud835\udc9e`-valued homological\ncomplex on a complex-shape with index `\u03b9`, then `embed.X X oi` for `oi : option \u03b9`\nis the value `X\u1d62` of `h` at `some i` (an object of `\ud835\udc9e`), or `0` for `none`. -/\ndef embed.X : option \u03b9 \u2192 \ud835\udc9e\n| (some i) := X.X i\n| none     := 0\n\ndef embed.X_iso_of_none {e : option \u03b9} (he : e = none) :\n  embed.X X e \u2245 0 :=\nby { rw he, refl }\n\ndef embed.X_is_zero_of_none {e : option \u03b9} (he : e = none) :\n  is_zero (embed.X X e) :=\nis_zero.of_iso (category_theory.limits.is_zero_zero \ud835\udc9e) (embed.X_iso_of_none X he)\n\ndef embed.X_iso_of_some {e : option \u03b9} {i} (he : e = some i) :\n  embed.X X e \u2245 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 : \u03b9) : embed.X X (some i) = X.X i := rfl\n\n/-- The morphism `X\u1d62 \u2192 X\u2c7c` with `i j : option \u03b9` coming from the complex `X`.\nEqual to zero if either `i` or `j` is `none`.  -/\ndef embed.d : \u03a0 i j, embed.X X i \u27f6 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\u2081 e\u2082 : option \u03b9} (he : e\u2081 = none) :\n  embed.d X e\u2081 e\u2082 = 0 :=\nby { rw he, refl }\n\ndef embed.d_of_none_tgt {e\u2081 e\u2082 : option \u03b9} (he : e\u2082 = none) :\n  embed.d X e\u2081 e\u2082 = 0 :=\nby { rw he, cases e\u2081; refl }\n\ndef embed.d_of_some_of_some {e\u2081 e\u2082 : option \u03b9} {i j}\n  (h\u2081 : e\u2081 = some i) (h\u2082 : e\u2082 = some j) :\n  embed.d X e\u2081 e\u2082 = (embed.X_iso_of_some X h\u2081).hom \u226b X.d i j \u226b\n    (embed.X_iso_of_some X h\u2082).inv :=\nby { subst h\u2081, subst h\u2082, change _ = \ud835\udfd9 _ \u226b _ \u226b \ud835\udfd9 _, simpa }\n\n@[simp] lemma embed.d_some_some (i j : \u03b9) : embed.d X (some i) (some j) = X.d i j :=\nrfl\n\nlemma embed.d_ne_zero (e\u2081 e\u2082 : option \u03b9) (h : embed.d X e\u2081 e\u2082 \u2260 0) :\n  \u2203 (i j : \u03b9) (h\u2081 : e\u2081 = some i) (h\u2082 : e\u2082 = some j), X.d i j \u2260 0 :=\nbegin\n  rcases h\u2081 : e\u2081 with _ | \u27e8i\u27e9,\n  { exfalso,\n    apply h,\n    exact embed.d_of_none_src X h\u2081, },\n  { rcases h\u2082 : e\u2082 with _ | \u27e8j\u27e9,\n    { exfalso,\n      apply h,\n      exact embed.d_of_none_tgt X h\u2082, },\n    { substs h\u2081 h\u2082,\n      refine \u27e8i, j, rfl, rfl, h\u27e9, }, },\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 \u27f6 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 \u27f6 c) :=\n@unique.subsingleton _ (has_zero_object.unique_to c)\n\n@[simp] lemma embed.d_to_none (i : option \u03b9) : embed.d X i none = 0 :=\nby cases i; refl\n\n@[simp] lemma embed.d_of_none (i : option \u03b9) : embed.d X none i = 0 :=\nrfl\n\nlemma embed.shape : \u2200 (i j : option \u03b9)\n  (h : \u2200 (i' j' : \u03b9), i = some i' \u2192 j = some j' \u2192 \u00ac c\u03b9.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 : \u2200 i j k, embed.d X i j \u226b 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\u03b9.embedding c\u03b9')\n\n/-- Object-valued pushforward of `\ud835\udc9e`-valued homological complexes along an embedding\n  `\u03b9\u2081 \u21aa \u03b9\u2082` of complex-shapes (with all indexes not in the image going to `0`). -/\ndef embed.obj (X : homological_complex \ud835\udc9e c\u03b9) : homological_complex \ud835\udc9e c\u03b9' :=\n{ X := \u03bb i, embed.X X (e.r i),\n  d := \u03bb i j, embed.d X (e.r i) (e.r j),\n  shape' := \u03bb 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' := \u03bb i j k hij hjk, embed.d_comp_d X _ _ _ }\n\nvariables {X Y Z : homological_complex \ud835\udc9e c\u03b9} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n\n/-- Morphism-valued pushforward of `\ud835\udc9e`-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 : \u03a0 i, embed.X X i \u27f6 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 : \u03b9) : embed.f f (some i) = f.f i := rfl\n\nlemma embed.f_add {f g : X \u27f6 Y} : \u2200 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 :  \u2200 i j, embed.f f i \u226b embed.d Y i j = embed.d X i j \u226b embed.f f j\n| (some i) (some j) := f.comm _ _\n| (some i) none     := show _ \u226b 0 = 0 \u226b 0, by simp only [comp_zero]\n| none     j        := show 0 \u226b 0 = 0 \u226b _, by simp only [zero_comp]\n\n/-- Pushforward of a morphism `(X\u1d62)\u1d62 \u27f6 (Y\u1d62)\u1d62` of homological complexes with\n  the same complex-shape `\u03b9`, along an embedding of complex shapes c.embedding `\u03b9 \u2192 \u03b9'` -/\ndef embed.map : embed.obj e X \u27f6 embed.obj e Y :=\n{ f := \u03bb i, embed.f f _,\n  comm' := \u03bb i j hij, embed.comm f _ _ }\n\nlemma embed.f_id : \u2200 i, embed.f (\ud835\udfd9 X) i = \ud835\udfd9 (embed.X X i)\n| (some i) := rfl\n| none     := has_zero_object.from_zero_ext _ _\n\nlemma embed.f_comp : \u2200 i, embed.f (f \u226b g) i = embed.f f i \u226b embed.f g i\n| (some i) := rfl\n| none     := has_zero_object.from_zero_ext _ _\n\nlemma embed.f_of_some {e : option \u03b9} {i} (he : e = some i) :\n  embed.f f e =\n    (embed.X_iso_of_some _ he).hom \u226b\n    f.f i \u226b\n    (embed.X_iso_of_some _ he).inv :=\nby { subst he, change _ = \ud835\udfd9 _ \u226b _ \u226b \ud835\udfd9 _, simp, }\n\n/-- Functor pushing forward, for a fixed abelian category `\ud835\udc9e`, the category\nof `\ud835\udc9e`-valued homological complexes of shape `\u03b9\u2081` along an embedding `\u03b9\u2081 \u21aa \u03b9\u2082`\n(not Lean notation -- fix somehow?) of complexes. -/\ndef embed : homological_complex \ud835\udc9e c\u03b9 \u2964 homological_complex \ud835\udc9e c\u03b9' :=\n{ obj := embed.obj e,\n  map := \u03bb X Y f, embed.map e f,\n  map_id' := \u03bb 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 \ud835\udc9e c\u03b9 \u2964 homological_complex \ud835\udc9e c\u03b9').additive :=\n { map_add' := \u03bb X Y f g, by { ext, exact embed.f_add _, }, }\n\ndef embed_iso (i : \u03b9) : ((embed e).obj X).X (e.f i) \u2245 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' : \u03b9') (hi' : e.r i' = none) :\n  is_zero (embed e \u22d9 homological_complex.eval \ud835\udc9e _ 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' : \u03b9') (i : \u03b9) (hi' : e.r i' = some i) :\n  embed e \u22d9 homological_complex.eval \ud835\udc9e c\u03b9' i' \u2245 homological_complex.eval \ud835\udc9e c\u03b9 i :=\nnat_iso.of_components (\u03bb X, embed.X_iso_of_some X hi')\n  (\u03bb X\u2081 X\u2082 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 \ud835\udc9e \u2115) (i : \u2115) :\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 \ud835\udc9e \u2115) :\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 \ud835\udc9e \u2115) (i : \u2115) :\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\u2081 C\u2082 : chain_complex \ud835\udc9e \u2115) (f : C\u2081 \u27f6 C\u2082) (i : \u2115) :\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\u2081 C\u2082 : chain_complex \ud835\udc9e \u2115) (f : C\u2081 \u27f6 C\u2082) :\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\u2081 C\u2082 : chain_complex \ud835\udc9e \u2115) (f : C\u2081 \u27f6 C\u2082) (i : \u2115) :\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 \ud835\udc9e c\u03b9}\n\nvariables (f f' : X \u27f6 Y) (h : homotopy f f')\n\n/-- The morphism `h\u1d62\u2c7c: X\u1d62 \u27f6 Y\u2c7c` coming from a homotopy between two morphisms of type `X \u27f6 Y`.\n  Here `X` and `Y` are complexes of shape `\u03b9` and the indices `i j` run over `option \u03b9`. -/\ndef embed_homotopy_hom : \u03a0 (i j : option \u03b9), embed.X X i \u27f6 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 : \u03b9) :\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 \u03b9) :\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 \u03b9) :\n  embed_homotopy_hom f f' h none oi = 0 := rfl\n\nlemma embed_homotopy_zero : \u03a0 (oi oj : option \u03b9)\n  (H : \u2200 (i j : \u03b9), oi = some i \u2192 oj = some j \u2192 \u00ac c\u03b9.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\u03b9.embedding c\u03b9') :\n  homotopy ((embed e).map f) ((embed e).map f') :=\n{ hom := \u03bb i j, embed_homotopy_hom f f' h (e.r i) (e.r j),\n  zero' := \u03bb 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 := \u03bb i', begin\n    by_cases hi : \u2203 i : \u03b9, i' = e.f i,\n    { rcases hi with \u27e8i, rfl\u27e9,\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 : \u2203 j, c\u03b9.rel i j,\n        { rcases aux with \u27e8j, hj\u27e9,\n          rw [c\u03b9.next_eq' hj, c\u03b9'.next_eq' (e.c hj), e.r_f] },\n        { push_neg at aux,\n          induction x : e.r (c\u03b9'.next (e.f i));\n          simp only [X.shape _ _ (aux _), zero_comp], } },\n      { by_cases aux : \u2203 j, c\u03b9.rel j i,\n        { rcases aux with \u27e8j, hj\u27e9,\n          rw [c\u03b9.prev_eq' hj, c\u03b9'.prev_eq' (e.c hj), e.r_f] },\n        { push_neg at aux,\n          induction x : e.r (c\u03b9'.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') \u27f6 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 (\ud835\udcd0 : Type*) [category \ud835\udcd0] [preadditive \ud835\udcd0] (c\u2081 : complex_shape \u03b9\u2081) (i j : \u03b9\u2081)\n  (h : i = j) : eval \ud835\udcd0 c\u2081 i \u2245 eval \ud835\udcd0 c\u2081 j := eq_to_iso (by rw h)\n\ndef congr_prev_functor (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0] (c\u2081 : complex_shape \u03b9\u2081) (i j : \u03b9\u2081)\n  (h : i = j) : prev_functor \ud835\udcd0 c\u2081 i \u2245 prev_functor \ud835\udcd0 c\u2081 j := eq_to_iso (by rw h)\n\ndef congr_next_functor (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0] (c\u2081 : complex_shape \u03b9\u2081) (i j : \u03b9\u2081)\n  (h : i = j) : next_functor \ud835\udcd0 c\u2081 i \u2245 next_functor \ud835\udcd0 c\u2081 j := eq_to_iso (by rw h)\n\ndef embed_comp_eval (\ud835\udcd0 : Type*) [category \ud835\udcd0] [preadditive \ud835\udcd0] [has_zero_object \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (i\u2081 : \u03b9\u2081) :\n  embed e \u22d9 eval \ud835\udcd0 c\u2082 (e.f i\u2081) \u2245 eval \ud835\udcd0 c\u2081 i\u2081 :=\nnat_iso.of_components\n(\u03bb X, embed.X_iso_of_some X (e.r_f i\u2081))\n(\u03bb X Y f, begin\n  dsimp [embed, embed.map],\n  rw embed.f_of_some f (e.r_f i\u2081),\n  simp only [category.assoc, iso.inv_hom_id, category.comp_id],\nend)\n\n/-\ndef embed_comp_prev_functor (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (he : e.c_iff) (i\u2081 : \u03b9\u2081) :\n  embed e \u22d9 prev_functor \ud835\udcd0 c\u2082 (e.f i\u2081) \u2245 prev_functor \ud835\udcd0 c\u2081 i\u2081 :=\nbegin\n  rcases h\u2081 : c\u2081.prev i\u2081 with _ | \u27e8j, hj\u27e9,\n  { apply is_zero.iso,\n    { rcases h\u2082 : c\u2082.prev (e.f i\u2081) with _ | \u27e8k, hk\u27e9,\n      { apply functor.is_zero_of_comp,\n        exact prev_functor_is_zero _ _ _ h\u2082, },\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 \u27e8i, hi\u27e9,\n        rw [hi, \u2190 he] at hk,\n        rw c\u2081.prev_eq_some hk at h\u2081,\n        simpa only using h\u2081, }, },\n    { exact prev_functor_is_zero _ _ _ h\u2081, }, },\n  { exact iso_whisker_left (embed e) (prev_functor_iso_eval \ud835\udcd0 c\u2082 (e.f i\u2081) (e.f j) (e.c hj)) \u226a\u226b\n       embed_comp_eval \ud835\udcd0 e j \u226a\u226b\n       (prev_functor_iso_eval \ud835\udcd0 c\u2081 i\u2081 j hj).symm, }\nend\n\ndef embed_comp_next_functor (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (he : e.c_iff) (i\u2081 : \u03b9\u2081) :\n  embed e \u22d9 next_functor \ud835\udcd0 c\u2082 (e.f i\u2081) \u2245 next_functor \ud835\udcd0 c\u2081 i\u2081 :=\nbegin\n  rcases h\u2081 : c\u2081.next i\u2081 with _ | \u27e8j, hj\u27e9,\n  { apply is_zero.iso,\n    { rcases h\u2082 : c\u2082.next (e.f i\u2081) with _ | \u27e8k, hk\u27e9,\n      { apply functor.is_zero_of_comp,\n        exact next_functor_is_zero _ _ _ h\u2082, },\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 \u27e8i, hi\u27e9,\n        rw [hi, \u2190 he] at hk,\n        rw c\u2081.next_eq_some hk at h\u2081,\n        simpa only using h\u2081,}, },\n    { exact next_functor_is_zero _ _ _ h\u2081, }, },\n  { exact iso_whisker_left (embed e) (next_functor_iso_eval \ud835\udcd0 c\u2082 (e.f i\u2081) (e.f j) (e.c hj)) \u226a\u226b\n       embed_comp_eval \ud835\udcd0 e j \u226a\u226b\n       (next_functor_iso_eval \ud835\udcd0 c\u2081 i\u2081 j hj).symm }\nend\n\ndef embed_short_complex_functor_homological_complex_\u03c0\u2081 (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (he : e.c_iff)\n  (i\u2081 : \u03b9\u2081) (i\u2082 : \u03b9\u2082) (h\u2081\u2082 : e.f i\u2081 = i\u2082) :\n  (embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082) \u22d9 short_complex.\u03c0\u2081 \u2245\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u22d9 short_complex.\u03c0\u2081 :=\nfunctor.associator _ _ _ \u226a\u226b\n  iso_whisker_left (embed e)\n    (short_complex.functor_homological_complex_\u03c0\u2081_iso_prev_functor \ud835\udcd0 c\u2082 i\u2082) \u226a\u226b\n  (iso_whisker_left (embed e) (congr_prev_functor \ud835\udcd0 c\u2082 i\u2082 (e.f i\u2081) h\u2081\u2082.symm)) \u226a\u226b\n  embed_comp_prev_functor \ud835\udcd0 e he i\u2081 \u226a\u226b\n  (short_complex.functor_homological_complex_\u03c0\u2081_iso_prev_functor \ud835\udcd0 c\u2081 i\u2081).symm\n\ndef embed_short_complex_functor_homological_complex_\u03c0\u2082 (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (i\u2081 : \u03b9\u2081) (i\u2082 : \u03b9\u2082)\n  (h\u2081\u2082 : e.f i\u2081 = i\u2082) :\n  (embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082) \u22d9 short_complex.\u03c0\u2082 \u2245\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u22d9 short_complex.\u03c0\u2082 :=\nfunctor.associator _ _ _ \u226a\u226b\n  iso_whisker_left (embed e)\n    (short_complex.functor_homological_complex_\u03c0\u2082_iso_eval \ud835\udcd0 c\u2082 i\u2082) \u226a\u226b\n  (iso_whisker_left (embed e) (congr_eval \ud835\udcd0 c\u2082 i\u2082 (e.f i\u2081) h\u2081\u2082.symm)) \u226a\u226b\n  embed_comp_eval \ud835\udcd0 e i\u2081 \u226a\u226b\n  (short_complex.functor_homological_complex_\u03c0\u2082_iso_eval \ud835\udcd0 c\u2081 i\u2081).symm\n\ndef embed_short_complex_functor_homological_complex_\u03c0\u2083 (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (he : e.c_iff)\n  (i\u2081 : \u03b9\u2081) (i\u2082 : \u03b9\u2082) (h\u2081\u2082 : e.f i\u2081 = i\u2082) :\n  (embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082) \u22d9 short_complex.\u03c0\u2083 \u2245\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u22d9 short_complex.\u03c0\u2083 :=\nfunctor.associator _ _ _ \u226a\u226b\n  iso_whisker_left (embed e)\n    (short_complex.functor_homological_complex_\u03c0\u2083_iso_next_functor \ud835\udcd0 c\u2082 i\u2082) \u226a\u226b\n  (iso_whisker_left (embed e) (congr_next_functor \ud835\udcd0 c\u2082 i\u2082 (e.f i\u2081) h\u2081\u2082.symm)) \u226a\u226b\n  embed_comp_next_functor \ud835\udcd0 e he i\u2081 \u226a\u226b\n  (short_complex.functor_homological_complex_\u03c0\u2083_iso_next_functor \ud835\udcd0 c\u2081 i\u2081).symm\n\nlemma embed_d_to (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (he : e.c_iff)\n  (i\u2081 : \u03b9\u2081) (X : homological_complex \ud835\udcd0 c\u2081) :\n  ((embed e).obj X).d_to (e.f i\u2081) \u226b (embed.X_iso_of_some X (e.r_f i\u2081)).hom =\n  (embed_comp_prev_functor \ud835\udcd0 e he i\u2081).hom.app X \u226b X.d_to i\u2081 :=\nbegin\n  dsimp [embed_comp_prev_functor],\n  rcases h\u2081 : c\u2081.prev i\u2081 with _ | \u27e8j, hj\u27e9,\n  { simp only [h\u2081, d_to_eq_zero, comp_zero, preadditive.is_iso.comp_right_eq_zero],\n    rcases h\u2082 : c\u2082.prev (e.f i\u2081) with _ | \u27e8k, hk\u27e9,\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\u2082), },\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\u2083 : e.r k with _ | l,\n      { refl, },\n      { rw e.r_f i\u2081,\n        dsimp [embed.d],\n        by_cases h\u2084 : c\u2081.rel l i\u2081,\n        { exfalso,\n          simpa only [c\u2081.prev_eq_some h\u2084] using h\u2081, },\n        { exact X.shape _ _ h\u2084, }, }, }, },\n  { simp only [h\u2081, 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\u2081),\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 (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (he : e.c_iff)\n  (i\u2081 : \u03b9\u2081) (X : homological_complex \ud835\udcd0 c\u2081) :\n  ((embed e).obj X).d_from (e.f i\u2081) \u226b (embed_comp_next_functor \ud835\udcd0 e he i\u2081).hom.app X =\n  (embed.X_iso_of_some X (e.r_f i\u2081)).hom \u226b X.d_from i\u2081 :=\nbegin\n  dsimp [embed_comp_next_functor],\n  rcases h\u2081 : c\u2081.next i\u2081 with _ | \u27e8j, hj\u27e9,\n  { simp only [h\u2081, d_from_eq_zero, comp_zero, preadditive.is_iso.comp_right_eq_zero],\n    rcases h\u2082 : c\u2082.next (e.f i\u2081) with _ | \u27e8k, hk\u27e9,\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\u2082), },\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\u2083 : e.r k with _ | l,\n      { exact embed.d_of_none_tgt X rfl, },\n      { rw e.r_f i\u2081,\n        dsimp [embed.d],\n        by_cases h\u2084 : c\u2081.rel i\u2081 l,\n        { exfalso,\n          simpa only [c\u2081.next_eq_some h\u2084] using h\u2081, },\n        { exact X.shape _ _ h\u2084, }, }, }, },\n  { simp only [h\u2081, 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\u2081) (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 (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0]\n  {c\u2081 : complex_shape \u03b9\u2081} {c\u2082 : complex_shape \u03b9\u2082} (e : c\u2081.embedding c\u2082) (he : e.c_iff)\n  (i\u2081 : \u03b9\u2081) (i\u2082 : \u03b9\u2082) (h\u2081\u2082 : e.f i\u2081 = i\u2082) :\n  embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082 \u2245\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 :=\nbegin\n  refine short_complex.functor_nat_iso_mk\n    (embed_short_complex_functor_homological_complex_\u03c0\u2081 \ud835\udcd0 e he i\u2081 i\u2082 h\u2081\u2082)\n    (embed_short_complex_functor_homological_complex_\u03c0\u2082 \ud835\udcd0 e i\u2081 i\u2082 h\u2081\u2082)\n    (embed_short_complex_functor_homological_complex_\u03c0\u2083 \ud835\udcd0 e he i\u2081 i\u2082 h\u2081\u2082) _ _,\n  { subst h\u2081\u2082,\n    ext X,\n    dsimp [nat_trans.hcomp, embed_short_complex_functor_homological_complex_\u03c0\u2082,\n      short_complex.functor_homological_complex_\u03c0\u2082_iso_eval,\n      embed_short_complex_functor_homological_complex_\u03c0\u2081, congr_eval,\n      congr_prev_functor, embed_comp_eval, iso.refl,\n      short_complex.functor_homological_complex_\u03c0\u2081_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\u2081\u2082,\n    ext X,\n    dsimp [nat_trans.hcomp, embed_short_complex_functor_homological_complex_\u03c0\u2082,\n      short_complex.functor_homological_complex_\u03c0\u2082_iso_eval,\n      embed_short_complex_functor_homological_complex_\u03c0\u2083, congr_eval,\n      congr_prev_functor, embed_comp_eval, iso.refl,\n      short_complex.functor_homological_complex_\u03c0\u2083_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 (\ud835\udcd0 : Type*) [category \ud835\udcd0] [abelian \ud835\udcd0] (e : c\u2081.embedding c\u2082)\n  (i\u2081 : \u03b9\u2081) (i\u2082 : \u03b9\u2082)\n\n@[simp]\ndef embed_short_complex_\u03c0\u2081_\u03b9 :\n  embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082 \u22d9 short_complex.\u03c0\u2081 \u27f6\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u22d9 short_complex.\u03c0\u2081 :=\nbegin\n  by_cases e.r (c\u2082.prev i\u2082) = some (c\u2081.prev i\u2081),\n  { exact (embed_eval_iso_of_some e _ _ h).hom, },\n  { exact 0, },\nend\n\n@[simp]\ndef embed_short_complex_\u03c0\u2082_iso (h\u2081\u2082 : e.f i\u2081 = i\u2082) :\n  embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082 \u22d9 short_complex.\u03c0\u2082 \u2245\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u22d9 short_complex.\u03c0\u2082 :=\nembed_eval_iso_of_some e i\u2082 i\u2081 (by { rw [\u2190 h\u2081\u2082, e.r_f],})\n\n@[simp]\ndef embed_short_complex_\u03c0\u2083_\u03b9 :\n  embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082 \u22d9 short_complex.\u03c0\u2083 \u27f6\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u22d9 short_complex.\u03c0\u2083 :=\nbegin\n  by_cases e.r (c\u2082.next i\u2082) = some (c\u2081.next i\u2081),\n  { exact (embed_eval_iso_of_some e _ _ h).hom, },\n  { exact 0, },\nend\n\n-- @[simps]\ndef embed_short_complex_\u03b9 (h\u2081\u2082 : e.f i\u2081 = i\u2082) :\n  embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082 \u27f6\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 :=\nshort_complex.nat_trans_hom_mk\n  (embed_short_complex_\u03c0\u2081_\u03b9 \ud835\udcd0 e _ _)\n  (embed_short_complex_\u03c0\u2082_iso \ud835\udcd0 e _ _ h\u2081\u2082).hom\n  (embed_short_complex_\u03c0\u2083_\u03b9 \ud835\udcd0 e _ _)\nbegin\n  ext X,\n  subst h\u2081\u2082,\n  show (((embed e).obj X).d_to (e.f i\u2081) \u226b \ud835\udfd9 (((embed e).obj X).X (e.f i\u2081))) \u226b (embed.X_iso_of_some X _).hom =\n    (embed_short_complex_\u03c0\u2081_\u03b9 \ud835\udcd0 e i\u2081 (e.f i\u2081)).app X \u226b X.d_to i\u2081 \u226b \ud835\udfd9 (X.X i\u2081),\n  simp only [embed_short_complex_\u03c0\u2081_\u03b9, category.comp_id],\n  split_ifs with h,\n  { show embed.d X (e.r (c\u2082.prev (e.f i\u2081))) (e.r (e.f i\u2081)) \u226b (embed.X_iso_of_some X _).hom =\n      (embed.X_iso_of_some X h).hom \u226b X.d (c\u2081.prev i\u2081) i\u2081,\n    simp only [embed.d_of_some_of_some X h (e.r_f i\u2081),\n      category.assoc, iso.inv_hom_id, category.comp_id], },\n  { suffices : ((embed e).obj X).d_to (e.f i\u2081) = 0,\n    { simp only [this, nat_trans.app_zero, zero_comp], },\n    rcases h\u2082 : e.r (c\u2082.prev (e.f i\u2081)) with _ | j,\n    { apply is_zero.eq_of_src,\n      apply embed.X_is_zero_of_none,\n      exact h\u2082, },\n    { show embed.d X (e.r (c\u2082.prev (e.f i\u2081))) (e.r (e.f i\u2081)) = 0,\n      by_contra h',\n      rcases embed.d_ne_zero _ _ _ h' with \u27e8i, k, h\u2083, h\u2084, h\u2085\u27e9,\n      rw e.r_f at h\u2084,\n      rw h\u2082 at h\u2083,\n      simp only at h\u2084 h\u2083,\n      substs h\u2083 h\u2084,\n      have h\u2085' : c\u2081.rel j i\u2081,\n      { by_contra h\u2085'',\n        exact h\u2085 (X.shape _ _ h\u2085''), },\n      rw c\u2081.prev_eq' h\u2085' at h,\n      exact h h\u2082, }, },\nend\nbegin\n  ext X,\n  show (((embed e).obj X).d_from i\u2082 \u226b \ud835\udfd9 (((embed e).obj X).X_next i\u2082)) \u226b _ =\n    (embed.X_iso_of_some X _).hom \u226b X.d_from i\u2081 \u226b \ud835\udfd9 (X.X_next i\u2081),\n  dsimp only [embed_short_complex_\u03c0\u2083_\u03b9],\n  subst h\u2081\u2082,\n  split_ifs with h,\n  { simp only [category.comp_id],\n    show embed.d X (e.r (e.f i\u2081)) (e.r (c\u2082.next (e.f i\u2081))) \u226b (embed.X_iso_of_some X h).hom =\n      (embed.X_iso_of_some X _).hom \u226b X.d_from i\u2081,\n    simp only [embed.d_of_some_of_some X (e.r_f i\u2081) h,\n      category.assoc, iso.inv_hom_id, category.comp_id], },\n  { suffices : X.d i\u2081 (c\u2081.next i\u2081) = 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\u2082.next_eq' (e.c h) },\nend\n.\n\n@[simp]\ndef embed_short_complex_\u03c0\u2081_\u03c0 :\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u22d9 short_complex.\u03c0\u2081 \u27f6\n  embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082 \u22d9 short_complex.\u03c0\u2081 :=\nbegin\n  by_cases e.r (c\u2082.prev i\u2082) = some (c\u2081.prev i\u2081),\n  { exact (embed_eval_iso_of_some e _ _ h).inv, },\n  { exact 0, },\nend\n\n@[simp]\ndef embed_short_complex_\u03c0\u2083_\u03c0 :\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u22d9 short_complex.\u03c0\u2083 \u27f6\n  embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082 \u22d9 short_complex.\u03c0\u2083 :=\nbegin\n  by_cases e.r (c\u2082.next i\u2082) = some (c\u2081.next i\u2081),\n  { exact (embed_eval_iso_of_some e _ _ h).inv, },\n  { exact 0, },\nend\n\n@[simps]\ndef embed_short_complex_\u03c0 (h\u2081\u2082 : e.f i\u2081 = i\u2082) :\n  short_complex.functor_homological_complex \ud835\udcd0 c\u2081 i\u2081 \u27f6\n  embed e \u22d9 short_complex.functor_homological_complex \ud835\udcd0 c\u2082 i\u2082 :=\nshort_complex.nat_trans_hom_mk\n  (embed_short_complex_\u03c0\u2081_\u03c0 \ud835\udcd0 e _ _)\n  (embed_short_complex_\u03c0\u2082_iso \ud835\udcd0 e _ _ h\u2081\u2082).inv\n  (embed_short_complex_\u03c0\u2083_\u03c0 \ud835\udcd0 e _ _)\nbegin\n  ext X,\n  show (X.d_to i\u2081 \u226b \ud835\udfd9 (X.X i\u2081)) \u226b (embed.X_iso_of_some X _).inv =\n    _ \u226b ((embed e).obj X).d_to i\u2082 \u226b \ud835\udfd9 (((embed e).obj X).X i\u2082),\n  dsimp only [embed_short_complex_\u03c0\u2081_\u03c0],\n  subst h\u2081\u2082,\n  split_ifs with h,\n  { simp only [category.comp_id],\n    show X.d (c\u2081.prev i\u2081) i\u2081 \u226b (embed.X_iso_of_some X _).inv =\n      (embed.X_iso_of_some X h).inv \u226b embed.d X (e.r (c\u2082.prev (e.f i\u2081))) (e.r (e.f i\u2081)),\n    simp only [embed.d_of_some_of_some X h (e.r_f i\u2081), category.assoc, iso.inv_hom_id_assoc], },\n  { suffices : X.d (c\u2081.prev i\u2081) i\u2081 = 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\u2082.prev_eq' (e.c h) },\nend\nbegin\n  ext X,\n  show (X.d_from i\u2081 \u226b \ud835\udfd9 (X.X_next i\u2081)) \u226b _ =\n    (embed.X_iso_of_some X _).inv \u226b ((embed e).obj X).d_from i\u2082 \u226b \ud835\udfd9 (((embed e).obj X).X_next i\u2082),\n  dsimp only [embed_short_complex_\u03c0\u2083_\u03c0],\n  subst h\u2081\u2082,\n  split_ifs with h,\n  { simp only [category.comp_id],\n    show X.d i\u2081 (c\u2081.next i\u2081) \u226b (embed.X_iso_of_some X h).inv =\n      (embed.X_iso_of_some X _).inv \u226b embed.d X (e.r (e.f i\u2081)) (e.r (c\u2082.next (e.f i\u2081))),\n    simp only [embed.d_of_some_of_some X (e.r_f i\u2081) h, category.assoc, iso.inv_hom_id_assoc], },\n  { suffices : ((embed e).obj X).d_from (e.f i\u2081) = 0,\n    { simp only [this, nat_trans.app_zero, zero_comp, comp_zero], },\n    rcases h\u2082 : e.r (c\u2082.next (e.f i\u2081)) with _ | j,\n    { apply is_zero.eq_of_tgt,\n      apply embed.X_is_zero_of_none,\n      exact h\u2082, },\n    { show embed.d X (e.r (e.f i\u2081)) (e.r (c\u2082.next (e.f i\u2081))) = 0,\n      by_contra h',\n      rcases embed.d_ne_zero _ _ _ h' with \u27e8i, k, h\u2083, h\u2084, h\u2085\u27e9,\n      rw e.r_f at h\u2083,\n      rw h\u2082 at h\u2084,\n      simp only at h\u2084 h\u2083,\n      substs h\u2083 h\u2084,\n      have h\u2085' : c\u2081.rel i\u2081 j,\n      { by_contra h\u2085'',\n        exact h\u2085 (X.shape _ _ h\u2085''), },\n      rw c\u2081.next_eq' h\u2085' at h,\n      exact h h\u2082, }, },\nend\n\ndef homology_embed_nat_iso (h\u2081\u2082 : e.f i\u2081 = i\u2082) :\n  embed e \u22d9 homology_functor \ud835\udcd0 c\u2082 i\u2082 \u2245 homology_functor \ud835\udcd0 c\u2081 i\u2081 :=\n{ hom := embed_short_complex_\u03b9 \ud835\udcd0 e i\u2081 i\u2082 h\u2081\u2082 \u25eb (\ud835\udfd9 short_complex.homology_functor),\n  inv := embed_short_complex_\u03c0 \ud835\udcd0 e i\u2081 i\u2082 h\u2081\u2082 \u25eb (\ud835\udfd9 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      \u2190 functor.map_comp],\n    apply short_complex.homology_functor_map_eq_id,\n    simp only [short_complex.comp_\u03c4\u2082],\n    dsimp only [embed_short_complex_\u03b9, embed_short_complex_\u03c0],\n    simpa only [short_complex.nat_trans_hom_mk_app_\u03c4\u2082_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      \u2190 functor.map_comp],\n    apply short_complex.homology_functor_map_eq_id,\n    simp only [short_complex.comp_\u03c4\u2082],\n    dsimp only [embed_short_complex_\u03b9, embed_short_complex_\u03c0],\n    simpa only [short_complex.nat_trans_hom_mk_app_\u03c4\u2082_eq,\n      iso.inv_hom_id_app],\n  end, }\n\nend homology_comparison\n\nend homological_complex\n\nnamespace chain_complex\n\ndef single\u2080_comp_embed_iso_single_component (X : \ud835\udc9e) : \u03a0 (i : \u2124),\n  ((single\u2080 \ud835\udc9e \u22d9 homological_complex.embed complex_shape.embedding.nat_down_int_up).obj X).X i \u2245\n    ((homological_complex.single \ud835\udc9e (complex_shape.up \u2124) 0).obj X).X i\n| 0       := iso.refl _\n| (n+1:\u2115) := iso.refl _\n| -[1+n]  := iso.refl _\n\ndef single\u2080_comp_embed_iso_single :\n  single\u2080 \ud835\udc9e \u22d9 homological_complex.embed complex_shape.embedding.nat_down_int_up \u2245\n    homological_complex.single \ud835\udc9e (complex_shape.up \u2124) 0 :=\nnat_iso.of_components\n  (\u03bb X, homological_complex.hom.iso_of_components\n    (single\u2080_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 `\u22a2 P (x + x + x)` ~> `\u22a2 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\u03b1 a \u2192 Bool\n  | .atom _ => true\n  | _ => false\n\n/-- True if this represents an atomic expression. -/\ndef ExProd.isAtom : ExProd s\u03b1 a \u2192 Bool\n  | .mul va\u2081 (.const 1 _) (.const 1 _) => va\u2081.isAtom\n  | _ => false\n\n/-- True if this represents an atomic expression. -/\ndef ExSum.isAtom : ExSum s\u03b1 a \u2192 Bool\n  | .add va\u2081 va\u2082 => match va\u2082 with -- FIXME: this takes a while to compile as one match\n    | .zero => va\u2081.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 \u2192 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 \u21a6 do\n    let pre e :=\n      try\n        guard <| root || parent != e -- recursion guard\n        let e \u2190 withReducible <| whnf e\n        guard e.isApp -- all interesting ring expressions are applications\n        let \u27e8.succ u, \u03b1, e\u27e9 \u2190 inferTypeQ e | failure\n        let s\u03b1 \u2190 synthInstanceQ (q(CommSemiring $\u03b1) : Q(Type u))\n        let c \u2190 mkCache s\u03b1\n        let \u27e8a, _, pa\u27e9 \u2190 match \u2190 isAtomOrDerivable s\u03b1 c e rctx s with\n        | none => eval s\u03b1 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 \u2190 nctx.simp { expr := a, proof? := pa }\n        if \u2190 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 \u00b7 fun _ \u21a6 none)\n    (\u00b7.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 \u03b1) : MetaM \u03b1 := do\n  let ctx := {\n    simpTheorems := #[\u2190 Elab.Tactic.simpOnlyBuiltins.foldlM (\u00b7.addConst \u00b7) {}]\n    congrTheorems := \u2190 getSimpCongrTheorems }\n  let simp \u2190 match cfg.mode with\n  | .raw => pure pure\n  | .SOP =>\n    let thms : SimpTheorems := {}\n    let thms \u2190 [``add_zero, ``add_assoc_rev, ``_root_.mul_one, ``mul_assoc_rev,\n      ``_root_.pow_one, ``mul_neg, ``add_neg].foldlM (\u00b7.addConst \u00b7) thms\n    let thms \u2190 [``nat_rawCast_0, ``nat_rawCast_1, ``nat_rawCast_2, ``int_rawCast_1, ``int_rawCast_2,\n      ``rat_rawCast_2].foldlM (\u00b7.addConst \u00b7 (post := false)) thms\n    let ctx' := { ctx with simpTheorems := #[thms] }\n    pure fun r' : Simp.Result \u21a6 do\n      Simp.mkEqTrans r' (\u2190 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 \u21a6 rewrite e false nctx rctx s\n      else fun e \u21a6 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 (\u2190 IO.mkRef {}) { recursive := false } fun nctx _ _ =>\n    return (\u2190 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 \u2190 getMainGoal\n  let tgt \u2190 instantiateMVars (\u2190 goal.getType)\n  let r \u2190 M.run s cfg <| rewrite tgt\n  if r.expr.isConstOf ``True then\n    goal.assign (\u2190 mkOfEqTrue (\u2190 r.getProof))\n    replaceMainGoal []\n  else\n    replaceMainGoal [\u2190 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 \u2190 instantiateMVars (\u2190 fvarId.getType)\n  let goal \u2190 getMainGoal\n  let myres \u2190 M.run s cfg <| rewrite tgt\n  match \u2190 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 \u2190 elabConfig cfg\n  if tk.isSome then cfg := { cfg with red := .default }\n  let loc := (loc.map expandLocation).getD (.targets #[] true)\n  let s \u2190 IO.mkRef {}\n  withLocation loc (ringNFLocalDecl s cfg) (ringNFTarget s cfg)\n    fun _ \u21a6 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 \u2190 elabConfig cfg\n  if tk.isSome then cfg := { cfg with red := .default }\n  let s \u2190 IO.mkRef {}\n  liftMetaMAtMain fun g \u21a6 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 \u21a6 match stx with\n  | `(conv| ring_nf $[!%$tk]? $(_cfg)?) => withMainContext do\n    let mut cfg \u2190 elabConfig stx[2]\n    if tk.isSome then cfg := { cfg with red := .default }\n    let s \u2190 IO.mkRef {}\n    Conv.applySimpResult (\u2190 M.run s cfg <| rewrite (\u2190 instantiateMVars (\u2190 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 : \u2115) (m : \u2124) : 2^(n+1) * m = 2 * 2^n * m := by ring\nexample (a b : \u2124) (n : \u2115) : (a + b)^(n + 2) = (a^2 + b^2 + a * b + b * a) * (a + b)^n := by ring\nexample (x y : \u2115) : 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 {\u03b1 : Type _}\n\nnamespace WithTop\n\nvariable [DecidableEq \u03b1]\n\nsection Mul\n\nvariable [Zero \u03b1] [Mul \u03b1]\n\ninstance : MulZeroClass (WithTop \u03b1) where\n  zero := 0\n  mul m n := if m = 0 \u2228 n = 0 then 0 else Option.map\u2082 (\u00b7 * \u00b7) 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (ite.{succ u1} (WithTop.{u1} \u03b1) (Or (Eq.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (Eq.{succ u1} (WithTop.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))))) (Or.decidable (Eq.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (Eq.{succ u1} (WithTop.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (Option.decidableEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (Option.decidableEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) b (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (Option.map\u2082.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _inst_3)) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (ite.{succ u1} (WithTop.{u1} \u03b1) (Or (Eq.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (Eq.{succ u1} (WithTop.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (instDecidableOr (Eq.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (Eq.{succ u1} (WithTop.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (WithTop.instDecidableEqWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (WithTop.instDecidableEqWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) b (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))) (Option.map\u2082.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.200 : \u03b1) (x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.202 : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _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\u2093'. -/\ntheorem mul_def {a b : WithTop \u03b1} : a * b = if a = 0 \u2228 b = 0 then 0 else Option.map\u2082 (\u00b7 * \u00b7) 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1}, Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (ite.{succ u1} (WithTop.{u1} \u03b1) (Eq.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (Option.decidableEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] (a : WithTop.{u1} \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) (ite.{succ u1} (WithTop.{u1} \u03b1) (Eq.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (WithTop.instDecidableEqWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_top' WithTop.mul_top'\u2093'. -/\ntheorem mul_top' {a : WithTop \u03b1} : a * \u22a4 = if a = 0 then 0 else \u22a4 := 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1}, (Ne.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) -> (Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1}, (Ne.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) -> (Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_top WithTop.mul_top\u2093'. -/\n@[simp]\ntheorem mul_top {a : WithTop \u03b1} (h : a \u2260 0) : a * \u22a4 = \u22a4 := 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1}, Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)) a) (ite.{succ u1} (WithTop.{u1} \u03b1) (Eq.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (Option.decidableEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] (a : WithTop.{u1} \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)) a) (ite.{succ u1} (WithTop.{u1} \u03b1) (Eq.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (WithTop.instDecidableEqWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_top.top_mul' WithTop.top_mul'\u2093'. -/\ntheorem top_mul' {a : WithTop \u03b1} : \u22a4 * a = if a = 0 then 0 else \u22a4 := 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1}, (Ne.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) -> (Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)) a) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1}, (Ne.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) -> (Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)) a) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_top.top_mul WithTop.top_mul\u2093'. -/\n@[simp]\ntheorem top_mul {a : WithTop \u03b1} (h : a \u2260 0) : \u22a4 * a = \u22a4 := 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1], Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1], Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))\nCase conversion may be inaccurate. Consider using '#align with_top.top_mul_top WithTop.top_mul_top\u2093'. -/\n@[simp]\ntheorem top_mul_top : (\u22a4 * \u22a4 : WithTop \u03b1) = \u22a4 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Iff (Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (Or (And (Ne.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))) (Eq.{succ u1} (WithTop.{u1} \u03b1) b (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))) (And (Eq.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (Ne.{succ u1} (WithTop.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Iff (Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) (Or (And (Ne.{succ u1} (WithTop.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2)))) (Eq.{succ u1} (WithTop.{u1} \u03b1) b (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)))) (And (Eq.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) (Ne.{succ u1} (WithTop.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_eq_top_iff WithTop.mul_eq_top_iff\u2093'. -/\ntheorem mul_eq_top_iff {a b : WithTop \u03b1} : a * b = \u22a4 \u2194 a \u2260 0 \u2227 b = \u22a4 \u2228 a = \u22a4 \u2227 b \u2260 0 :=\n  by\n  rw [mul_def, ite_eq_iff, \u2190 none_eq_top, Option.map\u2082_eq_none_iff]\n  have ha : a = 0 \u2192 a \u2260 none := fun h => h.symm \u25b8 zero_ne_top\n  have hb : b = 0 \u2192 b \u2260 none := fun h => h.symm \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] [_inst_4 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_4) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_4) b (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_4) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] [_inst_4 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_4) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_4) b (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_4) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_lt_top' WithTop.mul_lt_top'\u2093'. -/\ntheorem mul_lt_top' [LT \u03b1] {a b : WithTop \u03b1} (ha : a < \u22a4) (hb : b < \u22a4) : a * b < \u22a4 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] [_inst_4 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (Ne.{succ u1} (WithTop.{u1} \u03b1) b (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_4) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] [_inst_4 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (Ne.{succ u1} (WithTop.{u1} \u03b1) b (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_4) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_lt_top WithTop.mul_lt_top\u2093'. -/\ntheorem mul_lt_top [LT \u03b1] {a b : WithTop \u03b1} (ha : a \u2260 \u22a4) (hb : b \u2260 \u22a4) : a * b < \u22a4 :=\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 \u03b1] : NoZeroDivisors (WithTop \u03b1) :=\n  by\n  refine' \u27e8fun a b h\u2081 => Decidable.by_contradiction fun h\u2082 => _\u27e9\n  rw [mul_def, if_neg h\u2082] at h\u2081\n  rcases Option.mem_map\u2082_iff.1 h\u2081 with \u27e8a, b, rfl : _ = _, rfl : _ = _, hab\u27e9\n  exact h\u2082 ((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 \u03b1]\n\n/- warning: with_top.coe_mul -> WithTop.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Eq.{succ u1} (WithTop.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)) a b)) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2) (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Eq.{succ u1} (WithTop.{u1} \u03b1) (WithTop.some.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 _inst_2)) a b)) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toZero.{u1} \u03b1 _inst_2) (MulZeroClass.toMul.{u1} \u03b1 _inst_2)))) (WithTop.some.{u1} \u03b1 a) (WithTop.some.{u1} \u03b1 b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_mul WithTop.coe_mul\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_mul {a b : \u03b1} : (\u2191(a * b) : WithTop \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] {b : \u03b1}, (Ne.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2))))) -> (forall {a : WithTop.{u1} \u03b1}, Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2) (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)))) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b)) (Option.bind.{u1, u1} \u03b1 \u03b1 a (fun (a : \u03b1) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (Option.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (coeOption.{u1} \u03b1))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)) a b))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] {b : \u03b1}, (Ne.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MulZeroClass.toZero.{u1} \u03b1 _inst_2)))) -> (forall {a : WithTop.{u1} \u03b1}, Eq.{succ u1} (WithTop.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toZero.{u1} \u03b1 _inst_2) (MulZeroClass.toMul.{u1} \u03b1 _inst_2)))) a (WithTop.some.{u1} \u03b1 b)) (Option.bind.{u1, u1} \u03b1 \u03b1 a (fun (a : \u03b1) => Option.some.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 _inst_2)) a b))))\nCase conversion may be inaccurate. Consider using '#align with_top.mul_coe WithTop.mul_coe\u2093'. -/\ntheorem mul_coe {b : \u03b1} (hb : b \u2260 0) : \u2200 {a : WithTop \u03b1}, a * b = a.bind fun a : \u03b1 => \u2191(a * b)\n  | none =>\n    show (if (\u22a4 : WithTop \u03b1) = 0 \u2228 (b : WithTop \u03b1) = 0 then 0 else \u22a4 : WithTop \u03b1) = \u22a4 by simp [hb]\n  | some a => show \u2191a * \u2191b = \u2191(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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] (a : WithTop.{u1} \u03b1) (b : WithTop.{u1} \u03b1), Eq.{succ u1} \u03b1 (WithTop.untop'.{u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2)))) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithTop.{u1} \u03b1) (WithTop.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2) (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)))) a b)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)) (WithTop.untop'.{u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2)))) a) (WithTop.untop'.{u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2)))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] (a : WithTop.{u1} \u03b1) (b : WithTop.{u1} \u03b1), Eq.{succ u1} \u03b1 (WithTop.untop'.{u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MulZeroClass.toZero.{u1} \u03b1 _inst_2))) (HMul.hMul.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHMul.{u1} (WithTop.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithTop.{u1} \u03b1) (WithTop.instMulZeroClassWithTop.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toZero.{u1} \u03b1 _inst_2) (MulZeroClass.toMul.{u1} \u03b1 _inst_2)))) a b)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 _inst_2)) (WithTop.untop'.{u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MulZeroClass.toZero.{u1} \u03b1 _inst_2))) a) (WithTop.untop'.{u1} \u03b1 (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MulZeroClass.toZero.{u1} \u03b1 _inst_2))) b))\nCase conversion may be inaccurate. Consider using '#align with_top.untop'_zero_mul WithTop.untop'_zero_mul\u2093'. -/\n@[simp]\ntheorem untop'_zero_mul (a b : WithTop \u03b1) : (a * b).untop' 0 = a.untop' 0 * b.untop' 0 :=\n  by\n  by_cases ha : a = 0;\n  \u00b7 rw [ha, MulZeroClass.zero_mul, \u2190 coe_zero, untop'_coe, MulZeroClass.zero_mul]\n  by_cases hb : b = 0;\n  \u00b7 rw [hb, MulZeroClass.mul_zero, \u2190 coe_zero, untop'_coe, MulZeroClass.mul_zero]\n  induction a using WithTop.recTopCoe; \u00b7 rw [top_mul hb, untop'_top, MulZeroClass.zero_mul]\n  induction b using WithTop.recTopCoe; \u00b7 rw [mul_top ha, untop'_top, MulZeroClass.mul_zero]\n  rw [\u2190 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 \u03b1` is needed here as otherwise we have `1 * \u22a4 = \u22a4` but also `0 * \u22a4 = 0`. -/\ninstance [MulZeroOneClass \u03b1] [Nontrivial \u03b1] : MulZeroOneClass (WithTop \u03b1) :=\n  { WithTop.mulZeroClass with\n    mul := (\u00b7 * \u00b7)\n    one := 1\n    zero := 0\n    one_mul := fun a =>\n      match a with\n      | \u22a4 => mul_top (mt coe_eq_coe.1 one_ne_zero)\n      | (a : \u03b1) => by rw [\u2190 coe_one, \u2190 coe_mul, one_mul]\n    mul_one := fun a =>\n      match a with\n      | \u22a4 => top_mul (mt coe_eq_coe.1 one_ne_zero)\n      | (a : \u03b1) => by rw [\u2190 coe_one, \u2190 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\u2093'. -/\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 \u2192*\u2080 S)\n    (hf : Function.Injective f) : WithTop R \u2192*\u2080 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 : \u2200 z, map f z = 0 \u2194 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      \u00b7 simp\n      rcases Decidable.eq_or_ne y 0 with (rfl | hy)\n      \u00b7 simp\n      induction x using WithTop.recTopCoe\n      \u00b7 simp [hy, this]\n      induction y using WithTop.recTopCoe\n      \u00b7 have : (f x : WithTop S) \u2260 0 := by simpa [hf.eq_iff' (map_zero f)] using hx\n        simp [hx, this]\n      simp only [\u2190 coe_mul, map_coe, map_mul] }\n#align monoid_with_zero_hom.with_top_map MonoidWithZeroHom.withTopMap\n\ninstance [SemigroupWithZero \u03b1] [NoZeroDivisors \u03b1] : SemigroupWithZero (WithTop \u03b1) :=\n  { WithTop.mulZeroClass with\n    mul := (\u00b7 * \u00b7)\n    zero := 0\n    mul_assoc := fun a b c => by\n      rcases eq_or_ne a 0 with (rfl | ha); \u00b7 simp only [MulZeroClass.zero_mul]\n      rcases eq_or_ne b 0 with (rfl | hb);\n      \u00b7 simp only [MulZeroClass.zero_mul, MulZeroClass.mul_zero]\n      rcases eq_or_ne c 0 with (rfl | hc); \u00b7 simp only [MulZeroClass.mul_zero]\n      induction a using WithTop.recTopCoe; \u00b7 simp [hb, hc]\n      induction b using WithTop.recTopCoe; \u00b7 simp [ha, hc]\n      induction c using WithTop.recTopCoe; \u00b7 simp [ha, hb]\n      simp only [\u2190 coe_mul, mul_assoc] }\n\ninstance [MonoidWithZero \u03b1] [NoZeroDivisors \u03b1] [Nontrivial \u03b1] : MonoidWithZero (WithTop \u03b1) :=\n  { WithTop.mulZeroOneClass, WithTop.semigroupWithZero with }\n\ninstance [CommMonoidWithZero \u03b1] [NoZeroDivisors \u03b1] [Nontrivial \u03b1] :\n    CommMonoidWithZero (WithTop \u03b1) :=\n  { WithTop.monoidWithZero with\n    mul := (\u00b7 * \u00b7)\n    zero := 0\n    mul_comm := fun a b => by\n      simp only [or_comm', mul_def, mul_comm, @Option.map\u2082_comm _ _ _ _ a b _ mul_comm] }\n\nvariable [CanonicallyOrderedCommSemiring \u03b1]\n\nprivate theorem distrib' (a b c : WithTop \u03b1) : (a + b) * c = a * c + b * c :=\n  by\n  induction c using WithTop.recTopCoe\n  \u00b7 by_cases ha : a = 0 <;> simp [ha]\n  \u00b7 by_cases hc : c = 0\n    \u00b7 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 \u03b1] : CommSemiring (WithTop \u03b1) :=\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 \u03b1] : CanonicallyOrderedCommSemiring (WithTop \u03b1) :=\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\u2093'. -/\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 \u2192+* S)\n    (hf : Function.Injective f) : WithTop R \u2192+* 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 \u03b1]\n\nsection Mul\n\nvariable [Zero \u03b1] [Mul \u03b1]\n\ninstance : MulZeroClass (WithBot \u03b1) :=\n  WithTop.mulZeroClass\n\n/- warning: with_bot.mul_def -> WithBot.mul_def is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (ite.{succ u1} (WithBot.{u1} \u03b1) (Or (Eq.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2))))) (Eq.{succ u1} (WithBot.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2)))))) (Or.decidable (Eq.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2))))) (Eq.{succ u1} (WithBot.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2))))) (Option.decidableEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2))))) (Option.decidableEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) b (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2)))))) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2)))) (Option.map\u2082.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _inst_3)) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (ite.{succ u1} (WithBot.{u1} \u03b1) (Or (Eq.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2)))) (Eq.{succ u1} (WithBot.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2))))) (instDecidableOr (Eq.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2)))) (Eq.{succ u1} (WithBot.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2)))) (WithBot.instDecidableEqWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2)))) (WithBot.instDecidableEqWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) b (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2))))) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2))) (Option.map\u2082.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.3008 : \u03b1) (x._@.Mathlib.Algebra.Order.Ring.WithTop._hyg.3010 : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _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\u2093'. -/\ntheorem mul_def {a b : WithBot \u03b1} : a * b = if a = 0 \u2228 b = 0 then 0 else Option.map\u2082 (\u00b7 * \u00b7) 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithBot.{u1} \u03b1}, (Ne.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2))))) -> (Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithBot.{u1} \u03b1}, (Ne.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2)))) -> (Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1))) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_bot.mul_bot WithBot.mul_bot\u2093'. -/\n@[simp]\ntheorem mul_bot {a : WithBot \u03b1} (h : a \u2260 0) : a * \u22a5 = \u22a5 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithBot.{u1} \u03b1}, (Ne.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2))))) -> (Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) a) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithBot.{u1} \u03b1}, (Ne.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2)))) -> (Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) a) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_mul WithBot.bot_mul\u2093'. -/\n@[simp]\ntheorem bot_mul {a : WithBot \u03b1} (h : a \u2260 0) : \u22a5 * a = \u22a5 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1], Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1], Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1))) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_mul_bot WithBot.bot_mul_bot\u2093'. -/\n@[simp]\ntheorem bot_mul_bot : (\u22a5 * \u22a5 : WithBot \u03b1) = \u22a5 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Iff (Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (Or (And (Ne.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2))))) (Eq.{succ u1} (WithBot.{u1} \u03b1) b (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)))) (And (Eq.{succ u1} (WithBot.{u1} \u03b1) a (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (Ne.{succ u1} (WithBot.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 0 (Zero.zero.{u1} (WithBot.{u1} \u03b1) (WithBot.hasZero.{u1} \u03b1 _inst_2)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Iff (Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1))) (Or (And (Ne.{succ u1} (WithBot.{u1} \u03b1) a (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2)))) (Eq.{succ u1} (WithBot.{u1} \u03b1) b (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)))) (And (Eq.{succ u1} (WithBot.{u1} \u03b1) a (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1))) (Ne.{succ u1} (WithBot.{u1} \u03b1) b (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithBot.{u1} \u03b1) (WithBot.zero.{u1} \u03b1 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align with_bot.mul_eq_bot_iff WithBot.mul_eq_bot_iff\u2093'. -/\ntheorem mul_eq_bot_iff {a b : WithBot \u03b1} : a * b = \u22a5 \u2194 a \u2260 0 \u2227 b = \u22a5 \u2228 a = \u22a5 \u2227 b \u2260 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] [_inst_4 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_4) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) a) -> (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_4) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) b) -> (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_4) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] [_inst_4 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_4) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) a) -> (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_4) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) b) -> (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_4) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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'\u2093'. -/\ntheorem bot_lt_mul' [LT \u03b1] {a b : WithBot \u03b1} (ha : \u22a5 < a) (hb : \u22a5 < b) : \u22a5 < a * b :=\n  @WithTop.mul_lt_top' \u03b1\u1d52\u1d48 _ _ _ _ _ _ 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] [_inst_4 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, (Ne.{succ u1} (WithBot.{u1} \u03b1) a (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) -> (Ne.{succ u1} (WithBot.{u1} \u03b1) b (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) -> (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_4) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) _inst_2 _inst_3))) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : Zero.{u1} \u03b1] [_inst_3 : Mul.{u1} \u03b1] [_inst_4 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, (Ne.{succ u1} (WithBot.{u1} \u03b1) a (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1))) -> (Ne.{succ u1} (WithBot.{u1} \u03b1) b (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1))) -> (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_4) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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\u2093'. -/\ntheorem bot_lt_mul [LT \u03b1] {a b : WithBot \u03b1} (ha : a \u2260 \u22a5) (hb : b \u2260 \u22a5) : \u22a5 < a * b :=\n  @WithTop.mul_lt_top \u03b1\u1d52\u1d48 _ _ _ _ _ _ ha hb\n#align with_bot.bot_lt_mul WithBot.bot_lt_mul\n\nend Mul\n\nsection MulZeroClass\n\nvariable [MulZeroClass \u03b1]\n\n/- warning: with_bot.coe_mul -> WithBot.coe_mul is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Eq.{succ u1} (WithBot.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)) a b)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2) (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Eq.{succ u1} (WithBot.{u1} \u03b1) (WithBot.some.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 _inst_2)) a b)) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toZero.{u1} \u03b1 _inst_2) (MulZeroClass.toMul.{u1} \u03b1 _inst_2)))) (WithBot.some.{u1} \u03b1 a) (WithBot.some.{u1} \u03b1 b))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_mul WithBot.coe_mul\u2093'. -/\n@[norm_cast]\ntheorem coe_mul {a b : \u03b1} : (\u2191(a * b) : WithBot \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] {b : \u03b1}, (Ne.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2))))) -> (forall {a : WithBot.{u1} \u03b1}, Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toHasMul.{u1} (WithBot.{u1} \u03b1) (WithBot.mulZeroClass.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toHasZero.{u1} \u03b1 _inst_2) (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)))) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b)) (Option.bind.{u1, u1} \u03b1 \u03b1 a (fun (a : \u03b1) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (Option.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (coeOption.{u1} \u03b1))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 _inst_2)) a b))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : MulZeroClass.{u1} \u03b1] {b : \u03b1}, (Ne.{succ u1} \u03b1 b (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MulZeroClass.toZero.{u1} \u03b1 _inst_2)))) -> (forall {a : WithBot.{u1} \u03b1}, Eq.{succ u1} (WithBot.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHMul.{u1} (WithBot.{u1} \u03b1) (MulZeroClass.toMul.{u1} (WithBot.{u1} \u03b1) (WithBot.instMulZeroClassWithBot.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (MulZeroClass.toZero.{u1} \u03b1 _inst_2) (MulZeroClass.toMul.{u1} \u03b1 _inst_2)))) a (WithBot.some.{u1} \u03b1 b)) (Option.bind.{u1, u1} \u03b1 \u03b1 a (fun (a : \u03b1) => Option.some.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 _inst_2)) a b))))\nCase conversion may be inaccurate. Consider using '#align with_bot.mul_coe WithBot.mul_coe\u2093'. -/\ntheorem mul_coe {b : \u03b1} (hb : b \u2260 0) {a : WithBot \u03b1} : a * b = a.bind fun a : \u03b1 => \u2191(a * b) :=\n  WithTop.mul_coe hb\n#align with_bot.mul_coe WithBot.mul_coe\n\nend MulZeroClass\n\n/-- `nontrivial \u03b1` is needed here as otherwise we have `1 * \u22a5 = \u22a5` but also `= 0 * \u22a5 = 0`. -/\ninstance [MulZeroOneClass \u03b1] [Nontrivial \u03b1] : MulZeroOneClass (WithBot \u03b1) :=\n  WithTop.mulZeroOneClass\n\ninstance [MulZeroClass \u03b1] [NoZeroDivisors \u03b1] : NoZeroDivisors (WithBot \u03b1) :=\n  WithTop.noZeroDivisors\n\ninstance [SemigroupWithZero \u03b1] [NoZeroDivisors \u03b1] : SemigroupWithZero (WithBot \u03b1) :=\n  WithTop.semigroupWithZero\n\ninstance [MonoidWithZero \u03b1] [NoZeroDivisors \u03b1] [Nontrivial \u03b1] : MonoidWithZero (WithBot \u03b1) :=\n  WithTop.monoidWithZero\n\ninstance [CommMonoidWithZero \u03b1] [NoZeroDivisors \u03b1] [Nontrivial \u03b1] :\n    CommMonoidWithZero (WithBot \u03b1) :=\n  WithTop.commMonoidWithZero\n\ninstance [CanonicallyOrderedCommSemiring \u03b1] [Nontrivial \u03b1] : CommSemiring (WithBot \u03b1) :=\n  WithTop.commSemiring\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [PosMulMono \u03b1] : PosMulMono (WithBot \u03b1) :=\n  \u27e8by\n    rintro \u27e8x, x0\u27e9 a b h; simp only [Subtype.coe_mk]\n    rcases eq_or_ne x 0 with (rfl | x0'); \u00b7 simp\n    lift x to \u03b1;\n    \u00b7 rintro \u27e8rfl\u27e9\n      exact (WithBot.bot_lt_coe (0 : \u03b1)).not_le x0\n    induction a using WithBot.recBotCoe; \u00b7 simp_rw [mul_bot x0', bot_le]\n    induction b using WithBot.recBotCoe; \u00b7 exact absurd h (bot_lt_coe a).not_le\n    simp only [\u2190 coe_mul, coe_le_coe] at *\n    norm_cast  at x0\n    exact mul_le_mul_of_nonneg_left h x0\u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [MulPosMono \u03b1] : MulPosMono (WithBot \u03b1) :=\n  \u27e8by\n    rintro \u27e8x, x0\u27e9 a b h; simp only [Subtype.coe_mk]\n    rcases eq_or_ne x 0 with (rfl | x0'); \u00b7 simp\n    lift x to \u03b1;\n    \u00b7 rintro \u27e8rfl\u27e9\n      exact (WithBot.bot_lt_coe (0 : \u03b1)).not_le x0\n    induction a using WithBot.recBotCoe; \u00b7 simp_rw [bot_mul x0', bot_le]\n    induction b using WithBot.recBotCoe; \u00b7 exact absurd h (bot_lt_coe a).not_le\n    simp only [\u2190 coe_mul, coe_le_coe] at *\n    norm_cast  at x0\n    exact mul_le_mul_of_nonneg_right h x0\u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [PosMulStrictMono \u03b1] : PosMulStrictMono (WithBot \u03b1) :=\n  \u27e8by\n    rintro \u27e8x, x0\u27e9 a b h; simp only [Subtype.coe_mk]\n    lift x to \u03b1 using x0.ne_bot\n    induction b using WithBot.recBotCoe; \u00b7 exact absurd h not_lt_bot\n    induction a using WithBot.recBotCoe; \u00b7 simp_rw [mul_bot x0.ne.symm, \u2190 coe_mul, bot_lt_coe]\n    simp only [\u2190 coe_mul, coe_lt_coe] at *\n    norm_cast  at x0\n    exact mul_lt_mul_of_pos_left h x0\u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [MulPosStrictMono \u03b1] : MulPosStrictMono (WithBot \u03b1) :=\n  \u27e8by\n    rintro \u27e8x, x0\u27e9 a b h; simp only [Subtype.coe_mk]\n    lift x to \u03b1 using x0.ne_bot\n    induction b using WithBot.recBotCoe; \u00b7 exact absurd h not_lt_bot\n    induction a using WithBot.recBotCoe; \u00b7 simp_rw [bot_mul x0.ne.symm, \u2190 coe_mul, bot_lt_coe]\n    simp only [\u2190 coe_mul, coe_lt_coe] at *\n    norm_cast  at x0\n    exact mul_lt_mul_of_pos_right h x0\u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [PosMulReflectLT \u03b1] : PosMulReflectLT (WithBot \u03b1) :=\n  \u27e8by\n    rintro \u27e8x, x0\u27e9 a b h; simp only [Subtype.coe_mk] at h\n    rcases eq_or_ne x 0 with (rfl | x0'); \u00b7 simpa using h\n    lift x to \u03b1;\n    \u00b7 rintro \u27e8rfl\u27e9\n      exact (WithBot.bot_lt_coe (0 : \u03b1)).not_le x0\n    induction b using WithBot.recBotCoe;\n    \u00b7 rw [mul_bot x0'] at h\n      exact absurd h bot_le.not_lt\n    induction a using WithBot.recBotCoe; \u00b7 exact WithBot.bot_lt_coe _\n    simp only [\u2190 coe_mul, coe_lt_coe] at *\n    norm_cast  at x0\n    exact lt_of_mul_lt_mul_left h x0\u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [MulPosReflectLT \u03b1] : MulPosReflectLT (WithBot \u03b1) :=\n  \u27e8by\n    rintro \u27e8x, x0\u27e9 a b h; simp only [Subtype.coe_mk] at h\n    rcases eq_or_ne x 0 with (rfl | x0'); \u00b7 simpa using h\n    lift x to \u03b1;\n    \u00b7 rintro \u27e8rfl\u27e9\n      exact (WithBot.bot_lt_coe (0 : \u03b1)).not_le x0\n    induction b using WithBot.recBotCoe;\n    \u00b7 rw [bot_mul x0'] at h\n      exact absurd h bot_le.not_lt\n    induction a using WithBot.recBotCoe; \u00b7 exact WithBot.bot_lt_coe _\n    simp only [\u2190 coe_mul, coe_lt_coe] at *\n    norm_cast  at x0\n    exact lt_of_mul_lt_mul_right h x0\u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [PosMulMonoRev \u03b1] : PosMulMonoRev (WithBot \u03b1) :=\n  \u27e8by\n    rintro \u27e8x, x0\u27e9 a b h; simp only [Subtype.coe_mk] at h\n    lift x to \u03b1 using x0.ne_bot\n    induction a using WithBot.recBotCoe; \u00b7 exact bot_le\n    induction b using WithBot.recBotCoe\n    \u00b7 rw [mul_bot x0.ne.symm, \u2190 coe_mul] at h\n      exact absurd h (bot_lt_coe (x * a)).not_le\n    simp only [\u2190 coe_mul, coe_le_coe] at *\n    norm_cast  at x0\n    exact le_of_mul_le_mul_left h x0\u27e9\n\ninstance [MulZeroClass \u03b1] [Preorder \u03b1] [MulPosMonoRev \u03b1] : MulPosMonoRev (WithBot \u03b1) :=\n  \u27e8by\n    rintro \u27e8x, x0\u27e9 a b h; simp only [Subtype.coe_mk] at h\n    lift x to \u03b1 using x0.ne_bot\n    induction a using WithBot.recBotCoe; \u00b7 exact bot_le\n    induction b using WithBot.recBotCoe\n    \u00b7 rw [bot_mul x0.ne.symm, \u2190 coe_mul] at h\n      exact absurd h (bot_lt_coe (a * x)).not_le\n    simp only [\u2190 coe_mul, coe_le_coe] at *\n    norm_cast  at x0\n    exact le_of_mul_le_mul_right h x0\u27e9\n\ninstance [CanonicallyOrderedCommSemiring \u03b1] [Nontrivial \u03b1] : OrderedCommSemiring (WithBot \u03b1) :=\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\u207b\u00b9))`  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\u00f6lich, *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 \u2194 FiniteDimensional Fqt F :=\n  by\n  let e := IsLocalization.algEquiv Fq[X]\u2070 (Ratfunc Fq) Fqt\n  have : \u2200 (c) (x : F), e c \u2022 x = c \u2022 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, \u2190 IsScalarTower.algebraMap_apply]\n  constructor <;> intro h <;> skip\n  \u00b7 let b := FiniteDimensional.finBasis (Ratfunc Fq) F\n    exact FiniteDimensional.of_fintype_basis (b.map_coeffs e this)\n  \u00b7 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 \u21d1(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 \u21d1(algebraMap Fq[X] (ringOfIntegers Fq F)) :=\n  by\n  have hinj : Function.Injective \u21d1(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] \u21a5(ring_of_integers Fq F))]\n  intro p hp\n  rw [\u2190 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 : \u00acIsField (ringOfIntegers Fq F) := by\n  simpa [\u2190\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 \u2208 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) : \u2124\u2098\u2080 :=\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  \u00b7 rw [hx, MulZeroClass.zero_mul, if_pos (Eq.refl _), MulZeroClass.zero_mul]\n  \u00b7 by_cases hy : y = 0\n    \u00b7 rw [hy, MulZeroClass.mul_zero, if_pos (Eq.refl _), MulZeroClass.mul_zero]\n    \u00b7\n      rw [if_neg hx, if_neg hy, if_neg (mul_ne_zero hx hy), \u2190 WithZero.coe_mul, WithZero.coe_inj, \u2190\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) \u2264 max (inftyValuationDef Fq x) (inftyValuationDef Fq y) :=\n  by\n  by_cases hx : x = 0\n  \u00b7 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  \u00b7 by_cases hy : y = 0\n    \u00b7 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    \u00b7 by_cases hxy : x + y = 0\n      \u00b7 rw [infty_valuation_def, if_pos hxy]\n        exact zero_le'\n      \u00b7 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, \u2190 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 \u2260 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) \u2124\u2098\u2080\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 \u2260 0) :\n    inftyValuationDef Fq (Ratfunc.c k) = Multiplicative.ofAdd (0 : \u2124) :=\n  by\n  have hCk : Ratfunc.c k \u2260 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 : \u2124) := 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 \u2260 0) :\n    inftyValuationDef Fq (algebraMap Fq[X] (Ratfunc Fq) p) =\n      Multiplicative.ofAdd (p.natDegree : \u2124) :=\n  by\n  have hp' : algebraMap Fq[X] (Ratfunc Fq) p \u2260 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) \u2124\u2098\u2080 :=\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\u207b\u00b9))`  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  \u27e8(0 : FqtInfty Fq)\u27e9\n\n/-- The valuation at infinity on `k(t)` extends to a valuation on `Fqt_infty`. -/\ninstance valuedFqtInfty : Valued (FqtInfty Fq) \u2124\u2098\u2080 :=\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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\u2082`: 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\u2083` as its only purpose so far would be to prove properties of\n`option.map\u2082` and casing already fulfills this task.\n-/\n\n\nopen Function\n\nnamespace Option\n\nvariable {\u03b1 \u03b1' \u03b2 \u03b2' \u03b3 \u03b3' \u03b4 \u03b4' \u03b5 \u03b5' : Type _} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {a : Option \u03b1} {b : Option \u03b2}\n  {c : Option \u03b3}\n\n#print Option.map\u2082 /-\n/-- The image of a binary function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` as a function `option \u03b1 \u2192 option \u03b2 \u2192 option \u03b3`.\nMathematically this should be thought of as the image of the corresponding function `\u03b1 \u00d7 \u03b2 \u2192 \u03b3`. -/\ndef map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : Option \u03b2) : Option \u03b3 :=\n  a.bind fun a => b.map <| f a\n#align option.map\u2082 Option.map\u2082\n-/\n\n/- warning: option.map\u2082_def -> Option.map\u2082_def is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u1}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : Option.{u1} \u03b1) (b : Option.{u1} \u03b2), Eq.{succ u1} (Option.{u1} \u03b3) (Option.map\u2082.{u1, u1, u1} \u03b1 \u03b2 \u03b3 f a b) (Seq.seq.{u1, u1} Option.{u1} (Applicative.toHasSeq.{u1, u1} Option.{u1} (Monad.toApplicative.{u1, u1} Option.{u1} Option.monad.{u1})) \u03b2 \u03b3 (Functor.map.{u1, u1} Option.{u1} (Traversable.toFunctor.{u1} Option.{u1} Option.traversable.{u1}) \u03b1 (\u03b2 -> \u03b3) f a) b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u1}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : Option.{u1} \u03b1) (b : Option.{u1} \u03b2), Eq.{succ u1} (Option.{u1} \u03b3) (Option.map\u2082.{u1, u1, u1} \u03b1 \u03b2 \u03b3 f a b) (Seq.seq.{u1, u1} Option.{u1} (Applicative.toSeq.{u1, u1} Option.{u1} (Alternative.toApplicative.{u1, u1} Option.{u1} instAlternativeOption.{u1})) \u03b2 \u03b3 (Functor.map.{u1, u1} Option.{u1} instFunctorOption.{u1} \u03b1 (\u03b2 -> \u03b3) f a) (fun (x._@.Mathlib.Data.Option.NAry._hyg.142 : Unit) => b))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_def Option.map\u2082_def\u2093'. -/\n/-- `option.map\u2082` in terms of monadic operations. Note that this can't be taken as the definition\nbecause of the lack of universe polymorphism. -/\ntheorem map\u2082_def {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : Option \u03b2) :\n    map\u2082 f a b = f <$> a <*> b := by cases a <;> rfl\n#align option.map\u2082_def Option.map\u2082_def\n\n/- warning: option.map\u2082_some_some -> Option.map\u2082_some_some is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : \u03b1) (b : \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f (Option.some.{u1} \u03b1 a) (Option.some.{u2} \u03b2 b)) (Option.some.{u3} \u03b3 (f a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : \u03b1) (b : \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 f (Option.some.{u2} \u03b1 a) (Option.some.{u1} \u03b2 b)) (Option.some.{u3} \u03b3 (f a b))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_some_some Option.map\u2082_some_some\u2093'. -/\n@[simp]\ntheorem map\u2082_some_some (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (b : \u03b2) : map\u2082 f (some a) (some b) = some (f a b) :=\n  rfl\n#align option.map\u2082_some_some Option.map\u2082_some_some\n\n/- warning: option.map\u2082_coe_coe -> Option.map\u2082_coe_coe is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : \u03b1) (b : \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (Option.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (coeOption.{u1} \u03b1))) a) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) \u03b2 (Option.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} \u03b2 (Option.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} \u03b2 (Option.{u2} \u03b2) (coeOption.{u2} \u03b2))) b)) ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) \u03b3 (Option.{u3} \u03b3) (HasLiftT.mk.{succ u3, succ u3} \u03b3 (Option.{u3} \u03b3) (CoeTC\u2093.coe.{succ u3, succ u3} \u03b3 (Option.{u3} \u03b3) (coeOption.{u3} \u03b3))) (f a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : \u03b1) (b : \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 f (Option.some.{u2} \u03b1 a) (Option.some.{u1} \u03b2 b)) (Option.some.{u3} \u03b3 (f a b))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_coe_coe Option.map\u2082_coe_coe\u2093'. -/\ntheorem map\u2082_coe_coe (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (b : \u03b2) : map\u2082 f a b = f a b :=\n  rfl\n#align option.map\u2082_coe_coe Option.map\u2082_coe_coe\n\n/- warning: option.map\u2082_none_left -> Option.map\u2082_none_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (b : Option.{u2} \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f (Option.none.{u1} \u03b1) b) (Option.none.{u3} \u03b3)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} (f : \u03b1 -> \u03b2 -> \u03b3) (b : Option.{u3} \u03b2), Eq.{succ u2} (Option.{u2} \u03b3) (Option.map\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 f (Option.none.{u1} \u03b1) b) (Option.none.{u2} \u03b3)\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_none_left Option.map\u2082_none_left\u2093'. -/\n@[simp]\ntheorem map\u2082_none_left (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (b : Option \u03b2) : map\u2082 f none b = none :=\n  rfl\n#align option.map\u2082_none_left Option.map\u2082_none_left\n\n/- warning: option.map\u2082_none_right -> Option.map\u2082_none_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : Option.{u1} \u03b1), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f a (Option.none.{u2} \u03b2)) (Option.none.{u3} \u03b3)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : Option.{u3} \u03b1), Eq.{succ u2} (Option.{u2} \u03b3) (Option.map\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 f a (Option.none.{u1} \u03b2)) (Option.none.{u2} \u03b3)\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_none_right Option.map\u2082_none_right\u2093'. -/\n@[simp]\ntheorem map\u2082_none_right (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) : map\u2082 f a none = none := by cases a <;> rfl\n#align option.map\u2082_none_right Option.map\u2082_none_right\n\n/- warning: option.map\u2082_coe_left -> Option.map\u2082_coe_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : \u03b1) (b : Option.{u2} \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (Option.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (Option.{u1} \u03b1) (coeOption.{u1} \u03b1))) a) b) (Option.map.{u2, u3} \u03b2 \u03b3 (fun (b : \u03b2) => f a b) b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : \u03b1) (b : Option.{u3} \u03b2), Eq.{succ u2} (Option.{u2} \u03b3) (Option.map\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 f (Option.some.{u1} \u03b1 a) b) (Option.map.{u3, u2} \u03b2 \u03b3 (fun (b : \u03b2) => f a b) b)\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_coe_left Option.map\u2082_coe_left\u2093'. -/\n@[simp]\ntheorem map\u2082_coe_left (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) (b : Option \u03b2) : map\u2082 f a b = b.map fun b => f a b :=\n  rfl\n#align option.map\u2082_coe_left Option.map\u2082_coe_left\n\n/- warning: option.map\u2082_coe_right -> Option.map\u2082_coe_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : Option.{u1} \u03b1) (b : \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f a ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) \u03b2 (Option.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} \u03b2 (Option.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} \u03b2 (Option.{u2} \u03b2) (coeOption.{u2} \u03b2))) b)) (Option.map.{u1, u3} \u03b1 \u03b3 (fun (a : \u03b1) => f a b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : Option.{u3} \u03b1) (b : \u03b2), Eq.{succ u2} (Option.{u2} \u03b3) (Option.map\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 f a (Option.some.{u1} \u03b2 b)) (Option.map.{u3, u2} \u03b1 \u03b3 (fun (a : \u03b1) => f a b) a)\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_coe_right Option.map\u2082_coe_right\u2093'. -/\n@[simp]\ntheorem map\u2082_coe_right (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : \u03b2) : map\u2082 f a b = a.map fun a => f a b :=\n  rfl\n#align option.map\u2082_coe_right Option.map\u2082_coe_right\n\n/- warning: option.mem_map\u2082_iff -> Option.mem_map\u2082_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {c : \u03b3}, Iff (Membership.Mem.{u3, u3} \u03b3 (Option.{u3} \u03b3) (Option.hasMem.{u3} \u03b3) c (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f a b)) (Exists.{succ u1} \u03b1 (fun (a' : \u03b1) => Exists.{succ u2} \u03b2 (fun (b' : \u03b2) => And (Membership.Mem.{u1, u1} \u03b1 (Option.{u1} \u03b1) (Option.hasMem.{u1} \u03b1) a' a) (And (Membership.Mem.{u2, u2} \u03b2 (Option.{u2} \u03b2) (Option.hasMem.{u2} \u03b2) b' b) (Eq.{succ u3} \u03b3 (f a' b') c)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u2} \u03b1} {b : Option.{u1} \u03b2} {c : \u03b3}, Iff (Membership.mem.{u3, u3} \u03b3 (Option.{u3} \u03b3) (Option.instMembershipOption.{u3} \u03b3) c (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 f a b)) (Exists.{succ u2} \u03b1 (fun (a' : \u03b1) => Exists.{succ u1} \u03b2 (fun (b' : \u03b2) => And (Membership.mem.{u2, u2} \u03b1 (Option.{u2} \u03b1) (Option.instMembershipOption.{u2} \u03b1) a' a) (And (Membership.mem.{u1, u1} \u03b2 (Option.{u1} \u03b2) (Option.instMembershipOption.{u1} \u03b2) b' b) (Eq.{succ u3} \u03b3 (f a' b') c)))))\nCase conversion may be inaccurate. Consider using '#align option.mem_map\u2082_iff Option.mem_map\u2082_iff\u2093'. -/\n@[simp]\ntheorem mem_map\u2082_iff {c : \u03b3} : c \u2208 map\u2082 f a b \u2194 \u2203 a' b', a' \u2208 a \u2227 b' \u2208 b \u2227 f a' b' = c := by\n  simp [map\u2082]\n#align option.mem_map\u2082_iff Option.mem_map\u2082_iff\n\n/- warning: option.map\u2082_eq_none_iff -> Option.map\u2082_eq_none_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2}, Iff (Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f a b) (Option.none.{u3} \u03b3)) (Or (Eq.{succ u1} (Option.{u1} \u03b1) a (Option.none.{u1} \u03b1)) (Eq.{succ u2} (Option.{u2} \u03b2) b (Option.none.{u2} \u03b2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u2} \u03b1} {b : Option.{u1} \u03b2}, Iff (Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 f a b) (Option.none.{u3} \u03b3)) (Or (Eq.{succ u2} (Option.{u2} \u03b1) a (Option.none.{u2} \u03b1)) (Eq.{succ u1} (Option.{u1} \u03b2) b (Option.none.{u1} \u03b2)))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_eq_none_iff Option.map\u2082_eq_none_iff\u2093'. -/\n@[simp]\ntheorem map\u2082_eq_none_iff : map\u2082 f a b = none \u2194 a = none \u2228 b = none := by\n  cases a <;> cases b <;> simp\n#align option.map\u2082_eq_none_iff Option.map\u2082_eq_none_iff\n\n/- warning: option.map\u2082_swap -> Option.map\u2082_swap is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : Option.{u1} \u03b1) (b : Option.{u2} \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f a b) (Option.map\u2082.{u2, u1, u3} \u03b2 \u03b1 \u03b3 (fun (a : \u03b2) (b : \u03b1) => f b a) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (f : \u03b1 -> \u03b2 -> \u03b3) (a : Option.{u3} \u03b1) (b : Option.{u2} \u03b2), Eq.{succ u1} (Option.{u1} \u03b3) (Option.map\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f a b) (Option.map\u2082.{u2, u3, u1} \u03b2 \u03b1 \u03b3 (fun (a : \u03b2) (b : \u03b1) => f b a) b a)\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_swap Option.map\u2082_swap\u2093'. -/\ntheorem map\u2082_swap (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : Option \u03b2) :\n    map\u2082 f a b = map\u2082 (fun a b => f b a) b a := by cases a <;> cases b <;> rfl\n#align option.map\u2082_swap Option.map\u2082_swap\n\n/- warning: option.map_map\u2082 -> Option.map_map\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} (f : \u03b1 -> \u03b2 -> \u03b3) (g : \u03b3 -> \u03b4), Eq.{succ u4} (Option.{u4} \u03b4) (Option.map.{u3, u4} \u03b3 \u03b4 g (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f a b)) (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b1) (b : \u03b2) => g (f a b)) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} {\u03b4 : Option.{u2} \u03b1} {a : Option.{u1} \u03b2} {b : Type.{u4}} (f : \u03b1 -> \u03b2 -> \u03b3) (g : \u03b3 -> b), Eq.{succ u4} (Option.{u4} b) (Option.map.{u3, u4} \u03b3 b g (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 f \u03b4 a)) (Option.map\u2082.{u2, u1, u4} \u03b1 \u03b2 b (fun (a : \u03b1) (b : \u03b2) => g (f a b)) \u03b4 a)\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082 Option.map_map\u2082\u2093'. -/\ntheorem map_map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (g : \u03b3 \u2192 \u03b4) :\n    (map\u2082 f a b).map g = map\u2082 (fun a b => g (f a b)) a b := by cases a <;> cases b <;> rfl\n#align option.map_map\u2082 Option.map_map\u2082\n\n/- warning: option.map\u2082_map_left -> Option.map\u2082_map_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} (f : \u03b3 -> \u03b2 -> \u03b4) (g : \u03b1 -> \u03b3), Eq.{succ u4} (Option.{u4} \u03b4) (Option.map\u2082.{u3, u2, u4} \u03b3 \u03b2 \u03b4 f (Option.map.{u1, u3} \u03b1 \u03b3 g a) b) (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b1) (b : \u03b2) => f (g a) b) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Option.{u1} \u03b1} {a : Option.{u2} \u03b2} {b : Type.{u4}} (f : \u03b3 -> \u03b2 -> b) (g : \u03b1 -> \u03b3), Eq.{succ u4} (Option.{u4} b) (Option.map\u2082.{u3, u2, u4} \u03b3 \u03b2 b f (Option.map.{u1, u3} \u03b1 \u03b3 g \u03b4) a) (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b2 b (fun (a : \u03b1) (b : \u03b2) => f (g a) b) \u03b4 a)\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_map_left Option.map\u2082_map_left\u2093'. -/\ntheorem map\u2082_map_left (f : \u03b3 \u2192 \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b3) :\n    map\u2082 f (a.map g) b = map\u2082 (fun a b => f (g a) b) a b := by cases a <;> rfl\n#align option.map\u2082_map_left Option.map\u2082_map_left\n\n/- warning: option.map\u2082_map_right -> Option.map\u2082_map_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} (f : \u03b1 -> \u03b3 -> \u03b4) (g : \u03b2 -> \u03b3), Eq.{succ u4} (Option.{u4} \u03b4) (Option.map\u2082.{u1, u3, u4} \u03b1 \u03b3 \u03b4 f a (Option.map.{u2, u3} \u03b2 \u03b3 g b)) (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b1) (b : \u03b2) => f a (g b)) a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} {\u03b4 : Option.{u3} \u03b1} {a : Option.{u1} \u03b2} {b : Type.{u4}} (f : \u03b1 -> \u03b3 -> b) (g : \u03b2 -> \u03b3), Eq.{succ u4} (Option.{u4} b) (Option.map\u2082.{u3, u2, u4} \u03b1 \u03b3 b f \u03b4 (Option.map.{u1, u2} \u03b2 \u03b3 g a)) (Option.map\u2082.{u3, u1, u4} \u03b1 \u03b2 b (fun (a : \u03b1) (b : \u03b2) => f a (g b)) \u03b4 a)\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_map_right Option.map\u2082_map_right\u2093'. -/\ntheorem map\u2082_map_right (f : \u03b1 \u2192 \u03b3 \u2192 \u03b4) (g : \u03b2 \u2192 \u03b3) :\n    map\u2082 f a (b.map g) = map\u2082 (fun a b => f a (g b)) a b := by cases b <;> rfl\n#align option.map\u2082_map_right Option.map\u2082_map_right\n\n/- warning: option.map\u2082_curry -> Option.map\u2082_curry is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03b3) (a : Option.{u1} \u03b1) (b : Option.{u2} \u03b2), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (Function.curry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f) a b) (Option.map.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 f (Option.map\u2082.{u1, u2, max u1 u2} \u03b1 \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) (Prod.mk.{u1, u2} \u03b1 \u03b2) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (f : (Prod.{u3, u2} \u03b1 \u03b2) -> \u03b3) (a : Option.{u3} \u03b1) (b : Option.{u2} \u03b2), Eq.{succ u1} (Option.{u1} \u03b3) (Option.map\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (Function.curry.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f) a b) (Option.map.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 f (Option.map\u2082.{u3, u2, max u3 u2} \u03b1 \u03b2 (Prod.{u3, u2} \u03b1 \u03b2) (Prod.mk.{u3, u2} \u03b1 \u03b2) a b))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_curry Option.map\u2082_curry\u2093'. -/\n@[simp]\ntheorem map\u2082_curry (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) (a : Option \u03b1) (b : Option \u03b2) :\n    map\u2082 (curry f) a b = Option.map f (map\u2082 Prod.mk a b) :=\n  (map_map\u2082 _ _).symm\n#align option.map\u2082_curry Option.map\u2082_curry\n\n/- warning: option.map_uncurry -> Option.map_uncurry is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2 -> \u03b3) (x : Option.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)), Eq.{succ u3} (Option.{u3} \u03b3) (Option.map.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Function.uncurry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f) x) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f (Option.map.{max u1 u2, u1} (Prod.{u1, u2} \u03b1 \u03b2) \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2) x) (Option.map.{max u1 u2, u2} (Prod.{u1, u2} \u03b1 \u03b2) \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2) x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u1}} (f : \u03b1 -> \u03b2 -> \u03b3) (x : Option.{max u3 u2} (Prod.{u2, u3} \u03b1 \u03b2)), Eq.{succ u1} (Option.{u1} \u03b3) (Option.map.{max u3 u2, u1} (Prod.{u2, u3} \u03b1 \u03b2) \u03b3 (Function.uncurry.{u2, u3, u1} \u03b1 \u03b2 \u03b3 f) x) (Option.map\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03b3 f (Option.map.{max u3 u2, u2} (Prod.{u2, u3} \u03b1 \u03b2) \u03b1 (Prod.fst.{u2, u3} \u03b1 \u03b2) x) (Option.map.{max u3 u2, u3} (Prod.{u2, u3} \u03b1 \u03b2) \u03b2 (Prod.snd.{u2, u3} \u03b1 \u03b2) x))\nCase conversion may be inaccurate. Consider using '#align option.map_uncurry Option.map_uncurry\u2093'. -/\n@[simp]\ntheorem map_uncurry (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (x : Option (\u03b1 \u00d7 \u03b2)) :\n    x.map (uncurry f) = map\u2082 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\u2082` of those operations.\nThe proof pattern is `map\u2082_lemma operation_lemma`. For example, `map\u2082_comm mul_comm` proves that\n`map\u2082 (*) a b = map\u2082 (*) g f` in a `comm_semigroup`.\n-/\n\n\n/- warning: option.map\u2082_assoc -> Option.map\u2082_assoc is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {\u03b5 : Type.{u5}} {\u03b5' : Type.{u6}} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {c : Option.{u3} \u03b3} {f : \u03b4 -> \u03b3 -> \u03b5} {g : \u03b1 -> \u03b2 -> \u03b4} {f' : \u03b1 -> \u03b5' -> \u03b5} {g' : \u03b2 -> \u03b3 -> \u03b5'}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u5} \u03b5 (f (g a b) c) (f' a (g' b c))) -> (Eq.{succ u5} (Option.{u5} \u03b5) (Option.map\u2082.{u4, u3, u5} \u03b4 \u03b3 \u03b5 f (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 g a b) c) (Option.map\u2082.{u1, u6, u5} \u03b1 \u03b5' \u03b5 f' a (Option.map\u2082.{u2, u3, u6} \u03b2 \u03b3 \u03b5' g' b c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} {\u03b4 : Option.{u2} \u03b1} {\u03b5 : Option.{u1} \u03b2} {\u03b5' : Option.{u3} \u03b3} {a : Type.{u6}} {b : Type.{u5}} {c : Type.{u4}} {f : a -> \u03b3 -> b} {g : \u03b1 -> \u03b2 -> a} {f' : \u03b1 -> c -> b} {g' : \u03b2 -> \u03b3 -> c}, (forall (a : \u03b1) (b_1 : \u03b2) (c : \u03b3), Eq.{succ u5} b (f (g a b_1) c) (f' a (g' b_1 c))) -> (Eq.{succ u5} (Option.{u5} b) (Option.map\u2082.{u6, u3, u5} a \u03b3 b f (Option.map\u2082.{u2, u1, u6} \u03b1 \u03b2 a g \u03b4 \u03b5) \u03b5') (Option.map\u2082.{u2, u4, u5} \u03b1 c b f' \u03b4 (Option.map\u2082.{u1, u3, u4} \u03b2 \u03b3 c g' \u03b5 \u03b5')))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_assoc Option.map\u2082_assoc\u2093'. -/\ntheorem map\u2082_assoc {f : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b5' \u2192 \u03b5} {g' : \u03b2 \u2192 \u03b3 \u2192 \u03b5'}\n    (h_assoc : \u2200 a b c, f (g a b) c = f' a (g' b c)) :\n    map\u2082 f (map\u2082 g a b) c = map\u2082 f' a (map\u2082 g' b c) := by\n  cases a <;> cases b <;> cases c <;> simp [h_assoc]\n#align option.map\u2082_assoc Option.map\u2082_assoc\n\n/- warning: option.map\u2082_comm -> Option.map\u2082_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {g : \u03b2 -> \u03b1 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03b3 (f a b) (g b a)) -> (Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f a b) (Option.map\u2082.{u2, u1, u3} \u03b2 \u03b1 \u03b3 g b a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u2} \u03b1} {b : Option.{u1} \u03b2} {g : \u03b2 -> \u03b1 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03b3 (f a b) (g b a)) -> (Eq.{succ u3} (Option.{u3} \u03b3) (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 f a b) (Option.map\u2082.{u1, u2, u3} \u03b2 \u03b1 \u03b3 g b a))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_comm Option.map\u2082_comm\u2093'. -/\ntheorem map\u2082_comm {g : \u03b2 \u2192 \u03b1 \u2192 \u03b3} (h_comm : \u2200 a b, f a b = g b a) : map\u2082 f a b = map\u2082 g b a := by\n  cases a <;> cases b <;> simp [h_comm]\n#align option.map\u2082_comm Option.map\u2082_comm\n\n/- warning: option.map\u2082_left_comm -> Option.map\u2082_left_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {\u03b4' : Type.{u5}} {\u03b5 : Type.{u6}} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {c : Option.{u3} \u03b3} {f : \u03b1 -> \u03b4 -> \u03b5} {g : \u03b2 -> \u03b3 -> \u03b4} {f' : \u03b1 -> \u03b3 -> \u03b4'} {g' : \u03b2 -> \u03b4' -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u6} \u03b5 (f a (g b c)) (g' b (f' a c))) -> (Eq.{succ u6} (Option.{u6} \u03b5) (Option.map\u2082.{u1, u4, u6} \u03b1 \u03b4 \u03b5 f a (Option.map\u2082.{u2, u3, u4} \u03b2 \u03b3 \u03b4 g b c)) (Option.map\u2082.{u2, u5, u6} \u03b2 \u03b4' \u03b5 g' b (Option.map\u2082.{u1, u3, u5} \u03b1 \u03b3 \u03b4' f' a c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {\u03b4 : Option.{u3} \u03b1} {\u03b4' : Option.{u2} \u03b2} {\u03b5 : Option.{u1} \u03b3} {a : Type.{u6}} {b : Type.{u5}} {c : Type.{u4}} {f : \u03b1 -> a -> b} {g : \u03b2 -> \u03b3 -> a} {f' : \u03b1 -> \u03b3 -> c} {g' : \u03b2 -> c -> b}, (forall (a : \u03b1) (b_1 : \u03b2) (c : \u03b3), Eq.{succ u5} b (f a (g b_1 c)) (g' b_1 (f' a c))) -> (Eq.{succ u5} (Option.{u5} b) (Option.map\u2082.{u3, u6, u5} \u03b1 a b f \u03b4 (Option.map\u2082.{u2, u1, u6} \u03b2 \u03b3 a g \u03b4' \u03b5)) (Option.map\u2082.{u2, u4, u5} \u03b2 c b g' \u03b4' (Option.map\u2082.{u3, u1, u4} \u03b1 \u03b3 c f' \u03b4 \u03b5)))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_left_comm Option.map\u2082_left_comm\u2093'. -/\ntheorem map\u2082_left_comm {f : \u03b1 \u2192 \u03b4 \u2192 \u03b5} {g : \u03b2 \u2192 \u03b3 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b3 \u2192 \u03b4'} {g' : \u03b2 \u2192 \u03b4' \u2192 \u03b5}\n    (h_left_comm : \u2200 a b c, f a (g b c) = g' b (f' a c)) :\n    map\u2082 f a (map\u2082 g b c) = map\u2082 g' b (map\u2082 f' a c) := by\n  cases a <;> cases b <;> cases c <;> simp [h_left_comm]\n#align option.map\u2082_left_comm Option.map\u2082_left_comm\n\n/- warning: option.map\u2082_right_comm -> Option.map\u2082_right_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {\u03b4' : Type.{u5}} {\u03b5 : Type.{u6}} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {c : Option.{u3} \u03b3} {f : \u03b4 -> \u03b3 -> \u03b5} {g : \u03b1 -> \u03b2 -> \u03b4} {f' : \u03b1 -> \u03b3 -> \u03b4'} {g' : \u03b4' -> \u03b2 -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u6} \u03b5 (f (g a b) c) (g' (f' a c) b)) -> (Eq.{succ u6} (Option.{u6} \u03b5) (Option.map\u2082.{u4, u3, u6} \u03b4 \u03b3 \u03b5 f (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 g a b) c) (Option.map\u2082.{u5, u2, u6} \u03b4' \u03b2 \u03b5 g' (Option.map\u2082.{u1, u3, u5} \u03b1 \u03b3 \u03b4' f' a c) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} {\u03b4 : Option.{u2} \u03b1} {\u03b4' : Option.{u1} \u03b2} {\u03b5 : Option.{u3} \u03b3} {a : Type.{u6}} {b : Type.{u5}} {c : Type.{u4}} {f : a -> \u03b3 -> b} {g : \u03b1 -> \u03b2 -> a} {f' : \u03b1 -> \u03b3 -> c} {g' : c -> \u03b2 -> b}, (forall (a : \u03b1) (b_1 : \u03b2) (c : \u03b3), Eq.{succ u5} b (f (g a b_1) c) (g' (f' a c) b_1)) -> (Eq.{succ u5} (Option.{u5} b) (Option.map\u2082.{u6, u3, u5} a \u03b3 b f (Option.map\u2082.{u2, u1, u6} \u03b1 \u03b2 a g \u03b4 \u03b4') \u03b5) (Option.map\u2082.{u4, u1, u5} c \u03b2 b g' (Option.map\u2082.{u2, u3, u4} \u03b1 \u03b3 c f' \u03b4 \u03b5) \u03b4'))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_right_comm Option.map\u2082_right_comm\u2093'. -/\ntheorem map\u2082_right_comm {f : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b3 \u2192 \u03b4'} {g' : \u03b4' \u2192 \u03b2 \u2192 \u03b5}\n    (h_right_comm : \u2200 a b c, f (g a b) c = g' (f' a c) b) :\n    map\u2082 f (map\u2082 g a b) c = map\u2082 g' (map\u2082 f' a c) b := by\n  cases a <;> cases b <;> cases c <;> simp [h_right_comm]\n#align option.map\u2082_right_comm Option.map\u2082_right_comm\n\n/- warning: option.map_map\u2082_distrib -> Option.map_map\u2082_distrib is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u4}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u6}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1' -> \u03b2' -> \u03b4} {g\u2081 : \u03b1 -> \u03b1'} {g\u2082 : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u6} \u03b4 (g (f a b)) (f' (g\u2081 a) (g\u2082 b))) -> (Eq.{succ u6} (Option.{u6} \u03b4) (Option.map.{u5, u6} \u03b3 \u03b4 g (Option.map\u2082.{u1, u3, u5} \u03b1 \u03b2 \u03b3 f a b)) (Option.map\u2082.{u2, u4, u6} \u03b1' \u03b2' \u03b4 f' (Option.map.{u1, u2} \u03b1 \u03b1' g\u2081 a) (Option.map.{u3, u4} \u03b2 \u03b2' g\u2082 b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b1' : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b2' : \u03b1 -> \u03b1' -> \u03b2} {\u03b3 : Option.{u2} \u03b1} {\u03b4 : Option.{u1} \u03b1'} {f : Type.{u6}} {a : Type.{u5}} {b : Type.{u4}} {g : \u03b2 -> f} {f' : a -> b -> f} {g\u2081 : \u03b1 -> a} {g\u2082 : \u03b1' -> b}, (forall (a : \u03b1) (b : \u03b1'), Eq.{succ u6} f (g (\u03b2' a b)) (f' (g\u2081 a) (g\u2082 b))) -> (Eq.{succ u6} (Option.{u6} f) (Option.map.{u3, u6} \u03b2 f g (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b1' \u03b2 \u03b2' \u03b3 \u03b4)) (Option.map\u2082.{u5, u4, u6} a b f f' (Option.map.{u2, u5} \u03b1 a g\u2081 \u03b3) (Option.map.{u1, u4} \u03b1' b g\u2082 \u03b4)))\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082_distrib Option.map_map\u2082_distrib\u2093'. -/\ntheorem map_map\u2082_distrib {g : \u03b3 \u2192 \u03b4} {f' : \u03b1' \u2192 \u03b2' \u2192 \u03b4} {g\u2081 : \u03b1 \u2192 \u03b1'} {g\u2082 : \u03b2 \u2192 \u03b2'}\n    (h_distrib : \u2200 a b, g (f a b) = f' (g\u2081 a) (g\u2082 b)) :\n    (map\u2082 f a b).map g = map\u2082 f' (a.map g\u2081) (b.map g\u2082) := by\n  cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map\u2082_distrib Option.map_map\u2082_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\u2082_distrib_left -> Option.map_map\u2082_distrib_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1' -> \u03b2 -> \u03b4} {g' : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' (g' a) b)) -> (Eq.{succ u5} (Option.{u5} \u03b4) (Option.map.{u4, u5} \u03b3 \u03b4 g (Option.map\u2082.{u1, u3, u4} \u03b1 \u03b2 \u03b3 f a b)) (Option.map\u2082.{u2, u3, u5} \u03b1' \u03b2 \u03b4 f' (Option.map.{u1, u2} \u03b1 \u03b1' g' a) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b1' : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : \u03b1 -> \u03b1' -> \u03b2} {\u03b4 : Option.{u2} \u03b1} {f : Option.{u1} \u03b1'} {a : Type.{u5}} {b : Type.{u4}} {g : \u03b2 -> a} {f' : b -> \u03b1' -> a} {g' : \u03b1 -> b}, (forall (a_1 : \u03b1) (b : \u03b1'), Eq.{succ u5} a (g (\u03b3 a_1 b)) (f' (g' a_1) b)) -> (Eq.{succ u5} (Option.{u5} a) (Option.map.{u3, u5} \u03b2 a g (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b1' \u03b2 \u03b3 \u03b4 f)) (Option.map\u2082.{u4, u1, u5} b \u03b1' a f' (Option.map.{u2, u4} \u03b1 b g' \u03b4) f))\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082_distrib_left Option.map_map\u2082_distrib_left\u2093'. -/\n/-- Symmetric statement to `option.map\u2082_map_left_comm`. -/\ntheorem map_map\u2082_distrib_left {g : \u03b3 \u2192 \u03b4} {f' : \u03b1' \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b1 \u2192 \u03b1'}\n    (h_distrib : \u2200 a b, g (f a b) = f' (g' a) b) : (map\u2082 f a b).map g = map\u2082 f' (a.map g') b := by\n  cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map\u2082_distrib_left Option.map_map\u2082_distrib_left\n\n/- warning: option.map_map\u2082_distrib_right -> Option.map_map\u2082_distrib_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1 -> \u03b2' -> \u03b4} {g' : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' a (g' b))) -> (Eq.{succ u5} (Option.{u5} \u03b4) (Option.map.{u4, u5} \u03b3 \u03b4 g (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b3 f a b)) (Option.map\u2082.{u1, u3, u5} \u03b1 \u03b2' \u03b4 f' a (Option.map.{u2, u3} \u03b2 \u03b2' g' b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b2' : Type.{u3}} {\u03b3 : \u03b1 -> \u03b2 -> \u03b2'} {\u03b4 : Option.{u2} \u03b1} {f : Option.{u1} \u03b2} {a : Type.{u5}} {b : Type.{u4}} {g : \u03b2' -> a} {f' : \u03b1 -> b -> a} {g' : \u03b2 -> b}, (forall (a_1 : \u03b1) (b : \u03b2), Eq.{succ u5} a (g (\u03b3 a_1 b)) (f' a_1 (g' b))) -> (Eq.{succ u5} (Option.{u5} a) (Option.map.{u3, u5} \u03b2' a g (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b2' \u03b3 \u03b4 f)) (Option.map\u2082.{u2, u4, u5} \u03b1 b a f' \u03b4 (Option.map.{u1, u4} \u03b2 b g' f)))\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082_distrib_right Option.map_map\u2082_distrib_right\u2093'. -/\n/-- Symmetric statement to `option.map_map\u2082_right_comm`. -/\ntheorem map_map\u2082_distrib_right {g : \u03b3 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b2' \u2192 \u03b4} {g' : \u03b2 \u2192 \u03b2'}\n    (h_distrib : \u2200 a b, g (f a b) = f' a (g' b)) : (map\u2082 f a b).map g = map\u2082 f' a (b.map g') := by\n  cases a <;> cases b <;> simp [h_distrib]\n#align option.map_map\u2082_distrib_right Option.map_map\u2082_distrib_right\n\n/- warning: option.map\u2082_map_left_comm -> Option.map\u2082_map_left_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {a : Option.{u1} \u03b1} {b : Option.{u3} \u03b2} {f : \u03b1' -> \u03b2 -> \u03b3} {g : \u03b1 -> \u03b1'} {f' : \u03b1 -> \u03b2 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u4} \u03b3 (f (g a) b) (g' (f' a b))) -> (Eq.{succ u4} (Option.{u4} \u03b3) (Option.map\u2082.{u2, u3, u4} \u03b1' \u03b2 \u03b3 f (Option.map.{u1, u2} \u03b1 \u03b1' g a) b) (Option.map.{u5, u4} \u03b4 \u03b3 g' (Option.map\u2082.{u1, u3, u5} \u03b1 \u03b2 \u03b4 f' a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Option.{u1} \u03b1} {\u03b4 : Option.{u2} \u03b1'} {a : Type.{u5}} {b : Type.{u4}} {f : a -> \u03b1' -> \u03b2} {g : \u03b1 -> a} {f' : \u03b1 -> \u03b1' -> b} {g' : b -> \u03b2}, (forall (a : \u03b1) (b : \u03b1'), Eq.{succ u3} \u03b2 (f (g a) b) (g' (f' a b))) -> (Eq.{succ u3} (Option.{u3} \u03b2) (Option.map\u2082.{u5, u2, u3} a \u03b1' \u03b2 f (Option.map.{u1, u5} \u03b1 a g \u03b3) \u03b4) (Option.map.{u4, u3} b \u03b2 g' (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b1' b f' \u03b3 \u03b4)))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_map_left_comm Option.map\u2082_map_left_comm\u2093'. -/\n/-- Symmetric statement to `option.map_map\u2082_distrib_left`. -/\ntheorem map\u2082_map_left_comm {f : \u03b1' \u2192 \u03b2 \u2192 \u03b3} {g : \u03b1 \u2192 \u03b1'} {f' : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_left_comm : \u2200 a b, f (g a) b = g' (f' a b)) : map\u2082 f (a.map g) b = (map\u2082 f' a b).map g' := by\n  cases a <;> cases b <;> simp [h_left_comm]\n#align option.map\u2082_map_left_comm Option.map\u2082_map_left_comm\n\n/- warning: option.map_map\u2082_right_comm -> Option.map_map\u2082_right_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {f : \u03b1 -> \u03b2' -> \u03b3} {g : \u03b2 -> \u03b2'} {f' : \u03b1 -> \u03b2 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u4} \u03b3 (f a (g b)) (g' (f' a b))) -> (Eq.{succ u4} (Option.{u4} \u03b3) (Option.map\u2082.{u1, u3, u4} \u03b1 \u03b2' \u03b3 f a (Option.map.{u2, u3} \u03b2 \u03b2' g b)) (Option.map.{u5, u4} \u03b4 \u03b3 g' (Option.map\u2082.{u1, u2, u5} \u03b1 \u03b2 \u03b4 f' a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b2' : Type.{u3}} {\u03b3 : Option.{u2} \u03b1} {\u03b4 : Option.{u1} \u03b2} {a : Type.{u5}} {b : Type.{u4}} {f : \u03b1 -> a -> \u03b2'} {g : \u03b2 -> a} {f' : \u03b1 -> \u03b2 -> b} {g' : b -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03b2' (f a (g b)) (g' (f' a b))) -> (Eq.{succ u3} (Option.{u3} \u03b2') (Option.map\u2082.{u2, u5, u3} \u03b1 a \u03b2' f \u03b3 (Option.map.{u1, u5} \u03b2 a g \u03b4)) (Option.map.{u4, u3} b \u03b2' g' (Option.map\u2082.{u2, u1, u4} \u03b1 \u03b2 b f' \u03b3 \u03b4)))\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082_right_comm Option.map_map\u2082_right_comm\u2093'. -/\n/-- Symmetric statement to `option.map_map\u2082_distrib_right`. -/\ntheorem map_map\u2082_right_comm {f : \u03b1 \u2192 \u03b2' \u2192 \u03b3} {g : \u03b2 \u2192 \u03b2'} {f' : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_right_comm : \u2200 a b, f a (g b) = g' (f' a b)) : map\u2082 f a (b.map g) = (map\u2082 f' a b).map g' :=\n  by cases a <;> cases b <;> simp [h_right_comm]\n#align option.map_map\u2082_right_comm Option.map_map\u2082_right_comm\n\n/- warning: option.map_map\u2082_antidistrib -> Option.map_map\u2082_antidistrib is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u4}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u6}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2' -> \u03b1' -> \u03b4} {g\u2081 : \u03b2 -> \u03b2'} {g\u2082 : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u6} \u03b4 (g (f a b)) (f' (g\u2081 b) (g\u2082 a))) -> (Eq.{succ u6} (Option.{u6} \u03b4) (Option.map.{u5, u6} \u03b3 \u03b4 g (Option.map\u2082.{u1, u3, u5} \u03b1 \u03b2 \u03b3 f a b)) (Option.map\u2082.{u4, u2, u6} \u03b2' \u03b1' \u03b4 f' (Option.map.{u3, u4} \u03b2 \u03b2' g\u2081 b) (Option.map.{u1, u2} \u03b1 \u03b1' g\u2082 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b1' : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b2' : \u03b1 -> \u03b1' -> \u03b2} {\u03b3 : Option.{u2} \u03b1} {\u03b4 : Option.{u1} \u03b1'} {f : Type.{u6}} {a : Type.{u5}} {b : Type.{u4}} {g : \u03b2 -> f} {f' : a -> b -> f} {g\u2081 : \u03b1' -> a} {g\u2082 : \u03b1 -> b}, (forall (a : \u03b1) (b : \u03b1'), Eq.{succ u6} f (g (\u03b2' a b)) (f' (g\u2081 b) (g\u2082 a))) -> (Eq.{succ u6} (Option.{u6} f) (Option.map.{u3, u6} \u03b2 f g (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b1' \u03b2 \u03b2' \u03b3 \u03b4)) (Option.map\u2082.{u5, u4, u6} a b f f' (Option.map.{u1, u5} \u03b1' a g\u2081 \u03b4) (Option.map.{u2, u4} \u03b1 b g\u2082 \u03b3)))\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082_antidistrib Option.map_map\u2082_antidistrib\u2093'. -/\ntheorem map_map\u2082_antidistrib {g : \u03b3 \u2192 \u03b4} {f' : \u03b2' \u2192 \u03b1' \u2192 \u03b4} {g\u2081 : \u03b2 \u2192 \u03b2'} {g\u2082 : \u03b1 \u2192 \u03b1'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' (g\u2081 b) (g\u2082 a)) :\n    (map\u2082 f a b).map g = map\u2082 f' (b.map g\u2081) (a.map g\u2082) := by\n  cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map\u2082_antidistrib Option.map_map\u2082_antidistrib\n\n/- warning: option.map_map\u2082_antidistrib_left -> Option.map_map\u2082_antidistrib_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2' -> \u03b1 -> \u03b4} {g' : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' (g' b) a)) -> (Eq.{succ u5} (Option.{u5} \u03b4) (Option.map.{u4, u5} \u03b3 \u03b4 g (Option.map\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b3 f a b)) (Option.map\u2082.{u3, u1, u5} \u03b2' \u03b1 \u03b4 f' (Option.map.{u2, u3} \u03b2 \u03b2' g' b) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b2' : Type.{u3}} {\u03b3 : \u03b1 -> \u03b2 -> \u03b2'} {\u03b4 : Option.{u2} \u03b1} {f : Option.{u1} \u03b2} {a : Type.{u5}} {b : Type.{u4}} {g : \u03b2' -> a} {f' : b -> \u03b1 -> a} {g' : \u03b2 -> b}, (forall (a_1 : \u03b1) (b : \u03b2), Eq.{succ u5} a (g (\u03b3 a_1 b)) (f' (g' b) a_1)) -> (Eq.{succ u5} (Option.{u5} a) (Option.map.{u3, u5} \u03b2' a g (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b2' \u03b3 \u03b4 f)) (Option.map\u2082.{u4, u2, u5} b \u03b1 a f' (Option.map.{u1, u4} \u03b2 b g' f) \u03b4))\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082_antidistrib_left Option.map_map\u2082_antidistrib_left\u2093'. -/\n/-- Symmetric statement to `option.map\u2082_map_left_anticomm`. -/\ntheorem map_map\u2082_antidistrib_left {g : \u03b3 \u2192 \u03b4} {f' : \u03b2' \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b2 \u2192 \u03b2'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' (g' b) a) : (map\u2082 f a b).map g = map\u2082 f' (b.map g') a :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map\u2082_antidistrib_left Option.map_map\u2082_antidistrib_left\n\n/- warning: option.map_map\u2082_antidistrib_right -> Option.map_map\u2082_antidistrib_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {f : \u03b1 -> \u03b2 -> \u03b3} {a : Option.{u1} \u03b1} {b : Option.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2 -> \u03b1' -> \u03b4} {g' : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' b (g' a))) -> (Eq.{succ u5} (Option.{u5} \u03b4) (Option.map.{u4, u5} \u03b3 \u03b4 g (Option.map\u2082.{u1, u3, u4} \u03b1 \u03b2 \u03b3 f a b)) (Option.map\u2082.{u3, u2, u5} \u03b2 \u03b1' \u03b4 f' b (Option.map.{u1, u2} \u03b1 \u03b1' g' a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b1' : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : \u03b1 -> \u03b1' -> \u03b2} {\u03b4 : Option.{u2} \u03b1} {f : Option.{u1} \u03b1'} {a : Type.{u5}} {b : Type.{u4}} {g : \u03b2 -> a} {f' : \u03b1' -> b -> a} {g' : \u03b1 -> b}, (forall (a_1 : \u03b1) (b : \u03b1'), Eq.{succ u5} a (g (\u03b3 a_1 b)) (f' b (g' a_1))) -> (Eq.{succ u5} (Option.{u5} a) (Option.map.{u3, u5} \u03b2 a g (Option.map\u2082.{u2, u1, u3} \u03b1 \u03b1' \u03b2 \u03b3 \u03b4 f)) (Option.map\u2082.{u1, u4, u5} \u03b1' b a f' f (Option.map.{u2, u4} \u03b1 b g' \u03b4)))\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082_antidistrib_right Option.map_map\u2082_antidistrib_right\u2093'. -/\n/-- Symmetric statement to `option.map_map\u2082_right_anticomm`. -/\ntheorem map_map\u2082_antidistrib_right {g : \u03b3 \u2192 \u03b4} {f' : \u03b2 \u2192 \u03b1' \u2192 \u03b4} {g' : \u03b1 \u2192 \u03b1'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' b (g' a)) : (map\u2082 f a b).map g = map\u2082 f' b (a.map g') :=\n  by cases a <;> cases b <;> simp [h_antidistrib]\n#align option.map_map\u2082_antidistrib_right Option.map_map\u2082_antidistrib_right\n\n/- warning: option.map\u2082_map_left_anticomm -> Option.map\u2082_map_left_anticomm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {a : Option.{u1} \u03b1} {b : Option.{u3} \u03b2} {f : \u03b1' -> \u03b2 -> \u03b3} {g : \u03b1 -> \u03b1'} {f' : \u03b2 -> \u03b1 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u4} \u03b3 (f (g a) b) (g' (f' b a))) -> (Eq.{succ u4} (Option.{u4} \u03b3) (Option.map\u2082.{u2, u3, u4} \u03b1' \u03b2 \u03b3 f (Option.map.{u1, u2} \u03b1 \u03b1' g a) b) (Option.map.{u5, u4} \u03b4 \u03b3 g' (Option.map\u2082.{u3, u1, u5} \u03b2 \u03b1 \u03b4 f' b a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Option.{u1} \u03b1} {\u03b4 : Option.{u2} \u03b1'} {a : Type.{u5}} {b : Type.{u4}} {f : a -> \u03b1' -> \u03b2} {g : \u03b1 -> a} {f' : \u03b1' -> \u03b1 -> b} {g' : b -> \u03b2}, (forall (a : \u03b1) (b : \u03b1'), Eq.{succ u3} \u03b2 (f (g a) b) (g' (f' b a))) -> (Eq.{succ u3} (Option.{u3} \u03b2) (Option.map\u2082.{u5, u2, u3} a \u03b1' \u03b2 f (Option.map.{u1, u5} \u03b1 a g \u03b3) \u03b4) (Option.map.{u4, u3} b \u03b2 g' (Option.map\u2082.{u2, u1, u4} \u03b1' \u03b1 b f' \u03b4 \u03b3)))\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_map_left_anticomm Option.map\u2082_map_left_anticomm\u2093'. -/\n/-- Symmetric statement to `option.map_map\u2082_antidistrib_left`. -/\ntheorem map\u2082_map_left_anticomm {f : \u03b1' \u2192 \u03b2 \u2192 \u03b3} {g : \u03b1 \u2192 \u03b1'} {f' : \u03b2 \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_left_anticomm : \u2200 a b, f (g a) b = g' (f' b a)) :\n    map\u2082 f (a.map g) b = (map\u2082 f' b a).map g' := by cases a <;> cases b <;> simp [h_left_anticomm]\n#align option.map\u2082_map_left_anticomm Option.map\u2082_map_left_anticomm\n\n/- warning: option.map_map\u2082_right_anticomm -> Option.map_map\u2082_right_anticomm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {a : Option.{u1} \u03b1} {b : Option.{u2} \u03b2} {f : \u03b1 -> \u03b2' -> \u03b3} {g : \u03b2 -> \u03b2'} {f' : \u03b2 -> \u03b1 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u4} \u03b3 (f a (g b)) (g' (f' b a))) -> (Eq.{succ u4} (Option.{u4} \u03b3) (Option.map\u2082.{u1, u3, u4} \u03b1 \u03b2' \u03b3 f a (Option.map.{u2, u3} \u03b2 \u03b2' g b)) (Option.map.{u5, u4} \u03b4 \u03b3 g' (Option.map\u2082.{u2, u1, u5} \u03b2 \u03b1 \u03b4 f' b a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b2' : Type.{u3}} {\u03b3 : Option.{u2} \u03b1} {\u03b4 : Option.{u1} \u03b2} {a : Type.{u5}} {b : Type.{u4}} {f : \u03b1 -> a -> \u03b2'} {g : \u03b2 -> a} {f' : \u03b2 -> \u03b1 -> b} {g' : b -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03b2' (f a (g b)) (g' (f' b a))) -> (Eq.{succ u3} (Option.{u3} \u03b2') (Option.map\u2082.{u2, u5, u3} \u03b1 a \u03b2' f \u03b3 (Option.map.{u1, u5} \u03b2 a g \u03b4)) (Option.map.{u4, u3} b \u03b2' g' (Option.map\u2082.{u1, u2, u4} \u03b2 \u03b1 b f' \u03b4 \u03b3)))\nCase conversion may be inaccurate. Consider using '#align option.map_map\u2082_right_anticomm Option.map_map\u2082_right_anticomm\u2093'. -/\n/-- Symmetric statement to `option.map_map\u2082_antidistrib_right`. -/\ntheorem map_map\u2082_right_anticomm {f : \u03b1 \u2192 \u03b2' \u2192 \u03b3} {g : \u03b2 \u2192 \u03b2'} {f' : \u03b2 \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_right_anticomm : \u2200 a b, f a (g b) = g' (f' b a)) :\n    map\u2082 f a (b.map g) = (map\u2082 f' b a).map g' := by cases a <;> cases b <;> simp [h_right_anticomm]\n#align option.map_map\u2082_right_anticomm Option.map_map\u2082_right_anticomm\n\n#print Option.map\u2082_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\u2082 f`. -/\ntheorem map\u2082_left_identity {f : \u03b1 \u2192 \u03b2 \u2192 \u03b2} {a : \u03b1} (h : \u2200 b, f a b = b) (o : Option \u03b2) :\n    map\u2082 f (some a) o = o := by\n  cases o\n  exacts[rfl, congr_arg some (h _)]\n#align option.map\u2082_left_identity Option.map\u2082_left_identity\n-/\n\n/- warning: option.map\u2082_right_identity -> Option.map\u2082_right_identity is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : \u03b1 -> \u03b2 -> \u03b1} {b : \u03b2}, (forall (a : \u03b1), Eq.{succ u1} \u03b1 (f a b) a) -> (forall (o : Option.{u1} \u03b1), Eq.{succ u1} (Option.{u1} \u03b1) (Option.map\u2082.{u1, u2, u1} \u03b1 \u03b2 \u03b1 f o (Option.some.{u2} \u03b2 b)) o)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {f : \u03b1 -> \u03b2 -> \u03b1} {b : \u03b2}, (forall (a : \u03b1), Eq.{succ u2} \u03b1 (f a b) a) -> (forall (o : Option.{u2} \u03b1), Eq.{succ u2} (Option.{u2} \u03b1) (Option.map\u2082.{u2, u1, u2} \u03b1 \u03b2 \u03b1 f o (Option.some.{u1} \u03b2 b)) o)\nCase conversion may be inaccurate. Consider using '#align option.map\u2082_right_identity Option.map\u2082_right_identity\u2093'. -/\n/-- If `b` is a right identity for a binary operation `f`, then `some b` is a right identity for\n`option.map\u2082 f`. -/\ntheorem map\u2082_right_identity {f : \u03b1 \u2192 \u03b2 \u2192 \u03b1} {b : \u03b2} (h : \u2200 a, f a b = a) (o : Option \u03b1) :\n    map\u2082 f o (some b) = o := by simp [h, map\u2082]\n#align option.map\u2082_right_identity Option.map\u2082_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 \u2192+ B)\n    where\n  smul r f :=\n    { toFun := r \u2022 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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) \u1fb0) (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 (\u1fb0 : A), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : A) => B) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_smul (r : R) (f : A \u2192+ B) : \u21d1(r \u2022 f) = r \u2022 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\u2093'. -/\ntheorem smul_apply (r : R) (f : A \u2192+ B) (x : A) : (r \u2022 f) x = r \u2022 f x :=\n  rfl\n#align add_monoid_hom.smul_apply AddMonoidHom.smul_apply\n\ninstance [SMulCommClass R S B] : SMulCommClass R S (A \u2192+ B) :=\n  \u27e8fun a b f => ext fun x => smul_comm _ _ _\u27e9\n\ninstance [SMul R S] [IsScalarTower R S B] : IsScalarTower R S (A \u2192+ B) :=\n  \u27e8fun a b f => ext fun x => smul_assoc _ _ _\u27e9\n\ninstance [DistribMulAction R\u1d50\u1d52\u1d56 B] [IsCentralScalar R B] : IsCentralScalar R (A \u2192+ B) :=\n  \u27e8fun a b => ext fun x => op_smul_eq_smul _ _\u27e9\n\nend\n\ninstance [Semiring R] [AddMonoid A] [AddCommMonoid B] [Module R B] : Module R (A \u2192+ 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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u2124} {n : \u2124} {z : cocycle B A 1} {f : A \u27f6 X} (g : twist z \u27f6 Y) {p : X \u27f6 Y} {j : K \u27f6 X}\n  (sq : comm_sq f (twist.inr z) p g) (l : \u03a0 (q : \u2124), comm_sq.lift_struct ((homological_complex.eval C _ q).map_comm_sq sq))\n  (hpj : is_termwise_kernel j p)\n\n@[simp]\ndef \u03c6 : cochain B Y 0 := cochain.comp (twist.inl z (zero_add 1)) (cochain.of_hom g) (zero_add 0).symm\n\nlemma d\u03c6 : \u03b4 0 1 (\u03c6 g) = cochain.comp \u2191z (cochain.of_hom (twist.inr z \u226b g)) (add_zero 1).symm :=\nby simp only [\u03c6, add_left_eq_self, \u03b4_comp_of_second_is_zero_cochain,\n  cocycle.\u03b4_cochain_of_hom, cochain.comp_zero, twist.\u03b4_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 (\u03bb q, (l q).l)) (zero_add 0).symm\n\ninclude sq l\n\n@[simps]\ndef obs\u2080 : cocycle B X 1 :=\ncocycle.mk (\u03b4 0 1 (L sq l) - cochain.comp \u2191z (cochain.of_hom f) (add_zero 1).symm) 2 rfl\n(by simp only [\u03b4_sub, \u03b4\u03b4, zero_sub, \u03b4_comp_of_second_is_zero_cochain _ _ 2 rfl, neg_zero,\n    cocycle.\u03b4_eq_zero, cocycle.\u03b4_cochain_of_hom, cochain.comp_zero, cochain.zero_comp, add_zero])\n\ndef obs : cocycle B K 1 :=\ncocycle.lift_to_kernel (obs\u2080 sq l) hpj\nbegin\n  have eq\u2081 : cochain.comp (cochain.of_homs (\u03bb (q : \u2124), (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\u2082 : cochain.comp (\u03b4 0 1 (cochain.of_homs (\u03bb (q : \u2124), (l q).l))) (cochain.of_hom p)\n    (add_zero 1).symm = 0,\n  { suffices : \u03b4 0 1 (cochain.comp (cochain.of_homs (\u03bb (q : \u2124), (l q).l)) (cochain.of_hom p)\n      (zero_add 0).symm) = 0,\n    { simpa only [\u03b4_comp_of_second_is_zero_cochain _ _ _ (zero_add 1),\n        zero_add, cocycle.\u03b4_cochain_of_hom, cochain.comp_zero] using this, },\n    simp only [eq\u2081, cocycle.\u03b4_cochain_of_hom], },\n  simp only [obs\u2080, cochain.sub_comp, cocycle.mk_coe, cochain.add_comp,\n    cochain.comp_assoc_of_third_is_zero_cochain, \u2190 cochain.of_hom_comp, sq.w, L,\n    \u03b4_comp_of_second_is_zero_cochain _ _ _ (zero_add 1),\n    eq\u2082, cochain.comp_zero, zero_add,\n    eq\u2081, \u2190 d\u03c6 g, \u03c6, cocycle.\u03b4_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 = \u2191(obs\u2080 sq l) :=\nby apply cocycle.lift_to_kernel_comp\n\nvariables (w : cochain B K 0) (hw : \u03b4 0 1 w = \u2191(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  \u03b4 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, \u03b4_sub, \u03b4_comp_of_second_is_zero_cochain _ _ _ (zero_add 1),\n  cocycle.\u03b4_cochain_of_hom, cochain.comp_zero, zero_add, hw, obs_comp, obs\u2080,\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      \u2190 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 [\u2190 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes H\u00f6lzl\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 {\u22a4}`, 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 \u2260 \u22a4) := 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 \u2208 nhds \u2191r := sorry\n\ntheorem tendsto_coe {\u03b1 : Type u_1} {f : filter \u03b1} {m : \u03b1 \u2192 nnreal} {a : nnreal} :\n    filter.tendsto (fun (a : \u03b1) => \u2191(m a)) f (nhds \u2191a) \u2194 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 {\u03b1 : Type u_1} [topological_space \u03b1] {f : \u03b1 \u2192 nnreal} :\n    (continuous fun (a : \u03b1) => \u2191(f a)) \u2194 continuous f :=\n  iff.symm (embedding.continuous_iff embedding_coe)\n\ntheorem nhds_coe {r : nnreal} : nhds \u2191r = filter.map coe (nhds r) := sorry\n\ntheorem nhds_coe_coe {r : nnreal} {p : nnreal} :\n    nhds (\u2191r, \u2191p) =\n        filter.map (fun (p : nnreal \u00d7 nnreal) => (\u2191(prod.fst p), \u2191(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 {\u03b1 : Type u_1} {f : filter \u03b1} {m : \u03b1 \u2192 \u211d} {a : \u211d}\n    (h : filter.tendsto m f (nhds a)) :\n    filter.tendsto (fun (a : \u03b1) => 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 \u2260 \u22a4 \u2192 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 \u2260 \u22a4) :=\n  sorry\n\ntheorem tendsto_to_real {a : ennreal} :\n    a \u2260 \u22a4 \u2192 filter.tendsto ennreal.to_real (nhds a) (nhds (ennreal.to_real a)) :=\n  fun (ha : a \u2260 \u22a4) =>\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 `\u211d\u22650`. -/\ndef ne_top_homeomorph_nnreal : \u21a5(set_of fun (a : ennreal) => a \u2260 \u22a4) \u2243\u209c 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 `\u211d\u22650`. -/\ndef lt_top_homeomorph_nnreal : \u21a5(set_of fun (a : ennreal) => a < \u22a4) \u2243\u209c nnreal :=\n  homeomorph.trans (homeomorph.set_congr sorry) ne_top_homeomorph_nnreal\n\ntheorem nhds_top :\n    nhds \u22a4 = infi fun (a : ennreal) => infi fun (H : a \u2260 \u22a4) => filter.principal (set.Ioi a) :=\n  sorry\n\ntheorem nhds_top' : nhds \u22a4 = infi fun (r : nnreal) => filter.principal (set.Ioi \u2191r) :=\n  Eq.trans nhds_top (infi_ne_top fun (a : ennreal) => filter.principal (set.Ioi a))\n\ntheorem tendsto_nhds_top_iff_nnreal {\u03b1 : Type u_1} {m : \u03b1 \u2192 ennreal} {f : filter \u03b1} :\n    filter.tendsto m f (nhds \u22a4) \u2194 \u2200 (x : nnreal), filter.eventually (fun (a : \u03b1) => \u2191x < m a) f :=\n  sorry\n\ntheorem tendsto_nhds_top_iff_nat {\u03b1 : Type u_1} {m : \u03b1 \u2192 ennreal} {f : filter \u03b1} :\n    filter.tendsto m f (nhds \u22a4) \u2194 \u2200 (n : \u2115), filter.eventually (fun (a : \u03b1) => \u2191n < m a) f :=\n  sorry\n\ntheorem tendsto_nhds_top {\u03b1 : Type u_1} {m : \u03b1 \u2192 ennreal} {f : filter \u03b1}\n    (h : \u2200 (n : \u2115), filter.eventually (fun (a : \u03b1) => \u2191n < m a) f) : filter.tendsto m f (nhds \u22a4) :=\n  iff.mpr tendsto_nhds_top_iff_nat h\n\ntheorem tendsto_nat_nhds_top : filter.tendsto (fun (n : \u2115) => \u2191n) filter.at_top (nhds \u22a4) := sorry\n\n@[simp] theorem tendsto_coe_nhds_top {\u03b1 : Type u_1} {f : \u03b1 \u2192 nnreal} {l : filter \u03b1} :\n    filter.tendsto (fun (x : \u03b1) => \u2191(f x)) l (nhds \u22a4) \u2194 filter.tendsto f l filter.at_top :=\n  sorry\n\ntheorem nhds_zero :\n    nhds 0 = infi fun (a : ennreal) => infi fun (H : a \u2260 0) => filter.principal (set.Iio a) :=\n  sorry\n\ninstance nhds_within_Ioi_coe_ne_bot {r : nnreal} : filter.ne_bot (nhds_within (\u2191r) (set.Ioi \u2191r)) :=\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-- \u2022 don't have 'Ioo (x - \u03b5) (x + \u03b5) \u2208 \ud835\udcdd x' unless x > 0\n\n-- \u2022 (x - y \u2264 \u03b5 \u2194 x \u2264 \u03b5 + y) is true, while (x - y < \u03b5 \u2194 x < \u03b5 + y) is not\n\ntheorem Icc_mem_nhds {x : ennreal} {\u03b5 : ennreal} :\n    x \u2260 \u22a4 \u2192 0 < \u03b5 \u2192 set.Icc (x - \u03b5) (x + \u03b5) \u2208 nhds x :=\n  sorry\n\ntheorem nhds_of_ne_top {x : ennreal} :\n    x \u2260 \u22a4 \u2192\n        nhds x =\n          infi\n            fun (\u03b5 : ennreal) =>\n              infi fun (H : \u03b5 > 0) => filter.principal (set.Icc (x - \u03b5) (x + \u03b5)) :=\n  sorry\n\n/-- Characterization of neighborhoods for `ennreal` numbers. See also `tendsto_order`\nfor a version with strict inequalities. -/\nprotected theorem tendsto_nhds {\u03b1 : Type u_1} {f : filter \u03b1} {u : \u03b1 \u2192 ennreal} {a : ennreal}\n    (ha : a \u2260 \u22a4) :\n    filter.tendsto u f (nhds a) \u2194\n        \u2200 (\u03b5 : ennreal),\n          \u03b5 > 0 \u2192 filter.eventually (fun (x : \u03b1) => u x \u2208 set.Icc (a - \u03b5) (a + \u03b5)) f :=\n  sorry\n\nprotected theorem tendsto_at_top {\u03b2 : Type u_2} [Nonempty \u03b2] [semilattice_sup \u03b2] {f : \u03b2 \u2192 ennreal}\n    {a : ennreal} (ha : a \u2260 \u22a4) :\n    filter.tendsto f filter.at_top (nhds a) \u2194\n        \u2200 (\u03b5 : ennreal), \u03b5 > 0 \u2192 \u2203 (N : \u03b2), \u2200 (n : \u03b2), n \u2265 N \u2192 f n \u2208 set.Icc (a - \u03b5) (a + \u03b5) :=\n  sorry\n\nprotected instance has_continuous_add : has_continuous_add ennreal := sorry\n\nprotected theorem tendsto_mul {a : ennreal} {b : ennreal} (ha : a \u2260 0 \u2228 b \u2260 \u22a4)\n    (hb : b \u2260 0 \u2228 a \u2260 \u22a4) :\n    filter.tendsto (fun (p : ennreal \u00d7 ennreal) => prod.fst p * prod.snd p) (nhds (a, b))\n        (nhds (a * b)) :=\n  sorry\n\nprotected theorem tendsto.mul {\u03b1 : Type u_1} {f : filter \u03b1} {ma : \u03b1 \u2192 ennreal} {mb : \u03b1 \u2192 ennreal}\n    {a : ennreal} {b : ennreal} (hma : filter.tendsto ma f (nhds a)) (ha : a \u2260 0 \u2228 b \u2260 \u22a4)\n    (hmb : filter.tendsto mb f (nhds b)) (hb : b \u2260 0 \u2228 a \u2260 \u22a4) :\n    filter.tendsto (fun (a : \u03b1) => ma a * mb a) f (nhds (a * b)) :=\n  sorry\n\nprotected theorem tendsto.const_mul {\u03b1 : Type u_1} {f : filter \u03b1} {m : \u03b1 \u2192 ennreal} {a : ennreal}\n    {b : ennreal} (hm : filter.tendsto m f (nhds b)) (hb : b \u2260 0 \u2228 a \u2260 \u22a4) :\n    filter.tendsto (fun (b : \u03b1) => a * m b) f (nhds (a * b)) :=\n  sorry\n\nprotected theorem tendsto.mul_const {\u03b1 : Type u_1} {f : filter \u03b1} {m : \u03b1 \u2192 ennreal} {a : ennreal}\n    {b : ennreal} (hm : filter.tendsto m f (nhds a)) (ha : a \u2260 0 \u2228 b \u2260 \u22a4) :\n    filter.tendsto (fun (x : \u03b1) => m x * b) f (nhds (a * b)) :=\n  sorry\n\nprotected theorem continuous_at_const_mul {a : ennreal} {b : ennreal} (h : a \u2260 \u22a4 \u2228 b \u2260 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 \u2260 \u22a4 \u2228 b \u2260 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 \u2260 \u22a4) : 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 \u2260 \u22a4) :\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 : \u2200 (a : ennreal), a < 1 \u2192 a * x \u2264 y) : x \u2264 y :=\n  sorry\n\ntheorem infi_mul_left {\u03b9 : Sort u_1} [Nonempty \u03b9] {f : \u03b9 \u2192 ennreal} {a : ennreal}\n    (h : a = \u22a4 \u2192 (infi fun (i : \u03b9) => f i) = 0 \u2192 \u2203 (i : \u03b9), f i = 0) :\n    (infi fun (i : \u03b9) => a * f i) = a * infi fun (i : \u03b9) => f i :=\n  sorry\n\ntheorem infi_mul_right {\u03b9 : Sort u_1} [Nonempty \u03b9] {f : \u03b9 \u2192 ennreal} {a : ennreal}\n    (h : a = \u22a4 \u2192 (infi fun (i : \u03b9) => f i) = 0 \u2192 \u2203 (i : \u03b9), f i = 0) :\n    (infi fun (i : \u03b9) => f i * a) = (infi fun (i : \u03b9) => f i) * a :=\n  sorry\n\nprotected theorem continuous_inv : continuous has_inv.inv := sorry\n\n@[simp] protected theorem tendsto_inv_iff {\u03b1 : Type u_1} {f : filter \u03b1} {m : \u03b1 \u2192 ennreal}\n    {a : ennreal} :\n    filter.tendsto (fun (x : \u03b1) => m x\u207b\u00b9) f (nhds (a\u207b\u00b9)) \u2194 filter.tendsto m f (nhds a) :=\n  sorry\n\nprotected theorem tendsto.div {\u03b1 : Type u_1} {f : filter \u03b1} {ma : \u03b1 \u2192 ennreal} {mb : \u03b1 \u2192 ennreal}\n    {a : ennreal} {b : ennreal} (hma : filter.tendsto ma f (nhds a)) (ha : a \u2260 0 \u2228 b \u2260 0)\n    (hmb : filter.tendsto mb f (nhds b)) (hb : b \u2260 \u22a4 \u2228 a \u2260 \u22a4) :\n    filter.tendsto (fun (a : \u03b1) => ma a / mb a) f (nhds (a / b)) :=\n  sorry\n\nprotected theorem tendsto.const_div {\u03b1 : Type u_1} {f : filter \u03b1} {m : \u03b1 \u2192 ennreal} {a : ennreal}\n    {b : ennreal} (hm : filter.tendsto m f (nhds b)) (hb : b \u2260 \u22a4 \u2228 a \u2260 \u22a4) :\n    filter.tendsto (fun (b : \u03b1) => a / m b) f (nhds (a / b)) :=\n  sorry\n\nprotected theorem tendsto.div_const {\u03b1 : Type u_1} {f : filter \u03b1} {m : \u03b1 \u2192 ennreal} {a : ennreal}\n    {b : ennreal} (hm : filter.tendsto m f (nhds a)) (ha : a \u2260 0 \u2228 b \u2260 0) :\n    filter.tendsto (fun (x : \u03b1) => m x / b) f (nhds (a / b)) :=\n  sorry\n\nprotected theorem tendsto_inv_nat_nhds_zero :\n    filter.tendsto (fun (n : \u2115) => \u2191n\u207b\u00b9) filter.at_top (nhds 0) :=\n  inv_top \u25b8 iff.mpr ennreal.tendsto_inv_iff tendsto_nat_nhds_top\n\ntheorem bsupr_add {a : ennreal} {\u03b9 : Type u_1} {s : set \u03b9} (hs : set.nonempty s) {f : \u03b9 \u2192 ennreal} :\n    (supr fun (i : \u03b9) => supr fun (H : i \u2208 s) => f i) + a =\n        supr fun (i : \u03b9) => supr fun (H : i \u2208 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 \u2208 s) => b + a :=\n  sorry\n\ntheorem supr_add {a : ennreal} {\u03b9 : Sort u_1} {s : \u03b9 \u2192 ennreal} [h : Nonempty \u03b9] :\n    supr s + a = supr fun (b : \u03b9) => s b + a :=\n  sorry\n\ntheorem add_supr {a : ennreal} {\u03b9 : Sort u_1} {s : \u03b9 \u2192 ennreal} [h : Nonempty \u03b9] :\n    a + supr s = supr fun (b : \u03b9) => a + s b :=\n  sorry\n\ntheorem supr_add_supr {\u03b9 : Sort u_1} {f : \u03b9 \u2192 ennreal} {g : \u03b9 \u2192 ennreal}\n    (h : \u2200 (i j : \u03b9), \u2203 (k : \u03b9), f i + g j \u2264 f k + g k) :\n    supr f + supr g = supr fun (a : \u03b9) => f a + g a :=\n  sorry\n\ntheorem supr_add_supr_of_monotone {\u03b9 : Type u_1} [semilattice_sup \u03b9] {f : \u03b9 \u2192 ennreal}\n    {g : \u03b9 \u2192 ennreal} (hf : monotone f) (hg : monotone g) :\n    supr f + supr g = supr fun (a : \u03b9) => f a + g a :=\n  supr_add_supr\n    fun (i j : \u03b9) => Exists.intro (i \u2294 j) (add_le_add (hf le_sup_left) (hg le_sup_right))\n\ntheorem finset_sum_supr_nat {\u03b1 : Type u_1} {\u03b9 : Type u_2} [semilattice_sup \u03b9] {s : finset \u03b1}\n    {f : \u03b1 \u2192 \u03b9 \u2192 ennreal} (hf : \u2200 (a : \u03b1), monotone (f a)) :\n    (finset.sum s fun (a : \u03b1) => supr (f a)) =\n        supr fun (n : \u03b9) => finset.sum s fun (a : \u03b1) => 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 \u2208 s) => a * i :=\n  sorry\n\ntheorem mul_supr {\u03b9 : Sort u_1} {f : \u03b9 \u2192 ennreal} {a : ennreal} :\n    a * supr f = supr fun (i : \u03b9) => a * f i :=\n  sorry\n\ntheorem supr_mul {\u03b9 : Sort u_1} {f : \u03b9 \u2192 ennreal} {a : ennreal} :\n    supr f * a = supr fun (i : \u03b9) => f i * a :=\n  sorry\n\nprotected theorem tendsto_coe_sub {r : nnreal} {b : ennreal} :\n    filter.tendsto (fun (b : ennreal) => \u2191r - b) (nhds b) (nhds (\u2191r - b)) :=\n  sorry\n\ntheorem sub_supr {a : ennreal} {\u03b9 : Sort u_1} [h\u03b9 : Nonempty \u03b9] {b : \u03b9 \u2192 ennreal} (hr : a < \u22a4) :\n    (a - supr fun (i : \u03b9) => b i) = infi fun (i : \u03b9) => a - b i :=\n  sorry\n\ntheorem supr_eq_zero {\u03b9 : Sort u_1} {f : \u03b9 \u2192 ennreal} :\n    (supr fun (i : \u03b9) => f i) = 0 \u2194 \u2200 (i : \u03b9), f i = 0 :=\n  sorry\n\nprotected theorem has_sum_coe {\u03b1 : Type u_1} {f : \u03b1 \u2192 nnreal} {r : nnreal} :\n    has_sum (fun (a : \u03b1) => \u2191(f a)) \u2191r \u2194 has_sum f r :=\n  sorry\n\nprotected theorem tsum_coe_eq {\u03b1 : Type u_1} {r : nnreal} {f : \u03b1 \u2192 nnreal} (h : has_sum f r) :\n    (tsum fun (a : \u03b1) => \u2191(f a)) = \u2191r :=\n  has_sum.tsum_eq (iff.mpr ennreal.has_sum_coe h)\n\nprotected theorem coe_tsum {\u03b1 : Type u_1} {f : \u03b1 \u2192 nnreal} :\n    summable f \u2192 \u2191(tsum f) = tsum fun (a : \u03b1) => \u2191(f a) :=\n  sorry\n\nprotected theorem has_sum {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} :\n    has_sum f (supr fun (s : finset \u03b1) => finset.sum s fun (a : \u03b1) => f a) :=\n  tendsto_at_top_supr fun (s t : finset \u03b1) => finset.sum_le_sum_of_subset\n\n@[simp] protected theorem summable {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} : summable f :=\n  Exists.intro (supr fun (s : finset \u03b1) => finset.sum s fun (a : \u03b1) => f a) ennreal.has_sum\n\ntheorem tsum_coe_ne_top_iff_summable {\u03b2 : Type u_2} {f : \u03b2 \u2192 nnreal} :\n    (tsum fun (b : \u03b2) => \u2191(f b)) \u2260 \u22a4 \u2194 summable f :=\n  sorry\n\nprotected theorem tsum_eq_supr_sum {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} :\n    (tsum fun (a : \u03b1) => f a) = supr fun (s : finset \u03b1) => finset.sum s fun (a : \u03b1) => f a :=\n  has_sum.tsum_eq ennreal.has_sum\n\nprotected theorem tsum_eq_supr_sum' {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} {\u03b9 : Type u_2}\n    (s : \u03b9 \u2192 finset \u03b1) (hs : \u2200 (t : finset \u03b1), \u2203 (i : \u03b9), t \u2286 s i) :\n    (tsum fun (a : \u03b1) => f a) = supr fun (i : \u03b9) => finset.sum (s i) fun (a : \u03b1) => f a :=\n  sorry\n\nprotected theorem tsum_sigma {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (f : (a : \u03b1) \u2192 \u03b2 a \u2192 ennreal) :\n    (tsum fun (p : sigma fun (a : \u03b1) => \u03b2 a) => f (sigma.fst p) (sigma.snd p)) =\n        tsum fun (a : \u03b1) => tsum fun (b : \u03b2 a) => f a b :=\n  tsum_sigma' (fun (b : \u03b1) => ennreal.summable) ennreal.summable\n\nprotected theorem tsum_sigma' {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2}\n    (f : (sigma fun (a : \u03b1) => \u03b2 a) \u2192 ennreal) :\n    (tsum fun (p : sigma fun (a : \u03b1) => \u03b2 a) => f p) =\n        tsum fun (a : \u03b1) => tsum fun (b : \u03b2 a) => f (sigma.mk a b) :=\n  tsum_sigma' (fun (b : \u03b1) => ennreal.summable) ennreal.summable\n\nprotected theorem tsum_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2 \u2192 ennreal} :\n    (tsum fun (p : \u03b1 \u00d7 \u03b2) => f (prod.fst p) (prod.snd p)) =\n        tsum fun (a : \u03b1) => tsum fun (b : \u03b2) => f a b :=\n  tsum_prod' ennreal.summable fun (_x : \u03b1) => ennreal.summable\n\nprotected theorem tsum_comm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2 \u2192 ennreal} :\n    (tsum fun (a : \u03b1) => tsum fun (b : \u03b2) => f a b) =\n        tsum fun (b : \u03b2) => tsum fun (a : \u03b1) => f a b :=\n  tsum_comm' ennreal.summable (fun (_x : \u03b2) => ennreal.summable) fun (_x : \u03b1) => ennreal.summable\n\nprotected theorem tsum_add {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} {g : \u03b1 \u2192 ennreal} :\n    (tsum fun (a : \u03b1) => f a + g a) = (tsum fun (a : \u03b1) => f a) + tsum fun (a : \u03b1) => g a :=\n  tsum_add ennreal.summable ennreal.summable\n\nprotected theorem tsum_le_tsum {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} {g : \u03b1 \u2192 ennreal}\n    (h : \u2200 (a : \u03b1), f a \u2264 g a) : (tsum fun (a : \u03b1) => f a) \u2264 tsum fun (a : \u03b1) => g a :=\n  tsum_le_tsum h ennreal.summable ennreal.summable\n\nprotected theorem sum_le_tsum {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} (s : finset \u03b1) :\n    (finset.sum s fun (x : \u03b1) => f x) \u2264 tsum fun (x : \u03b1) => f x :=\n  sum_le_tsum s (fun (x : \u03b1) (hx : \u00acx \u2208 s) => zero_le (f x)) ennreal.summable\n\nprotected theorem tsum_eq_supr_nat' {f : \u2115 \u2192 ennreal} {N : \u2115 \u2192 \u2115}\n    (hN : filter.tendsto N filter.at_top filter.at_top) :\n    (tsum fun (i : \u2115) => f i) =\n        supr fun (i : \u2115) => finset.sum (finset.range (N i)) fun (i : \u2115) => f i :=\n  sorry\n\nprotected theorem tsum_eq_supr_nat {f : \u2115 \u2192 ennreal} :\n    (tsum fun (i : \u2115) => f i) =\n        supr fun (i : \u2115) => finset.sum (finset.range i) fun (i : \u2115) => f i :=\n  ennreal.tsum_eq_supr_sum' (fun (i : \u2115) => finset.range i) finset.exists_nat_subset_range\n\nprotected theorem le_tsum {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} (a : \u03b1) :\n    f a \u2264 tsum fun (a : \u03b1) => f a :=\n  le_tsum' ennreal.summable a\n\nprotected theorem tsum_eq_top_of_eq_top {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal} :\n    (\u2203 (a : \u03b1), f a = \u22a4) \u2192 (tsum fun (a : \u03b1) => f a) = \u22a4 :=\n  fun (\u1fb0 : \u2203 (a : \u03b1), f a = \u22a4) =>\n    Exists.dcases_on \u1fb0\n      fun (\u1fb0_w : \u03b1) (\u1fb0_h : f \u1fb0_w = \u22a4) =>\n        idRhs ((tsum fun (a : \u03b1) => f a) = \u22a4) (top_unique (\u1fb0_h \u25b8 ennreal.le_tsum \u1fb0_w))\n\nprotected theorem ne_top_of_tsum_ne_top {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal}\n    (h : (tsum fun (a : \u03b1) => f a) \u2260 \u22a4) (a : \u03b1) : f a \u2260 \u22a4 :=\n  fun (ha : f a = \u22a4) => h (ennreal.tsum_eq_top_of_eq_top (Exists.intro a ha))\n\nprotected theorem tsum_mul_left {\u03b1 : Type u_1} {a : ennreal} {f : \u03b1 \u2192 ennreal} :\n    (tsum fun (i : \u03b1) => a * f i) = a * tsum fun (i : \u03b1) => f i :=\n  sorry\n\nprotected theorem tsum_mul_right {\u03b1 : Type u_1} {a : ennreal} {f : \u03b1 \u2192 ennreal} :\n    (tsum fun (i : \u03b1) => f i * a) = (tsum fun (i : \u03b1) => f i) * a :=\n  sorry\n\n@[simp] theorem tsum_supr_eq {\u03b1 : Type u_1} (a : \u03b1) {f : \u03b1 \u2192 ennreal} :\n    (tsum fun (b : \u03b1) => supr fun (h : a = b) => f b) = f a :=\n  sorry\n\ntheorem has_sum_iff_tendsto_nat {f : \u2115 \u2192 ennreal} (r : ennreal) :\n    has_sum f r \u2194\n        filter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i) filter.at_top\n          (nhds r) :=\n  sorry\n\ntheorem to_nnreal_apply_of_tsum_ne_top {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal}\n    (hf : (tsum fun (i : \u03b1) => f i) \u2260 \u22a4) (x : \u03b1) : \u2191(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 {\u03b1 : Type u_1} {f : \u03b1 \u2192 ennreal}\n    (hf : (tsum fun (i : \u03b1) => f i) \u2260 \u22a4) : summable (ennreal.to_nnreal \u2218 f) :=\n  sorry\n\nprotected theorem tsum_apply {\u03b9 : Type u_1} {\u03b1 : Type u_2} {f : \u03b9 \u2192 \u03b1 \u2192 ennreal} {x : \u03b1} :\n    tsum (fun (i : \u03b9) => f i) x = tsum fun (i : \u03b9) => f i x :=\n  tsum_apply (iff.mpr pi.summable fun (_x : \u03b1) => ennreal.summable)\n\ntheorem tsum_sub {f : \u2115 \u2192 ennreal} {g : \u2115 \u2192 ennreal} (h\u2081 : (tsum fun (i : \u2115) => g i) < \u22a4)\n    (h\u2082 : g \u2264 f) :\n    (tsum fun (i : \u2115) => f i - g i) = (tsum fun (i : \u2115) => f i) - tsum fun (i : \u2115) => g i :=\n  sorry\n\nend ennreal\n\n\nnamespace nnreal\n\n\n/-- Comparison test of convergence of `\u211d\u22650`-valued series. -/\ntheorem exists_le_has_sum_of_le {\u03b2 : Type u_2} {f : \u03b2 \u2192 nnreal} {g : \u03b2 \u2192 nnreal} {r : nnreal}\n    (hgf : \u2200 (b : \u03b2), g b \u2264 f b) (hfr : has_sum f r) : \u2203 (p : nnreal), \u2203 (H : p \u2264 r), has_sum g p :=\n  sorry\n\n/-- Comparison test of convergence of `\u211d\u22650`-valued series. -/\ntheorem summable_of_le {\u03b2 : Type u_2} {f : \u03b2 \u2192 nnreal} {g : \u03b2 \u2192 nnreal}\n    (hgf : \u2200 (b : \u03b2), g b \u2264 f b) : summable f \u2192 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 : \u2115 \u2192 nnreal} {r : nnreal} :\n    has_sum f r \u2194\n        filter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i) filter.at_top\n          (nhds r) :=\n  sorry\n\ntheorem not_summable_iff_tendsto_nat_at_top {f : \u2115 \u2192 nnreal} :\n    \u00acsummable f \u2194\n        filter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i) filter.at_top\n          filter.at_top :=\n  sorry\n\ntheorem summable_iff_not_tendsto_nat_at_top {f : \u2115 \u2192 nnreal} :\n    summable f \u2194\n        \u00acfilter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i)\n            filter.at_top filter.at_top :=\n  sorry\n\ntheorem summable_of_sum_range_le {f : \u2115 \u2192 nnreal} {c : nnreal}\n    (h : \u2200 (n : \u2115), (finset.sum (finset.range n) fun (i : \u2115) => f i) \u2264 c) : summable f :=\n  sorry\n\ntheorem tsum_le_of_sum_range_le {f : \u2115 \u2192 nnreal} {c : nnreal}\n    (h : \u2200 (n : \u2115), (finset.sum (finset.range n) fun (i : \u2115) => f i) \u2264 c) :\n    (tsum fun (i : \u2115) => f i) \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 nnreal} (hf : summable f)\n    {i : \u03b2 \u2192 \u03b1} (hi : function.injective i) :\n    (tsum fun (x : \u03b2) => f (i x)) \u2264 tsum fun (x : \u03b1) => f x :=\n  tsum_le_tsum_of_inj i hi (fun (c : \u03b1) (hc : \u00acc \u2208 set.range i) => zero_le (f c))\n    (fun (b : \u03b2) => le_refl (f (i b))) (summable_comp_injective hf hi) hf\n\ntheorem summable_sigma {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} {f : (sigma fun (x : \u03b1) => \u03b2 x) \u2192 nnreal} :\n    summable f \u2194\n        (\u2200 (x : \u03b1), summable fun (y : \u03b2 x) => f (sigma.mk x y)) \u2227\n          summable fun (x : \u03b1) => tsum fun (y : \u03b2 x) => f (sigma.mk x y) :=\n  sorry\n\n/-- For `f : \u2115 \u2192 \u211d\u22650`, then `\u2211' 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 : \u2115 \u2192 nnreal) :\n    filter.tendsto (fun (i : \u2115) => tsum fun (k : \u2115) => 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 : \u2115 \u2192 ennreal) (hf : (tsum fun (i : \u2115) => f i) \u2260 \u22a4) :\n    filter.tendsto (fun (i : \u2115) => tsum fun (k : \u2115) => f (k + i)) filter.at_top (nhds 0) :=\n  sorry\n\nend ennreal\n\n\ntheorem tsum_comp_le_tsum_of_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u211d} (hf : summable f)\n    (hn : \u2200 (a : \u03b1), 0 \u2264 f a) {i : \u03b2 \u2192 \u03b1} (hi : function.injective i) : tsum (f \u2218 i) \u2264 tsum f :=\n  sorry\n\n/-- Comparison test of convergence of series of non-negative real numbers. -/\ntheorem summable_of_nonneg_of_le {\u03b2 : Type u_2} {f : \u03b2 \u2192 \u211d} {g : \u03b2 \u2192 \u211d} (hg : \u2200 (b : \u03b2), 0 \u2264 g b)\n    (hgf : \u2200 (b : \u03b2), g b \u2264 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 : \u2115 \u2192 \u211d} (hf : \u2200 (i : \u2115), 0 \u2264 f i) (r : \u211d) :\n    has_sum f r \u2194\n        filter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i) filter.at_top\n          (nhds r) :=\n  sorry\n\ntheorem ennreal.of_real_tsum_of_nonneg {\u03b1 : Type u_1} {f : \u03b1 \u2192 \u211d} (hf_nonneg : \u2200 (n : \u03b1), 0 \u2264 f n)\n    (hf : summable f) :\n    ennreal.of_real (tsum fun (n : \u03b1) => f n) = tsum fun (n : \u03b1) => ennreal.of_real (f n) :=\n  sorry\n\ntheorem not_summable_iff_tendsto_nat_at_top_of_nonneg {f : \u2115 \u2192 \u211d} (hf : \u2200 (n : \u2115), 0 \u2264 f n) :\n    \u00acsummable f \u2194\n        filter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i) filter.at_top\n          filter.at_top :=\n  sorry\n\ntheorem summable_iff_not_tendsto_nat_at_top_of_nonneg {f : \u2115 \u2192 \u211d} (hf : \u2200 (n : \u2115), 0 \u2264 f n) :\n    summable f \u2194\n        \u00acfilter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => f i)\n            filter.at_top filter.at_top :=\n  sorry\n\ntheorem summable_sigma_of_nonneg {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2}\n    {f : (sigma fun (x : \u03b1) => \u03b2 x) \u2192 \u211d} (hf : \u2200 (x : sigma fun (x : \u03b1) => \u03b2 x), 0 \u2264 f x) :\n    summable f \u2194\n        (\u2200 (x : \u03b1), summable fun (y : \u03b2 x) => f (sigma.mk x y)) \u2227\n          summable fun (x : \u03b1) => tsum fun (y : \u03b2 x) => f (sigma.mk x y) :=\n  sorry\n\ntheorem summable_of_sum_range_le {f : \u2115 \u2192 \u211d} {c : \u211d} (hf : \u2200 (n : \u2115), 0 \u2264 f n)\n    (h : \u2200 (n : \u2115), (finset.sum (finset.range n) fun (i : \u2115) => f i) \u2264 c) : summable f :=\n  sorry\n\ntheorem tsum_le_of_sum_range_le {f : \u2115 \u2192 \u211d} {c : \u211d} (hf : \u2200 (n : \u2115), 0 \u2264 f n)\n    (h : \u2200 (n : \u2115), (finset.sum (finset.range n) fun (i : \u2115) => f i) \u2264 c) :\n    (tsum fun (i : \u2115) => f i) \u2264 c :=\n  sorry\n\n/-- In an emetric ball, the distance between points is everywhere finite -/\ntheorem edist_ne_top_of_mem_ball {\u03b2 : Type u_2} [emetric_space \u03b2] {a : \u03b2} {r : ennreal}\n    (x : \u21a5(emetric.ball a r)) (y : \u21a5(emetric.ball a r)) :\n    edist (subtype.val x) (subtype.val y) \u2260 \u22a4 :=\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 {\u03b2 : Type u_2} [emetric_space \u03b2] (a : \u03b2) (r : ennreal) :\n    metric_space \u21a5(emetric.ball a r) :=\n  emetric_space.to_metric_space edist_ne_top_of_mem_ball\n\ntheorem nhds_eq_nhds_emetric_ball {\u03b2 : Type u_2} [emetric_space \u03b2] (a : \u03b2) (x : \u03b2) (r : ennreal)\n    (h : x \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [emetric_space \u03b1] {l : filter \u03b2}\n    {f : \u03b2 \u2192 \u03b1} {y : \u03b1} :\n    filter.tendsto f l (nhds y) \u2194 filter.tendsto (fun (x : \u03b2) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [emetric_space \u03b1]\n    [Nonempty \u03b2] [semilattice_sup \u03b2] {s : \u03b2 \u2192 \u03b1} :\n    cauchy_seq s \u2194\n        \u2203 (b : \u03b2 \u2192 ennreal),\n          (\u2200 (n m N : \u03b2), N \u2264 n \u2192 N \u2264 m \u2192 edist (s n) (s m) \u2264 b N) \u2227\n            filter.tendsto b filter.at_top (nhds 0) :=\n  sorry\n\ntheorem continuous_of_le_add_edist {\u03b1 : Type u_1} [emetric_space \u03b1] {f : \u03b1 \u2192 ennreal} (C : ennreal)\n    (hC : C \u2260 \u22a4) (h : \u2200 (x y : \u03b1), f x \u2264 f y + C * edist x y) : continuous f :=\n  sorry\n\ntheorem continuous_edist {\u03b1 : Type u_1} [emetric_space \u03b1] :\n    continuous fun (p : \u03b1 \u00d7 \u03b1) => edist (prod.fst p) (prod.snd p) :=\n  sorry\n\ntheorem continuous.edist {\u03b1 : Type u_1} {\u03b2 : Type u_2} [emetric_space \u03b1] [topological_space \u03b2]\n    {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (hf : continuous f) (hg : continuous g) :\n    continuous fun (b : \u03b2) => edist (f b) (g b) :=\n  continuous.comp continuous_edist (continuous.prod_mk hf hg)\n\ntheorem filter.tendsto.edist {\u03b1 : Type u_1} {\u03b2 : Type u_2} [emetric_space \u03b1] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1}\n    {x : filter \u03b2} {a : \u03b1} {b : \u03b1} (hf : filter.tendsto f x (nhds a))\n    (hg : filter.tendsto g x (nhds b)) :\n    filter.tendsto (fun (x : \u03b2) => 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 {\u03b1 : Type u_1} [emetric_space \u03b1] {f : \u2115 \u2192 \u03b1}\n    (d : \u2115 \u2192 ennreal) (hf : \u2200 (n : \u2115), edist (f n) (f (Nat.succ n)) \u2264 d n) (hd : tsum d \u2260 \u22a4) :\n    cauchy_seq f :=\n  sorry\n\ntheorem emetric.is_closed_ball {\u03b1 : Type u_1} [emetric_space \u03b1] {a : \u03b1} {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 : \u2115 \u2192 ennreal`,\nthen the distance from `f n` to the limit is bounded by `\u2211'_{k=n}^\u221e d k`. -/\ntheorem edist_le_tsum_of_edist_le_of_tendsto {\u03b1 : Type u_1} [emetric_space \u03b1] {f : \u2115 \u2192 \u03b1}\n    (d : \u2115 \u2192 ennreal) (hf : \u2200 (n : \u2115), edist (f n) (f (Nat.succ n)) \u2264 d n) {a : \u03b1}\n    (ha : filter.tendsto f filter.at_top (nhds a)) (n : \u2115) :\n    edist (f n) a \u2264 tsum fun (m : \u2115) => d (n + m) :=\n  sorry\n\n/-- If `edist (f n) (f (n+1))` is bounded above by a function `d : \u2115 \u2192 ennreal`,\nthen the distance from `f 0` to the limit is bounded by `\u2211'_{k=0}^\u221e d k`. -/\ntheorem edist_le_tsum_of_edist_le_of_tendsto\u2080 {\u03b1 : Type u_1} [emetric_space \u03b1] {f : \u2115 \u2192 \u03b1}\n    (d : \u2115 \u2192 ennreal) (hf : \u2200 (n : \u2115), edist (f n) (f (Nat.succ n)) \u2264 d n) {a : \u03b1}\n    (ha : filter.tendsto f filter.at_top (nhds a)) : edist (f 0) a \u2264 tsum fun (m : \u2115) => 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\u1d52\u1d56 \u2964 D) (S : J.cover X) :=\n  { x : \u2200 I : S.arrow, P.obj (op I.y) //\n    \u2200 I : S.Relation, P.map I.g\u2081.op (x I.fst) = P.map I.g\u2082.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\u1d52\u1d56 \u2964 D) (S : J.cover X) :\n    CoeFun (Meq P S) fun x => \u2200 I : S.arrow, P.obj (op I.y) :=\n  \u27e8fun x => x.1\u27e9\n\n@[ext]\ntheorem ext {X} {P : C\u1d52\u1d56 \u2964 D} {S : J.cover X} (x y : Meq P S) (h : \u2200 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\u1d52\u1d56 \u2964 D} {S : J.cover X} (x : Meq P S) (I : S.Relation) :\n    P.map I.g\u2081.op (x ((S.index P).fstTo I)) = P.map I.g\u2082.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 \u27f6 T` of covers. -/\ndef refine {X : C} {P : C\u1d52\u1d56 \u2964 D} {S T : J.cover X} (x : Meq P T) (e : S \u27f6 T) : Meq P S :=\n  \u27e8fun I => x \u27e8I.y, I.f, (leOfHom e) _ I.hf\u27e9, fun I =>\n    x.condition\n      \u27e8I.y\u2081, I.y\u2082, I.z, I.g\u2081, I.g\u2082, I.f\u2081, I.f\u2082, (leOfHom e) _ I.h\u2081, (leOfHom e) _ I.h\u2082, I.w\u27e9\u27e9\n#align category_theory.meq.refine CategoryTheory.Meq.refine\n\n@[simp]\ntheorem refine_apply {X : C} {P : C\u1d52\u1d56 \u2964 D} {S T : J.cover X} (x : Meq P T) (e : S \u27f6 T)\n    (I : S.arrow) : x.refine e I = x \u27e8I.y, I.f, (leOfHom e) _ I.hf\u27e9 :=\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 \u27f6 X` in `C`. -/\ndef pullback {Y X : C} {P : C\u1d52\u1d56 \u2964 D} {S : J.cover X} (x : Meq P S) (f : Y \u27f6 X) :\n    Meq P ((J.pullback f).obj S) :=\n  \u27e8fun I => x \u27e8_, I.f \u226b f, I.hf\u27e9, fun I =>\n    x.condition\n      \u27e8I.y\u2081, I.y\u2082, I.z, I.g\u2081, I.g\u2082, I.f\u2081 \u226b f, I.f\u2082 \u226b f, I.h\u2081, I.h\u2082, by simp [reassoc_of I.w]\u27e9\u27e9\n#align category_theory.meq.pullback CategoryTheory.Meq.pullback\n\n@[simp]\ntheorem pullback_apply {Y X : C} {P : C\u1d52\u1d56 \u2964 D} {S : J.cover X} (x : Meq P S) (f : Y \u27f6 X)\n    (I : ((J.pullback f).obj S).arrow) : x.pullback f I = x \u27e8_, I.f \u226b f, I.hf\u27e9 :=\n  rfl\n#align category_theory.meq.pullback_apply CategoryTheory.Meq.pullback_apply\n\n@[simp]\ntheorem pullback_refine {Y X : C} {P : C\u1d52\u1d56 \u2964 D} {S T : J.cover X} (h : S \u27f6 T) (f : Y \u27f6 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\u1d52\u1d56 \u2964 D} (S : J.cover X) (x : P.obj (op X)) : Meq P S :=\n  \u27e8fun I => P.map I.f.op x, fun I => by\n    dsimp\n    simp only [\u2190 comp_apply, \u2190 P.map_comp, \u2190 op_comp, I.w]\u27e9\n#align category_theory.meq.mk CategoryTheory.Meq.mk\n\ntheorem mk_apply {X : C} {P : C\u1d52\u1d56 \u2964 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\u1d52\u1d56 \u2964 D) (S : J.cover X) [HasMultiequalizer (S.index P)] :\n    (multiequalizer (S.index P) : D) \u2243 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\u1d52\u1d56 \u2964 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.\u03b9 (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\u1d52\u1d56 \u2964 D} {S : J.cover X} [HasMultiequalizer (S.index P)]\n    (x : Meq P S) (I : S.arrow) : Multiequalizer.\u03b9 (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 [\u2190 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 [\u2200 X : C, HasColimitsOfShape (J.cover X)\u1d52\u1d56 D]\n\nvariable [\u2200 (P : C\u1d52\u1d56 \u2964 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\u1d52\u1d56 \u2964 D} {S : J.cover X} (x : Meq P S) : (J.plusObj P).obj (op X) :=\n  colimit.\u03b9 (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\u1d52\u1d56 \u2964 D} {S : J.cover X} (x : Meq P S) (f : Y \u27f6 X) :\n    (J.plusObj P).map f.op (mk x) = mk (x.pullback f) :=\n  by\n  dsimp [mk, plus_obj]\n  simp only [\u2190 comp_apply, colimit.\u03b9_pre, \u03b9_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, \u2190 comp_apply]\n  erw [multiequalizer.lift_\u03b9, 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\u1d52\u1d56 \u2964 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 \u27f6 \u22a4 := hom_of_le (OrderTop.le_top _)\n  rw [\u2190 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 [\u2190 comp_apply, category.assoc, multiequalizer.lift_\u03b9, 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\u1d52\u1d56 \u2964 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 [\u2190 comp_apply, colimit.\u03b9_pre, \u03b9_colim_map_assoc]\n  simp only [comp_apply]\n  dsimp only [functor.op]\n  let e : (J.pullback I.f).obj (unop (op S)) \u27f6 \u22a4 := hom_of_le (OrderTop.le_top _)\n  rw [\u2190 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 [\u2190 comp_apply, category.assoc, multiequalizer.lift_\u03b9, category.comp_id,\n    meq.equiv_symm_eq_apply]\n  let RR : S.relation :=\n    \u27e8_, _, _, i.f, \ud835\udfd9 _, I.f, i.f \u226b I.f, I.hf, sieve.downward_closed _ I.hf _, by simp\u27e9\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\u1d52\u1d56 \u2964 D} (x : P.obj (op X)) :\n    (J.toPlus P).app _ x = mk (Meq.mk \u22a4 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 \u22a4\n  ext i\n  simpa\n#align category_theory.grothendieck_topology.plus.to_plus_eq_mk CategoryTheory.GrothendieckTopology.Plus.toPlus_eq_mk\n\nvariable [\u2200 X : C, PreservesColimitsOfShape (J.cover X)\u1d52\u1d56 (forget D)]\n\ntheorem exists_rep {X : C} {P : C\u1d52\u1d56 \u2964 D} (x : (J.plusObj P).obj (op X)) :\n    \u2203 (S : J.cover X)(y : Meq P S), x = mk y :=\n  by\n  obtain \u27e8S, y, h\u27e9 := concrete.colimit_exists_rep (J.diagram P X) x\n  use S.unop, meq.equiv _ _ y\n  rw [\u2190 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\u1d52\u1d56 \u2964 D} {S T : J.cover X} (x : Meq P S) (y : Meq P T) :\n    mk x = mk y \u2194 \u2203 (W : J.cover X)(h1 : W \u27f6 S)(h2 : W \u27f6 T), x.refine h1 = y.refine h2 :=\n  by\n  constructor\n  \u00b7 intro h\n    obtain \u27e8W, h1, h2, hh\u27e9 := concrete.colimit_exists_of_rep_eq _ _ _ h\n    use W.unop, h1.unop, h2.unop\n    ext I\n    apply_fun multiequalizer.\u03b9 (W.unop.index P) I  at hh\n    convert hh\n    all_goals\n      dsimp [diagram]\n      simp only [\u2190 comp_apply, multiequalizer.lift_\u03b9, category.comp_id, meq.equiv_symm_eq_apply]\n      cases I; rfl\n  \u00b7 rintro \u27e8S, h1, h2, e\u27e9\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 [\u2190 comp_apply, multiequalizer.lift_\u03b9, 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\u207a` is always separated. -/\ntheorem sep {X : C} (P : C\u1d52\u1d56 \u2964 D) (S : J.cover X) (x y : (J.plusObj P).obj (op X))\n    (h : \u2200 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 \u27e8Sx, x, rfl\u27e9 := exists_rep x\n  obtain \u27e8Sy, y, rfl\u27e9 := 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 \u27f6 Sx :=\n    hom_of_le\n      (by\n        rintro Y f \u27e8Z, e1, e2, he2, he1, hee\u27e9\n        rw [\u2190 hee]\n        apply le_of_hom (h1 \u27e8_, _, he2\u27e9)\n        exact he1)\n  let ey : B \u27f6 Sy :=\n    hom_of_le\n      (by\n        rintro Y f \u27e8Z, e1, e2, he2, he1, hee\u27e9\n        rw [\u2190 hee]\n        apply le_of_hom (h2 \u27e8_, _, he2\u27e9)\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  \u00b7 let Rx : Sx.relation :=\n      \u27e8I.Y, I.Y, I.Y, \ud835\udfd9 _, \ud835\udfd9 _, I.f, I.to_middle_hom \u226b I.from_middle_hom, _, _, by\n        simp [I.middle_spec]\u27e9\n    have := x.condition Rx\n    simpa using this\n  \u00b7 let Ry : Sy.relation :=\n      \u27e8I.Y, I.Y, I.Y, \ud835\udfd9 _, \ud835\udfd9 _, I.f, I.to_middle_hom \u226b I.from_middle_hom, _, _, by\n        simp [I.middle_spec]\u27e9\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\u1d52\u1d56 \u2964 D)\n    (hsep :\n      \u2200 (X : C) (S : J.cover X) (x y : P.obj (op X)),\n        (\u2200 I : S.arrow, P.map I.f.op x = P.map I.f.op y) \u2192 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 \u27e8W, h1, h2, hh\u27e9 := 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\u207a`, 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\u1d52\u1d56 \u2964 D)\n    (hsep :\n      \u2200 (X : C) (S : J.cover X) (x y : P.obj (op X)),\n        (\u2200 I : S.arrow, P.map I.f.op x = P.map I.f.op y) \u2192 x = y)\n    (X : C) (S : J.cover X) (s : Meq (J.plusObj P) S) (T : \u2200 I : S.arrow, J.cover I.y)\n    (t : \u2200 I : S.arrow, Meq P (T I)) (ht : \u2200 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 [\u2190 comp_apply, \u2190 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, \u2190 ht, \u2190 ht, \u2190\n      comp_apply, \u2190 comp_apply, \u2190 (J.plus_obj P).map_comp, \u2190 (J.plus_obj P).map_comp]\n    rw [\u2190 op_comp, \u2190 op_comp]\n    let IR : S.relation :=\n      \u27e8_, _, _, II.g\u2081 \u226b II.fst.to_middle_hom, II.g\u2082 \u226b 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, _\u27e9\n    swap;\n    \u00b7 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\u1d52\u1d56 \u2964 D)\n    (hsep :\n      \u2200 (X : C) (S : J.cover X) (x y : P.obj (op X)),\n        (\u2200 I : S.arrow, P.map I.f.op x = P.map I.f.op y) \u2192 x = y)\n    (X : C) (S : J.cover X) (s : Meq (J.plusObj P) S) :\n    \u2203 t : (J.plusObj P).obj (op X), Meq.mk S t = s :=\n  by\n  have inj : \u2200 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\u207a` 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) \u27f6 (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        \u00b7 cases I\n          exact hf)\n  use e0, \ud835\udfd9 _\n  ext IV\n  dsimp only [meq.refine_apply, meq.pullback_apply, w]\n  let IA : B.arrow := \u27e8_, (IV.f \u226b II.f) \u226b I.f, _\u27e9\n  swap\n  \u00b7 refine' \u27e8I.Y, _, _, I.hf, _, rfl\u27e9\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 := \u27e8IV.Y, IV.f \u226b II.f, sieve.downward_closed (T I) II.hf IV.f\u27e9\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, \u2190 ht, \u2190 ht]\n  -- Conclude by constructing the relation showing equality...\n  let IR : S.relation := \u27e8_, _, IV.Y, IC.f, ID.f, IB.f, I.f, _, I.hf, IA.middle_spec\u27e9\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\u207a` is a sheaf. -/\ntheorem isSheaf_of_sep (P : C\u1d52\u1d56 \u2964 D)\n    (hsep :\n      \u2200 (X : C) (S : J.cover X) (x y : P.obj (op X)),\n        (\u2200 I : S.arrow, P.map I.f.op x = P.map I.f.op y) \u2192 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  \u00b7 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    \u00b7 erw [meq.equiv_apply, \u2190 comp_apply, multiequalizer.lift_\u03b9]\n    \u00b7 erw [meq.equiv_apply, \u2190 comp_apply, multiequalizer.lift_\u03b9]\n  \u00b7 rintro (x : (multiequalizer (S.index _) : D))\n    obtain \u27e8t, ht\u27e9 := exists_of_sep P hsep X S (meq.equiv _ _ x)\n    use t\n    apply_fun meq.equiv _ _\n    swap\n    \u00b7 infer_instance\n    rw [\u2190 ht]\n    ext i\n    dsimp\n    rw [\u2190 comp_apply, multiequalizer.lift_\u03b9]\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\u207a\u207a` is always a sheaf. -/\ntheorem isSheaf_plus_plus (P : C\u1d52\u1d56 \u2964 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 [\u2200 (P : C\u1d52\u1d56 \u2964 D) (X : C) (S : J.cover X), HasMultiequalizer (S.index P)]\n  [\u2200 X : C, HasColimitsOfShape (J.cover X)\u1d52\u1d56 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\u1d52\u1d56 \u2964 D) : C\u1d52\u1d56 \u2964 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\u1d52\u1d56 \u2964 D) : P \u27f6 J.sheafify P :=\n  J.toPlus P \u226b 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\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) : J.sheafify P \u27f6 J.sheafify Q :=\n  J.plusMap <| J.plusMap \u03b7\n#align category_theory.grothendieck_topology.sheafify_map CategoryTheory.GrothendieckTopology.sheafifyMap\n\n@[simp]\ntheorem sheafifyMap_id (P : C\u1d52\u1d56 \u2964 D) : J.sheafifyMap (\ud835\udfd9 P) = \ud835\udfd9 (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\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) (\u03b3 : Q \u27f6 R) :\n    J.sheafifyMap (\u03b7 \u226b \u03b3) = J.sheafifyMap \u03b7 \u226b J.sheafifyMap \u03b3 :=\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\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) :\n    \u03b7 \u226b J.toSheafify _ = J.toSheafify _ \u226b J.sheafifyMap \u03b7 :=\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\u1d52\u1d56 \u2964 D) \u2964 C\u1d52\u1d56 \u2964 D :=\n  J.plusFunctor D \u22d9 J.plusFunctor D\n#align category_theory.grothendieck_topology.sheafification CategoryTheory.GrothendieckTopology.sheafification\n\n@[simp]\ntheorem sheafification_obj (P : C\u1d52\u1d56 \u2964 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\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) :\n    (J.sheafification D).map \u03b7 = J.sheafifyMap \u03b7 :=\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 : \ud835\udfed _ \u27f6 sheafification J D :=\n  J.toPlusNatTrans D \u226b 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\u1d52\u1d56 \u2964 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\u1d52\u1d56 \u2964 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\u1d52\u1d56 \u2964 D} (hP : Presheaf.IsSheaf J P) : P \u2245 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\u1d52\u1d56 \u2964 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 \u27f6 Q`, construct a morphism from\n`J.sheafifcation P` to `Q`. -/\ndef sheafifyLift {P Q : C\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) (hQ : Presheaf.IsSheaf J Q) : J.sheafify P \u27f6 Q :=\n  J.plusLift (J.plusLift \u03b7 hQ) hQ\n#align category_theory.grothendieck_topology.sheafify_lift CategoryTheory.GrothendieckTopology.sheafifyLift\n\n@[simp, reassoc.1]\ntheorem toSheafify_sheafifyLift {P Q : C\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) (hQ : Presheaf.IsSheaf J Q) :\n    J.toSheafify P \u226b sheafifyLift J \u03b7 hQ = \u03b7 :=\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\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) (hQ : Presheaf.IsSheaf J Q)\n    (\u03b3 : J.sheafify P \u27f6 Q) : J.toSheafify P \u226b \u03b3 = \u03b7 \u2192 \u03b3 = sheafifyLift J \u03b7 hQ :=\n  by\n  intro h\n  apply plus_lift_unique\n  apply plus_lift_unique\n  rw [\u2190 category.assoc, \u2190 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\u1d52\u1d56 \u2964 D} (hP : Presheaf.IsSheaf J P) :\n    (J.isoSheafify hP).inv = J.sheafifyLift (\ud835\udfd9 _) 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\u1d52\u1d56 \u2964 D} (\u03b7 \u03b3 : J.sheafify P \u27f6 Q) (hQ : Presheaf.IsSheaf J Q)\n    (h : J.toSheafify P \u226b \u03b7 = J.toSheafify P \u226b \u03b3) : \u03b7 = \u03b3 :=\n  by\n  apply J.plus_hom_ext _ _ hQ\n  apply J.plus_hom_ext _ _ hQ\n  rw [\u2190 category.assoc, \u2190 category.assoc, \u2190 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\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) (\u03b3 : Q \u27f6 R)\n    (hR : Presheaf.IsSheaf J R) :\n    J.sheafifyMap \u03b7 \u226b J.sheafifyLift \u03b3 hR = J.sheafifyLift (\u03b7 \u226b \u03b3) hR :=\n  by\n  apply J.sheafify_lift_unique\n  rw [\u2190 category.assoc, \u2190 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  [\u2200 (P : C\u1d52\u1d56 \u2964 D) (X : C) (S : J.cover X), HasMultiequalizer (S.index P)]\n  [\u2200 X : C, HasColimitsOfShape (J.cover X)\u1d52\u1d56 D]\n  [\u2200 X : C, PreservesColimitsOfShape (J.cover X)\u1d52\u1d56 (forget D)] [ReflectsIsomorphisms (forget D)]\n\ntheorem GrothendieckTopology.sheafify_isSheaf (P : C\u1d52\u1d56 \u2964 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\u1d52\u1d56 \u2964 D) \u2964 Sheaf J D\n    where\n  obj P := \u27e8J.sheafify P, J.sheafify_isSheaf P\u27e9\n  map P Q \u03b7 := \u27e8J.sheafifyMap \u03b7\u27e9\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.\u03b9_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 \u22a3 sheafToPresheaf J D :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun P Q =>\n        { toFun := fun e => J.toSheafify P \u226b e.val\n          invFun := fun e => \u27e8J.sheafifyLift e Q.2\u27e9\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 \u03b7 \u03b3; ext1; dsimp; symm\n        apply J.sheafify_map_sheafify_lift\n      homEquiv_naturality_right := fun P Q R \u03b7 \u03b3 =>\n        by\n        dsimp\n        rw [category.assoc] }\n#align category_theory.sheafification_adjunction CategoryTheory.sheafificationAdjunction\n\ninstance sheafToPresheafIsRightAdjoint : IsRightAdjoint (sheafToPresheaf J D) :=\n  \u27e8_, sheafificationAdjunction J D\u27e9\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 \u27f6 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 \u27f6 G) : Mono f \u2194 Mono f.1 :=\n  \u27e8fun m => by\n    skip\n    infer_instance, fun m => by\n    skip\n    exact Sheaf.hom.mono_of_presheaf_mono J D f\u27e9\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 \u2245 (presheafToSheaf J D).obj P.val\n    where\n  Hom := \u27e8(J.isoSheafify P.2).Hom\u27e9\n  inv := \u27e8(J.isoSheafify P.2).inv\u27e9\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\u27e8(localization.of _).to_map 1\u27e9\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 : \u03a0 x : U, localizations R x) : Prop :=\n\u2203 (r s : R), \u2200 x : U,\n  \u00ac (s \u2208 x.1.as_ideal) \u2227 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 := \u03bb U f, is_fraction f,\n  res := by { rintro V U i f \u27e8r, s, w\u27e9, exact \u27e8r, s, \u03bb x, w (i x)\u27e9 } }\n\n/--\nWe will define the structure sheaf as\nthe subsheaf of all dependent functions in `\u03a0 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 \u2286 Spec A$, we define $\ud835\udcaa(U)$ to be the set of functions\n$s : U \u2192 \u2a06_{\ud835\udd2d \u2208 U} A_\ud835\udd2d$, such that $s(\ud835\udd2d) \u2208 A_\ud835\udd2d$ for each $\ud835\udd2d$,\nand such that $s$ is locally a quotient of elements of $A$:\nto be precise, we require that for each $\ud835\udd2d \u2208 U$, there is a neighborhood $V$ of $\ud835\udd2d$,\ncontained in $U$, and elements $a, f \u2208 A$, such that for each $\ud835\udd2e \u2208 V, f \u2209 \ud835\udd2e$,\nand $s(\ud835\udd2e) = a/f$ in $A_\ud835\udd2e$.\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`\u03a0 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 : \u03a0 x : U, localizations R x) :\n  (is_locally_fraction R).pred f =\n  \u2200 x : U, \u2203 (V) (m : x.1 \u2208 V) (i : V \u27f6 U),\n  \u2203 (r s : R), \u2200 y : V,\n  \u00ac (s \u2208 y.1.as_ideal) \u2227\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))\u1d52\u1d56) :\n  subring (\u03a0 x : unop U, localizations R x) :=\n{ carrier := { f | (is_locally_fraction R).pred f },\n  zero_mem' :=\n  begin\n    refine \u03bb x, \u27e8unop U, x.2, \ud835\udfd9 _, 0, 1, \u03bb y, \u27e8_, _\u27e9\u27e9,\n    { rw \u2190ideal.ne_top_iff_one, exact y.1.is_prime.1, },\n    { simp, },\n  end,\n  one_mem' :=\n  begin\n    refine \u03bb x, \u27e8unop U, x.2, \ud835\udfd9 _, 1, 1, \u03bb y, \u27e8_, _\u27e9\u27e9,\n    { rw \u2190ideal.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 \u27e8Va, ma, ia, ra, sa, wa\u27e9,\n    rcases hb x with \u27e8Vb, mb, ib, rb, sb, wb\u27e9,\n    refine \u27e8Va \u2293 Vb, \u27e8ma, mb\u27e9, opens.inf_le_left _ _ \u226b ia, ra * sb + rb * sa, sa * sb, _\u27e9,\n    intro y,\n    rcases wa (opens.inf_le_left _ _ y) with \u27e8nma, wa\u27e9,\n    rcases wb (opens.inf_le_right _ _ y) with \u27e8nmb, wb\u27e9,\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 [\u2190wa, \u2190wb],\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 \u27e8V, m, i, r, s, w\u27e9,\n    refine \u27e8V, m, i, -r, s, _\u27e9,\n    intro y,\n    rcases w y with \u27e8nm, w\u27e9,\n    fsplit,\n    { exact nm, },\n    { simp only [ring_hom.map_neg, pi.neg_apply],\n      erw [\u2190w],\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 \u27e8Va, ma, ia, ra, sa, wa\u27e9,\n    rcases hb x with \u27e8Vb, mb, ib, rb, sb, wb\u27e9,\n    refine \u27e8Va \u2293 Vb, \u27e8ma, mb\u27e9, opens.inf_le_left _ _ \u226b ia, ra * rb, sa * sb, _\u27e9,\n    intro y,\n    rcases wa (opens.inf_le_left _ _ y) with \u27e8nma, wa\u27e9,\n    rcases wb (opens.inf_le_right _ _ y) with \u27e8nmb, wb\u27e9,\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 [\u2190wa, \u2190wb],\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))\u1d52\u1d56) :\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 := \u03bb U, CommRing.of ((structure_sheaf_in_Type R).presheaf.obj U),\n  map := \u03bb U V i,\n  { to_fun := ((structure_sheaf_in_Type R).presheaf.map i),\n    map_zero' := rfl,\n    map_add' := \u03bb x y, rfl,\n    map_one' := rfl,\n    map_mul' := \u03bb 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 \u22d9 (forget CommRing) \u2245 (structure_sheaf_in_Type R).presheaf :=\nnat_iso.of_components\n  (\u03bb 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 \u27f6 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 \u2264 D_g) : OX(V) [for api]\n2. def to_open (U) : R \u27f6 OX(U)\n3. [2] def to_stalk (p : Spec R) : R \u27f6 OX_p\n4. [2] def to_basic_open (f : R) : R_f \u27f6 OX(D_f)\n5. [3] def localization_to_stalk (p : Spec R) : R_p \u27f6 OX_p\n6. def open_to_localization (U) (p) (hp : p \u2208 U) : OX(U) \u27f6 R_p\n7. [6] def stalk_to_fiber_ring_hom (p : Spec R) : OX_p \u27f6 R_p\n8. [5,7] def stalk_iso (p : Spec R) : OX_p \u2245 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 \u2208 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 : \u2200 x \u2208 U, g \u2208 (x : Spec.Top R).as_ideal.prime_compl) :\n  (structure_sheaf R).presheaf.obj (op U) :=\n\u27e8\u03bb x, (localization.of _).mk' f \u27e8g, hu x x.2\u27e9,\n \u03bb x, \u27e8U, x.2, \ud835\udfd9 _, f, g, \u03bb y, \u27e8hu y y.2, localization_map.mk'_spec _ _ _\u27e9\u27e9\u27e9\n\n@[simp] lemma const_apply (f g : R) (U : opens (Spec.Top R))\n  (hu : \u2200 x \u2208 U, g \u2208 (x : Spec.Top R).as_ideal.prime_compl) (x : U) :\n  (const R f g U hu).1 x = (localization.of _).mk' f \u27e8g, hu x x.2\u27e9 :=\nrfl\n\nlemma const_apply' (f g : R) (U : opens (Spec.Top R))\n  (hu : \u2200 x \u2208 U, g \u2208 (x : Spec.Top R).as_ideal.prime_compl) (x : U)\n  (hx : g \u2208 (as_ideal x.1).prime_compl) :\n  (const R f g U hu).1 x = (localization.of _).mk' f \u27e8g, hx\u27e9 :=\nrfl\n\nlemma exists_const (U) (s : (structure_sheaf R).presheaf.obj (op U)) (x : Spec.Top R) (hx : x \u2208 U) :\n  \u2203 (V : opens (Spec.Top R)) (hxV : x \u2208 V) (i : V \u27f6 U) (f g : R) hg,\n  const R f g V hg = (structure_sheaf R).presheaf.map i.op s :=\nlet \u27e8V, hxV, iVU, f, g, hfg\u27e9 := s.2 \u27e8x, hx\u27e9 in\n\u27e8V, hxV, iVU, f, g, \u03bb y hyV, (hfg \u27e8y, hyV\u27e9).1, subtype.eq $ funext $ \u03bb y,\n(localization.of _).mk'_eq_iff_eq_mul.2 $ eq.symm $ (hfg y).2\u27e9\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) (\u03bb _, 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 $ \u03bb 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 $ \u03bb x, localization_map.mk'_self _ _\n\nlemma const_one (U) : const R 1 1 U (\u03bb p _, submonoid.one_mem _) = 1 :=\nconst_self R 1 U _\n\nlemma const_add (f\u2081 f\u2082 g\u2081 g\u2082 : R) (U hu\u2081 hu\u2082) :\n  const R f\u2081 g\u2081 U hu\u2081 + const R f\u2082 g\u2082 U hu\u2082 =\n  const R (f\u2081 * g\u2082 + f\u2082 * g\u2081) (g\u2081 * g\u2082) U (\u03bb x hx, submonoid.mul_mem _ (hu\u2081 x hx) (hu\u2082 x hx)) :=\nsubtype.eq $ funext $ \u03bb x, eq.symm $\nby convert (localization.of _).mk'_add f\u2081 f\u2082 \u27e8g\u2081, hu\u2081 x x.2\u27e9 \u27e8g\u2082, hu\u2082 x x.2\u27e9\n\nlemma const_mul (f\u2081 f\u2082 g\u2081 g\u2082 : R) (U hu\u2081 hu\u2082) :\n  const R f\u2081 g\u2081 U hu\u2081 * const R f\u2082 g\u2082 U hu\u2082 =\n  const R (f\u2081 * f\u2082) (g\u2081 * g\u2082) U (\u03bb x hx, submonoid.mul_mem _ (hu\u2081 x hx) (hu\u2082 x hx)) :=\nsubtype.eq $ funext $ \u03bb x, eq.symm $\nby convert (localization.of _).mk'_mul f\u2081 f\u2082 \u27e8g\u2081, hu\u2081 x x.2\u27e9 \u27e8g\u2082, hu\u2082 x x.2\u27e9\n\nlemma const_ext {f\u2081 f\u2082 g\u2081 g\u2082 : R} {U hu\u2081 hu\u2082} (h : f\u2081 * g\u2082 = f\u2082 * g\u2081) :\n  const R f\u2081 g\u2081 U hu\u2081 = const R f\u2082 g\u2082 U hu\u2082 :=\nsubtype.eq $ funext $ \u03bb x, (localization.of _).mk'_eq_of_eq h.symm\n\nlemma const_congr {f\u2081 f\u2082 g\u2081 g\u2082 : R} {U hu} (hf : f\u2081 = f\u2082) (hg : g\u2081 = g\u2082) :\n  const R f\u2081 g\u2081 U hu = const R f\u2082 g\u2082 U (hg \u25b8 hu) :=\nby substs hf hg\n\nlemma const_mul_rev (f g : R) (U hu\u2081 hu\u2082) :\n  const R f g U hu\u2081 * const R g f U hu\u2082 = 1 :=\nby rw [const_mul, const_congr R rfl (mul_comm g f), const_self]\n\nlemma const_mul_cancel (f g\u2081 g\u2082 : R) (U hu\u2081 hu\u2082) :\n  const R f g\u2081 U hu\u2081 * const R g\u2081 g\u2082 U hu\u2082 = const R f g\u2082 U hu\u2082 :=\nby { rw [const_mul, const_ext], rw mul_assoc }\n\nlemma const_mul_cancel' (f g\u2081 g\u2082 : R) (U hu\u2081 hu\u2082) :\n  const R g\u2081 g\u2082 U hu\u2082 * const R f g\u2081 U hu\u2081 = const R f g\u2082 U hu\u2082 :=\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 \u27f6 (structure_sheaf R).presheaf.obj (op U) :=\n{ to_fun := \u03bb f, \u27e8\u03bb x, (localization.of _).to_map f,\n    \u03bb x, \u27e8U, x.2, \ud835\udfd9 _, f, 1, \u03bb y, \u27e8(ideal.ne_top_iff_one _).1 y.1.2.1,\n      by { rw [ring_hom.map_one, mul_one], refl } \u27e9\u27e9\u27e9,\n  map_one' := subtype.eq $ funext $ \u03bb x, ring_hom.map_one _,\n  map_mul' := \u03bb f g, subtype.eq $ funext $ \u03bb x, ring_hom.map_mul _ _ _,\n  map_zero' := subtype.eq $ funext $ \u03bb x, ring_hom.map_zero _,\n  map_add' := \u03bb f g, subtype.eq $ funext $ \u03bb x, ring_hom.map_add _ _ _ }\n\n@[simp] lemma to_open_res (U V : opens (Spec.Top R)) (i : V \u27f6 U) :\n  to_open R U \u226b (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 (\u03bb x _, (ideal.ne_top_iff_one _).1 x.2.1) :=\nsubtype.eq $ funext $ \u03bb 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 \u27f6 (structure_sheaf R).presheaf.stalk x :=\n(to_open R \u22a4 \u226b (structure_sheaf R).presheaf.germ \u27e8x, \u27e8\u27e9\u27e9 : _)\n\n@[simp] lemma to_open_germ (U : opens (Spec.Top R)) (x : U) :\n  to_open R U \u226b (structure_sheaf R).presheaf.germ x =\n  to_stalk R x :=\nby { rw [\u2190 to_open_res R \u22a4 U (hom_of_le le_top : U \u27f6 \u22a4), 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 \u2190 to_open_germ, refl }\n\nlemma germ_to_top (x : Spec.Top R) (f : R) :\n  (structure_sheaf R).presheaf.germ (\u27e8x, trivial\u27e9 : (\u22a4 : opens (Spec.Top R))) (to_open R \u22a4 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) (\u03bb _, id)) $\nby rw [to_open_eq_const, const_mul_rev]\n\n/-- The canonical ring homomorphism interpreting `s \u2208 R_f` as a section of the structure sheaf\non the basic open defined by `f \u2208 R`. -/\ndef to_basic_open (f : R) : CommRing.of (localization (submonoid.powers f)) \u27f6\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) (\u03bb 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 $ \u03bb 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) (\u03bb _ _, 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 \u2190 germ_to_open R (basic_open (f : R)) \u27e8x, f.2\u27e9 (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) \u27f6 (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 (\u27e8x, s.2\u27e9 : basic_open (s : R))\n    (const R f s (basic_open s) (\u03bb _, id)) :=\n((localization.of _).lift_mk'_spec _ _ _ _).2 $\nby erw [\u2190 germ_to_open R (basic_open s) \u27e8x, s.2\u27e9, \u2190 germ_to_open R (basic_open s) \u27e8x, s.2\u27e9,\n    \u2190 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 \u2208 U) :\n  (structure_sheaf R).presheaf.obj (op U) \u27f6 CommRing.of (localization.at_prime x.as_ideal) :=\n{ to_fun := \u03bb s, (s.1 \u27e8x, hx\u27e9 : _),\n  map_one' := rfl,\n  map_mul' := \u03bb _ _, rfl,\n  map_zero' := rfl,\n  map_add' := \u03bb _ _, rfl }\n\n@[simp] lemma coe_open_to_localization (U : opens (Spec.Top R)) (x : Spec.Top R) (hx : x \u2208 U) :\n  (open_to_localization R U x hx :\n    (structure_sheaf R).presheaf.obj (op U) \u2192 localization.at_prime x.as_ideal) =\n  (\u03bb s, (s.1 \u27e8x, hx\u27e9 : _)) :=\nrfl\n\nlemma open_to_localization_apply (U : opens (Spec.Top R)) (x : Spec.Top R) (hx : x \u2208 U)\n  (s : (structure_sheaf R).presheaf.obj (op U)) :\n  open_to_localization R U x hx s = (s.1 \u27e8x, hx\u27e9 : _) :=\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 \u27f6 CommRing.of (localization.at_prime x.as_ideal) :=\nlimits.colimit.desc (((open_nhds.inclusion x).op) \u22d9 (structure_sheaf R).presheaf)\n  { X := _,\n    \u03b9 :=\n    { app := \u03bb 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 \u226b stalk_to_fiber_ring_hom R x =\n  open_to_localization R U x x.2 :=\nlimits.colimit.\u03b9_desc _ _\n\n@[simp] lemma stalk_to_fiber_ring_hom_germ' (U : opens (Spec.Top R)) (x : Spec.Top R) (hx : x \u2208 U)\n  (s : (structure_sheaf R).presheaf.obj (op U)) :\n  stalk_to_fiber_ring_hom R x ((structure_sheaf R).presheaf.germ \u27e8x, hx\u27e9 s) = (s.1 \u27e8x, hx\u27e9 : _) :=\nring_hom.ext_iff.1 (germ_comp_stalk_to_fiber_ring_hom R U \u27e8x, hx\u27e9 : _) 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 \u226b 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 \u2245 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 $ \u03bb U hxU,\n  begin\n    ext s, simp only [coe_comp], rw [coe_id, stalk_to_fiber_ring_hom_germ'],\n    obtain \u27e8V, hxV, iVU, f, g, hg, hs\u27e9 := exists_const _ _ s x hxU,\n    erw [\u2190 res_apply R U V iVU s \u27e8x, hxV\u27e9, \u2190 hs, const_apply, localization_to_stalk_mk'],\n    refine (structure_sheaf R).presheaf.germ_ext V hxV (hom_of_le hg) iVU _,\n    erw [\u2190 hs, res_const']\n  end,\n  inv_hom_id' := (localization.of x.as_ideal.prime_compl).epic_of_localization_map $ \u03bb 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 : \u2102) :\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 : \u2115) : \u2203 m : \u2115, n < m := sorry\n```\n\nproduces\n\n```\ndef it (n : \u2115) : \u2115 := classical.some (it_exists n)\n\nlemma it_spec (n : \u2115) : 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 \u2192 name \u2192 expr \u2192 pexpr \u2192 tactic unit)\n(names : list name)\n(pis_depth : \u2115 := 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 `\u2203` 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 \u2192 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 \u2227 B \u2227 C`) to a specific proof (eg\n`B`).\n-/\nmeta structure parse_ctx_props extends parse_ctx_exists :=\n(project_proof : pexpr \u2192 pexpr := id)\n\n/--\nReplaces free variables with their exists declaration. For example, if:\n\n```lean\ndef n_value : \u2115 := ... -- generated by `expand_exists`\n```\n\nthen this function converts `#0` in `#0 = #0` from `\u2203 n : \u2115, 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 (\u03bbname,\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 \u2227 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 \u2192 expr \u2192 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 := (\u03bb p, (const `and.left []) p) \u2218 ctx.project_proof,\n      ..ctx } p\n    >> parse_props { names := tail,\n      project_proof := (\u03bb p, (const `and.right []) p) \u2218 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 `\u2203 a : \u03b1, p a`, and creates an associated definition with a value of `\u03b1`. When `p \u03b1` is\nnot an exists statement, it will call `parse_props`.\n-/\nmeta def parse_exists : parse_ctx_exists \u2192 expr \u2192 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  \u27e8n, names\u27e9 <- 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 `\u2200 (a : \u03b1), p a`. If `p` is not a pi expression, it will call `parse_exists`\n-/\nmeta def parse_pis : parse_ctx \u2192 expr \u2192 tactic unit\n| ctx (pi n bi ty body) :=\n  -- When making a declaration, wrap in an equivalent pi expression.\n  let decl := (\u03bb 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 := (\u03bb (e : expr),\n    (list.range ctx.pis_depth).foldr (\u03bb 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 : \u2115) : \u2203 m : \u2115, n < m := ...\n\n#check nat_greater      -- nat_greater : \u2115 \u2192 \u2115\n#check nat_greater_spec -- nat_greater_spec : \u2200 (n : \u2115), 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 : \u2115) : \u2203 (m l : \u2115), n < m \u2227 m < l := ...\n\n#check nat_greater_m      -- nat_greater : \u2115 \u2192 \u2115\n#check nat_greater_l      -- nat_greater : \u2115 \u2192 \u2115\n#check nat_greater_spec-- nat_greater_spec : \u2200 (n : \u2115),\n  n < nat_greater_m n \u2227 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 : \u2115) : \u2203 m : \u2115, n < m \u2227 m \u2260 0 := ...\n\n#check nat_greater         -- nat_greater : \u2115 \u2192 \u2115\n#check nat_greater_lt      -- nat_greater_lt : \u2200 (n : \u2115), n < nat_greater n\n#check nat_greater_nonzero -- nat_greater_nonzero : \u2200 (n : \u2115), nat_greater n \u2260 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 : \u2200 (n : \u2115), n < nat_greater n \u2227 nat_greater n \u2260 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 $ \u03bb 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 := \u03bb is_t n ty val, (tactic.to_expr val >>= \u03bb 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) \u2124\nnoncomputable theory\n\nlocal notation `\u210d'`:= (\u27e8upper_half_plane.upper_half_space , upper_half_plane_is_open\u27e9: topological_space.opens \u2102)\n\n/-! ### Eisenstein series -/\n\nnamespace Eisenstein_series\n\n/-- The function on `\u2124 \u00d7 \u2124` whose sum defines an Eisenstein series.-/\n\ndef Eise (k: \u2124) (z : \u210d) : \u2124 \u00d7 \u2124 \u2192  \u2102:=\n\u03bb x, 1/(x.1*z+x.2)^k\n\n/-\ndef Eisen (k : \u2124) (x : \u2124 \u00d7 \u2124) : C(\u210d, \u2102) :=\n\u27e8\u03bb z, 1/(x.1*z+x.2)^k, by {simp,  sorry}\u27e9\n-/\n\ninstance : topological_space C(\u210d, \u2102) :=infer_instance\n\n\n\ndef Eise' (k: \u2124) (z : \u2102) : \u2124 \u00d7 \u2124 \u2192  \u2102:=\n\u03bb x, 1/(x.1*z+x.2)^k\n\ndef real_Eise (k: \u2124) (z : \u210d) : \u2124 \u00d7 \u2124 \u2192  \u211d:=\n\u03bb x, complex.abs(1/(x.1*z+x.2)^k)\n\n\ndef Eise_deriv (k: \u2124) (z : \u2102) : \u2124 \u00d7 \u2124 \u2192  \u2102:=\n\u03bb x, (-k*x.1)/(x.1*z+x.2)^(k+1)\n\n\n/--The Eisenstein series of weight `k : \u2124` -/\ndef Eisenstein_series_of_weight_ (k: \u2124) : \u210d \u2192 \u2102:=\n \u03bb z, \u2211' (x : \u2124 \u00d7 \u2124), (Eise k z x)\n\ndef real_Eisenstein_series_of_weight_ (k: \u2124) : \u210d \u2192 \u211d:=\n \u03bb z, \u2211' (x : \u2124 \u00d7 \u2124), (real_Eise k z x)\n\ndef Eisenstein_deriv_weight (k: \u2124) : \u210d \u2192 \u2102:=\n \u03bb z, \u2211' (x : \u2124 \u00d7 \u2124), (Eise_deriv k z x)\n\n\n/-\nlemma summable2 (k : \u2124) (h: 3 \u2264 k) : summable (Eisen k):=\nbegin\n  sorry,\nend\n\n\ndef Eisenstein_series_of_weight_' (k: \u2124) : C(\u210d, \u2102):=\n \u2211' (x : \u2124 \u00d7 \u2124), Eisen k x\n-/\n\nlemma Eise_is_nonneg (k: \u2124) (z : \u210d) (y : \u2124 \u00d7 \u2124): 0 \u2264 abs (Eise k z y):=\nbegin\n apply complex.abs.nonneg,\nend\n\nlemma calc_lem (k: \u2124) (a b c d i1 i2: \u2102) (z : \u210d) (h: c*z+d \u2260 0) :\n((i1* ((a*z+b)/(c*z+d))+i2)^k)\u207b\u00b9=(c*z+d)^k* (((i1 * a + i2 * c) * z + (i1 * b + i2 * d))^k)\u207b\u00b9:=\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 \u2260 0,\n  by {apply zpow_ne_zero _ h,  },\n  apply congr_arg (\u03bb (b : \u2102), (c*z+d)^k * b\u207b\u00b9),\n  ring_nf,\nend\n\nlemma coe_chain (A: SL2Z) (i j : fin (2)):\n  (A.1 i j : \u2102)= ((A.1 : (matrix (fin 2) (fin 2) \u211d) ) i j : \u2102):=\nbegin\n  simp,\n  rw \u2190 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: \u2124) (z : \u210d) (A : SL2Z) (i : \u2124 \u00d7 \u2124 ) :\n  Eise k ( (A : matrix.GL_pos (fin 2) \u211d) \u2022 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 \u2190 coe_coe,\n  apply upper_half_plane.denom_ne_zero A,\nend\n\ndef Eisenstein_is_slash_inv (\u0393 : subgroup SL2Z) (k: \u2124) :\n(slash_invariant_form \u0393 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 : \u2115) (z : \u210d) (n : \u2115) (x: \u2124 \u00d7 \u2124) (h: x \u2208 Square n) (hn: 1 \u2264 n):\n  (complex.abs(((x.1: \u2102)*z+(x.2: \u2102))^k))\u207b\u00b9 \u2264 (complex.abs ((rfunct z)^k* n^k))\u207b\u00b9 :=\nbegin\n  by_cases C1: complex.abs (x.1: \u2102)=n,\n  rw inv_le_inv,\n  have h0: (x.1:\u2102) \u2260 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 \u2190 C1 at hn,\n  simp only [nat.one_ne_zero, le_zero_iff] at hn,\n  exact hn,},\n  have h1:(\u2191(x.fst) * \u2191z + \u2191(x.snd)) ^ k =  (\u2191(x.fst))^k* ((z: \u2102)+(x.2: \u2102)/(\u2191(x.fst)))^k,\n  by { rw \u2190 mul_pow,\n  rw div_eq_mul_inv,\n  have: (x.fst: \u2102) * ((z: \u2102)  + (x.snd: \u2102) * ((x.fst: \u2102))\u207b\u00b9)=(x.fst: \u2102) * (z: \u2102) + (x.snd: \u2102),\n  by {have p1: (x.fst: \u2102) * ((z: \u2102)  + (x.snd: \u2102) * ((x.fst: \u2102))\u207b\u00b9)=\n  ((x.fst: \u2102) * (z: \u2102)  + (x.fst : \u2102) * ((x.fst: \u2102))\u207b\u00b9 * (x.snd: \u2102)),\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 (\u2191(x.fst) ^ k)= (complex.abs (\u2191(x.fst)))^k , by {apply complex.abs_pow, },\n  rw h3,\n  rw C1,\n  have h4: complex.abs (\u2191n ^ k)=\u2191n ^ 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): \u2102) * (z: \u2102) + (x.snd: \u2102) \u2260 0, by {\n  intro H,\n  have H1 : x.1 = 0 \u2228 (z: \u2102).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 \u2190 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: \u2102)=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 \u2190 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 \u2190 this,\n  rw int.abs_eq_nat_abs,},\n  rw inv_le_inv,\n  have h0: (x.2: \u2102 ) \u2260 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 \u2190 C2 at hn,\n  simp only [nat.one_ne_zero, le_zero_iff] at hn,\n  exact hn,},\n  have h1:(\u2191(x.fst) * \u2191z + \u2191(x.snd)) ^ k =  (\u2191(x.snd))^k* (((x.1:\u2102)/(x.2: \u2102))*(z: \u2102)+1)^k,\n  by {rw \u2190 mul_pow,simp only,\n  rw div_eq_mul_inv,\n  have: (x.snd: \u2102) * ((x.fst: \u2102) * ((x.snd: \u2102))\u207b\u00b9 * (z:\u2102) + 1)=\n  ((x.snd: \u2102 ) * ((x.snd : \u2102))\u207b\u00b9 * (x.fst : \u2102 )* (z: \u2102) + (x.snd: \u2102)), 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 (\u2191(x.2) ^ k)= (complex.abs (\u2191(x.2)))^k ,\n  by {apply complex.abs_pow,},\n  rw h3,\n  rw C2,\n  have h4: complex.abs (\u2191n ^ k)=\u2191n ^ 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): \u2102) * (z: \u2102) + (x.snd: \u2102) \u2260 0,\n  by {intro H,\n  have H1 : x.1 = 0 \u2228 (z: \u2102).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 \u2190 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 : \u2115) (z : \u210d) (n : \u2115) (hn: 1 \u2264 n): \u2200 (x: \u2124 \u00d7 \u2124),\nx \u2208 (Square n) \u2192  (complex.abs(((x.1: \u2102)*z+(x.2: \u2102))^k))\u207b\u00b9 \u2264 (complex.abs ((rfunct z)^k* n^k))\u207b\u00b9 :=\nbegin\nintros x hx,\napply Eise_on_square_is_bounded k z n x hx hn,\nend\n\nlemma Eise_on_zero_Square (k : \u2115) (z : \u210d) (h: 1 \u2264 k) : \u2200 (x : \u2124 \u00d7 \u2124),\nx \u2208 (Square 0) \u2192  (complex.abs(((x.1: \u2102)*z+(x.2: \u2102))^k))\u207b\u00b9 \u2264 (complex.abs ((rfunct z)^k* 0^k))\u207b\u00b9 :=\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: \u2102)^k=0, by {rw zero_pow_eq_zero, linarith,},\n  rw h1,\n  simp,\nend\n\nlemma Eise_on_square_is_bounded'' ( k : \u2115) (z : \u210d) (n : \u2115) (hn: 1 \u2264 k): \u2200 (x: \u2124 \u00d7 \u2124),\nx \u2208 (Square n) \u2192  (complex.abs(((x.1: \u2102)*z+(x.2: \u2102))^k))\u207b\u00b9 \u2264 (complex.abs ((rfunct z)^k* n^k))\u207b\u00b9 :=\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 \u2264 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 : \u211d) (n : \u2124)  (h2: x \u2260 0): (x^(n-1))\u207b\u00b9=(x^n)\u207b\u00b9*x:=\nbegin\nhave:=zpow_sub_one\u2080 h2 n,\nrw this,\nhave h3:=mul_zpow (x^n) (x\u207b\u00b9) (-1),\nsimp at *,\nexact h3,\nend\n\n/-Sum over squares is bounded -/\nlemma BigClaim (k : \u2115) (z : \u210d) (h : 3 \u2264 k):\n  \u2200 (n: \u2115), \u2211 (y: \u2124 \u00d7 \u2124) in (Square n),\n  ((real_Eise k z) y)  \u2264 (8/((rfunct z)^k))*(n^((k: \u2124)-1))\u207b\u00b9:=\nbegin\n  intro n,\n  rw real_Eise,\n  simp  [one_div, complex.abs_pow, abs_inv, zpow_coe_nat],\n  have k0: 1 \u2264 k, by {linarith,},\n  have BO :=  Eise_on_square_is_bounded'' ( k : \u2115) (z : \u210d) (n : \u2115) 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: \u2102)^k=0, by {rw zero_pow_eq_zero, linarith,},\n  simp  [abs_zero, inv_zero],\n  have H00: (0: \u211d)^((k: \u2124)-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): \u211d))\u207b\u00b9 : \u211d)=\n  (8/((rfunct z)^k))*(n^((k: \u2124)-1))\u207b\u00b9,\n  by {rw complex.abs_pow,\n  rw complex.abs_of_nonneg,\n  rw \u2190 mul_pow,\n  rw div_eq_inv_mul,\n  have : 8* \u2191n * ((rfunct z * \u2191n) ^ k)\u207b\u00b9= 8*((rfunct z)^k)\u207b\u00b9 * (\u2191n^((k: \u2124)-1))\u207b\u00b9,\n  by {have dis: ((rfunct z * \u2191n) ^ k)\u207b\u00b9 = ((rfunct z)^k)\u207b\u00b9* (\u2191n^k)\u207b\u00b9,\n  by {rw mul_pow,\n  simp_rw [\u2190 zpow_neg_one],\n  simp_rw [\u2190 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 : \u2115) (z : \u210d) (h : 3 \u2264 k):\n \u2200 (n : \u2115), (\u03bb (x: \u2115), \u2211 (y : \u2124 \u00d7 \u2124) in (Square x), (real_Eise k z) y) n \u2264\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 :((\u2191n ^ ((k: \u2124) - 1))\u207b\u00b9: \u211d)=((\u2191n ^ ((k: \u211d) - 1))\u207b\u00b9: \u211d), by {simp [inv_inj],\nhave:= realpow n k,\nrw \u2190 this,\nsimp [int.cast_coe_nat, int.cast_one, int.cast_sub],},\nrw \u2190 tr,\napply BIGCLAIM n,\nend\n\n\nlemma real_eise_is_summable (k : \u2115) (z : \u210d) (h : 3 \u2264 k): summable (real_Eise k z):=\nbegin\n  let In:=Square,\n  have HI:=Squares_cover_all,\n  let g:= \u03bb (y : \u2124 \u00d7 \u2124), (real_Eise k z) y,\n  have gpos: \u2200 (y : \u2124 \u00d7 \u2124), 0 \u2264 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:=\u03bb (x: \u2115), \u2211 (y : \u2124 \u00d7 \u2124) in (In x), g y,\n  have BIGCLAIM: \u2200 (n : \u2115), \u2211 (y : \u2124 \u00d7 \u2124) in (In n), g y \u2264(8/((rfunct z)^k))*(n^((k: \u2124)-1))\u207b\u00b9,\n  by {simp_rw g,\n  apply BigClaim k z h,},\n  have smallerclaim:  \u2200 (n : \u2115), e n \u2264  (8/(rfunct z)^k) * ((rie (k-1)) n),\n  by {simp_rw e,\n  apply SmallClaim k z h,},\n  have epos: \u2200 (x : \u2115), 0 \u2264 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): \u2124), by { linarith, },\n  have nze: ((8/((rfunct z)^k)): \u211d)  \u2260 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 (\u03bb (n : \u2115), (8 / (rfunct z)^k) * rie (\u2191k - 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 : \u2115) (z : \u210d) (h : 3 \u2264 k):\n    (real_Eisenstein_series_of_weight_ k z) \u2264 (8/(rfunct z)^k)*Riemann_zeta (k-1):=\nbegin\n  rw [real_Eisenstein_series_of_weight_, Riemann_zeta, \u2190 tsum_mul_left],\n  let In:=Square,\n  have HI:=Squares_cover_all,\n  let g:= \u03bb (y : \u2124 \u00d7 \u2124), (real_Eise k z) y,\n  have gpos: \u2200 (y : \u2124 \u00d7 \u2124), 0 \u2264 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): \u2124), by { linarith, },\n  have nze: ((8/((rfunct z)^k)): \u211d)  \u2260 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 (\u03bb (n : \u2115), (8 / (rfunct z)^k) * rie (\u2191k - 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 \u2190 ind_lem2,\n  simp_rw g at hgsumm,\n  apply hgsumm,\n  apply riesum',\nend\n\nlemma Eisenstein_series_is_summable (k : \u2115) (z : \u210d) (h : 3 \u2264 k) : summable (Eise k z) :=\nbegin\nlet f:=(Eise k z),\nhave sum_Eq:  summable (\u03bb x, abs (f x)) \u2192 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 : \u2124) (n: \u2115): \u210d \u2192 \u2102:=\n\u03bb z, \u2211 x in Square n, Eise k z x\n\n\nlemma Eisenstein_series_is_sum_eisen_squares (k: \u2115) (z: \u210d) (h : 3 \u2264 k) :\n(Eisenstein_series_of_weight_ k z) = \u2211' (n : \u2115), eisen_square k n z:=\nbegin\nrw Eisenstein_series_of_weight_, simp_rw eisen_square,\n\nhave HI:=Squares_cover_all,\nlet g:= \u03bb (y : \u2124 \u00d7 \u2124),  (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: \u2124) (n : \u2115): \u210d \u2192 \u2102:=\n\u03bb z, \u2211 x in (finset.range n), (eisen_square k x z)\n\ndef upper_half_space_slice (A B : \u211d) :=\n  {z : \u210d' | complex.abs(z.1.1) \u2264 A \u2227 complex.abs(z.1.2) \u2265 B  }\n\ninstance upper_half_space_slice_to_uhs (A B : \u211d) :\n  has_coe (upper_half_space_slice A B) \u210d := \u27e8\u03bb z, z.1\u27e9\n\n@[simp]lemma slice_mem (A B : \u211d) (z: \u210d): z \u2208 (upper_half_space_slice A B) \u2194\n(complex.abs(z.1.1) \u2264 A \u2227 complex.abs(z.1.2) \u2265 B) :=iff.rfl\n\nlemma slice_in_upper_half (A B : \u211d) (x : (upper_half_space_slice A B) ) :\n  x.1.1 \u2208 \u210d'.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 : \u210d') (A B \u03b5 : \u211d)(hB : 0 < B) ( h\u03b5 : 0 < \u03b5) (hB\u03b5 : \u03b5 < B)\n  (h : metric.closed_ball z \u03b5 \u2286 upper_half_space_slice A B) :\n    metric.closed_ball z.1 \u03b5 \u2286 \u210d'.1 :=\nbegin\nintros x hx,\nsimp at *,\nhave hg : 0 < (x.2), by {\n  rw metric.closed_ball at h,\n    have hz : z \u2208 upper_half_space_slice A B, by {apply h, simp [h\u03b5.le]},\n    simp at hz,\n    have hz2:= z.2,\n    have hzB: B \u2264 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: -\u03b5 \u2264 - |z.1.im - x.im|, by {simp, apply h3, },\n    simp at h4,\n    have h5 : |z.1.im| - |z.1.im - x.im| \u2264 |x.im|, by {simp,linarith,},\n    simp at hzB,\n    have h6 : B - \u03b5 \u2264 |z.1.im| - |z.1.im - x.im|, by {simp at *, linarith, },\n    by_contradiction hc,\n    simp at hc,\n    have hcc: 0 \u2264 -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 : \u210d') : \u2203 (A B \u03b5 : \u211d), 0 < \u03b5 \u2227 0 < B \u2227\n  metric.closed_ball z \u03b5 \u2286 upper_half_space_slice A B \u2227  0 \u2264 A \u2227 \u03b5 < B:=\nbegin\n  let e := 3\u207b\u00b9 * 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 : \u2102) (z :\u2102), 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 : \u2102) (z : \u2102) 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 \u2264 |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 \u2190 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 : \u211d) (h: 0 < B): \u210d := \u27e8\u27e8A,B\u27e9, by { simp, exact h,},\u27e9\n\nlemma aux55 (a b : \u211d ) (h : a \u2260 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 : \u211d) (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 \u2260 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 : \u211d): 0 < a^2/b^2+1:=\nbegin\n  have h1: 0 \u2264a^2/b^2, by  {apply div_nonneg, nlinarith, nlinarith, },\n  linarith,\nend\n\nlemma aux6 (a b : \u211d) (h: 0 \u2264  a) (h2: 0 \u2264 b) : a \u2264 b \u2192 a^2 \u2264 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 : \u211d) (h: 0 < B) (z : upper_half_space_slice A B) :\nrfunct (lbpoint A B h) \u2264  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 \u2264 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)\u207b\u00b9 : \u211d)\u2264 ((B^2)\u207b\u00b9 : \u211d) ,\n    by {rw inv_le_inv,\n    have h' : 0 \u2264 B , by {linarith,},\n    have z_prop' : 0 \u2264 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 : \u211d )\u2264 (A^2 : \u211d),\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 \u2190 this,\n    have v2: 0 \u2264 complex.abs (z_val_val.re), by {apply complex.abs.nonneg,},\n    norm_cast at v2,\n    have v1: 0 \u2264 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 \u2264 (z_val_val.re)^2, by {nlinarith,},\n  have i5: 0 \u2264 (B ^ 2)\u207b\u00b9 , 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 : \u2124), 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 : \u2124), 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 : \u2115) (h : 3 \u2264 k) (A B : \u211d) (hb : 0 < B) (z : upper_half_space_slice A B) :\n(8/(rfunct z)^k)*Riemann_zeta (k-1)  \u2264 (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 \u2264 rfunct z, by {have:= rfunct_pos z, linarith, },\n  have v2: 0 \u2264 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 \u2190 inv_le_inv at h2,\n  have h3: 0 \u2264  Riemann_zeta (k-1), by {have hk: 1 < (k-1 : \u2124), by { linarith,},\n  have hkk: 1 < ((k-1 : \u2124) : \u211d), 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 : \u2115) (A B : \u211d) (hb : 0 < B) (z : upper_half_space_slice A B)\n(n : \u2115) : (8/(rfunct z)^k)* (rie (k-1) n)  \u2264 (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 \u2264 rfunct z, by {have:= rfunct_pos z, linarith, },\n  have v2: 0 \u2264 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 \u2190 inv_le_inv at h2,\n  have h3: 0 \u2264  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 : \u2115) (h : 3 \u2264 k) (A B : \u211d) (hb : 0 < B)\n  (z : upper_half_space_slice A B) :\n    (real_Eisenstein_series_of_weight_ k z.1) \u2264 (8/(rfunct (lbpoint A B hb) )^k)*Riemann_zeta (k-1):=\nbegin\nhave : (8/(rfunct z)^k)*Riemann_zeta (k-1)  \u2264 (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 : \u2124) (A B : \u211d)  (n : \u2115) :\n  (upper_half_space_slice A B) \u2192 \u2102 := \u03bb x, (eisen_square k n x)\n\ndef Eisen_par_sum_slice (k : \u2124) (A B : \u211d) (n : \u2115) :\n  (upper_half_space_slice A B) \u2192 \u2102 :=\n  \u03bb z, \u2211 x in (finset.range n), (Eisen_square_slice k A B  x z)\n\ninstance : has_coe \u210d \u210d' :=\n\u27e8 \u03bb z, \u27e8 z.1, by {simp, cases z, assumption,}, \u27e9 \u27e9\n\ninstance slice_coe (A B : \u211d) (hb : 0 < B) : has_coe (upper_half_space_slice A B) \u210d' :=\n\u27e8\u03bb (x : (upper_half_space_slice A B)), (x : \u210d')  \u27e9\n\ndef Eisenstein_series_restrict (k : \u2124) (A B : \u211d) : (upper_half_space_slice A B) \u2192 \u2102 :=\n\u03bb x, Eisenstein_series_of_weight_ k x\n\ninstance  nonemp (A B : \u211d) (ha : 0 \u2264  A) (hb : 0 < B) : nonempty (upper_half_space_slice A B):=\nbegin\n  let z:= (\u27e8  A, B\u27e9 : \u2102),\n  rw \u2190 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: \u2115) (h : 3 \u2264 k) (A B : \u211d) (hb : 0 < B)\n (z: (upper_half_space_slice A B)) :\n  (Eisenstein_series_restrict k A B z) = \u2211' (n : \u2115), (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:= \u03bb (y : \u2124 \u00d7 \u2124),  (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: \u2115) (h : 3 \u2264 k) (A B : \u211d) (ha : 0 \u2264 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 : \u2115 \u2192 \u211d := \u03bb 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  \u2190 (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 (\u2211 (x : \u2124 \u00d7 \u2124) in Square n, ((\u2191(x.fst) * \u2191\u2191a + \u2191(x.snd)) ^ k)\u207b\u00b9) \u2264\n  \u2211 (x : \u2124 \u00d7 \u2124) in Square n, (complex.abs ((\u2191(x.fst) * \u2191\u2191a + \u2191(x.snd)) ^ k))\u207b\u00b9,\n  by {simp,\n  have := complex_abs_sum_le  (Square n)\n  (\u03bb  (x : \u2124 \u00d7 \u2124),  (((x.1 : \u2102) * (a : \u2102) + (x.2 : \u2102)) ^ k)\u207b\u00b9),\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): \u2124), by { linarith, },\n  have nze: ((8/((rfunct (lbpoint A B hb))^k)): \u211d)  \u2260 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 : \u2124) : \u2102 \u2192 \u2102 :=\n\u03bb x, x^k\n\ndef trans (a b : \u2124) : \u2102 \u2192 \u2102 :=\n\u03bb x, a*x+b\n\ndef ein (a b k : \u2124): \u2102 \u2192 \u2102 :=\n\u03bb x, (a*x+b)^k\n\nlemma com (a b k : \u2124): (ein a b k) = (powfun k) \u2218 trans a b :=\nbegin\nrefl,\nend\n\nlemma d1 (k: \u2124) (x : \u2102): deriv (\u03bb x, x^k) x = k*x^(k-1) :=\nby {simp only [deriv_zpow'], }\n\nlemma d2 (a b k: \u2124) (x : \u2102) (h : (a: \u2102)*x+b \u2260 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: \u2124 ) (x : \u2102): (((a : \u2102)*x+b)^k)\u207b\u00b9 =  ((a : \u2102)*x+b)^-k:=\nbegin\nrefine (zpow_neg _ k).symm,\nend\n\nlemma dd2 (a b k: \u2124) (x : \u2102) (h : (a: \u2102)*x+b \u2260 0) :\n  has_deriv_at (ein a b k) (k*(a*x+b)^(k-1)*(a) : \u2102) 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: \u2102) (has_deriv_at_id x) ,\n  simp at *,\n  exact this,\nend\n\nlemma H_member (z : \u2102) : z \u2208 upper_half_plane.upper_half_space \u2194 0 < z.im:=iff.rfl\n\nlemma Eise'_has_deriv_within_at (k : \u2124) (y: \u2124 \u00d7 \u2124) (hkn: k \u2260 0) :\n  is_holomorphic_on (\u03bb (z : \u210d'), Eise k z y):=\nbegin\n  rw is_holomorphic_on,\n  intro z,\n  by_cases hy: (y.1 : \u2102)*z.1 + y.2 \u2260 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 : \u2102)*z.1 + y.2 \u2260 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 (\u03bb (x : \u2102), (\u2191(y.fst) * x + \u2191(y.snd)) ^ -k)\n  (\u2191-k * (\u2191(y.fst) * \u2191z + \u2191(y.snd)) ^ (-k - 1) * \u2191(y.fst)) upper_half_plane.upper_half_space \u2191z, by {apply H'},\n  simp at H,\n  let fx:=(-k*((y.1:\u2102)*z.1+y.2)^(-k-1)*(y.1) : \u2102),\n  refine \u27e8 fx, _\u27e9,\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 \u03b5 h\u03b5,\n  have HH:= H \u03b5 h\u03b5,\n  obtain \u27e8d1, hd1, hh\u27e9 := HH,\n  refine \u27e8d1 ,hd1, _\u27e9,\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 \u2190 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 \u2227 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 \u210d' ,\n  rw is_holomorphic_on at zhol,\n  have zhol':= zhol z,\n  simp only at zhol',\n  have zk: ((0: \u2102)^k)\u207b\u00b9 =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 : \u2124) (y: \u2124 \u00d7 \u2124) (hkn: k \u2260 0) :\n  differentiable_on \u2102 (extend_by_zero (\u03bb (z : \u210d'), Eise k z y)) \u210d':=\nbegin\n  have:= is_holomorphic_on_iff_differentiable_on \u210d' (\u03bb (z : \u210d'), 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 : \u211d} {z w : \u2102} (hw : w \u2208 metric.ball z R) (k : \u2124) (y: \u2124 \u00d7 \u2124) (hkn: k \u2260 0)\n  (h : metric.closed_ball z R \u2286 \u210d' ):\n  differentiable_on \u2102 (extend_by_zero (\u03bb (z : \u210d'), 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 : \u2115) (x : \u211a) :\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 : \u2200 m : \u2115, m < n \u2192 (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) * \u2211 (l : \u2115) in finset.range (n + 1), (n + 1) * (finset.range (n + 1)).sum (\u03bb (k : \u2115) (hk : k \u2208 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) * \u2211 (l : \u2115) in finset.range (n + 1), (n + 1) * (finset.range (n + 1)).sum (\u03bb (k : \u2115) (hk : k \u2208 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 : \u2115) (x : \u211a) :\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 \u2260 0,\n    have h1 : \u2200 (m : \u2115) (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 : \u2200 (m : \u2115) (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 : \u2200 (m : \u2115) (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 : \u2115) (x : \u211a) :\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 : \u2200 m : \u2115, m < n \u2192 (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 : \u2115) (x : \u211a) :\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 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h2 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h3 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h4 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h5 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h6 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h7 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h8 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h9 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h10 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h11 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h12 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h13 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h14 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h15 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h16 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h17 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h18 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h19 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h20 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h21 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h22 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h23 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h24 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h25 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h26 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h27 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h28 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h29 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h30 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h31 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h32 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h33 : \u2200 m < d, (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1), from by auto [hd],\n  have h34 : \u2200 m < d, (polynomial.bernoulli\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : \u2200 (m : \u2115) (x : \u211a), polynomial.bernoulli m = (m + 1) * polynomial.X^m - \u2211 l in finset.range (m + 1), (m + 1) * (finset.range (m + 1)).sum (\u03bb (k : \u2115), (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 : \u2200 (m : \u2115) (x : \u211a), (m + 1) * polynomial.X^m - \u2211 l in finset.range (m + 1), (m + 1) * (finset.range (m + 1)).sum (\u03bb (k : \u2115), (m + 1) * (polynomial.X^k) * polynomial.bernoulli k / (k + 1)) = m * polynomial.X^m - \u2211 l in finset.range m, m * (finset.range m).sum (\u03bb (k : \u2115), 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 : \u2200 (m : \u2115) (x : \u211a), (m + 1) * polynomial.X^m - \u2211 l in finset.range m, m * (finset.range m).sum (\u03bb (k : \u2115), m * (polynomial.X^k) * polynomial.bernoulli k / (k + 1)) = m * polynomial.X^m - \u2211 l in finset.range m, m * (finset.range m).sum (\u03bb (k : \u2115), 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 : \u2200 (m : \u2115) (x : \u211a), m * polynomial.X^m - \u2211 l in finset.range m, m * (finset.range m).sum (\u03bb (k : \u2115), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), polynomial.bernoulli m = polynomial.X^m + m * polynomial.X^(m - 1) * polynomial.bernoulli m / (m + 1), from\n    by auto [h5],\n  have h7 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m : \u2115) (x : \u211a), 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 : \u2200 (m :\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : (\u2200 m : \u2115, m < n \u2192 (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 : \u2115) (x : \u211a) :\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 : \u2200 m : \u2115, m < d \u2192 (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 : \u2115) (x : \u211a) :\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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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 : \u2115) (x : \u211a) :\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' := \u03bb _ _, hs.mul_mem,\n  zero_mem' := hs.zero_mem,\n  add_mem' := \u03bb _ _, hs.add_mem,\n  neg_mem' := \u03bb _, 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 \u2192+* S) {s : set S} (hs : is_subring s) : is_subring (f \u207b\u00b9' 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 \u2192+* 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 \u2192+* 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\u2081 S\u2082 : set R} (hS\u2081 : is_subring S\u2081) (hS\u2082 : is_subring S\u2082) :\n  is_subring (S\u2081 \u2229 S\u2082) :=\n{ ..is_add_subgroup.inter hS\u2081.to_is_add_subgroup hS\u2082.to_is_add_subgroup,\n  ..is_submonoid.inter hS\u2081.to_is_submonoid hS\u2082.to_is_submonoid }\n\nlemma is_subring.Inter {\u03b9 : Sort*} {S : \u03b9 \u2192 set R} (h : \u2200 y : \u03b9, is_subring (S y)) :\n  is_subring (set.Inter S) :=\n{ ..is_add_subgroup.Inter (\u03bb i, (h i).to_is_add_subgroup),\n  ..is_submonoid.Inter (\u03bb i, (h i).to_is_submonoid) }\n\nlemma is_subring_Union_of_directed {\u03b9 : Type*} [h\u03b9 : nonempty \u03b9]\n  {s : \u03b9 \u2192 set R} (h : \u2200 i, is_subring (s i))\n  (directed : \u2200 i j, \u2203 k, s i \u2286 s k \u2227 s j \u2286 s k) :\n  is_subring (\u22c3i, s i) :=\n{ to_is_add_subgroup := is_add_subgroup_Union_of_directed\n    (\u03bb i, (h i).to_is_add_subgroup) directed,\n  to_is_submonoid := is_submonoid_Union_of_directed (\u03bb 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 \u2208 closure s) :\n  (\u2203 L : list (list R), (\u2200 l \u2208 L, \u2200 x \u2208 l, x \u2208 s \u2228 x = (-1:R)) \u2227 (L.map list.prod).sum = a) :=\nadd_group.in_closure.rec_on h\n  (\u03bb x hx, match x, monoid.exists_list_of_mem_closure hx with\n    | _, \u27e8L, h1, rfl\u27e9 := \u27e8[L], list.forall_mem_singleton.2 (\u03bb r hr, or.inl (h1 r hr)), zero_add _\u27e9\n    end)\n  \u27e8[], list.forall_mem_nil _, rfl\u27e9\n  (\u03bb b _ ih, match b, ih with\n    | _, \u27e8L1, h1, rfl\u27e9 := \u27e8L1.map (list.cons (-1)),\n      \u03bb L2 h2, match L2, list.mem_map.1 h2 with\n        | _, \u27e8L3, h3, rfl\u27e9 := list.forall_mem_cons.2 \u27e8or.inr rfl, h1 L3 h3\u27e9\n        end,\n      by simp only [list.map_map, (\u2218), list.prod_cons, neg_one_mul];\n      exact list.rec_on L1 neg_zero.symm (\u03bb hd tl ih,\n        by rw [list.map_cons, list.sum_cons, ih, list.map_cons, list.sum_cons, neg_add])\u27e9\n    end)\n  (\u03bb r1 r2 hr1 hr2 ih1 ih2, match r1, r2, ih1, ih2 with\n    | _, _, \u27e8L1, h1, rfl\u27e9, \u27e8L2, h2, rfl\u27e9 := \u27e8L1 ++ L2, list.forall_mem_append.2 \u27e8h1, h2\u27e9,\n      by rw [list.map_append, list.sum_append]\u27e9\n    end)\n\n@[elab_as_eliminator]\nprotected theorem in_closure.rec_on {C : R \u2192 Prop} {x : R} (hx : x \u2208 closure s)\n  (h1 : C 1) (hneg1 : C (-1)) (hs : \u2200 z \u2208 s, \u2200 n, C n \u2192 C (z * n))\n  (ha : \u2200 {x y}, C x \u2192 C y \u2192 C (x + y)) : C x :=\nbegin\n  have h0 : C 0 := add_neg_self (1:R) \u25b8 ha h1 hneg1,\n  rcases exists_list_of_mem_closure hx with \u27e8L, HL, rfl\u27e9, 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 \u27e8L, HL', HP | HP\u27e9 : \u2203 L : list R,\n    (\u2200 x \u2208 L, x \u2208 s) \u2227 (list.prod hd = list.prod L \u2228 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 \u27e8[], list.forall_mem_nil _, or.inl rfl\u27e9 },\n  rw list.forall_mem_cons at HL,\n  rcases ih HL.2 with \u27e8L, HL', HP | HP\u27e9; cases HL.1 with hhd hhd,\n  { exact \u27e8hd :: L, list.forall_mem_cons.2 \u27e8hhd, HL'\u27e9, or.inl $\n      by rw [list.prod_cons, list.prod_cons, HP]\u27e9 },\n  { exact \u27e8L, HL', or.inr $ by rw [list.prod_cons, hhd, neg_one_mul, HP]\u27e9 },\n  { exact \u27e8hd :: L, list.forall_mem_cons.2 \u27e8hhd, HL'\u27e9, or.inr $\n      by rw [list.prod_cons, list.prod_cons, HP, neg_mul_eq_mul_neg]\u27e9 },\n  { exact \u27e8L, HL', or.inl $ by rw [list.prod_cons, hhd, HP, neg_one_mul, neg_neg]\u27e9 }\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 := \u03bb a b ha hb, add_group.in_closure.rec_on hb\n    ( \u03bb c hc, add_group.in_closure.rec_on ha\n      ( \u03bb d hd, add_group.subset_closure ((monoid.closure.is_submonoid _).mul_mem hd hc))\n      ( (zero_mul c).symm \u25b8 (add_group.closure.is_add_subgroup _).zero_mem)\n      ( \u03bb d hd hdc, neg_mul_eq_neg_mul d c \u25b8 (add_group.closure.is_add_subgroup _).neg_mem hdc)\n      ( \u03bb d e hd he hdc hec, (add_mul d e c).symm \u25b8\n        ((add_group.closure.is_add_subgroup _).add_mem hdc hec)))\n    ( (mul_zero a).symm \u25b8 (add_group.closure.is_add_subgroup _).zero_mem)\n    ( \u03bb c hc hac, neg_mul_eq_mul_neg a c \u25b8 (add_group.closure.is_add_subgroup _).neg_mem hac)\n    ( \u03bb c d hc hd hac had, (mul_add a c d).symm \u25b8\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 \u2208 s \u2192 a \u2208 closure s :=\nadd_group.mem_closure \u2218 @monoid.subset_closure _ _ _ _\n\ntheorem subset_closure : s \u2286 closure s :=\n\u03bb _, mem_closure\n\ntheorem closure_subset {t : set R} (ht : is_subring t) : s \u2286 t \u2192 closure s \u2286 t :=\n(add_group.closure_subset ht.to_is_add_subgroup) \u2218 (monoid.closure_subset ht.to_is_submonoid)\n\ntheorem closure_subset_iff {s t : set R} (ht : is_subring t) : closure s \u2286 t \u2194 s \u2286 t :=\n(add_group.closure_subset_iff ht.to_is_add_subgroup).trans\n  \u27e8set.subset.trans monoid.subset_closure, monoid.closure_subset ht.to_is_submonoid\u27e9\n\ntheorem closure_mono {s t : set R} (H : s \u2286 t) : closure s \u2286 closure t :=\nclosure_subset closure.is_subring $ set.subset.trans H subset_closure\n\nlemma image_closure {S : Type*} [ring S] (f : R \u2192+* S) (s : set R) :\n  f '' closure s = closure (f '' s) :=\nle_antisymm\n  begin\n    rintros _ \u27e8x, hx, rfl\u27e9,\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 : \u03b1) (l : List \u03b1) : a :: l \u2260 [] := fun.\n\ntheorem cons_ne_self (a : \u03b1) (l : List \u03b1) : a :: l \u2260 l := mt (congrArg length) (Nat.succ_ne_self _)\n\ntheorem head_eq_of_cons_eq (H : h\u2081 :: t\u2081 = h\u2082 :: t\u2082) : h\u2081 = h\u2082 := (cons.inj H).1\n\ntheorem tail_eq_of_cons_eq (H : h\u2081 :: t\u2081 = h\u2082 :: t\u2082) : t\u2081 = t\u2082 := (cons.inj H).2\n\ntheorem cons_inj (a : \u03b1) {l l' : List \u03b1} : a :: l = a :: l' \u2194 l = l' :=\n  \u27e8tail_eq_of_cons_eq, congrArg _\u27e9\n\ntheorem exists_cons_of_ne_nil : \u2200 {l : List \u03b1}, l \u2260 [] \u2192 \u2203 b L, l = b :: L\n  | c :: l', _ => \u27e8c, l', rfl\u27e9\n\n/-! ### length -/\n\n@[simp 1100] theorem length_singleton (a : \u03b1) : length [a] = 1 := rfl\n\ntheorem length_pos_of_mem {a : \u03b1} : \u2200 {l : List \u03b1}, a \u2208 l \u2192 0 < length l\n  | _::_, _ => Nat.zero_lt_succ _\n\ntheorem exists_mem_of_length_pos : \u2200 {l : List \u03b1}, 0 < length l \u2192 \u2203 a, a \u2208 l\n  | _::_, _ => \u27e8_, .head ..\u27e9\n\ntheorem length_pos_iff_exists_mem {l : List \u03b1} : 0 < length l \u2194 \u2203 a, a \u2208 l :=\n  \u27e8exists_mem_of_length_pos, fun \u27e8_, h\u27e9 => length_pos_of_mem h\u27e9\n\ntheorem length_pos {l : List \u03b1} : 0 < length l \u2194 l \u2260 [] :=\n  Nat.pos_iff_ne_zero.trans (not_congr length_eq_zero)\n\ntheorem exists_mem_of_ne_nil (l : List \u03b1) (h : l \u2260 []) : \u2203 x, x \u2208 l :=\n  exists_mem_of_length_pos (length_pos.2 h)\n\ntheorem length_eq_one {l : List \u03b1} : length l = 1 \u2194 \u2203 a, l = [a] :=\n  \u27e8fun h => match l, h with | [_], _ => \u27e8_, rfl\u27e9, fun \u27e8_, h\u27e9 => by simp [h]\u27e9\n\n/-! ### mem -/\n\n@[simp] theorem not_mem_nil (a : \u03b1) : \u00ac a \u2208 [] := fun.\n\ntheorem mem_nil_iff (a : \u03b1) : a \u2208 ([] : List \u03b1) \u2194 False := by simp\n\n@[simp] theorem mem_cons : a \u2208 (b :: l) \u2194 a = b \u2228 a \u2208 l :=\n  \u27e8fun h => by cases h <;> simp [Membership.mem, *],\n   fun | Or.inl rfl => by constructor | Or.inr h => by constructor; assumption\u27e9\n\ntheorem mem_cons_self (a : \u03b1) (l : List \u03b1) : a \u2208 a :: l := .head ..\n\ntheorem mem_cons_of_mem (y : \u03b1) {a : \u03b1} {l : List \u03b1} : a \u2208 l \u2192 a \u2208 y :: l := .tail _\n\ntheorem mem_singleton_self (a : \u03b1) : a \u2208 [a] := mem_cons_self _ _\n\ntheorem eq_of_mem_singleton : a \u2208 [b] \u2192 a = b\n  | .head .. => rfl\n\n@[simp 1100] theorem mem_singleton {a b : \u03b1} : a \u2208 [b] \u2194 a = b :=\n  \u27e8eq_of_mem_singleton, (by simp [\u00b7])\u27e9\n\ntheorem mem_of_mem_cons_of_mem : \u2200 {a b : \u03b1} {l : List \u03b1}, a \u2208 b :: l \u2192 b \u2208 l \u2192 a \u2208 l\n  | _, _, _, .head .., h | _, _, _, .tail _ h, _ => h\n\ntheorem eq_or_ne_mem_of_mem {a b : \u03b1} {l : List \u03b1} (h' : a \u2208 b :: l) : a = b \u2228 (a \u2260 b \u2227 a \u2208 l) :=\n  (Classical.em _).imp_right fun h => \u27e8h, (mem_cons.1 h').resolve_left h\u27e9\n\ntheorem ne_nil_of_mem {a : \u03b1} {l : List \u03b1} (h : a \u2208 l) : l \u2260 [] := by cases h <;> intro.\n\ntheorem append_of_mem {a : \u03b1} {l : List \u03b1} : a \u2208 l \u2192 \u2203 s t : List \u03b1, l = s ++ a :: t\n  | .head l => \u27e8[], l, rfl\u27e9\n  | .tail b h => let \u27e8s, t, h'\u27e9 := append_of_mem h; \u27e8b::s, t, by rw [h', cons_append]\u27e9\n\n@[simp] theorem elem_iff [DecidableEq \u03b1] {a : \u03b1} {as : List \u03b1} :\n    elem a as \u2194 a \u2208 as := \u27e8mem_of_elem_eq_true, elem_eq_true_of_mem\u27e9\n\ntheorem mem_of_ne_of_mem {a y : \u03b1} {l : List \u03b1} (h\u2081 : a \u2260 y) (h\u2082 : a \u2208 y :: l) : a \u2208 l :=\n  Or.elim (mem_cons.mp h\u2082) (absurd \u00b7 h\u2081) (\u00b7)\n\ntheorem ne_of_not_mem_cons {a b : \u03b1} {l : List \u03b1} : a \u2209 b::l \u2192 a \u2260 b := mt (\u00b7 \u25b8 .head _)\n\ntheorem not_mem_of_not_mem_cons {a b : \u03b1} {l : List \u03b1} : a \u2209 b::l \u2192 a \u2209 l := mt (.tail _)\n\ntheorem not_mem_cons_of_ne_of_not_mem {a y : \u03b1} {l : List \u03b1} : a \u2260 y \u2192 a \u2209 l \u2192 a \u2209 y::l :=\n  mt \u2218 mem_of_ne_of_mem\n\ntheorem ne_and_not_mem_of_not_mem_cons {a y : \u03b1} {l : List \u03b1} : a \u2209 y::l \u2192 a \u2260 y \u2227 a \u2209 l :=\n  fun p => \u27e8ne_of_not_mem_cons p, not_mem_of_not_mem_cons p\u27e9\n\n/-! ### append -/\n\ntheorem append_eq_append : List.append l\u2081 l\u2082 = l\u2081 ++ l\u2082 := rfl\n\n@[simp] theorem append_eq_nil : p ++ q = [] \u2194 p = [] \u2227 q = [] := by\n  cases p <;> simp\n\ntheorem append_ne_nil_of_ne_nil_left (s t : List \u03b1) : s \u2260 [] \u2192 s ++ t \u2260 [] := by simp_all\n\ntheorem append_ne_nil_of_ne_nil_right (s t : List \u03b1) : t \u2260 [] \u2192 s ++ t \u2260 [] := by simp_all\n\n@[simp] theorem nil_eq_append : [] = a ++ b \u2194 a = [] \u2227 b = [] := by\n  rw [eq_comm, append_eq_nil]\n\ntheorem append_ne_nil_of_left_ne_nil (a b : List \u03b1) (h0 : a \u2260 []) : a ++ b \u2260 [] := by simp [*]\n\ntheorem append_eq_cons :\n    a ++ b = x :: c \u2194 (a = [] \u2227 b = x :: c) \u2228 (\u2203 a', a = x :: a' \u2227 c = a' ++ b) := by\n  cases a with simp | cons a as => ?_\n  exact \u27e8fun h => \u27e8as, by simp [h]\u27e9, fun \u27e8a', \u27e8aeq, aseq\u27e9, h\u27e9 => \u27e8aeq, by rw [aseq, h]\u27e9\u27e9\n\ntheorem cons_eq_append :\n    x :: c = a ++ b \u2194 (a = [] \u2227 b = x :: c) \u2228 (\u2203 a', a = x :: a' \u2227 c = a' ++ b) := by\n  rw [eq_comm, append_eq_cons]\n\ntheorem append_eq_append_iff {a b c d : List \u03b1} :\n  a ++ b = c ++ d \u2194 (\u2203 a', c = a ++ a' \u2227 b = a' ++ d) \u2228 \u2203 c', a = c ++ c' \u2227 d = c' ++ b := by\n  induction a generalizing c with\n  | nil => simp; exact (or_iff_left_of_imp fun \u27e8_, \u27e8e, rfl\u27e9, h\u27e9 => e \u25b8 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 : \u03b1} {s t : List \u03b1} : a \u2208 s ++ t \u2194 a \u2208 s \u2228 a \u2208 t := by\n  induction s <;> simp_all [or_assoc]\n\ntheorem not_mem_append {a : \u03b1} {s t : List \u03b1} (h\u2081 : a \u2209 s) (h\u2082 : a \u2209 t) : a \u2209 s ++ t :=\n  mt mem_append.1 $ not_or.mpr \u27e8h\u2081, h\u2082\u27e9\n\ntheorem mem_append_eq (a : \u03b1) (s t : List \u03b1) : (a \u2208 s ++ t) = (a \u2208 s \u2228 a \u2208 t) :=\n  propext mem_append\n\ntheorem mem_append_left {a : \u03b1} {l\u2081 : List \u03b1} (l\u2082 : List \u03b1) (h : a \u2208 l\u2081) : a \u2208 l\u2081 ++ l\u2082 :=\n  mem_append.2 (Or.inl h)\n\ntheorem mem_append_right {a : \u03b1} (l\u2081 : List \u03b1) {l\u2082 : List \u03b1} (h : a \u2208 l\u2082) : a \u2208 l\u2081 ++ l\u2082 :=\n  mem_append.2 (Or.inr h)\n\n/-! ### map -/\n\ntheorem map_singleton (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : map f [a] = [f a] := rfl\n\n@[simp] theorem mem_map {f : \u03b1 \u2192 \u03b2} : \u2200 {l : List \u03b1}, b \u2208 l.map f \u2194 \u2203 a, a \u2208 l \u2227 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 : \u03b1 \u2192 \u03b2) (h : a \u2208 l) : f a \u2208 map f l := mem_map.2 \u27e8_, h, rfl\u27e9\n\ntheorem exists_of_mem_map (h : b \u2208 map f l) : \u2203 a, a \u2208 l \u2227 f a = b := mem_map.1 h\n\ntheorem forall_mem_map_iff {f : \u03b1 \u2192 \u03b2} {l : List \u03b1} {P : \u03b2 \u2192 Prop} :\n    (\u2200 i \u2208 l.map f, P i) \u2194 \u2200 j \u2208 l, P (f j) := by\n  simp; exact \u27e8fun H j h => H _ _ h rfl, fun H i x h e => e \u25b8 H _ h\u27e9\n\n@[simp] theorem map_eq_nil {f : \u03b1 \u2192 \u03b2} {l : List \u03b1} : map f l = [] \u2194 l = [] := by\n  constructor <;> exact fun _ => match l with | [] => rfl\n\n@[simp] theorem length_zipWith (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l\u2081 l\u2082) :\n    length (zipWith f l\u2081 l\u2082) = min (length l\u2081) (length l\u2082) := by\n  induction l\u2081 generalizing l\u2082 <;> cases l\u2082 <;>\n    simp_all [add_one, min_succ_succ, Nat.zero_min, Nat.min_zero]\n\n/-! ### join -/\n\ntheorem join_nil : join ([] : List (List \u03b1)) = [] := rfl\n\ntheorem join_cons : join (a :: l : List (List \u03b1)) = a ++ join l := rfl\n\ntheorem mem_join : \u2200 {L : List (List \u03b1)}, a \u2208 L.join \u2194 \u2203 l, l \u2208 L \u2227 a \u2208 l\n  | [] => by simp\n  | b :: l => by simp [mem_join, or_and_right, exists_or]\n\ntheorem exists_of_mem_join : a \u2208 join L \u2192 \u2203 l, l \u2208 L \u2227 a \u2208 l := mem_join.1\n\ntheorem mem_join_of_mem (lL : l \u2208 L) (al : a \u2208 l) : a \u2208 join L := mem_join.2 \u27e8l, lL, al\u27e9\n\n/-! ### bind -/\n\ntheorem mem_bind {f : \u03b1 \u2192 List \u03b2} {b} {l : List \u03b1} : b \u2208 l.bind f \u2194 \u2203 a, a \u2208 l \u2227 b \u2208 f a := by\n  simp [List.bind, mem_join]\n  exact \u27e8fun \u27e8_, \u27e8a, h\u2081, rfl\u27e9, h\u2082\u27e9 => \u27e8a, h\u2081, h\u2082\u27e9, fun \u27e8a, h\u2081, h\u2082\u27e9 => \u27e8_, \u27e8a, h\u2081, rfl\u27e9, h\u2082\u27e9\u27e9\n\ntheorem exists_of_mem_bind {b : \u03b2} {l : List \u03b1} {f : \u03b1 \u2192 List \u03b2} :\n    b \u2208 List.bind l f \u2192 \u2203 a, a \u2208 l \u2227 b \u2208 f a := mem_bind.1\n\ntheorem mem_bind_of_mem {b : \u03b2} {l : List \u03b1} {f : \u03b1 \u2192 List \u03b2} {a} (al : a \u2208 l) (h : b \u2208 f a) :\n    b \u2208 List.bind l f := mem_bind.2 \u27e8a, al, h\u27e9\n\ntheorem bind_map (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 List \u03b2) :\n    \u2200 l : List \u03b1, 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 : (\u2205 : List \u03b1) = [] := rfl\n\n/-! ### bounded quantifiers over Lists -/\n\ntheorem exists_mem_nil (p : \u03b1 \u2192 Prop) : \u00ac\u2203 x \u2208 @nil \u03b1, p x := fun.\n\ntheorem forall_mem_nil (p : \u03b1 \u2192 Prop) : \u2200 x \u2208 @nil \u03b1, p x := fun.\n\ntheorem exists_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1} :\n    (\u2203 x \u2208 a :: l, p x) \u2194 p a \u2228 \u2203 x \u2208 l, p x := by simp\n\ntheorem forall_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1} :\n    (\u2200 x \u2208 a :: l, p x) \u2194 p a \u2227 \u2200 x \u2208 l, p x := by simp\n\ntheorem forall_mem_singleton {p : \u03b1 \u2192 Prop} {a : \u03b1} : (\u2200 x \u2208 [a], p x) \u2194 p a := by\n  simp only [mem_singleton, forall_eq]\n\ntheorem forall_mem_append {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : List \u03b1} :\n    (\u2200 x \u2208 l\u2081 ++ l\u2082, p x) \u2194 (\u2200 x \u2208 l\u2081, p x) \u2227 (\u2200 x \u2208 l\u2082, p x) := by\n  simp only [mem_append, or_imp, forall_and]\n\n/-! ### List subset -/\n\ntheorem subset_def {l\u2081 l\u2082 : List \u03b1} : l\u2081 \u2286 l\u2082 \u2194 \u2200 {a : \u03b1}, a \u2208 l\u2081 \u2192 a \u2208 l\u2082 := .rfl\n\n@[simp] theorem nil_subset (l : List \u03b1) : [] \u2286 l := fun.\n\n@[simp] theorem Subset.refl (l : List \u03b1) : l \u2286 l := fun _ i => i\n\ntheorem Subset.trans {l\u2081 l\u2082 l\u2083 : List \u03b1} (h\u2081 : l\u2081 \u2286 l\u2082) (h\u2082 : l\u2082 \u2286 l\u2083) : l\u2081 \u2286 l\u2083 :=\n  fun _ i => h\u2082 (h\u2081 i)\n\n@[simp] theorem subset_cons (a : \u03b1) (l : List \u03b1) : l \u2286 a :: l := fun _ => Mem.tail _\n\ntheorem subset_of_cons_subset {a : \u03b1} {l\u2081 l\u2082 : List \u03b1} : a :: l\u2081 \u2286 l\u2082 \u2192 l\u2081 \u2286 l\u2082 :=\n  fun s _ i => s (mem_cons_of_mem _ i)\n\ntheorem subset_cons_of_subset (a : \u03b1) {l\u2081 l\u2082 : List \u03b1} : l\u2081 \u2286 l\u2082 \u2192 l\u2081 \u2286 a :: l\u2082 :=\n  fun s _ i => .tail _ (s i)\n\ntheorem cons_subset_cons {l\u2081 l\u2082 : List \u03b1} (a : \u03b1) (s : l\u2081 \u2286 l\u2082) : a :: l\u2081 \u2286 a :: l\u2082 :=\n  fun _ => by simp only [mem_cons]; exact Or.imp_right (@s _)\n\n@[simp] theorem subset_append_left (l\u2081 l\u2082 : List \u03b1) : l\u2081 \u2286 l\u2081 ++ l\u2082 := fun _ => mem_append_left _\n\n@[simp] theorem subset_append_right (l\u2081 l\u2082 : List \u03b1) : l\u2082 \u2286 l\u2081 ++ l\u2082 := fun _ => mem_append_right _\n\ntheorem subset_append_of_subset_left (l\u2082 : List \u03b1) : l \u2286 l\u2081 \u2192 l \u2286 l\u2081 ++ l\u2082 :=\nfun s => Subset.trans s <| subset_append_left _ _\n\ntheorem subset_append_of_subset_right (l\u2081 : List \u03b1) : l \u2286 l\u2082 \u2192 l \u2286 l\u2081 ++ l\u2082 :=\nfun s => Subset.trans s <| subset_append_right _ _\n\n@[simp] theorem cons_subset : a :: l \u2286 m \u2194 a \u2208 m \u2227 l \u2286 m := by\n  simp only [subset_def, mem_cons, or_imp, forall_and, forall_eq]\n\n@[simp] theorem append_subset {l\u2081 l\u2082 l : List \u03b1} :\n    l\u2081 ++ l\u2082 \u2286 l \u2194 l\u2081 \u2286 l \u2227 l\u2082 \u2286 l := by simp [subset_def, or_imp, forall_and]\n\ntheorem subset_nil {l : List \u03b1} : l \u2286 [] \u2194 l = [] :=\n  \u27e8fun h => match l with | [] => rfl | _::_ => nomatch h (.head ..), fun | rfl => Subset.refl _\u27e9\n\ntheorem eq_nil_iff_forall_not_mem {l : List \u03b1} : l = [] \u2194 \u2200 a, a \u2209 l :=\n  subset_nil.symm.trans <| by simp [subset_def]\n\ntheorem map_subset {l\u2081 l\u2082 : List \u03b1} (f : \u03b1 \u2192 \u03b2) (H : l\u2081 \u2286 l\u2082) : map f l\u2081 \u2286 map f l\u2082 :=\n  fun x => by simp only [mem_map]; exact .imp fun a => .imp_left (@H _)\n\n/-! ### replicate -/\n\ntheorem replicate_succ (a : \u03b1) (n) : replicate (n+1) a = a :: replicate n a := rfl\n\ntheorem mem_replicate {a b : \u03b1} : \u2200 {n}, b \u2208 replicate n a \u2194 n \u2260 0 \u2227 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 : \u03b1} {n} (h : b \u2208 replicate n a) : b = a := (mem_replicate.1 h).2\n\ntheorem eq_replicate_of_mem {a : \u03b1} :\n    \u2200 {l : List \u03b1}, (\u2200 b \u2208 l, b = a) \u2192 l = replicate l.length a\n  | [], _ => rfl\n  | b :: l, H => by\n    let \u27e8rfl, H\u2082\u27e9 := forall_mem_cons.1 H\n    rw [length_cons, replicate, \u2190 eq_replicate_of_mem H\u2082]\n\ntheorem eq_replicate {a : \u03b1} {n} {l : List \u03b1} :\n    l = replicate n a \u2194 length l = n \u2227 \u2200 b \u2208 l, b = a :=\n  \u27e8fun h => h \u25b8 \u27e8length_replicate .., fun _ => eq_of_mem_replicate\u27e9,\n   fun \u27e8e, al\u27e9 => e \u25b8 eq_replicate_of_mem al\u27e9\n\n/-! ### getLast -/\n\ntheorem getLast_cons' {a : \u03b1} {l : List \u03b1} : \u2200 (h\u2081 : a :: l \u2260 nil) (h\u2082 : l \u2260 nil),\n  getLast (a :: l) h\u2081 = getLast l h\u2082 := by\n  induction l <;> intros; {contradiction}; rfl\n\n@[simp] theorem getLast_append {a : \u03b1} : \u2200 (l : List \u03b1) 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 \u2260 []) \u2192 getLast (concat l a) h = a :=\n  concat_eq_append .. \u25b8 getLast_append _\n\n/-! ### sublists -/\n\n@[simp] theorem nil_sublist : \u2200 l : List \u03b1, [] <+ l\n  | [] => .slnil\n  | a :: l => (nil_sublist l).cons a\n\n@[simp] theorem Sublist.refl : \u2200 l : List \u03b1, l <+ l\n  | [] => .slnil\n  | a :: l => (Sublist.refl l).cons\u2082 a\n\ntheorem Sublist.trans {l\u2081 l\u2082 l\u2083 : List \u03b1} (h\u2081 : l\u2081 <+ l\u2082) (h\u2082 : l\u2082 <+ l\u2083) : l\u2081 <+ l\u2083 := by\n  induction h\u2082 generalizing l\u2081 with\n  | slnil => exact h\u2081\n  | cons _ _ IH => exact (IH h\u2081).cons _\n  | @cons\u2082 l\u2082 _ a _ IH =>\n    generalize e : a :: l\u2082 = l\u2082'\n    match e \u25b8 h\u2081 with\n    | .slnil => apply nil_sublist\n    | .cons a' h\u2081' => cases e; apply (IH h\u2081').cons\n    | .cons\u2082 a' h\u2081' => cases e; apply (IH h\u2081').cons\u2082\n\ninstance : Trans (@Sublist \u03b1) Sublist Sublist := \u27e8Sublist.trans\u27e9\n\n@[simp] theorem sublist_cons (a : \u03b1) (l : List \u03b1) : l <+ a :: l := (Sublist.refl l).cons _\n\ntheorem sublist_of_cons_sublist : a :: l\u2081 <+ l\u2082 \u2192 l\u2081 <+ l\u2082 :=\n  (sublist_cons a l\u2081).trans\n\n@[simp] theorem sublist_append_left : \u2200 l\u2081 l\u2082 : List \u03b1, l\u2081 <+ l\u2081 ++ l\u2082\n  | [], _ => nil_sublist _\n  | _ :: l\u2081, l\u2082 => (sublist_append_left l\u2081 l\u2082).cons\u2082 _\n\n@[simp] theorem sublist_append_right : \u2200 l\u2081 l\u2082 : List \u03b1, l\u2082 <+ l\u2081 ++ l\u2082\n  | [], _ => Sublist.refl _\n  | _ :: l\u2081, l\u2082 => (sublist_append_right l\u2081 l\u2082).cons _\n\ntheorem sublist_append_of_sublist_left (s : l <+ l\u2081) : l <+ l\u2081 ++ l\u2082 :=\n  s.trans <| sublist_append_left ..\n\ntheorem sublist_append_of_sublist_right (s : l <+ l\u2082) : l <+ l\u2081 ++ l\u2082 :=\n  s.trans <| sublist_append_right ..\n\ntheorem cons_sublist_cons : a :: l\u2081 <+ a :: l\u2082 \u2194 l\u2081 <+ l\u2082 :=\n  \u27e8fun | .cons _ s => sublist_of_cons_sublist s | .cons\u2082 _ s => s, .cons\u2082 _\u27e9\n\n@[simp] theorem append_sublist_append_left : \u2200 l, l ++ l\u2081 <+ l ++ l\u2082 \u2194 l\u2081 <+ l\u2082\n  | [] => Iff.rfl\n  | _ :: l => cons_sublist_cons.trans (append_sublist_append_left l)\n\ntheorem Sublist.append_right : l\u2081 <+ l\u2082 \u2192 \u2200 l, l\u2081 ++ l <+ l\u2082 ++ l\n  | .slnil, _ => Sublist.refl _\n  | .cons _ h, _ => (h.append_right _).cons _\n  | .cons\u2082 _ h, _ => (h.append_right _).cons\u2082 _\n\ntheorem sublist_or_mem_of_sublist (h : l <+ l\u2081 ++ a :: l\u2082) : l <+ l\u2081 ++ l\u2082 \u2228 a \u2208 l := by\n  induction l\u2081 generalizing l with\n  | nil => match h with\n    | .cons _ h => exact .inl h\n    | .cons\u2082 _ h => exact .inr (.head ..)\n  | cons b l\u2081 IH =>\n    match h with\n    | .cons _ h => exact (IH h).imp_left (Sublist.cons _)\n    | .cons\u2082 _ h => exact (IH h).imp (Sublist.cons\u2082 _) (.tail _)\n\ntheorem Sublist.reverse : l\u2081 <+ l\u2082 \u2192 l\u2081.reverse <+ l\u2082.reverse\n  | .slnil => Sublist.refl _\n  | .cons _ h => by rw [reverse_cons]; exact sublist_append_of_sublist_left h.reverse\n  | .cons\u2082 _ h => by rw [reverse_cons, reverse_cons]; exact h.reverse.append_right _\n\n@[simp] theorem reverse_sublist : l\u2081.reverse <+ l\u2082.reverse \u2194 l\u2081 <+ l\u2082 :=\n  \u27e8fun h => l\u2081.reverse_reverse \u25b8 l\u2082.reverse_reverse \u25b8 h.reverse, Sublist.reverse\u27e9\n\n@[simp] theorem append_sublist_append_right (l) : l\u2081 ++ l <+ l\u2082 ++ l \u2194 l\u2081 <+ l\u2082 :=\n  \u27e8fun 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\u27e9\n\ntheorem Sublist.append (hl : l\u2081 <+ l\u2082) (hr : r\u2081 <+ r\u2082) : l\u2081 ++ r\u2081 <+ l\u2082 ++ r\u2082 :=\n  (hl.append_right _).trans ((append_sublist_append_left _).2 hr)\n\ntheorem Sublist.subset : l\u2081 <+ l\u2082 \u2192 l\u2081 \u2286 l\u2082\n  | .slnil, _, h => h\n  | .cons _ s, _, h => .tail _ (s.subset h)\n  | .cons\u2082 .., _, .head .. => .head ..\n  | .cons\u2082 _ s, _, .tail _ h => .tail _ (s.subset h)\n\ntheorem Sublist.length_le : l\u2081 <+ l\u2082 \u2192 length l\u2081 \u2264 length l\u2082\n  | .slnil => Nat.le_refl 0\n  | .cons _l s => le_succ_of_le (length_le s)\n  | .cons\u2082 _ s => succ_le_succ (length_le s)\n\n@[simp] theorem sublist_nil {l : List \u03b1} : l <+ [] \u2194 l = [] :=\n  \u27e8fun s => subset_nil.mp <| s.subset, fun H => H \u25b8 Sublist.refl _\u27e9\n\ntheorem Sublist.eq_of_length : l\u2081 <+ l\u2082 \u2192 length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082\n  | .slnil, _ => rfl\n  | .cons a s, h => nomatch Nat.not_lt.2 s.length_le (h \u25b8 lt_succ_self _)\n  | .cons\u2082 a s, h => by rw [s.eq_of_length (succ.inj h)]\n\ntheorem Sublist.eq_of_length_le (s : l\u2081 <+ l\u2082) (h : length l\u2082 \u2264 length l\u2081) : l\u2081 = l\u2082 :=\n  s.eq_of_length <| Nat.le_antisymm s.length_le h\n\n@[simp] theorem singleton_sublist {a : \u03b1} {l} : [a] <+ l \u2194 a \u2208 l := by\n  refine \u27e8fun h => h.subset (mem_singleton_self _), fun h => ?_\u27e9\n  obtain \u27e8_, _, rfl\u27e9 := append_of_mem h\n  exact ((nil_sublist _).cons\u2082 _).trans (sublist_append_right ..)\n\n@[simp] theorem replicate_sublist_replicate {m n} (a : \u03b1) :\n    replicate m a <+ replicate n a \u2194 m \u2264 n := by\n  refine \u27e8fun h => ?_, fun h => ?_\u27e9\n  \u00b7 have := h.length_le; simp only [length_replicate] at this \u22a2; exact this\n  \u00b7 induction h with\n    | refl => apply Sublist.refl\n    | step => simp [*, replicate, Sublist.cons]\n\n/-! ### head -/\n\ntheorem head!_of_head? [Inhabited \u03b1] : \u2200 {l : List \u03b1}, head? l = some a \u2192 head! l = a\n  | _a::_l, rfl => rfl\n\ntheorem head?_eq_head : \u2200 l h, @head? \u03b1 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 \u03b1) : tailD l l' = (tail? l).getD l' := by\n  cases l <;> rfl\n\ntheorem tail_eq_tailD (l) : @tail \u03b1 l = tailD l [] := by cases l <;> rfl\n\ntheorem tail_eq_tail? (l) : @tail \u03b1 l = (tail? l).getD [] := by simp [tail_eq_tailD]\n\n/-! ### next? -/\n\n@[simp] theorem next?_nil : @next? \u03b1 [] = none := rfl\n@[simp] theorem next?_cons (a l) : @next? \u03b1 (a :: l) = some (a, l) := rfl\n\n/-! ### getLast -/\n\n@[simp] theorem getLastD_nil (a) : @getLastD \u03b1 [] a = a := rfl\n@[simp] theorem getLastD_cons (a b l) : @getLastD \u03b1 (b::l) a = getLastD l b := by cases l <;> rfl\n\ntheorem getLast_eq_getLastD (a l h) : @getLast \u03b1 (a::l) h = getLastD l a := by\n  cases l <;> rfl\n\ntheorem getLast_singleton (a h) : @getLast \u03b1 [a] h = a := rfl\n\ntheorem getLast!_cons [Inhabited \u03b1] : @getLast! \u03b1 _ (a::l) = getLastD l a := by\n  simp [getLast!, getLast_eq_getLastD]\n\n@[simp] theorem getLast?_nil : @getLast? \u03b1 [] = none := rfl\ntheorem getLast?_cons : @getLast? \u03b1 (a::l) = getLastD l a := by\n  simp [getLast?, getLast_eq_getLastD]\n\ntheorem getLast?_eq_getLast : \u2200 l h, @getLast? \u03b1 l = some (getLast l h)\n  | [], h => nomatch h rfl\n  | _::_, _ => rfl\n\n/-! ### dropLast -/\n\n@[simp] theorem dropLast_nil : @dropLast \u03b1 [] = [] := rfl\n@[simp] theorem dropLast_single : dropLast [a] = [] := rfl\n@[simp] theorem dropLast_cons\u2082 : dropLast (a::b::l) = a :: dropLast (b::l) := rfl\n\n@[simp] theorem dropLast_append_cons : dropLast (l\u2081 ++ b::l\u2082) = l\u2081 ++ dropLast (b::l\u2082) := by\n  induction l\u2081 <;> simp [*]\n\n@[simp 1100] theorem dropLast_concat : dropLast (l\u2081 ++ [b]) = l\u2081 := by simp\n\n/-! ### nth element -/\n\n@[simp] theorem get_cons_zero {as : List \u03b1} : (a :: as).get \u27e80, Nat.zero_lt_succ _\u27e9 = a := rfl\n\n@[simp] theorem get_cons_succ {as : List \u03b1} {h : i + 1 < (a :: as).length} :\n  (a :: as).get \u27e8i+1, h\u27e9 = as.get \u27e8i, Nat.lt_of_succ_lt_succ h\u27e9 := rfl\n\ntheorem get_of_mem : \u2200 {a} {l : List \u03b1}, a \u2208 l \u2192 \u2203 n, get l n = a\n  | _, _ :: _, .head .. => \u27e8\u27e80, Nat.succ_pos _\u27e9, rfl\u27e9\n  | _, _ :: _, .tail _ m => let \u27e8\u27e8n, h\u27e9, e\u27e9 := get_of_mem m; \u27e8\u27e8n+1, Nat.succ_lt_succ h\u27e9, e\u27e9\n\ntheorem get?_eq_get : \u2200 {l : List \u03b1} {n} h, l.get? n = some (get l \u27e8n, h\u27e9)\n  | _ :: _, 0, _ => rfl\n  | _ :: l, _+1, _ => get?_eq_get (l := l) _\n\ntheorem get?_len_le : \u2200 {l : List \u03b1} {n}, length l \u2264 n \u2192 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 \u2194 \u2203 h, get l \u27e8n, h\u27e9 = a :=\n  \u27e8fun e =>\n    have : n < length l := Nat.lt_of_not_le fun hn => by cases get?_len_le hn \u25b8 e\n    \u27e8this, by rwa [get?_eq_get this, Option.some.injEq] at e\u27e9,\n  fun \u27e8h, e\u27e9 => e \u25b8 get?_eq_get _\u27e9\n\n@[simp] theorem get?_eq_none : l.get? n = none \u2194 length l \u2264 n :=\n  \u27e8fun e => Nat.le_of_not_lt (fun h' => by cases e \u25b8 get?_eq_some.2 \u27e8h', rfl\u27e9), get?_len_le\u27e9\n\ntheorem get?_of_mem {a} {l : List \u03b1} (h : a \u2208 l) : \u2203 n, l.get? n = some a :=\n  let \u27e8\u27e8n, _\u27e9, e\u27e9 := get_of_mem h; \u27e8n, e \u25b8 get?_eq_get _\u27e9\n\ntheorem get_mem : \u2200 (l : List \u03b1) n h, get l \u27e8n, h\u27e9 \u2208 l\n  | _ :: _, 0, _ => .head ..\n  | _ :: l, _+1, _ => .tail _ (get_mem l ..)\n\ntheorem get?_mem {l : List \u03b1} {n a} (e : l.get? n = some a) : a \u2208 l :=\n  let \u27e8_, e\u27e9 := get?_eq_some.1 e; e \u25b8 get_mem ..\n\ntheorem mem_iff_get {a} {l : List \u03b1} : a \u2208 l \u2194 \u2203 n, get l n = a :=\n  \u27e8get_of_mem, fun \u27e8_, e\u27e9 => e \u25b8 get_mem ..\u27e9\n\n-- TODO(Mario): move somewhere else\ntheorem Fin.exists_iff (p : Fin n \u2192 Prop) : (\u2203 i, p i) \u2194 \u2203 i h, p \u27e8i, h\u27e9 :=\n  \u27e8fun \u27e8i, h\u27e9 => \u27e8i.1, i.2, h\u27e9, fun \u27e8i, hi, h\u27e9 => \u27e8\u27e8i, hi\u27e9, h\u27e9\u27e9\n\ntheorem mem_iff_get? {a} {l : List \u03b1} : a \u2208 l \u2194 \u2203 n, l.get? n = some a := by\n  simp [get?_eq_some, Fin.exists_iff, mem_iff_get]\n\ntheorem get?_zero (l : List \u03b1) : l.get? 0 = l.head? := by cases l <;> rfl\n\n@[simp] theorem getElem_eq_get (l : List \u03b1) (i : Nat) (h) : l[i]'h = l.get \u27e8i, h\u27e9 := rfl\n\n@[simp] theorem getElem?_eq_get? (l : List \u03b1) (i : Nat) : l[i]? = l.get? i := by\n  unfold getElem?; split\n  \u00b7 exact (get?_eq_get \u2039_\u203a).symm\n  \u00b7 exact (get?_eq_none.2 <| Nat.not_lt.1 \u2039_\u203a).symm\n\ntheorem get?_inj\n    (h\u2080 : i < xs.length) (h\u2081 : Nodup xs) (h\u2082 : xs.get? i = xs.get? j) : i = j := by\n  induction xs generalizing i j with\n  | nil => cases h\u2080\n  | cons x xs ih =>\n    match i, j with\n    | 0, 0 => rfl\n    | i+1, j+1 => simp; cases h\u2081 with\n      | cons ha h\u2081 => exact ih (Nat.lt_of_succ_lt_succ h\u2080) h\u2081 h\u2082\n    | i+1, 0 => ?_ | 0, j+1 => ?_\n    all_goals\n      simp at h\u2082\n      cases h\u2081; rename_i h' h\n      have := h x ?_ rfl; cases this\n      rw [mem_iff_get?]\n    exact \u27e8_, h\u2082\u27e9; exact \u27e8_ , h\u2082.symm\u27e9\n\n@[simp] theorem get?_map (f : \u03b1 \u2192 \u03b2) : \u2200 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 : \u03b1 \u2192 \u03b2) {l n} : get (map f l) n = f (get l \u27e8n, length_map l f \u25b8 n.2\u27e9) :=\n  Option.some.inj <| by rw [\u2190 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 \u03b1} (h : l = l') (i : Fin l.length) :\n    get l i = get l' \u27e8i, h \u25b8 i.2\u27e9 := by cases h; rfl\n\n@[simp] \n\ntheorem get_zero : \u2200 {l : List \u03b1} (h : 0 < l.length), l.get \u27e80, h\u27e9 = l.head?\n  | _::_, _ => rfl\n\ntheorem get_append : \u2200 {l\u2081 l\u2082 : List \u03b1} (n : Nat) (h : n < l\u2081.length),\n    (l\u2081 ++ l\u2082).get \u27e8n, length_append .. \u25b8 Nat.lt_add_right _ _ _ h\u27e9 = l\u2081.get \u27e8n, h\u27e9\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 : \u2200 {l\u2081 l\u2082 : List \u03b1} {n : Nat}, l\u2081.length \u2264 n \u2192\n  (l\u2081 ++ l\u2082).get? n = l\u2082.get? (n - l\u2081.length)\n| [], _, n, _ => rfl\n| a :: l, _, n+1, h\u2081 => by rw [cons_append]; simp [get?_append_right (Nat.lt_succ.1 h\u2081)]\n\ntheorem get_append_right_aux {l\u2081 l\u2082 : List \u03b1} {n : Nat}\n  (h\u2081 : l\u2081.length \u2264 n) (h\u2082 : n < (l\u2081 ++ l\u2082).length) : n - l\u2081.length < l\u2082.length := by\n  rw [length_append] at h\u2082\n  exact Nat.sub_lt_left_of_lt_add h\u2081 h\u2082\n\ntheorem get_append_right' {l\u2081 l\u2082 : List \u03b1} {n : Nat} (h\u2081 : l\u2081.length \u2264 n) (h\u2082) :\n    (l\u2081 ++ l\u2082).get \u27e8n, h\u2082\u27e9 = l\u2082.get \u27e8n - l\u2081.length, get_append_right_aux h\u2081 h\u2082\u27e9 :=\nOption.some.inj <| by rw [\u2190 get?_eq_get, \u2190 get?_eq_get, get?_append_right h\u2081]\n\ntheorem get_of_append_proof {l : List \u03b1}\n    (eq : l = l\u2081 ++ a :: l\u2082) (h : l\u2081.length = n) : n < length l := eq \u25b8 h \u25b8 by simp_arith\n\ntheorem get_of_append {l : List \u03b1} (eq : l = l\u2081 ++ a :: l\u2082) (h : l\u2081.length = n) :\n    l.get \u27e8n, get_of_append_proof eq h\u27e9 = a := Option.some.inj <| by\n  rw [\u2190 get?_eq_get, eq, get?_append_right (h \u25b8 Nat.le_refl _), h, Nat.sub_self]; rfl\n\n@[simp] theorem get_replicate (a : \u03b1) {n : Nat} (m : Fin _) : (replicate n a).get m = a :=\n  eq_of_mem_replicate (get_mem _ _ _)\n\ntheorem get?_append {l\u2081 l\u2082 : List \u03b1} {n : Nat} (hn : n < l\u2081.length) :\n  (l\u2081 ++ l\u2082).get? n = l\u2081.get? n := by\n  have hn' : n < (l\u2081 ++ l\u2082).length := Nat.lt_of_lt_of_le hn <|\n    length_append .. \u25b8 Nat.le_add_right ..\n  rw [get?_eq_get hn, get?_eq_get hn', get_append]\n\ntheorem getLast_eq_get : \u2200 (l : List \u03b1) (h : l \u2260 []),\n    getLast l h = l.get \u27e8l.length - 1, Nat.sub_lt (length_pos.2 h) Nat.one_pos\u27e9\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? : \u2200 (l : List \u03b1), 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 : \u2200 (l : List \u03b1) (a : \u03b1), (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 \u03b1) : getLast? (l ++ [a]) = some a := by\n  simp [getLast?_eq_get?]\n\ntheorem get_cons_length (x : \u03b1) (xs : List \u03b1) (n : Nat) (h : n = xs.length) :\n    (x :: xs).get \u27e8n, by simp [h]\u27e9 = (x :: xs).getLast (cons_ne_nil x xs) := by\n  rw [getLast_eq_get]; cases h; rfl\n\n@[ext] theorem ext : \u2200 {l\u2081 l\u2082 : List \u03b1}, (\u2200 n, l\u2081.get? n = l\u2082.get? n) \u2192 l\u2081 = l\u2082\n  | [], [], _ => rfl\n  | a :: l\u2081, [], h => nomatch h 0\n  | [], a' :: l\u2082, h => nomatch h 0\n  | a :: l\u2081, a' :: l\u2082, 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\u2081 l\u2082 : List \u03b1} (hl : length l\u2081 = length l\u2082)\n    (h : \u2200 n h\u2081 h\u2082, get l\u2081 \u27e8n, h\u2081\u27e9 = get l\u2082 \u27e8n, h\u2082\u27e9) : l\u2081 = l\u2082 :=\n  ext fun n =>\n    if h\u2081 : n < length l\u2081 then by\n      rw [get?_eq_get, get?_eq_get, h n h\u2081 (by rwa [\u2190 hl])]\n    else by\n      have h\u2081 := Nat.le_of_not_lt h\u2081\n      rw [get?_len_le h\u2081, get?_len_le]; rwa [\u2190 hl]\n\ntheorem get?_reverse' : \u2200 {l : List \u03b1} (i j), i + j + 1 = length l \u2192\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 \u22a2\n    rw [get?_append, get?_reverse' _ j this]\n    rw [length_reverse, \u2190 this]; apply Nat.lt_add_of_pos_right (Nat.succ_pos _)\n\ntheorem get?_reverse {l : List \u03b1} (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 \u03b1] : \u2200 {l : List \u03b1} {n}, get? l n = some a \u2192 get! l n = a\n  | _a::_, 0, rfl => rfl\n  | _::l, _+1, e => get!_of_get? (l := l) e\n\ntheorem getD_eq_get? : \u2200 l n (a : \u03b1), 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 : \u2200 (i : Nat) (l : List \u03b1), 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 \u03b1) : length (take n l) \u2264 n := by simp [Nat.min_le_left]\n\ntheorem length_take_of_le (h : n \u2264 length l) : length (take n l) = n := by simp [Nat.min_eq_left h]\n\ntheorem get_cons_drop : \u2200 (l : List \u03b1) i, get l i :: drop (i + 1) l = drop i l\n  | _::_, \u27e80, _\u27e9 => rfl\n  | _::_, \u27e8i+1, _\u27e9 => get_cons_drop _ \u27e8i, _\u27e9\n\ntheorem map_eq_append_split {f : \u03b1 \u2192 \u03b2} {l : List \u03b1} {s\u2081 s\u2082 : List \u03b2}\n    (h : map f l = s\u2081 ++ s\u2082) : \u2203 l\u2081 l\u2082, l = l\u2081 ++ l\u2082 \u2227 map f l\u2081 = s\u2081 \u2227 map f l\u2082 = s\u2082 := by\n  have := h\n  rw [\u2190 take_append_drop (length s\u2081) l] at this \u22a2\n  rw [map_append] at this\n  refine \u27e8_, _, rfl, append_inj this ?_\u27e9\n  rw [length_map, length_take, Nat.min_eq_left]\n  rw [\u2190 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 : \u2200 {n} {l : List \u03b1}, a \u2208 l.drop n \u2192 a \u2208 l\n  | 0, _, h => h\n  | _+1, _::_, h => .tail _ (mem_of_mem_drop h)\n\n/-! ### modify nth -/\n\ntheorem modifyNthTail_id : \u2200 n (l : List \u03b1), 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 : \u2200 n (l : List \u03b1), 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 : \u03b1 \u2192 \u03b1) :\n    \u2200 n (l : List \u03b1) 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 \u03b1 \u2192 List \u03b1) (H : \u2200 l, length (f l) = length l) :\n    \u2200 n l, length (modifyNthTail f n l) = length l\n  | 0, _ => H _\n  | _+1, [] => rfl\n  | _+1, _ :: _ => congrArg (\u00b7+1) (modifyNthTail_length _ H _ _)\n\ntheorem modifyNthTail_add (f : List \u03b1 \u2192 List \u03b1) (n) (l\u2081 l\u2082 : List \u03b1) :\n    modifyNthTail f (l\u2081.length + n) (l\u2081 ++ l\u2082) = l\u2081 ++ modifyNthTail f n l\u2082 := by\n  induction l\u2081 <;> simp [*, Nat.succ_add]\n\ntheorem exists_of_modifyNthTail (f : List \u03b1 \u2192 List \u03b1) {n} {l : List \u03b1} (h : n \u2264 l.length) :\n    \u2203 l\u2081 l\u2082, l = l\u2081 ++ l\u2082 \u2227 l\u2081.length = n \u2227 modifyNthTail f n l = l\u2081 ++ f l\u2082 :=\n  have \u27e8_, _, eq, hl\u27e9 : \u2203 l\u2081 l\u2082, l = l\u2081 ++ l\u2082 \u2227 l\u2081.length = n :=\n    \u27e8_, _, (take_append_drop n l).symm, length_take_of_le h\u27e9\n  \u27e8_, _, eq, hl, hl \u25b8 eq \u25b8 modifyNthTail_add (n := 0) ..\u27e9\n\n@[simp] theorem modify_get?_length (f : \u03b1 \u2192 \u03b1) : \u2200 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 : \u03b1 \u2192 \u03b1) (n) (l : List \u03b1) :\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 : \u03b1 \u2192 \u03b1) {m n} (l : List \u03b1) (h : m \u2260 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 : \u03b1 \u2192 \u03b1) {n} {l : List \u03b1} (h : n < l.length) :\n    \u2203 l\u2081 a l\u2082, l = l\u2081 ++ a :: l\u2082 \u2227 l\u2081.length = n \u2227 modifyNth f n l = l\u2081 ++ f a :: l\u2082 :=\n  match exists_of_modifyNthTail _ (Nat.le_of_lt h) with\n  | \u27e8_, _::_, eq, hl, H\u27e9 => \u27e8_, _, _, eq, hl, H\u27e9\n  | \u27e8_, [], eq, hl, _\u27e9 => nomatch Nat.ne_of_gt h (eq \u25b8 append_nil _ \u25b8 hl)\n\n/-! ### set -/\n\ntheorem set_eq_modifyNth (a : \u03b1) : \u2200 n (l : List \u03b1), 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 : \u03b1 \u2192 \u03b1) :\n    \u2200 n (l : List \u03b1), 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 : \u03b1 \u2192 \u03b1) {n} {l : List \u03b1} (h) :\n    l.modifyNth f n = l.set n (f (l.get \u27e8n, h\u27e9)) := by\n  rw [modifyNth_eq_set_get?, get?_eq_get h]; rfl\n\ntheorem exists_of_set {l : List \u03b1} (h : n < l.length) :\n    \u2203 l\u2081 a l\u2082, l = l\u2081 ++ a :: l\u2082 \u2227 l\u2081.length = n \u2227 l.set n a' = l\u2081 ++ a' :: l\u2082 := by\n  rw [set_eq_modifyNth]; exact exists_of_modifyNth _ h\n\ntheorem exists_of_set' {l : List \u03b1} (h : n < l.length) :\n    \u2203 l\u2081 l\u2082, l = l\u2081 ++ l.get \u27e8n, h\u27e9 :: l\u2082 \u2227 l\u2081.length = n \u2227 l.set n a' = l\u2081 ++ a' :: l\u2082 :=\n  have \u27e8_, _, _, h\u2081, h\u2082, h\u2083\u27e9 := exists_of_set h; \u27e8_, _, get_of_append h\u2081 h\u2082 \u25b8 h\u2081, h\u2082, h\u2083\u27e9\n\ntheorem get?_set_eq (a : \u03b1) (n) (l : List \u03b1) : (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 : \u03b1) {n} {l : List \u03b1} (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 : \u03b1) {m n} (l : List \u03b1) (h : m \u2260 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 : \u03b1) {m n} (l : List \u03b1) :\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 : \u03b1) {m n} (l : List \u03b1) (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 : \u03b1) {m n} (l : List \u03b1) (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 : \u03b1) : [].set n a = [] := rfl\n\n@[simp] theorem set_succ (x : \u03b1) (xs : List \u03b1) (n : Nat) (a : \u03b1) :\n  (x :: xs).set n.succ a = x :: xs.set n a := rfl\n\ntheorem set_comm (a b : \u03b1) : \u2200 {n m : Nat} (l : List \u03b1), n \u2260 m \u2192\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 \u03b1) (i : Nat) (a : \u03b1) (h : i < (l.set i a).length) :\n    (l.set i a).get \u27e8i, h\u27e9 = a := by\n  rw [\u2190 Option.some_inj, \u2190 get?_eq_get, get?_set_eq, get?_eq_get] <;> simp_all\n\n@[simp] theorem get_set_ne {l : List \u03b1} {i j : Nat} (h : i \u2260 j) (a : \u03b1)\n    (hj : j < (l.set i a).length) :\n    (l.set i a).get \u27e8j, hj\u27e9 = l.get \u27e8j, by simp at hj; exact hj\u27e9 := by\n  rw [\u2190 Option.some_inj, \u2190 get?_eq_get, get?_set_ne _ _ h, get?_eq_get]\n\ntheorem get_set (a : \u03b1) {m n} (l : List \u03b1) (h) :\n    (set l m a).get \u27e8n, h\u27e9 = if m = n then a else l.get \u27e8n, length_set .. \u25b8 h\u27e9 := by\n  if h : m = n then subst m; simp else simp [h]\n\ntheorem mem_or_eq_of_mem_set : \u2200 {l : List \u03b1} {n : Nat} {a b : \u03b1}, a \u2208 l.set n b \u2192 a \u2208 l \u2228 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 : \u2200 {l i}, i < length l \u2192 length (@removeNth \u03b1 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, \u2190 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 \u03b1) : length (tail l) = length l - 1 := by cases l <;> rfl\n\n/-! ### all / any -/\n\n@[simp] theorem all_eq_true {l : List \u03b1} : l.all p \u2194 \u2200 x \u2208 l, p x := by induction l <;> simp [*]\n\n@[simp] theorem any_eq_true {l : List \u03b1} : l.any p \u2194 \u2203 x \u2208 l, p x := by induction l <;> simp [*]\n\n/-! ### reverse -/\n\n@[simp] theorem mem_reverseAux (x : \u03b1) : \u2200 as bs, x \u2208 reverseAux as bs \u2194 x \u2208 as \u2228 x \u2208 bs\n  | [], _ => by simp\n  | a :: _, _ => by simp [mem_reverseAux]; rw [\u2190 or_assoc, @or_comm (x = a)]\n\n@[simp] theorem mem_reverse (x : \u03b1) (as : List \u03b1) : x \u2208 reverse as \u2194 x \u2208 as := by simp [reverse]\n\n/-! ### insert -/\n\nsection insert\nvariable [DecidableEq \u03b1]\n\n@[simp] theorem insert_of_mem {l : List \u03b1} (h : a \u2208 l) : l.insert a = l := by\n  simp only [List.insert, if_pos h]\n\n@[simp] theorem insert_of_not_mem {l : List \u03b1} (h : a \u2209 l) : l.insert a = a :: l := by\n  simp only [List.insert, if_neg h]\n\n@[simp] theorem mem_insert_iff {l : List \u03b1} : a \u2208 l.insert b \u2194 a = b \u2228 a \u2208 l := by\n  if h : b \u2208 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 : \u03b1) (l : List \u03b1) : a \u2208 l.insert a :=\n  mem_insert_iff.2 (Or.inl rfl)\n\ntheorem mem_insert_of_mem {l : List \u03b1} (h : a \u2208 l) : a \u2208 l.insert b :=\n  mem_insert_iff.2 (Or.inr h)\n\ntheorem eq_or_mem_of_mem_insert {l : List \u03b1} (h : a \u2208 l.insert b) : a = b \u2228 a \u2208 l :=\n  mem_insert_iff.1 h\n\n@[simp] theorem length_insert_of_mem {l : List \u03b1} (h : a \u2208 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 \u03b1} (h : a \u2209 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 : \u03b1) (l : List \u03b1) :\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 \u03b1} (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 \u03b1} (p) (h : \u00acp a) :\n    (a :: l).eraseP p = a :: l.eraseP p := by simp [eraseP_cons, h]\n\ntheorem eraseP_of_forall_not {l : List \u03b1} (h : \u2200 a, a \u2208 l \u2192 \u00acp 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 : \u2200 {l : List \u03b1} {a} (al : a \u2208 l) (pa : p a),\n    \u2203 a l\u2081 l\u2082, (\u2200 b \u2208 l\u2081, \u00acp b) \u2227 p a \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.eraseP p = l\u2081 ++ l\u2082\n  | b :: l, a, al, pa =>\n    if pb : p b then\n      \u27e8b, [], l, forall_mem_nil _, pb, by simp [pb]\u27e9\n    else\n      match al with\n      | .head .. => nomatch pb pa\n      | .tail _ al =>\n        let \u27e8c, l\u2081, l\u2082, h\u2081, h\u2082, h\u2083, h\u2084\u27e9 := exists_of_eraseP al pa\n        \u27e8c, b::l\u2081, l\u2082, (forall_mem_cons ..).2 \u27e8pb, h\u2081\u27e9,\n          h\u2082, by rw [h\u2083, cons_append], by simp [pb, h\u2084]\u27e9\n\ntheorem exists_or_eq_self_of_eraseP (p) (l : List \u03b1) :\n    l.eraseP p = l \u2228\n    \u2203 a l\u2081 l\u2082, (\u2200 b \u2208 l\u2081, \u00acp b) \u2227 p a \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.eraseP p = l\u2081 ++ l\u2082 :=\n  if h : \u2203 a \u2208 l, p a then\n    let \u27e8_, ha, pa\u27e9 := h\n    .inr (exists_of_eraseP ha pa)\n  else\n    .inl (eraseP_of_forall_not (h \u27e8\u00b7, \u00b7, \u00b7\u27e9))\n\n@[simp] theorem length_eraseP_of_mem (al : a \u2208 l) (pa : p a) :\n    length (l.eraseP p) = Nat.pred (length l) := by\n  let \u27e8_, l\u2081, l\u2082, _, _, e\u2081, e\u2082\u27e9 := exists_of_eraseP al pa\n  rw [e\u2082]; simp [length_append, e\u2081]; rfl\n\ntheorem eraseP_append_left {a : \u03b1} (pa : p a) :\n    \u2200 {l\u2081 : List \u03b1} l\u2082, a \u2208 l\u2081 \u2192 (l\u2081++l\u2082).eraseP p = l\u2081.eraseP p ++ l\u2082\n  | x :: xs, l\u2082, h => by\n    by_cases h' : p x <;> simp [h']\n    rw [eraseP_append_left pa l\u2082 ((mem_cons.1 h).resolve_left (mt _ h'))]\n    intro | rfl => exact pa\n\ntheorem eraseP_append_right :\n    \u2200 {l\u2081 : List \u03b1} l\u2082, (\u2200 b \u2208 l\u2081, \u00acp b) \u2192 eraseP p (l\u2081++l\u2082) = l\u2081 ++ l\u2082.eraseP p\n  | [],      l\u2082, _ => rfl\n  | x :: xs, l\u2082, 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 \u03b1) : 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 \u27e8c, l\u2081, l\u2082, _, _, h\u2083, h\u2084\u27e9 => rw [h\u2084, h\u2083]; simp\n\ntheorem eraseP_subset (l : List \u03b1) : l.eraseP p \u2286 l := (eraseP_sublist l).subset\n\ntheorem Sublist.eraseP : l\u2081 <+ l\u2082 \u2192 l\u2081.eraseP p <+ l\u2082.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\u2082 a s => by\n    by_cases h : p a <;> simp [h]\n    exacts [s, s.eraseP.cons\u2082 _]\n\ntheorem mem_of_mem_eraseP {l : List \u03b1} : a \u2208 l.eraseP p \u2192 a \u2208 l := (eraseP_subset _ \u00b7)\n\n@[simp] theorem mem_eraseP_of_neg {l : List \u03b1} (pa : \u00acp a) : a \u2208 l.eraseP p \u2194 a \u2208 l := by\n  refine \u27e8mem_of_mem_eraseP, fun al => ?_\u27e9\n  match exists_or_eq_self_of_eraseP p l with\n  | .inl h => rw [h]; assumption\n  | .inr \u27e8c, l\u2081, l\u2082, h\u2081, h\u2082, h\u2083, h\u2084\u27e9 =>\n    rw [h\u2084]; rw [h\u2083] at al\n    have : a \u2260 c := fun h => (h \u25b8 pa).elim h\u2082\n    simp [this] at al; simp [al]\n\ntheorem eraseP_map (f : \u03b2 \u2192 \u03b1) : \u2200 (l : List \u03b2), (map f l).eraseP p = map f (l.eraseP (p \u2218 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 \u03b1) : extractP p l = (find? p l, eraseP p l) := by\n  let rec go (acc) : \u2200 xs, l = acc.data ++ xs \u2192\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    \u00b7 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 \u03b1]\n\n@[simp] theorem erase_nil (a : \u03b1) : [].erase a = [] := rfl\n\ntheorem erase_cons (a b : \u03b1) (l : List \u03b1) :\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 : \u03b1) (l : List \u03b1) : (a :: l).erase a = l := by\n  simp [erase_cons]\n\n@[simp] theorem erase_cons_tail {a b : \u03b1} (l : List \u03b1) (h : b \u2260 a) :\n    (b :: l).erase a = b :: l.erase a := by simp only [erase_cons, if_neg h]\n\ntheorem erase_eq_eraseP (a : \u03b1) : \u2200 l : List \u03b1, 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 : \u03b1) {l\u2081 l\u2082 : List \u03b1} (h : l\u2081 <+ l\u2082) : l\u2081.erase a <+ l\u2082.erase a := by\n  simp [erase_eq_eraseP]; exact Sublist.eraseP h\n\ntheorem erase_of_not_mem {a : \u03b1} : \u2200 {l : List \u03b1}, a \u2209 l \u2192 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 : \u03b1} {l : List \u03b1} (h : a \u2208 l) :\n    \u2203 l\u2081 l\u2082, a \u2209 l\u2081 \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.erase a = l\u2081 ++ l\u2082 := by\n  let \u27e8_, l\u2081, l\u2082, h\u2081, e, h\u2082, h\u2083\u27e9 := exists_of_eraseP h (beq_self_eq_true _)\n  rw [erase_eq_eraseP]; exact \u27e8l\u2081, l\u2082, fun h => h\u2081 _ h (beq_self_eq_true _), eq_of_beq e \u25b8 h\u2082, h\u2083\u27e9\n\n@[simp] theorem length_erase_of_mem {a : \u03b1} {l : List \u03b1} (h : a \u2208 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\u2081 : List \u03b1} (l\u2082) (h : a \u2208 l\u2081) :\n    (l\u2081 ++ l\u2082).erase a = l\u2081.erase a ++ l\u2082 := by\n  simp [erase_eq_eraseP]; exact eraseP_append_left (by exact decide_eq_true rfl) l\u2082 h\n\ntheorem erase_append_right {a : \u03b1} {l\u2081 : List \u03b1} (l\u2082 : List \u03b1) (h : a \u2209 l\u2081) :\n    (l\u2081 ++ l\u2082).erase a = (l\u2081 ++ l\u2082.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 : \u03b1) (l : List \u03b1) : l.erase a <+ l :=\n  erase_eq_eraseP a l \u25b8 eraseP_sublist l\n\ntheorem erase_subset (a : \u03b1) (l : List \u03b1) : l.erase a \u2286 l := (erase_sublist a l).subset\n\ntheorem sublist.erase (a : \u03b1) {l\u2081 l\u2082 : List \u03b1} (h : l\u2081 <+ l\u2082) : l\u2081.erase a <+ l\u2082.erase a := by\n  simp only [erase_eq_eraseP]; exact h.eraseP\n\ntheorem mem_of_mem_erase {a b : \u03b1} {l : List \u03b1} (h : a \u2208 l.erase b) : a \u2208 l := erase_subset _ _ h\n\n@[simp] theorem mem_erase_of_ne {a b : \u03b1} {l : List \u03b1} (ab : a \u2260 b) : a \u2208 l.erase b \u2194 a \u2208 l :=\n  erase_eq_eraseP b l \u25b8 mem_eraseP_of_neg (mt of_decide_eq_true ab.symm)\n\ntheorem erase_comm (a b : \u03b1) (l : List \u03b1) : (l.erase a).erase b = (l.erase b).erase a := by\n  if ab : a = b then rw [ab] else ?_\n  if ha : a \u2208 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 \u2208 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  | _, _, \u27e8l\u2081, l\u2082, ha', rfl, rfl\u27e9 =>\n    if h\u2081 : b \u2208 l\u2081 then\n      rw [erase_append_left _ h\u2081, erase_append_left _ h\u2081,\n          erase_append_right _ (mt mem_of_mem_erase ha'), erase_cons_head]\n    else\n      rw [erase_append_right _ h\u2081, erase_append_right _ h\u2081, 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 : \u03b1 \u2192 Bool) : filter p [] = [] := rfl\n\n@[simp] theorem filter_cons_of_pos {p : \u03b1 \u2192 Bool} {a : \u03b1} (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 : \u03b1 \u2192 Bool} {a : \u03b1} (l) (pa : \u00ac 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 : \u03b1 \u2192 Bool} :\n    \u2200 (l\u2081 l\u2082 : List \u03b1), filter p (l\u2081 ++ l\u2082) = filter p l\u2081 ++ filter p l\u2082\n  | [], l\u2082 => rfl\n  | a :: l\u2081, l\u2082 => by simp [filter]; split <;> simp [filter_append l\u2081]\n\n@[simp] theorem filter_sublist {p : \u03b1 \u2192 Bool} : \u2200 (l : List \u03b1), filter p l <+ l\n  | [] => .slnil\n  | a :: l => by rw [filter]; split <;> simp [Sublist.cons, Sublist.cons\u2082, filter_sublist l]\n\ntheorem mem_filter : x \u2208 filter p as \u2194 x \u2208 as \u2227 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    \u00b7 exact or_congr_left (and_iff_left_of_imp fun | rfl => h).symm\n    \u00b7 exact (or_iff_right fun \u27e8rfl, h'\u27e9 => h h').symm\n\n@[simp] theorem partition_eq_filter_filter (p : \u03b1 \u2192 Bool) (l : List \u03b1) :\n    partition p l = (filter p l, filter (not \u2218 p) l) := by simp [partition, aux] where\n  aux : \u2200 l {as bs}, partition.loop p l (as, bs) =\n    (as.reverse ++ filter p l, bs.reverse ++ filter (not \u2218 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 : \u03b1 \u2192 Bool} :\n    \u2200 {l : List \u03b1}, (\u2200 x \u2208 l, p x \u2194 q x) \u2192 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    \u00b7 simp [pa, h.1.1 pa, filter_congr' h.2]\n    \u00b7 simp [pa, mt h.1.2 pa, filter_congr' h.2]\n\n/-! ### filterMap -/\n\n@[simp] theorem filterMap_nil (f : \u03b1 \u2192 Option \u03b2) : filterMap f [] = [] := rfl\n\n@[simp] theorem filterMap_cons (f : \u03b1 \u2192 Option \u03b2) (a : \u03b1) (l : List \u03b1) :\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 : \u03b1 \u2192 Option \u03b2} (a : \u03b1) (l : List \u03b1) (h : f a = none) :\n    filterMap f (a :: l) = filterMap f l := by simp only [filterMap, h]\n\ntheorem filterMap_cons_some (f : \u03b1 \u2192 Option \u03b2) (a : \u03b1) (l : List \u03b1) {b : \u03b2} (h : f a = some b) :\n    filterMap f (a :: l) = b :: filterMap f l := by simp only [filterMap, h]\n\ntheorem filterMap_append {\u03b1 \u03b2 : Type _} (l l' : List \u03b1) (f : \u03b1 \u2192 Option \u03b2) :\n    filterMap f (l ++ l') = filterMap f l ++ filterMap f l' := by\n  induction l <;> simp; split <;> simp [*]\n\ntheorem filterMap_eq_map (f : \u03b1 \u2192 \u03b2) : filterMap (some \u2218 f) = map f := by\n  funext l; induction l <;> simp [*]\n\ntheorem filterMap_eq_filter (p : \u03b1 \u2192 Bool) :\n    filterMap (Option.guard (p \u00b7)) = 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, \u2190 IH]\n\ntheorem filterMap_filterMap (f : \u03b1 \u2192 Option \u03b2) (g : \u03b2 \u2192 Option \u03b3) (l : List \u03b1) :\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 : \u03b1 \u2192 Option \u03b2) (g : \u03b2 \u2192 \u03b3) (l : List \u03b1) :\n    map g (filterMap f l) = filterMap (fun x => (f x).map g) l := by\n  simp only [\u2190 filterMap_eq_map, filterMap_filterMap, Option.map_eq_bind]\n\ntheorem filterMap_map (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 Option \u03b3) (l : List \u03b1) :\n    filterMap g (map f l) = filterMap (g \u2218 f) l := by\n  rw [\u2190 filterMap_eq_map, filterMap_filterMap]; rfl\n\ntheorem filter_filterMap (f : \u03b1 \u2192 Option \u03b2) (p : \u03b2 \u2192 Bool) (l : List \u03b1) :\n    filter p (filterMap f l) = filterMap (fun x => (f x).filter p) l := by\n  rw [\u2190 filterMap_eq_filter, filterMap_filterMap]\n  congr; funext x; cases f x <;> simp [Option.filter, Option.guard]\n\ntheorem filterMap_filter (p : \u03b1 \u2192 Bool) (f : \u03b1 \u2192 Option \u03b2) (l : List \u03b1) :\n    filterMap f (filter p l) = filterMap (fun x => if p x then f x else none) l := by\n  rw [\u2190 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 \u03b1) : filterMap some l = l := by\n  erw [filterMap_eq_map, map_id]\n\ntheorem map_filterMap_some_eq_filter_map_is_some (f : \u03b1 \u2192 Option \u03b2) (l : List \u03b1) :\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 : \u03b1 \u2192 Option \u03b2) (l : List \u03b1) {b : \u03b2} :\n    b \u2208 filterMap f l \u2194 \u2203 a, a \u2208 l \u2227 f a = some b := by\n  induction l <;> simp; split <;> simp [*, eq_comm]\n\n@[simp] theorem filterMap_join (f : \u03b1 \u2192 Option \u03b2) (L : List (List \u03b1)) :\n    filterMap f (join L) = join (map (filterMap f) L) := by\n  induction L <;> simp [*, filterMap_append]\n\ntheorem map_filterMap_of_inv (f : \u03b1 \u2192 Option \u03b2) (g : \u03b2 \u2192 \u03b1) (H : \u2200 x : \u03b1, (f x).map g = some x)\n    (l : List \u03b1) : map g (filterMap f l) = l := by simp only [map_filterMap, H, filterMap_some]\n\ntheorem length_filter_le (p : \u03b1 \u2192 Bool) (l : List \u03b1) :\n    (l.filter p).length \u2264 l.length := (filter_sublist _).length_le\n\ntheorem length_filterMap_le (f : \u03b1 \u2192 Option \u03b2) (l : List \u03b1) :\n    (filterMap f l).length \u2264 l.length := by\n  rw [\u2190 length_map _ some, map_filterMap_some_eq_filter_map_is_some, \u2190 length_map _ f]\n  apply length_filter_le\n\ntheorem Sublist.filterMap (f : \u03b1 \u2192 Option \u03b2) (s : l\u2081 <+ l\u2082) : filterMap f l\u2081 <+ filterMap f l\u2082 := by\n  induction s <;> simp <;> split <;> simp [*, cons, cons\u2082]\n\ntheorem Sublist.filter (p : \u03b1 \u2192 Bool) {l\u2081 l\u2082} (s : l\u2081 <+ l\u2082) : filter p l\u2081 <+ filter p l\u2082 := by\n  rw [\u2190 filterMap_eq_filter]; apply s.filterMap\n\ntheorem map_filter (f : \u03b2 \u2192 \u03b1) (l : List \u03b2) : filter p (map f l) = map f (filter (p \u2218 f) l) := by\n  rw [\u2190 filterMap_eq_map, filter_filterMap, filterMap_filter]; rfl\n\n@[simp] theorem filter_filter (q) : \u2200 l, filter p (filter q l) = filter (fun a => p a \u2227 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 = [] \u2194 \u2200 a \u2208 l, \u00acp 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 \u2194 \u2200 a \u2208 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 \u25b8 length_filter_le p l)\n\ntheorem filter_length_eq_length {l} : (filter p l).length = l.length \u2194 \u2200 a \u2208 l, p a :=\n  Iff.trans \u27e8l.filter_sublist.eq_of_length, congrArg length\u27e9 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 : \u00acp a) : find? p (a :: l) = find? p l :=\n  by simp [find?, h]\n\ntheorem find?_eq_none : find? p l = none \u2194 \u2200 x \u2208 l, \u00ac p x := by\n  induction l <;> simp; split <;> simp [*]\n\ntheorem find?_some : \u2200 {l}, find? p l = some a \u2192 p a\n  | b :: l, H => by\n    by_cases h : p b <;> simp [find?, h] at H\n    \u00b7 exact H \u25b8 h\n    \u00b7 exact find?_some H\n\n@[simp] theorem mem_of_find?_eq_some : \u2200 {l}, find? p l = some a \u2192 a \u2208 l\n  | b :: l, H => by\n    by_cases h : p b <;> simp [find?, h] at H\n    \u00b7 exact H \u25b8 .head _\n    \u00b7 exact .tail _ (mem_of_find?_eq_some H)\n\n/-! ### pairwise -/\n\ntheorem Pairwise.sublist : l\u2081 <+ l\u2082 \u2192 l\u2082.Pairwise R \u2192 l\u2081.Pairwise R\n  | .slnil, h => h\n  | .cons _ s, .cons _ h\u2082 => h\u2082.sublist s\n  | .cons\u2082 _ s, .cons h\u2081 h\u2082 => (h\u2082.sublist s).cons fun _ h => h\u2081 _ (s.subset h)\n\ntheorem pairwise_map {l : List \u03b1} :\n    (l.map f).Pairwise R \u2194 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\u2081 l\u2082 : List \u03b1} :\n    (l\u2081 ++ l\u2082).Pairwise R \u2194 l\u2081.Pairwise R \u2227 l\u2082.Pairwise R \u2227 \u2200 a \u2208 l\u2081, \u2200 b \u2208 l\u2082, R a b := by\n  induction l\u2081 <;> simp [*, or_imp, forall_and, and_assoc, and_left_comm]\n\ntheorem pairwise_reverse {l : List \u03b1} :\n    l.reverse.Pairwise R \u2194 l.Pairwise (fun a b => R b a) := by\n  induction l <;> simp [*, pairwise_append, and_comm]\n\ntheorem Pairwise.imp {\u03b1 R S} (H : \u2200 {a b}, R a b \u2192 S a b) :\n    \u2200 {l : List \u03b1}, l.Pairwise R \u2192 l.Pairwise S\n  | _, .nil => .nil\n  | _, .cons h\u2081 h\u2082 => .cons (H \u2218 h\u2081 \u00b7) (h\u2082.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\u2081 l\u2082) : Disjoint l\u2082 l\u2081 := fun _ i\u2082 i\u2081 => d i\u2081 i\u2082\n\ntheorem disjoint_comm : Disjoint l\u2081 l\u2082 \u2194 Disjoint l\u2082 l\u2081 := \u27e8disjoint_symm, disjoint_symm\u27e9\n\ntheorem disjoint_left : Disjoint l\u2081 l\u2082 \u2194 \u2200 \u2983a\u2984, a \u2208 l\u2081 \u2192 a \u2209 l\u2082 := by simp [Disjoint]\n\ntheorem disjoint_right : Disjoint l\u2081 l\u2082 \u2194 \u2200 \u2983a\u2984, a \u2208 l\u2082 \u2192 a \u2209 l\u2081 := disjoint_comm\n\ntheorem disjoint_iff_ne : Disjoint l\u2081 l\u2082 \u2194 \u2200 a \u2208 l\u2081, \u2200 b \u2208 l\u2082, a \u2260 b :=\n  \u27e8fun h _ al1 _ bl2 ab => h al1 (ab \u25b8 bl2), fun h _ al1 al2 => h _ al1 _ al2 rfl\u27e9\n\ntheorem disjoint_of_subset_left (ss : l\u2081 \u2286 l) (d : Disjoint l l\u2082) : Disjoint l\u2081 l\u2082 :=\n  fun _ m => d (ss m)\n\ntheorem disjoint_of_subset_right (ss : l\u2082 \u2286 l) (d : Disjoint l\u2081 l) : Disjoint l\u2081 l\u2082 :=\n  fun _ m m\u2081 => d m (ss m\u2081)\n\ntheorem disjoint_of_disjoint_cons_left {l\u2081 l\u2082} : Disjoint (a :: l\u2081) l\u2082 \u2192 Disjoint l\u2081 l\u2082 :=\ndisjoint_of_subset_left (subset_cons _ _)\n\ntheorem disjoint_of_disjoint_cons_right {l\u2081 l\u2082} : Disjoint l\u2081 (a :: l\u2082) \u2192 Disjoint l\u2081 l\u2082 :=\ndisjoint_of_subset_right (subset_cons _ _)\n\n@[simp] theorem disjoint_nil_left (l : List \u03b1) : Disjoint [] l := fun a => (not_mem_nil a).elim\n\n@[simp] theorem disjoint_nil_right (l : List \u03b1) : Disjoint l [] := by\n  rw [disjoint_comm]; exact disjoint_nil_left _\n\n@[simp 1100] theorem singleton_disjoint : Disjoint [a] l \u2194 a \u2209 l := by simp [Disjoint]\n\n@[simp 1100] theorem disjoint_singleton : Disjoint l [a] \u2194 a \u2209 l := by\n  rw [disjoint_comm, singleton_disjoint]\n\n@[simp] theorem disjoint_append_left : Disjoint (l\u2081 ++ l\u2082) l \u2194 Disjoint l\u2081 l \u2227 Disjoint l\u2082 l := by\n  simp [Disjoint, or_imp, forall_and]\n\n@[simp] theorem disjoint_append_right : Disjoint l (l\u2081 ++ l\u2082) \u2194 Disjoint l l\u2081 \u2227 Disjoint l l\u2082 :=\n  disjoint_comm.trans <| by rw [disjoint_append_left]; simp [disjoint_comm]\n\n@[simp] theorem disjoint_cons_left : Disjoint (a::l\u2081) l\u2082 \u2194 (a \u2209 l\u2082) \u2227 Disjoint l\u2081 l\u2082 :=\n  (disjoint_append_left (l\u2081 := [a])).trans <| by simp [singleton_disjoint]\n\n@[simp] theorem disjoint_cons_right : Disjoint l\u2081 (a :: l\u2082) \u2194 (a \u2209 l\u2081) \u2227 Disjoint l\u2081 l\u2082 :=\n  disjoint_comm.trans <| by rw [disjoint_cons_left]; simp [disjoint_comm]\n\ntheorem disjoint_of_disjoint_append_left_left (d : Disjoint (l\u2081 ++ l\u2082) l) : Disjoint l\u2081 l :=\n  (disjoint_append_left.1 d).1\n\ntheorem disjoint_of_disjoint_append_left_right (d : Disjoint (l\u2081 ++ l\u2082) l) : Disjoint l\u2082 l :=\n  (disjoint_append_left.1 d).2\n\ntheorem disjoint_of_disjoint_append_right_left (d : Disjoint l (l\u2081 ++ l\u2082)) : Disjoint l l\u2081 :=\n  (disjoint_append_right.1 d).1\n\ntheorem disjoint_of_disjoint_append_right_right (d : Disjoint l (l\u2081 ++ l\u2082)) : Disjoint l l\u2082 :=\n  (disjoint_append_right.1 d).2\n\ntheorem disjoint_take_drop : \u2200 {l : List \u03b1}, l.Nodup \u2192 m \u2264 n \u2192 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    \u00b7 case succ.zero => cases h\n    \u00b7 cases hl with | cons h\u2080 h\u2081 =>\n      refine \u27e8fun h => h\u2080 _ (mem_of_mem_drop h) rfl, ?_\u27e9\n      exact disjoint_take_drop h\u2081 (Nat.le_of_succ_le_succ h)\n\n/-! ### foldl / foldr -/\n\ntheorem foldl_map (f : \u03b2\u2081 \u2192 \u03b2\u2082) (g : \u03b1 \u2192 \u03b2\u2082 \u2192 \u03b1) (l : List \u03b2\u2081) (init : \u03b1) :\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 : \u03b1\u2081 \u2192 \u03b1\u2082) (g : \u03b1\u2082 \u2192 \u03b2 \u2192 \u03b2) (l : List \u03b1\u2081) (init : \u03b2) :\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 : \u03b1\u2081 \u2192 \u03b1\u2082) (g\u2081 : \u03b1\u2081 \u2192 \u03b2 \u2192 \u03b1\u2081) (g\u2082 : \u03b1\u2082 \u2192 \u03b2 \u2192 \u03b1\u2082) (l : List \u03b2) (init : \u03b1\u2081)\n    (H : \u2200 x y, g\u2082 (f x) y = f (g\u2081 x y)) : l.foldl g\u2082 (f init) = f (l.foldl g\u2081 init) := by\n  induction l generalizing init <;> simp [*, H]\n\ntheorem foldr_hom (f : \u03b2\u2081 \u2192 \u03b2\u2082) (g\u2081 : \u03b1 \u2192 \u03b2\u2081 \u2192 \u03b2\u2081) (g\u2082 : \u03b1 \u2192 \u03b2\u2082 \u2192 \u03b2\u2082) (l : List \u03b1) (init : \u03b2\u2081)\n    (H : \u2200 x y, g\u2082 x (f y) = f (g\u2081 x y)) : l.foldr g\u2082 (f init) = f (l.foldr g\u2081 init) := by\n  induction l <;> simp [*, H]\n\n/-! ### union -/\n\nsection union\n\nvariable [DecidableEq \u03b1]\n\n@[simp] theorem nil_union (l : List \u03b1) : nil.union l = l := by simp [List.union, foldr]\n\n@[simp] theorem cons_union (a : \u03b1) (l\u2081 l\u2082 : List \u03b1) :\n    (a :: l\u2081).union l\u2082 = (l\u2081.union l\u2082).insert a := by simp [List.union, foldr]\n\n@[simp] theorem mem_union_iff [DecidableEq \u03b1] {x : \u03b1} {l\u2081 l\u2082 : List \u03b1} :\n    x \u2208 l\u2081.union l\u2082 \u2194 x \u2208 l\u2081 \u2228 x \u2208 l\u2082 := by induction l\u2081 <;> simp [*, or_assoc]\n\nend union\n\n/-! ### inter -/\n\n@[simp] theorem mem_inter_iff [DecidableEq \u03b1] {x : \u03b1} {l\u2081 l\u2082 : List \u03b1} :\n    x \u2208 l\u2081.inter l\u2082 \u2194 x \u2208 l\u2081 \u2227 x \u2208 l\u2082 := by\n  cases l\u2081 <;> 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 \u03b1} {ys : List \u03b2} {x : \u03b1} {y : \u03b2} :\n    (x, y) \u2208 product xs ys \u2194 x \u2208 xs \u2227 y \u2208 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 : \u03b1) (l : List \u03b1) :\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 : \u03b1) (l : List \u03b1) :\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 : \u03b1) (l : List \u03b1) : 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 \u03b1 \u03b2 m _ = forIn := rfl\n\ntheorem forIn_eq_bindList [Monad m] [LawfulMonad m]\n    (f : \u03b1 \u2192 \u03b2 \u2192 m (ForInStep \u03b2)) (l : List \u03b1) (init : \u03b2) :\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\u2081 l\u2082 : List \u03b1) (f : \u03b1 \u2192 m PUnit) :\n    (l\u2081 ++ l\u2082).forM f = (do l\u2081.forM f; l\u2082.forM f) := by induction l\u2081 <;> simp [*]\n\n/-! ### diff -/\n\nsection Diff\n-- TODO: theorems about `BEq`\nvariable [DecidableEq \u03b1]\n\n@[simp] theorem diff_nil (l : List \u03b1) : l.diff [] = l := rfl\n\n@[simp] theorem diff_cons (l\u2081 l\u2082 : List \u03b1) (a : \u03b1) : l\u2081.diff (a :: l\u2082) = (l\u2081.erase a).diff l\u2082 := by\n  simp [List.diff]; split <;> simp [*, erase_of_not_mem]\n\ntheorem diff_cons_right (l\u2081 l\u2082 : List \u03b1) (a : \u03b1) : l\u2081.diff (a :: l\u2082) = (l\u2081.diff l\u2082).erase a := by\n  apply Eq.symm; induction l\u2082 generalizing l\u2081 <;> simp [erase_comm, *]\n\ntheorem diff_erase (l\u2081 l\u2082 : List \u03b1) (a : \u03b1) : (l\u2081.diff l\u2082).erase a = (l\u2081.erase a).diff l\u2082 := by\n  rw [\u2190 diff_cons_right, diff_cons]\n\n@[simp] theorem nil_diff (l : List \u03b1) : [].diff l = [] := by\n  induction l <;> simp [*, erase_of_not_mem]\n\ntheorem cons_diff (a : \u03b1) (l\u2081 l\u2082 : List \u03b1) :\n    (a :: l\u2081).diff l\u2082 = if a \u2208 l\u2082 then l\u2081.diff (l\u2082.erase a) else a :: l\u2081.diff l\u2082 := by\n  induction l\u2082 generalizing l\u2081 with\n  | nil => rfl\n  | cons b l\u2082 ih => by_cases h : a = b <;> simp [*, eq_comm]\n\ntheorem cons_diff_of_mem {a : \u03b1} {l\u2082 : List \u03b1} (h : a \u2208 l\u2082) (l\u2081 : List \u03b1) :\n    (a :: l\u2081).diff l\u2082 = l\u2081.diff (l\u2082.erase a) := by rw [cons_diff, if_pos h]\n\ntheorem cons_diff_of_not_mem {a : \u03b1} {l\u2082 : List \u03b1} (h : a \u2209 l\u2082) (l\u2081 : List \u03b1) :\n    (a :: l\u2081).diff l\u2082 = a :: l\u2081.diff l\u2082 := by rw [cons_diff, if_neg h]\n\ntheorem diff_eq_foldl : \u2200 l\u2081 l\u2082 : List \u03b1, l\u2081.diff l\u2082 = foldl List.erase l\u2081 l\u2082\n  | _, [] => rfl\n  | l\u2081, a :: l\u2082 => (diff_cons l\u2081 l\u2082 a).trans (diff_eq_foldl _ _)\n\n@[simp] theorem diff_append (l\u2081 l\u2082 l\u2083 : List \u03b1) : l\u2081.diff (l\u2082 ++ l\u2083) = (l\u2081.diff l\u2082).diff l\u2083 := by\n  simp only [diff_eq_foldl, foldl_append]\n\ntheorem diff_sublist : \u2200 l\u2081 l\u2082 : List \u03b1, l\u2081.diff l\u2082 <+ l\u2081\n  | _, [] => .refl _\n  | l\u2081, a :: l\u2082 =>\n    calc\n      l\u2081.diff (a :: l\u2082) = (l\u2081.erase a).diff l\u2082 := diff_cons ..\n      _ <+ l\u2081.erase a := diff_sublist ..\n      _ <+ l\u2081 := erase_sublist ..\n\ntheorem diff_subset (l\u2081 l\u2082 : List \u03b1) : l\u2081.diff l\u2082 \u2286 l\u2081 := (diff_sublist ..).subset\n\ntheorem mem_diff_of_mem {a : \u03b1} : \u2200 {l\u2081 l\u2082 : List \u03b1}, a \u2208 l\u2081 \u2192 a \u2209 l\u2082 \u2192 a \u2208 l\u2081.diff l\u2082\n  | _, [], h\u2081, _ => h\u2081\n  | l\u2081, b :: l\u2082, h\u2081, h\u2082 => by\n    rw [diff_cons]\n    exact mem_diff_of_mem ((mem_erase_of_ne <| ne_of_not_mem_cons h\u2082).2 h\u2081) (mt (.tail _) h\u2082)\n\ntheorem Sublist.diff_right : \u2200 {l\u2081 l\u2082 l\u2083 : List \u03b1}, l\u2081 <+ l\u2082 \u2192 l\u2081.diff l\u2083 <+ l\u2082.diff l\u2083\n  | _,  _, [], h => h\n  | l\u2081, l\u2082, a :: l\u2083, h => by simp only [diff_cons, (h.erase _).diff_right]\n\ntheorem Sublist.erase_diff_erase_sublist {a : \u03b1} :\n    \u2200 {l\u2081 l\u2082 : List \u03b1}, l\u2081 <+ l\u2082 \u2192 (l\u2082.erase a).diff (l\u2081.erase a) <+ l\u2082.diff l\u2081\n  | [], l\u2082, _ => erase_sublist _ _\n  | b :: l\u2081, l\u2082, 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 _ \u25b8 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u03b1`, and `f : \u03b1 \u2192 \u03b2` a function.\n\n* `\u220f x in s, f x` is notation for `finset.prod s f` (assuming `\u03b2` is a `comm_monoid`)\n* `\u2211 x in s, f x` is notation for `finset.sum s f` (assuming `\u03b2` is an `add_comm_monoid`)\n* `\u220f x, f x` is notation for `finset.prod finset.univ f`\n  (assuming `\u03b1` is a `fintype` and `\u03b2` is a `comm_monoid`)\n* `\u2211 x, f x` is notation for `finset.sum finset.univ f`\n  (assuming `\u03b1` is a `fintype` and `\u03b2` 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 {\u03b2 : Type u} {\u03b1 : Type v} {\u03b3 : Type w}\n\nnamespace finset\n\n/--\n`\u220f 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 \"`\u2211 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 \u03b2] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) : \u03b2 := (s.1.map f).prod\n\n@[simp, to_additive] lemma prod_mk [comm_monoid \u03b2] (s : multiset \u03b1) (hs : s.nodup) (f : \u03b1 \u2192 \u03b2) :\n  (\u27e8s, hs\u27e9 : finset \u03b1).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 `\u220f` and `\u2211`.\nWe will have to make a choice.\n\nOnline discussions, such as https://math.stackexchange.com/q/185538/30839\nseem to suggest that `\u220f` and `\u2211` 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\u2211 k in K, (a k + b k) = \u2211 k in K, a k + \u2211 k in K, b k \u2192\n  \u220f k in K, a k * b k = (\u220f k in K, a k) * (\u220f 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 `\u2211` binders `, ` r:(scoped:67 f, finset.sum finset.univ f) := r\"\n  in big_operators\nlocalized \"notation `\u220f` binders `, ` r:(scoped:67 f, finset.prod finset.univ f) := r\"\n  in big_operators\n\nlocalized \"notation `\u2211` binders ` in ` s `, ` r:(scoped:67 f, finset.sum s f) := r\"\n  in big_operators\nlocalized \"notation `\u220f` 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\u2081 s\u2082 : finset \u03b1} {a : \u03b1} {f g : \u03b1 \u2192 \u03b2}\n\n@[to_additive] lemma prod_eq_multiset_prod [comm_monoid \u03b2] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  \u220f x in s, f x = (s.1.map f).prod := rfl\n\n@[to_additive]\ntheorem prod_eq_fold [comm_monoid \u03b2] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  \u220f x in s, f x = s.fold (*) 1 f :=\nrfl\n\n@[simp] lemma sum_multiset_singleton (s : finset \u03b1) :\n  s.sum (\u03bb 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 \u03b2] [comm_monoid \u03b3] {G : Type*} [monoid_hom_class G \u03b2 \u03b3] (g : G)\n  (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) :\n  g (\u220f x in s, f x) = \u220f 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 \u03b2] [comm_monoid \u03b3] (g : \u03b2 \u2192* \u03b3) (f : \u03b1 \u2192 \u03b2)\n  (s : finset \u03b1) : g (\u220f x in s, f x) = \u220f 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 \u03b2] [comm_monoid \u03b3] (g : \u03b2 \u2243* \u03b3) (f : \u03b1 \u2192 \u03b2)\n  (s : finset \u03b1) : g (\u220f x in s, f x) = \u220f 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 \u03b2] [semiring \u03b3] (f : \u03b2 \u2192+* \u03b3) (l : list \u03b2) :\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 \u03b2] [non_assoc_semiring \u03b3]\n  (f : \u03b2 \u2192+* \u03b3) (l : list \u03b2) :\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 \u03b2] [semiring \u03b3] (f : \u03b2 \u2192+* \u03b3\u1d50\u1d52\u1d56)\n  (l : list \u03b2) : mul_opposite.unop (f l.prod) = (l.map (mul_opposite.unop \u2218 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 \u03b2] [comm_semiring \u03b3] (f : \u03b2 \u2192+* \u03b3)\n  (s : multiset \u03b2) :\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 \u03b2] [non_assoc_semiring \u03b3]\n  (f : \u03b2 \u2192+* \u03b3) (s : multiset \u03b2) :\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 \u03b2] [comm_semiring \u03b3] (g : \u03b2 \u2192+* \u03b3) (f : \u03b1 \u2192 \u03b2)\n  (s : finset \u03b1) :\n  g (\u220f x in s, f x) = \u220f 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 \u03b2] [non_assoc_semiring \u03b3]\n  (g : \u03b2 \u2192+* \u03b3) (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) :\n  g (\u2211 x in s, f x) = \u2211 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 \u03b2] [comm_monoid \u03b3] (f : \u03b1 \u2192 \u03b2 \u2192* \u03b3) (s : finset \u03b1) :\n  \u21d1(\u220f x in s, f x) = \u220f x in s, f x :=\n(monoid_hom.coe_fn \u03b2 \u03b3).map_prod _ _\n\n-- See also `finset.prod_apply`, with the same conclusion\n-- but with the weaker hypothesis `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3`.\n@[simp, to_additive]\nlemma monoid_hom.finset_prod_apply [mul_one_class \u03b2] [comm_monoid \u03b3] (f : \u03b1 \u2192 \u03b2 \u2192* \u03b3)\n  (s : finset \u03b1) (b : \u03b2) : (\u220f x in s, f x) b = \u220f x in s, f x b :=\n(monoid_hom.eval b).map_prod _ _\n\nvariables {s s\u2081 s\u2082 : finset \u03b1} {a : \u03b1} {f g : \u03b1 \u2192 \u03b2}\n\nnamespace finset\n\nsection comm_monoid\nvariables [comm_monoid \u03b2]\n\n@[simp, to_additive]\nlemma prod_empty {f : \u03b1 \u2192 \u03b2} : (\u220f x in (\u2205:finset \u03b1), f x) = 1 := rfl\n\n@[simp, to_additive]\nlemma prod_cons (h : a \u2209 s) : (\u220f x in (cons a s h), f x) = f a * \u220f x in s, f x :=\nfold_cons h\n\n@[simp, to_additive]\nlemma prod_insert [decidable_eq \u03b1] : a \u2209 s \u2192 (\u220f x in (insert a s), f x) = f a * \u220f 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 \u03b1] (h : a \u2209 s \u2192 f a = 1) :\n  \u220f x in insert a s, f x = \u220f x in s, f x :=\nbegin\n  by_cases hm : a \u2208 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 \u03b1] (h : f a = 1) :\n  \u220f x in insert a s, f x = \u220f x in s, f x :=\nprod_insert_of_eq_one_if_not_mem (\u03bb _, h)\n\n@[simp, to_additive]\nlemma prod_singleton : (\u220f x in (singleton a), f x) = f a :=\neq.trans fold_singleton $ mul_one _\n\n@[to_additive]\nlemma prod_pair [decidable_eq \u03b1] {a b : \u03b1} (h : a \u2260 b) :\n  (\u220f x in ({a, b} : finset \u03b1), 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 : (\u220f x in s, (1 : \u03b2)) = 1 :=\nby simp only [finset.prod, multiset.map_const, multiset.prod_repeat, one_pow]\n\n@[simp, to_additive]\nlemma prod_image [decidable_eq \u03b1] {s : finset \u03b3} {g : \u03b3 \u2192 \u03b1} :\n  (\u2200 x \u2208 s, \u2200 y \u2208 s, g x = g y \u2192 x = y) \u2192 (\u220f x in (s.image g), f x) = \u220f x in s, f (g x) :=\nfold_image\n\n@[simp, to_additive]\nlemma prod_map (s : finset \u03b1) (e : \u03b1 \u21aa \u03b3) (f : \u03b3 \u2192 \u03b2) :\n  (\u220f x in (s.map e), f x) = \u220f 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\u2081 = s\u2082) : (\u2200 x \u2208 s\u2082, f x = g x) \u2192 s\u2081.prod f = s\u2082.prod g :=\nby rw [h]; exact fold_congr\nattribute [congr] finset.sum_congr\n\n@[to_additive]\nlemma prod_union_inter [decidable_eq \u03b1] :\n  (\u220f x in (s\u2081 \u222a s\u2082), f x) * (\u220f x in (s\u2081 \u2229 s\u2082), f x) = (\u220f x in s\u2081, f x) * (\u220f x in s\u2082, f x) :=\nfold_union_inter\n\n@[to_additive]\nlemma prod_union [decidable_eq \u03b1] (h : disjoint s\u2081 s\u2082) :\n  (\u220f x in (s\u2081 \u222a s\u2082), f x) = (\u220f x in s\u2081, f x) * (\u220f x in s\u2082, f x) :=\nby rw [\u2190prod_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 \u03b1) (p : \u03b1 \u2192 Prop) [decidable_pred p]\n  [decidable_pred (\u03bb x, \u00acp x)] (f : \u03b1 \u2192 \u03b2) :\n  (\u220f x in s.filter p, f x) * (\u220f x in s.filter (\u03bb x, \u00acp x), f x) = \u220f x in s, f x :=\nbegin\n  haveI := classical.dec_eq \u03b1,\n  rw [\u2190 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 \u03b1) (f : \u03b1 \u2192 \u03b2) : (s.to_list.map f).prod = s.prod f :=\nby rw [finset.prod, \u2190 multiset.coe_prod, \u2190 multiset.coe_map, finset.coe_to_list]\n\nend to_list\n\n@[to_additive]\nlemma _root_.equiv.perm.prod_comp (\u03c3 : equiv.perm \u03b1) (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2)\n  (hs : {a | \u03c3 a \u2260 a} \u2286 s) :\n  (\u220f x in s, f (\u03c3 x)) = \u220f x in s, f x :=\nby { convert (prod_map _ \u03c3.to_embedding _).symm, exact (map_perm hs).symm }\n\n@[to_additive]\nlemma _root_.equiv.perm.prod_comp' (\u03c3 : equiv.perm \u03b1) (s : finset \u03b1) (f : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n  (hs : {a | \u03c3 a \u2260 a} \u2286 s) :\n  (\u220f x in s, f (\u03c3 x) x) = \u220f x in s, f x (\u03c3.symm x) :=\nby { convert \u03c3.prod_comp s (\u03bb x, f x (\u03c3.symm x)) hs, ext, rw equiv.symm_apply_apply }\n\nend comm_monoid\n\nend finset\n\nsection\nopen finset\nvariables [fintype \u03b1] [decidable_eq \u03b1] [comm_monoid \u03b2]\n\n@[to_additive]\nlemma is_compl.prod_mul_prod {s t : finset \u03b1} (h : is_compl s t) (f : \u03b1 \u2192 \u03b2) :\n  (\u220f i in s, f i) * (\u220f i in t, f i) = \u220f i, f i :=\n(finset.prod_union h.disjoint).symm.trans $ by rw [\u2190 finset.sup_eq_union, h.sup_eq_top]; refl\n\nend\n\nnamespace finset\n\nsection comm_monoid\nvariables [comm_monoid \u03b2]\n\n/-- Multiplying the products of a function over `s` and over `s\u1d9c` 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\u1d9c` gives the whole sum.\nFor a version expressed with subtypes, see `fintype.sum_subtype_add_sum_subtype`. \"]\nlemma prod_mul_prod_compl [fintype \u03b1] [decidable_eq \u03b1] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  (\u220f i in s, f i) * (\u220f i in s\u1d9c, f i) = \u220f i, f i :=\nis_compl.prod_mul_prod is_compl_compl f\n\n@[to_additive]\nlemma prod_compl_mul_prod [fintype \u03b1] [decidable_eq \u03b1] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  (\u220f i in s\u1d9c, f i) * (\u220f i in s, f i) = \u220f i, f i :=\n(@is_compl_compl _ s _).symm.prod_mul_prod f\n\n@[to_additive]\nlemma prod_sdiff [decidable_eq \u03b1] (h : s\u2081 \u2286 s\u2082) :\n  (\u220f x in (s\u2082 \\ s\u2081), f x) * (\u220f x in s\u2081, f x) = (\u220f x in s\u2082, f x) :=\nby rw [\u2190prod_union sdiff_disjoint, sdiff_union_of_subset h]\n\n@[simp, to_additive]\nlemma prod_sum_elim [decidable_eq (\u03b1 \u2295 \u03b3)]\n  (s : finset \u03b1) (t : finset \u03b3) (f : \u03b1 \u2192 \u03b2) (g : \u03b3 \u2192 \u03b2) :\n  \u220f x in s.map function.embedding.inl \u222a t.map function.embedding.inr, sum.elim f g x =\n    (\u220f x in s, f x) * (\u220f 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 _ \u27e8i, hi, rfl\u27e9 \u27e8j, hj, H\u27e9,\n    cases H }\nend\n\n@[to_additive]\nlemma prod_bUnion [decidable_eq \u03b1] {s : finset \u03b3} {t : \u03b3 \u2192 finset \u03b1}\n  (hs : set.pairwise_disjoint \u2191s t) :\n  (\u220f x in (s.bUnion t), f x) = \u220f x in s, \u220f i in t x, f i :=\nbegin\n  haveI := classical.dec_eq \u03b3,\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 (\u03bb y hy, hs.2 y hy $ \u03bb 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 {\u03c3 : \u03b1 \u2192 Type*}\n  (s : finset \u03b1) (t : \u03a0 a, finset (\u03c3 a)) (f : sigma \u03c3 \u2192 \u03b2) :\n  (\u220f x in s.sigma t, f x) = \u220f a in s, \u220f s in (t a), f \u27e8a, s\u27e9 :=\nby classical;\ncalc (\u220f x in s.sigma t, f x) =\n       \u220f x in s.bUnion (\u03bb a, (t a).map (function.embedding.sigma_mk a)), f x : by rw sigma_eq_bUnion\n  ... = \u220f a in s, \u220f x in (t a).map (function.embedding.sigma_mk a), f x :\n    prod_bUnion $ assume a\u2081 ha a\u2082 ha\u2082 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 \u27e8\u27e8y, hy, rfl\u27e9, \u27e8z, hz, hz'\u27e9\u27e9, cc }\n  ... = \u220f a in s, \u220f s in t a, f \u27e8a, s\u27e9 :\n    prod_congr rfl $ \u03bb _ _, prod_map _ _ _\n\n@[to_additive]\nlemma prod_sigma' {\u03c3 : \u03b1 \u2192 Type*}\n  (s : finset \u03b1) (t : \u03a0 a, finset (\u03c3 a)) (f : \u03a0 a, \u03c3 a \u2192 \u03b2) :\n  (\u220f a in s, \u220f s in (t a), f a s) = \u220f x in s.sigma t, f x.1 x.2 :=\neq.symm $ prod_sigma s t (\u03bb 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 \u03b1} {t : finset \u03b3} {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b2}\n  (i : \u03a0 a \u2208 s, \u03b3) (hi : \u2200 a ha, i a ha \u2208 t) (h : \u2200 a ha, f a = g (i a ha))\n  (i_inj : \u2200 a\u2081 a\u2082 ha\u2081 ha\u2082, i a\u2081 ha\u2081 = i a\u2082 ha\u2082 \u2192 a\u2081 = a\u2082) (i_surj : \u2200 b \u2208 t, \u2203 a ha, b = i a ha) :\n  (\u220f x in s, f x) = (\u220f 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 \u03b1} {t : finset \u03b3} {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b2}\n  (i : \u03a0 a \u2208 s, \u03b3) (hi : \u2200 a ha, i a ha \u2208 t) (h : \u2200 a ha, f a = g (i a ha))\n  (j : \u03a0 a \u2208 t, \u03b1) (hj : \u2200 a ha, j a ha \u2208 s) (left_inv : \u2200 a ha, j (i a ha) (hi a ha) = a)\n  (right_inv : \u2200 a ha, i (j a ha) (hj a ha) = a) :\n  (\u220f x in s, f x) = (\u220f x in t, g x) :=\nbegin\n  refine prod_bij i hi h _ _,\n  {intros a1 a2 h1 h2 eq, rw [\u2190left_inv a1 h1, \u2190left_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 (\u03b3 \u00d7 \u03b1)) (s : finset \u03b3) (t : \u03b3 \u2192 finset \u03b1)\n  (h : \u2200 p : \u03b3 \u00d7 \u03b1, p \u2208 r \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t p.1) {f : \u03b3 \u00d7 \u03b1 \u2192 \u03b2} :\n  \u220f p in r, f p = \u220f c in s, \u220f a in t c, f (c, a) :=\nbegin\n  refine eq.trans _ (prod_sigma s t (\u03bb p, f (p.1, p.2))),\n  exact prod_bij' (\u03bb p hp, \u27e8p.1, p.2\u27e9) (\u03bb p, mem_sigma.mpr \u2218 (h p).mp)\n    (\u03bb p hp, congr_arg f prod.mk.eta.symm) (\u03bb p hp, (p.1, p.2))\n    (\u03bb p, (h (p.1, p.2)).mpr \u2218 mem_sigma.mp) (\u03bb p hp, prod.mk.eta) (\u03bb p hp, p.eta),\nend\n\n@[to_additive] lemma prod_finset_product'\n  (r : finset (\u03b3 \u00d7 \u03b1)) (s : finset \u03b3) (t : \u03b3 \u2192 finset \u03b1)\n  (h : \u2200 p : \u03b3 \u00d7 \u03b1, p \u2208 r \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t p.1) {f : \u03b3 \u2192 \u03b1 \u2192 \u03b2} :\n  \u220f p in r, f p.1 p.2 = \u220f c in s, \u220f 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 (\u03b1 \u00d7 \u03b3)) (s : finset \u03b3) (t : \u03b3 \u2192 finset \u03b1)\n  (h : \u2200 p : \u03b1 \u00d7 \u03b3, p \u2208 r \u2194 p.2 \u2208 s \u2227 p.1 \u2208 t p.2) {f : \u03b1 \u00d7 \u03b3 \u2192 \u03b2} :\n  \u220f p in r, f p = \u220f c in s, \u220f a in t c, f (a, c) :=\nbegin\n  refine eq.trans _ (prod_sigma s t (\u03bb p, f (p.2, p.1))),\n  exact prod_bij' (\u03bb p hp, \u27e8p.2, p.1\u27e9) (\u03bb p, mem_sigma.mpr \u2218 (h p).mp)\n    (\u03bb p hp, congr_arg f prod.mk.eta.symm) (\u03bb p hp, (p.2, p.1))\n    (\u03bb p, (h (p.2, p.1)).mpr \u2218 mem_sigma.mp) (\u03bb p hp, prod.mk.eta) (\u03bb p hp, p.eta),\nend\n\n@[to_additive] lemma prod_finset_product_right'\n  (r : finset (\u03b1 \u00d7 \u03b3)) (s : finset \u03b3) (t : \u03b3 \u2192 finset \u03b1)\n  (h : \u2200 p : \u03b1 \u00d7 \u03b3, p \u2208 r \u2194 p.2 \u2208 s \u2227 p.1 \u2208 t p.2) {f : \u03b1 \u2192 \u03b3 \u2192 \u03b2} :\n  \u220f p in r, f p.1 p.2 = \u220f c in s, \u220f 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 \u03b3] {s : finset \u03b1} {t : finset \u03b3} {g : \u03b1 \u2192 \u03b3}\n  (h : \u2200 x \u2208 s, g x \u2208 t) (f : \u03b1 \u2192 \u03b2) :\n  (\u220f y in t, \u220f x in s.filter (\u03bb x, g x = y), f x) = \u220f x in s, f x :=\nbegin\n  letI := classical.dec_eq \u03b1,\n  rw [\u2190 bUnion_filter_eq_of_maps_to h] {occs := occurrences.pos [2]},\n  refine (prod_bUnion $ \u03bb 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 \u03b1] {s : finset \u03b3} {g : \u03b3 \u2192 \u03b1} (h : \u03b3 \u2192 \u03b2)\n  (eq : \u2200 c \u2208 s, f (g c) = \u220f x in s.filter (\u03bb c', g c' = g c), h x) :\n  (\u220f x in s.image g, f x) = \u220f x in s, h x :=\ncalc (\u220f x in s.image g, f x) = \u220f x in s.image g, \u220f x in s.filter (\u03bb c', g c' = x), h x :\n  prod_congr rfl $ \u03bb x hx, let \u27e8c, hcs, hc\u27e9 := mem_image.1 hx in hc \u25b8 (eq c hcs)\n... = \u220f x in s, h x : prod_fiberwise_of_maps_to (\u03bb x, mem_image_of_mem g) _\n\n@[to_additive]\nlemma prod_mul_distrib : \u220f x in s, (f x * g x) = (\u220f x in s, f x) * (\u220f x in s, g x) :=\neq.trans (by rw one_mul; refl) fold_op_distrib\n\n@[to_additive]\nlemma prod_comm {s : finset \u03b3} {t : finset \u03b1} {f : \u03b3 \u2192 \u03b1 \u2192 \u03b2} :\n  (\u220f x in s, \u220f y in t, f x y) = (\u220f y in t, \u220f 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 \u03b3} {t : finset \u03b1} {f : \u03b3\u00d7\u03b1 \u2192 \u03b2} :\n  (\u220f x in s.product t, f x) = \u220f x in s, \u220f y in t, f (x, y) :=\nprod_finset_product (s.product t) s (\u03bb a, t) (\u03bb 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 \u03b3} {t : finset \u03b1} {f : \u03b3 \u2192 \u03b1 \u2192 \u03b2} :\n  (\u220f x in s.product t, f x.1 x.2) = \u220f x in s, \u220f y in t, f x y :=\nprod_product\n\n@[to_additive]\nlemma prod_product_right {s : finset \u03b3} {t : finset \u03b1} {f : \u03b3\u00d7\u03b1 \u2192 \u03b2} :\n  (\u220f x in s.product t, f x) = \u220f y in t, \u220f 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 \u03b3} {t : finset \u03b1} {f : \u03b3 \u2192 \u03b1 \u2192 \u03b2} :\n  (\u220f x in s.product t, f x.1 x.2) = \u220f y in t, \u220f x in s, f x y :=\nprod_product_right\n\n@[to_additive]\nlemma prod_hom_rel [comm_monoid \u03b3] {r : \u03b2 \u2192 \u03b3 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} {s : finset \u03b1}\n  (h\u2081 : r 1 1) (h\u2082 : \u2200 a b c, r b c \u2192 r (f a * b) (g a * c)) : r (\u220f x in s, f x) (\u220f x in s, g x) :=\nby { delta finset.prod, apply multiset.prod_hom_rel; assumption }\n\n@[to_additive]\nlemma prod_eq_one {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} (h : \u2200 x \u2208 s, f x = 1) : (\u220f x in s, f x) = 1 :=\ncalc (\u220f x in s, f x) = \u220f 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 \u03b1] (h : s\u2081 \u2286 s\u2082) (hg : \u2200 x \u2208 (s\u2082 \\ s\u2081), g x = 1)\n  (hfg : \u2200 x \u2208 s\u2081, f x = g x) : \u220f i in s\u2081, f i = \u220f i in s\u2082, g i :=\nbegin\n  rw [\u2190 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\u2081 \u2286 s\u2082) (hf : \u2200 x \u2208 s\u2082, x \u2209 s\u2081 \u2192 f x = 1) :\n  (\u220f x in s\u2081, f x) = \u220f x in s\u2082, f x :=\nby haveI := classical.dec_eq \u03b1; exact prod_subset_one_on_sdiff h (by simpa) (\u03bb _ _, rfl)\n\n@[to_additive]\nlemma prod_filter_of_ne {p : \u03b1 \u2192 Prop} [decidable_pred p] (hp : \u2200 x \u2208 s, f x \u2260 1 \u2192 p x) :\n  (\u220f x in (s.filter p), f x) = (\u220f x in s, f x) :=\nprod_subset (filter_subset _ _) $ \u03bb x,\n  by { classical, rw [not_imp_comm, mem_filter], exact \u03bb h\u2081 h\u2082, \u27e8h\u2081, hp _ h\u2081 h\u2082\u27e9 }\n\n-- If we use `[decidable_eq \u03b2]` here, some rewrites fail because they find a wrong `decidable`\n-- instance first; `{\u2200 x, decidable (f x \u2260 1)}` doesn't work with `rw \u2190 prod_filter_ne_one`\n@[to_additive]\nlemma prod_filter_ne_one [\u2200 x, decidable (f x \u2260 1)] :\n  (\u220f x in (s.filter $ \u03bb x, f x \u2260 1), f x) = (\u220f x in s, f x) :=\nprod_filter_of_ne $ \u03bb _ _, id\n\n@[to_additive]\nlemma prod_filter (p : \u03b1 \u2192 Prop) [decidable_pred p] (f : \u03b1 \u2192 \u03b2) :\n  (\u220f a in s.filter p, f a) = (\u220f a in s, if p a then f a else 1) :=\ncalc (\u220f a in s.filter p, f a) = \u220f 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  ... = \u220f 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 \u03b1} {f : \u03b1 \u2192 \u03b2} (a : \u03b1) (h : a \u2208 s)\n  (h\u2080 : \u2200 b \u2208 s, b \u2260 a \u2192 f b = 1) : (\u220f x in s, f x) = f a :=\nbegin\n  haveI := classical.dec_eq \u03b1,\n  calc (\u220f x in s, f x) = \u220f 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 \u03b1} {f : \u03b1 \u2192 \u03b2} (a : \u03b1)\n  (h\u2080 : \u2200 b \u2208 s, b \u2260 a \u2192 f b = 1) (h\u2081 : a \u2209 s \u2192 f a = 1) : (\u220f x in s, f x) = f a :=\nby haveI := classical.dec_eq \u03b1;\nfrom classical.by_cases\n  (assume : a \u2208 s, prod_eq_single_of_mem a this h\u2080)\n  (assume : a \u2209 s,\n    (prod_congr rfl $ \u03bb b hb, h\u2080 b hb $ by rintro rfl; cc).trans $\n      prod_const_one.trans (h\u2081 this).symm)\n\n@[to_additive]\n\n\n@[to_additive]\nlemma prod_eq_mul {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} (a b : \u03b1) (hn : a \u2260 b)\n  (h\u2080 : \u2200 c \u2208 s, c \u2260 a \u2227 c \u2260 b \u2192 f c = 1) (ha : a \u2209 s \u2192 f a = 1) (hb : b \u2209 s \u2192 f b = 1) :\n  (\u220f x in s, f x) = (f a) * (f b) :=\nbegin\n  haveI := classical.dec_eq \u03b1;\n  by_cases h\u2081 : a \u2208 s; by_cases h\u2082 : b \u2208 s,\n  { exact prod_eq_mul_of_mem a b h\u2081 h\u2082 hn h\u2080 },\n  { rw [hb h\u2082, mul_one],\n    apply prod_eq_single_of_mem a h\u2081,\n    exact \u03bb c hc hca, h\u2080 c hc \u27e8hca, ne_of_mem_of_not_mem hc h\u2082\u27e9 },\n  { rw [ha h\u2081, one_mul],\n    apply prod_eq_single_of_mem b h\u2082,\n    exact \u03bb c hc hcb, h\u2080 c hc \u27e8ne_of_mem_of_not_mem hc h\u2081, hcb\u27e9 },\n  { rw [ha h\u2081, hb h\u2082, mul_one],\n    exact trans\n      (prod_congr rfl (\u03bb c hc, h\u2080 c hc \u27e8ne_of_mem_of_not_mem hc h\u2081, ne_of_mem_of_not_mem hc h\u2082\u27e9))\n      prod_const_one }\nend\n\n@[to_additive]\nlemma prod_attach {f : \u03b1 \u2192 \u03b2} : (\u220f x in s.attach, f x) = (\u220f x in s, f x) :=\nby haveI := classical.dec_eq \u03b1; exact\n  calc (\u220f x in s.attach, f x.val) = (\u220f 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 : \u03b1 \u2192 \u03b2) {p : \u03b1 \u2192 Prop} [decidable_pred p] :\n  \u220f x in s.subtype p, f x = \u220f x in s.filter p, f x :=\nbegin\n  conv_lhs { erw \u2190prod_map (s.subtype p) (function.embedding.subtype _) f },\n  exact prod_congr (subtype_map _) (\u03bb 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 : \u03b1 \u2192 \u03b2) {p : \u03b1 \u2192 Prop} [decidable_pred p]\n    (h : \u2200 x \u2208 s, p x) : \u220f x in s.subtype p, f x = \u220f 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 : \u03b1 \u2192 Prop} {s : finset {x // p x}} {f : {x // p x} \u2192 \u03b2}\n    {g : \u03b1 \u2192 \u03b2} (h : \u2200 x : {x // p x}, x \u2208 s \u2192 g x = f x) :\n  \u220f x in s.map (function.embedding.subtype _), g x = \u220f 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 : \u03b1 \u2192 \u03b2) (s : finset \u03b1) :\n  \u220f (i : (s : set \u03b1)), f i = \u220f i in s, f i :=\nprod_attach\n\n@[to_additive]\nlemma prod_subtype {p : \u03b1 \u2192 Prop} {F : fintype (subtype p)} (s : finset \u03b1)\n  (h : \u2200 x, x \u2208 s \u2194 p x) (f : \u03b1 \u2192 \u03b2) :\n  \u220f a in s, f a = \u220f a : subtype p, f a :=\nhave (\u2208 s) = p, from set.ext h, by { substI p, rw [\u2190prod_finset_coe], congr }\n\n@[to_additive] lemma prod_apply_dite {s : finset \u03b1} {p : \u03b1 \u2192 Prop} {hp : decidable_pred p}\n  [decidable_pred (\u03bb x, \u00ac p x)] (f : \u03a0 (x : \u03b1), p x \u2192 \u03b3) (g : \u03a0 (x : \u03b1), \u00acp x \u2192 \u03b3)\n  (h : \u03b3 \u2192 \u03b2) :\n  (\u220f x in s, h (if hx : p x then f x hx else g x hx)) =\n  (\u220f x in (s.filter p).attach, h (f x.1 (mem_filter.mp x.2).2)) *\n    (\u220f x in (s.filter (\u03bb x, \u00ac p x)).attach, h (g x.1 (mem_filter.mp x.2).2)) :=\ncalc \u220f x in s, h (if hx : p x then f x hx else g x hx)\n    = (\u220f x in s.filter p, h (if hx : p x then f x hx else g x hx)) *\n    (\u220f x in s.filter (\u03bb x, \u00ac 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... = (\u220f x in (s.filter p).attach, h (if hx : p x.1 then f x.1 hx else g x.1 hx)) *\n    (\u220f x in (s.filter (\u03bb x, \u00ac 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... = (\u220f x in (s.filter p).attach, h (f x.1 (mem_filter.mp x.2).2)) *\n    (\u220f x in (s.filter (\u03bb x, \u00ac p x)).attach, h (g x.1 (mem_filter.mp x.2).2)) :\n  congr_arg2 _\n    (prod_congr rfl (\u03bb x hx, congr_arg h (dif_pos (mem_filter.mp x.2).2)))\n    (prod_congr rfl (\u03bb x hx, congr_arg h (dif_neg (mem_filter.mp x.2).2)))\n\n@[to_additive] lemma prod_apply_ite {s : finset \u03b1}\n  {p : \u03b1 \u2192 Prop} {hp : decidable_pred p} (f g : \u03b1 \u2192 \u03b3) (h : \u03b3 \u2192 \u03b2) :\n  (\u220f x in s, h (if p x then f x else g x)) =\n  (\u220f x in s.filter p, h (f x)) * (\u220f x in s.filter (\u03bb x, \u00ac p x), h (g x)) :=\ntrans (prod_apply_dite _ _ _)\n  (congr_arg2 _ (@prod_attach _ _ _ _ (h \u2218 f)) (@prod_attach _ _ _ _ (h \u2218 g)))\n\n@[to_additive] lemma prod_dite {s : finset \u03b1} {p : \u03b1 \u2192 Prop} {hp : decidable_pred p}\n  (f : \u03a0 (x : \u03b1), p x \u2192 \u03b2) (g : \u03a0 (x : \u03b1), \u00acp x \u2192 \u03b2) :\n  (\u220f x in s, if hx : p x then f x hx else g x hx) =\n  (\u220f x in (s.filter p).attach, f x.1 (mem_filter.mp x.2).2) *\n    (\u220f x in (s.filter (\u03bb x, \u00ac p x)).attach, g x.1 (mem_filter.mp x.2).2) :=\nby simp [prod_apply_dite _ _ (\u03bb x, x)]\n\n@[to_additive] lemma prod_ite {s : finset \u03b1}\n  {p : \u03b1 \u2192 Prop} {hp : decidable_pred p} (f g : \u03b1 \u2192 \u03b2) :\n  (\u220f x in s, if p x then f x else g x) =\n  (\u220f x in s.filter p, f x) * (\u220f x in s.filter (\u03bb x, \u00ac p x), g x) :=\nby simp [prod_apply_ite _ _ (\u03bb x, x)]\n\n@[to_additive] lemma prod_ite_of_false {p : \u03b1 \u2192 Prop} {hp : decidable_pred p} (f g : \u03b1 \u2192 \u03b2)\n  (h : \u2200 x \u2208 s, \u00acp x) : (\u220f x in s, if p x then f x else g x) = (\u220f 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 : \u03b1 \u2192 Prop} {hp : decidable_pred p} (f g : \u03b1 \u2192 \u03b2)\n  (h : \u2200 x \u2208 s, p x) : (\u220f x in s, if p x then f x else g x) = (\u220f x in s, f x) :=\nby { simp_rw \u2190(ite_not (p _)), apply prod_ite_of_false, simpa }\n\n@[to_additive] lemma prod_apply_ite_of_false {p : \u03b1 \u2192 Prop} {hp : decidable_pred p} (f g : \u03b1 \u2192 \u03b3)\n  (k : \u03b3 \u2192 \u03b2) (h : \u2200 x \u2208 s, \u00acp x) :\n  (\u220f x in s, k (if p x then f x else g x)) = (\u220f 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 : \u03b1 \u2192 Prop} {hp : decidable_pred p} (f g : \u03b1 \u2192 \u03b3)\n  (k : \u03b3 \u2192 \u03b2) (h : \u2200 x \u2208 s, p x) :\n  (\u220f x in s, k (if p x then f x else g x)) = (\u220f 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 \u03b1] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  \u220f i in s, (if i \u2208 s then f i else 1) = \u220f i in s, f i :=\nprod_congr rfl $ \u03bb i hi, if_pos hi\n\n@[simp, to_additive]\nlemma prod_dite_eq [decidable_eq \u03b1] (s : finset \u03b1) (a : \u03b1) (b : \u03a0 x : \u03b1, a = x \u2192 \u03b2) :\n  (\u220f x in s, (if h : a = x then b x h else 1)) = ite (a \u2208 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 \u03b1] (s : finset \u03b1) (a : \u03b1) (b : \u03a0 x : \u03b1, x = a \u2192 \u03b2) :\n  (\u220f x in s, (if h : x = a then b x h else 1)) = ite (a \u2208 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 \u03b1] (s : finset \u03b1) (a : \u03b1) (b : \u03b1 \u2192 \u03b2) :\n  (\u220f x in s, (ite (a = x) (b x) 1)) = ite (a \u2208 s) (b a) 1 :=\nprod_dite_eq s a (\u03bb 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 \u03b1] (s : finset \u03b1) (a : \u03b1) (b : \u03b1 \u2192 \u03b2) :\n  (\u220f x in s, (ite (x = a) (b x) 1)) = ite (a \u2208 s) (b a) 1 :=\nprod_dite_eq' s a (\u03bb x _, b x)\n\n@[to_additive]\nlemma prod_ite_index (p : Prop) [decidable p] (s t : finset \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  (\u220f x in if p then s else t, f x) = if p then \u220f x in s, f x else \u220f x in t, f x :=\napply_ite (\u03bb s, \u220f x in s, f x) _ _ _\n\n@[simp, to_additive]\nlemma prod_dite_irrel (p : Prop) [decidable p] (s : finset \u03b1) (f : p \u2192 \u03b1 \u2192 \u03b2) (g : \u00acp \u2192 \u03b1 \u2192 \u03b2):\n  (\u220f x in s, if h : p then f h x else g h x) = if h : p then \u220f x in s, f h x else \u220f x in s, g h x :=\nby { split_ifs with h; refl }\n\n@[simp] lemma sum_pi_single' {\u03b9 M : Type*} [decidable_eq \u03b9] [add_comm_monoid M]\n  (i : \u03b9) (x : M) (s : finset \u03b9) :\n  \u2211 j in s, pi.single i x j = if i \u2208 s then x else 0 :=\nsum_dite_eq' _ _ _\n\n@[simp] lemma sum_pi_single {\u03b9 : Type*} {M : \u03b9 \u2192 Type*}\n  [decidable_eq \u03b9] [\u03a0 i, add_comm_monoid (M i)] (i : \u03b9) (f : \u03a0 i, M i) (s : finset \u03b9) :\n  \u2211 j in s, pi.single j (f j) i = if i \u2208 s then f i else 0 :=\nsum_dite_eq _ _ _\n\n@[to_additive]\nlemma prod_bij_ne_one {s : finset \u03b1} {t : finset \u03b3} {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b2}\n  (i : \u03a0 a \u2208 s, f a \u2260 1 \u2192 \u03b3) (hi : \u2200 a h\u2081 h\u2082, i a h\u2081 h\u2082 \u2208 t)\n  (i_inj : \u2200 a\u2081 a\u2082 h\u2081\u2081 h\u2081\u2082 h\u2082\u2081 h\u2082\u2082, i a\u2081 h\u2081\u2081 h\u2081\u2082 = i a\u2082 h\u2082\u2081 h\u2082\u2082 \u2192 a\u2081 = a\u2082)\n  (i_surj : \u2200 b \u2208 t, g b \u2260 1 \u2192 \u2203 a h\u2081 h\u2082, b = i a h\u2081 h\u2082)\n  (h : \u2200 a h\u2081 h\u2082, f a = g (i a h\u2081 h\u2082)) :\n  (\u220f x in s, f x) = (\u220f x in t, g x) :=\nby classical; exact\ncalc (\u220f x in s, f x) = \u220f x in (s.filter $ \u03bb x, f x \u2260 1), f x : prod_filter_ne_one.symm\n  ... = \u220f x in (t.filter $ \u03bb x, g x \u2260 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 $ \u03bb h\u2081 h\u2082, mem_filter.mpr\n        \u27e8hi a h\u2081 h\u2082, \u03bb hg, h\u2082 (hg \u25b8 h a h\u2081 h\u2082)\u27e9)\n      (assume a ha, (mem_filter.mp ha).elim $ h a)\n      (assume a\u2081 a\u2082 ha\u2081 ha\u2082,\n        (mem_filter.mp ha\u2081).elim $ \u03bb ha\u2081\u2081 ha\u2081\u2082,\n          (mem_filter.mp ha\u2082).elim $ \u03bb ha\u2082\u2081 ha\u2082\u2082, i_inj a\u2081 a\u2082 _ _ _ _)\n      (assume b hb, (mem_filter.mp hb).elim $ \u03bb h\u2081 h\u2082,\n        let \u27e8a, ha\u2081, ha\u2082, eq\u27e9 := i_surj b h\u2081 h\u2082 in \u27e8a, mem_filter.mpr \u27e8ha\u2081, ha\u2082\u27e9, eq\u27e9)\n  ... = (\u220f x in t, g x) : prod_filter_ne_one\n\n@[to_additive] lemma prod_dite_of_false {p : \u03b1 \u2192 Prop} {hp : decidable_pred p}\n  (h : \u2200 x \u2208 s, \u00ac p x) (f : \u03a0 (x : \u03b1), p x \u2192 \u03b2) (g : \u03a0 (x : \u03b1), \u00acp x \u2192 \u03b2) :\n  (\u220f x in s, if hx : p x then f x hx else g x hx) =\n  \u220f (x : s), g x.val (h x.val x.property) :=\nprod_bij (\u03bb x hx, \u27e8x,hx\u27e9) (\u03bb x hx, by simp) (\u03bb a ha, by { dsimp, rw dif_neg })\n  (\u03bb a\u2081 a\u2082 h\u2081 h\u2082 hh, congr_arg coe hh) (\u03bb b hb, \u27e8b.1, b.2, by simp\u27e9)\n\n@[to_additive] lemma prod_dite_of_true {p : \u03b1 \u2192 Prop} {hp : decidable_pred p}\n  (h : \u2200 x \u2208 s, p x) (f : \u03a0 (x : \u03b1), p x \u2192 \u03b2) (g : \u03a0 (x : \u03b1), \u00acp x \u2192 \u03b2) :\n  (\u220f x in s, if hx : p x then f x hx else g x hx) =\n  \u220f (x : s), f x.val (h x.val x.property) :=\nprod_bij (\u03bb x hx, \u27e8x,hx\u27e9) (\u03bb x hx, by simp) (\u03bb a ha, by { dsimp, rw dif_pos })\n  (\u03bb a\u2081 a\u2082 h\u2081 h\u2082 hh, congr_arg coe hh) (\u03bb b hb, \u27e8b.1, b.2, by simp\u27e9)\n\n@[to_additive]\nlemma nonempty_of_prod_ne_one (h : (\u220f x in s, f x) \u2260 1) : s.nonempty :=\ns.eq_empty_or_nonempty.elim (\u03bb H, false.elim $ h $ H.symm \u25b8 prod_empty) id\n\n@[to_additive]\nlemma exists_ne_one_of_prod_ne_one (h : (\u220f x in s, f x) \u2260 1) : \u2203 a \u2208 s, f a \u2260 1 :=\nbegin\n  classical,\n  rw \u2190 prod_filter_ne_one at h,\n  rcases nonempty_of_prod_ne_one h with \u27e8x, hx\u27e9,\n  exact \u27e8x, (mem_filter.1 hx).1, (mem_filter.1 hx).2\u27e9\nend\n\n@[to_additive]\nlemma prod_range_succ_comm (f : \u2115 \u2192 \u03b2) (n : \u2115) :\n  \u220f x in range (n + 1), f x = f n * \u220f 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 : \u2115 \u2192 \u03b2) (n : \u2115) :\n  \u220f x in range (n + 1), f x = (\u220f 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 : \u2115 \u2192 \u03b2) :\n  \u2200 n : \u2115, (\u220f k in range (n + 1), f k) = (\u220f 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, \u2190 prod_range_succ', prod_range_succ]\n\n@[to_additive]\nlemma eventually_constant_prod {u : \u2115 \u2192 \u03b2} {N : \u2115} (hu : \u2200 n \u2265 N, u n = 1) {n : \u2115} (hn : N \u2264 n) :\n  \u220f k in range (n + 1), u k = \u220f k in range (N + 1), u k :=\nbegin\n  obtain \u27e8m, rfl : n = N + m\u27e9 := 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 : \u2115 \u2192 \u03b2) (n m : \u2115) :\n  \u220f x in range (n + m), f x =\n  (\u220f x in range n, f x) * (\u220f 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 {\u03b1 : Type*} [comm_group \u03b1] (f : \u2115 \u2192 \u03b1) (n m : \u2115) :\n  (\u220f k in range (n + m), f k) / (\u220f k in range n, f k) = \u220f 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 : \u2115 \u2192 \u03b2) :\n  \u220f 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 : \u2115 \u2192 \u03b2) :\n  \u220f k in range 1, f k = f 0 :=\nby { rw [range_one], apply @prod_singleton \u03b2 \u2115 0 f }\n\nopen multiset\n\n@[to_additive] lemma prod_multiset_map_count [decidable_eq \u03b1] (s : multiset \u03b1)\n  {M : Type*} [comm_monoid M] (f : \u03b1 \u2192 M) :\n  (s.map f).prod = \u220f 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 \u2208 s.to_finset,\n  { rw [insert_eq_of_mem has, \u2190 insert_erase has, prod_insert (not_mem_erase _ _),\n        prod_insert (not_mem_erase _ _), \u2190 mul_assoc, count_cons_self, pow_succ],\n    congr' 1, refine prod_congr rfl (\u03bb 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 (\u03bb 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 \u03b1] [comm_monoid \u03b1] (s : multiset \u03b1) :\n  s.prod = \u220f 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 \u03b1] [comm_monoid \u03b1]\n  (m : multiset \u03b1) (s : finset \u03b1) (hs : m.to_finset \u2286 s) :\n  m.prod = \u220f 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 \u03b1]\n  (m : multiset \u03b1) (f : {x // x \u2208 m} \u2192 \u03b2) (g : \u03b1 \u2192 \u03b2)\n  (hfg : \u2200 x, f x = g x) :\n  \u220f (x : {x // x \u2208 m}), f x = \u220f x in m.to_finset, g x :=\nprod_bij (\u03bb x _, x.1) (\u03bb x _, multiset.mem_to_finset.mpr x.2)\n  (\u03bb _ _, hfg _)\n  (\u03bb _ _ _ _ h, by { ext, assumption })\n  (\u03bb y hy, \u27e8\u27e8y, multiset.mem_to_finset.mp hy\u27e9, finset.mem_univ _, rfl\u27e9)\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 : \u03b1 \u2192 M) (p : M \u2192 Prop)\n  (p_mul : \u2200 a b, p a \u2192 p b \u2192 p (a * b)) (p_one : p 1) (p_s : \u2200 x \u2208 s, p $ f x) :\n  p $ \u220f 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 : \u03b1 \u2192 M) (p : M \u2192 Prop)\n  (p_mul : \u2200 a b, p a \u2192 p b \u2192 p (a * b)) (hs_nonempty : s.nonempty) (p_s : \u2200 x \u2208 s, p $ f x) :\n  p $ \u220f 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 : \u2115 \u2192 M) (h0 : s 0 = 1) (h : \u2200 n, s (n + 1) = s n * f n) (n : \u2115) :\n  \u220f 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 : \u2115 \u2192 M) (h0 : s 0 = 0) (h : \u2200 n, s (n + 1) = s n + f n) (n : \u2115) :\n  \u2211 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 : \u2115 \u2192 G) (n : \u2115) :\n  \u2211 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 : \u2115 \u2192 G) (n : \u2115) :\n  \u2211 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 : \u2115 \u2192 M) (n : \u2115) :\n  \u220f i in range n, (f (i+1) * (f i)\u207b\u00b9) = f n * (f 0)\u207b\u00b9 :=\nby simpa only [\u2190 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 : \u2115 \u2192 M) (n : \u2115) :\n  \u220f i in range n, (f i * (f (i+1))\u207b\u00b9) = f 0 * (f n)\u207b\u00b9 :=\nby simpa only [\u2190 div_eq_mul_inv] using @sum_range_sub' (additive M) _ f n\n\n/--\nA telescoping sum along `{0, ..., n-1}` of an `\u2115`-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 : \u2115 \u2192 \u2115} (h : monotone f) (n : \u2115) :\n  \u2211 i in range n, (f (i+1) - f i) = f n - f 0 :=\nbegin\n  refine sum_range_induction _ _ (tsub_self _) (\u03bb n, _) _,\n  have h\u2081 : f n \u2264 f (n+1) := h (nat.le_succ _),\n  have h\u2082 : f 0 \u2264 f n := h (nat.zero_le _),\n  rw [tsub_add_eq_add_tsub h\u2082, add_tsub_cancel_of_le h\u2081],\nend\n\n@[simp, to_additive] lemma prod_const (b : \u03b2) : (\u220f x in s, b) = b ^ s.card :=\nby haveI := classical.dec_eq \u03b1; exact\nfinset.induction_on s (by simp) (\u03bb 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 : \u03b2) : \u2200 n, b ^ n = \u220f k in range n, b := by simp\n\n@[to_additive]\nlemma prod_pow (s : finset \u03b1) (n : \u2115) (f : \u03b1 \u2192 \u03b2) :\n  \u220f x in s, f x ^ n = (\u220f x in s, f x) ^ n :=\nby haveI := classical.dec_eq \u03b1; exact\nfinset.induction_on s (by simp) (by simp [mul_pow] {contextual := tt})\n\n@[to_additive]\nlemma prod_flip {n : \u2115} (f : \u2115 \u2192 \u03b2) :\n  \u220f r in range (n + 1), f (n - r) = \u220f 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 [\u2190 ih] }\nend\n\n@[to_additive]\nlemma prod_involution {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} :\n  \u2200 (g : \u03a0 a \u2208 s, \u03b1)\n  (h : \u2200 a ha, f a * f (g a ha) = 1)\n  (g_ne : \u2200 a ha, f a \u2260 1 \u2192 g a ha \u2260 a)\n  (g_mem : \u2200 a ha, g a ha \u2208 s)\n  (g_inv : \u2200 a ha, g (g a ha) (g_mem a ha) = a),\n  (\u220f x in s, f x) = 1 :=\nby haveI := classical.dec_eq \u03b1;\nhaveI := classical.dec_eq \u03b2; exact\nfinset.strong_induction_on s\n  (\u03bb s ih g h g_ne g_mem g_inv,\n    s.eq_empty_or_nonempty.elim (\u03bb hs, hs.symm \u25b8 rfl)\n      (\u03bb \u27e8x, hx\u27e9,\n      have hmem : \u2200 y \u2208 (s.erase x).erase (g x hx), y \u2208 s,\n        from \u03bb y hy, (mem_of_mem_erase (mem_of_mem_erase hy)),\n      have g_inj : \u2200 {x hx y hy}, g x hx = g y hy \u2192 x = y,\n        from \u03bb x hx y hy h, by rw [\u2190 g_inv x hx, \u2190 g_inv y hy]; simp [h],\n      have ih': \u220f y in erase (erase s x) (g x hx), f y = (1 : \u03b2) :=\n        ih ((s.erase x).erase (g x hx))\n          \u27e8subset.trans (erase_subset _ _) (erase_subset _ _),\n            \u03bb h, not_mem_erase (g x hx) (s.erase x) (h (g_mem x hx))\u27e9\n          (\u03bb y hy, g y (hmem y hy))\n          (\u03bb y hy, h y (hmem y hy))\n          (\u03bb y hy, g_ne y (hmem y hy))\n          (\u03bb y hy, mem_erase.2 \u27e8\u03bb (h : g y _ = g x hx), by simpa [g_inj h] using hy,\n            mem_erase.2 \u27e8\u03bb (h : g y _ = x),\n              have y = g x hx, from g_inv y (hmem y hy) \u25b8 by simp [h],\n              by simpa [this] using hy, g_mem y (hmem y hy)\u27e9\u27e9)\n          (\u03bb y hy, g_inv y (hmem y hy)),\n      if hx1 : f x = 1\n      then ih' \u25b8 eq.symm (prod_subset hmem\n        (\u03bb y hy hy\u2081,\n          have y = x \u2228 y = g x hx, by simp [hy] at hy\u2081; tauto,\n          this.elim (\u03bb hy, hy.symm \u25b8 hx1)\n            (\u03bb hy, h x hx \u25b8 hy \u25b8 hx1.symm \u25b8 (one_mul _).symm)))\n      else by rw [\u2190 insert_erase hx, prod_insert (not_mem_erase _ _),\n        \u2190 insert_erase (mem_erase.2 \u27e8g_ne x hx hx1, g_mem x hx\u27e9),\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 \u2208 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 \u2208 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 \u03b3] (f : \u03b3 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) :\n  \u220f a in s, f (g a) = \u220f b in s.image g, f b ^ (s.filter (\u03bb a, g a = b)).card  :=\ncalc \u220f a in s, f (g a)\n    = \u220f x in (s.image g).sigma (\u03bb b : \u03b3, s.filter (\u03bb a, g a = b)), f (g x.2) :\n  prod_bij (\u03bb a ha, \u27e8g a, a\u27e9) (by simp; tauto) (\u03bb _ _, rfl) (by simp) -- `(by finish)` closes this\n  (by { rintro \u27e8b_fst, b_snd\u27e9 H,\n        simp only [mem_image, exists_prop, mem_filter, mem_sigma] at H,\n        tauto })\n... = \u220f b in s.image g, \u220f a in s.filter (\u03bb a, g a = b), f (g a) : prod_sigma _ _ _\n... = \u220f b in s.image g, \u220f a in s.filter (\u03bb a, g a = b), f b :\n  prod_congr rfl (\u03bb b hb, prod_congr rfl (by simp {contextual := tt}))\n... = \u220f b in s.image g, f b ^ (s.filter (\u03bb a, g a = b)).card :\n  prod_congr rfl (\u03bb _ _, prod_const _)\n\n@[to_additive]\nlemma prod_piecewise [decidable_eq \u03b1] (s t : finset \u03b1) (f g : \u03b1 \u2192 \u03b2) :\n  (\u220f x in s, (t.piecewise f g) x) = (\u220f x in s \u2229 t, f x) * (\u220f x in s \\ t, g x) :=\nby { rw [piecewise, prod_ite, filter_mem_eq_inter, \u2190 sdiff_eq_filter], }\n\n@[to_additive]\nlemma prod_inter_mul_prod_diff [decidable_eq \u03b1] (s t : finset \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  (\u220f x in s \u2229 t, f x) * (\u220f x in s \\ t, f x) = (\u220f 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 \u03b1] {s : finset \u03b1} {i : \u03b1} (h : i \u2208 s)\n  (f : \u03b1 \u2192 \u03b2) : \u220f x in s, f x = f i * \u220f 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 \u03b1] {s : finset \u03b1} {i : \u03b1} (h : i \u2208 s)\n  (f : \u03b1 \u2192 \u03b2) : \u220f x in s, f x = (\u220f 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 \u03b1] [fintype \u03b1] (a : \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  \u220f i, f i = (f a) * \u220f i in {a}\u1d9c, 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 \u03b1] [fintype \u03b1] (a : \u03b1) (f : \u03b1 \u2192 \u03b2) :\n  \u220f i, f i = (\u220f i in {a}\u1d9c, f i) * f a :=\nprod_eq_prod_diff_singleton_mul (mem_univ a) f\n\nlemma dvd_prod_of_mem (f : \u03b1 \u2192 \u03b2) {a : \u03b1} {s : finset \u03b1} (ha : a \u2208 s) :\n  f a \u2223 \u220f 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 \u03b1) [decidable_rel R.r] :\n  (\u220f x in s, f x) = \u220f xbar in s.image quotient.mk, \u220f y in s.filter (\u03bb y, \u27e6y\u27e7 = xbar), f y :=\nbegin\n  refine (finset.prod_image' f (\u03bb 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 \u03b1) [decidable_rel R.r]\n  (h : \u2200 x \u2208 s, (\u220f a in s.filter (\u03bb y, y \u2248 x), f a) = 1) : (\u220f x in s, f x) = 1 :=\nbegin\n  rw [prod_partition R, \u2190finset.prod_eq_one],\n  intros xbar xbar_in_s,\n  obtain \u27e8x, x_in_s, xbar_eq_x\u27e9 := mem_image.mp xbar_in_s,\n  rw [\u2190xbar_eq_x, filter_congr (\u03bb 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 \u03b1] {s : finset \u03b1} {i : \u03b1}\n  (h : i \u2209 s) (f : \u03b1 \u2192 \u03b2) (b : \u03b2) : (\u220f x in s, function.update f i b x) = (\u220f x in s, f x) :=\nbegin\n  apply prod_congr rfl (\u03bb j hj, _),\n  have : j \u2260 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 \u03b1] {s : finset \u03b1} {i : \u03b1} (h : i \u2208 s) (f : \u03b1 \u2192 \u03b2) (b : \u03b2) :\n  (\u220f x in s, function.update f i b x) = b * (\u220f 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 \u03b1} (hc : s.card \u2264 1) {f : \u03b1 \u2192 \u03b2} {b : \u03b2}\n    (h : \u220f x in s, f x = b) : \u2200 x \u2208 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 \u03b1` 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 \u03b1` 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 \u03b1] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) {a : \u03b1} (h : a \u2208 s) :\n  f a * (\u220f x in s.erase a, f x) = \u220f x in s, f x :=\nby rw [\u2190 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 \u03b1] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) {a : \u03b1} (h : a \u2208 s) :\n  (\u220f x in s.erase a, f x) * f a = \u220f 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 \u03b1] (s : finset \u03b1) {f : \u03b1 \u2192 \u03b2} {a : \u03b1} (h : f a = 1) :\n  \u220f x in s.erase a, f x = \u220f x in s, f x :=\nbegin\n  rw \u2190sdiff_singleton_eq_erase,\n  refine prod_subset (sdiff_subset _ _) (\u03bb 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 \u03b1} {f : \u03b1 \u2192 \u03b2} {a : \u03b1} (hp : \u220f x in s, f x = 1)\n    (h1 : \u2200 x \u2208 s, x \u2260 a \u2192 f x = 1) : \u2200 x \u2208 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 [\u2190prod_subset (singleton_subset_iff.2 hx)\n                      (\u03bb 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 \u03b1] (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) :\n  (\u220f x in s, (f x)^(ite (a = x) 1 0)) = ite (a \u2208 s) (f a) 1 :=\nby simp\n\nlemma prod_dvd_prod_of_dvd {S : finset \u03b1} (g1 g2 : \u03b1 \u2192 \u03b2) (h : \u2200 a \u2208 S, g1 a \u2223 g2 a) :\n  S.prod g1 \u2223 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 {\u03b9 M : Type*} [comm_monoid M] (s t : finset \u03b9) (f : \u03b9 \u2192 M)\n  (h : s \u2286 t) : \u220f i in s, f i \u2223 \u220f 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 \u03b2] {s : finset \u03b1} {i : \u03b1} {f g h : \u03b1 \u2192 \u03b2}\n  (hi : i \u2208 s) (h1 : g i + h i = f i) (h2 : \u2200 j \u2208 s, j \u2260 i \u2192 g j = f j)\n  (h3 : \u2200 j \u2208 s, j \u2260 i \u2192 h j = f j) : \u220f i in s, g i + \u220f i in s, h i = \u220f i in s, f i :=\nby { classical, simp_rw [prod_eq_mul_prod_diff_singleton hi, \u2190 h1, right_distrib],\n     congr' 2; apply prod_congr rfl; simpa }\n\nlemma card_eq_sum_ones (s : finset \u03b1) : s.card = \u2211 _ in s, 1 :=\nby simp\n\nlemma sum_const_nat {m : \u2115} {f : \u03b1 \u2192 \u2115} (h\u2081 : \u2200 x \u2208 s, f x = m) :\n  (\u2211 x in s, f x) = card s * m :=\nbegin\n  rw [\u2190 nat.nsmul_eq_mul, \u2190 sum_const],\n  apply sum_congr rfl h\u2081\nend\n\n@[simp]\nlemma sum_boole {s : finset \u03b1} {p : \u03b1 \u2192 Prop} [non_assoc_semiring \u03b2] {hp : decidable_pred p} :\n  (\u2211 x in s, if p x then (1 : \u03b2) else (0 : \u03b2)) = (s.filter p).card :=\nby simp [sum_ite]\n\nlemma eq_sum_range_sub [add_comm_group \u03b2] (f : \u2115 \u2192 \u03b2) (n : \u2115) :\n  f n = f 0 + \u2211 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 \u03b2] (f : \u2115 \u2192 \u03b2) (n : \u2115) :\n  f n = \u2211 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 \u03b2] (s : finset \u03b1)\n  (f : \u03b1 \u2192 \u03b2) (b : \u03b2) (h : \u2200 i \u2208 s, commute b (f i)) :\n  commute b (\u2211 i in s, f i) :=\ncommute.multiset_sum_right _ _ $ \u03bb b hb, begin\n  obtain \u27e8i, hi, rfl\u27e9 := multiset.mem_map.mp hb,\n  exact h _ hi\nend\n\nlemma _root_.commute.sum_left [non_unital_non_assoc_semiring \u03b2] (s : finset \u03b1)\n  (f : \u03b1 \u2192 \u03b2) (b : \u03b2) (h : \u2200 i \u2208 s, commute (f i) b) :\n  commute (\u2211 i in s, f i) b :=\n(commute.sum_right _ _ _ $ \u03bb 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 \u03b2] {s : finset \u03b1} (f : \u03b1 \u2192 \u03b2) :\n  op (\u2211 x in s, f x) = \u2211 x in s, op (f x) :=\n(op_add_equiv : \u03b2 \u2243+ \u03b2\u1d50\u1d52\u1d56).map_sum _ _\n\n@[simp] lemma unop_sum [add_comm_monoid \u03b2] {s : finset \u03b1} (f : \u03b1 \u2192 \u03b2\u1d50\u1d52\u1d56) :\n  unop (\u2211 x in s, f x) = \u2211 x in s, unop (f x) :=\n(op_add_equiv : \u03b2 \u2243+ \u03b2\u1d50\u1d52\u1d56).symm.map_sum _ _\n\nend opposite\n\nsection comm_group\nvariables [comm_group \u03b2]\n\n@[simp, to_additive]\nlemma prod_inv_distrib : (\u220f x in s, (f x)\u207b\u00b9) = (\u220f x in s, f x)\u207b\u00b9 := multiset.prod_map_inv'\n\n@[to_additive zsmul_sum]\nlemma prod_zpow (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) (n : \u2124) :\n  (\u220f a in s, f a) ^ n = \u220f a in s, (f a) ^ n :=\nmultiset.prod_map_zpow.symm\n\n@[to_additive]\nlemma prod_sdiff_div_prod_sdiff [decidable_eq \u03b1] :\n  (\u220f (x : \u03b1) in s\u2082 \\ s\u2081, f x) / (\u220f (x : \u03b1) in s\u2081 \\ s\u2082, f x)\n  = (\u220f (x : \u03b1) in s\u2082, f x) / (\u220f (x : \u03b1) in s\u2081, f x) :=\nby simp [\u2190 finset.prod_sdiff (@inf_le_left _ _ s\u2081 s\u2082),\n  \u2190 finset.prod_sdiff (@inf_le_right _ _ s\u2081 s\u2082)]\n\nend comm_group\n\n@[simp] theorem card_sigma {\u03c3 : \u03b1 \u2192 Type*} (s : finset \u03b1) (t : \u03a0 a, finset (\u03c3 a)) :\n  card (s.sigma t) = \u2211 a in s, card (t a) :=\nmultiset.card_sigma _ _\n\nlemma card_bUnion [decidable_eq \u03b2] {s : finset \u03b1} {t : \u03b1 \u2192 finset \u03b2}\n  (h : \u2200 x \u2208 s, \u2200 y \u2208 s, x \u2260 y \u2192 disjoint (t x) (t y)) :\n  (s.bUnion t).card = \u2211 u in s, card (t u) :=\ncalc (s.bUnion t).card = \u2211 i in s.bUnion t, 1 : by simp\n... = \u2211 a in s, \u2211 i in t a, 1 : finset.sum_bUnion h\n... = \u2211 u in s, card (t u) : by simp\n\nlemma card_bUnion_le [decidable_eq \u03b2] {s : finset \u03b1} {t : \u03b1 \u2192 finset \u03b2} :\n  (s.bUnion t).card \u2264 \u2211 a in s, (t a).card :=\nby haveI := classical.dec_eq \u03b1; exact\nfinset.induction_on s (by simp)\n  (\u03bb a s has ih,\n    calc ((insert a s).bUnion t).card \u2264 (t a).card + (s.bUnion t).card :\n    by rw bUnion_insert; exact finset.card_union_le _ _\n    ... \u2264 \u2211 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 \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} {t : finset \u03b2}\n  (H : \u2200 x \u2208 s, f x \u2208 t) :\n  s.card = \u2211 a in t, (s.filter (\u03bb 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 \u03b2] (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) :\n  s.card = \u2211 a in s.image f, (s.filter (\u03bb x, f x = a)).card :=\ncard_eq_sum_card_fiberwise (\u03bb _, mem_image_of_mem _)\n\n@[simp] lemma sum_sub_distrib [add_comm_group \u03b2] :\n  \u2211 x in s, (f x - g x) = (\u2211 x in s, f x) - (\u2211 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 : \u03b1 \u2192 multiset \u03b2} (s : finset \u03b1) (b : \u03b2) :\n  b \u2208 \u2211 x in s, f x \u2194 \u2203 a \u2208 s, b \u2208 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 \u03b2]\n\nlemma prod_eq_zero (ha : a \u2208 s) (h : f a = 0) : (\u220f x in s, f x) = 0 :=\nby { haveI := classical.dec_eq \u03b1, rw [\u2190prod_erase_mul _ _ ha, h, mul_zero] }\n\nlemma prod_boole {s : finset \u03b1} {p : \u03b1 \u2192 Prop} [decidable_pred p] :\n  \u220f i in s, ite (p i) (1 : \u03b2) (0 : \u03b2) = ite (\u2200 i \u2208 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 \u27e8i, hi, hq\u27e9,\n    apply prod_eq_zero hi,\n    rw [if_neg hq] },\nend\n\nvariables [nontrivial \u03b2] [no_zero_divisors \u03b2]\n\nlemma prod_eq_zero_iff : (\u220f x in s, f x) = 0 \u2194 (\u2203 a \u2208 s, f a = 0) :=\nbegin\n  classical,\n  apply finset.induction_on s,\n  exact \u27e8not.elim one_ne_zero, \u03bb \u27e8_, H, _\u27e9, H.elim\u27e9,\n  assume a s ha ih,\n  rw [prod_insert ha, mul_eq_zero, bex_def, exists_mem_insert, ih, \u2190 bex_def]\nend\n\ntheorem prod_ne_zero_iff : (\u220f x in s, f x) \u2260 0 \u2194 (\u2200 a \u2208 s, f a \u2260 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 \u03b2]\n\n@[simp]\nlemma prod_inv_distrib' : (\u220f x in s, (f x)\u207b\u00b9) = (\u220f x in s, f x)\u207b\u00b9 :=\nbegin\n  classical,\n  by_cases h : \u2203 x \u2208 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 : \u2200 x \u2208 s, (f x)\u207b\u00b9 * f x = 1 := \u03bb x hx, inv_mul_cancel (h x hx),\n    apply mul_right_cancel\u2080 h',\n    simp [h, h', \u2190 finset.prod_mul_distrib, prod_congr rfl hf] }\nend\n\nend comm_group_with_zero\n\n@[to_additive]\nlemma prod_unique_nonempty {\u03b1 \u03b2 : Type*} [comm_monoid \u03b2] [unique \u03b1]\n  (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2) (h : s.nonempty) :\n  (\u220f x in s, f x) = f default :=\nbegin\n  obtain \u27e8a, ha\u27e9 := 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 {\u03b1 \u03b2 M : Type*} [fintype \u03b1] [fintype \u03b2] [comm_monoid M]\n  (e : \u03b1 \u2192 \u03b2) (he : function.bijective e) (f : \u03b1 \u2192 M) (g : \u03b2 \u2192 M) (h : \u2200 x, f x = g (e x)) :\n  \u220f x : \u03b1, f x = \u220f x : \u03b2, g x :=\nprod_bij\n  (\u03bb x _, e x)\n  (\u03bb x _, mem_univ (e x))\n  (\u03bb x _, h x)\n  (\u03bb x x' _ _ h, he.injective h)\n  (\u03bb y _, (he.surjective y).imp $ \u03bb a h, \u27e8mem_univ _, h.symm\u27e9)\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 {\u03b1 \u03b2 M : Type*} [fintype \u03b1] [fintype \u03b2] [comm_monoid M]\n  (e : \u03b1 \u2243 \u03b2) (f : \u03b1 \u2192 M) (g : \u03b2 \u2192 M) (h : \u2200 x, f x = g (e x)) :\n  \u220f x : \u03b1, f x = \u220f x : \u03b2, g x :=\nprod_bijective e e.bijective f g h\n\n@[to_additive]\nlemma prod_finset_coe [comm_monoid \u03b2] :\n  \u220f (i : (s : set \u03b1)), f i = \u220f i in s, f i :=\n(finset.prod_subtype s (\u03bb _, iff.rfl) f).symm\n\n@[to_additive]\nlemma prod_unique {\u03b1 \u03b2 : Type*} [comm_monoid \u03b2] [unique \u03b1] (f : \u03b1 \u2192 \u03b2) :\n  (\u220f x : \u03b1, f x) = f default :=\nby rw [univ_unique, prod_singleton]\n\n@[to_additive] lemma prod_empty {\u03b1 \u03b2 : Type*} [comm_monoid \u03b2] [is_empty \u03b1] (f : \u03b1 \u2192 \u03b2) :\n  (\u220f x : \u03b1, f x) = 1 :=\nby rw [eq_empty_of_is_empty (univ : finset \u03b1), finset.prod_empty]\n\n@[to_additive]\nlemma prod_subsingleton {\u03b1 \u03b2 : Type*} [comm_monoid \u03b2] [subsingleton \u03b1] (f : \u03b1 \u2192 \u03b2) (a : \u03b1) :\n  (\u220f x : \u03b1, f x) = f a :=\nbegin\n  haveI : unique \u03b1 := unique_of_subsingleton a,\n  convert prod_unique f\nend\n\n@[to_additive]\nlemma prod_subtype_mul_prod_subtype {\u03b1 \u03b2 : Type*} [fintype \u03b1] [comm_monoid \u03b2]\n  (p : \u03b1 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) [decidable_pred p] :\n  (\u220f (i : {x // p x}), f i) * (\u220f i : {x // \u00ac p x}, f i) = \u220f i, f i :=\nbegin\n  classical,\n  let s := {x | p x}.to_finset,\n  rw [\u2190 finset.prod_subtype s, \u2190 finset.prod_subtype s\u1d9c],\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 \u03b1] [comm_monoid M]\n  (f : \u03b1 \u2192 M) : \u2200 {l : list \u03b1} (hl : l.nodup), l.to_finset.prod f = (l.map f).prod\n| [] _ := by simp\n| (a :: l) hl := let \u27e8not_mem, hl\u27e9 := 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 \u03b1]\n\n@[simp] lemma to_finset_sum_count_eq (s : multiset \u03b1) :\n  (\u2211 a in s.to_finset, s.count a) = s.card :=\nmultiset.induction_on s rfl\n  (assume a s ih,\n    calc (\u2211 x in to_finset (a ::\u2098 s), count x (a ::\u2098 s)) =\n      \u2211 x in to_finset (a ::\u2098 s), ((if x = a then 1 else 0) + count x s) :\n        finset.sum_congr rfl $ \u03bb _ _, 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 ::\u2098 s) :\n      begin\n        by_cases a \u2208 s.to_finset,\n        { have : \u2211 x in s.to_finset, ite (x = a) 1 0 = \u2211 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 \u2209 s, by rwa mem_to_finset at h,\n          have : \u2211 x in to_finset s, ite (x = a) 1 0 = \u2211 x in to_finset s, 0, from\n            finset.sum_congr rfl (\u03bb 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 \u03b2} {a : \u03b1} {f : \u03b2 \u2192 multiset \u03b1} :\n  count a (\u2211 x in s, f x) = \u2211 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 \u03b1) :\n  (\u2211 a in s.to_finset, s.count a \u2022 {a}) = s :=\nbegin\n  apply ext', intro b,\n  rw count_sum',\n  have h : count b s = count b (count b s \u2022 {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 \u03b1) {k : \u2115}\n  (h : \u2200 (a : \u03b1), a \u2208 s \u2192 k \u2223 multiset.count a s) :\n  \u2203 (u : multiset \u03b1), s = k \u2022 u :=\nbegin\n  use \u2211 a in s.to_finset, (s.count a / k) \u2022 {a},\n  have h\u2082 : \u2211 (x : \u03b1) in s.to_finset, k \u2022 (count x s / k) \u2022 ({x} : multiset \u03b1) =\n    \u2211 (x : \u03b1) in s.to_finset, count x s \u2022 {x},\n  { apply finset.sum_congr rfl,\n    intros x hx,\n    rw [\u2190 mul_nsmul, nat.mul_div_cancel' (h x (mem_to_finset.mp hx))] },\n  rw [\u2190 finset.sum_nsmul, h\u2082, to_finset_sum_count_nsmul_eq]\nend\n\nlemma to_finset_prod_dvd_prod [comm_monoid \u03b1] (S : multiset \u03b1) : S.to_finset.prod id \u2223 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 {\u03b1 : Type*} {\u03b9 : Type*} [comm_monoid \u03b1] (f : \u03b9 \u2192 multiset \u03b1) (s : finset \u03b9) :\n  (\u2211 x in s, f x).prod = \u220f 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 \u03b2] [has_one \u03b2] (s : finset \u03b1) (f : \u03b1 \u2192 \u2115) :\n  \u2191(\u2211 x in s, f x : \u2115) = (\u2211 x in s, (f x : \u03b2)) :=\n(nat.cast_add_monoid_hom \u03b2).map_sum f s\n\n@[simp, norm_cast] lemma int.cast_sum [add_comm_group \u03b2] [has_one \u03b2] (s : finset \u03b1) (f : \u03b1 \u2192 \u2124) :\n  \u2191(\u2211 x in s, f x : \u2124) = (\u2211 x in s, (f x : \u03b2)) :=\n(int.cast_add_hom \u03b2).map_sum f s\n\n@[simp, norm_cast] lemma nat.cast_prod {R : Type*} [comm_semiring R] (f : \u03b1 \u2192 \u2115) (s : finset \u03b1) :\n  (\u2191\u220f i in s, f i : R) = \u220f 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 : \u03b1 \u2192 \u2124) (s : finset \u03b1) :\n  (\u2191\u220f i in s, f i : R) = \u220f 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 : \u03b1 \u2192 M\u02e3)\n  (s : finset \u03b1) : (\u2191\u220f i in s, f i : M) = \u220f i in s, f i :=\n(units.coe_hom M).map_prod _ _\n\nlemma nat_abs_sum_le {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 \u2124) :\n  (\u2211 i in s, f i).nat_abs \u2264 \u2211 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\u2081 v\u2082 u u\u2081 u\u2082\n\nopen category_theory\n\nnamespace category_theory.limits\n\nvariables {C : Type u\u2081} [category.{v\u2081} 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, \u03c0 := 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, \u03b9 := 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 \u27f6 Y`. -/\ndef is_terminal_equiv_unique (F : discrete.{0} pempty.{1} \u2964 C) (Y : C) :\n  is_limit (\u27e8Y, by tidy\u27e9 : cone F) \u2243 \u2200 X : C, unique (X \u27f6 Y) :=\n{ to_fun := \u03bb t X, { default := t.lift \u27e8X, by tidy\u27e9,\n    uniq := \u03bb f, t.uniq \u27e8X, by tidy\u27e9 f (by tidy) },\n  inv_fun := \u03bb u, { lift := \u03bb s, (u s.X).default, uniq' := \u03bb 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 \u27f6 Y`\n    (as an instance). -/\ndef is_terminal.of_unique (Y : C) [h : \u03a0 X : C, unique (X \u27f6 Y)] : is_terminal Y :=\n{ lift := \u03bb s, (h s.X).default }\n\n/-- If `\u03b1` is a preorder with top, then `\u22a4` is a terminal object. -/\ndef is_terminal_top {\u03b1 : Type*} [preorder \u03b1] [order_top \u03b1] : is_terminal (\u22a4 : \u03b1) :=\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 \u2245 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 \u27f6 Y`. -/\ndef is_initial_equiv_unique (F : discrete.{0} pempty.{1} \u2964 C) (X : C) :\n  is_colimit (\u27e8X, by tidy\u27e9 : cocone F) \u2243 \u2200 Y : C, unique (X \u27f6 Y) :=\n{ to_fun := \u03bb t X, { default := t.desc \u27e8X, by tidy\u27e9,\n    uniq := \u03bb f, t.uniq \u27e8X, by tidy\u27e9 f (by tidy) },\n  inv_fun := \u03bb u, { desc := \u03bb s, (u s.X).default, uniq' := \u03bb 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 \u27f6 Y`\n    (as an instance). -/\ndef is_initial.of_unique (X : C) [h : \u03a0 Y : C, unique (X \u27f6 Y)] : is_initial X :=\n{ desc := \u03bb s, (h s.X).default }\n\n/-- If `\u03b1` is a preorder with bot, then `\u22a5` is an initial object. -/\ndef is_initial_bot {\u03b1 : Type*} [preorder \u03b1] [order_bot \u03b1] : is_initial (\u22a5 : \u03b1) :=\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 \u2245 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 \u27f6 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 \u27f6 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 \u27f6 Y) :\n  f \u226b 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 = \ud835\udfd9 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 \u27f6 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 \u27f6 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 \u27f6 Z) :\n  t.to Y \u226b f = t.to Z :=\nt.hom_ext _ _\n\n@[simp] lemma is_initial.to_self {X : C} (t : is_initial X) : t.to X = \ud835\udfd9 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 \u27f6 Y) :\n  is_split_mono f := is_split_mono.mk' \u27e8t.from _, t.hom_ext _ _\u27e9\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 \u27f6 X) :\n  is_split_epi f := is_split_epi.mk' \u27e8t.to _, t.hom_ext _ _\u27e9\n\n/-- Any morphism from a terminal object is mono. -/\nlemma is_terminal.mono_from {X Y : C} (t : is_terminal X) (f : X \u27f6 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 \u27f6 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 \u2245 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 \u2245 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\u2081 : discrete.{w} pempty \u2964 C} {F\u2082 : discrete.{w'} pempty \u2964 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\u2081 : cone F\u2081} (hl : is_limit c\u2081)\n  (c\u2082 : cone F\u2082) (hi : c\u2081.X \u2245 c\u2082.X) : is_limit c\u2082 :=\n{ lift := \u03bb c, hl.lift \u27e8c.X, by tidy\u27e9 \u226b hi.hom,\n  fac' := \u03bb _ j, j.as.elim,\n  uniq' := \u03bb c f _, by { erw \u2190 hl.uniq \u27e8c.X, by tidy\u27e9 (f \u226b hi.inv) (\u03bb 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\u2081 : cone F\u2081) (c\u2082 : cone F\u2082) (h : c\u2081.X \u2245 c\u2082.X) :\n  is_limit c\u2081 \u2243 is_limit c\u2082 :=\n{ to_fun := \u03bb hl, is_limit_change_empty_cone C hl c\u2082 h,\n  inv_fun := \u03bb hl, is_limit_change_empty_cone C hl c\u2081 h.symm,\n  left_inv := by tidy,\n  right_inv := by tidy }\n\nlemma has_terminal_change_diagram (h : has_limit F\u2081) : has_limit F\u2082 :=\n\u27e8\u27e8\u27e8\u27e8limit F\u2081, by tidy\u27e9, is_limit_change_empty_cone C (limit.is_limit F\u2081) _ (eq_to_iso rfl)\u27e9\u27e9\u27e9\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 := \u03bb 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\u2081 : cocone F\u2081} (hl : is_colimit c\u2081)\n  (c\u2082 : cocone F\u2082) (hi : c\u2081.X \u2245 c\u2082.X) : is_colimit c\u2082 :=\n{ desc := \u03bb c, hi.inv \u226b hl.desc \u27e8c.X, by tidy\u27e9,\n  fac' := \u03bb _ j, j.as.elim,\n  uniq' := \u03bb c f _, by { erw \u2190 hl.uniq \u27e8c.X, by tidy\u27e9 (hi.hom \u226b f) (\u03bb 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\u2081 : cocone F\u2081) (c\u2082 : cocone F\u2082) (h : c\u2081.X \u2245 c\u2082.X) :\n  is_colimit c\u2081 \u2243 is_colimit c\u2082 :=\n{ to_fun := \u03bb hl, is_colimit_change_empty_cocone C hl c\u2082 h,\n  inv_fun := \u03bb hl, is_colimit_change_empty_cocone C hl c\u2081 h.symm,\n  left_inv := by tidy,\n  right_inv := by tidy }\n\nlemma has_initial_change_diagram (h : has_colimit F\u2081) : has_colimit F\u2082 :=\n\u27e8\u27e8\u27e8\u27e8colimit F\u2081, by tidy\u27e9,\n   is_colimit_change_empty_cocone C (colimit.is_colimit F\u2081) _ (eq_to_iso rfl)\u27e9\u27e9\u27e9\n\n\n\nend univ\n\n/--\nAn arbitrary choice of terminal object, if one exists.\nYou can use the notation `\u22a4_ 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 `\u22a5_ 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 `\u22a4_ ` C:20 := terminal C\nnotation `\u22a5_ ` 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 : \u03a0 Y : C, unique (Y \u27f6 X)] : has_terminal C :=\n{ has_limit := \u03bb F, has_limit.mk \u27e8_, (is_terminal_equiv_unique F X).inv_fun h\u27e9 }\n\nlemma is_terminal.has_terminal {X : C} (h : is_terminal X) : has_terminal C :=\n{ has_limit := \u03bb F, has_limit.mk \u27e8\u27e8X, by tidy\u27e9, is_limit_change_empty_cone _ h _ (iso.refl _)\u27e9 }\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 : \u03a0 Y : C, unique (X \u27f6 Y)] : has_initial C :=\n{ has_colimit := \u03bb F, has_colimit.mk \u27e8_, (is_initial_equiv_unique F X).inv_fun h\u27e9 }\n\nlemma is_initial.has_initial {X : C} (h : is_initial X) : has_initial C :=\n{ has_colimit := \u03bb F, has_colimit.mk\n    \u27e8\u27e8X, by tidy\u27e9, is_colimit_change_empty_cocone _ h _ (iso.refl _)\u27e9 }\n\n/-- The map from an object to the terminal object. -/\nabbreviation terminal.from [has_terminal C] (P : C) : P \u27f6 \u22a4_ 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) : \u22a5_ C \u27f6 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 (\u22a4_ C) :=\n{ lift := \u03bb s, terminal.from _ }\n\n/-- An initial object is initial. -/\ndef initial_is_initial [has_initial C] : is_initial (\u22a5_ C) :=\n{ desc := \u03bb s, initial.to _ }\n\ninstance unique_to_terminal [has_terminal C] (P : C) : unique (P \u27f6 \u22a4_ C) :=\nis_terminal_equiv_unique _ (\u22a4_ C) terminal_is_terminal P\n\ninstance unique_from_initial [has_initial C] (P : C) : unique (\u22a5_ C \u27f6 P) :=\nis_initial_equiv_unique _ (\u22a5_ C) initial_is_initial P\n\n@[simp] lemma terminal.comp_from [has_terminal C] {P Q : C} (f : P \u27f6 Q) :\n  f \u226b terminal.from Q = terminal.from P :=\nby tidy\n@[simp] lemma initial.to_comp [has_initial C] {P Q : C} (f : P \u27f6 Q) :\n  initial.to P \u226b 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) : \u22a5_ C \u2245 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) : \u22a4_ C \u2245 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 : \u22a4_ C \u27f6 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 \u27f6 \u22a5_ 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 := \u03bb s, (t.to s.X.unop).op,\n  uniq' := \u03bb 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\u1d52\u1d56} (t : is_initial X) : is_terminal X.unop :=\n{ lift := \u03bb s, (t.to (opposite.op s.X)).unop,\n  uniq' := \u03bb 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 := \u03bb s, (t.from s.X.unop).op,\n  uniq' := \u03bb 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\u1d52\u1d56} (t : is_terminal X) : is_initial X.unop :=\n{ desc := \u03bb s, (t.from (opposite.op s.X)).unop,\n  uniq' := \u03bb s m w, quiver.hom.op_inj (t.hom_ext _ _) }\n\ninstance has_initial_op_of_has_terminal [has_terminal C] : has_initial C\u1d52\u1d56 :=\n(initial_op_of_terminal terminal_is_terminal).has_initial\n\ninstance has_terminal_op_of_has_initial [has_initial C] : has_terminal C\u1d52\u1d56 :=\n(terminal_op_of_initial initial_is_initial).has_terminal\n\nlemma has_terminal_of_has_initial_op [has_initial C\u1d52\u1d56] : has_terminal C :=\n(terminal_unop_of_initial initial_is_initial).has_terminal\n\nlemma has_initial_of_has_terminal_op [has_terminal C\u1d52\u1d56] : 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 (\u22a4_ C)) :=\nhas_limit.mk\n{ cone :=\n  { X := \u22a4_ C,\n    \u03c0 := { app := \u03bb _, terminal.from _, }, },\n  is_limit :=\n  { lift := \u03bb s, terminal.from _, }, }\n\n/-- The limit of the constant `\u22a4_ C` functor is `\u22a4_ 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 (\u22a4_ C)) \u2245 \u22a4_ C :=\n{ hom := terminal.from _,\n  inv := limit.lift ((category_theory.functor.const J).obj (\u22a4_ C))\n    { X := \u22a4_ C, \u03c0 := { app := \u03bb j, terminal.from _, }}, }\n\n@[simp, reassoc] lemma limit_const_terminal_inv_\u03c0\n  {J : Type*} [category J] {C : Type*} [category C] [has_terminal C] {j : J} :\n  limit_const_terminal.inv \u226b limit.\u03c0 ((category_theory.functor.const J).obj (\u22a4_ C)) j =\n    terminal.from _ :=\nby ext \u27e8\u27e8\u27e9\u27e9\n\ninstance {J : Type*} [category J] {C : Type*} [category C] [has_initial C] :\n  has_colimit ((category_theory.functor.const J).obj (\u22a5_ C)) :=\nhas_colimit.mk\n{ cocone :=\n  { X := \u22a5_ C,\n    \u03b9 := { app := \u03bb _, initial.to _, }, },\n  is_colimit :=\n  { desc := \u03bb s, initial.to _, }, }\n\n/-- The colimit of the constant `\u22a5_ C` functor is `\u22a5_ 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 (\u22a5_ C)) \u2245 \u22a5_ C :=\n{ hom := colimit.desc ((category_theory.functor.const J).obj (\u22a5_ C))\n    { X := \u22a5_ C, \u03b9 := { app := \u03bb j, initial.to _, }, },\n  inv := initial.to _, }\n\n@[simp, reassoc] lemma \u03b9_colimit_const_initial_hom\n  {J : Type*} [category J] {C : Type*} [category C] [has_initial C] {j : J} :\n  colimit.\u03b9 ((category_theory.functor.const J).obj (\u22a5_ C)) j \u226b colimit_const_initial.hom =\n    initial.to _ :=\nby ext \u27e8\u27e8\u27e9\u27e9\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\u2081) [category.{v\u2081} C] : Prop :=\n(is_initial_mono_from : \u2200 {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 \u27f6 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 : \u22a5_ C \u27f6 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 : \u2200 X, mono (hI.to X)) :\n  initial_mono_class C :=\n{ is_initial_mono_from := \u03bb I' X hI',\n  begin\n    rw hI'.hom_ext (hI'.to X) ((hI'.unique_up_to_iso hI).hom \u226b 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 : \u2200 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 (\u03bb X, mono_of_mono_fac (hI.hom_ext (_ \u226b 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 (\u22a4_ 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\u2082} [category.{v\u2082} D] (G : C \u2964 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 (\u22a4_ C) \u27f6 \u22a4_ 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  \u22a5_ D \u27f6 G.obj (\u22a5_ C) :=\ninitial.to _\n\nend comparison\n\nvariables {J : Type u} [category.{v} J]\n\n/-- From a functor `F : J \u2964 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 \u2964 C) : cone F :=\n{ X := F.obj X,\n  \u03c0 :=\n  { app := \u03bb j, F.map (tX.to j),\n    naturality' := \u03bb j j' k,\n    begin\n      dsimp,\n      rw [\u2190 F.map_comp, category.id_comp, tX.hom_ext (tX.to j \u226b k) (tX.to j')],\n    end } }\n\n/-- From a functor `F : J \u2964 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 \u2964 C) :\nis_limit (cone_of_diagram_initial tX F) :=\n{ lift := \u03bb s, s.\u03c0.app X,\n  uniq' := \u03bb s m w,\n    begin\n      rw [\u2190 w X, cone_of_diagram_initial_\u03c0_app, tX.hom_ext (tX.to X) (\ud835\udfd9 _)],\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 \u2964 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 \u2964 C)\n  [has_initial J] [has_limit F] :\nlimit F \u2245 F.obj (\u22a5_ 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 \u2964 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 \u2964 C) [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : cone F :=\n{ X := F.obj X,\n  \u03c0 :=\n  { app := \u03bb 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        \u2190 F.map_comp, hX.hom_ext (hX.from i) (f \u226b hX.from j)],\n    end } }\n\n/-- From a functor `F : J \u2964 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 \u2964 C) [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] :\n  is_limit (cone_of_diagram_terminal hX F) :=\n{ lift := \u03bb S, S.\u03c0.app _ }\n\n-- This is reducible to allow usage of lemmas about `cone_point_unique_up_to_iso`.\n/-- For a functor `F : J \u2964 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 \u2964 C)\n  [has_terminal J] [has_limit F] [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] :\nlimit F \u2245 F.obj (\u22a4_ 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 \u2964 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 \u2964 C) : cocone F :=\n{ X := F.obj X,\n  \u03b9 :=\n  { app := \u03bb j, F.map (tX.from j),\n    naturality' := \u03bb j j' k,\n    begin\n      dsimp,\n      rw [\u2190 F.map_comp, category.comp_id, tX.hom_ext (k \u226b tX.from j') (tX.from j)],\n    end } }\n\n/-- From a functor `F : J \u2964 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 \u2964 C) :\nis_colimit (cocone_of_diagram_terminal tX F) :=\n{ desc := \u03bb s, s.\u03b9.app X,\n  uniq' := \u03bb s m w,\n    by { rw [\u2190 w X, cocone_of_diagram_terminal_\u03b9_app, tX.hom_ext (tX.from X) (\ud835\udfd9 _)], simp } }\n\n-- This is reducible to allow usage of lemmas about `cocone_point_unique_up_to_iso`.\n/-- For a functor `F : J \u2964 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 \u2964 C)\n  [has_terminal J] [has_colimit F] :\ncolimit F \u2245 F.obj (\u22a4_ 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 \u2964 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 \u2964 C)\n  [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : cocone F :=\n{ X := F.obj X,\n  \u03b9 :=\n  { app := \u03bb 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        \u2190 F.map_comp, hX.hom_ext (hX.to i \u226b f) (hX.to j)],\n    end } }\n\n/-- From a functor `F : J \u2964 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 \u2964 C)\n  [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_colimit (cocone_of_diagram_initial hX F) :=\n{ desc := \u03bb S, S.\u03b9.app _ }\n\n-- This is reducible to allow usage of lemmas about `cocone_point_unique_up_to_iso`.\n/-- For a functor `F : J \u2964 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 \u2964 C)\n  [has_initial J] [has_colimit F] [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] :\ncolimit F \u2245 F.obj (\u22a5_ 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.\u03c0 F j` is an isomorphism.\n-/\nlemma is_iso_\u03c0_of_is_initial {j : J} (I : is_initial j) (F : J \u2964 C) [has_limit F] :\n  is_iso (limit.\u03c0 F j) :=\n\u27e8\u27e8limit.lift _ (cone_of_diagram_initial I F), \u27e8by { ext, simp }, by simp\u27e9\u27e9\u27e9\n\ninstance is_iso_\u03c0_initial [has_initial J] (F : J \u2964 C) [has_limit F] :\n  is_iso (limit.\u03c0 F (\u22a5_ J)) :=\nis_iso_\u03c0_of_is_initial (initial_is_initial) F\n\nlemma is_iso_\u03c0_of_is_terminal {j : J} (I : is_terminal j) (F : J \u2964 C)\n  [has_limit F] [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_iso (limit.\u03c0 F j) :=\n\u27e8\u27e8limit.lift _ (cone_of_diagram_terminal I F), by { ext, simp }, by simp \u27e9\u27e9\n\ninstance is_iso_\u03c0_terminal [has_terminal J] (F : J \u2964 C) [has_limit F]\n  [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_iso (limit.\u03c0 F (\u22a4_ J)) :=\nis_iso_\u03c0_of_is_terminal terminal_is_terminal F\n\n/--\nIf `j` is terminal in the index category, then the map `colimit.\u03b9 F j` is an isomorphism.\n-/\nlemma is_iso_\u03b9_of_is_terminal {j : J} (I : is_terminal j) (F : J \u2964 C) [has_colimit F] :\n  is_iso (colimit.\u03b9 F j) :=\n\u27e8\u27e8colimit.desc _ (cocone_of_diagram_terminal I F), \u27e8by simp, by { ext, simp }\u27e9\u27e9\u27e9\n\ninstance is_iso_\u03b9_terminal [has_terminal J] (F : J \u2964 C) [has_colimit F] :\n  is_iso (colimit.\u03b9 F (\u22a4_ J)) :=\nis_iso_\u03b9_of_is_terminal (terminal_is_terminal) F\n\nlemma is_iso_\u03b9_of_is_initial {j : J} (I : is_initial j) (F : J \u2964 C)\n  [has_colimit F] [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_iso (colimit.\u03b9 F j) :=\n\u27e8\u27e8colimit.desc _ (cocone_of_diagram_initial I F), \u27e8by tidy, by { ext, simp }\u27e9\u27e9\u27e9\n\ninstance is_iso_\u03b9_initial [has_initial J] (F : J \u2964 C) [has_colimit F]\n  [\u2200 (i j : J) (f : i \u27f6 j), is_iso (F.map f)] : is_iso (colimit.\u03b9 F (\u22a5_ J)) :=\nis_iso_\u03b9_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": "constant p : Nat \u2192 Prop\nconstant q : Nat \u2192 Prop\n\ntheorem p_of_q : q x \u2192 p x := sorry\n\ntheorem pletfun : p (let_fun x := 0; x + 1) := by\n  -- \u22a2 p (let_fun x := 0; x + 1)\n  apply p_of_q\n  trace_state -- `let_fun` hint should not be consumed.\n  sorry\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/consumePPHint.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6477982315512488, "lm_q1q2_score": 0.4735784543968868}}
{"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\u2081 v\u2082 u\u2081 u\u2082 -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u\u2081} [category.{v\u2081} 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 (\ud835\udfed T) X\n\n-- Satisfying the inhabited linter\ninstance over.inhabited [inhabited T] : inhabited (over (default : T)) :=\n{ default :=\n  { left := default,\n    hom := \ud835\udfd9 _ } }\n\nnamespace over\n\nvariables {X : T}\n\n@[ext] lemma over_morphism.ext {X : T} {U V : over X} {f g : U \u27f6 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 (\ud835\udfd9 U) = \ud835\udfd9 U.left := rfl\n@[simp] lemma comp_left (a b c : over X) (f : a \u27f6 b) (g : b \u27f6 c) :\n  (f \u226b g).left = f.left \u226b g.left := rfl\n\n@[simp, reassoc] lemma w {A B : over X} (f : A \u27f6 B) : f.left \u226b 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 V.left) (w : f \u226b V.hom = U.hom . obviously) :\n  U \u27f6 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 \u2245 g.left) (hw : hl.hom \u226b g.hom = f.hom . obviously) :\n  f \u2245 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 \u2964 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 \u27f6 V} : (forget X).map f = f.left := rfl\n\n/-- The natural cocone over the forgetful functor `over X \u2964 T` with cocone point `X`. -/\n@[simps] def forget_cocone (X : T) : limits.cocone (forget X) :=\n{ X := X, \u03b9 := { app := comma.hom } }\n\n/--\nA morphism `f : X \u27f6 Y` induces a functor `over X \u2964 over Y` in the obvious way.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef map {Y : T} (f : X \u27f6 Y) : over X \u2964 over Y := comma.map_right _ $ discrete.nat_trans (\u03bb _, f)\n\nsection\nvariables {Y : T} {f : X \u27f6 Y} {U V : over X} {g : U \u27f6 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 \u226b 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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f \u226b g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map f \u22d9 map g :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := \u03bb Y Z f t, by exactI\n  \u27e8\u27e8over.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\u27e9\u27e9 }\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 \u27f6 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 \u27f6 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 \u27f6 g) [mono k] : mono k.left :=\nbegin\n  refine \u27e8\u03bb (Y : T) l m a, _\u27e9,\n  let l' : mk (m \u226b f.hom) \u27f6 f := hom_mk l (by { dsimp, rw [\u2190over.w k, reassoc_of a] }),\n  suffices : l' = hom_mk m,\n  { apply congr_arg comma_morphism.left this },\n  rw \u2190 cancel_mono k,\n  ext,\n  apply a,\nend\n\nsection iterated_slice\nvariables (f : over X)\n\n/-- Given f : Y \u27f6 X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iterated_slice_forward : over f \u2964 over f.left :=\n{ obj := \u03bb \u03b1, over.mk \u03b1.hom.left,\n  map := \u03bb \u03b1 \u03b2 \u03ba, over.hom_mk \u03ba.left.left (by { rw auto_param_eq, rw \u2190 over.w \u03ba, refl }) }\n\n/-- Given f : Y \u27f6 X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iterated_slice_backward : over f.left \u2964 over f :=\n{ obj := \u03bb g, mk (hom_mk g.hom : mk (g.hom \u226b f.hom) \u27f6 f),\n  map := \u03bb g h \u03b1, hom_mk (hom_mk \u03b1.left (w_assoc \u03b1 f.hom)) (over_morphism.ext (w \u03b1)) }\n\n/-- Given f : Y \u27f6 X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iterated_slice_equiv : over f \u224c over f.left :=\n{ functor := iterated_slice_forward f,\n  inverse := iterated_slice_backward f,\n  unit_iso :=\n    nat_iso.of_components\n    (\u03bb g, over.iso_mk (over.iso_mk (iso.refl _) (by tidy)) (by tidy))\n    (\u03bb X Y g, by { ext, dsimp, simp }),\n  counit_iso :=\n    nat_iso.of_components\n    (\u03bb g, over.iso_mk (iso.refl _) (by tidy))\n    (\u03bb X Y g, by { ext, dsimp, simp }) }\n\nlemma iterated_slice_forward_forget :\n  iterated_slice_forward f \u22d9 forget f.left = forget f \u22d9 forget X :=\nrfl\n\nlemma iterated_slice_backward_forget_forget :\n  iterated_slice_backward f \u22d9 forget f \u22d9 forget X = forget f.left :=\nrfl\n\nend iterated_slice\n\nsection\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `F : T \u2964 D` induces a functor `over X \u2964 over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T \u2964 D) : over X \u2964 over (F.obj X) :=\n{ obj := \u03bb Y, mk $ F.map Y.hom,\n  map := \u03bb Y\u2081 Y\u2082 f,\n  { left := F.map f.left,\n    w' := by tidy; erw [\u2190 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 (\ud835\udfed T)\n\n-- Satisfying the inhabited linter\ninstance under.inhabited [inhabited T] : inhabited (under (default : T)) :=\n{ default :=\n  { right := default,\n    hom := \ud835\udfd9 _ } }\n\nnamespace under\n\nvariables {X : T}\n\n@[ext] lemma under_morphism.ext {X : T} {U V : under X} {f g : U \u27f6 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 (\ud835\udfd9 U) = \ud835\udfd9 U.right := rfl\n@[simp] lemma comp_right (a b c : under X) (f : a \u27f6 b) (g : b \u27f6 c) :\n  (f \u226b g).right = f.right \u226b g.right := rfl\n\n@[simp, reassoc] lemma w {A B : under X} (f : A \u27f6 B) : A.hom \u226b 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 \u27f6 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 \u27f6 V.right) (w : U.hom \u226b f = V.hom . obviously) :\n  U \u27f6 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 \u2245 g.right) (hw : f.hom \u226b hr.hom = g.hom) : f \u2245 g :=\nstructured_arrow.iso_mk hr hw\n\n@[simp]\nlemma iso_mk_hom_right {f g : under X} (hr : f.right \u2245 g.right) (hw : f.hom \u226b 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 \u2245 g.right) (hw : f.hom \u226b 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 \u2964 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 \u27f6 V} : (forget X).map f = f.right := rfl\n\n/-- The natural cone over the forgetful functor `under X \u2964 T` with cone point `X`. -/\n@[simps] def forget_cone (X : T) : limits.cone (forget X) :=\n{ X := X, \u03c0 := { app := comma.hom } }\n\n/-- A morphism `X \u27f6 Y` induces a functor `under Y \u2964 under X` in the obvious way. -/\ndef map {Y : T} (f : X \u27f6 Y) : under Y \u2964 under X := comma.map_left _ $ discrete.nat_trans (\u03bb _, f)\n\nsection\nvariables {Y : T} {f : X \u27f6 Y} {U V : under Y} {g : U \u27f6 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 \u226b 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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f \u226b g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map g \u22d9 map f :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := \u03bb Y Z f t, by exactI\n  \u27e8\u27e8under.hom_mk (inv ((under.forget X).map f)) ((is_iso.comp_inv_eq _).2 (under.w f).symm),\n    by tidy\u27e9\u27e9 }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\nsection\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `F : T \u2964 D` induces a functor `under X \u2964 under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T \u2964 D) : under X \u2964 under (F.obj X) :=\n{ obj := \u03bb Y, mk $ F.map Y.hom,\n  map := \u03bb Y\u2081 Y\u2082 f,\n  { right := F.map f.right,\n    w' := by tidy; erw [\u2190 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 : \u03b1) (xs ys : List \u03b1) : List.reverseAux (z :: xs) ys = List.reverseAux xs (z :: ys) := rfl\n\nnamespace Index\nvariable {\u03b1} {xs ys : List \u03b1}\n\ndef reverseAux : {xs ys : List \u03b1} \u2192 Sum (Index xs) (Index ys) \u2192 Index (List.reverseAux xs ys)\n| [], _, .inr j => j\n| x :: xs, ys, .inl .head => (List.reverseAux_step x xs ys).symm \u25b8 reverseAux (.inr .head)\n| x :: xs, ys, .inl (.tail i) => (List.reverseAux_step x xs ys).symm \u25b8 reverseAux (.inl i)\n| x :: xs, ys, .inr j => (List.reverseAux_step x xs ys).symm \u25b8 reverseAux (.inr (.tail j))\n\ndef reverseTR {xs : List \u03b1} (i : Index xs) : Index xs.reverse := reverseAux (.inl i)\n\ndef appendTR {xs ys : List \u03b1} : Sum (Index xs) (Index ys) \u2192 Index (List.append xs ys)\n| .inl i => List.append_eq_appendTR \u25b8 reverseAux (.inl i.reverseTR)\n| .inr j => List.append_eq_appendTR \u25b8 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' : \u211d\u22650} (M : Type*) (N : \u2115)\n\nnamespace profinitely_filtered_pseudo_normed_group\n\nvariables [profinitely_filtered_pseudo_normed_group M]\n\ndef unrescale (N : \u211d\u22650) (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\u207b\u00b9\nbegin\n  intro c,\n  refine \u27e8\u03bb x hx, _, _\u27e9,\n  { rwa mul_comm },\n  { haveI : fact (c * N\u207b\u00b9 \u2264 N\u207b\u00b9 * c) := \u27e8(mul_comm _ _).le\u27e9,\n    exact comphaus_filtered_pseudo_normed_group.continuous_cast_le (c * N\u207b\u00b9) (N\u207b\u00b9 * 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\u207b\u00b9 :=\nby { intros c x hx, rw [rescale.mem_filtration, mul_comm] at hx, exact hx i }\n\ndef sum_hom (N : \u2115) :\n  comphaus_filtered_pseudo_normed_group_hom (rescale N (M ^ N)) M :=\n\u2211 i, rescale_proj M N i\n\nlemma sum_hom_apply (x) : sum_hom M N x = \u2211 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) (\u03bb i, N\u207b\u00b9) (\u03bb 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  (\u03bb 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 = \u2211 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\u00f4pital'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 `\ud835\udcdd a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `\u211d`.\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' \u2260 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 : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d}\n    {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d}\n    (hff' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at f (f' x) x)\n    (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at g (g' x) x)\n    (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\ntheorem lhopital_zero_right_on_Ico {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d}\n    {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d}\n    (hff' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at f (f' x) x)\n    (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 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' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 g' x \u2260 0) (hfa : f a = 0) (hga : g a = 0)\n    (hdiv : filter.tendsto (fun (x : \u211d) => f' x / g' x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\ntheorem lhopital_zero_left_on_Ioo {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d}\n    {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d}\n    (hff' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at f (f' x) x)\n    (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at g (g' x) x)\n    (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within b (set.Iio b)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within b (set.Iio b)) l :=\n  sorry\n\ntheorem lhopital_zero_left_on_Ioc {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d}\n    {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d}\n    (hff' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at f (f' x) x)\n    (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 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' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 g' x \u2260 0) (hfb : f b = 0) (hgb : g b = 0)\n    (hdiv : filter.tendsto (fun (x : \u211d) => f' x / g' x) (nhds_within b (set.Iio b)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within b (set.Iio b)) l :=\n  sorry\n\ntheorem lhopital_zero_at_top_on_Ioi {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    {g' : \u211d \u2192 \u211d} (hff' : \u2200 (x : \u211d), x \u2208 set.Ioi a \u2192 has_deriv_at f (f' x) x)\n    (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioi a \u2192 has_deriv_at g (g' x) x)\n    (hg' : \u2200 (x : \u211d), x \u2208 set.Ioi a \u2192 g' x \u2260 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 : \u211d) => f' x / g' x) filter.at_top l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_top l :=\n  sorry\n\ntheorem lhopital_zero_at_bot_on_Iio {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    {g' : \u211d \u2192 \u211d} (hff' : \u2200 (x : \u211d), x \u2208 set.Iio a \u2192 has_deriv_at f (f' x) x)\n    (hgg' : \u2200 (x : \u211d), x \u2208 set.Iio a \u2192 has_deriv_at g (g' x) x)\n    (hg' : \u2200 (x : \u211d), x \u2208 set.Iio a \u2192 g' x \u2260 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 : \u211d) => f' x / g' x) filter.at_bot l) :\n    filter.tendsto (fun (x : \u211d) => 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 : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d}\n    {g : \u211d \u2192 \u211d} (hdf : differentiable_on \u211d f (set.Ioo a b))\n    (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\ntheorem lhopital_zero_right_on_Ico {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d}\n    {g : \u211d \u2192 \u211d} (hdf : differentiable_on \u211d f (set.Ioo a b)) (hcf : continuous_on f (set.Ico a b))\n    (hcg : continuous_on g (set.Ico a b)) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 deriv g x \u2260 0)\n    (hfa : f a = 0) (hga : g a = 0)\n    (hdiv : filter.tendsto (fun (x : \u211d) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\ntheorem lhopital_zero_left_on_Ioo {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d}\n    {g : \u211d \u2192 \u211d} (hdf : differentiable_on \u211d f (set.Ioo a b))\n    (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within b (set.Iio b)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within b (set.Iio b)) l :=\n  sorry\n\ntheorem lhopital_zero_at_top_on_Ioi {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    (hdf : differentiable_on \u211d f (set.Ioi a)) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioi a \u2192 deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) filter.at_top l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_top l :=\n  sorry\n\ntheorem lhopital_zero_at_bot_on_Iio {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    (hdf : differentiable_on \u211d f (set.Iio a)) (hg' : \u2200 (x : \u211d), x \u2208 set.Iio a \u2192 deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) filter.at_bot l) :\n    filter.tendsto (fun (x : \u211d) => 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\u00f4pital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    {g' : \u211d \u2192 \u211d}\n    (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) (nhds_within a (set.Ioi a)))\n    (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) (nhds_within a (set.Ioi a)))\n    (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\n/-- L'H\u00f4pital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    {g' : \u211d \u2192 \u211d}\n    (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) (nhds_within a (set.Iio a)))\n    (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) (nhds_within a (set.Iio a)))\n    (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within a (set.Iio a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Iio a)) l :=\n  sorry\n\n/-- L'H\u00f4pital'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 : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d}\n    (hff' :\n      filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x)\n        (nhds_within a (set.univ \\ singleton a)))\n    (hgg' :\n      filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x)\n        (nhds_within a (set.univ \\ singleton a)))\n    (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within a (set.univ \\ singleton a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l :=\n  sorry\n\n/-- L'H\u00f4pital's rule for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d}\n    (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) (nhds a))\n    (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) (nhds a))\n    (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) (nhds a) l) :\n    filter.tendsto (fun (x : \u211d) => 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\u00f4pital's rule for approaching +\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d}\n    (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) filter.at_top)\n    (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) filter.at_top)\n    (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) filter.at_top l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_top l :=\n  sorry\n\n/-- L'H\u00f4pital's rule for approaching -\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d}\n    (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) filter.at_bot)\n    (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) filter.at_bot)\n    (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) filter.at_bot l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_bot l :=\n  sorry\n\nend has_deriv_at\n\n\nnamespace deriv\n\n\n/-- L'H\u00f4pital's rule for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) (nhds_within a (set.Ioi a)))\n    (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l :=\n  sorry\n\n/-- L'H\u00f4pital's rule for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) (nhds_within a (set.Iio a)))\n    (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within a (set.Iio a)) l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Iio a)) l :=\n  sorry\n\n/-- L'H\u00f4pital's rule for approaching a real, `deriv` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds' {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    (hdf :\n      filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x)\n        (nhds_within a (set.univ \\ singleton a)))\n    (hg' :\n      filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within a (set.univ \\ singleton a))\n        l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l :=\n  sorry\n\n/-- L'H\u00f4pital's rule for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) (nhds a))\n    (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds a) l) :\n    filter.tendsto (fun (x : \u211d) => 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\u00f4pital's rule for approaching +\u221e, `deriv` version -/\ntheorem lhopital_zero_at_top {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) filter.at_top)\n    (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) filter.at_top l) :\n    filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_top l :=\n  sorry\n\n/-- L'H\u00f4pital's rule for approaching -\u221e, `deriv` version -/\ntheorem lhopital_zero_at_bot {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d}\n    (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) filter.at_bot)\n    (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) filter.at_bot l) :\n    filter.tendsto (fun (x : \u211d) => 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\u00e4rn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David W\u00e4rn\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 \u21bb 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 \u2192 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 \u27f6 y` in this category is simply a scalar `m : M` such that `m \u2022 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 \u21bb X viewed as a functor mapping the single object of M to X\n  and an element `m : M` to the map `X \u2192 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 \u21bb 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 \u03c0 (M : Type u_1) [monoid M] (X : Type u) [mul_action M X] :\n    action_category M X \u2964 single_obj M :=\n  category_of_elements.\u03c0 (action_as_functor M X)\n\n@[simp] theorem \u03c0_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 \u27f6 q) :\n    functor.map (\u03c0 M X) f = subtype.val f :=\n  rfl\n\n@[simp] theorem \u03c0_obj (M : Type u_1) [monoid M] (X : Type u) [mul_action M X]\n    (p : action_category M X) : functor.obj (\u03c0 M X) p = single_obj.star M :=\n  subsingleton.elim (functor.obj (\u03c0 M X) p) (single_obj.star M)\n\n/-- An object of the action category given by M \u21bb X corresponds to an element of X. -/\ndef obj_equiv (M : Type u_1) [monoid M] (X : Type u) [mul_action M X] : X \u2243 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 \u27f6 q) =\n        Subtype\n          fun (m : M) =>\n            m \u2022 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    \u21a5(mul_action.stabilizer.submonoid M x) \u2243* End (coe_fn (obj_equiv M X) x) :=\n  mul_equiv.refl \u21a5(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 : \u21a5(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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n\nopen function (fixed_points is_fixed_pt)\n\nnamespace preorder_hom\n\nsection basic\n\nvariables [complete_lattice \u03b1] (f : \u03b1 \u2192\u2098 \u03b1)\n\n/-- Least fixed point of a monotone function -/\ndef lfp : (\u03b1 \u2192\u2098 \u03b1) \u2192\u2098 \u03b1 :=\n{ to_fun := \u03bb f, Inf {a | f a \u2264 a},\n  monotone' := \u03bb f g hle, Inf_le_Inf $ \u03bb a ha, (hle a).trans ha }\n\n/-- Greatest fixed point of a monotone function -/\ndef gfp : (\u03b1 \u2192\u2098 \u03b1) \u2192\u2098 \u03b1 :=\n{ to_fun := \u03bb f, Sup {a | a \u2264 f a},\n  monotone' := \u03bb f g hle, Sup_le_Sup $ \u03bb a ha, le_trans ha (hle a) }\n\nlemma lfp_le {a : \u03b1} (h : f a \u2264 a) : lfp f \u2264 a := Inf_le h\n\nlemma lfp_le_fixed {a : \u03b1} (h : f a = a) : lfp f \u2264 a := f.lfp_le h.le\n\nlemma le_lfp {a : \u03b1} (h : \u2200 b, f b \u2264 b \u2192 a \u2264 b) : a \u2264 lfp f := le_Inf h\n\nlemma map_le_lfp {a : \u03b1} (ha : a \u2264 f.lfp) : f a \u2264 f.lfp :=\nf.le_lfp $ \u03bb 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) \u2264 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 : \u03b1} (ha : lfp f \u2264 a) : lfp f \u2264 f a :=\ncalc lfp f = f (lfp f) : f.map_lfp.symm\n       ... \u2264 f a       : f.mono ha\n\nlemma is_least_lfp_le : is_least {a | f a \u2264 a} (lfp f) :=\n\u27e8f.map_lfp.le, \u03bb a, f.lfp_le\u27e9\n\nlemma is_least_lfp : is_least (fixed_points f) (lfp f) :=\n\u27e8f.is_fixed_pt_lfp, \u03bb a, f.lfp_le_fixed\u27e9\n\nlemma lfp_induction {p : \u03b1 \u2192 Prop} (step : \u2200 a, p a \u2192 a \u2264 lfp f \u2192 p (f a))\n  (hSup : \u2200 s, (\u2200 a \u2208 s, p a) \u2192 p (Sup s)) :\n  p (lfp f) :=\nbegin\n  set s := {a | a \u2264 lfp f \u2227 p a},\n  specialize hSup s (\u03bb a, and.right),\n  suffices : Sup s = lfp f, from this \u25b8 hSup,\n  have h : Sup s \u2264 lfp f := Sup_le (\u03bb b, and.left),\n  have hmem : f (Sup s) \u2208 s, from \u27e8f.map_le_lfp h, step _ hSup h\u27e9,\n  exact h.antisymm (f.lfp_le $ le_Sup hmem)\nend\n\nlemma le_gfp {a : \u03b1} (h : a \u2264 f a) : a \u2264 gfp f :=\nle_Sup h\n\nlemma gfp_le {a : \u03b1} (h : \u2200 b, b \u2264 f b \u2192 b \u2264 a) : gfp f \u2264 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 : \u03b1} (ha : a \u2264 gfp f) : f a \u2264 gfp f := f.dual.lfp_le_map ha\n\nlemma gfp_le_map {a : \u03b1} (ha : gfp f \u2264 a) : gfp f \u2264 f a := f.dual.map_le_lfp ha\n\nlemma is_greatest_gfp_le : is_greatest {a | a \u2264 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 : \u03b1 \u2192 Prop} (step : \u2200 a, p a \u2192 gfp f \u2264 a \u2192 p (f a))\n  (hInf : \u2200 s, (\u2200 a \u2208 s, p a) \u2192 p (Inf s)) :\n  p (gfp f) :=\nf.dual.lfp_induction step hInf\n\nend basic\n\nsection eqn\n\nvariables [complete_lattice \u03b1] [complete_lattice \u03b2] (f : \u03b2 \u2192\u2098 \u03b1) (g : \u03b1 \u2192\u2098 \u03b2)\n\n-- Rolling rule\nlemma map_lfp_comp : f (lfp (g.comp f)) = lfp (f.comp g) :=\nle_antisymm ((f.comp g).map_lfp \u25b8 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 : \u03b1 \u2192\u2098 \u03b1 \u2192\u2098 \u03b1) :\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 \u2218 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 : \u03b1 \u2192\u2098 \u03b1 \u2192\u2098 \u03b1) :\n  gfp (gfp.comp h) = gfp h.on_diag :=\n@lfp_lfp (order_dual \u03b1) _ $ (preorder_hom.dual_iso (order_dual \u03b1)\n  (order_dual \u03b1)).symm.to_order_embedding.to_preorder_hom.comp h.dual\n\nend eqn\n\nsection prev_next\nvariables [complete_lattice \u03b1] (f : \u03b1 \u2192\u2098 \u03b1)\n\nlemma gfp_const_inf_le (x : \u03b1) : gfp (const \u03b1 x \u2293 f) \u2264 x :=\ngfp_le _ $ \u03bb 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 \u2264 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 : \u03b1) (hx : f x \u2264 x) : fixed_points f :=\n\u27e8gfp (const \u03b1 x \u2293 f),\n  calc f (gfp (const \u03b1 x \u2293 f)) = x \u2293 f (gfp (const \u03b1 x \u2293 f)) :\n    eq.symm $ inf_of_le_right $ (f.mono $ f.gfp_const_inf_le x).trans hx\n  ... = gfp (const \u03b1 x \u2293 f) : (const \u03b1 x \u2293 f).map_gfp \u27e9\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 \u2264 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 : \u03b1) (hx : x \u2264 f x) : fixed_points f :=\n{ val := (const \u03b1 x \u2294 f).lfp,\n  .. f.dual.prev_fixed x hx }\n\nlemma prev_fixed_le {x : \u03b1} (hx : f x \u2264 x) : \u2191(f.prev_fixed x hx) \u2264 x :=\nf.gfp_const_inf_le x\n\nlemma le_next_fixed {x : \u03b1} (hx : x \u2264 f x) : x \u2264 f.next_fixed x hx :=\nf.dual.prev_fixed_le hx\n\nlemma next_fixed_le {x : \u03b1} (hx : x \u2264 f x) {y : fixed_points f} (h : x \u2264 y) :\n  f.next_fixed x hx \u2264 y :=\nsubtype.coe_le_coe.1 $ lfp_le _ $ sup_le h y.2.le\n\n@[simp] lemma next_fixed_le_iff {x : \u03b1} (hx : x \u2264 f x) {y : fixed_points f} :\n  f.next_fixed x hx \u2264 y \u2194 x \u2264 y :=\n\u27e8\u03bb h, (f.le_next_fixed hx).trans h, f.next_fixed_le hx\u27e9\n\n@[simp] \n\nlemma le_prev_fixed {x : \u03b1} (hx : f x \u2264 x) {y : fixed_points f} (h : \u2191y \u2264 x) :\n  y \u2264 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 \u2294 y : \u03b1) \u2264 f (x \u2294 y) :=\ncalc (x \u2294 y : \u03b1) = f x \u2294 f y : congr_arg2 (\u2294) x.2.symm y.2.symm\n             ... \u2264 f (x \u2294 y) : f.mono.le_map_sup x y\n\nlemma map_inf_fixed_points_le (x y : fixed_points f) : f (x \u2293 y) \u2264 x \u2293 y :=\nf.dual.le_map_sup_fixed_points x y\n\nlemma le_map_Sup_subset_fixed_points (A : set \u03b1) (hA : A \u2286 fixed_points f) : Sup A \u2264 f (Sup A) :=\nSup_le $ \u03bb x hx, hA hx \u25b8 (f.mono $ le_Sup hx)\n\nlemma map_Inf_subset_fixed_points_le (A : set \u03b1) (hA : A \u2286 fixed_points f) : f (Inf A) \u2264 Inf A :=\nle_Inf $ \u03bb x hx, (hA hx) \u25b8 (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 \u03b1] (f : \u03b1 \u2192\u2098 \u03b1)\n\ninstance : semilattice_sup (fixed_points f) :=\n{ sup := \u03bb x y, f.next_fixed (x \u2294 y) (f.le_map_sup_fixed_points x y),\n  le_sup_left := \u03bb x y, subtype.coe_le_coe.1 $ le_sup_left.trans (f.le_next_fixed _),\n  le_sup_right := \u03bb x y, subtype.coe_le_coe.1 $ le_sup_right.trans (f.le_next_fixed _),\n  sup_le := \u03bb 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 := \u03bb x y, f.prev_fixed (x \u2293 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 := \u03bb s, f.next_fixed (Sup (coe '' s))\n    (f.le_map_Sup_subset_fixed_points (coe '' s) (\u03bb z \u27e8x, hx\u27e9, hx.2 \u25b8 x.2)),\n  le_Sup := \u03bb 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 := \u03bb 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 := \u03bb s, f.prev_fixed (Inf (coe '' s))\n    (f.map_Inf_subset_fixed_points_le (coe '' s) (\u03bb z \u27e8x, hx\u27e9, hx.2 \u25b8 x.2)),\n  le_Inf := \u03bb s x hx, f.le_prev_fixed _ $ le_Inf $ set.ball_image_iff.2 hx,\n  Inf_le := \u03bb 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 := \u27e8f.gfp, f.is_fixed_pt_gfp\u27e9,\n  bot := \u27e8f.lfp, f.is_fixed_pt_lfp\u27e9,\n  le_top := \u03bb x, f.le_gfp x.2.ge,\n  bot_le := \u03bb 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes H\u00f6lzl\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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n\nlocal notation `\u221e` := 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 {\u22a4}`, while this topology doesn't have singleton elements. -/\ninstance : topological_space ennreal :=\ntopological_space.generate_from {s | \u2203a, s = {b | a < b} \u2228 s = {b | b < a}}\n\ninstance : orderable_topology ennreal := \u27e8rfl\u27e9\n\ninstance : t2_space ennreal := by apply_instance\n\ninstance : second_countable_topology ennreal :=\n\u27e8\u27e8\u22c3q \u2265 (0:\u211a), {{a : ennreal | a < nnreal.of_real q}, {a : ennreal | \u2191(nnreal.of_real q) < a}},\n  countable_bUnion (countable_encodable _) $ assume a ha, countable_insert (countable_singleton _),\n  le_antisymm\n    (generate_from_le $ \u03bb s h, begin\n      rcases h with \u27e8a, hs | hs\u27e9;\n      [ rw show s = \u22c3q\u2208{q:\u211a | 0 \u2264 q \u2227 a < nnreal.of_real q}, {b | \u2191(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 = \u22c3q\u2208{q:\u211a | 0 \u2264 q \u2227 \u2191(nnreal.of_real q) < a}, {b | b < \u2191(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})\u27e9\u27e9\n\nlemma embedding_coe : embedding (coe : nnreal \u2192 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 \u27e8a, rfl | rfl\u27e9,\n    exact \u27e8{b : ennreal | \u2191a < b}, @is_open_lt' ennreal ennreal.topological_space _ _ _, by simp\u27e9,\n    exact \u27e8{b : ennreal | b < \u2191a}, @is_open_gt' ennreal ennreal.topological_space _ _ _, by simp\u27e9, },\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 \u27e8a, rfl | rfl\u27e9,\n    show is_open {b : nnreal | a < \u2191b},\n    { cases a; simp [none_eq_top, some_eq_coe, is_open_lt'] },\n    show is_open {b : nnreal | \u2191b < 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 \u2260 \u22a4} :=\nis_open_neg (is_closed_eq continuous_id continuous_const)\n\nlemma coe_range_mem_nhds : range (coe : nnreal \u2192 ennreal) \u2208 nhds (r : ennreal) :=\nhave {a : ennreal | a \u2260 \u22a4} = range (coe : nnreal \u2192 ennreal),\n  from set.ext $ assume a, by cases a; simp [none_eq_top, some_eq_coe],\nthis \u25b8 mem_nhds_sets is_open_ne_top coe_ne_top\n\nlemma tendsto_coe {f : filter \u03b1} {m : \u03b1 \u2192 nnreal} {a : nnreal} :\n  tendsto (\u03bba, (m a : ennreal)) f (nhds \u2191a) \u2194 tendsto m f (nhds a) :=\nembedding_coe.tendsto_nhds_iff.symm\n\nlemma continuous_coe {\u03b1} [topological_space \u03b1] {f : \u03b1 \u2192 nnreal} :\ncontinuous (\u03bba, (f a : ennreal)) \u2194 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 (\u03bbp:nnreal\u00d7nnreal, (p.1, p.2)) :=\nbegin\n  rw [(embedding_prod_mk embedding_coe embedding_coe).map_nhds_eq],\n  rw [\u2190 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 \u03b1} {m : \u03b1 \u2192 \u211d} {a : \u211d} (h : tendsto m f (nhds a)) :\n  tendsto (\u03bba, 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 \u2260 \u22a4 \u2192\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, (\u2218)],\n  exact tendsto_id\nend\n\nlemma tendsto_nhds_top {m : \u03b1 \u2192 ennreal} {f : filter \u03b1}\n  (h : \u2200n:\u2115, {a | \u2191n < m a} \u2208 f) : tendsto m f (nhds \u22a4) :=\ntendsto_nhds_generate_from $ assume s hs,\nmatch s, hs with\n| _, \u27e8none,   or.inl rfl\u27e9, hr := (lt_irrefl \u22a4 hr).elim\n| _, \u27e8some r, or.inl rfl\u27e9, hr :=\n  let \u27e8n, hrn\u27e9 := exists_nat_gt r in\n  mem_sets_of_superset (h n) $ assume a hnma, show \u2191r < m a, from\n    lt_trans (show (r : ennreal) < n, from (coe_nat n) \u25b8 coe_lt_coe.2 hrn) hnma\n| _, \u27e8a,      or.inr rfl\u27e9, hr := (not_top_lt $ show \u22a4 < a, from hr).elim\nend\n\nlemma tendsto_coe_nnreal_nhds_top {\u03b1} {l : filter \u03b1} {f : \u03b1 \u2192 nnreal} (h : tendsto f l at_top) :\n  tendsto (\u03bba, (f a : ennreal)) l (nhds (\u22a4:ennreal)) :=\ntendsto_nhds_top $ assume n,\nhave {a : \u03b1 | \u2191(n+1) \u2264 f a} \u2208 l := h $ mem_at_top _,\nmem_sets_of_superset this $ assume a (ha : \u2191(n+1) \u2264 f a),\nbegin\n  rw [\u2190 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\u27e8 continuous_iff_continuous_at.2 $\n  have hl : \u2200a:ennreal, tendsto (\u03bb (p : ennreal \u00d7 ennreal), p.fst + p.snd) (nhds (\u22a4, a)) (nhds \u22a4), from\n    assume a, tendsto_nhds_top $ assume n,\n    have set.prod {a | \u2191n < a } univ \u2208 nhds ((\u22a4:ennreal), a), from\n      prod_mem_nhds_sets (lt_mem_nhds $ coe_nat n \u25b8 coe_lt_top) univ_mem_sets,\n    show {a : ennreal \u00d7 ennreal | \u2191n < a.fst + a.snd} \u2208 nhds (\u22a4, a),\n    begin filter_upwards [this] assume \u27e8a\u2081, a\u2082\u27e9 \u27e8h\u2081, h\u2082\u27e9, lt_of_lt_of_le h\u2081 (le_add_right $ le_refl _) end,\n  begin\n    rintro \u27e8a\u2081, a\u2082\u27e9,\n    cases a\u2081, { simp [continuous_at, none_eq_top, hl a\u2082], },\n    cases a\u2082, { simp [continuous_at, none_eq_top, some_eq_coe, nhds_swap (a\u2081 : ennreal) \u22a4,\n                      tendsto_map'_iff, (\u2218), hl \u2191a\u2081] },\n    simp [continuous_at, some_eq_coe, nhds_coe_coe, tendsto_map'_iff, (\u2218)],\n    simp only [coe_add.symm, tendsto_coe, tendsto_add']\n  end \u27e9\n\nprotected lemma tendsto_mul' (ha : a \u2260 0 \u2228 b \u2260 \u22a4) (hb : b \u2260 0 \u2228 a \u2260 \u22a4) :\n  tendsto (\u03bbp:ennreal\u00d7ennreal, p.1 * p.2) (nhds (a, b)) (nhds (a * b)) :=\nhave ht : \u2200b:ennreal, b \u2260 0 \u2192 tendsto (\u03bbp:ennreal\u00d7ennreal, p.1 * p.2) (nhds ((\u22a4:ennreal), b)) (nhds \u22a4),\nbegin\n  refine assume b hb, tendsto_nhds_top $ assume n, _,\n  rcases dense (zero_lt_iff_ne_zero.2 hb) with \u27e8\u03b5', h\u03b5', h\u03b5b'\u27e9,\n  rcases ennreal.lt_iff_exists_coe.1 h\u03b5b' with \u27e8\u03b5, rfl, h\u27e9,\n  rcases exists_nat_gt (\u2191n / \u03b5) with \u27e8m, hm\u27e9,\n  have h\u03b5 : \u03b5 > 0, from coe_lt_coe.1 h\u03b5',\n  refine mem_sets_of_superset (prod_mem_nhds_sets (lt_mem_nhds $ @coe_lt_top m) (lt_mem_nhds $ h)) _,\n  rintros \u27e8a\u2081, a\u2082\u27e9 \u27e8h\u2081, h\u2082\u27e9,\n  dsimp at h\u2081 h\u2082 \u22a2,\n  calc (n:ennreal) = \u2191(((n:nnreal) / \u03b5) * \u03b5) :\n    begin\n      simp [nnreal.div_def],\n      rw [mul_assoc, \u2190 coe_mul, nnreal.inv_mul_cancel, coe_one, \u2190 coe_nat, mul_one],\n      exact zero_lt_iff_ne_zero.1 h\u03b5\n    end\n    ... < (\u2191m * \u03b5 : nnreal) : coe_lt_coe.2 $ mul_lt_mul hm (le_refl _) h\u03b5 (nat.cast_nonneg _)\n    ... \u2264 a\u2081 * a\u2082 : by rw [coe_mul]; exact canonically_ordered_semiring.mul_le_mul\n      (le_of_lt h\u2081)\n      (le_of_lt h\u2082)\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 \u2260 0, from mt coe_eq_coe.2 ha,\n    simp [*, nhds_swap (a : ennreal) \u22a4, none_eq_top, some_eq_coe, top_mul, tendsto_map'_iff, (\u2218), mul_comm] },\n  simp [some_eq_coe, nhds_coe_coe, tendsto_map'_iff, (\u2218)],\n  simp only [coe_mul.symm, tendsto_coe, tendsto_mul']\nend\n\nprotected lemma tendsto_mul {f : filter \u03b1} {ma : \u03b1 \u2192 ennreal} {mb : \u03b1 \u2192 ennreal} {a b : ennreal}\n  (hma : tendsto ma f (nhds a)) (ha : a \u2260 0 \u2228 b \u2260 \u22a4) (hmb : tendsto mb f (nhds b)) (hb : b \u2260 0 \u2228 a \u2260 \u22a4) :\n  tendsto (\u03bba, ma a * mb a) f (nhds (a * b)) :=\nshow tendsto ((\u03bbp:ennreal\u00d7ennreal, p.1 * p.2) \u2218 (\u03bba, (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 \u03b1} {m : \u03b1 \u2192 ennreal} {a b : ennreal}\n  (hm : tendsto m f (nhds b)) (hb : b \u2260 0 \u2228 a \u2260 \u22a4) : tendsto (\u03bbb, a * m b) f (nhds (a * b)) :=\nby_cases\n  (assume : a = 0, by simp [this, tendsto_const_nhds])\n  (assume ha : a \u2260 0, ennreal.tendsto_mul tendsto_const_nhds (or.inl ha) hm hb)\n\nlemma Sup_add {s : set ennreal} (hs : s \u2260 \u2205) : Sup s + a = \u2a06b\u2208s, b + a :=\nhave Sup ((\u03bbb, 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 {\u03b9 : Sort*} {s : \u03b9 \u2192 ennreal} [h : nonempty \u03b9] : supr s + a = \u2a06b, s b + a :=\nlet \u27e8x\u27e9 := h in\ncalc supr s + a = Sup (range s) + a : by simp [Sup_range]\n  ... = (\u2a06b\u2208range s, b + a) : Sup_add $ ne_empty_iff_exists_mem.mpr \u27e8s x, x, rfl\u27e9\n  ... = _ : by simp [supr_range, -mem_range]\n\nlemma add_supr {\u03b9 : Sort*} {s : \u03b9 \u2192 ennreal} [h : nonempty \u03b9] : a + supr s = \u2a06b, a + s b :=\nby rw [add_comm, supr_add]; simp\n\nlemma supr_add_supr {\u03b9 : Sort*} {f g : \u03b9 \u2192 ennreal} (h : \u2200i j, \u2203k, f i + g j \u2264 f k + g k) :\n  supr f + supr g = (\u2a06 a, f a + g a) :=\nbegin\n  by_cases h\u03b9 : nonempty \u03b9,\n  { letI := h\u03b9,\n    refine le_antisymm _ (supr_le $ \u03bb a, add_le_add' (le_supr _ _) (le_supr _ _)),\n    simpa [add_supr, supr_add] using\n      \u03bb i j:\u03b9, show f i + g j \u2264 \u2a06 a, f a + g a, from\n      let \u27e8k, hk\u27e9 := h i j in le_supr_of_le k hk },\n  { have : \u2200f:\u03b9 \u2192 ennreal, (\u2a06i, f i) = 0 := assume f, bot_unique (supr_le $ assume i, (h\u03b9 \u27e8i\u27e9).elim),\n    rw [this, this, this, zero_add] }\nend\n\nlemma supr_add_supr_of_monotone {\u03b9 : Sort*} [semilattice_sup \u03b9]\n  {f g : \u03b9 \u2192 ennreal} (hf : monotone f) (hg : monotone g) :\n  supr f + supr g = (\u2a06 a, f a + g a) :=\nsupr_add_supr $ assume i j, \u27e8i \u2294 j, add_le_add' (hf $ le_sup_left) (hg $ le_sup_right)\u27e9\n\nlemma finset_sum_supr_nat {\u03b1} {\u03b9} [semilattice_sup \u03b9] {s : finset \u03b1} {f : \u03b1 \u2192 \u03b9 \u2192 ennreal}\n  (hf : \u2200a, monotone (f a)) :\n  s.sum (\u03bba, supr (f a)) = (\u2a06 n, s.sum (\u03bba, f a n)) :=\nbegin\n  refine finset.induction_on s _ _,\n  { simp,\n    exact (bot_unique $ supr_le $ assume i, le_refl \u22a5).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 = \u2a06i\u2208s, a * i :=\nbegin\n  by_cases hs : \u2200x\u2208s, x = (0:ennreal),\n  { have h\u2081 : Sup s = 0 := (bot_unique $ Sup_le $ assume a ha, (hs a ha).symm \u25b8 le_refl 0),\n    have h\u2082 : (\u2a06i \u2208 s, a * i) = 0 :=\n      (bot_unique $ supr_le $ assume a, supr_le $ assume ha, by simp [hs a ha]),\n    rw [h\u2081, h\u2082, mul_zero] },\n  { simp only [not_forall] at hs,\n    rcases hs with \u27e8x, hx, hx0\u27e9,\n    have s\u2080 : s \u2260 \u2205 := not_eq_empty_iff_exists.2 \u27e8x, hx\u27e9,\n    have s\u2081 : Sup s \u2260 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 ((\u03bbb, 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\u2080\n        (ennreal.tendsto_mul_right (tendsto_id' inf_le_left) (or.inl s\u2081))),\n    rw [this.symm, Sup_image] }\nend\n\nlemma mul_supr {\u03b9 : Sort*} {f : \u03b9 \u2192 ennreal} {a : ennreal} : a * supr f = \u2a06i, a * f i :=\nby rw [\u2190 Sup_range, mul_Sup, supr_range]\n\nlemma supr_mul {\u03b9 : Sort*} {f : \u03b9 \u2192 ennreal} {a : ennreal} : supr f * a = \u2a06i, f i * a :=\nby rw [mul_comm, mul_supr]; congr; funext; rw [mul_comm]\n\nprotected lemma tendsto_coe_sub : \u2200{b:ennreal}, tendsto (\u03bbb:ennreal, \u2191r - b) (nhds b) (nhds (\u2191r - b)) :=\nbegin\n  refine (forall_ennreal.2 $ and.intro (assume a, _) _),\n  { simp [@nhds_coe a, tendsto_map'_iff, (\u2218), 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 {\u03b9 : Sort*} [h\u03b9 : nonempty \u03b9] {b : \u03b9 \u2192 ennreal} (hr : a < \u22a4) :\n  a - (\u2a06i, b i) = (\u2a05i, a - b i) :=\nlet \u27e8i\u27e9 := h\u03b9 in\nlet \u27e8r, eq, _\u27e9 := lt_iff_exists_coe.mp hr in\nhave Inf ((\u03bbb, \u2191r - b) '' range b) = \u2191r - (\u2a06i, 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 \u27e8i, rfl\u27e9)\n    (tendsto.comp (tendsto_id' inf_le_left) ennreal.tendsto_coe_sub),\nby rw [eq, \u2190this]; simp [Inf_image, infi_range, -mem_range]; exact le_refl _\n\nend topological_space\n\nsection tsum\n\nvariables {f g : \u03b1 \u2192 ennreal}\n\nprotected lemma is_sum_coe {f : \u03b1 \u2192 nnreal} {r : nnreal} :\n  is_sum (\u03bba, (f a : ennreal)) \u2191r \u2194 is_sum f r :=\nhave (\u03bbs:finset \u03b1, s.sum (coe \u2218 f)) = (coe : nnreal \u2192 ennreal) \u2218 (\u03bbs:finset \u03b1, 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 : \u03b1 \u2192 nnreal} (h : is_sum f r) : (\u2211a, (f a : ennreal)) = r :=\ntsum_eq_is_sum $ ennreal.is_sum_coe.2 $ h\n\nprotected lemma tsum_coe {f : \u03b1 \u2192 nnreal} : has_sum f \u2192 (\u2211a, (f a : ennreal)) = \u2191(tsum f)\n| \u27e8r, hr\u27e9 := by rw [tsum_eq_is_sum hr, ennreal.tsum_coe_eq hr]\n\nprotected lemma is_sum : is_sum f (\u2a06s:finset \u03b1, s.sum f) :=\ntendsto_orderable.2\n  \u27e8assume a' ha',\n    let \u27e8s, hs\u27e9 := lt_supr_iff.mp ha' in\n    mem_at_top_sets.mpr \u27e8s, assume t ht, lt_of_lt_of_le hs $ finset.sum_le_sum_of_subset ht\u27e9,\n  assume a' ha',\n    univ_mem_sets' $ assume s,\n    have s.sum f \u2264 \u2a06(s : finset \u03b1), s.sum f,\n      from le_supr (\u03bb(s : finset \u03b1), s.sum f) s,\n    lt_of_le_of_lt this ha'\u27e9\n\n@[simp] protected lemma has_sum : has_sum f := \u27e8_, ennreal.is_sum\u27e9\n\nprotected lemma tsum_eq_supr_sum : (\u2211a, f a) = (\u2a06s:finset \u03b1, s.sum f) :=\ntsum_eq_is_sum ennreal.is_sum\n\nprotected lemma tsum_sigma {\u03b2 : \u03b1 \u2192 Type*} (f : \u03a0a, \u03b2 a \u2192 ennreal) :\n  (\u2211p:\u03a3a, \u03b2 a, f p.1 p.2) = (\u2211a b, f a b) :=\ntsum_sigma (assume b, ennreal.has_sum) ennreal.has_sum\n\nprotected lemma tsum_prod {f : \u03b1 \u2192 \u03b2 \u2192 ennreal} : (\u2211p:\u03b1\u00d7\u03b2, f p.1 p.2) = (\u2211a, \u2211b, f a b) :=\nlet j : \u03b1 \u00d7 \u03b2 \u2192 (\u03a3a:\u03b1, \u03b2) := \u03bbp, sigma.mk p.1 p.2 in\nlet i : (\u03a3a:\u03b1, \u03b2) \u2192 \u03b1 \u00d7 \u03b2 := \u03bbp, (p.1, p.2) in\nlet f' : (\u03a3a:\u03b1, \u03b2) \u2192 ennreal := \u03bbp, f p.1 p.2 in\ncalc (\u2211p:\u03b1\u00d7\u03b2, f' (j p)) = (\u2211p:\u03a3a:\u03b1, \u03b2, f p.1 p.2) :\n    tsum_eq_tsum_of_iso j i (assume \u27e8a, b\u27e9, rfl) (assume \u27e8a, b\u27e9, rfl)\n   ... = (\u2211a, \u2211b, f a b) : ennreal.tsum_sigma f\n\nprotected lemma tsum_comm {f : \u03b1 \u2192 \u03b2 \u2192 ennreal} : (\u2211a, \u2211b, f a b) = (\u2211b, \u2211a, f a b) :=\nlet f' : \u03b1\u00d7\u03b2 \u2192 ennreal := \u03bbp, f p.1 p.2 in\ncalc (\u2211a, \u2211b, f a b) = (\u2211p:\u03b1\u00d7\u03b2, f' p) : ennreal.tsum_prod.symm\n  ... = (\u2211p:\u03b2\u00d7\u03b1, f' (prod.swap p)) :\n    (tsum_eq_tsum_of_iso prod.swap (@prod.swap \u03b1 \u03b2) (assume \u27e8a, b\u27e9, rfl) (assume \u27e8a, b\u27e9, rfl)).symm\n  ... = (\u2211b, \u2211a, f' (prod.swap (b, a))) : @ennreal.tsum_prod \u03b2 \u03b1 (\u03bbb a, f' (prod.swap (b, a)))\n\nprotected lemma tsum_add : (\u2211a, f a + g a) = (\u2211a, f a) + (\u2211a, g a) :=\ntsum_add ennreal.has_sum ennreal.has_sum\n\nprotected lemma tsum_le_tsum (h : \u2200a, f a \u2264 g a) : (\u2211a, f a) \u2264 (\u2211a, g a) :=\ntsum_le_tsum h ennreal.has_sum ennreal.has_sum\n\nprotected lemma tsum_eq_supr_nat {f : \u2115 \u2192 ennreal} :\n  (\u2211i:\u2115, f i) = (\u2a06i:\u2115, (finset.range i).sum f) :=\ncalc _ = (\u2a06s:finset \u2115, s.sum f) : ennreal.tsum_eq_supr_sum\n  ... = (\u2a06i:\u2115, (finset.range i).sum f) : le_antisymm\n    (supr_le_supr2 $ assume s,\n      let \u27e8n, hn\u27e9 := finset.exists_nat_subset_range s in\n      \u27e8n, finset.sum_le_sum_of_subset hn\u27e9)\n    (supr_le_supr2 $ assume i, \u27e8finset.range i, le_refl _\u27e9)\n\nprotected lemma le_tsum (a : \u03b1) : f a \u2264 (\u2211a, f a) :=\ncalc f a = ({a} : finset \u03b1).sum f : by simp\n  ... \u2264 (\u2a06s:finset \u03b1, s.sum f) : le_supr (\u03bbs:finset \u03b1, s.sum f) _\n  ... = (\u2211a, f a) : by rw [ennreal.tsum_eq_supr_sum]\n\nprotected lemma mul_tsum : (\u2211i, a * f i) = a * (\u2211i, f i) :=\nif h : \u2200i, f i = 0 then by simp [h] else\nlet \u27e8i, (hi : f i \u2260 0)\u27e9 := classical.not_forall.mp h in\nhave sum_ne_0 : (\u2211i, f i) \u2260 0, from ne_of_gt $\n  calc 0 < f i : lt_of_le_of_ne (zero_le _) hi.symm\n    ... \u2264 (\u2211i, f i) : ennreal.le_tsum _,\nhave tendsto (\u03bbs:finset \u03b1, s.sum ((*) a \u2218 f)) at_top (nhds (a * (\u2211i, f i))),\n  by rw [\u2190 show (*) a \u2218 (\u03bbs:finset \u03b1, s.sum f) = \u03bbs, s.sum ((*) a \u2218 f),\n         from funext $ \u03bb 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 : (\u2211i, f i * a) = (\u2211i, f i) * a :=\nby simp [mul_comm, ennreal.mul_tsum]\n\n@[simp] lemma tsum_supr_eq {\u03b1 : Type*} (a : \u03b1) {f : \u03b1 \u2192 ennreal} :\n  (\u2211b:\u03b1, \u2a06 (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 (\u03bbb, \u2a06 (h : a = b), f b) \u2264 (finset.singleton a).sum (\u03bbb, \u2a06 (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 \u2264 (\u2a06 (h : a = a), f a) : le_supr (\u03bbh:a=a, f a) rfl\n    ... \u2264 (\u2211b:\u03b1, \u2a06 (h : a = b), f b) : ennreal.le_tsum _)\n\nlemma is_sum_iff_tendsto_nat {f : \u2115 \u2192 ennreal} (r : ennreal) :\n  is_sum f r \u2194 tendsto (\u03bbn:\u2115, (finset.range n).sum f) at_top (nhds r) :=\nbegin\n  refine \u27e8tendsto_sum_nat_of_is_sum, assume h, _\u27e9,\n  rw [\u2190 supr_eq_of_tendsto _ h, \u2190 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 : \u03b2 \u2192 nnreal} {r : nnreal}\n  (hgf : \u2200b, g b \u2264 f b) (hfr : is_sum f r) : \u2203p\u2264r, is_sum g p :=\nhave (\u2211b, (g b : ennreal)) \u2264 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 \u27e8p, eq, hpr\u27e9 := ennreal.le_coe_iff.1 this in\n\u27e8p, hpr, ennreal.is_sum_coe.1 $ eq \u25b8 is_sum_tsum ennreal.has_sum\u27e9\n\nlemma has_sum_of_le {f g : \u03b2 \u2192 nnreal} (hgf : \u2200b, g b \u2264 f b) : has_sum f \u2192 has_sum g\n| \u27e8r, hfr\u27e9 := let \u27e8p, _, hp\u27e9 := exists_le_is_sum_of_le hgf hfr in has_sum_spec hp\n\nlemma is_sum_iff_tendsto_nat {f : \u2115 \u2192 nnreal} (r : nnreal) :\n  is_sum f r \u2194 tendsto (\u03bbn:\u2115, (finset.range n).sum f) at_top (nhds r) :=\nbegin\n  rw [\u2190 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 : \u03b2 \u2192 \u211d}\n  (hg : \u2200b, 0 \u2264 g b) (hgf : \u2200b, g b \u2264 f b) (hf : has_sum f) : has_sum g :=\nlet f' (b : \u03b2) : nnreal := \u27e8f b, le_trans (hg b) (hgf b)\u27e9 in\nlet g' (b : \u03b2) : nnreal := \u27e8g b, hg b\u27e9 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 (\u03bbb, g' b : \u03b2 \u2192 \u211d), from nnreal.has_sum_coe.2 this\n\nlemma is_sum_iff_tendsto_nat_of_nonneg {f : \u2115 \u2192 \u211d} (hf : \u2200i, 0 \u2264 f i) (r : \u211d) :\n  is_sum f r \u2194 tendsto (\u03bbn:\u2115, (finset.range n).sum f) at_top (nhds r) :=\n\u27e8tendsto_sum_nat_of_is_sum,\n  assume hfr,\n  have 0 \u2264 r := ge_of_tendsto at_top_ne_bot hfr $ univ_mem_sets' $ assume i,\n    show 0 \u2264 (finset.range i).sum f, from finset.zero_le_sum $ assume i _, hf i,\n  let f' (n : \u2115) : nnreal := \u27e8f n, hf n\u27e9, r' : nnreal := \u27e8r, this\u27e9 in\n  have f_eq : f = (\u03bbi:\u2115, (f' i : \u211d)) := 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, \u2190 nnreal.tendsto_coe],\n    simp only [nnreal.sum_coe],\n    exact hfr\n  end\u27e9\n\nlemma infi_real_pos_eq_infi_nnreal_pos {\u03b1 : Type*} [complete_lattice \u03b1] {f : \u211d \u2192 \u03b1} :\n  (\u2a05(n:\u211d) (h : n > 0), f n) = (\u2a05(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 \u27e8r, le_of_lt hr\u27e9 $ infi_le _ hr)\n\nsection\nvariables [emetric_space \u03b2]\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 : \u03b2} {r : ennreal} (x y : ball a r) : edist x.1 y.1 \u2260 \u22a4 :=\nlt_top_iff_ne_top.1 $\ncalc edist x y \u2264 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  ... \u2264 \u22a4 : 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 : \u03b2) (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 : \u03b2) (r : ennreal) (h : x \u2208 ball a r) :\n  nhds x = map (coe : ball a r \u2192 \u03b2) (nhds \u27e8x, h\u27e9) :=\n(map_nhds_subtype_val_eq _ $ mem_nhds_sets emetric.is_open_ball h).symm\nend\n\nsection\nvariable [emetric_space \u03b1]\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 \u03b2] [semilattice_sup \u03b2] {s : \u03b2 \u2192 \u03b1} :\n  cauchy_seq s \u2194 (\u2203 (b: \u03b2 \u2192 ennreal), (\u2200 n m N : \u03b2, N \u2264 n \u2192 N \u2264 m \u2192 edist (s n) (s m) \u2264 b N)\n                    \u2227 (tendsto b at_top (nhds 0))) :=\n\u27e8begin\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 \u2265 N`-/\n  let b := \u03bbN, Sup ((\u03bb(p : \u03b2 \u00d7 \u03b2), edist (s p.1) (s p.2))''{p | p.1 \u2265 N \u2227 p.2 \u2265 N}),\n  --Prove that it bounds the distances of points in the Cauchy sequence\n  have C : \u2200 n m N, N \u2264 n \u2192 N \u2264 m \u2192 edist (s n) (s m) \u2264 b N,\n  { refine \u03bbm 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 \u27e8hm, hn\u27e9 },\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 \u27e8\u03bba ha, absurd ha (ennreal.not_lt_zero), \u03bb\u03b5 \u03b5pos, _\u27e9,\n    rcases dense \u03b5pos with \u27e8\u03b4, \u03b4pos, \u03b4lt\u27e9,\n    rcases hs \u03b4 \u03b4pos with \u27e8N, hN\u27e9,\n    refine filter.mem_at_top_sets.2 \u27e8N, \u03bbn hn, _\u27e9,\n    have : b n \u2264 \u03b4 := 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 \u2190 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 \u03b4lt },\n  -- Conclude\n  exact \u27e8b, \u27e8C, D\u27e9\u27e9\nend,\nbegin\n  rintros \u27e8b, \u27e8b_bound, b_lim\u27e9\u27e9,\n  /-b : \u2115 \u2192 \u211d, b_bound : \u2200 (n m N : \u2115), N \u2264 n \u2192 N \u2264 m \u2192 edist (s n) (s m) \u2264 b N,\n    b_lim : tendsto b at_top (nhds 0)-/\n  refine emetric.cauchy_seq_iff.2 (\u03bb\u03b5 \u03b5pos, _),\n  have : {n | b n < \u03b5} \u2208 at_top := (tendsto_orderable.1 b_lim ).2 _ \u03b5pos,\n  rcases filter.mem_at_top_sets.1 this with \u27e8N, hN\u27e9,\n  exact \u27e8N, \u03bbm n hm hn, calc\n    edist (s n) (s m) \u2264 b N : b_bound n m N hn hm\n    ... < \u03b5 : (hN _ (le_refl N)) \u27e9\nend\u27e9\n\nlemma continuous_of_le_add_edist {f : \u03b1 \u2192 ennreal} (C : ennreal)\n  (hC : C \u2260 \u22a4) (h : \u2200x y, f x \u2264 f y + C * edist x y) : continuous f :=\nbegin\n  refine continuous_iff_continuous_at.2 (\u03bbx, tendsto_orderable.2 \u27e8_, _\u27e9),\n  show \u2200e, e < f x \u2192 {y : \u03b1 | e < f y} \u2208 nhds x,\n  { assume e he,\n    let \u03b5 := min (f x - e) 1,\n    have : \u03b5 < \u22a4 := lt_of_le_of_lt (min_le_right _ _) (by simp [lt_top_iff_ne_top]),\n    have : 0 < \u03b5 := by simp [\u03b5, hC, he, ennreal.zero_lt_one],\n    have : 0 < C\u207b\u00b9 * (\u03b5/2) := bot_lt_iff_ne_bot.2 (by simp [hC, (ne_of_lt this).symm, ennreal.mul_eq_zero]),\n    have I : C * (C\u207b\u00b9 * (\u03b5/2)) < \u03b5,\n    { by_cases C_zero : C = 0,\n      { simp [C_zero, \u20390 < \u03b5\u203a] },\n      { calc C * (C\u207b\u00b9 * (\u03b5/2)) = (C * C\u207b\u00b9) * (\u03b5/2) : by simp [mul_assoc]\n        ... = \u03b5/2 : by simp [ennreal.mul_inv_cancel C_zero hC]\n        ... < \u03b5 : ennreal.half_lt_self (bot_lt_iff_ne_bot.1 \u20390 < \u03b5\u203a) (lt_top_iff_ne_top.1 \u2039\u03b5 < \u22a4\u203a) }},\n    have : ball x (C\u207b\u00b9 * (\u03b5/2)) \u2286 {y : \u03b1 | e < f y},\n    { rintros y hy,\n      by_cases htop : f y = \u22a4,\n      { simp [htop, lt_top_iff_ne_top, ne_top_of_lt he] },\n      { simp at hy,\n        have : e + \u03b5 < f y + \u03b5 := calc\n          e + \u03b5 \u2264 e + (f x - e) : add_le_add_left' (min_le_left _ _)\n          ... = f x : by simp [le_of_lt he]\n          ... \u2264 f y + C * edist x y : h x y\n          ... = f y + C * edist y x : by simp [edist_comm]\n          ... \u2264 f y + C * (C\u207b\u00b9 * (\u03b5/2)) :\n            add_le_add_left' $ canonically_ordered_semiring.mul_le_mul (le_refl _) (le_of_lt hy)\n          ... < f y + \u03b5 : (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 \u2039\u03b5 < \u22a4\u203a).1 this }},\n    apply filter.mem_sets_of_superset (ball_mem_nhds _ (\u20390 < C\u207b\u00b9 * (\u03b5/2)\u203a)) this },\n  show \u2200e, f x < e \u2192 {y : \u03b1 | f y < e} \u2208 nhds x,\n  { assume e he,\n    let \u03b5 := min (e - f x) 1,\n    have : \u03b5 < \u22a4 := lt_of_le_of_lt (min_le_right _ _) (by simp [lt_top_iff_ne_top]),\n    have : 0 < \u03b5 := by simp [\u03b5, he, ennreal.zero_lt_one],\n    have : 0 < C\u207b\u00b9 * (\u03b5/2) := bot_lt_iff_ne_bot.2 (by simp [hC, (ne_of_lt this).symm, ennreal.mul_eq_zero]),\n    have I : C * (C\u207b\u00b9 * (\u03b5/2)) < \u03b5,\n    { by_cases C_zero : C = 0,\n      simp [C_zero, \u20390 < \u03b5\u203a],\n      calc C * (C\u207b\u00b9 * (\u03b5/2)) = (C * C\u207b\u00b9) * (\u03b5/2) : by simp [mul_assoc]\n        ... = \u03b5/2 : by simp [ennreal.mul_inv_cancel C_zero hC]\n        ... < \u03b5 : ennreal.half_lt_self (bot_lt_iff_ne_bot.1 \u20390 < \u03b5\u203a) (lt_top_iff_ne_top.1 \u2039\u03b5 < \u22a4\u203a) },\n    have : ball x (C\u207b\u00b9 * (\u03b5/2)) \u2286 {y : \u03b1 | f y < e},\n    { rintros y hy,\n      have htop : f x \u2260 \u22a4 := ne_top_of_lt he,\n      show f y < e, from calc\n        f y \u2264 f x + C * edist y x : h y x\n        ... \u2264 f x + C * (C\u207b\u00b9 * (\u03b5/2)) :\n            add_le_add_left' $ canonically_ordered_semiring.mul_le_mul (le_refl _) (le_of_lt hy)\n        ... < f x + \u03b5 : (ennreal.add_lt_add_iff_left (lt_top_iff_ne_top.2 htop)).2 I\n        ... \u2264 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 _ (\u20390 < C\u207b\u00b9 * (\u03b5/2)\u203a)) this },\nend\n\ntheorem continuous_edist' : continuous (\u03bbp:\u03b1\u00d7\u03b1, edist p.1 p.2) :=\nbegin\n  apply continuous_of_le_add_edist 2 (by simp),\n  rintros \u27e8x, y\u27e9 \u27e8x', y'\u27e9,\n  calc edist x y \u2264 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    ... \u2264 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 [\u2190 mul_two, mul_comm]\nend\n\ntheorem continuous_edist [topological_space \u03b2] {f g : \u03b2 \u2192 \u03b1}\n  (hf : continuous f) (hg : continuous g) : continuous (\u03bbb, edist (f b) (g b)) :=\n(hf.prod_mk hg).comp continuous_edist'\n\ntheorem tendsto_edist {f g : \u03b2 \u2192 \u03b1} {x : filter \u03b2} {a b : \u03b1}\n  (hf : tendsto f x (nhds a)) (hg : tendsto g x (nhds b)) :\n  tendsto (\u03bbx, edist (f x) (g x)) x (nhds (edist a b)) :=\nhave tendsto (\u03bbp:\u03b1\u00d7\u03b1, 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 \u03b1` 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 {\u03b1 : Type _} {\u03b2 : \u03b1 \u2192 Type _}\n\nnamespace Multiset\n\nvariable [DecidableEq \u03b1] (f g : Multiset \u03b1)\n\ninstance : LocallyFiniteOrder (Multiset \u03b1) :=\n  LocallyFiniteOrder.ofIcc (Multiset \u03b1)\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Multiset.{u1} \u03b1)) (Finset.Icc.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1)) (Multiset.locallyFiniteOrder.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g) (Finset.map.{u1, u1} (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (Multiset.{u1} \u03b1) (Equiv.toEmbedding.{succ u1, succ u1} (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (Multiset.{u1} \u03b1) (Equiv.symm.{succ u1, succ u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (AddEquiv.toEquiv.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (Multiset.hasAdd.{u1} \u03b1) (AddZeroClass.toHasAdd.{u1} (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.equivDfinsupp.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b))))) (Finset.Icc.{u1} (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (Dfinsupp.preorder.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero) (fun (i : \u03b1) => PartialOrder.toPreorder.{0} Nat (OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)))) (Dfinsupp.locallyFiniteOrder.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (i : \u03b1) (a : Nat) (b : Nat) => Nat.decidableEq a b) (fun (i : \u03b1) => OrderedCancelAddCommMonoid.toPartialOrder.{0} Nat (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{0} Nat Nat.strictOrderedSemiring)) (fun (i : \u03b1) => Nat.hasZero) (fun (i : \u03b1) => Nat.locallyFiniteOrder)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (fun (_x : AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) => (Multiset.{u1} \u03b1) -> (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero))) (AddMonoidHom.hasCoeToFun.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.toDfinsupp.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (fun (_x : AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) => (Multiset.{u1} \u03b1) -> (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero))) (AddMonoidHom.hasCoeToFun.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => Nat.hasZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.orderedCancelAddCommMonoid.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.toDfinsupp.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) g)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{succ u1} (Finset.{u1} (Multiset.{u1} \u03b1)) (Finset.Icc.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g) (Finset.map.{u1, u1} (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Multiset.{u1} \u03b1) (Equiv.toEmbedding.{succ u1, succ u1} (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Multiset.{u1} \u03b1) (Equiv.symm.{succ u1, succ u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddEquiv.toEquiv.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Multiset.instAddMultiset.{u1} \u03b1) (Dfinsupp.instAddDfinsuppToZero.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.equivDfinsupp.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b))))) (Finset.Icc.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) f) (Dfinsupp.instPreorderDfinsupp.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero) (fun (i : \u03b1) => PartialOrder.toPreorder.{0} Nat (StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring))) (Dfinsupp.instLocallyFiniteOrderDfinsuppInstPreorderDfinsuppToPreorder.{u1, 0} \u03b1 (fun (a : \u03b1) => Nat) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (fun (i : \u03b1) (a : Nat) (b : Nat) => instDecidableEqNat a b) (fun (i : \u03b1) => StrictOrderedSemiring.toPartialOrder.{0} Nat Nat.strictOrderedSemiring) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero) (fun (i : \u03b1) => instLocallyFiniteOrderNatToPreorderToPartialOrderStrictOrderedSemiring)) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{u1} (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHom.addMonoidHomClass.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))))) (Multiset.toDfinsupp.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f) (FunLike.coe.{succ u1, succ u1, succ u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} \u03b1) (fun (_x : Multiset.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} \u03b1) => Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) _x) (AddHomClass.toFunLike.{u1, u1, u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddZeroClass.toAdd.{u1} (Multiset.{u1} \u03b1) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1))))))) (AddZeroClass.toAdd.{u1} (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (AddMonoidHomClass.toAddHomClass.{u1, u1, u1} (AddMonoidHom.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))) (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHom.addMonoidHomClass.{u1, u1} (Multiset.{u1} \u03b1) (Dfinsupp.{u1, 0} \u03b1 (fun (_a : \u03b1) => Nat) (fun (i : \u03b1) => LinearOrderedCommMonoidWithZero.toZero.{0} ((fun (_a : \u03b1) => Nat) i) Nat.linearOrderedCommMonoidWithZero)) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} \u03b1) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} \u03b1) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} \u03b1) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} \u03b1) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} \u03b1)))))) (Dfinsupp.addZeroClass'.{u1, 0} \u03b1 Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid))))) (Multiset.toDfinsupp.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) g)))\nCase conversion may be inaccurate. Consider using '#align multiset.Icc_eq Multiset.Icc_eq\u2093'. -/\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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Icc.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1)) (Multiset.locallyFiniteOrder.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g)) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) g)) (fun (i : \u03b1) => 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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) i f)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Icc.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g)) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.instUnionFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) g)) (fun (i : \u03b1) => 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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Multiset.count.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) i f)))\nCase conversion may be inaccurate. Consider using '#align multiset.card_Icc Multiset.card_Icc\u2093'. -/\ntheorem card_Icc :\n    (Finset.Icc f g).card = \u220f i in f.toFinset \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Ico.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1)) (Multiset.locallyFiniteOrder.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) g)) (fun (i : \u03b1) => 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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Ico.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.instUnionFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) g)) (fun (i : \u03b1) => 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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Multiset.count.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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\u2093'. -/\ntheorem card_Ico :\n    (Finset.Ico f g).card = (\u220f i in f.toFinset \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Ioc.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1)) (Multiset.locallyFiniteOrder.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) g)) (fun (i : \u03b1) => 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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Ioc.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.instUnionFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) g)) (fun (i : \u03b1) => 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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Multiset.count.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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\u2093'. -/\ntheorem card_Ioc :\n    (Finset.Ioc f g).card = (\u220f i in f.toFinset \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Ioo.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1)) (Multiset.locallyFiniteOrder.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) g)) (fun (i : \u03b1) => 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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1) (g : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Ioo.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1)) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) f g)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.instUnionFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) g)) (fun (i : \u03b1) => 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} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) i g) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))) (Multiset.count.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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\u2093'. -/\ntheorem card_Ioo :\n    (Finset.Ioo f g).card = (\u220f i in f.toFinset \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Iic.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1)) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.partialOrder.{u1} \u03b1)) (Multiset.orderBot.{u1} \u03b1) (Multiset.locallyFiniteOrder.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b))) f)) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (fun (i : \u03b1) => HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Multiset.count.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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 {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (f : Multiset.{u1} \u03b1), Eq.{1} Nat (Finset.card.{u1} (Multiset.{u1} \u03b1) (Finset.Iic.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1)) (Finset.LocallyFiniteOrder.toLocallyFiniteOrderBot.{u1} (Multiset.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Multiset.{u1} \u03b1) (Multiset.instPartialOrderMultiset.{u1} \u03b1)) (Multiset.instOrderBotMultisetToLEToPreorderInstPartialOrderMultiset.{u1} \u03b1) (Multiset.instLocallyFiniteOrderMultisetToPreorderInstPartialOrderMultiset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b))) f)) (Finset.prod.{0, u1} Nat \u03b1 Nat.commMonoid (Multiset.toFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) f) (fun (i : \u03b1) => HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Multiset.count.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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\u2093'. -/\ntheorem card_Iic : (Finset.Iic f).card = \u220f 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\ud835\udce4 X` on `X \u00d7 X` satisfying some conditions\nwhich makes it reasonable to say that `\u2200\u1da0 (p : X \u00d7 X) in \ud835\udce4 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 \u2208 \ud835\udce4 X \u2194 \u2203 \u03b5 > 0, { p | dist p.1 p.2 < \u03b5 } \u2286 V`\n* If `G` is an additive topological group, `V \u2208 \ud835\udce4 G \u2194 \u2203 U \u2208 \ud835\udcdd (0 : G), {p | p.2 - p.1 \u2208 U} \u2286 V`\n\nThose examples are generalizations in two different directions of the elementary example where\n`X = \u211d` and `V \u2208 \ud835\udce4 \u211d \u2194 \u2203 \u03b5 > 0, { p | |p.2 - p.1| < \u03b5 } \u2286 V` which features both the topological\ngroup structure on `\u211d` and its metric space structure.\n\nEach uniform structure on `X` induces a topology on `X` characterized by\n\n> `nhds_eq_comap_uniformity : \u2200 {x : X}, \ud835\udcdd x = comap (prod.mk x) (\ud835\udce4 X)`\n\nwhere `prod.mk x : X \u2192 X \u00d7 X := (\u03bb 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) \u2208 V` for some `V \u2208 \ud835\udce4 X`\n* a ball `ball x r` roughly corresponds to `uniform_space.ball x V := {y | (x, y) \u2208 V}`\n  for some `V \u2208 \ud835\udce4 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 \u2194 \u2200 x \u2208 s, \u2203 V \u2208 \ud835\udce4 X, ball x V \u2286 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`\u2200 (x y z : X) (r r' : \u211d), dist x y \u2264 r \u2192 dist y z \u2264 r' \u2192 dist x z \u2264 r + r'`.\nThen, for any `V` and `W` with type `set (X \u00d7 X)`, the composition `V \u25cb W : set (X \u00d7 X)` is\ndefined as `{ p : X \u00d7 X | \u2203 z, (p.1, z) \u2208 V \u2227 (z, p.2) \u2208 W }`.\nIn the metric space case, if `V = { p | dist p.1 p.2 \u2264 r }` and `W = { p | dist p.1 p.2 \u2264 r' }`\nthen the triangle inequality, as reformulated above, says `V \u25cb W` is contained in\n`{p | dist p.1 p.2 \u2264 r + r'}` which is the entourage associated to the radius `r + r'`.\nIn general we have `mem_ball_comp (h : y \u2208 ball x V) (h' : z \u2208 ball y W) : z \u2208 ball x (V \u25cb 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 `\ud835\udce4 X` to satisfy the following:\n* every `V \u2208 \ud835\udce4 X` contains the diagonal `id_rel = { p | p.1 = p.2 }`. This abstracts the fact\n  that `dist x x \u2264 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 \u2208 \ud835\udce4 X \u2192 prod.swap '' V \u2208 \ud835\udce4 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* `\u2200 V \u2208 \ud835\udce4 X, \u2203 W \u2208 \ud835\udce4 X, W \u25cb W \u2286 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##\u00a0Main 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 : \u03b1 \u2192 \u03b2` between uniform spaces\n  is uniformly continuous : `\u2200 r \u2208 \ud835\udce4 \u03b2, \u2200\u1da0 (x : \u03b1 \u00d7 \u03b1) in \ud835\udce4 \u03b1, (f x.1, f x.2) \u2208 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 `\ud835\udce4 X` for the uniformity on a uniform space `X`,\nand `\u25cb` for composition of relations, seen as terms with type `set (X \u00d7 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 (\u03b1 \u03b2 : Type*) := \u03b1 \u2192 \u03b2 \u2192 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 (\u03b1 \u00d7 \u03b1)`\ninstead of `rel \u03b1 \u03b1` because we really need sets to use the filter library, and elements\nof filters on `\u03b1 \u00d7 \u03b1` have type `set (\u03b1 \u00d7 \u03b1)`.\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 (\u03b1 \u00d7 \u03b1)`\n-/\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*} {\u03b9 : Sort*}\n\n/-- The identity relation, or the graph of the identity function -/\ndef id_rel {\u03b1 : Type*} := {p : \u03b1 \u00d7 \u03b1 | p.1 = p.2}\n\n@[simp] theorem mem_id_rel {a b : \u03b1} : (a, b) \u2208 @id_rel \u03b1 \u2194 a = b := iff.rfl\n\n@[simp] theorem id_rel_subset {s : set (\u03b1 \u00d7 \u03b1)} : id_rel \u2286 s \u2194 \u2200 a, (a, a) \u2208 s :=\nby simp [subset_def]; exact forall_congr (\u03bb a, by simp)\n\n/-- The composition of relations -/\ndef comp_rel {\u03b1 : Type u} (r\u2081 r\u2082 : set (\u03b1\u00d7\u03b1)) := {p : \u03b1 \u00d7 \u03b1 | \u2203z:\u03b1, (p.1, z) \u2208 r\u2081 \u2227 (z, p.2) \u2208 r\u2082}\n\nlocalized \"infix (name := uniformity.comp_rel) ` \u25cb `:55 := comp_rel\" in uniformity\n\n@[simp] theorem mem_comp_rel {r\u2081 r\u2082 : set (\u03b1\u00d7\u03b1)}\n  {x y : \u03b1} : (x, y) \u2208 r\u2081 \u25cb r\u2082 \u2194 \u2203 z, (x, z) \u2208 r\u2081 \u2227 (z, y) \u2208 r\u2082 := iff.rfl\n\n@[simp] theorem swap_id_rel : prod.swap '' id_rel = @id_rel \u03b1 :=\nset.ext $ assume \u27e8a, b\u27e9, by simp [image_swap_eq_preimage_swap]; exact eq_comm\n\ntheorem monotone.comp_rel [preorder \u03b2] {f g : \u03b2 \u2192 set (\u03b1\u00d7\u03b1)}\n  (hf : monotone f) (hg : monotone g) : monotone (\u03bbx, (f x) \u25cb (g x)) :=\nassume a b h p \u27e8z, h\u2081, h\u2082\u27e9, \u27e8z, hf h h\u2081, hg h h\u2082\u27e9\n\n@[mono]\nlemma comp_rel_mono {f g h k: set (\u03b1\u00d7\u03b1)} (h\u2081 : f \u2286 h) (h\u2082 : g \u2286 k) : f \u25cb g \u2286 h \u25cb k :=\n\u03bb \u27e8x, y\u27e9 \u27e8z, h, h'\u27e9, \u27e8z, h\u2081 h, h\u2082 h'\u27e9\n\nlemma prod_mk_mem_comp_rel {a b c : \u03b1} {s t : set (\u03b1\u00d7\u03b1)} (h\u2081 : (a, c) \u2208 s) (h\u2082 : (c, b) \u2208 t) :\n  (a, b) \u2208 s \u25cb t :=\n\u27e8c, h\u2081, h\u2082\u27e9\n\n@[simp] lemma id_comp_rel {r : set (\u03b1\u00d7\u03b1)} : id_rel \u25cb r = r :=\nset.ext $ assume \u27e8a, b\u27e9, by simp\n\nlemma comp_rel_assoc {r s t : set (\u03b1\u00d7\u03b1)} :\n  (r \u25cb s) \u25cb t = r \u25cb (s \u25cb t) :=\nby ext p; cases p; simp only [mem_comp_rel]; tauto\n\nlemma left_subset_comp_rel {s t : set (\u03b1 \u00d7 \u03b1)} (h : id_rel \u2286 t) : s \u2286 s \u25cb t :=\n\u03bb \u27e8x, y\u27e9 xy_in, \u27e8y, xy_in, h $ by exact rfl\u27e9\n\nlemma right_subset_comp_rel {s t : set (\u03b1 \u00d7 \u03b1)} (h : id_rel \u2286 s) : t \u2286 s \u25cb t :=\n\u03bb \u27e8x, y\u27e9 xy_in, \u27e8x, h $ by exact rfl, xy_in\u27e9\n\nlemma subset_comp_self {s : set (\u03b1 \u00d7 \u03b1)} (h : id_rel \u2286 s) : s \u2286 s \u25cb s :=\nleft_subset_comp_rel h\n\nlemma subset_iterate_comp_rel {s t : set (\u03b1 \u00d7 \u03b1)} (h : id_rel \u2286 s) (n : \u2115) :\n  t \u2286 (((\u25cb) 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 (\u03b1 \u00d7 \u03b1)) : Prop := prod.swap \u207b\u00b9' V = V\n\n/-- The maximal symmetric relation contained in a given relation. -/\ndef symmetrize_rel (V : set (\u03b1 \u00d7 \u03b1)) : set (\u03b1 \u00d7 \u03b1) := V \u2229 prod.swap \u207b\u00b9' V\n\nlemma symmetric_symmetrize_rel (V : set (\u03b1 \u00d7 \u03b1)) : symmetric_rel (symmetrize_rel V) :=\nby simp [symmetric_rel, symmetrize_rel, preimage_inter, inter_comm, \u2190 preimage_comp]\n\nlemma symmetrize_rel_subset_self (V : set (\u03b1 \u00d7 \u03b1)) : symmetrize_rel V \u2286 V :=\nsep_subset _ _\n\n@[mono]\nlemma symmetrize_mono {V W: set (\u03b1 \u00d7 \u03b1)} (h : V \u2286 W) : symmetrize_rel V \u2286 symmetrize_rel W :=\ninter_subset_inter h $ preimage_mono h\n\nlemma symmetric_rel.mk_mem_comm {V : set (\u03b1 \u00d7 \u03b1)} (hV : symmetric_rel V) {x y : \u03b1} :\n  (x, y) \u2208 V \u2194 (y, x) \u2208 V :=\nset.ext_iff.1 hV (y, x)\n\nlemma symmetric_rel.eq {U : set (\u03b1 \u00d7 \u03b1)} (hU : symmetric_rel U) : prod.swap \u207b\u00b9' U = U := hU\n\nlemma symmetric_rel.inter {U V : set (\u03b1 \u00d7 \u03b1)} (hU : symmetric_rel U) (hV : symmetric_rel V) :\n  symmetric_rel (U \u2229 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 (\u03b1 : Type u) :=\n(uniformity : filter (\u03b1 \u00d7 \u03b1))\n(refl       : \ud835\udcdf id_rel \u2264 uniformity)\n(symm       : tendsto prod.swap uniformity uniformity)\n(comp       : uniformity.lift' (\u03bbs, s \u25cb s) \u2264 uniformity)\n\n/-- An alternative constructor for `uniform_space.core`. This version unfolds various\n`filter`-related definitions. -/\ndef uniform_space.core.mk' {\u03b1 : Type u} (U : filter (\u03b1 \u00d7 \u03b1))\n  (refl : \u2200 (r \u2208 U) x, (x, x) \u2208 r)\n  (symm : \u2200 r \u2208 U, prod.swap \u207b\u00b9' r \u2208 U)\n  (comp : \u2200 r \u2208 U, \u2203 t \u2208 U, t \u25cb t \u2286 r) : uniform_space.core \u03b1 :=\n\u27e8U, \u03bb r ru, id_rel_subset.2 (refl _ ru), symm,\n  \u03bb r ru, let \u27e8s, hs, hsr\u27e9 := comp _ ru in mem_of_superset (mem_lift' hs) hsr\u27e9\n\n/-- Defining an `uniform_space.core` from a filter basis satisfying some uniformity-like axioms. -/\ndef uniform_space.core.mk_of_basis {\u03b1 : Type u} (B : filter_basis (\u03b1 \u00d7 \u03b1))\n  (refl : \u2200 (r \u2208 B) x, (x, x) \u2208 r)\n  (symm : \u2200 r \u2208 B, \u2203 t \u2208 B, t \u2286 prod.swap \u207b\u00b9' r)\n  (comp : \u2200 r \u2208 B, \u2203 t \u2208 B, t \u25cb t \u2286 r) : uniform_space.core \u03b1 :=\n{ uniformity := B.filter,\n  refl := B.has_basis.ge_iff.mpr (\u03bb 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 {\u03b1 : Type u} (u : uniform_space.core \u03b1) :\n  topological_space \u03b1 :=\n{ is_open        := \u03bbs, \u2200x\u2208s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 u.uniformity,\n  is_open_univ   := by simp; intro; exact univ_mem,\n  is_open_inter  :=\n    assume s t hs ht x \u27e8xs, xt\u27e9, by filter_upwards [hs x xs, ht x xt]; simp {contextual := tt},\n  is_open_sUnion :=\n    assume s hs x \u27e8t, ts, xt\u27e9, by filter_upwards [hs t ts x xt] with p ph h using \u27e8t, ts, ph h\u27e9 }\n\nlemma uniform_space.core_eq :\n  \u2200{u\u2081 u\u2082 : uniform_space.core \u03b1}, u\u2081.uniformity = u\u2082.uniformity \u2192 u\u2081 = u\u2082\n| \u27e8u\u2081, _, _, _\u27e9  \u27e8u\u2082, _, _, _\u27e9 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 `\u03b1 \u00d7 \u03b1` 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 (\u03b1 : Type u) extends topological_space \u03b1, uniform_space.core \u03b1 :=\n(is_open_uniformity : \u2200s, @_root_.is_open _ to_topological_space s \u2194\n  (\u2200x\u2208s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 uniformity))\n\n/-- Alternative constructor for `uniform_space \u03b1` when a topology is already given. -/\n@[pattern] def uniform_space.mk' {\u03b1} (t : topological_space \u03b1)\n  (c : uniform_space.core \u03b1)\n  (is_open_uniformity : \u2200s:set \u03b1, is_open s \u2194\n    (\u2200x\u2208s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 c.uniformity)) :\n  uniform_space \u03b1 := \u27e8c, is_open_uniformity\u27e9\n\n/-- Construct a `uniform_space` from a `uniform_space.core`. -/\ndef uniform_space.of_core {\u03b1 : Type u} (u : uniform_space.core \u03b1) : uniform_space \u03b1 :=\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 {\u03b1 : Type u} (u : uniform_space.core \u03b1) (t : topological_space \u03b1)\n  (h : t = u.to_topological_space) : uniform_space \u03b1 :=\n{ to_core := u,\n  to_topological_space := t,\n  is_open_uniformity := assume a, h.symm \u25b8 iff.rfl }\n\nlemma uniform_space.to_core_to_topological_space (u : uniform_space \u03b1) :\n  u.to_core.to_topological_space = u.to_topological_space :=\ntopological_space_eq $ funext $ \u03bb s, by rw [uniform_space.is_open_uniformity, is_open_mk]\n\n/-- The uniformity is a filter on \u03b1 \u00d7 \u03b1 (inferred from an ambient uniform space\n  structure on \u03b1). -/\ndef uniformity (\u03b1 : Type u) [uniform_space \u03b1] : filter (\u03b1 \u00d7 \u03b1) :=\n  (@uniform_space.to_core \u03b1 _).uniformity\n\nlocalized \"notation (name := uniformity_of) `\ud835\udce4[` u `]` := @uniformity hole! u\" in topology\n\n@[ext]\nlemma uniform_space_eq : \u2200 {u\u2081 u\u2082 : uniform_space \u03b1}, \ud835\udce4[u\u2081] = \ud835\udce4[u\u2082] \u2192 u\u2081 = u\u2082\n| (uniform_space.mk' t\u2081 u\u2081 o\u2081)  (uniform_space.mk' t\u2082 u\u2082 o\u2082) h :=\n  have u\u2081 = u\u2082, from uniform_space.core_eq h,\n  have t\u2081 = t\u2082, from topological_space_eq $ funext $ assume s, by rw [o\u2081, o\u2082]; simp [this],\n  by simp [*]\n\nlemma uniform_space.of_core_eq_to_core\n  (u : uniform_space \u03b1) (t : topological_space \u03b1) (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 {\u03b1 : Type*} [i : topological_space \u03b1]\n  (u : uniform_space \u03b1) (h : i = u.to_topological_space) : uniform_space \u03b1 :=\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 {\u03b1 : Type*} [i : topological_space \u03b1] (u : uniform_space \u03b1)\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 {\u03b1 \u03b2 : Type*} [ordered_add_comm_monoid \u03b2]\n  (d : \u03b1 \u2192 \u03b1 \u2192 \u03b2) (refl : \u2200 x, d x x = 0) (symm : \u2200 x y, d x y = d y x)\n  (triangle : \u2200 x y z, d x z \u2264 d x y + d y z)\n  (half : \u2200 \u03b5 > (0 : \u03b2), \u2203 \u03b4 > (0 : \u03b2), \u2200 x < \u03b4, \u2200 y < \u03b4, x + y < \u03b5) :\n  uniform_space \u03b1 :=\nuniform_space.of_core\n  { uniformity := \u2a05 r > 0, \ud835\udcdf { x | d x.1 x.2 < r },\n    refl := le_infi\u2082 $ \u03bb r hr, principal_mono.2 $ id_rel_subset.2 $ \u03bb x, by simpa [refl],\n    symm := tendsto_infi_infi $ \u03bb r, tendsto_infi_infi $ \u03bb _, tendsto_principal_principal.2 $\n      \u03bb x hx, by rwa [mem_set_of, symm],\n    comp := le_infi\u2082 $ \u03bb r hr, let \u27e8\u03b4, h0, h\u03b4r\u27e9 := half r hr in le_principal_iff.2 $ mem_of_superset\n      (mem_lift' $ mem_infi_of_mem \u03b4 $ mem_infi_of_mem h0 $ mem_principal_self _) $\n      \u03bb \u27e8x, z\u27e9 \u27e8y, h\u2081, h\u2082\u27e9, (triangle _ _ _).trans_lt (h\u03b4r _ h\u2081 _ h\u2082) }\n\nlemma uniform_space.has_basis_of_fun {\u03b1 \u03b2 : Type*} [linear_ordered_add_comm_monoid \u03b2]\n  (h\u2080 : \u2203 x : \u03b2, 0 < x) (d : \u03b1 \u2192 \u03b1 \u2192 \u03b2) (refl : \u2200 x, d x x = 0) (symm : \u2200 x y, d x y = d y x)\n  (triangle : \u2200 x y z, d x z \u2264 d x y + d y z)\n  (half : \u2200 \u03b5 > (0 : \u03b2), \u2203 \u03b4 > (0 : \u03b2), \u2200 x < \u03b4, \u2200 y < \u03b4, x + y < \u03b5) :\n  \ud835\udce4[uniform_space.of_fun d refl symm triangle half].has_basis ((<) (0 : \u03b2))\n    (\u03bb \u03b5, { x | d x.1 x.2 < \u03b5 }) :=\nhas_basis_binfi_principal'\n  (\u03bb \u03b5\u2081 h\u2081 \u03b5\u2082 h\u2082, \u27e8min \u03b5\u2081 \u03b5\u2082, lt_min h\u2081 h\u2082, \u03bb _x hx, lt_of_lt_of_le hx (min_le_left _ _),\n    \u03bb _x hx, lt_of_lt_of_le hx (min_le_right _ _)\u27e9) h\u2080\n\nsection uniform_space\nvariables [uniform_space \u03b1]\n\nlocalized \"notation (name := uniformity) `\ud835\udce4` := uniformity\" in uniformity\n\nlemma is_open_uniformity {s : set \u03b1} :\n  is_open s \u2194 (\u2200x\u2208s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 \ud835\udce4 \u03b1) :=\nuniform_space.is_open_uniformity s\n\nlemma refl_le_uniformity : \ud835\udcdf id_rel \u2264 \ud835\udce4 \u03b1 :=\n(@uniform_space.to_core \u03b1 _).refl\n\ninstance uniformity.ne_bot [nonempty \u03b1] : ne_bot (\ud835\udce4 \u03b1) :=\ndiagonal_nonempty.principal_ne_bot.mono refl_le_uniformity\n\nlemma refl_mem_uniformity {x : \u03b1} {s : set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) :\n  (x, x) \u2208 s :=\nrefl_le_uniformity h rfl\n\nlemma mem_uniformity_of_eq {x y : \u03b1} {s : set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) (hx : x = y) :\n  (x, y) \u2208 s :=\nrefl_le_uniformity h hx\n\nlemma symm_le_uniformity : map (@prod.swap \u03b1 \u03b1) (\ud835\udce4 _) \u2264 (\ud835\udce4 _) :=\n(@uniform_space.to_core \u03b1 _).symm\n\nlemma comp_le_uniformity : (\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), s \u25cb s) \u2264 \ud835\udce4 \u03b1 :=\n(@uniform_space.to_core \u03b1 _).comp\n\nlemma tendsto_swap_uniformity : tendsto (@prod.swap \u03b1 \u03b1) (\ud835\udce4 \u03b1) (\ud835\udce4 \u03b1) :=\nsymm_le_uniformity\n\nlemma comp_mem_uniformity_sets {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, t \u25cb t \u2286 s :=\nhave s \u2208 (\ud835\udce4 \u03b1).lift' (\u03bbt:set (\u03b1\u00d7\u03b1), t \u25cb t),\n  from comp_le_uniformity hs,\n(mem_lift'_sets $ monotone_id.comp_rel monotone_id).mp this\n\n/-- If `s \u2208 \ud835\udce4 \u03b1`, then for any natural `n`, for a subset `t` of a sufficiently small set in `\ud835\udce4 \u03b1`,\nwe have `t \u25cb t \u25cb ... \u25cb t \u2286 s` (`n` compositions). -/\nlemma eventually_uniformity_iterate_comp_subset {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) (n : \u2115) :\n  \u2200\u1da0 t in (\ud835\udce4 \u03b1).small_sets, ((\u25cb) t) ^[n] t \u2286 s :=\nbegin\n  suffices : \u2200\u1da0 t in (\ud835\udce4 \u03b1).small_sets, t \u2286 s \u2227 (((\u25cb) t) ^[n] t \u2286 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 \u27e8t, htU, hts\u27e9,\n  refine (ihn htU).mono (\u03bb U hU, _),\n  rw [function.iterate_succ_apply'],\n  exact \u27e8hU.1.trans $ (subset_comp_self $ refl_le_uniformity htU).trans hts,\n    (comp_rel_mono hU.1 hU.2).trans hts\u27e9\nend\n\n/-- If `s \u2208 \ud835\udce4 \u03b1`, then for any natural `n`, for a subset `t` of a sufficiently small set in `\ud835\udce4 \u03b1`,\nwe have `t \u25cb t \u2286 s`. -/\nlemma eventually_uniformity_comp_subset {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2200\u1da0 t in (\ud835\udce4 \u03b1).small_sets, t \u25cb t \u2286 s :=\neventually_uniformity_iterate_comp_subset hs 1\n\n/-- Relation `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is transitive. -/\nlemma filter.tendsto.uniformity_trans {l : filter \u03b2} {f\u2081 f\u2082 f\u2083 : \u03b2 \u2192 \u03b1}\n  (h\u2081\u2082 : tendsto (\u03bb x, (f\u2081 x, f\u2082 x)) l (\ud835\udce4 \u03b1)) (h\u2082\u2083 : tendsto (\u03bb x, (f\u2082 x, f\u2083 x)) l (\ud835\udce4 \u03b1)) :\n  tendsto (\u03bb x, (f\u2081 x, f\u2083 x)) l (\ud835\udce4 \u03b1) :=\nbegin\n  refine le_trans (le_lift'.2 $ \u03bb s hs, mem_map.2 _) comp_le_uniformity,\n  filter_upwards [h\u2081\u2082 hs, h\u2082\u2083 hs] with x hx\u2081\u2082 hx\u2082\u2083 using \u27e8_, hx\u2081\u2082, hx\u2082\u2083\u27e9,\nend\n\n/-- Relation `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is symmetric -/\nlemma filter.tendsto.uniformity_symm {l : filter \u03b2} {f : \u03b2 \u2192 \u03b1 \u00d7 \u03b1}\n  (h : tendsto f l (\ud835\udce4 \u03b1)) :\n  tendsto (\u03bb x, ((f x).2, (f x).1)) l (\ud835\udce4 \u03b1) :=\ntendsto_swap_uniformity.comp h\n\n/-- Relation `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is reflexive. -/\nlemma tendsto_diag_uniformity (f : \u03b2 \u2192 \u03b1) (l : filter \u03b2) :\n  tendsto (\u03bb x, (f x, f x)) l (\ud835\udce4 \u03b1) :=\nassume s hs, mem_map.2 $ univ_mem' $ \u03bb x, refl_mem_uniformity hs\n\nlemma tendsto_const_uniformity {a : \u03b1} {f : filter \u03b2} : tendsto (\u03bb _, (a, a)) f (\ud835\udce4 \u03b1) :=\ntendsto_diag_uniformity (\u03bb _, a) f\n\nlemma symm_of_uniformity {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, (\u2200a b, (a, b) \u2208 t \u2192 (b, a) \u2208 t) \u2227 t \u2286 s :=\nhave preimage prod.swap s \u2208 \ud835\udce4 \u03b1, from symm_le_uniformity hs,\n\u27e8s \u2229 preimage prod.swap s, inter_mem hs this, \u03bb a b \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2082, h\u2081\u27e9, inter_subset_left _ _\u27e9\n\nlemma comp_symm_of_uniformity {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, (\u2200{a b}, (a, b) \u2208 t \u2192 (b, a) \u2208 t) \u2227 t \u25cb t \u2286 s :=\nlet \u27e8t, ht\u2081, ht\u2082\u27e9 := comp_mem_uniformity_sets hs in\nlet \u27e8t', ht', ht'\u2081, ht'\u2082\u27e9 := symm_of_uniformity ht\u2081 in\n\u27e8t', ht', ht'\u2081, subset.trans (monotone_id.comp_rel monotone_id ht'\u2082) ht\u2082\u27e9\n\nlemma uniformity_le_symm : \ud835\udce4 \u03b1 \u2264 (@prod.swap \u03b1 \u03b1) <$> \ud835\udce4 \u03b1 :=\nby rw [map_swap_eq_comap_swap];\nfrom map_le_iff_le_comap.1 tendsto_swap_uniformity\n\nlemma uniformity_eq_symm : \ud835\udce4 \u03b1 = (@prod.swap \u03b1 \u03b1) <$> \ud835\udce4 \u03b1 :=\nle_antisymm uniformity_le_symm symm_le_uniformity\n\n@[simp] lemma comap_swap_uniformity : comap (@prod.swap \u03b1 \u03b1) (\ud835\udce4 \u03b1) = \ud835\udce4 \u03b1 :=\n(congr_arg _ uniformity_eq_symm).trans $ comap_map prod.swap_injective\n\nlemma symmetrize_mem_uniformity {V : set (\u03b1 \u00d7 \u03b1)} (h : V \u2208 \ud835\udce4 \u03b1) : symmetrize_rel V \u2208 \ud835\udce4 \u03b1 :=\nbegin\n  apply (\ud835\udce4 \u03b1).inter_sets h,\n  rw [\u2190 image_swap_eq_preimage_swap, uniformity_eq_symm],\n  exact image_mem_map h,\nend\n\n/-- Symmetric entourages form a basis of `\ud835\udce4 \u03b1` -/\nlemma uniform_space.has_basis_symmetric :\n  (\ud835\udce4 \u03b1).has_basis (\u03bb s : set (\u03b1 \u00d7 \u03b1), s \u2208 \ud835\udce4 \u03b1 \u2227 symmetric_rel s) id :=\nhas_basis_self.2 $ \u03bb t t_in, \u27e8symmetrize_rel t, symmetrize_mem_uniformity t_in,\n  symmetric_symmetrize_rel t, symmetrize_rel_subset_self t\u27e9\n\ntheorem uniformity_lift_le_swap {g : set (\u03b1\u00d7\u03b1) \u2192 filter \u03b2} {f : filter \u03b2} (hg : monotone g)\n  (h : (\ud835\udce4 \u03b1).lift (\u03bbs, g (preimage prod.swap s)) \u2264 f) : (\ud835\udce4 \u03b1).lift g \u2264 f :=\ncalc (\ud835\udce4 \u03b1).lift g \u2264 (filter.map (@prod.swap \u03b1 \u03b1) $ \ud835\udce4 \u03b1).lift g :\n    lift_mono uniformity_le_symm le_rfl\n  ... \u2264 _ :\n    by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]; exact h\n\nlemma uniformity_lift_le_comp {f : set (\u03b1\u00d7\u03b1) \u2192 filter \u03b2} (h : monotone f) :\n  (\ud835\udce4 \u03b1).lift (\u03bbs, f (s \u25cb s)) \u2264 (\ud835\udce4 \u03b1).lift f :=\ncalc (\ud835\udce4 \u03b1).lift (\u03bbs, f (s \u25cb s)) =\n    ((\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), s \u25cb s)).lift f :\n  begin\n    rw [lift_lift'_assoc],\n    exact monotone_id.comp_rel monotone_id,\n    exact h\n  end\n  ... \u2264 (\ud835\udce4 \u03b1).lift f : lift_mono comp_le_uniformity le_rfl\n\nlemma comp_le_uniformity3 :\n  (\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), s \u25cb (s \u25cb s)) \u2264 (\ud835\udce4 \u03b1) :=\ncalc (\ud835\udce4 \u03b1).lift' (\u03bbd, d \u25cb (d \u25cb d)) =\n  (\ud835\udce4 \u03b1).lift (\u03bbs, (\ud835\udce4 \u03b1).lift' (\u03bbt:set(\u03b1\u00d7\u03b1), s \u25cb (t \u25cb 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  ... \u2264 (\ud835\udce4 \u03b1).lift (\u03bbs, (\ud835\udce4 \u03b1).lift' (\u03bbt:set(\u03b1\u00d7\u03b1), s \u25cb t)) :\n    lift_mono' $ assume s hs, @uniformity_lift_le_comp \u03b1 _ _ (\ud835\udcdf \u2218 (\u25cb) s) $\n      monotone_principal.comp (monotone_const.comp_rel monotone_id)\n  ... = (\ud835\udce4 \u03b1).lift' (\u03bbs:set(\u03b1\u00d7\u03b1), s \u25cb 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  ... \u2264 (\ud835\udce4 \u03b1) : comp_le_uniformity\n\n/-- See also `comp_open_symm_mem_uniformity_sets`. -/\nlemma comp_symm_mem_uniformity_sets {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, symmetric_rel t \u2227 t \u25cb t \u2286 s :=\nbegin\n  obtain \u27e8w, w_in, w_sub\u27e9 : \u2203 w \u2208 \ud835\udce4 \u03b1, w \u25cb w \u2286 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 \u2286 w := symmetrize_rel_subset_self w,\n  calc symmetrize_rel w \u25cb symmetrize_rel w \u2286 w \u25cb w : by mono\n                                       ... \u2286 s     : w_sub,\nend\n\nlemma subset_comp_self_of_mem_uniformity {s : set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) : s \u2286 s \u25cb s :=\nsubset_comp_self (refl_le_uniformity h)\n\nlemma comp_comp_symm_mem_uniformity_sets {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, symmetric_rel t \u2227 t \u25cb t \u25cb t \u2286 s :=\nbegin\n  rcases comp_symm_mem_uniformity_sets hs with \u27e8w, w_in, w_symm, w_sub\u27e9,\n  rcases comp_symm_mem_uniformity_sets w_in with \u27e8t, t_in, t_symm, t_sub\u27e9,\n  use [t, t_in, t_symm],\n  have : t \u2286 t \u25cb t :=  subset_comp_self_of_mem_uniformity t_in,\n  calc\n  t \u25cb t \u25cb t \u2286 w \u25cb t       : by mono\n        ... \u2286 w \u25cb (t \u25cb t) : by mono\n        ... \u2286 w \u25cb w       : by mono\n        ... \u2286 s           : w_sub,\nend\n\n/-!\n###\u00a0Balls in uniform spaces\n-/\n\n/-- The ball around `(x : \u03b2)` with respect to `(V : set (\u03b2 \u00d7 \u03b2))`. Intended to be\nused for `V \u2208 \ud835\udce4 \u03b2`, 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 : \u03b2) (V : set (\u03b2 \u00d7 \u03b2)) : set \u03b2 := (prod.mk x) \u207b\u00b9' V\n\nopen uniform_space (ball)\n\nlemma uniform_space.mem_ball_self (x : \u03b1) {V : set (\u03b1 \u00d7 \u03b1)} (hV : V \u2208 \ud835\udce4 \u03b1) :\n  x \u2208 ball x V :=\nrefl_mem_uniformity hV\n\n/-- The triangle inequality for `uniform_space.ball` -/\nlemma mem_ball_comp {V W : set (\u03b2 \u00d7 \u03b2)} {x y z} (h : y \u2208 ball x V) (h' : z \u2208 ball y W) :\n  z \u2208 ball x (V \u25cb W) :=\nprod_mk_mem_comp_rel h h'\n\nlemma ball_subset_of_comp_subset {V W : set (\u03b2 \u00d7 \u03b2)} {x y} (h : x \u2208 ball y W) (h' : W \u25cb W \u2286 V) :\n  ball x W \u2286 ball y V :=\n\u03bb z z_in, h' (mem_ball_comp h z_in)\n\nlemma ball_mono {V W : set (\u03b2 \u00d7 \u03b2)} (h : V \u2286 W) (x : \u03b2) : ball x V \u2286 ball x W :=\npreimage_mono h\n\nlemma ball_inter (x : \u03b2) (V W : set (\u03b2 \u00d7 \u03b2)) : ball x (V \u2229 W) = ball x V \u2229 ball x W :=\npreimage_inter\n\nlemma ball_inter_left (x : \u03b2) (V W : set (\u03b2 \u00d7 \u03b2)) : ball x (V \u2229 W) \u2286 ball x V :=\nball_mono (inter_subset_left V W) x\n\nlemma ball_inter_right (x : \u03b2) (V W : set (\u03b2 \u00d7 \u03b2)) : ball x (V \u2229 W) \u2286 ball x W :=\nball_mono (inter_subset_right V W) x\n\nlemma mem_ball_symmetry {V : set (\u03b2 \u00d7 \u03b2)} (hV : symmetric_rel V) {x y} :\n  x \u2208 ball y V \u2194 y \u2208 ball x V :=\nshow (x, y) \u2208 prod.swap \u207b\u00b9' V \u2194 (x, y) \u2208 V, by { unfold symmetric_rel at hV, rw hV }\n\nlemma ball_eq_of_symmetry {V : set (\u03b2 \u00d7 \u03b2)} (hV : symmetric_rel V) {x} :\n  ball x V = {y | (y, x) \u2208 V} :=\nby { ext y, rw mem_ball_symmetry hV, exact iff.rfl }\n\nlemma mem_comp_of_mem_ball {V W : set (\u03b2 \u00d7 \u03b2)} {x y z : \u03b2} (hV : symmetric_rel V)\n  (hx : x \u2208 ball z V) (hy : y \u2208 ball z W) : (x, y) \u2208 V \u25cb W :=\nbegin\n  rw mem_ball_symmetry hV at hx,\n  exact \u27e8z, hx, hy\u27e9\nend\n\nlemma uniform_space.is_open_ball (x : \u03b1) {V : set (\u03b1 \u00d7 \u03b1)} (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 (\u03b2 \u00d7 \u03b2)} (hW' : symmetric_rel W) {p : \u03b2 \u00d7 \u03b2} :\n  p \u2208 V \u25cb M \u25cb W \u2194 ((ball p.1 V \u00d7\u02e2 ball p.2 W) \u2229 M).nonempty :=\nbegin\n  cases p with x y,\n  split,\n  { rintros \u27e8z, \u27e8w, hpw, hwz\u27e9, hzy\u27e9,\n    exact \u27e8(w, z), \u27e8hpw, by rwa mem_ball_symmetry hW'\u27e9, hwz\u27e9, },\n  { rintro \u27e8\u27e8w, z\u27e9, \u27e8w_in, z_in\u27e9, hwz\u27e9,\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 : \u03b1} {s : set \u03b1} :\n  s \u2208 \ud835\udcdd x \u2194 {p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s} \u2208 \ud835\udce4 \u03b1 :=\nbegin\n  refine \u27e8_, \u03bb hs, _\u27e9,\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 \u03bb y h eq, ts (h eq) },\n  { refine mem_nhds_iff.mpr \u27e8{x | {p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s} \u2208 \ud835\udce4 \u03b1}, _, _, hs\u27e9,\n    { exact \u03bb y hy, refl_mem_uniformity hy rfl },\n    { refine is_open_uniformity.mpr (\u03bb y hy, _),\n      rcases comp_mem_uniformity_sets hy with \u27e8t, ht, tr\u27e9,\n      filter_upwards [ht], rintro \u27e8a, b\u27e9 hp' rfl,\n      filter_upwards [ht], rintro \u27e8a', b'\u27e9 hp'' rfl,\n      exact @tr (a, b') \u27e8a', hp', hp''\u27e9 rfl } }\nend\n\nlemma mem_nhds_uniformity_iff_left {x : \u03b1} {s : set \u03b1} :\n  s \u2208 \ud835\udcdd x \u2194 {p : \u03b1 \u00d7 \u03b1 | p.2 = x \u2192 p.1 \u2208 s} \u2208 \ud835\udce4 \u03b1 :=\nby { rw [uniformity_eq_symm, mem_nhds_uniformity_iff_right], refl }\n\nlemma nhds_eq_comap_uniformity {x : \u03b1} : \ud835\udcdd x = (\ud835\udce4 \u03b1).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 \u03b1} : is_open s \u2194 \u2200 x \u2208 s, \u2203 V \u2208 \ud835\udce4 \u03b1, ball x V \u2286 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 : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set (\u03b1 \u00d7 \u03b1)} (h : (\ud835\udce4 \u03b1).has_basis p s)\n  {x : \u03b1} :\n  (\ud835\udcdd x).has_basis p (\u03bb i, ball x (s i)) :=\nby { rw [nhds_eq_comap_uniformity], exact h.comap (prod.mk x) }\n\nlemma nhds_basis_uniformity {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set (\u03b1 \u00d7 \u03b1)} (h : (\ud835\udce4 \u03b1).has_basis p s) {x : \u03b1} :\n  (\ud835\udcdd x).has_basis p (\u03bb i, {y | (y, x) \u2208 s i}) :=\nbegin\n  replace h := h.comap prod.swap,\n  rw [\u2190 map_swap_eq_comap_swap, \u2190 uniformity_eq_symm] at h,\n  exact nhds_basis_uniformity' h\nend\n\nlemma nhds_eq_comap_uniformity' {x : \u03b1} : \ud835\udcdd x = (\ud835\udce4 \u03b1).comap (\u03bb y, (y, x)) :=\n(nhds_basis_uniformity (\ud835\udce4 \u03b1).basis_sets).eq_of_same_basis $ (\ud835\udce4 \u03b1).basis_sets.comap _\n\nlemma uniform_space.mem_nhds_iff {x : \u03b1} {s : set \u03b1} : s \u2208 \ud835\udcdd x \u2194 \u2203 V \u2208 \ud835\udce4 \u03b1, ball x V \u2286 s :=\nbegin\n  rw [nhds_eq_comap_uniformity, mem_comap],\n  exact iff.rfl,\nend\n\nlemma uniform_space.ball_mem_nhds (x : \u03b1) \u2983V : set (\u03b1 \u00d7 \u03b1)\u2984 (V_in : V \u2208 \ud835\udce4 \u03b1) : ball x V \u2208 \ud835\udcdd x :=\nbegin\n  rw uniform_space.mem_nhds_iff,\n  exact \u27e8V, V_in, subset.refl _\u27e9\nend\n\nlemma uniform_space.mem_nhds_iff_symm {x : \u03b1} {s : set \u03b1} :\n  s \u2208 \ud835\udcdd x \u2194 \u2203 V \u2208 \ud835\udce4 \u03b1, symmetric_rel V \u2227 ball x V \u2286 s :=\nbegin\n  rw uniform_space.mem_nhds_iff,\n  split,\n  { rintros \u27e8V, V_in, V_sub\u27e9,\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 \u27e8V, V_in, V_symm, V_sub\u27e9,\n    exact \u27e8V, V_in, V_sub\u27e9 }\nend\n\nlemma uniform_space.has_basis_nhds (x : \u03b1) :\n  has_basis (\ud835\udcdd x) (\u03bb s : set (\u03b1 \u00d7 \u03b1), s \u2208 \ud835\udce4 \u03b1 \u2227 symmetric_rel s) (\u03bb s, ball x s) :=\n\u27e8\u03bb t, by simp [uniform_space.mem_nhds_iff_symm, and_assoc]\u27e9\n\nopen uniform_space\n\nlemma uniform_space.mem_closure_iff_symm_ball {s : set \u03b1} {x} :\n  x \u2208 closure s \u2194 \u2200 {V}, V \u2208 \ud835\udce4 \u03b1 \u2192 symmetric_rel V \u2192 (s \u2229 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 \u03b1} {x} :\n  x \u2208 closure s \u2194 \u2200 {V}, V \u2208 \ud835\udce4 \u03b1 \u2192 (ball x V \u2229 s).nonempty :=\nby simp [mem_closure_iff_nhds_basis' (nhds_basis_uniformity' (\ud835\udce4 \u03b1).basis_sets)]\n\nlemma uniform_space.has_basis_nhds_prod (x y : \u03b1) :\n  has_basis (\ud835\udcdd (x, y)) (\u03bb s, s \u2208 \ud835\udce4 \u03b1 \u2227 symmetric_rel s) $ \u03bb s, ball x s \u00d7\u02e2 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 \u27e8U_in, U_symm\u27e9 \u27e8V_in, V_symm\u27e9,\n  exact \u27e8U \u2229 V, \u27e8(\ud835\udce4 \u03b1).inter_sets U_in V_in, U_symm.inter V_symm\u27e9,\n         ball_inter_left x U V, ball_inter_right y U V\u27e9,\nend\n\nlemma nhds_eq_uniformity {x : \u03b1} : \ud835\udcdd x = (\ud835\udce4 \u03b1).lift' (ball x) :=\n(nhds_basis_uniformity' (\ud835\udce4 \u03b1).basis_sets).eq_binfi\n\nlemma nhds_eq_uniformity' {x : \u03b1} : \ud835\udcdd x = (\ud835\udce4 \u03b1).lift' (\u03bb s, {y | (y, x) \u2208 s}) :=\n(nhds_basis_uniformity (\ud835\udce4 \u03b1).basis_sets).eq_binfi\n\nlemma mem_nhds_left (x : \u03b1) {s : set (\u03b1\u00d7\u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) :\n  {y : \u03b1 | (x, y) \u2208 s} \u2208 \ud835\udcdd x :=\nball_mem_nhds x h\n\nlemma mem_nhds_right (y : \u03b1) {s : set (\u03b1\u00d7\u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) :\n  {x : \u03b1 | (x, y) \u2208 s} \u2208 \ud835\udcdd y :=\nmem_nhds_left _ (symm_le_uniformity h)\n\nlemma exists_mem_nhds_ball_subset_of_mem_nhds {a : \u03b1} {U : set \u03b1} (h : U \u2208 \ud835\udcdd a) :\n  \u2203 (V \u2208 \ud835\udcdd a) (t \u2208 \ud835\udce4 \u03b1), \u2200 a' \u2208 V, uniform_space.ball a' t \u2286 U :=\nlet \u27e8t, ht, htU\u27e9 := comp_mem_uniformity_sets (mem_nhds_uniformity_iff_right.1 h) in\n\u27e8_, mem_nhds_left a ht, t, ht, \u03bb a\u2081 h\u2081 a\u2082 h\u2082, @htU (a, a\u2082) \u27e8a\u2081, h\u2081, h\u2082\u27e9 rfl\u27e9\n\nlemma is_compact.nhds_set_basis_uniformity {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set (\u03b1 \u00d7 \u03b1)}\n  (hU : (\ud835\udce4 \u03b1).has_basis p s) {K : set \u03b1} (hK : is_compact K) :\n  (\ud835\udcdd\u02e2 K).has_basis p (\u03bb i, \u22c3 x \u2208 K, ball x (s i)) :=\nbegin\n  refine \u27e8\u03bb U, _\u27e9,\n  simp only [mem_nhds_set_iff_forall, (nhds_basis_uniformity' hU).mem_iff, Union\u2082_subset_iff],\n  refine \u27e8\u03bb H, _, \u03bb \u27e8i, hpi, hi\u27e9 x hx, \u27e8i, hpi, hi x hx\u27e9\u27e9,\n  replace H : \u2200 x \u2208 K, \u2203 i : {i // p i}, ball x (s i \u25cb s i) \u2286 U,\n  { intros x hx,\n    rcases H x hx with \u27e8i, hpi, hi\u27e9,\n    rcases comp_mem_uniformity_sets (hU.mem_of_mem hpi) with \u27e8t, ht_mem, ht\u27e9,\n    rcases hU.mem_iff.1 ht_mem with \u27e8j, hpj, hj\u27e9,\n    exact \u27e8\u27e8j, hpj\u27e9, subset.trans (ball_mono ((comp_rel_mono hj hj).trans ht) _) hi\u27e9 },\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 (\u03bb x, ball x $ s (I x))\n    (\u03bb x hx, ball_mem_nhds _ $ hU.mem_of_mem (I x).2) with \u27e8t, htK, ht\u27e9,\n  obtain \u27e8i, hpi, hi\u27e9 : \u2203 i (hpi : p i), s i \u2286 \u22c2 x \u2208 t, s (I x),\n    from hU.mem_iff.1 ((bInter_finset_mem t).2 (\u03bb x hx, hU.mem_of_mem (I x).2)),\n  rw [subset_Inter\u2082_iff] at hi,\n  refine \u27e8i, hpi, \u03bb x hx, _\u27e9,\n  rcases mem_Union\u2082.1 (ht hx) with \u27e8z, hzt : z \u2208 t, hzx : x \u2208 ball z (s (I z))\u27e9,\n  calc ball x (s i) \u2286 ball z (s (I z) \u25cb s (I z)) : \u03bb y hy, \u27e8x, hzx, hi z hzt hy\u27e9\n                ... \u2286 U                          : hI z (htK z hzt),\nend\n\nlemma disjoint.exists_uniform_thickening {A B : set \u03b1}\n  (hA : is_compact A) (hB : is_closed B) (h : disjoint A B) :\n  \u2203 V \u2208 \ud835\udce4 \u03b1, disjoint (\u22c3 x \u2208 A, ball x V) (\u22c3 x \u2208 B, ball x V) :=\nbegin\n  have : B\u1d9c \u2208 \ud835\udcdd\u02e2 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 \u27e8U, hU, hUAB\u27e9,\n  rcases comp_symm_mem_uniformity_sets hU with \u27e8V, hV, hVsymm, hVU\u27e9,\n  refine \u27e8V, hV, set.disjoint_left.mpr $ \u03bb x, _\u27e9,\n  simp only [mem_Union\u2082],\n  rintro \u27e8a, ha, hxa\u27e9 \u27e8b, hb, hxb\u27e9,\n  rw mem_ball_symmetry hVsymm at hxa hxb,\n  exact hUAB (mem_Union\u2082_of_mem ha $ hVU $ mem_comp_of_mem_ball hVsymm hxa hxb) hb\nend\n\nlemma disjoint.exists_uniform_thickening_of_basis {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set (\u03b1 \u00d7 \u03b1)}\n  (hU : (\ud835\udce4 \u03b1).has_basis p s) {A B : set \u03b1}\n  (hA : is_compact A) (hB : is_closed B) (h : disjoint A B) :\n  \u2203 i, p i \u2227 disjoint (\u22c3 x \u2208 A, ball x (s i)) (\u22c3 x \u2208 B, ball x (s i)) :=\nbegin\n  rcases h.exists_uniform_thickening hA hB with \u27e8V, hV, hVAB\u27e9,\n  rcases hU.mem_iff.1 hV with \u27e8i, hi, hiV\u27e9,\n  exact \u27e8i, hi, hVAB.mono\n    (Union\u2082_mono $ \u03bb a _, ball_mono hiV a) (Union\u2082_mono $ \u03bb b _, ball_mono hiV b)\u27e9,\nend\n\nlemma tendsto_right_nhds_uniformity {a : \u03b1} : tendsto (\u03bba', (a', a)) (\ud835\udcdd a) (\ud835\udce4 \u03b1) :=\nassume s, mem_nhds_right a\n\nlemma tendsto_left_nhds_uniformity {a : \u03b1} : tendsto (\u03bba', (a, a')) (\ud835\udcdd a) (\ud835\udce4 \u03b1) :=\nassume s, mem_nhds_left a\n\nlemma lift_nhds_left {x : \u03b1} {g : set \u03b1 \u2192 filter \u03b2} (hg : monotone g) :\n  (\ud835\udcdd x).lift g = (\ud835\udce4 \u03b1).lift (\u03bbs:set (\u03b1\u00d7\u03b1), g (ball x s)) :=\nby { rw [nhds_eq_comap_uniformity, comap_lift_eq2 hg], refl }\n\nlemma lift_nhds_right {x : \u03b1} {g : set \u03b1 \u2192 filter \u03b2} (hg : monotone g) :\n  (\ud835\udcdd x).lift g = (\ud835\udce4 \u03b1).lift (\u03bbs:set (\u03b1\u00d7\u03b1), g {y | (y, x) \u2208 s}) :=\nby { rw [nhds_eq_comap_uniformity', comap_lift_eq2 hg], refl }\n\nlemma nhds_nhds_eq_uniformity_uniformity_prod {a b : \u03b1} :\n  \ud835\udcdd a \u00d7\u1da0 \ud835\udcdd b =\n  (\ud835\udce4 \u03b1).lift (\u03bbs:set (\u03b1\u00d7\u03b1), (\ud835\udce4 \u03b1).lift' (\u03bbt:set (\u03b1\u00d7\u03b1),\n    {y : \u03b1 | (y, a) \u2208 s} \u00d7\u02e2 {y : \u03b1 | (b, y) \u2208 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 : \u03b1} :\n  \ud835\udcdd (a, b) =\n  (\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), {y : \u03b1 | (y, a) \u2208 s} \u00d7\u02e2 {y : \u03b1 | (b, y) \u2208 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 (\u03b1\u00d7\u03b1)} (s : set (\u03b1\u00d7\u03b1)) (hd : d \u2208 \ud835\udce4 \u03b1) :\n  \u2203(t : set (\u03b1\u00d7\u03b1)), is_open t \u2227 s \u2286 t \u2227 t \u2286 {p | \u2203x y, (p.1, x) \u2208 d \u2227 (x, y) \u2208 s \u2227 (y, p.2) \u2208 d} :=\nlet cl_d := {p:\u03b1\u00d7\u03b1 | \u2203x y, (p.1, x) \u2208 d \u2227 (x, y) \u2208 s \u2227 (y, p.2) \u2208 d} in\nhave \u2200p \u2208 s, \u2203t \u2286 cl_d, is_open t \u2227 p \u2208 t, from\n  assume \u27e8x, y\u27e9 hp, _root_.mem_nhds_iff.mp $\n  show cl_d \u2208 \ud835\udcdd (x, y),\n  begin\n    rw [nhds_eq_uniformity_prod, mem_lift'_sets],\n    exact \u27e8d, hd, assume \u27e8a, b\u27e9 \u27e8ha, hb\u27e9, \u27e8x, y, ha, hp, hb\u27e9\u27e9,\n    exact monotone_preimage.set_prod monotone_preimage\n  end,\nhave \u2203t:(\u03a0(p:\u03b1\u00d7\u03b1) (h:p \u2208 s), set (\u03b1\u00d7\u03b1)),\n    \u2200p, \u2200h:p \u2208 s, t p h \u2286 cl_d \u2227 is_open (t p h) \u2227 p \u2208 t p h,\n  by simp [classical.skolem] at this; simp; assumption,\nmatch this with\n| \u27e8t, ht\u27e9 :=\n  \u27e8(\u22c3 p:\u03b1\u00d7\u03b1, \u22c3 h : p \u2208 s, t p h : set (\u03b1\u00d7\u03b1)),\n    is_open_Union $ assume (p:\u03b1\u00d7\u03b1), is_open_Union $ assume hp, (ht p hp).right.left,\n    assume \u27e8a, b\u27e9 hp, begin simp; exact \u27e8a, b, hp, (ht (a,b) hp).right.right\u27e9 end,\n    Union_subset $ assume p, Union_subset $ assume hp, (ht p hp).left\u27e9\nend\n\n/-- Entourages are neighborhoods of the diagonal. -/\nlemma nhds_le_uniformity (x : \u03b1) : \ud835\udcdd (x, x) \u2264 \ud835\udce4 \u03b1 :=\nbegin\n  intros V V_in,\n  rcases comp_symm_mem_uniformity_sets V_in with \u27e8w, w_in, w_symm, w_sub\u27e9,\n  have : ball x w \u00d7\u02e2 ball x w \u2208 \ud835\udcdd (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 \u27e8u, v\u27e9 \u27e8u_in, v_in\u27e9,\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 : (\u2a06 x : \u03b1, \ud835\udcdd (x, x)) \u2264 \ud835\udce4 \u03b1 :=\nsupr_le nhds_le_uniformity\n\n/-- Entourages are neighborhoods of the diagonal. -/\nlemma nhds_set_diagonal_le_uniformity : \ud835\udcdd\u02e2 (diagonal \u03b1) \u2264 \ud835\udce4 \u03b1 :=\n(nhds_set_diagonal \u03b1).trans_le supr_nhds_le_uniformity\n\n/-!\n### Closure and interior in uniform spaces\n-/\n\nlemma closure_eq_uniformity (s : set $ \u03b1 \u00d7 \u03b1) :\n  closure s = \u22c2 V \u2208 {V | V \u2208 \ud835\udce4 \u03b1 \u2227 symmetric_rel V}, V \u25cb s \u25cb V :=\nbegin\n  ext \u27e8x, y\u27e9,\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, \u2190 mem_inter_iff, inter_comm, set.nonempty]\n    { contextual := tt }\nend\n\nlemma uniformity_has_basis_closed : has_basis (\ud835\udce4 \u03b1) (\u03bb V : set (\u03b1 \u00d7 \u03b1), V \u2208 \ud835\udce4 \u03b1 \u2227 is_closed V) id :=\nbegin\n  refine filter.has_basis_self.2 (\u03bb t h, _),\n  rcases comp_comp_symm_mem_uniformity_sets h with \u27e8w, w_in, w_symm, r\u27e9,\n  refine \u27e8closure w, mem_of_superset w_in subset_closure, is_closed_closure, _\u27e9,\n  refine subset.trans _ r,\n  rw closure_eq_uniformity,\n  apply Inter_subset_of_subset,\n  apply Inter_subset,\n  exact \u27e8w_in, w_symm\u27e9\nend\n\nlemma uniformity_eq_uniformity_closure : \ud835\udce4 \u03b1 = (\ud835\udce4 \u03b1).lift' closure :=\neq.symm $ uniformity_has_basis_closed.lift'_closure_eq_self $ \u03bb _, and.right\n\nlemma filter.has_basis.uniformity_closure {p : \u03b9 \u2192 Prop} {U : \u03b9 \u2192 set (\u03b1 \u00d7 \u03b1)}\n  (h : (\ud835\udce4 \u03b1).has_basis p U) : (\ud835\udce4 \u03b1).has_basis p (\u03bb i, closure (U i)) :=\n(@uniformity_eq_uniformity_closure \u03b1 _).symm \u25b8 h.lift'_closure\n\n/-- Closed entourages form a basis of the uniformity filter. -/\nlemma uniformity_has_basis_closure : has_basis (\ud835\udce4 \u03b1) (\u03bb V : set (\u03b1 \u00d7 \u03b1), V \u2208 \ud835\udce4 \u03b1) closure :=\n(\ud835\udce4 \u03b1).basis_sets.uniformity_closure\n\nlemma closure_eq_inter_uniformity {t : set (\u03b1\u00d7\u03b1)} :\n  closure t = (\u22c2 d \u2208 \ud835\udce4 \u03b1, d \u25cb (t \u25cb d)) :=\ncalc closure t = \u22c2 V (hV : V \u2208 \ud835\udce4 \u03b1 \u2227 symmetric_rel V), V \u25cb t \u25cb V : closure_eq_uniformity t\n... = \u22c2 V \u2208 \ud835\udce4 \u03b1, V \u25cb t \u25cb V : eq.symm $ uniform_space.has_basis_symmetric.bInter_mem $\n  \u03bb V\u2081 V\u2082 hV, comp_rel_mono (comp_rel_mono hV subset.rfl) hV\n... = \u22c2 V \u2208 \ud835\udce4 \u03b1, V \u25cb (t \u25cb V) : by simp only [comp_rel_assoc]\n\nlemma uniformity_eq_uniformity_interior : \ud835\udce4 \u03b1 = (\ud835\udce4 \u03b1).lift' interior :=\nle_antisymm\n  (le_infi $ assume d, le_infi $ assume hd,\n    let \u27e8s, hs, hs_comp\u27e9 := (mem_lift'_sets $\n      monotone_id.comp_rel $ monotone_id.comp_rel monotone_id).mp\n        (comp_le_uniformity3 hd) in\n    let \u27e8t, ht, hst, ht_comp\u27e9 := nhdset_of_mem_uniformity s hs in\n    have s \u2286 interior d, from\n      calc s \u2286 t : hst\n       ... \u2286 interior d : ht.subset_interior_iff.mpr $\n        \u03bb x (hx : x \u2208 t), let \u27e8x, y, h\u2081, h\u2082, h\u2083\u27e9 := ht_comp hx in hs_comp \u27e8x, h\u2081, y, h\u2082, h\u2083\u27e9,\n    have interior d \u2208 \ud835\udce4 \u03b1, by filter_upwards [hs] using this,\n    by simp [this])\n  (assume s hs, ((\ud835\udce4 \u03b1).lift' interior).sets_of_superset (mem_lift' hs) interior_subset)\n\nlemma interior_mem_uniformity {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  interior s \u2208 \ud835\udce4 \u03b1 :=\nby rw [uniformity_eq_uniformity_interior]; exact mem_lift' hs\n\nlemma mem_uniformity_is_closed {s : set (\u03b1\u00d7\u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203t \u2208 \ud835\udce4 \u03b1, is_closed t \u2227 t \u2286 s :=\nlet \u27e8t, \u27e8ht_mem, htc\u27e9, hts\u27e9 := uniformity_has_basis_closed.mem_iff.1 h in\n\u27e8t, ht_mem, htc, hts\u27e9\n\nlemma is_open_iff_open_ball_subset {s : set \u03b1} :\n  is_open s \u2194 \u2200 x \u2208 s, \u2203 V \u2208 \ud835\udce4 \u03b1, is_open V \u2227 ball x V \u2286 s :=\nbegin\n  rw is_open_iff_ball_subset,\n  split; intros h x hx,\n  { obtain \u27e8V, hV, hV'\u27e9 := h x hx,\n    exact \u27e8interior V, interior_mem_uniformity hV, is_open_interior,\n      (ball_mono interior_subset x).trans hV'\u27e9, },\n  { obtain \u27e8V, hV, -, hV'\u27e9 := h x hx,\n    exact \u27e8V, hV, hV'\u27e9, },\nend\n\n/-- The uniform neighborhoods of all points of a dense set cover the whole space. -/\nlemma dense.bUnion_uniformity_ball {s : set \u03b1} {U : set (\u03b1 \u00d7 \u03b1)} (hs : dense s) (hU : U \u2208 \ud835\udce4 \u03b1) :\n  (\u22c3 x \u2208 s, ball x U) = univ :=\nbegin\n  refine Union\u2082_eq_univ_iff.2 (\u03bb y, _),\n  rcases hs.inter_nhds_nonempty (mem_nhds_right y hU) with \u27e8x, hxs, hxy : (x, y) \u2208 U\u27e9,\n  exact \u27e8x, hxs, hxy\u27e9\nend\n\n/-!\n### Uniformity bases\n-/\n\n/-- Open elements of `\ud835\udce4 \u03b1` form a basis of `\ud835\udce4 \u03b1`. -/\nlemma uniformity_has_basis_open : has_basis (\ud835\udce4 \u03b1) (\u03bb V : set (\u03b1 \u00d7 \u03b1), V \u2208 \ud835\udce4 \u03b1 \u2227 is_open V) id :=\nhas_basis_self.2 $ \u03bb s hs,\n  \u27e8interior s, interior_mem_uniformity hs, is_open_interior, interior_subset\u27e9\n\nlemma filter.has_basis.mem_uniformity_iff {p : \u03b2 \u2192 Prop} {s : \u03b2 \u2192 set (\u03b1\u00d7\u03b1)}\n  (h : (\ud835\udce4 \u03b1).has_basis p s) {t : set (\u03b1 \u00d7 \u03b1)} :\n  t \u2208 \ud835\udce4 \u03b1 \u2194 \u2203 i (hi : p i), \u2200 a b, (a, b) \u2208 s i \u2192 (a, b) \u2208 t :=\nh.mem_iff.trans $ by simp only [prod.forall, subset_def]\n\n/-- Open elements `s : set (\u03b1 \u00d7 \u03b1)` of `\ud835\udce4 \u03b1` such that `(x, y) \u2208 s \u2194 (y, x) \u2208 s` form a basis\nof `\ud835\udce4 \u03b1`. -/\nlemma uniformity_has_basis_open_symmetric :\n  has_basis (\ud835\udce4 \u03b1) (\u03bb V : set (\u03b1 \u00d7 \u03b1), V \u2208 \ud835\udce4 \u03b1 \u2227 is_open V \u2227 symmetric_rel V) id :=\nbegin\n  simp only [\u2190 and_assoc],\n  refine uniformity_has_basis_open.restrict (\u03bb s hs, \u27e8symmetrize_rel s, _\u27e9),\n  exact \u27e8\u27e8symmetrize_mem_uniformity hs.1, is_open.inter hs.2 (hs.2.preimage continuous_swap)\u27e9,\n    symmetric_symmetrize_rel s, symmetrize_rel_subset_self s\u27e9\nend\n\nlemma comp_open_symm_mem_uniformity_sets {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, is_open t \u2227 symmetric_rel t \u2227 t \u25cb t \u2286 s :=\nbegin\n  obtain \u27e8t, ht\u2081, ht\u2082\u27e9 := comp_mem_uniformity_sets hs,\n  obtain \u27e8u, \u27e8hu\u2081, hu\u2082, hu\u2083\u27e9, hu\u2084 : u \u2286 t\u27e9 := uniformity_has_basis_open_symmetric.mem_iff.mp ht\u2081,\n  exact \u27e8u, hu\u2081, hu\u2082, hu\u2083, (comp_rel_mono hu\u2084 hu\u2084).trans ht\u2082\u27e9,\nend\n\nsection\n\nvariable (\u03b1)\n\nlemma uniform_space.has_seq_basis [is_countably_generated $ \ud835\udce4 \u03b1] :\n  \u2203 V : \u2115 \u2192 set (\u03b1 \u00d7 \u03b1), has_antitone_basis (\ud835\udce4 \u03b1) V \u2227 \u2200 n, symmetric_rel (V n) :=\nlet \u27e8U, hsym, hbasis\u27e9 :=  uniform_space.has_basis_symmetric.exists_antitone_subbasis\nin \u27e8U, hbasis, \u03bb n, (hsym n).2\u27e9\n\nend\n\nlemma filter.has_basis.bInter_bUnion_ball {p : \u03b9 \u2192 Prop} {U : \u03b9 \u2192 set (\u03b1 \u00d7 \u03b1)}\n  (h : has_basis (\ud835\udce4 \u03b1) p U) (s : set \u03b1) :\n  (\u22c2 i (hi : p i), \u22c3 x \u2208 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 : \u03b1 \u2192 \u03b2` 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 `\u03b1`. -/\ndef uniform_continuous [uniform_space \u03b2] (f : \u03b1 \u2192 \u03b2) :=\ntendsto (\u03bbx:\u03b1\u00d7\u03b1, (f x.1, f x.2)) (\ud835\udce4 \u03b1) (\ud835\udce4 \u03b2)\n\n/-- A function `f : \u03b1 \u2192 \u03b2` is *uniformly continuous* on `s : set \u03b1` if `(f x, f y)` tends to\nthe diagonal as `(x, y)` tends to the diagonal while remaining in `s \u00d7\u02e2 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 \u03b2] (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) : Prop :=\ntendsto (\u03bb x : \u03b1 \u00d7 \u03b1, (f x.1, f x.2)) (\ud835\udce4 \u03b1 \u2293 principal (s \u00d7\u02e2 s)) (\ud835\udce4 \u03b2)\n\ntheorem uniform_continuous_def [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  uniform_continuous f \u2194 \u2200 r \u2208 \ud835\udce4 \u03b2, { x : \u03b1 \u00d7 \u03b1 | (f x.1, f x.2) \u2208 r} \u2208 \ud835\udce4 \u03b1 :=\niff.rfl\n\ntheorem uniform_continuous_iff_eventually [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  uniform_continuous f \u2194 \u2200 r \u2208 \ud835\udce4 \u03b2, \u2200\u1da0 (x : \u03b1 \u00d7 \u03b1) in \ud835\udce4 \u03b1, (f x.1, f x.2) \u2208 r :=\niff.rfl\n\ntheorem uniform_continuous_on_univ [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  uniform_continuous_on f univ \u2194 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 \u03b2] {c : \u03b1 \u2192 \u03b2} (h : \u2200a b, c a = c b) :\n  uniform_continuous c :=\nhave (\u03bb (x : \u03b1 \u00d7 \u03b1), (c (x.fst), c (x.snd))) \u207b\u00b9' id_rel = univ, from\n  eq_univ_iff_forall.2 $ assume \u27e8a, b\u27e9, 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 \u03b1) :=\nby simp [uniform_continuous]; exact tendsto_id\n\nlemma uniform_continuous_const [uniform_space \u03b2] {b : \u03b2} : uniform_continuous (\u03bba:\u03b1, b) :=\nuniform_continuous_of_const $ \u03bb _ _, rfl\n\nlemma uniform_continuous.comp [uniform_space \u03b2] [uniform_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2}\n  (hg : uniform_continuous g) (hf : uniform_continuous f) : uniform_continuous (g \u2218 f) :=\nhg.comp hf\n\nlemma filter.has_basis.uniform_continuous_iff {\u03b9'} [uniform_space \u03b2] {p : \u03b9 \u2192 Prop}\n  {s : \u03b9 \u2192 set (\u03b1\u00d7\u03b1)} (ha : (\ud835\udce4 \u03b1).has_basis p s) {q : \u03b9' \u2192 Prop} {t : \u03b9' \u2192 set (\u03b2\u00d7\u03b2)}\n  (hb : (\ud835\udce4 \u03b2).has_basis q t) {f : \u03b1 \u2192 \u03b2} :\n  uniform_continuous f \u2194 \u2200 i (hi : q i), \u2203 j (hj : p j), \u2200 x y, (x, y) \u2208 s j \u2192 (f x, f y) \u2208 t i :=\n(ha.tendsto_iff hb).trans $ by simp only [prod.forall]\n\nlemma filter.has_basis.uniform_continuous_on_iff {\u03b9'} [uniform_space \u03b2] {p : \u03b9 \u2192 Prop}\n  {s : \u03b9 \u2192 set (\u03b1\u00d7\u03b1)} (ha : (\ud835\udce4 \u03b1).has_basis p s) {q : \u03b9' \u2192 Prop} {t : \u03b9' \u2192 set (\u03b2\u00d7\u03b2)}\n  (hb : (\ud835\udce4 \u03b2).has_basis q t) {f : \u03b1 \u2192 \u03b2} {S : set \u03b1} :\n  uniform_continuous_on f S \u2194\n    \u2200 i (hi : q i), \u2203 j (hj : p j), \u2200 x y \u2208 S, (x, y) \u2208 s j \u2192 (f x, f y) \u2208 t i :=\n((ha.inf_principal (S \u00d7\u02e2 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 \u03b1) :=\n{ le          := \u03bbt s, t.uniformity \u2264 s.uniformity,\n  le_antisymm := assume t s h\u2081 h\u2082, uniform_space_eq $ le_antisymm h\u2081 h\u2082,\n  le_refl     := assume t, le_rfl,\n  le_trans    := assume a b c h\u2081 h\u2082, le_trans h\u2081 h\u2082 }\n\ninstance : has_Inf (uniform_space \u03b1) :=\n\u27e8assume s, uniform_space.of_core\n{ uniformity := (\u2a05u\u2208s, \ud835\udce4[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 }\u27e9\n\nprivate lemma Inf_le {tt : set (uniform_space \u03b1)} {t : uniform_space \u03b1} (h : t \u2208 tt) :\n  Inf tt \u2264 t :=\nshow (\u2a05 u \u2208 tt, \ud835\udce4[u]) \u2264 \ud835\udce4[t], from infi\u2082_le t h\n\nprivate lemma le_Inf {tt : set (uniform_space \u03b1)} {t : uniform_space \u03b1} (h : \u2200t'\u2208tt, t \u2264 t') :\n  t \u2264 Inf tt :=\nshow \ud835\udce4[t] \u2264 (\u2a05 u \u2208 tt, \ud835\udce4[u]), from le_infi\u2082 h\n\ninstance : has_top (uniform_space \u03b1) :=\n\u27e8uniform_space.of_core { uniformity := \u22a4, refl := le_top, symm := le_top, comp := le_top }\u27e9\n\ninstance : has_bot (uniform_space \u03b1) :=\n\u27e8{ to_topological_space := \u22a5,\n  uniformity  := \ud835\udcdf 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 } } \u27e9\n\ninstance : has_inf (uniform_space \u03b1) :=\n\u27e8\u03bb u\u2081 u\u2082,\n  @uniform_space.replace_topology _\n    (u\u2081.to_topological_space \u2293 u\u2082.to_topological_space) (uniform_space.of_core\n    { uniformity  := u\u2081.uniformity \u2293 u\u2082.uniformity,\n      refl        := le_inf u\u2081.refl u\u2082.refl,\n      symm        := u\u2081.symm.inf u\u2082.symm,\n      comp        := (lift'_inf_le _ _ _).trans $ inf_le_inf u\u2081.comp u\u2082.comp }) $\n    eq_of_nhds_eq_nhds $ \u03bb a,\n      by simpa only [nhds_inf, nhds_eq_comap_uniformity] using comap_inf.symm\u27e9\n\ninstance : complete_lattice (uniform_space \u03b1) :=\n{ sup           := \u03bba b, Inf {x | a \u2264 x \u2227 b \u2264 x},\n  le_sup_left   := \u03bb a b, le_Inf (\u03bb _ \u27e8h, _\u27e9, h),\n  le_sup_right  := \u03bb a b, le_Inf (\u03bb _ \u27e8_, h\u27e9, h),\n  sup_le        := \u03bb a b c h\u2081 h\u2082, Inf_le \u27e8h\u2081, h\u2082\u27e9,\n  inf           := (\u2293),\n  le_inf        := \u03bb a b c h\u2081 h\u2082, show a.uniformity \u2264 _, from le_inf h\u2081 h\u2082,\n  inf_le_left   := \u03bb a b, show _ \u2264 a.uniformity, from inf_le_left,\n  inf_le_right  := \u03bb a b, show _ \u2264 b.uniformity, from inf_le_right,\n  top           := \u22a4,\n  le_top        := \u03bb a, show a.uniformity \u2264 \u22a4, from le_top,\n  bot           := \u22a5,\n  bot_le        := \u03bb u, u.refl,\n  Sup           := \u03bb tt, Inf {t | \u2200 t' \u2208 tt, t' \u2264 t},\n  le_Sup        := \u03bb s u h, le_Inf (\u03bb u' h', h' u h),\n  Sup_le        := \u03bb s u h, Inf_le h,\n  Inf           := Inf,\n  le_Inf        := \u03bb s a hs, le_Inf hs,\n  Inf_le        := \u03bb s a ha, Inf_le ha,\n  ..uniform_space.partial_order }\n\nlemma infi_uniformity {\u03b9 : Sort*} {u : \u03b9 \u2192 uniform_space \u03b1} : \ud835\udce4[infi u] = (\u2a05i, \ud835\udce4[u i]) :=\ninfi_range\n\nlemma inf_uniformity {u v : uniform_space \u03b1} : \ud835\udce4[u \u2293 v] = \ud835\udce4[u] \u2293 \ud835\udce4[v] := rfl\n\ninstance inhabited_uniform_space : inhabited (uniform_space \u03b1) := \u27e8\u22a5\u27e9\ninstance inhabited_uniform_space_core : inhabited (uniform_space.core \u03b1) :=\n\u27e8@uniform_space.to_core _ default\u27e9\n\n/-- Given `f : \u03b1 \u2192 \u03b2` and a uniformity `u` on `\u03b2`, the inverse image of `u` under `f`\n  is the inverse image in the filter sense of the induced function `\u03b1 \u00d7 \u03b1 \u2192 \u03b2 \u00d7 \u03b2`. -/\ndef uniform_space.comap (f : \u03b1 \u2192 \u03b2) (u : uniform_space \u03b2) : uniform_space \u03b1 :=\n{ uniformity := \ud835\udce4[u].comap (\u03bbp:\u03b1\u00d7\u03b1, (f p.1, f p.2)),\n  to_topological_space := u.to_topological_space.induced f,\n  refl := le_trans (by simp; exact assume \u27e8a, b\u27e9 (h : a = b), h \u25b8 rfl) (comap_mono u.refl),\n  symm := by simp [tendsto_comap_iff, prod.swap, (\u2218)];\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 \u27e8a\u2081, a\u2082\u27e9 \u27e8x, h\u2081, h\u2082\u27e9, \u27e8f x, h\u2081, h\u2082\u27e9),\n      exact monotone_id.comp_rel monotone_id\n    end\n    (comap_mono u.comp),\n  is_open_uniformity := \u03bb s, by simp only [is_open_fold, is_open_induced, is_open_iff_mem_nhds,\n    nhds_induced, nhds_eq_comap_uniformity, comap_comap, \u2190 mem_comap_prod_mk, \u2190 uniformity] }\n\nlemma uniformity_comap [uniform_space \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  \ud835\udce4[uniform_space.comap f \u2039_\u203a] = comap (prod.map f f) (\ud835\udce4 \u03b2) :=\nrfl\n\n@[simp] lemma uniform_space_comap_id {\u03b1 : Type*} : uniform_space.comap (id : \u03b1 \u2192 \u03b1) = id :=\nby { ext : 2, rw [uniformity_comap, prod.map_id, comap_id] }\n\nlemma uniform_space.comap_comap {\u03b1 \u03b2 \u03b3} [u\u03b3 : uniform_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} :\n  uniform_space.comap (g \u2218 f) u\u03b3 = uniform_space.comap f (uniform_space.comap g u\u03b3) :=\nby { ext1, simp only [uniformity_comap, comap_comap, prod.map_comp_map] }\n\nlemma uniform_space.comap_inf {\u03b1 \u03b3} {u\u2081 u\u2082 : uniform_space \u03b3} {f : \u03b1 \u2192 \u03b3} :\n  (u\u2081 \u2293 u\u2082).comap f = u\u2081.comap f \u2293 u\u2082.comap f :=\nuniform_space_eq comap_inf\n\nlemma uniform_space.comap_infi {\u03b9 \u03b1 \u03b3} {u : \u03b9 \u2192 uniform_space \u03b3} {f : \u03b1 \u2192 \u03b3} :\n  (\u2a05 i, u i).comap f = \u2a05 i, (u i).comap f :=\nbegin\n  ext : 1,\n  simp [uniformity_comap, infi_uniformity]\nend\n\nlemma uniform_space.comap_mono {\u03b1 \u03b3} {f : \u03b1 \u2192 \u03b3} :\n  monotone (\u03bb u : uniform_space \u03b3, u.comap f) :=\nbegin\n  intros u\u2081 u\u2082 hu,\n  change (\ud835\udce4 _) \u2264 (\ud835\udce4 _),\n  rw uniformity_comap,\n  exact comap_mono hu\nend\n\nlemma uniform_continuous_iff {\u03b1 \u03b2} {u\u03b1 : uniform_space \u03b1} {u\u03b2 : uniform_space \u03b2} {f : \u03b1 \u2192 \u03b2} :\n  uniform_continuous f \u2194 u\u03b1 \u2264 u\u03b2.comap f :=\nfilter.map_le_iff_le_comap\n\nlemma le_iff_uniform_continuous_id {u v : uniform_space \u03b1} :\n  u \u2264 v \u2194 @uniform_continuous _ _ u v id :=\nby rw [uniform_continuous_iff, uniform_space_comap_id, id]\n\nlemma uniform_continuous_comap {f : \u03b1 \u2192 \u03b2} [u : uniform_space \u03b2] :\n  @uniform_continuous \u03b1 \u03b2 (uniform_space.comap f u) u f :=\ntendsto_comap\n\ntheorem to_topological_space_comap {f : \u03b1 \u2192 \u03b2} {u : uniform_space \u03b2} :\n  @uniform_space.to_topological_space _ (uniform_space.comap f u) =\n  topological_space.induced f (@uniform_space.to_topological_space \u03b2 u) := rfl\n\nlemma uniform_continuous_comap' {f : \u03b3 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} [v : uniform_space \u03b2] [u : uniform_space \u03b1]\n  (h : uniform_continuous (f \u2218 g)) : @uniform_continuous \u03b1 \u03b3 u (uniform_space.comap f v) g :=\ntendsto_comap_iff.2 h\n\nlemma to_nhds_mono {u\u2081 u\u2082 : uniform_space \u03b1} (h : u\u2081 \u2264 u\u2082) (a : \u03b1) :\n  @nhds _ (@uniform_space.to_topological_space _ u\u2081) a \u2264\n    @nhds _ (@uniform_space.to_topological_space _ u\u2082) a :=\nby rw [@nhds_eq_uniformity \u03b1 u\u2081 a, @nhds_eq_uniformity \u03b1 u\u2082 a]; exact (lift'_mono h le_rfl)\n\nlemma to_topological_space_mono {u\u2081 u\u2082 : uniform_space \u03b1} (h : u\u2081 \u2264 u\u2082) :\n  @uniform_space.to_topological_space _ u\u2081 \u2264 @uniform_space.to_topological_space _ u\u2082 :=\nle_of_nhds_le_nhds $ to_nhds_mono h\n\nlemma uniform_continuous.continuous [uniform_space \u03b1] [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2}\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 \u03b1 \u22a5 = \u22a5 := rfl\n\nlemma to_topological_space_top : @uniform_space.to_topological_space \u03b1 \u22a4 = \u22a4 :=\ntop_unique $ assume s hs, s.eq_empty_or_nonempty.elim\n  (assume : s = \u2205, this.symm \u25b8 @is_open_empty _ \u22a4)\n  (assume  \u27e8x, hx\u27e9,\n    have s = univ, from top_unique $ assume y hy, hs x hx (x, y) rfl,\n    this.symm \u25b8 @is_open_univ _ \u22a4)\n\nlemma to_topological_space_infi {\u03b9 : Sort*} {u : \u03b9 \u2192 uniform_space \u03b1} :\n  (infi u).to_topological_space = \u2a05i, (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 \u03b1)} :\n  (Inf s).to_topological_space = (\u2a05i\u2208s, @uniform_space.to_topological_space \u03b1 i) :=\nbegin\n  rw [Inf_eq_infi],\n  simp only [\u2190 to_topological_space_infi],\nend\n\nlemma to_topological_space_inf {u v : uniform_space \u03b1} :\n  (u \u2293 v).to_topological_space = u.to_topological_space \u2293 v.to_topological_space :=\nrfl\n\n/-- Uniform space structure on `ulift \u03b1`. -/\ninstance ulift.uniform_space [uniform_space \u03b1] : uniform_space (ulift \u03b1) :=\nuniform_space.comap ulift.down \u2039_\u203a\n\nsection uniform_continuous_infi\n\nlemma uniform_continuous_inf_rng {f : \u03b1 \u2192 \u03b2} {u\u2081 : uniform_space \u03b1} {u\u2082 u\u2083 : uniform_space \u03b2}\n  (h\u2081 : @@uniform_continuous u\u2081 u\u2082 f) (h\u2082 : @@uniform_continuous u\u2081 u\u2083 f) :\n  @@uniform_continuous u\u2081 (u\u2082 \u2293 u\u2083) f :=\ntendsto_inf.mpr \u27e8h\u2081, h\u2082\u27e9\n\nlemma uniform_continuous_inf_dom_left {f : \u03b1 \u2192 \u03b2} {u\u2081 u\u2082 : uniform_space \u03b1} {u\u2083 : uniform_space \u03b2}\n  (hf : @@uniform_continuous u\u2081 u\u2083 f) : @@uniform_continuous (u\u2081 \u2293 u\u2082) u\u2083 f :=\ntendsto_inf_left hf\n\nlemma uniform_continuous_inf_dom_right {f : \u03b1 \u2192 \u03b2} {u\u2081 u\u2082 : uniform_space \u03b1} {u\u2083 : uniform_space \u03b2}\n  (hf : @@uniform_continuous u\u2082 u\u2083 f) : @@uniform_continuous (u\u2081 \u2293 u\u2082) u\u2083 f :=\ntendsto_inf_right hf\n\nlemma uniform_continuous_Inf_dom {f : \u03b1 \u2192 \u03b2} {u\u2081 : set (uniform_space \u03b1)} {u\u2082 : uniform_space \u03b2}\n  {u : uniform_space \u03b1} (h\u2081 : u \u2208 u\u2081) (hf : @@uniform_continuous u u\u2082 f) :\n  @@uniform_continuous (Inf u\u2081) u\u2082 f :=\nbegin\n  rw [uniform_continuous, Inf_eq_infi', infi_uniformity],\n  exact tendsto_infi' \u27e8u, h\u2081\u27e9 hf\nend\n\nlemma uniform_continuous_Inf_rng {f : \u03b1 \u2192 \u03b2} {u\u2081 : uniform_space \u03b1} {u\u2082 : set (uniform_space \u03b2)}\n  (h : \u2200u\u2208u\u2082, @@uniform_continuous u\u2081 u f) : @@uniform_continuous u\u2081 (Inf u\u2082) f :=\nbegin\n  rw [uniform_continuous, Inf_eq_infi', infi_uniformity],\n  exact tendsto_infi.mpr (\u03bb \u27e8u, hu\u27e9, h u hu)\nend\n\nlemma uniform_continuous_infi_dom {f : \u03b1 \u2192 \u03b2} {u\u2081 : \u03b9 \u2192 uniform_space \u03b1} {u\u2082 : uniform_space \u03b2}\n  {i : \u03b9} (hf : @@uniform_continuous (u\u2081 i) u\u2082 f) : @@uniform_continuous (infi u\u2081) u\u2082 f :=\nbegin\n  rw [uniform_continuous, infi_uniformity],\n  exact tendsto_infi' i hf\nend\n\nlemma uniform_continuous_infi_rng {f : \u03b1 \u2192 \u03b2} {u\u2081 : uniform_space \u03b1} {u\u2082 : \u03b9 \u2192 uniform_space \u03b2}\n  (h : \u2200i, @@uniform_continuous u\u2081 (u\u2082 i) f) : @@uniform_continuous u\u2081 (infi u\u2082) 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\u03b1 : uniform_space \u03b1]\n  (h : uniformity \u03b1 = \ud835\udcdf id_rel) :\n  discrete_topology \u03b1 :=\n\u27e8(uniform_space_eq h.symm : \u22a5 = h\u03b1) \u25b8 rfl\u27e9\n\ninstance : uniform_space empty := \u22a5\ninstance : uniform_space punit := \u22a5\ninstance : uniform_space bool := \u22a5\ninstance : uniform_space \u2115 := \u22a5\ninstance : uniform_space \u2124 := \u22a5\n\nsection\nvariables [uniform_space \u03b1]\n\nopen additive multiplicative\n\ninstance : uniform_space (additive \u03b1) := \u2039uniform_space \u03b1\u203a\ninstance : uniform_space (multiplicative \u03b1) := \u2039uniform_space \u03b1\u203a\n\nlemma uniform_continuous_of_mul : uniform_continuous (of_mul : \u03b1 \u2192 additive \u03b1) :=\nuniform_continuous_id\nlemma uniform_continuous_to_mul : uniform_continuous (to_mul : additive \u03b1 \u2192 \u03b1) :=\nuniform_continuous_id\nlemma uniform_continuous_of_add : uniform_continuous (of_add : \u03b1 \u2192 multiplicative \u03b1) :=\nuniform_continuous_id\nlemma uniform_continuous_to_add : uniform_continuous (to_add : multiplicative \u03b1 \u2192 \u03b1) :=\nuniform_continuous_id\n\nlemma uniformity_additive : \ud835\udce4 (additive \u03b1) = (\ud835\udce4 \u03b1).map (prod.map of_mul of_mul) :=\nby { convert map_id.symm, exact prod.map_id }\n\nlemma uniformity_multiplicative : \ud835\udce4 (multiplicative \u03b1) = (\ud835\udce4 \u03b1).map (prod.map of_add of_add) :=\nby { convert map_id.symm, exact prod.map_id }\n\nend\n\ninstance {p : \u03b1 \u2192 Prop} [t : uniform_space \u03b1] : uniform_space (subtype p) :=\nuniform_space.comap subtype.val t\n\nlemma uniformity_subtype {p : \u03b1 \u2192 Prop} [t : uniform_space \u03b1] :\n  \ud835\udce4 (subtype p) = comap (\u03bbq:subtype p \u00d7 subtype p, (q.1.1, q.2.1)) (\ud835\udce4 \u03b1) :=\nrfl\n\nlemma uniformity_set_coe {s : set \u03b1} [t : uniform_space \u03b1] :\n  \ud835\udce4 s = comap (prod.map (coe : s \u2192 \u03b1) (coe : s \u2192 \u03b1)) (\ud835\udce4 \u03b1) :=\nrfl\n\nlemma uniform_continuous_subtype_val {p : \u03b1 \u2192 Prop} [uniform_space \u03b1] :\n  uniform_continuous (subtype.val : {a : \u03b1 // p a} \u2192 \u03b1) :=\nuniform_continuous_comap\n\nlemma uniform_continuous_subtype_coe {p : \u03b1 \u2192 Prop} [uniform_space \u03b1] :\n  uniform_continuous (coe : {a : \u03b1 // p a} \u2192 \u03b1) :=\nuniform_continuous_subtype_val\n\nlemma uniform_continuous.subtype_mk {p : \u03b1 \u2192 Prop} [uniform_space \u03b1] [uniform_space \u03b2]\n  {f : \u03b2 \u2192 \u03b1} (hf : uniform_continuous f) (h : \u2200x, p (f x)) :\n  uniform_continuous (\u03bbx, \u27e8f x, h x\u27e9 : \u03b2 \u2192 subtype p) :=\nuniform_continuous_comap' hf\n\nlemma uniform_continuous_on_iff_restrict [uniform_space \u03b1] [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2}\n  {s : set \u03b1} :\n  uniform_continuous_on f s \u2194 uniform_continuous (s.restrict f) :=\nbegin\n  unfold uniform_continuous_on set.restrict uniform_continuous tendsto,\n  conv_rhs { rw [show (\u03bb x : s \u00d7 s, (f x.1, f x.2)) = prod.map f f \u2218 prod.map coe coe, from rfl,\n    uniformity_set_coe, \u2190 map_map, map_comap, range_prod_map, subtype.range_coe] },\n  refl\nend\n\nlemma tendsto_of_uniform_continuous_subtype\n  [uniform_space \u03b1] [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {a : \u03b1}\n  (hf : uniform_continuous (\u03bbx:s, f x.val)) (ha : s \u2208 \ud835\udcdd a) :\n  tendsto f (\ud835\udcdd a) (\ud835\udcdd (f a)) :=\nby rw [(@map_nhds_subtype_coe_eq \u03b1 _ 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 \u03b1] [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2}\n  {s : set \u03b1} (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 \u03b1] : uniform_space (\u03b1\u1d50\u1d52\u1d56) :=\nuniform_space.comap mul_opposite.unop \u2039_\u203a\n\n@[to_additive]\nlemma uniformity_mul_opposite [uniform_space \u03b1] :\n  \ud835\udce4 (\u03b1\u1d50\u1d52\u1d56) = comap (\u03bb q : \u03b1\u1d50\u1d52\u1d56 \u00d7 \u03b1\u1d50\u1d52\u1d56, (q.1.unop, q.2.unop)) (\ud835\udce4 \u03b1) :=\nrfl\n\n@[simp, to_additive] lemma comap_uniformity_mul_opposite [uniform_space \u03b1] :\n  comap (\u03bb p : \u03b1 \u00d7 \u03b1, (mul_opposite.op p.1, mul_opposite.op p.2)) (\ud835\udce4 \u03b1\u1d50\u1d52\u1d56) = \ud835\udce4 \u03b1 :=\nby simpa [uniformity_mul_opposite, comap_comap, (\u2218)] using comap_id\n\nnamespace mul_opposite\n\n@[to_additive]\nlemma uniform_continuous_unop [uniform_space \u03b1] : uniform_continuous (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) :=\nuniform_continuous_comap\n\n@[to_additive]\nlemma uniform_continuous_op [uniform_space \u03b1] : uniform_continuous (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) :=\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\u2081 : uniform_space \u03b1] [u\u2082 : uniform_space \u03b2] : uniform_space (\u03b1 \u00d7 \u03b2) :=\nu\u2081.comap prod.fst \u2293 u\u2082.comap prod.snd\n\n-- check the above produces no diamond\nexample [u\u2081 : uniform_space \u03b1] [u\u2082 : uniform_space \u03b2] :\n  (prod.topological_space : topological_space (\u03b1 \u00d7 \u03b2)) = uniform_space.to_topological_space :=\nrfl\n\ntheorem uniformity_prod [uniform_space \u03b1] [uniform_space \u03b2] : \ud835\udce4 (\u03b1 \u00d7 \u03b2) =\n  (\ud835\udce4 \u03b1).comap (\u03bbp:(\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2, (p.1.1, p.2.1)) \u2293\n  (\ud835\udce4 \u03b2).comap (\u03bbp:(\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2, (p.1.2, p.2.2)) :=\nrfl\n\nlemma uniformity_prod_eq_comap_prod [uniform_space \u03b1] [uniform_space \u03b2] :\n  \ud835\udce4 (\u03b1 \u00d7 \u03b2) = comap (\u03bb p : (\u03b1 \u00d7 \u03b2) \u00d7 (\u03b1 \u00d7 \u03b2), ((p.1.1, p.2.1), (p.1.2, p.2.2))) (\ud835\udce4 \u03b1 \u00d7\u1da0 \ud835\udce4 \u03b2) :=\nby rw [uniformity_prod, filter.prod, comap_inf, comap_comap, comap_comap]\n\nlemma uniformity_prod_eq_prod [uniform_space \u03b1] [uniform_space \u03b2] :\n  \ud835\udce4 (\u03b1 \u00d7 \u03b2) = map (\u03bb p : (\u03b1 \u00d7 \u03b1) \u00d7 (\u03b2 \u00d7 \u03b2), ((p.1.1, p.2.1), (p.1.2, p.2.2))) (\ud835\udce4 \u03b1 \u00d7\u1da0 \ud835\udce4 \u03b2) :=\nby rw [map_swap4_eq_comap, uniformity_prod_eq_comap_prod]\n\nlemma mem_uniformity_of_uniform_continuous_invariant [uniform_space \u03b1] [uniform_space \u03b2]\n  {s : set (\u03b2 \u00d7 \u03b2)} {f : \u03b1 \u2192 \u03b1 \u2192 \u03b2} (hf : uniform_continuous (\u03bb p : \u03b1 \u00d7 \u03b1, f p.1 p.2))\n  (hs : s \u2208 \ud835\udce4 \u03b2) :\n  \u2203 u \u2208 \ud835\udce4 \u03b1, \u2200 a b c, (a, b) \u2208 u \u2192 (f a c, f b c) \u2208 s :=\nbegin\n  rw [uniform_continuous, uniformity_prod_eq_prod, tendsto_map'_iff, (\u2218)] at hf,\n  rcases mem_prod_iff.1 (mem_map.1 $ hf hs) with \u27e8u, hu, v, hv, huvt\u27e9,\n  exact \u27e8u, hu, \u03bb a b c hab, @huvt ((_, _), (_, _)) \u27e8hab, refl_mem_uniformity hv\u27e9\u27e9\nend\n\nlemma mem_uniform_prod [t\u2081 : uniform_space \u03b1] [t\u2082 : uniform_space \u03b2] {a : set (\u03b1 \u00d7 \u03b1)}\n  {b : set (\u03b2 \u00d7 \u03b2)} (ha : a \u2208 \ud835\udce4 \u03b1) (hb : b \u2208 \ud835\udce4 \u03b2) :\n  {p:(\u03b1\u00d7\u03b2)\u00d7(\u03b1\u00d7\u03b2) | (p.1.1, p.2.1) \u2208 a \u2227 (p.1.2, p.2.2) \u2208 b } \u2208 \ud835\udce4 (\u03b1 \u00d7 \u03b2) :=\nby rw [uniformity_prod]; exact inter_mem_inf (preimage_mem_comap ha) (preimage_mem_comap hb)\n\nlemma tendsto_prod_uniformity_fst [uniform_space \u03b1] [uniform_space \u03b2] :\n  tendsto (\u03bbp:(\u03b1\u00d7\u03b2)\u00d7(\u03b1\u00d7\u03b2), (p.1.1, p.2.1)) (\ud835\udce4 (\u03b1 \u00d7 \u03b2)) (\ud835\udce4 \u03b1) :=\nle_trans (map_mono inf_le_left) map_comap_le\n\nlemma tendsto_prod_uniformity_snd [uniform_space \u03b1] [uniform_space \u03b2] :\n  tendsto (\u03bbp:(\u03b1\u00d7\u03b2)\u00d7(\u03b1\u00d7\u03b2), (p.1.2, p.2.2)) (\ud835\udce4 (\u03b1 \u00d7 \u03b2)) (\ud835\udce4 \u03b2) :=\nle_trans (map_mono inf_le_right) map_comap_le\n\nlemma uniform_continuous_fst [uniform_space \u03b1] [uniform_space \u03b2] :\n  uniform_continuous (\u03bbp:\u03b1\u00d7\u03b2, p.1) :=\ntendsto_prod_uniformity_fst\n\nlemma uniform_continuous_snd [uniform_space \u03b1] [uniform_space \u03b2] :\n  uniform_continuous (\u03bbp:\u03b1\u00d7\u03b2, p.2) :=\ntendsto_prod_uniformity_snd\n\nvariables [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3]\nlemma uniform_continuous.prod_mk\n  {f\u2081 : \u03b1 \u2192 \u03b2} {f\u2082 : \u03b1 \u2192 \u03b3} (h\u2081 : uniform_continuous f\u2081) (h\u2082 : uniform_continuous f\u2082) :\n  uniform_continuous (\u03bba, (f\u2081 a, f\u2082 a)) :=\nby rw [uniform_continuous, uniformity_prod]; exact\ntendsto_inf.2 \u27e8tendsto_comap_iff.2 h\u2081, tendsto_comap_iff.2 h\u2082\u27e9\n\nlemma uniform_continuous.prod_mk_left {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (h : uniform_continuous f) (b) :\n  uniform_continuous (\u03bb a, f (a,b)) :=\nh.comp (uniform_continuous_id.prod_mk uniform_continuous_const)\n\nlemma uniform_continuous.prod_mk_right {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (h : uniform_continuous f) (a) :\n  uniform_continuous (\u03bb b, f (a,b)) :=\nh.comp (uniform_continuous_const.prod_mk  uniform_continuous_id)\n\nlemma uniform_continuous.prod_map [uniform_space \u03b4] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4}\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 {\u03b1} {\u03b2} [u : uniform_space \u03b1] [v : uniform_space \u03b2] :\n  @uniform_space.to_topological_space (\u03b1 \u00d7 \u03b2) prod.uniform_space =\n    @prod.topological_space \u03b1 \u03b2 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\u2082 {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n  {ua1 ua2 : uniform_space \u03b1} {ub1 ub2 : uniform_space \u03b2} {uc1 : uniform_space \u03b3}\n  (h : by haveI := ua1; haveI := ub1; exact uniform_continuous (\u03bb p : \u03b1 \u00d7 \u03b2, f p.1 p.2)) :\n  by haveI := ua1 \u2293 ua2; haveI := ub1 \u2293 ub2; exact uniform_continuous (\u03bb p : \u03b1 \u00d7 \u03b2, f p.1 p.2) :=\nbegin\n  -- proof essentially copied from ``continuous_inf_dom_left\u2082`\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 \u2293 ua2) (ub1 \u2293 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\u2082 {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n  {ua1 ua2 : uniform_space \u03b1} {ub1 ub2 : uniform_space \u03b2} {uc1 : uniform_space \u03b3}\n  (h : by haveI := ua2; haveI := ub2; exact uniform_continuous (\u03bb p : \u03b1 \u00d7 \u03b2, f p.1 p.2)) :\n  by haveI := ua1 \u2293 ua2; haveI := ub1 \u2293 ub2; exact uniform_continuous (\u03bb p : \u03b1 \u00d7 \u03b2, f p.1 p.2) :=\nbegin\n  -- proof essentially copied from ``continuous_inf_dom_right\u2082`\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 \u2293 ua2) (ub1 \u2293 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\u2082 {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n  {uas : set (uniform_space \u03b1)} {ubs : set (uniform_space \u03b2)}\n  {ua : uniform_space \u03b1} {ub : uniform_space \u03b2} {uc : uniform_space \u03b3}\n  (ha : ua \u2208 uas) (hb : ub \u2208 ubs)\n  (hf : uniform_continuous (\u03bb p : \u03b1 \u00d7 \u03b2, f p.1 p.2)):\n  by haveI := Inf uas; haveI := Inf ubs;\n    exact @uniform_continuous _ _ _ uc (\u03bb p : \u03b1 \u00d7 \u03b2, f p.1 p.2) :=\nbegin\n  -- proof essentially copied from ``continuous_Inf_dom`\n  let t : uniform_space (\u03b1 \u00d7 \u03b2) := 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 {\u03b4' : Type*} [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3] [uniform_space \u03b4]\n  [uniform_space \u03b4']\n\nlocal notation f ` \u2218\u2082 ` g := function.bicompr f g\n\n/-- Uniform continuity for functions of two variables. -/\ndef uniform_continuous\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) := uniform_continuous (uncurry f)\n\nlemma uniform_continuous\u2082_def (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :\n  uniform_continuous\u2082 f \u2194 uniform_continuous (uncurry f) := iff.rfl\n\nlemma uniform_continuous\u2082.uniform_continuous {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (h : uniform_continuous\u2082 f) :\n  uniform_continuous (uncurry f) := h\n\nlemma uniform_continuous\u2082_curry (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) :\n  uniform_continuous\u2082 (function.curry f) \u2194 uniform_continuous f :=\nby rw [uniform_continuous\u2082, uncurry_curry]\n\nlemma uniform_continuous\u2082.comp {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {g : \u03b3 \u2192 \u03b4}\n  (hg : uniform_continuous g) (hf : uniform_continuous\u2082 f) :\n  uniform_continuous\u2082 (g \u2218\u2082 f) :=\nhg.comp hf\n\nlemma uniform_continuous\u2082.bicompl {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {ga : \u03b4 \u2192 \u03b1} {gb : \u03b4' \u2192 \u03b2}\n  (hf : uniform_continuous\u2082 f) (hga : uniform_continuous ga) (hgb : uniform_continuous gb) :\n  uniform_continuous\u2082 (bicompl f ga gb) :=\nhf.uniform_continuous.comp (hga.prod_map hgb)\n\nend\n\nlemma to_topological_space_subtype [u : uniform_space \u03b1] {p : \u03b1 \u2192 Prop} :\n  @uniform_space.to_topological_space (subtype p) subtype.uniform_space =\n    @subtype.topological_space \u03b1 p u.to_topological_space := rfl\n\nsection sum\nvariables [uniform_space \u03b1] [uniform_space \u03b2]\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 (\u03b1 \u2295 \u03b2) :=\nuniform_space.core.mk'\n  (map (\u03bb p : \u03b1 \u00d7 \u03b1, (inl p.1, inl p.2)) (\ud835\udce4 \u03b1) \u2294 map (\u03bb p : \u03b2 \u00d7 \u03b2, (inr p.1, inr p.2)) (\ud835\udce4 \u03b2))\n  (\u03bb r \u27e8H\u2081, H\u2082\u27e9 x, by cases x; [apply refl_mem_uniformity H\u2081, apply refl_mem_uniformity H\u2082])\n  (\u03bb r \u27e8H\u2081, H\u2082\u27e9, \u27e8symm_le_uniformity H\u2081, symm_le_uniformity H\u2082\u27e9)\n  (\u03bb r \u27e8Hr\u03b1, Hr\u03b2\u27e9, begin\n    rcases comp_mem_uniformity_sets Hr\u03b1 with \u27e8t\u03b1, ht\u03b1, Ht\u03b1\u27e9,\n    rcases comp_mem_uniformity_sets Hr\u03b2 with \u27e8t\u03b2, ht\u03b2, Ht\u03b2\u27e9,\n    refine \u27e8_,\n      \u27e8mem_map_iff_exists_image.2 \u27e8t\u03b1, ht\u03b1, subset_union_left _ _\u27e9,\n       mem_map_iff_exists_image.2 \u27e8t\u03b2, ht\u03b2, subset_union_right _ _\u27e9\u27e9, _\u27e9,\n    rintros \u27e8_, _\u27e9 \u27e8z, \u27e8\u27e8a, b\u27e9, hab, \u27e8\u27e9\u27e9 | \u27e8\u27e8a, b\u27e9, hab, \u27e8\u27e9\u27e9,\n                       \u27e8\u27e8_, c\u27e9, hbc, \u27e8\u27e9\u27e9 | \u27e8\u27e8_, c\u27e9, hbc, \u27e8\u27e9\u27e9\u27e9,\n    { have A : (a, c) \u2208 t\u03b1 \u25cb t\u03b1 := \u27e8b, hab, hbc\u27e9,\n      exact Ht\u03b1 A },\n    { have A : (a, c) \u2208 t\u03b2 \u25cb t\u03b2 := \u27e8b, hab, hbc\u27e9,\n      exact Ht\u03b2 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 (\u03b1 \u00d7 \u03b1)} (ha : a \u2208 \ud835\udce4 \u03b1) {b : set (\u03b2 \u00d7 \u03b2)} (hb : b \u2208 \ud835\udce4 \u03b2) :\n  ((\u03bb p : (\u03b1 \u00d7 \u03b1), (inl p.1, inl p.2)) '' a \u222a (\u03bb p : (\u03b2 \u00d7 \u03b2), (inr p.1, inr p.2)) '' b) \u2208\n    (@uniform_space.core.sum \u03b1 \u03b2 _ _).uniformity :=\n\u27e8mem_map_iff_exists_image.2 \u27e8_, ha, subset_union_left _ _\u27e9,\n  mem_map_iff_exists_image.2 \u27e8_, hb, subset_union_right _ _\u27e9\u27e9\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 (\u03b1 \u2295 \u03b2)} (hs : is_open s) {x : \u03b1 \u2295 \u03b2} (xs : x \u2208 s) :\n  { p : ((\u03b1 \u2295 \u03b2) \u00d7 (\u03b1 \u2295 \u03b2)) | p.1 = x \u2192 p.2 \u2208 s } \u2208 (@uniform_space.core.sum \u03b1 \u03b2 _ _).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 _ \u27e8\u27e8_, b\u27e9, h, \u27e8\u27e9\u27e9 \u27e8\u27e9,\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 _ \u27e8\u27e8a, _\u27e9, h, \u27e8\u27e9\u27e9 \u27e8\u27e9,\n    exact h rfl },\nend\n\nlemma open_of_uniformity_sum_aux {s : set (\u03b1 \u2295 \u03b2)}\n  (hs : \u2200x \u2208 s, { p : ((\u03b1 \u2295 \u03b2) \u00d7 (\u03b1 \u2295 \u03b2)) | p.1 = x \u2192 p.2 \u2208 s } \u2208\n    (@uniform_space.core.sum \u03b1 \u03b2 _ _).uniformity) :\n  is_open s :=\nbegin\n  split,\n  { refine (@is_open_iff_mem_nhds \u03b1 _ _).2 (\u03bb a ha, mem_nhds_uniformity_iff_right.2 _),\n    rcases mem_map_iff_exists_image.1 (hs _ ha).1 with \u27e8t, ht, st\u27e9,\n    refine mem_of_superset ht _,\n    rintro p pt rfl, exact st \u27e8_, pt, rfl\u27e9 rfl },\n  { refine (@is_open_iff_mem_nhds \u03b2 _ _).2 (\u03bb b hb, mem_nhds_uniformity_iff_right.2 _),\n    rcases mem_map_iff_exists_image.1 (hs _ hb).2 with \u27e8t, ht, st\u27e9,\n    refine mem_of_superset ht _,\n    rintro p pt rfl, exact st \u27e8_, pt, rfl\u27e9 rfl }\nend\n\n/- We can now define the uniform structure on the disjoint union -/\ninstance sum.uniform_space : uniform_space (\u03b1 \u2295 \u03b2) :=\n{ to_core := uniform_space.core.sum,\n  is_open_uniformity := \u03bb s, \u27e8uniformity_sum_of_open_aux, open_of_uniformity_sum_aux\u27e9 }\n\nlemma sum.uniformity : \ud835\udce4 (\u03b1 \u2295 \u03b2) =\n    map (\u03bb p : \u03b1 \u00d7 \u03b1, (inl p.1, inl p.2)) (\ud835\udce4 \u03b1) \u2294\n    map (\u03bb p : \u03b2 \u00d7 \u03b2, (inr p.1, inr p.2)) (\ud835\udce4 \u03b2) := rfl\n\nend sum\n\nend constructions\n\n/-- Let `c : \u03b9 \u2192 set \u03b1` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x \u2208 s` its `n`-neighborhood is contained in some `c i`. -/\nlemma lebesgue_number_lemma {\u03b1 : Type u} [uniform_space \u03b1] {s : set \u03b1} {\u03b9} {c : \u03b9 \u2192 set \u03b1}\n  (hs : is_compact s) (hc\u2081 : \u2200 i, is_open (c i)) (hc\u2082 : s \u2286 \u22c3 i, c i) :\n  \u2203 n \u2208 \ud835\udce4 \u03b1, \u2200 x \u2208 s, \u2203 i, {y | (x, y) \u2208 n} \u2286 c i :=\nbegin\n  let u := \u03bb n, {x | \u2203 i (m \u2208 \ud835\udce4 \u03b1), {y | (x, y) \u2208 m \u25cb n} \u2286 c i},\n  have hu\u2081 : \u2200 n \u2208 \ud835\udce4 \u03b1, is_open (u n),\n  { refine \u03bb n hn, is_open_uniformity.2 _,\n    rintro x \u27e8i, m, hm, h\u27e9,\n    rcases comp_mem_uniformity_sets hm with \u27e8m', hm', mm'\u27e9,\n    apply (\ud835\udce4 \u03b1).sets_of_superset hm',\n    rintros \u27e8x, y\u27e9 hp rfl,\n    refine \u27e8i, m', hm', \u03bb z hz, h (monotone_id.comp_rel monotone_const mm' _)\u27e9,\n    dsimp [-mem_comp_rel] at hz \u22a2, rw comp_rel_assoc,\n    exact \u27e8y, hp, hz\u27e9 },\n  have hu\u2082 : s \u2286 \u22c3 n \u2208 \ud835\udce4 \u03b1, u n,\n  { intros x hx,\n    rcases mem_Union.1 (hc\u2082 hx) with \u27e8i, h\u27e9,\n    rcases comp_mem_uniformity_sets (is_open_uniformity.1 (hc\u2081 i) x h) with \u27e8m', hm', mm'\u27e9,\n    exact mem_bUnion hm' \u27e8i, _, hm', \u03bb y hy, mm' hy rfl\u27e9 },\n  rcases hs.elim_finite_subcover_image hu\u2081 hu\u2082 with \u27e8b, bu, b_fin, b_cover\u27e9,\n  refine \u27e8_, (bInter_mem b_fin).2 bu, \u03bb x hx, _\u27e9,\n  rcases mem_Union\u2082.1 (b_cover hx) with \u27e8n, bn, i, m, hm, h\u27e9,\n  refine \u27e8i, \u03bb y hy, h _\u27e9,\n  exact prod_mk_mem_comp_rel (refl_mem_uniformity hm) (bInter_subset_of_mem bn hy)\nend\n\n/-- Let `c : set (set \u03b1)` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x \u2208 s` its `n`-neighborhood is contained in some `t \u2208 c`. -/\nlemma lebesgue_number_lemma_sUnion {\u03b1 : Type u} [uniform_space \u03b1] {s : set \u03b1} {c : set (set \u03b1)}\n  (hs : is_compact s) (hc\u2081 : \u2200 t \u2208 c, is_open t) (hc\u2082 : s \u2286 \u22c3\u2080 c) :\n  \u2203 n \u2208 \ud835\udce4 \u03b1, \u2200 x \u2208 s, \u2203 t \u2208 c, \u2200 y, (x, y) \u2208 n \u2192 y \u2208 t :=\nby rw sUnion_eq_Union at hc\u2082;\n   simpa using lebesgue_number_lemma hs (by simpa) hc\u2082\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 \u03b1]\n  {K U : set \u03b1} (hK : is_compact K) (hU : is_open U) (hKU : K \u2286 U) :\n  \u2203 V \u2208 \ud835\udce4 \u03b1, is_open V \u2227 \u2200 x \u2208 K, uniform_space.ball x V \u2286 U :=\nbegin\n  let W : K \u2192 set (\u03b1 \u00d7 \u03b1) := \u03bb k, classical.some $ is_open_iff_open_ball_subset.mp hU k.1 $ hKU k.2,\n  have hW : \u2200 k, W k \u2208 \ud835\udce4 \u03b1 \u2227 is_open (W k) \u2227 uniform_space.ball k.1 (W k) \u2286 U,\n  { intros k,\n    obtain \u27e8h\u2081, h\u2082, h\u2083\u27e9 := classical.some_spec (is_open_iff_open_ball_subset.mp hU k.1 (hKU k.2)),\n    exact \u27e8h\u2081, h\u2082, h\u2083\u27e9, },\n  let c : K \u2192 set \u03b1 := \u03bb k, uniform_space.ball k.1 (W k),\n  have hc\u2081 : \u2200 k, is_open (c k), { exact \u03bb k, uniform_space.is_open_ball k.1 (hW k).2.1, },\n  have hc\u2082 : K \u2286 \u22c3 i, c i,\n  { intros k hk,\n    simp only [mem_Union, set_coe.exists],\n    exact \u27e8k, hk, uniform_space.mem_ball_self k (hW \u27e8k, hk\u27e9).1\u27e9, },\n  have hc\u2083 : \u2200 k, c k \u2286 U, { exact \u03bb k, (hW k).2.2, },\n  obtain \u27e8V, hV, hV'\u27e9 := lebesgue_number_lemma hK hc\u2081 hc\u2082,\n  refine \u27e8interior V, interior_mem_uniformity hV, is_open_interior, _\u27e9,\n  intros k hk,\n  obtain \u27e8k', hk'\u27e9 := hV' k hk,\n  exact ((ball_mono interior_subset k).trans hk').trans (hc\u2083 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 \u03b1]\n\ntheorem tendsto_nhds_right {f : filter \u03b2} {u : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n  tendsto u f (\ud835\udcdd a) \u2194 tendsto (\u03bb x, (a, u x)) f (\ud835\udce4 \u03b1)  :=\nby rw [nhds_eq_comap_uniformity, tendsto_comap_iff]\n\ntheorem tendsto_nhds_left {f : filter \u03b2} {u : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n  tendsto u f (\ud835\udcdd a) \u2194 tendsto (\u03bb x, (u x, a)) f (\ud835\udce4 \u03b1)  :=\nby rw [nhds_eq_comap_uniformity', tendsto_comap_iff]\n\ntheorem continuous_at_iff'_right [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n  continuous_at f b \u2194 tendsto (\u03bb x, (f b, f x)) (\ud835\udcdd b) (\ud835\udce4 \u03b1) :=\nby rw [continuous_at, tendsto_nhds_right]\n\ntheorem continuous_at_iff'_left [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n  continuous_at f b \u2194 tendsto (\u03bb x, (f x, f b)) (\ud835\udcdd b) (\ud835\udce4 \u03b1) :=\nby rw [continuous_at, tendsto_nhds_left]\n\ntheorem continuous_at_iff_prod [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n  continuous_at f b \u2194 tendsto (\u03bb x : \u03b2 \u00d7 \u03b2, (f x.1, f x.2)) (\ud835\udcdd (b, b)) (\ud835\udce4 \u03b1) :=\n\u27e8\u03bb H, le_trans (H.prod_map' H) (nhds_le_uniformity _),\n  \u03bb H, continuous_at_iff'_left.2 $ H.comp $ tendsto_id.prod_mk_nhds tendsto_const_nhds\u27e9\n\ntheorem continuous_within_at_iff'_right [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} {s : set \u03b2} :\n  continuous_within_at f s b \u2194 tendsto (\u03bb x, (f b, f x)) (\ud835\udcdd[s] b) (\ud835\udce4 \u03b1) :=\nby rw [continuous_within_at, tendsto_nhds_right]\n\ntheorem continuous_within_at_iff'_left [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} {s : set \u03b2} :\n  continuous_within_at f s b \u2194 tendsto (\u03bb x, (f x, f b)) (\ud835\udcdd[s] b) (\ud835\udce4 \u03b1) :=\nby rw [continuous_within_at, tendsto_nhds_left]\n\ntheorem continuous_on_iff'_right [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {s : set \u03b2} :\n  continuous_on f s \u2194 \u2200 b \u2208 s, tendsto (\u03bb x, (f b, f x)) (\ud835\udcdd[s] b) (\ud835\udce4 \u03b1) :=\nby simp [continuous_on, continuous_within_at_iff'_right]\n\ntheorem continuous_on_iff'_left [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} {s : set \u03b2} :\n  continuous_on f s \u2194 \u2200 b \u2208 s, tendsto (\u03bb x, (f x, f b)) (\ud835\udcdd[s] b) (\ud835\udce4 \u03b1) :=\nby simp [continuous_on, continuous_within_at_iff'_left]\n\ntheorem continuous_iff'_right [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} :\n  continuous f \u2194 \u2200 b, tendsto (\u03bb x, (f b, f x)) (\ud835\udcdd b) (\ud835\udce4 \u03b1) :=\ncontinuous_iff_continuous_at.trans $ forall_congr $ \u03bb b, tendsto_nhds_right\n\ntheorem continuous_iff'_left [topological_space \u03b2] {f : \u03b2 \u2192 \u03b1} :\n  continuous f \u2194 \u2200 b, tendsto (\u03bb x, (f x, f b)) (\ud835\udcdd b) (\ud835\udce4 \u03b1) :=\ncontinuous_iff_continuous_at.trans $ forall_congr $ \u03bb b, tendsto_nhds_left\n\nend uniform\n\nlemma filter.tendsto.congr_uniformity {\u03b1 \u03b2} [uniform_space \u03b2] {f g : \u03b1 \u2192 \u03b2} {l : filter \u03b1} {b : \u03b2}\n  (hf : tendsto f l (\ud835\udcdd b)) (hg : tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b2)) :\n  tendsto g l (\ud835\udcdd b) :=\nuniform.tendsto_nhds_right.2 $ (uniform.tendsto_nhds_right.1 hf).uniformity_trans hg\n\nlemma uniform.tendsto_congr {\u03b1 \u03b2} [uniform_space \u03b2] {f g : \u03b1 \u2192 \u03b2} {l : filter \u03b1} {b : \u03b2}\n  (hfg : tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b2)) :\n  tendsto f l (\ud835\udcdd b) \u2194 tendsto g l (\ud835\udcdd b) :=\n\u27e8\u03bb h, h.congr_uniformity hfg, \u03bb h, h.congr_uniformity hfg.uniformity_symm\u27e9\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 {\u03b1 : Type*} [partial_order \u03b1] (b : \u03b1) : partial_order {x // b \u2264 x} := by apply_instance\n\n-- why is subtype.ext an iff?\n\ninstance slice.semilattice_sup {\u03b1 : Type*} [semilattice_sup \u03b1] (b : \u03b1) : semilattice_sup {x // b \u2264 x} :=\n{ sup := \u03bb x y, \u27e8x.val \u2294 y.val, le_sup_left_of_le x.2\u27e9,\n  le_sup_left := \u03bb _ _, le_sup_left,\n  le_sup_right := \u03bb _ _, le_sup_right,\n  sup_le := \u03bb _ _ _, sup_le,\n  ..subtype.partial_order _}\n\ninstance slice.semilattice_inf {\u03b1 : Type*} [semilattice_inf \u03b1] (b : \u03b1) : semilattice_inf {x // b \u2264 x} :=\n{ inf := \u03bb x y, \u27e8x.val \u2293 y.val, le_inf x.2 y.2\u27e9,\n  inf_le_left := \u03bb _ _, inf_le_left,\n  inf_le_right := \u03bb _ _, inf_le_right,\n  le_inf := \u03bb _ _ _, le_inf,\n  ..subtype.partial_order _}\n\ninstance slice.lattice {\u03b1 : Type*} [lattice \u03b1] (b : \u03b1) : lattice {x // b \u2264 x} :=\n{ ..slice.semilattice_inf b, ..slice.semilattice_sup b}\n\ninstance slice.order_top {\u03b1 : Type*} [order_top \u03b1] (b : \u03b1) : order_top {x // b \u2264 x} :=\n{ top := \u27e8\u22a4, le_top\u27e9,\n  le_top := \u03bb _, le_top,\n  ..subtype.partial_order _ }\n\ninstance slice.order_bot {\u03b1 : Type*} [partial_order \u03b1] (b : \u03b1) : order_bot {x // b \u2264 x} :=\n{ bot := \u27e8b, le_refl b\u27e9,\n  bot_le := subtype.property,\n  ..subtype.partial_order _ }\n\ninstance slice.bounded_lattice {\u03b1 : Type*} [bounded_lattice \u03b1] (b : \u03b1) : bounded_lattice {x // b \u2264 x} :=\n{ ..slice.order_top b, ..slice.order_bot b, ..slice.lattice b}\n\ninstance slice.has_Sup {\u03b1 : Type*} [complete_lattice \u03b1] (b : \u03b1) : has_Sup {x // b \u2264 x} :=\n\u27e8\u03bb X, \u27e8Sup $ set.insert b (set.image subtype.val X), le_Sup $ set.mem_insert b _\u27e9\u27e9\n\ninstance slice.has_Inf {\u03b1 : Type*} [complete_lattice \u03b1] (b : \u03b1) : has_Inf {x // b \u2264 x} :=\n\u27e8\u03bb X, \u27e8Inf $ set.image subtype.val X, le_Inf $ by {rintro _ \u27e8y, _, rfl\u27e9, exact y.2}\u27e9\u27e9\n\ninstance slice.complete_lattice {\u03b1 : Type*} [complete_lattice \u03b1] (b : \u03b1) : complete_lattice {x // b \u2264 x} :=\n{ le_Sup := \u03bb X y h, le_Sup $ set.mem_insert_of_mem _ \u27e8y, h, rfl\u27e9,\n  Sup_le := \u03bb X y h, Sup_le $ \u03bb x h2, begin\n    change x \u2208 insert b _ at h2,\n    rw set.mem_insert_iff at h2,\n    rcases h2 with \u27e8rfl, h2\u27e9, exact y.2,\n    rcases h2 with \u27e8_, h2, rfl\u27e9,\n    exact h _ h2,\n  end,\n  Inf_le := \u03bb X y h, Inf_le \u27e8y, h, rfl\u27e9,\n  le_Inf := \u03bb X y h, le_Inf $ by {rintro _ \u27e8x, hx, rfl\u27e9, 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 \u2964 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\u2081 v\u2081 v\u2082 u\u2081 u\u2082\n\nnamespace CategoryTheory\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C]\n\n#print CategoryTheory.ULift.upFunctor /-\n/-- The functorial version of `ulift.up`. -/\n@[simps]\ndef ULift.upFunctor : C \u2964 ULift.{u\u2082} 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\u2082} C \u2964 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\u2093'. -/\n/-- The categorical equivalence between `C` and `ulift C`. -/\n@[simps]\ndef ULift.equivalence : C \u224c ULift.{u\u2082} C\n    where\n  Functor := ULift.upFunctor\n  inverse := ULift.downFunctor\n  unitIso :=\n    { Hom := \ud835\udfd9 _\n      inv := \ud835\udfd9 _ }\n  counitIso :=\n    { Hom :=\n        { app := fun X => \ud835\udfd9 _\n          naturality' := fun X Y f => by\n            change f \u226b \ud835\udfd9 _ = \ud835\udfd9 _ \u226b f\n            simp }\n      inv :=\n        { app := fun X => \ud835\udfd9 _\n          naturality' := fun X Y f => by\n            change f \u226b \ud835\udfd9 _ = \ud835\udfd9 _ \u226b f\n            simp }\n      hom_inv_id' := by\n        ext\n        change \ud835\udfd9 _ \u226b \ud835\udfd9 _ = \ud835\udfd9 _\n        simp\n      inv_hom_id' := by\n        ext\n        change \ud835\udfd9 _ \u226b \ud835\udfd9 _ = \ud835\udfd9 _\n        simp }\n  functor_unitIso_comp' X := by\n    change \ud835\udfd9 X \u226b \ud835\udfd9 X = \ud835\udfd9 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  \u27e8(Inhabited.default C : C)\u27e9\n\n#print CategoryTheory.ULiftHom.objDown /-\n/-- The obvious function `ulift_hom C \u2192 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 \u2192 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\u2093'. -/\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\u2093'. -/\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\u2082 v\u2081} (ULiftHom.{v\u2082} C)\n    where\n  Hom A B := ULift.{v\u2082} <| A.objDown \u27f6 B.objDown\n  id A := \u27e8\ud835\udfd9 _\u27e9\n  comp A B C f g := \u27e8f.down \u226b g.down\u27e9\n\n#print CategoryTheory.ULiftHom.up /-\n/-- One half of the quivalence between `C` and `ulift_hom C`. -/\n@[simps]\ndef ULiftHom.up : C \u2964 ULiftHom C where\n  obj := ULiftHom.objUp\n  map X Y f := \u27e8f\u27e9\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 \u2964 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\u2093'. -/\n/-- The equivalence between `C` and `ulift_hom C`. -/\ndef ULiftHom.equiv : C \u224c 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\u2081} C)\n    where\n  Hom X Y := ULift.{max w\u2081 u\u2081} <| X.down \u27f6 Y.down\n  id X := \u27e8\ud835\udfd9 _\u27e9\n  comp X Y Z f g := \u27e8f.down \u226b g.down\u27e9\n\n#print CategoryTheory.AsSmall.up /-\n/-- One half of the equivalence between `C` and `as_small C`. -/\n@[simps]\ndef AsSmall.up : C \u2964 AsSmall C where\n  obj X := \u27e8X\u27e9\n  map X Y f := \u27e8f\u27e9\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 \u2964 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\u2093'. -/\n/-- The equivalence between `C` and `as_small C`. -/\n@[simps]\ndef AsSmall.equiv : C \u224c 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  \u27e8\u27e8Inhabited.default _\u27e9\u27e9\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\u2093'. -/\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 \u224c 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\u2081 v\u2081 \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\u2081) [category C] (D : Type u\u2081) [category D] : category (C \u2295 D) :=\n  category.mk\n\n@[simp] theorem sum_comp_inl (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] {P : C} {Q : C} {R : C} (f : sum.inl P \u27f6 sum.inl Q) (g : sum.inl Q \u27f6 sum.inl R) : f \u226b g = f \u226b g :=\n  rfl\n\n@[simp] theorem sum_comp_inr (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] {P : D} {Q : D} {R : D} (f : sum.inr P \u27f6 sum.inr Q) (g : sum.inr Q \u27f6 sum.inr R) : f \u226b g = f \u226b g :=\n  rfl\n\nnamespace sum\n\n\n/-- `inl_` is the functor `X \u21a6 inl X`. -/\n-- Unfortunate naming here, suggestions welcome.\n\ndef inl_ (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : C \u2964 C \u2295 D :=\n  functor.mk (fun (X : C) => sum.inl X) fun (X Y : C) (f : X \u27f6 Y) => f\n\n/-- `inr_` is the functor `X \u21a6 inr X`. -/\ndef inr_ (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : D \u2964 C \u2295 D :=\n  functor.mk (fun (X : D) => sum.inr X) fun (X Y : D) (f : X \u27f6 Y) => f\n\n/-- The functor exchanging two direct summand categories. -/\ndef swap (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : C \u2295 D \u2964 D \u2295 C :=\n  functor.mk (fun (X : C \u2295 D) => sorry) fun (X Y : C \u2295 D) (f : X \u27f6 Y) => sorry\n\n@[simp] theorem swap_obj_inl (C : Type u\u2081) [category C] (D : Type u\u2081) [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\u2081) [category C] (D : Type u\u2081) [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\u2081) [category C] (D : Type u\u2081) [category D] {X : C} {Y : C} {f : sum.inl X \u27f6 sum.inl Y} : functor.map (swap C D) f = f :=\n  rfl\n\n@[simp] theorem swap_map_inr (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] {X : D} {Y : D} {f : sum.inr X \u27f6 sum.inr Y} : functor.map (swap C D) f = f :=\n  rfl\n\nnamespace swap\n\n\n/-- `swap` gives an equivalence between `C \u2295 D` and `D \u2295 C`. -/\ndef equivalence (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : C \u2295 D \u224c D \u2295 C :=\n  equivalence.mk (swap C D) (swap D C) (nat_iso.of_components (fun (X : C \u2295 D) => eq_to_iso sorry) sorry)\n    (nat_iso.of_components (fun (X : D \u2295 C) => eq_to_iso sorry) sorry)\n\nprotected instance is_equivalence (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : is_equivalence (swap C D) :=\n  is_equivalence.of_equivalence (equivalence C D)\n\n/-- The double swap on `C \u2295 D` is naturally isomorphic to the identity functor. -/\ndef symmetry (C : Type u\u2081) [category C] (D : Type u\u2081) [category D] : swap C D \u22d9 swap D C \u2245 \ud835\udfed :=\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\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 D) : A \u2295 C \u2964 B \u2295 D :=\n  mk (fun (X : A \u2295 C) => sorry) fun (X Y : A \u2295 C) (f : X \u27f6 Y) => sorry\n\n@[simp] theorem sum_obj_inl {A : Type u\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 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\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 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\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 D) {a : A} {a' : A} (f : sum.inl a \u27f6 sum.inl a') : map (sum F G) f = map F f :=\n  rfl\n\n@[simp] theorem sum_map_inr {A : Type u\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C] {D : Type u\u2081} [category D] (F : A \u2964 B) (G : C \u2964 D) {c : C} {c' : C} (f : sum.inr c \u27f6 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\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C] {D : Type u\u2081} [category D] {F : A \u2964 B} {G : A \u2964 B} {H : C \u2964 D} {I : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) : functor.sum F H \u27f6 functor.sum G I :=\n  mk fun (X : A \u2295 C) => sorry\n\n@[simp] theorem sum_app_inl {A : Type u\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C] {D : Type u\u2081} [category D] {F : A \u2964 B} {G : A \u2964 B} {H : C \u2964 D} {I : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) (a : A) : app (sum \u03b1 \u03b2) (sum.inl a) = app \u03b1 a :=\n  rfl\n\n@[simp] theorem sum_app_inr {A : Type u\u2081} [category A] {B : Type u\u2081} [category B] {C : Type u\u2081} [category C] {D : Type u\u2081} [category D] {F : A \u2964 B} {G : A \u2964 B} {H : C \u2964 D} {I : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) (c : C) : app (sum \u03b1 \u03b2) (sum.inr c) = app \u03b2 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 : \u2115 \u2192 Type\n| zero : langf 0\n| succ : langf 1\n| add  : langf 2\n| mul : langf 2\n\ninductive langp : \u2115 \u2192 Type\n| le : langp 2\n\n@[reducible] def LA : language := \u27e8langf, langp\u27e9\n\ninductive additional_pr : \u2115 \u2192 Type\n| lt : additional_pr 2\n| dvd : additional_pr 2\n| prime : additional_pr 1\n\n@[reducible] def additional : language := \u27e8\u03bb _, pempty, additional_pr\u27e9\n\ninductive LIopen_fn : \u2115 \u2192 Type\n| pair : LIopen_fn 2\n\n@[reducible] def LIopen : language := \u27e8LIopen_fn, \u03bb _, pempty\u27e9\n\ninductive LISigma\u2081_fn : \u2115 \u2192 Type\n| exp : LISigma\u2081_fn 1\n\n@[reducible] def LISigma\u2081 : language := \u27e8LISigma\u2081_fn, \u03bb _, pempty\u27e9\n\n@[reducible] def LA' : language := LA + additional\n\ninstance : has_zero_symbol LA := \u27e8langf.zero\u27e9\ninstance : has_succ_symbol LA := \u27e8langf.succ\u27e9\ninstance : has_add_symbol LA := \u27e8langf.add\u27e9\ninstance : has_mul_symbol LA := \u27e8langf.mul\u27e9\ninstance : has_le_symbol LA := \u27e8langp.le\u27e9\n\n@[reducible] def LISigma\u2081.exp (t : term LISigma\u2081) : term LISigma\u2081 := term.app LISigma\u2081_fn.exp \u2039t\u203a\n\nprefix `exp `:max := LISigma\u2081.exp\n\n@[reducible] def LIopen.pair (t u : term LIopen) : term LIopen := term.app LIopen_fn.pair \u2039t, u\u203a\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 := \u27e8by refl\u27e9\n\ninstance commutes_additional : language.commutes additional LA' L := \u27e8by refl\u27e9\n\ndef lt (t u : term L) : formula L :=\napp ((coe : LA'.pr 2 \u2192 L.pr 2) (sum.inr additional_pr.lt)) \u2039t, u\u203a\n\ndef dvd (t u : term L) : formula L :=\napp ((coe : LA'.pr 2 \u2192 L.pr 2) (sum.inr additional_pr.dvd)) \u2039t, u\u203a\n\ndef prime (t : term L) : formula L := app ((coe : LA'.pr 1 \u2192 L.pr 1) (sum.inr additional_pr.prime)) \u2039t\u203a\n\nnotation t ` is_prime`:80 := prime t\n\ninstance lt_abb : abberavation\u2082 (@lt L _) := { map_rew := by simp[lt], arity := by simp[lt] }\n\ninstance dvd_abb : abberavation\u2082 (@dvd L _) := { map_rew := by simp[dvd], arity := by simp[dvd] }\n\ninstance is_prime_abb : abberavation\u2081 (@prime L _) := { map_rew := by simp[prime], arity := by simp[prime] }\n\nend additional\n\nlocal infix ` \u227a `:50 := additional.lt\n\nlocal infix ` \u236d `:50 := additional.dvd\n\ninductive robinson : Theory LA\n| q1 : robinson \u2200\u2081 x, 0 \u2260' Succ x\n| q2 : robinson \u2200\u2081 x, \u2200\u2081 y, ((Succ x =' Succ y) \u27f6 (x =' y))\n| q3 : robinson \u2200\u2081 x, ((x =' 0) \u2294 \u2203\u2081 y, x =' Succ y)\n| q4 : robinson \u2200\u2081 x, x + 0 =' x\n| q5 : robinson \u2200\u2081 x y, x + Succ y =' Succ (x + y)\n| q6 : robinson \u2200\u2081 x, x * 0 =' 0\n| q7 : robinson \u2200\u2081 x y, x * Succ y =' x * y + x\n| q8 : robinson \u2200\u2081 x y, ((x \u227c y) \u27f7 \u2203\u2081 z, z + x =' y)\n\nnotation `\ud835\udc10` := robinson\n\ninstance : closed_Theory \ud835\udc10 := \u27e8\u03bb p h, by cases h; simp[is_sentence, lrarrow_def, formula.ex, formula.and, fal_fn, ex_fn]\u27e9\n\nnamespace additional\n\ninstance addditional_predicate : additional.predicate := \u27e8\u03bb n, pempty.is_empty\u27e9\n\n@[simp] def df_pr : \u03a0 {n} (r : additional.pr n), formula LA\n| 2 additional_pr.lt := ((#0 : term LA) \u227c #1) \u2293 ((#0 : term LA) \u2260' #1)\n| 2 additional_pr.dvd := \u2203. (#0 * #1 =' #2)\n| 1 additional_pr.prime := \u2203. (#0 + 1 =' #1) \u2293 \u2200. (\u2203. (#0 * #2 =' #1) \u27f6 (#0 =' 1) \u2294 (#0 =' #1))\n\n@[reducible] def defs : LA.definitions additional :=\n{ df_fn := \u03bb n f, by exfalso; exact is_empty.false f,\n  hdf_fn := \u03bb n f, by exfalso; exact is_empty.false f,\n  df_pr := @df_pr,\n  hdf_pr := \u03bb 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 : \u2115}\n\n@[simp] lemma thy.lt (x y) : T \u22a2 (x \u227a y) \u27f7 (x \u227c y) \u2293 (x \u2260' y) :=\nby simpa[fal_fn] using defs.pr' T additional_pr.lt \u2039x, y\u203a\n\n@[simp] lemma thy.dvd (x y) : T \u22a2 (x \u236d y) \u27f7 \u2203. (#0 * x^1 =' y^1) :=\nby simpa[fal_fn, ex_fn] using defs.pr' T additional_pr.dvd \u2039x, y\u203a\n\nvariables {T}\n\ndef Herbrand.lt (h\u2081 h\u2082 : Herbrand T i) : Lindenbaum T i :=\nLindenbaum.predicate_of ((coe : LA'.pr 2 \u2192 L.pr 2) (sum.inr additional_pr.lt)) \u2039h\u2081, h\u2082\u203a\n\ninfix ` \u227a' `:50 := Herbrand.lt\n\n@[simp] lemma Lindenbaum.lt_def (v) :\n  Lindenbaum.predicate_of ((coe : LA'.pr 2 \u2192 L.pr 2) (sum.inr additional_pr.lt)) v = (v 0 \u227a' v 1 : Lindenbaum T i) := rfl\n\nlemma Lindenbaum.lt_eq (h\u2081 h\u2082 : Herbrand T i) : (h\u2081 \u227a' h\u2082) = (h\u2081 \u227c h\u2082) \u2293 (h\u2081 =' h\u2082)\u1d9c :=\nby induction h\u2081 using fol.Herbrand.ind_on with t;\n   induction h\u2082 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\u2081 h\u2082 : Herbrand T i) : Lindenbaum T i :=\nLindenbaum.predicate_of ((coe : LA'.pr 2 \u2192 L.pr 2) (sum.inr additional_pr.dvd)) \u2039h\u2081, h\u2082\u203a\n\ninfix ` \u236d' `:50 := Herbrand.dvd\n\n@[simp] lemma Lindenbaum.dvd_def (v) :\n  Lindenbaum.predicate_of ((coe : LA'.pr 2 \u2192 L.pr 2) (sum.inr additional_pr.dvd)) v = (v 0 \u236d' v 1 : Lindenbaum T i) := rfl\n\nlemma Lindenbaum.dvd_eq (h\u2081 h\u2082 : Herbrand T i) : (h\u2081 \u236d' h\u2082) = \u2203' (\u266f0 * h\u2081.pow =' h\u2082.pow : Lindenbaum T (i + 1)) :=\nby induction h\u2081 using fol.Herbrand.ind_on with t;\n   induction h\u2082 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 := \u2200.* (p.rew (0 \u2322 \u0131) \u27f6 \u2200. (p \u27f6 p.rew ((Succ #0) \u2322 (\u03bb x, #(x+1)))) \u27f6 \u2200. p)\n\ndef test (p : formula L) : formula L := p.rew (0 \u2322 \u0131)\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 := \ud835\udc10 \u222a (succ_induction '' C)\n\nprefix `\ud835\udc08`:max := succ_induction_axiom\n\n@[reducible] def peano : Theory LA := \ud835\udc08set.univ\n\nnotation `\ud835\udc0f\ud835\udc00` := peano\n\ninstance {C : Theory LA} : closed_Theory \ud835\udc08C := \n\u27e8\u03bb p h, by { rcases h with (h | \u27e8p, hp, rfl\u27e9), { refine closed_Theory.cl h }, { simp[succ_induction] } }\u27e9\n\ndef collection (p : formula L) : formula L :=\n  \u2200\u2081 u, (\u2200\u2081 x \u227c\u1d47 u, \u2203\u2081 y, p.rew \u0131-{2}) \u27f6 (\u2203\u2081 v, \u2200\u2081 x \u227c\u1d47 u, \u2203\u2081 y \u227c\u1d47 v, p.rew \u0131-{2}-{2})\n\ndef collection_axiom (C : Theory LA) : Theory LA := \ud835\udc10 \u222a (collection '' C)\n\nprefix `\ud835\udc01`:max := collection_axiom\n\nend \n\nsection\nvariables [LA'.language_translation_coe L]\n\ndef order_induction (p : formula L) : formula L := (\u2200\u2081 x, ((\u2200\u2081 y \u227a\u1d47 x, p.rew \u0131-{1}) \u27f6 p)) \u27f6 \u2200\u2081 x, p\n\ndef order_induction_axiom (C : Theory LA') : Theory LA' := \u2191\ud835\udc10 \u222a (order_induction '' C)\n\nprefix `\ud835\udc08\u2032`:max := order_induction_axiom\n\nend\n\n@[simp] lemma Q_ss_I {C} : \ud835\udc10 \u2286 \ud835\udc08C := by simp[succ_induction_axiom]\n\ninstance extend_Q_I (C : Theory LA) : extend \ud835\udc10 \ud835\udc08C := \u27e8\u03bb p h, weakening Q_ss_I h\u27e9\n\ninstance extend_ax\u2081 (C : Theory LA) (p : formula LA) : extend \ud835\udc10 (\ud835\udc08C +{ p }) :=\nTheory.extend_of_inclusion (\u03bb p mem, by simp[Q_ss_I mem])\n\ninstance extend_ax\u2082 (C : Theory LA) (p q : formula LA) : extend \ud835\udc10 (\ud835\udc08C +{ p }+{ q }) :=\nTheory.extend_of_inclusion (\u03bb p mem, by simp[Q_ss_I mem])\n\ninstance extend_ax\u2083 (C : Theory LA) (p q r : formula LA) : extend \ud835\udc10 (\ud835\udc08C +{ p }+{ q }+{ r }) :=\nTheory.extend_of_inclusion (\u03bb p mem, by simp[Q_ss_I mem])\n\ninstance extend_ax\u2084 (C : Theory LA) (p q r s : formula LA) : extend \ud835\udc10 (\ud835\udc08C +{ p }+{ q }+{ r }+{ s }) :=\nTheory.extend_of_inclusion (\u03bb 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 \ud835\udc10 Q] (i : \u2115)\n\n@[simp] lemma zero_ne_succ (t : term L) : Q \u22a2 0 \u2260' Succ t :=\nby { have : Q \u22a2 \u2200\u2081 x, 0 \u2260' Succ x, by simpa[fal_fn] using provable.lextend (by_axiom robinson.q1) Q,\n     simpa using this \u229a t }\n\n@[simp] lemma Lindembaum.zero_ne_succ (h : Herbrand Q i) : 0 =' Succ h = (\u22a5 : 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 = (\u22a5 : Lindenbaum Q i) :=\nby simp [Lindenbaum.equal_symm (Succ h) 0]\n\n@[simp] lemma succ_inj (t u : term L) :\n  Q \u22a2 (Succ t =' Succ u) \u27f6 (t =' u) :=\nby { have : Q \u22a2 \u2200\u2081 x y, (Succ x =' Succ y) \u27f6 (x =' y), by simpa[fal_fn] using provable.lextend (by_axiom robinson.q2) Q,\n     simpa[fal_fn] using this \u229a t \u229a u }\n\n@[simp] lemma Lindenbaum.succ_inj  (h\u2081 h\u2082 : Herbrand Q i) : (Succ h\u2081 =' Succ h\u2082 : Lindenbaum Q i) = (h\u2081 =' h\u2082) :=\nby { induction h\u2081 using fol.Herbrand.ind_on with t,\n     induction h\u2082 using fol.Herbrand.ind_on with u,\n     have : Q^i \u22a2 (Succ t =' Succ u) \u27f7 (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 \u2192 Herbrand Q i) :=\n\u03bb h\u2081 h\u2082,\nbegin\n  induction h\u2081 using fol.Herbrand.ind_on with t,\n  induction h\u2082 using fol.Herbrand.ind_on with u,\n  intros h,\n  have lmm\u2081 : Q^i \u22a2 Succ t =' Succ u, from Herbrand.eq_of_provable_equiv.mpr (by simp[h]),\n  have lmm\u2082 : Q^i \u22a2 (Succ t =' Succ u) \u27f6 (t =' u), by simp, \n  have : Q^i \u22a2 t =' u, from lmm\u2082 \u2a00 lmm\u2081,\n  exact Herbrand.eq_of_provable_equiv.mp this\nend\n\n@[simp] lemma Herbrand.succ_injective_iff (h\u2081 h\u2082 : Herbrand Q i) : Succ h\u2081 = Succ h\u2082 \u2194 h\u2081 = h\u2082 :=\n\u27e8@@Herbrand.succ_injective _ Q _ i, \u03bb h, by simp[h]\u27e9\n\n@[simp] lemma zero_or_succ (t) : Q \u22a2 (t =' 0) \u2294 (\u2203\u2081 y, t^1 =' Succ y) :=\nby { have : Q \u22a2 \u2200\u2081 x, (x =' 0) \u2294 (\u2203\u2081 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 \u229a t }\n\n@[simp] lemma add_zero (t : term L) : Q \u22a2 t + 0 =' t :=\nby { have : Q \u22a2 \u2200\u2081 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 \u229a 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 \u22a2 t + Succ u =' Succ (t + u) :=\nby { have : Q \u22a2 \u2200\u2081 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 \u229a t \u229a u }\n\n@[simp] lemma Herbrand.add_succ {i} (h\u2081 h\u2082 : Herbrand Q i) : h\u2081 + Succ h\u2082 = Succ (h\u2081 + h\u2082) :=\nby { induction h\u2081 using fol.Herbrand.ind_on with t,\n     induction h\u2082 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 \u22a2 t * 0 =' 0 :=\nby { have : Q \u22a2 \u2200\u2081 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 \u229a 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 \u22a2 t * Succ u =' t * u + t :=\nby { have : Q \u22a2 \u2200\u2081 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 \u229a t \u229a u }\n\n@[simp] lemma Herbrand.mul_succ {i} (h\u2081 h\u2082 : Herbrand Q i) : h\u2081 * Succ h\u2082 = h\u2081 * h\u2082 + h\u2081 :=\nby { induction h\u2081 using fol.Herbrand.ind_on with t,\n     induction h\u2082 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 \u22a2 (t \u227c u) \u27f7 \u2203. (#0 + t^1 =' u^1) :=\nby { have : Q \u22a2 \u2200\u2081 x y, (x \u227c y) \u27f7 \u2203\u2081 z, (z + x =' y), by simpa[fal_fn, ex_fn] using provable.lextend (by_axiom robinson.q8) Q,\n     simpa[fal_fn, ex_fn, \u2190term.pow_rew_distrib] using this \u229a t \u229a u }\n\nlemma Lindenbaum.le_iff {h\u2081 h\u2082 : Herbrand Q i} :\n  (h\u2081 \u227c h\u2082 : Lindenbaum Q i) = \u2203' (\u266f0 + h\u2081.pow =' h\u2082.pow : Lindenbaum Q (i + 1)) :=\nby { induction h\u2081 using fol.Herbrand.ind_on with t,\n     induction h\u2082 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\u2081 h\u2082 : Herbrand Q i} (h : e + h\u2081 = h\u2082) : h\u2081 \u2264 h\u2082 :=\nbegin\n  induction e using fol.Herbrand.ind_on with u,\n  induction h\u2081 using fol.Herbrand.ind_on with t\u2081,\n  induction h\u2082 using fol.Herbrand.ind_on with t\u2082,\n  have lmm\u2081 : Q^i \u22a2 \u2203. (#0 + t\u2081^1 =' t\u2082^1),\n  { refine use u _, simp, refine Herbrand.eq_of_provable_equiv.mpr (by simp[h]) },\n  have lmm\u2082 : Q^i \u22a2 (t\u2081 \u227c t\u2082) \u27f7 \u2203. (#0 + t\u2081^1 =' t\u2082^1), by simp,\n  exact Herbrand.le_iff_provable_le.mp (of_equiv lmm\u2081 (equiv_symm lmm\u2082))\nend\n\n@[simp] lemma le_add_self (h\u2081 h\u2082 : Herbrand Q i) : h\u2081 \u2264 h\u2082 + h\u2081 := le_of_eq Q i h\u2082 rfl\n\n@[simp] lemma succ_inj_le {h\u2081 h\u2082 : Herbrand Q i} :\n  (Succ h\u2081 \u227c Succ h\u2082 : Lindenbaum Q i) = (h\u2081 \u227c h\u2082) := by simp[le_iff, succ_pow]\n\nlemma add_numeral_eq_numeral_add (m n : \u2115) : (n\u02d9 : Herbrand Q i) + m\u02d9 = (n + m)\u02d9 :=\nby induction m with m IH; simp[numeral, *, \u2190nat.add_one, \u2190add_assoc]\n\nlemma mul_numeral_eq_numeral_mul (m n : \u2115) : (n\u02d9 : Herbrand Q i) * m\u02d9 = (n * m)\u02d9 :=\nby induction m with m IH; simp[numeral, *, \u2190nat.add_one, add_numeral_eq_numeral_add, mul_add]\n\nlemma succ_add_numeral_eq_add_succ_numeral (h : Herbrand Q i) (n : \u2115) : Succ h + n\u02d9 = h + (n + 1)\u02d9 :=\nby induction n with n IH; simp[numeral, *]\n\nend Lindenbaum\n\n@[simp] lemma add_eq_zero : Q \u22a2 \u2200\u2081 x y, (x + y =' 0) \u27f6 (x =' 0) \u2293 (y =' 0) :=\nbegin\n  refine generalize (generalize _), simp[fal_fn], \n  have lmm\u2081 : \u290a\u290aQ \u22a2 (#0 =' 0) \u27f6 (#1 + #0 =' 0) \u27f6 (#1 =' 0) \u2293 (#0 =' 0),\n    from (deduction.mp (by simp [le_of_provable_imply_0, rew_by_axiom\u2081])),\n  have lmm\u2082 : \u290a\u290aQ \u22a2 (\u2203\u2081 y, #1 =' Succ y) \u27f6 (#1 + #0 =' 0) \u27f6 (#1 =' 0) \u2293 (#0 =' 0),\n    from imply_ex_of_fal_imply (generalize (deduction.mp (by simp [le_of_provable_imply_0, rew_by_axiom\u2081]))), \n  exact case_of_ax (zero_or_succ _ #0) lmm\u2081 lmm\u2082\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) \u2293 (y =' 0) :=\nbegin\n  induction x using fol.Herbrand.ind_on,\n  induction y using fol.Herbrand.ind_on,\n  have : Q^i \u22a2 (x + y =' 0) \u27f7 (x =' 0) \u2293 (y =' 0), \n  { simp[iff_equiv],\n    refine \u27e8by simpa[fal_fn] using add_eq_zero (Q^i) \u229a x \u229a y, deduction.mp _\u27e9, simp,\n    simp[Herbrand.eq_of_provable_equiv_0, rew_by_axiom\u2081, rew_by_axiom\u2082] },\n  simpa using Lindenbaum.eq_of_provable_equiv.mp this\nend\n\nlemma mul_eq_zero : Q \u22a2 \u2200\u2081 x y, (x * y =' 0) \u27f6 (x =' 0) \u2294 (y =' 0) :=\nbegin\n  refine generalize (generalize _), simp[fal_fn], \n  have lmm\u2081 : \u290a\u290aQ \u22a2 (#0 =' 0) \u27f6 (#1 * #0 =' 0) \u27f6 (#1 =' 0) \u2294 (#0 =' 0),\n  { refine (deduction.mp _),\n    simp[le_of_provable_imply_0, rew_by_axiom\u2081] },\n  have lmm\u2082 : \u290a\u290aQ \u22a2 (\u2203\u2081 y, #1 =' Succ y) \u27f6 (#1 * #0 =' 0) \u27f6 (#1 =' 0) \u2294 (#0 =' 0),\n  { refine imply_ex_of_fal_imply (generalize (deduction.mp _)), simp,\n    simp[le_of_provable_imply_0, rew_by_axiom\u2081] },\n  exact case_of_ax (zero_or_succ _ #0) lmm\u2081 lmm\u2082\nend\n\nlemma zero_le : Q \u22a2 \u2200\u2081 x, 0 \u227c x :=\nbegin\n  refine generalize _, simp[fal_fn],\n  have : \u290aQ \u22a2 (0 \u227c #0) \u27f7 (\u2203\u2081 z, z + 0 =' #1), by simpa using (le_iff \u290aQ 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 \u2264 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) \u229a t)\n\n@[simp] lemma le_zero_equiv_eq_zero : Q \u22a2 \u2200\u2081 x, (x \u227c 0) \u27f7 (x =' 0) :=\nbegin\n  refine generalize _, simp[fal_fn],\n  suffices : \u290aQ \u22a2 \u2203. (#0 + #1 =' 0) \u27f7 (#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\u2081 _ _).mpr $ generalize _),\n    simp[Lindenbaum.le_of_provable_imply_0] },\n  { refine deduction.mp (use 0 _), simp[\u0131, Herbrand.eq_of_provable_equiv_0, rew_by_axiom\u2081] }\nend\n\n@[simp] lemma Lindenbaum.le_zero_eq_eq_zero (h : Herbrand Q i) : (h \u227c 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) \u229a t)\n\n@[simp] lemma add_numeral_eq_numeral_add (n m : \u2115) : Q \u22a2 (n\u02d9 : term L) + m\u02d9 =' (n + m)\u02d9 :=\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 : \u2115) : Q \u22a2 (n\u02d9 : term L) * m\u02d9 =' (n * m)\u02d9 :=\nby simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.mul_numeral_eq_numeral_mul]\n\nlemma le_numeral_of_le {n m : \u2115} (h : n \u2264 m) : Q \u22a2 (n\u02d9 : term L) \u227c m\u02d9 :=\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\u02d9) _) (equiv_symm $ le_iff Q (n\u02d9) ((l + n)\u02d9)), simp\nend\n\nlemma le_numeral_iff (n : \u2115) : Q \u22a2 \u2200. ((#0 \u227c n\u02d9) \u27f7 \u22c1 i : fin (n+1), #0 =' (i : \u2115)\u02d9) :=\nbegin\n  suffices : \u2200 k : \u2115, Q^k \u22a2 \u2200. ((#0 \u227c n\u02d9) \u27f7 \u22c1 i : fin (n+1), #0 =' (i : \u2115)\u02d9),\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[\u2190Theory.sf_itr_succ, iff_equiv, -finitary.disjunction], split,\n    { have zero : Q^(k + 1) \u22a2 (#0 =' 0) \u27f6 (#0 \u227c (n + 1)\u02d9) \u27f6 \u22c1 (i : fin (n.succ + 1)), #0 =' \u2191i\u02d9,\n      { refine (deduction.mp $ deduction.mp $ imply_or_right _ _ \u2a00 (rew_of_eq 0 0 (by simp) _)), \n        simp, refine disjunction_of \u27e80, by simp\u27e9 (by simp[numeral]) },\n      have succ : Q^(k + 1) \u22a2 (\u2203\u2081 y, #1 =' Succ y) \u27f6 (#0 \u227c (n + 1)\u02d9) \u27f6 \u22c1 (i : fin (n.succ + 1)), #0 =' \u2191i\u02d9,\n      { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ rew_of_eq (Succ #0) 1 (by simp) (deduction.mp _)),\n        simp[ -finitary.disjunction, \u2190Theory.sf_itr_succ], \n        have : (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 \u227c (n + 1)\u02d9 } \u22a2 #0 \u227c n\u02d9,\n          from of_equiv_p (show _ \u22a2 Succ #0 \u227c (n + 1)\u02d9, by simp) (by simp[numeral, Lindenbaum.eq_of_provable_equiv_0]), \n        have lmm\u2081 : (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 \u227c (n + 1)\u02d9 } \u22a2 \u22c1 (i : fin (n + 1)), #0 =' \u2191i\u02d9,\n          from of_equiv_p this (weakening\n            (show Q^(k + 2) \u2286 (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 \u227c (n + 1)\u02d9 }, by { intros p mem, refine set.subset_insert _ _ (set.subset_insert _ _ mem) })\n            (show Q^(k + 2) \u22a2 (#0 \u227c n\u02d9) \u27f7 \u22c1 (i : fin (n + 1)), #0 =' \u2191i\u02d9, by simpa using IH (k + 2) \u229a #0)),\n        have lmm\u2082 : (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 \u227c (n + 1)\u02d9 } \u22a2 (\u22c1 (i : fin (n + 1)), #0 =' \u2191i\u02d9) \u27f6 (\u22c1 (i : fin (n.succ + 1)), Succ #0 =' \u2191i\u02d9),\n        { suffices : (Q^(k + 2)) +{ #1 =' Succ #0 } +{ Succ #0 \u227c (n + 1)\u02d9 } \u22a2 \u22c0 (i : fin (n + 1)), (#0 =' \u2191i\u02d9) \u27f6 \u22c1 (i : fin (n.succ + 1)), Succ #0 =' \u2191i\u02d9,\n            from of_equiv this (conj_imply_iff_disj_imply _ _),\n          refine conjunction_iff.mpr (\u03bb i, deduction.mp $ rew_of_eq (\u2191i\u02d9) 0 (by simp) _), simp[-finitary.disjunction],\n          refine disjunction_of \u27e8i + 1, by simp\u27e9 (by simp[numeral]) },\n        exact lmm\u2082 \u2a00 lmm\u2081 },\n      exact case_of_ax (show (Q^(k + 1)) \u22a2 (#0 =' 0) \u2294 \u2203\u2081 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 \u27e8i, hi\u27e9, refine (deduction.mp $  rew_of_eq (i\u02d9) 0 (by simp) _),\n      simp[\u2190nat.add_one],\n      exact le_numeral_of_le _ (show i \u2264 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 \ud835\udc08C T]\n          {L'} [LA'.language_translation_coe L'] (T' : Theory L') [lextend \ud835\udc08C T']\n\nlemma I_succ_induction_aux (p : formula LA) (h : p \u2208 C) :\n  T \u22a2 succ_induction p :=\nby { have : \ud835\udc08C \u22a2 succ_induction p, from by_axiom (by { simp[succ_induction_axiom, h], refine or.inr \u27e8p, by simp[h]\u27e9 }),\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 \u2208 C) :\n  T \u22a2 p.rew (0 \u2322 \u0131) \u27f6 \u2200. (p \u27f6 p.rew ((Succ #0) \u2322 (\u03bb x, #(x+1)))) \u27f6 \u2200. p :=\nby simpa using provable.fal_complete_rew _ \u0131 \u2a00 (I_succ_induction_aux C T p h)\n\nlemma equiv_succ_induction_of_equiv {T\u2080 : Theory L} [closed_Theory T\u2080] {p q : formula L} (h : T\u2080 \u22a2 p \u27f7 q) :\n  T\u2080 \u22a2 succ_induction p \u27f7 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 \u2322 \u0131) },\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\u2081 L\u2082 : language.{0}}\n  [LA.language_translation_coe L\u2081] [LA.language_translation_coe L\u2082] [L\u2081.language_translation_coe L\u2082] [LA.commutes L\u2081 L\u2082]\n  (p : formula L\u2081) :\n  (\u2191(succ_induction p : formula L\u2081) : formula L\u2082) = succ_induction (\u2191p : formula L\u2082) :=\nby simp[succ_induction, language.language_translation_coe.coe_p_rew, function.comp]\n\nsection\nvariables {L\u2081 L\u2082 : language.{0}}\n  [LA'.language_translation_coe L\u2081] [LA'.language_translation_coe L\u2082] [L\u2081.language_translation_coe L\u2082] [LA'.commutes L\u2081 L\u2082]\n\n@[simp] lemma coe_lt (t u : term L\u2081) : ((t \u227a u : formula L\u2081) : formula L\u2082) = (t \u227a u) :=\nby simp[additional.lt]; refine language.commutes.coe_coe_pr_of_commute _\n\n@[simp] lemma coe_dvd (t u : term L\u2081) : ((t \u236d u : formula L\u2081) : formula L\u2082) = (t \u236d 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\u2081 \u2192 term L\u2081) (t u : term L\u2081) :\n  quantifier_fn_aux s (\u03bb x, f x \u227a g x) (t \u227a u) = (f #s \u227a g #s) := rfl\n\n@[simp] lemma quantifier_fn_aux_dvd (s) (f g : term L\u2081 \u2192 term L\u2081) (t u : term L\u2081) :\n  quantifier_fn_aux s (\u03bb x, f x \u236d g x) (t \u236d u) = (f #s \u236d 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\u2092\u209a\u2091\u2099 : Theory L) [lextend \ud835\udc08is_open I\u2092\u209a\u2091\u2099] (i : \u2115)\n          {L'} [LA'.language_translation_coe L'] (I\u2092\u209a\u2091\u2099' : Theory L') [lextend \ud835\udc08is_open I\u2092\u209a\u2091\u2099']\n          [lextend additional.defs.thy I\u2092\u209a\u2091\u2099']\n\ninstance lextend_Q : lextend \ud835\udc10 I\u2092\u209a\u2091\u2099 := Theory.lextend_trans \ud835\udc10 \ud835\udc08is_open I\u2092\u209a\u2091\u2099\n\nlemma I_succ_induction_LA (p : formula LA') (h : formula.coe_inv_is_open defs p):\n  I\u2092\u209a\u2091\u2099' \u22a2 p.rew (0 \u2322 \u0131) \u27f6 \u2200. (p \u27f6 p.rew ((Succ #0) \u2322 (\u03bb x, #(x+1)))) \u27f6 \u2200. p :=\nbegin\n  have : I\u2092\u209a\u2091\u2099' \u22a2 succ_induction \u2191p \u27f7 succ_induction \u2191(coe_inv defs p),\n    by simpa using provable.lextend (equiv_succ_induction_of_equiv (coe_inv_equiv additional.defs p)) I\u2092\u209a\u2091\u2099',\n  have : I\u2092\u209a\u2091\u2099' \u22a2 succ_induction \u2191p,\n    from of_equiv_p (I_succ_induction_aux is_open I\u2092\u209a\u2091\u2099' (coe_inv defs p) (by simp[set.mem_def, h])) (equiv_symm this),\n  simpa using provable.fal_complete_rew _ \u0131 \u2a00 this\nend\n\n@[simp] lemma zero_add : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x, 0 + x =' x :=\nbegin\n  have lmm\u2081 : I\u2092\u209a\u2091\u2099 \u22a2 (0 + 0 =' 0) \u27f6 \u2200. ((0 + #0 =' #0) \u27f6 (0 + Succ #0 =' Succ #0)) \u27f6 \u2200. (0 + #0 =' #0), \n    by simpa using Ind.I_succ_induction is_open I\u2092\u209a\u2091\u2099 (0 + #0 =' #0) (by simp[set.mem_def]),\n  have lmm\u2082 : I\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((0 + #0 =' #0) \u27f6 (0 + Succ #0 =' Succ #0)),\n  { refine generalize (deduction.mp _), \n    have : \u290aI\u2092\u209a\u2091\u2099 +{ 0 + #0 =' #0 } \u22a2 0 + #0 =' #0, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2, exact this },\n  simpa using (lmm\u2081 \u2a00 (by simp[Herbrand.eq_of_provable_equiv_0]) \u2a00 lmm\u2082)\nend\n\n@[simp] lemma Lindenbaum.zero_add (h : Herbrand I\u2092\u209a\u2091\u2099 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\u2092\u209a\u2091\u2099^i) \u229a t)\n\n@[simp] lemma succ_add : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y, Succ x + y =' Succ (x + y) :=\nbegin\n  have ind : \u290aI\u2092\u209a\u2091\u2099 \u22a2 (Succ #0 + 0 =' Succ (#0 + 0)) \u27f6\n                    \u2200. ((Succ #1 + #0 =' Succ (#1 + #0)) \u27f6 (Succ #1 + Succ #0 =' Succ (#1 + Succ #0))) \u27f6\n                    \u2200. (Succ #1 + #0 =' Succ (#1 + #0)), \n  by simpa using Ind.I_succ_induction is_open \u290aI\u2092\u209a\u2091\u2099 (Succ #1 + #0 =' Succ (#1 + #0)) (by simp[set.mem_def]),\n  have zero : \u290aI\u2092\u209a\u2091\u2099 \u22a2 Succ #0 + 0 =' Succ (#0 + 0),  by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : \u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((Succ #1 + #0 =' Succ (#1 + #0)) \u27f6 (Succ #1 + Succ #0 =' Succ (#1 + Succ #0))),\n  { refine (generalize $ deduction.mp _), simp,\n    have : \u290a\u290aI\u2092\u209a\u2091\u2099 +{ Succ #1 + #0 =' Succ (#1 + #0) } \u22a2 Succ #1 + #0 =' Succ (#1 + #0), by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2,  exact this },\n  simpa using (generalize $ ind \u2a00 zero \u2a00 succ)\nend\n\n@[simp] lemma Lindenbaum.succ_add (h\u2081 h\u2082 : Herbrand I\u2092\u209a\u2091\u2099 i) : Succ h\u2081 + h\u2082 = Succ (h\u2081 + h\u2082) :=\nby induction h\u2081 using fol.Herbrand.ind_on with t;\n   induction h\u2082 using fol.Herbrand.ind_on with u;\n   simpa using Herbrand.eq_of_provable_equiv.mp (succ_add (I\u2092\u209a\u2091\u2099^i) \u229a t \u229a u)\n\nlemma add_commutative : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y, x + y =' y + x :=\nbegin\n  have ind : \u290aI\u2092\u209a\u2091\u2099 \u22a2 (#0 + 0 =' 0 + #0) \u27f6 \u2200. ((#1 + #0 =' #0 + #1) \u27f6 (#1 + Succ #0 =' Succ #0 + #1)) \u27f6 \u2200. (#1 + #0 =' #0 + #1),\n    by simpa using Ind.I_succ_induction is_open \u290aI\u2092\u209a\u2091\u2099 (#1 + #0 =' #0 + #1) (by simp[set.mem_def]),\n  have zero : \u290aI\u2092\u209a\u2091\u2099 \u22a2 #0 + 0 =' 0 + #0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : \u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((#1 + #0 =' #0 + #1) \u27f6 (#1 + Succ #0 =' Succ #0 + #1)),\n  { refine (generalize $ deduction.mp _), simp,\n    have : \u290a\u290aI\u2092\u209a\u2091\u2099 +{ #1 + #0 =' #0 + #1 } \u22a2 #1 + #0 =' #0 + #1, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2, exact this },\n  simpa using (generalize $ ind \u2a00 zero \u2a00 succ)\nend\n\nlemma Lindenbaum.add_commutative (h\u2081 h\u2082 : Herbrand I\u2092\u209a\u2091\u2099 i) : h\u2081 + h\u2082 = h\u2082 + h\u2081 :=\nby induction h\u2081 using fol.Herbrand.ind_on with t;\n   induction h\u2082 using fol.Herbrand.ind_on with u;\n   simpa using Herbrand.eq_of_provable_equiv.mp (add_commutative (I\u2092\u209a\u2091\u2099^i) \u229a t \u229a u)\n\nlemma add_associative : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y z, x + y + z =' x + (y + z) :=\nbegin\n  have ind : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 (#1 + #0 + 0 =' #1 + (#0 + 0)) \u27f6\n                     \u2200. ((#2 + #1 + #0 =' #2 + (#1 + #0)) \u27f6 (#2 + #1 + Succ #0 =' #2 + (#1 + Succ #0))) \u27f6\n                     \u2200. (#2 + #1 + #0 =' #2 + (#1 + #0)),\n  by simpa using Ind.I_succ_induction is_open \u290a\u290aI\u2092\u209a\u2091\u2099 (#2 + #1 + #0 =' #2 + (#1 + #0)) (by simp[set.mem_def]),\n  have zero : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 #1 + #0 + 0 =' #1 + (#0 + 0), by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((#2 + #1 + #0 =' #2 + (#1 + #0)) \u27f6 (#2 + #1 + Succ #0 =' #2 + (#1 + Succ #0))),\n  { refine (generalize $ deduction.mp _), simp,\n    have : \u290a\u290a\u290aI\u2092\u209a\u2091\u2099 +{ #2 + #1 + #0 =' #2 + (#1 + #0) } \u22a2 #2 + #1 + #0 =' #2 + (#1 + #0), by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2, exact this },\n  simpa using (generalize $ generalize $ ind \u2a00 zero \u2a00 succ)\nend\n\nlemma Lindenbaum.add_associative (h\u2081 h\u2082 h\u2083 : Herbrand I\u2092\u209a\u2091\u2099 i) : h\u2081 + h\u2082 + h\u2083 = h\u2081 + (h\u2082 + h\u2083) :=\nby induction h\u2081 using fol.Herbrand.ind_on with t\u2081;\n   induction h\u2082 using fol.Herbrand.ind_on with t\u2082;\n   induction h\u2083 using fol.Herbrand.ind_on with t\u2083;\n   simpa using Herbrand.eq_of_provable_equiv.mp (add_associative _ \u229a t\u2081 \u229a t\u2082 \u229a t\u2083)\n\n\ninstance Lindenbaum.add_comm_semigroup : add_comm_semigroup (Herbrand I\u2092\u209a\u2091\u2099 i) :=\n{ add := (+),\n  add_assoc := Lindenbaum.add_associative _ _,\n  add_comm := Lindenbaum.add_commutative _ _ }\n\nlemma zero_mul : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x, 0 * x =' 0 :=\nbegin\n  have ind : I\u2092\u209a\u2091\u2099 \u22a2 (0 * 0 =' 0) \u27f6 \u2200. ((0 * #0 =' 0) \u27f6 (0 * Succ #0 =' 0)) \u27f6 \u2200. (0 * #0 =' 0),\n    by simpa using Ind.I_succ_induction is_open I\u2092\u209a\u2091\u2099 (0 * #0 =' 0) (by simp[set.mem_def]), \n  have zero : I\u2092\u209a\u2091\u2099 \u22a2 0 * 0 =' 0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : I\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((0 * #0 =' 0) \u27f6 (0 * Succ #0 =' 0)),\n  { refine (generalize $ deduction.mp _),\n    have : \u290aI\u2092\u209a\u2091\u2099 +{ 0 * #0 =' 0 } \u22a2 0 * #0 =' 0, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2, simp[this] },\n  simpa using ind \u2a00 zero \u2a00 succ\nend\n\n@[simp] lemma Lindenbaum.zero_mul (h : Herbrand I\u2092\u209a\u2091\u2099 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 _ \u229a t)\n\nlemma succ_mul : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y, Succ x * y =' x * y + y :=\nbegin\n  have ind : \u290aI\u2092\u209a\u2091\u2099 \u22a2 (Succ #0 * 0 =' #0 * 0 + 0) \u27f6\n                    \u2200. ((Succ #1 * #0 =' #1 * #0 + #0) \u27f6 (Succ #1 * Succ #0 =' #1 * Succ #0 + Succ #0)) \u27f6\n                    \u2200. (Succ #1 * #0 =' #1 * #0 + #0),\n  by simpa using Ind.I_succ_induction is_open \u290aI\u2092\u209a\u2091\u2099 (Succ #1 * #0 =' #1 * #0 + #0) (by simp[set.mem_def]),\n  have zero : \u290aI\u2092\u209a\u2091\u2099 \u22a2 Succ #0 * 0 =' #0 * 0 + 0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : \u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((Succ #1 * #0 =' #1 * #0 + #0) \u27f6 (Succ #1 * Succ #0 =' #1 * Succ #0 + Succ #0)),\n  { refine (generalize $ deduction.mp _),\n    have : \u290a\u290aI\u2092\u209a\u2091\u2099 +{ Succ #1 * #0 =' #1 * #0 + #0 } \u22a2 Succ #1 * #0 =' #1 * #0 + #0, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2,\n    calc (Succ \u266f1 * \u266f0 + \u266f1 : Herbrand (\u290a\u290aI\u2092\u209a\u2091\u2099 +{ Succ #1 * #0 =' #1 * #0 + #0 }) 0)\n        = \u266f1 * \u266f0 + \u266f0 + \u266f1   : by rw[this]\n    ... = \u266f1 * \u266f0 + (\u266f1 + \u266f0) : by simp[add_assoc, add_comm]\n    ... = \u266f1 * \u266f0 + \u266f1 + \u266f0   : by simp[add_assoc] },\n  simpa using (generalize $ ind \u2a00 zero \u2a00 succ)\nend\n\n@[simp] lemma Lindenbaum.succ_mul (h\u2081 h\u2082 : Herbrand I\u2092\u209a\u2091\u2099 i) : Succ h\u2081 * h\u2082 = h\u2081 * h\u2082 + h\u2082 :=\nby induction h\u2081 using fol.Herbrand.ind_on with t;\n   induction h\u2082 using fol.Herbrand.ind_on with u;\n   simpa using Herbrand.eq_of_provable_equiv.mp (succ_mul _ \u229a t \u229a u)\n\nlemma mul_commutative : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y, x * y =' y * x :=\nbegin\n  have ind : \u290aI\u2092\u209a\u2091\u2099 \u22a2 (#0 * 0 =' 0 * #0) \u27f6 \u2200. ((#1 * #0 =' #0 * #1) \u27f6 (#1 * Succ #0 =' Succ #0 * #1)) \u27f6 \u2200. (#1 * #0 =' #0 * #1),\n    by simpa using Ind.I_succ_induction is_open \u290aI\u2092\u209a\u2091\u2099 (#1 * #0 =' #0 * #1) (by simp[set.mem_def]),\n  have zero : \u290aI\u2092\u209a\u2091\u2099 \u22a2 #0 * 0 =' 0 * #0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : \u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((#1 * #0 =' #0 * #1) \u27f6 (#1 * Succ #0 =' Succ #0 * #1)),\n  { refine (generalize $ deduction.mp _), simp,\n    have : \u290a\u290aI\u2092\u209a\u2091\u2099 +{ #1 * #0 =' #0 * #1 } \u22a2 #1 * #0 =' #0 * #1, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2, simp[this] },\n  simpa using (generalize $ ind \u2a00 zero \u2a00 succ)\nend\n\nlemma Lindenbaum.mul_commutative (h\u2081 h\u2082 : Herbrand I\u2092\u209a\u2091\u2099 i) : h\u2081 * h\u2082 = h\u2082 * h\u2081 :=\nby induction h\u2081 using fol.Herbrand.ind_on with t;\n   induction h\u2082 using fol.Herbrand.ind_on with u;\n   simpa using Herbrand.eq_of_provable_equiv.mp (mul_commutative _ \u229a t \u229a u)\n\nlemma mul_add : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y z, x * (y + z) =' x * y + x * z :=\nbegin\n  have ind : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 (#1 * (#0 + 0) =' #1 * #0 + #1 * 0) \u27f6\n                     \u2200. ((#2 * (#1 + #0) =' #2 * #1 + #2 * #0) \u27f6 (#2 * (#1 + Succ #0) =' #2 * #1 + #2 * Succ #0)) \u27f6\n                     \u2200. (#2 * (#1 + #0) =' #2 * #1 + #2 * #0),\n  by simpa using Ind.I_succ_induction is_open \u290a\u290aI\u2092\u209a\u2091\u2099 (#2 * (#1 + #0) =' #2 * #1 + #2 * #0) (by simp[set.mem_def]),\n  have zero : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 #1 * (#0 + 0) =' #1 * #0 + #1 * 0, by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((#2 * (#1 + #0) =' #2 * #1 + #2 * #0) \u27f6 (#2 * (#1 + Succ #0) =' #2 * #1 + #2 * Succ #0)),\n  { refine (generalize $ deduction.mp _), simp, \n    have : \u290a\u290a\u290aI\u2092\u209a\u2091\u2099 +{ #2 * (#1 + #0) =' #2 * #1 + #2 * #0 } \u22a2 #2 * (#1 + #0) =' #2 * #1 + #2 * #0, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2,\n    simp[this, add_assoc] },\n  simpa using (generalize $ generalize $ ind \u2a00 zero \u2a00 succ)\nend\n\nlemma Lindenbaum.mul_add (h\u2081 h\u2082 h\u2083 : Herbrand I\u2092\u209a\u2091\u2099 i) : h\u2081 * (h\u2082 + h\u2083) = h\u2081 * h\u2082 + h\u2081 * h\u2083 :=\nby induction h\u2081 using fol.Herbrand.ind_on with t\u2081;\n   induction h\u2082 using fol.Herbrand.ind_on with t\u2082;\n   induction h\u2083 using fol.Herbrand.ind_on with t\u2083;\n   simpa using Herbrand.eq_of_provable_equiv.mp (mul_add _ \u229a t\u2081 \u229a t\u2082 \u229a t\u2083)\n\nlemma mul_associative : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y z, x * y * z =' x * (y * z) :=\nbegin\n  have ind : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 (#1 * #0 * 0 =' #1 * (#0 * 0)) \u27f6\n                     \u2200. ((#2 * #1 * #0 =' #2 * (#1 * #0)) \u27f6 (#2 * #1 * Succ #0 =' #2 * (#1 * Succ #0))) \u27f6\n                     \u2200. (#2 * #1 * #0 =' #2 * (#1 * #0)),\n  by simpa using Ind.I_succ_induction is_open \u290a\u290aI\u2092\u209a\u2091\u2099 (#2 * #1 * #0 =' #2 * (#1 * #0)) (by simp[set.mem_def]),\n  have zero : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 #1 * #0 * 0 =' #1 * (#0 * 0), by simp[Herbrand.eq_of_provable_equiv_0],\n  have succ : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2200. ((#2 * #1 * #0 =' #2 * (#1 * #0)) \u27f6 (#2 * #1 * Succ #0 =' #2 * (#1 * Succ #0))),\n  { refine (generalize $ deduction.mp _),\n    have : \u290a\u290a\u290aI\u2092\u209a\u2091\u2099 +{ #2 * #1 * #0 =' #2 * (#1 * #0) } \u22a2 #2 * #1 * #0 =' #2 * (#1 * #0), by simp,\n    simp[Herbrand.eq_of_provable_equiv_0] at this \u22a2, simp[this, Lindenbaum.mul_add] },\n  simpa using (generalize $ generalize $ ind \u2a00 zero \u2a00 succ)\nend\n\nlemma Lindenbaum.mul_associative (h\u2081 h\u2082 h\u2083 : Herbrand I\u2092\u209a\u2091\u2099 i) : h\u2081 * h\u2082 * h\u2083 = h\u2081 * (h\u2082 * h\u2083) :=\nby induction h\u2081 using fol.Herbrand.ind_on with t\u2081;\n   induction h\u2082 using fol.Herbrand.ind_on with t\u2082;\n   induction h\u2083 using fol.Herbrand.ind_on with t\u2083;\n   simpa using Herbrand.eq_of_provable_equiv.mp (mul_associative _ \u229a t\u2081 \u229a t\u2082 \u229a t\u2083)\n\n@[simp] lemma mul_one : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 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\u2092\u209a\u2091\u2099 i) : h * 1 = h := by simp[numeral_one_def]\n\ninstance Lindenbaum.comm_semigroup : comm_semigroup (Herbrand I\u2092\u209a\u2091\u2099 i) :=\n{ mul := (*),\n  mul_assoc := Lindenbaum.mul_associative _ _,\n  mul_comm := Lindenbaum.mul_commutative _ _ }\n\ninstance Lindenbaum.distrib : distrib (Herbrand I\u2092\u209a\u2091\u2099 i) :=\n{ mul := (*), add := (+),\n  left_distrib := Lindenbaum.mul_add _ _,\n  right_distrib := \u03bb a b c, by simp[mul_comm (a + b), mul_comm a, mul_comm b, Lindenbaum.mul_add] }\n\nlemma add_right_cancel : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y z, (x + z =' y + z) \u27f6 (x =' y) :=\nbegin\n  have ind : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 ((#1 + 0 =' #0 + 0) \u27f6 (#1 =' #0)) \u27f6\n                     \u2200. (((#2 + #0 =' #1 + #0) \u27f6 (#2 =' #1)) \u27f6 (#2 + Succ #0 =' #1 + Succ #0) \u27f6 (#2 =' #1)) \u27f6\n                     \u2200. ((#2 + #0 =' #1 + #0) \u27f6 (#2 =' #1)),\n  by simpa using Ind.I_succ_induction is_open \u290a\u290aI\u2092\u209a\u2091\u2099 ((#2 + #0 =' #1 + #0) \u27f6 (#2 =' #1)) (by simp[set.mem_def]),\n  have zero : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 (#1 + 0 =' #0 + 0) \u27f6 (#1 =' #0), by simp[Lindenbaum.le_of_provable_imply_0],\n  have succ : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2200. (((#2 + #0 =' #1 + #0) \u27f6 (#2 =' #1)) \u27f6 (#2 + Succ #0 =' #1 + Succ #0) \u27f6 (#2 =' #1)),\n  { refine (generalize $ deduction.mp $ deduction.mp _), simp,\n    have : \u290a\u290a\u290aI\u2092\u209a\u2091\u2099 +{ (#2 + #0 =' #1 + #0) \u27f6 (#2 =' #1) } +{ #2 + Succ #0 =' #1 + Succ #0 } \u22a2 #2 + #0 =' #1 + #0,\n      from deduction.mpr (by simp[Lindenbaum.le_of_provable_imply_0]),\n    exact (show _ \u22a2 (#2 + #0 =' #1 + #0) \u27f6 (#2 =' #1), by simp) \u2a00 this },\n  simpa using (generalize $ generalize $ ind \u2a00 zero \u2a00 succ)\nend\n\nlemma Herbrand.add_right_cancel (h\u2081 h\u2082 h\u2083 : Herbrand I\u2092\u209a\u2091\u2099 i) : h\u2081 + h\u2083 = h\u2082 + h\u2083 \u2194 h\u2081 = h\u2082 :=\n\u27e8\u03bb h, begin\n  induction h\u2081 using fol.Herbrand.ind_on with t\u2081,\n  induction h\u2082 using fol.Herbrand.ind_on with t\u2082,\n  induction h\u2083 using fol.Herbrand.ind_on with t\u2083,\n  have lmm\u2081 : I\u2092\u209a\u2091\u2099^i \u22a2 t\u2081 + t\u2083 =' t\u2082 + t\u2083, from Herbrand.eq_of_provable_equiv.mpr (by simp[h]),\n  have lmm\u2082 : I\u2092\u209a\u2091\u2099^i \u22a2 (t\u2081 + t\u2083 =' t\u2082 + t\u2083) \u27f6 (t\u2081 =' t\u2082), by simpa[fal_fn] using add_right_cancel _ \u229a t\u2081 \u229a t\u2082 \u229a t\u2083,\n  exact Herbrand.eq_of_provable_equiv.mp (lmm\u2082 \u2a00 lmm\u2081)\nend, \u03bb h, by simp[h]\u27e9\n\nlemma Herbrand.add_left_cancel (h\u2081 h\u2082 h\u2083 : Herbrand I\u2092\u209a\u2091\u2099 i) : h\u2083 + h\u2081 = h\u2083 + h\u2082 \u2194 h\u2081 = h\u2082 :=\nby simp[add_comm h\u2083, Herbrand.add_right_cancel]\n\n@[simp] lemma Lindenbaum.add_right_cancel (h\u2081 h\u2082 h\u2083 : Herbrand I\u2092\u209a\u2091\u2099 i) : (h\u2081 + h\u2083 =' h\u2082 + h\u2083 : Lindenbaum I\u2092\u209a\u2091\u2099 i) = (h\u2081 =' h\u2082) :=\nbegin\n  induction h\u2081 using fol.Herbrand.ind_on with t\u2081,\n  induction h\u2082 using fol.Herbrand.ind_on with t\u2082,\n  induction h\u2083 using fol.Herbrand.ind_on with t\u2083,\n  have : I\u2092\u209a\u2091\u2099^i \u22a2 (t\u2081 + t\u2083 =' t\u2082 + t\u2083) \u27f7 (t\u2081 =' t\u2082),\n  { simp[iff_equiv], refine \u27e8by simpa[fal_fn] using add_right_cancel _ \u229a t\u2081 \u229a t\u2082 \u229a t\u2083, deduction.mp _\u27e9,\n  simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.rew_by_axiom\u2081] },\n  simpa using Lindenbaum.eq_of_provable_equiv.mp this\nend\n\nlemma add_le_add : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y z, (x + z \u227c y + z) \u27f7 (x \u227c y) :=\nbegin\n  refine (generalize $ generalize $ generalize _), simp[fal_fn],\n  suffices : \u290a\u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2203. (#0 + (#3 + #1) =' #2 + #1) \u27f7 \u2203. (#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 : \u290a\u290a\u290a\u290aI\u2092\u209a\u2091\u2099 +{ #0 + (#3 + #1) =' #2 + #1 } \u22a2 #0 + (#3 + #1) =' #2 + #1, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0, \u2190add_assoc, Herbrand.add_right_cancel] at this \u22a2, exact this },\n  { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ use #0 _), simp[formula.pow_eq],\n    have : \u290a\u290a\u290a\u290aI\u2092\u209a\u2091\u2099 +{ #0 + #3 =' #2 } \u22a2 #0 + #3 =' #2, by simp,\n    simp[Herbrand.eq_of_provable_equiv_0, \u2190add_assoc, Herbrand.add_right_cancel] at this \u22a2, exact this }\nend \n\n@[simp] lemma Lindenbaum.le_add_right_cancel (h\u2081 h\u2082 h\u2083 : Herbrand I\u2092\u209a\u2091\u2099 i) :\n  (h\u2081 + h\u2083 \u227c h\u2082 + h\u2083 : Lindenbaum I\u2092\u209a\u2091\u2099 i) = (h\u2081 \u227c h\u2082) :=\nbegin\n  induction h\u2081 using fol.Herbrand.ind_on with t\u2081,\n  induction h\u2082 using fol.Herbrand.ind_on with t\u2082,\n  induction h\u2083 using fol.Herbrand.ind_on with t\u2083,\n  have : I\u2092\u209a\u2091\u2099^i \u22a2 (t\u2081 + t\u2083 \u227c t\u2082 + t\u2083) \u27f7 (t\u2081 \u227c t\u2082), by simpa[fal_fn] using add_le_add _ \u229a t\u2081 \u229a t\u2082 \u229a t\u2083,\n  simpa using Lindenbaum.eq_of_provable_equiv.mp this\nend\n\nlemma lt_equiv : I\u2092\u209a\u2091\u2099' \u22a2 \u2200\u2081 x y, (x \u227a y) \u27f7 \u2203\u2081 z, (Succ z + x =' y) :=\nbegin\n  refine (generalize $ generalize _), simp[fal_fn, ex_fn],\n  suffices : \u290a\u290aI\u2092\u209a\u2091\u2099' \u22a2 (#1 \u227c #0) \u2293 (#1 \u2260' #0) \u27f7 \u2203. (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 : \u290a\u290aI\u2092\u209a\u2091\u2099' \u22a2 (\u2203. (#0 + #2 =' #1)) \u27f6 \u223c(#1 =' #0) \u27f6 \u2203. (Succ #0 + #2 =' #1),\n    { simp[Lindenbaum.le_of_provable_imply_0, Lindenbaum.le_iff] at this \u22a2,\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 : \u290a\u290a\u290aI\u2092\u209a\u2091\u2099' +{ #0 + #2 =' #1 } \u22a2 (#0 =' 0) \u27f6 (#2 \u2260' #0 + #2) \u27f6 \u2203. (Succ #0 + #3 =' #1 + #3),\n    { refine (deduction.mp _), simp[Lindenbaum.le_of_provable_imply_0, Lindenbaum.rew_by_axiom\u2081] },\n    have succ : \u290a\u290a\u290aI\u2092\u209a\u2091\u2099' +{ #0 + #2 =' #1 } \u22a2 (\u2203\u2081 y, #1 =' Succ y) \u27f6 (#2 \u2260' #0 + #2) \u27f6 \u2203. (Succ #0 + #3 =' #1 + #3),\n    { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ deduction.mp $ use #0 _), simp[\u2190sf_dsb], \n      simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.rew_by_axiom\u2082] },\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 (\u290a\u290a\u290aI\u2092\u209a\u2091\u2099' +{ Succ #0 + #2 =' #1 }) 0 0 (Succ \u266f0) \u266f2, }\nend\n\nlemma lt_equiv' (x y) : I\u2092\u209a\u2091\u2099' \u22a2 (x \u227a y) \u27f7 \u2203\u2081 z, (Succ z + x^1 =' y^1) :=\nby simpa[lt, fal_fn, ex_fn, \u2190term.pow_rew_distrib] using (lt_equiv _) \u229a x \u229a y \n\nlemma Lindenbaum.lt_eq (h\u2081 h\u2082 : Herbrand I\u2092\u209a\u2091\u2099' i) :\n  (h\u2081 \u227a' h\u2082) = \u2203' (Succ \u266f0 + h\u2081.pow =' h\u2082.pow : Lindenbaum I\u2092\u209a\u2091\u2099' (i + 1)) :=\nby induction h\u2081 using fol.Herbrand.ind_on with t;\n   induction h\u2082 using fol.Herbrand.ind_on with u;\n   simpa[lt, fal_fn, ex_fn] using Lindenbaum.eq_of_provable_equiv.mp ((lt_equiv' (I\u2092\u209a\u2091\u2099'^i) t u))\n\n@[simp, refl] lemma Lindenbaum.le_refl (h : Herbrand I\u2092\u209a\u2091\u2099 i) : h \u2264 h :=\nby { have : h \u2264 0 + h, from robinson.Lindenbaum.le_add_self I\u2092\u209a\u2091\u2099 i h 0,\n     simpa using this }\n\n@[simp] lemma Lindenbaum.le_succ_refl (h : Herbrand I\u2092\u209a\u2091\u2099 i) : h \u2264 Succ h :=\nby { have : h \u2264 1 + h, from robinson.Lindenbaum.le_add_self I\u2092\u209a\u2091\u2099 i h 1, \n     simpa[numeral_one_def] using this }\n\nlemma le_transitive : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y z, (x \u227c y) \u27f6 (y \u227c z) \u27f6 (x \u227c z) :=\nbegin\n  refine (generalize $ generalize $ generalize _), simp[fal_fn],\n  suffices : \u290a\u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2203. (#0 + #3 =' #2) \u27f6 \u2203. (#0 + #2 =' #1) \u27f6 \u2203. (#0 + #3 =' #1),\n  { simp[Lindenbaum.eq_top_of_provable_0, Lindenbaum.le_iff] at this \u22a2, 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[\u2190sf_dsb, formula.pow_eq],\n  show (I\u2092\u209a\u2091\u2099^5) +{ #1 + #4 =' #3 } +{ #0 + #3 =' #2 } \u22a2 #0 + #1 + #4 =' #2,\n  by simp[Herbrand.eq_of_provable_equiv_0, Lindenbaum.rew_by_axiom\u2081_inv, Lindenbaum.rew_by_axiom\u2082_inv, add_assoc]\nend\n\n@[trans] lemma Lindenbaum.le_transitive {h\u2081 h\u2082 h\u2083 : Herbrand I\u2092\u209a\u2091\u2099 i} : h\u2081 \u2264 h\u2082 \u2192 h\u2082 \u2264 h\u2083 \u2192 h\u2081 \u2264 h\u2083 := \u03bb le\u2081\u2082 le\u2082\u2083,\nbegin\n  induction h\u2081 using fol.Herbrand.ind_on with t\u2081,\n  induction h\u2082 using fol.Herbrand.ind_on with t\u2082,\n  induction h\u2083 using fol.Herbrand.ind_on with t\u2083,\n  have le\u2081\u2082 : I\u2092\u209a\u2091\u2099^i \u22a2 t\u2081 \u227c t\u2082, from Herbrand.le_iff_provable_le.mpr le\u2081\u2082,\n  have le\u2082\u2083 : I\u2092\u209a\u2091\u2099^i \u22a2 t\u2082 \u227c t\u2083, from Herbrand.le_iff_provable_le.mpr le\u2082\u2083,\n  have : I\u2092\u209a\u2091\u2099^i \u22a2 (t\u2081 \u227c t\u2082) \u27f6 (t\u2082 \u227c t\u2083) \u27f6 (t\u2081 \u227c t\u2083), by simpa[fal_fn] using le_transitive _ \u229a t\u2081 \u229a t\u2082 \u229a t\u2083,\n  exact Herbrand.le_iff_provable_le.mp (this \u2a00 le\u2081\u2082 \u2a00 le\u2082\u2083)\nend\n\nlemma add_lt_of_lt_of_lt : I\u2092\u209a\u2091\u2099' \u22a2 \u2200\u2081 x y z v, (x \u227a y) \u27f6 (z \u227a v) \u27f6 (x + z \u227a y + v) :=\nbegin\n  refine (generalize $ generalize $ generalize $ generalize _), simp[fal_fn],\n  show I\u2092\u209a\u2091\u2099'^4 \u22a2 (#3 \u227a #2) \u27f6 (#1 \u227a #0) \u27f6 (#3 + #1 \u227a #2 + #0),\n  suffices : I\u2092\u209a\u2091\u2099'^4 \u22a2 \u2203. (Succ #0 + #4 =' #3) \u27f6 \u2203. (Succ #0 + #2 =' #1) \u27f6 \u2203. (Succ #0 + #4 + #2 =' #3 + #1),\n  { simp[lt, Lindenbaum.eq_top_of_provable_0, Lindenbaum.lt_eq, add_pow, add_assoc] at this \u22a2, 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[\u2190sf_dsb, formula.pow_eq],\n  show (I\u2092\u209a\u2091\u2099'^6)+{ Succ #1 + #5 =' #4 }+{ Succ #0 + #3 =' #2 } \u22a2 Succ (Succ #1 + #0) + #5 + #3 =' #4 + #2,\n  simp[Herbrand.eq_of_provable_equiv_0, rew_by_axiom\u2081_inv, rew_by_axiom\u2082_inv],\n  calc    (\u266f1 + \u266f0 + \u266f5 + \u266f3 : Herbrand ((I\u2092\u209a\u2091\u2099'^6)+{ Succ #1 + #5 =' #4 }+{ Succ #0 + #3 =' #2 }) 0) \n        = (\u266f1 + (\u266f0 + \u266f5) + \u266f3) : by simp[add_assoc]\n    ... = (\u266f1 + (\u266f5 + \u266f0) + \u266f3) : by simp[add_comm]\n    ... = \u266f1 + \u266f5 + (\u266f0 + \u266f3)   : by simp[add_assoc]\nend\n\nlemma eq_or_succ_le_of_le : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y, (x \u227c y) \u27f6 (x =' y) \u2294 (Succ x \u227c y) :=\nbegin\n  refine (generalize $ generalize _), simp[fal_fn],\n  suffices : \u290a\u290aI\u2092\u209a\u2091\u2099 \u22a2 \u2203. (#0 + #2 =' #1) \u27f6 (#1 =' #0) \u2294 \u2203. (#0 + Succ #2 =' #1),\n  { simp[Lindenbaum.eq_top_of_provable_0, Lindenbaum.le_iff] at this \u22a2, exact this },\n  refine (imply_ex_of_fal_imply $ generalize _), simp[formula.pow_eq],\n  show I\u2092\u209a\u2091\u2099^3 \u22a2 (#0 + #2 =' #1) \u27f6 (#2 =' #1) \u2294 \u2203. (#0 + Succ #3 =' #2),\n  have zero : I\u2092\u209a\u2091\u2099^3 \u22a2 (#0 =' 0) \u27f6 (#0 + #2 =' #1) \u27f6 (#2 =' #1) \u2294 \u2203. (#0 + Succ #3 =' #2),\n  { refine (deduction.mp $ deduction.mp _),\n    simp[Lindenbaum.eq_top_of_provable_0, Lindenbaum.rew_by_axiom\u2081_inv, Lindenbaum.rew_by_axiom\u2082] },\n  have succ : I\u2092\u209a\u2091\u2099^3 \u22a2 (\u2203\u2081 y, #1 =' Succ y) \u27f6 (#0 + #2 =' #1) \u27f6 (#2 =' #1) \u2294 \u2203. (#0 + Succ #3 =' #2),\n  { refine (imply_ex_of_fal_imply $ generalize $ deduction.mp $ deduction.mp $ imply_or_right _ _ \u2a00 use #0 _),\n    simp[Lindenbaum.eq_top_of_provable_0, Lindenbaum.rew_by_axiom\u2081_inv, Lindenbaum.rew_by_axiom\u2082] },\n  exact case_of_ax (zero_or_succ _ #0) zero succ\nend\n\nlemma le_or_ge : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y, (x \u227c y) \u2294 (y \u227c x) :=\nbegin\n  have ind : I\u2092\u209a\u2091\u2099^1 \u22a2 (#0 \u227c 0) \u2294 (0 \u227c #0) \u27f6\n                  \u2200. ((#1 \u227c #0) \u2294 (#0 \u227c #1) \u27f6 (#1 \u227c Succ #0) \u2294 (Succ #0 \u227c #1)) \u27f6\n                  \u2200. (#1 \u227c #0) \u2294 (#0 \u227c #1),\n  by simpa using Ind.I_succ_induction is_open \u290aI\u2092\u209a\u2091\u2099 ((#1 \u227c #0) \u2294 (#0 \u227c #1)) (by simp[set.mem_def]),\n  have zero : I\u2092\u209a\u2091\u2099^1 \u22a2 (#0 \u227c 0) \u2294 (0 \u227c #0), from (imply_or_right _ _ \u2a00 (by simp[Herbrand.le_iff_provable_le_0])),\n  have succ : I\u2092\u209a\u2091\u2099^1 \u22a2 \u2200. ((#1 \u227c #0) \u2294 (#0 \u227c #1) \u27f6 (#1 \u227c Succ #0) \u2294 (Succ #0 \u227c #1)),\n  { refine generalize _, \n    have orl : I\u2092\u209a\u2091\u2099^2 \u22a2 (#1 \u227c #0) \u27f6 (#1 \u227c Succ #0) \u2294 (Succ #0 \u227c #1),\n    { refine (deduction.mp $ imply_or_left _ _ \u2a00 _),\n      have : (I\u2092\u209a\u2091\u2099^2)+{ #1 \u227c #0 } \u22a2 #1 \u227c #0, by simp,\n      simp[Herbrand.le_iff_provable_le_0] at this \u22a2,\n      refine Lindenbaum.le_transitive _ _ this (by simp) },\n    have orr : I\u2092\u209a\u2091\u2099^2 \u22a2 (#0 \u227c #1) \u27f6 (#1 \u227c Succ #0) \u2294 (Succ #0 \u227c #1),\n    { refine (deduction.mp _),\n      have eq      : (I\u2092\u209a\u2091\u2099^2) +{ #0 \u227c #1 } \u22a2 (#0 =' #1) \u27f6 (#1 \u227c Succ #0) \u2294 (Succ #0 \u227c #1),\n      { refine (deduction.mp $ imply_or_left _ _ \u2a00 _), simp[Herbrand.le_iff_provable_le_0, rew_by_axiom\u2081] },\n      have succ_le : (I\u2092\u209a\u2091\u2099^2) +{ #0 \u227c #1 } \u22a2 (Succ #0 \u227c #1) \u27f6 (#1 \u227c Succ #0) \u2294 (Succ #0 \u227c #1),\n        by simp[Lindenbaum.le_of_provable_imply_0],\n      have : (I\u2092\u209a\u2091\u2099^2) +{ #0 \u227c #1 } \u22a2 (#0 =' #1) \u2294 (Succ #0 \u227c #1), \n        from deduction.mpr (show (I\u2092\u209a\u2091\u2099^2) \u22a2 (#0 \u227c #1) \u27f6 (#0 =' #1) \u2294 (Succ #0 \u227c #1),\n        by simpa[fal_fn] using eq_or_succ_le_of_le _ \u229a #0 \u229a #1),\n      exact case_of_ax this eq succ_le },\n    exact or_imply _ _ _ \u2a00 orl \u2a00 orr },\n  refine (generalize _), simp[fal_fn], exact ind \u2a00 zero \u2a00 succ\nend\n\n@[simp] lemma prec_open (t u : term LA') : coe_inv_is_open defs (t \u227a u) :=\nby { have : ((coe : LA'.pr 2 \u2192 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\u2092\u209a\u2091\u2099' \u22a2 \u2200\u2081 x y z, (x \u227a y) \u27f6 (z \u2260' 0) \u27f6 (x * z \u227a y * z) :=\nbegin\n  have ind : I\u2092\u209a\u2091\u2099'^2 \u22a2\n       ((#1 \u227a #0) \u27f6 ((0 : term LA) \u2260' 0) \u27f6 (#1 * 0 \u227a #0 * 0)) \u27f6\n    \u2200. (((#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0)) \u27f6 (#2 \u227a #1) \u27f6 (Succ #0 \u2260' 0) \u27f6 (#2 * Succ #0 \u227a #1 * Succ #0)) \u27f6\n    \u2200. ((#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0)),\n  by simpa[additional.lt] using\n    I_succ_induction_LA (I\u2092\u209a\u2091\u2099'^2) ((#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0)) (by simp),\n  have zero : I\u2092\u209a\u2091\u2099'^2 \u22a2 (#1 \u227a #0) \u27f6 ((0 : term LA) \u2260' 0) \u27f6 (#1 * 0 \u227a #0 * 0), by simp[Lindenbaum.eq_top_of_provable_0],\n  have succ : I\u2092\u209a\u2091\u2099'^2 \u22a2 \u2200. (((#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0)) \u27f6 (#2 \u227a #1) \u27f6 (Succ #0 \u2260' 0) \u27f6 (#2 * Succ #0 \u227a #1 * Succ #0)),\n  { refine (generalize $ deduction.mp $ deduction.mp $ deduction.mp _), simp[-iff_and],\n    have zero : (I\u2092\u209a\u2091\u2099'^3) +{ (#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0) } +{ #2 \u227a #1 } +{ Succ #0 \u2260' 0 } \u22a2 (#0 =' 0) \u27f6 (#2 * Succ #0 \u227a #1 * Succ #0),\n    { refine (deduction.mp $ rew_of_eq 0 0 (by simp) _),\n      have : (I\u2092\u209a\u2091\u2099'^3) +{ (#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0) } +{ #2 \u227a #1 } +{ Succ #0 \u2260' 0 }+{ #0 =' 0 } \u22a2 #2 \u227a #1, by simp,\n      simpa[Herbrand.iff_abberavation\u2082_0] using this },\n    have nonzero : (I\u2092\u209a\u2091\u2099'^3) +{ (#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0) } +{ #2 \u227a #1 } +{ Succ #0 \u2260' 0 } \u22a2 (#0 \u2260' 0) \u27f6 (#2 * Succ #0 \u227a #1 * Succ #0),\n    { refine (deduction.mp _),\n      have lt : (I\u2092\u209a\u2091\u2099'^3) +{ (#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0) } +{ #2 \u227a #1 } +{ Succ #0 \u2260' 0 } +{ #0 \u2260' 0 } \u22a2 #2 * #0 \u227a #1 * #0,\n        from (show _ \u22a2 (#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0), by simp) \u2a00 (by simp) \u2a00 (by simp),\n      have : (I\u2092\u209a\u2091\u2099'^3) \u22a2 (#2 * #0 \u227a #1 * #0) \u27f6 (#2 \u227a #1) \u27f6 (#2 * #0 + #2 \u227a #1 * #0 + #1),\n      by simpa[fal_fn] using ((add_lt_of_lt_of_lt (I\u2092\u209a\u2091\u2099'^3)) \u229a (#2 * #0) \u229a (#1 * #0) \u229a #2 \u229a #1),\n      have : (I\u2092\u209a\u2091\u2099'^3) +{ (#2 \u227a #1) \u27f6 (#0 \u2260' 0) \u27f6 (#2 * #0 \u227a #1 * #0) } +{ #2 \u227a #1 } +{ Succ #0 \u2260' 0 } +{ #0 \u2260' 0 } \u22a2 #2 * #0 + #2 \u227a #1 * #0 + #1,\n        from this.extend \u2a00 lt \u2a00 (by simp),\n      simp[Lindenbaum.eq_top_of_provable_0] at this \u22a2, exact this },\n    refine cases_of _ _ zero nonzero },\n  refine (generalize $ generalize _), simp[fal_fn], exact ind \u2a00 zero \u2a00 succ\nend\n\n#check 0  /-\nlemma mul_right_cancel_of_nonzero_aux : I\u2092\u209a\u2091\u2099' \u22a2 \u2200\u2081 x y z, (z \u2260' 0) \u27f6 (x * z =' y * z) \u27f6 (x =' y) :=\nbegin\n  refine (generalize $ generalize $ generalize _), simp[fal_fn],\n  suffices : I\u2092\u209a\u2091\u2099'^3 \u22a2 (#0 \u2260' 0) \u27f6 (#2 \u2260' #1) \u27f6 (#2 * #0 \u2260' #1 * #0),\n  {  simp[Lindenbaum.eq_top_of_provable_0] at this \u22a2, simpa[sup_comm] using this },\n  have : I\u2092\u209a\u2091\u2099'^3 \u22a2 \u2200\u2081 x y z, (x \u227a y) \u27f6 (z \u2260' 0) \u27f6 (x * z \u227a y * z),\n  have := (lt_mul_of_nonzero_of_lt (I\u2092\u209a\u2091\u2099'^3)),\n\n  simp[fal_fn] at this,\n  have orl : I\u2092\u209a\u2091\u2099' \u22a2 (#1 \u227c #2) \u27f6 \u223c(#0 =' 0) \u27f6 \u223c(#2 =' #1) \u27f6 \u223c(#2 * #0 =' #1 * #0),\n  { refine (deduction.mp $ deduction.mp $ deduction.mp $ ne_symm _),\n    have : I\u2092\u209a\u2091\u2099' +{ #1 \u227c #2 } +{ #0 \u2260' 0 } +{ #2 \u2260' #1 } \u22a2 _, { have h := (this \u229a #1 \u229a #2 \u229a #0),  }, \n    have := this \u2a00 (by {simp[lessthan_def, fal_fn], refine ne_symm (by simp) }) \u2a00 (by simp[fal_fn]),\n    simp[lessthan_def, fal_fn] at this, exact this.2 },\n  have orr : I\u2092\u209a\u2091\u2099 \u22a2 (#2 \u227c #1) \u27f6 \u223c(#0 =' 0) \u27f6 \u223c(#2 =' #1) \u27f6 \u223c(#2 * #0 =' #1 * #0),\n  { refine (deduction.mp $ deduction.mp $ deduction.mp _),\n    have : I\u2092\u209a\u2091\u2099 +{ #2 \u227c #1 } +{ #0 \u2260' 0 } +{ #2 \u2260' #1 } \u22a2 _, from provable.extend (this \u229a #2 \u229a #1 \u229a #0), \n    have := this \u2a00 (by simp[lessthan_def, fal_fn]) \u2a00 (by simp[fal_fn]),\n    simp[lessthan_def, fal_fn] at this, exact this.2 },\n  refine case_of_ax (show I\u2092\u209a\u2091\u2099 \u22a2 (#1 \u227c #2) \u2294 (#2 \u227c #1), by simpa[fal_fn] using le_or_ge \u229a #1 \u229a #2) orl orr\nend\n\nlemma one_divides : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x, 1 \u236d 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\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x, x \u236d 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\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x, x \u236d 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\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y z, (x \u236d y) \u27f6 (y \u236d z) \u27f6 (x \u236d 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, \u2190sf_dsb],\n  show I\u2092\u209a\u2091\u2099 +{ #1 * #5 =' #4 } +{ #0 * #4 =' #3 } \u22a2 #0 * #1 * #5 =' #3,\n  simp[Herbrand.eq_of_provable_equiv_0, rew_by_axiom\u2081_inv, rew_by_axiom\u2082_inv, mul_assoc]\nend\n-/\nend Iopen\n/-\u2092\ndef \n\n\nlemma add_symm : I\u2092\u209a\u2091\u2099 \u22a2 \u2200\u2081 x y, (x + y =' y + x) :=\nbegin\n  refine (generalize _), simp[fal_fn],\n  have zero : I\u2092\u209a\u2091\u2099 \u22a2 (#0 =' 0) \u27f6 \u2200. (#1 + #0 =' #0 + #1),\n  { refine (deduction.mp $ generalize _), simp[\u2190sf_dsb, Herbrand.eq_of_provable_equiv_0, rew_by_axiom\u2081] },\n  have succ : I\u2092\u209a\u2091\u2099 \u22a2 (\u2203\u2081 y, #1 =' Succ y) \u27f6 \u2200. (#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, \u2190sf_dsb],\n    suffices : I\u2092\u209a\u2091\u2099 \u22a2 Succ #1 + #0 =' #0 + Succ #1, by simp[this],\n     \n     }\nend\n\n\n\n\ndef Ind {C : Theory LA} : Lindenbaum \ud835\udc08C 1 \u2192 Prop := \u03bb l, \u2203 p, p \u2208 C \u2227 l = \u27e6p\u27e7\u1d38\n\nlemma Ind_mem (p : formula LA) : Ind (\u27e6p\u27e7\u1d38 : Lindenbaum \ud835\udc08C 1) \u2192 (\u27e6peano_induction p\u27e7\u1d38 : Lindenbaum \ud835\udc08C 0) = \u22a4 :=\nbegin\n  simp[Ind], \n  intros p0 h eqn, \n  have : \ud835\udc08C \u22a2 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 : (\u27e6peano_induction p\u27e7\u1d38 : Lindenbaum \ud835\udc08C 0) = \u27e6peano_induction p0\u27e7\u1d38,\n  { simp[succ_induction, Lindenbaum.pow_eq, Lindenbaum.subst_eq, eqn], },\n  simp*\nend\n\nlemma Lindenbaum_induction \n  (l : Lindenbaum \ud835\udc08C 1) (m : Lindenbaum \ud835\udc08C 0)\n  (h : Ind l)\n  (zero : m \u2264 0 \u22b3 l)\n  (succ : m.pow \u2264 (\u266f0 \u22b3 l.pow)\u1d9c \u2294 (Succ \u266f0) \u22b3 l.pow) : m \u2264 \u2200. 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 \ud835\udc08C 0) \u22b3 \u27e6p\u27e7\u1d38 \u2293 \u2200. ((\u266f0 \u22b3 pow \u27e6p\u27e7\u1d38)\u1d9c \u2294 (Succ \u266f0) \u22b3 pow \u27e6p\u27e7\u1d38) \u2264 \u2200. \u27e6p\u27e7\u1d38,\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 \u2264 \u2200. ((\u266f0 \u22b3 pow \u27e6p\u27e7\u1d38)\u1d9c \u2294 (Succ \u266f0) \u22b3 pow \u27e6p\u27e7\u1d38),\n    from Lindenbaum.proper.pow_le_le_fal succ,\n  have : m \u2264 0 \u22b3 \u27e6p\u27e7\u1d38 \u2293 \u2200. ((\u266f0 \u22b3 pow \u27e6p\u27e7\u1d38)\u1d9c \u2294 (Succ \u266f0) \u22b3 pow \u27e6p\u27e7\u1d38), \n    from le_inf zero succ',\n  exact le_trans this trn\nend\n\nlemma Lindenbaum_induction_top {p : formula LA} (l : Lindenbaum \ud835\udc08C 1)\n  (h : Ind l)\n  (zero : 0 \u22b3 l = \u22a4)\n  (succ : \u266f0 \u22b3 l.pow \u2264 (Succ \u266f0) \u22b3 l.pow) : (\u2200. l : Lindenbaum \ud835\udc08C 0) = \u22a4 :=\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 \ud835\udc08C 0) \u22b3 \u27e6p\u27e7\u1d38 \u2293 \u2200. ((\u266f0 \u22b3 pow \u27e6p\u27e7\u1d38)\u1d9c \u2294 (Succ \u266f0) \u22b3 pow \u27e6p\u27e7\u1d38) \u2264 \u2200. \u27e6p\u27e7\u1d38,\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 : (\u266f0 \u22b3 pow \u27e6p\u27e7\u1d38)\u1d9c \u2294 (Succ \u266f0) \u22b3 pow \u27e6p\u27e7\u1d38 = \u22a4,\n    from ((\u266f0 \u22b3 pow \u27e6p\u27e7\u1d38).compl_sup_iff_le ((Succ \u266f0) \u22b3 pow \u27e6p\u27e7\u1d38)).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 := \u2200. ((\u266f0 \u227c h.pow)\u1d9c \u2294 l)\ndef Lindenbaum.bd_ex {T : Theory LA} (l : Lindenbaum T (i + 1)) (h : Herbrand T i) : Lindenbaum T i := \u2203. ((\u266f0 \u227c h.pow) \u2293 l)\n\nnotation `\u2200._{\u227c `:95 h `} ` l :90 := Lindenbaum.bd_fal l h \nnotation `\u2203._{\u227c `:95 h `} ` l :90 := Lindenbaum.bd_ex l h \n\ntheorem collection (p : formula LA) [proper 0 (\ud835\udeba\u20701)] :\n  \ud835\udc08\ud835\udeba\u20701 \u22a2 ([\u2200. \u227c #0] \u2203. p) \u27f6 \u2203. [\u2200. \u227c #1] [\u2203. \u227c #1] ((p^3).rew \u0131[4 \u21dd #0]).rew \u0131[3 \u21dd #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 : \u2200 l : Lindenbaum \ud835\udc10+\ud835\udc08\ud835\udeba\u20701 2,\n    \u2200._{\u227c \u266f1} \u2203. l \u2264 \u2203. \u2200._{\u227c \u266f2} \u2203._{\u227c \u266f2} (\u266f1 \u22b3 \u266f0 \u22b3 l.pow.pow.pow),\n  { sorry },\n  intros l,\n  have : \u2200._{\u227c \u266f1} \u2203. l \u2264 \u2200. \u2200. ((\u266f0 \u227c \u266f1)\u1d9c \u2294 \u2203. \u2200._{\u227c \u266f1} \u2203._{\u227c \u266f1} l.pow.pow.pow),\n  { refine Lindenbaum_induction _ _ _ _ _; sorry }\n  \nend\n\ntheorem collection (p : formula LA) [proper 0 (\ud835\udeba\u20701)] : \ud835\udc10+\ud835\udc08\ud835\udeba\u20701 \u22a2 ([\u2200. \u227c #0] \u2203. p) \u27f6 \u2203. [\u2200. \u227c #1] [\u2203. \u227c #1] p :=\nbegin\n  refine deduction.mp _,\n  have : \u2200 n, \u2203 m, (((\u0131[0 \u21dd #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 \u27e8q, e_q\u27e9,\n  suffices : \ud835\udc10+\ud835\udc08\ud835\udeba\u20701+{[\u2200. \u227c #0] \u2203. p} \u22a2 \u2200. \u2200. ((#0 \u227c #1) \u27f6 \u2203. [\u2200. \u227c #1] [\u2203. \u227c #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 : (\u03bb (x : \u2115), term.rew \u0131[3 \u21dd #3] (\u0131[4 \u21dd #4] x) : \u2115 \u2192 term LA) = \n      (\u03bb x, if x < 4 then #x else if 4 < x then #(x - 2) else #3 ),\n    { funext x, have C : x < 4 \u2228 x = 4 \u2228 4 < x := trichotomous x 4,\n      cases C, simp[C], { by_cases C\u2082 : x < 3, simp[C\u2082], simp[show x = 3, by omega] },\n      cases C; simp[C], \n      { simp[show \u00acx < 4, from asymm C, show 3 < x - 1, from nat.lt_sub_left_of_add_lt C, \u0131],\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\u2082 (\ud835\udc10^0) *\u2264 \u27e6#0\u27e7\u1d34 c\u27ea*Z\u27eb\u2070 = \u22a5,\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 \u25b8 x.1.zero_mem\n\nsection\nvariables (R) (S : Type v) [comm_ring S]\n\n/-- The prime spectrum of `R \u00d7 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 \u00d7 S) \u2243 prime_spectrum R \u2295 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 \u22a4 :=\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 \u22a4 x.as_ideal :=\nby { cases x, refl }\n\nend\n\n@[ext] lemma ext {x y : prime_spectrum R} :\n  x = y \u2194 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 \u2286 x.as_ideal}\n\n@[simp] lemma mem_zero_locus (x : prime_spectrum R) (s : set R) :\n  x \u2208 zero_locus s \u2194 s \u2286 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\u2a05 (x : prime_spectrum R) (h : x \u2208 t), x.as_ideal\n\nlemma coe_vanishing_ideal (t : set (prime_spectrum R)) :\n  (vanishing_ideal t : set R) = {f : R | \u2200 x : prime_spectrum R, x \u2208 t \u2192 f \u2208 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 \u2208 vanishing_ideal t \u2194 \u2200 x : prime_spectrum R, x \u2208 t \u2192 f \u2208 x.as_ideal :=\nby rw [\u2190 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 \u2286 zero_locus I \u2194 I \u2264 vanishing_ideal t :=\n\u27e8\u03bb h f k, (mem_vanishing_ideal _ _).mpr (\u03bb x j, (mem_zero_locus _ _).mpr (h j) k), \u03bb h,\n  \u03bb x j, (mem_zero_locus _ _).mpr (le_trans h (\u03bb f h, ((mem_vanishing_ideal _ _).mp h) x j))\u27e9\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  (\u03bb I, zero_locus I) (\u03bb t, vanishing_ideal t) :=\n\u03bb 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  (\u03bb s, zero_locus s) (\u03bb 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 \u2286 zero_locus s \u2194 s \u2286 vanishing_ideal t :=\n(gc_set R) s t\n\nend gc\n\nlemma subset_vanishing_ideal_zero_locus (s : set R) :\n  s \u2286 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 \u2264 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 $ \u03bb f,\nbegin\n  rw [mem_vanishing_ideal, ideal.radical_eq_Inf, submodule.mem_Inf],\n  exact \u27e8(\u03bb h x hx, h \u27e8x, hx.2\u27e9 hx.1), (\u03bb h x hx, h x.1 \u27e8hx, x.2\u27e9)\u27e9\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 \u25b8 (gc R).l_u_l_eq_l I\n\nlemma subset_zero_locus_vanishing_ideal (t : set (prime_spectrum R)) :\n  t \u2286 zero_locus (vanishing_ideal t) :=\n(gc R).l_u_le t\n\nlemma zero_locus_anti_mono {s t : set R} (h : s \u2286 t) : zero_locus t \u2286 zero_locus s :=\n(gc_set R).monotone_l h\n\nlemma zero_locus_anti_mono_ideal {s t : ideal R} (h : s \u2264 t) :\n  zero_locus (t : set R) \u2286 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 \u2286 t) :\n  vanishing_ideal t \u2264 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) \u2286 zero_locus (J : set R) \u2194 J \u2264 I.radical :=\n\u27e8\u03bb h, ideal.radical_le_radical_iff.mp (vanishing_ideal_zero_locus_eq_radical I \u25b8\n  vanishing_ideal_zero_locus_eq_radical J \u25b8 vanishing_ideal_anti_mono h),\n\u03bb h, zero_locus_radical I \u25b8 zero_locus_anti_mono_ideal h\u27e9\n\nlemma zero_locus_subset_zero_locus_singleton_iff (f g : R) :\n  zero_locus ({f} : set R) \u2286 zero_locus {g} \u2194 g \u2208 (ideal.span ({f} : set R)).radical :=\nby rw [\u2190 zero_locus_span {f}, \u2190 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 ((\u22a5 : 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 (\u2205 : set R) = set.univ :=\n(gc_set R).l_bot\n\n@[simp] lemma vanishing_ideal_univ :\n  vanishing_ideal (\u2205 : set (prime_spectrum R)) = \u22a4 :=\nby simpa using (gc R).u_top\n\nlemma zero_locus_empty_of_one_mem {s : set R} (h : (1:R) \u2208 s) :\n  zero_locus s = \u2205 :=\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 = \u22a4, { 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) = \u2205 :=\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) = \u2205 \u2194 I = \u22a4 :=\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 \u27e8M, hM, hIM\u27e9,\n    exact \u27e8\u27e8M, hM.is_prime\u27e9, hIM\u27e9 },\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) = \u2205 :=\nzero_locus_empty_of_one_mem (set.mem_univ 1)\n\nlemma zero_locus_sup (I J : ideal R) :\n  zero_locus ((I \u2294 J : ideal R) : set R) = zero_locus I \u2229 zero_locus J :=\n(gc R).l_sup\n\nlemma zero_locus_union (s s' : set R) :\n  zero_locus (s \u222a s') = zero_locus s \u2229 zero_locus s' :=\n(gc_set R).l_sup\n\nlemma vanishing_ideal_union (t t' : set (prime_spectrum R)) :\n  vanishing_ideal (t \u222a t') = vanishing_ideal t \u2293 vanishing_ideal t' :=\n(gc R).u_inf\n\nlemma zero_locus_supr {\u03b9 : Sort*} (I : \u03b9 \u2192 ideal R) :\n  zero_locus ((\u2a06 i, I i : ideal R) : set R) = (\u22c2 i, zero_locus (I i)) :=\n(gc R).l_supr\n\nlemma zero_locus_Union {\u03b9 : Sort*} (s : \u03b9 \u2192 set R) :\n  zero_locus (\u22c3 i, s i) = (\u22c2 i, zero_locus (s i)) :=\n(gc_set R).l_supr\n\nlemma zero_locus_bUnion (s : set (set R)) :\n  zero_locus (\u22c3 s' \u2208 s, s' : set R) = \u22c2 s' \u2208 s, zero_locus s' :=\nby simp only [zero_locus_Union]\n\nlemma vanishing_ideal_Union {\u03b9 : Sort*} (t : \u03b9 \u2192 set (prime_spectrum R)) :\n  vanishing_ideal (\u22c3 i, t i) = (\u2a05 i, vanishing_ideal (t i)) :=\n(gc R).u_infi\n\nlemma zero_locus_inf (I J : ideal R) :\n  zero_locus ((I \u2293 J : ideal R) : set R) = zero_locus I \u222a zero_locus J :=\nset.ext $ \u03bb x, by simpa using x.2.inf_le\n\nlemma union_zero_locus (s s' : set R) :\n  zero_locus s \u222a zero_locus s' = zero_locus ((ideal.span s) \u2293 (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 \u222a zero_locus J :=\nset.ext $ \u03bb 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} \u222a zero_locus {g} :=\nset.ext $ \u03bb x, by simpa using x.2.mul_mem_iff_mem_or_mem\n\n@[simp] lemma zero_locus_pow (I : ideal R) {n : \u2115} (hn : 0 < n) :\n  zero_locus ((I ^ n : ideal R) : set R) = zero_locus I :=\nzero_locus_radical (I ^ n) \u25b8 (I.radical_pow n hn).symm \u25b8 zero_locus_radical I\n\n@[simp] lemma zero_locus_singleton_pow (f : R) (n : \u2115) (hn : 0 < n) :\n  zero_locus ({f ^ n} : set R) = zero_locus {f} :=\nset.ext $ \u03bb 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 \u2294 vanishing_ideal t' \u2264 vanishing_ideal (t \u2229 t') :=\nbegin\n  intros r,\n  rw [submodule.mem_sup, mem_vanishing_ideal],\n  rintro \u27e8f, hf, g, hg, rfl\u27e9 x \u27e8hxt, hxt'\u27e9,\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 \u2208 (zero_locus {f} : set (prime_spectrum R))\u1d9c \u2194 f \u2209 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  (\u27e8set.univ, by simp\u27e9)\n  begin\n    intros Zs h,\n    rw set.sInter_eq_Inter,\n    let f : Zs \u2192 set R := \u03bb i, classical.some (h i.2),\n    have hf : \u2200 i : Zs, \u2191i = zero_locus (f i) := \u03bb i, (classical.some_spec (h i.2)).symm,\n    simp only [hf],\n    exact \u27e8_, zero_locus_Union _\u27e9\n  end\n  (by { rintro _ _ \u27e8s, rfl\u27e9 \u27e8t, rfl\u27e9, exact \u27e8_, (union_zero_locus s t).symm\u27e9 })\n\nlemma is_open_iff (U : set (prime_spectrum R)) :\n  is_open U \u2194 \u2203 s, U\u1d9c = zero_locus s :=\nby simp only [@eq_comm _ U\u1d9c]; refl\n\nlemma is_closed_iff_zero_locus (Z : set (prime_spectrum R)) :\n  is_closed Z \u2194 \u2203 s, Z = zero_locus s :=\nby rw [\u2190 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 \u27e8s, rfl\u27e9 }\n\nlemma is_closed_singleton_iff_is_maximal (x : prime_spectrum R) :\n  is_closed ({x} : set (prime_spectrum R)) \u2194 x.as_ideal.is_maximal :=\nbegin\n  refine (is_closed_iff_zero_locus _).trans \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { obtain \u27e8s, hs\u27e9 := h,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem] at hs,\n    refine \u27e8\u27e8x.2.1, \u03bb I hI, not_not.1 (mt (ideal.exists_le_maximal I) $\n      not_exists.2 (\u03bb J, not_and.2 $ \u03bb hJ hIJ,_))\u27e9\u27e9,\n    exact ne_of_lt (lt_of_lt_of_le hI hIJ) (symm $ congr_arg prime_spectrum.as_ideal\n      (hs.2 \u27e8J, hJ.is_prime\u27e9 (\u03bb r hr, hIJ (le_of_lt hI $ hs.1 hr)))) },\n  { refine \u27e8x.as_ideal.1, _\u27e9,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem],\n    refine \u27e8\u03bb _ h, h, \u03bb y hy, prime_spectrum.ext.2 (h.eq_of_le y.2.ne_top hy).symm\u27e9 }\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' \u27e8ht', ht\u27e9,\n    obtain \u27e8fs, rfl\u27e9 : \u2203 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 \u25b8 (gc R).u_l_u_eq_u t\n\nlemma t1_space_iff_is_field [is_domain R] :\n  t1_space (prime_spectrum R) \u2194 is_field R :=\nbegin\n  refine \u27e8_, \u03bb h, _\u27e9,\n  { introI h,\n    have hbot : ideal.is_prime (\u22a5 : 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 \u27e8\u22a5, hbot\u27e9)) (not_not.2 rfl)) },\n  { refine \u27e8\u03bb x, (is_closed_singleton_iff_is_maximal x).2 _\u27e9,\n    by_cases hx : x.as_ideal = \u22a5,\n    { exact hx.symm \u25b8 @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 \u27e8x.as_ideal, \u27e8hx, x.2\u27e9\u27e9) } }\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 \u2192+* S) (s : set R) :\n  (\u03bb y, \u27e8ideal.comap f y.as_ideal, infer_instance\u27e9 :\n    prime_spectrum S \u2192 prime_spectrum R) \u207b\u00b9' (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 \u2192+* S) : C(prime_spectrum S, prime_spectrum R) :=\n{ to_fun := \u03bb y, \u27e8ideal.comap f y.as_ideal, infer_instance\u27e9,\n  continuous_to_fun :=\n    begin\n      simp only [continuous_iff_is_closed, is_closed_iff_zero_locus],\n      rintro _ \u27e8s, rfl\u27e9,\n      exact \u27e8_, preimage_comap_zero_locus_aux f s\u27e9\n    end }\n\nvariables (f : R \u2192+* 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 \u2192+* S) (g : S \u2192+* 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) \u207b\u00b9' (zero_locus s) = zero_locus (f '' s) :=\npreimage_comap_zero_locus_aux f s\n\nlemma comap_injective_of_surjective (f : R \u2192+* S) (hf : function.surjective f) :\n  function.injective (comap f) :=\n\u03bb 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 \u2192+* 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 \u2192+* 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 \u2190 is_closed_compl_iff,\n  generalize : U\u1d9c = Z,\n  simp_rw [is_closed_induced_iff, is_closed_iff_zero_locus],\n  split,\n  { rintro \u27e8s, rfl\u27e9,\n    refine \u27e8_,\u27e8(algebra_map R S) \u207b\u00b9' (ideal.span s),rfl\u27e9,_\u27e9,\n    rw [preimage_comap_zero_locus, \u2190 zero_locus_span, \u2190 zero_locus_span s],\n    congr' 1,\n    exact congr_arg submodule.carrier (is_localization.map_comap M S (ideal.span s)) },\n  { rintro \u27e8_, \u27e8t, rfl\u27e9, rfl\u27e9, 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 (\u03bb (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\u27e8localization_comap_inducing S M, localization_comap_injective S M\u27e9\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 \u27e8p, rfl\u27e9 x \u27e8hx\u2081, hx\u2082\u27e9,\n    exact (p.2.1 : \u00ac _)\n      (p.as_ideal.eq_top_of_is_unit_mem hx\u2082 (is_localization.map_units S \u27e8x, hx\u2081\u27e9)) },\n  { intro h,\n    use \u27e8x.as_ideal.map (algebra_map R S),\n      is_localization.is_prime_of_is_prime_disjoint M S _ x.2 h\u27e9,\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 \u2209 x.as_ideal },\n  property := \u27e8{r}, set.ext $ \u03bb x, set.singleton_subset_iff.trans $ not_not.symm\u27e9 }\n\n@[simp] lemma mem_basic_open (f : R) (x : prime_spectrum R) :\n  x \u2208 basic_open f \u2194 f \u2209 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})\u1d9c :=\nset.ext $ \u03bb 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) = \u22a4 :=\ntopological_space.opens.ext $ by {simp, refl}\n\n@[simp] lemma basic_open_zero : basic_open (0 : R) = \u22a5 :=\ntopological_space.opens.ext $ by {simp, refl}\n\nlemma basic_open_le_basic_open_iff (f g : R) :\n  basic_open f \u2264 basic_open g \u2194 f \u2208 (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 \u2293 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) \u2264 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) \u2264 basic_open g :=\nby { rw basic_open_mul f g, exact inf_le_right }\n\n@[simp] lemma basic_open_pow (f : R) (n : \u2115) (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 (\u03bb (r : R), (basic_open r : set (prime_spectrum R)))) :=\nbegin\n  apply topological_space.is_topological_basis_of_open_of_nhds,\n  { rintros _ \u27e8r, rfl\u27e9,\n    exact is_open_basic_open },\n  { rintros p U hp \u27e8s, hs\u27e9,\n    rw [\u2190 compl_compl U, set.mem_compl_eq, \u2190 hs, mem_zero_locus, set.not_subset] at hp,\n    obtain \u27e8f, hfs, hfp\u27e9 := hp,\n    refine \u27e8basic_open f, \u27e8f, rfl\u27e9, hfp, _\u27e9,\n    rw [\u2190 set.compl_subset_compl, \u2190 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 \u2190 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 $ \u03bb \u03b9 Z hZc hZ,\nbegin\n  let I : \u03b9 \u2192 ideal R := \u03bb i, vanishing_ideal (Z i),\n  have hI : \u2200 i, Z i = zero_locus (I i) := \u03bb 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, \u2190 set.diff_eq,\n      set.diff_eq_empty, funext hI, \u2190 zero_locus_supr] at hZ,\n  obtain \u27e8n, hn\u27e9 : f \u2208 (\u2a06 (i : \u03b9), I i).radical,\n  { rw \u2190 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 \u27e8s, hs\u27e9,\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, \u2190 set.diff_eq,\n           set.diff_eq_empty, hI, \u2190 zero_locus_supr],\n  rw \u2190 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 \u27e8n, hs\u27e9\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\u2081 h\u2082,\n    exact h\u2081 \u27e8submonoid.mem_powers r, h\u2082\u27e9 },\n  { rintros h\u2081 _ \u27e8\u27e8n, rfl\u27e9, h\u2083\u27e9,\n    exact h\u2081 (x.2.mem_of_pow_mem _ h\u2083) },\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 \u2264 y` if and only if `y \u2208 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 \u2264 y.as_ideal \u2194 x \u2264 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 \u2194 x < y :=\nsubtype.coe_lt_coe\n\nlemma le_iff_mem_closure (x y : prime_spectrum R) :\n  x \u2264 y \u2194 y \u2208 closure ({x} : set (prime_spectrum R)) :=\nby rw [\u2190 as_ideal_le_as_ideal, \u2190 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\u27e8maximal_ideal R, (maximal_ideal.is_maximal R).is_prime\u27e9\n\nvariable {R}\n\nlemma local_hom_iff_comap_closed_point {S : Type v} [comm_ring S] [local_ring S]\n  {f : R \u2192+* S} : is_local_ring_hom f \u2194 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 \u00d7 S) :=\n{ star := \u03bb x, (star x.1, star x.2) }\n\n@[simp] lemma fst_star [has_star R] [has_star S] (x : R \u00d7 S) : (star x).1 = star x.1 := rfl\n@[simp] \n\nlemma star_def [has_star R] [has_star S] (x : R \u00d7 S) : star x = (star x.1, star x.2) := rfl\n\ninstance [has_involutive_star R] [has_involutive_star S] : has_involutive_star (R \u00d7 S) :=\n{ star_involutive := \u03bb _, prod.ext (star_star _) (star_star _) }\n\ninstance [semigroup R] [semigroup S] [star_semigroup R] [star_semigroup S] :\n  star_semigroup (R \u00d7 S) :=\n{ star_mul := \u03bb _ _, 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 \u00d7 S) :=\n{ star_add := \u03bb _ _, 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 \u00d7 S) :=\n{ ..prod.star_add_monoid, ..(prod.star_semigroup : star_semigroup (R \u00d7 S)) }\n\ninstance {\u03b1 : Type w} [has_scalar \u03b1 R] [has_scalar \u03b1 S] [has_star \u03b1] [has_star R] [has_star S]\n  [star_module \u03b1 R] [star_module \u03b1 S] :\n  star_module \u03b1 (R \u00d7 S) :=\n{ star_smul := \u03bb 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\u02e3) :\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 : \u2115)\n\n/-- Constant multivariate functor -/\n@[nolint unused_arguments]\ndef const (A : Type*) (v : typevec.{u} n) : Type* :=\nA\n\ninstance const.inhabited {A \u03b1} [inhabited A] : inhabited (const n A \u03b1) :=\n\u27e8 (default A : A) \u27e9\n\nnamespace const\nopen mvfunctor mvpfunctor\nvariables {n} {A : Type u} {\u03b1 \u03b2 : typevec.{u} n} (f : \u03b1 \u27f9 \u03b2)\n\n/-- Constructor for constant functor -/\nprotected def mk (x : A) : (const n A) \u03b1 := x\n\n/-- Destructor for constant functor -/\nprotected def get (x : (const n A) \u03b1) : A := x\n\n@[simp] protected lemma mk_get (x : (const n A) \u03b1) : const.mk (const.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : A) : const.get (const.mk x : const n A \u03b1) = x := rfl\n\n/-- `map` for constant functor -/\nprotected def map : (const n A) \u03b1 \u2192 (const n A) \u03b2 :=\n\u03bb x, x\n\ninstance : mvfunctor (const n A) :=\n{ map := \u03bb \u03b1 \u03b2 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) \u03b1) :\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       := \u03bb \u03b1 x, mvpfunctor.const.get x,\n  repr      := \u03bb \u03b1 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 : \u2200 {\u03b1 : Sort _}, \u03b1\n\n@[aesop safe cases]\nclass IsEmpty (\u03b1 : Sort _) where\n  false : \u03b1 \u2192 False\n\n@[aesop safe forward]\ndef IsEmpty.false' (h : IsEmpty \u03b1) (a : \u03b1) : False :=\n  h.false a\n\n@[aesop safe constructors]\nstructure Unique (\u03b1 : Sort _) extends Inhabited \u03b1 where\n  uniq : \u2200 a : \u03b1, a = toInhabited.default\n\nclass IsLeftId (\u03b1 : Type _) (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) (o : outParam \u03b1) : Prop where\n  leftId : \u2200 a, op o a = a\n\ndef Injective (f : \u03b1 \u2192 \u03b2) : Prop :=\n  \u2200 x y, f x = f y \u2192 x = y\n\n@[aesop safe forward]\ntheorem injective_elim (h\u2081 : Injective f) (h\u2082 : f a = f b) : a = b :=\n  h\u2081 _ _ h\u2082\n\n@[aesop 99%]\ntheorem injective_intro (h : \u2200 a b, f a = f b \u2192 a = b) : Injective f :=\n  h\n\ndef Surjective (f : \u03b1 \u2192 \u03b2) : Prop :=\n  \u2200 b, \u2203 a, f a = b\n\n@[aesop norm (forward (immediate := [h]))]\ntheorem surjective_elim (h : Surjective f) : \u2200 b, \u2203 a, f a = b :=\n  h\n\n@[aesop 99%]\ntheorem surjective_intro (h : \u2200 b, \u2203 a, f a = b) : Surjective f :=\n  h\n\n@[aesop norm unfold]\ndef Bijective (f : \u03b1 \u2192 \u03b2) : Prop :=\n  Injective f \u2227 Surjective f\n\ndef Involutive (f : \u03b1 \u2192 \u03b1) : Prop :=\n  \u2200 x, f (f x) = x\n\n@[aesop norm forward]\ntheorem involutive_elim {f : \u03b1 \u2192 \u03b1} (h : Involutive f) (a : \u03b1) : f (f a) = a :=\n  h a\n\n@[aesop 99%]\ntheorem involutive_intro (h : \u2200 a, f (f a) = a) : Involutive f :=\n  h\n\n@[aesop 25%]\ntheorem Involutive.injective : Involutive f \u2192 Injective f :=\n  \u03bb h x y hxy => by rw [\u2190 h x, \u2190 h y, hxy]\n\n@[aesop 25%]\ntheorem Involutive.surjective : Involutive f \u2192 Surjective f :=\n  \u03bb h x => \u27e8f x, h x\u27e9\n\ntheorem Involutive.bijective (h : Involutive f) : Bijective f :=\n  \u27e8h.injective, h.surjective\u27e9\n\nnamespace Option\n\n@[aesop safe [constructors, cases]]\ninductive Mem (a : \u03b1) : Option \u03b1 \u2192 Prop\n  | some : Mem a (some a)\n\ninstance : Membership \u03b1 (Option \u03b1) :=\n  \u27e8Option.Mem\u27e9\n\n@[simp]\ntheorem mem_spec {o : Option \u03b1} : a \u2208 o \u2194 o = some a := by\n  aesop (add norm simp Membership.mem)\n\n@[simp]\ntheorem mem_none : a \u2208 none \u2194 False := by\n  aesop\n\n@[simp]\ntheorem mem_some : a \u2208 some b \u2194 a = b := by\n  aesop\n\n@[simp]\ndef iget [Inhabited \u03b1] : Option \u03b1 \u2192 \u03b1\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 \u03b1 \u2192 List \u03b1\n  | [] => []\n  | [_] => []\n  | a :: as => a :: init as\n\n@[simp]\ndef last : (l : List \u03b1) \u2192 l \u2260 [] \u2192 \u03b1\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 \u03b1] : List \u03b1 \u2192 \u03b1\n  | [] => default\n  | [a] => a\n  | [_, b] => b\n  | _ :: _ :: l => ilast l\n\n@[simp]\ndef head' : List \u03b1 \u2192 Option \u03b1\n  | [] => none\n  | a :: _ => some a\n\n@[simp]\ndef ihead [Inhabited \u03b1] : List \u03b1 \u2192 \u03b1\n  | [] => default\n  | a :: _ => a\n\n@[simp]\ndef nth_le : \u2200 (l : List \u03b1) (n), n < l.length \u2192 \u03b1\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 : \u03b1 \u2192 \u03b1) : List \u03b1 \u2192 List \u03b1\n  | [] => []\n  | (a :: as) => f a :: as\n\n@[simp]\ndef Empty : List \u03b1 \u2192 Prop\n  | [] => True\n  | _ :: _ => False\n\n@[simp] theorem mem_eq_mem : Mem x xs \u2194 x \u2208 xs := Iff.rfl\n\ntheorem subset_trans {l\u2081 l\u2082 l\u2083 : List \u03b1} : l\u2081 \u2286 l\u2082 \u2192 l\u2082 \u2286 l\u2083 \u2192 l\u2081 \u2286 l\u2083 := by\n  intro h\u2081 h\u2082 a ha\n  cases l\u2081 with\n  | nil =>\n    cases ha\n  | cons x xs =>\n    cases ha with\n    | head =>\n      apply h\u2082\n      apply h\u2081\n      constructor\n    | tail _ hxs =>\n      apply h\u2082\n      apply h\u2081\n      constructor\n      assumption\n\n-- END PRELUDE\n\ninstance unique_of_is_empty [IsEmpty \u03b1] : Unique (List \u03b1) := by\n  aesop (add 1% cases List)\n\n-- instance : is_left_id (list \u03b1) has_append.append [] :=\n-- \u27e8 nil_append \u27e9\n\n-- instance : is_right_id (list \u03b1) has_append.append [] :=\n-- \u27e8 append_nil \u27e9\n\n-- instance : is_associative (list \u03b1) has_append.append :=\n-- \u27e8 append_assoc \u27e9\n\n-- attribute [-simp] cons_ne_nil\ntheorem X.cons_ne_nil (a : \u03b1) (l : List \u03b1) : a::l \u2260 [] := by\n  aesop\n\n-- attribute [-simp] cons_ne_self\ntheorem X.cons_ne_self (a : \u03b1) (l : List \u03b1) : a::l \u2260 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\u2081 h\u2082 : \u03b1} {t\u2081 t\u2082 : List \u03b1} :\n      (h\u2081::t\u2081) = (h\u2082::t\u2082) \u2192 h\u2081 = h\u2082 := by\n  aesop\n\n-- attribute [-simp] tail_eq_of_cons_eq\ntheorem X.tail_eq_of_cons_eq {h\u2081 h\u2082 : \u03b1} {t\u2081 t\u2082 : List \u03b1} :\n      (h\u2081::t\u2081) = (h\u2082::t\u2082) \u2192 t\u2081 = t\u2082 := by\n  aesop\n\n@[simp] theorem cons_injective {a : \u03b1} : Injective (cons a) := by\n  aesop\n\n-- attribute [-simp] cons_inj\ntheorem X.cons_inj (a : \u03b1) {l l' : List \u03b1} : a::l = a::l' \u2194 l = l' := by\n  aesop\n\n-- attribute [-simp] exists_cons_of_ne_nil\ntheorem X.exists_cons_of_ne_nil : l \u2260 nil \u2192 \u2203 b L, l = b :: L := by\n  aesop (add 1% cases List)\n\n-- theorem set_of_mem_cons (l : list \u03b1) (a : \u03b1) : {x | x \u2208 a :: l} = insert a {x | x \u2208 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 : \u03b1) : a \u2208 [a] := by\n  aesop\n\nattribute [-simp] mem_singleton\n-- attribute [-simp] eq_of_mem_singleton\ntheorem X.eq_of_mem_singleton {a b : \u03b1} : a \u2208 [b] \u2192 a = b := by\n  aesop\n\n@[simp]\ntheorem X.mem_singleton {a b : \u03b1} : a \u2208 [b] \u2194 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 : \u03b1} {l : List \u03b1} : a \u2208 b::l \u2192 b \u2208 l \u2192 a \u2208 l := by\n  aesop\n\nset_option linter.unusedVariables false in\ntheorem _root_.decidable.list.eq_or_ne_mem_of_mem [deq : DecidableEq \u03b1]\n  {a b : \u03b1} {l : List \u03b1} (h : a \u2208 b :: l) : a = b \u2228 (a \u2260 b \u2227 a \u2208 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 : \u03b1} {l : List \u03b1} : a \u2208 b :: l \u2192 a = b \u2228 (a \u2260 b \u2227 a \u2208 l) := by\n  open Classical in\n  aesop (add safe [decidable.list.eq_or_ne_mem_of_mem])\n\ntheorem not_mem_append {a : \u03b1} {s t : List \u03b1} (h\u2081 : a \u2209 s) (h\u2082 : a \u2209 t) : a \u2209 s ++ t := by\n  induction s <;> aesop\n\n-- attribute [-simp] ne_nil_of_mem\ntheorem X.ne_nil_of_mem {a : \u03b1} {l : List \u03b1} (h : a \u2208 l) : l \u2260 [] := by\n  aesop\n\nset_option linter.unusedVariables false in\ntheorem mem_split {a : \u03b1} {l : List \u03b1} (h : a \u2208 l) : \u2203 s t : List \u03b1, l = s ++ a :: t :=\n  ADMIT -- Nontrivial existential.\n\ntheorem mem_of_ne_of_mem {a y : \u03b1} {l : List \u03b1} (h\u2081 : a \u2260 y) (h\u2082 : a \u2208 y :: l) : a \u2208 l := by\n  aesop\n\ntheorem ne_of_not_mem_cons {a b : \u03b1} {l : List \u03b1} : a \u2209 b::l \u2192 a \u2260 b := by\n  aesop\n\ntheorem not_mem_of_not_mem_cons {a b : \u03b1} {l : List \u03b1} : a \u2209 b::l \u2192 a \u2209 l := by\n  aesop\n\ntheorem not_mem_cons_of_ne_of_not_mem {a y : \u03b1} {l : List \u03b1} : a \u2260 y \u2192 a \u2209 l \u2192 a \u2209 y::l := by\n  aesop\n\ntheorem ne_and_not_mem_of_not_mem_cons {a y : \u03b1} {l : List \u03b1} : a \u2209 y::l \u2192 a \u2260 y \u2227 a \u2209 l := by\n  aesop\n\n-- attribute [-simp] mem_map\n@[simp] theorem X.mem_map {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {l : List \u03b1} : b \u2208 map f l \u2194 \u2203 a, a \u2208 l \u2227 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 : \u03b1 \u2192 \u03b2) {a : \u03b1} {l : List \u03b1} (h : a \u2208 l) : f a \u2208 map f l := by\n  aesop\n\ntheorem mem_map_of_injective {f : \u03b1 \u2192 \u03b2} (H : Injective f) {a : \u03b1} {l : List \u03b1} :\n  f a \u2208 map f l \u2194 a \u2208 l := by\n  aesop\n\n@[simp] theorem _root_.function.involutive.exists_mem_and_apply_eq_iff {f : \u03b1 \u2192 \u03b1}\n  (hf : Involutive f) (x : \u03b1) (l : List \u03b1) :\n  (\u2203 (y : \u03b1), y \u2208 l \u2227 f y = x) \u2194 f x \u2208 l := by\n  aesop\n\ntheorem mem_map_of_involutive {f : \u03b1 \u2192 \u03b1} (hf : Involutive f) {a : \u03b1} {l : List \u03b1} :\n  a \u2208 map f l \u2194 f a \u2208 l := by\n  aesop\n\n-- attribute [-simp] forall_mem_map_iff\ntheorem X.forall_mem_map_iff {f : \u03b1 \u2192 \u03b2} {l : List \u03b1} {P : \u03b2 \u2192 Prop} :\n  (\u2200 i, i \u2208 l.map f \u2192 P i) \u2194 \u2200 j, j \u2208 l \u2192 P (f j) := by\n  aesop\n\nattribute [-simp] map_eq_nil\n@[simp] theorem X.map_eq_nil {f : \u03b1 \u2192 \u03b2} {l : List \u03b1} : map f l = [] \u2194 l = [] := by\n  aesop (add 1% cases List)\n\n-- attribute [-simp] mem_join\n@[simp] theorem X.mem_join {a : \u03b1} : \u2200 {L : List (List \u03b1)}, a \u2208 join L \u2194 \u2203 l, l \u2208 L \u2227 a \u2208 l := by\n  intro L; induction L <;> aesop\n\n-- attribute [-simp] exists_of_mem_join\ntheorem X.exists_of_mem_join {a : \u03b1} {L : List (List \u03b1)} : a \u2208 join L \u2192 \u2203 l, l \u2208 L \u2227 a \u2208 l := by\n  aesop\n\n-- attribute [-simp] mem_join_of_mem\ntheorem X.mem_join_of_mem {a : \u03b1} {L : List (List \u03b1)} {l} (lL : l \u2208 L) (al : a \u2208 l) : a \u2208 join L := by\n  aesop\n\n-- attribute [-simp] mem_bind\n@[simp] theorem X.mem_bind {b : \u03b2} {l : List \u03b1} {f : \u03b1 \u2192 List \u03b2} : b \u2208 l.bind f \u2194 \u2203 a, a \u2208 l \u2227 b \u2208 f a := by\n  induction l <;> aesop\n\n-- attribute [-simp] exists_of_mem_bind\ntheorem X.exists_of_mem_bind {l : List \u03b1} :\n    b \u2208 l.bind f \u2192 \u2203 a, a \u2208 l \u2227 b \u2208 f a := by\n  aesop\n\n-- attribute [-simp] mem_bind_of_mem\ntheorem X.mem_bind_of_mem {l : List \u03b1} :\n    (\u2203 a, a \u2208 l \u2227 b \u2208 f a) \u2192 b \u2208 l.bind f := by\n  induction l <;> aesop\n\n-- attribute [-simp] bind_map\ntheorem X.bind_map {g : \u03b1 \u2192 List \u03b2} {f : \u03b2 \u2192 \u03b3} :\n  \u2200 l : List \u03b1, map f (l.bind g) = l.bind (\u03bba => (g a).map f) := by\n  intro l; induction l <;> aesop\n\ntheorem map_bind (g : \u03b2 \u2192 List \u03b3) (f : \u03b1 \u2192 \u03b2) :\n  \u2200 l : List \u03b1, (map f l).bind g = l.bind (\u03bb a => g (f a)) := by\n  intro l; induction l <;> aesop\n\n-- theorem range_map (f : \u03b1 \u2192 \u03b2) : set.range (map f) = {l | \u2200 x \u2208 l, x \u2208 set.range f} :=\n\n-- theorem range_map_coe (s : set \u03b1) : set.range (map (coe : s \u2192 \u03b1)) = {l | \u2200 x \u2208 l, x \u2208 s} :=\n\n-- instance [h : can_lift \u03b1 \u03b2] : can_lift (list \u03b1) (list \u03b2) :=\n\n/-! ### length -/\n\n-- attribute [-simp] length_eq_zero\ntheorem X.length_eq_zero {l : List \u03b1} : length l = 0 \u2194 l = [] := by\n  aesop (add 1% cases List)\n\nattribute [-simp] length_singleton\n@[simp] theorem X.length_singleton (a : \u03b1) : length [a] = 1 := rfl\n\n-- attribute [-simp] length_pos_of_mem\ntheorem X.length_pos_of_mem {a : \u03b1} : \u2200 {l : List \u03b1}, a \u2208 l \u2192 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 : \u2200 {l : List \u03b1}, 0 < length l \u2192 \u2203 a, a \u2208 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 \u03b1} : 0 < length l \u2194 \u2203 a, a \u2208 l := by\n  aesop (add unsafe [length_pos_of_mem, exists_mem_of_length_pos])\n\ntheorem ne_nil_of_length_pos {l : List \u03b1} : 0 < length l \u2192 l \u2260 [] := by\n  aesop (add 1% cases List)\n\ntheorem length_pos_of_ne_nil {l : List \u03b1} : l \u2260 [] \u2192 0 < length l := by\n  aesop (add 1% cases List) (simp_options := { arith := true })\n\ntheorem length_pos_iff_ne_nil {l : List \u03b1} : 0 < length l \u2194 l \u2260 [] := 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 \u03b1) (h : l \u2260 []) : \u2203 x, x \u2208 l := by\n  aesop (add 1% cases List)\n\n-- attribute [-simp] length_eq_one\ntheorem X.length_eq_one : length l = 1 \u2194 \u2203 a, l = [a] := by\n  aesop (add 1% cases List)\n\ntheorem exists_of_length_succ {n} :\n  \u2200 l : List \u03b1, l.length = n + 1 \u2192 \u2203 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 \u03b1 \u2192 Nat) \u2194 Subsingleton \u03b1 :=\n  ADMIT -- Requires induction after case split.\n\n@[simp] theorem length_injective [Subsingleton \u03b1] : Injective (length : List \u03b1 \u2192 Nat) := by\n  aesop\n\ntheorem length_eq_two {l : List \u03b1} : l.length = 2 \u2194 \u2203 a b, l = [a, b] := by\n  aesop (add 50% cases List)\n\ntheorem length_eq_three {l : List \u03b1} : l.length = 3 \u2194 \u2203 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 : (\u2205 : List \u03b1) = [] := rfl\n\n-- theorem singleton_eq (x : \u03b1) : ({x} : List \u03b1) = [x]\n\n-- theorem insert_neg [DecidableEq \u03b1] {x : \u03b1} {l : List \u03b1} (h : x \u2209 l) :\n--   has_insert.insert x l = x :: l\n\n-- theorem insert_pos [DecidableEq \u03b1] {x : \u03b1} {l : List \u03b1} (h : x \u2208 l) :\n--   has_insert.insert x l = l\n\n-- theorem doubleton_eq [DecidableEq \u03b1] {x y : \u03b1} (h : x \u2260 y) : ({x, y} : List \u03b1) = [x, y]\n\n/-! ### bounded quantifiers over lists -/\n\n-- The notation used in Lean 3 (`\u2200 x \u2208 xs, P x` and `\u2203 x \u2208 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 : \u03b1 \u2192 Prop) : \u2200 x, x \u2208 @nil \u03b1 \u2192 p x := by\n  aesop\n\n-- attribute [-simp] forall_mem_cons\ntheorem X.forall_mem_cons : \u2200 {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1},\n    (\u2200 x, x \u2208 a :: l \u2192 p x) \u2194 p a \u2227 \u2200 x, x \u2208 l \u2192 p x := by\n  aesop\n\ntheorem forall_mem_of_forall_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1}\n    (h : \u2200 x, x \u2208 a :: l \u2192 p x) :\n  \u2200 x, x \u2208 l \u2192 p x := by\n  aesop\n\n-- attribute [-simp] forall_mem_singleton\ntheorem X.forall_mem_singleton {p : \u03b1 \u2192 Prop} {a : \u03b1} : (\u2200 x, x \u2208 [a] \u2192 p x) \u2194 p a := by\n  aesop\n\n-- attribute [-simp] forall_mem_append\ntheorem X.forall_mem_append {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : List \u03b1} :\n    (\u2200 x, x \u2208 l\u2081 ++ l\u2082 \u2192 p x) \u2194 (\u2200 x, x \u2208 l\u2081 \u2192 p x) \u2227 (\u2200 x, x \u2208 l\u2082 \u2192 p x) := by\n  aesop\n\ntheorem not_exists_mem_nil (p : \u03b1 \u2192 Prop) : \u00ac \u2203 x, x \u2208 @nil \u03b1 \u2227 p x := by\n  aesop\n\ntheorem exists_mem_cons_of {p : \u03b1 \u2192 Prop} {a : \u03b1} (l : List \u03b1) (h : p a) :\n    \u2203 x, x \u2208 a :: l \u2227 p x := by\n  aesop\n\ntheorem exists_mem_cons_of_exists {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1} (h : \u2203 x, x \u2208 l \u2227 p x) :\n  \u2203 x, x \u2208 a :: l \u2227 p x := by\n  aesop\n\ntheorem or_exists_of_exists_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1} (h : \u2203 x, x \u2208 a :: l \u2227 p x) :\n  p a \u2228 \u2203 x, x \u2208 l \u2227 p x := by\n  aesop\n\ntheorem exists_mem_cons_iff (p : \u03b1 \u2192 Prop) (a : \u03b1) (l : List \u03b1) :\n  (\u2203 x, x \u2208 a :: l \u2227 p x) \u2194 p a \u2228 \u2203 x, x \u2208 l \u2227 p x := by\n  aesop\n\n/-! ### list subset -/\n\n-- attribute [-simp] subset_def\ntheorem X.subset_def {l\u2081 l\u2082 : List \u03b1} : l\u2081 \u2286 l\u2082 \u2194 \u2200 \u2983a : \u03b1\u2984, a \u2208 l\u2081 \u2192 a \u2208 l\u2082 := by\n  aesop\n\n-- attribute [-simp] subset_append_of_subset_left\ntheorem X.subset_append_of_subset_left (l l\u2081 l\u2082 : List \u03b1) : l \u2286 l\u2081 \u2192 l \u2286 l\u2081++l\u2082 := 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\u2081 l\u2082 : List \u03b1) : l \u2286 l\u2082 \u2192 l \u2286 l\u2081 ++ l\u2082 := by\n  aesop (add 1% subset_trans)\n\nattribute [-simp] cons_subset\n@[simp] theorem X.cons_subset {a : \u03b1} {l m : List \u03b1} :\n  a::l \u2286 m \u2194 a \u2208 m \u2227 l \u2286 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 : \u03b1} {l m : List \u03b1}\n    (ainm : a \u2208 m) (lsubm : l \u2286 m) : a::l \u2286 m := by\n  aesop\n\ntheorem append_subset_of_subset_of_subset {l\u2081 l\u2082 l : List \u03b1} (l\u2081subl : l\u2081 \u2286 l) (l\u2082subl : l\u2082 \u2286 l) :\n  l\u2081 ++ l\u2082 \u2286 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\u2081 l\u2082 l : List \u03b1} :\n    l\u2081 ++ l\u2082 \u2286 l \u2194 l\u2081 \u2286 l \u2227 l\u2082 \u2286 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 \u03b1} : l \u2286 [] \u2192 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 \u03b1} : l = [] \u2194 \u2200 a, a \u2209 l := by\n  aesop (add 1% cases List)\n\n-- attribute [-simp] map_subset\ntheorem X.map_subset {l\u2081 l\u2082 : List \u03b1} (f : \u03b1 \u2192 \u03b2) (H : l\u2081 \u2286 l\u2082) : map f l\u2081 \u2286 map f l\u2082 := 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\u2081 l\u2082 : List \u03b1} (f : \u03b1 \u2192 \u03b2) (h : Injective f) :\n    map f l\u2081 \u2286 map f l\u2082 \u2194 l\u2081 \u2286 l\u2082 := by\n  induction l\u2081 <;> induction l\u2082 <;> aesop\n\n/-! ### append -/\n\ntheorem append_eq_has_append {L\u2081 L\u2082 : List \u03b1} : List.append L\u2081 L\u2082 = L\u2081 ++ L\u2082 := rfl\n\nattribute [-simp] singleton_append\n@[simp] theorem X.singleton_append {x : \u03b1} {l : List \u03b1} : [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 \u03b1) : s \u2260 [] \u2192 s ++ t \u2260 [] := 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 \u03b1) : t \u2260 [] \u2192 s ++ t \u2260 [] := by\n  induction s <;> aesop\n\nattribute [-simp] append_eq_nil\n@[simp] theorem X.append_eq_nil {p q : List \u03b1} : (p ++ q) = [] \u2194 p = [] \u2227 q = [] := by\n  aesop (add 1% cases List)\n\n@[simp] theorem nil_eq_append_iff {a b : List \u03b1} : [] = a ++ b \u2194 a = [] \u2227 b = [] := by\n  induction a <;> aesop\n\ntheorem append_eq_cons_iff {a b c : List \u03b1} {x : \u03b1} :\n  a ++ b = x :: c \u2194 (a = [] \u2227 b = x :: c) \u2228 (\u2203a', a = x :: a' \u2227 c = a' ++ b) := by\n  aesop (add 1% cases List)\n\ntheorem cons_eq_append_iff {a b c : List \u03b1} {x : \u03b1} :\n    (x :: c : List \u03b1) = a ++ b \u2194 (a = [] \u2227 b = x :: c) \u2228 (\u2203a', a = x :: a' \u2227 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 \u03b1} :\n    a ++ b = c ++ d \u2194 (\u2203a', c = a ++ a' \u2227 b = a' ++ d) \u2228 (\u2203c', a = c ++ c' \u2227 d = c' ++ b) :=\n  ADMIT -- Nontrivial existential.\n\nattribute [-simp] take_append_drop\n@[simp] theorem X.take_append_drop : \u2200 (n : Nat) (l : List \u03b1), 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  \u2200 {s\u2081 s\u2082 t\u2081 t\u2082 : List \u03b1}, s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082 \u2192 length s\u2081 = length s\u2082 \u2192 s\u2081 = s\u2082 \u2227 t\u2081 = t\u2082\n  | []     , []     , t\u2081, t\u2082, h, _  => by aesop\n  | (a::s\u2081), []     , t\u2081, t\u2082, _, hl => by aesop\n  | []     , (b::s\u2082), t\u2081, t\u2082, _, hl => by aesop\n  | (a::s\u2081), (b::s\u2082), t\u2081, t\u2082, h, hl => by\n    have ih := @append_inj _ s\u2081 s\u2082 t\u2081 t\u2082\n    aesop\n\n-- attribute [-simp] append_inj_right\ntheorem X.append_inj_right {s\u2081 s\u2082 t\u2081 t\u2082 : List \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082)\n    (hl : length s\u2081 = length s\u2082) : t\u2081 = t\u2082 := by\n  aesop\n\n-- attribute [-simp] append_inj_left\ntheorem X.append_inj_left {s\u2081 s\u2082 t\u2081 t\u2082 : List \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082)\n    (hl : length s\u2081 = length s\u2082) : s\u2081 = s\u2082 := by\n  aesop\n\n-- attribute [-simp] append_inj'\nset_option linter.unusedVariables false in\n@[aesop safe forward]\ntheorem X.append_inj' {s\u2081 s\u2082 t\u2081 t\u2082 : List \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082) (hl : length t\u2081 = length t\u2082) :\n  s\u2081 = s\u2082 \u2227 t\u2081 = t\u2082 := by\n  induction s\u2081 generalizing s\u2082 <;> induction s\u2082 <;>\n    aesop (simp_options := { arith := true })\n\n-- attribute [-simp] append_inj_right'\ntheorem X.append_inj_right' {s\u2081 s\u2082 t\u2081 t\u2082 : List \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082)\n    (hl : length t\u2081 = length t\u2082) : t\u2081 = t\u2082 := by\n  aesop\n\n-- attribute [-simp] append_inj_left'\ntheorem X.append_inj_left' {s\u2081 s\u2082 t\u2081 t\u2082 : List \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082)\n    (hl : length t\u2081 = length t\u2082) : s\u2081 = s\u2082 := by\n  aesop\n\ntheorem append_left_cancel {s t\u2081 t\u2082 : List \u03b1} (h : s ++ t\u2081 = s ++ t\u2082) : t\u2081 = t\u2082 := by\n  aesop\n\ntheorem append_right_cancel {s\u2081 s\u2082 t : List \u03b1} (h : s\u2081 ++ t = s\u2082 ++ t) : s\u2081 = s\u2082 := by\n  aesop\n\ntheorem append_right_injective (s : List \u03b1) : Injective (\u03bb t => s ++ t) := by\n  aesop\n\n-- attribute [-simp] append_right_inj\ntheorem X.append_right_inj {t\u2081 t\u2082 : List \u03b1} (s) : s ++ t\u2081 = s ++ t\u2082 \u2194 t\u2081 = t\u2082 := by\n  aesop\n\ntheorem append_left_injective (t : List \u03b1) : Injective (\u03bb s => s ++ t) := by\n  aesop\n\n-- attribute [-simp] append_left_inj\ntheorem X.append_left_inj {s\u2081 s\u2082 : List \u03b1} (t) : s\u2081 ++ t = s\u2082 ++ t \u2194 s\u2081 = s\u2082 := by\n  aesop\n\n-- attribute [-simp] map_eq_append_split\nset_option linter.unusedVariables false in\ntheorem X.map_eq_append_split {f : \u03b1 \u2192 \u03b2} {l : List \u03b1} {s\u2081 s\u2082 : List \u03b2}\n    (h : map f l = s\u2081 ++ s\u2082) : \u2203 l\u2081 l\u2082, l = l\u2081 ++ l\u2082 \u2227 map f l\u2081 = s\u2081 \u2227 map f l\u2082 = s\u2082 :=\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 : \u03b1) (n) : replicate (n + 1) a = a :: replicate n a := rfl\n\n-- attribute [-simp] mem_replicate\n@[simp] theorem X.mem_replicate {a b : \u03b1} {n} : b \u2208 replicate n a \u2194 n \u2260 0 \u2227 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 : \u03b1} {n} (h : b \u2208 replicate n a) : b = a := by\n  aesop\n\ntheorem eq_replicate_of_mem {a : \u03b1} {l : List \u03b1} : (\u2200 b, b \u2208 l \u2192 b = a) \u2192 l = replicate l.length a := by\n  induction l <;> aesop (simp_options := { useHyps := false })\n\ntheorem eq_replicate' {a : \u03b1} {l : List \u03b1} : l = replicate l.length a \u2194 \u2200 b, b \u2208 l \u2192 b = a := by\n  induction l <;> aesop\n\ntheorem eq_replicate {a : \u03b1} {n} {l : List \u03b1} : l = replicate n a \u2194 length l = n \u2227 \u2200 b, b \u2208 l \u2192 b = a := by\n  set_option aesop.check.script false in -- TODO\n  aesop (add norm simp eq_replicate')\n\ntheorem replicate_add (a : \u03b1) (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 : \u03b1) (n) : replicate n a \u2286 [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 : \u03b1} {L : List \u03b1} : L \u2286 [a] \u2194 \u2203 n, L = replicate n a :=\n  ADMIT -- Nontrivial existential.\n\n@[simp] theorem map_const (l : List \u03b1) (b : \u03b2) : map (\u03bb _ => b) l = replicate l.length b := by\n  induction l <;> aesop\n\ntheorem eq_of_mem_map_const {b\u2081 b\u2082 : \u03b2} {l : List \u03b1} (h : b\u2081 \u2208 map (\u03bb _ => b\u2082) l) :\n  b\u2081 = b\u2082 := by\n  aesop\n\n@[simp] theorem map_replicate (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (n) : map f (replicate n a) = replicate n (f a) := by\n  induction n <;> aesop\n\n@[simp] theorem tail_replicate (a : \u03b1) (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 \u03b1 := by\n  induction n <;> aesop\n\ntheorem replicate_left_injective {n : Nat} (hn : n \u2260 0) :\n    Injective (\u03bb a : \u03b1 => replicate n a) := by\n  induction n <;> aesop\n\n@[simp] theorem replicate_left_inj' {a b : \u03b1} :\n  \u2200 {n}, replicate n a = replicate n b \u2194 n = 0 \u2228 a = b := by\n  intro n; induction n <;> aesop\n\ntheorem replicate_right_injective (a : \u03b1) : Injective (\u03bb 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 : \u03b1} {n m : Nat} :\n    replicate n a = replicate m a \u2194 n = m := by\n  induction n generalizing m <;> aesop (add 1% cases Nat)\n\n/-! ### pure -/\n\n@[simp]\ntheorem mem_pure {\u03b1} (x y : \u03b1) :\n    x \u2208 (pure y : List \u03b1) \u2194 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 {\u03b1 \u03b2} (f : \u03b1 \u2192 List \u03b2) (l : List \u03b1) :\n    l >>= f = l.bind f := rfl\n\ntheorem bind_append (f : \u03b1 \u2192 List \u03b2) (l\u2081 l\u2082 : List \u03b1) :\n  (l\u2081 ++ l\u2082).bind f = l\u2081.bind f ++ l\u2082.bind f := by\n  induction l\u2081 <;> aesop\n\n@[simp] theorem bind_singleton (f : \u03b1 \u2192 List \u03b2) (x : \u03b1) : [x].bind f = f x := by\n  aesop\n\n@[simp] theorem bind_singleton' (l : List \u03b1) : l.bind (\u03bb x => [x]) = l := by\n  induction l <;> aesop\n\ntheorem map_eq_bind {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (l : List \u03b1) : map f l = l.bind (\u03bb x => [f x]) := by\n  induction l <;> aesop\n\ntheorem bind_assoc {\u03b1 \u03b2 \u03b3 : Type u} (l : List \u03b1) (f : \u03b1 \u2192 List \u03b2) (g : \u03b2 \u2192 List \u03b3) :\n    (l.bind f).bind g = l.bind (\u03bb x => (f x).bind g) :=\n  ADMIT\n  -- have aux {\u03b4 : Type u} (xs ys : List (List \u03b4)) : 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 : \u03b1) : concat [] a = [a] := rfl\n\n@[simp] theorem concat_cons (a b : \u03b1) (l : List \u03b1) : concat (a :: l) b = a :: concat l b := rfl\n\nattribute [-simp] concat_eq_append\n@[simp] theorem X.concat_eq_append (a : \u03b1) (l : List \u03b1) : concat l a = l ++ [a] := by\n  induction l <;> aesop\n\ntheorem init_eq_of_concat_eq {a : \u03b1} {l\u2081 l\u2082 : List \u03b1} : concat l\u2081 a = concat l\u2082 a \u2192 l\u2081 = l\u2082 := by\n  aesop\n\ntheorem last_eq_of_concat_eq {a b : \u03b1} {l : List \u03b1} : concat l a = concat l b \u2192 a = b := by\n  aesop\n\ntheorem concat_ne_nil (a : \u03b1) (l : List \u03b1) : concat l a \u2260 [] := by\n  aesop\n\nattribute [simp] append_assoc\n\ntheorem concat_append (a : \u03b1) (l\u2081 l\u2082 : List \u03b1) : concat l\u2081 a ++ l\u2082 = l\u2081 ++ a :: l\u2082 := by\n  aesop\n\nattribute [-simp] length_concat\ntheorem X.length_concat (a : \u03b1) (l : List \u03b1) : length (concat l a) = .succ (length l) := by\n  aesop\n\ntheorem append_concat (a : \u03b1) (l\u2081 l\u2082 : List \u03b1) : l\u2081 ++ concat l\u2082 a = concat (l\u2081 ++ l\u2082) a := by\n  aesop\n\n/-! ### reverse -/\n\nattribute [-simp] reverse_nil\n@[simp] theorem X.reverse_nil : reverse (@nil \u03b1) = [] := rfl\n\nattribute [-simp] reverse_cons\n@[simp] theorem X.reverse_cons (a : \u03b1) (l : List \u03b1) : reverse (a::l) = reverse l ++ [a] :=\n  ADMIT\n  -- have aux : \u2200 l\u2081 l\u2082, reverseAux l\u2081 l\u2082 ++ [a] = reverseAux l\u2081 (l\u2082 ++ [a]) := by\n  --   intro l\u2081; induction l\u2081 <;> 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\u2081 l\u2082 : List \u03b1) : reverseAux l\u2081 l\u2082 = reverse l\u2081 ++ l\u2082 := by\n  induction l\u2081 generalizing l\u2082 <;> aesop\n\ntheorem reverse_cons' (a : \u03b1) (l : List \u03b1) : reverse (a::l) = concat (reverse l) a := by\n  aesop\n\n@[simp] theorem reverse_singleton (a : \u03b1) : reverse [a] = [a] := rfl\n\nattribute [-simp] reverse_append\n@[simp] theorem X.reverse_append (s t : List \u03b1) : reverse (s ++ t) = (reverse t) ++ (reverse s) := by\n  induction s <;> aesop\n\n-- attribute [-simp] reverse_concat\ntheorem X.reverse_concat (l : List \u03b1) (a : \u03b1) : reverse (concat l a) = a :: reverse l := by\n  aesop\n\nattribute [-simp] reverse_reverse\n@[simp] theorem X.reverse_reverse (l : List \u03b1) : reverse (reverse l) = l := by\n  induction l <;> aesop\n\n@[simp] theorem reverse_involutive : Involutive (@reverse \u03b1) := by\n  aesop\n\n@[simp] theorem reverse_injective {\u03b1 : Type u} : Injective (@reverse \u03b1) := by\n  aesop\n\n@[simp] theorem reverse_surjective {\u03b1 : Type u} : Surjective (@reverse \u03b1) := by\n  aesop\n\n@[simp] theorem reverse_bijective : Bijective (@reverse \u03b1) := by\n  aesop\n\n@[simp] theorem reverse_inj {l\u2081 l\u2082 : List \u03b1} : reverse l\u2081 = reverse l\u2082 \u2194 l\u2081 = l\u2082 := by\n  aesop (add safe forward reverse_injective)\n\ntheorem reverse_eq_iff {l l' : List \u03b1} :\n  l.reverse = l' \u2194 l = l'.reverse := by\n  aesop\n\n@[simp] theorem reverse_eq_nil {l : List \u03b1} : reverse l = [] \u2194 l = [] := by\n  aesop (add norm simp reverse_eq_iff)\n\ntheorem concat_eq_reverse_cons (a : \u03b1) (l : List \u03b1) : 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 \u03b1) : length (reverse l) = length l := by\n  induction l <;> aesop\n\ntheorem map_reverse (f : \u03b1 \u2192 \u03b2) (l : List \u03b1) : map f (reverse l) = reverse (map f l) := by\n  induction l <;> aesop\n\n-- attribute [-simp] map_reverseAux\ntheorem map_reverse_core (f : \u03b1 \u2192 \u03b2) (l\u2081 l\u2082 : List \u03b1) :\n  map f (reverseAux l\u2081 l\u2082) = reverseAux (map f l\u2081) (map f l\u2082) := by\n  aesop (add norm simp reverse_map)\n\nattribute [-simp] mem_reverse\n@[simp] theorem X.mem_reverse {a : \u03b1} {l : List \u03b1} : a \u2208 reverse l \u2194 a \u2208 l := by\n  induction l <;> aesop\n\n@[simp] theorem reverse_replicate (a : \u03b1) (n) : reverse (replicate n a) = replicate n a :=\n  ADMIT -- Several missing lemmas.\n\n/-! ### empty -/\n\ntheorem empty_iff_eq_nil {l : List \u03b1} : Empty l \u2194 l = [] := by\n  aesop\n\n/-! ### init -/\n\n@[simp] theorem length_init : \u2200 (l : List \u03b1), 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 : \u03b1} {l : List \u03b1} :\n  \u2200 (h : l \u2260 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 : \u03b1} (l : List \u03b1) :\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\u2081 l\u2082 : List \u03b1) (h : l\u2082 \u2260 []) :\n  last (l\u2081 ++ l\u2082) (append_ne_nil_of_ne_nil_right l\u2081 l\u2082 h) = last l\u2082 h := by\n  induction l\u2081 <;> aesop\n\ntheorem last_concat {a : \u03b1} (l : List \u03b1) : last (concat l a) (concat_ne_nil a l) = a := by\n  aesop\n\n@[simp] theorem last_singleton (a : \u03b1) : last [a] (cons_ne_nil a []) = a := rfl\n\n@[simp] theorem last_cons_cons (a\u2081 a\u2082 : \u03b1) (l : List \u03b1) :\n  last (a\u2081::a\u2082::l) (cons_ne_nil _ _) = last (a\u2082::l) (cons_ne_nil a\u2082 l) := rfl\n\ntheorem init_append_last : \u2200 {l : List \u03b1} (h : l \u2260 []), 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\u2081 l\u2082 : List \u03b1} (h\u2081 : l\u2081 \u2260 []) (h\u2082 : l\u2082 \u2260 []) (h\u2083 : l\u2081 = l\u2082) :\n  last l\u2081 h\u2081 = last l\u2082 h\u2082 := by\n  aesop\n\ntheorem last_mem : \u2200 {l : List \u03b1} (h : l \u2260 []), last l h \u2208 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  \u2200 {l : List \u03b1}, (last' l).isNone \u2194 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 : \u2200 {l : List \u03b1}, l.last'.isSome \u2194 l \u2260 []\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 : \u2200 {l : List \u03b1} {x : \u03b1}, x \u2208 l.last' \u2192 \u2203 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 : \u2200 {l : List \u03b1} (h : l \u2260 []), 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 : \u03b1} : \u2200 {l : List \u03b1} (_ : x \u2208 l.last'), x \u2208 (y :: l).last' := by\n  intro l; induction l <;> aesop\n\ntheorem mem_of_mem_last' {l : List \u03b1} {a : \u03b1} (ha : a \u2208 l.last') : a \u2208 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' : \u2200 {l : List \u03b1} {a}, a \u2208 l.last' \u2192 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 \u03b1] : \u2200 l : List \u03b1, 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 : \u2200 (l\u2081 : List \u03b1) (a : \u03b1) (l\u2082 : List \u03b1),\n  last' (l\u2081 ++ a :: l\u2082) = last' (a :: l\u2082)\n  | [], a, l\u2082 => by aesop\n  | [_], a, l\u2082 => by aesop\n  | _ :: c :: l\u2081, a, l\u2082 =>\n    have ih := last'_append_cons (c :: l\u2081) a\n    by aesop\n\n@[simp] theorem last'_cons_cons (x y : \u03b1) (l : List \u03b1) :\n  last' (x :: y :: l) = last' (y :: l) := rfl\n\ntheorem last'_append_of_ne_nil (l\u2081 : List \u03b1) : \u2200 {l\u2082 : List \u03b1} (_ : l\u2082 \u2260 []),\n  last' (l\u2081 ++ l\u2082) = last' l\u2082\n  | [], hl\u2082 => by aesop\n  | b :: l\u2082, _ => by aesop\n\ntheorem last'_append {l\u2081 l\u2082 : List \u03b1} {x : \u03b1} (h : x \u2208 l\u2082.last') :\n  x \u2208 (l\u2081 ++ l\u2082).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 \u03b1] (l : List \u03b1) : ihead l = (head' l).iget := by\n  aesop (add 1% cases List)\n\ntheorem mem_of_mem_head' {x : \u03b1} : \u2200 {l : List \u03b1}, x \u2208 l.head' \u2192 x \u2208 l := by\n  intro l; induction l <;> aesop\n\n-- attribute [-simp] head'_cons\n@[simp] theorem X.head'_cons [Inhabited \u03b1] (a : \u03b1) (l : List \u03b1) : head' (a::l) = a := rfl\n\nattribute [-simp] tail_nil\n@[simp] theorem X.tail_nil : tail (@nil \u03b1) = [] := rfl\n\nattribute [-simp] tail_cons\n@[simp] theorem X.tail_cons (a : \u03b1) (l : List \u03b1) : tail (a::l) = l := rfl\n\n-- attribute [-simp] ihead_append\n@[simp] theorem head_append [Inhabited \u03b1] (t : List \u03b1) {s : List \u03b1} (h : s \u2260 []) :\n  ihead (s ++ t) = ihead s := by\n  aesop (add 1% cases List)\n\ntheorem head'_append {s t : List \u03b1} {x : \u03b1} (h : x \u2208 s.head') :\n  x \u2208 (s ++ t).head' := by\n  aesop (add 1% cases List)\n\ntheorem head'_append_of_ne_nil : \u2200 (l\u2081 : List \u03b1) {l\u2082 : List \u03b1} (_ : l\u2081 \u2260 []),\n  head' (l\u2081 ++ l\u2082) = head' l\u2081 := by\n  aesop (add 1% cases List)\n\ntheorem tail_append_singleton_of_ne_nil {a : \u03b1} {l : List \u03b1} (h : l \u2260 nil) :\n  tail (l ++ [a]) = tail l ++ [a] := by\n  induction l <;> aesop\n\ntheorem cons_head'_tail : \u2200 {l : List \u03b1} {a : \u03b1} (_ : a \u2208 head' l), a :: tail l = l := by\n  aesop\n\n-- attribute [-simp] ihead_mem_head'\ntheorem head_mem_head' [Inhabited \u03b1] : \u2200 {l : List \u03b1} (_ : l \u2260 []), ihead l \u2208 head' l := by\n  aesop\n\n-- attribute [-simp] cons_ihead_tail\ntheorem cons_head_tail [Inhabited \u03b1] {l : List \u03b1} (h : l \u2260 []) : (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 {\u03b1 : Type u} [decidable_eq \u03b1]\n\nnamespace list\n\nvariables {\u03b2 : Type v} [add_monoid \u03b2] [partial_order \u03b2] \nvariables [contravariant_class \u03b2 \u03b2 (+) (<)]\nvariables [covariant_class \u03b2 \u03b2 (+) (<)]\nvariables [covariant_class \u03b2 \u03b2 (function.swap (+)) (\u2264)]\nvariables [covariant_class \u03b2 \u03b2 (function.swap (+)) (<)]\nvariables [covariant_class \u03b2 \u03b2 (+) (\u2264)]\nvariables [@decidable_rel \u03b2 (\u2264)]\n\nlemma sum_map_le_sum_map {l : list \u03b1} {f g : \u03b1 \u2192 \u03b2} (hfg : \u2200 x \u2208 l, f x \u2264 g x) : (l.map f).sum \u2264 (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 (\u03bb x hx, hfg _ (mem_cons_of_mem _ hx))) }\nend\n\nlemma sum_map_lt_sum_map (l : list \u03b1) (f g : \u03b1 \u2192 \u03b2) (hfg : \u2200 x \u2208 l, f x \u2264 g x) :\n  (l.map f).sum < (l.map g).sum \u2194 \u2203 x \u2208 l, f x < g x :=\nbegin\n  refine \u27e8_, _\u27e9,\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 \u03bb _, \u27e8a, \u27e8mem_cons_self _ _, h\u27e9\u27e9 },\n      { have hfa : f a = g a := decidable.eq_iff_le_not_lt.2 \u27e8hfg _ (mem_cons_self _ _), h\u27e9,\n        simp only [list.map_cons, list.sum_cons, hfa, add_lt_add_iff_left],\n        intro h',\n        obtain \u27e8x, \u27e8hx, hx'\u27e9\u27e9 := ih (\u03bb x hx, hfg _ (mem_cons_of_mem _ hx)) h',\n        exact \u27e8x, \u27e8mem_cons_of_mem _ hx, hx'\u27e9\u27e9 } } },\n  { rintro \u27e8x, \u27e8hx, hx'\u27e9\u27e9,\n    obtain \u27e8s, t, rfl\u27e9 := 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 (\u03bb x hx, hfg _ (mem_append_left _ hx))) _,\n    exact add_lt_add_of_lt_of_le hx' (sum_map_le_sum_map (\u03bb 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 \u03b1) (c : clause \u03b1) : clause \u03b1 :=\nc.filter $ (\u2260) l.inverse\n\ndef unit_propagate' (l : literal \u03b1) (c : clause \u03b1) : option (clause \u03b1) :=\nif l \u2208 c then none else some (unit_propagate l c)\n\nlemma unit_propagate'_of_mem {l : literal \u03b1} {c : clause \u03b1} (h : l \u2208 c) : unit_propagate' l c = none :=\nby simp only [unit_propagate', h, if_true]\n\nlemma unit_propagate'_of_not_mem {l : literal \u03b1} {c : clause \u03b1} (h : l \u2209 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 \u03b1) (c d : clause \u03b1) :\n  unit_propagate' l c = some d \u2194 l \u2209 c \u2227 unit_propagate l c = d :=\nby by_cases h : l \u2208 c; simp [unit_propagate', h]\n\n@[simp]\ndef satisfied' (\u03b9 : interpretation \u03b1) : option (clause \u03b1) \u2192 Prop\n| none := tt\n| (some c) := satisfied \u03b9 c\n\n@[simp]\ndef length' : option (clause \u03b1) \u2192 \u2115\n| none := 0\n| (some c) := c.length\n\nlemma length'_comp_some : (length' : option (clause \u03b1) \u2192 \u2115) \u2218 some = list.length :=\nrfl\n\nlemma length_unit_propagate {l : literal \u03b1} {c : clause \u03b1} (hl : l.inverse \u2208 c) :\n  (unit_propagate l c).length < c.length :=\n(list.length_filter_lt_length_iff_exists _ _).2 \u27e8_, hl, \u03bb h, h rfl\u27e9\n\nlemma length'_unit_propagate'_of_mem {l : literal \u03b1} {c : clause \u03b1} (hl : l \u2208 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 \u03b1} {c : clause \u03b1} (hl : l.inverse \u2208 c) : length' (unit_propagate' l c) < c.length :=\nbegin\n  by_cases h : l \u2208 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 \u03b1) (c : clause \u03b1) : (unit_propagate l c).length \u2264 c.length :=\nlist.length_le_of_sublist $ list.filter_sublist c\n\nlemma length'_unit_propagate'_le (l : literal \u03b1) (c : clause \u03b1) : length' (unit_propagate' l c) \u2264 c.length :=\nbegin\n  by_cases h : l \u2208 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 \u03b1} {c : clause \u03b1} {m : literal \u03b1} :\n  m \u2208 unit_propagate l c \u2194 m \u2208 c \u2227 l.inverse \u2260 m :=\nby rw [unit_propagate, list.mem_filter]\n\nlemma satisfied_unit_propagate (l : literal \u03b1) (c : clause \u03b1) (\u03b9 : interpretation \u03b1)\n  (hl : literal.satisfied \u03b9 l) : satisfied \u03b9 (unit_propagate l c) \u2194 satisfied \u03b9 c :=\nbegin\n  simp only [satisfied],\n  refine \u27e8_, _\u27e9,\n  { rintro \u27e8m, \u27e8hmem, hm\u27e9\u27e9,\n    rw [mem_unit_propagate] at hmem,\n    exact \u27e8m, \u27e8hmem.1, hm\u27e9\u27e9 },\n  { rintro \u27e8m, \u27e8hmem, hm\u27e9\u27e9,\n    refine \u27e8m, \u27e8_, hm\u27e9\u27e9,\n    { rw mem_unit_propagate,\n      refine \u27e8hmem, _\u27e9,\n      symmetry,\n      apply literal.not_satisfied_and_satisfied_inverse _ _ _ hm hl } }\nend\n\nlemma satisfied'_unit_propagate' (l : literal \u03b1) (c : clause \u03b1) (\u03b9 : interpretation \u03b1)\n  (hl : literal.satisfied \u03b9 l) : satisfied' \u03b9 (unit_propagate' l c) \u2194 satisfied \u03b9 c :=\nbegin\n  by_cases h : l \u2208 c,\n  { rw [unit_propagate'_of_mem h, satisfied', satisfied, coe_sort_tt, true_iff],\n    exact \u27e8_, h, hl\u27e9 },\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 \u03b1) (c : cnf \u03b1) : cnf \u03b1 :=\nc.filter_map $ clause.unit_propagate' l\n\nlemma unit_propagate_cons (l : literal \u03b1) (\u03b3 : clause \u03b1) (c : cnf \u03b1) :\n  unit_propagate l (\u03b3 :: c) = if l \u2208 \u03b3 then unit_propagate l c else (clause.unit_propagate l \u03b3) :: unit_propagate l c :=\nbegin\n  by_cases h : l \u2208 \u03b3,\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 \u03b1) (c : cnf \u03b1) :\n  sizeof (unit_propagate l c) = (c.map (clause.length' \u2218 clause.unit_propagate' l)).sum :=\nbegin\n  induction c with \u03b3 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 \u2208 \u03b3,\n    { simp only [h, clause.unit_propagate'_of_mem h, \u2190ih, sizeof_eq_size, size, if_true, clause.length', zero_add] },\n    { simp only [h, clause.unit_propagate'_of_not_mem h, \u2190ih, sizeof_eq_size, size, list.sum_cons, clause.length',\n      if_false, list.map] } }\nend\n\nlemma sizeof_cnf (c : cnf \u03b1) : sizeof c = (c.map (clause.length' \u2218 some)).sum :=\nby rw [clause.length'_comp_some, sizeof_eq_size, size]\n\nlemma sizeof_unit_propagate_of_mem {l : literal \u03b1} {\u03b3 : clause \u03b1} {c : cnf \u03b1} (hl\u03b3 : l \u2208 \u03b3 \u2228 l.inverse \u2208 \u03b3) (h\u03b3c: \u03b3 \u2208 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\u03b3,\n    { exact \u27e8\u03b3, h\u03b3c, clause.length'_unit_propagate'_of_mem hl\u03b3\u27e9 },\n    { exact \u27e8\u03b3, h\u03b3c, clause.length'_unit_propagate' hl\u03b3\u27e9 } },\n  { exact \u03bb _ _, clause.length'_unit_propagate'_le _ _ }\nend\n\nlemma mem_unit_propagate (l : literal \u03b1) (c : cnf \u03b1) (\u03b3 : clause \u03b1) :\n  \u03b3 \u2208 unit_propagate l c \u2194 \u2203 \u03b4, (\u03b4 \u2208 c \u2227 l \u2209 \u03b4) \u2227 clause.unit_propagate l \u03b4 = \u03b3 :=\nby simp only [unit_propagate, clause.unit_propagate'_eq_some, and.assoc, list.mem_filter_map]\n\nlemma non_mem_unit_propagate {l : literal \u03b1} {c : cnf \u03b1} {\u03b3 : clause \u03b1} (h\u03b3 : \u03b3 \u2208 unit_propagate l c) : l \u2209 \u03b3 :=\nbegin\n  obtain \u27e8\u03b4, \u27e8\u27e8h\u03b4c, hl\u03b4\u27e9, rfl\u27e9\u27e9 := (mem_unit_propagate l c \u03b3).1 h\u03b3,\n  exact \u03bb hl, hl\u03b4 (clause.mem_unit_propagate.1 hl).1\nend\n\nlemma inverse_non_mem_unit_propagate {l : literal \u03b1} {c : cnf \u03b1} {\u03b3 : clause \u03b1} (h\u03b3 : \u03b3 \u2208 unit_propagate l c) :\n  l.inverse \u2209 \u03b3 :=\nbegin\n  obtain \u27e8\u03b4, \u27e8\u27e8h\u03b4c, hl\u03b4\u27e9, rfl\u27e9\u27e9 := (mem_unit_propagate l c \u03b3).1 h\u03b3,\n  exact \u03bb hl, (clause.mem_unit_propagate.1 hl).2 rfl\nend\n\nlemma satisfied_unit_propagate (l : literal \u03b1) {c : cnf \u03b1} {\u03b9 : interpretation \u03b1}\n  (hl : literal.satisfied \u03b9 l) : satisfied \u03b9 (unit_propagate l c) \u2194 satisfied \u03b9 c :=\nbegin\n  simp only [satisfied],\n  refine \u27e8\u03bb h \u03b3 h\u03b3, _, \u03bb h \u03b3 h\u03b3, _\u27e9,\n  { by_cases hl\u03b3 : l \u2208 \u03b3,\n    { rw clause.satisfied,\n      exact \u27e8l, hl\u03b3, hl\u27e9 },\n    { rw \u2190clause.satisfied_unit_propagate l _ _ hl,\n      apply h,\n      rw mem_unit_propagate,\n      exact \u27e8\u03b3, \u27e8h\u03b3, hl\u03b3\u27e9, rfl\u27e9 } },\n  { rw mem_unit_propagate at h\u03b3,\n    rcases h\u03b3 with \u27e8\u03b4, \u27e8h\u03b4, -\u27e9, rfl\u27e9, \n    rw clause.satisfied_unit_propagate _ _ _ hl,\n    exact h _ h\u03b4 }\nend\n\nlemma satisfiable_of_satisfiable_unit_propagate {l : literal \u03b1} {c : cnf \u03b1} (h : satisfiable (unit_propagate l c)) :\n  satisfiable c :=\nbegin\n  rcases h with \u27e8\u03b9, h\u03b9\u27e9,\n  by_cases h : literal.satisfied \u03b9 l,\n  { exact \u27e8\u03b9, (satisfied_unit_propagate _ h).1 h\u03b9\u27e9 },\n  { refine \u27e8\u03b9.flip l, (satisfied_unit_propagate l _).1 ((satisfied_iff _ \u03b9 (\u03bb \u03b3 h\u03b3 m hm, _)).2 h\u03b9)\u27e9,\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\u03b3 hm, inverse_non_mem_unit_propagate h\u03b3 hm] } }\nend\n\ndef any_literal : \u03a0 (c : clause \u03b1) (hc : c \u2260 []), literal \u03b1\n| [] hc := false.elim (hc rfl)\n| (l::lc) hc := l\n\nlemma any_literal_mem : \u2200 {c : clause \u03b1} (hc : c \u2260 []), any_literal c hc \u2208 c\n| [] hc := false.elim (hc rfl)\n| (l::lc) hc := list.mem_cons_self _ _\n\ndef dpll : cnf \u03b1 \u2192 bool\n| [] := tt\n| (x::xs) := if h : [] \u2208 x::xs then ff else\n    have hx : x \u2260 [], from \u03bb 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 : \u2200 (c : cnf \u03b1), dpll c \u2194 satisfiable c\n| [] := by simp only [dpll, satisfiable_empty, coe_sort_tt]\n| (x::xs) := if h : [] \u2208 x::xs then by simpa [dpll, h] using not_satisfiable_of_empty_mem h else\n    have hx : x \u2260 [], from \u03bb 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 \u27e8_, _\u27e9,\n      { rintro (hr|hr),\n        { apply satisfiable_of_satisfiable_unit_propagate hr },\n        { apply satisfiable_of_satisfiable_unit_propagate hr } },\n      { rintro \u27e8\u03b9, h\u03b9\u27e9,\n        by_cases hl\u03b9 : literal.satisfied \u03b9 (any_literal x hx),\n        { exact or.inl \u27e8\u03b9, (satisfied_unit_propagate _ hl\u03b9).2 h\u03b9\u27e9 },\n        { refine or.inr \u27e8\u03b9, (satisfied_unit_propagate _ _).2 h\u03b9\u27e9,\n          simpa only [literal.satisfied_inverse] using hl\u03b9 } }\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 \u03b2 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 \u03b2\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 \u2227 \u03b2.reduced value)\n\ninstance (et: encoding_type): has_equiv (encoded_data et) := \u27e8 \u03bb a b : encoded_data et, a.value = b.value \u27e9\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) \u2115 :=\n \u27e8 \u03bb prog data cost, distance_le cost prog.value data.value,\n   \u03bb prog data, \u27e8 prog.value\u00b7data.value, by simp [closed, prog.proof, data.proof.left] \u27e9,\n   \u03bb 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   \u03bb prog data c\u2080 c\u2081, distance_le_mono' \u27e9\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  \u2200 n, a.value.closed_below n :=\n  \u03bb n, closed_below_mono' a.proof (nat.zero_le _)\n\n@[simp] theorem program_ignores_shift (a: encoded_program) (n: \u2115):\n  a.value \u2191\u00b9 n = a.value := by rw [shift_of_closed a.proof]\n\n@[simp] theorem program_ignores_substitution (a: encoded_program) (n: \u2115) (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  \u2200 n, a.value.closed_below n :=\n  \u03bb n, closed_below_mono' a.proof.left (nat.zero_le _)\n\n@[simp] theorem data_is_closed_below' {\u03b1: Type}\n  [f: complexity.has_encoding (distance_model et) \u03b1]\n  (a: \u03b1) : \u2200 n, (f.value.encode a).value.closed_below n :=\n  \u03bb 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' {\u03b1: Type}\n  [f: complexity.has_encoding (distance_model et) \u03b1]\n  (a: \u03b1) : 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 \u2248 b \u2194 a.value = b.value := by refl\n\n@[simp] theorem data_value_inj {\u03b1: Type}\n  [f: complexity.has_encoding (distance_model et) \u03b1] (a b: \u03b1):\n  (f.value.encode a).value = (f.value.encode b).value \u2194 a = b :=\nby rw [\u2190 value_inj, complexity.encoding.inj_iff]\n\n@[simp] theorem data_ignores_shift (a: encoded_data et) (n: \u2115):\n  a.value \u2191\u00b9 n = a.value := by rw [shift_of_closed a.proof.left]\n\n@[simp] theorem data_ignores_substitution (a: encoded_data et) (n: \u2115) (g: utlc):\n  has_substitution.substitution a.value n g = a.value := by rw [substitution_of_closed a.proof.left]\n\nend encoding\nend \u03b2\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 \u27f6 S) (p : prime_spectrum R)\n\n/--\nFor an algebra `f : R \u2192+* S`, this is the ring homomorphism `S \u2192+* (f\u2217 \ud835\udcaa\u209b)\u209a` 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 \u27f6 (Spec.Top_map f _* (structure_sheaf S).1).stalk p :=\nstructure_sheaf.to_open S \u22a4 \u226b\n  @Top.presheaf.germ _ _ _ _ (Spec.Top_map f _* (structure_sheaf S).1) \u22a4 \u27e8p, trivial\u27e9\n\n@[reassoc]\nlemma to_pushforward_stalk_comp :\n  f \u226b structure_sheaf.to_pushforward_stalk f p =\n  structure_sheaf.to_stalk R p \u226b\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_\u0393_naturality_assoc f _,\nend\n\ninstance : algebra R ((Spec.Top_map f _* (structure_sheaf S).1).stalk p) :=\n(f \u226b 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 \u226b 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 \u27f6 (f\u2217 \ud835\udcaa\u209b)\u209a` for some\nalgebra `R \u27f6 S` and some `p : Spec R`.\n-/\n@[simps]\ndef to_pushforward_stalk_alg_hom :\n  S \u2192\u2090[R] (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).stalk p :=\n{ commutes' := \u03bb _, 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  \u2203 (x : S \u00d7 p.as_ideal.prime_compl), x.2 \u2022 y = to_pushforward_stalk_alg_hom R S p x.1 :=\nbegin\n  obtain \u27e8U, hp, s, e\u27e9 := Top.presheaf.germ_exist _ _ y,\n  obtain \u27e8_, \u27e8r, rfl\u27e9, hpr, hrU\u27e9 := prime_spectrum.is_topological_basis_basic_opens\n    .exists_subset_of_mem_open (show p \u2208 U.1, from hp) U.2,\n  change prime_spectrum.basic_open r \u2264 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) \u27e8p, hpr\u27e9 _).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 \u2190 h at e,\n  clear_value s', clear_dependent U,\n  obtain \u27e8\u27e8s, \u27e8_, n, rfl\u27e9\u27e9, hsn\u27e9 := @is_localization.surj _ _ _\n    _ _ _ (structure_sheaf.is_localization.to_basic_open S $ algebra_map R S r) s',\n  refine \u27e8\u27e8s, \u27e8r, hpr\u27e9 ^ n\u27e9, _\u27e9,\n  rw [submonoid.smul_def, algebra.smul_def, algebra_map_pushforward_stalk, to_pushforward_stalk,\n    comp_apply, comp_apply],\n  iterate 2 { erw \u2190 (Spec.Top_map (algebra_map R S) _* (structure_sheaf S).1).germ_res_apply\n    (hom_of_le le_top) \u27e8p, hpr\u27e9 },\n  rw [\u2190 e, \u2190 map_mul, mul_comm],\n  dsimp only [subtype.coe_mk] at hsn,\n  rw \u2190 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) \u27e8x, hx\u27e9).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      \u2190 (to_pushforward_stalk (algebra_map R S) p).map_zero, to_pushforward_stalk, comp_apply,\n      comp_apply, map_zero] at hx,\n    obtain \u27e8U, hpU, i\u2081, i\u2082, e\u27e9 := Top.presheaf.germ_eq _ _ _ _ _ _ hx,\n    obtain \u27e8_, \u27e8r, rfl\u27e9, hpr, hrU\u27e9 := prime_spectrum.is_topological_basis_basic_opens\n      .exists_subset_of_mem_open (show p \u2208 U.1, from hpU) U.2,\n    change prime_spectrum.basic_open r \u2264 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, \u2190 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 \u27e8\u27e8_, n, rfl\u27e9, e\u27e9 := (is_localization.mk'_eq_zero_iff _ _).mp this,\n    refine \u27e8\u27e8r, hpr\u27e9 ^ n, _\u27e9,\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 \u03bb x hx, H.1 \u27e8x, hx\u27e9 },\n  { simp_rw [submonoid.smul_def, algebra.smul_def, mul_comm], exact H.2 },\n  { intros x hx, rw \u2190 (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, \u2190 linear_map.map_smul,\n    linear_equiv.coe_to_linear_map, is_localized_module.iso_mk, \u2190 is_localized_module.mk'_smul,\n    \u2190 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 \u2190 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 \u2190 _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 : \u2203 n : Nat, n = n := by\n  refine \u27e8?n, ?h\u27e9\n  case h => exact Eq.refl 3\n\nexample : \u2203 n : Nat, n = n := by\n  refine \u27e8?n, ?h\u27e9\n  case h => exact rfl\n  case n => exact 3\n\nexample : \u2203 n : Nat, n = n := by\n  refine \u27e8?n, by rfl\u27e9\n  case n => exact 3\n\nexample : \u2203 n : Nat, n = n := by\n  refine \u27e8?n, ?h\u27e9\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 : \u2115\n\nstructure boundary_part :=\n  mk :: (i j : fin (n + 2)) (h : i \u2264 j)\n\nstructure end_part :=\n  mk :: (i : fin (n + 3))\n\ndef boundary_f (p : boundary_part n) := \u0394[n]\ndef simplex_f (p : end_part n) := \u0394[n+1]\n\ndef boundary_start := \u2210 (boundary_f n)\n\ndef simplex_end := \u2210 (simplex_f n)\n\ndef morph_boundary_1 : boundary_start n \u27f6 simplex_end n :=\n  limits.sigma.desc\n    (\u03bb idx : boundary_part n, yoneda.map (simplex_category.\u03b4 idx.i)\n      \u226b (limits.sigma.\u03b9 (simplex_f n) \u27e8idx.j.succ\u27e9))\n  \ndef morph_boundary_2 : boundary_start n \u27f6 simplex_end n :=\n  limits.sigma.desc\n    (\u03bb idx, yoneda.map (simplex_category.\u03b4 idx.j)\n      \u226b (limits.sigma.\u03b9 (simplex_f n) \u27e8idx.i.cast_succ\u27e9))\n\ndef boundary_morphism : simplex_end n \u27f6 \u2202\u0394[n + 2] :=\n  limits.sigma.desc (\u03bb b, yoneda_equiv.inv_fun \u27e8simplex_category.\u03b4 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  }\u27e9)\n\nlemma boundary_coeq : morph_boundary_1 n \u226b boundary_morphism n = morph_boundary_2 n \u226b 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_\u03b9_app, limits.colimit.\u03b9_desc, limits.colimit.\u03b9_desc_assoc, coe_coe,\n    equiv.inv_fun_as_coe, category.assoc],\n  intro idx,\n  rw [\u2190equiv.apply_eq_iff_eq yoneda_equiv],\n  rw [\u2190yoneda_equiv_naturality, \u2190yoneda_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.\u03b4_comp_\u03b4 h,\nend\n\ndef boundary_fork := limits.cofork.of_\u03c0 (boundary_morphism n) (boundary_coeq n)\n\ndef boundary_hole {m n} (f : [m] \u27f6 [n + 1]) (h : \u00ac function.surjective f.to_order_hom)\n  : \u2203 i, i \u2209 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 _ \u226b _,\n--       exact \u0394[n + 1],\n--       apply yoneda_equiv.inv_fun,\n--       exact nonsurj_fun f_val f_property,\n--       refine _ \u226b s.\u03c0,\n--       exact limits.sigma.\u03b9 (simplex_f n) \u27e8nonsurj_index f_val f_property\u27e9,\n--     },\n--     focus {\n--       intros X Y f,\n--       have sn := s.\u03c0.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' : \u2200 x, ((\u2210 simplex_f n).map f \u226b s.\u03c0.app (opposite.op [k])) x\n--         = (s.\u03c0.app (opposite.op [m]) \u226b s.X.map f) x := by { intro, rw [sn], },\n--       simp only [types_comp_apply] at sn',\n--       rw \u2190sn',\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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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] \u27f6 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.\u03c3 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`\u03b8 : [n] \u27f6 \u0394'` is a non injective map in `simplex_category`, then\n`X.map \u03b8.op \u226b P_infty.f n = 0`. It follows from the more precise\nstatement vanishing statement `\u03c3_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_\u03c3 {Y : C} {X : simplicial_object C} {n b q : \u2115} {\u03c6 : Y \u27f6 X _[n+1]}\n  (v : higher_faces_vanish q \u03c6) (hnbq : n + 1 = b + q) :\n    higher_faces_vanish q (\u03c6 \u226b X.\u03c3 \u27e8b,\n    by simpa only [hnbq, nat.lt_succ_iff, le_add_iff_nonneg_right] using zero_le q\u27e9) :=\n\u03bb j hj, begin\n  rw [assoc, simplicial_object.\u03b4_comp_\u03c3_of_gt', fin.pred_succ,\n    v.comp_\u03b4_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 \u03c3_comp_P_eq_zero (X : simplicial_object C)\n  {n q : \u2115} (i : fin (n + 1)) (hi : n + 1 \u2264 i + q) : (X.\u03c3 i) \u226b (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 \u2264 (i : \u2115) + q,\n    { unfold P,\n      simp only [homological_complex.comp_f, \u2190 assoc],\n      rw [hq i h, zero_comp], },\n    { have hi' : n = (i : \u2115) + q,\n      { cases le_iff_exists_add.mp hi with j hj,\n        rw [\u2190 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 [\u2190 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\u03c3, 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\u03c3'_eq' (zero_add 0).symm, h\u03c3'_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.\u03b4_comp_\u03c3_self, simplicial_object.\u03b4_comp_\u03c3_self_assoc,\n          simplicial_object.\u03b4_comp_\u03c3_succ, comp_id, simplicial_object.\u03b4_comp_\u03c3_of_le X\n            (show (0 : fin(2)) \u2264 fin.cast_succ 0, by rw fin.cast_succ_zero),\n          simplicial_object.\u03b4_comp_\u03c3_self_assoc, simplicial_object.\u03b4_comp_\u03c3_succ_assoc],\n        abel, },\n      { rw [\u2190 id_comp (X.\u03c3 i), \u2190 (P_add_Q_f q n.succ : _ = \ud835\udfd9 (X.obj _)), add_comp, add_comp],\n        have v : higher_faces_vanish q ((P q).f n.succ \u226b X.\u03c3 i) :=\n          (higher_faces_vanish.of_P q n).comp_\u03c3 hi',\n        unfold P,\n        erw [\u2190 assoc, v.comp_P_eq_self, homological_complex.add_f_apply,\n          preadditive.comp_add, comp_id, v.comp_H\u03c3_eq hi', assoc,\n          simplicial_object.\u03b4_comp_\u03c3_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 \u27e8k, hk\u27e9 := 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 \u27e8i, by linarith\u27e9 :=\n            by { ext, simp only [fin.cast_succ_mk, fin.eta], },\n          have eq := hq j.rev.succ begin\n            simp only [\u2190 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.\u03c3_comp_\u03c3_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 \u03c3_comp_P_infty (X : simplicial_object C) {n : \u2115} (i : fin (n+1)) :\n  (X.\u03c3 i) \u226b P_infty.f (n+1) = 0 :=\nbegin\n  rw [P_infty_f, \u03c3_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 : \u2115) {\u0394' : simplex_category} (\u03b8 : [n] \u27f6 \u0394') (h\u03b8 : \u00acmono \u03b8) :\n  X.map \u03b8.op \u226b P_infty.f n = 0 :=\nbegin\n  rw simplex_category.mono_iff_injective at h\u03b8,\n  cases n,\n  { exfalso,\n    apply h\u03b8,\n    intros x y h,\n    fin_cases x,\n    fin_cases y, },\n  { obtain \u27e8i, \u03b1, h\u27e9 := simplex_category.eq_\u03c3_comp_of_not_injective \u03b8 h\u03b8,\n    rw [h, op_comp, X.map_comp, assoc, (show X.map (simplex_category.\u03c3 i).op = X.\u03c3 i, by refl),\n      \u03c3_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 \u25b8 x.1.zero_mem\n\nsection\nvariables (R) (S : Type v) [comm_ring S]\n\n/-- The prime spectrum of `R \u00d7 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 \u00d7 S) \u2243 prime_spectrum R \u2295 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 \u22a4 :=\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 \u22a4 x.as_ideal :=\nby { cases x, refl }\n\nend\n\n@[ext] lemma ext {x y : prime_spectrum R} :\n  x = y \u2194 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 \u2286 x.as_ideal}\n\n@[simp] lemma mem_zero_locus (x : prime_spectrum R) (s : set R) :\n  x \u2208 zero_locus s \u2194 s \u2286 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\u2a05 (x : prime_spectrum R) (h : x \u2208 t), x.as_ideal\n\nlemma coe_vanishing_ideal (t : set (prime_spectrum R)) :\n  (vanishing_ideal t : set R) = {f : R | \u2200 x : prime_spectrum R, x \u2208 t \u2192 f \u2208 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 \u2208 vanishing_ideal t \u2194 \u2200 x : prime_spectrum R, x \u2208 t \u2192 f \u2208 x.as_ideal :=\nby rw [\u2190 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 \u2286 zero_locus I \u2194 I \u2264 vanishing_ideal t :=\n\u27e8\u03bb h f k, (mem_vanishing_ideal _ _).mpr (\u03bb x j, (mem_zero_locus _ _).mpr (h j) k), \u03bb h,\n  \u03bb x j, (mem_zero_locus _ _).mpr (le_trans h (\u03bb f h, ((mem_vanishing_ideal _ _).mp h) x j))\u27e9\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  (\u03bb I, zero_locus I) (\u03bb t, vanishing_ideal t) :=\n\u03bb 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  (\u03bb s, zero_locus s) (\u03bb 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 \u2286 zero_locus s \u2194 s \u2286 vanishing_ideal t :=\n(gc_set R) s t\n\nend gc\n\nlemma subset_vanishing_ideal_zero_locus (s : set R) :\n  s \u2286 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 \u2264 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 $ \u03bb f,\nbegin\n  rw [mem_vanishing_ideal, ideal.radical_eq_Inf, submodule.mem_Inf],\n  exact \u27e8(\u03bb h x hx, h \u27e8x, hx.2\u27e9 hx.1), (\u03bb h x hx, h x.1 \u27e8hx, x.2\u27e9)\u27e9\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 \u25b8 (gc R).l_u_l_eq_l I\n\nlemma subset_zero_locus_vanishing_ideal (t : set (prime_spectrum R)) :\n  t \u2286 zero_locus (vanishing_ideal t) :=\n(gc R).l_u_le t\n\nlemma zero_locus_anti_mono {s t : set R} (h : s \u2286 t) : zero_locus t \u2286 zero_locus s :=\n(gc_set R).monotone_l h\n\nlemma zero_locus_anti_mono_ideal {s t : ideal R} (h : s \u2264 t) :\n  zero_locus (t : set R) \u2286 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 \u2286 t) :\n  vanishing_ideal t \u2264 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) \u2286 zero_locus (J : set R) \u2194 J \u2264 I.radical :=\n\u27e8\u03bb h, ideal.radical_le_radical_iff.mp (vanishing_ideal_zero_locus_eq_radical I \u25b8\n  vanishing_ideal_zero_locus_eq_radical J \u25b8 vanishing_ideal_anti_mono h),\n\u03bb h, zero_locus_radical I \u25b8 zero_locus_anti_mono_ideal h\u27e9\n\nlemma zero_locus_subset_zero_locus_singleton_iff (f g : R) :\n  zero_locus ({f} : set R) \u2286 zero_locus {g} \u2194 g \u2208 (ideal.span ({f} : set R)).radical :=\nby rw [\u2190 zero_locus_span {f}, \u2190 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 ((\u22a5 : 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 (\u2205 : set R) = set.univ :=\n(gc_set R).l_bot\n\n@[simp] lemma vanishing_ideal_univ :\n  vanishing_ideal (\u2205 : set (prime_spectrum R)) = \u22a4 :=\nby simpa using (gc R).u_top\n\nlemma zero_locus_empty_of_one_mem {s : set R} (h : (1:R) \u2208 s) :\n  zero_locus s = \u2205 :=\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 = \u22a4, { 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) = \u2205 :=\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) = \u2205 \u2194 I = \u22a4 :=\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 \u27e8M, hM, hIM\u27e9,\n    exact \u27e8\u27e8M, hM.is_prime\u27e9, hIM\u27e9 },\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) = \u2205 :=\nzero_locus_empty_of_one_mem (set.mem_univ 1)\n\nlemma zero_locus_sup (I J : ideal R) :\n  zero_locus ((I \u2294 J : ideal R) : set R) = zero_locus I \u2229 zero_locus J :=\n(gc R).l_sup\n\nlemma zero_locus_union (s s' : set R) :\n  zero_locus (s \u222a s') = zero_locus s \u2229 zero_locus s' :=\n(gc_set R).l_sup\n\nlemma vanishing_ideal_union (t t' : set (prime_spectrum R)) :\n  vanishing_ideal (t \u222a t') = vanishing_ideal t \u2293 vanishing_ideal t' :=\n(gc R).u_inf\n\nlemma zero_locus_supr {\u03b9 : Sort*} (I : \u03b9 \u2192 ideal R) :\n  zero_locus ((\u2a06 i, I i : ideal R) : set R) = (\u22c2 i, zero_locus (I i)) :=\n(gc R).l_supr\n\nlemma zero_locus_Union {\u03b9 : Sort*} (s : \u03b9 \u2192 set R) :\n  zero_locus (\u22c3 i, s i) = (\u22c2 i, zero_locus (s i)) :=\n(gc_set R).l_supr\n\nlemma zero_locus_bUnion (s : set (set R)) :\n  zero_locus (\u22c3 s' \u2208 s, s' : set R) = \u22c2 s' \u2208 s, zero_locus s' :=\nby simp only [zero_locus_Union]\n\nlemma vanishing_ideal_Union {\u03b9 : Sort*} (t : \u03b9 \u2192 set (prime_spectrum R)) :\n  vanishing_ideal (\u22c3 i, t i) = (\u2a05 i, vanishing_ideal (t i)) :=\n(gc R).u_infi\n\nlemma zero_locus_inf (I J : ideal R) :\n  zero_locus ((I \u2293 J : ideal R) : set R) = zero_locus I \u222a zero_locus J :=\nset.ext $ \u03bb x, by simpa using x.2.inf_le\n\nlemma union_zero_locus (s s' : set R) :\n  zero_locus s \u222a zero_locus s' = zero_locus ((ideal.span s) \u2293 (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 \u222a zero_locus J :=\nset.ext $ \u03bb 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} \u222a zero_locus {g} :=\nset.ext $ \u03bb x, by simpa using x.2.mul_mem_iff_mem_or_mem\n\n@[simp] lemma zero_locus_pow (I : ideal R) {n : \u2115} (hn : 0 < n) :\n  zero_locus ((I ^ n : ideal R) : set R) = zero_locus I :=\nzero_locus_radical (I ^ n) \u25b8 (I.radical_pow n hn).symm \u25b8 zero_locus_radical I\n\n@[simp] lemma zero_locus_singleton_pow (f : R) (n : \u2115) (hn : 0 < n) :\n  zero_locus ({f ^ n} : set R) = zero_locus {f} :=\nset.ext $ \u03bb 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 \u2294 vanishing_ideal t' \u2264 vanishing_ideal (t \u2229 t') :=\nbegin\n  intros r,\n  rw [submodule.mem_sup, mem_vanishing_ideal],\n  rintro \u27e8f, hf, g, hg, rfl\u27e9 x \u27e8hxt, hxt'\u27e9,\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 \u2208 (zero_locus {f} : set (prime_spectrum R))\u1d9c \u2194 f \u2209 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  (\u27e8set.univ, by simp\u27e9)\n  begin\n    intros Zs h,\n    rw set.sInter_eq_Inter,\n    let f : Zs \u2192 set R := \u03bb i, classical.some (h i.2),\n    have hf : \u2200 i : Zs, \u2191i = zero_locus (f i) := \u03bb i, (classical.some_spec (h i.2)).symm,\n    simp only [hf],\n    exact \u27e8_, zero_locus_Union _\u27e9\n  end\n  (by { rintro _ \u27e8s, rfl\u27e9 _ \u27e8t, rfl\u27e9, exact \u27e8_, (union_zero_locus s t).symm\u27e9 })\n\nlemma is_open_iff (U : set (prime_spectrum R)) :\n  is_open U \u2194 \u2203 s, U\u1d9c = zero_locus s :=\nby simp only [@eq_comm _ U\u1d9c]; refl\n\nlemma is_closed_iff_zero_locus (Z : set (prime_spectrum R)) :\n  is_closed Z \u2194 \u2203 s, Z = zero_locus s :=\nby rw [\u2190 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 \u2194 \u2203 (s : ideal R), Z = zero_locus s :=\n(is_closed_iff_zero_locus _).trans\n  \u27e8\u03bb x, \u27e8_, x.some_spec.trans (zero_locus_span _).symm\u27e9, \u03bb x, \u27e8_, x.some_spec\u27e9\u27e9\n\nlemma is_closed_iff_zero_locus_radical_ideal (Z : set (prime_spectrum R)) :\n  is_closed Z \u2194 \u2203 (s : ideal R), s.radical = s \u2227 Z = zero_locus s :=\n(is_closed_iff_zero_locus_ideal _).trans\n  \u27e8\u03bb x, \u27e8_, ideal.radical_idem _, x.some_spec.trans (zero_locus_radical _).symm\u27e9,\n    \u03bb x, \u27e8_, x.some_spec.2\u27e9\u27e9\n\nlemma is_closed_zero_locus (s : set R) :\n  is_closed (zero_locus s) :=\nby { rw [is_closed_iff_zero_locus], exact \u27e8s, rfl\u27e9 }\n\nlemma is_closed_singleton_iff_is_maximal (x : prime_spectrum R) :\n  is_closed ({x} : set (prime_spectrum R)) \u2194 x.as_ideal.is_maximal :=\nbegin\n  refine (is_closed_iff_zero_locus _).trans \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { obtain \u27e8s, hs\u27e9 := h,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem] at hs,\n    refine \u27e8\u27e8x.2.1, \u03bb I hI, not_not.1 (mt (ideal.exists_le_maximal I) $\n      not_exists.2 (\u03bb J, not_and.2 $ \u03bb hJ hIJ,_))\u27e9\u27e9,\n    exact ne_of_lt (lt_of_lt_of_le hI hIJ) (symm $ congr_arg prime_spectrum.as_ideal\n      (hs.2 \u27e8J, hJ.is_prime\u27e9 (\u03bb r hr, hIJ (le_of_lt hI $ hs.1 hr)))) },\n  { refine \u27e8x.as_ideal.1, _\u27e9,\n    rw [eq_comm, set.eq_singleton_iff_unique_mem],\n    refine \u27e8\u03bb _ h, h, \u03bb y hy, prime_spectrum.ext.2 (h.eq_of_le y.2.ne_top hy).symm\u27e9 }\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' \u27e8ht', ht\u27e9,\n    obtain \u27e8fs, rfl\u27e9 : \u2203 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 \u25b8 (gc R).u_l_u_eq_u t\n\nlemma t1_space_iff_is_field [is_domain R] :\n  t1_space (prime_spectrum R) \u2194 is_field R :=\nbegin\n  refine \u27e8_, \u03bb h, _\u27e9,\n  { introI h,\n    have hbot : ideal.is_prime (\u22a5 : 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 \u27e8\u22a5, hbot\u27e9)) (not_not.2 rfl)) },\n  { refine \u27e8\u03bb x, (is_closed_singleton_iff_is_maximal x).2 _\u27e9,\n    by_cases hx : x.as_ideal = \u22a5,\n    { exact hx.symm \u25b8 @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 \u27e8x.as_ideal, \u27e8hx, x.2\u27e9\u27e9) } }\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)) \u2194 I.radical.is_prime :=\n(zero_locus_radical I) \u25b8 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, \u2190 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\u2081 h\u2082,\n  rw [\u2190 h\u2082.closure_eq, \u2190 zero_locus_vanishing_ideal_eq_closure,\n    is_irreducible_zero_locus_iff] at h\u2081,\n  use \u27e8_, h\u2081\u27e9,\n  obtain \u27e8s, hs, rfl\u27e9 := (is_closed_iff_zero_locus_radical_ideal _).mp h\u2082,\n  rw is_generic_point_iff_forall_closed h\u2082,\n  intros Z hZ hxZ,\n  obtain \u27e8t, rfl\u27e9 := (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 \u2192+* S) (s : set R) :\n  (\u03bb y, \u27e8ideal.comap f y.as_ideal, infer_instance\u27e9 :\n    prime_spectrum S \u2192 prime_spectrum R) \u207b\u00b9' (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 \u2192+* S) : C(prime_spectrum S, prime_spectrum R) :=\n{ to_fun := \u03bb y, \u27e8ideal.comap f y.as_ideal, infer_instance\u27e9,\n  continuous_to_fun :=\n    begin\n      simp only [continuous_iff_is_closed, is_closed_iff_zero_locus],\n      rintro _ \u27e8s, rfl\u27e9,\n      exact \u27e8_, preimage_comap_zero_locus_aux f s\u27e9\n    end }\n\nvariables (f : R \u2192+* 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 \u2192+* S) (g : S \u2192+* S') :\n  comap (g.comp f) = (comap f).comp (comap g) :=\nrfl\n\nlemma comap_comp_apply (f : R \u2192+* S) (g : S \u2192+* 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) \u207b\u00b9' (zero_locus s) = zero_locus (f '' s) :=\npreimage_comap_zero_locus_aux f s\n\nlemma comap_injective_of_surjective (f : R \u2192+* S) (hf : function.surjective f) :\n  function.injective (comap f) :=\n\u03bb 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 \u2192+* 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 \u2192+* 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 \u2190 is_closed_compl_iff,\n  generalize : U\u1d9c = Z,\n  simp_rw [is_closed_induced_iff, is_closed_iff_zero_locus],\n  split,\n  { rintro \u27e8s, rfl\u27e9,\n    refine \u27e8_,\u27e8(algebra_map R S) \u207b\u00b9' (ideal.span s),rfl\u27e9,_\u27e9,\n    rw [preimage_comap_zero_locus, \u2190 zero_locus_span, \u2190 zero_locus_span s],\n    congr' 1,\n    exact congr_arg submodule.carrier (is_localization.map_comap M S (ideal.span s)) },\n  { rintro \u27e8_, \u27e8t, rfl\u27e9, rfl\u27e9, 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 (\u03bb (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\u27e8localization_comap_inducing S M, localization_comap_injective S M\u27e9\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 \u27e8p, rfl\u27e9 x \u27e8hx\u2081, hx\u2082\u27e9,\n    exact (p.2.1 : \u00ac _)\n      (p.as_ideal.eq_top_of_is_unit_mem hx\u2082 (is_localization.map_units S \u27e8x, hx\u2081\u27e9)) },\n  { intro h,\n    use \u27e8x.as_ideal.map (algebra_map R S),\n      is_localization.is_prime_of_is_prime_disjoint M S _ x.2 h\u27e9,\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 \u2209 x.as_ideal },\n  property := \u27e8{r}, set.ext $ \u03bb x, set.singleton_subset_iff.trans $ not_not.symm\u27e9 }\n\n@[simp] lemma mem_basic_open (f : R) (x : prime_spectrum R) :\n  x \u2208 basic_open f \u2194 f \u2209 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})\u1d9c :=\nset.ext $ \u03bb 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) = \u22a4 :=\ntopological_space.opens.ext $ by simp\n\n@[simp] lemma basic_open_zero : basic_open (0 : R) = \u22a5 :=\ntopological_space.opens.ext $ by simp\n\nlemma basic_open_le_basic_open_iff (f g : R) :\n  basic_open f \u2264 basic_open g \u2194 f \u2208 (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 \u2293 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) \u2264 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) \u2264 basic_open g :=\nby { rw basic_open_mul f g, exact inf_le_right }\n\n@[simp] lemma basic_open_pow (f : R) (n : \u2115) (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 (\u03bb (r : R), (basic_open r : set (prime_spectrum R)))) :=\nbegin\n  apply topological_space.is_topological_basis_of_open_of_nhds,\n  { rintros _ \u27e8r, rfl\u27e9,\n    exact is_open_basic_open },\n  { rintros p U hp \u27e8s, hs\u27e9,\n    rw [\u2190 compl_compl U, set.mem_compl_eq, \u2190 hs, mem_zero_locus, set.not_subset] at hp,\n    obtain \u27e8f, hfs, hfp\u27e9 := hp,\n    refine \u27e8basic_open f, \u27e8f, rfl\u27e9, hfp, _\u27e9,\n    rw [\u2190 set.compl_subset_compl, \u2190 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 \u2190 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 $ \u03bb \u03b9 Z hZc hZ,\nbegin\n  let I : \u03b9 \u2192 ideal R := \u03bb i, vanishing_ideal (Z i),\n  have hI : \u2200 i, Z i = zero_locus (I i) := \u03bb 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, \u2190 set.diff_eq,\n      set.diff_eq_empty, funext hI, \u2190 zero_locus_supr] at hZ,\n  obtain \u27e8n, hn\u27e9 : f \u2208 (\u2a06 (i : \u03b9), I i).radical,\n  { rw \u2190 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 \u27e8s, hs\u27e9,\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, \u2190 set.diff_eq,\n           set.diff_eq_empty, hI, \u2190 zero_locus_supr],\n  rw \u2190 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 \u27e8n, hs\u27e9\nend\n\n@[simp]\nlemma basic_open_eq_bot_iff (f : R) :\n  basic_open f = \u22a5 \u2194 is_nilpotent f :=\nbegin\n  rw [\u2190 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\u2081 h\u2082,\n    exact h\u2081 \u27e8submonoid.mem_powers r, h\u2082\u27e9 },\n  { rintros h\u2081 _ \u27e8\u27e8n, rfl\u27e9, h\u2083\u27e9,\n    exact h\u2081 (x.2.mem_of_pow_mem _ h\u2083) },\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 \u2264 y` if and only if `y \u2208 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 \u2264 y.as_ideal \u2194 x \u2264 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 \u2194 x < y :=\nsubtype.coe_lt_coe\n\nlemma le_iff_mem_closure (x y : prime_spectrum R) :\n  x \u2264 y \u2194 y \u2208 closure ({x} : set (prime_spectrum R)) :=\nby rw [\u2190 as_ideal_le_as_ideal, \u2190 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 \u2264 y \u2194 x \u2933 y :=\nle_iff_mem_closure x y\n\ninstance : t0_space (prime_spectrum R) :=\nby { simp [t0_space_iff_or_not_mem_closure, \u2190 le_iff_mem_closure,\n  \u2190 not_and_distrib, \u2190 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 \u2933 y) :\n  localization.at_prime y.as_ideal \u2192+* localization.at_prime x.as_ideal :=\n@is_localization.lift _ _ _ _ _ _ _ _ localization.is_localization (algebra_map R _)\nbegin\n  rintro \u27e8a, ha\u27e9,\n  rw [\u2190 prime_spectrum.le_iff_specializes, \u2190 as_ideal_le_as_ideal, \u2190 set_like.coe_subset_coe,\n    \u2190 set.compl_subset_compl] at h,\n  exact (is_localization.map_units _ \u27e8a, (show a \u2208 x.as_ideal.prime_compl, from h ha)\u27e9 : _)\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\u27e8maximal_ideal R, (maximal_ideal.is_maximal R).is_prime\u27e9\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 \u2192+* S) : is_local_ring_hom f \u2194 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 \u2192+* 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 {\u03b1 : Type _} {\u03b9 : Sort _} {\u03b9' : Sort _} [Nonempty \u03b9] [Nonempty \u03b9']\n  [ConditionallyCompleteLattice \u03b1] [Group \u03b1]\n\n/- warning: le_mul_cinfi -> le_mul_cinf\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : Nonempty.{u2} \u03b9] [_inst_3 : ConditionallyCompleteLattice.{u1} \u03b1] [_inst_4 : Group.{u1} \u03b1] [_inst_5 : CovariantClass.{u1, u1} \u03b1 \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4)))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))))] {a : \u03b1} {g : \u03b1} {h : \u03b9 -> \u03b1}, (forall (j : \u03b9), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) g (h j))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) g (inf\u1d62.{u1, u2} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 _inst_3) \u03b9 h)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : Nonempty.{u1} \u03b9] [_inst_3 : ConditionallyCompleteLattice.{u2} \u03b1] [_inst_4 : Group.{u2} \u03b1] [_inst_5 : CovariantClass.{u2, u2} \u03b1 \u03b1 (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.50 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.52 : \u03b1) => HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.50 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.52) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.65 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.67 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.65 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.67)] {a : \u03b1} {g : \u03b1} {h : \u03b9 -> \u03b1}, (forall (j : \u03b9), LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) a (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) g (h j))) -> (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) a (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) g (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 _inst_3) \u03b9 h)))\nCase conversion may be inaccurate. Consider using '#align le_mul_cinfi le_mul_cinf\u1d62\u2093'. -/\n@[to_additive]\ntheorem le_mul_cinf\u1d62 [CovariantClass \u03b1 \u03b1 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)] {a : \u03b1} {g : \u03b1} {h : \u03b9 \u2192 \u03b1}\n    (H : \u2200 j, a \u2264 g * h j) : a \u2264 g * inf\u1d62 h :=\n  inv_mul_le_iff_le_mul.mp <| le_cinf\u1d62 fun hi => inv_mul_le_iff_le_mul.mpr <| H _\n#align le_mul_cinfi le_mul_cinf\u1d62\n#align le_add_cinfi le_add_cinf\u1d62\n\n/- warning: mul_csupr_le -> mul_csup\u1d62_le is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : Nonempty.{u2} \u03b9] [_inst_3 : ConditionallyCompleteLattice.{u1} \u03b1] [_inst_4 : Group.{u1} \u03b1] [_inst_5 : CovariantClass.{u1, u1} \u03b1 \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4)))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))))] {a : \u03b1} {g : \u03b1} {h : \u03b9 -> \u03b1}, (forall (j : \u03b9), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) g (h j)) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) g (sup\u1d62.{u1, u2} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 _inst_3) \u03b9 h)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : Nonempty.{u1} \u03b9] [_inst_3 : ConditionallyCompleteLattice.{u2} \u03b1] [_inst_4 : Group.{u2} \u03b1] [_inst_5 : CovariantClass.{u2, u2} \u03b1 \u03b1 (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.139 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.141 : \u03b1) => HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.139 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.141) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.154 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.156 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.154 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.156)] {a : \u03b1} {g : \u03b1} {h : \u03b9 -> \u03b1}, (forall (j : \u03b9), LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) g (h j)) a) -> (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) g (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 _inst_3) \u03b9 h)) a)\nCase conversion may be inaccurate. Consider using '#align mul_csupr_le mul_csup\u1d62_le\u2093'. -/\n@[to_additive]\ntheorem mul_csup\u1d62_le [CovariantClass \u03b1 \u03b1 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)] {a : \u03b1} {g : \u03b1} {h : \u03b9 \u2192 \u03b1}\n    (H : \u2200 j, g * h j \u2264 a) : g * sup\u1d62 h \u2264 a :=\n  @le_mul_cinf\u1d62 \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ H\n#align mul_csupr_le mul_csup\u1d62_le\n#align add_csupr_le add_csup\u1d62_le\n\n/- warning: le_cinfi_mul -> le_cinf\u1d62_mul is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : Nonempty.{u2} \u03b9] [_inst_3 : ConditionallyCompleteLattice.{u1} \u03b1] [_inst_4 : Group.{u1} \u03b1] [_inst_5 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))))] {a : \u03b1} {g : \u03b9 -> \u03b1} {h : \u03b1}, (forall (i : \u03b9), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) (g i) h)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) (inf\u1d62.{u1, u2} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 _inst_3) \u03b9 g) h))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : Nonempty.{u1} \u03b9] [_inst_3 : ConditionallyCompleteLattice.{u2} \u03b1] [_inst_4 : Group.{u2} \u03b1] [_inst_5 : CovariantClass.{u2, u2} \u03b1 \u03b1 (Function.swap.{succ u2, succ u2, succ u2} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.228 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.230 : \u03b1) => HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.228 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.230)) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.243 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.245 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.243 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.245)] {a : \u03b1} {g : \u03b9 -> \u03b1} {h : \u03b1}, (forall (i : \u03b9), LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) a (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) (g i) h)) -> (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) a (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) (inf\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u2} \u03b1 _inst_3) \u03b9 g) h))\nCase conversion may be inaccurate. Consider using '#align le_cinfi_mul le_cinf\u1d62_mul\u2093'. -/\n@[to_additive]\ntheorem le_cinf\u1d62_mul [CovariantClass \u03b1 \u03b1 (Function.swap (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7)] {a : \u03b1} {g : \u03b9 \u2192 \u03b1}\n    {h : \u03b1} (H : \u2200 i, a \u2264 g i * h) : a \u2264 inf\u1d62 g * h :=\n  mul_inv_le_iff_le_mul.mp <| le_cinf\u1d62 fun gi => mul_inv_le_iff_le_mul.mpr <| H _\n#align le_cinfi_mul le_cinf\u1d62_mul\n#align le_cinfi_add le_cinf\u1d62_add\n\n/- warning: csupr_mul_le -> csup\u1d62_mul_le is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : Nonempty.{u2} \u03b9] [_inst_3 : ConditionallyCompleteLattice.{u1} \u03b1] [_inst_4 : Group.{u1} \u03b1] [_inst_5 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))))] {a : \u03b1} {g : \u03b9 -> \u03b1} {h : \u03b1}, (forall (i : \u03b9), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) (g i) h) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) (sup\u1d62.{u1, u2} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 _inst_3) \u03b9 g) h) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : Nonempty.{u1} \u03b9] [_inst_3 : ConditionallyCompleteLattice.{u2} \u03b1] [_inst_4 : Group.{u2} \u03b1] [_inst_5 : CovariantClass.{u2, u2} \u03b1 \u03b1 (Function.swap.{succ u2, succ u2, succ u2} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.320 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.322 : \u03b1) => HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.320 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.322)) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.335 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.337 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.335 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.337)] {a : \u03b1} {g : \u03b9 -> \u03b1} {h : \u03b1}, (forall (i : \u03b9), LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) (g i) h) a) -> (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (ConditionallyCompleteLattice.toLattice.{u2} \u03b1 _inst_3))))) (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (MulOneClass.toMul.{u2} \u03b1 (Monoid.toMulOneClass.{u2} \u03b1 (DivInvMonoid.toMonoid.{u2} \u03b1 (Group.toDivInvMonoid.{u2} \u03b1 _inst_4))))) (sup\u1d62.{u2, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u2} \u03b1 _inst_3) \u03b9 g) h) a)\nCase conversion may be inaccurate. Consider using '#align csupr_mul_le csup\u1d62_mul_le\u2093'. -/\n@[to_additive]\ntheorem csup\u1d62_mul_le [CovariantClass \u03b1 \u03b1 (Function.swap (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7)] {a : \u03b1} {g : \u03b9 \u2192 \u03b1}\n    {h : \u03b1} (H : \u2200 i, g i * h \u2264 a) : sup\u1d62 g * h \u2264 a :=\n  @le_cinf\u1d62_mul \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ H\n#align csupr_mul_le csup\u1d62_mul_le\n#align csupr_add_le csup\u1d62_add_le\n\n/- warning: le_cinfi_mul_cinfi -> le_cinf\u1d62_mul_cinf\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} {\u03b9' : Sort.{u3}} [_inst_1 : Nonempty.{u2} \u03b9] [_inst_2 : Nonempty.{u3} \u03b9'] [_inst_3 : ConditionallyCompleteLattice.{u1} \u03b1] [_inst_4 : Group.{u1} \u03b1] [_inst_5 : CovariantClass.{u1, u1} \u03b1 \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4)))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))))] [_inst_6 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))))] {a : \u03b1} {g : \u03b9 -> \u03b1} {h : \u03b9' -> \u03b1}, (forall (i : \u03b9) (j : \u03b9'), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) (g i) (h j))) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) a (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) (inf\u1d62.{u1, u2} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 _inst_3) \u03b9 g) (inf\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 _inst_3) \u03b9' h)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b9 : Sort.{u2}} {\u03b9' : Sort.{u1}} [_inst_1 : Nonempty.{u2} \u03b9] [_inst_2 : Nonempty.{u1} \u03b9'] [_inst_3 : ConditionallyCompleteLattice.{u3} \u03b1] [_inst_4 : Group.{u3} \u03b1] [_inst_5 : CovariantClass.{u3, u3} \u03b1 \u03b1 (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.406 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.408 : \u03b1) => HMul.hMul.{u3, u3, u3} \u03b1 \u03b1 \u03b1 (instHMul.{u3} \u03b1 (MulOneClass.toMul.{u3} \u03b1 (Monoid.toMulOneClass.{u3} \u03b1 (DivInvMonoid.toMonoid.{u3} \u03b1 (Group.toDivInvMonoid.{u3} \u03b1 _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.406 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.408) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.421 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.423 : \u03b1) => LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (ConditionallyCompleteLattice.toLattice.{u3} \u03b1 _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.421 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.423)] [_inst_6 : CovariantClass.{u3, u3} \u03b1 \u03b1 (Function.swap.{succ u3, succ u3, succ u3} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.443 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.445 : \u03b1) => HMul.hMul.{u3, u3, u3} \u03b1 \u03b1 \u03b1 (instHMul.{u3} \u03b1 (MulOneClass.toMul.{u3} \u03b1 (Monoid.toMulOneClass.{u3} \u03b1 (DivInvMonoid.toMonoid.{u3} \u03b1 (Group.toDivInvMonoid.{u3} \u03b1 _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.443 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.445)) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.458 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.460 : \u03b1) => LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (ConditionallyCompleteLattice.toLattice.{u3} \u03b1 _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.458 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.460)] {a : \u03b1} {g : \u03b9 -> \u03b1} {h : \u03b9' -> \u03b1}, (forall (i : \u03b9) (j : \u03b9'), LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (ConditionallyCompleteLattice.toLattice.{u3} \u03b1 _inst_3))))) a (HMul.hMul.{u3, u3, u3} \u03b1 \u03b1 \u03b1 (instHMul.{u3} \u03b1 (MulOneClass.toMul.{u3} \u03b1 (Monoid.toMulOneClass.{u3} \u03b1 (DivInvMonoid.toMonoid.{u3} \u03b1 (Group.toDivInvMonoid.{u3} \u03b1 _inst_4))))) (g i) (h j))) -> (LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (ConditionallyCompleteLattice.toLattice.{u3} \u03b1 _inst_3))))) a (HMul.hMul.{u3, u3, u3} \u03b1 \u03b1 \u03b1 (instHMul.{u3} \u03b1 (MulOneClass.toMul.{u3} \u03b1 (Monoid.toMulOneClass.{u3} \u03b1 (DivInvMonoid.toMonoid.{u3} \u03b1 (Group.toDivInvMonoid.{u3} \u03b1 _inst_4))))) (inf\u1d62.{u3, u2} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u3} \u03b1 _inst_3) \u03b9 g) (inf\u1d62.{u3, u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u3} \u03b1 _inst_3) \u03b9' h)))\nCase conversion may be inaccurate. Consider using '#align le_cinfi_mul_cinfi le_cinf\u1d62_mul_cinf\u1d62\u2093'. -/\n@[to_additive]\ntheorem le_cinf\u1d62_mul_cinf\u1d62 [CovariantClass \u03b1 \u03b1 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)]\n    [CovariantClass \u03b1 \u03b1 (Function.swap (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7)] {a : \u03b1} {g : \u03b9 \u2192 \u03b1} {h : \u03b9' \u2192 \u03b1}\n    (H : \u2200 i j, a \u2264 g i * h j) : a \u2264 inf\u1d62 g * inf\u1d62 h :=\n  le_cinf\u1d62_mul fun i => le_mul_cinf\u1d62 <| H _\n#align le_cinfi_mul_cinfi le_cinf\u1d62_mul_cinf\u1d62\n#align le_cinfi_add_cinfi le_cinf\u1d62_add_cinf\u1d62\n\n/- warning: csupr_mul_csupr_le -> csup\u1d62_mul_csup\u1d62_le is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} {\u03b9' : Sort.{u3}} [_inst_1 : Nonempty.{u2} \u03b9] [_inst_2 : Nonempty.{u3} \u03b9'] [_inst_3 : ConditionallyCompleteLattice.{u1} \u03b1] [_inst_4 : Group.{u1} \u03b1] [_inst_5 : CovariantClass.{u1, u1} \u03b1 \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4)))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))))] [_inst_6 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))))] {a : \u03b1} {g : \u03b9 -> \u03b1} {h : \u03b9' -> \u03b1}, (forall (i : \u03b9) (j : \u03b9'), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) (g i) (h j)) a) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 _inst_3))))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 (Group.toDivInvMonoid.{u1} \u03b1 _inst_4))))) (sup\u1d62.{u1, u2} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 _inst_3) \u03b9 g) (sup\u1d62.{u1, u3} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 _inst_3) \u03b9' h)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b9 : Sort.{u2}} {\u03b9' : Sort.{u1}} [_inst_1 : Nonempty.{u2} \u03b9] [_inst_2 : Nonempty.{u1} \u03b9'] [_inst_3 : ConditionallyCompleteLattice.{u3} \u03b1] [_inst_4 : Group.{u3} \u03b1] [_inst_5 : CovariantClass.{u3, u3} \u03b1 \u03b1 (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.534 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.536 : \u03b1) => HMul.hMul.{u3, u3, u3} \u03b1 \u03b1 \u03b1 (instHMul.{u3} \u03b1 (MulOneClass.toMul.{u3} \u03b1 (Monoid.toMulOneClass.{u3} \u03b1 (DivInvMonoid.toMonoid.{u3} \u03b1 (Group.toDivInvMonoid.{u3} \u03b1 _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.534 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.536) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.549 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.551 : \u03b1) => LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (ConditionallyCompleteLattice.toLattice.{u3} \u03b1 _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.549 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.551)] [_inst_6 : CovariantClass.{u3, u3} \u03b1 \u03b1 (Function.swap.{succ u3, succ u3, succ u3} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.571 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.573 : \u03b1) => HMul.hMul.{u3, u3, u3} \u03b1 \u03b1 \u03b1 (instHMul.{u3} \u03b1 (MulOneClass.toMul.{u3} \u03b1 (Monoid.toMulOneClass.{u3} \u03b1 (DivInvMonoid.toMonoid.{u3} \u03b1 (Group.toDivInvMonoid.{u3} \u03b1 _inst_4))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.571 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.573)) (fun (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.586 : \u03b1) (x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.588 : \u03b1) => LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (ConditionallyCompleteLattice.toLattice.{u3} \u03b1 _inst_3))))) x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.586 x._@.Mathlib.Order.ConditionallyCompleteLattice.Group._hyg.588)] {a : \u03b1} {g : \u03b9 -> \u03b1} {h : \u03b9' -> \u03b1}, (forall (i : \u03b9) (j : \u03b9'), LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (ConditionallyCompleteLattice.toLattice.{u3} \u03b1 _inst_3))))) (HMul.hMul.{u3, u3, u3} \u03b1 \u03b1 \u03b1 (instHMul.{u3} \u03b1 (MulOneClass.toMul.{u3} \u03b1 (Monoid.toMulOneClass.{u3} \u03b1 (DivInvMonoid.toMonoid.{u3} \u03b1 (Group.toDivInvMonoid.{u3} \u03b1 _inst_4))))) (g i) (h j)) a) -> (LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (ConditionallyCompleteLattice.toLattice.{u3} \u03b1 _inst_3))))) (HMul.hMul.{u3, u3, u3} \u03b1 \u03b1 \u03b1 (instHMul.{u3} \u03b1 (MulOneClass.toMul.{u3} \u03b1 (Monoid.toMulOneClass.{u3} \u03b1 (DivInvMonoid.toMonoid.{u3} \u03b1 (Group.toDivInvMonoid.{u3} \u03b1 _inst_4))))) (sup\u1d62.{u3, u2} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u3} \u03b1 _inst_3) \u03b9 g) (sup\u1d62.{u3, u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u3} \u03b1 _inst_3) \u03b9' h)) a)\nCase conversion may be inaccurate. Consider using '#align csupr_mul_csupr_le csup\u1d62_mul_csup\u1d62_le\u2093'. -/\n@[to_additive]\ntheorem csup\u1d62_mul_csup\u1d62_le [CovariantClass \u03b1 \u03b1 (\u00b7 * \u00b7) (\u00b7 \u2264 \u00b7)]\n    [CovariantClass \u03b1 \u03b1 (Function.swap (\u00b7 * \u00b7)) (\u00b7 \u2264 \u00b7)] {a : \u03b1} {g : \u03b9 \u2192 \u03b1} {h : \u03b9' \u2192 \u03b1}\n    (H : \u2200 i j, g i * h j \u2264 a) : sup\u1d62 g * sup\u1d62 h \u2264 a :=\n  csup\u1d62_mul_le fun i => mul_csup\u1d62_le <| H _\n#align csupr_mul_csupr_le csup\u1d62_mul_csup\u1d62_le\n#align csupr_add_csupr_le csup\u1d62_add_csup\u1d62_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 {\u03b1 \u03b9 \u03b3 A B C : Type _} [AddCommMonoid A] [AddCommMonoid B] [AddCommMonoid C]\n\nvariable {t : \u03b9 \u2192 A \u2192 C} (h0 : \u2200 i, t i 0 = 0) (h1 : \u2200 i x y, t i (x + y) = t i x + t i y)\n\nvariable {s : Finset \u03b1} {f : \u03b1 \u2192 \u03b9 \u2192\u2080 A} (i : \u03b9)\n\nvariable (g : \u03b9 \u2192\u2080 A) (k : \u03b9 \u2192 A \u2192 \u03b3 \u2192 B) (x : \u03b3)\n\nvariable {\u03b2 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 `\u03b2` 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 : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 N) : N :=\n  \u220f 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 : \u03b1 \u2192\u2080 M) {s : Finset \u03b1} (hs : f.support \u2286 s) (g : \u03b1 \u2192 M \u2192 N)\n    (h : \u2200 i \u2208 s, g i 0 = 1) : f.prod g = \u220f x in s, g x (f x) := by\n  refine Finset.prod_subset hs fun x hxs hx => h x hxs \u25b8 (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 \u03b1] (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 N) (h : \u2200 i, g i 0 = 1) :\n    f.prod g = \u220f 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 : \u03b1} {b : M} {h : \u03b1 \u2192 M \u2192 N} (h_zero : h a 0 = 1) :\n    (single a b).prod h = h a b :=\n  calc\n    (single a b).prod h = \u220f 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 \u25b8 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 \u2192 M'} {hf : f 0 = 0} {g : \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M' \u2192 N}\n    (h0 : \u2200 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 : \u03b1 \u2192 M \u2192 N} : (0 : \u03b1 \u2192\u2080 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 : \u03b1 \u2192\u2080 M) (g : \u03b2 \u2192\u2080 M') (h : \u03b1 \u2192 M \u2192 \u03b2 \u2192 M' \u2192 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 \u03b1] (f : \u03b1 \u2192\u2080 M) (a : \u03b1) (b : \u03b1 \u2192 M \u2192 N) :\n    (f.prod fun x v => ite (a = x) (b x v) 1) = ite (a \u2208 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 \u2191f a = 0 then 0 else \u2191f a\n-/\n-- @[simp]\ntheorem sum_ite_self_eq [DecidableEq \u03b1] {N : Type _} [AddCommMonoid N] (f : \u03b1 \u2192\u2080 N) (a : \u03b1) :\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 \u03b1] {N : Type _} [AddCommMonoid N] (f : \u03b1 \u2192\u2080 N) (a : \u03b1) :\n    (if a \u2208 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 \u21a6 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 \u03b1] (f : \u03b1 \u2192\u2080 M) (a : \u03b1) (b : \u03b1 \u2192 M \u2192 N) :\n    (f.prod fun x v => ite (x = a) (b x v) 1) = ite (a \u2208 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 \u03b1] {N : Type _} [AddCommMonoid N] (f : \u03b1 \u2192\u2080 N) (a : \u03b1) :\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 \u03b1] (f : \u03b1 \u2192\u2080 \u2115) (g : \u03b1 \u2192 N) :\n    (f.prod fun a b => g a ^ b) = \u220f a, g a ^ f a :=\n  f.prod_fintype _ fun _ \u21a6 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 \u03b1} {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M \u2192 N} (hf : \u2200 a, f a \u2260 0 \u2192 a \u2208 s)\n    (hg : \u2200 a, g a 0 = 1) : (onFinset s f hf).prod g = \u220f 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 : \u03b1 \u2192\u2080 M` is the same as multiplying the value on a single element\n`y \u2208 f.support` by the product over `erase y f`. -/\n@[to_additive\n      \" Taking a sum over over `f : \u03b1 \u2192\u2080 M` is the same as adding the value on a\n      single element `y \u2208 f.support` to the sum over `erase y f`. \"]\ntheorem mul_prod_erase (f : \u03b1 \u2192\u2080 M) (y : \u03b1) (g : \u03b1 \u2192 M \u2192 N) (hyf : y \u2208 f.support) :\n    g y (f y) * (erase y f).prod g = f.prod g := by\n  classical\n    rw [Finsupp.prod, Finsupp.prod, \u2190 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 : \u03b1 \u2192\u2080 M` is the same as multiplying the value on any element\n`y : \u03b1` 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 : \u03b1 \u2192\u2080 M` is the same as adding the value on any element\n      `y : \u03b1` to the sum over `erase y f`. \"]\ntheorem mul_prod_erase' (f : \u03b1 \u2192\u2080 M) (y : \u03b1) (g : \u03b1 \u2192 M \u2192 N) (hg : \u2200 i : \u03b1, 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 \u2208 f.support\n    \u00b7 exact Finsupp.mul_prod_erase f y g hyf\n    \u00b7 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 : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 N) (h : \u2200 c, f c \u2260 0 \u2192 g c (f c) \u2208 s) : f.prod g \u2208 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 : \u03b1 \u2192\u2080 M} {g1 g2 : \u03b1 \u2192 M \u2192 N} (h : \u2200 x \u2208 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 : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 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 \u2243* P)\n    (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 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 \u2192* P)\n    (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 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 \u2192+* S)\n    (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 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 \u2192+* S)\n    (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 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 \u21d1 on the rhs\n@[to_additive]\ntheorem MonoidHom.coe_finsupp_prod [Zero \u03b2] [Monoid N] [CommMonoid P] (f : \u03b1 \u2192\u2080 \u03b2)\n    (g : \u03b1 \u2192 \u03b2 \u2192 N \u2192* P) : \u21d1(f.prod g) = f.prod fun i fi => \u21d1(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 \u03b2] [Monoid N] [CommMonoid P] (f : \u03b1 \u2192\u2080 \u03b2)\n    (g : \u03b1 \u2192 \u03b2 \u2192 N \u2192* 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 : \u03b1) :\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 \u03b9) (f : \u03b9 \u2192 M) (a : \u03b1) :\n    single a (\u2211 b in s, f b) = \u2211 b in s, single a (f b) := by\n  trans\n  \u00b7 apply single_multiset_sum\n  \u00b7 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 : \u03b9 \u2192\u2080 M) (f : \u03b9 \u2192 M \u2192 N) (a : \u03b1) :\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 : \u03b1 \u2192\u2080 G} {h : \u03b1 \u2192 G \u2192 M}\n    (h0 : \u2200 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 \u03b9) (f : \u03b9 \u2192 \u03b1 \u2192\u2080 N) (a : \u03b1) :\n    (\u2211 i in S, f i) a = \u2211 i in S, f i a :=\n  (applyAddHom a : (\u03b1 \u2192\u2080 N) \u2192+ _).map_sum _ _\n#align finsupp.finset_sum_apply Finsupp.finset_sum_apply\n\n@[simp]\ntheorem sum_apply [Zero M] [AddCommMonoid N] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192 M \u2192 \u03b2 \u2192\u2080 N} {a\u2082 : \u03b2} :\n    (f.sum g) a\u2082 = f.sum fun a\u2081 b => g a\u2081 b a\u2082 :=\n  finset_sum_apply _ _ _\n#align finsupp.sum_apply Finsupp.sum_apply\n\n-- Porting note: inserted \u21d1 on the rhs\ntheorem coe_finset_sum [AddCommMonoid N] (S : Finset \u03b9) (f : \u03b9 \u2192 \u03b1 \u2192\u2080 N) :\n    \u21d1(\u2211 i in S, f i) = \u2211 i in S, \u21d1(f i) :=\n  (coeFnAddHom : (\u03b1 \u2192\u2080 N) \u2192+ _).map_sum _ _\n#align finsupp.coe_finset_sum Finsupp.coe_finset_sum\n\n-- Porting note: inserted \u21d1 on the rhs\ntheorem coe_sum [Zero M] [AddCommMonoid N] (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 \u03b2 \u2192\u2080 N) :\n    \u21d1(f.sum g) = f.sum fun a\u2081 b => \u21d1(g a\u2081 b) :=\n  coe_finset_sum _ _\n#align finsupp.coe_sum Finsupp.coe_sum\n\ntheorem support_sum [DecidableEq \u03b2] [Zero M] [AddCommMonoid N] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192 M \u2192 \u03b2 \u2192\u2080 N} :\n    (f.sum g).support \u2286 f.support.bunion\u1d62 fun a => (g a (f a)).support := by\n  have : \u2200 c, (f.sum fun a b => g a b c) \u2260 0 \u2192 \u2203 a, f a \u2260 0 \u2227 \u00ac(g a (f a)) c = 0 := fun a\u2081 h =>\n    let \u27e8a, ha, ne\u27e9 := Finset.exists_ne_zero_of_sum_ne_zero h\n    \u27e8a, mem_support_iff.mp ha, ne\u27e9\n  simpa only [Finset.subset_iff, mem_support_iff, Finset.mem_bunion\u1d62, sum_apply, exists_prop]\n#align finsupp.support_sum Finsupp.support_sum\n\ntheorem support_finset_sum [DecidableEq \u03b2] [AddCommMonoid M] {s : Finset \u03b1} {f : \u03b1 \u2192 \u03b2 \u2192\u2080 M} :\n    (Finset.sum s f).support \u2286 s.bunion\u1d62 fun x => (f x).support := by\n  rw [\u2190 Finset.sup_eq_bunion\u1d62]\n  induction' s using Finset.cons_induction_on with a s ha ih\n  \u00b7 rfl\n  \u00b7 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 : \u03b1 \u2192\u2080 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 : \u03b1 \u2192\u2080 M} {h\u2081 h\u2082 : \u03b1 \u2192 M \u2192 N} :\n    (f.prod fun a b => h\u2081 a b * h\u2082 a b) = f.prod h\u2081 * f.prod h\u2082 :=\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 : \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M \u2192 G} :\n    (f.prod fun a b => (h a b)\u207b\u00b9) = (f.prod h)\u207b\u00b9 :=\n  (map_prod (MonoidHom.id G)\u207b\u00b9 _ _).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 \u03b1] [AddZeroClass M] [CommMonoid N] {f g : \u03b1 \u2192\u2080 M}\n    {h : \u03b1 \u2192 M \u2192 N} (h_zero : \u2200 a \u2208 f.support \u222a g.support, h a 0 = 1)\n    (h_add : \u2200 a \u2208 f.support \u222a g.support, \u2200 (b\u2081 b\u2082), h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082) :\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, \u2190\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 : \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M \u2192 N}\n    (h_zero : \u2200 a, h a 0 = 1) (h_add : \u2200 a b\u2081 b\u2082, h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082) :\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 : \u03b1 \u2192\u2080 M} (h : \u03b1 \u2192 M \u2192+ 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 : \u03b1 \u2192\u2080 M}\n    (h : \u03b1 \u2192 Multiplicative M \u2192* 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 `\u03b1 \u2192 (M \u2192+ N)`\nand monoid homomorphisms `(\u03b1 \u2192\u2080 M) \u2192+ N`. -/\ndef liftAddHom [AddZeroClass M] [AddCommMonoid N] : (\u03b1 \u2192 M \u2192+ N) \u2243+ ((\u03b1 \u2192\u2080 M) \u2192+ N)\n    where\n  toFun F :=\n    { toFun := fun f \u21a6 f.sum fun x \u21a6 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 : \u03b1 \u2192 M \u2192+ N) (f : \u03b1 \u2192\u2080 M) :\n    (liftAddHom (\u03b1 := \u03b1) (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 : (\u03b1 \u2192\u2080 M) \u2192+ N) (x : \u03b1) :\n    (liftAddHom (\u03b1 := \u03b1) (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 : (\u03b1 \u2192\u2080 M) \u2192+ N) (x : \u03b1)\n    (y : M) : (liftAddHom (\u03b1 := \u03b1) (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 (\u03b1 := \u03b1) (M := M) (N := \u03b1 \u2192\u2080 M)) (singleAddHom : \u03b1 \u2192 M \u2192+ \u03b1 \u2192\u2080 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 : \u03b1 \u2192\u2080 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 \u03b1] (i : \u03b1) (m : M) :\n    (\u2211 j : \u03b1, (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 \u03b1] (i : \u03b1) (m : M) :\n    (\u2211 j : \u03b1, (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 : \u03b1 \u2192 M \u2192+ N) (a : \u03b1)\n    (b : M) : (liftAddHom (\u03b1 := \u03b1) (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 : \u03b1 \u2192 M \u2192+ N) (a : \u03b1) :\n    ((liftAddHom (\u03b1 := \u03b1) (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 \u2192+ P)\n    (f : \u03b1 \u2192 M \u2192+ N) :\n    g.comp ((liftAddHom (\u03b1 := \u03b1) (M := M) (N := N)) f) =\n      (liftAddHom (\u03b1 := \u03b1) (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 \u03b2] [AddCommGroup \u03b3] {f g : \u03b1 \u2192\u2080 \u03b2} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n    (h_sub : \u2200 a b\u2081 b\u2082, h a (b\u2081 - b\u2082) = h a b\u2081 - h a b\u2082) : (f - g).sum h = f.sum h - g.sum h :=\n  ((liftAddHom (\u03b1 := \u03b1) (M := \u03b2) (N := \u03b3)) 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 : \u03b1 \u2192\u2080 M} {f : \u03b1 \u21aa \u03b2} {g : \u03b2 \u2192 M \u2192 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 \u03b9} {g : \u03b9 \u2192 \u03b1 \u2192\u2080 M}\n    {h : \u03b1 \u2192 M \u2192 N} (h_zero : \u2200 a, h a 0 = 1) (h_add : \u2200 a b\u2081 b\u2082, h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082) :\n    (\u220f i in s, (g i).prod h) = (\u2211 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 : \u03b1 \u2192\u2080 M}\n    {g : \u03b1 \u2192 M \u2192 \u03b2 \u2192\u2080 N} {h : \u03b2 \u2192 N \u2192 P} (h_zero : \u2200 a, h a 0 = 1)\n    (h_add : \u2200 a b\u2081 b\u2082, h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082) :\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 (\u03b1 \u2192\u2080 M))\n    (h : \u03b1 \u2192 M \u2192 N) (h\u2080 : \u2200 a, h a 0 = 0)\n    (h\u2081 : \u2200 (a : \u03b1) (b\u2081 b\u2082 : M), h a (b\u2081 + b\u2082) = h a b\u2081 + h a b\u2082) :\n    f.sum.sum h = (f.map fun g : \u03b1 \u2192\u2080 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\u2080 h\u2081, ih]\n#align finsupp.multiset_sum_sum_index Finsupp.multiset_sum_sum_index\n\ntheorem support_sum_eq_bunion\u1d62 {\u03b1 : Type _} {\u03b9 : Type _} {M : Type _} [DecidableEq \u03b1]\n    [AddCommMonoid M] {g : \u03b9 \u2192 \u03b1 \u2192\u2080 M} (s : Finset \u03b9)\n    (h : \u2200 i\u2081 i\u2082, i\u2081 \u2260 i\u2082 \u2192 Disjoint (g i\u2081).support (g i\u2082).support) :\n    (\u2211 i in s, g i).support = s.bunion\u1d62 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  \u00b7 simp\n  \u00b7 intro i s hi\n    simp only [hi, sum_insert, not_false_iff, bunion\u1d62_insert]\n    intro hs\n    rw [Finsupp.support_add_eq, hs]\n    rw [hs, Finset.disjoint_bunion\u1d62_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\u1d62\n\ntheorem multiset_map_sum [Zero M] {f : \u03b1 \u2192\u2080 M} {m : \u03b2 \u2192 \u03b3} {h : \u03b1 \u2192 M \u2192 Multiset \u03b2} :\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 : \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M \u2192 Multiset N} :\n    Multiset.sum (f.sum h) = f.sum fun a b => Multiset.sum (h a b) :=\n  (Multiset.sumAddMonoidHom : Multiset N \u2192+ 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 : \u03b1 \u2192\u2080 M}\n    (hd : Disjoint f1.support f2.support) {\u03b2 : Type _} [CommMonoid \u03b2] (g : \u03b1 \u2192 M \u2192 \u03b2) :\n    (f1 + f2).prod g = f1.prod g * f2.prod g := by\n  have :\n    \u2200 {f1 f2 : \u03b1 \u2192\u2080 M},\n      Disjoint f1.support f2.support \u2192 (\u220f 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 [\u2190 this hd, \u2190 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 : \u03b1 \u2192\u2080 M}\n    {g1 g2 : \u03b1 \u2192 M \u2192 N} (h1 : f1.support \u2286 f2.support)\n    (h2 : \u2200 a : \u03b1, a \u2208 f1.support \u2192 g1 a (f1 a) \u2223 g2 a (f2 a)) : f1.prod g1 \u2223 f2.prod g2 := by\n  classical\n    simp only [Finsupp.prod, Finsupp.prod_mul]\n    rw [\u2190 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 \u03b1) (f : \u2200 a \u2208 s, M) :\n    indicator s f = \u2211 x in s.attach, single \u2191x (f x x.2) := by\n  rw [\u2190 sum_single (indicator s f), sum, sum_subset (support_indicator_subset _ _), \u2190 sum_attach]\n  \u00b7 refine' Finset.sum_congr rfl (fun _ _ => _)\n    rw [indicator_of_mem]\n  \u00b7 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 \u03b1} (f : \u2200 a \u2208 s, M) {h : \u03b1 \u2192 M \u2192 N} (h_zero : \u2200 a \u2208 s, h a 0 = 1) :\n    (indicator s f).prod h = \u220f x in s.attach, h \u2191x (f x x.2) := by\n  rw [prod_of_support_subset _ (support_indicator_subset _ _) h h_zero, \u2190 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' : (\u2211 k in s, f k) i = \u2211 k in s, f k i :=\n  (Finsupp.applyAddHom i : (\u03b9 \u2192\u2080 A) \u2192+ 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' : (\u2211 x in s, f x).sum t = \u2211 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 : \u03b1 \u2192\u2080 R) {f : \u03b1 \u2192 R \u2192 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 : \u03b1 \u2192\u2080 R) {f : \u03b1 \u2192 R \u2192 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 (\u00b7 ^ \u00b7)\n/-- If `0 : \u2115` is not in the support of `f : \u2115 \u2192\u2080 \u2115` then `0 < \u220f x in f.support, x ^ (f x)`. -/\ntheorem prod_pow_pos_of_zero_not_mem_support {f : \u2115 \u2192\u2080 \u2115} (hf : 0 \u2209 f.support) :\n    0 < f.prod (\u00b7 ^ \u00b7) :=\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 \u2192 Sort v}\n  (hvar : \u2200(k : fin n), C &k)\n  (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n  \u03a0 {l} (t : bounded_preterm L n l) (ts : dvector (bounded_term L n) l)\n  (ih_ts : \u2200s, ts.pmem s \u2192 C s), C (bd_apps t ts)\n| l (bd_var k) dvector.nil := \u03bb _, hvar k\n| l (bd_func f)  ts := \u03bb hs, hfunc f ts hs\n| l (bd_app t s) ts := \u03bb hs, bounded_term.rec2_aux t (dvector.cons s ts) $\n  \u03bb r hr, psum.cases_on hr\n    (\u03bb hrs, eq.rec_on hrs.symm (bounded_term.rec2_aux s dvector.nil $\n      \u03bb s\u2080 hs\u2080, false.elim $ by {cases hs\u2080}))\n    (hs _)\n\ndef bounded_term.rec2 {n} {C : bounded_term L n \u2192 Sort v}\n  (hvar : \u2200(k : fin n), C &k)\n  (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n  \u2200(t : bounded_term L n), C t :=\n\u03bbt, bounded_term.rec2_aux hvar (\u03bb _, hfunc) t dvector.nil (\u03bb s hs, false.elim $ by {cases hs})\n\n-- have h : \u2200{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\u2081 ([])) (f_ih_f\u2082 ([])), exact hall (f_ih ([]))\n-- end,\n-- \u03bbn f, h f ([])\n\n@[simp] def bounded_formula.rec2_aux {C : \u03a0n, bounded_formula L n \u2192 Sort v}\n  (hfalsum : \u03a0 {n}, C n \u22a5)\n  (hequal : \u03a0 {n} (t\u2081 t\u2082 : bounded_term L n), C n (t\u2081 \u2243 t\u2082))\n  (hrel : \u03a0 {n l : \u2115} (R : L.relations l) (ts : dvector (bounded_term L n) l),\n    C n (bd_apps_rel (bd_rel R) ts))\n  (himp : \u03a0 {n} {f\u2081 f\u2082 : bounded_formula L n} (ih\u2081 : C n f\u2081) (ih\u2082 : C n f\u2082), C n (f\u2081 \u27f9 f\u2082))\n  (hall : \u03a0 {n} {f : bounded_formula L (n+1)} (ih : C (n+1) f), C n (\u2200' f)) :\n  \u2200{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\u2081 \u2243 t\u2082) 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\u2081 \u27f9 f\u2082) dvector.nil := himp (bounded_formula.rec2_aux f\u2081 dvector.nil)\n  (bounded_formula.rec2_aux f\u2082 dvector.nil)\n| _ _ (\u2200' f)    dvector.nil := hall (bounded_formula.rec2_aux f dvector.nil)\n\n@[simp] def bounded_formula.rec2 {C : \u03a0n, bounded_formula L n \u2192 Sort v}\n  (hfalsum : \u03a0 {n}, C n \u22a5)\n  (hequal : \u03a0 {n} (t\u2081 t\u2082 : bounded_term L n), C n (t\u2081 \u2243 t\u2082))\n  (hrel : \u03a0 {n l : \u2115} (R : L.relations l) (ts : dvector (bounded_term L n) l),\n    C n (bd_apps_rel (bd_rel R) ts))\n  (himp : \u03a0 {n} {f\u2081 f\u2082 : bounded_formula L n} (ih\u2081 : C n f\u2081) (ih\u2082 : C n f\u2082), C n (f\u2081 \u27f9 f\u2082))\n  (hall : \u03a0 {n} {f : bounded_formula L (n+1)} (ih : C (n+1) f), C n (\u2200' f)) :\n  \u2200{n : \u2115} (f : bounded_formula L n), C n f :=\n\u03bb n f, bounded_formula.rec2_aux (\u03bb _, hfalsum) (\u03bb _, hequal) (\u03bb _ _, hrel) (\u03bb _ _ _, himp)\n  (\u03bb _ _, hall) f dvector.nil\n\n-- lemma bounded_term.rec2_aux_bd_apps {n} {C : bounded_term L n \u2192 Sort v}\n--   (hvar : \u2200(k : fin n), C &k)\n--   (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n--     (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n--   \u2200 {l} (t : bounded_preterm L n l) (ts : dvector (bounded_term L n) l)\n--     (ih_ts : \u2200t, ts.pmem t \u2192 C t),\n--   bounded_term.rec2_aux hvar (\u03bb _, 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 \u2192 Sort v}\n  (hvar : \u2200(k : fin n), C &k)\n  (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n  \u2200 (k : fin n),\n  bounded_term.rec2 hvar (\u03bb _, hfunc) &k = hvar k := \u03bb k, rfl\n\nlemma bounded_term.rec2_bd_apps {n} {C : bounded_term L n \u2192 Sort v}\n  (hvar : \u2200(k : fin n), C &k)\n  (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n  \u2200 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t),\n  bounded_term.rec2 hvar (\u03bb _, 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 : \u2115)\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\u2099` (with arity zero given by `pempty`)\n  For each `\u27e8 n , f \u27e9 : \u03a3 n : \u2115, L.functions n` we have a function application (with arity `n`) -/\n@[reducible] def term_\u03b1 := ulift.{u} (fin n) \u2295 \u03a3 m : ulift.{u} \u2115, L.functions m.down\n\n/-- To define the arities in the `W_type` for `closed_term`.\n  For each `n : \u2115` we have a variable `x\u2099` (with arity zero given by `pempty`)\n  For each `\u27e8 n , f \u27e9 : \u03a3 n : \u2115, L.functions n` we have a function application (with arity `n`) -/\n@[reducible] def term_\u03b2 : \u03a0 (c : term_\u03b1.{u} L n), Type u\n| (sum.inl m) := pempty.{u+1}\n| (sum.inr \u27e8 m , f \u27e9) := ulift.{u} (fin m.down)\n\nvariable {L}\n\n/-- The forward map of the equivalence `W_type_term_\u03b2_equiv_closed_term` -/\n@[reducible] def bounded_term_of_W_type_term_\u03b2 : W_type (term_\u03b2 L n) \u2192 bounded_term L n\n| \u27e8 sum.inl m , b \u27e9 := x_ m.down\n| \u27e8 sum.inr (\u27e8 n , f \u27e9) , b \u27e9 := bd_apps (bd_func f)\n  (dvector.of_fn (\u03bb k, bounded_term_of_W_type_term_\u03b2 $ b (ulift.up k)))\n\n/-- The forward map of the equivalence `W_type_term_\u03b2_equiv_closed_term` -/\n@[reducible] def W_type_term_\u03b2_of_bounded_term : bounded_term L n \u2192 W_type (term_\u03b2 L n) :=\n  bounded_term.rec2\n    (\u03bb m, \u27e8 sum.inl \u27e8m\u27e9 , pempty.elim \u27e9) $\n    \u03bb l f ts rec,\n    \u27e8 sum.inr \u27e8 ulift.up l , f \u27e9, \u03bb k : ulift (fin l), rec (dvector.nth' ts $ k.down) dvector.pmem_nth' \u27e9\n\nlemma bounded_term_of_W_type_term_\u03b2_right_inv : \u2200 t : bounded_term L n,\n  bounded_term_of_W_type_term_\u03b2 n (W_type_term_\u03b2_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_\u03b2_of_bounded_term],\n    rw bounded_term.rec2_bd_apps _ _ _ _ (\u03bb t _, W_type_term_\u03b2_of_bounded_term n t),\n    dsimp [bounded_term_of_W_type_term_\u03b2],\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_\u03b2_surjective :\n  function.surjective (@bounded_term_of_W_type_term_\u03b2 L n) :=\nbegin\n  intros t,\n  use W_type_term_\u03b2_of_bounded_term n t,\n  exact bounded_term_of_W_type_term_\u03b2_right_inv _ _,\nend\n\nlemma fintype_term_\u03b2 : \u03a0 (a : term_\u03b1 L n), fintype (term_\u03b2 L n a)\n| (sum.inl \u27e8 m \u27e9) := by apply_instance\n| (sum.inr \u27e8 m , f \u27e9) := fintype.of_equiv (fin m.down) equiv.ulift.symm\n\nlocal attribute [instance] fintype_term_\u03b2\n\nlemma bounded_term_le_functions : #(bounded_term L n) \u2264\n  max (cardinal.sum (\u03bb n : ulift.{u} (\u2115), #(L.functions n.down))) \u03c9 :=\ncalc #(bounded_term L n)\n      \u2264 #(W_type (term_\u03b2.{u} L n)) :\n    cardinal.mk_le_of_surjective (bounded_term_of_W_type_term_\u03b2_surjective n)\n  ... \u2264 max (# (ulift.{u} (fin n) \u2295 \u03a3 (m : ulift.{u} \u2115), L.functions m.down)) \u03c9 :\n    W_type.cardinal_mk_le_max_omega_of_fintype\n  ... \u2264 max (#(\u03a3 n : ulift.{u} \u2115, L.functions n.down)) \u03c9 :\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 (\u03bb n : ulift.{u} \u2115, #(L.functions n.down))) \u03c9 :\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  | \u22a5           | unit                 | empty |\n  | t\u2081 \u2243 t\u2082     | (bounded_term L n)\u00b2  | empty |\n  | \u27f9           | unit                 | bool  |\n  ```\n  This gives us a way of injecting `bounded_formula L n`\n  into `W_type \u03b2 n \u2295 bounded_formula L (n+1)` (to account for `\u2200`) (there are no relations).\n  This ultimately gives us\n  `bounded_formula L 0 \u21aa \u03a3 n : \u2115, W_type \u03b2 n ` where instead of\n  mapping into `bounded_formula L (n+1)` we map into the next `W_type \u03b2 (n+1)`.\n  We have bounds on each `W_type \u03b2 n`, namely by `unit`, `(bounded_term L n)\u00b2` and `\u03c9`.\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 : \u2115 \u2192 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_\u03b1 : Type u := punit.{u+1} \u2295 ((bounded_term L n) \u00d7 (bounded_term L n)) \u2295 punit.{u+1}\n\n@[reducible] def atomic_formula_\u03b2 : atomic_formula_\u03b1 L n \u2192 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 `\u2295` `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_\u03b1 : Type u := atomic_formula_\u03b1 L n \u2295 (bounded_formula L (n+1))\n\n/-- The arities of the constructors `formula_\u03b1` for the `W_type` -/\n@[reducible] def formula_\u03b2 : formula_\u03b1 L n \u2192 Type u\n| (sum.inl x) := atomic_formula_\u03b2 L n x\n| (sum.inr x) := pempty.{u+1}\n\nlemma fintype_formula_\u03b2 : \u03a0 (a : formula_\u03b1 L n), fintype (formula_\u03b2 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_\u03b2\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 `\u2200` 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 \u2192 W_type (formula_\u03b2 L n) :=\nbounded_formula.rec2\n  (\u03bb _, \u27e8 sum.inl $ sum.inl punit.star , pempty.elim \u27e9) -- bd_falsum\n  (\u03bb _ t s, \u27e8 sum.inl $ sum.inr $ sum.inl \u27e8 t , s \u27e9 , pempty.elim \u27e9) -- t \u2243 s\n  (\u03bb _ l r, false.elim $ Language.is_algebraic.empty_relations l r) -- there are no relation symbols\n  (\u03bb _ f\u2081 f\u2082 recf\u2081 recf\u2082, \u27e8 sum.inl $ sum.inr $ sum.inr punit.star ,\n    \u03bb \u27e8b\u27e9, bool.rec_on b recf\u2081 recf\u2082 \u27e9 ) -- bd_imp\n  (\u03bb _ f _, \u27e8 sum.inr f , pempty.elim \u27e9) -- 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_\u03b2 L n) \u2192 bounded_formula L n\n| \u27e8 (sum.inl (sum.inl x)) , y \u27e9 := \u22a5\n| \u27e8 sum.inl (sum.inr (sum.inl \u27e8 t , s \u27e9)) , y \u27e9 := t \u2243 s\n| \u27e8 sum.inl (sum.inr (sum.inr x)) , y \u27e9 :=\n  bounded_formula_of_W_type (y $ \u27e8 ff \u27e9) \u27f9\n  bounded_formula_of_W_type (y $ \u27e8 tt \u27e9)\n| \u27e8 sum.inr f , y \u27e9 := \u2200' f\n\nlemma bounded_formula_of_W_type_left_inv\n  [is_algebraic L] {n} : \u2200 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 \u27e8 h1 , h2 \u27e9 },\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_\u03b2 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 \u27e8 ff \u27e9,\n    have htt := hind \u27e8 tt \u27e9,\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 \u22a2 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_\u03b2 L n)` are equivalent -/\ndef bounded_formula_equiv_W_type [is_algebraic L] (n : \u2115) :\n  _root_.equiv (bounded_formula L n) (W_type (formula_\u03b2 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 : \u2115 \u2192 Type u\n| base {n} : box n\n| succ {n} : box n \u2192 box n\n| drop {n} (x : box (n+1)) : box n\n\ndef nat_of_box : \u2200 n, box n \u2192 \u2115 \u00d7 \u2115 \u00d7 \u2115\n| n (box.base) := \u27e8 n , 0 , 0 \u27e9\n| n (box.succ x) := \u27e8 (nat_of_box n x).1, (nat_of_box n x).2.1.succ , (nat_of_box n x).2.2 \u27e9\n| n (box.drop x) := \u27e8(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 \u27e9\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 : \u03a0 (l : \u2115), bounded_term L l \u2192 logic_symbol\n| nat : \u2115 \u2192 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 \u2192 list (logic_symbol L) :=\nbounded_formula.rec2\n  (\u03bb l, [logic_symbol.nat l, logic_symbol.bot]) -- \u22a5\n  (\u03bb l t s, [ logic_symbol.nat l, logic_symbol.eq ,\n    logic_symbol.term l t , logic_symbol.term l s ]) -- t \u2243 s\n  (\u03bb _ _ r, false.elim $ Language.is_algebraic.empty_relations _ r) -- bd_rel\n  (\u03bb l \u03d5 \u03c8 l\u03d5 l\u03c8, (logic_symbol.nat l) :: (logic_symbol.nat (list.length l\u03d5))\n    :: (logic_symbol.nat (list.length l\u03c8)) :: logic_symbol.imp :: l\u03d5.append l\u03c8 ) -- \u03d5 \u27f9 \u03c8\n  (\u03bb l \u03d5 l\u03d5, (logic_symbol.nat l) :: logic_symbol.all :: l\u03d5) -- \u2200\u2097 \u03d5\n\nlemma logic_symbol_of_preformula_injective [is_algebraic L] {n} : \u2200 (x : bounded_formula L n)\n  {m} (y : bounded_formula L m),\n  logic_symbol_of_formula x = logic_symbol_of_formula y \u2192 x == y :=\nbegin\n  -- apply bounded_formula.rec2,\n  have hrel : \u2200 {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 _ (\u03bb _ x, \u2200 {m} (y : bounded_formula L m),\n    logic_symbol_of_formula x = logic_symbol_of_formula y \u2192 x == y),\n  { intro l,\n    apply @bounded_formula.rec2 _ (\u03bb n y,\n      logic_symbol_of_formula _ = logic_symbol_of_formula y \u2192 _ == 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 _ (\u03bb n y,\n      logic_symbol_of_formula _ = logic_symbol_of_formula y \u2192 _ == 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\u2081 f\u2082 hf\u2081 hf\u2082,\n    apply @bounded_formula.rec2 _ (\u03bb n y,\n      logic_symbol_of_formula _ = logic_symbol_of_formula y \u2192 _ == 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\u2081' f\u2082' hf\u2081' hf\u2082' h, simp at h, obtain \u27e8 hll' , hlen\u03d5 , hlen\u03c8 , h \u27e9 := h,\n      subst hll', obtain \u27e8 hf\u2081f\u2081' , hf\u2082f\u2082'\u27e9 := list.append_inj h hlen\u03d5, congr,\n      { simp at hf\u2081, specialize hf\u2081 f\u2081' hf\u2081f\u2081', subst hf\u2081 },\n      { simp at hf\u2082, specialize hf\u2082 f\u2082' hf\u2082f\u2082', subst hf\u2082 } },\n    { intros _ _ _ h, simp at h, simpa [h] } },\n  { intros l f\u2081 hf\u2081 m, apply @bounded_formula.rec2 _\n      (\u03bb n y, logic_symbol_of_formula _ = logic_symbol_of_formula y \u2192 _ == 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\u2082 hf\u2082 h, simp only [logic_symbol_of_formula, bounded_formula.rec2_aux,\n        bounded_formula.rec2, eq_self_iff_true, true_and] at h hf\u2081,\n      cases h with hlk h, subst hlk, congr1, apply eq_of_heq, apply hf\u2081, exact h } },\nend\n\nlemma card_le_max [is_algebraic L] {n} (hn : #(bounded_formula L (n + 1))\n    \u2264 max (cardinal.sum (\u03bb (m : ulift.{u} \u2115), #(bounded_term L m.down))) \u03c9) :\n  #(bounded_formula L n)\n    \u2264 max (cardinal.sum (\u03bb m : ulift.{u} \u2115, #(bounded_term L m.down))) \u03c9 :=\ncalc #(bounded_formula L n)\n        = #(W_type (formula_\u03b2 L n)) :\n  cardinal.mk_congr (bounded_formula_equiv_W_type _)\n    ... \u2264 _ : W_type.cardinal_mk_le_max_omega_of_fintype\n    ... \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(bounded_term L n.down))) \u03c9 :\nbegin\n  dsimp only [formula_\u03b1, atomic_formula_\u03b1],\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} (\u03bb (n : ulift.{u} \u2115), #(bounded_term.{u} L n.down)) \u27e8 n \u27e9 }},\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) \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(bounded_term L n.down))) \u03c9 :=\ncalc #(bounded_formula L n)\n        = #(W_type (formula_\u03b2 L n)) :\n  cardinal.mk_congr (bounded_formula_equiv_W_type _)\n    ... \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(bounded_term L n.down))) \u03c9 : sorry\n\n\nlemma sentence_le_bounded_term :\n  #(bounded_formula L 0) \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(bounded_term L n.down))) \u03c9 :=\ncalc #(bounded_formula L 0) \u2264 #(W_type (formula_\u03b2 L 0)) : sorry\n     ... \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(bounded_term L n.down))) \u03c9 : sorry\n\nlemma sentence_le_functions :\n  #(bounded_formula L 0) \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(L.functions n.down))) \u03c9 :=\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 `\u2200` is an injection downwards. -/\ndef bounded_formula_bd_all : bounded_formula L (n+1) \u2192 (bounded_formula L n) :=\n\u03bb \u03d5, \u2200' \u03d5\n\n/-- Applying `\u2200` n times is an injection. \"Dropbox\" -/\ndef bounded_formula_bd_alls : \u03a0 n, bounded_formula L n \u2192 (bounded_formula L 0)\n| 0 := id\n| (n+1) := (bounded_formula_bd_alls n) \u2218 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\u03bb \u03d5 \u03c8, bounded_preformula.bd_all.inj\n\nlemma bounded_formula_bd_alls_injective : \u03a0 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 \u2200 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 : \u2115) :\n  #(bounded_formula L n) \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(L.functions n.down))) \u03c9 :=\ncalc #(bounded_formula L n) \u2264 #(bounded_formula L 0) : cardinal.mk_le_of_injective (bounded_formula_bd_alls_injective _)\n                        ... \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(L.functions n.down))) \u03c9 :\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  (\u2203 (V1 V2 : set G), (\u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) \u2227 (\u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)))) \u2194 (\u2203 (V1 V2 : set G), (\u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) \u2227 (\u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)))) :=\nbegin\n  have h1 : (\u2203 (V1 V2 : set G), (\u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) \u2227 (\u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)))), from by {\n    assume (V1 : set G) (V2 : set G) (h1 : \u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) (h2 : \u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1))),\n    have h3 : \u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2, from by assume v : G,\n      have (v \u2208 V1 \u2228 v \u2208 V2) \u2228 (v \u2208 V1 \u2228 v \u2208 V2), from or.inl (h1 v),\n      or.elim (or.inl (h1 v)) (\n        assume h4 : v \u2208 V1 \u2228 v \u2208 V2,\n        show v \u2208 V1 \u2228 v \u2208 V2, from or.inl h4\n      ) (\n        assume h5 : v \u2208 V1 \u2228 v \u2208 V2,\n        show v \u2208 V1 \u2228 v \u2208 V2, from or.inr h5\n      ),\n    have h4 : \u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)), from by assume (e : G) (he : edge e),\n      have ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)) \u2228 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)), from or.inl (h2 e he),\n      or.elim (or.inl (h2 e he)) (\n        assume h5 : (e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1),\n        show (e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1), from or.inl h5\n      ) (\n        assume h6 : (e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1),\n        show (e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1), from or.inr h6\n      ),\n    have h5 : (\u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) \u2227 (\u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1))), from and.intro h3 h4,\n    show \u2203 (V1 V2 : set G), (\u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) \u2227 (\u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1))), from exists.intro V1 (exists.intro V2 h5),\n  },\n  have h2 : (\u2203 (V1 V2 : set G), (\u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) \u2227 (\u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)))), from by {\n    assume (V1 : set G) (V2 : set G) (h1 : \u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) (h2 : \u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1))),\n    have h3 : \u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2, from by assume v : G,\n      have (v \u2208 V1 \u2228 v \u2208 V2) \u2228 (v \u2208 V1 \u2228 v \u2208 V2), from or.inr (h1 v),\n      or.elim (or.inr (h1 v)) (\n        assume h4 : v \u2208 V1 \u2228 v \u2208 V2,\n        show v \u2208 V1 \u2228 v \u2208 V2, from or.inl h4\n      ) (\n        assume h5 : v \u2208 V1 \u2228 v \u2208 V2,\n        show v \u2208 V1 \u2228 v \u2208 V2, from or.inr h5\n      ),\n    have h4 : \u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)), from by assume (e : G) (he : edge e),\n      have ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)) \u2228 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1)), from or.inr (h2 e he),\n      or.elim (or.inr (h2 e he)) (\n        assume h5 : (e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1),\n        show (e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1), from or.inl h5\n      ) (\n        assume h6 : (e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1),\n        show (e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1), from or.inr h6\n      ),\n    have h5 : (\u2200 (v : G), v \u2208 V1 \u2228 v \u2208 V2) \u2227 (\u2200 (e : G), (edge e) \u2192 ((e.left \u2208 V1 \u2227 e.right \u2208 V2) \u2228 (e.left \u2208 V2 \u2227 e.right \u2208 V1))), from and.intro h3 h4,\n    show \u2203 (V1 V2 : set G\nend --Needs more than 2000 tokens!\n\n--OUTPUT 2\ntheorem bipartite_graph_is_two_colorable (G : Type*) [graph G] : \u2200 g : G, twocolorable g \u2194 bipartite g :=\nbegin\n  assume (g : G),\n  have h1 : twocolorable g \u2192 bipartite g, from by {\n    assume h2 : twocolorable g,\n    have h3 : \u2203 a b : set (vertex g), a \u2229 b = \u2205 \u2227 a \u222a b = vertex g \u2227 \u2200 e : edge g, (endpoint g e).fst \u2208 a \u2227 (endpoint g e).snd \u2208 b, from by {\n      have h4 : \u2203 a b : vertex g, color g a \u2260 color g b, from by {\n        have h5 : \u2200 v : vertex g, color g v = red \u2228 color g v = blue, from by {\n          assume v : vertex g,\n          have h6 : \u2200 v : vertex g, color g v = red, from by {\n            assume v : vertex g,\n            have h7 : \u2200 v : vertex g, \u2203 c : color g v, color g v = c, from by {\n              assume v : vertex g,\n              show \u2203 c : color g v, color g v = c, from by {\n                have h8 : color g v = red \u2228 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 \u2200 v : vertex g, color g v = red \u2228 color g v = blue, from by {\n            assume v : vertex g,\n            have h6 : color g v = red \u2228 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 \u2203 a b : vertex g, color g a \u2260 color g b, from by {\n          have h6 : \u2203 a : vertex g, color g a = red, from by {\n            have h7 : \u2200 a : vertex g, color g a = red, from by {\n              assume a : vertex g,\n              have h8 : \u2203 c : color g a, color g a = c, from by {\n                have h9 : color g a = red \u2228 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 \u2203 a : vertex g, color g a = red, from by {\n              have h8 : \u2200 a : vertex g, \u2203 c : color g a, color g a = c, from by {\n                assume a : vertex g,\n                show \u2203 c : color g a, color g a = c, from by {\n                  have h9 : color g a = red \u2228 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 \u2203 a : vertex g, color g a = red, from (h8 (arbitrary_vertex g)).elim (assume c, assume h10, \u27e8arbitrary_vertex g, h10\u27e9),\n            },\n          },\n          have h7 : \u2203 b : vertex g, color g b = blue, from by {\n            have h8 : \u2203 b : vertex g, color g b = blue, from by {\n              have h9 : \u2200 b : vertex g, color g b = blue, from by {\n                assume b : vertex g,\n                have h10 : \u2203 c : color g b, color g b = c, from by {\n                  have h11 : color g b = red \u2228 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 \u2203 b : vertex g, color g b = blue, from by {\n                have h10 : \u2200 b : vertex g, \u2203 c : color g b, color g b = c, from by {\n                  assume b : vertex g,\n                  show \u2203 c : color g b, color g b = c, from by {\n                    have h11 : color g b = red \u2228 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 \u2203 b : vertex g, color g b = blue, from (h10 (arbitrary_vertex g)).elim (assume c, assume h12, \u27e8arbitrary_vertex g, h12\u27e9),\n              },\n            },\n            show \u2203 b : vertex g, color g b = blue, from by {\n              have h9 : \u2203 b : vertex g, color g b = blue, from by {\n                have h10 : \u2200 b : vertex g, color g b = blue, from by {\n                  assume b : vertex g,\n                  have h11 : \u2203 c : color g b, color g b = c, from by {\n                    have h12 : color g b = red \u2228 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 \u2203 b : vertex g, color g b = blue, from by {\n                  have h11 : \u2200 b : vertex g, \u2203 c : color g b, color g b = c, from by {\n                    assume b : vertex g,\n                    show \u2203 c : color g b, color g b = c, from by {\n                      have h12 : color g b = red \u2228 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 \u2203 b : vertex g, color g b = blue, from (h11 (arbitrary_vertex g)).elim (assume c, assume h12, \u27e8arbitrary_vertex g, h12\u27e9),\n                },\n              },\n              show \u2203 b : vertex g, color g b = blue, from by {\n                have h10 : \u2203 b : vertex g, color g b = blue, from by {\n                  have h11 : \u2200 b : vertex g, color g b = blue, from by {\n                    assume b : vertex g,\n                    have h12 : \u2203 c : color g b, color g b = c, from by {\n                      have h13 : color g b = red \u2228 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 \u2203 b : vertex g, color g b = blue, from by {\n                    have h12 : \u2200 b : vertex g, \u2203 c : color g b, color g b = c, from by {\n                      assume b : vertex g,\n                      show \u2203 c : color g b, color g b = c, from by {\n                        have h13 : color g b = red \u2228 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 \u2194 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 := \u03bb v, if v \u2208 h.left then 0 else 1},\n      -- this is a valid coloring\n      have hval : \u2200 v, v \u2208 (vertex_set G) \u2192 (color_map v) \u2208 (colors), from by {\n        assume v hv,\n        have hl : v \u2208 h.left \u2192 (color_map v) \u2208 (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 \u2208 h.right \u2192 (color_map v) \u2208 (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 : \u2200 e, e \u2208 (edge_set G) \u2192 (color_map e.x) \u2260 (color_map e.y), from by {\n        assume e he,\n        have hx : e.x \u2208 h.left \u2228 e.x \u2208 h.right, from by apply set.mem_or_mem_of_mem_union,\n        have hy : e.y \u2208 h.left \u2228 e.y \u2208 h.right, from by apply set.mem_or_mem_of_mem_union,\n        unfold color_map,\n        have hnx : e.x \u2209 h.left \u2192 e.x \u2208 h.right, from by {\n          assume hnx,\n          apply set.mem_of_mem_diff hx,\n          exact hnx,\n        },\n        have hny : e.y \u2209 h.left \u2192 e.y \u2208 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 \u2208 h.left)) (\u03bb hl, or.elim (em (e.y \u2208 h.left)) (\u03bb hyl, (mt dif_pos hl) hyl) (\u03bb hyr, (mt dif_pos hl) hyr)) (\u03bb hr, or.elim (em (e.y \u2208 h.left)) (\u03bb hyl, (mt dif_neg (hnx hr)) hyl) (\u03bb hyr, (mt dif_neg (hnx hr)) hyr))\n      },\n      exact \u27e8hval,hne\u27e9,\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 : \u2200 e, e \u2208 (edge_set G) \u2192 e.x \u2208 (h.left) \u2192 e.y \u2208 (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) \u2260 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 \u27e8hne\u27e9,\n    }\n  }\nend\n\n--OUTPUT 4\ntheorem two_colorable_graph_is_bipartite (G : Type*) [simple_graph G] : \n  \u2200 (V1 V2 : set G) (h1 : disjoint V1 V2) (h2 : \u2200 v w : G, v \u2260 w \u2192 (v \u2208 V1 \u2227 w \u2208 V2) \u2228 (v \u2208 V2 \u2208 w \u2208 V1)), \n    \u2200 v : G, \u2203! 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 : \u2200 v w : G, v \u2260 w \u2192 (v \u2208 V1 \u2227 w \u2208 V2) \u2228 (v \u2208 V2 \u2227 w \u2208 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 | \u2203 c : color, color_graph G v c \u2227 c = red},\n  let B := {v : G | \u2203 c : color, color_graph G v c \u2227 c = blue},\n\n  -- Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n  have h3 : \u2200 v w : G, (v \u2208 A \u2227 w \u2208 A) \u2192 \u00ac edge_graph G v w, from assume v w : G, assume h3 : (v \u2208 A \u2227 w \u2208 A),\n    have h4 : \u2203 c1 : color, color_graph G v c1 \u2227 c1 = red, from h3.left,\n    have h5 : \u2203 c2 : color, color_graph G w c2 \u2227 c2 = red, from h3.right,\n    have h6 : color_graph G v red \u2227 color_graph G w red, from and.intro (h4.left) (h5.left),\n    show \u00ac edge_graph G v w, from by {apply two_color_graph_no_edge,exact h6},\n  have h4 : \u2200 v w : G, (v \u2208 B \u2227 w \u2208 B) \u2192 \u00ac edge_graph G v w, from assume v w : G, assume h4 : (v \u2208 B \u2227 w \u2208 B),\n    have h5 : \u2203 c1 : color, color_graph G v c1 \u2227 c1 = blue, from h4.left,\n    have h6 : \u2203 c2 : color, color_graph G w c2 \u2227 c2 = blue, from h4.right,\n    have h7 : color_graph G v blue \u2227 color_graph G w blue, from and.intro (h5.left) (h6.left),\n    show \u00ac 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 : \u2200 v w : G, edge_graph G v w \u2192 (v \u2208 A \u2227 w \u2208 B) \u2228 (v \u2208 B \u2227 w \u2208 A), from \n    assume v w : G, assume h5 : edge_graph G v w,\n    have h6 : \u00ac color_graph G v red \u2228 \u00ac color_graph G w red, from by {apply two_color_graph_no_edge,exact h5},\n    have h7 : \u00ac color_graph G v blue \u2228 \u00ac color_graph G w blue, from by {apply two_color_graph_no_edge,exact h5},\n    or.elim h6 (assume h8 : \u00ac color_graph G v red, or.elim h7 (assume h9 : \u00ac color_graph G w blue,\n      begin\n        have h10 : \u2203 c1 : color, color_graph G v c1 \u2227 c1 = blue, from by {use blue, exact and.intro h9 rfl},\n        have h11 : \u2203 c2 : color, color_graph G w c2 \u2227 c2 = red, from by {use red, exact and.intro h8 rfl},\n        show (v \u2208 B \u2227 w \u2208 A) \u2228 (v \u2208 A \u2227 w \u2208 B), from by {right,exact \u27e8h10,h11\u27e9},\n      end\n    )\n    (assume h9 : color_graph G w blue,\n      begin\n        have h10 : \u2203 c1 : color, color_graph G v c1 \u2227 c1 = blue, from by {use blue, exact and.intro h9 rfl},\n        have h11 : \u2203 c2 : color, color_graph G w c2 \u2227 c2 = blue, from by {use blue, exact h9},\n        show (v \u2208 B \u2227 w \u2208 A) \u2228 (v \u2208 A \u2227 w \u2208 B), from by {left,exact \u27e8h10,h11\u27e9},\n      end\n    )\n    )\n    (assume h8 : color_graph G v red, or.elim h7 (assume h9 : \u00ac color_graph G w blue,\n      begin\n        have h10 : \u2203 c1 : color, color_graph G v c1 \u2227 c1 = red, from by {use red, exact h8},\n        have h11 : \u2203 c2 : color, color_graph G w c2 \u2227 c2 = red, from by {use red, exact and.intro h9 rfl},\n        show (v \u2208 B \u2227 w \u2208 A) \u2228 (v \u2208 A \u2227 w \u2208 B), from by {right,exact \u27e8h10,h11\u27e9},\n      end\n    )\n    (assume h9 : color_graph G w blue,\n      begin\n        have h10 : \u2203 c1 : color, color_graph G v c1 \u2227 c1 = red, from by {use red, exact h8},\n        have h11 : \u2203 c2 : color, color_graph G w c2 \u2227 c2 = blue, from by {use blue, exact h9},\n        show (v \u2208 B \u2227 w \u2208 A) \u2228 (v \u2208 A \u2227 w \u2208 B), from by {left,exact \u27e8h10,h11\u27e9},\n      end\n    )\n    ),\n  have h6 : \u2200 v w : G, edge_graph G v w \u2192 v \u2208 A \u2227 w \u2208 B, from assume v w : G, assume h6 : edge_graph G v w,\n    or.elim (h5 v w h6) (assume h7 : v \u2208 B \u2227 w \u2208 A,\n      begin\n        have h8 : v \u2208 A \u2227 w \u2208 B, from by {split,\n          show v \u2208 A, from by {rw A,existsi red,exact \u27e8h7.right.left,rfl\u27e9},\n          show w \u2208 B, from by {rw B,existsi blue,exact \u27e8h7.left.left,rfl\u27e9},},\n        exact h8,\n      end\n    )\n    (assume h7 : v \u2208 A \u2227 w \u2208 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 : \u2200 v w : G, edge_graph G v w \u2192 v \u2208 V1 \u2227 w \u2208 V2 \u2228 v \u2208 V2 \u2227 w \u2208 V1, from \n    assume v w : G, assume h7 : edge_graph G v w, h6 v w h7,\n  have h8 : \u2200 v w : G, v \u2208 V1 \u2227 w \u2208 V2 \u2192 edge_graph G v w, from \n    assume v w : G, assume h8 : v \u2208 V1 \u2227 w \u2208 V2, or.elim (h7 v\nend --Needs more than 2000 tokens!\n\n--OUTPUT 5\ntheorem two_coloring_bipartite (G : Type*) [graph G] : \n  (\u2200 A B : G, \u2200 x y : G, (x \u2208 A \u2227 y \u2208 B) \u2228 (x \u2208 B \u2227 y \u2208 A)) \u2194 (\u2203 A B : G, \u2200 x y : G, (x \u2208 A \u2227 y \u2208 B) \u2228 (x \u2208 B \u2227 y \u2208 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 : \u2200 A B : G, \u2200 x y : G, (x \u2208 A \u2227 y \u2208 B) \u2228 (x \u2208 B \u2227 y \u2208 A),\n    show \u2203 A B : G, \u2200 x y : G, (x \u2208 A \u2227 y \u2208 B) \u2228 (x \u2208 B \u2227 y \u2208 A), from\n    begin\n      use {A : G | true},\n      use {B : G | true},\n      assume x y : G,\n      have h3 : \u2203! C : G, x \u2208 C, from by {\n        use {x : G | true},\n        rw mem_set_of,\n        exact \u27e8trivial, by {obviously}\u27e9,\n      },\n      have h4 : \u2203! D : G, y \u2208 D, from by {\n        use {y : G | true},\n        rw mem_set_of,\n        exact \u27e8trivial, by {obviously}\u27e9,\n      },\n      have h5 : \u2203! A : G, x \u2208 A, from by {\n        have h6 : \u2203! A : G, (\u2203 z : G, z \u2208 A), from by {\n          use {A : G | true},\n          obviously,\n        },\n        have h7 : \u2203! A : G, (\u2203 z : G, z \u2208 A) \u2227 x \u2208 A, from by {\n          use {A : G | x \u2208 A},\n          obviously,\n        },\n        exact h7,\n      },\n      have h8 : \u2203! B : G, y \u2208 B, from by {\n        have h9 : \u2203! B : G, (\u2203 z : G, z \u2208 B), from by {\n          use {B : G | true},\n          obviously,\n        },\n        have h10 : \u2203! B : G, (\u2203 z : G, z \u2208 B) \u2227 y \u2208 B, from by {\n          use {B : G | y \u2208 B},\n          obviously,\n        },\n        exact h10,\n      },\n      have h11 : \u2203! C : G, x \u2208 C \u2227 y \u2208 C, from by {\n        use {C : G | x \u2208 C \u2227 y \u2208 C},\n        obviously,\n      },\n      have h12 : \u2203! A : G, x \u2208 A \u2227 y \u2208 A, from by {\n        have h13 : \u2203! A : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 A), from by {\n          use {A : G | true},\n          obviously,\n        },\n        have h14 : \u2203! A : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 A) \u2227 x \u2208 A \u2227 y \u2208 A, from by {\n          use {A : G | x \u2208 A \u2227 y \u2208 A},\n          obviously,\n        },\n        exact h14,\n      },\n      have h15 : \u2203! B : G, x \u2208 B \u2227 y \u2208 B, from by {\n        use {B : G | x \u2208 B \u2227 y \u2208 B},\n        obviously,\n      },\n      have h16 : \u2203! A : G, x \u2208 A \u2227 y \u2208 B, from by {\n        have h17 : \u2203! A : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B), from by {\n          use {A : G | true},\n          obviously,\n        },\n        have h18 : \u2203! A : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 x \u2208 A \u2227 y \u2208 B, from by {\n          use {A : G | x \u2208 A \u2227 y \u2208 B},\n          obviously,\n        },\n        exact h18,\n      },\n      have h19 : \u2203! B : G, x \u2208 B \u2227 y \u2208 A, from by {\n        have h20 : \u2203! B : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B), from by {\n          use {B : G | true},\n          obviously,\n        },\n        have h21 : \u2203! B : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 x \u2208 B \u2227 y \u2208 A, from by {\n          use {B : G | x \u2208 B \u2227 y \u2208 A},\n          obviously,\n        },\n        exact h21,\n      },\n      have h22 : \u2203! A : G, x \u2208 A \u2227 y \u2208 B \u2227 x \u2208 B \u2227 y \u2208 A, from by {\n        have h23 : \u2203! A : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 (\u2203 z : G, z \u2208 B) \u2227 (\u2203 w : G, w \u2208 A), from by {\n          use {A : G | true},\n          obviously,\n        },\n        have h24 : \u2203! A : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 (\u2203 z : G, z \u2208 B) \u2227 (\u2203 w : G, w \u2208 A) \u2227 x \u2208 A \u2227 y \u2208 B \u2227 x \u2208 B \u2227 y \u2208 A, from by {\n          use {A : G | x \u2208 A \u2227 y \u2208 B \u2227 x \u2208 B \u2227 y \u2208 A},\n          obviously,\n        },\n        exact h24,\n      },\n      have h25 : \u2203! B : G, x \u2208 B \u2227 y \u2208 A \u2227 x \u2208 A \u2227 y \u2208 B, from by {\n        have h26 : \u2203! B : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B), from by {\n          use {B : G | true},\n          obviously,\n        },\n        have h27 : \u2203! B : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 x \u2208 B \u2227 y \u2208 A \u2227 x \u2208 A \u2227 y \u2208 B, from by {\n          use {B : G | x \u2208 B \u2227 y \u2208 A \u2227 x \u2208 A \u2227 y \u2208 B},\n          obviously,\n        },\n        exact h27,\n      },\n      have h28 : \u2203! A : G, x \u2208 A \u2227 y \u2208 B \u2227 x \u2208 B \u2227 y \u2208 A \u2227 x \u2208 A \u2227 y \u2208 B \u2227 x \u2208 B \u2227 y \u2208 A, from by {\n        have h29 : \u2203! A : G, (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 (\u2203 z : G, z \u2208 B) \u2227 (\u2203 w : G, w \u2208 A) \u2227 (\u2203 z : G, z \u2208 A) \u2227 (\u2203 w : G, w \u2208 B) \u2227 (\u2203 z : G, z \u2208 B\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem graph_bipartite_iff_two_colorable (G : Type*) [graph G] : \n\u2200 g : G, bipartite g \u2194 two_colorable g :=\nbegin\n  -- Let $G$ be a 2-colorable graph\n  assume g : G,\n  have h1 : \u2200 g : G, two_colorable g \u2192 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 : \u2203 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 : \u2200 v : vertex g, (v \u2208 A) \u2192 (\u2200 w : vertex g, (v \u2260 w) \u2192 (v,w) \u2209 edge g), from by {\n      assume (v : vertex g) (hv : v \u2208 A),\n      assume (w : vertex g) (hvw : v \u2260 w),\n      have hvred : coloring.is_red v coloring, from by {\n        have hv : v \u2208 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 \u2208 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) \u2209 edge g, from\n        two_colorable.no_adjacent_colored_same h2c v hvred w hwred hvw,\n      show (v,w) \u2209 edge g, from hredred,\n    },\n    have hB : \u2200 v : vertex g, (v \u2208 B) \u2192 (\u2200 w : vertex g, (v \u2260 w) \u2192 (v,w) \u2209 edge g), from by {\n      assume (v : vertex g) (hv : v \u2208 B),\n      assume (w : vertex g) (hvw : v \u2260 w),\n      have hvblue : coloring.is_blue v coloring, from by {\n        have hv : v \u2208 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 \u2208 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) \u2209 edge g, from\n        two_colorable.no_adjacent_colored_same h2c v hvblue w hwblue hvw,\n      show (v,w) \u2209 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 \u2200 v w : vertex g, (v \u2260 w) \u2192 (v,w) \u2208 edge g \u2192 (v \u2208 A \u2227 w \u2208 B) \u2228 (v \u2208 B \u2227 w \u2208 A), from by {\n        assume (v : vertex g) (w : vertex g) (hvw : v \u2260 w),\n        assume (hvwedge : (v,w) \u2208 edge g),\n        have hvred : coloring.is_red v coloring, from by {\n          have hv : v \u2208 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 \u2208 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 \u2208 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 \u2208 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 \u2227 hwblue)) (assume hvredblue : hvred \u2227 hwblue,\n          have hvA : v \u2208 A, from by {\n            apply set.mem_of_mem_of_mem_coloring hvredblue.left,\n            show v \u2208 vertex g, from by apply set.mem_univ v,\n          },\n          have hwB : w \u2208 B, from by {\n            apply set.mem_of_mem_of_mem_coloring hvredblue.right,\n            show w \u2208 vertex g, from by apply set.mem_univ w,\n          },\n          show (v \u2208 A \u2227 w \u2208 B) \u2228 (v \u2208 B \u2227 w \u2208 A), from or.inl \u27e8hvA,hwB\u27e9)\n          (assume hvbluered : \u00ac (hvred \u2227 hwblue),\n            have hredblue : hvblue \u2227 hwred, from by {\n              show hvblue \u2227 hwred, from \u27e8hvbluered.left, hvbluered.right.left,\u27e9\n            },\n            have hvB : v \u2208 B, from by {\n              apply set.mem_of_mem_of_mem_coloring hredblue.left,\n              show v \u2208 vertex g, from by apply set.mem_univ v,\n            },\n            have hwA : w \u2208 A, from by {\n              apply set.mem_of_mem_of_mem_coloring hredblue.right,\n              show w \u2208 vertex g, from by apply set.mem_univ w,\n            },\n            show (v \u2208 A \u2227 w \u2208 B) \u2228 (v \u2208 B \u2227 w \u2208 A), from or.inr \u27e8hvB, hwA\u27e9)\n      },\n      show \u2200 v w : vertex g, (v \u2260 w) \u2192 (v,w) \u2209 edge g \u2192 (v \u2208 A \u2227 w \u2208 A) \u2228 (v \u2208 B \u2227 w \u2208 B), from by {\n        assume (v : vertex g) (w : vertex g) (hvw : v \u2260 w),\n        assume (hvwnotedge : (v,w) \u2209 edge g),\n        have hvA : v \u2208 A, from set.mem_of_mem_of_mem_coloring hvwnotedge (h1 g).left hvw,\n        have hwA : w \u2208 A, from set.mem_of_mem_of_mem_coloring hvwnotedge (h1 g).left hvw,\n        show (v \u2208 A \u2227 w \u2208 A) \u2228 (v \u2208 B \u2227 w \u2208 B), from or.inl \u27e8hvA,hwA\u27e9,\n      },\n    },\n    show bipartite g, from hbipartite,\n  },\n  have h2 : \u2200 g : G, bipartite g \u2192 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] : \u2203! color : G \u2192 (color_type G), \u2200 e : G, e.edges.forall (\u03bb e, e.color \u2260 e.other.color) :=\nbegin\n  -- Assume $G$ is a 2-colorable graph\n  assume color : G \u2192 (color_type G),\n  assume e : G, assume h : e.edges.forall (\u03bb e, e.color \u2260 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 : \u2200 a \u2208 A, a.edges.forall (\u03bb e, e.other \u2209 A), from \n    assume a : G, assume hA : a \u2208 A,\n    begin\n      assume e : G, assume h2 : e \u2208 a.edges,\n      have h3 : e.other.color = color_type.blue, from \n        by {rw \u2190 h, apply h2,},\n      have h4 : a.color = color_type.red, from by {rw \u2190 hA, rw A,},\n      show e.other \u2209 A, from by {rw h3, rw h4, rw A, intro h5, cases h5,},\n    end,\n  have h2 : \u2200 b \u2208 B, b.edges.forall (\u03bb e, e.other \u2209 B), from \n    assume b : G, assume hB : b \u2208 B,\n    begin\n      assume e : G, assume h2 : e \u2208 b.edges,\n      have h3 : e.other.color = color_type.red, from \n        by {rw \u2190 h, apply h2,},\n      have h4 : b.color = color_type.blue, from by {rw \u2190 hB, rw B,},\n      show e.other \u2209 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 : \u2200 e : G, e \u2208 G.edges \u2192 e.other \u2208 A \u2192 e.other \u2208 B, from\n    assume e : G, assume h4 : e \u2208 G.edges, assume h5 : e.other \u2208 A,\n    begin\n      have h6 : e \u2208 e.other.edges, from by {rw G.edges, exact or.inr h4,},\n      have h7 : e.other \u2209 A, from by {apply h1 e.other h5, exact h6,},\n      show e.other \u2208 B, from by {rw B, rw h7,},\n    end,\n  -- \n  have h4 : \u2200 e : G, e \u2208 G.edges \u2192 e.other \u2208 B \u2192 e.other \u2208 A, from\n    assume e : G, assume h4 : e \u2208 G.edges, assume h5 : e.other \u2208 B,\n    begin\n      have h6 : e \u2208 e.other.edges, from by {rw G.edges, exact or.inr h4,},\n      have h7 : e.other \u2209 B, from by {apply h2 e.other h5, exact h6,},\n      show e.other \u2208 A, from by {rw A, rw h7,},\n    end,\n  show G.is_bipartite, from \u27e8A, B, h3, h4\u27e9,\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 \u2192 color_type G := \n    begin\n      assume e : G,\n      have h2 : \u2203! x \u2208 A, e \u2208 x.edges, from by {\n        use e,\n        have h3 : e \u2208 G.edges, from by {rw G.edges, exact or.inl e.edges.left,},\n        have h4 : e.other \u2208 A, from by {apply h1.left_right e h3,},\n        have h5 : e \u2208 e.other.edges, from by {rw G.edges, exact or.inr e.edges.left,},\n        show e \u2208 A, from by {apply exists_unique.unique (h2 e) h4 h5,},\n      end,\n      have h3 : \u2203! x \u2208 B, e \u2208 x.edges, from by {\n        use e,\n        have h4 : e \u2208 G.edges, from by {rw G.edges, exact or.inl e.edges.left,},\n        have h5 : e.other \u2208 B, from by {apply h1.right_left e h4,},\n        have h6 : e \u2208 e.other.edges, from by {rw G.edges, exact or.inr e.edges.left,},\n        show e \u2208 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 : \u2200 e : G, e.edges.forall (\u03bb e, e.color \u2260 e.other.color), from \n    assume e : G,\n    begin\n      assume e : G, assume h2 : e \u2208 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 \u2260 e.other.color, from \n        by {rw \u2190 h3, rw \u2190 h4, intro h5, cases h5,},\n    end,\n  show \u2203! color : G \u2192 color_type G, from \u27e8color, h2\u27e9,\nend\n\n--OUTPUT 8\ntheorem two_colorable_iff_bipartite (G : Type*) [graph G] : \n  (\u2203 (c : G \u2192 Prop), \u2200 (a b : G), (a \u2260 b) \u2192 (edge a b) \u2192 (c a \u2260 c b)) \u2194 \n  (\u2203 (V\u2081 V\u2082 : set G), \u2200 (a : G), a \u2208 V\u2081 \u2228 a \u2208 V\u2082 \u2227 \u2200 (a b : G), (edge a b) \u2192 ((a \u2208 V\u2081 \u2227 b \u2208 V\u2082) \u2228 (a \u2208 V\u2082 \u2227 b \u2208 V\u2081))) :=\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 : \u2203 (c : G \u2192 Prop), \u2200 (a b : G), (a \u2260 b) \u2192 (edge a b) \u2192 (c a \u2260 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 : \u2203 (V\u2081 V\u2082 : set G), \u2200 (a : G), a \u2208 V\u2081 \u2228 a \u2208 V\u2082 \u2227 \u2200 (a b : G), (edge a b) \u2192 ((a \u2208 V\u2081 \u2227 b \u2208 V\u2082) \u2228 (a \u2208 V\u2082 \u2227 b \u2208 V\u2081)), from by {\n    --Since all vertices of $A$ are red, there are no edges within $A$, and similarly for $B$.\n    let V\u2081 : set G := {a : G | c a},\n    let V\u2082 : set G := {a : G | \u00ac(c a)},\n    have h4 : \u2200 (a b : G), (a \u2260 b) \u2192 (edge a b) \u2192 (a \u2208 V\u2081 \u2227 b \u2208 V\u2082) \u2228 (a \u2208 V\u2082 \u2227 b \u2208 V\u2081), from by {\n      assume a b : G, assume h5 : (a \u2260 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 \u2260 c b, from h2 a b h5 h6,\n      have h8 : a \u2208 V\u2081 \u2228 a \u2208 V\u2082, from by {\n        cases (c a),\n        {exact or.inl \u27e8_, h\u27e9,},\n        {exact or.inr \u27e8_, h\u27e9,},\n      },\n      have h9 : b \u2208 V\u2081 \u2228 b \u2208 V\u2082, from by {\n        cases (c b),\n        {exact or.inl \u27e8_, h\u27e9,},\n        {exact or.inr \u27e8_, h\u27e9,},\n      },\n      cases h8 with h10 h11,\n      {exact or.inl \u27e8h10, h9\u27e9,},\n      {exact or.inr \u27e8h11, h8\u27e9,},\n    },\n    exact \u27e8V\u2081, V\u2082, h4\u27e9,\n  },\n  show \u2203 (V\u2081 V\u2082 : set G), \u2200 (a : G), a \u2208 V\u2081 \u2228 a \u2208 V\u2082 \u2227 \u2200 (a b : G), (edge a b) \u2192 ((a \u2208 V\u2081 \u2227 b \u2208 V\u2082) \u2228 (a \u2208 V\u2082 \u2227 b \u2208 V\u2081)), 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 : \u2203 (V\u2081 V\u2082 : set G), \u2200 (a : G), a \u2208 V\u2081 \u2228 a \u2208 V\u2082 \u2227 \u2200 (a b : G), (edge a b) \u2192 ((a \u2208 V\u2081 \u2227 b \u2208 V\u2082) \u2228 (a \u2208 V\u2082 \u2227 b \u2208 V\u2081)),\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\u2081 h2, cases h2 with V\u2082 h3,\n  have h4 : \u2203 (c : G \u2192 Prop), \u2200 (a b : G), (a \u2260 b) \u2192 (edge a b) \u2192 (c a \u2260 c b), from by {\n    let c : G \u2192 Prop := \u03bb (a : G), (a \u2208 V\u2081),\n    have h5 : \u2200 (a b : G), (a \u2260 b) \u2192 (edge a b) \u2192 (c a \u2260 c b), from by {\n      assume a b : G, assume h5 : (a \u2260 b), assume h6 : (edge a b),\n      have h7 : a \u2208 V\u2081 \u2228 a \u2208 V\u2082, from h3 a,\n      have h8 : b \u2208 V\u2081 \u2228 b \u2208 V\u2082, from h3 b,\n      cases h7 with h9 h10,\n      {\n        cases h8 with h11 h12,\n        {\n          have h13 : (a \u2208 V\u2081 \u2227 b \u2208 V\u2082) \u2228 (a \u2208 V\u2082 \u2227 b \u2208 V\u2081), from h3 a b h6,\n          cases h13 with h14 h15,\n          {\n            have h16 : c a \u2227 c b, from \u27e8h9, h11\u27e9,\n            cases h16 with h17 h18,\n            {\n              have h19 : c a = c b, from by {rw \u2190 h17,rw \u2190 h18},\n              show c a \u2260 c b, from h19 \u25b8 h5,\n            },\n          },\n          {\n            have h16 : c a \u2227 \u00acc b, from \u27e8h9, h12\u27e9,\n            cases h16 with h17 h18,\n            {\n              have h19 : c a = \u00acc b, from by {rw \u2190 h17,rw \u2190 h18},\n              show c a \u2260 c b, from h19 \u25b8 h5,\n            },\n          },\n        },\n        {\n          have h13 : (a \u2208 V\u2081 \u2227 b \u2208 V\u2082) \u2228 (a \u2208 V\u2082 \u2227 b \u2208 V\u2081), from h3 a b h6,\n          cases h13 with h14 h15,\n          {\n            have h16 : c a \u2227 c b, from \u27e8h9, h11\u27e9,\n            cases h16 with h17 h18,\n            {\n              have h19 : c a = c b, from by {rw \u2190 h17,rw \u2190 h18},\n              show c a \u2260 c b, from h19 \u25b8 h5,\n            },\n          },\n          {\n            have h16 : c a \u2227 \u00acc b, from \u27e8h9, h12\u27e9,\n            cases h16 with h17 h18,\n            {\n              have h19 : c a = \u00acc b, from by {rw \u2190 h17,rw \u2190 h18},\n              show c a \u2260 c b, from h19 \u25b8 h5,\n            },\n          },\n        },\n      },\n      {\n        cases h8 with h11 h12,\n        {\n          have h13 : (a \u2208 V\u2081 \u2227 b \u2208 V\u2082) \u2228 (a \u2208 V\u2082 \u2227 b \u2208 V\u2081), 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 {\u03b1 \u03b2 : 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  \u27e8X\u27e9\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  \u27e8X, to_two_pointing\u27e9\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) : \u21a5(of to_two_pointing) = X :=\n  rfl\n#align Twop.coe_of TwoP.coe_of\n-/\n\nalias of \u2190 _root_.two_pointing.Twop\n#align two_pointing.Twop TwoPointing.TwoP\n\ninstance : Inhabited TwoP :=\n  \u27e8of TwoPointing.bool\u27e9\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) : \u21a5X.toBipointed = \u21a5X :=\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\u2082 TwoP Bipointed :=\n  InducedCategory.hasForget\u2082 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 \u2964 TwoP where\n  obj X := \u27e8X, X.toTwoPointing.symm\u27e9\n  map X Y f := \u27e8f.toFun, f.map_snd, f.map_fst\u27e9\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\u2093'. -/\n/-- The equivalence between `Twop` and itself induced by `prod.swap` both ways. -/\n@[simps]\ndef swapEquiv : TwoP \u224c TwoP :=\n  Equivalence.mk swap swap\n    (NatIso.ofComponents\n      (fun X =>\n        { Hom := \u27e8id, rfl, rfl\u27e9\n          inv := \u27e8id, rfl, rfl\u27e9 })\n      fun X Y f => rfl)\n    (NatIso.ofComponents\n      (fun X =>\n        { Hom := \u27e8id, rfl, rfl\u27e9\n          inv := \u27e8id, rfl, rfl\u27e9 })\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\u2093'. -/\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 \u22d9 forget\u2082 TwoP Bipointed = forget\u2082 TwoP Bipointed \u22d9 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} \u2964 TwoP\n    where\n  obj X := \u27e8Option X, \u27e8X.point, none\u27e9, some_ne_none _\u27e9\n  map X Y f := \u27e8Option.map f.toFun, congr_arg _ f.map_point, rfl\u27e9\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} \u2964 TwoP\n    where\n  obj X := \u27e8Option X, \u27e8none, X.point\u27e9, (some_ne_none _).symm\u27e9\n  map X Y f := \u27e8Option.map f.toFun, rfl, congr_arg _ f.map_point\u27e9\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 \u22d9 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 \u22d9 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 \u22d9 forget\u2082 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 \u22d9 forget\u2082 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 \u22a3 forget\u2082 TwoP Bipointed \u22d9 bipointedToPointedFst :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f => \u27e8f.toFun \u2218 Option.some, f.map_fst\u27e9\n          invFun := fun f => \u27e8fun o => o.elim Y.toTwoPointing.toProd.2 f.toFun, f.map_point, rfl\u27e9\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 \u22a3 forget\u2082 TwoP Bipointed \u22d9 bipointedToPointedSnd :=\n  Adjunction.mkOfHomEquiv\n    { homEquiv := fun X Y =>\n        { toFun := fun f => \u27e8f.toFun \u2218 Option.some, f.map_snd\u27e9\n          invFun := fun f => \u27e8fun o => o.elim Y.toTwoPointing.toProd.1 f.toFun, rfl, f.map_point\u27e9\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": "import data.real.basic\nimport topology.continuous_function.polynomial\nimport data.polynomial.basic\nimport data.polynomial.ring_division\nimport data.complex.basic\n\ntheorem USAMO_Problem_3_1989 (P : polynomial \u2102) : \ncomplex.abs(P.eval complex.I) < 1 \u2192 \n\u2203 a b : \u211d, (P.eval (a+b*complex.I : \u2102) = 0 \u2227 (a^2+b^2+1)^2 < 4*b^2+1)\n:= sorry\n\n\n\n\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/1989-USAMO-Problem_3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.9099070084811307, "lm_q2_score": 0.519521321952093, "lm_q1q2_score": 0.4727160918995913}}
{"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\u2081` for a T\u2081 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 := \u03bb s, if none \u2208 s then is_compact (some\u207b\u00b9' s)\u1d9c \u2227 is_open (some\u207b\u00b9' s)\n    else is_open (some\u207b\u00b9' s),\n  is_open_univ := by simp,\n  is_open_inter :=\n  \u03bb 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  \u03bb S ht, begin\n    suffices : is_open (some\u207b\u00b9' \u22c3\u2080S),\n    { split_ifs with h,\n      { obtain \u27e8(a : set (option X)), ha, ha'\u27e9 := mem_sUnion.mp h,\n        specialize ht a ha,\n        rw if_pos ha' at ht,\n        refine \u27e8compact_of_is_closed_subset ht.left this.is_closed_compl _, this\u27e9,\n        rw [compl_subset_compl, preimage_subset_iff],\n        intros y hy,\n        refine \u27e8a, ha, hy\u27e9 },\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 \u27e8some\u207b\u00b9' s, subset_subset_Union _ (subset_subset_Union hs (subset.refl _)), _,\n      mem_preimage.mpr hy\u27e9,\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\u207b\u00b9' {none} : set X) = \u2205 :=\nby { ext, simp }\n\nlemma some_mem_range_some (x : X) : some x \u2208 (some '' (univ : set X)) :=\nby simp\n\nlemma none_not_mem_range_some : none \u2209 some '' (univ : set X) .\n\n@[simp] lemma none_not_mem_image_some {s : set X} : none \u2209 some '' s :=\nnot_mem_subset (image_subset _ $ subset_univ _) none_not_mem_range_some\n\nlemma union_none_eq_univ : (some '' univ \u222a {none}) = (univ : set (option X)) :=\nbegin\n  refine le_antisymm (subset_univ _) _,\n  rintros \u27e8_|x\u27e9;\n  simp\nend\n\nlemma inter_none_eq_empty : (some '' univ) \u2229 {none} = (\u2205 : set (option X)) :=\nby { ext \u27e8_|x\u27e9; simp }\n\nvariables [topological_space X]\n\nlemma is_open_alexandroff_iff_aux :\n  is_open s \u2194 if none \u2208 s then is_compact (some\u207b\u00b9' s)\u1d9c \u2227 is_open (some\u207b\u00b9' s)\n  else is_open (some\u207b\u00b9' s) :=\niff.rfl\n\nlemma is_open_iff_of_mem (h : none \u2208 s) :\n  is_open s \u2194 is_compact (some\u207b\u00b9' s)\u1d9c \u2227 is_closed (some\u207b\u00b9' s)\u1d9c :=\nby simp [is_open_alexandroff_iff_aux, h, is_closed_compl_iff]\n\nlemma is_open_iff_of_not_mem (h : none \u2209 s) :\n  is_open s \u2194 is_open (some\u207b\u00b9' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_of_is_open (h : is_open s) :\n  is_open (some\u207b\u00b9' s) :=\nbegin\n  by_cases H : none \u2208 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\u03bb s hs, begin\n  rw [\u2190 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 (\u03bb 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 \u2227 is_closed s) :\n  topological_space.opens (option X) :=\n\u27e8(some '' s)\u1d9c, 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' }\u27e9\n\nlemma none_mem_opens_of_compl {s : set X} (h : is_compact s \u2227 is_closed s) :\n  none \u2208 (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 (\u03bb \u03b9 Z h H, _),\n    simp only [univ_subset_iff] at H \u22a2,\n    rcases Union_eq_univ_iff.mp H none with \u27e8K, hK\u27e9,\n    have minor\u2081 : is_compact (some\u207b\u00b9' Z K)\u1d9c,\n    { specialize h K, rw is_open_iff_of_mem hK at h, exact h.1 },\n    let p : \u03b9 \u2192 set X := \u03bb i, some\u207b\u00b9' Z i,\n    have minor\u2082 : \u2200 i, is_open (p i) := \u03bb i, is_open_of_is_open (h i),\n    have minor\u2083 : (some\u207b\u00b9' Z K)\u1d9c \u2286 \u22c3 i, p i :=\n      by simp only [p, \u2190 preimage_Union, H, preimage_univ, subset_univ],\n    rcases is_compact_iff_finite_subcover.mp minor\u2081 p minor\u2082 minor\u2083 with \u27e8\u03b9', H'\u27e9,\n    refine \u27e8insert K \u03b9', _\u27e9,\n    rw \u2190 preimage_compl at H',\n    simp only [Union_eq_univ_iff],\n    intros x,\n    by_cases hx : x \u2208 Z K,\n    { exact \u27e8K, mem_Union.mpr \u27e8finset.mem_insert_self _ _, hx\u27e9\u27e9 },\n    { have triv\u2081 : x \u2260 none := (ne_of_mem_of_not_mem hK hx).symm,\n      rcases option.ne_none_iff_exists.mp triv\u2081 with \u27e8y, hy\u27e9,\n      have triv\u2082 : some y \u2208 {x} := mem_singleton_of_eq hy,\n      rw [\u2190 mem_compl_iff, \u2190 singleton_subset_iff] at hx,\n      have : some\u207b\u00b9' {x} \u2286 some\u207b\u00b9' (Z K)\u1d9c := \u03bb y hy, hx hy,\n      have key : y \u2208 \u22c3 (i : \u03b9) (H : i \u2208 \u03b9'), p i := this.trans H' (mem_preimage.mpr triv\u2082),\n      rcases mem_bUnion_iff'.mp key with \u27e8i, hi, hyi\u27e9,\n      refine \u27e8i, mem_Union.mpr \u27e8finset.subset_insert _ \u03b9' hi, _\u27e9\u27e9,\n      simpa [hy] using hyi }\n  end }\n\n/-- The one-point extension of a T\u2081 space `X` is T\u2081-/\n@[reducible, nolint def_lemma]\ndef t1_space [t1_space X] : t1_space (option X) :=\n{ t1 :=\n  \u03bb z, begin\n    cases z,\n    { rw [\u2190 is_open_compl_iff, compl_eq_univ_diff, \u2190 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 \u2208 ({some z}\u1d9c : set (option X)) :=\n        mem_compl (\u03bb w, (option.some_ne_none z).symm (mem_singleton_iff.mp w)),\n      rw [\u2190 is_open_compl_iff, is_open_iff_of_mem this],\n      rw [preimage_compl, compl_compl, \u2190 image_singleton, \n          (option.some_injective X).preimage_image _],\n      exact \u27e8is_compact_singleton, is_closed_singleton\u27e9 }\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  \u03bb x y hxy, begin\n    have key : \u2200 (z : option X), z \u2260 none \u2192\n      \u2203 (u v : set (option X)), is_open u \u2227 is_open v \u2227 none \u2208 u \u2227 z \u2208 v \u2227 u \u2229 v = \u2205 :=\n    \u03bb z h, begin\n      rcases option.ne_none_iff_exists.mp h with \u27e8y', hy'\u27e9,\n      rcases exists_open_with_compact_closure y' with \u27e8u, hu, huy', Hu\u27e9,\n      have minor\u2081 : _ \u2227 is_closed (closure u) := \u27e8Hu, is_closed_closure\u27e9,\n      refine \u27e8opens_of_compl minor\u2081, some '' u, _\u27e9,\n      refine \u27e8(opens_of_compl minor\u2081).2, is_open_map_some _ hu,\n        none_mem_opens_of_compl minor\u2081, \u27e8y', huy', hy'\u27e9, _\u27e9,\n      simp only [opens_of_compl, topological_space.opens.coe_mk],\n      have minor\u2082 : (some '' closure u)\u1d9c \u2229 some '' u \u2286 (some '' u)\u1d9c \u2229 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\u2082,\n      exact eq_empty_of_subset_empty minor\u2082\n    end,\n    cases x; cases y,\n    { simpa using hxy },\n    { simpa using key y hxy.symm },\n    { rcases key x hxy with \u27e8u, v, hu, hv, hxu, hyv, huv\u27e9,\n      exact \u27e8v, u, hv, hu, hyv, hxu, (inter_comm u v) \u25b8 huv\u27e9 },\n    { have hxy' : x \u2260 y := \u03bb w, hxy ((option.some.inj_eq _ _).mpr w),\n      rcases t2_separation hxy' with \u27e8u, v, hu, hv, hxu, hyv, huv\u27e9,\n      refine \u27e8some '' u, some '' v, is_open_map_some _ hu, is_open_map_some _ hv,\n        \u27e8x, hxu, rfl\u27e9, \u27e8y, hyv, rfl\u27e9, _\u27e9,\n      simp only [image_inter (option.some_injective X), huv, image_empty] }\n  end }\n\nlemma dense_range_some (h : \u00ac is_compact (univ : set X)) : dense (some '' (univ : set X)) :=\nbegin\n  refine dense_iff_inter_open.mpr (\u03bb s hs Hs, _),\n  by_cases H : none \u2208 s,\n  { rw is_open_iff_of_mem H at hs,\n    have minor\u2081 : s \u2260 {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\u2082 : some\u207b\u00b9' s \u2260 \u2205,\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 : \u2200 z \u2208 s, z = none := \u03bb z hz,\n        by_contra (\u03bb w', let \u27e8x, hx\u27e9 := option.ne_none_iff_exists'.mp w' in\n          by rw hx at hz; exact (w x) hz),\n      exact minor\u2081 (eq_singleton_iff_unique_mem.mpr \u27e8H, this\u27e9) },\n    rcases ne_empty_iff_nonempty.mp minor\u2082 with \u27e8x, hx\u27e9,\n    exact \u27e8some x, hx, x, mem_univ _, rfl\u27e9 },\n  { rcases Hs with \u27e8z, hz\u27e9,\n    rcases option.ne_none_iff_exists'.mp (ne_of_mem_of_not_mem hz H) with \u27e8x, hx\u27e9,\n    rw hx at hz,\n    exact \u27e8some x, hz, x, mem_univ _, rfl\u27e9 }\nend\n\nlemma connected_space [preconnected_space X] (h : \u00ac is_compact (univ : set X)) :\n  connected_space (option X) :=\n{ is_preconnected_univ :=\n  begin\n    rw \u2190 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 := \u27e8none\u27e9 }\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 \u2192 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 `\u221e` := infty\n\nnamespace alexandroff\n\ninstance : has_coe_t X (alexandroff X) := \u27e8of\u27e9\n\ninstance : inhabited(alexandroff X) := \u27e8\u221e\u27e9\n\n@[norm_cast] \nlemma coe_eq_coe {x y : X} : (x : alexandroff X) = y \u2194 x = y :=\nof_injective.eq_iff\n\n@[simp] lemma coe_ne_infty (x : X) : (x : alexandroff X) \u2260 \u221e  .\n@[simp] lemma infity_ne_coe (x : X) : \u221e \u2260 (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 \u2192 Prop} (h : p none) : p infty :=\nby simpa [infty] using h\n\n/-- Recursor for `alexandroff` using the preferred forms `\u221e` and `\u2191x`. -/\n@[elab_as_eliminator]\ndef rec_infty_coe (C : alexandroff X \u2192 Sort*) (h\u2081 : C infty) (h\u2082 : \u03a0 (x : X), C x) :\n  \u03a0 (z : alexandroff X), C z :=\noption.rec h\u2081 h\u2082\n\nlemma ne_infty_iff_exists {x : alexandroff X} : \n  x \u2260 infty \u2194 \u2203 (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) \u2208 (range_of X) :=\none_point_extension.some_mem_range_some x\n\nlemma union_infty_eq_univ : (range_of X \u222a {\u221e}) = univ :=\none_point_extension.union_none_eq_univ\n\n@[simp] lemma infty_not_mem_range_of : \u221e \u2209 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 \u2209 range_of X \u2194 x = \u221e :=\nby { induction x using alexandroff.rec_infty_coe; simp }\n\n@[simp] lemma infty_not_mem_image_of {s : set X} : \u221e \u2209 of '' s :=\none_point_extension.none_not_mem_image_some\n\nlemma inter_infty_eq_empty : (range_of X) \u2229 {\u221e} = \u2205 :=\none_point_extension.inter_none_eq_empty\n\nlemma of_preimage_infty : (of\u207b\u00b9' {\u221e} : set X) = \u2205 :=\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 \u2194 if infty \u2208 s then is_compact (of\u207b\u00b9' s)\u1d9c \u2227 is_open (of\u207b\u00b9' s)\n  else is_open (of\u207b\u00b9' s) :=\niff.rfl\n\nlemma is_open_iff_of_mem' (h : infty \u2208 s) :\n  is_open s \u2194 is_compact (of\u207b\u00b9' s)\u1d9c \u2227 is_open (of\u207b\u00b9' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_iff_of_mem (h : infty \u2208 s) :\n  is_open s \u2194 is_compact (of\u207b\u00b9' s)\u1d9c \u2227 is_closed (of\u207b\u00b9' s)\u1d9c :=\nby simp [is_open_alexandroff_iff_aux, h, is_closed_compl_iff]\n\nlemma is_open_iff_of_not_mem (h : infty \u2209 s) :\n  is_open s \u2194 is_open (of\u207b\u00b9' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_of_is_open (h : is_open s) :\n  is_open (of\u207b\u00b9' 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 \u2227 is_closed s) :\n  topological_space.opens (alexandroff X) :=\n\u27e8(of '' s)\u1d9c, (one_point_extension.opens_of_compl h).2\u27e9\n\nlemma infty_mem_opens_of_compl {s : set X} (h : is_compact s \u2227 is_closed s) :\n  infty \u2208 (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 : \u00ac 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 : \u00ac 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 : \u2115) (x : \u211a) :\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, \u2212)$.\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\u2081)`, where `u\u2081 > 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 \u2192 C \u2192 Type v\n| a b := a \u27f6 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 \u2192 hom C b c \u2192 hom C a c\n| f g := f \u226b g  -- same as `g \u226b 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 := \ud835\udfd9 a\n\nattribute [simp] comp id\n\ninstance hom_setoid {C : Type u} [category.{v} C] (a b : C) : setoid (hom C a b) := \u27e8\u03bb f g, f = g\u27e9\n\n/--\nThe Yoneda embedding is the functor that takes each object $x$ of $C$ to the covariant\nhom-functor $\\hom_C(\u2212,x)$ and each morphism $f : x \u2192 y$ to the function $\u03b1 \u2192 f\u2218\u03b1$ that sends\neach morphism $\u03b1 : z \u2192 x$ to the composite $f\u2218\u03b1 : z \u2192 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) \u2245 \ud835\udfd9 (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 \u2192 b$ be a morphism in $C$.\n  rw function.funext_iff, -- It suffices to prove that \n  intros \u03b1, -- for all $\u03b1 : x \u2192 a$, $f\u2218\u03b1 = \u03b1'\u2218f$\n  apply eq_of_inv_eq_inv, -- Since the inverse is unique, \n  rw [\u2190cancel_epi f, \u2190cancel_epi \u03b1], -- $g\u2218f = id_a$ and $f'\u2218\u03b1$\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 : \u2115) (x : \u211a) :\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 : \u2115) (x : \u211a) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) := \nbegin\n  assume (n : \u2115) (x : \u211a),\n  assume h1 : \u2200 m : \u2115, m < n \u2192 (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1),\n  have h2 : \u2200 l : \u2115, (n + 1 : \u211a) * ((1 + x) : \u211a)^l = (n + 1 : \u211a) * (x : \u211a)^l + l * \u2211 k = 0 to l - 1, ((nat.choose (l - 1) k) : \u211a) * (x : \u211a)^(l - 1 - k)  := \n  begin\n    assume l : \u2115,\n    show ((n + 1) * ((1 + x) : \u211a)^l) = ((n + 1) * x^l) + l * (\u2211 k = 0 to l - 1, (nat.choose (l - 1) k) * x^(l - 1 - k)),\n    have h3 : (n + 1 : \u211a) * ((1 + x) : \u211a)^l = (n + 1 : \u211a) * (\u2211 k = 0 to l - 1, nat.choose l k * x^k), from sorry,\n    have h4 : \u2200 k : \u2115, (n + 1 : \u211a) * 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 : \u2115,\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 : \u2200 k : \u2115, 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 : \u2200 k : \u2115, k < l \u2192 (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 : \u2200 k : \u2115, k < l \u2192 (n + 1 : \u211a) * (nat.choose l k : \u211a) * (x : \u211a)^k = (nat.choose (l - 1) k : \u211a) * (x : \u211a)^(l - 1 - k) + (l * x^(l - 1) * (x^(k - l + 1) * (nat.choose (l - 1) k))), from sorry,\n    have h8 : \u2200 k : \u2115, k < l \u2192 \u2203! (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 : \u2200 k : \u2115, k < l \u2192 (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 : \u2200 k : \u2115, k < l \u2192 \u2203! (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 : \u211a) * (\u2211 k = 0 to l - 1, (nat.choose l k : \u211a) * (x : \u211a)^k) = (\u2211 k = 0 to l - 1, (nat.choose (l - 1) k : \u211a) * (x : \u211a)^(l - 1 - k) + (l * (x : \u211a)^(l - 1) * (x^(k - l + 1) * (nat.choose (l - 1) k)))), from sorry,\n    have h12 : \u2200 k : \u2115, k < l \u2192 \u2203! (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 : \u2200 k : \u2115, \u2203! ((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 : \u2200 k : \u2115, nat.choose (l - 1) k * x^(l - 1 - k) + (l * x^(l - 1) * (x^(k - l + 1) * (nat.choose (l - 1) k))) = (n + 1 : \u211a) * (nat.choose l k) * x^k, from sorry,\n    sorry,\n  end,\n  rw (n + 1 : \u211a) * ((1 + x) : \u211a)^n = (n + 1 : \u211a) * (x : \u211a)^n + n * (\u2211 k : \u2115, (nat.choose n k : \u211a) * (x : \u211a)^(n - 1 - k)) at h2,\n  have h3 : \u2200 k : \u2115, \u2203! (n + 1 : \u211a) * (nat.choose n k : \u211a) * (x : \u211a)^k = (nat.choose (n - 1) k : \u211a) * (x : \u211a)^(n - 1 - k) + n * (nat.choose (n - 1) k : \u211a) * (x : \u211a)^(n - 1 - k), from sorry,\n  have h4 : \u2200 k : \u2115, (n + 1 : \u211a) * (nat.choose n k : \u211a) * (x : \u211a)^k = (nat.choose (n - 1) k : \u211a) * (x : \u211a)^(n - 1 - k) + n * (nat.choose (n - 1) k : \u211a) * (x : \u211a)^(n - 1 - k), from sorry,\n  have h5 : \u2200 k : \u2115, (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) : \u211d) = (n + 1 : \u211a) * (polynomial.bernoulli n).eval x + n * (\nend --Needs more than 2000 tokens!\n\n--OUTPUT 4\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\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 : \u2115) (x : \u211a) :\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 : \u2115) (x : \u211a) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : \u2200 (l : \u2115), \u2211 k in range (l + 1), ((l + 1) choose k) * (polynomial.bernoulli k).eval x = (l + 1) * x^l, from\n  begin\n    assume (l : \u2115),\n    have h2 : polynomial.degree ((\u2211 k in range (l + 1), ((l + 1) choose k) * (polynomial.bernoulli k)) : polynomial \u211a) \u2264 l, from sorry,\n    rw polynomial.sum_degree_eq_max_of_degree_le at h2,\n    have h3 : \u2200 (k : \u2115), k \u2208 range (l + 1) \u2192 (polynomial.degree (polynomial.const ((l + 1 : \u2115) choose k) * polynomial.bernoulli k)) < l, from sorry,\n    rw polynomial.sum_degree_eq_max_of_degree_lt at h3,\n    have h4 : \u2200 (k : \u2115), k \u2208 range (l + 1) \u2192 (polynomial.degree (polynomial.const ((l + 1 : \u2115) choose k))) < l, from sorry,\n    rw polynomial.sum_degree_eq_max_of_degree_lt at h4,\n\n    calc (\u2211 k in range (l + 1), ((l + 1) choose k) * (polynomial.bernoulli k).eval x)\n        = (\u2211 k in range (l + 1), ((l + 1) choose k) * (polynomial.bernoulli k).eval x) : by sorry\n    ... = (\u2211 k in range (l + 1), ((l + 1) choose k) * x^k) : by sorry\n    ... = (\u2211 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 : \u2200 (m : \u2115) (x : \u211a), m < n \u2192 polynomial.bernoulli m).eval (1 + x) = polynomial.bernoulli (m).eval (x) + m * x^(m - 1), from\n  begin\n    assume (m : \u2115) (x : \u211a) (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 : \u2115) (ihm : m < n \u2192 (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 : \u2115) = succ succ m, from rfl,\n    rw [h3, polynomial.eval_pow] at *, \n    have h4 : ((succ m) + 1 : \u2115) = 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 : \u2115) < n \u2192 (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval (x) + m * x^(m - 1)),\n    assume (h7 : (n : \u2115) < n),\n  end\nend\n\n--OUTPUT 7\ntheorem bernoulli_eval_one_add (n : \u2115) (x : \u211a) :\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 : \u2115) (h_ind : \u2200 m : \u2115, m < d \u2192\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 : \u2200 l : \u2115, \n                             (sum (polynomial.bernoulli l) (finset.range (l + 1))).eval (1 + x) =\n                             (l + 1) * (1 + x)^l,\n      {\n        assume (l : \u2115),\n        have h_sum_polynomial : \u2200 (l : \u2115) (P : polynomial \u211a), \n        (sum P (finset.range (l + 1))).eval x = \u2211 (i : finset (l + 1)), P.eval x,\n        {\n          assume (l : \u2115) (P : polynomial \u211a),\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 : \u2200 (l : \u2115), \n                                  (sum (polynomial.bernoulli l) (finset.range (l + 1))).eval x = \n                                  \u2211 (i : finset (l + 1)), (polynomial.bernoulli l).eval x,\n        {\n          assume (l : \u2115),\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 : \u2200 (l : \u2115), \n                                      (sum (polynomial.bernoulli l) (finset.range (l + 1))).eval x = \n                                      \u2211 (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 : \u2115),\n          have h_sum_bernoulli_poly : \u2200 (l : \u2115) (n : \u2115),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       \u2211 (i : finset (l + 1)), (polynomial.bernoulli l).eval x,\n          {\n            assume (l : \u2115) (n : \u2115),\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 : \u2200 (l : \u2115) (n : \u2115),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       \u2211 (i : finset (l + 1)), polynomial.bernoulli_number i,\n          {\n            assume (l : \u2115) (n : \u2115),\n            have h_sum_bernoulli_poly : \u2200 (l : \u2115) (n : \u2115),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       \u2211 (i : finset (l + 1)), (polynomial.bernoulli l).eval x,\n            {\n              assume (l : \u2115) (n : \u2115),\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 : \u2200 (l : \u2115) (n : \u2115),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       \u2211 (i : finset (l + 1)), polynomial.bernoulli_number i,\n            {\n              assume (l : \u2115) (n : \u2115),\n              by {\n                apply polynomial.bernoulli_eval_one,\n              },\n            },\n            have h_sum_bernoulli_poly_one : \u2200 (l : \u2115) (n : \u2115),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       \u2211 (i : finset (l + 1)), polynomial.bernoulli_number i,\n            {\n              assume (l : \u2115) (n : \u2115),\n              by {\n                apply polynomial.bernoulli_eval_one,\n              },\n            },\n            have h_sum_bernoulli_poly_one : \u2200 (l : \u2115) (n : \u2115),\n                                       sum (polynomial.bernoulli l) \n                                           (finset.range (l + 1)) =\n                                       \u2211 (i : finset (l + 1)), polynomial.bernoulli_number i,\n            {\n              assume (l : \u2115) (n : \u2115),\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 : \u2200 (l : \u2115),\n                                          \u2211 (i : finset (l + 1)), polynomial.bernoulli_number i =\n                                           (l + 1) * x^l,\n        {\n          assume (l : \u2115),\n          have h_sum_bernoulli_number : \u2200 (l : \u2115), \n                                      (sum (polynomial.bernoulli l) (finset.range (l + 1))).eval x = \n                                      \u2211 (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 : \u2115) (x : \u211a) :\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 : \u2115) (x : \u211a) :\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 : \u2115) (x : \u211a) :\n  (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1) :=\nbegin\n  have h1 : \u2200 n : \u2115, \u2200 x : \u211a, n < n \u2192 (polynomial.bernoulli n).eval (1 + x) = (polynomial.bernoulli n).eval x + n * x^(n - 1), from begin\n    assume (n : \u2115) (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 : \u2200 m : \u2115, \u2200 d : \u2115, m < d \u2192 \n    \u2200 x : \u211a, \n    (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1) \u2192 \n    (polynomial.bernoulli d).eval (1 + x) = (polynomial.bernoulli d).eval x + d * x^(d - 1), from begin\n    assume (m : \u2115) (d : \u2115) (h2 : m < d) (x : \u211a) (h3 : (polynomial.bernoulli m).eval (1 + x) = (polynomial.bernoulli m).eval x + m * x^(m - 1)),\n    have h4 : \u2200 l : \u2115, (polynomial.bernoulli l).eval (1 + x) = (polynomial.bernoulli l).eval x + l * x^(l - 1), from begin\n      assume (l : \u2115),\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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from sorry,\n  have h2 : (A \u2229 B) \u2286 A, from sorry,\n  have h3 : (A \u2229 B) \u2286 S, from sorry,\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from sorry,\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from sorry,\n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from sorry,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from sorry,\n\n  have h5 : \u2200 a : G, classical.some (h3 a) = (1 : G), from sorry,\n  have h6 : \u2200 a : G, classical.some (h4 a) = (1 : G), from sorry,\n\n  show \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (h7 : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 a : G, e = classical.some (h3 a), from sorry,\n      have h9 : \u2200 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 : \u2115) (x : \u211a) :\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 : \u00ac\u00acp) : p := or.elim (em p) (assume Hp : p, Hp) (assume Hnp : \u00acp, absurd Hnp H)\n\nlemma tag_eq_of_eq {A : Type} {P : A \u2192 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 \u00d7 B\n\ntheorem prod_eta : (x.1,x.2) = x := prod.rec_on x (\u03bb a b, rfl)\n\ntheorem eq_of_prod {A B : Type} {p q : A \u00d7 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 \u2192 B) [inhabited A] : image f univ \u2260 \u2205 :=\nhave (\u2205 : set A) \u2260 univ, from empty_ne_univ,\nhave \u2203 a, a \u2208 (univ : set A), from exists_mem_of_ne_empty (ne.symm this),\nlet \u27e8a,h\u27e9 := this in\nhave f a \u2208 image f univ, from exists.intro a (and.intro h rfl),\nset.ne_empty_of_mem this\n\ntheorem val_mapsto (n : \u2115) : maps_to fin.val (@univ (fin n)) {i : \u2115 | i < n} :=\ntake x, assume Ha, is_lt x\n\ntheorem injective_val_on_univ (n : \u2115): inj_on fin.val (@univ (fin n)) :=\ntake x\u2081 x\u2082, assume H1, assume H2, assume eq, eq_of_veq eq\n\ninstance finite_univ_of_fin (n : \u2115) : 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 \u2192 B) : set.image f (@set.univ A) = {b : B | \u2203 x, f x = b} :=\nhave Hl : set.image f (@set.univ A) \u2286 {b : B | \u2203 x, f x = b}, from \n  take x, assume Hx, \n  let \u27e8i,h\u27e9 := Hx in exists.intro i (and.right h),\nhave {b : B | \u2203 x, f x = b} \u2286 set.image f  (@set.univ A), from \n  take x, assume Hx, \n  let \u27e8i,h\u27e9 := Hx in exists.intro i (and.intro trivial h),\nset.subset.antisymm Hl this\n\ntheorem finite_image_of_fin {A : Type} {n : \u2115} (f : fin n \u2192 A) : finite {a : A | \u2203 x, f x = a} := \nhave image f (@univ (fin n)) = {a : A | \u2203 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 : \u2115 \u2192 finite_tree\ntheorem finite_tree_destruct {t : finite_tree} :\n\u2203 n (ss : fin n \u2192 finite_tree), t = cons ss :=\nfinite_tree.cases_on t (\u03bb n a, \u27e8n,a,rfl\u27e9)\n\ndefinition num_of_branches_at_root : finite_tree \u2192 \u2115\n| (@cons n ts) := n\n\n-- definition num_of_branches_at_root (t : finite_tree) (H : t \u2260 node) : \u2115 := \n-- some (exists_eq_cons_of_ne_node H)\n\n-- definition branches_at_root : finite_tree \u2192 \u03a0 {n : \u2115}, fin n \u2192 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 : \u2115} : finite_tree \u2192 set (finite_tree \u00d7 \u2115)\n-- | (@cons n ts) := {x : finite_tree \u00d7 \u2115 | \u2203 a : fin n, ts a = x.1 \u2227 val a = x.2}\n\n-- {x : finite_tree \u00d7 \u2115 | \u2203 a : fin n, ts a = x.1 \u2227 val a = x.2}\n\ndef branches_aux {n : \u2115} (ts : fin n \u2192 finite_tree) : set (finite_tree \u00d7 \u2115) := \n{x : finite_tree \u00d7 \u2115 | \u2203 a : fin n, ts a = x.1 \u2227 val a = x.2}\n\ntheorem empty_branches (ts : fin 0 \u2192 finite_tree) : branches_aux ts = \u2205 :=\nhave \u2200 x, x \u2209 branches_aux ts, from \u03bb x h, let \u27e8a,ha\u27e9 := h in fin_zero_absurd a,\nset.eq_empty_of_forall_not_mem this\n\ndefinition branches : finite_tree \u2192 set (finite_tree \u00d7 \u2115) \n| (@cons n ts) := branches_aux ts\n\ntheorem embeds_of_branches {t : finite_tree \u00d7 \u2115} {T : finite_tree} : t \u2208 (branches T) \u2192 t.1 \u227c 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 \u00d7 \u2115} {T : finite_tree} : t \u2208 branches T \u2192 size t.1 < size T :=\nbegin \ncases T with n ts,\nintro h,\nassert h' : \u2203 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 : \u2115} (ts : fin n \u2192 finite_tree) : finite (branches_aux ts) := \nlet f (a : fin n) : finite_tree \u00d7 \u2115 := (ts a, val a) in\nlet S : set (finite_tree \u00d7 \u2115) := {x : finite_tree \u00d7 \u2115 | \u2203 a : fin n, f a = x} in\nhave finS : finite S, from finite_image_of_fin f,\nhave H1 : S \u2286 branches_aux ts, from \n  \u03bb x \u27e8a,h\u27e9, \u27e8a,\u27e8by rw -h,by rw -h\u27e9\u27e9,\nhave H2 : branches_aux ts \u2286 S, from \n  \u03bb x \u27e8a,h\u27e9, \u27e8a,begin dsimp,rw [h^.left, h^.right], apply prod_eta end\u27e9, \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 : \u2203 f, \u00ac is_good f embeds\n\ndefinition mbs_of_finite_tree := minimal_bad_seq size H \n\ntheorem bad_mbs_finite_tree : \u00ac is_good mbs_of_finite_tree embeds := badness_of_mbs size H\n\ntheorem ne_node_of_elt_of_mbs_finite_tree (n : \u2115) {ts : fin 0 \u2192 finite_tree} : mbs_of_finite_tree n \u2260 cons ts :=\nassume Hneg,\nhave cons ts  \u227c mbs_of_finite_tree (succ n), by apply node_embeds,\nhave Hr : mbs_of_finite_tree n \u227c 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 : \u2115 \u2192 finite_tree) (Hf : \u00ac is_good f embeds) : size (mbs_of_finite_tree 0) \u2264 size (f 0) := minimality_of_mbs_0 size H f Hf\n\ntheorem minimality_of_mbs_finite_tree (n : \u2115) (f : \u2115 \u2192 finite_tree) (H1 : extends_at n mbs_of_finite_tree f \u2227 \u00ac is_good f embeds) : size (mbs_of_finite_tree (succ n)) \u2264 size (f (succ n)) := minimality_of_mbs size H n f H1\n\ndefinition seq_branches_of_mbs_tree (n : \u2115) : set (finite_tree \u00d7 \u2115) := branches (mbs_of_finite_tree n)\n\ntheorem mem_of_seq_branches {n i : \u2115} (ts : fin n \u2192 finite_tree) (k : fin n) (Heq : mbs_of_finite_tree i = cons ts) : (ts k, val k) \u2208 seq_branches_of_mbs_tree i :=\nhave ts k = (ts k, val k).1 \u2227 val k = (ts k, val k).2, from and.intro rfl rfl,\nhave \u2203 a, ts a = (ts k, val k).1 \u2227 val a = (ts k, val k).2, from exists.intro k this,\nhave (ts k, val k) \u2208 branches (cons ts), from this,\nby rw -Heq at this;exact this\n\ndefinition mbs_tree : Type := {t : finite_tree \u00d7 \u2115 // \u2203 i, t \u2208 seq_branches_of_mbs_tree i}\n\ndefinition embeds' (t : mbs_tree) (s : mbs_tree) : Prop := t.val.1 \u227c 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 \u2192 embeds' b c \u2192 embeds' a c :=\nassume H\u2081, assume H\u2082, embeds_trans H\u2081 H\u2082\n\nsection\n\nparameter H' : \u2203 f, \u00ac is_good f embeds'\n\ndefinition R : \u2115 \u2192 mbs_tree := some H'\n\ndefinition family_index (n : \u2115) : \u2115 := some ((R n).2) \n\ndefinition index_set_of_mbs_tree : set \u2115 := image family_index  univ\n\nlemma index_ne_empty : index_set_of_mbs_tree \u2260 \u2205 := 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 : \u2203 i, family_index i = least_family_index :=\nhave least_family_index \u2208 index_set_of_mbs_tree, from least_is_mem index_set_of_mbs_tree index_ne_empty,\nlet \u27e8i,h\u27e9 := this in\n\u27e8i, h^.right\u27e9\n\ndefinition least_index : \u2115 := some exists_least\n\ndefinition Kruskal's_g (n : \u2115) : mbs_tree := R (least_index + n)\n\ndefinition Kruskal's_h (n : \u2115) : \u2115 :=  family_index (least_index + n)\n\ntheorem bad_Kruskal's_g : \u00ac is_good Kruskal's_g embeds' :=\nsuppose is_good Kruskal's_g embeds',\nlet \u27e8i,j,hij\u27e9 := 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 \u27e8least_index + i, \u27e8least_index + j,\u27e8this, Hr\u27e9\u27e9\u27e9,\n(some_spec H') this\n\ntheorem Kruskal's_Hg : \u00ac is_good (fst \u2218 (val \u2218 Kruskal's_g)) embeds := bad_Kruskal's_g\n\ntheorem trans_of_Kruskal's_g {i j : \u2115} (H1 : mbs_of_finite_tree i \u227c (Kruskal's_g j).val.1) : \nmbs_of_finite_tree i \u227c mbs_of_finite_tree (Kruskal's_h j) := \nhave (Kruskal's_g j).val \u2208 branches (mbs_of_finite_tree (Kruskal's_h j)), from some_spec (Kruskal's_g j).2,\nhave (Kruskal's_g j).val.1 \u227c 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 : \u2115) : 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 : \u2115) : Kruskal's_h n \u2208 index_set_of_mbs_tree :=\nhave Kruskal's_h n = family_index (least_index + n), from rfl,\n\u27e8(least_index + n),\u27e8trivial,rfl\u27e9\u27e9\n\ntheorem Kruskal's_Hh (n : \u2115) : Kruskal's_h 0 \u2264 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 : \u2200 i j, mbs_of_finite_tree i \u227c (Kruskal's_g (j - Kruskal's_h 0)).val.1 \u2192 mbs_of_finite_tree i \u227c mbs_of_finite_tree (Kruskal's_h (j - Kruskal's_h 0)) := \u03bb i j, \u03bb H1, trans_of_Kruskal's_g H1\n\ndefinition Kruskal's_comb_seq (n : \u2115) : finite_tree := @comb_seq_with_mbs _ embeds (fst \u2218 (val \u2218 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 : \u2200 f, is_good f embeds' := \nby_contradiction\n(suppose \u00ac \u2200 f, is_good f embeds',\n have \u2203 f, \u00ac 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\u27e8\u27e8\u27e8embeds'\u27e9,embeds'_refl,embeds'_trans\u27e9,embeds'_is_good\u27e9\n\ndefinition wqo_finite_subsets_of_mbs_tree : wqo (finite_subsets mbs_tree) := wqo_finite_subsets\n\ndefinition os : finite_subsets mbs_tree \u2192 finite_subsets mbs_tree \u2192 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 : \u2115 \u2192 finite_subsets mbs_tree,  there exists i j such that there exists a f' : mbs_tree \u2192 mbs_tree which is injective and nondescending from (f i) to (f j). \ntheorem good_finite_subsets_of_mbs_tree : \u2200 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 \u2192 fin m for some n,m \u2208 \u2115, 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 : \u2115) : set mbs_tree := {x : mbs_tree | x.1 \u2208 seq_branches_of_mbs_tree n}\n\ntheorem mirror_refl_left (x : mbs_tree) (n : \u2115) : x \u2208 elt_mirror n \u2192 x.1 \u2208 seq_branches_of_mbs_tree n := \u03bb Hx, Hx\n\ntheorem mirror_refl_right (x : mbs_tree) (n : \u2115) : x.1 \u2208 seq_branches_of_mbs_tree n \u2192 x \u2208 elt_mirror n := \u03bb Hx, Hx\n\ninstance  finite_seq_branches (n : \u2115) : finite (seq_branches_of_mbs_tree n) := finite_branches (mbs_of_finite_tree n)\n\ntheorem finite_elt (n : \u2115) : finite (elt_mirror n) := \nhave mapsto : maps_to subtype.val (elt_mirror n) (seq_branches_of_mbs_tree n), from \u03bb x Hx, mirror_refl_left x n Hx,\nhave inj_on subtype.val (elt_mirror n), from \u03bb x\u2081 x\u2082 H\u2081 H\u2082, 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 : \u2115) : finite_subsets mbs_tree := \u27e8elt_mirror n, finite_elt n\u27e9\n\n-- (mirror i) is the collection of branches at the root of (mbs_of_finite_tree i)\n\ntheorem good_mirror : \u2203 i j, i < j \u2227 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 \u227c 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 \u2192 fin nj such that tsi ti \u227c 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 : \u2115}\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 \u2192 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 : \u2200 a : mbs_tree, a.val \u2208 seq_branches_of_mbs_tree i \u2192 a.val.1 \u227c (f' a).val.1 \u2227  (f' a).val \u2208 seq_branches_of_mbs_tree j\n-- suppose (mbs_of_finite_tree i) is of the form (cons tsi)\nparameters ni nj : \u2115\nparameters (tsi : fin ni \u2192 finite_tree) (tsj : fin nj \u2192 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 : \u2200 a, (tsi a, val a) \u2208 seq_branches_of_mbs_tree i\n\n-- lemma eltini (ti : fin ni) : (tsi ti, val ti) \u2208 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) : \u2203 i, (tsi ti, val ti) \u2208 seq_branches_of_mbs_tree i := \u27e8i,Htsi ti\u27e9\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 := \u27e8(tsi ti, val ti),(foo ti)\u27e9\n\ntheorem mem_mbst_form (a : fin ni) : mbst_form a \u2208 elt_mirror i := Htsi a\n\ntheorem eq_of_mbst_form {a\u2081 a\u2082 : fin ni} (Heq : mbst_form a\u2081 = mbst_form a\u2082) : a\u2081 = a\u2082 :=\nby apply eq_of_veq;super\n\n-- lemma mem (ti : fin ni) : (f' (mbst_form ti)).val \u2208 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 \u2208 seq_branches_of_mbs_tree j, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right,\nhave mem : (f' (mbst_form ti)).val \u2208 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 \u2208 branches_aux tsj, by rw this at mem;exact mem,\n-- have \u2203 a : fin nj, tsj a = (f' (mbst_form ti)).val.1 \u2227 val a = (f' (mbst_form ti)).val.2, from this,\nsome this\n\ntheorem perm_recover (ti : fin ni) : tsi ti \u227c tsj (recover ti) := \nhave (f' (mbst_form ti)).val \u2208 seq_branches_of_mbs_tree j, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right,\nhave mem : (f' (mbst_form ti)).val \u2208 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 \u2208 branches_aux tsj, by rw this at mem;exact mem,\n-- have \u2203 a : fin nj, tsj a = (f' (mbst_form ti)).val.1 \u2227 val a =  (f' (mbst_form ti)).val.2, from this,\nhave tsj (recover ti) = (f' (mbst_form ti)).val.1, from let \u27e8a,b\u27e9 := some_spec this in a,\nhave tsi ti \u227c (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\u03bb a\u2081 a\u2082 Heq,\nhave (f' (mbst_form a\u2081)).val \u2208 seq_branches_of_mbs_tree j, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right,\nhave mem : (f' (mbst_form a\u2081)).val \u2208 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\u2081)).val \u2208 branches_aux tsj, by rw this at mem;exact mem,\n\nhave eeq1 : \u2203 a : fin nj, tsj a = (f' (mbst_form a\u2081)).val.1 \u2227 val a = (f' (mbst_form a\u2081)).val.2, from this,\nhave pr11 : tsj (recover a\u2081) = (f' (mbst_form a\u2081)).val.1, from let \u27e8a,b\u27e9 := some_spec eeq1 in a,-- proof and.left (some_spec eeq1) qed,\nhave pr21 : val (recover a\u2081) = (f' (mbst_form a\u2081)).val.2, from let \u27e8a,b\u27e9 := some_spec eeq1 in b, -- proof and.right (some_spec eeq1) qed,\nhave (f' (mbst_form a\u2082)).val \u2208 seq_branches_of_mbs_tree j, from (nond _ (begin dsimp [mbst_form], apply Htsi end))^.right,-- proof and.right (nond _ (eltini a\u2082)) qed,\nhave mem : (f' (mbst_form a\u2082)).val \u2208 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\u2082)).val \u2208 branches_aux tsj, by rw this at mem;exact mem,\nhave eeq2 : \u2203 a : fin nj, tsj a = (f' (mbst_form a\u2082)).val.1 \u2227 val a = (f' (mbst_form a\u2082)).val.2, from this,\nhave pr12 : tsj (recover a\u2082) = (f' (mbst_form a\u2082)).val.1,  from let \u27e8a,b\u27e9 := some_spec eeq2 in a,-- proof and.left (some_spec eeq2) qed,\nhave pr22 : val (recover a\u2082) = (f' (mbst_form a\u2082)).val.2, from let \u27e8a,b\u27e9 := some_spec eeq2 in b,-- proof and.right (some_spec eeq2) qed,\nhave eq1 : (f' (mbst_form a\u2081)).val.1 = (f' (mbst_form a\u2082)).val.1, by rw [-pr12, -pr11, Heq],\nhave (f' (mbst_form a\u2081)).val.2 = (f' (mbst_form a\u2082)).val.2, by rw [-pr22,-pr21,Heq],\nhave (f' (mbst_form a\u2081)).val = (f' (mbst_form a\u2082)).val, from eq_of_prod eq1 this,\nhave f'eq : f' (mbst_form a\u2081) = f' (mbst_form a\u2082), from subtype.eq this,\nhave \u2200 x\u2081 x\u2082 : mbs_tree, x\u2081 \u2208 elt_mirror i \u2192 x\u2082 \u2208 elt_mirror i \u2192 f' x\u2081 = f' x\u2082 \u2192 x\u2081 = x\u2082, from and.right inj,\nhave mbst_form a\u2081 = mbst_form a\u2082, from this (mbst_form a\u2081) (mbst_form a\u2082) (mem_mbst_form a\u2081) (mem_mbst_form a\u2082) 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 :  \u2203 i j, i < j \u2227 mbs_of_finite_tree i \u227c mbs_of_finite_tree j :=\nlet \u27e8i,j,\u27e8iltj,\u27e8f',\u27e8inj,nond\u27e9\u27e9\u27e9\u27e9 := good_mirror in\nlet \u27e8ni,tsi,htsi\u27e9 := @finite_tree_destruct (mbs_of_finite_tree i) in\nlet \u27e8nj,tsj,htsj\u27e9 := @finite_tree_destruct (mbs_of_finite_tree j) in\nhave Htsi : \u2200 a, (tsi a, val a) \u2208 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 \u2200 z : fin ni, tsi z \u227c tsj (f z), from \u03bb z, perm_recover _ _ _ _ _ _ _ _ _,\nhave cons tsi \u227c cons tsj, from or.inr \u27e8f,\u27e8injf,this\u27e9\u27e9,\nhave mbs_of_finite_tree i \u227c mbs_of_finite_tree j, by simph,\n\u27e8i,j,\u27e8iltj,this\u27e9\u27e9\n\ntheorem Kruskal's_contradiction : false := bad_mbs_finite_tree good_mbs_of_finite_tree\n\nend\n\ntheorem embeds_is_good : \u2200 f, is_good f embeds :=\nby_contradiction\n(suppose \u00ac \u2200 f, is_good f embeds,\n have \u2203 f, \u00ac 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\u27e8\u27e8\u27e8embeds\u27e9,embeds_refl,@embeds_trans\u27e9,embeds_is_good\u27e9\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\u207b\u00b9 * b = a * b`.\n\nFirst we introduce the one step reduction relation\n  `free_group.red.step`:  w * x * x\u207b\u00b9 * 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 \u03b1` 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 {\u03b1 : Type u}\n\nlocal attribute [simp] list.append_eq_has_append\n\nnamespace free_group\nvariables {L L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)}\n\n/-- Reduction step: `w * x * x\u207b\u00b9 * v ~> w * v` -/\ninductive red.step : list (\u03b1 \u00d7 bool) \u2192 list (\u03b1 \u00d7 bool) \u2192 Prop\n| bnot {L\u2081 L\u2082 x b} : red.step (L\u2081 ++ (x, b) :: (x, bnot b) :: L\u2082) (L\u2081 ++ L\u2082)\nattribute [simp] red.step.bnot\n\n/-- Reflexive-transitive closure of red.step -/\ndef red : list (\u03b1 \u00d7 bool) \u2192 list (\u03b1 \u00d7 bool) \u2192 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\u2081 L\u2082 \u2192 red L\u2082 L\u2083 \u2192 red L\u2081 L\u2083 := refl_trans_gen.trans\n\nnamespace red\n\n/-- Predicate asserting that word `w\u2081` can be reduced to `w\u2082` in one step, i.e. there are words\n`w\u2083 w\u2084` and letter `x` such that `w\u2081 = w\u2083xx\u207b\u00b9w\u2084` and `w\u2082 = w\u2083w\u2084`  -/\ntheorem step.length : \u2200 {L\u2081 L\u2082 : list (\u03b1 \u00d7 bool)}, step L\u2081 L\u2082 \u2192 L\u2082.length + 2 = L\u2081.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\u2081 ++ (x, bnot b) :: (x, b) :: L\u2082) (L\u2081 ++ L\u2082) :=\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 : \u2200 {L\u2081 L\u2082 L\u2083 : list (\u03b1 \u00d7 bool)}, step L\u2082 L\u2083 \u2192 step (L\u2081 ++ L\u2082) (L\u2081 ++ L\u2083)\n| _ _ _ red.step.bnot := by rw [\u2190 list.append_assoc, \u2190 list.append_assoc]; constructor\n\ntheorem step.cons {x} (H : red.step L\u2081 L\u2082) : red.step (x :: L\u2081) (x :: L\u2082) :=\n@step.append_left _ [x] _ _ H\n\ntheorem step.append_right : \u2200 {L\u2081 L\u2082 L\u2083 : list (\u03b1 \u00d7 bool)}, step L\u2081 L\u2082 \u2192 step (L\u2081 ++ L\u2083) (L\u2082 ++ L\u2083)\n| _ _ _ red.step.bnot := by simp\n\nlemma not_step_nil : \u00ac step [] L :=\nbegin\n  generalize h' : [] = L',\n  assume h,\n  cases h with L\u2081 L\u2082,\n  simp [list.nil_eq_append_iff] at h',\n  contradiction\nend\n\nlemma step.cons_left_iff {a : \u03b1} {b : bool} :\n  step ((a, b) :: L\u2081) L\u2082 \u2194 (\u2203L, step L\u2081 L \u2227 L\u2082 = (a, b) :: L) \u2228 (L\u2081 = (a, bnot b)::L\u2082) :=\nbegin\n  split,\n  { generalize hL : ((a, b) :: L\u2081 : list _) = L,\n    assume h,\n    rcases h with \u27e8_ | \u27e8p, s'\u27e9, e, a', b'\u27e9,\n    { simp at hL, simp [*] },\n    { simp at hL,\n      rcases hL with \u27e8rfl, rfl\u27e9,\n      refine or.inl \u27e8s' ++ e, step.bnot, _\u27e9,\n      simp } },\n  { assume h,\n    rcases h with \u27e8L, h, rfl\u27e9 | rfl,\n    { exact step.cons h },\n    { exact step.cons_bnot } }\nend\n\nlemma not_step_singleton : \u2200 {p : \u03b1 \u00d7 bool}, \u00ac step [p] L\n| (a, b) := by simp [step.cons_left_iff, not_step_nil]\n\nlemma step.cons_cons_iff : \u2200{p : \u03b1 \u00d7 bool}, step (p :: L\u2081) (p :: L\u2082) \u2194 step L\u2081 L\u2082 :=\nby simp [step.cons_left_iff, iff_def, or_imp_distrib] {contextual := tt}\n\nlemma step.append_left_iff : \u2200L, step (L ++ L\u2081) (L ++ L\u2082) \u2194 step L\u2081 L\u2082\n| [] := by simp\n| (p :: l) := by simp [step.append_left_iff l, step.cons_cons_iff]\n\nprivate theorem step.diamond_aux : \u2200 {L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)} {x1 b1 x2 b2},\n  L\u2081 ++ (x1, b1) :: (x1, bnot b1) :: L\u2082 = L\u2083 ++ (x2, b2) :: (x2, bnot b2) :: L\u2084 \u2192\n  L\u2081 ++ L\u2082 = L\u2083 ++ L\u2084 \u2228 \u2203 L\u2085, red.step (L\u2081 ++ L\u2082) L\u2085 \u2227 red.step (L\u2083 ++ L\u2084) L\u2085\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 \u27e8_, red.step.bnot, red.step.cons_bnot\u27e9\n| ((x3,b3)::(x4,b4)::tl) _ []                     _ _ _ _ _ H :=\n  by injections; subst_vars; simp; right; exact \u27e8_, red.step.cons_bnot, red.step.bnot\u27e9\n| ((x3,b3)::tl) _ ((x4,b4)::tl2) _ _ _ _ _ H :=\n  let \u27e8H1, H2\u27e9 := 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 \u27e8L\u2085, H3, H4\u27e9 := or.inr\n      \u27e8_, step.cons H3, by simpa [H1] using step.cons H4\u27e9\n  end\n\ntheorem step.diamond : \u2200 {L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)},\n  red.step L\u2081 L\u2083 \u2192 red.step L\u2082 L\u2084 \u2192 L\u2081 = L\u2082 \u2192\n  L\u2083 = L\u2084 \u2228 \u2203 L\u2085, red.step L\u2083 L\u2085 \u2227 red.step L\u2084 L\u2085\n| _ _ _ _ red.step.bnot red.step.bnot H := step.diamond_aux H\n\nlemma step.to_red : step L\u2081 L\u2082 \u2192 red L\u2081 L\u2082 :=\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\u2081 L\u2082 \u2192 red L\u2081 L\u2083 \u2192 join red L\u2082 L\u2083 :=\nrelation.church_rosser (assume a b c hab hac,\nmatch b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := \u27e8b, by refl, by refl\u27e9\n| b, c, or.inr \u27e8d, hbd, hcd\u27e9 := \u27e8d, refl_gen.single hbd, hcd.to_red\u27e9\nend)\n\nlemma cons_cons {p} : red L\u2081 L\u2082 \u2192 red (p :: L\u2081) (p :: L\u2082) :=\nrefl_trans_gen_lift (list.cons p) (assume a b, step.cons)\n\nlemma cons_cons_iff (p) : red (p :: L\u2081) (p :: L\u2082) \u2194 red L\u2081 L\u2082 :=\niff.intro\n  begin\n    generalize eq\u2081 : (p :: L\u2081 : list _) = LL\u2081,\n    generalize eq\u2082 : (p :: L\u2082 : list _) = LL\u2082,\n    assume h,\n    induction h using relation.refl_trans_gen.head_induction_on\n      with L\u2081 L\u2082 h\u2081\u2082 h ih\n      generalizing L\u2081 L\u2082,\n    { subst_vars, cases eq\u2082, constructor },\n    { subst_vars,\n      cases p with a b,\n      rw [step.cons_left_iff] at h\u2081\u2082,\n      rcases h\u2081\u2082 with \u27e8L, h\u2081\u2082, rfl\u27e9 | rfl,\n      { exact (ih rfl rfl).head h\u2081\u2082 },\n      { exact (cons_cons h).tail step.cons_bnot_rev } }\n  end\n  cons_cons\n\nlemma append_append_left_iff : \u2200L, red (L ++ L\u2081) (L ++ L\u2082) \u2194 red L\u2081 L\u2082\n| []       := iff.refl _\n| (p :: L) := by simp [append_append_left_iff L, cons_cons_iff]\n\nlemma append_append (h\u2081 : red L\u2081 L\u2083) (h\u2082 : red L\u2082 L\u2084) : red (L\u2081 ++ L\u2082) (L\u2083 ++ L\u2084) :=\n(refl_trans_gen_lift (\u03bbL, L ++ L\u2082) (assume a b, step.append_right) h\u2081).trans\n  ((append_append_left_iff _).2 h\u2082)\n\nlemma to_append_iff : red L (L\u2081 ++ L\u2082) \u2194 (\u2203L\u2083 L\u2084, L = L\u2083 ++ L\u2084 \u2227 red L\u2083 L\u2081 \u2227 red L\u2084 L\u2082) :=\niff.intro\n  begin\n    generalize eq : L\u2081 ++ L\u2082 = L\u2081\u2082,\n    assume h,\n    induction h with L' L\u2081\u2082 hLL' h ih generalizing L\u2081 L\u2082,\n    { exact \u27e8_, _, eq.symm, by refl, by refl\u27e9 },\n    { cases h with s e a b,\n      rcases list.append_eq_append_iff.1 eq with \u27e8s', rfl, rfl\u27e9 | \u27e8e', rfl, rfl\u27e9,\n      { have : L\u2081 ++ (s' ++ ((a, b) :: (a, bnot b) :: e)) = (L\u2081 ++ s') ++ ((a, b) :: (a, bnot b) :: e),\n        { simp },\n        rcases ih this with \u27e8w\u2081, w\u2082, rfl, h\u2081, h\u2082\u27e9,\n        exact \u27e8w\u2081, w\u2082, rfl, h\u2081, h\u2082.tail step.bnot\u27e9 },\n      { have : (s ++ ((a, b) :: (a, bnot b) :: e')) ++ L\u2082 = s ++ ((a, b) :: (a, bnot b) :: (e' ++ L\u2082)),\n        { simp },\n        rcases ih this with \u27e8w\u2081, w\u2082, rfl, h\u2081, h\u2082\u27e9,\n        exact \u27e8w\u2081, w\u2082, rfl, h\u2081.tail step.bnot, h\u2082\u27e9 }, }\n  end\n  (assume \u27e8L\u2083, L\u2084, eq, h\u2083, h\u2084\u27e9, eq.symm \u25b8 append_append h\u2083 h\u2084)\n\n/-- The empty word `[]` only reduces to itself. -/\ntheorem nil_iff : red [] L \u2194 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\u2081 \u2194 L\u2081 = [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\u207b\u00b9` -/\ntheorem cons_nil_iff_singleton {x b} : red ((x, b) :: L) [] \u2194 red L [(x, bnot b)] :=\niff.intro\n  (assume h,\n    have h\u2081 : red ((x, bnot b) :: (x, b) :: L) [(x, bnot b)], from cons_cons h,\n    have h\u2082 : red ((x, bnot b) :: (x, b) :: L) L, from refl_trans_gen.single step.cons_bnot_rev,\n    let \u27e8L', h\u2081, h\u2082\u27e9 := church_rosser h\u2081 h\u2082 in\n    by rw [singleton_iff] at h\u2081; 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) \u2260 (x2, b2)) :\n  red [(x1, bnot b1), (x2, b2)] L \u2194 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 \u27e8rfl, \u27e8rfl, rfl\u27e9, \u27e8rfl, rfl\u27e9, rfl\u27e9, subst_vars,\n  simp at h,\n  contradiction\nend\n\n/-- If `x` and `y` are distinct letters and `w\u2081 w\u2082` are words such that `xw\u2081` reduces to `yw\u2082`, then\n`w\u2081` reduces to `x\u207b\u00b9yw\u2082`. -/\ntheorem inv_of_red_of_ne {x1 b1 x2 b2}\n  (H1 : (x1, b1) \u2260 (x2, b2))\n  (H2 : red ((x1, b1) :: L\u2081) ((x2, b2) :: L\u2082)) :\n  red L\u2081 ((x1, bnot b1) :: (x2, b2) :: L\u2082) :=\nbegin\n  have : red ((x1, b1) :: L\u2081) ([(x2, b2)] ++ L\u2082), from H2,\n  rcases to_append_iff.1 this with \u27e8_ | \u27e8p, L\u2083\u27e9, L\u2084, eq, h\u2081, h\u2082\u27e9,\n  { simp [nil_iff] at h\u2081, contradiction },\n  { cases eq,\n    show red (L\u2083 ++ L\u2084) ([(x1, bnot b1), (x2, b2)] ++ L\u2082),\n    apply append_append _ h\u2082,\n    have h\u2081 : red ((x1, bnot b1) :: (x1, b1) :: L\u2083) [(x1, bnot b1), (x2, b2)],\n    { exact cons_cons h\u2081 },\n    have h\u2082 : red ((x1, bnot b1) :: (x1, b1) :: L\u2083) L\u2083,\n    { exact step.cons_bnot_rev.to_red },\n    rcases church_rosser h\u2081 h\u2082 with \u27e8L', h\u2081, h\u2082\u27e9,\n    rw [red_iff_irreducible H1] at h\u2081,\n    rwa [h\u2081] at h\u2082 }\nend\n\ntheorem step.sublist (H : red.step L\u2081 L\u2082) : L\u2082 <+ L\u2081 :=\nby cases H; simp; constructor; constructor; refl\n\n/-- If `w\u2081 w\u2082` are words such that `w\u2081` reduces to `w\u2082`, then `w\u2082` is a sublist of `w\u2081`. -/\ntheorem sublist : red L\u2081 L\u2082 \u2192 L\u2082 <+ L\u2081 :=\nrefl_trans_gen_of_transitive_reflexive\n  (\u03bbl, list.sublist.refl l) (\u03bba b c hab hbc, list.sublist.trans hbc hab) (\u03bba b, red.step.sublist)\n\ntheorem sizeof_of_step : \u2200 {L\u2081 L\u2082 : list (\u03b1 \u00d7 bool)}, step L\u2081 L\u2082 \u2192 L\u2082.sizeof < L\u2081.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\u2081 L\u2082) : \u2203 n, L\u2081.length = L\u2082.length + 2 * n :=\nbegin\n  induction h with L\u2082 L\u2083 h\u2081\u2082 h\u2082\u2083 ih,\n  { exact \u27e80, rfl\u27e9 },\n  { rcases ih with \u27e8n, eq\u27e9,\n    existsi (1 + n),\n    simp [mul_add, eq, (step.length h\u2082\u2083).symm] }\nend\n\ntheorem antisymm (h\u2081\u2082 : red L\u2081 L\u2082) : red L\u2082 L\u2081 \u2192 L\u2081 = L\u2082 :=\nmatch L\u2081, h\u2081\u2082.cases_head with\n| _,  or.inl rfl            := assume h, rfl\n| L\u2081, or.inr \u27e8L\u2083, h\u2081\u2083, h\u2083\u2082\u27e9 := assume h\u2082\u2081,\n  let \u27e8n, eq\u27e9 := length (h\u2083\u2082.trans h\u2082\u2081) in\n  have list.length L\u2083 + 0 = list.length L\u2083 + (2 * n + 2),\n    by simpa [(step.length h\u2081\u2083).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 \u03b1)) :=\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           := \u27e8b, by refl, by refl\u27e9\n| b, c, or.inr \u27e8d, hbd, hcd\u27e9 := \u27e8d, refl_gen.single hbd, refl_trans_gen.single hcd\u27e9\nend)\n\ntheorem join_red_of_step (h : red.step L\u2081 L\u2082) : join red L\u2081 L\u2082 :=\njoin_of_single reflexive_refl_trans_gen h.to_red\n\ntheorem eqv_gen_step_iff_join_red : eqv_gen red.step L\u2081 L\u2082 \u2194 join red L\u2081 L\u2082 :=\niff.intro\n  (assume h,\n    have eqv_gen (join red) L\u2081 L\u2082 := 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 (\u03b1 : Type u) : Type u :=\nquot $ @free_group.red.step \u03b1\n\nnamespace free_group\n\nvariables {\u03b1} {L L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)}\n\ndef mk (L) : free_group \u03b1 := 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 (\u03b2 : Type v) (f : list (\u03b1 \u00d7 bool) \u2192 \u03b2)\n  (H : \u2200 L\u2081 L\u2082, red.step L\u2081 L\u2082 \u2192 f L\u2081 = f L\u2082) :\nquot.lift f H (mk L) = f L := rfl\n\n@[simp] lemma quot_lift_on_mk (\u03b2 : Type v) (f : list (\u03b1 \u00d7 bool) \u2192 \u03b2)\n  (H : \u2200 L\u2081 L\u2082, red.step L\u2081 L\u2082 \u2192 f L\u2081 = f L\u2082) :\nquot.lift_on (mk L) f H = f L := rfl\n\ninstance : has_one (free_group \u03b1) := \u27e8mk []\u27e9\nlemma one_eq_mk : (1 : free_group \u03b1) = mk [] := rfl\n\ninstance : has_mul (free_group \u03b1) :=\n\u27e8\u03bb x y, quot.lift_on x\n    (\u03bb L\u2081, quot.lift_on y (\u03bb L\u2082, mk $ L\u2081 ++ L\u2082) (\u03bb L\u2082 L\u2083 H, quot.sound $ red.step.append_left H))\n    (\u03bb L\u2081 L\u2082 H, quot.induction_on y $ \u03bb L\u2083, quot.sound $ red.step.append_right H)\u27e9\n@[simp] lemma mul_mk : mk L\u2081 * mk L\u2082 = mk (L\u2081 ++ L\u2082) := rfl\n\ninstance : has_inv (free_group \u03b1) :=\n\u27e8\u03bbx, quot.lift_on x (\u03bb L, mk (L.map $ \u03bb x : \u03b1 \u00d7 bool, (x.1, bnot x.2)).reverse)\n  (assume a b h, quot.sound $ by cases h; simp)\u27e9\n@[simp] lemma inv_mk : (mk L)\u207b\u00b9 = mk (L.map $ \u03bb x : \u03b1 \u00d7 bool, (x.1, bnot x.2)).reverse := rfl\n\ninstance : group (free_group \u03b1) :=\n{ mul := (*),\n  one := 1,\n  inv := has_inv.inv,\n  mul_assoc := by rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9 \u27e8L\u2083\u27e9; simp,\n  one_mul := by rintros \u27e8L\u27e9; refl,\n  mul_one := by rintros \u27e8L\u27e9; simp [one_eq_mk],\n  mul_left_inv := by rintros \u27e8L\u27e9; exact (list.rec_on L rfl $\n    \u03bb \u27e8x, b\u27e9 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 : \u03b1) : free_group \u03b1 :=\nmk [(x, tt)]\n\ntheorem red.exact : mk L\u2081 = mk L\u2082 \u2194 join red L\u2081 L\u2082 :=\ncalc (mk L\u2081 = mk L\u2082) \u2194 eqv_gen red.step L\u2081 L\u2082 : iff.intro (quot.exact _) quot.eqv_gen_sound\n  ... \u2194 join red L\u2081 L\u2082 : 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 : \u03b1} (H : of x = of y) : x = y :=\nlet \u27e8L\u2081, hx, hy\u27e9 := red.exact.1 H in\nby simp [red.singleton_iff] at hx hy; cc\n\nsection to_group\n\nvariables {\u03b2 : Type v} [group \u03b2] (f : \u03b1 \u2192 \u03b2) {x y : free_group \u03b1}\n\ndef to_group.aux : list (\u03b1 \u00d7 bool) \u2192 \u03b2 :=\n\u03bb L, list.prod $ L.map $ \u03bb x, cond x.2 (f x.1) (f x.1)\u207b\u00b9\n\ntheorem red.step.to_group {f : \u03b1 \u2192 \u03b2} (H : red.step L\u2081 L\u2082) :\n  to_group.aux f L\u2081 = to_group.aux f L\u2082 :=\nby cases H with _ _ _ b; cases b; simp [to_group.aux]\n\n/-- If `\u03b2` is a group, then any function from `\u03b1` to `\u03b2`\nextends uniquely to a group homomorphism from\nthe free group over `\u03b1` to `\u03b2` -/\ndef to_group : free_group \u03b1 \u2192 \u03b2 :=\nquot.lift (to_group.aux f) $ \u03bb L\u2081 L\u2082 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 $ \u03bb x, cond x.2 (f x.1) (f x.1)\u207b\u00b9) :=\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\u27e8by rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9; simp\u27e9\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\u207b\u00b9 = (to_group f x)\u207b\u00b9 :=\nis_group_hom.inv _ _\n\ntheorem to_group.unique (g : free_group \u03b1 \u2192 \u03b2) [is_group_hom g]\n  (hg : \u2200 x, g (of x) = f x) : \u2200{x}, g x = to_group f x :=\nby rintros \u27e8L\u27e9; exact list.rec_on L (is_group_hom.one g)\n(\u03bb \u27e8x, b\u27e9 t (ih : g (mk t) = _), bool.rec_on b\n  (show g ((of x)\u207b\u00b9 * 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 \u03b1) : to_group of x = x :=\neq.symm $ to_group.unique id (\u03bb x, rfl)\n\ntheorem to_group.range_subset {s : set \u03b2} [is_subgroup s] (H : set.range f \u2286 s) :\n  set.range (to_group f) \u2286 s :=\nby rintros _ \u27e8\u27e8L\u27e9, rfl\u27e9; exact list.rec_on L (is_submonoid.one_mem s)\n(\u03bb \u27e8x, b\u27e9 tl ih, bool.rec_on b\n    (by simp at ih \u22a2; from is_submonoid.mul_mem\n      (is_subgroup.inv_mem $ H \u27e8x, rfl\u27e9) ih)\n    (by simp at ih \u22a2; from is_submonoid.mul_mem (H \u27e8x, rfl\u27e9) 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 $ \u03bb y \u27e8x, hx\u27e9, \u27e8of x, by simpa\u27e9)\n\nend to_group\n\nsection map\n\nvariables {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) {x y : free_group \u03b1}\n\ndef map.aux (L : list (\u03b1 \u00d7 bool)) : list (\u03b2 \u00d7 bool) :=\nL.map $ \u03bb x, (f x.1, x.2)\n\n/-- Any function from `\u03b1` to `\u03b2` extends uniquely\nto a group homomorphism from the free group\nver `\u03b1` to the free group over `\u03b2`. -/\ndef map (x : free_group \u03b1) : free_group \u03b2 :=\nx.lift_on (\u03bb L, mk $ map.aux f L) $\n\u03bb L\u2081 L\u2082 H, quot.sound $ by cases H; simp [map.aux]\n\ninstance map.is_group_hom : is_group_hom (map f) :=\n\u27e8by rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9; simp [map, map.aux]\u27e9\n\nvariable {f}\n\n@[simp] lemma map.mk : map f (mk L) = mk (L.map (\u03bb x, (f x.1, x.2))) :=\nrfl\n\n@[simp] lemma map.id : map id x = x :=\nhave H1 : (\u03bb (x : \u03b1 \u00d7 bool), x) = id := rfl,\nby rcases x with \u27e8L\u27e9; simp [H1]\n\n@[simp] lemma map.id' : map (\u03bb z, z) x = x := map.id\n\ntheorem map.comp {\u03b3 : Type w} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} {x} :\n  map g (map f x) = map (g \u2218 f) x :=\nby rcases x with \u27e8L\u27e9; 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\u207b\u00b9 = (map f x)\u207b\u00b9 :=\nis_group_hom.inv _ x\n\ntheorem map.unique (g : free_group \u03b1 \u2192 free_group \u03b2) [is_group_hom g]\n  (hg : \u2200 x, g (of x) = of (f x)) : \u2200{x}, g x = map f x :=\nby rintros \u27e8L\u27e9; exact list.rec_on L (is_group_hom.one g)\n(\u03bb \u27e8x, b\u27e9 t (ih : g (mk t) = map f (mk t)), bool.rec_on b\n  (show g ((of x)\u207b\u00b9 * mk t) = map f ((of x)\u207b\u00b9 * 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 {\u03b1 \u03b2} (e : \u03b1 \u2243 \u03b2) : free_group \u03b1 \u2243 free_group \u03b2 :=\n\u27e8map e, map e.symm,\n \u03bb x, by simp [function.comp, map.comp],\n \u03bb x, by simp [function.comp, map.comp]\u27e9\n\ntheorem map_eq_to_group : map f x = to_group (of \u2218 f) x :=\neq.symm $ map.unique _ $ \u03bb x, by simp\n\nend map\n\nsection prod\n\nvariables [group \u03b1] (x y : free_group \u03b1)\n\n/-- If `\u03b1` is a group, then any function from `\u03b1` to `\u03b1`\nextends uniquely to a homomorphism from the\nfree group over `\u03b1` to `\u03b1`. This is the multiplicative\nversion of `sum`. -/\ndef prod : \u03b1 :=\nto_group id x\n\nvariables {x y}\n\n@[simp] lemma prod_mk :\n  prod (mk L) = list.prod (L.map $ \u03bb x, cond x.2 x.1 x.1\u207b\u00b9) :=\nrfl\n\n@[simp] lemma prod.of {x : \u03b1} : prod (of x) = x :=\nto_group.of\n\ninstance prod.is_group_hom : is_group_hom (@prod \u03b1 _) :=\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 \u03b1) = 1 :=\nto_group.one\n\n@[simp] lemma prod.inv : prod x\u207b\u00b9 = (prod x)\u207b\u00b9 :=\nto_group.inv\n\nlemma prod.unique (g : free_group \u03b1 \u2192 \u03b1) [is_group_hom g]\n  (hg : \u2200 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 {\u03b2 : Type v} [group \u03b2] {f : \u03b1 \u2192 \u03b2} {x} :\n  to_group f x = prod (map f x) :=\neq.symm $ to_group.unique (prod \u2218 map f) $ \u03bb _, by simp\n\nsection sum\n\nvariables [add_group \u03b1] (x y : free_group \u03b1)\n\n/-- If `\u03b1` is a group, then any function from `\u03b1` to `\u03b1`\nextends uniquely to a homomorphism from the\nfree group over `\u03b1` to `\u03b1`. This is the additive\nversion of `prod`. -/\ndef sum : \u03b1 :=\n@prod (multiplicative _) _ x\n\nvariables {x y}\n\n@[simp] lemma sum_mk :\n  sum (mk L) = list.sum (L.map $ \u03bb x, cond x.2 x.1 (-x.1)) :=\nrfl\n\n@[simp] lemma sum.of {x : \u03b1} : sum (of x) = x :=\nprod.of\n\ninstance sum.is_group_hom : is_group_hom (@sum \u03b1 _) :=\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 \u03b1) = 0 :=\nprod.one\n\n@[simp] lemma sum.inv : sum x\u207b\u00b9 = -sum x :=\nprod.inv\n\nend sum\n\ndef free_group_empty_equiv_unit : free_group empty \u2243 unit :=\n{ to_fun    := \u03bb _, (),\n  inv_fun   := \u03bb _, 1,\n  left_inv  := by rintros \u27e8_ | \u27e8\u27e8\u27e8\u27e9, _\u27e9, _\u27e9\u27e9; refl,\n  right_inv := \u03bb \u27e8\u27e9, rfl }\n\ndef free_group_unit_equiv_int : free_group unit \u2243 int :=\n{ to_fun    := \u03bb x, sum $ map (\u03bb _, 1) x,\n  inv_fun   := \u03bb x, of () ^ x,\n  left_inv  := by rintros \u27e8L\u27e9; exact list.rec_on L rfl\n    (\u03bb \u27e8\u27e8\u27e9, b\u27e9 tl ih, by cases b; simp [gpow_add] at ih \u22a2; rw ih; refl),\n  right_inv := \u03bb x, int.induction_on x (by simp)\n    (\u03bb i ih, by simp at ih; simp [gpow_add, ih])\n    (\u03bb i ih, by simp at ih; simp [gpow_add, ih]) }\n\nsection category\n\nvariables {\u03b2 : Type u}\n\ninstance : monad free_group.{u} :=\n{ pure := \u03bb \u03b1, of,\n  map := \u03bb \u03b1 \u03b2, map,\n  bind := \u03bb \u03b1 \u03b2 x f, to_group f x }\n\n@[elab_as_eliminator]\nprotected theorem induction_on\n  {C : free_group \u03b1 \u2192 Prop}\n  (z : free_group \u03b1)\n  (C1 : C 1)\n  (Cp : \u2200 x, C $ pure x)\n  (Ci : \u2200 x, C (pure x) \u2192 C (pure x)\u207b\u00b9)\n  (Cm : \u2200 x y, C x \u2192 C y \u2192 C (x * y)) : C z :=\nquot.induction_on z $ \u03bb L, list.rec_on L C1 $ \u03bb \u27e8x, b\u27e9 tl ih,\nbool.rec_on b (Cm _ _ (Ci _ $ Cp x) ih) (Cm _ _ (Cp x) ih)\n\n@[simp] lemma map_pure (f : \u03b1 \u2192 \u03b2) (x : \u03b1) : f <$> (pure x : free_group \u03b1) = pure (f x) :=\nmap.of\n\n@[simp] lemma map_one (f : \u03b1 \u2192 \u03b2) : f <$> (1 : free_group \u03b1) = 1 :=\nmap.one\n\n@[simp] lemma map_mul (f : \u03b1 \u2192 \u03b2) (x y : free_group \u03b1) : f <$> (x * y) = f <$> x * f <$> y :=\nmap.mul\n\n@[simp] lemma map_inv (f : \u03b1 \u2192 \u03b2) (x : free_group \u03b1) : f <$> (x\u207b\u00b9) = (f <$> x)\u207b\u00b9 :=\nmap.inv\n\n@[simp] lemma pure_bind (f : \u03b1 \u2192 free_group \u03b2) (x) : pure x >>= f = f x :=\nto_group.of\n\n@[simp] lemma one_bind (f : \u03b1 \u2192 free_group \u03b2) : 1 >>= f = 1 :=\n@@to_group.one _ f\n\n@[simp] lemma mul_bind (f : \u03b1 \u2192 free_group \u03b2) (x y : free_group \u03b1) : x * y >>= f = (x >>= f) * (y >>= f) :=\nto_group.mul\n\n@[simp] lemma inv_bind (f : \u03b1 \u2192 free_group \u03b2) (x : free_group \u03b1) : x\u207b\u00b9 >>= f = (x >>= f)\u207b\u00b9 :=\nto_group.inv\n\ninstance : is_lawful_monad free_group.{u} :=\n{ id_map := \u03bb \u03b1 x, free_group.induction_on x (map_one id) (\u03bb x, map_pure id x)\n    (\u03bb x ih, by rw [map_inv, ih]) (\u03bb x y ihx ihy, by rw [map_mul, ihx, ihy]),\n  pure_bind := \u03bb \u03b1 \u03b2 x f, pure_bind f x,\n  bind_assoc := \u03bb \u03b1 \u03b2 \u03b3 x f g, free_group.induction_on x\n    (by iterate 3 { rw one_bind }) (\u03bb x, by iterate 2 { rw pure_bind })\n    (\u03bb x ih, by iterate 3 { rw inv_bind }; rw ih)\n    (\u03bb x y ihx ihy, by iterate 3 { rw mul_bind }; rw [ihx, ihy]),\n  bind_pure_comp_eq_map := \u03bb \u03b1 \u03b2 f x, free_group.induction_on x\n    (by rw [one_bind, map_one]) (\u03bb x, by rw [pure_bind, map_pure])\n    (\u03bb x ih, by rw [inv_bind, map_inv, ih]) (\u03bb x y ihx ihy, by rw [mul_bind, map_mul, ihx, ihy]) }\n\nend category\n\nsection reduce\n\nvariable [decidable_eq \u03b1]\n\n/-- The maximal reduction of a word. It is computable\niff `\u03b1` has decidable equality. -/\ndef reduce (L : list (\u03b1 \u00d7 bool)) : list (\u03b1 \u00d7 bool) :=\nlist.rec_on L [] $ \u03bb hd1 tl1 ih,\nlist.cases_on ih [hd1] $ \u03bb hd2 tl2,\nif hd1.1 = hd2.1 \u2227 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] (\u03bb hd tl,\n  if x.1 = hd.1 \u2227 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 \u2227 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} : \u2200 {L\u2081 L\u2082 L\u2083 : list (\u03b1 \u00d7 bool)} {x b}, reduce L\u2081 = L\u2082 ++ (x, b) :: (x, bnot b) :: L\u2083 \u2192 p\n| [] L2 L3 _ _ := \u03bb 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 \u2227 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 _|\u27e8a, L2\u27e9,\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\u2081) L\u2082) : reduce L\u2081 = L\u2082 :=\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\u2081 L\u2082) : reduce L\u2081 = reduce L\u2082 :=\nlet \u27e8L\u2083, HR13, HR23\u27e9 := 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\u2081 L\u2082) : reduce L\u2081 = reduce L\u2082 :=\nlet \u27e8L\u2083, HR13, HR23\u27e9 := 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\u2081 = mk L\u2082) : reduce L\u2081 = reduce L\u2082 :=\nlet \u27e8L\u2083, H13, H23\u27e9 := 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\u2081 = reduce L\u2082) : mk L\u2081 = mk L\u2082 :=\nred.exact.2 \u27e8reduce L\u2082, H \u25b8 reduce.red, reduce.red\u27e9\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\u2081 w\u2082` are such that `w\u2081` reduces to `w\u2082`,\nthen `w\u2082` reduces to the maximal reduction of `w\u2081`. -/\ntheorem reduce.rev (H : red L\u2081 L\u2082) : red L\u2082 (reduce L\u2081) :=\n(reduce.eq_of_red H).symm \u25b8 reduce.red\n\n/-- The function that sends an element of the free\ngroup to its maximal reduction. -/\ndef to_word : free_group \u03b1 \u2192 list (\u03b1 \u00d7 bool) :=\nquot.lift reduce $ \u03bb L\u2081 L\u2082 H, reduce.step.eq H\n\ndef to_word.mk : \u2200{x : free_group \u03b1}, mk (to_word x) = x :=\nby rintros \u27e8L\u27e9; exact reduce.self\n\ndef to_word.inj : \u2200(x y : free_group \u03b1), to_word x = to_word y \u2192 x = y :=\nby rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9; exact reduce.exact\n\n/-- Constructive Church-Rosser theorem (compare `church_rosser`). -/\ndef reduce.church_rosser (H12 : red L\u2081 L\u2082) (H13 : red L\u2081 L\u2083) :\n  { L\u2084 // red L\u2082 L\u2084 \u2227 red L\u2083 L\u2084 } :=\n\u27e8reduce L\u2081, reduce.rev H12, reduce.rev H13\u27e9\n\ninstance : decidable_eq (free_group \u03b1) :=\nfunction.injective.decidable_eq to_word.inj\n\ninstance red.decidable_rel : decidable_rel (@red \u03b1)\n| [] []          := is_true red.refl\n| [] (hd2::tl2)  := is_false $ \u03bb 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 $ \u03bb 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 \u25b8 red.cons_cons H\n    | is_false H := is_false $ \u03bb H2, H $ h \u25b8 (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 $ \u03bb H2, H $ red.inv_of_red_of_ne h H2\n    end\n\n/-- A list containing every word that `w\u2081` reduces to. -/\ndef red.enum (L\u2081 : list (\u03b1 \u00d7 bool)) : list (list (\u03b1 \u00d7 bool)) :=\nlist.filter (\u03bb L\u2082, red L\u2081 L\u2082) (list.sublists L\u2081)\n\ntheorem red.enum.sound (H : L\u2082 \u2208 red.enum L\u2081) : red L\u2081 L\u2082 :=\nlist.of_mem_filter H\n\ntheorem red.enum.complete (H : red L\u2081 L\u2082) : L\u2082 \u2208 red.enum L\u2081 :=\nlist.mem_filter_of_mem (list.mem_sublists.2 $ red.sublist H) H\n\ninstance : fintype { L\u2082 // red L\u2081 L\u2082 } :=\nfintype.subtype (list.to_finset $ red.enum L\u2081) $\n\u03bb L\u2082, \u27e8\u03bb H, red.enum.sound $ list.mem_to_finset.1 H,\n  \u03bb H, list.mem_to_finset.2 $ red.enum.complete H\u27e9\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 \u2192 Sort u} (zero : motive 0) (succ : (n : Nat) \u2192 motive n \u2192 motive (n+1)) : (t : Nat) \u2192 motive t\n| 0 => zero\n| n+1 => succ n (Nat.recAux zero succ n)\n\nprotected def recAuxOn.{u} {motive : Nat \u2192 Sort u} (t : Nat) (zero : motive 0) (succ : (n : Nat) \u2192 motive n \u2192 motive (n+1)) : motive t :=\n  Nat.recAux zero succ t\n\nprotected def casesAuxOn.{u} {motive : Nat \u2192 Sort u} (t : Nat) (zero : motive 0) (succ : (n : Nat) \u2192 motive (n+1)) : motive t :=\n  Nat.recAux zero (\u03bb n _ => succ n) t\n\nprotected def recDiagAux.{u} {motive : Nat \u2192 Nat \u2192 Sort u}\n  (left : (x : Nat) \u2192 motive x 0)\n  (right : (y : Nat) \u2192 motive 0 y)\n  (diag : (x y : Nat) \u2192 motive x y \u2192 motive (x + 1) (y + 1)) :\n  (x y : Nat) \u2192 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 \u2192 Nat \u2192 Sort u} (x y : Nat)\n  (left : (x : Nat) \u2192 motive x 0)\n  (right : (y : Nat) \u2192 motive 0 y)\n  (diag : (x y : Nat) \u2192 motive x y \u2192 motive (x + 1) (y + 1)) :\n  motive x y :=\n  Nat.recDiagAux left right diag x y\n\nprotected def casesDiagAuxOn.{u} {motive : Nat \u2192 Nat \u2192 Sort u} (x y : Nat)\n  (left : (x : Nat) \u2192 motive x 0)\n  (right : (y : Nat) \u2192 motive 0 y)\n  (diag : (x y : Nat) \u2192 motive (x + 1) (y + 1)) :\n  motive x y :=\n  Nat.recDiagAuxOn x y left right (\u03bb x y _ => diag x y)\n\nprotected def recDiag.{u} {motive : Nat \u2192 Nat \u2192 Sort u}\n  (zero_zero : motive 0 0)\n  (succ_zero : (x : Nat) \u2192 motive x 0 \u2192 motive (x + 1) 0)\n  (zero_succ : (y : Nat) \u2192 motive 0 y \u2192 motive 0 (y + 1))\n  (succ_succ : (x y : Nat) \u2192 motive x y \u2192 motive (x + 1) (y + 1)) :\n  (x y : Nat) \u2192 motive x y :=\n  Nat.recDiagAux left right succ_succ where\n  left : (x : Nat) \u2192 motive x 0\n  | 0 => zero_zero\n  | x+1 => succ_zero x (left x)\n  right : (y : Nat) \u2192 motive 0 y\n  | 0 => zero_zero\n  | y+1 => zero_succ y (right y)\n\nprotected def recDiagOn.{u} {motive : Nat \u2192 Nat \u2192 Sort u} (x y : Nat)\n  (zero_zero : motive 0 0)\n  (succ_zero : (x : Nat) \u2192 motive x 0 \u2192 motive (x + 1) 0)\n  (zero_succ : (y : Nat) \u2192 motive 0 y \u2192 motive 0 (y + 1))\n  (succ_succ : (x y : Nat) \u2192 motive x y \u2192 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 \u2192 Nat \u2192 Sort u} (x y : Nat)\n  (zero_zero : motive 0 0)\n  (succ_zero : (x : Nat) \u2192 motive (x + 1) 0)\n  (zero_succ : (y : Nat) \u2192 motive 0 (y + 1))\n  (succ_succ : (x y : Nat) \u2192 motive (x + 1) (y + 1)) :\n  motive x y :=\n  Nat.recDiagOn x y zero_zero (\u03bb x _ => succ_zero x) (\u03bb y _ => zero_succ y) (\u03bb 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 \u2190hx,\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) \u2192 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 (\u03bb z : (eta_equalizer Q), \u2191z) 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 \u2190hx1,\n        refl,\n      },\n    },\n    rw \u2190hxy_rw at hxy,\n    clear hxy_rw,\n    sorry,\n    /-\n    have hxy1 : (list.map (\u03bb z : (eta_equalizer Q), (of (\u2191z) : 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 \u2190hxy1 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 \u2208 \u2191(eta_equalizer Q)) : of (\u27e8x, hx\u27e9 : eta_equalizer Q) = (L_of_morph of of_is_pq_morphism) (\u27e8x, hx\u27e9 : 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 \u2190of_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 \u2190of_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) \u2243* 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} [\ud835\udcb1 : category.{v} V] [abelian.{v} V]\ninclude \ud835\udcb1\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 : \u2124) : cokernel (C.d i) \u27f6 image (C.d (i + 1)) :=\ncokernel.desc (C.d i) (cokernel.\u03c0 (kernel.\u03b9 (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 : \u2124} : epi (cokernel_to_image_map C i) :=\nepi_of_epi_fac $ show cokernel.\u03c0 (C.d i) \u226b cokernel_to_image_map C i = cokernel.\u03c0 (kernel.\u03b9 (C.d (i + 1))),\n  by erw colimit.\u03b9_desc; refl\n\ndef dd (i : \u2124) : cokernel (C.d i) \u27f6 kernel (C.d (i + 1 + 1)) :=\ncokernel_to_image_map C i \u226b image_to_kernel_map C (i + 1)\n\nlemma exact_right (i : \u2124) : exact (dd C i) (cokernel.\u03c0 (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 `\u2133 : \u03b9 \u2192 submodule R M` for a `module R M`, homogeneous submodules, and operations on them (sums, intersections, quotients\u2026)\n\nThe ring `R` is  not graded.\n\nAt the end, one adds an `graded_ring \ud835\udc9c` for `\ud835\udc9c : \u03b9 \u2192 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 \u201cwithout R\u201d ?\nMathematically, this is equivalent with having R = \u2115,\nbut it may be painful to have to use `to_nat_module`\u2026\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 : \u03b9 \u2192 \u03b8 \u2192 \u03b8`\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 {\u03b9 \u03c3 \u03c4 R A M : Type*}\n\n\nvariables [semiring R]\nvariables [decidable_eq \u03b9] [add_monoid \u03b9]\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 (\ud835\udc9c : \u03b9 \u2192 submodule R A) \n\nvariable (\u2133 : \u03b9 \u2192 submodule R M) \n\nsection graded_module\n\n-- variables [set_like.graded_monoid \ud835\udc9c] [graded_ring \ud835\udc9c] [set_like.has_graded_smul \ud835\udc9c \u2133]\n\n-- example : set_like.has_graded_smul \ud835\udc9c \ud835\udc9c := \n-- set_like.has_graded_mul.to_has_graded_smul \ud835\udc9c\n\n/-  Trop lourd\n class graded_module {\u03b9 : Type*}  [decidable_eq \u03b9] [add_monoid \u03b9]\n  {A R M : Type*} \n  [comm_semiring R] [comm_semiring A] [add_comm_monoid M] [algebra R A]\n  [graded_algebra \ud835\udc9c]\n  [module R M] [module A M] [is_scalar_tower R A M]\n  {\u03c3 : Type*} [set_like \u03c3 A] [add_submonoid_class \u03c3 A] [submodule_class \u03c3 R A] (\ud835\udc9c : \u03b9 \u2192 \u03c3) \n  {\u03c4 : Type*} [set_like \u03c4 M] [add_submonoid_class \u03c4 M] [submodule_class \u03c4 R M] (\u2133 : \u03b9 \u2192 \u03c4) :=\n(to_decomposition : direct_sum.decomposition \u2133)\n(to_graded_smul : set_like.has_graded_smul \ud835\udc9c \u2133)\n -/\n\nclass graded_module {\u03b9 : Type*}  [decidable_eq \u03b9] [add_monoid \u03b9]\n  {R M : Type*} \n  [semiring R] [add_comm_monoid M] \n  [module R M] \n  {\u03c4 : Type*} [set_like \u03c4 M] [add_submonoid_class \u03c4 M] [submodule_class \u03c4 R M] (\u2133 : \u03b9 \u2192 \u03c4) \n  extends direct_sum.decomposition \u2133\n\n\nvariable [graded_module \u2133]\n\n/-- The projection maps of a graded module -/\ndef graded_module.proj (i : \u03b9) : M \u2192+ M :=\n(add_submonoid_class.subtype (\u2133 i)).comp ((dfinsupp.eval_add_monoid_hom i).comp $\n  add_equiv.to_add_monoid_hom $ direct_sum.decompose_add_equiv \u2133)\n\n@[simp] lemma graded_module.proj_apply (i : \u03b9) (r : M) :\n  graded_module.proj \u2133 i r = (decompose \u2133 r : \u2a01 i, \u2133 i) i := rfl\n\nlemma graded_module.proj_recompose (r : \u2a01 i, \u2133 i) (i : \u03b9) :\n  graded_module.proj \u2133 i ((decompose \u2133).symm r) =\n  (decompose \u2133).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 [\u03a0 i (x : \u2133 i), decidable (x \u2260 0)] (r : M) (i : \u03b9) :\n  i \u2208 (decompose \u2133 r).support \u2194 graded_module.proj \u2133 i r \u2260 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 \u2133]\n\nvariable {R}\n/- An `N : submodule R M` is homogeneous if for every `r \u2208 N`, all homogeneous components\n  of `r` are in `N`. -/\ndef submodule.is_homogeneous [graded_module \u2133] (N : submodule R M): Prop :=\n\u2200 (i : \u03b9) \u2983r : M\u2984, r \u2208 N \u2192 (direct_sum.decompose \u2133 r i : M) \u2208 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 \u2133 to_submodule)\n\nvariable {\u2133}\n\nlemma homogeneous_submodule.is_homogeneous (N : homogeneous_submodule \u2133) :\n  N.to_submodule.is_homogeneous \u2133 := N.is_homogeneous'\n\nlemma homogeneous_submodule.to_submodule_injective :\n  function.injective (homogeneous_submodule.to_submodule : homogeneous_submodule \u2133 \u2192 submodule R M) :=\n\u03bb \u27e8x, hx\u27e9 \u27e8y, hy\u27e9 (h : x = y), by simp [h]\n\ninstance homogeneous_submodule.set_like : set_like (homogeneous_submodule \u2133) M :=\n{ coe := \u03bb N, N.to_submodule,\n  coe_injective' := \u03bb N P h, homogeneous_submodule.to_submodule_injective $ set_like.coe_injective h }\n\n@[ext] lemma homogeneous_submodule.ext {N P : homogeneous_submodule \u2133}\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 \u2133} {x : M} :\n  x \u2208 N.to_submodule \u2194 x \u2208 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 \u03c4 M]  (\u2133 : \u03b9 \u2192 \u03c4)\n\nvariable (N : submodule R M)\nvariable {R}\ninclude M\n\n/-- For any `N : submodule R M`, not necessarily homogeneous, `N.homogeneous_core' \u2133`\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 \u2133) \u2192 M) \u207b\u00b9' N))\n\n\nlemma submodule.homogeneous_core'_mono : monotone (submodule.homogeneous_core' \u2133) :=\n\u03bb N P N_le_P, submodule.span_mono $ set.image_subset _ $ \u03bb x, @N_le_P _\n\nlemma submodule.homogeneous_core'_le : N.homogeneous_core' \u2133 \u2264 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 \u03c4 M] [add_submonoid_class \u03c4 M] [submodule_class \u03c4 R M] (\u2133 : \u03b9 \u2192 \u03c4)\n-- variables [decidable_eq \u03b9] [add_monoid \u03b9] [graded_module \u2133]\n\nvariable [graded_module \u2133]\n\nvariable (N : submodule R M)\nvariable {R}\ninclude M\n\nlemma submodule.is_homogeneous_iff_forall_subset :\n  N.is_homogeneous \u2133 \u2194 \u2200 i, (N : set M) \u2286 graded_module.proj \u2133 i \u207b\u00b9' N :=\niff.rfl\n\nlemma submodule.is_homogeneous_iff_subset_Inter :\n  N.is_homogeneous \u2133 \u2194 (N : set M) \u2286 \u22c2 i, graded_module.proj \u2133 i \u207b\u00b9' \u2191N :=\nsubset_Inter_iff.symm\n\n/- --  Plus tard, lorsqu'il y aura un anneau gradu\u00e9 \nlemma submodule.mul_homogeneous_element_mem_of_mem\n  {I : ideal A} (r x : A) (hx\u2081 : is_homogeneous \ud835\udc9c x) (hx\u2082 : x \u2208 I) (j : \u03b9) :\n  graded_ring.proj \ud835\udc9c j (r * x) \u2208 I :=\nbegin\n  classical,\n  rw [\u2190direct_sum.sum_support_decompose \ud835\udc9c r, finset.sum_mul, map_sum],\n  apply ideal.sum_mem,\n  intros k hk,\n  obtain \u27e8i, hi\u27e9 := hx\u2081,\n  have mem\u2081 : (direct_sum.decompose \ud835\udc9c r k : A) * x \u2208 \ud835\udc9c (k + i) := graded_monoid.mul_mem\n    (set_like.coe_mem _) hi,\n  erw [graded_ring.proj_apply, direct_sum.decompose_of_mem \ud835\udc9c mem\u2081,\n    coe_of_apply, set_like.coe_mk],\n  split_ifs,\n  { exact I.mul_mem_left _ hx\u2082 },\n  { exact I.zero_mem },\nend -/\n\nlemma submodule.is_homogeneous_span (s : set M) (h : \u2200 x \u2208 s, is_homogeneous \u2133 x) :\n  (submodule.span R s).is_homogeneous \u2133 :=\nbegin\n  rintros i r hr,\n  rw [finsupp.span_eq_range_total, linear_map.mem_range] at hr,\n  obtain \u27e8f, rfl\u27e9 := 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 \u27e8z, hz\u27e9 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 \u27e8j, hzj\u27e9 := 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 \u2133 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 \u2133`\nis the largest homogeneous submodule of `M` contained in `N`.-/\ndef submodule.homogeneous_core : homogeneous_submodule \u2133 :=\n\u27e8submodule.homogeneous_core' \u2133 N,\n  submodule.is_homogeneous_span \u2133 _ (\u03bb x h,\n  by { rw [subtype.image_preimage_coe, mem_inter_iff, mem_coe] at h,exact h.2, })\u27e9\n\nlemma submodule.homogeneous_core_mono : monotone (submodule.homogeneous_core \u2133) :=\nsubmodule.homogeneous_core'_mono \u2133\n\nlemma submodule.to_submodule_homogeneous_core_le : (N.homogeneous_core \u2133).to_submodule \u2264 N :=\nsubmodule.homogeneous_core'_le \u2133 N\n\nvariables {\u2133 N}\n\nlemma submodule.mem_homogeneous_core_of_is_homogeneous_of_mem {x : M}\n  (h : set_like.is_homogeneous \u2133 x) (hmem : x \u2208 N) : x \u2208 N.homogeneous_core \u2133 :=\nsubmodule.subset_span \u27e8\u27e8x, h\u27e9, hmem, rfl\u27e9\n\nlemma submodule.is_homogeneous.to_submodule_homogeneous_core_eq_self (h : N.is_homogeneous \u2133) :\n  (N.homogeneous_core \u2133).to_submodule = N :=\nbegin\n  apply le_antisymm (N.homogeneous_core'_le \u2133) _,\n  intros x hx,\n  classical,\n  rw \u2190direct_sum.sum_support_decompose \u2133 x,\n  exact submodule.sum_mem _ (\u03bb j hj, submodule.subset_span \u27e8\u27e8_, is_homogeneous_coe _\u27e9, h _ hx, rfl\u27e9)\nend\n\n@[simp] lemma homogeneous_submodule.to_ideal_homogeneous_core_eq_self (N : homogeneous_submodule \u2133) :\n  N.to_submodule.homogeneous_core \u2133 = N :=\nby ext1; convert submodule.is_homogeneous.to_submodule_homogeneous_core_eq_self R N.is_homogeneous\n\nvariables (\u2133 N)\n\nlemma submodule.is_homogeneous.iff_eq : N.is_homogeneous \u2133 \u2194 (N.homogeneous_core \u2133).to_submodule = N :=\n\u27e8 \u03bb hI, hI.to_submodule_homogeneous_core_eq_self,\n  \u03bb hI, hI \u25b8 (submodule.homogeneous_core \u2133 N).2 \u27e9\n\ndef homogeneous_set : set M := {m : M | is_homogeneous \u2133 m}\n\nlemma submodule.is_homogeneous.iff_exists :\n  N.is_homogeneous \u2133 \u2194 \u2203 (S : set (homogeneous_set \u2133)), 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 \u03b9] [add_monoid \u03b9]\nvariables [set_like \u03c3 A] [add_submonoid_class \u03c3 A] (\ud835\udc9c : \u03b9 \u2192 \u03c3) [graded_ring \ud835\udc9c]\ninclude A\n\nnamespace ideal.is_homogeneous\n\nlemma bot : ideal.is_homogeneous \ud835\udc9c \u22a5 := \u03bb 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 \ud835\udc9c \u22a4 :=\n\u03bb i r hr, by simp only [submodule.mem_top]\n\nvariables {\ud835\udc9c}\n\nlemma inf {I J : ideal A} (HI : I.is_homogeneous \ud835\udc9c) (HJ : J.is_homogeneous \ud835\udc9c) :\n  (I \u2293 J).is_homogeneous \ud835\udc9c :=\n\u03bb i r hr, \u27e8HI _ hr.1, HJ _ hr.2\u27e9\n\nlemma sup {I J : ideal A} (HI : I.is_homogeneous \ud835\udc9c) (HJ : J.is_homogeneous \ud835\udc9c) :\n  (I \u2294 J).is_homogeneous \ud835\udc9c :=\nbegin\n  rw iff_exists at HI HJ \u22a2,\n  obtain \u27e8\u27e8s\u2081, rfl\u27e9, \u27e8s\u2082, rfl\u27e9\u27e9 := \u27e8HI, HJ\u27e9,\n  refine \u27e8s\u2081 \u222a s\u2082, _\u27e9,\n  rw [set.image_union],\n  exact (submodule.span_union _ _).symm,\nend\n\nprotected lemma supr {\u03ba : Sort*} {f : \u03ba \u2192 ideal A} (h : \u2200 i, (f i).is_homogeneous \ud835\udc9c) :\n  (\u2a06 i, f i).is_homogeneous \ud835\udc9c :=\nbegin\n  simp_rw iff_exists at h \u22a2,\n  choose s hs using h,\n  refine \u27e8\u22c3 i, s i, _\u27e9,\n  simp_rw [set.image_Union, ideal.span_Union],\n  congr',\n  exact funext hs,\nend\n\nprotected lemma infi {\u03ba : Sort*} {f : \u03ba \u2192 ideal A} (h : \u2200 i, (f i).is_homogeneous \ud835\udc9c) :\n  (\u2a05 i, f i).is_homogeneous \ud835\udc9c :=\nbegin\n  intros i x hx,\n  simp only [ideal.mem_infi] at \u22a2 hx,\n  exact \u03bb j, h _ _ (hx j),\nend\n\nlemma supr\u2082 {\u03ba : Sort*} {\u03ba' : \u03ba \u2192 Sort*} {f : \u03a0 i, \u03ba' i \u2192 ideal A}\n  (h : \u2200 i j, (f i j).is_homogeneous \ud835\udc9c) :\n  (\u2a06 i j, f i j).is_homogeneous \ud835\udc9c :=\nis_homogeneous.supr $ \u03bb i, is_homogeneous.supr $ h i\n\nlemma infi\u2082 {\u03ba : Sort*} {\u03ba' : \u03ba \u2192 Sort*} {f : \u03a0 i, \u03ba' i \u2192 ideal A}\n  (h : \u2200 i j, (f i j).is_homogeneous \ud835\udc9c) :\n  (\u2a05 i j, f i j).is_homogeneous \ud835\udc9c :=\nis_homogeneous.infi $ \u03bb i, is_homogeneous.infi $ h i\n\nlemma Sup {\u2110 : set (ideal A)} (h : \u2200 I \u2208 \u2110, ideal.is_homogeneous \ud835\udc9c I) :\n  (Sup \u2110).is_homogeneous \ud835\udc9c :=\nby { rw Sup_eq_supr, exact supr\u2082 h }\n\nlemma Inf {\u2110 : set (ideal A)} (h : \u2200 I \u2208 \u2110, ideal.is_homogeneous \ud835\udc9c I) :\n  (Inf \u2110).is_homogeneous \ud835\udc9c :=\nby { rw Inf_eq_infi, exact infi\u2082 h }\n\nend ideal.is_homogeneous\n\nvariables {\ud835\udc9c}\n\nnamespace homogeneous_ideal\n\ninstance : partial_order (homogeneous_ideal \ud835\udc9c) := set_like.partial_order\n\ninstance : has_top (homogeneous_ideal \ud835\udc9c) := \u27e8\u27e8\u22a4, ideal.is_homogeneous.top \ud835\udc9c\u27e9\u27e9\ninstance : has_bot (homogeneous_ideal \ud835\udc9c) := \u27e8\u27e8\u22a5, ideal.is_homogeneous.bot \ud835\udc9c\u27e9\u27e9\ninstance : has_sup (homogeneous_ideal \ud835\udc9c) := \u27e8\u03bb I J, \u27e8_, I.is_homogeneous.sup J.is_homogeneous\u27e9\u27e9\ninstance : has_inf (homogeneous_ideal \ud835\udc9c) := \u27e8\u03bb I J, \u27e8_, I.is_homogeneous.inf J.is_homogeneous\u27e9\u27e9\ninstance : has_Sup (homogeneous_ideal \ud835\udc9c) :=\n\u27e8\u03bb S, \u27e8\u2a06 s \u2208 S, to_ideal s, ideal.is_homogeneous.supr\u2082 $ \u03bb s _, s.is_homogeneous\u27e9\u27e9\ninstance : has_Inf (homogeneous_ideal \ud835\udc9c) :=\n\u27e8\u03bb S, \u27e8\u2a05 s \u2208 S, to_ideal s, ideal.is_homogeneous.infi\u2082 $ \u03bb s _, s.is_homogeneous\u27e9\u27e9\n\n@[simp] lemma coe_top : ((\u22a4 : homogeneous_ideal \ud835\udc9c) : set A) = univ := rfl\n@[simp] lemma coe_bot : ((\u22a5 : homogeneous_ideal \ud835\udc9c) : set A) = 0 := rfl\n@[simp] lemma coe_sup (I J : homogeneous_ideal \ud835\udc9c) : \u2191(I \u2294 J) = (I + J : set A) :=\nsubmodule.coe_sup _ _\n@[simp] lemma coe_inf (I J : homogeneous_ideal \ud835\udc9c) : (\u2191(I \u2293 J) : set A) = I \u2229 J := rfl\n\n@[simp] lemma to_ideal_top : (\u22a4 : homogeneous_ideal \ud835\udc9c).to_ideal = (\u22a4 : ideal A) := rfl\n@[simp] lemma to_ideal_bot : (\u22a5 : homogeneous_ideal \ud835\udc9c).to_ideal = (\u22a5 : ideal A) := rfl\n\n@[simp] lemma to_ideal_sup (I J : homogeneous_ideal \ud835\udc9c) :\n  (I \u2294 J).to_ideal = I.to_ideal \u2294 J.to_ideal := rfl\n\n@[simp] lemma to_ideal_inf (I J : homogeneous_ideal \ud835\udc9c) :\n  (I \u2293 J).to_ideal = I.to_ideal \u2293 J.to_ideal := rfl\n\n@[simp] lemma to_ideal_Sup (\u2110 : set (homogeneous_ideal \ud835\udc9c)) :\n  (Sup \u2110).to_ideal = \u2a06 s \u2208 \u2110, to_ideal s := rfl\n\n@[simp] lemma to_ideal_Inf (\u2110 : set (homogeneous_ideal \ud835\udc9c)) :\n  (Inf \u2110).to_ideal = \u2a05 s \u2208 \u2110, to_ideal s := rfl\n\n@[simp] lemma to_ideal_supr {\u03ba : Sort*} (s : \u03ba \u2192 homogeneous_ideal \ud835\udc9c) :\n  (\u2a06 i, s i).to_ideal = \u2a06 i, (s i).to_ideal :=\nby rw [supr, to_ideal_Sup, supr_range]\n\n@[simp] lemma to_ideal_infi {\u03ba : Sort*} (s : \u03ba \u2192 homogeneous_ideal \ud835\udc9c) :\n  (\u2a05 i, s i).to_ideal = \u2a05 i, (s i).to_ideal :=\nby rw [infi, to_ideal_Inf, infi_range]\n\n@[simp] lemma to_ideal_supr\u2082 {\u03ba : Sort*} {\u03ba' : \u03ba \u2192 Sort*} (s : \u03a0 i, \u03ba' i \u2192 homogeneous_ideal \ud835\udc9c) :\n  (\u2a06 i j, s i j).to_ideal = \u2a06 i j, (s i j).to_ideal :=\nby simp_rw to_ideal_supr\n\n@[simp] lemma to_ideal_infi\u2082 {\u03ba : Sort*} {\u03ba' : \u03ba \u2192 Sort*} (s : \u03a0 i, \u03ba' i \u2192 homogeneous_ideal \ud835\udc9c) :\n  (\u2a05 i j, s i j).to_ideal = \u2a05 i j, (s i j).to_ideal :=\nby simp_rw to_ideal_infi\n\n@[simp] lemma eq_top_iff (I : homogeneous_ideal \ud835\udc9c) : I = \u22a4 \u2194 I.to_ideal = \u22a4 :=\nto_ideal_injective.eq_iff.symm\n\n@[simp] lemma eq_bot_iff (I : homogeneous_ideal \ud835\udc9c) : I = \u22a5 \u2194 I.to_ideal = \u22a5 :=\nto_ideal_injective.eq_iff.symm\n\ninstance : complete_lattice (homogeneous_ideal \ud835\udc9c) :=\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 \ud835\udc9c) := \u27e8(\u2294)\u27e9\n\n@[simp] lemma to_ideal_add (I J : homogeneous_ideal \ud835\udc9c) :\n  (I + J).to_ideal = I.to_ideal + J.to_ideal := rfl\n\ninstance : inhabited (homogeneous_ideal \ud835\udc9c) := { default := \u22a5 }\n\nend homogeneous_ideal\n\nend semiring\n\nsection comm_semiring\nvariables [comm_semiring A]\nvariables [decidable_eq \u03b9] [add_monoid \u03b9]\nvariables [set_like \u03c3 A] [add_submonoid_class \u03c3 A] {\ud835\udc9c : \u03b9 \u2192 \u03c3} [graded_ring \ud835\udc9c]\nvariable (I : ideal A)\ninclude A\n\nlemma ideal.is_homogeneous.mul {I J : ideal A}\n  (HI : I.is_homogeneous \ud835\udc9c) (HJ : J.is_homogeneous \ud835\udc9c) : (I * J).is_homogeneous \ud835\udc9c :=\nbegin\n  rw ideal.is_homogeneous.iff_exists at HI HJ \u22a2,\n  obtain \u27e8\u27e8s\u2081, rfl\u27e9, \u27e8s\u2082, rfl\u27e9\u27e9 := \u27e8HI, HJ\u27e9,\n  rw ideal.span_mul_span',\n  exact \u27e8s\u2081 * s\u2082, congr_arg _ $ (set.image_mul (homogeneous_submonoid \ud835\udc9c).subtype).symm\u27e9,\nend\n\nvariables {\ud835\udc9c}\n\ninstance : has_mul (homogeneous_ideal \ud835\udc9c) :=\n{ mul := \u03bb I J, \u27e8I.to_ideal * J.to_ideal, I.is_homogeneous.mul J.is_homogeneous\u27e9 }\n\n@[simp] lemma homogeneous_ideal.to_ideal_mul (I J : homogeneous_ideal \ud835\udc9c) :\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 \u03b9] [add_monoid \u03b9]\nvariables [set_like \u03c3 A] [add_submonoid_class \u03c3 A] (\ud835\udc9c : \u03b9 \u2192 \u03c3) [graded_ring \ud835\udc9c]\nvariable (I : ideal A)\ninclude A\n\nlemma ideal.homogeneous_core.gc : galois_connection to_ideal (ideal.homogeneous_core \ud835\udc9c) :=\n\u03bb I J, \u27e8\n  \u03bb H, I.to_ideal_homogeneous_core_eq_self \u25b8 ideal.homogeneous_core_mono \ud835\udc9c H,\n  \u03bb H, le_trans H (ideal.homogeneous_core'_le _ _)\u27e9\n\n/--`to_ideal : homogeneous_ideal \ud835\udc9c \u2192 ideal A` and `ideal.homogeneous_core \ud835\udc9c` forms a galois\ncoinsertion-/\ndef ideal.homogeneous_core.gi : galois_coinsertion to_ideal (ideal.homogeneous_core \ud835\udc9c) :=\n{ choice := \u03bb I HI,\n    \u27e8I, le_antisymm (I.to_ideal_homogeneous_core_le \ud835\udc9c) HI \u25b8 homogeneous_ideal.is_homogeneous _\u27e9,\n  gc := ideal.homogeneous_core.gc \ud835\udc9c,\n  u_l_le := \u03bb I, ideal.homogeneous_core'_le _ _,\n  choice_eq := \u03bb I H, le_antisymm H (I.to_ideal_homogeneous_core_le _) }\n\nlemma ideal.homogeneous_core_eq_Sup :\n  I.homogeneous_core \ud835\udc9c = Sup {J : homogeneous_ideal \ud835\udc9c | J.to_ideal \u2264 I} :=\neq.symm $ is_lub.Sup_eq $ (ideal.homogeneous_core.gc \ud835\udc9c).is_greatest_u.is_lub\n\nlemma ideal.homogeneous_core'_eq_Sup :\n  I.homogeneous_core' \ud835\udc9c = Sup {J : ideal A | J.is_homogeneous \ud835\udc9c \u2227 J \u2264 I} :=\nbegin\n  refine (is_lub.Sup_eq _).symm,\n  apply is_greatest.is_lub,\n  have coe_mono : monotone (to_ideal : homogeneous_ideal \ud835\udc9c \u2192 ideal A) := \u03bb x y, id,\n  convert coe_mono.map_is_greatest (ideal.homogeneous_core.gc \ud835\udc9c).is_greatest_u using 1,\n  ext,\n  rw [mem_image, mem_set_of_eq],\n  refine \u27e8\u03bb hI, \u27e8\u27e8x, hI.1\u27e9, \u27e8hI.2, rfl\u27e9\u27e9, by rintro \u27e8x, \u27e8hx, rfl\u27e9\u27e9; exact \u27e8x.is_homogeneous, hx\u27e9\u27e9,\nend\n\nend homogeneous_core\n\n/-! ### Homogeneous hulls -/\n\nsection homogeneous_hull\n\nopen homogeneous_ideal\n\nvariables [semiring A] [decidable_eq \u03b9] [add_monoid \u03b9]\nvariables [set_like \u03c3 A] [add_submonoid_class \u03c3 A] (\ud835\udc9c : \u03b9 \u2192 \u03c3) [graded_ring \ud835\udc9c]\nvariable (I : ideal A)\ninclude A\n\n/--For any `I : ideal A`, not necessarily homogeneous, `I.homogeneous_hull \ud835\udc9c` is\nthe smallest homogeneous ideal containing `I`. -/\ndef ideal.homogeneous_hull : homogeneous_ideal \ud835\udc9c :=\n\u27e8ideal.span {r : A | \u2203 (i : \u03b9) (x : I), (direct_sum.decompose \ud835\udc9c (x : A) i : A) = r}, begin\n  refine ideal.is_homogeneous_span _ _ (\u03bb x hx, _),\n  obtain \u27e8i, x, rfl\u27e9 := hx,\n  apply set_like.is_homogeneous_coe\nend\u27e9\n\nlemma ideal.le_to_ideal_homogeneous_hull :\n  I \u2264 (ideal.homogeneous_hull \ud835\udc9c I).to_ideal :=\nbegin\n  intros r hr,\n  classical,\n  rw [\u2190direct_sum.sum_support_decompose \ud835\udc9c r],\n  refine ideal.sum_mem _ _, intros j hj,\n  apply ideal.subset_span, use j, use \u27e8r, hr\u27e9, refl,\nend\n\nlemma ideal.homogeneous_hull_mono : monotone (ideal.homogeneous_hull \ud835\udc9c) := \u03bb I J I_le_J,\nbegin\n  apply ideal.span_mono,\n  rintros r \u27e8hr1, \u27e8x, hx\u27e9, rfl\u27e9,\n  refine \u27e8hr1, \u27e8\u27e8x, I_le_J hx\u27e9, rfl\u27e9\u27e9,\nend\n\nvariables {I \ud835\udc9c}\n\nlemma ideal.is_homogeneous.to_ideal_homogeneous_hull_eq_self (h : I.is_homogeneous \ud835\udc9c) :\n  (ideal.homogeneous_hull \ud835\udc9c I).to_ideal = I :=\nbegin\n  apply le_antisymm _ (ideal.le_to_ideal_homogeneous_hull _ _),\n  apply (ideal.span_le).2,\n  rintros _ \u27e8i, x, rfl\u27e9,\n  exact h _ x.prop,\nend\n\n@[simp] lemma homogeneous_ideal.homogeneous_hull_to_ideal_eq_self (I : homogeneous_ideal \ud835\udc9c) :\n  I.to_ideal.homogeneous_hull \ud835\udc9c = I :=\nhomogeneous_ideal.to_ideal_injective $ I.is_homogeneous.to_ideal_homogeneous_hull_eq_self\n\nvariables (I \ud835\udc9c)\n\nlemma ideal.to_ideal_homogeneous_hull_eq_supr :\n  (I.homogeneous_hull \ud835\udc9c).to_ideal = \u2a06 i, ideal.span (graded_ring.proj \ud835\udc9c i '' I) :=\nbegin\n  rw \u2190ideal.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 \ud835\udc9c) =\n  \u2a06 i, \u27e8ideal.span (graded_ring.proj \ud835\udc9c i '' I), ideal.is_homogeneous_span \ud835\udc9c _\n    (by {rintros _ \u27e8x, -, rfl\u27e9, apply set_like.is_homogeneous_coe})\u27e9 :=\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 \u03b9] [add_monoid \u03b9]\nvariables [set_like \u03c3 A] [add_submonoid_class \u03c3 A] (\ud835\udc9c : \u03b9 \u2192 \u03c3) [graded_ring \ud835\udc9c]\ninclude A\n\nlemma ideal.homogeneous_hull.gc : galois_connection (ideal.homogeneous_hull \ud835\udc9c) to_ideal :=\n\u03bb I J, \u27e8\n  le_trans (ideal.le_to_ideal_homogeneous_hull _ _),\n  \u03bb H, J.homogeneous_hull_to_ideal_eq_self \u25b8 ideal.homogeneous_hull_mono \ud835\udc9c H\u27e9\n\n/-- `ideal.homogeneous_hull \ud835\udc9c` and `to_ideal : homogeneous_ideal \ud835\udc9c \u2192 ideal A` form a galois\ninsertion-/\ndef ideal.homogeneous_hull.gi : galois_insertion (ideal.homogeneous_hull \ud835\udc9c) to_ideal :=\n{ choice := \u03bb I H, \u27e8I, le_antisymm H (I.le_to_ideal_homogeneous_hull \ud835\udc9c) \u25b8 is_homogeneous _\u27e9,\n  gc := ideal.homogeneous_hull.gc \ud835\udc9c,\n  le_l_u := \u03bb I, ideal.le_to_ideal_homogeneous_hull _ _,\n  choice_eq := \u03bb I H, le_antisymm (I.le_to_ideal_homogeneous_hull \ud835\udc9c) H}\n\nlemma ideal.homogeneous_hull_eq_Inf (I : ideal A) :\n  ideal.homogeneous_hull \ud835\udc9c I = Inf { J : homogeneous_ideal \ud835\udc9c | I \u2264 J.to_ideal } :=\neq.symm $ is_glb.Inf_eq $ (ideal.homogeneous_hull.gc \ud835\udc9c).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  \u2203 (p : polynomial R), p \u2260 0 \u2227 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  \u2200 (x : A), x \u2208 S \u2192 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  \u2200 (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 \u2194 algebra.is_algebraic R \u21a5S := 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 \u2194 subalgebra.is_algebraic \u22a4 := 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 \u2194 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 \u2194 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 \u22a4 (is_noetherian_of_submodule_of_noetherian K L (\u2191\u22a4) 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 : \u2200 (x : R), coe_fn (algebra_map R S) x = 0 \u2192 x = 0) : \u2203 (x : \u21a5(integral_closure R S)), \u2203 (y : \u21a5(integral_closure R S)), \u2203 (H : y \u2260 0), z * \u2191y = \u2191x := 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) \u2260 0) : x\u207b\u00b9 =\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 \u2260 0) : x\u207b\u00b9 = -(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 : \u21a5A} {p : polynomial K} (aeval_eq : coe_fn (polynomial.aeval x) p = 0) (coeff_zero_ne : polynomial.coeff p 0 \u2260 0) : \u2191x\u207b\u00b9 \u2208 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 : \u21a5A} (hx : is_algebraic K \u2191x) : \u2191x\u207b\u00b9 \u2208 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 \u21a5A := 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 (\u2260) = [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 {\u03b1 : Type _} (l : List \u03b1) (R : \u03b1 \u2192 \u03b1 \u2192 Prop) [DecidableRel R] {a b : \u03b1}\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 : \u00acR 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  \u00b7 simp\n  rw [destutter']\n  split_ifs\n  \u00b7 exact sublist.cons2 _ _ _ (hl b)\n  \u00b7 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 \u2208 l.destutter' R a :=\n  by\n  induction' l with b l hl\n  \u00b7 simp\n  rw [destutter']\n  split_ifs\n  \u00b7 simp\n  \u00b7 assumption\n#align list.mem_destutter' List.mem_destutter'\n-/\n\n#print List.destutter'_is_chain /-\ntheorem destutter'_is_chain : \u2200 l : List \u03b1, \u2200 {a b}, R a b \u2192 (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    \u00b7 rw [chain_cons]\n      exact \u27e8h, destutter'_is_chain l hbc\u27e9\n    \u00b7 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  \u00b7 simp\n  rw [destutter']\n  split_ifs\n  \u00b7 exact destutter'_is_chain R l h\n  \u00b7 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  \u00b7 simp\n  obtain \u27e8h, hc\u27e9 := 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 \u2194 l.Chain R a :=\n  \u27e8fun h => by\n    rw [\u2190 chain', \u2190 h]\n    exact l.destutter'_is_chain' R a, destutter'_of_chain _ _\u27e9\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 \u2260 [] :=\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 \u03b1).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 : \u2200 l : List \u03b1, 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' : \u2200 l : List \u03b1, (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' : \u2200 l : List \u03b1, l.Chain' R \u2192 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 : \u2200 l : List \u03b1, l.destutter R = l \u2194 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 : \u2200 {l : List \u03b1}, destutter R l = [] \u2194 l = []\n  | [] => Iff.rfl\n  | a :: l => \u27e8fun h => absurd h <| l.destutter'_ne_nil R, fun h => nomatch h\u27e9\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 {\u03b9 : Type u'} {c : complex_shape \u03b9}\n\n-- move this\nsection\nvariables {C : Type u} [category.{v} C] {Z : C \u2192 Prop}\n@[simps]\ndef lift_iso {X Y : full_subcategory Z} (h : X.obj \u2245 Y.obj) : X \u2245 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 \u03b9) := \u03b9\n\ninductive walking_complex_hom : walking_complex c \u2192 walking_complex c \u2192 Type u'\n| id : \u03a0 i, walking_complex_hom i i\n| d : \u03a0 {i j}, c.rel i j \u2192 walking_complex_hom i j\n| zero : \u03a0 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 \u2192 walking_complex_hom j k \u2192 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 \u27f6 j) :=\n\u27e8walking_complex_hom.zero i j\u27e9\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 = \ud835\udfd9 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 \u27f6 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 \u226b 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 \u27f6 j) : h.X i \u27f6 h.X j :=\nbegin\n  cases f, exacts [\ud835\udfd9 _, 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 (\ud835\udfd9 i) = \ud835\udfd9 _ :=\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 \u27f6 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 \u2964 V :=\n{ obj := h.X, map := \u03bb 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 \u2964 V)\n  (hF : \u2200 i j, F.map (0 : i \u27f6 j) = 0) :\n  homological_complex V c :=\n{ X := F.obj,\n  d := \u03bb 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', \u2190 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 \u2964 full_subcategory (\u03bb F : walking_complex c \u2964 V, \u2200 i j, F.map (0 : i \u27f6 j) = 0) :=\n{ obj := \u03bb X, \u27e8complex_to_functor X, \u03bb _ _, rfl\u27e9, map := \u03bb X Y f, { app := f.f } }\n\n@[simps]\ndef functor_to_complex_functor :\n  full_subcategory (\u03bb F : walking_complex c \u2964 V, \u2200 i j, F.map (0 : i \u27f6 j) = 0) \u2964 homological_complex V c :=\n{ obj := \u03bb F, functor_to_complex F.1 F.2,\n  map := \u03bb 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  \ud835\udfed _ \u2245 complex_to_functor_functor V c \u22d9 functor_to_complex_functor V c :=\nnat_iso.of_components\n  (\u03bb X, hom.iso_of_components (\u03bb 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 \u22d9 complex_to_functor_functor V c \u2245 \ud835\udfed _ :=\nnat_iso.of_components\n  (\u03bb F, lift_iso $ nat_iso.of_components (\u03bb 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 \u224c full_subcategory (\u03bb F : walking_complex c \u2964 V, \u2200 i j, F.map (0 : i \u27f6 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 \u2964 walking_complex c \u2964 V :=\ncomplex_to_functor_functor V c \u22d9 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, \u201cLarge Theory\nReasoning with SUMO at CASC,\u201d pp. 1\u20138, Jul. 2009.\nHere we present the natural deduction proof in Lean.\n-/\n\nimport bs_test\n\n-- some initial tests\n\nlemma VertebrateAnimal : \u2200 (x : U), ins x Vertebrate \u2192 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 \u27e8 a72180, a71844 \u27e9, \n exact \u27e8 a67818, a13 \u27e9, \nend\n\nlemma VertebrateOrganism : \u2200 (x : U), ins x Vertebrate \u2192 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 : \u2200 x, ins x Vertebrate \u2192 ins x Animal, apply VertebrateAnimal; assumption,\n have h2, from h0 a h,\n exact and.intro a71369 h2,\nend\n\nlemma VertebrateOrganism' : \u2200 (x : U), ins x Vertebrate \u2192 ins x Organism := \nbegin\n  intros a h,\n  have h\u2081 : ins subclass_m TransitiveRelation,\n    --specialize a15 PartialOrderingRelation TransitiveRelation subclass_m,\n    apply a15,\n    exact \u27e8a72180, a71844\u27e9, \n    exact \u27e8a67818, a13\u27e9, \n  have h\u2082 : subclass Vertebrate Organism,\n    apply a67809 _ Animal _,\n    exact \u27e8a71402, \u27e8a72771, a71371\u27e9\u27e9,\n    exact h\u2081,\n    exact \u27e8a71382, a71369\u27e9,\n  apply a15 Vertebrate _ _,\n  exact \u27e8a71402, a71371\u27e9,\n  exact \u27e8h\u2082, h\u27e9\nend\n\nlemma VertebrateEntity : \u2200 (x : U), ins x Vertebrate \u2192 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 \u27e8a71402, \u27e8 a72771, a71371 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8a71382, a71369\u27e9,  \n  have h3 : subclass Vertebrate Agent,\n    apply a67809 _ Organism _,\n    exact \u27e8a71402, \u27e8 a71371, a71872 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h2, a71340\u27e9,\n  have h4 : subclass Vertebrate Object,\n    apply a67809 _ Agent _,\n    exact \u27e8a71402, \u27e8 a71872, a71669 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h3, a67315\u27e9,\n  have h5 : subclass Vertebrate Physical,\n    apply a67809 _ Object _,\n    exact \u27e8a71402, \u27e8 a71669, a69763 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h4, a67177\u27e9,\n  have h6 : subclass Vertebrate Entity,\n    apply a67809 _ Physical _,\n    exact \u27e8a71402, \u27e8 a69763, a67331 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8 h5, a67174 \u27e9,\n  apply a15 Vertebrate _ _,\n  exact \u27e8a71402, a67331\u27e9,\n  exact \u27e8h6, h\u27e9\nend\n\n-- start proofs\n\nlemma listLemma (hne : nonempty U) : \u2200 x y z : U, \n  ins x Entity \u2227 ins y Entity \u2227 ins z Entity \u2192\n  inList x (ListFn2 y z) \u2192 x = y \u2228 x = z :=\nbegin\n  intros x y z h h1,\n    rw (a72767 y z \u27e8h.right.left, h.right.right\u27e9) at h1,\n    have h2 : x = y \u2228 inList x (ConsFn z NullList_m),\n      rw \u2190(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 \u27e8a68771, a67331\u27e9,\n          have h3, from a15 _ _ _ \u27e8a67958, a68763\u27e9 \u27e8a67954, a67959\u27e9,\n          exact \u27e8a67332, a15 _ _ _ \u27e8a68763, a68771\u27e9 \u27e8a67450, h3\u27e9\u27e9, \n          exact a67959,\n      cases h2,\n        exact or.inl h2,\n        have h3 : x = z \u2228 inList x NullList_m,\n          rw \u2190(a72770 NullList_m x z),\n          exact h2,\n          exact \u27e8h.1, \u27e8h.2.2, a67959\u27e9\u27e9,\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) : \u2200 x c c1 c2,\n  (ins c SetOrClass \u2227 ins c1 SetOrClass \u2227 ins c2 SetOrClass) \u2192\n  (ins c Class \u2227 ins c1 Class \u2227 ins c2 Class \u2227 ins x Entity) \u2192 \n    (partition3 c c1 c2 \u2227 ins x c \u2227 \u00ac ins x c1) \u2192 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\u2083, from a67131' \u27e8 h2.1, \u27e8h2.2.1, h2.2.2.1 \u27e9\u27e9,\n  have h4, from iff.elim_left h\u2083 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 \u27e8a67448, \u27e8a68771, a67331\u27e9\u27e9,\n      apply subclass_TransitiveRelation; assumption,\n      exact \u27e8a67446, a67332\u27e9,\n  have h10 : ins c1 Entity,\n    apply (a15 SetOrClass _ _), \n      exact \u27e8a67448, a67331\u27e9,\n      exact \u27e8h9, h1.2.1\u27e9,\n  have h11 : ins c2 Entity,\n    apply (a15 SetOrClass _ _), \n      exact \u27e8a67448, a67331\u27e9,\n      exact \u27e8h9, h1.2.2\u27e9,\n  specialize h7 \u27e8h1.1, \u27e8h2.1, \u27e8h2.2.1, \u27e8h10, \u27e8h2.2.2.1, h11\u27e9\u27e9\u27e9\u27e9\u27e9,\n  specialize h7 h4a,\n  specialize h7 h3.right.left,\n  have h12 : b = c1 \u2228 b = c2,\n    apply listLemma, \n      repeat { assumption },\n      split,\n        apply a15 SetOrClass _ _,\n          exact \u27e8a67448, a67331\u27e9,\n          exact \u27e8h9, h5.left\u27e9,\n      exact \u27e8h10, h11\u27e9,\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 \u2190h12,\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 \u27e8a72771, \u27e8 a71371, a71872 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8a71369, a71340\u27e9,\n  have h3 : subclass Animal Object,\n    apply a67809 _ Agent _,\n    exact \u27e8a72771, \u27e8 a71872, a71669 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h2, a67315\u27e9,\n  have h4 : subclass Animal Physical,\n    apply a67809 _ Object _,\n    exact \u27e8a72771, \u27e8 a71669, a69763 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h3, a67177\u27e9,\n  apply a67809 _ Physical _,\n  exact \u27e8a72771, \u27e8 a69763, a67331 \u27e9\u27e9,\n  exact h1,\n  exact \u27e8 h4, a67174 \u27e9,\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 \u27e8a71402, \u27e8 a72771, a71371 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8a71382, a71369\u27e9,  \n  have h3 : subclass Vertebrate Agent,\n    apply a67809 _ Organism _,\n    exact \u27e8a71402, \u27e8 a71371, a71872 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h2, a71340\u27e9,\n  have h4 : subclass Vertebrate Object,\n    apply a67809 _ Agent _,\n    exact \u27e8a71402, \u27e8 a71872, a71669 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h3, a67315\u27e9,\n  have h5 : subclass Vertebrate Physical,\n    apply a67809 _ Object _,\n    exact \u27e8a71402, \u27e8 a71669, a69763 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h4, a67177\u27e9,\n  apply a67809 _ Physical _,\n  exact \u27e8a71402, \u27e8 a69763, a67331 \u27e9\u27e9,\n  exact h1,\n  exact \u27e8 h5, a67174 \u27e9,\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 \u27e8a72778, \u27e8 a72771, a71371 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8a71383, a71369\u27e9,  \n  have h3 : subclass Invertebrate Agent,\n    apply a67809 _ Organism _,\n    exact \u27e8a72778, \u27e8 a71371, a71872 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h2, a71340\u27e9,\n  have h4 : subclass Invertebrate Object,\n    apply a67809 _ Agent _,\n    exact \u27e8a72778, \u27e8 a71872, a71669 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h3, a67315\u27e9,\n  have h5 : subclass Invertebrate Physical,\n    apply a67809 _ Object _,\n    exact \u27e8a72778, \u27e8 a71669, a69763 \u27e9\u27e9,\n    exact h1,\n    exact \u27e8h4, a67177\u27e9,\n  apply a67809 _ Physical _,\n  exact \u27e8a72778, \u27e8 a69763, a67331 \u27e9\u27e9,\n  exact h1,\n  exact \u27e8 h5, a67174 \u27e9,\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) : \u00ac(ins BananaSlug10 Vertebrate) := by simp *\nlemma l0  (hne : nonempty U) : \u00ac(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 : \u00ac ins BananaSlug10 Vertebrate,\n  apply l0; assumption,\n have h2 : \u2200 x c c1 c2,\n  (ins c SetOrClass \u2227 ins c1 SetOrClass \u2227 ins c2 SetOrClass) \u2192\n  (ins c Class \u2227 ins c1 Class \u2227 ins c2 Class \u2227 ins x Entity) \u2192 \n   (partition3 c c1 c2 \u2227 ins x c \u2227 \u00ac ins x c1) \u2192 ins x c2, \n   apply lX; assumption,\n have h3, from h2 BananaSlug10 Animal Vertebrate Invertebrate,\n apply h3,\n exact \u27e8 a72771, \u27e8 a71402, a72778 \u27e9\u27e9,\n have h\u2081 : subclass Animal Entity, \n   apply subclass_animal_entity; assumption,\n have h\u2082 : ins Animal Class,\n   rw a67173, exact h\u2081,\n have h\u2083 : subclass Vertebrate Entity,\n   apply subclass_vertebrate_entity; assumption,\n have h\u2084 : ins Vertebrate Class, \n   rw a67173, exact h\u2083,\n have h\u2085 : subclass Invertebrate Entity,\n   apply subclass_invertebrate_entity; assumption,\n have h\u2086 : ins Invertebrate Class, \n  rw a67173, exact h\u2085,\n have h\u2087 : ins BananaSlug10 Entity, \n  apply ins_banana_entity; assumption,\n exact and.intro h\u2082 (and.intro h\u2084 (and.intro h\u2086 h\u2087)),\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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> \u03b1`: Equips `option \u03b1` with the order on `\u03b1` plus `none` as the top/bottom element.\n\n -/\n\n\nvariable {\u03b1 \u03b2 \u03b3 \u03b4 : Type _}\n\n#print WithBot /-\n/-- Attach `\u22a5` to a type. -/\ndef WithBot (\u03b1 : Type _) :=\n  Option \u03b1\n#align with_bot WithBot\n-/\n\nnamespace WithBot\n\nvariable {a b : \u03b1}\n\nunsafe instance [has_to_format \u03b1] : has_to_format (WithBot \u03b1)\n    where to_format x :=\n    match x with\n    | none => \"\u22a5\"\n    | some x => to_fmt x\n\ninstance [Repr \u03b1] : Repr (WithBot \u03b1) :=\n  \u27e8fun o =>\n    match o with\n    | none => \"\u22a5\"\n    | some a => \"\u2191\" ++ repr a\u27e9\n\ninstance : CoeTC \u03b1 (WithBot \u03b1) :=\n  \u27e8some\u27e9\n\ninstance : Bot (WithBot \u03b1) :=\n  \u27e8none\u27e9\n\nunsafe instance {\u03b1 : Type} [reflected _ \u03b1] [has_reflect \u03b1] : has_reflect (WithBot \u03b1)\n  | \u22a5 => q(\u22a5)\n  | (a : \u03b1) => q((coe : \u03b1 \u2192 WithBot \u03b1)).subst q(a)\n\ninstance : Inhabited (WithBot \u03b1) :=\n  \u27e8\u22a5\u27e9\n\ninstance [Nonempty \u03b1] : Nontrivial (WithBot \u03b1) :=\n  Option.nontrivial\n\nopen Function\n\n#print WithBot.coe_injective /-\ntheorem coe_injective : Injective (coe : \u03b1 \u2192 WithBot \u03b1) :=\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 \u03b1) = b \u2194 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 \u03b1 \u2192 Prop} : (\u2200 x, p x) \u2194 p \u22a5 \u2227 \u2200 x : \u03b1, p x :=\n  Option.forall\n#align with_bot.forall WithBot.forall\n-/\n\n#print WithBot.exists /-\nprotected theorem exists {p : WithBot \u03b1 \u2192 Prop} : (\u2203 x, p x) \u2194 p \u22a5 \u2228 \u2203 x : \u03b1, 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 \u03b1) = (\u22a5 : WithBot \u03b1) :=\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 : \u03b1) : (some a : WithBot \u03b1) = (\u2191a : WithBot \u03b1) :=\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 : \u22a5 \u2260 (a : WithBot \u03b1) :=\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 \u03b1) \u2260 \u22a5 :=\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 `\u22a5` and `\u2191a`. -/\n@[elab_as_elim]\ndef recBotCoe {C : WithBot \u03b1 \u2192 Sort _} (h\u2081 : C \u22a5) (h\u2082 : \u2200 a : \u03b1, C a) : \u2200 n : WithBot \u03b1, C n :=\n  Option.rec h\u2081 h\u2082\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 {\u03b1 : Type.{u1}} {C : (WithBot.{u1} \u03b1) -> Sort.{u2}} (d : C (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (f : forall (a : \u03b1), C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a)), Eq.{u2} (C (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (WithBot.recBotCoe.{u1, u2} \u03b1 C d f (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) d\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {C : (WithBot.{u2} \u03b1) -> Sort.{u1}} (d : C (Bot.bot.{u2} (WithBot.{u2} \u03b1) (WithBot.bot.{u2} \u03b1))) (f : forall (a : \u03b1), C (WithBot.some.{u2} \u03b1 a)), Eq.{u1} (C (Bot.bot.{u2} (WithBot.{u2} \u03b1) (WithBot.bot.{u2} \u03b1))) (WithBot.recBotCoe.{u2, u1} \u03b1 C d f (Bot.bot.{u2} (WithBot.{u2} \u03b1) (WithBot.bot.{u2} \u03b1))) d\nCase conversion may be inaccurate. Consider using '#align with_bot.rec_bot_coe_bot WithBot.recBotCoe_bot\u2093'. -/\n@[simp]\ntheorem recBotCoe_bot {C : WithBot \u03b1 \u2192 Sort _} (d : C \u22a5) (f : \u2200 a : \u03b1, C a) :\n    @recBotCoe _ C d f \u22a5 = 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 {\u03b1 : Type.{u1}} {C : (WithBot.{u1} \u03b1) -> Sort.{u2}} (d : C (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (f : forall (a : \u03b1), C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a)) (x : \u03b1), Eq.{u2} (C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) x)) (WithBot.recBotCoe.{u1, u2} \u03b1 C d f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) x)) (f x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {C : (WithBot.{u2} \u03b1) -> Sort.{u1}} (d : C (Bot.bot.{u2} (WithBot.{u2} \u03b1) (WithBot.bot.{u2} \u03b1))) (f : forall (a : \u03b1), C (WithBot.some.{u2} \u03b1 a)) (x : \u03b1), Eq.{u1} (C (WithBot.some.{u2} \u03b1 x)) (WithBot.recBotCoe.{u2, u1} \u03b1 C d f (WithBot.some.{u2} \u03b1 x)) (f x)\nCase conversion may be inaccurate. Consider using '#align with_bot.rec_bot_coe_coe WithBot.recBotCoe_coe\u2093'. -/\n@[simp]\ntheorem recBotCoe_coe {C : WithBot \u03b1 \u2192 Sort _} (d : C \u22a5) (f : \u2200 a : \u03b1, C a) (x : \u03b1) :\n    @recBotCoe _ C d f \u2191x = 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 \u03b1` that respects API boundaries.\n-/\ndef unbot' (d : \u03b1) (x : WithBot \u03b1) : \u03b1 :=\n  recBotCoe d id x\n#align with_bot.unbot' WithBot.unbot'\n-/\n\n#print WithBot.unbot'_bot /-\n@[simp]\ntheorem unbot'_bot {\u03b1} (d : \u03b1) : unbot' d \u22a5 = d :=\n  rfl\n#align with_bot.unbot'_bot WithBot.unbot'_bot\n-/\n\n#print WithBot.unbot'_coe /-\n@[simp]\ntheorem unbot'_coe {\u03b1} (d x : \u03b1) : 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 \u03b1) = b \u2194 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 : \u03b1} {x : WithBot \u03b1} : unbot' d x = y \u2194 x = y \u2228 x = \u22a5 \u2227 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 : \u03b1} {x : WithBot \u03b1} : unbot' d x = d \u2194 x = d \u2228 x = \u22a5 := 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 : \u03b1} {x y : WithBot \u03b1} :\n    unbot' d x = unbot' d y \u2194 x = y \u2228 x = d \u2227 y = \u22a5 \u2228 x = \u22a5 \u2227 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 : \u03b1 \u2192 \u03b2` to `with_bot \u03b1 \u2192 with_bot \u03b2`. Implemented using `option.map`. -/\ndef map (f : \u03b1 \u2192 \u03b2) : WithBot \u03b1 \u2192 WithBot \u03b2 :=\n  Option.map f\n#align with_bot.map WithBot.map\n-/\n\n#print WithBot.map_bot /-\n@[simp]\ntheorem map_bot (f : \u03b1 \u2192 \u03b2) : map f \u22a5 = \u22a5 :=\n  rfl\n#align with_bot.map_bot WithBot.map_bot\n-/\n\n#print WithBot.map_coe /-\n@[simp]\ntheorem map_coe (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {f\u2081 : \u03b1 -> \u03b2} {f\u2082 : \u03b1 -> \u03b3} {g\u2081 : \u03b2 -> \u03b4} {g\u2082 : \u03b3 -> \u03b4}, (Eq.{max (succ u1) (succ u4)} (\u03b1 -> \u03b4) (Function.comp.{succ u1, succ u2, succ u4} \u03b1 \u03b2 \u03b4 g\u2081 f\u2081) (Function.comp.{succ u1, succ u3, succ u4} \u03b1 \u03b3 \u03b4 g\u2082 f\u2082)) -> (forall (a : \u03b1), Eq.{succ u4} (WithBot.{u4} \u03b4) (WithBot.map.{u2, u4} \u03b2 \u03b4 g\u2081 (WithBot.map.{u1, u2} \u03b1 \u03b2 f\u2081 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a))) (WithBot.map.{u3, u4} \u03b3 \u03b4 g\u2082 (WithBot.map.{u1, u3} \u03b1 \u03b3 f\u2082 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {\u03b4 : Type.{u3}} {f\u2081 : \u03b1 -> \u03b2} {f\u2082 : \u03b1 -> \u03b3} {g\u2081 : \u03b2 -> \u03b4} {g\u2082 : \u03b3 -> \u03b4}, (Eq.{max (succ u4) (succ u3)} (\u03b1 -> \u03b4) (Function.comp.{succ u4, succ u2, succ u3} \u03b1 \u03b2 \u03b4 g\u2081 f\u2081) (Function.comp.{succ u4, succ u1, succ u3} \u03b1 \u03b3 \u03b4 g\u2082 f\u2082)) -> (forall (a : \u03b1), Eq.{succ u3} (WithBot.{u3} \u03b4) (WithBot.map.{u2, u3} \u03b2 \u03b4 g\u2081 (WithBot.map.{u4, u2} \u03b1 \u03b2 f\u2081 (WithBot.some.{u4} \u03b1 a))) (WithBot.map.{u1, u3} \u03b3 \u03b4 g\u2082 (WithBot.map.{u4, u1} \u03b1 \u03b3 f\u2082 (WithBot.some.{u4} \u03b1 a))))\nCase conversion may be inaccurate. Consider using '#align with_bot.map_comm WithBot.map_comm\u2093'. -/\ntheorem map_comm {f\u2081 : \u03b1 \u2192 \u03b2} {f\u2082 : \u03b1 \u2192 \u03b3} {g\u2081 : \u03b2 \u2192 \u03b4} {g\u2082 : \u03b3 \u2192 \u03b4} (h : g\u2081 \u2218 f\u2081 = g\u2082 \u2218 f\u2082)\n    (a : \u03b1) : map g\u2081 (map f\u2081 a) = map g\u2082 (map f\u2082 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 \u03b1} : x \u2260 \u22a5 \u2194 \u2203 a : \u03b1, \u2191a = 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 \u03b1` to the underlying value in `\u03b1`, given a proof that `x \u2260 \u22a5`. -/\ndef unbot : \u2200 x : WithBot \u03b1, x \u2260 \u22a5 \u2192 \u03b1\n  | \u22a5, 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 \u03b1) (h : x \u2260 \u22a5) : (x.unbot h : WithBot \u03b1) = 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 : \u03b1) (h : (x : WithBot \u03b1) \u2260 \u22a5 := coe_ne_bot) : (x : WithBot \u03b1).unbot h = x :=\n  rfl\n#align with_bot.unbot_coe WithBot.unbot_coe\n-/\n\n#print WithBot.canLift /-\ninstance canLift : CanLift (WithBot \u03b1) \u03b1 coe fun r => r \u2260 \u22a5\n    where prf x h := \u27e8x.unbot h, coe_unbot _ _\u27e9\n#align with_bot.can_lift WithBot.canLift\n-/\n\nsection LE\n\nvariable [LE \u03b1]\n\ninstance (priority := 10) : LE (WithBot \u03b1) :=\n  \u27e8fun o\u2081 o\u2082 : Option \u03b1 => \u2200 a \u2208 o\u2081, \u2203 b \u2208 o\u2082, a \u2264 b\u27e9\n\n/- warning: with_bot.some_le_some -> WithBot.some_le_some is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1], Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.some.{u1} \u03b1 b)) (LE.le.{u1} \u03b1 _inst_1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1], Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.some.{u1} \u03b1 b)) (LE.le.{u1} \u03b1 _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_bot.some_le_some WithBot.some_le_some\u2093'. -/\n@[simp]\ntheorem some_le_some : @LE.le (WithBot \u03b1) _ (some a) (some b) \u2194 a \u2264 b := by simp [(\u00b7 \u2264 \u00b7)]\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 {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1], Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b)) (LE.le.{u1} \u03b1 _inst_1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1], Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) (WithBot.some.{u1} \u03b1 a) (WithBot.some.{u1} \u03b1 b)) (LE.le.{u1} \u03b1 _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_le_coe WithBot.coe_le_coe\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_le_coe : (a : WithBot \u03b1) \u2264 b \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} \u03b1}, LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) (Option.none.{u1} \u03b1) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} \u03b1}, LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) (Option.none.{u1} \u03b1) a\nCase conversion may be inaccurate. Consider using '#align with_bot.none_le WithBot.none_le\u2093'. -/\n@[simp]\ntheorem none_le {a : WithBot \u03b1} : @LE.le (WithBot \u03b1) _ none a := fun b h => Option.noConfusion h\n#align with_bot.none_le WithBot.none_le\n\ninstance : OrderBot (WithBot \u03b1) :=\n  { WithBot.hasBot with bot_le := fun a => none_le }\n\ninstance [OrderTop \u03b1] : OrderTop (WithBot \u03b1)\n    where\n  top := some \u22a4\n  le_top o a ha := by cases ha <;> exact \u27e8_, rfl, le_top\u27e9\n\ninstance [OrderTop \u03b1] : BoundedOrder (WithBot \u03b1) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] (a : \u03b1), Not (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] (a : \u03b1), Not (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) (WithBot.some.{u1} \u03b1 a) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_bot.not_coe_le_bot WithBot.not_coe_le_bot\u2093'. -/\ntheorem not_coe_le_bot (a : \u03b1) : \u00ac(a : WithBot \u03b1) \u2264 \u22a5 := fun h =>\n  let \u27e8b, hb, _\u27e9 := 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 {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1] {o : Option.{u1} \u03b1}, (Membership.Mem.{u1, u1} \u03b1 (Option.{u1} \u03b1) (Option.hasMem.{u1} \u03b1) b o) -> (Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) o) (LE.le.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1] {o : Option.{u1} \u03b1}, (Membership.mem.{u1, u1} \u03b1 (Option.{u1} \u03b1) (Option.instMembershipOption.{u1} \u03b1) b o) -> (Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) (WithBot.some.{u1} \u03b1 a) o) (LE.le.{u1} \u03b1 _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_le WithBot.coe_le\u2093'. -/\ntheorem coe_le : \u2200 {o : Option \u03b1}, b \u2208 o \u2192 ((a : WithBot \u03b1) \u2264 o \u2194 a \u2264 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 {\u03b1 : Type.{u1}} {a : \u03b1} [_inst_1 : LE.{u1} \u03b1] {x : WithBot.{u1} \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) x) (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (Eq.{succ u1} (WithBot.{u1} \u03b1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b)) (LE.le.{u1} \u03b1 _inst_1 a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} [_inst_1 : LE.{u1} \u03b1] {x : WithBot.{u1} \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) (WithBot.some.{u1} \u03b1 a) x) (Exists.{succ u1} \u03b1 (fun (b : \u03b1) => And (Eq.{succ u1} (WithBot.{u1} \u03b1) x (WithBot.some.{u1} \u03b1 b)) (LE.le.{u1} \u03b1 _inst_1 a b)))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_le_iff WithBot.coe_le_iff\u2093'. -/\ntheorem coe_le_iff : \u2200 {x : WithBot \u03b1}, \u2191a \u2264 x \u2194 \u2203 b : \u03b1, x = b \u2227 a \u2264 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 {\u03b1 : Type.{u1}} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1] {x : WithBot.{u1} \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b)) (forall (a : \u03b1), (Eq.{succ u1} (WithBot.{u1} \u03b1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a)) -> (LE.le.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1] {x : WithBot.{u1} \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) x (WithBot.some.{u1} \u03b1 b)) (forall (a : \u03b1), (Eq.{succ u1} (WithBot.{u1} \u03b1) x (WithBot.some.{u1} \u03b1 a)) -> (LE.le.{u1} \u03b1 _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.le_coe_iff WithBot.le_coe_iff\u2093'. -/\ntheorem le_coe_iff : \u2200 {x : WithBot \u03b1}, x \u2264 b \u2194 \u2200 a, x = \u2191a \u2192 a \u2264 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 {\u03b1 : Type.{u1}} {a : \u03b1} [_inst_1 : LE.{u1} \u03b1], (IsMax.{u1} \u03b1 _inst_1 a) -> (IsMax.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} [_inst_1 : LE.{u1} \u03b1], (IsMax.{u1} \u03b1 _inst_1 a) -> (IsMax.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) (WithBot.some.{u1} \u03b1 a))\nCase conversion may be inaccurate. Consider using '#align is_max.with_bot IsMax.withBot\u2093'. -/\nprotected theorem IsMax.withBot (h : IsMax a) : IsMax (a : WithBot \u03b1)\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 \u03b1]\n\ninstance (priority := 10) : LT (WithBot \u03b1) :=\n  \u27e8fun o\u2081 o\u2082 : Option \u03b1 => \u2203 b \u2208 o\u2082, \u2200 a \u2208 o\u2081, a < b\u27e9\n\n/- warning: with_bot.some_lt_some -> WithBot.some_lt_some is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LT.{u1} \u03b1], Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.some.{u1} \u03b1 b)) (LT.lt.{u1} \u03b1 _inst_1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LT.{u1} \u03b1], Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.some.{u1} \u03b1 b)) (LT.lt.{u1} \u03b1 _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_bot.some_lt_some WithBot.some_lt_some\u2093'. -/\n@[simp]\ntheorem some_lt_some : @LT.lt (WithBot \u03b1) _ (some a) (some b) \u2194 a < b := by simp [(\u00b7 < \u00b7)]\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 {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LT.{u1} \u03b1], Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b)) (LT.lt.{u1} \u03b1 _inst_1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LT.{u1} \u03b1], Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) (WithBot.some.{u1} \u03b1 a) (WithBot.some.{u1} \u03b1 b)) (LT.lt.{u1} \u03b1 _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_lt_coe WithBot.coe_lt_coe\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_lt_coe : (a : WithBot \u03b1) < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : \u03b1), LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) (Option.none.{u1} \u03b1) (Option.some.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : \u03b1), LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) (Option.none.{u1} \u03b1) (WithBot.some.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align with_bot.none_lt_some WithBot.none_lt_some\u2093'. -/\n@[simp]\ntheorem none_lt_some (a : \u03b1) : @LT.lt (WithBot \u03b1) _ none (some a) :=\n  \u27e8a, rfl, fun b hb => (Option.not_mem_none _ hb).elim\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : \u03b1), LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : \u03b1), LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) (WithBot.some.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_lt_coe WithBot.bot_lt_coe\u2093'. -/\ntheorem bot_lt_coe (a : \u03b1) : (\u22a5 : WithBot \u03b1) < 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : WithBot.{u1} \u03b1), Not (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) a (Option.none.{u1} \u03b1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : WithBot.{u1} \u03b1), Not (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) a (Option.none.{u1} \u03b1))\nCase conversion may be inaccurate. Consider using '#align with_bot.not_lt_none WithBot.not_lt_none\u2093'. -/\n@[simp]\ntheorem not_lt_none (a : WithBot \u03b1) : \u00ac@LT.lt (WithBot \u03b1) _ a none := fun \u27e8_, h, _\u27e9 =>\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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) a b) (Exists.{succ u1} \u03b1 (fun (p : \u03b1) => And (Eq.{succ u1} (WithBot.{u1} \u03b1) b ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) p)) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) p))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) a b) (Exists.{succ u1} \u03b1 (fun (p : \u03b1) => And (Eq.{succ u1} (WithBot.{u1} \u03b1) b (WithBot.some.{u1} \u03b1 p)) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) a (WithBot.some.{u1} \u03b1 p))))\nCase conversion may be inaccurate. Consider using '#align with_bot.lt_iff_exists_coe WithBot.lt_iff_exists_coe\u2093'. -/\ntheorem lt_iff_exists_coe : \u2200 {a b : WithBot \u03b1}, a < b \u2194 \u2203 p : \u03b1, b = p \u2227 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 {\u03b1 : Type.{u1}} {b : \u03b1} [_inst_1 : LT.{u1} \u03b1] {x : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b)) (forall (a : \u03b1), (Eq.{succ u1} (WithBot.{u1} \u03b1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a)) -> (LT.lt.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {b : \u03b1} [_inst_1 : LT.{u1} \u03b1] {x : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) x (WithBot.some.{u1} \u03b1 b)) (forall (a : WithBot.{u1} \u03b1), (Eq.{succ u1} (WithBot.{u1} \u03b1) x a) -> (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) a (WithBot.some.{u1} \u03b1 b)))\nCase conversion may be inaccurate. Consider using '#align with_bot.lt_coe_iff WithBot.lt_coe_iff\u2093'. -/\ntheorem lt_coe_iff : \u2200 {x : WithBot \u03b1}, x < b \u2194 \u2200 a, x = \u2191a \u2192 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {x : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) x) (Ne.{succ u1} (WithBot.{u1} \u03b1) x (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {x : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) x) (Ne.{succ u1} (WithBot.{u1} \u03b1) x (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_lt_iff_ne_bot WithBot.bot_lt_iff_ne_bot\u2093'. -/\n/-- A version of `bot_lt_iff_ne_bot` for `with_bot` that only requires `has_lt \u03b1`, not\n`partial_order \u03b1`. -/\nprotected theorem bot_lt_iff_ne_bot : \u2200 {x : WithBot \u03b1}, \u22a5 < x \u2194 x \u2260 \u22a5\n  | \u22a5 => iff_of_false (WithBot.not_lt_none _) fun h => h rfl\n  | (x : \u03b1) => 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 \u03b1] : Preorder (WithBot \u03b1)\n    where\n  le := (\u00b7 \u2264 \u00b7)\n  lt := (\u00b7 < \u00b7)\n  lt_iff_le_not_le := by\n    intros\n    cases a <;> cases b <;> simp [lt_iff_le_not_le] <;> simp [(\u00b7 < \u00b7), (\u00b7 \u2264 \u00b7)]\n  le_refl o a ha := \u27e8a, ha, le_rfl\u27e9\n  le_trans o\u2081 o\u2082 o\u2083 h\u2081 h\u2082 a ha :=\n    let \u27e8b, hb, ab\u27e9 := h\u2081 a ha\n    let \u27e8c, hc, bc\u27e9 := h\u2082 b hb\n    \u27e8c, hc, le_trans ab bc\u27e9\n\ninstance [PartialOrder \u03b1] : PartialOrder (WithBot \u03b1) :=\n  { WithBot.preorder with\n    le_antisymm := fun o\u2081 o\u2082 h\u2081 h\u2082 => by\n      cases' o\u2081 with a\n      \u00b7 cases' o\u2082 with b\n        \u00b7 rfl\n        rcases h\u2082 b rfl with \u27e8_, \u27e8\u27e9, _\u27e9\n      \u00b7 rcases h\u2081 a rfl with \u27e8b, \u27e8\u27e9, h\u2081'\u27e9\n        rcases h\u2082 b rfl with \u27e8_, \u27e8\u27e9, h\u2082'\u27e9\n        rw [le_antisymm h\u2081' h\u2082'] }\n\n#print WithBot.coe_strictMono /-\ntheorem coe_strictMono [Preorder \u03b1] : StrictMono (coe : \u03b1 \u2192 WithBot \u03b1) := 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 \u03b1] : Monotone (coe : \u03b1 \u2192 WithBot \u03b1) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : (WithBot.{u1} \u03b1) -> \u03b2}, Iff (Monotone.{u1, u2} (WithBot.{u1} \u03b1) \u03b2 (WithBot.preorder.{u1} \u03b1 _inst_1) _inst_2 f) (And (Monotone.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 (Function.comp.{succ u1, succ u1, succ u2} \u03b1 (WithBot.{u1} \u03b1) \u03b2 f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1)))))) (forall (x : \u03b1), LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) (f (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) x))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : (WithBot.{u2} \u03b1) -> \u03b2}, Iff (Monotone.{u2, u1} (WithBot.{u2} \u03b1) \u03b2 (WithBot.preorder.{u2} \u03b1 _inst_1) _inst_2 f) (And (Monotone.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) => f (WithBot.some.{u2} \u03b1 a))) (forall (x : \u03b1), LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _inst_2) (f (Bot.bot.{u2} (WithBot.{u2} \u03b1) (WithBot.bot.{u2} \u03b1))) (f (WithBot.some.{u2} \u03b1 x))))\nCase conversion may be inaccurate. Consider using '#align with_bot.monotone_iff WithBot.monotone_iff\u2093'. -/\ntheorem monotone_iff [Preorder \u03b1] [Preorder \u03b2] {f : WithBot \u03b1 \u2192 \u03b2} :\n    Monotone f \u2194 Monotone (f \u2218 coe : \u03b1 \u2192 \u03b2) \u2227 \u2200 x : \u03b1, f \u22a5 \u2264 f x :=\n  \u27e8fun h => \u27e8h.comp WithBot.coe_mono, fun x => h bot_le\u27e9, fun h =>\n    WithBot.forall.2\n      \u27e8WithBot.forall.2 \u27e8fun _ => le_rfl, fun x _ => h.2 x\u27e9, fun x =>\n        WithBot.forall.2 \u27e8fun h => (not_coe_le_bot _ h).elim, fun y hle => h.1 (coe_le_coe.1 hle)\u27e9\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, Iff (Monotone.{u1, u2} (WithBot.{u1} \u03b1) (WithBot.{u2} \u03b2) (WithBot.preorder.{u1} \u03b1 _inst_1) (WithBot.preorder.{u2} \u03b2 _inst_2) (WithBot.map.{u1, u2} \u03b1 \u03b2 f)) (Monotone.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, Iff (Monotone.{u2, u1} (WithBot.{u2} \u03b1) (WithBot.{u1} \u03b2) (WithBot.preorder.{u2} \u03b1 _inst_1) (WithBot.preorder.{u1} \u03b2 _inst_2) (WithBot.map.{u2, u1} \u03b1 \u03b2 f)) (Monotone.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align with_bot.monotone_map_iff WithBot.monotone_map_iff\u2093'. -/\n@[simp]\ntheorem monotone_map_iff [Preorder \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    Monotone (WithBot.map f) \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Monotone.{u1, u2} (WithBot.{u1} \u03b1) (WithBot.{u2} \u03b2) (WithBot.preorder.{u1} \u03b1 _inst_1) (WithBot.preorder.{u2} \u03b2 _inst_2) (WithBot.map.{u1, u2} \u03b1 \u03b2 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Monotone.{u2, u1} (WithBot.{u2} \u03b1) (WithBot.{u1} \u03b2) (WithBot.preorder.{u2} \u03b1 _inst_1) (WithBot.preorder.{u1} \u03b2 _inst_2) (WithBot.map.{u2, u1} \u03b1 \u03b2 f))\nCase conversion may be inaccurate. Consider using '#align monotone.with_bot_map Monotone.withBot_map\u2093'. -/\nalias monotone_map_iff \u2194 _ _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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : (WithBot.{u1} \u03b1) -> \u03b2}, Iff (StrictMono.{u1, u2} (WithBot.{u1} \u03b1) \u03b2 (WithBot.preorder.{u1} \u03b1 _inst_1) _inst_2 f) (And (StrictMono.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 (Function.comp.{succ u1, succ u1, succ u2} \u03b1 (WithBot.{u1} \u03b1) \u03b2 f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1)))))) (forall (x : \u03b1), LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 _inst_2) (f (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) (f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) x))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : (WithBot.{u2} \u03b1) -> \u03b2}, Iff (StrictMono.{u2, u1} (WithBot.{u2} \u03b1) \u03b2 (WithBot.preorder.{u2} \u03b1 _inst_1) _inst_2 f) (And (StrictMono.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) => f (WithBot.some.{u2} \u03b1 a))) (forall (x : \u03b1), LT.lt.{u1} \u03b2 (Preorder.toLT.{u1} \u03b2 _inst_2) (f (Bot.bot.{u2} (WithBot.{u2} \u03b1) (WithBot.bot.{u2} \u03b1))) (f (WithBot.some.{u2} \u03b1 x))))\nCase conversion may be inaccurate. Consider using '#align with_bot.strict_mono_iff WithBot.strictMono_iff\u2093'. -/\ntheorem strictMono_iff [Preorder \u03b1] [Preorder \u03b2] {f : WithBot \u03b1 \u2192 \u03b2} :\n    StrictMono f \u2194 StrictMono (f \u2218 coe : \u03b1 \u2192 \u03b2) \u2227 \u2200 x : \u03b1, f \u22a5 < f x :=\n  \u27e8fun h => \u27e8h.comp WithBot.coe_strictMono, fun x => h (bot_lt_coe _)\u27e9, fun h =>\n    WithBot.forall.2\n      \u27e8WithBot.forall.2 \u27e8flip absurd (lt_irrefl _), fun x _ => h.2 x\u27e9, fun x =>\n        WithBot.forall.2 \u27e8fun h => (not_lt_bot h).elim, fun y hle => h.1 (coe_lt_coe.1 hle)\u27e9\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, Iff (StrictMono.{u1, u2} (WithBot.{u1} \u03b1) (WithBot.{u2} \u03b2) (WithBot.preorder.{u1} \u03b1 _inst_1) (WithBot.preorder.{u2} \u03b2 _inst_2) (WithBot.map.{u1, u2} \u03b1 \u03b2 f)) (StrictMono.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, Iff (StrictMono.{u2, u1} (WithBot.{u2} \u03b1) (WithBot.{u1} \u03b2) (WithBot.preorder.{u2} \u03b1 _inst_1) (WithBot.preorder.{u1} \u03b2 _inst_2) (WithBot.map.{u2, u1} \u03b1 \u03b2 f)) (StrictMono.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align with_bot.strict_mono_map_iff WithBot.strictMono_map_iff\u2093'. -/\n@[simp]\ntheorem strictMono_map_iff [Preorder \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    StrictMono (WithBot.map f) \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (StrictMono.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (StrictMono.{u1, u2} (WithBot.{u1} \u03b1) (WithBot.{u2} \u03b2) (WithBot.preorder.{u1} \u03b1 _inst_1) (WithBot.preorder.{u2} \u03b2 _inst_2) (WithBot.map.{u1, u2} \u03b1 \u03b2 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (StrictMono.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (StrictMono.{u2, u1} (WithBot.{u2} \u03b1) (WithBot.{u1} \u03b2) (WithBot.preorder.{u2} \u03b1 _inst_1) (WithBot.preorder.{u1} \u03b2 _inst_2) (WithBot.map.{u2, u1} \u03b1 \u03b2 f))\nCase conversion may be inaccurate. Consider using '#align strict_mono.with_bot_map StrictMono.withBot_map\u2093'. -/\nalias strict_mono_map_iff \u2194 _ _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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] (f : \u03b1 -> \u03b2), (forall {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) (f a) (f b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) a b)) -> (forall (a : WithBot.{u1} \u03b1) (b : WithBot.{u1} \u03b1), Iff (LE.le.{u2} (WithBot.{u2} \u03b2) (Preorder.toLE.{u2} (WithBot.{u2} \u03b2) (WithBot.preorder.{u2} \u03b2 _inst_2)) (WithBot.map.{u1, u2} \u03b1 \u03b2 f a) (WithBot.map.{u1, u2} \u03b1 \u03b2 f b)) (LE.le.{u1} (WithBot.{u1} \u03b1) (Preorder.toLE.{u1} (WithBot.{u1} \u03b1) (WithBot.preorder.{u1} \u03b1 _inst_1)) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] (f : \u03b1 -> \u03b2), (forall {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _inst_2) (f a) (f b)) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_1) a b)) -> (forall (a : WithBot.{u2} \u03b1) (b : WithBot.{u2} \u03b1), Iff (LE.le.{u1} (WithBot.{u1} \u03b2) (Preorder.toLE.{u1} (WithBot.{u1} \u03b2) (WithBot.preorder.{u1} \u03b2 _inst_2)) (WithBot.map.{u2, u1} \u03b1 \u03b2 f a) (WithBot.map.{u2, u1} \u03b1 \u03b2 f b)) (LE.le.{u2} (WithBot.{u2} \u03b1) (Preorder.toLE.{u2} (WithBot.{u2} \u03b1) (WithBot.preorder.{u2} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align with_bot.map_le_iff WithBot.map_le_iff\u2093'. -/\ntheorem map_le_iff [Preorder \u03b1] [Preorder \u03b2] (f : \u03b1 \u2192 \u03b2) (mono_iff : \u2200 {a b}, f a \u2264 f b \u2194 a \u2264 b) :\n    \u2200 a b : WithBot \u03b1, a.map f \u2264 b.map f \u2194 a \u2264 b\n  | \u22a5, _ => by simp only [map_bot, bot_le]\n  | (a : \u03b1), \u22a5 => by simp only [map_coe, map_bot, coe_ne_bot, not_coe_le_bot _]\n  | (a : \u03b1), (b : \u03b1) => 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 \u03b1] : \u2200 (a : WithBot \u03b1) (b : \u03b1), a \u2264 a.unbot' b\n  | (a : \u03b1), b => le_rfl\n  | \u22a5, 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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : OrderBot.{u1} \u03b1 _inst_1] {a : WithBot.{u1} \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 _inst_1 (WithBot.unbot'.{u1} \u03b1 (Bot.bot.{u1} \u03b1 (OrderBot.toHasBot.{u1} \u03b1 _inst_1 _inst_2)) a) b) (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : OrderBot.{u1} \u03b1 _inst_1] {a : WithBot.{u1} \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b1 _inst_1 (WithBot.unbot'.{u1} \u03b1 (Bot.bot.{u1} \u03b1 (OrderBot.toBot.{u1} \u03b1 _inst_1 _inst_2)) a) b) (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) a (WithBot.some.{u1} \u03b1 b))\nCase conversion may be inaccurate. Consider using '#align with_bot.unbot'_bot_le_iff WithBot.unbot'_bot_le_iff\u2093'. -/\ntheorem unbot'_bot_le_iff [LE \u03b1] [OrderBot \u03b1] {a : WithBot \u03b1} {b : \u03b1} : a.unbot' \u22a5 \u2264 b \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : \u03b1} {c : \u03b1}, (Ne.{succ u1} (WithBot.{u1} \u03b1) a (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1))) -> (Iff (LT.lt.{u1} \u03b1 _inst_1 (WithBot.unbot'.{u1} \u03b1 b a) c) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) c)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : \u03b1} {c : \u03b1}, (Ne.{succ u1} (WithBot.{u1} \u03b1) a (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1))) -> (Iff (LT.lt.{u1} \u03b1 _inst_1 (WithBot.unbot'.{u1} \u03b1 b a) c) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) a (WithBot.some.{u1} \u03b1 c)))\nCase conversion may be inaccurate. Consider using '#align with_bot.unbot'_lt_iff WithBot.unbot'_lt_iff\u2093'. -/\ntheorem unbot'_lt_iff [LT \u03b1] {a : WithBot \u03b1} {b c : \u03b1} (ha : a \u2260 \u22a5) : a.unbot' b < c \u2194 a < c :=\n  by\n  lift a to \u03b1 using ha\n  rw [unbot'_coe, coe_lt_coe]\n#align with_bot.unbot'_lt_iff WithBot.unbot'_lt_iff\n\ninstance [SemilatticeSup \u03b1] : SemilatticeSup (WithBot \u03b1) :=\n  { WithBot.orderBot,\n    WithBot.partialOrder with\n    sup := Option.liftOrGet (\u00b7 \u2294 \u00b7)\n    le_sup_left := fun o\u2081 o\u2082 a ha => by cases ha <;> cases o\u2082 <;> simp [Option.liftOrGet]\n    le_sup_right := fun o\u2081 o\u2082 a ha => by cases ha <;> cases o\u2081 <;> simp [Option.liftOrGet]\n    sup_le := fun o\u2081 o\u2082 o\u2083 h\u2081 h\u2082 a ha =>\n      by\n      cases' o\u2081 with b <;> cases' o\u2082 with c <;> cases ha\n      \u00b7 exact h\u2082 a rfl\n      \u00b7 exact h\u2081 a rfl\n      \u00b7 rcases h\u2081 b rfl with \u27e8d, \u27e8\u27e9, h\u2081'\u27e9\n        simp at h\u2082\n        exact \u27e8d, rfl, sup_le h\u2081' h\u2082\u27e9 }\n\n/- warning: with_bot.coe_sup -> WithBot.coe_sup is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SemilatticeSup.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (WithBot.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) (Sup.sup.{u1} \u03b1 (SemilatticeSup.toHasSup.{u1} \u03b1 _inst_1) a b)) (Sup.sup.{u1} (WithBot.{u1} \u03b1) (SemilatticeSup.toHasSup.{u1} (WithBot.{u1} \u03b1) (WithBot.semilatticeSup.{u1} \u03b1 _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SemilatticeSup.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (WithBot.{u1} \u03b1) (WithBot.some.{u1} \u03b1 (Sup.sup.{u1} \u03b1 (SemilatticeSup.toSup.{u1} \u03b1 _inst_1) a b)) (Sup.sup.{u1} (WithBot.{u1} \u03b1) (SemilatticeSup.toSup.{u1} (WithBot.{u1} \u03b1) (WithBot.semilatticeSup.{u1} \u03b1 _inst_1)) (WithBot.some.{u1} \u03b1 a) (WithBot.some.{u1} \u03b1 b))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_sup WithBot.coe_sup\u2093'. -/\ntheorem coe_sup [SemilatticeSup \u03b1] (a b : \u03b1) : ((a \u2294 b : \u03b1) : WithBot \u03b1) = a \u2294 b :=\n  rfl\n#align with_bot.coe_sup WithBot.coe_sup\n\ninstance [SemilatticeInf \u03b1] : SemilatticeInf (WithBot \u03b1) :=\n  { WithBot.orderBot,\n    WithBot.partialOrder with\n    inf := Option.map\u2082 (\u00b7 \u2293 \u00b7)\n    inf_le_left := fun o\u2081 o\u2082 a ha =>\n      by\n      rcases Option.mem_map\u2082_iff.1 ha with \u27e8a, b, rfl : _ = _, rfl : _ = _, rfl\u27e9\n      exact \u27e8_, rfl, inf_le_left\u27e9\n    inf_le_right := fun o\u2081 o\u2082 a ha =>\n      by\n      rcases Option.mem_map\u2082_iff.1 ha with \u27e8a, b, rfl : _ = _, rfl : _ = _, rfl\u27e9\n      exact \u27e8_, rfl, inf_le_right\u27e9\n    le_inf := fun o\u2081 o\u2082 o\u2083 h\u2081 h\u2082 a ha => by\n      cases ha\n      rcases h\u2081 a rfl with \u27e8b, \u27e8\u27e9, ab\u27e9\n      rcases h\u2082 a rfl with \u27e8c, \u27e8\u27e9, ac\u27e9\n      exact \u27e8_, rfl, le_inf ab ac\u27e9 }\n\n/- warning: with_bot.coe_inf -> WithBot.coe_inf is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SemilatticeInf.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (WithBot.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) (Inf.inf.{u1} \u03b1 (SemilatticeInf.toHasInf.{u1} \u03b1 _inst_1) a b)) (Inf.inf.{u1} (WithBot.{u1} \u03b1) (SemilatticeInf.toHasInf.{u1} (WithBot.{u1} \u03b1) (WithBot.semilatticeInf.{u1} \u03b1 _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SemilatticeInf.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (WithBot.{u1} \u03b1) (WithBot.some.{u1} \u03b1 (Inf.inf.{u1} \u03b1 (SemilatticeInf.toInf.{u1} \u03b1 _inst_1) a b)) (Inf.inf.{u1} (WithBot.{u1} \u03b1) (SemilatticeInf.toInf.{u1} (WithBot.{u1} \u03b1) (WithBot.semilatticeInf.{u1} \u03b1 _inst_1)) (WithBot.some.{u1} \u03b1 a) (WithBot.some.{u1} \u03b1 b))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_inf WithBot.coe_inf\u2093'. -/\ntheorem coe_inf [SemilatticeInf \u03b1] (a b : \u03b1) : ((a \u2293 b : \u03b1) : WithBot \u03b1) = a \u2293 b :=\n  rfl\n#align with_bot.coe_inf WithBot.coe_inf\n\ninstance [Lattice \u03b1] : Lattice (WithBot \u03b1) :=\n  { WithBot.semilatticeSup, WithBot.semilatticeInf with }\n\ninstance [DistribLattice \u03b1] : DistribLattice (WithBot \u03b1) :=\n  { WithBot.lattice with\n    le_sup_inf := fun o\u2081 o\u2082 o\u2083 =>\n      match o\u2081, o\u2082, o\u2083 with\n      | \u22a5, \u22a5, \u22a5 => le_rfl\n      | \u22a5, \u22a5, (a\u2081 : \u03b1) => le_rfl\n      | \u22a5, (a\u2081 : \u03b1), \u22a5 => le_rfl\n      | \u22a5, (a\u2081 : \u03b1), (a\u2083 : \u03b1) => le_rfl\n      | (a\u2081 : \u03b1), \u22a5, \u22a5 => inf_le_left\n      | (a\u2081 : \u03b1), \u22a5, (a\u2083 : \u03b1) => inf_le_left\n      | (a\u2081 : \u03b1), (a\u2082 : \u03b1), \u22a5 => inf_le_right\n      | (a\u2081 : \u03b1), (a\u2082 : \u03b1), (a\u2083 : \u03b1) => 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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : DecidableRel.{succ u1} \u03b1 (LE.le.{u1} \u03b1 _inst_1)], DecidableRel.{succ u1} (WithBot.{u1} \u03b1) (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : DecidableRel.{succ u1} \u03b1 (fun (x._@.Mathlib.Order.WithBot._hyg.4186 : \u03b1) (x._@.Mathlib.Order.WithBot._hyg.4188 : \u03b1) => LE.le.{u1} \u03b1 _inst_1 x._@.Mathlib.Order.WithBot._hyg.4186 x._@.Mathlib.Order.WithBot._hyg.4188)], DecidableRel.{succ u1} (WithBot.{u1} \u03b1) (fun (x._@.Mathlib.Order.WithBot._hyg.4206 : WithBot.{u1} \u03b1) (x._@.Mathlib.Order.WithBot._hyg.4208 : WithBot.{u1} \u03b1) => LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _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\u2093'. -/\ninstance decidableLE [LE \u03b1] [@DecidableRel \u03b1 (\u00b7 \u2264 \u00b7)] : @DecidableRel (WithBot \u03b1) (\u00b7 \u2264 \u00b7)\n  | none, x => isTrue fun a h => Option.noConfusion h\n  | some x, some y => if h : x \u2264 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 \u27e8y, \u27e8_\u27e9, _\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] [_inst_2 : DecidableRel.{succ u1} \u03b1 (LT.lt.{u1} \u03b1 _inst_1)], DecidableRel.{succ u1} (WithBot.{u1} \u03b1) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] [_inst_2 : DecidableRel.{succ u1} \u03b1 (fun (x._@.Mathlib.Order.WithBot._hyg.4348 : \u03b1) (x._@.Mathlib.Order.WithBot._hyg.4350 : \u03b1) => LT.lt.{u1} \u03b1 _inst_1 x._@.Mathlib.Order.WithBot._hyg.4348 x._@.Mathlib.Order.WithBot._hyg.4350)], DecidableRel.{succ u1} (WithBot.{u1} \u03b1) (fun (x._@.Mathlib.Order.WithBot._hyg.4368 : WithBot.{u1} \u03b1) (x._@.Mathlib.Order.WithBot._hyg.4370 : WithBot.{u1} \u03b1) => LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _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\u2093'. -/\ninstance decidableLT [LT \u03b1] [@DecidableRel \u03b1 (\u00b7 < \u00b7)] : @DecidableRel (WithBot \u03b1) (\u00b7 < \u00b7)\n  | none, some x => isTrue <| by exists x, rfl <;> rintro _ \u27e8\u27e9\n  | some x, some y => if h : x < y then isTrue <| by simp [*] else isFalse <| by simp [*]\n  | x, none => isFalse <| by rintro \u27e8a, \u27e8\u27e8\u27e9\u27e9\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : IsTotal.{u1} \u03b1 (LE.le.{u1} \u03b1 _inst_1)], IsTotal.{u1} (WithBot.{u1} \u03b1) (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : IsTotal.{u1} \u03b1 (fun (x._@.Mathlib.Order.WithBot._hyg.4547 : \u03b1) (x._@.Mathlib.Order.WithBot._hyg.4549 : \u03b1) => LE.le.{u1} \u03b1 _inst_1 x._@.Mathlib.Order.WithBot._hyg.4547 x._@.Mathlib.Order.WithBot._hyg.4549)], IsTotal.{u1} (WithBot.{u1} \u03b1) (fun (x._@.Mathlib.Order.WithBot._hyg.4567 : WithBot.{u1} \u03b1) (x._@.Mathlib.Order.WithBot._hyg.4569 : WithBot.{u1} \u03b1) => LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _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\u2093'. -/\ninstance isTotal_le [LE \u03b1] [IsTotal \u03b1 (\u00b7 \u2264 \u00b7)] : IsTotal (WithBot \u03b1) (\u00b7 \u2264 \u00b7) :=\n  \u27e8fun 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 (\u00b7 \u2264 \u00b7) x y).imp some_le_some.2 some_le_some.2\u27e9\n#align with_bot.is_total_le WithBot.isTotal_le\n\ninstance [LinearOrder \u03b1] : LinearOrder (WithBot \u03b1) :=\n  Lattice.toLinearOrder _\n\n/- warning: with_bot.coe_min -> WithBot.coe_min is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (WithBot.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) (LinearOrder.min.{u1} \u03b1 _inst_1 x y)) (LinearOrder.min.{u1} (WithBot.{u1} \u03b1) (WithBot.linearOrder.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) y))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (WithBot.{u1} \u03b1) (WithBot.some.{u1} \u03b1 (Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_1) x y)) (Min.min.{u1} (WithBot.{u1} \u03b1) (LinearOrder.toMin.{u1} (WithBot.{u1} \u03b1) (WithBot.linearOrder.{u1} \u03b1 _inst_1)) (WithBot.some.{u1} \u03b1 x) (WithBot.some.{u1} \u03b1 y))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_min WithBot.coe_min\u2093'. -/\n-- this is not marked simp because the corresponding with_top lemmas are used\n@[norm_cast]\ntheorem coe_min [LinearOrder \u03b1] (x y : \u03b1) : ((min x y : \u03b1) : WithBot \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (WithBot.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) (LinearOrder.max.{u1} \u03b1 _inst_1 x y)) (LinearOrder.max.{u1} (WithBot.{u1} \u03b1) (WithBot.linearOrder.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) y))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (WithBot.{u1} \u03b1) (WithBot.some.{u1} \u03b1 (Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_1) x y)) (Max.max.{u1} (WithBot.{u1} \u03b1) (LinearOrder.toMax.{u1} (WithBot.{u1} \u03b1) (WithBot.linearOrder.{u1} \u03b1 _inst_1)) (WithBot.some.{u1} \u03b1 x) (WithBot.some.{u1} \u03b1 y))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_max WithBot.coe_max\u2093'. -/\n-- this is not marked simp because the corresponding with_top lemmas are used\n@[norm_cast]\ntheorem coe_max [LinearOrder \u03b1] (x y : \u03b1) : ((max x y : \u03b1) : WithBot \u03b1) = max x y :=\n  rfl\n#align with_bot.coe_max WithBot.coe_max\n\n#print WithBot.wellFounded_lt /-\ntheorem wellFounded_lt [Preorder \u03b1] (h : @WellFounded \u03b1 (\u00b7 < \u00b7)) :\n    @WellFounded (WithBot \u03b1) (\u00b7 < \u00b7) :=\n  have acc_bot : Acc ((\u00b7 < \u00b7) : WithBot \u03b1 \u2192 WithBot \u03b1 \u2192 Prop) \u22a5 :=\n    Acc.intro _ fun a ha => (not_le_of_gt ha bot_le).elim\n  \u27e8fun 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              \u2200 b : \u03b1,\n                (\u2200 c,\n                    c < b \u2192 (c : WithBot \u03b1) < a \u2192 Acc ((\u00b7 < \u00b7) : WithBot \u03b1 \u2192 WithBot \u03b1 \u2192 Prop) c) \u2192\n                  (b : WithBot \u03b1) < a \u2192 Acc ((\u00b7 < \u00b7) : WithBot \u03b1 \u2192 WithBot \u03b1 \u2192 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))\u27e9\n#align with_bot.well_founded_lt WithBot.wellFounded_lt\n-/\n\ninstance [LT \u03b1] [DenselyOrdered \u03b1] [NoMinOrder \u03b1] : DenselyOrdered (WithBot \u03b1) :=\n  \u27e8fun a b =>\n    match a, b with\n    | a, none => fun h : a < \u22a5 => (not_lt_none _ h).elim\n    | none, some b => fun h =>\n      let \u27e8a, ha\u27e9 := exists_lt b\n      \u27e8a, bot_lt_coe a, coe_lt_coe.2 ha\u27e9\n    | some a, some b => fun h =>\n      let \u27e8a, ha\u2081, ha\u2082\u27e9 := exists_between (coe_lt_coe.1 h)\n      \u27e8a, coe_lt_coe.2 ha\u2081, coe_lt_coe.2 ha\u2082\u27e9\u27e9\n\n#print WithBot.lt_iff_exists_coe_btwn /-\ntheorem lt_iff_exists_coe_btwn [Preorder \u03b1] [DenselyOrdered \u03b1] [NoMinOrder \u03b1] {a b : WithBot \u03b1} :\n    a < b \u2194 \u2203 x : \u03b1, a < \u2191x \u2227 \u2191x < b :=\n  \u27e8fun h =>\n    let \u27e8y, hy\u27e9 := exists_between h\n    let \u27e8x, hx\u27e9 := lt_iff_exists_coe.1 hy.1\n    \u27e8x, hx.1 \u25b8 hy\u27e9,\n    fun \u27e8x, hx\u27e9 => lt_trans hx.1 hx.2\u27e9\n#align with_bot.lt_iff_exists_coe_btwn WithBot.lt_iff_exists_coe_btwn\n-/\n\ninstance [LE \u03b1] [NoTopOrder \u03b1] [Nonempty \u03b1] : NoTopOrder (WithBot \u03b1) :=\n  \u27e8by\n    apply rec_bot_coe\n    \u00b7 exact \u2039Nonempty \u03b1\u203a.elim fun a => \u27e8a, not_coe_le_bot a\u27e9\n    \u00b7 intro a\n      obtain \u27e8b, h\u27e9 := exists_not_le a\n      exact \u27e8b, by rwa [coe_le_coe]\u27e9\u27e9\n\ninstance [LT \u03b1] [NoMaxOrder \u03b1] [Nonempty \u03b1] : NoMaxOrder (WithBot \u03b1) :=\n  \u27e8by\n    apply WithBot.recBotCoe\n    \u00b7 apply \u2039Nonempty \u03b1\u203a.elim\n      exact fun a => \u27e8a, WithBot.bot_lt_coe a\u27e9\n    \u00b7 intro a\n      obtain \u27e8b, ha\u27e9 := exists_gt a\n      exact \u27e8b, with_bot.coe_lt_coe.mpr ha\u27e9\u27e9\n\nend WithBot\n\n#print WithTop /-\n--TODO(Mario): Construct using order dual on with_bot\n/-- Attach `\u22a4` to a type. -/\ndef WithTop (\u03b1 : Type _) :=\n  Option \u03b1\n#align with_top WithTop\n-/\n\nnamespace WithTop\n\nvariable {a b : \u03b1}\n\nunsafe instance [has_to_format \u03b1] : has_to_format (WithTop \u03b1)\n    where to_format x :=\n    match x with\n    | none => \"\u22a4\"\n    | some x => to_fmt x\n\ninstance [Repr \u03b1] : Repr (WithTop \u03b1) :=\n  \u27e8fun o =>\n    match o with\n    | none => \"\u22a4\"\n    | some a => \"\u2191\" ++ repr a\u27e9\n\ninstance : CoeTC \u03b1 (WithTop \u03b1) :=\n  \u27e8some\u27e9\n\ninstance : Top (WithTop \u03b1) :=\n  \u27e8none\u27e9\n\nunsafe instance {\u03b1 : Type} [reflected _ \u03b1] [has_reflect \u03b1] : has_reflect (WithTop \u03b1)\n  | \u22a4 => q(\u22a4)\n  | (a : \u03b1) => q((coe : \u03b1 \u2192 WithTop \u03b1)).subst q(a)\n\ninstance : Inhabited (WithTop \u03b1) :=\n  \u27e8\u22a4\u27e9\n\ninstance [Nonempty \u03b1] : Nontrivial (WithTop \u03b1) :=\n  Option.nontrivial\n\n#print WithTop.forall /-\nprotected theorem forall {p : WithTop \u03b1 \u2192 Prop} : (\u2200 x, p x) \u2194 p \u22a4 \u2227 \u2200 x : \u03b1, p x :=\n  Option.forall\n#align with_top.forall WithTop.forall\n-/\n\n#print WithTop.exists /-\nprotected theorem exists {p : WithTop \u03b1 \u2192 Prop} : (\u2203 x, p x) \u2194 p \u22a4 \u2228 \u2203 x : \u03b1, 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 \u03b1) = (\u22a4 : WithTop \u03b1) :=\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 : \u03b1) : (some a : WithTop \u03b1) = (\u2191a : WithTop \u03b1) :=\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 : \u22a4 \u2260 (a : WithTop \u03b1) :=\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 \u03b1) \u2260 \u22a4 :=\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 `\u22a4` and `\u2191a`. -/\n@[elab_as_elim]\ndef recTopCoe {C : WithTop \u03b1 \u2192 Sort _} (h\u2081 : C \u22a4) (h\u2082 : \u2200 a : \u03b1, C a) : \u2200 n : WithTop \u03b1, C n :=\n  Option.rec h\u2081 h\u2082\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 {\u03b1 : Type.{u1}} {C : (WithTop.{u1} \u03b1) -> Sort.{u2}} (d : C (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (f : forall (a : \u03b1), C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a)), Eq.{u2} (C (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (WithTop.recTopCoe.{u1, u2} \u03b1 C d f (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) d\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {C : (WithTop.{u2} \u03b1) -> Sort.{u1}} (d : C (Top.top.{u2} (WithTop.{u2} \u03b1) (WithTop.top.{u2} \u03b1))) (f : forall (a : \u03b1), C (WithTop.some.{u2} \u03b1 a)), Eq.{u1} (C (Top.top.{u2} (WithTop.{u2} \u03b1) (WithTop.top.{u2} \u03b1))) (WithTop.recTopCoe.{u2, u1} \u03b1 C d f (Top.top.{u2} (WithTop.{u2} \u03b1) (WithTop.top.{u2} \u03b1))) d\nCase conversion may be inaccurate. Consider using '#align with_top.rec_top_coe_top WithTop.recTopCoe_top\u2093'. -/\n@[simp]\ntheorem recTopCoe_top {C : WithTop \u03b1 \u2192 Sort _} (d : C \u22a4) (f : \u2200 a : \u03b1, C a) :\n    @recTopCoe _ C d f \u22a4 = 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 {\u03b1 : Type.{u1}} {C : (WithTop.{u1} \u03b1) -> Sort.{u2}} (d : C (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (f : forall (a : \u03b1), C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a)) (x : \u03b1), Eq.{u2} (C ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) x)) (WithTop.recTopCoe.{u1, u2} \u03b1 C d f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) x)) (f x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {C : (WithTop.{u2} \u03b1) -> Sort.{u1}} (d : C (Top.top.{u2} (WithTop.{u2} \u03b1) (WithTop.top.{u2} \u03b1))) (f : forall (a : \u03b1), C (WithTop.some.{u2} \u03b1 a)) (x : \u03b1), Eq.{u1} (C (WithTop.some.{u2} \u03b1 x)) (WithTop.recTopCoe.{u2, u1} \u03b1 C d f (WithTop.some.{u2} \u03b1 x)) (f x)\nCase conversion may be inaccurate. Consider using '#align with_top.rec_top_coe_coe WithTop.recTopCoe_coe\u2093'. -/\n@[simp]\ntheorem recTopCoe_coe {C : WithTop \u03b1 \u2192 Sort _} (d : C \u22a4) (f : \u2200 a : \u03b1, C a) (x : \u03b1) :\n    @recTopCoe _ C d f \u2191x = 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 `\u22a4` to `\u22a5` and any `a : \u03b1` to `to_dual a : \u03b1\u1d52\u1d48`.\nSee `with_top.to_dual_bot_equiv` for the related order-iso.\n-/\nprotected def toDual : WithTop \u03b1 \u2243 WithBot \u03b1\u1d52\u1d48 :=\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 `\u22a4` to `\u22a5` and any `a : \u03b1\u1d52\u1d48` to `of_dual a : \u03b1`.\nSee `with_top.to_dual_bot_equiv` for the related order-iso.\n-/\nprotected def ofDual : WithTop \u03b1\u1d52\u1d48 \u2243 WithBot \u03b1 :=\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 `\u22a5` to `\u22a4` and any `a : \u03b1` to `to_dual a : \u03b1\u1d52\u1d48`.\nSee `with_bot.to_dual_top_equiv` for the related order-iso.\n-/\nprotected def WithBot.toDual : WithBot \u03b1 \u2243 WithTop \u03b1\u1d52\u1d48 :=\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 `\u22a5` to `\u22a4` and any `a : \u03b1\u1d52\u1d48` to `of_dual a : \u03b1`.\nSee `with_bot.to_dual_top_equiv` for the related order-iso.\n-/\nprotected def WithBot.ofDual : WithBot \u03b1\u1d52\u1d48 \u2243 WithTop \u03b1 :=\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 \u03b1\u1d52\u1d48) : 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 \u03b1) : 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 (\u22a4 : WithTop \u03b1) = \u22a5 :=\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 (\u22a4 : WithTop \u03b1) = \u22a5 :=\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 : \u03b1) : WithTop.toDual (a : WithTop \u03b1) = 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 : \u03b1\u1d52\u1d48) : WithTop.ofDual (a : WithTop \u03b1\u1d52\u1d48) = 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 \u03b1` that respects API boundaries.\n-/\ndef untop' (d : \u03b1) (x : WithTop \u03b1) : \u03b1 :=\n  recTopCoe d id x\n#align with_top.untop' WithTop.untop'\n-/\n\n#print WithTop.untop'_top /-\n@[simp]\ntheorem untop'_top {\u03b1} (d : \u03b1) : untop' d \u22a4 = d :=\n  rfl\n#align with_top.untop'_top WithTop.untop'_top\n-/\n\n#print WithTop.untop'_coe /-\n@[simp]\ntheorem untop'_coe {\u03b1} (d x : \u03b1) : 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 \u03b1) = b \u2194 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 : \u03b1} {x : WithTop \u03b1} : untop' d x = y \u2194 x = y \u2228 x = \u22a4 \u2227 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 : \u03b1} {x : WithTop \u03b1} : untop' d x = d \u2194 x = d \u2228 x = \u22a4 :=\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 : \u03b1} {x y : WithTop \u03b1} :\n    untop' d x = untop' d y \u2194 x = y \u2228 x = d \u2227 y = \u22a4 \u2228 x = \u22a4 \u2227 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 : \u03b1 \u2192 \u03b2` to `with_top \u03b1 \u2192 with_top \u03b2`. Implemented using `option.map`. -/\ndef map (f : \u03b1 \u2192 \u03b2) : WithTop \u03b1 \u2192 WithTop \u03b2 :=\n  Option.map f\n#align with_top.map WithTop.map\n-/\n\n#print WithTop.map_top /-\n@[simp]\ntheorem map_top (f : \u03b1 \u2192 \u03b2) : map f \u22a4 = \u22a4 :=\n  rfl\n#align with_top.map_top WithTop.map_top\n-/\n\n#print WithTop.map_coe /-\n@[simp]\ntheorem map_coe (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {f\u2081 : \u03b1 -> \u03b2} {f\u2082 : \u03b1 -> \u03b3} {g\u2081 : \u03b2 -> \u03b4} {g\u2082 : \u03b3 -> \u03b4}, (Eq.{max (succ u1) (succ u4)} (\u03b1 -> \u03b4) (Function.comp.{succ u1, succ u2, succ u4} \u03b1 \u03b2 \u03b4 g\u2081 f\u2081) (Function.comp.{succ u1, succ u3, succ u4} \u03b1 \u03b3 \u03b4 g\u2082 f\u2082)) -> (forall (a : \u03b1), Eq.{succ u4} (WithTop.{u4} \u03b4) (WithTop.map.{u2, u4} \u03b2 \u03b4 g\u2081 (WithTop.map.{u1, u2} \u03b1 \u03b2 f\u2081 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a))) (WithTop.map.{u3, u4} \u03b3 \u03b4 g\u2082 (WithTop.map.{u1, u3} \u03b1 \u03b3 f\u2082 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {\u03b4 : Type.{u3}} {f\u2081 : \u03b1 -> \u03b2} {f\u2082 : \u03b1 -> \u03b3} {g\u2081 : \u03b2 -> \u03b4} {g\u2082 : \u03b3 -> \u03b4}, (Eq.{max (succ u4) (succ u3)} (\u03b1 -> \u03b4) (Function.comp.{succ u4, succ u2, succ u3} \u03b1 \u03b2 \u03b4 g\u2081 f\u2081) (Function.comp.{succ u4, succ u1, succ u3} \u03b1 \u03b3 \u03b4 g\u2082 f\u2082)) -> (forall (a : \u03b1), Eq.{succ u3} (WithTop.{u3} \u03b4) (WithTop.map.{u2, u3} \u03b2 \u03b4 g\u2081 (WithTop.map.{u4, u2} \u03b1 \u03b2 f\u2081 (WithTop.some.{u4} \u03b1 a))) (WithTop.map.{u1, u3} \u03b3 \u03b4 g\u2082 (WithTop.map.{u4, u1} \u03b1 \u03b3 f\u2082 (WithTop.some.{u4} \u03b1 a))))\nCase conversion may be inaccurate. Consider using '#align with_top.map_comm WithTop.map_comm\u2093'. -/\ntheorem map_comm {f\u2081 : \u03b1 \u2192 \u03b2} {f\u2082 : \u03b1 \u2192 \u03b3} {g\u2081 : \u03b2 \u2192 \u03b4} {g\u2082 : \u03b3 \u2192 \u03b4} (h : g\u2081 \u2218 f\u2081 = g\u2082 \u2218 f\u2082)\n    (a : \u03b1) : map g\u2081 (map f\u2081 a) = map g\u2082 (map f\u2082 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : (OrderDual.{u1} \u03b1) -> (OrderDual.{u2} \u03b2)) (a : WithBot.{u1} \u03b1), Eq.{succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b2)) (WithTop.map.{u1, u2} (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a)) (WithBot.map.{u1, u2} \u03b1 (OrderDual.{u2} \u03b2) (Function.comp.{succ u1, succ u2, succ u2} \u03b1 \u03b2 (OrderDual.{u2} \u03b2) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) (fun (_x : Equiv.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) => \u03b2 -> (OrderDual.{u2} \u03b2)) (Equiv.hasCoeToFun.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) (OrderDual.toDual.{u2} \u03b2)) f) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : (OrderDual.{u2} \u03b1) -> (OrderDual.{u1} \u03b2)) (a : WithBot.{u2} \u03b1), Eq.{succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b2)) (WithTop.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} \u03b1) (WithTop.{u2} (OrderDual.{u2} \u03b1))) (WithBot.{u2} \u03b1) (fun (_x : WithBot.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u2} \u03b1) => WithTop.{u2} (OrderDual.{u2} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithBot.{u2} \u03b1) (WithTop.{u2} (OrderDual.{u2} \u03b1))) (WithBot.toDual.{u2} \u03b1) a)) (WithBot.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} (OrderDual.{u1} \u03b2)) (Function.comp.{succ u2, succ u1, succ u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) (OrderDual.{u1} (OrderDual.{u1} \u03b2)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) (OrderDual.{u1} (OrderDual.{u1} \u03b2))) (OrderDual.{u1} \u03b2) (fun (_x : OrderDual.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} \u03b2) => OrderDual.{u1} (OrderDual.{u1} \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) (OrderDual.{u1} (OrderDual.{u1} \u03b2))) (OrderDual.toDual.{u1} (OrderDual.{u1} \u03b2))) f) a)\nCase conversion may be inaccurate. Consider using '#align with_top.map_to_dual WithTop.map_toDual\u2093'. -/\ntheorem map_toDual (f : \u03b1\u1d52\u1d48 \u2192 \u03b2\u1d52\u1d48) (a : WithBot \u03b1) :\n    map f (WithBot.toDual a) = a.map (toDual \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) (a : WithBot.{u1} (OrderDual.{u1} \u03b1)), Eq.{succ u2} (WithTop.{u2} \u03b2) (WithTop.map.{u1, u2} \u03b1 \u03b2 f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a)) (WithBot.map.{u1, u2} (OrderDual.{u1} \u03b1) \u03b2 (Function.comp.{succ u1, succ u2, succ u2} (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) \u03b2 (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) (fun (_x : Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) => (OrderDual.{u2} \u03b2) -> \u03b2) (Equiv.hasCoeToFun.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) (OrderDual.ofDual.{u2} \u03b2)) f) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) (a : WithBot.{u2} (OrderDual.{u2} \u03b1)), Eq.{succ u1} (WithTop.{u1} \u03b2) (WithTop.map.{u2, u1} \u03b1 \u03b2 f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b1)) (WithTop.{u2} \u03b1)) (WithBot.{u2} (OrderDual.{u2} \u03b1)) (fun (_x : WithBot.{u2} (OrderDual.{u2} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u2} (OrderDual.{u2} \u03b1)) => WithTop.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b1)) (WithTop.{u2} \u03b1)) (WithBot.ofDual.{u2} \u03b1) a)) (WithBot.map.{u2, u1} \u03b1 \u03b2 (Function.comp.{succ u2, succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b2) \u03b2 (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) \u03b2) (OrderDual.{u1} \u03b2) (fun (_x : OrderDual.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) \u03b2) (OrderDual.ofDual.{u1} \u03b2)) f) a)\nCase conversion may be inaccurate. Consider using '#align with_top.map_of_dual WithTop.map_ofDual\u2093'. -/\ntheorem map_ofDual (f : \u03b1 \u2192 \u03b2) (a : WithBot \u03b1\u1d52\u1d48) : map f (WithBot.ofDual a) = a.map (ofDual \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) (a : WithTop.{u1} \u03b1), Eq.{succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b2)) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} \u03b2) (WithBot.{u2} (OrderDual.{u2} \u03b2))) (fun (_x : Equiv.{succ u2, succ u2} (WithTop.{u2} \u03b2) (WithBot.{u2} (OrderDual.{u2} \u03b2))) => (WithTop.{u2} \u03b2) -> (WithBot.{u2} (OrderDual.{u2} \u03b2))) (Equiv.hasCoeToFun.{succ u2, succ u2} (WithTop.{u2} \u03b2) (WithBot.{u2} (OrderDual.{u2} \u03b2))) (WithTop.toDual.{u2} \u03b2) (WithTop.map.{u1, u2} \u03b1 \u03b2 f a)) (WithBot.map.{u1, u2} (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) (Function.comp.{succ u1, succ u2, succ u2} (OrderDual.{u1} \u03b1) \u03b2 (OrderDual.{u2} \u03b2) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) (fun (_x : Equiv.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) => \u03b2 -> (OrderDual.{u2} \u03b2)) (Equiv.hasCoeToFun.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) (OrderDual.toDual.{u2} \u03b2)) (Function.comp.{succ u1, succ u1, succ u2} (OrderDual.{u1} \u03b1) \u03b1 \u03b2 f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b1) \u03b1) (fun (_x : Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b1) \u03b1) => (OrderDual.{u1} \u03b1) -> \u03b1) (Equiv.hasCoeToFun.{succ u1, succ u1} (OrderDual.{u1} \u03b1) \u03b1) (OrderDual.ofDual.{u1} \u03b1)))) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) (a : WithTop.{u2} \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b2) => WithBot.{u1} (OrderDual.{u1} \u03b2)) (WithTop.map.{u2, u1} \u03b1 \u03b2 f a)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b2) (WithBot.{u1} (OrderDual.{u1} \u03b2))) (WithTop.{u1} \u03b2) (fun (_x : WithTop.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b2) => WithBot.{u1} (OrderDual.{u1} \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b2) (WithBot.{u1} (OrderDual.{u1} \u03b2))) (WithTop.toDual.{u1} \u03b2) (WithTop.map.{u2, u1} \u03b1 \u03b2 f a)) (WithBot.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) (Function.comp.{succ u2, succ u1, succ u1} (OrderDual.{u2} \u03b1) \u03b2 (OrderDual.{u1} \u03b2) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} \u03b2 (OrderDual.{u1} \u03b2)) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => OrderDual.{u1} \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} \u03b2 (OrderDual.{u1} \u03b2)) (OrderDual.toDual.{u1} \u03b2)) (Function.comp.{succ u2, succ u2, succ u1} (OrderDual.{u2} \u03b1) \u03b1 \u03b2 f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b1) \u03b1) (OrderDual.{u2} \u03b1) (fun (_x : OrderDual.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u2} \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (OrderDual.{u2} \u03b1) \u03b1) (OrderDual.ofDual.{u2} \u03b1)))) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} \u03b1) (WithBot.{u2} (OrderDual.{u2} \u03b1))) (WithTop.{u2} \u03b1) (fun (_x : WithTop.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u2} \u03b1) => WithBot.{u2} (OrderDual.{u2} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithTop.{u2} \u03b1) (WithBot.{u2} (OrderDual.{u2} \u03b1))) (WithTop.toDual.{u2} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_top.to_dual_map WithTop.toDual_map\u2093'. -/\ntheorem toDual_map (f : \u03b1 \u2192 \u03b2) (a : WithTop \u03b1) :\n    WithTop.toDual (map f a) = WithBot.map (toDual \u2218 f \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : (OrderDual.{u1} \u03b1) -> (OrderDual.{u2} \u03b2)) (a : WithTop.{u1} (OrderDual.{u1} \u03b1)), Eq.{succ u2} (WithBot.{u2} \u03b2) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b2)) (WithBot.{u2} \u03b2)) (fun (_x : Equiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b2)) (WithBot.{u2} \u03b2)) => (WithTop.{u2} (OrderDual.{u2} \u03b2)) -> (WithBot.{u2} \u03b2)) (Equiv.hasCoeToFun.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b2)) (WithBot.{u2} \u03b2)) (WithTop.ofDual.{u2} \u03b2) (WithTop.map.{u1, u2} (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) f a)) (WithBot.map.{u1, u2} \u03b1 \u03b2 (Function.comp.{succ u1, succ u2, succ u2} \u03b1 (OrderDual.{u2} \u03b2) \u03b2 (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) (fun (_x : Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) => (OrderDual.{u2} \u03b2) -> \u03b2) (Equiv.hasCoeToFun.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) (OrderDual.ofDual.{u2} \u03b2)) (Function.comp.{succ u1, succ u1, succ u2} \u03b1 (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b1)) => \u03b1 -> (OrderDual.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b1)) (OrderDual.toDual.{u1} \u03b1)))) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : (OrderDual.{u2} \u03b1) -> (OrderDual.{u1} \u03b2)) (a : WithTop.{u2} (OrderDual.{u2} \u03b1)), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b2)) => WithBot.{u1} \u03b2) (WithTop.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) f a)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b2)) (WithBot.{u1} \u03b2)) (WithTop.{u1} (OrderDual.{u1} \u03b2)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b2)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b2)) => WithBot.{u1} \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b2)) (WithBot.{u1} \u03b2)) (WithTop.ofDual.{u1} \u03b2) (WithTop.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) f a)) (WithBot.map.{u2, u1} \u03b1 \u03b2 (Function.comp.{succ u2, succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b2) \u03b2 (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) \u03b2) (OrderDual.{u1} \u03b2) (fun (_x : OrderDual.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) \u03b2) (OrderDual.ofDual.{u1} \u03b2)) (Function.comp.{succ u2, succ u2, succ u1} \u03b1 (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} \u03b1 (OrderDual.{u2} \u03b1)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => OrderDual.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} \u03b1 (OrderDual.{u2} \u03b1)) (OrderDual.toDual.{u2} \u03b1)))) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b1)) (WithBot.{u2} \u03b1)) (WithTop.{u2} (OrderDual.{u2} \u03b1)) (fun (_x : WithTop.{u2} (OrderDual.{u2} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u2} (OrderDual.{u2} \u03b1)) => WithBot.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b1)) (WithBot.{u2} \u03b1)) (WithTop.ofDual.{u2} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_top.of_dual_map WithTop.ofDual_map\u2093'. -/\ntheorem ofDual_map (f : \u03b1\u1d52\u1d48 \u2192 \u03b2\u1d52\u1d48) (a : WithTop \u03b1\u1d52\u1d48) :\n    WithTop.ofDual (map f a) = WithBot.map (ofDual \u2218 f \u2218 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 \u03b1} : x \u2260 \u22a4 \u2194 \u2203 a : \u03b1, \u2191a = 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 \u03b1` to the underlying value in `\u03b1`, given a proof that `x \u2260 \u22a4`. -/\ndef untop : \u2200 x : WithTop \u03b1, x \u2260 \u22a4 \u2192 \u03b1 :=\n  WithBot.unbot\n#align with_top.untop WithTop.untop\n-/\n\n#print WithTop.coe_untop /-\n@[simp]\ntheorem coe_untop (x : WithTop \u03b1) (h : x \u2260 \u22a4) : (x.untop h : WithTop \u03b1) = 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 : \u03b1) (h : (x : WithTop \u03b1) \u2260 \u22a4 := coe_ne_top) : (x : WithTop \u03b1).untop h = x :=\n  rfl\n#align with_top.untop_coe WithTop.untop_coe\n-/\n\n#print WithTop.canLift /-\ninstance canLift : CanLift (WithTop \u03b1) \u03b1 coe fun r => r \u2260 \u22a4\n    where prf x h := \u27e8x.untop h, coe_untop _ _\u27e9\n#align with_top.can_lift WithTop.canLift\n-/\n\nsection LE\n\nvariable [LE \u03b1]\n\ninstance (priority := 10) : LE (WithTop \u03b1) :=\n  \u27e8fun o\u2081 o\u2082 : Option \u03b1 => \u2200 a \u2208 o\u2082, \u2203 b \u2208 o\u2081, b \u2264 a\u27e9\n\n#print WithTop.toDual_le_iff /-\ntheorem toDual_le_iff {a : WithTop \u03b1} {b : WithBot \u03b1\u1d52\u1d48} :\n    WithTop.toDual a \u2264 b \u2194 WithBot.ofDual b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.hasLe.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLe.{u1} \u03b1 _inst_1)) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b)) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.le.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLEOrderDual.{u1} \u03b1 _inst_1)) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.{u1} \u03b1) (fun (_x : WithTop.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b)) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_top.le_to_dual_iff WithTop.le_toDual_iff\u2093'. -/\ntheorem le_toDual_iff {a : WithBot \u03b1\u1d52\u1d48} {b : WithTop \u03b1} :\n    a \u2264 WithTop.toDual b \u2194 b \u2264 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 \u03b1} : WithTop.toDual a \u2264 WithTop.toDual b \u2194 b \u2264 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 \u03b1\u1d52\u1d48} {b : WithBot \u03b1} :\n    WithTop.ofDual a \u2264 b \u2194 WithBot.toDual b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b)) (LE.le.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.hasLe.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLe.{u1} \u03b1 _inst_1)) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_1) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b)) (LE.le.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.le.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLEOrderDual.{u1} \u03b1 _inst_1)) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.{u1} \u03b1) (fun (_x : WithBot.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_top.le_of_dual_iff WithTop.le_ofDual_iff\u2093'. -/\ntheorem le_ofDual_iff {a : WithBot \u03b1} {b : WithTop \u03b1\u1d52\u1d48} :\n    a \u2264 WithTop.ofDual b \u2194 b \u2264 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 \u03b1\u1d52\u1d48} : WithTop.ofDual a \u2264 WithTop.ofDual b \u2194 b \u2264 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 {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1], Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b)) (LE.le.{u1} \u03b1 _inst_1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1], Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) (WithTop.some.{u1} \u03b1 a) (WithTop.some.{u1} \u03b1 b)) (LE.le.{u1} \u03b1 _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_top.coe_le_coe WithTop.coe_le_coe\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_le_coe : (a : WithTop \u03b1) \u2264 b \u2194 a \u2264 b := by\n  simp only [\u2190 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 {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1], Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.some.{u1} \u03b1 b)) (LE.le.{u1} \u03b1 _inst_1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1], Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.some.{u1} \u03b1 b)) (LE.le.{u1} \u03b1 _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_top.some_le_some WithTop.some_le_some\u2093'. -/\n@[simp]\ntheorem some_le_some : @LE.le (WithTop \u03b1) _ (some a) (some b) \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithTop.{u1} \u03b1}, LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) a (Option.none.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithTop.{u1} \u03b1}, LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) a (Option.none.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align with_top.le_none WithTop.le_none\u2093'. -/\n@[simp]\ntheorem le_none {a : WithTop \u03b1} : @LE.le (WithTop \u03b1) _ a none :=\n  toDual_le_toDual_iff.mp WithBot.none_le\n#align with_top.le_none WithTop.le_none\n\ninstance : OrderTop (WithTop \u03b1) :=\n  { WithTop.hasTop with le_top := fun a => le_none }\n\ninstance [OrderBot \u03b1] : OrderBot (WithTop \u03b1)\n    where\n  bot := some \u22a5\n  bot_le o a ha := by cases ha <;> exact \u27e8_, rfl, bot_le\u27e9\n\ninstance [OrderBot \u03b1] : BoundedOrder (WithTop \u03b1) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] (a : \u03b1), Not (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] (a : \u03b1), Not (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)) (WithTop.some.{u1} \u03b1 a))\nCase conversion may be inaccurate. Consider using '#align with_top.not_top_le_coe WithTop.not_top_le_coe\u2093'. -/\ntheorem not_top_le_coe (a : \u03b1) : \u00ac(\u22a4 : WithTop \u03b1) \u2264 \u2191a :=\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 {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1] {o : Option.{u1} \u03b1}, (Membership.Mem.{u1, u1} \u03b1 (Option.{u1} \u03b1) (Option.hasMem.{u1} \u03b1) a o) -> (Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) o ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b)) (LE.le.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1] {o : Option.{u1} \u03b1}, (Membership.mem.{u1, u1} \u03b1 (Option.{u1} \u03b1) (Option.instMembershipOption.{u1} \u03b1) a o) -> (Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) o (WithTop.some.{u1} \u03b1 b)) (LE.le.{u1} \u03b1 _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align with_top.le_coe WithTop.le_coe\u2093'. -/\ntheorem le_coe : \u2200 {o : Option \u03b1}, a \u2208 o \u2192 (@LE.le (WithTop \u03b1) _ o b \u2194 a \u2264 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 {\u03b1 : Type.{u1}} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1] {x : WithTop.{u1} \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b)) (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => And (Eq.{succ u1} (WithTop.{u1} \u03b1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a)) (LE.le.{u1} \u03b1 _inst_1 a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {b : \u03b1} [_inst_1 : LE.{u1} \u03b1] {x : WithTop.{u1} \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) x (WithTop.some.{u1} \u03b1 b)) (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => And (Eq.{succ u1} (WithTop.{u1} \u03b1) x (WithTop.some.{u1} \u03b1 a)) (LE.le.{u1} \u03b1 _inst_1 a b)))\nCase conversion may be inaccurate. Consider using '#align with_top.le_coe_iff WithTop.le_coe_iff\u2093'. -/\ntheorem le_coe_iff {x : WithTop \u03b1} : x \u2264 b \u2194 \u2203 a : \u03b1, x = a \u2227 a \u2264 b := by\n  simpa [\u2190 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 {\u03b1 : Type.{u1}} {a : \u03b1} [_inst_1 : LE.{u1} \u03b1] {x : WithTop.{u1} \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) x) (forall (b : \u03b1), (Eq.{succ u1} (WithTop.{u1} \u03b1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b)) -> (LE.le.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} [_inst_1 : LE.{u1} \u03b1] {x : WithTop.{u1} \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) (WithTop.some.{u1} \u03b1 a) x) (forall (b : \u03b1), (Eq.{succ u1} (WithTop.{u1} \u03b1) x (WithTop.some.{u1} \u03b1 b)) -> (LE.le.{u1} \u03b1 _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_le_iff WithTop.coe_le_iff\u2093'. -/\ntheorem coe_le_iff {x : WithTop \u03b1} : \u2191a \u2264 x \u2194 \u2200 b, x = \u2191b \u2192 a \u2264 b :=\n  by\n  simp only [\u2190 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\u2082_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 {\u03b1 : Type.{u1}} {a : \u03b1} [_inst_1 : LE.{u1} \u03b1], (IsMin.{u1} \u03b1 _inst_1 a) -> (IsMin.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} [_inst_1 : LE.{u1} \u03b1], (IsMin.{u1} \u03b1 _inst_1 a) -> (IsMin.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_1) (WithTop.some.{u1} \u03b1 a))\nCase conversion may be inaccurate. Consider using '#align is_min.with_top IsMin.withTop\u2093'. -/\nprotected theorem IsMin.withTop (h : IsMin a) : IsMin (a : WithTop \u03b1) :=\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 [\u2190 to_dual_le_to_dual_iff] at hb\n  simpa [to_dual_le_iff] using (IsMax.withBot h : IsMax (to_dual a : WithBot \u03b1\u1d52\u1d48)) hb\n#align is_min.with_top IsMin.withTop\n\nend LE\n\nsection LT\n\nvariable [LT \u03b1]\n\ninstance (priority := 10) : LT (WithTop \u03b1) :=\n  \u27e8fun o\u2081 o\u2082 : Option \u03b1 => \u2203 b \u2208 o\u2081, \u2200 a \u2208 o\u2082, b < a\u27e9\n\n/- warning: with_top.to_dual_lt_iff -> WithTop.toDual_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithBot.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) a) b) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithBot.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) a) (WithBot.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.{u1} \u03b1) (fun (_x : WithTop.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) a) b) (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) b) (WithTop.lt.{u1} \u03b1 _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) b) a)\nCase conversion may be inaccurate. Consider using '#align with_top.to_dual_lt_iff WithTop.toDual_lt_iff\u2093'. -/\ntheorem toDual_lt_iff {a : WithTop \u03b1} {b : WithBot \u03b1\u1d52\u1d48} :\n    WithTop.toDual a < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.{u1} \u03b1) (fun (_x : WithTop.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_top.lt_to_dual_iff WithTop.lt_toDual_iff\u2093'. -/\ntheorem lt_toDual_iff {a : WithBot \u03b1\u1d52\u1d48} {b : WithTop \u03b1} :\n    a < WithTop.toDual b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) a) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) a) (WithBot.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.{u1} \u03b1) (fun (_x : WithTop.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.{u1} \u03b1) (fun (_x : WithTop.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem toDual_lt_toDual_iff {a b : WithTop \u03b1} : WithTop.toDual a < WithTop.toDual b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} (OrderDual.{u1} \u03b1)} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) a) b) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} (OrderDual.{u1} \u03b1)} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) a) (WithBot.lt.{u1} \u03b1 _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) a) b) (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) b) (WithTop.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.{u1} \u03b1) (fun (_x : WithBot.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) b) a)\nCase conversion may be inaccurate. Consider using '#align with_top.of_dual_lt_iff WithTop.ofDual_lt_iff\u2093'. -/\ntheorem ofDual_lt_iff {a : WithTop \u03b1\u1d52\u1d48} {b : WithBot \u03b1} :\n    WithTop.ofDual a < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.{u1} \u03b1) (fun (_x : WithBot.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_top.lt_of_dual_iff WithTop.lt_ofDual_iff\u2093'. -/\ntheorem lt_ofDual_iff {a : WithBot \u03b1} {b : WithTop \u03b1\u1d52\u1d48} :\n    a < WithTop.ofDual b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) a) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) a) (WithBot.lt.{u1} \u03b1 _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem ofDual_lt_ofDual_iff {a b : WithTop \u03b1\u1d52\u1d48} : WithTop.ofDual a < WithTop.ofDual b \u2194 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 \u03b1\u1d52\u1d48) : 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 \u03b1) : 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 (\u22a5 : WithBot \u03b1) = \u22a4 :=\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 (\u22a5 : WithBot \u03b1) = \u22a4 :=\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 : \u03b1) : WithBot.toDual (a : WithBot \u03b1) = 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 : \u03b1\u1d52\u1d48) : WithBot.ofDual (a : WithBot \u03b1\u1d52\u1d48) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : (OrderDual.{u1} \u03b1) -> (OrderDual.{u2} \u03b2)) (a : WithTop.{u1} \u03b1), Eq.{succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b2)) (WithBot.map.{u1, u2} (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) a)) (WithTop.map.{u1, u2} \u03b1 (OrderDual.{u2} \u03b2) (Function.comp.{succ u1, succ u2, succ u2} \u03b1 \u03b2 (OrderDual.{u2} \u03b2) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) (fun (_x : Equiv.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) => \u03b2 -> (OrderDual.{u2} \u03b2)) (Equiv.hasCoeToFun.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) (OrderDual.toDual.{u2} \u03b2)) f) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : (OrderDual.{u2} \u03b1) -> (OrderDual.{u1} \u03b2)) (a : WithTop.{u2} \u03b1), Eq.{succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b2)) (WithBot.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} \u03b1) (WithBot.{u2} (OrderDual.{u2} \u03b1))) (WithTop.{u2} \u03b1) (fun (_x : WithTop.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u2} \u03b1) => WithBot.{u2} (OrderDual.{u2} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithTop.{u2} \u03b1) (WithBot.{u2} (OrderDual.{u2} \u03b1))) (WithTop.toDual.{u2} \u03b1) a)) (WithTop.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} (OrderDual.{u1} \u03b2)) (Function.comp.{succ u2, succ u1, succ u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) (OrderDual.{u1} (OrderDual.{u1} \u03b2)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) (OrderDual.{u1} (OrderDual.{u1} \u03b2))) (OrderDual.{u1} \u03b2) (fun (_x : OrderDual.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} \u03b2) => OrderDual.{u1} (OrderDual.{u1} \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) (OrderDual.{u1} (OrderDual.{u1} \u03b2))) (OrderDual.toDual.{u1} (OrderDual.{u1} \u03b2))) f) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.map_to_dual WithBot.map_toDual\u2093'. -/\ntheorem map_toDual (f : \u03b1\u1d52\u1d48 \u2192 \u03b2\u1d52\u1d48) (a : WithTop \u03b1) :\n    WithBot.map f (WithTop.toDual a) = a.map (toDual \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) (a : WithTop.{u1} (OrderDual.{u1} \u03b1)), Eq.{succ u2} (WithBot.{u2} \u03b2) (WithBot.map.{u1, u2} \u03b1 \u03b2 f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) a)) (WithTop.map.{u1, u2} (OrderDual.{u1} \u03b1) \u03b2 (Function.comp.{succ u1, succ u2, succ u2} (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) \u03b2 (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) (fun (_x : Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) => (OrderDual.{u2} \u03b2) -> \u03b2) (Equiv.hasCoeToFun.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) (OrderDual.ofDual.{u2} \u03b2)) f) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) (a : WithTop.{u2} (OrderDual.{u2} \u03b1)), Eq.{succ u1} (WithBot.{u1} \u03b2) (WithBot.map.{u2, u1} \u03b1 \u03b2 f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b1)) (WithBot.{u2} \u03b1)) (WithTop.{u2} (OrderDual.{u2} \u03b1)) (fun (_x : WithTop.{u2} (OrderDual.{u2} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u2} (OrderDual.{u2} \u03b1)) => WithBot.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b1)) (WithBot.{u2} \u03b1)) (WithTop.ofDual.{u2} \u03b1) a)) (WithTop.map.{u2, u1} \u03b1 \u03b2 (Function.comp.{succ u2, succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b2) \u03b2 (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) \u03b2) (OrderDual.{u1} \u03b2) (fun (_x : OrderDual.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) \u03b2) (OrderDual.ofDual.{u1} \u03b2)) f) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.map_of_dual WithBot.map_ofDual\u2093'. -/\ntheorem map_ofDual (f : \u03b1 \u2192 \u03b2) (a : WithTop \u03b1\u1d52\u1d48) :\n    WithBot.map f (WithTop.ofDual a) = a.map (ofDual \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) (a : WithBot.{u1} \u03b1), Eq.{succ u2} (WithTop.{u2} (OrderDual.{u2} \u03b2)) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} \u03b2) (WithTop.{u2} (OrderDual.{u2} \u03b2))) (fun (_x : Equiv.{succ u2, succ u2} (WithBot.{u2} \u03b2) (WithTop.{u2} (OrderDual.{u2} \u03b2))) => (WithBot.{u2} \u03b2) -> (WithTop.{u2} (OrderDual.{u2} \u03b2))) (Equiv.hasCoeToFun.{succ u2, succ u2} (WithBot.{u2} \u03b2) (WithTop.{u2} (OrderDual.{u2} \u03b2))) (WithBot.toDual.{u2} \u03b2) (WithBot.map.{u1, u2} \u03b1 \u03b2 f a)) (WithBot.map.{u1, u2} (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) (Function.comp.{succ u1, succ u2, succ u2} (OrderDual.{u1} \u03b1) \u03b2 (OrderDual.{u2} \u03b2) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) (fun (_x : Equiv.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) => \u03b2 -> (OrderDual.{u2} \u03b2)) (Equiv.hasCoeToFun.{succ u2, succ u2} \u03b2 (OrderDual.{u2} \u03b2)) (OrderDual.toDual.{u2} \u03b2)) (Function.comp.{succ u1, succ u1, succ u2} (OrderDual.{u1} \u03b1) \u03b1 \u03b2 f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b1) \u03b1) (fun (_x : Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b1) \u03b1) => (OrderDual.{u1} \u03b1) -> \u03b1) (Equiv.hasCoeToFun.{succ u1, succ u1} (OrderDual.{u1} \u03b1) \u03b1) (OrderDual.ofDual.{u1} \u03b1)))) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) (a : WithBot.{u2} \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b2) => WithTop.{u1} (OrderDual.{u1} \u03b2)) (WithBot.map.{u2, u1} \u03b1 \u03b2 f a)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b2) (WithTop.{u1} (OrderDual.{u1} \u03b2))) (WithBot.{u1} \u03b2) (fun (_x : WithBot.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b2) => WithTop.{u1} (OrderDual.{u1} \u03b2)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b2) (WithTop.{u1} (OrderDual.{u1} \u03b2))) (WithBot.toDual.{u1} \u03b2) (WithBot.map.{u2, u1} \u03b1 \u03b2 f a)) (WithBot.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) (Function.comp.{succ u2, succ u1, succ u1} (OrderDual.{u2} \u03b1) \u03b2 (OrderDual.{u1} \u03b2) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} \u03b2 (OrderDual.{u1} \u03b2)) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => OrderDual.{u1} \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} \u03b2 (OrderDual.{u1} \u03b2)) (OrderDual.toDual.{u1} \u03b2)) (Function.comp.{succ u2, succ u2, succ u1} (OrderDual.{u2} \u03b1) \u03b1 \u03b2 f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b1) \u03b1) (OrderDual.{u2} \u03b1) (fun (_x : OrderDual.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u2} \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (OrderDual.{u2} \u03b1) \u03b1) (OrderDual.ofDual.{u2} \u03b1)))) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} \u03b1) (WithTop.{u2} (OrderDual.{u2} \u03b1))) (WithBot.{u2} \u03b1) (fun (_x : WithBot.{u2} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u2} \u03b1) => WithTop.{u2} (OrderDual.{u2} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithBot.{u2} \u03b1) (WithTop.{u2} (OrderDual.{u2} \u03b1))) (WithBot.toDual.{u2} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_bot.to_dual_map WithBot.toDual_map\u2093'. -/\ntheorem toDual_map (f : \u03b1 \u2192 \u03b2) (a : WithBot \u03b1) :\n    WithBot.toDual (WithBot.map f a) = map (toDual \u2218 f \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : (OrderDual.{u1} \u03b1) -> (OrderDual.{u2} \u03b2)) (a : WithBot.{u1} (OrderDual.{u1} \u03b1)), Eq.{succ u2} (WithTop.{u2} \u03b2) (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b2)) (WithTop.{u2} \u03b2)) (fun (_x : Equiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b2)) (WithTop.{u2} \u03b2)) => (WithBot.{u2} (OrderDual.{u2} \u03b2)) -> (WithTop.{u2} \u03b2)) (Equiv.hasCoeToFun.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b2)) (WithTop.{u2} \u03b2)) (WithBot.ofDual.{u2} \u03b2) (WithBot.map.{u1, u2} (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) f a)) (WithBot.map.{u1, u2} \u03b1 \u03b2 (Function.comp.{succ u1, succ u2, succ u2} \u03b1 (OrderDual.{u2} \u03b2) \u03b2 (coeFn.{succ u2, succ u2} (Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) (fun (_x : Equiv.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) => (OrderDual.{u2} \u03b2) -> \u03b2) (Equiv.hasCoeToFun.{succ u2, succ u2} (OrderDual.{u2} \u03b2) \u03b2) (OrderDual.ofDual.{u2} \u03b2)) (Function.comp.{succ u1, succ u1, succ u2} \u03b1 (OrderDual.{u1} \u03b1) (OrderDual.{u2} \u03b2) f (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b1)) => \u03b1 -> (OrderDual.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b1)) (OrderDual.toDual.{u1} \u03b1)))) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : (OrderDual.{u2} \u03b1) -> (OrderDual.{u1} \u03b2)) (a : WithBot.{u2} (OrderDual.{u2} \u03b1)), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b2)) => WithTop.{u1} \u03b2) (WithBot.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) f a)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b2)) (WithTop.{u1} \u03b2)) (WithBot.{u1} (OrderDual.{u1} \u03b2)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b2)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b2)) => WithTop.{u1} \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b2)) (WithTop.{u1} \u03b2)) (WithBot.ofDual.{u1} \u03b2) (WithBot.map.{u2, u1} (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) f a)) (WithBot.map.{u2, u1} \u03b1 \u03b2 (Function.comp.{succ u2, succ u1, succ u1} \u03b1 (OrderDual.{u1} \u03b2) \u03b2 (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) \u03b2) (OrderDual.{u1} \u03b2) (fun (_x : OrderDual.{u1} \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : OrderDual.{u1} \u03b2) => \u03b2) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (OrderDual.{u1} \u03b2) \u03b2) (OrderDual.ofDual.{u1} \u03b2)) (Function.comp.{succ u2, succ u2, succ u1} \u03b1 (OrderDual.{u2} \u03b1) (OrderDual.{u1} \u03b2) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} \u03b1 (OrderDual.{u2} \u03b1)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => OrderDual.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} \u03b1 (OrderDual.{u2} \u03b1)) (OrderDual.toDual.{u2} \u03b1)))) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b1)) (WithTop.{u2} \u03b1)) (WithBot.{u2} (OrderDual.{u2} \u03b1)) (fun (_x : WithBot.{u2} (OrderDual.{u2} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u2} (OrderDual.{u2} \u03b1)) => WithTop.{u2} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} (WithBot.{u2} (OrderDual.{u2} \u03b1)) (WithTop.{u2} \u03b1)) (WithBot.ofDual.{u2} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_bot.of_dual_map WithBot.ofDual_map\u2093'. -/\ntheorem ofDual_map (f : \u03b1\u1d52\u1d48 \u2192 \u03b2\u1d52\u1d48) (a : WithBot \u03b1\u1d52\u1d48) :\n    WithBot.ofDual (WithBot.map f a) = map (ofDual \u2218 f \u2218 toDual) a.ofDual :=\n  rfl\n#align with_bot.of_dual_map WithBot.ofDual_map\n\nsection LE\n\nvariable [LE \u03b1] {a b : \u03b1}\n\n/- warning: with_bot.to_dual_le_iff -> WithBot.toDual_le_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LE.le.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.hasLe.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLe.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a) b) (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LE.le.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) a) (WithTop.le.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLEOrderDual.{u1} \u03b1 _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.{u1} \u03b1) (fun (_x : WithBot.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a) b) (LE.le.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) b) (WithBot.le.{u1} \u03b1 _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.to_dual_le_iff WithBot.toDual_le_iff\u2093'. -/\ntheorem toDual_le_iff {a : WithBot \u03b1} {b : WithTop \u03b1\u1d52\u1d48} :\n    WithBot.toDual a \u2264 b \u2194 WithTop.ofDual b \u2264 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 \u03b1\u1d52\u1d48} {b : WithBot \u03b1} :\n    a \u2264 WithBot.toDual b \u2194 b \u2264 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 \u03b1} : WithBot.toDual a \u2264 WithBot.toDual b \u2194 b \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a) b) (LE.le.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.hasLe.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLe.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} \u03b1}, Iff (LE.le.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) a) (WithTop.le.{u1} \u03b1 _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a) b) (LE.le.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) b) (WithBot.le.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLEOrderDual.{u1} \u03b1 _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.{u1} \u03b1) (fun (_x : WithTop.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.of_dual_le_iff WithBot.ofDual_le_iff\u2093'. -/\ntheorem ofDual_le_iff {a : WithBot \u03b1\u1d52\u1d48} {b : WithTop \u03b1} :\n    WithBot.ofDual a \u2264 b \u2194 WithTop.toDual b \u2264 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 \u03b1} {b : WithBot \u03b1\u1d52\u1d48} :\n    a \u2264 WithBot.ofDual b \u2194 b \u2264 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 \u03b1\u1d52\u1d48} : WithBot.ofDual a \u2264 WithBot.ofDual b \u2194 b \u2264 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 \u03b1] {a b : \u03b1}\n\n/- warning: with_bot.to_dual_lt_iff -> WithBot.toDual_lt_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a) b) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithTop.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) a) (WithTop.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.{u1} \u03b1) (fun (_x : WithBot.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a) b) (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) b) (WithBot.lt.{u1} \u03b1 _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) b) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.to_dual_lt_iff WithBot.toDual_lt_iff\u2093'. -/\ntheorem toDual_lt_iff {a : WithBot \u03b1} {b : WithTop \u03b1\u1d52\u1d48} :\n    WithBot.toDual a < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} (OrderDual.{u1} \u03b1)} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) => (WithTop.{u1} (OrderDual.{u1} \u03b1)) -> (WithBot.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} (OrderDual.{u1} \u03b1)} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.{u1} \u03b1) (fun (_x : WithBot.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_1) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithTop.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} (OrderDual.{u1} \u03b1)) => WithBot.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithBot.{u1} \u03b1)) (WithTop.ofDual.{u1} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_bot.lt_to_dual_iff WithBot.lt_toDual_iff\u2093'. -/\ntheorem lt_toDual_iff {a : WithTop \u03b1\u1d52\u1d48} {b : WithBot \u03b1} :\n    a < WithBot.toDual b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} (OrderDual.{u1} \u03b1)) (WithTop.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) => (WithBot.{u1} \u03b1) -> (WithTop.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_1) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) a) (WithTop.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.{u1} \u03b1) (fun (_x : WithBot.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.{u1} \u03b1) (fun (_x : WithBot.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} \u03b1) => WithTop.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} \u03b1) (WithTop.{u1} (OrderDual.{u1} \u03b1))) (WithBot.toDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem toDual_lt_toDual_iff {a b : WithBot \u03b1} : WithBot.toDual a < WithBot.toDual b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a) b) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) a) (WithTop.lt.{u1} \u03b1 _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a) b) (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) b) (WithBot.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.{u1} \u03b1) (fun (_x : WithTop.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) b) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.of_dual_lt_iff WithBot.ofDual_lt_iff\u2093'. -/\ntheorem ofDual_lt_iff {a : WithBot \u03b1\u1d52\u1d48} {b : WithTop \u03b1} :\n    WithBot.ofDual a < b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithBot.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) a (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) b (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (fun (_x : Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) => (WithTop.{u1} \u03b1) -> (WithBot.{u1} (OrderDual.{u1} \u03b1))) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithBot.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) a (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _inst_1)) b (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.{u1} \u03b1) (fun (_x : WithTop.{u1} \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithTop.{u1} \u03b1) => WithBot.{u1} (OrderDual.{u1} \u03b1)) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithTop.{u1} \u03b1) (WithBot.{u1} (OrderDual.{u1} \u03b1))) (WithTop.toDual.{u1} \u03b1) a))\nCase conversion may be inaccurate. Consider using '#align with_bot.lt_of_dual_iff WithBot.lt_ofDual_iff\u2093'. -/\ntheorem lt_ofDual_iff {a : WithTop \u03b1} {b : WithBot \u03b1\u1d52\u1d48} :\n    a < WithBot.ofDual b \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithBot.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a) (coeFn.{succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (fun (_x : Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) => (WithBot.{u1} (OrderDual.{u1} \u03b1)) -> (WithTop.{u1} \u03b1)) (Equiv.hasCoeToFun.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.hasLt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.hasLt.{u1} \u03b1 _inst_1)) b a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithBot.{u1} (OrderDual.{u1} \u03b1)} {b : WithBot.{u1} (OrderDual.{u1} \u03b1)}, Iff (LT.lt.{u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) a) (WithTop.lt.{u1} \u03b1 _inst_1) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.{u1} (OrderDual.{u1} \u03b1)) (fun (_x : WithBot.{u1} (OrderDual.{u1} \u03b1)) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : WithBot.{u1} (OrderDual.{u1} \u03b1)) => WithTop.{u1} \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithTop.{u1} \u03b1)) (WithBot.ofDual.{u1} \u03b1) b)) (LT.lt.{u1} (WithBot.{u1} (OrderDual.{u1} \u03b1)) (WithBot.lt.{u1} (OrderDual.{u1} \u03b1) (OrderDual.instLTOrderDual.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem ofDual_lt_ofDual_iff {a b : WithBot \u03b1\u1d52\u1d48} : WithBot.ofDual a < WithBot.ofDual b \u2194 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 \u03b1] {a b : \u03b1}\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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b)) (LT.lt.{u1} \u03b1 _inst_1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) (WithTop.some.{u1} \u03b1 a) (WithTop.some.{u1} \u03b1 b)) (LT.lt.{u1} \u03b1 _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_top.coe_lt_coe WithTop.coe_lt_coe\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_lt_coe : (a : WithTop \u03b1) < b \u2194 a < b := by\n  simp only [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.some.{u1} \u03b1 b)) (LT.lt.{u1} \u03b1 _inst_1 a b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.some.{u1} \u03b1 b)) (LT.lt.{u1} \u03b1 _inst_1 a b)\nCase conversion may be inaccurate. Consider using '#align with_top.some_lt_some WithTop.some_lt_some\u2093'. -/\n@[simp]\ntheorem some_lt_some : @LT.lt (WithTop \u03b1) _ (some a) (some b) \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : \u03b1), LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : \u03b1), LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) (WithTop.some.{u1} \u03b1 a) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_lt_top WithTop.coe_lt_top\u2093'. -/\ntheorem coe_lt_top (a : \u03b1) : (a : WithTop \u03b1) < \u22a4 := by\n  simpa [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : \u03b1), LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.none.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : \u03b1), LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) (Option.some.{u1} \u03b1 a) (Option.none.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align with_top.some_lt_none WithTop.some_lt_none\u2093'. -/\n@[simp]\ntheorem some_lt_none (a : \u03b1) : @LT.lt (WithTop \u03b1) _ (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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : WithTop.{u1} \u03b1), Not (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) (Option.none.{u1} \u03b1) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] (a : WithTop.{u1} \u03b1), Not (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) (Option.none.{u1} \u03b1) a)\nCase conversion may be inaccurate. Consider using '#align with_top.not_none_lt WithTop.not_none_lt\u2093'. -/\n@[simp]\ntheorem not_none_lt (a : WithTop \u03b1) : \u00ac@LT.lt (WithTop \u03b1) _ none a :=\n  by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) a b) (Exists.{succ u1} \u03b1 (fun (p : \u03b1) => And (Eq.{succ u1} (WithTop.{u1} \u03b1) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) p)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) p) b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) a b) (Exists.{succ u1} \u03b1 (fun (p : \u03b1) => And (Eq.{succ u1} (WithTop.{u1} \u03b1) a (WithTop.some.{u1} \u03b1 p)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) (WithTop.some.{u1} \u03b1 p) b)))\nCase conversion may be inaccurate. Consider using '#align with_top.lt_iff_exists_coe WithTop.lt_iff_exists_coe\u2093'. -/\ntheorem lt_iff_exists_coe {a b : WithTop \u03b1} : a < b \u2194 \u2203 p : \u03b1, a = p \u2227 \u2191p < b :=\n  by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : \u03b1} {x : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) x) (forall (b : \u03b1), (Eq.{succ u1} (WithTop.{u1} \u03b1) x ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b)) -> (LT.lt.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {a : \u03b1} {x : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) (WithTop.some.{u1} \u03b1 a) x) (forall (b : WithTop.{u1} \u03b1), (Eq.{succ u1} (WithTop.{u1} \u03b1) x b) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) (WithTop.some.{u1} \u03b1 a) b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_lt_iff WithTop.coe_lt_iff\u2093'. -/\ntheorem coe_lt_iff {x : WithTop \u03b1} : \u2191a < x \u2194 \u2200 b, x = \u2191b \u2192 a < b :=\n  by\n  simp only [\u2190 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\u2082_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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {x : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1) x (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (Ne.{succ u1} (WithTop.{u1} \u03b1) x (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] {x : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_1) x (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) (Ne.{succ u1} (WithTop.{u1} \u03b1) x (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align with_top.lt_top_iff_ne_top WithTop.lt_top_iff_ne_top\u2093'. -/\n/-- A version of `lt_top_iff_ne_top` for `with_top` that only requires `has_lt \u03b1`, not\n`partial_order \u03b1`. -/\nprotected theorem lt_top_iff_ne_top {x : WithTop \u03b1} : x < \u22a4 \u2194 x \u2260 \u22a4 :=\n  @WithBot.bot_lt_iff_ne_bot \u03b1\u1d52\u1d48 _ x\n#align with_top.lt_top_iff_ne_top WithTop.lt_top_iff_ne_top\n\nend LT\n\ninstance [Preorder \u03b1] : Preorder (WithTop \u03b1)\n    where\n  le := (\u00b7 \u2264 \u00b7)\n  lt := (\u00b7 < \u00b7)\n  lt_iff_le_not_le := by simp [\u2190 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 [\u2190 to_dual_le_to_dual_iff]\n    exact Function.swap le_trans\n\ninstance [PartialOrder \u03b1] : PartialOrder (WithTop \u03b1) :=\n  { WithTop.preorder with\n    le_antisymm := fun _ _ => by\n      simp_rw [\u2190 to_dual_le_to_dual_iff]\n      exact Function.swap le_antisymm }\n\n#print WithTop.coe_strictMono /-\ntheorem coe_strictMono [Preorder \u03b1] : StrictMono (coe : \u03b1 \u2192 WithTop \u03b1) := 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 \u03b1] : Monotone (coe : \u03b1 \u2192 WithTop \u03b1) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : (WithTop.{u1} \u03b1) -> \u03b2}, Iff (Monotone.{u1, u2} (WithTop.{u1} \u03b1) \u03b2 (WithTop.preorder.{u1} \u03b1 _inst_1) _inst_2 f) (And (Monotone.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 (Function.comp.{succ u1, succ u1, succ u2} \u03b1 (WithTop.{u1} \u03b1) \u03b2 f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1)))))) (forall (x : \u03b1), LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) (f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) x)) (f (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : (WithTop.{u2} \u03b1) -> \u03b2}, Iff (Monotone.{u2, u1} (WithTop.{u2} \u03b1) \u03b2 (WithTop.preorder.{u2} \u03b1 _inst_1) _inst_2 f) (And (Monotone.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) => f (WithTop.some.{u2} \u03b1 a))) (forall (x : \u03b1), LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _inst_2) (f (WithTop.some.{u2} \u03b1 x)) (f (Top.top.{u2} (WithTop.{u2} \u03b1) (WithTop.top.{u2} \u03b1)))))\nCase conversion may be inaccurate. Consider using '#align with_top.monotone_iff WithTop.monotone_iff\u2093'. -/\ntheorem monotone_iff [Preorder \u03b1] [Preorder \u03b2] {f : WithTop \u03b1 \u2192 \u03b2} :\n    Monotone f \u2194 Monotone (f \u2218 coe : \u03b1 \u2192 \u03b2) \u2227 \u2200 x : \u03b1, f x \u2264 f \u22a4 :=\n  \u27e8fun h => \u27e8h.comp WithTop.coe_mono, fun x => h le_top\u27e9, fun h =>\n    WithTop.forall.2\n      \u27e8WithTop.forall.2 \u27e8fun _ => le_rfl, fun x h => (not_top_le_coe _ h).elim\u27e9, fun x =>\n        WithTop.forall.2 \u27e8fun _ => h.2 x, fun y hle => h.1 (coe_le_coe.1 hle)\u27e9\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, Iff (Monotone.{u1, u2} (WithTop.{u1} \u03b1) (WithTop.{u2} \u03b2) (WithTop.preorder.{u1} \u03b1 _inst_1) (WithTop.preorder.{u2} \u03b2 _inst_2) (WithTop.map.{u1, u2} \u03b1 \u03b2 f)) (Monotone.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, Iff (Monotone.{u2, u1} (WithTop.{u2} \u03b1) (WithTop.{u1} \u03b2) (WithTop.preorder.{u2} \u03b1 _inst_1) (WithTop.preorder.{u1} \u03b2 _inst_2) (WithTop.map.{u2, u1} \u03b1 \u03b2 f)) (Monotone.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align with_top.monotone_map_iff WithTop.monotone_map_iff\u2093'. -/\n@[simp]\ntheorem monotone_map_iff [Preorder \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    Monotone (WithTop.map f) \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Monotone.{u1, u2} (WithTop.{u1} \u03b1) (WithTop.{u2} \u03b2) (WithTop.preorder.{u1} \u03b1 _inst_1) (WithTop.preorder.{u2} \u03b2 _inst_2) (WithTop.map.{u1, u2} \u03b1 \u03b2 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (Monotone.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (Monotone.{u2, u1} (WithTop.{u2} \u03b1) (WithTop.{u1} \u03b2) (WithTop.preorder.{u2} \u03b1 _inst_1) (WithTop.preorder.{u1} \u03b2 _inst_2) (WithTop.map.{u2, u1} \u03b1 \u03b2 f))\nCase conversion may be inaccurate. Consider using '#align monotone.with_top_map Monotone.withTop_map\u2093'. -/\nalias monotone_map_iff \u2194 _ _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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : (WithTop.{u1} \u03b1) -> \u03b2}, Iff (StrictMono.{u1, u2} (WithTop.{u1} \u03b1) \u03b2 (WithTop.preorder.{u1} \u03b1 _inst_1) _inst_2 f) (And (StrictMono.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 (Function.comp.{succ u1, succ u1, succ u2} \u03b1 (WithTop.{u1} \u03b1) \u03b2 f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1)))))) (forall (x : \u03b1), LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 _inst_2) (f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) x)) (f (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : (WithTop.{u2} \u03b1) -> \u03b2}, Iff (StrictMono.{u2, u1} (WithTop.{u2} \u03b1) \u03b2 (WithTop.preorder.{u2} \u03b1 _inst_1) _inst_2 f) (And (StrictMono.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 (fun (a : \u03b1) => f (WithTop.some.{u2} \u03b1 a))) (forall (x : \u03b1), LT.lt.{u1} \u03b2 (Preorder.toLT.{u1} \u03b2 _inst_2) (f (WithTop.some.{u2} \u03b1 x)) (f (Top.top.{u2} (WithTop.{u2} \u03b1) (WithTop.top.{u2} \u03b1)))))\nCase conversion may be inaccurate. Consider using '#align with_top.strict_mono_iff WithTop.strictMono_iff\u2093'. -/\ntheorem strictMono_iff [Preorder \u03b1] [Preorder \u03b2] {f : WithTop \u03b1 \u2192 \u03b2} :\n    StrictMono f \u2194 StrictMono (f \u2218 coe : \u03b1 \u2192 \u03b2) \u2227 \u2200 x : \u03b1, f x < f \u22a4 :=\n  \u27e8fun h => \u27e8h.comp WithTop.coe_strictMono, fun x => h (coe_lt_top _)\u27e9, fun h =>\n    WithTop.forall.2\n      \u27e8WithTop.forall.2 \u27e8flip absurd (lt_irrefl _), fun x h => (not_top_lt h).elim\u27e9, fun x =>\n        WithTop.forall.2 \u27e8fun _ => h.2 x, fun y hle => h.1 (coe_lt_coe.1 hle)\u27e9\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, Iff (StrictMono.{u1, u2} (WithTop.{u1} \u03b1) (WithTop.{u2} \u03b2) (WithTop.preorder.{u1} \u03b1 _inst_1) (WithTop.preorder.{u2} \u03b2 _inst_2) (WithTop.map.{u1, u2} \u03b1 \u03b2 f)) (StrictMono.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, Iff (StrictMono.{u2, u1} (WithTop.{u2} \u03b1) (WithTop.{u1} \u03b2) (WithTop.preorder.{u2} \u03b1 _inst_1) (WithTop.preorder.{u1} \u03b2 _inst_2) (WithTop.map.{u2, u1} \u03b1 \u03b2 f)) (StrictMono.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f)\nCase conversion may be inaccurate. Consider using '#align with_top.strict_mono_map_iff WithTop.strictMono_map_iff\u2093'. -/\n@[simp]\ntheorem strictMono_map_iff [Preorder \u03b1] [Preorder \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    StrictMono (WithTop.map f) \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] {f : \u03b1 -> \u03b2}, (StrictMono.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (StrictMono.{u1, u2} (WithTop.{u1} \u03b1) (WithTop.{u2} \u03b2) (WithTop.preorder.{u1} \u03b1 _inst_1) (WithTop.preorder.{u2} \u03b2 _inst_2) (WithTop.map.{u1, u2} \u03b1 \u03b2 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] {f : \u03b1 -> \u03b2}, (StrictMono.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f) -> (StrictMono.{u2, u1} (WithTop.{u2} \u03b1) (WithTop.{u1} \u03b2) (WithTop.preorder.{u2} \u03b1 _inst_1) (WithTop.preorder.{u1} \u03b2 _inst_2) (WithTop.map.{u2, u1} \u03b1 \u03b2 f))\nCase conversion may be inaccurate. Consider using '#align strict_mono.with_top_map StrictMono.withTop_map\u2093'. -/\nalias strict_mono_map_iff \u2194 _ _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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] (f : \u03b1 -> \u03b2) (a : WithTop.{u1} \u03b1) (b : WithTop.{u1} \u03b1), (forall {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) (f a) (f b)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_1) a b)) -> (Iff (LE.le.{u2} (WithTop.{u2} \u03b2) (Preorder.toLE.{u2} (WithTop.{u2} \u03b2) (WithTop.preorder.{u2} \u03b2 _inst_2)) (WithTop.map.{u1, u2} \u03b1 \u03b2 f a) (WithTop.map.{u1, u2} \u03b1 \u03b2 f b)) (LE.le.{u1} (WithTop.{u1} \u03b1) (Preorder.toLE.{u1} (WithTop.{u1} \u03b1) (WithTop.preorder.{u1} \u03b1 _inst_1)) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Preorder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] (f : \u03b1 -> \u03b2) (a : WithTop.{u2} \u03b1) (b : WithTop.{u2} \u03b1), (forall {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _inst_2) (f a) (f b)) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_1) a b)) -> (Iff (LE.le.{u1} (WithTop.{u1} \u03b2) (Preorder.toLE.{u1} (WithTop.{u1} \u03b2) (WithTop.preorder.{u1} \u03b2 _inst_2)) (WithTop.map.{u2, u1} \u03b1 \u03b2 f a) (WithTop.map.{u2, u1} \u03b1 \u03b2 f b)) (LE.le.{u2} (WithTop.{u2} \u03b1) (Preorder.toLE.{u2} (WithTop.{u2} \u03b1) (WithTop.preorder.{u2} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align with_top.map_le_iff WithTop.map_le_iff\u2093'. -/\ntheorem map_le_iff [Preorder \u03b1] [Preorder \u03b2] (f : \u03b1 \u2192 \u03b2) (a b : WithTop \u03b1)\n    (mono_iff : \u2200 {a b}, f a \u2264 f b \u2194 a \u2264 b) : a.map f \u2264 b.map f \u2194 a \u2264 b :=\n  by\n  rw [\u2190 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 \u03b1] : SemilatticeInf (WithTop \u03b1) :=\n  { WithTop.partialOrder with\n    inf := Option.liftOrGet (\u00b7 \u2293 \u00b7)\n    inf_le_left := fun o\u2081 o\u2082 a ha => by cases ha <;> cases o\u2082 <;> simp [Option.liftOrGet]\n    inf_le_right := fun o\u2081 o\u2082 a ha => by cases ha <;> cases o\u2081 <;> simp [Option.liftOrGet]\n    le_inf := fun o\u2081 o\u2082 o\u2083 h\u2081 h\u2082 a ha =>\n      by\n      cases' o\u2082 with b <;> cases' o\u2083 with c <;> cases ha\n      \u00b7 exact h\u2082 a rfl\n      \u00b7 exact h\u2081 a rfl\n      \u00b7 rcases h\u2081 b rfl with \u27e8d, \u27e8\u27e9, h\u2081'\u27e9\n        simp at h\u2082\n        exact \u27e8d, rfl, le_inf h\u2081' h\u2082\u27e9 }\n\n/- warning: with_top.coe_inf -> WithTop.coe_inf is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SemilatticeInf.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) (Inf.inf.{u1} \u03b1 (SemilatticeInf.toHasInf.{u1} \u03b1 _inst_1) a b)) (Inf.inf.{u1} (WithTop.{u1} \u03b1) (SemilatticeInf.toHasInf.{u1} (WithTop.{u1} \u03b1) (WithTop.semilatticeInf.{u1} \u03b1 _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SemilatticeInf.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) (WithTop.some.{u1} \u03b1 (Inf.inf.{u1} \u03b1 (SemilatticeInf.toInf.{u1} \u03b1 _inst_1) a b)) (Inf.inf.{u1} (WithTop.{u1} \u03b1) (SemilatticeInf.toInf.{u1} (WithTop.{u1} \u03b1) (WithTop.semilatticeInf.{u1} \u03b1 _inst_1)) (WithTop.some.{u1} \u03b1 a) (WithTop.some.{u1} \u03b1 b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_inf WithTop.coe_inf\u2093'. -/\ntheorem coe_inf [SemilatticeInf \u03b1] (a b : \u03b1) : ((a \u2293 b : \u03b1) : WithTop \u03b1) = a \u2293 b :=\n  rfl\n#align with_top.coe_inf WithTop.coe_inf\n\ninstance [SemilatticeSup \u03b1] : SemilatticeSup (WithTop \u03b1) :=\n  { WithTop.partialOrder with\n    sup := Option.map\u2082 (\u00b7 \u2294 \u00b7)\n    le_sup_left := fun o\u2081 o\u2082 a ha =>\n      by\n      rcases Option.mem_map\u2082_iff.1 ha with \u27e8a, b, rfl : _ = _, rfl : _ = _, rfl\u27e9\n      exact \u27e8_, rfl, le_sup_left\u27e9\n    le_sup_right := fun o\u2081 o\u2082 a ha =>\n      by\n      rcases Option.mem_map\u2082_iff.1 ha with \u27e8a, b, rfl : _ = _, rfl : _ = _, rfl\u27e9\n      exact \u27e8_, rfl, le_sup_right\u27e9\n    sup_le := fun o\u2081 o\u2082 o\u2083 h\u2081 h\u2082 a ha => by\n      cases ha\n      rcases h\u2081 a rfl with \u27e8b, \u27e8\u27e9, ab\u27e9\n      rcases h\u2082 a rfl with \u27e8c, \u27e8\u27e9, ac\u27e9\n      exact \u27e8_, rfl, sup_le ab ac\u27e9 }\n\n/- warning: with_top.coe_sup -> WithTop.coe_sup is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SemilatticeSup.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) (Sup.sup.{u1} \u03b1 (SemilatticeSup.toHasSup.{u1} \u03b1 _inst_1) a b)) (Sup.sup.{u1} (WithTop.{u1} \u03b1) (SemilatticeSup.toHasSup.{u1} (WithTop.{u1} \u03b1) (WithTop.semilatticeSup.{u1} \u03b1 _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SemilatticeSup.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) (WithTop.some.{u1} \u03b1 (Sup.sup.{u1} \u03b1 (SemilatticeSup.toSup.{u1} \u03b1 _inst_1) a b)) (Sup.sup.{u1} (WithTop.{u1} \u03b1) (SemilatticeSup.toSup.{u1} (WithTop.{u1} \u03b1) (WithTop.semilatticeSup.{u1} \u03b1 _inst_1)) (WithTop.some.{u1} \u03b1 a) (WithTop.some.{u1} \u03b1 b))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_sup WithTop.coe_sup\u2093'. -/\ntheorem coe_sup [SemilatticeSup \u03b1] (a b : \u03b1) : ((a \u2294 b : \u03b1) : WithTop \u03b1) = a \u2294 b :=\n  rfl\n#align with_top.coe_sup WithTop.coe_sup\n\ninstance [Lattice \u03b1] : Lattice (WithTop \u03b1) :=\n  { WithTop.semilatticeSup, WithTop.semilatticeInf with }\n\ninstance [DistribLattice \u03b1] : DistribLattice (WithTop \u03b1) :=\n  { WithTop.lattice with\n    le_sup_inf := fun o\u2081 o\u2082 o\u2083 =>\n      match o\u2081, o\u2082, o\u2083 with\n      | \u22a4, o\u2082, o\u2083 => le_rfl\n      | (a\u2081 : \u03b1), \u22a4, \u22a4 => le_rfl\n      | (a\u2081 : \u03b1), \u22a4, (a\u2083 : \u03b1) => le_rfl\n      | (a\u2081 : \u03b1), (a\u2082 : \u03b1), \u22a4 => le_rfl\n      | (a\u2081 : \u03b1), (a\u2082 : \u03b1), (a\u2083 : \u03b1) => 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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : DecidableRel.{succ u1} \u03b1 (LE.le.{u1} \u03b1 _inst_1)], DecidableRel.{succ u1} (WithTop.{u1} \u03b1) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : DecidableRel.{succ u1} \u03b1 (fun (x._@.Mathlib.Order.WithBot._hyg.10360 : \u03b1) (x._@.Mathlib.Order.WithBot._hyg.10362 : \u03b1) => LE.le.{u1} \u03b1 _inst_1 x._@.Mathlib.Order.WithBot._hyg.10360 x._@.Mathlib.Order.WithBot._hyg.10362)], DecidableRel.{succ u1} (WithTop.{u1} \u03b1) (fun (x._@.Mathlib.Order.WithBot._hyg.10380 : WithTop.{u1} \u03b1) (x._@.Mathlib.Order.WithBot._hyg.10382 : WithTop.{u1} \u03b1) => LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _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\u2093'. -/\ninstance decidableLE [LE \u03b1] [@DecidableRel \u03b1 (\u00b7 \u2264 \u00b7)] : @DecidableRel (WithTop \u03b1) (\u00b7 \u2264 \u00b7) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] [_inst_2 : DecidableRel.{succ u1} \u03b1 (LT.lt.{u1} \u03b1 _inst_1)], DecidableRel.{succ u1} (WithTop.{u1} \u03b1) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LT.{u1} \u03b1] [_inst_2 : DecidableRel.{succ u1} \u03b1 (fun (x._@.Mathlib.Order.WithBot._hyg.10415 : \u03b1) (x._@.Mathlib.Order.WithBot._hyg.10417 : \u03b1) => LT.lt.{u1} \u03b1 _inst_1 x._@.Mathlib.Order.WithBot._hyg.10415 x._@.Mathlib.Order.WithBot._hyg.10417)], DecidableRel.{succ u1} (WithTop.{u1} \u03b1) (fun (x._@.Mathlib.Order.WithBot._hyg.10435 : WithTop.{u1} \u03b1) (x._@.Mathlib.Order.WithBot._hyg.10437 : WithTop.{u1} \u03b1) => LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _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\u2093'. -/\ninstance decidableLT [LT \u03b1] [@DecidableRel \u03b1 (\u00b7 < \u00b7)] : @DecidableRel (WithTop \u03b1) (\u00b7 < \u00b7) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : IsTotal.{u1} \u03b1 (LE.le.{u1} \u03b1 _inst_1)], IsTotal.{u1} (WithTop.{u1} \u03b1) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : IsTotal.{u1} \u03b1 (fun (x._@.Mathlib.Order.WithBot._hyg.10470 : \u03b1) (x._@.Mathlib.Order.WithBot._hyg.10472 : \u03b1) => LE.le.{u1} \u03b1 _inst_1 x._@.Mathlib.Order.WithBot._hyg.10470 x._@.Mathlib.Order.WithBot._hyg.10472)], IsTotal.{u1} (WithTop.{u1} \u03b1) (fun (x._@.Mathlib.Order.WithBot._hyg.10490 : WithTop.{u1} \u03b1) (x._@.Mathlib.Order.WithBot._hyg.10492 : WithTop.{u1} \u03b1) => LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _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\u2093'. -/\ninstance isTotal_le [LE \u03b1] [IsTotal \u03b1 (\u00b7 \u2264 \u00b7)] : IsTotal (WithTop \u03b1) (\u00b7 \u2264 \u00b7) :=\n  \u27e8fun _ _ => by\n    simp_rw [\u2190 to_dual_le_to_dual_iff]\n    exact total_of _ _ _\u27e9\n#align with_top.is_total_le WithTop.isTotal_le\n\ninstance [LinearOrder \u03b1] : LinearOrder (WithTop \u03b1) :=\n  Lattice.toLinearOrder _\n\n/- warning: with_top.coe_min -> WithTop.coe_min is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) (LinearOrder.min.{u1} \u03b1 _inst_1 x y)) (LinearOrder.min.{u1} (WithTop.{u1} \u03b1) (WithTop.linearOrder.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) y))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) (WithTop.some.{u1} \u03b1 (Min.min.{u1} \u03b1 (LinearOrder.toMin.{u1} \u03b1 _inst_1) x y)) (Min.min.{u1} (WithTop.{u1} \u03b1) (LinearOrder.toMin.{u1} (WithTop.{u1} \u03b1) (WithTop.linearOrder.{u1} \u03b1 _inst_1)) (WithTop.some.{u1} \u03b1 x) (WithTop.some.{u1} \u03b1 y))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_min WithTop.coe_min\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_min [LinearOrder \u03b1] (x y : \u03b1) : (\u2191(min x y) : WithTop \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) (LinearOrder.max.{u1} \u03b1 _inst_1 x y)) (LinearOrder.max.{u1} (WithTop.{u1} \u03b1) (WithTop.linearOrder.{u1} \u03b1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) x) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) y))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrder.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (WithTop.{u1} \u03b1) (WithTop.some.{u1} \u03b1 (Max.max.{u1} \u03b1 (LinearOrder.toMax.{u1} \u03b1 _inst_1) x y)) (Max.max.{u1} (WithTop.{u1} \u03b1) (LinearOrder.toMax.{u1} (WithTop.{u1} \u03b1) (WithTop.linearOrder.{u1} \u03b1 _inst_1)) (WithTop.some.{u1} \u03b1 x) (WithTop.some.{u1} \u03b1 y))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_max WithTop.coe_max\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_max [LinearOrder \u03b1] (x y : \u03b1) : (\u2191(max x y) : WithTop \u03b1) = max x y :=\n  rfl\n#align with_top.coe_max WithTop.coe_max\n\n#print WithTop.wellFounded_lt /-\ntheorem wellFounded_lt [Preorder \u03b1] (h : @WellFounded \u03b1 (\u00b7 < \u00b7)) :\n    @WellFounded (WithTop \u03b1) (\u00b7 < \u00b7) :=\n  have acc_some : \u2200 a : \u03b1, Acc ((\u00b7 < \u00b7) : WithTop \u03b1 \u2192 WithTop \u03b1 \u2192 Prop) (some a) := fun a =>\n    Acc.intro _\n      (WellFounded.induction h a\n        (show\n          \u2200 b,\n            (\u2200 c, c < b \u2192 \u2200 d : WithTop \u03b1, d < some c \u2192 Acc (\u00b7 < \u00b7) d) \u2192\n              \u2200 y : WithTop \u03b1, y < some b \u2192 Acc (\u00b7 < \u00b7) 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  \u27e8fun 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\u27e9\n#align with_top.well_founded_lt WithTop.wellFounded_lt\n-/\n\nopen OrderDual\n\n#print WithTop.wellFounded_gt /-\ntheorem wellFounded_gt [Preorder \u03b1] (h : @WellFounded \u03b1 (\u00b7 > \u00b7)) :\n    @WellFounded (WithTop \u03b1) (\u00b7 > \u00b7) :=\n  \u27e8fun a =>\n    by\n    -- ideally, use rel_hom_class.acc, but that is defined later\n    have : Acc (\u00b7 < \u00b7) 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 \u27e8_, fun a' h => IH a'.toDual (to_dual_lt_to_dual.mpr h) _ rfl\u27e9\u27e9\n#align with_top.well_founded_gt WithTop.wellFounded_gt\n-/\n\n#print WithBot.wellFounded_gt /-\ntheorem WithBot.wellFounded_gt [Preorder \u03b1] (h : @WellFounded \u03b1 (\u00b7 > \u00b7)) :\n    @WellFounded (WithBot \u03b1) (\u00b7 > \u00b7) :=\n  \u27e8fun a =>\n    by\n    -- ideally, use rel_hom_class.acc, but that is defined later\n    have : Acc (\u00b7 < \u00b7) 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 \u27e8_, fun a' h => IH a'.toDual (to_dual_lt_to_dual.mpr h) _ rfl\u27e9\u27e9\n#align with_bot.well_founded_gt WithBot.wellFounded_gt\n-/\n\n#print WithTop.trichotomous.lt /-\ninstance trichotomous.lt [Preorder \u03b1] [IsTrichotomous \u03b1 (\u00b7 < \u00b7)] :\n    IsTrichotomous (WithTop \u03b1) (\u00b7 < \u00b7) :=\n  \u27e8by\n    rintro (a | _) (b | _)\n    iterate 3 simp\n    simpa [Option.some_inj] using @trichotomous _ (\u00b7 < \u00b7) _ a b\u27e9\n#align with_top.trichotomous.lt WithTop.trichotomous.lt\n-/\n\n#print WithTop.IsWellOrder.lt /-\ninstance IsWellOrder.lt [Preorder \u03b1] [h : IsWellOrder \u03b1 (\u00b7 < \u00b7)] : IsWellOrder (WithTop \u03b1) (\u00b7 < \u00b7)\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 \u03b1] [IsTrichotomous \u03b1 (\u00b7 > \u00b7)] :\n    IsTrichotomous (WithTop \u03b1) (\u00b7 > \u00b7) :=\n  \u27e8by\n    rintro (a | _) (b | _)\n    iterate 3 simp\n    simpa [Option.some_inj] using @trichotomous _ (\u00b7 > \u00b7) _ a b\u27e9\n#align with_top.trichotomous.gt WithTop.trichotomous.gt\n-/\n\n#print WithTop.IsWellOrder.gt /-\ninstance IsWellOrder.gt [Preorder \u03b1] [h : IsWellOrder \u03b1 (\u00b7 > \u00b7)] : IsWellOrder (WithTop \u03b1) (\u00b7 > \u00b7)\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 \u03b1] [h : IsTrichotomous \u03b1 (\u00b7 < \u00b7)] :\n    IsTrichotomous (WithBot \u03b1) (\u00b7 < \u00b7) :=\n  @WithTop.trichotomous.gt \u03b1\u1d52\u1d48 _ h\n#align with_bot.trichotomous.lt WithBot.trichotomous.lt\n-/\n\n#print WithBot.isWellOrder.lt /-\ninstance WithBot.isWellOrder.lt [Preorder \u03b1] [h : IsWellOrder \u03b1 (\u00b7 < \u00b7)] :\n    IsWellOrder (WithBot \u03b1) (\u00b7 < \u00b7) :=\n  @WithTop.IsWellOrder.gt \u03b1\u1d52\u1d48 _ h\n#align with_bot.is_well_order.lt WithBot.isWellOrder.lt\n-/\n\n#print WithBot.trichotomous.gt /-\ninstance WithBot.trichotomous.gt [Preorder \u03b1] [h : IsTrichotomous \u03b1 (\u00b7 > \u00b7)] :\n    IsTrichotomous (WithBot \u03b1) (\u00b7 > \u00b7) :=\n  @WithTop.trichotomous.lt \u03b1\u1d52\u1d48 _ h\n#align with_bot.trichotomous.gt WithBot.trichotomous.gt\n-/\n\n#print WithBot.isWellOrder.gt /-\ninstance WithBot.isWellOrder.gt [Preorder \u03b1] [h : IsWellOrder \u03b1 (\u00b7 > \u00b7)] :\n    IsWellOrder (WithBot \u03b1) (\u00b7 > \u00b7) :=\n  @WithTop.IsWellOrder.lt \u03b1\u1d52\u1d48 _ h\n#align with_bot.is_well_order.gt WithBot.isWellOrder.gt\n-/\n\ninstance [LT \u03b1] [DenselyOrdered \u03b1] [NoMaxOrder \u03b1] : DenselyOrdered (WithTop \u03b1) :=\n  OrderDual.denselyOrdered (WithBot \u03b1\u1d52\u1d48)\n\n#print WithTop.lt_iff_exists_coe_btwn /-\ntheorem lt_iff_exists_coe_btwn [Preorder \u03b1] [DenselyOrdered \u03b1] [NoMaxOrder \u03b1] {a b : WithTop \u03b1} :\n    a < b \u2194 \u2203 x : \u03b1, a < \u2191x \u2227 \u2191x < b :=\n  \u27e8fun h =>\n    let \u27e8y, hy\u27e9 := exists_between h\n    let \u27e8x, hx\u27e9 := lt_iff_exists_coe.1 hy.2\n    \u27e8x, hx.1 \u25b8 hy\u27e9,\n    fun \u27e8x, hx\u27e9 => lt_trans hx.1 hx.2\u27e9\n#align with_top.lt_iff_exists_coe_btwn WithTop.lt_iff_exists_coe_btwn\n-/\n\ninstance [LE \u03b1] [NoBotOrder \u03b1] [Nonempty \u03b1] : NoBotOrder (WithTop \u03b1) :=\n  OrderDual.noBotOrder (WithBot \u03b1\u1d52\u1d48)\n\ninstance [LT \u03b1] [NoMinOrder \u03b1] [Nonempty \u03b1] : NoMinOrder (WithTop \u03b1) :=\n  OrderDual.noMinOrder (WithBot \u03b1\u1d52\u1d48)\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 {\u03b1:Type*} {\u03b2:Type*} [M\u03b1:measurable_space \u03b1] [M\u03b2:measurable_space \u03b2] \n  (\u03bc\u03b1:measure_theory.outer_measure \u03b1) (\u03bc\u03b2:measure_theory.outer_measure \u03b2):measure_theory.outer_measure (\u03b1 \u00d7 \u03b2) := \n  measure_theory.outer_measure.of_function\n  (\u03bb P:set (\u03b1 \u00d7 \u03b2), \u03bc\u03b1 (prod.fst '' P) * \u03bc\u03b2 (prod.snd '' P))\nbegin\n  simp,\nend \n\nnoncomputable def prod.measure {\u03b1:Type*} {\u03b2:Type*} [M\u03b1:measurable_space \u03b1] [M\u03b2:measurable_space \u03b2] \n  (\u03bc\u03b1:measure_theory.measure \u03b1) (\u03bc\u03b2:measure_theory.measure \u03b2):measure_theory.measure (\u03b1 \u00d7 \u03b2) := \n  (prod.outer_measure \u03bc\u03b1.to_outer_measure \u03bc\u03b2.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:\u03bc\u03b1 (prod.fst '' t \u2229 s) + \u03bc\u03b1 (prod.fst '' t \\ s) = \u03bc\u03b1 (prod.fst '' t),\n   {rw \u2190 measure_theory.measure_eq_inter_diff', apply A1},\n   rw \u2190 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:\u03bc\u03b2 (prod.snd '' t \u2229 s) + \u03bc\u03b2 (prod.snd '' t \\ s) = \u03bc\u03b2 (prod.snd '' t),\n   {rw \u2190 measure_theory.measure_eq_inter_diff', apply A1},\n   rw \u2190 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 {\u03b1:Type*} {\u03b2:Type*} (A:set \u03b1) (B:set \u03b2) (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 {\u03b1:Type*} {\u03b2:Type*} (A:set \u03b1) (B:set \u03b2) (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 {\u03b1:Type*} {\u03b2:Type*} [M\u03b1:measurable_space \u03b1] [M\u03b2:measurable_space \u03b2] \n  (\u03bc\u03b1:measure_theory.outer_measure \u03b1) (\u03bc\u03b2:measure_theory.outer_measure \u03b2) {P:set (\u03b1 \u00d7 \u03b2)}:\n  prod.outer_measure \u03bc\u03b1 \u03bc\u03b2 P = \n  \u2a05 (f:\u2115 \u2192 set \u03b1) (g:\u2115 \u2192 set \u03b2) (h\u2081: P \u2286 \u22c3 n, (f n).prod (g n)), \u2211' n, \u03bc\u03b1 (f n) * \u03bc\u03b2 (g n) :=\nbegin\n  unfold prod.outer_measure measure_theory.outer_measure.of_function,\n  rw \u2190 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  _ _ _ _ (\u03bb (n:\u2115), (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 _ _ _ _ (\u03bb n, prod.fst '' (h n)),\n  apply @infi_le_of_le ennreal _ _ _ _ (\u03bb 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 (\u03b1 \u00d7 \u03b2) P (set.Union h) (\u22c3 (n : \u2115), (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 {\u03b1:Type*} {\u03b2:Type*} {A A':set \u03b1} {B B':set \u03b2}:A \u2286 A' \u2192 B \u2286 B' \u2192\nA.prod B \u2286 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 {\u03b1:Type*} {\u03b2:Type*} [M\u03b1:measurable_space \u03b1] [M\u03b2:measurable_space \u03b2] \n  (\u03bc\u03b1:measure_theory.measure \u03b1) (\u03bc\u03b2:measure_theory.measure \u03b2) {P:set (\u03b1 \u00d7 \u03b2)}:\n  prod.outer_measure \u03bc\u03b1.to_outer_measure \u03bc\u03b2.to_outer_measure P = \n  \u2a05 (f:\u2115 \u2192 set \u03b1) (g:\u2115 \u2192 set \u03b2) \n    (h\u2081 : \u2200 n, measurable_set (f n)) \n    (h\u2082 : \u2200 n, measurable_set (g n)) \n   (h\u2083: P \u2286 \u22c3 n, (f n).prod (g n)), \u2211' n, \u03bc\u03b1 (f n) * \u03bc\u03b2 (g n) :=\nbegin\n  rw prod.outer_measure.Inf_sum,\n  apply le_antisymm,\n  { simp,\n    intros f g h\u2081 h\u2082 h\u2083,\n    apply @infi_le_trans (\u2115\u2192 set \u03b1) ennreal _ f,\n    apply @infi_le_trans (\u2115\u2192 set \u03b2) ennreal _ g,\n    rw infi_prop_def,\n    apply le_refl _,\n    apply h\u2083 },\n  { simp,\n    intros f g h\u2083,\n    have h4 := \u03bb n, measure_theory.measurable_eq \u03bc\u03b1 (f n),\n    rw classical.skolem at h4,\n    cases h4 with f' h4,\n    have h5 := \u03bb n, measure_theory.measurable_eq \u03bc\u03b2 (g n),\n    rw classical.skolem at h5,\n    cases h5 with g' h5,\n\n\n    apply @infi_le_trans (\u2115\u2192 set \u03b1) ennreal _ f',\n    apply @infi_le_trans (\u2115\u2192 set \u03b2) 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 (\u22c3 (n : \u2115), (f n).prod (g n)) \n          (\u22c3 (n : \u2115), (f' n).prod (g' n)) h\u2083,\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 {\u03b1:Type*} {\u03b2:Type*} [M\u03b1:measurable_space \u03b1] [M\u03b2:measurable_space \u03b2] \n  (\u03bc\u03b1:measure_theory.outer_measure \u03b1) (\u03bc\u03b2:measure_theory.outer_measure \u03b2) {A:set \u03b1} {B:set \u03b2}:\n  prod.outer_measure \u03bc\u03b1 \u03bc\u03b2 (A.prod B) \u2264 \u03bc\u03b1 A * \u03bc\u03b2 B :=\nbegin\n  rw prod.outer_measure.Inf_sum,\n  {apply @infi_le_of_le ennreal _ _ _ _ (\u03bb (n:\u2115), ite (n = 0) A \u2205),\n  apply @infi_le_of_le ennreal _ _ _ _ (\u03bb (n:\u2115), ite (n = 0) B \u2205),\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 {\u03b1:Type*} {\u03b2:Type*} [M\u03b1:measurable_space \u03b1] [M\u03b2:measurable_space \u03b2] \n  (\u03bc\u03b1:measure_theory.measure \u03b1) (\u03bc\u03b2:measure_theory.measure \u03b2) {A:set \u03b1} {B:set \u03b2}:\n  (measurable_set A) \u2192 (measurable_set B) \u2192\n  \u03bc\u03b1 A * \u03bc\u03b2 B  \u2264 prod.outer_measure \u03bc\u03b1.to_outer_measure \u03bc\u03b2.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 \u2264 \u2211' (n : \u2115), ((f n).prod (g n)).characteristic,\n  { apply function.le_trans (set.characteristic.subset A1),\n    apply set.characteristic.Union,\n     },\n  have h3:\u2200 (a:\u03b1) (b:\u03b2), (A.characteristic a) * (B.characteristic b)  \u2264 \n          \u2211' (n : \u2115), ((f n).characteristic a * (g n).characteristic b),\n  { intros a b,\n    rw \u2190 set.characteristic.prod,\n    have h3a: (\u03bb n, ((f n).characteristic a * (g n).characteristic b)) =\n              (\u03bb n, ((f n).prod (g n)).characteristic (a, b)),\n    { ext n, rw set.characteristic.prod },\n    rw h3a,\n    have h3b:((\u2211' (n : \u2115), ((f n).prod (g n)).characteristic) (a, b)) =\n        (\u2211' (n : \u2115), ((f n).prod (g n)).characteristic (a, b)) ,\n    { apply ennreal.tsum_apply }, \n    rw \u2190 h3b,\n    apply h2 },\n  have h4:\u2200 (b:\u03b2), measure_theory.lintegral \u03bc\u03b1  (\u03bb a, A.characteristic a * (B.characteristic b))  \u2264 measure_theory.lintegral \u03bc\u03b1 (\u03bb a, \n            \u2211' (n : \u2115), ((f n).characteristic a) * (g n).characteristic b),\n  { intro b,\n    have h4a: \u2200 (a:\u03b1), (A.characteristic a) * (B.characteristic b)  \u2264 \n          \u2211' (n : \u2115), ((f n).characteristic a * (g n).characteristic b),\n    { intro a, apply h3 },\n    apply measure_theory.lintegral_mono, apply h4a },\n  have h5:\u2200 (b:\u03b2), \u03bc\u03b1 A * (B.characteristic b)  \u2264 \n            \u2211' (n : \u2115), ((\u03bc\u03b1 (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 : (\u03bb i, (\u222b\u207b (a : \u03b1), (f i).characteristic a * (g i).characteristic b \u2202\u03bc\u03b1)) =\n               (\u03bb i, \u03bc\u03b1 (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:\u222b\u207b (b : \u03b2),   (\u03bc\u03b1 A) * B.characteristic b \u2202\u03bc\u03b2 \u2264\n          \u222b\u207b (b : \u03b2), ( \u2211' (n : \u2115), (\u03bc\u03b1 (f n)) * (g n).characteristic b)  \u2202\u03bc\u03b2,\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: (\u03bb i, \u222b\u207b (b : \u03b2), \u03bc\u03b1 (f i) * (g i).characteristic b \u2202\u03bc\u03b2) =\n           (\u03bb i,  \u03bc\u03b1 (f i) *  \u03bc\u03b2 (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 {\u03b1:Type*} {\u03b2:Type*} [M\u03b1:measurable_space \u03b1] [M\u03b2:measurable_space \u03b2] \n  (\u03bc\u03b1:measure_theory.measure \u03b1) (\u03bc\u03b2:measure_theory.measure \u03b2) (S:set (\u03b1 \u00d7 \u03b2)):measurable_set S \u2192\n  prod.measure \u03bc\u03b1 \u03bc\u03b2 S = \n  prod.outer_measure \u03bc\u03b1.to_outer_measure \u03bc\u03b2.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{\u03b1:Type*} {\u03b2:Type*} [M\u03b1:measurable_space \u03b1] [M\u03b2:measurable_space \u03b2] \n  (\u03bc\u03b1:measure_theory.measure \u03b1) (\u03bc\u03b2:measure_theory.measure \u03b2) (A:set \u03b1) (B:set \u03b2):measurable_set A \u2192\n  measurable_set B \u2192 \n  (prod.measure \u03bc\u03b1 \u03bc\u03b2) (A.prod B) = (\u03bc\u03b1 A) * (\u03bc\u03b2 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 \u2192 q \u2192 p \u2227 q \u2227 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 \u2192 q \u2192 p \u2227 q \u2227 p := by\n  intro hp hq; apply And.intro hp; exact And.intro hq hp\n\n/- Structuring proofs -/\n\nexample : p \u2192 q \u2192 p \u2227 q \u2227 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 \u2192 q \u2192 p \u2227 q \u2227 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 \u2964 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nopen nat_trans category category_theory.functor\n\nvariables (C : Type u\u2081) [category.{v\u2081} C] (D : Type u\u2082) [category.{v\u2082} 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\u2081 v\u2082)} (C \u2964 D) :=\n{ hom     := \u03bb F G, nat_trans F G,\n  id      := \u03bb F, nat_trans.id F,\n  comp    := \u03bb _ _ _ \u03b1 \u03b2, vcomp \u03b1 \u03b2 }\n\nvariables {C D} {E : Type u\u2083} [category.{v\u2083} E]\nvariables {F G H I : C \u2964 D}\n\nnamespace nat_trans\n\n@[simp] lemma vcomp_eq_comp (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H) : vcomp \u03b1 \u03b2 = \u03b1 \u226b \u03b2 := rfl\n\nlemma vcomp_app' (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H) (X : C) :\n  (\u03b1 \u226b \u03b2).app X = (\u03b1.app X) \u226b (\u03b2.app X) := rfl\n\nlemma congr_app {\u03b1 \u03b2 : F \u27f6 G} (h : \u03b1 = \u03b2) (X : C) : \u03b1.app X = \u03b2.app X := by rw h\n@[simp] lemma id_app (F : C \u2964 D) (X : C) : (\ud835\udfd9 F : F \u27f6 F).app X = \ud835\udfd9 (F.obj X) := rfl\n@[simp] lemma comp_app {F G H : C \u2964 D} (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H) (X : C) :\n  (\u03b1 \u226b \u03b2).app X = \u03b1.app X \u226b \u03b2.app X := rfl\n\nlemma app_naturality {F G : C \u2964 (D \u2964 E)} (T : F \u27f6 G) (X : C) {Y Z : D} (f : Y \u27f6 Z) :\n  ((F.obj X).map f) \u226b ((T.app X).app Z) = ((T.app X).app Y) \u226b ((G.obj X).map f) :=\n(T.app X).naturality f\n\nlemma naturality_app {F G : C \u2964 (D \u2964 E)} (T : F \u27f6 G) (Z : D) {X Y : C} (f : X \u27f6 Y) :\n  ((F.map f).app Z) \u226b ((T.app Y).app Z) = ((T.app X).app Z) \u226b ((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 (\u03b1 : F \u27f6 G) [\u2200 (X : C), mono (\u03b1.app X)] : mono \u03b1 :=\n\u27e8\u03bb H g h eq, by { ext X, rw [\u2190cancel_mono (\u03b1.app X), \u2190comp_app, eq, comp_app] }\u27e9\n\n/-- A natural transformation is an epimorphism if each component is. -/\nlemma epi_app_of_epi (\u03b1 : F \u27f6 G) [\u2200 (X : C), epi (\u03b1.app X)] : epi \u03b1 :=\n\u27e8\u03bb H g h eq, by { ext X, rw [\u2190cancel_epi (\u03b1.app X), \u2190comp_app, eq, comp_app] }\u27e9\n\n/-- `hcomp \u03b1 \u03b2` is the horizontal composition of natural transformations. -/\ndef hcomp {H I : D \u2964 E} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) : (F \u22d9 H) \u27f6 (G \u22d9 I) :=\n{ app         := \u03bb X : C, (\u03b2.app (F.obj X)) \u226b (I.map (\u03b1.app X)),\n  naturality' := \u03bb X Y f,\n  begin\n    rw [functor.comp_map, functor.comp_map, \u2190assoc, naturality, assoc,\n        \u2190map_comp I, naturality, map_comp, assoc]\n  end }\n\ninfix ` \u25eb `:80 := hcomp\n\n@[simp] lemma hcomp_app {H I : D \u2964 E} (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) (X : C) :\n  (\u03b1 \u25eb \u03b2).app X = (\u03b2.app (F.obj X)) \u226b (I.map (\u03b1.app X)) := rfl\n\n@[simp] lemma hcomp_id_app {H : D \u2964 E} (\u03b1 : F \u27f6 G) (X : C) : (\u03b1 \u25eb \ud835\udfd9 H).app X = H.map (\u03b1.app X) :=\n  by {dsimp, simp} -- See note [dsimp, simp].\n\nlemma id_hcomp_app {H : E \u2964 C} (\u03b1 : F \u27f6 G) (X : E) : (\ud835\udfd9 H \u25eb \u03b1).app X = \u03b1.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 \u2964 E} (\u03b1 : F \u27f6 G) (\u03b2 : G \u27f6 H)\n  (\u03b3 : I \u27f6 J) (\u03b4 : J \u27f6 K) : (\u03b1 \u226b \u03b2) \u25eb (\u03b3 \u226b \u03b4) = (\u03b1 \u25eb \u03b3) \u226b (\u03b2 \u25eb \u03b4) :=\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 \u2964 (D \u2964 E)) : D \u2964 (C \u2964 E) :=\n{ obj := \u03bb k,\n  { obj := \u03bb j, (F.obj j).obj k,\n    map := \u03bb j j' f, (F.map f).app k,\n    map_id' := \u03bb X, begin rw category_theory.functor.map_id, refl end,\n    map_comp' := \u03bb X Y Z f g, by rw [map_comp, \u2190comp_app] },\n  map := \u03bb c c' f,\n  { app := \u03bb j, (F.obj j).map f } }.\n\n@[simp] lemma flip_obj_obj (F : C \u2964 (D \u2964 E)) (c) (d) : (F.flip.obj d).obj c = (F.obj c).obj d := rfl\n@[simp] lemma flip_obj_map (F : C \u2964 (D \u2964 E)) {c c' : C} (f : c \u27f6 c') (d : D) :\n  (F.flip.obj d).map f = (F.map f).app d := rfl\n@[simp] lemma flip_map_app (F : C \u2964 (D \u2964 E)) {d d' : D} (f : d \u27f6 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 \u222a t)).to_submodule.fg :=\nbegin\n  rcases fg_def.1 h1 with \u27e8p, hp, hp'\u27e9,\n  rcases fg_def.1 h2 with \u27e8q, hq, hq'\u27e9,\n  refine fg_def.2 \u27e8p * q, hp.mul hq, le_antisymm _ _\u27e9,\n  { rw [span_le],\n    rintros _ \u27e8x, y, hx, hy, rfl\u27e9,\n    change x * y \u2208 _,\n    refine subalgebra.mul_mem _ _ _,\n    { have : x \u2208 (adjoin R s).to_submodule,\n      { rw \u2190 hp', exact subset_span hx },\n      exact adjoin_mono (set.subset_union_left _ _) this },\n    have : y \u2208 (adjoin (adjoin R s) t).to_submodule,\n    { rw \u2190 hq', exact subset_span hy },\n    change y \u2208 adjoin R (s \u222a t), rwa adjoin_union_eq_adjoin_adjoin },\n  { intros r hr,\n    change r \u2208 adjoin R (s \u222a t) at hr,\n    rw adjoin_union_eq_adjoin_adjoin at hr,\n    change r \u2208 (adjoin (adjoin R s) t).to_submodule at hr,\n    rw [\u2190 hq', \u2190 set.image_id q, finsupp.mem_span_image_iff_total (adjoin R s)] at hr,\n    rcases hr with \u27e8l, hlq, rfl\u27e9,\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 * _ \u2208 _,\n    have : (l z).1 \u2208 (adjoin R s).to_submodule := (l z).2,\n    rw [\u2190 hp', \u2190 set.image_id p, finsupp.mem_span_image_iff_total R] at this,\n    rcases this with \u27e8l2, hlp, hl\u27e9,\n    have := @finsupp.total_apply A A R,\n    rw this at hl,\n    rw [\u2190hl, finsupp.sum_mul],\n    refine sum_mem _ _,\n    intros t ht, change _ * _ \u2208 _, rw smul_mul_assoc, refine smul_mem _ _ _,\n    exact subset_span \u27e8t, z, hlp ht, hlq hz, rfl\u27e9 }\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\u2203 t : finset A, algebra.adjoin R \u2191t = S\n\nlemma fg_adjoin_finset (s : finset A) : (algebra.adjoin R (\u2191s : set A)).fg :=\n\u27e8s, rfl\u27e9\n\ntheorem fg_def {S : subalgebra R A} : S.fg \u2194 \u2203 t : set A, set.finite t \u2227 algebra.adjoin R t = S :=\n\u27e8\u03bb \u27e8t, ht\u27e9, \u27e8\u2191t, set.finite_mem_finset t, ht\u27e9,\n\u03bb \u27e8t, ht1, ht2\u27e9, \u27e8ht1.to_finset, by rwa set.finite.coe_to_finset\u27e9\u27e9\n\ntheorem fg_bot : (\u22a5 : subalgebra R A).fg :=\n\u27e8\u2205, algebra.adjoin_empty R A\u27e9\n\ntheorem fg_of_fg_to_submodule {S : subalgebra R A} : S.to_submodule.fg \u2192 S.fg :=\n\u03bb \u27e8t, ht\u27e9, \u27e8t, le_antisymm\n  (algebra.adjoin_le (\u03bb x hx, show x \u2208 S.to_submodule, from ht \u25b8 subset_span hx)) $\n  show S.to_submodule \u2264 (algebra.adjoin R \u2191t).to_submodule,\n  from (\u03bb x hx, span_le.mpr\n    (\u03bb x hx, algebra.subset_adjoin hx)\n      (show x \u2208 span R \u2191t, by { rw ht, exact hx }))\u27e9\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 : (\u22a4 : submodule R A).fg) : (\u22a4 : subalgebra R A).fg :=\nlet \u27e8s, hs\u27e9 := h in \u27e8s, to_submodule_injective $\nby { rw [algebra.top_to_submodule, eq_top_iff, \u2190 hs, span_le], exact algebra.subset_adjoin }\u27e9\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 \u27e8s, hs\u27e9 := fg_def.1 hS,\n  obtain \u27e8t, ht\u27e9 := fg_def.1 hT,\n  rw [\u2190 hs.2, \u2190 ht.2],\n  exact fg_def.2 \u27e8(linear_map.inl R A B '' (s \u222a {1})) \u222a (linear_map.inr R A B '' (t \u222a {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\u27e9\nend\n\nsection\nopen_locale classical\nlemma fg_map (S : subalgebra R A) (f : A \u2192\u2090[R] B) (hs : S.fg) : (S.map f).fg :=\nlet \u27e8s, hs\u27e9 := hs in \u27e8s.image f, by rw [finset.coe_image, algebra.adjoin_image, hs]\u27e9\nend\n\nlemma fg_of_fg_map (S : subalgebra R A) (f : A \u2192\u2090[R] B) (hf : function.injective f)\n  (hs : (S.map f).fg) : S.fg :=\nlet \u27e8s, hs\u27e9 := hs in \u27e8s.preimage f $ \u03bb _ _ _ _ h, hf h, map_injective f hf $\nby { rw [\u2190 algebra.adjoin_image, finset.coe_preimage, set.image_preimage_eq_of_subset, hs],\n  rw [\u2190 alg_hom.coe_range, \u2190 algebra.adjoin_le_iff, hs, \u2190 algebra.map_top], exact map_mono le_top }\u27e9\n\nlemma fg_top (S : subalgebra R A) : (\u22a4 : subalgebra R S).fg \u2194 S.fg :=\n\u27e8\u03bb h, by { rw [\u2190 S.range_val, \u2190 algebra.map_top], exact fg_map _ _ h },\n\u03bb h, fg_of_fg_map _ S.val subtype.val_injective $ by { rw [algebra.map_top, range_val], exact h }\u27e9\n\nlemma induction_on_adjoin [is_noetherian R A] (P : subalgebra R A \u2192 Prop)\n  (base : P \u22a5) (ih : \u2200 (S : subalgebra R A) (x : A), P S \u2192 P (algebra.adjoin R (insert x S)))\n  (S : subalgebra R A) : P S :=\nbegin\n  classical,\n  obtain \u27e8t, rfl\u27e9 := 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 \u2192\u2090[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 \u27e8t, ht\u27e9 := HS in ht \u25b8 (algebra.adjoin_eq_range R (\u2191t : set A)).symm \u25b8\nby haveI : is_noetherian_ring (mv_polynomial (\u2191t : 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 \u25b8 is_noetherian_ring_of_fg (subalgebra.fg_def.2 \u27e8s, hs, rfl\u27e9)\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 \u2192 A`.\nThis is primarily due to some restrictions arising from our inductive constructions.\n\n-/\n\ndef ftuple (A : Type*) (n : \u2115) := fin n \u2192 A\n\nlocal notation `\u03b7` := sum_fin_sum_equiv.to_fun \nlocal notation `\u03b4` := 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 \u2192 fin (m + n) := \u03b7 \u2218 sum.inl \ndef inr {m n} : fin n \u2192 fin (m + n) := \u03b7 \u2218 sum.inr\n\ndef nil : ftuple A 0 := \u03bb i, fin.elim0 i\ndef cast {m n} (h : m = n) (as : ftuple A m) : ftuple A n := as \u2218 (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 := \u03bb i, a\ndef append {m n} (as : ftuple A m) (bs : ftuple A n) : ftuple A (m+n) := \u03bb i, sum.cases_on (\u03b4 i) as bs\ndef map {n} (as : ftuple A n) (f : A \u2192 B) : ftuple B n := f \u2218 as\ndef proj {m n} (f : fin m \u2192 fin n) (as : ftuple A n) : ftuple A m := as \u2218 f\ndef init {m n} (as : ftuple A (m + n)) : ftuple A m := \u03bb i, as (\u03b7 $ sum.inl i)\ndef last {m n} (as : ftuple A (m + n)) : ftuple A n := \u03bb i, as (\u03b7 $ sum.inr i)\ndef compl {m n} (as : ftuple A (m+n)) (f : ftuple A m \u2192 A) (g : ftuple A (1 + n) \u2192 A) : A := \n  g $ append (of $ f as.init) as.last\ndef compr {m n} (as : ftuple A (n+m)) (f : ftuple A m \u2192 A) (g : ftuple A (n + 1) \u2192 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) \u2192 B) : A \u2192 (ftuple A n \u2192 B) := \u03bb a as, f (cons a as) \ndef uncurry {n} (f : A \u2192 (ftuple A n \u2192 B)) : ftuple A (n+1) \u2192 B := \u03bb 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 \u2192 B) : (of a).map f = of (f a) := rfl\n\n@[simp]\nlemma map_proj {m n} (f : fin m \u2192 fin n) (g : A \u2192 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 \u2192 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 \u2192 B) (as : ftuple A (m+n)) : as.last.map f = (as.map f).last := rfl\n\n@[simp]\nlemma map_map {n} (f : A \u2192 B) (g : B \u2192 C) (as : ftuple A n) : as.map (g \u2218 f) = (as.map f).map g := rfl\n\n@[simp]\nlemma map_eval {n} (f : A \u2192 B) (as : ftuple A n) : \u2200 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 = \u03b7 (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 = \u03b7 (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 \u2264 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 \u2264 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 \u2264 x.val)\n  : (as.append bs) x = bs (fin.sub_nat m x.swap_args hx) :=\nbegin\n  conv_lhs\n  { rw \u2190 (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 \u2192 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 := \u27e8x.val, h\u27e9,\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  : \u2200 i : fin n, ((cons a as) (i.succ) = as i) := by apply fin.cons_succ\n\nlemma val_nonzero_of_fin_nonzero {n : \u2115} (i : fin n.succ) (h : i \u2260 0) : i.val \u2260 0 :=\nbegin\n  intro contra,\n  exact h ((fin.ext_iff i 0).mpr contra),\nend\n\ndef zero_lt_val {n : \u2115} (i : fin n.succ) (h : i \u2260 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 : \u2115} (as : ftuple A n.succ)\n  : \u2200 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 \u2192 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 \u2190 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 : \u2115} (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 \u2190 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 \u2192 B} (bs : ftuple B n) (surj : function.surjective f) :\n  \u2203 as : ftuple A n, as.map f = bs :=\nbegin\n  induction n with n hn,\n  { use nil,\n    apply nil_unique, },\n  { rw \u2190is_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 \u2190 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  (\u2200 i, (cons a as) i \u2248 (cons a bs) i) \u2194\n  (\u2200 i, as i \u2248 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 \u2190 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  (\u2200 i, (cons a as) i \u2248 (cons b as) i) \u2194\n  a \u2248 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 \u2190 fin.succ_pred i hi,\n      repeat {rw cons_shift}, } }\nend\n\ndef quotient_lift : \u03a0 {n} (f : ftuple A n \u2192 B) \n  (hyp : \u2200 (as bs : ftuple A n), (\u2200 i, as i \u2248 bs i) \u2192 f as = f bs),  \n  ftuple (quotient I) n \u2192 B := \u03bb n, nat.rec_on n \n  (\u03bb f hyp, \u03bb _, f nil) \n  (\u03bb n ind f hyp, uncurry $ quotient.lift (\u03bb 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 \u2192 B)\n  (hyp : \u2200 (as bs : ftuple A n), (\u2200 i, as i \u2248 bs i) \u2192 f as = f bs) (as : ftuple A n):  \n  (quotient_lift f hyp) (as.map (\u03bb a, \u27e6a\u27e7)) = 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 : \u2115) :\n  \u220f p in primes_le n, ((1 - (\u2191p)\u207b\u00b9)\u207b\u00b9 : \u211d) \u2264\n  \u2191(finset.card (primes_le n) + 1) :=\nbegin\n  sorry,\nend\n\n-- def pnat_range (n : \u2115) : finset \u2115+ := finset.image nat.to_pnat' (finset.Icc 1 n)\n--\n-- lemma coe_pnat_range_eq {n : \u2115} : 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 \u2218 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 : \u2115} {x : \u2115} (hx : x \u2208 finset.Icc 1 n) : (nat.to_pnat' x \u2208 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 : \u2115) : finset \u21a5(pnat_fac_le n) :=\n  -- finset.image (\u03bb x, \u27e8nat.to_pnat' x.val, mem_pnat_fac_le_of_mem_Icc x.property\u27e9) (finset.Icc 1 n).attach\n  (finset.Icc 1 n).attach.image (\u03bb x, \u27e8nat.to_pnat' x.val, mem_pnat_fac_le_of_mem_Icc x.property\u27e9)\n\nlemma coe_pnat_fac_le_range_eq {n : \u2115} : 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 {\u03b1 : Type*} {f : \u03b1 \u2192 nnreal} (s : finset \u03b1) :\n--   s.sum (\u03bb (x : \u03b1), f x) \u2264 \u2211' (x : \u03b1), 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 : \u2115} :\n  -- \u2211 k : \u2115+ in finset.Icc 1 n, ((\u2191k)\u207b\u00b9 : nnreal) \u2264 \n  harmonic n \u2264 \u2211' k : \u21a5(pnat_fac_le n), (\u2191k)\u207b\u00b9 :=\nbegin\n  rw harmonic,\n  rw \u2190 coe_pnat_fac_le_range_eq,\n  rw finset.sum_image,\n  { rw \u2190 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 : \u2115} : \n  log (\u2191n + 1) \u2264 \u2191(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 : \u2200 {x : \u2115}, (\u2191x : \u211d) = ((\u2191x : nnreal) : \u211d)),\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 (\u03bb 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\u2082, ..., a\u2099]` is a `chain` starting at `a\u2081` with respect to the relation `r` if `r a\u2081 a\u2082`\nand `r a\u2082 a\u2083` and ... and `r a\u2099\u208b\u2081 a\u2099`. We write it `chain r a\u2081 [a\u2082, ..., a\u2099]`.\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 {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop}\n\nmk_iff_of_inductive_prop list.chain list.chain_iff\n\ntheorem rel_of_chain_cons {a b : \u03b1} {l : list \u03b1}\n  (p : chain R a (b :: l)) : R a b :=\n(chain_cons.1 p).1\n\ntheorem chain_of_chain_cons {a b : \u03b1} {l : list \u03b1}\n  (p : chain R a (b :: l)) : chain R b l :=\n(chain_cons.1 p).2\n\ntheorem chain.imp' {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (HRS : \u2200 \u2983a b\u2984, R a b \u2192 S a b) {a b : \u03b1} (Hab : \u2200 \u2983c\u2984, R a c \u2192 S b c)\n  {l : list \u03b1} (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 : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b) {a : \u03b1} {l : list \u03b1} (p : chain R a l) : chain S a l :=\np.imp' H (H a)\n\ntheorem chain.iff {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2194 S a b) {a : \u03b1} {l : list \u03b1} : chain R a l \u2194 chain S a l :=\n\u27e8chain.imp (\u03bb a b, (H a b).1), chain.imp (\u03bb a b, (H a b).2)\u27e9\n\ntheorem chain.iff_mem {a : \u03b1} {l : list \u03b1} :\n  chain R a l \u2194 chain (\u03bb x y, x \u2208 a :: l \u2227 y \u2208 l \u2227 R x y) a l :=\n\u27e8\u03bb p, by induction p with _ a b l r p IH; constructor;\n  [exact \u27e8mem_cons_self _ _, mem_cons_self _ _, r\u27e9,\n   exact IH.imp (\u03bb a b \u27e8am, bm, h\u27e9,\n    \u27e8mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h\u27e9)],\n chain.imp (\u03bb a b h, h.2.2)\u27e9\n\ntheorem chain_singleton {a b : \u03b1} : chain R a [b] \u2194 R a b :=\nby simp only [chain_cons, chain.nil, and_true]\n\ntheorem chain_split {a b : \u03b1} {l\u2081 l\u2082 : list \u03b1} : chain R a (l\u2081 ++ b :: l\u2082) \u2194\n  chain R a (l\u2081 ++ [b]) \u2227 chain R b l\u2082 :=\nby induction l\u2081 with x l\u2081 IH generalizing a;\nsimp only [*, nil_append, cons_append, chain.nil, chain_cons, and_true, and_assoc]\n\ntheorem chain_map (f : \u03b2 \u2192 \u03b1) {b : \u03b2} {l : list \u03b2} :\n  chain R (f b) (map f l) \u2194 chain (\u03bb a b : \u03b2, 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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, S (f a) (f b) \u2192 R a b) {a : \u03b1} {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, R a b \u2192 S (f a) (f b)) {a : \u03b1} {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} {p : \u03b1 \u2192 Prop}\n  {f : \u03a0 a, p a \u2192 \u03b2}\n  (H : \u2200 a b ha hb, R a b \u2192 S (f a ha) (f b hb))\n  {a : \u03b1} {l : list \u03b1}\n  (hl\u2081 : chain R a l) (ha : p a) (hl\u2082 : \u2200 a \u2208 l, p a) :\n  chain S (f a ha) (list.pmap f l hl\u2082) :=\nbegin\n  induction l with lh lt l_ih generalizing a,\n  { simp },\n  { simp [H _ _ _ _ (rel_of_chain_cons hl\u2081), l_ih _ (chain_of_chain_cons hl\u2081)] }\nend\n\ntheorem chain_of_chain_pmap {S : \u03b2 \u2192 \u03b2 \u2192 Prop} {p : \u03b1 \u2192 Prop}\n  (f : \u03a0 a, p a \u2192 \u03b2) {l : list \u03b1} (hl\u2081 : \u2200 a \u2208 l, p a)\n  {a : \u03b1} (ha : p a) (hl\u2082 : chain S (f a ha) (list.pmap f l hl\u2081))\n  (H : \u2200 a b ha hb, S (f a ha) (f b hb) \u2192 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\u2082), l_ih _ _ (chain_of_chain_cons hl\u2082)] }\nend\n\ntheorem chain_of_pairwise {a : \u03b1} {l : list \u03b1} (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 \u27e8r.1, IH r'\u27e9\nend\n\ntheorem chain_iff_pairwise (tr : transitive R) {a : \u03b1} {l : list \u03b1} :\n  chain R a l \u2194 pairwise R (a :: l) :=\n\u27e8\u03bb 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 \u2200 x \u2208 l, R b x, from \u03bb x m, (tr r (rel_of_pairwise_cons IH m)),\nend, chain_of_pairwise\u27e9\n\ntheorem chain_iff_nth_le {R} : \u2200 {a : \u03b1} {l : list \u03b1},\n  chain R a l \u2194 (\u2200 h : 0 < length l, R a (nth_le l 0 h)) \u2227 (\u2200 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 \u27e8R, \u27e8h0, h\u27e9\u27e9,\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 \u27e8h0, h\u27e9, 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 : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b) {l : list \u03b1} (p : chain' R l) : chain' S l :=\nby cases l; [trivial, exact p.imp H]\n\ntheorem chain'.iff {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2194 S a b) {l : list \u03b1} : chain' R l \u2194 chain' S l :=\n\u27e8chain'.imp (\u03bb a b, (H a b).1), chain'.imp (\u03bb a b, (H a b).2)\u27e9\n\ntheorem chain'.iff_mem : \u2200 {l : list \u03b1}, chain' R l \u2194 chain' (\u03bb x y, x \u2208 l \u2227 y \u2208 l \u2227 R x y) l\n| []       := iff.rfl\n| (x :: l) :=\n  \u27e8\u03bb h, (chain.iff_mem.1 h).imp $ \u03bb a b \u27e8h\u2081, h\u2082, h\u2083\u27e9, \u27e8h\u2081, or.inr h\u2082, h\u2083\u27e9,\n   chain'.imp $ \u03bb a b h, h.2.2\u27e9\n\n@[simp] theorem chain'_nil : chain' R [] := trivial\n\n@[simp] theorem chain'_singleton (a : \u03b1) : chain' R [a] := chain.nil\n\ntheorem chain'_split {a : \u03b1} : \u2200 {l\u2081 l\u2082 : list \u03b1}, chain' R (l\u2081 ++ a :: l\u2082) \u2194\n  chain' R (l\u2081 ++ [a]) \u2227 chain' R (a :: l\u2082)\n| []        l\u2082 := (and_iff_right (chain'_singleton a)).symm\n| (b :: l\u2081) l\u2082 := chain_split\n\ntheorem chain'_map (f : \u03b2 \u2192 \u03b1) {l : list \u03b2} :\n  chain' R (map f l) \u2194 chain' (\u03bb a b : \u03b2, R (f a) (f b)) l :=\nby cases l; [refl, exact chain_map _]\n\ntheorem chain'_of_chain'_map {S : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, S (f a) (f b) \u2192 R a b) {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, R a b \u2192 S (f a) (f b)) {l : list \u03b1}\n  (p : chain' R l) : chain' S (map f l) :=\n(chain'_map f).2 $ p.imp H\n\ntheorem pairwise.chain' : \u2200 {l : list \u03b1}, pairwise R l \u2192 chain' R l\n| []       _ := trivial\n| (a :: l) h := chain_of_pairwise h\n\ntheorem chain'_iff_pairwise (tr : transitive R) : \u2200 {l : list \u03b1},\n  chain' R l \u2194 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) \u2194 R x y \u2227 chain' R (y :: l) :=\nchain_cons\n\ntheorem chain'.cons {x y l} (h\u2081 : R x y) (h\u2082 : chain' R (y :: l)) :\n  chain' R (x :: y :: l) :=\nchain'_cons.2 \u27e8h\u2081, h\u2082\u27e9\n\ntheorem chain'.tail : \u2200 {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)) \u2983y\u2984 (hy : y \u2208 head' l) : R x y :=\nby { rw \u2190 cons_head'_tail hy at h, exact h.rel_head }\n\ntheorem chain'.cons' {x} :\n  \u2200 {l : list \u03b1},  chain' R l \u2192 (\u2200 y \u2208 l.head', R x y) \u2192 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) \u2194 (\u2200 y \u2208 head' l, R x y) \u2227 chain' R l :=\n\u27e8\u03bb h, \u27e8h.rel_head', h.tail\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, h\u2082.cons' h\u2081\u27e9\n\ntheorem chain'.drop : \u2200 (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 : \u2200 {l\u2081 l\u2082 : list \u03b1} (h\u2081 : chain' R l\u2081) (h\u2082 : chain' R l\u2082)\n  (h : \u2200 (x \u2208 l\u2081.last') (y \u2208 l\u2082.head'), R x y),\n  chain' R (l\u2081 ++ l\u2082)\n| []            l\u2082 h\u2081 h\u2082 h := h\u2082\n| [a]           l\u2082 h\u2081 h\u2082 h := h\u2082.cons' $ h _ rfl\n| (a :: b :: l) l\u2082 h\u2081 h\u2082 h :=\n  begin\n    simp only [last'] at h,\n    have : chain' R (b :: l) := h\u2081.tail,\n    exact (this.append h\u2082 h).cons h\u2081.rel_head\n  end\n\ntheorem chain'_pair {x y} : chain' R [x, y] \u2194 R x y :=\nby simp only [chain'_singleton, chain'_cons, and_true]\n\ntheorem chain'.imp_head {x y} (h : \u2200 {z}, R x z \u2192 R y z) {l} (hl : chain' R (x :: l)) :\n  chain' R (y :: l) :=\nhl.tail.cons' $ \u03bb z hz, h $ hl.rel_head' hz\n\ntheorem chain'_reverse : \u2200 {l}, chain' R (reverse l) \u2194 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, \u2190 reverse_cons, @chain'_reverse (b :: l), and_comm, chain'_pair, flip]\n\ntheorem chain'_iff_nth_le {R} : \u2200 {l : list \u03b1},\n  chain' R l \u2194 \u2200 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 \u27e8R, h\u27e9 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\u2081 l\u2082` and `l\u2083` are lists and `l\u2081 ++ l\u2082` and `l\u2082 ++ l\u2083` both satisfy\n  `chain' R`, then so does `l\u2081 ++ l\u2082 ++ l\u2083` provided `l\u2082 \u2260 []` -/\nlemma chain'.append_overlap : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1}\n  (h\u2081 : chain' R (l\u2081 ++ l\u2082)) (h\u2082 : chain' R (l\u2082 ++ l\u2083)) (hn : l\u2082 \u2260 []),\n  chain' R (l\u2081 ++ l\u2082 ++ l\u2083)\n| []             l\u2082        l\u2083 h\u2081 h\u2082 hn := h\u2082\n| l\u2081             []        l\u2083 h\u2081 h\u2082 hn := (hn rfl).elim\n| [a]            (b :: l\u2082) l\u2083 h\u2081 h\u2082 hn := by { simp at *, tauto }\n| (a :: b :: l\u2081) (c :: l\u2082) l\u2083 h\u2081 h\u2082 hn := begin\n  simp only [cons_append, chain'_cons] at h\u2081 h\u2082 \u22a2,\n  simp only [\u2190 cons_append] at h\u2081 h\u2082 \u22a2,\n  exact \u27e8h\u2081.1, chain'.append_overlap h\u2081.2 h\u2082 (cons_ne_nil _ _)\u27e9\nend\n\nvariables {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a b : \u03b1}\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  \u2203 l, chain r a l \u2227 last (a :: l) (cons_ne_nil _ _) = b :=\nbegin\n  apply relation.refl_trans_gen.head_induction_on h,\n  { exact \u27e8[], chain.nil, rfl\u27e9 },\n  { intros c d e t ih,\n    obtain \u27e8l, hl\u2081, hl\u2082\u27e9 := ih,\n    refine \u27e8d :: l, chain.cons e hl\u2081, _\u27e9,\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 \u2192 p y \u2192 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 : \u03b1 \u2192 Prop)\n  (l : list \u03b1) (h : chain r a l)\n  (hb : last (a :: l) (cons_ne_nil _ _) = b)\n  (carries : \u2200 \u2983x y : \u03b1\u2984, r x y \u2192 p y \u2192 p x) (final : p b) : \u2200 i \u2208 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 \u2192 p y \u2192 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 : \u03b1 \u2192 Prop)\n  (l : list \u03b1) (h : chain r a l)\n  (hb : last (a :: l) (cons_ne_nil _ _) = b)\n  (carries : \u2200 \u2983x y : \u03b1\u2984, r x y \u2192 p y \u2192 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\u2081 : chain r a l)\n  (hl\u2082 : last (a :: l) (cons_ne_nil _ _) = b) :\n  relation.refl_trans_gen r a b :=\nchain.induction_head _ l hl\u2081 hl\u2082 (\u03bb 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 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\n\nuniverse u v w\n\n@[inline] def id {\u03b1 : Sort u} (a : \u03b1) : \u03b1 := a\n\n/- `idRhs` is an auxiliary declaration used to implement \"smart unfolding\". It is used as a marker. -/\n@[macroInline, reducible] def idRhs (\u03b1 : Sort u) (a : \u03b1) : \u03b1 := a\n\nabbrev Function.comp {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b4 : Sort w} (f : \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b4 :=\n  fun x => f (g x)\n\nabbrev Function.const {\u03b1 : Sort u} (\u03b2 : Sort v) (a : \u03b1) : \u03b2 \u2192 \u03b1 :=\n  fun x => a\n\nset_option checkBinderAnnotations false in\n@[reducible] def inferInstance {\u03b1 : Sort u} [i : \u03b1] : \u03b1 := i\nset_option checkBinderAnnotations false in\n@[reducible] def inferInstanceAs (\u03b1 : Sort u) [i : \u03b1] : \u03b1 := i\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\ninductive PUnit : Sort u where\n  | unit : PUnit\n\n/-- An abbreviation for `PUnit.{0}`, its most common instantiation.\n    This Type should be preferred over `PUnit` where possible to avoid\n    unnecessary universe parameters. -/\nabbrev Unit : Type := PUnit\n\n@[matchPattern] abbrev Unit.unit : Unit := PUnit.unit\n\n/-- Auxiliary unsafe constant used by the Compiler when erasing proofs from code. -/\nunsafe axiom lcProof {\u03b1 : Prop} : \u03b1\n\n/-- Auxiliary unsafe constant used by the Compiler to mark unreachable code. -/\nunsafe axiom lcUnreachable {\u03b1 : Sort u} : \u03b1\n\ninductive True : Prop where\n  | intro : True\n\ninductive False : Prop\n\ninductive Empty : Type\n\ndef Not (a : Prop) : Prop := a \u2192 False\n\n@[macroInline] def False.elim {C : Sort u} (h : False) : C :=\n  False.rec (fun _ => C) h\n\n@[macroInline] def absurd {a : Prop} {b : Sort v} (h\u2081 : a) (h\u2082 : Not a) : b :=\n  False.elim (h\u2082 h\u2081)\n\ninductive Eq {\u03b1 : Sort u} (a : \u03b1) : \u03b1 \u2192 Prop where\n  | refl {} : Eq a a\n\n@[simp] abbrev Eq.ndrec.{u1, u2} {\u03b1 : Sort u2} {a : \u03b1} {motive : \u03b1 \u2192 Sort u1} (m : motive a) {b : \u03b1} (h : Eq a b) : motive b :=\n  Eq.rec (motive := fun \u03b1 _ => motive \u03b1) m h\n\n@[matchPattern] def rfl {\u03b1 : Sort u} {a : \u03b1} : Eq a a := Eq.refl a\n\n@[simp] theorem id_eq (a : \u03b1) : Eq (id a) a := rfl\n\ntheorem Eq.subst {\u03b1 : Sort u} {motive : \u03b1 \u2192 Prop} {a b : \u03b1} (h\u2081 : Eq a b) (h\u2082 : motive a) : motive b :=\n  Eq.ndrec h\u2082 h\u2081\n\ntheorem Eq.symm {\u03b1 : Sort u} {a b : \u03b1} (h : Eq a b) : Eq b a :=\n  h \u25b8 rfl\n\ntheorem Eq.trans {\u03b1 : Sort u} {a b c : \u03b1} (h\u2081 : Eq a b) (h\u2082 : Eq b c) : Eq a c :=\n  h\u2082 \u25b8 h\u2081\n\n@[macroInline] def cast {\u03b1 \u03b2 : Sort u} (h : Eq \u03b1 \u03b2) (a : \u03b1) : \u03b2 :=\n  Eq.rec (motive := fun \u03b1 _ => \u03b1) a h\n\ntheorem congrArg {\u03b1 : Sort u} {\u03b2 : Sort v} {a\u2081 a\u2082 : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : Eq a\u2081 a\u2082) : Eq (f a\u2081) (f a\u2082) :=\n  h \u25b8 rfl\n\ntheorem congr {\u03b1 : Sort u} {\u03b2 : Sort v} {f\u2081 f\u2082 : \u03b1 \u2192 \u03b2} {a\u2081 a\u2082 : \u03b1} (h\u2081 : Eq f\u2081 f\u2082) (h\u2082 : Eq a\u2081 a\u2082) : Eq (f\u2081 a\u2081) (f\u2082 a\u2082) :=\n  h\u2081 \u25b8 h\u2082 \u25b8 rfl\n\ntheorem congrFun {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {f g : (x : \u03b1) \u2192  \u03b2 x} (h : Eq f g) (a : \u03b1) : Eq (f a) (g a) :=\n  h \u25b8 rfl\n\n/-\nInitialize the Quotient Module, which effectively adds the following definitions:\n\nconstant Quot {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Sort u\n\nconstant Quot.mk {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : Quot r\n\nconstant Quot.lift {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) :\n  (\u2200 a b : \u03b1, r a b \u2192 Eq (f a) (f b)) \u2192 Quot r \u2192 \u03b2\n\nconstant Quot.ind {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Quot r \u2192 Prop} :\n  (\u2200 a : \u03b1, \u03b2 (Quot.mk r a)) \u2192 \u2200 q : Quot r, \u03b2 q\n-/\ninit_quot\n\ninductive HEq {\u03b1 : Sort u} (a : \u03b1) : {\u03b2 : Sort u} \u2192 \u03b2 \u2192 Prop where\n  | refl {} : HEq a a\n\n@[matchPattern] def HEq.rfl {\u03b1 : Sort u} {a : \u03b1} : HEq a a :=\n  HEq.refl a\n\ntheorem eqOfHEq {\u03b1 : Sort u} {a a' : \u03b1} (h : HEq a a') : Eq a a' :=\n  have : (\u03b1 \u03b2 : Sort u) \u2192 (a : \u03b1) \u2192 (b : \u03b2) \u2192 HEq a b \u2192 (h : Eq \u03b1 \u03b2) \u2192 Eq (cast h a) b :=\n    fun \u03b1 \u03b2 a b h\u2081 =>\n      HEq.rec (motive := fun {\u03b2} (b : \u03b2) (h : HEq a b) => (h\u2082 : Eq \u03b1 \u03b2) \u2192 Eq (cast h\u2082 a) b)\n        (fun (h\u2082 : Eq \u03b1 \u03b1) => rfl)\n        h\u2081\n  this \u03b1 \u03b1 a a' h rfl\n\nstructure Prod (\u03b1 : Type u) (\u03b2 : Type v) where\n  fst : \u03b1\n  snd : \u03b2\n\nattribute [unbox] Prod\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` can be propositions.\n   We use this Type internally to automatically generate the brecOn recursor. -/\nstructure PProd (\u03b1 : Sort u) (\u03b2 : Sort v) where\n  fst : \u03b1\n  snd : \u03b2\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` are in the same universe. -/\nstructure MProd (\u03b1 \u03b2 : Type u) where\n  fst : \u03b1\n  snd : \u03b2\n\nstructure And (a b : Prop) : Prop where\n  intro :: (left : a) (right : b)\n\ninductive Or (a b : Prop) : Prop where\n  | inl (h : a) : Or a b\n  | inr (h : b) : Or a b\n\ninductive Bool : Type where\n  | false : Bool\n  | true : Bool\n\nexport Bool (false true)\n\n/- Remark: Subtype must take a Sort instead of Type because of the axiom strongIndefiniteDescription. -/\nstructure Subtype {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) where\n  val : \u03b1\n  property : p val\n\n/-- Gadget for optional parameter support. -/\n@[reducible] def optParam (\u03b1 : Sort u) (default : \u03b1) : Sort u := \u03b1\n\n/-- Gadget for marking output parameters in type classes. -/\n@[reducible] def outParam (\u03b1 : Sort u) : Sort u := \u03b1\n\n/-- Auxiliary Declaration used to implement the notation (a : \u03b1) -/\n@[reducible] def typedExpr (\u03b1 : Sort u) (a : \u03b1) : \u03b1 := a\n\n/-- Auxiliary Declaration used to implement the named patterns `x@p` -/\n@[reducible] def namedPattern {\u03b1 : Sort u} (x a : \u03b1) : \u03b1 := a\n\n/- Auxiliary axiom used to implement `sorry`. -/\n@[extern \"lean_sorry\", neverExtract]\naxiom sorryAx (\u03b1 : Sort u) (synthetic := true) : \u03b1\n\ntheorem eqFalseOfNeTrue : {b : Bool} \u2192 Not (Eq b true) \u2192 Eq b false\n  | true, h => False.elim (h rfl)\n  | false, h => rfl\n\ntheorem eqTrueOfNeFalse : {b : Bool} \u2192 Not (Eq b false) \u2192 Eq b true\n  | true, h => rfl\n  | false, h => False.elim (h rfl)\n\ntheorem neFalseOfEqTrue : {b : Bool} \u2192 Eq b true \u2192 Not (Eq b false)\n  | true, _  => fun h => Bool.noConfusion h\n  | false, h => Bool.noConfusion h\n\ntheorem neTrueOfEqFalse : {b : Bool} \u2192 Eq b false \u2192 Not (Eq b true)\n  | true, h  => Bool.noConfusion h\n  | false, _ => fun h => Bool.noConfusion h\n\nclass Inhabited (\u03b1 : Sort u) where\n  mk {} :: (default : \u03b1)\n\nconstant arbitrary [Inhabited \u03b1] : \u03b1 :=\n  Inhabited.default\n\ninstance : Inhabited (Sort u) where\n  default := PUnit\n\ninstance (\u03b1 : Sort u) {\u03b2 : Sort v} [Inhabited \u03b2] : Inhabited (\u03b1 \u2192 \u03b2) where\n  default := fun _ => arbitrary\n\ninstance (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(a : \u03b1) \u2192 Inhabited (\u03b2 a)] : Inhabited ((a : \u03b1) \u2192 \u03b2 a) where\n  default := fun _ => arbitrary\n\nderiving instance Inhabited for Bool\n\n/-- Universe lifting operation from Sort to Type -/\nstructure PLift (\u03b1 : Sort u) : Type u where\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and PLift \u03b1 -/\ntheorem PLift.upDown {\u03b1 : Sort u} : \u2200 (b : PLift \u03b1), Eq (up (down b)) b\n  | up a => rfl\n\ntheorem PLift.downUp {\u03b1 : Sort u} (a : \u03b1) : Eq (down (up a)) a :=\n  rfl\n\n/- Pointed types -/\nstructure PointedType where\n  (type : Type u)\n  (val : type)\n\ninstance : Inhabited PointedType.{u} where\n  default := { type := PUnit.{u+1}, val := \u27e8\u27e9 }\n\n/-- Universe lifting operation -/\nstructure ULift.{r, s} (\u03b1 : Type s) : Type (max s r) where\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and ULift.{v} \u03b1 -/\ntheorem ULift.upDown {\u03b1 : Type u} : \u2200 (b : ULift.{v} \u03b1), Eq (up (down b)) b\n  | up a => rfl\n\ntheorem ULift.downUp {\u03b1 : Type u} (a : \u03b1) : Eq (down (up.{v} a)) a :=\n  rfl\n\nclass inductive Decidable (p : Prop) where\n  | isFalse (h : Not p) : Decidable p\n  | isTrue  (h : p) : Decidable p\n\n@[inlineIfReduce, nospecialize] def Decidable.decide (p : Prop) [h : Decidable p] : Bool :=\n  Decidable.casesOn (motive := fun _ => Bool) h (fun _ => false) (fun _ => true)\n\nexport Decidable (isTrue isFalse decide)\n\nabbrev DecidablePred {\u03b1 : Sort u} (r : \u03b1 \u2192 Prop) :=\n  (a : \u03b1) \u2192 Decidable (r a)\n\nabbrev DecidableRel {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :=\n  (a b : \u03b1) \u2192 Decidable (r a b)\n\nabbrev DecidableEq (\u03b1 : Sort u) :=\n  (a b : \u03b1) \u2192 Decidable (Eq a b)\n\ndef decEq {\u03b1 : Sort u} [s : DecidableEq \u03b1] (a b : \u03b1) : Decidable (Eq a b) :=\n  s a b\n\ntheorem decideEqTrue : [s : Decidable p] \u2192 p \u2192 Eq (decide p) true\n  | isTrue  _, _   => rfl\n  | isFalse h\u2081, h\u2082 => absurd h\u2082 h\u2081\n\ntheorem decideEqFalse : [s : Decidable p] \u2192 Not p \u2192 Eq (decide p) false\n  | isTrue  h\u2081, h\u2082 => absurd h\u2081 h\u2082\n  | isFalse h, _   => rfl\n\ntheorem ofDecideEqTrue [s : Decidable p] : Eq (decide p) true \u2192 p := fun h =>\n  match (generalizing := false) s with\n  | isTrue  h\u2081 => h\u2081\n  | isFalse h\u2081 => absurd h (neTrueOfEqFalse (decideEqFalse h\u2081))\n\ntheorem ofDecideEqFalse [s : Decidable p] : Eq (decide p) false \u2192 Not p := fun h =>\n  match (generalizing := false) s with\n  | isTrue  h\u2081 => absurd h (neFalseOfEqTrue (decideEqTrue h\u2081))\n  | isFalse h\u2081 => h\u2081\n\n@[inline] instance : DecidableEq Bool :=\n  fun a b => match a, b with\n   | false, false => isTrue rfl\n   | false, true  => isFalse (fun h => Bool.noConfusion h)\n   | true, false  => isFalse (fun h => Bool.noConfusion h)\n   | true, true   => isTrue rfl\n\nclass BEq (\u03b1 : Type u) where\n  beq : \u03b1 \u2192 \u03b1 \u2192 Bool\n\nopen BEq (beq)\n\ninstance [DecidableEq \u03b1] : BEq \u03b1 where\n  beq a b := decide (Eq a b)\n\n-- We use \"dependent\" if-then-else to be able to communicate the if-then-else condition\n-- to the branches\n@[macroInline] def dite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t : c \u2192 \u03b1) (e : Not c \u2192 \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h e t\n\n/- if-then-else -/\n\n@[macroInline] def ite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t e : \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h (fun _ => e) (fun _ => t)\n\n@[macroInline] instance {p q} [dp : Decidable p] [dq : Decidable q] : Decidable (And p q) :=\n  match dp with\n  | isTrue  hp =>\n    match dq with\n    | isTrue hq  => isTrue \u27e8hp, hq\u27e9\n    | isFalse hq => isFalse (fun h => hq (And.right h))\n  | isFalse hp =>\n    isFalse (fun h => hp (And.left h))\n\n@[macroInline] instance [dp : Decidable p] [dq : Decidable q] : Decidable (Or p q) :=\n  match dp with\n  | isTrue  hp => isTrue (Or.inl hp)\n  | isFalse hp =>\n    match dq with\n    | isTrue hq  => isTrue (Or.inr hq)\n    | isFalse hq =>\n      isFalse fun h => match h with\n        | Or.inl h => hp h\n        | Or.inr h => hq h\n\ninstance [dp : Decidable p] : Decidable (Not p) :=\n  match dp with\n  | isTrue hp  => isFalse (absurd hp)\n  | isFalse hp => isTrue hp\n\n/- Boolean operators -/\n\n@[macroInline] def cond {\u03b1 : Type u} (c : Bool) (x y : \u03b1) : \u03b1 :=\n  match c with\n  | true  => x\n  | false => y\n\n@[macroInline] def or (x y : Bool) : Bool :=\n  match x with\n  | true  => true\n  | false => y\n\n@[macroInline] def and (x y : Bool) : Bool :=\n  match x with\n  | false => false\n  | true  => y\n\n@[inline] def not : Bool \u2192 Bool\n  | true  => false\n  | false => true\n\ninductive Nat where\n  | zero : Nat\n  | succ (n : Nat) : Nat\n\ninstance : Inhabited Nat where\n  default := Nat.zero\n\n/- For numeric literals notation -/\nclass OfNat (\u03b1 : Type u) (n : Nat) where\n  ofNat : \u03b1\n\n@[defaultInstance 100] /- low prio -/\ninstance (n : Nat) : OfNat Nat n where\n  ofNat := n\n\nclass LE (\u03b1 : Type u) where le : \u03b1 \u2192 \u03b1 \u2192 Prop\nclass LT (\u03b1 : Type u) where lt : \u03b1 \u2192 \u03b1 \u2192 Prop\n\n@[reducible] def GE.ge {\u03b1 : Type u} [LE \u03b1] (a b : \u03b1) : Prop := LE.le b a\n@[reducible] def GT.gt {\u03b1 : Type u} [LT \u03b1] (a b : \u03b1) : Prop := LT.lt b a\n\n@[inline] def max [LT \u03b1] [DecidableRel (@LT.lt \u03b1 _)] (a b : \u03b1) : \u03b1 :=\n  ite (LT.lt b a) a b\n\n@[inline] def min [LE \u03b1] [DecidableRel (@LE.le \u03b1 _)] (a b : \u03b1) : \u03b1 :=\n  ite (LE.le a b) a b\n\nclass HAdd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAdd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HSub (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hSub : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HMul (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hMul : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HDiv (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hDiv : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HMod (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hMod : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HPow (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hPow : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HAppend (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAppend : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HOrElse (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hOrElse : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HAndThen (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAndThen : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HAnd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAnd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HXor (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hXor : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HOr (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hOr : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HShiftLeft (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hShiftLeft : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HShiftRight (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hShiftRight : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass Add (\u03b1 : Type u) where\n  add : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Sub (\u03b1 : Type u) where\n  sub : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Mul (\u03b1 : Type u) where\n  mul : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Neg (\u03b1 : Type u) where\n  neg : \u03b1 \u2192 \u03b1\n\nclass Div (\u03b1 : Type u) where\n  div : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Mod (\u03b1 : Type u) where\n  mod : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Pow (\u03b1 : Type u) where\n  pow : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Append (\u03b1 : Type u) where\n  append : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass OrElse (\u03b1 : Type u) where\n  orElse  : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass AndThen (\u03b1 : Type u) where\n  andThen : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass AndOp (\u03b1 : Type u) where\n  and : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Xor (\u03b1 : Type u) where\n  xor : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass OrOp (\u03b1 : Type u) where\n  or : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Complement (\u03b1 : Type u) where\n  complement : \u03b1 \u2192 \u03b1\n\nclass ShiftLeft (\u03b1 : Type u) where\n  shiftLeft : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass ShiftRight (\u03b1 : Type u) where\n  shiftRight : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n@[defaultInstance]\ninstance [Add \u03b1] : HAdd \u03b1 \u03b1 \u03b1 where\n  hAdd a b := Add.add a b\n\n@[defaultInstance]\ninstance [Sub \u03b1] : HSub \u03b1 \u03b1 \u03b1 where\n  hSub a b := Sub.sub a b\n\n@[defaultInstance]\ninstance [Mul \u03b1] : HMul \u03b1 \u03b1 \u03b1 where\n  hMul a b := Mul.mul a b\n\n@[defaultInstance]\ninstance [Div \u03b1] : HDiv \u03b1 \u03b1 \u03b1 where\n  hDiv a b := Div.div a b\n\n@[defaultInstance]\ninstance [Mod \u03b1] : HMod \u03b1 \u03b1 \u03b1 where\n  hMod a b := Mod.mod a b\n\n@[defaultInstance]\ninstance [Pow \u03b1] : HPow \u03b1 \u03b1 \u03b1 where\n  hPow a b := Pow.pow a b\n\n@[defaultInstance]\ninstance [Append \u03b1] : HAppend \u03b1 \u03b1 \u03b1 where\n  hAppend a b := Append.append a b\n\n@[defaultInstance]\ninstance [OrElse \u03b1] : HOrElse \u03b1 \u03b1 \u03b1 where\n  hOrElse a b := OrElse.orElse a b\n\n@[defaultInstance]\ninstance [AndThen \u03b1] : HAndThen \u03b1 \u03b1 \u03b1 where\n  hAndThen a b := AndThen.andThen a b\n\n@[defaultInstance]\ninstance [AndOp \u03b1] : HAnd \u03b1 \u03b1 \u03b1 where\n  hAnd a b := AndOp.and a b\n\n@[defaultInstance]\ninstance [Xor \u03b1] : HXor \u03b1 \u03b1 \u03b1 where\n  hXor a b := Xor.xor a b\n\n@[defaultInstance]\ninstance [OrOp \u03b1] : HOr \u03b1 \u03b1 \u03b1 where\n  hOr a b := OrOp.or a b\n\n@[defaultInstance]\ninstance [ShiftLeft \u03b1] : HShiftLeft \u03b1 \u03b1 \u03b1 where\n  hShiftLeft a b := ShiftLeft.shiftLeft a b\n\n@[defaultInstance]\ninstance [ShiftRight \u03b1] : HShiftRight \u03b1 \u03b1 \u03b1 where\n  hShiftRight a b := ShiftRight.shiftRight a b\n\nopen HAdd (hAdd)\nopen HMul (hMul)\nopen HPow (hPow)\nopen HAppend (hAppend)\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_add\"]\nprotected def Nat.add : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, Nat.zero   => a\n  | a, Nat.succ b => Nat.succ (Nat.add a b)\n\ninstance : Add Nat where\n  add := Nat.add\n\n/- We mark the following definitions as pattern to make sure they can be used in recursive equations,\n   and reduced by the equation Compiler. -/\nattribute [matchPattern] Nat.add Add.add HAdd.hAdd Neg.neg\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_mul\"]\nprotected def Nat.mul : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0          => 0\n  | a, Nat.succ b => Nat.add (Nat.mul a b) a\n\ninstance : Mul Nat where\n  mul := Nat.mul\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_pow\"]\nprotected def Nat.pow (m : @& Nat) : (@& Nat) \u2192 Nat\n  | 0      => 1\n  | succ n => Nat.mul (Nat.pow m n) m\n\ninstance : Pow Nat where\n  pow := Nat.pow\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_dec_eq\"]\ndef Nat.beq : (@& Nat) \u2192 (@& Nat) \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => false\n  | succ n, zero   => false\n  | succ n, succ m => beq n m\n\ntheorem Nat.eqOfBeqEqTrue : {n m : Nat} \u2192 Eq (beq n m) true \u2192 Eq n m\n  | zero,   zero,   h => rfl\n  | zero,   succ m, h => Bool.noConfusion h\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : Eq (beq n m) true := h\n    have : Eq n m := eqOfBeqEqTrue this\n    this \u25b8 rfl\n\ntheorem Nat.neOfBeqEqFalse : {n m : Nat} \u2192 Eq (beq n m) false \u2192 Not (Eq n m)\n  | zero,   zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | zero,   succ m, h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, zero,   h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have : Eq (beq n m) false := h\u2081\n    Nat.noConfusion h\u2082 (fun h\u2082 => absurd h\u2082 (neOfBeqEqFalse this))\n\n@[extern \"lean_nat_dec_eq\"]\nprotected def Nat.decEq (n m : @& Nat) : Decidable (Eq n m) :=\n  match h:beq n m with\n  | true  => isTrue (eqOfBeqEqTrue h)\n  | false => isFalse (neOfBeqEqFalse h)\n\n@[inline] instance : DecidableEq Nat := Nat.decEq\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_dec_le\"]\ndef Nat.ble : @& Nat \u2192 @& Nat \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => true\n  | succ n, zero   => false\n  | succ n, succ m => ble n m\n\nprotected def Nat.le (n m : Nat) : Prop :=\n  Eq (ble n m) true\n\ninstance : LE Nat where\n  le := Nat.le\n\nprotected def Nat.lt (n m : Nat) : Prop :=\n  Nat.le (succ n) m\n\ninstance : LT Nat where\n  lt := Nat.lt\n\ntheorem Nat.notSuccLeZero : \u2200 (n : Nat), LE.le (succ n) 0 \u2192 False\n  | 0,      h => nomatch h\n  | succ n, h => nomatch h\n\ntheorem Nat.notLtZero (n : Nat) : Not (LT.lt n 0) :=\n  notSuccLeZero n\n\n@[extern \"lean_nat_dec_le\"]\ninstance Nat.decLe (n m : @& Nat) : Decidable (LE.le n m) :=\n  decEq (Nat.ble n m) true\n\n@[extern \"lean_nat_dec_lt\"]\ninstance Nat.decLt (n m : @& Nat) : Decidable (LT.lt n m) :=\n  decLe (succ n) m\n\ntheorem Nat.zeroLe : (n : Nat) \u2192 LE.le 0 n\n  | zero   => rfl\n  | succ n => rfl\n\ntheorem Nat.succLeSucc {n m : Nat} (h : LE.le n m) : LE.le (succ n) (succ m) :=\n  h\n\ntheorem Nat.zeroLtSucc (n : Nat) : LT.lt 0 (succ n) :=\n  succLeSucc (zeroLe n)\n\ntheorem Nat.leStep : {n m : Nat} \u2192 LE.le n m \u2192 LE.le n (succ m)\n  | zero,   zero,   h => rfl\n  | zero,   succ n, h => rfl\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : LE.le n m := h\n    have : LE.le n (succ m) := leStep this\n    succLeSucc this\n\nprotected theorem Nat.leTrans : {n m k : Nat} \u2192 LE.le n m \u2192 LE.le m k \u2192 LE.le n k\n  | zero,   m,      k,      h\u2081, h\u2082 => zeroLe _\n  | succ n, zero,   k,      h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | succ n, succ m, zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2082\n  | succ n, succ m, succ k, h\u2081, h\u2082 =>\n    have h\u2081' : LE.le n m := h\u2081\n    have h\u2082' : LE.le m k := h\u2082\n    show LE.le n k from\n    Nat.leTrans h\u2081' h\u2082'\n\nprotected theorem Nat.ltTrans {n m k : Nat} (h\u2081 : LT.lt n m) : LT.lt m k \u2192 LT.lt n k :=\n  Nat.leTrans (leStep h\u2081)\n\ntheorem Nat.leSucc : (n : Nat) \u2192 LE.le n (succ n)\n  | zero   => rfl\n  | succ n => leSucc n\n\ntheorem Nat.leSuccOfLe {n m : Nat} (h : LE.le n m) : LE.le n (succ m) :=\n  Nat.leTrans h (leSucc m)\n\nprotected theorem Nat.eqOrLtOfLe : {n m: Nat} \u2192 LE.le n m \u2192 Or (Eq n m) (LT.lt n m)\n  | zero,   zero,   h => Or.inl rfl\n  | zero,   succ n, h => Or.inr (zeroLe n)\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : LE.le n m := h\n    match Nat.eqOrLtOfLe this with\n    | Or.inl h => Or.inl (h \u25b8 rfl)\n    | Or.inr h => Or.inr (succLeSucc h)\n\nprotected def Nat.leRefl : (n : Nat) \u2192 LE.le n n\n  | zero   => rfl\n  | succ n => Nat.leRefl n\n\nprotected theorem Nat.ltOrGe (n m : Nat) : Or (LT.lt n m) (GE.ge n m) :=\n  match m with\n  | zero   => Or.inr (zeroLe n)\n  | succ m =>\n    match Nat.ltOrGe n m with\n    | Or.inl h => Or.inl (leSuccOfLe h)\n    | Or.inr h =>\n      match Nat.eqOrLtOfLe h with\n      | Or.inl h1 => Or.inl (h1 \u25b8 Nat.leRefl _)\n      | Or.inr h1 => Or.inr h1\n\nprotected theorem Nat.leAntisymm : {n m : Nat} \u2192 LE.le n m \u2192 LE.le m n \u2192 Eq n m\n  | zero,   zero,   h\u2081, h\u2082 => rfl\n  | succ n, zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | zero,   succ m, h\u2081, h\u2082 => Bool.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have h\u2081' : LE.le n m := h\u2081\n    have h\u2082' : LE.le m n := h\u2082\n    (Nat.leAntisymm h\u2081' h\u2082') \u25b8 rfl\n\nprotected theorem Nat.ltOfLeOfNe {n m : Nat} (h\u2081 : LE.le n m) (h\u2082 : Not (Eq n m)) : LT.lt n m :=\n  match Nat.ltOrGe n m with\n  | Or.inl h\u2083 => h\u2083\n  | Or.inr h\u2083 => absurd (Nat.leAntisymm h\u2081 h\u2083) h\u2082\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"lean_nat_sub(#1, lean_box(1))\"]\ndef Nat.pred : (@& Nat) \u2192 Nat\n  | 0      => 0\n  | succ a => a\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_sub\"]\nprotected def Nat.sub : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0      => a\n  | a, succ b => pred (Nat.sub a b)\n\ninstance : Sub Nat where\n  sub := Nat.sub\n\ntheorem Nat.predLePred : {n m : Nat} \u2192 LE.le n m \u2192 LE.le (pred n) (pred m)\n  | zero,   zero,   h => rfl\n  | zero,   succ n, h => zeroLe n\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h => h\n\ntheorem Nat.leOfSuccLeSucc {n m : Nat} : LE.le (succ n) (succ m) \u2192 LE.le n m :=\n  predLePred\n\ntheorem Nat.leOfLtSucc {m n : Nat} : LT.lt m (succ n) \u2192 LE.le m n :=\n  leOfSuccLeSucc\n\n@[extern \"lean_system_platform_nbits\"] constant System.Platform.getNumBits : Unit \u2192 Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=\n  fun _ => \u27e864, Or.inr rfl\u27e9 -- inhabitant\n\ndef System.Platform.numBits : Nat :=\n  (getNumBits ()).val\n\ntheorem System.Platform.numBitsEq : Or (Eq numBits 32) (Eq numBits 64) :=\n  (getNumBits ()).property\n\nstructure Fin (n : Nat) where\n  val  : Nat\n  isLt : LT.lt val n\n\ntheorem Fin.eqOfVeq {n} : \u2200 {i j : Fin n}, Eq i.val j.val \u2192 Eq i j\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Fin.veqOfEq {n} {i j : Fin n} (h : Eq i j) : Eq i.val j.val :=\n  h \u25b8 rfl\n\ntheorem Fin.neOfVne {n} {i j : Fin n} (h : Not (Eq i.val j.val)) : Not (Eq i j) :=\n  fun h' => absurd (veqOfEq h') h\n\ninstance (n : Nat) : DecidableEq (Fin n) :=\n  fun i j =>\n    match decEq i.val j.val with\n    | isTrue h  => isTrue (Fin.eqOfVeq h)\n    | isFalse h => isFalse (Fin.neOfVne h)\n\ninstance {n} : LT (Fin n) where\n  lt a b := LT.lt a.val b.val\n\ninstance {n} : LE (Fin n) where\n  le a b := LE.le a.val b.val\n\ninstance Fin.decLt {n} (a b : Fin n) :  Decidable (LT.lt a b)  := Nat.decLt ..\ninstance Fin.decLe {n} (a b : Fin n) : Decidable (LE.le a b) := Nat.decLe ..\n\ndef UInt8.size : Nat := 256\nstructure UInt8 where\n  val : Fin UInt8.size\n\nattribute [extern \"lean_uint8_of_nat_mk\"] UInt8.mk\nattribute [extern \"lean_uint8_to_nat\"] UInt8.val\n\n@[extern \"lean_uint8_of_nat\"]\ndef UInt8.ofNatCore (n : @& Nat) (h : LT.lt n UInt8.size) : UInt8 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt8.decEq (a b : UInt8) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt8.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt8 := UInt8.decEq\n\ninstance : Inhabited UInt8 where\n  default := UInt8.ofNatCore 0 (by decide)\n\ndef UInt16.size : Nat := 65536\nstructure UInt16 where\n  val : Fin UInt16.size\n\nattribute [extern \"lean_uint16_of_nat_mk\"] UInt16.mk\nattribute [extern \"lean_uint16_to_nat\"] UInt16.val\n\n@[extern \"lean_uint16_of_nat\"]\ndef UInt16.ofNatCore (n : @& Nat) (h : LT.lt n UInt16.size) : UInt16 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt16.decEq (a b : UInt16) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt16.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt16 := UInt16.decEq\n\ninstance : Inhabited UInt16 where\n  default := UInt16.ofNatCore 0 (by decide)\n\ndef UInt32.size : Nat := 4294967296\nstructure UInt32 where\n  val : Fin UInt32.size\n\nattribute [extern \"lean_uint32_of_nat_mk\"] UInt32.mk\nattribute [extern \"lean_uint32_to_nat\"] UInt32.val\n\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNatCore (n : @& Nat) (h : LT.lt n UInt32.size) : UInt32 := {\n  val := { val := n, isLt := h }\n}\n\n@[extern \"lean_uint32_to_nat\"]\ndef UInt32.toNat (n : UInt32) : Nat := n.val.val\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt32.decEq (a b : UInt32) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt32.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt32 := UInt32.decEq\n\ninstance : Inhabited UInt32 where\n  default := UInt32.ofNatCore 0 (by decide)\n\ninstance : LT UInt32 where\n  lt a b := LT.lt a.val b.val\n\ninstance : LE UInt32 where\n  le a b := LE.le a.val b.val\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 < #2\"]\ndef UInt32.decLt (a b : UInt32) : Decidable (LT.lt a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LT.lt n m))\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 <= #2\"]\ndef UInt32.decLe (a b : UInt32) : Decidable (LE.le a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LE.le n m))\n\ninstance (a b : UInt32) : Decidable (LT.lt a b) := UInt32.decLt a b\ninstance (a b : UInt32) : Decidable (LE.le a b) := UInt32.decLe a b\n\ndef UInt64.size : Nat := 18446744073709551616\nstructure UInt64 where\n  val : Fin UInt64.size\n\nattribute [extern \"lean_uint64_of_nat_mk\"] UInt64.mk\nattribute [extern \"lean_uint64_to_nat\"] UInt64.val\n\n@[extern \"lean_uint64_of_nat\"]\ndef UInt64.ofNatCore (n : @& Nat) (h : LT.lt n UInt64.size) : UInt64 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt64.decEq (a b : UInt64) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt64.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt64 := UInt64.decEq\n\ninstance : Inhabited UInt64 where\n  default := UInt64.ofNatCore 0 (by decide)\n\ndef USize.size : Nat := hPow 2 System.Platform.numBits\n\ntheorem usizeSzEq : Or (Eq USize.size 4294967296) (Eq USize.size 18446744073709551616) :=\n  show Or (Eq (hPow 2 System.Platform.numBits) 4294967296) (Eq (hPow 2 System.Platform.numBits) 18446744073709551616) from\n  match System.Platform.numBits, System.Platform.numBitsEq with\n  | _, Or.inl rfl => Or.inl (by decide)\n  | _, Or.inr rfl => Or.inr (by decide)\n\nstructure USize where\n  val : Fin USize.size\n\nattribute [extern \"lean_usize_of_nat_mk\"] USize.mk\nattribute [extern \"lean_usize_to_nat\"] USize.val\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNatCore (n : @& Nat) (h : LT.lt n USize.size) : USize := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef USize.decEq (a b : USize) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h =>isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => USize.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq USize := USize.decEq\n\ninstance : Inhabited USize where\n  default := USize.ofNatCore 0 (match USize.size, usizeSzEq with\n    | _, Or.inl rfl => by decide\n    | _, Or.inr rfl => by decide)\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNat32 (n : @& Nat) (h : LT.lt n 4294967296) : USize := {\n  val := {\n    val  := n\n    isLt := match USize.size, usizeSzEq with\n      | _, Or.inl rfl => h\n      | _, Or.inr rfl => Nat.ltTrans h (by decide)\n  }\n}\n\nabbrev Nat.isValidChar (n : Nat) : Prop :=\n  Or (LT.lt n 0xd800) (And (LT.lt 0xdfff n) (LT.lt n 0x110000))\n\nabbrev UInt32.isValidChar (n : UInt32) : Prop :=\n  n.toNat.isValidChar\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   : UInt32\n  valid : val.isValidChar\n\nprivate theorem validCharIsUInt32 {n : Nat} (h : n.isValidChar) : LT.lt n UInt32.size :=\n  match h with\n  | Or.inl h      => Nat.ltTrans h (by decide)\n  | Or.inr \u27e8_, h\u27e9 => Nat.ltTrans h (by decide)\n\n@[extern \"lean_uint32_of_nat\"]\nprivate def Char.ofNatAux (n : @& Nat) (h : n.isValidChar) : Char :=\n  { val := \u27e8{ val := n, isLt := validCharIsUInt32 h }\u27e9, valid := h }\n\n@[noinline, matchPattern]\ndef Char.ofNat (n : Nat) : Char :=\n  dite (n.isValidChar)\n    (fun h => Char.ofNatAux n h)\n    (fun _ => { val := \u27e8{ val := 0, isLt := by decide }\u27e9, valid := Or.inl (by decide) })\n\ntheorem Char.eqOfVeq : \u2200 {c d : Char}, Eq c.val d.val \u2192 Eq c d\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Char.veqOfEq : \u2200 {c d : Char}, Eq c d \u2192 Eq c.val d.val\n  | _, _, rfl => rfl\n\ntheorem Char.neOfVne {c d : Char} (h : Not (Eq c.val d.val)) : Not (Eq c d) :=\n  fun h' => absurd (veqOfEq h') h\n\ntheorem Char.vneOfNe {c d : Char} (h : Not (Eq c d)) : Not (Eq c.val d.val) :=\n  fun h' => absurd (eqOfVeq h') h\n\ninstance : DecidableEq Char :=\n  fun c d =>\n    match decEq c.val d.val with\n    | isTrue h  => isTrue (Char.eqOfVeq h)\n    | isFalse h => isFalse (Char.neOfVne h)\n\ndef Char.utf8Size (c : Char) : UInt32 :=\n  let v := c.val\n  ite (LE.le v (UInt32.ofNatCore 0x7F (by decide)))\n    (UInt32.ofNatCore 1 (by decide))\n    (ite (LE.le v (UInt32.ofNatCore 0x7FF (by decide)))\n      (UInt32.ofNatCore 2 (by decide))\n      (ite (LE.le v (UInt32.ofNatCore 0xFFFF (by decide)))\n        (UInt32.ofNatCore 3 (by decide))\n        (UInt32.ofNatCore 4 (by decide))))\n\ninductive Option (\u03b1 : Type u) where\n  | none : Option \u03b1\n  | some (val : \u03b1) : Option \u03b1\n\nattribute [unbox] Option\n\nexport Option (none some)\n\ninstance {\u03b1} : Inhabited (Option \u03b1) where\n  default := none\n\n@[macroInline] def Option.getD : Option \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  | some x, _ => x\n  | none,   e => e\n\ninductive List (\u03b1 : Type u) where\n  | nil : List \u03b1\n  | cons (head : \u03b1) (tail : List \u03b1) : List \u03b1\n\ninstance {\u03b1} : Inhabited (List \u03b1) where\n  default := List.nil\n\nprotected def List.hasDecEq {\u03b1: Type u} [DecidableEq \u03b1] : (a b : List \u03b1) \u2192 Decidable (Eq a b)\n  | nil,       nil       => isTrue rfl\n  | cons a as, nil       => isFalse (fun h => List.noConfusion h)\n  | nil,       cons b bs => isFalse (fun h => List.noConfusion h)\n  | cons a as, cons b bs =>\n    match decEq a b with\n    | isTrue hab  =>\n      match List.hasDecEq as bs with\n      | isTrue habs  => isTrue (hab \u25b8 habs \u25b8 rfl)\n      | isFalse nabs => isFalse (fun h => List.noConfusion h (fun _ habs => absurd habs nabs))\n    | isFalse nab => isFalse (fun h => List.noConfusion h (fun hab _ => absurd hab nab))\n\ninstance {\u03b1 : Type u} [DecidableEq \u03b1] : DecidableEq (List \u03b1) := List.hasDecEq\n\n@[specialize]\ndef List.foldl {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) : (init : \u03b1) \u2192 List \u03b2 \u2192 \u03b1\n  | a, nil      => a\n  | a, cons b l => foldl f (f a b) l\n\ndef List.set : List \u03b1 \u2192 Nat \u2192 \u03b1 \u2192 List \u03b1\n  | cons a as, 0,          b => cons b as\n  | cons a as, Nat.succ n, b => cons a (set as n b)\n  | nil,       _,          _ => nil\n\ndef List.lengthAux {\u03b1 : Type u} : List \u03b1 \u2192 Nat \u2192 Nat\n  | nil,       n => n\n  | cons a as, n => lengthAux as (Nat.succ n)\n\ndef List.length {\u03b1 : Type u} (as : List \u03b1) : Nat :=\n  lengthAux as 0\n\n@[simp] theorem List.length_cons {\u03b1} (a : \u03b1) (as : List \u03b1) : Eq (cons a as).length as.length.succ :=\n  let rec aux (a : \u03b1) (as : List \u03b1) : (n : Nat) \u2192 Eq ((cons a as).lengthAux n) (as.lengthAux n).succ :=\n    match as with\n    | nil       => fun _ => rfl\n    | cons a as => fun n => aux a as n.succ\n  aux a as 0\n\ndef List.concat {\u03b1 : Type u} : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1\n  | nil,       b => cons b nil\n  | cons a as, b => cons a (concat as b)\n\ndef List.get {\u03b1 : Type u} : (as : List \u03b1) \u2192 (i : Nat) \u2192 LT.lt i as.length \u2192 \u03b1\n  | nil,       i,          h => absurd h (Nat.notLtZero _)\n  | cons a as, 0,          h => a\n  | cons a as, Nat.succ i, h =>\n    have : LT.lt i.succ as.length.succ := length_cons .. \u25b8 h\n    get as i (Nat.leOfSuccLeSucc this)\n\nstructure String where\n  data : List Char\n\nattribute [extern \"lean_string_mk\"] String.mk\nattribute [extern \"lean_string_data\"] String.data\n\n@[extern \"lean_string_dec_eq\"]\ndef String.decEq (s\u2081 s\u2082 : @& String) : Decidable (Eq s\u2081 s\u2082) :=\n  match s\u2081, s\u2082 with\n  | \u27e8s\u2081\u27e9, \u27e8s\u2082\u27e9 =>\n    dite (Eq s\u2081 s\u2082) (fun h => isTrue (congrArg _ h)) (fun h => isFalse (fun h' => String.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq String := String.decEq\n\n/-- A byte position in a `String`. Internally, `String`s are UTF-8 encoded.\nCodepoint positions (counting the Unicode codepoints rather than bytes)\nare represented by plain `Nat`s instead.\nIndexing a `String` by a byte position is constant-time, while codepoint\npositions need to be translated internally to byte positions in linear-time. -/\nabbrev String.Pos := Nat\n\nstructure Substring where\n  str : String\n  startPos : String.Pos\n  stopPos : String.Pos\n\n@[inline] def Substring.bsize : Substring \u2192 Nat\n  | \u27e8_, b, e\u27e9 => e.sub b\n\ndef String.csize (c : Char) : Nat :=\n  c.utf8Size.toNat\n\nprivate def String.utf8ByteSizeAux : List Char \u2192 Nat \u2192 Nat\n  | List.nil,       r => r\n  | List.cons c cs, r => utf8ByteSizeAux cs (hAdd r (csize c))\n\n@[extern \"lean_string_utf8_byte_size\"]\ndef String.utf8ByteSize : (@& String) \u2192 Nat\n  | \u27e8s\u27e9 => utf8ByteSizeAux s 0\n\n@[inline] def String.bsize (s : String) : Nat :=\n  utf8ByteSize s\n\n@[inline] def String.toSubstring (s : String) : Substring := {\n  str      := s\n  startPos := 0\n  stopPos  := s.bsize\n}\n\n@[extern c inline \"#3\"]\nunsafe def unsafeCast {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) : \u03b2 :=\n  cast lcProof (PUnit.{v})\n\n@[neverExtract, extern \"lean_panic_fn\"]\nconstant panic {\u03b1 : Type u} [Inhabited \u03b1] (msg : String) : \u03b1\n\n/-\nThe Compiler has special support for arrays.\nThey are implemented using dynamic arrays: https://en.wikipedia.org/wiki/Dynamic_array\n-/\nstructure Array (\u03b1 : Type u) where\n  data : List \u03b1\n\nattribute [extern \"lean_array_data\"] Array.data\nattribute [extern \"lean_array_mk\"] Array.mk\n\n/- The parameter `c` is the initial capacity -/\n@[extern \"lean_mk_empty_array_with_capacity\"]\ndef Array.mkEmpty {\u03b1 : Type u} (c : @& Nat) : Array \u03b1 := {\n  data := List.nil\n}\n\ndef Array.empty {\u03b1 : Type u} : Array \u03b1 :=\n  mkEmpty 0\n\n@[reducible, extern \"lean_array_get_size\"]\ndef Array.size {\u03b1 : Type u} (a : @& Array \u03b1) : Nat :=\n a.data.length\n\n@[extern \"lean_array_fget\"]\ndef Array.get {\u03b1 : Type u} (a : @& Array \u03b1) (i : @& Fin a.size) : \u03b1 :=\n  a.data.get i.val i.isLt\n\n@[inline] def Array.getD (a : Array \u03b1) (i : Nat) (v\u2080 : \u03b1) : \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.get \u27e8i, h\u27e9) (fun _ => v\u2080)\n\n/- \"Comfortable\" version of `fget`. It performs a bound check at runtime. -/\n@[extern \"lean_array_get\"]\ndef Array.get! {\u03b1 : Type u} [Inhabited \u03b1] (a : @& Array \u03b1) (i : @& Nat) : \u03b1 :=\n  Array.getD a i arbitrary\n\ndef Array.getOp {\u03b1 : Type u} [Inhabited \u03b1] (self : Array \u03b1) (idx : Nat) : \u03b1 :=\n  self.get! idx\n\n@[extern \"lean_array_push\"]\ndef Array.push {\u03b1 : Type u} (a : Array \u03b1) (v : \u03b1) : Array \u03b1 := {\n  data := List.concat a.data v\n}\n\n@[extern \"lean_array_fset\"]\ndef Array.set (a : Array \u03b1) (i : @& Fin a.size) (v : \u03b1) : Array \u03b1 := {\n  data := a.data.set i.val v\n}\n\n@[inline] def Array.setD (a : Array \u03b1) (i : Nat) (v : \u03b1) : Array \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.set \u27e8i, h\u27e9 v) (fun _ => a)\n\n@[extern \"lean_array_set\"]\ndef Array.set! (a : Array \u03b1) (i : @& Nat) (v : \u03b1) : Array \u03b1 :=\n  Array.setD a i v\n\n-- Slower `Array.append` used in quotations.\nprotected def Array.appendCore {\u03b1 : Type u}  (as : Array \u03b1) (bs : Array \u03b1) : Array \u03b1 :=\n  let rec loop (i : Nat) (j : Nat) (as : Array \u03b1) : Array \u03b1 :=\n    dite (LT.lt j bs.size)\n      (fun hlt =>\n        match i with\n        | 0           => as\n        | Nat.succ i' => loop i' (hAdd j 1) (as.push (bs.get \u27e8j, hlt\u27e9)))\n      (fun _ => as)\n  loop bs.size 0 as\n\n@[inlineIfReduce]\ndef List.toArrayAux : List \u03b1 \u2192 Array \u03b1 \u2192 Array \u03b1\n  | nil,       r => r\n  | cons a as, r => toArrayAux as (r.push a)\n\n@[inlineIfReduce]\ndef List.redLength : List \u03b1 \u2192 Nat\n  | nil       => 0\n  | cons _ as => as.redLength.succ\n\n@[inline, matchPattern, export lean_list_to_array]\ndef List.toArray (as : List \u03b1) : Array \u03b1 :=\n  as.toArrayAux (Array.mkEmpty as.redLength)\n\nclass Bind (m : Type u \u2192 Type v) where\n  bind : {\u03b1 \u03b2 : Type u} \u2192 m \u03b1 \u2192 (\u03b1 \u2192 m \u03b2) \u2192 m \u03b2\n\nexport Bind (bind)\n\nclass Pure (f : Type u \u2192 Type v) where\n  pure {\u03b1 : Type u} : \u03b1 \u2192 f \u03b1\n\nexport Pure (pure)\n\nclass Functor (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  map      : {\u03b1 \u03b2 : Type u} \u2192 (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n  mapConst : {\u03b1 \u03b2 : Type u} \u2192 \u03b1 \u2192 f \u03b2 \u2192 f \u03b1 := Function.comp map (Function.const _)\n\nclass Seq (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seq  : {\u03b1 \u03b2 : Type u} \u2192 f (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n\nclass SeqLeft (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seqLeft : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 f \u03b2 \u2192 f \u03b1\n\nclass SeqRight (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seqRight : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 f \u03b2 \u2192 f \u03b2\n\nclass Applicative (f : Type u \u2192 Type v) extends Functor f, Pure f, Seq f, SeqLeft f, SeqRight f where\n  map      := fun x y => Seq.seq (pure x) y\n  seqLeft  := fun a b => Seq.seq (Functor.map (Function.const _) a) b\n  seqRight := fun a b => Seq.seq (Functor.map (Function.const _ id) a) b\n\nclass Monad (m : Type u \u2192 Type v) extends Applicative m, Bind m : Type (max (u+1) v) where\n  map      f x := bind x (Function.comp pure f)\n  seq      f x := bind f fun y => Functor.map y x\n  seqLeft  x y := bind x fun a => bind y (fun _ => pure a)\n  seqRight x y := bind x fun _ => y\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] : Inhabited (\u03b1 \u2192 m \u03b1) where\n  default := pure\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] [Inhabited \u03b1] : Inhabited (m \u03b1) where\n  default := pure arbitrary\n\n-- A fusion of Haskell's `sequence` and `map`\ndef Array.sequenceMap {\u03b1 : Type u} {\u03b2 : Type v} {m : Type v \u2192 Type w} [Monad m] (as : Array \u03b1) (f : \u03b1 \u2192 m \u03b2) : m (Array \u03b2) :=\n  let rec loop (i : Nat) (j : Nat) (bs : Array \u03b2) : m (Array \u03b2) :=\n    dite (LT.lt j as.size)\n      (fun hlt =>\n        match i with\n        | 0           => pure bs\n        | Nat.succ i' => Bind.bind (f (as.get \u27e8j, hlt\u27e9)) fun b => loop i' (hAdd j 1) (bs.push b))\n      (fun _ => bs)\n  loop as.size 0 Array.empty\n\n/-- A Function for lifting a computation from an inner Monad to an outer Monad.\n    Like [MonadTrans](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Class.html),\n    but `n` does not have to be a monad transformer.\n    Alternatively, an implementation of [MonadLayer](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLayer) without `layerInvmap` (so far). -/\nclass MonadLift (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadLift`.\n    `monadLift` is used to transitively lift monadic computations such as `StateT.get` or `StateT.put s`.\n    Corresponds to [MonadLift](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLift). -/\nclass MonadLiftT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\nexport MonadLiftT (monadLift)\n\nabbrev liftM := @monadLift\n\ninstance (m n o) [MonadLift n o] [MonadLiftT m n] : MonadLiftT m o where\n  monadLift x := MonadLift.monadLift (m := n) (monadLift x)\n\ninstance (m) : MonadLiftT m m where\n  monadLift x := x\n\n/-- A functor in the category of monads. Can be used to lift monad-transforming functions.\n    Based on pipes' [MFunctor](https://hackage.haskell.org/package/pipes-2.4.0/docs/Control-MFunctor.html),\n    but not restricted to monad transformers.\n    Alternatively, an implementation of [MonadTransFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadTransFunctor). -/\nclass MonadFunctor (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadFunctor`.\n    `monadMap` is used to transitively lift Monad morphisms -/\nclass MonadFunctorT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\nexport MonadFunctorT (monadMap)\n\ninstance (m n o) [MonadFunctor n o] [MonadFunctorT m n] : MonadFunctorT m o where\n  monadMap f := MonadFunctor.monadMap (m := n) (monadMap (m := m) f)\n\ninstance monadFunctorRefl (m) : MonadFunctorT m m where\n  monadMap f := f\n\ninductive Except (\u03b5 : Type u) (\u03b1 : Type v) where\n  | error : \u03b5 \u2192 Except \u03b5 \u03b1\n  | ok    : \u03b1 \u2192 Except \u03b5 \u03b1\n\nattribute [unbox] Except\n\ninstance {\u03b5 : Type u} {\u03b1 : Type v} [Inhabited \u03b5] : Inhabited (Except \u03b5 \u03b1) where\n  default := Except.error arbitrary\n\n/-- An implementation of [MonadError](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Except.html#t:MonadError) -/\nclass MonadExceptOf (\u03b5 : Type u) (m : Type v \u2192 Type w) where\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\nabbrev throwThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (e : \u03b5) : m \u03b1 :=\n  MonadExceptOf.throw e\n\nabbrev tryCatchThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (x : m \u03b1) (handle : \u03b5 \u2192 m \u03b1) : m \u03b1 :=\n  MonadExceptOf.tryCatch x handle\n\n/-- Similar to `MonadExceptOf`, but `\u03b5` is an outParam for convenience -/\nclass MonadExcept (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) where\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\nexport MonadExcept (throw tryCatch)\n\ninstance (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) [MonadExceptOf \u03b5 m] : MonadExcept \u03b5 m where\n  throw    := throwThe \u03b5\n  tryCatch := tryCatchThe \u03b5\n\nnamespace MonadExcept\nvariable {\u03b5 : Type u} {m : Type v \u2192 Type w}\n\n@[inline] protected def orelse [MonadExcept \u03b5 m] {\u03b1 : Type v} (t\u2081 t\u2082 : m \u03b1) : m \u03b1 :=\n  tryCatch t\u2081 fun _ => t\u2082\n\ninstance [MonadExcept \u03b5 m] {\u03b1 : Type v} : OrElse (m \u03b1) where\n  orElse := MonadExcept.orelse\n\nend MonadExcept\n\n/-- An implementation of [ReaderT](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Reader.html#t:ReaderT) -/\ndef ReaderT (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) : Type (max u v) :=\n  \u03c1 \u2192 m \u03b1\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) [Inhabited (m \u03b1)] : Inhabited (ReaderT \u03c1 m \u03b1) where\n  default := fun _ => arbitrary\n\n@[inline] def ReaderT.run {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u} (x : ReaderT \u03c1 m \u03b1) (r : \u03c1) : m \u03b1 :=\n  x r\n\nnamespace ReaderT\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u}\n\ninstance  : MonadLift m (ReaderT \u03c1 m) where\n  monadLift x := fun _ => x\n\ninstance (\u03b5) [MonadExceptOf \u03b5 m] : MonadExceptOf \u03b5 (ReaderT \u03c1 m) where\n  throw e  := liftM (m := m) (throw e)\n  tryCatch := fun x c r => tryCatchThe \u03b5 (x r) (fun e => (c e) r)\n\nend\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] {\u03b1 \u03b2 : Type u}\n\n@[inline] protected def read : ReaderT \u03c1 m \u03c1 :=\n  pure\n\n@[inline] protected def pure (a : \u03b1) : ReaderT \u03c1 m \u03b1 :=\n  fun r => pure a\n\n@[inline] protected def bind (x : ReaderT \u03c1 m \u03b1) (f : \u03b1 \u2192 ReaderT \u03c1 m \u03b2) : ReaderT \u03c1 m \u03b2 :=\n  fun r => bind (x r) fun a => f a r\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : ReaderT \u03c1 m \u03b1) : ReaderT \u03c1 m \u03b2 :=\n  fun r => Functor.map f (x r)\n\ninstance : Monad (ReaderT \u03c1 m) where\n  pure := ReaderT.pure\n  bind := ReaderT.bind\n  map  := ReaderT.map\n\ninstance (\u03c1 m) [Monad m] : MonadFunctor m (ReaderT \u03c1 m) where\n  monadMap f x := fun ctx => f (x ctx)\n\n@[inline] protected def adapt {\u03c1' : Type u} [Monad m] {\u03b1 : Type u} (f : \u03c1' \u2192 \u03c1) : ReaderT \u03c1 m \u03b1 \u2192 ReaderT \u03c1' m \u03b1 :=\n  fun x r => x (f r)\n\nend\nend ReaderT\n\n/-- An implementation of [MonadReader](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Reader-Class.html#t:MonadReader).\n    It does not contain `local` because this Function cannot be lifted using `monadLift`.\n    Instead, the `MonadReaderAdapter` class provides the more general `adaptReader` Function.\n\n    Note: This class can be seen as a simplification of the more \"principled\" definition\n    ```\n    class MonadReader (\u03c1 : outParam (Type u)) (n : Type u \u2192 Type u) where\n      lift {\u03b1 : Type u} : ({m : Type u \u2192 Type u} \u2192 [Monad m] \u2192 ReaderT \u03c1 m \u03b1) \u2192 n \u03b1\n    ```\n    -/\nclass MonadReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  read : m \u03c1\n\n@[inline] def readThe (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadReaderOf \u03c1 m] : m \u03c1 :=\n  MonadReaderOf.read\n\n/-- Similar to `MonadReaderOf`, but `\u03c1` is an outParam for convenience -/\nclass MonadReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  read : m \u03c1\n\nexport MonadReader (read)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadReaderOf \u03c1 m] : MonadReader \u03c1 m where\n  read := readThe \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadReaderOf \u03c1 m] : MonadReaderOf \u03c1 n where\n  read := liftM (m := m) read\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadReaderOf \u03c1 (ReaderT \u03c1 m) where\n  read := ReaderT.read\n\nclass MonadWithReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\n@[inline] def withTheReader (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadWithReaderOf \u03c1 m] {\u03b1 : Type u} (f : \u03c1 \u2192 \u03c1) (x : m \u03b1) : m \u03b1 :=\n  MonadWithReaderOf.withReader f x\n\nclass MonadWithReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadWithReader (withReader)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadWithReaderOf \u03c1 m] : MonadWithReader \u03c1 m where\n  withReader := withTheReader \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type v} [MonadFunctor m n] [MonadWithReaderOf \u03c1 m] : MonadWithReaderOf \u03c1 n where\n  withReader f := monadMap (m := m) (withTheReader \u03c1 f)\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadWithReaderOf \u03c1 (ReaderT \u03c1 m) where\n  withReader f x := fun ctx => x (f ctx)\n\n/-- An implementation of [MonadState](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-State-Class.html).\n    In contrast to the Haskell implementation, we use overlapping instances to derive instances\n    automatically from `monadLift`. -/\nclass MonadStateOf (\u03c3 : Type u) (m : Type u \u2192 Type v) where\n  /- Obtain the top-most State of a Monad stack. -/\n  get : m \u03c3\n  /- Set the top-most State of a Monad stack. -/\n  set : \u03c3 \u2192 m PUnit\n  /- Map the top-most State of a Monad stack.\n\n     Note: `modifyGet f` may be preferable to `do s <- get; let (a, s) := f s; put s; pure a`\n     because the latter does not use the State linearly (without sufficient inlining). -/\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadStateOf (set)\n\nabbrev getThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] : m \u03c3 :=\n  MonadStateOf.get\n\n@[inline] abbrev modifyThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  MonadStateOf.modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] abbrev modifyGetThe {\u03b1 : Type u} (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : m \u03b1 :=\n  MonadStateOf.modifyGet f\n\n/-- Similar to `MonadStateOf`, but `\u03c3` is an outParam for convenience -/\nclass MonadState (\u03c3 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  get : m \u03c3\n  set : \u03c3 \u2192 m PUnit\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadState (get modifyGet)\n\ninstance (\u03c3 : Type u) (m : Type u \u2192 Type v) [MonadStateOf \u03c3 m] : MonadState \u03c3 m where\n  set         := MonadStateOf.set\n  get         := getThe \u03c3\n  modifyGet f := MonadStateOf.modifyGet f\n\n@[inline] def modify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] def getModify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] [Monad m] (f : \u03c3 \u2192 \u03c3) : m \u03c3 :=\n  modifyGet fun s => (s, f s)\n\n-- NOTE: The Ordering of the following two instances determines that the top-most `StateT` Monad layer\n-- will be picked first\ninstance {\u03c3 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadStateOf \u03c3 m] : MonadStateOf \u03c3 n where\n  get         := liftM (m := m) MonadStateOf.get\n  set       s := liftM (m := m) (MonadStateOf.set s)\n  modifyGet f := monadLift (m := m) (MonadState.modifyGet f)\n\nnamespace EStateM\n\ninductive Result (\u03b5 \u03c3 \u03b1 : Type u) where\n  | ok    : \u03b1 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n  | error : \u03b5 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nvariable {\u03b5 \u03c3 \u03b1 : Type u}\n\ninstance [Inhabited \u03b5] [Inhabited \u03c3] : Inhabited (Result \u03b5 \u03c3 \u03b1) where\n  default := Result.error arbitrary arbitrary\n\nend EStateM\n\nopen EStateM (Result) in\ndef EStateM (\u03b5 \u03c3 \u03b1 : Type u) := \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nnamespace EStateM\n\nvariable {\u03b5 \u03c3 \u03b1 \u03b2 : Type u}\n\ninstance [Inhabited \u03b5] : Inhabited (EStateM \u03b5 \u03c3 \u03b1) where\n  default := fun s => Result.error arbitrary s\n\n@[inline] protected def pure (a : \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.ok a s\n\n@[inline] protected def set (s : \u03c3) : EStateM \u03b5 \u03c3 PUnit := fun _ =>\n  Result.ok \u27e8\u27e9 s\n\n@[inline] protected def get : EStateM \u03b5 \u03c3 \u03c3 := fun s =>\n  Result.ok s s\n\n@[inline] protected def modifyGet (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  match f s with\n  | (a, s) => Result.ok a s\n\n@[inline] protected def throw (e : \u03b5) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.error e s\n\n/-- Auxiliary instance for saving/restoring the \"backtrackable\" part of the state. -/\nclass Backtrackable (\u03b4 : outParam (Type u)) (\u03c3 : Type u) where\n  save    : \u03c3 \u2192 \u03b4\n  restore : \u03c3 \u2192 \u03b4 \u2192 \u03c3\n\n@[inline] protected def tryCatch {\u03b4} [Backtrackable \u03b4 \u03c3] {\u03b1} (x : EStateM \u03b5 \u03c3 \u03b1) (handle : \u03b5 \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s\n  match x s with\n  | Result.error e s => handle e (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] protected def orElse {\u03b4} [Backtrackable \u03b4 \u03c3] (x\u2081 x\u2082 : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s;\n  match x\u2081 s with\n  | Result.error _ s => x\u2082 (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] def adaptExcept {\u03b5' : Type u} (f : \u03b5 \u2192 \u03b5') (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5' \u03c3 \u03b1 := fun s =>\n  match x s with\n  | Result.error e s => Result.error (f e) s\n  | Result.ok a s    => Result.ok a s\n\n@[inline] protected def bind (x : EStateM \u03b5 \u03c3 \u03b1) (f : \u03b1 \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => f a s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => Result.ok (f a) s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def seqRight (x : EStateM \u03b5 \u03c3 \u03b1) (y : EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok _ s    => y s\n  | Result.error e s => Result.error e s\n\ninstance : Monad (EStateM \u03b5 \u03c3) where\n  bind     := EStateM.bind\n  pure     := EStateM.pure\n  map      := EStateM.map\n  seqRight := EStateM.seqRight\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : OrElse (EStateM \u03b5 \u03c3 \u03b1) where\n  orElse := EStateM.orElse\n\ninstance : MonadStateOf \u03c3 (EStateM \u03b5 \u03c3) where\n  set       := EStateM.set\n  get       := EStateM.get\n  modifyGet := EStateM.modifyGet\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : MonadExceptOf \u03b5 (EStateM \u03b5 \u03c3) where\n  throw    := EStateM.throw\n  tryCatch := EStateM.tryCatch\n\n@[inline] def run (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Result \u03b5 \u03c3 \u03b1 :=\n  x s\n\n@[inline] def run' (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Option \u03b1 :=\n  match run x s with\n  | Result.ok v _   => some v\n  | Result.error .. => none\n\n@[inline] def dummySave : \u03c3 \u2192 PUnit := fun _ => \u27e8\u27e9\n\n@[inline] def dummyRestore : \u03c3 \u2192 PUnit \u2192 \u03c3 := fun s _ => s\n\n/- Dummy default instance -/\ninstance nonBacktrackable : Backtrackable PUnit \u03c3 where\n  save    := dummySave\n  restore := dummyRestore\n\nend EStateM\n\nclass Hashable (\u03b1 : Sort u) where\n  hash : \u03b1 \u2192 UInt64\n\nexport Hashable (hash)\n\n@[extern c inline \"(size_t)#1\"]\nconstant UInt64.toUSize (u : UInt64) : USize\n\n@[extern c inline \"(uint64_t)#1\"]\nconstant USize.toUInt64 (u : USize) : UInt64\n\n@[extern \"lean_uint64_mix_hash\"]\nconstant mixHash (u\u2081 u\u2082 : UInt64) : UInt64\n\n@[extern \"lean_string_hash\"]\nprotected constant String.hash (s : @& String) : UInt64\n\ninstance : Hashable String where\n  hash := String.hash\n\nnamespace Lean\n\n/- Hierarchical names -/\ninductive Name where\n  | anonymous : Name\n  | str : Name \u2192 String \u2192 UInt64 \u2192 Name\n  | num : Name \u2192 Nat \u2192 UInt64 \u2192 Name\n\ninstance : Inhabited Name where\n  default := Name.anonymous\n\nprotected def Name.hash : Name \u2192 UInt64\n  | Name.anonymous => UInt64.ofNatCore 1723 (by decide)\n  | Name.str p s h => h\n  | Name.num p v h => h\n\ninstance : Hashable Name where\n  hash := Name.hash\n\nnamespace Name\n\n@[export lean_name_mk_string]\ndef mkStr (p : Name) (s : String) : Name :=\n  Name.str p s (mixHash (hash p) (hash s))\n\n@[export lean_name_mk_numeral]\ndef mkNum (p : Name) (v : Nat) : Name :=\n  Name.num p v (mixHash (hash p) (dite (LT.lt v UInt64.size) (fun h => UInt64.ofNatCore v h) (fun _ => UInt64.ofNatCore 17 (by decide))))\n\ndef mkSimple (s : String) : Name :=\n  mkStr Name.anonymous s\n\n@[extern \"lean_name_eq\"]\nprotected def beq : (@& Name) \u2192 (@& Name) \u2192 Bool\n  | anonymous,   anonymous   => true\n  | str p\u2081 s\u2081 _, str p\u2082 s\u2082 _ => and (BEq.beq s\u2081 s\u2082) (Name.beq p\u2081 p\u2082)\n  | num p\u2081 n\u2081 _, num p\u2082 n\u2082 _ => and (BEq.beq n\u2081 n\u2082) (Name.beq p\u2081 p\u2082)\n  | _,           _           => false\n\ninstance : BEq Name where\n  beq := Name.beq\n\nprotected def append : Name \u2192 Name \u2192 Name\n  | n, anonymous => n\n  | n, str p s _ => Name.mkStr (Name.append n p) s\n  | n, num p d _ => Name.mkNum (Name.append n p) d\n\ninstance : Append Name where\n  append := Name.append\n\nend Name\n\n/- Syntax -/\n\n/-- Source information of tokens. -/\ninductive SourceInfo where\n  /-\n    Token from original input with whitespace and position information.\n    `leading` will be inferred after parsing by `Syntax.updateLeading`. During parsing,\n    it is not at all clear what the preceding token was, especially with backtracking. -/\n  | original (leading : Substring) (pos : String.Pos) (trailing : Substring) (endPos : String.Pos)\n  /-\n    Synthesized token (e.g. from a quotation) annotated with a span from the original source.\n    In the delaborator, we \"misuse\" this constructor to store synthetic positions identifying\n    subterms. -/\n  | synthetic (pos : String.Pos) (endPos : String.Pos)\n  /- Synthesized token without position information. -/\n  | protected none\n\ninstance : Inhabited SourceInfo := \u27e8SourceInfo.none\u27e9\n\nnamespace SourceInfo\n\ndef getPos? (info : SourceInfo) (originalOnly := false) : Option String.Pos :=\n  match info, originalOnly with\n  | original (pos := pos) ..,  _     => some pos\n  | synthetic (pos := pos) .., false => some pos\n  | _,                         _     => none\n\nend SourceInfo\n\nabbrev SyntaxNodeKind := Name\n\n/- Syntax AST -/\n\ninductive Syntax where\n  | missing : Syntax\n  | node   (kind : SyntaxNodeKind) (args : Array Syntax) : Syntax\n  | atom   (info : SourceInfo) (val : String) : Syntax\n  | ident  (info : SourceInfo) (rawVal : Substring) (val : Name) (preresolved : List (Prod Name (List String))) : Syntax\n\ninstance : Inhabited Syntax where\n  default := Syntax.missing\n\n/- Builtin kinds -/\ndef choiceKind : SyntaxNodeKind := `choice\ndef nullKind : SyntaxNodeKind := `null\ndef groupKind : SyntaxNodeKind := `group\ndef identKind : SyntaxNodeKind := `ident\ndef strLitKind : SyntaxNodeKind := `strLit\ndef charLitKind : SyntaxNodeKind := `charLit\ndef numLitKind : SyntaxNodeKind := `numLit\ndef scientificLitKind : SyntaxNodeKind := `scientificLit\ndef nameLitKind : SyntaxNodeKind := `nameLit\ndef fieldIdxKind : SyntaxNodeKind := `fieldIdx\ndef interpolatedStrLitKind : SyntaxNodeKind := `interpolatedStrLitKind\ndef interpolatedStrKind : SyntaxNodeKind := `interpolatedStrKind\n\nnamespace Syntax\n\ndef getKind (stx : Syntax) : SyntaxNodeKind :=\n  match stx with\n  | Syntax.node k args => k\n  -- We use these \"pseudo kinds\" for antiquotation kinds.\n  -- For example, an antiquotation `$id:ident` (using Lean.Parser.Term.ident)\n  -- is compiled to ``if stx.isOfKind `ident ...``\n  | Syntax.missing     => `missing\n  | Syntax.atom _ v    => Name.mkSimple v\n  | Syntax.ident ..    => identKind\n\ndef setKind (stx : Syntax) (k : SyntaxNodeKind) : Syntax :=\n  match stx with\n  | Syntax.node _ args => Syntax.node k args\n  | _                  => stx\n\ndef isOfKind (stx : Syntax) (k : SyntaxNodeKind) : Bool :=\n  beq stx.getKind k\n\ndef getArg (stx : Syntax) (i : Nat) : Syntax :=\n  match stx with\n  | Syntax.node _ args => args.getD i Syntax.missing\n  | _                  => Syntax.missing\n\n-- Add `stx[i]` as sugar for `stx.getArg i`\n@[inline] def getOp (self : Syntax) (idx : Nat) : Syntax :=\n  self.getArg idx\n\ndef getArgs (stx : Syntax) : Array Syntax :=\n  match stx with\n  | Syntax.node _ args => args\n  | _                  => Array.empty\n\ndef getNumArgs (stx : Syntax) : Nat :=\n  match stx with\n  | Syntax.node _ args => args.size\n  | _                  => 0\n\ndef isMissing : Syntax \u2192 Bool\n  | Syntax.missing => true\n  | _ => false\n\ndef isNodeOf (stx : Syntax) (k : SyntaxNodeKind) (n : Nat) : Bool :=\n  and (stx.isOfKind k) (beq stx.getNumArgs n)\n\ndef isIdent : Syntax \u2192 Bool\n  | ident _ _ _ _ => true\n  | _             => false\n\ndef getId : Syntax \u2192 Name\n  | ident _ _ val _ => val\n  | _               => Name.anonymous\n\ndef matchesNull (stx : Syntax) (n : Nat) : Bool :=\n  isNodeOf stx nullKind n\n\ndef matchesIdent (stx : Syntax) (id : Name) : Bool :=\n  and stx.isIdent (beq stx.getId id)\n\ndef setArgs (stx : Syntax) (args : Array Syntax) : Syntax :=\n  match stx with\n  | node k _ => node k args\n  | stx      => stx\n\ndef setArg (stx : Syntax) (i : Nat) (arg : Syntax) : Syntax :=\n  match stx with\n  | node k args => node k (args.setD i arg)\n  | stx         => stx\n\n/-- Retrieve the left-most leaf's info in the Syntax tree. -/\npartial def getHeadInfo? : Syntax \u2192 Option SourceInfo\n  | atom info _   => some info\n  | ident info .. => some info\n  | node _ args   =>\n    let rec loop (i : Nat) : Option SourceInfo :=\n      match decide (LT.lt i args.size) with\n      | true => match getHeadInfo? (args.get! i) with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | _             => none\n\n/-- Retrieve the left-most leaf's info in the Syntax tree, or `none` if there is no token. -/\npartial def getHeadInfo (stx : Syntax) : SourceInfo :=\n  match stx.getHeadInfo? with\n  | some info => info\n  | none      => SourceInfo.none\n\ndef getPos? (stx : Syntax) (originalOnly := false) : Option String.Pos :=\n  stx.getHeadInfo.getPos? originalOnly\n\npartial def getTailPos? (stx : Syntax) (originalOnly := false) : Option String.Pos :=\n  match stx, originalOnly with\n  | atom (SourceInfo.original (endPos := pos) ..) ..,    _    => some pos\n  | atom (SourceInfo.synthetic (endPos := pos) ..) _,  false  => some pos\n  | ident (SourceInfo.original (endPos := pos) ..) .., _      => some pos\n  | ident (SourceInfo.synthetic (endPos := pos) ..) .., false => some pos\n  | node _ args,                                        _     =>\n    let rec loop (i : Nat) : Option String.Pos :=\n      match decide (LT.lt i args.size) with\n      | true => match getTailPos? (args.get! ((args.size.sub i).sub 1)) originalOnly with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | _, _ => none\n\n/--\n  An array of syntax elements interspersed with separators. Can be coerced to/from `Array Syntax` to automatically\n  remove/insert the separators. -/\nstructure SepArray (sep : String) where\n  elemsAndSeps : Array Syntax\n\nend Syntax\n\ndef SourceInfo.fromRef (ref : Syntax) : SourceInfo :=\n  match ref.getPos?, ref.getTailPos? with\n  | some pos, some tailPos => SourceInfo.synthetic pos tailPos\n  | _,        _            => SourceInfo.none\n\ndef mkAtom (val : String) : Syntax :=\n  Syntax.atom SourceInfo.none val\n\ndef mkAtomFrom (src : Syntax) (val : String) : Syntax :=\n  Syntax.atom src.getHeadInfo val\n\n/- Parser descriptions -/\n\ninductive ParserDescr where\n  | const  (name : Name)\n  | unary  (name : Name) (p : ParserDescr)\n  | binary (name : Name) (p\u2081 p\u2082 : ParserDescr)\n  | node (kind : SyntaxNodeKind) (prec : Nat) (p : ParserDescr)\n  | trailingNode (kind : SyntaxNodeKind) (prec lhsPrec : Nat) (p : ParserDescr)\n  | symbol (val : String)\n  | nonReservedSymbol (val : String) (includeIdent : Bool)\n  | cat (catName : Name) (rbp : Nat)\n  | parser (declName : Name)\n  | nodeWithAntiquot (name : String) (kind : SyntaxNodeKind) (p : ParserDescr)\n  | sepBy  (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n  | sepBy1 (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n\ninstance : Inhabited ParserDescr where\n  default := ParserDescr.symbol \"\"\n\nabbrev TrailingParserDescr := ParserDescr\n\n/-\nRuntime support for making quotation terms auto-hygienic, by mangling identifiers\nintroduced by them with a \"macro scope\" supplied by the context. Details to appear in a\npaper soon.\n-/\n\nabbrev MacroScope := Nat\n/-- Macro scope used internally. It is not available for our frontend. -/\ndef reservedMacroScope := 0\n/-- First macro scope available for our frontend -/\ndef firstFrontendMacroScope := hAdd reservedMacroScope 1\n\nclass MonadRef (m : Type \u2192 Type) where\n  getRef      : m Syntax\n  withRef {\u03b1} : Syntax \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadRef (getRef)\n\ninstance (m n : Type \u2192 Type) [MonadLift m n] [MonadFunctor m n] [MonadRef m] : MonadRef n where\n  getRef        := liftM (getRef : m _)\n  withRef ref x := monadMap (m := m) (MonadRef.withRef ref) x\n\ndef replaceRef (ref : Syntax) (oldRef : Syntax) : Syntax :=\n  match ref.getPos? with\n  | some _ => ref\n  | _      => oldRef\n\n@[inline] def withRef {m : Type \u2192 Type} [Monad m] [MonadRef m] {\u03b1} (ref : Syntax) (x : m \u03b1) : m \u03b1 :=\n  bind getRef fun oldRef =>\n  let ref := replaceRef ref oldRef\n  MonadRef.withRef ref x\n\n/-- A monad that supports syntax quotations. Syntax quotations (in term\n    position) are monadic values that when executed retrieve the current \"macro\n    scope\" from the monad and apply it to every identifier they introduce\n    (independent of whether this identifier turns out to be a reference to an\n    existing declaration, or an actually fresh binding during further\n    elaboration). We also apply the position of the result of `getRef` to each\n    introduced symbol, which results in better error positions than not applying\n    any position. -/\nclass MonadQuotation (m : Type \u2192 Type) extends MonadRef m where\n  -- Get the fresh scope of the current macro invocation\n  getCurrMacroScope : m MacroScope\n  getMainModule     : m Name\n  /- Execute action in a new macro invocation context. This transformer should be\n     used at all places that morally qualify as the beginning of a \"macro call\",\n     e.g. `elabCommand` and `elabTerm` in the case of the elaborator. However, it\n     can also be used internally inside a \"macro\" if identifiers introduced by\n     e.g. different recursive calls should be independent and not collide. While\n     returning an intermediate syntax tree that will recursively be expanded by\n     the elaborator can be used for the same effect, doing direct recursion inside\n     the macro guarded by this transformer is often easier because one is not\n     restricted to passing a single syntax tree. Modelling this helper as a\n     transformer and not just a monadic action ensures that the current macro\n     scope before the recursive call is restored after it, as expected. -/\n  withFreshMacroScope {\u03b1 : Type} : m \u03b1 \u2192 m \u03b1\n\nexport MonadQuotation (getCurrMacroScope getMainModule withFreshMacroScope)\n\ndef MonadRef.mkInfoFromRefPos [Monad m] [MonadRef m] : m SourceInfo := do\n  SourceInfo.fromRef (\u2190 getRef)\n\ninstance {m n : Type \u2192 Type} [MonadFunctor m n] [MonadLift m n] [MonadQuotation m] : MonadQuotation n where\n  getCurrMacroScope   := liftM (m := m) getCurrMacroScope\n  getMainModule       := liftM (m := m) getMainModule\n  withFreshMacroScope := monadMap (m := m) withFreshMacroScope\n\n/-\nWe represent a name with macro scopes as\n```\n<actual name>._@.(<module_name>.<scopes>)*.<module_name>._hyg.<scopes>\n```\nExample: suppose the module name is `Init.Data.List.Basic`, and name is `foo.bla`, and macroscopes [2, 5]\n```\nfoo.bla._@.Init.Data.List.Basic._hyg.2.5\n```\n\nWe may have to combine scopes from different files/modules.\nThe main modules being processed is always the right most one.\nThis situation may happen when we execute a macro generated in\nan imported file in the current file.\n```\nfoo.bla._@.Init.Data.List.Basic.2.1.Init.Lean.Expr_hyg.4\n```\n\nThe delimiter `_hyg` is used just to improve the `hasMacroScopes` performance.\n-/\n\ndef Name.hasMacroScopes : Name \u2192 Bool\n  | str _ s _   => beq s \"_hyg\"\n  | num p _   _ => hasMacroScopes p\n  | _           => false\n\nprivate def eraseMacroScopesAux : Name \u2192 Name\n  | Name.str p s _   => match beq s \"_@\" with\n    | true  => p\n    | false => eraseMacroScopesAux p\n  | Name.num p _ _   => eraseMacroScopesAux p\n  | Name.anonymous   => Name.anonymous\n\n@[export lean_erase_macro_scopes]\ndef Name.eraseMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => eraseMacroScopesAux n\n  | false => n\n\nprivate def simpMacroScopesAux : Name \u2192 Name\n  | Name.num p i _ => Name.mkNum (simpMacroScopesAux p) i\n  | n              => eraseMacroScopesAux n\n\n/- Helper function we use to create binder names that do not need to be unique. -/\n@[export lean_simp_macro_scopes]\ndef Name.simpMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => simpMacroScopesAux n\n  | false => n\n\nstructure MacroScopesView where\n  name       : Name\n  imported   : Name\n  mainModule : Name\n  scopes     : List MacroScope\n\ninstance : Inhabited MacroScopesView where\n  default := \u27e8arbitrary, arbitrary, arbitrary, arbitrary\u27e9\n\ndef MacroScopesView.review (view : MacroScopesView) : Name :=\n  match view.scopes with\n  | List.nil      => view.name\n  | List.cons _ _ =>\n    let base := (Name.mkStr (hAppend (hAppend (Name.mkStr view.name \"_@\") view.imported) view.mainModule) \"_hyg\")\n    view.scopes.foldl Name.mkNum base\n\nprivate def assembleParts : List Name \u2192 Name \u2192 Name\n  | List.nil,                      acc => acc\n  | List.cons (Name.str _ s _) ps, acc => assembleParts ps (Name.mkStr acc s)\n  | List.cons (Name.num _ n _) ps, acc => assembleParts ps (Name.mkNum acc n)\n  | _,                             acc => panic \"Error: unreachable @ assembleParts\"\n\nprivate def extractImported (scps : List MacroScope) (mainModule : Name) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := mainModule, imported := assembleParts parts Name.anonymous, scopes := scps }\n    | false => extractImported scps mainModule p (List.cons n parts)\n  | n@(Name.num p str _), parts => extractImported scps mainModule p (List.cons n parts)\n  | _,                    _     => panic \"Error: unreachable @ extractImported\"\n\nprivate def extractMainModule (scps : List MacroScope) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := assembleParts parts Name.anonymous, imported := Name.anonymous, scopes := scps }\n    | false => extractMainModule scps p (List.cons n parts)\n  | n@(Name.num p num _), acc => extractImported scps (assembleParts acc Name.anonymous) n List.nil\n  | _,                    _   => panic \"Error: unreachable @ extractMainModule\"\n\nprivate def extractMacroScopesAux : Name \u2192 List MacroScope \u2192 MacroScopesView\n  | Name.num p scp _, acc => extractMacroScopesAux p (List.cons scp acc)\n  | Name.str p str _, acc => extractMainModule acc p List.nil -- str must be \"_hyg\"\n  | _,                _   => panic \"Error: unreachable @ extractMacroScopesAux\"\n\n/--\n  Revert all `addMacroScope` calls. `v = extractMacroScopes n \u2192 n = v.review`.\n  This operation is useful for analyzing/transforming the original identifiers, then adding back\n  the scopes (via `MacroScopesView.review`). -/\ndef extractMacroScopes (n : Name) : MacroScopesView :=\n  match n.hasMacroScopes with\n  | true  => extractMacroScopesAux n List.nil\n  | false => { name := n, scopes := List.nil, imported := Name.anonymous, mainModule := Name.anonymous }\n\ndef addMacroScope (mainModule : Name) (n : Name) (scp : MacroScope) : Name :=\n  match n.hasMacroScopes with\n  | true =>\n    let view := extractMacroScopes n\n    match beq view.mainModule mainModule with\n    | true  => Name.mkNum n scp\n    | false =>\n      { view with\n        imported   := view.scopes.foldl Name.mkNum (hAppend view.imported view.mainModule)\n        mainModule := mainModule\n        scopes     := List.cons scp List.nil\n      }.review\n  | false =>\n    Name.mkNum (Name.mkStr (hAppend (Name.mkStr n \"_@\") mainModule) \"_hyg\") scp\n\n@[inline] def MonadQuotation.addMacroScope {m : Type \u2192 Type} [MonadQuotation m] [Monad m] (n : Name) : m Name :=\n  bind getMainModule     fun mainModule =>\n  bind getCurrMacroScope fun scp =>\n  pure (Lean.addMacroScope mainModule n scp)\n\ndef defaultMaxRecDepth := 512\n\ndef maxRecDepthErrorMessage : String :=\n  \"maximum recursion depth has been reached (use `set_option maxRecDepth <num>` to increase limit)\"\n\nnamespace Macro\n\n/- References -/\nprivate constant MethodsRefPointed : PointedType.{0}\n\nprivate def MethodsRef : Type := MethodsRefPointed.type\n\nstructure Context where\n  methods        : MethodsRef\n  mainModule     : Name\n  currMacroScope : MacroScope\n  currRecDepth   : Nat := 0\n  maxRecDepth    : Nat := defaultMaxRecDepth\n  ref            : Syntax\n\ninductive Exception where\n  | error             : Syntax \u2192 String \u2192 Exception\n  | unsupportedSyntax : Exception\n\nstructure State where\n  macroScope : MacroScope\n  traceMsgs  : List (Prod Name String) := List.nil\n  deriving Inhabited\n\nend Macro\n\nabbrev MacroM := ReaderT Macro.Context (EStateM Macro.Exception Macro.State)\n\nabbrev Macro := Syntax \u2192 MacroM Syntax\n\nnamespace Macro\n\ninstance : MonadRef MacroM where\n  getRef     := bind read fun ctx => pure ctx.ref\n  withRef    := fun ref x => withReader (fun ctx => { ctx with ref := ref }) x\n\ndef addMacroScope (n : Name) : MacroM Name :=\n  bind read fun ctx =>\n  pure (Lean.addMacroScope ctx.mainModule n ctx.currMacroScope)\n\ndef throwUnsupported {\u03b1} : MacroM \u03b1 :=\n  throw Exception.unsupportedSyntax\n\ndef throwError {\u03b1} (msg : String) : MacroM \u03b1 :=\n  bind getRef fun ref =>\n  throw (Exception.error ref msg)\n\ndef throwErrorAt {\u03b1} (ref : Syntax) (msg : String) : MacroM \u03b1 :=\n  withRef ref (throwError msg)\n\n@[inline] protected def withFreshMacroScope {\u03b1} (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind (modifyGet (fun s => (s.macroScope, { s with macroScope := hAdd s.macroScope 1 }))) fun fresh =>\n  withReader (fun ctx => { ctx with currMacroScope := fresh }) x\n\n@[inline] def withIncRecDepth {\u03b1} (ref : Syntax) (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind read fun ctx =>\n  match beq ctx.currRecDepth ctx.maxRecDepth with\n  | true  => throw (Exception.error ref maxRecDepthErrorMessage)\n  | false => withReader (fun ctx => { ctx with currRecDepth := hAdd ctx.currRecDepth 1 }) x\n\ninstance : MonadQuotation MacroM where\n  getCurrMacroScope ctx := pure ctx.currMacroScope\n  getMainModule     ctx := pure ctx.mainModule\n  withFreshMacroScope   := Macro.withFreshMacroScope\n\nstructure Methods where\n  expandMacro?      : Syntax \u2192 MacroM (Option Syntax)\n  getCurrNamespace  : MacroM Name\n  hasDecl           : Name \u2192 MacroM Bool\n  resolveNamespace? : Name \u2192 MacroM (Option Name)\n  resolveGlobalName : Name \u2192 MacroM (List (Prod Name (List String)))\n  deriving Inhabited\n\nunsafe def mkMethodsImp (methods : Methods) : MethodsRef :=\n  unsafeCast methods\n\n@[implementedBy mkMethodsImp]\nconstant mkMethods (methods : Methods) : MethodsRef := MethodsRefPointed.val\n\ninstance : Inhabited MethodsRef where\n  default := mkMethods arbitrary\n\nunsafe def getMethodsImp : MacroM Methods :=\n  bind read fun ctx => pure (unsafeCast (ctx.methods))\n\n@[implementedBy getMethodsImp] constant getMethods : MacroM Methods\n\n/-- `expandMacro? stx` return `some stxNew` if `stx` is a macro, and `stxNew` is its expansion. -/\ndef expandMacro? (stx : Syntax) : MacroM (Option Syntax) := do\n  (\u2190 getMethods).expandMacro? stx\n\n/-- Return `true` if the environment contains a declaration with name `declName` -/\ndef hasDecl (declName : Name) : MacroM Bool := do\n  (\u2190 getMethods).hasDecl declName\n\ndef getCurrNamespace : MacroM Name := do\n  (\u2190 getMethods).getCurrNamespace\n\ndef resolveNamespace? (n : Name) : MacroM (Option Name) := do\n  (\u2190 getMethods).resolveNamespace? n\n\ndef resolveGlobalName (n : Name) : MacroM (List (Prod Name (List String))) := do\n  (\u2190 getMethods).resolveGlobalName n\n\ndef trace (clsName : Name) (msg : String) : MacroM Unit := do\n  modify fun s => { s with traceMsgs := List.cons (Prod.mk clsName msg) s.traceMsgs }\n\nend Macro\n\nexport Macro (expandMacro?)\n\nnamespace PrettyPrinter\n\nabbrev UnexpandM := EStateM Unit Unit\n\n/--\n  Function that tries to reverse macro expansions as a post-processing step of delaboration.\n  While less general than an arbitrary delaborator, it can be declared without importing `Lean`.\n  Used by the `[appUnexpander]` attribute. -/\n-- a `kindUnexpander` could reasonably be added later\nabbrev Unexpander := Syntax \u2192 UnexpandM Syntax\n\n-- unexpanders should not need to introduce new names\ninstance : MonadQuotation UnexpandM where\n  getRef              := pure Syntax.missing\n  withRef             := fun _ => id\n  getCurrMacroScope   := pure 0\n  getMainModule       := pure `_fakeMod\n  withFreshMacroScope := id\n\nend PrettyPrinter\n\nend Lean\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/Prelude.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6757646010190476, "lm_q2_score": 0.6992544147913993, "lm_q1q2_score": 0.47253138062231753}}
{"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\u2097 = sl(l+1)\n  * B\u2097 \u2243 so(l+1, l) \u2243 so(2l+1)\n  * C\u2097 = sp(l)\n  * D\u2097 \u2243 so(l, l) \u2243 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 \u00d7 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\u2081 u\u2082\n\nnamespace lie_algebra\nopen_locale matrix\n\nvariables (n p q l : Type*) (R : Type u\u2082)\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 \u2045X, Y\u2046 = 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' := \u03bb 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) : \u2045A, B\u2046.val = A.val \u2b1d B.val - B.val \u2b1d 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 := \u03bb i' j', if i = i' \u2227 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 : \u00ac(i = i' \u2227 j = j')) : E R i j i' j' = 0 := if_neg h\n\n@[simp] lemma E_diag_zero (h : j \u2260 i) : matrix.diag n R R (E R i j) = 0 :=\nbegin\n  ext k, rw matrix.diag_apply,\n  suffices : \u00ac(i = k \u2227 j = k), by exact if_neg this,\n  rintros \u27e8e\u2081, e\u2082\u27e9, apply h, subst e\u2081, exact e\u2082,\nend\n\nlemma E_trace_zero (h : j \u2260 i) : matrix.trace n R R (E R i j) = 0 := by simp [h]\n\n/-- When j \u2260 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 \u2260 i) : sl n R :=\n\u27e8E R i j, by { change E R i j \u2208 linear_map.ker (matrix.trace n R R), simp [E_trace_zero R i j h], }\u27e9\n\n@[simp] lemma Eb_val (h : j \u2260 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 \u2295 l) (l \u2295 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 \u2295 l) (l \u2295 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 \u2208 so n R \u2194 A\u1d40 = -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 \u2295 q) (p \u2295 q) R :=\n  matrix.diagonal $ sum.elim (\u03bb _, 1) (\u03bb _, -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 \u2295 q) (p \u2295 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 \u2295 q) (p \u2295 q) R :=\n  matrix.diagonal $ sum.elim (\u03bb _, 1) (\u03bb _, 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\u27e8{ 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\u27e9\n\nlemma indefinite_diagonal_transform {i : R} (hi : i*i = -1) :\n  (Pso p q R i)\u1d40 \u2b1d (indefinite_diagonal p q R) \u2b1d (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 \u2243\u2097\u2045R\u2046 so (p \u2295 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 \u2295 q) (p \u2295 q) R) =\n    (Pso p q R i)\u207b\u00b9 \u2b1d (A : matrix (p \u2295 q) (p \u2295 q) R) \u2b1d (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 \u2295 l) (l \u2295 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 \u2295 l) (l \u2295 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 [\u2190 matrix.diagonal_one, matrix.diagonal_neg, matrix.from_blocks_diagonal],\n  refl,\nend\n\nlemma JD_transform : (PD l R)\u1d40 \u2b1d (JD l R) \u2b1d (PD l R) = (2 : R) \u2022 (S l R) :=\nbegin\n  have h : (PD l R)\u1d40 \u2b1d (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) * (\u215f(2 : R) \u2022 (PD l R)\u1d40) = 1 :=\nbegin\n  have h : \u215f(2 : R) \u2022 (1 : matrix l l R) + \u215f(2 : R) \u2022 1 = 1 := by\n    rw [\u2190 smul_add, \u2190 (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\u27e8{ val     := PD l R,\n   inv     := \u215f(2 : R) \u2022 (PD l R)\u1d40,\n   val_inv := PD_inv l R,\n   inv_val := by { apply matrix.nonsing_inv_left_right, exact PD_inv l R, }, },\nrfl\u27e9\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 \u2243\u2097\u2045R\u2046 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, \u2190 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) \u2022 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)\u207b\u00b9) = 1 :=\nbegin\n  simp [PB, matrix.from_blocks_multiply, (PD l R).mul_nonsing_inv, is_unit_PD,\n        \u2190 (PD l R).is_unit_iff_is_unit_det]\nend\n\nlemma is_unit_PB [invertible (2 : R)] : is_unit (PB l R) :=\n\u27e8{ val     := PB l R,\n   inv     := matrix.from_blocks 1 0 0 (PD l R)\u207b\u00b9,\n   val_inv := PB_inv l R,\n   inv_val := by { apply matrix.nonsing_inv_left_right, exact PB_inv l R, }, },\nrfl\u27e9\n\nlemma JB_transform : (PB l R)\u1d40 \u2b1d (JB l R) \u2b1d (PB l R) = (2 : R) \u2022 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 \u2295 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 \u27e8\u27e8i\u2081 | i\u2082\u27e9 | i\u2083\u27e9;\n  rcases j with \u27e8\u27e8j\u2081 | j\u2082\u27e9 | j\u2083\u27e9;\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 \u2243\u2097\u2045R\u2046 so' (unit \u2295 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 \u2295 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, \u2190 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (start : \u2115) (b : \u03b2) (as : List \u03b1) : \u03b2 :=\n  foldr (function.uncurry f) b (enum_from start as)\n\ntheorem foldr_with_index_aux_spec_cons {\u03b1 : Type u} {\u03b2 : Type v} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (start : \u2115) (b : \u03b2) (a : \u03b1) (as : List \u03b1) : 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (start : \u2115) (b : \u03b2) (as : List \u03b1) : 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (as : List \u03b1) : foldr_with_index f b as = foldr (function.uncurry f) b (enum as) := sorry\n\ntheorem indexes_values_eq_filter_enum {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) [decidable_pred p] (as : List \u03b1) : indexes_values p as = filter (p \u2218 prod.snd) (enum as) := sorry\n\ntheorem find_indexes_eq_map_indexes_values {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) [decidable_pred p] (as : List \u03b1) : 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (start : \u2115) (a : \u03b1) (bs : List \u03b2) : \u03b1 :=\n  foldl (fun (a : \u03b1) (p : \u2115 \u00d7 \u03b2) => f (prod.fst p) a (prod.snd p)) a (enum_from start bs)\n\ntheorem foldl_with_index_aux_spec_cons {\u03b1 : Type u} {\u03b2 : Type v} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (start : \u2115) (a : \u03b1) (b : \u03b2) (bs : List \u03b2) : 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (start : \u2115) (a : \u03b1) (bs : List \u03b2) : 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (bs : List \u03b2) : foldl_with_index f a bs = foldl (fun (a : \u03b1) (p : \u2115 \u00d7 \u03b2) => f (prod.fst p) a (prod.snd p)) a (enum bs) := sorry\n\ntheorem mfoldr_with_index_eq_mfoldr_enum {m : Type u \u2192 Type v} [Monad m] {\u03b1 : Type u_1} {\u03b2 : Type u} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 m \u03b2) (b : \u03b2) (as : List \u03b1) : 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 \u2192 Type v} [Monad m] [is_lawful_monad m] {\u03b1 : Type u_1} {\u03b2 : Type u} (f : \u2115 \u2192 \u03b2 \u2192 \u03b1 \u2192 m \u03b2) (b : \u03b2) (as : List \u03b1) : mfoldl_with_index f b as = mfoldl (fun (b : \u03b2) (p : \u2115 \u00d7 \u03b1) => 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 \u2192 Type v} [Applicative m] {\u03b1 : Type u_1} {\u03b2 : Type u} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (start : \u2115) (as : List \u03b1) : m (List \u03b2) :=\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 \u2192 Type u`.\n\ntheorem mmap_with_index_aux_spec_cons {m : Type u \u2192 Type v} [Applicative m] {\u03b1 : Type u_1} {\u03b2 : Type u} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (start : \u2115) (a : \u03b1) (as : List \u03b1) : 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 \u2192 Type v} [Applicative m] {\u03b1 : Type u_1} {\u03b2 : Type u} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (start : \u2115) (as : List \u03b1) : 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 \u2192 Type v} [Applicative m] {\u03b1 : Type u_1} {\u03b2 : Type u} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (as : List \u03b1) : 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 \u2192 Type v} [Applicative m] [is_lawful_applicative m] {\u03b1 : Type u_1} (f : \u2115 \u2192 \u03b1 \u2192 m PUnit) (start : \u2115) (as : List \u03b1) : 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 \u2192 Type v} [Applicative m] [is_lawful_applicative m] {\u03b1 : Type u_1} (f : \u2115 \u2192 \u03b1 \u2192 m PUnit) (as : List \u03b1) : 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": "import Smt\n\ntheorem zero_sub : 0 - x = 0 := by\n  smt\n  induction x <;> simp_all [Nat.sub_succ]\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/Nat/ZeroSub.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7634837635542924, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.4724288143685121}}
{"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 \u2192 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 \u2192 Prop)\n        (h\u2081 : p (1 * x + y)) (h\u2082 : p  (x * z * 1))\n        : p (y + 0 + x) \u2227 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 \u2260 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} \u2192 (f : Y \u27f6 X) \u2192 [_inst_3 : mono f] \u2192 is_iso f \u2243 f \u2260 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 \u27f6 Y} [mono f] (w : f \u2260 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 \u27f6 Y} [limits.has_kernel f] (w : f \u2260 0) :\n    limits.kernel.\u03b9 f = 0 :=\n  decidable.by_contradiction fun (h : \u00aclimits.kernel.\u03b9 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 \u27f6 Y} [mono f] (w : is_iso f \u2192 False) : f = 0 :=\n  decidable.by_contradiction fun (h : \u00acf = 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    \ud835\udfd9 \u2260 0 :=\n  coe_fn (simple.mono_is_iso_equiv_nonzero \ud835\udfd9) (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} \u2192 (f : X \u27f6 Z) \u2192 [_inst_3 : epi f] \u2192 is_iso f \u2243 f \u2260 0) : simple X :=\n  simple.mk\n    fun (Y : C) (f : Y \u27f6 X) (I : mono f) =>\n      equiv_of_subsingleton_of_subsingleton sorry\n        fun (hf : f \u2260 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 \u27f6 Y} [epi f] (w : f \u2260 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 \u27f6 Y} [limits.has_cokernel f] (w : f \u2260 0) : limits.cokernel.\u03c0 f = 0 :=\n  decidable.by_contradiction\n    fun (h : \u00aclimits.cokernel.\u03c0 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 \u27f6 Y} [epi f] (w : is_iso f \u2192 False) : f = 0 :=\n  decidable.by_contradiction fun (h : \u00acf = 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}] (\u03b1 : \u039b) [position_data.{}] [phase_2_assumptions \u03b1] {\u03b2 : type_index}\n\n/-- A litter is *inflexible* if it is the image of some f-map. -/\n@[mk_iff] inductive inflexible : litter \u2192 extended_index \u03b2 \u2192 Prop\n| mk_coe \u2983\u03b3 : Iic \u03b1\u2984 \u2983\u03b4 : Iio \u03b1\u2984 \u2983\u03b5 : Iio \u03b1\u2984 (h\u03b4 : (\u03b4 : \u039b) < \u03b3) (h\u03b5 : (\u03b5 : \u039b) < \u03b3) (h\u03b4\u03b5 : \u03b4 \u2260 \u03b5)\n    (A : quiver.path (\u03b2 : type_index) \u03b3) (t : tangle \u03b4) :\n    inflexible\n      (f_map (with_bot.coe_ne_coe.mpr $ coe_ne' h\u03b4\u03b5) t)\n      ((A.cons (coe_lt h\u03b5)).cons (with_bot.bot_lt_coe _))\n| mk_bot \u2983\u03b3 : Iic \u03b1\u2984 \u2983\u03b5 : Iio \u03b1\u2984 (h\u03b5 : (\u03b5 : \u039b) < \u03b3)\n    (A : quiver.path (\u03b2 : type_index) \u03b3) (a : atom) :\n    inflexible\n      (f_map (show (\u22a5 : type_index) \u2260 (\u03b5 : \u039b), from with_bot.bot_ne_coe) a)\n      ((A.cons (coe_lt h\u03b5)).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 \u03b2) : Prop := \u00acinflexible \u03b1 L A\n\nlemma mk_flexible (A : extended_index \u03b2) : #{L | flexible \u03b1 L A} = #\u03bc :=\nbegin\n  refine le_antisymm ((cardinal.mk_subtype_le _).trans mk_litter.le) _,\n  refine \u27e8\u27e8\u03bb \u03bd, \u27e8\u27e8\u03bd, \u22a5, \u03b1, with_bot.bot_ne_coe\u27e9, _\u27e9, _\u27e9\u27e9,\n  { intro h,\n    rw inflexible_iff at h,\n    obtain (\u27e8\u03b3, \u03b4, \u03b5, h\u03b4, h\u03b5, h\u03b4\u03b5, A, t, h, rfl\u27e9 | \u27e8\u03b3, \u03b5, h\u03b5, A, t, h, rfl\u27e9) := h,\n    all_goals { have := f_map_\u03b3 _ _,\n      rw \u2190 h at this,\n      exact ne_of_lt \u03b5.prop this.symm, }, },\n  { intros \u03bd\u2081 \u03bd\u2082 h,\n    simp only [subtype.mk_eq_mk, eq_self_iff_true, and_true] at h,\n    exact h, },\nend\n\nvariable {\u03b1}\n\nlemma inflexible.comp {\u03b3 : type_index} {L : litter} {A : extended_index \u03b3}\n  (h : inflexible \u03b1 L A) (B : quiver.path \u03b2 \u03b3) : inflexible \u03b1 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 \u03b2} :\n  \u00acflexible \u03b1 L A \u2194 inflexible \u03b1 L A := not_not\n\nlemma flexible_of_comp_flexible {\u03b3 : type_index} {L : litter} {A : extended_index \u03b3}\n  {B : quiver.path \u03b2 \u03b3} (h : flexible \u03b1 L (B.comp A)) : flexible \u03b1 L A :=\n\u03bb 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b4 : Type x}\n\ninstance : is_left_id (list \u03b1) has_append.append [] :=\n\u27e8 nil_append \u27e9\n\ninstance : is_right_id (list \u03b1) has_append.append [] :=\n\u27e8 append_nil \u27e9\n\ninstance : is_associative (list \u03b1) has_append.append :=\n\u27e8 append_assoc \u27e9\n\n@[simp] theorem cons_ne_nil (a : \u03b1) (l : list \u03b1) : a::l \u2260 [].\n\ntheorem head_eq_of_cons_eq {h\u2081 h\u2082 : \u03b1} {t\u2081 t\u2082 : list \u03b1} :\n      (h\u2081::t\u2081) = (h\u2082::t\u2082) \u2192 h\u2081 = h\u2082 :=\nassume Peq, list.no_confusion Peq (assume Pheq Pteq, Pheq)\n\ntheorem tail_eq_of_cons_eq {h\u2081 h\u2082 : \u03b1} {t\u2081 t\u2082 : list \u03b1} :\n      (h\u2081::t\u2081) = (h\u2082::t\u2082) \u2192 t\u2081 = t\u2082 :=\nassume Peq, list.no_confusion Peq (assume Pheq Pteq, Pteq)\n\ntheorem cons_inj {a : \u03b1} : injective (cons a) :=\nassume l\u2081 l\u2082, assume Pe, tail_eq_of_cons_eq Pe\n\n@[simp] theorem cons_inj' (a : \u03b1) {l l' : list \u03b1} : a::l = a::l' \u2194 l = l' :=\n\u27e8\u03bb e, cons_inj e, congr_arg _\u27e9\n\n/- mem -/\n\ntheorem mem_singleton_self (a : \u03b1) : a \u2208 [a] := mem_cons_self _ _\n\ntheorem eq_of_mem_singleton {a b : \u03b1} : a \u2208 [b] \u2192 a = b :=\nassume : a \u2208 [b], or.elim (eq_or_mem_of_mem_cons this)\n  (assume : a = b, this)\n  (assume : a \u2208 [], absurd this (not_mem_nil a))\n\n@[simp] theorem mem_singleton {a b : \u03b1} : a \u2208 [b] \u2194 a = b :=\n\u27e8eq_of_mem_singleton, or.inl\u27e9\n\ntheorem mem_of_mem_cons_of_mem {a b : \u03b1} {l : list \u03b1} : a \u2208 b::l \u2192 b \u2208 l \u2192 a \u2208 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 \u2208 l, this)\n\ntheorem eq_or_ne_mem_of_mem {a b : \u03b1} {l : list \u03b1} (h : a \u2208 b :: l) : a = b \u2228 (a \u2260 b \u2227 a \u2208 l) :=\nclassical.by_cases or.inl $ assume : a \u2260 b, h.elim or.inl $ assume h, or.inr \u27e8this, h\u27e9\n\ntheorem not_mem_append {a : \u03b1} {s t : list \u03b1} (h\u2081 : a \u2209 s) (h\u2082 : a \u2209 t) : a \u2209 s ++ t :=\nmt mem_append.1 $ not_or_distrib.2 \u27e8h\u2081, h\u2082\u27e9\n\ntheorem ne_nil_of_mem {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) : l \u2260 [] :=\nby intro e; rw e at h; cases h\n\ntheorem length_eq_zero {l : list \u03b1} : length l = 0 \u2194 l = [] :=\n\u27e8eq_nil_of_length_eq_zero, \u03bb h, h.symm \u25b8 rfl\u27e9\n\ntheorem length_pos_of_mem {a : \u03b1} : \u2200 {l : list \u03b1}, a \u2208 l \u2192 0 < length l\n| (b::l) _ := zero_lt_succ _\n\ntheorem exists_mem_of_length_pos : \u2200 {l : list \u03b1}, 0 < length l \u2192 \u2203 a, a \u2208 l\n| (b::l) _ := \u27e8b, mem_cons_self _ _\u27e9\n\ntheorem length_pos_iff_exists_mem {l : list \u03b1} : 0 < length l \u2194 \u2203 a, a \u2208 l :=\n\u27e8exists_mem_of_length_pos, \u03bb \u27e8a, h\u27e9, length_pos_of_mem h\u27e9\n\ntheorem length_eq_one {l : list \u03b1} : length l = 1 \u2194 \u2203 a, l = [a] :=\n\u27e8match l with [a], _ := \u27e8a, rfl\u27e9 end, \u03bb \u27e8a, e\u27e9, e.symm \u25b8 rfl\u27e9\n\ntheorem mem_split {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) : \u2203 s t : list \u03b1, l = s ++ a :: t :=\nbegin\n  induction l with b l ih, {cases h}, rcases h with rfl | h,\n  { exact \u27e8[], l, rfl\u27e9 },\n  { rcases ih h with \u27e8s, t, rfl\u27e9,\n    exact \u27e8b::s, t, rfl\u27e9 }\nend\n\ntheorem mem_of_ne_of_mem {a y : \u03b1} {l : list \u03b1} (h\u2081 : a \u2260 y) (h\u2082 : a \u2208 y :: l) : a \u2208 l :=\nor.elim (eq_or_mem_of_mem_cons h\u2082) (\u03bbe, absurd e h\u2081) (\u03bbr, r)\n\ntheorem ne_of_not_mem_cons {a b : \u03b1} {l : list \u03b1} : a \u2209 b::l \u2192 a \u2260 b :=\nassume nin aeqb, absurd (or.inl aeqb) nin\n\ntheorem not_mem_of_not_mem_cons {a b : \u03b1} {l : list \u03b1} : a \u2209 b::l \u2192 a \u2209 l :=\nassume nin nainl, absurd (or.inr nainl) nin\n\ntheorem not_mem_cons_of_ne_of_not_mem {a y : \u03b1} {l : list \u03b1} : a \u2260 y \u2192 a \u2209 l \u2192 a \u2209 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 : \u03b1} {l : list \u03b1} : a \u2209 y::l \u2192 a \u2260 y \u2227 a \u2209 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 : \u03b1 \u2192 \u03b2) {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) : f a \u2208 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 : \u03b1 \u2192 \u03b2} {b : \u03b2} {l : list \u03b1} (h : b \u2208 map f l) : \u2203 a, a \u2208 l \u2227 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 \u27e8c, mem_cons_self _ _, h.symm\u27e9},\n    {rcases ih h with \u27e8a, ha\u2081, ha\u2082\u27e9,\n      exact \u27e8a, mem_cons_of_mem _ ha\u2081, ha\u2082\u27e9 }}\nend\n\n@[simp] theorem mem_map {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {l : list \u03b1} : b \u2208 map f l \u2194 \u2203 a, a \u2208 l \u2227 f a = b :=\n\u27e8exists_of_mem_map, \u03bb \u27e8a, la, h\u27e9, by rw [\u2190 h]; exact mem_map_of_mem f la\u27e9\n\n@[simp] theorem mem_map_of_inj {f : \u03b1 \u2192 \u03b2} (H : injective f) {a : \u03b1} {l : list \u03b1} :\n  f a \u2208 map f l \u2194 a \u2208 l :=\n\u27e8\u03bb m, let \u27e8a', m', e\u27e9 := exists_of_mem_map m in H e \u25b8 m', mem_map_of_mem _\u27e9\n\n@[simp] theorem mem_join {a : \u03b1} : \u2200 {L : list (list \u03b1)}, a \u2208 join L \u2194 \u2203 l, l \u2208 L \u2227 a \u2208 l\n| []       := \u27e8false.elim, \u03bb\u27e8_, h, _\u27e9, false.elim h\u27e9\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 : \u03b1} {L : list (list \u03b1)} : a \u2208 join L \u2192 \u2203 l, l \u2208 L \u2227 a \u2208 l :=\nmem_join.1\n\ntheorem mem_join_of_mem {a : \u03b1} {L : list (list \u03b1)} {l} (lL : l \u2208 L) (al : a \u2208 l) : a \u2208 join L :=\nmem_join.2 \u27e8l, lL, al\u27e9\n\n@[simp] theorem mem_bind {b : \u03b2} {l : list \u03b1} {f : \u03b1 \u2192 list \u03b2} : b \u2208 list.bind l f \u2194 \u2203 a \u2208 l, b \u2208 f a :=\niff.trans mem_join\n  \u27e8\u03bb \u27e8l', h1, h2\u27e9, let \u27e8a, al, fa\u27e9 := exists_of_mem_map h1 in \u27e8a, al, fa.symm \u25b8 h2\u27e9,\n  \u03bb \u27e8a, al, bfa\u27e9, \u27e8f a, mem_map_of_mem _ al, bfa\u27e9\u27e9\n\ntheorem exists_of_mem_bind {b : \u03b2} {l : list \u03b1} {f : \u03b1 \u2192 list \u03b2} : b \u2208 list.bind l f \u2192 \u2203 a \u2208 l, b \u2208 f a :=\nmem_bind.1\n\ntheorem mem_bind_of_mem {b : \u03b2} {l : list \u03b1} {f : \u03b1 \u2192 list \u03b2} {a} (al : a \u2208 l) (h : b \u2208 f a) : b \u2208 list.bind l f :=\nmem_bind.2 \u27e8a, al, h\u27e9\n\nlemma bind_map {g : \u03b1 \u2192 list \u03b2} {f : \u03b2 \u2192 \u03b3} :\n  \u2200(l : list \u03b1), list.map f (l.bind g) = l.bind (\u03bba, (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 : \u03b1 \u2192 Prop) : \u2200 x \u2208 @nil \u03b1, p x.\n\n@[simp] theorem forall_mem_cons' {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1} :\n  (\u2200 (x : \u03b1), x = a \u2228 x \u2208 l \u2192 p x) \u2194 p a \u2227 \u2200 x \u2208 l, p x :=\nby simp only [or_imp_distrib, forall_and_distrib, forall_eq]\n\ntheorem forall_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1} :\n  (\u2200 x \u2208 a :: l, p x) \u2194 p a \u2227 \u2200 x \u2208 l, p x :=\nby simp only [mem_cons_iff, forall_mem_cons']\n\ntheorem forall_mem_of_forall_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1}\n    (h : \u2200 x \u2208 a :: l, p x) :\n  \u2200 x \u2208 l, p x :=\n(forall_mem_cons.1 h).2\n\ntheorem forall_mem_singleton {p : \u03b1 \u2192 Prop} {a : \u03b1} : (\u2200 x \u2208 [a], p x) \u2194 p a :=\nby simp only [mem_singleton, forall_eq]\n\ntheorem forall_mem_append {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1} :\n  (\u2200 x \u2208 l\u2081 ++ l\u2082, p x) \u2194 (\u2200 x \u2208 l\u2081, p x) \u2227 (\u2200 x \u2208 l\u2082, p x) :=\nby simp only [mem_append, or_imp_distrib, forall_and_distrib]\n\ntheorem not_exists_mem_nil (p : \u03b1 \u2192 Prop) : \u00ac \u2203 x \u2208 @nil \u03b1, p x.\n\ntheorem exists_mem_cons_of {p : \u03b1 \u2192 Prop} {a : \u03b1} (l : list \u03b1) (h : p a) :\n  \u2203 x \u2208 a :: l, p x :=\nbex.intro a (mem_cons_self _ _) h\n\ntheorem exists_mem_cons_of_exists {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1} (h : \u2203 x \u2208 l, p x) :\n  \u2203 x \u2208 a :: l, p x :=\nbex.elim h (\u03bb x xl px, bex.intro x (mem_cons_of_mem _ xl) px)\n\ntheorem or_exists_of_exists_mem_cons {p : \u03b1 \u2192 Prop} {a : \u03b1} {l : list \u03b1} (h : \u2203 x \u2208 a :: l, p x) :\n  p a \u2228 \u2203 x \u2208 l, p x :=\nbex.elim h (\u03bb x xal px,\n  or.elim (eq_or_mem_of_mem_cons xal)\n    (assume : x = a, begin rw \u2190this, left, exact px end)\n    (assume : x \u2208 l, or.inr (bex.intro x this px)))\n\n@[simp] theorem exists_mem_cons_iff (p : \u03b1 \u2192 Prop) (a : \u03b1) (l : list \u03b1) :\n  (\u2203 x \u2208 a :: l, p x) \u2194 p a \u2228 \u2203 x \u2208 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\u2081 l\u2082 : list \u03b1} : l\u2081 \u2286 l\u2082 \u2194 \u2200 \u2983a : \u03b1\u2984, a \u2208 l\u2081 \u2192 a \u2208 l\u2082 := iff.rfl\n\ntheorem subset_app_of_subset_left (l l\u2081 l\u2082 : list \u03b1) : l \u2286 l\u2081 \u2192 l \u2286 l\u2081++l\u2082 :=\n\u03bb s, subset.trans s $ subset_append_left _ _\n\ntheorem subset_app_of_subset_right (l l\u2081 l\u2082 : list \u03b1) : l \u2286 l\u2082 \u2192 l \u2286 l\u2081++l\u2082 :=\n\u03bb s, subset.trans s $ subset_append_right _ _\n\n@[simp] theorem cons_subset {a : \u03b1} {l m : list \u03b1} :\n  a::l \u2286 m \u2194 a \u2208 m \u2227 l \u2286 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 : \u03b1} {l m : list \u03b1}\n  (ainm : a \u2208 m) (lsubm : l \u2286 m) : a::l \u2286 m :=\ncons_subset.2 \u27e8ainm, lsubm\u27e9\n\ntheorem app_subset_of_subset_of_subset {l\u2081 l\u2082 l : list \u03b1} (l\u2081subl : l\u2081 \u2286 l) (l\u2082subl : l\u2082 \u2286 l) :\n  l\u2081 ++ l\u2082 \u2286 l :=\n\u03bb a h, (mem_append.1 h).elim (@l\u2081subl _) (@l\u2082subl _)\n\ntheorem eq_nil_of_subset_nil : \u2200 {l : list \u03b1}, l \u2286 [] \u2192 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 \u03b1} : l = [] \u2194 \u2200 a, a \u2209 l :=\nshow l = [] \u2194 l \u2286 [], from \u27e8\u03bb e, e \u25b8 subset.refl _, eq_nil_of_subset_nil\u27e9\n\ntheorem map_subset {l\u2081 l\u2082 : list \u03b1} (f : \u03b1 \u2192 \u03b2) (H : l\u2081 \u2286 l\u2082) : map f l\u2081 \u2286 map f l\u2082 :=\n\u03bb x, by simp only [mem_map, not_and, exists_imp_distrib, and_imp]; exact \u03bb a h e, \u27e8a, H h, e\u27e9\n\n/- append -/\n\nlemma append_eq_has_append {L\u2081 L\u2082 : list \u03b1} : list.append L\u2081 L\u2082 = L\u2081 ++ L\u2082 := rfl\n\ntheorem append_ne_nil_of_ne_nil_left (s t : list \u03b1) : s \u2260 [] \u2192 s ++ t \u2260 [] :=\nby induction s; intros; contradiction\n\ntheorem append_ne_nil_of_ne_nil_right (s t : list \u03b1) : t \u2260 [] \u2192 s ++ t \u2260 [] :=\nby induction s; intros; contradiction\n\ntheorem append_foldl (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (s t : list \u03b2) : 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (a : \u03b2) (s t : list \u03b1) : 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 \u03b1} : (p ++ q) = [] \u2194 p = [] \u2227 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 \u03b1} : [] = a ++ b \u2194 a = [] \u2227 b = [] :=\nby rw [eq_comm, append_eq_nil]\n\nlemma append_eq_cons_iff {a b c : list \u03b1} {x : \u03b1} :\n  a ++ b = x :: c \u2194 (a = [] \u2227 b = x :: c) \u2228 (\u2203a', a = x :: a' \u2227 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 \u03b1} {x : \u03b1} :\n  (x :: c : list \u03b1) = a ++ b \u2194 (a = [] \u2227 b = x :: c) \u2228 (\u2203a', a = x :: a' \u2227 c = a' ++ b) :=\nby rw [eq_comm, append_eq_cons_iff]\n\nlemma append_eq_append_iff {a b c d : list \u03b1} :\n  a ++ b = c ++ d \u2194 (\u2203a', c = a ++ a' \u2227 b = a' ++ d) \u2228 (\u2203c', a = c ++ c' \u2227 d = c' ++ b) :=\nbegin\n  induction a generalizing c,\n  case nil { rw nil_append, split,\n    { rintro rfl, left, exact \u27e8_, rfl, rfl\u27e9 },\n    { rintro (\u27e8a', rfl, rfl\u27e9 | \u27e8a', H, rfl\u27e9), {refl}, {rw [\u2190 append_assoc, \u2190 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 : \u2200 (n : \u2115) (l : list \u03b1), 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 : \u2200 (n : \u2115) (l : list \u03b1), 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 : \u2200 {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1}, s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082 \u2192 length s\u2081 = length s\u2082 \u2192 s\u2081 = s\u2082 \u2227 t\u2081 = t\u2082\n| []      []      t\u2081 t\u2082 h hl := \u27e8rfl, h\u27e9\n| (a::s\u2081) []      t\u2081 t\u2082 h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl\n| []      (b::s\u2082) t\u2081 t\u2082 h hl := list.no_confusion $ eq_nil_of_length_eq_zero hl.symm\n| (a::s\u2081) (b::s\u2082) t\u2081 t\u2082 h hl := list.no_confusion h $ \u03bbab hap,\n  let \u27e8e1, e2\u27e9 := @append_inj s\u2081 s\u2082 t\u2081 t\u2082 hap (succ.inj hl) in\n  by rw [ab, e1, e2]; exact \u27e8rfl, rfl\u27e9\n\ntheorem append_inj_left {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082) (hl : length s\u2081 = length s\u2082) : t\u2081 = t\u2082 :=\n(append_inj h hl).right\n\ntheorem append_inj_right {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082) (hl : length s\u2081 = length s\u2082) : s\u2081 = s\u2082 :=\n(append_inj h hl).left\n\ntheorem append_inj' {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082) (hl : length t\u2081 = length t\u2082) : s\u2081 = s\u2082 \u2227 t\u2081 = t\u2082 :=\nappend_inj h $ @nat.add_right_cancel _ (length t\u2081) _ $\nlet hap := congr_arg length h in by simp only [length_append] at hap; rwa [\u2190 hl] at hap\n\ntheorem append_inj_left' {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082) (hl : length t\u2081 = length t\u2082) : t\u2081 = t\u2082 :=\n(append_inj' h hl).right\n\ntheorem append_inj_right' {s\u2081 s\u2082 t\u2081 t\u2082 : list \u03b1} (h : s\u2081 ++ t\u2081 = s\u2082 ++ t\u2082) (hl : length t\u2081 = length t\u2082) : s\u2081 = s\u2082 :=\n(append_inj' h hl).left\n\ntheorem append_left_cancel {s t\u2081 t\u2082 : list \u03b1} (h : s ++ t\u2081 = s ++ t\u2082) : t\u2081 = t\u2082 :=\nappend_inj_left h rfl\n\ntheorem append_right_cancel {s\u2081 s\u2082 t : list \u03b1} (h : s\u2081 ++ t = s\u2082 ++ t) : s\u2081 = s\u2082 :=\nappend_inj_right' h rfl\n\ntheorem append_left_inj {t\u2081 t\u2082 : list \u03b1} (s) : s ++ t\u2081 = s ++ t\u2082 \u2194 t\u2081 = t\u2082 :=\n\u27e8append_left_cancel, congr_arg _\u27e9\n\ntheorem append_right_inj {s\u2081 s\u2082 : list \u03b1} (t) : s\u2081 ++ t = s\u2082 ++ t \u2194 s\u2081 = s\u2082 :=\n\u27e8append_right_cancel, congr_arg _\u27e9\n\ntheorem map_eq_append_split {f : \u03b1 \u2192 \u03b2} {l : list \u03b1} {s\u2081 s\u2082 : list \u03b2}\n  (h : map f l = s\u2081 ++ s\u2082) : \u2203 l\u2081 l\u2082, l = l\u2081 ++ l\u2082 \u2227 map f l\u2081 = s\u2081 \u2227 map f l\u2082 = s\u2082 :=\nbegin\n  have := h, rw [\u2190 take_append_drop (length s\u2081) l] at this \u22a2,\n  rw map_append at this,\n  refine \u27e8_, _, rfl, append_inj this _\u27e9,\n  rw [length_map, length_take, min_eq_left],\n  rw [\u2190 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 : \u2200 {L : list (list \u03b1)}, join L = [] \u2194 \u2200 l \u2208 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\u2081 L\u2082 : list (list \u03b1)) : join (L\u2081 ++ L\u2082) = join L\u2081 ++ join L\u2082 :=\nby induction L\u2081; [refl, simp only [*, join, cons_append, append_assoc]]\n\n/- repeat -/\n\n@[simp] theorem repeat_succ (a : \u03b1) (n) : repeat a (n + 1) = a :: repeat a n := rfl\n\ntheorem eq_of_mem_repeat {a b : \u03b1} : \u2200 {n}, b \u2208 repeat a n \u2192 b = a\n| (n+1) h := or.elim h id $ @eq_of_mem_repeat _\n\ntheorem eq_repeat_of_mem {a : \u03b1} : \u2200 {l : list \u03b1}, (\u2200 b \u2208 l, b = a) \u2192 l = repeat a l.length\n| []     H := rfl\n| (b::l) H := by cases forall_mem_cons.1 H with H\u2081 H\u2082;\n  unfold length repeat; congr; [exact H\u2081, exact eq_repeat_of_mem H\u2082]\n\ntheorem eq_repeat' {a : \u03b1} {l : list \u03b1} : l = repeat a l.length \u2194 \u2200 b \u2208 l, b = a :=\n\u27e8\u03bb h, h.symm \u25b8 \u03bb b, eq_of_mem_repeat, eq_repeat_of_mem\u27e9\n\ntheorem eq_repeat {a : \u03b1} {n} {l : list \u03b1} : l = repeat a n \u2194 length l = n \u2227 \u2200 b \u2208 l, b = a :=\n\u27e8\u03bb h, h.symm \u25b8 \u27e8length_repeat _ _, \u03bb b, eq_of_mem_repeat\u27e9,\n \u03bb \u27e8e, al\u27e9, e \u25b8 eq_repeat_of_mem al\u27e9\n\ntheorem repeat_add (a : \u03b1) (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 : \u03b1) (n) : repeat a n \u2286 [a] :=\n\u03bb b h, mem_singleton.2 (eq_of_mem_repeat h)\n\n@[simp] theorem map_const (l : list \u03b1) (b : \u03b2) : map (function.const \u03b1 b) l = repeat b l.length :=\nby induction l; [refl, simp only [*, map]]; split; refl\n\ntheorem eq_of_mem_map_const {b\u2081 b\u2082 : \u03b2} {l : list \u03b1} (h : b\u2081 \u2208 map (function.const \u03b1 b\u2082) l) : b\u2081 = b\u2082 :=\nby rw map_const at h; exact eq_of_mem_repeat h\n\n@[simp] theorem map_repeat (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (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 : \u03b1) (n) : tail (repeat a n) = repeat a n.pred :=\nby cases n; refl\n\n@[simp] theorem join_repeat_nil (n : \u2115) : join (repeat [] n) = @nil \u03b1 :=\nby induction n; [refl, simp only [*, repeat, join, append_nil]]\n\n/- bind -/\n\n@[simp] theorem bind_eq_bind {\u03b1 \u03b2} (f : \u03b1 \u2192 list \u03b2) (l : list \u03b1) :\n  l >>= f = l.bind f := rfl\n\n@[simp] theorem bind_append {\u03b1 \u03b2} (f : \u03b1 \u2192 list \u03b2) (l\u2081 l\u2082 : list \u03b1) :\n  (l\u2081 ++ l\u2082).bind f = l\u2081.bind f ++ l\u2082.bind f :=\nappend_bind _ _ _\n\n/- concat -/\n\n@[simp] theorem concat_nil (a : \u03b1) : concat [] a = [a] := rfl\n\n@[simp] theorem concat_cons (a b : \u03b1) (l : list \u03b1) : concat (a :: l) b = a :: concat l b := rfl\n\n@[simp] theorem concat_ne_nil (a : \u03b1) (l : list \u03b1) : concat l a \u2260 [] :=\nby induction l; intro h; contradiction\n\n@[simp] theorem concat_append (a : \u03b1) (l\u2081 l\u2082 : list \u03b1) : concat l\u2081 a ++ l\u2082 = l\u2081 ++ a :: l\u2082 :=\nby induction l\u2081; simp only [*, cons_append, concat]; split; refl\n\n@[simp] theorem concat_eq_append (a : \u03b1) (l : list \u03b1) : concat l a = l ++ [a] :=\nby induction l; simp only [*, concat]; split; refl\n\n@[simp] theorem length_concat (a : \u03b1) (l : list \u03b1) : length (concat l a) = succ (length l) :=\nby simp only [concat_eq_append, length_append, length]\n\ntheorem append_concat (a : \u03b1) (l\u2081 l\u2082 : list \u03b1) : l\u2081 ++ concat l\u2082 a = concat (l\u2081 ++ l\u2082) a :=\nby induction l\u2082 with b l\u2082 ih; simp only [concat_eq_append, nil_append, cons_append, append_assoc]\n\n/- reverse -/\n\n@[simp] theorem reverse_nil : reverse (@nil \u03b1) = [] := rfl\n\nlocal attribute [simp] reverse_core\n\n@[simp] theorem reverse_cons (a : \u03b1) (l : list \u03b1) : reverse (a::l) = reverse l ++ [a] :=\nhave aux : \u2200 l\u2081 l\u2082, reverse_core l\u2081 l\u2082 ++ [a] = reverse_core l\u2081 (l\u2082 ++ [a]),\nby intro l\u2081; induction l\u2081; intros; [refl, simp only [*, reverse_core, cons_append]],\n(aux l nil).symm\n\ntheorem reverse_core_eq (l\u2081 l\u2082 : list \u03b1) : reverse_core l\u2081 l\u2082 = reverse l\u2081 ++ l\u2082 :=\nby induction l\u2081 generalizing l\u2082; [refl, simp only [*, reverse_core, reverse_cons, append_assoc]]; refl\n\ntheorem reverse_cons' (a : \u03b1) (l : list \u03b1) : reverse (a::l) = concat (reverse l) a :=\nby simp only [reverse_cons, concat_eq_append]\n\n@[simp] theorem reverse_singleton (a : \u03b1) : reverse [a] = [a] := rfl\n\n@[simp] theorem reverse_append (s t : list \u03b1) : 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 \u03b1) : reverse (reverse l) = l :=\nby induction l; [refl, simp only [*, reverse_cons, reverse_append]]; refl\n\ntheorem reverse_injective : injective (@reverse \u03b1) :=\ninjective_of_left_inverse reverse_reverse\n\n@[simp] theorem reverse_inj {l\u2081 l\u2082 : list \u03b1} : reverse l\u2081 = reverse l\u2082 \u2194 l\u2081 = l\u2082 :=\nreverse_injective.eq_iff\n\n@[simp] theorem reverse_eq_nil {l : list \u03b1} : reverse l = [] \u2194 l = [] :=\n@reverse_inj _ l []\n\ntheorem concat_eq_reverse_cons (a : \u03b1) (l : list \u03b1) : 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 \u03b1) : length (reverse l) = length l :=\nby induction l; [refl, simp only [*, reverse_cons, length_append, length]]\n\n@[simp] theorem map_reverse (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) : 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 : \u03b1 \u2192 \u03b2) (l\u2081 l\u2082 : list \u03b1) :\n  map f (reverse_core l\u2081 l\u2082) = reverse_core (map f l\u2081) (map f l\u2082) :=\nby simp only [reverse_core_eq, map_append, map_reverse]\n\n@[simp] theorem mem_reverse {a : \u03b1} {l : list \u03b1} : a \u2208 reverse l \u2194 a \u2208 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 : \u03b1) (n) : reverse (repeat a n) = repeat a n :=\neq_repeat.2 \u27e8by simp only [length_reverse, length_repeat], \u03bb b h, eq_of_mem_repeat (mem_reverse.1 h)\u27e9\n\n@[elab_as_eliminator] def reverse_rec_on {C : list \u03b1 \u2192 Sort*}\n  (l : list \u03b1) (H0 : C [])\n  (H1 : \u2200 (l : list \u03b1) (a : \u03b1), C l \u2192 C (l ++ [a])) : C l :=\nbegin\n  rw \u2190 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 : \u03b1} {l : list \u03b1} : \u2200 (h\u2081 : a :: l \u2260 nil) (h\u2082 : l \u2260 nil), last (a :: l) h\u2081 = last l h\u2082 :=\nby {induction l; intros, contradiction, reflexivity}\n\n@[simp] theorem last_append {a : \u03b1} (l : list \u03b1) (h : l ++ [a] \u2260 []) : last (l ++ [a]) h = a :=\nby induction l; [refl, simp only [cons_append, last_cons _ (\u03bb H, cons_ne_nil _ _ (append_eq_nil.1 H).2), *]]\n\ntheorem last_concat {a : \u03b1} (l : list \u03b1) (h : concat l a \u2260 []) : last (concat l a) h = a :=\nby simp only [concat_eq_append, last_append]\n\n@[simp] theorem last_singleton (a : \u03b1) (h : [a] \u2260 []) : last [a] h = a := rfl\n\n@[simp] theorem last_cons_cons (a\u2081 a\u2082 : \u03b1) (l : list \u03b1) (h : a\u2081::a\u2082::l \u2260 []) :\n  last (a\u2081::a\u2082::l) h = last (a\u2082::l) (cons_ne_nil a\u2082 l) := rfl\n\ntheorem last_congr {l\u2081 l\u2082 : list \u03b1} (h\u2081 : l\u2081 \u2260 []) (h\u2082 : l\u2082 \u2260 []) (h\u2083 : l\u2081 = l\u2082) :\n  last l\u2081 h\u2081 = last l\u2082 h\u2082 :=\nby subst l\u2081\n\n/- head(') and tail -/\n\ntheorem head_eq_head' [inhabited \u03b1] (l : list \u03b1) : head l = (head' l).iget :=\nby cases l; refl\n\n@[simp] theorem head_cons [inhabited \u03b1] (a : \u03b1) (l : list \u03b1) : head (a::l) = a := rfl\n\n@[simp] theorem tail_nil : tail (@nil \u03b1) = [] := rfl\n\n@[simp] theorem tail_cons (a : \u03b1) (l : list \u03b1) : tail (a::l) = l := rfl\n\n@[simp] theorem head_append [inhabited \u03b1] (t : list \u03b1) {s : list \u03b1} (h : s \u2260 []) : head (s ++ t) = head s :=\nby {induction s, contradiction, refl}\n\ntheorem cons_head_tail [inhabited \u03b1] {l : list \u03b1} (h : l \u2260 []) : (head l)::(tail l) = l :=\nby {induction l, contradiction, refl}\n\n/- map -/\n\nlemma map_congr {f g : \u03b1 \u2192 \u03b2} : \u2200 {l : list \u03b1}, (\u2200 x \u2208 l, f x = g x) \u2192 map f l = map g l\n| []     _ := rfl\n| (a::l) h := let \u27e8h\u2081, h\u2082\u27e9 := forall_mem_cons.1 h in\n  by rw [map, map, h\u2081, map_congr h\u2082]\n\ntheorem map_concat (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (l : list \u03b1) : 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 : \u03b1 \u2192 \u03b1} (h : \u2200 x, f x = x) (l : list \u03b1) : map f l = l :=\nby induction l; [refl, simp only [*, map]]; split; refl\n\n@[simp] theorem foldl_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b3 \u2192 \u03b1) (a : \u03b1) (l : list \u03b2) : foldl f a (map g l) = foldl (\u03bbx 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 : \u03b2 \u2192 \u03b3) (f : \u03b3 \u2192 \u03b1 \u2192 \u03b1) (a : \u03b1) (l : list \u03b2) : foldr f a (map g l) = foldr (f \u2218 g) a l :=\nby revert a; induction l; intros; [refl, simp only [*, map, foldr]]\n\ntheorem foldl_hom (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3 \u2192 \u03b1) (g' : \u03b2 \u2192 \u03b3 \u2192 \u03b2) (a : \u03b1)\n  (h : \u2200a x, f (g a x) = g' (f a) x) (l : list \u03b3) : 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 : \u03b1 \u2192 \u03b2) (g : \u03b3 \u2192 \u03b1 \u2192 \u03b1) (g' : \u03b3 \u2192 \u03b2 \u2192 \u03b2) (a : \u03b1)\n  (h : \u2200x a, f (g x a) = g' x (f a)) (l : list \u03b3) : 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 : \u03b1 \u2192 \u03b2} {l : list \u03b1} (h : map f l = nil) : l = nil :=\neq_nil_of_length_eq_zero $ by rw [\u2190 length_map f l, h]; refl\n\n@[simp] theorem map_join (f : \u03b1 \u2192 \u03b2) (L : list (list \u03b1)) :\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) :\n  l.bind (list.ret \u2218 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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) :\n  f <$> l = map f l := rfl\n\n@[simp] theorem map_tail (f : \u03b1 \u2192 \u03b2) (l) : map f (tail l) = tail (map f l) :=\nby cases l; refl\n\n/- map\u2082 -/\n\ntheorem nil_map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l : list \u03b2) : map\u2082 f [] l = [] :=\nby cases l; refl\n\ntheorem map\u2082_nil (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (l : list \u03b1) : map\u2082 f l [] = [] :=\nby cases l; refl\n\n/- sublists -/\n\n@[simp] theorem nil_sublist : \u03a0 (l : list \u03b1), [] <+ l\n| []       := sublist.slnil\n| (a :: l) := sublist.cons _ _ a (nil_sublist l)\n\n@[refl, simp] theorem sublist.refl : \u03a0 (l : list \u03b1), l <+ l\n| []       := sublist.slnil\n| (a :: l) := sublist.cons2 _ _ a (sublist.refl l)\n\n@[trans] theorem sublist.trans {l\u2081 l\u2082 l\u2083 : list \u03b1} (h\u2081 : l\u2081 <+ l\u2082) (h\u2082 : l\u2082 <+ l\u2083) : l\u2081 <+ l\u2083 :=\nsublist.rec_on h\u2082 (\u03bb_ s, s)\n  (\u03bbl\u2082 l\u2083 a h\u2082 IH l\u2081 h\u2081, sublist.cons _ _ _ (IH l\u2081 h\u2081))\n  (\u03bbl\u2082 l\u2083 a h\u2082 IH l\u2081 h\u2081, @sublist.cases_on _ (\u03bbl\u2081 l\u2082', l\u2082' = a :: l\u2082 \u2192 l\u2081 <+ a :: l\u2083) _ _ h\u2081\n    (\u03bb_, nil_sublist _)\n    (\u03bbl\u2081 l\u2082' a' h\u2081' e, match a', l\u2082', e, h\u2081' with ._, ._, rfl, h\u2081 := sublist.cons _ _ _ (IH _ h\u2081) end)\n    (\u03bbl\u2081 l\u2082' a' h\u2081' e, match a', l\u2082', e, h\u2081' with ._, ._, rfl, h\u2081 := sublist.cons2 _ _ _ (IH _ h\u2081) end) rfl)\n  l\u2081 h\u2081\n\n@[simp] theorem sublist_cons (a : \u03b1) (l : list \u03b1) : l <+ a::l :=\nsublist.cons _ _ _ (sublist.refl l)\n\ntheorem sublist_of_cons_sublist {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} : a::l\u2081 <+ l\u2082 \u2192 l\u2081 <+ l\u2082 :=\nsublist.trans (sublist_cons a l\u2081)\n\ntheorem cons_sublist_cons {l\u2081 l\u2082 : list \u03b1} (a : \u03b1) (s : l\u2081 <+ l\u2082) : a::l\u2081 <+ a::l\u2082 :=\nsublist.cons2 _ _ _ s\n\n@[simp] theorem sublist_append_left : \u03a0 (l\u2081 l\u2082 : list \u03b1), l\u2081 <+ l\u2081++l\u2082\n| []      l\u2082 := nil_sublist _\n| (a::l\u2081) l\u2082 := cons_sublist_cons _ (sublist_append_left l\u2081 l\u2082)\n\n@[simp] theorem sublist_append_right : \u03a0 (l\u2081 l\u2082 : list \u03b1), l\u2082 <+ l\u2081++l\u2082\n| []      l\u2082 := sublist.refl _\n| (a::l\u2081) l\u2082 := sublist.cons _ _ _ (sublist_append_right l\u2081 l\u2082)\n\ntheorem sublist_cons_of_sublist (a : \u03b1) {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+ l\u2082 \u2192 l\u2081 <+ a::l\u2082 :=\nsublist.cons _ _ _\n\ntheorem sublist_app_of_sublist_left {l l\u2081 l\u2082 : list \u03b1} (s : l <+ l\u2081) : l <+ l\u2081++l\u2082 :=\ns.trans $ sublist_append_left _ _\n\ntheorem sublist_app_of_sublist_right {l l\u2081 l\u2082 : list \u03b1} (s : l <+ l\u2082) : l <+ l\u2081++l\u2082 :=\ns.trans $ sublist_append_right _ _\n\ntheorem sublist_of_cons_sublist_cons {l\u2081 l\u2082 : list \u03b1} : \u2200 {a : \u03b1}, a::l\u2081 <+ a::l\u2082 \u2192 l\u2081 <+ l\u2082\n| ._ (sublist.cons  ._ ._ a s) := sublist_of_cons_sublist s\n| ._ (sublist.cons2 ._ ._ a s) := s\n\ntheorem cons_sublist_cons_iff {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a::l\u2081 <+ a::l\u2082 \u2194 l\u2081 <+ l\u2082 :=\n\u27e8sublist_of_cons_sublist_cons, cons_sublist_cons _\u27e9\n\n@[simp] theorem append_sublist_append_left {l\u2081 l\u2082 : list \u03b1} : \u2200 l, l++l\u2081 <+ l++l\u2082 \u2194 l\u2081 <+ l\u2082\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\u2081 l\u2082 : list \u03b1} (h : l\u2081 <+ l\u2082) (l) : l\u2081++l <+ l\u2082++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\u2081 l\u2082 : list \u03b1} {a : \u03b1} (h : l <+ l\u2081 ++ a::l\u2082) : l <+ l\u2081 ++ l\u2082 \u2228 a \u2208 l :=\nbegin\n  induction l\u2081 with b l\u2081 IH generalizing l,\n  { cases h, { left, exact \u2039l <+ l\u2082\u203a }, { 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\u2081 l\u2082 : list \u03b1} (h : l\u2081 <+ l\u2082) : l\u2081.reverse <+ l\u2082.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\u2081 l\u2082 : list \u03b1} : l\u2081.reverse <+ l\u2082.reverse \u2194 l\u2081 <+ l\u2082 :=\n\u27e8\u03bb h, by have := reverse_sublist h; simp only [reverse_reverse] at this; assumption, reverse_sublist\u27e9\n\n@[simp] theorem append_sublist_append_right {l\u2081 l\u2082 : list \u03b1} (l) : l\u2081++l <+ l\u2082++l \u2194 l\u2081 <+ l\u2082 :=\n\u27e8\u03bb h, by have := reverse_sublist h; simp only [reverse_append, append_sublist_append_left, reverse_sublist_iff] at this; assumption,\n \u03bb h, append_sublist_append_of_sublist_right h l\u27e9\n\ntheorem subset_of_sublist : \u03a0 {l\u2081 l\u2082 : list \u03b1}, l\u2081 <+ l\u2082 \u2192 l\u2081 \u2286 l\u2082\n| ._ ._ sublist.slnil             b h := h\n| ._ ._ (sublist.cons  l\u2081 l\u2082 a s) b h := mem_cons_of_mem _ (subset_of_sublist s h)\n| ._ ._ (sublist.cons2 l\u2081 l\u2082 a s) b h :=\n  match eq_or_mem_of_mem_cons h with\n  | or.inl h := h \u25b8 mem_cons_self _ _\n  | or.inr h := mem_cons_of_mem _ (subset_of_sublist s h)\n  end\n\ntheorem singleton_sublist {a : \u03b1} {l} : [a] <+ l \u2194 a \u2208 l :=\n\u27e8\u03bb h, subset_of_sublist h (mem_singleton_self _), \u03bb h,\nlet \u27e8s, t, e\u27e9 := mem_split h in e.symm \u25b8\n  (cons_sublist_cons _ (nil_sublist _)).trans (sublist_append_right _ _)\u27e9\n\ntheorem eq_nil_of_sublist_nil {l : list \u03b1} (s : l <+ []) : l = [] :=\neq_nil_of_subset_nil $ subset_of_sublist s\n\ntheorem repeat_sublist_repeat (a : \u03b1) {m n} : repeat a m <+ repeat a n \u2194 m \u2264 n :=\n\u27e8\u03bb h, by simpa only [length_repeat] using length_le_of_sublist h,\n \u03bb h, by induction h; [refl, simp only [*, repeat_succ, sublist.cons]] \u27e9\n\ntheorem eq_of_sublist_of_length_eq : \u2200 {l\u2081 l\u2082 : list \u03b1}, l\u2081 <+ l\u2082 \u2192 length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082\n| ._ ._ sublist.slnil             h := rfl\n| ._ ._ (sublist.cons  l\u2081 l\u2082 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\u2081 l\u2082 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\u2081 l\u2082 : list \u03b1} (s : l\u2081 <+ l\u2082) (h : length l\u2082 \u2264 length l\u2081) : l\u2081 = l\u2082 :=\neq_of_sublist_of_length_eq s (le_antisymm (length_le_of_sublist s) h)\n\ntheorem sublist_antisymm {l\u2081 l\u2082 : list \u03b1} (s\u2081 : l\u2081 <+ l\u2082) (s\u2082 : l\u2082 <+ l\u2081) : l\u2081 = l\u2082 :=\neq_of_sublist_of_length_le s\u2081 (length_le_of_sublist s\u2082)\n\ninstance decidable_sublist [decidable_eq \u03b1] : \u2200 (l\u2081 l\u2082 : list \u03b1), decidable (l\u2081 <+ l\u2082)\n| []      l\u2082      := is_true $ nil_sublist _\n| (a::l\u2081) []      := is_false $ \u03bbh, list.no_confusion $ eq_nil_of_sublist_nil h\n| (a::l\u2081) (b::l\u2082) :=\n  if h : a = b then\n    decidable_of_decidable_of_iff (decidable_sublist l\u2081 l\u2082) $\n      by rw [\u2190 h]; exact \u27e8cons_sublist_cons _, sublist_of_cons_sublist_cons\u27e9\n  else decidable_of_decidable_of_iff (decidable_sublist (a::l\u2081) l\u2082)\n    \u27e8sublist_cons_of_sublist _, \u03bbs, match a, l\u2081, s, h with\n    | a, l\u2081, sublist.cons ._ ._ ._ s', h := s'\n    | ._, ._, sublist.cons2 t ._ ._ s', h := absurd rfl h\n    end\u27e9\n\n/- index_of -/\n\nsection index_of\nvariable [decidable_eq \u03b1]\n\n@[simp] theorem index_of_nil (a : \u03b1) : index_of a [] = 0 := rfl\n\ntheorem index_of_cons (a b : \u03b1) (l : list \u03b1) : 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 : \u03b1} (l : list \u03b1) : a = b \u2192 index_of a (b::l) = 0 :=\nassume e, if_pos e\n\n@[simp] theorem index_of_cons_self (a : \u03b1) (l : list \u03b1) : index_of a (a::l) = 0 :=\nindex_of_cons_eq _ rfl\n\n@[simp] theorem index_of_cons_ne {a b : \u03b1} (l : list \u03b1) : a \u2260 b \u2192 index_of a (b::l) = succ (index_of a l) :=\nassume n, if_neg n\n\ntheorem index_of_eq_length {a : \u03b1} {l : list \u03b1} : index_of a l = length l \u2194 a \u2209 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 \u27e8\u27e9) (\u03bb H, H $ or.inl h) },\n  { simp only [h, false_or], rw \u2190 ih, exact succ_inj' }\nend\n\n@[simp] theorem index_of_of_not_mem {l : list \u03b1} {a : \u03b1} : a \u2209 l \u2192 index_of a l = length l :=\nindex_of_eq_length.2\n\ntheorem index_of_le_length {a : \u03b1} {l : list \u03b1} : index_of a l \u2264 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 \u03b1} : index_of a l < length l \u2194 a \u2208 l :=\n\u27e8\u03bbh, by_contradiction $ \u03bb al, ne_of_lt h $ index_of_eq_length.2 al,\n\u03bbal, lt_of_le_of_ne index_of_le_length $ \u03bb h, index_of_eq_length.1 h al\u27e9\n\nend index_of\n\n/- nth element -/\n\ntheorem nth_le_of_mem : \u2200 {a} {l : list \u03b1}, a \u2208 l \u2192 \u2203 n h, nth_le l n h = a\n| a (_ :: l) (or.inl rfl) := \u27e80, succ_pos _, rfl\u27e9\n| a (b :: l) (or.inr m)   :=\n  let \u27e8n, h, e\u27e9 := nth_le_of_mem m in \u27e8n+1, succ_lt_succ h, e\u27e9\n\ntheorem nth_le_nth : \u2200 {l : list \u03b1} {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 : \u2200 {l : list \u03b1} {n}, n \u2265 length l \u2192 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 \u03b1} {n a} : nth l n = some a \u2194 \u2203 h, nth_le l n h = a :=\n\u27e8\u03bb e,\n  have h : n < length l, from lt_of_not_ge $ \u03bb hn,\n    by rw nth_ge_len hn at e; contradiction,\n  \u27e8h, by rw nth_le_nth h at e;\n    injection e with e; apply nth_le_mem\u27e9,\n\u03bb \u27e8h, e\u27e9, e \u25b8 nth_le_nth _\u27e9\n\ntheorem nth_of_mem {a} {l : list \u03b1} (h : a \u2208 l) : \u2203 n, nth l n = some a :=\nlet \u27e8n, h, e\u27e9 := nth_le_of_mem h in \u27e8n, by rw [nth_le_nth, e]\u27e9\n\ntheorem nth_le_mem : \u2200 (l : list \u03b1) n h, nth_le l n h \u2208 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 \u03b1} {n a} (e : nth l n = some a) : a \u2208 l :=\nlet \u27e8h, e\u27e9 := nth_eq_some.1 e in e \u25b8 nth_le_mem _ _ _\n\ntheorem mem_iff_nth_le {a} {l : list \u03b1} : a \u2208 l \u2194 \u2203 n h, nth_le l n h = a :=\n\u27e8nth_le_of_mem, \u03bb \u27e8n, h, e\u27e9, e \u25b8 nth_le_mem _ _ _\u27e9\n\ntheorem mem_iff_nth {a} {l : list \u03b1} : a \u2208 l \u2194 \u2203 n, nth l n = some a :=\nmem_iff_nth_le.trans $ exists_congr $ \u03bb n, nth_eq_some.symm\n\n@[simp] theorem nth_map (f : \u03b1 \u2192 \u03b2) : \u2200 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 : \u03b1 \u2192 \u03b2) {l n} (H1 H2) : nth_le (map f l) n H1 = f (nth_le l n H2) :=\noption.some.inj $ by rw [\u2190 nth_le_nth, nth_map, nth_le_nth]; refl\n\n@[simp] theorem nth_le_map' (f : \u03b1 \u2192 \u03b2) {l n} (H) :\n  nth_le (map f l) n H = f (nth_le l n (length_map f l \u25b8 H)) :=\nnth_le_map f _ _\n\n@[simp] lemma nth_le_singleton (a : \u03b1) {n : \u2115} (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 : \u2200 {l\u2081 l\u2082 : list \u03b1} {n : \u2115} (hn\u2081) (hn\u2082),\n  (l\u2081 ++ l\u2082).nth_le n hn\u2081 = l\u2081.nth_le n hn\u2082\n| []     _ n     hn\u2081 hn\u2082  := (not_lt_zero _ hn\u2082).elim\n| (a::l) _ 0     hn\u2081 hn\u2082 := rfl\n| (a::l) _ (n+1) hn\u2081 hn\u2082 := by simp only [nth_le, cons_append];\n                         exact nth_le_append _ _\n\n@[simp] lemma nth_le_repeat (a : \u03b1) {n m : \u2115} (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\u2081 l\u2082 : list \u03b1} {n : \u2115} (hn : n < l\u2081.length) :\n  (l\u2081 ++ l\u2082).nth n = l\u2081.nth n :=\nhave hn' : n < (l\u2081 ++ l\u2082).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: \u2200 (l : list \u03b1) (a : \u03b1), (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 : \u2200 {l\u2081 l\u2082 : list \u03b1}, (\u2200n, nth l\u2081 n = nth l\u2082 n) \u2192 l\u2081 = l\u2082\n| []      []       h := rfl\n| (a::l\u2081) []       h := by have h0 := h 0; contradiction\n| []      (a'::l\u2082) h := by have h0 := h 0; contradiction\n| (a::l\u2081) (a'::l\u2082) h := by have h0 : some a = some a' := h 0; injection h0 with aa;\n    simp only [aa, ext (\u03bbn, h (n+1))]; split; refl\n\ntheorem ext_le {l\u2081 l\u2082 : list \u03b1} (hl : length l\u2081 = length l\u2082) (h : \u2200n h\u2081 h\u2082, nth_le l\u2081 n h\u2081 = nth_le l\u2082 n h\u2082) : l\u2081 = l\u2082 :=\next $ \u03bbn, if h\u2081 : n < length l\u2081\n  then by rw [nth_le_nth, nth_le_nth, h n h\u2081 (by rwa [\u2190 hl])]\n  else let h\u2081 := le_of_not_gt h\u2081 in by rw [nth_ge_len h\u2081, nth_ge_len (by rwa [\u2190 hl])]\n\n@[simp] theorem index_of_nth_le [decidable_eq \u03b1] {a : \u03b1} : \u2200 {l : list \u03b1} 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 \u03b1] {a : \u03b1} {l : list \u03b1} (h : a \u2208 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 : \u2200 (l r : list \u03b1) (i h1 h2), nth_le (reverse_core l r) (i + length l) h1 = nth_le r i h2\n| []       r i := \u03bbh1 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  \u03bbh1 h2, nth_le_reverse_aux1 l (a :: r) (i+1) h1 (succ_lt_succ h2)\n\ntheorem nth_le_reverse_aux2 : \u2200 (l r : list \u03b1) (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 [\u2190 heq] at aux,\n    apply aux\n  end\n\n@[simp] theorem nth_le_reverse (l : list \u03b1) (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 \u03b1 \u2192 list \u03b1} (m : \u2115) :\n  \u2200n (l:list \u03b1), (l.modify_nth_tail f n).modify_nth_tail g (m + n) =\n    l.modify_nth_tail (\u03bbl, (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 \u03b1 \u2192 list \u03b1} (m n : \u2115) (l : list \u03b1) (h : n \u2264 m) :\n  (l.modify_nth_tail f n).modify_nth_tail g m =\n    l.modify_nth_tail (\u03bbl, (f l).modify_nth_tail g (m - n)) n :=\nbegin\n  rcases le_iff_exists_add.1 h with \u27e8m, rfl\u27e9,\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 \u03b1 \u2192 list \u03b1} (n : \u2115) (l:list \u03b1) :\n  (l.modify_nth_tail f n).modify_nth_tail g n = l.modify_nth_tail (g \u2218 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  \u2200n (l:list \u03b1), 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 : \u2200 n (l : list \u03b1), 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 : \u03b1) : \u2200 n (l : list \u03b1),\n  update_nth l n a = modify_nth (\u03bb _, 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 : \u03b1 \u2192 \u03b1) : \u2200 n (l : list \u03b1),\n  modify_nth f n l = ((\u03bb 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 : \u03b1 \u2192 \u03b1) : \u2200 n (l : list \u03b1) m,\n  nth (modify_nth f n l) m = (\u03bb 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 \u03b1 \u2192 list \u03b1) (H : \u2200 l, length (f l) = length l) :\n  \u2200 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 : \u03b1 \u2192 \u03b1) :\n  \u2200 n l, length (modify_nth f n l) = length l :=\nmodify_nth_tail_length _ (\u03bb l, by cases l; refl)\n\n@[simp] theorem update_nth_length (l : list \u03b1) (n) (a : \u03b1) :\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 : \u03b1 \u2192 \u03b1) (n) (l : list \u03b1) :\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 : \u03b1 \u2192 \u03b1) {m n} (l : list \u03b1) (h : m \u2260 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 : \u03b1) (n) (l : list \u03b1) :\n  nth (update_nth l n a) n = (\u03bb _, a) <$> nth l n :=\nby simp only [update_nth_eq_modify_nth, nth_modify_nth_eq]\n\ntheorem nth_update_nth_of_lt (a : \u03b1) {n} {l : list \u03b1} (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 : \u03b1) {m n} (l : list \u03b1) (h : m \u2260 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 : \u03b1}\n\n@[simp] lemma insert_nth_nil (a : \u03b1) : insert_nth 0 a [] = [a] := rfl\n\nlemma length_insert_nth : \u2200n as, n \u2264 length as \u2192 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:\u2115) (l : list \u03b1) : (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 : \u2200n m as, n < length as \u2192 m \u2265 n \u2192\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 : \u2200n m as, n < length as \u2192 m \u2264 n \u2192\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 : \u03b1) :\n  \u2200(i j : \u2115) (l : list \u03b1) (h : i \u2264 j) (hj : j \u2264 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\u2080 h\u2081,\n  by simp [insert_nth]; exact insert_nth_comm i j l (nat.le_of_succ_le_succ h\u2080) (nat.le_of_succ_le_succ h\u2081)\n\nend insert_nth\n\n/- take, drop -/\n@[simp] theorem take_zero (l : list \u03b1) : take 0 l = [] := rfl\n\n@[simp] theorem take_nil : \u2200 n, take n [] = ([] : list \u03b1)\n| 0     := rfl\n| (n+1) := rfl\n\ntheorem take_cons (n) (a : \u03b1) (l : list \u03b1) : take (succ n) (a::l) = a :: take n l := rfl\n\n@[simp] theorem take_all : \u2200 (l : list \u03b1), 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 : \u2200 {n} {l : list \u03b1}, n \u2265 length l \u2192 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 : \u2200 l\u2081 l\u2082 : list \u03b1, take (length l\u2081) (l\u2081 ++ l\u2082) = l\u2081\n| []      l\u2082 := rfl\n| (a::l\u2081) l\u2082 := congr_arg (cons a) (take_left l\u2081 l\u2082)\n\ntheorem take_left' {l\u2081 l\u2082 : list \u03b1} {n} (h : length l\u2081 = n) :\n  take n (l\u2081 ++ l\u2082) = l\u2081 :=\nby rw \u2190 h; apply take_left\n\ntheorem take_take : \u2200 (n m) (l : list \u03b1), 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 : \u2200 n, drop n [] = ([] : list \u03b1)\n| 0     := rfl\n| (n+1) := rfl\n\n@[simp] theorem drop_one : \u2200 l : list \u03b1, drop 1 l = tail l\n| []       := rfl\n| (a :: l) := rfl\n\ntheorem drop_add : \u2200 m n (l : list \u03b1), 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 : \u2200 l\u2081 l\u2082 : list \u03b1, drop (length l\u2081) (l\u2081 ++ l\u2082) = l\u2082\n| []      l\u2082 := rfl\n| (a::l\u2081) l\u2082 := drop_left l\u2081 l\u2082\n\ntheorem drop_left' {l\u2081 l\u2082 : list \u03b1} {n} (h : length l\u2081 = n) :\n  drop n (l\u2081 ++ l\u2082) = l\u2082 :=\nby rw \u2190 h; apply drop_left\n\ntheorem drop_eq_nth_le_cons : \u2200 {n} {l : list \u03b1} 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 \u03b1) : 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 : \u2200 {l\u2081 l\u2082 : list \u03b1} {n : \u2115}, n \u2264 l\u2081.length \u2192\n  (l\u2081 ++ l\u2082).drop n = l\u2081.drop n ++ l\u2082\n| l\u2081      l\u2082 0     hn := by simp\n| []      l\u2082 (n+1) hn := absurd hn dec_trivial\n| (a::l\u2081) l\u2082 (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 : \u2200 {l\u2081 l\u2082 : list \u03b1} {n : \u2115},\n  n \u2264 l\u2081.length \u2192 (l\u2081 ++ l\u2082).take n = l\u2081.take n\n| l\u2081      l\u2082 0     hn := by simp\n| []      l\u2082 (n+1) hn := absurd hn dec_trivial\n| (a::l\u2081) l\u2082 (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 : \u2115) : \u2200 (m) (l : list \u03b1), 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 : \u2200 (m : \u2115) (n : \u2115) (l : list \u03b1),\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 \u03b1 \u2192 list \u03b1) (H : f [] = []) :\n  \u2200 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 : \u03b1 \u2192 \u03b1) :\n  \u2200 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 : \u03b1 \u2192 \u03b1) {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 : \u03b1) {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 \u03b1) (n : \u2115) (a : \u03b1) : l.update_nth n a = [] \u2194 l = [] :=\nby cases l; cases n; simp only [update_nth]\n\nsection take'\nvariable [inhabited \u03b1]\n\n@[simp] theorem take'_length : \u2200 n l, length (@take' \u03b1 _ n l) = n\n| 0     l := rfl\n| (n+1) l := congr_arg succ (take'_length _ _)\n\n@[simp] theorem take'_nil : \u2200 n, take' n (@nil \u03b1) = repeat (default _) n\n| 0     := rfl\n| (n+1) := congr_arg (cons _) (take'_nil _)\n\ntheorem take'_eq_take : \u2200 {n} {l : list \u03b1},\n  n \u2264 length l \u2192 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\u2081 l\u2082 : list \u03b1) : take' (length l\u2081) (l\u2081 ++ l\u2082) = l\u2081 :=\n(take'_eq_take (by simp only [length_append, nat.le_add_right])).trans (take_left _ _)\n\ntheorem take'_left' {l\u2081 l\u2082 : list \u03b1} {n} (h : length l\u2081 = n) :\n  take' n (l\u2081 ++ l\u2082) = l\u2081 :=\nby rw \u2190 h; apply take'_left\n\nend take'\n\n/- foldl, foldr -/\n\nlemma foldl_ext (f g : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1)\n  {l : list \u03b2} (H : \u2200 a : \u03b1, \u2200 b \u2208 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 (\u03bb a b bin, H a b $ mem_cons_of_mem _ bin), H a hd (mem_cons_self _ _)]\nend\n\nlemma foldr_ext (f g : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2)\n  {l : list \u03b1} (H : \u2200 a \u2208 l, \u2200 b : \u03b2, 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) : foldl f a [] = a := rfl\n\n@[simp] theorem foldl_cons (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (b : \u03b2) (l : list \u03b2) :\n  foldl f a (b::l) = foldl f (f a b) l := rfl\n\n@[simp] theorem foldr_nil (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) : foldr f b [] = b := rfl\n\n@[simp] theorem foldr_cons (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (a : \u03b1) (l : list \u03b1) :\n  foldr f b (a::l) = f a (foldr f b l) := rfl\n\n@[simp] theorem foldl_append (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) :\n  \u2200 (a : \u03b1) (l\u2081 l\u2082 : list \u03b2), foldl f a (l\u2081++l\u2082) = foldl f (foldl f a l\u2081) l\u2082\n| a []      l\u2082 := rfl\n| a (b::l\u2081) l\u2082 := by simp only [cons_append, foldl_cons, foldl_append (f a b) l\u2081 l\u2082]\n\n@[simp] theorem foldr_append (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) :\n  \u2200 (b : \u03b2) (l\u2081 l\u2082 : list \u03b1), foldr f b (l\u2081++l\u2082) = foldr f (foldr f b l\u2082) l\u2081\n| b []      l\u2082 := rfl\n| b (a::l\u2081) l\u2082 := by simp only [cons_append, foldr_cons, foldr_append b l\u2081 l\u2082]\n\n@[simp] theorem foldl_join (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) :\n  \u2200 (a : \u03b1) (L : list (list \u03b2)), 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) :\n  \u2200 (b : \u03b2) (L : list (list \u03b1)), foldr f b (join L) = foldr (\u03bb 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (l : list \u03b2) : foldl f a (reverse l) = foldr (\u03bbx 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (a : \u03b2) (l : list \u03b1) : foldr f a (reverse l) = foldl (\u03bbx y, f y x) a l :=\nlet t := foldl_reverse (\u03bbx y, f y x) a (reverse l) in\nby rw reverse_reverse l at t; rwa t\n\n@[simp] theorem foldr_eta : \u2200 (l : list \u03b1), 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 \u03b1} : reverse (foldl (\u03bb t h, h :: t) [] l) = l :=\nby rw \u2190foldr_reverse; simp\n\n/- scanr -/\n\n@[simp] theorem scanr_nil (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) : scanr f b [] = [b] := rfl\n\n@[simp] theorem scanr_aux_cons (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) : \u2200 (a : \u03b1) (l : list \u03b1),\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (a : \u03b1) (l : list \u03b1) :\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 : \u03b1 \u2192 \u03b1 \u2192 \u03b1} (hcomm : commutative f) (hassoc : associative f)\n\n  include hassoc\n  theorem foldl1_eq_foldr1 : \u2200 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 : \u2200 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 [\u2190 foldl_eq_of_comm_of_assoc, right_comm _ hcomm hassoc]; refl\n\n  theorem foldl_eq_foldr : \u2200 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 : \u03b1 \u2192 \u03b1 \u2192 \u03b1} [ha : is_associative \u03b1 op] [hc : is_commutative \u03b1 op]\nlocal notation a * b := op a b\nlocal notation l <*> a := foldl op a l\n\ninclude ha\n\nlemma foldl_assoc : \u2200 {l : list \u03b1} {a\u2081 a\u2082}, l <*> (a\u2081 * a\u2082) = a\u2081 * (l <*> a\u2082)\n| [] a\u2081 a\u2082 := rfl\n| (a :: l) a\u2081 a\u2082 :=\n  calc a::l <*> (a\u2081 * a\u2082) = l <*> (a\u2081 * (a\u2082 * a)) : by simp only [foldl_cons, ha.assoc]\n    ... = a\u2081 * (a::l <*> a\u2082) : by rw [foldl_assoc, foldl_cons]\n\nlemma foldl_op_eq_op_foldr_assoc : \u2200{l : list \u03b1} {a\u2081 a\u2082}, (l <*> a\u2081) * a\u2082 = a\u2081 * l.foldr (*) a\u2082\n| [] a\u2081 a\u2082 := rfl\n| (a :: l) a\u2081 a\u2082 := 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 \u03b1} {a\u2081 a\u2082} : (a\u2081 :: l) <*> a\u2082 = a\u2081 * (l <*> a\u2082) :=\nby rw [foldl_cons, hc.comm, foldl_assoc]\n\nend\n\n/- mfoldl, mfoldr -/\n\nsection mfoldl_mfoldr\nvariables {m : Type v \u2192 Type w} [monad m]\n\n@[simp] theorem mfoldl_nil (f : \u03b2 \u2192 \u03b1 \u2192 m \u03b2) {b} : mfoldl f b [] = pure b := rfl\n\n@[simp] theorem mfoldr_nil (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) {b} : mfoldr f b [] = pure b := rfl\n\n@[simp] theorem mfoldl_cons {f : \u03b2 \u2192 \u03b1 \u2192 m \u03b2} {b a l} :\n  mfoldl f b (a :: l) = f b a >>= \u03bb b', mfoldl f b' l := rfl\n\n@[simp] theorem mfoldr_cons {f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2} {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 : \u03b2 \u2192 \u03b1 \u2192 m \u03b2} : \u2200 {b l\u2081 l\u2082},\n  mfoldl f b (l\u2081 ++ l\u2082) = mfoldl f b l\u2081 >>= \u03bb x, mfoldl f x l\u2082\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 : \u03b1 \u2192 \u03b2 \u2192 m \u03b2} : \u2200 {b l\u2081 l\u2082},\n  mfoldr f b (l\u2081 ++ l\u2082) = mfoldr f b l\u2082 >>= \u03bb x, mfoldr f x l\u2081\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 \u03b1] {l l\u2081 l\u2082 : list \u03b1} {a : \u03b1}\n\n@[simp, to_additive list.sum_nil]\ntheorem prod_nil : ([] : list \u03b1).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\u2081 ++ l\u2082).prod = l\u2081.prod * l\u2082.prod :=\ncalc (l\u2081 ++ l\u2082).prod = foldl (*) (foldl (*) 1 l\u2081 * 1) l\u2082 : by simp [list.prod]\n  ... = l\u2081.prod * l\u2082.prod : foldl_assoc\n\n@[simp, to_additive list.sum_join]\ntheorem prod_join {l : list (list \u03b1)} : 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 \u03b1] [comm_monoid \u03b1] {a} :\n  \u03a0 {l : list \u03b1}, a \u2208 l \u2192 a * (l.erase a).prod = l.prod\n| (b::l) h :=\n  begin\n    rcases eq_or_ne_mem_of_mem h with rfl | \u27e8ne, h\u27e9,\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 \u03b1] {a} {l : list \u03b1} (ha : a \u2208 l) : a \u2223 l.prod :=\nlet \u27e8s, t, h\u27e9 := 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 : \u2115) : 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 \u03b1)) : 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 \u03b1) (f : \u03b1 \u2192 list \u03b2) : length (list.bind l f) = sum (map (length \u2218 f) l) :=\nby rw [list.bind, length_join, map_map]\n\n/- lexicographic ordering -/\n\ninductive lex (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : list \u03b1 \u2192 list \u03b1 \u2192 Prop\n| nil {} {a l} : lex [] (a :: l)\n| cons {a l\u2081 l\u2082} (h : lex l\u2081 l\u2082) : lex (a :: l\u2081) (a :: l\u2082)\n| rel {a\u2081 l\u2081 a\u2082 l\u2082} (h : r a\u2081 a\u2082) : lex (a\u2081 :: l\u2081) (a\u2082 :: l\u2082)\n\nnamespace lex\ntheorem cons_iff {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_irrefl \u03b1 r] {a l\u2081 l\u2082} :\n  lex r (a :: l\u2081) (a :: l\u2082) \u2194 lex r l\u2081 l\u2082 :=\n\u27e8\u03bb h, by cases h with _ _ _ _ _ h _ _ _ _ h;\n  [exact h, exact (irrefl_of r a h).elim], lex.cons\u27e9\n\ninstance is_order_connected (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [is_order_connected \u03b1 r] [is_trichotomous \u03b1 r] :\n  is_order_connected (list \u03b1) (lex r) :=\n\u27e8\u03bb l\u2081, match l\u2081 with\n| _,     [],    c::l\u2083, nil    := or.inr nil\n| _,     [],    c::l\u2083, rel _ := or.inr nil\n| _,     [],    c::l\u2083, cons _ := or.inr nil\n| _,     b::l\u2082, c::l\u2083, nil := or.inl nil\n| a::l\u2081, b::l\u2082, c::l\u2083, rel h :=\n  (is_order_connected.conn _ b _ h).imp rel rel\n| a::l\u2081, b::l\u2082, _::l\u2083, cons h := begin\n    rcases trichotomous_of r a b with ab | rfl | ab,\n    { exact or.inl (rel ab) },\n    { exact (_match _ l\u2082 _ h).imp cons cons },\n    { exact or.inr (rel ab) }\n  end\nend\u27e9\n\ninstance is_trichotomous (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [is_trichotomous \u03b1 r] :\n  is_trichotomous (list \u03b1) (lex r) :=\n\u27e8\u03bb l\u2081, match l\u2081 with\n| [], [] := or.inr (or.inl rfl)\n| [], b::l\u2082 := or.inl nil\n| a::l\u2081, [] := or.inr (or.inr nil)\n| a::l\u2081, b::l\u2082 := begin\n    rcases trichotomous_of r a b with ab | rfl | ab,\n    { exact or.inl (rel ab) },\n    { exact (_match l\u2081 l\u2082).imp cons\n      (or.imp (congr_arg _) cons) },\n    { exact or.inr (or.inr (rel ab)) }\n  end\nend\u27e9\n\ninstance is_asymm (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [is_asymm \u03b1 r] : is_asymm (list \u03b1) (lex r) :=\n\u27e8\u03bb l\u2081, match l\u2081 with\n| a::l\u2081, b::l\u2082, lex.rel h\u2081, lex.rel h\u2082 := asymm h\u2081 h\u2082\n| a::l\u2081, b::l\u2082, lex.rel h\u2081, lex.cons h\u2082 := asymm h\u2081 h\u2081\n| a::l\u2081, b::l\u2082, lex.cons h\u2081, lex.rel h\u2082 := asymm h\u2082 h\u2082\n| a::l\u2081, b::l\u2082, lex.cons h\u2081, lex.cons h\u2082 :=\n  by exact _match _ _ h\u2081 h\u2082\nend\u27e9\n\ninstance is_strict_total_order (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [is_strict_total_order' \u03b1 r] : is_strict_total_order' (list \u03b1) (lex r) :=\n{..is_strict_weak_order_of_is_order_connected}\n\ninstance decidable_rel [decidable_eq \u03b1] (r : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  [decidable_rel r] : decidable_rel (lex r)\n| l\u2081 [] := is_false $ \u03bb h, by cases h\n| [] (b::l\u2082) := is_true lex.nil\n| (a::l\u2081) (b::l\u2082) := begin\n  haveI := decidable_rel l\u2081 l\u2082,\n  refine decidable_of_iff (r a b \u2228 a = b \u2227 lex r l\u2081 l\u2082) \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { rcases h with h | \u27e8rfl, h\u27e9,\n    { exact lex.rel h },\n    { exact lex.cons h } },\n  { rcases h with _|\u27e8_,_,_,h\u27e9|\u27e8_,_,_,_,h\u27e9,\n    { exact or.inr \u27e8rfl, h\u27e9 },\n    { exact or.inl h } }\nend\n\ntheorem append_right (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :\n  \u2200 {s\u2081 s\u2082} t, lex r s\u2081 s\u2082 \u2192 lex r s\u2081 (s\u2082 ++ t)\n| _ _ t nil      := nil\n| _ _ t (cons h) := cons (append_right _ h)\n| _ _ t (rel r)  := rel r\n\ntheorem append_left (R : \u03b1 \u2192 \u03b1 \u2192 Prop) {t\u2081 t\u2082} (h : lex R t\u2081 t\u2082) :\n  \u2200 s, lex R (s ++ t\u2081) (s ++ t\u2082)\n| []      := h\n| (a::l) := cons (append_left l)\n\ntheorem imp {r s : \u03b1 \u2192 \u03b1 \u2192 Prop} (H : \u2200 a b, r a b \u2192 s a b) :\n  \u2200 l\u2081 l\u2082, lex r l\u2081 l\u2082 \u2192 lex s l\u2081 l\u2082\n| _ _ nil      := nil\n| _ _ (cons h) := cons (imp _ _ h)\n| _ _ (rel r)  := rel (H _ _ r)\n\ntheorem to_ne : \u2200 {l\u2081 l\u2082 : list \u03b1}, lex (\u2260) l\u2081 l\u2082 \u2192 l\u2081 \u2260 l\u2082\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\u2081 l\u2082 : list \u03b1} (H : length l\u2081 \u2264 length l\u2082) :\n  lex (\u2260) l\u2081 l\u2082 \u2194 l\u2081 \u2260 l\u2082 :=\n\u27e8to_ne, \u03bb h, begin\n  induction l\u2081 with a l\u2081 IH generalizing l\u2082; cases l\u2082 with b l\u2082,\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\u27e9\n\nend lex\n\n--Note: this overrides an instance in core lean\ninstance has_lt' [has_lt \u03b1] : has_lt (list \u03b1) := \u27e8lex (<)\u27e9\n\ntheorem nil_lt_cons [has_lt \u03b1] (a : \u03b1) (l : list \u03b1) : [] < a :: l :=\nlex.nil\n\ninstance [linear_order \u03b1] : linear_order (list \u03b1) :=\nlinear_order_of_STO' (lex (<))\n\n--Note: this overrides an instance in core lean\ninstance has_le' [linear_order \u03b1] : has_le (list \u03b1) :=\npreorder.to_has_le _\n\ninstance [decidable_linear_order \u03b1] : decidable_linear_order (list \u03b1) :=\ndecidable_linear_order_of_STO' (lex (<))\n\n/- all & any -/\n\n@[simp] theorem all_nil (p : \u03b1 \u2192 bool) : all [] p = tt := rfl\n\n@[simp] theorem all_cons (p : \u03b1 \u2192 bool) (a : \u03b1) (l : list \u03b1) : all (a::l) p = (p a && all l p) := rfl\n\ntheorem all_iff_forall {p : \u03b1 \u2192 bool} {l : list \u03b1} : all l p \u2194 \u2200 a \u2208 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 : \u03b1 \u2192 Prop} [decidable_pred p]\n  {l : list \u03b1} : all l (\u03bb a, p a) \u2194 \u2200 a \u2208 l, p a :=\nby simp only [all_iff_forall, bool.of_to_bool_iff]\n\n@[simp] theorem any_nil (p : \u03b1 \u2192 bool) : any [] p = ff := rfl\n\n@[simp] theorem any_cons (p : \u03b1 \u2192 bool) (a : \u03b1) (l : list \u03b1) : any (a::l) p = (p a || any l p) := rfl\n\ntheorem any_iff_exists {p : \u03b1 \u2192 bool} {l : list \u03b1} : any l p \u2194 \u2203 a \u2208 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 : \u03b1 \u2192 Prop} [decidable_pred p]\n  {l : list \u03b1} : any l (\u03bb a, p a) \u2194 \u2203 a \u2208 l, p a :=\nby simp [any_iff_exists]\n\ntheorem any_of_mem {p : \u03b1 \u2192 bool} {a : \u03b1} {l : list \u03b1} (h\u2081 : a \u2208 l) (h\u2082 : p a) : any l p :=\nany_iff_exists.2 \u27e8_, h\u2081, h\u2082\u27e9\n\n@[priority 500] instance decidable_forall_mem {p : \u03b1 \u2192 Prop} [decidable_pred p] (l : list \u03b1) :\n  decidable (\u2200 x \u2208 l, p x) :=\ndecidable_of_iff _ all_iff_forall_prop\n\ninstance decidable_exists_mem {p : \u03b1 \u2192 Prop} [decidable_pred p] (l : list \u03b1) :\n  decidable (\u2203 x \u2208 l, p x) :=\ndecidable_of_iff _ any_iff_exists_prop\n\n/- map for partial functions -/\n\n/-- Partial map. If `f : \u03a0 a, p a \u2192 \u03b2` is a partial function defined on\n  `a : \u03b1` 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 : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) : \u03a0 l : list \u03b1, (\u2200 a \u2208 l, p a) \u2192 list \u03b2\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 \u2208 l}`. -/\ndef attach (l : list \u03b1) : list {x // x \u2208 l} := pmap subtype.mk l (\u03bb a, id)\n\ntheorem pmap_eq_map (p : \u03b1 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) (H) :\n  @pmap _ _ p (\u03bb a _, f a) l H = map f l :=\nby induction l; [refl, simp only [*, pmap, map]]; split; refl\n\ntheorem pmap_congr {p q : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2} {g : \u03a0 a, q a \u2192 \u03b2}\n  (l : list \u03b1) {H\u2081 H\u2082} (h : \u2200 a h\u2081 h\u2082, f a h\u2081 = g a h\u2082) :\n  pmap f l H\u2081 = pmap g l H\u2082 :=\nby induction l with _ _ ih; [refl, rw [pmap, pmap, h, ih]]\n\ntheorem map_pmap {p : \u03b1 \u2192 Prop} (g : \u03b2 \u2192 \u03b3) (f : \u03a0 a, p a \u2192 \u03b2)\n  (l H) : map g (pmap f l H) = pmap (\u03bb 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 : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2)\n  (l H) : pmap f l H = l.attach.map (\u03bb x, f x.1 (H _ x.2)) :=\nby rw [attach, map_pmap]; exact pmap_congr l (\u03bb a h\u2081 h\u2082, rfl)\n\ntheorem attach_map_val (l : list \u03b1) : 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 \u03b1) : \u2200 x, x \u2208 l.attach | \u27e8a, h\u27e9 :=\nby have := mem_map.1 (by rw [attach_map_val]; exact h);\n   { rcases this with \u27e8\u27e8_, _\u27e9, m, rfl\u27e9, exact m }\n\n@[simp] theorem mem_pmap {p : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2}\n  {l H b} : b \u2208 pmap f l H \u2194 \u2203 a (h : a \u2208 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 : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2}\n  {l H} : length (pmap f l H) = length l :=\nby induction l; [refl, simp only [*, pmap, length]]\n\n@[simp] lemma length_attach {\u03b1} (L : list \u03b1) : L.attach.length = L.length := length_pmap\n\n/- find -/\n\nsection find\nvariables {p : \u03b1 \u2192 Prop} [decidable_pred p] {l : list \u03b1} {a : \u03b1}\n\n@[simp] theorem find_nil (p : \u03b1 \u2192 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 : \u00ac p a) : find p (a::l) = find p l :=\nif_neg h\n\n@[simp] theorem find_eq_none : find p l = none \u2194 \u2200 x \u2208 l, \u00ac 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 \u2208 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 : \u03b1 \u2192 option \u03b1)\n\n@[simp] theorem lookmap_nil : [].lookmap f = [] := rfl\n\n@[simp] theorem lookmap_cons_none {a : \u03b1} (l : list \u03b1) (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 : \u03b1} (l : list \u03b1) (h : f a = some b) :\n  (a :: l).lookmap f = b :: l :=\nby simp [lookmap, h]\n\ntheorem lookmap_some : \u2200 l : list \u03b1, l.lookmap some = l\n| []     := rfl\n| (a::l) := rfl\n\ntheorem lookmap_none : \u2200 l : list \u03b1, l.lookmap (\u03bb _, none) = l\n| []     := rfl\n| (a::l) := congr_arg (cons a) (lookmap_none l)\n\ntheorem lookmap_congr {f g : \u03b1 \u2192 option \u03b1} :\n  \u2200 {l : list \u03b1}, (\u2200 a \u2208 l, f a = g a) \u2192 l.lookmap f = l.lookmap g\n| []     H := rfl\n| (a::l) H := begin\n  cases forall_mem_cons.1 H with H\u2081 H\u2082,\n  cases h : g a with b,\n  { simp [h, H\u2081.trans h, lookmap_congr H\u2082] },\n  { simp [lookmap_cons_some _ _ h, lookmap_cons_some _ _ (H\u2081.trans h)] }\nend\n\ntheorem lookmap_of_forall_not {l : list \u03b1} (H : \u2200 a \u2208 l, f a = none) : l.lookmap f = l :=\n(lookmap_congr H).trans (lookmap_none l)\n\ntheorem lookmap_map_eq (g : \u03b1 \u2192 \u03b2) (h : \u2200 a (b \u2208 f a), g a = g b) :\n  \u2200 l : list \u03b1, 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 : \u2200 a (b \u2208 f a), a = b) (l : list \u03b1) : l.lookmap f = l :=\nby rw [\u2190 map_id (l.lookmap f), lookmap_map_eq, map_id]; exact h\n\ntheorem length_lookmap (l : list \u03b1) : length (l.lookmap f) = length l :=\nby rw [\u2190 length_map, lookmap_map_eq _ (\u03bb _, ()), length_map]; simp\n\nend lookmap\n\n/- filter_map -/\n\n@[simp] theorem filter_map_nil (f : \u03b1 \u2192 option \u03b2) : filter_map f [] = [] := rfl\n\n@[simp] theorem filter_map_cons_none {f : \u03b1 \u2192 option \u03b2} (a : \u03b1) (l : list \u03b1) (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 : \u03b1 \u2192 option \u03b2)\n  (a : \u03b1) (l : list \u03b1) {b : \u03b2} (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 : \u03b1 \u2192 \u03b2) : filter_map (some \u2218 f) = map f :=\nbegin\n  funext l,\n  induction l with a l IH, {refl},\n  simp only [filter_map_cons_some (some \u2218 f) _ _ rfl, IH, map_cons], split; refl\nend\n\ntheorem filter_map_eq_filter (p : \u03b1 \u2192 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 : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 option \u03b3) (l : list \u03b1) :\n  filter_map g (filter_map f l) = filter_map (\u03bb 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 : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 \u03b3) (l : list \u03b1) :\n  map g (filter_map f l) = filter_map (\u03bb x, (f x).map g) l :=\nby rw [\u2190 filter_map_eq_map, filter_map_filter_map]; refl\n\ntheorem filter_map_map (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 option \u03b3) (l : list \u03b1) :\n  filter_map g (map f l) = filter_map (g \u2218 f) l :=\nby rw [\u2190 filter_map_eq_map, filter_map_filter_map]; refl\n\ntheorem filter_filter_map (f : \u03b1 \u2192 option \u03b2) (p : \u03b2 \u2192 Prop) [decidable_pred p] (l : list \u03b1) :\n  filter p (filter_map f l) = filter_map (\u03bb x, (f x).filter p) l :=\nby rw [\u2190 filter_map_eq_filter, filter_map_filter_map]; refl\n\ntheorem filter_map_filter (p : \u03b1 \u2192 Prop) [decidable_pred p] (f : \u03b1 \u2192 option \u03b2) (l : list \u03b1) :\n  filter_map f (filter p l) = filter_map (\u03bb x, if p x then f x else none) l :=\nbegin\n  rw [\u2190 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 \u03b1) : filter_map some l = l :=\nby rw filter_map_eq_map; apply map_id\n\n@[simp] theorem mem_filter_map (f : \u03b1 \u2192 option \u03b2) (l : list \u03b1) {b : \u03b2} :\n  b \u2208 filter_map f l \u2194 \u2203 a, a \u2208 l \u2227 f a = some b :=\nbegin\n  induction l with a l IH,\n  { split, { intro H, cases H }, { rintro \u27e8_, H, _\u27e9, cases H } },\n  cases h : f a with b',\n  { have : f a \u2260 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 \u2194 b = b',\n    { split; intro t, {rw t at h; injection h}, {exact t.symm \u25b8 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 : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 \u03b1)\n  (H : \u2200 x : \u03b1, (f x).map g = some x) (l : list \u03b1) :\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 : \u03b1 \u2192 option \u03b2) {l\u2081 l\u2082 : list \u03b1}\n  (s : l\u2081 <+ l\u2082) : filter_map f l\u2081 <+ filter_map f l\u2082 :=\nby induction s with l\u2081 l\u2082 a s IH l\u2081 l\u2082 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 : \u03b1 \u2192 \u03b2) {l\u2081 l\u2082 : list \u03b1}\n  (s : l\u2081 <+ l\u2082) : map f l\u2081 <+ map f l\u2082 :=\nby rw \u2190 filter_map_eq_map; exact filter_map_sublist_filter_map _ s\n\n/- filter -/\n\nsection filter\nvariables {p : \u03b1 \u2192 Prop} [decidable_pred p]\n\nlemma filter_congr {p q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q]\n  : \u2200 {l : list \u03b1}, (\u2200 x \u2208 l, p x \u2194 q x) \u2192 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 \u03b1) : filter p l \u2286 l :=\nsubset_of_sublist $ filter_sublist l\n\ntheorem of_mem_filter {a : \u03b1} : \u2200 {l}, a \u2208 filter p l \u2192 p a\n| (b::l) ain :=\n  if pb : p b then\n    have a \u2208 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 [\u2190 this] at pb, exact pb end)\n      (assume : a \u2208 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 : \u03b1} {l} (h : a \u2208 filter p l) : a \u2208 l :=\nfilter_subset l h\n\ntheorem mem_filter_of_mem {a : \u03b1} : \u2200 {l}, a \u2208 l \u2192 p a \u2192 a \u2208 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 : \u03b1} {l} : a \u2208 filter p l \u2194 a \u2208 l \u2227 p a :=\n\u27e8\u03bb h, \u27e8mem_of_mem_filter h, of_mem_filter h\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, mem_filter_of_mem h\u2081 h\u2082\u27e9\n\ntheorem filter_eq_self {l} : filter p l = l \u2194 \u2200 a \u2208 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 = [] \u2194 \u2200 a \u2208 l, \u00acp a :=\nby simp only [eq_nil_iff_forall_not_mem, mem_filter, not_and]\n\ntheorem filter_sublist_filter {l\u2081 l\u2082} (s : l\u2081 <+ l\u2082) : filter p l\u2081 <+ filter p l\u2082 :=\nby rw \u2190 filter_map_eq_filter; exact filter_map_sublist_filter_map _ s\n\ntheorem filter_of_map (f : \u03b2 \u2192 \u03b1) (l) : filter p (map f l) = map f (filter (p \u2218 f) l) :=\nby rw [\u2190 filter_map_eq_map, filter_filter_map, filter_map_filter]; refl\n\n@[simp] theorem filter_filter {q} [decidable_pred q] : \u2200 l,\n  filter p (filter q l) = filter (\u03bb a, p a \u2227 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 : \u03b1 \u2192 Prop) [decidable_pred p] : \u2200 (l : list \u03b1), 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 : \u03b1 \u2192 Prop) [decidable_pred p] : \u2200 (l : list \u03b1), 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 : \u03b1 \u2192 Prop) [decidable_pred p] : countp p [] = 0 := rfl\n\n@[simp] theorem countp_cons_of_pos {a : \u03b1} (l) (pa : p a) : countp p (a::l) = countp p l + 1 :=\nif_pos pa\n\n@[simp] theorem countp_cons_of_neg {a : \u03b1} (l) (pa : \u00ac 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\u2081 l\u2082) : countp p (l\u2081 ++ l\u2082) = countp p l\u2081 + countp p l\u2082 :=\nby simp only [countp_eq_length_filter, filter_append, length_append]\n\ntheorem countp_pos {l} : 0 < countp p l \u2194 \u2203 a \u2208 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\u2081 l\u2082} (s : l\u2081 <+ l\u2082) : countp p l\u2081 \u2264 countp p l\u2082 :=\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 \u03b1) :\n  countp p (filter q l) = countp (\u03bb a, p a \u2227 q a) l :=\nby simp only [countp_eq_length_filter, filter_filter]\n\nend filter\n\n/- count -/\n\nsection count\nvariable [decidable_eq \u03b1]\n\n@[simp] theorem count_nil (a : \u03b1) : count a [] = 0 := rfl\n\ntheorem count_cons (a b : \u03b1) (l : list \u03b1) :\n  count a (b :: l) = if a = b then succ (count a l) else count a l := rfl\n\ntheorem count_cons' (a b : \u03b1) (l : list \u03b1) :\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 : \u03b1) (l : list \u03b1) : count a (a::l) = succ (count a l) :=\nif_pos rfl\n\n@[simp] theorem count_cons_of_ne {a b : \u03b1} (h : a \u2260 b) (l : list \u03b1) : count a (b::l) = count a l :=\nif_neg h\n\ntheorem count_le_of_sublist (a : \u03b1) {l\u2081 l\u2082} : l\u2081 <+ l\u2082 \u2192 count a l\u2081 \u2264 count a l\u2082 :=\ncountp_le_of_sublist\n\ntheorem count_le_count_cons (a b : \u03b1) (l : list \u03b1) : count a l \u2264 count a (b :: l) :=\ncount_le_of_sublist _ (sublist_cons _ _)\n\ntheorem count_singleton (a : \u03b1) : count a [a] = 1 := if_pos rfl\n\n@[simp] theorem count_append (a : \u03b1) : \u2200 l\u2081 l\u2082, count a (l\u2081 ++ l\u2082) = count a l\u2081 + count a l\u2082 :=\ncountp_append\n\n@[simp] theorem count_concat (a : \u03b1) (l : list \u03b1) : count a (concat l a) = succ (count a l) :=\nby rw [concat_eq_append, count_append, count_singleton]\n\ntheorem count_pos {a : \u03b1} {l : list \u03b1} : 0 < count a l \u2194 a \u2208 l :=\nby simp only [count, countp_pos, exists_prop, exists_eq_right']\n\n@[simp] theorem count_eq_zero_of_not_mem {a : \u03b1} {l : list \u03b1} (h : a \u2209 l) : count a l = 0 :=\nby_contradiction $ \u03bb h', h $ count_pos.1 (nat.pos_of_ne_zero h')\n\ntheorem not_mem_of_count_eq_zero {a : \u03b1} {l : list \u03b1} (h : count a l = 0) : a \u2209 l :=\n\u03bb h', ne_of_gt (count_pos.2 h') h\n\n@[simp] theorem count_repeat (a : \u03b1) (n : \u2115) : count a (repeat a n) = n :=\nby rw [count, countp_eq_length_filter, filter_eq_self.2, length_repeat];\n   exact \u03bb b m, (eq_of_mem_repeat m).symm\n\ntheorem le_count_iff_repeat_sublist {a : \u03b1} {l : list \u03b1} {n : \u2115} : n \u2264 count a l \u2194 repeat a n <+ l :=\n\u27e8\u03bb h, ((repeat_sublist_repeat a).2 h).trans $\n  have filter (eq a) l = repeat a (count a l), from eq_repeat.2\n    \u27e8by simp only [count, countp_eq_length_filter], \u03bb b m, (of_mem_filter m).symm\u27e9,\n  by rw \u2190 this; apply filter_sublist,\n \u03bb h, by simpa only [count_repeat] using count_le_of_sublist a h\u27e9\n\n@[simp] theorem count_filter {p} [decidable_pred p]\n  {a} {l : list \u03b1} (h : p a) : count a (filter p l) = count a l :=\nby simp only [count, countp_filter]; congr; exact\nset.ext (\u03bb b, and_iff_left_of_imp (\u03bb e, e \u25b8 h))\n\nend count\n\n/- prefix, suffix, infix -/\n\n@[simp] theorem prefix_append (l\u2081 l\u2082 : list \u03b1) : l\u2081 <+: l\u2081 ++ l\u2082 := \u27e8l\u2082, rfl\u27e9\n\n@[simp] theorem suffix_append (l\u2081 l\u2082 : list \u03b1) : l\u2082 <:+ l\u2081 ++ l\u2082 := \u27e8l\u2081, rfl\u27e9\n\n@[simp] theorem infix_append (l\u2081 l\u2082 l\u2083 : list \u03b1) : l\u2082 <:+: l\u2081 ++ l\u2082 ++ l\u2083 := \u27e8l\u2081, l\u2083, rfl\u27e9\n\ntheorem nil_prefix (l : list \u03b1) : [] <+: l := \u27e8l, rfl\u27e9\n\ntheorem nil_suffix (l : list \u03b1) : [] <:+ l := \u27e8l, append_nil _\u27e9\n\n@[refl] theorem prefix_refl (l : list \u03b1) : l <+: l := \u27e8[], append_nil _\u27e9\n\n@[refl] theorem suffix_refl (l : list \u03b1) : l <:+ l := \u27e8[], rfl\u27e9\n\n@[simp] theorem suffix_cons (a : \u03b1) : \u2200 l, l <:+ a :: l := suffix_append [a]\n\n@[simp] theorem prefix_concat (a : \u03b1) (l) : l <+: concat l a :=\nby simp only [concat_eq_append, prefix_append]\n\ntheorem infix_of_prefix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+: l\u2082 \u2192 l\u2081 <:+: l\u2082 :=\n\u03bb\u27e8t, h\u27e9, \u27e8[], t, h\u27e9\n\ntheorem infix_of_suffix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+ l\u2082 \u2192 l\u2081 <:+: l\u2082 :=\n\u03bb\u27e8t, h\u27e9, \u27e8t, [], by simp only [h, append_nil]\u27e9\n\n@[refl] theorem infix_refl (l : list \u03b1) : l <:+: l := infix_of_prefix $ prefix_refl l\n\ntheorem nil_infix (l : list \u03b1) : [] <:+: l := infix_of_prefix $ nil_prefix l\n\ntheorem infix_cons {L\u2081 L\u2082 : list \u03b1} {x : \u03b1} : L\u2081 <:+: L\u2082 \u2192 L\u2081 <:+: x :: L\u2082 :=\n\u03bb\u27e8LP, LS, H\u27e9, \u27e8x :: LP, LS, H \u25b8 rfl\u27e9\n\n@[trans] theorem is_prefix.trans : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1}, l\u2081 <+: l\u2082 \u2192 l\u2082 <+: l\u2083 \u2192 l\u2081 <+: l\u2083\n| l ._ ._ \u27e8r\u2081, rfl\u27e9 \u27e8r\u2082, rfl\u27e9 := \u27e8r\u2081 ++ r\u2082, (append_assoc _ _ _).symm\u27e9\n\n@[trans] theorem is_suffix.trans : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1}, l\u2081 <:+ l\u2082 \u2192 l\u2082 <:+ l\u2083 \u2192 l\u2081 <:+ l\u2083\n| l ._ ._ \u27e8l\u2081, rfl\u27e9 \u27e8l\u2082, rfl\u27e9 := \u27e8l\u2082 ++ l\u2081, append_assoc _ _ _\u27e9\n\n@[trans] theorem is_infix.trans : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1}, l\u2081 <:+: l\u2082 \u2192 l\u2082 <:+: l\u2083 \u2192 l\u2081 <:+: l\u2083\n| l ._ ._ \u27e8l\u2081, r\u2081, rfl\u27e9 \u27e8l\u2082, r\u2082, rfl\u27e9 := \u27e8l\u2082 ++ l\u2081, r\u2081 ++ r\u2082, by simp only [append_assoc]\u27e9\n\ntheorem sublist_of_infix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+: l\u2082 \u2192 l\u2081 <+ l\u2082 :=\n\u03bb\u27e8s, t, h\u27e9, by rw [\u2190 h]; exact (sublist_append_right _ _).trans (sublist_append_left _ _)\n\ntheorem sublist_of_prefix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+: l\u2082 \u2192 l\u2081 <+ l\u2082 :=\nsublist_of_infix \u2218 infix_of_prefix\n\ntheorem sublist_of_suffix {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+ l\u2082 \u2192 l\u2081 <+ l\u2082 :=\nsublist_of_infix \u2218 infix_of_suffix\n\ntheorem reverse_suffix {l\u2081 l\u2082 : list \u03b1} : reverse l\u2081 <:+ reverse l\u2082 \u2194 l\u2081 <+: l\u2082 :=\n\u27e8\u03bb \u27e8r, e\u27e9, \u27e8reverse r,\n  by rw [\u2190 reverse_reverse l\u2081, \u2190 reverse_append, e, reverse_reverse]\u27e9,\n \u03bb \u27e8r, e\u27e9, \u27e8reverse r, by rw [\u2190 reverse_append, e]\u27e9\u27e9\n\ntheorem reverse_prefix {l\u2081 l\u2082 : list \u03b1} : reverse l\u2081 <+: reverse l\u2082 \u2194 l\u2081 <:+ l\u2082 :=\nby rw \u2190 reverse_suffix; simp only [reverse_reverse]\n\ntheorem length_le_of_infix {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <:+: l\u2082) : length l\u2081 \u2264 length l\u2082 :=\nlength_le_of_sublist $ sublist_of_infix s\n\ntheorem eq_nil_of_infix_nil {l : list \u03b1} (s : l <:+: []) : l = [] :=\neq_nil_of_sublist_nil $ sublist_of_infix s\n\ntheorem eq_nil_of_prefix_nil {l : list \u03b1} (s : l <+: []) : l = [] :=\neq_nil_of_infix_nil $ infix_of_prefix s\n\ntheorem eq_nil_of_suffix_nil {l : list \u03b1} (s : l <:+ []) : l = [] :=\neq_nil_of_infix_nil $ infix_of_suffix s\n\ntheorem infix_iff_prefix_suffix (l\u2081 l\u2082 : list \u03b1) : l\u2081 <:+: l\u2082 \u2194 \u2203 t, l\u2081 <+: t \u2227 t <:+ l\u2082 :=\n\u27e8\u03bb\u27e8s, t, e\u27e9, \u27e8l\u2081 ++ t, \u27e8_, rfl\u27e9, by rw [\u2190 e, append_assoc]; exact \u27e8_, rfl\u27e9\u27e9,\n\u03bb\u27e8._, \u27e8t, rfl\u27e9, \u27e8s, e\u27e9\u27e9, \u27e8s, t, by rw append_assoc; exact e\u27e9\u27e9\n\ntheorem eq_of_infix_of_length_eq {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <:+: l\u2082) : length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082 :=\neq_of_sublist_of_length_eq $ sublist_of_infix s\n\ntheorem eq_of_prefix_of_length_eq {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <+: l\u2082) : length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082 :=\neq_of_sublist_of_length_eq $ sublist_of_prefix s\n\ntheorem eq_of_suffix_of_length_eq {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <:+ l\u2082) : length l\u2081 = length l\u2082 \u2192 l\u2081 = l\u2082 :=\neq_of_sublist_of_length_eq $ sublist_of_suffix s\n\ntheorem prefix_of_prefix_length_le : \u2200 {l\u2081 l\u2082 l\u2083 : list \u03b1},\n l\u2081 <+: l\u2083 \u2192 l\u2082 <+: l\u2083 \u2192 length l\u2081 \u2264 length l\u2082 \u2192 l\u2081 <+: l\u2082\n| []      l\u2082 l\u2083 h\u2081 h\u2082 _ := nil_prefix _\n| (a::l\u2081) (b::l\u2082) _ \u27e8r\u2081, rfl\u27e9 \u27e8r\u2082, e\u27e9 ll := begin\n  injection e with _ e', subst b,\n  rcases prefix_of_prefix_length_le \u27e8_, rfl\u27e9 \u27e8_, e'\u27e9\n    (le_of_succ_le_succ ll) with \u27e8r\u2083, rfl\u27e9,\n  exact \u27e8r\u2083, rfl\u27e9\nend\n\ntheorem prefix_or_prefix_of_prefix {l\u2081 l\u2082 l\u2083 : list \u03b1}\n (h\u2081 : l\u2081 <+: l\u2083) (h\u2082 : l\u2082 <+: l\u2083) : l\u2081 <+: l\u2082 \u2228 l\u2082 <+: l\u2081 :=\n(le_total (length l\u2081) (length l\u2082)).imp\n  (prefix_of_prefix_length_le h\u2081 h\u2082)\n  (prefix_of_prefix_length_le h\u2082 h\u2081)\n\ntheorem suffix_of_suffix_length_le {l\u2081 l\u2082 l\u2083 : list \u03b1}\n (h\u2081 : l\u2081 <:+ l\u2083) (h\u2082 : l\u2082 <:+ l\u2083) (ll : length l\u2081 \u2264 length l\u2082) : l\u2081 <:+ l\u2082 :=\nreverse_prefix.1 $ prefix_of_prefix_length_le\n  (reverse_prefix.2 h\u2081) (reverse_prefix.2 h\u2082) (by simp [ll])\n\ntheorem suffix_or_suffix_of_suffix {l\u2081 l\u2082 l\u2083 : list \u03b1}\n (h\u2081 : l\u2081 <:+ l\u2083) (h\u2082 : l\u2082 <:+ l\u2083) : l\u2081 <:+ l\u2082 \u2228 l\u2082 <:+ l\u2081 :=\n(prefix_or_prefix_of_prefix (reverse_prefix.2 h\u2081) (reverse_prefix.2 h\u2082)).imp\n  reverse_prefix.1 reverse_prefix.1\n\ntheorem infix_of_mem_join : \u2200 {L : list (list \u03b1)} {l}, l \u2208 L \u2192 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\u2081 l\u2082 : list \u03b1} (l) : l ++ l\u2081 <+: l ++ l\u2082 \u2194 l\u2081 <+: l\u2082 :=\nexists_congr $ \u03bb r, by rw [append_assoc, append_left_inj]\n\ntheorem prefix_cons_inj {l\u2081 l\u2082 : list \u03b1} (a) : a :: l\u2081 <+: a :: l\u2082 \u2194 l\u2081 <+: l\u2082 :=\nprefix_append_left_inj [a]\n\ntheorem take_prefix (n) (l : list \u03b1) : take n l <+: l := \u27e8_, take_append_drop _ _\u27e9\n\ntheorem drop_suffix (n) (l : list \u03b1) : drop n l <:+ l := \u27e8_, take_append_drop _ _\u27e9\n\ntheorem prefix_iff_eq_append {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+: l\u2082 \u2194 l\u2081 ++ drop (length l\u2081) l\u2082 = l\u2082 :=\n\u27e8by rintros \u27e8r, rfl\u27e9; rw drop_left, \u03bb e, \u27e8_, e\u27e9\u27e9\n\ntheorem suffix_iff_eq_append {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+ l\u2082 \u2194 take (length l\u2082 - length l\u2081) l\u2082 ++ l\u2081 = l\u2082 :=\n\u27e8by rintros \u27e8r, rfl\u27e9; simp only [length_append, nat.add_sub_cancel, take_left], \u03bb e, \u27e8_, e\u27e9\u27e9\n\ntheorem prefix_iff_eq_take {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+: l\u2082 \u2194 l\u2081 = take (length l\u2081) l\u2082 :=\n\u27e8\u03bb h, append_right_cancel $\n  (prefix_iff_eq_append.1 h).trans (take_append_drop _ _).symm,\n \u03bb e, e.symm \u25b8 take_prefix _ _\u27e9\n\ntheorem suffix_iff_eq_drop {l\u2081 l\u2082 : list \u03b1} : l\u2081 <:+ l\u2082 \u2194 l\u2081 = drop (length l\u2082 - length l\u2081) l\u2082 :=\n\u27e8\u03bb h, append_left_cancel $\n  (suffix_iff_eq_append.1 h).trans (take_append_drop _ _).symm,\n \u03bb e, e.symm \u25b8 drop_suffix _ _\u27e9\n\ninstance decidable_prefix [decidable_eq \u03b1] : \u2200 (l\u2081 l\u2082 : list \u03b1), decidable (l\u2081 <+: l\u2082)\n| []      l\u2082 := is_true \u27e8l\u2082, rfl\u27e9\n| (a::l\u2081) [] := is_false $ \u03bb \u27e8t, te\u27e9, list.no_confusion te\n| (a::l\u2081) (b::l\u2082) :=\n  if h : a = b then\n    @decidable_of_iff _ _ (by rw [\u2190 h, prefix_cons_inj])\n      (decidable_prefix l\u2081 l\u2082)\n  else\n    is_false $ \u03bb \u27e8t, te\u27e9, h $ by injection te\n\n-- Alternatively, use mem_tails\ninstance decidable_suffix [decidable_eq \u03b1] : \u2200 (l\u2081 l\u2082 : list \u03b1), decidable (l\u2081 <:+ l\u2082)\n| []      l\u2082 := is_true \u27e8l\u2082, append_nil _\u27e9\n| (a::l\u2081) [] := is_false $ mt (length_le_of_sublist \u2218 sublist_of_suffix) dec_trivial\n| l\u2081      l\u2082 := let len1 := length l\u2081, len2 := length l\u2082 in\n  if hl : len1 \u2264 len2 then\n    decidable_of_iff' (l\u2081 = drop (len2-len1) l\u2082) suffix_iff_eq_drop\n  else is_false $ \u03bb h, hl $ length_le_of_sublist $ sublist_of_suffix h\n\n@[simp] theorem mem_inits : \u2200 (s t : list \u03b1), s \u2208 inits t \u2194 s <+: t\n| s []     := suffices s = nil \u2194 s <+: nil, by simpa only [inits, mem_singleton],\n  \u27e8\u03bbh, h.symm \u25b8 prefix_refl [], eq_nil_of_prefix_nil\u27e9\n| s (a::t) :=\n  suffices (s = nil \u2228 \u2203 l \u2208 inits t, a :: l = s) \u2194 s <+: a :: t, by simpa,\n  \u27e8\u03bbo, match s, o with\n  | ._, or.inl rfl := \u27e8_, rfl\u27e9\n  | s, or.inr \u27e8r, hr, hs\u27e9 := let \u27e8s, ht\u27e9 := (mem_inits _ _).1 hr in\n    by rw [\u2190 hs, \u2190 ht]; exact \u27e8s, rfl\u27e9\n  end, \u03bbmi, match s, mi with\n  | [], \u27e8._, rfl\u27e9 := or.inl rfl\n  | (b::s), \u27e8r, hr\u27e9 := list.no_confusion hr $ \u03bbba (st : s++r = t), or.inr $\n    by rw ba; exact \u27e8_, (mem_inits _ _).2 \u27e8_, st\u27e9, rfl\u27e9\n  end\u27e9\n\n@[simp] theorem mem_tails : \u2200 (s t : list \u03b1), s \u2208 tails t \u2194 s <:+ t\n| s []     := by simp only [tails, mem_singleton]; exact \u27e8\u03bbh, by rw h; exact suffix_refl [], eq_nil_of_suffix_nil\u27e9\n| s (a::t) := by simp only [tails, mem_cons_iff, mem_tails s t]; exact show s = a :: t \u2228 s <:+ t \u2194 s <:+ a :: t, from\n  \u27e8\u03bbo, match s, t, o with\n  | ._, t, or.inl rfl := suffix_refl _\n  | s, ._, or.inr \u27e8l, rfl\u27e9 := \u27e8a::l, rfl\u27e9\n  end, \u03bbe, match s, t, e with\n  | ._, t, \u27e8[], rfl\u27e9 := or.inl rfl\n  | s, t, \u27e8b::l, he\u27e9 := list.no_confusion he (\u03bbab lt, or.inr \u27e8l, lt\u27e9)\n  end\u27e9\n\ninstance decidable_infix [decidable_eq \u03b1] : \u2200 (l\u2081 l\u2082 : list \u03b1), decidable (l\u2081 <:+: l\u2082)\n| []      l\u2082 := is_true \u27e8[], l\u2082, rfl\u27e9\n| (a::l\u2081) [] := is_false $ \u03bb\u27e8s, t, te\u27e9, absurd te $ append_ne_nil_of_ne_nil_left _ _ $\n                append_ne_nil_of_ne_nil_right _ _ $ \u03bbh, list.no_confusion h\n| l\u2081      l\u2082 := decidable_of_decidable_of_iff (list.decidable_bex (\u03bbt, l\u2081 <+: t) (tails l\u2082)) $\n  by refine (exists_congr (\u03bbt, _)).trans (infix_iff_prefix_suffix _ _).symm;\n     exact \u27e8\u03bb\u27e8h1, h2\u27e9, \u27e8h2, (mem_tails _ _).1 h1\u27e9, \u03bb\u27e8h2, h1\u27e9, \u27e8(mem_tails _ _).2 h1, h2\u27e9\u27e9\n\n/- sublists -/\n\n@[simp] theorem sublists'_nil : sublists' (@nil \u03b1) = [[]] := rfl\n\n@[simp] theorem sublists'_singleton (a : \u03b1) : sublists' [a] = [[], [a]] := rfl\n\ntheorem map_sublists'_aux (g : list \u03b2 \u2192 list \u03b3) (l : list \u03b1) (f r) :\n  map g (sublists'_aux l f r) = sublists'_aux l (g \u2218 f) (map g r) :=\nby induction l generalizing f r; [refl, simp only [*, sublists'_aux]]\n\ntheorem sublists'_aux_append (r' : list (list \u03b2)) (l : list \u03b1) (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 \u03b1 \u03b2 l f r = map f (sublists' l) ++ r :=\nby rw [sublists', map_sublists'_aux, \u2190 sublists'_aux_append]; refl\n\n@[simp] theorem sublists'_cons (a : \u03b1) (l : list \u03b1) :\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 \u03b1} : s \u2208 sublists' t \u2194 s <+ t :=\nbegin\n  induction t with a t IH generalizing s,\n  { simp only [sublists'_nil, mem_singleton],\n    exact \u27e8\u03bb h, by rw h, eq_nil_of_sublist_nil\u27e9 },\n  simp only [sublists'_cons, mem_append, IH, mem_map],\n  split; intro h, rcases h with h | \u27e8s, h, rfl\u27e9,\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 \u27e8s, h, rfl\u27e9 } }\nend\n\n@[simp] theorem length_sublists' : \u2200 l : list \u03b1, 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 \u03b1) = [[]] := rfl\n\n@[simp] theorem sublists_singleton (a : \u03b1) : sublists [a] = [[], [a]] := rfl\n\ntheorem sublists_aux\u2081_eq_sublists_aux : \u2200 l (f : list \u03b1 \u2192 list \u03b2),\n  sublists_aux\u2081 l f = sublists_aux l (\u03bb ys r, f ys ++ r)\n| []     f := rfl\n| (a::l) f := by rw [sublists_aux\u2081, sublists_aux]; simp only [*, append_assoc]\n\ntheorem sublists_aux_cons_eq_sublists_aux\u2081 (l : list \u03b1) :\n  sublists_aux l cons = sublists_aux\u2081 l (\u03bb x, [x]) :=\nby rw [sublists_aux\u2081_eq_sublists_aux]; refl\n\ntheorem sublists_aux_eq_foldr.aux {a : \u03b1} {l : list \u03b1}\n  (IH\u2081 : \u2200 (f : list \u03b1 \u2192 list \u03b2 \u2192 list \u03b2), sublists_aux l f = foldr f [] (sublists_aux l cons))\n  (IH\u2082 : \u2200 (f : list \u03b1 \u2192 list (list \u03b1) \u2192 list (list \u03b1)),\n      sublists_aux l f = foldr f [] (sublists_aux l cons))\n  (f : list \u03b1 \u2192 list \u03b2 \u2192 list \u03b2) : sublists_aux (a::l) f = foldr f [] (sublists_aux (a::l) cons) :=\nbegin\n  simp only [sublists_aux, foldr_cons], rw [IH\u2082, IH\u2081], 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 \u03b1) : \u2200 (f : list \u03b1 \u2192 list \u03b2 \u2192 list \u03b2),\n  sublists_aux l f = foldr f [] (sublists_aux l cons) :=\nsuffices _ \u2227 \u2200 f : list \u03b1 \u2192 list (list \u03b1) \u2192 list (list \u03b1),\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 \u27e8sublists_aux_eq_foldr.aux IH.1 IH.2,\n         sublists_aux_eq_foldr.aux IH.2 IH.2\u27e9\nend\n\ntheorem sublists_aux_cons_cons (l : list \u03b1) (a : \u03b1) :\n  sublists_aux (a::l) cons = [a] :: foldr (\u03bbys r, ys :: (a :: ys) :: r) [] (sublists_aux l cons) :=\nby rw [\u2190 sublists_aux_eq_foldr]; refl\n\ntheorem sublists_aux\u2081_append : \u2200 (l\u2081 l\u2082 : list \u03b1) (f : list \u03b1 \u2192 list \u03b2),\n  sublists_aux\u2081 (l\u2081 ++ l\u2082) f = sublists_aux\u2081 l\u2081 f ++\n    sublists_aux\u2081 l\u2082 (\u03bb x, f x ++ sublists_aux\u2081 l\u2081 (f \u2218 (++ x)))\n| []      l\u2082 f := by simp only [sublists_aux\u2081, nil_append, append_nil]\n| (a::l\u2081) l\u2082 f := by simp only [sublists_aux\u2081, cons_append, sublists_aux\u2081_append l\u2081, append_assoc]; refl\n\ntheorem sublists_aux\u2081_concat (l : list \u03b1) (a : \u03b1) (f : list \u03b1 \u2192 list \u03b2) :\n  sublists_aux\u2081 (l ++ [a]) f = sublists_aux\u2081 l f ++\n    f [a] ++ sublists_aux\u2081 l (\u03bb x, f (x ++ [a])) :=\nby simp only [sublists_aux\u2081_append, sublists_aux\u2081, append_assoc, append_nil]\n\ntheorem sublists_aux\u2081_bind : \u2200 (l : list \u03b1)\n  (f : list \u03b1 \u2192 list \u03b2) (g : \u03b2 \u2192 list \u03b3),\n  (sublists_aux\u2081 l f).bind g = sublists_aux\u2081 l (\u03bb x, (f x).bind g)\n| []     f g := rfl\n| (a::l) f g := by simp only [sublists_aux\u2081, bind_append, sublists_aux\u2081_bind l]\n\ntheorem sublists_aux_cons_append (l\u2081 l\u2082 : list \u03b1) :\n  sublists_aux (l\u2081 ++ l\u2082) cons = sublists_aux l\u2081 cons ++\n    (do x \u2190 sublists_aux l\u2082 cons, (++ x) <$> sublists l\u2081) :=\nbegin\n  simp only [sublists, sublists_aux_cons_eq_sublists_aux\u2081, sublists_aux\u2081_append, bind_eq_bind, sublists_aux\u2081_bind],\n  congr, funext x, apply congr_arg _,\n  rw [\u2190 bind_ret_eq_map, sublists_aux\u2081_bind], exact (append_nil _).symm\nend\n\ntheorem sublists_append (l\u2081 l\u2082 : list \u03b1) :\n  sublists (l\u2081 ++ l\u2082) = (do x \u2190 sublists l\u2082, (++ x) <$> sublists l\u2081) :=\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' (\u03bb _, rfl)]; split; refl\n\n@[simp] theorem sublists_concat (l : list \u03b1) (a : \u03b1) :\n  sublists (l ++ [a]) = sublists l ++ map (\u03bb 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 \u03b1) : 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, (\u2218)]]\n\ntheorem sublists_eq_sublists' (l : list \u03b1) : sublists l = map reverse (sublists' (reverse l)) :=\nby rw [\u2190 sublists_reverse, reverse_reverse]\n\ntheorem sublists'_reverse (l : list \u03b1) : 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 \u03b1) : sublists' l = map reverse (sublists (reverse l)) :=\nby rw [\u2190 sublists'_reverse, reverse_reverse]\n\ntheorem sublists_aux_ne_nil : \u2200 (l : list \u03b1), [] \u2209 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 \u27e8ne_of_not_mem_cons this, ih (not_mem_of_not_mem_cons this)\u27e9\nend\n\n@[simp] theorem mem_sublists {s t : list \u03b1} : s \u2208 sublists t \u2194 s <+ t :=\nby rw [\u2190 reverse_sublist_iff, \u2190 mem_sublists',\n       sublists'_reverse, mem_map_of_inj reverse_injective]\n\n@[simp] theorem length_sublists (l : list \u03b1) : 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 \u03b1) : map list.ret l <+ sublists l :=\nreverse_rec_on l (nil_sublist _) $\n\u03bb 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 \u27e8[], mem_sublists.2 (nil_sublist _), by refl\u27e9).trans\n((append_sublist_append_right _).2 IH)\n\n/- forall\u2082 -/\n\nsection forall\u2082\nvariables {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop}\nopen relator relation\n\nrun_cmd tactic.mk_iff_of_inductive_prop `list.forall\u2082 `list.forall\u2082_iff\n\n@[simp] theorem forall\u2082_cons {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {a b l\u2081 l\u2082} :\n  forall\u2082 R (a::l\u2081) (b::l\u2082) \u2194 R a b \u2227 forall\u2082 R l\u2081 l\u2082 :=\n\u27e8\u03bb h, by cases h with h\u2081 h\u2082; split; assumption, \u03bb \u27e8h\u2081, h\u2082\u27e9, forall\u2082.cons h\u2081 h\u2082\u27e9\n\ntheorem forall\u2082.imp {R S : \u03b1 \u2192 \u03b2 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b) {l\u2081 l\u2082}\n  (h : forall\u2082 R l\u2081 l\u2082) : forall\u2082 S l\u2081 l\u2082 :=\nby induction h; constructor; solve_by_elim\n\nlemma forall\u2082.mp {r q s : \u03b1 \u2192 \u03b2 \u2192 Prop} (h : \u2200a b, r a b \u2192 q a b \u2192 s a b) :\n  \u2200{l\u2081 l\u2082}, forall\u2082 r l\u2081 l\u2082 \u2192 forall\u2082 q l\u2081 l\u2082 \u2192 forall\u2082 s l\u2081 l\u2082\n| []      []      forall\u2082.nil           forall\u2082.nil           := forall\u2082.nil\n| (a::l\u2081) (b::l\u2082) (forall\u2082.cons hr hrs) (forall\u2082.cons hq hqs) :=\n  forall\u2082.cons (h a b hr hq) (forall\u2082.mp hrs hqs)\n\nlemma forall\u2082.flip : \u2200{a b}, forall\u2082 (flip r) b a \u2192 forall\u2082 r a b\n| _ _                 forall\u2082.nil          := forall\u2082.nil\n| (a :: as) (b :: bs) (forall\u2082.cons h\u2081 h\u2082) := forall\u2082.cons h\u2081 h\u2082.flip\n\nlemma forall\u2082_same {r : \u03b1 \u2192 \u03b1 \u2192 Prop} : \u2200{l}, (\u2200x\u2208l, r x x) \u2192 forall\u2082 r l l\n| []      _ := forall\u2082.nil\n| (a::as) h := forall\u2082.cons\n    (h _ (mem_cons_self _ _))\n    (forall\u2082_same $ assume a ha, h a $ mem_cons_of_mem _ ha)\n\nlemma forall\u2082_refl {r} [is_refl \u03b1 r] (l : list \u03b1) : forall\u2082 r l l :=\nforall\u2082_same $ assume a h, is_refl.refl _ _\n\nlemma forall\u2082_eq_eq_eq : forall\u2082 ((=) : \u03b1 \u2192 \u03b1 \u2192 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\u2082_refl _ }\nend\n\n@[simp] lemma forall\u2082_nil_left_iff {l} : forall\u2082 r nil l \u2194 l = nil :=\n\u27e8\u03bb H, by cases H; refl, by rintro rfl; exact forall\u2082.nil\u27e9\n\n@[simp] lemma forall\u2082_nil_right_iff {l} : forall\u2082 r l nil \u2194 l = nil :=\n\u27e8\u03bb H, by cases H; refl, by rintro rfl; exact forall\u2082.nil\u27e9\n\nlemma forall\u2082_cons_left_iff {a l u} : forall\u2082 r (a::l) u \u2194 (\u2203b u', r a b \u2227 forall\u2082 r l u' \u2227 u = b :: u') :=\niff.intro\n  (assume h, match u, h with (b :: u'), forall\u2082.cons h\u2081 h\u2082 := \u27e8b, u', h\u2081, h\u2082, rfl\u27e9 end)\n  (assume h, match u, h with _, \u27e8b, u', h\u2081, h\u2082, rfl\u27e9 := forall\u2082.cons h\u2081 h\u2082 end)\n\nlemma forall\u2082_cons_right_iff {b l u} :\n  forall\u2082 r u (b::l) \u2194 (\u2203a u', r a b \u2227 forall\u2082 r u' l \u2227 u = a :: u') :=\niff.intro\n  (assume h, match u, h with (b :: u'), forall\u2082.cons h\u2081 h\u2082 := \u27e8b, u', h\u2081, h\u2082, rfl\u27e9 end)\n  (assume h, match u, h with _, \u27e8b, u', h\u2081, h\u2082, rfl\u27e9 := forall\u2082.cons h\u2081 h\u2082 end)\n\nlemma forall\u2082_and_left {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b1 \u2192 Prop} :\n  \u2200l u, forall\u2082 (\u03bba b, p a \u2227 r a b) l u \u2194 (\u2200a\u2208l, p a) \u2227 forall\u2082 r l u\n| []     u := by simp only [forall\u2082_nil_left_iff, forall_prop_of_false (not_mem_nil _), imp_true_iff, true_and]\n| (a::l) u := by simp only [forall\u2082_and_left l, forall\u2082_cons_left_iff, forall_mem_cons,\n    and_assoc, and_comm, and.left_comm, exists_and_distrib_left.symm]\n\n@[simp] lemma forall\u2082_map_left_iff {f : \u03b3 \u2192 \u03b1} :\n  \u2200{l u}, forall\u2082 r (map f l) u \u2194 forall\u2082 (\u03bbc b, r (f c) b) l u\n| []     _ := by simp only [map, forall\u2082_nil_left_iff]\n| (a::l) _ := by simp only [map, forall\u2082_cons_left_iff, forall\u2082_map_left_iff]\n\n@[simp] lemma forall\u2082_map_right_iff {f : \u03b3 \u2192 \u03b2} :\n  \u2200{l u}, forall\u2082 r l (map f u) \u2194 forall\u2082 (\u03bba c, r a (f c)) l u\n| _ []     := by simp only [map, forall\u2082_nil_right_iff]\n| _ (b::u) := by simp only [map, forall\u2082_cons_right_iff, forall\u2082_map_right_iff]\n\nlemma left_unique_forall\u2082 (hr : left_unique r) : left_unique (forall\u2082 r)\n| a\u2080 nil a\u2081 forall\u2082.nil forall\u2082.nil := rfl\n| (a\u2080::l\u2080) (b::l) (a\u2081::l\u2081) (forall\u2082.cons ha\u2080 h\u2080) (forall\u2082.cons ha\u2081 h\u2081) :=\n  hr ha\u2080 ha\u2081 \u25b8 left_unique_forall\u2082 h\u2080 h\u2081 \u25b8 rfl\n\nlemma right_unique_forall\u2082 (hr : right_unique r) : right_unique (forall\u2082 r)\n| nil a\u2080 a\u2081 forall\u2082.nil forall\u2082.nil := rfl\n| (b::l) (a\u2080::l\u2080) (a\u2081::l\u2081) (forall\u2082.cons ha\u2080 h\u2080) (forall\u2082.cons ha\u2081 h\u2081) :=\n  hr ha\u2080 ha\u2081 \u25b8 right_unique_forall\u2082 h\u2080 h\u2081 \u25b8 rfl\n\nlemma bi_unique_forall\u2082 (hr : bi_unique r) : bi_unique (forall\u2082 r) :=\n\u27e8assume a b c, left_unique_forall\u2082 hr.1, assume a b c, right_unique_forall\u2082 hr.2\u27e9\n\ntheorem forall\u2082_length_eq {R : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  \u2200 {l\u2081 l\u2082}, forall\u2082 R l\u2081 l\u2082 \u2192 length l\u2081 = length l\u2082\n| _ _ forall\u2082.nil          := rfl\n| _ _ (forall\u2082.cons h\u2081 h\u2082) := congr_arg succ (forall\u2082_length_eq h\u2082)\n\ntheorem forall\u2082_zip {R : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  \u2200 {l\u2081 l\u2082}, forall\u2082 R l\u2081 l\u2082 \u2192 \u2200 {a b}, (a, b) \u2208 zip l\u2081 l\u2082 \u2192 R a b\n| _ _ (forall\u2082.cons h\u2081 h\u2082) x y (or.inl rfl) := h\u2081\n| _ _ (forall\u2082.cons h\u2081 h\u2082) x y (or.inr h\u2083) := forall\u2082_zip h\u2082 h\u2083\n\ntheorem forall\u2082_iff_zip {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {l\u2081 l\u2082} : forall\u2082 R l\u2081 l\u2082 \u2194\n  length l\u2081 = length l\u2082 \u2227 \u2200 {a b}, (a, b) \u2208 zip l\u2081 l\u2082 \u2192 R a b :=\n\u27e8\u03bb h, \u27e8forall\u2082_length_eq h, @forall\u2082_zip _ _ _ _ _ h\u27e9,\n \u03bb h, begin\n  cases h with h\u2081 h\u2082,\n  induction l\u2081 with a l\u2081 IH generalizing l\u2082,\n  { cases length_eq_zero.1 h\u2081.symm, constructor },\n  { cases l\u2082 with b l\u2082; injection h\u2081 with h\u2081,\n    exact forall\u2082.cons (h\u2082 $ or.inl rfl) (IH h\u2081 $ \u03bb a b h, h\u2082 $ or.inr h) }\nend\u27e9\n\ntheorem forall\u2082_take {R : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  \u2200 n {l\u2081 l\u2082}, forall\u2082 R l\u2081 l\u2082 \u2192 forall\u2082 R (take n l\u2081) (take n l\u2082)\n| 0 _ _ _ := by simp only [forall\u2082.nil, take]\n| (n+1) _ _ (forall\u2082.nil) := by simp only [forall\u2082.nil, take]\n| (n+1) _ _ (forall\u2082.cons h\u2081 h\u2082) := by simp [and.intro h\u2081 h\u2082, forall\u2082_take n]\n\ntheorem forall\u2082_drop {R : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  \u2200 n {l\u2081 l\u2082}, forall\u2082 R l\u2081 l\u2082 \u2192 forall\u2082 R (drop n l\u2081) (drop n l\u2082)\n| 0 _ _ h := by simp only [drop, h]\n| (n+1) _ _ (forall\u2082.nil) := by simp only [forall\u2082.nil, drop]\n| (n+1) _ _ (forall\u2082.cons h\u2081 h\u2082) := by simp [and.intro h\u2081 h\u2082, forall\u2082_drop n]\n\ntheorem forall\u2082_take_append {R : \u03b1 \u2192 \u03b2 \u2192 Prop} (l : list \u03b1) (l\u2081 : list \u03b2) (l\u2082 : list \u03b2)\n  (h : forall\u2082 R l (l\u2081 ++ l\u2082)) : forall\u2082 R (list.take (length l\u2081) l) l\u2081 :=\nhave h': forall\u2082 R (take (length l\u2081) l) (take (length l\u2081) (l\u2081 ++ l\u2082)), from forall\u2082_take (length l\u2081) h,\nby rwa [take_left] at h'\n\ntheorem forall\u2082_drop_append {R : \u03b1 \u2192 \u03b2 \u2192 Prop} (l : list \u03b1) (l\u2081 : list \u03b2) (l\u2082 : list \u03b2)\n  (h : forall\u2082 R l (l\u2081 ++ l\u2082)) : forall\u2082 R (list.drop (length l\u2081) l) l\u2082 :=\nhave h': forall\u2082 R (drop (length l\u2081) l) (drop (length l\u2081) (l\u2081 ++ l\u2082)), from forall\u2082_drop (length l\u2081) h,\nby rwa [drop_left] at h'\n\nlemma rel_mem (hr : bi_unique r) : (r \u21d2 forall\u2082 r \u21d2 iff) (\u2208) (\u2208)\n| a b h [] [] forall\u2082.nil := by simp only [not_mem_nil]\n| a b h (a'::as) (b'::bs) (forall\u2082.cons h\u2081 h\u2082) := rel_or (rel_eq hr h h\u2081) (rel_mem h h\u2082)\n\nlemma rel_map : ((r \u21d2 p) \u21d2 forall\u2082 r \u21d2 forall\u2082 p) map map\n| f g h [] [] forall\u2082.nil := forall\u2082.nil\n| f g h (a::as) (b::bs) (forall\u2082.cons h\u2081 h\u2082) := forall\u2082.cons (h h\u2081) (rel_map @h h\u2082)\n\nlemma rel_append : (forall\u2082 r \u21d2 forall\u2082 r \u21d2 forall\u2082 r) append append\n| [] [] h l\u2081 l\u2082 hl := hl\n| (a::as) (b::bs) (forall\u2082.cons h\u2081 h\u2082) l\u2081 l\u2082 hl := forall\u2082.cons h\u2081 (rel_append h\u2082 hl)\n\nlemma rel_join : (forall\u2082 (forall\u2082 r) \u21d2 forall\u2082 r) join join\n| [] [] forall\u2082.nil := forall\u2082.nil\n| (a::as) (b::bs) (forall\u2082.cons h\u2081 h\u2082) := rel_append h\u2081 (rel_join h\u2082)\n\nlemma rel_bind : (forall\u2082 r \u21d2 (r \u21d2 forall\u2082 p) \u21d2 forall\u2082 p) list.bind list.bind :=\nassume a b h\u2081 f g h\u2082, rel_join (rel_map @h\u2082 h\u2081)\n\nlemma rel_foldl : ((p \u21d2 r \u21d2 p) \u21d2 p \u21d2 forall\u2082 r \u21d2 p) foldl foldl\n| f g hfg _ _ h _ _ forall\u2082.nil := h\n| f g hfg x y hxy _ _ (forall\u2082.cons hab hs) := rel_foldl @hfg (hfg hxy hab) hs\n\nlemma rel_foldr : ((r \u21d2 p \u21d2 p) \u21d2 p \u21d2 forall\u2082 r \u21d2 p) foldr foldr\n| f g hfg _ _ h _ _ forall\u2082.nil := h\n| f g hfg x y hxy _ _ (forall\u2082.cons hab hs) := hfg hab (rel_foldr @hfg hxy hs)\n\nlemma rel_filter {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} [decidable_pred p] [decidable_pred q]\n  (hpq : (r \u21d2 (\u2194)) p q) :\n  (forall\u2082 r \u21d2 forall\u2082 r) (filter p) (filter q)\n| _ _ forall\u2082.nil := forall\u2082.nil\n| (a::as) (b::bs) (forall\u2082.cons h\u2081 h\u2082) :=\n  begin\n    by_cases p a,\n    { have : q b, { rwa [\u2190 hpq h\u2081] },\n      simp only [filter_cons_of_pos _ h, filter_cons_of_pos _ this, forall\u2082_cons, h\u2081, rel_filter h\u2082, and_true], },\n    { have : \u00ac q b, { rwa [\u2190 hpq h\u2081] },\n      simp only [filter_cons_of_neg _ h, filter_cons_of_neg _ this, rel_filter h\u2082], },\n  end\n\ntheorem filter_map_cons (f : \u03b1 \u2192 option \u03b2) (a : \u03b1) (l : list \u03b1) :\n  filter_map f (a :: l) = option.cases_on (f a) (filter_map f l) (\u03bbb, 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 : \u03b1 \u2192 option \u03b3} {q : \u03b2 \u2192 option \u03b4} :\n  ((r \u21d2 option.rel p) \u21d2 forall\u2082 r \u21d2 forall\u2082 p) filter_map filter_map\n| f g hfg _ _ forall\u2082.nil := forall\u2082.nil\n| f g hfg (a::as) (b::bs) (forall\u2082.cons h\u2081 h\u2082) :=\n  by rw [filter_map_cons, filter_map_cons];\n  from match f a, g b, hfg h\u2081 with\n  | _, _, option.rel.none := rel_filter_map @hfg h\u2082\n  | _, _, option.rel.some h := forall\u2082.cons h (rel_filter_map @hfg h\u2082)\n  end\n\n@[to_additive list.rel_sum]\nlemma rel_prod [monoid \u03b1] [monoid \u03b2]\n  (h : r 1 1) (hf : (r \u21d2 r \u21d2 r) (*) (*)) : (forall\u2082 r \u21d2 r) prod prod :=\nassume a b, rel_foldl (assume a b, hf) h\n\nend forall\u2082\n\n/- sections -/\n\ntheorem mem_sections {L : list (list \u03b1)} {f} : f \u2208 sections L \u2194 forall\u2082 (\u2208) f L :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { induction L generalizing f, {cases mem_singleton.1 h, exact forall\u2082.nil},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map] at h,\n    rcases h with \u27e8_, _, _, _, rfl\u27e9,\n    simp only [*, forall\u2082_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 \u27e8_, fs, _, al, rfl, rfl\u27e9 }\nend\n\ntheorem mem_sections_length {L : list (list \u03b1)} {f} (h : f \u2208 sections L) : length f = length L :=\nforall\u2082_length_eq (mem_sections.1 h)\n\nlemma rel_sections {r : \u03b1 \u2192 \u03b2 \u2192 Prop} : (forall\u2082 (forall\u2082 r) \u21d2 forall\u2082 (forall\u2082 r)) sections sections\n| _ _ forall\u2082.nil := forall\u2082.cons forall\u2082.nil forall\u2082.nil\n| _ _ (forall\u2082.cons h\u2080 h\u2081) :=\n  rel_bind (rel_sections h\u2081) (assume _ _ hl, rel_map (assume _ _ ha, forall\u2082.cons ha hl) h\u2080)\n\n/- permutations -/\n\nsection permutations\n\n@[simp] theorem permutations_aux_nil (is : list \u03b1) : permutations_aux [] is = [] :=\nby rw [permutations_aux, permutations_aux.rec]\n\n@[simp] theorem permutations_aux_cons (t : \u03b1) (ts is : list \u03b1) :\n  permutations_aux (t :: ts) is = foldr (\u03bby 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 \u03b1]\n\n@[simp] theorem insert_nil (a : \u03b1) : insert a nil = [a] := rfl\n\ntheorem insert.def (a : \u03b1) (l : list \u03b1) : insert a l = if a \u2208 l then l else a :: l := rfl\n\n@[simp] theorem insert_of_mem {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) : insert a l = l :=\nby simp only [insert.def, if_pos h]\n\n@[simp] theorem insert_of_not_mem {a : \u03b1} {l : list \u03b1} (h : a \u2209 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 : \u03b1} {l : list \u03b1} : a \u2208 insert b l \u2194 a = b \u2228 a \u2208 l :=\nbegin\n  by_cases h' : b \u2208 l,\n  { simp only [insert_of_mem h'],\n    apply (or_iff_right_of_imp _).symm,\n    exact \u03bb e, e.symm \u25b8 h' },\n  simp only [insert_of_not_mem h', mem_cons_iff]\nend\n\n@[simp] theorem suffix_insert (a : \u03b1) (l : list \u03b1) : l <:+ insert a l :=\nby by_cases a \u2208 l; [simp only [insert_of_mem h], simp only [insert_of_not_mem h, suffix_cons]]\n\n@[simp] theorem mem_insert_self (a : \u03b1) (l : list \u03b1) : a \u2208 insert a l :=\nmem_insert_iff.2 (or.inl rfl)\n\n@[simp] theorem mem_insert_of_mem {a b : \u03b1} {l : list \u03b1} (h : a \u2208 l) : a \u2208 insert b l :=\nmem_insert_iff.2 (or.inr h)\n\ntheorem eq_or_mem_of_mem_insert {a b : \u03b1} {l : list \u03b1} (h : a \u2208 insert b l) : a = b \u2228 a \u2208 l :=\nmem_insert_iff.1 h\n\n@[simp] theorem length_insert_of_mem {a : \u03b1} [decidable_eq \u03b1] {l : list \u03b1} (h : a \u2208 l) :\n  length (insert a l) = length l :=\nby rw insert_of_mem h\n\n@[simp] theorem length_insert_of_not_mem {a : \u03b1} [decidable_eq \u03b1] {l : list \u03b1} (h : a \u2209 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 : \u03b1 \u2192 Prop} [decidable_pred p]\n\n@[simp] theorem erasep_nil : [].erasep p = [] := rfl\n\ntheorem erasep_cons (a : \u03b1) (l : list \u03b1) : (a :: l).erasep p = if p a then l else a :: l.erasep p := rfl\n\n@[simp] theorem erasep_cons_of_pos {a : \u03b1} {l : list \u03b1} (h : p a) : (a :: l).erasep p = l :=\nby simp [erasep_cons, h]\n\n@[simp] theorem erasep_cons_of_neg {a : \u03b1} {l : list \u03b1} (h : \u00ac p a) : (a::l).erasep p = a :: l.erasep p :=\nby simp [erasep_cons, h]\n\ntheorem erasep_of_forall_not {l : list \u03b1}\n  (h : \u2200 a \u2208 l, \u00ac 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 \u03b1} {a} (al : a \u2208 l) (pa : p a) :\n  \u2203 a l\u2081 l\u2082, (\u2200 b \u2208 l\u2081, \u00ac p b) \u2227 p a \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.erasep p = l\u2081 ++ l\u2082 :=\nbegin\n  induction l with b l IH, {cases al},\n  by_cases pb : p b,\n  { exact \u27e8b, [], l, forall_mem_nil _, pb, by simp [pb]\u27e9 },\n  { rcases al with rfl | al, {exact pb.elim pa},\n    rcases IH al with \u27e8c, l\u2081, l\u2082, h\u2081, h\u2082, h\u2083, h\u2084\u27e9,\n    exact \u27e8c, b::l\u2081, l\u2082, forall_mem_cons.2 \u27e8pb, h\u2081\u27e9,\n      h\u2082, by rw h\u2083; refl, by simp [pb, h\u2084]\u27e9 }\nend\n\ntheorem exists_or_eq_self_of_erasep (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : list \u03b1) :\n  l.erasep p = l \u2228 \u2203 a l\u2081 l\u2082, (\u2200 b \u2208 l\u2081, \u00ac p b) \u2227 p a \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.erasep p = l\u2081 ++ l\u2082 :=\nbegin\n  by_cases h : \u2203 a \u2208 l, p a,\n  { rcases h with \u27e8a, ha, pa\u27e9,\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 \u03b1} {a} (al : a \u2208 l) (pa : p a) :\n length (l.erasep p) = pred (length l) :=\nby rcases exists_of_erasep al pa with \u27e8_, l\u2081, l\u2082, _, _, e\u2081, e\u2082\u27e9;\n   rw e\u2082; simp [-add_comm, e\u2081]; refl\n\ntheorem erasep_append_left {a : \u03b1} (pa : p a) :\n  \u2200 {l\u2081 : list \u03b1} (l\u2082), a \u2208 l\u2081 \u2192 (l\u2081++l\u2082).erasep p = l\u2081.erasep p ++ l\u2082\n| (x::xs) l\u2082 h := begin\n  by_cases h' : p x; simp [h'],\n  rw erasep_append_left l\u2082 (mem_of_ne_of_mem (mt _ h') h),\n  rintro rfl, exact pa\nend\n\ntheorem erasep_append_right : \u2200 {l\u2081 : list \u03b1} (l\u2082), (\u2200 b \u2208 l\u2081, \u00ac p b) \u2192 (l\u2081++l\u2082).erasep p = l\u2081 ++ l\u2082.erasep p\n| []      l\u2082 h := rfl\n| (x::xs) l\u2082 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 \u03b1) : l.erasep p <+ l :=\nby rcases exists_or_eq_self_of_erasep p l with h | \u27e8c, l\u2081, l\u2082, h\u2081, h\u2082, h\u2083, h\u2084\u27e9;\n   [rw h, {rw [h\u2084, h\u2083], simp}]\n\ntheorem erasep_subset (l : list \u03b1) : l.erasep p \u2286 l :=\nsubset_of_sublist (erasep_sublist l)\n\ntheorem erasep_sublist_erasep {l\u2081 l\u2082 : list \u03b1} (s : l\u2081 <+ l\u2082) : l\u2081.erasep p <+ l\u2082.erasep p :=\nbegin\n  induction s,\n  case list.sublist.slnil { refl },\n  case list.sublist.cons : l\u2081 l\u2082 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\u2081 l\u2082 a s IH {\n    by_cases h : p a; simp [h],\n    exacts [s, IH.cons2 _ _ _] }\nend\n\ntheorem mem_of_mem_erasep {a : \u03b1} {l : list \u03b1} : a \u2208 l.erasep p \u2192 a \u2208 l :=\n@erasep_subset _ _ _ _ _\n\n@[simp] theorem mem_erasep_of_neg {a : \u03b1} {l : list \u03b1} (pa : \u00ac p a) : a \u2208 l.erasep p \u2194 a \u2208 l :=\n\u27e8mem_of_mem_erasep, \u03bb al, begin\n  rcases exists_or_eq_self_of_erasep p l with h | \u27e8c, l\u2081, l\u2082, h\u2081, h\u2082, h\u2083, h\u2084\u27e9,\n  { rwa h },\n  { rw h\u2084, rw h\u2083 at al,\n    have : a \u2260 c, {rintro rfl, exact pa.elim h\u2082},\n    simpa [this] using al }\nend\u27e9\n\ntheorem erasep_map (f : \u03b2 \u2192 \u03b1) :\n  \u2200 (l : list \u03b2), (map f l).erasep p = map f (l.erasep (p \u2218 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  \u2200 l : list \u03b1, 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 \u03b1]\n\n@[simp] theorem erase_nil (a : \u03b1) : [].erase a = [] := rfl\n\ntheorem erase_cons (a b : \u03b1) (l : list \u03b1) : (b :: l).erase a = if b = a then l else b :: l.erase a := rfl\n\n@[simp] theorem erase_cons_head (a : \u03b1) (l : list \u03b1) : (a :: l).erase a = l :=\nby simp only [erase_cons, if_pos rfl]\n\n@[simp] theorem erase_cons_tail {a b : \u03b1} (l : list \u03b1) (h : b \u2260 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 : \u03b1) (l : list \u03b1) : 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 : \u03b1} {l : list \u03b1} (h : a \u2209 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 : \u03b1} {l : list \u03b1} (h : a \u2208 l) :\n  \u2203 l\u2081 l\u2082, a \u2209 l\u2081 \u2227 l = l\u2081 ++ a :: l\u2082 \u2227 l.erase a = l\u2081 ++ l\u2082 :=\nby rcases exists_of_erasep h rfl with \u27e8_, l\u2081, l\u2082, h\u2081, rfl, h\u2082, h\u2083\u27e9;\n   rw erase_eq_erasep; exact \u27e8l\u2081, l\u2082, \u03bb h, h\u2081 _ h rfl, h\u2082, h\u2083\u27e9\n\n@[simp] theorem length_erase_of_mem {a : \u03b1} {l : list \u03b1} (h : a \u2208 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 : \u03b1} {l\u2081 : list \u03b1} (l\u2082) (h : a \u2208 l\u2081) :\n  (l\u2081++l\u2082).erase a = l\u2081.erase a ++ l\u2082 :=\nby simp [erase_eq_erasep]; exact erasep_append_left (by refl) l\u2082 h\n\ntheorem erase_append_right {a : \u03b1} {l\u2081 : list \u03b1} (l\u2082) (h : a \u2209 l\u2081) :\n  (l\u2081++l\u2082).erase a = l\u2081 ++ l\u2082.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 : \u03b1) (l : list \u03b1) : l.erase a <+ l :=\nby rw erase_eq_erasep; apply erasep_sublist\n\ntheorem erase_subset (a : \u03b1) (l : list \u03b1) : l.erase a \u2286 l :=\nsubset_of_sublist (erase_sublist a l)\n\ntheorem erase_sublist_erase (a : \u03b1) {l\u2081 l\u2082 : list \u03b1} (h : l\u2081 <+ l\u2082) : l\u2081.erase a <+ l\u2082.erase a :=\nby simp [erase_eq_erasep]; exact erasep_sublist_erasep h\n\ntheorem mem_of_mem_erase {a b : \u03b1} {l : list \u03b1} : a \u2208 l.erase b \u2192 a \u2208 l :=\n@erase_subset _ _ _ _ _\n\n@[simp] theorem mem_erase_of_ne {a b : \u03b1} {l : list \u03b1} (ab : a \u2260 b) : a \u2208 l.erase b \u2194 a \u2208 l :=\nby rw erase_eq_erasep; exact mem_erasep_of_neg ab.symm\n\ntheorem erase_comm (a b : \u03b1) (l : list \u03b1) : (l.erase a).erase b = (l.erase b).erase a :=\nif ab : a = b then by rw ab else\nif ha : a \u2208 l then\nif hb : b \u2208 l then match l, l.erase a, exists_erase_eq ha, hb with\n| ._, ._, \u27e8l\u2081, l\u2082, ha', rfl, rfl\u27e9, hb :=\n  if h\u2081 : b \u2208 l\u2081 then\n    by rw [erase_append_left _ h\u2081, erase_append_left _ h\u2081,\n           erase_append_right _ (mt mem_of_mem_erase ha'), erase_cons_head]\n  else\n    by rw [erase_append_right _ h\u2081, erase_append_right _ h\u2081, 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 \u03b2] {f : \u03b1 \u2192 \u03b2} (finj : injective f) {a : \u03b1}\n  (l : list \u03b1) : 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 \u03b2] {f : \u03b1 \u2192 \u03b2} (finj : injective f) {l\u2081 l\u2082 : list \u03b1} :\n  map f (foldl list.erase l\u2081 l\u2082) = foldl (\u03bb l a, l.erase (f a)) (map f l\u2081) l\u2082 :=\nby induction l\u2082 generalizing l\u2081; [refl,\nsimp only [foldl_cons, map_erase finj, *]]\n\n@[simp] theorem count_erase_self (a : \u03b1) : \u2200 (s : list \u03b1), 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 (\u03bb x : a = h, p x.symm), count_erase_self],\n    simp, }\nend\n\n@[simp] theorem count_erase_of_ne {a b : \u03b1} (ab : a \u2260 b) : \u2200 (s : list \u03b1), 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 \u03b1]\n\n@[simp] theorem diff_nil (l : list \u03b1) : l.diff [] = l := rfl\n\n@[simp] theorem diff_cons (l\u2081 l\u2082 : list \u03b1) (a : \u03b1) : l\u2081.diff (a::l\u2082) = (l\u2081.erase a).diff l\u2082 :=\nif h : a \u2208 l\u2081 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 \u03b1) : [].diff l = [] :=\nby induction l; [refl, simp only [*, diff_cons, erase_of_not_mem (not_mem_nil _)]]\n\ntheorem diff_eq_foldl : \u2200 (l\u2081 l\u2082 : list \u03b1), l\u2081.diff l\u2082 = foldl list.erase l\u2081 l\u2082\n| l\u2081 []      := rfl\n| l\u2081 (a::l\u2082) := (diff_cons l\u2081 l\u2082 a).trans (diff_eq_foldl _ _)\n\n@[simp] theorem diff_append (l\u2081 l\u2082 l\u2083 : list \u03b1) : l\u2081.diff (l\u2082 ++ l\u2083) = (l\u2081.diff l\u2082).diff l\u2083 :=\nby simp only [diff_eq_foldl, foldl_append]\n\n@[simp] theorem map_diff [decidable_eq \u03b2] {f : \u03b1 \u2192 \u03b2} (finj : injective f) {l\u2081 l\u2082 : list \u03b1} :\n  map f (l\u2081.diff l\u2082) = (map f l\u2081).diff (map f l\u2082) :=\nby simp only [diff_eq_foldl, foldl_map, map_foldl_erase finj]\n\ntheorem diff_sublist : \u2200 l\u2081 l\u2082 : list \u03b1, l\u2081.diff l\u2082 <+ l\u2081\n| l\u2081 []      := sublist.refl _\n| l\u2081 (a::l\u2082) := calc l\u2081.diff (a :: l\u2082) = (l\u2081.erase a).diff l\u2082 : diff_cons _ _ _\n  ... <+ l\u2081.erase a : diff_sublist _ _\n  ... <+ l\u2081 : list.erase_sublist _ _\n\ntheorem diff_subset (l\u2081 l\u2082 : list \u03b1) : l\u2081.diff l\u2082 \u2286 l\u2081 :=\nsubset_of_sublist $ diff_sublist _ _\n\ntheorem mem_diff_of_mem {a : \u03b1} : \u2200 {l\u2081 l\u2082 : list \u03b1}, a \u2208 l\u2081 \u2192 a \u2209 l\u2082 \u2192 a \u2208 l\u2081.diff l\u2082\n| l\u2081 []      h\u2081 h\u2082 := h\u2081\n| l\u2081 (b::l\u2082) h\u2081 h\u2082 := by rw diff_cons; exact\n  mem_diff_of_mem ((mem_erase_of_ne (ne_of_not_mem_cons h\u2082)).2 h\u2081) (not_mem_of_not_mem_cons h\u2082)\n\ntheorem diff_sublist_of_sublist : \u2200 {l\u2081 l\u2082 l\u2083: list \u03b1}, l\u2081 <+ l\u2082 \u2192 l\u2081.diff l\u2083 <+ l\u2082.diff l\u2083\n| l\u2081 l\u2082 [] h      := h\n| l\u2081 l\u2082 (a::l\u2083) h := by simp only\n  [diff_cons, diff_sublist_of_sublist (erase_sublist_erase _ h)]\n\ntheorem erase_diff_erase_sublist_of_sublist {a : \u03b1} : \u2200 {l\u2081 l\u2082 : list \u03b1},\n  l\u2081 <+ l\u2082 \u2192 (l\u2082.erase a).diff (l\u2081.erase a) <+ l\u2082.diff l\u2081\n| []      l\u2082 h := erase_sublist _ _\n| (b::l\u2081) l\u2082 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\u2082]\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 : \u03b1) (b : \u03b2) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n  zip (a :: l\u2081) (b :: l\u2082) = (a, b) :: zip l\u2081 l\u2082 := rfl\n\n@[simp] theorem zip_nil_left (l : list \u03b1) : zip ([] : list \u03b2) l = [] := rfl\n\n@[simp] theorem zip_nil_right (l : list \u03b1) : zip l ([] : list \u03b2) = [] :=\nby cases l; refl\n\n@[simp] theorem zip_swap : \u2200 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n  (zip l\u2081 l\u2082).map prod.swap = zip l\u2082 l\u2081\n| []      l\u2082      := (zip_nil_right _).symm\n| l\u2081      []      := by rw zip_nil_right; refl\n| (a::l\u2081) (b::l\u2082) := by simp only [zip_cons_cons, map_cons, zip_swap l\u2081 l\u2082, prod.swap_prod_mk]; split; refl\n\n@[simp] theorem length_zip : \u2200 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n   length (zip l\u2081 l\u2082) = min (length l\u2081) (length l\u2082)\n| []      l\u2082      := rfl\n| l\u2081      []      := by simp only [length, zip_nil_right, min_zero]\n| (a::l\u2081) (b::l\u2082) := by by simp only [length, zip_cons_cons, length_zip l\u2081 l\u2082, min_add_add_right]\n\ntheorem zip_append : \u2200 {l\u2081 l\u2082 r\u2081 r\u2082 : list \u03b1} (h : length l\u2081 = length l\u2082),\n   zip (l\u2081 ++ r\u2081) (l\u2082 ++ r\u2082) = zip l\u2081 l\u2082 ++ zip r\u2081 r\u2082\n| []      l\u2082      r\u2081 r\u2082 h := by simp only [eq_nil_of_length_eq_zero h.symm]; refl\n| l\u2081      []      r\u2081 r\u2082 h := by simp only [eq_nil_of_length_eq_zero h]; refl\n| (a::l\u2081) (b::l\u2082) r\u2081 r\u2082 h := by simp only [cons_append, zip_cons_cons, zip_append (succ_inj h)]; split; refl\n\ntheorem zip_map (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) : \u2200 (l\u2081 : list \u03b1) (l\u2082 : list \u03b2),\n   zip (l\u2081.map f) (l\u2082.map g) = (zip l\u2081 l\u2082).map (prod.map f g)\n| []      l\u2082      := rfl\n| l\u2081      []      := by simp only [map, zip_nil_right]\n| (a::l\u2081) (b::l\u2082) := by simp only [map, zip_cons_cons, zip_map l\u2081 l\u2082, prod.map]; split; refl\n\ntheorem zip_map_left (f : \u03b1 \u2192 \u03b3) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n   zip (l\u2081.map f) l\u2082 = (zip l\u2081 l\u2082).map (prod.map f id) :=\nby rw [\u2190 zip_map, map_id]\n\ntheorem zip_map_right (f : \u03b2 \u2192 \u03b3) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n   zip l\u2081 (l\u2082.map f) = (zip l\u2081 l\u2082).map (prod.map id f) :=\nby rw [\u2190 zip_map, map_id]\n\ntheorem zip_map' (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) : \u2200 (l : list \u03b1),\n   zip (l.map f) (l.map g) = l.map (\u03bb 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} : \u2200 {l\u2081 : list \u03b1} {l\u2082 : list \u03b2},\n   (a, b) \u2208 zip l\u2081 l\u2082 \u2192 a \u2208 l\u2081 \u2227 b \u2208 l\u2082\n| (_::l\u2081) (_::l\u2082) (or.inl rfl) := \u27e8or.inl rfl, or.inl rfl\u27e9\n| (a'::l\u2081) (b'::l\u2082) (or.inr h) := by split; simp only [mem_cons_iff, or_true, mem_zip h]\n\n@[simp] theorem unzip_nil : unzip (@nil (\u03b1 \u00d7 \u03b2)) = ([], []) := rfl\n\n@[simp] theorem unzip_cons (a : \u03b1) (b : \u03b2) (l : list (\u03b1 \u00d7 \u03b2)) :\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 : \u2200 (l : list (\u03b1 \u00d7 \u03b2)), 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 (\u03b1 \u00d7 \u03b2)) : (unzip l).1 = l.map prod.fst :=\nby simp only [unzip_eq_map]\n\ntheorem unzip_right (l : list (\u03b1 \u00d7 \u03b2)) : (unzip l).2 = l.map prod.snd :=\nby simp only [unzip_eq_map]\n\ntheorem unzip_swap (l : list (\u03b1 \u00d7 \u03b2)) : unzip (l.map prod.swap) = (unzip l).swap :=\nby simp only [unzip_eq_map, map_map]; split; refl\n\ntheorem zip_unzip : \u2200 (l : list (\u03b1 \u00d7 \u03b2)), 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 : \u2200 {l\u2081 : list \u03b1} {l\u2082 : list \u03b2}, length l\u2081 \u2264 length l\u2082 \u2192\n  (unzip (zip l\u2081 l\u2082)).1 = l\u2081\n| []      l\u2082      h := rfl\n| l\u2081      []      h := by rw eq_nil_of_length_eq_zero (eq_zero_of_le_zero h); refl\n| (a::l\u2081) (b::l\u2082) 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\u2081 : list \u03b1} {l\u2082 : list \u03b2} (h : length l\u2082 \u2264 length l\u2081) :\n  (unzip (zip l\u2081 l\u2082)).2 = l\u2082 :=\nby rw [\u2190 zip_swap, unzip_swap]; exact unzip_zip_left h\n\ntheorem unzip_zip {l\u2081 : list \u03b1} {l\u2082 : list \u03b2} (h : length l\u2081 = length l\u2082) :\n  unzip (zip l\u2081 l\u2082) = (l\u2081, l\u2082) :=\nby rw [\u2190 @prod.mk.eta _ _ (unzip (zip l\u2081 l\u2082)),\n  unzip_zip_left (le_of_eq h), unzip_zip_right (ge_of_eq h)]\n\n@[simp] theorem length_revzip (l : list \u03b1) : length (revzip l) = length l :=\nby simp only [revzip, length_zip, length_reverse, min_self]\n\n@[simp] theorem unzip_revzip (l : list \u03b1) : (revzip l).unzip = (l, l.reverse) :=\nunzip_zip (length_reverse l).symm\n\n@[simp] theorem revzip_map_fst (l : list \u03b1) : (revzip l).map prod.fst = l :=\nby rw [\u2190 unzip_left, unzip_revzip]\n\n@[simp] theorem revzip_map_snd (l : list \u03b1) : (revzip l).map prod.snd = l.reverse :=\nby rw [\u2190 unzip_right, unzip_revzip]\n\ntheorem reverse_revzip (l : list \u03b1) : reverse l.revzip = revzip l.reverse :=\nby rw [\u2190 zip_unzip.{u u} (revzip l).reverse, unzip_eq_map]; simp; simp [revzip]\n\ntheorem revzip_swap (l : list \u03b1) : (revzip l).map prod.swap = revzip l.reverse :=\nby simp [revzip]\n\n/- enum -/\n\ntheorem length_enum_from : \u2200 n (l : list \u03b1), 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 : \u2200 (l : list \u03b1), length (enum l) = length l := length_enum_from _\n\n@[simp] theorem enum_from_nth : \u2200 n (l : list \u03b1) m,\n  nth (enum_from n l) m = (\u03bb 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 : \u2200 (l : list \u03b1) n,\n  nth (enum l) n = (\u03bb 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 : \u2200 n (l : list \u03b1),\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 : \u2200 (l : list \u03b1),\n  map prod.snd (enum l) = l := enum_from_map_snd _\n\n\n/- product -/\n\n@[simp] theorem nil_product (l : list \u03b2) : product (@nil \u03b1) l = [] := rfl\n\n@[simp] theorem product_cons (a : \u03b1) (l\u2081 : list \u03b1) (l\u2082 : list \u03b2)\n        : product (a::l\u2081) l\u2082 = map (\u03bb b, (a, b)) l\u2082 ++ product l\u2081 l\u2082 := rfl\n\n@[simp] theorem product_nil : \u2200 (l : list \u03b1), product l (@nil \u03b2) = []\n| []     := rfl\n| (a::l) := by rw [product_cons, product_nil]; refl\n\n@[simp] theorem mem_product {l\u2081 : list \u03b1} {l\u2082 : list \u03b2} {a : \u03b1} {b : \u03b2} :\n  (a, b) \u2208 product l\u2081 l\u2082 \u2194 a \u2208 l\u2081 \u2227 b \u2208 l\u2082 :=\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\u2081 : list \u03b1) (l\u2082 : list \u03b2) :\n  length (product l\u2081 l\u2082) = length l\u2081 * length l\u2082 :=\nby induction l\u2081 with x l\u2081 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 {\u03c3 : \u03b1 \u2192 Type*}\n\n@[simp] theorem nil_sigma (l : \u03a0 a, list (\u03c3 a)) : (@nil \u03b1).sigma l = [] := rfl\n\n@[simp] theorem sigma_cons (a : \u03b1) (l\u2081 : list \u03b1) (l\u2082 : \u03a0 a, list (\u03c3 a))\n        : (a::l\u2081).sigma l\u2082 = map (sigma.mk a) (l\u2082 a) ++ l\u2081.sigma l\u2082 := rfl\n\n@[simp] theorem sigma_nil : \u2200 (l : list \u03b1), l.sigma (\u03bb a, @nil (\u03c3 a)) = []\n| []     := rfl\n| (a::l) := by rw [sigma_cons, sigma_nil]; refl\n\n@[simp] theorem mem_sigma {l\u2081 : list \u03b1} {l\u2082 : \u03a0 a, list (\u03c3 a)} {a : \u03b1} {b : \u03c3 a} :\n  sigma.mk a b \u2208 l\u2081.sigma l\u2082 \u2194 a \u2208 l\u2081 \u2227 b \u2208 l\u2082 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\u2081 : list \u03b1) (l\u2082 : \u03a0 a, list (\u03c3 a)) :\n  length (l\u2081.sigma l\u2082) = (l\u2081.map (\u03bb a, length (l\u2082 a))).sum :=\nby induction l\u2081 with x l\u2081 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 \u2192 \u03b1) :\n  \u2200 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 \u2192 \u03b1) : length (of_fn f) = n :=\n(length_of_fn_aux f _ _ _).trans (zero_add _)\n\ntheorem nth_of_fn_aux {n} (f : fin n \u2192 \u03b1) (i) :\n  \u2200 m h l,\n    (\u2200 i, nth l i = of_fn_nth_val f (i + m)) \u2192\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 \u2192 \u03b1) (i) :\n  nth (of_fn f) i = of_fn_nth_val f i :=\nnth_of_fn_aux f _ _ _ _ $ \u03bb 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 \u2192 \u03b1) (i : fin n) :\n  nth_le (of_fn f) i.1 ((length_of_fn f).symm \u25b8 i.2) = f i :=\noption.some.inj $ by rw [\u2190 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 \u03b1) : a.to_list = of_fn a.read :=\nsuffices \u2200 {m h l}, d_array.rev_iterate_aux a\n  (\u03bb 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 \u2192 \u03b1) : of_fn f = [] := rfl\n\ntheorem of_fn_succ {n} (f : fin (succ n) \u2192 \u03b1) :\n  of_fn f = f 0 :: of_fn (\u03bb i, f i.succ) :=\nsuffices \u2200 {m h l}, of_fn_aux f (succ m) (succ_le_succ h) l =\n  f 0 :: of_fn_aux (\u03bb 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 : \u2200 l : list \u03b1, of_fn (\u03bb 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\u2081 l\u2082 : list \u03b1} (d : disjoint l\u2081 l\u2082) : disjoint l\u2082 l\u2081\n| a i\u2082 i\u2081 := d i\u2081 i\u2082\n\n@[simp] theorem disjoint_comm {l\u2081 l\u2082 : list \u03b1} : disjoint l\u2081 l\u2082 \u2194 disjoint l\u2082 l\u2081 :=\n\u27e8disjoint.symm, disjoint.symm\u27e9\n\ntheorem disjoint_left {l\u2081 l\u2082 : list \u03b1} : disjoint l\u2081 l\u2082 \u2194 \u2200 {a}, a \u2208 l\u2081 \u2192 a \u2209 l\u2082 := iff.rfl\n\ntheorem disjoint_right {l\u2081 l\u2082 : list \u03b1} : disjoint l\u2081 l\u2082 \u2194 \u2200 {a}, a \u2208 l\u2082 \u2192 a \u2209 l\u2081 :=\ndisjoint_comm\n\ntheorem disjoint_iff_ne {l\u2081 l\u2082 : list \u03b1} : disjoint l\u2081 l\u2082 \u2194 \u2200 a \u2208 l\u2081, \u2200 b \u2208 l\u2082, a \u2260 b :=\nby simp only [disjoint_left, imp_not_comm, forall_eq']\n\ntheorem disjoint_of_subset_left {l\u2081 l\u2082 l : list \u03b1} (ss : l\u2081 \u2286 l) (d : disjoint l l\u2082) : disjoint l\u2081 l\u2082\n| x m\u2081 := d (ss m\u2081)\n\ntheorem disjoint_of_subset_right {l\u2081 l\u2082 l : list \u03b1} (ss : l\u2082 \u2286 l) (d : disjoint l\u2081 l) : disjoint l\u2081 l\u2082\n| x m m\u2081 := d m (ss m\u2081)\n\ntheorem disjoint_of_disjoint_cons_left {a : \u03b1} {l\u2081 l\u2082} : disjoint (a::l\u2081) l\u2082 \u2192 disjoint l\u2081 l\u2082 :=\ndisjoint_of_subset_left (list.subset_cons _ _)\n\ntheorem disjoint_of_disjoint_cons_right {a : \u03b1} {l\u2081 l\u2082} : disjoint l\u2081 (a::l\u2082) \u2192 disjoint l\u2081 l\u2082 :=\ndisjoint_of_subset_right (list.subset_cons _ _)\n\n@[simp] theorem disjoint_nil_left (l : list \u03b1) : disjoint [] l\n| a := (not_mem_nil a).elim\n\n@[simp] theorem singleton_disjoint {l : list \u03b1} {a : \u03b1} : disjoint [a] l \u2194 a \u2209 l :=\nby simp only [disjoint, mem_singleton, forall_eq]; refl\n\n@[simp] theorem disjoint_singleton {l : list \u03b1} {a : \u03b1} : disjoint l [a] \u2194 a \u2209 l :=\nby rw disjoint_comm; simp only [singleton_disjoint]\n\n@[simp] theorem disjoint_append_left {l\u2081 l\u2082 l : list \u03b1} :\n  disjoint (l\u2081++l\u2082) l \u2194 disjoint l\u2081 l \u2227 disjoint l\u2082 l :=\nby simp only [disjoint, mem_append, or_imp_distrib, forall_and_distrib]\n\n@[simp] theorem disjoint_append_right {l\u2081 l\u2082 l : list \u03b1} :\n  disjoint l (l\u2081++l\u2082) \u2194 disjoint l l\u2081 \u2227 disjoint l l\u2082 :=\ndisjoint_comm.trans $ by simp only [disjoint_comm, disjoint_append_left]\n\n@[simp] theorem disjoint_cons_left {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} :\n  disjoint (a::l\u2081) l\u2082 \u2194 a \u2209 l\u2082 \u2227 disjoint l\u2081 l\u2082 :=\n(@disjoint_append_left _ [a] l\u2081 l\u2082).trans $ by simp only [singleton_disjoint]\n\n@[simp] theorem disjoint_cons_right {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} :\n  disjoint l\u2081 (a::l\u2082) \u2194 a \u2209 l\u2081 \u2227 disjoint l\u2081 l\u2082 :=\ndisjoint_comm.trans $ by simp only [disjoint_comm, disjoint_cons_left]\n\ntheorem disjoint_of_disjoint_append_left_left {l\u2081 l\u2082 l : list \u03b1} (d : disjoint (l\u2081++l\u2082) l) : disjoint l\u2081 l :=\n(disjoint_append_left.1 d).1\n\ntheorem disjoint_of_disjoint_append_left_right {l\u2081 l\u2082 l : list \u03b1} (d : disjoint (l\u2081++l\u2082) l) : disjoint l\u2082 l :=\n(disjoint_append_left.1 d).2\n\ntheorem disjoint_of_disjoint_append_right_left {l\u2081 l\u2082 l : list \u03b1} (d : disjoint l (l\u2081++l\u2082)) : disjoint l l\u2081 :=\n(disjoint_append_right.1 d).1\n\ntheorem disjoint_of_disjoint_append_right_right {l\u2081 l\u2082 l : list \u03b1} (d : disjoint l (l\u2081++l\u2082)) : disjoint l l\u2082 :=\n(disjoint_append_right.1 d).2\n\nend disjoint\n\n/- union -/\nsection union\nvariable [decidable_eq \u03b1]\n\n@[simp] theorem nil_union (l : list \u03b1) : [] \u222a l = l := rfl\n\n@[simp] theorem cons_union (l\u2081 l\u2082 : list \u03b1) (a : \u03b1) : a :: l\u2081 \u222a l\u2082 = insert a (l\u2081 \u222a l\u2082) := rfl\n\n@[simp] theorem mem_union {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a \u2208 l\u2081 \u222a l\u2082 \u2194 a \u2208 l\u2081 \u2228 a \u2208 l\u2082 :=\nby induction l\u2081; 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 : \u03b1} {l\u2081 : list \u03b1} (h : a \u2208 l\u2081) (l\u2082 : list \u03b1) : a \u2208 l\u2081 \u222a l\u2082 :=\nmem_union.2 (or.inl h)\n\ntheorem mem_union_right {a : \u03b1} (l\u2081 : list \u03b1) {l\u2082 : list \u03b1} (h : a \u2208 l\u2082) : a \u2208 l\u2081 \u222a l\u2082 :=\nmem_union.2 (or.inr h)\n\ntheorem sublist_suffix_of_union : \u2200 l\u2081 l\u2082 : list \u03b1, \u2203 t, t <+ l\u2081 \u2227 t ++ l\u2082 = l\u2081 \u222a l\u2082\n| [] l\u2082 := \u27e8[], by refl, rfl\u27e9\n| (a::l\u2081) l\u2082 := let \u27e8t, s, e\u27e9 := sublist_suffix_of_union l\u2081 l\u2082 in\n  if h : a \u2208 l\u2081 \u222a l\u2082\n  then \u27e8t, sublist_cons_of_sublist _ s, by simp only [e, cons_union, insert_of_mem h]\u27e9\n  else \u27e8a::t, cons_sublist_cons _ s, by simp only [cons_append, cons_union, e, insert_of_not_mem h]; split; refl\u27e9\n\ntheorem suffix_union_right (l\u2081 l\u2082 : list \u03b1) : l\u2082 <:+ l\u2081 \u222a l\u2082 :=\n(sublist_suffix_of_union l\u2081 l\u2082).imp (\u03bb a, and.right)\n\ntheorem union_sublist_append (l\u2081 l\u2082 : list \u03b1) : l\u2081 \u222a l\u2082 <+ l\u2081 ++ l\u2082 :=\nlet \u27e8t, s, e\u27e9 := sublist_suffix_of_union l\u2081 l\u2082 in\ne \u25b8 (append_sublist_append_right _).2 s\n\ntheorem forall_mem_union {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1} :\n  (\u2200 x \u2208 l\u2081 \u222a l\u2082, p x) \u2194 (\u2200 x \u2208 l\u2081, p x) \u2227 (\u2200 x \u2208 l\u2082, p x) :=\nby simp only [mem_union, or_imp_distrib, forall_and_distrib]\n\ntheorem forall_mem_of_forall_mem_union_left {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1}\n   (h : \u2200 x \u2208 l\u2081 \u222a l\u2082, p x) : \u2200 x \u2208 l\u2081, p x :=\n(forall_mem_union.1 h).1\n\ntheorem forall_mem_of_forall_mem_union_right {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : list \u03b1}\n   (h : \u2200 x \u2208 l\u2081 \u222a l\u2082, p x) : \u2200 x \u2208 l\u2082, p x :=\n(forall_mem_union.1 h).2\n\nend union\n\n/- inter -/\nsection inter\nvariable [decidable_eq \u03b1]\n\n@[simp] theorem inter_nil (l : list \u03b1) : [] \u2229 l = [] := rfl\n\n@[simp] theorem inter_cons_of_mem {a : \u03b1} (l\u2081 : list \u03b1) {l\u2082 : list \u03b1} (h : a \u2208 l\u2082) :\n  (a::l\u2081) \u2229 l\u2082 = a :: (l\u2081 \u2229 l\u2082) :=\nif_pos h\n\n@[simp] theorem inter_cons_of_not_mem {a : \u03b1} (l\u2081 : list \u03b1) {l\u2082 : list \u03b1} (h : a \u2209 l\u2082) :\n  (a::l\u2081) \u2229 l\u2082 = l\u2081 \u2229 l\u2082 :=\nif_neg h\n\ntheorem mem_of_mem_inter_left {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a \u2208 l\u2081 \u2229 l\u2082 \u2192 a \u2208 l\u2081 :=\nmem_of_mem_filter\n\ntheorem mem_of_mem_inter_right {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a \u2208 l\u2081 \u2229 l\u2082 \u2192 a \u2208 l\u2082 :=\nof_mem_filter\n\ntheorem mem_inter_of_mem_of_mem {l\u2081 l\u2082 : list \u03b1} {a : \u03b1} : a \u2208 l\u2081 \u2192 a \u2208 l\u2082 \u2192 a \u2208 l\u2081 \u2229 l\u2082 :=\nmem_filter_of_mem\n\n@[simp] theorem mem_inter {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} : a \u2208 l\u2081 \u2229 l\u2082 \u2194 a \u2208 l\u2081 \u2227 a \u2208 l\u2082 :=\nmem_filter\n\ntheorem inter_subset_left (l\u2081 l\u2082 : list \u03b1) : l\u2081 \u2229 l\u2082 \u2286 l\u2081 :=\nfilter_subset _\n\ntheorem inter_subset_right (l\u2081 l\u2082 : list \u03b1) : l\u2081 \u2229 l\u2082 \u2286 l\u2082 :=\n\u03bb a, mem_of_mem_inter_right\n\ntheorem subset_inter {l l\u2081 l\u2082 : list \u03b1} (h\u2081 : l \u2286 l\u2081) (h\u2082 : l \u2286 l\u2082) : l \u2286 l\u2081 \u2229 l\u2082 :=\n\u03bb a h, mem_inter.2 \u27e8h\u2081 h, h\u2082 h\u27e9\n\ntheorem inter_eq_nil_iff_disjoint {l\u2081 l\u2082 : list \u03b1} : l\u2081 \u2229 l\u2082 = [] \u2194 disjoint l\u2081 l\u2082 :=\nby simp only [eq_nil_iff_forall_not_mem, mem_inter, not_and]; refl\n\ntheorem forall_mem_inter_of_forall_left {p : \u03b1 \u2192 Prop} {l\u2081 : list \u03b1} (h : \u2200 x \u2208 l\u2081, p x)\n     (l\u2082 : list \u03b1) :\n  \u2200 x, x \u2208 l\u2081 \u2229 l\u2082 \u2192 p x :=\nball.imp_left (\u03bb x, mem_of_mem_inter_left) h\n\ntheorem forall_mem_inter_of_forall_right {p : \u03b1 \u2192 Prop} (l\u2081 : list \u03b1) {l\u2082 : list \u03b1}\n    (h : \u2200 x \u2208 l\u2082, p x) :\n  \u2200 x, x \u2208 l\u2081 \u2229 l\u2082 \u2192 p x :=\nball.imp_left (\u03bb x, mem_of_mem_inter_right) h\n\nend inter\n\n/- bag_inter -/\nsection bag_inter\nvariable [decidable_eq \u03b1]\n\n@[simp] theorem nil_bag_inter (l : list \u03b1) : [].bag_inter l = [] :=\nby cases l; refl\n\n@[simp] theorem bag_inter_nil (l : list \u03b1) : l.bag_inter [] = [] :=\nby cases l; refl\n\n@[simp] theorem cons_bag_inter_of_pos {a} (l\u2081 : list \u03b1) {l\u2082} (h : a \u2208 l\u2082) :\n  (a :: l\u2081).bag_inter l\u2082 = a :: l\u2081.bag_inter (l\u2082.erase a) :=\nby cases l\u2082; exact if_pos h\n\n@[simp] theorem cons_bag_inter_of_neg {a} (l\u2081 : list \u03b1) {l\u2082} (h : a \u2209 l\u2082) :\n  (a :: l\u2081).bag_inter l\u2082 = l\u2081.bag_inter l\u2082 :=\nbegin\n  cases l\u2082, {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 : \u03b1} : \u2200 {l\u2081 l\u2082 : list \u03b1}, a \u2208 l\u2081.bag_inter l\u2082 \u2194 a \u2208 l\u2081 \u2227 a \u2208 l\u2082\n| []      l\u2082 := by simp only [nil_bag_inter, not_mem_nil, false_and]\n| (b::l\u2081) l\u2082 := begin\n    by_cases b \u2208 l\u2082,\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 \u27e8rfl, h'\u27e9, exact h.elim h' }\n  end\n\n@[simp] theorem count_bag_inter {a : \u03b1} :\n  \u2200 {l\u2081 l\u2082 : list \u03b1}, count a (l\u2081.bag_inter l\u2082) = min (count a l\u2081) (count a l\u2082)\n| []         l\u2082 := by simp\n| l\u2081         [] := by simp\n| (h\u2081 :: l\u2081) (h\u2082 :: l\u2082) :=\nbegin\n  simp only [list.bag_inter, list.mem_cons_iff],\n  by_cases p\u2081 : h\u2082 = h\u2081; by_cases p\u2082 : h\u2081 = a,\n  { simp only [p\u2081, p\u2082, 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\u2081, ne.symm p\u2082, 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\u2082 at p\u2081,\n    by_cases p\u2083 : a \u2208 l\u2082,\n    { simp only [p\u2081, ne.symm p\u2081, p\u2082, p\u2083, erase_cons, count_bag_inter, eq.symm (min_succ_succ _ _),\n                 succ_pred_eq_of_pos (count_pos.2 p\u2083), 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\u2081, p\u2082, p\u2083] } },\n  { by_cases p\u2084 : h\u2081 \u2208 l\u2082; simp only [ne.symm p\u2081, ne.symm p\u2082, p\u2084, 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 : \u2200 l\u2081 l\u2082 : list \u03b1, l\u2081.bag_inter l\u2082 <+ l\u2081\n| []      l\u2082 := by simp [nil_sublist]\n| (b::l\u2081) l\u2082 := begin\n  by_cases b \u2208 l\u2082; 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 : \u2200 l\u2081 l\u2082 : list \u03b1, l\u2081.bag_inter l\u2082 = [] \u2194 l\u2081 \u2229 l\u2082 = []\n| []      l\u2082 := by simp\n| (b::l\u2081) l\u2082 :=\nbegin\n  by_cases h : b \u2208 l\u2082; simp [h],\n  exact bag_inter_nil_iff_inter_nil l\u2081 l\u2082\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 : \u03b1 \u2192 \u03b1 \u2192 Prop}\n\ntheorem rel_of_pairwise_cons {a : \u03b1} {l : list \u03b1}\n  (p : pairwise R (a::l)) : \u2200 {a'}, a' \u2208 l \u2192 R a a' :=\n(pairwise_cons.1 p).1\n\ntheorem pairwise_of_pairwise_cons {a : \u03b1} {l : list \u03b1}\n  (p : pairwise R (a::l)) : pairwise R l :=\n(pairwise_cons.1 p).2\n\ntheorem pairwise.imp_of_mem {S : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : list \u03b1}\n  (H : \u2200 {a b}, a \u2208 l \u2192 b \u2208 l \u2192 R a b \u2192 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      (\u03bb x h, H (mem_cons_self _ _) (mem_cons_of_mem _ h)) r },\n  { exact IH (\u03bb a b m m', H\n      (mem_cons_of_mem _ m) (mem_cons_of_mem _ m')) }\nend\n\ntheorem pairwise.imp {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b) {l : list \u03b1} : pairwise R l \u2192 pairwise S l :=\npairwise.imp_of_mem (\u03bb a b _ _, H a b)\n\ntheorem pairwise.and {S : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : list \u03b1} :\n  pairwise (\u03bb a b, R a b \u2227 S a b) l \u2194 pairwise R l \u2227 pairwise S l :=\n\u27e8\u03bb h, \u27e8h.imp (\u03bb a b h, h.1), h.imp (\u03bb a b h, h.2)\u27e9,\n \u03bb \u27e8hR, hS\u27e9, begin\n  clear_, induction hR with a l R1 R2 IH;\n  simp only [pairwise.nil, pairwise_cons] at *,\n  exact \u27e8\u03bb b bl, \u27e8R1 b bl, hS.1 b bl\u27e9, IH hS.2\u27e9\n end\u27e9\n\ntheorem pairwise.imp\u2082 {S : \u03b1 \u2192 \u03b1 \u2192 Prop} {T : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b \u2192 T a b) {l : list \u03b1}\n  (hR : pairwise R l) (hS : pairwise S l) : pairwise T l :=\n(pairwise.and.2 \u27e8hR, hS\u27e9).imp $ \u03bb a b, and.rec (H a b)\n\ntheorem pairwise.iff_of_mem {S : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : list \u03b1}\n  (H : \u2200 {a b}, a \u2208 l \u2192 b \u2208 l \u2192 (R a b \u2194 S a b)) : pairwise R l \u2194 pairwise S l :=\n\u27e8pairwise.imp_of_mem (\u03bb a b m m', (H m m').1),\n pairwise.imp_of_mem (\u03bb a b m m', (H m m').2)\u27e9\n\ntheorem pairwise.iff {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2194 S a b) {l : list \u03b1} : pairwise R l \u2194 pairwise S l :=\npairwise.iff_of_mem (\u03bb a b _ _, H a b)\n\ntheorem pairwise_of_forall {l : list \u03b1} (H : \u2200 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 \u03b1} :\n  pairwise R l \u2194 pairwise (\u03bb x y, x \u2208 l \u2227 y \u2208 l \u2227 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 \u03b1} :\n  pairwise R l \u2194 pairwise (\u03bb x y, x \u2208 l \u2192 y \u2208 l \u2192 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 : \u03a0 {l\u2081 l\u2082 : list \u03b1}, l\u2081 <+ l\u2082 \u2192 pairwise R l\u2082 \u2192 pairwise R l\u2081\n| ._ ._ sublist.slnil h := h\n| ._ ._ (sublist.cons l\u2081 l\u2082 a s) (pairwise.cons i n) := pairwise_of_sublist s n\n| ._ ._ (sublist.cons2 l\u2081 l\u2082 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 \u03b1} (H\u2081 : \u2200 x \u2208 l, R x x) (H\u2082 : pairwise R l) :\n  \u2200 (x \u2208 l) (y \u2208 l), R x y :=\nbegin\n  induction l with a l IH, { exact forall_mem_nil _ },\n  cases forall_mem_cons.1 H\u2081 with H\u2081\u2081 H\u2081\u2082,\n  cases pairwise_cons.1 H\u2082 with H\u2082\u2081 H\u2082\u2082,\n  rintro x (rfl | hx) y (rfl | hy),\n  exacts [H\u2081\u2081, H\u2082\u2081 _ hy, H (H\u2082\u2081 _ hx), IH H\u2081\u2082 H\u2082\u2082 _ hx _ hy]\nend\n\nlemma forall_of_pairwise (H : symmetric R) {l : list \u03b1}\n   (hl : pairwise R l) : (\u2200a\u2208l, \u2200b\u2208l, a \u2260 b \u2192 R a b) :=\nforall_of_forall_of_pairwise\n  (\u03bb a b h hne, H (h hne.symm))\n  (\u03bb _ _ h, (h rfl).elim)\n  (pairwise.imp (\u03bb _ _ h _, h) hl)\n\ntheorem pairwise_singleton (R) (a : \u03b1) : 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 : \u03b1} : pairwise R [a, b] \u2194 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\u2081 l\u2082 : list \u03b1} : pairwise R (l\u2081++l\u2082) \u2194\n  pairwise R l\u2081 \u2227 pairwise R l\u2082 \u2227 \u2200 x \u2208 l\u2081, \u2200 y \u2208 l\u2082, R x y :=\nby induction l\u2081 with x l\u2081 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\u2081 l\u2082 : list \u03b1} :\n  pairwise R (l\u2081++l\u2082) \u2194 pairwise R (l\u2082++l\u2081) :=\nhave \u2200 l\u2081 l\u2082 : list \u03b1,\n  (\u2200 (x : \u03b1), x \u2208 l\u2081 \u2192 \u2200 (y : \u03b1), y \u2208 l\u2082 \u2192 R x y) \u2192\n  (\u2200 (x : \u03b1), x \u2208 l\u2082 \u2192 \u2200 (y : \u03b1), y \u2208 l\u2081 \u2192 R x y),\nfrom \u03bb l\u2081 l\u2082 a x xm y ym, s (a y ym x xm),\nby simp only [pairwise_append, and.left_comm]; rw iff.intro (this l\u2081 l\u2082) (this l\u2082 l\u2081)\n\ntheorem pairwise_middle (s : symmetric R) {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} :\n  pairwise R (l\u2081 ++ a::l\u2082) \u2194 pairwise R (a::(l\u2081++l\u2082)) :=\nshow pairwise R (l\u2081 ++ ([a] ++ l\u2082)) \u2194 pairwise R ([a] ++ l\u2081 ++ l\u2082),\nby rw [\u2190 append_assoc, pairwise_append, @pairwise_append _ _ ([a] ++ l\u2081), pairwise_app_comm s];\n   simp only [mem_append, or_comm]\n\ntheorem pairwise_map (f : \u03b2 \u2192 \u03b1) :\n  \u2200 {l : list \u03b2}, pairwise R (map f l) \u2194 pairwise (\u03bb a b : \u03b2, R (f a) (f b)) l\n| []     := by simp only [map, pairwise.nil]\n| (b::l) :=\n  have (\u2200 a b', b' \u2208 l \u2192 f b' = a \u2192 R (f b) a) \u2194 \u2200 (b' : \u03b2), b' \u2208 l \u2192 R (f b) (f b'), from\n  forall_swap.trans $ forall_congr $ \u03bb 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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, S (f a) (f b) \u2192 R a b) {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, R a b \u2192 S (f a) (f b)) {l : list \u03b1}\n  (p : pairwise R l) : pairwise S (map f l) :=\n(pairwise_map f).2 $ p.imp H\n\ntheorem pairwise_filter_map (f : \u03b2 \u2192 option \u03b1) {l : list \u03b2} :\n  pairwise R (filter_map f l) \u2194 pairwise (\u03bb a a' : \u03b2, \u2200 (b \u2208 f a) (b' \u2208 f a'), R b b') l :=\nlet S (a a' : \u03b2) := \u2200 (b \u2208 f a) (b' \u2208 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 (\u2200 (a' : \u03b1) (x : \u03b2), x \u2208 l \u2192 f x = some a' \u2192 R b a') \u2227 pairwise S l \u2194\n        (\u2200 (a' : \u03b2), a' \u2208 l \u2192 \u2200 (b' : \u03b1), f a' = some b' \u2192 R b b') \u2227 pairwise S l,\n  from and_congr \u27e8\u03bb h b mb a ma, h a b mb ma, \u03bb h a b mb ma, h b mb a ma\u27e9 iff.rfl\nend\n\ntheorem pairwise_filter_map_of_pairwise {S : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 option \u03b2)\n  (H : \u2200 (a a' : \u03b1), R a a' \u2192 \u2200 (b \u2208 f a) (b' \u2208 f a'), S b b') {l : list \u03b1}\n  (p : pairwise R l) : pairwise S (filter_map f l) :=\n(pairwise_filter_map _).2 $ p.imp H\n\ntheorem pairwise_filter (p : \u03b1 \u2192 Prop) [decidable_pred p] {l : list \u03b1} :\n  pairwise R (filter p l) \u2194 pairwise (\u03bb x y, p x \u2192 p y \u2192 R x y) l :=\nbegin\n  rw [\u2190 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 : \u03b1 \u2192 Prop) [decidable_pred p] {l : list \u03b1}\n  : pairwise R l \u2192 pairwise R (filter p l) :=\npairwise_of_sublist (filter_sublist _)\n\ntheorem pairwise_join {L : list (list \u03b1)} : pairwise R (join L) \u2194\n  (\u2200 l \u2208 L, pairwise R l) \u2227 pairwise (\u03bb l\u2081 l\u2082, \u2200 (x \u2208 l\u2081) (y \u2208 l\u2082), 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 : (\u2200 (x : \u03b1), x \u2208 l \u2192 \u2200 (y : \u03b1) (x_1 : list \u03b1), x_1 \u2208 L \u2192 y \u2208 x_1 \u2192 R x y) \u2194\n          \u2200 (a' : list \u03b1), a' \u2208 L \u2192 \u2200 (x : \u03b1), x \u2208 l \u2192 \u2200 (y : \u03b1), y \u2208 a' \u2192 R x y :=\n    \u27e8\u03bb h a b c d e, h c d e a b, \u03bb h c d e a b, h a b c d e\u27e9,\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 : \u2200 {R} {l : list \u03b1},\n  pairwise R (reverse l) \u2194 pairwise (\u03bb x y, R y x) l :=\nsuffices \u2200 {R l}, @pairwise \u03b1 R l \u2192 pairwise (\u03bb x y, R y x) (reverse l),\nfrom \u03bb R l, \u27e8\u03bb p, reverse_reverse l \u25b8 this p, this\u27e9,\n\u03bb 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} : \u2200 {l : list \u03b1},\n  pairwise R l \u2194 \u2200 i j (h\u2081 : j < length l) (h\u2082 : i < j), R (nth_le l i (lt_trans h\u2082 h\u2081)) (nth_le l j h\u2081)\n| [] := by simp only [pairwise.nil, true_iff]; exact \u03bb i j h, (not_lt_zero j).elim h\n| (a::l) := begin\n  rw [pairwise_cons, pairwise_iff_nth_le],\n  refine \u27e8\u03bb H i j h\u2081 h\u2082, _, \u03bb H, \u27e8\u03bb a' m, _,\n    \u03bb i j h\u2081 h\u2082, H _ _ (succ_lt_succ h\u2081) (succ_lt_succ h\u2082)\u27e9\u27e9,\n  { cases j with j, {exact (not_lt_zero _).elim h\u2082},\n    cases i with i,\n    { exact H.1 _ (nth_le_mem l _ _) },\n    { exact H.2 _ _ (lt_of_succ_lt_succ h\u2081) (lt_of_succ_lt_succ h\u2082) } },\n  { rcases nth_le_of_mem m with \u27e8n, h, rfl\u27e9,\n    exact H _ _ (succ_lt_succ h) (succ_pos _) }\nend\n\ntheorem pairwise_sublists' {R} : \u2200 {l : list \u03b1}, pairwise R l \u2192\n  pairwise (lex (swap R)) (sublists' l)\n| _ pairwise.nil := pairwise_singleton _ _\n| _ (@pairwise.cons _ _ a l H\u2081 H\u2082) :=\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\u2082,\n    refine \u27e8IH, IH.imp (\u03bb l\u2081 l\u2082, lex.cons), _\u27e9,\n    intros l\u2081 sl\u2081 x l\u2082 sl\u2082 e, subst e,\n    cases l\u2081 with b l\u2081, {constructor},\n    exact lex.rel (H\u2081 _ $ subset_of_sublist sl\u2081 $ mem_cons_self _ _)\n  end\n\ntheorem pairwise_sublists {R} {l : list \u03b1} (H : pairwise R l) :\n  pairwise (\u03bb l\u2081 l\u2082, lex R (reverse l\u2081) (reverse l\u2082)) (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 : \u03b1} {l : list \u03b1} (h : \u2200 b \u2208 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 : \u03b1} {l : list \u03b1} (h : \u00ac \u2200 b \u2208 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 : \u2200 (l : list \u03b1), pw_filter R l <+ l\n| []     := nil_sublist _\n| (x::l) := begin\n  by_cases (\u2200 y \u2208 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 \u03b1) : pw_filter R l \u2286 l :=\nsubset_of_sublist (pw_filter_sublist _)\n\ntheorem pairwise_pw_filter : \u2200 (l : list \u03b1), pairwise R (pw_filter R l)\n| []     := pairwise.nil\n| (x::l) := begin\n  by_cases (\u2200 y \u2208 pw_filter R l, R x y),\n  { rw [pw_filter_cons_of_pos h],\n    exact pairwise_cons.2 \u27e8h, pairwise_pw_filter l\u27e9 },\n  { rw [pw_filter_cons_of_neg h],\n    exact pairwise_pw_filter l },\nend\n\ntheorem pw_filter_eq_self {l : list \u03b1} : pw_filter R l = l \u2194 pairwise R l :=\n\u27e8\u03bb e, e \u25b8 pairwise_pw_filter l, \u03bb 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\u27e9\n\n@[simp] theorem pw_filter_idempotent {l : list \u03b1} :\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 : \u2200 {x y z}, R x z \u2192 R x y \u2228 R y z)\n  (a : \u03b1) (l : list \u03b1) : (\u2200 b \u2208 pw_filter R l, R a b) \u2194 (\u2200 b \u2208 l, R a b) :=\n\u27e8begin\n  induction l with x l IH, { exact \u03bb _ _, false.elim },\n  simp only [forall_mem_cons],\n  by_cases (\u2200 y \u2208 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 \u03bb r H, \u27e8r, IH H\u27e9 },\n  { rw [pw_filter_cons_of_neg h],\n    refine \u03bb H, \u27e8_, IH H\u27e9,\n    cases e : find (\u03bb y, \u00ac R x y) (pw_filter R l) with k,\n    { refine h.elim (ball.imp_right _ (find_eq_none.1 e)),\n      exact \u03bb 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)\u27e9\n\nend pairwise\n\n/- chain relation (conjunction of R a b \u2227 R b c \u2227 R c d ...) -/\n\nsection chain\n\nrun_cmd tactic.mk_iff_of_inductive_prop `list.chain `list.chain_iff\n\nvariable {R : \u03b1 \u2192 \u03b1 \u2192 Prop}\n\ntheorem rel_of_chain_cons {a b : \u03b1} {l : list \u03b1}\n  (p : chain R a (b::l)) : R a b :=\n(chain_cons.1 p).1\n\ntheorem chain_of_chain_cons {a b : \u03b1} {l : list \u03b1}\n  (p : chain R a (b::l)) : chain R b l :=\n(chain_cons.1 p).2\n\ntheorem chain.imp {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b) {a : \u03b1} {l : list \u03b1} (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 : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2194 S a b) {a : \u03b1} {l : list \u03b1} : chain R a l \u2194 chain S a l :=\n\u27e8chain.imp (\u03bb a b, (H a b).1), chain.imp (\u03bb a b, (H a b).2)\u27e9\n\ntheorem chain.iff_mem {a : \u03b1} {l : list \u03b1} :\n  chain R a l \u2194 chain (\u03bb x y, x \u2208 a :: l \u2227 y \u2208 l \u2227 R x y) a l :=\n\u27e8\u03bb p, by induction p with _ a b l r p IH; constructor;\n  [exact \u27e8mem_cons_self _ _, mem_cons_self _ _, r\u27e9,\n   exact IH.imp (\u03bb a b \u27e8am, bm, h\u27e9,\n    \u27e8mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h\u27e9)],\n chain.imp (\u03bb a b h, h.2.2)\u27e9\n\ntheorem chain_singleton {a b : \u03b1} : chain R a [b] \u2194 R a b :=\nby simp only [chain_cons, chain.nil, and_true]\n\ntheorem chain_split {a b : \u03b1} {l\u2081 l\u2082 : list \u03b1} : chain R a (l\u2081++b::l\u2082) \u2194\n  chain R a (l\u2081++[b]) \u2227 chain R b l\u2082 :=\nby induction l\u2081 with x l\u2081 IH generalizing a;\nsimp only [*, nil_append, cons_append, chain.nil, chain_cons, and_true, and_assoc]\n\ntheorem chain_map (f : \u03b2 \u2192 \u03b1) {b : \u03b2} {l : list \u03b2} :\n  chain R (f b) (map f l) \u2194 chain (\u03bb a b : \u03b2, 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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, S (f a) (f b) \u2192 R a b) {a : \u03b1} {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, R a b \u2192 S (f a) (f b)) {a : \u03b1} {l : list \u03b1}\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 : \u03b1} {l : list \u03b1} (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 \u27e8r.1, IH r'\u27e9\nend\n\ntheorem chain_iff_pairwise (tr : transitive R) {a : \u03b1} {l : list \u03b1} :\n  chain R a l \u2194 pairwise R (a::l) :=\n\u27e8\u03bb 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 \u2200 x \u2208 l, R b x, from \u03bb x m, (tr r (rel_of_pairwise_cons IH m)),\nend, chain_of_pairwise\u27e9\n\ntheorem chain'.imp {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b) {l : list \u03b1} (p : chain' R l) : chain' S l :=\nby cases l; [trivial, exact p.imp H]\n\ntheorem chain'.iff {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2194 S a b) {l : list \u03b1} : chain' R l \u2194 chain' S l :=\n\u27e8chain'.imp (\u03bb a b, (H a b).1), chain'.imp (\u03bb a b, (H a b).2)\u27e9\n\ntheorem chain'.iff_mem {S : \u03b1 \u2192 \u03b1 \u2192 Prop} : \u2200 {l : list \u03b1},\n  chain' R l \u2194 chain' (\u03bb x y, x \u2208 l \u2227 y \u2208 l \u2227 R x y) l\n| [] := iff.rfl\n| (x::l) :=\n  \u27e8\u03bb h, (chain.iff_mem.1 h).imp $ \u03bb a b \u27e8h\u2081, h\u2082, h\u2083\u27e9, \u27e8h\u2081, or.inr h\u2082, h\u2083\u27e9,\n   chain'.imp $ \u03bb a b h, h.2.2\u27e9\n\ntheorem chain'_singleton (a : \u03b1) : chain' R [a] := chain.nil\n\ntheorem chain'_split {a : \u03b1} : \u2200 {l\u2081 l\u2082 : list \u03b1}, chain' R (l\u2081++a::l\u2082) \u2194\n  chain' R (l\u2081++[a]) \u2227 chain' R (a::l\u2082)\n| []      l\u2082 := (and_iff_right (chain'_singleton a)).symm\n| (b::l\u2081) l\u2082 := chain_split\n\ntheorem chain'_map (f : \u03b2 \u2192 \u03b1) {l : list \u03b2} :\n  chain' R (map f l) \u2194 chain' (\u03bb a b : \u03b2, R (f a) (f b)) l :=\nby cases l; [refl, exact chain_map _]\n\ntheorem chain'_of_chain'_map {S : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, S (f a) (f b) \u2192 R a b) {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, R a b \u2192 S (f a) (f b)) {l : list \u03b1}\n  (p : chain' R l) : chain' S (map f l) :=\n(chain'_map f).2 $ p.imp H\n\ntheorem chain'_of_pairwise : \u2200 {l : list \u03b1}, pairwise R l \u2192 chain' R l\n| [] _ := trivial\n| (a::l) h := chain_of_pairwise h\n\ntheorem chain'_iff_pairwise (tr : transitive R) : \u2200 {l : list \u03b1},\n  chain' R l \u2194 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 : \u03b1} {l : list \u03b1} : (\u2200 (a' : \u03b1), a' \u2208 l \u2192 \u00aca = a') \u2194 a \u2209 l :=\n\u27e8\u03bb h m, h _ m rfl, \u03bb h a' m e, h (e.symm \u25b8 m)\u27e9\n\n@[simp] theorem nodup_nil : @nodup \u03b1 [] := pairwise.nil\n\n@[simp] theorem nodup_cons {a : \u03b1} {l : list \u03b1} : nodup (a::l) \u2194 a \u2209 l \u2227 nodup l :=\nby simp only [nodup, pairwise_cons, forall_mem_ne]\n\nlemma rel_nodup {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (hr : relator.bi_unique r) : (forall\u2082 r \u21d2 (\u2194)) nodup nodup\n| _ _ forall\u2082.nil      := by simp only [nodup_nil]\n| _ _ (forall\u2082.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 : \u03b1} {l : list \u03b1} (m : a \u2209 l) (n : nodup l) : nodup (a::l) :=\nnodup_cons.2 \u27e8m, n\u27e9\n\ntheorem nodup_singleton (a : \u03b1) : nodup [a] :=\nnodup_cons_of_nodup (not_mem_nil a) nodup_nil\n\ntheorem nodup_of_nodup_cons {a : \u03b1} {l : list \u03b1} (h : nodup (a::l)) : nodup l :=\n(nodup_cons.1 h).2\n\ntheorem not_mem_of_nodup_cons {a : \u03b1} {l : list \u03b1} (h : nodup (a::l)) : a \u2209 l :=\n(nodup_cons.1 h).1\n\ntheorem not_nodup_cons_of_mem {a : \u03b1} {l : list \u03b1} : a \u2208 l \u2192 \u00ac nodup (a :: l) :=\nimp_not_comm.1 not_mem_of_nodup_cons\n\ntheorem nodup_of_sublist {l\u2081 l\u2082 : list \u03b1} : l\u2081 <+ l\u2082 \u2192 nodup l\u2082 \u2192 nodup l\u2081 :=\npairwise_of_sublist\n\ntheorem not_nodup_pair (a : \u03b1) : \u00ac nodup [a, a] :=\nnot_nodup_cons_of_mem $ mem_singleton_self _\n\ntheorem nodup_iff_sublist {l : list \u03b1} : nodup l \u2194 \u2200 a, \u00ac [a, a] <+ l :=\n\u27e8\u03bb 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    (\u03bb al, h a $ cons_sublist_cons _ $ singleton_sublist.2 al)\n    (IH $ \u03bb a s, h a $ sublist_cons_of_sublist _ s)\nend\u27e9\n\ntheorem nodup_iff_nth_le_inj {l : list \u03b1} :\n  nodup l \u2194 \u2200 i j h\u2081 h\u2082, nth_le l i h\u2081 = nth_le l j h\u2082 \u2192 i = j :=\npairwise_iff_nth_le.trans\n\u27e8\u03bb H i j h\u2081 h\u2082 h, ((lt_trichotomy _ _)\n  .resolve_left (\u03bb h', H _ _ h\u2082 h' h))\n  .resolve_right (\u03bb h', H _ _ h\u2081 h' h.symm),\n \u03bb H i j h\u2081 h\u2082 h, ne_of_lt h\u2082 (H _ _ _ _ h)\u27e9\n\n@[simp] theorem nth_le_index_of [decidable_eq \u03b1] {l : list \u03b1} (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 \u03b1] {l : list \u03b1} : nodup l \u2194 \u2200 a, count a l \u2264 1 :=\nnodup_iff_sublist.trans $ forall_congr $ \u03bb a,\nhave [a, a] <+ l \u2194 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 : \u03b1) : \u2200 {n : \u2115}, nodup (repeat a n) \u2194 n \u2264 1\n| 0 := by simp [nat.zero_le]\n| 1 := by simp\n| (n+2) := iff_of_false\n  (\u03bb 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 \u03b1] {a : \u03b1} {l : list \u03b1}\n  (d : nodup l) (h : a \u2208 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\u2081 l\u2082 : list \u03b1} : nodup (l\u2081++l\u2082) \u2192 nodup l\u2081 :=\nnodup_of_sublist (sublist_append_left l\u2081 l\u2082)\n\ntheorem nodup_of_nodup_append_right {l\u2081 l\u2082 : list \u03b1} : nodup (l\u2081++l\u2082) \u2192 nodup l\u2082 :=\nnodup_of_sublist (sublist_append_right l\u2081 l\u2082)\n\ntheorem nodup_append {l\u2081 l\u2082 : list \u03b1} : nodup (l\u2081++l\u2082) \u2194 nodup l\u2081 \u2227 nodup l\u2082 \u2227 disjoint l\u2081 l\u2082 :=\nby simp only [nodup, pairwise_append, disjoint_iff_ne]\n\ntheorem disjoint_of_nodup_append {l\u2081 l\u2082 : list \u03b1} (d : nodup (l\u2081++l\u2082)) : disjoint l\u2081 l\u2082 :=\n(nodup_append.1 d).2.2\n\ntheorem nodup_append_of_nodup {l\u2081 l\u2082 : list \u03b1} (d\u2081 : nodup l\u2081) (d\u2082 : nodup l\u2082) (dj : disjoint l\u2081 l\u2082) : nodup (l\u2081++l\u2082) :=\nnodup_append.2 \u27e8d\u2081, d\u2082, dj\u27e9\n\ntheorem nodup_app_comm {l\u2081 l\u2082 : list \u03b1} : nodup (l\u2081++l\u2082) \u2194 nodup (l\u2082++l\u2081) :=\nby simp only [nodup_append, and.left_comm, disjoint_comm]\n\ntheorem nodup_middle {a : \u03b1} {l\u2081 l\u2082 : list \u03b1} : nodup (l\u2081 ++ a::l\u2082) \u2194 nodup (a::(l\u2081++l\u2082)) :=\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 : \u03b1 \u2192 \u03b2) {l : list \u03b1} : nodup (map f l) \u2192 nodup l :=\npairwise_of_pairwise_map f $ \u03bb a b, mt $ congr_arg f\n\ntheorem nodup_map_on {f : \u03b1 \u2192 \u03b2} {l : list \u03b1} (H : \u2200x\u2208l, \u2200y\u2208l, f x = f y \u2192 x = y)\n  (d : nodup l) : nodup (map f l) :=\npairwise_map_of_pairwise _ (by exact \u03bb a b \u27e8ma, mb, n\u27e9 e, n (H a ma b mb e)) (pairwise.and_mem.1 d)\n\ntheorem nodup_map {f : \u03b1 \u2192 \u03b2} {l : list \u03b1} (hf : injective f) : nodup l \u2192 nodup (map f l) :=\nnodup_map_on (assume x _ y _ h, hf h)\n\ntheorem nodup_map_iff {f : \u03b1 \u2192 \u03b2} {l : list \u03b1} (hf : injective f) : nodup (map f l) \u2194 nodup l :=\n\u27e8nodup_of_nodup_map _, nodup_map hf\u27e9\n\n@[simp] theorem nodup_attach {l : list \u03b1} : nodup (attach l) \u2194 nodup l :=\n\u27e8\u03bb h, attach_map_val l \u25b8 nodup_map (\u03bb a b, subtype.eq) h,\n \u03bb h, nodup_of_nodup_map subtype.val ((attach_map_val l).symm \u25b8 h)\u27e9\n\ntheorem nodup_pmap {p : \u03b1 \u2192 Prop} {f : \u03a0 a, p a \u2192 \u03b2} {l : list \u03b1} {H}\n  (hf : \u2200 a ha b hb, f a ha = f b hb \u2192 a = b) (h : nodup l) : nodup (pmap f l H) :=\nby rw [pmap_eq_map_attach]; exact nodup_map\n  (\u03bb \u27e8a, ha\u27e9 \u27e8b, hb\u27e9 h, by congr; exact hf a (H _ ha) b (H _ hb) h)\n  (nodup_attach.2 h)\n\ntheorem nodup_filter (p : \u03b1 \u2192 Prop) [decidable_pred p] {l} : nodup l \u2192 nodup (filter p l) :=\npairwise_filter_of_pairwise p\n\n@[simp] theorem nodup_reverse {l : list \u03b1} : nodup (reverse l) \u2194 nodup l :=\npairwise_reverse.trans $ by simp only [nodup, ne.def, eq_comm]\n\ntheorem nodup_erase_eq_filter [decidable_eq \u03b1] (a : \u03b1) {l} (d : nodup l) : l.erase a = filter (\u2260 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 \u03b1] (a : \u03b1) {l} : nodup l \u2192 nodup (l.erase a) :=\nnodup_of_sublist (erase_sublist _ _)\n\ntheorem mem_erase_iff_of_nodup [decidable_eq \u03b1] {a b : \u03b1} {l} (d : nodup l) :\n  a \u2208 l.erase b \u2194 a \u2260 b \u2227 a \u2208 l :=\nby rw nodup_erase_eq_filter b d; simp only [mem_filter, and_comm]\n\ntheorem mem_erase_of_nodup [decidable_eq \u03b1] {a : \u03b1} {l} (h : nodup l) : a \u2209 l.erase a :=\n\u03bb H, ((mem_erase_iff_of_nodup h).1 H).1 rfl\n\ntheorem nodup_join {L : list (list \u03b1)} : nodup (join L) \u2194 (\u2200 l \u2208 L, nodup l) \u2227 pairwise disjoint L :=\nby simp only [nodup, pairwise_join, disjoint_left.symm, forall_mem_ne]\n\ntheorem nodup_bind {l\u2081 : list \u03b1} {f : \u03b1 \u2192 list \u03b2} : nodup (l\u2081.bind f) \u2194\n  (\u2200 x \u2208 l\u2081, nodup (f x)) \u2227 pairwise (\u03bb (a b : \u03b1), disjoint (f a) (f b)) l\u2081 :=\nby simp only [list.bind, nodup_join, pairwise_map, and_comm, and.left_comm, mem_map, exists_imp_distrib, and_imp];\n   rw [show (\u2200 (l : list \u03b2) (x : \u03b1), f x = l \u2192 x \u2208 l\u2081 \u2192 nodup l) \u2194\n            (\u2200 (x : \u03b1), x \u2208 l\u2081 \u2192 nodup (f x)),\n       from forall_swap.trans $ forall_congr $ \u03bb_, forall_eq']\n\ntheorem nodup_product {l\u2081 : list \u03b1} {l\u2082 : list \u03b2} (d\u2081 : nodup l\u2081) (d\u2082 : nodup l\u2082) :\n  nodup (product l\u2081 l\u2082) :=\n nodup_bind.2\n  \u27e8\u03bb a ma, nodup_map (injective_of_left_inverse (\u03bb b, (rfl : (a,b).2 = b))) d\u2082,\n  d\u2081.imp $ \u03bb a\u2081 a\u2082 n x h\u2081 h\u2082, begin\n    rcases mem_map.1 h\u2081 with \u27e8b\u2081, mb\u2081, rfl\u27e9,\n    rcases mem_map.1 h\u2082 with \u27e8b\u2082, mb\u2082, \u27e8\u27e9\u27e9,\n    exact n rfl\n  end\u27e9\n\ntheorem nodup_sigma {\u03c3 : \u03b1 \u2192 Type*} {l\u2081 : list \u03b1} {l\u2082 : \u03a0 a, list (\u03c3 a)}\n  (d\u2081 : nodup l\u2081) (d\u2082 : \u2200 a, nodup (l\u2082 a)) : nodup (l\u2081.sigma l\u2082) :=\n nodup_bind.2\n  \u27e8\u03bb a ma, nodup_map (\u03bb b b' h, by injection h with _ h; exact eq_of_heq h) (d\u2082 a),\n  d\u2081.imp $ \u03bb a\u2081 a\u2082 n x h\u2081 h\u2082, begin\n    rcases mem_map.1 h\u2081 with \u27e8b\u2081, mb\u2081, rfl\u27e9,\n    rcases mem_map.1 h\u2082 with \u27e8b\u2082, mb\u2082, \u27e8\u27e9\u27e9,\n    exact n rfl\n  end\u27e9\n\ntheorem nodup_filter_map {f : \u03b1 \u2192 option \u03b2} {l : list \u03b1}\n  (H : \u2200 (a a' : \u03b1) (b : \u03b2), b \u2208 f a \u2192 b \u2208 f a' \u2192 a = a') :\n  nodup l \u2192 nodup (filter_map f l) :=\npairwise_filter_map_of_pairwise f $ \u03bb a a' n b bm b' bm' e, n $ H a a' b' (e \u25b8 bm) bm'\n\ntheorem nodup_concat {a : \u03b1} {l : list \u03b1} (h : a \u2209 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 \u03b1] {a : \u03b1} {l : list \u03b1} (h : nodup l) : nodup (insert a l) :=\nif h' : a \u2208 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 \u03b1] (l\u2081 : list \u03b1) {l\u2082 : list \u03b1} (h : nodup l\u2082) :\n  nodup (l\u2081 \u222a l\u2082) :=\nbegin\n  induction l\u2081 with a l\u2081 ih generalizing l\u2082,\n  { exact h },\n  apply nodup_insert,\n  exact ih h\nend\n\ntheorem nodup_inter_of_nodup [decidable_eq \u03b1] {l\u2081 : list \u03b1} (l\u2082) : nodup l\u2081 \u2192 nodup (l\u2081 \u2229 l\u2082) :=\nnodup_filter _\n\n@[simp] theorem nodup_sublists {l : list \u03b1} : nodup (sublists l) \u2194 nodup l :=\n\u27e8\u03bb h, nodup_of_nodup_map _ (nodup_of_sublist (map_ret_sublist_sublists _) h),\n \u03bb h, (pairwise_sublists h).imp (\u03bb _ _ h, mt reverse_inj.2 h.to_ne)\u27e9\n\n@[simp] theorem nodup_sublists' {l : list \u03b1} : nodup (sublists' l) \u2194 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 \u03b1]\n\n@[simp] theorem erase_dup_nil : erase_dup [] = ([] : list \u03b1) := rfl\n\ntheorem erase_dup_cons_of_mem' {a : \u03b1} {l : list \u03b1} (h : a \u2208 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 : \u03b1} {l : list \u03b1} (h : a \u2209 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 : \u03b1} {l : list \u03b1} : a \u2208 erase_dup l \u2194 a \u2208 l :=\nby simpa only [erase_dup, forall_mem_ne, not_not] using not_congr (@forall_mem_pw_filter \u03b1 (\u2260) _\n  (\u03bb 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 : \u03b1} {l : list \u03b1} (h : a \u2208 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 : \u03b1} {l : list \u03b1} (h : a \u2209 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 : \u2200 (l : list \u03b1), erase_dup l <+ l := pw_filter_sublist\n\ntheorem erase_dup_subset : \u2200 (l : list \u03b1), erase_dup l \u2286 l := pw_filter_subset\n\ntheorem subset_erase_dup (l : list \u03b1) : l \u2286 erase_dup l :=\n\u03bb a, mem_erase_dup.2\n\ntheorem nodup_erase_dup : \u2200 l : list \u03b1, nodup (erase_dup l) := pairwise_pw_filter\n\ntheorem erase_dup_eq_self {l : list \u03b1} : erase_dup l = l \u2194 nodup l := pw_filter_eq_self\n\n@[simp] theorem erase_dup_idempotent {l : list \u03b1} : erase_dup (erase_dup l) = erase_dup l :=\npw_filter_idempotent\n\ntheorem erase_dup_append (l\u2081 l\u2082 : list \u03b1) : erase_dup (l\u2081 ++ l\u2082) = l\u2081 \u222a erase_dup l\u2082 :=\nbegin\n  induction l\u2081 with a l\u2081 IH, {refl}, rw [cons_union, \u2190 IH],\n  show erase_dup (a :: (l\u2081 ++ l\u2082)) = insert a (erase_dup (l\u2081 ++ l\u2082)),\n  by_cases a \u2208 erase_dup (l\u2081 ++ l\u2082);\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' : \u2200 (s n : \u2115), 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 : \u2115} : \u2200 {s n : \u2115}, m \u2208 range' s n \u2194 s \u2264 m \u2227 m < s + n\n| s 0     := (false_iff _).2 $ \u03bb \u27e8H1, H2\u27e9, not_le_of_lt H2 H1\n| s (succ n) :=\n  have m = s \u2192 m < s + n + 1,\n    from \u03bb e, e \u25b8 lt_succ_of_le (le_add_right _ _),\n  have l : m = s \u2228 s + 1 \u2264 m \u2194 s \u2264 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) : \u2200 s n : \u2115, 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) : \u2200 (s n : \u2115) (h : a \u2264 s), map (\u03bb 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' : \u2200 s n : \u2115, chain (\u03bb 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 : \u2115) : chain (<) s (range' (s+1) n) :=\n(chain_succ_range' s n).imp (\u03bb a b e, e.symm \u25b8 lt_succ_self _)\n\ntheorem pairwise_lt_range' : \u2200 s n : \u2115, pairwise (<) (range' s n)\n| s 0     := pairwise.nil\n| s (n+1) := (chain_iff_pairwise (by exact \u03bb a b c, lt_trans)).1 (chain_lt_range' s n)\n\ntheorem nodup_range' (s n : \u2115) : nodup (range' s n) :=\n(pairwise_lt_range' s n).imp (\u03bb a b, ne_of_lt)\n\n@[simp] theorem range'_append : \u2200 s m n : \u2115, 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 : \u2115} : range' s m <+ range' s n \u2194 m \u2264 n :=\n\u27e8\u03bb h, by simpa only [length_range'] using length_le_of_sublist h,\n \u03bb h, by rw [\u2190 nat.sub_add_cancel h, \u2190 range'_append]; apply sublist_append_left\u27e9\n\ntheorem range'_subset_right {s m n : \u2115} : range' s m \u2286 range' s n \u2194 m \u2264 n :=\n\u27e8\u03bb h, le_of_not_lt $ \u03bb hn, lt_irrefl (s+n) $\n  (mem_range'.1 $ h $ mem_range'.2 \u27e8le_add_right _ _, nat.add_lt_add_left hn s\u27e9).2,\n \u03bb h, subset_of_sublist (range'_sublist_right.2 h)\u27e9\n\ntheorem nth_range' : \u2200 s {m n : \u2115}, m < n \u2192 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 : \u2115) : 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' : \u2200 s n : \u2115, 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 : \u2115) : range n = range' 0 n :=\n(range_core_range' n 0).trans $ by rw zero_add\n\ntheorem range_succ_eq_map (n : \u2115) : range (n + 1) = 0 :: map succ (range n) :=\nby rw [range_eq_range', range_eq_range', range',\n       add_comm, \u2190 map_add_range'];\n   congr; exact funext one_add\n\ntheorem range'_eq_map_range (s n : \u2115) : range' s n = map ((+) s) (range n) :=\nby rw [range_eq_range', map_add_range']; refl\n\n@[simp] theorem length_range (n : \u2115) : length (range n) = n :=\nby simp only [range_eq_range', length_range']\n\ntheorem pairwise_lt_range (n : \u2115) : pairwise (<) (range n) :=\nby simp only [range_eq_range', pairwise_lt_range']\n\ntheorem nodup_range (n : \u2115) : nodup (range n) :=\nby simp only [range_eq_range', nodup_range']\n\ntheorem range_sublist {m n : \u2115} : range m <+ range n \u2194 m \u2264 n :=\nby simp only [range_eq_range', range'_sublist_right]\n\ntheorem range_subset {m n : \u2115} : range m \u2286 range n \u2194 m \u2264 n :=\nby simp only [range_eq_range', range'_subset_right]\n\n@[simp] theorem mem_range {m n : \u2115} : m \u2208 range n \u2194 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 : \u2115} : n \u2209 range n :=\nmt mem_range.1 $ lt_irrefl _\n\ntheorem nth_range {m n : \u2115} (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 : \u2115) : range (n + 1) = range n ++ [n] :=\nby simp only [range_eq_range', range'_concat, zero_add]\n\ntheorem iota_eq_reverse_range' : \u2200 n : \u2115, 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 : \u2115) : length (iota n) = n :=\nby simp only [iota_eq_reverse_range', length_reverse, length_range']\n\ntheorem pairwise_gt_iota (n : \u2115) : pairwise (>) (iota n) :=\nby simp only [iota_eq_reverse_range', pairwise_reverse, pairwise_lt_range']\n\ntheorem nodup_iota (n : \u2115) : nodup (iota n) :=\nby simp only [iota_eq_reverse_range', nodup_reverse, nodup_range']\n\ntheorem mem_iota {m n : \u2115} : m \u2208 iota n \u2194 1 \u2264 m \u2227 m \u2264 n :=\nby simp only [iota_eq_reverse_range', mem_reverse, mem_range', add_comm, lt_succ_iff]\n\ntheorem reverse_range' : \u2200 s n : \u2115,\n  reverse (range' s n) = map (\u03bb 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, (\u2218),\n    \u03bb 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 \u2264 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 \u2264 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 : \u2115) : list \u2115 := range' n (m - n)\n\nnamespace Ico\n\ntheorem zero_bot (n : \u2115) : Ico 0 n = range n :=\nby rw [Ico, nat.sub_zero, range_eq_range']\n\n@[simp] theorem length (n m : \u2115) : length (Ico n m) = m - n :=\nby dsimp [Ico]; simp only [length_range']\n\ntheorem pairwise_lt (n m : \u2115) : pairwise (<) (Ico n m) :=\nby dsimp [Ico]; simp only [pairwise_lt_range']\n\ntheorem nodup (n m : \u2115) : nodup (Ico n m) :=\nby dsimp [Ico]; simp only [nodup_range']\n\n@[simp] theorem mem {n m l : \u2115} : l \u2208 Ico n m \u2194 n \u2264 l \u2227 l < m :=\nsuffices n \u2264 l \u2227 l < n + (m - n) \u2194 n \u2264 l \u2227 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 : \u2115} (h : m \u2264 n) : Ico n m = [] :=\nby simp [Ico, nat.sub_eq_zero_of_le h]\n\ntheorem map_add (n m k : \u2115) : (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 : \u2115) (h\u2081 : k \u2264 n): (Ico n m).map (\u03bb x, x - k) = Ico (n - k) (m - k) :=\nbegin\n  by_cases h\u2082 : n < m,\n  { rw [Ico, Ico],\n    rw nat.sub_sub_sub_cancel_right h\u2081,\n    rw [map_sub_range' _ _ _ h\u2081] },\n  { simp at h\u2082,\n    rw [eq_nil_of_le h\u2082],\n    rw [eq_nil_of_le (nat.sub_le_sub_right h\u2082 _)],\n    refl }\nend\n\n@[simp] theorem self_empty {n : \u2115} : Ico n n = [] :=\neq_nil_of_le (le_refl n)\n\n@[simp] theorem eq_empty_iff {n m : \u2115} : Ico n m = [] \u2194 m \u2264 n :=\niff.intro (assume h, nat.le_of_sub_eq_zero $ by rw [\u2190 length, h]; refl) eq_nil_of_le\n\nlemma append_consecutive {n m l : \u2115} (hnm : n \u2264 m) (hml : m \u2264 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 [\u2190 nat.add_sub_assoc hnm, nat.sub_add_cancel] }\nend\n\n@[simp] lemma inter_consecutive (n m l : \u2115) : Ico n m \u2229 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\u2081 h\u2082 h\u2083,\n  exfalso,\n  exact not_lt_of_ge h\u2083 h\u2082\nend\n\n@[simp] lemma bag_inter_consecutive (n m l : \u2115) : 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 : \u2115} : Ico n (n+1) = [n] :=\nby dsimp [Ico]; simp [nat.add_sub_cancel_left]\n\ntheorem succ_top {n m : \u2115} (h : n \u2264 m) : Ico n (m + 1) = Ico n m ++ [m] :=\nby rwa [\u2190 succ_singleton, append_consecutive]; exact nat.le_succ _\n\ntheorem eq_cons {n m : \u2115} (h : n < m) : Ico n m = n :: Ico (n + 1) m :=\nby rw [\u2190 append_consecutive (nat.le_succ n) h, succ_singleton]; refl\n\n@[simp] theorem pred_singleton {m : \u2115} (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 : \u2115) : chain' (\u03bba 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 : \u2115} : m \u2209 Ico n m :=\nby simp; intros; refl\n\nlemma filter_lt_of_top_le {n m l : \u2115} (hml : m \u2264 l) : (Ico n m).filter (\u03bb 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 : \u2115} (hln : l \u2264 n) : (Ico n m).filter (\u03bb 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 : \u2115} (hlm : l \u2264 m) : (Ico n m).filter (\u03bb x, x < l) = Ico n l :=\nbegin\n  cases le_total n l with hnl hln,\n  { rw [\u2190 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 : \u2115) : (Ico n m).filter (\u03bb 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 : \u2115} (hln : l \u2264 n) : (Ico n m).filter (\u03bb x, x \u2265 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 : \u2115} (hml : m \u2264 l) : (Ico n m).filter (\u03bb x, x \u2265 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 : \u2115} (hnl : n \u2264 l) : (Ico n m).filter (\u03bb x, x \u2265 l) = Ico l m :=\nbegin\n  cases le_total l m with hlm hml,\n  { rw [\u2190 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 : \u2115) : (Ico n m).filter (\u03bb x, x \u2265 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 : \u2200 n (l : list \u03b1),\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 \u03b1) :\n  map prod.fst (enum l) = range l.length :=\nby simp only [enum, enum_from_map_fst, range_eq_range']\n\ntheorem last'_mem {\u03b1} : \u2200 a l, @last' \u03b1 a l \u2208 a :: l\n| a []     := or.inl rfl\n| a (b::l) := or.inr (last'_mem b l)\n\n@[simp] lemma nth_le_attach {\u03b1} (L : list \u03b1) (i) (H : i < L.attach.length) :\n  (L.attach.nth_le i H).1 = L.nth_le i (length_attach L \u25b8 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 [\u2190 nth_le_nth _, nth_range (by simpa using H)]\n\ntheorem of_fn_eq_pmap {\u03b1 n} {f : fin n \u2192 \u03b1} :\n  of_fn f = pmap (\u03bb i hi, f \u27e8i, hi\u27e9) (range n) (\u03bb _, mem_range.1) :=\nby rw [pmap_eq_map_attach]; from ext_le (by simp)\n  (\u03bb i hi1 hi2, by simp at hi1; simp [nth_le_of_fn f \u27e8i, hi1\u27e9])\n\ntheorem nodup_of_fn {\u03b1 n} {f : fin n \u2192 \u03b1} (hf : function.injective f) :\n  nodup (of_fn f) :=\nby rw of_fn_eq_pmap; from nodup_pmap\n  (\u03bb _ _ _ _ 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 \u2208 l) :\n  tfae (a::l) \u2194 (a \u2194 b) \u2227 tfae l :=\n\u27e8\u03bb H, \u27e8H a (by simp) b (or.inr h), \u03bb p hp q hq, H _ (or.inr hp) _ (or.inr hq)\u27e9,\nbegin\n   rintro \u27e8ab, H\u27e9 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\u27e9\n\ntheorem tfae_cons_cons {a b} {l : list Prop} : tfae (a::b::l) \u2194 (a \u2194 b) \u2227 tfae (b::l) :=\ntfae_cons_of_mem (or.inl rfl)\n\ntheorem tfae_of_forall (b : Prop) (l : list Prop) (h : \u2200 a \u2208 l, a \u2194 b) : tfae l :=\n\u03bb a\u2081 h\u2081 a\u2082 h\u2082, (h _ h\u2081).trans (h _ h\u2082).symm\n\ntheorem tfae_of_cycle {a b} {l : list Prop} :\n  list.chain (\u2192) a (b::l) \u2192 (last' b l \u2192 a) \u2192 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 \u2218 la),\n  exact \u27e8\u27e8ab, la \u2218 (this.2 c (or.inl rfl) _ (last'_mem _ _)).1 \u2218 bc\u27e9, this\u27e9\nend\n\ntheorem tfae.out {l} (h : tfae l) (n\u2081 n\u2082)\n (h\u2081 : n\u2081 < list.length l . tactic.exact_dec_trivial)\n (h\u2082 : n\u2082 < list.length l . tactic.exact_dec_trivial) :\n  list.nth_le l n\u2081 h\u2081 \u2194 list.nth_le l n\u2082 h\u2082 :=\nh _ (list.nth_le_mem _ _ _) _ (list.nth_le_mem _ _ _)\n\nend tfae\n\nlemma rotate_mod (l : list \u03b1) (n : \u2115) : l.rotate (n % l.length) = l.rotate n :=\nby simp [rotate]\n\n@[simp] lemma rotate_nil (n : \u2115) : ([] : list \u03b1).rotate n = [] := by cases n; refl\n\n@[simp] lemma rotate_zero (l : list \u03b1) : l.rotate 0 = l := by simp [rotate]\n\n@[simp] lemma rotate'_nil (n : \u2115) : ([] : list \u03b1).rotate' n = [] := by cases n; refl\n\n@[simp] lemma rotate'_zero (l : list \u03b1) : l.rotate' 0 = l := by cases l; refl\n\nlemma rotate'_cons_succ (l : list \u03b1) (a : \u03b1) (n : \u2115) :\n  (a :: l : list \u03b1).rotate' n.succ = (l ++ [a]).rotate' n := by simp [rotate']\n\n@[simp] lemma length_rotate' : \u2200 (l : list \u03b1) (n : \u2115), (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 : \u2200 {l : list \u03b1} {n : \u2115}, n \u2264 l.length \u2192\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 \u2264 l.length, from le_of_succ_le_succ h,\nhave hnl' : n \u2264 (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' : \u2200 (l : list \u03b1) (n m : \u2115), (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 \u03b1) : rotate' l l.length = l :=\nby rw rotate'_eq_take_append_drop (le_refl _); simp\n\n@[simp] lemma rotate'_length_mul (l : list \u03b1) : \u2200 n : \u2115, 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 \u03b1) (n : \u2115) : 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 \u03b1) (n : \u2115) : l.rotate n = l.rotate' n :=\nif h : l.length = 0 then by simp [length_eq_zero, *] at *\nelse by\n  rw [\u2190 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 \u03b1) (a : \u03b1) (n : \u2115) :\n  (a :: l : list \u03b1).rotate n.succ = (l ++ [a]).rotate n :=\nby rw [rotate_eq_rotate', rotate_eq_rotate', rotate'_cons_succ]\n\n@[simp] lemma mem_rotate : \u2200 {l : list \u03b1} {a : \u03b1} {n : \u2115}, a \u2208 l.rotate n \u2194 a \u2208 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 \u03b1) (n : \u2115) : (l.rotate n).length = l.length :=\nby rw [rotate_eq_rotate', length_rotate']\n\nlemma rotate_eq_take_append_drop {l : list \u03b1} {n : \u2115} : n \u2264 l.length \u2192\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 \u03b1) (n m : \u2115) : (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 \u03b1) : rotate l l.length = l :=\nby rw [rotate_eq_rotate', rotate'_length]\n\n@[simp] lemma rotate_length_mul (l : list \u03b1) (n : \u2115) : 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 \u03b1] : \u2200 {l : list \u03b1} (hl : l.prod = 1) (n : \u2115),\n  (l.rotate n).prod = 1\n| []     _  _ := by simp\n| (a::l) hl n :=\nhave n % list.length (a :: l) \u2264 list.length (a :: l), from le_of_lt (nat.mod_lt _ dec_trivial),\nby rw \u2190 list.take_append_drop (n % list.length (a :: l)) (a :: l) at hl;\n  rw [\u2190 rotate_mod, rotate_eq_take_append_drop this, list.prod_append, mul_eq_one_iff_inv_eq,\n    \u2190 one_mul (list.prod _)\u207b\u00b9, \u2190 hl, list.prod_append, mul_assoc, mul_inv_self, mul_one]\n\nsection choose\nvariables (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : list \u03b1)\n\nlemma choose_spec (hp : \u2203 a, a \u2208 l \u2227 p a) : choose p l hp \u2208 l \u2227 p (choose p l hp) :=\n(choose_x p l hp).property\n\nlemma choose_mem (hp : \u2203 a, a \u2208 l \u2227 p a) : choose p l hp \u2208 l := (choose_spec _ _ _).1\n\nlemma choose_property (hp : \u2203 a, a \u2208 l \u2227 p a) : p (choose p l hp) := (choose_spec _ _ _).2\n\nend choose\n\nend list\n\ntheorem option.to_list_nodup {\u03b1} : \u2200 o : option \u03b1, 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 : \u2200 {\u03a6 : Hyp}, derives \u03a6 top)\n\ninstance {Form : Type} [Der : has_ltop Form] : has_top Form := \u27e8 Der.top \u27e9\n\n/- Logical And -/\nclass has_and (Form : Type) extends has_ltop Form :=\n  (and : Form \u2192 Form \u2192 Form)\n  (and_intro {\u03a6} {\u03c6 \u03c8 : Form}    \n        : derives \u03a6 \u03c6 \u2192 derives \u03a6 \u03c8 \u2192 derives \u03a6 (and \u03c6 \u03c8))\n  (and_eliml {\u03a6} {\u03c6 \u03c8 : Form}    \n        : derives \u03a6 (and \u03c6 \u03c8) \u2192 derives \u03a6 \u03c6)\n  (and_elimr {\u03a6} {\u03c6 \u03c8 : Form}    \n        : derives \u03a6 (and \u03c6 \u03c8) \u2192 derives \u03a6 \u03c8)\n\ninfix `&`:79      := has_and.and \n\n/- Implication -/\nclass has_impl (Form : Type) extends has_and Form :=\n  (impl : Form \u2192 Form \u2192 Form)\n  (impl_intro {\u03a6} (\u03c6) {\u03c8}   \n        : derives (insert \u03c6 \u03a6) \u03c8 \u2192 derives \u03a6 (impl \u03c6 \u03c8))\n  (impl_elim {\u03a6} (\u03c6) {\u03c8} \n        : derives \u03a6 (impl \u03c6 \u03c8) \u2192 derives \u03a6 \u03c6 \u2192 derives \u03a6 \u03c8)\n\nnotation (name:= has_impl.impl) \u03c6 ` \u2283 `:80 \u03c8 := has_impl.impl \u03c6 \u03c8 \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] {\u03c6 \u03c8 : Form} : \n    Der.derives (Der.insertHyp.insert \u03c8 {\u03c6}) (\u03c6&\u03c8) :=\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] {\u03c6 \u03c8 \u03b8: Form} : \n    (\u03c6 & \u03c8 \u22a2 \u03b8) \u2192 Der.derives (Der.insertHyp.insert \u03c8 {\u03c6}) \u03b8 :=\n  begin\n    assume h,\n    apply Der.derive_Trans (\u03c6 & \u03c8),\n    exact and_intro1,\n    exact h,\n  end\n\n\n  lemma and_eliml1 {Form : Type} [Der : has_and Form] {\u03c6 \u03c8 : Form} : \n    \u03c6 & \u03c8 \u22a2 \u03c6 :=\n  begin\n    apply Der.and_eliml,\n    apply derive_refl,\n  end\n  lemma and_elimr1 {Form : Type} [Der : has_and Form] {\u03c6 \u03c8 : Form} : \n    \u03c6 & \u03c8 \u22a2 \u03c8 :=\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    \u2200 {\u03c6 \u03c8 : Form}, (\u03c6 \u2283 \u03c8) & \u03c6 \u22a2 \u03c8 :=\n  begin\n    assume \u03c6 \u03c8,\n    apply Der.impl_elim \u03c6,\n    apply and_eliml1,\n    apply and_elimr1,\n  end\n\n  lemma impl_\u03b5 {Form : Type} [Der : has_impl Form] :\n    \u2200 {\u03c6 \u03c8 \u03b8 : Form}, \u03c6 & \u03c8 \u22a2 \u03b8  \u2192  \u03c6 \u22a2 \u03c8 \u2283 \u03b8 :=\n  begin\n    assume \u03c6 \u03c8 \u03b8 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] {\u03a6} {\u03c6 \u03c8 : Form} :\n    (\u03c6 \u22a2 \u03c8) \u2192 Der.derives (Der.insertHyp.insert \u03c6 \u03a6) \u03c8 :=\n  begin\n    assume h,\n    apply Der.derive_Trans \u03c6,\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(\u03bb _ _ 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\u27e8gcf.of v, generalized_continued_fraction.of_is_simple_continued_fraction v\u27e9\n\nlemma simple_continued_fraction.of_is_continued_fraction :\n  (simple_continued_fraction.of v).is_continued_fraction :=\n(\u03bb _ 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\u27e8simple_continued_fraction.of v, simple_continued_fraction.of_is_continued_fraction v\u27e9\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  \u2200 (\u03b5 > (0 : K)), \u2203 (N : \u2115), \u2200 (n \u2265 N), |v - (gcf.of v).convergents n| < \u03b5 :=\nbegin\n  assume \u03b5 \u03b5_pos,\n  -- use the archemidean property to obtian a suitable N\n  rcases (exists_nat_gt (1 / \u03b5) : \u2203 (N' : \u2115), 1 / \u03b5 < N') with \u27e8N', one_div_\u03b5_lt_N'\u27e9,\n  let N := max N' 5, -- set minimum to 5 to have N \u2264 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 \u03b5_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| \u2264 1 / (B * nB), from\n      abs_sub_convergents_le not_terminated_at_n,\n    suffices : 1 / (B * nB) < \u03b5, 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) \u2264 nB, by\n    { have : \u00acg.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) \u2264 B, by\n    { have : \u00acg.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 < \u03b5 * (B * nB), from (div_lt_iff zero_lt_mul_conts).elim_right this,\n    -- use that `N \u2265 n` was obtained from the archimedian property to show the following\n    have one_lt_\u03b5_mul_N : 1 < \u03b5 * n, by\n    { have one_lt_\u03b5_mul_N' : 1 < \u03b5 * (N' : K), from (div_lt_iff' \u03b5_pos).elim_left one_div_\u03b5_lt_N',\n      have : (N' : K) \u2264 N, by exact_mod_cast (le_max_left  _ _),\n      have : \u03b5 * N' \u2264 \u03b5 * n, from\n        (mul_le_mul_left \u03b5_pos).elim_right (le_trans this (by exact_mod_cast n_ge_N)),\n      exact (lt_of_lt_of_le one_lt_\u03b5_mul_N' this) },\n    suffices : \u03b5 * n \u2264 \u03b5 * (B * nB), from lt_of_lt_of_le one_lt_\u03b5_mul_N this,\n    -- cancel `\u03b5`\n    suffices : (n : K) \u2264 B * nB, from (mul_le_mul_left \u03b5_pos).elim_right this,\n    show (n : K) \u2264 B * nB,\n      calc (n : K)\n          \u2264 fib n                     : by exact_mod_cast (le_fib_self $ le_trans\n                                           (le_max_right N' 5) n_ge_N)\n      ... \u2264 fib (n + 1)               : by exact_mod_cast fib_le_fib_succ\n      ... \u2264 fib (n + 1) * fib (n + 1) : by exact_mod_cast ((fib (n + 1)).le_mul_self)\n      ... \u2264 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      ... \u2264 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\u00f6lzl, 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 \u2964 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 \u2964 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\u2082 C D : C \u2964 D` such that `(forget\u2082 C D) \u22d9 (forget D) = forget C`,\nsee `class has_forget\u2082`.  Due to `faithful.div_comp`, it suffices\nto verify that `forget\u2082.obj` and `forget\u2082.map` agree with the equality\nabove; then `forget\u2082` will satisfy the functor laws automatically, see\n`has_forget\u2082.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 \u2964 Type`.\n\nNote that `ConcreteCategory` potentially depends on three independent universe levels,\n* the universe level `w` appearing in `Forget : C \u2964 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 \u2964 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 \u2964 Type u :=\n  ConcreteCategory.Forget\n#align category_theory.forget CategoryTheory.forget\n\ninstance ConcreteCategory.types : ConcreteCategory (Type u) where\n  Forget := \ud835\udfed _\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 \u27f6 Y) fun _ => X \u2192 Y :=\n  \u27e8fun f => (forget _).map f\u27e9\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 \u27f6 Y) (w : \u2200 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 \u27f6 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 \u27f6 Y} (h : f = g) (x : X) : f x = g x :=\n  congrFun (congrArg (fun k : X \u27f6 Y => (k : X \u2192 Y)) h) x\n#align category_theory.congr_hom CategoryTheory.congr_hom\n\ntheorem coe_id {X : C} : (\ud835\udfd9 X : X \u2192 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 \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g : X \u2192 Z) = g \u2218 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) : (\ud835\udfd9 X : X \u2192 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 \u27f6 Y) (g : Y \u27f6 Z) (x : X) : (f \u226b 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 \u27f6 Y} (h : f = g) (x : X) : f x = g x :=\n  congr_fun (congr_arg (fun f : X \u27f6 Y => (f : X \u2192 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 \u27f6 Y) {x x' : X} (h : x = x') : f x = f x' :=\n  congrArg (f : X \u2192 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 \u27f6 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 \u27f6 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 \u27f6 Y)\n    [PreservesLimitsOfShape WalkingCospan (forget C)] : Mono f \u2194 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 \u27f6 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 \u27f6 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 \u27f6 Y)\n    [PreservesColimitsOfShape WalkingSpan (forget C)] : Epi f \u2194 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 \u27f6 Y) [IsIso f] :\n    Function.Bijective ((forget C).map f) := by\n  rw [\u2190 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 \u27f6  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\u2082 C D`, where `C` and `D` are both concrete categories, provides a functor\n`forget\u2082 C D : C \u2964 D` and a proof that `forget\u2082 \u22d9 (forget D) = forget C`.\n-/\nclass HasForget\u2082 (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\u2082 : C \u2964 D\n  /-- It covers the `ConcreteCategory.Forget` for `C` and `D` -/\n  forget_comp : forget\u2082 \u22d9 forget D = forget C := by aesop\n#align category_theory.has_forget\u2082 CategoryTheory.HasForget\u2082\n\n/-- The forgetful functor `C \u2964 D` between concrete categories for which we have an instance\n`HasForget\u2082 C `. -/\n@[reducible]\ndef forget\u2082 (C : Type v) (D : Type v') [Category C] [ConcreteCategory C] [Category D]\n    [ConcreteCategory D] [HasForget\u2082 C D] : C \u2964 D :=\n  HasForget\u2082.forget\u2082\n#align category_theory.forget\u2082 CategoryTheory.forget\u2082\n\ninstance forget\u2082_faithful (C : Type v) (D : Type v') [Category C] [ConcreteCategory C] [Category D]\n    [ConcreteCategory D] [HasForget\u2082 C D] : Faithful (forget\u2082 C D) :=\n  HasForget\u2082.forget_comp.faithful_of_comp\n#align category_theory.forget\u2082_faithful CategoryTheory.forget\u2082_faithful\n\ninstance forget\u2082_preservesMonomorphisms (C : Type v) (D : Type v') [Category C] [ConcreteCategory C]\n    [Category D] [ConcreteCategory D] [HasForget\u2082 C D] [(forget C).PreservesMonomorphisms] :\n    (forget\u2082 C D).PreservesMonomorphisms :=\n  have : (forget\u2082 C D \u22d9 forget D).PreservesMonomorphisms := by\n    simp only [HasForget\u2082.forget_comp]\n    infer_instance\n  Functor.preservesMonomorphisms_of_preserves_of_reflects _ (forget D)\n#align category_theory.forget\u2082_preserves_monomorphisms CategoryTheory.forget\u2082_preservesMonomorphisms\n\ninstance forget\u2082_preservesEpimorphisms (C : Type v) (D : Type v') [Category C] [ConcreteCategory C]\n    [Category D] [ConcreteCategory D] [HasForget\u2082 C D] [(forget C).PreservesEpimorphisms] :\n    (forget\u2082 C D).PreservesEpimorphisms :=\n  have : (forget\u2082 C D \u22d9 forget D).PreservesEpimorphisms := by\n    simp only [HasForget\u2082.forget_comp]\n    infer_instance\n  Functor.preservesEpimorphisms_of_preserves_of_reflects _ (forget D)\n#align category_theory.forget\u2082_preserves_epimorphisms CategoryTheory.forget\u2082_preservesEpimorphisms\n\ninstance InducedCategory.concreteCategory {C : Type v} {D : Type v'} [Category D]\n    [ConcreteCategory D] (f : C \u2192 D) : ConcreteCategory (InducedCategory D f) where\n  Forget := inducedFunctor f \u22d9 forget D\n#align category_theory.induced_category.concrete_category CategoryTheory.InducedCategory.concreteCategory\n\ninstance InducedCategory.hasForget\u2082 {C : Type v} {D : Type v'} [Category D] [ConcreteCategory D]\n    (f : C \u2192 D) : HasForget\u2082 (InducedCategory D f) D where\n  forget\u2082 := inducedFunctor f\n  forget_comp := rfl\n#align category_theory.induced_category.has_forget\u2082 CategoryTheory.InducedCategory.hasForget\u2082\n\ninstance FullSubcategory.concreteCategory {C : Type v} [Category C] [ConcreteCategory C]\n    (Z : C \u2192 Prop) : ConcreteCategory (FullSubcategory Z) where\n  Forget := fullSubcategoryInclusion Z \u22d9 forget C\n#align category_theory.full_subcategory.concrete_category CategoryTheory.FullSubcategory\u2093.concreteCategory\n\ninstance FullSubcategory.hasForget\u2082 {C : Type v} [Category C] [ConcreteCategory C] (Z : C \u2192 Prop) :\n    HasForget\u2082 (FullSubcategory Z) C where\n  forget\u2082 := fullSubcategoryInclusion Z\n  forget_comp := rfl\n#align category_theory.full_subcategory.has_forget\u2082 CategoryTheory.FullSubcategory\u2093.hasForget\u2082\n\n/-- In order to construct a \u201cpartially forgetting\u201d functor, we do not need to verify functor laws;\nit suffices to ensure that compositions agree with `forget\u2082 C D \u22d9 forget D = forget C`.\n-/\ndef HasForget\u2082.mk' {C : Type v} {D : Type v'} [Category C] [ConcreteCategory C] [Category D]\n    [ConcreteCategory D] (obj : C \u2192 D) (h_obj : \u2200 X, (forget D).obj (obj X) = (forget C).obj X)\n    (map : \u2200 {X Y}, (X \u27f6 Y) \u2192 (obj X \u27f6 obj Y))\n    (h_map : \u2200 {X Y} {f : X \u27f6 Y}, HEq ((forget D).map (map f)) ((forget C).map f)) : HasForget\u2082 C D\n    where\n  forget\u2082 := Faithful.div _ _ _ @h_obj _ @h_map\n  forget_comp := by apply Faithful.div_comp\n#align category_theory.has_forget\u2082.mk' CategoryTheory.HasForget\u2082.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\u2082 C (Type u) where\n  forget\u2082 := 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n\nsection reflects_iso\nvariables {D : Type u\u2082} [category.{v\u2082} D]\nvariables {E : Type u\u2083} [category.{v\u2083} E]\n\n/--\nDefine what it means for a functor `F : C \u2964 D` to reflect isomorphisms: for any\nmorphism `f : A \u27f6 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 \u2964 D) : Prop :=\n(reflects : \u03a0 {A B : C} (f : A \u27f6 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 \u27f6 B) (F : C \u2964 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 \u2964 D) [full F] [faithful F] : reflects_isomorphisms F :=\n{ reflects := \u03bb X Y f i, by exactI\n  \u27e8\u27e8F.preimage (inv (F.map f)), \u27e8F.map_injective (by simp), F.map_injective (by simp)\u27e9\u27e9\u27e9 }\n\ninstance (F : C \u2964 D) (G : D \u2964 E) [reflects_isomorphisms F] [reflects_isomorphisms G] :\n  reflects_isomorphisms (F \u22d9 G) :=\n\u27e8\u03bb _ _ 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 }\u27e9\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\u2081 v\u2082 u\u2081 u\u2082 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\u2081} {D : Type u\u2082} [category C] [category D] (F : C \u2964 D) : set D :=\n  fun (Y : D) => \u2203 (X : C), Nonempty (obj F X \u2245 Y)\n\n/-- Get the witnessing object that `Y` is in the subcategory given by `F`. -/\ndef ess_image.witness {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {F : C \u2964 D} {Y : D}\n    (h : Y \u2208 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\u2081} {D : Type u\u2082} [category C] [category D] {F : C \u2964 D} {Y : D}\n    (h : Y \u2208 ess_image F) : obj F (ess_image.witness h) \u2245 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\u2081} {D : Type u\u2082} [category C] [category D] {F : C \u2964 D} {Y : D}\n    {Y' : D} (h : Y \u2245 Y') (hY : Y \u2208 ess_image F) : Y' \u2208 ess_image F :=\n  Exists.imp (fun (B : C) => nonempty.map fun (_x : obj F B \u2245 Y) => _x \u226a\u226b 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 \u2245 F'`.\n-/\ntheorem ess_image.of_nat_iso {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {F : C \u2964 D}\n    {F' : C \u2964 D} (h : F \u2245 F') {Y : D} (hY : Y \u2208 ess_image F) : Y \u2208 ess_image F' :=\n  Exists.imp (fun (X : C) => nonempty.map fun (t : obj F X \u2245 Y) => iso.app (iso.symm h) X \u226a\u226b t) hY\n\n/-- Isomorphic functors have equal essential images. -/\ntheorem ess_image_eq_of_nat_iso {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {F : C \u2964 D}\n    {F' : C \u2964 D} (h : F \u2245 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\u2081} {D : Type u\u2082} [category C] [category D] (F : D \u2964 C)\n    (Y : D) : obj F Y \u2208 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\u2081} {D : Type u\u2082} [category C]\n    [category D] {F : C \u2964 D} : category \u21a5(ess_image F) :=\n  category_theory.full_subcategory fun (x : D) => x \u2208 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\u2081} {D : Type u\u2082} [category C] [category D]\n    (F : C \u2964 D) (c : Subtype fun (X : D) => (fun (x : D) => x \u2208 ess_image F) X) :\n    obj (ess_image_inclusion F) c = \u2191c :=\n  Eq.refl \u2191c\n\n/--\nGiven a functor `F : C \u2964 D`, we have an (essentially surjective) functor from `C` to the essential\nimage of `F`.\n-/\ndef to_ess_image {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] (F : C \u2964 D) :\n    C \u2964 \u21a5(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 \u27f6 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\u2081} {D : Type u\u2082}\n    [category C] [category D] {F : C \u2964 D} (X : C) :\n    nat_trans.app (iso.hom to_ess_image_comp_essential_image_inclusion) X = \ud835\udfd9 :=\n  Eq.refl \ud835\udfd9\n\nend functor\n\n\n/--\nA functor `F : C \u2964 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 \u2245 Y`.\n\nSee https://stacks.math.columbia.edu/tag/001C.\n-/\nclass ess_surj {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] (F : C \u2964 D) where\n  mem_ess_image : \u2200 (Y : D), Y \u2208 functor.ess_image F\n\nprotected instance functor.to_ess_image.ess_surj {C : Type u\u2081} {D : Type u\u2082} [category C]\n    [category D] {F : C \u2964 D} : ess_surj (functor.to_ess_image F) :=\n  ess_surj.mk fun (_x : \u21a5(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\u2081} {D : Type u\u2082} [category C] [category D] (F : C \u2964 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\u2081} {D : Type u\u2082} [category C] [category D] (F : C \u2964 D)\n    [ess_surj F] (Y : D) : functor.obj F (functor.obj_preimage F Y) \u2245 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 := \u27e8\u27e9\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 (\u03b1 : Type*) [linear_order \u03b1] : LinOrd := bundled.of \u03b1\n\n@[simp] lemma coe_of (\u03b1 : Type*) [linear_order \u03b1] : \u21a5(of \u03b1) = \u03b1 := rfl\n\ninstance : inhabited LinOrd := \u27e8of punit\u27e9\n\ninstance (\u03b1 : LinOrd) : linear_order \u03b1 := \u03b1.str\n\ninstance has_forget_to_Lat : has_forget\u2082 LinOrd Lat :=\n{ forget\u2082 := { obj := \u03bb X, Lat.of X,\n               map := \u03bb 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 {\u03b1 \u03b2 : LinOrd.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2 :=\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 \u2964 LinOrd :=\n{ obj := \u03bb X, of X\u1d52\u1d48, map := \u03bb 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 \u224c LinOrd :=\nequivalence.mk dual dual\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n\nend LinOrd\n\nlemma LinOrd_dual_comp_forget_to_Lat :\n  LinOrd.dual \u22d9 forget\u2082 LinOrd Lat = forget\u2082 LinOrd Lat \u22d9 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 : \u2115) := \u2200 a b : \u2115,\n  a.coprime p \u2192 b.coprime p \u2192 a < b \u2192 \u2203 i : \u2115, 0 < i \u2227 (F p^[i]) a \u2264 (F p^[i]) b\n\n\n\nsection general_results\n\nvariables {p : \u2115} (h : odd p)\ninclude h\n\ntheorem balanced_iff_S0_coprime_eq_pairwise :\n  balanced p \u2194 \u2200 x y : \u2115, x.coprime p \u2192 y.coprime p \u2192 S0 h x = S0 h y :=\nbegin\n  ---- Right-to-left direction is easy\n  symmetry; refine \u27e8\u03bb h1 a b ha hb h2, \u27e8order_two_mod_p h, order_two_mod_p_pos h, _\u27e9, _\u27e9,\n  rw [F_iterate_S, F_iterate_S, \u2190 S0, \u2190 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 : (\u2203 x y : \u2115, x.coprime p \u2227 y.coprime p \u2227 S0 h x < S0 h y) \u2192 \u00acbalanced p,\n  { intros h1; contrapose! h1,\n    rcases h1 with \u27e8x, y, h1, h2, h3\u27e9,\n    rw [ne_iff_lt_or_gt, gt_iff_lt] at h3,\n    cases h3 with h3 h3,\n    exacts [this \u27e8x, y, h1, h2, h3\u27e9, this \u27e8y, x, h2, h1, h3\u27e9] },\n\n  ---- There exists such `x` and `y` with an extra condition: `y < x`\n  rintros \u27e8u, y, h1, h2, h3\u27e9,\n  simp only [balanced, not_forall, not_exists, not_and, not_le],\n  replace h1 : \u2203 x : \u2115, x.coprime p \u2227 y < x \u2227 S0 h x < S0 h y :=\n  begin\n    refine \u27e8u + (y + 1) * p, _, _, _\u27e9,\n    rwa nat.coprime_add_mul_right_left,\n    rw \u2190 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, \u2190 S0_mod_p]\n  end,\n  clear h3 u,\n  rcases h1 with \u27e8x, h1, h3\u27e9,\n\n  ---- It suffices to find some `N \u2265 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 : \u2203 N : \u2115, (\u2200 n : \u2115, N < n \u2192 (F p^[n]) x < (F p^[n]) y) \u2227 (F p^[N]) y < (F p^[N]) x,\n  { rcases this with \u27e8N, h4, h5\u27e9,\n    refine \u27e8(F p^[N]) y, (F p^[N]) x, F_iterate_coprime h h2 _,\n      F_iterate_coprime h h1 _, h5, \u03bb k hk, _\u27e9,\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 \u27e8(nat.find h2).pred, \u03bb n X, h3 n (nat.le_of_pred_lt X), _\u27e9,\n  generalize_hyp h4 : nat.find h2 = N at h3 \u22a2,\n  cases N with _ N,\n  exact h1,\n  refine lt_of_le_of_ne _ (\u03bb X, ne_of_lt h1 (injective.iterate (F_injective h) _ X)),\n  rw [nat.pred_succ, \u2190 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 \u27e8n, h2, h4\u27e9,\n  rw [le_iff_eq_or_lt, \u2190 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 \u2194 \u2200 x : \u2115, x.coprime p \u2192 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 \u27e8\u03bb h1 x y h2 h3, _, \u03bb h1 x h2, _\u27e9,\n  replace h2 := h1 x h2,\n  rw \u2190 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 : \u2203 y : \u2115, y.coprime p \u2227 p \u2223 x + y,\n  { rcases this with \u27e8y, h3, h4\u27e9,\n    rw [\u2190 S0_p_dvd_add h (not_dvd_of_coprime (ne_of_gt h0) h2) h4, \u2190 h1 x y h2 h3, \u2190 two_mul] },\n  clear h1 h0,\n  refine \u27e8x * (p - 1), h2.mul _, _\u27e9,\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 [\u2190 mul_one_add, add_comm, nat.sub_add_cancel h.pos],\n  exact \u27e8x, mul_comm x p\u27e9\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 : \u2203 c : \u2115, p \u2223 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 \u2223 x + 2 ^ c * x :=\n    by rw [\u2190 one_add_mul, add_comm]; exact dvd_mul_of_dvd_left h1 x,\n  rw [\u2190 S0_p_dvd_add h (not_dvd_of_coprime (ne_of_gt h0) h2) h1, S0_two_pow_mul h, \u2190 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 \u2223 order_two_mod_p h * p := \u27e8S0 h 1, (h1 1 (nat.coprime_one_left p)).symm\u27e9,\n  rwa [(two_coprime_p h).dvd_mul_right, \u2190 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 : \u2115} (h : odd p) (h0 : is_prime_pow p) :\n  balanced p \u2194 even (order_two_mod_p h) :=\n\u27e8even_order_two_mod_p_of_balanced h h0.one_lt,\n  \u03bb 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)\u27e9\n\nvariables {p : \u2115} (hp : p.prime)\ninclude hp\n\n/-- Final solution, part 2 -/\ntheorem final_solution_part2 (h : odd p) :\n  balanced p \u2194 even (order_two_mod_p h) :=\n  final_solution_part2' h hp.is_prime_pow\n\n/-- If p is prime, p \u2261 3 or 5 (mod 8), then p is balanced -/\ntheorem balanced_3_or_5_mod_8 (h : p % 8 = 3 \u2228 p % 8 = 5) : balanced p :=\nbegin\n  have h0 : p \u2260 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 \u27e8p / 2, _\u27e9,\n  haveI : fact p.prime := \u27e8hp\u27e9,\n  have h2 := h0,\n  rw [\u2190 nat.coprime_primes hp nat.prime_two, hp.coprime_iff_not_dvd,\n      \u2190 char_p.cast_eq_zero_iff (zmod p), nat.cast_two, \u2190 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 [\u2190 char_p.cast_eq_zero_iff (zmod p), nat.cast_succ, add_eq_zero_iff_eq_neg,\n      nat.cast_pow, nat.cast_two, \u2190 int.cast_two, \u2190 legendre_sym.eq_pow, h3,\n      int.cast_neg, int.cast_one]\nend\n\n/-- If p is prime, p \u2261 7 (mod 8), then p is not balanced -/\ntheorem not_balanced_7_mod_8 (h : p % 8 = 7) : \u00acbalanced p :=\nbegin\n  have h0 : p \u2260 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, \u2190 nat.odd_iff_not_even],\n  suffices : 2 ^ (p / 2) \u2261 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 \u2190 this; clear this c,\n    rw [\u2190 nat.div_add_mod p 8, h, bit0, \u2190 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 := \u27e8hp\u27e9,\n  rw [\u2190 zmod.eq_iff_modeq_nat, nat.cast_one, nat.cast_pow, nat.cast_two,\n      \u2190 zmod.euler_criterion, zmod.exists_sq_eq_two_iff h0],\n  right; exact h,\n  rwa [ne.def, \u2190 nat.cast_two, char_p.cast_eq_zero_iff (zmod p) p,\n       \u2190 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 : \u2115 | odd p \u2227 p.prime \u2227 \u00acbalanced 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 \u27e8hp, h1\u27e9,\n  refine \u27e8_, hp, not_balanced_7_mod_8 hp h1\u27e9,\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 : \u2115 | odd p \u2227 p.prime \u2227 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 \u27e8hp, h1\u27e9,\n  refine \u27e8_, hp, balanced_3_or_5_mod_8 hp (or.inr h1)\u27e9,\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u211a`, is the type of rational numbers. It is defined\n  as the set of pairs \u27e8n, d\u27e9 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 : \u2124)\n(denom : \u2115)\n(pos : denom > 0)\n(cop : num.nat_abs.coprime denom)\nnotation `\u211a` := rat\n\nnamespace rat\n\nprotected def repr : \u211a \u2192 string\n| \u27e8n, d, _, _\u27e9 := if d = 1 then _root_.repr n else\n  _root_.repr n ++ \"/\" ++ _root_.repr d\n\ninstance : has_repr \u211a := \u27e8rat.repr\u27e9\ninstance : has_to_string \u211a := \u27e8rat.repr\u27e9\nmeta instance : has_to_format \u211a := \u27e8coe \u2218 rat.repr\u27e9\n\ninstance : encodable \u211a := encodable.of_equiv (\u03a3 n : \u2124, {d : \u2115 // d > 0 \u2227 n.nat_abs.coprime d})\n  \u27e8\u03bb \u27e8a, b, c, d\u27e9, \u27e8a, b, c, d\u27e9, \u03bb\u27e8a, b, c, d\u27e9, \u27e8a, b, c, d\u27e9,\n   \u03bb \u27e8a, b, c, d\u27e9, rfl, \u03bb\u27e8a, b, c, d\u27e9, rfl\u27e9\n\n/-- Embed an integer as a rational number -/\ndef of_int (n : \u2124) : \u211a :=\n\u27e8n, 1, nat.one_pos, nat.coprime_one_right _\u27e9\n\ninstance : has_zero \u211a := \u27e8of_int 0\u27e9\ninstance : has_one \u211a := \u27e8of_int 1\u27e9\ninstance : inhabited \u211a := \u27e80\u27e9\n\n/-- Form the quotient `n / d` where `n:\u2124` and `d:\u2115+` (not necessarily coprime) -/\ndef mk_pnat (n : \u2124) : \u2115+ \u2192 \u211a | \u27e8d, dpos\u27e9 :=\nlet n' := n.nat_abs, g := n'.gcd d in\n\u27e8n / 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 / \u2191g) = 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\u27e9\n\n/-- Form the quotient `n / d` where `n:\u2124` and `d:\u2115`. In the case `d = 0`, we\n  define `n / 0 = 0` by convention. -/\ndef mk_nat (n : \u2124) (d : \u2115) : \u211a :=\nif d0 : d = 0 then 0 else mk_pnat n \u27e8d, nat.pos_of_ne_zero d0\u27e9\n\n/-- Form the quotient `n / d` where `n d : \u2124`. -/\ndef mk : \u2124 \u2192 \u2124 \u2192 \u211a\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 \u27e8d, h\u27e9 = 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 : \u2124) \u2223 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 : \u2124} (b0 : b \u2260 0) : a /. b = 0 \u2194 a = 0 :=\nbegin\n  constructor; intro h; [skip, {subst a, simp}],\n  have : \u2200 {a b}, mk_pnat a b = 0 \u2192 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 : \u2200 {a b c d : \u2124} (hb : b \u2260 0) (hd : d \u2260 0),\n  a /. b = c /. d \u2194 a * d = c * b :=\nsuffices \u2200 a b c d hb hd, mk_pnat a \u27e8b, hb\u27e9 = mk_pnat c \u27e8d, hd\u27e9 \u2194 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 * \u2191(d.succ) = -c * \u2191b \u2194 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 * \u2191d = c * b.succ \u2194 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 \u2194 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 \u2190 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 := \u03bb {a b}, nat.gcd_dvd_right (int.nat_abs a) b,\n      have := nat.eq_mul_of_div_eq_right dv hb,\n      rw \u2190 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 : \u2124) \u2260 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 : \u2200 a c, a * d = c * b \u2192\n      a / a.gcd b = c / c.gcd d \u2227 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\u2081 h\u2082,\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 \u2190 int.sign_mul_nat_abs a },\n      conv in c { rw \u2190 int.sign_mul_nat_abs c },\n      rw [int.mul_div_assoc, int.mul_div_assoc],\n      exact \u27e8congr (congr_arg (*) hs) (congr_arg coe h\u2081), h\u2082\u27e9,\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 \u27e8_, bd\u27e9,\n      apply nat.eq_of_mul_eq_mul_left hb,\n      rw [\u2190 nat.mul_div_assoc _ (nat.gcd_dvd_left _ _), mul_comm,\n          nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), bd,\n          \u2190 nat.mul_div_assoc _ (nat.gcd_dvd_right _ _), h, mul_comm,\n          nat.mul_div_assoc _ (nat.gcd_dvd_left _ _)] },\n    suffices : \u2200 {a c : \u2115} (b>0) (d>0),\n      a * d = c * b \u2192 b / a.gcd b \u2264 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 \u27e8c / c.gcd d, _\u27e9,\n    rw [\u2190 nat.mul_div_assoc _ (nat.gcd_dvd_left _ _),\n        \u2190 nat.mul_div_assoc _ (nat.gcd_dvd_right _ _)],\n    apply congr_arg (/ c.gcd d),\n    rw [mul_comm, \u2190 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 : \u2124} (c0 : c \u2260 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 : \u2200 a : \u211a, a = a.num /. a.denom\n| \u27e8n, d, h, (c:_=1)\u27e9 := 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) : (\u27e8n, d, h, c\u27e9 : \u211a) = n /. d := num_denom _\n\n@[elab_as_eliminator] theorem {u} num_denom_cases_on {C : \u211a \u2192 Sort u}\n   : \u2200 (a : \u211a) (H : \u2200 n d, d > 0 \u2192 (int.nat_abs n).coprime d \u2192 C (n /. d)), C a\n| \u27e8n, d, h, c\u27e9 H := by rw num_denom'; exact H n d h c\n\n@[elab_as_eliminator] theorem {u} num_denom_cases_on' {C : \u211a \u2192 Sort u}\n   (a : \u211a) (H : \u2200 (n:\u2124) (d:\u2115), d \u2260 0 \u2192 C (n /. d)) : C a :=\nnum_denom_cases_on a $ \u03bb n d h c,\nH n d $ ne_of_gt h\n\ntheorem num_dvd (a) {b : \u2124} (b0 : b \u2260 0) : (a /. b).num \u2223 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 : \u2124) : ((a /. b).denom : \u2124) \u2223 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 [\u2190 int.nat_abs_mul, \u2190 int.coe_nat_dvd, int.dvd_nat_abs, \u2190 e], simp\nend\n\nprotected def add : \u211a \u2192 \u211a \u2192 \u211a\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := mk_pnat (n\u2081 * d\u2082 + n\u2082 * d\u2081) \u27e8d\u2081 * d\u2082, mul_pos h\u2081 h\u2082\u27e9\n\ninstance : has_add \u211a := \u27e8rat.add\u27e9\n\ntheorem lift_binop_eq (f : \u211a \u2192 \u211a \u2192 \u211a) (f\u2081 : \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124) (f\u2082 : \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124 \u2192 \u2124)\n  (fv : \u2200 {n\u2081 d\u2081 h\u2081 c\u2081 n\u2082 d\u2082 h\u2082 c\u2082},\n    f \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 = f\u2081 n\u2081 d\u2081 n\u2082 d\u2082 /. f\u2082 n\u2081 d\u2081 n\u2082 d\u2082)\n  (f0 : \u2200 {n\u2081 d\u2081 n\u2082 d\u2082} (d\u20810 : d\u2081 \u2260 0) (d\u20820 : d\u2082 \u2260 0), f\u2082 n\u2081 d\u2081 n\u2082 d\u2082 \u2260 0)\n  (a b c d : \u2124) (b0 : b \u2260 0) (d0 : d \u2260 0)\n  (H : \u2200 {n\u2081 d\u2081 n\u2082 d\u2082} (h\u2081 : a * d\u2081 = n\u2081 * b) (h\u2082 : c * d\u2082 = n\u2082 * d),\n       f\u2081 n\u2081 d\u2081 n\u2082 d\u2082 * f\u2082 a b c d = f\u2081 a b c d * f\u2082 n\u2081 d\u2081 n\u2082 d\u2082) :\n  f (a /. b) (c /. d) = f\u2081 a b c d /. f\u2082 a b c d :=\nbegin\n  generalize ha : a /. b = x, cases x with n\u2081 d\u2081 h\u2081 c\u2081, rw num_denom' at ha,\n  generalize hc : c /. d = x, cases x with n\u2082 d\u2082 h\u2082 c\u2082, rw num_denom' at hc,\n  rw fv,\n  have d\u20810 := ne_of_gt (int.coe_nat_lt.2 h\u2081),\n  have d\u20820 := ne_of_gt (int.coe_nat_lt.2 h\u2082),\n  exact (mk_eq (f0 d\u20810 d\u20820) (f0 b0 d0)).2 (H ((mk_eq b0 d\u20810).1 ha) ((mk_eq d0 d\u20820).1 hc))\nend\n\n@[simp] theorem add_def {a b c d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 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\u20810 d\u20820 },\n  calc (n\u2081 * d\u2082 + n\u2082 * d\u2081) * (b * d) =\n          (n\u2081 * b) * d\u2082 * d + (n\u2082 * d) * (d\u2081 * b) : by simp [mul_add, mul_comm, mul_left_comm]\n    ... = (a * d\u2081) * d\u2082 * d + (c * d\u2082) * (d\u2081 * b) : by rw [h\u2081, h\u2082]\n    ... = (a * d + c * b) * (d\u2081 * d\u2082)             : by simp [mul_add, mul_comm, mul_left_comm]\nend\n\nprotected def neg : \u211a \u2192 \u211a\n| \u27e8n, d, h, c\u27e9 := \u27e8-n, d, h, by simp [c]\u27e9\n\ninstance : has_neg \u211a := \u27e8rat.neg\u27e9\n\n@[simp] theorem neg_def {a b : \u2124} : -(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\u2081 d\u2081 h\u2081 c\u2081, rw num_denom' at ha,\n  show rat.mk' _ _ _ _ = _, rw num_denom',\n  have d0 := ne_of_gt (int.coe_nat_lt.2 h\u2081),\n  apply (mk_eq d0 b0).2, have h\u2081 := (mk_eq b0 d0).1 ha,\n  simp only [neg_mul_eq_neg_mul_symm, congr_arg has_neg.neg h\u2081]\nend\n\nprotected def mul : \u211a \u2192 \u211a \u2192 \u211a\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := mk_pnat (n\u2081 * n\u2082) \u27e8d\u2081 * d\u2082, mul_pos h\u2081 h\u2082\u27e9\n\ninstance : has_mul \u211a := \u27e8rat.mul\u27e9\n\n@[simp] theorem mul_def {a b c d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 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\u20810 d\u20820 },\n  cc\nend\n\nprotected def inv : \u211a \u2192 \u211a\n| \u27e8(n+1:\u2115), d, h, c\u27e9 := \u27e8d, n+1, n.succ_pos, c.symm\u27e9\n| \u27e80, d, h, c\u27e9 := 0\n| \u27e8-[1+ n], d, h, c\u27e9 := \u27e8-d, n+1, n.succ_pos, nat.coprime.symm $ by simp; exact c\u27e9\n\ninstance : has_inv \u211a := \u27e8rat.inv\u27e9\n\n@[simp] theorem inv_def {a b : \u2124} : (a /. b)\u207b\u00b9 = 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 \u27e8n, d, h, c\u27e9 = d /. n) _,\n  { cases n with n; [cases n with n, skip],\n    { refl },\n    { change int.of_nat n.succ with (n+1:\u2115),\n      unfold rat.inv, rw num_denom' },\n    { unfold rat.inv, rw num_denom', refl } },\n  have n0 : n \u2260 0,\n  { refine mt (\u03bb (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 : \u211a)\n\nprotected theorem add_zero : a + 0 = a :=\nnum_denom_cases_on' a $ \u03bb n d h,\nby rw [\u2190 zero_mk d]; simp [h, -zero_mk]\n\nprotected theorem zero_add : 0 + a = a :=\nnum_denom_cases_on' a $ \u03bb n d h,\nby rw [\u2190 zero_mk d]; simp [h, -zero_mk]\n\nprotected theorem add_comm : a + b = b + a :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nby simp [h\u2081, h\u2082, mul_comm]\n\nprotected theorem add_assoc : a + b + c = a + (b + c) :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nnum_denom_cases_on' c $ \u03bb n\u2083 d\u2083 h\u2083,\nby simp [h\u2081, h\u2082, h\u2083, 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 $ \u03bb n d h,\nby simp [h]\n\nprotected theorem mul_one : a * 1 = a :=\nnum_denom_cases_on' a $ \u03bb n d h,\nby change (1:\u211a) with 1 /. 1; simp [h]\n\nprotected theorem one_mul : 1 * a = a :=\nnum_denom_cases_on' a $ \u03bb n d h,\nby change (1:\u211a) with 1 /. 1; simp [h]\n\nprotected theorem mul_comm : a * b = b * a :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nby simp [h\u2081, h\u2082, mul_comm]\n\nprotected theorem mul_assoc : a * b * c = a * (b * c) :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nnum_denom_cases_on' c $ \u03bb n\u2083 d\u2083 h\u2083,\nby simp [h\u2081, h\u2082, h\u2083, 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 $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nnum_denom_cases_on' c $ \u03bb n\u2083 d\u2083 h\u2083,\nby simp [h\u2081, h\u2082, h\u2083, mul_ne_zero];\n   refine (div_mk_div_cancel_left (int.coe_nat_ne_zero.2 h\u2083)).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 \u2260 (1:\u211a) :=\nmt (\u03bb (h : 0 = 1 /. 1), (mk_eq_zero one_ne_zero).1 h.symm) one_ne_zero\n\nprotected theorem mul_inv_cancel : a \u2260 0 \u2192 a * a\u207b\u00b9 = 1 :=\nnum_denom_cases_on' a $ \u03bb n d h a0,\nhave n0 : n \u2260 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 \u2260 0) : a\u207b\u00b9 * a = 1 :=\neq.trans (rat.mul_comm _ _) (rat.mul_inv_cancel _ h)\n\ninstance : decidable_eq \u211a := by tactic.mk_dec_eq_instance\n\ninstance : discrete_field \u211a :=\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 \u211a              := by apply_instance\ninstance : division_ring \u211a      := by apply_instance\ninstance : integral_domain \u211a    := by apply_instance\n-- TODO(Mario): this instance slows down data.real.basic\n--instance : domain \u211a           := by apply_instance\ninstance : nonzero_comm_ring \u211a  := by apply_instance\ninstance : comm_ring \u211a          := by apply_instance\n--instance : ring \u211a             := by apply_instance\ninstance : comm_semiring \u211a      := by apply_instance\ninstance : semiring \u211a           := by apply_instance\ninstance : add_comm_group \u211a     := by apply_instance\ninstance : add_group \u211a          := by apply_instance\ninstance : add_comm_monoid \u211a    := by apply_instance\ninstance : add_monoid \u211a         := by apply_instance\ninstance : add_left_cancel_semigroup \u211a := by apply_instance\ninstance : add_right_cancel_semigroup \u211a := by apply_instance\ninstance : add_comm_semigroup \u211a := by apply_instance\ninstance : add_semigroup \u211a      := by apply_instance\ninstance : comm_monoid \u211a        := by apply_instance\ninstance : monoid \u211a             := by apply_instance\ninstance : comm_semigroup \u211a     := by apply_instance\ninstance : semigroup \u211a          := by apply_instance\n\ntheorem sub_def {a b c d : \u2124} (b0 : b \u2260 0) (d0 : d \u2260 0) :\n  a /. b - c /. d = (a * d - c * b) /. (b * d) :=\nby simp [b0, d0]\n\nprotected def nonneg : \u211a \u2192 Prop\n| \u27e8n, d, h, c\u27e9 := n \u2265 0\n\n@[simp] theorem mk_nonneg (a : \u2124) {b : \u2124} (h : b > 0) : (a /. b).nonneg \u2194 a \u2265 0 :=\nbegin\n  generalize ha : a /. b = x, cases x with n\u2081 d\u2081 h\u2081 c\u2081, rw num_denom' at ha,\n  simp [rat.nonneg],\n  have d0 := int.coe_nat_lt.2 h\u2081,\n  have := (mk_eq (ne_of_gt h) (ne_of_gt d0)).1 ha,\n  constructor; intro h\u2082,\n  { apply nonneg_of_mul_nonneg_right _ d0,\n    rw this, exact mul_nonneg h\u2082 (le_of_lt h) },\n  { apply nonneg_of_mul_nonneg_right _ h,\n    rw \u2190 this, exact mul_nonneg h\u2082 (int.coe_zero_le _) },\nend\n\nprotected def nonneg_add {a b} : rat.nonneg a \u2192 rat.nonneg b \u2192 rat.nonneg (a + b) :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nbegin\n  have d\u20810 : (d\u2081:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h\u2081),\n  have d\u20820 : (d\u2082:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h\u2082),\n  simp [d\u20810, d\u20820, h\u2081, h\u2082, mul_pos d\u20810 d\u20820],\n  intros n\u20810 n\u20820,\n  apply add_nonneg; apply mul_nonneg; {assumption <|> apply int.coe_zero_le}\nend\n\nprotected def nonneg_mul {a b} : rat.nonneg a \u2192 rat.nonneg b \u2192 rat.nonneg (a * b) :=\nnum_denom_cases_on' a $ \u03bb n\u2081 d\u2081 h\u2081,\nnum_denom_cases_on' b $ \u03bb n\u2082 d\u2082 h\u2082,\nbegin\n  have d\u20810 : (d\u2081:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h\u2081),\n  have d\u20820 : (d\u2082:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h\u2082),\n  simp [d\u20810, d\u20820, h\u2081, h\u2082, mul_pos d\u20810 d\u20820],\n  exact mul_nonneg\nend\n\nprotected def nonneg_antisymm {a} : rat.nonneg a \u2192 rat.nonneg (-a) \u2192 a = 0 :=\nnum_denom_cases_on' a $ \u03bb n d h,\nbegin\n  have d0 : (d:\u2124) > 0 := int.coe_nat_pos.2 (nat.pos_of_ne_zero h),\n  simp [d0, h],\n  exact \u03bb h\u2081 h\u2082, le_antisymm (nonpos_of_neg_nonneg h\u2082) h\u2081\nend\n\nprotected def nonneg_total : rat.nonneg a \u2228 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 : \u211a) := rat.nonneg (b - a)\n\ninstance : has_le \u211a := \u27e8rat.le\u27e9\n\ninstance decidable_le : decidable_rel ((\u2264) : \u211a \u2192 \u211a \u2192 Prop)\n| a b := show decidable (rat.nonneg (b - a)), by apply_instance\n\nprotected theorem le_def {a b c d : \u2124} (b0 : b > 0) (d0 : d > 0) :\n  a /. b \u2264 c /. d \u2194 a * d \u2264 c * b :=\nshow rat.nonneg _ \u2194 _,\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 \u2264 a :=\nshow rat.nonneg (a - a), by rw sub_self; exact le_refl (0 : \u2124)\n\nprotected theorem le_total : a \u2264 b \u2228 b \u2264 a :=\nby have := rat.nonneg_total (b - a); rwa neg_sub at this\n\nprotected theorem le_antisymm {a b : \u211a} (hab : a \u2264 b) (hba : b \u2264 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 : \u211a} (hab : a \u2264 b) (hbc : b \u2264 c) : a \u2264 c :=\nhave rat.nonneg (b - a + (c - b)), from rat.nonneg_add hab hbc,\nby simpa\n\ninstance : decidable_linear_order \u211a :=\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 \u211a                  := by apply_instance\ninstance : lattice.distrib_lattice \u211a := by apply_instance\ninstance : lattice.lattice \u211a         := by apply_instance\ninstance : lattice.semilattice_inf \u211a := by apply_instance\ninstance : lattice.semilattice_sup \u211a := by apply_instance\ninstance : lattice.has_inf \u211a         := by apply_instance\ninstance : lattice.has_sup \u211a         := by apply_instance\ninstance : linear_order \u211a            := by apply_instance\ninstance : partial_order \u211a           := by apply_instance\ninstance : preorder \u211a                := by apply_instance\n\ntheorem nonneg_iff_zero_le {a} : rat.nonneg a \u2194 0 \u2264 a :=\nshow rat.nonneg a \u2194 rat.nonneg (a - 0), by simp\n\ntheorem num_nonneg_iff_zero_le : \u2200 {a : \u211a}, 0 \u2264 a.num \u2194 0 \u2264 a\n| \u27e8n, d, h, c\u27e9 := @nonneg_iff_zero_le \u27e8n, d, h, c\u27e9\n\ntheorem mk_le {a b c d : \u2124} (h\u2081 : b > 0) (h\u2082 : d > 0) :\n  a /. b \u2264 c /. d \u2194 a * d \u2264 c * b :=\nby conv in (_ \u2264 _) {\n  simp only [(\u2264), rat.le],\n  rw [sub_def (ne_of_gt h\u2082) (ne_of_gt h\u2081),\n      mk_nonneg _ (mul_pos h\u2082 h\u2081), ge, sub_nonneg] }\n\nprotected theorem add_le_add_left {a b c : \u211a} : c + a \u2264 c + b \u2194 a \u2264 b :=\nby unfold has_le.le rat.le; rw add_sub_add_left_eq_sub\n\nprotected theorem mul_nonneg {a b : \u211a} (ha : 0 \u2264 a) (hb : 0 \u2264 b) : 0 \u2264 a * b :=\nby rw \u2190 nonneg_iff_zero_le at ha hb \u22a2; exact rat.nonneg_mul ha hb\n\ninstance : discrete_linear_ordered_field \u211a :=\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 $ \u03bb 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 \u211a                := by apply_instance\ninstance : decidable_linear_ordered_comm_ring \u211a  := by apply_instance\ninstance : linear_ordered_comm_ring \u211a            := by apply_instance\ninstance : linear_ordered_ring \u211a                 := by apply_instance\ninstance : ordered_ring \u211a                        := by apply_instance\ninstance : decidable_linear_ordered_semiring \u211a   := by apply_instance\ninstance : linear_ordered_semiring \u211a             := by apply_instance\ninstance : ordered_semiring \u211a                    := by apply_instance\ninstance : decidable_linear_ordered_comm_group \u211a := by apply_instance\ninstance : ordered_comm_group \u211a                  := by apply_instance\ninstance : ordered_cancel_comm_monoid \u211a          := by apply_instance\ninstance : ordered_comm_monoid \u211a                 := by apply_instance\n\nattribute [irreducible] rat.le\n\ntheorem num_pos_iff_pos {a : \u211a} : 0 < a.num \u2194 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 : \u2124) : of_int z = z /. 1 := num_denom' _ _ _ _\n\ntheorem coe_int_eq_mk : \u2200 z : \u2124, \u2191z = z /. 1\n| (n : \u2115) := show (n:\u211a) = n /. 1,\n  by induction n with n IH n; simp [*, show (1:\u211a) = 1 /. 1, from rfl]\n| -[1+ n] := show (-(n + 1) : \u211a) = -[1+ n] /. 1, begin\n  induction n with n IH, {refl},\n  show -(n + 1 + 1 : \u211a) = -[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 : \u2124) : \u2191z = of_int z :=\n(coe_int_eq_mk z).trans (of_int_eq_mk z).symm\n\ntheorem mk_eq_div (n d : \u2124) : n /. d = (n / d : \u211a) :=\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 \u2264 q` -/\ndef floor : \u211a \u2192 \u2124\n| \u27e8n, d, h, c\u27e9 := n / d\n\ntheorem le_floor {z : \u2124} : \u2200 {r : \u211a}, z \u2264 floor r \u2194 (z : \u211a) \u2264 r\n| \u27e8n, d, h, c\u27e9 := 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 : \u211a} {z : \u2124} : floor r < z \u2194 r < z :=\nlt_iff_lt_of_le_iff_le le_floor\n\ntheorem floor_le (r : \u211a) : (floor r : \u211a) \u2264 r :=\nle_floor.1 (le_refl _)\n\ntheorem lt_succ_floor (r : \u211a) : r < (floor r).succ :=\nfloor_lt.1 $ int.lt_succ_self _\n\n@[simp] theorem floor_coe (z : \u2124) : floor z = z :=\neq_of_forall_le_iff $ \u03bb a, by rw [le_floor, int.cast_le]\n\ntheorem floor_mono {a b : \u211a} (h : a \u2264 b) : floor a \u2264 floor b :=\nle_floor.2 (le_trans (floor_le _) h)\n\n@[simp] theorem floor_add_int (r : \u211a) (z : \u2124) : floor (r + z) = floor r + z :=\neq_of_forall_le_iff $ \u03bb a, by rw [le_floor,\n  \u2190 sub_le_iff_le_add, \u2190 sub_le_iff_le_add, le_floor, int.cast_sub]\n\ntheorem floor_sub_int (r : \u211a) (z : \u2124) : 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 \u2264 z` -/\ndef ceil (r : \u211a) : \u2124 :=\n-(floor (-r))\n\ntheorem ceil_le {z : \u2124} {r : \u211a} : ceil r \u2264 z \u2194 r \u2264 z :=\nby rw [ceil, neg_le, le_floor, int.cast_neg, neg_le_neg_iff]\n\ntheorem le_ceil (r : \u211a) : r \u2264 ceil r :=\nceil_le.1 (le_refl _)\n\n@[simp] theorem ceil_coe (z : \u2124) : ceil z = z :=\nby rw [ceil, \u2190 int.cast_neg, floor_coe, neg_neg]\n\ntheorem ceil_mono {a b : \u211a} (h : a \u2264 b) : ceil a \u2264 ceil b :=\nceil_le.2 (le_trans h (le_ceil _))\n\n@[simp] theorem ceil_add_int (r : \u211a) (z : \u2124) : 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 : \u211a) (z : \u2124) : 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 {\u03b1 : Type*}\n\nsection\nvariables [division_ring \u03b1]\n\n/-- Construct the canonical injection from `\u211a` 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 : \u211a \u2192 \u03b1\n| \u27e8n, d, h, c\u27e9 := n / d\n\n@[priority 0] instance cast_coe : has_coe \u211a \u03b1 := \u27e8rat.cast\u27e9\n\n@[simp] theorem cast_of_int (n : \u2124) : (of_int n : \u03b1) = n :=\nshow (n / (1:\u2115) : \u03b1) = n, by rw [nat.cast_one, div_one]\n\n@[simp] theorem cast_coe_int (n : \u2124) : ((n : \u211a) : \u03b1) = n :=\nby rw [coe_int_eq_of_int, cast_of_int]\n\n@[simp] theorem coe_int_num (n : \u2124) : (n : \u211a).num = n :=\nby rw coe_int_eq_of_int; refl\n\n@[simp] theorem coe_int_denom (n : \u2124) : (n : \u211a).denom = 1 :=\nby rw coe_int_eq_of_int; refl\n\n@[simp] theorem coe_nat_num (n : \u2115) : (n : \u211a).num = n :=\nby rw [\u2190 int.cast_coe_nat, coe_int_num]\n\n@[simp] theorem coe_nat_denom (n : \u2115) : (n : \u211a).denom = 1 :=\nby rw [\u2190 int.cast_coe_nat, coe_int_denom]\n\n@[simp] theorem cast_coe_nat (n : \u2115) : ((n : \u211a) : \u03b1) = n := cast_coe_int n\n\n@[simp] theorem cast_zero : ((0 : \u211a) : \u03b1) = 0 :=\n(cast_of_int _).trans int.cast_zero\n\n@[simp] theorem cast_one : ((1 : \u211a) : \u03b1) = 1 :=\n(cast_of_int _).trans int.cast_one\n\ntheorem mul_cast_comm (a : \u03b1) :\n  \u2200 (n : \u211a), (n.denom : \u03b1) \u2260 0 \u2192 a * n = n * a\n| \u27e8n, d, h, c\u27e9 h\u2082 := show a * (n * d\u207b\u00b9) = n * d\u207b\u00b9 * a,\n  by rw [\u2190 mul_assoc, int.mul_cast_comm, mul_assoc, mul_assoc,\n         \u2190 show (d:\u03b1)\u207b\u00b9 * a = a * d\u207b\u00b9, from\n           division_ring.inv_comm_of_comm h\u2082 (int.mul_cast_comm a d).symm]\n\ntheorem cast_mk_of_ne_zero (a b : \u2124)\n  (b0 : (b:\u03b1) \u2260 0) : (a /. b : \u03b1) = a / b :=\nbegin\n  have b0' : b \u2260 0, { refine mt _ b0, simp {contextual := tt} },\n  cases e : a /. b with n d h c,\n  have d0 : (d:\u03b1) \u2260 0,\n  { intro d0,\n    have dd := denom_dvd a b,\n    cases (show (d:\u2124) \u2223 b, by rwa e at dd) with k ke,\n    have : (b:\u03b1) = (d:\u03b1) * (k:\u03b1), {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 : \u2124 \u2192 \u03b1) ((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\u207b\u00b9 : \u03b1) = n / d,\n  rw [eq_div_iff_mul_eq _ _ d0, mul_assoc, nat.mul_cast_comm,\n      \u2190 mul_assoc, this, mul_assoc, mul_inv_cancel b0, mul_one]\nend\n\ntheorem cast_add_of_ne_zero : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m + n : \u211a) : \u03b1) = m + n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', add_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * (d\u2082 * (d\u2082\u207b\u00b9 * d\u2081\u207b\u00b9)) +\n    n\u2082 * (d\u2081 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9 : \u03b1) = n\u2081 * d\u2081\u207b\u00b9 + n\u2082 * d\u2082\u207b\u00b9,\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\u20810, d\u20820, division_ring.mul_ne_zero d\u20810 d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820, division_ring.mul_ne_zero d\u20810 d\u20820]} },\n  rw [\u2190 mul_assoc (d\u2082:\u03b1), mul_inv_cancel d\u20820, one_mul,\n      \u2190 nat.mul_cast_comm], simp [d\u20810, mul_assoc]\nend\n\n@[simp] theorem cast_neg : \u2200 n, ((-n : \u211a) : \u03b1) = -n\n| \u27e8n, d, h, c\u27e9 := show (\u2191-n * d\u207b\u00b9 : \u03b1) = -(n * d\u207b\u00b9),\n  by rw [int.cast_neg, neg_mul_eq_neg_mul]\n\ntheorem cast_sub_of_ne_zero {m n : \u211a}\n  (m0 : (m.denom : \u03b1) \u2260 0) (n0 : (n.denom : \u03b1) \u2260 0) : ((m - n : \u211a) : \u03b1) = m - n :=\nhave ((-n).denom : \u03b1) \u2260 0, by cases n; exact n0,\nby simp [m0, this, cast_add_of_ne_zero]\n\ntheorem cast_mul_of_ne_zero : \u2200 {m n : \u211a},\n  (m.denom : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((m * n : \u211a) : \u03b1) = m * n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := \u03bb (d\u20810 : (d\u2081:\u03b1) \u2260 0) (d\u20820 : (d\u2082:\u03b1) \u2260 0), begin\n  have d\u20810' : (d\u2081:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20810; exact d\u20810 rfl),\n  have d\u20820' : (d\u2082:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb e, by rw e at d\u20820; exact d\u20820 rfl),\n  rw [num_denom', num_denom', mul_def d\u20810' d\u20820'],\n  suffices : (n\u2081 * ((n\u2082 * d\u2082\u207b\u00b9) * d\u2081\u207b\u00b9) : \u03b1) = n\u2081 * (d\u2081\u207b\u00b9 * (n\u2082 * d\u2082\u207b\u00b9)),\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\u20810, d\u20820, division_ring.mul_ne_zero d\u20810 d\u20820, mul_assoc] },\n    all_goals {simp [d\u20810, d\u20820, division_ring.mul_ne_zero d\u20810 d\u20820]} },\n  rw [division_ring.inv_comm_of_comm d\u20810 (nat.mul_cast_comm _ _).symm]\nend\n\ntheorem cast_inv_of_ne_zero : \u2200 {n : \u211a},\n  (n.num : \u03b1) \u2260 0 \u2192 (n.denom : \u03b1) \u2260 0 \u2192 ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9\n| \u27e8n, d, h, c\u27e9 := \u03bb (n0 : (n:\u03b1) \u2260 0) (d0 : (d:\u03b1) \u2260 0), begin\n  have n0' : (n:\u2124) \u2260 0 := \u03bb e, by rw e at n0; exact n0 rfl,\n  have d0' : (d:\u2124) \u2260 0 := int.coe_nat_ne_zero.2 (\u03bb 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 : \u211a} (md : (m.denom : \u03b1) \u2260 0)\n  (nn : (n.num : \u03b1) \u2260 0) (nd : (n.denom : \u03b1) \u2260 0) : ((m / n : \u211a) : \u03b1) = m / n :=\nhave (n\u207b\u00b9.denom : \u2124) \u2223 n.num,\nby conv in n\u207b\u00b9.denom { rw [num_denom n, inv_def] };\n   apply denom_dvd,\nhave (n\u207b\u00b9.denom : \u03b1) = 0 \u2192 (n.num : \u03b1) = 0, from\n\u03bb h, let \u27e8k, e\u27e9 := this in\n  by have := congr_arg (coe : \u2124 \u2192 \u03b1) 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 \u03b1] : \u2200 {m n : \u211a}, (m : \u03b1) = n \u2194 m = n\n| \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9 \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 := begin\n  refine \u27e8\u03bb h, _, congr_arg _\u27e9,\n  have d\u20810 : d\u2081 \u2260 0 := ne_of_gt h\u2081,\n  have d\u20820 : d\u2082 \u2260 0 := ne_of_gt h\u2082,\n  have d\u2081a : (d\u2081:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20810,\n  have d\u2082a : (d\u2082:\u03b1) \u2260 0 := nat.cast_ne_zero.2 d\u20820,\n  rw [num_denom', num_denom'] at h \u22a2,\n  rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h; simp [d\u20810, d\u20820] at h \u22a2,\n  rwa [eq_div_iff_mul_eq _ _ d\u2082a, division_def, mul_assoc,\n    division_ring.inv_comm_of_comm d\u2081a (nat.mul_cast_comm _ _),\n    \u2190 mul_assoc, \u2190 division_def, eq_comm, eq_div_iff_mul_eq _ _ d\u2081a, eq_comm,\n    \u2190 int.cast_coe_nat, \u2190 int.cast_mul, \u2190 int.cast_coe_nat, \u2190 int.cast_mul,\n    int.cast_inj, \u2190 mk_eq (int.coe_nat_ne_zero.2 d\u20810) (int.coe_nat_ne_zero.2 d\u20820)] at h\nend\n\ntheorem cast_injective [char_zero \u03b1] : function.injective (coe : \u211a \u2192 \u03b1)\n| m n := cast_inj.1\n\n@[simp] theorem cast_eq_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) = 0 \u2194 n = 0 :=\nby rw [\u2190 cast_zero, cast_inj]\n\n@[simp] theorem cast_ne_zero [char_zero \u03b1] {n : \u211a} : (n : \u03b1) \u2260 0 \u2194 n \u2260 0 :=\nnot_congr cast_eq_zero\n\ntheorem eq_cast_of_ne_zero (f : \u211a \u2192 \u03b1) (H1 : f 1 = 1)\n  (Hadd : \u2200 x y, f (x + y) = f x + f y)\n  (Hmul : \u2200 x y, f (x * y) = f x * f y) :\n  \u2200 n : \u211a, (n.denom : \u03b1) \u2260 0 \u2192 f n = n\n| \u27e8n, d, h, c\u27e9 := \u03bb (h\u2082 : ((d:\u2124):\u03b1) \u2260 0), show _ = (n / (d:\u2124) : \u03b1), begin\n  rw [num_denom', mk_eq_div, eq_div_iff_mul_eq _ _ h\u2082],\n  have : \u2200 n : \u2124, f n = n, { apply int.eq_cast; simp [H1, Hadd] },\n  rw [\u2190 this, \u2190 this, \u2190 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 \u03b1] (f : \u211a \u2192 \u03b1) (H1 : f 1 = 1)\n  (Hadd : \u2200 x y, f (x + y) = f x + f y)\n  (Hmul : \u2200 x y, f (x * y) = f x * f y) (n : \u211a) : 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 \u03b1] [char_zero \u03b1] (a b : \u2124) : ((a /. b) : \u03b1) = 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 \u03b1] [char_zero \u03b1] (m n) : ((m + n : \u211a) : \u03b1) = 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 \u03b1] [char_zero \u03b1] (m n) : ((m - n : \u211a) : \u03b1) = 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 \u03b1] [char_zero \u03b1] (m n) : ((m * n : \u211a) : \u03b1) = 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 \u03b1] [char_zero \u03b1] (n) : ((n\u207b\u00b9 : \u211a) : \u03b1) = n\u207b\u00b9 :=\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 \u03b1] [char_zero \u03b1] (m n) : ((m / n : \u211a) : \u03b1) = m / n :=\nby rw [division_def, cast_mul, cast_inv, division_def]\n\n@[simp] theorem cast_pow [discrete_field \u03b1] [char_zero \u03b1] (q) (k : \u2115) : ((q ^ k : \u211a) : \u03b1) = q ^ k :=\nby induction k; simp only [*, cast_one, cast_mul, pow_zero, pow_succ]\n\n@[simp] theorem cast_bit0 [division_ring \u03b1] [char_zero \u03b1] (n : \u211a) : ((bit0 n : \u211a) : \u03b1) = bit0 n := cast_add _ _\n\n@[simp] theorem cast_bit1 [division_ring \u03b1] [char_zero \u03b1] (n : \u211a) : ((bit1 n : \u211a) : \u03b1) = bit1 n :=\nby rw [bit1, cast_add, cast_one, cast_bit0]; refl\n\n@[simp] theorem cast_nonneg [linear_ordered_field \u03b1] : \u2200 {n : \u211a}, 0 \u2264 (n : \u03b1) \u2194 0 \u2264 n\n| \u27e8n, d, h, c\u27e9 := show 0 \u2264 (n * d\u207b\u00b9 : \u03b1) \u2194 0 \u2264 (\u27e8n, d, h, c\u27e9 : \u211a),\n  by rw [num_denom', \u2190 nonneg_iff_zero_le, mk_nonneg _ (int.coe_nat_pos.2 h),\n    mul_nonneg_iff_right_nonneg_of_pos (@inv_pos \u03b1 _ _ (nat.cast_pos.2 h)),\n    int.cast_nonneg]\n\n@[simp] theorem cast_le [linear_ordered_field \u03b1] {m n : \u211a} : (m : \u03b1) \u2264 n \u2194 m \u2264 n :=\nby rw [\u2190 sub_nonneg, \u2190 cast_sub, cast_nonneg, sub_nonneg]\n\n@[simp] theorem cast_lt [linear_ordered_field \u03b1] {m n : \u211a} : (m : \u03b1) < n \u2194 m < n :=\nby simpa [-cast_le] using not_congr (@cast_le \u03b1 _ n m)\n\n@[simp] theorem cast_nonpos [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) \u2264 0 \u2194 n \u2264 0 :=\nby rw [\u2190 cast_zero, cast_le]\n\n@[simp] theorem cast_pos [linear_ordered_field \u03b1] {n : \u211a} : (0 : \u03b1) < n \u2194 0 < n :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp] theorem cast_lt_zero [linear_ordered_field \u03b1] {n : \u211a} : (n : \u03b1) < 0 \u2194 n < 0 :=\nby rw [\u2190 cast_zero, cast_lt]\n\n@[simp] theorem cast_id : \u2200 n : \u211a, \u2191n = n\n| \u27e8n, d, h, c\u27e9 := show (n / (d : \u2124) : \u211a) = _, by rw [num_denom', mk_eq_div]\n\n@[simp] theorem cast_min [discrete_linear_ordered_field \u03b1] {a b : \u211a} : (\u2191(min a b) : \u03b1) = min a b :=\nby by_cases a \u2264 b; simp [h, min]\n\n@[simp] theorem cast_max [discrete_linear_ordered_field \u03b1] {a b : \u211a} : (\u2191(max a b) : \u03b1) = max a b :=\nby by_cases a \u2264 b; simp [h, max]\n\n@[simp] theorem cast_abs [discrete_linear_ordered_field \u03b1] {q : \u211a} : ((abs q : \u211a) : \u03b1) = 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 \u2264 n`.\n  It is the same as `ceil q` when `q \u2265 0`, otherwise it is `0`. -/\ndef nat_ceil (q : \u211a) : \u2115 := int.to_nat (ceil q)\n\ntheorem nat_ceil_le {q : \u211a} {n : \u2115} : nat_ceil q \u2264 n \u2194 q \u2264 n :=\nby rw [nat_ceil, int.to_nat_le, ceil_le]; refl\n\ntheorem lt_nat_ceil {q : \u211a} {n : \u2115} : n < nat_ceil q \u2194 (n : \u211a) < q :=\nnot_iff_not.1 $ by rw [not_lt, not_lt, nat_ceil_le]\n\ntheorem le_nat_ceil (q : \u211a) : q \u2264 nat_ceil q :=\nnat_ceil_le.1 (le_refl _)\n\ntheorem nat_ceil_mono {q\u2081 q\u2082 : \u211a} (h : q\u2081 \u2264 q\u2082) : nat_ceil q\u2081 \u2264 nat_ceil q\u2082 :=\nnat_ceil_le.2 (le_trans h (le_nat_ceil _))\n\n@[simp] theorem nat_ceil_coe (n : \u2115) : nat_ceil n = n :=\nshow (ceil (n:\u2124)).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 : \u211a} (hq : 0 \u2264 q) (n : \u2115) : nat_ceil (q + n) = nat_ceil q + n :=\nshow int.to_nat (ceil (q + (n:\u2124))) = 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| _, \u27e8m, rfl\u27e9 := rfl\nend\n\ntheorem nat_ceil_lt_add_one {q : \u211a} (hq : q \u2265 0) : \u2191(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 : \u2200 q : \u211a, (-q).denom = q.denom\n| \u27e8_, d, _, _\u27e9 := rfl\n\n@[simp] lemma num_neg_eq_neg_num : \u2200 q : \u211a, (-q).num = -(q.num)\n| \u27e8n, _, _, _\u27e9 := rfl\n\n@[simp] lemma num_zero : rat.num 0 = 0 := rfl\n\nlemma zero_of_num_zero {q : \u211a} (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 : \u211a} : q = 0 \u2194 q.num = 0 :=\n\u27e8\u03bb _, by simp *, zero_of_num_zero\u27e9\n\nlemma num_ne_zero_of_ne_zero {q : \u211a} (h : q \u2260 0) : q.num \u2260 0 :=\nassume : q.num = 0,\nh $ zero_of_num_zero this\n\n@[simp] lemma num_one : (1 : \u211a).num = 1 := rfl\n\n@[simp] lemma denom_one : (1 : \u211a).denom = 1 := rfl\n\nlemma denom_ne_zero (q : \u211a) : q.denom \u2260 0 :=\nne_of_gt q.pos\n\nlemma mk_num_ne_zero_of_ne_zero {q : \u211a} {n d : \u2124} (hq : q \u2260 0) (hqnd : q = n /. d) : n \u2260 0 :=\nassume : n = 0,\nhq $ by simpa [this] using hqnd\n\nlemma mk_denom_ne_zero_of_ne_zero {q : \u211a} {n d : \u2124} (hq : q \u2260 0) (hqnd : q = n /. d) : d \u2260 0 :=\nassume : d = 0,\nhq $ by simpa [this] using hqnd\n\nlemma mk_ne_zero_of_ne_zero {n d : \u2124} (h : n \u2260 0) (hd : d \u2260 0) : n /. d \u2260 0 :=\nassume : n /. d = 0,\nh $ (mk_eq_zero hd).1 this\n\nlemma mul_num_denom (q r : \u211a) : q * r = (q.num * r.num) /. \u2191(q.denom * r.denom) :=\nhave hq' : (\u2191q.denom : \u2124) \u2260 0, by have := denom_ne_zero q; simpa,\nhave hr' : (\u2191r.denom : \u2124) \u2260 0, by have := denom_ne_zero r; simpa,\nsuffices (q.num /. \u2191q.denom) * (r.num /. \u2191r.denom) = (q.num * r.num) /. \u2191(q.denom * r.denom),\n  by rwa [\u2190num_denom q, \u2190num_denom r] at this,\nby simp [mul_def hq' hr']\n\nlemma div_num_denom (q r : \u211a) : 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\u207b\u00b9 : div_eq_mul_inv\n            ... = (q.num /. q.denom) * (r.num /. r.denom)\u207b\u00b9 : by rw [\u2190num_denom q, \u2190num_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 : \u211a} {n d : \u2124} (hn : n \u2260 0) (hd : d \u2260 0) (qdf : q = n /. d) :\n      \u2203 c : \u2124, n = c * q.num \u2227 d = c * q.denom :=\nhave hq : q \u2260 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 [\u2190rat.num_denom q],\nhave q.num * d = n * \u2191(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 \u2223 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 : \u2124) (d : \u2115+) :\n  (mk_pnat n d).num = n / nat.gcd n.nat_abs d :=\nby cases d; refl\n\ntheorem mk_pnat_denom (n : \u2124) (d : \u2115+) :\n  (mk_pnat n d).denom = d / nat.gcd n.nat_abs d :=\nby cases d; refl\n\ntheorem mul_num (q\u2081 q\u2082 : \u211a) : (q\u2081 * q\u2082).num =\n  (q\u2081.num * q\u2082.num) / nat.gcd (q\u2081.num * q\u2082.num).nat_abs (q\u2081.denom * q\u2082.denom) :=\nby cases q\u2081; cases q\u2082; refl\n\ntheorem mul_denom (q\u2081 q\u2082 : \u211a) : (q\u2081 * q\u2082).denom =\n  (q\u2081.denom * q\u2082.denom) / nat.gcd (q\u2081.num * q\u2082.num).nat_abs (q\u2081.denom * q\u2082.denom) :=\nby cases q\u2081; cases q\u2082; refl\n\ntheorem mul_self_num (q : \u211a) : (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 : \u211a) : (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 : \u211a) : abs q = q.num.nat_abs /. q.denom :=\nbegin\n  have hz : (0:\u211a) = 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, \u2190 neg_def, \u2190 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, \u2190 num_denom q] }\nend\n\nlemma add_num_denom (q r : \u211a) : q + r =\n  ((q.num * r.denom + q.denom * r.num : \u2124)) /. (\u2191q.denom * \u2191r.denom : \u2124) :=\nhave hqd : (q.denom : \u2124) \u2260 0, from int.coe_nat_ne_zero_iff_pos.2 q.3,\nhave hrd : (r.denom : \u2124) \u2260 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 : \u211a) : \u211a :=\nrat.mk (int.sqrt q.num) (nat.sqrt q.denom)\n\ntheorem sqrt_eq (q : \u211a) : 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 : \u211a) :\n  (\u2203 q, q * q = x) \u2194 rat.sqrt x * rat.sqrt x = x :=\n\u27e8\u03bb \u27e8n, hn\u27e9, by rw [\u2190 hn, sqrt_eq, abs_mul_abs_self],\n\u03bb h, \u27e8rat.sqrt x, h\u27e9\u27e9\n\ntheorem sqrt_nonneg (q : \u211a) : 0 \u2264 rat.sqrt q :=\nnonneg_iff_zero_le.1 $ (mk_nonneg _ $ int.coe_nat_pos.2 $\nnat.pos_of_ne_zero $ \u03bb 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 : \u2115) := cmonad (fi n)\n\n/- Projecting at the i-th dimension -/\n-- TODO generalize this to arbitrary elementary surjections?\ndef cproj (b : bool) : \u03a0 {m}, fi (m + 1) \u2192 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 \u2218 deg i\n\ntheorem cproj_cdeg {m} {b : bool} (i : fi (m + 1)) : cproj b i \u2218c cdeg i = dim :=\nbegin\n  apply funext, intro j, change (_ \u2218c 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 \u2218 suc)) :=\nby reflexivity\n\ntheorem clift_dim {n : \u2115} : clift (@dim (fi n)) = dim :=\nbegin\n  apply funext, intro i, cases i, repeat {reflexivity},\nend\n\ntheorem clift_ccomp {m n o : \u2115} (f : cmor (fi m) (fi n)) (g : cmor (fi n) (fi o)) :\n  clift (g \u2218c f) = (clift g) \u2218c (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 : \u2115} (f : cmor (fi m) (fi n)) (b : bool) :\n  (cproj b fi.zero) \u2218c (clift f) = f \u2218c (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 : \u2115} : cmor (fi 0) (fi m) := \u03bb i, match i with\n                                                  end\n\ntheorem zero_deg_right {m n : \u2115} (f : cmor (fi m) (fi n)) :\n  f \u2218c 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: \u2200c st st1 st2,\n    st =[ c ]\u21d2 st1 \u2192\n    st =[ c ]\u21d2 st2 \u2192\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 \u2192 tactic (list name) :=\n-- \u03bbes, match es with\n-- | [] := do pure []\n-- | e::es := do\n--   es' \u2190 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' \u2190 get_local h,\n--   rs \u2190 cases h',\n--   try $ clear_lst [h],\n--   subst_vars,\n--   g \u2190 get_goals,\n--   -- supporting naming\n--   try $ (list.zip g rs).mmap'(\u03bbr, do\n--     -- trace r,\n--     let \u27e8g, n, e\u27e9 := r,\n--     n' \u2190 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' \u2190 get_local h,\n  rs \u2190 cases (none, pexpr.of_expr h') w,\n  try $ propagate_tags $ do\n  clear_lst [h],\n  subst_vars\n  -- g \u2190 get_goals,\n  -- -- supporting naming\n  -- try $ (list.zip g rs).mmap'(\u03bbr, do\n  --   -- trace r,\n  --   let \u27e8g, n, e\u27e9 := r,\n  --   n' \u2190 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 \u2192 state \u2192 state \u2192 Prop\n| E_Skip : \u2200st, ceval SKIP st st\n| E_Ass : \u2200{st a\u2081 n} x,\n  aeval st a\u2081 = n \u2192\n  ceval (x ::= a\u2081) st (x !\u2192 n ; st)\n| E_Seq : \u2200{c\u2081 c\u2082 st st' st''},\n  ceval c\u2081 st st' \u2192\n  ceval c\u2082 st' st'' \u2192\n  ceval (c\u2081 ;; c\u2082) st st''\n| E_IfTrue : \u2200{st st' b c\u2081} c\u2082,\n  beval st b = tt \u2192\n  ceval c\u2081 st st' \u2192\n  ceval (TEST b THEN c\u2081 ELSE c\u2082 FI) st st'\n| E_IfFalse : \u2200{st st' b} c\u2081 {c\u2082},\n  beval st b = ff \u2192\n  ceval c\u2082 st st' \u2192\n  ceval (TEST b THEN c\u2081 ELSE c\u2082 FI) st st'\n| E_WhileFalse : \u2200{b st} c,\n  beval st b = ff \u2192\n  ceval (WHILE b DO c END) st st\n| E_WhileTrue : \u2200{st st' st'' b c},\n  beval st b = tt \u2192\n  ceval c st st' \u2192\n  ceval (WHILE b DO c END) st' st'' \u2192\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\u2081 st\u2082}\n  (h\u2081 : st =[ c ]\u21d2 st\u2081) (h\u2082 : st =[ c ]\u21d2 st\u2082)\n  : st\u2081 = st\u2082 :=\nbegin\n  induction h\u2081 generalizing st\u2082; inv h\u2082,\n  case E_Ass { refl, },\n  case E_Seq {\n    cases h\u2081_ih_a h\u2082_a,\n    exact h\u2081_ih_a_1 h\u2082_a_1,\n  },\n  case E_IfTrue E_IfTrue { exact h\u2081_ih h\u2082_a_1, },\n  case E_IfTrue E_IfFalse {\n    rw h\u2081_a at h\u2082_a,\n    contradiction,\n  },\n  case E_IfFalse E_IfTrue {\n    rw h\u2081_a at h\u2082_a,\n    contradiction,\n  },\n  case E_IfFalse E_IfFalse { exact h\u2081_ih h\u2082_a_1, },\n  case E_WhileFalse E_WhileTrue {\n    rw h\u2081_a at h\u2082_a,\n    contradiction,\n  },\n  case E_WhileTrue E_WhileFalse {\n    rw h\u2081_a at h\u2082_a,\n    contradiction,\n  },\n  case E_WhileTrue E_WhileTrue {\n    cases h\u2081_ih_a h\u2082_a_1,\n    exact h\u2081_ih_a_1 h\u2082_a_2,\n  },\nend\n\n/-\nExample auto_example_1 : \u2200(P Q R: Prop),\n  (P \u2192 Q) \u2192 (Q \u2192 R) \u2192 P \u2192 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 \u2192 Q) (hqr : Q \u2192 R) (hp : P) : R :=\nbegin\n  apply hqr,\n  apply hpq,\n  exact hp,\nend\n\n/-\nExample auto_example_1' : \u2200(P Q R: Prop),\n  (P \u2192 Q) \u2192 (Q \u2192 R) \u2192 P \u2192 R.\nProof.\n  auto.\nQed.\n-/\n\nexample (P Q R : Prop) : (P \u2192 Q) \u2192 (Q \u2192 R) \u2192 P \u2192 R := by tauto\n\n/-\nExample auto_example_2 : \u2200P Q R S T U : Prop,\n  (P \u2192 Q) \u2192\n  (P \u2192 R) \u2192\n  (T \u2192 R) \u2192\n  (S \u2192 T \u2192 U) \u2192\n  ((P\u2192Q) \u2192 (P\u2192S)) \u2192\n  T \u2192\n  P \u2192\n  U.\nProof. auto. Qed.\n-/\n\n/- tauto is not good -/\nexample (P Q R S T U : Prop) :\n  (P \u2192 Q) \u2192\n  (P \u2192 R) \u2192\n  (T \u2192 R) \u2192\n  (S \u2192 T \u2192 U) \u2192\n  ((P \u2192 Q) \u2192 (P \u2192 S)) \u2192\n  T \u2192\n  P \u2192\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 \u2192 Q) \u2192\n  (P \u2192 R) \u2192\n  (T \u2192 R) \u2192\n  (S \u2192 T \u2192 U) \u2192\n  ((P \u2192 Q) \u2192 (P \u2192 S)) \u2192\n  T \u2192\n  P \u2192\n  U := by cc\n\n/-\nExample auto_example_3 : \u2200(P Q R S T U: Prop),\n  (P \u2192 Q) \u2192\n  (Q \u2192 R) \u2192\n  (R \u2192 S) \u2192\n  (S \u2192 T) \u2192\n  (T \u2192 U) \u2192\n  P \u2192\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 \u2192 Q) \u2192\n  (Q \u2192 R) \u2192\n  (R \u2192 S) \u2192\n  (S \u2192 T) \u2192\n  (T \u2192 U) \u2192\n  P \u2192\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 \u2192 Q) \u2192\n  (Q \u2192 R) \u2192\n  (R \u2192 S) \u2192\n  (S \u2192 T) \u2192\n  (T \u2192 U) \u2192\n  P \u2192\n  U := by cc\n\n/-\nExample auto_example_4 : \u2200P Q R : Prop,\n  Q \u2192\n  (Q \u2192 R) \u2192\n  P \u2228 (Q \u2227 R).\nProof. auto. Qed.\n-/\n\n/- tauto failed here too -/\nexample (P Q R : Prop) : Q \u2192 (Q \u2192 R) \u2192 P \u2228 (Q \u2227 R) := by cc\n\n/-\nLemma le_antisym : \u2200n m: nat, (n \u2264 m \u2227 m \u2264 n) \u2192 n = m.\nProof. intros. omega. Qed.\n\nExample auto_example_6 : \u2200n m p : nat,\n  (n \u2264 p \u2192 (n \u2264 m \u2227 m \u2264 n)) \u2192\n  n \u2264 p \u2192\n  n = m.\nProof.\n  intros.\n  auto using le_antisym.\nQed.\n-/\n\nlemma le_antisym {n m : \u2115} (h : n \u2264 m \u2227 m \u2264 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 : \u2115) :\n  (n \u2264 p \u2192 n \u2264 m \u2227 m \u2264 n) \u2192\n  n \u2264 p \u2192\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' : \u2200n m p : nat,\n  (n\u2264 p \u2192 (n \u2264 m \u2227 m \u2264 n)) \u2192\n  n \u2264 p \u2192\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: \u2200x,\n  (x \u2264 42 \u2227 42 \u2264 x) \u2192 is_fortytwo x.\nProof.\n  auto. (* does nothing *)\nAbort.\n\nHint Unfold is_fortytwo.\n\nExample auto_example_7' : \u2200x,\n  (x \u2264 42 \u2227 42 \u2264 x) \u2192 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 : \u2115) :\n  (n \u2264 p \u2192 n \u2264 m \u2227 m \u2264 n) \u2192\n  n \u2264 p \u2192\n  n = m := by ifinish\n\ndef is_fortytwo (x) := x = 42\n\n-- example (x) : (x \u2264 42 \u2227 42 \u2264 x) \u2192 is_fortytwo x := by isafe,\n\nexample (x) : (x \u2264 42 \u2227 42 \u2264 x) \u2192 is_fortytwo x := by isafe using is_fortytwo\n\nlocal attribute [simp] is_fortytwo\n\nexample (x) : (x \u2264 42 \u2227 42 \u2264 x) \u2192 is_fortytwo x := by finish\n\n/-\nTheorem ceval_deterministic': \u2200c st st1 st2,\n    st =[ c ]\u21d2 st1 \u2192\n    st =[ c ]\u21d2 st2 \u2192\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\u2081 st\u2082}\n  (h\u2081 : st =[ c ]\u21d2 st\u2081) (h\u2082 : st =[ c ]\u21d2 st\u2082)\n  : st\u2081 = st\u2082 :=\nbegin\n  induction h\u2081 generalizing st\u2082; inv h\u2082; try { ifinish },\n  /- E_ASS -/ { tauto, },\n  /- E_SEQ -/ {\n    have : h\u2081_st' = h\u2082_st', tauto,\n    ifinish,\n  },\n  /- E_WHILE_TRUE E_WHILE_TRUE -/ {\n    have : h\u2081_st' = h\u2082_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'': \u2200c st st1 st2,\n    st =[ c ]\u21d2 st1 \u2192\n    st =[ c ]\u21d2 st2 \u2192\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\u2081 h\u2082 : parse ident) : tactic unit :=\npropagate_tags $ do\n  h\u2081' \u2190 get_local h\u2081,\n  h\u2082' \u2190 get_local h\u2082,\n  rewrite_hyp h\u2081' h\u2082',\n  inv h\u2082 []\n\nend tactic.interactive\n\ntheorem ceval_deterministic'' {c st st\u2081 st\u2082}\n  (h\u2081 : st =[ c ]\u21d2 st\u2081) (h\u2082 : st =[ c ]\u21d2 st\u2082)\n  : st\u2081 = st\u2082 :=\nbegin\n  induction h\u2081 generalizing st\u2082; inv h\u2082; try { tauto <|> rwinv h\u2081_a h\u2082_a },\n  case E_Seq {\n    have : h\u2081_st' = h\u2082_st', tauto,\n    ifinish,\n  },\n  case E_WhileTrue E_WhileTrue {\n    have : h\u2081_st' = h\u2082_st', tauto,\n    ifinish,\n  },\nend\n\n/-\nLtac find_rwinv :=\n  match goal with\n    H1: ?E = true,\n    H2: ?E = false\n    \u22a2 _ \u21d2 rwinv H1 H2\n  end.\n-/\n\nnamespace tactic.interactive\n\n-- meta def eq_bool (b : bool): list expr \u2192 tactic (option expr)\n-- | [] := none\n-- | (e::es) := do\n--   e' \u2190 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 \u2190 local_context,\n  mv \u2190 mk_mvar,\n  h\u2081 \u2190 find_same_type `(%%mv = tt) ctx,\n  h\u2082 \u2190 find_same_type `(%%mv = ff) ctx,\n  rwinv h\u2081.local_pp_name h\u2082.local_pp_name\n\nend tactic.interactive\n\ntheorem ceval_deterministic''' {c st st\u2081 st\u2082}\n  (h\u2081 : st =[ c ]\u21d2 st\u2081) (h\u2082 : st =[ c ]\u21d2 st\u2082)\n  : st\u2081 = st\u2082 :=\nbegin\n  induction h\u2081 generalizing st\u2082; inv h\u2082; try { tauto <|> find_rwinv },\n  case E_Seq {\n    have : h\u2081_st' = h\u2082_st', tauto,\n    ifinish,\n  },\n  case E_WhileTrue E_WhileTrue {\n    have : h\u2081_st' = h\u2082_st', tauto,\n    ifinish,\n  },\nend\n\n/-\nLtac find_eqn :=\n  match goal with\n    H1: \u2200x, ?P x \u2192 ?L = ?R,\n    H2: ?P ?X\n    \u22a2 _ \u21d2 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 \u2192 tactic string := \u03bbe, do\n--   trace $ \"e: \" ++ to_string e,\n--   s \u2190 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\u2081 e\u2082 body :=\n--     pure $ \"elet: \" ++ to_string n ++ to_string e\u2081 ++\n--       to_string e\u2082 ++ 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\u2081 n\u2082 bind e :=\n--     pure $ \"loc: \" ++ to_string n\u2081 ++ to_string n\u2082 ++ to_string e\n--   | macro d es := pure $ \"mac: \" ++ to_string es\n--   | mvar n\u2081 n\u2082 e :=\n--     pure $ \"mvar: \" ++ to_string n\u2081 ++ to_string n\u2082 ++ to_string e\n--   | pi n bind e body :=\n--     -- expr_view e >>= \u03bbe,\n--     -- expr_view body >>= \u03bbbody,\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 \u2190 local_context,\n--   ctx.mmap' (\u03bbh, expr_view h >> infer_type h >>= expr_view)\n\n-- meta def infer (e : expr) : tactic (expr \u00d7 expr) := do\n--   e' \u2190 infer_type e,\n--   pure (e, e')\n\nmeta def find_pi : (list (expr \u00d7 expr)) \u2192 tactic (list (expr \u00d7 expr)) := \u03bbes,\n  match es with\n  | (n, (pi _ _ _ (pi _ _ (app e\u2081 e\u2082) `(%%l = %%r))))::es := do\n    es \u2190 find_pi es,\n    pure $ (n, e\u2081)::es\n  | (_::es) := find_pi es\n  | _ := pure $ []\n  end\n\nmeta def find_app (e: expr) : (list (expr \u00d7 expr)) \u2192 tactic (list (expr \u00d7 expr))\n:= \u03bbes,\n  match es with\n  | (n, (app e\u2081 e\u2082))::es := do\n    es \u2190 find_app es,\n    pure $ if e = e\u2081 then (n, e\u2082)::es else es\n  | (_::es) := find_app es\n  | _ := pure $ []\n  end\n\nmeta def find_props : tactic (list (expr \u00d7 expr \u00d7 expr)) := do\n  h \u2190 local_context,\n  h \u2190 h.mmap (\u03bbh, do h' \u2190 infer_type h, pure (h, h')),\n  a \u2190 find_pi h,\n  p \u2190 a.mmap (\u03bb\u27e8n, e\u27e9, do\n    p \u2190 find_app e h,\n    pure $ p.map (\u03bb\u27e8n\u2081, e\u27e9, (n, n\u2081, e))\n  ),\n  pure p.join\n\nmeta def find_eqn : tactic unit :=\npropagate_tags $ do\n  p \u2190 find_props,\n  p.mmap' (\u03bb\u27e8n\u2081, n\u2082, e\u27e9, do\n    h \u2190 note `this none (mk_app n\u2081 [e, n\u2082]),\n    do tactic.subst h <|> tactic.clear h\n  )\n\nend tactic.interactive\n\n/-\nTheorem ceval_deterministic''''': \u2200c st st1 st2,\n    st =[ c ]\u21d2 st1 \u2192\n    st =[ c ]\u21d2 st2 \u2192\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\u2081 st\u2082}\n  (h\u2081 : st =[ c ]\u21d2 st\u2081) (h\u2082 : st =[ c ]\u21d2 st\u2082)\n  : st\u2081 = st\u2082 :=\nbegin\n  induction h\u2081 generalizing st\u2082;\n    inv h\u2082;\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\u2081 c\u2082 : com)\n| CIf (b : bexp) (c\u2081 c\u2082 : 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 \u2192 com \u2192 state \u2192 Prop :=\n  | E_Skip : \u2200st,\n      ceval st SKIP st\n  | E_Ass : \u2200st a1 n X,\n      aeval st a1 = n \u2192\n      ceval st (X ::= a1) (t_update st X n)\n  | E_Seq : \u2200c1 c2 st st' st'',\n      ceval st c1 st' \u2192\n      ceval st' c2 st'' \u2192\n      ceval st (c1 ; c2) st''\n  | E_IfTrue : \u2200st st' b1 c1 c2,\n      beval st b1 = true \u2192\n      ceval st c1 st' \u2192\n      ceval st (TEST b1 THEN c1 ELSE c2 FI) st'\n  | E_IfFalse : \u2200st st' b1 c1 c2,\n      beval st b1 = false \u2192\n      ceval st c2 st' \u2192\n      ceval st (TEST b1 THEN c1 ELSE c2 FI) st'\n  | E_WhileFalse : \u2200b1 st c1,\n      beval st b1 = false \u2192\n      ceval st (WHILE b1 DO c1 END) st\n  | E_WhileTrue : \u2200st st' st'' b1 c1,\n      beval st b1 = true \u2192\n      ceval st c1 st' \u2192\n      ceval st' (WHILE b1 DO c1 END) st'' \u2192\n      ceval st (WHILE b1 DO c1 END) st''\n  | E_RepeatEnd : \u2200st st' b1 c1,\n      ceval st c1 st' \u2192\n      beval st' b1 = true \u2192\n      ceval st (CRepeat c1 b1) st'\n  | E_RepeatLoop : \u2200st st' st'' b1 c1,\n      ceval st c1 st' \u2192\n      beval st' b1 = false \u2192\n      ceval st' (CRepeat c1 b1) st'' \u2192\n      ceval st (CRepeat c1 b1) st''.\n\nNotation \"st '=[' c ']\u21d2' 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\u2081 ` THEN ` c\u2082 ` ELSE ` c\u2083 ` FI` := CIf c\u2081 c\u2082 c\u2083\nlocal notation `REPEAT ` e\u2081 ` UNTIL ` b\u2082 ` END` := CRepeat e\u2081 b\u2082\n\ninductive ceval : com \u2192 imp.state \u2192 imp.state \u2192 Prop\n| E_Skip : \u2200st, ceval SKIP st st\n| E_Ass : \u2200{st a\u2081 n} x,\n  aeval st a\u2081 = n \u2192\n  ceval (x ::= a\u2081) st (x !\u2192 n ; st)\n| E_Seq : \u2200{c\u2081 c\u2082 st st' st''},\n  ceval c\u2081 st st' \u2192\n  ceval c\u2082 st' st'' \u2192\n  ceval (c\u2081 ;; c\u2082) st st''\n| E_IfTrue : \u2200{st st' b c\u2081} c\u2082,\n  beval st b = tt \u2192\n  ceval c\u2081 st st' \u2192\n  ceval (TEST b THEN c\u2081 ELSE c\u2082 FI) st st'\n| E_IfFalse : \u2200{st st' b} c\u2081 {c\u2082},\n  beval st b = ff \u2192\n  ceval c\u2082 st st' \u2192\n  ceval (TEST b THEN c\u2081 ELSE c\u2082 FI) st st'\n| E_WhileFalse : \u2200{b st} c,\n  beval st b = ff \u2192\n  ceval (WHILE b DO c END) st st\n| E_WhileTrue : \u2200{st st' st'' b c},\n  beval st b = tt \u2192\n  ceval c st st' \u2192\n  ceval (WHILE b DO c END) st' st'' \u2192\n  ceval (WHILE b DO c END) st st''\n| E_RepeatEnd : \u2200{st st' b c},\n  ceval c st st' \u2192\n  beval st' b = tt \u2192\n  ceval (REPEAT c UNTIL b END) st st'\n| E_RepeatLoop : \u2200{st st' st'' b c},\n  ceval c st st' \u2192\n  beval st' b = ff \u2192\n  ceval (REPEAT c UNTIL b END) st' st'' \u2192\n  ceval (REPEAT c UNTIL b END) st st''\n\nopen ceval\n\nlocal notation st ` =[ ` c ` ]\u21d2 ` st' := ceval c st st'\n\nopen imp\n\n/-\nTheorem ceval_deterministic: \u2200c st st1 st2,\n    st =[ c ]\u21d2 st1 \u2192\n    st =[ c ]\u21d2 st2 \u2192\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\u2082 breaks it\n\nnote: ifinish can handle find_rwinv so moving find_eqn makes no difference\n-/\ntheorem ceval_deterministic {c : com} {st st\u2081 st\u2082}\n  (h\u2081 : st =[ c ]\u21d2 st\u2081) (h\u2082 : ceval c st st\u2082)\n  : st\u2081 = st\u2082 :=\nbegin\n  induction h\u2081 generalizing st\u2082;\n    inv h\u2082;\n    try { refl <|> find_rwinv };\n    find_eqn;\n    ifinish,\nend\n\n/-\nTheorem ceval_deterministic': \u2200c st st1 st2,\n    st =[ c ]\u21d2 st1 \u2192\n    st =[ c ]\u21d2 st2 \u2192\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\u2081 st\u2082}\n  (h\u2081 : st =[ c ]\u21d2 st\u2081) (h\u2082 : ceval c st st\u2082)\n  : st\u2081 = st\u2082 :=\nbegin\n  induction h\u2081 generalizing st\u2082;\n    inv h\u2082;\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 \u2264 1\n      THEN Y ::= 3\n      ELSE Z ::= 4\n    FI\n  ]\u21d2 (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 \u2264' 1\n      THEN Y ::= 3\n      ELSE Z ::= 4\n    FI\n  ]\u21d2 Z !\u2192 4 ; X !\u2192 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 \u2264 1\n      THEN Y ::= 3\n      ELSE Z ::= 4\n    FI\n  ]\u21d2 (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 \u2264' 1\n      THEN Y ::= 3\n      ELSE Z ::= 4\n    FI\n  ]\u21d2 Z !\u2192 4 ; X !\u2192 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 : \u2203s',\n  st21 =[\n    TEST X \u2264 Y\n      THEN Z ::= Y - X\n      ELSE Y ::= X + Z\n    FI\n  ]\u21d2 s'.\nProof. eauto. Qed.\n-/\n\n/-\nTODO: no finishing tactic handles this\n-/\n\n-- def st\u2081\u2082 := Y !\u2192 2 ; X !\u2192 1\n-- def st\u2082\u2081 := Y !\u2192 1 ; X !\u2192 2\n\n-- example : \u2203s',\n--   st\u2082\u2081 =[\n--     TEST X \u2264' Y\n--       THEN Z ::= Y - X\n--       ELSE Y ::= X + Z\n--     FI\n--   ]\u21d2 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 Smt\n\ntheorem triv': \u2200 p : Prop, p \u2192 p := by\n  smt\n  apply propext\n  apply Iff.intro\n  \u00b7 exact \u03bb _ _ => id\n  \u00b7 exact \u03bb _   => True.intro\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/Triv'.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.47214778554542175}}
{"text": "import data.complex.basic\n\nnamespace cau_seq\n\ntheorem const_inv {\u03b1 \u03b2 : Type*} [discrete_field \u03b2] [discrete_linear_ordered_field \u03b1] {abv : \u03b2 \u2192 \u03b1} \n  [is_absolute_value abv] {x : \u03b2} (hx : x \u2260 0) : \n  const abv (x\u207b\u00b9) = 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 \u211d abs} {x : \u211d} (h : cau_seq.const abs x \u2248 f) : x = lim f :=\nconst_equiv.mp $ setoid.trans h $ equiv_lim f\n\nlemma lim_eq_of_equiv_const {f : cau_seq \u211d abs} {x : \u211d} (h : f \u2248 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 \u211d abs} (h : f \u2248 g) : lim f = lim g := \nlim_eq_of_equiv_const $ setoid.trans h $ equiv_lim g\n\n@[simp] lemma lim_const (x : \u211d) : lim (const abs x) = x := \nlim_eq_of_equiv_const $ setoid.refl _\n\nlemma lim_add (f g : cau_seq \u211d abs) : lim f + lim g = lim \u21d1(f + g) := \neq_lim_of_const_equiv $ show lim_zero (const abs (lim \u21d1f + lim \u21d1g) - (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 \u211d abs) : lim f * lim g = lim \u21d1(f * g) := \neq_lim_of_const_equiv $ show lim_zero (const abs (lim \u21d1f * lim \u21d1g) - f * g),\n  from have h : const abs (lim \u21d1f * lim \u21d1g) - 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 \u211d abs) (x : \u211d) : lim f * x = lim \u21d1(f * const abs x) :=\nby rw [\u2190 lim_mul_lim, lim_const]\n\nlemma lim_neg (f : cau_seq \u211d abs) : lim \u21d1(-f) = -lim f :=\nlim_eq_of_equiv_const (show lim_zero (-f - const abs (-lim \u21d1f)),\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 \u211d abs) : lim f = 0 \u2194 lim_zero f :=\n\u27e8assume 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\u2081 : f = (f - const abs 0) := ext (\u03bb n, by simp [sub_apply, const_apply]),\n  by rw h\u2081 at h; exact lim_eq_of_equiv_const h \u27e9\n\nlemma lim_inv {f : cau_seq \u211d abs} (hf : \u00ac lim_zero f) : lim \u21d1(inv f hf) = (lim f)\u207b\u00b9 :=\nhave hl : lim f \u2260 0 := by rwa \u2190 lim_eq_zero_iff at hf, \nlim_eq_of_equiv_const $ show lim_zero (inv f hf - const abs (lim \u21d1f)\u207b\u00b9),\n  from have h\u2081 : \u2200 (g f : cau_seq \u211d abs) (hf : \u00ac lim_zero f), lim_zero (g - f * inv f hf * g) := \n    \u03bb g f hf, by rw [\u2190 one_mul g, \u2190 mul_assoc, \u2190 sub_mul, mul_one, mul_comm, mul_comm f];\n    exact mul_lim_zero _ (setoid.symm (cau_seq.inv_mul_cancel _)),\n  have h\u2082 : lim_zero ((inv f hf - const abs (lim \u21d1f)\u207b\u00b9) - (const abs (lim f) - f) * \n      (inv f hf * const abs (lim \u21d1f)\u207b\u00b9)) := \n    by rw [sub_mul, \u2190 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 \u21d1f) * (inv f hf * const abs (lim \u21d1f)\u207b\u00b9)\n      - (const abs (lim \u21d1f)\u207b\u00b9 - f * (inv f hf * const abs (lim \u21d1f)\u207b\u00b9))),\n    from sub_lim_zero\n      (by rw [\u2190 mul_assoc, mul_right_comm, const_inv hl]; exact h\u2081 _ _ _)\n      (by rw [\u2190 mul_assoc]; exact h\u2081 _ _ _),\n  (lim_zero_congr h\u2082).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 : \u2115 \u2192 \u2102} (hf : is_cau_seq abs f) (z : \u2102) :\n    cau_seq.const abs z \u2248 \u27e8f, hf\u27e9 \u2192 cau_seq.const _root_.abs z.re \u2248 \u27e8(\u03bb (n : \u2115), (f n).re), \n    complex.is_cau_seq_re \u27e8f,hf\u27e9\u27e9 := begin\n  assume h,assume \u03b5 \u03b50,cases h \u03b5 \u03b50 with i hi,existsi i,assume j ji,\n  replace hi := hi j ji, simp at *, rw [\u2190complex.neg_re,\u2190complex.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 : \u2115 \u2192 \u2102} (hf : is_cau_seq abs f) (z : \u2102) :\n    cau_seq.const abs z \u2248 \u27e8f, hf\u27e9 \u2192 cau_seq.const _root_.abs z.im \u2248 \u27e8(\u03bb (n : \u2115), (f n).im),\n    complex.is_cau_seq_im \u27e8f,hf\u27e9\u27e9 := begin\n  assume h,assume \u03b5 \u03b50,cases h \u03b5 \u03b50 with i hi,existsi i,assume j ji,\n  replace hi := hi j ji, simp at *, rw [\u2190complex.neg_im,\u2190complex.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 \u2102 abs}  {z: \u2102} : \n    cau_seq.const complex.abs z \u2248 f \u2192 z = complex.lim f := begin\n  assume h,\n  unfold complex.lim,cases z with zre zim,simp,\n  split, have := real.equiv_lim \u27e8(\u03bb (n : \u2115), (f.1 n).re), complex.is_cau_seq_re f\u27e9,\n  rw \u2190cau_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 \u27e8(\u03bb (n : \u2115), (f.1 n).im), complex.is_cau_seq_im f\u27e9,\n  rw \u2190cau_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 \u2102 complex.abs} {x : \u2102} (h : f \u2248 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 \u2102 complex.abs} (h : f \u2248 g) : lim f = lim g := \nlim_eq_of_equiv_const $ setoid.trans h $ equiv_lim g\n\n@[simp] lemma lim_const (x : \u2102) : lim (const abs x) = x := \nlim_eq_of_equiv_const $ setoid.refl _\n\nlemma lim_add (f g : cau_seq \u2102 complex.abs) : lim f + lim g = lim \u21d1(f + g) := \neq_lim_of_const_equiv $ show lim_zero (const complex.abs (lim \u21d1f + lim \u21d1g) - (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 \u2102 complex.abs) : lim f * lim g = lim \u21d1(f * g) := \neq_lim_of_const_equiv $ show lim_zero (const complex.abs (lim \u21d1f * lim \u21d1g) - f * g),\n  from have h : const complex.abs (lim \u21d1f * lim \u21d1g) - 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 \u2102 complex.abs) (x : \u2102) : lim f * x = lim \u21d1(f * const complex.abs x) :=\nby rw [\u2190 lim_mul_lim, lim_const]\n\nlemma lim_neg (f : cau_seq \u2102 complex.abs) : lim \u21d1(-f) = -lim f :=\nlim_eq_of_equiv_const (show lim_zero (-f - const complex.abs (-lim \u21d1f)),\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 \u2102 complex.abs) : lim f = 0 \u2194 lim_zero f :=\n\u27e8assume 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\u2081 : f = (f - const complex.abs (0 : \u2102)) := cau_seq.ext (\u03bb n, by simp [sub_apply, const_apply]),\n  by rw h\u2081 at h; exact lim_eq_of_equiv_const h \u27e9\n\nlemma lim_inv {f : cau_seq \u2102 complex.abs} (hf : \u00ac lim_zero f) : lim \u21d1(inv f hf) = (lim f)\u207b\u00b9 :=\nhave hl : lim f \u2260 0 := by rwa \u2190 lim_eq_zero_iff at hf, \nlim_eq_of_equiv_const $ show lim_zero (inv f hf - const abs (lim \u21d1f)\u207b\u00b9),\n  from have h\u2081 : \u2200 (g f : cau_seq \u2102 abs) (hf : \u00ac lim_zero f), lim_zero (g - f * inv f hf * g) := \n    \u03bb g f hf, by rw [\u2190 one_mul g, \u2190 mul_assoc, \u2190 sub_mul, mul_one, mul_comm, mul_comm f];\n    exact mul_lim_zero _ (setoid.symm (cau_seq.inv_mul_cancel _)),\n  have h\u2082 : lim_zero ((inv f hf - const abs (lim \u21d1f)\u207b\u00b9) - (const abs (lim f) - f) * \n      (inv f hf * const abs (lim \u21d1f)\u207b\u00b9)) := \n    by rw [sub_mul, \u2190 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 \u21d1f) * (inv f hf * const abs (lim \u21d1f)\u207b\u00b9)\n      - (const abs (lim \u21d1f)\u207b\u00b9 - f * (inv f hf * const abs (lim \u21d1f)\u207b\u00b9))),\n    from sub_lim_zero\n      (by rw [\u2190 mul_assoc, mul_right_comm, cau_seq.const_inv hl]; exact h\u2081 _ _ _)\n      (by rw [\u2190 mul_assoc]; exact h\u2081 _ _ _),\n  (lim_zero_congr h\u2082).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 \u2228 Q \u2192 Q \u2228 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, Mario Carneiro, Patrick Massot, Yury Kudryashov, R\u00e9my 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 \u03b1] [Preorder \u03b2]\n\n@[simp]\ntheorem preimage_Iic (e : \u03b1 \u2243o \u03b2) (b : \u03b2) : e \u207b\u00b9' Iic b = Iic (e.symm b) := by\n  ext x\n  simp [\u2190 e.le_iff_le]\n#align order_iso.preimage_Iic OrderIso.preimage_Iic\n\n@[simp]\ntheorem preimage_Ici (e : \u03b1 \u2243o \u03b2) (b : \u03b2) : e \u207b\u00b9' Ici b = Ici (e.symm b) := by\n  ext x\n  simp [\u2190 e.le_iff_le]\n#align order_iso.preimage_Ici OrderIso.preimage_Ici\n\n@[simp]\ntheorem preimage_Iio (e : \u03b1 \u2243o \u03b2) (b : \u03b2) : e \u207b\u00b9' Iio b = Iio (e.symm b) := by\n  ext x\n  simp [\u2190 e.lt_iff_lt]\n#align order_iso.preimage_Iio OrderIso.preimage_Iio\n\n@[simp]\ntheorem preimage_Ioi (e : \u03b1 \u2243o \u03b2) (b : \u03b2) : e \u207b\u00b9' Ioi b = Ioi (e.symm b) := by\n  ext x\n  simp [\u2190 e.lt_iff_lt]\n#align order_iso.preimage_Ioi OrderIso.preimage_Ioi\n\n@[simp]\ntheorem preimage_Icc (e : \u03b1 \u2243o \u03b2) (a b : \u03b2) : e \u207b\u00b9' Icc a b = Icc (e.symm a) (e.symm b) := by\n  simp [\u2190 Ici_inter_Iic]\n#align order_iso.preimage_Icc OrderIso.preimage_Icc\n\n@[simp]\ntheorem preimage_Ico (e : \u03b1 \u2243o \u03b2) (a b : \u03b2) : e \u207b\u00b9' Ico a b = Ico (e.symm a) (e.symm b) := by\n  simp [\u2190 Ici_inter_Iio]\n#align order_iso.preimage_Ico OrderIso.preimage_Ico\n\n@[simp]\ntheorem preimage_Ioc (e : \u03b1 \u2243o \u03b2) (a b : \u03b2) : e \u207b\u00b9' Ioc a b = Ioc (e.symm a) (e.symm b) := by\n  simp [\u2190 Ioi_inter_Iic]\n#align order_iso.preimage_Ioc OrderIso.preimage_Ioc\n\n@[simp]\ntheorem preimage_Ioo (e : \u03b1 \u2243o \u03b2) (a b : \u03b2) : e \u207b\u00b9' Ioo a b = Ioo (e.symm a) (e.symm b) := by\n  simp [\u2190 Ioi_inter_Iio]\n#align order_iso.preimage_Ioo OrderIso.preimage_Ioo\n\n@[simp]\ntheorem image_Iic (e : \u03b1 \u2243o \u03b2) (a : \u03b1) : 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 : \u03b1 \u2243o \u03b2) (a : \u03b1) : 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 : \u03b1 \u2243o \u03b2) (a : \u03b1) : 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 : \u03b1 \u2243o \u03b2) (a : \u03b1) : 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 : \u03b1 \u2243o \u03b2) (a b : \u03b1) : 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 : \u03b1 \u2243o \u03b2) (a b : \u03b1) : 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 : \u03b1 \u2243o \u03b2) (a b : \u03b1) : 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 : \u03b1 \u2243o \u03b2) (a b : \u03b1) : 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 (\u22a4 : \u03b1)` and `\u03b1` when `\u03b1` has a top element -/\ndef IicTop [Preorder \u03b1] [OrderTop \u03b1] : Iic (\u22a4 : \u03b1) \u2243o \u03b1 :=\n  { @Equiv.subtypeUnivEquiv \u03b1 (Iic (\u22a4 : \u03b1)) 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 (\u22a5 : \u03b1)` and `\u03b1` when `\u03b1` has a bottom element -/\ndef IciBot [Preorder \u03b1] [OrderBot \u03b1] : Ici (\u22a5 : \u03b1) \u2243o \u03b1 :=\n  { @Equiv.subtypeUnivEquiv \u03b1 (Ici (\u22a5 : \u03b1)) 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, \u2190 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. `\u222a, \u2229, \u2293, \u2294, ...`), 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 `\u03b1`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 {\u03b1 : Type*} : list \u03b1 \u2192 list bool \u2192 list \u03b1\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 \u00d7 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 \u2208 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 \u00d7 expr) \u2192 list expr \u2192 list bool \u2192\n  tactic (list expr \u00d7 list expr \u00d7 list expr \u00d7 list bool)\n| [] l_un l_m      := return ([], [], l_un, l_m)\n| (be::l) l_un l_m := do\n  (ex :: _) \u2190 l_un.mfilter $ \u03bb 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) \u2190 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 \u00d7 pexpr` to a list of pairs `bool \u00d7 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 \u00d7 pexpr)) (sl : list expr) : tactic (list expr \u00d7 list bool) :=\ndo\n  lp_exp : list (bool \u00d7 expr) \u2190 lp.mmap $ \u03bb x, (do e \u2190 to_expr x.2 tt ff, return (x.1, e)),\n  (l1, l2, l3, is_unused) \u2190 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 \u22652-argument function application,\nwith the binary operation `op`, failing if it cannot. -/\nmeta def as_given_op (op : pexpr) : expr \u2192 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) \u2190 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))] `(\u2200 x y : \u2115, 2 = 0)\n--  (\u2115 \u2192 \u2115 \u2192 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  `(\u03bb (e : \u2115), \u2200 (x : \u2115), \u2203 (y : \u2115),\n      2 + x * (y + (e + 5)) + y = x + 2 + e \u2192 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   (\u03bb (e : \u2115), \u2200 (x : \u2115), \u2203 (y : \u2115),\n      x * (5 + y + e) + y + 2   = x + e + 2 \u2192 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 \u00d7 pexpr)) :\n  expr \u2192 tactic (expr \u00d7 list bool)\n| F'@(expr.app F b) := do\n    is_op \u2190 try_core (as_given_op op F'),\n    match is_op with\n    | some op := do\n        (sort_list, is_unused) \u2190 list_binary_operands op F' >>= final_sort lp,\n        sort_all \u2190 sort_list.mmap (\u03bb e, do\n          (e, lu) \u2190 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 \u2190 pure recs | fail!\"internal error: cannot have 0 operands\",\n        let summed := recs_rest.foldl (\u03bb 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)] \u2190 [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] \u2190 [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] \u2190 [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 \u2190 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 \u2190 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] \u2190 [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 \u2190 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 (\u03bb _, 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 \u00d7 pexpr)) (na : option name) :\n  tactic (bool \u00d7 list bool) := do\n(thyp, hyploc) \u2190 match na with\n  | none := do\n      t \u2190 target,\n      return (t, none)\n  | some na := do\n      hl \u2190 get_local na,\n      th \u2190 infer_type hl,\n      return (th, some hl)\n  end,\n(reordered, is_unused) \u2190 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 \u2190 mk_app `eq [thyp, reordered],\nnop \u2190 to_expr op tt ff,\npre \u2190 pp reordered,\n(_, prf) \u2190 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 `\u2190`. -/\nmeta def move_op_arg (prec : nat) : parser (bool \u00d7 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 \u00d7 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 \u2190 locat.get_locals,\ntg \u2190 target,\nlet locas_with_tg := if locat.include_goal then locas ++ [tg] else locas,\nner \u2190 locas_with_tg.mmap (\u03bb e, reorder_hyp op args e.local_pp_name <|> reorder_hyp op args none),\nlet (unch_tgts, unus_vars) := ner.unzip,\nstr_unva \u2190 match\n  (return_unused args (unus_vars.transpose.map list.band)).map (\u03bb e : bool \u00d7 pexpr, e.2) with\n  | []   := pure []\n  | [pe] := do\n    nm \u2190 to_expr pe tt ff >>= \u03bb ex, pp ex.replace_mvars,\n    return [format!\"'{nm}' is an unused variable\"]\n  | pes  := do\n    nms \u2190 pes.mmap (\u03bb e, to_expr e tt ff) >>= \u03bb 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 \u2208 return_unused names unch_tgts\n        then [format!\"Goal did not change\"] else []) ++\n      (if linames \u2260 [] then [format!\"'{linames.reverse}' did not change\"] else [])\n  end,\n[] \u2190 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, \u2190 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 `\u2190` 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 : \u2115} (h : c = d) : c + b + a = b + a + d :=\nbegin\n  move_add [\u2190 a, b],  -- Goal: `a + c + b = a + d + b`  -- both sides changed\n  congr,\n  exact h\nend\n\nexample {a b c d : \u2115} (h : c = d) : c + b * c + a * c = a * d + d + b * d :=\nbegin\n  move_add [_ * c, \u2190 _ * 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 \u2190 f` and `move_add [\u2190 f]` mean the same.\n\nFinally, `move_add` can also target one or more hypotheses.  If `hp\u2081, hp\u2082` are in the\nlocal context, then `move_add [f, \u2190 g] at hp\u2081 hp\u2082` performs the rearranging at `hp\u2081` and `hp\u2082`.\nAs usual, passing `\u22a2` 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 \u2190 _` 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 \u2190 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 : \u2115) : max a b = max b a :=\nby move_oper [max] [\u2190 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] \u2190 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\u00f6lzl, 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\u2093'. -/\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\u2093'. -/\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type _}\n\nopen Set Filter Function\n\nopen Classical Filter\n\n/-- `filter \u03b1` is an atomic type: for every filter there exists an ultrafilter that is less than or\nequal to this filter. -/\ninstance : IsAtomic (Filter \u03b1) :=\n  IsAtomic.of_isChain_bounded fun c hc hne hb =>\n    \u27e8inf\u209b c, (inf\u209b_neBot_of_directed' hne (show IsChain (\u00b7 \u2265 \u00b7) c from hc.symm).DirectedOn hb).Ne,\n      fun x hx => inf\u209b_le hx\u27e9\n\n#print Ultrafilter /-\n/-- An ultrafilter is a minimal (maximal in the set order) proper filter. -/\n@[protect_proj]\nstructure Ultrafilter (\u03b1 : Type _) extends Filter \u03b1 where\n  ne_bot' : NeBot to_filter\n  le_of_le : \u2200 g, Filter.NeBot g \u2192 g \u2264 to_filter \u2192 to_filter \u2264 g\n#align ultrafilter Ultrafilter\n-/\n\nnamespace Ultrafilter\n\nvariable {f g : Ultrafilter \u03b1} {s t : Set \u03b1} {p q : \u03b1 \u2192 Prop}\n\ninstance : CoeTC (Ultrafilter \u03b1) (Filter \u03b1) :=\n  \u27e8Ultrafilter.toFilter\u27e9\n\ninstance : Membership (Set \u03b1) (Ultrafilter \u03b1) :=\n  \u27e8fun s f => s \u2208 (f : Filter \u03b1)\u27e9\n\n/- warning: ultrafilter.unique -> Ultrafilter.unique is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1) {g : Filter.{u1} \u03b1}, (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f)) -> (autoParam\u2093.{0} (Filter.NeBot.{u1} \u03b1 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} \u03b1) g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1) {g : Filter.{u1} \u03b1}, (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) g (Ultrafilter.toFilter.{u1} \u03b1 f)) -> (autoParam.{0} (Filter.NeBot.{u1} \u03b1 g) _auto._@.Mathlib.Order.Filter.Ultrafilter._hyg.261) -> (Eq.{succ u1} (Filter.{u1} \u03b1) g (Ultrafilter.toFilter.{u1} \u03b1 f))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.unique Ultrafilter.unique\u2093'. -/\ntheorem unique (f : Ultrafilter \u03b1) {g : Filter \u03b1} (h : g \u2264 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 \u03b1) : NeBot (f : Filter \u03b1) :=\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 {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1), IsAtom.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1), IsAtom.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.is_atom Ultrafilter.isAtom\u2093'. -/\nprotected theorem isAtom (f : Ultrafilter \u03b1) : IsAtom (f : Filter \u03b1) :=\n  \u27e8f.ne_bot.Ne, fun g hgf => by_contra fun hg => hgf.Ne <| f.unique hgf.le \u27e8hg\u27e9\u27e9\n#align ultrafilter.is_atom Ultrafilter.isAtom\n\n#print Ultrafilter.mem_coe /-\n@[simp, norm_cast]\ntheorem mem_coe : s \u2208 (f : Filter \u03b1) \u2194 s \u2208 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 \u03b1 \u2192 Filter \u03b1)\n  | \u27e8f, h\u2081, h\u2082\u27e9, \u27e8g, h\u2083, h\u2084\u27e9, 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 {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {g : Ultrafilter.{u1} \u03b1}, (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g)) -> (Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {g : Ultrafilter.{u1} \u03b1}, (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) (Ultrafilter.toFilter.{u1} \u03b1 g)) -> (Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.eq_of_le Ultrafilter.eq_of_le\u2093'. -/\ntheorem eq_of_le {f g : Ultrafilter \u03b1} (h : (f : Filter \u03b1) \u2264 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 {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {g : Ultrafilter.{u1} \u03b1}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g)) (Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {g : Ultrafilter.{u1} \u03b1}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) (Ultrafilter.toFilter.{u1} \u03b1 g)) (Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.coe_le_coe Ultrafilter.coe_le_coe\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_le_coe {f g : Ultrafilter \u03b1} : (f : Filter \u03b1) \u2264 g \u2194 f = g :=\n  \u27e8fun h => eq_of_le h, fun h => h \u25b8 le_rfl\u27e9\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 \u03b1) = g \u2194 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 \u2983f g : Ultrafilter \u03b1\u2984 (h : \u2200 s, s \u2208 f \u2194 s \u2208 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 {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1) {g : Filter.{u1} \u03b1}, (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) g)) -> (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1) {g : Filter.{u1} \u03b1}, (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) (Ultrafilter.toFilter.{u1} \u03b1 f) g)) -> (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.le_of_inf_ne_bot Ultrafilter.le_of_inf_neBot\u2093'. -/\ntheorem le_of_inf_neBot (f : Ultrafilter \u03b1) {g : Filter \u03b1} (hg : NeBot (\u2191f \u2293 g)) : \u2191f \u2264 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 {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1) {g : Filter.{u1} \u03b1}, (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) g ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f))) -> (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1) {g : Filter.{u1} \u03b1}, (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) g (Ultrafilter.toFilter.{u1} \u03b1 f))) -> (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.le_of_inf_ne_bot' Ultrafilter.le_of_inf_neBot'\u2093'. -/\ntheorem le_of_inf_neBot' (f : Ultrafilter \u03b1) {g : Filter \u03b1} (hg : NeBot (g \u2293 f)) : \u2191f \u2264 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 {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {g : Filter.{u1} \u03b1}, Iff (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) g)) (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {g : Filter.{u1} \u03b1}, Iff (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) (Ultrafilter.toFilter.{u1} \u03b1 f) g)) (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) g)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.inf_ne_bot_iff Ultrafilter.inf_neBot_iff\u2093'. -/\ntheorem inf_neBot_iff {f : Ultrafilter \u03b1} {g : Filter \u03b1} : NeBot (\u2191f \u2293 g) \u2194 \u2191f \u2264 g :=\n  \u27e8le_of_inf_neBot f, fun h => (inf_of_le_left h).symm \u25b8 f.ne_bot\u27e9\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 {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {g : Filter.{u1} \u03b1}, Iff (Disjoint.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) g) (Not (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {g : Filter.{u1} \u03b1}, Iff (Disjoint.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) g) (Not (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) g))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.disjoint_iff_not_le Ultrafilter.disjoint_iff_not_le\u2093'. -/\ntheorem disjoint_iff_not_le {f : Ultrafilter \u03b1} {g : Filter \u03b1} : Disjoint (\u2191f) g \u2194 \u00ac\u2191f \u2264 g := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} \u03b1}, Iff (Not (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) f)) (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} \u03b1}, Iff (Not (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) f)) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.compl_not_mem_iff Ultrafilter.compl_not_mem_iff\u2093'. -/\n@[simp]\ntheorem compl_not_mem_iff : s\u1d9c \u2209 f \u2194 s \u2208 f :=\n  \u27e8fun hsc =>\n    le_principal_iff.1 <| f.le_of_inf_neBot \u27e8fun h => hsc <| mem_of_eq_bot <| by rwa [compl_compl]\u27e9,\n    compl_not_mem\u27e9\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 : (\u2203\u1da0 x in f, p x) \u2194 \u2200\u1da0 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 \u2194 _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 {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) f) (Not (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) f) (Not (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s f))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.compl_mem_iff_not_mem Ultrafilter.compl_mem_iff_not_mem\u2093'. -/\ntheorem compl_mem_iff_not_mem : s\u1d9c \u2208 f \u2194 s \u2209 f := by rw [\u2190 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 {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1} (f : Ultrafilter.{u1} \u03b1), Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (SDiff.sdiff.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s t) f) (And (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s f) (Not (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) t f)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1} (f : Ultrafilter.{u1} \u03b1), Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (SDiff.sdiff.{u1} (Set.{u1} \u03b1) (Set.instSDiffSet.{u1} \u03b1) s t) f) (And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s f) (Not (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) t f)))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.diff_mem_iff Ultrafilter.diff_mem_iff\u2093'. -/\ntheorem diff_mem_iff (f : Ultrafilter \u03b1) : s \\ t \u2208 f \u2194 s \u2208 f \u2227 t \u2209 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 {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1), (forall (s : Set.{u1} \u03b1), Iff (Not (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) f)) (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s f)) -> (Ultrafilter.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1), (forall (s : Set.{u1} \u03b1), Iff (Not (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) f)) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s f)) -> (Ultrafilter.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.of_compl_not_mem_iff Ultrafilter.ofComplNotMemIff\u2093'. -/\n/-- If `s\u1d9c \u2209 f \u2194 s \u2208 f`, then `f` is an ultrafilter. The other implication is given by\n`ultrafilter.compl_not_mem_iff`.  -/\ndef ofComplNotMemIff (f : Filter \u03b1) (h : \u2200 s, s\u1d9c \u2209 f \u2194 s \u2208 f) : Ultrafilter \u03b1\n    where\n  toFilter := f\n  ne_bot' := \u27e8fun hf => by simpa [hf] using h\u27e9\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 {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1), (IsAtom.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) f) -> (Ultrafilter.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1), (IsAtom.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) f) -> (Ultrafilter.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.of_atom Ultrafilter.ofAtom\u2093'. -/\n/-- If `f : filter \u03b1` is an atom, then it is an ultrafilter. -/\ndef ofAtom (f : Filter \u03b1) (hf : IsAtom f) : Ultrafilter \u03b1\n    where\n  toFilter := f\n  ne_bot' := \u27e8hf.1\u27e9\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 \u2208 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 \u2208 f) : s \u2260 \u2205 :=\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 : \u2205 \u2209 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 {\u03b1 : Type.{u1}} {u : Ultrafilter.{u1} \u03b1} {f : Filter.{u1} \u03b1} {g : Filter.{u1} \u03b1}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) u) (Sup.sup.{u1} (Filter.{u1} \u03b1) (SemilatticeSup.toHasSup.{u1} (Filter.{u1} \u03b1) (Lattice.toSemilatticeSup.{u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toLattice.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))))) f g)) (Or (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) u) f) (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) u) g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {u : Ultrafilter.{u1} \u03b1} {f : Filter.{u1} \u03b1} {g : Filter.{u1} \u03b1}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 u) (Sup.sup.{u1} (Filter.{u1} \u03b1) (SemilatticeSup.toSup.{u1} (Filter.{u1} \u03b1) (Lattice.toSemilatticeSup.{u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toLattice.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))))) f g)) (Or (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 u) f) (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 u) g))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.le_sup_iff Ultrafilter.le_sup_iff\u2093'. -/\n@[simp]\ntheorem le_sup_iff {u : Ultrafilter \u03b1} {f g : Filter \u03b1} : \u2191u \u2264 f \u2294 g \u2194 \u2191u \u2264 f \u2228 \u2191u \u2264 g :=\n  not_iff_not.1 <| by simp only [\u2190 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 {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (Union.union.{u1} (Set.{u1} \u03b1) (Set.hasUnion.{u1} \u03b1) s t) f) (Or (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s f) (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) t f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} \u03b1} {t : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (Union.union.{u1} (Set.{u1} \u03b1) (Set.instUnionSet.{u1} \u03b1) s t) f) (Or (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s f) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) t f))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.union_mem_iff Ultrafilter.union_mem_iff\u2093'. -/\n@[simp]\ntheorem union_mem_iff : s \u222a t \u2208 f \u2194 s \u2208 f \u2228 t \u2208 f := by\n  simp only [\u2190 mem_coe, \u2190 le_principal_iff, \u2190 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 {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1) (s : Set.{u1} \u03b1), Or (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s f) (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1) (s : Set.{u1} \u03b1), Or (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s f) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.mem_or_compl_mem Ultrafilter.mem_or_compl_mem\u2093'. -/\ntheorem mem_or_compl_mem (f : Ultrafilter \u03b1) (s : Set \u03b1) : s \u2208 f \u2228 s\u1d9c \u2208 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 \u03b1) (p : \u03b1 \u2192 Prop) : (\u2200\u1da0 x in f, p x) \u2228 \u2200\u1da0 x in f, \u00acp 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 : (\u2200\u1da0 x in f, p x \u2228 q x) \u2194 (\u2200\u1da0 x in f, p x) \u2228 \u2200\u1da0 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 : (\u2200\u1da0 x in f, \u00acp x) \u2194 \u00ac\u2200\u1da0 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 : (\u2200\u1da0 x in f, p x \u2192 q x) \u2194 (\u2200\u1da0 x in f, p x) \u2192 \u2200\u1da0 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\u209b_mem_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} (Set.{u1} \u03b1)}, (Set.Finite.{u1} (Set.{u1} \u03b1) s) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (Set.union\u209b.{u1} \u03b1 s) f) (Exists.{succ u1} (Set.{u1} \u03b1) (fun (t : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) t s) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) t s) => Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) t f))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} (Set.{u1} \u03b1)}, (Set.Finite.{u1} (Set.{u1} \u03b1) s) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (Set.union\u209b.{u1} \u03b1 s) f) (Exists.{succ u1} (Set.{u1} \u03b1) (fun (t : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) t s) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) t f))))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.finite_sUnion_mem_iff Ultrafilter.finite_union\u209b_mem_iff\u2093'. -/\ntheorem finite_union\u209b_mem_iff {s : Set (Set \u03b1)} (hs : s.Finite) : \u22c3\u2080 s \u2208 f \u2194 \u2203 t \u2208 s, t \u2208 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\u209b_mem_iff\n\n/- warning: ultrafilter.finite_bUnion_mem_iff -> Ultrafilter.finite_bunion\u1d62_mem_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : Ultrafilter.{u1} \u03b1} {is : Set.{u2} \u03b2} {s : \u03b2 -> (Set.{u1} \u03b1)}, (Set.Finite.{u2} \u03b2 is) -> (Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b2 (fun (i : \u03b2) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) i is) (fun (H : Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) i is) => s i))) f) (Exists.{succ u2} \u03b2 (fun (i : \u03b2) => Exists.{0} (Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) i is) (fun (H : Membership.Mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.hasMem.{u2} \u03b2) i is) => Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (s i) f))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : Ultrafilter.{u1} \u03b1} {is : Set.{u2} \u03b2} {s : \u03b2 -> (Set.{u1} \u03b1)}, (Set.Finite.{u2} \u03b2 is) -> (Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b2 (fun (i : \u03b2) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.instMembershipSet.{u2} \u03b2) i is) (fun (H : Membership.mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.instMembershipSet.{u2} \u03b2) i is) => s i))) f) (Exists.{succ u2} \u03b2 (fun (i : \u03b2) => And (Membership.mem.{u2, u2} \u03b2 (Set.{u2} \u03b2) (Set.instMembershipSet.{u2} \u03b2) i is) (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (s i) f))))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.finite_bUnion_mem_iff Ultrafilter.finite_bunion\u1d62_mem_iff\u2093'. -/\ntheorem finite_bunion\u1d62_mem_iff {is : Set \u03b2} {s : \u03b2 \u2192 Set \u03b1} (his : is.Finite) :\n    (\u22c3 i \u2208 is, s i) \u2208 f \u2194 \u2203 i \u2208 is, s i \u2208 f := by\n  simp only [\u2190 sUnion_image, finite_sUnion_mem_iff (his.image s), bex_image_iff]\n#align ultrafilter.finite_bUnion_mem_iff Ultrafilter.finite_bunion\u1d62_mem_iff\n\n#print Ultrafilter.map /-\n/-- Pushforward for ultrafilters. -/\ndef map (m : \u03b1 \u2192 \u03b2) (f : Ultrafilter \u03b1) : Ultrafilter \u03b2 :=\n  ofComplNotMemIff (map m f) fun s => @compl_not_mem_iff _ f (m \u207b\u00b9' s)\n#align ultrafilter.map Ultrafilter.map\n-/\n\n#print Ultrafilter.coe_map /-\n@[simp, norm_cast]\ntheorem coe_map (m : \u03b1 \u2192 \u03b2) (f : Ultrafilter \u03b1) : (map m f : Filter \u03b2) = Filter.map m \u2191f :=\n  rfl\n#align ultrafilter.coe_map Ultrafilter.coe_map\n-/\n\n#print Ultrafilter.mem_map /-\n@[simp]\ntheorem mem_map {m : \u03b1 \u2192 \u03b2} {f : Ultrafilter \u03b1} {s : Set \u03b2} : s \u2208 map m f \u2194 m \u207b\u00b9' s \u2208 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 \u03b1) : 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 \u03b1) : (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : Ultrafilter.{u1} \u03b1) (m : \u03b1 -> \u03b2) (n : \u03b2 -> \u03b3), Eq.{succ u3} (Ultrafilter.{u3} \u03b3) (Ultrafilter.map.{u2, u3} \u03b2 \u03b3 n (Ultrafilter.map.{u1, u2} \u03b1 \u03b2 m f)) (Ultrafilter.map.{u1, u3} \u03b1 \u03b3 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u1}} (f : Ultrafilter.{u2} \u03b1) (m : \u03b1 -> \u03b2) (n : \u03b2 -> \u03b3), Eq.{succ u1} (Ultrafilter.{u1} \u03b3) (Ultrafilter.map.{u3, u1} \u03b2 \u03b3 n (Ultrafilter.map.{u2, u3} \u03b1 \u03b2 m f)) (Ultrafilter.map.{u2, u1} \u03b1 \u03b3 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m) f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.map_map Ultrafilter.map_map\u2093'. -/\n@[simp]\ntheorem map_map (f : Ultrafilter \u03b1) (m : \u03b1 \u2192 \u03b2) (n : \u03b2 \u2192 \u03b3) : (f.map m).map n = f.map (n \u2218 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 : \u03b1 \u2192 \u03b2} (u : Ultrafilter \u03b2) (inj : Injective m) (large : Set.range m \u2208 u) :\n    Ultrafilter \u03b1 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 [\u2190 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 : \u03b1 \u2192 \u03b2} (u : Ultrafilter \u03b2) (inj : Injective m) (large : Set.range m \u2208 u)\n    {s : Set \u03b1} : s \u2208 u.comap inj large \u2194 m '' s \u2208 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 : \u03b1 \u2192 \u03b2} (u : Ultrafilter \u03b2) (inj : Injective m) (large : Set.range m \u2208 u) :\n    (u.comap inj large : Filter \u03b1) = 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 \u03b1) (h\u2080 : Injective (id : \u03b1 \u2192 \u03b1) := injective_id)\n    (h\u2081 : range id \u2208 f :=\n      (by\n        rw [range_id]\n        exact univ_mem)) :\n    f.comap h\u2080 h\u2081 = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : Ultrafilter.{u3} \u03b3) {m : \u03b1 -> \u03b2} {n : \u03b2 -> \u03b3} (inj\u2080 : Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 n) (large\u2080 : Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) (Set.range.{u3, succ u2} \u03b3 \u03b2 n) f) (inj\u2081 : Function.Injective.{succ u1, succ u2} \u03b1 \u03b2 m) (large\u2081 : Membership.Mem.{u2, u2} (Set.{u2} \u03b2) (Ultrafilter.{u2} \u03b2) (Ultrafilter.hasMem.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 m) (Ultrafilter.comap.{u2, u3} \u03b2 \u03b3 n f inj\u2080 large\u2080)) (inj\u2082 : optParam.{0} (Function.Injective.{succ u1, succ u3} \u03b1 \u03b3 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m)) (Function.Injective.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m inj\u2080 inj\u2081)) (large\u2082 : optParam.{0} (Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) (Set.range.{u3, succ u1} \u03b3 \u03b1 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m)) f) (Eq.mpr.{0} (Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) (Set.range.{u3, succ u1} \u03b3 \u03b1 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m)) f) (Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) (Set.image.{u2, u3} \u03b2 \u03b3 n (Set.range.{u2, succ u1} \u03b2 \u03b1 m)) f) (id_tag Tactic.IdTag.rw (Eq.{1} Prop (Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) (Set.range.{u3, succ u1} \u03b3 \u03b1 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m)) f) (Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) (Set.image.{u2, u3} \u03b2 \u03b3 n (Set.range.{u2, succ u1} \u03b2 \u03b1 m)) f)) (Eq.ndrec.{0, succ u3} (Set.{u3} \u03b3) (Set.range.{u3, succ u1} \u03b3 \u03b1 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m)) (fun (_a : Set.{u3} \u03b3) => Eq.{1} Prop (Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) (Set.range.{u3, succ u1} \u03b3 \u03b1 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m)) f) (Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) _a f)) (rfl.{1} Prop (Membership.Mem.{u3, u3} (Set.{u3} \u03b3) (Ultrafilter.{u3} \u03b3) (Ultrafilter.hasMem.{u3} \u03b3) (Set.range.{u3, succ u1} \u03b3 \u03b1 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m)) f)) (Set.image.{u2, u3} \u03b2 \u03b3 n (Set.range.{u2, succ u1} \u03b2 \u03b1 m)) (Set.range_comp.{u2, u3, succ u1} \u03b2 \u03b3 \u03b1 n m))) (Filter.image_mem_of_mem_comap.{u3, u2} \u03b3 \u03b2 ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (Ultrafilter.{u3} \u03b3) (Filter.{u3} \u03b3) (HasLiftT.mk.{succ u3, succ u3} (Ultrafilter.{u3} \u03b3) (Filter.{u3} \u03b3) (CoeTC\u2093.coe.{succ u3, succ u3} (Ultrafilter.{u3} \u03b3) (Filter.{u3} \u03b3) (Ultrafilter.Filter.hasCoeT.{u3} \u03b3))) f) n large\u2080 (Set.range.{u2, succ u1} \u03b2 \u03b1 m) large\u2081))), Eq.{succ u1} (Ultrafilter.{u1} \u03b1) (Ultrafilter.comap.{u1, u2} \u03b1 \u03b2 m (Ultrafilter.comap.{u2, u3} \u03b2 \u03b3 n f inj\u2080 large\u2080) inj\u2081 large\u2081) (Ultrafilter.comap.{u1, u3} \u03b1 \u03b3 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 n m) f inj\u2082 large\u2082)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u1}} (f : Ultrafilter.{u1} \u03b3) {m : \u03b1 -> \u03b2} {n : \u03b2 -> \u03b3} (inj\u2080 : Function.Injective.{succ u3, succ u1} \u03b2 \u03b3 n) (large\u2080 : Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) (Set.range.{u1, succ u3} \u03b3 \u03b2 n) f) (inj\u2081 : Function.Injective.{succ u2, succ u3} \u03b1 \u03b2 m) (large\u2081 : Membership.mem.{u3, u3} (Set.{u3} \u03b2) (Ultrafilter.{u3} \u03b2) (Ultrafilter.instMembershipSetUltrafilter.{u3} \u03b2) (Set.range.{u3, succ u2} \u03b2 \u03b1 m) (Ultrafilter.comap.{u3, u1} \u03b2 \u03b3 n f inj\u2080 large\u2080)) (inj\u2082 : optParam.{0} (Function.Injective.{succ u2, succ u1} \u03b1 \u03b3 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m)) (Function.Injective.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m inj\u2080 inj\u2081)) (large\u2082 : optParam.{0} (Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) (Set.range.{u1, succ u2} \u03b3 \u03b1 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m)) f) (Eq.mpr.{0} (Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) (Set.range.{u1, succ u2} \u03b3 \u03b1 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m)) f) (Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) (Set.image.{u3, u1} \u03b2 \u03b3 n (Set.range.{u3, succ u2} \u03b2 \u03b1 m)) f) (id.{0} (Eq.{1} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) (Set.range.{u1, succ u2} \u03b3 \u03b1 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m)) f) (Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) (Set.image.{u3, u1} \u03b2 \u03b3 n (Set.range.{u3, succ u2} \u03b2 \u03b1 m)) f)) (Eq.ndrec.{0, succ u1} (Set.{u1} \u03b3) (Set.range.{u1, succ u2} \u03b3 \u03b1 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m)) (fun (_a : Set.{u1} \u03b3) => Eq.{1} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) (Set.range.{u1, succ u2} \u03b3 \u03b1 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m)) f) (Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) _a f)) (Eq.refl.{1} Prop (Membership.mem.{u1, u1} (Set.{u1} \u03b3) (Ultrafilter.{u1} \u03b3) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b3) (Set.range.{u1, succ u2} \u03b3 \u03b1 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m)) f)) (Set.image.{u3, u1} \u03b2 \u03b3 n (Set.range.{u3, succ u2} \u03b2 \u03b1 m)) (Set.range_comp.{u3, succ u2, u1} \u03b2 \u03b3 \u03b1 n m))) (Filter.image_mem_of_mem_comap.{u1, u3} \u03b3 \u03b2 (Ultrafilter.toFilter.{u1} \u03b3 f) n large\u2080 (Set.range.{u3, succ u2} \u03b2 \u03b1 m) large\u2081))), Eq.{succ u2} (Ultrafilter.{u2} \u03b1) (Ultrafilter.comap.{u2, u3} \u03b1 \u03b2 m (Ultrafilter.comap.{u3, u1} \u03b2 \u03b3 n f inj\u2080 large\u2080) inj\u2081 large\u2081) (Ultrafilter.comap.{u2, u1} \u03b1 \u03b3 (Function.comp.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 n m) f inj\u2082 large\u2082)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.comap_comap Ultrafilter.comap_comap\u2093'. -/\n@[simp]\ntheorem comap_comap (f : Ultrafilter \u03b3) {m : \u03b1 \u2192 \u03b2} {n : \u03b2 \u2192 \u03b3} (inj\u2080 : Injective n)\n    (large\u2080 : range n \u2208 f) (inj\u2081 : Injective m) (large\u2081 : range m \u2208 f.comap inj\u2080 large\u2080)\n    (inj\u2082 : Injective (n \u2218 m) := inj\u2080.comp inj\u2081)\n    (large\u2082 : range (n \u2218 m) \u2208 f :=\n      (by\n        rw [range_comp]\n        exact image_mem_of_mem_comap large\u2080 large\u2081)) :\n    (f.comap inj\u2080 large\u2080).comap inj\u2081 large\u2081 = f.comap inj\u2082 large\u2082 :=\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  \u27e8fun \u03b1 a => ofComplNotMemIff (pure a) fun s => by simp\u27e9\n\n/- warning: ultrafilter.mem_pure -> Ultrafilter.mem_pure is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} \u03b1 a)) (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} \u03b1 a)) (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) a s)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.mem_pure Ultrafilter.mem_pure\u2093'. -/\n@[simp]\ntheorem mem_pure {a : \u03b1} {s : Set \u03b1} : s \u2208 (pure a : Ultrafilter \u03b1) \u2194 a \u2208 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 {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} \u03b1 a)) (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (Ultrafilter.toFilter.{u1} \u03b1 (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} \u03b1 a)) (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.coe_pure Ultrafilter.coe_pure\u2093'. -/\n@[simp]\ntheorem coe_pure (a : \u03b1) : \u2191(pure a : Ultrafilter \u03b1) = (pure a : Filter \u03b1) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (m : \u03b1 -> \u03b2) (a : \u03b1), Eq.{succ u2} (Ultrafilter.{u2} \u03b2) (Ultrafilter.map.{u1, u2} \u03b1 \u03b2 m (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} \u03b1 a)) (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.hasPure.{u2} \u03b2 (m a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (m : \u03b1 -> \u03b2) (a : \u03b1), Eq.{succ u2} (Ultrafilter.{u2} \u03b2) (Ultrafilter.map.{u1, u2} \u03b1 \u03b2 m (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} \u03b1 a)) (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.instPureUltrafilter.{u2} \u03b2 (m a))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.map_pure Ultrafilter.map_pure\u2093'. -/\n@[simp]\ntheorem map_pure (m : \u03b1 \u2192 \u03b2) (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {m : \u03b1 -> \u03b2} (a : \u03b1) (inj : Function.Injective.{succ u1, succ u2} \u03b1 \u03b2 m) (large : Membership.Mem.{u2, u2} (Set.{u2} \u03b2) (Ultrafilter.{u2} \u03b2) (Ultrafilter.hasMem.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 m) (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.hasPure.{u2} \u03b2 (m a))), Eq.{succ u1} (Ultrafilter.{u1} \u03b1) (Ultrafilter.comap.{u1, u2} \u03b1 \u03b2 m (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.hasPure.{u2} \u03b2 (m a)) inj large) (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {m : \u03b1 -> \u03b2} (a : \u03b1) (inj : Function.Injective.{succ u1, succ u2} \u03b1 \u03b2 m) (large : Membership.mem.{u2, u2} (Set.{u2} \u03b2) (Ultrafilter.{u2} \u03b2) (Ultrafilter.instMembershipSetUltrafilter.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 m) (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.instPureUltrafilter.{u2} \u03b2 (m a))), Eq.{succ u1} (Ultrafilter.{u1} \u03b1) (Ultrafilter.comap.{u1, u2} \u03b1 \u03b2 m (Pure.pure.{u2, u2} Ultrafilter.{u2} Ultrafilter.instPureUltrafilter.{u2} \u03b2 (m a)) inj large) (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.comap_pure Ultrafilter.comap_pure\u2093'. -/\n@[simp]\ntheorem comap_pure {m : \u03b1 \u2192 \u03b2} (a : \u03b1) (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, \u2190 principal_singleton, \u2190 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 {\u03b1 : Type.{u1}}, Function.Injective.{succ u1, succ u1} \u03b1 (Ultrafilter.{u1} \u03b1) (Pure.pure.{u1, u1} (fun {\u03b1 : Type.{u1}} => Ultrafilter.{u1} \u03b1) Ultrafilter.hasPure.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}}, Function.Injective.{succ u1, succ u1} \u03b1 (Ultrafilter.{u1} \u03b1) (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.pure_injective Ultrafilter.pure_injective\u2093'. -/\ntheorem pure_injective : Injective (pure : \u03b1 \u2192 Ultrafilter \u03b1) := fun a b h =>\n  Filter.pure_injective (congr_arg Ultrafilter.toFilter h : _)\n#align ultrafilter.pure_injective Ultrafilter.pure_injective\n\ninstance [Inhabited \u03b1] : Inhabited (Ultrafilter \u03b1) :=\n  \u27e8pure default\u27e9\n\ninstance [Nonempty \u03b1] : Nonempty (Ultrafilter \u03b1) :=\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 {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} \u03b1}, (Set.Finite.{u1} \u03b1 s) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s f) -> (Exists.{succ u1} \u03b1 (fun (x : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) => Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} \u03b1 x))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Ultrafilter.{u1} \u03b1} {s : Set.{u1} \u03b1}, (Set.Finite.{u1} \u03b1 s) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s f) -> (Exists.{succ u1} \u03b1 (fun (x : \u03b1) => And (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) (Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} \u03b1 x))))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.eq_pure_of_finite_mem Ultrafilter.eq_pure_of_finite_mem\u2093'. -/\ntheorem eq_pure_of_finite_mem (h : s.Finite) (h' : s \u2208 f) : \u2203 x \u2208 s, f = pure x :=\n  by\n  rw [\u2190 bUnion_of_singleton s] at h'\n  rcases(Ultrafilter.finite_bunion\u1d62_mem_iff h).mp h' with \u27e8a, has, haf\u27e9\n  exact \u27e8a, has, eq_of_le (Filter.le_pure_iff.2 haf)\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Finite.{succ u1} \u03b1] (f : Ultrafilter.{u1} \u03b1), Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} \u03b1 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Finite.{succ u1} \u03b1] (f : Ultrafilter.{u1} \u03b1), Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} \u03b1 a))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.eq_pure_of_finite Ultrafilter.eq_pure_of_finite\u2093'. -/\ntheorem eq_pure_of_finite [Finite \u03b1] (f : Ultrafilter \u03b1) : \u2203 a, f = pure a :=\n  (eq_pure_of_finite_mem finite_univ univ_mem).imp fun a \u27e8_, ha\u27e9 => 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 {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1), Or (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) (Filter.cofinite.{u1} \u03b1)) (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.hasPure.{u1} \u03b1 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Ultrafilter.{u1} \u03b1), Or (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) (Filter.cofinite.{u1} \u03b1)) (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Eq.{succ u1} (Ultrafilter.{u1} \u03b1) f (Pure.pure.{u1, u1} Ultrafilter.{u1} Ultrafilter.instPureUltrafilter.{u1} \u03b1 a)))\nCase conversion may be inaccurate. Consider using '#align ultrafilter.le_cofinite_or_eq_pure Ultrafilter.le_cofinite_or_eq_pure\u2093'. -/\ntheorem le_cofinite_or_eq_pure (f : Ultrafilter \u03b1) : (f : Filter \u03b1) \u2264 cofinite \u2228 \u2203 a, f = pure a :=\n  or_iff_not_imp_left.2 fun h =>\n    let \u27e8s, hs, hfin\u27e9 := Filter.disjoint_cofinite_right.1 (disjoint_iff_not_le.2 h)\n    let \u27e8a, has, hf\u27e9 := eq_pure_of_finite_mem hfin hs\n    \u27e8a, hf\u27e9\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 \u03b1) (m : \u03b1 \u2192 Ultrafilter \u03b2) : Ultrafilter \u03b2 :=\n  ofComplNotMemIff (bind \u2191f fun x => \u2191(m x)) fun s => by\n    simp only [mem_bind', mem_coe, \u2190 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  \u27e8@Ultrafilter.bind\u27e9\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 \u03b1 f := coe_injective (id_map f.1)\n  pure_bind \u03b1 \u03b2 a f := coe_injective (pure_bind a (coe \u2218 f))\n  bind_assoc \u03b1 \u03b2 \u03b3 f m\u2081 m\u2082 := coe_injective (filter_eq rfl)\n  bind_pure_comp_eq_map \u03b1 \u03b2 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 {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1) [h : Filter.NeBot.{u1} \u03b1 f], Exists.{succ u1} (Ultrafilter.{u1} \u03b1) (fun (u : Ultrafilter.{u1} \u03b1) => LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) u) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1) [h : Filter.NeBot.{u1} \u03b1 f], Exists.{succ u1} (Ultrafilter.{u1} \u03b1) (fun (u : Ultrafilter.{u1} \u03b1) => LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 u) f)\nCase conversion may be inaccurate. Consider using '#align ultrafilter.exists_le Ultrafilter.exists_le\u2093'. -/\n/-- The ultrafilter lemma: Any proper filter is contained in an ultrafilter. -/\ntheorem exists_le (f : Filter \u03b1) [h : NeBot f] : \u2203 u : Ultrafilter \u03b1, \u2191u \u2264 f :=\n  let \u27e8u, hu, huf\u27e9 := (eq_bot_or_exists_atom_le f).resolve_left h.Ne\n  \u27e8ofAtom u hu, huf\u27e9\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 {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1) [h : Filter.NeBot.{u1} \u03b1 f], Exists.{succ u1} (Ultrafilter.{u1} \u03b1) (fun (u : Ultrafilter.{u1} \u03b1) => LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) u) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1) [h : Filter.NeBot.{u1} \u03b1 f], Exists.{succ u1} (Ultrafilter.{u1} \u03b1) (fun (u : Ultrafilter.{u1} \u03b1) => LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 u) f)\nCase conversion may be inaccurate. Consider using '#align filter.exists_ultrafilter_le Filter.exists_ultrafilter_le\u2093'. -/\nalias exists_le \u2190 _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 \u03b1) [NeBot f] : Ultrafilter \u03b1 :=\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 {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1) [_inst_1 : Filter.NeBot.{u1} \u03b1 f], LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) (Ultrafilter.of.{u1} \u03b1 f _inst_1)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1) [_inst_1 : Filter.NeBot.{u1} \u03b1 f], LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 (Ultrafilter.of.{u1} \u03b1 f _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align ultrafilter.of_le Ultrafilter.of_le\u2093'. -/\ntheorem of_le (f : Filter \u03b1) [NeBot f] : \u2191(of f) \u2264 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 \u03b1) : of \u2191f = 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 \u03b1))\n    (cond : \u2200 T : Finset (Set \u03b1), (\u2191T : Set (Set \u03b1)) \u2286 S \u2192 (\u22c2\u2080 (\u2191T : Set (Set \u03b1))).Nonempty) :\n    \u2203 F : Ultrafilter \u03b1, S \u2286 F.sets :=\n  haveI : ne_bot (generate S) :=\n    generate_ne_bot_iff.2 fun t hts ht =>\n      ht.coe_toFinset \u25b8 cond ht.toFinset (ht.coe_to_finset.symm \u25b8 hts)\n  \u27e8of (generate S), fun t ht => (of_le <| generate S) <| generate_sets.basic ht\u27e9\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 \u03b1} {s : Set \u03b1} {a : \u03b1}\n\nopen Ultrafilter\n\n/- warning: filter.is_atom_pure -> Filter.isAtom_pure is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {a : \u03b1}, IsAtom.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {a : \u03b1}, IsAtom.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1)) (BoundedOrder.toOrderBot.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (CompleteLattice.toBoundedOrder.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align filter.is_atom_pure Filter.isAtom_pure\u2093'. -/\ntheorem isAtom_pure : IsAtom (pure a : Filter \u03b1) :=\n  (pure a : Ultrafilter \u03b1).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 {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1} {a : \u03b1}, (Filter.NeBot.{u1} \u03b1 f) -> (Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)) (Eq.{succ u1} (Filter.{u1} \u03b1) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1} {a : \u03b1}, (Filter.NeBot.{u1} \u03b1 f) -> (Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)) (Eq.{succ u1} (Filter.{u1} \u03b1) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)))\nCase conversion may be inaccurate. Consider using '#align filter.ne_bot.le_pure_iff Filter.NeBot.le_pure_iff\u2093'. -/\nprotected theorem NeBot.le_pure_iff (hf : f.ne_bot) : f \u2264 pure a \u2194 f = pure a :=\n  \u27e8Ultrafilter.unique (pure a), le_of_eq\u27e9\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 {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1} {a : \u03b1}, Iff (LT.lt.{u1} (Filter.{u1} \u03b1) (Preorder.toLT.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)) (Eq.{succ u1} (Filter.{u1} \u03b1) f (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1} {a : \u03b1}, Iff (LT.lt.{u1} (Filter.{u1} \u03b1) (Preorder.toLT.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)) (Eq.{succ u1} (Filter.{u1} \u03b1) f (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toBot.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))))\nCase conversion may be inaccurate. Consider using '#align filter.lt_pure_iff Filter.lt_pure_iff\u2093'. -/\n@[simp]\ntheorem lt_pure_iff : f < pure a \u2194 f = \u22a5 :=\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 {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1} {a : \u03b1}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)) (Or (Eq.{succ u1} (Filter.{u1} \u03b1) f (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1)))) (Eq.{succ u1} (Filter.{u1} \u03b1) f (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1} {a : \u03b1}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)) (Or (Eq.{succ u1} (Filter.{u1} \u03b1) f (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toBot.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1)))) (Eq.{succ u1} (Filter.{u1} \u03b1) f (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)))\nCase conversion may be inaccurate. Consider using '#align filter.le_pure_iff' Filter.le_pure_iff'\u2093'. -/\ntheorem le_pure_iff' : f \u2264 pure a \u2194 f = \u22a5 \u2228 f = pure a :=\n  isAtom_pure.le_iff\u2093\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 {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Set.{u1} (Filter.{u1} \u03b1)) (Set.Iic.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1)) (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)) (Insert.insert.{u1, u1} (Filter.{u1} \u03b1) (Set.{u1} (Filter.{u1} \u03b1)) (Set.hasInsert.{u1} (Filter.{u1} \u03b1)) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (Singleton.singleton.{u1, u1} (Filter.{u1} \u03b1) (Set.{u1} (Filter.{u1} \u03b1)) (Set.hasSingleton.{u1} (Filter.{u1} \u03b1)) (Pure.pure.{u1, u1} Filter.{u1} Filter.hasPure.{u1} \u03b1 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Set.{u1} (Filter.{u1} \u03b1)) (Set.Iic.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1)) (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)) (Insert.insert.{u1, u1} (Filter.{u1} \u03b1) (Set.{u1} (Filter.{u1} \u03b1)) (Set.instInsertSet.{u1} (Filter.{u1} \u03b1)) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toBot.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (Singleton.singleton.{u1, u1} (Filter.{u1} \u03b1) (Set.{u1} (Filter.{u1} \u03b1)) (Set.instSingletonSet.{u1} (Filter.{u1} \u03b1)) (Pure.pure.{u1, u1} Filter.{u1} Filter.instPureFilter.{u1} \u03b1 a)))\nCase conversion may be inaccurate. Consider using '#align filter.Iic_pure Filter.Iic_pure\u2093'. -/\n@[simp]\ntheorem Iic_pure (a : \u03b1) : Iic (pure a : Filter \u03b1) = {\u22a5, 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 {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s f) (forall (g : Ultrafilter.{u1} \u03b1), (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g) f) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s f) (forall (g : Ultrafilter.{u1} \u03b1), (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 g) f) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s g))\nCase conversion may be inaccurate. Consider using '#align filter.mem_iff_ultrafilter Filter.mem_iff_ultrafilter\u2093'. -/\ntheorem mem_iff_ultrafilter : s \u2208 f \u2194 \u2200 g : Ultrafilter \u03b1, \u2191g \u2264 f \u2192 s \u2208 g :=\n  by\n  refine' \u27e8fun hf g hg => hg hf, fun H => by_contra fun hf => _\u27e9\n  set g : Filter \u21a5(s\u1d9c) := 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 {\u03b1 : Type.{u1}} {f\u2081 : Filter.{u1} \u03b1} {f\u2082 : Filter.{u1} \u03b1}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) f\u2081 f\u2082) (forall (g : Ultrafilter.{u1} \u03b1), (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g) f\u2081) -> (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g) f\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f\u2081 : Filter.{u1} \u03b1} {f\u2082 : Filter.{u1} \u03b1}, Iff (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) f\u2081 f\u2082) (forall (g : Ultrafilter.{u1} \u03b1), (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 g) f\u2081) -> (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 g) f\u2082))\nCase conversion may be inaccurate. Consider using '#align filter.le_iff_ultrafilter Filter.le_iff_ultrafilter\u2093'. -/\ntheorem le_iff_ultrafilter {f\u2081 f\u2082 : Filter \u03b1} : f\u2081 \u2264 f\u2082 \u2194 \u2200 g : Ultrafilter \u03b1, \u2191g \u2264 f\u2081 \u2192 \u2191g \u2264 f\u2082 :=\n  \u27e8fun h g h\u2081 => h\u2081.trans h, fun h s hs => mem_iff_ultrafilter.2 fun g hg => h g hg hs\u27e9\n#align filter.le_iff_ultrafilter Filter.le_iff_ultrafilter\n\n/- warning: filter.supr_ultrafilter_le_eq -> Filter.sup\u1d62_ultrafilter_le_eq is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (sup\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasSup.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (Ultrafilter.{u1} \u03b1) (fun (g : Ultrafilter.{u1} \u03b1) => sup\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toHasSup.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g) f) (fun (hg : LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g) f) => (fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g))) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (f : Filter.{u1} \u03b1), Eq.{succ u1} (Filter.{u1} \u03b1) (sup\u1d62.{u1, succ u1} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toSupSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (Ultrafilter.{u1} \u03b1) (fun (g : Ultrafilter.{u1} \u03b1) => sup\u1d62.{u1, 0} (Filter.{u1} \u03b1) (ConditionallyCompleteLattice.toSupSet.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 g) f) (fun (hg : LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 g) f) => Ultrafilter.toFilter.{u1} \u03b1 g))) f\nCase conversion may be inaccurate. Consider using '#align filter.supr_ultrafilter_le_eq Filter.sup\u1d62_ultrafilter_le_eq\u2093'. -/\n/-- A filter equals the intersection of all the ultrafilters which contain it. -/\ntheorem sup\u1d62_ultrafilter_le_eq (f : Filter \u03b1) :\n    (\u2a06 (g : Ultrafilter \u03b1) (hg : \u2191g \u2264 f), (g : Filter \u03b1)) = f :=\n  eq_of_forall_ge_iff fun f' => by simp only [sup\u1d62_le_iff, \u2190 le_iff_ultrafilter]\n#align filter.supr_ultrafilter_le_eq Filter.sup\u1d62_ultrafilter_le_eq\n\n/- warning: filter.tendsto_iff_ultrafilter -> Filter.tendsto_iff_ultrafilter is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) (l\u2081 : Filter.{u1} \u03b1) (l\u2082 : Filter.{u2} \u03b2), Iff (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l\u2081 l\u2082) (forall (g : Ultrafilter.{u1} \u03b1), (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g) l\u2081) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) g) l\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) (l\u2081 : Filter.{u1} \u03b1) (l\u2082 : Filter.{u2} \u03b2), Iff (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l\u2081 l\u2082) (forall (g : Ultrafilter.{u1} \u03b1), (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 g) l\u2081) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f (Ultrafilter.toFilter.{u1} \u03b1 g) l\u2082))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto_iff_ultrafilter Filter.tendsto_iff_ultrafilter\u2093'. -/\n/-- The `tendsto` relation can be checked on ultrafilters. -/\ntheorem tendsto_iff_ultrafilter (f : \u03b1 \u2192 \u03b2) (l\u2081 : Filter \u03b1) (l\u2082 : Filter \u03b2) :\n    Tendsto f l\u2081 l\u2082 \u2194 \u2200 g : Ultrafilter \u03b1, \u2191g \u2264 l\u2081 \u2192 Tendsto f g l\u2082 := 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 {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1}, Iff (Exists.{succ u1} (Ultrafilter.{u1} \u03b1) (fun (u : Ultrafilter.{u1} \u03b1) => LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) u) f)) (Filter.NeBot.{u1} \u03b1 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {f : Filter.{u1} \u03b1}, Iff (Exists.{succ u1} (Ultrafilter.{u1} \u03b1) (fun (u : Ultrafilter.{u1} \u03b1) => LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 u) f)) (Filter.NeBot.{u1} \u03b1 f)\nCase conversion may be inaccurate. Consider using '#align filter.exists_ultrafilter_iff Filter.exists_ultrafilter_iff\u2093'. -/\ntheorem exists_ultrafilter_iff {f : Filter \u03b1} : (\u2203 u : Ultrafilter \u03b1, \u2191u \u2264 f) \u2194 NeBot f :=\n  \u27e8fun \u27e8u, uf\u27e9 => neBot_of_le uf, fun h => @exists_ultrafilter_le _ _ h\u27e9\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 {\u03b1 : Type.{u1}} {g : Filter.{u1} \u03b1} {p : (Filter.{u1} \u03b1) -> Prop}, (Monotone.{u1, 0} (Filter.{u1} \u03b1) Prop (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1)) (PartialOrder.toPreorder.{0} Prop Prop.partialOrder) p) -> (Iff (forall (f : Filter.{u1} \u03b1), (Filter.NeBot.{u1} \u03b1 f) -> (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) f g) -> (p f)) (forall (f : Ultrafilter.{u1} \u03b1), (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f) g) -> (p ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) f))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {g : Filter.{u1} \u03b1} {p : (Filter.{u1} \u03b1) -> Prop}, (Monotone.{u1, 0} (Filter.{u1} \u03b1) Prop (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1)) (PartialOrder.toPreorder.{0} Prop Prop.partialOrder) p) -> (Iff (forall (f : Filter.{u1} \u03b1), (Filter.NeBot.{u1} \u03b1 f) -> (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) f g) -> (p f)) (forall (f : Ultrafilter.{u1} \u03b1), (LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 f) g) -> (p (Ultrafilter.toFilter.{u1} \u03b1 f))))\nCase conversion may be inaccurate. Consider using '#align filter.forall_ne_bot_le_iff Filter.forall_neBot_le_iff\u2093'. -/\ntheorem forall_neBot_le_iff {g : Filter \u03b1} {p : Filter \u03b1 \u2192 Prop} (hp : Monotone p) :\n    (\u2200 f : Filter \u03b1, NeBot f \u2192 f \u2264 g \u2192 p f) \u2194 \u2200 f : Ultrafilter \u03b1, \u2191f \u2264 g \u2192 p f :=\n  by\n  refine' \u27e8fun H f hf => H f f.ne_bot hf, _\u27e9\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 (\u03b1) [Infinite \u03b1]\n\n#print Filter.hyperfilter /-\n/-- The ultrafilter extending the cofinite filter. -/\nnoncomputable def hyperfilter : Ultrafilter \u03b1 :=\n  Ultrafilter.of cofinite\n#align filter.hyperfilter Filter.hyperfilter\n-/\n\nvariable {\u03b1}\n\n/- warning: filter.hyperfilter_le_cofinite -> Filter.hyperfilter_le_cofinite is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1], LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) (Filter.hyperfilter.{u1} \u03b1 _inst_1)) (Filter.cofinite.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1], LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 (Filter.hyperfilter.{u1} \u03b1 _inst_1)) (Filter.cofinite.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align filter.hyperfilter_le_cofinite Filter.hyperfilter_le_cofinite\u2093'. -/\ntheorem hyperfilter_le_cofinite : \u2191(hyperfilter \u03b1) \u2264 @cofinite \u03b1 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1], Ne.{succ u1} (Filter.{u1} \u03b1) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (Filter.{u1} \u03b1) (Filter.completeLattice.{u1} \u03b1))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Ultrafilter.{u1} \u03b1) (Filter.{u1} \u03b1) (Ultrafilter.Filter.hasCoeT.{u1} \u03b1))) (Filter.hyperfilter.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1], Ne.{succ u1} (Filter.{u1} \u03b1) (Bot.bot.{u1} (Filter.{u1} \u03b1) (CompleteLattice.toBot.{u1} (Filter.{u1} \u03b1) (Filter.instCompleteLatticeFilter.{u1} \u03b1))) (Ultrafilter.toFilter.{u1} \u03b1 (Filter.hyperfilter.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align filter.bot_ne_hyperfilter Filter.bot_ne_hyperfilter\u2093'. -/\n@[simp]\ntheorem bot_ne_hyperfilter : (\u22a5 : Filter \u03b1) \u2260 hyperfilter \u03b1 :=\n  (by infer_instance : NeBot \u2191(hyperfilter \u03b1)).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 \u03b1} (hf : s.Finite) : s \u2209 hyperfilter \u03b1 := 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 \u2190 _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 {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1] {s : Set.{u1} \u03b1}, (Set.Finite.{u1} \u03b1 s) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) (Filter.hyperfilter.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1] {s : Set.{u1} \u03b1}, (Set.Finite.{u1} \u03b1 s) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) (Filter.hyperfilter.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align filter.compl_mem_hyperfilter_of_finite Filter.compl_mem_hyperfilter_of_finite\u2093'. -/\ntheorem compl_mem_hyperfilter_of_finite {s : Set \u03b1} (hf : Set.Finite s) : s\u1d9c \u2208 hyperfilter \u03b1 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1] {s : Set.{u1} \u03b1}, (Set.Finite.{u1} \u03b1 s) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s) (Filter.hyperfilter.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1] {s : Set.{u1} \u03b1}, (Set.Finite.{u1} \u03b1 s) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s) (Filter.hyperfilter.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align set.finite.compl_mem_hyperfilter Set.Finite.compl_mem_hyperfilter\u2093'. -/\nalias compl_mem_hyperfilter_of_finite \u2190 _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 {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1] {s : Set.{u1} \u03b1}, (Set.Finite.{u1} \u03b1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) s)) -> (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.hasMem.{u1} \u03b1) s (Filter.hyperfilter.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Infinite.{succ u1} \u03b1] {s : Set.{u1} \u03b1}, (Set.Finite.{u1} \u03b1 (HasCompl.compl.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} \u03b1) (Set.instBooleanAlgebraSet.{u1} \u03b1)) s)) -> (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Ultrafilter.{u1} \u03b1) (Ultrafilter.instMembershipSetUltrafilter.{u1} \u03b1) s (Filter.hyperfilter.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align filter.mem_hyperfilter_of_finite_compl Filter.mem_hyperfilter_of_finite_compl\u2093'. -/\ntheorem mem_hyperfilter_of_finite_compl {s : Set \u03b1} (hf : Set.Finite (s\u1d9c)) : s \u2208 hyperfilter \u03b1 :=\n  compl_compl s \u25b8 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 : \u03b1 \u2192 \u03b2} {s : Set \u03b1} {g : Ultrafilter \u03b2}\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {m : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1} {g : Ultrafilter.{u2} \u03b2}, (Membership.Mem.{u2, u2} (Set.{u2} \u03b2) (Ultrafilter.{u2} \u03b2) (Ultrafilter.hasMem.{u2} \u03b2) (Set.image.{u1, u2} \u03b1 \u03b2 m s) g) -> (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.hasInf.{u1} \u03b1) (Filter.comap.{u1, u2} \u03b1 \u03b2 m ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Ultrafilter.{u2} \u03b2) (Filter.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} (Ultrafilter.{u2} \u03b2) (Filter.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} (Ultrafilter.{u2} \u03b2) (Filter.{u2} \u03b2) (Ultrafilter.Filter.hasCoeT.{u2} \u03b2))) g)) (Filter.principal.{u1} \u03b1 s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {m : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1} {g : Ultrafilter.{u2} \u03b2}, (Membership.mem.{u2, u2} (Set.{u2} \u03b2) (Ultrafilter.{u2} \u03b2) (Ultrafilter.instMembershipSetUltrafilter.{u2} \u03b2) (Set.image.{u1, u2} \u03b1 \u03b2 m s) g) -> (Filter.NeBot.{u1} \u03b1 (Inf.inf.{u1} (Filter.{u1} \u03b1) (Filter.instInfFilter.{u1} \u03b1) (Filter.comap.{u1, u2} \u03b1 \u03b2 m (Ultrafilter.toFilter.{u2} \u03b2 g)) (Filter.principal.{u1} \u03b1 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\u2093'. -/\ntheorem comap_inf_principal_neBot_of_image_mem (h : m '' s \u2208 g) : (Filter.comap m g \u2293 \ud835\udcdf 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 \u2208 g) : Ultrafilter \u03b1 :=\n  @of _ (Filter.comap m g \u2293 \ud835\udcdf 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 \u2208 g) : s \u2208 ofComapInfPrincipal h :=\n  by\n  let f := Filter.comap m g \u2293 \ud835\udcdf s\n  haveI : f.ne_bot := comap_inf_principal_ne_bot_of_image_mem h\n  have : s \u2208 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 \u2208 g) : (ofComapInfPrincipal h).map m = g :=\n  by\n  let f := Filter.comap m g \u2293 \ud835\udcdf 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) \u2264 Filter.map m f := map_mono (of_le _)\n    _ \u2264 (Filter.map m <| Filter.comap m g) \u2293 Filter.map m (\ud835\udcdf s) := map_inf_le\n    _ = (Filter.map m <| Filter.comap m g) \u2293 (\ud835\udcdf <| m '' s) := by rw [map_principal]\n    _ \u2264 g \u2293 (\ud835\udcdf <| 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\u2081 u\u2082 v\u2081 v\u2082 u\u2083 u\u2084 v\u2083 v\u2084 \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\u2081) [category C] (D : Type u\u2082) [category D] : category (C \u00d7 D) :=\n  category.mk\n\n-- rfl lemmas for category.prod\n\n@[simp] theorem prod_id (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C) (Y : D) :\n    \ud835\udfd9 = (\ud835\udfd9, \ud835\udfd9) :=\n  rfl\n\n@[simp] theorem prod_comp (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] {P : C} {Q : C}\n    {R : C} {S : D} {T : D} {U : D} (f : (P, S) \u27f6 (Q, T)) (g : (Q, T) \u27f6 (R, U)) :\n    f \u226b g = (prod.fst f \u226b prod.fst g, prod.snd f \u226b prod.snd g) :=\n  rfl\n\n@[simp] theorem prod_id_fst (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 D) :\n    prod.fst \ud835\udfd9 = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem prod_id_snd (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 D) :\n    prod.snd \ud835\udfd9 = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem prod_comp_fst (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] {X : C \u00d7 D}\n    {Y : C \u00d7 D} {Z : C \u00d7 D} (f : X \u27f6 Y) (g : Y \u27f6 Z) : prod.fst (f \u226b g) = prod.fst f \u226b prod.fst g :=\n  rfl\n\n@[simp] theorem prod_comp_snd (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] {X : C \u00d7 D}\n    {Y : C \u00d7 D} {Z : C \u00d7 D} (f : X \u27f6 Y) (g : Y \u27f6 Z) : prod.snd (f \u226b g) = prod.snd f \u226b 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\u2081) [category C] (D : Type u\u2081) [category D] :\n    category (C \u00d7 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 \u2964 C \u00d7 D` given by `X \u21a6 (X, Z)`. -/\n@[simp] theorem sectl_obj (C : Type u\u2081) [category C] {D : Type u\u2082} [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 \u2964 C \u00d7 D` given by `Y \u21a6 (Z, Y)` . -/\ndef sectr {C : Type u\u2081} [category C] (Z : C) (D : Type u\u2082) [category D] : D \u2964 C \u00d7 D :=\n  functor.mk (fun (X : D) => (Z, X)) fun (X Y : D) (f : X \u27f6 Y) => (\ud835\udfd9, f)\n\n/-- `fst` is the functor `(X, Y) \u21a6 X`. -/\n@[simp] theorem fst_obj (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 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) \u21a6 Y`. -/\n@[simp] theorem snd_map (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 D)\n    (Y : C \u00d7 D) (f : X \u27f6 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 \u00d7 D \u2964 D \u00d7 C`. -/\n@[simp] theorem swap_map (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (_x : C \u00d7 D) :\n    \u2200 (_x_1 : C \u00d7 D) (f : _x \u27f6 _x_1), functor.map (swap C D) f = (prod.snd f, prod.fst f) :=\n  fun (_x_1 : C \u00d7 D) (f : _x \u27f6 _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\u2081) [category C] (D : Type u\u2082) [category D] (X : C \u00d7 D) :\n    nat_trans.app (iso.hom (symmetry C D)) X = \ud835\udfd9 :=\n  Eq.refl (nat_trans.app (iso.hom (symmetry C D)) X)\n\n/--\nThe equivalence, given by swapping factors, between `C \u00d7 D` and `D \u00d7 C`.\n-/\n@[simp] theorem braiding_counit_iso_inv_app (C : Type u\u2081) [category C] (D : Type u\u2082) [category D]\n    (X : D \u00d7 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\u2081) [category C] (D : Type u\u2082) [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\u2081) [category C] (D : Type u\u2082) [category D] : C \u2964 (C \u2964 D) \u2964 D :=\n  functor.mk\n    (fun (X : C) =>\n      functor.mk (fun (F : C \u2964 D) => functor.obj F X)\n        fun (F G : C \u2964 D) (\u03b1 : F \u27f6 G) => nat_trans.app \u03b1 X)\n    fun (X Y : C) (f : X \u27f6 Y) => nat_trans.mk fun (F : C \u2964 D) => functor.map F f\n\n/--\nThe \"evaluation of `F` at `X`\" functor,\nas a functor `C \u00d7 (C \u2964 D) \u2964 D`.\n-/\n@[simp] theorem evaluation_uncurried_obj (C : Type u\u2081) [category C] (D : Type u\u2082) [category D]\n    (p : C \u00d7 (C \u2964 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\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083}\n    [category C] {D : Type u\u2084} [category D] (F : A \u2964 B) (G : C \u2964 D) (X : A \u00d7 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 \u00d7 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\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083}\n    [category C] {D : Type u\u2084} [category D] {F : A \u2964 B} {G : A \u2964 B} {H : C \u2964 D} {I : C \u2964 D}\n    (\u03b1 : F \u27f6 G) (\u03b2 : H \u27f6 I) (X : A \u00d7 C) :\n    app (prod \u03b1 \u03b2) X = (app \u03b1 (prod.fst X), app \u03b2 (prod.snd X)) :=\n  Eq.refl (app (prod \u03b1 \u03b2) 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n\ntheorem mapp {p : \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2) : \u03a0 (l : list \u03b1) (h : \u2200 x\u2208l, p (f x)) x, x \u2208 list.map f l \u2192 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 : \u03b2 \u2192 Prop} {q : \u03b1 \u2192 Prop} (f : \u03a0 a, q a \u2192 \u03b2)  : \u03a0 (l : list \u03b1) \n(h : \u2200 y (hy : q y) (h\u2081 : y \u2208 l), p (f y hy)) \n(hf : \u2200 y \u2208 l, q y) x, x \u2208 list.pmap f l hf \u2192 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 : \u03a0 l : list \u03b1, l \u2260 [] \u2192 \u03b1\n| []       h := by contradiction\n| (a :: l) h := a\n\ntheorem mem_pmap_of_mem {p : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) {a : \u03b1} {l : list \u03b1} (h : a \u2208 l) (hf : \u2200 y \u2208 l, p y) : \nf a (hf a h) \u2208 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 : \u2200 (y : \u03b1), y \u2208 l' \u2192 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 \u2192 list nnf\n| [] := []\n| ((box \u03c6) :: l) := \u03c6 :: unbox l\n| (e :: l) := unbox l\n\ntheorem unbox_iff : \u03a0 {\u0393 \u03c6}, box \u03c6 \u2208 \u0393 \u2194 \u03c6 \u2208 unbox \u0393\n| [] \u03c6 := begin split, repeat {intro h, simpa using h} end\n| (hd::tl) \u03c6 := \nbegin\n  split,\n  { intro h, cases h\u2081 : hd, \n    case nnf.box : \u03c8 \n    { dsimp [unbox], cases h, \n       {left, rw h\u2081 at h, injection h},\n       {right, exact (@unbox_iff tl \u03c6).1 h} },\n    all_goals \n    { dsimp [unbox], cases h, \n       {rw h\u2081 at h, contradiction},\n       {exact (@unbox_iff tl \u03c6).1 h} } },\n  { intro h, cases h\u2081 : hd, \n    case nnf.box : \u03c8\n    { rw h\u2081 at h, dsimp [unbox] at h, cases h, \n       {simp [h]}, {right, exact (@unbox_iff tl \u03c6).2 h} },\n    all_goals \n    { rw h\u2081 at h, dsimp [unbox] at h, right, exact (@unbox_iff tl \u03c6).2 h } }\nend\n\ntheorem unbox_size_aux : \u03a0 {\u0393}, node_size (unbox \u0393) \u2264 node_size \u0393\n| [] := by simp\n| (hd::tl) := \nbegin\n  cases h : hd,\n  case nnf.box : \u03c8\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 \u2192 list nnf \n| [] := []\n| (hd::tl) := box hd :: rebox tl\n\ntheorem rebox_unbox_of_mem : \u03a0 {\u0393} (h : \u2200 {\u03c6}, \u03c6 \u2208 unbox \u0393 \u2192 box \u03c6 \u2208 \u0393), rebox (unbox \u0393) \u2286 \u0393\n| [] h := by simp\n| (hd::tl) h := \nbegin\n  cases h\u03c8 : hd,\n  case nnf.box : \u03c6 {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 : \u03a0 {\u0393}, unbox (rebox \u0393) = \u0393\n| [] := by simp\n| (hd::tl) := by simp [unbox_rebox]\n\n-- Just that I don't want to say \u2203 \u03c6 s.t. ...\ndef box_only_rebox : \u03a0 {\u0393}, box_only (rebox \u0393)\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 \u03c6 \u03c8 h, cases h, contradiction, \n                      apply (@box_only_rebox tl).no_and, assumption \n                    end,\n          no_or := begin \n                     intros \u03c6 \u03c8 h, cases h, contradiction, \n                     apply (@box_only_rebox tl).no_or, assumption \n                   end, \n          no_dia := begin \n                      intros \u03c6 h, cases h, contradiction, \n                      apply (@box_only_rebox tl).no_dia, assumption \n                    end} }\nend\n\ntheorem rebox_iff : \u03a0 {\u03c6 \u0393}, box \u03c6 \u2208 rebox \u0393 \u2194 \u03c6 \u2208 \u0393\n| \u03c6 [] := by simp\n| \u03c6 (hd::tl) := \nbegin\n  split, \n  {intro h, cases h\u2081 : hd, \n   all_goals { cases h, \n               {left, rw \u2190h\u2081, injection h}, \n               {right,  have := (@rebox_iff \u03c6 tl).1, exact this h } }},\n  {intro h, cases h\u2081 : hd, \n   all_goals { dsimp, cases h, \n               {left, rw \u2190h\u2081, rw h}, \n               {right, have := (@rebox_iff \u03c6 tl).2, exact this h } } }\nend\n\n@[simp] def undia : list nnf \u2192 list nnf\n| [] := []\n| ((dia \u03c6) :: l) := \u03c6 :: undia l\n| (e :: l) := undia l\n\ntheorem undia_iff : \u03a0 {\u0393 \u03c6}, dia \u03c6 \u2208 \u0393 \u2194 \u03c6 \u2208 undia \u0393\n| [] \u03c6 := begin split, repeat {intro h, simpa using h} end\n| (hd::tl) \u03c6 := \nbegin\n  split,\n  { intro h, cases h\u2081 : hd, \n    case nnf.dia : \u03c8 \n    { dsimp [undia], cases h, \n       {left, rw h\u2081 at h, injection h},\n       {right, exact (@undia_iff tl \u03c6).1 h} },\n    all_goals \n    { dsimp [undia], cases h, \n       {rw h\u2081 at h, contradiction},\n       {exact (@undia_iff tl \u03c6).1 h} } },\n  { intro h, cases h\u2081 : hd, \n    case nnf.dia : \u03c8\n    { rw h\u2081 at h, dsimp [undia] at h, cases h, \n       {simp [h]}, {right, exact (@undia_iff tl \u03c6).2 h} },\n    all_goals \n    { rw h\u2081 at h, dsimp [undia] at h, right, exact (@undia_iff tl \u03c6).2 h } }\nend\n\ndef get_contra : \u03a0 \u0393 : list nnf, \n                 psum {p : nat // var p \u2208 \u0393 \u2227 neg p \u2208 \u0393} \n                      (\u2200 n, var n \u2208 \u0393 \u2192 neg n \u2209 \u0393)\n| []             := psum.inr $ \u03bb _ h, absurd h $ not_mem_nil _\n| (hd :: tl)     := \nbegin\n  cases h : hd,\n  case nnf.var : n \n  {apply dite (neg n \u2208 tl),\n    {intro t, \n     exact psum.inl \u27e8n, \u27e8mem_cons_self _ _, mem_cons_of_mem _ t\u27e9\u27e9},\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 \u2190eq, 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 \u2208 tl),\n    { intro t, \n      exact psum.inl \u27e8n, \u27e8mem_cons_of_mem _ t, mem_cons_self _ _\u27e9\u27e9 },\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 \u2190eq, 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 : \u03a0 \u0393 : sseqt,\n                 psum {p : nat // var p \u2208 \u0393.m \u2227 neg p \u2208 \u0393.m} \n                      (\u2200 n, var n \u2208 \u0393.m \u2192 neg n \u2209 \u0393.m)\n:= \u03bb \u0393, get_contra \u0393.m\n\ndef get_and : \u03a0 \u0393 : list nnf, \n              psum {p : nnf \u00d7 nnf // and p.1 p.2 \u2208 \u0393} \n                   (\u2200 \u03c6 \u03c8, nnf.and \u03c6 \u03c8 \u2209 \u0393)\n| []               := psum.inr $ \u03bb _ _, not_mem_nil _\n| (hd :: tl)       := \nbegin\n  cases h : hd,\n  case nnf.and : \u03c6 \u03c8 { left, constructor,swap,\n                       constructor, exact \u03c6, exact \u03c8, 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 \u03b3 \u03c8 h, \n     cases h, contradiction,\n    apply val, assumption }\n  }\nend\n\ndef get_and_seqt : \u03a0 \u0393 : sseqt, \n              psum {p : nnf \u00d7 nnf // and p.1 p.2 \u2208 \u0393.m} \n                   (\u2200 \u03c6 \u03c8, nnf.and \u03c6 \u03c8 \u2209 \u0393.m)\n:= \u03bb \u0393, get_and \u0393.m\n\ndef get_or : \u03a0 \u0393 : list nnf, \n              psum {p : nnf \u00d7 nnf // or p.1 p.2 \u2208 \u0393} \n                   (\u2200 \u03c6 \u03c8, nnf.or \u03c6 \u03c8 \u2209 \u0393)\n| []               := psum.inr $ \u03bb _ _, not_mem_nil _\n| (hd :: tl)       :=\nbegin\n  cases h : hd,\n  case nnf.or : \u03c6 \u03c8 { left, constructor,swap,\n                       constructor, exact \u03c6, exact \u03c8, 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 \u03b3 \u03c8 h, \n     cases h, contradiction,\n    apply val, assumption}\n  }\nend\n\ndef get_or_seqt : \u03a0 \u0393 : sseqt,\n              psum {p : nnf \u00d7 nnf // or p.1 p.2 \u2208 \u0393.m} \n                   (\u2200 \u03c6 \u03c8, nnf.or \u03c6 \u03c8 \u2209 \u0393.m)\n:= \u03bb \u0393, get_or \u0393.m\n\ndef get_dia : \u03a0 \u0393 : list nnf, \n              psum {p : nnf // dia p \u2208 \u0393} \n                   (\u2200 \u03c6, nnf.dia \u03c6 \u2209 \u0393)\n| []               := psum.inr $ \u03bb _, not_mem_nil _\n| (hd :: tl)       := \nbegin\n  cases h : hd,\n  case nnf.dia : \u03c6 { left, constructor, swap, exact \u03c6, 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 \u03b3 h, \n     cases h, contradiction,\n     apply val, assumption } }\nend\n\ndef get_dia_seqt : \u03a0 \u0393 : sseqt,\n              psum {p : nnf // dia p \u2208 \u0393.m} \n                   (\u2200 \u03c6, nnf.dia \u03c6 \u2209 \u0393.m)\n:= \u03bb \u0393, get_dia \u0393.m\n\ndef get_box : \u03a0 \u0393 : list nnf,\n              psum {l : nnf // box l \u2208 \u0393} \n                   (\u2200 \u03c6, nnf.box \u03c6 \u2209 \u0393)\n| [] := psum.inr $ \u03bb _, not_mem_nil _\n| (hd :: tl) := \nbegin\n  cases h : hd,\n  case nnf.box : \u03c6 { left, constructor, swap, exact \u03c6, 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 \u03b3 h, \n     cases h, contradiction,\n     apply val, assumption } }\nend\n\ndef get_box_seqt : \u03a0 \u0393 : sseqt,\n              psum {p : nnf // box p \u2208 \u0393.m} \n                   (\u2200 \u03c6, nnf.box \u03c6 \u2209 \u0393.m)\n:= \u03bb \u0393, get_box \u0393.m\n\n@[simp] def get_var : list nnf \u2192 list \u2115\n| [] := []\n| ((var n) :: l) := n :: get_var l\n| (e :: l) := get_var l\n\ntheorem get_var_iff : \u03a0 {\u0393 n}, var n \u2208 \u0393 \u2194 n \u2208 get_var \u0393\n| [] \u03c6 := begin split, repeat {intro h, simpa using h} end\n| (hd::tl) \u03c6 := \nbegin\n  split,\n  { intro h, cases h\u2081 : hd, \n    case nnf.var : n\n    { dsimp, cases h, \n       {left, rw h\u2081 at h, injection h},\n       {right, exact (@get_var_iff tl \u03c6).1 h} },\n    all_goals \n    { dsimp, cases h, \n       {rw h\u2081 at h, contradiction},\n       {exact (@get_var_iff tl \u03c6).1 h} } },\n  { intro h, cases h\u2081 : hd, \n    case nnf.var : n\n    { rw h\u2081 at h, dsimp at h, cases h, \n       {simp [h]}, {right, exact (@get_var_iff tl \u03c6).2 h} },\n    all_goals \n    { rw h\u2081 at h, dsimp [undia] at h, right, exact (@get_var_iff tl \u03c6).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 \u2208 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 {\u03b9 \u03b1 : Type*}\n\n/-- A filter `l` has the countable intersection property if for any countable collection\nof sets `s \u2208 l` their intersection belongs to `l` as well. -/\nclass countable_Inter_filter (l : filter \u03b1) : Prop :=\n(countable_sInter_mem_sets' :\n  \u2200 {S : set (set \u03b1)} (hSc : countable S) (hS : \u2200 s \u2208 S, s \u2208 l), \u22c2\u2080 S \u2208 l)\n\nvariables {l : filter \u03b1} [countable_Inter_filter l]\n\nlemma countable_sInter_mem_sets {S : set (set \u03b1)} (hSc : countable S) :\n  \u22c2\u2080 S \u2208 l \u2194 \u2200 s \u2208 S, s \u2208 l :=\n\u27e8\u03bb hS s hs, mem_of_superset hS (sInter_subset_of_mem hs),\n  countable_Inter_filter.countable_sInter_mem_sets' hSc\u27e9\n\nlemma countable_Inter_mem_sets [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1} :\n  (\u22c2 i, s i) \u2208 l \u2194 \u2200 i, s i \u2208 l :=\nsInter_range s \u25b8 (countable_sInter_mem_sets (countable_range _)).trans forall_range_iff\n\nlemma countable_bInter_mem {S : set \u03b9} (hS : countable S) {s : \u03a0 i \u2208 S, set \u03b1} :\n  (\u22c2 i \u2208 S, s i \u2039_\u203a) \u2208 l \u2194  \u2200 i \u2208 S, s i \u2039_\u203a \u2208 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 \u03b9] {p : \u03b1 \u2192 \u03b9 \u2192 Prop} :\n  (\u2200\u1da0 x in l, \u2200 i, p x i) \u2194 \u2200 i, \u2200\u1da0 x in l, p x i :=\nby simpa only [filter.eventually, set_of_forall]\n  using @countable_Inter_mem_sets _ _ l _ _ (\u03bb i, {x | p x i})\n\nlemma eventually_countable_ball {S : set \u03b9} (hS : countable S) {p : \u03a0 (x : \u03b1) (i \u2208 S), Prop} :\n  (\u2200\u1da0 x in l, \u2200 i \u2208 S, p x i \u2039_\u203a) \u2194 \u2200 i \u2208 S, \u2200\u1da0 x in l, p x i \u2039_\u203a :=\nby simpa only [filter.eventually, set_of_forall]\n  using @countable_bInter_mem _ _ l _ _ hS (\u03bb i hi, {x | p x i hi})\n\nlemma eventually_le.countable_Union [encodable \u03b9] {s t : \u03b9 \u2192 set \u03b1} (h : \u2200 i, s i \u2264\u1da0[l] t i) :\n  (\u22c3 i, s i) \u2264\u1da0[l] \u22c3 i, t i :=\n(eventually_countable_forall.2 h).mono $ \u03bb x hst hs, mem_Union.2 $\n  (mem_Union.1 hs).imp hst\n\nlemma eventually_eq.countable_Union [encodable \u03b9] {s t : \u03b9 \u2192 set \u03b1} (h : \u2200 i, s i =\u1da0[l] t i) :\n  (\u22c3 i, s i) =\u1da0[l] \u22c3 i, t i :=\n(eventually_le.countable_Union (\u03bb i, (h i).le)).antisymm\n  (eventually_le.countable_Union (\u03bb i, (h i).symm.le))\n\nlemma eventually_le.countable_bUnion {S : set \u03b9} (hS : countable S) {s t : \u03a0 i \u2208 S, set \u03b1}\n  (h : \u2200 i \u2208 S, s i \u2039_\u203a \u2264\u1da0[l] t i \u2039_\u203a) : (\u22c3 i \u2208 S, s i \u2039_\u203a) \u2264\u1da0[l] \u22c3 i \u2208 S, t i \u2039_\u203a :=\nbegin\n  simp only [bUnion_eq_Union],\n  haveI := hS.to_encodable,\n  exact eventually_le.countable_Union (\u03bb i, h i i.2)\nend\n\nlemma eventually_eq.countable_bUnion {S : set \u03b9} (hS : countable S) {s t : \u03a0 i \u2208 S, set \u03b1}\n  (h : \u2200 i \u2208 S, s i \u2039_\u203a =\u1da0[l] t i \u2039_\u203a) : (\u22c3 i \u2208 S, s i \u2039_\u203a) =\u1da0[l] \u22c3 i \u2208 S, t i \u2039_\u203a :=\n(eventually_le.countable_bUnion hS (\u03bb i hi, (h i hi).le)).antisymm\n  (eventually_le.countable_bUnion hS (\u03bb i hi, (h i hi).symm.le))\n\nlemma eventually_le.countable_Inter [encodable \u03b9] {s t : \u03b9 \u2192 set \u03b1} (h : \u2200 i, s i \u2264\u1da0[l] t i) :\n  (\u22c2 i, s i) \u2264\u1da0[l] \u22c2 i, t i :=\n(eventually_countable_forall.2 h).mono $ \u03bb x hst hs, mem_Inter.2 $ \u03bb i, hst _ (mem_Inter.1 hs i)\n\nlemma eventually_eq.countable_Inter [encodable \u03b9] {s t : \u03b9 \u2192 set \u03b1} (h : \u2200 i, s i =\u1da0[l] t i) :\n  (\u22c2 i, s i) =\u1da0[l] \u22c2 i, t i :=\n(eventually_le.countable_Inter (\u03bb i, (h i).le)).antisymm\n  (eventually_le.countable_Inter (\u03bb i, (h i).symm.le))\n\nlemma eventually_le.countable_bInter {S : set \u03b9} (hS : countable S) {s t : \u03a0 i \u2208 S, set \u03b1}\n  (h : \u2200 i \u2208 S, s i \u2039_\u203a \u2264\u1da0[l] t i \u2039_\u203a) : (\u22c2 i \u2208 S, s i \u2039_\u203a) \u2264\u1da0[l] \u22c2 i \u2208 S, t i \u2039_\u203a :=\nbegin\n  simp only [bInter_eq_Inter],\n  haveI := hS.to_encodable,\n  exact eventually_le.countable_Inter (\u03bb i, h i i.2)\nend\n\nlemma eventually_eq.countable_bInter {S : set \u03b9} (hS : countable S) {s t : \u03a0 i \u2208 S, set \u03b1}\n  (h : \u2200 i \u2208 S, s i \u2039_\u203a =\u1da0[l] t i \u2039_\u203a) : (\u22c2 i \u2208 S, s i \u2039_\u203a) =\u1da0[l] \u22c2 i \u2208 S, t i \u2039_\u203a :=\n(eventually_le.countable_bInter hS (\u03bb i hi, (h i hi).le)).antisymm\n  (eventually_le.countable_bInter hS (\u03bb i hi, (h i hi).symm.le))\n\ninstance countable_Inter_filter_principal (s : set \u03b1) : countable_Inter_filter (\ud835\udcdf s) :=\n\u27e8\u03bb S hSc hS, subset_sInter hS\u27e9\n\ninstance countable_Inter_filter_bot : countable_Inter_filter (\u22a5 : filter \u03b1) :=\nby { rw \u2190 principal_empty, apply countable_Inter_filter_principal }\n\ninstance countable_Inter_filter_top : countable_Inter_filter (\u22a4 : filter \u03b1) :=\nby { rw \u2190 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 \u03b1 \u2293 \ud835\udcdf s`. -/\ninstance countable_Inter_filter_inf (l\u2081 l\u2082 : filter \u03b1) [countable_Inter_filter l\u2081]\n  [countable_Inter_filter l\u2082] :\n  countable_Inter_filter (l\u2081 \u2293 l\u2082) :=\nbegin\n  refine \u27e8\u03bb S hSc hS, _\u27e9,\n  choose s hs t ht hst using hS,\n  replace hs : (\u22c2 i \u2208 S, s i \u2039_\u203a) \u2208 l\u2081 := (countable_bInter_mem hSc).2 hs,\n  replace ht : (\u22c2 i \u2208 S, t i \u2039_\u203a) \u2208 l\u2082 := (countable_bInter_mem hSc).2 ht,\n  refine mem_of_superset (inter_mem_inf hs ht) (subset_sInter $ \u03bb 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\u2081 l\u2082 : filter \u03b1) [countable_Inter_filter l\u2081]\n  [countable_Inter_filter l\u2082] :\n  countable_Inter_filter (l\u2081 \u2294 l\u2082) :=\nbegin\n  refine \u27e8\u03bb S hSc hS, \u27e8_, _\u27e9\u27e9; refine (countable_sInter_mem_sets hSc).2 (\u03bb 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 : \u2115` 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 (\u2115 \u00d7 \u2124)\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 : \u2124) (l : linexp) : linexp :=\n  ite (c = 0) [] (ite (c = 1) l (list.map (fun (_x : \u2115 \u00d7 \u2124) => 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 : \u2115) : linexp \u2192 Option \u2124 :=\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 : \u2115) : linexp \u2192 Bool :=\n  option.is_some \u2218 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 : \u2115) (l : linexp) : \u2124 :=\n  sorry\n\n/-- `l.vars` returns the list of variables that occur in `l`. -/\ndef vars (l : linexp) : List \u2115 :=\n  list.map prod.fst l\n\n/--\nDefines a lex ordering on `linexp`. This function is performance critical.\n-/\ndef cmp : linexp \u2192 linexp \u2192 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 \u2192 ineq \u2192 ineq :=\n  sorry\n\n/-- `ineq` is ordered `eq < le < lt`. -/\ndef cmp : ineq \u2192 ineq \u2192 ordering :=\n  sorry\n\n/-- Prints an `ineq` as the corresponding infix symbol. -/\ndef to_string : ineq \u2192 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 (\u03bb \u27e8k, v\u27e9, v * Var[k])`.\nstr determines the strength of the comparison -- is it < 0, \u2264 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 \u2192 List \u2115 :=\n  linexp.vars \u2218 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 : \u2115) : \u2124 :=\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 : \u2115) : comp :=\n  comp.mk (comp.str c) (linexp.scale (\u2191n) (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 \u2192 \u2115 \u2192 tactic (rb_map \u2115 \u2115)`.\n`produce_certificate hyps max_var` tries to derive a contradiction from the comparisons in `hyps`\nby eliminating all variables \u2264 `max_var`.\nIf successful, it returns a map `coeff : \u2115 \u2192 \u2115` as a certificate.\nThis map represents that we can find a contradiction by taking the sum  `\u2211 (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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n\nnamespace List\n\n@[simp] theorem length_nil : length ([] : List \u03b1) = 0 :=\n  rfl\n\ndef reverseAux : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\n  | [],   r => r\n  | a::l, r => reverseAux l (a::r)\n\ndef reverse (as : List \u03b1) :List \u03b1 :=\n  reverseAux as []\n\nprotected def append (as bs : List \u03b1) : List \u03b1 :=\n  reverseAux as.reverse bs\n\ninstance : Append (List \u03b1) := \u27e8List.append\u27e9\n\ntheorem reverseAux_reverseAux_nil (as bs : List \u03b1) : 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 \u03b1) : [] ++ as = as := rfl\n\n@[simp] theorem append_nil (as : List \u03b1) : as ++ [] = as := by\n  show reverseAux (reverseAux as []) [] = as\n  simp [reverseAux_reverseAux_nil, reverseAux]\n\ntheorem reverseAux_reverseAux (as bs cs : List \u03b1) : 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 : \u03b1) (as bs : List \u03b1) : (a::as) ++ bs = a::(as ++ bs) :=\n  reverseAux_reverseAux as [a] bs\n\ntheorem append_assoc (as bs cs : List \u03b1) : (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 \u03b1) := \u27e8List.nil\u27e9\n\nprotected def erase {\u03b1} [BEq \u03b1] : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1\n  | [],    b => []\n  | a::as, b => match a == b with\n    | true  => as\n    | false => a :: List.erase as b\n\ndef eraseIdx : List \u03b1 \u2192 Nat \u2192 List \u03b1\n  | [],    _   => []\n  | a::as, 0   => as\n  | a::as, n+1 => a :: eraseIdx as n\n\ndef isEmpty : List \u03b1 \u2192 Bool\n  | []     => true\n  | _ :: _ => false\n\n@[specialize] def map (f : \u03b1 \u2192 \u03b2) : List \u03b1 \u2192 List \u03b2\n  | []    => []\n  | a::as => f a :: map f as\n\n@[specialize] def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3\n  | [],    _     => []\n  | _,     []    => []\n  | a::as, b::bs => f a b :: map\u2082 f as bs\n\ndef join : List (List \u03b1) \u2192 List \u03b1\n  | []      => []\n  | a :: as => a ++ join as\n\n@[specialize] def filterMap (f : \u03b1 \u2192 Option \u03b2) : List \u03b1 \u2192 List \u03b2\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 : \u03b1 \u2192 Bool) : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\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 : \u03b1 \u2192 Bool) (as : List \u03b1) : List \u03b1 :=\n  filterAux p as []\n\n@[specialize] def partitionAux (p : \u03b1 \u2192 Bool) : List \u03b1 \u2192 List \u03b1 \u00d7 List \u03b1 \u2192 List \u03b1 \u00d7 List \u03b1\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 : \u03b1 \u2192 Bool) (as : List \u03b1) : List \u03b1 \u00d7 List \u03b1 :=\n  partitionAux p as ([], [])\n\ndef dropWhile (p : \u03b1 \u2192 Bool) : List \u03b1 \u2192 List \u03b1\n  | []   => []\n  | a::l => match p a with\n    | true  => dropWhile p l\n    | false =>  a::l\n\ndef find? (p : \u03b1 \u2192 Bool) : List \u03b1 \u2192 Option \u03b1\n  | []    => none\n  | a::as => match p a with\n    | true  => some a\n    | false => find? p as\n\ndef findSome? (f : \u03b1 \u2192 Option \u03b2) : List \u03b1 \u2192 Option \u03b2\n  | []    => none\n  | a::as => match f a with\n    | some b => some b\n    | none   => findSome? f as\n\ndef replace [BEq \u03b1] : List \u03b1 \u2192 \u03b1 \u2192 \u03b1 \u2192 List \u03b1\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 \u03b1] (a : \u03b1) : List \u03b1 \u2192 Bool\n  | []    => false\n  | b::bs => match a == b with\n    | true  => true\n    | false => elem a bs\n\ndef notElem [BEq \u03b1] (a : \u03b1) (as : List \u03b1) : Bool :=\n  !(as.elem a)\n\nabbrev contains [BEq \u03b1] (as : List \u03b1) (a : \u03b1) : Bool :=\n  elem a as\n\ndef eraseDupsAux {\u03b1} [BEq \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\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 {\u03b1} [BEq \u03b1] (as : List \u03b1) : List \u03b1 :=\n  eraseDupsAux as []\n\ndef eraseRepsAux {\u03b1} [BEq \u03b1] : \u03b1 \u2192 List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\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 {\u03b1} [BEq \u03b1] : List \u03b1 \u2192 List \u03b1\n  | []    => []\n  | a::as => eraseRepsAux a as []\n\n@[specialize] def spanAux (p : \u03b1 \u2192 Bool) : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1 \u00d7 List \u03b1\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 : \u03b1 \u2192 Bool) (as : List \u03b1) : List \u03b1 \u00d7 List \u03b1 :=\n  spanAux p as []\n\n@[specialize] def groupByAux (eq : \u03b1 \u2192 \u03b1 \u2192 Bool) : List \u03b1 \u2192 List (List \u03b1) \u2192 List (List \u03b1)\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 : \u03b1 \u2192 \u03b1 \u2192 Bool) : List \u03b1 \u2192 List (List \u03b1)\n  | []    => []\n  | a::as => groupByAux p as [[a]]\n\ndef lookup [BEq \u03b1] : \u03b1 \u2192 List (\u03b1 \u00d7 \u03b2) \u2192 Option \u03b2\n  | _, []        => none\n  | a, (k,b)::es => match a == k with\n    | true  => some b\n    | false => lookup a es\n\ndef removeAll [BEq \u03b1] (xs ys : List \u03b1) : List \u03b1 :=\n  xs.filter (fun x => ys.notElem x)\n\ndef drop : Nat \u2192 List \u03b1 \u2192 List \u03b1\n  | 0,   a     => a\n  | n+1, []    => []\n  | n+1, a::as => drop n as\n\ndef take : Nat \u2192 List \u03b1 \u2192 List \u03b1\n  | 0,   a     => []\n  | n+1, []    => []\n  | n+1, a::as => a :: take n as\n\n@[specialize] def foldr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (init : \u03b2) : List \u03b1 \u2192 \u03b2\n  | []     => init\n  | a :: l => f a (foldr f init l)\n\n@[inline] def any (l : List \u03b1) (p : \u03b1 \u2192 Bool) : Bool :=\n  foldr (fun a r => p a || r) false l\n\n@[inline] def all (l : List \u03b1) (p : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3\n  | x::xs, y::ys => f x y :: zipWith f xs ys\n  | _,     _     => []\n\ndef zip : List \u03b1 \u2192 List \u03b2 \u2192 List (Prod \u03b1 \u03b2) :=\n  zipWith Prod.mk\n\ndef unzip : List (\u03b1 \u00d7 \u03b2) \u2192 List \u03b1 \u00d7 List \u03b2\n  | []          => ([], [])\n  | (a, b) :: t => match unzip t with | (al, bl) => (a::al, b::bl)\n\ndef rangeAux : Nat \u2192 List Nat \u2192 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 \u2192 List Nat\n  | 0       => []\n  | m@(n+1) => m :: iota n\n\ndef enumFrom : Nat \u2192 List \u03b1 \u2192 List (Nat \u00d7 \u03b1)\n  | n, [] => nil\n  | n, x :: xs   => (n, x) :: enumFrom (n + 1) xs\n\ndef enum : List \u03b1 \u2192 List (Nat \u00d7 \u03b1) := enumFrom 0\n\ndef init : List \u03b1 \u2192 List \u03b1\n  | []   => []\n  | [a]  => []\n  | a::l => a::init l\n\ndef intersperse (sep : \u03b1) : List \u03b1 \u2192 List \u03b1\n  | []    => []\n  | [x]   => [x]\n  | x::xs => x :: sep :: intersperse sep xs\n\ndef intercalate (sep : List \u03b1) (xs : List (List \u03b1)) : List \u03b1 :=\n  join (intersperse sep xs)\n\n@[inline] protected def bind {\u03b1 : Type u} {\u03b2 : Type v} (a : List \u03b1) (b : \u03b1 \u2192 List \u03b2) : List \u03b2 := join (map b a)\n\n@[inline] protected def pure {\u03b1 : Type u} (a : \u03b1) : List \u03b1 := [a]\n\ninductive lt [LT \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 Prop where\n  | nil  (b : \u03b1) (bs : List \u03b1) : lt [] (b::bs)\n  | head {a : \u03b1} (as : List \u03b1) {b : \u03b1} (bs : List \u03b1) : a < b \u2192 lt (a::as) (b::bs)\n  | tail {a : \u03b1} {as : List \u03b1} {b : \u03b1} {bs : List \u03b1} : \u00ac a < b \u2192 \u00ac b < a \u2192 lt as bs \u2192 lt (a::as) (b::bs)\n\ninstance [LT \u03b1] : LT (List \u03b1) := \u27e8List.lt\u27e9\n\ninstance hasDecidableLt [LT \u03b1] [h : DecidableRel (\u03b1:=\u03b1) (\u00b7<\u00b7)] : (l\u2081 l\u2082 : List \u03b1) \u2192 Decidable (l\u2081 < l\u2082)\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\u2081  => isTrue (List.lt.head _ _ h\u2081)\n    | isFalse h\u2081 =>\n      match h b a with\n      | isTrue h\u2082  => isFalse (fun h => match h with\n         | List.lt.head _ _ h\u2081' => absurd h\u2081' h\u2081\n         | List.lt.tail _ h\u2082' _ => absurd h\u2082 h\u2082')\n      | isFalse h\u2082 =>\n        match hasDecidableLt as bs with\n        | isTrue h\u2083  => isTrue (List.lt.tail h\u2081 h\u2082 h\u2083)\n        | isFalse h\u2083 => isFalse (fun h => match h with\n           | List.lt.head _ _ h\u2081' => absurd h\u2081' h\u2081\n           | List.lt.tail _ _ h\u2083' => absurd h\u2083' h\u2083)\n\n@[reducible] protected def le [LT \u03b1] (a b : List \u03b1) : Prop := \u00ac b < a\n\ninstance [LT \u03b1] : LE (List \u03b1) := \u27e8List.le\u27e9\n\ninstance [LT \u03b1] [h : DecidableRel ((\u00b7 < \u00b7) : \u03b1 \u2192 \u03b1 \u2192 Prop)] : (l\u2081 l\u2082 : List \u03b1) \u2192 Decidable (l\u2081 \u2264 l\u2082) :=\n  fun a b => inferInstanceAs (Decidable (Not _))\n\n/--  `isPrefixOf l\u2081 l\u2082` returns `true` Iff `l\u2081` is a prefix of `l\u2082`. -/\ndef isPrefixOf [BEq \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 Bool\n  | [],    _     => true\n  | _,     []    => false\n  | a::as, b::bs => a == b && isPrefixOf as bs\n\n/--  `isSuffixOf l\u2081 l\u2082` returns `true` Iff `l\u2081` is a suffix of `l\u2082`. -/\ndef isSuffixOf [BEq \u03b1] (l\u2081 l\u2082 : List \u03b1) : Bool :=\n  isPrefixOf l\u2081.reverse l\u2082.reverse\n\n@[specialize] def isEqv : List \u03b1 \u2192 List \u03b1 \u2192 (\u03b1 \u2192 \u03b1 \u2192 Bool) \u2192 Bool\n  | [],    [],    _   => true\n  | a::as, b::bs, eqv => eqv a b && isEqv as bs eqv\n  | _,     _,     eqv => false\n\nprotected def beq [BEq \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 Bool\n  | [],    []    => true\n  | a::as, b::bs => a == b && List.beq as bs\n  | _,     _     => false\n\ninstance [BEq \u03b1] : BEq (List \u03b1) := \u27e8List.beq\u27e9\n\ndef replicate {\u03b1 : Type u} (n : Nat) (a : \u03b1) : List \u03b1 :=\n  let rec loop : Nat \u2192 List \u03b1 \u2192 List \u03b1\n    | 0, as => as\n    | n+1, as => loop n (a::as)\n  loop n []\n\ndef dropLast {\u03b1} : List \u03b1 \u2192 List \u03b1\n  | []    => []\n  | [a]   => []\n  | a::as => a :: dropLast as\n\n@[simp] theorem length_replicate (n : Nat) (a : \u03b1) : (replicate n a).length = n :=\n  let rec aux (n : Nat) (as : List \u03b1) : (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 \u03b1) (a : \u03b1) : (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 \u03b1) (i : Nat) (a : \u03b1) : (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 \u03b1) : 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 \u03b1] [DecidableRel (@LT.lt \u03b1 _)] : List \u03b1 \u2192 Option \u03b1\n  | []    => none\n  | a::as => some <| as.foldl max a\n\ndef minimum? [LE \u03b1] [DecidableRel (@LE.le \u03b1 _)] : List \u03b1 \u2192 Option \u03b1\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u2192 name \u2192 expr\n| (local_const n _ bi d) pp := local_const n pp bi d\n| e n := e\n\nprivate meta def elim_or : \u2115 \u2192 expr \u2192 tactic (list expr)\n| 0       h := fail \"zero cases\"\n| 1       h := return [h]\n| (n + 1) h := do\n  [(_, [hl], []), (_, [hr], [])] \u2190 induction h, -- there should be no dependent terms\n  [gl, gr] \u2190 get_goals,\n  set_goals [gr],\n  hsr \u2190 elim_or n hr,\n  gsr \u2190 get_goals,\n  set_goals (gl :: gsr),\n  return (hl :: hsr)\n\nprivate meta def dest_or : expr \u2192 tactic (list expr) | e := do\n  `(%%a \u2228 %%b) \u2190 whnf e | return [e],\n  lb \u2190 dest_or b,\n  return (a :: lb)\n\nprivate meta def match_perms (pat : pattern) : expr \u2192 tactic (list $ list expr) | t :=\n  (do\n    m \u2190 match_pattern pat t,\n    guard (m.2.all expr.is_local_constant),\n    return [m.2]) <|>\n  (do\n    `(%%l \u2228 %%r) \u2190 whnf t,\n    m \u2190 match_pattern pat l,\n    rs \u2190 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 \u0393 \u2b1d vars \u2b1d cases \u22a2 \u2200deps, \u2026\n  nr \u2190 revert_lst (vars' ++ [h_cases]),\n  vars \u2190 intron' vars'.length,\n  h_cases \u2190 intro h_cases.local_pp_name,\n\n  cases \u2190 infer_type h_cases,\n  h_fst_case \u2190\n    mk_local_def h_cases.local_pp_name\n      (fst_case.instantiate_locals $ (vars'.zip vars).map $ \u03bb\u27e8o, n\u27e9, (o.local_uniq_name, n)),\n  ((), pr) \u2190 solve_aux cases (repeat $ exact h_fst_case <|> left >> skip),\n\n  t \u2190 target,\n  fixed_vars \u2190 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]) \u2190 local_proof `this t' (do\n    clear h_cases,\n    vars.mmap clear,\n    intron nr),\n\n  h\u2080 :: hs \u2190 elim_or perms.length h_cases,\n\n  solve1 (do\n    exact (h.mk_app $ vars ++ [h\u2080])),\n\n  focus ((hs.zip perms.tail).map $ \u03bb\u27e8h_case, perm\u27e9, do\n    let p_v := (vars'.zip vars).map (\u03bb\u27e8p, v\u27e9, (p.local_uniq_name, v)),\n    let p := perm.map (\u03bbp, p.instantiate_locals p_v),\n    note `this none (h.mk_app $ p ++ [h_case]),\n    clear h,\n    return ()),\n  gs \u2190 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)) \u2192 tactic (list (list expr))\n| none                    := return []\n| (some [])               := return []\n| (some perms@(p\u2080 :: ps)) := do\n  (guard p\u2080.nodup <|> fail\n    \"No permutation `xs_i` in `using [xs_1, \u2026, xs_n]` should contain the same variable twice.\"),\n  (guard (perms.all $ \u03bbp, p.perm p\u2080) <|>\n    fail (\"The permutations `xs_i` in `using [xs_1, \u2026, xs_n]` must be permutations of the same\" ++\n      \" variables.\")),\n  perms.mmap (\u03bbp, 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  `\u22a2 p xs_0 \u2228 \u22ef \u2228 p xs_n`\nThe main goal, i.e. the goal reduced to `xs_0`:\n  `(h : p xs_0) \u22a2 g xs_0`\nThe invariant goals, i.e. `g` is invariant under `xs_i`:\n  `(h : p xs_i) (this : g xs_0) \u22a2 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\u2080 \u2228 (p\u2081 \u2228 p\u2082)`. In many cases\nthe invariant goals can be solved by AC rewriting using `cc` etc.\n\nExample:\n  On a state `(n m : \u2115) \u22a2 p n m` the tactic `wlog h : n \u2264 m using [n m, m n]` produces the following\n  states:\n    `(n m : \u2115) \u22a2 n \u2264 m \u2228 m \u2264 n`\n    `(n m : \u2115) (h : n \u2264 m) \u22a2 p n m`\n    `(n m : \u2115) (h : m \u2264 n) (this : p n m) \u22a2 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, \u2026, xsn]`\n  Results in the case goal `p xs0 \u2228 \u22ef \u2228 ps xsn`, the main goal `(case : p xs0) \u22a2 g xs0` and the\n  invariance goals `(case : p xsi) (this : g xs0) \u22a2 g xsi`.\n\n(2) `wlog : p xs0 := r using xs0`\n  The expression `r` is a proof of the shape `p xs0 \u2228 \u22ef \u2228 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 \u2228 \u22ef \u2228 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 \u2228 R y x`. If `R` is \u2264, 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*) <|> (\u03bbx, [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 \u2190 parse_permutations perms,\n(pat, cases_pr, cases_goal, vars, perms) \u2190 (match cases with\n| some r := do\n  vars::_ \u2190 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 \u2190 to_expr r,\n  cases_pr \u2190 (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 \u2190 infer_type cases_pr,\n  (pat, perms') \u2190 match pat with\n  | some pat := do\n    pat \u2190 to_expr pat,\n    let vars' := vars.filter $ \u03bbv, v.occurs pat,\n    case_pat \u2190 mk_pattern [] vars' pat [] vars',\n    perms' \u2190 match_perms case_pat cases,\n    return (pat, perms')\n  | none := do\n    (p :: ps) \u2190 dest_or cases,\n    let vars' := vars.filter $ \u03bbv, v.occurs p,\n    case_pat \u2190 mk_pattern [] vars' p [] vars',\n    perms' \u2190 (p :: ps).mmap (\u03bbp, do m \u2190 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 $ \u03bbp, p.all $ \u03bbv, v.is_local_constant \u2227 v.local_uniq_name \u2208 vars_name) <|>\n    fail \"Cases contains variables not declared in `using x y z`\",\n  perms \u2190 (if perms.length = 1\n    then do\n      return (perms'.map $ \u03bb p,\n        p ++ vars.filter (\u03bb v, p.all (\u03bb v', v'.local_uniq_name \u2260 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 \u2190 return pat | fail \"Either specify cases or a pattern with permutations\",\n  pat \u2190 to_expr pat,\n  (do\n    [x, y] \u2190 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' \u2264 %%y') \u2190 return pat,\n      (cases_pr, []) \u2190 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]) \u2190 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 \u2265 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') \u2190 return perms,\n    let names := vars.map local_uniq_name,\n    let cases := mk_or_lst (pat :: perms'.map (\u03bbp, pat.instantiate_locals (names.zip p))),\n    (cases_pr, [g]) \u2190 local_proof name_h cases skip,\n    return (pat, cases_pr, some g, vars, perms))\nend),\nlet name_fn := if perms.length = 2 then \u03bb _, `invariant else\n  \u03bb i, mk_simple_name (\"invariant_\" ++ to_string (i + 1)),\nwith_enable_tags $ tactic.focus1 $ do\n  t \u2190 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 (\u03bbi, 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 \u2190 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 \u2192 Sort v}\n  (hvar : \u2200(k : fin n), C &k)\n  (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n  \u03a0 {l} (t : bounded_preterm L n l) (ts : dvector (bounded_term L n) l)\n  (ih_ts : \u2200s, ts.pmem s \u2192 C s), C (bd_apps t ts)\n| l (bd_var k) dvector.nil := \u03bb _, hvar k\n| l (bd_func f)  ts := \u03bb hs, hfunc f ts hs\n| l (bd_app t s) ts := \u03bb hs, bounded_term.rec2_aux t (dvector.cons s ts) $\n  \u03bb r hr, psum.cases_on hr\n    (\u03bb hrs, eq.rec_on hrs.symm (bounded_term.rec2_aux s dvector.nil $\n      \u03bb s\u2080 hs\u2080, false.elim $ by {cases hs\u2080}))\n    (hs _)\n\ndef bounded_term.rec2 {n} {C : bounded_term L n \u2192 Sort v}\n  (hvar : \u2200(k : fin n), C &k)\n  (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n  \u2200(t : bounded_term L n), C t :=\n\u03bbt, bounded_term.rec2_aux hvar (\u03bb _, hfunc) t dvector.nil (\u03bb s hs, false.elim $ by {cases hs})\n\n-- have h : \u2200{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\u2081 ([])) (f_ih_f\u2082 ([])), exact hall (f_ih ([]))\n-- end,\n-- \u03bbn f, h f ([])\n\ndef bounded_formula.rec2_aux {C : \u03a0n, bounded_formula L n \u2192 Sort v}\n  (hfalsum : \u03a0 {n}, C n \u22a5)\n  (hequal : \u03a0 {n} (t\u2081 t\u2082 : bounded_term L n), C n (t\u2081 \u2243 t\u2082))\n  (hrel : \u03a0 {n l : \u2115} (R : L.relations l) (ts : dvector (bounded_term L n) l),\n    C n (bd_apps_rel (bd_rel R) ts))\n  (himp : \u03a0 {n} {f\u2081 f\u2082 : bounded_formula L n} (ih\u2081 : C n f\u2081) (ih\u2082 : C n f\u2082), C n (f\u2081 \u27f9 f\u2082))\n  (hall : \u03a0 {n} {f : bounded_formula L (n+1)} (ih : C (n+1) f), C n (\u2200' f)) :\n  \u2200{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\u2081 \u2243 t\u2082) 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\u2081 \u27f9 f\u2082) dvector.nil := himp (bounded_formula.rec2_aux f\u2081 dvector.nil)\n  (bounded_formula.rec2_aux f\u2082 dvector.nil)\n| _ _ (\u2200' f)    dvector.nil := hall (bounded_formula.rec2_aux f dvector.nil)\n\ndef bounded_formula.rec2 {C : \u03a0n, bounded_formula L n \u2192 Sort v}\n  (hfalsum : \u03a0 {n}, C n \u22a5)\n  (hequal : \u03a0 {n} (t\u2081 t\u2082 : bounded_term L n), C n (t\u2081 \u2243 t\u2082))\n  (hrel : \u03a0 {n l : \u2115} (R : L.relations l) (ts : dvector (bounded_term L n) l),\n    C n (bd_apps_rel (bd_rel R) ts))\n  (himp : \u03a0 {n} {f\u2081 f\u2082 : bounded_formula L n} (ih\u2081 : C n f\u2081) (ih\u2082 : C n f\u2082), C n (f\u2081 \u27f9 f\u2082))\n  (hall : \u03a0 {n} {f : bounded_formula L (n+1)} (ih : C (n+1) f), C n (\u2200' f)) :\n  \u2200{n : \u2115} (f : bounded_formula L n), C n f :=\n\u03bb n f, bounded_formula.rec2_aux (\u03bb _, hfalsum) (\u03bb _, hequal) (\u03bb _ _, hrel) (\u03bb _ _ _, himp)\n  (\u03bb _ _, hall) f dvector.nil\n\n-- lemma bounded_term.rec2_aux_bd_apps {n} {C : bounded_term L n \u2192 Sort v}\n--   (hvar : \u2200(k : fin n), C &k)\n--   (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n--     (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n--   \u2200 {l} (t : bounded_preterm L n l) (ts : dvector (bounded_term L n) l)\n--     (ih_ts : \u2200t, ts.pmem t \u2192 C t),\n--   bounded_term.rec2_aux hvar (\u03bb _, 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 \u2192 Sort v}\n  (hvar : \u2200(k : fin n), C &k)\n  (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n  \u2200 (k : fin n),\n  bounded_term.rec2 hvar (\u03bb _, hfunc) &k = hvar k := \u03bb k, rfl\n\nlemma bounded_term.rec2_bd_apps {n} {C : bounded_term L n \u2192 Sort v}\n  (hvar : \u2200(k : fin n), C &k)\n  (hfunc : \u03a0 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t), C (bd_apps (bd_func f) ts)) :\n  \u2200 {l} (f : L.functions l) (ts : dvector (bounded_term L n) l)\n    (ih_ts : \u2200t, ts.pmem t \u2192 C t),\n  bounded_term.rec2 hvar (\u03bb _, 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 : \u2115)\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\u2099` (with arity zero given by `pempty`)\n  For each `\u27e8 n , f \u27e9 : \u03a3 n : \u2115, L.functions n` we have a function application (with arity `n`) -/\n@[reducible] def term_\u03b1 := ulift.{u} (fin n) \u2295 \u03a3 m : ulift.{u} \u2115, L.functions m.down\n\n/-- To define the arities in the `W_type` for `closed_term`.\n  For each `n : \u2115` we have a variable `x\u2099` (with arity zero given by `pempty`)\n  For each `\u27e8 n , f \u27e9 : \u03a3 n : \u2115, L.functions n` we have a function application (with arity `n`) -/\n@[reducible] def term_\u03b2 : \u03a0 (c : term_\u03b1.{u} L n), Type u\n| (sum.inl m) := pempty.{u+1}\n| (sum.inr \u27e8 m , f \u27e9) := ulift.{u} (fin m.down)\n\nvariable {L}\n\n/-- The forward map of the equivalence `W_type_term_\u03b2_equiv_closed_term` -/\n@[reducible] def bounded_term_of_W_type_term_\u03b2 : W_type (term_\u03b2 L n) \u2192 bounded_term L n\n| \u27e8 sum.inl m , b \u27e9 := x_ m.down\n| \u27e8 sum.inr (\u27e8 n , f \u27e9) , b \u27e9 := bd_apps (bd_func f)\n  (dvector.of_fn (\u03bb k, bounded_term_of_W_type_term_\u03b2 $ b (ulift.up k)))\n\n/-- The forward map of the equivalence `W_type_term_\u03b2_equiv_closed_term` -/\n@[reducible] def W_type_term_\u03b2_of_bounded_term : bounded_term L n \u2192 W_type (term_\u03b2 L n) :=\n  bounded_term.rec2\n    (\u03bb m, \u27e8 sum.inl \u27e8m\u27e9 , pempty.elim \u27e9) $\n    \u03bb l f ts rec,\n    \u27e8 sum.inr \u27e8 ulift.up l , f \u27e9, \u03bb k : ulift (fin l), rec (dvector.nth' ts $ k.down) dvector.pmem_nth' \u27e9\n\nlemma bounded_term_of_W_type_term_\u03b2_right_inv : \u2200 t : bounded_term L n,\n  bounded_term_of_W_type_term_\u03b2 n (W_type_term_\u03b2_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_\u03b2_of_bounded_term],\n    rw bounded_term.rec2_bd_apps _ _ _ _ (\u03bb t _, W_type_term_\u03b2_of_bounded_term n t),\n    dsimp [bounded_term_of_W_type_term_\u03b2],\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_\u03b2_surjective :\n  function.surjective (@bounded_term_of_W_type_term_\u03b2 L n) :=\nbegin\n  intros t,\n  use W_type_term_\u03b2_of_bounded_term n t,\n  exact bounded_term_of_W_type_term_\u03b2_right_inv _ _,\nend\n\nlemma fintype_term_\u03b2 : \u03a0 (a : term_\u03b1 L n), fintype (term_\u03b2 L n a)\n| (sum.inl \u27e8 m \u27e9) := by apply_instance\n| (sum.inr \u27e8 m , f \u27e9) := fintype.of_equiv (fin m.down) equiv.ulift.symm\n\nlocal attribute [instance] fintype_term_\u03b2\n\nlemma bounded_term_le_functions : #(bounded_term L n) \u2264\n  max (cardinal.sum (\u03bb n : ulift.{u} (\u2115), #(L.functions n.down))) \u03c9 :=\ncalc #(bounded_term L n)\n      \u2264 #(W_type (term_\u03b2.{u} L n)) :\n    cardinal.mk_le_of_surjective (bounded_term_of_W_type_term_\u03b2_surjective n)\n  ... \u2264 max (# (ulift.{u} (fin n) \u2295 \u03a3 (m : ulift.{u} \u2115), L.functions m.down)) \u03c9 :\n    W_type.cardinal_mk_le_max_omega_of_fintype\n  ... \u2264 max (#(\u03a3 n : ulift.{u} \u2115, L.functions n.down)) \u03c9 :\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 (\u03bb n : ulift.{u} \u2115, #(L.functions n.down))) \u03c9 :\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  | \u22a5           | unit                 | empty |\n  | t\u2081 \u2243 t\u2082     | (bounded_term L n)\u00b2  | empty |\n  | \u27f9           | unit                 | bool  |\n  ```\n  This gives us a way of injecting `bounded_formula L n`\n  into `W_type \u03b2 n \u2295 bounded_formula L (n+1)` (to account for `\u2200`) (there are no relations).\n  This ultimately gives us\n  `bounded_formula L 0 \u21aa \u03a3 n : \u2115, W_type \u03b2 n ` where instead of\n  mapping into `bounded_formula L (n+1)` we map into the next `W_type \u03b2 (n+1)`.\n  We have bounds on each `W_type \u03b2 n`, namely by `unit`, `(bounded_term L n)\u00b2` and `\u03c9`.\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 : \u2115 \u2192 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 `\u2295` `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_\u03b1 : Type u := punit.{u+1} \u2295 ((bounded_term L n) \u00d7 (bounded_term L n)) \u2295 punit.{u+1}\n\n/-- The arities of the constructors `formula_\u03b1` for the `W_type` -/\ndef formula_\u03b2 : formula_\u03b1 L n \u2192 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 \u2192 W_type (formula_\u03b2 L n) :=\nbounded_formula.rec2\n  (\u03bb _, \u27e8 sum.inl punit.star , pempty.elim \u27e9) -- bd_falsum\n  (\u03bb _ t s, \u27e8 sum.inr $ sum.inl \u27e8 t , s \u27e9 , pempty.elim \u27e9) -- t \u2243 s\n  (\u03bb _ l r, false.elim $ Language.is_algebraic.empty_relations l r) -- there are no relation symbols\n  (\u03bb _ f\u2081 f\u2082 recf\u2081 recf\u2082, \u27e8 sum.inr $ sum.inr punit.star , \u03bb \u27e8b\u27e9, bool.rec_on b recf\u2081 recf\u2082 \u27e9 )\n    -- bd_imp\n  (\u03bb _ _ _, \u27e8 sum.inl punit.star , pempty.elim \u27e9) -- 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 `\u27f9` case,\n  it is important to define it without the `\u2200` first.\n  For the recursion to work in the `\u2200` 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 \u2192 W_type (formula_\u03b2 L n) \u2295 bounded_formula L (n+1) :=\nbounded_formula.rec2\n  (\u03bb k, sum.inl (W_type_of_bounded_formula \u22a5)) -- bd_falsum\n  (\u03bb _ t s, sum.inl (W_type_of_bounded_formula (t \u2243 s))) -- t \u2243 s\n  (\u03bb _ l r, false.elim $ Language.is_algebraic.empty_relations l r) -- there are no relation symbols\n  (\u03bb _ f\u2081 f\u2082 recf\u2081 recf\u2082, sum.inl (W_type_of_bounded_formula (f\u2081 \u27f9 f\u2082))) -- bd_imp\n  (\u03bb _ 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_\u03b2 L n) \u2192 bounded_formula L n\n| \u27e8 (sum.inl x) , y \u27e9 := \u22a5\n| \u27e8 (sum.inr (sum.inl \u27e8 t , s \u27e9)) , y \u27e9 := t \u2243 s\n| \u27e8 (sum.inr (sum.inr x)) , y \u27e9 :=\n  bounded_formula_of_W_type (y $ \u27e8 tt \u27e9) \u27f9\n  bounded_formula_of_W_type (y $ \u27e8 ff \u27e9)\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_\u03b2 L n) \u2295 bounded_formula L (n+1) \u2192 bounded_formula L n\n| (sum.inl x) := bounded_formula_of_W_type x\n| (sum.inr f) := \u2200' f\n\nlemma bounded_formula_of_W_type_right_inv\n  [is_algebraic L] {n} : \u2200 f : bounded_formula L n,\n  ((\u2200 g : bounded_formula L (n+1), f \u2260 \u2200' g) \u2192\n    bounded_formula_of_W_type (W_type_of_bounded_formula f) = f) :=\nbegin\n  apply @bounded_formula.rec2 _\n    (\u03bb (n : \u2115) f : bounded_formula L n, (\u2200 g : bounded_formula L (n+1), f \u2260 \u2200' g) \u2192\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} : \u2200 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\u2081 f\u2082,\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) \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(bounded_term L n.down))) \u03c9 :=\nsorry\n\nlemma sentence_le_functions :\n  #(bounded_formula L 0) \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(L.functions n.down))) \u03c9 :=\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 `\u2200` is an injection downwards. -/\ndef bounded_formula_bd_all : bounded_formula L (n+1) \u2192 (bounded_formula L n) :=\n\u03bb \u03d5, \u2200' \u03d5\n\n/-- Applying `\u2200` n times is an injection. \"Dropbox\" -/\ndef bounded_formula_bd_alls : \u03a0 n, bounded_formula L n \u2192 (bounded_formula L 0)\n| 0 := id\n| (n+1) := (bounded_formula_bd_alls n) \u2218 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\u03bb \u03d5 \u03c8, bounded_preformula.bd_all.inj\n\nlemma bounded_formula_bd_alls_injective : \u03a0 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 \u2200 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 : \u2115) :\n  #(bounded_formula L n) \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(L.functions n.down))) \u03c9 :=\ncalc #(bounded_formula L n) \u2264 #(bounded_formula L 0) : cardinal.mk_le_of_injective (bounded_formula_bd_alls_injective _)\n                        ... \u2264 max (cardinal.sum (\u03bb n : ulift.{u} \u2115, #(L.functions n.down))) \u03c9 :\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 {\u03b1} [discrete_linear_ordered_field \u03b1]\n  {\u03b2} [ring \u03b2] (f : \u03b2 \u2192 \u03b1) : Prop :=\n(abv_nonneg : \u2200 x, 0 \u2264 f x)\n(abv_eq_zero : \u2200 {x}, f x = 0 \u2194 x = 0)\n(abv_add : \u2200 x y, f (x + y) \u2264 f x + f y)\n(abv_mul : \u2200 x y, f (x * y) = f x * f y)\n\nnamespace is_absolute_value\nvariables {\u03b1 : Type*} [discrete_linear_ordered_field \u03b1]\n  {\u03b2 : Type*} [ring \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv]\n\ntheorem abv_zero : abv 0 = 0 := (abv_eq_zero abv).2 rfl\n\ntheorem abv_one' (h : (1:\u03b2) \u2260 0) : abv 1 = 1 :=\n(domain.mul_left_inj $ mt (abv_eq_zero abv).1 h).1 $\nby rw [\u2190 abv_mul abv, mul_one, mul_one]\n\ntheorem abv_one\n  {\u03b2 : Type*} [domain \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv] :\n  abv 1 = 1 := abv_one' abv one_ne_zero\n\ntheorem abv_pos {a : \u03b2} : 0 < abv a \u2194 a \u2260 0 :=\nby rw [lt_iff_le_and_ne, ne, eq_comm]; simp [abv_eq_zero abv, abv_nonneg abv]\n\ntheorem abv_neg (a : \u03b2) : abv (-a) = abv a :=\nby rw [\u2190 mul_self_inj_of_nonneg (abv_nonneg abv _) (abv_nonneg abv _),\n  \u2190 abv_mul abv, \u2190 abv_mul abv]; simp\n\ntheorem abv_sub (a b : \u03b2) : abv (a - b) = abv (b - a) :=\nby rw [\u2190 neg_sub, abv_neg abv]\n\ntheorem abv_inv\n  {\u03b2 : Type*} [discrete_field \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv]\n  (a : \u03b2) : abv a\u207b\u00b9 = (abv a)\u207b\u00b9 :=\nclassical.by_cases\n  (\u03bb h : a = 0, by simp [h, abv_zero abv])\n  (\u03bb h, (domain.mul_left_inj (mt (abv_eq_zero abv).1 h)).1 $\n    by rw [\u2190 abv_mul abv]; simp [h, mt (abv_eq_zero abv).1 h, abv_one abv])\n\ntheorem abv_div\n  {\u03b2 : Type*} [discrete_field \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv]\n  (a b : \u03b2) : 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 : \u03b2) : abv (a - c) \u2264 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 : \u03b2) : abv a - abv b \u2264 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 : \u03b2) :\n  abs (abv a - abv b) \u2264 abv (a - b) :=\nabs_sub_le_iff.2 \u27e8sub_abv_le_abv_sub abv _ _,\n  by rw abv_sub abv; apply sub_abv_le_abv_sub abv\u27e9\n\nend is_absolute_value\n\ninstance abs_is_absolute_value {\u03b1} [discrete_linear_ordered_field \u03b1] :\n  is_absolute_value (abs : \u03b1 \u2192 \u03b1) :=\n{ abv_nonneg  := abs_nonneg,\n  abv_eq_zero := \u03bb _, abs_eq_zero,\n  abv_add     := abs_add,\n  abv_mul     := abs_mul }\n\nopen is_absolute_value\n\ntheorem exists_forall_ge_and {\u03b1} [linear_order \u03b1] {P Q : \u03b1 \u2192 Prop} :\n  (\u2203 i, \u2200 j \u2265 i, P j) \u2192 (\u2203 i, \u2200 j \u2265 i, Q j) \u2192\n  \u2203 i, \u2200 j \u2265 i, P j \u2227 Q j\n| \u27e8a, h\u2081\u27e9 \u27e8b, h\u2082\u27e9 := let \u27e8c, ac, bc\u27e9 := exists_ge_of_linear a b in\n  \u27e8c, \u03bb j hj, \u27e8h\u2081 _ (le_trans ac hj), h\u2082 _ (le_trans bc hj)\u27e9\u27e9\n\nsection\nvariables {\u03b1 : Type*} [discrete_linear_ordered_field \u03b1]\n  {\u03b2 : Type*} [ring \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv]\n\ntheorem rat_add_continuous_lemma\n  {\u03b5 : \u03b1} (\u03b50 : 0 < \u03b5) : \u2203 \u03b4 > 0, \u2200 {a\u2081 a\u2082 b\u2081 b\u2082 : \u03b2},\n  abv (a\u2081 - b\u2081) < \u03b4 \u2192 abv (a\u2082 - b\u2082) < \u03b4 \u2192 abv (a\u2081 + a\u2082 - (b\u2081 + b\u2082)) < \u03b5 :=\n\u27e8\u03b5 / 2, half_pos \u03b50, \u03bb a\u2081 a\u2082 b\u2081 b\u2082 h\u2081 h\u2082,\n  by simpa [add_halves] using lt_of_le_of_lt (abv_add abv _ _) (add_lt_add h\u2081 h\u2082)\u27e9\n\ntheorem rat_mul_continuous_lemma\n  {\u03b5 K\u2081 K\u2082 : \u03b1} (\u03b50 : 0 < \u03b5) (K\u20810 : 0 < K\u2081) (K\u20820 : 0 < K\u2082) :\n  \u2203 \u03b4 > 0, \u2200 {a\u2081 a\u2082 b\u2081 b\u2082 : \u03b2}, abv a\u2081 < K\u2081 \u2192 abv b\u2082 < K\u2082 \u2192\n  abv (a\u2081 - b\u2081) < \u03b4 \u2192 abv (a\u2082 - b\u2082) < \u03b4 \u2192 abv (a\u2081 * a\u2082 - b\u2081 * b\u2082) < \u03b5 :=\nbegin\n  have K0 := lt_of_lt_of_le K\u20810 (le_max_left _ K\u2082),\n  have \u03b5K := div_pos (half_pos \u03b50) K0,\n  refine \u27e8_, \u03b5K, \u03bb a\u2081 a\u2082 b\u2081 b\u2082 ha\u2081 hb\u2082 h\u2081 h\u2082, _\u27e9,\n  replace ha\u2081 := lt_of_lt_of_le ha\u2081 (le_max_left _ K\u2082),\n  replace hb\u2082 := lt_of_lt_of_le hb\u2082 (le_max_right K\u2081 _),\n  have := add_lt_add\n    (mul_lt_mul' (le_of_lt h\u2081) hb\u2082 (abv_nonneg abv _) \u03b5K)\n    (mul_lt_mul' (le_of_lt h\u2082) ha\u2081 (abv_nonneg abv _) \u03b5K),\n  rw [\u2190 abv_mul abv, mul_comm, div_mul_cancel _ (ne_of_gt K0), \u2190 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  {\u03b2 : Type*} [discrete_field \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv]\n  {\u03b5 K : \u03b1} (\u03b50 : 0 < \u03b5) (K0 : 0 < K) :\n  \u2203 \u03b4 > 0, \u2200 {a b : \u03b2}, K \u2264 abv a \u2192 K \u2264 abv b \u2192\n  abv (a - b) < \u03b4 \u2192 abv (a\u207b\u00b9 - b\u207b\u00b9) < \u03b5 :=\nbegin\n  have KK := mul_pos K0 K0,\n  have \u03b5K := mul_pos \u03b50 KK,\n  refine \u27e8_, \u03b5K, \u03bb a b ha hb h, _\u27e9,\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      \u2190 mul_div_cancel \u03b5 (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 \u03b50 KK) KK\nend\nend\n\ndef is_cau_seq {\u03b1 : Type*} [discrete_linear_ordered_field \u03b1]\n  {\u03b2 : Type*} [ring \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv] (f : \u2115 \u2192 \u03b2) :=\n\u2200 \u03b5 > 0, \u2203 i, \u2200 j \u2265 i, abv (f j - f i) < \u03b5\n\nnamespace is_cau_seq\nvariables {\u03b1 : Type*} [discrete_linear_ordered_field \u03b1]\n  {\u03b2 : Type*} [ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv] {f : \u2115 \u2192 \u03b2}\n\ntheorem cauchy\u2082 (hf : is_cau_seq abv f) {\u03b5:\u03b1} (\u03b50 : \u03b5 > 0) :\n  \u2203 i, \u2200 j k \u2265 i, abv (f j - f k) < \u03b5 :=\nbegin\n  refine (hf _ (half_pos \u03b50)).imp (\u03bb i hi j k ij ik, _),\n  rw \u2190 add_halves \u03b5,\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\u2083 (hf : is_cau_seq abv f) {\u03b5:\u03b1} (\u03b50 : \u03b5 > 0) :\n  \u2203 i, \u2200 j \u2265 i, \u2200 k \u2265 j, abv (f k - f j) < \u03b5 :=\nlet \u27e8i, H\u27e9 := hf.cauchy\u2082 \u03b50 in \u27e8i, \u03bb j ij k jk, H _ _ (le_trans ij jk) ij\u27e9\n\nend is_cau_seq\n\ndef cau_seq {\u03b1 : Type*} [discrete_linear_ordered_field \u03b1]\n  (\u03b2 : Type*) [ring \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv] :=\n{f : \u2115 \u2192 \u03b2 // is_cau_seq abv f}\n\nnamespace cau_seq\nvariables {\u03b1 : Type*} [discrete_linear_ordered_field \u03b1]\n\nsection ring\nvariables {\u03b2 : Type*} [ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv]\n\ninstance : has_coe_to_fun (cau_seq \u03b2 abv) := \u27e8_, subtype.val\u27e9\n\n@[simp] theorem mk_to_fun (f) (hf : is_cau_seq abv f) :\n  @coe_fn (cau_seq \u03b2 abv) _ \u27e8f, hf\u27e9 = f := rfl\n\ntheorem ext {f g : cau_seq \u03b2 abv} (h : \u2200 i, f i = g i) : f = g :=\nsubtype.eq (funext h)\n\ntheorem is_cau (f : cau_seq \u03b2 abv) : is_cau_seq abv f := f.2\n\ntheorem cauchy (f : cau_seq \u03b2 abv) :\n  \u2200 {\u03b5}, \u03b5 > 0 \u2192 \u2203 i, \u2200 j \u2265 i, abv (f j - f i) < \u03b5 := f.2\n\ntheorem cauchy\u2082 (f : cau_seq \u03b2 abv) {\u03b5:\u03b1} : \u03b5 > 0 \u2192\n  \u2203 i, \u2200 j k \u2265 i, abv (f j - f k) < \u03b5 := f.2.cauchy\u2082\n\ntheorem cauchy\u2083 (f : cau_seq \u03b2 abv) {\u03b5:\u03b1} : \u03b5 > 0 \u2192\n  \u2203 i, \u2200 j \u2265 i, \u2200 k \u2265 j, abv (f k - f j) < \u03b5 := f.2.cauchy\u2083\n\ntheorem bounded (f : cau_seq \u03b2 abv) : \u2203 r, \u2200 i, abv (f i) < r :=\nbegin\n  cases f.cauchy zero_lt_one with i h,\n  let R := (finset.range (i+1)).sum (\u03bb j, abv (f j)),\n  have : \u2200 j \u2264 i, abv (f j) \u2264 R,\n  { intros j ij, change (\u03bb j, abv (f j)) j \u2264 R,\n    apply finset.single_le_sum,\n    { intros, apply abv_nonneg abv },\n    { rwa [finset.mem_range, nat.lt_succ_iff] } },\n  refine \u27e8R + 1, \u03bb j, _\u27e9,\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 \u03b2 abv) (x : \u03b1) : \u2203 r > x, \u2200 i, abv (f i) < r :=\nlet \u27e8r, h\u27e9 := f.bounded in\n\u27e8max r (x+1), lt_of_lt_of_le (lt_add_one _) (le_max_right _ _),\n  \u03bb i, lt_of_lt_of_le (h i) (le_max_left _ _)\u27e9\n\ndef of_eq (f : cau_seq \u03b2 abv) (g : \u2115 \u2192 \u03b2) (e : \u2200 i, f i = g i) : cau_seq \u03b2 abv :=\n\u27e8g, \u03bb \u03b5, by rw [show g = f, from (funext e).symm]; exact f.cauchy\u27e9\n\ninstance : has_add (cau_seq \u03b2 abv) :=\n\u27e8\u03bb f g, \u27e8\u03bb i, (f i + g i : \u03b2), \u03bb \u03b5 \u03b50,\n  let \u27e8\u03b4, \u03b40, H\u03b4\u27e9 := rat_add_continuous_lemma abv \u03b50,\n      \u27e8i, H\u27e9 := exists_forall_ge_and (f.cauchy\u2083 \u03b40) (g.cauchy\u2083 \u03b40) in\n  \u27e8i, \u03bb j ij, let \u27e8H\u2081, H\u2082\u27e9 := H _ (le_refl _) in H\u03b4 (H\u2081 _ ij) (H\u2082 _ ij)\u27e9\u27e9\u27e9\n\n@[simp] theorem add_apply (f g : cau_seq \u03b2 abv) (i : \u2115) : (f + g) i = f i + g i := rfl\n\nvariable (abv)\ndef const (x : \u03b2) : cau_seq \u03b2 abv :=\n\u27e8\u03bb i, x, \u03bb \u03b5 \u03b50, \u27e80, \u03bb j ij, by simpa [abv_zero abv] using \u03b50\u27e9\u27e9\nvariable {abv}\n\nlocal notation `const` := const abv\n\n@[simp] theorem const_apply (x : \u03b2) (i : \u2115) : (const x : \u2115 \u2192 \u03b2) i = x := rfl\n\ntheorem const_inj {x y : \u03b2} : (const x : cau_seq \u03b2 abv) = const y \u2194 x = y :=\n\u27e8\u03bb h, congr_arg (\u03bb f:cau_seq \u03b2 abv, (f:\u2115\u2192\u03b2) 0) h, congr_arg _\u27e9\n\ninstance : has_zero (cau_seq \u03b2 abv) := \u27e8const 0\u27e9\ninstance : has_one (cau_seq \u03b2 abv) := \u27e8const 1\u27e9\n\n@[simp] theorem zero_apply (i) : (0 : cau_seq \u03b2 abv) i = 0 := rfl\n@[simp] theorem one_apply (i) : (1 : cau_seq \u03b2 abv) i = 1 := rfl\n\ntheorem const_add (x y : \u03b2) : const (x + y) = const x + const y :=\next $ \u03bb i, rfl\n\ninstance : has_mul (cau_seq \u03b2 abv) :=\n\u27e8\u03bb f g, \u27e8\u03bb i, (f i * g i : \u03b2), \u03bb \u03b5 \u03b50,\n  let \u27e8F, F0, hF\u27e9 := f.bounded' 0, \u27e8G, G0, hG\u27e9 := g.bounded' 0,\n      \u27e8\u03b4, \u03b40, H\u03b4\u27e9 := rat_mul_continuous_lemma abv \u03b50 F0 G0,\n      \u27e8i, H\u27e9 := exists_forall_ge_and (f.cauchy\u2083 \u03b40) (g.cauchy\u2083 \u03b40) in\n  \u27e8i, \u03bb j ij, let \u27e8H\u2081, H\u2082\u27e9 := H _ (le_refl _) in\n    H\u03b4 (hF j) (hG i) (H\u2081 _ ij) (H\u2082 _ ij)\u27e9\u27e9\u27e9\n\n@[simp] theorem mul_apply (f g : cau_seq \u03b2 abv) (i : \u2115) : (f * g) i = f i * g i := rfl\n\ntheorem const_mul (x y : \u03b2) : const (x * y) = const x * const y :=\next $ \u03bb i, rfl\n\ninstance : has_neg (cau_seq \u03b2 abv) :=\n\u27e8\u03bb f, of_eq (const (-1) * f) (\u03bb x, -f x) (\u03bb i, by simp)\u27e9\n\n@[simp] theorem neg_apply (f : cau_seq \u03b2 abv) (i) : (-f) i = -f i := rfl\n\ntheorem const_neg (x : \u03b2) : const (-x) = -const x :=\next $ \u03bb i, rfl\n\ninstance : ring (cau_seq \u03b2 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 {\u03b2 : Type*} [comm_ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv] : comm_ring (cau_seq \u03b2 abv) :=\n{ mul_comm := by intros; apply ext; simp [mul_left_comm, mul_comm],\n  ..cau_seq.ring }\n\ntheorem const_sub (x y : \u03b2) : 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 \u03b2 abv) (i : \u2115) : (f - g) i = f i - g i := rfl\n\ndef lim_zero (f : cau_seq \u03b2 abv) := \u2200 \u03b5 > 0, \u2203 i, \u2200 j \u2265 i, abv (f j) < \u03b5\n\ntheorem add_lim_zero {f g : cau_seq \u03b2 abv}\n  (hf : lim_zero f) (hg : lim_zero g) : lim_zero (f + g)\n| \u03b5 \u03b50 := (exists_forall_ge_and\n    (hf _ $ half_pos \u03b50) (hg _ $ half_pos \u03b50)).imp $\n  \u03bb i H j ij, let \u27e8H\u2081, H\u2082\u27e9 := H _ ij in\n    by simpa [add_halves \u03b5] using lt_of_le_of_lt (abv_add abv _ _) (add_lt_add H\u2081 H\u2082)\n\ntheorem mul_lim_zero (f : cau_seq \u03b2 abv) {g}\n  (hg : lim_zero g) : lim_zero (f * g)\n| \u03b5 \u03b50 := let \u27e8F, F0, hF\u27e9 := f.bounded' 0 in\n  (hg _ $ div_pos \u03b50 F0).imp $ \u03bb 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), \u2190 abv_mul abv] at this\n\ntheorem neg_lim_zero {f : cau_seq \u03b2 abv} (hf : lim_zero f) : lim_zero (-f) :=\nby rw \u2190 neg_one_mul; exact mul_lim_zero _ hf\n\ntheorem sub_lim_zero {f g : cau_seq \u03b2 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 \u03b2 abv)\n| \u03b5 \u03b50 := \u27e80, \u03bb j ij, by simpa [abv_zero abv] using \u03b50\u27e9\n\ntheorem const_lim_zero {x : \u03b2} : lim_zero (const x) \u2194 x = 0 :=\n\u27e8\u03bb H, (abv_eq_zero abv).1 $\n  eq_of_le_of_forall_le_of_dense (abv_nonneg abv _) $\n  \u03bb \u03b5 \u03b50, let \u27e8i, hi\u27e9 := H _ \u03b50 in le_of_lt $ hi _ (le_refl _),\n\u03bb e, e.symm \u25b8 zero_lim_zero\u27e9\n\ninstance equiv : setoid (cau_seq \u03b2 abv) :=\n\u27e8\u03bb f g, lim_zero (f - g),\n\u27e8\u03bb f, by simp [zero_lim_zero],\n \u03bb f g h, by simpa using neg_lim_zero h,\n \u03bb f g h fg gh, by simpa using add_lim_zero fg gh\u27e9\u27e9\n\ntheorem equiv_def\u2083 {f g : cau_seq \u03b2 abv} (h : f \u2248 g) {\u03b5:\u03b1} (\u03b50 : 0 < \u03b5) :\n  \u2203 i, \u2200 j \u2265 i, \u2200 k \u2265 j, abv (f k - g j) < \u03b5 :=\n(exists_forall_ge_and (h _ $ half_pos \u03b50) (f.cauchy\u2083 $ half_pos \u03b50)).imp $\n\u03bb i H j ij k jk, let \u27e8h\u2081, h\u2082\u27e9 := H _ ij in\nby have := lt_of_le_of_lt (abv_add abv (f j - g j) _) (add_lt_add h\u2081 (h\u2082 _ jk));\n   rwa [sub_add_sub_cancel', add_halves] at this\n\ntheorem lim_zero_congr {f g : cau_seq \u03b2 abv} (h : f \u2248 g) : lim_zero f \u2194 lim_zero g :=\n\u27e8\u03bb l, by simpa using add_lim_zero (setoid.symm h) l,\n \u03bb l, by simpa using add_lim_zero h l\u27e9\n\ntheorem abv_pos_of_not_lim_zero {f : cau_seq \u03b2 abv} (hf : \u00ac lim_zero f) :\n  \u2203 K > 0, \u2203 i, \u2200 j \u2265 i, K \u2264 abv (f j) :=\nbegin\n  haveI := classical.prop_decidable,\n  by_contra nk,\n  refine hf (\u03bb \u03b5 \u03b50, _),\n  simp [not_forall] at nk,\n  cases f.cauchy\u2083 (half_pos \u03b50) with i hi,\n  rcases nk _ (half_pos \u03b50) i with \u27e8j, ij, hj\u27e9,\n  refine \u27e8j, \u03bb k jk, _\u27e9,\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 : \u2115 \u2192 \u03b2) (g : cau_seq \u03b2 abv)\n  (h : \u2200 \u03b5 > 0, \u2203 i, \u2200 j \u2265 i, abv (f j - g j) < \u03b5) : is_cau_seq abv f\n| \u03b5 \u03b50 :=\n  let \u27e8i, hi\u27e9 := exists_forall_ge_and\n    (h _ (half_pos $ half_pos \u03b50)) (g.cauchy\u2083 $ half_pos \u03b50) in\n  \u27e8i, \u03bb j ij, begin\n    cases hi _ (le_refl _) with h\u2081 h\u2082, rw abv_sub abv at h\u2081,\n    have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add (hi _ ij).1 h\u2081),\n    have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add this (h\u2082 _ ij)),\n    rwa [add_halves, add_halves, add_right_comm,\n         sub_add_sub_cancel, sub_add_sub_cancel] at this\n  end\u27e9\n\nlemma not_lim_zero_of_not_congr_zero {f : cau_seq _ abv} (hf : \u00ac f \u2248 0) : \u00ac 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 \u2248 0) : g * f \u2248 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 : \u00ac f \u2248 0) (hg : \u00ac g \u2248 0) : \u00ac (f * g) \u2248 0 :=\nassume : lim_zero (f*g - 0),\nhave hlz : lim_zero (f*g), by simpa,\nhave hf' : \u00ac lim_zero f, by simpa using (show \u00ac lim_zero (f - 0), from hf),\nhave hg' : \u00ac lim_zero g, by simpa using (show \u00ac lim_zero (g - 0), from hg),\nbegin \n  rcases abv_pos_of_not_lim_zero hf' with \u27e8a1, ha1, N1, hN1\u27e9,\n  rcases abv_pos_of_not_lim_zero hg' with \u27e8a2, ha2, N2, hN2\u27e9,\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 _ \u2264 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 {\u03b2 : Type*} [comm_ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv]\n\nlemma mul_equiv_zero' (g : cau_seq _ abv) {f : cau_seq _ abv} (hf : f \u2248 0) : f * g \u2248 0 :=\nby rw mul_comm; apply mul_equiv_zero _ hf\n\nend comm_ring \n\nsection integral_domain\nvariables {\u03b2 : Type*} [integral_domain \u03b2] (abv : \u03b2 \u2192 \u03b1) [is_absolute_value abv]\n\nlemma one_not_equiv_zero : \u00ac (const abv 1) \u2248 (const abv 0) :=\nassume h,\nhave \u2200 \u03b5 > 0, \u2203 i, \u2200 k, k \u2265 i \u2192 abv (1 - 0) < \u03b5, from h,\nhave h1 : abv 1 \u2264 0, from le_of_not_gt $\n  assume h2 : abv 1 > 0,\n  exists.elim (this _ h2) $ \u03bb i hi,\n    lt_irrefl (abv 1) $ by simpa using hi _ (le_refl _),\nhave h2 : abv 1 \u2265 0, from is_absolute_value.abv_nonneg _ _,\nhave abv 1 = 0, from le_antisymm h1 h2,\nhave (1 : \u03b2) = 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 {\u03b2 : Type*} [discrete_field \u03b2] {abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv]\n\ntheorem inv_aux {f : cau_seq \u03b2 abv} (hf : \u00ac lim_zero f) :\n  \u2200 \u03b5 > 0, \u2203 i, \u2200 j \u2265 i, abv ((f j)\u207b\u00b9 - (f i)\u207b\u00b9) < \u03b5 | \u03b5 \u03b50 :=\nlet \u27e8K, K0, HK\u27e9 := abv_pos_of_not_lim_zero hf,\n    \u27e8\u03b4, \u03b40, H\u03b4\u27e9 := rat_inv_continuous_lemma abv \u03b50 K0,\n    \u27e8i, H\u27e9 := exists_forall_ge_and HK (f.cauchy\u2083 \u03b40) in\n\u27e8i, \u03bb j ij, let \u27e8iK, H'\u27e9 := H _ (le_refl _) in H\u03b4 (H _ ij).1 iK (H' _ ij)\u27e9\n\ndef inv (f) (hf : \u00ac lim_zero f) : cau_seq \u03b2 abv := \u27e8_, inv_aux hf\u27e9\n\n@[simp] theorem inv_apply {f : cau_seq \u03b2 abv} (hf i) : inv f hf i = (f i)\u207b\u00b9 := rfl\n\ntheorem inv_mul_cancel {f : cau_seq \u03b2 abv} (hf) : inv f hf * f \u2248 1 :=\n\u03bb \u03b5 \u03b50, let \u27e8K, K0, i, H\u27e9 := abv_pos_of_not_lim_zero hf in\n\u27e8i, \u03bb j ij,\n  by simpa [(abv_pos abv).1 (lt_of_lt_of_le K0 (H _ ij)),\n    abv_zero abv] using \u03b50\u27e9\n\ntheorem const_inv {x : \u03b2} (hx : x \u2260 0) : const abv (x\u207b\u00b9) = 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 \u03b1 abs) : Prop := \u2203 K > 0, \u2203 i, \u2200 j \u2265 i, K \u2264 f j\n\ntheorem not_lim_zero_of_pos {f : cau_seq \u03b1 abs} : pos f \u2192 \u00ac lim_zero f\n| \u27e8F, F0, hF\u27e9 H :=\n  let \u27e8i, h\u27e9 := exists_forall_ge_and hF (H _ F0),\n      \u27e8h\u2081, h\u2082\u27e9 := h _ (le_refl _) in\n  not_lt_of_le h\u2081 (abs_lt.1 h\u2082).2\n\ntheorem const_pos {x : \u03b1} : pos (const x) \u2194 0 < x :=\n\u27e8\u03bb \u27e8K, K0, i, h\u27e9, lt_of_lt_of_le K0 (h _ (le_refl _)),\n \u03bb h, \u27e8x, h, 0, \u03bb j _, le_refl _\u27e9\u27e9\n\ntheorem add_pos {f g : cau_seq \u03b1 abs} : pos f \u2192 pos g \u2192 pos (f + g)\n| \u27e8F, F0, hF\u27e9 \u27e8G, G0, hG\u27e9 :=\n  let \u27e8i, h\u27e9 := exists_forall_ge_and hF hG in\n  \u27e8_, _root_.add_pos F0 G0, i,\n    \u03bb j ij, let \u27e8h\u2081, h\u2082\u27e9 := h _ ij in add_le_add h\u2081 h\u2082\u27e9\n\ntheorem pos_add_lim_zero {f g : cau_seq \u03b1 abs} : pos f \u2192 lim_zero g \u2192 pos (f + g)\n| \u27e8F, F0, hF\u27e9 H :=\n  let \u27e8i, h\u27e9 := exists_forall_ge_and hF (H _ (half_pos F0)) in\n  \u27e8_, half_pos F0, i, \u03bb j ij, begin\n    cases h j ij with h\u2081 h\u2082,\n    have := add_le_add h\u2081 (le_of_lt (abs_lt.1 h\u2082).1),\n    rwa [\u2190 sub_eq_add_neg, sub_self_div_two] at this\n  end\u27e9\n\ntheorem mul_pos {f g : cau_seq \u03b1 abs} : pos f \u2192 pos g \u2192 pos (f * g)\n| \u27e8F, F0, hF\u27e9 \u27e8G, G0, hG\u27e9 :=\n  let \u27e8i, h\u27e9 := exists_forall_ge_and hF hG in\n  \u27e8_, _root_.mul_pos F0 G0, i,\n    \u03bb j ij, let \u27e8h\u2081, h\u2082\u27e9 := h _ ij in\n    mul_le_mul h\u2081 h\u2082 (le_of_lt G0) (le_trans (le_of_lt F0) h\u2081)\u27e9\n\ntheorem trichotomy (f : cau_seq \u03b1 abs) : pos f \u2228 lim_zero f \u2228 pos (-f) :=\nbegin\n  cases classical.em (lim_zero f); simp *,\n  rcases abv_pos_of_not_lim_zero h with \u27e8K, K0, hK\u27e9,\n  rcases exists_forall_ge_and hK (f.cauchy\u2083 K0) with \u27e8i, hi\u27e9,\n  refine (le_total 0 (f i)).imp _ _;\n    refine (\u03bb h, \u27e8K, K0, i, \u03bb j ij, _\u27e9);\n    have := (hi _ ij).1;\n    cases hi _ (le_refl _) with h\u2081 h\u2082,\n  { rwa abs_of_nonneg at this,\n    rw abs_of_nonneg h at h\u2081,\n    exact (le_add_iff_nonneg_right _).1\n      (le_trans h\u2081 $ neg_le_sub_iff_le_add'.1 $\n        le_of_lt (abs_lt.1 $ h\u2082 _ ij).1) },\n  { rwa abs_of_nonpos at this,\n    rw abs_of_nonpos h at h\u2081,\n    rw [\u2190 sub_le_sub_iff_right, zero_sub],\n    exact le_trans (le_of_lt (abs_lt.1 $ h\u2082 _ ij).2) h\u2081 }\nend\n\ninstance : has_lt (cau_seq \u03b1 abs) := \u27e8\u03bb f g, pos (g - f)\u27e9\ninstance : has_le (cau_seq \u03b1 abs) := \u27e8\u03bb f g, f < g \u2228 f \u2248 g\u27e9\n\ntheorem lt_of_lt_of_eq {f g h : cau_seq \u03b1 abs}\n  (fg : f < g) (gh : g \u2248 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 \u03b1 abs}\n  (fg : f \u2248 g) (gh : g < h) : f < h :=\nby have := pos_add_lim_zero gh (neg_lim_zero fg);\n   rwa [\u2190 sub_eq_add_neg, sub_sub_sub_cancel_right] at this\n\ntheorem lt_trans {f g h : cau_seq \u03b1 abs} (fg : f < g) (gh : g < h) : f < h :=\nby simpa using add_pos fg gh\n\ntheorem lt_irrefl {f : cau_seq \u03b1 abs} : \u00ac f < f\n| h := not_lim_zero_of_pos h (by simp [zero_lim_zero])\n\ninstance : preorder (cau_seq \u03b1 abs) :=\n{ lt := (<),\n  le := \u03bb f g, f < g \u2228 f \u2248 g,\n  le_refl := \u03bb f, or.inr (setoid.refl _),\n  le_trans := \u03bb 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 := \u03bb f g,\n    \u27e8\u03bb h, \u27e8or.inl h,\n      not_or (mt (lt_trans h) lt_irrefl) (not_lim_zero_of_pos h)\u27e9,\n    \u03bb \u27e8h\u2081, h\u2082\u27e9, h\u2081.resolve_right\n      (mt (\u03bb h, or.inr (setoid.symm h)) h\u2082)\u27e9 }\n\ntheorem le_antisymm {f g : cau_seq \u03b1 abs} (fg : f \u2264 g) (gf : g \u2264 f) : f \u2248 g :=\nfg.resolve_left (not_lt_of_le gf)\n\ntheorem lt_total (f g : cau_seq \u03b1 abs) : f < g \u2228 f \u2248 g \u2228 g < f :=\n(trichotomy (g - f)).imp_right\n  (\u03bb h, h.imp (\u03bb h, setoid.symm h) (\u03bb h, by rwa neg_sub at h))\n\ntheorem le_total (f g : cau_seq \u03b1 abs) : f \u2264 g \u2228 g \u2264 f :=\n(or.assoc.2 (lt_total f g)).imp_right or.inl\n\ntheorem const_lt {x y : \u03b1} : const x < const y \u2194 x < y :=\nshow pos _ \u2194 _, by rw [\u2190 const_sub, const_pos, sub_pos]\n\ntheorem const_equiv {x y : \u03b1} : const x \u2248 const y \u2194 x = y :=\nshow lim_zero _ \u2194 _, by rw [\u2190 const_sub, const_lim_zero, sub_eq_zero]\n\ntheorem const_le {x y : \u03b1} : const x \u2264 const y \u2194 x \u2264 y :=\nby rw le_iff_lt_or_eq; exact or_congr const_lt const_equiv\n\ntheorem exists_gt (f : cau_seq \u03b1 abs) : \u2203 a : \u03b1, f < const a :=\nlet \u27e8K, H\u27e9 := f.bounded in\n\u27e8K + 1, 1, zero_lt_one, 0, \u03bb 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\u27e9\n\ntheorem exists_lt (f : cau_seq \u03b1 abs) : \u2203 a : \u03b1, const a < f :=\nlet \u27e8a, h\u27e9 := (-f).exists_gt in \u27e8-a, show pos _,\n  by rwa [const_neg, sub_neg_eq_add, add_comm, \u2190 sub_neg_eq_add]\u27e9\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 \u2192  m.f.states \u2192 Prop :=\n-- \u03bb s t, \u2203 i \u2208 G, t \u2208 (m.f.rel i s)\n\ndef C_path {agents : Type}  {m : modelCLK agents} : \n  list agents \u2192 list m.f.states \u2192  m.f.states \u2192  m.f.states \u2192 Prop\n  | list.nil  _        s t := false\n  | (i :: is) list.nil s t := t \u2208 (m.f.rel i s)\n  | (i :: is)(u :: us) s t := (u \u2208 (m.f.rel i s) \u2227 (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 \u2192 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 \u2192 \u2115\n-- | bot := 1\n-- | (var n) := 1 + sizeof n\n-- | (imp \u03c6 \u03c8) := 1 + formCLC.sizeof' \u03c6 + formCLC.sizeof' \u03c8\n-- | (and \u03c6 \u03c8) := 1 + formCLC.sizeof' \u03c6 + formCLC.sizeof' \u03c8\n-- | ([G] \u03c6) := 1 + sizeof G + formCLC.sizeof' \u03c6\n-- | (k i \u03c6) := 1 + sizeof i + formCLC.sizeof' \u03c6\n-- | (e i \u03c6) := 1 + sizeof i + formCLC.sizeof' \u03c6 + 1 -- Make recursion from E' to K' possible\n-- | (c i \u03c6) := 1 + sizeof i + formCLC.sizeof' \u03c6\n\n-- def formCLC.has_sizeof' {agents} : has_sizeof (formCLC agents) := \u27e8formCLC.sizeof' _\u27e9\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}  : \u03a0 (m : modelCLK agents), m.f.states \u2192 formCLC agents \u2192 Prop\n  | m s bot       := false\n  | m s (var n)   := s \u2208 m.v n\n  | m s (imp \u03c6 \u03c8) := (s_entails_CLC m s \u03c6) \u2192 (s_entails_CLC m s \u03c8)\n  | m s (and \u03c6 \u03c8) := (s_entails_CLC m s \u03c6) \u2227 (s_entails_CLC m s \u03c8)\n  | m s ([G] \u03c6)   := {t : m.f.states | s_entails_CLC m t \u03c6} \u2208 m.f.E.E (s) (G)\n  | m s (k i \u03c6)   := \u2200 t : m.f.states, t \u2208 (m.f.rel i s) \u2192 s_entails_CLC m t \u03c6\n  -- | m (e G \u03c6)   s := \u2200 i \u2208 G, (s_entails_CLC.aux m (k i \u03c6) s)\n  | m s (c G \u03c6)   := \u2200 t : m.f.states, (\u2203 la, (\u2200 a \u2208 la, a \u2208 G) \u2227 \u2203 ls, C_path la ls s t) \u2192 \n                        s_entails_CLC m t \u03c6\n  -- | m (c G \u03c6)   s := \u2200 t : m.f.states, (relation.trans_gen (disjunct_rel G) s t) \u2192 s_entails_CLC.aux m \u03c6 t\n\n-- -- Definition of semantic entailment\n-- def s_entails_CLC {agents : Type} (m : modelCLK agents) (s : m.f.states) (\u03c6 : formCLC agents) : Prop :=\n-- s_entails_CLC.aux m \u03c6 s\n\n-- def tilde (m: modelCLC agents) (\u03c6 : formCLC agents)  :=\n-- {t: m.f.states | s_entails m t \u03c6}\nlemma s_entails_CLC_conjunction {agents : Type} {m : modelCLK agents} {s : m.f.states} \n  {\u03c6s : list (formCLC agents)} : \n  s_entails_CLC m s (finite_conjunction \u03c6s) \u2194 \u2200 \u03c6 \u2208 \u03c6s, s_entails_CLC m s \u03c6 :=\nbegin\n  induction \u03c6s with \u03c6 \u03c6s ih,\n  { simp [finite_conjunction],\n    show s_entails_CLC m s \u22a4,\n    simp [s_entails_CLC], },\n  { unfold finite_conjunction,\n    show s_entails_CLC m s (\u03c6 & finite_conjunction \u03c6s) \u2194 _,\n    simp [s_entails_CLC],\n    intros h,\n    exact ih, },\nend\n\nvariables {agents : Type}\n\n-- \u03c6 is valid in a model M = (f,v)\ndef valid_m (m: modelCLK agents) (\u03c6 : formCLC agents) := \n  \u2200 s, s_entails_CLC m s \u03c6\n\ndef global_valid (\u03c6 : formCLC agents) :=\n  \u2200 m, valid_m m \u03c6\n\n-- -- \u03c6 is valid in a frame f\n-- def f_valid (\u03c6 : formCL agents) (f : frame agents) := \n--   \u2200 v s, s_entails f v s \u03c6\n\n\n-- -- \u03c6 is valid in a class of frames F\n-- def F_valid (\u03c6 : formCL agents) (F : set (frame agents)) := \n--   \u2200 f \u2208 F, \u2200 v s, s_entails f v s \u03c6\n\n-- -- \u03c6 is universally valid (valid in all frames)\n-- def u_valid (\u03c6 : formCL agents) := \n--   \u2200 f v s, s_entails f v s \u03c6\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--   := \u2200 \u03c6, \u2200 s, s_entails m s \u03c6\n\n\n-- Global semantic consequence\n-- def global_sem_csq (\u03c6 : formCL agents) :=\n--   \u2200 m s, s_entails m s \u03c6\n\n\nlemma not_s_entails_imp (m : modelCLK agents) : \u2200 s \u03c6, \n  (\u00ac (s_entails_CLC m s \u03c6)) \u2194 (s_entails_CLC m s (\u00ac \u03c6)) :=\nbegin\n  intros s \u03c6,\n  unfold s_entails_CLC,\n  refl\nend\n\n\n-- lemma s_entails_exists {f : frame} {v : nat \u2192 f.states \u2192 Prop} {x : f.states} {\u03c6 : form} :\n--   s_entails f v x (\u25c7\u03c6) \u2194 \u2203 y : f.states, (f.rel x y \u2227 s_entails f v y \u03c6) :=\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 (\u00ac\u03c6)).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 \u27f6 Y`, or `eq_to_iso h : X \u2245 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\u2081 v\u2082 u\u2081 u\u2082 -- morphism levels before object levels. See note [category_theory universes].\n\nnamespace category_theory\nopen opposite\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n\n/--\nAn equality `X = Y` gives us a morphism `X \u27f6 Y`.\n\nIt is typically better to use this, rather than rewriting by the equality then using `\ud835\udfd9 _`\nwhich usually leads to dependent type theory hell.\n-/\ndef eq_to_hom {X Y : C} (p : X = Y) : X \u27f6 Y := by rw p; exact \ud835\udfd9 _\n\n@[simp] lemma eq_to_hom_refl (X : C) (p : X = X) : eq_to_hom p = \ud835\udfd9 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 \u226b 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 \u27f6 Z) :\n  (congr_arg (\u03bb W : C, W \u27f6 Z) p).mpr q = eq_to_hom p \u226b 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 \u27f6 Y) (q : Z = Y) :\n  (congr_arg (\u03bb W : C, X \u27f6 W) q).mpr p = p \u226b eq_to_hom q.symm :=\nby { cases q, simp, }\n\n/--\nAn equality `X = Y` gives us an isomorphism `X \u2245 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 \u2245 Y :=\n\u27e8eq_to_hom p, eq_to_hom p.symm, by simp, by simp\u27e9\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\u1d52\u1d56} (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\u2082} [category.{v\u2082} 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 \u2964 D} (h_obj : \u2200 X, F.obj X = G.obj X)\n  (h_map : \u2200 X Y f, F.map f = eq_to_hom (h_obj X) \u226b G.map f \u226b 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 \u2964 D} (h_obj : \u2200 X, F.obj X = G.obj X)\n  (h_map : \u2200 X Y (f : X \u27f6 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 \u2964 D} (h : F = G) (X) : F.obj X = G.obj X :=\nby subst h\n\nlemma congr_hom {F G : C \u2964 D} (h : F = G) {X Y} (f : X \u27f6 Y) :\n  F.map f = eq_to_hom (congr_obj h X) \u226b G.map f \u226b 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 \u2964 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 \u2964 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 \u2964 D} (h : F = G) (X : C) :\n  (eq_to_hom h : F \u27f6 G).app X = eq_to_hom (functor.congr_obj h X) :=\nby subst h; refl\n\nlemma nat_trans.congr {F G : C \u2964 D} (\u03b1 : F \u27f6 G) {X Y : C} (h : X = Y) :\n  \u03b1.app X = F.map (eq_to_hom h) \u226b \u03b1.app Y \u226b G.map (eq_to_hom h.symm) :=\nby { rw [\u03b1.naturality_assoc], simp }\n\nlemma eq_conj_eq_to_hom {X Y : C} (f : X \u27f6 Y) :\n  f = eq_to_hom rfl \u226b f \u226b 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 : \u2200 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\u27e8\u03bb X : LocallyRingedSpace, (X.to_Top : Type u)\u27e9\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 \ud835\udcaa 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 \ud835\udcaa : 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 \u27f6 Y.to_SheafedSpace)\n(prop : \u2200 x, is_local_ring_hom (PresheafedSpace.stalk_map val x))\n\ninstance : quiver LocallyRingedSpace := \u27e8hom\u27e9\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.\ud835\udcaa.stalk` here?\nnoncomputable\ndef stalk (X : LocallyRingedSpace) (x : X) : CommRing := X.presheaf.stalk x\n\n/--\nA morphism of locally ringed spaces `f : X \u27f6 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 \u27f6 Y) (x : X) :\n  Y.stalk (f.1.1 x) \u27f6 X.stalk x :=\nPresheafedSpace.stalk_map f.1 x\n\ninstance {X Y : LocallyRingedSpace} (f : X \u27f6 Y) (x : X) :\n  is_local_ring_hom (stalk_map f x) := f.2 x\n\ninstance {X Y : LocallyRingedSpace} (f : X \u27f6 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\u27e8\ud835\udfd9 _, \u03bb x, by { erw PresheafedSpace.stalk_map.id, apply is_local_ring_hom_id, }\u27e9\n\ninstance (X : LocallyRingedSpace) : inhabited (hom X X) := \u27e8id X\u27e9\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\u27e8f.val \u226b g.val, \u03bb x,\nbegin\n  erw PresheafedSpace.stalk_map.comp,\n  exact @is_local_ring_hom_comp _ _ _ _ _ _ _ _ (f.2 _) (g.2 _),\nend\u27e9\n\n/-- The category of locally ringed spaces. -/\ninstance : category LocallyRingedSpace :=\n{ hom := hom,\n  id := id,\n  comp := \u03bb 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 \u2964 SheafedSpace CommRing :=\n{ obj := \u03bb X, X.to_SheafedSpace,\n  map := \u03bb 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 \u2964 Top :=\nforget_to_SheafedSpace \u22d9 SheafedSpace.forget _\n\n@[simp] lemma comp_val {X Y Z : LocallyRingedSpace} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).val = f.val \u226b g.val := rfl\n\n@[simp] lemma comp_val_c {X Y Z : LocallyRingedSpace.{u}} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).val.c = g.val.c \u226b (presheaf.pushforward _ g.val.base).map f.val.c := rfl\n\nlemma comp_val_c_app {X Y Z : LocallyRingedSpace} (f : X \u27f6 Y) (g : Y \u27f6 Z) (U : (opens Z)\u1d52\u1d56) :\n  (f \u226b g).val.c.app U = g.val.c.app U \u226b 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 \u27f6 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 \u27f6 Y.to_SheafedSpace) [is_iso f] : X \u27f6 Y :=\nhom.mk f $ \u03bb 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 \u27f6 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 \u2245 Y.to_SheafedSpace) : X \u2245 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 := \u03bb X Y f i,\n  { out := by exactI\n    \u27e8hom_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 _)\u27e9 } }\n\ninstance is_SheafedSpace_iso {X Y : LocallyRingedSpace} (f : X \u27f6 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 \u27f6 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 \u27f6 X.to_Top}\n  (h : open_embedding f) : X.restrict h \u27f6 X :=\n\u27e8X.to_PresheafedSpace.of_restrict h, \u03bb x, infer_instance\u27e9\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 \u22a4) \u2245 X :=\n@iso_of_SheafedSpace_iso (X.restrict (opens.open_embedding \u22a4)) X\n  X.to_SheafedSpace.restrict_top_iso\n\n/--\nThe global sections, notated Gamma.\n-/\ndef \u0393 : LocallyRingedSpace\u1d52\u1d56 \u2964 CommRing :=\nforget_to_SheafedSpace.op \u22d9 SheafedSpace.\u0393\n\nlemma \u0393_def : \u0393 = forget_to_SheafedSpace.op \u22d9 SheafedSpace.\u0393 := rfl\n\n@[simp] lemma \u0393_obj (X : LocallyRingedSpace\u1d52\u1d56) : \u0393.obj X = (unop X).presheaf.obj (op \u22a4) := rfl\n\nlemma \u0393_obj_op (X : LocallyRingedSpace) : \u0393.obj (op X) = X.presheaf.obj (op \u22a4) := rfl\n\n@[simp] lemma \u0393_map {X Y : LocallyRingedSpace\u1d52\u1d56} (f : X \u27f6 Y) :\n  \u0393.map f = f.unop.1.c.app (op \u22a4) := rfl\n\nlemma \u0393_map_op {X Y : LocallyRingedSpace} (f : X \u27f6 Y) :\n  \u0393.map f.op = f.1.c.app (op \u22a4) := rfl\n\nlemma preimage_basic_open {X Y : LocallyRingedSpace} (f : X \u27f6 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 \u27e8\u27e8y, hyU\u27e9, (hy : is_unit _), (rfl : y = _)\u27e9,\n    erw RingedSpace.mem_basic_open _ _ \u27e8x, show x \u2208 (opens.map f.1.base).obj U, from hyU\u27e9,\n    rw \u2190 PresheafedSpace.stalk_map_germ_apply,\n    exact (PresheafedSpace.stalk_map f.1 _).is_unit_map hy },\n  { rintros \u27e8y, (hy : is_unit _), rfl\u27e9,\n    erw RingedSpace.mem_basic_open _ _ \u27e8f.1.base y.1, y.2\u27e9,\n    rw \u2190 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) = \u22a5 :=\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\u2093.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\u2093.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\u2093'. -/\ntheorem dvd_sub_pow_of_dvd_sub {R : Type _} [CommRing R] {p : \u2115} {a b : R} (h : (p : R) \u2223 a - b)\n    (k : \u2115) : (p ^ (k + 1) : R) \u2223 a ^ p ^ k - b ^ p ^ k :=\n  by\n  induction' k with k ih\n  \u00b7 rwa [pow_one, pow_zero, pow_one, pow_one]\n  rw [pow_succ' p k, pow_mul, pow_mul, \u2190 geom_sum\u2082_mul, pow_succ]\n  refine' mul_dvd_mul _ ih\n  let I : Ideal R := span {p}\n  let f : R \u2192+* R \u29f8 I := mk I\n  have hp : (p : R \u29f8 I) = 0 := by rw [\u2190 map_natCast f, eq_zero_iff_mem, mem_span_singleton]\n  rw [\u2190 mem_span_singleton, \u2190 Ideal.Quotient.eq] at h\n  rw [\u2190 mem_span_singleton, \u2190 eq_zero_iff_mem, RingHom.map_geom_sum\u2082, RingHom.map_pow,\n    RingHom.map_pow, h, geom_sum\u2082_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 \u2964 Profinite\u1d52\u1d56 \u2964 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 : \u211d\u22650) [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 \u2190 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 : \u211d\u22650) [normed_with_aut r V] :\n  (normed_with_aut.T.hom : Completion.obj V \u27f6 _) = Completion.map normed_with_aut.T.hom := rfl\n\nlemma T_hom_incl {V : SemiNormedGroup} {r : \u211d\u22650} [normed_with_aut r V] :\n  (incl : V \u27f6 _) \u226b normed_with_aut.T.hom = normed_with_aut.T.hom \u226b 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 : \u211d\u22650} [normed_with_aut r V] :\n  normed_with_aut.T.hom = Completion.lift ((normed_with_aut.T.hom : V \u27f6 V) \u226b 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 \u2192 V`. -/\ndef LCC : SemiNormedGroup \u2964 Profinite\u1d52\u1d56 \u2964 SemiNormedGroup :=\ncurry.obj ((uncurry.obj LocallyConstant) \u22d9 Completion)\n\nlemma LCC_obj_map' (V : SemiNormedGroup) {X Y : Profinite\u1d52\u1d56} (f : Y \u27f6 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 [\u2190 functor.map_comp, category.id_comp]\nend\n\nlemma LCC_obj_map (V : SemiNormedGroup) {X Y : Profinite\u1d52\u1d56} (f : Y \u27f6 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\u1d52\u1d56} (f : Y \u27f6 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\u1d52\u1d56) (r : \u211d\u22650)\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 \u2190 op_unop S,\n    rintro (f : locally_constant (unop S : Profinite) V),\n    show Sup _ = \u2191r * 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\u1d52\u1d56) (r : \u211d\u22650)\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' : \u2200 (c : R) {x : M}, x \u2208 carrier \u2192 c \u2022 x \u2208 carrier)\n\nnamespace sub_mul_action\n\nvariables [has_smul R M]\n\ninstance : set_like (sub_mul_action R M) M :=\n\u27e8sub_mul_action.carrier, \u03bb p q h, by cases p; cases q; congr'\u27e9\n\n@[simp] lemma mem_carrier {p : sub_mul_action R M} {x : M} : x \u2208 p.carrier \u2194 x \u2208 (p : set M) :=\niff.rfl\n\n@[ext] theorem ext {p q : sub_mul_action R M} (h : \u2200 x, x \u2208 p \u2194 x \u2208 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 = \u2191p) : sub_mul_action R M :=\n{ carrier := s,\n  smul_mem' := hs.symm \u25b8 p.smul_mem' }\n\n@[simp] lemma coe_copy (p : sub_mul_action R M) (s : set M) (hs : s = \u2191p) :\n  (p.copy s hs : set M) = s := rfl\n\nlemma copy_eq (p : sub_mul_action R M) (s : set M) (hs : s = \u2191p) : p.copy s hs = p :=\nset_like.coe_injective hs\n\ninstance : has_bot (sub_mul_action R M) :=\n\u27e8{ carrier := \u2205, smul_mem' := \u03bb c, set.not_mem_empty}\u27e9\n\ninstance : inhabited (sub_mul_action R M) := \u27e8\u22a5\u27e9\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 \u2208 p) : r \u2022 x \u2208 p := p.smul_mem' r h\n\ninstance : has_smul R p :=\n{ smul := \u03bb c x, \u27e8c \u2022 x.1, smul_mem _ c x.2\u27e9 }\n\nvariables {p}\n@[simp, norm_cast] lemma coe_smul (r : R) (x : p) : ((r \u2022 x : p) : M) = r \u2022 \u2191x := rfl\n@[simp, norm_cast] lemma coe_mk (x : M) (hx : x \u2208 p) : ((\u27e8x, hx\u27e9 : p) : M) = x := rfl\n\nvariables (p)\n\n/-- Embedding of a submodule `p` to the ambient space `M`. -/\nprotected def subtype : p \u2192[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 \u2192 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 \u2208 p) : s \u2022 x \u2208 p :=\nby { rw [\u2190one_smul R x, \u2190smul_assoc], exact p.smul_mem _ h }\n\ninstance has_smul' : has_smul S p :=\n{ smul := \u03bb c x, \u27e8c \u2022 x.1, smul_of_tower_mem _ c x.2\u27e9 }\n\ninstance : is_scalar_tower S R p :=\n{ smul_assoc := \u03bb s r x, subtype.ext $ smul_assoc s r \u2191x }\n\n@[simp, norm_cast] lemma coe_smul_of_tower (s : S) (x : p) : ((s \u2022 x : p) : M) = s \u2022 \u2191x := 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 \u2022 x \u2208 p \u2194 x \u2208 p :=\n\u27e8\u03bb h, inv_smul_smul g x \u25b8 p.smul_of_tower_mem g\u207b\u00b9 h, p.smul_of_tower_mem g\u27e9\n\ninstance [has_smul S\u1d50\u1d52\u1d56 R] [has_smul S\u1d50\u1d52\u1d56 M] [is_scalar_tower S\u1d50\u1d52\u1d56 R M]\n  [is_central_scalar S M] : is_central_scalar S p :=\n{ op_smul_eq_smul := \u03bb 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 := (\u2022),\n  one_smul := \u03bb x, subtype.ext $ one_smul _ x,\n  mul_smul := \u03bb c\u2081 c\u2082 x, subtype.ext $ mul_smul c\u2081 c\u2082 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      \u2190 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 \u2190 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) \u2208 p :=\nlet \u27e8x, hx\u27e9 := h in zero_smul R (x : M) \u25b8 p.smul_mem 0 hx\n\n/-- If the scalar product forms a `module`, and the `sub_mul_action` is not `\u22a5`, then the\nsubset inherits the zero. -/\ninstance [n_empty : nonempty p] : has_zero p :=\n{ zero := \u27e80, n_empty.elim $ \u03bb x, p.zero_mem \u27e8x, x.prop\u27e9\u27e9 }\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 \u2208 p) : -x \u2208 p := by { rw \u2190 neg_one_smul R, exact p.smul_mem _ hx }\n\n@[simp] lemma neg_mem_iff : -x \u2208 p \u2194 x \u2208 p :=\n\u27e8\u03bb h, by { rw \u2190neg_neg x, exact neg_mem _ h}, neg_mem _\u27e9\n\ninstance : has_neg p := \u27e8\u03bbx, \u27e8-x.1, neg_mem _ x.2\u27e9\u27e9\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 \u2260 0) : s \u2022 x \u2208 p \u2194 x \u2208 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 `\u27e8X, b\u27e9`, 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\nnoncomputable theory\n\nnamespace category_theory\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] [monoidal_category C]\n\n/--\nA half-braiding on `X : C` is a family of isomorphisms `X \u2297 U \u2245 U \u2297 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(\u03b2 : \u03a0 U, X \u2297 U \u2245 U \u2297 X)\n(monoidal' : \u2200 U U', (\u03b2 (U \u2297 U')).hom =\n  (\u03b1_ _ _ _).inv \u226b ((\u03b2 U).hom \u2297 \ud835\udfd9 U') \u226b (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 U \u2297 (\u03b2 U').hom) \u226b (\u03b1_ _ _ _).inv\n  . obviously)\n(naturality' : \u2200 {U U'} (f : U \u27f6 U'), (\ud835\udfd9 X \u2297 f) \u226b (\u03b2 U').hom = (\u03b2 U).hom \u226b (f \u2297 \ud835\udfd9 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 `\u27e8X, b\u27e9`, where `X : C`\nand `b` is a half-braiding on `X`.\n-/\n@[nolint has_inhabited_instance]\ndef center := \u03a3 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 \u27f6 Y.1)\n(comm' : \u2200 U, (f \u2297 \ud835\udfd9 U) \u226b (Y.2.\u03b2 U).hom = (X.2.\u03b2 U).hom \u226b (\ud835\udfd9 U \u2297 f) . obviously)\n\nrestate_axiom hom.comm'\nattribute [simp, reassoc] hom.comm\n\ninstance : category (center C) :=\n{ hom := hom,\n  id := \u03bb X, { f := \ud835\udfd9 X.1, },\n  comp := \u03bb X Y Z f g, { f := f.f \u226b g.f, }, }\n\n@[simp] lemma id_f (X : center C) : hom.f (\ud835\udfd9 X) = \ud835\udfd9 X.1 := rfl\n@[simp] lemma comp_f {X Y Z : center C} (f : X \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g).f = f.f \u226b g.f := rfl\n\n@[ext]\nlemma ext {X Y : center C} (f g : X \u27f6 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 \u27f6 Y) [is_iso f.f] : X \u2245 Y :=\n{ hom := f,\n  inv := \u27e8inv f.f, \u03bb U, by simp [\u2190cancel_epi (f.f \u2297 \ud835\udfd9 U), \u2190comp_tensor_id_assoc, \u2190id_tensor_comp]\u27e9 }\n\ninstance is_iso_of_f_is_iso {X Y : center C} (f : X \u27f6 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\u27e8X.1 \u2297 Y.1,\n  { \u03b2 := \u03bb U, \u03b1_ _ _ _ \u226a\u226b (iso.refl X.1 \u2297 Y.2.\u03b2 U) \u226a\u226b (\u03b1_ _ _ _).symm\n      \u226a\u226b (X.2.\u03b2 U \u2297 iso.refl Y.1) \u226a\u226b \u03b1_ _ _ _,\n    monoidal' := \u03bb 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.\u03b2 U).hom \u2297 \ud835\udfd9 Y.fst) \u2297 \ud835\udfd9 U'`\n      -- and `\ud835\udfd9 U \u2297 \ud835\udfd9 X.fst \u2297 (Y.snd.\u03b2 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 \u2190associator_naturality, },\n      slice_rhs 6 7 { rw [tensor_id, tensor_id, tensor_id_comp_id_tensor, \u2190id_tensor_comp_tensor_id,\n        \u2190tensor_id, \u2190tensor_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' := \u03bb U U' f,\n    begin\n      dsimp,\n      rw [category.assoc, category.assoc, category.assoc, category.assoc,\n        id_tensor_associator_naturality_assoc, \u2190id_tensor_comp_assoc, half_braiding.naturality,\n        id_tensor_comp_assoc, associator_inv_naturality_assoc, \u2190comp_tensor_id_assoc,\n        half_braiding.naturality, comp_tensor_id_assoc, associator_naturality, \u2190tensor_id],\n    end, }\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_hom {X\u2081 Y\u2081 X\u2082 Y\u2082 : center C} (f : X\u2081 \u27f6 Y\u2081) (g : X\u2082 \u27f6 Y\u2082) :\n  tensor_obj X\u2081 X\u2082 \u27f6 tensor_obj Y\u2081 Y\u2082 :=\n{ f := f.f \u2297 g.f,\n  comm' := \u03bb U, begin\n    dsimp,\n    rw [category.assoc, category.assoc, category.assoc, category.assoc,\n      associator_naturality_assoc, \u2190tensor_id_comp_id_tensor, category.assoc,\n      \u2190id_tensor_comp_assoc, g.comm, id_tensor_comp_assoc, tensor_id_comp_id_tensor_assoc,\n      \u2190id_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, \u2190tensor_id_comp_id_tensor g.f, category.assoc,\n      \u2190comp_tensor_id_assoc, f.comm, comp_tensor_id_assoc, id_tensor_associator_naturality,\n      associator_naturality_assoc, \u2190id_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\u27e8\ud835\udfd9_ C,\n  { \u03b2 := \u03bb U, (\u03bb_ U) \u226a\u226b (\u03c1_ U).symm,\n    monoidal' := \u03bb U U', by simp,\n    naturality' := \u03bb U U' f, begin\n      dsimp,\n      rw [left_unitor_naturality_assoc, right_unitor_inv_naturality, category.assoc],\n    end, }\u27e9\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 \u2245 tensor_obj X (tensor_obj Y Z) :=\niso_mk \u27e8(\u03b1_ X.1 Y.1 Z.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [comp_tensor_id, id_tensor_comp, \u2190tensor_id, associator_conjugation],\n  coherence,\nend\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef left_unitor (X : center C) : tensor_obj tensor_unit X \u2245 X :=\niso_mk \u27e8(\u03bb_ X.1).hom, \u03bb 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 [\u2190left_unitor_tensor, left_unitor_naturality, left_unitor_tensor'_assoc],\nend\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef right_unitor (X : center C) : tensor_obj X tensor_unit \u2245 X :=\niso_mk \u27e8(\u03c1_ X.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [tensor_id_comp_id_tensor_assoc, triangle_assoc, id_tensor_comp, category.assoc],\n  rw [\u2190tensor_id_comp_id_tensor_assoc (\u03c1_ U).inv, cancel_epi, \u2190right_unitor_tensor_inv_assoc,\n    \u2190right_unitor_inv_naturality_assoc],\n  simp,\nend\u27e9\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 := \u03bb X Y, tensor_obj X Y,\n  tensor_hom := \u03bb X\u2081 Y\u2081 X\u2082 Y\u2082 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 \u2297 Y).1 = X.1 \u2297 Y.1 := rfl\n\n@[simp] lemma tensor_\u03b2 (X Y : center C) (U : C) :\n  (X \u2297 Y).2.\u03b2 U =\n    \u03b1_ _ _ _ \u226a\u226b (iso.refl X.1 \u2297 Y.2.\u03b2 U) \u226a\u226b (\u03b1_ _ _ _).symm\n      \u226a\u226b (X.2.\u03b2 U \u2297 iso.refl Y.1) \u226a\u226b \u03b1_ _ _ _ :=\nrfl\n@[simp] \n\n@[simp] lemma tensor_unit_\u03b2 (U : C) : (\ud835\udfd9_ (center C)).2.\u03b2 U = (\u03bb_ U) \u226a\u226b (\u03c1_ U).symm := rfl\n\n@[simp] lemma associator_hom_f (X Y Z : center C) : hom.f (\u03b1_ X Y Z).hom = (\u03b1_ X.1 Y.1 Z.1).hom :=\nrfl\n\n@[simp] lemma associator_inv_f (X Y Z : center C) : hom.f (\u03b1_ X Y Z).inv = (\u03b1_ X.1 Y.1 Z.1).inv :=\nby { ext, rw [\u2190associator_hom_f, \u2190comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma left_unitor_hom_f (X : center C) : hom.f (\u03bb_ X).hom = (\u03bb_ X.1).hom :=\nrfl\n\n@[simp] lemma left_unitor_inv_f (X : center C) : hom.f (\u03bb_ X).inv = (\u03bb_ X.1).inv :=\nby { ext, rw [\u2190left_unitor_hom_f, \u2190comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma right_unitor_hom_f (X : center C) : hom.f (\u03c1_ X).hom = (\u03c1_ X.1).hom :=\nrfl\n\n@[simp] lemma right_unitor_inv_f (X : center C) : hom.f (\u03c1_ X).inv = (\u03c1_ X.1).inv :=\nby { ext, rw [\u2190right_unitor_hom_f, \u2190comp_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 := \u03bb X, X.1,\n  map := \u03bb X Y f, f.f,\n  \u03b5 := \ud835\udfd9 (\ud835\udfd9_ C),\n  \u03bc := \u03bb X Y, \ud835\udfd9 (X.1 \u2297 Y.1), }\n\ninstance : reflects_isomorphisms (forget C).to_functor :=\n{ reflects := \u03bb 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 \u2297 Y \u2245 Y \u2297 X :=\niso_mk \u27e8(X.2.\u03b2 Y.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [category.assoc],\n  rw [\u2190is_iso.inv_comp_eq, is_iso.iso.inv_hom, \u2190half_braiding.monoidal_assoc,\n    \u2190half_braiding.naturality_assoc, half_braiding.monoidal],\n  simp,\nend\u27e9\n\ninstance braided_category_center : braided_category (center C) :=\n{ braiding := braiding,\n  braiding_naturality' := \u03bb X Y X' Y' f g, begin\n    ext,\n    dsimp,\n    rw [\u2190tensor_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\u27e8X, { \u03b2 := \u03bb Y, \u03b2_ X Y,\n  monoidal' := \u03bb U U', begin\n    rw [iso.eq_inv_comp, \u2190category.assoc, \u2190category.assoc, iso.eq_comp_inv,\n      category.assoc, category.assoc],\n    exact hexagon_forward X U U',\n  end }\u27e9\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 := \u03bb X X' f,\n  { f := f,\n    comm' := \u03bb U, braiding_naturality _ _, },\n  \u03b5 :=\n  { f := \ud835\udfd9 _,\n    comm' := \u03bb U, begin\n      dsimp,\n      rw [tensor_id, category.id_comp, tensor_id, category.comp_id, \u2190braiding_right_unitor,\n        category.assoc, iso.hom_inv_id, category.comp_id],\n    end, },\n  \u03bc := \u03bb X Y,\n  { f := \ud835\udfd9 _,\n    comm' := \u03bb U, begin\n      dsimp,\n      rw [tensor_id, tensor_id, category.id_comp, category.comp_id,\n        \u2190iso.inv_comp_eq, \u2190category.assoc, \u2190category.assoc, \u2190iso.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 \u226b 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 \u27f6 Q) : Prop :=\n(epi : epi f)\n(has_lift : \u03a0 {X Y : C} {u : P \u27f6 X} {v : Q \u27f6 Y} {z : X \u27f6 Y} [mono z] (h : u \u226b z = f \u226b 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 \u27f6 Q) : Prop :=\n(mono : mono f)\n(has_lift : \u03a0 {X Y : C} {u : X \u27f6 P} {v : Y \u27f6 Q} {z : X \u27f6 Y} [epi z] (h : u \u226b f = z \u226b 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 \u27f6 Q) [strong_epi f] : epi f := strong_epi.epi\n\n@[priority 100]\ninstance mono_of_strong_mono (f : P \u27f6 Q) [strong_mono f] : mono f := strong_mono.mono\n\nsection\nvariables {R : C} (f : P \u27f6 Q) (g : Q \u27f6 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 \u226b g) :=\n{ epi := epi_comp _ _,\n  has_lift :=\n  begin\n    introsI,\n    have h\u2080 : u \u226b z = f \u226b g \u226b v, by simpa [category.assoc] using h,\n    let w : Q \u27f6 X := arrow.lift (arrow.hom_mk' h\u2080),\n    have h\u2081 : w \u226b z = g \u226b v, by rw arrow.lift_mk'_right,\n    exact arrow.has_lift.mk \u27e8(arrow.lift (arrow.hom_mk' h\u2081) : R \u27f6 X), by simp, by simp\u27e9\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 \u226b g) :=\n{ mono := mono_comp _ _,\n  has_lift :=\n  begin\n    introsI,\n    have h\u2080 : (u \u226b f) \u226b g = z \u226b v, by simpa [category.assoc] using h,\n    let w : Y \u27f6 Q := arrow.lift (arrow.hom_mk' h\u2080),\n    have h\u2081 : u \u226b f = z \u226b w, by rw arrow.lift_mk'_left,\n    exact arrow.has_lift.mk \u27e8(arrow.lift (arrow.hom_mk' h\u2081) : Y \u27f6 P), by simp, by simp\u27e9\n  end }\n\n/-- If `f \u226b g` is a strong epimorphism, then so is `g`. -/\nlemma strong_epi_of_strong_epi [strong_epi (f \u226b g)] : strong_epi g :=\n{ epi := epi_of_epi f g,\n  has_lift :=\n  begin\n    introsI,\n    have h\u2080 : (f \u226b u) \u226b z = (f \u226b g) \u226b v, by simp only [category.assoc, h],\n    exact arrow.has_lift.mk\n      \u27e8(arrow.lift (arrow.hom_mk' h\u2080) : R \u27f6 X), (cancel_mono z).1 (by simp [h]), by simp\u27e9,\n  end }\n\n/-- If `f \u226b 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 := \u03bb X Y u v z _ h, arrow.has_lift.mk \u27e8inv f \u226b u, by simp, by simp [h]\u27e9 }\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 := \u03bb X Y u v z _ h, arrow.has_lift.mk\n    \u27e8v \u226b inv f, by simp [\u2190 category.assoc, \u2190 h], by simp\u27e9 }\n\nend\n\n/-- A strong epimorphism that is a monomorphism is an isomorphism. -/\nlemma is_iso_of_mono_of_strong_epi (f : P \u27f6 Q) [mono f] [strong_epi f] : is_iso f :=\n\u27e8\u27e8arrow.lift $ arrow.hom_mk' $ show \ud835\udfd9 P \u226b f = f \u226b \ud835\udfd9 Q, by simp, by tidy\u27e9\u27e9\n\n/-- A strong monomorphism that is an epimorphism is an isomorphism. -/\nlemma is_iso_of_epi_of_strong_mono (f : P \u27f6 Q) [epi f] [strong_mono f] : is_iso f :=\n\u27e8\u27e8arrow.lift $ arrow.hom_mk' $ show \ud835\udfd9 P \u226b f = f \u226b \ud835\udfd9 Q, by simp, by tidy\u27e9\u27e9\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u03b1` is the type of open subsets of a topological space `\u03b1`.\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 `\u03b1` containing `x : \u03b1`.\n- `open_nhds_of.comap f x U` is the preimage of open neighborhood `U` of `f x` under `f : C(\u03b1, \u03b2)`.\n\n## Main results\n\nWe define order structures on both `opens \u03b1` (`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 {\u03b9 \u03b1 \u03b2 \u03b3 : Type*} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3]\n\nnamespace topological_space\n\nvariable (\u03b1)\n\n/-- The type of open subsets of a topological space. -/\nstructure opens :=\n(carrier : set \u03b1)\n(is_open' : is_open carrier)\n\nvariable {\u03b1}\n\nnamespace opens\n\ninstance : set_like (opens \u03b1) \u03b1 :=\n{ coe := opens.carrier,\n  coe_injective' := \u03bb \u27e8_, _\u27e9 \u27e8_, _\u27e9 _, by congr; assumption }\n\ninstance : can_lift (set \u03b1) (opens \u03b1) coe is_open :=\n\u27e8\u03bb s h, \u27e8\u27e8s, h\u27e9, rfl\u27e9\u27e9\n\nlemma \u00abforall\u00bb {p : opens \u03b1 \u2192 Prop} : (\u2200 U, p U) \u2194 \u2200 (U : set \u03b1) (hU : is_open U), p \u27e8U, hU\u27e9 :=\n\u27e8\u03bb h _ _, h _, \u03bb h \u27e8U, hU\u27e9, h _ _\u27e9\n\n@[simp] lemma carrier_eq_coe (U : opens \u03b1) : U.1 = \u2191U := rfl\n\n/-- the coercion `opens \u03b1 \u2192 set \u03b1` applied to a pair is the same as taking the first component -/\n@[simp] lemma coe_mk {U : set \u03b1} {hU : is_open U} : \u2191(\u27e8U, hU\u27e9 : opens \u03b1) = U := rfl\n\n@[simp] lemma mem_mk {x : \u03b1} {U : set \u03b1} {h : is_open U} :\n  @has_mem.mem _ (opens \u03b1) _ x \u27e8U, h\u27e9 \u2194 x \u2208 U := iff.rfl\n\n-- todo: make it `simp` for a `set_like`?\n@[simp] protected lemma nonempty_coe_sort {U : opens \u03b1} : nonempty U \u2194 (U : set \u03b1).nonempty :=\nset.nonempty_coe_sort\n\n@[ext] lemma ext {U V : opens \u03b1} (h : (U : set \u03b1) = V) : U = V := set_like.coe_injective h\n@[simp] lemma coe_inj {U V : opens \u03b1} : (U : set \u03b1) = V \u2194 U = V := set_like.ext'_iff.symm\n\nprotected lemma is_open (U : opens \u03b1) : is_open (U : set \u03b1) := U.is_open'\n\n@[simp] lemma mk_coe (U : opens \u03b1) : mk \u2191U U.is_open = U := by { cases U, refl }\n\n/-- See Note [custom simps projection]. -/\ndef simps.coe (U : opens \u03b1) : set \u03b1 := U\n\ninitialize_simps_projections opens (carrier \u2192 coe)\n\n/-- The interior of a set, as an element of `opens`. -/\ndef interior (s : set \u03b1) : opens \u03b1 := \u27e8interior s, is_open_interior\u27e9\n\nlemma gc : galois_connection (coe : opens \u03b1 \u2192 set \u03b1) interior :=\n\u03bb U s, \u27e8\u03bb h, interior_maximal h U.is_open, \u03bb h, le_trans h interior_subset\u27e9\n\n/-- The galois coinsertion between sets and opens. -/\ndef gi : galois_coinsertion coe (@interior \u03b1 _) :=\n{ choice := \u03bb s hs, \u27e8s, interior_eq_iff_is_open.mp $ le_antisymm interior_subset hs\u27e9,\n  gc := gc,\n  u_l_le := \u03bb _, interior_subset,\n  choice_eq := \u03bb s hs, le_antisymm hs interior_subset }\n\ninstance : complete_lattice (opens \u03b1) :=\ncomplete_lattice.copy (galois_coinsertion.lift_complete_lattice gi)\n/- le  -/ (\u03bb U V, (U : set \u03b1) \u2286 V) rfl\n/- top -/ \u27e8univ, is_open_univ\u27e9 (ext interior_univ.symm)\n/- bot -/ \u27e8\u2205, is_open_empty\u27e9 rfl\n/- sup -/ (\u03bb U V, \u27e8\u2191U \u222a \u2191V, U.2.union V.2\u27e9) rfl\n/- inf -/ (\u03bb U V, \u27e8\u2191U \u2229 \u2191V, U.2.inter V.2\u27e9) (funext\u2082 $ \u03bb U V, ext (U.2.inter V.2).interior_eq.symm)\n/- Sup -/ (\u03bb S, \u27e8\u22c3 s \u2208 S, \u2191s, is_open_bUnion $ \u03bb s _, s.2\u27e9) (funext $ \u03bb S, ext Sup_image.symm)\n/- Inf -/ _ rfl\n\n@[simp] lemma mk_inf_mk {U V : set \u03b1} {hU : is_open U} {hV : is_open V} :\n  (\u27e8U, hU\u27e9 \u2293 \u27e8V, hV\u27e9 : opens \u03b1) = \u27e8U \u2293 V, is_open.inter hU hV\u27e9 := rfl\n@[simp, norm_cast] lemma coe_inf (s t : opens \u03b1) : (\u2191(s \u2293 t) : set \u03b1) = s \u2229 t := rfl\n@[simp, norm_cast] lemma coe_sup (s t : opens \u03b1) : (\u2191(s \u2294 t) : set \u03b1) = s \u222a t := rfl\n@[simp, norm_cast] lemma coe_bot : ((\u22a5 : opens \u03b1) : set \u03b1) = \u2205 := rfl\n@[simp, norm_cast] lemma coe_top : ((\u22a4 : opens \u03b1) : set \u03b1) = set.univ := rfl\n@[simp, norm_cast] lemma coe_Sup {S : set (opens \u03b1)} : (\u2191(Sup S) : set \u03b1) = \u22c3 i \u2208 S, \u2191i := rfl\n\n@[simp, norm_cast] lemma coe_finset_sup (f : \u03b9 \u2192 opens \u03b1) (s : finset \u03b9) :\n  (\u2191(s.sup f) : set \u03b1) = s.sup (coe \u2218 f) :=\nmap_finset_sup (\u27e8\u27e8coe, coe_sup\u27e9, coe_bot\u27e9 : sup_bot_hom (opens \u03b1) (set \u03b1)) _ _\n\n@[simp, norm_cast] lemma coe_finset_inf (f : \u03b9 \u2192 opens \u03b1) (s : finset \u03b9) :\n  (\u2191(s.inf f) : set \u03b1) = s.inf (coe \u2218 f) :=\nmap_finset_inf (\u27e8\u27e8coe, coe_inf\u27e9, coe_top\u27e9 : inf_top_hom (opens \u03b1) (set \u03b1)) _ _\n\ninstance : inhabited (opens \u03b1) := \u27e8\u22a5\u27e9\n\nlemma supr_def {\u03b9} (s : \u03b9 \u2192 opens \u03b1) : (\u2a06 i, s i) = \u27e8\u22c3 i, s i, is_open_Union $ \u03bb i, (s i).2\u27e9 :=\nby { ext, simp only [supr, coe_Sup, bUnion_range], refl }\n\n@[simp] lemma supr_mk {\u03b9} (s : \u03b9 \u2192 set \u03b1) (h : \u03a0 i, is_open (s i)) :\n  (\u2a06 i, \u27e8s i, h i\u27e9 : opens \u03b1) = \u27e8\u22c3 i, s i, is_open_Union h\u27e9 :=\nby { rw supr_def, simp }\n\n@[simp, norm_cast] lemma coe_supr {\u03b9} (s : \u03b9 \u2192 opens \u03b1) :\n  ((\u2a06 i, s i : opens \u03b1) : set \u03b1) = \u22c3 i, s i :=\nby simp [supr_def]\n\n@[simp] theorem mem_supr {\u03b9} {x : \u03b1} {s : \u03b9 \u2192 opens \u03b1} : x \u2208 supr s \u2194 \u2203 i, x \u2208 s i :=\nby { rw [\u2190 set_like.mem_coe], simp, }\n\n@[simp] lemma mem_Sup {Us : set (opens \u03b1)} {x : \u03b1} : x \u2208 Sup Us \u2194 \u2203 u \u2208 Us, x \u2208 u :=\nby simp_rw [Sup_eq_supr, mem_supr]\n\ninstance : frame (opens \u03b1) :=\n{ Sup := Sup,\n  inf_Sup_le_supr_inf := \u03bb a s,\n    (ext $ by simp only [coe_inf, coe_supr, coe_Sup, set.inter_Union\u2082]).le,\n  ..opens.complete_lattice }\n\nlemma open_embedding_of_le {U V : opens \u03b1} (i : U \u2264 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 \u03b1) : \u00ac set.nonempty (U : set \u03b1) \u2194 U = \u22a5 :=\nby rw [\u2190 coe_inj, opens.coe_bot, \u2190 set.not_nonempty_iff_eq_empty]\n\nlemma ne_bot_iff_nonempty (U : opens \u03b1) : U \u2260 \u22a5 \u2194 set.nonempty (U : set \u03b1) :=\nby rw [ne.def, \u2190 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 {\u03b1} [t : topological_space \u03b1] (h : t = \u22a4) (U : opens \u03b1) : U = \u22a5 \u2228 U = \u22a4 :=\nbegin\n  simp only [\u2190 coe_inj],\n  unfreezingI { subst h }, letI : topological_space \u03b1 := \u22a4,\n  exact (is_open_top_iff _).1 U.2\nend\n\n/-- A set of `opens \u03b1` is a basis if the set of corresponding sets is a topological basis. -/\ndef is_basis (B : set (opens \u03b1)) : Prop := is_topological_basis ((coe : _ \u2192 set \u03b1) '' B)\n\nlemma is_basis_iff_nbhd {B : set (opens \u03b1)} :\n  is_basis B \u2194 \u2200 {U : opens \u03b1} {x}, x \u2208 U \u2192 \u2203 U' \u2208 B, x \u2208 U' \u2227 U' \u2264 U :=\nbegin\n  split; intro h,\n  { rintros \u27e8sU, hU\u27e9 x hx,\n    rcases h.mem_nhds_iff.mp (is_open.mem_nhds hU hx)\n      with \u27e8sV, \u27e8\u27e8V, H\u2081, H\u2082\u27e9, hsV\u27e9\u27e9,\n    refine \u27e8V, H\u2081, _\u27e9,\n    cases V, dsimp at H\u2082, subst H\u2082, exact hsV },\n  { refine is_topological_basis_of_open_of_nhds _ _,\n    { rintros sU \u27e8U, \u27e8H\u2081, rfl\u27e9\u27e9, exact U.2 },\n    { intros x sU hx hsU,\n      rcases @h (\u27e8sU, hsU\u27e9 : opens \u03b1) x hx with \u27e8V, hV, H\u27e9,\n      exact \u27e8V, \u27e8V, hV, rfl\u27e9, H\u27e9 } }\nend\n\nlemma is_basis_iff_cover {B : set (opens \u03b1)} :\n  is_basis B \u2194 \u2200 U : opens \u03b1, \u2203 Us \u2286 B, U = Sup Us :=\nbegin\n  split,\n  { intros hB U,\n    refine \u27e8{V : opens \u03b1 | V \u2208 B \u2227 V \u2264 U}, \u03bb U hU, hU.left, _\u27e9,\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 \u27e8Us, hUs, rfl\u27e9,\n    rcases mem_Sup.1 hx with \u27e8U, Us, xU\u27e9,\n    exact \u27e8U, hUs Us, xU, le_Sup Us\u27e9 }\nend\n\n/-- If `\u03b1` has a basis consisting of compact opens, then an open set in `\u03b1` 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  {\u03b9 : Type*} (b : \u03b9 \u2192 opens \u03b1) (hb : is_basis (set.range b))\n  (hb' : \u2200 i, is_compact (b i : set \u03b1)) (U : set \u03b1) :\n  is_compact U \u2227 is_open U \u2194 \u2203 (s : set \u03b9), s.finite \u2227 U = \u22c3 i \u2208 s, b i :=\nbegin\n  apply is_compact_open_iff_eq_finite_Union_of_is_topological_basis\n    (\u03bb i : \u03b9, (b i).1),\n  { convert hb, ext, simp },\n  { exact hb' }\nend\n\n@[simp] lemma is_compact_element_iff (s : opens \u03b1) :\n  complete_lattice.is_compact_element s \u2194 is_compact (s : set \u03b1) :=\nbegin\n  rw [is_compact_iff_finite_subcover, complete_lattice.is_compact_element_iff],\n  refine \u27e8_, \u03bb H \u03b9 U hU, _\u27e9,\n  { introv H hU hU',\n    obtain \u27e8t, ht\u27e9 := H \u03b9 (\u03bb i, \u27e8U i, hU i\u27e9) (by simpa),\n    refine \u27e8t, set.subset.trans ht _\u27e9,\n    rw [coe_finset_sup, finset.sup_eq_supr],\n    refl },\n  { obtain \u27e8t, ht\u27e9 := H (\u03bb i, U i) (\u03bb i, (U i).is_open)\n      (by simpa using (show (s : set \u03b1) \u2286 \u2191(supr U), from hU)),\n    refine \u27e8t, set.subset.trans ht _\u27e9,\n    simp only [set.Union_subset_iff],\n    show \u2200 i \u2208 t, U i \u2264 t.sup U, from \u03bb i, finset.le_sup }\nend\n\n/-- The preimage of an open set, as an open set. -/\ndef comap (f : C(\u03b1, \u03b2)) : frame_hom (opens \u03b2) (opens \u03b1) :=\n{ to_fun := \u03bb s, \u27e8f \u207b\u00b9' s, s.2.preimage f.continuous\u27e9,\n  map_Sup' := \u03bb s, ext $ by simp only [coe_Sup, preimage_Union, bUnion_image, coe_mk],\n  map_inf' := \u03bb a b, rfl,\n  map_top' := rfl }\n\n@[simp] lemma comap_id : comap (continuous_map.id \u03b1) = frame_hom.id _ :=\nframe_hom.ext $ \u03bb a, ext rfl\n\nlemma comap_mono (f : C(\u03b1, \u03b2)) {s t : opens \u03b2} (h : s \u2264 t) : comap f s \u2264 comap f t :=\norder_hom_class.mono (comap f) h\n\n@[simp] lemma coe_comap (f : C(\u03b1, \u03b2)) (U : opens \u03b2) : \u2191(comap f U) = f \u207b\u00b9' U := rfl\n\nprotected lemma comap_comp (g : C(\u03b2, \u03b3)) (f : C(\u03b1, \u03b2)) :\n  comap (g.comp f) = (comap f).comp (comap g) := rfl\n\nprotected lemma comap_comap (g : C(\u03b2, \u03b3)) (f : C(\u03b1, \u03b2)) (U : opens \u03b3) :\n  comap f (comap g U) = comap (g.comp f) U := rfl\n\nlemma comap_injective [t0_space \u03b2] : injective (comap : C(\u03b1, \u03b2) \u2192 frame_hom (opens \u03b2) (opens \u03b1)) :=\n\u03bb f g h, continuous_map.ext $ \u03bb a, inseparable.eq $ inseparable_iff_forall_open.2 $ \u03bb s hs,\nhave comap f \u27e8s, hs\u27e9 = comap g \u27e8s, hs\u27e9, from fun_like.congr_fun h \u27e8_, hs\u27e9,\nshow a \u2208 f \u207b\u00b9' s \u2194 a \u2208 g \u207b\u00b9' 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 : \u03b1 \u2243\u209c \u03b2) : opens \u03b1 \u2243o opens \u03b2 :=\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' := \u03bb U V, by simp only [\u2190 set_like.coe_subset_coe];\n    exact f.symm.surjective.preimage_subset_preimage_iff }\n\n@[simp] lemma _root_.homeomorph.opens_congr_symm (f : \u03b1 \u2243\u209c \u03b2) :\n  f.opens_congr.symm = f.symm.opens_congr :=\nrfl\n\ninstance [finite \u03b1] : finite (opens \u03b1) := 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 : \u03b1) extends opens \u03b1 :=\n(mem' : x \u2208 carrier)\n\nnamespace open_nhds_of\n\nvariables {x : \u03b1}\n\nlemma to_opens_injective : injective (to_opens : open_nhds_of x \u2192 opens \u03b1)\n| \u27e8_, _\u27e9 \u27e8_, _\u27e9 rfl := rfl\n\ninstance : set_like (open_nhds_of x) \u03b1 :=\n{ coe := \u03bb U, U.1,\n  coe_injective' := set_like.coe_injective.comp to_opens_injective }\n\ninstance can_lift_set : can_lift (set \u03b1) (open_nhds_of x) coe (\u03bb s, is_open s \u2227 x \u2208 s) :=\n\u27e8\u03bb s hs, \u27e8\u27e8\u27e8s, hs.1\u27e9, hs.2\u27e9, rfl\u27e9\u27e9\n\nprotected lemma mem (U : open_nhds_of x) : x \u2208 U := U.mem'\nprotected lemma is_open (U : open_nhds_of x) : is_open (U : set \u03b1) := U.is_open'\n\ninstance : order_top (open_nhds_of x) :=\n{ top := \u27e8\u22a4, set.mem_univ _\u27e9,\n  le_top := \u03bb _, subset_univ _ }\n\ninstance : inhabited (open_nhds_of x) := \u27e8\u22a4\u27e9\n\ninstance : has_inf (open_nhds_of x) := \u27e8\u03bb U V, \u27e8U.1 \u2293 V.1, U.2, V.2\u27e9\u27e9\n\ninstance : has_sup (open_nhds_of x) := \u27e8\u03bb U V, \u27e8U.1 \u2294 V.1, or.inl U.2\u27e9\u27e9\n\ninstance : distrib_lattice (open_nhds_of x) :=\nto_opens_injective.distrib_lattice _ (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\nlemma basis_nhds : (\ud835\udcdd x).has_basis (\u03bb U : open_nhds_of x, true) coe :=\n(nhds_basis_opens x).to_has_basis (\u03bb U hU, \u27e8\u27e8\u27e8U, hU.2\u27e9, hU.1\u27e9, trivial, subset.rfl\u27e9)\n  (\u03bb U _, \u27e8U, \u27e8\u27e8U.mem, U.is_open\u27e9, subset.rfl\u27e9\u27e9)\n\n/-- Preimage of an open neighborhood of `f x` under a continuous map `f` as a `lattice_hom`. -/\ndef comap (f : C(\u03b1, \u03b2)) (x : \u03b1) : lattice_hom (open_nhds_of (f x)) (open_nhds_of x) :=\n{ to_fun := \u03bb U, \u27e8opens.comap f U.1, U.mem\u27e9,\n  map_sup' := \u03bb U V, rfl,\n  map_inf' := \u03bb 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 \u2192 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 \u2192 finset (tagged V)\n| (var bound _)  := \u2205\n| (var free x)   := {x}\n| (app ef ea)    := fv ef \u222a fv ea\n| (lam _ eb)     := fv eb\n| (let_ _ ed eb) := fv ed \u222a fv eb\n\n@[simp] theorem fv_var_bound : x \u2209 fv (var bound y) :=\nfinset.not_mem_empty x\n\n@[simp] theorem fv_var_free : x \u2209 fv (var free y) \u2194 x \u2260 y :=\n\u27e8finset.not_mem_singleton.mp,\n \u03bb p h, absurd (finset.mem_of_mem_insert_of_ne h p) (finset.not_mem_empty x)\u27e9\n\n@[simp] theorem fv_app : x \u2209 fv (app ef ea) \u2194 x \u2209 fv ef \u2227 x \u2209 fv ea :=\nfinset.not_mem_union\n\n@[simp] theorem fv_lam : x \u2209 fv (lam v eb) \u2194 x \u2209 fv eb :=\n\u27e8by rw fv; exact id, by rw fv; exact id\u27e9\n\n@[simp] theorem fv_let_ : x \u2209 fv (let_ v ed eb) \u2194 x \u2209 fv ed \u2227 x \u2209 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 (\u03b1 : Type*) (F : Type*)\n\nstructure is_clone (C : set (op F \u03b1)) :=\n(proj_closed : \u2200 k, (\u03bb (x : F \u2192 \u03b1), x k) \u2208 C)\n(comp_closed : \u2200 f (g : F \u2192 op F \u03b1), f \u2208 C \u2192 (\u2200 i, g i \u2208 C) \u2192 (\u03bb x, f (\u03bb i, g i x)) \u2208 C)\n\nparameter (X : set (op F \u03b1))\n\n-- The smallest clone containing X\ninductive clo : set (op F \u03b1)\n| proj (k) : clo (\u03c0 k)\n-- there are like two different ways to make this SEGFAULT lmao\n| comp {f} {g : F \u2192 op F \u03b1} :\n    f \u2208 X \u2192 (\u2200 i, clo (g i)) \u2192 clo (\u03bb x, f (\u03bb i, g i x))\n\ntheorem clo_contains : X \u2286 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 \u03b1)) :\n  is_clone Y \u2192 X \u2286 Y \u2192 clo \u2286 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 \u2243 (X \u27f6 sierpinski) :=\n\u27e8\u03bb s, Top.mk_hom (\u03bb x, \u27e8x \u2208 s.val\u27e9)\n   (continuous.comp continuous_ulift_up (continuous_Prop.mpr s.property)),\n \u03bb f, \u27e8\u03bb x, (f x).down, continuous_Prop.mp (by continuity)\u27e9,\n \u03bb s, by ext; refl,\n \u03bb f, by ext; refl\u27e9\n\nlemma opens_equiv_nat {X Y : Top} (f : X \u27f6 Y) (s : opens Y) :\n  f \u226b opens_equiv Y s = opens_equiv X \u27e8f \u207b\u00b9' s, f.2 s.val s.property\u27e9 :=\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) \u22a4\n\ndef set_equiv (X : Top) : set X \u2243 (X \u27f6 prop_indisc) :=\n\u27e8\u03bb s, Top.mk_hom (\u03bb x, \u27e8x \u2208 s\u27e9) (by continuity),\n \u03bb f, \u03bb x, (f x).down,\n \u03bb s, by ext; refl,\n \u03bb f, by ext; refl\u27e9\n\nlemma set_equiv_nat {X Y : Top} (f : X \u27f6 Y) (s : set Y) :\n  f \u226b set_equiv Y s = set_equiv X (f \u207b\u00b9' s) :=\nrfl\n\ndef forget_open : sierpinski \u27f6 prop_indisc := Top.mk_hom id\n\ninstance forget_open_mono : mono forget_open :=\n\u27e8\u03bb X f g h, by ext1; apply Top.hom_congr h\u27e9\n\nlemma forget_open_map {X : Top} (s : opens X) :\n  opens_equiv X s \u226b 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\u00e9bastien Gou\u00ebzel\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* `\ud835\udcdd x`: the filter of neighborhoods of a point `x`;\n* `\ud835\udcdf s`: the principal filter of a set `s`;\n* `\ud835\udcdd[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 `\ud835\udcdd[s] a` are sets containing the\nintersection of `s` and a neighborhood of `a`. -/\ndef nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) (s : set \u03b1) : filter \u03b1 :=\n  nhds a \u2293 filter.principal s\n\n@[simp] theorem nhds_bind_nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} : (filter.bind (nhds a) fun (x : \u03b1) => 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 {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} {p : \u03b1 \u2192 Prop} : filter.eventually (fun (y : \u03b1) => filter.eventually (fun (x : \u03b1) => p x) (nhds_within y s)) (nhds a) \u2194\n  filter.eventually (fun (x : \u03b1) => p x) (nhds_within a s) :=\n  iff.mp filter.ext_iff nhds_bind_nhds_within (set_of fun (x : \u03b1) => p x)\n\ntheorem eventually_nhds_within_iff {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} {p : \u03b1 \u2192 Prop} : filter.eventually (fun (x : \u03b1) => p x) (nhds_within a s) \u2194 filter.eventually (fun (x : \u03b1) => x \u2208 s \u2192 p x) (nhds a) :=\n  filter.eventually_inf_principal\n\n@[simp] theorem eventually_nhds_within_nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} {p : \u03b1 \u2192 Prop} : filter.eventually (fun (y : \u03b1) => filter.eventually (fun (x : \u03b1) => p x) (nhds_within y s)) (nhds_within a s) \u2194\n  filter.eventually (fun (x : \u03b1) => p x) (nhds_within a s) := sorry\n\ntheorem nhds_within_eq {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) (s : set \u03b1) : nhds_within a s =\n  infi fun (t : set \u03b1) => infi fun (H : t \u2208 set_of fun (t : set \u03b1) => a \u2208 t \u2227 is_open t) => filter.principal (t \u2229 s) :=\n  filter.has_basis.eq_binfi (filter.has_basis.inf_principal (nhds_basis_opens a) s)\n\ntheorem nhds_within_univ {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) : 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 \u2293 filter.principal set.univ = nhds a)) filter.principal_univ))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (nhds a \u2293 \u22a4 = nhds a)) inf_top_eq)) (Eq.refl (nhds a))))\n\ntheorem nhds_within_has_basis {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {p : \u03b2 \u2192 Prop} {s : \u03b2 \u2192 set \u03b1} {a : \u03b1} (h : filter.has_basis (nhds a) p s) (t : set \u03b1) : filter.has_basis (nhds_within a t) p fun (i : \u03b2) => s i \u2229 t :=\n  filter.has_basis.inf_principal h t\n\ntheorem nhds_within_basis_open {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) (t : set \u03b1) : filter.has_basis (nhds_within a t) (fun (u : set \u03b1) => a \u2208 u \u2227 is_open u) fun (u : set \u03b1) => u \u2229 t :=\n  nhds_within_has_basis (nhds_basis_opens a) t\n\ntheorem mem_nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] {t : set \u03b1} {a : \u03b1} {s : set \u03b1} : t \u2208 nhds_within a s \u2194 \u2203 (u : set \u03b1), is_open u \u2227 a \u2208 u \u2227 u \u2229 s \u2286 t := sorry\n\ntheorem mem_nhds_within_iff_exists_mem_nhds_inter {\u03b1 : Type u_1} [topological_space \u03b1] {t : set \u03b1} {a : \u03b1} {s : set \u03b1} : t \u2208 nhds_within a s \u2194 \u2203 (u : set \u03b1), \u2203 (H : u \u2208 nhds a), u \u2229 s \u2286 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 \u2208 nhds x) (t : set X) : s \\ t \u2208 nhds_within x (t\u1d9c) :=\n  filter.diff_mem_inf_principal_compl hs t\n\ntheorem nhds_of_nhds_within_of_nhds {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {t : set \u03b1} {a : \u03b1} (h1 : s \u2208 nhds a) (h2 : t \u2208 nhds_within a s) : t \u2208 nhds a := sorry\n\ntheorem mem_nhds_within_of_mem_nhds {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {t : set \u03b1} {a : \u03b1} (h : s \u2208 nhds a) : s \u2208 nhds_within a t :=\n  filter.mem_inf_sets_of_left h\n\ntheorem self_mem_nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} : s \u2208 nhds_within a s :=\n  filter.mem_inf_sets_of_right (filter.mem_principal_self s)\n\ntheorem inter_mem_nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] (s : set \u03b1) {t : set \u03b1} {a : \u03b1} (h : t \u2208 nhds a) : s \u2229 t \u2208 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 {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) {s : set \u03b1} {t : set \u03b1} (h : s \u2286 t) : nhds_within a s \u2264 nhds_within a t :=\n  inf_le_inf_left (nhds a) (iff.mpr filter.principal_mono h)\n\ntheorem pure_le_nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} (ha : a \u2208 s) : pure a \u2264 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 {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} {t : set \u03b1} (ha : a \u2208 s) (ht : t \u2208 nhds_within a s) : a \u2208 t :=\n  pure_le_nhds_within ha ht\n\ntheorem filter.eventually.self_of_nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] {p : \u03b1 \u2192 Prop} {s : set \u03b1} {x : \u03b1} (h : filter.eventually (fun (y : \u03b1) => p y) (nhds_within x s)) (hx : x \u2208 s) : p x :=\n  mem_of_mem_nhds_within hx h\n\ntheorem tendsto_const_nhds_within {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {l : filter \u03b2} {s : set \u03b1} {a : \u03b1} (ha : a \u2208 s) : filter.tendsto (fun (x : \u03b2) => 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'' {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} (s : set \u03b1) {t : set \u03b1} (h : t \u2208 nhds_within a s) : nhds_within a s = nhds_within a (s \u2229 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' {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} (s : set \u03b1) {t : set \u03b1} (h : t \u2208 nhds a) : nhds_within a s = nhds_within a (s \u2229 t) :=\n  nhds_within_restrict'' s (filter.mem_inf_sets_of_left h)\n\ntheorem nhds_within_restrict {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} (s : set \u03b1) {t : set \u03b1} (h\u2080 : a \u2208 t) (h\u2081 : is_open t) : nhds_within a s = nhds_within a (s \u2229 t) :=\n  nhds_within_restrict' s (mem_nhds_sets h\u2081 h\u2080)\n\ntheorem nhds_within_le_of_mem {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} {t : set \u03b1} (h : s \u2208 nhds_within a t) : nhds_within a t \u2264 nhds_within a s := sorry\n\ntheorem nhds_within_eq_nhds_within {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} (h\u2080 : a \u2208 s) (h\u2081 : is_open s) (h\u2082 : t \u2229 s = u \u2229 s) : nhds_within a t = nhds_within a u := sorry\n\ntheorem nhds_within_eq_of_open {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} (h\u2080 : a \u2208 s) (h\u2081 : 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\u2081 h\u2080))\n\n@[simp] theorem nhds_within_empty {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) : nhds_within a \u2205 = \u22a5 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (nhds_within a \u2205 = \u22a5)) (nhds_within.equations._eqn_1 a \u2205)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (nhds a \u2293 filter.principal \u2205 = \u22a5)) filter.principal_empty))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (nhds a \u2293 \u22a5 = \u22a5)) inf_bot_eq)) (Eq.refl \u22a5)))\n\ntheorem nhds_within_union {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) (s : set \u03b1) (t : set \u03b1) : nhds_within a (s \u222a t) = nhds_within a s \u2294 nhds_within a t := sorry\n\ntheorem nhds_within_inter {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) (s : set \u03b1) (t : set \u03b1) : nhds_within a (s \u2229 t) = nhds_within a s \u2293 nhds_within a t := sorry\n\ntheorem nhds_within_inter' {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) (s : set \u03b1) (t : set \u03b1) : nhds_within a (s \u2229 t) = nhds_within a s \u2293 filter.principal t := sorry\n\n@[simp] theorem nhds_within_singleton {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) : nhds_within a (singleton a) = pure a := sorry\n\n@[simp] theorem nhds_within_insert {\u03b1 : Type u_1} [topological_space \u03b1] (a : \u03b1) (s : set \u03b1) : nhds_within a (insert a s) = pure a \u2294 nhds_within a s := sorry\n\ntheorem mem_nhds_within_insert {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} {t : set \u03b1} : t \u2208 nhds_within a (insert a s) \u2194 a \u2208 t \u2227 t \u2208 nhds_within a s := sorry\n\ntheorem insert_mem_nhds_within_insert {\u03b1 : Type u_1} [topological_space \u03b1] {a : \u03b1} {s : set \u03b1} {t : set \u03b1} (h : t \u2208 nhds_within a s) : insert a t \u2208 nhds_within a (insert a s) := sorry\n\ntheorem nhds_within_prod_eq {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b2 : Type u_2} [topological_space \u03b2] (a : \u03b1) (b : \u03b2) (s : set \u03b1) (t : set \u03b2) : nhds_within (a, b) (set.prod s t) = filter.prod (nhds_within a s) (nhds_within b t) := sorry\n\ntheorem nhds_within_prod {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b2 : Type u_2} [topological_space \u03b2] {s : set \u03b1} {u : set \u03b1} {t : set \u03b2} {v : set \u03b2} {a : \u03b1} {b : \u03b2} (hu : u \u2208 nhds_within a s) (hv : v \u2208 nhds_within b t) : set.prod u v \u2208 nhds_within (a, b) (set.prod s t) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (set.prod u v \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {p : \u03b1 \u2192 Prop} [decidable_pred p] {a : \u03b1} {s : set \u03b1} {l : filter \u03b2} (h\u2080 : filter.tendsto f (nhds_within a (s \u2229 p)) l) (h\u2081 : filter.tendsto g (nhds_within a (s \u2229 set_of fun (x : \u03b1) => \u00acp x)) l) : filter.tendsto (fun (x : \u03b1) => ite (p x) (f x) (g x)) (nhds_within a s) l := sorry\n\ntheorem map_nhds_within {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (s : set \u03b1) : filter.map f (nhds_within a s) =\n  infi\n    fun (t : set \u03b1) => infi fun (H : t \u2208 set_of fun (t : set \u03b1) => a \u2208 t \u2227 is_open t) => filter.principal (f '' (t \u2229 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {f : \u03b1 \u2192 \u03b2} {a : \u03b1} {s : set \u03b1} {t : set \u03b1} {l : filter \u03b2} (hst : s \u2286 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1} {l : filter \u03b2} {a : \u03b1} {s : set \u03b1} {t : set \u03b1} (hst : s \u2286 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {f : \u03b1 \u2192 \u03b2} {a : \u03b1} {s : set \u03b1} {l : filter \u03b2} (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 {\u03b1 : Type u_1} (s : set \u03b1) (t : set (Subtype fun (x : \u03b1) => x \u2208 s)) : filter.principal t = filter.comap coe (filter.principal (coe '' t)) := sorry\n\ntheorem mem_closure_iff_nhds_within_ne_bot {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {x : \u03b1} : x \u2208 closure s \u2194 filter.ne_bot (nhds_within x s) :=\n  mem_closure_iff_cluster_pt\n\ntheorem nhds_within_ne_bot_of_mem {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {x : \u03b1} (hx : x \u2208 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 {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} (hs : is_closed s) {x : \u03b1} (hx : filter.ne_bot (nhds_within x s)) : x \u2208 s := sorry\n\ntheorem dense_range.nhds_within_ne_bot {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Type u_2} {f : \u03b9 \u2192 \u03b1} (h : dense_range f) (x : \u03b1) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {s : set \u03b1} {a : \u03b1} : filter.eventually_eq (nhds_within a s) f g \u2194 filter.eventually (fun (x : \u03b1) => x \u2208 s \u2192 f x = g x) (nhds a) :=\n  filter.mem_inf_principal\n\ntheorem eventually_eq_nhds_within_of_eq_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {s : set \u03b1} {a : \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {s : set \u03b1} {a : \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {s : set \u03b1} {a : \u03b1} {l : filter \u03b2} (hfg : \u2200 (x : \u03b1), x \u2208 s \u2192 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 {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {a : \u03b1} {p : \u03b1 \u2192 Prop} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 p x) : filter.eventually (fun (x : \u03b1) => 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 {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b2 : Type u_2} {a : \u03b1} {l : filter \u03b2} {s : set \u03b1} (f : \u03b2 \u2192 \u03b1) (h1 : filter.tendsto f l (nhds a)) (h2 : filter.eventually (fun (x : \u03b2) => f x \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {a : \u03b1} (h : filter.eventually_eq (nhds_within a s) f g) (hmem : a \u2208 s) : f a = g a :=\n  filter.eventually.self_of_nhds_within h hmem\n\ntheorem eventually_nhds_within_of_eventually_nhds {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {a : \u03b1} {p : \u03b1 \u2192 Prop} (h : filter.eventually (fun (x : \u03b1) => p x) (nhds a)) : filter.eventually (fun (x : \u03b1) => 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 {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {a : Subtype fun (x : \u03b1) => x \u2208 s} {t : set (Subtype fun (x : \u03b1) => x \u2208 s)} {u : set (Subtype fun (x : \u03b1) => x \u2208 s)} : t \u2208 nhds_within a u \u2194 t \u2208 filter.comap coe (nhds_within (\u2191a) (coe '' u)) := sorry\n\ntheorem nhds_within_subtype {\u03b1 : Type u_1} [topological_space \u03b1] (s : set \u03b1) (a : Subtype fun (x : \u03b1) => x \u2208 s) (t : set (Subtype fun (x : \u03b1) => x \u2208 s)) : nhds_within a t = filter.comap coe (nhds_within (\u2191a) (coe '' t)) :=\n  filter.ext fun (u : set (Subtype fun (x : \u03b1) => x \u2208 s)) => mem_nhds_within_subtype\n\ntheorem nhds_within_eq_map_subtype_coe {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {a : \u03b1} (h : a \u2208 s) : nhds_within a s = filter.map coe (nhds { val := a, property := h }) := sorry\n\ntheorem tendsto_nhds_within_iff_subtype {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] {s : set \u03b1} {a : \u03b1} (h : a \u2208 s) (f : \u03b1 \u2192 \u03b2) (l : filter \u03b2) : filter.tendsto f (nhds_within a s) l \u2194 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\u2080` within a subset `s`\nif `f x` tends to `f x\u2080` when `x` tends to `x\u2080` while staying within `s`. -/\ndef continuous_within_at {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (x : \u03b1) :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) :=\n  \u2200 (x : \u03b1), x \u2208 s \u2192 continuous_within_at f s x\n\ntheorem continuous_on.continuous_within_at {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (hf : continuous_on f s) (hx : x \u2208 s) : continuous_within_at f s x :=\n  hf x hx\n\ntheorem continuous_within_at_univ {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2192 \u03b2) (x : \u03b1) : continuous_within_at f set.univ x \u2194 continuous_at f x := sorry\n\ntheorem continuous_within_at_iff_continuous_at_restrict {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2192 \u03b2) {x : \u03b1} {s : set \u03b1} (h : x \u2208 s) : continuous_within_at f s x \u2194 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {s : set \u03b1} {t : set \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {s : set \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4} {s : set \u03b1} {t : set \u03b2} {x : \u03b1} {y : \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} : continuous_on f s \u2194\n  \u2200 (x : \u03b1), x \u2208 s \u2192 \u2200 (t : set \u03b2), is_open t \u2192 f x \u2208 t \u2192 \u2203 (u : set \u03b1), is_open u \u2227 x \u2208 u \u2227 u \u2229 s \u2286 f \u207b\u00b9' t := sorry\n\ntheorem continuous_on_iff_continuous_restrict {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} : continuous_on f s \u2194 continuous (set.restrict f s) := sorry\n\ntheorem continuous_on_iff' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} : continuous_on f s \u2194 \u2200 (t : set \u03b2), is_open t \u2192 \u2203 (u : set \u03b1), is_open u \u2227 f \u207b\u00b9' t \u2229 s = u \u2229 s := sorry\n\ntheorem continuous_on_iff_is_closed {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} : continuous_on f s \u2194 \u2200 (t : set \u03b2), is_closed t \u2192 \u2203 (u : set \u03b1), is_closed u \u2227 f \u207b\u00b9' t \u2229 s = u \u2229 s := sorry\n\ntheorem continuous_on.prod_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4} {s : set \u03b1} {t : set \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2192 \u03b2) : continuous_on f \u2205 :=\n  fun (x : \u03b1) => false.elim\n\ntheorem nhds_within_le_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {x : \u03b1} {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} (ctsf : continuous_within_at f s x) : nhds_within x s \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2192 \u03b2) {x : \u03b1} {s : set \u03b1} : continuous_within_at f s x \u2194 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} : continuous f \u2194 continuous_on f set.univ := sorry\n\ntheorem continuous_within_at.mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b1} {x : \u03b1} (h : continuous_within_at f t x) (hs : s \u2286 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b1} {x : \u03b1} (h : continuous_within_at f t x) (hs : t \u2208 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' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b1} {x : \u03b1} (h : t \u2208 nhds_within x s) : continuous_within_at f (s \u2229 t) x \u2194 continuous_within_at f s x := sorry\n\ntheorem continuous_within_at_inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b1} {x : \u03b1} (h : t \u2208 nhds x) : continuous_within_at f (s \u2229 t) x \u2194 continuous_within_at f s x := sorry\n\ntheorem continuous_within_at_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b1} {x : \u03b1} : continuous_within_at f (s \u222a t) x \u2194 continuous_within_at f s x \u2227 continuous_within_at f t x := sorry\n\ntheorem continuous_within_at.union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b1} {x : \u03b1} (hs : continuous_within_at f s x) (ht : continuous_within_at f t x) : continuous_within_at f (s \u222a t) x :=\n  iff.mpr continuous_within_at_union { left := hs, right := ht }\n\ntheorem continuous_within_at.mem_closure_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (h : continuous_within_at f s x) (hx : x \u2208 closure s) : f x \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} {A : set \u03b2} (h : continuous_within_at f s x) (hx : x \u2208 closure s) (hA : s \u2286 f \u207b\u00b9' A) : f x \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (hf : \u2200 (x : \u03b1), x \u2208 closure s \u2192 continuous_within_at f s x) : f '' closure s \u2286 closure (f '' s) := sorry\n\n@[simp] theorem continuous_within_at_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {x : \u03b1} : continuous_within_at f (singleton x) x := sorry\n\n@[simp] theorem continuous_within_at_insert_self {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {s : set \u03b1} : continuous_within_at f (insert x s) x \u2194 continuous_within_at f s x := sorry\n\ntheorem continuous_within_at.insert_self {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {s : set \u03b1} : continuous_within_at f s x \u2192 continuous_within_at f (insert x s) x :=\n  iff.mpr continuous_within_at_insert_self\n\ntheorem continuous_within_at.diff_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b1} {x : \u03b1} (ht : continuous_within_at f t x) : continuous_within_at f (s \\ t) x \u2194 continuous_within_at f s x := sorry\n\n@[simp] theorem continuous_within_at_diff_self {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} : continuous_within_at f (s \\ singleton x) x \u2194 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (h : is_open_map (set.restrict f s)) {finv : \u03b2 \u2192 \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : is_open_map f) {finv : \u03b2 \u2192 \u03b1} (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 : \u03b1) (_x : x \u2208 set.univ) => hleft x)\n\ntheorem continuous_on.congr_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {s : set \u03b1} {s\u2081 : set \u03b1} (h : continuous_on f s) (h' : set.eq_on g f s\u2081) (h\u2081 : s\u2081 \u2286 s) : continuous_on g s\u2081 := sorry\n\ntheorem continuous_on.congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {s : set \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {s : set \u03b1} (h' : set.eq_on g f s) : continuous_on g s \u2194 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (h : continuous_within_at f s x) (hs : s \u2208 nhds x) : continuous_at f x := sorry\n\ntheorem continuous_on.continuous_at {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (h : continuous_on f s) (hx : s \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b2} {x : \u03b1} (hg : continuous_within_at g t (f x)) (hf : continuous_within_at f s x) (h : s \u2286 f \u207b\u00b9' t) : continuous_within_at (g \u2218 f) s x := sorry\n\ntheorem continuous_within_at.comp' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b2} {x : \u03b1} (hg : continuous_within_at g t (f x)) (hf : continuous_within_at f s x) : continuous_within_at (g \u2218 f) (s \u2229 f \u207b\u00b9' t) x :=\n  continuous_within_at.comp hg (continuous_within_at.mono hf (set.inter_subset_left s (f \u207b\u00b9' t)))\n    (set.inter_subset_right s (f \u207b\u00b9' t))\n\ntheorem continuous_on.comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b2} (hg : continuous_on g t) (hf : continuous_on f s) (h : s \u2286 f \u207b\u00b9' t) : continuous_on (g \u2218 f) s :=\n  fun (x : \u03b1) (hx : x \u2208 s) => continuous_within_at.comp (hg (f x) (h hx)) (hf x hx) h\n\ntheorem continuous_on.mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b1} (hf : continuous_on f s) (h : t \u2286 s) : continuous_on f t :=\n  fun (x : \u03b1) (hx : x \u2208 t) => filter.tendsto.mono_left (hf x (h hx)) (nhds_within_mono x h)\n\ntheorem continuous_on.comp' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b2} (hg : continuous_on g t) (hf : continuous_on f s) : continuous_on (g \u2218 f) (s \u2229 f \u207b\u00b9' t) :=\n  continuous_on.comp hg (continuous_on.mono hf (set.inter_subset_left s (f \u207b\u00b9' t))) (set.inter_subset_right s (f \u207b\u00b9' t))\n\ntheorem continuous.continuous_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (hg : continuous g) (hf : continuous_on f s) : continuous_on (g \u2218 f) s :=\n  continuous_on.comp (continuous.continuous_on hg) hf set.subset_preimage_univ\n\ntheorem continuous_on.comp_continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} (hg : continuous_on g s) (hf : continuous f) (hs : \u2200 (x : \u03b1), f x \u2208 s) : continuous (g \u2218 f) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (continuous (g \u2218 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 : \u03b1) (_x : x \u2208 set.univ) => hs x)\n\ntheorem continuous_within_at.preimage_mem_nhds_within {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {s : set \u03b1} {t : set \u03b2} (h : continuous_within_at f s x) (ht : t \u2208 nhds (f x)) : f \u207b\u00b9' t \u2208 nhds_within x s :=\n  h ht\n\ntheorem continuous_within_at.preimage_mem_nhds_within' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {s : set \u03b1} {t : set \u03b2} (h : continuous_within_at f s x) (ht : t \u2208 nhds_within (f x) (f '' s)) : f \u207b\u00b9' t \u2208 nhds_within x s := sorry\n\ntheorem continuous_within_at.congr_of_eventually_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {f\u2081 : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (h : continuous_within_at f s x) (h\u2081 : filter.eventually_eq (nhds_within x s) f\u2081 f) (hx : f\u2081 x = f x) : continuous_within_at f\u2081 s x := sorry\n\ntheorem continuous_within_at.congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {f\u2081 : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} (h : continuous_within_at f s x) (h\u2081 : \u2200 (y : \u03b1), y \u2208 s \u2192 f\u2081 y = f y) (hx : f\u2081 x = f x) : continuous_within_at f\u2081 s x :=\n  continuous_within_at.congr_of_eventually_eq h (filter.mem_sets_of_superset self_mem_nhds_within h\u2081) hx\n\ntheorem continuous_within_at.congr_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {s : set \u03b1} {s\u2081 : set \u03b1} {x : \u03b1} (h : continuous_within_at f s x) (h' : set.eq_on g f s\u2081) (h\u2081 : s\u2081 \u2286 s) (hx : g x = f x) : continuous_within_at g s\u2081 x :=\n  continuous_within_at.congr (continuous_within_at.mono h h\u2081) h' hx\n\ntheorem continuous_on_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {s : set \u03b1} {c : \u03b2} : continuous_on (fun (x : \u03b1) => c) s :=\n  continuous.continuous_on continuous_const\n\ntheorem continuous_within_at_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {b : \u03b2} {s : set \u03b1} {x : \u03b1} : continuous_within_at (fun (_x : \u03b1) => b) s x :=\n  continuous.continuous_within_at continuous_const\n\ntheorem continuous_on_id {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} : continuous_on id s :=\n  continuous.continuous_on continuous_id\n\ntheorem continuous_within_at_id {\u03b1 : Type u_1} [topological_space \u03b1] {s : set \u03b1} {x : \u03b1} : continuous_within_at id s x :=\n  continuous.continuous_within_at continuous_id\n\ntheorem continuous_on_open_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (hs : is_open s) : continuous_on f s \u2194 \u2200 (t : set \u03b2), is_open t \u2192 is_open (s \u2229 f \u207b\u00b9' t) := sorry\n\ntheorem continuous_on.preimage_open_of_open {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b2} (hf : continuous_on f s) (hs : is_open s) (ht : is_open t) : is_open (s \u2229 f \u207b\u00b9' t) :=\n  iff.mp (continuous_on_open_iff hs) hf t ht\n\ntheorem continuous_on.preimage_closed_of_closed {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b2} (hf : continuous_on f s) (hs : is_closed s) (ht : is_closed t) : is_closed (s \u2229 f \u207b\u00b9' t) := sorry\n\ntheorem continuous_on.preimage_interior_subset_interior_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {t : set \u03b2} (hf : continuous_on f s) (hs : is_open s) : s \u2229 f \u207b\u00b9' interior t \u2286 s \u2229 interior (f \u207b\u00b9' t) := sorry\n\ntheorem continuous_on_of_locally_continuous_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 \u2203 (t : set \u03b1), is_open t \u2227 x \u2208 t \u2227 continuous_on f (s \u2229 t)) : continuous_on f s := sorry\n\ntheorem continuous_on_open_of_generate_from {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b2 : Type u_2} {s : set \u03b1} {T : set (set \u03b2)} {f : \u03b1 \u2192 \u03b2} (hs : is_open s) (h : \u2200 (t : set \u03b2), t \u2208 T \u2192 is_open (s \u2229 f \u207b\u00b9' t)) : continuous_on f s := sorry\n\ntheorem continuous_within_at.prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} {s : set \u03b1} {x : \u03b1} (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) : continuous_within_at (fun (x : \u03b1) => (f x, g x)) s x :=\n  filter.tendsto.prod_mk_nhds hf hg\n\ntheorem continuous_on.prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} {s : set \u03b1} (hf : continuous_on f s) (hg : continuous_on g s) : continuous_on (fun (x : \u03b1) => (f x, g x)) s :=\n  fun (x : \u03b1) (hx : x \u2208 s) => continuous_within_at.prod (hf x hx) (hg x hx)\n\ntheorem inducing.continuous_on_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hg : inducing g) {s : set \u03b1} : continuous_on f s \u2194 continuous_on (g \u2218 f) s := sorry\n\ntheorem embedding.continuous_on_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hg : embedding g) {s : set \u03b1} : continuous_on f s \u2194 continuous_on (g \u2218 f) s :=\n  inducing.continuous_on_iff (embedding.to_inducing hg)\n\ntheorem continuous_within_at_of_not_mem_closure {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1} : \u00acx \u2208 closure s \u2192 continuous_within_at f s x := sorry\n\ntheorem continuous_on_if' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {s : set \u03b1} {p : \u03b1 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {h : (a : \u03b1) \u2192 Decidable (p a)} (hpf : \u2200 (a : \u03b1),\n  a \u2208 s \u2229 frontier (set_of fun (a : \u03b1) => p a) \u2192\n    filter.tendsto f (nhds_within a (s \u2229 set_of fun (a : \u03b1) => p a)) (nhds (ite (p a) (f a) (g a)))) (hpg : \u2200 (a : \u03b1),\n  a \u2208 s \u2229 frontier (set_of fun (a : \u03b1) => p a) \u2192\n    filter.tendsto g (nhds_within a (s \u2229 set_of fun (a : \u03b1) => \u00acp a)) (nhds (ite (p a) (f a) (g a)))) (hf : continuous_on f (s \u2229 set_of fun (a : \u03b1) => p a)) (hg : continuous_on g (s \u2229 set_of fun (a : \u03b1) => \u00acp a)) : continuous_on (fun (a : \u03b1) => ite (p a) (f a) (g a)) s := sorry\n\ntheorem continuous_on_if {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {p : \u03b1 \u2192 Prop} {h : (a : \u03b1) \u2192 Decidable (p a)} {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (hp : \u2200 (a : \u03b1), a \u2208 s \u2229 frontier (set_of fun (a : \u03b1) => p a) \u2192 f a = g a) (hf : continuous_on f (s \u2229 closure (set_of fun (a : \u03b1) => p a))) (hg : continuous_on g (s \u2229 closure (set_of fun (a : \u03b1) => \u00acp a))) : continuous_on (fun (a : \u03b1) => ite (p a) (f a) (g a)) s := sorry\n\ntheorem continuous_if' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {p : \u03b1 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {h : (a : \u03b1) \u2192 Decidable (p a)} (hpf : \u2200 (a : \u03b1),\n  a \u2208 frontier (set_of fun (x : \u03b1) => p x) \u2192\n    filter.tendsto f (nhds_within a (set_of fun (x : \u03b1) => p x)) (nhds (ite (p a) (f a) (g a)))) (hpg : \u2200 (a : \u03b1),\n  a \u2208 frontier (set_of fun (x : \u03b1) => p x) \u2192\n    filter.tendsto g (nhds_within a (set_of fun (x : \u03b1) => \u00acp x)) (nhds (ite (p a) (f a) (g a)))) (hf : continuous_on f (set_of fun (x : \u03b1) => p x)) (hg : continuous_on g (set_of fun (x : \u03b1) => \u00acp x)) : continuous fun (a : \u03b1) => ite (p a) (f a) (g a) := sorry\n\ntheorem continuous_on_fst {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {s : set (\u03b1 \u00d7 \u03b2)} : continuous_on prod.fst s :=\n  continuous.continuous_on continuous_fst\n\ntheorem continuous_within_at_fst {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {s : set (\u03b1 \u00d7 \u03b2)} {p : \u03b1 \u00d7 \u03b2} : continuous_within_at prod.fst s p :=\n  continuous.continuous_within_at continuous_fst\n\ntheorem continuous_on_snd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {s : set (\u03b1 \u00d7 \u03b2)} : continuous_on prod.snd s :=\n  continuous.continuous_on continuous_snd\n\ntheorem continuous_within_at_snd {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {s : set (\u03b1 \u00d7 \u03b2)} {p : \u03b1 \u00d7 \u03b2} : 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` (`\u224b`, `\\~~~`). -/\ninductive Fam.Cat.Hom.Equiv\n  {\u2102 : Cat}\n  {\u03b1 \u03b2 : \u2102.Obj}\n  (f : \u03b1 \u21a0 \u03b2)\n: {\u03b3 \u03b4 : \u2102.Obj}\n  \u2192 (\u03b3 \u21a0 \u03b4)\n  \u2192 Prop\nwhere\n| proof :\n  (g : \u03b1 \u21a0 \u03b2)\n  \u2192 f \u2248 g\n  \u2192 Equiv f g\n\n\n/-- Predicate for *\"`f` and `g` are equivalent\"* (`\u224b`, `\\~~~`). -/\nabbrev Fam.Cat.Hom.Equiv.equiv\n  {\u2102 : Cat}\n  {\u03b1 \u03b2 \u03b3 \u03b4 : \u2102.Obj}\n  (f : \u03b1 \u21a0 \u03b2)\n  (g : \u03b3 \u21a0 \u03b4)\n: Prop :=\n  @Equiv \u2102 \u03b1 \u03b2 f \u03b3 \u03b4 g\n\ninfix:30 \" \u224b \" =>\n  Fam.Cat.Hom.Equiv.equiv\n\n\n\ntheorem Fam.Cat.Hom.Equiv.domEq\n  {\u2102 : Cat}\n  {\u03b1 \u03b2 \u03b3 \u03b4 : \u2102.Obj}\n  {f : \u03b1 \u21a0 \u03b2}\n  {g : \u03b3 \u21a0 \u03b4}\n  (h : f \u224b g)\n: \u03b1 = \u03b3 :=\n  by\n    cases h with\n    | proof _ _ =>\n      rfl\n\ntheorem Fam.Cat.Hom.Equiv.codEq\n  {\u2102 : Cat}\n  {\u03b1 \u03b2 \u03b3 \u03b4 : \u2102.Obj}\n  {f : \u03b1 \u21a0 \u03b2}\n  {g : \u03b3 \u21a0 \u03b4}\n  (h : f \u224b g)\n: \u03b2 = \u03b4 :=\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  {\u2102 : Cat}\n  {\u03b1 \u03b2 \u03b3 \u03b4 : \u2102.Obj}\n  {f : \u03b1 \u21a0 \u03b2}\n  {g : \u03b3 \u21a0 \u03b4}\n  (h : f \u224b g)\n: (\n  @Equiv \u2102 \u03b1 \u03b2 f \u03b1 \u03b2 (\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  {\u2102 : Cat}\n  {\u03b1 \u03b2 : \u2102.Obj}\n  {f : \u03b1 \u21a0 \u03b2}\n  {g : \u03b1 \u21a0 \u03b2}\n  (h : f \u224b g)\n: (f \u2248 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 : \u03b1 \u2192 \u03b1 \u2192 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    {\u2102 : Cat}\n    {\u03b1 \u03b2 : \u2102.Obj}\n    (f : \u03b1 \u21a0 \u03b2)\n  : f \u224b f :=\n    let eq_f :=\n      \u2102.Hom \u03b1 \u03b2 |>.refl f\n    proof f eq_f\n\n  theorem symm\n    {\u2102 : Cat}\n    {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : \u2102.Obj}\n    (f\u2081 : \u03b1\u2081 \u21a0 \u03b2\u2081)\n    (f\u2082 : \u03b1\u2082 \u21a0 \u03b2\u2082)\n  : f\u2081 \u224b f\u2082 \u2192 f\u2082 \u224b f\u2081 :=\n    by\n      intro h\n      cases h\n      apply proof\n      apply \u2102.Hom \u03b1\u2081 \u03b2\u2081 |>.symm\n      assumption\n\n  theorem trans\n    {\u2102 : Cat}\n    {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 \u03b1\u2083 \u03b2\u2083 : \u2102.Obj}\n    {f\u2081 : \u03b1\u2081 \u21a0 \u03b2\u2081}\n    {f\u2082 : \u03b1\u2082 \u21a0 \u03b2\u2082}\n    {f\u2083 : \u03b1\u2083 \u21a0 \u03b2\u2083}\n  : f\u2081 \u224b f\u2082 \u2192 f\u2082 \u224b f\u2083 \u2192 f\u2081 \u224b f\u2083 :=\n    by\n      intro h\u2081\u2082 h\u2082\u2083\n      cases h\u2081\u2082 ; cases h\u2082\u2083\n      apply proof\n      apply \u2102.Hom \u03b1\u2081 \u03b2\u2081 |>.trans\n      <;> assumption\n\nend Fam.Cat.Hom.Equiv\n\ninstance instTransHomEq\n  {\u2102 : Fam.Cat}\n  {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 \u03b1\u2083 \u03b2\u2083 : \u2102.Obj}\n: Trans\n  (@Fam.Cat.Hom.Equiv.equiv \u2102 \u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082)\n  (@Fam.Cat.Hom.Equiv.equiv \u2102 \u03b1\u2082 \u03b2\u2082 \u03b1\u2083 \u03b2\u2083)\n  (@Fam.Cat.Hom.Equiv.equiv \u2102 \u03b1\u2081 \u03b2\u2081 \u03b1\u2083 \u03b2\u2083)\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 `\u2113^\u221e(\u211d)` up to isometry, which is a well-defined type,\nand define the distance as the infimum of the Hausdorff distance over all\nembeddings in `\u2113^\u221e(\u211d)`. We prove that this coincides with the previous description,\nas all separable metric spaces embed isometrically into `\u2113^\u221e(\u211d)`, 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 `\u2113_infty_\u211d`:= lp (\u03bb n : \u2115, \u211d) \u221e\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 `\u2113^\u221e(\u211d)` 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 \u2113_infty_\u211d \u2192 nonempty_compacts \u2113_infty_\u211d \u2192 Prop :=\n\u03bb x y, nonempty (x \u2243\u1d62 y)\n\n/-- This is indeed an equivalence relation -/\nprivate lemma is_equivalence_isometry_rel : equivalence isometry_rel :=\n\u27e8\u03bb x, \u27e8isometry_equiv.refl _\u27e9, \u03bb x y \u27e8e\u27e9, \u27e8e.symm\u27e9, \u03bb x y z \u27e8e\u27e9 \u27e8f\u27e9, \u27e8e.trans f\u27e9\u27e9\n\n/-- setoid instance identifying two isometric nonempty compact subspaces of \u2113^\u221e(\u211d) -/\ninstance isometry_rel.setoid : setoid (nonempty_compacts \u2113_infty_\u211d) :=\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  \u27e6nonempty_compacts.Kuratowski_embedding X\u27e7\n\ninstance : inhabited GH_space := \u27e8quot.mk _ \u27e8\u27e8{0}, is_compact_singleton\u27e9, singleton_nonempty _\u27e9\u27e9\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 \u2113_infty_\u211d)\n\nlemma eq_to_GH_space_iff {X : Type u} [metric_space X] [compact_space X] [nonempty X]\n  {p : nonempty_compacts \u2113_infty_\u211d} :\n  \u27e6p\u27e7 = to_GH_space X \u2194 \u2203 \u03a8 : X \u2192 \u2113_infty_\u211d, isometry \u03a8 \u2227 range \u03a8 = p :=\nbegin\n  simp only [to_GH_space, quotient.eq],\n  refine \u27e8\u03bb h, _, _\u27e9,\n  { rcases setoid.symm h with \u27e8e\u27e9,\n    have f := (Kuratowski_embedding.isometry X).isometry_equiv_on_range.trans e,\n    use [\u03bb 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 \u27e8\u03a8, \u27e8isom\u03a8, range\u03a8\u27e9\u27e9,\n    have f := ((Kuratowski_embedding.isometry X).isometry_equiv_on_range.symm.trans\n               isom\u03a8.isometry_equiv_on_range).symm,\n    have E : (range \u03a8 \u2243\u1d62 nonempty_compacts.Kuratowski_embedding X) =\n        (p \u2243\u1d62 range (Kuratowski_embedding X)),\n      by { dunfold nonempty_compacts.Kuratowski_embedding, rw [range\u03a8]; refl },\n    exact \u27e8cast E f\u27e9 }\nend\n\nlemma eq_to_GH_space {p : nonempty_compacts \u2113_infty_\u211d} : \u27e6p\u27e7 = to_GH_space p :=\neq_to_GH_space_iff.2 \u27e8\u03bb x, x, isometry_subtype_coe, subtype.range_coe\u27e9\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 \u2113_infty_\u211d) = p,\n  rw \u2190 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 `\u2113^\u221e(\u211d)`, but we will prove below that it works for all spaces. -/\ninstance : has_dist (GH_space) :=\n{ dist := \u03bb x y, Inf $\n    (\u03bb p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d,\n      Hausdorff_dist (p.1 : set \u2113_infty_\u211d) p.2) '' ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = 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] : \u211d := 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  {\u03b3 : Type w} [metric_space \u03b3] {\u03a6 : X \u2192 \u03b3} {\u03a8 : Y \u2192 \u03b3} (ha : isometry \u03a6) (hb : isometry \u03a8) :\n  GH_dist X Y \u2264 Hausdorff_dist (range \u03a6) (range \u03a8) :=\nbegin\n  /- For the proof, we want to embed `\u03b3` in `\u2113^\u221e(\u211d)`, to say that the Hausdorff distance is realized\n  in `\u2113^\u221e(\u211d)` and therefore bounded below by the Gromov-Hausdorff-distance. However, `\u03b3` is not\n  separable in general. We restrict to the union of the images of `X` and `Y` in `\u03b3`, which is\n  separable and therefore embeddable in `\u2113^\u221e(\u211d)`. -/\n  rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n  let s : set \u03b3 := (range \u03a6) \u222a (range \u03a8),\n  let \u03a6' : X \u2192 subtype s := \u03bb y, \u27e8\u03a6 y, mem_union_left _ (mem_range_self _)\u27e9,\n  let \u03a8' : Y \u2192 subtype s := \u03bb y, \u27e8\u03a8 y, mem_union_right _ (mem_range_self _)\u27e9,\n  have I\u03a6' : isometry \u03a6' := \u03bb x y, ha x y,\n  have I\u03a8' : isometry \u03a8' := \u03bb 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) := \u27e8is_compact_iff_is_compact_univ.1 \u2039is_compact s\u203a\u27e9,\n  haveI : nonempty (subtype s) := \u27e8\u03a6' xX\u27e9,\n  have \u03a6\u03a6' : \u03a6 = subtype.val \u2218 \u03a6', by { funext, refl },\n  have \u03a8\u03a8' : \u03a8 = subtype.val \u2218 \u03a8', by { funext, refl },\n  have : Hausdorff_dist (range \u03a6) (range \u03a8) = Hausdorff_dist (range \u03a6') (range \u03a8'),\n  { rw [\u03a6\u03a6', \u03a8\u03a8', range_comp, range_comp],\n    exact Hausdorff_dist_image (isometry_subtype_coe) },\n  rw this,\n  -- Embed `s` in `\u2113^\u221e(\u211d)` through its Kuratowski embedding\n  let F := Kuratowski_embedding (subtype s),\n  have : Hausdorff_dist (F '' (range \u03a6')) (F '' (range \u03a8')) =\n    Hausdorff_dist (range \u03a6') (range \u03a8') := Hausdorff_dist_image (Kuratowski_embedding.isometry _),\n  rw \u2190 this,\n  -- Let `A` and `B` be the images of `X` and `Y` under this embedding. They are in `\u2113^\u221e(\u211d)`, and\n  -- their Hausdorff distance is the same as in the original space.\n  let A : nonempty_compacts \u2113_infty_\u211d := \u27e8\u27e8F '' (range \u03a6'), (is_compact_range I\u03a6'.continuous).image\n    (Kuratowski_embedding.isometry _).continuous\u27e9, (range_nonempty _).image _\u27e9,\n  let B : nonempty_compacts \u2113_infty_\u211d := \u27e8\u27e8F '' (range \u03a8'), (is_compact_range I\u03a8'.continuous).image\n    (Kuratowski_embedding.isometry _).continuous\u27e9, (range_nonempty _).image _\u27e9,\n  have AX : \u27e6A\u27e7 = to_GH_space X,\n  { rw eq_to_GH_space_iff,\n    exact \u27e8\u03bb x, F (\u03a6' x), (Kuratowski_embedding.isometry _).comp I\u03a6', range_comp _ _\u27e9 },\n  have BY : \u27e6B\u27e7 = to_GH_space Y,\n  { rw eq_to_GH_space_iff,\n    exact \u27e8\u03bb x, F (\u03a8' x), (Kuratowski_embedding.isometry _).comp I\u03a8', range_comp _ _\u27e9 },\n  refine cInf_le \u27e80, _\u27e9 _,\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 \u2190 ht,\n    exact Hausdorff_dist_nonneg },\n  apply (mem_image _ _ _).2,\n  existsi (\u27e8A, B\u27e9 : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\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 `\u2264`, 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 \u2295 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 : \u2200 p q : nonempty_compacts \u2113_infty_\u211d, \u27e6p\u27e7 = to_GH_space X \u2192 \u27e6q\u27e7 = to_GH_space Y \u2192\n        Hausdorff_dist (p : set \u2113_infty_\u211d) q < diam (univ : set X) + 1 + diam (univ : set Y) \u2192\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) \u2264\n        Hausdorff_dist (p : set \u2113_infty_\u211d) q,\n  { assume p q hp hq bound,\n    rcases eq_to_GH_space_iff.1 hp with \u27e8\u03a6, \u27e8\u03a6isom, \u03a6range\u27e9\u27e9,\n    rcases eq_to_GH_space_iff.1 hq with \u27e8\u03a8, \u27e8\u03a8isom, \u03a8range\u27e9\u27e9,\n    have I : diam (range \u03a6 \u222a range \u03a8) \u2264 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y),\n    { rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n      have : \u2203 y \u2208 range \u03a8, dist (\u03a6 xX) y < diam (univ : set X) + 1 + diam (univ : set Y),\n      { rw \u03a8range,\n        have : \u03a6 xX \u2208 \u2191p := \u03a6range.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 \u27e8y, hy, dy\u27e9,\n      rcases mem_range.1 hy with \u27e8z, hzy\u27e9,\n      rw \u2190 hzy at dy,\n      have D\u03a6 : diam (range \u03a6) = diam (univ : set X) := \u03a6isom.diam_range,\n      have D\u03a8 : diam (range \u03a8) = diam (univ : set Y) := \u03a8isom.diam_range,\n      calc\n        diam (range \u03a6 \u222a range \u03a8) \u2264 diam (range \u03a6) + dist (\u03a6 xX) (\u03a8 z) + diam (range \u03a8) :\n          diam_union (mem_range_self _) (mem_range_self _)\n        ... \u2264 diam (univ : set X) + (diam (univ : set X) + 1 + diam (univ : set Y)) +\n              diam (univ : set Y) :\n          by { rw [D\u03a6, D\u03a8], 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 \u2295 Y \u2192 \u2113_infty_\u211d := \u03bb x, match x with | inl y := \u03a6 y | inr z := \u03a8 z end,\n    let F : (X \u2295 Y) \u00d7 (X \u2295 Y) \u2192 \u211d := \u03bb p, dist (f p.1) (f p.2),\n    -- check that the induced \"distance\" is a candidate\n    have Fgood : F \u2208 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 \u03bb x y, calc\n        F (inl x, inl y) = dist (\u03a6 x) (\u03a6 y) : rfl\n        ... = dist x y : \u03a6isom.dist_eq x y },\n      { exact \u03bb x y, calc\n        F (inr x, inr y) = dist (\u03a8 x) (\u03a8 y) : rfl\n        ... = dist x y : \u03a8isom.dist_eq x y },\n      { exact \u03bb x y, dist_comm _ _ },\n      { exact \u03bb x y z, dist_triangle _ _ _ },\n      { exact \u03bb x y, calc\n        F (x, y) \u2264 diam (range \u03a6 \u222a range \u03a8) :\n        begin\n          have A : \u2200 z : X \u2295 Y, f z \u2208 range \u03a6 \u222a range \u03a8,\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 [\u03a6range, \u03a8range],\n          exact (p \u2294 q).is_compact.bounded,\n        end\n        ... \u2264 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)) \u2264 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 (\u03bb r hr, _)),\n    have I1 : \u2200 x : X, (\u2a05 y, Fb (inl x, inr y)) \u2264 r,\n    { assume x,\n      have : f (inl x) \u2208 \u2191p := \u03a6range.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 \u27e8z, zq, hz\u27e9,\n      have : z \u2208 range \u03a8, by rwa [\u2190 \u03a8range] at zq,\n      rcases mem_range.1 this with \u27e8y, hy\u27e9,\n      calc (\u2a05 y, Fb (inl x, inr y)) \u2264 Fb (inl x, inr y) :\n          cinfi_le (by simpa only [add_zero] using HD_below_aux1 0) y\n        ... = dist (\u03a6 x) (\u03a8 y) : rfl\n        ... = dist (f (inl x)) z : by rw hy\n        ... \u2264 r : le_of_lt hz },\n    have I2 : \u2200 y : Y, (\u2a05 x, Fb (inl x, inr y)) \u2264 r,\n    { assume y,\n      have : f (inr y) \u2208 \u2191q := \u03a8range.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 \u27e8z, zq, hz\u27e9,\n      have : z \u2208 range \u03a6, by rwa [\u2190 \u03a6range] at zq,\n      rcases mem_range.1 this with \u27e8x, hx\u27e9,\n      calc (\u2a05 x, Fb (inl x, inr y)) \u2264 Fb (inl x, inr y) :\n          cinfi_le (by simpa only [add_zero] using HD_below_aux2 0) x\n        ... = dist (\u03a6 x) (\u03a8 y) : rfl\n        ... = dist z (f (inr y)) : by rw hx\n        ... \u2264 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 : \u2200 p q : nonempty_compacts \u2113_infty_\u211d, \u27e6p\u27e7 = to_GH_space X \u2192 \u27e6q\u27e7 = to_GH_space Y \u2192\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) \u2264\n        Hausdorff_dist (p : set \u2113_infty_\u211d) q,\n  { assume p q hp hq,\n    by_cases h :\n      Hausdorff_dist (p : set \u2113_infty_\u211d) 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               \u2264 HD (candidates_b_dist X Y) :\n             Hausdorff_dist_optimal_le_HD _ _ (candidates_b_dist_mem_candidates_b)\n           ... \u2264 diam (univ : set X) + 1 + diam (univ : set Y) : HD_candidates_b_dist_le\n           ... \u2264 Hausdorff_dist (p : set \u2113_infty_\u211d) q : not_lt.1 h } },\n  refine le_antisymm _ _,\n  { apply le_cInf,\n    { refine (set.nonempty.prod _ _).image _; exact \u27e8_, rfl\u27e9 },\n    { rintro b \u27e8\u27e8p, q\u27e9, \u27e8hp, hq\u27e9, rfl\u27e9,\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 `\u2113^\u221e(\u211d)`, 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  \u2203 \u03a6 : X \u2192 \u2113_infty_\u211d, \u2203 \u03a8 : Y \u2192 \u2113_infty_\u211d, isometry \u03a6 \u2227 isometry \u03a8 \u2227\n  GH_dist X Y = Hausdorff_dist (range \u03a6) (range \u03a8) :=\nbegin\n  let F := Kuratowski_embedding (optimal_GH_coupling X Y),\n  let \u03a6 := F \u2218 optimal_GH_injl X Y,\n  let \u03a8 := F \u2218 optimal_GH_injr X Y,\n  refine \u27e8\u03a6, \u03a8, _, _, _\u27e9,\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 [\u2190 image_univ, \u2190 image_univ, image_comp F, image_univ, image_comp F (optimal_GH_injr X Y),\n      image_univ, \u2190 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 := \u03bb x, begin\n    rcases exists_rep x with \u27e8y, hy\u27e9,\n    refine le_antisymm _ _,\n    { apply cInf_le,\n      { exact \u27e80, by { rintro b \u27e8\u27e8u, v\u27e9, \u27e8hu, hv\u27e9, rfl\u27e9, exact Hausdorff_dist_nonneg } \u27e9},\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 \u27e8y, hy\u27e9 \u27e8y, hy\u27e9).image _ },\n      { rintro b \u27e8\u27e8u, v\u27e9, \u27e8hu, hv\u27e9, rfl\u27e9, exact Hausdorff_dist_nonneg } },\n  end,\n  dist_comm := \u03bb x y, begin\n    have A : (\u03bb (p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\n                 Hausdorff_dist (p.1 : set \u2113_infty_\u211d) p.2) ''\n             ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = y})\n           = ((\u03bb (p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\n                 Hausdorff_dist (p.1 : set \u2113_infty_\u211d) p.2) \u2218 prod.swap) ''\n                 ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = 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 := \u03bb 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 \u27e8\u03a6, \u03a8, \u03a6isom, \u03a8isom, D\u03a6\u03a8\u27e9,\n    rw [\u2190 dist_GH_dist, hxy] at D\u03a6\u03a8,\n    have : range \u03a6 = range \u03a8,\n    { have h\u03a6 : is_compact (range \u03a6) := is_compact_range \u03a6isom.continuous,\n      have h\u03a8 : is_compact (range \u03a8) := is_compact_range \u03a8isom.continuous,\n      apply (is_closed.Hausdorff_dist_zero_iff_eq _ _ _).1 (D\u03a6\u03a8.symm),\n      { exact h\u03a6.is_closed },\n      { exact h\u03a8.is_closed },\n      { exact Hausdorff_edist_ne_top_of_nonempty_of_bounded (range_nonempty _)\n          (range_nonempty _) h\u03a6.bounded h\u03a8.bounded } },\n    have T : ((range \u03a8) \u2243\u1d62 y.rep) = ((range \u03a6) \u2243\u1d62 y.rep), by rw this,\n    have e\u03a8 := cast T \u03a8isom.isometry_equiv_on_range.symm,\n    have e := \u03a6isom.isometry_equiv_on_range.trans e\u03a8,\n    rw [\u2190 x.to_GH_space_rep, \u2190 y.to_GH_space_rep, to_GH_space_eq_to_GH_space_iff_isometry_equiv],\n    exact \u27e8e\u27e9\n  end,\n  dist_triangle := \u03bb 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 `\u03b31`, and an optimal coupling between `Y` and `Z` in a space\n    `\u03b32`. Then, glue these metric spaces along `Y`. We get a new space `\u03b3` 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 `\u03b3` to conclude. -/\n    let X := x.rep,\n    let Y := y.rep,\n    let Z := z.rep,\n    let \u03b31 := optimal_GH_coupling X Y,\n    let \u03b32 := optimal_GH_coupling Y Z,\n    let \u03a6 : Y \u2192 \u03b31 := optimal_GH_injr X Y,\n    have h\u03a6 : isometry \u03a6 := isometry_optimal_GH_injr X Y,\n    let \u03a8 : Y \u2192 \u03b32 := optimal_GH_injl Y Z,\n    have h\u03a8 : isometry \u03a8 := isometry_optimal_GH_injl Y Z,\n    let \u03b3 := glue_space h\u03a6 h\u03a8,\n    have Comm : (to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y) =\n      (to_glue_r h\u03a6 h\u03a8) \u2218 (optimal_GH_injl Y Z) := to_glue_commute h\u03a6 h\u03a8,\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      ... \u2264 Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injl X Y)))\n                       (range ((to_glue_r h\u03a6 h\u03a8) \u2218 (optimal_GH_injr Y Z))) :\n        GH_dist_le_Hausdorff_dist\n          ((to_glue_l_isometry h\u03a6 h\u03a8).comp (isometry_optimal_GH_injl X Y))\n          ((to_glue_r_isometry h\u03a6 h\u03a8).comp (isometry_optimal_GH_injr Y Z))\n      ... \u2264 Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injl X Y)))\n                           (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y)))\n          + Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y)))\n                           (range ((to_glue_r h\u03a6 h\u03a8) \u2218 (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\u03a6 h\u03a8).comp\n              (isometry_optimal_GH_injl X Y)))).bounded },\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry h\u03a6 h\u03a8).comp\n              (isometry_optimal_GH_injr X Y)))).bounded }\n        end\n      ... = Hausdorff_dist ((to_glue_l h\u03a6 h\u03a8) '' (range (optimal_GH_injl X Y)))\n                           ((to_glue_l h\u03a6 h\u03a8) '' (range (optimal_GH_injr X Y)))\n          + Hausdorff_dist ((to_glue_r h\u03a6 h\u03a8) '' (range (optimal_GH_injl Y Z)))\n                           ((to_glue_r h\u03a6 h\u03a8) '' (range (optimal_GH_injr Y Z))) :\n        by simp only [\u2190 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\u03a6 h\u03a8),\n               Hausdorff_dist_image (to_glue_r_isometry h\u03a6 h\u03a8)]\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 \u2264 dist p q :=\nbegin\n  have ha : isometry (coe : p \u2192 X) := isometry_subtype_coe,\n  have hb : isometry (coe : q \u2192 X) := isometry_subtype_coe,\n  have A : dist p q = Hausdorff_dist (p : set X) q := rfl,\n  have I : \u2191p = range (coe : p \u2192 X) := subtype.range_coe_subtype.symm,\n  have J : \u2191q = range (coe : q \u2192 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 \u2192 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 \u2192 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 `\u03b5\u2082`, then their\nGromov-Hausdorff distance is bounded by `\u03b5\u2082 / 2`. More generally, if there are subsets which are\n`\u03b5\u2081`-dense and `\u03b5\u2083`-dense in two spaces, and isometric up to `\u03b5\u2082`, then the Gromov-Hausdorff\ndistance between the spaces is bounded by `\u03b5\u2081 + \u03b5\u2082/2 + \u03b5\u2083`. 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 `\u03b5\u2081`-dense and `\u03b5\u2083`-dense in two spaces, and\nisometric up to `\u03b5\u2082`, then the Gromov-Hausdorff distance between the spaces is bounded by\n`\u03b5\u2081 + \u03b5\u2082/2 + \u03b5\u2083`. -/\ntheorem GH_dist_le_of_approx_subsets {s : set X} (\u03a6 : s \u2192 Y) {\u03b5\u2081 \u03b5\u2082 \u03b5\u2083 : \u211d}\n  (hs : \u2200 x : X, \u2203 y \u2208 s, dist x y \u2264 \u03b5\u2081) (hs' : \u2200 x : Y, \u2203 y : s, dist x (\u03a6 y) \u2264 \u03b5\u2083)\n  (H : \u2200 x y : s, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5\u2082) :\n  GH_dist X Y \u2264 \u03b5\u2081 + \u03b5\u2082 / 2 + \u03b5\u2083 :=\nbegin\n  refine le_of_forall_pos_le_add (\u03bb \u03b4 \u03b40, _),\n  rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n  rcases hs xX with \u27e8xs, hxs, Dxs\u27e9,\n  have sne : s.nonempty := \u27e8xs, hxs\u27e9,\n  letI : nonempty s := sne.to_subtype,\n  have : 0 \u2264 \u03b5\u2082 := le_trans (abs_nonneg _) (H \u27e8xs, hxs\u27e9 \u27e8xs, hxs\u27e9),\n  have : \u2200 p q : s, |dist p q - dist (\u03a6 p) (\u03a6 q)| \u2264 2 * (\u03b5\u2082/2 + \u03b4) := \u03bb p q, calc\n    |dist p q - dist (\u03a6 p) (\u03a6 q)| \u2264 \u03b5\u2082 : H p q\n    ... \u2264 2 * (\u03b5\u2082/2 + \u03b4) : by linarith,\n  -- glue `X` and `Y` along the almost matching subsets\n  letI : metric_space (X \u2295 Y) :=\n    glue_metric_approx (\u03bb x:s, (x:X)) (\u03bb x, \u03a6 x) (\u03b5\u2082/2 + \u03b4) (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 (\u03bb x y, rfl),\n  have Ir : isometry Fr := isometry.of_dist_eq (\u03bb 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  `\u03a6 s`, and of `\u03a6 s` and `Y` (in the coupling or, equivalently, in the original space). The first\n  term is bounded by `\u03b5\u2081`, by `\u03b5\u2081`-density. The third one is bounded by `\u03b5\u2083`. And the middle one is\n  bounded by `\u03b5\u2082/2` as in the coupling the points `x` and `\u03a6 x` are at distance `\u03b5\u2082/2` by\n  construction of the coupling (in fact `\u03b5\u2082/2 + \u03b4` where `\u03b4` 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 \u2295 Y`). -/\n  have : GH_dist X Y \u2264 Hausdorff_dist (range Fl) (range Fr) :=\n    GH_dist_le_Hausdorff_dist Il Ir,\n  have : Hausdorff_dist (range Fl) (range Fr) \u2264 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) \u2264 Hausdorff_dist (Fl '' s) (Fr '' (range \u03a6))\n                                             + Hausdorff_dist (Fr '' (range \u03a6)) (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) \u2264 \u03b5\u2081,\n  { rw [\u2190 image_univ, Hausdorff_dist_image Il],\n    have : 0 \u2264 \u03b5\u2081 := le_trans dist_nonneg Dxs,\n    refine Hausdorff_dist_le_of_mem_dist this (\u03bb x hx, hs x)\n      (\u03bb x hx, \u27e8x, mem_univ _, by simpa only [dist_self]\u27e9) },\n  have : Hausdorff_dist (Fl '' s) (Fr '' (range \u03a6)) \u2264 \u03b5\u2082/2 + \u03b4,\n  { refine Hausdorff_dist_le_of_mem_dist (by linarith) _ _,\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with \u27e8x, \u27e8x_in_s, xx'\u27e9\u27e9,\n      rw \u2190 xx',\n      use [Fr (\u03a6 \u27e8x, x_in_s\u27e9), mem_image_of_mem Fr (mem_range_self _)],\n      exact le_of_eq (glue_dist_glued_points (\u03bb x:s, (x:X)) \u03a6 (\u03b5\u2082/2 + \u03b4) \u27e8x, x_in_s\u27e9) },\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with \u27e8y, \u27e8y_in_s', yx'\u27e9\u27e9,\n      rcases mem_range.1 y_in_s' with \u27e8x, xy\u27e9,\n      use [Fl x, mem_image_of_mem _ x.2],\n      rw [\u2190 yx', \u2190 xy, dist_comm],\n      exact le_of_eq (glue_dist_glued_points (@subtype.val X s) \u03a6 (\u03b5\u2082/2 + \u03b4) x) } },\n  have : Hausdorff_dist (Fr '' (range \u03a6)) (range Fr) \u2264 \u03b5\u2083,\n  { rw [\u2190 @image_univ _ _ Fr, Hausdorff_dist_image Ir],\n    rcases exists_mem_of_nonempty Y with \u27e8xY, _\u27e9,\n    rcases hs' xY with \u27e8xs', Dxs'\u27e9,\n    have : 0 \u2264 \u03b5\u2083 := le_trans dist_nonneg Dxs',\n    refine Hausdorff_dist_le_of_mem_dist this (\u03bb x hx, \u27e8x, mem_univ _, by simpa only [dist_self]\u27e9)\n      (\u03bb x _, _),\n    rcases hs' x with \u27e8y, Dy\u27e9,\n    exact \u27e8\u03a6 y, mem_range_self _, Dy\u27e9 },\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 (\u03bb \u03b4 \u03b4pos, _),\n  let \u03b5 := (2/5) * \u03b4,\n  have \u03b5pos : 0 < \u03b5 := mul_pos (by norm_num) \u03b4pos,\n  have : \u2200 p:GH_space, \u2203 s : set p.rep, s.finite \u2227 (univ \u2286 (\u22c3x\u2208s, ball x \u03b5)) :=\n    \u03bb p, by simpa only [subset_univ, exists_true_left]\n      using finite_cover_balls_of_compact is_compact_univ \u03b5pos,\n  -- for each `p`, `s p` is a finite `\u03b5`-dense subset of `p` (or rather the metric space\n  -- `p.rep` representing `p`)\n  choose s hs using this,\n  have : \u2200 p:GH_space, \u2200 t:set p.rep, t.finite \u2192 \u2203 n:\u2115, \u2203 e:equiv t (fin n), true,\n  { assume p t ht,\n    letI : fintype t := finite.fintype ht,\n    exact \u27e8fintype.card t, fintype.equiv_fin t, trivial\u27e9 },\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 := \u03bb 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 := \u03bb 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 `\u03b5`-dense set `s p`.\n  let F : GH_space \u2192 \u03a3n:\u2115, (fin n \u2192 fin n \u2192 \u2124) :=\n    \u03bbp, \u27e8N p, \u03bba b, \u230a\u03b5\u207b\u00b9 * dist ((E p).symm a) ((E p).symm b)\u230b\u27e9,\n  refine \u27e8\u03a3 n, fin n \u2192 fin n \u2192 \u2124, by apply_instance, F, \u03bbp q hpq, _\u27e9,\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 `\u2264 \u03b4`.\n  For this, we construct a map `\u03a6` from `s p \u2286 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 `\u03a8` between `s p` and `s q`, and then\n  composing with the canonical inclusion we get `\u03a6`. -/\n  have Npq : N p = N q := (sigma.mk.inj_iff.1 hpq).1,\n  let \u03a8 : s p \u2192 s q := \u03bb x, (E q).symm (fin.cast Npq ((E p) x)),\n  let \u03a6 : s p \u2192 q.rep := \u03bb x, \u03a8 x,\n  -- Use the almost isometry `\u03a6` to show that `p.rep` and `q.rep`\n  -- are within controlled Gromov-Hausdorff distance.\n  have main : GH_dist p.rep q.rep \u2264 \u03b5 + \u03b5/2 + \u03b5,\n  { refine GH_dist_le_of_approx_subsets \u03a6  _ _ _,\n    show \u2200 x : p.rep, \u2203 (y : p.rep) (H : y \u2208 s p), dist x y \u2264 \u03b5,\n    { -- by construction, `s p` is `\u03b5`-dense\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s p), ball y \u03b5 := (hs p).2 (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      exact \u27e8y, ys, le_of_lt hy\u27e9 },\n    show \u2200 x : q.rep, \u2203 (z : s p), dist x (\u03a6 z) \u2264 \u03b5,\n    { -- by construction, `s q` is `\u03b5`-dense, and it is the range of `\u03a6`\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s q), ball y \u03b5 := (hs q).2 (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      let i : \u2115 := E q \u27e8y, ys\u27e9,\n      let hi := ((E q) \u27e8y, ys\u27e9).is_lt,\n      have ihi_eq : (\u27e8i, hi\u27e9 : fin (N q)) = (E q) \u27e8y, ys\u27e9, 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 \u27e8i, hip\u27e9,\n      use z,\n      have C1 : (E p) z = \u27e8i, hip\u27e9 := (E p).apply_symm_apply \u27e8i, hip\u27e9,\n      have C2 : fin.cast Npq \u27e8i, hip\u27e9 = \u27e8i, hi\u27e9 := rfl,\n      have C3 : (E q).symm \u27e8i, hi\u27e9 = \u27e8y, ys\u27e9,\n      { rw ihi_eq, exact (E q).symm_apply_apply \u27e8y, ys\u27e9 },\n      have : \u03a6 z = y,\n      { simp only [\u03a6, \u03a8], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_of_lt hy },\n    show \u2200 x y : s p, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `\u03a6 x` and `\u03a6 y` (two points of `s q`) is encoded in `F q`, all this up to `\u03b5`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (\u03a6 x) (\u03a6 y) = dist (\u03a8 x) (\u03a8 y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `\u03a6 x` in `fin (N p) = fin (N q)`\n      let i : \u2115 := 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) (\u03a8 x)), by { simp only [equiv.apply_symm_apply, fin.coe_cast] },\n      -- introduce `j`, that codes both `y` and `\u03a6 y` in `fin (N p) = fin (N q)`\n      let j : \u2115 := 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) (\u03a8 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 (\u03b5\u207b\u00b9 * dist x y),\n        by simp only [F, (E p).symm_apply_apply],\n      have Ap : (F p).2 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9 = floor (\u03b5\u207b\u00b9 * dist x y),\n        by { rw \u2190 this, congr; apply fin.ext_iff.2; refl },\n      -- Express `dist (\u03a6 x) (\u03a6 y)` in terms of `F q`\n      have : (F q).2 ((E q) (\u03a8 x)) ((E q) (\u03a8 y)) = floor (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)),\n        by simp only [F, (E q).symm_apply_apply],\n      have Aq : (F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9 = floor (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)),\n        by { rw \u2190 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 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9 = (F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9,\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 \u22a2,\n        subst hpq,\n        intros,\n        refl },\n      rw [Ap, Aq] at this,\n      -- deduce that the distances coincide up to `\u03b5`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)| =\n          |\u03b5\u207b\u00b9 * (dist x y - dist (\u03a8 x) (\u03a8 y))| : (abs_mul _ _).symm\n        ... = |(\u03b5\u207b\u00b9 * dist x y) - (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y))| : by { congr, ring }\n        ... \u2264 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (\u03a8 x) (\u03a8 y)| = (\u03b5 * \u03b5\u207b\u00b9) * |dist x y - dist (\u03a8 x) (\u03a8 y)| :\n          by rw [mul_inv_cancel (ne_of_gt \u03b5pos), one_mul]\n        ... = \u03b5 * (|\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 \u03b5pos)), mul_assoc]\n        ... \u2264 \u03b5 * 1 : mul_le_mul_of_nonneg_left I (le_of_lt \u03b5pos)\n        ... = \u03b5 : mul_one _ } },\n  calc dist p q = GH_dist p.rep (q.rep) : dist_GH_dist p q\n    ... \u2264 \u03b5 + \u03b5/2 + \u03b5 : main\n    ... = \u03b4 : by { simp only [\u03b5], 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 `\u03b5` the number of balls of radius `\u03b5` 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 : \u211d} {u : \u2115 \u2192 \u211d} {K : \u2115 \u2192 \u2115}\n  (ulim : tendsto u at_top (\ud835\udcdd 0))\n  (hdiam : \u2200 p \u2208 t, diam (univ : set (GH_space.rep p)) \u2264 C)\n  (hcov : \u2200 p \u2208 t, \u2200 n:\u2115, \u2203 s : set (GH_space.rep p),\n    cardinal.mk s \u2264 K n \u2227 univ \u2286 \u22c3x\u2208s, ball x (u n)) :\n  totally_bounded t :=\nbegin\n  /- Let `\u03b4>0`, and `\u03b5 = \u03b4/5`. For each `p`, we construct a finite subset `s p` of `p`, which\n  is `\u03b5`-dense and has cardinality at most `K n`. Encoding the mutual distances of points in `s p`,\n  up to `\u03b5`, we will get a map `F` associating to `p` finitely many data, and making it possible to\n  reconstruct `p` up to `\u03b5`. This is enough to prove total boundedness. -/\n  refine metric.totally_bounded_of_finite_discretization (\u03bb \u03b4 \u03b4pos, _),\n  let \u03b5 := (1/5) * \u03b4,\n  have \u03b5pos : 0 < \u03b5 := mul_pos (by norm_num) \u03b4pos,\n  -- choose `n` for which `u n < \u03b5`\n  rcases metric.tendsto_at_top.1 ulim \u03b5 \u03b5pos with \u27e8n, hn\u27e9,\n  have u_le_\u03b5 : u n \u2264 \u03b5,\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 `\u03b5`-dense and has cardinal `\u2264 K n`\n  have : \u2200 p:GH_space, \u2203 s : set p.rep, \u2203 N \u2264 K n, \u2203 E : equiv s (fin N),\n    p \u2208 t \u2192 univ \u2286 \u22c3x\u2208s, ball x (u n),\n  { assume p,\n    by_cases hp : p \u2209 t,\n    { have : nonempty (equiv (\u2205 : set p.rep) (fin 0)),\n      { rw \u2190 fintype.card_eq, simp only [empty_card', fintype.card_fin] },\n      use [\u2205, 0, bot_le, choice (this)] },\n    { rcases hcov _ (set.not_not_mem.1 hp) n with \u27e8s, \u27e8scard, scover\u27e9\u27e9,\n      rcases cardinal.lt_aleph_0.1 (lt_of_le_of_lt scard (cardinal.nat_lt_aleph_0 _)) with \u27e8N, hN\u27e9,\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 `\u03b5`, namely the (discretized) distances between elements of `s p`.\n  let M := \u230a\u03b5\u207b\u00b9 * max C 0\u230b\u208a,\n  let F : GH_space \u2192 (\u03a3k:fin ((K n).succ), (fin k \u2192 fin k \u2192 fin (M.succ))) :=\n    \u03bb p, \u27e8\u27e8N p, lt_of_le_of_lt (hN p) (nat.lt_succ_self _)\u27e9,\n         \u03bb a b, \u27e8min M \u230a\u03b5\u207b\u00b9 * dist ((E p).symm a) ((E p).symm b)\u230b\u208a,\n                ( min_le_left _ _).trans_lt (nat.lt_succ_self _) \u27e9 \u27e9,\n  refine \u27e8_, _, (\u03bb p, F p), _\u27e9, apply_instance,\n  -- It remains to show that if `F p = F q`, then `p` and `q` are `\u03b5`-close\n  rintros \u27e8p, pt\u27e9 \u27e8q, qt\u27e9 hpq,\n  have Npq : N p = N q := fin.ext_iff.1 (sigma.mk.inj_iff.1 hpq).1,\n  let \u03a8 : s p \u2192 s q := \u03bb x, (E q).symm (fin.cast Npq ((E p) x)),\n  let \u03a6 : s p \u2192 q.rep := \u03bb x, \u03a8 x,\n  have main : GH_dist p.rep (q.rep) \u2264 \u03b5 + \u03b5/2 + \u03b5,\n  { -- to prove the main inequality, argue that `s p` is `\u03b5`-dense in `p`, and `s q` is `\u03b5`-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 \u03a6  _ _ _,\n    show \u2200 x : p.rep, \u2203 (y : p.rep) (H : y \u2208 s p), dist x y \u2264 \u03b5,\n    { -- by construction, `s p` is `\u03b5`-dense\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s p), ball y (u n) := (hs p pt) (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      exact \u27e8y, ys, le_trans (le_of_lt hy) u_le_\u03b5\u27e9 },\n    show \u2200 x : q.rep, \u2203 (z : s p), dist x (\u03a6 z) \u2264 \u03b5,\n    { -- by construction, `s q` is `\u03b5`-dense, and it is the range of `\u03a6`\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s q), ball y (u n) := (hs q qt) (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      let i : \u2115 := E q \u27e8y, ys\u27e9,\n      let hi := ((E q) \u27e8y, ys\u27e9).2,\n      have ihi_eq : (\u27e8i, hi\u27e9 : fin (N q)) = (E q) \u27e8y, ys\u27e9, 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 \u27e8i, hip\u27e9,\n      use z,\n      have C1 : (E p) z = \u27e8i, hip\u27e9 := (E p).apply_symm_apply \u27e8i, hip\u27e9,\n      have C2 : fin.cast Npq \u27e8i, hip\u27e9 = \u27e8i, hi\u27e9 := rfl,\n      have C3 : (E q).symm \u27e8i, hi\u27e9 = \u27e8y, ys\u27e9,\n        by { rw ihi_eq, exact (E q).symm_apply_apply \u27e8y, ys\u27e9 },\n      have : \u03a6 z = y :=\n        by { simp only [\u03a6, \u03a8], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_trans (le_of_lt hy) u_le_\u03b5 },\n    show \u2200 x y : s p, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `\u03a6 x` and `\u03a6 y` (two points of `s q`) is encoded in `F q`, all this up to `\u03b5`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (\u03a6 x) (\u03a6 y) = dist (\u03a8 x) (\u03a8 y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `\u03a6 x` in `fin (N p) = fin (N q)`\n      let i : \u2115 := 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) (\u03a8 x)), by { simp only [equiv.apply_symm_apply, fin.coe_cast] },\n      -- introduce `j`, that codes both `y` and `\u03a6 y` in `fin (N p) = fin (N q)`\n      let j : \u2115 := 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) (\u03a8 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 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a := calc\n        ((F p).2 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = ((F p).2 ((E p) x) ((E p) y)).1 :\n          by { congr; apply fin.ext_iff.2; refl }\n        ... = min M \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a :\n          by simp only [F, (E p).symm_apply_apply]\n        ... = \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a :\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 \u03b5pos).le),\n          change dist (x : p.rep) y \u2264 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 (\u03a6 x) (\u03a6 y)` in terms of `F q`\n      have Aq : ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).1 = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a := calc\n        ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).1 = ((F q).2 ((E q) (\u03a8 x)) ((E q) (\u03a8 y))).1 :\n          by { congr; apply fin.ext_iff.2; [exact i', exact j'] }\n        ... = min M \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a :\n          by simp only [F, (E q).symm_apply_apply]\n        ... = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a :\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 \u03b5pos).le),\n          change dist (\u03a8 x : q.rep) (\u03a8 y) \u2264 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 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).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 \u22a2,\n        subst hpq,\n        intros,\n        refl },\n      have : \u230a\u03b5\u207b\u00b9 * dist x y\u230b = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b,\n      { rw [Ap, Aq] at this,\n        have D : 0 \u2264 \u230a\u03b5\u207b\u00b9 * dist x y\u230b :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 \u03b5pos)) dist_nonneg),\n        have D' : 0 \u2264 \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 \u03b5pos)) dist_nonneg),\n        rw [\u2190 int.to_nat_of_nonneg D, \u2190 int.to_nat_of_nonneg D', int.floor_to_nat,int.floor_to_nat,\n          this] },\n      -- deduce that the distances coincide up to `\u03b5`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)| =\n          |\u03b5\u207b\u00b9 * (dist x y - dist (\u03a8 x) (\u03a8 y))| : (abs_mul _ _).symm\n        ... = |(\u03b5\u207b\u00b9 * dist x y) - (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y))| : by { congr, ring }\n        ... \u2264 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (\u03a8 x) (\u03a8 y)| = (\u03b5 * \u03b5\u207b\u00b9) * |dist x y - dist (\u03a8 x) (\u03a8 y)| :\n          by rw [mul_inv_cancel (ne_of_gt \u03b5pos), one_mul]\n        ... = \u03b5 * (|\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 \u03b5pos)), mul_assoc]\n        ... \u2264 \u03b5 * 1 : mul_le_mul_of_nonneg_left I (le_of_lt \u03b5pos)\n        ... = \u03b5 : mul_one _ } },\n  calc dist p q = GH_dist p.rep (q.rep) : dist_GH_dist p q\n    ... \u2264 \u03b5 + \u03b5/2 + \u03b5 : main\n    ... = \u03b4/2 : by { simp only [\u03b5, one_div], ring }\n    ... < \u03b4 : half_lt_self \u03b4pos\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 : \u2115 \u2192 Type) [\u2200 n, metric_space (X n)] [\u2200 n, compact_space (X n)] [\u2200 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 \u2192 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\u27e8{ space := A,\n  metric := by apply_instance,\n  embed := id,\n  isom := \u03bb x y, rfl }\u27e9\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 : \u2115) : aux_gluing_struct (X n) :=\nnat.rec_on n default $ \u03bb 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              \u2218 (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 : \u2200 (n : \u2115), 0 < ((1:\u211d) / 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 (\u03bb n, (1/2)^n) this (\u03bb u hu, _),\n  -- `X n` is a representative of `u n`\n  let X := \u03bb 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 : \u2200 n : \u2115,\n    glue_space (Y n).isom (isometry_optimal_GH_injl (X n) (X (n + 1))) = (Y (n + 1)).space :=\n    \u03bb n, by { dsimp only [Y, aux_gluing], refl },\n  let c := \u03bb n, cast (E n),\n  have ic : \u2200 n, isometry (c n) := \u03bb 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 : \u03a0 n, (Y n).space \u2192 (Y (n + 1)).space :=\n    \u03bb n, c n \u2218 to_glue_l (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)),\n  have I : \u2200 n, isometry (f n) := \u03bb 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 \u03a6 := to_inductive_limit I,\n  let coeZ := (coe : Z0 \u2192 Z),\n  -- let `X2 n` be the image of `X n` in the space `Z`\n  let X2 := \u03bb n, range (coeZ \u2218 (\u03a6 n) \u2218 (Y n).embed),\n  have isom : \u2200 n, isometry (coeZ \u2218 (\u03a6 n) \u2218 (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 : \u2200 n, Hausdorff_dist (X2 n) (X2 n.succ) < (1/2)^n,\n  { assume n,\n    have X2n : X2 n = range ((coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n      \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      \u2218 (optimal_GH_injl (X n) (X n.succ))),\n    { change X2 n = range (coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n        \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)))\n        \u2218 (optimal_GH_injl (X n) (X n.succ))),\n      simp only [X2, \u03a6],\n      rw [\u2190 to_inductive_limit_commute I],\n      simp only [f],\n      rw \u2190 to_glue_commute },\n    rw range_comp at X2n,\n    have X2nsucc : X2 n.succ = range ((coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n      \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      \u2218 (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, \u2190 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 : \u2115 \u2192 nonempty_compacts Z := \u03bb n,\n    \u27e8\u27e8X2 n, is_compact_range (isom n).continuous\u27e9, range_nonempty _\u27e9,\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) (\u03bb 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 \u27e8L, hL\u27e9,\n  -- the images of `X3 n` in the Gromov-Hausdorff space converge to the image of `L`\n  have M : tendsto (\u03bb n, (X3 n).to_GH_space) at_top (\ud835\udcdd 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 : \u2200 n, (X3 n).to_GH_space = u n,\n  { assume n,\n    rw [nonempty_compacts.to_GH_space, \u2190 (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 \u27e8L.to_GH_space, by simpa only [this] using M\u27e9\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 \u27f6 Y` is a morphism for which there exists a morphism `g : Y \u27f6 X`, such that `f \u226b g = \ud835\udfd9 X` and `g \u226b f = \ud835\udfd9 Y`.\n-/\n\n\n/- Lemma\nIf $$f : X \u27f6 Y$$ and $$g : X \u27f6 Y$$ are morphisms such that $$f = g$$, then $$f \u226b h = g \u226b h$$.\n-/\nlemma cancel_right_iso' {X Y Z : C} (f : X \u27f6 Y) [is_iso f] {g h : Y \u27f6 Z} : (f \u226b g = f \u226b h) \u2194 g = h :=\nbegin\n    split,\n\n    intro hyp,\n    rw \u2190 category.id_comp g,\n    rw \u2190 category.id_comp h,\n    rw \u2190 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u211d\n\nWe introduce the necessary bits to be able to define manifolds modelled over `\u211d^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 \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n)` for the model space\n  used to define `n`-dimensional real manifolds with boundary\n* `model_with_corners \u211d (euclidean_space \u211d (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* `\ud835\udce1 n` for the identity model with corners on `euclidean_space \u211d (fin n)`\n* `\ud835\udce1\u2202 n` for `model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n)`.\n\nFor instance, if a manifold `M` is boundaryless, smooth and modelled on `euclidean_space \u211d (fin m)`,\nand `N` is smooth with boundary modelled on `euclidean_half_space n`, and `f : M \u2192 N` is a smooth\nmap, then the derivative of `f` can be written simply as `mfderiv (\ud835\udce1 m) (\ud835\udce1\u2202 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 `\u211d^n`, used to model manifolds with boundary. We only define it when\n`1 \u2264 n`, as the definition only makes sense in this case.\n-/\ndef euclidean_half_space (n : \u2115) [has_zero (fin n)] : Type :=\n{x : euclidean_space \u211d (fin n) // 0 \u2264 x 0}\n\n/--\nThe quadrant in `\u211d^n`, used to model manifolds with corners, made of all vectors with nonnegative\ncoordinates.\n-/\ndef euclidean_quadrant (n : \u2115) : Type := {x : euclidean_space \u211d (fin n) // \u2200i:fin n, 0 \u2264 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 : \u2115}\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) := \u27e8\u27e80, le_refl _\u27e9\u27e9\ninstance : inhabited (euclidean_quadrant n) := \u27e8\u27e80, \u03bb i, le_refl _\u27e9\u27e9\n\nlemma range_half_space (n : \u2115) [has_zero (fin n)] :\n  range (\u03bbx : euclidean_half_space n, x.val) = {y | 0 \u2264 y 0} :=\nby simp\n\nlemma range_quadrant (n : \u2115) :\n  range (\u03bbx : euclidean_quadrant n, x.val) = {y | \u2200i:fin n, 0 \u2264 y i} :=\nby simp\n\nend\n\n/--\nDefinition of the model with corners `(euclidean_space \u211d (fin n), euclidean_half_space n)`, used as\na model for manifolds with boundary. In the locale `manifold`, use the shortcut `\ud835\udce1\u2202 n`.\n-/\ndef model_with_corners_euclidean_half_space (n : \u2115) [has_zero (fin n)] :\n  model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := \u03bbx, \u27e8update x 0 (max (x 0) 0), by simp [le_refl]\u27e9,\n  source      := univ,\n  target      := {x | 0 \u2264 x 0},\n  map_source' := \u03bbx hx, x.property,\n  map_target' := \u03bbx hx, mem_univ _,\n  left_inv'   := \u03bb \u27e8xval, xprop\u27e9 hx, begin\n    rw [subtype.mk_eq_mk, update_eq_iff],\n    exact \u27e8max_eq_left xprop, \u03bb i _, rfl\u27e9\n  end,\n  right_inv'  := \u03bbx hx, update_eq_iff.2 \u27e8max_eq_left hx, \u03bb i _, rfl\u27e9,\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on \u211d _ :=\n      unique_diff_on.pi (fin n) (\u03bb _, \u211d) _ _ (\u03bb i \u2208 ({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 \u211d (fin n), euclidean_quadrant n)`, used as a\nmodel for manifolds with corners -/\ndef model_with_corners_euclidean_quadrant (n : \u2115) :\n  model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_quadrant n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := \u03bbx, \u27e8\u03bbi, max (x i) 0, \u03bbi, by simp only [le_refl, or_true, le_max_iff]\u27e9,\n  source      := univ,\n  target      := {x | \u2200 i, 0 \u2264 x i},\n  map_source' := \u03bbx hx, by simpa only [subtype.range_val] using x.property,\n  map_target' := \u03bbx hx, mem_univ _,\n  left_inv'   := \u03bb \u27e8xval, xprop\u27e9 hx, by { ext i, simp only [subtype.coe_mk, xprop i, max_eq_left] },\n  right_inv' := \u03bb 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 \u211d _ :=\n      unique_diff_on.univ_pi (fin n) (\u03bb _, \u211d) _ (\u03bb 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 $ \u03bb i,\n    (continuous_id.max continuous_const).comp (continuous_apply i) }\n\nlocalized \"notation `\ud835\udce1 `n := model_with_corners_self \u211d (euclidean_space \u211d (fin n))\" in manifold\nlocalized \"notation `\ud835\udce1\u2202 `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 : \u211d) [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      := \u03bb(z : Icc x y), \u27e8\u03bbi, z.val - x, sub_nonneg.mpr z.property.1\u27e9,\n  inv_fun     := \u03bbz, \u27e8min (z.val 0 + x) y, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y))]\u27e9,\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 \u27e8z, hz\u27e9 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 \u27e8z, hz\u27e9 h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x + z 0 \u2264 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 : \u211d | z < y} := is_open_Iio,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : \u211d | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space \u211d (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (\u03bb _, \u211d) _ 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 (\u03bb (z : \u211d) (i : fin 1), z - x) :=\n      continuous.sub (continuous_pi $ \u03bbi, 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 (\u03bb z : \u211d, min (z + x) y) :=\n      (continuous_id.add continuous_const).min continuous_const,\n    have B : continuous (\u03bbz : euclidean_space \u211d (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 : \u211d) [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      := \u03bb(z : Icc x y), \u27e8\u03bbi, y - z.val, sub_nonneg.mpr z.property.2\u27e9,\n  inv_fun     := \u03bbz,\n    \u27e8max (y - z.val 0) x, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y)), sub_eq_add_neg]\u27e9,\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 \u27e8z, hz\u27e9 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 \u27e8z, hz\u27e9 h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x \u2264 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 : \u211d | x < z} := is_open_Ioi,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : \u211d | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space \u211d (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (\u03bb _, \u211d) _ 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 (\u03bb (z : \u211d) (i : fin 1), y - z) :=\n      continuous_const.sub (continuous_pi (\u03bbi, 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 (\u03bb z : \u211d, max (y - z) x) :=\n      (continuous_const.sub continuous_id).max continuous_const,\n    have B : continuous (\u03bbz : euclidean_space \u211d (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 : \u211d) [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 := \u03bbz, if z.val < y then Icc_left_chart x y else Icc_right_chart x y,\n  mem_chart_source := \u03bbz, 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 := \u03bbz, 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 : \u211d) [fact (x < y)] :\n  smooth_manifold_with_corners (\ud835\udce1\u2202 1) (Icc x y) :=\nbegin\n  have M : times_cont_diff_on \u211d \u221e (\u03bbz : euclidean_space \u211d (fin 1), - z + (\u03bbi, 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^\u221e` 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 _ \u27e8\u27e8hz\u2081, hz\u2082\u27e9, \u27e8\u27e8z, hz\u2080\u27e9, rfl\u27e9\u27e9,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      update_same, max_eq_left, hz\u2080, lt_sub_iff_add_lt] with mfld_simps at hz\u2081 hz\u2082,\n    rw [min_eq_left hz\u2081.le, lt_add_iff_pos_left] at hz\u2082,\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\u2081.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 _ \u27e8\u27e8hz\u2081, hz\u2082\u27e9, \u27e8z, hz\u2080\u27e9, rfl\u27e9,\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\u2080] with mfld_simps at hz\u2081 hz\u2082,\n    rw lt_sub at hz\u2081,\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\u2080, hz\u2081.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 : \u211d) < 1) := \u27e8zero_lt_one\u27e9\n\nlocal attribute [instance] fact_zero_lt_one\n\ninstance : charted_space (euclidean_half_space 1) (Icc (0 : \u211d) 1) := by apply_instance\ninstance : smooth_manifold_with_corners (\ud835\udce1\u2202 1) (Icc (0 : \u211d) 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 [\u2190 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 `\u2264 y`, `norm a \u2264 norm_bound L f abs * y ^ n`. -/\nnoncomputable def norm_bound (abs : absolute_value R \u2124) : \u2124 :=\nlet n := integral_closure.dim L f,\n    h : 0 < integral_closure.dim L f := integral_closure.dim_pos L f,\n    m : \u2124 := finset.max' (finset.univ.image (\u03bb (ijk : fin _ \u00d7 fin _ \u00d7 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        \u27e8_, finset.mem_image.mpr \u27e8\u27e8\u27e80, h\u27e9, \u27e80, h\u27e9, \u27e80, h\u27e9\u27e9, finset.mem_univ _, rfl\u27e9\u27e9\nin nat.factorial n \u2022 (n \u2022 m) ^ n\n\nlemma norm_bound_pos (abs : absolute_value R \u2124) : 0 < norm_bound L f abs :=\nbegin\n  obtain \u27e8i, j, k, hijk\u27e9 : \u2203 i j k,\n    matrix.lmul (integral_closure.is_basis L f) (integral_closure.basis L f i) j k \u2260 0,\n  { by_contra h,\n    push_neg at h,\n    apply (integral_closure.is_basis L f).ne_zero \u27e80, integral_closure.dim_pos L f\u27e9,\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 \u27e8\u27e8i, j, k\u27e9, finset.mem_univ _, rfl\u27e9\nend\n\nlemma norm_bound_ne_zero (abs : absolute_value R \u2124) : norm_bound L f abs \u2260 0 :=\nne_of_gt (norm_bound_pos L f abs)\n\nlemma norm_le (a : integral_closure R L) {abs : absolute_value R \u2124}\n  {y : \u2124} (hy : \u2200 k, abs ((integral_closure.is_basis L f).repr a k) \u2264 y) :\n  abs_norm f abs a \u2264 norm_bound L f abs * y ^ (integral_closure.dim L f) :=\nbegin\n  conv_lhs { rw \u2190 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, \u2190 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 \u27e8\u27e8i, j, k\u27e9, finset.mem_univ _, rfl\u27e9 },\nend\n\nlemma norm_lt {S : Type*} [linear_ordered_comm_ring S]\n  (a : integral_closure R L) {abs : absolute_value R \u2124}\n  {y : S} (hy : \u2200 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 (\u03bb k, abs ((integral_closure.is_basis L f).repr a k))).nonempty :=\n    \u27e8_, finset.mem_image.mpr \u27e8\u27e80, h\u27e9, finset.mem_univ _, rfl\u27e9\u27e9,\n  set y' : \u2124 := finset.max' _ him with y'_def,\n  have hy' : \u2200 k, abs ((integral_closure.is_basis L f).repr a k) \u2264 y',\n  { intro k,\n    exact finset.le_max' _ _ (finset.mem_image.mpr \u27e8k, finset.mem_univ _, rfl\u27e9) },\n  have : (y' : S) < y,\n  { rw [y'_def, finset.map_max' (show monotone (coe : \u2124 \u2192 S), from \u03bb 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 _ \u27e8x, \u27e8k, -, rfl\u27e9, rfl\u27e9,\n    exact hy k },\n  have y'_nonneg : 0 \u2264 y' := le_trans (abs.nonneg _) (hy' \u27e80, h\u27e9),\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 \u2264 x so this works too.\n-/\nnoncomputable def cardM : \u2115 :=\n(abs.card (norm_bound L f abs ^ (-1 / (integral_closure.dim L f) : \u211d)))^(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 \u21aa 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 (\u03bb (xy : fin _ \u00d7 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) \u2209 finset_approx L f abs :=\nfinset.not_mem_erase _ _\n\n@[simp] lemma mem_finset_approx [decidable_eq R] {x : R} :\n  x \u2208 finset_approx L f abs \u2194\n  \u2203 i j, i \u2260 j \u2227 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 \u27e8hx, \u27e8i, j\u27e9, _, rfl\u27e9,\n    refine \u27e8i, j, _, rfl\u27e9,\n    rintro rfl,\n    simpa using hx },\n  { rintros \u27e8i, j, hij, rfl\u27e9,\n    refine \u27e8_, \u27e8i, j\u27e9, finset.mem_product.mpr \u27e8finset.mem_univ _, finset.mem_univ _\u27e9, rfl\u27e9,\n    rw [ne.def, sub_eq_zero],\n    exact \u03bb 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 \u2260 (0 : R)) :\n  \u2203 (q : integral_closure R L) (r \u2208 finset_approx L f abs),\n    abs_norm f abs (r \u2022 a - b \u2022 q) < abs_norm f abs (algebra_map R (integral_closure R L) b) :=\nbegin\n  set \u03b5 : \u211d := norm_bound L f abs ^ (-1 / (integral_closure.dim L f) : \u211d) with \u03b5_eq,\n  have h\u03b5 : 0 < \u03b5 := real.rpow_pos_of_pos (int.cast_pos.mpr (norm_bound_pos L f abs)) _,\n  have \u03b5_le : (norm_bound L f abs : \u211d) * (abs b \u2022 \u03b5) ^ integral_closure.dim L f \u2264\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 [\u03b5_eq, algebra.smul_def, ring_hom.eq_int_cast, \u2190 rpow_nat_cast, mul_rpow, \u2190 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 \u03bc : fin (cardM L f abs).succ \u21aa R := distinct_elems L f abs,\n  set s := (integral_closure.is_basis L f).repr a,\n  have s_eq : \u2200 i, s i = (integral_closure.is_basis L f).repr a i := \u03bb i, rfl,\n  set qs := \u03bb j i, (\u03bc j * s i) / b,\n  have q_eq : \u2200 j i, qs j i = (\u03bc j * s i) / b := \u03bb i j, rfl,\n  set rs := \u03bb j i, (\u03bc j * s i) % b with r_eq,\n  have r_eq : \u2200 j i, rs j i = (\u03bc j * s i) % b := \u03bb i j, rfl,\n  set c := integral_closure.basis L f,\n  have c_eq : \u2200 i, c i = integral_closure.basis L f i := \u03bb i, rfl,\n  have \u03bc_eq : \u2200 i j, \u03bc 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 \u03bc_mul_a_eq : \u2200 j, \u03bc j \u2022 a = b \u2022 \u2211 i, qs j i \u2022 c i + \u2211 i, rs j i \u2022 c i,\n  { intro j,\n    rw \u2190 sum_repr (integral_closure.is_basis L f) a,\n    simp only [finset.smul_sum, \u2190 finset.sum_add_distrib],\n    refine finset.sum_congr rfl (\u03bb i _, _),\n    rw [\u2190 c_eq, \u2190 s_eq, \u2190 mul_smul, \u03bc_eq, add_smul, mul_smul] },\n\n  obtain \u27e8j, k, j_ne_k, hjk\u27e9 :=\n    abs.exists_approx (integral_closure.dim L f) h\u03b5 hb (\u03bb j i, \u03bc j * s i),\n  have hjk' : \u2200 i, (abs (rs k i - rs j i) : \u211d) < abs b \u2022 \u03b5,\n  { simpa only [r_eq] using hjk },\n  set q := \u2211 i, (qs k i - qs j i) \u2022 c i with q_eq,\n  set r := \u03bc k - \u03bc j with r_eq,\n  refine \u27e8q, r, (mem_finset_approx L f abs).mpr _, _\u27e9,\n  { exact \u27e8k, j, j_ne_k.symm, rfl\u27e9 },\n  have : r \u2022 a - b \u2022 q = (\u2211 (x : fin (integral_closure.dim L f)), (rs k x \u2022 c x - rs j x \u2022 c x)),\n  { simp only [r_eq, sub_smul, \u03bc_mul_a_eq, q_eq, finset.smul_sum, \u2190 finset.sum_add_distrib,\n               \u2190 finset.sum_sub_distrib, smul_sub],\n    refine finset.sum_congr rfl (\u03bb 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 _ (\u03bb 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 \u03b5_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 \u2260 (0 : integral_closure R L)) :\n  \u2203 (q : integral_closure R L) (r \u2208 finset_approx L f abs),\n  abs_norm f abs (r \u2022 a - q * b) < abs_norm f abs b :=\nbegin\n  obtain \u27e8a', b', hb', h\u27e9 := exists_eq_mul f a b hb,\n  obtain \u27e8q, r, hr, hqr\u27e9 := exists_mem_finset_approx L f abs a' hb',\n  refine \u27e8q, r, hr, _\u27e9,\n  apply lt_of_mul_lt_mul_left _\n    (show 0 \u2264 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 [\u2190 abs_norm_mul, \u2190 abs_norm_mul, \u2190 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 \u2192* H) :\n  f.range = \u22a4 \u2194 function.surjective f :=\n\u27e8 \u03bb h y, show y \u2208 f.range, from h.symm \u25b8 subgroup.mem_top y,\n  \u03bb h, subgroup.ext (\u03bb x, by simp [h x]) \u27e9\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  \u2203 b \u2208 I.1, b \u2260 0 \u2227 \u2200 c \u2208 I.1, abs_norm f abs c < abs_norm f abs b \u2192 c = 0 :=\nbegin\n  haveI := classical.dec_eq L,\n  obtain \u27e8_, \u27e8b, b_mem, b_ne_zero, rfl\u27e9, min\u27e9 :=\n    @int.exists_least_of_bdd (\u03bb a, \u2203 b \u2208 I.1, b \u2260 0 \u2227 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 _ \u27e8c, hc, c_ne_zero, rfl\u27e9) },\n  { use 0,\n    rintros _ \u27e8b, b_mem, b_ne_zero, rfl\u27e9,\n    apply abs.nonneg },\n  { obtain \u27e8b, b_mem, b_ne_zero\u27e9 := I.1.ne_bot_iff.mp I.2,\n    exact \u27e8_, \u27e8b, b_mem, b_ne_zero, rfl\u27e9\u27e9 }\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 \u2192 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\u2080 : Type*} [cancel_monoid_with_zero G\u2080]\n  {a b c : G\u2080} (ha : a \u2260 0) (h : a * b \u2223 a * c) :\n  b \u2223 c :=\nbegin\n  obtain \u27e8d, hd\u27e9 := h,\n  refine \u27e8d, mul_left_cancel' ha _\u27e9,\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 \u2260 \u22a5)\n  (h : I * J \u2223 I * K) :\n  J \u2223 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 \u2260 0) :\n  ideal.span ({a} : set R) \u2260 \u22a5 :=\nbegin\n  rw [ne.def, ideal.span_eq_bot],\n  push_neg,\n  exact \u27e8a, set.mem_singleton a, ha\u27e9\nend\n\nlemma finset.dvd_prod {\u03b9 M : Type*} [comm_monoid M] {x : \u03b9} {s : finset \u03b9}\n  (hx : x \u2208 s) (f : \u03b9 \u2192 M) :\n  f x \u2223 \u220f i in s, f i :=\nmultiset.dvd_prod (multiset.mem_map.mpr \u27e8x, hx, rfl\u27e9)\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) (\u220f m in finset_approx L f abs, m) \u2260 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 \u2223 ideal.span {algebra_map _ _ (\u220f m in finset_approx L f abs, m)}) :\n  J \u2260 0 :=\nbegin\n  simp only [ne.def, ideal.zero_eq_bot, submodule.eq_bot_iff, not_forall, not_imp],\n  refine \u27e8(algebra_map _ _) (\u220f (m : R) in finset_approx L f abs, m), _, _\u27e9,\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  \u2203 (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 \u2227\n    J.1 \u2223 ideal.span {algebra_map _ _ (\u220f m in finset_approx L f abs, m)} :=\nbegin\n  set m := \u220f m in finset_approx L f abs, m with m_eq,\n  have hm : algebra_map R (integral_closure R L) m \u2260 0 := prod_finset_approx_ne_zero f abs,\n  obtain \u27e8b, b_mem, b_ne_zero, b_min\u27e9 := exists_min f abs I,\n  suffices : ideal.span {b} \u2223 ideal.span {algebra_map _ _ m} * I.1,\n  { obtain \u27e8J, hJ\u27e9 := this,\n    refine \u27e8\u27e8J, _\u27e9, _, _\u27e9,\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 \u27e8algebra_map _ _ m, b, hm, b_ne_zero, hJ\u27e9 },\n    apply ideal.dvd_of_mul_dvd_mul_left (ideal.span_singleton_ne_bot b_ne_zero),\n    rw [ideal.dvd_iff_le, \u2190 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 \u22a2 hr',\n  obtain \u27e8q, r, r_mem, lt\u27e9 := 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 \u2190 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 (\u03bb 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 `\u220f 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 \u2223\n    ideal.span {algebra_map _ _ (\u220f m in finset_approx L f abs, m)}}) :\n  class_group (integral_closure.fraction_map_of_finite_extension L f) :=\nclass_group.mk0 _ \u27e8J.1, ne_zero_of_dvd_prod_finset_approx f abs J.1 J.2\u27e9\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 \u27e8\u27e8I, hI\u27e9, rfl\u27e9 := class_group.mk0_surjective _ I',\n  obtain \u27e8J, mk0_eq_mk0, J_dvd\u27e9 := exists_mk0_eq_mk0 f abs \u27e8I, hI\u27e9,\n  exact \u27e8\u27e8J, J_dvd\u27e9, mk0_eq_mk0.symm\u27e9\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 : \u2115 := 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 \u2194 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 \u211a = 1 :=\nclass_number_eq_one_iff.mpr $ is_principal_ideal_ring.of_surjective _\n  (rat.ring_of_integers_equiv.symm : \u2124 \u2243+* ring_of_integers \u211a).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 : \u2115 := 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 \u2194 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 \u2192 bset2d\n  := (component_extend_cols avail) \u2218 (component_extend_rows avail)\ndef comp_measure (avail ini : bset2d) : \u2115\n  := avail.count - ini.count\n\ndef component2d_aux : \u2115 \u2192 bset2d \u2192 bset2d \u2192 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) : \u2115\u00d7\u2115 \u2192 Prop\n| triv (xy : \u2115\u00d7\u2115) (Ha : xy \u2208 avail) (Hi : xy \u2208 ini)\n  : in_component2d xy\n| move (d : direction) (xy : \u2115\u00d7\u2115) (Ha : xy \u2208 avail)\n  (Hc : in_component2d (d.shift xy))\n  : in_component2d xy\n\ntheorem in_component2d_trans (avail ini ini2 : bset2d) :\n  (\u2200 xy : \u2115\u00d7\u2115, xy \u2208 avail \u2192 xy \u2208 ini2\n    \u2192 in_component2d avail ini xy) \u2192\n  \u2200 xy : \u2115\u00d7\u2115, in_component2d avail ini2 xy \u2192 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 : \u2200 (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  in_component2d avail.transpose ini.transpose xy \u2192\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 : \u2200 (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  in_component2d avail ini xy \u2192 xy \u2208 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 : \u2200 (avail ini ini2 : bset2d),\n  ini2 \u2286 ini \u2192\n  \u2200 xy : \u2115\u00d7\u2115, in_component2d avail ini2 xy \u2192\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 : \u2200 (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  xy \u2208 (component_extend_rows avail ini) \u2192\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  : \u2200 (avail ini : bset2d), (component_extend_rows avail ini) \u2286 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  : \u2200 (avail ini : bset2d), ini \u2286 avail \u2192\n  ini \u2286 (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 : \u2115\u00d7\u2115}\n  : \u2200 (d : direction),\n  xy \u2208 avail \u2192 (d.shift xy) \u2208 avail \u2192 (d.shift xy) \u2208 ini \u2192\n  (d = direction.left \u2228 d = direction.right) \u2192\n  xy \u2208 (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 \u2190(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 : \u2200 (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  xy \u2208 (component_extend_cols avail ini) \u2192\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  : \u2200 (avail ini : bset2d), (component_extend_cols avail ini) \u2286 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  : \u2200 (avail ini : bset2d), ini \u2286 avail \u2192\n  ini \u2286 (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 : \u2115\u00d7\u2115}\n  : \u2200 (d : direction),\n  xy \u2208 avail \u2192 (d.shift xy) \u2208 avail \u2192 (d.shift xy) \u2208 ini \u2192\n  (d = direction.up \u2228 d = direction.down) \u2192\n  xy \u2208 (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 : \u2200 (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  xy \u2208 (component_step avail ini) \u2192\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  : \u2200 (avail ini : bset2d), (component_step avail ini) \u2286 avail :=\nbegin\n  intros, unfold component_step, simp,\n  apply component_extend_cols_subset_avail,\nend\ntheorem component_step_supset\n  : \u2200 (avail ini : bset2d), ini \u2286 avail \u2192\n  ini \u2286 (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  : \u2200 (avail ini : bset2d),\n  ini \u2286 avail \u2192\n  (\u00ac comp_measure avail (component_step avail ini) < comp_measure avail ini) \u2192\n  \u2200 xy : \u2115\u00d7\u2115, in_component2d avail ini xy \u2192\n  xy \u2208 ini\n:=\nbegin\n  introv Hia_sub Hm_nlt Hin,\n  have Hsub : (component_step avail ini) \u2286 ini, {\n    clear Hin xy,\n    have Hm_ge : comp_measure avail (component_step avail ini) \u2265 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 \u2264 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 \u2264 ini.count\n      := (nat.sub_le_sub_left_iff Hca_le).mp Hm_ge,\n    have Hic_sub : ini \u2286 (component_step avail ini)\n      := component_step_supset avail ini Hia_sub,\n    have Hic_le : ini.count \u2264 (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) \u2208 avail\n    := in_component2d_subset_avail avail ini (d.shift xy) Hc,\n  apply Hsub,\n  have Hlr : xy \u2208 (component_extend_rows avail ini)\n    \u2192 xy \u2208 (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) \u2208 (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 : \u2200 (b : \u2115) (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  ini \u2286 avail \u2192\n  xy \u2208 (component2d_aux b avail ini) \u2192\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 : \u2200 (b : \u2115) (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  ini \u2286 avail \u2192\n  comp_measure avail ini \u2264 b \u2192\n  in_component2d avail ini xy \u2192\n  xy \u2208 (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 : \u2200 (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  xy \u2208 (component2d avail ini) \u2192\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 : \u2200 (avail ini : bset2d) (xy : \u2115\u00d7\u2115),\n  in_component2d avail ini xy \u2192\n  xy \u2208 (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 : \u2200 {avail ini : bset2d} {xy : \u2115\u00d7\u2115} {d : direction},\n  d.shift xy \u2208 (component2d avail ini) \u2192\n  xy \u2208 avail \u2192\n  xy \u2208 (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 : \u2200 {avail ini : bset2d} {xy : \u2115\u00d7\u2115} {d : direction},\n  xy \u2208 (component2d avail ini) \u2192\n  d.shift xy \u2208 avail \u2192\n  d.shift xy \u2208 (component2d avail ini) :=\nbegin\n  introv Hc Ha, cases direction.opposite_shift d xy with Heq Hrev,\n  { rw Heq, exact Hc, },\n  rw \u2190Hrev at Hc, exact component2d_op_closed Hc Ha,\nend\ntheorem component2d_subset_avail : \u2200 {avail ini : bset2d},\n  (component2d avail ini) \u2286 avail :=\n\u03bb avail ini xy Hin, in_component2d_subset_avail _ _ _ (component2d_valid _ _ _ Hin)\n\ntheorem component2d_supset : \u2200 {avail ini : bset2d},\n  ini \u2286 avail \u2192 ini \u2286 (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 := \u2200 {r s : R}, s \u2260 0 \u2192 (\u2203 (n : \u2115) (f : \u2115 \u2192 R)\n(hf : f 0 = 1), \u2211 ij in finset.nat.antidiagonal n, f ij.1 * r ^ ij.2 * s ^ ij.1 = 0) \u2192 s \u2223 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 : \u2200 P : ideal R, P \u2260 \u22a5 \u2192 P.is_prime \u2192 P.is_maximal)\n\nclass number_field (K : Type*) :=\n   (fld : field K)\n   (alg : algebra \u211a K)\n   (fd : finite_dimensional \u211a 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 \u211a K := _inst_1.alg\n\ninstance infinite_of_number_field (K : Type*) [number_field K] : infinite K := begin\n  let f : \u2124 \u2192 K := (\u03bb n, (n : \u211a) \u2022 (1 : K)),\n  apply infinite.of_injective f,\n  intros x y hxy,\n  have hxy2 : (x : \u211a) \u2022 (1 : K) = (y : \u211a) \u2022 (1 : K), exact hxy,\n  have h : 0 = ((x : \u211a) - (y : \u211a)) \u2022 (1 : K), calc 0 = (x : \u211a) \u2022 (1 : K) - (y : \u211a) \u2022 (1 : K) : by rw sub_eq_zero.mpr hxy\n  ... = (x : \u211a) \u2022 (1 : K) + (-((y : \u211a) \u2022 (1 : K))) : sub_eq_add_neg (\u2191x \u2022 1) (\u2191y \u2022 1)\n  ... = (x : \u211a) \u2022 (1 : K) + ((-(y : \u211a)) \u2022 (1 : K)) : by rw neg_smul\n  ... = ((x : \u211a) + (-(y : \u211a))) \u2022 (1 : K) : by rw add_smul\n  ... = ((x : \u211a) - (y : \u211a)) \u2022 (1 : K) : by rw sub_eq_add_neg,\n  have h2 : ((x : \u211a) - (y : \u211a)) = 0 \u2228 (1 : K) = 0, {exact (@smul_eq_zero \u211a K _ _ _ ((x : \u211a) - (y : \u211a)) (1 : K)).1 (eq.symm h)},\n  cases h2, {have h3 : (x : \u211a) = (y : \u211a), exact sub_eq_zero.mp h2,\n    exact (rat.coe_int_inj (x : \u2124) (y : \u2124)).1 h3},\n  {exfalso, revert h2, simp}\nend\n\ndef number_ring (K : Type*) [number_field K] := @integral_closure \u2124 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 \u2260 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 : \u2203 (x y : R), x \u2260 y)\n    (mul_comm : \u2200 (x y : R), x * y = y * x)\n    (mul_inv_cancel' : \u2200 {a : R}, a \u2260 0 \u2192 \u2203 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' := \u03bb a ha, \u27e8a\u207b\u00b9, field.mul_inv_cancel ha\u27e9,\n   .. (\u2039_\u203a : field R) }\n\nnoncomputable def is_field.to_field (R : Type*) [ring R] (h : is_field R) : field R :=\n    {inv := (\u03bb 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 := (\u03bb 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]: \u2200 (x : R), x \u2260 0 \u2192 \u2203! (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 \u27e8\u27e8x\u27e9, \u27e8y\u27e9, hxy\u27e9,\n        apply hxy,\n        apply ideal.quotient.eq.2,\n        rw \u2190mul_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) \u2260 0,\n        {exact @mt ((ideal.quotient.mk I x) = 0) (x \u2208 I) ideal.quotient.eq_zero_iff_mem.1 hxnI},\n        have hinvx : \u2203 (y : I.quotient), (ideal.quotient.mk I x) * y = 1, {exact _inst_2.mul_inv_cancel' hxn0},\n        rcases hinvx with \u27e8\u27e8y\u27e9, hy\u27e9,\n        change (ideal.quotient.mk I x) * (ideal.quotient.mk I y) = 1 at hy,\n        rw \u2190((ideal.quotient.mk I).map_mul x y) at hy,\n        have hxy1I : x*y-1 \u2208 I, exact ideal.quotient.eq.1 hy,\n        have hxy1J : x*y-1 \u2208 J, exact hIJ hxy1I,\n        have hxyJ : x*y \u2208 J, exact ideal.mul_mem_right J hxJ,\n        have hend : x*y-(x*y-1) \u2208 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 \u2194 (@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 \u2192 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\u207b\u00b9 :=\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 / \u2191J) 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) := \u27e8\u03bb I, 1 / I\u27e9\n\nlemma pls_work (I : ring.fractional_ideal g) (h : I \u2260 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\u207b\u00b9.val = a.val\u207b\u00b9,\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 | \u2203 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 := \u2203 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) \u2227 (normal F L)\n\ndef gal_grp (F L : Type*) [field F] [field L] [algebra F L] : (Type : Type 1) := {\u03c3 : ring_aut L | \u2200 x : F, \u03c3 (x \u2022 (1:L)) = (x \u2022 (1:L)) }\n\nclass zp_ext (L : Type*) [field L] (p : \u2115) [fact p.prime] ( h : \u2115 \u2192 set L ) :=\n( blah2 : \u2200 i : \u2115, number_field (h i) )\n( blah : \u2200 i j : \u2115, i < j \u2194 (h i) \u2282 (h j) )\n( blah4 : \u2200 i : \u2115, algebra (h 0) (h i) )\n( blah3 : \u2200 i : \u2115, gal_ext (h 0) (h i) )\n( blah5 : \u2200 i : \u2115, gal_grp (h 0) (h i) = zmod (p^i) )\n( blah6 : L = \u22c3 (i : \u2115), (h i) )\n\ninstance nth_ext (L : Type*) [field L] (p : \u2115) ( n : \u2115 ) [fact p.prime] ( h : \u2115 \u2192 set L ) [ zp_ext L p h ] : number_field (h n) := zp_ext.blah2 p n\n\nvariables {p : \u2115} [fact p.prime]\n\nvariables (L : Type 0) [field L] ( h : \u2115 \u2192 set L ) [zp_ext L p h] (n : \u2115) [ gn : (fraction_map (number_ring (h n)) (h n) ) ]\n\ninstance any_ext : \u2200 m : \u2115, number_field (h m) := \nbegin\n  sorry,\nend\n\nlemma ne : \u2200 m : \u2115, nonempty ( fraction_map (number_ring (h m)) (h m) ) :=\nbegin\n  sorry,\nend\n\ndef class_no_tower' : \u2115 \u2192 \u2115 := \u03bb m, class_number (h m) (classical.choice (ne L h m) )\n\n-- def nth_class_no_for_tower : \u2115 := class_number (h n) gn\n\ntheorem main : \u2203 N : \u2115, \u2200 m \u2265 N, \u2203 a b c : \u2115, 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 : \u2115 \u2192 \u2115 := \u03bb 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 : \u2115 \u2192 set L ) [zp_ext L p h] [\u2200 n : \u2115, 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (s : set \u03b1) (u : set \u03b2) : set (continuous_map \u03b1 \u03b2) :=\n  set_of fun (f : continuous_map \u03b1 \u03b2) => \u21d1f '' s \u2286 u\n\n-- The compact-open topology on the space of continuous maps \u03b1 \u2192 \u03b2.\n\nprotected instance compact_open {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] : topological_space (continuous_map \u03b1 \u03b2) :=\n  topological_space.generate_from\n    (set_of\n      fun (m : set (continuous_map \u03b1 \u03b2)) =>\n        \u2203 (s : set \u03b1), \u2203 (hs : is_compact s), \u2203 (u : set \u03b2), \u2203 (hu : is_open u), m = sorry)\n\ndef induced {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : continuous g) (f : continuous_map \u03b1 \u03b2) : continuous_map \u03b1 \u03b3 :=\n  mk (g \u2218 \u21d1f)\n\n/-- C(\u03b1, -) is a functor. -/\ntheorem continuous_induced {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} (hg : continuous g) : continuous (induced hg) := sorry\n\ndef ev (\u03b1 : Type u_1) (\u03b2 : Type u_2) [topological_space \u03b1] [topological_space \u03b2] (p : continuous_map \u03b1 \u03b2 \u00d7 \u03b1) : \u03b2 :=\n  coe_fn (prod.fst p) (prod.snd p)\n\n-- The evaluation map C(\u03b1, \u03b2) \u00d7 \u03b1 \u2192 \u03b2 is continuous if \u03b1 is locally compact.\n\ntheorem continuous_ev {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] [locally_compact_space \u03b1] : continuous (ev \u03b1 \u03b2) := sorry\n\ndef coev (\u03b1 : Type u_1) (\u03b2 : Type u_2) [topological_space \u03b1] [topological_space \u03b2] (b : \u03b2) : continuous_map \u03b1 (\u03b2 \u00d7 \u03b1) :=\n  mk fun (a : \u03b1) => (b, a)\n\ntheorem image_coev {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {y : \u03b2} (s : set \u03b1) : \u21d1(coev \u03b1 \u03b2 y) '' s = set.prod (singleton y) s := sorry\n\n-- The coevaluation map \u03b2 \u2192 C(\u03b1, \u03b2 \u00d7 \u03b1) is continuous (always).\n\ntheorem continuous_coev {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] : continuous (coev \u03b1 \u03b2) := 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 `)\u27e9` := 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 `/\u221a2 = 1/2`. Convert it to reals.\nlemma no_cloning_contra_h : /\u221a2 = 1/2 \u2192 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 : \u211d) = 4, {\n        calc 2 = \u221a2 * \u221a2 : by {rw real.mul_self_sqrt, linarith}\n           ... = 2 * 2 : by rw c1\n           ... = (4 : \u211d) : by linarith,\n    },\n    linarith,\nend\n\nlemma no_cloning_contra : \u00ac (\u2200 (x y : Vector 2), (x\u2020 \u2b1d y) = (x\u2020 \u2b1d y) \u2297 (x\u2020 \u2b1d y))\n:= begin\n    intros h,\n    have f1: (|0\u27e9\u2020 \u2b1d |+\u27e9) = \u03bb _ _, /\u221a2, {\n        unfold_qubits; grind_matrix, grind_dot_product; finish_complex_arith,\n    },\n    have f2: (|0\u27e9\u2020 \u2b1d |+\u27e9) = \u03bb _ _, 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\u27e9\u2020 \u2b1d |+\u27e9) 0 0 = /\u221a2, {\n        rw f1,\n    },\n    have f2': (|0\u27e9\u2020 \u2b1d |+\u27e9) 0 0 = 1/2, {\n        rw f2,\n    },\n    have c: /\u221a2 = 1/2, {\n        rw <- f1',\n        rw <- f2',\n    },\n    apply no_cloning_contra_h c,\nend\n\ntheorem no_cloning_1\n    : \u00ac (\u2203 (U : Matrix 4 4), U.unitary \u2227 \u2200 s : Vector 2, U \u2b1d (s \u2297 |0\u27e9) = s \u2297 s)\n:= begin\n    intros h, rcases h with \u27e8U, \u27e8H1, H2\u27e9\u27e9,\n\n    -- Part 1: derive the main contradictory fact.\n    have f1: \u2200 (x y : Vector 2), (x\u2020 \u2b1d y) = (x\u2020 \u2b1d y) \u2297 (x\u2020 \u2b1d y), {\n        intros x y,\n        have g1: (x\u2020 \u2297 (|0\u27e9\u2020)) \u2b1d (U\u2020 \u2b1d U) \u2b1d (y \u2297 |0\u27e9) = (x\u2020 \u2297 (x\u2020)) \u2b1d (y \u2297 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\u2020) \u2b1d y = (x\u2020 \u2b1d y) \u2297 (|0\u27e9\u2020 \u2b1d |0\u27e9) : by simp\n                  ... = (x\u2020 \u2297 (|0\u27e9\u2020)) \u2b1d (y \u2297 |0\u27e9) : by rw kron_mixed_prod\n                  ... = (x\u2020 \u2297 (|0\u27e9\u2020)) \u2b1d (U\u2020 \u2b1d U) \u2b1d (y \u2297 |0\u27e9) : by {rw unfold_unitary H1, simp}\n                  ... = (x\u2020 \u2297 (x\u2020)) \u2b1d (y \u2297 y) : g1\n                  ... = (x\u2020 \u2b1d y) \u2297 (x\u2020 \u2b1d 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 : \u2115) : \u00ac (\u2200 (x y : Vector 2 * (2^n)), (x\u2020 \u2b1d y) = (x\u2020 \u2b1d y) \u2297 (x\u2020 \u2b1d y))\n:= begin\n    intros h,\n    have f1: ((|0\u27e9 \u2297 |0^(n)\u27e9)\u2020) \u2b1d (|+\u27e9 \u2297 |0^(n)\u27e9) = \u03bb _ _, /\u221a2, {\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\u27e9 \u2297 |0^(n)\u27e9)\u2020) \u2b1d (|+\u27e9 \u2297 |0^(n)\u27e9) = \u03bb _ _, 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 := (\u27e80, by simp\u27e9 : fin (1*1)),\n    have f1': (((|0\u27e9 \u2297 |0^(n)\u27e9)\u2020) \u2b1d (|+\u27e9 \u2297 |0^(n)\u27e9)) fin0 fin0 = /\u221a2, {\n        rw f1,\n    },\n    have f2': (((|0\u27e9 \u2297 |0^(n)\u27e9)\u2020) \u2b1d (|+\u27e9 \u2297 |0^(n)\u27e9)) fin0 fin0 = 1/2, {\n        rw f2,\n    },\n    have c: /\u221a2 = 1/2, {\n        rw <- f1',\n        rw <- f2',\n    },\n    apply no_cloning_contra_h c,\nend\n\ntheorem no_cloning_2 (n : \u2115) (npos : 0 < n)\n    : \u00ac (\u2203 (U : Square (2^n * 2^n))\n         , U.unitary \u2227 \u2200 (s : Vector 2^n), U \u2b1d (s \u2297 |0^(n)\u27e9) = s \u2297 s)\n:= begin\n    intros h, rcases h with \u27e8U, \u27e8H1, H2\u27e9\u27e9,\n\n    -- Part 1: derive the main contradictory fact.\n    have f1: \u2200 (x y : Vector 2^n), (x\u2020 \u2b1d y) = (x\u2020 \u2b1d y) \u2297 (x\u2020 \u2b1d y), {\n        intros x y,\n        have g1: (x\u2020 \u2297 (|0^(n)\u27e9\u2020)) \u2b1d (U\u2020 \u2b1d U) \u2b1d (y \u2297 |0^(n)\u27e9) = (x\u2020 \u2297 (x\u2020)) \u2b1d (y \u2297 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\u2020) \u2b1d y = (x\u2020 \u2b1d y) \u2297 (|0^(n)\u27e9\u2020 \u2b1d |0^(n)\u27e9) : by simp\n                  ... = (x\u2020 \u2297 (|0^(n)\u27e9\u2020)) \u2b1d (y \u2297 |0^(n)\u27e9) : by rw kron_mixed_prod\n                  ... = (x\u2020 \u2297 (|0^(n)\u27e9\u2020)) \u2b1d (U\u2020 \u2b1d U) \u2b1d (y \u2297 |0^(n)\u27e9) : by {rw unfold_unitary H1, simp}\n                  ... = (x\u2020 \u2297 (x\u2020)) \u2b1d (y \u2297 y) : g1\n                  ... = (x\u2020 \u2b1d y) \u2297 (x\u2020 \u2b1d 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 : \u2115}\nvariables {U : Square (2 ^ (n + 2))} {f : (Vector 2) \u2192 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    (\u2200 s : Vector 2, s.unit \u2192 U \u2b1d (s \u2297 (|0^(n+1)\u27e9)) = (s \u2297 (s \u2297 (f s))))\n    \u2192 U.unitary \u2192 x.unit\n    \u2192 (f x).unit\n:= begin\n    intros h u xu,\n    have f1: (x \u2297 (x \u2297 f x)).unit, {\n        rw <- h _ xu,\n        unfold matrix.unit,\n        rw unitary_preserve_norm _ _ _ u,\n        change ((x \u2297 |0^(n + 1)\u27e9).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    (\u2200 s : Vector 2, s.unit \u2192 U \u2b1d (s \u2297 (|0^(n+1)\u27e9)) = (s \u2297 (s \u2297 (f s))))\n    \u2192 U.unitary \u2192 x.unit \u2192 y.unit\n    \u2192 (x\u2020) \u2b1d y \u2260 0\n    \u2192 (x\u2020 \u2b1d y) \u2b1d ((f x)\u2020 \u2b1d f y) = 1\n:= begin\n    intros h u xu yu h',\n\n    have fx1: x \u2297 (x \u2297 (f x)) = U \u2b1d (x \u2297 (|0^(n+1)\u27e9)), by rw h; assumption,\n    have fy1: y \u2297 (y \u2297 (f y)) = U \u2b1d (y \u2297 (|0^(n+1)\u27e9)), by rw h; assumption,\n\n    have f1: ((x \u2297 (x \u2297 (f x)))\u2020) \u2b1d (y \u2297 (y \u2297 (f y))) = ((x \u2297 (|0^(n+1)\u27e9))\u2020) \u2b1d (y \u2297 (|0^(n+1)\u27e9)), {\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\u2020) \u2b1d y) \u2b1d (x\u2020 \u2b1d y \u2b1d (f x\u2020 \u2b1d f y)) = (x\u2020 \u2b1d y) \u2b1d 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    : \u00ac (\u2203 (U : Square (2 ^ (n + 2))) (f : (Vector 2) \u2192 Vector (2^n))\n         , U.unitary\n         \u2227 (\u2200 s : Vector 2, s.unit \u2192 U \u2b1d (s \u2297 (|0^(n+1)\u27e9)) = (s \u2297 (s \u2297 (f s)))))\n:= begin\n    by_contradiction H,\n    rcases H with \u27e8U, \u27e8f, H\u27e9\u27e9,\n    rcases H with \u27e8u, h\u27e9,\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\u27e9).unit, {\n        apply no_cloning_3_unit h u; try {solve1 {simp *}},\n    },\n    have f_ket_plus_unit: (f |+\u27e9).unit, {\n        apply no_cloning_3_unit h u; try {solve1 {simp *}},\n    },\n    have f1: |\u27ea f |0\u27e9, f |+\u27e9 \u27eb| \u2264 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\u27e9\u2020 \u2b1d |+\u27e9) \u2b1d ((f |0\u27e9)\u2020 \u2b1d f |+\u27e9) = 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: \u27ea f |0\u27e9, f |+\u27e9 \u27eb = \u221a2, {\n        have c1': \u27ea |0\u27e9, |+\u27e9 \u27eb * \u27ea f |0\u27e9, f |+\u27e9 \u27eb = 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: (\u221a2 * (/\u221a2 * \u27ea f |0\u27e9, f |+\u27e9 \u27eb) : \u2102) = \u221a2 * 1, {\n            rw c1',\n        },\n        calc \u27ea f |0\u27e9, f |+\u27e9 \u27eb = \u221a2 * (/\u221a2 * \u27ea f |0\u27e9, f |+\u27e9 \u27eb) : by {simp,}\n                         ... = \u221a2 : by {rw c2_1, simp,},\n    },\n    have c3: |(\u221a2 : \u2102)| \u2264 1 \u2192 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) : (/\u221a2 \u2022 (|0\u27e9 \u2297 |0\u27e9) i 0)\u2020 * (/\u221a2 \u2022 (|1\u27e9 \u2297 |1\u27e9)) 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 : \u27e6(|+\u27e9 \u2297 |+\u27e9)\u27e7 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 : \u27e6(/\u221a2 \u2022 (|0\u27e9 \u2297 |0\u27e9)) + (/\u221a2 \u2022 (|1\u27e9 \u2297 |1\u27e9))\u27e7 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    : \u00ac (\u2203 (U : Square (2 ^ (n + 2))) (f : (Vector 2) \u2192 Vector (2^n))\n         , U.unitary\n         \u2227 (\u2200 s : Vector 2, s.unit \u2192 U \u2b1d (s \u2297 (|0^(n+1)\u27e9)) = (s \u2297 (s \u2297 (f s)))))\n:= begin\n    by_contradiction H,\n    rcases H with \u27e8U, \u27e8f, H\u27e9\u27e9,\n    rcases H with \u27e8u, H\u27e9,\n\n    let U_0 := (H (|0\u27e9)),\n    let U_1 := (H (|1\u27e9)),\n    let U_plus := (H |+\u27e9),\n\n    -- Step 1. Compute the state after cloning |+\u27e9\n    have step1 : U \u2b1d (|+\u27e9 \u2297 |0^(n+1)\u27e9) = /\u221a2 \u2022 U \u2b1d (|0\u27e9 \u2297 |0^(n+1)\u27e9)\n                                      + /\u221a2 \u2022 U \u2b1d (|1\u27e9 \u2297 |0^(n+1)\u27e9), {\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\u27e9 or |1\u27e9 with a 50% probability.\n    --         This should be identical to the Step #1 when combined.\n    have step2_1: /\u221a2 \u2022 U \u2b1d (|0\u27e9 \u2297 |0^(n+1)\u27e9) = /\u221a2 \u2022 |0\u27e9 \u2297 (|0\u27e9 \u2297 f |0\u27e9), {\n        congr' 1, apply H, simp,\n    },\n    have step2_2: /\u221a2 \u2022 U \u2b1d (|1\u27e9 \u2297 |0^(n+1)\u27e9) = /\u221a2 \u2022 |1\u27e9 \u2297 (|1\u27e9 \u2297 f |1\u27e9), {\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: |+\u27e9 \u2297 (|+\u27e9 \u2297 f |+\u27e9) = (/\u221a2 \u2022 |0\u27e9 \u2297 (|0\u27e9 \u2297 f |0\u27e9)) + (/\u221a2 \u2022 |1\u27e9 \u2297 (|1\u27e9 \u2297 f |1\u27e9)), {\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: (|+\u27e9 \u2297 |+\u27e9) \u2297 f |+\u27e9 = (/\u221a2 \u2022 (|0\u27e9 \u2297 |0\u27e9)) \u2297 f |0\u27e9 + (/\u221a2 \u2022 (|1\u27e9 \u2297 |1\u27e9)) \u2297 f |1\u27e9, {\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\u27e9).unit, {\n        apply no_cloning_3_unit H u; try {solve1 {simp *}},\n    },\n    have f_ket1_unit: (f |1\u27e9).unit, {\n        apply no_cloning_3_unit H u; try {solve1 {simp *}},\n    },\n    have f_ket_plus_unit: (f |+\u27e9).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: \u27e6(|+\u27e9 \u2297 |+\u27e9)\u27e7 1 = \u27e6(/\u221a2 \u2022 (|0\u27e9 \u2297 |0\u27e9)) + (/\u221a2 \u2022 (|1\u27e9 \u2297 |1\u27e9))\u27e7 1, {\n        have p1: \u2983 (|+\u27e9 \u2297 |+\u27e9) \u2297 f |+\u27e9 \u2984 = \u27e6(|+\u27e9 \u2297 |+\u27e9)\u27e7, {\n            apply partial_measure_proj_kron,\n            apply trace_proj_eq_one_of_unit; assumption,\n        },\n        have p2: \u2983 (/\u221a2 \u2022 (|0\u27e9 \u2297 |0\u27e9)) \u2297 f |0\u27e9 + (/\u221a2 \u2022 (|1\u27e9 \u2297 |1\u27e9)) \u2297 f |1\u27e9 \u2984\n                = \u27e6 (/\u221a2 \u2022 (|0\u27e9 \u2297 |0\u27e9)) + (/\u221a2 \u2022 (|1\u27e9 \u2297 |1\u27e9)) \u27e7, {\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 : \u211d) = 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 \u2194 (preadditive_coyoneda.obj (op P)).preserves_epimorphisms :=\nbegin\n  rw projective_iff_preserves_epimorphisms_coyoneda_obj,\n  refine \u27e8\u03bb (h : (preadditive_coyoneda.obj (op P) \u22d9 (forget _)).preserves_epimorphisms), _, _\u27e9,\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) \u22d9 forget _).preserves_epimorphisms) }\nend\n\nlemma projective_iff_preserves_epimorphisms_preadditive_coyoneda_obj' (P : C) :\n  projective P \u2194 (preadditive_coyoneda_obj (op P)).preserves_epimorphisms :=\nbegin\n  rw projective_iff_preserves_epimorphisms_coyoneda_obj,\n  refine \u27e8\u03bb (h : (preadditive_coyoneda_obj (op P) \u22d9 (forget _)).preserves_epimorphisms), _, _\u27e9,\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) \u22d9 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 : \u2200 {ishape : S} (x : T ishape), is_continuous (\u03bb (x\u2080 : T ishape), x\u2080) x\naxiom continuous_const : \u2200 {ishape oshape : S} (y : T oshape) (x : T ishape), is_continuous (\u03bb (x\u2080 : T ishape), y) x\n\naxiom continuous_add_fs {ishape oshape : S} (f g : T ishape \u2192 T oshape) (x : T ishape) :\n  is_continuous f x \u2192 is_continuous g x \u2192 is_continuous (\u03bb x\u2080, f x\u2080 + g x\u2080) x\n\nlemma continuous_sumr {\u03b1 : Type} {ishape oshape : S} (f : \u03b1 \u2192 T ishape \u2192 T oshape) (x : T ishape) :\n  \u2200 (\u03b3s : list \u03b1), (\u2200 (\u03b3 : \u03b1), \u03b3 \u2208 \u03b3s \u2192 is_continuous (\u03bb (x\u2080 : T ishape), f \u03b3 x\u2080) x) \u2192\n  is_continuous (\u03bb (x\u2080 : T ishape), list.sumr (map (\u03bb \u03b3, f \u03b3 x\u2080) \u03b3s)) x\n| [] H := by apply (continuous_const 0)\n\n| (\u03b3::\u03b3s) H :=\nbegin\ndunfold sumr map,\napply (continuous_add_fs _ _ _ (H \u03b3 mem_of_cons_same)),\napply continuous_sumr,\nintros \u03b3' H_\u03b3',\nexact H \u03b3' (mem_cons_of_mem _ H_\u03b3')\nend\n\naxiom continuous_chain_full {ishape oshape fshape : S} {f : T ishape \u2192 T oshape} {g : T ishape \u2192 T oshape \u2192 T fshape} {x : T ishape} :\n  is_continuous f x \u2192 is_continuous (\u03bb x\u2080, g x\u2080 (f x)) x \u2192 is_continuous (g x) (f x) \u2192 is_continuous (\u03bb x\u2080, g x\u2080 (f x\u2080)) x\n\nlemma continuous_chain {ishape oshape fshape : S} (f : T ishape \u2192 T oshape) (g : T oshape \u2192 T fshape) (x : T ishape) :\n  is_continuous f x \u2192 is_continuous g (f x) \u2192 is_continuous (\u03bb 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 \u2192 T oshape \u2192 T fshape := \u03bb x y, g y in\nhave H_cont_h\u2081 : is_continuous (\u03bb x\u2080, h x\u2080 (f x)) x, by apply (continuous_const (g (f x))),\nhave H_cont_h\u2082 : is_continuous (h x) (f x), from H_cont_g,\ncontinuous_chain_full H_cont_f H_cont_h\u2081 H_cont_h\u2082\n\naxiom continuous_binary {ishape oshape : S} (f : T ishape \u2192 T ishape \u2192 T oshape) (\u03b8 : T ishape) :\n  is_continuous (\u03bb \u03b8\u2080, f \u03b8\u2080 \u03b8) \u03b8 \u2192 is_continuous (\u03bb \u03b8\u2080, f \u03b8 \u03b8\u2080) \u03b8 \u2192 is_continuous (\u03bb \u03b8\u2080, f \u03b8\u2080 \u03b8\u2080) \u03b8\n\nlemma continuous_congr {ishape oshape : S} (f g : T ishape \u2192 T oshape) (x : T ishape) :\n  (\u2200 x\u2080, g x\u2080 = f x\u2080) \u2192 is_continuous f x \u2192 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\u2080 {shape : S} (\u03b1 : \u211d) : is_continuous (\u03bb \u03b1 : \u211d, const \u03b1 shape) \u03b1\naxiom continuous_scale {shape : S} (\u03b1 : \u211d) (x : T shape) : is_continuous (\u03bb x\u2080, \u03b1 \u2b1d x\u2080) x\naxiom continuous_neg {shape : S} {\u03b8 : T shape} : is_continuous neg \u03b8\naxiom continuous_exp {shape : S} {\u03b8 : T shape} : is_continuous exp \u03b8\naxiom continuous_log {shape : S} {\u03b8 : T shape} : \u03b8 > 0 \u2192 is_continuous log \u03b8\naxiom continuous_sqrt {shape : S} {\u03b8 : T shape} : \u03b8 > 0 \u2192 is_continuous sqrt \u03b8\naxiom continuous_add\u2081 {shape : S} {\u03b8 x : T shape} : is_continuous (\u03bb \u03b8\u2080, \u03b8\u2080 + x) \u03b8\naxiom continuous_add\u2082 {shape : S} {\u03b8 x : T shape} : is_continuous (\u03bb \u03b8\u2080, x + \u03b8\u2080) \u03b8\naxiom continuous_mul\u2081 {shape : S} {\u03b8 x : T shape} : is_continuous (\u03bb \u03b8\u2080, \u03b8\u2080 * x) \u03b8\naxiom continuous_mul\u2082 {shape : S} {\u03b8 x : T shape} : is_continuous (\u03bb \u03b8\u2080, x * \u03b8\u2080) \u03b8\naxiom continuous_sub\u2081 {shape : S} {\u03b8 x : T shape} : is_continuous (\u03bb \u03b8\u2080, \u03b8\u2080 - x) \u03b8\naxiom continuous_sub\u2082 {shape : S} {\u03b8 x : T shape} : is_continuous (\u03bb \u03b8\u2080, x - \u03b8\u2080) \u03b8\naxiom continuous_div\u2081 {shape : S} {\u03b8 x : T shape} : square x > 0 \u2192 is_continuous (\u03bb \u03b8\u2080, \u03b8\u2080 / x) \u03b8\naxiom continuous_div\u2082 {shape : S} {\u03b8 x : T shape} : square \u03b8 > 0 \u2192 is_continuous (\u03bb \u03b8\u2080, x / \u03b8\u2080) \u03b8\naxiom continuous_sum {shape : S} {\u03b8 : T shape} : is_continuous sum \u03b8\naxiom continuous_gemm\u2081 {m n p : \u2115} (M : T [m, n]) (N : T [n, p]) : is_continuous (\u03bb M\u2080, T.gemm M\u2080 N) M\naxiom continuous_gemm\u2082 {m n p : \u2115} (M : T [m, n]) (N : T [n, p]) : is_continuous (\u03bb N\u2080, T.gemm M N\u2080) N\n\nlemma continuous_square {shape : S} (\u03b8 : T shape) : is_continuous (\u03bb x, T.square x) \u03b8 :=\nby { apply continuous_binary (\u03bb \u03b8\u2081 \u03b8\u2082, \u03b8\u2081 * \u03b8\u2082), apply continuous_mul\u2081, apply continuous_mul\u2082 }\n\naxiom continuous_mvn_pdf_\u03bc {shape : S} (\u03bc \u03c3 x : T shape) (H_\u03c3 : \u03c3 > 0) : is_continuous (\u03bb \u03b8, mvn_pdf \u03b8 \u03c3 x) \u03bc\naxiom continuous_mvn_pdf_\u03c3 {shape : S} (\u03bc \u03c3 x : T shape) (H_\u03c3 : \u03c3 > 0) : is_continuous (\u03bb \u03b8, mvn_pdf \u03bc \u03b8 x) \u03c3\n\nlemma continuous_scale_fs {ishape oshape : S} {f : T ishape \u2192 \u211d} {g : T ishape \u2192 T oshape} {\u03b8 : T ishape} :\n                          is_continuous f \u03b8 \u2192 is_continuous g \u03b8 \u2192 is_continuous (\u03bb \u03b8\u2080, f \u03b8\u2080 \u2b1d g \u03b8\u2080) \u03b8 :=\nassume (H_cont_f : is_continuous f \u03b8) (H_cont_g : is_continuous g \u03b8),\nbegin\napply (continuous_binary (\u03bb \u03b8\u2081 \u03b8\u2082, f \u03b8\u2081 \u2b1d g \u03b8\u2082)),\napply (continuous_chain f (\u03bb \u03b8\u2080, \u03b8\u2080 \u2b1d g \u03b8) _ H_cont_f),\nsimp [T.smul.def],\napply (continuous_chain (\u03bb \u03b8\u2080, const \u03b8\u2080 oshape) (\u03bb \u03b8\u2080, g \u03b8 * \u03b8\u2080) _),\napply continuous_lift\u2080,\napply continuous_mul\u2082,\napply (continuous_chain g (\u03bb \u03b8\u2080, f \u03b8 \u2b1d \u03b8\u2080) _ H_cont_g),\napply continuous_scale\nend\n\nlemma continuous_fscale {ishape oshape : S} {f : T ishape \u2192 \u211d} {x : T oshape} {\u03b8 : T ishape} :\n                        is_continuous f \u03b8 \u2192 is_continuous (\u03bb \u03b8\u2080, f \u03b8\u2080 \u2b1d x) \u03b8 :=\nassume (H_cont_f : is_continuous f \u03b8),\nbegin\napply continuous_scale_fs,\nexact H_cont_f,\napply continuous_const\nend\n\nlemma continuous_scale_f {ishape oshape : S} (\u03b1 : \u211d) (f : T ishape \u2192 T oshape) (x : T ishape) : is_continuous f x \u2192 is_continuous (\u03bb x\u2080, \u03b1 \u2b1d f x\u2080) x :=\nassume (H_f_cont : is_continuous f x),\ncontinuous_scale_fs (continuous_const \u03b1 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  \u2200 (parents : list reference) (oshape : S) (tgt : reference) (m : env)\n    (f : dvec T parents^.p2 \u2192 T oshape) (\u03b8 : T tgt.2),\n    (\u2200 (idx : \u2115), at_idx parents idx tgt \u2192\n    is_continuous (\u03bb \u03b8\u2080, f (dvec.update_at \u03b8\u2080 (env.get_ks parents (env.insert tgt \u03b8 m)) idx)) \u03b8)\n    \u2192\n    is_continuous (\u03bb \u03b8\u2080, f (env.get_ks parents (env.insert tgt \u03b8\u2080 m))) \u03b8\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\u2081\n--     , applyc `certigrad.T.continuous_mvn_kl\u2082,\n\n     , applyc `certigrad.T.continuous_lift\u2080\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\u2081\n     , applyc `certigrad.T.continuous_add\u2082\n     , applyc `certigrad.T.continuous_mul\u2081\n     , applyc `certigrad.T.continuous_mul\u2082\n     , applyc `certigrad.T.continuous_sub\u2081\n     , applyc `certigrad.T.continuous_sub\u2082\n     , applyc `certigrad.T.continuous_div\u2081\n     , applyc `certigrad.T.continuous_div\u2082\n     , applyc `certigrad.T.continuous_sum\n     , applyc `certigrad.T.continuous_gemm\u2081\n     , applyc `certigrad.T.continuous_gemm\u2082\n     , applyc `certigrad.T.continuous_square\n     , applyc `certigrad.T.continuous_mvn_pdf_\u03bc\n     , applyc `certigrad.T.continuous_mvn_pdf_\u03c3\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\u2081 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : is_continuous (\u03bb \u03bc\u2080, mvn_kl \u03bc\u2080 \u03c3) \u03bc :=\nby { dunfold mvn_kl, prove_continuous }\n\nlemma continuous_mvn_kl\u2082 {shape : S} (\u03bc \u03c3 : T shape) (H_\u03c3 : \u03c3 > 0) : is_continuous (\u03bb \u03c3\u2080, mvn_kl \u03bc \u03c3\u2080) \u03c3 :=\nhave H_\u03c3\u2082 : square \u03c3 > 0, from square_pos_of_pos H_\u03c3,\nby { dunfold mvn_kl, prove_continuous }\n\nlemma continuous_bernoulli_neglogpdf\u2081 {shape : S} (p x : T shape) (H_p\u2081 : p > 0) (H_p\u2082 : 1 - p > 0) :\nis_continuous (\u03bb p\u2080, bernoulli_neglogpdf p\u2080 x) p :=\nby { dunfold bernoulli_neglogpdf, prove_continuous }\n\nlemma continuous_bernoulli_neglogpdf\u2082 {shape : S} (p x : T shape) (H_p\u2081 : p > 0) (H_p\u2082 : 1 - p > 0) :\nis_continuous (\u03bb x\u2080, bernoulli_neglogpdf p x\u2080) x :=\nbegin\ndunfold bernoulli_neglogpdf,\napply continuous_binary (\u03bb \u03b8\u2081 \u03b8\u2082, - T.sum (\u03b8\u2081 * T.log (eps shape + p) + (1 - \u03b8\u2082) * T.log (eps shape + (1 + -p)))),\ndsimp,\nprove_continuous,\n-- TODO(dhs): not sure why this is necessary\napply continuous_chain (\u03bb x, 1 - x) (\u03bb 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": "import algebra.module.linear_map\nimport data.real.basic\n\n\ndef f (x y z : \u211d) : \u211d  := x-z\ntheorem cpge_applin_1_b [module \u211d (prod \u211d (prod \u211d \u211d))] [E : set (prod \u211d \u211d)]: \n\u2203 g : (linear_map  \u211d (prod \u211d (prod \u211d \u211d)) \u211d), \n\u2200 x y z : \u211d , (f x y z) = (g (x, y, z)) := 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/applications_lineaires/cpge_applin_1_b.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.893309411735131, "lm_q2_score": 0.5273165233795672, "lm_q1q2_score": 0.4710568132984157}}
{"text": "-- Copyright \u00a9 2019 Fran\u00e7ois 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 {\u03c4 : Type} {\u03c3 : Type*} (sig : signature \u03c4 \u03c3)\n\nstructure identity :=\n(cod : \u03c4)\n(dom : list \u03c4)\n(eqn : equation sig dom cod)\n\nvariable {sig}\n\ndefinition equation.to_identity {dom} {{cod}} : equation sig dom cod \u2192 identity sig :=\n\u03bb e, \u27e8_, _, e\u27e9\n\ndefinition term.to_identity {dom} {{cod}} : term sig dom cod \u2192 term sig dom cod \u2192 identity sig :=\n\u03bb x\u2081 x\u2082, \u27e8_, _, \u27e8x\u2081, x\u2082\u27e9\u27e9\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 \u03c4} (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 \u03c4} (sub : substitution sig ax.dom dom) :\n(ax.subst sub).lhs = ax.lhs.subst sub := rfl\n\ntheorem subst_rhs {dom : list \u03c4} (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\u2081 : algebra sig} {alg\u2082 : algebra sig} (h : homomorphism alg\u2081 alg\u2082)\n\ndefinition satisfies (ax : identity sig) : Prop :=\n\u2200 (val : \u03a0 (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\u2082.satisfies ax \u2192 alg\u2081.satisfies ax :=\nbegin\nintros H\u2082 val\u2081,\napply homomorphism.injective.elim h,\nrw h.eval,\nrw h.eval,\napply H\u2082,\nend \n\ntheorem satisfies_of_surjective_hom [homomorphism.surjective h] (ax : identity sig) : \nalg\u2081.satisfies ax \u2192 alg\u2082.satisfies ax :=\nbegin\nintros H\u2081 val\u2082,\nhave : nonempty (\u03a0 (i : index ax.dom), { x : alg\u2081.sort i.val // h.map i.val x = val\u2082 i}),\nbegin\napply index.choice,\nintro i,\ncases homomorphism.surjective.elim h i.val (val\u2082 i) with x hx,\nexact nonempty.intro \u27e8x, hx\u27e9,\nend,\ncases this with pval\u2081,\nlet val\u2081 := \u03bb i, (pval\u2081 i).val,\nhave : val\u2082 = (\u03bb i, h.map _ (val\u2081 i)), from funext (\u03bb i, eq.symm (pval\u2081 i).property),\nrw this,\nrw \u2190 h.eval,\nrw \u2190 h.eval,\napply congr_arg,\napply H\u2081,\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u03b1 \u03b2 \u03b3 \u03b4 : Type _}\n\n#print HeytingHom /-\n/-- The type of Heyting homomorphisms from `\u03b1` to `\u03b2`. Bounded lattice homomorphisms that preserve\nHeyting implication. -/\n@[protect_proj]\nstructure HeytingHom (\u03b1 \u03b2 : Type _) [HeytingAlgebra \u03b1] [HeytingAlgebra \u03b2] extends\n  LatticeHom \u03b1 \u03b2 where\n  map_bot' : to_fun \u22a5 = \u22a5\n  map_himp' : \u2200 a b, to_fun (a \u21e8 b) = to_fun a \u21e8 to_fun b\n#align heyting_hom HeytingHom\n-/\n\n#print CoheytingHom /-\n/-- The type of co-Heyting homomorphisms from `\u03b1` to `\u03b2`. Bounded lattice homomorphisms that\npreserve difference. -/\n@[protect_proj]\nstructure CoheytingHom (\u03b1 \u03b2 : Type _) [CoheytingAlgebra \u03b1] [CoheytingAlgebra \u03b2] extends\n  LatticeHom \u03b1 \u03b2 where\n  map_top' : to_fun \u22a4 = \u22a4\n  map_sdiff' : \u2200 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 `\u03b1` to `\u03b2`. Bounded lattice homomorphisms that\npreserve Heyting implication and difference. -/\n@[protect_proj]\nstructure BiheytingHom (\u03b1 \u03b2 : Type _) [BiheytingAlgebra \u03b1] [BiheytingAlgebra \u03b2] extends\n  LatticeHom \u03b1 \u03b2 where\n  map_himp' : \u2200 a b, to_fun (a \u21e8 b) = to_fun a \u21e8 to_fun b\n  map_sdiff' : \u2200 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 \u03b1 \u03b2` states that `F` is a type of Heyting homomorphisms.\n\nYou should extend this class when you extend `heyting_hom`. -/\nclass HeytingHomClass (F : Type _) (\u03b1 \u03b2 : outParam <| Type _) [HeytingAlgebra \u03b1]\n  [HeytingAlgebra \u03b2] extends LatticeHomClass F \u03b1 \u03b2 where\n  map_bot (f : F) : f \u22a5 = \u22a5\n  map_himp (f : F) : \u2200 a b, f (a \u21e8 b) = f a \u21e8 f b\n#align heyting_hom_class HeytingHomClass\n-/\n\n#print CoheytingHomClass /-\n/-- `coheyting_hom_class F \u03b1 \u03b2` 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 _) (\u03b1 \u03b2 : outParam <| Type _) [CoheytingAlgebra \u03b1]\n  [CoheytingAlgebra \u03b2] extends LatticeHomClass F \u03b1 \u03b2 where\n  map_top (f : F) : f \u22a4 = \u22a4\n  map_sdiff (f : F) : \u2200 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 \u03b1 \u03b2` 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 _) (\u03b1 \u03b2 : outParam <| Type _) [BiheytingAlgebra \u03b1]\n  [BiheytingAlgebra \u03b2] extends LatticeHomClass F \u03b1 \u03b2 where\n  map_himp (f : F) : \u2200 a b, f (a \u21e8 b) = f a \u21e8 f b\n  map_sdiff (f : F) : \u2200 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 \u03b1]\n    [HeytingAlgebra \u03b2] [HeytingHomClass F \u03b1 \u03b2] : BoundedLatticeHomClass F \u03b1 \u03b2 :=\n  { \u2039HeytingHomClass F \u03b1 \u03b2\u203a with\n    map_top := fun f => by rw [\u2190 @himp_self \u03b1 _ \u22a5, \u2190 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 \u03b1]\n    [CoheytingAlgebra \u03b2] [CoheytingHomClass F \u03b1 \u03b2] : BoundedLatticeHomClass F \u03b1 \u03b2 :=\n  { \u2039CoheytingHomClass F \u03b1 \u03b2\u203a with\n    map_bot := fun f => by rw [\u2190 @sdiff_self \u03b1 _ \u22a4, \u2190 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 \u03b1]\n    [BiheytingAlgebra \u03b2] [BiheytingHomClass F \u03b1 \u03b2] : HeytingHomClass F \u03b1 \u03b2 :=\n  { \u2039BiheytingHomClass F \u03b1 \u03b2\u203a with\n    map_bot := fun f => by rw [\u2190 @sdiff_self \u03b1 _ \u22a4, \u2190 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 \u03b1]\n    [BiheytingAlgebra \u03b2] [BiheytingHomClass F \u03b1 \u03b2] : CoheytingHomClass F \u03b1 \u03b2 :=\n  { \u2039BiheytingHomClass F \u03b1 \u03b2\u203a with\n    map_top := fun f => by rw [\u2190 @himp_self \u03b1 _ \u22a5, \u2190 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 \u03b1] [HeytingAlgebra \u03b2]\n    [OrderIsoClass F \u03b1 \u03b2] : HeytingHomClass F \u03b1 \u03b2 :=\n  { OrderIsoClass.toBoundedLatticeHomClass with\n    map_himp := fun f a b =>\n      eq_of_forall_le_iff fun c =>\n        by\n        simp only [\u2190 map_inv_le_iff, le_himp_iff]\n        rw [\u2190 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 \u03b1]\n    [CoheytingAlgebra \u03b2] [OrderIsoClass F \u03b1 \u03b2] : CoheytingHomClass F \u03b1 \u03b2 :=\n  { OrderIsoClass.toBoundedLatticeHomClass with\n    map_sdiff := fun f a b =>\n      eq_of_forall_ge_iff fun c =>\n        by\n        simp only [\u2190 le_map_inv_iff, sdiff_le_iff]\n        rw [\u2190 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 \u03b1]\n    [BiheytingAlgebra \u03b2] [OrderIsoClass F \u03b1 \u03b2] : BiheytingHomClass F \u03b1 \u03b2 :=\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 [\u2190 map_inv_le_iff, le_himp_iff]\n        rw [\u2190 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 [\u2190 le_map_inv_iff, sdiff_le_iff]\n        rw [\u2190 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 \u03b1] [BooleanAlgebra \u03b2]\n    [BoundedLatticeHomClass F \u03b1 \u03b2] : BiheytingHomClass F \u03b1 \u03b2 :=\n  {\n    \u2039BoundedLatticeHomClass F \u03b1\n        \u03b2\u203a 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 \u03b1] [HeytingAlgebra \u03b2] [HeytingHomClass F \u03b1 \u03b2] (f : F)\n\ninclude \u03b2\n\n#print map_compl /-\n@[simp]\ntheorem map_compl (a : \u03b1) : f (a\u1d9c) = f a\u1d9c := by rw [\u2190 himp_bot, \u2190 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}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : HeytingAlgebra.{u2} \u03b1] [_inst_2 : HeytingAlgebra.{u3} \u03b2] [_inst_3 : HeytingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : \u03b1) (b : \u03b1), Eq.{succ u3} \u03b2 (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (HeytingHomClass.toLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f (bihimp.{u2} \u03b1 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))) (GeneralizedHeytingAlgebra.toHasHimp.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) a b)) (bihimp.{u3} \u03b2 (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))) (GeneralizedHeytingAlgebra.toHasHimp.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (HeytingHomClass.toLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f a) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (HeytingHomClass.toLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f b))\nbut is expected to have type\n  forall {F : Type.{u1}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : HeytingAlgebra.{u2} \u03b1] [_inst_2 : HeytingAlgebra.{u3} \u03b2] [_inst_3 : HeytingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : \u03b1) (b : \u03b1), Eq.{succ u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) (bihimp.{u2} \u03b1 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedHeytingAlgebra.toHImp.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) a b)) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f (bihimp.{u2} \u03b1 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedHeytingAlgebra.toHImp.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) a b)) (bihimp.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (Lattice.toInf.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (GeneralizedHeytingAlgebra.toLattice.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) _inst_2))) (GeneralizedHeytingAlgebra.toHImp.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) _inst_2)) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f a) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f b))\nCase conversion may be inaccurate. Consider using '#align map_bihimp map_bihimp\u2093'. -/\n@[simp]\ntheorem map_bihimp (a b : \u03b1) : f (a \u21d4 b) = f a \u21d4 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 \u03b1] [CoheytingAlgebra \u03b2] [CoheytingHomClass F \u03b1 \u03b2] (f : F)\n\ninclude \u03b2\n\n/- warning: map_hnot -> map_hnot is a dubious translation:\nlean 3 declaration is\n  forall {F : Type.{u1}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u3} \u03b2] [_inst_3 : CoheytingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : \u03b1), Eq.{succ u3} \u03b2 (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f (HNot.hnot.{u2} \u03b1 (CoheytingAlgebra.toHasHnot.{u2} \u03b1 _inst_1) a)) (HNot.hnot.{u3} \u03b2 (CoheytingAlgebra.toHasHnot.{u3} \u03b2 _inst_2) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f a))\nbut is expected to have type\n  forall {F : Type.{u1}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u3} \u03b2] [_inst_3 : CoheytingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : \u03b1), Eq.{succ u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) (HNot.hnot.{u2} \u03b1 (CoheytingAlgebra.toHNot.{u2} \u03b1 _inst_1) a)) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f (HNot.hnot.{u2} \u03b1 (CoheytingAlgebra.toHNot.{u2} \u03b1 _inst_1) a)) (HNot.hnot.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (CoheytingAlgebra.toHNot.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) _inst_2) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f a))\nCase conversion may be inaccurate. Consider using '#align map_hnot map_hnot\u2093'. -/\n@[simp]\ntheorem map_hnot (a : \u03b1) : f (\uffe2a) = \uffe2f a := by rw [\u2190 top_sdiff', \u2190 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}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u3} \u03b2] [_inst_3 : CoheytingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : \u03b1) (b : \u03b1), Eq.{succ u3} \u03b2 (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f (symmDiff.{u2} \u03b1 (SemilatticeSup.toHasSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (GeneralizedCoheytingAlgebra.toHasSdiff.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) a b)) (symmDiff.{u3} \u03b2 (SemilatticeSup.toHasSup.{u3} \u03b2 (Lattice.toSemilatticeSup.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (GeneralizedCoheytingAlgebra.toHasSdiff.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f a) (coeFn.{succ u1, max (succ u2) (succ u3)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => \u03b2) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (SemilatticeInf.toHasInf.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeInf.toHasInf.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (LatticeHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingHomClass.toLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f b))\nbut is expected to have type\n  forall {F : Type.{u1}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u3} \u03b2] [_inst_3 : CoheytingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : \u03b1) (b : \u03b1), Eq.{succ u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) (symmDiff.{u2} \u03b1 (SemilatticeSup.toSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (GeneralizedCoheytingAlgebra.toSDiff.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) a b)) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f (symmDiff.{u2} \u03b1 (SemilatticeSup.toSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (GeneralizedCoheytingAlgebra.toSDiff.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) a b)) (symmDiff.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (SemilatticeSup.toSup.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (Lattice.toSemilatticeSup.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (GeneralizedCoheytingAlgebra.toLattice.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) _inst_2)))) (GeneralizedCoheytingAlgebra.toSDiff.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) _inst_2)) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f a) (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{u1, u2, u3} F \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u2, u3} F \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)))) f b))\nCase conversion may be inaccurate. Consider using '#align map_symm_diff map_symmDiff\u2093'. -/\n@[simp]\ntheorem map_symmDiff (a b : \u03b1) : f (a \u2206 b) = f a \u2206 f b := by simp_rw [symmDiff, map_sup, map_sdiff]\n#align map_symm_diff map_symmDiff\n\nend CoheytingAlgebra\n\ninstance [HeytingAlgebra \u03b1] [HeytingAlgebra \u03b2] [HeytingHomClass F \u03b1 \u03b2] : CoeTC F (HeytingHom \u03b1 \u03b2) :=\n  \u27e8fun 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 }\u27e9\n\ninstance [CoheytingAlgebra \u03b1] [CoheytingAlgebra \u03b2] [CoheytingHomClass F \u03b1 \u03b2] :\n    CoeTC F (CoheytingHom \u03b1 \u03b2) :=\n  \u27e8fun 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 }\u27e9\n\ninstance [BiheytingAlgebra \u03b1] [BiheytingAlgebra \u03b2] [BiheytingHomClass F \u03b1 \u03b2] :\n    CoeTC F (BiheytingHom \u03b1 \u03b2) :=\n  \u27e8fun 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 }\u27e9\n\nnamespace HeytingHom\n\nvariable [HeytingAlgebra \u03b1] [HeytingAlgebra \u03b2] [HeytingAlgebra \u03b3] [HeytingAlgebra \u03b4]\n\ninstance : HeytingHomClass (HeytingHom \u03b1 \u03b2) \u03b1 \u03b2\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := f <;> obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := 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 \u03b1 \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] {f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2}, Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (SupHom.toFun.{u1, u2} \u03b1 \u03b2 (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))) (SemilatticeSup.toHasSup.{u2} \u03b2 (Lattice.toSemilatticeSup.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2)))) (LatticeHom.toSupHom.{u1, u2} \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2)) (HeytingHom.toLatticeHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} \u03b1] [_inst_2 : HeytingAlgebra.{u1} \u03b2] {f : HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2}, Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (SupHom.toFun.{u2, u1} \u03b1 \u03b2 (SemilatticeSup.toSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeSup.toSup.{u1} \u03b2 (Lattice.toSemilatticeSup.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))) (LatticeHom.toSupHom.{u2, u1} \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)) (HeytingHom.toLatticeHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) f)\nCase conversion may be inaccurate. Consider using '#align heyting_hom.to_fun_eq_coe HeytingHom.toFun_eq_coe\u2093'. -/\n@[simp]\ntheorem toFun_eq_coe {f : HeytingHom \u03b1 \u03b2} : f.toFun = (f : \u03b1 \u2192 \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] {f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2}, (forall (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g a)) -> (Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} \u03b1] [_inst_2 : HeytingAlgebra.{u1} \u03b2] {f : HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2} {g : HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2}, (forall (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) g a)) -> (Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align heyting_hom.ext HeytingHom.ext\u2093'. -/\n@[ext]\ntheorem ext {f g : HeytingHom \u03b1 \u03b2} (h : \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] (f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)) -> (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] (f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u2} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2))))) f)) -> (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align heyting_hom.copy HeytingHom.copy\u2093'. -/\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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : HeytingHom \u03b1 \u03b2\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] (f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (HeytingHom.copy.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f f' h)) f'\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} \u03b1] [_inst_2 : HeytingAlgebra.{u1} \u03b2] (f : HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) f)), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) (HeytingHom.copy.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align heyting_hom.coe_copy HeytingHom.coe_copy\u2093'. -/\n@[simp]\ntheorem coe_copy (f : HeytingHom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] (f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (HeytingHom.copy.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f f' h) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} \u03b1] [_inst_2 : HeytingAlgebra.{u1} \u03b2] (f : HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) f)), Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (HeytingHom.copy.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f f' h) f\nCase conversion may be inaccurate. Consider using '#align heyting_hom.copy_eq HeytingHom.copy_eq\u2093'. -/\ntheorem copy_eq (f : HeytingHom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align heyting_hom.copy_eq HeytingHom.copy_eq\n\nvariable (\u03b1)\n\n#print HeytingHom.id /-\n/-- `id` as a `heyting_hom`. -/\nprotected def id : HeytingHom \u03b1 \u03b1 :=\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 (\u03b1 : Type.{u1}) [_inst_1 : HeytingAlgebra.{u1} \u03b1], Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (HeytingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (HeytingHom.id.{u1} \u03b1 _inst_1)) (id.{succ u1} \u03b1)\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : HeytingAlgebra.{u1} \u03b1], Eq.{succ u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) \u1fb0) (FunLike.coe.{succ u1, succ u1, succ u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) _x) (InfHomClass.toFunLike.{u1, u1, u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 _inst_1 _inst_1 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1))))) (HeytingHom.id.{u1} \u03b1 _inst_1)) (id.{succ u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align heyting_hom.coe_id HeytingHom.coe_id\u2093'. -/\n@[simp]\ntheorem coe_id : \u21d1(HeytingHom.id \u03b1) = id :=\n  rfl\n#align heyting_hom.coe_id HeytingHom.coe_id\n\nvariable {\u03b1}\n\n/- warning: heyting_hom.id_apply -> HeytingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (HeytingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (HeytingHom.id.{u1} \u03b1 _inst_1) a) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) _x) (InfHomClass.toFunLike.{u1, u1, u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (HeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 _inst_1 _inst_1 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1))))) (HeytingHom.id.{u1} \u03b1 _inst_1) a) a\nCase conversion may be inaccurate. Consider using '#align heyting_hom.id_apply HeytingHom.id_apply\u2093'. -/\n@[simp]\ntheorem id_apply (a : \u03b1) : HeytingHom.id \u03b1 a = a :=\n  rfl\n#align heyting_hom.id_apply HeytingHom.id_apply\n\ninstance : Inhabited (HeytingHom \u03b1 \u03b1) :=\n  \u27e8HeytingHom.id _\u27e9\n\ninstance : PartialOrder (HeytingHom \u03b1 \u03b2) :=\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 \u03b2 \u03b3) (g : HeytingHom \u03b1 \u03b2) : HeytingHom \u03b1 \u03b3 :=\n  { f.toLatticeHom.comp g.toLatticeHom with\n    toFun := f \u2218 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\u2081 f\u2082 : HeytingHom \u03b1 \u03b2} {g g\u2081 g\u2082 : HeytingHom \u03b2 \u03b3}\n\n/- warning: heyting_hom.coe_comp -> HeytingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] [_inst_3 : HeytingAlgebra.{u3} \u03b3] (f : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (g : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (\u03b1 -> \u03b3) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (HeytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (fun (_x : HeytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) => \u03b1 -> \u03b3) (HeytingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (HeytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (HeytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u3} \u03b2] [_inst_3 : HeytingAlgebra.{u2} \u03b3] (f : HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) (g : HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) \u1fb0) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 _inst_1 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3))))) (HeytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u3, succ u2} \u03b1 \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3))))) f) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2))))) g))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.coe_comp HeytingHom.coe_comp\u2093'. -/\n@[simp]\ntheorem coe_comp (f : HeytingHom \u03b2 \u03b3) (g : HeytingHom \u03b1 \u03b2) : \u21d1(f.comp g) = f \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] [_inst_3 : HeytingAlgebra.{u3} \u03b3] (f : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (g : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (a : \u03b1), Eq.{succ u3} \u03b3 (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (HeytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (fun (_x : HeytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) => \u03b1 -> \u03b3) (HeytingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (HeytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g) a) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (HeytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u3} \u03b2] [_inst_3 : HeytingAlgebra.{u2} \u03b3] (f : HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) (g : HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) (a : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 _inst_1 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3))))) (HeytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g) a) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3))))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u1} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2))))) g a))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.comp_apply HeytingHom.comp_apply\u2093'. -/\n@[simp]\ntheorem comp_apply (f : HeytingHom \u03b2 \u03b3) (g : HeytingHom \u03b1 \u03b2) (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] [_inst_3 : HeytingAlgebra.{u3} \u03b3] [_inst_4 : HeytingAlgebra.{u4} \u03b4] (f : HeytingHom.{u3, u4} \u03b3 \u03b4 _inst_3 _inst_4) (g : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (h : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u4)} (HeytingHom.{u1, u4} \u03b1 \u03b4 _inst_1 _inst_4) (HeytingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 (HeytingHom.comp.{u2, u3, u4} \u03b2 \u03b3 \u03b4 _inst_2 _inst_3 _inst_4 f g) h) (HeytingHom.comp.{u1, u3, u4} \u03b1 \u03b3 \u03b4 _inst_1 _inst_3 _inst_4 f (HeytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g h))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] [_inst_3 : HeytingAlgebra.{u4} \u03b3] [_inst_4 : HeytingAlgebra.{u3} \u03b4] (f : HeytingHom.{u4, u3} \u03b3 \u03b4 _inst_3 _inst_4) (g : HeytingHom.{u2, u4} \u03b2 \u03b3 _inst_2 _inst_3) (h : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (HeytingHom.{u1, u3} \u03b1 \u03b4 _inst_1 _inst_4) (HeytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 (HeytingHom.comp.{u2, u4, u3} \u03b2 \u03b3 \u03b4 _inst_2 _inst_3 _inst_4 f g) h) (HeytingHom.comp.{u1, u4, u3} \u03b1 \u03b3 \u03b4 _inst_1 _inst_3 _inst_4 f (HeytingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g h))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.comp_assoc HeytingHom.comp_assoc\u2093'. -/\n@[simp]\ntheorem comp_assoc (f : HeytingHom \u03b3 \u03b4) (g : HeytingHom \u03b2 \u03b3) (h : HeytingHom \u03b1 \u03b2) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] (f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (HeytingHom.comp.{u1, u1, u2} \u03b1 \u03b1 \u03b2 _inst_1 _inst_1 _inst_2 f (HeytingHom.id.{u1} \u03b1 _inst_1)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} \u03b1] [_inst_2 : HeytingAlgebra.{u1} \u03b2] (f : HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (HeytingHom.comp.{u2, u2, u1} \u03b1 \u03b1 \u03b2 _inst_1 _inst_1 _inst_2 f (HeytingHom.id.{u2} \u03b1 _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align heyting_hom.comp_id HeytingHom.comp_id\u2093'. -/\n@[simp]\ntheorem comp_id (f : HeytingHom \u03b1 \u03b2) : f.comp (HeytingHom.id \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] (f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (HeytingHom.comp.{u1, u2, u2} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 (HeytingHom.id.{u2} \u03b2 _inst_2) f) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u2} \u03b1] [_inst_2 : HeytingAlgebra.{u1} \u03b2] (f : HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (HeytingHom.comp.{u2, u1, u1} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 (HeytingHom.id.{u1} \u03b2 _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align heyting_hom.id_comp HeytingHom.id_comp\u2093'. -/\n@[simp]\ntheorem id_comp (f : HeytingHom \u03b1 \u03b2) : (HeytingHom.id \u03b2).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] [_inst_3 : HeytingAlgebra.{u3} \u03b3] {f : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g\u2081 : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3} {g\u2082 : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (HeytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (HeytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (HeytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2081 f) (HeytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u3)} (HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) g\u2081 g\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : HeytingAlgebra.{u3} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] [_inst_3 : HeytingAlgebra.{u1} \u03b3] {f : HeytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g\u2081 : HeytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3} {g\u2082 : HeytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Surjective.{succ u3, succ u2} \u03b1 \u03b2 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (HeytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u3} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u3} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2))) (OrderTop.toTop.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b1 _inst_1)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b1 _inst_1))) (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b1 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b1 _inst_1)) (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b2 _inst_2)) (HeytingAlgebra.toBoundedOrder.{u3} \u03b1 _inst_1) (HeytingAlgebra.toBoundedOrder.{u2} \u03b2 _inst_2) (HeytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (HeytingHom.instHeytingHomClassHeytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2))))) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (HeytingHom.{u3, u1} \u03b1 \u03b3 _inst_1 _inst_3) (HeytingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2081 f) (HeytingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u1)} (HeytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.cancel_right HeytingHom.cancel_right\u2093'. -/\ntheorem cancel_right (hf : Surjective f) : g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => ext <| hf.forall.2 <| FunLike.ext_iff.1 h, congr_arg _\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u2} \u03b2] [_inst_3 : HeytingAlgebra.{u3} \u03b3] {f\u2081 : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {f\u2082 : HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : HeytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (HeytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (HeytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (HeytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2081) (HeytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f\u2081 f\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : HeytingAlgebra.{u1} \u03b1] [_inst_2 : HeytingAlgebra.{u3} \u03b2] [_inst_3 : HeytingAlgebra.{u2} \u03b3] {f\u2081 : HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2} {f\u2082 : HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2} {g : HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Injective.{succ u3, succ u2} \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)))))) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)))))) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedHeytingAlgebra.toLattice.{u3} \u03b2 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u3} \u03b2 _inst_2)) (GeneralizedHeytingAlgebra.toLattice.{u2} \u03b3 (HeytingAlgebra.toGeneralizedHeytingAlgebra.{u2} \u03b3 _inst_3)) (HeytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (HeytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (HeytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (HeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (HeytingHom.instHeytingHomClassHeytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3))))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (HeytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) (HeytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2081) (HeytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u1) (succ u3)} (HeytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align heyting_hom.cancel_left HeytingHom.cancel_left\u2093'. -/\ntheorem cancel_left (hg : Injective g) : g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => HeytingHom.ext fun a => hg <| by rw [\u2190 comp_apply, h, comp_apply], congr_arg _\u27e9\n#align heyting_hom.cancel_left HeytingHom.cancel_left\n\nend HeytingHom\n\nnamespace CoheytingHom\n\nvariable [CoheytingAlgebra \u03b1] [CoheytingAlgebra \u03b2] [CoheytingAlgebra \u03b3] [CoheytingAlgebra \u03b4]\n\ninstance : CoheytingHomClass (CoheytingHom \u03b1 \u03b2) \u03b1 \u03b2\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := f <;> obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := 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 \u03b1 \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] {f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2}, Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (SupHom.toFun.{u1, u2} \u03b1 \u03b2 (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (SemilatticeSup.toHasSup.{u2} \u03b2 (Lattice.toSemilatticeSup.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2)))) (LatticeHom.toSupHom.{u1, u2} \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2)) (CoheytingHom.toLatticeHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u1} \u03b2] {f : CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2}, Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (SupHom.toFun.{u2, u1} \u03b1 \u03b2 (SemilatticeSup.toSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (SemilatticeSup.toSup.{u1} \u03b2 (Lattice.toSemilatticeSup.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (LatticeHom.toSupHom.{u2, u1} \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingHom.toLatticeHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) f)\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.to_fun_eq_coe CoheytingHom.toFun_eq_coe\u2093'. -/\n@[simp]\ntheorem toFun_eq_coe {f : CoheytingHom \u03b1 \u03b2} : f.toFun = (f : \u03b1 \u2192 \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] {f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2}, (forall (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g a)) -> (Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u1} \u03b2] {f : CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2} {g : CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2}, (forall (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) g a)) -> (Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.ext CoheytingHom.ext\u2093'. -/\n@[ext]\ntheorem ext {f g : CoheytingHom \u03b1 \u03b2} (h : \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] (f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)) -> (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] (f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2))))) f)) -> (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.copy CoheytingHom.copy\u2093'. -/\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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : CoheytingHom \u03b1 \u03b2\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] (f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (CoheytingHom.copy.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f f' h)) f'\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u1} \u03b2] (f : CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) f)), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) (CoheytingHom.copy.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.coe_copy CoheytingHom.coe_copy\u2093'. -/\n@[simp]\ntheorem coe_copy (f : CoheytingHom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] (f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (CoheytingHom.copy.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f f' h) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u1} \u03b2] (f : CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2))))) f)), Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (CoheytingHom.copy.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f f' h) f\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.copy_eq CoheytingHom.copy_eq\u2093'. -/\ntheorem copy_eq (f : CoheytingHom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align coheyting_hom.copy_eq CoheytingHom.copy_eq\n\nvariable (\u03b1)\n\n#print CoheytingHom.id /-\n/-- `id` as a `coheyting_hom`. -/\nprotected def id : CoheytingHom \u03b1 \u03b1 :=\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 (\u03b1 : Type.{u1}) [_inst_1 : CoheytingAlgebra.{u1} \u03b1], Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (CoheytingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (CoheytingHom.id.{u1} \u03b1 _inst_1)) (id.{succ u1} \u03b1)\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : CoheytingAlgebra.{u1} \u03b1], Eq.{succ u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) \u1fb0) (FunLike.coe.{succ u1, succ u1, succ u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) _x) (InfHomClass.toFunLike.{u1, u1, u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 _inst_1 _inst_1 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1))))) (CoheytingHom.id.{u1} \u03b1 _inst_1)) (id.{succ u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.coe_id CoheytingHom.coe_id\u2093'. -/\n@[simp]\ntheorem coe_id : \u21d1(CoheytingHom.id \u03b1) = id :=\n  rfl\n#align coheyting_hom.coe_id CoheytingHom.coe_id\n\nvariable {\u03b1}\n\n/- warning: coheyting_hom.id_apply -> CoheytingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (CoheytingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (CoheytingHom.id.{u1} \u03b1 _inst_1) a) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) _x) (InfHomClass.toFunLike.{u1, u1, u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (CoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 _inst_1 _inst_1 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1))))) (CoheytingHom.id.{u1} \u03b1 _inst_1) a) a\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.id_apply CoheytingHom.id_apply\u2093'. -/\n@[simp]\ntheorem id_apply (a : \u03b1) : CoheytingHom.id \u03b1 a = a :=\n  rfl\n#align coheyting_hom.id_apply CoheytingHom.id_apply\n\ninstance : Inhabited (CoheytingHom \u03b1 \u03b1) :=\n  \u27e8CoheytingHom.id _\u27e9\n\ninstance : PartialOrder (CoheytingHom \u03b1 \u03b2) :=\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 \u03b2 \u03b3) (g : CoheytingHom \u03b1 \u03b2) : CoheytingHom \u03b1 \u03b3 :=\n  { f.toLatticeHom.comp g.toLatticeHom with\n    toFun := f \u2218 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\u2081 f\u2082 : CoheytingHom \u03b1 \u03b2} {g g\u2081 g\u2082 : CoheytingHom \u03b2 \u03b3}\n\n/- warning: coheyting_hom.coe_comp -> CoheytingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] [_inst_3 : CoheytingAlgebra.{u3} \u03b3] (f : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (g : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (\u03b1 -> \u03b3) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (fun (_x : CoheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) => \u03b1 -> \u03b3) (CoheytingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (CoheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (CoheytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u3} \u03b2] [_inst_3 : CoheytingAlgebra.{u2} \u03b3] (f : CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) (g : CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) \u1fb0) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 _inst_1 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3))))) (CoheytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u3, succ u2} \u03b1 \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3))))) f) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2))))) g))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.coe_comp CoheytingHom.coe_comp\u2093'. -/\n@[simp]\ntheorem coe_comp (f : CoheytingHom \u03b2 \u03b3) (g : CoheytingHom \u03b1 \u03b2) : \u21d1(f.comp g) = f \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] [_inst_3 : CoheytingAlgebra.{u3} \u03b3] (f : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (g : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (a : \u03b1), Eq.{succ u3} \u03b3 (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (fun (_x : CoheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) => \u03b1 -> \u03b3) (CoheytingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (CoheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g) a) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (CoheytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u3} \u03b2] [_inst_3 : CoheytingAlgebra.{u2} \u03b3] (f : CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) (g : CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) (a : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 _inst_1 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3))))) (CoheytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g) a) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3))))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2))))) g a))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.comp_apply CoheytingHom.comp_apply\u2093'. -/\n@[simp]\ntheorem comp_apply (f : CoheytingHom \u03b2 \u03b3) (g : CoheytingHom \u03b1 \u03b2) (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] [_inst_3 : CoheytingAlgebra.{u3} \u03b3] [_inst_4 : CoheytingAlgebra.{u4} \u03b4] (f : CoheytingHom.{u3, u4} \u03b3 \u03b4 _inst_3 _inst_4) (g : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (h : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u4)} (CoheytingHom.{u1, u4} \u03b1 \u03b4 _inst_1 _inst_4) (CoheytingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 (CoheytingHom.comp.{u2, u3, u4} \u03b2 \u03b3 \u03b4 _inst_2 _inst_3 _inst_4 f g) h) (CoheytingHom.comp.{u1, u3, u4} \u03b1 \u03b3 \u03b4 _inst_1 _inst_3 _inst_4 f (CoheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g h))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] [_inst_3 : CoheytingAlgebra.{u4} \u03b3] [_inst_4 : CoheytingAlgebra.{u3} \u03b4] (f : CoheytingHom.{u4, u3} \u03b3 \u03b4 _inst_3 _inst_4) (g : CoheytingHom.{u2, u4} \u03b2 \u03b3 _inst_2 _inst_3) (h : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} \u03b1 \u03b4 _inst_1 _inst_4) (CoheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 (CoheytingHom.comp.{u2, u4, u3} \u03b2 \u03b3 \u03b4 _inst_2 _inst_3 _inst_4 f g) h) (CoheytingHom.comp.{u1, u4, u3} \u03b1 \u03b3 \u03b4 _inst_1 _inst_3 _inst_4 f (CoheytingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g h))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.comp_assoc CoheytingHom.comp_assoc\u2093'. -/\n@[simp]\ntheorem comp_assoc (f : CoheytingHom \u03b3 \u03b4) (g : CoheytingHom \u03b2 \u03b3) (h : CoheytingHom \u03b1 \u03b2) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] (f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (CoheytingHom.comp.{u1, u1, u2} \u03b1 \u03b1 \u03b2 _inst_1 _inst_1 _inst_2 f (CoheytingHom.id.{u1} \u03b1 _inst_1)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u1} \u03b2] (f : CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (CoheytingHom.comp.{u2, u2, u1} \u03b1 \u03b1 \u03b2 _inst_1 _inst_1 _inst_2 f (CoheytingHom.id.{u2} \u03b1 _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.comp_id CoheytingHom.comp_id\u2093'. -/\n@[simp]\ntheorem comp_id (f : CoheytingHom \u03b1 \u03b2) : f.comp (CoheytingHom.id \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] (f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (CoheytingHom.comp.{u1, u2, u2} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 (CoheytingHom.id.{u2} \u03b2 _inst_2) f) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u2} \u03b1] [_inst_2 : CoheytingAlgebra.{u1} \u03b2] (f : CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (CoheytingHom.comp.{u2, u1, u1} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 (CoheytingHom.id.{u1} \u03b2 _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.id_comp CoheytingHom.id_comp\u2093'. -/\n@[simp]\ntheorem id_comp (f : CoheytingHom \u03b1 \u03b2) : (CoheytingHom.id \u03b2).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] [_inst_3 : CoheytingAlgebra.{u3} \u03b3] {f : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g\u2081 : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3} {g\u2082 : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (CoheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (CoheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2081 f) (CoheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u3)} (CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) g\u2081 g\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : CoheytingAlgebra.{u3} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] [_inst_3 : CoheytingAlgebra.{u1} \u03b3] {f : CoheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g\u2081 : CoheytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3} {g\u2082 : CoheytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Surjective.{succ u3, succ u2} \u03b1 \u03b2 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (CoheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u3} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u3} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 _inst_1))) (Lattice.toInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2))) (OrderTop.toTop.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 _inst_1)))))) (BoundedOrder.toOrderTop.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 _inst_1)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b1 _inst_1))) (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b2 _inst_2))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 _inst_1)) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b1 _inst_1) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b2 _inst_2) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2))))) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (CoheytingHom.{u3, u1} \u03b1 \u03b3 _inst_1 _inst_3) (CoheytingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2081 f) (CoheytingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u1)} (CoheytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.cancel_right CoheytingHom.cancel_right\u2093'. -/\ntheorem cancel_right (hf : Surjective f) : g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => ext <| hf.forall.2 <| FunLike.ext_iff.1 h, congr_arg _\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u2} \u03b2] [_inst_3 : CoheytingAlgebra.{u3} \u03b3] {f\u2081 : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {f\u2082 : CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : CoheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (CoheytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (CoheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2081) (CoheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f\u2081 f\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : CoheytingAlgebra.{u1} \u03b1] [_inst_2 : CoheytingAlgebra.{u3} \u03b2] [_inst_3 : CoheytingAlgebra.{u2} \u03b3] {f\u2081 : CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2} {f\u2082 : CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2} {g : CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Injective.{succ u3, succ u2} \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 _inst_2)) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 _inst_2) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 _inst_3) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (CoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (CoheytingHom.instCoheytingHomClassCoheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3))))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (CoheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) (CoheytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2081) (CoheytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u1) (succ u3)} (CoheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align coheyting_hom.cancel_left CoheytingHom.cancel_left\u2093'. -/\ntheorem cancel_left (hg : Injective g) : g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => CoheytingHom.ext fun a => hg <| by rw [\u2190 comp_apply, h, comp_apply], congr_arg _\u27e9\n#align coheyting_hom.cancel_left CoheytingHom.cancel_left\n\nend CoheytingHom\n\nnamespace BiheytingHom\n\nvariable [BiheytingAlgebra \u03b1] [BiheytingAlgebra \u03b2] [BiheytingAlgebra \u03b3] [BiheytingAlgebra \u03b4]\n\ninstance : BiheytingHomClass (BiheytingHom \u03b1 \u03b2) \u03b1 \u03b2\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := f <;> obtain \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _\u27e9 := 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 \u03b1 \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] {f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2}, Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (SupHom.toFun.{u1, u2} \u03b1 \u03b2 (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toHasSup.{u2} \u03b2 (Lattice.toSemilatticeSup.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2))))) (LatticeHom.toSupHom.{u1, u2} \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2))) (BiheytingHom.toLatticeHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f))) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} \u03b1] [_inst_2 : BiheytingAlgebra.{u1} \u03b2] {f : BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2}, Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (SupHom.toFun.{u2, u1} \u03b1 \u03b2 (SemilatticeSup.toSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b2 (Lattice.toSemilatticeSup.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))) (LatticeHom.toSupHom.{u2, u1} \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))) (BiheytingHom.toLatticeHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2)))))) f)\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.to_fun_eq_coe BiheytingHom.toFun_eq_coe\u2093'. -/\n@[simp]\ntheorem toFun_eq_coe {f : BiheytingHom \u03b1 \u03b2} : f.toFun = (f : \u03b1 \u2192 \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] {f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2}, (forall (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g a)) -> (Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} \u03b1] [_inst_2 : BiheytingAlgebra.{u1} \u03b2] {f : BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2} {g : BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2}, (forall (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2)))))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2)))))) g a)) -> (Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.ext BiheytingHom.ext\u2093'. -/\n@[ext]\ntheorem ext {f g : BiheytingHom \u03b1 \u03b2} (h : \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] (f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)) -> (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] (f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)))))) f)) -> (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.copy BiheytingHom.copy\u2093'. -/\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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : BiheytingHom \u03b1 \u03b2\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] (f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (BiheytingHom.copy.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f f' h)) f'\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} \u03b1] [_inst_2 : BiheytingAlgebra.{u1} \u03b2] (f : BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2)))))) f)), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2)))))) (BiheytingHom.copy.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f f' h)) f'\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.coe_copy BiheytingHom.coe_copy\u2093'. -/\n@[simp]\ntheorem coe_copy (f : BiheytingHom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] (f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)), Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (BiheytingHom.copy.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f f' h) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} \u03b1] [_inst_2 : BiheytingAlgebra.{u1} \u03b2] (f : BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u2 u1, u2, u1} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2)))))) f)), Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (BiheytingHom.copy.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 f f' h) f\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.copy_eq BiheytingHom.copy_eq\u2093'. -/\ntheorem copy_eq (f : BiheytingHom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align biheyting_hom.copy_eq BiheytingHom.copy_eq\n\nvariable (\u03b1)\n\n#print BiheytingHom.id /-\n/-- `id` as a `biheyting_hom`. -/\nprotected def id : BiheytingHom \u03b1 \u03b1 :=\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 (\u03b1 : Type.{u1}) [_inst_1 : BiheytingAlgebra.{u1} \u03b1], Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (BiheytingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (BiheytingHom.id.{u1} \u03b1 _inst_1)) (id.{succ u1} \u03b1)\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : BiheytingAlgebra.{u1} \u03b1], Eq.{succ u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) \u1fb0) (FunLike.coe.{succ u1, succ u1, succ u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) _x) (InfHomClass.toFunLike.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingHomClass.toCoheytingHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 _inst_1 _inst_1 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1)))))) (BiheytingHom.id.{u1} \u03b1 _inst_1)) (id.{succ u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.coe_id BiheytingHom.coe_id\u2093'. -/\n@[simp]\ntheorem coe_id : \u21d1(BiheytingHom.id \u03b1) = id :=\n  rfl\n#align biheyting_hom.coe_id BiheytingHom.coe_id\n\nvariable {\u03b1}\n\n/- warning: biheyting_hom.id_apply -> BiheytingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (BiheytingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (BiheytingHom.id.{u1} \u03b1 _inst_1) a) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b1) _x) (InfHomClass.toFunLike.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (InfTopHomClass.toInfHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (BoundedLatticeHomClass.toInfTopHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingHomClass.toBoundedLatticeHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingHomClass.toCoheytingHomClass.{u1, u1, u1} (BiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 _inst_1 _inst_1 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1)))))) (BiheytingHom.id.{u1} \u03b1 _inst_1) a) a\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.id_apply BiheytingHom.id_apply\u2093'. -/\n@[simp]\ntheorem id_apply (a : \u03b1) : BiheytingHom.id \u03b1 a = a :=\n  rfl\n#align biheyting_hom.id_apply BiheytingHom.id_apply\n\ninstance : Inhabited (BiheytingHom \u03b1 \u03b1) :=\n  \u27e8BiheytingHom.id _\u27e9\n\ninstance : PartialOrder (BiheytingHom \u03b1 \u03b2) :=\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 \u03b2 \u03b3) (g : BiheytingHom \u03b1 \u03b2) : BiheytingHom \u03b1 \u03b3 :=\n  { f.toLatticeHom.comp g.toLatticeHom with\n    toFun := f \u2218 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\u2081 f\u2082 : BiheytingHom \u03b1 \u03b2} {g g\u2081 g\u2082 : BiheytingHom \u03b2 \u03b3}\n\n/- warning: biheyting_hom.coe_comp -> BiheytingHom.coe_comp is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] [_inst_3 : BiheytingAlgebra.{u3} \u03b3] (f : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (g : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (\u03b1 -> \u03b3) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (fun (_x : BiheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) => \u03b1 -> \u03b3) (BiheytingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (BiheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (BiheytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u3} \u03b2] [_inst_3 : BiheytingAlgebra.{u2} \u03b3] (f : BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) (g : BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) \u1fb0) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 _inst_1 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3)))))) (BiheytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g)) (Function.comp.{succ u1, succ u3, succ u2} \u03b1 \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2) (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3)))))) f) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2)))))) g))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.coe_comp BiheytingHom.coe_comp\u2093'. -/\n@[simp]\ntheorem coe_comp (f : BiheytingHom \u03b2 \u03b3) (g : BiheytingHom \u03b1 \u03b2) : \u21d1(f.comp g) = f \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] [_inst_3 : BiheytingAlgebra.{u3} \u03b3] (f : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (g : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (a : \u03b1), Eq.{succ u3} \u03b3 (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (fun (_x : BiheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) => \u03b1 -> \u03b3) (BiheytingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (BiheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g) a) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (BiheytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) g a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u3} \u03b2] [_inst_3 : BiheytingAlgebra.{u2} \u03b3] (f : BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) (g : BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) (a : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b3) _x) (InfHomClass.toFunLike.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (InfTopHomClass.toInfHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u1 u2, u1, u2} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) \u03b1 \u03b3 _inst_1 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3)))))) (BiheytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f g) a) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2) (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3)))))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (OrderTop.toTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u1} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u1} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u1} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u1 u3, u1, u3} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2)))))) g a))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.comp_apply BiheytingHom.comp_apply\u2093'. -/\n@[simp]\ntheorem comp_apply (f : BiheytingHom \u03b2 \u03b3) (g : BiheytingHom \u03b1 \u03b2) (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] [_inst_3 : BiheytingAlgebra.{u3} \u03b3] [_inst_4 : BiheytingAlgebra.{u4} \u03b4] (f : BiheytingHom.{u3, u4} \u03b3 \u03b4 _inst_3 _inst_4) (g : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (h : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u4)} (BiheytingHom.{u1, u4} \u03b1 \u03b4 _inst_1 _inst_4) (BiheytingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 (BiheytingHom.comp.{u2, u3, u4} \u03b2 \u03b3 \u03b4 _inst_2 _inst_3 _inst_4 f g) h) (BiheytingHom.comp.{u1, u3, u4} \u03b1 \u03b3 \u03b4 _inst_1 _inst_3 _inst_4 f (BiheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g h))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] [_inst_3 : BiheytingAlgebra.{u4} \u03b3] [_inst_4 : BiheytingAlgebra.{u3} \u03b4] (f : BiheytingHom.{u4, u3} \u03b3 \u03b4 _inst_3 _inst_4) (g : BiheytingHom.{u2, u4} \u03b2 \u03b3 _inst_2 _inst_3) (h : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} \u03b1 \u03b4 _inst_1 _inst_4) (BiheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_4 (BiheytingHom.comp.{u2, u4, u3} \u03b2 \u03b3 \u03b4 _inst_2 _inst_3 _inst_4 f g) h) (BiheytingHom.comp.{u1, u4, u3} \u03b1 \u03b3 \u03b4 _inst_1 _inst_3 _inst_4 f (BiheytingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g h))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.comp_assoc BiheytingHom.comp_assoc\u2093'. -/\n@[simp]\ntheorem comp_assoc (f : BiheytingHom \u03b3 \u03b4) (g : BiheytingHom \u03b2 \u03b3) (h : BiheytingHom \u03b1 \u03b2) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] (f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (BiheytingHom.comp.{u1, u1, u2} \u03b1 \u03b1 \u03b2 _inst_1 _inst_1 _inst_2 f (BiheytingHom.id.{u1} \u03b1 _inst_1)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} \u03b1] [_inst_2 : BiheytingAlgebra.{u1} \u03b2] (f : BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (BiheytingHom.comp.{u2, u2, u1} \u03b1 \u03b1 \u03b2 _inst_1 _inst_1 _inst_2 f (BiheytingHom.id.{u2} \u03b1 _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.comp_id BiheytingHom.comp_id\u2093'. -/\n@[simp]\ntheorem comp_id (f : BiheytingHom \u03b1 \u03b2) : f.comp (BiheytingHom.id \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] (f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (BiheytingHom.comp.{u1, u2, u2} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 (BiheytingHom.id.{u2} \u03b2 _inst_2) f) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u2} \u03b1] [_inst_2 : BiheytingAlgebra.{u1} \u03b2] (f : BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (BiheytingHom.comp.{u2, u1, u1} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_2 (BiheytingHom.id.{u1} \u03b2 _inst_2) f) f\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.id_comp BiheytingHom.id_comp\u2093'. -/\n@[simp]\ntheorem id_comp (f : BiheytingHom \u03b1 \u03b2) : (BiheytingHom.id \u03b2).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] [_inst_3 : BiheytingAlgebra.{u3} \u03b3] {f : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g\u2081 : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3} {g\u2082 : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) => \u03b1 -> \u03b2) (BiheytingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (BiheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2081 f) (BiheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u3)} (BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) g\u2081 g\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : BiheytingAlgebra.{u3} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] [_inst_3 : BiheytingAlgebra.{u1} \u03b3] {f : BiheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g\u2081 : BiheytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3} {g\u2082 : BiheytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Surjective.{succ u3, succ u2} \u03b1 \u03b2 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (BiheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b1) => \u03b2) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u3} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b1 _inst_1)))) (Lattice.toInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2)))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (Lattice.toInf.{u3} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b1 _inst_1)))) (Lattice.toInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2)))) (OrderTop.toTop.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b1 _inst_1))))))) (BoundedOrder.toOrderTop.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b1 _inst_1))))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b1 _inst_1)))) (OrderTop.toTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b1 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b1 _inst_1))) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b1 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b1 _inst_1)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b1 _inst_1) (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b2 _inst_2) (BiheytingHomClass.toCoheytingHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2) \u03b1 \u03b2 _inst_1 _inst_2 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_2)))))) f)) -> (Iff (Eq.{max (succ u3) (succ u1)} (BiheytingHom.{u3, u1} \u03b1 \u03b3 _inst_1 _inst_3) (BiheytingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2081 f) (BiheytingHom.comp.{u3, u2, u1} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g\u2082 f)) (Eq.{max (succ u2) (succ u1)} (BiheytingHom.{u2, u1} \u03b2 \u03b3 _inst_2 _inst_3) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.cancel_right BiheytingHom.cancel_right\u2093'. -/\ntheorem cancel_right (hf : Surjective f) : g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => ext <| hf.forall.2 <| FunLike.ext_iff.1 h, congr_arg _\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u2} \u03b2] [_inst_3 : BiheytingAlgebra.{u3} \u03b3] {f\u2081 : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {f\u2082 : BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2} {g : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (_x : BiheytingHom.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) => \u03b2 -> \u03b3) (BiheytingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3) (BiheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2081) (BiheytingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) f\u2081 f\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : BiheytingAlgebra.{u1} \u03b1] [_inst_2 : BiheytingAlgebra.{u3} \u03b2] [_inst_3 : BiheytingAlgebra.{u2} \u03b3] {f\u2081 : BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2} {f\u2082 : BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2} {g : BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3}, (Function.Injective.{succ u3, succ u2} \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.Hom.Lattice._hyg.494 : \u03b2) => \u03b3) _x) (InfHomClass.toFunLike.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (InfTopHomClass.toInfHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (Lattice.toInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (Lattice.toInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (OrderTop.toTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (BoundedOrder.toOrderTop.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 (PartialOrder.toPreorder.{u3} \u03b2 (SemilatticeInf.toPartialOrder.{u3} \u03b2 (Lattice.toSemilatticeInf.{u3} \u03b2 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))))))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)))) (OrderTop.toTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (BoundedOrder.toOrderTop.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 (PartialOrder.toPreorder.{u2} \u03b3 (SemilatticeInf.toPartialOrder.{u2} \u03b3 (Lattice.toSemilatticeInf.{u2} \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))))))) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)))) (BoundedLatticeHomClass.toInfTopHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (GeneralizedCoheytingAlgebra.toLattice.{u3} \u03b2 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2))) (GeneralizedCoheytingAlgebra.toLattice.{u2} \u03b3 (CoheytingAlgebra.toGeneralizedCoheytingAlgebra.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3))) (CoheytingAlgebra.toBoundedOrder.{u3} \u03b2 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2)) (CoheytingAlgebra.toBoundedOrder.{u2} \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3)) (CoheytingHomClass.toBoundedLatticeHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 (BiheytingAlgebra.toCoheytingAlgebra.{u3} \u03b2 _inst_2) (BiheytingAlgebra.toCoheytingAlgebra.{u2} \u03b3 _inst_3) (BiheytingHomClass.toCoheytingHomClass.{max u3 u2, u3, u2} (BiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3) \u03b2 \u03b3 _inst_2 _inst_3 (BiheytingHom.instBiheytingHomClassBiheytingHom.{u3, u2} \u03b2 \u03b3 _inst_2 _inst_3)))))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (BiheytingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_3) (BiheytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2081) (BiheytingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 g f\u2082)) (Eq.{max (succ u1) (succ u3)} (BiheytingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align biheyting_hom.cancel_left BiheytingHom.cancel_left\u2093'. -/\ntheorem cancel_left (hg : Injective g) : g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => BiheytingHom.ext fun a => hg <| by rw [\u2190 comp_apply, h, comp_apply], congr_arg _\u27e9\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\u2081 v\u2082 u\u2081 u\u2082\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n\nsection reflects_iso\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/--\nDefine what it means for a functor `F : C \u2964 D` to reflect isomorphisms: for any\nmorphism `f : A \u27f6 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 \u2964 D) : Prop :=\n(reflects : \u03a0 {A B : C} (f : A \u27f6 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 \u27f6 B) (F : C \u2964 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 \u2964 D) [full F] [faithful F] : reflects_isomorphisms F :=\n{ reflects := \u03bb X Y f i, by exactI\n  \u27e8\u27e8F.preimage (inv (F.map f)), \u27e8F.map_injective (by simp), F.map_injective (by simp)\u27e9\u27e9\u27e9 }\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 (\u03b1 : Type u)\n\nclass NonUnitalSemiring (\u03b1 : Type u) extends NonUnitalNonAssocSemiring \u03b1\n\nclass Semiring (\u03b1 : Type u) extends NonUnitalSemiring \u03b1\n\nclass NonUnitalCommSemiring (\u03b1 : Type u) extends NonUnitalSemiring \u03b1\n\nclass CommSemiring (R : Type u) extends Semiring R\n\nclass NonUnitalNonAssocRing (\u03b1 : Type u) extends NonUnitalNonAssocSemiring \u03b1\n\nclass NonUnitalRing (\u03b1 : Type _) extends NonUnitalNonAssocRing \u03b1, NonUnitalSemiring \u03b1\n\nclass Ring (R : Type u) extends Semiring R\n\nclass NonUnitalCommRing (\u03b1 : Type u) extends NonUnitalRing \u03b1\n\nclass CommRing (\u03b1 : Type u) extends Ring \u03b1\n\ninstance (priority := 100) NonUnitalCommRing.toNonUnitalCommSemiring [s : NonUnitalCommRing \u03b1] :\n    NonUnitalCommSemiring \u03b1 :=\n  { s with }\n\ninstance (priority := 100) CommRing.toCommSemiring [s : CommRing \u03b1] : CommSemiring \u03b1 :=\n  { s with }\n\ninstance (priority := 100) CommSemiring.toNonUnitalCommSemiring [s : CommSemiring \u03b1] :\n    NonUnitalCommSemiring \u03b1 :=\n  { s with }\n\ninstance (priority := 100) CommRing.toNonUnitalCommRing [s : CommRing \u03b1] : NonUnitalCommRing \u03b1 :=\n  { s with }\n\nclass StarRing' (R : Type _) [NonUnitalSemiring R]\ndef starGizmo [CommSemiring R] [StarRing' R] : R \u2192 R := id\ntheorem starGizmo_foo [CommRing R] [StarRing' R] (x : R) : starGizmo x = x := rfl\n\nnamespace ReidMWE\n\nclass A (\u03b1 : Type u)\n\nclass B (\u03b1 : Type u) extends A \u03b1\n\nclass C (\u03b1 : Type u) extends B \u03b1\n\nclass D (\u03b1 : Type u) extends B \u03b1\n\nclass E (\u03b1 : Type u) extends C \u03b1, D \u03b1\n\nclass F (\u03b1 : Type u) extends A \u03b1\n\nclass G (\u03b1 : Type u) extends F \u03b1, B \u03b1\n\nclass H (\u03b1 : Type u) extends C \u03b1\n\nclass I (\u03b1 : Type u) extends G \u03b1, D \u03b1\n\nclass J (\u03b1 : Type u) extends H \u03b1, I \u03b1, E \u03b1\n\nclass StarRing' (R : Type 0) [B R]\ndef starGizmo [E R] [StarRing' R] : R \u2192 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\u2093'. -/\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 : \u2124) :\n    a * b ^ n * b ^ m = a * b ^ (n + m) := by rw [mul_assoc, \u2190 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\u2093'. -/\n@[to_additive]\ntheorem Mathlib.Tactic.Group.zpow_trick_one {G : Type _} [Group G] (a b : G) (m : \u2124) :\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'\u2093'. -/\n@[to_additive]\ntheorem Mathlib.Tactic.Group.zpow_trick_one' {G : Type _} [Group G] (a b : G) (n : \u2124) :\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 : \u2124) :\n    a * b ^ n * b ^ (-m) = a * b ^ (n - m) := by rw [mul_assoc, \u2190 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\u2081 (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\u2081 tactic.aux_group\u2081\n\n/-- Auxiliary tactic for the `group` tactic. Calls `ring_nf` to normalize exponents. -/\nunsafe def aux_group\u2082 (locat : Loc) : tactic Unit :=\n  ring_nf none Tactic.Ring.NormalizeMode.raw locat\n#align tactic.aux_group\u2082 tactic.aux_group\u2082\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)\u207b\u00b9*a\u207b\u00b9)*d) : a*c*d\u207b\u00b9 = a :=\nbegin\n  group at h, -- normalizes `h` which becomes `h : c = d`\n  rw h,       -- the goal is now `a*d*d\u207b\u00b9 = 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\u2081 locat\n  repeat (andthen (aux_group\u2082 locat) (aux_group\u2081 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 (\u03b1 : Type) extends myring \u03b1, has_inv \u03b1 :=\n(mul_inv {x : \u03b1}: x \u2260 0 \u2192 x * x\u207b\u00b9 = 1)\n(nontrivial: (0: \u03b1) \u2260 1)\n\nnamespace myfield\n\nopen myring\n\nvariables {\u03b1 : Type} [myfield \u03b1] (x y z : \u03b1)\n\ntheorem one_ne_zero : (1 : \u03b1) \u2260 0 :=\nbegin\n  assume h,\n  apply @nontrivial \u03b1,\n  symmetry,\n  assumption,\nend\n\ntheorem zero_ne_one : (0 : \u03b1) \u2260 1 := nontrivial\n\ntheorem inv_mul {x : \u03b1} (hx : x \u2260 0) : x\u207b\u00b9 * x = 1 :=\nbegin\n  rw [mul_comm],\n  apply mul_inv hx,\nend\n\ntheorem nzero_impl_inv_nzero (hx : x \u2260 0) : x\u207b\u00b9 \u2260 0 :=\nbegin\n  assume hinv0,\n  apply hx,\n  apply one_eq_zero_impl_all_zero,\n  rw [\u2190mul_inv hx, hinv0, myring.mul_zero],\nend\n\ninstance: integral_domain \u03b1 := \u27e8begin\n  intros a b ha hba,\n  rw [\u2190myring.mul_one b, \u2190mul_inv ha, \u2190myring.mul_assoc, hba, myring.zero_mul],\nend\u27e9\n\nopen integral_domain\n\ntheorem inv_unique {x : \u03b1} (y : \u03b1) (hx : x \u2260 0) : x * y = 1 \u2192 y = x\u207b\u00b9 :=\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\u207b\u00b9 = (1 : \u03b1) := begin\n  symmetry,\n  apply inv_unique,\n    exact one_ne_zero,\n  rw one_mul,\nend\n\ntheorem inv_nzero {x : \u03b1} (hx : x \u2260 0) : x\u207b\u00b9 \u2260 0 :=\nbegin\n  intro hx0,\n  apply @nontrivial \u03b1,\n  rw [\u2190mul_inv hx, \u2190mul_zero x, hx0],\nend\n\ntheorem inv_inv {x : \u03b1} (hx : x \u2260 0) : x\u207b\u00b9\u207b\u00b9 = x :=\nbegin\n  apply mul_cancel_right _ x\u207b\u00b9,\n    exact inv_nzero hx,\n  rw mul_comm,\n  transitivity (1 : \u03b1),\n    apply mul_inv,\n    exact inv_nzero hx,\n  symmetry,\n  apply mul_inv hx,\nend\n\ntheorem inv_inj {x y : \u03b1} (hx : x \u2260 0) (hy : y \u2260 0): x\u207b\u00b9 = y\u207b\u00b9 \u2192 x = y :=\nbegin\n  intro hxy,\n  rw [\u2190inv_inv hx, \u2190inv_inv hy],\n  congr,\n  assumption,\nend\n\ntheorem inv_distr {x y : \u03b1} (hx : x \u2260 0) (hy : y \u2260 0) : (x * y)\u207b\u00b9 = x\u207b\u00b9 * y\u207b\u00b9 :=\nbegin\n  have hxy : x * y \u2260 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, \u2190mul_assoc y\u207b\u00b9, mul_comm y\u207b\u00b9,\n      mul_inv hy, one_mul, inv_mul hx],\nend\n\ndef div : \u03b1 \u2192 \u03b1 \u2192 \u03b1 := \u03bb a b, a * b\u207b\u00b9\ninstance: has_div \u03b1 := \u27e8div\u27e9\n\n-- -- Division\n\ntheorem div_def : x / y = x * y\u207b\u00b9 := rfl\n\n@[simp] theorem div_one : x / 1 = x :=\nbegin\n  change x * 1\u207b\u00b9 = x,\n  rw [one_inv, mul_one],\nend\n\ntheorem one_div : 1 / x = x\u207b\u00b9 :=\nbegin\n  change 1 * x\u207b\u00b9 = x\u207b\u00b9,\n  rw one_mul,\nend\n\n@[simp] theorem zero_div : 0 / x = 0 :=\nbegin\n  change 0 * x\u207b\u00b9 = 0,\n  rw zero_mul,\nend\n\ntheorem mul_div_cancel : y \u2260 0 \u2192 (x * y) / y = x :=\nbegin\n  intro hy,\n  change x * y * y\u207b\u00b9 = x,\n  rw [mul_assoc, mul_inv hy, mul_one],\nend\n\ntheorem div_mul_cancel : y \u2260 0 \u2192 (x / y) * y = x :=\nbegin\n  intro hy,\n  change x * y\u207b\u00b9 * y = x,\n  rw [mul_assoc, inv_mul hy, mul_one],\nend\n\ntheorem div_self {x : \u03b1} : x \u2260 0 \u2192 x / x = 1 :=\nbegin\n  intro hx,\n  change x * x\u207b\u00b9 = 1,\n  exact mul_inv hx,\nend\n\ntheorem div_inv_switch {x y : \u03b1} (hx : x \u2260 0) (hy : y \u2260 0) : x / y = (y / x)\u207b\u00b9 :=\nbegin\n  change x * y\u207b\u00b9 = (y * x\u207b\u00b9)\u207b\u00b9,\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\u207b\u00b9 = x * z\u207b\u00b9 + y * z\u207b\u00b9,\n  apply add_mul,\nend\n\n-- Handy\ntheorem half_plus_half (water : 2 \u2260 (0 : \u03b1)) (\u03b5 : \u03b1) : \u03b5 / 2 + \u03b5 / 2 = \u03b5 :=\nbegin\n  rw [div_def, \u2190mul_add, \u2190one_div, \u2190add_div],\n  change \u03b5 * (2 / 2) = \u03b5,\n  rw [div_self water, mul_one],\nend\n\ntheorem minus_half (water : 2 \u2260 (0 : \u03b1)) (\u03b5 : \u03b1) : \u03b5 - \u03b5 /2 = \u03b5 / 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": "/-\nCopyright (c) 2020 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura\n-/\nprelude\n\nuniverse u v w\n\n@[inline] def id {\u03b1 : Sort u} (a : \u03b1) : \u03b1 := a\n\nabbrev Function.comp {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b4 : Sort w} (f : \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b4 :=\n  fun x => f (g x)\n\nabbrev Function.const {\u03b1 : Sort u} (\u03b2 : Sort v) (a : \u03b1) : \u03b2 \u2192 \u03b1 :=\n  fun x => a\n\nset_option checkBinderAnnotations false in\n@[reducible] def inferInstance {\u03b1 : Sort u} [i : \u03b1] : \u03b1 := i\nset_option checkBinderAnnotations false in\n@[reducible] def inferInstanceAs (\u03b1 : Sort u) [i : \u03b1] : \u03b1 := i\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\ninductive PUnit : Sort u where\n  | unit : PUnit\n\n/-- An abbreviation for `PUnit.{0}`, its most common instantiation.\n    This Type should be preferred over `PUnit` where possible to avoid\n    unnecessary universe parameters. -/\nabbrev Unit : Type := PUnit\n\n@[matchPattern] abbrev Unit.unit : Unit := PUnit.unit\n\n/-- Auxiliary unsafe constant used by the Compiler when erasing proofs from code. -/\nunsafe axiom lcProof {\u03b1 : Prop} : \u03b1\n\n/-- Auxiliary unsafe constant used by the Compiler to mark unreachable code. -/\nunsafe axiom lcUnreachable {\u03b1 : Sort u} : \u03b1\n\ninductive True : Prop where\n  | intro : True\n\ninductive False : Prop\n\ninductive Empty : Type\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\ninductive PEmpty : Sort u where\n\ndef Not (a : Prop) : Prop := a \u2192 False\n\n@[macroInline] def False.elim {C : Sort u} (h : False) : C :=\n  False.rec (fun _ => C) h\n\n@[macroInline] def absurd {a : Prop} {b : Sort v} (h\u2081 : a) (h\u2082 : Not a) : b :=\n  False.elim (h\u2082 h\u2081)\n\ninductive Eq {\u03b1 : Sort u} (a : \u03b1) : \u03b1 \u2192 Prop where\n  | refl {} : Eq a a\n\n@[simp] abbrev Eq.ndrec.{u1, u2} {\u03b1 : Sort u2} {a : \u03b1} {motive : \u03b1 \u2192 Sort u1} (m : motive a) {b : \u03b1} (h : Eq a b) : motive b :=\n  Eq.rec (motive := fun \u03b1 _ => motive \u03b1) m h\n\n@[matchPattern] def rfl {\u03b1 : Sort u} {a : \u03b1} : Eq a a := Eq.refl a\n\n@[simp] theorem id_eq (a : \u03b1) : Eq (id a) a := rfl\n\ntheorem Eq.subst {\u03b1 : Sort u} {motive : \u03b1 \u2192 Prop} {a b : \u03b1} (h\u2081 : Eq a b) (h\u2082 : motive a) : motive b :=\n  Eq.ndrec h\u2082 h\u2081\n\ntheorem Eq.symm {\u03b1 : Sort u} {a b : \u03b1} (h : Eq a b) : Eq b a :=\n  h \u25b8 rfl\n\ntheorem Eq.trans {\u03b1 : Sort u} {a b c : \u03b1} (h\u2081 : Eq a b) (h\u2082 : Eq b c) : Eq a c :=\n  h\u2082 \u25b8 h\u2081\n\n@[macroInline] def cast {\u03b1 \u03b2 : Sort u} (h : Eq \u03b1 \u03b2) (a : \u03b1) : \u03b2 :=\n  Eq.rec (motive := fun \u03b1 _ => \u03b1) a h\n\ntheorem congrArg {\u03b1 : Sort u} {\u03b2 : Sort v} {a\u2081 a\u2082 : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : Eq a\u2081 a\u2082) : Eq (f a\u2081) (f a\u2082) :=\n  h \u25b8 rfl\n\ntheorem congr {\u03b1 : Sort u} {\u03b2 : Sort v} {f\u2081 f\u2082 : \u03b1 \u2192 \u03b2} {a\u2081 a\u2082 : \u03b1} (h\u2081 : Eq f\u2081 f\u2082) (h\u2082 : Eq a\u2081 a\u2082) : Eq (f\u2081 a\u2081) (f\u2082 a\u2082) :=\n  h\u2081 \u25b8 h\u2082 \u25b8 rfl\n\ntheorem congrFun {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {f g : (x : \u03b1) \u2192  \u03b2 x} (h : Eq f g) (a : \u03b1) : Eq (f a) (g a) :=\n  h \u25b8 rfl\n\n/-\nInitialize the Quotient Module, which effectively adds the following definitions:\n\nconstant Quot {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Sort u\n\nconstant Quot.mk {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : Quot r\n\nconstant Quot.lift {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) :\n  (\u2200 a b : \u03b1, r a b \u2192 Eq (f a) (f b)) \u2192 Quot r \u2192 \u03b2\n\nconstant Quot.ind {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Quot r \u2192 Prop} :\n  (\u2200 a : \u03b1, \u03b2 (Quot.mk r a)) \u2192 \u2200 q : Quot r, \u03b2 q\n-/\ninit_quot\n\ninductive HEq {\u03b1 : Sort u} (a : \u03b1) : {\u03b2 : Sort u} \u2192 \u03b2 \u2192 Prop where\n  | refl {} : HEq a a\n\n@[matchPattern] protected def HEq.rfl {\u03b1 : Sort u} {a : \u03b1} : HEq a a :=\n  HEq.refl a\n\ntheorem eq_of_heq {\u03b1 : Sort u} {a a' : \u03b1} (h : HEq a a') : Eq a a' :=\n  have : (\u03b1 \u03b2 : Sort u) \u2192 (a : \u03b1) \u2192 (b : \u03b2) \u2192 HEq a b \u2192 (h : Eq \u03b1 \u03b2) \u2192 Eq (cast h a) b :=\n    fun \u03b1 \u03b2 a b h\u2081 =>\n      HEq.rec (motive := fun {\u03b2} (b : \u03b2) (h : HEq a b) => (h\u2082 : Eq \u03b1 \u03b2) \u2192 Eq (cast h\u2082 a) b)\n        (fun (h\u2082 : Eq \u03b1 \u03b1) => rfl)\n        h\u2081\n  this \u03b1 \u03b1 a a' h rfl\n\nstructure Prod (\u03b1 : Type u) (\u03b2 : Type v) where\n  fst : \u03b1\n  snd : \u03b2\n\nattribute [unbox] Prod\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` can be propositions.\n   We use this Type internally to automatically generate the brecOn recursor. -/\nstructure PProd (\u03b1 : Sort u) (\u03b2 : Sort v) where\n  fst : \u03b1\n  snd : \u03b2\n\n/-- Similar to `Prod`, but `\u03b1` and `\u03b2` are in the same universe. -/\nstructure MProd (\u03b1 \u03b2 : Type u) where\n  fst : \u03b1\n  snd : \u03b2\n\nstructure And (a b : Prop) : Prop where\n  intro :: (left : a) (right : b)\n\ninductive Or (a b : Prop) : Prop where\n  | inl (h : a) : Or a b\n  | inr (h : b) : Or a b\n\ntheorem Or.intro_left (b : Prop) (h : a) : Or a b :=\n  Or.inl h\n\ntheorem Or.intro_right (a : Prop) (h : b) : Or a b :=\n  Or.inr h\n\ntheorem Or.elim {c : Prop} (h : Or a b) (left : a \u2192 c) (right : b \u2192 c) : c :=\n  match h with\n  | Or.inl h => left h\n  | Or.inr h => right h\n\ninductive Bool : Type where\n  | false : Bool\n  | true : Bool\n\nexport Bool (false true)\n\n/- Remark: Subtype must take a Sort instead of Type because of the axiom strongIndefiniteDescription. -/\nstructure Subtype {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) where\n  val : \u03b1\n  property : p val\n\n/-- Gadget for optional parameter support. -/\n@[reducible] def optParam (\u03b1 : Sort u) (default : \u03b1) : Sort u := \u03b1\n\n/-- Gadget for marking output parameters in type classes. -/\n@[reducible] def outParam (\u03b1 : Sort u) : Sort u := \u03b1\n\n/-- Auxiliary Declaration used to implement the notation (a : \u03b1) -/\n@[reducible] def typedExpr (\u03b1 : Sort u) (a : \u03b1) : \u03b1 := a\n\n/-- Auxiliary Declaration used to implement the named patterns `x@p` -/\n@[reducible] def namedPattern {\u03b1 : Sort u} (x a : \u03b1) : \u03b1 := a\n\n/- Auxiliary axiom used to implement `sorry`. -/\n@[extern \"lean_sorry\", neverExtract]\naxiom sorryAx (\u03b1 : Sort u) (synthetic := true) : \u03b1\n\ntheorem eq_false_of_ne_true : {b : Bool} \u2192 Not (Eq b true) \u2192 Eq b false\n  | true, h => False.elim (h rfl)\n  | false, h => rfl\n\ntheorem eq_true_of_ne_false : {b : Bool} \u2192 Not (Eq b false) \u2192 Eq b true\n  | true, h => rfl\n  | false, h => False.elim (h rfl)\n\ntheorem ne_false_of_eq_true : {b : Bool} \u2192 Eq b true \u2192 Not (Eq b false)\n  | true, _  => fun h => Bool.noConfusion h\n  | false, h => Bool.noConfusion h\n\ntheorem ne_true_of_eq_false : {b : Bool} \u2192 Eq b false \u2192 Not (Eq b true)\n  | true, h  => Bool.noConfusion h\n  | false, _ => fun h => Bool.noConfusion h\n\nclass Inhabited (\u03b1 : Sort u) where\n  mk {} :: (default : \u03b1)\n\nconstant arbitrary [Inhabited \u03b1] : \u03b1 :=\n  Inhabited.default\n\ninstance : Inhabited (Sort u) where\n  default := PUnit\n\ninstance (\u03b1 : Sort u) {\u03b2 : Sort v} [Inhabited \u03b2] : Inhabited (\u03b1 \u2192 \u03b2) where\n  default := fun _ => arbitrary\n\ninstance (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(a : \u03b1) \u2192 Inhabited (\u03b2 a)] : Inhabited ((a : \u03b1) \u2192 \u03b2 a) where\n  default := fun _ => arbitrary\n\nderiving instance Inhabited for Bool\n\n/-- Universe lifting operation from Sort to Type -/\nstructure PLift (\u03b1 : Sort u) : Type u where\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and PLift \u03b1 -/\ntheorem PLift.up_down {\u03b1 : Sort u} : \u2200 (b : PLift \u03b1), Eq (up (down b)) b\n  | up a => rfl\n\ntheorem PLift.down_up {\u03b1 : Sort u} (a : \u03b1) : Eq (down (up a)) a :=\n  rfl\n\n/- Pointed types -/\nstructure PointedType where\n  (type : Type u)\n  (val : type)\n\ninstance : Inhabited PointedType.{u} where\n  default := { type := PUnit.{u+1}, val := \u27e8\u27e9 }\n\n/-- Universe lifting operation -/\nstructure ULift.{r, s} (\u03b1 : Type s) : Type (max s r) where\n  up :: (down : \u03b1)\n\n/- Bijection between \u03b1 and ULift.{v} \u03b1 -/\ntheorem ULift.up_down {\u03b1 : Type u} : \u2200 (b : ULift.{v} \u03b1), Eq (up (down b)) b\n  | up a => rfl\n\ntheorem ULift.down_up {\u03b1 : Type u} (a : \u03b1) : Eq (down (up.{v} a)) a :=\n  rfl\n\nclass inductive Decidable (p : Prop) where\n  | isFalse (h : Not p) : Decidable p\n  | isTrue  (h : p) : Decidable p\n\n@[inlineIfReduce, nospecialize] def Decidable.decide (p : Prop) [h : Decidable p] : Bool :=\n  Decidable.casesOn (motive := fun _ => Bool) h (fun _ => false) (fun _ => true)\n\nexport Decidable (isTrue isFalse decide)\n\nabbrev DecidablePred {\u03b1 : Sort u} (r : \u03b1 \u2192 Prop) :=\n  (a : \u03b1) \u2192 Decidable (r a)\n\nabbrev DecidableRel {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :=\n  (a b : \u03b1) \u2192 Decidable (r a b)\n\nabbrev DecidableEq (\u03b1 : Sort u) :=\n  (a b : \u03b1) \u2192 Decidable (Eq a b)\n\ndef decEq {\u03b1 : Sort u} [s : DecidableEq \u03b1] (a b : \u03b1) : Decidable (Eq a b) :=\n  s a b\n\ntheorem decide_eq_true : [s : Decidable p] \u2192 p \u2192 Eq (decide p) true\n  | isTrue  _, _   => rfl\n  | isFalse h\u2081, h\u2082 => absurd h\u2082 h\u2081\n\ntheorem decide_eq_false : [s : Decidable p] \u2192 Not p \u2192 Eq (decide p) false\n  | isTrue  h\u2081, h\u2082 => absurd h\u2081 h\u2082\n  | isFalse h, _   => rfl\n\ntheorem of_decide_eq_true [s : Decidable p] : Eq (decide p) true \u2192 p := fun h =>\n  match (generalizing := false) s with\n  | isTrue  h\u2081 => h\u2081\n  | isFalse h\u2081 => absurd h (ne_true_of_eq_false (decide_eq_false h\u2081))\n\ntheorem of_decide_eq_false [s : Decidable p] : Eq (decide p) false \u2192 Not p := fun h =>\n  match (generalizing := false) s with\n  | isTrue  h\u2081 => absurd h (ne_false_of_eq_true (decide_eq_true h\u2081))\n  | isFalse h\u2081 => h\u2081\n\n@[inline] instance : DecidableEq Bool :=\n  fun a b => match a, b with\n   | false, false => isTrue rfl\n   | false, true  => isFalse (fun h => Bool.noConfusion h)\n   | true, false  => isFalse (fun h => Bool.noConfusion h)\n   | true, true   => isTrue rfl\n\nclass BEq (\u03b1 : Type u) where\n  beq : \u03b1 \u2192 \u03b1 \u2192 Bool\n\nopen BEq (beq)\n\ninstance [DecidableEq \u03b1] : BEq \u03b1 where\n  beq a b := decide (Eq a b)\n\n-- We use \"dependent\" if-then-else to be able to communicate the if-then-else condition\n-- to the branches\n@[macroInline] def dite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t : c \u2192 \u03b1) (e : Not c \u2192 \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h e t\n\n/- if-then-else -/\n\n@[macroInline] def ite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t e : \u03b1) : \u03b1 :=\n  Decidable.casesOn (motive := fun _ => \u03b1) h (fun _ => e) (fun _ => t)\n\n@[macroInline] instance {p q} [dp : Decidable p] [dq : Decidable q] : Decidable (And p q) :=\n  match dp with\n  | isTrue  hp =>\n    match dq with\n    | isTrue hq  => isTrue \u27e8hp, hq\u27e9\n    | isFalse hq => isFalse (fun h => hq (And.right h))\n  | isFalse hp =>\n    isFalse (fun h => hp (And.left h))\n\n@[macroInline] instance [dp : Decidable p] [dq : Decidable q] : Decidable (Or p q) :=\n  match dp with\n  | isTrue  hp => isTrue (Or.inl hp)\n  | isFalse hp =>\n    match dq with\n    | isTrue hq  => isTrue (Or.inr hq)\n    | isFalse hq =>\n      isFalse fun h => match h with\n        | Or.inl h => hp h\n        | Or.inr h => hq h\n\ninstance [dp : Decidable p] : Decidable (Not p) :=\n  match dp with\n  | isTrue hp  => isFalse (absurd hp)\n  | isFalse hp => isTrue hp\n\n/- Boolean operators -/\n\n@[macroInline] def cond {\u03b1 : Type u} (c : Bool) (x y : \u03b1) : \u03b1 :=\n  match c with\n  | true  => x\n  | false => y\n\n@[macroInline] def or (x y : Bool) : Bool :=\n  match x with\n  | true  => true\n  | false => y\n\n@[macroInline] def and (x y : Bool) : Bool :=\n  match x with\n  | false => false\n  | true  => y\n\n@[inline] def not : Bool \u2192 Bool\n  | true  => false\n  | false => true\n\ninductive Nat where\n  | zero : Nat\n  | succ (n : Nat) : Nat\n\ninstance : Inhabited Nat where\n  default := Nat.zero\n\n/- For numeric literals notation -/\nclass OfNat (\u03b1 : Type u) (n : Nat) where\n  ofNat : \u03b1\n\n@[defaultInstance 100] /- low prio -/\ninstance (n : Nat) : OfNat Nat n where\n  ofNat := n\n\nclass LE (\u03b1 : Type u) where le : \u03b1 \u2192 \u03b1 \u2192 Prop\nclass LT (\u03b1 : Type u) where lt : \u03b1 \u2192 \u03b1 \u2192 Prop\n\n@[reducible] def GE.ge {\u03b1 : Type u} [LE \u03b1] (a b : \u03b1) : Prop := LE.le b a\n@[reducible] def GT.gt {\u03b1 : Type u} [LT \u03b1] (a b : \u03b1) : Prop := LT.lt b a\n\n@[inline] def max [LT \u03b1] [DecidableRel (@LT.lt \u03b1 _)] (a b : \u03b1) : \u03b1 :=\n  ite (LT.lt b a) a b\n\n@[inline] def min [LE \u03b1] [DecidableRel (@LE.le \u03b1 _)] (a b : \u03b1) : \u03b1 :=\n  ite (LE.le a b) a b\n\n/-- Transitive chaining of proofs, used e.g. by `calc`. -/\nclass Trans (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (s : \u03b2 \u2192 \u03b3 \u2192 Prop) (t : outParam (\u03b1 \u2192 \u03b3 \u2192 Prop)) where\n  trans : r a b \u2192 s b c \u2192 t a c\n\nexport Trans (trans)\n\ninstance (r : \u03b1 \u2192 \u03b3 \u2192 Prop) : Trans Eq r r where\n  trans heq h' := heq \u25b8 h'\n\ninstance (r : \u03b1 \u2192 \u03b2 \u2192 Prop) : Trans r Eq r where\n  trans h' heq := heq \u25b8 h'\n\nclass HAdd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAdd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HSub (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hSub : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HMul (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hMul : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HDiv (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hDiv : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HMod (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hMod : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HPow (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hPow : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HAppend (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAppend : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HOrElse (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hOrElse : \u03b1 \u2192 (Unit \u2192 \u03b2) \u2192 \u03b3\n\nclass HAndThen (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAndThen : \u03b1 \u2192 (Unit \u2192 \u03b2) \u2192 \u03b3\n\nclass HAnd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hAnd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HXor (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hXor : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HOr (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hOr : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HShiftLeft (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hShiftLeft : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass HShiftRight (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  hShiftRight : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\nclass Add (\u03b1 : Type u) where\n  add : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Sub (\u03b1 : Type u) where\n  sub : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Mul (\u03b1 : Type u) where\n  mul : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Neg (\u03b1 : Type u) where\n  neg : \u03b1 \u2192 \u03b1\n\nclass Div (\u03b1 : Type u) where\n  div : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Mod (\u03b1 : Type u) where\n  mod : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Pow (\u03b1 : Type u) (\u03b2 : Type v) where\n  pow : \u03b1 \u2192 \u03b2 \u2192 \u03b1\n\nclass Append (\u03b1 : Type u) where\n  append : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass OrElse (\u03b1 : Type u) where\n  orElse  : \u03b1 \u2192 (Unit \u2192 \u03b1) \u2192 \u03b1\n\nclass AndThen (\u03b1 : Type u) where\n  andThen : \u03b1 \u2192 (Unit \u2192 \u03b1) \u2192 \u03b1\n\nclass AndOp (\u03b1 : Type u) where\n  and : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Xor (\u03b1 : Type u) where\n  xor : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass OrOp (\u03b1 : Type u) where\n  or : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass Complement (\u03b1 : Type u) where\n  complement : \u03b1 \u2192 \u03b1\n\nclass ShiftLeft (\u03b1 : Type u) where\n  shiftLeft : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nclass ShiftRight (\u03b1 : Type u) where\n  shiftRight : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n@[defaultInstance]\ninstance [Add \u03b1] : HAdd \u03b1 \u03b1 \u03b1 where\n  hAdd a b := Add.add a b\n\n@[defaultInstance]\ninstance [Sub \u03b1] : HSub \u03b1 \u03b1 \u03b1 where\n  hSub a b := Sub.sub a b\n\n@[defaultInstance]\ninstance [Mul \u03b1] : HMul \u03b1 \u03b1 \u03b1 where\n  hMul a b := Mul.mul a b\n\n@[defaultInstance]\ninstance [Div \u03b1] : HDiv \u03b1 \u03b1 \u03b1 where\n  hDiv a b := Div.div a b\n\n@[defaultInstance]\ninstance [Mod \u03b1] : HMod \u03b1 \u03b1 \u03b1 where\n  hMod a b := Mod.mod a b\n\n@[defaultInstance]\ninstance [Pow \u03b1 \u03b2] : HPow \u03b1 \u03b2 \u03b1 where\n  hPow a b := Pow.pow a b\n\n@[defaultInstance]\ninstance [Append \u03b1] : HAppend \u03b1 \u03b1 \u03b1 where\n  hAppend a b := Append.append a b\n\n@[defaultInstance]\ninstance [OrElse \u03b1] : HOrElse \u03b1 \u03b1 \u03b1 where\n  hOrElse a b := OrElse.orElse a b\n\n@[defaultInstance]\ninstance [AndThen \u03b1] : HAndThen \u03b1 \u03b1 \u03b1 where\n  hAndThen a b := AndThen.andThen a b\n\n@[defaultInstance]\ninstance [AndOp \u03b1] : HAnd \u03b1 \u03b1 \u03b1 where\n  hAnd a b := AndOp.and a b\n\n@[defaultInstance]\ninstance [Xor \u03b1] : HXor \u03b1 \u03b1 \u03b1 where\n  hXor a b := Xor.xor a b\n\n@[defaultInstance]\ninstance [OrOp \u03b1] : HOr \u03b1 \u03b1 \u03b1 where\n  hOr a b := OrOp.or a b\n\n@[defaultInstance]\ninstance [ShiftLeft \u03b1] : HShiftLeft \u03b1 \u03b1 \u03b1 where\n  hShiftLeft a b := ShiftLeft.shiftLeft a b\n\n@[defaultInstance]\ninstance [ShiftRight \u03b1] : HShiftRight \u03b1 \u03b1 \u03b1 where\n  hShiftRight a b := ShiftRight.shiftRight a b\n\nopen HAdd (hAdd)\nopen HMul (hMul)\nopen HPow (hPow)\nopen HAppend (hAppend)\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_add\"]\nprotected def Nat.add : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, Nat.zero   => a\n  | a, Nat.succ b => Nat.succ (Nat.add a b)\n\ninstance : Add Nat where\n  add := Nat.add\n\n/- We mark the following definitions as pattern to make sure they can be used in recursive equations,\n   and reduced by the equation Compiler. -/\nattribute [matchPattern] Nat.add Add.add HAdd.hAdd Neg.neg\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_mul\"]\nprotected def Nat.mul : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0          => 0\n  | a, Nat.succ b => Nat.add (Nat.mul a b) a\n\ninstance : Mul Nat where\n  mul := Nat.mul\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_pow\"]\nprotected def Nat.pow (m : @& Nat) : (@& Nat) \u2192 Nat\n  | 0      => 1\n  | succ n => Nat.mul (Nat.pow m n) m\n\ninstance : Pow Nat Nat where\n  pow := Nat.pow\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_dec_eq\"]\ndef Nat.beq : (@& Nat) \u2192 (@& Nat) \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => false\n  | succ n, zero   => false\n  | succ n, succ m => beq n m\n\ntheorem Nat.eq_of_beq_eq_true : {n m : Nat} \u2192 Eq (beq n m) true \u2192 Eq n m\n  | zero,   zero,   h => rfl\n  | zero,   succ m, h => Bool.noConfusion h\n  | succ n, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : Eq (beq n m) true := h\n    have : Eq n m := eq_of_beq_eq_true this\n    this \u25b8 rfl\n\ntheorem Nat.ne_of_beq_eq_false : {n m : Nat} \u2192 Eq (beq n m) false \u2192 Not (Eq n m)\n  | zero,   zero,   h\u2081, h\u2082 => Bool.noConfusion h\u2081\n  | zero,   succ m, h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, zero,   h\u2081, h\u2082 => Nat.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have : Eq (beq n m) false := h\u2081\n    Nat.noConfusion h\u2082 (fun h\u2082 => absurd h\u2082 (ne_of_beq_eq_false this))\n\n@[extern \"lean_nat_dec_eq\"]\nprotected def Nat.decEq (n m : @& Nat) : Decidable (Eq n m) :=\n  match h:beq n m with\n  | true  => isTrue (eq_of_beq_eq_true h)\n  | false => isFalse (ne_of_beq_eq_false h)\n\n@[inline] instance : DecidableEq Nat := Nat.decEq\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_dec_le\"]\ndef Nat.ble : @& Nat \u2192 @& Nat \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ m => true\n  | succ n, zero   => false\n  | succ n, succ m => ble n m\n\nprotected inductive Nat.le (n : Nat) : Nat \u2192 Prop\n  | refl     : Nat.le n n\n  | step {m} : Nat.le n m \u2192 Nat.le n (succ m)\n\ninstance : LE Nat where\n  le := Nat.le\n\nprotected def Nat.lt (n m : Nat) : Prop :=\n  Nat.le (succ n) m\n\ninstance : LT Nat where\n  lt := Nat.lt\n\ntheorem Nat.not_succ_le_zero : \u2200 (n : Nat), LE.le (succ n) 0 \u2192 False\n  | 0,      h => nomatch h\n  | succ n, h => nomatch h\n\ntheorem Nat.not_lt_zero (n : Nat) : Not (LT.lt n 0) :=\n  not_succ_le_zero n\n\ntheorem Nat.zero_le : (n : Nat) \u2192 LE.le 0 n\n  | zero   => Nat.le.refl\n  | succ n => Nat.le.step (zero_le n)\n\ntheorem Nat.succ_le_succ : LE.le n m \u2192 LE.le (succ n) (succ m)\n  | Nat.le.refl   => Nat.le.refl\n  | Nat.le.step h => Nat.le.step (succ_le_succ h)\n\ntheorem Nat.zero_lt_succ (n : Nat) : LT.lt 0 (succ n) :=\n  succ_le_succ (zero_le n)\n\ntheorem Nat.le_step (h : LE.le n m) : LE.le n (succ m) :=\n  Nat.le.step h\n\nprotected theorem Nat.le_trans {n m k : Nat} : LE.le n m \u2192 LE.le m k \u2192 LE.le n k\n  | h,  Nat.le.refl    => h\n  | h\u2081, Nat.le.step h\u2082 => Nat.le.step (Nat.le_trans h\u2081 h\u2082)\n\nprotected theorem Nat.lt_trans {n m k : Nat} (h\u2081 : LT.lt n m) : LT.lt m k \u2192 LT.lt n k :=\n  Nat.le_trans (le_step h\u2081)\n\ntheorem Nat.le_succ (n : Nat) : LE.le n (succ n) :=\n  Nat.le.step Nat.le.refl\n\ntheorem Nat.le_succ_of_le {n m : Nat} (h : LE.le n m) : LE.le n (succ m) :=\n  Nat.le_trans h (le_succ m)\n\nprotected theorem Nat.le_refl (n : Nat) : LE.le n n :=\n  Nat.le.refl\n\ntheorem Nat.succ_pos (n : Nat) : LT.lt 0 (succ n) :=\n  zero_lt_succ n\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"lean_nat_sub(#1, lean_box(1))\"]\ndef Nat.pred : (@& Nat) \u2192 Nat\n  | 0      => 0\n  | succ a => a\n\ntheorem Nat.pred_le_pred : {n m : Nat} \u2192 LE.le n m \u2192 LE.le (pred n) (pred m)\n  | _,           _, Nat.le.refl   => Nat.le.refl\n  | 0,      succ m, Nat.le.step h => h\n  | succ n, succ m, Nat.le.step h => Nat.le_trans (le_succ _) h\n\ntheorem Nat.le_of_succ_le_succ {n m : Nat} : LE.le (succ n) (succ m) \u2192 LE.le n m :=\n  pred_le_pred\n\ntheorem Nat.le_of_lt_succ {m n : Nat} : LT.lt m (succ n) \u2192 LE.le m n :=\n  le_of_succ_le_succ\n\nprotected theorem Nat.eq_or_lt_of_le : {n m: Nat} \u2192 LE.le n m \u2192 Or (Eq n m) (LT.lt n m)\n  | zero,   zero,   h => Or.inl rfl\n  | zero,   succ n, h => Or.inr (Nat.succ_le_succ (Nat.zero_le _))\n  | succ n, zero,   h => absurd h (not_succ_le_zero _)\n  | succ n, succ m, h =>\n    have : LE.le n m := Nat.le_of_succ_le_succ h\n    match Nat.eq_or_lt_of_le this with\n    | Or.inl h => Or.inl (h \u25b8 rfl)\n    | Or.inr h => Or.inr (succ_le_succ h)\n\nprotected theorem Nat.lt_or_ge (n m : Nat) : Or (LT.lt n m) (GE.ge n m) :=\n  match m with\n  | zero   => Or.inr (zero_le n)\n  | succ m =>\n    match Nat.lt_or_ge n m with\n    | Or.inl h => Or.inl (le_succ_of_le h)\n    | Or.inr h =>\n      match Nat.eq_or_lt_of_le h with\n      | Or.inl h1 => Or.inl (h1 \u25b8 Nat.le_refl _)\n      | Or.inr h1 => Or.inr h1\n\ntheorem Nat.not_succ_le_self : (n : Nat) \u2192 Not (LE.le (succ n) n)\n  | 0      => not_succ_le_zero _\n  | succ n => fun h => absurd (le_of_succ_le_succ h) (not_succ_le_self n)\n\nprotected theorem Nat.lt_irrefl (n : Nat) : Not (LT.lt n n) :=\n  Nat.not_succ_le_self n\n\nprotected theorem Nat.lt_of_le_of_lt {n m k : Nat} (h\u2081 : LE.le n m) (h\u2082 : LT.lt m k) : LT.lt n k :=\n  Nat.le_trans (Nat.succ_le_succ h\u2081) h\u2082\n\nprotected theorem Nat.le_antisymm {n m : Nat} (h\u2081 : LE.le n m) (h\u2082 : LE.le m n) : Eq n m :=\n  match h\u2081 with\n  | Nat.le.refl   => rfl\n  | Nat.le.step h => absurd (Nat.lt_of_le_of_lt h h\u2082) (Nat.lt_irrefl n)\n\nprotected theorem Nat.lt_of_le_of_ne {n m : Nat} (h\u2081 : LE.le n m) (h\u2082 : Not (Eq n m)) : LT.lt n m :=\n  match Nat.lt_or_ge n m with\n  | Or.inl h\u2083 => h\u2083\n  | Or.inr h\u2083 => absurd (Nat.le_antisymm h\u2081 h\u2083) h\u2082\n\ntheorem Nat.le_of_ble_eq_true (h : Eq (Nat.ble n m) true) : LE.le n m :=\n  match n, m with\n  | 0,      _      => Nat.zero_le _\n  | succ _, succ _ => Nat.succ_le_succ (le_of_ble_eq_true h)\n\ntheorem Nat.ble_self_eq_true : (n : Nat) \u2192 Eq (Nat.ble n n) true\n  | 0      => rfl\n  | succ n => ble_self_eq_true n\n\ntheorem Nat.ble_succ_eq_true : {n m : Nat} \u2192 Eq (Nat.ble n m) true \u2192 Eq (Nat.ble n (succ m)) true\n  | 0,      _,      _ => rfl\n  | succ n, succ m, h => ble_succ_eq_true (n := n) h\n\ntheorem Nat.ble_eq_true_of_le (h : LE.le n m) : Eq (Nat.ble n m) true :=\n  match h with\n  | Nat.le.refl   => Nat.ble_self_eq_true n\n  | Nat.le.step h => Nat.ble_succ_eq_true (ble_eq_true_of_le h)\n\ntheorem Nat.not_le_of_not_ble_eq_true (h : Not (Eq (Nat.ble n m) true)) : Not (LE.le n m) :=\n  fun h' => absurd (Nat.ble_eq_true_of_le h') h\n\n@[extern \"lean_nat_dec_le\"]\ninstance Nat.decLe (n m : @& Nat) : Decidable (LE.le n m) :=\n  dite (Eq (Nat.ble n m) true) (fun h => isTrue (Nat.le_of_ble_eq_true h)) (fun h => isFalse (Nat.not_le_of_not_ble_eq_true h))\n\n@[extern \"lean_nat_dec_lt\"]\ninstance Nat.decLt (n m : @& Nat) : Decidable (LT.lt n m) :=\n  decLe (succ n) m\n\nset_option bootstrap.genMatcherCode false in\n@[extern \"lean_nat_sub\"]\nprotected def Nat.sub : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0      => a\n  | a, succ b => pred (Nat.sub a b)\n\ninstance : Sub Nat where\n  sub := Nat.sub\n\n@[extern \"lean_system_platform_nbits\"] constant System.Platform.getNumBits : Unit \u2192 Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=\n  fun _ => \u27e864, Or.inr rfl\u27e9 -- inhabitant\n\ndef System.Platform.numBits : Nat :=\n  (getNumBits ()).val\n\ntheorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=\n  (getNumBits ()).property\n\nstructure Fin (n : Nat) where\n  val  : Nat\n  isLt : LT.lt val n\n\ntheorem Fin.eq_of_val_eq {n} : \u2200 {i j : Fin n}, Eq i.val j.val \u2192 Eq i j\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Fin.val_eq_of_eq {n} {i j : Fin n} (h : Eq i j) : Eq i.val j.val :=\n  h \u25b8 rfl\n\ntheorem Fin.ne_of_val_ne {n} {i j : Fin n} (h : Not (Eq i.val j.val)) : Not (Eq i j) :=\n  fun h' => absurd (val_eq_of_eq h') h\n\ninstance (n : Nat) : DecidableEq (Fin n) :=\n  fun i j =>\n    match decEq i.val j.val with\n    | isTrue h  => isTrue (Fin.eq_of_val_eq h)\n    | isFalse h => isFalse (Fin.ne_of_val_ne h)\n\ninstance {n} : LT (Fin n) where\n  lt a b := LT.lt a.val b.val\n\ninstance {n} : LE (Fin n) where\n  le a b := LE.le a.val b.val\n\ninstance Fin.decLt {n} (a b : Fin n) : Decidable (LT.lt a b)  := Nat.decLt ..\ninstance Fin.decLe {n} (a b : Fin n) : Decidable (LE.le a b) := Nat.decLe ..\n\ndef UInt8.size : Nat := 256\nstructure UInt8 where\n  val : Fin UInt8.size\n\nattribute [extern \"lean_uint8_of_nat_mk\"] UInt8.mk\nattribute [extern \"lean_uint8_to_nat\"] UInt8.val\n\n@[extern \"lean_uint8_of_nat\"]\ndef UInt8.ofNatCore (n : @& Nat) (h : LT.lt n UInt8.size) : UInt8 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt8.decEq (a b : UInt8) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt8.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt8 := UInt8.decEq\n\ninstance : Inhabited UInt8 where\n  default := UInt8.ofNatCore 0 (by decide)\n\ndef UInt16.size : Nat := 65536\nstructure UInt16 where\n  val : Fin UInt16.size\n\nattribute [extern \"lean_uint16_of_nat_mk\"] UInt16.mk\nattribute [extern \"lean_uint16_to_nat\"] UInt16.val\n\n@[extern \"lean_uint16_of_nat\"]\ndef UInt16.ofNatCore (n : @& Nat) (h : LT.lt n UInt16.size) : UInt16 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt16.decEq (a b : UInt16) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt16.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt16 := UInt16.decEq\n\ninstance : Inhabited UInt16 where\n  default := UInt16.ofNatCore 0 (by decide)\n\ndef UInt32.size : Nat := 4294967296\nstructure UInt32 where\n  val : Fin UInt32.size\n\nattribute [extern \"lean_uint32_of_nat_mk\"] UInt32.mk\nattribute [extern \"lean_uint32_to_nat\"] UInt32.val\n\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNatCore (n : @& Nat) (h : LT.lt n UInt32.size) : UInt32 := {\n  val := { val := n, isLt := h }\n}\n\n@[extern \"lean_uint32_to_nat\"]\ndef UInt32.toNat (n : UInt32) : Nat := n.val.val\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt32.decEq (a b : UInt32) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt32.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt32 := UInt32.decEq\n\ninstance : Inhabited UInt32 where\n  default := UInt32.ofNatCore 0 (by decide)\n\ninstance : LT UInt32 where\n  lt a b := LT.lt a.val b.val\n\ninstance : LE UInt32 where\n  le a b := LE.le a.val b.val\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 < #2\"]\ndef UInt32.decLt (a b : UInt32) : Decidable (LT.lt a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LT.lt n m))\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 <= #2\"]\ndef UInt32.decLe (a b : UInt32) : Decidable (LE.le a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LE.le n m))\n\ninstance (a b : UInt32) : Decidable (LT.lt a b) := UInt32.decLt a b\ninstance (a b : UInt32) : Decidable (LE.le a b) := UInt32.decLe a b\n\ndef UInt64.size : Nat := 18446744073709551616\nstructure UInt64 where\n  val : Fin UInt64.size\n\nattribute [extern \"lean_uint64_of_nat_mk\"] UInt64.mk\nattribute [extern \"lean_uint64_to_nat\"] UInt64.val\n\n@[extern \"lean_uint64_of_nat\"]\ndef UInt64.ofNatCore (n : @& Nat) (h : LT.lt n UInt64.size) : UInt64 := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef UInt64.decEq (a b : UInt64) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt64.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt64 := UInt64.decEq\n\ninstance : Inhabited UInt64 where\n  default := UInt64.ofNatCore 0 (by decide)\n\ndef USize.size : Nat := hPow 2 System.Platform.numBits\n\ntheorem usize_size_eq : Or (Eq USize.size 4294967296) (Eq USize.size 18446744073709551616) :=\n  show Or (Eq (hPow 2 System.Platform.numBits) 4294967296) (Eq (hPow 2 System.Platform.numBits) 18446744073709551616) from\n  match System.Platform.numBits, System.Platform.numBits_eq with\n  | _, Or.inl rfl => Or.inl (by decide)\n  | _, Or.inr rfl => Or.inr (by decide)\n\nstructure USize where\n  val : Fin USize.size\n\nattribute [extern \"lean_usize_of_nat_mk\"] USize.mk\nattribute [extern \"lean_usize_to_nat\"] USize.val\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNatCore (n : @& Nat) (h : LT.lt n USize.size) : USize := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n@[extern c inline \"#1 == #2\"]\ndef USize.decEq (a b : USize) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h =>isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => USize.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq USize := USize.decEq\n\ninstance : Inhabited USize where\n  default := USize.ofNatCore 0 (match USize.size, usize_size_eq with\n    | _, Or.inl rfl => by decide\n    | _, Or.inr rfl => by decide)\n\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNat32 (n : @& Nat) (h : LT.lt n 4294967296) : USize := {\n  val := {\n    val  := n\n    isLt := match USize.size, usize_size_eq with\n      | _, Or.inl rfl => h\n      | _, Or.inr rfl => Nat.lt_trans h (by decide)\n  }\n}\n\nabbrev Nat.isValidChar (n : Nat) : Prop :=\n  Or (LT.lt n 0xd800) (And (LT.lt 0xdfff n) (LT.lt n 0x110000))\n\nabbrev UInt32.isValidChar (n : UInt32) : Prop :=\n  n.toNat.isValidChar\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   : UInt32\n  valid : val.isValidChar\n\nprivate theorem isValidChar_UInt32 {n : Nat} (h : n.isValidChar) : LT.lt n UInt32.size :=\n  match h with\n  | Or.inl h      => Nat.lt_trans h (by decide)\n  | Or.inr \u27e8_, h\u27e9 => Nat.lt_trans h (by decide)\n\n@[extern \"lean_uint32_of_nat\"]\nprivate def Char.ofNatAux (n : @& Nat) (h : n.isValidChar) : Char :=\n  { val := \u27e8{ val := n, isLt := isValidChar_UInt32 h }\u27e9, valid := h }\n\n@[noinline, matchPattern]\ndef Char.ofNat (n : Nat) : Char :=\n  dite (n.isValidChar)\n    (fun h => Char.ofNatAux n h)\n    (fun _ => { val := \u27e8{ val := 0, isLt := by decide }\u27e9, valid := Or.inl (by decide) })\n\ntheorem Char.eq_of_val_eq : \u2200 {c d : Char}, Eq c.val d.val \u2192 Eq c d\n  | \u27e8v, h\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Char.val_eq_of_eq : \u2200 {c d : Char}, Eq c d \u2192 Eq c.val d.val\n  | _, _, rfl => rfl\n\ntheorem Char.ne_of_val_ne {c d : Char} (h : Not (Eq c.val d.val)) : Not (Eq c d) :=\n  fun h' => absurd (val_eq_of_eq h') h\n\ntheorem Char.val_ne_of_ne {c d : Char} (h : Not (Eq c d)) : Not (Eq c.val d.val) :=\n  fun h' => absurd (eq_of_val_eq h') h\n\ninstance : DecidableEq Char :=\n  fun c d =>\n    match decEq c.val d.val with\n    | isTrue h  => isTrue (Char.eq_of_val_eq h)\n    | isFalse h => isFalse (Char.ne_of_val_ne h)\n\ndef Char.utf8Size (c : Char) : UInt32 :=\n  let v := c.val\n  ite (LE.le v (UInt32.ofNatCore 0x7F (by decide)))\n    (UInt32.ofNatCore 1 (by decide))\n    (ite (LE.le v (UInt32.ofNatCore 0x7FF (by decide)))\n      (UInt32.ofNatCore 2 (by decide))\n      (ite (LE.le v (UInt32.ofNatCore 0xFFFF (by decide)))\n        (UInt32.ofNatCore 3 (by decide))\n        (UInt32.ofNatCore 4 (by decide))))\n\ninductive Option (\u03b1 : Type u) where\n  | none : Option \u03b1\n  | some (val : \u03b1) : Option \u03b1\n\nattribute [unbox] Option\n\nexport Option (none some)\n\ninstance {\u03b1} : Inhabited (Option \u03b1) where\n  default := none\n\n@[macroInline] def Option.getD : Option \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  | some x, _ => x\n  | none,   e => e\n\ninductive List (\u03b1 : Type u) where\n  | nil : List \u03b1\n  | cons (head : \u03b1) (tail : List \u03b1) : List \u03b1\n\ninstance {\u03b1} : Inhabited (List \u03b1) where\n  default := List.nil\n\nprotected def List.hasDecEq {\u03b1: Type u} [DecidableEq \u03b1] : (a b : List \u03b1) \u2192 Decidable (Eq a b)\n  | nil,       nil       => isTrue rfl\n  | cons a as, nil       => isFalse (fun h => List.noConfusion h)\n  | nil,       cons b bs => isFalse (fun h => List.noConfusion h)\n  | cons a as, cons b bs =>\n    match decEq a b with\n    | isTrue hab  =>\n      match List.hasDecEq as bs with\n      | isTrue habs  => isTrue (hab \u25b8 habs \u25b8 rfl)\n      | isFalse nabs => isFalse (fun h => List.noConfusion h (fun _ habs => absurd habs nabs))\n    | isFalse nab => isFalse (fun h => List.noConfusion h (fun hab _ => absurd hab nab))\n\ninstance {\u03b1 : Type u} [DecidableEq \u03b1] : DecidableEq (List \u03b1) := List.hasDecEq\n\n@[specialize]\ndef List.foldl {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) : (init : \u03b1) \u2192 List \u03b2 \u2192 \u03b1\n  | a, nil      => a\n  | a, cons b l => foldl f (f a b) l\n\ndef List.set : List \u03b1 \u2192 Nat \u2192 \u03b1 \u2192 List \u03b1\n  | cons a as, 0,          b => cons b as\n  | cons a as, Nat.succ n, b => cons a (set as n b)\n  | nil,       _,          _ => nil\n\ndef List.length : List \u03b1 \u2192 Nat\n  | nil       => 0\n  | cons a as => HAdd.hAdd (length as) 1\n\ndef List.lengthTRAux : List \u03b1 \u2192 Nat \u2192 Nat\n  | nil,       n => n\n  | cons a as, n => lengthTRAux as (Nat.succ n)\n\ndef List.lengthTR (as : List \u03b1) : Nat :=\n  lengthTRAux as 0\n\n@[simp] theorem List.length_cons {\u03b1} (a : \u03b1) (as : List \u03b1) : Eq (cons a as).length as.length.succ :=\n  rfl\n\ndef List.concat {\u03b1 : Type u} : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1\n  | nil,       b => cons b nil\n  | cons a as, b => cons a (concat as b)\n\ndef List.get {\u03b1 : Type u} : (as : List \u03b1) \u2192 (i : Nat) \u2192 LT.lt i as.length \u2192 \u03b1\n  | nil,       i,          h => absurd h (Nat.not_lt_zero _)\n  | cons a as, 0,          h => a\n  | cons a as, Nat.succ i, h =>\n    have : LT.lt i.succ as.length.succ := length_cons .. \u25b8 h\n    get as i (Nat.le_of_succ_le_succ this)\n\nstructure String where\n  data : List Char\n\nattribute [extern \"lean_string_mk\"] String.mk\nattribute [extern \"lean_string_data\"] String.data\n\n@[extern \"lean_string_dec_eq\"]\ndef String.decEq (s\u2081 s\u2082 : @& String) : Decidable (Eq s\u2081 s\u2082) :=\n  match s\u2081, s\u2082 with\n  | \u27e8s\u2081\u27e9, \u27e8s\u2082\u27e9 =>\n    dite (Eq s\u2081 s\u2082) (fun h => isTrue (congrArg _ h)) (fun h => isFalse (fun h' => String.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq String := String.decEq\n\n/-- A byte position in a `String`. Internally, `String`s are UTF-8 encoded.\nCodepoint positions (counting the Unicode codepoints rather than bytes)\nare represented by plain `Nat`s instead.\nIndexing a `String` by a byte position is constant-time, while codepoint\npositions need to be translated internally to byte positions in linear-time. -/\nabbrev String.Pos := Nat\n\nstructure Substring where\n  str : String\n  startPos : String.Pos\n  stopPos : String.Pos\n\n@[inline] def Substring.bsize : Substring \u2192 Nat\n  | \u27e8_, b, e\u27e9 => e.sub b\n\ndef String.csize (c : Char) : Nat :=\n  c.utf8Size.toNat\n\nprivate def String.utf8ByteSizeAux : List Char \u2192 Nat \u2192 Nat\n  | List.nil,       r => r\n  | List.cons c cs, r => utf8ByteSizeAux cs (hAdd r (csize c))\n\n@[extern \"lean_string_utf8_byte_size\"]\ndef String.utf8ByteSize : (@& String) \u2192 Nat\n  | \u27e8s\u27e9 => utf8ByteSizeAux s 0\n\n@[inline] def String.bsize (s : String) : Nat :=\n  utf8ByteSize s\n\n@[inline] def String.toSubstring (s : String) : Substring := {\n  str      := s\n  startPos := 0\n  stopPos  := s.bsize\n}\n\n@[extern c inline \"#3\"]\nunsafe def unsafeCast {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) : \u03b2 :=\n  cast lcProof (PUnit.{v})\n\n@[neverExtract, extern \"lean_panic_fn\"]\nconstant panic {\u03b1 : Type u} [Inhabited \u03b1] (msg : String) : \u03b1\n\n/-\nThe Compiler has special support for arrays.\nThey are implemented using dynamic arrays: https://en.wikipedia.org/wiki/Dynamic_array\n-/\nstructure Array (\u03b1 : Type u) where\n  data : List \u03b1\n\nattribute [extern \"lean_array_data\"] Array.data\nattribute [extern \"lean_array_mk\"] Array.mk\n\n/- The parameter `c` is the initial capacity -/\n@[extern \"lean_mk_empty_array_with_capacity\"]\ndef Array.mkEmpty {\u03b1 : Type u} (c : @& Nat) : Array \u03b1 := {\n  data := List.nil\n}\n\ndef Array.empty {\u03b1 : Type u} : Array \u03b1 :=\n  mkEmpty 0\n\n@[reducible, extern \"lean_array_get_size\"]\ndef Array.size {\u03b1 : Type u} (a : @& Array \u03b1) : Nat :=\n a.data.length\n\n@[extern \"lean_array_fget\"]\ndef Array.get {\u03b1 : Type u} (a : @& Array \u03b1) (i : @& Fin a.size) : \u03b1 :=\n  a.data.get i.val i.isLt\n\n@[inline] def Array.getD (a : Array \u03b1) (i : Nat) (v\u2080 : \u03b1) : \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.get \u27e8i, h\u27e9) (fun _ => v\u2080)\n\n/- \"Comfortable\" version of `fget`. It performs a bound check at runtime. -/\n@[extern \"lean_array_get\"]\ndef Array.get! {\u03b1 : Type u} [Inhabited \u03b1] (a : @& Array \u03b1) (i : @& Nat) : \u03b1 :=\n  Array.getD a i arbitrary\n\ndef Array.getOp {\u03b1 : Type u} [Inhabited \u03b1] (self : Array \u03b1) (idx : Nat) : \u03b1 :=\n  self.get! idx\n\n@[extern \"lean_array_push\"]\ndef Array.push {\u03b1 : Type u} (a : Array \u03b1) (v : \u03b1) : Array \u03b1 := {\n  data := List.concat a.data v\n}\n\n@[extern \"lean_array_fset\"]\ndef Array.set (a : Array \u03b1) (i : @& Fin a.size) (v : \u03b1) : Array \u03b1 := {\n  data := a.data.set i.val v\n}\n\n@[inline] def Array.setD (a : Array \u03b1) (i : Nat) (v : \u03b1) : Array \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.set \u27e8i, h\u27e9 v) (fun _ => a)\n\n@[extern \"lean_array_set\"]\ndef Array.set! (a : Array \u03b1) (i : @& Nat) (v : \u03b1) : Array \u03b1 :=\n  Array.setD a i v\n\n-- Slower `Array.append` used in quotations.\nprotected def Array.appendCore {\u03b1 : Type u}  (as : Array \u03b1) (bs : Array \u03b1) : Array \u03b1 :=\n  let rec loop (i : Nat) (j : Nat) (as : Array \u03b1) : Array \u03b1 :=\n    dite (LT.lt j bs.size)\n      (fun hlt =>\n        match i with\n        | 0           => as\n        | Nat.succ i' => loop i' (hAdd j 1) (as.push (bs.get \u27e8j, hlt\u27e9)))\n      (fun _ => as)\n  loop bs.size 0 as\n\n@[inlineIfReduce]\ndef List.toArrayAux : List \u03b1 \u2192 Array \u03b1 \u2192 Array \u03b1\n  | nil,       r => r\n  | cons a as, r => toArrayAux as (r.push a)\n\n@[inlineIfReduce]\ndef List.redLength : List \u03b1 \u2192 Nat\n  | nil       => 0\n  | cons _ as => as.redLength.succ\n\n@[inline, matchPattern, export lean_list_to_array]\ndef List.toArray (as : List \u03b1) : Array \u03b1 :=\n  as.toArrayAux (Array.mkEmpty as.redLength)\n\nclass Bind (m : Type u \u2192 Type v) where\n  bind : {\u03b1 \u03b2 : Type u} \u2192 m \u03b1 \u2192 (\u03b1 \u2192 m \u03b2) \u2192 m \u03b2\n\nexport Bind (bind)\n\nclass Pure (f : Type u \u2192 Type v) where\n  pure {\u03b1 : Type u} : \u03b1 \u2192 f \u03b1\n\nexport Pure (pure)\n\nclass Functor (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  map      : {\u03b1 \u03b2 : Type u} \u2192 (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n  mapConst : {\u03b1 \u03b2 : Type u} \u2192 \u03b1 \u2192 f \u03b2 \u2192 f \u03b1 := Function.comp map (Function.const _)\n\nclass Seq (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seq  : {\u03b1 \u03b2 : Type u} \u2192 f (\u03b1 \u2192 \u03b2) \u2192 (Unit \u2192 f \u03b1) \u2192 f \u03b2\n\nclass SeqLeft (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seqLeft : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 (Unit \u2192 f \u03b2) \u2192 f \u03b1\n\nclass SeqRight (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  seqRight : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 (Unit \u2192 f \u03b2) \u2192 f \u03b2\n\nclass Applicative (f : Type u \u2192 Type v) extends Functor f, Pure f, Seq f, SeqLeft f, SeqRight f where\n  map      := fun x y => Seq.seq (pure x) fun _ => y\n  seqLeft  := fun a b => Seq.seq (Functor.map (Function.const _) a) b\n  seqRight := fun a b => Seq.seq (Functor.map (Function.const _ id) a) b\n\nclass Monad (m : Type u \u2192 Type v) extends Applicative m, Bind m : Type (max (u+1) v) where\n  map      f x := bind x (Function.comp pure f)\n  seq      f x := bind f fun y => Functor.map y (x ())\n  seqLeft  x y := bind x fun a => bind (y ()) (fun _ => pure a)\n  seqRight x y := bind x fun _ => y ()\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] : Inhabited (\u03b1 \u2192 m \u03b1) where\n  default := pure\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] [Inhabited \u03b1] : Inhabited (m \u03b1) where\n  default := pure arbitrary\n\n-- A fusion of Haskell's `sequence` and `map`\ndef Array.sequenceMap {\u03b1 : Type u} {\u03b2 : Type v} {m : Type v \u2192 Type w} [Monad m] (as : Array \u03b1) (f : \u03b1 \u2192 m \u03b2) : m (Array \u03b2) :=\n  let rec loop (i : Nat) (j : Nat) (bs : Array \u03b2) : m (Array \u03b2) :=\n    dite (LT.lt j as.size)\n      (fun hlt =>\n        match i with\n        | 0           => pure bs\n        | Nat.succ i' => Bind.bind (f (as.get \u27e8j, hlt\u27e9)) fun b => loop i' (hAdd j 1) (bs.push b))\n      (fun _ => bs)\n  loop as.size 0 Array.empty\n\n/-- A Function for lifting a computation from an inner Monad to an outer Monad.\n    Like [MonadTrans](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Class.html),\n    but `n` does not have to be a monad transformer.\n    Alternatively, an implementation of [MonadLayer](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLayer) without `layerInvmap` (so far). -/\nclass MonadLift (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadLift`.\n    `monadLift` is used to transitively lift monadic computations such as `StateT.get` or `StateT.put s`.\n    Corresponds to [MonadLift](https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLift). -/\nclass MonadLiftT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\nexport MonadLiftT (monadLift)\n\nabbrev liftM := @monadLift\n\ninstance (m n o) [MonadLift n o] [MonadLiftT m n] : MonadLiftT m o where\n  monadLift x := MonadLift.monadLift (m := n) (monadLift x)\n\ninstance (m) : MonadLiftT m m where\n  monadLift x := x\n\n/-- A functor in the category of monads. Can be used to lift monad-transforming functions.\n    Based on pipes' [MFunctor](https://hackage.haskell.org/package/pipes-2.4.0/docs/Control-MFunctor.html),\n    but not restricted to monad transformers.\n    Alternatively, an implementation of [MonadTransFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadTransFunctor). -/\nclass MonadFunctor (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadFunctor`.\n    `monadMap` is used to transitively lift Monad morphisms -/\nclass MonadFunctorT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\nexport MonadFunctorT (monadMap)\n\ninstance (m n o) [MonadFunctor n o] [MonadFunctorT m n] : MonadFunctorT m o where\n  monadMap f := MonadFunctor.monadMap (m := n) (monadMap (m := m) f)\n\ninstance monadFunctorRefl (m) : MonadFunctorT m m where\n  monadMap f := f\n\ninductive Except (\u03b5 : Type u) (\u03b1 : Type v) where\n  | error : \u03b5 \u2192 Except \u03b5 \u03b1\n  | ok    : \u03b1 \u2192 Except \u03b5 \u03b1\n\nattribute [unbox] Except\n\ninstance {\u03b5 : Type u} {\u03b1 : Type v} [Inhabited \u03b5] : Inhabited (Except \u03b5 \u03b1) where\n  default := Except.error arbitrary\n\n/-- An implementation of [MonadError](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Except.html#t:MonadError) -/\nclass MonadExceptOf (\u03b5 : Type u) (m : Type v \u2192 Type w) where\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\nabbrev throwThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (e : \u03b5) : m \u03b1 :=\n  MonadExceptOf.throw e\n\nabbrev tryCatchThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (x : m \u03b1) (handle : \u03b5 \u2192 m \u03b1) : m \u03b1 :=\n  MonadExceptOf.tryCatch x handle\n\n/-- Similar to `MonadExceptOf`, but `\u03b5` is an outParam for convenience -/\nclass MonadExcept (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) where\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\nexport MonadExcept (throw tryCatch)\n\ninstance (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) [MonadExceptOf \u03b5 m] : MonadExcept \u03b5 m where\n  throw    := throwThe \u03b5\n  tryCatch := tryCatchThe \u03b5\n\nnamespace MonadExcept\nvariable {\u03b5 : Type u} {m : Type v \u2192 Type w}\n\n@[inline] protected def orElse [MonadExcept \u03b5 m] {\u03b1 : Type v} (t\u2081 : m \u03b1) (t\u2082 : Unit \u2192 m \u03b1) : m \u03b1 :=\n  tryCatch t\u2081 fun _ => t\u2082 ()\n\ninstance [MonadExcept \u03b5 m] {\u03b1 : Type v} : OrElse (m \u03b1) where\n  orElse := MonadExcept.orElse\n\nend MonadExcept\n\n/-- An implementation of [ReaderT](https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Reader.html#t:ReaderT) -/\ndef ReaderT (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) : Type (max u v) :=\n  \u03c1 \u2192 m \u03b1\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) [Inhabited (m \u03b1)] : Inhabited (ReaderT \u03c1 m \u03b1) where\n  default := fun _ => arbitrary\n\n@[inline] def ReaderT.run {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u} (x : ReaderT \u03c1 m \u03b1) (r : \u03c1) : m \u03b1 :=\n  x r\n\nnamespace ReaderT\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u}\n\ninstance  : MonadLift m (ReaderT \u03c1 m) where\n  monadLift x := fun _ => x\n\ninstance (\u03b5) [MonadExceptOf \u03b5 m] : MonadExceptOf \u03b5 (ReaderT \u03c1 m) where\n  throw e  := liftM (m := m) (throw e)\n  tryCatch := fun x c r => tryCatchThe \u03b5 (x r) (fun e => (c e) r)\n\nend\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] {\u03b1 \u03b2 : Type u}\n\n@[inline] protected def read : ReaderT \u03c1 m \u03c1 :=\n  pure\n\n@[inline] protected def pure (a : \u03b1) : ReaderT \u03c1 m \u03b1 :=\n  fun r => pure a\n\n@[inline] protected def bind (x : ReaderT \u03c1 m \u03b1) (f : \u03b1 \u2192 ReaderT \u03c1 m \u03b2) : ReaderT \u03c1 m \u03b2 :=\n  fun r => bind (x r) fun a => f a r\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : ReaderT \u03c1 m \u03b1) : ReaderT \u03c1 m \u03b2 :=\n  fun r => Functor.map f (x r)\n\ninstance : Monad (ReaderT \u03c1 m) where\n  pure := ReaderT.pure\n  bind := ReaderT.bind\n  map  := ReaderT.map\n\ninstance (\u03c1 m) [Monad m] : MonadFunctor m (ReaderT \u03c1 m) where\n  monadMap f x := fun ctx => f (x ctx)\n\n@[inline] protected def adapt {\u03c1' : Type u} [Monad m] {\u03b1 : Type u} (f : \u03c1' \u2192 \u03c1) : ReaderT \u03c1 m \u03b1 \u2192 ReaderT \u03c1' m \u03b1 :=\n  fun x r => x (f r)\n\nend\nend ReaderT\n\n/-- An implementation of [MonadReader](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Reader-Class.html#t:MonadReader).\n    It does not contain `local` because this Function cannot be lifted using `monadLift`.\n    Instead, the `MonadReaderAdapter` class provides the more general `adaptReader` Function.\n\n    Note: This class can be seen as a simplification of the more \"principled\" definition\n    ```\n    class MonadReader (\u03c1 : outParam (Type u)) (n : Type u \u2192 Type u) where\n      lift {\u03b1 : Type u} : ({m : Type u \u2192 Type u} \u2192 [Monad m] \u2192 ReaderT \u03c1 m \u03b1) \u2192 n \u03b1\n    ```\n    -/\nclass MonadReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  read : m \u03c1\n\n@[inline] def readThe (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadReaderOf \u03c1 m] : m \u03c1 :=\n  MonadReaderOf.read\n\n/-- Similar to `MonadReaderOf`, but `\u03c1` is an outParam for convenience -/\nclass MonadReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  read : m \u03c1\n\nexport MonadReader (read)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadReaderOf \u03c1 m] : MonadReader \u03c1 m where\n  read := readThe \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadReaderOf \u03c1 m] : MonadReaderOf \u03c1 n where\n  read := liftM (m := m) read\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadReaderOf \u03c1 (ReaderT \u03c1 m) where\n  read := ReaderT.read\n\nclass MonadWithReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\n@[inline] def withTheReader (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadWithReaderOf \u03c1 m] {\u03b1 : Type u} (f : \u03c1 \u2192 \u03c1) (x : m \u03b1) : m \u03b1 :=\n  MonadWithReaderOf.withReader f x\n\nclass MonadWithReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadWithReader (withReader)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadWithReaderOf \u03c1 m] : MonadWithReader \u03c1 m where\n  withReader := withTheReader \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type v} [MonadFunctor m n] [MonadWithReaderOf \u03c1 m] : MonadWithReaderOf \u03c1 n where\n  withReader f := monadMap (m := m) (withTheReader \u03c1 f)\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadWithReaderOf \u03c1 (ReaderT \u03c1 m) where\n  withReader f x := fun ctx => x (f ctx)\n\n/-- An implementation of [MonadState](https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-State-Class.html).\n    In contrast to the Haskell implementation, we use overlapping instances to derive instances\n    automatically from `monadLift`. -/\nclass MonadStateOf (\u03c3 : Type u) (m : Type u \u2192 Type v) where\n  /- Obtain the top-most State of a Monad stack. -/\n  get : m \u03c3\n  /- Set the top-most State of a Monad stack. -/\n  set : \u03c3 \u2192 m PUnit\n  /- Map the top-most State of a Monad stack.\n\n     Note: `modifyGet f` may be preferable to `do s <- get; let (a, s) := f s; put s; pure a`\n     because the latter does not use the State linearly (without sufficient inlining). -/\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadStateOf (set)\n\nabbrev getThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] : m \u03c3 :=\n  MonadStateOf.get\n\n@[inline] abbrev modifyThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  MonadStateOf.modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] abbrev modifyGetThe {\u03b1 : Type u} (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : m \u03b1 :=\n  MonadStateOf.modifyGet f\n\n/-- Similar to `MonadStateOf`, but `\u03c3` is an outParam for convenience -/\nclass MonadState (\u03c3 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  get : m \u03c3\n  set : \u03c3 \u2192 m PUnit\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadState (get modifyGet)\n\ninstance (\u03c3 : Type u) (m : Type u \u2192 Type v) [MonadStateOf \u03c3 m] : MonadState \u03c3 m where\n  set         := MonadStateOf.set\n  get         := getThe \u03c3\n  modifyGet f := MonadStateOf.modifyGet f\n\n@[inline] def modify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  modifyGet fun s => (PUnit.unit, f s)\n\n@[inline] def getModify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] [Monad m] (f : \u03c3 \u2192 \u03c3) : m \u03c3 :=\n  modifyGet fun s => (s, f s)\n\n-- NOTE: The Ordering of the following two instances determines that the top-most `StateT` Monad layer\n-- will be picked first\ninstance {\u03c3 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadStateOf \u03c3 m] : MonadStateOf \u03c3 n where\n  get         := liftM (m := m) MonadStateOf.get\n  set       s := liftM (m := m) (MonadStateOf.set s)\n  modifyGet f := monadLift (m := m) (MonadState.modifyGet f)\n\nnamespace EStateM\n\ninductive Result (\u03b5 \u03c3 \u03b1 : Type u) where\n  | ok    : \u03b1 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n  | error : \u03b5 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nvariable {\u03b5 \u03c3 \u03b1 : Type u}\n\ninstance [Inhabited \u03b5] [Inhabited \u03c3] : Inhabited (Result \u03b5 \u03c3 \u03b1) where\n  default := Result.error arbitrary arbitrary\n\nend EStateM\n\nopen EStateM (Result) in\ndef EStateM (\u03b5 \u03c3 \u03b1 : Type u) := \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nnamespace EStateM\n\nvariable {\u03b5 \u03c3 \u03b1 \u03b2 : Type u}\n\ninstance [Inhabited \u03b5] : Inhabited (EStateM \u03b5 \u03c3 \u03b1) where\n  default := fun s => Result.error arbitrary s\n\n@[inline] protected def pure (a : \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.ok a s\n\n@[inline] protected def set (s : \u03c3) : EStateM \u03b5 \u03c3 PUnit := fun _ =>\n  Result.ok \u27e8\u27e9 s\n\n@[inline] protected def get : EStateM \u03b5 \u03c3 \u03c3 := fun s =>\n  Result.ok s s\n\n@[inline] protected def modifyGet (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  match f s with\n  | (a, s) => Result.ok a s\n\n@[inline] protected def throw (e : \u03b5) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.error e s\n\n/-- Auxiliary instance for saving/restoring the \"backtrackable\" part of the state. -/\nclass Backtrackable (\u03b4 : outParam (Type u)) (\u03c3 : Type u) where\n  save    : \u03c3 \u2192 \u03b4\n  restore : \u03c3 \u2192 \u03b4 \u2192 \u03c3\n\n@[inline] protected def tryCatch {\u03b4} [Backtrackable \u03b4 \u03c3] {\u03b1} (x : EStateM \u03b5 \u03c3 \u03b1) (handle : \u03b5 \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s\n  match x s with\n  | Result.error e s => handle e (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] protected def orElse {\u03b4} [Backtrackable \u03b4 \u03c3] (x\u2081 : EStateM \u03b5 \u03c3 \u03b1) (x\u2082 : Unit \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s;\n  match x\u2081 s with\n  | Result.error _ s => x\u2082 () (Backtrackable.restore s d)\n  | ok               => ok\n\n@[inline] def adaptExcept {\u03b5' : Type u} (f : \u03b5 \u2192 \u03b5') (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5' \u03c3 \u03b1 := fun s =>\n  match x s with\n  | Result.error e s => Result.error (f e) s\n  | Result.ok a s    => Result.ok a s\n\n@[inline] protected def bind (x : EStateM \u03b5 \u03c3 \u03b1) (f : \u03b1 \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => f a s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def map (f : \u03b1 \u2192 \u03b2) (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => Result.ok (f a) s\n  | Result.error e s => Result.error e s\n\n@[inline] protected def seqRight (x : EStateM \u03b5 \u03c3 \u03b1) (y : Unit \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok _ s    => y () s\n  | Result.error e s => Result.error e s\n\ninstance : Monad (EStateM \u03b5 \u03c3) where\n  bind     := EStateM.bind\n  pure     := EStateM.pure\n  map      := EStateM.map\n  seqRight := EStateM.seqRight\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : OrElse (EStateM \u03b5 \u03c3 \u03b1) where\n  orElse := EStateM.orElse\n\ninstance : MonadStateOf \u03c3 (EStateM \u03b5 \u03c3) where\n  set       := EStateM.set\n  get       := EStateM.get\n  modifyGet := EStateM.modifyGet\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : MonadExceptOf \u03b5 (EStateM \u03b5 \u03c3) where\n  throw    := EStateM.throw\n  tryCatch := EStateM.tryCatch\n\n@[inline] def run (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Result \u03b5 \u03c3 \u03b1 :=\n  x s\n\n@[inline] def run' (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Option \u03b1 :=\n  match run x s with\n  | Result.ok v _   => some v\n  | Result.error .. => none\n\n@[inline] def dummySave : \u03c3 \u2192 PUnit := fun _ => \u27e8\u27e9\n\n@[inline] def dummyRestore : \u03c3 \u2192 PUnit \u2192 \u03c3 := fun s _ => s\n\n/- Dummy default instance -/\ninstance nonBacktrackable : Backtrackable PUnit \u03c3 where\n  save    := dummySave\n  restore := dummyRestore\n\nend EStateM\n\nclass Hashable (\u03b1 : Sort u) where\n  hash : \u03b1 \u2192 UInt64\n\nexport Hashable (hash)\n\n@[extern c inline \"(size_t)#1\"]\nconstant UInt64.toUSize (u : UInt64) : USize\n\n@[extern c inline \"(uint64_t)#1\"]\nconstant USize.toUInt64 (u : USize) : UInt64\n\n@[extern \"lean_uint64_mix_hash\"]\nconstant mixHash (u\u2081 u\u2082 : UInt64) : UInt64\n\n@[extern \"lean_string_hash\"]\nprotected constant String.hash (s : @& String) : UInt64\n\ninstance : Hashable String where\n  hash := String.hash\n\nnamespace Lean\n\n/- Hierarchical names -/\ninductive Name where\n  | anonymous : Name\n  | str : Name \u2192 String \u2192 UInt64 \u2192 Name\n  | num : Name \u2192 Nat \u2192 UInt64 \u2192 Name\n\ninstance : Inhabited Name where\n  default := Name.anonymous\n\nprotected def Name.hash : Name \u2192 UInt64\n  | Name.anonymous => UInt64.ofNatCore 1723 (by decide)\n  | Name.str p s h => h\n  | Name.num p v h => h\n\ninstance : Hashable Name where\n  hash := Name.hash\n\nnamespace Name\n\n@[export lean_name_mk_string]\ndef mkStr (p : Name) (s : String) : Name :=\n  Name.str p s (mixHash (hash p) (hash s))\n\n@[export lean_name_mk_numeral]\ndef mkNum (p : Name) (v : Nat) : Name :=\n  Name.num p v (mixHash (hash p) (dite (LT.lt v UInt64.size) (fun h => UInt64.ofNatCore v h) (fun _ => UInt64.ofNatCore 17 (by decide))))\n\ndef mkSimple (s : String) : Name :=\n  mkStr Name.anonymous s\n\n@[extern \"lean_name_eq\"]\nprotected def beq : (@& Name) \u2192 (@& Name) \u2192 Bool\n  | anonymous,   anonymous   => true\n  | str p\u2081 s\u2081 _, str p\u2082 s\u2082 _ => and (BEq.beq s\u2081 s\u2082) (Name.beq p\u2081 p\u2082)\n  | num p\u2081 n\u2081 _, num p\u2082 n\u2082 _ => and (BEq.beq n\u2081 n\u2082) (Name.beq p\u2081 p\u2082)\n  | _,           _           => false\n\ninstance : BEq Name where\n  beq := Name.beq\n\nprotected def append : Name \u2192 Name \u2192 Name\n  | n, anonymous => n\n  | n, str p s _ => Name.mkStr (Name.append n p) s\n  | n, num p d _ => Name.mkNum (Name.append n p) d\n\ninstance : Append Name where\n  append := Name.append\n\nend Name\n\n/- Syntax -/\n\n/-- Source information of tokens. -/\ninductive SourceInfo where\n  /-\n    Token from original input with whitespace and position information.\n    `leading` will be inferred after parsing by `Syntax.updateLeading`. During parsing,\n    it is not at all clear what the preceding token was, especially with backtracking. -/\n  | original (leading : Substring) (pos : String.Pos) (trailing : Substring) (endPos : String.Pos)\n  /-\n    Synthesized token (e.g. from a quotation) annotated with a span from the original source.\n    In the delaborator, we \"misuse\" this constructor to store synthetic positions identifying\n    subterms. -/\n  | synthetic (pos : String.Pos) (endPos : String.Pos)\n  /- Synthesized token without position information. -/\n  | protected none\n\ninstance : Inhabited SourceInfo := \u27e8SourceInfo.none\u27e9\n\nnamespace SourceInfo\n\ndef getPos? (info : SourceInfo) (originalOnly := false) : Option String.Pos :=\n  match info, originalOnly with\n  | original (pos := pos) ..,  _     => some pos\n  | synthetic (pos := pos) .., false => some pos\n  | _,                         _     => none\n\nend SourceInfo\n\nabbrev SyntaxNodeKind := Name\n\n/- Syntax AST -/\n\ninductive Syntax where\n  | missing : Syntax\n  | node   (kind : SyntaxNodeKind) (args : Array Syntax) : Syntax\n  | atom   (info : SourceInfo) (val : String) : Syntax\n  | ident  (info : SourceInfo) (rawVal : Substring) (val : Name) (preresolved : List (Prod Name (List String))) : Syntax\n\ninstance : Inhabited Syntax where\n  default := Syntax.missing\n\n/- Builtin kinds -/\ndef choiceKind : SyntaxNodeKind := `choice\ndef nullKind : SyntaxNodeKind := `null\ndef groupKind : SyntaxNodeKind := `group\ndef identKind : SyntaxNodeKind := `ident\ndef strLitKind : SyntaxNodeKind := `strLit\ndef charLitKind : SyntaxNodeKind := `charLit\ndef numLitKind : SyntaxNodeKind := `numLit\ndef scientificLitKind : SyntaxNodeKind := `scientificLit\ndef nameLitKind : SyntaxNodeKind := `nameLit\ndef fieldIdxKind : SyntaxNodeKind := `fieldIdx\ndef interpolatedStrLitKind : SyntaxNodeKind := `interpolatedStrLitKind\ndef interpolatedStrKind : SyntaxNodeKind := `interpolatedStrKind\n\nnamespace Syntax\n\ndef getKind (stx : Syntax) : SyntaxNodeKind :=\n  match stx with\n  | Syntax.node k args => k\n  -- We use these \"pseudo kinds\" for antiquotation kinds.\n  -- For example, an antiquotation `$id:ident` (using Lean.Parser.Term.ident)\n  -- is compiled to ``if stx.isOfKind `ident ...``\n  | Syntax.missing     => `missing\n  | Syntax.atom _ v    => Name.mkSimple v\n  | Syntax.ident ..    => identKind\n\ndef setKind (stx : Syntax) (k : SyntaxNodeKind) : Syntax :=\n  match stx with\n  | Syntax.node _ args => Syntax.node k args\n  | _                  => stx\n\ndef isOfKind (stx : Syntax) (k : SyntaxNodeKind) : Bool :=\n  beq stx.getKind k\n\ndef getArg (stx : Syntax) (i : Nat) : Syntax :=\n  match stx with\n  | Syntax.node _ args => args.getD i Syntax.missing\n  | _                  => Syntax.missing\n\n-- Add `stx[i]` as sugar for `stx.getArg i`\n@[inline] def getOp (self : Syntax) (idx : Nat) : Syntax :=\n  self.getArg idx\n\ndef getArgs (stx : Syntax) : Array Syntax :=\n  match stx with\n  | Syntax.node _ args => args\n  | _                  => Array.empty\n\ndef getNumArgs (stx : Syntax) : Nat :=\n  match stx with\n  | Syntax.node _ args => args.size\n  | _                  => 0\n\ndef isMissing : Syntax \u2192 Bool\n  | Syntax.missing => true\n  | _ => false\n\ndef isNodeOf (stx : Syntax) (k : SyntaxNodeKind) (n : Nat) : Bool :=\n  and (stx.isOfKind k) (beq stx.getNumArgs n)\n\ndef isIdent : Syntax \u2192 Bool\n  | ident _ _ _ _ => true\n  | _             => false\n\ndef getId : Syntax \u2192 Name\n  | ident _ _ val _ => val\n  | _               => Name.anonymous\n\ndef matchesNull (stx : Syntax) (n : Nat) : Bool :=\n  isNodeOf stx nullKind n\n\ndef matchesIdent (stx : Syntax) (id : Name) : Bool :=\n  and stx.isIdent (beq stx.getId id)\n\ndef setArgs (stx : Syntax) (args : Array Syntax) : Syntax :=\n  match stx with\n  | node k _ => node k args\n  | stx      => stx\n\ndef setArg (stx : Syntax) (i : Nat) (arg : Syntax) : Syntax :=\n  match stx with\n  | node k args => node k (args.setD i arg)\n  | stx         => stx\n\n/-- Retrieve the left-most leaf's info in the Syntax tree. -/\npartial def getHeadInfo? : Syntax \u2192 Option SourceInfo\n  | atom info _   => some info\n  | ident info .. => some info\n  | node _ args   =>\n    let rec loop (i : Nat) : Option SourceInfo :=\n      match decide (LT.lt i args.size) with\n      | true => match getHeadInfo? (args.get! i) with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | _             => none\n\n/-- Retrieve the left-most leaf's info in the Syntax tree, or `none` if there is no token. -/\npartial def getHeadInfo (stx : Syntax) : SourceInfo :=\n  match stx.getHeadInfo? with\n  | some info => info\n  | none      => SourceInfo.none\n\ndef getPos? (stx : Syntax) (originalOnly := false) : Option String.Pos :=\n  stx.getHeadInfo.getPos? originalOnly\n\npartial def getTailPos? (stx : Syntax) (originalOnly := false) : Option String.Pos :=\n  match stx, originalOnly with\n  | atom (SourceInfo.original (endPos := pos) ..) ..,    _    => some pos\n  | atom (SourceInfo.synthetic (endPos := pos) ..) _,  false  => some pos\n  | ident (SourceInfo.original (endPos := pos) ..) .., _      => some pos\n  | ident (SourceInfo.synthetic (endPos := pos) ..) .., false => some pos\n  | node _ args,                                        _     =>\n    let rec loop (i : Nat) : Option String.Pos :=\n      match decide (LT.lt i args.size) with\n      | true => match getTailPos? (args.get! ((args.size.sub i).sub 1)) originalOnly with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | _, _ => none\n\n/--\n  An array of syntax elements interspersed with separators. Can be coerced to/from `Array Syntax` to automatically\n  remove/insert the separators. -/\nstructure SepArray (sep : String) where\n  elemsAndSeps : Array Syntax\n\nend Syntax\n\ndef SourceInfo.fromRef (ref : Syntax) : SourceInfo :=\n  match ref.getPos?, ref.getTailPos? with\n  | some pos, some tailPos => SourceInfo.synthetic pos tailPos\n  | _,        _            => SourceInfo.none\n\ndef mkAtom (val : String) : Syntax :=\n  Syntax.atom SourceInfo.none val\n\ndef mkAtomFrom (src : Syntax) (val : String) : Syntax :=\n  Syntax.atom (SourceInfo.fromRef src) val\n\n/- Parser descriptions -/\n\ninductive ParserDescr where\n  | const  (name : Name)\n  | unary  (name : Name) (p : ParserDescr)\n  | binary (name : Name) (p\u2081 p\u2082 : ParserDescr)\n  | node (kind : SyntaxNodeKind) (prec : Nat) (p : ParserDescr)\n  | trailingNode (kind : SyntaxNodeKind) (prec lhsPrec : Nat) (p : ParserDescr)\n  | symbol (val : String)\n  | nonReservedSymbol (val : String) (includeIdent : Bool)\n  | cat (catName : Name) (rbp : Nat)\n  | parser (declName : Name)\n  | nodeWithAntiquot (name : String) (kind : SyntaxNodeKind) (p : ParserDescr)\n  | sepBy  (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n  | sepBy1 (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n\ninstance : Inhabited ParserDescr where\n  default := ParserDescr.symbol \"\"\n\nabbrev TrailingParserDescr := ParserDescr\n\n/-\nRuntime support for making quotation terms auto-hygienic, by mangling identifiers\nintroduced by them with a \"macro scope\" supplied by the context. Details to appear in a\npaper soon.\n-/\n\nabbrev MacroScope := Nat\n/-- Macro scope used internally. It is not available for our frontend. -/\ndef reservedMacroScope := 0\n/-- First macro scope available for our frontend -/\ndef firstFrontendMacroScope := hAdd reservedMacroScope 1\n\nclass MonadRef (m : Type \u2192 Type) where\n  getRef      : m Syntax\n  withRef {\u03b1} : Syntax \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadRef (getRef)\n\ninstance (m n : Type \u2192 Type) [MonadLift m n] [MonadFunctor m n] [MonadRef m] : MonadRef n where\n  getRef        := liftM (getRef : m _)\n  withRef ref x := monadMap (m := m) (MonadRef.withRef ref) x\n\ndef replaceRef (ref : Syntax) (oldRef : Syntax) : Syntax :=\n  match ref.getPos? with\n  | some _ => ref\n  | _      => oldRef\n\n@[inline] def withRef {m : Type \u2192 Type} [Monad m] [MonadRef m] {\u03b1} (ref : Syntax) (x : m \u03b1) : m \u03b1 :=\n  bind getRef fun oldRef =>\n  let ref := replaceRef ref oldRef\n  MonadRef.withRef ref x\n\n/-- A monad that supports syntax quotations. Syntax quotations (in term\n    position) are monadic values that when executed retrieve the current \"macro\n    scope\" from the monad and apply it to every identifier they introduce\n    (independent of whether this identifier turns out to be a reference to an\n    existing declaration, or an actually fresh binding during further\n    elaboration). We also apply the position of the result of `getRef` to each\n    introduced symbol, which results in better error positions than not applying\n    any position. -/\nclass MonadQuotation (m : Type \u2192 Type) extends MonadRef m where\n  -- Get the fresh scope of the current macro invocation\n  getCurrMacroScope : m MacroScope\n  getMainModule     : m Name\n  /- Execute action in a new macro invocation context. This transformer should be\n     used at all places that morally qualify as the beginning of a \"macro call\",\n     e.g. `elabCommand` and `elabTerm` in the case of the elaborator. However, it\n     can also be used internally inside a \"macro\" if identifiers introduced by\n     e.g. different recursive calls should be independent and not collide. While\n     returning an intermediate syntax tree that will recursively be expanded by\n     the elaborator can be used for the same effect, doing direct recursion inside\n     the macro guarded by this transformer is often easier because one is not\n     restricted to passing a single syntax tree. Modelling this helper as a\n     transformer and not just a monadic action ensures that the current macro\n     scope before the recursive call is restored after it, as expected. -/\n  withFreshMacroScope {\u03b1 : Type} : m \u03b1 \u2192 m \u03b1\n\nexport MonadQuotation (getCurrMacroScope getMainModule withFreshMacroScope)\n\ndef MonadRef.mkInfoFromRefPos [Monad m] [MonadRef m] : m SourceInfo := do\n  SourceInfo.fromRef (\u2190 getRef)\n\ninstance {m n : Type \u2192 Type} [MonadFunctor m n] [MonadLift m n] [MonadQuotation m] : MonadQuotation n where\n  getCurrMacroScope   := liftM (m := m) getCurrMacroScope\n  getMainModule       := liftM (m := m) getMainModule\n  withFreshMacroScope := monadMap (m := m) withFreshMacroScope\n\n/-\nWe represent a name with macro scopes as\n```\n<actual name>._@.(<module_name>.<scopes>)*.<module_name>._hyg.<scopes>\n```\nExample: suppose the module name is `Init.Data.List.Basic`, and name is `foo.bla`, and macroscopes [2, 5]\n```\nfoo.bla._@.Init.Data.List.Basic._hyg.2.5\n```\n\nWe may have to combine scopes from different files/modules.\nThe main modules being processed is always the right most one.\nThis situation may happen when we execute a macro generated in\nan imported file in the current file.\n```\nfoo.bla._@.Init.Data.List.Basic.2.1.Init.Lean.Expr_hyg.4\n```\n\nThe delimiter `_hyg` is used just to improve the `hasMacroScopes` performance.\n-/\n\ndef Name.hasMacroScopes : Name \u2192 Bool\n  | str _ s _   => beq s \"_hyg\"\n  | num p _   _ => hasMacroScopes p\n  | _           => false\n\nprivate def eraseMacroScopesAux : Name \u2192 Name\n  | Name.str p s _   => match beq s \"_@\" with\n    | true  => p\n    | false => eraseMacroScopesAux p\n  | Name.num p _ _   => eraseMacroScopesAux p\n  | Name.anonymous   => Name.anonymous\n\n@[export lean_erase_macro_scopes]\ndef Name.eraseMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => eraseMacroScopesAux n\n  | false => n\n\nprivate def simpMacroScopesAux : Name \u2192 Name\n  | Name.num p i _ => Name.mkNum (simpMacroScopesAux p) i\n  | n              => eraseMacroScopesAux n\n\n/- Helper function we use to create binder names that do not need to be unique. -/\n@[export lean_simp_macro_scopes]\ndef Name.simpMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => simpMacroScopesAux n\n  | false => n\n\nstructure MacroScopesView where\n  name       : Name\n  imported   : Name\n  mainModule : Name\n  scopes     : List MacroScope\n\ninstance : Inhabited MacroScopesView where\n  default := \u27e8arbitrary, arbitrary, arbitrary, arbitrary\u27e9\n\ndef MacroScopesView.review (view : MacroScopesView) : Name :=\n  match view.scopes with\n  | List.nil      => view.name\n  | List.cons _ _ =>\n    let base := (Name.mkStr (hAppend (hAppend (Name.mkStr view.name \"_@\") view.imported) view.mainModule) \"_hyg\")\n    view.scopes.foldl Name.mkNum base\n\nprivate def assembleParts : List Name \u2192 Name \u2192 Name\n  | List.nil,                      acc => acc\n  | List.cons (Name.str _ s _) ps, acc => assembleParts ps (Name.mkStr acc s)\n  | List.cons (Name.num _ n _) ps, acc => assembleParts ps (Name.mkNum acc n)\n  | _,                             acc => panic \"Error: unreachable @ assembleParts\"\n\nprivate def extractImported (scps : List MacroScope) (mainModule : Name) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := mainModule, imported := assembleParts parts Name.anonymous, scopes := scps }\n    | false => extractImported scps mainModule p (List.cons n parts)\n  | n@(Name.num p str _), parts => extractImported scps mainModule p (List.cons n parts)\n  | _,                    _     => panic \"Error: unreachable @ extractImported\"\n\nprivate def extractMainModule (scps : List MacroScope) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str _), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := assembleParts parts Name.anonymous, imported := Name.anonymous, scopes := scps }\n    | false => extractMainModule scps p (List.cons n parts)\n  | n@(Name.num p num _), acc => extractImported scps (assembleParts acc Name.anonymous) n List.nil\n  | _,                    _   => panic \"Error: unreachable @ extractMainModule\"\n\nprivate def extractMacroScopesAux : Name \u2192 List MacroScope \u2192 MacroScopesView\n  | Name.num p scp _, acc => extractMacroScopesAux p (List.cons scp acc)\n  | Name.str p str _, acc => extractMainModule acc p List.nil -- str must be \"_hyg\"\n  | _,                _   => panic \"Error: unreachable @ extractMacroScopesAux\"\n\n/--\n  Revert all `addMacroScope` calls. `v = extractMacroScopes n \u2192 n = v.review`.\n  This operation is useful for analyzing/transforming the original identifiers, then adding back\n  the scopes (via `MacroScopesView.review`). -/\ndef extractMacroScopes (n : Name) : MacroScopesView :=\n  match n.hasMacroScopes with\n  | true  => extractMacroScopesAux n List.nil\n  | false => { name := n, scopes := List.nil, imported := Name.anonymous, mainModule := Name.anonymous }\n\ndef addMacroScope (mainModule : Name) (n : Name) (scp : MacroScope) : Name :=\n  match n.hasMacroScopes with\n  | true =>\n    let view := extractMacroScopes n\n    match beq view.mainModule mainModule with\n    | true  => Name.mkNum n scp\n    | false =>\n      { view with\n        imported   := view.scopes.foldl Name.mkNum (hAppend view.imported view.mainModule)\n        mainModule := mainModule\n        scopes     := List.cons scp List.nil\n      }.review\n  | false =>\n    Name.mkNum (Name.mkStr (hAppend (Name.mkStr n \"_@\") mainModule) \"_hyg\") scp\n\n@[inline] def MonadQuotation.addMacroScope {m : Type \u2192 Type} [MonadQuotation m] [Monad m] (n : Name) : m Name :=\n  bind getMainModule     fun mainModule =>\n  bind getCurrMacroScope fun scp =>\n  pure (Lean.addMacroScope mainModule n scp)\n\ndef defaultMaxRecDepth := 512\n\ndef maxRecDepthErrorMessage : String :=\n  \"maximum recursion depth has been reached (use `set_option maxRecDepth <num>` to increase limit)\"\n\nnamespace Macro\n\n/- References -/\nprivate constant MethodsRefPointed : PointedType.{0}\n\nprivate def MethodsRef : Type := MethodsRefPointed.type\n\nstructure Context where\n  methods        : MethodsRef\n  mainModule     : Name\n  currMacroScope : MacroScope\n  currRecDepth   : Nat := 0\n  maxRecDepth    : Nat := defaultMaxRecDepth\n  ref            : Syntax\n\ninductive Exception where\n  | error             : Syntax \u2192 String \u2192 Exception\n  | unsupportedSyntax : Exception\n\nstructure State where\n  macroScope : MacroScope\n  traceMsgs  : List (Prod Name String) := List.nil\n  deriving Inhabited\n\nend Macro\n\nabbrev MacroM := ReaderT Macro.Context (EStateM Macro.Exception Macro.State)\n\nabbrev Macro := Syntax \u2192 MacroM Syntax\n\nnamespace Macro\n\ninstance : MonadRef MacroM where\n  getRef     := bind read fun ctx => pure ctx.ref\n  withRef    := fun ref x => withReader (fun ctx => { ctx with ref := ref }) x\n\ndef addMacroScope (n : Name) : MacroM Name :=\n  bind read fun ctx =>\n  pure (Lean.addMacroScope ctx.mainModule n ctx.currMacroScope)\n\ndef throwUnsupported {\u03b1} : MacroM \u03b1 :=\n  throw Exception.unsupportedSyntax\n\ndef throwError {\u03b1} (msg : String) : MacroM \u03b1 :=\n  bind getRef fun ref =>\n  throw (Exception.error ref msg)\n\ndef throwErrorAt {\u03b1} (ref : Syntax) (msg : String) : MacroM \u03b1 :=\n  withRef ref (throwError msg)\n\n@[inline] protected def withFreshMacroScope {\u03b1} (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind (modifyGet (fun s => (s.macroScope, { s with macroScope := hAdd s.macroScope 1 }))) fun fresh =>\n  withReader (fun ctx => { ctx with currMacroScope := fresh }) x\n\n@[inline] def withIncRecDepth {\u03b1} (ref : Syntax) (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind read fun ctx =>\n  match beq ctx.currRecDepth ctx.maxRecDepth with\n  | true  => throw (Exception.error ref maxRecDepthErrorMessage)\n  | false => withReader (fun ctx => { ctx with currRecDepth := hAdd ctx.currRecDepth 1 }) x\n\ninstance : MonadQuotation MacroM where\n  getCurrMacroScope ctx := pure ctx.currMacroScope\n  getMainModule     ctx := pure ctx.mainModule\n  withFreshMacroScope   := Macro.withFreshMacroScope\n\nstructure Methods where\n  expandMacro?      : Syntax \u2192 MacroM (Option Syntax)\n  getCurrNamespace  : MacroM Name\n  hasDecl           : Name \u2192 MacroM Bool\n  resolveNamespace? : Name \u2192 MacroM (Option Name)\n  resolveGlobalName : Name \u2192 MacroM (List (Prod Name (List String)))\n  deriving Inhabited\n\nunsafe def mkMethodsImp (methods : Methods) : MethodsRef :=\n  unsafeCast methods\n\n@[implementedBy mkMethodsImp]\nconstant mkMethods (methods : Methods) : MethodsRef := MethodsRefPointed.val\n\ninstance : Inhabited MethodsRef where\n  default := mkMethods arbitrary\n\nunsafe def getMethodsImp : MacroM Methods :=\n  bind read fun ctx => pure (unsafeCast (ctx.methods))\n\n@[implementedBy getMethodsImp] constant getMethods : MacroM Methods\n\n/-- `expandMacro? stx` return `some stxNew` if `stx` is a macro, and `stxNew` is its expansion. -/\ndef expandMacro? (stx : Syntax) : MacroM (Option Syntax) := do\n  (\u2190 getMethods).expandMacro? stx\n\n/-- Return `true` if the environment contains a declaration with name `declName` -/\ndef hasDecl (declName : Name) : MacroM Bool := do\n  (\u2190 getMethods).hasDecl declName\n\ndef getCurrNamespace : MacroM Name := do\n  (\u2190 getMethods).getCurrNamespace\n\ndef resolveNamespace? (n : Name) : MacroM (Option Name) := do\n  (\u2190 getMethods).resolveNamespace? n\n\ndef resolveGlobalName (n : Name) : MacroM (List (Prod Name (List String))) := do\n  (\u2190 getMethods).resolveGlobalName n\n\ndef trace (clsName : Name) (msg : String) : MacroM Unit := do\n  modify fun s => { s with traceMsgs := List.cons (Prod.mk clsName msg) s.traceMsgs }\n\nend Macro\n\nexport Macro (expandMacro?)\n\nnamespace PrettyPrinter\n\nabbrev UnexpandM := EStateM Unit Unit\n\n/--\n  Function that tries to reverse macro expansions as a post-processing step of delaboration.\n  While less general than an arbitrary delaborator, it can be declared without importing `Lean`.\n  Used by the `[appUnexpander]` attribute. -/\n-- a `kindUnexpander` could reasonably be added later\nabbrev Unexpander := Syntax \u2192 UnexpandM Syntax\n\n-- unexpanders should not need to introduce new names\ninstance : MonadQuotation UnexpandM where\n  getRef              := pure Syntax.missing\n  withRef             := fun _ => id\n  getCurrMacroScope   := pure 0\n  getMainModule       := pure `_fakeMod\n  withFreshMacroScope := id\n\nend PrettyPrinter\n\nend Lean\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/stage0/src/Init/Prelude.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6442251064863697, "lm_q2_score": 0.7310585903489891, "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 : \u03a0 \u03b1 : type_index, Type u\n| \u22a5 := near_litter_perm\n| (\u03b1 : \u039b) := \u03a0 \u03b2 : type_index, \u03b2 < \u03b1 \u2192 struct_perm \u03b2\nusing_well_founded { dec_tac := `[assumption] }\n\nnamespace struct_perm\nsection\nvariables {\u03b1 \u03b2 : \u039b} {\u03b3 : type_index}\n\nnoncomputable! instance : \u03a0 \u03b1, inhabited (struct_perm \u03b1)\n| \u22a5 := by { unfold struct_perm, exact near_litter_perm.inhabited }\n| (\u03b1 : \u039b) := by { unfold struct_perm,\n  exact @pi.inhabited _ _ (\u03bb \u03b2, @pi.inhabited _ _ $ \u03bb _ : \u03b2 < \u2191\u03b1, inhabited \u03b2) }\nusing_well_founded { dec_tac := `[assumption] }\n\nlemma coe_def (\u03b1 : \u039b) : struct_perm \u2191\u03b1 = \u03a0 \u03b2 : type_index, \u03b2 < \u03b1 \u2192 struct_perm \u03b2 :=\nby unfold struct_perm\n\n/-- The \"identity\" equivalence between `near_litter_perm` and `struct_perm \u22a5`. -/\ndef to_bot : near_litter_perm \u2243 struct_perm \u22a5 := equiv.cast $ by unfold struct_perm\n\n/-- The \"identity\" equivalence between `struct_perm \u22a5` and `near_litter_perm`. -/\ndef of_bot : struct_perm \u22a5 \u2243 near_litter_perm := equiv.cast $ by unfold struct_perm\n\n/-- The \"identity\" equivalence between `\u03a0 \u03b2 < \u03b1, struct_perm \u03b2` and `struct_perm \u03b1`. -/\ndef to_coe : (\u03a0 \u03b2 : type_index, \u03b2 < \u03b1 \u2192 struct_perm \u03b2) \u2243 struct_perm \u03b1 :=\nequiv.cast $ by unfold struct_perm\n\n/-- The \"identity\" equivalence between `struct_perm \u03b1` and `\u03a0 \u03b2 < \u03b1, struct_perm \u03b2`. -/\ndef of_coe : struct_perm \u03b1 \u2243 \u03a0 \u03b2 : type_index, \u03b2 < \u03b1 \u2192 struct_perm \u03b2 :=\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 \u03b1 \u2243 _) := rfl\n@[simp] lemma of_coe_symm : of_coe.symm = (to_coe : _ \u2243 struct_perm \u03b1) := 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 \u03b1) : 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 \u03b1) = a := by simp [to_coe, of_coe]\n@[simp] lemma to_bot_inj {a b} : to_bot a = to_bot b \u2194 a = b := to_bot.injective.eq_iff\n@[simp] lemma of_bot_inj {a b} : of_bot a = of_bot b \u2194 a = b := of_bot.injective.eq_iff\n@[simp] lemma to_coe_inj {a b} : (to_coe a : struct_perm \u03b1) = to_coe b \u2194 a = b :=\nto_coe.injective.eq_iff\n@[simp] lemma of_coe_inj {a b : struct_perm \u03b1} : of_coe a = of_coe b \u2194 a = b :=\nof_coe.injective.eq_iff\n\nnoncomputable! instance group : \u03a0 \u03b1, group (struct_perm \u03b1)\n| \u22a5 := of_bot.group\n| (\u03b1 : \u039b) := @equiv.group _ _ of_coe $ @pi.group _ _ $ \u03bb \u03b2,\n  @pi_Prop.group _ _ $ \u03bb _ : \u03b2 < \u2191\u03b1, group \u03b2\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 \u2243* struct_perm \u22a5 :=\n{ map_mul' := \u03bb a b,\n  by { rw [show struct_perm.group \u22a5 = _, by unfold struct_perm.group], congr; simp },\n  ..to_bot }\n\n@[simp] lemma coe_to_bot_iso : \u21d1to_bot_iso = to_bot := rfl\n@[simp] lemma coe_to_bot_iso_symm : \u21d1to_bot_iso.symm = of_bot := rfl\n\n/--  The isomorphism between the product of structural permutations under `\u03b1` and `\u03b1`-structural\npermutations. This holds by definition of `struct_perm`. -/\ndef to_coe_iso (\u03b1 : \u039b) : (\u03a0 \u03b2 : type_index, \u03b2 < \u03b1 \u2192 struct_perm \u03b2) \u2243* struct_perm \u03b1 :=\n{ map_mul' := \u03bb a b,\n    by { rw [show struct_perm.group \u03b1 = _, by unfold struct_perm.group], congr; simp },\n  ..to_coe }\n\n@[simp] lemma coe_to_coe_iso (\u03b1 : \u039b) : \u21d1(to_coe_iso \u03b1) = to_coe := rfl\n@[simp] lemma coe_to_coe_iso_symm (\u03b1 : \u039b) : \u21d1(to_coe_iso \u03b1).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\u207b\u00b9 = (to_bot a)\u207b\u00b9 := to_bot_iso.map_inv _\n@[simp] lemma of_bot_inv (a) : of_bot a\u207b\u00b9 = (of_bot a)\u207b\u00b9 := to_bot_iso.symm.map_inv _\n\n@[simp] lemma to_coe_one : (to_coe 1 : struct_perm \u03b1) = 1 := (to_coe_iso \u03b1).map_one\n@[simp] lemma of_coe_one : of_coe (1 : struct_perm \u03b1) = 1 := (to_coe_iso \u03b1).symm.map_one\n@[simp] lemma to_coe_mul (a b) : (to_coe (a * b) : struct_perm \u03b1) = to_coe a * to_coe b :=\n(to_coe_iso \u03b1).map_mul _ _\n@[simp] lemma of_coe_mul (a b : struct_perm \u03b1) : of_coe (a * b) = of_coe a * of_coe b :=\n(to_coe_iso \u03b1).symm.map_mul _ _\n\nend\n\nvariables {\u03b1 \u03b2 \u03b3 : type_index}\n\n/-- Obtains the permutations on lower types induced by a structural permutation. -/\ndef lower : \u2200 {\u03b1 \u03b2 : type_index}, \u03b2 \u2264 \u03b1 \u2192 struct_perm \u03b1 \u2192* struct_perm \u03b2\n| \u22a5 \u22a5 h\u03b2 := monoid_hom.id _\n| \u22a5 (\u03b2 : \u039b) h\u03b2 := (not_coe_le_bot _ h\u03b2).elim\n| (\u03b1 : \u039b) \u03b2 h\u03b2 := if h : \u03b2 = \u03b1 then by { subst h, exact monoid_hom.id _ } else\n  { to_fun := \u03bb f, of_coe f _ $ h\u03b2.lt_of_ne h,\n  map_one' := congr_fun\u2082 of_coe_one _ _,\n  map_mul' := \u03bb _ _, congr_fun\u2082 (of_coe_mul _ _) _ _ }\n\n@[simp] lemma lower_self : lower le_rfl = monoid_hom.id (struct_perm \u03b1) :=\nby { cases \u03b1, { refl }, { exact dif_pos rfl } }\n\n/-- The near-litter permutation associated to a structural permutation. -/\ndef to_near_litter_perm : struct_perm \u03b1 \u2192* 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 \u22a5 \u2192 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 : \u03a0 {\u03b2}, path \u03b1 \u03b2 \u2192 struct_perm \u03b1 \u2192* struct_perm \u03b2\n| _ nil := monoid_hom.id _\n| \u03b3 (cons p_\u03b1\u03b3 h\u03b2\u03b3) := (lower $ le_of_lt h\u03b2\u03b3).comp $ derivative p_\u03b1\u03b3\n\n/-- The derivative along the empty path does nothing. -/\n@[simp] lemma derivative_nil (\u03c0 : struct_perm \u03b1) : derivative nil \u03c0 = \u03c0 := rfl\n\nlemma derivative_cons (\u03c0 : struct_perm \u03b1) (p : path \u03b1 \u03b2) {\u03b3 : type_index} (h : \u03b3 < \u03b2) :\n  derivative (p.cons h) \u03c0 = (derivative (path.nil.cons h)) (derivative p \u03c0) :=\nby simp only [derivative]; refl\n\n/-- The derivative map is functorial. -/\nlemma derivative_derivative (\u03c0 : struct_perm \u03b1) (p : path \u03b1 \u03b2) :\n  \u2200 {\u03b3 : type_index} (q : path \u03b2 \u03b3), derivative q (derivative p \u03c0) = derivative (p.comp q) \u03c0\n| _ nil := by simp only [derivative_nil, comp_nil]\n| \u03b3 (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 {\u03b2} (\u03c0\u2081 \u03c0\u2082 : struct_perm \u03b1) (A : path (\u03b1 : type_index) \u03b2) :\n  derivative A (\u03c0\u2081 * \u03c0\u2082) = derivative A \u03c0\u2081 * derivative A \u03c0\u2082 := 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 \u03b1) X :=\nmul_action.comp_hom _ to_near_litter_perm\n\n@[simp] lemma to_near_litter_perm_smul (f : struct_perm \u03b1) (x : X) :\n  f.to_near_litter_perm \u2022 x = f \u2022 x := rfl\n\n@[simp] lemma to_bot_smul (f : near_litter_perm) (x : X) : to_bot f \u2022 x = f \u2022 x :=\nby { change to_near_litter_perm _ \u2022 _ = _ \u2022 _, rw [coe_to_near_litter_perm, of_bot_to_bot] }\n\n@[simp] lemma of_bot_smul (f : struct_perm \u22a5) (x : X) : of_bot f \u2022 x = f \u2022 x :=\nby rw [\u2190to_bot_smul, to_bot_of_bot]\n\n@[simp] lemma to_bot_inv_smul (f : near_litter_perm) (x : X) : (to_bot f)\u207b\u00b9 \u2022 x = f\u207b\u00b9 \u2022 x :=\nby rw [inv_smul_eq_iff, to_bot_smul, smul_inv_smul]\n\n@[simp] lemma of_bot_inv_smul (f : struct_perm \u22a5) (x : X) : (of_bot f)\u207b\u00b9 \u2022 x = f\u207b\u00b9 \u2022 x :=\nby rw [inv_smul_eq_iff, of_bot_smul, smul_inv_smul]\n\n@[simp] lemma derivative_bot_smul {\u03b1 : \u039b} (f : struct_perm \u03b1) (x : X) :\n  struct_perm.derivative (nil.cons (bot_lt_coe \u03b1)) f \u2022 x = f \u2022 x := rfl\n\nlemma smul_near_litter_fst (\u03c0 : struct_perm \u03b1) (N : near_litter) : (\u03c0 \u2022 N).fst = \u03c0 \u2022 N.fst := rfl\n\nend\n\ndef proto_smul : \u03a0 \u03b1 : type_index, struct_perm \u03b1 \u2192 pretangle \u03b1 \u2192 pretangle \u03b1\n| \u22a5 := \u03bb \u03c0 t, pretangle.to_bot $ of_bot \u03c0 \u2022 t.of_bot\n| (\u03b1 : \u039b) := \u03bb \u03c0 t, pretangle.to_coe $ \u03bb \u03b2 (h\u03b2 : \u03b2 < \u03b1), proto_smul \u03b2 (of_coe \u03c0 \u03b2 h\u03b2) '' pretangle.of_coe t \u03b2 h\u03b2\nusing_well_founded { dec_tac := `[assumption] }\n\ninstance has_smul_pretangle : \u03a0 \u03b1 : type_index, has_smul (struct_perm \u03b1) (pretangle \u03b1) | \u03b1 := \u27e8proto_smul \u03b1\u27e9\n\n@[simp] lemma of_bot_smul_pretangle (\u03c0 : struct_perm \u22a5) (t : pretangle \u22a5) :\n  (\u03c0 \u2022 t).of_bot = of_bot \u03c0 \u2022 t.of_bot :=\nbegin\ndsimp [struct_perm.has_smul_pretangle],\nhave : (proto_smul \u22a5) = \u03bb \u03c0 t, pretangle.to_bot $ of_bot \u03c0 \u2022 t.of_bot,\nunfold proto_smul,\nrw this,\nsimp only [pretangle.of_bot_to_bot],\nend\n\n@[simp] lemma to_bot_smul_pretangle (\u03c0 : near_litter_perm) (t : atom) :\n   pretangle.to_bot (\u03c0 \u2022 t) = to_bot \u03c0 \u2022 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 {\u03b1 : \u039b} (\u03c0 : struct_perm \u03b1) (t : pretangle \u03b1) :\n  (\u03c0 \u2022 t).of_coe = of_coe \u03c0 \u2022 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 {\u03b1 : \u039b} (\u03c0 : \u03a0 \u03b2 : type_index, \u03b2 < \u03b1 \u2192 struct_perm \u03b2)\n  (t : \u03a0 \u03b2 : type_index, \u03b2 < \u03b1 \u2192 set (pretangle \u03b2)) :\n  pretangle.to_coe (\u03c0 \u2022 t) = to_coe \u03c0 \u2022 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 : \u2200 \u03b1 (t : pretangle \u03b1), (1 : struct_perm \u03b1) \u2022 t = t\n| \u22a5 := \u03bb t, pretangle.of_bot.injective $ by simp\n| (\u03b1 : \u039b) := \u03bb t, pretangle.of_coe.injective $\n    by { ext \u03b2 h\u03b2 : 2, simp [\u2190image_smul, one_smul \u03b2, image_id'] }\nusing_well_founded { dec_tac := `[assumption] }\n\nprotected lemma mul_smul :\n  \u2200 \u03b1 (\u03c0\u2081 \u03c0\u2082 : struct_perm \u03b1) (t : pretangle \u03b1), (\u03c0\u2081 * \u03c0\u2082) \u2022 t = \u03c0\u2081 \u2022 \u03c0\u2082 \u2022 t\n| \u22a5 := \u03bb \u03c0\u2081 \u03c0\u2082 t, pretangle.of_bot.injective $ by simp [mul_action.mul_smul]\n| (\u03b1 : \u039b) := \u03bb \u03c0\u2081 \u03c0\u2082 t, pretangle.of_coe.injective $\n    by { ext \u03b2 h\u03b2 : 2, simp only [of_coe_smul_pretangle, of_coe_mul, pi.smul_apply', pi.mul_apply,\n      pi_Prop.smul_apply', \u2190image_smul, image_image, \u2190mul_smul \u03b2], refl }\nusing_well_founded { dec_tac := `[assumption] }\n\ninstance mul_action_pretangle : mul_action (struct_perm \u03b1) (pretangle \u03b1) :=\n{ smul := (\u2022),\n  one_smul := struct_perm.one_smul _,\n  mul_smul := struct_perm.mul_smul _ }\n\nlemma derivative_cons_nil (\u03b1 : \u039b) (f : struct_perm \u03b1) (\u03b2 : type_index) (h\u03b2 : \u03b2 < \u03b1) :\n  derivative (cons nil h\u03b2) f = of_coe f \u03b2 h\u03b2 :=\nby { unfold derivative lower, rw dif_neg h\u03b2.ne, refl }\n\nlemma ext (\u03b1 : \u039b) (a b : struct_perm \u03b1)\n  (h : \u2200 (\u03b2 : type_index) (h\u03b2 : \u03b2 < \u03b1), derivative (cons nil h\u03b2) a = derivative (cons nil h\u03b2) b) :\n  a = b :=\nof_coe.injective $ by { ext \u03b2 h\u03b2, simp_rw \u2190derivative_cons_nil, exact h _ _ }\n\ninstance : has_faithful_smul (struct_perm \u22a5) atom :=\n\u27e8\u03bb f g h, of_bot.injective $ near_litter_perm.ext $ eq_of_smul_eq_smul h\u27e9\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": "import graphs.composition\n\n/-\nWe want to define the identity morphism, but that requires a compatability proof.  \nYou will need to use sym2.map_id.\n-/\n\n/- Lemma : The identity maps on vertices and edges satisfy the compatability condition.\n-/\nlemma id_compatability (G : graph) : G.endpoints \u2218 id = sym2.map id \u2218 G.endpoints :=\nbegin\n  sorry,\n\n\n\n\n  \nend\n", "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/game/morphisms-world/level3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7310585786300049, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.47096629066568896}}
{"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 {\u03b1 \u03b2 \u03b3 \u03b4 : Sort _}\n\nnamespace PProd\n\n/- warning: pprod.mk.eta -> PProd.mk.eta is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : PProd.{u1, u2} \u03b1 \u03b2}, Eq.{max 1 u1 u2} (PProd.{u1, u2} \u03b1 \u03b2) (PProd.mk.{u1, u2} \u03b1 \u03b2 (PProd.fst.{u1, u2} \u03b1 \u03b2 p) (PProd.snd.{u1, u2} \u03b1 \u03b2 p)) p\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {p : PProd.{u2, u1} \u03b1 \u03b2}, Eq.{max (max 1 u2) u1} (PProd.{u2, u1} \u03b1 \u03b2) (PProd.mk.{u2, u1} \u03b1 \u03b2 (PProd.fst.{u2, u1} \u03b1 \u03b2 p) (PProd.snd.{u2, u1} \u03b1 \u03b2 p)) p\nCase conversion may be inaccurate. Consider using '#align pprod.mk.eta PProd.mk.eta\u2093'. -/\n@[simp]\ntheorem mk.eta {p : PProd \u03b1 \u03b2} : 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : (PProd.{u1, u2} \u03b1 \u03b2) -> Prop}, Iff (forall (x : PProd.{u1, u2} \u03b1 \u03b2), p x) (forall (a : \u03b1) (b : \u03b2), p (PProd.mk.{u1, u2} \u03b1 \u03b2 a b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {p : (PProd.{u2, u1} \u03b1 \u03b2) -> Prop}, Iff (forall (x : PProd.{u2, u1} \u03b1 \u03b2), p x) (forall (a : \u03b1) (b : \u03b2), p (PProd.mk.{u2, u1} \u03b1 \u03b2 a b))\nCase conversion may be inaccurate. Consider using '#align pprod.forall PProd.forall\u2093'. -/\n@[simp]\ntheorem forall {p : PProd \u03b1 \u03b2 \u2192 Prop} : (\u2200 x, p x) \u2194 \u2200 a b, p \u27e8a, b\u27e9 :=\n  \u27e8fun h a b => h \u27e8a, b\u27e9, fun h \u27e8a, b\u27e9 => h a b\u27e9\n#align pprod.forall PProd.forall\n\n/- warning: pprod.exists -> PProd.exists is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : (PProd.{u1, u2} \u03b1 \u03b2) -> Prop}, Iff (Exists.{max 1 u1 u2} (PProd.{u1, u2} \u03b1 \u03b2) (fun (x : PProd.{u1, u2} \u03b1 \u03b2) => p x)) (Exists.{u1} \u03b1 (fun (a : \u03b1) => Exists.{u2} \u03b2 (fun (b : \u03b2) => p (PProd.mk.{u1, u2} \u03b1 \u03b2 a b))))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {p : (PProd.{u2, u1} \u03b1 \u03b2) -> Prop}, Iff (Exists.{max (max 1 u2) u1} (PProd.{u2, u1} \u03b1 \u03b2) (fun (x : PProd.{u2, u1} \u03b1 \u03b2) => p x)) (Exists.{u2} \u03b1 (fun (a : \u03b1) => Exists.{u1} \u03b2 (fun (b : \u03b2) => p (PProd.mk.{u2, u1} \u03b1 \u03b2 a b))))\nCase conversion may be inaccurate. Consider using '#align pprod.exists PProd.exists\u2093'. -/\n@[simp]\ntheorem exists {p : PProd \u03b1 \u03b2 \u2192 Prop} : (\u2203 x, p x) \u2194 \u2203 a b, p \u27e8a, b\u27e9 :=\n  \u27e8fun \u27e8\u27e8a, b\u27e9, h\u27e9 => \u27e8a, b, h\u27e9, fun \u27e8a, b, h\u27e9 => \u27e8\u27e8a, b\u27e9, h\u27e9\u27e9\n#align pprod.exists PProd.exists\n\n/- warning: pprod.forall' -> PProd.forall' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : \u03b1 -> \u03b2 -> Prop}, Iff (forall (x : PProd.{u1, u2} \u03b1 \u03b2), p (PProd.fst.{u1, u2} \u03b1 \u03b2 x) (PProd.snd.{u1, u2} \u03b1 \u03b2 x)) (forall (a : \u03b1) (b : \u03b2), p a b)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {p : \u03b1 -> \u03b2 -> Prop}, Iff (forall (x : PProd.{u2, u1} \u03b1 \u03b2), p (PProd.fst.{u2, u1} \u03b1 \u03b2 x) (PProd.snd.{u2, u1} \u03b1 \u03b2 x)) (forall (a : \u03b1) (b : \u03b2), p a b)\nCase conversion may be inaccurate. Consider using '#align pprod.forall' PProd.forall'\u2093'. -/\ntheorem forall' {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2200 x : PProd \u03b1 \u03b2, p x.1 x.2) \u2194 \u2200 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : \u03b1 -> \u03b2 -> Prop}, Iff (Exists.{max 1 u1 u2} (PProd.{u1, u2} \u03b1 \u03b2) (fun (x : PProd.{u1, u2} \u03b1 \u03b2) => p (PProd.fst.{u1, u2} \u03b1 \u03b2 x) (PProd.snd.{u1, u2} \u03b1 \u03b2 x))) (Exists.{u1} \u03b1 (fun (a : \u03b1) => Exists.{u2} \u03b2 (fun (b : \u03b2) => p a b)))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {p : \u03b1 -> \u03b2 -> Prop}, Iff (Exists.{max (max 1 u2) u1} (PProd.{u2, u1} \u03b1 \u03b2) (fun (x : PProd.{u2, u1} \u03b1 \u03b2) => p (PProd.fst.{u2, u1} \u03b1 \u03b2 x) (PProd.snd.{u2, u1} \u03b1 \u03b2 x))) (Exists.{u2} \u03b1 (fun (a : \u03b1) => Exists.{u1} \u03b2 (fun (b : \u03b2) => p a b)))\nCase conversion may be inaccurate. Consider using '#align pprod.exists' PProd.exists'\u2093'. -/\ntheorem exists' {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2203 x : PProd \u03b1 \u03b2, p x.1 x.2) \u2194 \u2203 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {\u03b4 : Sort.{u4}} {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b4}, (Function.Injective.{u1, u2} \u03b1 \u03b2 f) -> (Function.Injective.{u3, u4} \u03b3 \u03b4 g) -> (Function.Injective.{max 1 u1 u3, max 1 u2 u4} (PProd.{u1, u3} \u03b1 \u03b3) (PProd.{u2, u4} \u03b2 \u03b4) (fun (x : PProd.{u1, u3} \u03b1 \u03b3) => PProd.mk.{u2, u4} \u03b2 \u03b4 (f (PProd.fst.{u1, u3} \u03b1 \u03b3 x)) (g (PProd.snd.{u1, u3} \u03b1 \u03b3 x))))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u4}} {\u03b2 : Sort.{u3}} {\u03b3 : Sort.{u2}} {\u03b4 : Sort.{u1}} {f : \u03b1 -> \u03b2} {g : \u03b3 -> \u03b4}, (Function.Injective.{u4, u3} \u03b1 \u03b2 f) -> (Function.Injective.{u2, u1} \u03b3 \u03b4 g) -> (Function.Injective.{max (max 1 u4) u2, max (max 1 u3) u1} (PProd.{u4, u2} \u03b1 \u03b3) (PProd.{u3, u1} \u03b2 \u03b4) (fun (x : PProd.{u4, u2} \u03b1 \u03b3) => PProd.mk.{u3, u1} \u03b2 \u03b4 (f (PProd.fst.{u4, u2} \u03b1 \u03b3 x)) (g (PProd.snd.{u4, u2} \u03b1 \u03b3 x))))\nCase conversion may be inaccurate. Consider using '#align function.injective.pprod_map Function.Injective.pprod_map\u2093'. -/\ntheorem Function.Injective.pprod_map {f : \u03b1 \u2192 \u03b2} {g : \u03b3 \u2192 \u03b4} (hf : Injective f) (hg : Injective g) :\n    Injective (fun x => \u27e8f x.1, g x.2\u27e9 : PProd \u03b1 \u03b3 \u2192 PProd \u03b2 \u03b4) := fun \u27e8x\u2081, x\u2082\u27e9 \u27e8y\u2081, y\u2082\u27e9 h =>\n  have A := congr_arg PProd.fst h\n  have B := congr_arg PProd.snd h\n  congr_arg\u2082 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 {\u03c6 : Type v}\n\ndef F : Type u \u2964 Type (max v u) := \n    {\n        obj := \u03bb S, (set S) \u00d7 (set \u03c6),\n        map := \u03bb {A B} \u03d5, \u03bb \u27e8U , P\u27e9 , \u27e8image \u03d5 U, P\u27e9,\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 \u2218 f) (S, P)\n                    = \u27e8image (g \u2218 f) S, P\u27e9              : rfl\n                ... = \u27e8image g (image f S), P\u27e9          : by rw [img_comp f g S] \n                ... = F._match_1 g (F._match_1 f (S, P)) : rfl\n            end\n    } \n\ndef \u03b1 (K : Kripke \u03c6): K.State \u2192 F.obj K.State := \n        \u03bb s, \u27e8K.T s,  K.v s\u27e9\n\ndef Kripke_Coalgebra (K : Kripke \u03c6): Coalgebra F := \n    \u27e8K.State , \u03b1 K\u27e9 \n\nlemma Kripke_Coalgebra_hom {K\u2081 K\u2082 : Kripke \u03c6} (\u03d5 : K\u2081 \u2192 K\u2082): \n    is_homomorphism \u03c6 \u03d5 \u2194 \n    @is_coalgebra_homomorphism F \n        (Kripke_Coalgebra K\u2081) (Kripke_Coalgebra K\u2082)\n            \u03d5 :=\n    let \ud835\udd42\u2081  := Kripke_Coalgebra K\u2081 in\n    let \ud835\udd42\u2082 := Kripke_Coalgebra K\u2082 in\n    iff.intro \n    (\n    assume \u27e8tr, b_a, pr\u27e9,\n    show \ud835\udd42\u2082.\u03b1 \u2218 \u03d5 = F.map \u03d5 \u2218 \ud835\udd42\u2081.\u03b1,\n    begin \n        ext1,\n        have im_elem : \u2200 s : K\u2082.State , \n                s \u2208 image \u03d5 (K\u2081.T x) \u2194 s \u2208 K\u2082.T (\u03d5 x) :=   \n            begin\n                intro s,\n                split,\n                intros im_\u03d5,\n                cases im_\u03d5 with s12 specS12,\n                rw \u2190 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 \u03d5 (K\u2081.T x) = K\u2082.T (\u03d5 x) := \n            eq_sets.1 im_elem,\n        \n        have F_\u03d5 : F.map \u03d5 (\ud835\udd42\u2081.\u03b1 x) = \u27e8image \u03d5 (K\u2081.T x), K\u2081.v x\u27e9 \n                := rfl,\n        simp [F_\u03d5],\n        have last : (\u27e8K\u2082.T (\u03d5 x) , K\u2082.v (\u03d5 x)\u27e9 : \n            (set K\u2082.State) \u00d7 set \u03c6) = \u27e8image \u03d5 (K\u2081.T x), K\u2081.v x\u27e9 := \n                by simp [eq.symm im, eq.symm (pr x)],\n        simp [eq.symm last],\n        refl\n    end )\n    (\n    assume co_hom : \ud835\udd42\u2082.\u03b1 \u2218 \u03d5 = F.map \u03d5 \u2218 \ud835\udd42\u2081.\u03b1,\n    show (\u2200 a\u2081 a\u2082 :K\u2081 , a\u2082 \u2208 K\u2081.T a\u2081 \u2192 (\u03d5 a\u2082) \u2208 K\u2082.T (\u03d5 a\u2081)) \u2227 \n         (\u2200 (a : K\u2081) (b : K\u2082) , b \u2208 K\u2082.T (\u03d5 a) \u2192\n                \u2203 a': K\u2081 ,  a' \u2208 K\u2081.T a \u2227 \u03d5 a' = b) \u2227 \n         (\u2200 a : K\u2081 , K\u2081.v a = K\u2082.v (\u03d5 a)),\n    begin\n        split,\n        intros a\u2081 a\u2082 a\u2082_a\u2081,\n       \n        have h3 : (\ud835\udd42\u2082.\u03b1 \u2218 \u03d5) a\u2081 = ((F.map \u03d5) \u2218 \ud835\udd42\u2081.\u03b1) a\u2081 \n                     := by rw co_hom,\n        have h5 : (\u27e8K\u2082.T (\u03d5 a\u2081) , K\u2082.v (\u03d5 a\u2081)\u27e9 : \n            (set K\u2082.State) \u00d7 set \u03c6) = \u27e8image \u03d5 (K\u2081.T a\u2081), K\u2081.v a\u2081\u27e9 \n                := h3,\n        have h6 : K\u2082.T (\u03d5 a\u2081) = image \u03d5 (K\u2081.T a\u2081) := by tidy,\n        have h7 : \u03d5 a\u2082 \u2208 image \u03d5 (K\u2081.T a\u2081) := \n            by {use a\u2082, simp [a\u2082_a\u2081]},\n        rw h6,\n        exact h7,\n\n        split,\n        intros a\u2081 b b_T_\u03d5_a,\n        have h3 : (\ud835\udd42\u2082.\u03b1 \u2218 \u03d5) a\u2081 = ((F.map \u03d5) \u2218 \ud835\udd42\u2081.\u03b1) a\u2081 \n                     := by rw co_hom,\n        have h4 : \ud835\udd42\u2082.\u03b1 (\u03d5 a\u2081) = F.map \u03d5 (\ud835\udd42\u2081.\u03b1 a\u2081) \n                     := h3,\n        have h5 : (\u27e8K\u2082.T (\u03d5 a\u2081) , K\u2082.v (\u03d5 a\u2081)\u27e9 : \n            (set K\u2082.State) \u00d7 set \u03c6) = \u27e8image \u03d5 (K\u2081.T a\u2081), K\u2081.v a\u2081\u27e9 \n                := h4,\n        have h6 : K\u2082.T (\u03d5 a\u2081) = image \u03d5 (K\u2081.T a\u2081) := by tidy,\n        have h7 : b \u2208 image \u03d5 (K\u2081.T a\u2081) := h6 \u25b8 b_T_\u03d5_a,\n        exact h7,\n        intro a\u2081,\n        have h3 : (\ud835\udd42\u2082.\u03b1 \u2218 \u03d5) a\u2081 = ((F.map \u03d5) \u2218 \ud835\udd42\u2081.\u03b1) a\u2081 \n                     := by rw co_hom,\n        have h5 : (\u27e8K\u2082.T (\u03d5 a\u2081) , K\u2082.v (\u03d5 a\u2081)\u27e9 : \n            (set K\u2082.State) \u00d7 set \u03c6) = \u27e8image \u03d5 (K\u2081.T a\u2081), K\u2081.v a\u2081\u27e9 \n                := h3,\n        have h6 : K\u2082.v (\u03d5 a\u2081) = K\u2081.v a\u2081 := 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\u00e1chym \u0160imon, Tom\u00e1\u0161 L\u00e1vi\u010dka\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 {\u03b1 \u03b2 \u03b3  : 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: \u03b1 \u2192 \u03b2 \u2192 Prop}(A: \u03b1)(B:\u03b2): \n    P A B \u2192  \u2203 A:\u03b1, \u2203 B: \u03b2, P A B :=\n  begin intro a, repeat{apply exists.intro}, exact a end\n\n  lemma exintro3{P: \u03b1 \u2192 \u03b2 \u2192\u03b3 \u2192  Prop}(A: \u03b1)(B:\u03b2)(C:\u03b3): \n    P A B C \u2192  \u2203 A:\u03b1, \u2203 B: \u03b2,\u2203 C:\u03b3, P A B C :=\n  begin intro a, repeat{apply exists.intro}, exact a end\n\n  lemma exelim2{P: \u03b1 \u2192 \u03b2 \u2192 Prop}{Q:Prop}: \n    (\u2203 A:\u03b1, \u2203 B:\u03b2, P A B) \u2192 (\u2200 A:\u03b1, \u2200 B:\u03b2, P A B \u2192 Q) \u2192 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: \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 Prop}{Q:Prop}: \n    (\u2203 A:\u03b1, \u2203 B:\u03b2, \u2203 C:\u03b3, P A B C) \u2192 (\u2200 A:\u03b1, \u2200 B:\u03b2, \u2200 C:\u03b3, P A B C \u2192 Q) \u2192 Q :=\n  \u03bb hex hall, exists.elim hex \n  (\u03bb A hex1, exists.elim hex1 \n  (\u03bb B hex3, exists.elim hex3 \n  (\u03bb C hP, hall A B C hP)))\n\n\n-- FORM (inducive)\n\n  -- definition of formulae\n  inductive Form : Type\n  | p : \u2115 \u2192 Form\n  | imp : Form \u2192 Form \u2192 Form\n  | neg : Form \u2192 Form\n\n  local infixr \u21d2 : 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 := \u2115 \u2192 bool \n  -- variables\n  variables {v v\u2081 v\u2082:eval}\n  variables {A B C D:Form}\n  variables {\u0393 \u0394:set Form}\n  variables {m n:\u2115} \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 \u21d2 (B \u21d2 A)\n  def A2 (A B C:Form) := (A \u21d2 (B \u21d2 C)) \u21d2 ((A \u21d2 B) \u21d2 (A \u21d2 C))\n  def A3 (A B:Form) := (~B \u21d2 ~A) \u21d2 ((~B \u21d2 A) \u21d2 B) \n\n\n-- PROOF\n  -- formula in proof is either axiom, assumption or comes from modus ponens\n  def in_proof (A:Form)(\u0393:set Form)(l:list Form) : Prop :=\n    (\u2203 B C, A = A1 B C)  \u2228 \n    (\u2203 B C D, A = A2 B C D)  \u2228 \n    (\u2203 B C, A = A3 B C)  \u2228 \n    (A \u2208 \u0393)  \u2228 \n    (\u2203 B, B \u2208 l \u2227 (B \u21d2 A) \u2208 l) \n\n  -- list l is a proof from set of assumptions \u0393\n  def is_proof (\u0393:set Form)(l:list Form) : Prop := \n    list.rec_on l tt (\u03bb A li IH, in_proof A \u0393 li \u2227 IH)            \n  \n  -- formula A is provable from set of assumptions \u0393\n  def is_provable (\u0393:set Form)(A:Form) : Prop :=  \n    \u2203 l: list Form, is_proof \u0393 (A::l)                                   \n  \n  infixr ` \u22a2 ` : 40 := is_provable\n  prefix ` \u22a2 ` : 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 (\u0393:set Form)(l:list Form) : Prop := \n    list.rec_on l tt \n    (\u03bb A li IH, ((\u2203 B C, B \u2208 li \u2227 C \u2208 li \u2227 {B,C} \u22a2 A) \u2228 \n                  (\u2203 B, B \u2208 li \u2227 {B} \u22a2 A) \u2228\n                  ({} \u22a2 A) \u2228\n                   in_proof A \u0393 li) \n                   \u2227 IH )\n  -- formula A is provable from \u0393 using mentioned cut rules\n  def is_provable_with_cut (\u0393:set Form)(A:Form) : Prop :=  \n    \u2203 l: list Form, is_proof_with_cut \u0393 (A::l)\n\n  infixr ` \u22a2cut ` : 40 := is_provable_with_cut\n  prefix ` \u22a2cut ` : 40 := is_provable {}\n   \n\n-- PROOF lemmas\n  -- useful lemmas about proof definitions\n\n  lemma is_proof_ind : is_proof \u0393 (A::l) \u2192 is_proof \u0393 l := and.right      \n  lemma in_proof_extend : in_proof A \u0393 l \u2192 l <+ li \u2192 in_proof A \u0393 li :=\n    begin \n     intros a a_1, repeat {cases a, tac},\n     cases a with hl hr, repeat {right},\n     have hp: l \u2286 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 \u0393 l \u2192 is_proof \u0393 li \u2192 is_proof \u0393 (l++li) :=\n    list.rec_on l\n      (\u03bb h hp, hp)\n      (assume A lis IH Hl Hli, \n        \u27e8 in_proof_extend Hl.1 (list.sublist_append_left lis li),\n        IH (is_proof_ind Hl) Hli \u27e9)\n\n  lemma is_proof_extend : is_proof \u0393 l \u2192 A \u2208 l \u2192 in_proof A \u0393 l :=\n    list.rec_on l  \n    (\u03bb h hp, absurd rfl (list.ne_nil_of_mem hp))\n    (\u03bb D lis IH h hp,         \n    have lem: A \u2208 D::lis \u2192 A=D \u2228 A\u2208 lis, from \n      \u03bb h, or.elim (list.eq_or_ne_mem_of_mem h) (\u03bb hp, or.inl hp) (\u03bb hp, or.inr hp.2),\n    have sub: lis<+D::lis, from by simp,\n    or.elim (lem hp)                    \n      (assume H, H.symm \u25b8 in_proof_extend h.1 sub)         \n      (\u03bb 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 \u2192 bool :=\n    \u03bb A:Form, Form.rec_on A (\u03bb n:\u2115, v n) \n                            (\u03bb A B:Form, \u03bb a b:bool, !a || b) \n                            (\u03bb A:Form, \u03bb a:bool, !a)\n  \n  notation v `\u2217` := val v\n\n  -- A is tautology\n  def is_taut (A:Form) : Prop := \u2200 v:eval, v\u2217 A = tt\n  \n  notation `\u22a7` := is_taut\n\n\n-- SOUNDNESS \n  -- axioms are tautologies\n  lemma A1_taut : \u22a7 (A1 A B) :=\n    \u03bb v, have A1_bool: \u2200 a b: bool, !a || (!b || a) = tt, \n    from by simp, A1_bool (v\u2217A) (v\u2217B)\n    \n  lemma A2_taut : \u22a7 (A2 A B C) :=\n    \u03bb v, \n    have A2_bool: \u2200 a b c: bool, \n    !(!a || (!b || c)) || (!(!a || b) || (!a || c)) = tt,\n    from by simp, A2_bool (v\u2217 A) (v\u2217 B) (v\u2217 C) \n    \n  lemma A3_taut : \u22a7 (A3 A B):=\n    \u03bb v, \n    have A3_bool: \u2200 a b:bool, !((!!b) || (!a)) || ((!(!!b || a)) || b) = tt, \n    from by simp, A3_bool (v\u2217 A) (v\u2217 B)      \n    \n  lemma MP_taut (h1:\u22a7 A)(h2:\u22a7 (A \u21d2 B)) : \u22a7 B :=\n    \u03bb v, have MP_bool: (\u2200 (a b:bool), (a = tt \u2227 !a || b = tt) \u2192 b = tt), from  \n      ( \u03bb a b p1,\n      have p2: ff || b = tt, from @eq.subst bool (\u03bb x, bnot x || b = tt) a tt p1.1 p1.2,\n      or.elim (bool.dichotomy b)\n      (\u03bb i, false.elim \n        (bool.ff_ne_tt (calc ff = ff || ff : rfl \n                             ...= tt : @eq.subst bool (\u03bb x, ff || x = tt) b ff i p2)))\n      (\u03bb i, i) ),\n    MP_bool (v\u2217A) (v\u2217(B)) \u27e8h1 v, calc bnot (v\u2217A) || (v\u2217B) = (v\u2217(A \u21d2 B)) : rfl \n                                                     ... = tt : (h2 v)\u27e9\n  \n  lemma soundness_lemma : \u2200 A:Form, is_proof {} l \u2227 A \u2208 l \u2192 \u22a7 A :=\n    list.rec_on l\n    (\u03bb A i, forall_mem_nil \u22a7 A i.2)\n    (\u03bb B k IH,\n      (\u03bb A, \u03bb i_Bk: is_proof {} (B::k) \u2227 A \u2208 (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: \u22a7 b, apply IH b \u27e8is_proof_ind i_Bk.1, c.1\u27e9,\n            have hbB: \u22a7 (b \u21d2 B), apply IH (b \u21d2 B) \u27e8is_proof_ind i_Bk.1, c.2\u27e9,  \n            apply MP_taut hb hbB\n      end)\n    (\u03bb j, IH A \u27e8is_proof_ind i_Bk.1, j\u27e9)))\n\n  theorem CPL_soundness : \u2200 A:Form, \u22a2 A \u2192 \u22a7 A :=\n    begin \n      intros a a_1, \n      apply exists.elim a_1, intros a_2 a_3, \n      exact soundness_lemma a \u27e8a_3, by simp\u27e9 \n    end\n \n\n-- PROVABLE lemmas\n  -- monotony, cut rules, other rules\n  -- provable with cut \u2192 provable without cut\n\n  lemma modus_ponens_rule : {A, A \u21d2 B} \u22a2 B :=\n    let prf:= [A, A \u21d2 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  (\u0393 \u22a2 A) \u2192 (\u0393 \u22a2 B) \u2192 ({A, B} \u22a2 C) \u2192 (\u0393 \u22a2 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: \u2200 l:list Form, is_proof {A,B} l \u2192 is_proof \u0393 (l++pr), \n      intro l, apply list.rec_on l, intro a,  \n      exact (@is_proof_concat \u0393 (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 \u2208 li++pr, by simp,  \n      exact is_proof_extend (IH (is_proof_ind hp)) ha, \n      rw[h], \n      have ha: B \u2208 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 \u2286 (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}: (\u0393 \u22a2 A) \u2192 ({A} \u22a2 B) \u2192 (\u0393 \u22a2 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 : \u0393 \u2286 \u0394 \u2192 is_proof \u0393 l \u2192 is_proof \u0394 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 \u2208 \u0394, 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 : \u0393 \u2286 \u0394 \u2192 \u0393 \u22a2 A \u2192  \u0394 \u22a2 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 : \u0393 \u22a2cut A \u2192 \u0393 \u22a2 A := \n    begin \n      have lem : \u2200 l A, (is_proof_with_cut \u0393 l) \u2192 (A \u2208 l) \u2192 (\u0393 \u22a2 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: \u0393 \u22a2 C, from IH C hp.2 a.1 ,\n      have HD: \u0393 \u22a2 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: \u0393 \u22a2 C, from IH C hp.2 hC.1 ,       \n        exact unary_cut HC hC.2, \n      cases h, \n      have hyp: \u2205 \u2286 \u0393, from \u03bb 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: \u0393 \u22a2 G, exact  IH G hp.2 (hG.1),\n      have Hb: \u0393 \u22a2 G \u21d2 B, exact  IH (G \u21d2 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\u2208 A::l, from by simp,\n      exact lem (A::l) A hpp h  \n    end\n  . \n  lemma provable1 : \u0393 \u22a2 A \u21d2 A :=\n    let prf:= [ (A \u21d2 (A \u21d2 A)) \u21d2 (A \u21d2 A), \n               A2 A (A \u21d2 A) A,\n               A1 A A, \n               A1 A (A \u21d2 A) ] in\n    by mt_verifier\n\n  lemma exchange : {A \u21d2 B, A \u21d2 B \u21d2 C} \u22a2 A \u21d2 C:= \n    let prf:= [(A \u21d2 B) \u21d2 A \u21d2 C, A \u21d2 B, A \u21d2 B \u21d2 C, A2 A B C] in\n    by mt_verifier\n\n  theorem deduction_theorem : (\u0393 \u222a {A} \u22a2 B) \u2192 (\u0393 \u22a2 A \u21d2 B) :=\n   have lem: \u2200 l: list Form, is_proof (\u0393 \u222a {A}) l \u2192 \n                             \u2200 B, B \u2208 l \u2192  \n                             (\u0393 \u22a2 A \u21d2 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: \u0393 \u22a2 A \u21d2 B, exact IH h.2 B hB.1, \n     have Himp: \u0393 \u22a2 A \u21d2 B \u21d2 C, exact IH h.2 (B \u21d2 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 (\u03bb list hyp, \n   have is_in: B\u2208 B::list, from by simp,\n   lem (B::list) hyp B is_in)\n  \n  theorem deduction_theoremR : (\u0393 \u22a2 A \u21d2 B) \u2192 (\u0393 \u222a {A} \u22a2 B) := \n    begin \n      intro h, \n      have h3: \u0393 \u2286 \u0393 \u222a {A}, simp,\n      have h21: \u0393 \u222a {A} \u22a2 (A \u21d2 B),\n      exact monotony h3 h, \n      apply exists.elim h21, intros l h2,\n      let prf:=(A::(A \u21d2 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: \u22a2 ~~A \u21d2 A :=\n   begin \n    apply deduction_theorem, simp,\n    let prf := \n    [\n    (~A \u21d2 ~A) \u21d2  A,\n    ~A \u21d2 ~A,\n    ~A \u21d2 ~~A, \n    A3 (~A) A, \n    A1 (~~A) (~A),\n    ~~A], mt_verifier \n   end\n\n  lemma provable2 : \u0393 \u22a2 A \u21d2 ~~A := \n    let prf := [\n                (~~~A \u21d2 A) \u21d2 ~~A, \n                A3 A (~~A),\n                ~~~A \u21d2 ~A,\n                ~~~A \u21d2 A, \n                A1 A (~~~A),\n                A] in\n    begin \n      apply monotony, \n      have h: {} \u2286 \u0393, focus{simp}, exact h, \n      apply deduction_theorem, simp,\n      mt_verifier\n    end\n\n  lemma transitivity : {A \u21d2 B, B \u21d2 C} \u22a2 A \u21d2 C :=\n    let prf:= [\n      (A \u21d2 B) \u21d2 (A \u21d2 C),\n      A \u21d2 B, \n      A2 A B C, \n      A \u21d2 (B \u21d2 C), \n      A1 (B \u21d2 C) A,\n      B \u21d2 C\n    ] in by mt_verifier\n\n  lemma RAA: {A \u21d2 B, A \u21d2 ~B} \u22a2 ~A:= \n    have h1: {A \u21d2 B} \u22a2 ~~A \u21d2 B, from \n      by{let prf:= [~~A \u21d2 A, A \u21d2 B], mt_verifier},\n    have h2: {A \u21d2 ~B} \u22a2 ~~A \u21d2 ~B, from \n      by{let prf:= [ ~~A \u21d2 A, A \u21d2 ~B ], mt_verifier}, \n    by{let prf:= [(~~A \u21d2 B) \u21d2 ~A, A3 B (~A), ~~A \u21d2 ~B,~~A \u21d2 B, A \u21d2 B, A \u21d2 ~B], mt_verifier}\n\n  lemma contraposition : {A \u21d2 B} \u22a2 ~B \u21d2 ~A := \n    by{apply deduction_theorem, \n    let prf:= [A \u21d2 ~B, ~B \u21d2 (A \u21d2 ~B), ~B, A \u21d2 B], mt_verifier}\n                         \n  lemma provable5 : {A \u21d2 B, ~A \u21d2 B} \u22a2 B:= \n    let prf:= [                  \n                        (~B \u21d2 ~A ) \u21d2 B, \n                        (~B \u21d2 ~~A) \u21d2 (~B \u21d2 ~A) \u21d2 B,            \n                        ~B \u21d2 ~~A, \n                        ~A \u21d2 B, \n                        ~B \u21d2 ~A, \n                        A \u21d2 B \n                    ] in\n    by{mt_verifier}\n\n  theorem PCP : (\u0393 \u222a {A} \u22a2 B) \u2192 (\u0393 \u222a {~A} \u22a2 B) \u2192 (\u0393 \u22a2 B) := \n    assume h hneg, \n    have hp: \u0393 \u22a2 A \u21d2 B, from deduction_theorem h,\n    have hpp: \u0393 \u22a2 ~A \u21d2 B, from deduction_theorem hneg,        \n    binary_cut hp hpp (provable5)\n  \n  lemma modus_ponens : (\u0393 \u22a2 A) \u2192 (\u0393 \u22a2 (A \u21d2 B)) \u2192 (\u0393 \u22a2 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 \u0393 (A::la ++ (A\u21d2B)::lab), \n        from by {exact is_proof_concat prfa prfab},\n      have h3: in_proof B \u0393 (A::la ++ (A\u21d2B)::lab), \n        from by {repeat{right}, exact exists.intro A \u27e8by simp, by simp\u27e9},\n      exact exists.intro (A::la ++ (A\u21d2B)::lab) \u27e8h3, h\u27e9\n    end\n\n  lemma provable6 : (\u0393 \u22a2 A) \u2192 (\u0393 \u22a2 B \u21d2 A) :=\n    \u03bb hA, have p1: \u0393\u222a{B} \u22a2 A, from monotony (subset_union_left \u0393 {B}) hA,\n    deduction_theorem p1  \n\n  lemma provable3 : (\u0393 \u22a2 ~A) \u2192 (\u0393 \u22a2 A \u21d2 B):= \n    \u03bb h, \n    have h0: \u0393 \u2286 \u0393 \u222a {A}, from by simp,\n    have h1: \u0393 \u222a {A} \u22a2 ~A, from monotony h0 h,\n    have h2: \u0393 \u222a {A} \u22a2 A, from let prf:= [A] in by mt_verifier,\n    have h3: {~A, A} \u22a2 B, from\n    let prf:= [(~B \u21d2 A) \u21d2 B, A3 A B, ~B \u21d2 A, A, A1 A (~B), \n    (~B \u21d2 ~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} \u222a {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} \u22a2 ~(A \u21d2 B) := \n    begin \n      apply (@deduction_theoremR (~B) (~(A \u21d2 B)) {A}),\n      apply unary_cut, swap, exact contraposition, \n      have h: {A} = {} \u222a {A}, exact (@empty_union Form {A}).symm, rw[h], \n      apply (@deduction_theoremR A ((A \u21d2 B) \u21d2 B) {}), \n      apply deduction_theorem, apply deduction_theorem, \n      have h2: {A} \u222a {A \u21d2 B} = {A, A \u21d2 B}, exact sets_eqv.symm,  \n      rw[h.symm, h2], \n      exact modus_ponens_rule\n    end \n\n  lemma provable4 : (\u0393 \u22a2 A) \u2192 (\u0393 \u22a2 ~B) \u2192 (\u0393 \u22a2 ~(A \u21d2 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\u2217A = tt then A else ~A\n\n  @[simp] def swap_var (n:\u2115)(v:eval): Form :=\n    if v n = tt then p n else ~(p n)\n\n  @[simp] theorem swap_tt : (v\u2217A = tt) \u2192 (swap A v = A) := \n    \u03bb h, by simp [h]\n\n  @[simp] theorem swap_ff : (v\u2217A = ff) \u2192 (swap A v = ~A) :=\n    \u03bb h, by simp [h]\n\n  @[simp] lemma pswap_neg_tt: (v\u2217A = tt) \u2192 (v\u2217(~A) = ff) := \n    \u03bb h, @eq.subst bool (\u03bb x, (v\u2217(~A)) = bnot x) (v\u2217A) tt h rfl\n  \n  @[simp] lemma pswap_neg_ff: (v\u2217A = ff) \u2192 (v\u2217(~A) = tt) := \n    \u03bb h, @eq.subst bool (\u03bb x, (v\u2217(~A)) = bnot x) (v\u2217A) ff h rfl\n\n  @[simp] theorem swap_neg_ff : (v\u2217A = ff) \u2192 swap (~A) v = ~A :=\n    \u03bb h, by simp [h]\n \n  theorem swap_neg_tt : (v\u2217A = tt) \u2192 swap (~A) v = ~~A := \n    \u03bb h, by simp[h]\n\n  @[simp] lemma pswap_imp_tt_ff : (v\u2217A = tt) \u2192 (v\u2217B = ff) \u2192 (v\u2217(A \u21d2 B) = ff) :=\n    \u03bb ha hb, have h2: (v\u2217(A \u21d2 B)) = bnot (v\u2217A) || ff, from hb \u25b8 rfl,\n    @eq.subst bool (\u03bb x, (v\u2217(A \u21d2 B)) = bnot x || ff) (v\u2217A) tt ha h2\n\n  @[simp] lemma pswap_imp_tt_tt : (v\u2217A = tt) \u2192 (v\u2217B = tt) \u2192 (v\u2217(A \u21d2 B) = tt) :=\n    \u03bb ha hb, have h2: (v\u2217(A \u21d2 B)) = bnot (v\u2217A) || tt, from hb \u25b8 rfl,\n    @eq.subst bool (\u03bb x, (v\u2217(A \u21d2 B)) = bnot x || tt) (v\u2217A) tt ha h2\n\n  theorem swap_imp_tt_ff : \n      (v\u2217A = tt) \u2192 (v\u2217B = ff) \u2192 (swap (A \u21d2 B) v = ~(A \u21d2 B)) :=\n    \u03bb h h1, by simp[h, h1] \n\n  theorem swap_imp_tt_tt: \n      (v\u2217A = tt) \u2192 (v\u2217B = tt) \u2192 (swap (A \u21d2 B) v = A \u21d2 B) :=\n    \u03bb h p, by simp[h, p] \n\n  theorem swap_imp_ff : (v\u2217A = ff) \u2192 (v\u2217(A \u21d2 B)) = tt := \n    \u03bb h, calc v\u2217(A \u21d2 B) = bnot ff || (v\u2217B) : h \u25b8 rfl\n\n  lemma swap_var_tt : v n = tt \u2192 (swap_var n v = p n) := \n    \u03bb h, by simp [h]\n\n  lemma swap_var_ff : v n = ff \u2192 (swap_var n v = ~p n) :=\n    \u03bb h, by simp [h]\n \n -- svar_set set\n  def svar_set (n:\u2115)(v:eval) : set Form :=\n    { A | \u2203 i:\u2115, i < n \u2227 A = (swap_var i v)}\n\n  def form_index (A:Form) : \u2115 := \n    Form.rec_on A (\u03bb n:\u2115, n+1) \n                  (\u03bb A B:Form, \u03bb na nb:\u2115, max na nb) \n                  (\u03bb A:Form, \u03bb m:\u2115, m)\n\n  lemma swap_in_flae : (swap (p n) v) \u2208  svar_set (form_index (p n)) v :=\n    have h: form_index (p n) = n+1, from rfl,\n    exists.intro n \u27e8lt_succ_self n, rfl\u27e9   \n\n  lemma flae_inclusion : (\u2200 n \u2264 m,  svar_set n v \u2286  svar_set m v) := \n    \u03bb n h A h', exists.elim h'\n    (\u03bb i h1, exists.intro i (show i < m \u2227 A = swap_var i v, from \n    \u27e8nat.le_trans h1.1 h, h1.2\u27e9))\n\n  lemma flae_empty :  svar_set 0 v = {} := \n    funext (\u03bb A:Form, show  svar_set 0 v A = false, from \n    propext \u27e8 (\u03bb h: svar_set 0 v A, exists.elim h (\u03bb i h1, \n    (nat.succ_ne_zero i (nat.eq_zero_of_le_zero h1.1 )))),\n    false.elim \u27e9)\n    \n  lemma var_index_max_left : form_index A \u2264 form_index (A \u21d2 B) :=\n    le_max_left (form_index A) (form_index B)\n\n  lemma var_index_max_right : form_index B \u2264 form_index (A \u21d2 B) :=\n    le_max_right (form_index A) (form_index B)\n\n -- truth eval \n  @[simp] def g\u2081 (n:\u2115)(v:eval) : \u2115 \u2192 bool := \n   \u03bb m, if m<n then v m else tt\n\n  @[simp] def g\u2082 (n:\u2115)(v:eval) : \u2115 \u2192 bool := \n   \u03bb m, if m<n then v m else ff\n\n  lemma g\u2081_eq_tt (h: m = n) : (g\u2081 n v) m = tt := \n    have \u00ac( m < n), from \u03bb h', ne_of_lt h' h,\n    by simp [this]\n \n  lemma g\u2082_eq_ff (h: m = n) : (g\u2082 n v) m = ff := \n    have \u00ac  m < n, from \u03bb h', ne_of_lt h' h,\n    by simp [this]\n\n  lemma g\u2081_v_eq_ite (v g:eval)(n:\u2115) : v n = g n \u2192 \n    ite (v n = tt) (p n) (~ p n) = ite (g n = tt) (p n) (~ p n) := \n   \u03bb h, (@eq.subst bool (\u03bb 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\u2081_v_eq: \u2200 m < n, v m = (g\u2081 n v) m :=\n   \u03bb m n, by simp [n]\n\n  lemma g\u2082_v_eq: \u2200 m < n, v m = (g\u2082 n v) m :=\n   \u03bb m n, by simp [n]\n\n  lemma g\u2081_v_swap_var_eq (v:eval) : m < n \u2192 swap_var m v = swap_var m (g\u2081 n v) := \n   \u03bb h , have h1: v m = (g\u2081 n v) m, from g\u2081_v_eq m h,\n   g\u2081_v_eq_ite v (g\u2081 n v) m h1\n\n  lemma g\u2082_v_swap_var_eq (v:eval) : m<n \u2192 swap_var m v = swap_var m (g\u2082 n v) :=\n   \u03bb h , have h1: v m = (g\u2082 n v) m, from g\u2082_v_eq m h,\n   g\u2081_v_eq_ite v (g\u2082 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\u2081_v_swap_var_eq v h_h.1} <|> {exact g\u2082_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\u2081 n v n = tt, from @g\u2081_eq_tt v n n rfl,\n      have hp2: g\u2082 n v n = ff, from @g\u2082_eq_ff v n n rfl, \n      {rw[(@swap_var_tt (g\u2081 n v) n hp1).symm]} <|> \n      {rw[(@swap_var_ff (g\u2082 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\u2081_v_swap_var_eq v h2)], exact h_h.2} <|> \n      {rw[(g\u2082_v_swap_var_eq v h2)], exact h_h.2},\n\n      intro h2, right, \n      {rw[(swap_var_tt (@g\u2081_eq_tt v h_w n h2)), h2] at h_h, exact h_h.2} <|> \n      {rw[(swap_var_ff (@g\u2082_eq_ff v h_w n h2)), h2] at h_h, exact h_h.2}, \n\n      intro h2, have h5: h_w \u2264 n, from iff.elim_left lt_succ_iff h_h.1,\n      have h6: h_w \u2264 n \u2227 \u00ach_w \u2264 n, from \u27e8h5, (iff.elim_left (lt_iff_not_ge n h_w)) h2\u27e9,\n      exact false.elim (iff.elim_left (and_not_self (h_w \u2264 n)) h6)\n  ]\n\n  lemma flae_ind : (svar_set n v) \u222a {p n} =  svar_set (n+1) (g\u2081 n v) :=\n    by flae_ind_tac\n\n  lemma flae_ind_neg : (svar_set n v) \u222a {~p n} =  svar_set (n+1) (g\u2082 n v) :=\n    by flae_ind_tac\n\n \n -- induction formalization \n  def nprovable (A:Form)(n:\u2115) : Prop :=\n    \u2200 v:eval, (svar_set n v) \u22a2 A\n\n  lemma PCP_app : \u2200 n:\u2115, nprovable A (n+1) \u2192 nprovable A n:=\n    \u03bb n hp f, show  (svar_set n f) \u22a2 A, from PCP\n    (@eq.subst (set Form) (\u03bb \u0393, \u0393 \u22a2 A) (svar_set (n+1) (g\u2081 n f)) ((svar_set n f) \u222a {p n}) \n      (@flae_ind f n).symm (hp (g\u2081 n f)))        \n    (@eq.subst (set Form) (\u03bb \u0393, \u0393 \u22a2  A) (svar_set (n+1) (g\u2082 n f)) ((svar_set n f) \u222a { ~(p n)}) \n      (@flae_ind_neg f n).symm (hp (g\u2082 n f)))\n\n  theorem nprov_theorem : nprovable A n \u2192 (\u22a2 A) :=\n    \u03bb h, have H: nprovable A n \u2192 nprovable A 0, from  \n      nat.rec_on n (\u03bb h, h) (assume n IH hp, IH (PCP_app n hp)), \n    (@flae_empty (\u03bb n:\u2115, tt)) \u25b8 (H h) (\u03bb n:\u2115, tt)\n\n\n-- COMPLETENESS\n\n  lemma main_lemma : \u2200 v:eval, (svar_set (form_index A) v) \u22a2 swap A v := \n    \u03bb v,\n    Form.rec_on A \n    -- p constructor     \n    (\u03bb n, exists.intro []\n      \u27e8or.inr (or.inr (or.inr (or.inl swap_in_flae))), rfl\u27e9)\n    -- imp constructor\n    (\u03bb A B, let \u0393a := (svar_set (form_index A) v),\n                \u0393b:set Form := (svar_set (form_index B) v),\n                \u0393imp := (svar_set (form_index (A \u21d2 B)) v) in\n   \u03bb IHa: \u0393a \u22a2 swap A v, \n   \u03bb IHb: \u0393b \u22a2 swap B v,\n   have h: \u0393a \u2286 \u0393imp, from flae_inclusion (form_index A) var_index_max_left,\n   have hbb: \u0393b \u2286 \u0393imp, from flae_inclusion (form_index B) var_index_max_right, \n   or.elim (bool.dichotomy (v\u2217A))\n    -- v\u2217A=ff                          \n     (\u03bb hpa, have himp: swap (A \u21d2 B) v = (A \u21d2 B), from swap_tt (swap_imp_ff hpa),                          \n     (calc (\u0393a \u22a2 swap A v) \u2192 (\u0393a \u22a2 ~A)                :  \u03bb h, swap_ff hpa \u25b8 IHa\n                 ...       \u2192 (\u0393a \u22a2 A \u21d2 B)             :  \u03bb h, provable3 h \n                 ...       \u2192 (\u0393imp \u22a2 A \u21d2 B)           :  \u03bb hp, monotony h hp    \n                 ...       \u2192 (\u0393imp \u22a2 swap (A \u21d2 B) v)  :  \u03bb h, himp.symm \u25b8 h) \n     IHa)\n              \n    -- v\u2217A=tt \n     (\u03bb hpa, or.elim (bool.dichotomy (v\u2217 B))\n      -- v\u2217B=ff\n      (\u03bb hpb, have ha: (\u0393imp \u22a2 A), from  \n              (calc (\u0393a \u22a2 swap A v) \u2192 (\u0393a \u22a2 A)    : \u03bb h5, swap_tt hpa \u25b8 IHa\n                          ...       \u2192 (\u0393imp \u22a2 A)  : \u03bb h5, monotony h h5) IHa, \n              have hb: (\u0393imp \u22a2 ~B), from \n              (calc (\u0393b \u22a2 swap B v) \u2192 (\u0393b \u22a2 ~B)   : \u03bb h5, swap_ff hpb \u25b8 IHb\n                           ...      \u2192 (\u0393imp \u22a2 ~B) : \u03bb h5, monotony hbb h5) IHb, \n              have hab: (\u0393imp \u22a2 ~(A \u21d2 B)), from provable4 ha hb, \n              (calc (\u0393imp \u22a2 ~(A \u21d2 B)) \u2192 (\u0393imp \u22a2 swap (A \u21d2 B) v) : \n               \u03bb h5, eq.substr (swap_imp_tt_ff hpa hpb) h5) hab)\n      -- v\u2217B=tt\n      (\u03bb hpb, have hb: (\u0393imp \u22a2 B), from \n              (calc (\u0393b \u22a2 swap B v) \u2192 (\u0393b \u22a2 B)   : \u03bb h5, swap_tt hpb \u25b8 IHb\n                           ...      \u2192  (\u0393imp \u22a2 B) : \u03bb h5, monotony hbb h5) IHb, \n              have hab: (\u0393imp \u22a2 (A \u21d2 B)), from (@provable6 B A \u0393imp) hb, \n              (calc (\u0393imp \u22a2 (A \u21d2 B)) \u2192 (\u0393imp \u22a2 swap (A \u21d2 B) v) : \n               \u03bb h5, (swap_imp_tt_tt hpa hpb).symm \u25b8 h5) hab)))\n    -- neg\u2081 constructor\n    (\u03bb A,   let \u0393a := ( svar_set (form_index A) v) in              \n     \u03bb ha: \u0393a \u22a2 swap A v, \n     show \u0393a \u22a2 swap (~A) v, from \n     or.elim (bool.dichotomy (v\u2217A))\n    -- v\u2217A=ff\n    (\u03bb h, (calc (\u0393a \u22a2 swap A v) \u2192 (\u0393a \u22a2 ~A)          : \u03bb h1, swap_ff h \u25b8 ha\n                       ...      \u2192 (\u0393a \u22a2 swap (~A) v) : \u03bb h1, (swap_neg_ff h).symm \u25b8 h1) ha) \n    -- v\u2217A=tt \n    (\u03bb h, (calc (\u0393a \u22a2 swap A v) \u2192 (\u0393a \u22a2 A)           : \u03bb h1, swap_tt h \u25b8 ha\n                       ...      \u2192 (\u0393a \u22a2 ~~A)         : \u03bb h1, modus_ponens h1 provable2\n                       ...      \u2192 (\u0393a \u22a2 swap (~A) v) : \u03bb h1, (swap_neg_tt h).symm \u25b8 h1) ha))\n  \n  theorem CPL_completeness: \u22a7 A \u2192 \u22a2 A :=\n    \u03bb h, have H: nprovable A (form_index A), from             \n      (\u03bb v:eval, @eq.subst Form \n      (\u03bb 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 {\u03b1 \u03b2 : Type*} [ring \u03b2] (e : \u03b1 \u2243 \u03b2) :\n  @is_ring_hom \u03b1 \u03b2 (equiv.ring e) _ e :=\nby split; simp [equiv.mul_def, equiv.add_def, equiv.one_def]\n\ninstance equiv.is_ring_hom.symm {\u03b1 \u03b2 : Type*} [ring \u03b2] (e : \u03b1 \u2243 \u03b2) :\n  @is_ring_hom \u03b2 \u03b1 _ (equiv.ring e) e.symm :=\nby letI := equiv.ring e; exact (show \u03b1 \u2243r \u03b2, from \u27e8e, equiv.is_ring_hom e\u27e9).symm.2\n\ninductive in_algebraic_closure {L : Type v} [discrete_field L] (i : K \u2192 L) : L \u2192 Prop\n| of_field : \u2200 x, in_algebraic_closure (i x)\n| root     : \u2200 (l : L) (f : polynomial L), f \u2260 0 \u2192 (\u2200 n : \u2115, in_algebraic_closure (f.coeff n)) \u2192\n  is_root f l \u2192 in_algebraic_closure l\n\ndef algebraic {L : Type v} [comm_ring L] (i : K \u2192 L) (x : L) : Prop :=\n\u2203 f : polynomial K, f \u2260 0 \u2227 f.eval\u2082 i x = 0\n\nclass is_algebraically_closed :=\n(exists_root : \u2200 f : polynomial K, 0 < degree f \u2192 \u2203 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 \u2192 L) (j : L \u2192 M) [is_ring_hom i] [is_ring_hom j] {x : L} :\n  algebraic K i x \u2192 algebraic K (j \u2218 i) (j x) :=\n\u03bb \u27e8f, hf\u27e9, \u27e8f, hf.1, by rw [\u2190 eval_map, function.comp, \u2190 polynomial.map_map i j, eval_map,\n    eval\u2082_hom, eval_map, hf.2, is_ring_hom.map_zero j]\u27e9\n\nlemma algebraic_id (x : K) : algebraic K id x :=\n\u27e8X - C x, ne_zero_of_monic (monic_X_sub_C _), by simp\u27e9\n\nlemma algebraic_equiv {L : Type*} [discrete_field L] (e : K \u2243 L) [is_ring_hom e] (x : L) : \n  algebraic K e x :=\n\u27e8X - C (e.symm x), ne_zero_of_monic (monic_X_sub_C _), \n  by rw [\u2190 eval_map, map_sub, map_X, map_C, equiv.apply_symm_apply,\n      eval_sub, eval_X, eval_C, sub_self]\u27e9\n\nlemma algebraic_adjoin_root (f : polynomial K) [irreducible f] :\n  \u2200 x, algebraic K (adjoin_root.of : K \u2192 adjoin_root f) x := sorry\n\nlemma algebraic_comp' {L M : Type*} [discrete_field L] [discrete_field M]\n  (i : K \u2192 L) (j : L \u2192 M) [is_field_hom i] [is_field_hom j] :\n  (\u2200 x, algebraic K i x) \u2192 (\u2200 x, algebraic L j  x) \u2192 \u2200 x, algebraic K (j \u2218 i) x := sorry\n\nsection classical\n\nlocal attribute [instance, priority 1] classical.dec\n\ndef big_type := set (\u2115 \u00d7 polynomial K)\n\ndef big_type_map {L : Type*} [discrete_field L] (i : K \u2192 L) [is_ring_hom i]\n  (h : \u2200 l : L, algebraic K i l) (x : L) : \u2115 \u00d7 polynomial K :=\nlet f := classical.some (h x) in\n\u27e8list.index_of x (quotient.out ((f.map i).roots.1)), f\u27e9\n\nlemma big_type_map_injective {L : Type*} [discrete_field L] (i : K \u2192 L) [is_ring_hom i]\n  (h : \u2200 l : L, algebraic K i l) : injective (big_type_map K i h) :=\n\u03bb x y hxy,\nlet f := classical.some (h x) in\nlet g := classical.some (h y) in\nhave hf : f \u2260 0 \u2227 f.eval\u2082 i x = 0, from classical.some_spec (h x),\nhave hg : g \u2260 0 \u2227 g.eval\u2082 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 \u25b8 rfl),\nhave hx : x \u2208 quotient.out ((f.map i).roots.1),\n  from multiset.mem_coe.1 begin\n    show x \u2208 quotient.mk _,\n    rw [quotient.out_eq, \u2190 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 \u2208 quotient.out ((f.map i).roots.1),\n  from multiset.mem_coe.1 begin\n    show y \u2208 quotient.mk _,\n    rw [quotient.out_eq, \u2190 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 \u21aa big_type K :=\n\u27e8\u03bb a, show set _, from {(0, X - C a)}, \u03bb a b, by simp [C_inj]\u27e9\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 \u21a5carrier]\n(range_subset : set.range (bembedding K) \u2286 carrier)\n[is_field_hom : is_field_hom (inclusion range_subset)]\n(algebraic : \u2200 x, algebraic _ (inclusion (range_subset)) x)\n(lift : \u03a0 {\u03b1 : Type u} [discrete_field \u03b1] (i : set.range (bembedding K) \u2192 \u03b1)\n  [by exactI _root_.is_field_hom i] [is_algebraically_closed \u03b1],\n  carrier \u2192 \u03b1)\n(lift_is_field_hom : \u2200 {\u03b1 : Type u} [discrete_field \u03b1] (i : set.range (bembedding K) \u2192 \u03b1)\n  [by exactI _root_.is_field_hom i] [is_algebraically_closed \u03b1],\n  by exactI _root_.is_field_hom (lift i))\n(lift_comp : \u2200 {\u03b1 : Type u} [discrete_field \u03b1] (i : set.range (bembedding K) \u2192 \u03b1)\n  [by exactI _root_.is_field_hom i] [is_algebraically_closed \u03b1] (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 := \u03bb s t, \u2203 hst : s.carrier \u2286 t.carrier, is_field_hom (inclusion hst)\n    \u2227 \u2200 {\u03b1 : Type u} [discrete_field \u03b1] (i : set.range (bembedding K) \u2192 \u03b1)\n    [by exactI _root_.is_field_hom i] [by exactI is_algebraically_closed \u03b1] (x : s.carrier),\n    by exactI s.lift i x = t.lift i (inclusion hst x),\n  le_refl := \u03bb _, \u27e8by refl, by simp [inclusion]; exact is_ring_hom.id,\n    by intros; simp [inclusion, subtype.coe_eta]\u27e9,\n  le_trans := \u03bb s t u \u27e8hst\u2081, hst\u2082, hst\u2083\u27e9 \u27e8htu\u2081, htu\u2082, htu\u2083\u27e9,\n    \u27e8set.subset.trans hst\u2081 htu\u2081,\n      by resetI; convert is_ring_hom.comp (inclusion hst\u2081) (inclusion htu\u2081),\n      by intros; rw [hst\u2083, htu\u2083, inclusion_inclusion]\u27e9 }\n\nprivate structure chain' (c : set (extension K)) : Prop :=\n(chain : chain (\u2264) c)\n\nlocal attribute [class] chain'\n\nlemma is_chain (c : set (extension K)) [chain' _ c]: chain (\u2264) 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\u27e8\u03bb \u27e8i, hi\u27e9 \u27e8j, hj\u27e9, let \u27e8k, hkc, hk\u27e9 := chain.directed_on\n  (is_chain _ c) i hi j hj in \u27e8\u27e8k, hkc\u27e9, hk\u27e9\u27e9\n\ndef chain_map (i j : c) (hij : i \u2264 j) : i.1.carrier \u2192 j.1.carrier :=\ninclusion (exists.elim hij (\u03bb h _, h))\n\ninstance chain_field_hom (i j : c) (hij : i \u2264 j) : is_field_hom (chain_map _ c i j hij) :=\nexists.elim hij (\u03bb _, and.left)\n\ninstance chain_directed_system : directed_system (\u03bb 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 (\u03bb i : c, i.1.carrier) (chain_map _ c)\n\nlemma of_eq_of (x : big_type K) (i j : c) (hi : x \u2208 i.1.carrier) (hj : x \u2208 j.1.carrier) :\n  ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map _ c) i \u27e8x, hi\u27e9 =\n  ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map _ c) j \u27e8x, hj\u27e9 :=\nhave hij : i \u2264 j \u2228 j \u2264 i,\n  from show i.1 \u2264 j.1 \u2228 j.1 \u2264 i.1, from chain.total (is_chain _ c) i.2 j.2,\nhij.elim\n  (\u03bb hij, begin\n    rw \u2190 @ring.direct_limit.of_f c _ _ _ (\u03bb i : c, i.1.carrier) _ _ (chain_map _ c) _\n      _ _ _ hij,\n    simp [chain_map, inclusion]\n  end)\n  (\u03bb hij, begin\n    rw \u2190 @ring.direct_limit.of_f c _ _ _ (\u03bb 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 : \u22c3 i : c, i.1.carrier) (hx : x.1 \u2208 i.1.carrier) (hy : y.1 \u2208 j.1.carrier) :\n  ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map _ c) i \u27e8x, hx\u27e9 =\n  ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map _ c) j \u27e8y, hy\u27e9 \u2192\n  x = y :=\nhave hij : i \u2264 j \u2228 j \u2264 i,\n  from show i.1 \u2264 j.1 \u2228 j.1 \u2264 i.1, from chain.total (is_chain _ c) i.2 j.2,\nhave hinj : \u2200 (i j : c) (hij : i \u2264 j), injective (chain_map _ c i j hij),\n  from \u03bb _ _ _, is_field_hom.injective _,\nhij.elim\n  (\u03bb hij h, begin\n    rw \u2190 @ring.direct_limit.of_f c _ _ _ (\u03bb 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  (\u03bb hji h, begin\n    rw \u2190 @ring.direct_limit.of_f c _ _ _ (\u03bb 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 : (\u22c3 (i : c), i.1.carrier) \u2243\n  ring.direct_limit (\u03bb i : c, i.1.carrier) (chain_map _ c) :=\n@equiv.of_bijective (\u22c3 i : c, i.1.carrier)\n  (ring.direct_limit (\u03bb i : c, i.1.carrier) (chain_map _ c))\n  (\u03bb x, ring.direct_limit.of _ _ (classical.some (set.mem_Union.1 x.2))\n    \u27e8_, classical.some_spec (set.mem_Union.1 x.2)\u27e9)\n  \u27e8\u03bb x y, injective_aux _ _ _ _ _ _ _ _,\n    \u03bb x, let \u27e8i, \u27e8y, hy\u27e9, hy'\u27e9 := ring.direct_limit.exists_of x in\n      \u27e8\u27e8y, _, \u27e8i, rfl\u27e9, hy\u27e9, begin\n        convert hy',\n        exact of_eq_of _ _ _ _ _ _ _\n      end\u27e9\u27e9\n\ninstance Union_field : discrete_field (\u22c3 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 (\u03bb i : c, i.1.carrier) i)) :=\nsuffices inclusion (set.subset_Union (\u03bb i : c, i.1.carrier) i) =\n    ((equiv_direct_limit K c).symm \u2218\n    ring.direct_limit.of (\u03bb i : c, i.1.carrier) (chain_map _ c) i),\n  by rw this; exact is_ring_hom.comp _ _,\nfunext $ \u03bb \u27e8_, _\u27e9,\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) \u2286 \u22c3 i : c, i.1.carrier) :\n  is_field_hom (inclusion h) :=\nlet \u27e8i\u27e9 := hc in\nhave h\u2081 : i.1.carrier \u2286 \u22c3 i : c, i.1.carrier, from set.subset_Union _ i,\nhave h\u2082 : set.range (bembedding K) \u2286 i.1.carrier, from i.1.range_subset,\nhave inclusion h = inclusion h\u2081 \u2218 inclusion h\u2082, by simp [function.comp],\nby rw this; exact is_ring_hom.comp _ _\n\ndef chain_lift [nonempty c] (\u03b1 : Type u) [discrete_field \u03b1] (i : set.range (bembedding K) \u2192 \u03b1)\n  [is_field_hom i] [is_algebraically_closed \u03b1] :\n  (\u22c3 i : c, i.1.carrier) \u2192 \u03b1 :=\n(ring.direct_limit.lift (\u03bb j : c, j.1.carrier) (chain_map _ c) _\n  (\u03bb j : c, j.1.lift i) (\u03bb i j \u27e8_, _, h\u27e9, by introsI; rw [h, chain_map])) \u2218\n  (equiv_direct_limit K c)\n\ndef is_field_hom_chain_lift [nonempty c] (\u03b1 : Type u) [discrete_field \u03b1]\n  (i : set.range (bembedding K) \u2192 \u03b1) [is_field_hom i]\n  [is_algebraically_closed \u03b1] : is_field_hom (chain_lift K c \u03b1 i) :=\nis_ring_hom.comp _ _\n\nend\n\nlemma exists_algebraic_closure : \u2203 m : extension K, \u2200 a, m \u2264 a \u2192 a \u2264 m :=\nby letI := classical.dec; exact\nzorn\n  (\u03bb c hc, if h : nonempty c\n    then by letI : chain' K c := \u27e8hc\u27e9; exact\n      \u27e8{carrier := \u22c3 (i : c), i.1.carrier,\n        range_subset := let \u27e8i\u27e9 := h in\n          have hi : set.range (bembedding K) \u2286 i.1.carrier,\n            from extension.range_subset _,\n          set.subset.trans hi (set.subset_Union (\u03bb i : c, i.1.carrier) i),\n        algebraic := begin\n            rintros \u27e8x, hx\u27e9,\n            cases set.mem_Union.1 hx with i hi,\n            convert @algebraic_comp (set.range (bembedding K)) _ i.1.carrier\n              (\u22c3 i : c, i.1.carrier) _ _ _ _\n              (inclusion i.1.range_subset)\n              (inclusion (set.subset_Union (\u03bb i : c, i.1.carrier) (i : c))) _ _ _\n              (i.1.algebraic \u27e8x, hi\u27e9)\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      \u03bb e he, \u27e8set.subset_Union (\u03bb i : c, i.1.carrier) \u27e8e, he\u27e9,\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 (\u03bb i : c, i.1.carrier) \u27e8e, he\u27e9 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\u27e9\u27e9\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 \u27e8\u27e8set.range (bembedding K), by refl,\n          \u03bb _, by convert algebraic_id _ _; funext; simp, \u03bb _ _ i _ _, i,\n          by introsI; apply_instance, by simp [inclusion]\u27e9,\n        \u03bb a ha, (h \u27e8\u27e8a, ha\u27e9\u27e9).elim\u27e9)\n  (\u03bb _ _ _, 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 \u2192 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) \u2192 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 \u2192 algebraic_closure K :=\ninclusion (classical.some (exists_algebraic_closure K)).range_subset \u2218 \n(of_aux K)\n\ninstance : is_ring_hom (of K) :=\nbegin \n  haveI h\u2081 := (classical.some (exists_algebraic_closure K)).is_field_hom,\n  letI h\u2082 : 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\u2081\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 \u27e8f, hf\u27e9 := (classical.some (exists_algebraic_closure K)).algebraic x in\n\u27e8f.map (of_aux_symm K), mt (map_eq_zero _).1 hf.1,\n  calc eval\u2082 (of K) x (f.map (of_aux_symm K)) = eval\u2082 (\u03bb x, of K (of_aux_symm K x)) x f :\n    sorry\n\n  ... = 0 : sorry\n  \u27e9\n -- eval\u2082_map (of_aux_symm K) (of K) x).trans _\n\ndef lift_aux {L : Type u} [discrete_field L] (i : set.range (bembedding K) \u2192 L)\n  [is_field_hom i] [is_algebraically_closed L] :\n  algebraic_closure K \u2192 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) \u2192 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 \u21aa Y) (fxz : X \u21aa Z)\n  (hYZ : (Z \u21aa Y) \u2192 false) : \u21a5-range fxy.1 \u21aa \u21a5-range fxz.1 :=\nclassical.choice $ or.resolve_left embedding.total $\n  \u03bb \u27e8f\u27e9, hYZ $\n    calc Z \u21aa range fxz \u2295 \u21a5-range fxz :\n      (equiv.set.sum_compl _).symm.to_embedding\n    ... \u21aa range fxy \u2295 \u21a5-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    ... \u21aa Y : (equiv.set.sum_compl _).to_embedding\n\ndef map {X : Type u} {Y : Type v} {Z : Type w} (fxy : X \u21aa Y) (fxz : X \u21aa Z)\n  (hYZ : (Z \u21aa Y) \u2192 false) : Y \u21aa Z :=\ncalc Y \u21aa range fxy \u2295 \u21a5-range fxy : (equiv.set.sum_compl _).symm.to_embedding\n... \u21aa range fxz \u2295 \u21a5-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... \u21aa Z : (equiv.set.sum_compl _).to_embedding\n\nlemma map_commutes {X : Type u} {Y : Type v} {Z : Type w}  (fxy : X \u21aa Y) (fxz : X \u21aa Z)\n  (hYZ : (Z \u21aa Y) \u2192 false) (x : X) : map fxy fxz hYZ (fxy x) = fxz x :=\nhave (\u27e8fxy x, mem_range_self _\u27e9 : 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 \u2218 of K) := is_ring_hom.comp _ _\n\ndef adjoin_root.of_embedding : algebraic_closure K \u21aa adjoin_root f :=\n\u27e8adjoin_root.of, is_field_hom.injective _\u27e9\n\ndef adjoin_root_extension_map : adjoin_root f \u21aa big_type K :=\n(map (adjoin_root.of_embedding K f) \n    \u27e8subtype.val, subtype.val_injective\u27e9 \n  (\u03bb i, cantor_injective _ (show big_type K \u21aa \u2115 \u00d7 polynomial K,\n    from i.trans \u27e8big_type_map K (@adjoin_root.of _ _ _ f \u2218 of K)\n        (algebraic_comp' K _ _ (of_algebraic K) (algebraic_adjoin_root _ f)), \n      big_type_map_injective _ _ _\u27e9).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 \u2286 set.range (adjoin_root_extension_map K f) :=\n(\u03bb x h, \u27e8adjoin_root.of_embedding K f \u27e8x, h\u27e9, \n  show (adjoin_root_extension_map K f) \n      (adjoin_root.of_embedding K f \u27e8x, h\u27e9) = \n      (\u27e8x, h\u27e9 : algebraic_closure K).val, \n    from map_commutes _ _ _ _\u27e9)\n\nlemma adjoin_root_range_subset : \n  (set.range (bembedding K)) \u2286 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) \u2218 \n  (@adjoin_root.of (algebraic_closure K) _ _ f) \u2218 \n  inclusion (classical.some (exists_algebraic_closure K)).range_subset :=\nfunext $ \u03bb 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) \u2218\n  (@adjoin_root.of (algebraic_closure K) _ _ f) :=\nfunext $ \u03bb 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, \u2190 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 {\u03b1 : Type u} [_inst_2_1 : discrete_field \u03b1] (i : (range \u21d1(bembedding K)) \u2192 \u03b1)\n  [is_field_hom i] [is_algebraically_closed \u03b1] :\n  (range \u21d1(adjoin_root_extension_map K f)) \u2192 \u03b1 :=\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 [\u2190 eval_map]; \n    exact (classical.some_spec h)) \u2218 \n  (equiv.set.range _ (adjoin_root_extension_map K f).2).symm\nend\n\nlemma adjoin_root_lift.is_ring_hom {\u03b1 : Type u} [_inst_2_1 : discrete_field \u03b1] \n  (i : (range \u21d1(bembedding K)) \u2192 \u03b1) [is_field_hom i] [is_algebraically_closed \u03b1] :\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 [\u2190 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, \u2190 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 \u2264 adjoin_root_extension K f :=\nby letI : discrete_field (closed_extension K).carrier := extension.field _; exact\n\u27e8closure_subset_adjoin_root K f, by rw [adjoin_root_inclusion_eq'];\n  exact is_ring_hom.comp _ _, begin\n  introsI,\n\nend\u27e9\n\ninstance : is_algebraically_closed (algebraic_closure K) :=\n\u27e8\u03bb f hf0, let \u27e8g, hg\u27e9 := is_noetherian_ring.exists_irreducible_factor \n    (show \u00ac is_unit f, from \u03bb h, by rw [is_unit_iff_degree_eq_zero] at h;\n      rw h at hf0; exact lt_irrefl _ hf0) \n    (\u03bb h, by rw [\u2190 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\u27e9 \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}} (\ud835\udcd5 : sheaf Ab X) (U V : X.oc)\n\ndef d_from_to (i j : \u2115) : C \ud835\udcd5 U i \u27f6 C \ud835\udcd5 U j :=\ndite (j = i + 1)\n(\u03bb h, d \ud835\udcd5 U i \u226b eq_to_hom (by rw h))\n(\u03bb h, 0)\n\nlemma d_to_succ {i : \u2115} (f \u03b1) :\n  d_from_to \ud835\udcd5 U i (i + 1) f \u03b1 = d \ud835\udcd5 U i f \u03b1 :=\nbegin\n  rw [d_from_to],\n  rw dif_pos rfl,\n  rw comp_apply,\n  refl,\nend\n\nlemma d_to_succ' (i : \u2115) :\n  d_from_to \ud835\udcd5 U i (i + 1) = d \ud835\udcd5 U i :=\nbegin\n  ext f \u03b1,\n  rw d_to_succ,\nend\n\nlemma d_not_to_succ {i j : \u2115} (h : j \u2260 i + 1) (f \u03b1) :\n  d_from_to \ud835\udcd5 U i j f \u03b1 = 0 :=\nbegin\n  rw [d_from_to, dif_neg h],\n  refl,\nend\n\ndef Cech_complex_wrt_cover_unordered : cochain_complex Ab.{u} \u2115 :=\n{ X := \u03bb n, C \ud835\udcd5 U (n + 1),\n  d := \u03bb i j, d_from_to \ud835\udcd5 U (i + 1) (j + 1),\n  shape' := \u03bb i j h, begin\n    ext f \u03b1,\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' := \u03bb 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 \u03b1,\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 : \u2115) (m) (h : (complex_shape.up \u2115).prev n = some m) :\n  (Cech_complex_wrt_cover_unordered \ud835\udcd5 U).d m.1 n =\n  d \ud835\udcd5 U (m.1 + 1) \u226b 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 \ud835\udcd5 U _ _ = _,\n  rw [d_from_to, dif_pos],\n  refl,\n  have h2 := m.2.symm,\n  rw \u2190 h2,\nend\n\ndef Cech_Cohomology_Group_wrt_cover_unordered_nth (n : \u2115) : Ab.{u} :=\n@homological_complex.homology \u2115 Ab _ _ (complex_shape.up \u2115) (abelian.has_zero_object) _ _ _\n  (Cech_complex_wrt_cover_unordered \ud835\udcd5 U) n\n\nsection\n\nvariables {U V} (r : U \u27f6 V)\n\ninclude r\ndef Cech_complex_wrt_cover_unordered.prev (n : \u2115) :\n  @homological_complex.X_prev _ _ _ _ (complex_shape.up \u2115) \n    (Cech_complex_wrt_cover_unordered \ud835\udcd5 V)\n    (abelian.has_zero_object) n \u27f6\n  @homological_complex.X_prev _ _ _ _ (complex_shape.up \u2115)\n    (Cech_complex_wrt_cover_unordered \ud835\udcd5 U)\n    (abelian.has_zero_object) n :=\nmatch (complex_shape.up \u2115).prev n with\n| none := 0\n| some m := begin\n  refine _ \u226b @C.refine X \ud835\udcd5 _ _ (m.1 + 1) r \u226b _,\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 \ud835\udcd5 U) (abelian.has_zero_object) m.2).inv,\nend\nend\n\nlemma Cech_complex_wrt_cover_unordered.prev_none (n : \u2115)\n  (h : (complex_shape.up \u2115).prev n = none) :\n  Cech_complex_wrt_cover_unordered.prev \ud835\udcd5 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 : \u2115) (m)\n  (h : (complex_shape.up \u2115).prev n = some m) :\n  Cech_complex_wrt_cover_unordered.prev \ud835\udcd5 r n = \n  (@@homological_complex.X_prev_iso _ _ _ (abelian.has_zero_object) m.2).hom \u226b \n    @C.refine X \ud835\udcd5 _ _ (m.1 + 1) r \u226b \n    (@@homological_complex.X_prev_iso _ _ (Cech_complex_wrt_cover_unordered \ud835\udcd5 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 : \u2115) : (complex_shape.up \u2115).next n = some \u27e8n+1, rfl\u27e9 :=\nbegin\n  rw [complex_shape.next_eq_some],\nend\n\ndef Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement (n : \u2115) :\n  Cech_Cohomology_Group_wrt_cover_unordered_nth \ud835\udcd5 V n \u27f6\n  Cech_Cohomology_Group_wrt_cover_unordered_nth \ud835\udcd5 U n :=\nhomology.map _ _ \n{ left := Cech_complex_wrt_cover_unordered.prev \ud835\udcd5 r n,\n  right := C.refine r,\n  w' := begin\n    simp only [category_theory.functor.id_map, arrow.mk_hom],\n    ext f \u03b1,\n    rw [comp_apply, comp_apply],\n    by_cases h : (complex_shape.up \u2115).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 _ \u2260 _ at h,\n      rw option.ne_none_iff_exists at h,\n      rcases h with \u27e8m, hm\u27e9,\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 \u2190 C.refine_d_eq_d_refine',\n      \n      simp only [\u2190 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 \ud835\udcd5 V) \n      (abelian.has_zero_object) \n      (rfl : n + 1 = n + 1)).hom \u226b \n      C.refine r \u226b \n      (@@homological_complex.X_next_iso _ _ (Cech_complex_wrt_cover_unordered \ud835\udcd5 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 \u03b1,\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 [\u2190 comp_apply],\n    congr' 1,\n    simp only [\u2190 category.assoc],\n    apply eq_whisker,\n    change C.refine r \u226b d_from_to \ud835\udcd5 U _ _ = _,\n    rw d_to_succ',\n    change _ = d_from_to _ _ _ _ \u226b 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 : \u2115) :\n  X.oc\u1d52\u1d56 \u2964 Ab.{u} :=\n{ obj := \u03bb U, Cech_Cohomology_Group_wrt_cover_unordered_nth \ud835\udcd5 U.unop n,\n  map := \u03bb U V r, Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement \ud835\udcd5 r.unop n,\n  map_id' := \u03bb U, begin\n    rw [Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement],\n    ext f,\n    simp only [unop_id, homology.\u03c0_map, comp_apply, id_apply],\n    congr',\n    sorry\n  end,\n  map_comp' := sorry }\n\ninclude \ud835\udcd5\ndef Cech_Cohomology_Group_nth (n : \u2115) : Ab :=\nlimits.colim.obj $ (Cech_Cohomology_Group_wrt_cover_unordered_nth.refinement_functor \ud835\udcd5 r n) \u22d9 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes H\u00f6lzl\n\nLinear structures on function with finite support `\u03b9 \u2192\u2080 \u03b2`.\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} {\u03b9 : Type u_3} [ring R] [add_comm_group M] [module R M] {\u03c6 : \u03b9 \u2192 Type u_4} {f : (\u03b9 : \u03b9) \u2192 \u03c6 \u03b9 \u2192 M} (hf : \u2200 (i : \u03b9), linear_independent R (f i)) : linear_independent R fun (ix : sigma fun (i : \u03b9) => \u03c6 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} {\u03b9 : Type u_3} [ring R] [add_comm_group M] [module R M] {\u03c6 : \u03b9 \u2192 Type u_4} (f : (\u03b9 : \u03b9) \u2192 \u03c6 \u03b9 \u2192 M) (hf : \u2200 (i : \u03b9), is_basis R (f i)) : is_basis R fun (ix : sigma fun (i : \u03b9) => \u03c6 i) => single (sigma.fst ix) (f (sigma.fst ix) (sigma.snd ix)) := sorry\n\ntheorem is_basis_single_one {R : Type u_1} {\u03b9 : Type u_3} [ring R] : is_basis R fun (i : \u03b9) => single i 1 := sorry\n\n/-- If b : \u03b9 \u2192 M and c : \u03ba \u2192 N are bases then so is \u03bb i, b i.1 \u2297\u209c c i.2 : \u03b9 \u00d7 \u03ba \u2192 M \u2297 N. -/\ntheorem is_basis.tensor_product {R : Type u_1} {M : Type u_2} {N : Type u_3} {\u03b9 : Type u_4} {\u03ba : Type u_5} [comm_ring R] [add_comm_group M] [module R M] [add_comm_group N] [module R N] {b : \u03b9 \u2192 M} (hb : is_basis R b) {c : \u03ba \u2192 N} (hc : is_basis R c) : is_basis R fun (i : \u03b9 \u00d7 \u03ba) => tensor_product.tmul R (b (prod.fst i)) (c (prod.snd i)) := sorry\n\ntheorem dim_eq {K : Type u} {V : Type v} {\u03b9 : Type v} [field K] [add_comm_group V] [vector_space K V] : vector_space.dim K (\u03b9 \u2192\u2080 V) = cardinal.mk \u03b9 * 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\u2081 : Type v} {V\u2082 : Type v} [field K] [add_comm_group V\u2081] [vector_space K V\u2081] [add_comm_group V\u2082] [vector_space K V\u2082] (h : vector_space.dim K V\u2081 = vector_space.dim K V\u2082) : linear_equiv K V\u2081 V\u2082 :=\n  Classical.choice sorry\n\n/-- An `n`-dimensional `K`-vector space is equivalent to `fin n \u2192 K`. -/\ndef fin_dim_vectorspace_equiv {K : Type u} {V : Type v} [field K] [add_comm_group V] [vector_space K V] (n : \u2115) (hn : vector_space.dim K V = \u2191n) : linear_equiv K V (fin n \u2192 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 \u21a5p = 0) : p = \u22a5 :=\n  let e : linear_equiv K \u21a5p \u21a5\u22a5 :=\n    equiv_of_dim_eq_dim (eq.mpr (id (Eq._oldrec (Eq.refl (vector_space.dim K \u21a5p = vector_space.dim K \u21a5\u22a5)) dim_bot)) h);\n  linear_equiv.eq_bot_of_equiv p e\n\ntheorem injective_of_surjective {K : Type u} {V\u2081 : Type v} {V\u2082 : Type v} [field K] [add_comm_group V\u2081] [vector_space K V\u2081] [add_comm_group V\u2082] [vector_space K V\u2082] (f : linear_map K V\u2081 V\u2082) (hV\u2081 : vector_space.dim K V\u2081 < cardinal.omega) (heq : vector_space.dim K V\u2082 = vector_space.dim K V\u2081) (hf : linear_map.range f = \u22a4) : linear_map.ker f = \u22a5 := 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 : \u2115) (p : preform) : clauses.unsat (dnf (preform.not p)) \u2192 univ_close p (fun (x : \u2115) => 0) m :=\n  fun (\u1fb0 : clauses.unsat (dnf (preform.not p))) =>\n    idRhs (univ_close p (fun (x : \u2115) => 0) m) (univ_close_of_valid (valid_of_unsat_not (unsat_of_clauses_unsat \u1fb0)))\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\u2081 P\u2082` (notation: `P\u2081 \u2243\u1d43[k] P\u2082`) to be the type of affine\nequivalences between `P\u2081` and `P\u2082, 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\u2081 P\u2082 : Type _) {V\u2081 V\u2082 : Type _} [Ring k] [AddCommGroup V\u2081] [Module k V\u2081]\n  [AddTorsor V\u2081 P\u2081] [AddCommGroup V\u2082] [Module k V\u2082] [AddTorsor V\u2082 P\u2082] extends P\u2081 \u2243 P\u2082 where\n  linear : V\u2081 \u2243\u2097[k] V\u2082\n  map_vadd' : \u2200 (p : P\u2081) (v : V\u2081), to_equiv (v +\u1d65 p) = linear v +\u1d65 to_equiv p\n#align affine_equiv AffineEquiv\n-/\n\n-- mathport name: \u00abexpr \u2243\u1d43[ ] \u00bb\nnotation:25 P\u2081 \" \u2243\u1d43[\" k:25 \"] \" P\u2082:0 => AffineEquiv k P\u2081 P\u2082\n\nvariable {k P\u2081 P\u2082 P\u2083 P\u2084 V\u2081 V\u2082 V\u2083 V\u2084 : Type _} [Ring k] [AddCommGroup V\u2081] [Module k V\u2081]\n  [AddTorsor V\u2081 P\u2081] [AddCommGroup V\u2082] [Module k V\u2082] [AddTorsor V\u2082 P\u2082] [AddCommGroup V\u2083]\n  [Module k V\u2083] [AddTorsor V\u2083 P\u2083] [AddCommGroup V\u2084] [Module k V\u2084] [AddTorsor V\u2084 P\u2084]\n\nnamespace AffineEquiv\n\ninclude V\u2081 V\u2082\n\n#print AffineEquiv.toAffineMap /-\n/-- Reinterpret an `affine_equiv` as an `affine_map`. -/\ndef toAffineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192\u1d43[k] P\u2082 :=\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (f : Equiv.{succ u2, succ u3} P\u2081 P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (h : forall (p : P\u2081) (v : V\u2081), Eq.{succ u3} P\u2082 (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) f (VAdd.vadd.{u4, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u4, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u4} V\u2081 (AddGroup.toSubNegMonoid.{u4} V\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4)) v p)) (VAdd.vadd.{u5, u3} V\u2082 P\u2082 (AddAction.toHasVadd.{u5, u3} V\u2082 P\u2082 (SubNegMonoid.toAddMonoid.{u5} V\u2082 (AddGroup.toSubNegMonoid.{u5} V\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5))) (AddTorsor.toAddAction.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) => V\u2081 -> V\u2082) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) f p))), Eq.{max (succ u4) (succ u2) (succ u5) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.mk.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) 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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (CoeTC\u2093.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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (LinearEquiv.LinearMap.hasCoe.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 : Type.{u5}} {P\u2082 : Type.{u4}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u4} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (f : Equiv.{succ u5, succ u4} P\u2081 P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (h : forall (p : P\u2081) (v : V\u2081), Eq.{succ u4} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) (HVAdd.hVAdd.{u2, u5, u5} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u5} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u5} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v p)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) f (HVAdd.hVAdd.{u2, u5, u5} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u5} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u5} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v p)) (HVAdd.hVAdd.{u1, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) (instHVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) (AddAction.toVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) _inst_5))) (AddTorsor.toAddAction.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) 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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) V\u2081 (fun (_x : V\u2081) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (SMulZeroClass.toSMul.{u3, u2} k V\u2081 (AddMonoid.toZero.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V\u2081 (AddMonoid.toAddZeroClass.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V\u2081 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V\u2082 (AddMonoid.toZero.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V\u2082 (AddMonoid.toAddZeroClass.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) f p))), Eq.{max (max (max (succ u5) (succ u4)) (succ u2)) (succ u1)} (AffineMap.{u3, u2, u5, u1, u4} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u3, u5, u4, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.mk.{u3, u5, u4, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) 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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2093'. -/\n@[simp]\ntheorem toAffineMap_mk (f : P\u2081 \u2243 P\u2082) (f' : V\u2081 \u2243\u2097[k] V\u2082) (h) :\n    toAffineMap (mk f f' h) = \u27e8f, f', h\u27e9 :=\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (AffineMap.linear.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (CoeTC\u2093.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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (LinearEquiv.LinearMap.hasCoe.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (AffineMap.linear.{u5, u2, u4, u1, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6 (AffineEquiv.linear.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem linear_toAffineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u5}} {P\u2082 : Type.{u4}} {V\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u2} V\u2082] [_inst_6 : Module.{u1, u2} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u2, u4} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u3, u5, u2, u4} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u5, u4, u3, u2} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\ntheorem toAffineMap_injective : Injective (toAffineMap : (P\u2081 \u2243\u1d43[k] P\u2082) \u2192 P\u2081 \u2192\u1d43[k] P\u2082) :=\n  by\n  rintro \u27e8e, el, h\u27e9 \u27e8e', el', h'\u27e9 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] {e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] {e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem toAffineMap_inj {e e' : P\u2081 \u2243\u1d43[k] P\u2082} : e.toAffineMap = e'.toAffineMap \u2194 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\u2081 \u2243\u1d43[k] P\u2082) P\u2081 P\u2082\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\u2081 \u2243\u1d43[k] P\u2082) fun _ => P\u2081 \u2192 P\u2082 :=\n  FunLike.hasCoeToFun\n\ninstance : Coe (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2243 P\u2082) :=\n  \u27e8AffineEquiv.toEquiv\u27e9\n\nvariable {k P\u2081}\n\n/- warning: affine_equiv.map_vadd -> AffineEquiv.map_vadd is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P\u2081) (v : V\u2081), Eq.{succ u3} P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e (VAdd.vadd.{u4, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u4, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u4} V\u2081 (AddGroup.toSubNegMonoid.{u4} V\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4)) v p)) (VAdd.vadd.{u5, u3} V\u2082 P\u2082 (AddAction.toHasVadd.{u5, u3} V\u2082 P\u2082 (SubNegMonoid.toAddMonoid.{u5} V\u2082 (AddGroup.toSubNegMonoid.{u5} V\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5))) (AddTorsor.toAddAction.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) => V\u2081 -> V\u2082) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P\u2081) (v : V\u2081), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) (HVAdd.hVAdd.{u2, u4, u4} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u4} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u4} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e (HVAdd.hVAdd.{u2, u4, u4} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u4} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u4} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v p)) (HVAdd.hVAdd.{u1, u3, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) p) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) p) (instHVAdd.{u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) p) (AddAction.toVAdd.{u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) p) (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) _inst_5))) (AddTorsor.toAddAction.{u1, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) p) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) 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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) V\u2081 (fun (_x : V\u2081) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (SMulZeroClass.toSMul.{u5, u2} k V\u2081 (AddMonoid.toZero.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribSMul.toSMulZeroClass.{u5, u2} k V\u2081 (AddMonoid.toAddZeroClass.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribMulAction.toDistribSMul.{u5, u2} k V\u2081 (MonoidWithZero.toMonoid.{u5} k (Semiring.toMonoidWithZero.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (Module.toDistribMulAction.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u5, u1} k V\u2082 (AddMonoid.toZero.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribSMul.toSMulZeroClass.{u5, u1} k V\u2082 (AddMonoid.toAddZeroClass.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribMulAction.toDistribSMul.{u5, u1} k V\u2082 (MonoidWithZero.toMonoid.{u5} k (Semiring.toMonoidWithZero.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (MonoidWithZero.toMonoid.{u5} k (Semiring.toMonoidWithZero.{u5} k (Ring.toSemiring.{u5} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3) (Module.toDistribMulAction.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u5, u2, u1, max u2 u1} k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u5, u5, u2, u1, max u2 u1} k k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem map_vadd (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2081) (v : V\u2081) : e (v +\u1d65 p) = e.linear v +\u1d65 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u2) (succ u3)} (P\u2081 -> P\u2082) (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (forall (\u1fb0 : P\u2081), (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) \u1fb0) (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (Equiv.{succ u4, succ u3} P\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u4, succ u3} P\u2081 P\u2082) (AffineEquiv.toEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem coe_toEquiv (e : P\u2081 \u2243\u1d43[k] P\u2082) : \u21d1e.toEquiv = e :=\n  rfl\n#align affine_equiv.coe_to_equiv AffineEquiv.coe_toEquiv\n\ninstance : Coe (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2192\u1d43[k] P\u2082) :=\n  \u27e8toAffineMap\u27e9\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineMap.hasCoeToFun.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (forall (a : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) 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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) _x) (AffineMap.funLike.{u5, u2, u4, u1, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem coe_toAffineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) : (e.toAffineMap : P\u2081 \u2192 P\u2082) = (e : P\u2081 \u2192 P\u2082) :=\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) ((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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (CoeTC\u2093.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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineMap.hasCoeToFun.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (CoeTC\u2093.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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{max (succ u4) (succ u3)} (forall (a : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) 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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) _x) (AffineMap.funLike.{u5, u2, u4, u1, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[norm_cast, simp]\ntheorem coe_coe (e : P\u2081 \u2243\u1d43[k] P\u2082) : ((e : P\u2081 \u2192\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082) = 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (AffineMap.linear.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (CoeTC\u2093.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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (CoeTC\u2093.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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (LinearEquiv.LinearMap.hasCoe.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (AffineMap.linear.{u5, u2, u4, u1, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.toAffineMap.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6 (AffineEquiv.linear.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem coe_linear (e : P\u2081 \u2243\u1d43[k] P\u2082) : (e : P\u2081 \u2192\u1d43[k] P\u2082).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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] {e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, (forall (x : P\u2081), Eq.{succ u3} P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] {e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, (forall (x : P\u2081), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) 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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[ext]\ntheorem ext {e e' : P\u2081 \u2243\u1d43[k] P\u2082} (h : \u2200 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\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2192 P\u2082) 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] {e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) e) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] {e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7}, Iff (Eq.{max (succ u4) (succ u3)} (forall (a : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) 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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp, norm_cast]\ntheorem coeFn_inj {e e' : P\u2081 \u2243\u1d43[k] P\u2082} : (e : P\u2081 \u2192 P\u2082) = e' \u2194 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (Equiv.{succ u2, succ u3} P\u2081 P\u2082) (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u5}} {P\u2082 : Type.{u4}} {V\u2081 : Type.{u3}} {V\u2082 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u2} V\u2082] [_inst_6 : Module.{u1, u2} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u2, u4} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (Equiv.{succ u5, succ u4} P\u2081 P\u2082) (AffineEquiv.toEquiv.{u1, u5, u4, u3, u2} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\ntheorem toEquiv_injective : Injective (toEquiv : (P\u2081 \u2243\u1d43[k] P\u2082) \u2192 P\u2081 \u2243 P\u2082) := 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] {e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082) (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] {e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} {e' : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082) (AffineEquiv.toEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) (AffineEquiv.toEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem toEquiv_inj {e e' : P\u2081 \u2243\u1d43[k] P\u2082} : e.toEquiv = e'.toEquiv \u2194 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : Equiv.{succ u2, succ u3} P\u2081 P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (h : forall (p : P\u2081) (v : V\u2081), Eq.{succ u3} P\u2082 (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) e (VAdd.vadd.{u4, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u4, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u4} V\u2081 (AddGroup.toSubNegMonoid.{u4} V\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4)) v p)) (VAdd.vadd.{u5, u3} V\u2082 P\u2082 (AddAction.toHasVadd.{u5, u3} V\u2082 P\u2082 (SubNegMonoid.toAddMonoid.{u5} V\u2082 (AddGroup.toSubNegMonoid.{u5} V\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5))) (AddTorsor.toAddAction.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) => V\u2081 -> V\u2082) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) e p))), Eq.{max (succ u2) (succ u3)} ((fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.mk.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.mk.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) e)\nbut is expected to have type\n  forall {k : Type.{u3}} {P\u2081 : Type.{u5}} {P\u2082 : Type.{u4}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u4} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : Equiv.{succ u5, succ u4} P\u2081 P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (h : forall (p : P\u2081) (v : V\u2081), Eq.{succ u4} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) (HVAdd.hVAdd.{u2, u5, u5} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u5} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u5} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v p)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e (HVAdd.hVAdd.{u2, u5, u5} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u5} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u5} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v p)) (HVAdd.hVAdd.{u1, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) (instHVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) (AddAction.toVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) _inst_5))) (AddTorsor.toAddAction.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) v) ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) p) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) 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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) V\u2081 (fun (_x : V\u2081) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (SMulZeroClass.toSMul.{u3, u2} k V\u2081 (AddMonoid.toZero.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V\u2081 (AddMonoid.toAddZeroClass.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V\u2081 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V\u2082 (AddMonoid.toZero.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V\u2082 (AddMonoid.toAddZeroClass.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e p))), Eq.{max (succ u5) (succ u4)} (forall (a : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) 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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u3, u5, u4, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) (AffineEquiv.mk.{u3, u5, u4, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_mk AffineEquiv.coe_mk\u2093'. -/\n@[simp]\ntheorem coe_mk (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (h) : ((\u27e8e, e', h\u27e9 : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082) = 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : P\u2081 -> P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (p : P\u2081), (forall (p' : P\u2081), Eq.{succ u3} P\u2082 (e p') (VAdd.vadd.{u5, u3} V\u2082 P\u2082 (AddAction.toHasVadd.{u5, u3} V\u2082 P\u2082 (SubNegMonoid.toAddMonoid.{u5} V\u2082 (AddGroup.toSubNegMonoid.{u5} V\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5))) (AddTorsor.toAddAction.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) => V\u2081 -> V\u2082) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2081 (AddTorsor.toHasVsub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) (e p))) -> (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : P\u2081 -> P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (p : P\u2081), (forall (p' : P\u2081), Eq.{succ u3} P\u2082 (e p') (HVAdd.hVAdd.{u5, u3, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u4, u2} V\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 P\u2082 (instHVAdd.{u5, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u4, u2} V\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (AddAction.toVAdd.{u5, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u4, u2} V\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (SubNegMonoid.toAddMonoid.{u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u4, u2} V\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) (AddGroup.toSubNegMonoid.{u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u4, u2} V\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) (AddCommGroup.toAddGroup.{u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u4, u2} V\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) _inst_5))) (AddTorsor.toAddAction.{u5, u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u4, u2} V\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (AddCommGroup.toAddGroup.{u5} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u4, u2} V\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) V\u2081 (fun (_x : V\u2081) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (SMulZeroClass.toSMul.{u1, u4} k V\u2081 (AddMonoid.toZero.{u4} V\u2081 (AddCommMonoid.toAddMonoid.{u4} V\u2081 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2))) (DistribSMul.toSMulZeroClass.{u1, u4} k V\u2081 (AddMonoid.toAddZeroClass.{u4} V\u2081 (AddCommMonoid.toAddMonoid.{u4} V\u2081 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2))) (DistribMulAction.toDistribSMul.{u1, u4} k V\u2081 (MonoidWithZero.toMonoid.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AddCommMonoid.toAddMonoid.{u4} V\u2081 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)) (Module.toDistribMulAction.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u1, u5} k V\u2082 (AddMonoid.toZero.{u5} V\u2082 (AddCommMonoid.toAddMonoid.{u5} V\u2082 (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5))) (DistribSMul.toSMulZeroClass.{u1, u5} k V\u2082 (AddMonoid.toAddZeroClass.{u5} V\u2082 (AddCommMonoid.toAddMonoid.{u5} V\u2082 (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5))) (DistribMulAction.toDistribSMul.{u1, u5} k V\u2082 (MonoidWithZero.toMonoid.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AddCommMonoid.toAddMonoid.{u5} V\u2082 (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)) (Module.toDistribMulAction.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (MonoidWithZero.toMonoid.{u1} k (Semiring.toMonoidWithZero.{u1} k (Ring.toSemiring.{u1} k _inst_1))) (AddCommMonoid.toAddMonoid.{u4} V\u2081 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)) (AddCommMonoid.toAddMonoid.{u5} V\u2082 (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)) (Module.toDistribMulAction.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_3) (Module.toDistribMulAction.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u1, u4, u5, max u4 u5} k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u1, u1, u4, u5, max u4 u5} k k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2081 (AddTorsor.toVSub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2) _inst_4) p' p)) (e p))) -> (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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'\u2093'. -/\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\u2081 \u2192 P\u2082`, a linear equivalence\n`e' : V\u2081 \u2243\u2097[k] V\u2082`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -\u1d65 p) +\u1d65 e p`. -/\ndef mk' (e : P\u2081 \u2192 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (p : P\u2081) (h : \u2200 p' : P\u2081, e p' = e' (p' -\u1d65 p) +\u1d65 e p) :\n    P\u2081 \u2243\u1d43[k] P\u2082 where\n  toFun := e\n  invFun := fun q' : P\u2082 => e'.symm (q' -\u1d65 e p) +\u1d65 p\n  left_inv p' := by simp [h p']\n  right_inv q' := by simp [h (e'.symm (q' -\u1d65 e p) +\u1d65 p)]\n  linear := e'\n  map_vadd' p' v := by simp [h p', h (v +\u1d65 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : Equiv.{succ u2, succ u3} P\u2081 P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (p : P\u2081) (h : forall (p' : P\u2081), Eq.{succ u3} P\u2082 (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) e p') (VAdd.vadd.{u5, u3} V\u2082 P\u2082 (AddAction.toHasVadd.{u5, u3} V\u2082 P\u2082 (SubNegMonoid.toAddMonoid.{u5} V\u2082 (AddGroup.toSubNegMonoid.{u5} V\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5))) (AddTorsor.toAddAction.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) => V\u2081 -> V\u2082) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2081 (AddTorsor.toHasVsub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) e p))), Eq.{max (succ u2) (succ u3)} (P\u2081 -> P\u2082) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.mk'.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) 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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) e)\nbut is expected to have type\n  forall {k : Type.{u3}} {P\u2081 : Type.{u5}} {P\u2082 : Type.{u4}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u4} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : Equiv.{succ u5, succ u4} P\u2081 P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (p : P\u2081) (h : forall (p' : P\u2081), Eq.{succ u4} P\u2082 (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e p') (HVAdd.hVAdd.{u1, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 P\u2082 (instHVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (AddAction.toVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) _inst_5))) (AddTorsor.toAddAction.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) V\u2081 (fun (_x : V\u2081) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (SMulZeroClass.toSMul.{u3, u2} k V\u2081 (AddMonoid.toZero.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V\u2081 (AddMonoid.toAddZeroClass.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V\u2081 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V\u2082 (AddMonoid.toZero.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V\u2082 (AddMonoid.toAddZeroClass.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e p))), Eq.{max (succ u5) (succ u4)} (forall (\u1fb0 : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) \u1fb0) (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u3, u5, u4, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) (AffineEquiv.mk'.{u3, u5, u4, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e) e' p h)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_mk' AffineEquiv.coe_mk'\u2093'. -/\n@[simp]\ntheorem coe_mk' (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (p h) : \u21d1(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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : Equiv.{succ u2, succ u3} P\u2081 P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (p : P\u2081) (h : forall (p' : P\u2081), Eq.{succ u3} P\u2082 (coeFn.{max 1 (max (succ u2) (succ u3)) (succ u3) (succ u2), max (succ u2) (succ u3)} (Equiv.{succ u2, succ u3} P\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) e p') (VAdd.vadd.{u5, u3} V\u2082 P\u2082 (AddAction.toHasVadd.{u5, u3} V\u2082 P\u2082 (SubNegMonoid.toAddMonoid.{u5} V\u2082 (AddGroup.toSubNegMonoid.{u5} V\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5))) (AddTorsor.toAddAction.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) => V\u2081 -> V\u2082) (LinearEquiv.hasCoeToFun.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2081 (AddTorsor.toHasVsub.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) 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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) _inst_3 _inst_6) (AffineEquiv.linear.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.mk'.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082) (fun (_x : Equiv.{succ u2, succ u3} P\u2081 P\u2082) => P\u2081 -> P\u2082) (Equiv.hasCoeToFun.{succ u2, succ u3} P\u2081 P\u2082) e) e' p h)) e'\nbut is expected to have type\n  forall {k : Type.{u3}} {P\u2081 : Type.{u5}} {P\u2082 : Type.{u4}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u4} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : Equiv.{succ u5, succ u4} P\u2081 P\u2082) (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (p : P\u2081) (h : forall (p' : P\u2081), Eq.{succ u4} P\u2082 (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e p') (HVAdd.hVAdd.{u1, u4, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 P\u2082 (instHVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (AddAction.toVAdd.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (SubNegMonoid.toAddMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) (AddGroup.toSubNegMonoid.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) _inst_5))) (AddTorsor.toAddAction.{u1, u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) P\u2082 (AddCommGroup.toAddGroup.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) (VSub.vsub.{u2, u5} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) V\u2081 (fun (_x : V\u2081) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (SMulZeroClass.toSMul.{u3, u2} k V\u2081 (AddMonoid.toZero.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V\u2081 (AddMonoid.toAddZeroClass.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V\u2081 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V\u2082 (AddMonoid.toZero.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V\u2082 (AddMonoid.toAddZeroClass.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 P\u2081 (AddTorsor.toVSub.{u2, u5} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) p' p)) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (Equiv.{succ u5, succ u4} P\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) 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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (AffineEquiv.linear.{u3, u5, u4, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.mk'.{u3, u5, u4, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082) P\u2081 (fun (_x : P\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : P\u2081) => P\u2082) _x) (Equiv.instFunLikeEquiv.{succ u5, succ u4} P\u2081 P\u2082) e) e' p h)) e'\nCase conversion may be inaccurate. Consider using '#align affine_equiv.linear_mk' AffineEquiv.linear_mk'\u2093'. -/\n@[simp]\ntheorem linear_mk' (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (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\u2081 \u2243\u1d43[k] P\u2082) : P\u2082 \u2243\u1d43[k] P\u2081\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 P\u2081) (Equiv.symm.{succ u2, succ u3} P\u2081 P\u2082 (AffineEquiv.toEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.toEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 P\u2081) (Equiv.symm.{succ u4, succ u3} P\u2081 P\u2082 (AffineEquiv.toEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.toEquiv.{u5, u3, u4, u1, u2} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem symm_toEquiv (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 V\u2081 (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) _inst_6 _inst_3) (LinearEquiv.symm.{u1, u1, u4, u5} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.linear.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 V\u2081 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_6 _inst_3) (LinearEquiv.symm.{u5, u5, u2, u1} k k V\u2081 V\u2082 (Ring.toSemiring.{u5} k _inst_1) (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.linear.{u5, u3, u4, u1, u2} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem symm_linear (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082 :=\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\u2081 \u2243\u1d43[k] P\u2082) : P\u2082 \u2192 P\u2081 :=\n  e.symm\n#align affine_equiv.simps.symm_apply AffineEquiv.Simps.symmApply\n-/\n\ninitialize_simps_projections AffineEquiv (to_equiv_to_fun \u2192 apply, to_equiv_inv_fun \u2192 symm_apply,\n  linear \u2192 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Bijective.{succ u2, succ u3} P\u2081 P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Bijective.{succ u4, succ u3} P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\nprotected theorem bijective (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Surjective.{succ u2, succ u3} P\u2081 P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Surjective.{succ u4, succ u3} P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\nprotected theorem surjective (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Injective.{succ u2, succ u3} P\u2081 P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Function.Injective.{succ u4, succ u3} P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\nprotected theorem injective (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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 {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} (h\u03c6 : Function.Bijective \u03c6) : P\u2081 \u2243\u1d43[k] P\u2082 :=\n  {\n    Equiv.ofBijective _\n      h\u03c6 with\n    linear := LinearEquiv.ofBijective \u03c6.linear (\u03c6.linear_bijective_iff.mpr h\u03c6)\n    map_vadd' := \u03c6.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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] {\u03c6 : AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} (h\u03c6 : Function.Bijective.{succ u2, succ u3} P\u2081 P\u2082 (coeFn.{max (succ u4) (succ u2) (succ u5) (succ u3), max (succ u2) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineMap.hasCoeToFun.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) \u03c6)), Eq.{max 1 (max (succ u3) (succ u2)) (succ u2) (succ u3)} (Equiv.{succ u3, succ u2} P\u2082 P\u2081) (AffineEquiv.toEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.ofBijective.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 h\u03c6))) (Equiv.symm.{succ u2, succ u3} P\u2081 P\u2082 (Equiv.ofBijective.{succ u2, succ u3} P\u2081 P\u2082 (coeFn.{max (succ u4) (succ u2) (succ u5) (succ u3), max (succ u2) (succ u3)} (AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineMap.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineMap.hasCoeToFun.{u1, u4, u2, u5, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) \u03c6) h\u03c6))\nbut is expected to have type\n  forall {k : Type.{u5}} {P\u2081 : Type.{u3}} {P\u2082 : Type.{u1}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u2}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u5, u4} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u2} V\u2082] [_inst_6 : Module.{u5, u2} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u2, u1} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u2} V\u2082 _inst_5)] {\u03c6 : AffineMap.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7} (h\u03c6 : Function.Bijective.{succ u3, succ u1} P\u2081 P\u2082 (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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) \u03c6)), Eq.{max (succ u3) (succ u1)} (Equiv.{succ u1, succ u3} P\u2082 P\u2081) (AffineEquiv.toEquiv.{u5, u1, u3, u2, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4 (AffineEquiv.symm.{u5, u3, u1, u4, u2} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 (AffineEquiv.ofBijective.{u5, u3, u1, u4, u2} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 \u03c6 h\u03c6))) (Equiv.symm.{succ u3, succ u1} P\u2081 P\u2082 (Equiv.ofBijective.{succ u3, succ u1} P\u2081 P\u2082 (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\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2082) _x) (AffineMap.funLike.{u5, u4, u3, u2, u1} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) \u03c6) h\u03c6))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.of_bijective.symm_eq AffineEquiv.ofBijective.symm_eq\u2093'. -/\ntheorem ofBijective.symm_eq {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} (h\u03c6 : Function.Bijective \u03c6) :\n    (ofBijective h\u03c6).symm.toEquiv = (Equiv.ofBijective _ h\u03c6).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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{succ u3} (Set.{u3} P\u2082) (Set.range.{u3, succ u2} P\u2082 P\u2081 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e)) (Set.univ.{u3} P\u2082)\nbut is expected to have type\n  forall {k : Type.{u5}} {P\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7), Eq.{succ u3} (Set.{u3} P\u2082) (Set.range.{u3, succ u4} P\u2082 P\u2081 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e)) (Set.univ.{u3} P\u2082)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.range_eq AffineEquiv.range_eq\u2093'. -/\n@[simp]\ntheorem range_eq (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P\u2082), Eq.{succ u3} P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P\u2082 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P\u2082), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 (fun (a : P\u2082) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2081) 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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 (fun (_x : P\u2082) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2081) _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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem apply_symm_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2082) : 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P\u2081), Eq.{succ u2} P\u2081 (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P\u2082 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (p : P\u2081), Eq.{succ u4} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2081) (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (a : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) 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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 (fun (_x : P\u2082) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2081) _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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem symm_apply_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2081) : 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) {p\u2081 : P\u2081} {p\u2082 : P\u2082}, Iff (Eq.{succ u3} P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p\u2081) p\u2082) (Eq.{succ u2} P\u2081 p\u2081 (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P\u2082 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) p\u2082))\nbut is expected to have type\n  forall {k : Type.{u5}} {P\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) {p\u2081 : P\u2081} {p\u2082 : (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) p\u2081}, Iff (Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) p\u2081) (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p\u2081) p\u2082) (Eq.{succ u4} P\u2081 p\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 (fun (_x : P\u2082) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2081) _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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) p\u2082))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.apply_eq_iff_eq_symm_apply AffineEquiv.apply_eq_iff_eq_symm_apply\u2093'. -/\ntheorem apply_eq_iff_eq_symm_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) {p\u2081 p\u2082} : e p\u2081 = p\u2082 \u2194 p\u2081 = e.symm p\u2082 :=\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) {p\u2081 : P\u2081} {p\u2082 : P\u2081}, Iff (Eq.{succ u3} P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p\u2081) (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) e p\u2082)) (Eq.{succ u2} P\u2081 p\u2081 p\u2082)\nbut is expected to have type\n  forall {k : Type.{u5}} {P\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) {p\u2081 : P\u2081} {p\u2082 : P\u2081}, Iff (Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) p\u2081) (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p\u2081) (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7))) e p\u2082)) (Eq.{succ u4} P\u2081 p\u2081 p\u2082)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.apply_eq_iff_eq AffineEquiv.apply_eq_iff_eq\u2093'. -/\n@[simp]\ntheorem apply_eq_iff_eq (e : P\u2081 \u2243\u1d43[k] P\u2082) {p\u2081 p\u2082 : P\u2081} : e p\u2081 = e p\u2082 \u2194 p\u2081 = p\u2082 :=\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (f : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (s : Set.{u3} P\u2082), Eq.{succ u2} (Set.{u2} P\u2081) (Set.image.{u3, u2} P\u2082 P\u2081 (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P\u2082 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f)) s) (Set.preimage.{u2, u3} P\u2081 P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (f : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (s : Set.{u3} P\u2082), Eq.{succ u4} (Set.{u4} P\u2081) (Set.image.{u3, u4} P\u2082 P\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 (fun (_x : P\u2082) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2081) _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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f)) s) (Set.preimage.{u4, u3} P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem image_symm (f : P\u2081 \u2243\u1d43[k] P\u2082) (s : Set P\u2082) : f.symm '' s = f \u207b\u00b9' 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (f : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (s : Set.{u2} P\u2081), Eq.{succ u3} (Set.{u3} P\u2082) (Set.preimage.{u3, u2} P\u2082 P\u2081 (coeFn.{max (succ u3) (succ u2) (succ u5) (succ u4), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) => P\u2082 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u5, u4} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f)) s) (Set.image.{u2, u3} P\u2081 P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (f : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (s : Set.{u4} P\u2081), Eq.{succ u3} (Set.{u3} P\u2082) (Set.preimage.{u3, u4} P\u2082 P\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 (fun (_x : P\u2082) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2081) _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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (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\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4) P\u2082 P\u2081 (AffineEquiv.equivLike.{u5, u3, u4, u1, u2} k P\u2082 P\u2081 V\u2082 V\u2081 _inst_1 _inst_5 _inst_6 _inst_7 _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 f)) s) (Set.image.{u4, u3} P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem preimage_symm (f : P\u2081 \u2243\u1d43[k] P\u2082) (s : Set P\u2081) : f.symm \u207b\u00b9' s = f '' s :=\n  (f.symm.image_symm _).symm\n#align affine_equiv.preimage_symm AffineEquiv.preimage_symm\n\nvariable (k P\u2081)\n\nomit V\u2082\n\n#print AffineEquiv.refl /-\n/-- Identity map as an `affine_equiv`. -/\n@[refl]\ndef refl : P\u2081 \u2243\u1d43[k] P\u2081 where\n  toEquiv := Equiv.refl P\u2081\n  linear := LinearEquiv.refl k V\u2081\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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], Eq.{succ u2} (P\u2081 -> P\u2081) (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (id.{succ u2} P\u2081)\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)], Eq.{succ u3} (forall (\u1fb0 : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) \u1fb0) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.refl.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (id.{succ u3} P\u2081)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_refl AffineEquiv.coe_refl\u2093'. -/\n@[simp]\ntheorem coe_refl : \u21d1(refl k P\u2081) = 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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineMap.{u1, u3, u2, u3, u2} k V\u2081 P\u2081 V\u2081 P\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.{u1, u3, u2, u3, u2} k V\u2081 P\u2081 V\u2081 P\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.{u1, u3, u2, u3, u2} k V\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (CoeTC\u2093.coe.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.{u1, u3, u2, u3, u2} k V\u2081 P\u2081 V\u2081 P\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.{u1, u3, u2, u3, u2} k V\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4)))) (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (AffineMap.id.{u1, u3, u2} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineMap.{u1, u2, u3, u2, u3} k V\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.toAffineMap.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (AffineMap.id.{u1, u2, u3} k V\u2081 P\u2081 _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\u2093'. -/\n@[simp]\ntheorem coe_refl_to_affineMap : \u2191(refl k P\u2081) = AffineMap.id k P\u2081 :=\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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (x : P\u2081), Eq.{succ u2} P\u2081 (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4) x) x\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (x : P\u2081), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.refl.{u1, u3, u2} k P\u2081 V\u2081 _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\u2093'. -/\n@[simp]\ntheorem refl_apply (x : P\u2081) : refl k P\u2081 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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], Eq.{succ u2} (Equiv.{succ u2, succ u2} P\u2081 P\u2081) (AffineEquiv.toEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (Equiv.refl.{succ u2} P\u2081)\nbut is expected to have type\n  forall (k : Type.{u2}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u1}} [_inst_1 : Ring.{u2} k] [_inst_2 : AddCommGroup.{u1} V\u2081] [_inst_3 : Module.{u2, u1} k V\u2081 (Ring.toSemiring.{u2} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u1, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u1} V\u2081 _inst_2)], Eq.{succ u3} (Equiv.{succ u3, succ u3} P\u2081 P\u2081) (AffineEquiv.toEquiv.{u2, u3, u3, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u2, u3, u1} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (Equiv.refl.{succ u3} P\u2081)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_equiv_refl AffineEquiv.toEquiv_refl\u2093'. -/\n@[simp]\ntheorem toEquiv_refl : (refl k P\u2081).toEquiv = Equiv.refl P\u2081 :=\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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _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\u2081 V\u2081 (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2) _inst_3 _inst_3) (AffineEquiv.linear.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (LinearEquiv.refl.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2) _inst_3)\nbut is expected to have type\n  forall (k : Type.{u2}) (P\u2081 : Type.{u1}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u2} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u2, u3} k V\u2081 (Ring.toSemiring.{u2} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u1} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _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\u2081 V\u2081 (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2) _inst_3 _inst_3) (AffineEquiv.linear.{u2, u1, u1, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u2, u1, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (LinearEquiv.refl.{u2, u3} k V\u2081 (Ring.toSemiring.{u2} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2) _inst_3)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.linear_refl AffineEquiv.linear_refl\u2093'. -/\n@[simp]\ntheorem linear_refl : (refl k P\u2081).linear = LinearEquiv.refl k V\u2081 :=\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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.refl.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (AffineEquiv.refl.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.symm_refl AffineEquiv.symm_refl\u2093'. -/\n@[simp]\ntheorem symm_refl : (refl k P\u2081).symm = refl k P\u2081 :=\n  rfl\n#align affine_equiv.symm_refl AffineEquiv.symm_refl\n\nvariable {k P\u2081}\n\ninclude V\u2082 V\u2083\n\n#print AffineEquiv.trans /-\n/-- Composition of two `affine_equiv`alences, applied left to right. -/\n@[trans]\ndef trans (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) : P\u2081 \u2243\u1d43[k] P\u2083\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, (\u00b7 \u2218 \u00b7), 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {P\u2083 : Type.{u4}} {V\u2081 : Type.{u5}} {V\u2082 : Type.{u6}} {V\u2083 : Type.{u7}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u5} V\u2081] [_inst_3 : Module.{u1, u5} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u5, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u5} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u6} V\u2082] [_inst_6 : Module.{u1, u6} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u6, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u6} V\u2082 _inst_5)] [_inst_8 : AddCommGroup.{u7} V\u2083] [_inst_9 : Module.{u1, u7} k V\u2083 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u7} V\u2083 _inst_8)] [_inst_10 : AddTorsor.{u7, u4} V\u2083 P\u2083 (AddCommGroup.toAddGroup.{u7} V\u2083 _inst_8)] (e : AffineEquiv.{u1, u2, u3, u5, u6} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10), Eq.{max (succ u2) (succ u4)} (P\u2081 -> P\u2083) (coeFn.{max (succ u2) (succ u4) (succ u5) (succ u7), max (succ u2) (succ u4)} (AffineEquiv.{u1, u2, u4, u5, u7} k P\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (fun (_x : AffineEquiv.{u1, u2, u4, u5, u7} k P\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) => P\u2081 -> P\u2083) (AffineEquiv.hasCoeToFun.{u1, u2, u4, u5, u7} k P\u2081 P\u2083 V\u2081 V\u2083 _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\u2081 P\u2082 P\u2083 V\u2081 V\u2082 V\u2083 _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\u2081 P\u2082 P\u2083 (coeFn.{max (succ u3) (succ u4) (succ u6) (succ u7), max (succ u3) (succ u4)} (AffineEquiv.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (fun (_x : AffineEquiv.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) => P\u2082 -> P\u2083) (AffineEquiv.hasCoeToFun.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u5, u6} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u5, u6} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u6}} {P\u2082 : Type.{u5}} {P\u2083 : Type.{u2}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u3}} {V\u2083 : Type.{u1}} [_inst_1 : Ring.{u7} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u7, u4} k V\u2081 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u6} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u3} V\u2082] [_inst_6 : Module.{u7, u3} k V\u2082 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u3, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u3} V\u2082 _inst_5)] [_inst_8 : AddCommGroup.{u1} V\u2083] [_inst_9 : Module.{u7, u1} k V\u2083 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2083 _inst_8)] [_inst_10 : AddTorsor.{u1, u2} V\u2083 P\u2083 (AddCommGroup.toAddGroup.{u1} V\u2083 _inst_8)] (e : AffineEquiv.{u7, u6, u5, u4, u3} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u7, u5, u2, u3, u1} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10), Eq.{max (succ u6) (succ u2)} (forall (\u1fb0 : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2083) \u1fb0) (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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2083) _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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P\u2081 P\u2083 (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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P\u2081 P\u2083 (AffineEquiv.equivLike.{u7, u6, u2, u4, u1} k P\u2081 P\u2083 V\u2081 V\u2083 _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\u2081 P\u2082 P\u2083 V\u2081 V\u2082 V\u2083 _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\u2081 P\u2082 P\u2083 (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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P\u2082 (fun (_x : P\u2082) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2083) _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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P\u2082 P\u2083 (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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P\u2082 P\u2083 (AffineEquiv.equivLike.{u7, u5, u2, u3, u1} k P\u2082 P\u2083 V\u2082 V\u2083 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u7, u6, u5, u4, u3} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem coe_trans (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) : \u21d1(e.trans e') = e' \u2218 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {P\u2083 : Type.{u4}} {V\u2081 : Type.{u5}} {V\u2082 : Type.{u6}} {V\u2083 : Type.{u7}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u5} V\u2081] [_inst_3 : Module.{u1, u5} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u5, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u5} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u6} V\u2082] [_inst_6 : Module.{u1, u6} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u6, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u6} V\u2082 _inst_5)] [_inst_8 : AddCommGroup.{u7} V\u2083] [_inst_9 : Module.{u1, u7} k V\u2083 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u7} V\u2083 _inst_8)] [_inst_10 : AddTorsor.{u7, u4} V\u2083 P\u2083 (AddCommGroup.toAddGroup.{u7} V\u2083 _inst_8)] (e : AffineEquiv.{u1, u2, u3, u5, u6} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _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\u2081 P\u2081 V\u2083 P\u2083 _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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u5, u2, u7, u4} k V\u2081 P\u2081 V\u2083 P\u2083 _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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u5, u2, u7, u4} k V\u2081 P\u2081 V\u2083 P\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (CoeTC\u2093.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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u5, u2, u7, u4} k V\u2081 P\u2081 V\u2083 P\u2083 _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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u5, u2, u7, u4} k V\u2081 P\u2081 V\u2083 P\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u4, u5, u7} k P\u2081 P\u2083 V\u2081 V\u2083 _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\u2081 P\u2082 P\u2083 V\u2081 V\u2082 V\u2083 _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\u2081 P\u2081 V\u2082 P\u2082 V\u2083 P\u2083 _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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u6, u3, u7, u4} k V\u2082 P\u2082 V\u2083 P\u2083 _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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u6, u3, u7, u4} k V\u2082 P\u2082 V\u2083 P\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (CoeTC\u2093.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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u6, u3, u7, u4} k V\u2082 P\u2082 V\u2083 P\u2083 _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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineMap.{u1, u6, u3, u7, u4} k V\u2082 P\u2082 V\u2083 P\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (AffineEquiv.AffineMap.hasCoe.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u5, u2, u6, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u5, u2, u6, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (CoeTC\u2093.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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u5, u2, u6, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineMap.{u1, u5, u2, u6, u3} k V\u2081 P\u2081 V\u2082 P\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (AffineEquiv.AffineMap.hasCoe.{u1, u2, u3, u5, u6} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u6}} {P\u2082 : Type.{u5}} {P\u2083 : Type.{u2}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u3}} {V\u2083 : Type.{u1}} [_inst_1 : Ring.{u7} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u7, u4} k V\u2081 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u6} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u3} V\u2082] [_inst_6 : Module.{u7, u3} k V\u2082 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u3, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u3} V\u2082 _inst_5)] [_inst_8 : AddCommGroup.{u1} V\u2083] [_inst_9 : Module.{u7, u1} k V\u2083 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2083 _inst_8)] [_inst_10 : AddTorsor.{u1, u2} V\u2083 P\u2083 (AddCommGroup.toAddGroup.{u1} V\u2083 _inst_8)] (e : AffineEquiv.{u7, u6, u5, u4, u3} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u7, u5, u2, u3, u1} k P\u2082 P\u2083 V\u2082 V\u2083 _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\u2081 P\u2081 V\u2083 P\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (AffineEquiv.toAffineMap.{u7, u6, u2, u4, u1} k P\u2081 P\u2083 V\u2081 V\u2083 _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\u2081 P\u2082 P\u2083 V\u2081 V\u2082 V\u2083 _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\u2081 P\u2081 V\u2082 P\u2082 V\u2083 P\u2083 _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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e') (AffineEquiv.toAffineMap.{u7, u6, u5, u4, u3} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem coe_trans_to_affineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) :\n    (e.trans e' : P\u2081 \u2192\u1d43[k] P\u2083) = (e' : P\u2082 \u2192\u1d43[k] P\u2083).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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {P\u2083 : Type.{u4}} {V\u2081 : Type.{u5}} {V\u2082 : Type.{u6}} {V\u2083 : Type.{u7}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u5} V\u2081] [_inst_3 : Module.{u1, u5} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u5, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u5} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u6} V\u2082] [_inst_6 : Module.{u1, u6} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u6, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u6} V\u2082 _inst_5)] [_inst_8 : AddCommGroup.{u7} V\u2083] [_inst_9 : Module.{u1, u7} k V\u2083 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u7} V\u2083 _inst_8)] [_inst_10 : AddTorsor.{u7, u4} V\u2083 P\u2083 (AddCommGroup.toAddGroup.{u7} V\u2083 _inst_8)] (e : AffineEquiv.{u1, u2, u3, u5, u6} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (p : P\u2081), Eq.{succ u4} P\u2083 (coeFn.{max (succ u2) (succ u4) (succ u5) (succ u7), max (succ u2) (succ u4)} (AffineEquiv.{u1, u2, u4, u5, u7} k P\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) (fun (_x : AffineEquiv.{u1, u2, u4, u5, u7} k P\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) => P\u2081 -> P\u2083) (AffineEquiv.hasCoeToFun.{u1, u2, u4, u5, u7} k P\u2081 P\u2083 V\u2081 V\u2083 _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\u2081 P\u2082 P\u2083 V\u2081 V\u2082 V\u2083 _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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (fun (_x : AffineEquiv.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) => P\u2082 -> P\u2083) (AffineEquiv.hasCoeToFun.{u1, u3, u4, u6, u7} k P\u2082 P\u2083 V\u2082 V\u2083 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u5, u6} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u5, u6} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u6}} {P\u2082 : Type.{u5}} {P\u2083 : Type.{u2}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u3}} {V\u2083 : Type.{u1}} [_inst_1 : Ring.{u7} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u7, u4} k V\u2081 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u6} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u3} V\u2082] [_inst_6 : Module.{u7, u3} k V\u2082 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u3, u5} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u3} V\u2082 _inst_5)] [_inst_8 : AddCommGroup.{u1} V\u2083] [_inst_9 : Module.{u7, u1} k V\u2083 (Ring.toSemiring.{u7} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2083 _inst_8)] [_inst_10 : AddTorsor.{u1, u2} V\u2083 P\u2083 (AddCommGroup.toAddGroup.{u1} V\u2083 _inst_8)] (e : AffineEquiv.{u7, u6, u5, u4, u3} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e' : AffineEquiv.{u7, u5, u2, u3, u1} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (p : P\u2081), Eq.{succ u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2083) 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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2083) _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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P\u2081 P\u2083 (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\u2081 P\u2083 V\u2081 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_8 _inst_9 _inst_10) P\u2081 P\u2083 (AffineEquiv.equivLike.{u7, u6, u2, u4, u1} k P\u2081 P\u2083 V\u2081 V\u2083 _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\u2081 P\u2082 P\u2083 V\u2081 V\u2082 V\u2083 _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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P\u2082 (fun (_x : P\u2082) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2082) => P\u2083) _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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P\u2082 P\u2083 (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\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) P\u2082 P\u2083 (AffineEquiv.equivLike.{u7, u5, u2, u3, u1} k P\u2082 P\u2083 V\u2082 V\u2083 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u7, u6, u5, u4, u3} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem trans_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) (p : P\u2081) : e.trans e' p = e' (e p) :=\n  rfl\n#align affine_equiv.trans_apply AffineEquiv.trans_apply\n\ninclude V\u2084\n\n/- warning: affine_equiv.trans_assoc -> AffineEquiv.trans_assoc is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {P\u2083 : Type.{u4}} {P\u2084 : Type.{u5}} {V\u2081 : Type.{u6}} {V\u2082 : Type.{u7}} {V\u2083 : Type.{u8}} {V\u2084 : Type.{u9}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u6} V\u2081] [_inst_3 : Module.{u1, u6} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u6, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u6} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u7} V\u2082] [_inst_6 : Module.{u1, u7} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u7} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u7, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u7} V\u2082 _inst_5)] [_inst_8 : AddCommGroup.{u8} V\u2083] [_inst_9 : Module.{u1, u8} k V\u2083 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u8} V\u2083 _inst_8)] [_inst_10 : AddTorsor.{u8, u4} V\u2083 P\u2083 (AddCommGroup.toAddGroup.{u8} V\u2083 _inst_8)] [_inst_11 : AddCommGroup.{u9} V\u2084] [_inst_12 : Module.{u1, u9} k V\u2084 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u9} V\u2084 _inst_11)] [_inst_13 : AddTorsor.{u9, u5} V\u2084 P\u2084 (AddCommGroup.toAddGroup.{u9} V\u2084 _inst_11)] (e\u2081 : AffineEquiv.{u1, u2, u3, u6, u7} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e\u2082 : AffineEquiv.{u1, u3, u4, u7, u8} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (e\u2083 : AffineEquiv.{u1, u4, u5, u8, u9} k P\u2083 P\u2084 V\u2083 V\u2084 _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\u2081 P\u2084 V\u2081 V\u2084 _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\u2081 P\u2083 P\u2084 V\u2081 V\u2083 V\u2084 _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\u2081 P\u2082 P\u2083 V\u2081 V\u2082 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e\u2081 e\u2082) e\u2083) (AffineEquiv.trans.{u1, u2, u3, u5, u6, u7, u9} k P\u2081 P\u2082 P\u2084 V\u2081 V\u2082 V\u2084 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_11 _inst_12 _inst_13 e\u2081 (AffineEquiv.trans.{u1, u3, u4, u5, u7, u8, u9} k P\u2082 P\u2083 P\u2084 V\u2082 V\u2083 V\u2084 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 e\u2082 e\u2083))\nbut is expected to have type\n  forall {k : Type.{u9}} {P\u2081 : Type.{u8}} {P\u2082 : Type.{u7}} {P\u2083 : Type.{u4}} {P\u2084 : Type.{u2}} {V\u2081 : Type.{u6}} {V\u2082 : Type.{u5}} {V\u2083 : Type.{u3}} {V\u2084 : Type.{u1}} [_inst_1 : Ring.{u9} k] [_inst_2 : AddCommGroup.{u6} V\u2081] [_inst_3 : Module.{u9, u6} k V\u2081 (Ring.toSemiring.{u9} k _inst_1) (AddCommGroup.toAddCommMonoid.{u6} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u6, u8} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u6} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u9, u5} k V\u2082 (Ring.toSemiring.{u9} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u7} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] [_inst_8 : AddCommGroup.{u3} V\u2083] [_inst_9 : Module.{u9, u3} k V\u2083 (Ring.toSemiring.{u9} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2083 _inst_8)] [_inst_10 : AddTorsor.{u3, u4} V\u2083 P\u2083 (AddCommGroup.toAddGroup.{u3} V\u2083 _inst_8)] [_inst_11 : AddCommGroup.{u1} V\u2084] [_inst_12 : Module.{u9, u1} k V\u2084 (Ring.toSemiring.{u9} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2084 _inst_11)] [_inst_13 : AddTorsor.{u1, u2} V\u2084 P\u2084 (AddCommGroup.toAddGroup.{u1} V\u2084 _inst_11)] (e\u2081 : AffineEquiv.{u9, u8, u7, u6, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (e\u2082 : AffineEquiv.{u9, u7, u4, u5, u3} k P\u2082 P\u2083 V\u2082 V\u2083 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10) (e\u2083 : AffineEquiv.{u9, u4, u2, u3, u1} k P\u2083 P\u2084 V\u2083 V\u2084 _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\u2081 P\u2084 V\u2081 V\u2084 _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\u2081 P\u2083 P\u2084 V\u2081 V\u2083 V\u2084 _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\u2081 P\u2082 P\u2083 V\u2081 V\u2082 V\u2083 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 e\u2081 e\u2082) e\u2083) (AffineEquiv.trans.{u9, u8, u7, u2, u6, u5, u1} k P\u2081 P\u2082 P\u2084 V\u2081 V\u2082 V\u2084 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_11 _inst_12 _inst_13 e\u2081 (AffineEquiv.trans.{u9, u7, u4, u2, u5, u3, u1} k P\u2082 P\u2083 P\u2084 V\u2082 V\u2083 V\u2084 _inst_1 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 e\u2082 e\u2083))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.trans_assoc AffineEquiv.trans_assoc\u2093'. -/\ntheorem trans_assoc (e\u2081 : P\u2081 \u2243\u1d43[k] P\u2082) (e\u2082 : P\u2082 \u2243\u1d43[k] P\u2083) (e\u2083 : P\u2083 \u2243\u1d43[k] P\u2084) :\n    (e\u2081.trans e\u2082).trans e\u2083 = e\u2081.trans (e\u2082.trans e\u2083) :=\n  ext fun _ => rfl\n#align affine_equiv.trans_assoc AffineEquiv.trans_assoc\n\nomit V\u2083 V\u2084\n\n/- warning: affine_equiv.trans_refl -> AffineEquiv.trans_refl is a dubious translation:\nlean 3 declaration is\n  forall {k : Type.{u1}} {P\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 P\u2082 V\u2081 V\u2082 V\u2082 _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\u2082 V\u2082 _inst_1 _inst_5 _inst_6 _inst_7)) e\nbut is expected to have type\n  forall {k : Type.{u5}} {P\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 P\u2082 V\u2081 V\u2082 V\u2082 _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\u2082 V\u2082 _inst_1 _inst_5 _inst_6 _inst_7)) e\nCase conversion may be inaccurate. Consider using '#align affine_equiv.trans_refl AffineEquiv.trans_refl\u2093'. -/\n@[simp]\ntheorem trans_refl (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.trans (refl k P\u2082) = 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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 P\u2082 V\u2081 V\u2081 V\u2082 _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\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4) e) e\nbut is expected to have type\n  forall {k : Type.{u5}} {P\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 P\u2082 V\u2081 V\u2081 V\u2082 _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\u2081 V\u2081 _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\u2093'. -/\n@[simp]\ntheorem refl_trans (e : P\u2081 \u2243\u1d43[k] P\u2082) : (refl k P\u2081).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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2082 P\u2081 V\u2081 V\u2082 V\u2081 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.refl.{u1, u2, u4} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {k : Type.{u5}} {P\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2082 P\u2081 V\u2081 V\u2082 V\u2081 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e)) (AffineEquiv.refl.{u5, u4, u2} k P\u2081 V\u2081 _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\u2093'. -/\n@[simp]\ntheorem self_trans_symm (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.trans e.symm = refl k P\u2081 :=\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 P\u2082 V\u2082 V\u2082 _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\u2082 P\u2081 P\u2082 V\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) e) (AffineEquiv.refl.{u1, u3, u5} k P\u2082 V\u2082 _inst_1 _inst_5 _inst_6 _inst_7)\nbut is expected to have type\n  forall {k : Type.{u5}} {P\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2082 P\u2082 V\u2082 V\u2082 _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\u2082 P\u2081 P\u2082 V\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 e) e) (AffineEquiv.refl.{u5, u3, u1} k P\u2082 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem symm_trans_self (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.symm.trans e = refl k P\u2082 :=\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\u2081 : Type.{u2}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u4}} {V\u2082 : Type.{u5}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u4} V\u2081] [_inst_3 : Module.{u1, u4} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u4} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u4, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u4} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u5} V\u2082] [_inst_6 : Module.{u1, u5} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u5} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u5, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u5} V\u2082 _inst_5)] (e : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (a : P\u2081) (b : P\u2081) (c : k), Eq.{succ u3} P\u2082 (coeFn.{max (succ u2) (succ u3) (succ u4) (succ u5), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 _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\u2081 P\u2081 _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\u2081) (AffineMap.hasCoeToFun.{u1, u1, u1, u4, u2} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _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\u2082 P\u2082 _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\u2082 P\u2082 _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\u2082) (AffineMap.hasCoeToFun.{u1, u1, u1, u5, u3} k k k V\u2082 P\u2082 _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\u2082 P\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (fun (_x : AffineEquiv.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) => P\u2081 -> P\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u4, u5} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 : Type.{u4}} {P\u2082 : Type.{u3}} {V\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u5} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u5, u2} k V\u2081 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u4} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u5, u1} k V\u2082 (Ring.toSemiring.{u5} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)] [_inst_7 : AddTorsor.{u1, u3} V\u2082 P\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5)] (e : AffineEquiv.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) (a : P\u2081) (b : P\u2081) (c : k), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) (FunLike.coe.{max (max (succ u5) (succ u2)) (succ u4), succ u5, succ u4} (AffineMap.{u5, u5, u5, u2, u4} k k k V\u2081 P\u2081 _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\u2081) a) (AffineMap.funLike.{u5, u5, u5, u2, u4} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2081 _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\u2081) _x) (AffineMap.funLike.{u5, u5, u5, u2, u4} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _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\u2082 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) 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\u2081) => P\u2082) a) _x) (AffineMap.funLike.{u5, u5, u5, u1, u3} k k k V\u2082 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) 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\u2082 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) 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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2082) _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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (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\u2081 P\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7) P\u2081 P\u2082 (AffineEquiv.equivLike.{u5, u4, u3, u2, u1} k P\u2081 P\u2082 V\u2081 V\u2082 _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\u2093'. -/\n@[simp]\ntheorem apply_lineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) (a b : P\u2081) (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\u2082\n\ninstance : Group (P\u2081 \u2243\u1d43[k] P\u2081) where\n  one := refl k P\u2081\n  mul e e' := e'.trans e\n  inv := symm\n  mul_assoc e\u2081 e\u2082 e\u2083 := 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))))))) (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {k : Type.{u1}} {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4))))))) (AffineEquiv.refl.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.one_def AffineEquiv.one_def\u2093'. -/\ntheorem one_def : (1 : P\u2081 \u2243\u1d43[k] P\u2081) = refl k P\u2081 :=\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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], Eq.{succ u2} (P\u2081 -> P\u2081) (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4))))))))) (id.{succ u2} P\u2081)\nbut is expected to have type\n  forall {k : Type.{u1}} {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)], Eq.{succ u3} (forall (\u1fb0 : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) \u1fb0) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))))))) (id.{succ u3} P\u2081)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_one AffineEquiv.coe_one\u2093'. -/\n@[simp]\ntheorem coe_one : \u21d1(1 : P\u2081 \u2243\u1d43[k] P\u2081) = 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (e : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (e' : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))))) e e') (AffineEquiv.trans.{u1, u2, u2, u2, u3, u3, u3} k P\u2081 P\u2081 P\u2081 V\u2081 V\u2081 V\u2081 _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\u2081 : Type.{u2}} {V\u2081 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V\u2081] [_inst_3 : Module.{u3, u1} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u1} V\u2081 _inst_2)] (e : AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (e' : AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u3, u2, u1} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))))) e e') (AffineEquiv.trans.{u3, u2, u2, u2, u1, u1, u1} k P\u2081 P\u2081 P\u2081 V\u2081 V\u2081 V\u2081 _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\u2093'. -/\ntheorem mul_def (e e' : P\u2081 \u2243\u1d43[k] P\u2081) : 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (e : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (e' : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4), Eq.{succ u2} (P\u2081 -> P\u2081) (coeFn.{succ (max u2 u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))))) e e')) (Function.comp.{succ u2, succ u2, succ u2} P\u2081 P\u2081 P\u2081 (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 : Type.{u2}} {V\u2081 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V\u2081] [_inst_3 : Module.{u3, u1} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u1} V\u2081 _inst_2)] (e : AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (e' : AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4), Eq.{succ u2} (forall (\u1fb0 : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u3, u2, u1} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))))) e e')) (Function.comp.{succ u2, succ u2, succ u2} P\u2081 P\u2081 P\u2081 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2093'. -/\n@[simp]\ntheorem coe_mul (e e' : P\u2081 \u2243\u1d43[k] P\u2081) : \u21d1(e * e') = e \u2218 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (e : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4))) e) (AffineEquiv.symm.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 : Type.{u2}} {V\u2081 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V\u2081] [_inst_3 : Module.{u3, u1} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u1} V\u2081 _inst_2)] (e : AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u3, u2, u1} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4))))) e) (AffineEquiv.symm.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2093'. -/\ntheorem inv_def (e : P\u2081 \u2243\u1d43[k] P\u2081) : e\u207b\u00b9 = 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\u2081 \u2243\u1d43[k] P\u2081) \u2192* V\u2081 \u2243\u2097[k] V\u2081\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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], MulEquiv.{max u2 u3, max u3 u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.monoid.{u1, u3, u2} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (MulOneClass.toHasMul.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.monoid.{u1, u3, u2} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (Units.mulOneClass.{max u3 u2} (AffineMap.{u1, u3, u2, u3, u2} k V\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.monoid.{u1, u3, u2} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))\nbut is expected to have type\n  forall {k : Type.{u1}} {P\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], MulEquiv.{max u3 u2, max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.instMonoidAffineMap.{u1, u3, u2} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (MulOneClass.toMul.{max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.instMonoidAffineMap.{u1, u3, u2} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4)) (Units.instMulOneClassUnits.{max u2 u3} (AffineMap.{u1, u3, u2, u3, u2} k V\u2081 P\u2081 V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineMap.instMonoidAffineMap.{u1, u3, u2} k V\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.equiv_units_affine_map AffineEquiv.equivUnitsAffineMap\u2093'. -/\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\u2081 \u2243\u1d43[k] P\u2081) \u2243* (P\u2081 \u2192\u1d43[k] P\u2081)\u02e3\n    where\n  toFun e := \u27e8e, e.symm, congr_arg coe e.symm_trans_self, congr_arg coe e.self_trans_symm\u27e9\n  invFun u :=\n    { toFun := (u : P\u2081 \u2192\u1d43[k] P\u2081)\n      invFun := (\u2191u\u207b\u00b9 : P\u2081 \u2192\u1d43[k] P\u2081)\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\u2081 \u2192\u1d43[k] P\u2081).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\u2081 e\u2082 := rfl\n#align affine_equiv.equiv_units_affine_map AffineEquiv.equivUnitsAffineMap\n\nvariable (k)\n\n#print AffineEquiv.vaddConst /-\n/-- The map `v \u21a6 v +\u1d65 b` as an affine equivalence between a module `V` and an affine space `P` with\ntangent space `V`. -/\n@[simps]\ndef vaddConst (b : P\u2081) : V\u2081 \u2243\u1d43[k] P\u2081\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' \u21a6 p -\u1d65 p'` as an equivalence. -/\ndef constVSub (p : P\u2081) : P\u2081 \u2243\u1d43[k] V\u2081\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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (p : P\u2081), Eq.{max (succ u2) (succ u3)} (P\u2081 -> V\u2081) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u3, u3} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (fun (_x : AffineEquiv.{u1, u2, u3, u3, u3} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) => P\u2081 -> V\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u3, u3} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AffineEquiv.constVSub.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 p)) (VSub.vsub.{u3, u2} V\u2081 P\u2081 (AddTorsor.toHasVsub.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4) p)\nbut is expected to have type\n  forall (k : Type.{u1}) {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (p : P\u2081), Eq.{max (succ u3) (succ u2)} (forall (\u1fb0 : P\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => V\u2081) \u1fb0) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (AffineEquiv.{u1, u3, u2, u2, u2} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => V\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u2} (AffineEquiv.{u1, u3, u2, u2, u2} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) P\u2081 V\u2081 (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u2} (AffineEquiv.{u1, u3, u2, u2, u2} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) P\u2081 V\u2081 (AffineEquiv.equivLike.{u1, u3, u2, u2, u2} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))))) (AffineEquiv.constVSub.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 p)) ((fun (x._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.6944 : P\u2081) (x._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.6946 : P\u2081) => VSub.vsub.{u2, u3} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _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\u2093'. -/\n@[simp]\ntheorem coe_constVSub (p : P\u2081) : \u21d1(constVSub k p) = (\u00b7 -\u1d65 \u00b7) 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (p : P\u2081), Eq.{max (succ u3) (succ u2)} (V\u2081 -> P\u2081) (coeFn.{max (succ u2) (succ u3), max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u2, u3, u3} k V\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)) _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u3, u2, u3, u3} k V\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)) _inst_2 _inst_3 _inst_4) => V\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u3, u2, u3, u3} k V\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)) _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u3, u3, u3} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)) (AffineEquiv.constVSub.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 p))) (fun (v : V\u2081) => VAdd.vadd.{u3, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u3, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4)) (Neg.neg.{u3} V\u2081 (SubNegMonoid.toHasNeg.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) v) p)\nbut is expected to have type\n  forall (k : Type.{u1}) {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (p : P\u2081), Eq.{max (succ u3) (succ u2)} (forall (\u1fb0 : V\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : V\u2081) => P\u2081) \u1fb0) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u3} (AffineEquiv.{u1, u2, u3, u2, u2} k V\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_2 _inst_3 _inst_4) V\u2081 (fun (_x : V\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : V\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u3), succ u2, succ u3} (AffineEquiv.{u1, u2, u3, u2, u2} k V\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_2 _inst_3 _inst_4) V\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u3), succ u2, succ u3} (AffineEquiv.{u1, u2, u3, u2, u2} k V\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_2 _inst_3 _inst_4) V\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u2, u3, u2, u2} k V\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_2 _inst_3 _inst_4))) (AffineEquiv.symm.{u1, u3, u2, u2, u2} k P\u2081 V\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) (AffineEquiv.constVSub.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 p))) (fun (v : V\u2081) => HVAdd.hVAdd.{u2, u3, u3} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u3} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u3} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) (Neg.neg.{u2} V\u2081 (NegZeroClass.toNeg.{u2} V\u2081 (SubNegZeroMonoid.toNegZeroClass.{u2} V\u2081 (SubtractionMonoid.toSubNegZeroMonoid.{u2} V\u2081 (SubtractionCommMonoid.toSubtractionMonoid.{u2} V\u2081 (AddCommGroup.toDivisionAddCommMonoid.{u2} V\u2081 _inst_2))))) v) p)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.coe_const_vsub_symm AffineEquiv.coe_constVSub_symm\u2093'. -/\n@[simp]\ntheorem coe_constVSub_symm (p : P\u2081) : \u21d1(constVSub k p).symm = fun v => -v +\u1d65 p :=\n  rfl\n#align affine_equiv.coe_const_vsub_symm AffineEquiv.coe_constVSub_symm\n\nvariable (P\u2081)\n\n#print AffineEquiv.constVAdd /-\n/-- The map `p \u21a6 v +\u1d65 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 `+\u1d65` is to `\u2022`. -/\n@[simps apply linear]\ndef constVAdd (v : V\u2081) : P\u2081 \u2243\u1d43[k] P\u2081\n    where\n  toEquiv := Equiv.constVAdd P\u2081 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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (OfNat.ofNat.{u3} V\u2081 0 (OfNat.mk.{u3} V\u2081 0 (Zero.zero.{u3} V\u2081 (AddZeroClass.toHasZero.{u3} V\u2081 (AddMonoid.toAddZeroClass.{u3} V\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))))))))) (AffineEquiv.refl.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)], Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (OfNat.ofNat.{u2} V\u2081 0 (Zero.toOfNat0.{u2} V\u2081 (NegZeroClass.toZero.{u2} V\u2081 (SubNegZeroMonoid.toNegZeroClass.{u2} V\u2081 (SubtractionMonoid.toSubNegZeroMonoid.{u2} V\u2081 (SubtractionCommMonoid.toSubtractionMonoid.{u2} V\u2081 (AddCommGroup.toDivisionAddCommMonoid.{u2} V\u2081 _inst_2)))))))) (AffineEquiv.refl.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.const_vadd_zero AffineEquiv.constVAdd_zero\u2093'. -/\n@[simp]\ntheorem constVAdd_zero : constVAdd k P\u2081 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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (v : V\u2081) (w : V\u2081), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (HAdd.hAdd.{u3, u3, u3} V\u2081 V\u2081 V\u2081 (instHAdd.{u3} V\u2081 (AddZeroClass.toHasAdd.{u3} V\u2081 (AddMonoid.toAddZeroClass.{u3} V\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)))))) v w)) (AffineEquiv.trans.{u1, u2, u2, u2, u3, u3, u3} k P\u2081 P\u2081 P\u2081 V\u2081 V\u2081 V\u2081 _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\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 w) (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 v))\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (v : V\u2081) (w : V\u2081), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (HAdd.hAdd.{u2, u2, u2} V\u2081 V\u2081 V\u2081 (instHAdd.{u2} V\u2081 (AddZeroClass.toAdd.{u2} V\u2081 (AddMonoid.toAddZeroClass.{u2} V\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)))))) v w)) (AffineEquiv.trans.{u1, u3, u3, u3, u2, u2, u2} k P\u2081 P\u2081 P\u2081 V\u2081 V\u2081 V\u2081 _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\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 w) (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _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\u2093'. -/\n@[simp]\ntheorem constVAdd_add (v w : V\u2081) :\n    constVAdd k P\u2081 (v + w) = (constVAdd k P\u2081 w).trans (constVAdd k P\u2081 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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (v : V\u2081), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 v)) (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (Neg.neg.{u3} V\u2081 (SubNegMonoid.toHasNeg.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) v))\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (v : V\u2081), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 v)) (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (Neg.neg.{u2} V\u2081 (NegZeroClass.toNeg.{u2} V\u2081 (SubNegZeroMonoid.toNegZeroClass.{u2} V\u2081 (SubtractionMonoid.toSubNegZeroMonoid.{u2} V\u2081 (SubtractionCommMonoid.toSubtractionMonoid.{u2} V\u2081 (AddCommGroup.toDivisionAddCommMonoid.{u2} V\u2081 _inst_2))))) v))\nCase conversion may be inaccurate. Consider using '#align affine_equiv.const_vadd_symm AffineEquiv.constVAdd_symm\u2093'. -/\n@[simp]\ntheorem constVAdd_symm (v : V\u2081) : (constVAdd k P\u2081 v).symm = constVAdd k P\u2081 (-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\u2081 \u2192* P\u2081 \u2243\u1d43[k] P\u2081\n    where\n  toFun v := constVAdd k P\u2081 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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (n : Nat) (v : V\u2081), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (SMul.smul.{0, u3} Nat V\u2081 (AddMonoid.SMul.{u3} V\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)))) n v)) (HPow.hPow.{max u2 u3, 0, max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Nat (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4))))) (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 v) n)\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (n : Nat) (v : V\u2081), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (HSMul.hSMul.{0, u2, u2} Nat V\u2081 V\u2081 (instHSMul.{0, u2} Nat V\u2081 (AddMonoid.SMul.{u2} V\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))))) n v)) (HPow.hPow.{max u3 u2, 0, max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Nat (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4))))) (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _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\u2093'. -/\ntheorem constVAdd_nsmul (n : \u2115) (v : V\u2081) : constVAdd k P\u2081 (n \u2022 v) = constVAdd k P\u2081 v ^ n :=\n  (constVAddHom k P\u2081).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\u2081 : Type.{u2}) {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (z : Int) (v : V\u2081), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (SMul.smul.{0, u3} Int V\u2081 (SubNegMonoid.SMulInt.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) z v)) (HPow.hPow.{max u2 u3, 0, max u2 u3} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Int (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))) (AffineEquiv.constVAdd.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 v) z)\nbut is expected to have type\n  forall (k : Type.{u1}) (P\u2081 : Type.{u3}) {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (z : Int) (v : V\u2081), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (HSMul.hSMul.{0, u2, u2} Int V\u2081 V\u2081 (instHSMul.{0, u2} Int V\u2081 (SubNegMonoid.SMulInt.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)))) z v)) (HPow.hPow.{max u3 u2, 0, max u3 u2} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) Int (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.group.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4)))) (AffineEquiv.constVAdd.{u1, u3, u2} k P\u2081 V\u2081 _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\u2093'. -/\ntheorem constVAdd_zsmul (z : \u2124) (v : V\u2081) : constVAdd k P\u2081 (z \u2022 v) = constVAdd k P\u2081 v ^ z :=\n  (constVAddHom k P\u2081).map_zpow _ _\n#align affine_equiv.const_vadd_zsmul AffineEquiv.constVAdd_zsmul\n\nsection Homothety\n\nomit V\u2081\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\u2093'. -/\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\u02e3 \u2192* P \u2243\u1d43[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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_homothetyUnitsMulHom_apply (p : P) (t : R\u02e3) :\n    (homothetyUnitsMulHom p t : P \u2192 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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_homothetyUnitsMulHom_apply_symm (p : P) (t : R\u02e3) :\n    ((homothetyUnitsMulHom p t).symm : P \u2192 P) = AffineMap.homothety p (\u2191t\u207b\u00b9 : 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_homothetyUnitsMulHom_eq_homothetyHom_coe (p : P) :\n    (coe : (P \u2243\u1d43[R] P) \u2192 P \u2192\u1d43[R] P) \u2218 homothetyUnitsMulHom p =\n      AffineMap.homothetyHom p \u2218 (coe : R\u02e3 \u2192 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\u2081}\n\nopen Function\n\n#print AffineEquiv.pointReflection /-\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P\u2081) : P\u2081 \u2243\u1d43[k] P\u2081 :=\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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (x : P\u2081) (y : P\u2081), Eq.{succ u2} P\u2081 (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) y) (VAdd.vadd.{u3, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u3, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4)) (VSub.vsub.{u3, u2} V\u2081 P\u2081 (AddTorsor.toHasVsub.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4) x y) x)\nbut is expected to have type\n  forall (k : Type.{u1}) {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (x : P\u2081) (y : P\u2081), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) y) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) y) (HVAdd.hVAdd.{u2, u3, u3} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u3} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u3} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) (VSub.vsub.{u2, u3} V\u2081 P\u2081 (AddTorsor.toVSub.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4) x y) x)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.point_reflection_apply AffineEquiv.pointReflection_apply\u2093'. -/\ntheorem pointReflection_apply (x y : P\u2081) : pointReflection k x y = x -\u1d65 y +\u1d65 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (x : P\u2081), Eq.{max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x)) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x)\nbut is expected to have type\n  forall (k : Type.{u1}) {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (x : P\u2081), Eq.{max (succ u3) (succ u2)} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.symm.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.pointReflection.{u1, u3, u2} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x)) (AffineEquiv.pointReflection.{u1, u3, u2} k P\u2081 V\u2081 _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\u2093'. -/\n@[simp]\ntheorem pointReflection_symm (x : P\u2081) : (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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (x : P\u2081), Eq.{succ u2} (Equiv.{succ u2, succ u2} P\u2081 P\u2081) (AffineEquiv.toEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x)) (Equiv.pointReflection.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4 x)\nbut is expected to have type\n  forall (k : Type.{u2}) {P\u2081 : Type.{u3}} {V\u2081 : Type.{u1}} [_inst_1 : Ring.{u2} k] [_inst_2 : AddCommGroup.{u1} V\u2081] [_inst_3 : Module.{u2, u1} k V\u2081 (Ring.toSemiring.{u2} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u1, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u1} V\u2081 _inst_2)] (x : P\u2081), Eq.{succ u3} (Equiv.{succ u3, succ u3} P\u2081 P\u2081) (AffineEquiv.toEquiv.{u2, u3, u3, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4 (AffineEquiv.pointReflection.{u2, u3, u1} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x)) (Equiv.pointReflection.{u1, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u1} V\u2081 _inst_2) _inst_4 x)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.to_equiv_point_reflection AffineEquiv.toEquiv_pointReflection\u2093'. -/\n@[simp]\ntheorem toEquiv_pointReflection (x : P\u2081) :\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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (x : P\u2081), Eq.{succ u2} P\u2081 (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) x) x\nbut is expected to have type\n  forall (k : Type.{u1}) {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (x : P\u2081), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) x) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u3, u2} k P\u2081 V\u2081 _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\u2093'. -/\n@[simp]\ntheorem pointReflection_self (x : P\u2081) : 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (x : P\u2081), Function.Involutive.{succ u2} P\u2081 (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x))\nbut is expected to have type\n  forall (k : Type.{u1}) {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (x : P\u2081), Function.Involutive.{succ u3} P\u2081 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u3, u2} k P\u2081 V\u2081 _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\u2093'. -/\ntheorem pointReflection_involutive (x : P\u2081) : Involutive (pointReflection k x : P\u2081 \u2192 P\u2081) :=\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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] {x : P\u2081} {y : P\u2081}, (Function.Injective.{succ u3, succ u3} V\u2081 V\u2081 (bit0.{u3} V\u2081 (AddZeroClass.toHasAdd.{u3} V\u2081 (AddMonoid.toAddZeroClass.{u3} V\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))))))) -> (Iff (Eq.{succ u2} P\u2081 (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) y) y) (Eq.{succ u2} P\u2081 y x))\nbut is expected to have type\n  forall (k : Type.{u1}) {P\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] {x : P\u2081} {y : P\u2081}, (Function.Injective.{succ u3, succ u3} V\u2081 V\u2081 (bit0.{u3} V\u2081 (AddZeroClass.toAdd.{u3} V\u2081 (AddMonoid.toAddZeroClass.{u3} V\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))))))) -> (Iff (Eq.{succ u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) y) (FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) y) y) (Eq.{succ u2} P\u2081 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\u2093'. -/\n/-- `x` is the only fixed point of `point_reflection x`. This lemma requires\n`x + x = y + y \u2194 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\u2081} (h : Injective (bit0 : V\u2081 \u2192 V\u2081)) :\n    pointReflection k x y = y \u2194 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], (Function.Injective.{succ u3, succ u3} V\u2081 V\u2081 (bit0.{u3} V\u2081 (AddZeroClass.toHasAdd.{u3} V\u2081 (AddMonoid.toAddZeroClass.{u3} V\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))))))) -> (forall (y : P\u2081), Function.Injective.{succ u2, succ u2} P\u2081 P\u2081 (fun (x : P\u2081) => coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) y))\nbut is expected to have type\n  forall (k : Type.{u1}) {P\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)], (Function.Injective.{succ u3, succ u3} V\u2081 V\u2081 (bit0.{u3} V\u2081 (AddZeroClass.toAdd.{u3} V\u2081 (AddMonoid.toAddZeroClass.{u3} V\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))))))) -> (forall (y : P\u2081), Function.Injective.{succ u2, succ u2} P\u2081 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) y) (fun (x : P\u2081) => FunLike.coe.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u3), succ u2, succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _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\u2093'. -/\ntheorem injective_pointReflection_left_of_injective_bit0 (h : Injective (bit0 : V\u2081 \u2192 V\u2081)) (y : P\u2081) :\n    Injective fun x : P\u2081 => 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _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\u2081), Function.Injective.{succ u2, succ u2} P\u2081 P\u2081 (fun (x : P\u2081) => coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) y)\nbut is expected to have type\n  forall (k : Type.{u3}) {P\u2081 : Type.{u2}} {V\u2081 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V\u2081] [_inst_3 : Module.{u3, u1} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u1} V\u2081 _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\u2081), Function.Injective.{succ u2, succ u2} P\u2081 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) y) (fun (x : P\u2081) => FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u3, u2, u1} k P\u2081 V\u2081 _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\u2093'. -/\ntheorem injective_pointReflection_left_of_module [Invertible (2 : k)] :\n    \u2200 y, Injective fun x : P\u2081 => pointReflection k x y :=\n  injective_pointReflection_left_of_injective_bit0 k fun x y h => by\n    rwa [bit0, bit0, \u2190 two_smul k x, \u2190 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _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\u2081} {y : P\u2081}, Iff (Eq.{succ u2} P\u2081 (coeFn.{max (succ u2) (succ u3), succ u2} (AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (fun (_x : AffineEquiv.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u1, u2, u2, u3, u3} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) (AffineEquiv.pointReflection.{u1, u2, u3} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) y) y) (Eq.{succ u2} P\u2081 y x)\nbut is expected to have type\n  forall (k : Type.{u3}) {P\u2081 : Type.{u2}} {V\u2081 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u1} V\u2081] [_inst_3 : Module.{u3, u1} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u1, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u1} V\u2081 _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\u2081} {y : P\u2081}, Iff (Eq.{succ u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) y) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u2} (AffineEquiv.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u3, u2, u2, u1, u1} k P\u2081 P\u2081 V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 _inst_2 _inst_3 _inst_4))) (AffineEquiv.pointReflection.{u3, u2, u1} k P\u2081 V\u2081 _inst_1 _inst_2 _inst_3 _inst_4 x) y) y) (Eq.{succ u2} P\u2081 y x)\nCase conversion may be inaccurate. Consider using '#align affine_equiv.point_reflection_fixed_iff_of_module AffineEquiv.pointReflection_fixed_iff_of_module\u2093'. -/\ntheorem pointReflection_fixed_iff_of_module [Invertible (2 : k)] {x y : P\u2081} :\n    pointReflection k x y = y \u2194 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\u2081 \u2243\u2097[k] V\u2082) : V\u2081 \u2243\u1d43[k] V\u2082\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\u2081 : Type.{u2}} {V\u2082 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u3} V\u2082] [_inst_6 : Module.{u1, u3} k V\u2082 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V\u2082 _inst_5) _inst_3 _inst_6), Eq.{max (succ u2) (succ u3)} (V\u2081 -> V\u2082) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (AffineEquiv.{u1, u2, u3, u2, u3} k V\u2081 V\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u3} V\u2082 (AddCommGroup.toAddGroup.{u3} V\u2082 _inst_5))) (fun (_x : AffineEquiv.{u1, u2, u3, u2, u3} k V\u2081 V\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u3} V\u2082 (AddCommGroup.toAddGroup.{u3} V\u2082 _inst_5))) => V\u2081 -> V\u2082) (AffineEquiv.hasCoeToFun.{u1, u2, u3, u2, u3} k V\u2081 V\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u3} V\u2082 (AddCommGroup.toAddGroup.{u3} V\u2082 _inst_5))) (LinearEquiv.toAffineEquiv.{u1, u2, u3} k V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V\u2082 _inst_5) _inst_3 _inst_6) => V\u2081 -> V\u2082) (LinearEquiv.hasCoeToFun.{u1, u1, u2, u3} k k V\u2081 V\u2082 (Ring.toSemiring.{u1} k _inst_1) (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u3} V\u2082 _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\u2081 : Type.{u2}} {V\u2082 : Type.{u1}} [_inst_1 : Ring.{u3} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_5 : AddCommGroup.{u1} V\u2082] [_inst_6 : Module.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : V\u2081), (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : V\u2081) => V\u2082) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (AffineEquiv.{u3, u2, u1, u2, u1} k V\u2081 V\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u1} V\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5))) V\u2081 (fun (_x : V\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : V\u2081) => V\u2082) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (AffineEquiv.{u3, u2, u1, u2, u1} k V\u2081 V\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u1} V\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5))) V\u2081 V\u2082 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u1} (AffineEquiv.{u3, u2, u1, u2, u1} k V\u2081 V\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u1} V\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5))) V\u2081 V\u2082 (AffineEquiv.equivLike.{u3, u2, u1, u2, u1} k V\u2081 V\u2082 V\u2081 V\u2082 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)) _inst_5 _inst_6 (addGroupIsAddTorsor.{u1} V\u2082 (AddCommGroup.toAddGroup.{u1} V\u2082 _inst_5))))) (LinearEquiv.toAffineEquiv.{u3, u2, u1} k V\u2081 V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) V\u2081 (fun (_x : V\u2081) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : V\u2081) => V\u2082) _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (SMulZeroClass.toSMul.{u3, u2} k V\u2081 (AddMonoid.toZero.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribSMul.toSMulZeroClass.{u3, u2} k V\u2081 (AddMonoid.toAddZeroClass.{u2} V\u2081 (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2))) (DistribMulAction.toDistribSMul.{u3, u2} k V\u2081 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3)))) (SMulZeroClass.toSMul.{u3, u1} k V\u2082 (AddMonoid.toZero.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribSMul.toSMulZeroClass.{u3, u1} k V\u2082 (AddMonoid.toAddZeroClass.{u1} V\u2082 (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5))) (DistribMulAction.toDistribSMul.{u3, u1} k V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) k V\u2081 V\u2082 (MonoidWithZero.toMonoid.{u3} k (Semiring.toMonoidWithZero.{u3} k (Ring.toSemiring.{u3} k _inst_1))) (AddCommMonoid.toAddMonoid.{u2} V\u2081 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)) (AddCommMonoid.toAddMonoid.{u1} V\u2082 (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5)) (Module.toDistribMulAction.{u3, u2} k V\u2081 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) _inst_3) (Module.toDistribMulAction.{u3, u1} k V\u2082 (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_6) (SemilinearMapClass.distribMulActionHomClass.{u3, u2, u1, max u2 u1} k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6 (SemilinearEquivClass.instSemilinearMapClass.{u3, u3, u2, u1, max u2 u1} k k V\u2081 V\u2082 (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\u2081 V\u2082 (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _inst_5) _inst_3 _inst_6) (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2081 V\u2082 (Ring.toSemiring.{u3} k _inst_1) (Ring.toSemiring.{u3} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2) (AddCommGroup.toAddCommMonoid.{u1} V\u2082 _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\u2093'. -/\n@[simp]\ntheorem coe_toAffineEquiv (e : V\u2081 \u2243\u2097[k] V\u2082) : \u21d1e.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\u2081\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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (v : V\u2081) (v' : V\u2081) (p : P\u2081) (c : k), Eq.{succ u2} P\u2081 (VAdd.vadd.{u3, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u3, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _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\u2081 V\u2081 _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\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (fun (_x : AffineMap.{u1, u1, u1, u3, u3} k k k V\u2081 V\u2081 _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\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) => k -> V\u2081) (AffineMap.hasCoeToFun.{u1, u1, u1, u3, u3} k k k V\u2081 V\u2081 _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\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AffineMap.lineMap.{u1, u3, u3} k V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _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\u2081 P\u2081 _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\u2081 P\u2081 _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\u2081) (AffineMap.hasCoeToFun.{u1, u1, u1, u3, u2} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (VAdd.vadd.{u3, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u3, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4)) v p) (VAdd.vadd.{u3, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u3, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4)) v' p)) c)\nbut is expected to have type\n  forall {k : Type.{u1}} {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (v : V\u2081) (v' : V\u2081) (p : P\u2081) (c : k), Eq.{succ u3} P\u2081 (HVAdd.hVAdd.{u2, u3, u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) c) P\u2081 P\u2081 (instHVAdd.{u2, u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) c) P\u2081 (AddAction.toVAdd.{u2, u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) c) P\u2081 (SubNegMonoid.toAddMonoid.{u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) c) (AddGroup.toSubNegMonoid.{u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) c) (AddCommGroup.toAddGroup.{u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) c) _inst_2))) (AddTorsor.toAddAction.{u2, u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) c) P\u2081 (AddCommGroup.toAddGroup.{u2} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) 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\u2081 V\u2081 _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\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) k (fun (_x : k) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => V\u2081) _x) (AffineMap.funLike.{u1, u1, u1, u2, u2} k k k V\u2081 V\u2081 _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\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AffineMap.lineMap.{u1, u2, u2} k V\u2081 V\u2081 _inst_1 _inst_2 _inst_3 (addGroupIsAddTorsor.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _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\u2081 P\u2081 _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\u2081) _x) (AffineMap.funLike.{u1, u1, u1, u2, u3} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (HVAdd.hVAdd.{u2, u3, u3} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u3} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u3} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v p) (HVAdd.hVAdd.{u2, u3, u3} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u3} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u3} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v' p)) c)\nCase conversion may be inaccurate. Consider using '#align affine_map.line_map_vadd AffineMap.lineMap_vadd\u2093'. -/\ntheorem lineMap_vadd (v v' : V\u2081) (p : P\u2081) (c : k) :\n    lineMap v v' c +\u1d65 p = lineMap (v +\u1d65 p) (v' +\u1d65 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\u2081 p\u2082 p\u2083 : P\u2081) (c : k) :\n    lineMap p\u2081 p\u2082 c -\u1d65 p\u2083 = lineMap (p\u2081 -\u1d65 p\u2083) (p\u2082 -\u1d65 p\u2083) c :=\n  (vaddConst k p\u2083).symm.apply_lineMap p\u2081 p\u2082 c\n#align affine_map.line_map_vsub AffineMap.lineMap_vsub\n-/\n\n#print AffineMap.vsub_lineMap /-\ntheorem vsub_lineMap (p\u2081 p\u2082 p\u2083 : P\u2081) (c : k) :\n    p\u2081 -\u1d65 lineMap p\u2082 p\u2083 c = lineMap (p\u2081 -\u1d65 p\u2082) (p\u2081 -\u1d65 p\u2083) c :=\n  (constVSub k p\u2081).apply_lineMap p\u2082 p\u2083 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\u2081 : Type.{u2}} {V\u2081 : Type.{u3}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u3} V\u2081] [_inst_3 : Module.{u1, u3} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u3} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2)] (v : V\u2081) (p\u2081 : P\u2081) (p\u2082 : P\u2081) (c : k), Eq.{succ u2} P\u2081 (VAdd.vadd.{u3, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u3, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _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\u2081 P\u2081 _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\u2081 P\u2081 _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\u2081) (AffineMap.hasCoeToFun.{u1, u1, u1, u3, u2} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 p\u2081 p\u2082) c)) (coeFn.{max (succ u1) (succ u3) (succ u2), max (succ u1) (succ u2)} (AffineMap.{u1, u1, u1, u3, u2} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _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\u2081) (AffineMap.hasCoeToFun.{u1, u1, u1, u3, u2} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (VAdd.vadd.{u3, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u3, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4)) v p\u2081) (VAdd.vadd.{u3, u2} V\u2081 P\u2081 (AddAction.toHasVadd.{u3, u2} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u3} V\u2081 (AddGroup.toSubNegMonoid.{u3} V\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u3, u2} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u3} V\u2081 _inst_2) _inst_4)) v p\u2082)) c)\nbut is expected to have type\n  forall {k : Type.{u1}} {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_1 : Ring.{u1} k] [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_3 : Module.{u1, u2} k V\u2081 (Ring.toSemiring.{u1} k _inst_1) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] (v : V\u2081) (p\u2081 : P\u2081) (p\u2082 : P\u2081) (c : k), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P\u2081) c) (HVAdd.hVAdd.{u2, u3, u3} V\u2081 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P\u2081) c) ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P\u2081) c) (instHVAdd.{u2, u3} V\u2081 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P\u2081) c) (AddAction.toVAdd.{u2, u3} V\u2081 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P\u2081) c) (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u3} V\u2081 ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : k) => P\u2081) c) (AddCommGroup.toAddGroup.{u2} V\u2081 _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\u2081 P\u2081 _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\u2081) _x) (AffineMap.funLike.{u1, u1, u1, u2, u3} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 p\u2081 p\u2082) 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\u2081 P\u2081 _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\u2081) _x) (AffineMap.funLike.{u1, u1, u1, u2, u3} k k k V\u2081 P\u2081 _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\u2081 P\u2081 _inst_1 _inst_2 _inst_3 _inst_4 (HVAdd.hVAdd.{u2, u3, u3} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u3} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u3} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v p\u2081) (HVAdd.hVAdd.{u2, u3, u3} V\u2081 P\u2081 P\u2081 (instHVAdd.{u2, u3} V\u2081 P\u2081 (AddAction.toVAdd.{u2, u3} V\u2081 P\u2081 (SubNegMonoid.toAddMonoid.{u2} V\u2081 (AddGroup.toSubNegMonoid.{u2} V\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2))) (AddTorsor.toAddAction.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2) _inst_4))) v p\u2082)) c)\nCase conversion may be inaccurate. Consider using '#align affine_map.vadd_line_map AffineMap.vadd_lineMap\u2093'. -/\ntheorem vadd_lineMap (v : V\u2081) (p\u2081 p\u2082 : P\u2081) (c : k) :\n    v +\u1d65 lineMap p\u2081 p\u2082 c = lineMap (v +\u1d65 p\u2081) (v +\u1d65 p\u2082) c :=\n  (constVAdd k P\u2081 v).apply_lineMap p\u2081 p\u2082 c\n#align affine_map.vadd_line_map AffineMap.vadd_lineMap\n\nvariable {R' : Type _} [CommRing R'] [Module R' V\u2081]\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\u2081 : Type.{u1}} {V\u2081 : Type.{u2}} [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_4 : AddTorsor.{u2, u1} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] {R' : Type.{u3}} [_inst_14 : CommRing.{u3} R'] [_inst_15 : Module.{u3, u2} R' V\u2081 (Ring.toSemiring.{u3} R' (CommRing.toRing.{u3} R' _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] (c : P\u2081) (p : P\u2081), Eq.{succ u1} P\u2081 (coeFn.{max (succ u2) (succ u1), succ u1} (AffineMap.{u3, u2, u1, u2, u1} R' V\u2081 P\u2081 V\u2081 P\u2081 (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\u2081 P\u2081 V\u2081 P\u2081 (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) => P\u2081 -> P\u2081) (AffineMap.hasCoeToFun.{u3, u2, u1, u2, u1} R' V\u2081 P\u2081 V\u2081 P\u2081 (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\u2081 P\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 (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\u2081 P\u2081 V\u2081 V\u2081 (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) => P\u2081 -> P\u2081) (AffineEquiv.hasCoeToFun.{u3, u1, u1, u2, u2} R' P\u2081 P\u2081 V\u2081 V\u2081 (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\u2081 V\u2081 (CommRing.toRing.{u3} R' _inst_14) _inst_2 _inst_15 _inst_4 c) p)\nbut is expected to have type\n  forall {P\u2081 : Type.{u3}} {V\u2081 : Type.{u2}} [_inst_2 : AddCommGroup.{u2} V\u2081] [_inst_4 : AddTorsor.{u2, u3} V\u2081 P\u2081 (AddCommGroup.toAddGroup.{u2} V\u2081 _inst_2)] {R' : Type.{u1}} [_inst_14 : CommRing.{u1} R'] [_inst_15 : Module.{u1, u2} R' V\u2081 (Ring.toSemiring.{u1} R' (CommRing.toRing.{u1} R' _inst_14)) (AddCommGroup.toAddCommMonoid.{u2} V\u2081 _inst_2)] (c : P\u2081) (p : P\u2081), Eq.{succ u3} ((fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2081) p) (FunLike.coe.{max (succ u2) (succ u3), succ u3, succ u3} (AffineMap.{u1, u2, u3, u2, u3} R' V\u2081 P\u2081 V\u2081 P\u2081 (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineMap._hyg.1004 : P\u2081) => P\u2081) _x) (AffineMap.funLike.{u1, u2, u3, u2, u3} R' V\u2081 P\u2081 V\u2081 P\u2081 (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\u2081 P\u2081 _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\u2081 P\u2081 V\u2081 V\u2081 (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) P\u2081 (fun (_x : P\u2081) => (fun (a._@.Mathlib.LinearAlgebra.AffineSpace.AffineEquiv._hyg.1471 : P\u2081) => P\u2081) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} R' P\u2081 P\u2081 V\u2081 V\u2081 (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) P\u2081 P\u2081 (EquivLike.toEmbeddingLike.{max (succ u3) (succ u2), succ u3, succ u3} (AffineEquiv.{u1, u3, u3, u2, u2} R' P\u2081 P\u2081 V\u2081 V\u2081 (CommRing.toRing.{u1} R' _inst_14) _inst_2 _inst_15 _inst_4 _inst_2 _inst_15 _inst_4) P\u2081 P\u2081 (AffineEquiv.equivLike.{u1, u3, u3, u2, u2} R' P\u2081 P\u2081 V\u2081 V\u2081 (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\u2081 V\u2081 (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\u2093'. -/\ntheorem homothety_neg_one_apply (c p : P\u2081) : 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 ` \u2192\u1d47 ` : 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 \u2192\u1d47 \u211d) := sorry\ninstance : semilattice_inf_top (X \u2192\u1d47 \u211d) := sorry\n\nvariables {M\u2080 : set (X \u2192\u1d47 \u211d)}\n\n-- The following 10 propositions are trivial\nlemma le_finset_sup {I : finset X} (g : X \u2192 X \u2192\u1d47 \u211d) :\n\u2200 i \u2208 I, \u2200 x : X, g i x \u2264 (I.sup g) x := sorry\n\nlemma finset_sup_lt {I : finset X} {g : X \u2192 X \u2192\u1d47 \u211d} {x} {r} \n(hlt : \u2200 i \u2208 I, g i x < r) : (I.sup g) x < r := sorry\n\nlemma finset_sup_mem_closure\u2080 {I : finset X} {g : X \u2192 X \u2192\u1d47 \u211d} \n(hg : \u2200 i, g i \u2208 closure\u2080 M\u2080) : I.sup g \u2208 closure\u2080 M\u2080 := sorry\n\nlemma finset_inf_le {I : finset X} (g : X \u2192 X \u2192\u1d47 \u211d) :\n\u2200 i \u2208 I, \u2200 x : X, (I.inf g) x \u2264 g i x := sorry\n\nlemma lt_finset_inf {I : finset X} {g : X \u2192 X \u2192\u1d47 \u211d} {x} {r} \n(hlt : \u2200 i \u2208 I, r < g i x) : r < (I.inf g) x := sorry\n\nlemma finset_inf_mem_closure\u2080 {I : finset X} {g : X \u2192 X \u2192\u1d47 \u211d} \n(hg : \u2200 i, g i \u2208 closure\u2080 M\u2080) : I.inf g \u2208 closure\u2080 M\u2080 := sorry\n\nlemma is_open_aux_set\u2080 {f : X \u2192\u1d47 \u211d} \n{g : X \u2192 X \u2192\u1d47 \u211d} {\u03b5 : \u211d} (h\u03b5 : \u03b5 > 0) : \n\u2200 y : X, is_open {z : X | f z - (g y) z < \u03b5} := sorry\n\nlemma is_open_aux_set\u2081 {f : X \u2192\u1d47 \u211d} \n{g : X \u2192 X \u2192\u1d47 \u211d} {\u03b5 : \u211d} (h\u03b5 : \u03b5 > 0) : \n\u2200 x : X, is_open {z : X | g x z < f z + \u03b5} := sorry\n\nlemma neg_inf_eq_sup {f g h : X \u2192\u1d47 \u211d} : f = g \u2294 h \u2194 -f = -g \u2293 -h := sorry\nlemma neg_sup_eq_inf {f g h : X \u2192\u1d47 \u211d} : f = g \u2293 h \u2194 -f = -g \u2294 -h := sorry\n\n/- Follows by choosing the same \u03b4 from hF -/\nlemma neg_unif_converges_to {f : X \u2192\u1d47 \u211d} {F : \u2115 \u2192 (X \u2192\u1d47 \u211d)} \n(hF : unif_converges_to (\u03bb n, F n) f) : unif_converges_to (\u03bb 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 \u2200 z \u2208 \u211d\u00b2, f : X \u2192\u1d47 \u211d, (u : X) \u21a6 z.1 if u = x, else z.2 -/\nlemma boundary_points_of_univ : \u2200 x y : X, boundary_points univ x y = univ := sorry\n\n/- This is true since M\u2080' is a subalgebra \u21d2 1 \u2208 M\u2080'.carrier and \n\u2200 \u03bc \u2208 \u211d, \u2200 f \u2208 M\u2080'.carrier, \u03bcf \u2208 M\u2080'.carrier \u21d2 r \u2022 1 \u2208 M\u2080'.carrier -/\nlemma subalgebra_closed_under_smul' {M\u2080' : subalgebra \u211d (X \u2192\u1d47 \u211d)} :\n\u2200 (\u03b1 : \u211d) {x}, x \u2208 M\u2080'.carrier \u2192 \u03b1 \u2022 x \u2208 M\u2080'.carrier := sorry\n\n-- The following 4 propositions are trivial\nlemma closure\u2082_of_closure\u2082 (M\u2080 : set (X \u2192\u1d47 \u211d)) : \nclosure\u2082 (closure\u2082 M\u2080) = closure\u2082 M\u2080 := sorry\n\nlemma closure\u2080_closed_with_sup {M\u2080 : set (X \u2192\u1d47 \u211d)} {f g} \n(hf : f \u2208 closure\u2080 M\u2080) (hg : g \u2208 closure\u2080 M\u2080) : f \u2294 g \u2208 closure\u2080 M\u2080 := sorry\n\nlemma closure\u2080_closed_with_inf {M\u2080 : set (X \u2192\u1d47 \u211d)} {f g} \n(hf : f \u2208 closure\u2080 M\u2080) (hg : g \u2208 closure\u2080 M\u2080) : f \u2293 g \u2208 closure\u2080 M\u2080 := sorry\n\nlemma closure_le_seq\u2081 {M\u2080 : set (X \u2192\u1d47 \u211d)} :\nclosure\u2080 M\u2080 \u2286 closure\u2082 M\u2080 := sorry\n\n/- To prove `closure\u2082_subalgebra` we need to first show that `closure\u2082 M\u2080'.carrier` \nforms a subring. The is easily shown since M\u2080'.carrier \u2286 closure\u2082 M\u2080'.carrier and \nclosure\u2082 M\u2080'.carrier is closed.\n\nWe also need to show `range_le'` but this also follows directly from M\u2080'.carrier \n\u2286 closure\u2082 M\u2080'.carrier. -/\ndef closure\u2082_subalgebra (M\u2080' : subalgebra \u211d (X \u2192\u1d47 \u211d)) : subalgebra \u211d (X \u2192\u1d47 \u211d) := \n{ carrier := closure\u2082 M\u2080'.carrier,\n  subring := sorry,\n  range_le' := sorry}\n\n/- This is the trivial subalgebra -/\ndef univ_subalgebra : subalgebra \u211d (X \u2192\u1d47 \u211d) := \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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 \u03b2 \u03b3 : Sort*} {f : \u03b1 \u2192 \u03b2}\n\n/-- Evaluate a function at an argument. Useful if you want to talk about the partially applied\n  `function.eval x : (\u03a0 x, \u03b2 x) \u2192 \u03b2 x`. -/\n@[reducible] def eval {\u03b2 : \u03b1 \u2192 Sort*} (x : \u03b1) (f : \u03a0 x, \u03b2 x) : \u03b2 x := f x\n\n@[simp] lemma eval_apply {\u03b2 : \u03b1 \u2192 Sort*} (x : \u03b1) (f : \u03a0 x, \u03b2 x) : eval x f = f x := rfl\n\nlemma comp_apply {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03c6 : Sort w} (f : \u03b2 \u2192 \u03c6) (g : \u03b1 \u2192 \u03b2) (a : \u03b1) :\n  (f \u2218 g) a = f (g a) := rfl\n\nlemma const_def {y : \u03b2} : (\u03bb x : \u03b1, y) = const \u03b1 y := rfl\n\n@[simp] lemma const_apply {y : \u03b2} {x : \u03b1} : const \u03b1 y x = y := rfl\n\n@[simp] lemma const_comp {f : \u03b1 \u2192 \u03b2} {c : \u03b3} : const \u03b2 c \u2218 f = const \u03b1 c := rfl\n\n@[simp] lemma comp_const {f : \u03b2 \u2192 \u03b3} {b : \u03b2} : f \u2218 const \u03b1 b = const \u03b1 (f b) := rfl\n\nlemma id_def : @id \u03b1 = \u03bb x, x := rfl\n\nlemma hfunext {\u03b1 \u03b1': Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {\u03b2' : \u03b1' \u2192 Sort v} {f : \u03a0a, \u03b2 a} {f' : \u03a0a, \u03b2' a}\n  (h\u03b1 : \u03b1 = \u03b1') (h : \u2200a a', a == a' \u2192 f a == f' a') : f == f' :=\nbegin\n  subst h\u03b1,\n  have : \u2200a, f a == f' a,\n  { intro a, exact h a a (heq.refl a) },\n  have : \u03b2 = \u03b2',\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 {\u03b2 : \u03b1 \u2192 Sort*} {f\u2081 f\u2082 : \u03a0 (x : \u03b1), \u03b2 x} : f\u2081 = f\u2082 \u2194 (\u2200 a, f\u2081 a = f\u2082 a) :=\niff.intro (assume h a, h \u25b8 rfl) funext\n\nlemma ne_iff {\u03b2 : \u03b1 \u2192 Sort*} {f\u2081 f\u2082 : \u03a0 a, \u03b2 a} : f\u2081 \u2260 f\u2082 \u2194 \u2203 a, f\u2081 a \u2260 f\u2082 a :=\nfunext_iff.not.trans not_forall\n\nprotected lemma bijective.injective {f : \u03b1 \u2192 \u03b2} (hf : bijective f) : injective f := hf.1\nprotected lemma bijective.surjective {f : \u03b1 \u2192 \u03b2} (hf : bijective f) : surjective f := hf.2\n\ntheorem injective.eq_iff (I : injective f) {a b : \u03b1} :\n  f a = f b \u2194 a = b :=\n\u27e8@I _ _, congr_arg f\u27e9\n\ntheorem injective.eq_iff' (I : injective f) {a b : \u03b1} {c : \u03b2} (h : f b = c) :\n  f a = c \u2194 a = b :=\nh \u25b8 I.eq_iff\n\nlemma injective.ne (hf : injective f) {a\u2081 a\u2082 : \u03b1} : a\u2081 \u2260 a\u2082 \u2192 f a\u2081 \u2260 f a\u2082 :=\nmt (assume h, hf h)\n\nlemma injective.ne_iff (hf : injective f) {x y : \u03b1} : f x \u2260 f y \u2194 x \u2260 y :=\n\u27e8mt $ congr_arg f, hf.ne\u27e9\n\nlemma injective.ne_iff' (hf : injective f) {x y : \u03b1} {z : \u03b2} (h : f y = z) :\n  f x \u2260 z \u2194 x \u2260 y :=\nh \u25b8 hf.ne_iff\n\n/-- If the co-domain `\u03b2` of an injective function `f : \u03b1 \u2192 \u03b2` has decidable equality, then\nthe domain `\u03b1` also has decidable equality. -/\ndef injective.decidable_eq [decidable_eq \u03b2] (I : injective f) : decidable_eq \u03b1 :=\n\u03bb a b, decidable_of_iff _ I.eq_iff\n\nlemma injective.of_comp {g : \u03b3 \u2192 \u03b1} (I : injective (f \u2218 g)) : injective g :=\n\u03bb x y h, I $ show f (g x) = f (g y), from congr_arg f h\n\nlemma injective.of_comp_iff {f : \u03b1 \u2192 \u03b2} (hf : injective f) (g : \u03b3 \u2192 \u03b1) :\n  injective (f \u2218 g) \u2194 injective g :=\n\u27e8injective.of_comp, hf.comp\u27e9\n\nlemma injective.of_comp_iff' (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : bijective g) :\n  injective (f \u2218 g) \u2194 injective f :=\n\u27e8 \u03bb h x y, let \u27e8x', hx\u27e9 := hg.surjective x, \u27e8y', hy\u27e9 := hg.surjective y in\n    hx \u25b8 hy \u25b8 \u03bb hf, h hf \u25b8 rfl,\n  \u03bb h, h.comp hg.injective\u27e9\n\n/-- Composition by an injective function on the left is itself injective. -/\nlemma injective.comp_left {g : \u03b2 \u2192 \u03b3} (hg : function.injective g) :\n  function.injective ((\u2218) g : (\u03b1 \u2192 \u03b2) \u2192 (\u03b1 \u2192 \u03b3)) :=\n\u03bb f\u2081 f\u2082 hgf, funext $ \u03bb i, hg $ (congr_fun hgf i : _)\n\nlemma injective_of_subsingleton [subsingleton \u03b1] (f : \u03b1 \u2192 \u03b2) :\n  injective f :=\n\u03bb a b ab, subsingleton.elim _ _\n\nlemma injective.dite (p : \u03b1 \u2192 Prop) [decidable_pred p]\n  {f : {a : \u03b1 // p a} \u2192 \u03b2} {f' : {a : \u03b1 // \u00ac p a} \u2192 \u03b2}\n  (hf : injective f) (hf' : injective f')\n  (im_disj : \u2200 {x x' : \u03b1} {hx : p x} {hx' : \u00ac p x'}, f \u27e8x, hx\u27e9 \u2260 f' \u27e8x', hx'\u27e9) :\n  function.injective (\u03bb x, if h : p x then f \u27e8x, h\u27e9 else f' \u27e8x, h\u27e9) :=\n\u03bb x\u2081 x\u2082 h, begin\n  dsimp only at h,\n  by_cases h\u2081 : p x\u2081; by_cases h\u2082 : p x\u2082,\n  { rw [dif_pos h\u2081, dif_pos h\u2082] at h, injection (hf h), },\n  { rw [dif_pos h\u2081, dif_neg h\u2082] at h, exact (im_disj h).elim, },\n  { rw [dif_neg h\u2081, dif_pos h\u2082] at h, exact (im_disj h.symm).elim, },\n  { rw [dif_neg h\u2081, dif_neg h\u2082] at h, injection (hf' h), },\nend\n\nlemma surjective.of_comp {g : \u03b3 \u2192 \u03b1} (S : surjective (f \u2218 g)) : surjective f :=\n\u03bb y, let \u27e8x, h\u27e9 := S y in \u27e8g x, h\u27e9\n\nlemma surjective.of_comp_iff (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : surjective g) :\n  surjective (f \u2218 g) \u2194 surjective f :=\n\u27e8surjective.of_comp, \u03bb h, h.comp hg\u27e9\n\nlemma surjective.of_comp_iff' (hf : bijective f) (g : \u03b3 \u2192 \u03b1) :\n  surjective (f \u2218 g) \u2194 surjective g :=\n\u27e8\u03bb h x, let \u27e8x', hx'\u27e9 := h (f x) in \u27e8x', hf.injective hx'\u27e9, hf.surjective.comp\u27e9\n\ninstance decidable_eq_pfun (p : Prop) [decidable p] (\u03b1 : p \u2192 Type*)\n  [\u03a0 hp, decidable_eq (\u03b1 hp)] : decidable_eq (\u03a0 hp, \u03b1 hp)\n| f g := decidable_of_iff (\u2200 hp, f hp = g hp) funext_iff.symm\n\nprotected theorem surjective.forall (hf : surjective f) {p : \u03b2 \u2192 Prop} :\n  (\u2200 y, p y) \u2194 \u2200 x, p (f x) :=\n\u27e8\u03bb h x, h (f x), \u03bb h y, let \u27e8x, hx\u27e9 := hf y in hx \u25b8 h x\u27e9\n\nprotected theorem surjective.forall\u2082 (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2200 y\u2081 y\u2082, p y\u2081 y\u2082) \u2194 \u2200 x\u2081 x\u2082, p (f x\u2081) (f x\u2082) :=\nhf.forall.trans $ forall_congr $ \u03bb x, hf.forall\n\nprotected theorem surjective.forall\u2083 (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2200 y\u2081 y\u2082 y\u2083, p y\u2081 y\u2082 y\u2083) \u2194 \u2200 x\u2081 x\u2082 x\u2083, p (f x\u2081) (f x\u2082) (f x\u2083) :=\nhf.forall.trans $ forall_congr $ \u03bb x, hf.forall\u2082\n\nprotected theorem surjective.exists (hf : surjective f) {p : \u03b2 \u2192 Prop} :\n  (\u2203 y, p y) \u2194 \u2203 x, p (f x) :=\n\u27e8\u03bb \u27e8y, hy\u27e9, let \u27e8x, hx\u27e9 := hf y in \u27e8x, hx.symm \u25b8 hy\u27e9, \u03bb \u27e8x, hx\u27e9, \u27e8f x, hx\u27e9\u27e9\n\nprotected theorem surjective.exists\u2082 (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2203 y\u2081 y\u2082, p y\u2081 y\u2082) \u2194 \u2203 x\u2081 x\u2082, p (f x\u2081) (f x\u2082) :=\nhf.exists.trans $ exists_congr $ \u03bb x, hf.exists\n\nprotected theorem surjective.exists\u2083 (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2203 y\u2081 y\u2082 y\u2083, p y\u2081 y\u2082 y\u2083) \u2194 \u2203 x\u2081 x\u2082 x\u2083, p (f x\u2081) (f x\u2082) (f x\u2083) :=\nhf.exists.trans $ exists_congr $ \u03bb x, hf.exists\u2082\n\nlemma surjective.injective_comp_right (hf : surjective f) :\n  injective (\u03bb g : \u03b2 \u2192 \u03b3, g \u2218 f) :=\n\u03bb g\u2081 g\u2082 h, funext $ hf.forall.2 $ congr_fun h\n\nprotected lemma surjective.right_cancellable (hf : surjective f) {g\u2081 g\u2082 : \u03b2 \u2192 \u03b3} :\n  g\u2081 \u2218 f = g\u2082 \u2218 f \u2194 g\u2081 = g\u2082 :=\nhf.injective_comp_right.eq_iff\n\nlemma surjective_of_right_cancellable_Prop (h : \u2200 g\u2081 g\u2082 : \u03b2 \u2192 Prop, g\u2081 \u2218 f = g\u2082 \u2218 f \u2192 g\u2081 = g\u2082) :\n  surjective f :=\nbegin\n  specialize h (\u03bb _, true) (\u03bb y, \u2203 x, f x = y) (funext $ \u03bb x, _),\n  { simp only [(\u2218), exists_apply_eq_apply] },\n  { intro y,\n    have : true = \u2203 x, f x = y, from congr_fun h y,\n    rw \u2190 this, exact trivial }\nend\n\nlemma bijective_iff_exists_unique (f : \u03b1 \u2192 \u03b2) : bijective f \u2194\n  \u2200 b : \u03b2, \u2203! (a : \u03b1), f a = b :=\n\u27e8 \u03bb hf b, let \u27e8a, ha\u27e9 := hf.surjective b in \u27e8a, ha, \u03bb a' ha', hf.injective (ha'.trans ha.symm)\u27e9,\n  \u03bb he, \u27e8\n    \u03bb a a' h, unique_of_exists_unique (he (f a')) h rfl,\n    \u03bb b, exists_of_exists_unique (he b) \u27e9\u27e9\n\n/-- Shorthand for using projection notation with `function.bijective_iff_exists_unique`. -/\nprotected lemma bijective.exists_unique {f : \u03b1 \u2192 \u03b2} (hf : bijective f) (b : \u03b2) :\n  \u2203! (a : \u03b1), f a = b :=\n(bijective_iff_exists_unique f).mp hf b\n\nlemma bijective.exists_unique_iff {f : \u03b1 \u2192 \u03b2} (hf : bijective f) {p : \u03b2 \u2192 Prop} :\n  (\u2203! y, p y) \u2194 \u2203! x, p (f x) :=\n\u27e8\u03bb \u27e8y, hpy, hy\u27e9, let \u27e8x, hx\u27e9 := hf.surjective y in \u27e8x, by rwa hx,\n  \u03bb z (hz : p (f z)), hf.injective $ hx.symm \u25b8 hy _ hz\u27e9,\n  \u03bb \u27e8x, hpx, hx\u27e9, \u27e8f x, hpx, \u03bb y hy,\n    let \u27e8z, hz\u27e9 := hf.surjective y in hz \u25b8 congr_arg f $ hx _ $ by rwa hz\u27e9\u27e9\n\nlemma bijective.of_comp_iff (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : bijective g) :\n  bijective (f \u2218 g) \u2194 bijective f :=\nand_congr (injective.of_comp_iff' _ hg) (surjective.of_comp_iff _ hg.surjective)\n\nlemma bijective.of_comp_iff' {f : \u03b1 \u2192 \u03b2} (hf : bijective f) (g : \u03b3 \u2192 \u03b1) :\n  function.bijective (f \u2218 g) \u2194 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 `\u03b1`\nto `set \u03b1`. -/\ntheorem cantor_surjective {\u03b1} (f : \u03b1 \u2192 set \u03b1) : \u00ac function.surjective f | h :=\nlet \u27e8D, e\u27e9 := h (\u03bb a, \u00ac 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 \u03b1`\nto `\u03b1`. -/\ntheorem cantor_injective {\u03b1 : Type*} (f : (set \u03b1) \u2192 \u03b1) :\n  \u00ac function.injective f | i :=\ncantor_surjective (\u03bb a b, \u2200 U, a = f U \u2192 U b) $\nright_inverse.surjective (\u03bb U, funext $ \u03bb a, propext \u27e8\u03bb h, h U rfl, \u03bb h' U' e, i e \u25b8 h'\u27e9)\n\n/-- There is no surjection from `\u03b1 : Type u` into `Type u`. This theorem\n  demonstrates why `Type : Type` would be inconsistent in Lean. -/\ntheorem not_surjective_Type {\u03b1 : Type u} (f : \u03b1 \u2192 Type (max u v)) :\n  \u00ac 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 \u2192 T := \u03bb s, \u27e8U, cast hU.symm s\u27e9,\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 option \u03b1) : Prop :=\n\u2200 x y, g y = some x \u2194 f x = y\n\ntheorem is_partial_inv_left {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g) (x) : g (f x) = some x :=\n(H _ _).2 rfl\n\ntheorem injective_of_partial_inv {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g) : injective f :=\n\u03bb a b h, option.some.inj $ ((H _ _).2 h).symm.trans ((H _ _).2 rfl)\n\ntheorem injective_of_partial_inv_right {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g)\n (x y b) (h\u2081 : b \u2208 g x) (h\u2082 : b \u2208 g y) : x = y :=\n((H _ _).1 h\u2081).symm.trans ((H _ _).1 h\u2082)\n\ntheorem left_inverse.comp_eq_id {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse f g) : f \u2218 g = id :=\nfunext h\n\ntheorem left_inverse_iff_comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} : left_inverse f g \u2194 f \u2218 g = id :=\n\u27e8left_inverse.comp_eq_id, congr_fun\u27e9\n\ntheorem right_inverse.comp_eq_id {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : right_inverse f g) : g \u2218 f = id :=\nfunext h\n\ntheorem right_inverse_iff_comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} : right_inverse f g \u2194 g \u2218 f = id :=\n\u27e8right_inverse.comp_eq_id, congr_fun\u27e9\n\ntheorem left_inverse.comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} {h : \u03b2 \u2192 \u03b3} {i : \u03b3 \u2192 \u03b2}\n  (hf : left_inverse f g) (hh : left_inverse h i) : left_inverse (h \u2218 f) (g \u2218 i) :=\nassume a, show h (f (g (i a))) = a, by rw [hf (i a), hh a]\n\ntheorem right_inverse.comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} {h : \u03b2 \u2192 \u03b3} {i : \u03b3 \u2192 \u03b2}\n  (hf : right_inverse f g) (hh : right_inverse h i) : right_inverse (h \u2218 f) (g \u2218 i) :=\nleft_inverse.comp hh hf\n\ntheorem left_inverse.right_inverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse g f) :\n  right_inverse f g := h\n\ntheorem right_inverse.left_inverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : right_inverse g f) :\n  left_inverse f g := h\n\ntheorem left_inverse.surjective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse f g) :\n  surjective f :=\nh.right_inverse.surjective\n\ntheorem right_inverse.injective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : right_inverse f g) :\n  injective f :=\nh.left_inverse.injective\n\ntheorem left_inverse.right_inverse_of_injective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse f g)\n  (hf : injective f) :\n  right_inverse f g :=\n\u03bb x, hf $ h (f x)\n\ntheorem left_inverse.right_inverse_of_surjective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse f g)\n  (hg : surjective g) :\n  right_inverse f g :=\n\u03bb x, let \u27e8y, hy\u27e9 := hg x in hy \u25b8 congr_arg g (h y)\n\ntheorem left_inverse.eq_right_inverse {f : \u03b1 \u2192 \u03b2} {g\u2081 g\u2082 : \u03b2 \u2192 \u03b1} (h\u2081 : left_inverse g\u2081 f)\n  (h\u2082 : right_inverse g\u2082 f) :\n  g\u2081 = g\u2082 :=\ncalc g\u2081 = g\u2081 \u2218 f \u2218 g\u2082 : by rw [h\u2082.comp_eq_id, comp.right_id]\n    ... = g\u2082          : by rw [\u2190 comp.assoc, h\u2081.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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (b : \u03b2) : option \u03b1 :=\nif h : \u2203 a, f a = b then some (classical.some h) else none\n\ntheorem partial_inv_of_injective {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} (I : injective f) :\n  is_partial_inv f (partial_inv f) | a b :=\n\u27e8\u03bb h, if h' : \u2203 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 \u03bb e, e \u25b8 have h : \u2203 a', f a' = f a, from \u27e8_, rfl\u27e9,\n   (dif_pos h).trans (congr_arg _ (I $ classical.some_spec h))\u27e9\n\ntheorem partial_inv_left {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} (I : injective f) : \u2200 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 {\u03b1 \u03b2 : Sort*} [nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} {a : \u03b1} {b : \u03b2}\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 : \u03b1 \u2192 \u03b2) : \u03b2 \u2192 \u03b1 :=\n\u03bb y, if h : \u2203 x, f x = y then h.some else classical.arbitrary \u03b1\n\ntheorem inv_fun_eq (h : \u2203 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 : \u00ac \u2203 a, f a = b) : inv_fun f b = classical.choice \u2039_\u203a :=\ndif_neg h\n\ntheorem inv_fun_eq_of_injective_of_right_inverse {g : \u03b2 \u2192 \u03b1}\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 \u27e8g b, hg b\u27e9 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\u03bb b, hf $ inv_fun_eq \u27e8b, rfl\u27e9\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 \u2218 f = id := funext $ left_inverse_inv_fun hf\n\nlemma injective.has_left_inverse (hf : injective f) : has_left_inverse f :=\n\u27e8inv_fun f, left_inverse_inv_fun hf\u27e9\n\nlemma injective_iff_has_left_inverse : injective f \u2194 has_left_inverse f :=\n\u27e8injective.has_left_inverse, has_left_inverse.injective\u27e9\n\nend inv_fun\n\nsection surj_inv\nvariables {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {f : \u03b1 \u2192 \u03b2}\n\n/-- The inverse of a surjective function. (Unlike `inv_fun`, this does not require\n  `\u03b1` to be inhabited.) -/\nnoncomputable def surj_inv {f : \u03b1 \u2192 \u03b2} (h : surjective f) (b : \u03b2) : \u03b1 := 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\u27e8_, right_inverse_surj_inv hf\u27e9\n\nlemma surjective_iff_has_right_inverse : surjective f \u2194 has_right_inverse f :=\n\u27e8surjective.has_right_inverse, has_right_inverse.surjective\u27e9\n\nlemma bijective_iff_has_inverse : bijective f \u2194 \u2203 g, left_inverse g f \u2227 right_inverse g f :=\n\u27e8\u03bb hf, \u27e8_, left_inverse_surj_inv hf, right_inverse_surj_inv hf.2\u27e9,\n \u03bb \u27e8g, gl, gr\u27e9, \u27e8gl.injective,  gr.surjective\u27e9\u27e9\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 \u03b1] [subsingleton \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  surjective f :=\n\u03bb y, let \u27e8a\u27e9 := na in \u27e8a, subsingleton.elim _ _\u27e9\n\n/-- Composition by an surjective function on the left is itself surjective. -/\nlemma surjective.comp_left {g : \u03b2 \u2192 \u03b3} (hg : surjective g) :\n  surjective ((\u2218) g : (\u03b1 \u2192 \u03b2) \u2192 (\u03b1 \u2192 \u03b3)) :=\n\u03bb f, \u27e8surj_inv hg \u2218 f, funext $ \u03bb x, right_inverse_surj_inv _ _\u27e9\n\n/-- Composition by an bijective function on the left is itself bijective. -/\nlemma bijective.comp_left {g : \u03b2 \u2192 \u03b3} (hg : bijective g) :\n  bijective ((\u2218) g : (\u03b1 \u2192 \u03b2) \u2192 (\u03b1 \u2192 \u03b3)) :=\n\u27e8hg.injective.comp_left, hg.surjective.comp_left\u27e9\n\nend surj_inv\n\nsection update\nvariables {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {\u03b1' : Sort w} [decidable_eq \u03b1] [decidable_eq \u03b1']\n\n/-- Replacing the value of a function at a given point by a given value. -/\ndef update (f : \u03a0a, \u03b2 a) (a' : \u03b1) (v : \u03b2 a') (a : \u03b1) : \u03b2 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 {\u03b2 : Sort*} (f : \u03b1 \u2192 \u03b2) (a' : \u03b1) (b : \u03b2) (a : \u03b1) :\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 : \u03b1) (v : \u03b2 a) (f : \u03a0a, \u03b2 a) : update f a v a = v :=\ndif_pos rfl\n\nlemma surjective_eval {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} [h : \u03a0 a, nonempty (\u03b2 a)] (a : \u03b1) :\n  surjective (eval a : (\u03a0 a, \u03b2 a) \u2192 \u03b2 a) :=\n\u03bb b, \u27e8@update _ _ (classical.dec_eq \u03b1) (\u03bb a, (h a).some) a b,\n  @update_same _ _ (classical.dec_eq \u03b1) _ _ _\u27e9\n\nlemma update_injective (f : \u03a0a, \u03b2 a) (a' : \u03b1) : injective (update f a') :=\n\u03bb v v' h, have _ := congr_fun h a', by rwa [update_same, update_same] at this\n\n@[simp] lemma update_noteq {a a' : \u03b1} (h : a \u2260 a') (v : \u03b2 a') (f : \u03a0a, \u03b2 a) :\n  update f a' v a = f a :=\ndif_neg h\n\nlemma forall_update_iff (f : \u03a0 a, \u03b2 a) {a : \u03b1} {b : \u03b2 a} (p : \u03a0 a, \u03b2 a \u2192 Prop) :\n  (\u2200 x, p x (update f a b x)) \u2194 p a b \u2227 \u2200 x \u2260 a, p x (f x) :=\nby { rw [\u2190 and_forall_ne a, update_same], simp { contextual := tt } }\n\nlemma exists_update_iff (f : \u03a0 a, \u03b2 a) {a : \u03b1} {b : \u03b2 a} (p : \u03a0 a, \u03b2 a \u2192 Prop) :\n  (\u2203 x, p x (update f a b x)) \u2194 p a b \u2228 \u2203 x \u2260 a, p x (f x) :=\nby { rw [\u2190 not_forall_not, forall_update_iff f (\u03bb a b, \u00acp a b)], simp [not_and_distrib] }\n\nlemma update_eq_iff {a : \u03b1} {b : \u03b2 a} {f g : \u03a0 a, \u03b2 a} :\n  update f a b = g \u2194 b = g a \u2227 \u2200 x \u2260 a, f x = g x :=\nfunext_iff.trans $ forall_update_iff _ (\u03bb x y, y = g x)\n\nlemma eq_update_iff {a : \u03b1} {b : \u03b2 a} {f g : \u03a0 a, \u03b2 a} :\n  g = update f a b \u2194 g a = b \u2227 \u2200 x \u2260 a, g x = f x :=\nfunext_iff.trans $ forall_update_iff _ (\u03bb x y, g x = y)\n\n@[simp] lemma update_eq_self (a : \u03b1) (f : \u03a0a, \u03b2 a) : update f a (f a) = f :=\nupdate_eq_iff.2 \u27e8rfl, \u03bb _ _, rfl\u27e9\n\nlemma update_comp_eq_of_forall_ne' {\u03b1'} (g : \u03a0 a, \u03b2 a) {f : \u03b1' \u2192 \u03b1} {i : \u03b1} (a : \u03b2 i)\n  (h : \u2200 x, f x \u2260 i) :\n  (\u03bb j, (update g i a) (f j)) = (\u03bb j, g (f j)) :=\nfunext $ \u03bb x, update_noteq (h _) _ _\n\n/-- Non-dependent version of `function.update_comp_eq_of_forall_ne'` -/\nlemma update_comp_eq_of_forall_ne {\u03b1 \u03b2 : Sort*} (g : \u03b1' \u2192 \u03b2) {f : \u03b1 \u2192 \u03b1'} {i : \u03b1'} (a : \u03b2)\n  (h : \u2200 x, f x \u2260 i) :\n  (update g i a) \u2218 f = g \u2218 f :=\nupdate_comp_eq_of_forall_ne' g a h\n\nlemma update_comp_eq_of_injective' (g : \u03a0 a, \u03b2 a) {f : \u03b1' \u2192 \u03b1} (hf : function.injective f)\n  (i : \u03b1') (a : \u03b2 (f i)) :\n  (\u03bb j, update g (f i) a (f j)) = update (\u03bb i, g (f i)) i a :=\neq_update_iff.2 \u27e8update_same _ _ _, \u03bb j hj, update_noteq (hf.ne hj) _ _\u27e9\n\n/-- Non-dependent version of `function.update_comp_eq_of_injective'` -/\nlemma update_comp_eq_of_injective {\u03b2 : Sort*} (g : \u03b1' \u2192 \u03b2) {f : \u03b1 \u2192 \u03b1'}\n  (hf : function.injective f) (i : \u03b1) (a : \u03b2) :\n  (function.update g (f i) a) \u2218 f = function.update (g \u2218 f) i a :=\nupdate_comp_eq_of_injective' g hf i a\n\nlemma apply_update {\u03b9 : Sort*} [decidable_eq \u03b9] {\u03b1 \u03b2 : \u03b9 \u2192 Sort*}\n  (f : \u03a0 i, \u03b1 i \u2192 \u03b2 i) (g : \u03a0 i, \u03b1 i) (i : \u03b9) (v : \u03b1 i) (j : \u03b9) :\n  f j (update g i v j) = update (\u03bb 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\u2082 {\u03b9 : Sort*} [decidable_eq \u03b9] {\u03b1 \u03b2 \u03b3 : \u03b9 \u2192 Sort*}\n  (f : \u03a0 i, \u03b1 i \u2192 \u03b2 i \u2192 \u03b3 i) (g : \u03a0 i, \u03b1 i) (h : \u03a0 i, \u03b2 i) (i : \u03b9) (v : \u03b1 i) (w : \u03b2 i) (j : \u03b9) :\n  f j (update g i v j) (update h i w j) = update (\u03bb 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 {\u03b1' : Sort*} {\u03b2 : Sort*} (f : \u03b1' \u2192 \u03b2) (g : \u03b1 \u2192 \u03b1') (i : \u03b1) (v : \u03b1') :\n  f \u2218 (update g i v) = update (f \u2218 g) i (f v) :=\nfunext $ apply_update _ _ _ _\n\ntheorem update_comm {\u03b1} [decidable_eq \u03b1] {\u03b2 : \u03b1 \u2192 Sort*}\n  {a b : \u03b1} (h : a \u2260 b) (v : \u03b2 a) (w : \u03b2 b) (f : \u03a0a, \u03b2 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\u2081 : c = b; by_cases h\u2082 : c = a; try {simp [h\u2081, h\u2082]},\n  cases h (h\u2082.symm.trans h\u2081),\nend\n\n@[simp] theorem update_idem {\u03b1} [decidable_eq \u03b1] {\u03b2 : \u03b1 \u2192 Sort*}\n  {a : \u03b1} (v w : \u03b2 a) (f : \u03a0a, \u03b2 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 {\u03b1 \u03b2 \u03b3 : Sort*} {f : \u03b1 \u2192 \u03b2}\n\n/-- `extend f g e'` extends a function `g : \u03b1 \u2192 \u03b3`\nalong a function `f : \u03b1 \u2192 \u03b2` to a function `\u03b2 \u2192 \u03b3`,\nby using the values of `g` on the range of `f`\nand the values of an auxiliary function `e' : \u03b2 \u2192 \u03b3` elsewhere.\n\nMostly useful when `f` is injective. -/\ndef extend (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) : \u03b2 \u2192 \u03b3 :=\n\u03bb b, if h : \u2203 a, f a = b then g (classical.some h) else e' b\n\nlemma extend_def (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (b : \u03b2) [decidable (\u2203 a, f a = b)] :\n  extend f g e' b = if h : \u2203 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 : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (a : \u03b1) :\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 : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (b : \u03b2) (hb : \u00ac\u2203 a, f a = b) :\n  extend f g e' b = e' b :=\nby simp [function.extend_def, hb]\n\nlemma apply_extend {\u03b4} (hf : injective f) (F : \u03b3 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (b : \u03b2) :\n  F (extend f g e' b) = extend f (F \u2218 g) (F \u2218 e') b :=\nbegin\n  by_cases hb : \u2203 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' : \u03b2 \u2192 \u03b3) :\n  injective (\u03bb g, extend f g e') :=\nbegin\n  intros g\u2081 g\u2082 hg,\n  refine funext (\u03bb 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 : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) :\n  extend f g e' \u2218 f = g :=\nfunext $ \u03bb a, extend_apply hf g e' a\n\nlemma injective.surjective_comp_right' (hf : injective f) (g\u2080 : \u03b2 \u2192 \u03b3) :\n  surjective (\u03bb g : \u03b2 \u2192 \u03b3, g \u2218 f) :=\n\u03bb g, \u27e8extend f g g\u2080, extend_comp hf _ _\u27e9\n\nlemma injective.surjective_comp_right [nonempty \u03b3] (hf : injective f) :\n  surjective (\u03bb g : \u03b2 \u2192 \u03b3, g \u2218 f) :=\nhf.surjective_comp_right' (\u03bb _, classical.choice \u2039_\u203a)\n\nlemma bijective.comp_right (hf : bijective f) :\n  bijective (\u03bb g : \u03b2 \u2192 \u03b3, g \u2218 f) :=\n\u27e8hf.surjective.injective_comp_right,\n  \u03bb g, \u27e8g \u2218 surj_inv hf.surjective,\n    by simp only [comp.assoc g _ f, (left_inverse_surj_inv hf).comp_eq_id, comp.right_id]\u27e9\u27e9\n\nend extend\n\nlemma uncurry_def {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : uncurry f = (\u03bbp, f p.1 p.2) :=\nrfl\n\n@[simp] lemma uncurry_apply_pair {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (x : \u03b1) (y : \u03b2) :\n  uncurry f (x, y) = f x y :=\nrfl\n\n@[simp] lemma curry_apply {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) (x : \u03b1) (y : \u03b2) :\n  curry f x y = f (x, y) :=\nrfl\n\nsection bicomp\nvariables {\u03b1 \u03b2 \u03b3 \u03b4 \u03b5 : 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 : \u03b3 \u2192 \u03b4 \u2192 \u03b5) (g : \u03b1 \u2192 \u03b3) (h : \u03b2 \u2192 \u03b4) (a b) :=\nf (g a) (h b)\n\n/-- Compose an unary function `f` with a binary function `g`. -/\ndef bicompr (f : \u03b3 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a b) :=\nf (g a b)\n\n-- Suggested local notation:\nlocal notation f `\u2218\u2082` g := bicompr f g\n\nlemma uncurry_bicompr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (g : \u03b3 \u2192 \u03b4) :\n  uncurry (g \u2218\u2082 f) = (g \u2218 uncurry f) := rfl\n\n\n\nend bicomp\n\nsection uncurry\n\nvariables {\u03b1 \u03b2 \u03b3 \u03b4 : Type*}\n\n/-- Records a way to turn an element of `\u03b1` into a function from `\u03b2` to `\u03b3`. The most generic use\nis to recursively uncurry. For instance `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4` will be turned into\n`\u21bff : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3 \u2192 \u03b4`. One can also add instances for bundled maps. -/\nclass has_uncurry (\u03b1 : Type*) (\u03b2 : out_param Type*) (\u03b3 : out_param Type*) := (uncurry : \u03b1 \u2192 (\u03b2 \u2192 \u03b3))\n\n/-- Uncurrying operator. The most generic use is to recursively uncurry. For instance\n`f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4` will be turned into `\u21bff : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3 \u2192 \u03b4`. One can also add instances\nfor bundled maps.-/\nadd_decl_doc has_uncurry.uncurry\n\nnotation `\u21bf`:max x:max := has_uncurry.uncurry x\n\ninstance has_uncurry_base : has_uncurry (\u03b1 \u2192 \u03b2) \u03b1 \u03b2 := \u27e8id\u27e9\n\ninstance has_uncurry_induction [has_uncurry \u03b2 \u03b3 \u03b4] : has_uncurry (\u03b1 \u2192 \u03b2) (\u03b1 \u00d7 \u03b3) \u03b4 :=\n\u27e8\u03bb f p, \u21bf(f p.1) p.2\u27e9\n\nend uncurry\n\n/-- A function is involutive, if `f \u2218 f = id`. -/\ndef involutive {\u03b1} (f : \u03b1 \u2192 \u03b1) : Prop := \u2200 x, f (f x) = x\n\nlemma involutive_iff_iter_2_eq_id {\u03b1} {f : \u03b1 \u2192 \u03b1} : involutive f \u2194 (f^[2] = id) :=\nfunext_iff.symm\n\nnamespace involutive\nvariables {\u03b1 : Sort u} {f : \u03b1 \u2192 \u03b1} (h : involutive f)\ninclude h\n\n@[simp]\nlemma comp_self : f \u2218 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 := \u03bb x, \u27e8f x, h x\u27e9\nprotected lemma bijective : bijective f := \u27e8h.injective, h.surjective\u27e9\n\n/-- Involuting an `ite` of an involuted value `x : \u03b1` negates the `Prop` condition in the `ite`. -/\nprotected lemma ite_not (P : Prop) [decidable P] (x : \u03b1) :\n  f (ite P x (f x)) = ite (\u00ac 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 : \u03b1} : f x = y \u2194 x = f y :=\nh.injective.eq_iff' (h y)\n\nend involutive\n\n/-- The property of a binary function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` being injective.\nMathematically this should be thought of as the corresponding function `\u03b1 \u00d7 \u03b2 \u2192 \u03b3` being injective.\n-/\ndef injective2 {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : Prop :=\n\u2200 \u2983a\u2081 a\u2082 b\u2081 b\u2082\u2984, f a\u2081 b\u2081 = f a\u2082 b\u2082 \u2192 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082\n\nnamespace injective2\nvariables {\u03b1 \u03b2 \u03b3 : Sort*} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n\n/-- A binary injective function is injective when only the left argument varies. -/\nprotected lemma left (hf : injective2 f) (b : \u03b2) : function.injective (\u03bb a, f a b) :=\n\u03bb a\u2081 a\u2082 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 : \u03b1) : function.injective (f a) :=\n\u03bb a\u2081 a\u2082 h, (hf h).right\n\nprotected lemma uncurry {\u03b1 \u03b2 \u03b3 : Type*} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hf : injective2 f) :\n  function.injective (uncurry f) :=\n\u03bb \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 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 \u03b2] : function.injective f :=\n\u03bb a\u2081 a\u2082 h, let \u27e8b\u27e9 := \u2039nonempty \u03b2\u203a 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 \u03b1] : function.injective (\u03bb b a, f a b) :=\n\u03bb b\u2081 b\u2082 h, let \u27e8a\u27e9 := \u2039nonempty \u03b1\u203a in hf.right a $ (congr_fun h a : _)\n\nlemma eq_iff (hf : injective2 f) {a\u2081 a\u2082 b\u2081 b\u2082} : f a\u2081 b\u2081 = f a\u2082 b\u2082 \u2194 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082 :=\n\u27e8\u03bb h, hf h, and.rec $ congr_arg2 f\u27e9\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 `\u03b1` is a proposition, in which case `f` is necessarily a\nconstant function, so that `sometimes f = f a` for all `a`. -/\nnoncomputable def sometimes {\u03b1 \u03b2} [nonempty \u03b2] (f : \u03b1 \u2192 \u03b2) : \u03b2 :=\nif h : nonempty \u03b1 then f (classical.choice h) else classical.choice \u2039_\u203a\n\ntheorem sometimes_eq {p : Prop} {\u03b1} [nonempty \u03b1] (f : p \u2192 \u03b1) (a : p) : sometimes f = f a :=\ndif_pos \u27e8a\u27e9\n\ntheorem sometimes_spec {p : Prop} {\u03b1} [nonempty \u03b1]\n  (P : \u03b1 \u2192 Prop) (f : p \u2192 \u03b1) (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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Sort v} (s : set \u03b1) (f g : \u03a0i, \u03b2 i)\n  [\u2200j, decidable (j \u2208 s)] :\n  \u03a0i, \u03b2 i :=\n\u03bbi, if i \u2208 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 {\u03b1 : Sort*} {C : \u03b1 \u2192 Sort*} :\n  \u2200 {a a' : \u03b1} (h : a = a'), function.bijective (@eq.rec_on _ _ C _ h)\n| _ _ rfl := \u27e8\u03bb x y, id, \u03bb x, \u27e8x, rfl\u27e9\u27e9\n\nlemma eq_mp_bijective {\u03b1 \u03b2 : Sort*} (h : \u03b1 = \u03b2) : function.bijective (eq.mp h) :=\neq_rec_on_bijective h\n\nlemma eq_mpr_bijective {\u03b1 \u03b2 : Sort*} (h : \u03b1 = \u03b2) : function.bijective (eq.mpr h) :=\neq_rec_on_bijective h.symm\n\nlemma cast_bijective {\u03b1 \u03b2 : Sort*} (h : \u03b1 = \u03b2) : 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 {\u03b1 : Sort*} {a a' : \u03b1} (h : a = a') {C : \u03b1 \u2192 Type*} (x y : C a) :\n  (eq.rec x h : C a') = eq.rec y h \u2194 x = y :=\n(eq_rec_on_bijective h).injective.eq_iff\n\n@[simp]\nlemma cast_inj {\u03b1 \u03b2 : Type*} (h : \u03b1 = \u03b2) {x y : \u03b1} : cast h x = cast h y \u2194 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 {\u03b1 \u03b2 : Type*} (A : set (\u03b1 \u2192 \u03b2)) : Prop :=\n\u2200 \u2983x y : \u03b1\u2984, x \u2260 y \u2192 \u2203 f \u2208 A, (f x : \u03b2) \u2260 f y\n\nlemma is_symm_op.flip_eq {\u03b1 \u03b2} (op) [is_symm_op \u03b1 \u03b2 op] : flip op = op :=\nfunext $ \u03bb a, funext $ \u03bb b, (is_symm_op.symm_op a b).symm\n\nlemma inv_image.equivalence {\u03b1 : Sort u} {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2)\n  (h : equivalence r) : equivalence (inv_image r f) :=\n\u27e8\u03bb _, h.1 _, \u03bb _ _ x, h.2.1 x, inv_image.trans r f h.2.2\u27e9\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 (\u03b1 \u03b2 : Type) where\n  x : Nat\n  y : \u03b1\n  z : List (\u03b1 \u00d7 \u03b2)\n  deriving Lenses\n\nvariable {\u03b1 \u03b2 : Type}\n\n#check (Foo.Lens.x : Lens (Foo \u03b1 \u03b2) Nat)\n#check (Foo.Lens.y : Lens (Foo \u03b1 \u03b2) \u03b1)\n#check (Foo.Lens.z : Lens (Foo \u03b1 \u03b2) (List (\u03b1 \u00d7 \u03b2)))\n\nstructure Bar (\u03b1 \u03b2 : Type) where\n  foo : Foo \u03b1 \u03b2\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 \u03b1 \u03b2) (Foo \u03b1 \u03b2))\n#check (Bar.Lens.foo /. Foo.Lens.x : Lens (Bar \u03b1 \u03b2) Nat)\n\ndef test := bar \u27e8 { x := 1, y := 0, z := [] } \u27e9\n\ntheorem check' : test = \u27e8 { x := 4, y := 0, z := [] } \u27e9 :=\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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u224c chain_complex C \u2115`\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 \u2115` 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\u2081 : simplicial_object C \u2964 karoubi (chain_complex C \u2115)`\n(defined in `functor_n.lean`) and the inverse of the equivalence\n`chain_complex C \u2115 \u224c karoubi (chain_complex C \u2115)`. The functor\n`idempotents.dold_kan.\u0393` of the equivalence is by definition the functor\n`\u0393\u2080` 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 \u2964 karoubi (chain_complex C \u2115)` and the inverse\nof the equivalence `chain_complex C \u2115 \u224c karoubi (chain_complex C \u2115)`. -/\n@[simps, nolint unused_arguments]\ndef N : simplicial_object C \u2964 chain_complex C \u2115 :=\nN\u2081 \u22d9 (to_karoubi_equivalence _).inverse\n\n/-- The functor `\u0393` for the equivalence is `\u0393'`. -/\n@[simps, nolint unused_arguments]\ndef \u0393 : chain_complex C \u2115 \u2964 simplicial_object C := \u0393\u2080\n\nlemma hN\u2081 : (to_karoubi_equivalence (simplicial_object C)).functor \u22d9\n  preadditive.dold_kan.equivalence.functor = N\u2081 :=\nfunctor.congr_obj (functor_extension\u2081_comp_whiskering_left_to_karoubi _ _) N\u2081\n\nlemma h\u0393\u2080 : (to_karoubi_equivalence (chain_complex C \u2115)).functor \u22d9\n  preadditive.dold_kan.equivalence.inverse = \u0393 \u22d9 (to_karoubi_equivalence _).functor :=\nfunctor.congr_obj (functor_extension\u2082_comp_whiskering_left_to_karoubi _ _) \u0393\u2080\n\n/-- The Dold-Kan equivalence for pseudoabelian categories given\nby the functors `N` and `\u0393`. It is obtained by applying the results in\n`compatibility.lean` to the equivalence `preadditive.dold_kan.equivalence`. -/\ndef equivalence : simplicial_object C \u224c chain_complex C \u2115 :=\ncompatibility.equivalence (eq_to_iso hN\u2081) (eq_to_iso h\u0393\u2080)\n\nlemma equivalence_functor : (equivalence : simplicial_object C \u224c _).functor = N := by refl\nlemma equivalence_inverse : (equivalence : simplicial_object C \u224c _).inverse = \u0393 := by refl\n\n/-- The natural isomorphism `N\u0393' satisfies the compatibility that is needed\nfor the construction of our counit isomorphism `\u03b7` -/\nlemma h\u03b7 : compatibility.\u03c4\u2080 =\n  compatibility.\u03c4\u2081 (eq_to_iso hN\u2081) (eq_to_iso h\u0393\u2080)\n  (N\u2081\u0393\u2080 : \u0393 \u22d9 N\u2081 \u2245 (to_karoubi_equivalence (chain_complex C \u2115)).functor) :=\nbegin\n  ext K : 3,\n  simpa only [compatibility.\u03c4\u2080_hom_app, compatibility.\u03c4\u2081_hom_app, eq_to_iso.hom,\n    preadditive.dold_kan.equivalence_counit_iso, N\u2082\u0393\u2082_to_karoubi_iso_hom, eq_to_hom_map,\n    eq_to_hom_trans_assoc, eq_to_hom_app] using N\u2082\u0393\u2082_compatible_with_N\u2081\u0393\u2080 K,\nend\n\n/-- The counit isomorphism induced by `N\u2081\u0393\u2080` -/\n@[simps]\ndef \u03b7 : \u0393 \u22d9 N \u2245 \ud835\udfed (chain_complex C \u2115) := compatibility.equivalence_counit_iso\n  (N\u2081\u0393\u2080 : (\u0393 : chain_complex C \u2115 \u2964 _ ) \u22d9 N\u2081 \u2245 (to_karoubi_equivalence _).functor)\n\nlemma equivalence_counit_iso :\n  dold_kan.equivalence.counit_iso = (\u03b7 : \u0393 \u22d9 N \u2245 \ud835\udfed (chain_complex C \u2115)) :=\ncompatibility.equivalence_counit_iso_eq h\u03b7\n\nlocal attribute [-simp, reassoc] nat_trans.comp_app\n\nlemma h\u03b5 : compatibility.\u03c5 (eq_to_iso hN\u2081) =\n  (\u0393\u2082N\u2081 : (to_karoubi_equivalence _).functor \u2245 (N\u2081 : simplicial_object C \u2964 _) \u22d9\n  preadditive.dold_kan.equivalence.inverse) :=\nbegin\n  ext X : 4,\n  erw [nat_trans.comp_app, compatibility_\u0393\u2082N\u2081_\u0393\u2082N\u2082_nat_trans],\n  simp only [compatibility.\u03c5_hom_app, compatibility_\u0393\u2082N\u2081_\u0393\u2082N\u2082,\n    preadditive.dold_kan.equivalence_unit_iso, \u0393\u2082N\u2082, iso.symm_hom, as_iso_inv, assoc],\n  erw [\u2190 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 `\u0393\u2082N\u2081`. -/\n@[simps]\ndef \u03b5 : \ud835\udfed (simplicial_object C) \u2245 N \u22d9 \u0393 :=\ncompatibility.equivalence_unit_iso (eq_to_iso h\u0393\u2080) \u0393\u2082N\u2081\n\nlemma equivalence_unit_iso : dold_kan.equivalence.unit_iso =\n  (\u03b5 : \ud835\udfed (simplicial_object C) \u2245 N \u22d9 \u0393) :=\ncompatibility.equivalence_unit_iso_eq h\u03b5\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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u2964 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 \u2964 C)) : J \u2964 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 \u2964 C) :=\nbegin\n  refine \u27e8_\u27e9,\n  intros F p hp,\n  have hC := (is_idempotent_complete_iff_has_equalizer_of_id_and_idempotent C).mp infer_instance,\n  haveI : \u2200 (j : J), has_equalizer (\ud835\udfd9 _) (p.app j) := \u03bb j, hC _ _ (congr_app hp j),\n  /- We construct the direct factor `Y` associated to `p : F \u27f6 F` by computing\n    the equalizer of the identity and `p.app j` on each object `(j : J)`.  -/\n  let Y : J \u2964 C :=\n  { obj := \u03bb j, limits.equalizer (\ud835\udfd9 _) (p.app j),\n    map := \u03bb j j' \u03c6, equalizer.lift (limits.equalizer.\u03b9 (\ud835\udfd9 _) (p.app j) \u226b F.map \u03c6)\n      (by rw [comp_id, assoc, p.naturality \u03c6, \u2190 assoc, \u2190 limits.equalizer.condition, comp_id]),\n    map_id' := \u03bb j, by { ext, simp only [comp_id, functor.map_id, equalizer.lift_\u03b9, id_comp], },\n    map_comp' := \u03bb j j' j'' \u03c6 \u03c6', begin\n      ext,\n      simp only [assoc, functor.map_comp, equalizer.lift_\u03b9, equalizer.lift_\u03b9_assoc],\n    end },\n  let i : Y \u27f6 F :=\n  { app := \u03bb j, equalizer.\u03b9 _ _,\n    naturality' := \u03bb j j' \u03c6, by rw [equalizer.lift_\u03b9],  },\n  let e : F \u27f6 Y :=\n  { app := \u03bb j, equalizer.lift (p.app j)\n      (by { rw comp_id, exact (congr_app hp j).symm, }),\n    naturality' := \u03bb j j' \u03c6, begin\n      ext,\n      simp only [assoc, equalizer.lift_\u03b9, nat_trans.naturality, equalizer.lift_\u03b9_assoc],\n    end },\n  use [Y, i, e],\n  split; ext j,\n  { simp only [nat_trans.comp_app, assoc, equalizer.lift_\u03b9, nat_trans.id_app, id_comp,\n      \u2190 equalizer.condition, comp_id], },\n  { simp only [nat_trans.comp_app, equalizer.lift_\u03b9], },\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 \u2964 C` to the functor `J \u2964 karoubi C` which sends `(j : J)` to\nthe corresponding direct factor of `F.obj j`. -/\n@[simps]\ndef obj (P : karoubi (J \u2964 C)) : J \u2964 karoubi C :=\n{ obj := \u03bb j, \u27e8P.X.obj j, P.p.app j, congr_app P.idem j\u27e9,\n  map := \u03bb j j' \u03c6,\n  { f := P.p.app j \u226b P.X.map \u03c6,\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' := \u03bb j, by { ext, simp only [functor.map_id, comp_id, id_eq], },\n  map_comp' := \u03bb j j' j'' \u03c6 \u03c6', 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 \u2964 C) \u2964 (J \u2964 karoubi C)`. -/\n@[simps]\ndef map {P Q : karoubi (J \u2964 C)} (f : P \u27f6 Q) : obj P \u27f6 obj Q :=\n{ app := \u03bb j, \u27e8f.f.app j, congr_app f.comm j\u27e9,\n  naturality' := \u03bb j j' \u03c6, 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' \u22a2,\n    slice_rhs 1 2 { erw h, },\n    rw \u2190 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 \u2964 C) \u2964 (J \u2964 karoubi C)`. -/\n@[simps]\ndef karoubi_functor_category_embedding :\n  karoubi (J \u2964 C) \u2964 (J \u2964 karoubi C) :=\n{ obj := karoubi_functor_category_embedding.obj,\n  map := \u03bb P Q, karoubi_functor_category_embedding.map,\n  map_id' := \u03bb P, rfl,\n  map_comp' := \u03bb P Q R f g, rfl, }\n\ninstance : full (karoubi_functor_category_embedding J C) :=\n{ preimage := \u03bb P Q f,\n  { f :=\n    { app := \u03bb j, (f.app j).f,\n      naturality' := \u03bb j j' \u03c6, begin\n        slice_rhs 1 1 { rw \u2190 karoubi.comp_p, },\n        have h := hom_ext.mp (f.naturality \u03c6),\n        simp only [comp] at h,\n        dsimp [karoubi_functor_category_embedding] at h \u22a2,\n        erw [assoc, \u2190 h, \u2190 P.p.naturality \u03c6, assoc, p_comp (f.app j')],\n      end },\n    comm := by { ext j, exact (f.app j).comm, } },\n  witness' := \u03bb P Q f, by { ext j, refl, }, }\n\ninstance : faithful (karoubi_functor_category_embedding J C) :=\n{ map_injective' := \u03bb P Q f f' h, by { ext j, exact hom_ext.mp (congr_app h j), }, }\n\n/-- The composition of `(J \u2964 C) \u2964 karoubi (J \u2964 C)` and `karoubi (J \u2964 C) \u2964 (J \u2964 karoubi C)`\nequals the functor `(J \u2964 C) \u2964 (J \u2964 karoubi C)` given by the composition with\n`to_karoubi C : C \u2964 karoubi C`. -/\nlemma to_karoubi_comp_karoubi_functor_category_embedding :\n  (to_karoubi _) \u22d9 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 (\u03bb j, rfl) _,\n    { intros j j' \u03c6,\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 \u2964 C)) (X : J) :\n  P.p.app X \u226b 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 \u2964 C)} (f : P \u27f6 Q) (X : J) :\n  P.p.app X \u226b 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 \u2964 C)} (f : P \u27f6 Q) (X : J) :\n  f.f.app X \u226b 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 \u2964 C)} (f : P \u27f6 Q) (X : J) :\n  P.p.app X \u226b f.f.app X = f.f.app X \u226b 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 \u2192 Nat\n  testVal: Nat\n  trueTarget: MonkeyId\n  falseTarget: MonkeyId\n  observedItems: Nat := 0\n\ninstance : Inhabited Monkey where\n  default := Monkey.mk 0 \u2205 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  _ \u2190 pstring \"Operation: new = \"\n  return \u2190 operation\n  where\n    opFunction: Parsec $ Nat \u2192 Nat \u2192 Nat := do\n      let op \u2190 ws *> (pchar '*' <|> pchar '+') <* ws\n      return match op with\n      | '*' => fun (x\u2081 x\u2082: Nat) => x\u2081 * x\u2082\n      | '+' => fun (x\u2081 x\u2082: Nat) => x\u2081 + x\u2082\n      | u => fun (_ _: Nat) => panic! s!\"Unknown op: {u}\"\n    operand : Parsec $ Nat \u2192 Nat :=\n      return match \u2190 pstring \"old\" <|> many1Chars digit with\n      | \"old\" => id\n      | digits => \n        let num := String.toNat! digits\n        fun _ => num\n    operation : Parsec $ Nat \u2192 Nat := do\n      let op\u2081 \u2190 operand\n      let f \u2190 opFunction\n      let op\u2082 \u2190 operand\n      return fun (worry: Nat) => \n        f (op\u2081 worry) (op\u2082 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 \u2190 ws *> pstring \"Monkey\" *> ws *> parseNat <* pchar ':' <* ws\n  let items: Array Item \u2190 pstring \"Starting items:\" *> ws *> parseItemsList <* ws\n  let itemQueue : Items := items -- (\u2205 : Items).enqueueAll items.toList\n  let op \u2190 ws *> parseWorryOperation <* ws\n  let test \u2190 testVal\n  let trueTarget \u2190 pstring \"If true: throw to monkey \" *> parseNat <* ws\n  let falseTarget \u2190 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 \u2190 many1 parseMonkey\n  return allMonkeys.foldl (init:=\u2205) (\u03bb map m => \n    map.insert m.id m\n  )\n\n#eval parseMonkeys sample.iter\n\ndef monkey\u2080 := Monkey.mk 0 #[79, 98] (\u00b7*19) 23 2 3 0\ndef monkey\u2081 := Monkey.mk 1 #[54, 65, 75, 74] (\u00b7+6) 19 2 0 0\ndef monkey\u2082 := Monkey.mk 2 #[79, 60, 97] (\u03bb x => x * x) 13 1 3 0\ndef monkey\u2083 := Monkey.mk 3 #[74] (\u00b7+3) 17 0 1 0\n\ndef monkeyExamples : MonkeyMap := \n  [\n    (0, monkey\u2080),\n    (1, monkey\u2081),\n    (2, monkey\u2082),\n    (3, monkey\u2083)\n  ].toRBMap compare\n\ndef processMonkeyItem (monkey: Monkey) (worryReducer: Nat \u2192 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\u2081.testVal * m\u2082.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) (\u03bb 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 (\u03bb 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 \u2192 Nat := (\u00b7/3)) : MonkeyMap :=\n  monkey.items.foldl (init:=removedItems) (processMonkeyItem monkey worryReducer)\n  where \n    removedItems := map.modify monkey.id (\u03bb m => { m with items := \u2205, observedItems := monkey.observedItems + monkey.items.size })\n\n#eval monkeyExamples\n  |> processMonkey monkey\u2080 \n#eval monkeyExamples\n  |> processMonkey monkey\u2080  \n  |> processMonkey monkey\u2081\n#eval monkeyExamples \n  |> processMonkey monkey\u2080\n  |> processMonkey monkey\u2081\n  |> processMonkey monkey\u2082\n\n#eval monkeyExamples\n  |> (\u03bb x => processMonkey (x.find? 0).get! x)\n  |> (\u03bb x => processMonkey (x.find? 1).get! x)\n  |> (\u03bb x => processMonkey (x.find? 2).get! x)\n  |> (\u03bb x => processMonkey (x.find? 3).get! x)\n\n#eval monkeyExamples\n  |> processMonkey monkey\u2080  \n  |> processMonkey monkey\u2081\n  |> processMonkey monkey\u2082\n  |> processMonkey monkey\u2083\n  |>.find? 1\n\n#eval monkeyExamples\n  |> processMonkey monkey\u2080  \n  |> processMonkey monkey\u2081\n  |> processMonkey monkey\u2082\n  |>.find? 3\n\ndef monkeysRound (map: MonkeyMap) (worryReducer: Nat \u2192 Nat := (\u00b7/3)) : MonkeyMap :=\n  map.foldl (init:=map) (\u03bb 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 \u2192 Nat) : StateM (MonkeyMap \u00d7 Array (Nat \u00d7  MonkeyMap)) Unit := do\n  for _round in [1:rounds+1] do\n    let (current, history) \u2190 get\n    let round := monkeysRound current worryReducer\n    set $ (round, history.push (_round, round))\n\nabbrev MonkeyCountMap := Map MonkeyId Nat\n\ndef roundHistory [ToInput \u03ba] (input: \u03ba) (rounds: Nat) (worryReducer: Nat \u2192 Nat := (\u00b7/3)) : Array $ Nat \u00d7 MonkeyMap :=\n  let initialMonkeys := parseAll (toInput input)\n  let result := StateT.run (runRounds rounds worryReducer) (initialMonkeys, #[(0, initialMonkeys)]) \n  let (_, history): MonkeyMap \u00d7 Array (Nat \u00d7 MonkeyMap) := result.snd\n  history\n\n#eval roundHistory sample 20\n\ndef run [ToInput \u03ba] (input: \u03ba) (rounds: Nat) (worryReducer: Nat \u2192 Nat := (\u00b7/3)) : Array Nat :=\n  roundHistory input rounds worryReducer\n  |>.map (\u03bb ((_, round): Nat \u00d7 MonkeyMap) => \n    round.foldl (init:=\u2205) (\u03bb (state: MonkeyCountMap) (k: MonkeyId) (m: Monkey) => \n      state.insert k m.observedItems\n    )\n  )\n  |>.lastD \u2205\n  |>.valuesArray\n  |>.qsort (Ordering.lt == compare \u00b7 \u00b7)\n\n#eval run sample 20\n/--\n-/\ndef part\u2081 (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\u2082 (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 := \u27e8 day, part\u2081, part\u2082 \u27e9 \n\n#eval testPart\u2081 solution sample (expect:=10605)\n-- #eval testPart\u2082 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\u00ebl Dillies, Kexing Ying. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 $$\u03ba(G) \u2264 \u03bb(G) \u2264 \u03b4(G)$$.\n-/\n\n/-!\n### Question 2\n\nLet $$G be a graph. Show that $$e(G) > {\u03c7(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 \u2212 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 \u2286 V$$ so that $$x \u2241 y$$ for all\n$$x, y \u2208 I$$. Let $$G = (V, E)$$ be a connected graph with $$\u2206(G) \u2264 3$$ and $$|V| \u2265 10$$. Show that\nthere exists an independent set $$I \u2286 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\u2212j > 0 for even j and cn\u2212j 6 0 for odd j. Also\nshow that if G has m edges and k triangles then cn\u22122 =\nm\n2\n\u0001\n\u2212 k.\n-/\n\n/-!\n### Question 7\n\nDetermine $$\u03c7(K_{n,n}$$). Determine $$\u03c7(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 $$\u03c7(G) \u2264 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 $$\u2206$$. Must we have $$\u03c7(G) = \u2206(G)$$?\n-/\n\n/-!\n### Question 11\n\nLet $$G = (V, E)$$ be a graph where $$V$$, $$E$$ are countably infinite. Show that $$\u03c7(G) \u2264 k$$ if\nand only if $$\u03c7(H) \u2264 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} \u2286 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 $$\u03c7(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 \u201cLet $$G$$ be a graph with $$|G| > 5$$. $$G$$ is\nouter-planar if and only if ...\u201d. 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\u25e6$$ be the\nplanar dual of $$G$$: the vertices of $$G\u25e6$$ are the faces of $$G$$ and edges in $$G\u25e6$$ join faces\nthat share a boundary edge (in $$G$$). Prove that $$\u03c7(G) \u2264 4$$ if and only if $$\u03c7(G\u25e6) \u2264 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 : \u03b1 \u2192 \u03b1` be measure preserving with respect to a measure `\u03bc`. We say `f` is ergodic with\nrespect to `\u03bc` (or `\u03bc` is ergodic with respect to `f`) if the only measurable sets `s` such that\n`f\u207b\u00b9' 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 {\u03b1 : Type*} {m : measurable_space \u03b1} (f : \u03b1 \u2192 \u03b1) {s : set \u03b1}\ninclude m\n\n/-- A map `f : \u03b1 \u2192 \u03b1` is said to be pre-ergodic with respect to a measure `\u03bc` if any measurable\nstrictly invariant set is either almost empty or full. -/\nstructure pre_ergodic (\u03bc : measure \u03b1 . volume_tac) : Prop :=\n(ae_empty_or_univ : \u2200 \u2983s\u2984, measurable_set s \u2192 f\u207b\u00b9' s = s \u2192 s =\u1d50[\u03bc] (\u2205 : set \u03b1) \u2228 s =\u1d50[\u03bc] univ)\n\n/-- A map `f : \u03b1 \u2192 \u03b1` is said to be ergodic with respect to a measure `\u03bc` if it is measure\npreserving and pre-ergodic. -/\n@[nolint has_nonempty_instance] structure ergodic (\u03bc : measure \u03b1 . volume_tac) extends\n  measure_preserving f \u03bc \u03bc, pre_ergodic f \u03bc : Prop\n\n/-- A map `f : \u03b1 \u2192 \u03b1` is said to be quasi ergodic with respect to a measure `\u03bc` if it is quasi\nmeasure preserving and pre-ergodic. -/\n@[nolint has_nonempty_instance] structure quasi_ergodic (\u03bc : measure \u03b1 . volume_tac) extends\n  quasi_measure_preserving f \u03bc \u03bc, pre_ergodic f \u03bc : Prop\n\nvariables {f} {\u03bc : measure \u03b1}\n\nnamespace pre_ergodic\n\nlemma measure_self_or_compl_eq_zero (hf : pre_ergodic f \u03bc)\n  (hs : measurable_set s) (hs' : f\u207b\u00b9' s = s) :\n  \u03bc s = 0 \u2228 \u03bc s\u1d9c = 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 \u03bc] (hf : pre_ergodic f \u03bc)\n  (hs : measurable_set s) (hs' : f\u207b\u00b9' s = s) :\n  \u03bc s = 0 \u2228 \u03bc s = 1 :=\nby simpa [hs] using hf.measure_self_or_compl_eq_zero hs hs'\n\nlemma of_iterate (n : \u2115) (hf : pre_ergodic (f^[n]) \u03bc) : pre_ergodic f \u03bc :=\n\u27e8\u03bb s hs hs', hf.ae_empty_or_univ hs $ is_fixed_pt.preimage_iterate hs' n\u27e9\n\nend pre_ergodic\n\nnamespace measure_theory.measure_preserving\n\nvariables {\u03b2 : Type*} {m' : measurable_space \u03b2} {\u03bc' : measure \u03b2} {s' : set \u03b2} {g : \u03b1 \u2192 \u03b2}\n\nlemma pre_ergodic_of_pre_ergodic_conjugate (hg : measure_preserving g \u03bc \u03bc')\n  (hf : pre_ergodic f \u03bc) {f' : \u03b2 \u2192 \u03b2} (h_comm : g \u2218 f = f' \u2218 g) :\n  pre_ergodic f' \u03bc' :=\n\u27e8begin\n  intros s hs\u2080 hs\u2081,\n  replace hs\u2081 : f\u207b\u00b9' (g\u207b\u00b9' s) = g\u207b\u00b9' s, { rw [\u2190 preimage_comp, h_comm, preimage_comp, hs\u2081], },\n  cases hf.ae_empty_or_univ (hg.measurable hs\u2080) hs\u2081 with hs\u2082 hs\u2082;\n  [left, right],\n  { simpa only [ae_eq_empty, hg.measure_preimage hs\u2080] using hs\u2082, },\n  { simpa only [ae_eq_univ, \u2190 preimage_compl, hg.measure_preimage hs\u2080.compl] using hs\u2082, },\nend\u27e9\n\nlemma pre_ergodic_conjugate_iff {e : \u03b1 \u2243\u1d50 \u03b2} (h : measure_preserving e \u03bc \u03bc') :\n  pre_ergodic (e \u2218 f \u2218 e.symm) \u03bc' \u2194 pre_ergodic f \u03bc :=\nbegin\n  refine \u27e8\u03bb hf, pre_ergodic_of_pre_ergodic_conjugate (h.symm e) hf _,\n          \u03bb hf, pre_ergodic_of_pre_ergodic_conjugate h hf _\u27e9,\n  { change (e.symm \u2218 e) \u2218 f \u2218 e.symm = f \u2218 e.symm,\n    rw [measurable_equiv.symm_comp_self, comp.left_id], },\n  { change e \u2218 f = e \u2218 f \u2218 e.symm \u2218 e,\n    rw [measurable_equiv.symm_comp_self, comp.right_id], },\nend\n\nlemma ergodic_conjugate_iff {e : \u03b1 \u2243\u1d50 \u03b2} (h : measure_preserving e \u03bc \u03bc') :\n  ergodic (e \u2218 f \u2218 e.symm) \u03bc' \u2194 ergodic f \u03bc :=\nbegin\n  have : measure_preserving (e \u2218 f \u2218 e.symm) \u03bc' \u03bc' \u2194 measure_preserving f \u03bc \u03bc :=\n    by rw [h.comp_left_iff, (measure_preserving.symm e h).comp_right_iff],\n  replace h : pre_ergodic (e \u2218 f \u2218 e.symm) \u03bc' \u2194 pre_ergodic f \u03bc := h.pre_ergodic_conjugate_iff,\n  exact \u27e8\u03bb hf, { .. this.mp hf.to_measure_preserving, .. h.mp hf.to_pre_ergodic, },\n         \u03bb hf, { .. this.mpr hf.to_measure_preserving, .. h.mpr hf.to_pre_ergodic, }\u27e9,\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 \u03bc) (hs : measurable_set s) (hs' : f\u207b\u00b9' s =\u1d50[\u03bc] s) :\n  s =\u1d50[\u03bc] (\u2205 : set \u03b1) \u2228 s =\u1d50[\u03bc] univ :=\nbegin\n  obtain \u27e8t, h\u2080, h\u2081, h\u2082\u27e9 := hf.to_quasi_measure_preserving.exists_preimage_eq_of_preimage_ae hs hs',\n  rcases hf.ae_empty_or_univ h\u2080 h\u2082 with h\u2083 | h\u2083;\n  [left, right];\n  exact ae_eq_trans h\u2081.symm h\u2083,\nend\n\nend quasi_ergodic\n\nnamespace ergodic\n\n/-- An ergodic map is quasi ergodic. -/\nlemma quasi_ergodic (hf : ergodic f \u03bc) : quasi_ergodic f \u03bc :=\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 \u03bc) (hs : measurable_set s) (hs' : f\u207b\u00b9' s \u2264\u1d50[\u03bc] s) (h_fin : \u03bc s \u2260 \u221e) :\n  s =\u1d50[\u03bc] (\u2205 : set \u03b1) \u2228 s =\u1d50[\u03bc] 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 \u03bc) (hs : measurable_set s) (hs' : s \u2264\u1d50[\u03bc] f\u207b\u00b9' s) (h_fin : \u03bc s \u2260 \u221e) :\n  s =\u1d50[\u03bc] (\u2205 : set \u03b1) \u2228 s =\u1d50[\u03bc] univ :=\nbegin\n  replace h_fin : \u03bc (f\u207b\u00b9' s) \u2260 \u221e, { 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 \u03bc) (hs : measurable_set s) (hs' : f '' s \u2264\u1d50[\u03bc] s) (h_fin : \u03bc s \u2260 \u221e) :\n  s =\u1d50[\u03bc] (\u2205 : set \u03b1) \u2228 s =\u1d50[\u03bc] univ :=\nbegin\n  replace hs' : s \u2264\u1d50[\u03bc] f \u207b\u00b9' 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 \u03bc]\n\nlemma ae_empty_or_univ_of_preimage_ae_le\n  (hf : ergodic f \u03bc) (hs : measurable_set s) (hs' : f\u207b\u00b9' s \u2264\u1d50[\u03bc] s) :\n  s =\u1d50[\u03bc] (\u2205 : set \u03b1) \u2228 s =\u1d50[\u03bc] univ :=\nae_empty_or_univ_of_preimage_ae_le' hf hs hs' $ measure_ne_top \u03bc s\n\nlemma ae_empty_or_univ_of_ae_le_preimage\n  (hf : ergodic f \u03bc) (hs : measurable_set s) (hs' : s \u2264\u1d50[\u03bc] f\u207b\u00b9' s) :\n  s =\u1d50[\u03bc] (\u2205 : set \u03b1) \u2228 s =\u1d50[\u03bc] univ :=\nae_empty_or_univ_of_ae_le_preimage' hf hs hs' $ measure_ne_top \u03bc s\n\nlemma ae_empty_or_univ_of_image_ae_le\n  (hf : ergodic f \u03bc) (hs : measurable_set s) (hs' : f '' s \u2264\u1d50[\u03bc] s) :\n  s =\u1d50[\u03bc] (\u2205 : set \u03b1) \u2228 s =\u1d50[\u03bc] univ :=\nae_empty_or_univ_of_image_ae_le' hf hs hs' $ measure_ne_top \u03bc 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) : \u2200 {as : List \u03b1}, map (g\u2218 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 {\u03b1 : Type u} : \u2200 (ass bss : List (List \u03b1)), (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 {\u03b1 : Type u} : \u2200 (asss : List (List (List \u03b1))), 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) : \u2200 {ass : List (List \u03b1)}, 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 {\u03b1 : Type*} {n : \u2115}\n\n\nlemma nil_append (as : dvector \u03b1 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 \u03b1 n) : fin n \u2192 \u03b1 :=\n\u03bb k, dvector.nth' as k\n @[simp] lemma cons_nth'_succ_eq_nth' {n} {x : \u03b1} {as : dvector \u03b1 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 : \u03b1} {as : dvector \u03b1 n} :\n  fin_val (dvector.cons x as) = fin.x_val x (fin_val as) :=\nfunext (\n  @fin.cases n\n  (\u03bb k, fin_val (dvector.cons x as) k = fin.x_val x (fin_val as) k)\n  rfl\n  (\u03bb k, begin unfold fin_val, simp, end)\n  )\n\nlemma nth_eq_succ_nth : \u03a0 {k n : \u2115} {as : dvector \u03b1 (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 : \u03a0 (as : list \u03b1), dvector \u03b1 (list.length as)\n| list.nil := dvector.nil\n| (list.cons a as) := dvector.cons a (of_list as)\n\ndef reverse : \u03a0 {n : \u2115} (v : dvector \u03b1 n),\n  dvector \u03b1 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 : \u03a0 {xl yl : \u2115}\n  {xs : dvector \u03b1 xl} {ys : dvector \u03b1 yl} {n : \u2115} (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 \u2190 (@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 : \u03a0 {xl yl : \u2115}\n  {xs : dvector \u03b1 xl} {ys : dvector \u03b1 yl} {n : \u2115}\n  (hbig : xl \u2264 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 : \u03a0 {xl yl k : \u2115}\n  {xs : dvector \u03b1 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 : \u03a0 (l : list \u03b1) (k : \u2115) (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 \u2192 \u03b1) \u2192 dvector \u03b1 n :=\n\u03bb f, dvector.cast (list.length_of_fn _) (dvector.of_list (list.of_fn f))\n\nlemma nth_of_fn (as : fin n \u2192 \u03b1) (k : \u2115) (hk : k < n) :\n  (dvector.of_fn as).nth k hk = as \u27e8 k , hk \u27e9 :=\nby rw [of_fn, nth_cast, nth_of_list, list.nth_le_of_fn']\n\nlemma nth'_of_fn (as : fin n \u2192 \u03b1) (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 \u2192 \u03b1) :\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 : \u03a0 {n : \u2115},\n  dvector \u03b1 n \u2192 list \u03b1\n| 0            as := []\n| (nat.succ n) (dvector.cons a as) := list.cons a (to_list as)\n\nlemma to_list_length : \u03a0 {n : \u2115} {as : dvector \u03b1 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 : \u2115} (i : fin n) (k : fin m) :\n  i.val * m + \u2191k < 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 \u27e8 i.1 , hi \u27e9),\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 : \u2115} (i : fin n) (xs : dvector \u03b1 (n * m)) :\n  dvector \u03b1 m :=\n  of_fn (\u03bb k, dvector.nth xs (i.1 * m + k) (dvector.ith_chunk_aux i k))\n\nlemma nth'_eq {\u03b1} {n} (ys : dvector \u03b1 n) :\n  (\u03bb (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 : \u2115} (i : fin n) (xs : dvector \u03b1 (n * m))\n  (l : \u2115) (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 \u27e8 l , hl \u27e9) :=\nby simpa only [dvector.ith_chunk, dvector.nth_of_fn]\n\nlemma nth_remove_mth_big_m : \u03a0 {n m} (xs : dvector \u03b1 (n+1)) {k : \u2115}\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 \u2190 nat.succ_lt_succ_iff,\n  exact hm,\nend\n\nlemma ext : \u03a0 {as bs : dvector \u03b1 n},\n  as = bs \u2194 \u2200 (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 \u27e8 i + 1 , nat.succ_lt_succ i.2 \u27e9,\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 : \u2115 \u2192 \u03b1} :\n  of_fn (\u03bb i : fin (n+1), f i) =\n  cons (f 0) (of_fn (\u03bb (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 : \u2115} : \u03a0 {f : \u2115 \u2192 \u03b1},\n  dvector.remove_mth n (of_fn (\u03bb (i : fin (n+1)), f i))\n  =\n  dvector.of_fn (\u03bb 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 (\u03bb (i : fin (n+2)), f i))\n      = cons (f 0) (of_fn (\u03bb i : fin n.succ, f (i + 1))) :=\n    of_fn_eq_cons_of_fn_succ,\n    have hrw1 : of_fn (\u03bb (i : fin n.succ), f i)\n      = cons (f 0) (of_fn (\u03bb 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 (\u03bb n, f (n + 1)),\n  },\nend\n\nsection ulift\n\ndef ulift_up {\u03b1} {n} : dvector \u03b1 n \u2192 dvector (ulift \u03b1) n :=\n  dvector.map ulift.up\n\ndef ulift_down {\u03b1} {n} : dvector (ulift \u03b1) n \u2192 dvector \u03b1 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 : \u2200 (a a_1 : Prop), (\u00aca \u2227 \u00aca_1 \u2228 a \u2227 \u00aca_1) \u2228 \u00aca \u2227 a_1 \u2228 a \u2227 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 \u2192 Literal\n| neg : Nat \u2192 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 \u2192 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 \u2228 b \u2228 \u00acc`. -/\ndef Clause := List Literal\n\ndef Clause.nil : Clause := []\ndef Clause.cons : Literal \u2192 Clause \u2192 Clause := List.cons\n\n/-- A formula is a list of clauses, thought of as a conjunction like `(a \u2228 b) \u2227 c \u2227 (\u00acc \u2228 \u00acd)`. -/\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 : \u2200 x, x \u2208 f' \u2192 x \u2208 f\n\ntheorem Fmla.subsumes_self (f : Fmla) : f.subsumes f := \u27e8fun _ h \u21a6 h\u27e9\ntheorem Fmla.subsumes_left (f f\u2081 f\u2082 : Fmla) (H : f.subsumes (f\u2081.and f\u2082)) : f.subsumes f\u2081 :=\n  \u27e8fun _ h \u21a6 H.1 _ $ List.mem_append.2 $ Or.inl h\u27e9\ntheorem Fmla.subsumes_right (f f\u2081 f\u2082 : Fmla) (H : f.subsumes (f\u2081.and f\u2082)) : f.subsumes f\u2082 :=\n  \u27e8fun _ h \u21a6 H.1 _ $ List.mem_append.2 $ Or.inr h\u27e9\n\n/-- A valuation is an assignment of values to all the propositional variables. -/\ndef Valuation := Nat \u2192 Prop\n\n/-- `v.neg lit` asserts that literal `lit` is falsified in the valuation. -/\ndef Valuation.neg (v : Valuation) : Literal \u2192 Prop\n| Literal.pos i => \u00ac 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 \u2228 \u00acb \u2228 c` is rewritten as\n`\u00aca \u2192 b \u2192 \u00acc \u2192 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 \u2192 Prop\n| [] => False\n| l::c => v.neg l \u2192 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 : \u2200 c, c \u2208 f \u2192 v.satisfies c\n\n/-- `f.proof c` asserts that `c` is derivable from `f`. -/\ndef Fmla.proof (f : Fmla) (c : Clause) : Prop :=\n  \u2200 v : Valuation, v.satisfies_fmla f \u2192 v.satisfies c\n\n/-- If `f` subsumes `c` (i.e. `c \u2208 f`), then `f.proof c`. -/\ntheorem Fmla.proof_of_subsumes (H : Fmla.subsumes f (Fmla.one c)) : f.proof c :=\n  fun _ h \u21a6 h.1 _ $ H.1 _ $ List.Mem.head ..\n\n/-- The core unit-propagation step.\n\nWe have a local context of assumptions `\u00acl'` (sometimes called an assignment)\nand we wish to add `\u00acl` to the context, that is, we want to prove `l` is also falsified.\nThis is because there is a clause `a \u2228 b \u2228 \u00acl` in the global context\nsuch that all literals in the clause are falsified except for `\u00acl`;\nso in the context `h\u2081` where we suppose that `\u00acl` is falsified,\nthe clause itself is falsified so we can prove `False`.\nWe continue the proof in `h\u2082`, with the assumption that `l` is falsified. -/\ntheorem Valuation.by_cases {v : Valuation} {l}\n  (h\u2081 : v.neg l.negate \u2192 False) (h\u2082 : v.neg l \u2192 False) : False :=\nmatch l with\n| Literal.pos _ => h\u2082 h\u2081\n| Literal.neg _ => h\u2081 h\u2082\n\n/-- `v.implies p [a, b, c] 0` definitionally unfolds to `(v 0 \u2194 a) \u2192 (v 1 \u2194 b) \u2192 (v 2 \u2194 c) \u2192 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 \u2192 Nat \u2192 Prop\n| [], _ => p\n| a::as, n => (v n \u2194 a) \u2192 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 \u2192 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\u2081) : as = List.reverseAux as\u2081 ps \u2192\n  (Valuation.mk as).implies p ps as\u2081.length \u2192 p := by\n  induction ps generalizing as\u2081 with\n  | nil => exact fun _ \u21a6 id\n  | cons a as ih =>\n    refine fun e H \u21a6 @ih (a::as\u2081) e (H ?_)\n    subst e; clear ih H\n    suffices \u2200 n n', n' = List.length as\u2081 + n \u2192\n      \u2200 bs, mk (as\u2081.reverseAux bs) n' \u2194 mk bs n from this 0 _ rfl (a::as)\n    induction as\u2081 with simp\n    | cons b as\u2081 ih => exact fun n bs \u21a6 ih (n+1) _ (Nat.succ_add ..) _\n\n/-- Asserts that `\u00ac\u27e6f\u27e7_v` implies `p`. -/\nstructure Fmla.reify (v : Valuation) (f : Fmla) (p : Prop) : Prop where\n  prop : \u00ac v.satisfies_fmla f \u2192 p\n\n/-- If `f` is unsatisfiable, and every `v` which agrees with `ps` implies `\u00ac\u27e6f\u27e7_v \u2192 p`, then `p`.\nEquivalently, there exists a valuation `v` which agrees with `ps`,\nand every such valuation yields `\u00ac\u27e6f\u27e7_v` because `f` is unsatisfiable. -/\ntheorem Fmla.refute (f : Fmla) (hf : f.proof [])\n  (hv : \u2200 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 `\u00ac\u27e6f\u2081 \u2227 f\u2082\u27e7_v \u2261 \u00ac\u27e6f\u2081\u27e7_v \u2228 \u00ac\u27e6f\u2082\u27e7_v`. -/\ntheorem Fmla.reify_or (h\u2081 : Fmla.reify v f\u2081 a) (h\u2082 : Fmla.reify v f\u2082 b) :\n  Fmla.reify v (f\u2081.and f\u2082) (a \u2228 b) := by\n  refine \u27e8fun H \u21a6 by_contra fun hn \u21a6 H \u27e8fun c h \u21a6 by_contra fun hn' \u21a6 ?_\u27e9\u27e9\n  rcases List.mem_append.1 h with h | h\n  \u00b7 exact hn $ Or.inl $ h\u2081.1 fun Hc \u21a6 hn' $ Hc.1 _ h\n  \u00b7 exact hn $ Or.inr $ h\u2082.1 fun Hc \u21a6 hn' $ Hc.1 _ h\n\n/-- Asserts that `\u00ac\u27e6c\u27e7_v` implies `p`. -/\nstructure Clause.reify (v : Valuation) (c : Clause) (p : Prop) : Prop where\n  prop : \u00ac v.satisfies c \u2192 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  \u27e8fun H \u21a6 h.1 fun h \u21a6 H \u27e8fun | _, List.Mem.head .. => h\u27e9\u27e9\n\n/-- Asserts that `\u00ac\u27e6l\u27e7_v` implies `p`. -/\nstructure Literal.reify (v : Valuation) (l : Literal) (p : Prop) : Prop where\n  prop : v.neg l \u2192 p\n\n/-- Negation turns OR into AND, so `\u00ac\u27e6l \u2228 c\u27e7_v \u2261 \u00ac\u27e6l\u27e7_v \u2227 \u00ac\u27e6c\u27e7_v`. -/\ntheorem Clause.reify_and (h\u2081 : Literal.reify v l a) (h\u2082 : Clause.reify v c b) :\n  Clause.reify v (Clause.cons l c) (a \u2227 b) :=\n  \u27e8fun H \u21a6 \u27e8h\u2081.1 (by_contra fun hn \u21a6 H hn.elim), h\u2082.1 fun h \u21a6 H fun _ \u21a6 h\u27e9\u27e9\n\n/-- The reification of the empty clause is `True`: `\u00ac\u27e6\u22a5\u27e7_v \u2261 True`. -/\ntheorem Clause.reify_zero : Clause.reify v Clause.nil True := \u27e8fun _ \u21a6 trivial\u27e9\n\n/-- The reification of a singleton clause `\u00ac\u27e6l\u27e7_v \u2261 \u00ac\u27e6l\u27e7_v`. -/\ntheorem Clause.reify_one (h\u2081 : Literal.reify v l a) : Clause.reify v (Clause.nil.cons l) a :=\n  \u27e8fun H \u21a6 ((Clause.reify_and h\u2081 Clause.reify_zero).1 H).1\u27e9\n\n/-- The reification of a positive literal `\u00ac\u27e6a\u27e7_v \u2261 \u00aca`. -/\ntheorem Literal.reify_pos (h : v n \u2194 a) : (Literal.pos n).reify v \u00aca := \u27e8mt h.2\u27e9\n\n/-- The reification of a negative literal `\u00ac\u27e6\u00aca\u27e7_v \u2261 a`. -/\ntheorem Literal.reify_neg (h : v n \u2194 a) : (Literal.neg n).reify v a := \u27e8h.1\u27e9\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 `\u22a2 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 \u21a6 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 `\u22a2 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 \u00d7 HashMap Nat Clause) : Nat \u00d7 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\u2081 := f.appFn!.appArg!\n    let f\u2082 := f.appArg!\n    let p\u2081 := mkApp4 (mkConst ``Sat.Fmla.subsumes_left) ctx f\u2081 f\u2082 p\n    let p\u2082 := mkApp4 (mkConst ``Sat.Fmla.subsumes_right) ctx f\u2081 f\u2082 p\n    let accum := buildClauses arr ctx start mid f\u2081 p\u2081 accum\n    buildClauses arr ctx mid stop f\u2082 p\u2082 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 `\u22a2 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 `\u22a2 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 \u21a6 ...) 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 `\u22a2 ctx.proof [a, b, c]` to\n     `\u2200 v, v.satisfies_fmla ctx \u2192 v.neg a \u2192 v.neg b \u2192 v.neg c \u2192 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 \u2192 v.neg y \u2192 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 \u21a6 hc v hv hnx hy) (fun hx : v.neg x \u21a6 ...)`\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 \u00b7 args) \u2218\n    lams.foldr (mkLambda `c default) \u2218\n    mkLambda `v default (mkConst ``Sat.Valuation) \u2218\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 \u2218 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 \u21a6 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 `\u22a2 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 (\u00b7.erase \u00b7) 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 `\u22a2 \u2200 a b : Prop, (a \u2227 b) \u2228 (\u00aca \u2227 b) \u2228 \u00acb`. 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 \u2194 a1, ... hn : v (n-1) \u2194 an \u22a2 ...`, 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 \u2194 a1) ... (hn : v (n-1) \u2194 an) \u21a6 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 \u22a2 [a1, ..., an] : List Prop`\n  5. `refute ctx (hf : ctx.proof []) (fun v h1 .. hn \u21a6 pr) : a` forces some definitional unfolding\n     since `fun h1 .. hn \u21a6 pr` should have type `implies v (reify v ctx a) [a1, ..., an] a`,\n     which involves unfolding `implies` n times as well as `ctx \u21a6 ctx'`.\n  6. Finally, we `intro a1 ... an` so that we have a proof of `\u2200 a1 ... an, a`.\n-/\npartial def buildReify (ctx ctx' proof : Expr) (nvars : Nat) : Expr \u00d7 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\u2081 := f.appFn!.appArg!\n      let f\u2082 := f.appArg!\n      let (e\u2081, h\u2081) := reifyFmla f\u2081\n      let (e\u2082, h\u2082) := reifyFmla f\u2082\n      (mkApp2 (mkConst ``Or) e\u2081 e\u2082, mkApp7 (mkConst ``Sat.Fmla.reify_or) v f\u2081 e\u2081 f\u2082 e\u2082 h\u2081 h\u2082)\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\u2081, h\u2081) := reifyLiteral l\n    if c.isConst then\n      (e\u2081, mkApp4 (mkConst ``Sat.Clause.reify_one) v l e\u2081 h\u2081)\n    else\n      let (e\u2082, h\u2082) := reifyClause1 c\n      (mkApp2 (mkConst ``And) e\u2081 e\u2082, mkApp7 (mkConst ``Sat.Clause.reify_and) v l e\u2081 c e\u2082 h\u2081 h\u2082)\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 \u2194 a` given a variable index `n`.\n  These are both lookups into the context\n  `(a0 .. a(n-1) : Prop) (v) (h1 : v 0 \u2194 a0) ... (hn : v (n-1) \u2194 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 (\u2190 peek!) = '-' then skip; pure $ -(\u2190 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 \u2190 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 \u2190 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 \u00d7 Array (Array Int)) := do\n  pstring \"p cnf\" *> ws\n  let nvars \u2190 parseNat <* ws\n  let nclauses \u2190 parseNat <* ws\n  let mut clauses := Array.mkEmpty nclauses\n  for _ in [:nclauses] do\n    clauses := clauses.push (\u2190 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 \u2190 parseNat <* ws\n  if (\u2190 peek!) = 'd' then skip <* ws; pure $ LRATStep.del (\u2190 parseNats)\n  else ws; pure $ LRATStep.add step (\u2190 parseInts) (\u2190 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 \u00d7 Expr \u00d7 Expr \u00d7 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 \u2190 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 \u2190 buildProof arr ctx ctx' steps\n  let declName \u2190 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`\u2200 (a a_1 : Prop), (\u00aca \u2227 \u00aca_1 \u2228 a \u2227 \u00aca_1) \u2228 \u00aca \u2227 a_1 \u2228 a \u2227 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) \u2190 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 : \u2200 (a a_1 : Prop), (\u00aca \u2227 \u00aca_1 \u2228 a \u2227 \u00aca_1) \u2228 \u00aca \u2227 a_1 \u2228 a \u2227 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 := (\u2190 getCurrNamespace) ++ if n.1.isIdent then n.1.getId else `_example\n  Command.liftTermElabM do\n    let cnf \u2190 unsafe evalTerm String (mkConst ``String) cnf\n    let lrat \u2190 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 : \u2200 (a a_1 : Prop), (\u00aca \u2227 \u00aca_1 \u2228 a \u2227 \u00aca_1) \u2228 \u00aca \u2227 a_1 \u2228 a \u2227 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 \u2190 unsafe evalTerm String (mkConst ``String) cnf\n  let lrat \u2190 unsafe evalTerm String (mkConst ``String) lrat\n  let name \u2190 mkAuxName `lrat\n  fromLRAT cnf lrat name\n  return mkConst name\n\nexample : \u2200 (a b : Prop), (\u00aca \u2227 \u00acb \u2228 a \u2227 \u00acb) \u2228 \u00aca \u2227 b \u2228 a \u2227 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 : \u211d) : \u211d := sorry\ndef cos (x : \u211d) : \u211d := sorry\n\nnamespace problem1\n\n-- (1) Consider the sine function defined by f(x) = sin x for (\u2212\u221e < x < \u221e).\n\n-- uhm we don't actually have the sin function in Lean yet ...\ndef f (x : \u211d) : \u211d := sin x\n-- nor pi\ndef pi : \u211d := sorry\n\n-- but if we did, we could prove this!\n\nnamespace part_a\n\n-- What is the image of \u03c0/2 under f?\nlemma answer_proof : f (pi / 2) = 1 := sorry\n\nend part_a\n\nnamespace part_b\n\n-- Find f\u207b\u00b9(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 \u211d := {x | f x = 1}\n-- aka the preimage\nlemma proof_preimage : answer = f \u207b\u00b9' {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 \u2208 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, \u03c0/6]), f([\u03c0/6, \u03c0/2]), f([0, \u03c0/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 \u2192 B and if X \u2282 A and Y \u2282 A, then f(X \u222a Y) = f(X) \u222a 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 \u2192 B) (X Y : set A) :\n  f '' (X \u222a Y) = f '' X \u222a 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] \u222a [c, d] = [a, d], given the following assumptions\ntheorem Icc_union {\u03b1 : Type*} [linear_order \u03b1] (a b c d : \u03b1) :\n  a \u2264 c \u2192 b \u2265 c \u2192 b \u2264 d \u2192\n  Icc a b \u222a 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 \u2264 b \u2228 b \u2264 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) \u222a Icc (pi/6) (pi/2) = Icc 0 (pi/2),\n  {\n    apply Icc_union,\n    /-\n    3 goals\n    \u22a2 0 \u2264 pi / 6\n    \u22a2 pi / 6 \u2265 pi / 6\n    \u22a2 pi / 6 \u2264 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 \u2190 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, \u03c0/6], B = [5\u03c0/6, \u03c0]. Does f(A \u2229 B) = f(A) \u2229 f(B)?\n\n-- nope, because A \u2229 B = \u2205, 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 \u2229 B) \u2260 f '' A \u2229 f '' B :=\n  begin\n  rw [A_image, B_image],\n  have : A \u2229 B = \u2205,\n  {\n    apply set.ext, intro x, simp,\n    show 0 \u2264 x \u2227 x \u2264 pi/6 \u2192 \u00ac (5*pi/6 \u2264 x \u2227 x \u2264 pi),\n    suffices : x \u2264 pi/6 \u2192 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 (\u00ac p) you need to prove (p \u2192 false))\n  -- (actually, that is true by definition: not p := p \u2192 false)\n  intro empty_eq_Icc,\n  -- 0 is an element in the interval\n  exact (empty_eq_Icc 0).2 \u27e8le_refl 0, le_of_lt one_half_pos\u27e9\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 : (\u22121, 1) \u2192 \u211d is defined by f(x) = arcsin x and\n--     g : (\u2212\u03c0/2, \u03c0/2) \u2192 \u211d by g(x) = tan x, let h = g \u25e6 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\u00b2)\n--     = sqrt(x\u00b2 / (1 - x\u00b2))\n--     = if x = 0 then 0 else (x\u207b\u00b2 - 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 : (-\u03c0/2, \u03c0/2),\n--   since f is continuous and monotonic between f(-1) = -\u03c0/2 and f(1) = \u03c0/2\n-- domain of g : (-\u03c0/2, \u03c0/2), range of g : (-\u221e, \u221e),\n--   since f is continuous and lim[x \u2192 \u00ad\u00b1\u03c0/2] f = \u00b1\u221e\n-- so domain of h : (-1, 1), range of h : (-\u221e, \u221e)\n\nend problem3\n\nnamespace problem4\n\n-- (4) Let f : \u211d \u2192 \u211d be defined by f(x) = 2x. Can you think of functions g\n--     and h which satisfy these two equations?\n-- g \u25e6 f = 2 * g * h\n-- h \u25e6 f = h^2 \u2212 g^2\n\ndef f (x : \u211d) := 2*x\n\ndef problem := \u2203 (g h : \u211d \u2192 \u211d), \u2200 x,\n  g (f x) = 2 * g x * h x \u2227\n  h (f x) = (h x)^2 - (g x)^2\n\ndef g (x : \u211d) := sin x\ndef h (x : \u211d) := cos x\n\n-- graph it! obviously can't prove it here ...\nlemma sin_two_eq_two_sin_cos :\n  \u2200 x, sin (2 * x) = 2 * sin x * cos x := sorry\nlemma sin_two_eq_cos_sqr_sub_sin_sqr :\n  \u2200 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 \u211d.\n-- Define the characteristic function of A \u03c7_A : \u211d \u2192 \u211d to be\n\n-- \u03c7_A(x) = 1 if x \u2208 A; 0 if x \u2208 \u211d \\ 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 \u03c7 {\u03b1 : Type} (A : set \u03b1) (a : \u03b1) := a \u2208 A\n-- but really it's just the identity function\n-- (this is because sets in set theory are represented as functions\n-- \u03b1 \u2192 Prop, for some \u03b1 : Type, where the proposition returned\n-- is true for only the (a : \u03b1) in the set.)\n-- (in HoTT, a set also means that it has no path constructors.)\n@[simp] lemma \u03c7_id {\u03b1 : Type} (A : set \u03b1) : \u03c7 A = A := rfl\n\n\nnamespace problem5\n\n-- (5) If f : \u211d \u2192 \u211d is defined by f(x) = x^2 and \u03c7_[0,9] is the\n--     characteristic function of [0, 9], of what subset of \u211d is\n--     \u03c7[0,9] \u25e6 f the characteristic function?\n\ndef real.sqr (x : \u211d) := x ^ 2\ndef zero_through_nine : set \u211d := Icc 0 9\n\ndef answer : set \u211d := Icc (-3) 3\n\ntheorem proof : answer = \u03c7 zero_through_nine \u2218 real.sqr :=\n  begin\n  apply set.ext, intro x,\n  show -3 \u2264 x \u2227 x \u2264 3 \u2194 0 \u2264 x^2 \u2227 x^2 \u2264 9,\n  unfold has_pow.pow monoid.pow, simp,\n  rw (by ring : (9 : \u211d) = 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 (\u03bb y, x = y \u2228 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 \u2190 abs_le,\n    have : (0 : \u211d) \u2264 3,\n      { change real.of_rat 0 \u2264 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 : \u211d); assumption) : 3 = real.sqrt (3^2)),\n    unfold has_pow.pow monoid.pow, simp,\n    rw \u2190 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 \u2192 B is a function and \u03c7_E is the characteristic function of\n-- E \u2282 B, of what subset of A is \u03c7_E \u25e6 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 \u2208 E }\ndef answer {A B : Type} (f : A \u2192 B) (E : set B) := f \u207b\u00b9' E\n#print set.preimage\ntheorem proof {A B : Type} (f : A \u2192 B) (E : set B)\n  : \u03c7 E \u2218 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 \u211d? That is, is there\n--     a subset A of \u211d such that \u03c7_A is continuous?\n\n-- Yes, there are two: A = \u211d, and A = \u2205.\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 \u2192 B \u2192 O) (g : I \u2192 A) (h : I \u2192 B) :=\n  \u03bb i, f (g i) (h i)\n\ntheorem proof (f g : \u211d \u2192 \u211d) : continuous f \u2192 continuous g \u2192 continuous (pointwise max f g) \u2227 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 \u2192 B and g : B \u2192 C and both f and g are injective,\n--         is g \u25e6 f also injective?\n--     (b) If f is not injective, is it still possible that g \u25e6 f is\n--         injective?\n--     (c) Give an example in which f is injective, g is not injective,\n--         but g \u25e6 f is injective.\nopen function\n\n-- it's very straightforward ...\ntheorem part_a {A B C : Type} (f : A \u2192 B) (g : B \u2192 C) : function.injective f \u2192 function.injective g \u2192 function.injective (g \u2218 f) :=\n  flip function.injective_comp\n\ntheorem part_b {A B C : Type} (f : A \u2192 B) (g : B \u2192 C) : \u00ac function.injective f \u2192 function.injective g \u2192 \u00ac function.injective (g \u2218 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 \u2192 B := \u03bb _, ff\ndef g : B \u2192 C := \u03bb _, unit.star\ntheorem proof : injective f \u2227 \u00ac injective g \u2227 injective (g \u2218 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 + \u00b7 \u00b7 \u00b7 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 \u03b1` instead of `countable \u03b1`, which is\n-- defined as `nonempty (encodable \u03b1)` (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 {\u03b1 \u03b2 : Type} : \u03b1 \u2243 \u03b2 \u2192 encodable \u03b1 \u2192 encodable \u03b2 :=\n  begin\n  intros eqv c,\n  apply encodable.mk (c.encode \u2218 eqv.2) (option.map eqv.1 \u2218 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 {\u03b1 : Type} : encodable \u03b1 \u2192 \u2200 n : \u2115, encodable (vector \u03b1 n) :=\n  begin\n  intros c n, induction n with n ih,\n  suffices : unit \u2243 vector \u03b1 0,\n  {\n    apply encodable_equiv this, apply_instance,\n  },\n  apply equiv.mk (\u03bb _, vector.nil) (\u03bb _, unit.star),\n  intro _, apply subsingleton.elim,\n  intro _, rw vector.eq_nil x,\n  suffices : (\u03b1 \u00d7 vector \u03b1 n) \u2243 vector \u03b1 (n+1),\n  {\n    apply encodable_equiv this,\n    apply @encodable.prod _ _ c ih,\n  },\n  apply equiv.mk\n    (\u03bb (p : \u03b1 \u00d7 vector \u03b1 n), vector.cons p.1 p.2)\n    (\u03bb 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 {\u03b1 : Type} (A B : set \u03b1)\n  (H : B \u2286 A) (HA : \u00ac(countable A)) (HB : countable B) : \u00ac(countable (A \\ B)) :=\n  \u03bb HC,\n  have this : (A \\ B) \u222a 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 : \u00ac (\u2200 T : Type, \u2200 L : language T,\n    is_CF L  \u2192  is_CF (L\u1d9c)\n) :=\nbegin\n  intro h,\n  have nny := nnyCF_of_CF_i_CF,\n  push_neg at nny,\n  rcases nny with \u27e8T, L\u2081, L\u2082, \u27e8hL\u2081, hL\u2082\u27e9, hyp_neg\u27e9,\n  specialize h T,\n  have hu := CF_of_CF_u_CF (L\u2081\u1d9c) (L\u2082\u1d9c) \u27e8h L\u2081 hL\u2081, h L\u2082 hL\u2082\u27e9,\n  have contra := h (L\u2081\u1d9c + L\u2082\u1d9c) 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\u2081 v\u2082 u\u2081 u\u2082 u\n\nopen CategoryTheory\n\nopen CategoryTheory.MonoidalCategory\n\nvariable (C : Type u\u2081) [Category.{v\u2081} C] [MonoidalCategory.{v\u2081} C] [BraidedCategory.{v\u2081} C]\n\n/-- A commutative monoid object internal to a monoidal category.\n-/\nstructure CommMon_ extends Mon_ C where\n  mul_comm' : (\u03b2_ _ _).Hom \u226b 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  \u27e8trivial C\u27e9\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 (\ud835\udfd9 A) = \ud835\udfd9 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 \u27f6 S) (g : S \u27f6 T) :\n    Mon_.Hom.hom (f \u226b g) = f.Hom \u226b 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\u2082Mon_ : CommMon_ C \u2964 Mon_ C :=\n  inducedFunctor CommMon_.toMon_ deriving Full, Faithful\n#align CommMon_.forget\u2082_Mon_ CommMon_.forget\u2082Mon_\n\n@[simp]\ntheorem forget\u2082_Mon_obj_one (A : CommMon_ C) : ((forget\u2082Mon_ C).obj A).one = A.one :=\n  rfl\n#align CommMon_.forget\u2082_Mon_obj_one CommMon_.forget\u2082_Mon_obj_one\n\n@[simp]\ntheorem forget\u2082_Mon_obj_mul (A : CommMon_ C) : ((forget\u2082Mon_ C).obj A).mul = A.mul :=\n  rfl\n#align CommMon_.forget\u2082_Mon_obj_mul CommMon_.forget\u2082_Mon_obj_mul\n\n@[simp]\ntheorem forget\u2082_Mon_map_hom {A B : CommMon_ C} (f : A \u27f6 B) : ((forget\u2082Mon_ C).map f).Hom = f.Hom :=\n  rfl\n#align CommMon_.forget\u2082_Mon_map_hom CommMon_.forget\u2082_Mon_map_hom\n\nend\n\ninstance uniqueHomFromTrivial (A : CommMon_ C) : Unique (trivial C \u27f6 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\u2082} [Category.{v\u2082} D] [MonoidalCategory.{v\u2082} D] [BraidedCategory.{v\u2082} D]\n\n/-- A lax braided functor takes commutative monoid objects to commutative monoid objects.\n\nThat is, a lax braided functor `F : C \u2964 D` induces a functor `CommMon_ C \u2964 CommMon_ D`.\n-/\n@[simps]\ndef mapCommMon (F : LaxBraidedFunctor C D) : CommMon_ C \u2964 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 [\u2190 this]\n        slice_lhs 2 3 => rw [\u2190 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 \u2964 CommMon_ C \u2964 CommMon_ D\n    where\n  obj := mapCommMon\n  map F G \u03b1 := { app := fun A => { Hom := \u03b1.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 \u2964 CommMon_ C\n    where\n  obj F := (F.mapCommMon : CommMon_ _ \u2964 CommMon_ C).obj (trivial (Discrete PUnit))\n  map F G \u03b1 := ((mapCommMonFunctor (Discrete PUnit) C).map \u03b1).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 \u2964 LaxBraidedFunctor (Discrete PUnit.{u + 1}) C\n    where\n  obj A :=\n    { obj := fun _ => A.pt\n      map := fun _ _ _ => \ud835\udfd9 _\n      \u03b5 := A.one\n      \u03bc := fun _ _ => A.mul\n      map_id' := fun _ => rfl\n      map_comp' := fun _ _ _ _ _ => (Category.id_comp (\ud835\udfd9 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    \ud835\udfed (LaxBraidedFunctor (Discrete PUnit.{u + 1}) C) \u2245\n      laxBraidedToCommMon C \u22d9 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 \u22d9 laxBraidedToCommMon C \u2245 \ud835\udfed (CommMon_ C) :=\n  NatIso.ofComponents\n    (fun F =>\n      { Hom := { Hom := \ud835\udfd9 _ }\n        inv := { Hom := \ud835\udfd9 _ } })\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 \u224c 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u03b1 \u03b2 \u03b3 \u03b4 : Type*}\n\n/-- The type of bounded maps from `\u03b1` to `\u03b2`, the maps which send a bounded set to a bounded set. -/\nstructure locally_bounded_map (\u03b1 \u03b2 : Type*) [bornology \u03b1] [bornology \u03b2] :=\n(to_fun : \u03b1 \u2192 \u03b2)\n(comap_cobounded_le' : (cobounded \u03b2).comap to_fun \u2264 cobounded \u03b1)\n\nsection\nset_option old_structure_cmd true\n\n/-- `locally_bounded_map_class F \u03b1 \u03b2` 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*) (\u03b1 \u03b2 : out_param $ Type*) [bornology \u03b1]\n  [bornology \u03b2]\n  extends fun_like F \u03b1 (\u03bb _, \u03b2) :=\n(comap_cobounded_le (f : F) : (cobounded \u03b2).comap f \u2264 cobounded \u03b1)\n\nend\n\nexport locally_bounded_map_class (comap_cobounded_le)\n\nlemma is_bounded.image [bornology \u03b1] [bornology \u03b2] [locally_bounded_map_class F \u03b1 \u03b2] {f : F}\n  {s : set \u03b1} (hs : is_bounded s) : is_bounded (f '' s) :=\ncomap_cobounded_le_iff.1 (comap_cobounded_le f) hs\n\ninstance [bornology \u03b1] [bornology \u03b2] [locally_bounded_map_class F \u03b1 \u03b2] :\n  has_coe_t F (locally_bounded_map \u03b1 \u03b2) :=\n\u27e8\u03bb f, \u27e8f, comap_cobounded_le f\u27e9\u27e9\n\nnamespace locally_bounded_map\nvariables [bornology \u03b1] [bornology \u03b2] [bornology \u03b3]\n  [bornology \u03b4]\n\ninstance : locally_bounded_map_class (locally_bounded_map \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := \u03bb f, f.to_fun,\n  coe_injective' := \u03bb f g h, by { cases f, cases g, congr' },\n  comap_cobounded_le := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : locally_bounded_map \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n@[ext] lemma ext {f g : locally_bounded_map \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) :\n  locally_bounded_map \u03b1 \u03b2 :=\n\u27e8f', h.symm \u25b8 f.comap_cobounded_le'\u27e9\n\n@[simp] lemma coe_copy (f : locally_bounded_map \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) :\n  \u21d1(f.copy f' h) = f' :=\nrfl\n\nlemma copy_eq (f : locally_bounded_map \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (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 : \u03b1 \u2192 \u03b2) (h) : locally_bounded_map \u03b1 \u03b2 := \u27e8f, comap_cobounded_le_iff.2 h\u27e9\n\n@[simp] lemma coe_of_map_bounded (f : \u03b1 \u2192 \u03b2) {h} : \u21d1(of_map_bounded f h) = f := rfl\n@[simp] lemma of_map_bounded_apply (f : \u03b1 \u2192 \u03b2) {h} (a : \u03b1) : of_map_bounded f h a = f a := rfl\n\nvariables (\u03b1)\n\n/-- `id` as a `locally_bounded_map`. -/\nprotected def id : locally_bounded_map \u03b1 \u03b1 := \u27e8id, comap_id.le\u27e9\n\ninstance : inhabited (locally_bounded_map \u03b1 \u03b1) := \u27e8locally_bounded_map.id \u03b1\u27e9\n\n@[simp] lemma coe_id : \u21d1(locally_bounded_map.id \u03b1) = id := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : locally_bounded_map.id \u03b1 a = a := rfl\n\n/-- Composition of `locally_bounded_map`s as a `locally_bounded_map`. -/\ndef comp (f : locally_bounded_map \u03b2 \u03b3) (g : locally_bounded_map \u03b1 \u03b2) : locally_bounded_map \u03b1 \u03b3 :=\n{ to_fun := f \u2218 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 \u03b2 \u03b3) (g : locally_bounded_map \u03b1 \u03b2) :\n  \u21d1(f.comp g) = f \u2218 g := rfl\n@[simp] lemma comp_apply (f : locally_bounded_map \u03b2 \u03b3) (g : locally_bounded_map \u03b1 \u03b2) (a : \u03b1) :\n  f.comp g a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : locally_bounded_map \u03b3 \u03b4) (g : locally_bounded_map \u03b2 \u03b3)\n  (h : locally_bounded_map \u03b1 \u03b2) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : locally_bounded_map \u03b1 \u03b2) :\n  f.comp (locally_bounded_map.id \u03b1) = f := ext $ \u03bb a, rfl\n@[simp] lemma id_comp (f : locally_bounded_map \u03b1 \u03b2) :\n  (locally_bounded_map.id \u03b2).comp f = f := ext $ \u03bb a, rfl\n\nlemma cancel_right {g\u2081 g\u2082 : locally_bounded_map \u03b2 \u03b3} {f : locally_bounded_map \u03b1 \u03b2}\n  (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : locally_bounded_map \u03b2 \u03b3} {f\u2081 f\u2082 : locally_bounded_map \u03b1 \u03b2}\n  (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, ext $ \u03bb a, hg $ by rw [\u2190comp_apply, h, comp_apply], congr_arg _\u27e9\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 {\u03b1 \u03b2:Type*} {B\u03b1:set (set \u03b1)}:\n    (@set.preimage (\u03b1 \u00d7 \u03b2) \u03b1 (@prod.fst \u03b1 \u03b2) '' B\u03b1) =\n    {U : set (\u03b1 \u00d7 \u03b2) | \u2203 (A : set \u03b1) (H : A \u2208 B\u03b1), U = @set.prod \u03b1 \u03b2 A (@set.univ \u03b2)} :=\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 {\u03b1 \u03b2:Type*} {B\u03b2:set (set \u03b2)}:\n    (@set.preimage (\u03b1 \u00d7 \u03b2) \u03b2 (@prod.snd \u03b1 \u03b2) '' B\u03b2) =\n    {U : set (\u03b1 \u00d7 \u03b2) | \u2203 (B : set \u03b2) (H : B \u2208 B\u03b2), U = @set.prod \u03b1 \u03b2 (@set.univ \u03b1) 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' {\u03b1 \u03b2:Type*} (f:\u03b1 \u2192 \u03b2) (T:set (set \u03b2)):\n (f \u207b\u00b9' \u22c3\u2080 T)=\u22c3\u2080 (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 {\u03b1:Type*} (A:set \u03b1) {\u03b2:Type*} (B:set (set \u03b2)):\n  (set.prod A (\u22c3\u2080 B)) = \u22c3\u2080  {C:set (\u03b1\u00d7 \u03b2)|\u2203 b\u2208 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 {\u03b1:Type*} (A:set (set \u03b1)) {\u03b2:Type*} (B:set \u03b2):\n  (set.prod (\u22c3\u2080 A) B) = \u22c3\u2080  {C:set (\u03b1\u00d7 \u03b2)|\u2203 a\u2208 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 {\u03b2:Type*} [decidable_eq \u03b2] {b:\u03b2} {S S2:finset \u03b2}:\n  b\u2208 (S \u222a S2) \u2194 (\n      ((b\u2208  S) \u2227 (b\u2209 S2)) \u2228 \n      ((b\u2208 S) \u2227 (b \u2208 S2)) \u2228 \n      ((b\u2209 S) \u2227 (b\u2208 S2))) :=\nbegin\n  have B1:(b\u2208 S)\u2228 (b\u2209 S),\n  {\n    apply classical.em,\n  },\n  have B2:(b\u2208 S2)\u2228 (b\u2209 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 {\u03b1:Type*} {A B:set \u03b1}:disjoint A B \u2192 disjoint B A :=\nbegin\n  apply @disjoint.symm (set \u03b1) _,\nend\n\n--Unused, but there are parallels in mathlib for finset and list.\n--Too trivial now.\nlemma set.disjoint_comm {\u03b1:Type*} {A B:set \u03b1}:disjoint A B \u2194 disjoint B A :=\nbegin\n  apply @disjoint.comm (set \u03b1) _,\nend\n\nlemma set.disjoint_compl_right {\u03b1:Type*} (B:set \u03b1):disjoint B B\u1d9c :=\nbegin\n  rw disjoint_iff,\n  simp,\nend \n\nlemma set.disjoint_inter_compl {\u03b1:Type*} (A B C:set \u03b1):disjoint (A \u2229 B) (C\u2229 B\u1d9c) :=\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\u1d9c),\n  simp [disjoint_iff],\nend\n\n--In general, disjoint A C \u2192 disjoint (A \u2293 B) C\nlemma set.disjoint_inter_left {\u03b1:Type*} {A B C:set \u03b1}:\n  disjoint A C \u2192\n  disjoint (A \u2229 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 \u2192 disjoint A (B \u2293 C)\nlemma set.disjoint_inter_right {\u03b1:Type*} {A B C:set \u03b1}:\n  disjoint A C \u2192\n  disjoint A (B \u2229 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 {\u03b1:Type*} {f:\u2115 \u2192 set \u03b1} {n:\u2115}:\n    f n \u2264 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 {\u03b1:Type*} {f:\u2115 \u2192 set \u03b1} {S:set \u03b1}:\n    (\u2200 i, f i \u2264 S) \u2192 \n    set.Union f \u2264 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 {\u03b1:Type*}\n    {f:\u2115 \u2192 set \u03b1}:\n    supr f = set.Union f :=\nbegin\n  apply le_antisymm,\n  {\n    apply @supr_le (set \u03b1) _ _,\n    intro i,\n    apply set.le_Union,\n  },\n  {\n    apply set.Union_le,\n    intros n,\n    apply @le_supr (set \u03b1) _ _,\n  },\nend\n\nlemma empty_of_subset_empty {\u03b1:Type*} (X:set \u03b1):\n    X \u2286 \u2205 \u2192 X = \u2205 :=\nbegin\n  have A1:(\u2205:set \u03b1) = \u22a5 := rfl,\n  rw A1,\n  rw \u2190 set.le_eq_subset,\n  intro A2,\n  rw le_bot_iff at A2,\n  apply A2,\nend\n\nlemma subset_empty_iff {\u03b1:Type*} (X:set \u03b1):\n    X \u2286 \u2205 \u2194 X = \u2205 :=\nbegin\n  have A1:(\u2205:set \u03b1) = \u22a5 := rfl,\n  rw A1,\n  rw \u2190 set.le_eq_subset,\n  apply le_bot_iff,\nend\n\nlemma set.eq_univ_iff_univ_subset {\u03b1:Type*} {S:set \u03b1}:\n  set.univ \u2286 S \u2194 S = set.univ :=\nbegin\n  have A1:@set.univ \u03b1 = \u22a4 := rfl,\n  rw A1,\n  rw \u2190 set.le_eq_subset,\n  apply top_le_iff,\nend\n\nlemma preimage_if {\u03b1 \u03b2:Type*}\n  {E:set \u03b1} {D:decidable_pred E}\n  {X Y:\u03b1 \u2192 \u03b2} {S:set \u03b2}:\n  set.preimage (\u03bb a:\u03b1, if (E a) then (X a) else (Y a)) S =\n  (E \u2229 set.preimage X S) \u222a (E\u1d9c \u2229 set.preimage Y S) :=\nbegin\n  ext a;split;intros A1,\n  {\n    cases (classical.em (a\u2208 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 {\u03b1:Type*} {A B:set \u03b1} {x:\u03b1}:(x\u2209 B) \u2192 ((insert x A) \u2229 B = A \u2229 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 {\u03b1:Type*} {A B:set \u03b1} {x:\u03b1}:(x\u2209 A) \u2192 (A \u2229 (insert x B) = A \u2229 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 {\u03b1:Type*} {A B:set \u03b1} {x:\u03b1}:(x\u2209 A) \u2192 (A \u2229 (insert x B) = A \u2229 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 {\u03b1:Type*} {A B:set \u03b1} {x:\u03b1}:(x\u2208 A) \u2192 (A \u2229 (insert x B) = insert x (A \u2229 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 {\u03b1:Type*} {A B C:set \u03b1} {x:\u03b1}:\n  (A \u2229 (insert x B) = insert x (C)) \u2192 (x \u2208 A) :=\nbegin\n  intros A1,\n  have B1 := set.mem_insert x (C),\n  rw \u2190 A1 at B1,\n  simp at B1,\n  apply B1,\nend\n\n\nlemma set.eq_of_insert_of_not_mem {\u03b1:Type*} {A B:set \u03b1} {x:\u03b1}:(x\u2209 A) \u2192 (x\u2209 B) \u2192 (insert x A  = insert x B)\n  \u2192 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 \u2190 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 {\u03b1:Type*} {f:\u2115 \u2192 set \u03b1}:\n  (@monotone \u2115 (set \u03b1) _ (order_dual.preorder (set \u03b1)) f) \u2192 (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 {\u03b1:Type*} {f:\u2115 \u2192 set \u03b1}:\n  (@monotone \u2115 (set \u03b1) _ (order_dual.preorder (set \u03b1)) f) \u2194 (\u2200 (n:\u2115), f (n.succ) \u2286 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 \u03b1) (order_dual.preorder (set \u03b1)),\n    intros n,\n    apply h_mono_nat },\nend\n\nlemma directed_superset_of_monotone_nat_dual {\u03b1:Type*} {f:\u2115 \u2192 set \u03b1}:\n  (\u2200 (n:\u2115), f (n.succ) \u2286 f n) \u2192 (directed superset f) := begin\n  rw \u2190 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 {\u03b1:Type*} {f:\u2115 \u2192 set \u03b1}:\n  monotone f \u2192 (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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\n-/\nimport data.multiset.nodup\n\n/-!\n# The cartesian product of multisets\n-/\n\nnamespace multiset\n\nsection pi\nvariables {\u03b1 : Type*}\nopen function\n\n/-- Given `\u03b4 : \u03b1 \u2192 Type*`, `pi.empty \u03b4` is the trivial dependent function out of the empty\nmultiset. -/\ndef pi.empty (\u03b4 : \u03b1 \u2192 Type*) : (\u03a0a\u2208(0:multiset \u03b1), \u03b4 a) .\n\nvariables [decidable_eq \u03b1] {\u03b4 : \u03b1 \u2192 Type*}\n\n/-- Given `\u03b4 : \u03b1 \u2192 Type*`, a multiset `m` and a term `a`, as well as a term `b : \u03b4 a` and a\nfunction `f` such that `f a' : \u03b4 a'` for all `a'` in `m`, `pi.cons m a b f` is a function `g` such\nthat `g a'' : \u03b4 a''` for all `a''` in `a ::\u2098 m`. -/\ndef pi.cons (m : multiset \u03b1) (a : \u03b1) (b : \u03b4 a) (f : \u03a0a\u2208m, \u03b4 a) : \u03a0a'\u2208a ::\u2098 m, \u03b4 a' :=\n\u03bba' 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 \u03b1} {a : \u03b1} {b : \u03b4 a} {f : \u03a0a\u2208m, \u03b4 a} (h : a \u2208 a ::\u2098 m) :\n  pi.cons m a b f a h = b :=\ndif_pos rfl\n\nlemma pi.cons_ne {m : multiset \u03b1} {a a' : \u03b1} {b : \u03b4 a} {f : \u03a0a\u2208m, \u03b4 a}\n  (h' : a' \u2208 a ::\u2098 m) (h : a' \u2260 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' : \u03b1} {b : \u03b4 a} {b' : \u03b4 a'} {m : multiset \u03b1} {f : \u03a0a\u2208m, \u03b4 a} (h : a \u2260 a') :\n  pi.cons (a' ::\u2098 m) a b (pi.cons m a' b' f) == pi.cons (a ::\u2098 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]) (\u03bb ha\u2081 ha\u2082 _, _),\n  rcases ne_or_eq a'' a with h\u2081 | rfl,\n  rcases eq_or_ne a'' a' with rfl | h\u2082,\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 \u03b1) (t : \u03a0a, multiset (\u03b4 a)) : multiset (\u03a0a\u2208m, \u03b4 a) :=\nm.rec_on {pi.empty \u03b4} (\u03bba m (p : multiset (\u03a0a\u2208m, \u03b4 a)), (t a).bind $ \u03bbb, 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 : \u03a0a, multiset (\u03b4 a)) : pi 0 t = {pi.empty \u03b4} := rfl\n\n@[simp] lemma pi_cons (m : multiset \u03b1) (t : \u03a0a, multiset (\u03b4 a)) (a : \u03b1) :\n  pi (a ::\u2098 m) t = ((t a).bind $ \u03bbb, (pi m t).map $ pi.cons m a b) :=\nrec_on_cons a m\n\nlemma pi_cons_injective {a : \u03b1} {b : \u03b4 a} {s : multiset \u03b1} (hs : a \u2209 s) :\n  function.injective (pi.cons s a b) :=\nassume f\u2081 f\u2082 eq, funext $ assume a', funext $ assume h',\nhave ne : a \u2260 a', from assume h, hs $ h.symm \u25b8 h',\nhave a' \u2208 a ::\u2098 s, from mem_cons_of_mem h',\ncalc f\u2081 a' h' = pi.cons s a b f\u2081 a' this : by rw [pi.cons_ne this ne.symm]\n  ... = pi.cons s a b f\u2082 a' this : by rw [eq]\n  ... = f\u2082 a' h' : by rw [pi.cons_ne this ne.symm]\n\nlemma card_pi (m : multiset \u03b1) (t : \u03a0a, multiset (\u03b4 a)) :\n  card (pi m t) = prod (m.map $ \u03bba, card (t a)) :=\nmultiset.induction_on m (by simp) (by simp [mul_comm] {contextual := tt})\n\nprotected lemma nodup.pi {s : multiset \u03b1} {t : \u03a0 a, multiset (\u03b4 a)} :\n  nodup s \u2192 (\u2200a\u2208s, nodup (t a)) \u2192 nodup (pi s t) :=\nmultiset.induction_on s (assume _ _, nodup_singleton _)\nbegin\n  assume a s ih hs ht,\n  have has : a \u2209 s, by simp at hs; exact hs.1,\n  have hs : nodup s, by simp at hs; exact hs.2,\n  simp,\n  refine \u27e8\u03bb b hb, (ih hs $ \u03bb a' h', ht a' $ mem_cons_of_mem h').map (pi_cons_injective has), _\u27e9,\n  refine (ht a $ mem_cons_self _ _).pairwise _,\n  from assume b\u2081 hb\u2081 b\u2082 hb\u2082 neb, disjoint_map_map.2 (assume f hf g hg eq,\n    have pi.cons s a b\u2081 f a (mem_cons_self _ _) = pi.cons s a b\u2082 g a (mem_cons_self _ _),\n      by rw [eq],\n    neb $ show b\u2081 = b\u2082, by rwa [pi.cons_same, pi.cons_same] at this)\nend\n\n@[simp]\nlemma pi.cons_ext {m : multiset \u03b1} {a : \u03b1} (f : \u03a0 a' \u2208 a ::\u2098 m, \u03b4 a') :\n  pi.cons m a (f _ (mem_cons_self _ _)) (\u03bb 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 \u03b1) (t : \u03a0a, multiset (\u03b4 a)) :\n  \u2200f:\u03a0a\u2208m, \u03b4 a, (f \u2208 pi m t) \u2194 (\u2200a (h : a \u2208 m), f a h \u2208 t a) :=\nbegin\n  intro f,\n  induction m using multiset.induction_on with a m ih,\n  { simpa using show f = pi.empty \u03b4, by funext a ha; exact ha.elim },\n  simp_rw [pi_cons, mem_bind, mem_map, ih],\n  split,\n  { rintro \u27e8b, hb, f', hf', rfl\u27e9 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 \u27e8_, hf a (mem_cons_self _ _), _, \u03bb a ha, hf a (mem_cons_of_mem ha), _\u27e9,\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 (\u03b1 : Type*) extends fintype \u03b1, linear_order \u03b1 :=\n(nonempty : nonempty \u03b1 . tactic.apply_instance)\n\nattribute [instance] nonempty_fin_lin_ord.nonempty\n\n@[priority 100]\ninstance nonempty_fin_lin_ord.to_bounded_order (\u03b1 : Type*) [nonempty_fin_lin_ord \u03b1] :\n  bounded_order \u03b1 :=\nfintype.to_bounded_order \u03b1\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 : \u2115) : nonempty_fin_lin_ord (fin (n+1)) :=\n{ .. fin.fintype _,\n  .. fin.linear_order }\n\ninstance ulift.nonempty_fin_lin_ord (\u03b1 : Type u) [nonempty_fin_lin_ord \u03b1] :\n  nonempty_fin_lin_ord (ulift.{v} \u03b1) :=\n{ nonempty := \u27e8ulift.up \u22a5\u27e9,\n  .. linear_order.lift equiv.ulift (equiv.injective _),\n  .. ulift.fintype _ }\n\ninstance (\u03b1 : Type*) [nonempty_fin_lin_ord \u03b1] : nonempty_fin_lin_ord (order_dual \u03b1) :=\n{ ..order_dual.fintype \u03b1 }\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 := \u27e8\u27e9\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 (\u03b1 : Type*) [nonempty_fin_lin_ord \u03b1] : NonemptyFinLinOrd := bundled.of \u03b1\n\n@[simp] lemma coe_of (\u03b1 : Type*) [nonempty_fin_lin_ord \u03b1] : \u21a5(of \u03b1) = \u03b1 := rfl\n\ninstance : inhabited NonemptyFinLinOrd := \u27e8of punit\u27e9\n\ninstance (\u03b1 : NonemptyFinLinOrd) : nonempty_fin_lin_ord \u03b1 := \u03b1.str\n\ninstance has_forget_to_LinearOrder : has_forget\u2082 NonemptyFinLinOrd LinearOrder :=\nbundled_hom.forget\u2082 _ _\n\n/-- Constructs an equivalence between nonempty finite linear orders from an order isomorphism\nbetween them. -/\n@[simps] def iso.mk {\u03b1 \u03b2 : NonemptyFinLinOrd.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2 :=\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 \u2964 NonemptyFinLinOrd :=\n{ obj := \u03bb X, of (order_dual X), map := \u03bb 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 \u224c NonemptyFinLinOrd :=\nequivalence.mk dual dual\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n\nend NonemptyFinLinOrd\n\nlemma NonemptyFinLinOrd_dual_comp_forget_to_LinearOrder :\n  NonemptyFinLinOrd.dual \u22d9 forget\u2082 NonemptyFinLinOrd LinearOrder =\n    forget\u2082 NonemptyFinLinOrd LinearOrder \u22d9 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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl Dillies, Bhavik Mehta\n-/\nimport .mathlib\n\n/-!\n# Constructions of `finpartition`\n-/\n\nopen finpartition finset\n\nvariables {\u03b1 : Type*}\n\nsection\nvariables [decidable_eq \u03b1] {s : finset \u03b1}\n\nlemma equitabilise_aux1' {m a b : \u2115} (hs : a*m + b*(m+1) = s.card) (A : finpartition s)\n  (h : s = \u2205) :\n  \u2203 (P : finpartition s),\n    (\u2200 (x : finset \u03b1), x \u2208 P.parts \u2192 x.card = m \u2228 x.card = m + 1) \u2227\n    (\u2200 x, x \u2208 A.parts \u2192 (x \\ finset.bUnion (P.parts.filter (\u03bb y, y \u2286 x)) id).card \u2264 m) \u2227\n    ((P.parts.filter (\u03bb i, finset.card i = m+1)).card = b) :=\nbegin\n  subst h,\n  rw unique.eq_default A,\n  refine \u27e8finpartition.empty _, by simp, by simp, _\u27e9,\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 : \u2115} (hs : a*m + b*(m+1) = s.card) (A : finset (finset \u03b1))\n  (subs : \u2200 i \u2208 A, i \u2286 s) (h : m = 0) :\n  \u2203 (P : finpartition s),\n    (\u2200 (x : finset \u03b1), x \u2208 P.parts \u2192 x.card = m \u2228 x.card = m+1) \u2227\n    (\u2200 x, x \u2208 A \u2192 (x \\ finset.bUnion (P.parts.filter (\u03bb y, y \u2286 x)) id).card \u2264 m) \u2227\n    ((P.parts.filter (\u03bb 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 \u27e8\u22a5, by simp, \u03bb x hx i hi, _, _\u27e9,\n  { simp only [mem_bUnion, exists_prop, mem_filter, id.def, and_assoc],\n    exact \u27e8{i}, mem_map_of_mem _ (subs x hx hi), by simpa, by simp\u27e9 },\n  { rw [filter_true_of_mem, card_bot, hs],\n    simp }\nend\n\nlemma equitabilise_aux' {m a b : \u2115} (hs : a*m + b*(m+1) = s.card) (A : finpartition s) :\n  \u2203 (P : finpartition s),\n    (\u2200 (x : finset \u03b1), x \u2208 P.parts \u2192 x.card = m \u2228 x.card = m + 1) \u2227\n    (\u2200 x, x \u2208 A.parts \u2192 (x \\ finset.bUnion (P.parts.filter (\u03bb y, y \u2286 x)) id).card \u2264 m) \u2227\n    ((P.parts.filter (\u03bb 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 _ (\u03bb i hi, A.le hi) h },\n  have : 0 < a \u2228 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 \u2203 p \u2208 A.parts, m+1 \u2264 finset.card p,\n  { rcases h with \u27e8p, hp\u2081, hp\u2082\u27e9,\n    have : p'_size \u2264 p.card,\n    { apply le_trans _ hp\u2082,\n      rw h',\n      split_ifs,\n      { apply nat.le_succ },\n      refl },\n    obtain \u27e8p', hp'\u2081, hp'\u2082\u27e9 := 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'\u2081.trans (A.le hp\u2081)), \u2190hs, hp'\u2082, 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, \u2190nat.add_sub_assoc],\n        apply nat.le_mul_of_pos_left (\u20390 < a \u2228 0 < b\u203a.resolve_left h) } },\n    have : p'.nonempty,\n    { rwa [\u2190card_pos, hp'\u2082] },\n    obtain \u27e8P', hP'\u2081, hP'\u2082, hP'\u2083\u27e9 :=\n      @ih (s \\ p') (sdiff_ssubset (hp'\u2081.trans (A.le hp\u2081)) 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 \u27e8P'.extend this.ne_empty sdiff_disjoint (sdiff_sup_cancel $ hp'\u2081.trans $ A.le hp\u2081),\n      _,  _, _\u27e9,\n    { simp only [mem_insert, forall_eq_or_imp, extend_parts, and_iff_left hP'\u2081, hp'\u2082, h'],\n      apply ite_eq_or_eq },\n    { conv in (_ \u2208 _) {rw \u2190finset.insert_erase hp\u2081},\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'\u2081, 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'\u2082 (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\u2081 hi\u2082 hi\u2083,\n          exact \u27e8\u27e8hi\u2081, hi\u2082\u27e9, \u03bb x hx hx', hi\u2083 _ hx (finset.subset.trans hx' (sdiff_subset _ _))\u27e9 },\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 \u27e8\u03bb i, h (i.antisymm hp'\u2081), _, hp\u2081, rfl\u27e9 }},\n      intros x hx,\n      apply (card_le_of_subset _).trans (hP'\u2082 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 \u27e8(nonempty_of_mem_parts _ (mem_of_mem_erase hx)).ne_empty, _,\n          mem_of_mem_erase hx, _\u27e9,\n        rw finset.sdiff_eq_self_iff_disjoint,\n        refine disjoint.mono_right hp'\u2081 _,\n        apply A.disjoint (mem_of_mem_erase hx) hp\u2081 (ne_of_mem_erase hx) } },\n    simp only [extend_parts, filter_insert, hp'\u2082, 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'\u2083, if_neg h, nat.sub_add_cancel],\n      apply \u20390 < a \u2228 0 < b\u203a.resolve_left h,\n      simp only [mem_filter, hp'\u2082, h', if_neg h, eq_self_iff_true, and_true],\n      intro t,\n      obtain \u27e8i, hi\u27e9 := \u2039p'.nonempty\u203a,\n      apply (mem_sdiff.1 (P'.le t hi)).2 hi },\n    { rw [hP'\u2083, if_pos],\n      simpa using h } },\n  push_neg at h,\n  have : p'_size \u2264 s.card,\n  { rw [\u2190hs, h'],\n    split_ifs,\n    { apply le_add_right (nat.le_mul_of_pos_left \u20390 < a\u203a) },\n    exact le_add_left (nat.le_mul_of_pos_left (\u20390 < a \u2228 0 < b\u203a.resolve_left \u2039\u00ac0 < a\u203a)) },\n  obtain \u27e8s', hs'\u2081, hs'\u2082\u27e9 := exists_smaller_set _ _ this,\n  have hs' : s'.nonempty,\n  { rwa [\u2190card_pos, hs'\u2082] },\n  have : ite (0 < a) (a - 1) a * m + ite (0 < a) b (b - 1) * (m + 1) = (s \\ s').card,\n  { rw [card_sdiff \u2039s' \u2286 s\u203a, hs'\u2082, h', \u2190hs],\n    split_ifs,\n    { rw [nat.mul_sub_right_distrib, one_mul,\n        tsub_add_eq_add_tsub (nat.le_mul_of_pos_left \u20390 < a\u203a)] },\n    rw [nat.mul_sub_right_distrib, one_mul, \u2190nat.add_sub_assoc],\n    exact nat.le_mul_of_pos_left (\u20390 < a \u2228 0 < b\u203a.resolve_left \u2039\u00ac0 < a\u203a) },\n  obtain \u27e8P', hP'\u2081, hP'\u2082, hP'\u2083\u27e9 := @ih (s \\ s') (sdiff_ssubset hs'\u2081 \u2039s'.nonempty\u203a) (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 \u27e8P'.extend hs'.ne_empty sdiff_disjoint (sdiff_sup_cancel hs'\u2081), _, _, _\u27e9,\n  { simp only [extend_parts, mem_insert, forall_eq_or_imp, and_iff_left hP'\u2081, hs'\u2082, h'],\n    apply ite_eq_or_eq },\n  { intros x hx,\n    refine le_trans (card_le_of_subset (sdiff_subset _ _)) _,\n    rw \u2190nat.lt_succ_iff,\n    exact h _ hx },\n  rw [extend_parts, filter_insert, hs'\u2082, 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'\u2083, if_neg h_1, nat.sub_add_cancel],\n    { apply \u20390 < a \u2228 0 < b\u203a.resolve_left h_1 },\n    simp only [mem_filter, hs'\u2082, h', if_neg h_1, eq_self_iff_true, and_true],\n    intro t,\n    obtain \u27e8i, hi\u27e9 := \u2039s'.nonempty\u203a,\n    exact (mem_sdiff.1 (P'.le t hi)).2 hi },\n  { rw [hP'\u2083, 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 : \u2115} (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 : \u2115}\n  (h : a*m + b*(m+1) = s.card) {u : finset \u03b1} (hu : u \u2208 (Q.equitabilise h).parts) :\n  u.card = m \u2228 u.card = m + 1 :=\n(equitabilise_aux' h Q).some_spec.1 _ hu\n\nlemma equitabilise.is_equipartition (Q : finpartition s) {m a b : \u2115}\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 \u27e8m, \u03bb u hu, card_eq_of_mem_parts_equitabilise h hu\u27e9\n\nlemma card_filter_equitabilise_big (Q : finpartition s) {m a b : \u2115}\n  (h : a*m + b*(m+1) = s.card) :\n  ((Q.equitabilise h).parts.filter (\u03bb u : finset \u03b1, 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 : \u2115} (hm : 0 < m)\n  (h : a*m + b*(m+1) = s.card) :\n  ((Q.equitabilise h).parts.filter (\u03bb u : finset \u03b1, 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, \u2190(Q.equitabilise h).sum_card_parts],\n  have hunion : (Q.equitabilise h).parts = (Q.equitabilise h).parts.filter (\u03bb u, u.card = m) \u222a\n    (Q.equitabilise h).parts.filter (\u03bb u, u.card = m + 1),\n  { rw [\u2190filter_or, filter_true_of_mem],\n    exact \u03bb x hx, card_eq_of_mem_parts_equitabilise h hx },\n  nth_rewrite 1 hunion,\n  rw [sum_union, sum_const_nat (\u03bb x hx, (mem_filter.1 hx).2),\n    sum_const_nat (\u03bb x hx, (mem_filter.1 hx).2), Q.card_filter_equitabilise_big],\n  refine \u03bb 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, \u2190hx.2.2, hx.1.2],\nend\n\nlemma equitabilise.parts_card {Q : finpartition s} {m a b : \u2115} (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 (\u03bb u, u.card = m) \u222a\n    (Q.equitabilise h).parts.filter (\u03bb u, u.card = m + 1),\n  { rw [\u2190filter_or, filter_true_of_mem],\n    exact \u03bb 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 \u03bb 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, \u2190hx.2.2, hx.1.2],\nend\n\nlemma almost_in_atoms_of_mem_parts_equitabilise {Q : finpartition s} {m a b : \u2115}\n  (h : a * m + b * (m + 1) = s.card) {u : finset \u03b1} (hu : u \u2208 Q.parts) :\n  (u \\ ((Q.equitabilise h).parts.filter $ \u03bb x, x \u2286 u).bUnion id).card \u2264 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 \u03bb hxu hx, \u27e8hxu, \u03bb a ha hau, _\u27e9,\n  obtain rfl | hanemp := eq_or_ne a \u2205,\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 \u03b1] {s : finset \u03b1}\n\nlemma union_of_atoms_aux {s : finset \u03b1} {Q : finset (finset \u03b1)} {A : finset \u03b1}\n  (hA : A \u2208 Q) (hs : A \u2286 s) (i : \u03b1) :\n  (\u2203 (B \u2208 (atomise s Q).parts), B \u2286 A \u2227 i \u2208 B) \u2194 i \u2208 A :=\nbegin\n  split,\n  { rintro \u27e8B, hB\u2081, hB\u2082, hB\u2083\u27e9,\n    exact hB\u2082 hB\u2083 },\n  intro hi,\n  obtain \u27e8B, hB\u2081, hB\u2082\u27e9 := (atomise s Q).exists_mem (hs hi),\n  refine \u27e8B, hB\u2081, \u03bb j hj, _, hB\u2082\u27e9,\n  obtain \u27e8P, hP, rfl\u27e9 := (mem_atomise.1 hB\u2081).2,\n  simp only [mem_filter] at hB\u2082 hj,\n  rwa [\u2190hj.2 _ hA, hB\u2082.2 _ hA]\nend\n\nopen_locale classical\n\nlemma union_of_atoms' {s : finset \u03b1} {Q : finset (finset \u03b1)} (A : finset \u03b1)\n  (hx : A \u2208 Q) (hs : A \u2286 s) :\n  ((atomise s Q).parts.filter (\u03bb B, B \u2286 A \u2227 B.nonempty)).bUnion id = A :=\nbegin\n  ext x,\n  simp only [mem_bUnion, exists_prop, mem_filter, id.def, and_assoc],\n  rw \u2190union_of_atoms_aux hx hs,\n  simp only [exists_prop, finset.nonempty],\n  tauto,\nend\n\nlemma partial_atomise {s : finset \u03b1} {Q : finset (finset \u03b1)} (A : finset \u03b1) (hA : A \u2208 Q) :\n  ((atomise s Q).parts.filter (\u03bb B, B \u2286 A \u2227 B.nonempty)).card \u2264 2^(Q.card - 1) :=\nbegin\n  suffices h :\n    (atomise s Q).parts.filter (\u03bb B, B \u2286 A \u2227 B.nonempty) \u2286\n      (Q.erase A).powerset.image (\u03bb P, s.filter (\u03bb i, \u2200 x \u2208 Q, x \u2208 insert A P \u2194 i \u2208 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\u2082],\n  rintro P' i hi P PQ rfl hy\u2082 j hj,\n  refine \u27e8P.erase A, erase_subset_erase _ PQ, _\u27e9,\n  have : A \u2208 P,\n  { rw mem_filter at hi,\n    rw hi.2 _ hA,\n    apply hy\u2082 (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 \u03b1] (s : finset \u03b1) {t : \u2115} (ht : 0 < t) (hs : t \u2264 s.card) :\n  \u2203 (P : finpartition s), P.is_equipartition \u2227 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, \u2190add_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 \u27e8(finpartition.indiscrete (finset.card_pos.1 $ ht.trans_le hs).ne_empty).equitabilise this,\n    equitabilise.is_equipartition _ _, _\u27e9,\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\u2081 P\u2082` (notation: `P\u2081 \u2243\u1d43[k] P\u2082`) to be the type of affine\nequivalences between `P\u2081` and `P\u2082`, 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\u2081 P\u2082 : Type _) {V\u2081 V\u2082 : Type _} [Ring k] [AddCommGroup V\u2081] [Module k V\u2081]\n  [AddTorsor V\u2081 P\u2081] [AddCommGroup V\u2082] [Module k V\u2082] [AddTorsor V\u2082 P\u2082] extends P\u2081 \u2243 P\u2082 where\n  linear : V\u2081 \u2243\u2097[k] V\u2082\n  map_vadd' : \u2200 (p : P\u2081) (v : V\u2081), toEquiv (v +\u1d65 p) = linear v +\u1d65 toEquiv p\n#align affine_equiv AffineEquiv\n\nnotation:25 P\u2081 \" \u2243\u1d43[\" k:25 \"] \" P\u2082:0 => AffineEquiv k P\u2081 P\u2082\n\nvariable {k P\u2081 P\u2082 P\u2083 P\u2084 V\u2081 V\u2082 V\u2083 V\u2084 : Type _} [Ring k] [AddCommGroup V\u2081] [Module k V\u2081]\n  [AddTorsor V\u2081 P\u2081] [AddCommGroup V\u2082] [Module k V\u2082] [AddTorsor V\u2082 P\u2082] [AddCommGroup V\u2083]\n  [Module k V\u2083] [AddTorsor V\u2083 P\u2083] [AddCommGroup V\u2084] [Module k V\u2084] [AddTorsor V\u2084 P\u2084]\n\nnamespace AffineEquiv\n\n/-- Reinterpret an `AffineEquiv` as an `AffineMap`. -/\n@[coe]\ndef toAffineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192\u1d43[k] P\u2082 :=\n  { e with }\n#align affine_equiv.to_affine_map AffineEquiv.toAffineMap\n\n@[simp]\ntheorem toAffineMap_mk (f : P\u2081 \u2243 P\u2082) (f' : V\u2081 \u2243\u2097[k] V\u2082) (h) :\n    toAffineMap (mk f f' h) = \u27e8f, f', h\u27e9 :=\n  rfl\n#align affine_equiv.to_affine_map_mk AffineEquiv.toAffineMap_mk\n\n@[simp]\ntheorem linear_toAffineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 \u2243\u1d43[k] P\u2082) \u2192 P\u2081 \u2192\u1d43[k] P\u2082) := by\n  rintro \u27e8e, el, h\u27e9 \u27e8e', el', h'\u27e9 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\u2081 \u2243\u1d43[k] P\u2082} : e.toAffineMap = e'.toAffineMap \u2194 e = e' :=\n  toAffineMap_injective.eq_iff\n#align affine_equiv.to_affine_map_inj AffineEquiv.toAffineMap_inj\n\ninstance equivLike : EquivLike (P\u2081 \u2243\u1d43[k] P\u2082) P\u2081 P\u2082 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\u2081 \u2243\u1d43[k] P\u2082) fun _ => P\u2081 \u2192 P\u2082 :=\n  FunLike.hasCoeToFun\n\n@[nolint dangerousInstance] -- Porting note: this was not a problem in Lean 3\ninstance : Coe (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2243 P\u2082) :=\n  \u27e8AffineEquiv.toEquiv\u27e9\n\n@[simp]\ntheorem map_vadd (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2081) (v : V\u2081) : e (v +\u1d65 p) = e.linear v +\u1d65 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\u2081 \u2243\u1d43[k] P\u2082) : \u21d1e.toEquiv = e :=\n  rfl\n#align affine_equiv.coe_to_equiv AffineEquiv.coe_toEquiv\n\ninstance : Coe (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2192\u1d43[k] P\u2082) :=\n  \u27e8toAffineMap\u27e9\n\n@[simp]\ntheorem coe_toAffineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) : (e.toAffineMap : P\u2081 \u2192 P\u2082) = (e : P\u2081 \u2192 P\u2082) :=\n  rfl\n#align affine_equiv.coe_to_affine_map AffineEquiv.coe_toAffineMap\n\n@[norm_cast, simp]\ntheorem coe_coe (e : P\u2081 \u2243\u1d43[k] P\u2082) : ((e : P\u2081 \u2192\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082) = e :=\n  rfl\n#align affine_equiv.coe_coe AffineEquiv.coe_coe\n\n@[simp]\ntheorem coe_linear (e : P\u2081 \u2243\u1d43[k] P\u2082) : (e : P\u2081 \u2192\u1d43[k] P\u2082).linear = e.linear :=\n  rfl\n#align affine_equiv.coe_linear AffineEquiv.coe_linear\n\n@[ext]\ntheorem ext {e e' : P\u2081 \u2243\u1d43[k] P\u2082} (h : \u2200 x, e x = e' x) : e = e' :=\n  FunLike.ext _ _ h\n#align affine_equiv.ext AffineEquiv.ext\n\ntheorem coeFn_injective : @Injective (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2192 P\u2082) (\u21d1) :=\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\u2081 \u2243\u1d43[k] P\u2082} : (e : P\u2081 \u2192 P\u2082) = e' \u2194 e = e' :=\n  coeFn_injective.eq_iff\n#align affine_equiv.coe_fn_inj AffineEquiv.coeFn_inj\n\ntheorem toEquiv_injective : Injective (toEquiv : (P\u2081 \u2243\u1d43[k] P\u2082) \u2192 P\u2081 \u2243 P\u2082) := 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\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (h) : ((\u27e8e, e', h\u27e9 : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082) = 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\u2081 \u2192 P\u2082`, a linear equivalence\n`e' : V\u2081 \u2243\u2097[k] V\u2082`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -\u1d65 p) +\u1d65 e p`. -/\ndef mk' (e : P\u2081 \u2192 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (p : P\u2081) (h : \u2200 p' : P\u2081, e p' = e' (p' -\u1d65 p) +\u1d65 e p) :\n    P\u2081 \u2243\u1d43[k] P\u2082 where\n  toFun := e\n  invFun := fun q' : P\u2082 => e'.symm (q' -\u1d65 e p) +\u1d65 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' -\u1d65 e p) +\u1d65 p), (vadd_vsub), (vsub_vadd)]\n  linear := e'\n  -- Porting note: `simp` needs `()`\n  map_vadd' p' v := by simp [h p', h (v +\u1d65 p'), (vadd_vsub_assoc), (vadd_vadd)]\n#align affine_equiv.mk' AffineEquiv.mk'\n\n@[simp]\ntheorem coe_mk' (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (p h) : \u21d1(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\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (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\u2081 \u2243\u1d43[k] P\u2082) : P\u2082 \u2243\u1d43[k] P\u2081 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\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082 :=\n  e\n#align affine_equiv.simps.apply AffineEquiv.Simps.apply\n\n/-- See Note [custom simps projection] -/\ndef Simps.symmApply (e : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2082 \u2192 P\u2081 :=\n  e.symm\n#align affine_equiv.simps.symm_apply AffineEquiv.Simps.symmApply\n\ninitialize_simps_projections AffineEquiv (toEquiv_toFun \u2192 apply, toEquiv_invFun \u2192 symmApply,\n  linear \u2192 linear, as_prefix linear, -toEquiv)\n\nprotected theorem bijective (e : P\u2081 \u2243\u1d43[k] P\u2082) : Bijective e :=\n  e.toEquiv.bijective\n#align affine_equiv.bijective AffineEquiv.bijective\n\nprotected theorem surjective (e : P\u2081 \u2243\u1d43[k] P\u2082) : Surjective e :=\n  e.toEquiv.surjective\n#align affine_equiv.surjective AffineEquiv.surjective\n\nprotected theorem injective (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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 {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} (h\u03c6 : Function.Bijective \u03c6) : P\u2081 \u2243\u1d43[k] P\u2082 :=\n  { Equiv.ofBijective _ h\u03c6 with\n    linear := LinearEquiv.ofBijective \u03c6.linear (\u03c6.linear_bijective_iff.mpr h\u03c6)\n    map_vadd' := \u03c6.map_vadd }\n#align affine_equiv.of_bijective AffineEquiv.ofBijective\n\ntheorem ofBijective.symm_eq {\u03c6 : P\u2081 \u2192\u1d43[k] P\u2082} (h\u03c6 : Function.Bijective \u03c6) :\n    (ofBijective h\u03c6).symm.toEquiv = (Equiv.ofBijective _ h\u03c6).symm :=\n  rfl\n#align affine_equiv.of_bijective.symm_eq AffineEquiv.ofBijective.symm_eq\n\n@[simp]\ntheorem range_eq (e : P\u2081 \u2243\u1d43[k] P\u2082) : 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\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2082) : 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\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2081) : 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\u2081 \u2243\u1d43[k] P\u2082) {p\u2081 p\u2082} : e p\u2081 = p\u2082 \u2194 p\u2081 = e.symm p\u2082 :=\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\u2081 \u2243\u1d43[k] P\u2082) {p\u2081 p\u2082 : P\u2081} : e p\u2081 = e p\u2082 \u2194 p\u2081 = p\u2082 :=\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\u2081 \u2243\u1d43[k] P\u2082) (s : Set P\u2082) : f.symm '' s = f \u207b\u00b9' 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\u2081 \u2243\u1d43[k] P\u2082) (s : Set P\u2081) : f.symm \u207b\u00b9' s = f '' s :=\n  (f.symm.image_symm _).symm\n#align affine_equiv.preimage_symm AffineEquiv.preimage_symm\n\nvariable (k P\u2081)\n\n/-- Identity map as an `AffineEquiv`. -/\n-- @[refl] -- Porting note: removed attribute\ndef refl : P\u2081 \u2243\u1d43[k] P\u2081 where\n  toEquiv := Equiv.refl P\u2081\n  linear := LinearEquiv.refl k V\u2081\n  map_vadd' _ _ := rfl\n#align affine_equiv.refl AffineEquiv.refl\n\n@[simp]\ntheorem coe_refl : \u21d1(refl k P\u2081) = id :=\n  rfl\n#align affine_equiv.coe_refl AffineEquiv.coe_refl\n\n@[simp]\ntheorem coe_refl_to_affineMap : \u2191(refl k P\u2081) = AffineMap.id k P\u2081 :=\n  rfl\n#align affine_equiv.coe_refl_to_affine_map AffineEquiv.coe_refl_to_affineMap\n\n@[simp]\ntheorem refl_apply (x : P\u2081) : refl k P\u2081 x = x :=\n  rfl\n#align affine_equiv.refl_apply AffineEquiv.refl_apply\n\n@[simp]\ntheorem toEquiv_refl : (refl k P\u2081).toEquiv = Equiv.refl P\u2081 :=\n  rfl\n#align affine_equiv.to_equiv_refl AffineEquiv.toEquiv_refl\n\n@[simp]\ntheorem linear_refl : (refl k P\u2081).linear = LinearEquiv.refl k V\u2081 :=\n  rfl\n#align affine_equiv.linear_refl AffineEquiv.linear_refl\n\n@[simp]\ntheorem symm_refl : (refl k P\u2081).symm = refl k P\u2081 :=\n  rfl\n#align affine_equiv.symm_refl AffineEquiv.symm_refl\n\nvariable {k P\u2081}\n\n/-- Composition of two `AffineEquiv`alences, applied left to right. -/\n@[trans]\ndef trans (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) : P\u2081 \u2243\u1d43[k] P\u2083 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), (\u00b7 \u2218 \u00b7), Equiv.coe_trans, (map_vadd)]\n#align affine_equiv.trans AffineEquiv.trans\n\n@[simp]\ntheorem coe_trans (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) : \u21d1(e.trans e') = e' \u2218 e :=\n  rfl\n#align affine_equiv.coe_trans AffineEquiv.coe_trans\n\n@[simp]\ntheorem coe_trans_to_affineMap (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) :\n    (e.trans e' : P\u2081 \u2192\u1d43[k] P\u2083) = (e' : P\u2082 \u2192\u1d43[k] P\u2083).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\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) (p : P\u2081) : e.trans e' p = e' (e p) :=\n  rfl\n#align affine_equiv.trans_apply AffineEquiv.trans_apply\n\ntheorem trans_assoc (e\u2081 : P\u2081 \u2243\u1d43[k] P\u2082) (e\u2082 : P\u2082 \u2243\u1d43[k] P\u2083) (e\u2083 : P\u2083 \u2243\u1d43[k] P\u2084) :\n    (e\u2081.trans e\u2082).trans e\u2083 = e\u2081.trans (e\u2082.trans e\u2083) :=\n  ext fun _ => rfl\n#align affine_equiv.trans_assoc AffineEquiv.trans_assoc\n\n@[simp]\ntheorem trans_refl (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.trans (refl k P\u2082) = e :=\n  ext fun _ => rfl\n#align affine_equiv.trans_refl AffineEquiv.trans_refl\n\n@[simp]\ntheorem refl_trans (e : P\u2081 \u2243\u1d43[k] P\u2082) : (refl k P\u2081).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\u2081 \u2243\u1d43[k] P\u2082) : e.trans e.symm = refl k P\u2081 :=\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\u2081 \u2243\u1d43[k] P\u2082) : e.symm.trans e = refl k P\u2082 :=\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\u2081 \u2243\u1d43[k] P\u2082) (a b : P\u2081) (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\u2081 \u2243\u1d43[k] P\u2081) where\n  one := refl k P\u2081\n  mul e e' := e'.trans e\n  inv := symm\n  mul_assoc e\u2081 e\u2082 e\u2083 := 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\u2081 \u2243\u1d43[k] P\u2081) = refl k P\u2081 :=\n  rfl\n#align affine_equiv.one_def AffineEquiv.one_def\n\n@[simp]\ntheorem coe_one : \u21d1(1 : P\u2081 \u2243\u1d43[k] P\u2081) = id :=\n  rfl\n#align affine_equiv.coe_one AffineEquiv.coe_one\n\ntheorem mul_def (e e' : P\u2081 \u2243\u1d43[k] P\u2081) : 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\u2081 \u2243\u1d43[k] P\u2081) : \u21d1(e * e') = e \u2218 e' :=\n  rfl\n#align affine_equiv.coe_mul AffineEquiv.coe_mul\n\ntheorem inv_def (e : P\u2081 \u2243\u1d43[k] P\u2081) : e\u207b\u00b9 = 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\u2081 \u2243\u1d43[k] P\u2081) \u2192* V\u2081 \u2243\u2097[k] V\u2081 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\u2081 \u2243\u1d43[k] P\u2081) \u2243* (P\u2081 \u2192\u1d43[k] P\u2081)\u02e3 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\u2081 \u2192\u1d43[k] P\u2081)\n      invFun := (\u2191u\u207b\u00b9 : P\u2081 \u2192\u1d43[k] P\u2081)\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\u2081 \u2192\u1d43[k] P\u2081).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 \u21a6 v +\u1d65 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\u2081) : V\u2081 \u2243\u1d43[k] P\u2081 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' \u21a6 p -\u1d65 p'` as an equivalence. -/\ndef constVSub (p : P\u2081) : P\u2081 \u2243\u1d43[k] V\u2081 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\u2081) : \u21d1(constVSub k p) = (\u00b7 -\u1d65 \u00b7) p :=\n  rfl\n#align affine_equiv.coe_const_vsub AffineEquiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P\u2081) : \u21d1(constVSub k p).symm = fun v : V\u2081 => -v +\u1d65 p :=\n  rfl\n#align affine_equiv.coe_const_vsub_symm AffineEquiv.coe_constVSub_symm\n\nvariable (P\u2081)\n\n/-- The map `p \u21a6 v +\u1d65 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 `+\u1d65` is to `\u2022`. -/\n@[simps! apply linear]\ndef constVAdd (v : V\u2081) : P\u2081 \u2243\u1d43[k] P\u2081 where\n  toEquiv := Equiv.constVAdd P\u2081 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\u2081 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\u2081) :\n    constVAdd k P\u2081 (v + w) = (constVAdd k P\u2081 w).trans (constVAdd k P\u2081 v) :=\n  ext <| add_vadd _ _\n#align affine_equiv.const_vadd_add AffineEquiv.constVAdd_add\n\n@[simp]\ntheorem constVAdd_symm (v : V\u2081) : (constVAdd k P\u2081 v).symm = constVAdd k P\u2081 (-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\u2081 \u2192* P\u2081 \u2243\u1d43[k] P\u2081 where\n  toFun v := constVAdd k P\u2081 (Multiplicative.toAdd v)\n  map_one' := constVAdd_zero _ _\n  map_mul' := constVAdd_add _ P\u2081\n#align affine_equiv.const_vadd_hom AffineEquiv.constVAddHom\n\ntheorem constVAdd_nsmul (n : \u2115) (v : V\u2081) : constVAdd k P\u2081 (n \u2022 v) = constVAdd k P\u2081 v ^ n :=\n  (constVAddHom k P\u2081).map_pow _ _\n#align affine_equiv.const_vadd_nsmul AffineEquiv.constVAdd_nsmul\n\ntheorem constVAdd_zsmul (z : \u2124) (v : V\u2081) : constVAdd k P\u2081 (z \u2022 v) = constVAdd k P\u2081 v ^ z :=\n  (constVAddHom k P\u2081).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\u02e3 \u2192* P \u2243\u1d43[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\u02e3) :\n    (homothetyUnitsMulHom p t : P \u2192 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\u02e3) :\n    ((homothetyUnitsMulHom p t).symm : P \u2192 P) = AffineMap.homothety p (\u2191t\u207b\u00b9 : 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    ((\u2191) : (P \u2243\u1d43[R] P) \u2192 P \u2192\u1d43[R] P) \u2218 homothetyUnitsMulHom p =\n      AffineMap.homothetyHom p \u2218 ((\u2191) : R\u02e3 \u2192 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\u2081}\n\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P\u2081) : P\u2081 \u2243\u1d43[k] P\u2081 :=\n  (constVSub k x).trans (vaddConst k x)\n#align affine_equiv.point_reflection AffineEquiv.pointReflection\n\ntheorem pointReflection_apply (x y : P\u2081) : pointReflection k x y = x -\u1d65 y +\u1d65 x :=\n  rfl\n#align affine_equiv.point_reflection_apply AffineEquiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_symm (x : P\u2081) : (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\u2081) :\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\u2081) : pointReflection k x x = x :=\n  vsub_vadd _ _\n#align affine_equiv.point_reflection_self AffineEquiv.pointReflection_self\n\ntheorem pointReflection_involutive (x : P\u2081) : Involutive (pointReflection k x : P\u2081 \u2192 P\u2081) :=\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 \u2194 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\u2081} (h : Injective (bit0 : V\u2081 \u2192 V\u2081)) :\n    pointReflection k x y = y \u2194 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\u2081 \u2192 V\u2081)) (y : P\u2081) :\n    Injective fun x : P\u2081 => 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    \u2200 y, Injective fun x : P\u2081 => pointReflection k x y :=\n  injective_pointReflection_left_of_injective_bit0 k fun x y h => by\n    rwa [bit0, bit0, \u2190 two_smul k x, \u2190 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\u2081} :\n    pointReflection k x y = y \u2194 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\u2081 \u2243\u2097[k] V\u2082) : V\u2081 \u2243\u1d43[k] V\u2082 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\u2081 \u2243\u2097[k] V\u2082) : \u21d1e.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\u2081) (p : P\u2081) (c : k) :\n    lineMap v v' c +\u1d65 p = lineMap (v +\u1d65 p) (v' +\u1d65 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\u2081 p\u2082 p\u2083 : P\u2081) (c : k) :\n    lineMap p\u2081 p\u2082 c -\u1d65 p\u2083 = lineMap (p\u2081 -\u1d65 p\u2083) (p\u2082 -\u1d65 p\u2083) c :=\n  (vaddConst k p\u2083).symm.apply_lineMap p\u2081 p\u2082 c\n#align affine_map.line_map_vsub AffineMap.lineMap_vsub\n\ntheorem vsub_lineMap (p\u2081 p\u2082 p\u2083 : P\u2081) (c : k) :\n    p\u2081 -\u1d65 lineMap p\u2082 p\u2083 c = lineMap (p\u2081 -\u1d65 p\u2082) (p\u2081 -\u1d65 p\u2083) c :=\n  (constVSub k p\u2081).apply_lineMap p\u2082 p\u2083 c\n#align affine_map.vsub_line_map AffineMap.vsub_lineMap\n\ntheorem vadd_lineMap (v : V\u2081) (p\u2081 p\u2082 : P\u2081) (c : k) :\n    v +\u1d65 lineMap p\u2081 p\u2082 c = lineMap (v +\u1d65 p\u2081) (v +\u1d65 p\u2082) c :=\n  (constVAdd k P\u2081 v).apply_lineMap p\u2081 p\u2082 c\n#align affine_map.vadd_line_map AffineMap.vadd_lineMap\n\nvariable {R' : Type _} [CommRing R'] [Module R' V\u2081]\n\ntheorem homothety_neg_one_apply (c p : P\u2081) : 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 (\u03b1 : Type u) where\n  one : \u03b1\n\ninstance One.toOfNat1 {\u03b1} [One \u03b1] : OfNat \u03b1 (nat_lit 1) where\n  ofNat := \u2039One \u03b1\u203a.1\n\nclass MulOneClass (M : Type u) extends One M, Mul M\n\nclass FunLike (F : Sort _) (\u03b1 : outParam (Sort _)) (\u03b2 : outParam <| \u03b1 \u2192 Sort _) where\n  coe : F \u2192 \u2200 a : \u03b1, \u03b2 a\n\ninstance (priority := 100) [FunLike F \u03b1 \u03b2] : CoeFun F fun _ => \u2200 a : \u03b1, \u03b2 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 \u2192 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 : \u2200 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 \u2192 N\n  map_mul' : \u2200 x y, toFun (x * y) = toFun x * toFun y\n\ninfixr:25 \" \u2192\u2099* \" => 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 : \u2200 (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 \u2192\u2099* N\n\ninfixr:25 \" \u2192* \" => 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 \u2192* N) :=\n  \u27e8fun f => {\n   toFun := f,\n   map_one' := map_one f,\n   map_mul' := map_mul f\n  }\u27e9\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 \u2192* N) :=\n  \u27e8fun f => {\n    toFun := f,\n    map_one' := map_one f,\n    map_mul' := map_mul f\n  }\u27e9\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 \u2113\u2081 \u2113\u2082\n\n/-! #brief A dependent list.\n-/\ninductive dlist {A : Type \u2113\u2081} (B : A \u2192 Sort \u2113\u2082) : list A \u2192 Type (max \u2113\u2081 \u2113\u2082)\n| nil : dlist []\n| cons : \u2200 (a : A) (b : B a) (aa : list A) (bb : dlist aa)\n         , dlist (a :: aa)\n\n-- notation `][` := dlist.nil _\n-- notation h ` :\u03a3: ` t  := dlist.cons _ h _ t\n\n/-! #brief Equality of dlists.\n-/\ndefinition dlist.eq {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {a : A} {aa : list A}\n         {b\u2081 b\u2082 : B a}\n         {bb\u2081 bb\u2082 : dlist B aa}\n         (\u03c9b : b\u2081 = b\u2082)\n         (\u03c9bb : bb\u2081 = bb\u2082)\n       , dlist.cons a b\u2081 aa bb\u2081 = dlist.cons a b\u2082 aa bb\u2082\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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n--     : \u2200 {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 \u2113\u2081} {B\u2081 B\u2082 : A \u2192 Sort \u2113\u2082} (f : \u2200 {a : A}, B\u2081 a \u2192 B\u2082 a)\n    : \u2200 {aa : list A}\n      , dlist B\u2081 aa \u2192 dlist B\u2082 aa\n| [] bb := dlist.nil B\u2082\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 \u2113\u2081} {B\u2081 B\u2082 B\u2083 : A \u2192 Sort \u2113\u2082}\n    (g : \u2200 {a : A}, B\u2082 a \u2192 B\u2083 a)\n    (f : \u2200 {a : A}, B\u2081 a \u2192 B\u2082 a)\n    : \u2200 {aa : list A} {bb : dlist B\u2081 aa}\n      , dlist.map @g (dlist.map @f bb) = dlist.map (\u03bb 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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {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 \u03c9) := b\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) (fin.mk (nat.succ n) \u03c9)\n:= dlist.get bb { val := n, is_lt := nat.lt_of_succ_lt_succ \u03c9 }\n\ntheorem dlist.get.simp {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    (a : A) (b : B a) (aa : list A) (bb : dlist B aa)\n    (n : \u2115) (\u03c9 : nat.succ n < list.length (a :: aa))\n    : dlist.get (dlist.cons a b aa bb) { val := nat.succ n, is_lt := \u03c9 }\n       == dlist.get bb { val := n, is_lt := nat.lt_of_succ_lt_succ \u03c9 }\n:= heq.refl _\n\n/-! #brief Congruence for dlist.get.\n-/\ntheorem dlist.congr_get {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    {aa : list A} {bb\u2081 bb\u2082 : dlist B aa}\n    (\u03c9bb : bb\u2081 = bb\u2082) (n : fin (list.length aa))\n    : dlist.get bb\u2081 n = dlist.get bb\u2082 n\n:= by rw \u03c9bb\n\n/-! #brief Getting an item out of a map.\n-/\ntheorem dlist.get_map {A : Type \u2113\u2081} {B\u2081 B\u2082 : A \u2192 Sort \u2113\u2082} (f : \u2200 {a : A}, B\u2081 a \u2192 B\u2082 a)\n    : \u2200 {aa : list A} (bb : dlist B\u2081 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 \u03c9) := rfl\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) (fin.mk (nat.succ n) \u03c9)\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 \u03c9),\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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    {a : A} {aa : list A}\n    (f : \u2200 (n : fin (list.length (a :: aa))), B (list.get (a :: aa) n))\n    : \u2200 (n : fin (list.length aa))\n      , B (list.get aa n)\n| (fin.mk n \u03c9) := f { val := nat.succ n, is_lt := nat.succ_lt_succ \u03c9 }\n\n/-! #brief Dropping on get.\n-/\ntheorem dlist.drop_get {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {a : A} {b : B a} {aa : list A} {bb : dlist B aa}\n         {n : \u2115} {\u03c9 : n < list.length aa}\n      , dlist.get (dlist.cons a b aa bb) (fin.mk (nat.succ n) (nat.succ_lt_succ \u03c9)) == dlist.get bb (fin.mk n \u03c9)\n| a b [] bb n \u03c9 := fin.zero_elim (fin.mk n \u03c9)\n| a\u2081 b\u2081 (a\u2082 :: aa) (dlist.cons .(a\u2082) b\u2082 .(aa) bb) 0 \u03c9 := heq.refl _\n| a\u2081 b\u2081 (a\u2082 :: aa) (dlist.cons .(a\u2082) b\u2082 .(aa) bb) (nat.succ n) \u03c9\n:= begin\n     refine heq.trans (dlist.get.simp _ _ _ _ _ _) _,\n     refine heq.trans (@dlist.drop_get _ _ _ _ n (nat.lt_of_succ_lt_succ \u03c9)) _,\n     apply heq.symm,\n     apply dlist.get.simp\n   end\n\n/-! #brief Inverse of dlist.get.\n-/\ndefinition dlist.enum {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa : list A}\n        (f : \u2200 (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 \u2113\u2081} {B\u2081 B\u2082 : A \u2192 Sort \u2113\u2082} (f : \u2200 {a : A}, B\u2081 a \u2192 B\u2082 a)\n    : \u2200 {aa : list A} (bb : dlist B\u2081 aa)\n        (h : \u2200 (n : fin (list.length aa)), B\u2082 (list.get aa n))\n        (\u03c9h : \u2200 (n : fin (list.length aa)), h n = f (dlist.get bb n))\n      , dlist.enum h = @dlist.map A B\u2081 B\u2082 @f aa bb\n| [] bb h \u03c9h := rfl\n| (a :: aa) (dlist.cons .(a) b .(aa) bb) h \u03c9h\n:= begin\n     dsimp [dlist.enum, dlist.map],\n     rw \u03c9h,\n     apply congr_arg,\n     apply dlist.enum_eq_map,\n     intro n, cases n with n \u03c9n,\n     dsimp [fin.drop],\n     rw \u03c9h,\n     trivial\n   end\n\n/-! #brief Getting an item out of an enumerated dlist.\n-/\ntheorem dlist.get_enum {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa : list A}\n        (f : \u2200 (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 \u03c9) := rfl\n| (a :: aa) f (fin.mk (nat.succ n) \u03c9)\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 \u03c9),\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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {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 \u03c9n,\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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    {aa : list A}\n    {bb\u2081 bb\u2082 : dlist B aa}\n    (\u03c9 : dlist.get bb\u2081 = dlist.get bb\u2082)\n    : bb\u2081 = bb\u2082\n:= by calc bb\u2081 = dlist.enum (dlist.get bb\u2081) : eq.symm dlist.enum_get\n           ... = dlist.enum (dlist.get bb\u2082) : by rw \u03c9\n           ... = bb\u2082                        : dlist.enum_get\n\n\n/-! #brief Appending dlists.\n-/\ndefinition dlist.append {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa\u2081 : list A} (bb\u2081 : dlist B aa\u2081)\n        {aa\u2082 : list A} (bb\u2082 : dlist B aa\u2082)\n      , dlist B (aa\u2081 ++ aa\u2082)\n| [] bb\u2081 aa\u2082 bb\u2082 := bb\u2082\n| (a :: aa\u2081) (dlist.cons .(a) b .(aa\u2081) bb\u2081) aa\u2082 bb\u2082 := dlist.cons a b (aa\u2081 ++ aa\u2082) (dlist.append bb\u2081 bb\u2082)\n\n/-! #brief Splitting apart a dlist at an append (left part).\n-/\ndefinition dlist.split_left {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 (aa\u2081 : list A) {aa\u2082 : list A}\n        (bb : dlist B (aa\u2081 ++ aa\u2082))\n      , dlist B aa\u2081\n:= \u03bb aa\u2081 aa\u2082 bb\n   , begin\n       induction aa\u2081 with a aa\u2081 rec,\n       { exact dlist.nil B },\n       { cases bb with a b aa\u2081 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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 (aa\u2081 : list A) {aa\u2082 : list A}\n        (bb : dlist B (aa\u2081 ++ aa\u2082))\n      , dlist B aa\u2082\n:= \u03bb aa\u2081 aa\u2082 bb\n   , begin\n       induction aa\u2081 with a aa\u2081 rec,\n       { exact bb },\n       { cases bb with a b aa\u2081 bb', exact rec bb'}\n     end\n\n/-! #brief Appending the splits.\n-/\ntheorem dlist.append_split {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa\u2081 aa\u2082 : list A}\n        {bb : dlist B (aa\u2081 ++ aa\u2082)}\n      , dlist.append (dlist.split_left _ bb) (dlist.split_right _ bb)\n         = bb\n:= \u03bb aa\u2081 aa\u2082 bb\n   , begin\n       induction aa\u2081 with a aa\u2081 rec,\n       { trivial },\n       { cases bb with a b aa\u2081 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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    {aa\u2081 aa\u2082 : list A}\n    {bb\u2081 bb\u2082 : dlist B (aa\u2081 ++ aa\u2082)}\n    (\u03c9left : dlist.split_left _ bb\u2081 = dlist.split_left _ bb\u2082)\n    (\u03c9right : dlist.split_right _ bb\u2081 = dlist.split_right _ bb\u2082)\n    : bb\u2081 = bb\u2082\n:= begin\n     refine eq.trans (eq.symm dlist.append_split) _,\n     refine eq.trans _ (dlist.append_split),\n     rw [\u03c9left, \u03c9right]\n   end\n\n/-! #brief Splitting an append.\n-/\ntheorem dlist.split_left_append {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa\u2081 aa\u2082 : list A}\n        {bb\u2081 : dlist B aa\u2081} {bb\u2082 : dlist B aa\u2082}\n      , dlist.split_left aa\u2081 (dlist.append bb\u2081 bb\u2082)\n         = bb\u2081\n| aa\u2081 aa\u2082 bb\u2081 bb\u2082\n:= begin\n     induction aa\u2081 with a aa\u2081 rec,\n     { cases bb\u2081 with a b aa\u2081 bb\u2081, trivial },\n     { cases bb\u2081 with a b aa\u2081 bb\u2081,\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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa\u2081 aa\u2082 : list A}\n        {bb\u2081 : dlist B aa\u2081} {bb\u2082 : dlist B aa\u2082}\n      , dlist.split_right aa\u2081 (dlist.append bb\u2081 bb\u2082)\n         = bb\u2082\n| aa\u2081 aa\u2082 bb\u2081 bb\u2082\n:= begin\n     induction aa\u2081 with a aa\u2081 rec,\n     { cases bb\u2081 with a b aa\u2081 bb\u2081, trivial },\n     { cases bb\u2081 with a b aa\u2081 bb\u2081,\n       apply rec\n     }\n   end\n\n/-! #brief Splitting a map.\n-/\ntheorem dlist.split_left_map {A : Type \u2113\u2081} {B\u2081 B\u2082 : A \u2192 Sort \u2113\u2082} (f : \u2200 {a : A}, B\u2081 a \u2192 B\u2082 a)\n    : \u2200 {aa\u2081 aa\u2082 : list A}\n        {bb : dlist B\u2081 (aa\u2081 ++ aa\u2082)}\n      , dlist.split_left aa\u2081 (dlist.map @f bb) = dlist.map @f (dlist.split_left aa\u2081 bb)\n| aa\u2081 aa\u2082 bb\n:= begin\n     induction aa\u2081 with a aa\u2081 rec,\n     { trivial },\n     { cases bb with a b aa\u2081 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 \u2113\u2081} {B\u2081 B\u2082 : A \u2192 Sort \u2113\u2082} (f : \u2200 {a : A}, B\u2081 a \u2192 B\u2082 a)\n    : \u2200 {aa\u2081 aa\u2082 : list A}\n        {bb : dlist B\u2081 (aa\u2081 ++ aa\u2082)}\n      , dlist.split_right aa\u2081 (dlist.map @f bb) = dlist.map @f (dlist.split_right aa\u2081 bb)\n| aa\u2081 aa\u2082 bb\n:= begin\n     induction aa\u2081 with a aa\u2081 rec,\n     { trivial },\n     { cases bb with a b aa\u2081 bb',\n       apply rec\n     }\n   end\n\n/-! #brief Getting out of an append.\n-/\ntheorem dlist.get_append {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa\u2081 aa\u2082 : list A}\n        {bb\u2081 : dlist B aa\u2081} {bb\u2082 : dlist B aa\u2082}\n        {n : \u2115} {\u03c9n : n < list.length aa\u2081}\n      , dlist.get (dlist.append bb\u2081 bb\u2082) (fin.mk n (list.length.grow_left \u03c9n))\n         == dlist.get bb\u2081 (fin.mk n \u03c9n)\n| aa\u2081 aa\u2082 bb\u2081 bb\u2082 n \u03c9n\n:= sorry\n\n/-! #brief Getting out of a split.\n-/\ntheorem dlist.get_split_left {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa\u2081 aa\u2082 : list A}\n        {bb : dlist B (aa\u2081 ++ aa\u2082)}\n        {n : \u2115} {\u03c9n : n < list.length aa\u2081}\n      , dlist.get (dlist.split_left aa\u2081 bb) (fin.mk n \u03c9n)\n         == dlist.get bb (fin.mk n (list.length.grow_left \u03c9n))\n:= \u03bb aa\u2081 aa\u2082 bb n \u03c9n\n   , sorry\n\n/-! #brief Getting out of a split.\n-/\ntheorem dlist.get_split_right {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    : \u2200 {aa\u2081 aa\u2082 : list A}\n        {bb : dlist B (aa\u2081 ++ aa\u2082)}\n        {n : \u2115} {\u03c9n : n < list.length aa\u2082}\n      , dlist.get (dlist.split_right aa\u2081 bb) (fin.mk n \u03c9n)\n         == dlist.get bb (fin.mk (n + list.length aa\u2081) (list.length.grow_right \u03c9n))\n:= \u03bb aa\u2081 aa\u2082 bb n \u03c9n\n   , sorry\n\n/-! #brief Repeating an item as a dlist.\n-/\ndefinition dlist.repeat {A : Type \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    {a : A} (b : B a)\n    : \u2200 (N : \u2115)\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 \u2113\u2081} {B : A \u2192 Sort \u2113\u2082}\n    {a : A} {b : B a}\n    : \u2200 {N : \u2115} {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 \u03c90) := heq.refl _\n| (nat.succ N) (fin.mk (nat.succ n) \u03c9n) := @dlist.get_repeat N (fin.mk n (nat.le_of_lt_succ \u03c9n))\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 {\u0393 : ctx agents} {\u03c6 : form agents} :\n  prfS5 \u0393 (\u03c6 \u2283 \u03c6) :=\nbegin\nexact mp (mp (@pl2 _ _ \u03c6 (\u03c6 \u2283 \u03c6) \u03c6) pl1) pl1\nend\n\n\nlemma prtrue {\u0393 : ctx agents} : prfS5 \u0393 \u00ac\u22a5 := iden\n\n\nlemma weak {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} :\n  prfS5 \u0393 \u03c6 \u2192 prfS5 (\u0393 \u222a \u03c8) \u03c6 :=\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 {\u0393 : ctx agents} {\u03c6 : form agents} :\n  prfS5 (\u0393 \u222a \u03c6) \u03c6 :=\nbegin\napply ax;\napply or.intro_left;\nsimp\nend\n\n\nlemma cut {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} :\n  prfS5 \u0393 (\u03c6 \u2283 \u03c8) \u2192 prfS5 \u0393 (\u03c8 \u2283 \u03c7) \u2192 prfS5 \u0393 (\u03c6 \u2283 \u03c7) :=\nbegin\nintros h1 h2,\nexact mp (mp pl2 (mp pl1 h2)) h1\nend\n\n\nlemma conv_deduction {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} :\n  prfS5 \u0393 (\u03c6 \u2283 \u03c8) \u2192 prfS5 (\u0393 \u222a \u03c6) \u03c8 :=\nbegin\nintro h, \nexact mp (weak h) pr \nend\n\n\nlemma hs1 {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} :\n  prfS5 \u0393 ((\u03c8 \u2283 \u03c7) \u2283 ((\u03c6 \u2283 \u03c8) \u2283 (\u03c6 \u2283 \u03c7))) :=\nbegin\nexact (mp (mp pl2 (mp pl1 pl2)) pl1)\nend\n\n\nlemma likemp {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} : \n  prfS5 \u0393 (\u03c6 \u2283 ((\u03c6 \u2283 \u03c8) \u2283 \u03c8)) :=\nbegin\nexact (mp (mp hs1 (mp pl2 iden)) pl1)\nend\n\n\nlemma dne {\u0393 : ctx agents} {\u03c6 : form agents} :\nprfS5 \u0393 ((\u00ac\u00ac\u03c6) \u2283 \u03c6) :=\nbegin\nhave h1 : prfS5 \u0393 (\u03c6 \u2283 (\u03c6 \u2283 \u03c6)), from pl1,\nexact (cut (cut pl1 (cut pl7 pl7)) (mp likemp h1))\nend\n\n\nlemma dni {\u0393 : ctx agents} {\u03c6 : form agents} : prfS5 \u0393 (\u03c6 \u2283 \u00ac\u00ac\u03c6) :=\nbegin\nexact mp pl7 dne\nend\n\n\nlemma imp_if_imp_imp {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} : prfS5 \u0393 (\u03c6 \u2283 \u03c7) \u2192 prfS5 \u0393 (\u03c6 \u2283 (\u03c8 \u2283 \u03c7)) :=\nbegin\nintro h1,\nexact mp (mp pl2 (mp pl1 pl1)) h1\nend\n\n\nlemma cut1 {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 \u03b8 : form agents} :\n  prfS5 \u0393 (\u03b8 \u2283 (\u03c6 \u2283 \u03c8)) \u2192 prfS5 \u0393 (\u03c8 \u2283 \u03c7) \u2192 prfS5 \u0393 (\u03b8 \u2283 (\u03c6 \u2283 \u03c7)) :=\nbegin\nintros h1 h2,\nexact (cut h1) (mp pl2 (mp pl1 h2))\nend\n\n\nlemma imp_switch {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} : prfS5 \u0393 (\u03c6 \u2283 (\u03c8 \u2283 \u03c7)) \u2192 prfS5 \u0393 (\u03c8 \u2283 (\u03c6 \u2283 \u03c7)) :=\nbegin\nintro h1,\nexact mp (mp pl2 (mp pl1 (mp pl2 h1))) pl1\nend\n\n\nlemma l2 {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} : prfS5 \u0393 ((\u03c6 \u2283 (\u03c8 \u2283 \u03c7)) \u2283 (\u03c8 \u2283 (\u03c6 \u2283 \u03c7))) :=\nbegin\nexact (mp (mp pl2 (cut pl2 hs1)) (mp pl1 pl1))\nend\n\n\nlemma hs2 {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} :\n  prfS5 \u0393 ((\u03c6 \u2283 \u03c8) \u2283 ((\u03c8 \u2283 \u03c7) \u2283 (\u03c6 \u2283 \u03c7))) :=\nbegin\nexact (mp l2 hs1)\nend\n\n\nlemma cut2 {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 \u03b8 : form agents} :\n  prfS5 \u0393 (\u03c6 \u2283 \u03c8) \u2192 prfS5 \u0393 (\u03b8 \u2283 (\u03c8 \u2283 \u03c7)) \u2192 prfS5 \u0393 (\u03b8 \u2283 (\u03c6 \u2283 \u03c7)) :=\nbegin\nintros h1 h2,\nexact imp_switch (cut h1 (imp_switch h2))\nend\n\n\nlemma double_imp {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} :\n  prfS5 \u0393 ((\u03c6 \u2283 (\u03c6 \u2283 \u03c8)) \u2283 (\u03c6 \u2283 \u03c8)) :=\nbegin\nexact mp pl2 (imp_switch iden)\nend\n\n\nlemma imp_imp_iff_imp {\u0393 : ctx agents} {\u03b8 \u03c6 \u03c8 : form agents} : \n  prfS5 \u0393 (\u03b8 \u2283 (\u03c6 \u2283 (\u03c6 \u2283 \u03c8))) \u2194 prfS5 \u0393 (\u03b8 \u2283 (\u03c6 \u2283 \u03c8)) :=\nbegin\nsplit,\n{intro h1,\nexact cut h1 double_imp},\n{intro h1,\nexact cut h1 pl1}\nend\n\n\nlemma imp_shift {\u0393 : ctx agents} {\u03b8 \u03c6 \u03c8 \u03c7 : form agents} : \n  prfS5 \u0393 (\u03b8 \u2283 (\u03c6 \u2283 (\u03c8 \u2283 \u03c7))) \u2194 prfS5 \u0393 (\u03b8 \u2283 (\u03c8 \u2283 (\u03c6 \u2283 \u03c7))) :=\nbegin\nsplit,\nrepeat {intro h1, exact cut h1 (cut2 pl1 pl2)}\nend\n\n\nlemma left_and_imp {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} :\n  prfS5 \u0393 (\u03c8 \u2283 ((\u03c6 & \u03c8) \u2283 \u03c7)) \u2192 prfS5 \u0393 ((\u03c6 & \u03c8) \u2283 \u03c7) :=\nbegin\nintro h1,\nexact mp double_imp (cut pl6 h1)\nend\n\n\nlemma and_right_imp {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} : \n  prfS5 \u0393 ((\u03c6 & \u03c8) \u2283 \u03c7) \u2194 prfS5 \u0393 (\u03c8 \u2283 (\u03c6 \u2283 \u03c7)) :=\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 {\u03c6 \u03c8 \u03c7 : form agents} {\u0393 : ctx agents} : prfS5 \u0393 (\u03c6 \u2194 \u03c8) \u2192 (prfS5 \u0393 \u00ac(\u03c7 & \u03c6) \u2194 prfS5 \u0393 \u00ac(\u03c7 & \u03c8)) :=\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 {\u0393 : ctx agents} {\u03c6 : form agents} : \n  prfS5 \u0393 \u00ac(\u03c6 & \u00ac\u03c6) :=\nbegin\nexact mp (mp pl3 (cut dne pl6)) (cut dne pl5)\nend\n\n\nlemma phi_and_true {\u0393 : ctx agents} {\u03c6 : form agents} : prfS5 \u0393 ((\u03c6&(\u00ac\u22a5)) \u2194 \u03c6) :=\nbegin\nexact (mp (mp pl4 pl5) (mp (imp_switch pl4) prtrue))\nend\n\n\nlemma imp_and_and_imp {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 \u03b8 : form agents} : \n  prfS5 \u0393 (((\u03c6 \u2283 \u03c8) & (\u03c7 \u2283 \u03b8))) \u2192 prfS5 \u0393 (((\u03c6 & \u03c7) \u2283 (\u03c8 & \u03b8))) :=\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 {\u0393 : ctx agents} {\u03c6 : form agents} : \n  prfS5 \u0393 (\u00ac(\u03c6 & \u00ac\u03c6) \u2194 \u00ac\u22a5) :=\nbegin\nexact (mp (mp pl4 (mp pl1 prtrue)) (mp pl1 not_contra))\nend\n\n\nlemma contrapos {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} :\n  prfS5 \u0393 ((\u00ac\u03c8) \u2283 (\u00ac\u03c6)) \u2194 prfS5 \u0393 (\u03c6 \u2283 \u03c8) :=\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 {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} :\n  prfS5 \u0393 (\u03c6 \u2194 \u03c8) \u2192 prfS5 \u0393 (\u00ac\u03c8 \u2194 \u00ac\u03c6) :=\nbegin\nintro h1,\nhave h2 : prfS5 \u0393 (\u03c6 \u2283 \u03c8), from mp pl5 h1,\nhave h3 : prfS5 \u0393 (\u03c8 \u2283 \u03c6), from mp pl6 h1,\nrw \u2190contrapos at h2,\nrw \u2190contrapos at h3,\nexact (mp (mp pl4 h2) h3)\nend\n\n\nlemma contra_equiv_false {\u0393 : ctx agents} {\u03c6 : form agents} : \n  prfS5 \u0393 ((\u03c6 & \u00ac\u03c6) \u2194 \u22a5) :=\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 {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} : prfS5 \u0393 ((\u03c6 & \u03c8) \u2194 (\u03c8 & \u03c6)) :=\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 {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} : \n  prfS5 \u0393 (\u03c6 \u2283 \u03c8) \u2192 prfS5 \u0393  ((\u03c7 & \u03c6) \u2283 (\u03c7 & \u03c8)) :=\nbegin\nintros h1,\nexact imp_and_and_imp (mp (mp pl4 iden) h1)\nend\n\n\nlemma iff_iff_and_iff {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 \u03b8 : form agents} : \n  prfS5 \u0393 (\u03c6 \u2194 \u03c7) \u2192 prfS5 \u0393 (\u03c8 \u2194 \u03b8) \u2192 prfS5 \u0393 ((\u03c6 & \u03c8) \u2194 (\u03c7 & \u03b8)) := \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 {\u0393 : ctx agents} {\u03c6 \u03c8 \u03c7 : form agents} : prfS5 \u0393 (((\u03c6 & \u03c8) & \u03c7) \u2194 (\u03c6 & (\u03c8 & \u03c7))) :=\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 {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} : \n  prfS5 \u0393 (\u00ac(\u03c6 & \u03c8)) \u2194 prfS5 \u0393 (\u03c6 \u2283 \u00ac\u03c8) :=\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 {\u0393 : ctx agents} {\u03c8 : form agents} : prfS5 \u0393 (\u22a5 \u2283 \u03c8) :=\nbegin\napply contrapos.mp, exact (mp pl1 iden)\nend\n\n\nlemma exfalso {\u0393 : ctx agents} {\u03c6 \u03c8 : form agents} : prfS5 \u0393 ((\u03c6 & \u00ac\u03c6) \u2283 \u03c8) :=\nbegin\nexact cut not_contra explosion\nend\n\n\nlemma box_dn {\u0393 : ctx agents} {\u03c6 : form agents} {a : agents}  : prfS5 \u0393 ((\u00acK a \u03c6) \u2194 \u00ac(K a (\u00ac\u00ac\u03c6))) :=\nbegin\nexact mp (mp pl4 (contrapos.mpr (mp kdist (nec dne)))) (contrapos.mpr (mp kdist (nec dni)))\nend\n\n\nlemma dual_equiv1 {\u0393 : ctx agents} {\u03c6 : form agents} {a : agents} : prfS5 \u0393 ((K a \u03c6) \u2194 (\u00ac(\u00acK a \u00ac(\u00ac\u03c6)))) :=\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} \u2983m\u2081 m\u2082 : monoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\nbegin\n  have h\u2081 : (@monoid.to_mul_one_class _ m\u2081).one = (@monoid.to_mul_one_class _ m\u2082).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\u2081) (@monoid.to_mul_one_class _ m\u2082) :=\n    { to_fun := id, map_one' := h\u2081, map_mul' := \u03bb x y, congr_fun (congr_fun h_mul x) y },\n  have hpow : m\u2081.npow = m\u2082.npow, by { ext n x, exact @monoid_hom.map_pow M M m\u2081 m\u2082 f x n },\n  unfreezingI { cases m\u2081, cases m\u2082 },\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma comm_monoid.ext {M : Type*} \u2983m\u2081 m\u2082 : comm_monoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma left_cancel_monoid.ext {M : Type u} \u2983m\u2081 m\u2082 : left_cancel_monoid M\u2984\n  (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma right_cancel_monoid.ext {M : Type u} \u2983m\u2081 m\u2082 : right_cancel_monoid M\u2984\n  (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma cancel_monoid.ext {M : Type*} \u2983m\u2081 m\u2082 : cancel_monoid M\u2984\n  (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\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 \u27e8\u27e9 \u27e8\u27e9 h,\n  congr'; injection h,\nend\n\n@[ext, to_additive]\nlemma cancel_comm_monoid.ext {M : Type*} \u2983m\u2081 m\u2082 : cancel_comm_monoid M\u2984\n  (h_mul : m\u2081.mul = m\u2082.mul) : m\u2081 = m\u2082 :=\ncancel_comm_monoid.to_comm_monoid_injective $ comm_monoid.ext h_mul\n\n@[ext, to_additive]\nlemma div_inv_monoid.ext {M : Type*} \u2983m\u2081 m\u2082 : div_inv_monoid M\u2984 (h_mul : m\u2081.mul = m\u2082.mul)\n  (h_inv : m\u2081.inv = m\u2082.inv) : m\u2081 = m\u2082 :=\nbegin\n  have h\u2081 : (@div_inv_monoid.to_monoid _ m\u2081).one = (@div_inv_monoid.to_monoid _ m\u2082).one,\n    from congr_arg (@monoid.one M) (monoid.ext h_mul),\n  set f : @monoid_hom M M (by letI := m\u2081; apply_instance) (by letI := m\u2082; apply_instance) :=\n    { to_fun := id, map_one' := h\u2081, map_mul' := \u03bb x y, congr_fun (congr_fun h_mul x) y },\n  have hpow : (@div_inv_monoid.to_monoid _ m\u2081).npow = (@div_inv_monoid.to_monoid _ m\u2082).npow :=\n    congr_arg (@monoid.npow M) (monoid.ext h_mul),\n  have hzpow : m\u2081.zpow = m\u2082.zpow,\n  { ext m x,\n    exact @monoid_hom.map_zpow' M M m\u2081 m\u2082 f (congr_fun h_inv) x m },\n  have hdiv : m\u2081.div = m\u2082.div,\n  { ext a b,\n    exact @map_div' M M _ m\u2081 m\u2082 _ f (congr_fun h_inv) a b },\n  unfreezingI { cases m\u2081, cases m\u2082 },\n  congr, exacts [h_mul, h\u2081, hpow, h_inv, hdiv, hzpow]\nend\n\n@[ext, to_additive]\nlemma group.ext {G : Type*} \u2983g\u2081 g\u2082 : group G\u2984 (h_mul : g\u2081.mul = g\u2082.mul) : g\u2081 = g\u2082 :=\nbegin\n  set f := @monoid_hom.mk' G G (by letI := g\u2081; apply_instance) g\u2082 id\n    (\u03bb 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\u2081 (@group.to_division_monoid _ g\u2082) f))\nend\n\n@[ext, to_additive]\nlemma comm_group.ext {G : Type*} \u2983g\u2081 g\u2082 : comm_group G\u2984\n  (h_mul : g\u2081.mul = g\u2082.mul) : g\u2081 = g\u2082 :=\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 \u2192 Q)\n(i : Q \u2192 R)\n(j : Q \u2192 T)\n(k : S \u2192 T)\n(l : T \u2192 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 (\u03b1 : Type u) where\n  init: List \u03b1 \n  tail: List \u03b1\n\nnamespace QueueData\ndef toList (q: QueueData \u03b1): List \u03b1 := q.init ++ q.tail.reverse\n\ndef send (q: QueueData \u03b1) (a: \u03b1): QueueData \u03b1 := {q with tail := a :: q.tail}\n\ndef pull (q: QueueData \u03b1) : Option (\u03b1 \u00d7 QueueData \u03b1) :=\n  match q.init with\n  | x :: xs  => some (x, \u27e8xs, tail\u27e9)\n  | [] => match q.tail.reverse with \n    | x :: xs => some (x, \u27e8xs, []\u27e9)\n    | []      => none\n\ndef isEmpty (q: QueueData \u03b1) : Bool := \n  q.init.isEmpty && q.tail.isEmpty\n\n\ndef rel (a b : QueueData \u03b1): Prop := a.toList = b.toList\n\ntheorem nonEmptyAppend {xs ys: List \u03b1} {x: \u03b1} (p: xs ++ (x :: ys) = []) : False := \n  by cases xs <;> simp at p\n\ntheorem isEmptyToList (q: QueueData \u03b1): 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 \u03b1}: 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 \u03b1} {x : \u03b1} {xs: List \u03b1}: \n  q.toList = x :: xs  <-> (exists (qt: QueueData \u03b1), qt.toList = xs \u2227 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 \u27e8 t , []\u27e9\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 (\u00b7.init) p2\n        let p4 := congrArg (\u00b7.tail) p2\n        simp at p3 p4\n        rw [\u2190 p3, \u2190 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 \u03b1 := \u27e8 t, q.tail \u27e9\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, \u2190 p1]\n      simp\n      let p4 := congrArg (\u00b7.init) p3\n      let p5 := congrArg (\u00b7.tail) p3\n      simp at p4 p5\n      rw [p4, p5]\n\nend QueueData\n\ndef EqvSetoid {\u03b1 : Type u} (f: \u03b1 -> \u03b2): Setoid \u03b1 := {\n  r := \u03bb 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 (\u03b1 : Type u): Setoid (QueueData \u03b1) := EqvSetoid <| QueueData.toList\n\ndef Queue (\u03b1 : Type u) := Quotient (QueueIsEqualUnderToList \u03b1) \n\nnamespace Queue\n\nvariable (q: Queue \u03b1)\n\ndef toList: List \u03b1 := \n  q.lift (\u00b7.toList) <| by intros; assumption\n\ndef send (x: \u03b1): Queue \u03b1 := \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 [\u2190 List.append_assoc]\n    simp [QueueIsEqualUnderToList, EqvSetoid, QueueData.rel, QueueData.toList] at p\n    rw [p]\n    \ndef pull: Option (\u03b1 \u00d7 Queue \u03b1) :=\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 [\u2190 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 (\u00b7.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 [\u2190QueueData.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, \u2190QueueData.isEmptyToList] at pe\n    rw [pe]\n\ndef empty: Queue \u03b1 :=   Quot.mk _ \u27e8[], []\u27e9\n\ndef peak: Option \u03b1 := q.pull.map (\u00b7.1)\n\ndef tail: Queue \u03b1 := (q.pull.map (\u00b7.2) ).getD empty\n\ndef sendMany [ForIn Id \u03c1 \u03b1](xs: \u03c1) : Id (Queue \u03b1) := do\n  let mut q := q\n  for x in xs do\n    q := q.send x\n  return q\n\ninstance: Inhabited (Queue \u03b1) where\n  default := empty\n\ninstance [ToString \u03b1]: ToString (Queue \u03b1) where\n  toString q := \"Queue\" ++ q.toList.toString   \n\ninstance [Lean.ToJson \u03b1]: Lean.ToJson (Queue \u03b1) where\n  toJson q := Lean.ToJson.toJson q.toList\n\ninstance : ForIn m (Queue \u03b1) \u03b1 where\n  forIn q b f := q.toList.forIn b f\n\ninstance [BEq \u03b1] : BEq (Queue \u03b1) 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 (\u03b1 : Type u)\n\nnamespace mul_opposite\n\n/-!\n### Additive structures on `\u03b1\u1d50\u1d52\u1d56`\n-/\n\ninstance [add_semigroup \u03b1] : add_semigroup (\u03b1\u1d50\u1d52\u1d56) :=\nunop_injective.add_semigroup _ (\u03bb x y, rfl)\n\ninstance [add_left_cancel_semigroup \u03b1] : add_left_cancel_semigroup \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_left_cancel_semigroup _ (\u03bb x y, rfl)\n\ninstance [add_right_cancel_semigroup \u03b1] : add_right_cancel_semigroup \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_right_cancel_semigroup _ (\u03bb x y, rfl)\n\ninstance [add_comm_semigroup \u03b1] : add_comm_semigroup \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_comm_semigroup _ (\u03bb x y, rfl)\n\ninstance [add_zero_class \u03b1] : add_zero_class \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_zero_class _ rfl (\u03bb x y, rfl)\n\ninstance [add_monoid \u03b1] : add_monoid \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [add_monoid_with_one \u03b1] : add_monoid_with_one \u03b1\u1d50\u1d52\u1d56 :=\n{ nat_cast := \u03bb n, op n,\n  nat_cast_zero := show op ((0 : \u2115) : \u03b1) = 0, by simp,\n  nat_cast_succ := show \u2200 n, op ((n + 1 : \u2115) : \u03b1) = op (n : \u2115) + 1, by simp,\n  .. mul_opposite.add_monoid \u03b1, .. mul_opposite.has_one \u03b1 }\n\ninstance [add_comm_monoid \u03b1] : add_comm_monoid \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_comm_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [sub_neg_monoid \u03b1] : sub_neg_monoid \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.sub_neg_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [add_group \u03b1] : add_group \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [add_group_with_one \u03b1] : add_group_with_one \u03b1\u1d50\u1d52\u1d56 :=\n{ int_cast := \u03bb n, op n,\n  int_cast_of_nat := \u03bb n, show op ((n : \u2124) : \u03b1) = op n, by rw int.cast_coe_nat,\n  int_cast_neg_succ_of_nat := \u03bb n, show op _ = op (- unop (op ((n + 1 : \u2115) : \u03b1))),\n    by erw [unop_op, int.cast_neg_succ_of_nat]; refl,\n  .. mul_opposite.add_monoid_with_one \u03b1, .. mul_opposite.add_group \u03b1 }\n\ninstance [add_comm_group \u03b1] : add_comm_group \u03b1\u1d50\u1d52\u1d56 :=\nunop_injective.add_comm_group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\n/-!\n### Multiplicative structures on `\u03b1\u1d50\u1d52\u1d56`\n\nWe also generate additive structures on `\u03b1\u1d43\u1d52\u1d56` using `to_additive`\n-/\n\n@[to_additive] instance [semigroup \u03b1] : semigroup \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_assoc := \u03bb x y z, unop_injective $ eq.symm $ mul_assoc (unop z) (unop y) (unop x),\n  .. mul_opposite.has_mul \u03b1 }\n\n@[to_additive] instance [right_cancel_semigroup \u03b1] : left_cancel_semigroup \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_left_cancel := \u03bb x y z H, unop_injective $ mul_right_cancel $ op_injective H,\n  .. mul_opposite.semigroup \u03b1 }\n\n@[to_additive] instance [left_cancel_semigroup \u03b1] : right_cancel_semigroup \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_right_cancel := \u03bb x y z H, unop_injective $ mul_left_cancel $ op_injective H,\n  .. mul_opposite.semigroup \u03b1 }\n\n@[to_additive] instance [comm_semigroup \u03b1] : comm_semigroup \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_comm := \u03bb x y, unop_injective $ mul_comm (unop y) (unop x),\n  .. mul_opposite.semigroup \u03b1 }\n\n@[to_additive] instance [mul_one_class \u03b1] : mul_one_class \u03b1\u1d50\u1d52\u1d56 :=\n{ one_mul := \u03bb x, unop_injective $ mul_one $ unop x,\n  mul_one := \u03bb x, unop_injective $ one_mul $ unop x,\n  .. mul_opposite.has_mul \u03b1, .. mul_opposite.has_one \u03b1 }\n\n@[to_additive] instance [monoid \u03b1] : monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ npow := \u03bb n x, op $ x.unop ^ n,\n  npow_zero' := \u03bb x, unop_injective $ monoid.npow_zero' x.unop,\n  npow_succ' := \u03bb n x, unop_injective $ pow_succ' x.unop n,\n  .. mul_opposite.semigroup \u03b1, .. mul_opposite.mul_one_class \u03b1 }\n\n@[to_additive] instance [right_cancel_monoid \u03b1] : left_cancel_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.left_cancel_semigroup \u03b1, .. mul_opposite.monoid \u03b1 }\n\n@[to_additive] instance [left_cancel_monoid \u03b1] : right_cancel_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.right_cancel_semigroup \u03b1, .. mul_opposite.monoid \u03b1 }\n\n@[to_additive] instance [cancel_monoid \u03b1] : cancel_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.right_cancel_monoid \u03b1, .. mul_opposite.left_cancel_monoid \u03b1 }\n\n@[to_additive] instance [comm_monoid \u03b1] : comm_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.monoid \u03b1, .. mul_opposite.comm_semigroup \u03b1 }\n\n@[to_additive] instance [cancel_comm_monoid \u03b1] : cancel_comm_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.cancel_monoid \u03b1, .. mul_opposite.comm_monoid \u03b1 }\n\n@[to_additive add_opposite.sub_neg_monoid] instance [div_inv_monoid \u03b1] : div_inv_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ zpow := \u03bb n x, op $ x.unop ^ n,\n  zpow_zero' := \u03bb x, unop_injective $ div_inv_monoid.zpow_zero' x.unop,\n  zpow_succ' := \u03bb n x, unop_injective $\n    by rw [unop_op, zpow_of_nat, zpow_of_nat, pow_succ', unop_mul, unop_op],\n  zpow_neg' := \u03bb z x, unop_injective $ div_inv_monoid.zpow_neg' z x.unop,\n  .. mul_opposite.monoid \u03b1, .. mul_opposite.has_inv \u03b1 }\n\n@[to_additive add_opposite.subtraction_monoid] instance [division_monoid \u03b1] :\n  division_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_inv_rev := \u03bb a b, unop_injective $ mul_inv_rev _ _,\n  inv_eq_of_mul := \u03bb a b h, unop_injective $ inv_eq_of_mul_eq_one_left $ congr_arg unop h,\n  .. mul_opposite.div_inv_monoid \u03b1, .. mul_opposite.has_involutive_inv \u03b1 }\n\n@[to_additive add_opposite.subtraction_comm_monoid] instance [division_comm_monoid \u03b1] :\n  division_comm_monoid \u03b1\u1d50\u1d52\u1d56 :=\n{ ..mul_opposite.division_monoid \u03b1, ..mul_opposite.comm_semigroup \u03b1 }\n\n@[to_additive] instance [group \u03b1] : group \u03b1\u1d50\u1d52\u1d56 :=\n{ mul_left_inv := \u03bb x, unop_injective $ mul_inv_self $ unop x,\n  .. mul_opposite.div_inv_monoid \u03b1, }\n\n@[to_additive] instance [comm_group \u03b1] : comm_group \u03b1\u1d50\u1d52\u1d56 :=\n{ .. mul_opposite.group \u03b1, .. mul_opposite.comm_monoid \u03b1 }\n\nvariable {\u03b1}\n\n@[simp, to_additive] lemma unop_div [div_inv_monoid \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) :\n  unop (x / y) = (unop y)\u207b\u00b9 * unop x :=\nrfl\n\n@[simp, to_additive] lemma op_div [div_inv_monoid \u03b1] (x y : \u03b1) :\n  op (x / y) = (op y)\u207b\u00b9 * op x :=\nby simp [div_eq_mul_inv]\n\n@[simp, to_additive] lemma semiconj_by_op [has_mul \u03b1] {a x y : \u03b1} :\n  semiconj_by (op a) (op y) (op x) \u2194 semiconj_by a x y :=\nby simp only [semiconj_by, \u2190 op_mul, op_inj, eq_comm]\n\n@[simp, to_additive] lemma semiconj_by_unop [has_mul \u03b1] {a x y : \u03b1\u1d50\u1d52\u1d56} :\n  semiconj_by (unop a) (unop y) (unop x) \u2194 semiconj_by a x y :=\nby conv_rhs { rw [\u2190 op_unop a, \u2190 op_unop x, \u2190 op_unop y, semiconj_by_op] }\n\n@[to_additive] lemma _root_.semiconj_by.op [has_mul \u03b1] {a x y : \u03b1} (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 \u03b1] {a x y : \u03b1\u1d50\u1d52\u1d56} (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 \u03b1] {x y : \u03b1} (h : commute x y) :\n  commute (op x) (op y) := h.op\n\n@[to_additive] lemma commute.unop [has_mul \u03b1] {x y : \u03b1\u1d50\u1d52\u1d56} (h : commute x y) :\n  commute (unop x) (unop y) := h.unop\n\n@[simp, to_additive] lemma commute_op [has_mul \u03b1] {x y : \u03b1} :\n  commute (op x) (op y) \u2194 commute x y :=\nsemiconj_by_op\n\n@[simp, to_additive] lemma commute_unop [has_mul \u03b1] {x y : \u03b1\u1d50\u1d52\u1d56} :\n  commute (unop x) (unop y) \u2194 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 \u03b1] : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56 :=\n{ map_add' := \u03bb a b, rfl, .. op_equiv }\n\n@[simp] lemma op_add_equiv_to_equiv [has_add \u03b1] :\n  (op_add_equiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).to_equiv = op_equiv :=\nrfl\n\nend mul_opposite\n\n/-!\n### Multiplicative structures on `\u03b1\u1d43\u1d52\u1d56`\n-/\n\nnamespace add_opposite\n\ninstance [semigroup \u03b1] : semigroup (\u03b1\u1d43\u1d52\u1d56) :=\nunop_injective.semigroup _ (\u03bb x y, rfl)\n\ninstance [left_cancel_semigroup \u03b1] : left_cancel_semigroup \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.left_cancel_semigroup _ (\u03bb x y, rfl)\n\ninstance [right_cancel_semigroup \u03b1] : right_cancel_semigroup \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.right_cancel_semigroup _ (\u03bb x y, rfl)\n\ninstance [comm_semigroup \u03b1] : comm_semigroup \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.comm_semigroup _ (\u03bb x y, rfl)\n\ninstance [mul_one_class \u03b1] : mul_one_class \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.mul_one_class _ rfl (\u03bb x y, rfl)\n\ninstance {\u03b2} [has_pow \u03b1 \u03b2] : has_pow \u03b1\u1d43\u1d52\u1d56 \u03b2 := { pow := \u03bb a b, op (unop a ^ b) }\n\n@[simp] lemma op_pow {\u03b2} [has_pow \u03b1 \u03b2] (a : \u03b1) (b : \u03b2) : op (a ^ b) = op a ^ b := rfl\n@[simp] lemma unop_pow {\u03b2} [has_pow \u03b1 \u03b2] (a : \u03b1\u1d43\u1d52\u1d56) (b : \u03b2) : unop (a ^ b) = unop a ^ b := rfl\n\ninstance [monoid \u03b1] : monoid \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.monoid _ rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [comm_monoid \u03b1] : comm_monoid \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.comm_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [div_inv_monoid \u03b1] : div_inv_monoid \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.div_inv_monoid _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [group \u03b1] : group \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [comm_group \u03b1] : comm_group \u03b1\u1d43\u1d52\u1d56 :=\nunop_injective.comm_group _ rfl (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\nvariable {\u03b1}\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 \u03b1] : \u03b1 \u2243* \u03b1\u1d43\u1d52\u1d56 :=\n{ map_mul' := \u03bb a b, rfl, .. op_equiv }\n\n@[simp] lemma op_mul_equiv_to_equiv [has_mul \u03b1] :\n  (op_mul_equiv : \u03b1 \u2243* \u03b1\u1d43\u1d52\u1d56).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 \u2243* G\u1d50\u1d52\u1d56 :=\n{ map_mul' := \u03bb x y, unop_injective $ mul_inv_rev x y,\n  .. (equiv.inv G).trans op_equiv }\n\n/-- A semigroup homomorphism `f : M \u2192\u2099* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism to `N\u1d50\u1d52\u1d56`. -/\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\u1d43\u1d52\u1d56`.\",\n  simps {fully_applied := ff}]\ndef mul_hom.to_opposite {M N : Type*} [has_mul M] [has_mul N] (f : M \u2192\u2099* N)\n  (hf : \u2200 x y, commute (f x) (f y)) : M \u2192\u2099* N\u1d50\u1d52\u1d56 :=\n{ to_fun := mul_opposite.op \u2218 f,\n  map_mul' := \u03bb x y, by simp [(hf x y).eq] }\n\n/-- A semigroup homomorphism `f : M \u2192\u2099* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism from `M\u1d50\u1d52\u1d56`. -/\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\u1d43\u1d52\u1d56`.\",\n  simps {fully_applied := ff}]\ndef mul_hom.from_opposite {M N : Type*} [has_mul M] [has_mul N] (f : M \u2192\u2099* N)\n  (hf : \u2200 x y, commute (f x) (f y)) : M\u1d50\u1d52\u1d56 \u2192\u2099* N :=\n{ to_fun := f \u2218 mul_opposite.unop,\n  map_mul' := \u03bb x y, (f.map_mul _ _).trans (hf _ _).eq }\n\n/-- A monoid homomorphism `f : M \u2192* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism to `N\u1d50\u1d52\u1d56`. -/\n@[to_additive \"An additive monoid homomorphism `f : M \u2192+ N` such that `f x` additively commutes\nwith `f y` for all `x, y` defines an additive monoid homomorphism to `S\u1d43\u1d52\u1d56`.\",\n  simps {fully_applied := ff}]\ndef monoid_hom.to_opposite {M N : Type*} [mul_one_class M] [mul_one_class N] (f : M \u2192* N)\n  (hf : \u2200 x y, commute (f x) (f y)) : M \u2192* N\u1d50\u1d52\u1d56 :=\n{ to_fun := mul_opposite.op \u2218 f,\n  map_one' := congr_arg op f.map_one,\n  map_mul' := \u03bb x y, by simp [(hf x y).eq] }\n\n/-- A monoid homomorphism `f : M \u2192* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism from `M\u1d50\u1d52\u1d56`. -/\n@[to_additive \"An additive monoid homomorphism `f : M \u2192+ N` such that `f x` additively commutes\nwith `f y` for all `x`, `y` defines an additive monoid homomorphism from `M\u1d43\u1d52\u1d56`.\",\n  simps {fully_applied := ff}]\ndef monoid_hom.from_opposite {M N : Type*} [mul_one_class M] [mul_one_class N] (f : M \u2192* N)\n  (hf : \u2200 x y, commute (f x) (f y)) : M\u1d50\u1d52\u1d56 \u2192* N :=\n{ to_fun := f \u2218 mul_opposite.unop,\n  map_one' := f.map_one,\n  map_mul' := \u03bb 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\u1d50\u1d52\u1d56)\u02e3 \u2243* (M\u02e3)\u1d50\u1d52\u1d56 :=\n{ to_fun := \u03bb u, op \u27e8unop u, unop \u2191(u\u207b\u00b9), op_injective u.4, op_injective u.3\u27e9,\n  inv_fun := mul_opposite.rec $ \u03bb u, \u27e8op \u2191(u), op \u2191(u\u207b\u00b9), unop_injective $ u.4, unop_injective u.3\u27e9,\n  map_mul' := \u03bb x y, unop_injective $ units.ext $ rfl,\n  left_inv := \u03bb x, units.ext $ by simp,\n  right_inv := \u03bb x, unop_injective $ units.ext $ rfl }\n\n@[simp, to_additive]\nlemma units.coe_unop_op_equiv {M} [monoid M] (u : (M\u1d50\u1d52\u1d56)\u02e3) :\n  ((units.op_equiv u).unop : M) = unop (u : M\u1d50\u1d52\u1d56) :=\nrfl\n\n@[simp, to_additive]\nlemma units.coe_op_equiv_symm {M} [monoid M] (u : (M\u02e3)\u1d50\u1d52\u1d56) :\n  (units.op_equiv.symm u : M\u1d50\u1d52\u1d56) = op (u.unop : M) :=\nrfl\n\n/-- A semigroup homomorphism `M \u2192\u2099* N` can equivalently be viewed as a semigroup homomorphism\n`M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-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\u1d43\u1d52\u1d56 N\u1d43\u1d52\u1d56`. This is the action of the (fully faithful)\n`\u1d43\u1d52\u1d56`-functor on morphisms.\", simps]\ndef mul_hom.op {M N} [has_mul M] [has_mul N] :\n  (M \u2192\u2099* N) \u2243 (M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun   := op \u2218 f \u2218 unop,\n                      map_mul' := \u03bb x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := \u03bb f, { to_fun   := unop \u2218 f \u2218 op,\n                      map_mul' := \u03bb x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext x, simp } }\n\n/-- The 'unopposite' of a semigroup homomorphism `M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56`. Inverse to `mul_hom.op`. -/\n@[simp, to_additive \"The 'unopposite' of an additive semigroup homomorphism `M\u1d43\u1d52\u1d56 \u2192\u2099+ N\u1d43\u1d52\u1d56`. Inverse\nto `add_hom.op`.\"]\ndef mul_hom.unop {M N} [has_mul M] [has_mul N] :\n  (M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56) \u2243 (M \u2192\u2099* 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\u1d50\u1d52\u1d56 N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on\nmorphisms. -/\n@[simps]\ndef add_hom.mul_op {M N} [has_add M] [has_add N] :\n  (add_hom M N) \u2243 (add_hom M\u1d50\u1d52\u1d56 N\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun    := op \u2218 f \u2218 unop,\n                      map_add'  := \u03bb x y, unop_injective (f.map_add x.unop y.unop) },\n  inv_fun   := \u03bb f, { to_fun    := unop \u2218 f \u2218 op,\n                      map_add'  := \u03bb x y, congr_arg unop (f.map_add (op x) (op y)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext, simp } }\n\n/-- The 'unopposite' of an additive semigroup hom `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56`. Inverse to\n`add_hom.mul_op`. -/\n@[simp] def add_hom.mul_unop {\u03b1 \u03b2} [has_add \u03b1] [has_add \u03b2] :\n  (add_hom \u03b1\u1d50\u1d52\u1d56 \u03b2\u1d50\u1d52\u1d56) \u2243 (add_hom \u03b1 \u03b2) := add_hom.mul_op.symm\n\n/-- A monoid homomorphism `M \u2192* N` can equivalently be viewed as a monoid homomorphism\n`M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on morphisms. -/\n@[to_additive \"An additive monoid homomorphism `M \u2192+ N` can equivalently be viewed as an\nadditive monoid homomorphism `M\u1d43\u1d52\u1d56 \u2192+ N\u1d43\u1d52\u1d56`. This is the action of the (fully faithful)\n`\u1d43\u1d52\u1d56`-functor on morphisms.\", simps]\ndef monoid_hom.op {M N} [mul_one_class M] [mul_one_class N] :\n  (M \u2192* N) \u2243 (M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun   := op \u2218 f \u2218 unop,\n                      map_one' := congr_arg op f.map_one,\n                      map_mul' := \u03bb x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := \u03bb f, { to_fun   := unop \u2218 f \u2218 op,\n                      map_one' := congr_arg unop f.map_one,\n                      map_mul' := \u03bb x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext x, simp } }\n\n/-- The 'unopposite' of a monoid homomorphism `M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56`. Inverse to `monoid_hom.op`. -/\n@[simp, to_additive \"The 'unopposite' of an additive monoid homomorphism `M\u1d43\u1d52\u1d56 \u2192+ N\u1d43\u1d52\u1d56`. Inverse to\n`add_monoid_hom.op`.\"]\ndef monoid_hom.unop {M N} [mul_one_class M] [mul_one_class N] :\n  (M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56) \u2243 (M \u2192* N) := monoid_hom.op.symm\n\n/-- An additive homomorphism `M \u2192+ N` can equivalently be viewed as an additive homomorphism\n`M\u1d50\u1d52\u1d56 \u2192+ N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on morphisms. -/\n@[simps]\ndef add_monoid_hom.mul_op {M N} [add_zero_class M] [add_zero_class N] :\n  (M \u2192+ N) \u2243 (M\u1d50\u1d52\u1d56 \u2192+ N\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun    := op \u2218 f \u2218 unop,\n                      map_zero' := unop_injective f.map_zero,\n                      map_add'  := \u03bb x y, unop_injective (f.map_add x.unop y.unop) },\n  inv_fun   := \u03bb f, { to_fun    := unop \u2218 f \u2218 op,\n                      map_zero' := congr_arg unop f.map_zero,\n                      map_add'  := \u03bb x y, congr_arg unop (f.map_add (op x) (op y)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext, simp } }\n\n/-- The 'unopposite' of an additive monoid hom `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56`. Inverse to\n`add_monoid_hom.mul_op`. -/\n@[simp] def add_monoid_hom.mul_unop {\u03b1 \u03b2} [add_zero_class \u03b1] [add_zero_class \u03b2] :\n  (\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56) \u2243 (\u03b1 \u2192+ \u03b2) := add_monoid_hom.mul_op.symm\n\n/-- A iso `\u03b1 \u2243+ \u03b2` can equivalently be viewed as an iso `\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56`. -/\n@[simps]\ndef add_equiv.mul_op {\u03b1 \u03b2} [has_add \u03b1] [has_add \u03b2] :\n  (\u03b1 \u2243+ \u03b2) \u2243 (\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, op_add_equiv.symm.trans (f.trans op_add_equiv),\n  inv_fun   := \u03bb f, op_add_equiv.trans (f.trans op_add_equiv.symm),\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext, simp } }\n\n/-- The 'unopposite' of an iso `\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56`. Inverse to `add_equiv.mul_op`. -/\n@[simp] def add_equiv.mul_unop {\u03b1 \u03b2} [has_add \u03b1] [has_add \u03b2] :\n  (\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56) \u2243 (\u03b1 \u2243+ \u03b2) := add_equiv.mul_op.symm\n\n/-- A iso `\u03b1 \u2243* \u03b2` can equivalently be viewed as an iso `\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56`. -/\n@[to_additive \"A iso `\u03b1 \u2243+ \u03b2` can equivalently be viewed as an iso `\u03b1\u1d43\u1d52\u1d56 \u2243+ \u03b2\u1d43\u1d52\u1d56`.\", simps]\ndef mul_equiv.op {\u03b1 \u03b2} [has_mul \u03b1] [has_mul \u03b2] :\n  (\u03b1 \u2243* \u03b2) \u2243 (\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56) :=\n{ to_fun    := \u03bb f, { to_fun   := op \u2218 f \u2218 unop,\n                      inv_fun  := op \u2218 f.symm \u2218 unop,\n                      left_inv := \u03bb x, unop_injective (f.symm_apply_apply x.unop),\n                      right_inv := \u03bb x, unop_injective (f.apply_symm_apply x.unop),\n                      map_mul' := \u03bb x y, unop_injective (f.map_mul y.unop x.unop) },\n  inv_fun   := \u03bb f, { to_fun   := unop \u2218 f \u2218 op,\n                      inv_fun  := unop \u2218 f.symm \u2218 op,\n                      left_inv := \u03bb x, by simp,\n                      right_inv := \u03bb x, by simp,\n                      map_mul' := \u03bb x y, congr_arg unop (f.map_mul (op y) (op x)) },\n  left_inv  := \u03bb f, by { ext, refl },\n  right_inv := \u03bb f, by { ext, simp } }\n\n/-- The 'unopposite' of an iso `\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56`. Inverse to `mul_equiv.op`. -/\n@[simp, to_additive \"The 'unopposite' of an iso `\u03b1\u1d43\u1d52\u1d56 \u2243+ \u03b2\u1d43\u1d52\u1d56`. Inverse to `add_equiv.op`.\"]\ndef mul_equiv.unop {\u03b1 \u03b2} [has_mul \u03b1] [has_mul \u03b2] :\n  (\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56) \u2243 (\u03b1 \u2243* \u03b2) := mul_equiv.op.symm\n\nsection ext\n\n/-- This ext lemma change equalities on `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2` to equalities on `\u03b1 \u2192+ \u03b2`.\nThis is useful because there are often ext lemmas for specific `\u03b1`s that will apply\nto an equality of `\u03b1 \u2192+ \u03b2` such as `finsupp.add_hom_ext'`. -/\n@[ext]\nlemma add_monoid_hom.mul_op_ext {\u03b1 \u03b2} [add_zero_class \u03b1] [add_zero_class \u03b2]\n  (f g : \u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2)\n  (h : f.comp (op_add_equiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).to_add_monoid_hom =\n       g.comp (op_add_equiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).to_add_monoid_hom) : f = g :=\nadd_monoid_hom.ext $ mul_opposite.rec $ \u03bb 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 \u03b9 : 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 \u03b9 R) : mv_polynomial \u03b9 R :=\nhomogeneous_component p.total_degree p\n\nlemma leading_terms_apply (p : mv_polynomial \u03b9 R) : p.leading_terms =\n  \u2211 d in p.support.filter (\u03bb d, \u2211 i in d.support, d i = p.total_degree), monomial d (coeff d p) :=\nhomogeneous_component_apply _ _\n-- (p.support.filter (\u03bb s : \u03b9 \u2192\u2080 \u2115, s.sum (\u03bb _ e, e) = p.total_degree)).sum $\n--   \u03bb s, monomial s (p.coeff s)\n\n@[simp]\nlemma leading_terms_zero : (0 : mv_polynomial \u03b9 R).leading_terms = 0 :=\nby simp [leading_terms]\n\nlemma finset.filter_eq_self_iff {\u03b1 : Type*} (S : finset \u03b1) (h : \u03b1 \u2192 Prop) [decidable_pred h] :\n  S.filter h = S \u2194 \u2200 s \u2208 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 \u03b9 R) :\n  p.leading_terms = p \u2194 p.is_homogeneous p.total_degree :=\nbegin\n  split; intro h,\n  { rw is_homogeneous,\n    contrapose! h,\n    rcases h with \u27e8h_w, h_h\u2081, h_h\u2082\u27e9,\n    rw [leading_terms, ne.def, mv_polynomial.ext_iff],\n    push_neg,\n    use h_w,\n    classical,\n    change \u00ac h_w.sum (\u03bb (_x : \u03b9) (e : \u2115), e) = p.total_degree at h_h\u2082,\n    simp only [h_h\u2081.symm, coeff_homogeneous_component, exists_prop, and_true, ne.def, not_false_iff,\n      not_forall, ite_eq_left_iff],\n    convert h_h\u2082, },\n  { rw [leading_terms_apply],\n    rw (_ : p.support.filter (\u03bb (s : \u03b9 \u2192\u2080 \u2115), \u2211 (i : \u03b9) 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 \u2190 h hs, }, },\nend\n\n@[simp]\nlemma leading_terms_C (r : R) : (C r : mv_polynomial \u03b9 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 \u03b9 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 \u03b9 R} (hp : p \u2260 0) :\n  \u2203 (v : \u03b9 \u2192\u2080 \u2115), v.sum (\u03bb _ e, e) = p.total_degree \u2227 p.coeff v \u2260 0 :=\nbegin\n  obtain \u27e8b, hb\u2081, hb\u2082\u27e9 := p.support.exists_mem_eq_sup (finsupp.support_nonempty_iff.mpr hp)\n    (\u03bb (m : \u03b9 \u2192\u2080 \u2115), m.to_multiset.card),\n  use b,\n  split,\n  { rw \u2190 total_degree_eq p at hb\u2082,\n    rw hb\u2082,\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\u2081, },\nend\n\n-- TODO mathlib\n@[simp] lemma support_eq_empty {f : mv_polynomial \u03b9 R} : f.support = \u2205 \u2194 f = 0 :=\nfinsupp.support_eq_empty\n\nlemma support_add_eq [decidable_eq \u03b9] {g\u2081 g\u2082 : mv_polynomial \u03b9 R}\n  (h : disjoint g\u2081.support g\u2082.support) : (g\u2081 + g\u2082).support = g\u2081.support \u222a g\u2082.support :=\nfinsupp.support_add_eq h\n\nlemma support_sum_monomial_subset (S : finset (\u03b9 \u2192\u2080 \u2115)) (f : (\u03b9 \u2192\u2080 \u2115) \u2192 R) :\n  support (\u2211 v in S, monomial v (f v)) \u2286 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 (\u03b9 \u2192\u2080 \u2115)) (f : (\u03b9 \u2192\u2080 \u2115) \u2192 R) :\n  support (\u2211 v in S, monomial v (f v)) = S.filter (\u03bb v, f v \u2260 0) :=\nbegin\n  letI := classical.dec_eq \u03b9,\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 (\u03b9 \u2192\u2080 \u2115)) (f : (\u03b9 \u2192\u2080 \u2115) \u2192 R)\n  (h : \u2203 (s) (hs : s \u2208 S), f s \u2260 0) : \u2211 (s : \u03b9 \u2192\u2080 \u2115) in S, monomial s (f s) \u2260 0 :=\nbegin\n  classical,\n  simp only [\u2190 support_eq_empty, support_sum_monomial_eq, filter_congr_decidable, ne.def],\n  rcases h with \u27e8s, h_S, h_s\u27e9,\n  exact ne_empty_of_mem (mem_filter.mpr \u27e8h_S, h_s\u27e9),\nend\n\nlemma leading_terms_ne_zero {p : mv_polynomial \u03b9 R} (hp : p \u2260 0) : p.leading_terms \u2260 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 (\u03bb (_x : \u03b9) (e : \u2115), e) with v.support.sum v,\n  simp [and_comm],\nend\n\n@[simp]\nlemma total_degree_homogenous_component_of_ne_zero {n : \u2115} {p : mv_polynomial \u03b9 R}\n  (hp : homogeneous_component n p \u2260 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 \u03b9 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 \u03b9 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  : \u2115) (p q : mv_polynomial \u03b9 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 \u03b9 R) (d : \u03b9 \u2192\u2080 \u2115) :\n  coeff d p.leading_terms = if \u2211 i in d.support, d i = p.total_degree then coeff d p else 0 :=\ncoeff_homogeneous_component _ _ _\n\nlemma support_homogeneous_component (n : \u2115) (p : mv_polynomial \u03b9 R) :\n  (homogeneous_component n p).support = p.support.filter (\u03bb d, d.sum (\u03bb _ 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 \u2190 finsupp.support_filter,\n  refl,\nend\n\nlemma support_homogeneous_component_subset (n : \u2115) (p : mv_polynomial \u03b9 R) :\n  (homogeneous_component n p).support \u2286 p.support :=\nbegin\n  rw support_homogeneous_component,\n  exact finset.filter_subset _ _,\nend\n\nlemma support_leading_terms (p : mv_polynomial \u03b9 R) :\n  p.leading_terms.support = p.support.filter (\u03bb d, d.sum (\u03bb _ m, m) = p.total_degree) :=\nsupport_homogeneous_component _ _\n\nlemma support_leading_terms_subset (p : mv_polynomial \u03b9 R) : p.leading_terms.support \u2286 p.support :=\nsupport_homogeneous_component_subset _ _\n\nlemma eq_leading_terms_add (p : mv_polynomial \u03b9 R) (hp : p.total_degree \u2260 0) :\n  \u2203 p_rest : mv_polynomial \u03b9 R,\n    p = p.leading_terms + p_rest \u2227 p_rest.total_degree < p.total_degree :=\nbegin\n  letI := classical.dec_eq \u03b9,\n  existsi (\u2211 (v : \u03b9 \u2192\u2080 \u2115) 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 : \u2200 (x : \u03b9 \u2192\u2080 \u2115) (hx : x \u2208 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 \u2286 p.support,\n    from support_leading_terms_subset _,\n    have : p.leading_terms.support \u2229 p.support = p.leading_terms.support,\n    { rw finset.inter_eq_left_iff_subset,\n      exact this },\n    nth_rewrite 0 \u2190 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 \u2190 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 {\u03b1 \u03b2 : Type*} [semilattice_sup \u03b2] [order_bot \u03b2] (f : \u03b1 \u2192 \u03b2)\n  (S : finset \u03b1) : S.sup f = \u22a5 \u2194 \u2200 s \u2208 S, f s = \u22a5 :=\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 \u03b9 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 {\u03b1 M R : Type*} [semiring R] [add_comm_monoid M] [module R M]\n  [no_zero_smul_divisors R M] {b : R} (hb : b \u2260 0) {g : \u03b1 \u2192\u2080 M} :\n  (b \u2022 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 \u03b9 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 \u03b9 R} (hp : p.total_degree = 0) :\n  \u2203 r : R, p = C r :=\nbegin\n  letI := classical.dec_eq \u03b9,\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 \u03b9 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 \u27e8rp, rfl\u27e9,\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 \u27e8rq, rfl\u27e9,\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 \u27e8wp, hp, tp\u27e9,\n  rw hp,\n  rcases eq_leading_terms_add q hq with \u27e8wq, hq, tq\u27e9,\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 _ \u2264 max (wp * q.leading_terms).total_degree (p.leading_terms * wq + wp * wq).total_degree :\n              total_degree_add _ _\n       ... \u2264 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       ... \u2264 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       ... \u2264 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 \u27e8tp, tq, add_lt_add tp tq\u27e9, },\nend\n\nlemma total_degree_mul_eq {S : Type*} [comm_ring S] [is_domain S] {p q : mv_polynomial \u03b9 S}\n  (hp : p \u2260 0) (hq : q \u2260 0) : (p * q).total_degree = p.total_degree + q.total_degree :=\nbegin\n  rw [\u2190 total_degree_leading_terms, \u2190 total_degree_leading_terms p, \u2190 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 \u03b9] {\u03b1 : Type*} (S : finset \u03b1) (g : \u03b1 \u2192 \u03b9 \u2192\u2080 \u2115)\n  (f : \u03b1 \u2192 R) : support (\u2211 v in S, monomial (g v) (f v)) \u2286 S.image g :=\nbegin\n  letI := classical.dec_eq \u03b1,\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 \u03b9] (p q : mv_polynomial \u03b9 R) :\n  (p * q).support \u2286 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 `\u2200 n : \u2115, prime n \u2192 n \u2264 100`,\n`slim_check` requires that `\u2115` 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 \u2115 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\u2264 100` will be tested. If it is false, `n` is a counter-example of `\u2200\nn : \u2115, prime n \u2192 n \u2264 100` and the test fails. If `n \u2264 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 \u03b1` provides ways of creating examples of type `\u03b1`,\nand given such an example `x : \u03b1`, 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 `\u2115 \u2192 \u2115`.\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 \u03b1` given a sampling function and a\nshrinking function for arbitrary `\u03b1`.\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 (\u03b1 : Type u)\n\nlocal infix ` \u227a `:50 := has_well_founded.r\n\n/-- `sizeof_lt x y` compares the sizes of `x` and `y`. -/\ndef sizeof_lt {\u03b1} [has_sizeof \u03b1] (x y : \u03b1) := sizeof x < sizeof y\n\n/-- `shrink_fn \u03b1` is the type of functions that shrink an\nargument of type `\u03b1` -/\n@[reducible]\ndef shrink_fn (\u03b1 : Type*) [has_sizeof \u03b1] := \u03a0 x : \u03b1, lazy_list { y : \u03b1 // sizeof_lt y x }\n\n/-- `sampleable \u03b1` provides ways of creating examples of type `\u03b1`,\nand given such an example `x : \u03b1`, gives us a way to shrink it\nand find simpler examples.  -/\nclass sampleable :=\n[wf : has_sizeof \u03b1]\n(sample [] : gen \u03b1)\n(shrink : \u03a0 x : \u03b1, lazy_list { y : \u03b1 // @sizeof _ wf y < @sizeof _ wf x } := \u03bb _, 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 \u03b1` given a sampling function and a shrinking function for\narbitrary `\u03b1` -/\nclass sampleable_functor (F : Type u \u2192 Type v) [functor F] :=\n[wf : \u03a0 \u03b1 [has_sizeof \u03b1], has_sizeof (F \u03b1)]\n(sample [] : \u2200 {\u03b1}, gen \u03b1 \u2192 gen (F \u03b1))\n(shrink : \u2200 \u03b1 [has_sizeof \u03b1], shrink_fn \u03b1 \u2192 shrink_fn (F \u03b1))\n(p_repr : \u2200 \u03b1, has_repr \u03b1 \u2192 has_repr (F \u03b1))\n\n/-- `sampleable_bifunctor F` makes it possible to create samples of\nand shrink `F \u03b1 \u03b2` given a sampling function and a shrinking function\nfor arbitrary `\u03b1` and `\u03b2` -/\nclass sampleable_bifunctor (F : Type u \u2192 Type v \u2192 Type w) [bifunctor F] :=\n[wf : \u03a0 \u03b1 \u03b2 [has_sizeof \u03b1] [has_sizeof \u03b2], has_sizeof (F \u03b1 \u03b2)]\n(sample [] : \u2200 {\u03b1 \u03b2}, gen \u03b1 \u2192 gen \u03b2 \u2192 gen (F \u03b1 \u03b2))\n(shrink : \u2200 \u03b1 \u03b2 [has_sizeof \u03b1] [has_sizeof \u03b2], shrink_fn \u03b1 \u2192 shrink_fn \u03b2 \u2192 shrink_fn (F \u03b1 \u03b2))\n(p_repr : \u2200 \u03b1 \u03b2, has_repr \u03b1 \u2192 has_repr \u03b2 \u2192 has_repr (F \u03b1 \u03b2))\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 `\u2115 \u2192 \u2115`.\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 (\u03b1 : Sort u) :=\n(proxy_repr : Type v)\n[wf : has_sizeof proxy_repr]\n(interp [] : proxy_repr \u2192 \u03b1 . 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 {\u03b1} [sampleable \u03b1] [has_repr \u03b1] : sampleable_ext \u03b1 :=\n{ proxy_repr := \u03b1,\n  sample := sampleable.sample \u03b1,\n  shrink := shrink }\n\ninstance sampleable.functor {\u03b1} {F} [functor F] [sampleable_functor F] [sampleable \u03b1] :\n  sampleable (F \u03b1) :=\n{ wf := _,\n  sample := sampleable_functor.sample F (sampleable.sample \u03b1),\n  shrink := sampleable_functor.shrink \u03b1 sampleable.shrink }\n\ninstance sampleable.bifunctor {\u03b1 \u03b2} {F} [bifunctor F] [sampleable_bifunctor F] [sampleable \u03b1]\n  [sampleable \u03b2] : sampleable (F \u03b1 \u03b2) :=\n{ wf := _,\n  sample := sampleable_bifunctor.sample F (sampleable.sample \u03b1) (sampleable.sample \u03b2),\n  shrink := sampleable_bifunctor.shrink \u03b1 \u03b2 sampleable.shrink sampleable.shrink }\n\nset_option default_priority 100\n\ninstance sampleable_ext.functor {\u03b1} {F} [functor F] [sampleable_functor F] [sampleable_ext \u03b1] :\n  sampleable_ext (F \u03b1) :=\n{ wf := _,\n  proxy_repr := F (proxy_repr \u03b1),\n  interp := functor.map (interp _),\n  sample := sampleable_functor.sample F (sampleable_ext.sample \u03b1),\n  shrink := sampleable_functor.shrink _ sampleable_ext.shrink,\n  p_repr := sampleable_functor.p_repr _ sampleable_ext.p_repr }\n\ninstance sampleable_ext.bifunctor {\u03b1 \u03b2} {F} [bifunctor F] [sampleable_bifunctor F]\n  [sampleable_ext \u03b1] [sampleable_ext \u03b2] : sampleable_ext (F \u03b1 \u03b2) :=\n{ wf := _,\n  proxy_repr := F (proxy_repr \u03b1) (proxy_repr \u03b2),\n  interp := bifunctor.bimap (interp _) (interp _),\n  sample := sampleable_bifunctor.sample F (sampleable_ext.sample \u03b1) (sampleable_ext.sample \u03b2),\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 : \u2115) : \u03a0 n : \u2115, n \u2264 k \u2192\n  list { m : \u2115 // has_well_founded.r m k } \u2192 list { m : \u2115 // has_well_founded.r m k }\n| n hn ls :=\nif h : n \u2264 1\n  then ls.reverse\n  else\n    have h\u2082 : 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\u2082),\n    have n / 2 < n, by simpa,\n    let m := n / 2 in\n    have h\u2080 : m \u2264 k, from le_trans (le_of_lt this) hn,\n    have h\u2083 : 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\u2081 : k - m < k,\n      from nat.sub_lt (lt_of_lt_of_le h\u2082 hn) h\u2083,\n    nat.shrink' m h\u2080 (\u27e8k - m, h\u2081\u27e9 :: 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 : \u2115) : list { m : \u2115 // has_well_founded.r m n } :=\nif h : n > 0 then\n  have \u2200 k, 1 < k \u2192 n / k < n, from\n    \u03bb 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  \u27e8n/11, this _ (by norm_num)\u27e9 :: \u27e8n/3, this _ (by norm_num)\u27e9 :: nat.shrink' n n (le_refl _) []\nelse\n  []\n\nopen gen\n\n/--\nTransport a `sampleable` instance from a type `\u03b1` to a type `\u03b2` 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 (\u03b1 : Type u) {\u03b2 : Type u} [sampleable \u03b1] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1)\n  (h : \u2200 (a : \u03b1), sizeof (g (f a)) \u2264 sizeof a) : sampleable \u03b2 :=\n{ wf := \u27e8 sizeof \u2218 g \u27e9,\n  sample := f <$> sample \u03b1,\n  shrink := \u03bb x,\n    have \u2200 a,  sizeof a < sizeof (g x) \u2192 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 \u2115 :=\n{ sample := sized $ \u03bb sz, freq [(1, coe <$> choose_any (fin $ succ (sz^3))),\n                                (3, coe <$> choose_any (fin $ succ sz))] dec_trivial,\n  shrink :=  \u03bb 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 {\u03b1} [has_to_string \u03b1] [sampleable \u03b1]\n  (p : \u03b1 \u2192 Prop) [decidable_pred p] :\n  \u03b1 \u2192 option \u03b1 :=\nwell_founded.fix has_well_founded.wf $ \u03bb x f_rec,\n  do trace sformat!\"{x} : {(shrink x).to_list}\" $ pure (),\n     y \u2190 (shrink x).find (\u03bb 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 \u2115 fin.of_nat' subtype.val $\n\u03bb i, (mod_le _ _ : i % n \u2264 i)\n\n@[priority 100]\ninstance fin.sampleable' {n} : sampleable (fin (succ n)) :=\nsampleable.lift \u2115 fin.of_nat subtype.val $\n\u03bb i, (mod_le _ _ : i % succ n \u2264 i)\n\ninstance pnat.sampleable : sampleable \u2115+ :=\nsampleable.lift \u2115 nat.succ_pnat pnat.nat_pred $ \u03bb 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 \u2124 := \u27e8 int.nat_abs \u27e9\n\nlocal attribute [instance, priority 2000] int.has_sizeof\n\ninstance int.sampleable : sampleable \u2124 :=\n{ wf := _,\n  sample := sized $ \u03bb sz,\n          freq [(1, subtype.val <$> choose (-(sz^3 + 1) : \u2124) (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    \u03bb x, lazy_list.of_list $ (nat.shrink $ int.nat_abs x).bind $\n    \u03bb \u27e8y,h\u27e9, [\u27e8y, h\u27e9, \u27e8-y, by dsimp [sizeof,has_sizeof.sizeof]; rw int.nat_abs_neg; exact h \u27e9] }\n\ninstance bool.sampleable : sampleable bool :=\n{ wf := \u27e8 \u03bb b, if b then 1 else 0 \u27e9,\n  sample := do { x \u2190 choose_any bool,\n                 return x },\n  shrink := \u03bb b, if h : b then lazy_list.singleton \u27e8ff, by cases h; unfold_wf\u27e9\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 {\u03b1 \u03b2} [has_sizeof \u03b1] [has_sizeof \u03b2]\n  (shr_a : shrink_fn \u03b1) (shr_b : shrink_fn \u03b2) : shrink_fn (\u03b1 \u00d7 \u03b2)\n| \u27e8x\u2080,x\u2081\u27e9 :=\n  let xs\u2080 : lazy_list { y : \u03b1 \u00d7 \u03b2 // sizeof_lt y (x\u2080,x\u2081) } :=\n          (shr_a x\u2080).map $ subtype.map (\u03bb a, (a, x\u2081))\n                           (\u03bb x h, by dsimp [sizeof_lt]; unfold_wf; apply h),\n      xs\u2081 : lazy_list { y : \u03b1 \u00d7 \u03b2 // sizeof_lt y (x\u2080,x\u2081) } :=\n          (shr_b x\u2081).map $ subtype.map (\u03bb a, (x\u2080, a))\n                           (\u03bb x h, by dsimp [sizeof_lt]; unfold_wf; apply h) in\n  xs\u2080.append xs\u2081\n\ninstance prod.sampleable : sampleable_bifunctor.{u v} prod :=\n{ wf := _,\n  sample := \u03bb \u03b1 \u03b2 sama samb, do\n              { \u27e8x\u27e9 \u2190 (uliftable.up $ sama : gen (ulift.{max u v} \u03b1)),\n                \u27e8y\u27e9 \u2190 (uliftable.up $ samb : gen (ulift.{max u v} \u03b2)),\n                pure (x,y) },\n  shrink := @prod.shrink,\n  p_repr := @prod.has_repr }\n\ninstance sigma.sampleable {\u03b1 \u03b2} [sampleable \u03b1] [sampleable \u03b2] : sampleable (\u03a3 _ : \u03b1, \u03b2) :=\nsampleable.lift (\u03b1 \u00d7 \u03b2) (\u03bb \u27e8x,y\u27e9, \u27e8x,y\u27e9) (\u03bb \u27e8x,y\u27e9, \u27e8x,y\u27e9) $ \u03bb \u27e8x,y\u27e9, le_refl _\n\n/-- shrinking function for sum types -/\ndef sum.shrink {\u03b1 \u03b2} [has_sizeof \u03b1] [has_sizeof \u03b2] (shrink_\u03b1 : shrink_fn \u03b1)\n  (shrink_\u03b2 : shrink_fn \u03b2) : shrink_fn (\u03b1 \u2295 \u03b2)\n| (sum.inr x) := (shrink_\u03b2 x).map $ subtype.map sum.inr $ \u03bb a,\n  by dsimp [sizeof_lt]; unfold_wf; solve_by_elim\n| (sum.inl x) := (shrink_\u03b1 x).map $ subtype.map sum.inl $ \u03bb a,\n  by dsimp [sizeof_lt]; unfold_wf; solve_by_elim\n\ninstance sum.sampleable : sampleable_bifunctor.{u v} sum :=\n{ wf := _,\n  sample := \u03bb (\u03b1 : Type u) (\u03b2 : Type v) sam_\u03b1 sam_\u03b2,\n            (@uliftable.up_map gen.{u} gen.{max u v} _ _ _ _ (@sum.inl \u03b1 \u03b2) sam_\u03b1 <|>\n             @uliftable.up_map gen.{v} gen.{max v u} _ _ _ _ (@sum.inr \u03b1 \u03b2) sam_\u03b2),\n  shrink := \u03bb \u03b1 \u03b2 I\u03b1 I\u03b2 shr_\u03b1 shr_\u03b2, @sum.shrink _ _ I\u03b1 I\u03b2 shr_\u03b1 shr_\u03b2,\n  p_repr := @sum.has_repr }\n\ninstance rat.sampleable : sampleable \u211a :=\nsampleable.lift (\u2124 \u00d7 \u2115+) (\u03bb x, prod.cases_on x rat.mk_pnat) (\u03bb r, (r.num, \u27e8r.denom, r.pos\u27e9)) $\nbegin\n  intro i,\n  rcases i with \u27e8x,\u27e8y,hy\u27e9\u27e9; unfold_wf;\n  dsimp [rat.mk_pnat],\n  mono*,\n  { rw [\u2190 int.coe_nat_le, \u2190 int.abs_eq_nat_abs, \u2190 int.abs_eq_nat_abs],\n    apply int.abs_div_le_abs },\n  { change _ - 1 \u2264 y-1,\n    apply tsub_le_tsub_right,\n    apply nat.div_le_of_le_mul,\n    suffices : 1 * y \u2264 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 \u2190 choose_nat 0 length dec_trivial,\n                 if x.val = 0 then do\n                   n \u2190 sample \u2115,\n                   pure $ char.of_nat n\n                 else do\n                   i \u2190 choose_nat 0 (characters.length - 1) dec_trivial,\n                   pure (characters.mk_iterator.nextn i).curr },\n  shrink := \u03bb _, lazy_list.nil }\n\ninstance char.sampleable : sampleable char :=\nsampleable_char 3 \" 0123abcABC:,;`\\\\/\"\n\nvariables {\u03b1}\n\nsection list_shrink\n\nvariables [has_sizeof \u03b1] (shr : \u03a0 x : \u03b1, lazy_list { y : \u03b1 // sizeof_lt y x })\n\n\n\nlemma list.sizeof_cons_lt_right (a b : \u03b1) {xs : list \u03b1} (h : sizeof a < sizeof b) :\n  sizeof (a :: xs) < sizeof (b :: xs) :=\nby unfold_wf; assumption\n\nlemma list.sizeof_cons_lt_left (x : \u03b1) {xs xs' : list \u03b1} (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 \u03b1} (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 \u03b1) : 1 \u2264 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 : \u2115) (hk : 0 < k) : \u03a0 (xs : list \u03b1) n,\n  n = xs.length \u2192 lazy_list { ys : list \u03b1 // 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 \u27e8[], this \u27e9\n  else\n    have h\u2082 : k < xs.length, from hn \u25b8 lt_of_le_of_ne (le_of_not_gt hkn) hkn',\n    match list.split_at k xs, rfl : \u03a0 ys, ys = list.split_at k xs \u2192 _ with\n    |  \u27e8xs\u2081,xs\u2082\u27e9, h :=\n      have h\u2084 : xs\u2081 = xs.take k,\n        by simp only [list.split_at_eq_take_drop, prod.mk.inj_iff] at h; tauto,\n      have h\u2083 : xs\u2082 = xs.drop k,\n        by simp only [list.split_at_eq_take_drop, prod.mk.inj_iff] at h; tauto,\n      have sizeof xs\u2082 < sizeof xs,\n        by rw h\u2083; solve_by_elim [list.sizeof_drop_lt_sizeof_of_lt_length],\n      have h\u2081 : n - k = xs\u2082.length,\n        by simp only [h\u2083, \u2190hn, list.length_drop],\n      have h\u2085 : \u2200 (a : list \u03b1), sizeof_lt a xs\u2082 \u2192 sizeof_lt (xs\u2081 ++ a) xs,\n        by intros a h; rw [\u2190 list.take_append_drop k xs, \u2190 h\u2083, \u2190 h\u2084];\n          solve_by_elim [list.sizeof_append_lt_left],\n      lazy_list.cons \u27e8xs\u2082, this\u27e9 $ subtype.map ((++) xs\u2081) h\u2085 <$> list.shrink_removes xs\u2082 (n - k) h\u2081\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 \u03b1)\n| [] := lazy_list.nil\n| (x :: xs) :=\n  lazy_list.append\n    (subtype.map (\u03bb x', x' :: xs) (\u03bb a,  list.sizeof_cons_lt_right _ _) <$> shr x)\n    (subtype.map ((::) x) (\u03bb _, 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 \u03b1) :\n  lazy_list { ys : list \u03b1 // sizeof_lt ys xs } :=\nlet n := xs.length in\nlazy_list.append\n  ((lazy_list.cons n $ (shrink n).reverse.map subtype.val).bind (\u03bb 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 := \u03bb \u03b1 sam_\u03b1, list_of sam_\u03b1,\n  shrink := \u03bb \u03b1 I\u03b1 shr_\u03b1, @list.shrink_with _ I\u03b1 shr_\u03b1,\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 := \u03bb _, 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 \u2124)`\nwill result in the list being cut down but individual\nintegers being kept as is. -/\ndef no_shrink (\u03b1 : Type*) := \u03b1\n\ninstance no_shrink.inhabited {\u03b1} [inhabited \u03b1] : inhabited (no_shrink \u03b1) :=\n\u27e8 (default \u03b1 : \u03b1) \u27e9\n\n/-- Introduction of the `no_shrink` type. -/\ndef no_shrink.mk {\u03b1} (x : \u03b1) : no_shrink \u03b1 := x\n\n/-- Selector of the `no_shrink` type. -/\ndef no_shrink.get {\u03b1} (x : no_shrink \u03b1) : \u03b1 := x\n\ninstance no_shrink.sampleable {\u03b1} [sampleable \u03b1] : sampleable (no_shrink \u03b1) :=\n{ sample := no_shrink.mk <$> sample \u03b1 }\n\ninstance string.sampleable : sampleable string :=\n{ sample := do { x \u2190 list_of (sample char), pure x.as_string },\n  .. sampleable.lift (list char) list.as_string string.to_list $ \u03bb _, le_refl _ }\n\n/-- implementation of `sampleable (tree \u03b1)` -/\ndef tree.sample (sample : gen \u03b1) : \u2115 \u2192 gen (tree \u03b1) | 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 {\u03b1 : Type*} [has_sizeof \u03b1] (t : \u03b1)\n  (sh : \u03a0 x : \u03b1, sizeof_lt x t \u2192 lazy_list { y : \u03b1 // sizeof_lt y x }) :\n  shrink_fn { t' : \u03b1 // sizeof_lt t' t }\n| \u27e8t',ht'\u27e9 := (\u03bb t'' : { y : \u03b1 // sizeof_lt y t' },\n    \u27e8\u27e8t''.val, lt_trans t''.property ht'\u27e9, t''.property\u27e9 ) <$> sh t' ht'\n\nlemma tree.one_le_sizeof {\u03b1} [has_sizeof \u03b1] (t : tree \u03b1) : 1 \u2264 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 \u03b1]\n  (shrink_a : \u03a0 x : \u03b1, shrink_fn { y : \u03b1 // sizeof_lt y x } \u2192\n    list (lazy_list { y : \u03b1 // sizeof_lt y x })) :\n  shrink_fn \u03b1 :=\nwell_founded.fix (sizeof_measure_wf _) $ \u03bb t f_rec,\nlazy_list.join\n    (lazy_list.of_list $\n      shrink_a t $ \u03bb \u27e8t', h\u27e9, rec_shrink _ f_rec _)\n\nlemma rec_shrink_with_eq [has_sizeof \u03b1]\n  (shrink_a : \u03a0 x : \u03b1, shrink_fn { y : \u03b1 // sizeof_lt y x } \u2192\n    list (lazy_list { y : \u03b1 // sizeof_lt y x }))\n  (x : \u03b1) :\n  rec_shrink_with shrink_a x =\n  lazy_list.join\n    (lazy_list.of_list $ shrink_a x $ \u03bb t', rec_shrink _ (\u03bb x h', rec_shrink_with shrink_a x) _) :=\nbegin\n  conv_lhs { rw [rec_shrink_with, well_founded.fix_eq], },\n  congr, ext \u27e8y, h\u27e9, 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 \u03b1] (shrink_a : shrink_fn \u03b1) : shrink_fn (tree \u03b1) :=\nrec_shrink_with $ \u03bb t,\nmatch t with\n| tree.nil := \u03bb f_rec, []\n| (tree.node x t\u2080 t\u2081) :=\n\u03bb f_rec,\n  have h\u2082 : sizeof_lt tree.nil (tree.node x t\u2080 t\u2081),\n    by clear _match; have := tree.one_le_sizeof t\u2080;\n       dsimp [sizeof_lt, sizeof, has_sizeof.sizeof] at *;\n       unfold_wf; linarith,\n  have h\u2080 : sizeof_lt t\u2080 (tree.node x t\u2080 t\u2081),\n    by dsimp [sizeof_lt]; unfold_wf; linarith,\n  have h\u2081 : sizeof_lt t\u2081 (tree.node x t\u2080 t\u2081),\n    by dsimp [sizeof_lt]; unfold_wf; linarith,\n  [lazy_list.of_list [\u27e8tree.nil, h\u2082\u27e9, \u27e8t\u2080, h\u2080\u27e9, \u27e8t\u2081, h\u2081\u27e9],\n   (prod.shrink shrink_a (prod.shrink f_rec f_rec) (x, \u27e8t\u2080, h\u2080\u27e9, \u27e8t\u2081, h\u2081\u27e9)).map\n    $ \u03bb \u27e8\u27e8y,\u27e8t'\u2080, _\u27e9,\u27e8t'\u2081, _\u27e9\u27e9,hy\u27e9, \u27e8tree.node y t'\u2080 t'\u2081,\n      by revert hy; dsimp [sizeof_lt]; unfold_wf; intro; linarith\u27e9]\nend\n\ninstance sampleable_tree : sampleable_functor tree :=\n{ wf := _,\n  sample := \u03bb \u03b1 sam_\u03b1, sized $ tree.sample sam_\u03b1,\n  shrink := \u03bb \u03b1 I\u03b1 shr_\u03b1, @tree.shrink_with _ I\u03b1 shr_\u03b1,\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 (\u03b1 : Type*) := \u03b1\n\n/-- Add the `small` type tag -/\ndef small.mk {\u03b1} (x : \u03b1) : small \u03b1 := x\n\n/-- Type tag that signals to `slim_check` to use large values for a given type. -/\ndef large (\u03b1 : Type*) := \u03b1\n\n/-- Add the `large` type tag -/\ndef large.mk {\u03b1} (x : \u03b1) : large \u03b1 := x\n\ninstance small.functor : functor small := id.monad.to_functor\ninstance large.functor : functor large := id.monad.to_functor\ninstance small.inhabited [inhabited \u03b1] : inhabited (small \u03b1) := \u27e8 (default \u03b1 : \u03b1) \u27e9\ninstance large.inhabited [inhabited \u03b1] : inhabited (large \u03b1) := \u27e8 (default \u03b1 : \u03b1) \u27e9\n\ninstance small.sampleable_functor : sampleable_functor small :=\n{ wf := _,\n  sample := \u03bb \u03b1 samp, gen.resize (\u03bb n, n / 5 + 5) samp,\n  shrink := \u03bb \u03b1 _, id,\n  p_repr := \u03bb \u03b1, id }\n\ninstance large.sampleable_functor : sampleable_functor large :=\n{ wf := _,\n  sample := \u03bb \u03b1 samp, gen.resize (\u03bb n, n * 5) samp,\n  shrink := \u03bb \u03b1 _, id,\n  p_repr := \u03bb \u03b1, id }\n\ninstance ulift.sampleable_functor : sampleable_functor ulift.{u v} :=\n{ wf := \u03bb \u03b1 h, \u27e8 \u03bb \u27e8x\u27e9, @sizeof \u03b1 h x \u27e9,\n  sample := \u03bb \u03b1 samp, uliftable.up_map ulift.up $ samp,\n  shrink := \u03bb \u03b1 _ shr \u27e8x\u27e9, (shr x).map (subtype.map ulift.up (\u03bb a h, h)),\n  p_repr := \u03bb \u03b1 h, \u27e8 @repr \u03b1 h \u2218 ulift.down \u27e9 }\n\n/-!\n## Subtype instances\n\nThe following instances are meant to improve the testing of properties of the form\n`\u2200 i j, i \u2264 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 `\u2115` -/\n\ninstance nat_le.sampleable {y} : slim_check.sampleable { x : \u2115 // x \u2264 y } :=\n{ sample :=\n         do { \u27e8x,h\u27e9 \u2190 slim_check.gen.choose_nat 0 y dec_trivial,\n              pure \u27e8x, h.2\u27e9},\n  shrink := \u03bb \u27e8x, h\u27e9, (\u03bb a : subtype _, subtype.rec_on a $\n    \u03bb x' h', \u27e8\u27e8x', le_trans (le_of_lt h') h\u27e9, h'\u27e9) <$> shrink x }\n\ninstance nat_ge.sampleable {x} : slim_check.sampleable { y : \u2115 // x \u2264 y } :=\n{ sample :=\n         do { (y : \u2115) \u2190 slim_check.sampleable.sample \u2115,\n              pure \u27e8x+y, by norm_num\u27e9 },\n  shrink := \u03bb \u27e8y, h\u27e9, (\u03bb a : { y' // sizeof y' < sizeof (y - x) },\n    subtype.rec_on a $ \u03bb \u03b4 h', \u27e8\u27e8x + \u03b4, nat.le_add_right _ _\u27e9, lt_tsub_iff_left.mp h'\u27e9) <$>\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 : \u2115 // x < y } :=\n{ sample :=\n         do { (y : \u2115) \u2190 slim_check.sampleable.sample \u2115,\n              pure \u27e8x+y+1, by linarith\u27e9 },\n  shrink := \u03bb x, shrink _ }\n\n/-! ### Subtypes of any `linear_ordered_add_comm_group` -/\n\ninstance le.sampleable {y : \u03b1} [sampleable \u03b1] [linear_ordered_add_comm_group \u03b1] :\n  slim_check.sampleable { x : \u03b1 // x \u2264 y } :=\n{ sample :=\n         do { x \u2190 sample \u03b1,\n              pure \u27e8y - |x|, sub_le_self _ (abs_nonneg _) \u27e9 },\n  shrink := \u03bb _, lazy_list.nil }\n\ninstance ge.sampleable {x : \u03b1}  [sampleable \u03b1] [linear_ordered_add_comm_group \u03b1] :\n  slim_check.sampleable { y : \u03b1 // x \u2264 y } :=\n{ sample :=\n         do { y \u2190 sample \u03b1,\n              pure \u27e8x + |y|, by norm_num [abs_nonneg]\u27e9 },\n  shrink := \u03bb _, lazy_list.nil }\n\n\n/-!\n### Subtypes of `\u2124`\n\nSpecializations of `le.sampleable` and `ge.sampleable` for `\u2124` to help instance search.\n-/\n\ninstance int_le.sampleable {y : \u2124} : slim_check.sampleable { x : \u2124 // x \u2264 y } :=\nsampleable.lift \u2115 (\u03bb n, \u27e8y - n, int.sub_left_le_of_le_add $ by simp\u27e9) (\u03bb \u27e8i, h\u27e9, (y - i).nat_abs)\n  (\u03bb n, by unfold_wf; simp [int_le.sampleable._match_1]; ring)\n\ninstance int_ge.sampleable {x : \u2124} : slim_check.sampleable { y : \u2124 // x \u2264 y } :=\nsampleable.lift \u2115 (\u03bb n, \u27e8x + n, by simp\u27e9) (\u03bb \u27e8i, h\u27e9, (i - x).nat_abs)\n  (\u03bb n, by unfold_wf; simp [int_ge.sampleable._match_1]; ring)\n\ninstance int_lt.sampleable {y} : slim_check.sampleable { x : \u2124 // x < y } :=\nsampleable.lift \u2115 (\u03bb n, \u27e8y - (n+1), int.sub_left_lt_of_lt_add $\n    by linarith [int.coe_nat_nonneg n]\u27e9)\n  (\u03bb \u27e8i, h\u27e9, (y - i - 1).nat_abs)\n  (\u03bb n, by unfold_wf; simp [int_lt.sampleable._match_1]; ring)\n\ninstance int_gt.sampleable {x} : slim_check.sampleable { y : \u2124 // x < y } :=\nsampleable.lift \u2115 (\u03bb n, \u27e8x + (n+1), by linarith\u27e9) (\u03bb \u27e8i, h\u27e9, (i - x - 1).nat_abs)\n  (\u03bb n, by unfold_wf; simp [int_gt.sampleable._match_1]; ring)\n\n/-! ### Subtypes of any `list` -/\n\ninstance perm.slim_check {xs : list \u03b1} : slim_check.sampleable { ys : list \u03b1 // list.perm xs ys } :=\n{ sample := permutation_of xs,\n  shrink := \u03bb _, lazy_list.nil }\n\ninstance perm'.slim_check {xs : list \u03b1} :\n  slim_check.sampleable { ys : list \u03b1 // list.perm ys xs } :=\n{ sample := subtype.map id (@list.perm.symm \u03b1 _) <$> permutation_of xs,\n  shrink := \u03bb _, 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 \u2190 io.run_rand $ uliftable.down $\n  do { xs \u2190 (list.range 10).mmap $ g.run \u2218 ulift.up,\n       pure \u27e8xs.map repr\u27e9 },\nxs.mmap' io.put_str_ln\n\n/-- Create a `gen \u03b1` expression from the argument of `#sample` -/\nmeta def mk_generator (e : expr) : tactic (expr \u00d7 expr) := do\nt \u2190 infer_type e,\nmatch t with\n| `(gen %%t) := do\n  repr_inst \u2190 mk_app ``has_repr [t] >>= mk_instance,\n  pure (repr_inst, e)\n| _ := do\n  samp_inst \u2190 to_expr ``(sampleable_ext %%e) >>= mk_instance,\n  repr_inst \u2190 mk_mapp ``sampleable_ext.p_repr [e, samp_inst],\n  gen \u2190 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 \u2190 texpr,\n   of_tactic $ do\n     e \u2190 i_to_expr e,\n     (repr_inst, gen) \u2190 mk_generator e,\n     print_samples \u2190 mk_mapp ``print_samples [none, repr_inst, gen],\n     sample \u2190 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 \u2192 V \u2192 Sort*\n| nil {c : V} : word c c\n| cons_p {c d e : V} (p : c \u27f6 d) (w : word d e) : word c e\n| cons_n {c d e : V} (p : d \u27f6 c) (w : word d e) : word c e\n\ndef word.length : \u03a0 {c d : V}, word c d \u2192 \u2115\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 \u27f6 d) : word c d := (word.cons_p p word.nil)\n@[pattern]\ndef letter_n {c d : V} (p : c \u27f6 d) : word d c := (word.cons_n p word.nil)\n\ndef word.append  : \u03a0 {c d e : V}, word c d \u2192 word d e \u2192 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 \u27f6 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 \u27f6 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 ` \u226b* `:100 := word.append\n\ndef word.reverse : \u03a0 {c d : V}, word c d \u2192 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 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  (\u2203 (a b : V) (q\u2080 : word c a) (q\u2081 : word a d) (f : a \u27f6 b), p = q\u2080 \u226b*  (letter_p f) \u226b* (letter_n f) \u226b* q\u2081 \u2227 q = q\u2080 \u226b* q\u2081)\n\u2228 (\u2203 (a b : V) (q\u2080 : word c a) (q\u2081 : word a d) (f : b \u27f6 a), p = q\u2080 \u226b* (letter_n f) \u226b* (letter_p f) \u226b* q\u2081 \u2227 q = q\u2080 \u226b* q\u2081)\n\n@[simp]\nlemma red_step.reverse {c d : V} (p\u2080 p\u2081 : word c d) : red_step p\u2080.reverse p\u2081.reverse \u2194 red_step p\u2080 p\u2081 :=\nbegin\n  suffices : \u2200 c d (p\u2080 p\u2081 : word c d),  red_step p\u2080 p\u2081 \u2192 red_step p\u2080.reverse p\u2081.reverse, \n  { split, rotate, exact this c d p\u2080 p\u2081,\n    rintro h,\n    rw  [\u2190word.reverse_reverse p\u2080, \u2190word.reverse_reverse p\u2081],\n    exact this d c _ _ h, },\n  rintro c d p\u2080 p\u2081 (\u27e8u,v,r\u2080,r\u2081,f,rfl,rfl\u27e9|\u27e8u,v,r\u2080,r\u2081,f,rfl,rfl\u27e9),\n  { left, use [u,v,r\u2081.reverse,r\u2080.reverse,f], simp, },\n  { right, use [u,v,r\u2081.reverse,r\u2080.reverse,f], simp, },\nend\n\n@[simp]\nlemma red_step.append_left_congr  {c d e : V} {p\u2080 p\u2081 : word c d} {q : word d e} : \n  red_step p\u2080 p\u2081 \u2192 red_step (p\u2080 \u226b* q) (p\u2081 \u226b* q) :=\nbegin \n  rintro (\u27e8u,v,r\u2080,r\u2081,f,rfl,rfl\u27e9|\u27e8u,v,r\u2080,r\u2081,f,rfl,rfl\u27e9),\n  { left, use [u,v,r\u2080,r\u2081.append q,f],simp, },\n  { right, use [u,v,r\u2080,r\u2081.append q,f],simp, },\nend\n\n@[simp]\nlemma red_step.append_right_congr  {c d e : V} {p : word c d} {q\u2080 q\u2081 : word d e} :  \n  red_step q\u2080 q\u2081 \u2192 red_step (p \u226b* q\u2080) (p \u226b* q\u2081) :=\nbegin \n  rintro (\u27e8u,v,r\u2080,r\u2081,f,rfl,rfl\u27e9|\u27e8u,v,r\u2080,r\u2081,f,rfl,rfl\u27e9),\n  { left, use [u,v,p.append r\u2080,r\u2081,f],simp, },\n  { right, use [u,v,p.append r\u2080,r\u2081,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 := \u03bb c d, quot (@red_step V _ c d) }\n\ndef quot_comp { c d e : free_groupoid V} (p : c \u27f6 d) (q : d \u27f6 e) : c \u27f6 e :=\nquot.lift_on \n  p \n  (\u03bb pp, quot.lift_on q \n    (\u03bb qq, quot.mk _ (pp \u226b* qq))\n    (\u03bb q\u2080 q\u2081 redq, quot.sound $ red_step.append_right_congr redq))\n  (\u03bb p\u2080 p\u2081 redp, quot.induction_on q $ \u03bb 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 := \u03bb a b c p q, quot_comp p q }\n\nlemma id_quot_comp { c d : free_groupoid V} (p : c \u27f6 d) : quot_comp (\ud835\udfd9 c) p = p :=\nquot.induction_on p $ \u03bb pp, quot.eqv_gen_sound $ eqv_gen.refl pp\n\nlemma quot_comp_id { c d : free_groupoid V} (p : c \u27f6 d) : quot_comp p (\ud835\udfd9 d) = p :=\nquot.induction_on p $ \u03bb 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 \u27f6 d) (q : d \u27f6 e)  (r : e \u27f6 f) :\n  quot_comp (quot_comp p q) r = quot_comp p (quot_comp q r) :=\nquot.induction_on\u2083 p q r $ \u03bb 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' := \u03bb a b p, id_quot_comp p\n  , comp_id' := \u03bb a b p, quot_comp_id p\n  , assoc' := \u03bb a b c d p q r, quot_comp_assoc p q r }\n\ndef quot_inv {c d : free_groupoid V} (p : c \u27f6 d) : d  \u27f6 c :=\nquot.lift_on p\n  (\u03bb pp, quot.mk (@red_step V (_inst_1) d c) pp.reverse)\n  (\u03bb p\u2080 p\u2081 redp , quot.sound $ by {simp only [red_step.reverse], exact redp })\n\nlemma quot_inv_inv {c d : free_groupoid V} (p : c \u27f6 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 \u27f6 d)  : (quot_inv p) \u226b p = \ud835\udfd9 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 \u226b* 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 \u226b* 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 \u27f6 d)  : quot_comp p (quot_inv p) = \ud835\udfd9 c :=\nbegin\n  nth_rewrite 0 \u2190quot_inv_inv p,\n  apply quot_comp_inv,\nend\n\ninstance : groupoid (free_groupoid V) :=\n{ to_category := free.free_groupoid_category\n, inv := \u03bb a b p, quot_inv p\n, inv_comp' := \u03bb a b p, (quot_comp_inv p)\n, comp_inv' := \u03bb a b p, quot_inv_comp p }\n\n@[simp]\nlemma quot_cons_p {c d e : V} (f : c \u27f6 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 \u27f6 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 \u03b9 : prefunctor V (free_groupoid V) := \n{ obj := \u03bb x, x \n, map := \u03bb x y p, quot.mk _ (letter_p p)}\n\ndef lift_word {V' : Type u'} [G' : groupoid V']\n  (\u03c6 : prefunctor V V') : \u03a0 {x y : V} (w : word x y), (\u03c6.obj x) \u27f6 (\u03c6.obj y)\n| x _ (word.nil) := \ud835\udfd9 (\u03c6.obj x)\n| x z (@word.cons_p _ _ _ y _ p w) := (\u03c6.map p) \u226b (lift_word w)\n| x z (@word.cons_n _ _ _ y _ p w) := (G'.inv $ \u03c6.map p) \u226b (lift_word w)\n\n@[simp]\nlemma lift_word_nil {V' : Type u'} [G' : groupoid V']\n  (\u03c6 : prefunctor V V') : \u03a0 (x : V),  (lift_word \u03c6 (word.nil : word x x)) = \ud835\udfd9 (\u03c6.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  (\u03c6 : prefunctor V V') {x y z : V} (f : x \u27f6 y) (w : word y z): (lift_word \u03c6 $ word.cons_p f w) = (\u03c6.map f) \u226b (lift_word \u03c6 w) := rfl\n\n@[simp]\nlemma lift_word_cons_n {V' : Type u'} [G' : groupoid V']\n  (\u03c6 : prefunctor V V') {x y z : V} (f : y \u27f6 x) (w : word y z): (lift_word \u03c6 $ word.cons_n f w) = (inv $ \u03c6.map f) \u226b (lift_word \u03c6 w) := rfl\n\n\n@[simp]\nlemma lift_word_letter_p {V' : Type u'} [G' : groupoid V']\n  (\u03c6 : prefunctor V V') : \u03a0 (x y : V) (u : x \u27f6 y),  (lift_word \u03c6 ( letter_p u : word x y)) = \u03c6.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  (\u03c6 : prefunctor V V') : \u03a0 (x y : V) (u : y \u27f6 x),  (lift_word \u03c6 (letter_n u : word x y)) = G'.inv (\u03c6.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'] (\u03c6 : prefunctor V V') \n  {x y z : V} (u : word x y) (w : word y z) : lift_word \u03c6 (u \u226b* w) = (lift_word \u03c6 u) \u226b (lift_word \u03c6 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 (\ud835\udfd9 v) = \ud835\udfd9 v := sorry\n@[simp] lemma _root_.category_theory.groupoid.inv_comp'' {V : Type*} [G : groupoid V] \n  {u v w : V} (f : u \u27f6 v) (g : v \u27f6 w) : G.inv (f \u226b g) = (G.inv g) \u226b (G.inv f) := sorry\n@[simp] lemma _root_.category_theory.groupoid.inv_inv {V : Type*} [G : groupoid V] (u v : V) [f : u \u27f6 v] : G.inv (G.inv f) = f := \n  calc G.inv (G.inv f) = (G.inv (G.inv f)) \u226b (\ud835\udfd9 v) : by rw category.comp_id\n                  ... = (G.inv (G.inv f)) \u226b (G.inv f \u226b f) : by rw \u2190groupoid.inv_comp\n                  ... = (G.inv (G.inv f) \u226b G.inv f) \u226b f : by rw \u2190category.assoc\n                  ... = (\ud835\udfd9 u) \u226b 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'] (\u03c6 : prefunctor V V')\n  {x y : V} (u : word x y) : lift_word \u03c6 (u.reverse) = G'.inv (lift_word \u03c6 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  (\u03c6 : prefunctor V V') : \u03a0 {x y : V} (w\u2080 w\u2081 : word x y) (redw : red_step w\u2080 w\u2081), lift_word \u03c6 w\u2080 = lift_word \u03c6 w\u2081 :=\nbegin\n  rintros x y w\u2080 w\u2081 redw,\n  dsimp [red_step] at redw,\n  rcases redw with (\u27e8u,v,r\u2080,r\u2081,p,rfl,rfl\u27e9|\u27e8u,v,r\u2080,r\u2081,p,rfl,rfl\u27e9),\n  { rw [\u2190word.reverse_letter_p p],\n    simp only [word.append_assoc, lift_word_append, lift_word_reverse],\n    nth_rewrite_lhs 1 \u2190category.assoc, \n    rw groupoid.comp_inv, simp only [category.id_comp], },\n  { rw [\u2190word.reverse_letter_n p],\n    simp only [word.append_assoc, lift_word_append, lift_word_reverse],\n    nth_rewrite_lhs 1 \u2190category.assoc, \n    rw groupoid.comp_inv, simp only [category.id_comp], },\nend\n\ndef lift {V' : Type u'} [G' : groupoid V']\n  (\u03c6 : prefunctor V V') : free_groupoid V \u2964 V' :=\n{ obj := \u03c6.obj\n, map := \u03bb x y, quot.lift (\u03bb p, lift_word \u03c6 p) (\u03bb p\u2080 p\u2081 (redp : red_step p\u2080 p\u2081), lift_word_congr \u03c6 p\u2080 p\u2081 redp)\n, map_id' := \u03bb x, by { dsimp only [lift_word,category_struct.id], refl,  }\n, map_comp' := \u03bb x y z f g, by { refine quot.induction_on\u2082 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 \u2964 D} \n  (h_obj : \u2200 X, F.obj X = G.obj X)\n  (h_map : \u2200 (X Y : C) (f : X \u27f6 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 : \u2200 X, F.obj X = G.obj X)\n  (h_map : \u2200 (X Y : V) (f : X \u27f6 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  (\u03c6 : prefunctor V V') : \u03b9.comp (lift \u03c6).to_prefunctor = \u03c6 :=\nbegin\n  ext, rotate,\n  rcases \u03c6 with \u27e8\u03c6o,\u03c6m\u27e9,\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] (\u03c6 : C \u2964 D)\n  {c d : C} (f : c \u27f6 d) :  \n  \u03c6.map (G.inv f) = H.inv (\u03c6.map f) := \ncalc \u03c6.map (G.inv f) = (\u03c6.map $ G.inv f) \u226b (\ud835\udfd9 $ \u03c6.obj c) : by rw [category.comp_id]\n                 ... = (\u03c6.map $ G.inv f) \u226b ((\u03c6.map f) \u226b (H.inv $ \u03c6.map f)) : by rw [comp_inv]\n                 ... = ((\u03c6.map $ G.inv f) \u226b (\u03c6.map f)) \u226b (H.inv $ \u03c6.map f) : by rw [category.assoc]\n                 ... = (\u03c6.map $ G.inv f \u226b f) \u226b (H.inv $ \u03c6.map f) : by rw [functor.map_comp']\n                 ... = (H.inv $ \u03c6.map f) : by rw [inv_comp,functor.map_id,category.id_comp]            \n\n\nlemma lift_unique (V' : Type u') [G' : groupoid V']\n  (\u03c6 : prefunctor V V') (\u03a6 : free_groupoid V \u2964 V') : (\u03b9.comp \u03a6.to_prefunctor) = \u03c6 \u2192 \u03a6 = (lift \u03c6) :=\nbegin\n  rintro h, subst h,\n  fapply functor.ext',\n  { rintro x, dsimp [lift,\u03b9], 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 \u03a6 x, },\n    { rintro x y z p w IHw, \n      rw [quot_cons_p],\n      have : \u03a6.map (quot_comp (quot.mk red_step  $ letter_p p ) (quot.mk red_step w)) = \u03a6.map ((quot.mk red_step  $ letter_p p ) \u226b  (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 : \u03a6.map (quot_comp (quot.mk red_step  $ letter_n p ) (quot.mk red_step w)) = \u03a6.map ((quot.mk red_step $ letter_n p ) \u226b  (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,\u03b9], rw \u2190word.reverse_letter_p,  \n        convert functor.groupoid_map_inv \u03a6 (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 : \u03a0 {B : Type} (b : B), a == b \u2192 Type} (H\u2081 : a == b) (H\u2082 : C a (refl a)) :\n    C b H\u2081 :=\n  heq.rec (\u03bb H\u2081 : a == a, show C a H\u2081, from H\u2082) H\u2081 H\u2081\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 \u2192 Type.{v}} {a a' : A} {b : B}\n\n  theorem hcongr_fun {f : \u03a0 x, P x} {f' : \u03a0 x, P' x} (a : A) (H\u2081 : f == f') (H\u2082 : P = P') :\n    f a == f' a :=\n  begin\n    cases H\u2082, cases H\u2081, reflexivity\n  end\n\n  theorem hcongr {P' : A' \u2192 Type} {f : \u03a0 a, P a} {f' : \u03a0 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 : \u03a0x, P x) {a b : A} (H : a = b) : f a == f b :=\n  H \u25b8 (heq.refl (f a))\nend\n\nsection\n  variables {A : Type} {B : A \u2192 Type} {C : \u03a0a, B a \u2192 Type} {D : \u03a0a b, C a b \u2192 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 : \u03a0a 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 : \u03a0a 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 \u2192 Type.{v}} {a a' : A} {b : B}\n\n  -- should H\u2081 be explicit (useful in e.g. hproof_irrel)\n  theorem eq_rec_to_heq {H\u2081 : a = a'} {p : P a} {p' : P a'} (H\u2082 : eq.rec_on H\u2081 p = p') : p == p' :=\n  by subst H\u2081; subst H\u2082\n\n  theorem cast_to_heq {H\u2081 : A = B} (H\u2082 : cast H\u2081 a = b) : a == b :=\n  eq_rec_to_heq H\u2082\n\n  theorem hproof_irrel {a b : Prop} (H : a = b) (H\u2081 : a) (H\u2082 : b) : H\u2081 == H\u2082 :=\n  eq_rec_to_heq (proof_irrel (cast H H\u2081) H\u2082)\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 \u2b1d Hbc) a :=\n  by subst Hab\n\n  theorem pi_eq (H : P = P') : (\u03a0 x, P x) = (\u03a0 x, P' x) :=\n  by subst H\n\n  theorem rec_on_app (H : P = P') (f : \u03a0 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 : \u03a0 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 : \u03a0 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 \u2192 Type} {B' : A \u2192 Type} {f : \u03a0 x, B x} {g : \u03a0 x, B' x}\n                (H : \u2200 a, f a == g a) : f == g :=\ncast_to_heq (funext (\u03bb a, eq_of_heq (heq.trans (cast_app (funext (\u03bb x, type_eq_of_heq (H x))) f a) (H a))))\n\nsection\n  variables {A : Type} {B : A \u2192 Type} {C : \u03a0a, B a \u2192 Type} {D : \u03a0a b, C a b \u2192 Type}\n            {E : \u03a0a b c, D a b c \u2192 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 : \u03a0a 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 : \u03a0a, B a \u2192 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 : \u03a0a b, C a b \u2192 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 : \u03a0a b c, D a b c \u2192 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 : \u03a0a b, C a b \u2192 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 : \u03a0a b c, D a b c \u2192 F) (Ha : a = a') (Hb : b == b')\n      (Hc : c == c')\n      (Hd : cast (dcongr_arg3 D Ha (!eq.rec_on_irrel_arg \u2b1d heq.to_cast_eq Hb)\n                                   (!eq.rec_on_irrel_arg \u2b1d 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 : \u03a0a b c, D a b c \u2192 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 : \u2115} (a : x = 1) : true :=\nbegin\n  suffices : false, trivial,\n  wlog h : x = y,\n  { guard_target x = y \u2228 y = x,\n    admit },\n  { guard_hyp h : x = y,\n    guard_hyp a : x = 1,\n    admit }\nend\n\nexample {x y : \u2115} : true :=\nbegin\n  suffices : false, trivial,\n  wlog h : x \u2264 y,\n  { guard_hyp h : x \u2264 y,\n    guard_target false,\n    admit }\nend\n\nexample {x y z : \u2115} : true :=\nbegin\n  suffices : false, trivial,\n  wlog : x \u2264 y + z using x y,\n  { guard_target x \u2264 y + z \u2228 y \u2264 x + z,\n    admit },\n  { guard_hyp case : x \u2264 y + z,\n    guard_target false,\n    admit },\nend\n\nexample {x : \u2115} (S\u2080 S\u2081 : set \u2115) (P : \u2115 \u2192 Prop)\n  (h : x \u2208 S\u2080 \u222a S\u2081) : true :=\nbegin\n  suffices : false, trivial,\n  wlog h' : x \u2208 S\u2080 using S\u2080 S\u2081,\n  { guard_target x \u2208 S\u2080 \u2228 x \u2208 S\u2081,\n    admit },\n  { guard_hyp h  : x \u2208 S\u2080 \u222a S\u2081,\n    guard_hyp h' : x \u2208 S\u2080,\n    admit }\nend\n\nexample {n m i : \u2115} {p : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 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 \u2228 p n i m \u2228 p i n m,\n    admit },\n  { guard_hyp case : p n m i,\n    admit }\nend\n\nexample {n m i : \u2115} {p : \u2115 \u2192 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 \u2228 p m \u2228 p i,\n    admit },\n  { guard_hyp case : p n,\n    admit }\nend\n\nexample {n m i : \u2115} {p : \u2115 \u2192 \u2115 \u2192 Prop} {q : \u2115 \u2192 \u2115 \u2192 \u2115 \u2192 Prop} : true :=\nbegin\n  suffices : q n m i, trivial,\n  have h : p n i \u2228 p i m \u2228 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 \u2229 (B \u222a C) = (A \u2229 B) \u222a (A \u2229 C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    cases hyp,\n    wlog x_in : x \u2208 B using B C,\n    { assumption },\n    { exact or.inl \u27e8hyp_left, x_in\u27e9 } },\n  { intro hyp,\n    wlog x_in : x \u2208 A \u2229 B using B C,\n    { assumption },\n    { exact \u27e8x_in.left, or.inl x_in.right\u27e9 } }\nend\n\nexample (X : Type) (A B C : set X) : A \u2229 (B \u222a C) = (A \u2229 B) \u222a (A \u2229 C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    wlog x_in : x \u2208 B := hyp.2 using B C,\n    { exact or.inl \u27e8hyp.1, x_in\u27e9 } },\n  { intro hyp,\n    wlog x_in : x \u2208 A \u2229 B := hyp using B C,\n    { exact \u27e8x_in.left, or.inl x_in.right\u27e9 } }\nend\n\nexample (X : Type) (A B C : set X) : A \u2229 (B \u222a C) = (A \u2229 B) \u222a (A \u2229 C) :=\nbegin\n  ext x,\n  split,\n  { intro hyp,\n    cases hyp,\n    wlog x_in : x \u2208 B := hyp_right using B C,\n    { exact or.inl \u27e8hyp_left, x_in\u27e9 }, },\n  { intro hyp,\n    wlog x_in : x \u2208 A \u2229 B := hyp using B C,\n    { exact \u27e8x_in.left, or.inl x_in.right\u27e9 } }\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\u2082\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 \u2192 walking_cospan \u2192 Type v := wide_pullback_shape.hom\n\n/-- The left arrow of the walking cospan. -/\n@[pattern] abbreviation hom.inl : left \u27f6 one := wide_pullback_shape.hom.term _\n/-- The right arrow of the walking cospan. -/\n@[pattern] abbreviation hom.inr : right \u27f6 one := wide_pullback_shape.hom.term _\n/-- The identity arrows of the walking cospan. -/\n@[pattern] abbreviation hom.id (X : walking_cospan) : X \u27f6 X := wide_pullback_shape.hom.id X\n\ninstance (X Y : walking_cospan) : subsingleton (X \u27f6 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 \u2192 walking_span \u2192 Type v := wide_pushout_shape.hom\n\n/-- The left arrow of the walking span. -/\n@[pattern] abbreviation hom.fst : zero \u27f6 left := wide_pushout_shape.hom.init _\n/-- The right arrow of the walking span. -/\n@[pattern] abbreviation hom.snd : zero \u27f6 right := wide_pushout_shape.hom.init _\n/-- The identity arrows of the walking span. -/\n@[pattern] abbreviation hom.id (X : walking_span) : X \u27f6 X := wide_pushout_shape.hom.id X\n\ninstance (X Y : walking_span) : subsingleton (X \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z) : walking_cospan \u2964 C :=\nwide_pullback_shape.wide_cospan Z\n  (\u03bb j, walking_pair.cases_on j X Y) (\u03bb 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 \u27f6 Y) (g : X \u27f6 Z) : walking_span \u2964 C :=\nwide_pushout_shape.wide_span X\n  (\u03bb j, walking_pair.cases_on j Y Z) (\u03bb j, walking_pair.cases_on j f g)\n\n@[simp] lemma cospan_left {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z) :\n  (cospan f g).obj walking_cospan.left = X := rfl\n@[simp] lemma span_left {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z) :\n  (span f g).obj walking_span.left = Y := rfl\n\n@[simp] lemma cospan_right {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z) :\n  (cospan f g).obj walking_cospan.right = Y := rfl\n@[simp] lemma span_right {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z) :\n  (span f g).obj walking_span.right = Z := rfl\n\n@[simp] lemma cospan_one {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z) :\n  (cospan f g).obj walking_cospan.one = Z := rfl\n@[simp] lemma span_zero {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z) :\n  (span f g).obj walking_span.zero = X := rfl\n\n@[simp] lemma cospan_map_inl {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z) :\n  (cospan f g).map walking_cospan.hom.inl = f := rfl\n@[simp] lemma span_map_fst {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z) :\n  (cospan f g).map walking_cospan.hom.inr = g := rfl\n@[simp] lemma span_map_snd {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z) :\n  (span f g).map walking_span.hom.snd = g := rfl\n\nlemma cospan_map_id {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z) (w : walking_cospan) :\n  (cospan f g).map (walking_cospan.hom.id w) = \ud835\udfd9 _ := rfl\nlemma span_map_id {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z) (w : walking_span) :\n  (span f g).map (walking_span.hom.id w) = \ud835\udfd9 _ := 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 \u2964 C) :\n  F \u2245 cospan (F.map inl) (F.map inr) :=\nnat_iso.of_components (\u03bb 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 \u2964 C) :\n  F \u2245 span (F.map fst) (F.map snd) :=\nnat_iso.of_components (\u03bb 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 \u27f6 Z` and\n    `g : Y \u27f6 Z`.-/\nabbreviation pullback_cone (f : X \u27f6 Z) (g : Y \u27f6 Z) := cone (cospan f g)\n\nnamespace pullback_cone\nvariables {f : X \u27f6 Z} {g : Y \u27f6 Z}\n\n/-- The first projection of a pullback cone. -/\nabbreviation fst (t : pullback_cone f g) : t.X \u27f6 X := t.\u03c0.app walking_cospan.left\n\n/-- The second projection of a pullback cone. -/\nabbreviation snd (t : pullback_cone f g) : t.X \u27f6 Y := t.\u03c0.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 : \u03a0 (s : pullback_cone f g), s.X \u27f6 t.X)\n  (fac_left : \u2200 (s : pullback_cone f g), lift s \u226b t.fst = s.fst)\n  (fac_right : \u2200 (s : pullback_cone f g), lift s \u226b t.snd = s.snd)\n  (uniq : \u2200 (s : pullback_cone f g) (m : s.X \u27f6 t.X)\n    (w : \u2200 j : walking_cospan, m \u226b t.\u03c0.app j = s.\u03c0.app j), m = lift s) :\n  is_limit t :=\n{ lift := lift,\n  fac' := \u03bb s j, option.cases_on j\n    (by { rw [\u2190 s.w inl, \u2190 t.w inl, \u2190category.assoc], congr, exact fac_left s, } )\n    (\u03bb 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 : \u03a0 (s : pullback_cone f g),\n    {l // l \u226b t.fst = s.fst \u2227 l \u226b t.snd = s.snd \u2227\n            \u2200 {m}, m \u226b t.fst = s.fst \u2192 m \u226b t.snd = s.snd \u2192 m = l}) :\nlimits.is_limit t :=\npullback_cone.is_limit_aux t\n  (\u03bb s, (create s).1)\n  (\u03bb s, (create s).2.1)\n  (\u03bb s, (create s).2.2.1)\n  (\u03bb 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 \u27f6 X` and `snd : W \u27f6 Y`\n    such that `fst \u226b f = snd \u226b g`. -/\n@[simps]\ndef mk {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) : pullback_cone f g :=\n{ X := W,\n  \u03c0 := { app := \u03bb j, option.cases_on j (fst \u226b f) (\u03bb j', walking_pair.cases_on j' fst snd) } }\n\n@[simp] lemma mk_\u03c0_app_left {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n  (mk fst snd eq).\u03c0.app walking_cospan.left = fst := rfl\n@[simp] lemma mk_\u03c0_app_right {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n  (mk fst snd eq).\u03c0.app walking_cospan.right = snd := rfl\n@[simp] lemma mk_\u03c0_app_one {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n  (mk fst snd eq).\u03c0.app walking_cospan.one = fst \u226b f := rfl\n\n@[simp] lemma mk_fst {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n  (mk fst snd eq).fst = fst := rfl\n@[simp] lemma mk_snd {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n  (mk fst snd eq).snd = snd := rfl\n\n@[reassoc] lemma condition (t : pullback_cone f g) : fst t \u226b f = snd t \u226b 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 \u27f6 t.X}\n  (h\u2080 : k \u226b fst t = l \u226b fst t) (h\u2081 : k \u226b snd t = l \u226b snd t) :\n  \u2200 (j : walking_cospan), k \u226b t.\u03c0.app j = l \u226b t.\u03c0.app j\n| (some walking_pair.left) := h\u2080\n| (some walking_pair.right) := h\u2081\n| none := by rw [\u2190 t.w inl, reassoc_of h\u2080]\n\nlemma is_limit.hom_ext {t : pullback_cone f g} (ht : is_limit t) {W : C} {k l : W \u27f6 t.X}\n  (h\u2080 : k \u226b fst t = l \u226b fst t) (h\u2081 : k \u226b snd t = l \u226b snd t) : k = l :=\nht.hom_ext $ equalizer_ext _ h\u2080 h\u2081\n\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W \u27f6 X` and `k : W \u27f6 Y` are such that\n    `h \u226b f = k \u226b g`, then we have `l : W \u27f6 t.X` satisfying `l \u226b fst t = h` and `l \u226b snd t = k`.\n    -/\ndef is_limit.lift' {t : pullback_cone f g} (ht : is_limit t) {W : C} (h : W \u27f6 X) (k : W \u27f6 Y)\n  (w : h \u226b f = k \u226b g) : {l : W \u27f6 t.X // l \u226b fst t = h \u2227 l \u226b snd t = k} :=\n\u27e8ht.lift $ pullback_cone.mk _ _ w, ht.fac _ _, ht.fac _ _\u27e9\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 \u27f6 X} {snd : W \u27f6 Y} (eq : fst \u226b f = snd \u226b g)\n  (lift : \u03a0 (s : pullback_cone f g), s.X \u27f6 W)\n  (fac_left : \u2200 (s : pullback_cone f g), lift s \u226b fst = s.fst)\n  (fac_right : \u2200 (s : pullback_cone f g), lift s \u226b snd = s.snd)\n  (uniq : \u2200 (s : pullback_cone f g) (m : s.X \u27f6 W)\n    (w_fst : m \u226b fst = s.fst) (w_snd : m \u226b snd = s.snd), m = lift s) :\n  is_limit (mk fst snd eq) :=\nis_limit_aux _ lift fac_left fac_right\n  (\u03bb 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 \u27f6 X} {k : W \u27f6 Y}\n  {comm : h \u226b f = k \u226b g} (t : is_limit (mk _ _ comm.symm)) :\n  is_limit (mk _ _ comm) :=\nis_limit_aux' _ $ \u03bb s,\nbegin\n  refine \u27e8(is_limit.lift' t _ _ s.condition.symm).1,\n          (is_limit.lift' t _ _ _).2.2,\n          (is_limit.lift' t _ _ _).2.1, \u03bb m m\u2081 m\u2082, t.hom_ext _\u27e9,\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 `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y) [mono f] :\n  is_limit (mk (\ud835\udfd9 X) (\ud835\udfd9 X) rfl : pullback_cone f f) :=\nis_limit.mk _\n  (\u03bb s, s.fst)\n  (\u03bb s, category.comp_id _)\n  (\u03bb s, by rw [\u2190cancel_mono f, category.comp_id, s.condition])\n  (\u03bb s m m\u2081 m\u2082, by simpa using m\u2081)\n\n/--\n`f` is a mono if the pullback cone `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y)\n  (t : is_limit (mk (\ud835\udfd9 X) (\ud835\udfd9 X) rfl : pullback_cone f f)) :\n  mono f :=\n\u27e8\u03bb Z g h eq, by { rcases pullback_cone.is_limit.lift' t _ _ eq with \u27e8_, rfl, rfl\u27e9, refl } \u27e9\n\nend pullback_cone\n\n/-- A pushout cocone is just a cocone on the span formed by two morphisms `f : X \u27f6 Y` and\n    `g : X \u27f6 Z`.-/\nabbreviation pushout_cocone (f : X \u27f6 Y) (g : X \u27f6 Z) := cocone (span f g)\n\nnamespace pushout_cocone\n\nvariables {f : X \u27f6 Y} {g : X \u27f6 Z}\n\n/-- The first inclusion of a pushout cocone. -/\nabbreviation inl (t : pushout_cocone f g) : Y \u27f6 t.X := t.\u03b9.app walking_span.left\n\n/-- The second inclusion of a pushout cocone. -/\nabbreviation inr (t : pushout_cocone f g) : Z \u27f6 t.X := t.\u03b9.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 : \u03a0 (s : pushout_cocone f g), t.X \u27f6 s.X)\n  (fac_left : \u2200 (s : pushout_cocone f g), t.inl \u226b desc s = s.inl)\n  (fac_right : \u2200 (s : pushout_cocone f g), t.inr \u226b desc s = s.inr)\n  (uniq : \u2200 (s : pushout_cocone f g) (m : t.X \u27f6 s.X)\n    (w : \u2200 j : walking_span, t.\u03b9.app j \u226b m = s.\u03b9.app j), m = desc s) :\n  is_colimit t :=\n{ desc := desc,\n  fac' := \u03bb s j, option.cases_on j (by { simp [\u2190 s.w fst, \u2190 t.w fst, fac_left s] } )\n                    (\u03bb 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 : \u03a0 (s : pushout_cocone f g),\n    {l // t.inl \u226b l = s.inl \u2227 t.inr \u226b l = s.inr \u2227\n            \u2200 {m}, t.inl \u226b m = s.inl \u2192 t.inr \u226b m = s.inr \u2192 m = l}) :\nis_colimit t :=\nis_colimit_aux t\n  (\u03bb s, (create s).1)\n  (\u03bb s, (create s).2.1)\n  (\u03bb s, (create s).2.2.1)\n  (\u03bb 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 \u27f6 W` and `inr : Z \u27f6 W` such\n    that `f \u226b inl = g \u21a0 inr`. -/\n@[simps]\ndef mk {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) : pushout_cocone f g :=\n{ X := W,\n  \u03b9 := { app := \u03bb j, option.cases_on j (f \u226b inl) (\u03bb j', walking_pair.cases_on j' inl inr) } }\n\n@[simp] lemma mk_\u03b9_app_left {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n  (mk inl inr eq).\u03b9.app walking_span.left = inl := rfl\n@[simp] lemma mk_\u03b9_app_right {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n  (mk inl inr eq).\u03b9.app walking_span.right = inr := rfl\n@[simp] lemma mk_\u03b9_app_zero {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n  (mk inl inr eq).\u03b9.app walking_span.zero = f \u226b inl := rfl\n\n@[simp] lemma mk_inl {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n  (mk inl inr eq).inl = inl := rfl\n@[simp] lemma mk_inr {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n  (mk inl inr eq).inr = inr := rfl\n\n@[reassoc] lemma condition (t : pushout_cocone f g) : f \u226b (inl t) = g \u226b (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 \u27f6 W}\n  (h\u2080 : inl t \u226b k = inl t \u226b l) (h\u2081 : inr t \u226b k = inr t \u226b l) :\n  \u2200 (j : walking_span), t.\u03b9.app j \u226b k = t.\u03b9.app j \u226b l\n| (some walking_pair.left) := h\u2080\n| (some walking_pair.right) := h\u2081\n| none := by rw [\u2190 t.w fst, category.assoc, category.assoc, h\u2080]\n\nlemma is_colimit.hom_ext {t : pushout_cocone f g} (ht : is_colimit t) {W : C} {k l : t.X \u27f6 W}\n  (h\u2080 : inl t \u226b k = inl t \u226b l) (h\u2081 : inr t \u226b k = inr t \u226b l) : k = l :=\nht.hom_ext $ coequalizer_ext _ h\u2080 h\u2081\n\n/-- If `t` is a colimit pushout cocone over `f` and `g` and `h : Y \u27f6 W` and `k : Z \u27f6 W` are\n    morphisms satisfying `f \u226b h = g \u226b k`, then we have a factorization `l : t.X \u27f6 W` such that\n    `inl t \u226b l = h` and `inr t \u226b l = k`. -/\ndef is_colimit.desc' {t : pushout_cocone f g} (ht : is_colimit t) {W : C} (h : Y \u27f6 W) (k : Z \u27f6 W)\n  (w : f \u226b h = g \u226b k) : {l : t.X \u27f6 W // inl t \u226b l = h \u2227 inr t \u226b l = k } :=\n\u27e8ht.desc $ pushout_cocone.mk _ _ w, ht.fac _ _, ht.fac _ _\u27e9\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 \u27f6 W} {inr : Z \u27f6 W} (eq : f \u226b inl = g \u226b inr)\n  (desc : \u03a0 (s : pushout_cocone f g), W \u27f6 s.X)\n  (fac_left : \u2200 (s : pushout_cocone f g), inl \u226b desc s = s.inl)\n  (fac_right : \u2200 (s : pushout_cocone f g), inr \u226b desc s = s.inr)\n  (uniq : \u2200 (s : pushout_cocone f g) (m : W \u27f6 s.X)\n    (w_inl : inl \u226b m = s.inl) (w_inr : inr \u226b m = s.inr), m = desc s) :\n  is_colimit (mk inl inr eq) :=\nis_colimit_aux _ desc fac_left fac_right\n  (\u03bb 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 \u27f6 W} {k : Z \u27f6 W}\n  {comm : f \u226b h = g \u226b k} (t : is_colimit (mk _ _ comm.symm)) :\n  is_colimit (mk _ _ comm) :=\nis_colimit_aux' _ $ \u03bb s,\nbegin\n  refine \u27e8(is_colimit.desc' t _ _ s.condition.symm).1,\n          (is_colimit.desc' t _ _ _).2.2,\n          (is_colimit.desc' t _ _ _).2.1, \u03bb m m\u2081 m\u2082, t.hom_ext _\u27e9,\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 \u2964 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 \u2964 C} (t : pullback_cone (F.map inl) (F.map inr)) : cone F :=\n{ X := t.X,\n  \u03c0 := t.\u03c0 \u226b (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 \u2964 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 \u2964 C} (t : pushout_cocone (F.map fst) (F.map snd)) : cocone F :=\n{ X := t.X,\n  \u03b9 := (diagram_iso_span F).hom \u226b t.\u03b9 }\n\n/-- Given `F : walking_cospan \u2964 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 \u2964 C} (t : cone F) : pullback_cone (F.map inl) (F.map inr) :=\n{ X := t.X,\n  \u03c0 := t.\u03c0 \u226b (diagram_iso_cospan F).hom }\n\n/-- Given `F : walking_span \u2964 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 \u2964 C} (t : cocone F) : pushout_cocone (F.map fst) (F.map snd) :=\n{ X := t.X,\n  \u03b9 := (diagram_iso_span F).inv \u226b t.\u03b9 }\n\n/--\n`has_pullback f g` represents a particular choice of limiting cone\nfor the pair of morphisms `f : X \u27f6 Z` and `g : Y \u27f6 Z`.\n-/\nabbreviation has_pullback {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y` and `g : X \u27f6 Z`.\n-/\nabbreviation has_pushout {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] :\n  pullback f g \u27f6 X :=\nlimit.\u03c0 (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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] :\n  pullback f g \u27f6 Y :=\nlimit.\u03c0 (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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] :\n  Y \u27f6 pushout f g :=\ncolimit.\u03b9 (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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] :\n  Z \u27f6 pushout f g :=\ncolimit.\u03b9 (span f g) walking_span.right\n\n/-- A pair of morphisms `h : W \u27f6 X` and `k : W \u27f6 Y` satisfying `h \u226b f = k \u226b g` induces a morphism\n    `pullback.lift : W \u27f6 pullback f g`. -/\nabbreviation pullback.lift {W X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g]\n  (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : W \u27f6 pullback f g :=\nlimit.lift _ (pullback_cone.mk h k w)\n\n/-- A pair of morphisms `h : Y \u27f6 W` and `k : Z \u27f6 W` satisfying `f \u226b h = g \u226b k` induces a morphism\n    `pushout.desc : pushout f g \u27f6 W`. -/\nabbreviation pushout.desc {W X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g]\n  (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : pushout f g \u27f6 W :=\ncolimit.desc _ (pushout_cocone.mk h k w)\n\n@[simp, reassoc]\nlemma pullback.lift_fst {W X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g]\n  (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : pullback.lift h k w \u226b pullback.fst = h :=\nlimit.lift_\u03c0 _ _\n\n@[simp, reassoc]\nlemma pullback.lift_snd {W X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g]\n  (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : pullback.lift h k w \u226b pullback.snd = k :=\nlimit.lift_\u03c0 _ _\n\n@[simp, reassoc]\nlemma pushout.inl_desc {W X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g]\n  (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : pushout.inl \u226b pushout.desc h k w = h :=\ncolimit.\u03b9_desc _ _\n\n@[simp, reassoc]\nlemma pushout.inr_desc {W X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g]\n  (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : pushout.inr \u226b pushout.desc h k w = k :=\ncolimit.\u03b9_desc _ _\n\n/-- A pair of morphisms `h : W \u27f6 X` and `k : W \u27f6 Y` satisfying `h \u226b f = k \u226b g` induces a morphism\n    `l : W \u27f6 pullback f g` such that `l \u226b pullback.fst = h` and `l \u226b pullback.snd = k`. -/\ndef pullback.lift' {W X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g]\n  (h : W \u27f6 X) (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) :\n  {l : W \u27f6 pullback f g // l \u226b pullback.fst = h \u2227 l \u226b pullback.snd = k} :=\n\u27e8pullback.lift h k w, pullback.lift_fst _ _ _, pullback.lift_snd _ _ _\u27e9\n\n/-- A pair of morphisms `h : Y \u27f6 W` and `k : Z \u27f6 W` satisfying `f \u226b h = g \u226b k` induces a morphism\n    `l : pushout f g \u27f6 W` such that `pushout.inl \u226b l = h` and `pushout.inr \u226b l = k`. -/\ndef pullback.desc' {W X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g]\n  (h : Y \u27f6 W) (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) :\n  {l : pushout f g \u27f6 W // pushout.inl \u226b l = h \u2227 pushout.inr \u226b l = k} :=\n\u27e8pushout.desc h k w, pushout.inl_desc _ _ _, pushout.inr_desc _ _ _\u27e9\n\n@[reassoc]\nlemma pullback.condition {X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g] :\n  (pullback.fst : pullback f g \u27f6 X) \u226b f = pullback.snd \u226b g :=\npullback_cone.condition _\n\n@[reassoc]\nlemma pushout.condition {X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] :\n  f \u226b (pushout.inl : Y \u27f6 pushout f g) = g \u226b 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g]\n  {W : C} {k l : W \u27f6 pullback f g} (h\u2080 : k \u226b pullback.fst = l \u226b pullback.fst)\n  (h\u2081 : k \u226b pullback.snd = l \u226b pullback.snd) : k = l :=\nlimit.hom_ext $ pullback_cone.equalizer_ext _ h\u2080 h\u2081\n\n/-- The pullback cone built from the pullback projections is a pullback. -/\ndef pullback_is_pullback {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z) [has_pullback f g] :\n  is_limit (pullback_cone.mk (pullback.fst : pullback f g \u27f6 _) pullback.snd pullback.condition) :=\npullback_cone.is_limit.mk _ (\u03bb 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 \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g]\n  [mono g] : mono (pullback.fst : pullback f g \u27f6 X) :=\n\u27e8\u03bb W u v h, pullback.hom_ext h $ (cancel_mono g).1 $ by simp [\u2190 pullback.condition, reassoc_of h]\u27e9\n\n/-- The pullback of a monomorphism is a monomorphism -/\ninstance pullback.snd_of_mono {X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [has_pullback f g]\n  [mono f] : mono (pullback.snd : pullback f g \u27f6 Y) :=\n\u27e8\u03bb W u v h, pullback.hom_ext ((cancel_mono f).1 $ by simp [pullback.condition, reassoc_of h]) h\u27e9\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 \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g]\n  {W : C} {k l : pushout f g \u27f6 W} (h\u2080 : pushout.inl \u226b k = pushout.inl \u226b l)\n  (h\u2081 : pushout.inr \u226b k = pushout.inr \u226b l) : k = l :=\ncolimit.hom_ext $ pushout_cocone.coequalizer_ext _ h\u2080 h\u2081\n\n/-- The pushout of an epimorphism is an epimorphism -/\ninstance pushout.inl_of_epi {X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] [epi g] :\n  epi (pushout.inl : Y \u27f6 pushout f g) :=\n\u27e8\u03bb W u v h, pushout.hom_ext h $ (cancel_epi g).1 $ by simp [\u2190 pushout.condition_assoc, h] \u27e9\n\n/-- The pushout of an epimorphism is an epimorphism -/\ninstance pushout.inr_of_epi {X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [has_pushout f g] [epi f] :\n  epi (pushout.inr : Z \u27f6 pushout f g) :=\n\u27e8\u03bb W u v h, pushout.hom_ext ((cancel_epi f).1 $ by simp [pushout.condition_assoc, h]) h\u27e9\n\nsection\n\nvariables {D : Type u\u2082} [category.{v} D] (G : C \u2964 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 \u27f6 Z) (g : Y \u27f6 Z)\n  [has_pullback f g] [has_pullback (G.map f) (G.map g)] :\n  G.obj (pullback f g) \u27f6 pullback (G.map f) (G.map g) :=\npullback.lift (G.map pullback.fst) (G.map pullback.snd)\n  (by simp only [\u2190G.map_comp, pullback.condition])\n\n@[simp, reassoc]\nlemma pullback_comparison_comp_fst (f : X \u27f6 Z) (g : Y \u27f6 Z)\n  [has_pullback f g] [has_pullback (G.map f) (G.map g)] :\n  pullback_comparison G f g \u226b pullback.fst = G.map pullback.fst :=\npullback.lift_fst _ _ _\n\n@[simp, reassoc]\nlemma pullback_comparison_comp_snd (f : X \u27f6 Z) (g : Y \u27f6 Z)\n  [has_pullback f g] [has_pullback (G.map f) (G.map g)] :\n  pullback_comparison G f g \u226b pullback.snd = G.map pullback.snd :=\npullback.lift_snd _ _ _\n\n@[simp, reassoc]\nlemma map_lift_pullback_comparison (f : X \u27f6 Z) (g : Y \u27f6 Z)\n  [has_pullback f g] [has_pullback (G.map f) (G.map g)]\n  {W : C} {h : W \u27f6 X} {k : W \u27f6 Y} (w : h \u226b f = k \u226b g) :\n    G.map (pullback.lift _ _ w) \u226b pullback_comparison G f g =\n      pullback.lift (G.map h) (G.map k) (by simp only [\u2190G.map_comp, w]) :=\nby { ext; simp [\u2190 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  [\u03a0 {X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z}, has_limit (cospan f g)] :\n  has_pullbacks C :=\n{ has_limit := \u03bb 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  [\u03a0 {X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z}, has_colimit (span f g)] :\n  has_pushouts C :=\n{ has_colimit := \u03bb 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\u00f6lzl, 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 \u2022 x : M` is defined, and\n  the operation `\u2022` 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\u2082`, `M \u2192\u2097[R] M\u2082` : 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 \u2022 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 : \u2200 (r s : R) (x : M), (r + s) \u2022 x = r \u2022 x + s \u2022 x\n  zero_smul : \u2200 (x : M), 0 \u2022 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) \u2022 x = r \u2022 x + s \u2022 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 \u2022 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 \u2022 x = x + x :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (bit0 1 \u2022 x = x + x)) (bit0.equations._eqn_1 1)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((1 + 1) \u2022 x = x + x)) (add_smul 1 1 x)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (1 \u2022 x + 1 \u2022 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 \u2022 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\u2082 : Type x} [semiring R] [add_comm_monoid M] [semimodule R M] [add_comm_monoid M\u2082] [has_scalar R M\u2082] (f : M\u2082 \u2192+ M) (hf : function.injective \u21d1f) (smul : \u2200 (c : R) (x : M\u2082), coe_fn f (c \u2022 x) = c \u2022 coe_fn f x) : semimodule R M\u2082 :=\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\u2082 : Type x} [semiring R] [add_comm_monoid M] [semimodule R M] [add_comm_monoid M\u2082] [has_scalar R M\u2082] (f : M \u2192+ M\u2082) (hf : function.surjective \u21d1f) (smul : \u2200 (c : R) (x : M), coe_fn f (c \u2022 x) = c \u2022 coe_fn f x) : semimodule R M\u2082 :=\n  semimodule.mk sorry sorry\n\n/-- `(\u2022)` 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 \u2192+ M \u2192+ 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 \u2022 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 \u2022 x = 0)) (Eq.symm zero_eq_one)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (0 \u2022 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 \u2022 x = list.sum (list.map (fun (r : R) => r \u2022 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 \u2022 x = multiset.sum (multiset.map (fun (r : R) => r \u2022 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} {\u03b9 : Type z} [semiring R] [add_comm_monoid M] [semimodule R M] {f : \u03b9 \u2192 R} {s : finset \u03b9} {x : M} : (finset.sum s fun (i : \u03b9) => f i) \u2022 x = finset.sum s fun (i : \u03b9) => f i \u2022 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 \u2022 a)\n    (add_group.sub._default add_comm_monoid.add sorry add_comm_monoid.zero sorry sorry fun (a : M) => -1 \u2022 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 : \u2200 (r : R) (x y : M), r \u2022 (x + y) = r \u2022 x + r \u2022 y\n  add_smul : \u2200 (r s : R) (x : M), (r + s) \u2022 x = r \u2022 x + s \u2022 x\n  mul_smul : \u2200 (r s : R) (x : M), (r * s) \u2022 x = r \u2022 s \u2022 x\n  one_smul : \u2200 (x : M), 1 \u2022 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 `\u2124^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 \u2115 M` and `module \u2124 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 : \u2200 (r : R) (m : M), r \u2022 m = r \u2022 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 \u2022 x = -(r \u2022 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 \u2022 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) \u2022 y = r \u2022 y - s \u2022 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 \u2022 x = 0 \u2194 c = 0 \u2228 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 \u2022 a' = a * a' :=\n  rfl\n\n/-- A ring homomorphism `f : R \u2192+* M` defines a module structure by `r \u2022 x = f r * x`. -/\ndef ring_hom.to_semimodule {R : Type u} {S : Type v} [semiring R] [semiring S] (f : R \u2192+* 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 `\u211d^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 \u2115-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 \u2022 x` when `n : \u2115`.\n\ninstance add_comm_monoid.nat_semimodule {M : Type w} [add_comm_monoid M] : semimodule \u2115 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 : \u2115) (x : M) : n \u2022\u2115 x = n \u2022 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 : \u2115) (b : M) : n \u2022\u2115 b = \u2191n \u2022 b := sorry\n\n/-- `nsmul` is equal to any `\u2115`-semimodule structure. -/\ntheorem nsmul_eq_smul {M : Type w} [add_comm_monoid M] [semimodule \u2115 M] (n : \u2115) (b : M) : n \u2022\u2115 b = n \u2022 b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022\u2115 b = n \u2022 b)) (nsmul_eq_smul_cast \u2115 n b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n \u2022 b = n \u2022 b)) (nat.cast_id n))) (Eq.refl (n \u2022 b)))\n\n/-- All `\u2115`-semimodule structures are equal. -/\nprotected instance add_comm_monoid.nat_semimodule.subsingleton {M : Type w} [add_comm_monoid M] : subsingleton (semimodule \u2115 M) :=\n  subsingleton.intro\n    fun (P Q : semimodule \u2115 M) =>\n      semimodule_ext P Q\n        fun (n : \u2115) (m : M) =>\n          eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022 m = n \u2022 m)) (Eq.symm (nsmul_eq_smul n m))))\n            (eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022\u2115 m = n \u2022 m)) (Eq.symm (nsmul_eq_smul n m)))) (Eq.refl (n \u2022\u2115 m)))\n\n/-- Note this does not depend on the `nat_semimodule` definition above, to avoid issues when\ndiamonds occur in finding `semimodule \u2115 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 \u2115 R] [semimodule \u2115 M] : is_scalar_tower \u2115 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 \u2115 M] : smul_comm_class \u2115 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 \u2115 M] : smul_comm_class R \u2115 M :=\n  smul_comm_class.symm \u2115 R M\n\n/-- The natural \u2124-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 \u2022 x` when `n : \u2124`.\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 \u2124 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 : \u2124) (x : M) : n \u2022\u2124 x = n \u2022 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 : \u2124) (b : M) : n \u2022\u2124 b = \u2191n \u2022 b := sorry\n\n/-- `gsmul` is equal to any `\u2124`-module structure. -/\ntheorem gsmul_eq_smul {M : Type w} [add_comm_group M] [semimodule \u2124 M] (n : \u2124) (b : M) : n \u2022\u2124 b = n \u2022 b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022\u2124 b = n \u2022 b)) (gsmul_eq_smul_cast \u2124 n b)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u2191n \u2022 b = n \u2022 b)) (int.cast_id n))) (Eq.refl (n \u2022 b)))\n\n/-- All `\u2124`-module structures are equal. -/\nprotected instance add_comm_group.int_module.subsingleton {M : Type w} [add_comm_group M] : subsingleton (semimodule \u2124 M) :=\n  subsingleton.intro\n    fun (P Q : semimodule \u2124 M) =>\n      semimodule_ext P Q\n        fun (n : \u2124) (m : M) =>\n          eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022 m = n \u2022 m)) (Eq.symm (gsmul_eq_smul n m))))\n            (eq.mpr (id (Eq._oldrec (Eq.refl (n \u2022\u2124 m = n \u2022 m)) (Eq.symm (gsmul_eq_smul n m)))) (Eq.refl (n \u2022\u2124 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 \u2124 R] [semimodule \u2124 M] : is_scalar_tower \u2124 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 \u2124 M] : smul_comm_class \u2124 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 \u2124 M] : smul_comm_class S \u2124 M :=\n  smul_comm_class.symm \u2124 S M\n\nnamespace add_monoid_hom\n\n\n-- We prove this without using the `add_comm_group.int_module` instance, so the `\u2022`s here\n\n-- come from whatever the local `module \u2124` structure actually is.\n\ntheorem map_int_module_smul {M : Type w} {M\u2082 : Type x} [add_comm_group M] [add_comm_group M\u2082] [module \u2124 M] [module \u2124 M\u2082] (f : M \u2192+ M\u2082) (x : \u2124) (a : M) : coe_fn f (x \u2022 a) = x \u2022 coe_fn f a := sorry\n\ntheorem map_int_cast_smul {R : Type u} {M : Type w} {M\u2082 : Type x} [ring R] [add_comm_group M] [add_comm_group M\u2082] [module R M] [module R M\u2082] (f : M \u2192+ M\u2082) (x : \u2124) (a : M) : coe_fn f (\u2191x \u2022 a) = \u2191x \u2022 coe_fn f a := sorry\n\ntheorem map_nat_cast_smul {R : Type u} {M : Type w} {M\u2082 : Type x} [semiring R] [add_comm_monoid M] [add_comm_monoid M\u2082] [semimodule R M] [semimodule R M\u2082] (f : M \u2192+ M\u2082) (x : \u2115) (a : M) : coe_fn f (\u2191x \u2022 a) = \u2191x \u2022 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 \u2192+ F) (c : \u211a) (x : E) : coe_fn f (\u2191c \u2022 x) = \u2191c \u2022 coe_fn f x := sorry\n\ntheorem map_rat_module_smul {E : Type u_1} [add_comm_group E] [vector_space \u211a E] {F : Type u_2} [add_comm_group F] [module \u211a F] (f : E \u2192+ F) (c : \u211a) (x : E) : coe_fn f (c \u2022 x) = c \u2022 coe_fn f x :=\n  rat.cast_id c \u25b8 map_rat_cast_smul f c x\n\n@[simp] theorem nat_smul_apply {M : Type w} {M\u2082 : Type x} [add_monoid M] [add_comm_monoid M\u2082] [semimodule \u2115 (M \u2192+ M\u2082)] [semimodule \u2115 M\u2082] (n : \u2115) (f : M \u2192+ M\u2082) (a : M) : coe_fn (n \u2022 f) a = n \u2022 coe_fn f a := sorry\n\n@[simp] theorem int_smul_apply {M : Type w} {M\u2082 : Type x} [add_monoid M] [add_comm_group M\u2082] [module \u2124 (M \u2192+ M\u2082)] [module \u2124 M\u2082] (n : \u2124) (f : M \u2192+ M\u2082) (a : M) : coe_fn (n \u2022 f) a = n \u2022 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 \u2115 M] [char_zero R] {v : M} {n : \u2115} : n \u2022 v = 0 \u2194 n = 0 \u2228 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 \u2115 M] [char_zero R] {v : M} (hv : bit0 1 \u2022 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 \u2260 0) : v \u2260 -v :=\n  fun (h : v = -v) => (fun (this : semimodule \u2115 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\n\nExtends the theory on functors, applicatives and monads.\n-/\n\nuniverses u v w\nvariables {\u03b1 \u03b2 \u03b3 : Type u}\n\nnotation a ` $< `:1 f:1 := f a\n\nsection functor\nvariables {f : Type u \u2192 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 : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (x : f \u03b1) :\n  g <$> (m <$> x) = (g \u2218 m) <$> x :=\n(comp_map _ _ _).symm\n\n@[simp] theorem id_map' (x : f \u03b1) : (\u03bba, a) <$> x = x := id_map _\n\nend functor\n\nsection applicative\nvariables {F : Type u \u2192 Type v} [applicative F]\n\ndef mzip_with\n  {\u03b1\u2081 \u03b1\u2082 \u03c6 : Type u}\n  (f : \u03b1\u2081 \u2192 \u03b1\u2082 \u2192 F \u03c6) :\n  \u03a0 (ma\u2081 : list \u03b1\u2081) (ma\u2082: list \u03b1\u2082), F (list \u03c6)\n| (x :: xs) (y :: ys) := (::) <$> f x y <*> mzip_with xs ys\n| _ _ := pure []\n\ndef mzip_with'  (f : \u03b1 \u2192 \u03b2 \u2192 F \u03b3) : list \u03b1 \u2192 list \u03b2 \u2192 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 \u03b1) : pure (\u03bbx, 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 (\u03b1 \u2192 \u03b2)) (f : \u03b3 \u2192 \u03b1) (y : F \u03b3) :\n  (x <*> (f <$> y)) = (\u03bb(m:\u03b1\u2192\u03b2), m \u2218 f) <$> x <*> y :=\nbegin\n  simp [(pure_seq_eq_map _ _).symm],\n  simp [seq_assoc, (comp_map _ _ _).symm, (\u2218)],\n  simp [pure_seq_eq_map]\nend\n\n@[functor_norm] theorem map_seq (f : \u03b2 \u2192 \u03b3) (x : F (\u03b1 \u2192 \u03b2)) (y : F \u03b1) :\n  (f <$> (x <*> y)) = ((\u2218) 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 \u2192 Type v} [monad m] [is_lawful_monad m]\n\nopen list\n\ndef list.mpartition {f : Type \u2192 Type} [monad f] {\u03b1 : Type} (p : \u03b1 \u2192 f bool) :\n  list \u03b1 \u2192 f (list \u03b1 \u00d7 list \u03b1)\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 \u03b1) {g : \u03b1 \u2192 m \u03b2} {f : \u03b2 \u2192 \u03b3} : f <$> (x >>= g) = (x >>= \u03bba, f <$> g a) :=\nby rw [\u2190 bind_pure_comp_eq_map,bind_assoc]; simp [bind_pure_comp_eq_map]\n\nlemma seq_bind_eq (x : m \u03b1) {g : \u03b2 \u2192 m \u03b3} {f : \u03b1 \u2192 \u03b2} : (f <$> x) >>= g = (x >>= g \u2218 f) :=\nshow bind (f <$> x) g = bind x (g \u2218 f),\nby rw [\u2190 bind_pure_comp_eq_map, bind_assoc]; simp [pure_bind]\n\nlemma seq_eq_bind_map {x : m \u03b1} {f : m (\u03b1 \u2192 \u03b2)} : 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] {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 m \u03b2) (g : \u03b2 \u2192 m \u03b3) := \u03bb 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 {\u03b1 \u03b2} (f : \u03b1 \u2192 m \u03b2) : f >=> pure = f :=\nby simp only [(>=>)] with functor_norm\n\n@[functor_norm]\nlemma fish_pipe {\u03b1 \u03b2} (f : \u03b1 \u2192 m \u03b2) : pure >=> f = f :=\nby simp only [(>=>)] with functor_norm\n\n@[functor_norm]\nlemma fish_assoc {\u03b1 \u03b2 \u03b3 \u03c6} (f : \u03b1 \u2192 m \u03b2) (g : \u03b2 \u2192 m \u03b3) (h : \u03b3 \u2192 m \u03c6) :\n  (f >=> g) >=> h = f >=> (g >=> h) :=\nby simp only [(>=>)] with functor_norm\n\nvariables {\u03b2' \u03b3' : Type v}\nvariables {m' : Type v \u2192 Type w} [monad m']\n\ndef list.mmap_accumr (f : \u03b1 \u2192 \u03b2' \u2192 m' (\u03b2' \u00d7 \u03b3')) : \u03b2' \u2192 list \u03b1 \u2192 m' (\u03b2' \u00d7 list \u03b3')\n| a [] := pure (a,[])\n| a (x :: xs) :=\n  do (a',ys) \u2190 list.mmap_accumr a xs,\n     (a'',y) \u2190 f x a',\n     pure (a'',y::ys)\n\ndef list.mmap_accuml (f : \u03b2' \u2192 \u03b1 \u2192 m' (\u03b2' \u00d7 \u03b3')) : \u03b2' \u2192 list \u03b1 \u2192 m' (\u03b2' \u00d7 list \u03b3')\n| a [] := pure (a,[])\n| a (x :: xs) :=\n  do (a',y) \u2190 f a x,\n     (a'',ys) \u2190 list.mmap_accuml a' xs,\n     pure (a'',y :: ys)\n\nend monad\n\nsection\nvariables {m : Type u \u2192 Type u} [monad m] [is_lawful_monad m]\n\nlemma mjoin_map_map {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) (a : m (m \u03b1)) :\n  mjoin (functor.map f <$> a) = f <$> (mjoin a) :=\nby simp only [mjoin, (\u2218), id.def,\n  (bind_pure_comp_eq_map _ _).symm, bind_assoc, map_bind, pure_bind]\n\nlemma mjoin_map_mjoin {\u03b1 : Type u} (a : m (m (m \u03b1))) :\n  mjoin (mjoin <$> a) = mjoin (mjoin a) :=\nby simp only [mjoin, (\u2218), id.def,\n  map_bind, (bind_pure_comp_eq_map _ _).symm, bind_assoc, pure_bind]\n\n@[simp] lemma mjoin_map_pure {\u03b1 : Type u} (a : m \u03b1) :\n  mjoin (pure <$> a) = a :=\nby simp only [mjoin, (\u2218), id.def,\n  map_bind, (bind_pure_comp_eq_map _ _).symm, bind_assoc, pure_bind, bind_pure]\n\n@[simp] lemma mjoin_pure {\u03b1 : Type u} (a : m \u03b1) : mjoin (pure a) = a :=\nis_lawful_monad.pure_bind a id\n\nend\n\nsection alternative\nvariables {F : Type \u2192 Type v} [alternative F]\n\ndef succeeds {\u03b1} (x : F \u03b1) : F bool := (x $> tt) <|> pure ff\n\ndef mtry {\u03b1} (x : F \u03b1) : 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 {\u03b1 \u03b2} : e \u2295 \u03b1 \u2192 (\u03b1 \u2192 e \u2295 \u03b2) \u2192 e \u2295 \u03b2\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 _ \u2295 _; refl\n\ninstance : is_lawful_monad (sum.{v u} e) :=\n{ bind_assoc := by { intros, casesm _ \u2295 _; refl },\n  pure_bind  := by { intros, refl },\n  bind_pure_comp_eq_map := by { intros, casesm _ \u2295 _; refl },\n  bind_map_eq_seq := by { intros, cases f; refl } }\n\nend sum\n\nclass is_comm_applicative (m : Type* \u2192 Type*) [applicative m] extends is_lawful_applicative m :\n  Prop :=\n(commutative_prod : \u2200{\u03b1 \u03b2} (a : m \u03b1) (b : m \u03b2), prod.mk <$> a <*> b = (\u03bbb a, (a, b)) <$> b <*> a)\n\nopen functor\n\nlemma is_comm_applicative.commutative_map\n  {m : Type* \u2192 Type*} [applicative m] [is_comm_applicative m]\n  {\u03b1 \u03b2 \u03b3} (a : m \u03b1) (b : m \u03b2) {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} :\n  f <$> a <*> b = flip f <$> b <*> a :=\ncalc f <$> a <*> b = (\u03bbp:\u03b1\u00d7\u03b2, f p.1 p.2) <$> (prod.mk <$> a <*> b) :\n    by simp [seq_map_assoc, map_seq, seq_assoc, seq_pure, map_map]\n  ... = (\u03bbb 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 \u2223 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\u02e3` can be inferred from `fintype K` in the presence of `decidable_eq K`,\nin this file we take the `fintype K\u02e3` 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 \u2264 nat_degree p * (univ.image (\u03bb x, eval x p)).card :=\nfinset.card_le_mul_card_image _ _\n  (\u03bb a _, calc _ = (p - C a).roots.to_finset.card : congr_arg card\n    (by simp [finset.ext_iff, mem_roots_sub_C hp])\n    ... \u2264 (p - C a).roots.card : multiset.to_finset_card_le _\n    ... \u2264 _ : 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) : \u2203 a b, f.eval a + g.eval b = 0 :=\nby letI := classical.dec_eq R; exact\nsuffices \u00ac disjoint (univ.image (\u03bb x : R, eval x f)) (univ.image (\u03bb x : R, eval x (-g))),\nbegin\n  simp only [disjoint_left, mem_image] at this,\n  push_neg at this,\n  rcases this with \u27e8x, \u27e8a, _, ha\u27e9, \u27e8b, _, hb\u27e9\u27e9,\n  exact \u27e8a, b, by rw [ha, \u2190 hb, eval_neg, neg_add_self]\u27e9\nend,\nassume hd : disjoint _ _,\nlt_irrefl (2 * ((univ.image (\u03bb x : R, eval x f)) \u222a (univ.image (\u03bb x : R, eval x (-g)))).card) $\ncalc 2 * ((univ.image (\u03bb x : R, eval x f)) \u222a (univ.image (\u03bb x : R, eval x (-g)))).card\n    \u2264 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 (\u03bb x : R, eval x f)).card +\n      nat_degree (-g) * (univ.image (\u03bb 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 (\u03bb x : R, eval x f) \u222a univ.image (\u03bb 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\u02e3] :\n  (\u220f x : K\u02e3, x) = (-1 : K\u02e3) :=\nbegin\n  classical,\n  have : (\u220f x in (@univ K\u02e3 _).erase (-1), x) = 1,\n  from prod_involution (\u03bb x _, x\u207b\u00b9) (by simp)\n    (\u03bb a, by simp [units.inv_eq_self_iff] {contextual := tt})\n    (\u03bb a, by simp [@inv_eq_iff_inv_eq _ _ a, eq_comm])\n    (by simp),\n  rw [\u2190 insert_erase (mem_univ (-1 : K\u02e3)), 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 \u2260 0) : a ^ (q - 1) = 1 :=\ncalc a ^ (fintype.card K - 1) = (units.mk0 a ha ^ (fintype.card K - 1) : K\u02e3) :\n    by rw [units.coe_pow, units.coe_mk0]\n  ... = 1 : by { classical, rw [\u2190 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 [\u2190 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 : \u2115) (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 : \u2115) [char_p K p] : \u2203 (n : \u2115+), nat.prime p \u2227 q = p^(n : \u2115) :=\nbegin\n  haveI hp : fact p.prime := \u27e8char_p.char_is_prime K p\u27e9,\n  letI : module (zmod p) K := { .. (zmod.cast_hom dvd_rfl K : zmod p \u2192+* _).to_module },\n  obtain \u27e8n, h\u27e9 := vector_space.card_fintype (zmod p) K,\n  rw zmod.card at h,\n  refine \u27e8\u27e8n, _\u27e9, hp.1, h\u27e9,\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' : \u2203 (p : \u2115) (n : \u2115+), nat.prime p \u2227 fintype.card K = p^(n : \u2115) :=\nlet \u27e8p, hc\u27e9 := char_p.exists K in \u27e8p, @finite_field.card K _ _ p hc\u27e9\n\n@[simp] lemma cast_card_eq_zero : (q : K) = 0 :=\nbegin\n  rcases char_p.exists K with \u27e8p, _char_p\u27e9, resetI,\n  rcases card K p with \u27e8n, hp, hn\u27e9,\n  simp only [char_p.cast_eq_zero_iff K p, hn],\n  conv { congr, rw [\u2190 pow_one p] },\n  exact pow_dvd_pow _ n.2,\nend\n\nlemma forall_pow_eq_one_iff (i : \u2115) :\n  (\u2200 x : K\u02e3, x ^ i = 1) \u2194 q - 1 \u2223 i :=\nbegin\n  classical,\n  obtain \u27e8x, hx\u27e9 := is_cyclic.exists_generator K\u02e3,\n  rw [\u2190fintype.card_units, \u2190order_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 \u2190 mem_powers_iff_mem_zpowers at hx,\n    rcases hx y with \u27e8j, rfl\u27e9,\n    rw [\u2190 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) \u2223 i`, in which case the sum is `q - 1`. -/\nlemma sum_pow_units [fintype K\u02e3] (i : \u2115) :\n  \u2211 x : K\u02e3, (x ^ i : K) = if (q - 1) \u2223 i then -1 else 0 :=\nbegin\n  let \u03c6 : K\u02e3 \u2192* K :=\n  { to_fun   := \u03bb 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 (\u03c6 = 1), { classical, apply_instance },\n  calc \u2211 x : K\u02e3, \u03c6 x = if \u03c6 = 1 then fintype.card K\u02e3 else 0 : sum_hom_units \u03c6\n                      ... = if (q - 1) \u2223 i then -1 else 0 : _,\n  suffices : (q - 1) \u2223 i \u2194 \u03c6 = 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 \u2264 q, from fintype.card_pos_iff.mpr \u27e80\u27e9 },\n  rw [\u2190 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 : \u2115) (h : i < q - 1) :\n  \u2211 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 : \u00ac (q - 1) \u2223 i, { contrapose! h,  exact nat.le_of_dvd (nat.pos_of_ne_zero hi) h },\n  let \u03c6 : K\u02e3 \u21aa K := \u27e8coe, units.ext\u27e9,\n  have : univ.map \u03c6 = 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 \u2211 x : K, x ^ i = \u2211 x in univ \\ {(0 : K)}, x ^ i :\n    by rw [\u2190 sum_sdiff ({0} : finset K).subset_univ, sum_singleton,\n           zero_pow (nat.pos_of_ne_zero hi), add_zero]\n    ... = \u2211 x : K\u02e3, x ^ i : by { rw [\u2190 this, univ.sum_map \u03c6], 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 : \u2115}\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 \u2260 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]) \u2260 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 \u2260 0) (hp : 1 < p) :\n  (X ^ p ^ n - X : K'[X]) \u2260 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 : \u2115) [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]) \u2260 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 [\u2190this, 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, \u2190C_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 [\u2190splits_id_iff_splits, splits_iff_card_roots, polynomial.map_sub, polynomial.map_pow,\n      map_X, h, roots_X_pow_card_sub_X K, \u2190finset.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 : \u2115} [fact p.prime] [char_p K p] {n : \u2115} (hcard : q = p^n) :\n  (frobenius K p) ^ n = 1 :=\nbegin\n  ext, conv_rhs { rw [ring_hom.one_def, ring_hom.id_apply, \u2190 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 \u27e8\u27e8n, npos\u27e9, \u27e8hp, hn\u27e9\u27e9,\n  haveI : fact p.prime := \u27e8hp\u27e9,\n  dsimp at hn,\n  rw [hn, \u2190 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 : \u2115) [hp : fact p.prime] (x : zmod p) :\n  \u2203 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 \u27e8a, b, hab\u27e9 : \u2203 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 \u27e8a, b, _\u27e9,\n  rw \u2190 sub_eq_zero,\n  simpa only [eval_C, eval_X, eval_pow, eval_sub, \u2190 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 : \u2115) [fact (0 < p)] [char_p R p] (x : \u2124) :\n  \u2203 a b : \u2115, (a^2 + b^2 : R) = x :=\nbegin\n  haveI := char_is_prime_of_pos R p,\n  obtain \u27e8a, b, hab\u27e9 := zmod.sq_add_sq p x,\n  refine \u27e8a.val, b.val, _\u27e9,\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 : \u2115} [fact (0 < n)] (x : (zmod n)\u02e3) : x ^ \u03c6 n = 1 :=\nby rw [\u2190 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 : \u2115} (h : nat.coprime x n) : x ^ \u03c6 n \u2261 1 [MOD n] :=\nbegin\n  cases n, {simp},\n  rw \u2190 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)) \u2192 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, \u2190 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 : \u2115} [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 : \u2115} [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 : \u2115) [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 : \u2115) [fact p.prime] : fintype.card ((zmod p)\u02e3) = 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 : \u2115) [fact p.prime] (a : (zmod p)\u02e3) :\n  a ^ (p - 1) = 1 :=\nby rw [\u2190 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 : \u2115} [fact p.prime] {a : zmod p} (ha : a \u2260 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 : \u2115} [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 : \u2124` coprime to `p`, we have\n`a ^ (p - 1) \u2261 1 [ZMOD p]`. -/\nlemma int.modeq.pow_card_sub_one_eq_one {p : \u2115} (hp : nat.prime p) {n : \u2124} (hpn : is_coprime n p) :\n  n ^ (p - 1) \u2261 1 [ZMOD p] :=\nbegin\n  haveI : fact p.prime := \u27e8hp\u27e9,\n  have : \u00ac (n : zmod p) = 0,\n  { rw [char_p.int_cast_eq_zero_iff _ p, \u2190 (nat.prime_iff_prime_int.mp hp).coprime_iff_not_dvd],\n    { exact hpn.symm },\n    exact zmod.char_p p },\n  simpa [\u2190 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 \u2194 fintype.card F % 2 = 0 :=\nbegin\n  rcases finite_field.card F (ring_char F) with \u27e8n, hp, h\u27e9,\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 [\u2190 nat.even_iff, nat.even_pow],\n    rintros \u27e8hev, hnz\u27e9,\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 \u2260 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) = \u00b11`. -/\nlemma pow_dichotomy (hF : ring_char F \u2260 2) {a : F} (ha : a \u2260 0) :\n  a ^ (fintype.card F / 2) = 1 \u2228 a ^ (fintype.card F / 2) = -1 :=\nbegin\n  have h\u2081 := finite_field.pow_card_sub_one_eq_one a ha,\n  rw [\u2190 nat.two_mul_odd_div_two (finite_field.odd_card_of_char_ne_two hF),\n      mul_comm, pow_mul, pow_two] at h\u2081,\n  exact mul_self_eq_one_iff.mp h\u2081,\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 \u2260 2) (a : F\u02e3) :\n  is_square a \u2194 a ^ (fintype.card F / 2) = 1 :=\nbegin\n  classical,\n  obtain \u27e8g, hg\u27e9 := is_cyclic.exists_generator F\u02e3,\n  obtain \u27e8n, hn\u27e9 : a \u2208 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 \u27e8y, rfl\u27e9,\n    rw [\u2190 pow_two, \u2190 pow_mul, hodd],\n    apply_fun (@coe F\u02e3 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) \u2223 n * (fintype.card F / 2),\n    { rw [\u2190 pow_mul] at h,\n      rw [hodd, \u2190 fintype.card_units, \u2190 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 \u27e8m, rfl\u27e9 := nat.dvd_of_mul_dvd_mul_right this key,\n    refine \u27e8g ^ m, _\u27e9,\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 \u2260 2) {a : F} (ha : a \u2260 0) :\n  is_square a \u2194 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 \u27e8y, hy\u27e9, exact \u27e8y, hy\u27e9 },\n  { rintro \u27e8y, rfl\u27e9,\n    have hy : y \u2260 0, { rintro rfl, simpa [zero_pow] using ha, },\n    refine \u27e8units.mk0 y hy, _\u27e9, simp, }\nend\n\n/-- In a finite field of odd characteristic, not every element is a square. -/\nlemma exists_nonsquare (hF : ring_char F \u2260 2) : \u2203 (a : F), \u00ac is_square a :=\nbegin\n  -- idea: the squaring map on `F` is not injetive, hence not surjective\n  let sq : F \u2192 F := \u03bb x, x ^ 2,\n  have h : \u00ac 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\u2081 := mt (fintype.injective_iff_surjective.mpr) h, -- sq not surjective\n  push_neg at h\u2081,\n  cases h\u2081 with a h\u2081,\n  use a,\n  simp only [is_square, sq, not_exists, ne.def] at h\u2081 \u22a2,\n  intros b hb,\n  rw \u2190 pow_two at hb,\n  exact h\u2081 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 := \u27e8OfNat.ofNat n\u27e9\n\ninstance (n : Nat) : OfNat Int8 n := \u27e8Int8.ofNat n\u27e9\n\ndef Int8.neg : Int8 -> Int8\n| \u27e8\u27e8a, isLt\u27e9\u27e9 => \u27e8(UInt8.size - a) % UInt8.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)\u27e9\n\ninstance : Neg Int8 := \u27e8Int8.neg\u27e9\n\ndef Int8.max : Int8 := 127\ndef Int8.min : Int8 := -128\n\ntheorem Int8.eq_of_val_eq : \u2200 {a b : Int8}, a.val = b.val -> a = b\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem Int8.ne_of_val_ne : \u2200 {a b : Int8}, a.val \u2260 b.val -> a \u2260 b\n| _, _, h => fun a_eq_b => Int8.noConfusion a_eq_b h\n\ntheorem Int8.val_eq_of_eq : \u2200 {a b : Int8}, a = b -> a.val = b.val\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem Int8.val_ne_of_ne : \u2200 {a b : Int8}, a \u2260 b -> a.val \u2260 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 := \u00aca.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 := \u27e8Int8.toString\u27e9\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 := \u27e8a.val.shiftLeft b.val\u27e9\n\ndef Int8.shiftRight (a b : Int8) : Int8 := \u27e8a.val.shiftRight b.val\u27e9\n\ndef Int8.land (a b : Int8) : Int8 := \u27e8a.val.land b.val\u27e9\n\ndef Int8.lor (a b : Int8) : Int8 := \u27e8a.val.lor b.val\u27e9\n\ndef Int8.xor (a b : Int8) : Int8 := \u27e8a.val.xor b.val\u27e9\n\ninstance : HMod Int8 Nat Int8 := \u27e8Int8.modn\u27e9\ninstance : AndOp Int8     := \u27e8Int8.land\u27e9\ninstance : OrOp Int8      := \u27e8Int8.lor\u27e9\ninstance : Xor Int8       := \u27e8Int8.xor\u27e9\ninstance : ShiftLeft Int8  := \u27e8Int8.shiftLeft\u27e9\ninstance : ShiftRight Int8 := \u27e8Int8.shiftRight\u27e9\n\ndef Int8.add : Int8 -> Int8 -> Int8\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a + b\u27e9\n\ninstance : Add Int8 := \u27e8Int8.add\u27e9\n\ndef Int8.sub (a b : Int8) : Int8 := a + -b\n\ndef Int8.mul : Int8 -> Int8 -> Int8\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a * b\u27e9\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 := \u27e8Int8.sub\u27e9\n\ninstance : Mul Int8 := \u27e8Int8.mul\u27e9\n\ninstance : Mod Int8 := \u27e8Int8.mod\u27e9\n\ninstance : Div Int8 := \u27e8Int8.div\u27e9\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 := \u27e8Int8.le\u27e9\n\ninstance : LT Int8 := \u27e8Int8.lt\u27e9\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 := \u27e8OfNat.ofNat n\u27e9\n\ninstance (n : Nat) : OfNat Int16 n := \u27e8Int16.ofNat n\u27e9\n\ndef Int16.neg : Int16 -> Int16\n| \u27e8\u27e8a, isLt\u27e9\u27e9 => \u27e8(UInt16.size - a) % UInt16.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)\u27e9\n\ninstance : Neg Int16 := \u27e8Int16.neg\u27e9\n\ndef Int16.max : Int16 := -32767\ndef Int16.min : Int16 := -32768\n\ntheorem Int16.eq_of_val_eq : \u2200 {a b : Int16}, a.val = b.val -> a = b\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem Int16.ne_of_val_ne : \u2200 {a b : Int16}, a.val \u2260 b.val -> a \u2260 b\n| _, _, h => fun a_eq_b => Int16.noConfusion a_eq_b h\n\ntheorem Int16.val_eq_of_eq : \u2200 {a b : Int16}, a = b -> a.val = b.val\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem Int16.val_ne_of_ne : \u2200 {a b : Int16}, a \u2260 b -> a.val \u2260 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 := \u00aca.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 := \u27e8Int16.toString\u27e9\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 := \u27e8a.val.shiftLeft b.val\u27e9\n\ndef Int16.shiftRight (a b : Int16) : Int16 := \u27e8a.val.shiftRight b.val\u27e9\n\ndef Int16.land (a b : Int16) : Int16 := \u27e8a.val.land b.val\u27e9\n\ndef Int16.lor (a b : Int16) : Int16 := \u27e8a.val.lor b.val\u27e9\n\ndef Int16.xor (a b : Int16) : Int16 := \u27e8a.val.xor b.val\u27e9\n\ninstance : HMod Int16 Nat Int16 := \u27e8Int16.modn\u27e9\ninstance : AndOp Int16     := \u27e8Int16.land\u27e9\ninstance : OrOp Int16      := \u27e8Int16.lor\u27e9\ninstance : Xor Int16       := \u27e8Int16.xor\u27e9\ninstance : ShiftLeft Int16  := \u27e8Int16.shiftLeft\u27e9\ninstance : ShiftRight Int16 := \u27e8Int16.shiftRight\u27e9\n\ndef Int16.add : Int16 -> Int16 -> Int16\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a + b\u27e9\n\ninstance : Add Int16 := \u27e8Int16.add\u27e9\n\ndef Int16.sub (a b : Int16) : Int16 := a + -b\n\ninstance : Sub Int16 := \u27e8Int16.sub\u27e9\n\ndef Int16.mul : Int16 -> Int16 -> Int16\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a * b\u27e9\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 := \u27e8Int16.mul\u27e9\n\ninstance : Mod Int16 := \u27e8Int16.mod\u27e9\n\ninstance : Div Int16 := \u27e8Int16.div\u27e9\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 := \u27e8Int16.le\u27e9\n\ninstance : LT Int16 := \u27e8Int16.lt\u27e9\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 := \u27e8OfNat.ofNat n\u27e9\n\ninstance (n : Nat) : OfNat Int32 n := \u27e8Int32.ofNat n\u27e9\n\n\ndef Int32.neg : Int32 -> Int32\n| \u27e8\u27e8a, isLt\u27e9\u27e9 => \u27e8(UInt32.size - a) % UInt32.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)\u27e9\n\ninstance : Neg Int32 := \u27e8Int32.neg\u27e9\n\ndef Int32.min : Int32 := -2147483648\ndef Int32.max : Int32 := 2147483647\n\ntheorem Int32.eq_of_val_eq : \u2200 {a b : Int32}, a.val = b.val -> a = b\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem Int32.ne_of_val_ne : \u2200 {a b : Int32}, a.val \u2260 b.val -> a \u2260 b\n| _, _, h => fun a_eq_b => Int32.noConfusion a_eq_b h\n\ntheorem Int32.val_eq_of_eq : \u2200 {a b : Int32}, a = b -> a.val = b.val\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem Int32.val_ne_of_ne : \u2200 {a b : Int32}, a \u2260 b -> a.val \u2260 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 := \u00aca.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 := \u27e8Int32.toString\u27e9\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 := \u27e8a.val.shiftLeft b.val\u27e9\n\ndef Int32.shiftRight (a b : Int32) : Int32 := \u27e8a.val.shiftRight b.val\u27e9\n\ndef Int32.land (a b : Int32) : Int32 := \u27e8a.val.land b.val\u27e9\n\ndef Int32.lor (a b : Int32) : Int32 := \u27e8a.val.lor b.val\u27e9\n\ndef Int32.xor (a b : Int32) : Int32 := \u27e8a.val.xor b.val\u27e9\n\ninstance : HMod Int32 Nat Int32 := \u27e8Int32.modn\u27e9\ninstance : AndOp Int32     := \u27e8Int32.land\u27e9\ninstance : OrOp Int32      := \u27e8Int32.lor\u27e9\ninstance : Xor Int32       := \u27e8Int32.xor\u27e9\ninstance : ShiftLeft Int32  := \u27e8Int32.shiftLeft\u27e9\ninstance : ShiftRight Int32 := \u27e8Int32.shiftRight\u27e9\n\ndef Int32.add : Int32 -> Int32 -> Int32\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a + b\u27e9\n\ninstance : Add Int32 := \u27e8Int32.add\u27e9\n\ndef Int32.sub (a b : Int32) : Int32 := a + -b\n\ninstance : Sub Int32 := \u27e8Int32.sub\u27e9\n\ndef Int32.mul : Int32 -> Int32 -> Int32\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a * b\u27e9\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 := \u27e8Int32.mul\u27e9\n\ninstance : Mod Int32 := \u27e8Int32.mod\u27e9\n\ninstance : Div Int32 := \u27e8Int32.div\u27e9\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 := \u27e8Int32.le\u27e9\n\ninstance : LT Int32 := \u27e8Int32.lt\u27e9\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 := \u27e8OfNat.ofNat n\u27e9\n\ninstance (n : Nat) : OfNat Int64 n := \u27e8Int64.ofNat n\u27e9\n\ntheorem Int64.eq_of_val_eq : \u2200 {a b : Int64}, a.val = b.val -> a = b\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem Int64.ne_of_val_ne : \u2200 {a b : Int64}, a.val \u2260 b.val -> a \u2260 b\n| _, _, h => fun a_eq_b => Int64.noConfusion a_eq_b h\n\ntheorem Int64.val_eq_of_eq : \u2200 {a b : Int64}, a = b -> a.val = b.val\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem Int64.val_ne_of_ne : \u2200 {a b : Int64}, a \u2260 b -> a.val \u2260 b.val\n| _, _, h => fun h' => absurd (Int64.eq_of_val_eq h') h\n\ndef Int64.neg : Int64 -> Int64\n| \u27e8\u27e8a, isLt\u27e9\u27e9 => \u27e8(UInt64.size - a) % UInt64.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)\u27e9\n\ninstance : Neg Int64 := \u27e8Int64.neg\u27e9\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 \u2194 a.val <= (9223372036854775807 : UInt64) := by\n  simp [Int64.isPositive]\n\ndef Int64.isNegative (a : Int64) : Bool := \u00aca.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 := \u27e8Int64.toString\u27e9\n\n\ndef Int64.ofInt : Int \u2192 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 := \u27e8a.val.shiftLeft b.val\u27e9\n\ndef Int64.shiftRight (a b : Int64) : Int64 := \u27e8a.val.shiftRight b.val\u27e9\n\ndef Int64.land (a b : Int64) : Int64 := \u27e8a.val.land b.val\u27e9\n\ndef Int64.lor (a b : Int64) : Int64 := \u27e8a.val.lor b.val\u27e9\n\ndef Int64.xor (a b : Int64) : Int64 := \u27e8a.val.xor b.val\u27e9\n\ninstance : HMod Int64 Nat Int64 := \u27e8Int64.modn\u27e9\ninstance : AndOp Int64     := \u27e8Int64.land\u27e9\ninstance : OrOp Int64      := \u27e8Int64.lor\u27e9\ninstance : Xor Int64       := \u27e8Int64.xor\u27e9\ninstance : ShiftLeft Int64  := \u27e8Int64.shiftLeft\u27e9\ninstance : ShiftRight Int64 := \u27e8Int64.shiftRight\u27e9\n\ndef Int64.add : Int64 -> Int64 -> Int64\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a + b\u27e9\n\ninstance : Add Int64 := \u27e8Int64.add\u27e9\n\ndef Int64.sub (a b : Int64) : Int64 := a + -b\n\ninstance : Sub Int64 := \u27e8Int64.sub\u27e9\n\ndef Int64.mul : Int64 -> Int64 -> Int64\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a * b\u27e9\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 := \u27e8Int64.mul\u27e9\n\ninstance : Mod Int64 := \u27e8Int64.mod\u27e9\n\ninstance : Div Int64 := \u27e8Int64.div\u27e9\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 := \u27e8Int64.le\u27e9\n\ninstance : LT Int64 := \u27e8Int64.lt\u27e9\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 \u2227 differentSign a out\n-/\ndef Int64.wrappingAdd (a b : Int64) : (Bool \u00d7 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 := \u27e8OfNat.ofNat n\u27e9\n\ninstance (n : Nat) : OfNat ISize n := \u27e8ISize.ofNat n\u27e9\n\ntheorem ISize.eq_of_val_eq : \u2200 {a b : ISize}, a.val = b.val -> a = b\n| _, _, h => congrArg ISize.mk h\n\ntheorem ISize.ne_of_val_ne : \u2200 {a b : ISize}, a.val \u2260 b.val -> a \u2260 b\n| _, _, h => fun a_eq_b => ISize.noConfusion a_eq_b h\n\ntheorem ISize.val_eq_of_eq : \u2200 {a b : ISize}, a = b -> a.val = b.val\n| _, _, h => congrArg ISize.val h\n\ntheorem ISize.val_ne_of_ne : \u2200 {a b : ISize}, a \u2260 b -> a.val \u2260 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 := \u00aca.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 := \u27e8ISize.toString\u27e9\n\ndef ISize.neg : ISize -> ISize\n| \u27e8\u27e8a, isLt\u27e9\u27e9 => \u27e8(USize.size - a) % USize.size, Nat.mod_lt _ (Nat.lt_of_le_of_lt (Nat.zero_le _) isLt)\u27e9\n\ninstance : Neg ISize := \u27e8ISize.neg\u27e9\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 := \u27e8a.val.shiftLeft b.val\u27e9\n\ndef ISize.shiftRight (a b : ISize) : ISize := \u27e8a.val.shiftRight b.val\u27e9\n\ndef ISize.land (a b : ISize) : ISize := \u27e8a.val.land b.val\u27e9\n\ndef ISize.lor (a b : ISize) : ISize := \u27e8a.val.lor b.val\u27e9\n\ndef ISize.xor (a b : ISize) : ISize := \u27e8a.val.xor b.val\u27e9\n\ninstance : HMod ISize Nat ISize := \u27e8ISize.modn\u27e9\ninstance : AndOp ISize     := \u27e8ISize.land\u27e9\ninstance : OrOp ISize      := \u27e8ISize.lor\u27e9\ninstance : Xor ISize       := \u27e8ISize.xor\u27e9\ninstance : ShiftLeft ISize  := \u27e8ISize.shiftLeft\u27e9\ninstance : ShiftRight ISize := \u27e8ISize.shiftRight\u27e9\n\ndef ISize.add : ISize -> ISize -> ISize\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a + b\u27e9\n\ninstance : Add ISize := \u27e8ISize.add\u27e9\n\ndef ISize.sub (a b : ISize) : ISize := a + -b\n\ninstance : Sub ISize := \u27e8ISize.sub\u27e9\n\ndef ISize.mul : ISize -> ISize -> ISize\n| \u27e8a\u27e9, \u27e8b\u27e9 => \u27e8a * b\u27e9\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 := \u27e8ISize.mul\u27e9\n\ninstance : Mod ISize := \u27e8ISize.mod\u27e9\n\ninstance : Div ISize := \u27e8ISize.div\u27e9\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 := \u27e8ISize.le\u27e9\n\ninstance : LT ISize := \u27e8ISize.lt\u27e9\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 \u2192 finset char\n| (\u22a5)      := set.to_finset { }\n| ( (\u00b7 c)) := { c }\n| (~ \u03c6)    := vocabOfFormula \u03c6\n| (\u03c6 \u22cf \u03c8 ) := vocabOfFormula \u03c6 \u222a vocabOfFormula \u03c8\n| (\u25a1 \u03c6)    := vocabOfFormula \u03c6\n\ndef vocabOfSetFormula : finset formula \u2192 finset char\n| X := finset.bUnion X vocabOfFormula\n\nclass hasVocabulary (\u03b1 : Type) := (voc : \u03b1 \u2192 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 {\u03d5} : vocabOfFormula (~\u03d5) = vocabOfFormula \u03d5 := by split\n\nlemma vocElem_subs_vocSet {\u03d5 X} : \u03d5 \u2208 X \u2192 vocabOfFormula \u03d5 \u2286 vocabOfSetFormula X :=\nbegin\n  apply finset.induction_on X,\n  -- case \u2205:\n  intro phi_in_X, cases phi_in_X,\n  -- case insert:\n  intros \u03c8 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 \u2286 Y) : voc X \u2286 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} {\u03d5 : formula} : voc (X \\ {\u03d5}) \u2286 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 \u222a Y) = voc X \u222a voc Y :=\nbegin\n  unfold voc vocabOfSetFormula,\n  ext1,\n  simp,\n  split ; { intro _, finish, },\nend\n\nlemma vocPreserved (X : finset formula) (\u03c8 \u03d5) :\n  \u03c8 \u2208 X \u2192 voc \u03d5 = voc \u03c8 \u2192 voc X = voc (X \\ {\u03c8} \u222a {\u03d5}) :=\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 \u27e8\u03b8,_,a_in_vocTheta\u27e9,\n    by_cases h : \u03b8 = \u03c8,\n    { left, rw eq_voc, rw \u2190 h, exact a_in_vocTheta, },\n    { right, use \u03b8, tauto, },\n  },\n  { cases a_in,\n    { use \u03c8, rw \u2190 eq_voc, tauto, },\n    { rcases a_in with \u27e8\u03b8,_,a_in_vocTheta\u27e9, use \u03b8, tauto, }\n  },\nend\n\nlemma vocPreservedTwo {X : finset formula} (\u03c8 \u03d51 \u03d52) :\n  \u03c8 \u2208 X \u2192 voc ({\u03d51,\u03d52} : finset formula) = voc \u03c8 \u2192 voc X = voc (X \\ {\u03c8} \u222a {\u03d51,\u03d52}) :=\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 \u27e8\u03b8,theta_in_X,a_in_vocTheta\u27e9,\n    by_cases h : \u03b8 = \u03c8,\n    { right, subst h, unfold vocabOfSetFormula vocabOfFormula at *, simp at *, rw \u2190 eq_voc at a_in_vocTheta, simp at a_in_vocTheta, tauto, },\n    { use \u03b8, itauto, },\n  },\n  cases a_in,\n  { rcases a_in with \u27e8\u03b8,theta_in_X,a_in_vocTheta\u27e9, use \u03b8, itauto, },\n  { use \u03c8, split, itauto, rw \u2190 eq_voc, unfold vocabOfSetFormula, simp, itauto, },\nend\n\nlemma vocPreservedSub {X : finset formula} (\u03c8 \u03d5) :\n  \u03c8 \u2208 X \u2192 voc \u03d5 \u2286 voc \u03c8 \u2192 voc (X \\ {\u03c8} \u222a {\u03d5}) \u2286 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 \u03c8, rw finset.subset_iff at sub_voc, tauto, },\n  { rcases a_in with \u27e8\u03b8,_,a_in_vocTheta\u27e9, use \u03b8, 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 {\u03b1 : Type _} (s : Set \u03b1)\n\nsection SupSet\n\nvariable [SupSet \u03b1]\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\u209b t :=\n    if ht : sup\u209b (coe '' t : Set \u03b1) \u2208 s then \u27e8sup\u209b (coe '' t : Set \u03b1), ht\u27e9 else default\n#align subset_has_Sup subsetSupSet\n-/\n\nattribute [local instance] subsetSupSet\n\n#print subset_sup\u209b_def /-\n@[simp]\ntheorem subset_sup\u209b_def [Inhabited s] :\n    @sup\u209b s _ = fun t =>\n      if ht : sup\u209b (coe '' t : Set \u03b1) \u2208 s then \u27e8sup\u209b (coe '' t : Set \u03b1), ht\u27e9 else default :=\n  rfl\n#align subset_Sup_def subset_sup\u209b_def\n-/\n\n#print subset_sup\u209b_of_within /-\ntheorem subset_sup\u209b_of_within [Inhabited s] {t : Set s} (h : sup\u209b (coe '' t : Set \u03b1) \u2208 s) :\n    sup\u209b (coe '' t : Set \u03b1) = (@sup\u209b s _ t : \u03b1) := by simp [dif_pos h]\n#align subset_Sup_of_within subset_sup\u209b_of_within\n-/\n\nend SupSet\n\nsection InfSet\n\nvariable [InfSet \u03b1]\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\u209b t :=\n    if ht : inf\u209b (coe '' t : Set \u03b1) \u2208 s then \u27e8inf\u209b (coe '' t : Set \u03b1), ht\u27e9 else default\n#align subset_has_Inf subsetInfSet\n-/\n\nattribute [local instance] subsetInfSet\n\n#print subset_inf\u209b_def /-\n@[simp]\ntheorem subset_inf\u209b_def [Inhabited s] :\n    @inf\u209b s _ = fun t =>\n      if ht : inf\u209b (coe '' t : Set \u03b1) \u2208 s then \u27e8inf\u209b (coe '' t : Set \u03b1), ht\u27e9 else default :=\n  rfl\n#align subset_Inf_def subset_inf\u209b_def\n-/\n\n#print subset_inf\u209b_of_within /-\ntheorem subset_inf\u209b_of_within [Inhabited s] {t : Set s} (h : inf\u209b (coe '' t : Set \u03b1) \u2208 s) :\n    inf\u209b (coe '' t : Set \u03b1) = (@inf\u209b s _ t : \u03b1) := by simp [dif_pos h]\n#align subset_Inf_of_within subset_inf\u209b_of_within\n-/\n\nend InfSet\n\nvariable [ConditionallyCompleteLinearOrder \u03b1]\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 {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : Inhabited.{succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)], (forall {t : Set.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)}, (Set.Nonempty.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) t) -> (BddAbove.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)) t) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) (Set.image.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 ((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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))))) t)) s)) -> (forall {t : Set.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)}, (Set.Nonempty.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) t) -> (BddBelow.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)) t) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) (Set.image.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 ((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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))))) t)) s)) -> (ConditionallyCompleteLinearOrder.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (s : Set.{u1} \u03b1) [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] [_inst_2 : Inhabited.{succ u1} (Set.Elem.{u1} \u03b1 s)], (forall {t : Set.{u1} (Set.Elem.{u1} \u03b1 s)}, (Set.Nonempty.{u1} (Set.Elem.{u1} \u03b1 s) t) -> (BddAbove.{u1} (Set.Elem.{u1} \u03b1 s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) t) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) (Set.image.{u1, u1} (Set.Elem.{u1} \u03b1 s) \u03b1 (Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) t)) s)) -> (forall {t : Set.{u1} (Set.Elem.{u1} \u03b1 s)}, (Set.Nonempty.{u1} (Set.Elem.{u1} \u03b1 s) t) -> (BddBelow.{u1} (Set.Elem.{u1} \u03b1 s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) t) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) (Set.image.{u1, u1} (Set.Elem.{u1} \u03b1 s) \u03b1 (Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) t)) s)) -> (ConditionallyCompleteLinearOrder.{u1} (Set.Elem.{u1} \u03b1 s))\nCase conversion may be inaccurate. Consider using '#align subset_conditionally_complete_linear_order subsetConditionallyCompleteLinearOrder\u2093'. -/\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 : \u2200 {t : Set s} (ht : t.Nonempty) (h_bdd : BddAbove t), sup\u209b (coe '' t : Set \u03b1) \u2208 s)\n    (h_Inf : \u2200 {t : Set s} (ht : t.Nonempty) (h_bdd : BddBelow t), inf\u209b (coe '' t : Set \u03b1) \u2208 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\u209b_image hct h_bdd\n      rwa [subset_sup\u209b_of_within s (h_Sup \u27e8c, hct\u27e9 h_bdd)] at this\n    cSup_le := by\n      rintro t B ht hB\n      have := (Subtype.mono_coe s).csup\u209b_image_le ht hB\n      rwa [subset_sup\u209b_of_within s (h_Sup ht \u27e8B, hB\u27e9)] at this\n    le_cInf := by\n      intro t B ht hB\n      have := (Subtype.mono_coe s).le_cinf\u209b_image ht hB\n      rwa [subset_inf\u209b_of_within s (h_Inf ht \u27e8B, hB\u27e9)] at this\n    cInf_le := by\n      rintro t c h_bdd hct\n      have := (Subtype.mono_coe s).cinf\u209b_image_le hct h_bdd\n      rwa [subset_inf\u209b_of_within s (h_Inf \u27e8c, hct\u27e9 h_bdd)] at this }\n#align subset_conditionally_complete_linear_order subsetConditionallyCompleteLinearOrder\n\nsection OrdConnected\n\n/- warning: Sup_within_of_ord_connected -> sup\u209b_within_of_ordConnected is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] {s : Set.{u1} \u03b1} [hs : Set.OrdConnected.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s] {{t : Set.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)}}, (Set.Nonempty.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) t) -> (BddAbove.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)) t) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasSup.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) (Set.image.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 ((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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))))) t)) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] {s : Set.{u1} \u03b1} [hs : Set.OrdConnected.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s] {{t : Set.{u1} (Set.Elem.{u1} \u03b1 s)}}, (Set.Nonempty.{u1} (Set.Elem.{u1} \u03b1 s) t) -> (BddAbove.{u1} (Set.Elem.{u1} \u03b1 s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) t) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (SupSet.sup\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toSupSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) (Set.image.{u1, u1} (Set.Elem.{u1} \u03b1 s) \u03b1 (Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) t)) s)\nCase conversion may be inaccurate. Consider using '#align Sup_within_of_ord_connected sup\u209b_within_of_ordConnected\u2093'. -/\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\u209b_within_of_ordConnected {s : Set \u03b1} [hs : OrdConnected s] \u2983t : Set s\u2984 (ht : t.Nonempty)\n    (h_bdd : BddAbove t) : sup\u209b (coe '' t : Set \u03b1) \u2208 s :=\n  by\n  obtain \u27e8c, hct\u27e9 : \u2203 c, c \u2208 t := ht\n  obtain \u27e8B, hB\u27e9 : \u2203 B, B \u2208 upperBounds t := h_bdd\n  refine' hs.out c.2 B.2 \u27e8_, _\u27e9\n  \u00b7 exact (Subtype.mono_coe s).le_csup\u209b_image hct \u27e8B, hB\u27e9\n  \u00b7 exact (Subtype.mono_coe s).csup\u209b_image_le \u27e8c, hct\u27e9 hB\n#align Sup_within_of_ord_connected sup\u209b_within_of_ordConnected\n\n/- warning: Inf_within_of_ord_connected -> inf\u209b_within_of_ordConnected is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] {s : Set.{u1} \u03b1} [hs : Set.OrdConnected.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s] {{t : Set.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)}}, (Set.Nonempty.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) t) -> (BddBelow.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)) t) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toHasInf.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) (Set.image.{u1, u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 ((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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s)))))) t)) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : ConditionallyCompleteLinearOrder.{u1} \u03b1] {s : Set.{u1} \u03b1} [hs : Set.OrdConnected.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) s] {{t : Set.{u1} (Set.Elem.{u1} \u03b1 s)}}, (Set.Nonempty.{u1} (Set.Elem.{u1} \u03b1 s) t) -> (BddBelow.{u1} (Set.Elem.{u1} \u03b1 s) (Subtype.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (ConditionallyCompleteLattice.toLattice.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1))))) (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) t) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) (InfSet.inf\u209b.{u1} \u03b1 (ConditionallyCompleteLattice.toInfSet.{u1} \u03b1 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b1 _inst_1)) (Set.image.{u1, u1} (Set.Elem.{u1} \u03b1 s) \u03b1 (Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s)) t)) s)\nCase conversion may be inaccurate. Consider using '#align Inf_within_of_ord_connected inf\u209b_within_of_ordConnected\u2093'. -/\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\u209b_within_of_ordConnected {s : Set \u03b1} [hs : OrdConnected s] \u2983t : Set s\u2984 (ht : t.Nonempty)\n    (h_bdd : BddBelow t) : inf\u209b (coe '' t : Set \u03b1) \u2208 s :=\n  by\n  obtain \u27e8c, hct\u27e9 : \u2203 c, c \u2208 t := ht\n  obtain \u27e8B, hB\u27e9 : \u2203 B, B \u2208 lowerBounds t := h_bdd\n  refine' hs.out B.2 c.2 \u27e8_, _\u27e9\n  \u00b7 exact (Subtype.mono_coe s).le_cinf\u209b_image \u27e8c, hct\u27e9 hB\n  \u00b7 exact (Subtype.mono_coe s).cinf\u209b_image_le hct \u27e8B, hB\u27e9\n#align Inf_within_of_ord_connected inf\u209b_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\u209b_within_of_ordConnected inf\u209b_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 {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)] \n  (\u03bc:\u03a0 a, measure_theory.outer_measure (\u03b2 a)):measure_theory.outer_measure (\u03a0 a, \u03b2 a) := \n  measure_theory.outer_measure.of_function\n  (\u03bb P:set (\u03a0 a, \u03b2 a), finset.univ.prod (\u03bb (a:\u03b1), (\u03bc a) ((\u03bb (p:\u03a0 a, \u03b2 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 {\u03b1:Type*} {f g:\u03b1 \u2192 ennreal} {s:finset \u03b1}:(\u2200 a\u2208 s, f a \u2264 g a) \u2192 s.prod f \u2264 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 {\u03b1:Type*} [F:fintype \u03b1] {d:\u03b1}:\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 {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)] \n  (\u03bc:\u03a0 a, measure_theory.measure (\u03b2 a)):measure_theory.measure (\u03a0 a, \u03b2 a) := \n  (pi.outer_measure (\u03bb a, (\u03bc 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:(\u03bc d) ((\u03bb (p : \u03a0 (a : \u03b1), (\u03bb (a : \u03b1), \u03b2 a) a), p d) '' t\u2229 s) +\n          (\u03bc d) ((\u03bb (p : \u03a0 (a : \u03b1), (\u03bb (a : \u03b1), \u03b2 a) a), p d) '' t\\ s) =\n          (\u03bc d) ((\u03bb (p : \u03a0 (a : \u03b1), (\u03bb (a : \u03b1), \u03b2 a) a), p d) '' t),\n  { rw \u2190 measure_theory.measure_eq_inter_diff', apply A1 },\n   rw \u2190 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 {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} {a a':\u03b1} (b:\u03b2 a) (h:a = a'):\u03b2 a' := cast begin\nrw h end b  \n\n\ndef subst.pi {\u03b1:Type*} [decidable_eq \u03b1] {\u03b2:\u03b1 \u2192 Type*} (f:\u03a0 (a:\u03b1), \u03b2 a) (a':\u03b1) (b:\u03b2 a'):\u03a0 (a:\u03b1), \u03b2 a :=\n  \u03bb (a:\u03b1), @dite (a' = a) _ (\u03b2 a) (\u03bb h, cast.pi b h) (\u03bb h, f a)\n\n\nlemma subst.pi_eq {\u03b1:Type*} [decidable_eq \u03b1] {\u03b2:\u03b1 \u2192 Type*} (f:\u03a0 (a:\u03b1), \u03b2 a) (a':\u03b1) (b:\u03b2 a'):\n  (subst.pi f a' b) a' = b := begin\n  simp [subst.pi],\n  refl,\nend\n\n\nlemma subst.pi_ne {\u03b1:Type*} [decidable_eq \u03b1] {\u03b2:\u03b1 \u2192 Type*} (f:\u03a0 (a:\u03b1), \u03b2 a) (a a':\u03b1) (b:\u03b2 a')\n (h:a' \u2260 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 {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} {f:\u03a0 (a:\u03b1), set (\u03b2 a)} (h:\u2200 a, (f a).nonempty) \n  {a':\u03b1}:\n      ((\u03bb (p : \u03a0 (a : \u03b1), \u03b2 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:\u2200 (a:\u03b1), \u2203 b:\u03b2 a, b \u2208 (f a),\n    { intros a, rw \u2190 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 {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} {f:\u03a0 (a:\u03b1), set (\u03b2 a)}  \n  {a':\u03b1} (h2:f a' = \u2205):\n  (set.pi set.univ f) = \u2205 :=\nbegin\n  ext x, simp, split,\n  { have h3:x a' \u2209 f a',\n    { simp [h2] },\n    apply h3, },\nend\n\n\nlemma pi.outer_measure.Inf_sum {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)] \n  (\u03bc:\u03a0 a, measure_theory.outer_measure (\u03b2 a)) {P:set (\u03a0 a, \u03b2 a)}:\n  pi.outer_measure \u03bc P =\n  (\u2a05 (f:\u2115 \u2192 (\u03a0 (a:\u03b1), set (\u03b2 a))) (h\u2081:P \u2286 \u22c3 (n:\u2115), set.pi set.univ (f n)), \n  \u2211' (n:\u2115), finset.univ.prod (\u03bb (m:\u03b1), \u03bc m (f n m))) := begin\n  unfold pi.outer_measure measure_theory.outer_measure.of_function,\n  rw \u2190 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  _ _ _ _ (\u03bb (n:\u2115), 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 (\u2200 (a:\u03b1), (f n a).nonempty)) with B2 B2,\n  { have D1:(\u03bb (a : \u03b1), (\u03bc a) ((\u03bb (p : \u03a0 (a : \u03b1), \u03b2 a), p a) '' (\u03bb (n : \u2115), set.pi set.univ (f n)) n)) = (\u03bb (m : \u03b1), (\u03bc 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':\u2115 \u2192 (\u03a0 (a:\u03b1), set (\u03b2 a)) := (\u03bb n m, ((\u03bb (p:\u03a0 (a:\u03b1), \u03b2 a), p m) '' (f n))),\n    begin\n      apply @infi_le_of_le ennreal (\u2115 \u2192 (\u03a0 (a:\u03b1), set (\u03b2 a))) _ _ _ f',  \n      rw infi_prop_def,\n      simp [f'],\n      apply le_refl _,\n      apply @set.subset.trans (\u03a0 a, \u03b2 a) P (set.Union f) (\u22c3 (n : \u2115), 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 {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} {S:\u03a0 (a:\u03b1), set (\u03b2 a)} {T:\u03a0 (a:\u03b1), set (\u03b2 a)}:\n    (\u2200 a, S a \u2286 T a) \u2192 set.pi set.univ S \u2286 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 {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 (a:\u03b1), measurable_space (\u03b2 a)] \n  (\u03bc:\u03a0 (a:\u03b1), measure_theory.measure (\u03b2 a)) {P:set (\u03a0 (a:\u03b1), \u03b2 a)}:\n  pi.outer_measure (\u03bb (a:\u03b1), (\u03bc a).to_outer_measure) P = \n\n  (\u2a05 (f:\u2115 \u2192 (\u03a0 (a:\u03b1), set (\u03b2 a))) (h\u2081:\u2200 n m, measurable_set (f n m))\n  (h\u2083:P \u2286 \u22c3 (n:\u2115), set.pi set.univ (f n)), \n  \u2211' (n:\u2115), finset.univ.prod (\u03bb (m:\u03b1), \u03bc m (f n m))) := begin\n  rw pi.outer_measure.Inf_sum,\n  apply le_antisymm,\n  { simp,\n    intros f h\u2081 h\u2083,\n    apply @infi_le_trans (\u2115\u2192 \u03a0 (a:\u03b1), set (\u03b2 a)) ennreal _ f,\n    rw infi_prop_def,\n    apply le_refl _,\n    apply h\u2083 },\n  { simp,\n    intros f h\u2081,\n   have h4_2 := \u03bb (n:\u2115) (m:\u03b1), measure_theory.measurable_eq (\u03bc m) (f n m),\n    have h4:\u2200 n, \u2203 (g:\u03a0 (a:\u03b1), set (\u03b2 a)), \u2200 (a:\u03b1), measurable_set (g a) \u2227 (\u03bc a) (g a) = (\u03bc a) (f n a) \u2227 f n a \u2286 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 (\u2115\u2192 (\u03a0 (a:\u03b1), set (\u03b2 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\u2081,\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 {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)] \n  (\u03bc:\u03a0 a, measure_theory.outer_measure (\u03b2 a)) {P:(\u03a0 a, set (\u03b2 a))}:\n  pi.outer_measure \u03bc (set.pi set.univ P) \u2264 finset.univ.prod (\u03bb a, \u03bc a (P a)) :=\nbegin\n  rw pi.outer_measure.Inf_sum,\n  { apply @infi_le_of_le ennreal _ _ _ _ (\u03bb (n:\u2115) (a:\u03b1), ite (n = 0) (P a) \u2205),\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 {\u03b1:Type*} [F:fintype \u03b1] {\u03b2:\u03b1 \u2192 Type*} {P:\u03a0 a, set (\u03b2 a)}\n  {x:\u03a0 a, \u03b2 a}:(set.pi set.univ P).characteristic x = \nfinset.univ.prod (\u03bb a, (P a).characteristic (x a)) :=\nbegin\n  have A1:\u2200 S:finset \u03b1, (set.pi (\u2191S) P).characteristic x = \n       S.prod (\u03bb 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 \u2190 h_ind,\n      cases classical.em ((x a) \u2208 (P a)) with A1 A1,\n      rw set.characteristic.of_mem A1,\n      rw one_mul,\n      cases classical.em (x \u2208 (set.pi (\u2191T) 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 = \u2191(finset.univ),\n  { ext x, split; intros A1, rw  @finset.mem_coe \u03b1 x, simp, simp },\n  rw A2,\n  apply A1,\nend\n\n\nlemma finset.prod_univ_diff_insert {\u03b1:Type*} [fintype \u03b1] (f:\u03b1 \u2192 ennreal) (A:finset \u03b1) (a:\u03b1) (h:a\u2209 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 {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)] \n  (\u03bc:\u03a0 a, measure_theory.measure (\u03b2 a)) {P:(\u03a0 a, set (\u03b2 a))}:(\u2200 (a:\u03b1), measurable_set (P a)) \u2192\n  finset.univ.prod (\u03bb a, \u03bc a (P a)) \u2264\n  pi.outer_measure (\u03bb a, (\u03bc 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 (\u2200 (a:\u03b1), (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 \u2264 \u2211' (n : \u2115), (set.pi set.univ (f n)).characteristic,\n  { apply function.le_trans (set.characteristic.subset A3),\n    apply set.characteristic.Union },\n  have h3:\u2200 (x:\u03a0 (a:\u03b1), \u03b2 a), finset.univ.prod (\u03bb a, (P a).characteristic (x a))  \u2264 \n          \u2211' (n : \u2115), finset.univ.prod (\u03bb a, (f n a).characteristic (x a)),\n  { intros x,\n    rw \u2190 set.characteristic.pi,\n    have h3a: (\u03bb n, (finset.univ.prod (\u03bb a, (f n a).characteristic (x a)))) =\n              (\u03bb n, (set.pi (set.univ) (f n)).characteristic x),\n    { ext1 n, rw set.characteristic.pi },\n    rw h3a,\n    have h3b:((\u2211' (n : \u2115), (set.pi set.univ (f n)).characteristic) x) =\n        (\u2211' (n : \u2115), (set.pi set.univ (f n)).characteristic x) ,\n    { apply ennreal.tsum_apply }, \n    rw \u2190 h3b,\n    apply h2 },\n  have h4:\u2200 (A:finset \u03b1), \u2200 (x:\u03a0 (a:\u03b1), \u03b2 a),\n    (A.prod (\u03bb a, \u03bc a (P a))) * ((finset.univ \\ A).prod (\u03bb a, (P a).characteristic (x a))) \u2264\n    \u2211' (n:\u2115), (A.prod (\u03bb a, \u03bc a (f n a))) * ((finset.univ \\ A).prod (\u03bb 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:(\u03bb (x':\u03b2 a'), (P a').characteristic (x') *\n      (s.prod (\u03bb (a : \u03b1), (\u03bc a) (P a)) *\n         (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (P a).characteristic (x a)))) \u2264\n    (\u03bb (x':\u03b2 a'), \u2211' (n : \u2115),\n      (f n a').characteristic (x') *\n        (s.prod (\u03bb (a : \u03b1), (\u03bc a) (f n a)) *\n           (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (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 (\u03bb (a : \u03b1), (\u03bc a) (P a)) * (finset.univ \\ s).prod (\u03bb (a : \u03b1), (P a).characteristic (subst.pi x a' x' a)) =  \n (P a').characteristic (x') *\n(s.prod (\u03bb (a : \u03b1), (\u03bc a) (P a)) *\n       (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (P a).characteristic (x a))),\n      { \n        have h4_1_2_1:\n      (finset.univ \\ (insert  a' s)).prod (\u03bb (a : \u03b1), (P a).characteristic (subst.pi x a' x' a)) =\n      (finset.univ \\ (insert a' s)).prod (\u03bb \u2983a' : \u03b1\u2984, (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 \u2190 h4_1_2_1,\n        clear h4_1_2_1,\n        rw \u2190 mul_assoc, rw mul_comm ((P a').characteristic (x')),\n        rw mul_assoc,\n        have h4_1_2_2:(P a').characteristic x' = (\u03bb 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:(\u03bb \n(n : \u2115),\n      s.prod (\u03bb (a : \u03b1), (\u03bc a) (f n a)) *\n        (finset.univ \\ s).prod (\u03bb (a : \u03b1), (f n a).characteristic (subst.pi x a' x' a))) =\n(\u03bb (n:\u2115), \n      (f n a').characteristic x' *\n        (s.prod (\u03bb (a : \u03b1), (\u03bc a) (f n a)) *\n           (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (f n a).characteristic (x a)))),\n      { ext1 n,\n        have h4_1_2_1:\n      (finset.univ \\ (insert  a' s)).prod (\u03bb (a : \u03b1), (f n a).characteristic (subst.pi x a' x' a)) =\n      (finset.univ \\ (insert a' s)).prod (\u03bb \u2983a' : \u03b1\u2984, (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 \u2190 h4_1_2_1,\n        clear h4_1_2_1,\n        rw \u2190 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' = (\u03bb 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 (\u03bc a') (\u03bb (x':\u03b2 a'), (P a').characteristic (x') *\n      (s.prod (\u03bb (a : \u03b1), (\u03bc a) (P a)) *\n         (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (P a).characteristic (x a)))) \u2264\n         measure_theory.lintegral (\u03bc a')\n    (\u03bb (x':\u03b2 a'), \u2211' (n : \u2115),\n      (f n a').characteristic (x') *\n        (s.prod (\u03bb (a : \u03b1), (\u03bc a) (f n a)) *\n           (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (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 (\u03bc a') (\u03bb (x':\u03b2 a'), (P a').characteristic (x') *\n      (s.prod (\u03bb (a : \u03b1), (\u03bc a) (P a)) *\n         (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (P a).characteristic (x a)))) =\n         (insert a' s).prod (\u03bb (a : \u03b1), (\u03bc a) (P a)) *\n         (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (P a).characteristic (x a)),\n      { rw measure_theory.lintegral_mul_const,\n        rw measure_theory.lintegral_characteristic,\n        rw \u2190 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:(\u222b\u207b (x' : \u03b2 a'),\n      (\u2211' (n : \u2115),\n         (f n a').characteristic x' *\n           (s.prod (\u03bb (a : \u03b1), (\u03bc a) (f n a)) *\n              (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (f n a).characteristic (x a)))) \u2202\u03bc a')\n        = \n      (\u2211' (n : \u2115),\n\u222b\u207b (x' : \u03b2 a'),\n(f n a').characteristic x' *\n           (s.prod (\u03bb (a : \u03b1), (\u03bc a) (f n a)) *\n              (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (f n a).characteristic (x a))) \u2202\u03bc 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:(\u03bb (n : \u2115),\n\u222b\u207b (x' : \u03b2 a'),\n(f n a').characteristic x' *\n           (s.prod (\u03bb (a : \u03b1), (\u03bc a) (f n a)) *\n              (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (f n a).characteristic (x a))) \u2202\u03bc a') =\n(\u03bb (n : \u2115),\n           (insert a' s).prod (\u03bb (a : \u03b1), (\u03bc a) (f n a)) *\n              (finset.univ \\ insert a' s).prod (\u03bb (a : \u03b1), (f n a).characteristic (x a))),\n      { ext1 n,\n        rw measure_theory.lintegral_mul_const,\n        rw measure_theory.lintegral_characteristic,\n        rw \u2190 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:\u2200 (a:\u03b1), \u2203 x, x \u2208 P a,\n  { intros a, rw \u2190 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{\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)] \n  (\u03bc:\u03a0 a, measure_theory.measure (\u03b2 a)) {P:set (\u03a0 a, \u03b2 a)}:measurable_set P \u2192\n  pi.measure \u03bc P =\n  pi.outer_measure (\u03bb a, (\u03bc 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'' {\u03b1:Type*} [F:fintype \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)]\n  {P:\u03a0 a, set (\u03b2 a)}:(\u2200 a, measurable_set (P a)) \u2192\n  measurable_set (set.pi set.univ P) := begin\n  intros A0,\n  have A1:(set.pi set.univ P) = \u22c2 a, ((\u03bb (p:\u03a0 a, \u03b2 a), p a) \u207b\u00b9' (P a)),\n  { ext x, simp,  },\n  rw A1,\n  have A3:trunc (encodable \u03b1) := encodable.trunc_encodable_of_fintype \u03b1,\n  trunc_cases A3,\n  haveI:encodable \u03b1 := A3,\n  apply measurable_set.Inter,\n  intros a',\n  have A2:measurable_space.comap (\u03bb (p:\u03a0 a, \u03b2 a), p a') (M a') \u2264 measurable_space.pi,\n  { simp [measurable_space.pi], apply @le_supr (measurable_space (\u03a0 a, \u03b2 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{\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} [M:\u2200 a, measurable_space (\u03b2 a)] \n  (\u03bc:\u03a0 a, measure_theory.measure (\u03b2 a)) {P:\u03a0 a, set (\u03b2 a)}:(\u2200 a, measurable_set (P a)) \u2192\n  pi.measure \u03bc (set.pi set.univ P) =\n  finset.univ.prod (\u03bb a, \u03bc 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 Mt.Reservation\nimport Mt.Thread\n\nnamespace SampleSimple\n\nstructure State where\n  x : Nat\n  y : Nat\n\ndef spec : Mt.Spec :={\n  State\n  Reservation :=Nat\n  validate := fun (luft : Nat) \u27e8x, y\u27e9 => x \u2265 y + luft\n}\n\nopen Mt\nopen Mt.TaskM\n\ndef thread1 : Thread spec :=mk_thread do\n  -- increase x atomically\n  atomic_read_modify \u03bb s => { s with x := s.x + 1 }\n  \n  -- increase y atomically\n  atomic_read_modify \u03bb s => { s with y := s.y + 1 }\n\n  atomic_assert fun \u27e8x, y\u27e9 => x \u2265 y\n\ntheorem thread1_valid : thread1.valid :=by\n  rw [Thread.valid]\n  apply valid_bind (spec :=spec) \u03bb _ (luft : Nat) => luft = 1\n  . -- validate ++x\n    ---------------\n    apply valid_rm\n    intro (env_luft : Nat) \u27e8x, y\u27e9 _ initial_valid\n    exists (1 : Nat)\n    simp only [and_true]\n\n    have : x \u2265 y + env_luft :=initial_valid\n    show x + 1 \u2265 y + env_luft + 1\n\n    exact Nat.succ_le_succ (by assumption)\n  \n  intro (luft : Nat) \u27e8\u27e9 luft_def\n  apply valid_bind (spec :=spec) \u03bb _ (luft : Nat) => luft = 0\n  . -- validate ++y knowing luft = 1\n    --------------------------------\n    apply valid_rm\n    intro (env_luft : Nat) \u27e8x, y\u27e9 _ initial_valid\n    exists (0 : Nat)\n    simp only [and_true]\n\n    rw [luft_def] at initial_valid\n\n    have : x \u2265 y + env_luft + 1 :=initial_valid\n    show x \u2265 y + 1 + env_luft\n\n    rw [Nat.add_right_comm] ; assumption\n  \n  clear luft luft_def\n  intro (luft : Nat) \u27e8\u27e9 luft_def\n  apply valid_assert (spec :=spec) luft_def\n  . -- validate `assert x \u2265 y`\n    ----------------------------\n    intro (env_luft : Nat) \u27e8x, y\u27e9 _ initial_valid\n\n    have : x \u2265 y + (env_luft + luft) :=initial_valid\n    show decide (x \u2265 y) = true\n\n    exact decide_eq_true <| calc\n      y \u2264 y + (env_luft + luft) :=by simp_arith\n      _ \u2264 x                     :=by assumption\n\nend SampleSimple", "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/Samples/sample_simple.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7341195152660688, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.47030328321712955}}
{"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 (\u03b1 : Type _) [decidable_eq \u03b1] (\u03c6 : Type _) [decidable_eq \u03c6] [model binary_module \u03c6] : inv_pred binary_module (\u03b1 \u2192 \u03c6) :=\n{\n  p := \u03bb f, is_finite {x // f x \u2260 0},\n  hinv :=\n    begin\n      intros n \u03bc fs hall,\n      cases \u03bc,\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 (\u03bb x, f x + g x \u2260 0),\n        dsimp at hfin',\n        refine is_finite.of_iff _ hfin',\n        intros x,\n        have : @premodel.act binary_module _ _ _ ops.add \u2045f,g\u2046 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 \u2192 _, {\n          intros hfx,\n          rw [hfx, _root_.zero_add] at hfgx,\n          exact or.inr hfgx\n        },\n        show f x \u2260 0 \u2192 _, {\n          exact or.inl\n        }\n      }\n    end\n}\n\n@[reducible]\ndefinition finsupp_fun (\u03b1 : Type _) [decidable_eq \u03b1] (\u03c6 : Type _) [decidable_eq \u03c6] [model binary_module \u03c6] :=\n  submodel binary_module (binary_module.has_finite_support \u03b1 \u03c6)\n\n@[reducible,inline]\ndefinition finsupp_bits (\u03b1 : Type _) [decidable_eq \u03b1] :=\n  finsupp_fun \u03b1 bool\n\n@[reducible]\ndefinition singlebit {\u03b1 : Type _} [decidable_eq \u03b1] : \u03b1 \u2192 finsupp_bits \u03b1 :=\n  \u03bb a, subtype.mk (\u03bb 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) \u2260 0,\n        by rw [to_bool_tt rfl]; intro h; exact bool.ff_ne_tt h.symm,\n      refine subtype.mk [\u27e8a,ha\u27e9] \u27e8list.nodup.nil.cons (list.not_mem_nil _), _\u27e9,\n      intros x,\n      refine dite (a = x.val) _ _,\n      show a = x.val \u2192 _, {\n        intros hax,\n        exact or.inl (subtype.eq hax.symm)\n      },\n      show a \u2260 x.val \u2192 _, {\n        intros hax,\n        have : ff \u2260 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 {\u03b1 : Type _} [decidable_eq \u03b1] {a : \u03b1} : \u2200 x, (singlebit a).val x \u2260 0 \u2194 x = a :=\n  \u03bb x, iff.intro\n    (\u03bb 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    (\u03bb 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 {\u03b1 : Type _} [decidable_eq \u03b1] {a : \u03b1} : \u2200 (l : exhaustive_list {x // (singlebit a).val x \u2260 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 \u03b1`, then the support of `w + singlebit a` is exactly the support of `w` minus `a`.\nlemma support_of_add_singlebit_of_nonzero {\u03b1 : Type _} [decidable_eq \u03b1] {w : finsupp_bits \u03b1} {a : \u03b1} : w.val a \u2260 0 \u2192 \u2200 (l : exhaustive_list {x // w.val x \u2260 0}) (la : exhaustive_list {x // w.val x + (singlebit a).val x \u2260 0}), list.perm l.underlying (a :: la.underlying) :=\n  begin\n    intros hwa l la,\n    dsimp [singlebit] at la,\n    have ha : a \u2209 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 \u2208 l.underlying \u2192 _, {\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 \u2208 a :: la.underlying \u2192 _, {\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 \u2260 x,\n          from (\u03bb h, ha (by rw [\u2190h] 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 {\u03b1 : Type _} [decidable_eq \u03b1] {\u03c6 : Type _} [model binary_module \u03c6] (f : \u03b1 \u2192 \u03c6) : finsupp_bits \u03b1 \u21d2 \u03c6 :=\n{\n  p := \u03bb w y, \u2200 (l : exhaustive_list {a // w.val a \u2260 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 \u2200 (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 \u2200 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 {\u03b1 : Type _} [decidable_eq \u03b1] {\u03c6 : Type _} [model binary_module \u03c6] (f : \u03b1 \u2192 \u03c6) : (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 {\u03b1 : Type _} [decidable_eq \u03b1] {\u03c6 : Type _} [model binary_module \u03c6] (f : \u03b1 \u2192 \u03c6) : \u2200 (a : \u03b1), (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 {\u03b1 : Type _} [decidable_eq \u03b1] {\u03c6 : Type _} [model binary_module \u03c6] (f : \u03b1 \u2192 \u03c6) : \u2200 (v w : finsupp_bits \u03b1) (y z : \u03c6), (waccum_funrel f).p v y \u2192 (waccum_funrel f).p w z \u2192 (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 : \u2200 a, (binary_module.add v w).val a \u2260 0 \u2194 (v.val a \u2260 0 \u2227 \u00acw.val a \u2260 0) \u2228 (\u00acv.val a \u2260 0 \u2227 w.val a \u2260 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) \u2260 0\n            \u2194 bxor (v.val a) (w.val a) = tt : neq_ff_iff _\n        ... \u2194 v.val a \u2260 w.val a : bxor_eq_tt_iff _ _\n        ... \u2194 (v.val a = tt \u2227 w.val a = 0) \u2228 (v.val a = 0 \u2227 w.val a = tt)\n            : bool.neq_iff (v.val a) (w.val a)\n        ... \u2194 (v.val a \u2260 0 \u2227 \u00acw.val a \u2260 0) \u2228 (\u00acv.val a \u2260 0 \u2227 w.val a \u2260 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 \u2260 0} v.property with suppv,\n    cases @is_finite.has_exhaustive_list {x // w.val x \u2260 0} w.property with suppw,\n    specialize hvy suppv,\n    specialize hwz suppw,\n    rw [accum_partition (\u03bb x, w.val x \u2260 0)] at hvy,\n    rw [accum_partition (\u03bb x, v.val x \u2260 0)] at hwz,\n    rw [\u2190suppv.subrestrict_underlying (\u03bb x, w.val x\u2260 0)] at hvy,\n    rw [\u2190suppv.subrestrict_underlying (\u03bb x, \u00acw.val x\u2260 0)] at hvy,\n    rw [\u2190suppw.subrestrict_underlying (\u03bb x, v.val x\u2260 0)] at hwz,\n    rw [\u2190suppw.subrestrict_underlying (\u03bb x, \u00acv.val x\u2260 0)] at hwz,\n    let suppv_only := suppv.subrestrict (\u03bb x, \u00acw.val x\u22600),\n    let suppv_w := suppv.subrestrict (\u03bb x, w.val x\u22600),\n    unirewrite suppv.subrestrict (\u03bb x, \u00acw.val x\u22600) with suppv_only at hvy,\n    unirewrite suppv.subrestrict (\u03bb x, w.val x\u22600) with suppv_w at hvy,\n    let suppw_only := suppw.subrestrict (\u03bb x, \u00acv.val x\u22600),\n    let suppw_v := suppw.subrestrict (\u03bb x, v.val x\u22600),\n    unirewrite suppw.subrestrict (\u03bb x, \u00acv.val x\u22600) with suppw_only at hwz,\n    unirewrite suppw.subrestrict (\u03bb x, v.val x\u22600) with suppw_v at hwz,\n    dsimp only [] at hvy hwz,\n    let suppw_only' := suppw_only.of_iff (\u03bb x, @and.comm (w.val x\u2260 0) (\u00acv.val x\u2260 0)),\n    rw [\u2190suppw_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 [\u2190suppw_v.of_iff_underlying (\u03bb x, @and.comm (w.val x\u22600) (v.val x\u22600))],\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 [\u2190hvy,\u2190hwz]\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,\u2190_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 (\u03bb x (h : (\u00acv.val x = 0 \u2227 \u00ac\u00acw.val x = 0) \u2227 \u00acv.val x \u2260 0 \u2227 w.val x \u2260 0), h.left.right h.right.right)];\n                 rw [\u2190accum_append]\n      ... = accum f suppvw.underlying\n            : accum_perm (suppvw.underlying_perm (suppv_only.union (suppw_only.of_iff (\u03bb x, @and.comm (w.val x\u2260 0) (\u00acv.val x\u2260 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 {\u03b1 : Type _} [decidable_eq \u03b1]\n\n--- `finsupp_bits` is non-zero precisely if it has at least one `tt` bit.\nlemma finsupp_bits.nonzero (w : finsupp_bits \u03b1) : w \u2260 0 \u2192 \u2203 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 \u03b1) _ 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 \u2208 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 \u2208 l.underlying,\n        by let h := list.mem_cons_self a tl; rw [\u2190hl] 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 {\u03c6 : Type _} [model binary_module \u03c6] (f : \u03b1 \u2192 \u03c6) : finsupp_bits \u03b1 \u2192 \u03c6 :=\n  reify (waccum_funrel f)\n\nnoncomputable definition waccum_hom {\u03c6 : Type _} [model binary_module \u03c6] (f : \u03b1 \u2192 \u03c6) : hom (finsupp_bits \u03b1) \u03c6 :=\n  subtype.mk (waccum f) $\n    begin\n      intros _ \u03bc as,\n      dunfold waccum,\n      cases \u03bc,\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 {\u03c6 : Type _} [model binary_module \u03c6] (f : \u03b1 \u2192 \u03c6) : \u2200 (a : \u03b1), 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 \u03b1` is free with basis `\u03b1` provided `decidable_eq \u03b1`.\ntheorem finsupp_bits_free {\u03c6 : Type _} [model binary_module \u03c6] (f : \u03b1 \u2192 \u03c6) : \u2203! (g : morphism binary_module (finsupp_bits \u03b1) \u03c6), \u2200 a, g.val (singlebit a) = f a :=\n  begin\n    existsi waccum_hom f,\n    dsimp [waccum_hom],\n    split,\n    show \u2200 (a : \u03b1), _ = f a,\n      from waccum_single f,\n    show \u2200 (g : morphism binary_module (finsupp_bits \u03b1) _), _, {\n      intros g hg,\n      apply subtype.eq; dsimp *,\n      apply funext,\n      suffices : \u2200 (n : \u2115) (w : finsupp_bits \u03b1) (l : exhaustive_list {x // w.val x \u2260 0}), l.underlying.length = n \u2192 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 \u2208 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 \u2260 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 [\u2190add_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 [\u2190morphism.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 \u03b1) _ (singlebit a) (singlebit a) with @has_sub.sub (finsupp_bits \u03b1) _ (singlebit a) (singlebit a);\n                     rw [sub_self, add_zero]\n      }\n    --/\n    }\n  end\n\n---`finsupp_bits \u03b1` is free with basis `\u03b1` provided `decidable_eq \u03b1`.\ntheorem finsupp_bits.is_free : is_free binary_module (@singlebit \u03b1 _) :=\n  @finsupp_bits_free \u03b1 _\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\u2081 v\u2081 u\u2082 v\u2082 u\u2083 v\u2083 u\u2084 v\u2084\n\nsection\nvariables (C : Type u\u2081) [\ud835\udc9e : category.{u\u2081 v\u2081} C] (D : Type u\u2082) [\ud835\udc9f : category.{u\u2082 v\u2082} D]\ninclude \ud835\udc9e \ud835\udc9f\n\n/--\n`prod.category C D` gives the cartesian product of two categories.\n-/\ninstance prod : category.{(max u\u2081 u\u2082) (max v\u2081 v\u2082)} (C \u00d7 D) :=\n{ hom     := \u03bb X Y, ((X.1) \u27f6 (Y.1)) \u00d7 ((X.2) \u27f6 (Y.2)),\n  id      := \u03bb X, \u27e8 \ud835\udfd9 (X.1), \ud835\udfd9 (X.2) \u27e9,\n  comp    := \u03bb _ _ _ f g, (f.1 \u226b g.1, f.2 \u226b g.2) }\n\n-- rfl lemmas for category.prod\n@[simp] lemma prod_id (X : C) (Y : D) : \ud835\udfd9 (X, Y) = (\ud835\udfd9 X, \ud835\udfd9 Y) := rfl\n@[simp] lemma prod_comp {P Q R : C} {S T U : D} (f : (P, S) \u27f6 (Q, T)) (g : (Q, T) \u27f6 (R, U)) : f \u226b g = (f.1 \u226b g.1, f.2 \u226b g.2) := rfl\nend\n\nsection\nvariables (C : Type u\u2081) [\ud835\udc9e : category.{u\u2081 v\u2081} C] (D : Type u\u2081) [\ud835\udc9f : category.{u\u2081 v\u2081} D]\ninclude \ud835\udc9e \ud835\udc9f \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 \u00d7 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\u2081) [\ud835\udc9e : category.{u\u2081 v\u2081} C] (D : Type u\u2082) [\ud835\udc9f : category.{u\u2082 v\u2082} D]\ninclude \ud835\udc9e \ud835\udc9f\n\n/-- `inl C Z` is the functor `X \u21a6 (X, Z)`. -/\ndef inl (Z : D) : C \u2964 (C \u00d7 D) :=\n{ obj      := \u03bb X, (X, Z),\n  map'     := \u03bb X Y f, (f, \ud835\udfd9 Z) }\n\n/-- `inr D Z` is the functor `X \u21a6 (Z, X)`. -/\ndef inr (Z : C) : D \u2964 (C \u00d7 D) :=\n{ obj      := \u03bb X, (Z, X),\n  map'     := \u03bb X Y f, (\ud835\udfd9 Z, f) }\n\n/-- `fst` is the functor `(X, Y) \u21a6 X`. -/\ndef fst : (C \u00d7 D) \u2964 C :=\n{ obj      := \u03bb X, X.1,\n  map'     := \u03bb X Y f, f.1 }\n\n/-- `snd` is the functor `(X, Y) \u21a6 Y`. -/\ndef snd : (C \u00d7 D) \u2964 D :=\n{ obj      := \u03bb X, X.2,\n  map'     := \u03bb X Y f, f.2 }\n\ndef swap : (C \u00d7 D) \u2964 (D \u00d7 C) :=\n{ obj := \u03bb X, (X.2, X.1),\n  map' := \u03bb _ _ f, (f.2, f.1) }\n\ndef symmetry : ((swap C D) \u22d9 (swap D C)) \u2245 (functor.id (C \u00d7 D)) :=\n{ hom := { app := \u03bb X, \ud835\udfd9 X, \n           naturality' := begin intros, erw [category.comp_id (C \u00d7 D), category.id_comp (C \u00d7 D)], dsimp [swap], simp, end },\n  inv := { app := \u03bb X, \ud835\udfd9 X, \n           naturality' := begin intros, erw [category.comp_id (C \u00d7 D), category.id_comp (C \u00d7 D)], dsimp [swap], simp, end } }\n\nend prod\n\nsection\nvariables (C : Type u\u2081) [\ud835\udc9e : category.{u\u2081 v\u2081} C] (D : Type u\u2082) [\ud835\udc9f : category.{u\u2082 v\u2082} D]\ninclude \ud835\udc9e \ud835\udc9f \n\n-- TODO, later this can be defined by uncurrying `functor.id (C \u2964 D)`\ndef evaluation : ((C \u2964 D) \u00d7 C) \u2964 D := \n{ obj := \u03bb p, p.1 p.2,\n  map' := \u03bb x y f, (x.1.map f.2) \u226b (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 [\u2190nat_trans.vcomp_app, nat_trans.naturality, category.assoc, nat_trans.naturality] \n               end }\nend\n\nvariables {A : Type u\u2081} [\ud835\udc9c : category.{u\u2081 v\u2081} A] {B : Type u\u2082} [\u212c : category.{u\u2082 v\u2082} B] {C : Type u\u2083} [\ud835\udc9e : category.{u\u2083 v\u2083} C] {D : Type u\u2084} [\ud835\udc9f : category.{u\u2084 v\u2084} D]\ninclude \ud835\udc9c \u212c \ud835\udc9e \ud835\udc9f\n\nnamespace functor\n/-- The cartesian product of two functors. -/\ndef prod (F : A \u2964 B) (G : C \u2964 D) : (A \u00d7 C) \u2964 (B \u00d7 D) :=\n{ obj  := \u03bb X, (F X.1, G X.2),\n  map' := \u03bb _ _ 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 \u00d7 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 \u2964 B) (G : C \u2964 D) (a : A) (c : C) : (F.prod G) (a, c) = (F a, G c) := rfl\n@[simp] lemma prod_map  (F : A \u2964 B) (G : C \u2964 D) {a a' : A} {c c' : C} (f : (a, c) \u27f6 (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 \u2964 B} {H I : C \u2964 D} (\u03b1 : F \u27f9 G) (\u03b2 : H \u27f9 I) : F.prod H \u27f9 G.prod I :=\n{ app         := \u03bb X, (\u03b1 X.1, \u03b2 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 `\u03b1 \u00d7 \u03b2`; use instead `\u03b1.prod \u03b2` or `nat_trans.prod \u03b1 \u03b2`. -/\n\n@[simp] lemma prod_app  {F G : A \u2964 B} {H I : C \u2964 D} (\u03b1 : F \u27f9 G) (\u03b2 : H \u27f9 I) (a : A) (c : C) : (nat_trans.prod \u03b1 \u03b2) (a, c) = (\u03b1 a, \u03b2 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 : \u03b1 \u00d7 \u03b2 \u2192 \u03b2 \u00d7 \u03b1` and proves various simple lemmas about `prod`.\n-/\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _} {\u03b4 : Type _}\n\n@[simp]\ntheorem Prod_map (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) (p : \u03b1 \u00d7 \u03b2) : 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 \u00abforall\u00bb {p : \u03b1 \u00d7 \u03b2 \u2192 Prop} : (\u2200 x, p x) \u2194 \u2200 a b, p (a, b) :=\n  \u27e8fun h a b \u21a6 h (a, b), fun h \u27e8a, b\u27e9 \u21a6 h a b\u27e9\n#align prod.forall Prod.forall\n\n@[simp]\ntheorem \u00abexists\u00bb {p : \u03b1 \u00d7 \u03b2 \u2192 Prop} : (\u2203 x, p x) \u2194 \u2203 a b, p (a, b) :=\n  \u27e8fun \u27e8\u27e8a, b\u27e9, h\u27e9 \u21a6 \u27e8a, b, h\u27e9, fun \u27e8a, b, h\u27e9 \u21a6 \u27e8\u27e8a, b\u27e9, h\u27e9\u27e9\n#align prod.exists Prod.exists\n\ntheorem forall' {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2200 x : \u03b1 \u00d7 \u03b2, p x.1 x.2) \u2194 \u2200 a b, p a b :=\n  Prod.forall\n#align prod.forall' Prod.forall'\n\ntheorem exists' {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2203 x : \u03b1 \u00d7 \u03b2, p x.1 x.2) \u2194 \u2203 a b, p a b :=\n  Prod.exists\n#align prod.exists' Prod.exists'\n\n@[simp]\ntheorem snd_comp_mk (x : \u03b1) : Prod.snd \u2218 (Prod.mk x : \u03b2 \u2192 \u03b1 \u00d7 \u03b2) = id :=\n  rfl\n#align prod.snd_comp_mk Prod.snd_comp_mk\n\n@[simp]\ntheorem fst_comp_mk (x : \u03b1) : Prod.fst \u2218 (Prod.mk x : \u03b2 \u2192 \u03b1 \u00d7 \u03b2) = Function.const \u03b2 x :=\n  rfl\n#align prod.fst_comp_mk Prod.fst_comp_mk\n\n@[simp]\ntheorem map_mk (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) (a : \u03b1) (b : \u03b2) : map f g (a, b) = (f a, g b) :=\n  rfl\n#align prod.map_mk Prod.map_mk\n\ntheorem map_fst (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) (p : \u03b1 \u00d7 \u03b2) : (map f g p).1 = f p.1 :=\n  rfl\n#align prod.map_fst Prod.map_fst\n\ntheorem map_snd (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) (p : \u03b1 \u00d7 \u03b2) : (map f g p).2 = g p.2 :=\n  rfl\n#align prod.map_snd Prod.map_snd\n\ntheorem map_fst' (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) : Prod.fst \u2218 map f g = f \u2218 Prod.fst :=\n  funext <| map_fst f g\n#align prod.map_fst' Prod.map_fst'\n\ntheorem map_snd' (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) : Prod.snd \u2218 map f g = g \u2218 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 {\u03b5 \u03b6 : Type _} (f : \u03b1 \u2192 \u03b2) (f' : \u03b3 \u2192 \u03b4) (g : \u03b2 \u2192 \u03b5) (g' : \u03b4 \u2192 \u03b6) :\n    Prod.map g g' \u2218 Prod.map f f' = Prod.map (g \u2218 f) (g' \u2218 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 {\u03b5 \u03b6 : Type _} (f : \u03b1 \u2192 \u03b2) (f' : \u03b3 \u2192 \u03b4) (g : \u03b2 \u2192 \u03b5) (g' : \u03b4 \u2192 \u03b6) (x : \u03b1 \u00d7 \u03b3) :\n    Prod.map g g' (Prod.map f f' x) = Prod.map (g \u2218 f) (g' \u2218 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\u2081 a\u2082 : \u03b1} {b\u2081 b\u2082 : \u03b2} : (a\u2081, b\u2081) = (a\u2082, b\u2082) \u2194 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082 :=\n  Iff.of_eq (mk.injEq _ _ _ _)\n#align prod.mk.inj_iff Prod.mk.inj_iff\n\ntheorem mk.inj_left {\u03b1 \u03b2 : Type _} (a : \u03b1) : Function.Injective (Prod.mk a : \u03b2 \u2192 \u03b1 \u00d7 \u03b2) := by\n  intro b\u2081 b\u2082 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\u2081) = (a, b\u2082) \u2194 b\u2081 = b\u2082 := (mk.inj_left _).eq_iff\nlemma mk_inj_right : (a\u2081, b) = (a\u2082, b) \u2194 a\u2081 = a\u2082 := (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 : \u03b1 \u00d7 \u03b2} : p = q \u2194 p.1 = q.1 \u2227 p.2 = q.2 := by\n  rw [\u2190 @mk.eta _ _ p, \u2190 @mk.eta _ _ q, mk.inj_iff]\n#align prod.ext_iff Prod.ext_iff\n\n@[ext]\ntheorem ext {\u03b1 \u03b2} {p q : \u03b1 \u00d7 \u03b2} (h\u2081 : p.1 = q.1) (h\u2082 : p.2 = q.2) : p = q :=\n  ext_iff.2 \u27e8h\u2081, h\u2082\u27e9\n#align prod.ext Prod.ext\n\ntheorem map_def {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4} : Prod.map f g = fun p : \u03b1 \u00d7 \u03b2 \u21a6 (f p.1, g p.2) :=\n  funext fun p \u21a6 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 : \u03b1 \u00d7 \u03b2 \u21a6 (p.1, p.2)) = id :=\n  rfl\n#align prod.id_prod Prod.id_prod\n\ntheorem map_id : Prod.map (@id \u03b1) (@id \u03b2) = id :=\n  id_prod\n#align prod.map_id Prod.map_id\n\ntheorem fst_surjective [h : Nonempty \u03b2] : Function.Surjective (@fst \u03b1 \u03b2) :=\n  fun x \u21a6 h.elim fun y \u21a6 \u27e8\u27e8x, y\u27e9, rfl\u27e9\n#align prod.fst_surjective Prod.fst_surjective\n\ntheorem snd_surjective [h : Nonempty \u03b1] : Function.Surjective (@snd \u03b1 \u03b2) :=\n  fun y \u21a6 h.elim fun x \u21a6 \u27e8\u27e8x, y\u27e9, rfl\u27e9\n#align prod.snd_surjective Prod.snd_surjective\n\ntheorem fst_injective [Subsingleton \u03b2] : Function.Injective (@fst \u03b1 \u03b2) :=\n  fun _ _ h \u21a6 ext h (Subsingleton.elim _ _)\n#align prod.fst_injective Prod.fst_injective\n\ntheorem snd_injective [Subsingleton \u03b1] : Function.Injective (@snd \u03b1 \u03b2) :=\n  fun _ _ h \u21a6 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 : \u03b1 \u00d7 \u03b2 \u2192 \u03b2 \u00d7 \u03b1 := fun p \u21a6 (p.2, p.1)\n#align prod.swap Prod.swap\n\n@[simp]\ntheorem swap_swap : \u2200 x : \u03b1 \u00d7 \u03b2, swap (swap x) = x\n  | \u27e8_, _\u27e9 => rfl\n#align prod.swap_swap Prod.swap_swap\n\n@[simp]\ntheorem fst_swap {p : \u03b1 \u00d7 \u03b2} : (swap p).1 = p.2 :=\n  rfl\n#align prod.fst_swap Prod.fst_swap\n\n@[simp]\ntheorem snd_swap {p : \u03b1 \u00d7 \u03b2} : (swap p).2 = p.1 :=\n  rfl\n#align prod.snd_swap Prod.snd_swap\n\n@[simp]\ntheorem swap_prod_mk {a : \u03b1} {b : \u03b2} : 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 \u2218 swap = @id (\u03b1 \u00d7 \u03b2) :=\n  funext swap_swap\n#align prod.swap_swap_eq Prod.swap_swap_eq\n\n@[simp]\ntheorem swap_leftInverse : Function.LeftInverse (@swap \u03b1 \u03b2) swap :=\n  swap_swap\n#align prod.swap_left_inverse Prod.swap_leftInverse\n\n@[simp]\ntheorem swap_rightInverse : Function.RightInverse (@swap \u03b1 \u03b2) swap :=\n  swap_swap\n#align prod.swap_right_inverse Prod.swap_rightInverse\n\ntheorem swap_injective : Function.Injective (@swap \u03b1 \u03b2) :=\n  swap_leftInverse.injective\n#align prod.swap_injective Prod.swap_injective\n\ntheorem swap_surjective : Function.Surjective (@swap \u03b1 \u03b2) :=\n  swap_leftInverse.surjective\n#align prod.swap_surjective Prod.swap_surjective\n\ntheorem swap_bijective : Function.Bijective (@swap \u03b1 \u03b2) :=\n  \u27e8swap_injective, swap_surjective\u27e9\n#align prod.swap_bijective Prod.swap_bijective\n\n@[simp]\ntheorem swap_inj {p q : \u03b1 \u00d7 \u03b2} : swap p = swap q \u2194 p = q :=\n  swap_injective.eq_iff\n#align prod.swap_inj Prod.swap_inj\n\ntheorem eq_iff_fst_eq_snd_eq : \u2200 {p q : \u03b1 \u00d7 \u03b2}, p = q \u2194 p.1 = q.1 \u2227 p.2 = q.2\n  | \u27e8p\u2081, p\u2082\u27e9, \u27e8q\u2081, q\u2082\u27e9 => by simp\n#align prod.eq_iff_fst_eq_snd_eq Prod.eq_iff_fst_eq_snd_eq\n\ntheorem fst_eq_iff : \u2200 {p : \u03b1 \u00d7 \u03b2} {x : \u03b1}, p.1 = x \u2194 p = (x, p.2)\n  | \u27e8a, b\u27e9, x => by simp\n#align prod.fst_eq_iff Prod.fst_eq_iff\n\ntheorem snd_eq_iff : \u2200 {p : \u03b1 \u00d7 \u03b2} {x : \u03b2}, p.2 = x \u2194 p = (p.1, x)\n  | \u27e8a, b\u27e9, x => by simp\n#align prod.snd_eq_iff Prod.snd_eq_iff\n\nvariable {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {x y : \u03b1 \u00d7 \u03b2}\n\ntheorem lex_def (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) {p q : \u03b1 \u00d7 \u03b2} :\n    Prod.Lex r s p q \u2194 r p.1 q.1 \u2228 p.1 = q.1 \u2227 s p.2 q.2 :=\n  \u27e8fun h \u21a6 by cases h <;> simp [*], fun h \u21a6\n    match p, q, h with\n    | (a, b), (c, d), Or.inl h => Lex.left _ _ h\n    | (a, b), (c, d), Or.inr \u27e8e, h\u27e9 => by subst e; exact Lex.right _ h\u27e9\n#align prod.lex_def Prod.lex_def\n\nlemma lex_iff : Prod.Lex r s x y \u2194 r x.1 y.1 \u2228 x.1 = y.1 \u2227 s x.2 y.2 := lex_def _ _\n#align prod.lex_iff Prod.lex_iff\n\ninstance Lex.decidable [DecidableEq \u03b1]\n    (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) [DecidableRel r] [DecidableRel s] :\n    DecidableRel (Prod.Lex r s) :=\n  fun _ _ \u21a6 decidable_of_decidable_of_iff (lex_def r s).symm\n\n@[refl]\ntheorem Lex.refl_left (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) [IsRefl \u03b1 r] : \u2200 x, Prod.Lex r s x x\n  | (_, _) => Lex.left _ _ (refl _)\n#align prod.lex.refl_left Prod.Lex.refl_left\n\ninstance {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} [IsRefl \u03b1 r] : IsRefl (\u03b1 \u00d7 \u03b2) (Prod.Lex r s) :=\n  \u27e8Lex.refl_left _ _\u27e9\n\n@[refl]\ntheorem Lex.refl_right (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) [IsRefl \u03b2 s] : \u2200 x, Prod.Lex r s x x\n  | (_, _) => Lex.right _ (refl _)\n#align prod.lex.refl_right Prod.Lex.refl_right\n\ninstance {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} [IsRefl \u03b2 s] : IsRefl (\u03b1 \u00d7 \u03b2) (Prod.Lex r s) :=\n  \u27e8Lex.refl_right _ _\u27e9\n\ninstance isIrrefl [IsIrrefl \u03b1 r] [IsIrrefl \u03b2 s] : IsIrrefl (\u03b1 \u00d7 \u03b2) (Prod.Lex r s) :=\n\u27e8by rintro \u27e8i, a\u27e9 (\u27e8_, _, h\u27e9 | \u27e8_, h\u27e9) <;> exact irrefl _ h\u27e9\n\n@[trans]\ntheorem Lex.trans {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} [IsTrans \u03b1 r] [IsTrans \u03b2 s] :\n    \u2200 {x y z : \u03b1 \u00d7 \u03b2}, Prod.Lex r s x y \u2192 Prod.Lex r s y z \u2192 Prod.Lex r s x z\n  | (_, _), (_, _), (_, _), left  _ _ hxy\u2081, left  _ _ hyz\u2081 => left  _ _ (_root_.trans hxy\u2081 hyz\u2081)\n  | (_, _), (_, _), (_, _), left  _ _ hxy\u2081, right _ _      => left  _ _ hxy\u2081\n  | (_, _), (_, _), (_, _), right _ _,      left  _ _ hyz\u2081 => left  _ _ hyz\u2081\n  | (_, _), (_, _), (_, _), right _ hxy\u2082,   right _ hyz\u2082   => right _ (_root_.trans hxy\u2082 hyz\u2082)\n#align prod.lex.trans Prod.Lex.trans\n\ninstance {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} [IsTrans \u03b1 r] [IsTrans \u03b2 s] :\n  IsTrans (\u03b1 \u00d7 \u03b2) (Prod.Lex r s) :=\n  \u27e8fun _ _ _ \u21a6 Lex.trans\u27e9\n\ninstance {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} [IsStrictOrder \u03b1 r] [IsAntisymm \u03b2 s] :\n    IsAntisymm (\u03b1 \u00d7 \u03b2) (Prod.Lex r s) :=\n  \u27e8fun x\u2081 x\u2082 h\u2081\u2082 h\u2082\u2081 \u21a6\n    match x\u2081, x\u2082, h\u2081\u2082, h\u2082\u2081 with\n    | (a, _), (_, _), .left  _ _ hr\u2081, .left  _ _ hr\u2082 => (irrefl a (_root_.trans hr\u2081 hr\u2082)).elim\n    | (_, _), (_, _), .left  _ _ hr\u2081, .right _ _     => (irrefl _ hr\u2081).elim\n    | (_, _), (_, _), .right _ _,     .left  _ _ hr\u2082 => (irrefl _ hr\u2082).elim\n    | (_, _), (_, _), .right _ hs\u2081,   .right _ hs\u2082   => antisymm hs\u2081 hs\u2082 \u25b8 rfl\u27e9\n\ninstance isTotal_left {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} [IsTotal \u03b1 r] :\n    IsTotal (\u03b1 \u00d7 \u03b2) (Prod.Lex r s) :=\n  \u27e8fun \u27e8a\u2081, _\u27e9 \u27e8a\u2082, _\u27e9 \u21a6 (IsTotal.total a\u2081 a\u2082).imp (Lex.left _ _) (Lex.left _ _)\u27e9\n#align prod.is_total_left Prod.isTotal_left\n\ninstance isTotal_right {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} [IsTrichotomous \u03b1 r] [IsTotal \u03b2 s] :\n    IsTotal (\u03b1 \u00d7 \u03b2) (Prod.Lex r s) :=\n  \u27e8fun \u27e8i, a\u27e9 \u27e8j, b\u27e9 \u21a6 by\n    obtain hij | rfl | hji := trichotomous_of r i j\n    \u00b7 exact Or.inl (.left _ _ hij)\n    \u00b7 exact (total_of s a b).imp (.right _) (.right _)\n    \u00b7 exact Or.inr (.left _ _ hji) \u27e9\n#align prod.is_total_right Prod.isTotal_right\n\ninstance IsTrichotomous [IsTrichotomous \u03b1 r] [IsTrichotomous \u03b2 s] :\n  IsTrichotomous (\u03b1 \u00d7 \u03b2) (Prod.Lex r s) :=\n\u27e8fun \u27e8i, a\u27e9 \u27e8j, b\u27e9 \u21a6 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) }\u27e9\n\nend Prod\n\nopen Prod\n\nnamespace Function\n\nvariable {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4} {f\u2081 : \u03b1 \u2192 \u03b2} {g\u2081 : \u03b3 \u2192 \u03b4} {f\u2082 : \u03b2 \u2192 \u03b1} {g\u2082 : \u03b4 \u2192 \u03b3}\n\ntheorem Injective.Prod_map (hf : Injective f) (hg : Injective g) : Injective (map f g) :=\n  fun _ _ h \u21a6 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 \u21a6\n  let \u27e8x, hx\u27e9 := hf p.1\n  let \u27e8y, hy\u27e9 := hg p.2\n  \u27e8(x, y), Prod.ext hx hy\u27e9\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  \u27e8hf.1.Prod_map hg.1, hf.2.Prod_map hg.2\u27e9\n#align function.bijective.prod_map Function.Bijective.Prod_map\n\ntheorem LeftInverse.Prod_map (hf : LeftInverse f\u2081 f\u2082) (hg : LeftInverse g\u2081 g\u2082) :\n    LeftInverse (map f\u2081 g\u2081) (map f\u2082 g\u2082) :=\n  fun a \u21a6 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\u2081 f\u2082 \u2192 RightInverse g\u2081 g\u2082 \u2192 RightInverse (map f\u2081 g\u2081) (map f\u2082 g\u2082) :=\n  LeftInverse.Prod_map\n#align function.right_inverse.prod_map Function.RightInverse.Prod_map\n\ntheorem Involutive.Prod_map {f : \u03b1 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b2} :\n    Involutive f \u2192 Involutive g \u2192 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 \u03b1] [Nonempty \u03b2] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4} :\n    Injective (map f g) \u2194 Injective f \u2227 Injective g :=\n  \u27e8fun h =>\n    \u27e8fun a\u2081 a\u2082 ha => by\n      inhabit \u03b2\n      injection\n        @h (a\u2081, default) (a\u2082, default) (congr_arg (fun c : \u03b3 => Prod.mk c (g default)) ha : _),\n      fun b\u2081 b\u2082 hb => by\n      inhabit \u03b1\n      injection @h (default, b\u2081) (default, b\u2082) (congr_arg (Prod.mk (f default)) hb : _)\u27e9,\n    fun h => h.1.Prod_map h.2\u27e9\n#align prod.map_injective Prod.map_injective\n\n@[simp]\ntheorem map_surjective [Nonempty \u03b3] [Nonempty \u03b4] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4} :\n    Surjective (map f g) \u2194 Surjective f \u2227 Surjective g :=\n  \u27e8fun h =>\n    \u27e8fun c => by\n      inhabit \u03b4\n      obtain \u27e8\u27e8a, b\u27e9, h\u27e9 := h (c, default)\n      exact \u27e8a, congr_arg Prod.fst h\u27e9,\n      fun d => by\n      inhabit \u03b3\n      obtain \u27e8\u27e8a, b\u27e9, h\u27e9 := h (default, d)\n      exact \u27e8b, congr_arg Prod.snd h\u27e9\u27e9,\n    fun h => h.1.Prod_map h.2\u27e9\n#align prod.map_surjective Prod.map_surjective\n\n@[simp]\ntheorem map_bijective [Nonempty \u03b1] [Nonempty \u03b2] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4} :\n    Bijective (map f g) \u2194 Bijective f \u2227 Bijective g := by\n  haveI := Nonempty.map f \u2039_\u203a\n  haveI := Nonempty.map g \u2039_\u203a\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 \u03b2] [Nonempty \u03b4] {f\u2081 : \u03b1 \u2192 \u03b2} {g\u2081 : \u03b3 \u2192 \u03b4} {f\u2082 : \u03b2 \u2192 \u03b1}\n    {g\u2082 : \u03b4 \u2192 \u03b3} : LeftInverse (map f\u2081 g\u2081) (map f\u2082 g\u2082) \u2194 LeftInverse f\u2081 f\u2082 \u2227 LeftInverse g\u2081 g\u2082 :=\n  \u27e8fun h =>\n    \u27e8fun b => by\n      inhabit \u03b4\n      exact congr_arg Prod.fst (h (b, default)),\n      fun d => by\n      inhabit \u03b2\n      exact congr_arg Prod.snd (h (default, d))\u27e9,\n    fun h => h.1.Prod_map h.2 \u27e9\n#align prod.map_left_inverse Prod.map_leftInverse\n\n@[simp]\ntheorem map_rightInverse [Nonempty \u03b1] [Nonempty \u03b3] {f\u2081 : \u03b1 \u2192 \u03b2} {g\u2081 : \u03b3 \u2192 \u03b4} {f\u2082 : \u03b2 \u2192 \u03b1}\n    {g\u2082 : \u03b4 \u2192 \u03b3} : RightInverse (map f\u2081 g\u2081) (map f\u2082 g\u2082) \u2194 RightInverse f\u2081 f\u2082 \u2227 RightInverse g\u2081 g\u2082 :=\n  map_leftInverse\n#align prod.map_right_inverse Prod.map_rightInverse\n\n@[simp]\ntheorem map_involutive [Nonempty \u03b1] [Nonempty \u03b2] {f : \u03b1 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b2} :\n    Involutive (map f g) \u2194 Involutive f \u2227 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 (\u2124/dp^n \u2124)\u02e3\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 : \u2115} [fact (nat.prime p)] {d : \u2115} [fact (0 < d)] {R : Type*} [normed_comm_ring R] (m : \u2115)\n(hd : d.gcd p = 1) (\u03c7 : dirichlet_character R (d*(p^m))) {c : \u2115} (hc : c.gcd p = 1)\n(hc' : c.gcd d = 1) (na : \u2200 (n : \u2115) (f : \u2115 \u2192 R),\n  \u2225 \u2211 (i : \u2115) in finset.range n, f i\u2225 \u2264 \u2a06 (i : zmod n), \u2225f i.val\u2225)\n(w : continuous_monoid_hom (units (zmod d) \u00d7 units \u2124_[p]) R)\nvariables (p d R) [complete_space R] [char_zero R]\nopen continuous_map\n\nvariables [normed_algebra \u211a_[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 \u211a R] [norm_one_class R] (n : \u2115) (k : \u2115) :=\n  \u2211 (x : (zmod (d * p ^ k))\u02e3),\n  ((asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R^n)) x : R) *\n  ((((x : zmod (d * p^k))).val)^(n - 1) : R)) \u2022\n  (algebra_map \u211a R) (int.fract (\u2191x / (\u2191d * \u2191p ^ k)))\n-- Idea 1 : replacing k by m + k so we can remove (hk : m \u2264 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 {\u03b1 : Type*} (s : finset \u03b1) (t : set \u03b1) :\n  set.finite ((s : set \u03b1) \u2229 t : set \u03b1) := set.finite.inter_of_left (finset.finite_to_set s) t\n\nlemma sum_units_eq {x : \u2115} (hx : 0 < x) (f : \u2115 \u2192 R) :\n  \u2211 (i : units (zmod (d * p^x))), f (i : zmod (d * p^x)).val =\n  \u2211 i in set.finite.to_finset (set.finite_of_finite_inter (finset.range (d * p^x))\n  ({x | x.coprime d} \u2229 {x | x.coprime p})), f i :=\nbegin\n  apply finset.sum_bij,\n  swap 5, { refine \u03bb 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 \u27e8zmod.val_lt _, _\u27e9,\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\u2081 a\u2082 ha\u2081 ha\u2082 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 \u27e8zmod.units_equiv_coprime.inv_fun \u27e8b, (zmod.val_cast_of_lt hb.1).symm \u25b8\n      (nat.coprime.mul_right hb.2.1 (nat.coprime.pow_right _ hb.2.2)) \u27e9, finset.mem_univ _, _\u27e9,\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 \u211a R] [norm_one_class R] {n : \u2115} (hn : 1 < n) (x : \u2115) :\n  \u2211 (x_1 : \u2115) in finset.range (d * p ^ x), (1 / \u2191(d * p ^ x : \u2115) : \u211a) \u2022\n  ((asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) (\u2191p * \u2191x_1) *\n  (\u2191p ^ (n - 1) * \u2191x_1 ^ n)) = \u2211 y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x.succ)) ({x | \u00ac x.coprime p})), ((asso_dirichlet_character\n  (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) \u2191y * \u2191y ^ (n - 1)) \u2022\n  (algebra_map \u211a R) (\u2191y / (\u2191d * \u2191p ^ x.succ)) :=\nbegin\n  symmetry,\n  apply finset.sum_bij,\n  swap 5, { refine \u03bb 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 \u2190 pow_succ', rw mul_comm,\n    rw \u2190 classical.some_spec (nat.prime_dvd_of_not_coprime p ha.2), apply ha.1, },\n  { intros a ha,\n    have h1 : \u2200 x : \u2115, ((d * p^x : \u2115) : \u211a) \u2260 0 := \u03bb 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 [\u2190 nat.cast_pow, \u2190 nat.cast_mul],\n    rw \u2190 classical.some_spec (nat.prime_dvd_of_not_coprime p ha.2),\n    rw \u2190 mul_smul_comm, rw smul_eq_mul, rw mul_assoc, congr,\n    rw \u2190 algebra_map_smul R, rw smul_eq_mul,\n    conv_rhs { congr, skip, congr, congr, skip, rw \u2190 nat.succ_pred_eq_of_pos\n      (lt_trans zero_lt_one hn), rw pow_succ', },\n    rw \u2190 mul_assoc (p ^ (n - 1)) _ _, rw nat.pred_eq_sub_one, rw \u2190 mul_pow,\n    rw \u2190 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 \u211a R) (1 / \u2191(d * p ^ x))) _,\n    rw mul_assoc, congr, rw \u2190 map_nat_cast (algebra_map \u211a R), rw \u2190 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 \u2190 mul_assoc d _ _, rw mul_assoc (d * p^x) _ _,\n    rw \u2190 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 \u2190 classical.some_spec (nat.prime_dvd_of_not_coprime p ha.2) at h2,\n    rw \u2190 classical.some_spec (nat.prime_dvd_of_not_coprime p hb.2) at h2, rw h2, },\n  { intros b hb, refine \u27e8p * b, _, _\u27e9,\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 \u2190 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 \u27e8p, fact.out _, dvd_mul_right p b, dvd_rfl\u27e9, }, },\n    { apply nat.eq_of_mul_eq_mul_left (nat.prime.pos (fact.out _)) _,\n      { exact p, },\n      { apply_instance, },\n      { rw \u2190 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 \u211a R] [norm_one_class R] (n : \u2115) (hn : 1 < n)\n  (h\u03c7 : \u03c7.is_even) (hp : 2 < p)\n  (na : \u2200 (n : \u2115) (f : \u2115 \u2192 R), \u2225 \u2211 (i : \u2115) in finset.range n, f i\u2225 \u2264 \u2a06 (i : zmod n), \u2225f i.val\u2225) :\n  tendsto (\u03bb x : \u2115, \u2211 y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x.succ)) ({x | \u00ac x.coprime p})), ((asso_dirichlet_character\n  (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) \u2191y * \u2191y ^ (n - 1)) \u2022\n  (algebra_map \u211a R) (\u2191y / (\u2191d * \u2191p ^ x.succ)) ) at_top (nhds ((asso_dirichlet_character\n  (dirichlet_character.mul \u03c7 (teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1)) *\n  (general_bernoulli_number (dirichlet_character.mul \u03c7\n  (teichmuller_character_mod_p' p R^n)) n))) :=\nbegin\n  conv { congr, funext, rw \u2190 helper_U_3' p d R m \u03c7 hn, },\n  apply (tendsto_congr _).1 (tendsto.const_mul ((asso_dirichlet_character\n    (dirichlet_character.mul \u03c7 (teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1)))\n    (lim_even_character' p d R m \u03c7 hn h\u03c7 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 \u211a R] [norm_one_class R] (n : \u2115) (hn : 1 < n)\n  (h\u03c7 : \u03c7.is_even) (hp : 2 < p)\n  (na : \u2200 (n : \u2115) (f : \u2115 \u2192 R), \u2225 \u2211 (i : \u2115) in finset.range n, f i\u2225 \u2264 \u2a06 (i : zmod n), \u2225f i.val\u2225) :\n  tendsto (\u03bb x : \u2115, \u2211 y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | \u00ac x.coprime p})), ((asso_dirichlet_character\n  (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) \u2191y * \u2191y ^ (n - 1)) \u2022\n  (algebra_map \u211a R) (\u2191y / (\u2191d * \u2191p ^ x)) ) at_top (nhds ((asso_dirichlet_character\n  (dirichlet_character.mul \u03c7 (teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1) ) *\n  (general_bernoulli_number (dirichlet_character.mul \u03c7\n  (teichmuller_character_mod_p' p R^n)) n))) :=\nbegin\n  have h1 := helper_U_2' p d R m \u03c7 n hn h\u03c7 hp na,\n  have h2 : tendsto nat.pred at_top at_top,\n  { rw tendsto_at_top, intro b, simp, refine \u27e8b.succ, \u03bb c hc, _\u27e9,\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 (\u03bb x : \u2115, \u2211 y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x.succ)) ({x | \u00ac x.coprime p})), ((asso_dirichlet_character\n  (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) \u2191y * \u2191y ^ (n - 1)) \u2022\n  (algebra_map \u211a R) (\u2191y / (\u2191d * \u2191p ^ x.succ)) ) nat.pred =\u1da0[at_top] (\u03bb x : \u2115, \u2211 y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | \u00ac x.coprime p})), ((asso_dirichlet_character\n  (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) \u2191y * \u2191y ^ (n - 1)) \u2022\n  (algebra_map \u211a R) (\u2191y / (\u2191d * \u2191p ^ x)) ),\n  { rw eventually_eq, rw eventually_at_top,\n    refine \u27e81, \u03bb x hx, _\u27e9, 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 \u211a R] [norm_one_class R] (n : \u2115)\n  (hd : d.coprime p) (h\u03c7 : d \u2223 \u03c7.conductor) :\n  tendsto (\u03bb x : \u2115, \u2211 y in set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | \u00ac x.coprime d})), ((asso_dirichlet_character\n  (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) \u2191y * \u2191y ^ (n - 1)) \u2022\n  (algebra_map \u211a R) (\u2191y / (\u2191d * \u2191p ^ 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 \u27e8k, hk\u27e9 := dvd_mul_of_dvd_conductor p d R m \u03c7 n hd h\u03c7,\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 \u211a R] [no_zero_divisors R] (hd : d.coprime p) (h\u03c7 : d \u2223 \u03c7.conductor) (n x : \u2115) : \u2211 (x_1 : \u2115) in (set.finite_of_finite_inter\n  (finset.range (d * p ^ x)) {x : \u2115 | \u00acx.coprime d}).to_finset \u2229 (set.finite_of_finite_inter\n  (finset.range (d * p ^ x)) {x : \u2115 | \u00acx.coprime p}).to_finset,\n  ((asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) \u2191x_1 *\n  \u2191x_1 ^ (n - 1)) \u2022 (algebra_map \u211a R) (\u2191x_1 / (\u2191d * \u2191p ^ 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 \u27e8k, hk\u27e9 := dvd_mul_of_dvd_conductor p d R m \u03c7 n hd h\u03c7,\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 : \u2115) : finset.range (d * p^x) = set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | \u00ac x.coprime d})) \u222a ((set.finite.to_finset (set.finite_of_finite_inter\n  (finset.range (d * p^x)) ({x | \u00ac x.coprime p}))) \u222a set.finite.to_finset (set.finite_of_finite_inter (finset.range (d * p^x))\n  ({x | x.coprime d} \u2229 {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 \u2227 a.coprime p, { right, right, refine \u27e8h, h'\u27e9, },\n    { rw not_and_distrib at h', cases h',\n      { left, refine \u27e8h, h'\u27e9, },\n      { right, left, refine \u27e8h, h'\u27e9, }, }, },\n  { intro h, cases h, apply h.1,\n    cases h, apply h.1, apply h.1, },\nend\n\nopen zmod\nlemma U [algebra \u211a R] [norm_one_class R] [no_zero_divisors R] [is_scalar_tower \u211a \u211a_[p] R]\n  (hd : d.coprime p) (n : \u2115) (hn : 1 < n) (h\u03c7 : \u03c7.is_even) (h\u03c7' : d \u2223 \u03c7.conductor) (hp : 2 < p)\n  (na : \u2200 (n : \u2115) (f : \u2115 \u2192 R), \u2225 \u2211 (i : \u2115) in finset.range n, f i\u2225 \u2264 \u2a06 (i : zmod n), \u2225f i.val\u2225) :\n  filter.tendsto (\u03bb j : \u2115, U_def p d R m \u03c7 n j)\n  filter.at_top (nhds ((1 - asso_dirichlet_character (dirichlet_character.mul \u03c7\n  (teichmuller_character_mod_p' p R^n)) (p) * p^(n - 1) ) *\n  (general_bernoulli_number (dirichlet_character.mul \u03c7\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 \u03c7 hn h\u03c7 hp na) (helper_U_2 p d R m \u03c7 n hd h\u03c7')) (helper_U_1' p d R m \u03c7 n hn h\u03c7 hp na)), -- might need a tendsto_congr' here\n  { rw sub_zero, rw \u2190 one_sub_mul, },\n  { rw eventually_eq, rw eventually_at_top,\n    refine \u27e8m, \u03bb x hx, _\u27e9,\n    --simp only,\n    have h1 : d * p^m \u2223 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 \u2190 zmod.nat_cast_val (x_1 : zmod (d * p^x)),\n      rw \u2190 zmod.nat_cast_val (x_1 : zmod (d * p^x)),\n      rw \u2190 nat.cast_pow p, rw \u2190 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 \u2190 dirichlet_character.mul_eq_mul R \u03c7\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 _ (\u03bb (y : \u2115), ((asso_dirichlet_character\n      (\u03c7.mul (teichmuller_character_mod_p' p R ^ n))) \u2191y * \u2191y ^ (n - 1)) \u2022\n      (algebra_map \u211a R) (((y : \u211a) / (\u2191d * \u2191p ^ x)))),\n    -- ext, congr,\n    rw sub_sub, rw \u2190 finset.sum_union_inter, rw add_comm,\n    apply sub_eq_of_eq_add', rw add_assoc, rw \u2190 finset.sum_union _,\n    rw helper_U_4 p d R m \u03c7 hd h\u03c7', rw zero_add,\n--    apply sub_eq_of_eq_add', rw \u2190 finset.sum_union _,\n    { apply finset.sum_congr,\n      { rw finset.union_assoc, rw \u2190 helper_U_3, },\n      { intros y hy, rw \u2190algebra_map_smul R (1 / \u2191(d * p ^ x : \u2115) : \u211a_[p]),\n        rw smul_eq_mul, rw smul_eq_mul,\n        { rw mul_comm, rw \u2190 mul_one (y : \u211a), rw \u2190 mul_div, rw ring_hom.map_mul, rw map_nat_cast,\n          rw \u2190 mul_assoc, rw [nat.cast_mul d _, nat.cast_pow p], apply congr_arg2 _ _ _,\n          rw mul_assoc, apply congr_arg2 _ rfl _, rw \u2190 pow_succ', rw nat.sub_add_cancel (le_of_lt hn),\n          rw is_scalar_tower.algebra_map_apply \u211a \u211a_[p] R,\n          simp_rw [\u2190 nat.cast_pow, \u2190 nat.cast_mul],\n          apply congr_arg,\n          symmetry,\n          apply eq_one_div_of_mul_eq_one_left,\n          rw \u2190smul_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 \u27e8_, _\u27e9,\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 \u03b1] (I : Ideal \u03b1)\n\n    protected def is_radical : Prop := \u2200 (x : \u03b1) (n : Nat), n \u2260 0 \u2192 x^n \u2208 I \u2192 x \u2208 I\n\n    def radical : Ideal \u03b1 where\n      subset     := {x | \u2203 n : Nat, n \u2260 0 \u2227 x^n \u2208 I}\n      has_zero   := \u27e81, Nat.one_ne_zero, by rw [pow_nat_1]; exact I.has_zero\u27e9\n      add_closed := by\n        intro a b \u27e8m, hm, ham\u27e9 \u27e8n, hn, hbn\u27e9; exact \u27e8m+n-1,\n          \u27e8by\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 \u25b8\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 \u25b8\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 \u27e8b^n, hbn,\n              Finset.map_sum.prop_sum _ _ _ (divides_zero _) (fun k hk =>\n                \u27e8((m + n - 1).choose k) * a ^ k * b ^ (m - 1 - k), by\n                  rw [Semiring.mul_comm, NCSemiring.mul_assoc, \u2190NCSemiring.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), \u2190Nat.zero_add m]\n                      exact (Finset.range'.mem_range'.mp hk).right)]\n                  rw [this]\u27e9) (@divides_add _ _ (b^n))\u27e9)\n              (Ideal.div_mem.mpr \u27e8a^m, ham,\n              Finset.map_sum.prop_sum _ _ _ (divides_zero _) (fun k hk =>\n                \u27e8((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, \u2190NCSemiring.mul_assoc (a^_),\n                    \u2190NCSemiring.pow_nat_add_distrib, \u2190NCSemiring.mul_assoc,\n                    Nat.sub_add_cancel (Nat.zero_add m \u25b8 (Finset.range'.mem_range'.mp hk).left)]\u27e9)\n                  (@divides_add _ _ (a^m))\u27e9)\u27e9\u27e9\n      mul_closed := fun a b \u27e8m, \u27e8hm, hbm\u27e9\u27e9 => \u27e8m, \u27e8hm, by rw [pow_nat_mul_distrib]; exact I.mul_closed (a^m) hbm\u27e9\u27e9\n\n    namespace radical\n      protected theorem is_radical : I.radical.is_radical :=\n        fun x n hn \u27e8m, hm, hx\u27e9 => \u27e8n * m, (Nat.mul_neq_zero _ _).mpr \u27e8hn, hm\u27e9,\n          by rw [\u2190pow_nat_comp]; exact hx\u27e9\n\n      protected theorem sub_self : I \u2286 I.radical := fun x hx =>\n        \u27e81, Nat.one_ne_zero, NCSemiring.pow_nat_1 x \u25b8 hx\u27e9\n\n      theorem subset {I J : Ideal \u03b1} (h : I \u2286 J) : I.radical \u2286 J.radical :=\n        fun x \u27e8n, hn0, hxn\u27e9 => \u27e8n, hn0, h hxn\u27e9\n\n      protected theorem of_unit (\u03b1) [Ring \u03b1] : (1 : Ideal \u03b1).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 => \u27e8fun \u27e8n, hn, m, hm, hxm\u27e9 => \u27e8n * m, (Nat.mul_neq_zero n m).mpr \u27e8hn, hm\u27e9,\n          pow_nat_comp x n m \u25b8 hxm\u27e9, (radical.sub_self _ \u00b7)\u27e9\n\n      protected theorem add (J : Ideal \u03b1) : (I + J).radical = (I.radical + J.radical).radical :=\n        Ideal.ext'.mpr fun x => \u27e8fun \u27e8n, hn, i, hi, j, hj, hij\u27e9 => \u27e8n, hn, i, radical.sub_self I hi, j,\n          radical.sub_self J hj, hij\u27e9, fun \u27e8n, hn, i, hi, j, hj, hij\u27e9 => radical.repeat _ \u25b8 \u27e8n, hn, hij \u25b8\n            (I + J).radical.add_closed (radical.subset (Ideal.add.subset I J) hi) (radical.subset (Ideal.add.subset' I J) hj)\u27e9\u27e9\n\n      protected theorem eq_unit_ideal_iff {I : Ideal \u03b1} : I.radical = 1 \u2194 I = 1 :=\n        \u27e8fun h => let \u27e8n, hn, h1n\u27e9 := is_unit_ideal.mp h; is_unit_ideal.mpr (pow_nat_one n \u25b8 h1n),\n          (\u00b7 \u25b8 radical.of_unit \u03b1)\u27e9\n\n      protected theorem proper_iff {I : Ideal \u03b1} : I.radical.proper_ideal \u2194 I.proper_ideal :=\n        not_iff_not.mpr radical.eq_unit_ideal_iff\n\n      protected theorem add_eq_one {I J : Ideal \u03b1} (h : I.radical + J.radical = 1) : I + J = 1 := by\n        have := congrArg Ideal.radical h\n        rw [\u2190radical.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 \u03b1} (hI : I.is_radical) : I.radical = I :=\n      Ideal.antisymm (fun x hx => let \u27e8n, hn0, hxn\u27e9 := hx; hI x n hn0 hxn) (radical.sub_self I)\n\n    theorem prime_radical {P : Ideal \u03b1} (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 \u25b8 hxn)) (ih hn') id }\n\n    def is_primary : Prop := I.proper_ideal \u2227 \u2200 a b : \u03b1, a * b \u2208 I \u2192 a \u2208 I \u2228 b \u2208 I.radical\n\n    theorem is_primary_of_prime {I : Ideal \u03b1} (hI : I.is_prime) : I.is_primary :=\n      And.imp_right (fun h a b hab => Or.imp_right (Ideal.radical.sub_self I \u00b7) (h a b hab)) hI\n\n    theorem is_primary_of_radical_maximal {I : Ideal \u03b1} (h : I.radical.is_maximal) : I.is_primary :=\n      \u27e8Ideal.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 \u25b8 Ideal.add.subset' _ _ (generator_in_principal b))\n        have : I.radical + (principal b).radical = 1 :=\n          unit_ideal_in (this \u25b8 Ideal.add.subset_add_subset (Subset.refl _) (radical.sub_self _))\n        let \u27e8i, hi, j, \u27e8k, hk\u27e9, hij\u27e9 := is_unit_ideal.mp (radical.add_eq_one this)\n        rw [\u2190mul_one a, \u2190hij, \u2190hk, mul_distrib_left, \u2190mul_assoc]\n        exact I.add_closed (I.mul_closed a hi) (I.mul_closed' hab k)\u27e9\n\n    theorem contraction_radical [Ring \u03b2] (f : \u03b1 \u2192\u1d63\u2081 \u03b2) (I : Ideal \u03b2) : contraction\u1d63\u2081 f I.radical = (contraction\u1d63\u2081 f I).radical :=\n      Ideal.ext'.mpr fun x => \u27e8fun \u27e8n, hn, hnx\u27e9 => \u27e8n, hn, by rw [\u2190f.preserve_pow x n] at hnx; exact hnx\u27e9,\n        fun \u27e8n, hn, hnx\u27e9 => \u27e8n, hn, f.preserve_pow x n \u25b8 hnx\u27e9\u27e9\n\n    theorem contraction_is_primary [Ring \u03b2] (f : \u03b1 \u2192\u1d63\u2081 \u03b2) {I : Ideal \u03b2} (hI : I.is_primary) : (contraction\u1d63\u2081 f I).is_primary :=\n      \u27e8contraction.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 \u25b8 hab)).imp_right (fun h => contraction_radical f I \u25b8 h)\u27e9\n\n    theorem radical_prime_of_primary {I : Ideal \u03b1} (hI : I.is_primary) : I.radical.is_prime :=\n      \u27e8radical.proper_iff.mpr hI.left, fun a b \u27e8n, hn, habn\u27e9 => 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          \u25b8 habn)).resolve_left (fun ha' => ha (radical.is_radical I a n hn (radical.sub_self I ha'))))\u27e9\n\n    theorem radical_minimal_prime_of_primary {I : Ideal \u03b1} (hI : I.is_primary) : I.radical.minimal_prime_ideal_of I :=\n      \u27e8radical_prime_of_primary hI, radical.sub_self I, fun hJ hIJ hJI => Ideal.antisymm hJI (is_radical.eq_rad (prime_radical hJ) \u25b8 radical.subset hIJ)\u27e9\n\n    theorem radical_pow_of_prime {P : Ideal \u03b1} (hP : P.is_prime) (n : Nat) (hn : n \u2260 0) : (P ^ n).radical = P :=\n      Ideal.antisymm (fun x \u27e8k, hk, hkx\u27e9 => prime_radical hP x k hk (product.pow_subset P n hn hkx)) (fun x hx => \u27e8n, hn, product.pow_contains n hx\u27e9)\n\n\n  end Ideal\n\n  namespace Ring\n    open QuotientRing\n    variable (\u03b1 : Type _) [Ring \u03b1]\n\n    def nil_radical : Ideal \u03b1 := (0 : Ideal \u03b1).radical\n\n    protected theorem nil_radical.def : (0 : Ideal \u03b1).radical = nil_radical \u03b1 := rfl\n\n    def is_reduced : Prop := nil_radical \u03b1 = 0\n\n    abbrev reduced := QClass (nil_radical \u03b1)\n\n    theorem reduced_reduced : is_reduced (reduced \u03b1) :=\n      Ideal.is_zero_ideal.mpr fun a \u27e8n, hn0, han\u27e9 =>\n        @Quotient.ind \u03b1 (QSetoid _) (fun (x : QClass _) => x^n = 0 \u2192 x = 0) (fun x (hxn : toQuotient _ _ ^ n = 0) =>\n          let \u27e8m, hm0, hxnm\u27e9 : x^n \u2208 nil_radical \u03b1 := is_zero.mp (preserve_pow_nat _ x n \u25b8 hxn)\n          is_zero.mpr \u27e8n * m, (Nat.mul_neq_zero n m).mpr \u27e8hn0, hm0\u27e9, pow_nat_comp x n m \u25b8 hxnm\u27e9) a han\n\n    noncomputable def jacobson_radical : Ideal \u03b1 := \u22c2\u2080 Ring.MaxSpec \u03b1\n\n    variable {\u03b1}\n\n    theorem nil_radical_proper (h : Ring.is_NonTrivial \u03b1) : (nil_radical \u03b1).proper_ideal :=\n      fun h' => let \u27e8n, hn, h1n\u27e9 := Ideal.is_unit_ideal.mp h'; absurd (pow_nat_one n \u25b8 h1n) h\n\n    theorem maximal_subset_jacobson {M : Ideal \u03b1} (hM : M.is_maximal) : jacobson_radical \u03b1 \u2286 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u03b1` is the type of open subsets of a topological space `\u03b1`.\n- `open_nhds_of x` is the type of open subsets of a topological space `\u03b1` containing `x : \u03b1`.\n-\n-/\n\nnamespace topological_space\n\n\n/-- The type of open subsets of a topological space. -/\ndef opens (\u03b1 : Type u_1) [topological_space \u03b1] :=\n  Subtype fun (s : set \u03b1) => is_open s\n\nnamespace opens\n\n\nprotected instance set.has_coe {\u03b1 : Type u_1} [topological_space \u03b1] : has_coe (opens \u03b1) (set \u03b1) :=\n  has_coe.mk subtype.val\n\ntheorem val_eq_coe {\u03b1 : Type u_1} [topological_space \u03b1] (U : opens \u03b1) : subtype.val U = \u2191U :=\n  rfl\n\n/-- the coercion `opens \u03b1 \u2192 set \u03b1` applied to a pair is the same as taking the first component -/\ntheorem coe_mk {\u03b1 : Type u_1} [topological_space \u03b1] {U : set \u03b1} {hU : is_open U} : \u2191{ val := U, property := hU } = U :=\n  rfl\n\nprotected instance has_subset {\u03b1 : Type u_1} [topological_space \u03b1] : has_subset (opens \u03b1) :=\n  has_subset.mk fun (U V : opens \u03b1) => \u2191U \u2286 \u2191V\n\nprotected instance has_mem {\u03b1 : Type u_1} [topological_space \u03b1] : has_mem \u03b1 (opens \u03b1) :=\n  has_mem.mk fun (a : \u03b1) (U : opens \u03b1) => a \u2208 \u2191U\n\n@[simp] theorem subset_coe {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} : \u2191U \u2286 \u2191V = (U \u2286 V) :=\n  rfl\n\n@[simp] theorem mem_coe {\u03b1 : Type u_1} [topological_space \u03b1] {x : \u03b1} {U : opens \u03b1} : x \u2208 \u2191U = (x \u2208 U) :=\n  rfl\n\ntheorem ext {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} (h : \u2191U = \u2191V) : U = V :=\n  iff.mpr subtype.ext_iff h\n\ntheorem ext_iff {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} : \u2191U = \u2191V \u2194 U = V :=\n  { mp := ext, mpr := congr_arg coe }\n\nprotected instance partial_order {\u03b1 : Type u_1} [topological_space \u03b1] : partial_order (opens \u03b1) :=\n  subtype.partial_order fun (s : set \u03b1) => is_open s\n\n/-- The interior of a set, as an element of `opens`. -/\ndef interior {\u03b1 : Type u_1} [topological_space \u03b1] (s : set \u03b1) : opens \u03b1 :=\n  { val := interior s, property := is_open_interior }\n\ntheorem gc {\u03b1 : Type u_1} [topological_space \u03b1] : galois_connection coe interior :=\n  fun (U : opens \u03b1) (s : set \u03b1) =>\n    { mp := fun (h : \u2191U \u2264 s) => interior_maximal h (subtype.property U),\n      mpr := fun (h : U \u2264 interior s) => le_trans h interior_subset }\n\n/-- The galois insertion between sets and opens, but ordered by reverse inclusion. -/\ndef gi {\u03b1 : Type u_1} [topological_space \u03b1] : galois_insertion interior subtype.val :=\n  galois_insertion.mk\n    (fun (s : order_dual (set \u03b1)) (hs : subtype.val (interior s) \u2264 s) => { val := s, property := sorry }) sorry sorry\n    sorry\n\n@[simp] theorem gi_choice_val {\u03b1 : Type u_1} [topological_space \u03b1] {s : order_dual (set \u03b1)} {hs : subtype.val (interior s) \u2264 s} : subtype.val (galois_insertion.choice gi s hs) = s :=\n  rfl\n\nprotected instance complete_lattice {\u03b1 : Type u_1} [topological_space \u03b1] : complete_lattice (opens \u03b1) :=\n  complete_lattice.copy (order_dual.complete_lattice (order_dual (opens \u03b1))) (fun (U V : opens \u03b1) => U \u2286 V) sorry\n    { val := set.univ, property := is_open_univ } sorry { val := \u2205, property := is_open_empty } sorry\n    (fun (U V : opens \u03b1) => { val := \u2191U \u222a \u2191V, property := sorry }) sorry\n    (fun (U V : opens \u03b1) => { val := \u2191U \u2229 \u2191V, property := sorry }) sorry\n    (fun (Us : set (opens \u03b1)) => { val := \u22c3\u2080(coe '' Us), property := sorry }) sorry complete_lattice.Inf sorry\n\n/- le  -/ (\u03bb U V, U \u2286 V) rfl\n/- top -/ \u27e8set.univ, is_open_univ\u27e9 (subtype.ext_iff_val.mpr interior_univ.symm)\n/- bot -/ \u27e8\u2205, is_open_empty\u27e9 rfl\n/- sup -/ (\u03bb U V, \u27e8\u2191U \u222a \u2191V, is_open_union U.2 V.2\u27e9) rfl\n/- inf -/ (\u03bb U V, \u27e8\u2191U \u2229 \u2191V, is_open_inter U.2 V.2\u27e9)\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 -/ (\u03bb Us, \u27e8\u22c3\u2080 (coe '' Us), is_open_sUnion $ \u03bb U hU,\nby { rcases hU with \u27e8\u27e8V, hV\u27e9, h, h'\u27e9, dsimp at h', subst h', exact hV}\u27e9)\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 \u03b1} : U \u2264 V \u2194 (U : set \u03b1) \u2264 (V : set \u03b1) :=\nby refl\ntheorem le_def {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} : U \u2264 V \u2194 \u2191U \u2264 \u2191V :=\n  iff.refl (U \u2264 V)\n\n\n@[simp] lemma mk_inf_mk {U V : set \u03b1} {hU : is_open U} {hV : is_open V} :\n  (\u27e8U, hU\u27e9 \u2293 \u27e8V, hV\u27e9 : opens \u03b1) = \u27e8U \u2293 V, is_open_inter hU hV\u27e9 := rfl\n@[simp] theorem mk_inf_mk {\u03b1 : Type u_1} [topological_space \u03b1] {U : set \u03b1} {V : set \u03b1} {hU : is_open U} {hV : is_open V} : { val := U, property := hU } \u2293 { val := V, property := hV } = { val := U \u2293 V, property := is_open_inter hU hV } :=\n  rfl\n\n@[simp,norm_cast] lemma coe_inf {U V : opens \u03b1} :\n  ((U \u2293 V : opens \u03b1) : set \u03b1) = (U : set \u03b1) \u2293 (V : set \u03b1) := rfl\n@[simp] theorem coe_inf {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} : \u2191(U \u2293 V) = \u2191U \u2293 \u2191V :=\n  rfl\n\n\ninstance : has_inter (opens \u03b1) := \u27e8\u03bb U V, U \u2293 V\u27e9\ninstance : has_union (opens \u03b1) := \u27e8\u03bb U V, U \u2294 V\u27e9\nprotected instance has_inter {\u03b1 : Type u_1} [topological_space \u03b1] : has_inter (opens \u03b1) :=\n  has_inter.mk fun (U V : opens \u03b1) => U \u2293 V\n\ninstance : has_emptyc (opens \u03b1) := \u27e8\u22a5\u27e9\nprotected instance has_union {\u03b1 : Type u_1} [topological_space \u03b1] : has_union (opens \u03b1) :=\n  has_union.mk fun (U V : opens \u03b1) => U \u2294 V\n\ninstance : inhabited (opens \u03b1) := \u27e8\u2205\u27e9\nprotected instance has_emptyc {\u03b1 : Type u_1} [topological_space \u03b1] : has_emptyc (opens \u03b1) :=\n  has_emptyc.mk \u22a5\n\n\nprotected instance inhabited {\u03b1 : Type u_1} [topological_space \u03b1] : Inhabited (opens \u03b1) :=\n  { default := \u2205 }\n\n@[simp] lemma inter_eq (U V : opens \u03b1) : U \u2229 V = U \u2293 V := rfl\n@[simp] lemma union_eq (U V : opens \u03b1) : U \u222a V = U \u2294 V := rfl\n@[simp] theorem inter_eq {\u03b1 : Type u_1} [topological_space \u03b1] (U : opens \u03b1) (V : opens \u03b1) : U \u2229 V = U \u2293 V :=\n  rfl\n\n@[simp] lemma empty_eq : (\u2205 : opens \u03b1) = \u22a5 := rfl\n@[simp] theorem union_eq {\u03b1 : Type u_1} [topological_space \u03b1] (U : opens \u03b1) (V : opens \u03b1) : U \u222a V = U \u2294 V :=\n  rfl\n\n\n@[simp] theorem empty_eq {\u03b1 : Type u_1} [topological_space \u03b1] : \u2205 = \u22a5 :=\n  rfl\n\n@[simp] lemma Sup_s {Us : set (opens \u03b1)} : \u2191(Sup Us) = \u22c3\u2080 ((coe : _ \u2192 set \u03b1) '' Us) :=\nbegin\n@[simp] theorem Sup_s {\u03b1 : Type u_1} [topological_space \u03b1] {Us : set (opens \u03b1)} : \u2191(Sup Us) = \u22c3\u2080(coe '' Us) := sorry\n\n  rw [@galois_connection.l_Sup (opens \u03b1) (set \u03b1) _ _ (coe : opens \u03b1 \u2192 set \u03b1) interior gc Us],\n  rw [set.sUnion_image]\nend\n\nlemma supr_def {\u03b9} (s : \u03b9 \u2192 opens \u03b1) : (\u2a06 i, s i) = \u27e8\u22c3 i, s i, is_open_Union $ \u03bb i, (s i).2\u27e9 :=\nby { ext, simp only [supr, opens.Sup_s, sUnion_image, bUnion_range], refl }\ntheorem supr_def {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Sort u_2} (s : \u03b9 \u2192 opens \u03b1) : (supr fun (i : \u03b9) => s i) =\n  { val := set.Union fun (i : \u03b9) => \u2191(s i), property := is_open_Union fun (i : \u03b9) => subtype.property (s i) } := sorry\n\n\n@[simp] lemma supr_mk {\u03b9} (s : \u03b9 \u2192 set \u03b1) (h : \u03a0 i, is_open (s i)) :\n  (\u2a06 i, \u27e8s i, h i\u27e9 : opens \u03b1) = \u27e8\u2a06 i, s i, is_open_Union h\u27e9 :=\n@[simp] theorem supr_mk {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Sort u_2} (s : \u03b9 \u2192 set \u03b1) (h : \u2200 (i : \u03b9), is_open (s i)) : (supr fun (i : \u03b9) => { val := s i, property := h i }) = { val := supr fun (i : \u03b9) => s i, property := is_open_Union h } := sorry\n\nby { rw supr_def, simp }\n\n@[simp] lemma supr_s {\u03b9} (s : \u03b9 \u2192 opens \u03b1) : ((\u2a06 i, s i : opens \u03b1) : set \u03b1) = \u22c3 i, s i :=\nby simp [supr_def]\n@[simp] theorem supr_s {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Sort u_2} (s : \u03b9 \u2192 opens \u03b1) : \u2191(supr fun (i : \u03b9) => s i) = set.Union fun (i : \u03b9) => \u2191(s i) := sorry\n\n\ntheorem mem_supr {\u03b9} {x : \u03b1} {s : \u03b9 \u2192 opens \u03b1} : x \u2208 supr s \u2194 \u2203 i, x \u2208 s i :=\nby { rw [\u2190mem_coe], simp, }\ntheorem mem_supr {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Sort u_2} {x : \u03b1} {s : \u03b9 \u2192 opens \u03b1} : x \u2208 supr s \u2194 \u2203 (i : \u03b9), x \u2208 s i := sorry\n\n\nlemma open_embedding_of_le {U V : opens \u03b1} (i : U \u2264 V) :\n  open_embedding (set.inclusion i) :=\ntheorem open_embedding_of_le {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} (i : U \u2264 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 \u03b1)) : Prop := is_topological_basis ((coe : _ \u2192 set \u03b1) '' B)\n\ndef is_basis {\u03b1 : Type u_1} [topological_space \u03b1] (B : set (opens \u03b1)) :=\n  is_topological_basis (coe '' B)\n\nlemma is_basis_iff_nbhd {B : set (opens \u03b1)} :\n  is_basis B \u2194 \u2200 {U : opens \u03b1} {x}, x \u2208 U \u2192 \u2203 U' \u2208 B, x \u2208 U' \u2227 U' \u2286 U :=\ntheorem is_basis_iff_nbhd {\u03b1 : Type u_1} [topological_space \u03b1] {B : set (opens \u03b1)} : is_basis B \u2194 \u2200 {U : opens \u03b1} {x : \u03b1}, x \u2208 U \u2192 \u2203 (U' : opens \u03b1), \u2203 (H : U' \u2208 B), x \u2208 U' \u2227 U' \u2286 U := sorry\n\nbegin\n  split; intro h,\n  { rintros \u27e8sU, hU\u27e9 x hx,\n    rcases (mem_nhds_of_is_topological_basis h).mp (mem_nhds_sets hU hx)\n      with \u27e8sV, \u27e8\u27e8V, H\u2081, H\u2082\u27e9, hsV\u27e9\u27e9,\n    refine \u27e8V, H\u2081, _\u27e9,\n    cases V, dsimp at H\u2082, subst H\u2082, exact hsV },\n  { refine is_topological_basis_of_open_of_nhds _ _,\n    { rintros sU \u27e8U, \u27e8H\u2081, H\u2082\u27e9\u27e9, subst H\u2082, exact U.property },\n    { intros x sU hx hsU,\n      rcases @h (\u27e8sU, hsU\u27e9 : opens \u03b1) x hx with \u27e8V, hV, H\u27e9,\n      exact \u27e8V, \u27e8V, hV, rfl\u27e9, H\u27e9 } }\nend\n\nlemma is_basis_iff_cover {B : set (opens \u03b1)} :\n  is_basis B \u2194 \u2200 U : opens \u03b1, \u2203 Us \u2286 B, U = Sup Us :=\ntheorem is_basis_iff_cover {\u03b1 : Type u_1} [topological_space \u03b1] {B : set (opens \u03b1)} : is_basis B \u2194 \u2200 (U : opens \u03b1), \u2203 (Us : set (opens \u03b1)), \u2203 (H : Us \u2286 B), U = Sup Us := sorry\n\nbegin\n  split,\n  { intros hB U,\n    rcases sUnion_basis_of_is_open hB U.prop with \u27e8sUs, H, hU\u27e9,\n    existsi {U : opens \u03b1 | U \u2208 B \u2227 \u2191U \u2208 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 \u27e8V, hV\u27e9,\n        rw \u2190 hV.right at hs,\n        refine \u27e8V, \u27e8\u27e8hV.left, hs\u27e9, hV.right\u27e9\u27e9 },\n      { rcases hs with \u27e8V, \u27e8\u27e8H\u2081, H\u2082\u27e9, H\u2083\u27e9\u27e9,\n        subst H\u2083, exact H\u2082 } } },\n  { intro h,\n    rw is_basis_iff_nbhd,\n    intros U x hx,\n    rcases h U with \u27e8Us, hUs, H\u27e9,\n    replace H := congr_arg (coe : _ \u2192 set \u03b1) H,\n    rw Sup_s at H,\n    change x \u2208 \u2191U at hx,\n    rw H at hx,\n    rcases set.mem_sUnion.mp hx with \u27e8sV, \u27e8\u27e8V, H\u2081, H\u2082\u27e9, hsV\u27e9\u27e9,\n    refine \u27e8V,hUs H\u2081,_\u27e9,\n    cases V with V hV,\n    dsimp at H\u2082, subst H\u2082,\n    refine \u27e8hsV,_\u27e9,\n    change V \u2286 U, rw H,\n    exact set.subset_sUnion_of_mem \u27e8\u27e8V, _\u27e9, \u27e8H\u2081, rfl\u27e9\u27e9 }\nend\n\n/-- The preimage of an open set, as an open set. -/\n\ndef comap {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (V : opens \u03b2) : opens \u03b1 :=\n\u27e8f \u207b\u00b9' V.1, V.2.preimage hf\u27e9\ndef comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (V : opens \u03b2) : opens \u03b1 :=\n  { val := f \u207b\u00b9' subtype.val V, property := sorry }\n\n\n@[simp] lemma comap_id (U : opens \u03b1) : U.comap continuous_id = U := by { ext, refl }\n\n@[simp] theorem comap_id {\u03b1 : Type u_1} [topological_space \u03b1] (U : opens \u03b1) : comap continuous_id U = U :=\n  ext (set.ext fun (x : \u03b1) => iff.refl (x \u2208 \u2191(comap continuous_id U)))\n\nlemma comap_mono {f : \u03b1 \u2192 \u03b2} (hf : continuous f) {V W : opens \u03b2} (hVW : V \u2286 W) :\n  V.comap hf \u2286 W.comap hf :=\ntheorem comap_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : continuous f) {V : opens \u03b2} {W : opens \u03b2} (hVW : V \u2286 W) : comap hf V \u2286 comap hf W :=\n  fun (_x : \u03b1) (h : _x \u2208 \u2191(comap hf V)) => hVW h\n\n\u03bb _ h, hVW h\n\n@[simp] lemma coe_comap {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (U : opens \u03b2) :\n  \u2191(U.comap hf) = f \u207b\u00b9' U := rfl\n@[simp] theorem coe_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (U : opens \u03b2) : \u2191(comap hf U) = f \u207b\u00b9' \u2191U :=\n  rfl\n\n\n@[simp] lemma comap_val {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (U : opens \u03b2) :\n  (U.comap hf).1 = f \u207b\u00b9' U := rfl\n@[simp] theorem comap_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (U : opens \u03b2) : subtype.val (comap hf U) = f \u207b\u00b9' \u2191U :=\n  rfl\n\n\nprotected lemma comap_comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : continuous g) (hf : continuous f)\n  (U : opens \u03b3) : U.comap (hg.comp hf) = (U.comap hg).comap hf :=\nprotected theorem comap_comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : continuous g) (hf : continuous f) (U : opens \u03b3) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (f : \u03b1 \u2243\u209c \u03b2) : opens \u03b1 \u2243 opens \u03b2 :=\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 {\u03b1 : Type u_1} [topological_space \u03b1] (x : \u03b1) :=\n  Subtype fun (s : set \u03b1) => is_open s \u2227 x \u2208 s\n\nprotected instance open_nhds_of.inhabited {\u03b1 : Type u_1} [topological_space \u03b1] (x : \u03b1) : 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `(\u207b\u00b9)` / `(+)` 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., `\u2115` and `\u211d\u22650` 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 \u2243\u209c 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) : \u21d1(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 \u2243\u209c 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 `\u03bb x y, x * y\u207b\u00b9` (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 {\u03b1 : Type u} {G : Type w} [topological_space G] [group G] [topological_group G] {f : \u03b1 \u2192 G} {l : filter \u03b1} {y : G} (h : filter.tendsto f l (nhds y)) : filter.tendsto (fun (x : \u03b1) => f x\u207b\u00b9) l (nhds (y\u207b\u00b9)) :=\n  filter.tendsto.comp (continuous.tendsto continuous_inv y) h\n\ntheorem continuous.inv {\u03b1 : Type u} {G : Type w} [topological_space G] [group G] [topological_group G] [topological_space \u03b1] {f : \u03b1 \u2192 G} (hf : continuous f) : continuous fun (x : \u03b1) => f x\u207b\u00b9 :=\n  continuous.comp continuous_inv hf\n\ntheorem continuous_on.inv {\u03b1 : Type u} {G : Type w} [topological_space G] [group G] [topological_group G] [topological_space \u03b1] {f : \u03b1 \u2192 G} {s : set \u03b1} (hf : continuous_on f s) : continuous_on (fun (x : \u03b1) => f x\u207b\u00b9) s :=\n  continuous.comp_continuous_on continuous_inv hf\n\ntheorem continuous_within_at.inv {\u03b1 : Type u} {G : Type w} [topological_space G] [group G] [topological_group G] [topological_space \u03b1] {f : \u03b1 \u2192 G} {s : set \u03b1} {x : \u03b1} (hf : continuous_within_at f s x) : continuous_within_at (fun (x : \u03b1) => f x\u207b\u00b9) 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 \u00d7 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 \u2243\u209c 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) \u21a6 (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 \u00d7 G \u2243\u209c G \u00d7 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] : \u21d1(homeomorph.shear_mul_right G) = fun (z : G \u00d7 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] : \u21d1(homeomorph.symm (homeomorph.shear_mul_right G)) = fun (z : G \u00d7 G) => (prod.fst z, prod.fst z\u207b\u00b9 * 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\u207b\u00b9 = closure (s\u207b\u00b9) :=\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 \u2208 nhds 0) : \u2203 (V : set G), \u2203 (H : V \u2208 nhds 0), \u2200 (v : G), v \u2208 V \u2192 \u2200 (w : G), w \u2208 V \u2192 v - w \u2208 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\u207b\u00b9)) (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\u207b\u00b9) (nhds 1) (nhds 1)) (hleft : \u2200 (x\u2080 : G), nhds x\u2080 = filter.map (fun (x : G) => x\u2080 * x) (nhds 1)) (hconj : \u2200 (x\u2080 : G), filter.map (fun (x : G) => x\u2080 * x * (x\u2080\u207b\u00b9)) (nhds 1) \u2264 nhds 1) : continuous fun (x : G) => x\u207b\u00b9 := 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 : \u2200 (x\u2080 : G), nhds x\u2080 = filter.map (fun (x : G) => x\u2080 + x) (nhds 0)) (hright : \u2200 (x\u2080 : G), nhds x\u2080 = filter.map (fun (x : G) => x + x\u2080) (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 : \u2200 (x\u2080 : G), nhds x\u2080 = filter.map (fun (x : G) => x\u2080 + x) (nhds 0)) (hconj : \u2200 (x\u2080 : G), filter.tendsto (fun (x : G) => x\u2080 + x + -x\u2080) (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 : \u2200 (x\u2080 : G), nhds x\u2080 = filter.map (fun (x : G) => x\u2080 + 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 \u2192 quotient_add_group.quotient N) (e_3 : f = f_1) =>\n          congr_arg continuous e_3)\n        Neg.neg (quotient.lift (coe \u2218 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 `\u03bb p : G \u00d7 G, p.1 - p.2` is a continuous function. This property\nautomatically holds for topological additive groups but it also holds, e.g., for `\u211d\u22650`. -/\nclass has_continuous_sub (G : Type u_1) [topological_space G] [Sub G] \nwhere\n  continuous_sub : continuous fun (p : G \u00d7 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 \u00d7 G \u2192 G) (e_3 : f = f_1) => congr_arg continuous e_3)\n          (fun (p : G \u00d7 G) => prod.fst p - prod.snd p) (fun (p : G \u00d7 G) => prod.fst p + -prod.snd p)\n          (funext fun (p : G \u00d7 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 {\u03b1 : Type u} {G : Type w} [topological_space G] [Sub G] [has_continuous_sub G] {f : \u03b1 \u2192 G} {g : \u03b1 \u2192 G} {l : filter \u03b1} {a : G} {b : G} (hf : filter.tendsto f l (nhds a)) (hg : filter.tendsto g l (nhds b)) : filter.tendsto (fun (x : \u03b1) => 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 {\u03b1 : Type u} {G : Type w} [topological_space G] [Sub G] [has_continuous_sub G] [topological_space \u03b1] {f : \u03b1 \u2192 G} {g : \u03b1 \u2192 G} (hf : continuous f) (hg : continuous g) : continuous fun (x : \u03b1) => f x - g x :=\n  continuous.comp continuous_sub (continuous.prod_mk hf hg)\n\ntheorem continuous_within_at.sub {\u03b1 : Type u} {G : Type w} [topological_space G] [Sub G] [has_continuous_sub G] [topological_space \u03b1] {f : \u03b1 \u2192 G} {g : \u03b1 \u2192 G} {s : set \u03b1} {x : \u03b1} (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) : continuous_within_at (fun (x : \u03b1) => f x - g x) s x :=\n  filter.tendsto.sub hf hg\n\ntheorem continuous_on.sub {\u03b1 : Type u} {G : Type w} [topological_space G] [Sub G] [has_continuous_sub G] [topological_space \u03b1] {f : \u03b1 \u2192 G} {g : \u03b1 \u2192 G} {s : set \u03b1} (hf : continuous_on f s) (hg : continuous_on g s) : continuous_on (fun (x : \u03b1) => f x - g x) s :=\n  fun (x : \u03b1) (hx : x \u2208 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 \u2264 Z\n  sub_Z : filter.tendsto (fun (p : G \u00d7 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 \u00d7 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 \u2208 Z G) : \u2203 (V : set G), \u2203 (H : V \u2208 Z G), \u2200 (v : G), v \u2208 V \u2192 \u2200 (w : G), w \u2208 V \u2192 v + w \u2208 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 \u00d7 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 \u2192 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 \u2208 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 \u2192 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 \u2208 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 \u2286 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 \u2286 U) : \u2203 (V : set G), is_open V \u2227 0 \u2208 V \u2227 K + V \u2286 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)) : \u2203 (t : finset G), K \u2286 set.Union fun (g : G) => set.Union fun (H : g \u2208 t) => (fun (h : G) => g + h) \u207b\u00b9' V := sorry\n\n/-- Every locally compact separable topological group is \u03c3-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 {\u03b1 : Type*}\n\ndef is_prefix (l\u2081 : list \u03b1) (l\u2082 : list \u03b1 ) : Prop :=\n\u2203 t, l\u2081 ++ t = l\u2082\n\ninfix ` <+: `:50 := is_prefix\n\nattribute [simp]\ntheorem list.is_prefix_refl (l : list \u03b1) : l <+: l :=\n\u27e8[], by simp\u27e9\n\nexample : [1, 2, 3] <+: [1, 2, 3] := by simp\n\n@[simp]\ntheorem list.is_prefix_refl' (l : list \u03b1) : l <+: l :=\n\u27e8[], by simp\u27e9\n\ntheorem list.is_prefix_refl'' (l : list \u03b1) : l <+: l :=\n\u27e8[], by simp\u27e9\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 \u2964 V`,\ncomputing the `i`-th homology.\n-/\n\nuniverses v u\n\nopen category_theory category_theory.limits\n\nvariables {\u03b9 : Type*}\nvariables {V : Type u} [category.{v} V] [has_zero_morphisms V]\nvariables {c : complex_shape \u03b9} (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 : \u03b9) : subobject (C.X i) :=\nkernel_subobject (C.d_from i)\n\n@[simp, reassoc]\nlemma cycles_arrow_d_from (i : \u03b9) : (C.cycles i).arrow \u226b C.d_from i = 0 :=\nby { dsimp [cycles], simp, }\n\nlemma cycles_eq_kernel_subobject {i j : \u03b9} (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 : \u03b9} (r : c.rel i j) :\n  (C.cycles i : V) \u2245 kernel (C.d i j) :=\nsubobject.iso_of_eq _ _ (C.cycles_eq_kernel_subobject r) \u226a\u226b\n  kernel_subobject_iso (C.d i j)\n\nlemma cycles_eq_top {i} (h : c.next i = none) : C.cycles i = \u22a4 :=\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 : \u03b9) : subobject (C.X j) :=\nimage_subobject (C.d_to j)\n\nlemma boundaries_eq_image_subobject [has_equalizers V] {i j : \u03b9} (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 : \u03b9} (r : c.rel i j) :\n  (C.boundaries j : V) \u2245 image (C.d i j) :=\nsubobject.iso_of_eq _ _ (C.boundaries_eq_image_subobject r) \u226a\u226b\n  image_subobject_iso (C.d i j)\n\nlemma boundaries_eq_bot {j} (h : c.prev j = none) : C.boundaries j = \u22a5 :=\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 : \u03b9) :\n  C.boundaries i \u2264 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 : \u03b9) :\n  (C.boundaries i : V) \u27f6 (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 : \u03b9) (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 : \u03b9) :\n  C.boundaries_to_cycles i \u226b (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 : \u03b9) : 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\u2081 C\u2082 C\u2083 : homological_complex V c} (f : C\u2081 \u27f6 C\u2082)\n\n/--\nThe morphism between cycles induced by a chain map.\n-/\nabbreviation cycles_map (f : C\u2081 \u27f6 C\u2082) (i : \u03b9) : (C\u2081.cycles i : V) \u27f6 (C\u2082.cycles i : V) :=\nsubobject.factor_thru _ ((C\u2081.cycles i).arrow \u226b f.f i) (kernel_subobject_factors _ _ (by simp))\n\n@[simp] lemma cycles_map_arrow (f : C\u2081 \u27f6 C\u2082) (i : \u03b9) :\n  (cycles_map f i) \u226b (C\u2082.cycles i).arrow = (C\u2081.cycles i).arrow \u226b f.f i :=\nby { simp, }\n\n@[simp] lemma cycles_map_id (i : \u03b9) : cycles_map (\ud835\udfd9 C\u2081) i = \ud835\udfd9 _ :=\nby { dunfold cycles_map, simp, }\n\n@[simp] lemma cycles_map_comp (f : C\u2081 \u27f6 C\u2082) (g : C\u2082 \u27f6 C\u2083) (i : \u03b9) :\n  cycles_map (f \u226b g) i = cycles_map f i \u226b 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 : \u03b9) : homological_complex V c \u2964 V :=\n{ obj := \u03bb C, C.cycles i,\n  map := \u03bb C\u2081 C\u2082 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\u2081 C\u2082 C\u2083 : homological_complex V c} (f : C\u2081 \u27f6 C\u2082)\n\n/--\nThe morphism between boundaries induced by a chain map.\n-/\nabbreviation boundaries_map (f : C\u2081 \u27f6 C\u2082) (i : \u03b9) : (C\u2081.boundaries i : V) \u27f6 (C\u2082.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 : \u03b9) : homological_complex V c \u2964 V :=\n{ obj := \u03bb C, C.boundaries i,\n  map := \u03bb C\u2081 C\u2082 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\u2081 C\u2082 : homological_complex V c} (f : C\u2081 \u27f6 C\u2082)\n\n@[simp, reassoc]\nlemma boundaries_to_cycles_naturality (i : \u03b9) :\n  boundaries_map f i \u226b C\u2082.boundaries_to_cycles i = C\u2081.boundaries_to_cycles i \u226b 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 : \u03b9) :\n  boundaries_functor V c i \u27f6 cycles_functor V c i :=\n{ app := \u03bb C, C.boundaries_to_cycles i,\n  naturality' := \u03bb C\u2081 C\u2082 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 : \u03b9) :\n  homological_complex V c \u2964 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 := \u03bb C, C.homology i,\n  map := \u03bb C\u2081 C\u2082 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.\u03c0_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.\u03c0_map_assoc,\n      homology.\u03c0_map, category.assoc]\n  end }\n\n/-- The homology functor from `\u03b9`-indexed complexes to `\u03b9`-graded objects in `V`. -/\n@[simps] def graded_homology_functor [has_cokernels V] :\n  homological_complex V c \u2964 graded_object \u03b9 V :=\n{ obj := \u03bb C i, C.homology i,\n  map := \u03bb 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.\u03c0_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.\u03c0_map_assoc,\n      pi.comp_apply, homology.\u03c0_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\u00f3n relacionP es inversa por la izquierda de la funci\u00f3n cociente\n-- Jos\u00e9 A. Alonso Jim\u00e9nez\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 : \u2200 X \u2208 Bloques, (X : set A).nonempty)\n(Hrecubren  : \u2200 a, \u2203 X \u2208 Bloques, a \u2208 X)\n(Hdisjuntos : \u2200 X Y \u2208 Bloques, (X \u2229 Y : set A).nonempty \u2192 X = Y)\n\nnamespace particion\n\nvariable  {A : Type}\nvariables {X Y : set A}\nvariable  {P : particion A}\nvariable  (R : A \u2192 A \u2192 Prop)\n\ndef clase (a : A) :=\n  {b : A | R b a}\n\ndef clases : (A \u2192 A \u2192 Prop) \u2192 set (set A) :=\n  \u03bb R, {B : set A | \u2203 x : A, B = clase R x}\n\nlemma pertenece_clase_syss\n  {a b : A}\n  : b \u2208 clase R a \u2194 R b a :=\nby refl\n\nlemma clases_no_vacias\n  (hR: equivalence R)\n  : \u2200 (X : set A), X \u2208 clases R \u2192 X.nonempty :=\nbegin\n  rintros _ \u27e8a, rfl\u27e9,\n  use a,\n  rw pertenece_clase_syss,\n  apply hR.1,\nend\n\nlemma clases_recubren\n  (hR: equivalence R)\n  : \u2200 a, \u2203 X \u2208 clases R, a \u2208 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 \u2192 A \u2192 Prop}\n  (hR: equivalence R)\n  {a b : A}\n  : a \u2208 clase R b \u2192 clase R a \u2286 clase R b :=\n\u03bb hab z hza, hR.2.2 hza hab\n\nlemma clases_iguales_si_pertenece\n  {R : A \u2192 A \u2192 Prop}\n  (hR: equivalence R)\n  {a b : A}\n  : a \u2208 clase R b \u2192 clase R a = clase R b :=\n\u03bb 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  : \u2200 X Y \u2208 clases R, (X \u2229 Y : set A).nonempty \u2192 X = Y :=\nbegin\n  rintros X \u27e8a, rfl\u27e9 Y \u27e8b, rfl\u27e9 \u27e8c, hca, hcb\u27e9,\n  exact clases_iguales_si_pertenece hR (hR.2.2 (hR.2.1 hca) hcb),\nend\n\ndef cociente : {R : A \u2192 A \u2192 Prop // equivalence R} \u2192 particion A :=\n  \u03bb R, { Bloques    := {B : set A | \u2203 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) \u2192 (A \u2192 A \u2192 Prop) :=\n  \u03bb P a b, \u2200 X \u2208 Bloques P, a \u2208 X \u2192 b \u2208 X\n\nlemma reflexiva\n  (P : particion A)\n  : reflexive (relacion P) :=\n\u03bb a X hXC haX, haX\n\nlemma iguales_si_comun\n  (hX : X \u2208 Bloques P)\n  (hY : Y \u2208 Bloques P)\n  {a : A}\n  (haX : a \u2208 X)\n  (haY : a \u2208 Y)\n  : X = Y :=\nHdisjuntos P X hX Y hY \u27e8a, haX, haY\u27e9\n\nlemma pertenece_si_pertenece\n  (hX : X \u2208 Bloques P)\n  (hY : Y \u2208 Bloques P)\n  {a b : A}\n  (haX : a \u2208 X)\n  (haY : a \u2208 Y)\n  (hbX : b \u2208 X)\n  : b \u2208 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 \u27e8Y, hY, haY\u27e9 := 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\u03bb a b c hab hbc X hX haX, hbc X hX (hab X hX haX)\n\ndef relacionP : particion A \u2192 {R : A \u2192 A \u2192 Prop // equivalence R} :=\n  \u03bb P, \u27e8\u03bb a b, \u2200 X \u2208 Bloques P, a \u2208 X \u2192 b \u2208 X,\n        \u27e8reflexiva P, simetrica P, transitiva P\u27e9\u27e9\n\n-- 1\u00aa demostraci\u00f3n\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\u00aa demostraci\u00f3n\nexample :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  rintro \u27e8R, hR\u27e9,\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\u00aa demostraci\u00f3n\nexample :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  rintro \u27e8R, hR\u27e9,\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\u00aa demostraci\u00f3n\nexample :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  rintro \u27e8R, hR\u27e9,\n  simp [relacionP, cociente],\n  ext a b,\n  split,\n  { exact \u03bb hab, hR.2.1 (hab a (hR.1 a)), },\n  { exact \u03bb hab c hac, hR.2.2 (hR.2.1 hab) hac, },\nend\n\n-- 5\u00aa demostraci\u00f3n\nlemma inversa_izq :\n  function.left_inverse relacionP (@cociente A) :=\nbegin\n  rintro \u27e8R, hR\u27e9,\n  simp [relacionP, cociente],\n  ext a b,\n  exact \u27e8\u03bb hab, hR.2.1 (hab a (hR.1 a)),\n         \u03bb hab c hac, hR.2.2 (hR.2.1 hab) hac\u27e9,\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u03b1`, a measure on `\u03b1` is a function that sends measurable sets to the\nextended nonnegative reals that satisfies the following conditions:\n1. `\u03bc \u2205 = 0`;\n2. `\u03bc` 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 `\u03b1` form a complete lattice, and are closed under scalar multiplication with `\u211d\u22650\u221e`.\n\nWe introduce the following typeclasses for measures:\n\n* `is_probability_measure \u03bc`: `\u03bc univ = 1`;\n* `is_finite_measure \u03bc`: `\u03bc univ < \u221e`;\n* `sigma_finite \u03bc`: there exists a countable collection of sets that cover `univ`\n  where `\u03bc` is finite;\n* `is_locally_finite_measure \u03bc` : `\u2200 x, \u2203 s \u2208 \ud835\udcdd x, \u03bc s < \u221e`;\n* `has_no_atoms \u03bc` : `\u2200 x, \u03bc {x} = 0`; possibly should be redefined as\n  `\u2200 s, 0 < \u03bc s \u2192 \u2203 t \u2286 s, 0 < \u03bc t \u2227 \u03bc t < \u03bc s`.\n\nGiven a measure, the null sets are the sets where `\u03bc s = 0`, where `\u03bc` denotes the corresponding\nouter measure (so `s` might not be measurable). We can then define the completion of `\u03bc` as the\nmeasure on the least `\u03c3`-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 `\u03bc : measure \u03b1`, `\u03bc 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\u00e9odory 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 \u03c0-system generating\n  the measurable sets, if the \u03c0-system contains a spanning increasing sequence of sets where the\n  measures take finite value (in particular the measures are \u03c3-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 \u03c0-system\n  generating the measurable sets. This is a special case of `ext_of_generate_from_of_Union` using\n  `C \u222a {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 {\u03b1 \u03b2 \u03b3 \u03b4 \u03b9 R R' : Type _}\n\nnamespace MeasureTheory\n\nsection\n\nvariable {m : MeasurableSpace \u03b1} {\u03bc \u03bc\u2081 \u03bc\u2082 : Measure \u03b1} {s s\u2081 s\u2082 t : Set \u03b1}\n\ninstance ae_isMeasurablyGenerated : IsMeasurablyGenerated \u03bc.ae :=\n  \u27e8fun s hs =>\n    let \u27e8t, hst, htm, ht\u03bc\u27e9 := exists_measurable_superset_of_null hs\n    \u27e8t\u1d9c, compl_mem_ae_iff.2 ht\u03bc, htm.compl, compl_subset_comm.1 hst\u27e9\u27e9\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 \u03b1] {a b : \u03b1} {P : \u03b1 \u2192 Prop} :\n    (\u2200\u1d50 x \u2202\u03bc, x \u2208 \u0399 a b \u2192 P x) \u2194 (\u2200\u1d50 x \u2202\u03bc, x \u2208 Ioc a b \u2192 P x) \u2227 \u2200\u1d50 x \u2202\u03bc, x \u2208 Ioc b a \u2192 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\u2081 s\u2082) (h : MeasurableSet s\u2082) : \u03bc (s\u2081 \u222a s\u2082) = \u03bc s\u2081 + \u03bc s\u2082 :=\n  measure_union\u2080 h.NullMeasurableSet hd.AeDisjoint\n#align measure_theory.measure_union MeasureTheory.measure_union\n\ntheorem measure_union' (hd : Disjoint s\u2081 s\u2082) (h : MeasurableSet s\u2081) : \u03bc (s\u2081 \u222a s\u2082) = \u03bc s\u2081 + \u03bc s\u2082 :=\n  measure_union\u2080' h.NullMeasurableSet hd.AeDisjoint\n#align measure_theory.measure_union' MeasureTheory.measure_union'\n\ntheorem measure_inter_add_diff (s : Set \u03b1) (ht : MeasurableSet t) : \u03bc (s \u2229 t) + \u03bc (s \\ t) = \u03bc s :=\n  measure_inter_add_diff\u2080 _ ht.NullMeasurableSet\n#align measure_theory.measure_inter_add_diff MeasureTheory.measure_inter_add_diff\n\ntheorem measure_diff_add_inter (s : Set \u03b1) (ht : MeasurableSet t) : \u03bc (s \\ t) + \u03bc (s \u2229 t) = \u03bc 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 \u03b1) (ht : MeasurableSet t) :\n    \u03bc (s \u222a t) + \u03bc (s \u2229 t) = \u03bc s + \u03bc t :=\n  by\n  rw [\u2190 measure_inter_add_diff (s \u222a t) ht, Set.union_inter_cancel_right, union_diff_right, \u2190\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 \u03b1) :\n    \u03bc (s \u222a t) + \u03bc (s \u2229 t) = \u03bc s + \u03bc 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) : \u03bc s + \u03bc (s\u1d9c) = \u03bc univ :=\n  measure_add_measure_compl\u2080 h.NullMeasurableSet\n#align measure_theory.measure_add_measure_compl MeasureTheory.measure_add_measure_compl\n\ntheorem measure_bUnion\u2080 {s : Set \u03b2} {f : \u03b2 \u2192 Set \u03b1} (hs : s.Countable)\n    (hd : s.Pairwise (AeDisjoint \u03bc on f)) (h : \u2200 b \u2208 s, NullMeasurableSet (f b) \u03bc) :\n    \u03bc (\u22c3 b \u2208 s, f b) = \u2211' p : s, \u03bc (f p) :=\n  by\n  haveI := hs.to_encodable\n  rw [bUnion_eq_Union]\n  exact measure_Union\u2080 (hd.on_injective Subtype.coe_injective fun x => x.2) fun x => h x x.2\n#align measure_theory.measure_bUnion\u2080 MeasureTheory.measure_bUnion\u2080\n\ntheorem measure_bUnion {s : Set \u03b2} {f : \u03b2 \u2192 Set \u03b1} (hs : s.Countable) (hd : s.PairwiseDisjoint f)\n    (h : \u2200 b \u2208 s, MeasurableSet (f b)) : \u03bc (\u22c3 b \u2208 s, f b) = \u2211' p : s, \u03bc (f p) :=\n  measure_bUnion\u2080 hs hd.AeDisjoint fun b hb => (h b hb).NullMeasurableSet\n#align measure_theory.measure_bUnion MeasureTheory.measure_bUnion\n\ntheorem measure_sUnion\u2080 {S : Set (Set \u03b1)} (hs : S.Countable) (hd : S.Pairwise (AeDisjoint \u03bc))\n    (h : \u2200 s \u2208 S, NullMeasurableSet s \u03bc) : \u03bc (\u22c3\u2080 S) = \u2211' s : S, \u03bc s := by\n  rw [sUnion_eq_bUnion, measure_bUnion\u2080 hs hd h]\n#align measure_theory.measure_sUnion\u2080 MeasureTheory.measure_sUnion\u2080\n\ntheorem measure_union\u209b {S : Set (Set \u03b1)} (hs : S.Countable) (hd : S.Pairwise Disjoint)\n    (h : \u2200 s \u2208 S, MeasurableSet s) : \u03bc (\u22c3\u2080 S) = \u2211' s : S, \u03bc s := by\n  rw [sUnion_eq_bUnion, measure_bUnion hs hd h]\n#align measure_theory.measure_sUnion MeasureTheory.measure_union\u209b\n\ntheorem measure_bUnion_finset\u2080 {s : Finset \u03b9} {f : \u03b9 \u2192 Set \u03b1}\n    (hd : Set.Pairwise (\u2191s) (AeDisjoint \u03bc on f)) (hm : \u2200 b \u2208 s, NullMeasurableSet (f b) \u03bc) :\n    \u03bc (\u22c3 b \u2208 s, f b) = \u2211 p in s, \u03bc (f p) :=\n  by\n  rw [\u2190 Finset.sum_attach, Finset.attach_eq_univ, \u2190 tsum_fintype]\n  exact measure_bUnion\u2080 s.countable_to_set hd hm\n#align measure_theory.measure_bUnion_finset\u2080 MeasureTheory.measure_bUnion_finset\u2080\n\ntheorem measure_bUnion_finset {s : Finset \u03b9} {f : \u03b9 \u2192 Set \u03b1} (hd : PairwiseDisjoint (\u2191s) f)\n    (hm : \u2200 b \u2208 s, MeasurableSet (f b)) : \u03bc (\u22c3 b \u2208 s, f b) = \u2211 p in s, \u03bc (f p) :=\n  measure_bUnion_finset\u2080 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\u1d62_of_disjoint {\u03b9 : Type _} [MeasurableSpace \u03b1] (\u03bc : Measure \u03b1)\n    {As : \u03b9 \u2192 Set \u03b1} (As_mble : \u2200 i : \u03b9, MeasurableSet (As i))\n    (As_disj : Pairwise (Disjoint on As)) : (\u2211' i, \u03bc (As i)) \u2264 \u03bc (\u22c3 i, As i) :=\n  by\n  rcases show Summable fun i => \u03bc (As i) from ENNReal.summable with \u27e8S, hS\u27e9\n  rw [hS.tsum_eq]\n  refine' tendsto_le_of_eventuallyLE hS tendsto_const_nhds (eventually_of_forall _)\n  intro s\n  rw [\u2190 measure_bUnion_finset (fun i hi j hj hij => As_disj hij) fun i _ => As_mble i]\n  exact measure_mono (Union\u2082_subset_Union (fun i : \u03b9 => i \u2208 s) fun i : \u03b9 => As i)\n#align measure_theory.tsum_meas_le_meas_Union_of_disjoint MeasureTheory.tsum_meas_le_meas_union\u1d62_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 \u207b\u00b9' {y}`. -/\ntheorem tsum_measure_preimage_singleton {s : Set \u03b2} (hs : s.Countable) {f : \u03b1 \u2192 \u03b2}\n    (hf : \u2200 y \u2208 s, MeasurableSet (f \u207b\u00b9' {y})) : (\u2211' b : s, \u03bc (f \u207b\u00b9' {\u2191b})) = \u03bc (f \u207b\u00b9' s) := by\n  rw [\u2190 Set.bunion\u1d62_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 \u207b\u00b9' {y}`. -/\ntheorem sum_measure_preimage_singleton (s : Finset \u03b2) {f : \u03b1 \u2192 \u03b2}\n    (hf : \u2200 y \u2208 s, MeasurableSet (f \u207b\u00b9' {y})) : (\u2211 b in s, \u03bc (f \u207b\u00b9' {b})) = \u03bc (f \u207b\u00b9' \u2191s) := by\n  simp only [\u2190 measure_bUnion_finset (pairwise_disjoint_fiber _ _) hf,\n    Finset.set_bunion\u1d62_preimage_singleton]\n#align measure_theory.sum_measure_preimage_singleton MeasureTheory.sum_measure_preimage_singleton\n\ntheorem measure_diff_null' (h : \u03bc (s\u2081 \u2229 s\u2082) = 0) : \u03bc (s\u2081 \\ s\u2082) = \u03bc s\u2081 :=\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 : \u03bc s\u2082 = 0) : \u03bc (s\u2081 \\ s\u2082) = \u03bc s\u2081 :=\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 \u03b1) : \u03bc s + \u03bc (t \\ s) = \u03bc (s \u222a t) := by\n  rw [\u2190 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 \u03b1) (hm : MeasurableSet t) (h_fin : \u03bc t \u2260 \u221e) :\n    \u03bc (s \\ t) = \u03bc (s \u222a t) - \u03bc 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\u2082 \u2286 s\u2081) (h\u2082 : MeasurableSet s\u2082) (h_fin : \u03bc s\u2082 \u2260 \u221e) :\n    \u03bc (s\u2081 \\ s\u2082) = \u03bc s\u2081 - \u03bc s\u2082 := by rw [measure_diff' _ h\u2082 h_fin, union_eq_self_of_subset_right h]\n#align measure_theory.measure_diff MeasureTheory.measure_diff\n\ntheorem le_measure_diff : \u03bc s\u2081 - \u03bc s\u2082 \u2264 \u03bc (s\u2081 \\ s\u2082) :=\n  tsub_le_iff_left.2 <|\n    calc\n      \u03bc s\u2081 \u2264 \u03bc (s\u2082 \u222a s\u2081) := measure_mono (subset_union_right _ _)\n      _ = \u03bc (s\u2082 \u222a s\u2081 \\ s\u2082) := (congr_arg \u03bc union_diff_self.symm)\n      _ \u2264 \u03bc s\u2082 + \u03bc (s\u2081 \\ s\u2082) := 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 \u2286 t) (hs' : \u03bc s \u2260 \u221e) {\u03b5 : \u211d\u22650\u221e}\n    (h : \u03bc t < \u03bc s + \u03b5) : \u03bc (t \\ s) < \u03b5 :=\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 \u2286 t) (hs' : \u03bc s \u2260 \u221e) {\u03b5 : \u211d\u22650\u221e} :\n    \u03bc (t \\ s) \u2264 \u03b5 \u2194 \u03bc t \u2264 \u03bc s + \u03b5 := 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 \u03b1} (hst : s \u2286 t) (h_nulldiff : \u03bc (t \\ s) = 0) :\n    \u03bc s = \u03bc 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\u2081 s\u2082 s\u2083 : Set \u03b1} (h12 : s\u2081 \u2286 s\u2082) (h23 : s\u2082 \u2286 s\u2083)\n    (h_nulldiff : \u03bc (s\u2083 \\ s\u2081) = 0) : \u03bc s\u2081 = \u03bc s\u2082 \u2227 \u03bc s\u2082 = \u03bc s\u2083 :=\n  by\n  have le12 : \u03bc s\u2081 \u2264 \u03bc s\u2082 := measure_mono h12\n  have le23 : \u03bc s\u2082 \u2264 \u03bc s\u2083 := measure_mono h23\n  have key : \u03bc s\u2083 \u2264 \u03bc s\u2081 :=\n    calc\n      \u03bc s\u2083 = \u03bc (s\u2083 \\ s\u2081 \u222a s\u2081) := by rw [diff_union_of_subset (h12.trans h23)]\n      _ \u2264 \u03bc (s\u2083 \\ s\u2081) + \u03bc s\u2081 := (measure_union_le _ _)\n      _ = \u03bc s\u2081 := by simp only [h_nulldiff, zero_add]\n      \n  exact \u27e8le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)\u27e9\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\u2081 s\u2082 s\u2083 : Set \u03b1} (h12 : s\u2081 \u2286 s\u2082)\n    (h23 : s\u2082 \u2286 s\u2083) (h_nulldiff : \u03bc (s\u2083 \\ s\u2081) = 0) : \u03bc s\u2081 = \u03bc s\u2082 :=\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\u2081 s\u2082 s\u2083 : Set \u03b1} (h12 : s\u2081 \u2286 s\u2082)\n    (h23 : s\u2082 \u2286 s\u2083) (h_nulldiff : \u03bc (s\u2083 \\ s\u2081) = 0) : \u03bc s\u2082 = \u03bc s\u2083 :=\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\u2081 : MeasurableSet s) (h_fin : \u03bc s \u2260 \u221e) : \u03bc (s\u1d9c) = \u03bc univ - \u03bc s :=\n  by\n  rw [compl_eq_univ_diff]\n  exact measure_diff (subset_univ s) h\u2081 h_fin\n#align measure_theory.measure_compl MeasureTheory.measure_compl\n\n@[simp]\ntheorem union_ae_eq_left_iff_ae_subset : (s \u222a t : Set \u03b1) =\u1d50[\u03bc] s \u2194 t \u2264\u1d50[\u03bc] s :=\n  by\n  rw [ae_le_set]\n  refine'\n    \u27e8fun h => by simpa only [union_diff_left] using (ae_eq_set.mp h).1, fun h =>\n      eventually_le_antisymm_iff.mpr\n        \u27e8by rwa [ae_le_set, union_diff_left],\n          HasSubset.Subset.eventuallyLE <| subset_union_left s t\u27e9\u27e9\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 \u222a t : Set \u03b1) =\u1d50[\u03bc] t \u2194 s \u2264\u1d50[\u03bc] 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\u2081 : s \u2264\u1d50[\u03bc] t) (h\u2082 : \u03bc t \u2264 \u03bc s) (hsm : MeasurableSet s)\n    (ht : \u03bc t \u2260 \u221e) : s =\u1d50[\u03bc] t :=\n  by\n  refine' eventually_le_antisymm_iff.mpr \u27e8h\u2081, ae_le_set.mpr _\u27e9\n  replace h\u2082 : \u03bc t = \u03bc s; exact h\u2082.antisymm (measure_mono_ae h\u2081)\n  replace ht : \u03bc s \u2260 \u221e; exact h\u2082 \u25b8 ht\n  rw [measure_diff' t hsm ht, measure_congr (union_ae_eq_left_iff_ae_subset.mpr h\u2081), h\u2082, 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 \u2286 t`, `\u03bc t \u2264 \u03bc s`, `\u03bc t \u2260 \u221e`, and `s` is measurable, then `s =\u1d50[\u03bc] t`. -/\ntheorem ae_eq_of_subset_of_measure_ge (h\u2081 : s \u2286 t) (h\u2082 : \u03bc t \u2264 \u03bc s) (hsm : MeasurableSet s)\n    (ht : \u03bc t \u2260 \u221e) : s =\u1d50[\u03bc] t :=\n  ae_eq_of_ae_subset_of_measure_ge (HasSubset.Subset.eventuallyLE h\u2081) h\u2082 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\u1d62_congr_of_subset [Countable \u03b2] {s : \u03b2 \u2192 Set \u03b1} {t : \u03b2 \u2192 Set \u03b1}\n    (hsub : \u2200 b, s b \u2286 t b) (h_le : \u2200 b, \u03bc (t b) \u2264 \u03bc (s b)) : \u03bc (\u22c3 b, s b) = \u03bc (\u22c3 b, t b) :=\n  by\n  rcases em (\u2203 b, \u03bc (t b) = \u221e) with (\u27e8b, hb\u27e9 | htop)\n  \u00b7\n    calc\n      \u03bc (\u22c3 b, s b) = \u221e := top_unique (hb \u25b8 (h_le b).trans <| measure_mono <| subset_Union _ _)\n      _ = \u03bc (\u22c3 b, t b) := Eq.symm <| top_unique <| hb \u25b8 measure_mono <| subset_Union _ _\n      \n  push_neg  at htop\n  refine' le_antisymm (measure_mono (Union_mono hsub)) _\n  set M := to_measurable \u03bc\n  have H : \u2200 b, (M (t b) \u2229 M (\u22c3 b, s b) : Set \u03b1) =\u1d50[\u03bc] M (t b) :=\n    by\n    refine' fun b => ae_eq_of_subset_of_measure_ge (inter_subset_left _ _) _ _ _\n    \u00b7\n      calc\n        \u03bc (M (t b)) = \u03bc (t b) := measure_to_measurable _\n        _ \u2264 \u03bc (s b) := (h_le b)\n        _ \u2264 \u03bc (M (t b) \u2229 M (\u22c3 b, s b)) :=\n          measure_mono <|\n            subset_inter ((hsub b).trans <| subset_to_measurable _ _)\n              ((subset_Union _ _).trans <| subset_to_measurable _ _)\n        \n    \u00b7 exact (measurable_set_to_measurable _ _).inter (measurable_set_to_measurable _ _)\n    \u00b7 rw [measure_to_measurable]\n      exact htop b\n  calc\n    \u03bc (\u22c3 b, t b) \u2264 \u03bc (\u22c3 b, M (t b)) := measure_mono (Union_mono fun b => subset_to_measurable _ _)\n    _ = \u03bc (\u22c3 b, M (t b) \u2229 M (\u22c3 b, s b)) := (measure_congr (EventuallyEq.countable_union\u1d62 H).symm)\n    _ \u2264 \u03bc (M (\u22c3 b, s b)) := (measure_mono (Union_subset fun b => inter_subset_right _ _))\n    _ = \u03bc (\u22c3 b, s b) := measure_to_measurable _\n    \n#align measure_theory.measure_Union_congr_of_subset MeasureTheory.measure_union\u1d62_congr_of_subset\n\ntheorem measure_union_congr_of_subset {t\u2081 t\u2082 : Set \u03b1} (hs : s\u2081 \u2286 s\u2082) (hs\u03bc : \u03bc s\u2082 \u2264 \u03bc s\u2081)\n    (ht : t\u2081 \u2286 t\u2082) (ht\u03bc : \u03bc t\u2082 \u2264 \u03bc t\u2081) : \u03bc (s\u2081 \u222a t\u2081) = \u03bc (s\u2082 \u222a t\u2082) :=\n  by\n  rw [union_eq_Union, union_eq_Union]\n  exact measure_Union_congr_of_subset (Bool.forall_bool.2 \u27e8ht, hs\u27e9) (Bool.forall_bool.2 \u27e8ht\u03bc, hs\u03bc\u27e9)\n#align measure_theory.measure_union_congr_of_subset MeasureTheory.measure_union_congr_of_subset\n\n@[simp]\ntheorem measure_union\u1d62_toMeasurable [Countable \u03b2] (s : \u03b2 \u2192 Set \u03b1) :\n    \u03bc (\u22c3 b, toMeasurable \u03bc (s b)) = \u03bc (\u22c3 b, s b) :=\n  Eq.symm <|\n    measure_union\u1d62_congr_of_subset (fun b => subset_toMeasurable _ _) fun b =>\n      (measure_toMeasurable _).le\n#align measure_theory.measure_Union_to_measurable MeasureTheory.measure_union\u1d62_toMeasurable\n\ntheorem measure_bUnion_toMeasurable {I : Set \u03b2} (hc : I.Countable) (s : \u03b2 \u2192 Set \u03b1) :\n    \u03bc (\u22c3 b \u2208 I, toMeasurable \u03bc (s b)) = \u03bc (\u22c3 b \u2208 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 : \u03bc (toMeasurable \u03bc s \u222a t) = \u03bc (s \u222a 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 : \u03bc (s \u222a toMeasurable \u03bc t) = \u03bc (s \u222a 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 \u03b9} {t : \u03b9 \u2192 Set \u03b1}\n    (h : \u2200 i \u2208 s, MeasurableSet (t i)) (H : Set.PairwiseDisjoint (\u2191s) t) :\n    (\u2211 i in s, \u03bc (t i)) \u2264 \u03bc (univ : Set \u03b1) :=\n  by\n  rw [\u2190 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 : \u03b9 \u2192 Set \u03b1} (hs : \u2200 i, MeasurableSet (s i))\n    (H : Pairwise (Disjoint on s)) : (\u2211' i, \u03bc (s i)) \u2264 \u03bc (univ : Set \u03b1) :=\n  by\n  rw [ENNReal.tsum_eq_sup\u1d62_sum]\n  exact sup\u1d62_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 `\u2211' i, \u03bc (s i) > \u03bc univ`, then\none of the intersections `s i \u2229 s j` is not empty. -/\ntheorem exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : MeasurableSpace \u03b1}\n    (\u03bc : Measure \u03b1) {s : \u03b9 \u2192 Set \u03b1} (hs : \u2200 i, MeasurableSet (s i))\n    (H : \u03bc (univ : Set \u03b1) < \u2211' i, \u03bc (s i)) : \u2203 (i j : _)(h : i \u2260 j), (s i \u2229 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 \u27e8x, hx\u27e9\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`\u2211 i in s, \u03bc (t i) > \u03bc univ`, then one of the intersections `t i \u2229 t j` is not empty. -/\ntheorem exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1)\n    {s : Finset \u03b9} {t : \u03b9 \u2192 Set \u03b1} (h : \u2200 i \u2208 s, MeasurableSet (t i))\n    (H : \u03bc (univ : Set \u03b1) < \u2211 i in s, \u03bc (t i)) :\n    \u2203 i \u2208 s, \u2203 j \u2208 s, \u2203 h : i \u2260 j, (t i \u2229 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 \u27e8x, hx\u27e9\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 `\u03bc s + \u03bc t > \u03bc u`,\nthen `s` intersects `t`. Version assuming that `t` is measurable. -/\ntheorem nonempty_inter_of_measure_lt_add {m : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) {s t u : Set \u03b1}\n    (ht : MeasurableSet t) (h's : s \u2286 u) (h't : t \u2286 u) (h : \u03bc u < \u03bc s + \u03bc t) : (s \u2229 t).Nonempty :=\n  by\n  rw [\u2190 Set.not_disjoint_iff_nonempty_inter]\n  contrapose! h\n  calc\n    \u03bc s + \u03bc t = \u03bc (s \u222a t) := (measure_union h ht).symm\n    _ \u2264 \u03bc 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 `\u03bc s + \u03bc t > \u03bc u`,\nthen `s` intersects `t`. Version assuming that `s` is measurable. -/\ntheorem nonempty_inter_of_measure_lt_add' {m : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) {s t u : Set \u03b1}\n    (hs : MeasurableSet s) (h's : s \u2286 u) (h't : t \u2286 u) (h : \u03bc u < \u03bc s + \u03bc t) : (s \u2229 t).Nonempty :=\n  by\n  rw [add_comm] at h\n  rw [inter_comm]\n  exact nonempty_inter_of_measure_lt_add \u03bc 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\u1d62_eq_sup\u1d62 [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (hd : Directed (\u00b7 \u2286 \u00b7) s) :\n    \u03bc (\u22c3 i, s i) = \u2a06 i, \u03bc (s i) := by\n  cases nonempty_encodable \u03b9\n  -- WLOG, `\u03b9 = \u2115`\n  generalize ht : Function.extend Encodable.encode s \u22a5 = t\n  replace hd : Directed (\u00b7 \u2286 \u00b7) t := ht \u25b8 hd.extend_bot Encodable.encode_injective\n  suffices \u03bc (\u22c3 n, t n) = \u2a06 n, \u03bc (t n)\n    by\n    simp only [\u2190 ht, encodable.encode_injective.apply_extend \u03bc, \u2190 supr_eq_Union,\n      sup\u1d62_extend_bot Encodable.encode_injective, (\u00b7 \u2218 \u00b7), Pi.bot_apply, bot_eq_empty,\n      measure_empty] at this\n    exact this.trans (sup\u1d62_extend_bot Encodable.encode_injective _)\n  clear! \u03b9\n  -- The `\u2265` inequality is trivial\n  refine' le_antisymm _ (sup\u1d62_le fun i => measure_mono <| subset_Union _ _)\n  -- Choose `T n \u2287 t n` of the same measure, put `Td n = disjointed T`\n  set T : \u2115 \u2192 Set \u03b1 := fun n => to_measurable \u03bc (t n)\n  set Td : \u2115 \u2192 Set \u03b1 := disjointed T\n  have hm : \u2200 n, MeasurableSet (Td n) :=\n    MeasurableSet.disjointed fun n => measurable_set_to_measurable _ _\n  calc\n    \u03bc (\u22c3 n, t n) \u2264 \u03bc (\u22c3 n, T n) := measure_mono (Union_mono fun i => subset_to_measurable _ _)\n    _ = \u03bc (\u22c3 n, Td n) := by rw [union\u1d62_disjointed]\n    _ \u2264 \u2211' n, \u03bc (Td n) := (measure_Union_le _)\n    _ = \u2a06 I : Finset \u2115, \u2211 n in I, \u03bc (Td n) := ENNReal.tsum_eq_sup\u1d62_sum\n    _ \u2264 \u2a06 n, \u03bc (t n) := sup\u1d62_le fun I => _\n    \n  rcases hd.finset_le I with \u27e8N, hN\u27e9\n  calc\n    (\u2211 n in I, \u03bc (Td n)) = \u03bc (\u22c3 n \u2208 I, Td n) :=\n      (measure_bUnion_finset ((disjoint_disjointed T).set_pairwise I) fun n _ => hm n).symm\n    _ \u2264 \u03bc (\u22c3 n \u2208 I, T n) := (measure_mono (Union\u2082_mono fun n hn => disjointed_subset _ _))\n    _ = \u03bc (\u22c3 n \u2208 I, t n) := (measure_bUnion_to_measurable I.countable_to_set _)\n    _ \u2264 \u03bc (t N) := (measure_mono (Union\u2082_subset hN))\n    _ \u2264 \u2a06 n, \u03bc (t n) := le_sup\u1d62 (\u03bc \u2218 t) N\n    \n#align measure_theory.measure_Union_eq_supr MeasureTheory.measure_union\u1d62_eq_sup\u1d62\n\ntheorem measure_bUnion_eq_sup\u1d62 {s : \u03b9 \u2192 Set \u03b1} {t : Set \u03b9} (ht : t.Countable)\n    (hd : DirectedOn ((\u00b7 \u2286 \u00b7) on s) t) : \u03bc (\u22c3 i \u2208 t, s i) = \u2a06 i \u2208 t, \u03bc (s i) :=\n  by\n  haveI := ht.to_encodable\n  rw [bUnion_eq_Union, measure_Union_eq_supr hd.directed_coe, \u2190 sup\u1d62_subtype'']\n#align measure_theory.measure_bUnion_eq_supr MeasureTheory.measure_bUnion_eq_sup\u1d62\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t \u00abexpr \u2286 \u00bb 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\u1d62_eq_inf\u1d62 [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (h : \u2200 i, MeasurableSet (s i))\n    (hd : Directed (\u00b7 \u2287 \u00b7) s) (hfin : \u2203 i, \u03bc (s i) \u2260 \u221e) : \u03bc (\u22c2 i, s i) = \u2a05 i, \u03bc (s i) :=\n  by\n  rcases hfin with \u27e8k, hk\u27e9\n  have : \u2200 (t) (_ : t \u2286 s k), \u03bc t \u2260 \u221e := fun t ht => ne_top_of_le_ne_top hk (measure_mono ht)\n  rw [\u2190 ENNReal.sub_sub_cancel hk (inf\u1d62_le _ k), ENNReal.sub_inf\u1d62, \u2190\n    ENNReal.sub_sub_cancel hk (measure_mono (Inter_subset _ k)), \u2190\n    measure_diff (Inter_subset _ k) (MeasurableSet.inter\u1d62 h) (this _ (Inter_subset _ k)),\n    diff_Inter, measure_Union_eq_supr]\n  \u00b7 congr 1\n    refine' le_antisymm (sup\u1d62_mono' fun i => _) (sup\u1d62_mono fun i => _)\n    \u00b7 rcases hd i k with \u27e8j, hji, hjk\u27e9\n      use j\n      rw [\u2190 measure_diff hjk (h _) (this _ hjk)]\n      exact measure_mono (diff_subset_diff_right hji)\n    \u00b7 rw [tsub_le_iff_right, \u2190 measure_union disjoint_sdiff_left (h i), Set.union_comm]\n      exact measure_mono (diff_subset_iff.1 <| subset.refl _)\n  \u00b7 exact hd.mono_comp _ fun _ _ => diff_subset_diff_right\n#align measure_theory.measure_Inter_eq_infi MeasureTheory.measure_inter\u1d62_eq_inf\u1d62\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\u1d62 [SemilatticeSup \u03b9] [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (hm : Monotone s) :\n    Tendsto (\u03bc \u2218 s) atTop (\ud835\udcdd (\u03bc (\u22c3 n, s n))) :=\n  by\n  rw [measure_Union_eq_supr (directed_of_sup hm)]\n  exact tendsto_atTop_sup\u1d62 fun n m hnm => measure_mono <| hm hnm\n#align measure_theory.tendsto_measure_Union MeasureTheory.tendsto_measure_union\u1d62\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\u1d62 [Countable \u03b9] [SemilatticeSup \u03b9] {s : \u03b9 \u2192 Set \u03b1}\n    (hs : \u2200 n, MeasurableSet (s n)) (hm : Antitone s) (hf : \u2203 i, \u03bc (s i) \u2260 \u221e) :\n    Tendsto (\u03bc \u2218 s) atTop (\ud835\udcdd (\u03bc (\u22c2 n, s n))) :=\n  by\n  rw [measure_Inter_eq_infi hs (directed_of_sup hm) hf]\n  exact tendsto_atTop_inf\u1d62 fun n m hnm => measure_mono <| hm hnm\n#align measure_theory.tendsto_measure_Inter MeasureTheory.tendsto_measure_inter\u1d62\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 {\u03b9 : Type _} [LinearOrder \u03b9] [TopologicalSpace \u03b9]\n    [OrderTopology \u03b9] [DenselyOrdered \u03b9] [TopologicalSpace.FirstCountableTopology \u03b9] {s : \u03b9 \u2192 Set \u03b1}\n    {a : \u03b9} (hs : \u2200 r > a, MeasurableSet (s r)) (hm : \u2200 i j, a < i \u2192 i \u2264 j \u2192 s i \u2286 s j)\n    (hf : \u2203 r > a, \u03bc (s r) \u2260 \u221e) : Tendsto (\u03bc \u2218 s) (\ud835\udcdd[Ioi a] a) (\ud835\udcdd (\u03bc (\u22c2 r > a, s r))) :=\n  by\n  refine' tendsto_order.2 \u27e8fun l hl => _, fun L hL => _\u27e9\n  \u00b7\n    filter_upwards [self_mem_nhdsWithin]with r hr using hl.trans_le\n        (measure_mono (bInter_subset_of_mem hr))\n  obtain \u27e8u, u_anti, u_pos, u_lim\u27e9 :\n    \u2203 u : \u2115 \u2192 \u03b9, StrictAnti u \u2227 (\u2200 n : \u2115, a < u n) \u2227 tendsto u at_top (\ud835\udcdd a) :=\n    by\n    rcases hf with \u27e8r, ar, hr\u27e9\n    rcases exists_seq_strictAnti_tendsto' ar with \u27e8w, w_anti, w_mem, w_lim\u27e9\n    exact \u27e8w, w_anti, fun n => (w_mem n).1, w_lim\u27e9\n  have A : tendsto (\u03bc \u2218 s \u2218 u) at_top (\ud835\udcdd (\u03bc (\u22c2 n, s (u n)))) :=\n    by\n    refine' tendsto_measure_Inter (fun n => hs _ (u_pos n)) _ _\n    \u00b7 intro m n hmn\n      exact hm _ _ (u_pos n) (u_anti.antitone hmn)\n    \u00b7 rcases hf with \u27e8r, rpos, hr\u27e9\n      obtain \u27e8n, hn\u27e9 : \u2203 n : \u2115, u n < r := ((tendsto_order.1 u_lim).2 r rpos).exists\n      refine' \u27e8n, ne_of_lt (lt_of_le_of_lt _ hr.lt_top)\u27e9\n      exact measure_mono (hm _ _ (u_pos n) hn.le)\n  have B : (\u22c2 n, s (u n)) = \u22c2 r > a, s r :=\n    by\n    apply subset.antisymm\n    \u00b7 simp only [subset_Inter_iff, gt_iff_lt]\n      intro r rpos\n      obtain \u27e8n, hn\u27e9 : \u2203 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    \u00b7 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 \u27e8n, hn\u27e9 : \u2203 n, \u03bc (s (u n)) < L := ((tendsto_order.1 A).2 _ hL).exists\n  have : Ioc a (u n) \u2208 \ud835\udcdd[>] a := Ioc_mem_nhdsWithin_Ioi \u27e8le_rfl, u_pos n\u27e9\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\u1d62) is a sequence of sets such\nthat `\u2211 \u03bc s\u1d62` is finite, then the limit superior of the `s\u1d62` is a null set. -/\ntheorem measure_limsup_eq_zero {s : \u2115 \u2192 Set \u03b1} (hs : (\u2211' i, \u03bc (s i)) \u2260 \u221e) :\n    \u03bc (limsup s atTop) = 0 :=\n  by\n  -- First we replace the sequence `s\u2099` with a sequence of measurable sets `t\u2099 \u2287 s\u2099` of the same\n  -- measure.\n  set t : \u2115 \u2192 Set \u03b1 := fun n => to_measurable \u03bc (s n)\n  have ht : (\u2211' i, \u03bc (t i)) \u2260 \u221e := by simpa only [t, measure_to_measurable] using hs\n  suffices \u03bc (limsup t at_top) = 0\n    by\n    have A : s \u2264 t := fun n => subset_to_measurable \u03bc (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\u1d62_eq_inter\u1d62, Set.sup\u1d62_eq_union\u1d62, \u2190\n    nonpos_iff_eq_zero]\n  -- Finally, we estimate `\u03bc (\u22c3 i, t (i + n))` by `\u2211 i', \u03bc (t (i + n))`\n  refine'\n    le_of_tendsto_of_tendsto'\n      (tendsto_measure_Inter\n        (fun i => MeasurableSet.union\u1d62 fun b => measurable_set_to_measurable _ _) _\n        \u27e80, ne_top_of_le_ne_top ht (measure_Union_le t)\u27e9)\n      (ENNReal.tendsto_sum_nat_add (\u03bc \u2218 t) ht) fun n => measure_Union_le _\n  intro n m hnm x\n  simp only [Set.mem_union\u1d62]\n  exact fun \u27e8i, hi\u27e9 => \u27e8i + (m - n), by simpa only [add_assoc, tsub_add_cancel_of_le hnm] using hi\u27e9\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 : \u2115 \u2192 Set \u03b1} (h : (\u2211' i, \u03bc (s i)) \u2260 \u22a4) : \u03bc (liminf s atTop) = 0 :=\n  by\n  rw [\u2190 le_zero_iff]\n  have : liminf s at_top \u2264 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 (\u03bc.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 : \u2115 \u2192 Set \u03b1) {t : Set \u03b1}\n    (h : \u2200 n, s n =\u1d50[\u03bc] t) :-- Need `@` below because of diamond; see gh issue #16932\n        @limsup\n        (Set \u03b1) \u2115 _ s atTop =\u1d50[\u03bc]\n      t :=\n  by\n  simp_rw [ae_eq_set] at h\u22a2\n  constructor\n  \u00b7 rw [at_top.limsup_sdiff s t]\n    apply measure_limsup_eq_zero\n    simp [h]\n  \u00b7 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 : \u2115 \u2192 Set \u03b1) {t : Set \u03b1}\n    (h : \u2200 n, s n =\u1d50[\u03bc] t) :-- Need `@` below because of diamond; see gh issue #16932\n        @liminf\n        (Set \u03b1) \u2115 _ s atTop =\u1d50[\u03bc]\n      t :=\n  by\n  simp_rw [ae_eq_set] at h\u22a2\n  constructor\n  \u00b7 rw [at_top.liminf_sdiff s t]\n    apply measure_liminf_eq_zero\n    simp [h]\n  \u00b7 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 : \u03b2} {t : Set \u03b2} {s : Set \u03b1} :\n    \u03bc (if x \u2208 t then s else \u2205) = indicator t (fun _ => \u03bc 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 \u03b1] {s t : Set \u03b1}\n\ninclude ms\n\n/-- Obtain a measure by giving an outer measure where all sets in the \u03c3-algebra are\n  Carath\u00e9odory measurable. -/\ndef OuterMeasure.toMeasure (m : OuterMeasure \u03b1) (h : ms \u2264 m.caratheodory) : Measure \u03b1 :=\n  Measure.ofMeasurable (fun s _ => m s) m.Empty fun f hf hd =>\n    m.union\u1d62_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 (\u03bc : Measure \u03b1) : ms \u2264 \u03bc.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 \u03b1) (h : ms \u2264 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 \u03b1) (h : ms \u2264 m.caratheodory) {s : Set \u03b1}\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 \u03b1) (h : ms \u2264 m.caratheodory) (s : Set \u03b1) :\n    m s \u2264 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\u2080 (m : OuterMeasure \u03b1) (h : ms \u2264 m.caratheodory) {s : Set \u03b1}\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 \u27e8t, hts, htm, heq\u27e9\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    _ \u2264 m s := m.mono hts\n    \n#align measure_theory.to_measure_apply\u2080 MeasureTheory.toMeasure_apply\u2080\n\n@[simp]\ntheorem toOuterMeasure_toMeasure {\u03bc : Measure \u03b1} :\n    \u03bc.toOuterMeasure.toMeasure (le_toOuterMeasure_caratheodory _) = \u03bc :=\n  Measure.ext fun s => \u03bc.toOuterMeasure.trim_eq\n#align measure_theory.to_outer_measure_to_measure MeasureTheory.toOuterMeasure_toMeasure\n\n@[simp]\ntheorem boundedBy_measure (\u03bc : Measure \u03b1) : OuterMeasure.boundedBy \u03bc = \u03bc.toOuterMeasure :=\n  \u03bc.toOuterMeasure.boundedBy_eq_self\n#align measure_theory.bounded_by_measure MeasureTheory.boundedBy_measure\n\nend OuterMeasure\n\nvariable {m0 : MeasurableSpace \u03b1} [MeasurableSpace \u03b2] [MeasurableSpace \u03b3]\n\nvariable {\u03bc \u03bc\u2081 \u03bc\u2082 \u03bc\u2083 \u03bd \u03bd' \u03bd\u2081 \u03bd\u2082 : Measure \u03b1} {s s' t : Set \u03b1}\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 `\u03bc (t \u2229 s) = \u03bc (u \u2229 s)`. -/\ntheorem measure_inter_eq_of_measure_eq {s t u : Set \u03b1} (hs : MeasurableSet s) (h : \u03bc t = \u03bc u)\n    (htu : t \u2286 u) (ht_ne_top : \u03bc t \u2260 \u221e) : \u03bc (t \u2229 s) = \u03bc (u \u2229 s) :=\n  by\n  rw [h] at ht_ne_top\n  refine' le_antisymm (measure_mono (inter_subset_inter_left _ htu)) _\n  have A : \u03bc (u \u2229 s) + \u03bc (u \\ s) \u2264 \u03bc (t \u2229 s) + \u03bc (u \\ s) :=\n    calc\n      \u03bc (u \u2229 s) + \u03bc (u \\ s) = \u03bc u := measure_inter_add_diff _ hs\n      _ = \u03bc t := h.symm\n      _ = \u03bc (t \u2229 s) + \u03bc (t \\ s) := (measure_inter_add_diff _ hs).symm\n      _ \u2264 \u03bc (t \u2229 s) + \u03bc (u \\ s) :=\n        add_le_add le_rfl (measure_mono (diff_subset_diff htu subset.rfl))\n      \n  have B : \u03bc (u \\ s) \u2260 \u221e := (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 \u03bc t` of `t` (which has the same measure as `t`)\nsatisfies, for any measurable set `s`, the equality `\u03bc (to_measurable \u03bc t \u2229 s) = \u03bc (u \u2229 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 \u03b1} (hs : MeasurableSet s) (ht : \u03bc t \u2260 \u221e) :\n    \u03bc (toMeasurable \u03bc t \u2229 s) = \u03bc (t \u2229 s) :=\n  (measure_inter_eq_of_measure_eq hs (measure_toMeasurable t).symm (subset_toMeasurable \u03bc t)\n      ht).symm\n#align measure_theory.measure.measure_to_measurable_inter MeasureTheory.Measure.measure_toMeasurable_inter\n\n/-! ### The `\u211d\u22650\u221e`-module of measures -/\n\n\ninstance [MeasurableSpace \u03b1] : Zero (Measure \u03b1) :=\n  \u27e8{  toOuterMeasure := 0\n      m_union\u1d62 := fun f hf hd => tsum_zero.symm\n      trimmed := OuterMeasure.trim_zero }\u27e9\n\n@[simp]\ntheorem zero_toOuterMeasure {m : MeasurableSpace \u03b1} : (0 : Measure \u03b1).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 \u03b1} : \u21d1(0 : Measure \u03b1) = 0 :=\n  rfl\n#align measure_theory.measure.coe_zero MeasureTheory.Measure.coe_zero\n\ninstance [IsEmpty \u03b1] {m : MeasurableSpace \u03b1} : Subsingleton (Measure \u03b1) :=\n  \u27e8fun \u03bc \u03bd => by\n    ext1 s hs\n    simp only [eq_empty_of_is_empty s, measure_empty]\u27e9\n\ntheorem eq_zero_of_isEmpty [IsEmpty \u03b1] {m : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) : \u03bc = 0 :=\n  Subsingleton.elim \u03bc 0\n#align measure_theory.measure.eq_zero_of_is_empty MeasureTheory.Measure.eq_zero_of_isEmpty\n\ninstance [MeasurableSpace \u03b1] : Inhabited (Measure \u03b1) :=\n  \u27e80\u27e9\n\ninstance [MeasurableSpace \u03b1] : Add (Measure \u03b1) :=\n  \u27e8fun \u03bc\u2081 \u03bc\u2082 =>\n    { toOuterMeasure := \u03bc\u2081.toOuterMeasure + \u03bc\u2082.toOuterMeasure\n      m_union\u1d62 := fun s hs hd =>\n        show \u03bc\u2081 (\u22c3 i, s i) + \u03bc\u2082 (\u22c3 i, s i) = \u2211' i, \u03bc\u2081 (s i) + \u03bc\u2082 (s i) by\n          rw [ENNReal.tsum_add, measure_Union hd hs, measure_Union hd hs]\n      trimmed := by rw [outer_measure.trim_add, \u03bc\u2081.trimmed, \u03bc\u2082.trimmed] }\u27e9\n\n@[simp]\ntheorem add_toOuterMeasure {m : MeasurableSpace \u03b1} (\u03bc\u2081 \u03bc\u2082 : Measure \u03b1) :\n    (\u03bc\u2081 + \u03bc\u2082).toOuterMeasure = \u03bc\u2081.toOuterMeasure + \u03bc\u2082.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 \u03b1} (\u03bc\u2081 \u03bc\u2082 : Measure \u03b1) : \u21d1(\u03bc\u2081 + \u03bc\u2082) = \u03bc\u2081 + \u03bc\u2082 :=\n  rfl\n#align measure_theory.measure.coe_add MeasureTheory.Measure.coe_add\n\ntheorem add_apply {m : MeasurableSpace \u03b1} (\u03bc\u2081 \u03bc\u2082 : Measure \u03b1) (s : Set \u03b1) :\n    (\u03bc\u2081 + \u03bc\u2082) s = \u03bc\u2081 s + \u03bc\u2082 s :=\n  rfl\n#align measure_theory.measure.add_apply MeasureTheory.Measure.add_apply\n\nsection SMul\n\nvariable [SMul R \u211d\u22650\u221e] [IsScalarTower R \u211d\u22650\u221e \u211d\u22650\u221e]\n\nvariable [SMul R' \u211d\u22650\u221e] [IsScalarTower R' \u211d\u22650\u221e \u211d\u22650\u221e]\n\ninstance [MeasurableSpace \u03b1] : SMul R (Measure \u03b1) :=\n  \u27e8fun c \u03bc =>\n    { toOuterMeasure := c \u2022 \u03bc.toOuterMeasure\n      m_union\u1d62 := fun s hs hd =>\n        by\n        rw [\u2190 smul_one_smul \u211d\u22650\u221e c (_ : outer_measure \u03b1)]\n        dsimp\n        simp_rw [measure_Union hd hs, ENNReal.tsum_mul_left]\n      trimmed := by rw [outer_measure.trim_smul, \u03bc.trimmed] }\u27e9\n\n@[simp]\ntheorem smul_toOuterMeasure {m : MeasurableSpace \u03b1} (c : R) (\u03bc : Measure \u03b1) :\n    (c \u2022 \u03bc).toOuterMeasure = c \u2022 \u03bc.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 \u03b1} (c : R) (\u03bc : Measure \u03b1) : \u21d1(c \u2022 \u03bc) = c \u2022 \u03bc :=\n  rfl\n#align measure_theory.measure.coe_smul MeasureTheory.Measure.coe_smul\n\n@[simp]\ntheorem smul_apply {m : MeasurableSpace \u03b1} (c : R) (\u03bc : Measure \u03b1) (s : Set \u03b1) :\n    (c \u2022 \u03bc) s = c \u2022 \u03bc s :=\n  rfl\n#align measure_theory.measure.smul_apply MeasureTheory.Measure.smul_apply\n\ninstance [SMulCommClass R R' \u211d\u22650\u221e] [MeasurableSpace \u03b1] : SMulCommClass R R' (Measure \u03b1) :=\n  \u27e8fun _ _ _ => ext fun _ _ => smul_comm _ _ _\u27e9\n\ninstance [SMul R R'] [IsScalarTower R R' \u211d\u22650\u221e] [MeasurableSpace \u03b1] :\n    IsScalarTower R R' (Measure \u03b1) :=\n  \u27e8fun _ _ _ => ext fun _ _ => smul_assoc _ _ _\u27e9\n\ninstance [SMul R\u1d50\u1d52\u1d56 \u211d\u22650\u221e] [IsCentralScalar R \u211d\u22650\u221e] [MeasurableSpace \u03b1] :\n    IsCentralScalar R (Measure \u03b1) :=\n  \u27e8fun _ _ => ext fun _ _ => op_smul_eq_smul _ _\u27e9\n\nend SMul\n\ninstance [Monoid R] [MulAction R \u211d\u22650\u221e] [IsScalarTower R \u211d\u22650\u221e \u211d\u22650\u221e] [MeasurableSpace \u03b1] :\n    MulAction R (Measure \u03b1) :=\n  Injective.mulAction _ toOuterMeasure_injective smul_toOuterMeasure\n\ninstance addCommMonoid [MeasurableSpace \u03b1] : AddCommMonoid (Measure \u03b1) :=\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 \u03b1} : Measure \u03b1 \u2192+ Set \u03b1 \u2192 \u211d\u22650\u221e :=\n  \u27e8coeFn, coe_zero, coe_add\u27e9\n#align measure_theory.measure.coe_add_hom MeasureTheory.Measure.coeAddHom\n\n@[simp]\ntheorem coe_finset_sum {m : MeasurableSpace \u03b1} (I : Finset \u03b9) (\u03bc : \u03b9 \u2192 Measure \u03b1) :\n    \u21d1(\u2211 i in I, \u03bc i) = \u2211 i in I, \u03bc i :=\n  (@coeAddHom \u03b1 m).map_sum _ _\n#align measure_theory.measure.coe_finset_sum MeasureTheory.Measure.coe_finset_sum\n\ntheorem finset_sum_apply {m : MeasurableSpace \u03b1} (I : Finset \u03b9) (\u03bc : \u03b9 \u2192 Measure \u03b1) (s : Set \u03b1) :\n    (\u2211 i in I, \u03bc i) s = \u2211 i in I, \u03bc 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 \u211d\u22650\u221e] [IsScalarTower R \u211d\u22650\u221e \u211d\u22650\u221e] [MeasurableSpace \u03b1] :\n    DistribMulAction R (Measure \u03b1) :=\n  Injective.distribMulAction \u27e8toOuterMeasure, zero_toOuterMeasure, add_toOuterMeasure\u27e9\n    toOuterMeasure_injective smul_toOuterMeasure\n\ninstance [Semiring R] [Module R \u211d\u22650\u221e] [IsScalarTower R \u211d\u22650\u221e \u211d\u22650\u221e] [MeasurableSpace \u03b1] :\n    Module R (Measure \u03b1) :=\n  Injective.module R \u27e8toOuterMeasure, zero_toOuterMeasure, add_toOuterMeasure\u27e9\n    toOuterMeasure_injective smul_toOuterMeasure\n\n@[simp]\ntheorem coe_nNReal_smul_apply {m : MeasurableSpace \u03b1} (c : \u211d\u22650) (\u03bc : Measure \u03b1) (s : Set \u03b1) :\n    (c \u2022 \u03bc) s = c * \u03bc 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 : \u03b1 \u2192 Prop} {c : \u211d\u22650\u221e} (hc : c \u2260 0) :\n    (\u2200\u1d50 x \u2202c \u2022 \u03bc, p x) \u2194 \u2200\u1d50 x \u2202\u03bc, 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 \u03b1} (h : (\u03bc + \u03bd) t \u2260 \u221e) (h' : s \u2286 t)\n    (h'' : (\u03bc + \u03bd) s = (\u03bc + \u03bd) t) : \u03bc s = \u03bc t :=\n  by\n  refine' le_antisymm (measure_mono h') _\n  have : \u03bc t + \u03bd t \u2264 \u03bc s + \u03bd t :=\n    calc\n      \u03bc t + \u03bd t = \u03bc s + \u03bd s := h''.symm\n      _ \u2264 \u03bc s + \u03bd 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 \u03b1} (h : (\u03bc + \u03bd) t \u2260 \u221e) (h' : s \u2286 t)\n    (h'' : (\u03bc + \u03bd) s = (\u03bc + \u03bd) t) : \u03bd s = \u03bd 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 \u03b1} (hs : MeasurableSet s)\n    (ht : (\u03bc + \u03bd) t \u2260 \u221e) : \u03bc (toMeasurable (\u03bc + \u03bd) t \u2229 s) = \u03bc (t \u2229 s) :=\n  by\n  refine' (measure_inter_eq_of_measure_eq hs _ (subset_to_measurable _ _) _).symm\n  \u00b7 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  \u00b7 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 \u03b1} (hs : MeasurableSet s)\n    (ht : (\u03bc + \u03bd) t \u2260 \u221e) : \u03bd (toMeasurable (\u03bc + \u03bd) t \u2229 s) = \u03bd (t \u2229 s) :=\n  by\n  rw [add_comm] at ht\u22a2\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 `\u03bc \u2264 \u03bd`, we may simply `intros s hs` instead of rewriting followed\nby `intros s hs`. -/\ninstance [MeasurableSpace \u03b1] : PartialOrder (Measure \u03b1)\n    where\n  le m\u2081 m\u2082 := \u2200 s, MeasurableSet s \u2192 m\u2081 s \u2264 m\u2082 s\n  le_refl m s hs := le_rfl\n  le_trans m\u2081 m\u2082 m\u2083 h\u2081 h\u2082 s hs := le_trans (h\u2081 s hs) (h\u2082 s hs)\n  le_antisymm m\u2081 m\u2082 h\u2081 h\u2082 := ext fun s hs => le_antisymm (h\u2081 s hs) (h\u2082 s hs)\n\ntheorem le_iff : \u03bc\u2081 \u2264 \u03bc\u2082 \u2194 \u2200 s, MeasurableSet s \u2192 \u03bc\u2081 s \u2264 \u03bc\u2082 s :=\n  Iff.rfl\n#align measure_theory.measure.le_iff MeasureTheory.Measure.le_iff\n\ntheorem toOuterMeasure_le : \u03bc\u2081.toOuterMeasure \u2264 \u03bc\u2082.toOuterMeasure \u2194 \u03bc\u2081 \u2264 \u03bc\u2082 := by\n  rw [\u2190 \u03bc\u2082.trimmed, outer_measure.le_trim_iff] <;> rfl\n#align measure_theory.measure.to_outer_measure_le MeasureTheory.Measure.toOuterMeasure_le\n\ntheorem le_iff' : \u03bc\u2081 \u2264 \u03bc\u2082 \u2194 \u2200 s, \u03bc\u2081 s \u2264 \u03bc\u2082 s :=\n  toOuterMeasure_le.symm\n#align measure_theory.measure.le_iff' MeasureTheory.Measure.le_iff'\n\ntheorem lt_iff : \u03bc < \u03bd \u2194 \u03bc \u2264 \u03bd \u2227 \u2203 s, MeasurableSet s \u2227 \u03bc s < \u03bd 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' : \u03bc < \u03bd \u2194 \u03bc \u2264 \u03bd \u2227 \u2203 s, \u03bc s < \u03bd 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 \u03b1] :\n    CovariantClass (Measure \u03b1) (Measure \u03b1) (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7) :=\n  \u27e8fun \u03bd \u03bc\u2081 \u03bc\u2082 h\u03bc s hs => add_le_add_left (h\u03bc s hs) _\u27e9\n#align measure_theory.measure.covariant_add_le MeasureTheory.Measure.covariant_add_le\n\nprotected theorem le_add_left (h : \u03bc \u2264 \u03bd) : \u03bc \u2264 \u03bd' + \u03bd := 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 : \u03bc \u2264 \u03bd) : \u03bc \u2264 \u03bd + \u03bd' := 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 \u03b1)}\n\ntheorem inf\u209b_caratheodory (s : Set \u03b1) (hs : MeasurableSet s) :\n    measurable_set[(inf\u209b (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\u1d62_iff, ball_image_iff, coe_to_outer_measure,\n    measure_eq_infi t]\n  intro \u03bc h\u03bc u htu hu\n  have hm : \u2200 {s t}, s \u2286 t \u2192 outer_measure.Inf_gen (to_outer_measure '' m) s \u2264 \u03bc t :=\n    by\n    intro s t hst\n    rw [outer_measure.Inf_gen_def]\n    refine' inf\u1d62_le_of_le \u03bc.to_outer_measure (inf\u1d62_le_of_le (mem_image_of_mem _ h\u03bc) _)\n    rw [to_outer_measure_apply]\n    refine' measure_mono hst\n  rw [\u2190 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\u209b_caratheodory\n\ninstance [MeasurableSpace \u03b1] : InfSet (Measure \u03b1) :=\n  \u27e8fun m => (inf\u209b (toOuterMeasure '' m)).toMeasure <| inf\u209b_caratheodory\u27e9\n\ntheorem inf\u209b_apply (hs : MeasurableSet s) : inf\u209b m s = inf\u209b (toOuterMeasure '' m) s :=\n  toMeasure_apply _ _ hs\n#align measure_theory.measure.Inf_apply MeasureTheory.Measure.inf\u209b_apply\n\nprivate theorem measure_Inf_le (h : \u03bc \u2208 m) : inf\u209b m \u2264 \u03bc :=\n  have : inf\u209b (toOuterMeasure '' m) \u2264 \u03bc.toOuterMeasure := inf\u209b_le (mem_image_of_mem _ h)\n  fun s hs => by rw [inf\u209b_apply hs, \u2190 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 : \u2200 \u03bc' \u2208 m, \u03bc \u2264 \u03bc') : \u03bc \u2264 inf\u209b m :=\n  have : \u03bc.toOuterMeasure \u2264 inf\u209b (toOuterMeasure '' m) :=\n    le_inf\u209b <| ball_image_of_ball fun \u03bc h\u03bc => toOuterMeasure_le.2 <| h _ h\u03bc\n  fun s hs => by rw [inf\u209b_apply hs, \u2190 to_outer_measure_apply] <;> exact this s\n#align measure_theory.measure.measure_le_Inf measure_theory.measure.measure_le_Inf\n\ninstance [MeasurableSpace \u03b1] : CompleteSemilatticeInf (Measure \u03b1) :=\n  { (by infer_instance : PartialOrder (Measure \u03b1)),\n    (by infer_instance :\n      InfSet (Measure \u03b1)) with\n    inf_le := fun s a => measure_inf\u209b_le\n    le_inf := fun s a => measure_le_inf\u209b }\n\ninstance [MeasurableSpace \u03b1] : CompleteLattice (Measure \u03b1) :=\n  {/- Adding an explicit `top` makes `leanchecker` fail, see lean#364, disable for now\n      \n        top := (\u22a4 : outer_measure \u03b1).to_measure (by rw [outer_measure.top_caratheodory]; exact le_top),\n        le_top := \u03bb a s hs,\n          by cases s.eq_empty_or_nonempty with h  h;\n            simp [h, to_measure_apply \u22a4 _ hs, outer_measure.top_apply],\n      -/\n      completeLatticeOfCompleteSemilatticeInf\n      (Measure \u03b1) with\n    bot := 0\n    bot_le := fun a s hs => bot_le }\n\nend Inf\n\n@[simp]\ntheorem top_add : \u22a4 + \u03bc = \u22a4 :=\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 : \u03bc + \u22a4 = \u22a4 :=\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 \u03b1} (\u03bc : Measure \u03b1) : 0 \u2264 \u03bc :=\n  bot_le\n#align measure_theory.measure.zero_le MeasureTheory.Measure.zero_le\n\ntheorem nonpos_iff_eq_zero' : \u03bc \u2264 0 \u2194 \u03bc = 0 :=\n  \u03bc.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 : \u03bc univ = 0 \u2194 \u03bc = 0 :=\n  \u27e8fun h => bot_unique fun s hs => trans_rel_left (\u00b7 \u2264 \u00b7) (measure_mono (subset_univ s)) h, fun h =>\n    h.symm \u25b8 rfl\u27e9\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 `\u03bc` every measurable\nset is caratheodory-measurable w.r.t. `f \u03bc` to a linear map between `measure` spaces. -/\ndef liftLinear {m0 : MeasurableSpace \u03b1} (f : OuterMeasure \u03b1 \u2192\u2097[\u211d\u22650\u221e] OuterMeasure \u03b2)\n    (hf : \u2200 \u03bc : Measure \u03b1, \u2039_\u203a \u2264 (f \u03bc.toOuterMeasure).caratheodory) : Measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] Measure \u03b2\n    where\n  toFun \u03bc := (f \u03bc.toOuterMeasure).toMeasure (hf \u03bc)\n  map_add' \u03bc\u2081 \u03bc\u2082 := ext fun s hs => by simp [hs]\n  map_smul' c \u03bc := 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 \u03b1 \u2192\u2097[\u211d\u22650\u221e] OuterMeasure \u03b2} (hf) {s : Set \u03b2}\n    (hs : MeasurableSet s) : liftLinear f hf \u03bc s = f \u03bc.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 \u03b1 \u2192\u2097[\u211d\u22650\u221e] OuterMeasure \u03b2} (hf) (s : Set \u03b2) :\n    f \u03bc.toOuterMeasure s \u2264 liftLinear f hf \u03bc 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\u2097 [MeasurableSpace \u03b1] (f : \u03b1 \u2192 \u03b2) : Measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] Measure \u03b2 :=\n  if hf : Measurable f then\n    liftLinear (OuterMeasure.map f) fun \u03bc s hs t =>\n      le_toOuterMeasure_caratheodory \u03bc _ (hf hs) (f \u207b\u00b9' t)\n  else 0\n#align measure_theory.measure.map\u2097 MeasureTheory.Measure.map\u2097\n\ntheorem map\u2097_congr {f g : \u03b1 \u2192 \u03b2} (hf : Measurable f) (hg : Measurable g) (h : f =\u1d50[\u03bc] g) :\n    map\u2097 f \u03bc = map\u2097 g \u03bc := by\n  ext1 s hs\n  simpa only [map\u2097, 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\u2097_congr MeasureTheory.Measure.map\u2097_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 \u03b1] (f : \u03b1 \u2192 \u03b2) (\u03bc : Measure \u03b1) : Measure \u03b2 :=\n  if hf : AeMeasurable f \u03bc then map\u2097 (hf.mk f) \u03bc else 0\n#align measure_theory.measure.map MeasureTheory.Measure.map\n\ninclude m0\n\ntheorem map\u2097_mk_apply_of_aeMeasurable {f : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) :\n    map\u2097 (hf.mk f) \u03bc = map f \u03bc := by simp [map, hf]\n#align measure_theory.measure.map\u2097_mk_apply_of_ae_measurable MeasureTheory.Measure.map\u2097_mk_apply_of_aeMeasurable\n\ntheorem map\u2097_apply_of_measurable {f : \u03b1 \u2192 \u03b2} (hf : Measurable f) (\u03bc : Measure \u03b1) :\n    map\u2097 f \u03bc = map f \u03bc :=\n  by\n  simp only [\u2190 map\u2097_mk_apply_of_ae_measurable hf.ae_measurable]\n  exact map\u2097_congr hf hf.ae_measurable.measurable_mk hf.ae_measurable.ae_eq_mk\n#align measure_theory.measure.map\u2097_apply_of_measurable MeasureTheory.Measure.map\u2097_apply_of_measurable\n\n@[simp]\ntheorem map_add (\u03bc \u03bd : Measure \u03b1) {f : \u03b1 \u2192 \u03b2} (hf : Measurable f) :\n    (\u03bc + \u03bd).map f = \u03bc.map f + \u03bd.map f := by simp [\u2190 map\u2097_apply_of_measurable hf]\n#align measure_theory.measure.map_add MeasureTheory.Measure.map_add\n\n@[simp]\ntheorem map_zero (f : \u03b1 \u2192 \u03b2) : (0 : Measure \u03b1).map f = 0 := by\n  by_cases hf : AeMeasurable f (0 : Measure \u03b1) <;> simp [map, hf]\n#align measure_theory.measure.map_zero MeasureTheory.Measure.map_zero\n\ntheorem map_of_not_aeMeasurable {f : \u03b1 \u2192 \u03b2} {\u03bc : Measure \u03b1} (hf : \u00acAeMeasurable f \u03bc) :\n    \u03bc.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 : \u03b1 \u2192 \u03b2} (h : f =\u1d50[\u03bc] g) : Measure.map f \u03bc = Measure.map g \u03bc :=\n  by\n  by_cases hf : AeMeasurable f \u03bc\n  \u00b7 have hg : AeMeasurable g \u03bc := hf.congr h\n    simp only [\u2190 map\u2097_mk_apply_of_ae_measurable hf, \u2190 map\u2097_mk_apply_of_ae_measurable hg]\n    exact\n      map\u2097_congr hf.measurable_mk hg.measurable_mk (hf.ae_eq_mk.symm.trans (h.trans hg.ae_eq_mk))\n  \u00b7 have hg : \u00acAeMeasurable g \u03bc := by simpa [\u2190 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 : \u211d\u22650\u221e) (\u03bc : Measure \u03b1) (f : \u03b1 \u2192 \u03b2) : (c \u2022 \u03bc).map f = c \u2022 \u03bc.map f :=\n  by\n  rcases eq_or_ne c 0 with (rfl | hc); \u00b7 simp\n  by_cases hf : AeMeasurable f \u03bc\n  \u00b7 have hfc : AeMeasurable f (c \u2022 \u03bc) :=\n      \u27e8hf.mk f, hf.measurable_mk, (ae_smul_measure_iff hc).2 hf.ae_eq_mk\u27e9\n    simp only [\u2190 map\u2097_mk_apply_of_ae_measurable hf, \u2190 map\u2097_mk_apply_of_ae_measurable hfc,\n      LinearMap.map_smul\u209b\u2097, RingHom.id_apply]\n    congr 1\n    apply map\u2097_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  \u00b7 have hfc : \u00acAeMeasurable f (c \u2022 \u03bc) := by\n      intro hfc\n      exact hf \u27e8hfc.mk f, hfc.measurable_mk, (ae_smul_measure_iff hc).1 hfc.ae_eq_mk\u27e9\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 : \u211d\u22650) (\u03bc : Measure \u03b1) (f : \u03b1 \u2192 \u03b2) :\n    (c \u2022 \u03bc).map f = c \u2022 \u03bc.map f :=\n  \u03bc.map_smul (c : \u211d\u22650\u221e) 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 : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) {s : Set \u03b2}\n    (hs : MeasurableSet s) : \u03bc.map f s = \u03bc (f \u207b\u00b9' s) := by\n  simpa only [map\u2097, hf.measurable_mk, hs, dif_pos, lift_linear_apply, outer_measure.map_apply,\n    coe_to_outer_measure, \u2190 map\u2097_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 : \u03b1 \u2192 \u03b2} (hf : Measurable f) {s : Set \u03b2} (hs : MeasurableSet s) :\n    \u03bc.map f s = \u03bc (f \u207b\u00b9' 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 : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) :\n    (\u03bc.map f).toOuterMeasure = (OuterMeasure.map f \u03bc.toOuterMeasure).trim :=\n  by\n  rw [\u2190 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 \u03bc = \u03bc :=\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) \u03bc = \u03bc :=\n  map_id\n#align measure_theory.measure.map_id' MeasureTheory.Measure.map_id'\n\ntheorem map_map {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : Measurable g) (hf : Measurable f) :\n    (\u03bc.map f).map g = \u03bc.map (g \u2218 f) :=\n  ext fun s hs => by simp [hf, hg, hs, hg hs, hg.comp hf, \u2190 preimage_comp]\n#align measure_theory.measure.map_map MeasureTheory.Measure.map_map\n\n@[mono]\ntheorem map_mono {f : \u03b1 \u2192 \u03b2} (h : \u03bc \u2264 \u03bd) (hf : Measurable f) : \u03bc.map f \u2264 \u03bd.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 \u03bc s` from below.\n  See also `measurable_equiv.map_apply`. -/\ntheorem le_map_apply {f : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) (s : Set \u03b2) : \u03bc (f \u207b\u00b9' s) \u2264 \u03bc.map f s :=\n  calc\n    \u03bc (f \u207b\u00b9' s) \u2264 \u03bc (f \u207b\u00b9' toMeasurable (\u03bc.map f) s) :=\n      measure_mono <| preimage_mono <| subset_toMeasurable _ _\n    _ = \u03bc.map f (toMeasurable (\u03bc.map f) s) :=\n      (map_apply_of_aeMeasurable hf <| measurableSet_toMeasurable _ _).symm\n    _ = \u03bc.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 \u03bc s = 0` implies that `\u03bc (f \u207b\u00b9' s) = 0`. -/\ntheorem preimage_null_of_map_null {f : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) {s : Set \u03b2}\n    (hs : \u03bc.map f s = 0) : \u03bc (f \u207b\u00b9' 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 : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) : Tendsto f \u03bc.ae (\u03bc.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\u2097 f \u03bc s = \u03bc (f '' s)`.\n\nIf the linearity is not needed, please use `comap` instead, which works for a larger class of\nfunctions. -/\ndef comap\u2097 [MeasurableSpace \u03b1] (f : \u03b1 \u2192 \u03b2) : Measure \u03b2 \u2192\u2097[\u211d\u22650\u221e] Measure \u03b1 :=\n  if hf : Injective f \u2227 \u2200 s, MeasurableSet s \u2192 MeasurableSet (f '' s) then\n    liftLinear (OuterMeasure.comap f) fun \u03bc 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\u2097 MeasureTheory.Measure.comap\u2097\n\ntheorem comap\u2097_apply {\u03b2} [MeasurableSpace \u03b1] {m\u03b2 : MeasurableSpace \u03b2} (f : \u03b1 \u2192 \u03b2)\n    (hfi : Injective f) (hf : \u2200 s, MeasurableSet s \u2192 MeasurableSet (f '' s)) (\u03bc : Measure \u03b2)\n    (hs : MeasurableSet s) : comap\u2097 f \u03bc s = \u03bc (f '' s) :=\n  by\n  rw [comap\u2097, dif_pos, lift_linear_apply _ hs, outer_measure.comap_apply, coe_to_outer_measure]\n  exact \u27e8hfi, hf\u27e9\n#align measure_theory.measure.comap\u2097_apply MeasureTheory.Measure.comap\u2097_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 \u03bc s = \u03bc (f '' s)`. -/\ndef comap [MeasurableSpace \u03b1] (f : \u03b1 \u2192 \u03b2) (\u03bc : Measure \u03b2) : Measure \u03b1 :=\n  if hf : Injective f \u2227 \u2200 s, MeasurableSet s \u2192 NullMeasurableSet (f '' s) \u03bc then\n    (OuterMeasure.comap f \u03bc.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\u2080 _ (hf.2 s hs)).symm\n  else 0\n#align measure_theory.measure.comap MeasureTheory.Measure.comap\n\ntheorem comap_apply\u2080 [MeasurableSpace \u03b1] (f : \u03b1 \u2192 \u03b2) (\u03bc : Measure \u03b2) (hfi : Injective f)\n    (hf : \u2200 s, MeasurableSet s \u2192 NullMeasurableSet (f '' s) \u03bc)\n    (hs : NullMeasurableSet s (comap f \u03bc)) : comap f \u03bc s = \u03bc (f '' s) :=\n  by\n  rw [comap, dif_pos (And.intro hfi hf)] at hs\u22a2\n  rw [to_measure_apply\u2080 _ _ hs, outer_measure.comap_apply, coe_to_outer_measure]\n#align measure_theory.measure.comap_apply\u2080 MeasureTheory.Measure.comap_apply\u2080\n\ntheorem le_comap_apply {\u03b2} [MeasurableSpace \u03b1] {m\u03b2 : MeasurableSpace \u03b2} (f : \u03b1 \u2192 \u03b2) (\u03bc : Measure \u03b2)\n    (hfi : Injective f) (hf : \u2200 s, MeasurableSet s \u2192 NullMeasurableSet (f '' s) \u03bc) (s : Set \u03b1) :\n    \u03bc (f '' s) \u2264 comap f \u03bc 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 {\u03b2} [MeasurableSpace \u03b1] {m\u03b2 : MeasurableSpace \u03b2} (f : \u03b1 \u2192 \u03b2) (hfi : Injective f)\n    (hf : \u2200 s, MeasurableSet s \u2192 MeasurableSet (f '' s)) (\u03bc : Measure \u03b2) (hs : MeasurableSet s) :\n    comap f \u03bc s = \u03bc (f '' s) :=\n  comap_apply\u2080 f \u03bc hfi (fun s hs => (hf s hs).NullMeasurableSet) hs.NullMeasurableSet\n#align measure_theory.measure.comap_apply MeasureTheory.Measure.comap_apply\n\ntheorem comap\u2097_eq_comap {\u03b2} [MeasurableSpace \u03b1] {m\u03b2 : MeasurableSpace \u03b2} (f : \u03b1 \u2192 \u03b2)\n    (hfi : Injective f) (hf : \u2200 s, MeasurableSet s \u2192 MeasurableSet (f '' s)) (\u03bc : Measure \u03b2)\n    (hs : MeasurableSet s) : comap\u2097 f \u03bc s = comap f \u03bc s :=\n  (comap\u2097_apply f hfi hf \u03bc hs).trans (comap_apply f hfi hf \u03bc hs).symm\n#align measure_theory.measure.comap\u2097_eq_comap MeasureTheory.Measure.comap\u2097_eq_comap\n\ntheorem measure_image_eq_zero_of_comap_eq_zero {\u03b2} [MeasurableSpace \u03b1] {m\u03b2 : MeasurableSpace \u03b2}\n    (f : \u03b1 \u2192 \u03b2) (\u03bc : Measure \u03b2) (hfi : Injective f)\n    (hf : \u2200 s, MeasurableSet s \u2192 NullMeasurableSet (f '' s) \u03bc) {s : Set \u03b1} (hs : comap f \u03bc s = 0) :\n    \u03bc (f '' s) = 0 :=\n  le_antisymm ((le_comap_apply f \u03bc 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 {\u03b2} [MeasurableSpace \u03b1] {m\u03b2 : MeasurableSpace \u03b2} (f : \u03b1 \u2192 \u03b2)\n    (\u03bc : Measure \u03b2) (hfi : Injective f) (hf : \u2200 s, MeasurableSet s \u2192 NullMeasurableSet (f '' s) \u03bc)\n    {s t : Set \u03b1} (hst : s =\u1d50[comap f \u03bc] t) : f '' s =\u1d50[\u03bc] f '' t :=\n  by\n  rw [eventually_eq, ae_iff] at hst\u22a2\n  have h_eq_\u03b1 : { a : \u03b1 | \u00acs a = t a } = s \\ t \u222a 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_\u03b2 : { a : \u03b2 | \u00ac(f '' s) a = (f '' t) a } = f '' s \\ f '' t \u222a 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 [\u2190 Set.image_diff hfi, \u2190 Set.image_diff hfi, \u2190 Set.image_union] at h_eq_\u03b2\n  rw [h_eq_\u03b2]\n  rw [h_eq_\u03b1] at hst\n  exact measure_image_eq_zero_of_comap_eq_zero f \u03bc 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 {\u03b2} [MeasurableSpace \u03b1] {m\u03b2 : MeasurableSpace \u03b2} (f : \u03b1 \u2192 \u03b2)\n    (\u03bc : Measure \u03b2) (hfi : Injective f) (hf : \u2200 s, MeasurableSet s \u2192 NullMeasurableSet (f '' s) \u03bc)\n    {s : Set \u03b1} (hs : NullMeasurableSet s (\u03bc.comap f)) : NullMeasurableSet (f '' s) \u03bc :=\n  by\n  refine' \u27e8to_measurable \u03bc (f '' to_measurable (\u03bc.comap f) s), measurable_set_to_measurable _ _, _\u27e9\n  refine' eventually_eq.trans _ (null_measurable_set.to_measurable_ae_eq _).symm\n  swap\n  \u00b7 exact hf _ (measurable_set_to_measurable _ _)\n  have h : to_measurable (comap f \u03bc) s =\u1d50[comap f \u03bc] s :=\n    @null_measurable_set.to_measurable_ae_eq _ _ (\u03bc.comap f : Measure \u03b1) s hs\n  exact ae_eq_image_of_ae_eq_comap f \u03bc hfi hf h.symm\n#align measure_theory.measure.null_measurable_set.image MeasureTheory.Measure.NullMeasurableSet.image\n\ntheorem comap_preimage {\u03b2} [MeasurableSpace \u03b1] {m\u03b2 : MeasurableSpace \u03b2} (f : \u03b1 \u2192 \u03b2) (\u03bc : Measure \u03b2)\n    {s : Set \u03b2} (hf : Injective f) (hf' : Measurable f)\n    (h : \u2200 t, MeasurableSet t \u2192 NullMeasurableSet (f '' t) \u03bc) (hs : MeasurableSet s) :\n    \u03bc.comap f (f \u207b\u00b9' s) = \u03bc (s \u2229 range f) := by\n  rw [comap_apply\u2080 _ _ 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 \u03bc)\n    (ht : MeasurableSet t) : NullMeasurableSet ((coe : s \u2192 \u03b1) '' t) \u03bc :=\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) \u03bc)\n      { t : Set s | \u2203 s' : Set \u03b1, MeasurableSet s' \u2227 coe \u207b\u00b9' s' = t } _ _ _ _ ht\n  \u00b7 rintro t' \u27e8s', hs', rfl\u27e9\n    rw [Subtype.image_preimage_coe]\n    exact hs'.null_measurable_set.inter hs\n  \u00b7 simp only [image_empty, null_measurable_set_empty]\n  \u00b7 intro t'\n    simp only [\u2190 range_diff_image Subtype.coe_injective, Subtype.range_coe_subtype, set_of_mem_eq]\n    exact hs.diff\n  \u00b7 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 \u03bc)\n    (ht : NullMeasurableSet t (\u03bc.comap Subtype.val)) : NullMeasurableSet ((coe : s \u2192 \u03b1) '' t) \u03bc :=\n  NullMeasurableSet.image coe \u03bc 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 \u03bc) (t : Set s) :\n    \u03bc ((coe : s \u2192 \u03b1) '' t) \u2264 \u03bc.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 \u03bc) {t : Set s}\n    (ht : \u03bc.comap Subtype.val t = 0) : \u03bc ((coe : s \u2192 \u03b1) '' 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 \u03b1] {p : \u03b1 \u2192 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\u2080 _ _ _ _ measurable_set.univ.null_measurable_set]\n  \u00b7 congr\n    simp only [Subtype.val_eq_coe, image_univ, Subtype.range_coe_subtype, set_of_mem_eq]\n  \u00b7 exact Subtype.coe_injective\n  \u00b7 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 \u2192 \u03b1) '' t) \u2264 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 \u2192 \u03b1) '' 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 `\u03bc` to a set `s` as an `\u211d\u22650\u221e`-linear map. -/\ndef restrict\u2097 {m0 : MeasurableSpace \u03b1} (s : Set \u03b1) : Measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] Measure \u03b1 :=\n  liftLinear (OuterMeasure.restrict s) fun \u03bc s' hs' t =>\n    by\n    suffices \u03bc (s \u2229 t) = \u03bc (s \u2229 t \u2229 s') + \u03bc ((s \u2229 t) \\ s') by\n      simpa [\u2190 Set.inter_assoc, Set.inter_comm _ s, \u2190 inter_diff_assoc]\n    exact le_to_outer_measure_caratheodory _ _ hs' _\n#align measure_theory.measure.restrict\u2097 MeasureTheory.Measure.restrict\u2097\n\n/-- Restrict a measure `\u03bc` to a set `s`. -/\ndef restrict {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) (s : Set \u03b1) : Measure \u03b1 :=\n  restrict\u2097 s \u03bc\n#align measure_theory.measure.restrict MeasureTheory.Measure.restrict\n\n@[simp]\ntheorem restrict\u2097_apply {m0 : MeasurableSpace \u03b1} (s : Set \u03b1) (\u03bc : Measure \u03b1) :\n    restrict\u2097 s \u03bc = \u03bc.restrict s :=\n  rfl\n#align measure_theory.measure.restrict\u2097_apply MeasureTheory.Measure.restrict\u2097_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    (\u03bc.restrict s).toOuterMeasure = OuterMeasure.restrict s \u03bc.toOuterMeasure := by\n  simp_rw [restrict, restrict\u2097, lift_linear, LinearMap.coe_mk, to_measure_to_outer_measure,\n    outer_measure.restrict_trim h, \u03bc.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\u2080 (ht : NullMeasurableSet t (\u03bc.restrict s)) : \u03bc.restrict s t = \u03bc (t \u2229 s) :=\n  (toMeasure_apply\u2080 _ _ ht).trans <| by\n    simp only [coe_to_outer_measure, outer_measure.restrict_apply]\n#align measure_theory.measure.restrict_apply\u2080 MeasureTheory.Measure.restrict_apply\u2080\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 \u2229 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) : \u03bc.restrict s t = \u03bc (t \u2229 s) :=\n  restrict_apply\u2080 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 \u03b1} \u2983s s' : Set \u03b1\u2984 \u2983\u03bc \u03bd : Measure \u03b1\u2984 (hs : s \u2264\u1d50[\u03bc] s')\n    (h\u03bc\u03bd : \u03bc \u2264 \u03bd) : \u03bc.restrict s \u2264 \u03bd.restrict s' := fun t ht =>\n  calc\n    \u03bc.restrict s t = \u03bc (t \u2229 s) := restrict_apply ht\n    _ \u2264 \u03bc (t \u2229 s') := (measure_mono_ae <| hs.mono fun x hx \u27e8hxt, hxs\u27e9 => \u27e8hxt, hx hxs\u27e9)\n    _ \u2264 \u03bd (t \u2229 s') := (le_iff'.1 h\u03bc\u03bd (t \u2229 s'))\n    _ = \u03bd.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 \u03b1} \u2983s s' : Set \u03b1\u2984 (hs : s \u2286 s') \u2983\u03bc \u03bd : Measure \u03b1\u2984\n    (h\u03bc\u03bd : \u03bc \u2264 \u03bd) : \u03bc.restrict s \u2264 \u03bd.restrict s' :=\n  restrict_mono' (ae_of_all _ hs) h\u03bc\u03bd\n#align measure_theory.measure.restrict_mono MeasureTheory.Measure.restrict_mono\n\ntheorem restrict_mono_ae (h : s \u2264\u1d50[\u03bc] t) : \u03bc.restrict s \u2264 \u03bc.restrict t :=\n  restrict_mono' h (le_refl \u03bc)\n#align measure_theory.measure.restrict_mono_ae MeasureTheory.Measure.restrict_mono_ae\n\ntheorem restrict_congr_set (h : s =\u1d50[\u03bc] t) : \u03bc.restrict s = \u03bc.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 \u2229 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) : \u03bc.restrict s t = \u03bc (t \u2229 s) := by\n  rw [\u2190 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\u2080' (hs : NullMeasurableSet s \u03bc) : \u03bc.restrict s t = \u03bc (t \u2229 s) := by\n  rw [\u2190 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\u2080' MeasureTheory.Measure.restrict_apply\u2080'\n\ntheorem restrict_le_self : \u03bc.restrict s \u2264 \u03bc := fun t ht =>\n  calc\n    \u03bc.restrict s t = \u03bc (t \u2229 s) := restrict_apply ht\n    _ \u2264 \u03bc t := measure_mono <| inter_subset_left t s\n    \n#align measure_theory.measure.restrict_le_self MeasureTheory.Measure.restrict_le_self\n\nvariable (\u03bc)\n\ntheorem restrict_eq_self (h : s \u2286 t) : \u03bc.restrict t s = \u03bc s :=\n  (le_iff'.1 restrict_le_self s).antisymm <|\n    calc\n      \u03bc s \u2264 \u03bc (toMeasurable (\u03bc.restrict t) s \u2229 t) :=\n        measure_mono (subset_inter (subset_toMeasurable _ _) h)\n      _ = \u03bc.restrict t s := by\n        rw [\u2190 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 \u03b1) : (\u03bc.restrict s) s = \u03bc s :=\n  restrict_eq_self \u03bc Subset.rfl\n#align measure_theory.measure.restrict_apply_self MeasureTheory.Measure.restrict_apply_self\n\nvariable {\u03bc}\n\ntheorem restrict_apply_univ (s : Set \u03b1) : \u03bc.restrict s univ = \u03bc 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 \u03b1) : \u03bc (t \u2229 s) \u2264 \u03bc.restrict s t :=\n  calc\n    \u03bc (t \u2229 s) = \u03bc.restrict s (t \u2229 s) := (restrict_eq_self \u03bc (inter_subset_right _ _)).symm\n    _ \u2264 \u03bc.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 \u2286 t) : \u03bc.restrict s t = \u03bc s :=\n  ((measure_mono (subset_univ _)).trans_eq <| restrict_apply_univ _).antisymm\n    ((restrict_apply_self \u03bc 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 \u03b1} (\u03bc \u03bd : Measure \u03b1) (s : Set \u03b1) :\n    (\u03bc + \u03bd).restrict s = \u03bc.restrict s + \u03bd.restrict s :=\n  (restrict\u2097 s).map_add \u03bc \u03bd\n#align measure_theory.measure.restrict_add MeasureTheory.Measure.restrict_add\n\n@[simp]\ntheorem restrict_zero {m0 : MeasurableSpace \u03b1} (s : Set \u03b1) : (0 : Measure \u03b1).restrict s = 0 :=\n  (restrict\u2097 s).map_zero\n#align measure_theory.measure.restrict_zero MeasureTheory.Measure.restrict_zero\n\n@[simp]\ntheorem restrict_smul {m0 : MeasurableSpace \u03b1} (c : \u211d\u22650\u221e) (\u03bc : Measure \u03b1) (s : Set \u03b1) :\n    (c \u2022 \u03bc).restrict s = c \u2022 \u03bc.restrict s :=\n  (restrict\u2097 s).map_smul c \u03bc\n#align measure_theory.measure.restrict_smul MeasureTheory.Measure.restrict_smul\n\ntheorem restrict_restrict\u2080 (hs : NullMeasurableSet s (\u03bc.restrict t)) :\n    (\u03bc.restrict t).restrict s = \u03bc.restrict (s \u2229 t) :=\n  ext fun u hu => by\n    simp only [Set.inter_assoc, restrict_apply hu,\n      restrict_apply\u2080 (hu.null_measurable_set.inter hs)]\n#align measure_theory.measure.restrict_restrict\u2080 MeasureTheory.Measure.restrict_restrict\u2080\n\n@[simp]\ntheorem restrict_restrict (hs : MeasurableSet s) : (\u03bc.restrict t).restrict s = \u03bc.restrict (s \u2229 t) :=\n  restrict_restrict\u2080 hs.NullMeasurableSet\n#align measure_theory.measure.restrict_restrict MeasureTheory.Measure.restrict_restrict\n\ntheorem restrict_restrict_of_subset (h : s \u2286 t) : (\u03bc.restrict t).restrict s = \u03bc.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\u2080' (ht : NullMeasurableSet t \u03bc) :\n    (\u03bc.restrict t).restrict s = \u03bc.restrict (s \u2229 t) :=\n  ext fun u hu => by simp only [restrict_apply hu, restrict_apply\u2080' ht, inter_assoc]\n#align measure_theory.measure.restrict_restrict\u2080' MeasureTheory.Measure.restrict_restrict\u2080'\n\ntheorem restrict_restrict' (ht : MeasurableSet t) :\n    (\u03bc.restrict t).restrict s = \u03bc.restrict (s \u2229 t) :=\n  restrict_restrict\u2080' ht.NullMeasurableSet\n#align measure_theory.measure.restrict_restrict' MeasureTheory.Measure.restrict_restrict'\n\ntheorem restrict_comm (hs : MeasurableSet s) :\n    (\u03bc.restrict t).restrict s = (\u03bc.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) : \u03bc.restrict s t = 0 \u2194 \u03bc (t \u2229 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 : \u03bc.restrict s t = 0) : \u03bc (t \u2229 s) = 0 :=\n  nonpos_iff_eq_zero.1 (h \u25b8 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) : \u03bc.restrict s t = 0 \u2194 \u03bc (t \u2229 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 : \u03bc.restrict s = 0 \u2194 \u03bc s = 0 := by\n  rw [\u2190 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 \u03b1} (h : \u03bc s = 0) : \u03bc.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 : \u03bc.restrict \u2205 = 0 :=\n  restrict_zero_set measure_empty\n#align measure_theory.measure.restrict_empty MeasureTheory.Measure.restrict_empty\n\n@[simp]\ntheorem restrict_univ : \u03bc.restrict univ = \u03bc :=\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\u2080 (s : Set \u03b1) (ht : NullMeasurableSet t \u03bc) :\n    \u03bc.restrict (s \u2229 t) + \u03bc.restrict (s \\ t) = \u03bc.restrict s :=\n  by\n  ext1 u hu\n  simp only [add_apply, restrict_apply hu, \u2190 inter_assoc, diff_eq]\n  exact measure_inter_add_diff\u2080 (u \u2229 s) ht\n#align measure_theory.measure.restrict_inter_add_diff\u2080 MeasureTheory.Measure.restrict_inter_add_diff\u2080\n\ntheorem restrict_inter_add_diff (s : Set \u03b1) (ht : MeasurableSet t) :\n    \u03bc.restrict (s \u2229 t) + \u03bc.restrict (s \\ t) = \u03bc.restrict s :=\n  restrict_inter_add_diff\u2080 s ht.NullMeasurableSet\n#align measure_theory.measure.restrict_inter_add_diff MeasureTheory.Measure.restrict_inter_add_diff\n\ntheorem restrict_union_add_inter\u2080 (s : Set \u03b1) (ht : NullMeasurableSet t \u03bc) :\n    \u03bc.restrict (s \u222a t) + \u03bc.restrict (s \u2229 t) = \u03bc.restrict s + \u03bc.restrict t := by\n  rw [\u2190 restrict_inter_add_diff\u2080 (s \u222a t) ht, union_inter_cancel_right, union_diff_right, \u2190\n    restrict_inter_add_diff\u2080 s ht, add_comm, \u2190 add_assoc, add_right_comm]\n#align measure_theory.measure.restrict_union_add_inter\u2080 MeasureTheory.Measure.restrict_union_add_inter\u2080\n\ntheorem restrict_union_add_inter (s : Set \u03b1) (ht : MeasurableSet t) :\n    \u03bc.restrict (s \u222a t) + \u03bc.restrict (s \u2229 t) = \u03bc.restrict s + \u03bc.restrict t :=\n  restrict_union_add_inter\u2080 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 \u03b1) :\n    \u03bc.restrict (s \u222a t) + \u03bc.restrict (s \u2229 t) = \u03bc.restrict s + \u03bc.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\u2080 (h : AeDisjoint \u03bc s t) (ht : NullMeasurableSet t \u03bc) :\n    \u03bc.restrict (s \u222a t) = \u03bc.restrict s + \u03bc.restrict t := by\n  simp [\u2190 restrict_union_add_inter\u2080 s ht, restrict_zero_set h]\n#align measure_theory.measure.restrict_union\u2080 MeasureTheory.Measure.restrict_union\u2080\n\ntheorem restrict_union (h : Disjoint s t) (ht : MeasurableSet t) :\n    \u03bc.restrict (s \u222a t) = \u03bc.restrict s + \u03bc.restrict t :=\n  restrict_union\u2080 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    \u03bc.restrict (s \u222a t) = \u03bc.restrict s + \u03bc.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) : \u03bc.restrict s + \u03bc.restrict (s\u1d9c) = \u03bc :=\n  by\n  rw [\u2190 restrict_union (@disjoint_compl_right (Set \u03b1) _ _) 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) : \u03bc.restrict (s\u1d9c) + \u03bc.restrict s = \u03bc :=\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 \u03b1) : \u03bc.restrict (s \u222a s') \u2264 \u03bc.restrict s + \u03bc.restrict s' :=\n  by\n  intro t ht\n  suffices \u03bc (t \u2229 s \u222a t \u2229 s') \u2264 \u03bc (t \u2229 s) + \u03bc (t \u2229 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\u1d62_apply_ae [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (hd : Pairwise (AeDisjoint \u03bc on s))\n    (hm : \u2200 i, NullMeasurableSet (s i) \u03bc) {t : Set \u03b1} (ht : MeasurableSet t) :\n    \u03bc.restrict (\u22c3 i, s i) t = \u2211' i, \u03bc.restrict (s i) t :=\n  by\n  simp only [restrict_apply, ht, inter_Union]\n  exact\n    measure_Union\u2080 (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\u1d62_apply_ae\n\ntheorem restrict_union\u1d62_apply [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (hd : Pairwise (Disjoint on s))\n    (hm : \u2200 i, MeasurableSet (s i)) {t : Set \u03b1} (ht : MeasurableSet t) :\n    \u03bc.restrict (\u22c3 i, s i) t = \u2211' i, \u03bc.restrict (s i) t :=\n  restrict_union\u1d62_apply_ae hd.AeDisjoint (fun i => (hm i).NullMeasurableSet) ht\n#align measure_theory.measure.restrict_Union_apply MeasureTheory.Measure.restrict_union\u1d62_apply\n\ntheorem restrict_union\u1d62_apply_eq_sup\u1d62 [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (hd : Directed (\u00b7 \u2286 \u00b7) s)\n    {t : Set \u03b1} (ht : MeasurableSet t) : \u03bc.restrict (\u22c3 i, s i) t = \u2a06 i, \u03bc.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\u2081 s\u2082 => inter_subset_inter_right _]\n#align measure_theory.measure.restrict_Union_apply_eq_supr MeasureTheory.Measure.restrict_union\u1d62_apply_eq_sup\u1d62\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 : \u03b1 \u2192 \u03b2} (hf : Measurable f) {s : Set \u03b2} (hs : MeasurableSet s) :\n    (\u03bc.map f).restrict s = (\u03bc.restrict <| f \u207b\u00b9' 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 : \u03bc s \u2260 \u221e) : \u03bc.restrict (toMeasurable \u03bc s) = \u03bc.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 \u03b1} \u2983s : Set \u03b1\u2984 \u2983\u03bc : Measure \u03b1\u2984\n    (hs : \u2200\u1d50 x \u2202\u03bc, x \u2208 s) : \u03bc.restrict s = \u03bc :=\n  calc\n    \u03bc.restrict s = \u03bc.restrict univ := restrict_congr_set (eventuallyEq_univ.mpr hs)\n    _ = \u03bc := 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 \u00abexpr \u2286 \u00bb s) -/\ntheorem restrict_congr_meas (hs : MeasurableSet s) :\n    \u03bc.restrict s = \u03bd.restrict s \u2194 \u2200 (t) (_ : t \u2286 s), MeasurableSet t \u2192 \u03bc t = \u03bd t :=\n  \u27e8fun H t hts ht => by\n    rw [\u2190 inter_eq_self_of_subset_left hts, \u2190 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)]\u27e9\n#align measure_theory.measure.restrict_congr_meas MeasureTheory.Measure.restrict_congr_meas\n\ntheorem restrict_congr_mono (hs : s \u2286 t) (h : \u03bc.restrict t = \u03bd.restrict t) :\n    \u03bc.restrict s = \u03bd.restrict s := by\n  rw [\u2190 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 \u222a t`. -/\ntheorem restrict_union_congr :\n    \u03bc.restrict (s \u222a t) = \u03bd.restrict (s \u222a t) \u2194\n      \u03bc.restrict s = \u03bd.restrict s \u2227 \u03bc.restrict t = \u03bd.restrict t :=\n  by\n  refine'\n    \u27e8fun h =>\n      \u27e8restrict_congr_mono (subset_union_left _ _) h,\n        restrict_congr_mono (subset_union_right _ _) h\u27e9,\n      _\u27e9\n  rintro \u27e8hs, ht\u27e9\n  ext1 u hu\n  simp only [restrict_apply hu, inter_union_distrib_left]\n  rcases exists_measurable_superset\u2082 \u03bc \u03bd (u \u2229 s) with \u27e8US, hsub, hm, h\u03bc, h\u03bd\u27e9\n  calc\n    \u03bc (u \u2229 s \u222a u \u2229 t) = \u03bc (US \u222a u \u2229 t) := measure_union_congr_of_subset hsub h\u03bc.le subset.rfl le_rfl\n    _ = \u03bc US + \u03bc ((u \u2229 t) \\ US) := (measure_add_diff hm _).symm\n    _ = restrict \u03bc s u + restrict \u03bc t (u \\ US) := by\n      simp only [restrict_apply, hu, hu.diff hm, h\u03bc, \u2190 inter_comm t, inter_diff_assoc]\n    _ = restrict \u03bd s u + restrict \u03bd t (u \\ US) := by rw [hs, ht]\n    _ = \u03bd US + \u03bd ((u \u2229 t) \\ US) := by\n      simp only [restrict_apply, hu, hu.diff hm, h\u03bd, \u2190 inter_comm t, inter_diff_assoc]\n    _ = \u03bd (US \u222a u \u2229 t) := (measure_add_diff hm _)\n    _ = \u03bd (u \u2229 s \u222a u \u2229 t) := Eq.symm <| measure_union_congr_of_subset hsub h\u03bd.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 \u03b9} {t : \u03b9 \u2192 Set \u03b1} :\n    \u03bc.restrict (\u22c3 i \u2208 s, t i) = \u03bd.restrict (\u22c3 i \u2208 s, t i) \u2194\n      \u2200 i \u2208 s, \u03bc.restrict (t i) = \u03bd.restrict (t i) :=\n  by\n  induction' s using Finset.induction_on with i s hi hs; \u00b7 simp\n  simp only [forall_eq_or_imp, Union_Union_eq_or_left, Finset.mem_insert]\n  rw [restrict_union_congr, \u2190 hs]\n#align measure_theory.measure.restrict_finset_bUnion_congr MeasureTheory.Measure.restrict_finset_bUnion_congr\n\ntheorem restrict_union\u1d62_congr [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} :\n    \u03bc.restrict (\u22c3 i, s i) = \u03bd.restrict (\u22c3 i, s i) \u2194 \u2200 i, \u03bc.restrict (s i) = \u03bd.restrict (s i) :=\n  by\n  refine' \u27e8fun h i => restrict_congr_mono (subset_Union _ _) h, fun h => _\u27e9\n  ext1 t ht\n  have D : Directed (\u00b7 \u2286 \u00b7) fun t : Finset \u03b9 => \u22c3 i \u2208 t, s i :=\n    directed_of_sup fun t\u2081 t\u2082 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\u1d62_congr\n\ntheorem restrict_bUnion_congr {s : Set \u03b9} {t : \u03b9 \u2192 Set \u03b1} (hc : s.Countable) :\n    \u03bc.restrict (\u22c3 i \u2208 s, t i) = \u03bd.restrict (\u22c3 i \u2208 s, t i) \u2194\n      \u2200 i \u2208 s, \u03bc.restrict (t i) = \u03bd.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\u209b_congr {S : Set (Set \u03b1)} (hc : S.Countable) :\n    \u03bc.restrict (\u22c3\u2080 S) = \u03bd.restrict (\u22c3\u2080 S) \u2194 \u2200 s \u2208 S, \u03bc.restrict s = \u03bd.restrict s := by\n  rw [sUnion_eq_bUnion, restrict_bUnion_congr hc]\n#align measure_theory.measure.restrict_sUnion_congr MeasureTheory.Measure.restrict_union\u209b_congr\n\n/-- This lemma shows that `Inf` and `restrict` commute for measures. -/\ntheorem restrict_inf\u209b_eq_inf\u209b_restrict {m0 : MeasurableSpace \u03b1} {m : Set (Measure \u03b1)}\n    (hm : m.Nonempty) (ht : MeasurableSet t) :\n    (inf\u209b m).restrict t = inf\u209b ((fun \u03bc : Measure \u03b1 => \u03bc.restrict t) '' m) :=\n  by\n  ext1 s hs\n  simp_rw [inf\u209b_apply hs, restrict_apply hs, inf\u209b_apply (MeasurableSet.inter hs ht),\n    Set.image_image, restrict_to_outer_measure_eq_to_outer_measure_restrict ht, \u2190\n    Set.image_image _ to_outer_measure, \u2190 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\u209b_eq_inf\u209b_restrict\n\ntheorem exists_mem_of_measure_ne_zero_of_ae (hs : \u03bc s \u2260 0) {p : \u03b1 \u2192 Prop}\n    (hp : \u2200\u1d50 x \u2202\u03bc.restrict s, p x) : \u2203 x, x \u2208 s \u2227 p x :=\n  by\n  rw [\u2190 \u03bc.restrict_apply_self, \u2190 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\u1d62_eq_univ [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (hs : (\u22c3 i, s i) = univ) :\n    \u03bc = \u03bd \u2194 \u2200 i, \u03bc.restrict (s i) = \u03bd.restrict (s i) := by\n  rw [\u2190 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\u1d62_eq_univ\n\nalias ext_iff_of_Union_eq_univ \u2194 _ ext_of_Union_eq_univ\n#align measure_theory.measure.ext_of_Union_eq_univ MeasureTheory.Measure.ext_of_union\u1d62_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 \u03b9} {s : \u03b9 \u2192 Set \u03b1} (hc : S.Countable)\n    (hs : (\u22c3 i \u2208 S, s i) = univ) : \u03bc = \u03bd \u2194 \u2200 i \u2208 S, \u03bc.restrict (s i) = \u03bd.restrict (s i) := by\n  rw [\u2190 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 \u2194 _ 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\u209b_eq_univ {S : Set (Set \u03b1)} (hc : S.Countable) (hs : \u22c3\u2080 S = univ) :\n    \u03bc = \u03bd \u2194 \u2200 s \u2208 S, \u03bc.restrict s = \u03bd.restrict s :=\n  ext_iff_of_bUnion_eq_univ hc <| by rwa [\u2190 sUnion_eq_bUnion]\n#align measure_theory.measure.ext_iff_of_sUnion_eq_univ MeasureTheory.Measure.ext_iff_of_union\u209b_eq_univ\n\nalias ext_iff_of_sUnion_eq_univ \u2194 _ ext_of_sUnion_eq_univ\n#align measure_theory.measure.ext_of_sUnion_eq_univ MeasureTheory.Measure.ext_of_union\u209b_eq_univ\n\ntheorem ext_of_generateFrom_of_cover {S T : Set (Set \u03b1)} (h_gen : \u2039_\u203a = generateFrom S)\n    (hc : T.Countable) (h_inter : IsPiSystem S) (hU : \u22c3\u2080 T = univ) (htop : \u2200 t \u2208 T, \u03bc t \u2260 \u221e)\n    (ST_eq : \u2200 t \u2208 T, \u2200 s \u2208 S, \u03bc (s \u2229 t) = \u03bd (s \u2229 t)) (T_eq : \u2200 t \u2208 T, \u03bc t = \u03bd t) : \u03bc = \u03bd :=\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  \u00b7 simp only [Set.empty_inter, measure_empty]\n  \u00b7 intro v hv hvt\n    have := T_eq t ht\n    rw [Set.inter_comm] at hvt\u22a2\n    rwa [\u2190 measure_inter_add_diff t hv, \u2190 measure_inter_add_diff t hv, \u2190 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  \u00b7 intro f hfd hfm h_eq\n    simp only [\u2190 restrict_apply (hfm _), \u2190 restrict_apply (MeasurableSet.union\u1d62 hfm)] at h_eq\u22a2\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 \u03c0-system generating the \u03c3-algebra,\n  and they are both finite on a increasing spanning sequence of sets in the \u03c0-system.\n  This lemma is formulated using `sUnion`. -/\ntheorem ext_of_generateFrom_of_cover_subset {S T : Set (Set \u03b1)} (h_gen : \u2039_\u203a = generateFrom S)\n    (h_inter : IsPiSystem S) (h_sub : T \u2286 S) (hc : T.Countable) (hU : \u22c3\u2080 T = univ)\n    (htop : \u2200 s \u2208 T, \u03bc s \u2260 \u221e) (h_eq : \u2200 s \u2208 S, \u03bc s = \u03bd s) : \u03bc = \u03bd :=\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 \u2229 t).eq_empty_or_nonempty with H H\n  \u00b7 simp only [H, measure_empty]\n  \u00b7 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 \u03c0-system generating the \u03c3-algebra,\n  and they are both finite on a increasing spanning sequence of sets in the \u03c0-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\u1d62 (C : Set (Set \u03b1)) (B : \u2115 \u2192 Set \u03b1) (hA : \u2039_\u203a = generateFrom C)\n    (hC : IsPiSystem C) (h1B : (\u22c3 i, B i) = univ) (h2B : \u2200 i, B i \u2208 C) (h\u03bcB : \u2200 i, \u03bc (B i) \u2260 \u221e)\n    (h_eq : \u2200 s \u2208 C, \u03bc s = \u03bd s) : \u03bc = \u03bd :=\n  by\n  refine' ext_of_generate_from_of_cover_subset hA hC _ (countable_range B) h1B _ h_eq\n  \u00b7 rintro _ \u27e8i, rfl\u27e9\n    apply h2B\n  \u00b7 rintro _ \u27e8i, rfl\u27e9\n    apply h\u03bcB\n#align measure_theory.measure.ext_of_generate_from_of_Union MeasureTheory.Measure.ext_of_generateFrom_of_union\u1d62\n\nsection Dirac\n\nvariable [MeasurableSpace \u03b1]\n\n/-- The dirac measure. -/\ndef dirac (a : \u03b1) : Measure \u03b1 :=\n  (OuterMeasure.dirac a).toMeasure (by simp)\n#align measure_theory.measure.dirac MeasureTheory.Measure.dirac\n\ninstance : MeasureSpace PUnit :=\n  \u27e8dirac PUnit.unit\u27e9\n\ntheorem le_dirac_apply {a} : s.indicator 1 a \u2264 dirac a s :=\n  OuterMeasure.dirac_apply a s \u25b8 le_toMeasure_apply _ _ _\n#align measure_theory.measure.le_dirac_apply MeasureTheory.Measure.le_dirac_apply\n\n@[simp]\ntheorem dirac_apply' (a : \u03b1) (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 : \u03b1} (h : a \u2208 s) : dirac a s = 1 :=\n  by\n  have : \u2200 t : Set \u03b1, a \u2208 t \u2192 t.indicator (1 : \u03b1 \u2192 \u211d\u22650\u221e) a = 1 := fun t ht => indicator_of_mem ht 1\n  refine' le_antisymm (this univ trivial \u25b8 _) (this s h \u25b8 le_dirac_apply)\n  rw [\u2190 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 \u03b1] (a : \u03b1) (s : Set \u03b1) :\n    dirac a s = s.indicator 1 a := by\n  by_cases h : a \u2208 s; \u00b7 rw [dirac_apply_of_mem h, indicator_of_mem h, Pi.one_apply]\n  rw [indicator_of_not_mem h, \u2190 nonpos_iff_eq_zero]\n  calc\n    dirac a s \u2264 dirac a ({a}\u1d9c) := 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 : \u03b1 \u2192 \u03b2} (hf : Measurable f) (a : \u03b1) : (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 (\u03bc : Measure \u03b1) (a : \u03b1) : \u03bc.restrict {a} = \u03bc {a} \u2022 dirac a :=\n  by\n  ext1 s hs\n  by_cases ha : a \u2208 s\n  \u00b7 have : s \u2229 {a} = {a} := by simpa\n    simp [*]\n  \u00b7 have : s \u2229 {a} = \u2205 := 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 : \u03b9 \u2192 Measure \u03b1) : Measure \u03b1 :=\n  (OuterMeasure.sum fun i => (f i).toOuterMeasure).toMeasure <|\n    le_trans (le_inf\u1d62 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 : \u03b9 \u2192 Measure \u03b1) (s : Set \u03b1) : (\u2211' i, f i s) \u2264 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 : \u03b9 \u2192 Measure \u03b1) {s : Set \u03b1} (hs : MeasurableSet s) : sum f s = \u2211' i, f i s :=\n  toMeasure_apply _ _ hs\n#align measure_theory.measure.sum_apply MeasureTheory.Measure.sum_apply\n\ntheorem le_sum (\u03bc : \u03b9 \u2192 Measure \u03b1) (i : \u03b9) : \u03bc i \u2264 sum \u03bc := fun s hs => by\n  simp only [sum_apply \u03bc 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 \u03b9] {\u03bc : \u03b9 \u2192 Measure \u03b1} {s : Set \u03b1} :\n    sum \u03bc s = 0 \u2194 \u2200 i, \u03bc i s = 0 :=\n  by\n  refine'\n    \u27e8fun h i => nonpos_iff_eq_zero.1 <| h \u25b8 le_iff'.1 (le_sum \u03bc i) _, fun h =>\n      nonpos_iff_eq_zero.1 _\u27e9\n  rcases exists_measurable_superset_forall_eq \u03bc s with \u27e8t, hst, htm, ht\u27e9\n  calc\n    Sum \u03bc s \u2264 Sum \u03bc 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' {\u03bc : \u03b9 \u2192 Measure \u03b1} {s : Set \u03b1} (hs : MeasurableSet s) :\n    sum \u03bc s = 0 \u2194 \u2200 i, \u03bc 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 {\u03b9' : Type _} (\u03bc : \u03b9 \u2192 \u03b9' \u2192 Measure \u03b1) :\n    (sum fun n => sum (\u03bc n)) = sum fun m => sum fun n => \u03bc 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 \u03b9] {\u03bc : \u03b9 \u2192 Measure \u03b1} {p : \u03b1 \u2192 Prop} :\n    (\u2200\u1d50 x \u2202sum \u03bc, p x) \u2194 \u2200 i, \u2200\u1d50 x \u2202\u03bc 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' {\u03bc : \u03b9 \u2192 Measure \u03b1} {p : \u03b1 \u2192 Prop} (h : MeasurableSet { x | p x }) :\n    (\u2200\u1d50 x \u2202sum \u03bc, p x) \u2194 \u2200 i, \u2200\u1d50 x \u2202\u03bc 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 \u03b9] (\u03bc : \u03b9 \u2192 Measure \u03b1) : sum \u03bc = \u2211 i, \u03bc 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 \u03b9) (\u03bc : \u03b9 \u2192 Measure \u03b1) :\n    (sum fun i : s => \u03bc i) = \u2211 i in s, \u03bc i := by rw [sum_fintype, Finset.sum_coe_sort s \u03bc]\n#align measure_theory.measure.sum_coe_finset MeasureTheory.Measure.sum_coe_finset\n\n@[simp]\ntheorem ae_sum_eq [Countable \u03b9] (\u03bc : \u03b9 \u2192 Measure \u03b1) : (sum \u03bc).ae = \u2a06 i, (\u03bc i).ae :=\n  Filter.ext fun s => ae_sum_iff.trans mem_sup\u1d62.symm\n#align measure_theory.measure.ae_sum_eq MeasureTheory.Measure.ae_sum_eq\n\n@[simp]\ntheorem sum_bool (f : Bool \u2192 Measure \u03b1) : 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 (\u03bc \u03bd : Measure \u03b1) : (sum fun b => cond b \u03bc \u03bd) = \u03bc + \u03bd :=\n  sum_bool _\n#align measure_theory.measure.sum_cond MeasureTheory.Measure.sum_cond\n\n@[simp]\ntheorem restrict_sum (\u03bc : \u03b9 \u2192 Measure \u03b1) {s : Set \u03b1} (hs : MeasurableSet s) :\n    (sum \u03bc).restrict s = sum fun i => (\u03bc 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 \u03b9] (\u03bc : \u03b9 \u2192 Measure \u03b1) : sum \u03bc = 0 := by\n  rw [\u2190 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 \u03b9) (\u03bc : \u03b9 \u2192 Measure \u03b1) :\n    ((sum fun i : s => \u03bc i) + sum fun i : s\u1d9c => \u03bc i) = sum \u03bc :=\n  by\n  ext1 t ht\n  simp only [add_apply, sum_apply _ ht]\n  exact @tsum_add_tsum_compl \u211d\u22650\u221e \u03b9 _ _ _ (fun i => \u03bc 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 {\u03bc \u03bd : \u2115 \u2192 Measure \u03b1} (h : \u2200 n, \u03bc n = \u03bd n) : sum \u03bc = sum \u03bd :=\n  congr_arg sum (funext h)\n#align measure_theory.measure.sum_congr MeasureTheory.Measure.sum_congr\n\ntheorem sum_add_sum (\u03bc \u03bd : \u2115 \u2192 Measure \u03b1) : sum \u03bc + sum \u03bd = sum fun n => \u03bc n + \u03bd 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 `\u03bc.map f` is a sum of Dirac measures. -/\ntheorem map_eq_sum [Countable \u03b2] [MeasurableSingletonClass \u03b2] (\u03bc : Measure \u03b1) (f : \u03b1 \u2192 \u03b2)\n    (hf : Measurable f) : \u03bc.map f = sum fun b : \u03b2 => \u03bc (f \u207b\u00b9' {b}) \u2022 dirac b :=\n  by\n  ext1 s hs\n  have : \u2200 y \u2208 s, MeasurableSet (f \u207b\u00b9' {y}) := fun y _ => hf (measurable_set_singleton _)\n  simp [\u2190 tsum_measure_preimage_singleton (to_countable s) this, *,\n    tsum_subtype s fun b => \u03bc (f \u207b\u00b9' {b}), \u2190 indicator_mul_right s fun b => \u03bc (f \u207b\u00b9' {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 \u03b1] [MeasurableSingletonClass \u03b1] (\u03bc : Measure \u03b1) :\n    (sum fun a => \u03bc {a} \u2022 dirac a) = \u03bc := by simpa using (map_eq_sum \u03bc id measurable_id).symm\n#align measure_theory.measure.sum_smul_dirac MeasureTheory.Measure.sum_smul_dirac\n\n/-- Given that `\u03b1` 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 \u2208 s`. -/\ntheorem tsum_indicator_apply_singleton [Countable \u03b1] [MeasurableSingletonClass \u03b1] (\u03bc : Measure \u03b1)\n    (s : Set \u03b1) (hs : MeasurableSet s) : (\u2211' x : \u03b1, s.indicator (fun x => \u03bc {x}) x) = \u03bc s :=\n  calc\n    (\u2211' x : \u03b1, s.indicator (fun x => \u03bc {x}) x) = Measure.sum (fun a => \u03bc {a} \u2022 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    _ = \u03bc s := by rw [\u03bc.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\u1d62_ae [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (hd : Pairwise (AeDisjoint \u03bc on s))\n    (hm : \u2200 i, NullMeasurableSet (s i) \u03bc) : \u03bc.restrict (\u22c3 i, s i) = sum fun i => \u03bc.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\u1d62_ae\n\ntheorem restrict_union\u1d62 [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} (hd : Pairwise (Disjoint on s))\n    (hm : \u2200 i, MeasurableSet (s i)) : \u03bc.restrict (\u22c3 i, s i) = sum fun i => \u03bc.restrict (s i) :=\n  restrict_union\u1d62_ae hd.AeDisjoint fun i => (hm i).NullMeasurableSet\n#align measure_theory.measure.restrict_Union MeasureTheory.Measure.restrict_union\u1d62\n\ntheorem restrict_union\u1d62_le [Countable \u03b9] {s : \u03b9 \u2192 Set \u03b1} :\n    \u03bc.restrict (\u22c3 i, s i) \u2264 sum fun i => \u03bc.restrict (s i) :=\n  by\n  intro t ht\n  suffices \u03bc (\u22c3 i, t \u2229 s i) \u2264 \u2211' i, \u03bc (t \u2229 s i) by simpa [ht, inter_Union]\n  apply measure_Union_le\n#align measure_theory.measure.restrict_Union_le MeasureTheory.Measure.restrict_union\u1d62_le\n\nsection Count\n\nvariable [MeasurableSpace \u03b1]\n\n/-- Counting measure on any measurable space. -/\ndef count : Measure \u03b1 :=\n  sum dirac\n#align measure_theory.measure.count MeasureTheory.Measure.count\n\ntheorem le_count_apply : (\u2211' i : s, 1 : \u211d\u22650\u221e) \u2264 count s :=\n  calc\n    (\u2211' i : s, 1 : \u211d\u22650\u221e) = \u2211' i, indicator s 1 i := tsum_subtype s 1\n    _ \u2264 \u2211' i, dirac i s := (ENNReal.tsum_le_tsum fun x => le_dirac_apply)\n    _ \u2264 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 = \u2211' i : s, 1 := by\n  simp only [count, sum_apply, hs, dirac_apply', \u2190 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 (\u2205 : Set \u03b1) = 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 \u03b1} (s_mble : MeasurableSet (s : Set \u03b1)) :\n    count (\u2191s : Set \u03b1) = s.card :=\n  calc\n    count (\u2191s : Set \u03b1) = \u2211' i : (\u2191s : Set \u03b1), 1 := count_apply s_mble\n    _ = \u2211 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 \u03b1] (s : Finset \u03b1) :\n    count (\u2191s : Set \u03b1) = 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 \u03b1} (s_fin : s.Finite) (s_mble : MeasurableSet s) :\n    count s = s_fin.toFinset.card := by\n  simp [\u2190\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 \u03b1] (s : Set \u03b1) (hs : s.Finite) :\n    count s = hs.toFinset.card := by rw [\u2190 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 = \u221e :=\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 \u27e8t, ht, rfl\u27e9\n  calc\n    (t.card : \u211d\u22650\u221e) = \u2211 i in t, 1 := by simp\n    _ = \u2211' i : (t : Set \u03b1), 1 := (t.tsum_subtype 1).symm\n    _ \u2264 count (t : Set \u03b1) := le_count_apply\n    _ \u2264 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 = \u221e \u2194 s.Infinite :=\n  by\n  by_cases hs : s.finite\n  \u00b7 simp [Set.Infinite, hs, count_apply_finite' hs s_mble]\n  \u00b7 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 \u03b1] : count s = \u221e \u2194 s.Infinite :=\n  by\n  by_cases hs : s.finite\n  \u00b7 exact count_apply_eq_top' hs.measurable_set\n  \u00b7 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 < \u221e \u2194 s.Finite :=\n  calc\n    count s < \u221e \u2194 count s \u2260 \u221e := lt_top_iff_ne_top\n    _ \u2194 \u00acs.Infinite := (not_congr (count_apply_eq_top' s_mble))\n    _ \u2194 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 \u03b1] : count s < \u221e \u2194 s.Finite :=\n  calc\n    count s < \u221e \u2194 count s \u2260 \u221e := lt_top_iff_ne_top\n    _ \u2194 \u00acs.Infinite := (not_congr count_apply_eq_top)\n    _ \u2194 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 = \u2205 :=\n  by\n  have hs : s.finite := by\n    rw [\u2190 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 \u03b1] (hsc : count s = 0) : s = \u2205 :=\n  by\n  have hs : s.finite := by\n    rw [\u2190 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 \u2194 s = \u2205 :=\n  \u27e8empty_of_count_eq_zero' s_mble, fun h => h.symm \u25b8 count_empty\u27e9\n#align measure_theory.measure.count_eq_zero_iff' MeasureTheory.Measure.count_eq_zero_iff'\n\n@[simp]\ntheorem count_eq_zero_iff [MeasurableSingletonClass \u03b1] : count s = 0 \u2194 s = \u2205 :=\n  \u27e8empty_of_count_eq_zero, fun h => h.symm \u25b8 count_empty\u27e9\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 \u2260 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 \u03b1] (hs' : s.Nonempty) : count s \u2260 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 : \u03b1} (ha : MeasurableSet ({a} : Set \u03b1)) : count ({a} : Set \u03b1) = 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 \u03b1] (a : \u03b1) : count ({a} : Set \u03b1) = 1 :=\n  count_singleton' (measurableSet_singleton a)\n#align measure_theory.measure.count_singleton MeasureTheory.Measure.count_singleton\n\ntheorem count_injective_image' {f : \u03b2 \u2192 \u03b1} (hf : Function.Injective f) {s : Set \u03b2}\n    (s_mble : MeasurableSet s) (fs_mble : MeasurableSet (f '' s)) : count (f '' s) = count s :=\n  by\n  by_cases hs : s.finite\n  \u00b7 lift s to Finset \u03b2 using hs\n    rw [\u2190 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 [\u2190 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 \u03b1] [MeasurableSingletonClass \u03b2] {f : \u03b2 \u2192 \u03b1}\n    (hf : Function.Injective f) (s : Set \u03b2) : count (f '' s) = count s :=\n  by\n  by_cases hs : s.finite\n  \u00b7 exact count_injective_image' hf hs.measurable_set (finite.image f hs).MeasurableSet\n  rw [count_apply_infinite hs]\n  rw [\u2190 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 `\u03bc` is absolutely continuous with respect to `\u03bd`, or that `\u03bc` is dominated by `\u03bd`,\n  if `\u03bd(A) = 0` implies that `\u03bc(A) = 0`. -/\ndef AbsolutelyContinuous {m0 : MeasurableSpace \u03b1} (\u03bc \u03bd : Measure \u03b1) : Prop :=\n  \u2200 \u2983s : Set \u03b1\u2984, \u03bd s = 0 \u2192 \u03bc s = 0\n#align measure_theory.measure.absolutely_continuous MeasureTheory.Measure.AbsolutelyContinuous\n\n-- mathport name: measure.absolutely_continuous\nscoped[MeasureTheory] infixl:50 \" \u226a \" => MeasureTheory.Measure.AbsolutelyContinuous\n\ntheorem absolutelyContinuousOfLe (h : \u03bc \u2264 \u03bd) : \u03bc \u226a \u03bd := fun s hs =>\n  nonpos_iff_eq_zero.1 <| hs \u25b8 le_iff'.1 h s\n#align measure_theory.measure.absolutely_continuous_of_le MeasureTheory.Measure.absolutelyContinuousOfLe\n\nalias absolutely_continuous_of_le \u2190 _root_.has_le.le.absolutely_continuous\n#align has_le.le.absolutely_continuous LE.le.absolutelyContinuous\n\ntheorem absolutelyContinuousOfEq (h : \u03bc = \u03bd) : \u03bc \u226a \u03bd :=\n  h.le.AbsolutelyContinuous\n#align measure_theory.measure.absolutely_continuous_of_eq MeasureTheory.Measure.absolutelyContinuousOfEq\n\nalias absolutely_continuous_of_eq \u2190 _root_.eq.absolutely_continuous\n#align eq.absolutely_continuous Eq.absolutelyContinuous\n\nnamespace AbsolutelyContinuous\n\ntheorem mk (h : \u2200 \u2983s : Set \u03b1\u2984, MeasurableSet s \u2192 \u03bd s = 0 \u2192 \u03bc s = 0) : \u03bc \u226a \u03bd :=\n  by\n  intro s hs\n  rcases exists_measurable_superset_of_null hs with \u27e8t, h1t, h2t, h3t\u27e9\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 \u03b1} (\u03bc : Measure \u03b1) : \u03bc \u226a \u03bc :=\n  rfl.AbsolutelyContinuous\n#align measure_theory.measure.absolutely_continuous.refl MeasureTheory.Measure.AbsolutelyContinuous.refl\n\nprotected theorem rfl : \u03bc \u226a \u03bc := fun s hs => hs\n#align measure_theory.measure.absolutely_continuous.rfl MeasureTheory.Measure.AbsolutelyContinuous.rfl\n\ninstance [MeasurableSpace \u03b1] : IsRefl (Measure \u03b1) (\u00b7 \u226a \u00b7) :=\n  \u27e8fun \u03bc => AbsolutelyContinuous.rfl\u27e9\n\n@[trans]\nprotected theorem trans (h1 : \u03bc\u2081 \u226a \u03bc\u2082) (h2 : \u03bc\u2082 \u226a \u03bc\u2083) : \u03bc\u2081 \u226a \u03bc\u2083 := 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 : \u03bc \u226a \u03bd) {f : \u03b1 \u2192 \u03b2} (hf : Measurable f) : \u03bc.map f \u226a \u03bd.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 \u211d\u22650\u221e] [IsScalarTower R \u211d\u22650\u221e \u211d\u22650\u221e] (h : \u03bc \u226a \u03bd)\n    (c : R) : c \u2022 \u03bc \u226a \u03bd := fun s h\u03bds => by simp only [h h\u03bds, 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 {\u03bc' : Measure \u03b1} {c : \u211d\u22650\u221e} (h\u03bc'_le : \u03bc' \u2264 c \u2022 \u03bc) : \u03bc' \u226a \u03bc :=\n  (Measure.absolutelyContinuousOfLe h\u03bc'_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 : \u03bc.ae \u2264 \u03bd.ae \u2194 \u03bc \u226a \u03bd :=\n  \u27e8fun 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\u27e9\n#align measure_theory.measure.ae_le_iff_absolutely_continuous MeasureTheory.Measure.ae_le_iff_absolutelyContinuous\n\nalias ae_le_iff_absolutely_continuous \u2194\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 \u2190 ae_mono'\n#align measure_theory.measure.ae_mono' MeasureTheory.Measure.ae_mono'\n\ntheorem AbsolutelyContinuous.ae_eq (h : \u03bc \u226a \u03bd) {f g : \u03b1 \u2192 \u03b4} (h' : f =\u1d50[\u03bd] g) : f =\u1d50[\u03bc] 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 : \u03b1 \u2192 \u03b2` is said to be *quasi measure preserving* (a.k.a. non-singular) w.r.t. measures\n`\u03bca` and `\u03bcb` if it is measurable and `\u03bcb s = 0` implies `\u03bca (f \u207b\u00b9' s) = 0`. -/\n@[protect_proj]\nstructure QuasiMeasurePreserving {m0 : MeasurableSpace \u03b1} (f : \u03b1 \u2192 \u03b2)\n  (\u03bca : Measure \u03b1 := by exact MeasureTheory.MeasureSpace.volume)\n  (\u03bcb : Measure \u03b2 := by exact MeasureTheory.MeasureSpace.volume) : Prop where\n  Measurable : Measurable f\n  AbsolutelyContinuous : \u03bca.map f \u226a \u03bcb\n#align measure_theory.measure.quasi_measure_preserving MeasureTheory.Measure.QuasiMeasurePreserving\n\nnamespace QuasiMeasurePreserving\n\nprotected theorem id {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) : QuasiMeasurePreserving id \u03bc \u03bc :=\n  \u27e8measurable_id, map_id.AbsolutelyContinuous\u27e9\n#align measure_theory.measure.quasi_measure_preserving.id MeasureTheory.Measure.QuasiMeasurePreserving.id\n\nvariable {\u03bca \u03bca' : Measure \u03b1} {\u03bcb \u03bcb' : Measure \u03b2} {\u03bcc : Measure \u03b3} {f : \u03b1 \u2192 \u03b2}\n\nprotected theorem Measurable.quasiMeasurePreserving {m0 : MeasurableSpace \u03b1} (hf : Measurable f)\n    (\u03bc : Measure \u03b1) : QuasiMeasurePreserving f \u03bc (\u03bc.map f) :=\n  \u27e8hf, AbsolutelyContinuous.rfl\u27e9\n#align measurable.quasi_measure_preserving Measurable.quasiMeasurePreserving\n\ntheorem monoLeft (h : QuasiMeasurePreserving f \u03bca \u03bcb) (ha : \u03bca' \u226a \u03bca) :\n    QuasiMeasurePreserving f \u03bca' \u03bcb :=\n  \u27e8h.1, (ha.map h.1).trans h.2\u27e9\n#align measure_theory.measure.quasi_measure_preserving.mono_left MeasureTheory.Measure.QuasiMeasurePreserving.monoLeft\n\ntheorem monoRight (h : QuasiMeasurePreserving f \u03bca \u03bcb) (ha : \u03bcb \u226a \u03bcb') :\n    QuasiMeasurePreserving f \u03bca \u03bcb' :=\n  \u27e8h.1, h.2.trans ha\u27e9\n#align measure_theory.measure.quasi_measure_preserving.mono_right MeasureTheory.Measure.QuasiMeasurePreserving.monoRight\n\n@[mono]\ntheorem mono (ha : \u03bca' \u226a \u03bca) (hb : \u03bcb \u226a \u03bcb') (h : QuasiMeasurePreserving f \u03bca \u03bcb) :\n    QuasiMeasurePreserving f \u03bca' \u03bcb' :=\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 : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : QuasiMeasurePreserving g \u03bcb \u03bcc)\n    (hf : QuasiMeasurePreserving f \u03bca \u03bcb) : QuasiMeasurePreserving (g \u2218 f) \u03bca \u03bcc :=\n  \u27e8hg.Measurable.comp hf.Measurable, by\n    rw [\u2190 map_map hg.1 hf.1]\n    exact (hf.2.map hg.1).trans hg.2\u27e9\n#align measure_theory.measure.quasi_measure_preserving.comp MeasureTheory.Measure.QuasiMeasurePreserving.comp\n\nprotected theorem iterate {f : \u03b1 \u2192 \u03b1} (hf : QuasiMeasurePreserving f \u03bca \u03bca) :\n    \u2200 n, QuasiMeasurePreserving (f^[n]) \u03bca \u03bca\n  | 0 => QuasiMeasurePreserving.id \u03bca\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 \u03bca \u03bcb) : AeMeasurable f \u03bca :=\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 \u03bca \u03bcb) : (\u03bca.map f).ae \u2264 \u03bcb.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 \u03bca \u03bcb) : Tendsto f \u03bca.ae \u03bcb.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 \u03bca \u03bcb) {p : \u03b2 \u2192 Prop} (hg : \u2200\u1d50 x \u2202\u03bcb, p x) :\n    \u2200\u1d50 x \u2202\u03bca, 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 \u03bca \u03bcb) {g\u2081 g\u2082 : \u03b2 \u2192 \u03b4} (hg : g\u2081 =\u1d50[\u03bcb] g\u2082) :\n    g\u2081 \u2218 f =\u1d50[\u03bca] g\u2082 \u2218 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 \u03bca \u03bcb) {s : Set \u03b2} (hs : \u03bcb s = 0) :\n    \u03bca (f \u207b\u00b9' 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 \u03b2} (hf : QuasiMeasurePreserving f \u03bca \u03bcb) (h : s \u2264\u1d50[\u03bcb] t) :\n    f \u207b\u00b9' s \u2264\u1d50[\u03bca] f \u207b\u00b9' 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 \u03b2} (hf : QuasiMeasurePreserving f \u03bca \u03bcb) (h : s =\u1d50[\u03bcb] t) :\n    f \u207b\u00b9' s =\u1d50[\u03bca] f \u207b\u00b9' 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 \u03b1} {f : \u03b1 \u2192 \u03b1} (hf : QuasiMeasurePreserving f \u03bc \u03bc) (k : \u2115)\n    (hs : f \u207b\u00b9' s =\u1d50[\u03bc] s) : f^[k] \u207b\u00b9' s =\u1d50[\u03bc] s :=\n  by\n  induction' k with k ih; \u00b7 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 \u03b1} {e : \u03b1 \u2243 \u03b1} (he : QuasiMeasurePreserving e \u03bc \u03bc)\n    (he' : QuasiMeasurePreserving e.symm \u03bc \u03bc) (k : \u2124) (hs : e '' s =\u1d50[\u03bc] s) :\n    \u21d1(e ^ k) '' s =\u1d50[\u03bc] s := by\n  rw [Equiv.image_eq_preimage]\n  obtain \u27e8k, rfl | rfl\u27e9 := k.eq_coe_or_neg\n  \u00b7 replace hs : \u21d1e\u207b\u00b9 \u207b\u00b9' s =\u1d50[\u03bc] s\n    \u00b7 rwa [Equiv.image_eq_preimage] at hs\n    replace he' : \u21d1e\u207b\u00b9^[k] \u207b\u00b9' s =\u1d50[\u03bc] s := he'.preimage_iterate_ae_eq k hs\n    rwa [Equiv.Perm.iterate_eq_pow e\u207b\u00b9 k, inv_pow e k] at he'\n  \u00b7 rw [zpow_neg, zpow_ofNat]\n    replace hs : e \u207b\u00b9' s =\u1d50[\u03bc] s\n    \u00b7 convert he.preimage_ae_eq hs.symm\n      rw [Equiv.preimage_image]\n    replace he : \u21d1e^[k] \u207b\u00b9' s =\u1d50[\u03bc] 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 : \u03b1 \u2192 \u03b1} (hf : QuasiMeasurePreserving f \u03bc \u03bc)\n    (hs : f \u207b\u00b9' s =\u1d50[\u03bc] s) :-- Need `@` below because of diamond; see gh issue #16932\n        @limsup\n        (Set \u03b1) \u2115 _ (fun n => (preimage f^[n]) s) atTop =\u1d50[\u03bc]\n      s :=\n  haveI : \u2200 n, (preimage f^[n]) s =\u1d50[\u03bc] s := by\n    intro n\n    induction' n with n ih\n    \u00b7 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 : \u03b1 \u2192 \u03b1} (hf : QuasiMeasurePreserving f \u03bc \u03bc)\n    (hs : f \u207b\u00b9' s =\u1d50[\u03bc] s) :-- Need `@` below because of diamond; see gh issue #16932\n        @liminf\n        (Set \u03b1) \u2115 _ (fun n => (preimage f^[n]) s) atTop =\u1d50[\u03bc]\n      s :=\n  by\n  -- Need `@` below because of diamond; see gh issue #16932\n  rw [\u2190 ae_eq_set_compl_compl, @Filter.liminf_compl (Set \u03b1)]\n  rw [\u2190 ae_eq_set_compl_compl, \u2190 preimage_compl] at hs\n  convert hf.limsup_preimage_iterate_ae_eq hs\n  ext1 n\n  simp only [\u2190 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 : \u03b1 \u2192 \u03b1} (h : QuasiMeasurePreserving f \u03bc \u03bc)\n    (hs : MeasurableSet s) (hs' : f \u207b\u00b9' s =\u1d50[\u03bc] s) :\n    \u2203 t : Set \u03b1, MeasurableSet t \u2227 t =\u1d50[\u03bc] s \u2227 f \u207b\u00b9' t = t :=\n  \u27e8limsup (fun n => (preimage f^[n]) s) atTop,\n    MeasurableSet.measurableSet_limsup fun n =>\n      @preimage_iterate_eq \u03b1 f n \u25b8 h.Measurable.iterate n hs,\n    h.limsup_preimage_iterate_ae_eq hs', (CompleteLatticeHom.setPreimage f).apply_limsup_iterate s\u27e9\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 \u03b1 : Type _} [Group G] [MulAction G \u03b1] [MeasurableSpace \u03b1]\n    {s t : Set \u03b1} {\u03bc : Measure \u03b1} (g : G) (h_qmp : QuasiMeasurePreserving ((\u00b7 \u2022 \u00b7) g\u207b\u00b9 : \u03b1 \u2192 \u03b1) \u03bc \u03bc)\n    (h_ae_eq : s =\u1d50[\u03bc] t) : (g \u2022 s : Set \u03b1) =\u1d50[\u03bc] (g \u2022 t : Set \u03b1) := by\n  simpa only [\u2190 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 \u00abexpr \u2260 \u00bb (1 : G)) -/\n@[to_additive]\ntheorem pairwise_aeDisjoint_of_aeDisjoint_forall_ne_one {G \u03b1 : Type _} [Group G] [MulAction G \u03b1]\n    [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1} {s : Set \u03b1}\n    (h_ae_disjoint : \u2200 (g) (_ : g \u2260 (1 : G)), AeDisjoint \u03bc (g \u2022 s) s)\n    (h_qmp : \u2200 g : G, QuasiMeasurePreserving ((\u00b7 \u2022 \u00b7) g : \u03b1 \u2192 \u03b1) \u03bc \u03bc) :\n    Pairwise (AeDisjoint \u03bc on fun g : G => g \u2022 s) :=\n  by\n  intro g\u2081 g\u2082 hg\n  let g := g\u2082\u207b\u00b9 * g\u2081\n  replace hg : g \u2260 1\n  \u00b7 rw [Ne.def, inv_mul_eq_one]\n    exact hg.symm\n  have : (\u00b7 \u2022 \u00b7) g\u2082\u207b\u00b9 \u207b\u00b9' (g \u2022 s \u2229 s) = g\u2081 \u2022 s \u2229 g\u2082 \u2022 s := by\n    rw [preimage_eq_iff_eq_image (MulAction.bijective g\u2082\u207b\u00b9), image_smul, smul_set_inter, smul_smul,\n      smul_smul, inv_mul_self, one_smul]\n  change \u03bc (g\u2081 \u2022 s \u2229 g\u2082 \u2022 s) = 0\n  exact this \u25b8 (h_qmp g\u2082\u207b\u00b9).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\u1d9c` has finite measure. -/\ndef cofinite {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) : Filter \u03b1\n    where\n  sets := { s | \u03bc (s\u1d9c) < \u221e }\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      \u03bc (s\u1d9c \u222a t\u1d9c) \u2264 \u03bc (s\u1d9c) + \u03bc (t\u1d9c) := measure_union_le _ _\n      _ < \u221e := ENNReal.add_lt_top.2 \u27e8hs, ht\u27e9\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 \u2208 \u03bc.cofinite \u2194 \u03bc (s\u1d9c) < \u221e :=\n  Iff.rfl\n#align measure_theory.measure.mem_cofinite MeasureTheory.Measure.mem_cofinite\n\ntheorem compl_mem_cofinite : s\u1d9c \u2208 \u03bc.cofinite \u2194 \u03bc s < \u221e := by rw [mem_cofinite, compl_compl]\n#align measure_theory.measure.compl_mem_cofinite MeasureTheory.Measure.compl_mem_cofinite\n\ntheorem eventually_cofinite {p : \u03b1 \u2192 Prop} : (\u2200\u1da0 x in \u03bc.cofinite, p x) \u2194 \u03bc { x | \u00acp x } < \u221e :=\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 {\u03bd : Measure \u03b2} {f : \u03b1 \u2192 \u03b2} {t : Set \u03b2}\n    (ht : NullMeasurableSet t \u03bd) (hf : QuasiMeasurePreserving f \u03bc \u03bd) :\n    NullMeasurableSet (f \u207b\u00b9' t) \u03bc :=\n  \u27e8f \u207b\u00b9' toMeasurable \u03bd t, hf.Measurable (measurableSet_toMeasurable _ _),\n    hf.ae_eq ht.toMeasurable_ae_eq.symm\u27e9\n#align measure_theory.null_measurable_set.preimage MeasureTheory.NullMeasurableSet.preimage\n\ntheorem NullMeasurableSet.monoAc (h : NullMeasurableSet s \u03bc) (hle : \u03bd \u226a \u03bc) :\n    NullMeasurableSet s \u03bd :=\n  h.Preimage <| (QuasiMeasurePreserving.id \u03bc).mono_left hle\n#align measure_theory.null_measurable_set.mono_ac MeasureTheory.NullMeasurableSet.monoAc\n\ntheorem NullMeasurableSet.mono (h : NullMeasurableSet s \u03bc) (hle : \u03bd \u2264 \u03bc) : NullMeasurableSet s \u03bd :=\n  h.monoAc hle.AbsolutelyContinuous\n#align measure_theory.null_measurable_set.mono MeasureTheory.NullMeasurableSet.mono\n\ntheorem AeDisjoint.preimage {\u03bd : Measure \u03b2} {f : \u03b1 \u2192 \u03b2} {s t : Set \u03b2} (ht : AeDisjoint \u03bd s t)\n    (hf : QuasiMeasurePreserving f \u03bc \u03bd) : AeDisjoint \u03bc (f \u207b\u00b9' s) (f \u207b\u00b9' t) :=\n  hf.preimage_null ht\n#align measure_theory.ae_disjoint.preimage MeasureTheory.AeDisjoint.preimage\n\n@[simp]\ntheorem ae_eq_bot : \u03bc.ae = \u22a5 \u2194 \u03bc = 0 := by\n  rw [\u2190 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 : \u03bc.ae.ne_bot \u2194 \u03bc \u2260 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 \u03b1} : (0 : Measure \u03b1).ae = \u22a5 :=\n  ae_eq_bot.2 rfl\n#align measure_theory.ae_zero MeasureTheory.ae_zero\n\n@[mono]\ntheorem ae_mono (h : \u03bc \u2264 \u03bd) : \u03bc.ae \u2264 \u03bd.ae :=\n  h.AbsolutelyContinuous.ae_le\n#align measure_theory.ae_mono MeasureTheory.ae_mono\n\ntheorem mem_ae_map_iff {f : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) {s : Set \u03b2} (hs : MeasurableSet s) :\n    s \u2208 (\u03bc.map f).ae \u2194 f \u207b\u00b9' s \u2208 \u03bc.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 : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) {s : Set \u03b2}\n    (hs : s \u2208 (\u03bc.map f).ae) : f \u207b\u00b9' s \u2208 \u03bc.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 : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) {p : \u03b2 \u2192 Prop}\n    (hp : MeasurableSet { x | p x }) : (\u2200\u1d50 y \u2202\u03bc.map f, p y) \u2194 \u2200\u1d50 x \u2202\u03bc, 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 : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) {p : \u03b2 \u2192 Prop} (h : \u2200\u1d50 y \u2202\u03bc.map f, p y) :\n    \u2200\u1d50 x \u2202\u03bc, 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 \u03b1} (f : \u03b1 \u2192 \u03b2) (hf : MeasurableSet (range f))\n    (\u03bc : Measure \u03b1) : \u2200\u1d50 x \u2202\u03bc.map f, x \u2208 range f :=\n  by\n  by_cases h : AeMeasurable f \u03bc\n  \u00b7 change range f \u2208 (\u03bc.map f).ae\n    rw [mem_ae_map_iff h hf]\n    apply eventually_of_forall\n    exact mem_range_self\n  \u00b7 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\u1d62_eq [Countable \u03b9] (s : \u03b9 \u2192 Set \u03b1) :\n    (\u03bc.restrict (\u22c3 i, s i)).ae = \u2a06 i, (\u03bc.restrict (s i)).ae :=\n  le_antisymm ((ae_sum_eq fun i => \u03bc.restrict (s i)) \u25b8 ae_mono restrict_union\u1d62_le) <|\n    sup\u1d62_le fun i => ae_mono <| restrict_mono (subset_union\u1d62 s i) le_rfl\n#align measure_theory.ae_restrict_Union_eq MeasureTheory.ae_restrict_union\u1d62_eq\n\n@[simp]\ntheorem ae_restrict_union_eq (s t : Set \u03b1) :\n    (\u03bc.restrict (s \u222a t)).ae = (\u03bc.restrict s).ae \u2294 (\u03bc.restrict t).ae := by\n  simp [union_eq_Union, sup\u1d62_bool_eq]\n#align measure_theory.ae_restrict_union_eq MeasureTheory.ae_restrict_union_eq\n\ntheorem ae_restrict_bUnion_eq (s : \u03b9 \u2192 Set \u03b1) {t : Set \u03b9} (ht : t.Countable) :\n    (\u03bc.restrict (\u22c3 i \u2208 t, s i)).ae = \u2a06 i \u2208 t, (\u03bc.restrict (s i)).ae :=\n  by\n  haveI := ht.to_subtype\n  rw [bUnion_eq_Union, ae_restrict_Union_eq, \u2190 sup\u1d62_subtype'']\n#align measure_theory.ae_restrict_bUnion_eq MeasureTheory.ae_restrict_bUnion_eq\n\ntheorem ae_restrict_bUnion_finset_eq (s : \u03b9 \u2192 Set \u03b1) (t : Finset \u03b9) :\n    (\u03bc.restrict (\u22c3 i \u2208 t, s i)).ae = \u2a06 i \u2208 t, (\u03bc.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\u1d62_iff [Countable \u03b9] (s : \u03b9 \u2192 Set \u03b1) (p : \u03b1 \u2192 Prop) :\n    (\u2200\u1d50 x \u2202\u03bc.restrict (\u22c3 i, s i), p x) \u2194 \u2200 i, \u2200\u1d50 x \u2202\u03bc.restrict (s i), p x := by simp\n#align measure_theory.ae_restrict_Union_iff MeasureTheory.ae_restrict_union\u1d62_iff\n\ntheorem ae_restrict_union_iff (s t : Set \u03b1) (p : \u03b1 \u2192 Prop) :\n    (\u2200\u1d50 x \u2202\u03bc.restrict (s \u222a t), p x) \u2194 (\u2200\u1d50 x \u2202\u03bc.restrict s, p x) \u2227 \u2200\u1d50 x \u2202\u03bc.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 : \u03b9 \u2192 Set \u03b1) {t : Set \u03b9} (ht : t.Countable) (p : \u03b1 \u2192 Prop) :\n    (\u2200\u1d50 x \u2202\u03bc.restrict (\u22c3 i \u2208 t, s i), p x) \u2194 \u2200 i \u2208 t, \u2200\u1d50 x \u2202\u03bc.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 : \u03b9 \u2192 Set \u03b1) (t : Finset \u03b9) (p : \u03b1 \u2192 Prop) :\n    (\u2200\u1d50 x \u2202\u03bc.restrict (\u22c3 i \u2208 t, s i), p x) \u2194 \u2200 i \u2208 t, \u2200\u1d50 x \u2202\u03bc.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\u1d62_iff [Countable \u03b9] (s : \u03b9 \u2192 Set \u03b1) (f g : \u03b1 \u2192 \u03b4) :\n    f =\u1d50[\u03bc.restrict (\u22c3 i, s i)] g \u2194 \u2200 i, f =\u1d50[\u03bc.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\u1d62_iff\n\ntheorem ae_eq_restrict_bUnion_iff (s : \u03b9 \u2192 Set \u03b1) {t : Set \u03b9} (ht : t.Countable) (f g : \u03b1 \u2192 \u03b4) :\n    f =\u1d50[\u03bc.restrict (\u22c3 i \u2208 t, s i)] g \u2194 \u2200 i \u2208 t, f =\u1d50[\u03bc.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 : \u03b9 \u2192 Set \u03b1) (t : Finset \u03b9) (f g : \u03b1 \u2192 \u03b4) :\n    f =\u1d50[\u03bc.restrict (\u22c3 i \u2208 t, s i)] g \u2194 \u2200 i \u2208 t, f =\u1d50[\u03bc.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 \u03b1] (a b : \u03b1) :\n    (\u03bc.restrict (\u0399 a b)).ae = (\u03bc.restrict (Ioc a b)).ae \u2294 (\u03bc.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 \u03b1] {a b : \u03b1} {P : \u03b1 \u2192 Prop} :\n    (\u2200\u1d50 x \u2202\u03bc.restrict (\u0399 a b), P x) \u2194\n      (\u2200\u1d50 x \u2202\u03bc.restrict (Ioc a b), P x) \u2227 \u2200\u1d50 x \u2202\u03bc.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 : \u03b1 \u2192 Prop} (hp : MeasurableSet { x | p x }) :\n    (\u2200\u1d50 x \u2202\u03bc.restrict s, p x) \u2194 \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 p x :=\n  by\n  simp only [ae_iff, \u2190 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 \u03b1} {p : \u03b1 \u2192 Prop} (h : \u2200\u1d50 x \u2202\u03bc.restrict s, p x) :\n    \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 p x := by\n  simp only [ae_iff] at h\u22a2\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 : \u03b1 \u2192 Prop} (hs : MeasurableSet s) :\n    (\u2200\u1d50 x \u2202\u03bc.restrict s, p x) \u2194 \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 p x :=\n  by\n  simp only [ae_iff, \u2190 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 : \u03b1 \u2192 \u03b4} {s : Set \u03b1} (hfg : f =\u1d50[\u03bc] g) :\n    f =\u1d50[\u03bc.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) : \u2200\u1d50 x \u2202\u03bc.restrict s, x \u2208 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\u2080 (hs : NullMeasurableSet s \u03bc) : \u2200\u1d50 x \u2202\u03bc.restrict s, x \u2208 s :=\n  by\n  rcases hs.exists_measurable_subset_ae_eq with \u27e8t, hts, htm, ht_eq\u27e9\n  rw [\u2190 restrict_congr_set ht_eq]\n  exact (ae_restrict_mem htm).mono hts\n#align measure_theory.ae_restrict_mem\u2080 MeasureTheory.ae_restrict_mem\u2080\n\ntheorem ae_restrict_of_ae {s : Set \u03b1} {p : \u03b1 \u2192 Prop} (h : \u2200\u1d50 x \u2202\u03bc, p x) : \u2200\u1d50 x \u2202\u03bc.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'\u2080 {p : \u03b1 \u2192 Prop} (hs : NullMeasurableSet s \u03bc) :\n    (\u2200\u1d50 x \u2202\u03bc.restrict s, p x) \u2194 \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 p x :=\n  by\n  refine' \u27e8fun h => ae_imp_of_ae_restrict h, fun h => _\u27e9\n  filter_upwards [ae_restrict_mem\u2080 hs, ae_restrict_of_ae h]with x hx h'x using h'x hx\n#align measure_theory.ae_restrict_iff'\u2080 MeasureTheory.ae_restrict_iff'\u2080\n\ntheorem ae_restrict_of_ae_restrict_of_subset {s t : Set \u03b1} {p : \u03b1 \u2192 Prop} (hst : s \u2286 t)\n    (h : \u2200\u1d50 x \u2202\u03bc.restrict t, p x) : \u2200\u1d50 x \u2202\u03bc.restrict s, p x :=\n  h.filter_mono (ae_mono <| Measure.restrict_mono hst (le_refl \u03bc))\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 \u03b1) {p : \u03b1 \u2192 Prop}\n    (ht : \u2200\u1d50 x \u2202\u03bc.restrict t, p x) (htc : \u2200\u1d50 x \u2202\u03bc.restrict (t\u1d9c), p x) : \u2200\u1d50 x \u2202\u03bc, p x :=\n  nonpos_iff_eq_zero.1 <|\n    calc\n      \u03bc { x | \u00acp x } = \u03bc ({ x | \u00acp x } \u2229 t \u222a { x | \u00acp x } \u2229 t\u1d9c) := by\n        rw [\u2190 inter_union_distrib_left, union_compl_self, inter_univ]\n      _ \u2264 \u03bc ({ x | \u00acp x } \u2229 t) + \u03bc ({ x | \u00acp x } \u2229 t\u1d9c) := (measure_union_le _ _)\n      _ \u2264 \u03bc.restrict t { x | \u00acp x } + \u03bc.restrict (t\u1d9c) { x | \u00acp 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 {\u03b2} {s : Set \u03b1} {t : Set \u03b2} {f : \u03b1 \u2192 \u03b2} (hs : MeasurableSet s) :\n    t \u2208 Filter.map f (\u03bc.restrict s).ae \u2194 \u03bc ((f \u207b\u00b9' t)\u1d9c \u2229 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 : \u03b1 \u2192 Prop} [Monoid R] [DistribMulAction R \u211d\u22650\u221e]\n    [IsScalarTower R \u211d\u22650\u221e \u211d\u22650\u221e] (h : \u2200\u1d50 x \u2202\u03bc, p x) (c : R) : \u2200\u1d50 x \u2202c \u2022 \u03bc, 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 : \u03b1 \u2192 Prop} {\u03bd} :\n    (\u2200\u1d50 x \u2202\u03bc + \u03bd, p x) \u2194 (\u2200\u1d50 x \u2202\u03bc, p x) \u2227 \u2200\u1d50 x \u2202\u03bd, 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' {\u03bd : Measure \u03b2} {f : \u03b1 \u2192 \u03b2} {g g' : \u03b2 \u2192 \u03b4} (hf : AeMeasurable f \u03bc)\n    (h : g =\u1d50[\u03bd] g') (h2 : \u03bc.map f \u226a \u03bd) : g \u2218 f =\u1d50[\u03bc] g' \u2218 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 {\u03bd : Measure \u03b2} {f : \u03b1 \u2192 \u03b2} {g g' : \u03b2 \u2192 \u03b4}\n    (hf : QuasiMeasurePreserving f \u03bc \u03bd) (h : g =\u1d50[\u03bd] g') : g \u2218 f =\u1d50[\u03bc] g' \u2218 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 : \u03b1 \u2192 \u03b2} {g g' : \u03b2 \u2192 \u03b4} (hf : AeMeasurable f \u03bc) (h : g =\u1d50[\u03bc.map f] g') :\n    g \u2218 f =\u1d50[\u03bc] g' \u2218 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 {\u03b2} [AddGroup \u03b2] (f g : \u03b1 \u2192 \u03b2) : f - g =\u1d50[\u03bc] 0 \u2194 f =\u1d50[\u03bc] g :=\n  by\n  refine' \u27e8fun h => h.mono fun x hx => _, fun h => h.mono fun x hx => _\u27e9\n  \u00b7 rwa [Pi.sub_apply, Pi.zero_apply, sub_eq_zero] at hx\n  \u00b7 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 : \u03bc.ae \u2293 \ud835\udcdf s \u2264 (\u03bc.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) : (\u03bc.restrict s).ae = \u03bc.ae \u2293 \ud835\udcdf 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' (_ \u2208 s)]\n  rfl\n#align measure_theory.ae_restrict_eq MeasureTheory.ae_restrict_eq\n\n@[simp]\ntheorem ae_restrict_eq_bot {s} : (\u03bc.restrict s).ae = \u22a5 \u2194 \u03bc 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} : (\u03bc.restrict s).ae.ne_bot \u2194 0 < \u03bc 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 \u2208 (\u03bc.restrict s).ae := by\n  simp only [ae_restrict_eq hs, exists_prop, mem_principal, mem_inf_iff] <;>\n    exact \u27e8_, univ_mem, s, subset.rfl, (univ_inter s).symm\u27e9\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 =\u1d50[\u03bc] t) {p : \u03b1 \u2192 Prop} :\n    (\u2200\u1d50 x \u2202\u03bc.restrict s, p x) \u2192 \u2200\u1d50 x \u2202\u03bc.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 =\u1d50[\u03bc] t) {p : \u03b1 \u2192 Prop} :\n    (\u2200\u1d50 x \u2202\u03bc.restrict s, p x) \u2194 \u2200\u1d50 x \u2202\u03bc.restrict t, p x :=\n  \u27e8ae_restrict_of_ae_eq_of_ae_restrict hst, ae_restrict_of_ae_eq_of_ae_restrict hst.symm\u27e9\n#align measure_theory.ae_restrict_congr_set MeasureTheory.ae_restrict_congr_set\n\n/-- A version of the **Borel-Cantelli lemma**: if `p\u1d62` is a sequence of predicates such that\n`\u2211 \u03bc {x | p\u1d62 x}` is finite, then the measure of `x` such that `p\u1d62 x` holds frequently as `i \u2192 \u221e` (or\nequivalently, `p\u1d62 x` holds for infinitely many `i`) is equal to zero. -/\ntheorem measure_setOf_frequently_eq_zero {p : \u2115 \u2192 \u03b1 \u2192 Prop} (hp : (\u2211' i, \u03bc { x | p i x }) \u2260 \u221e) :\n    \u03bc { x | \u2203\u1da0 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\u1d62` is a sequence of sets such that\n`\u2211 \u03bc s\u1d62` exists, then for almost all `x`, `x` does not belong to almost all `s\u1d62`. -/\ntheorem ae_eventually_not_mem {s : \u2115 \u2192 Set \u03b1} (hs : (\u2211' i, \u03bc (s i)) \u2260 \u221e) :\n    \u2200\u1d50 x \u2202\u03bc, \u2200\u1da0 n in atTop, x \u2209 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 \u03b1] {s : Set \u03b1} (hsc : s.Countable)\n    (hst : \u2200 x : \u03b1, \u2203 y \u2208 s, x \u2264 y) (hdir : DirectedOn (\u00b7 \u2264 \u00b7) s) : (\u2a06 x \u2208 s, \u03bc (Iic x)) = \u03bc univ :=\n  by\n  rw [\u2190 measure_bUnion_eq_supr hsc]\n  \u00b7 congr\n    exact Union\u2082_eq_univ_iff.2 hst\n  \u00b7 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 \u03b1] {a b : \u03b1}\n\ntheorem Iio_ae_eq_Iic' (ha : \u03bc {a} = 0) : Iio a =\u1d50[\u03bc] Iic a := by\n  rw [\u2190 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 : \u03bc {a} = 0) : Ioi a =\u1d50[\u03bc] Ici a :=\n  @Iio_ae_eq_Iic' \u03b1\u1d52\u1d48 \u2039_\u203a \u2039_\u203a _ _ ha\n#align measure_theory.Ioi_ae_eq_Ici' MeasureTheory.Ioi_ae_eq_Ici'\n\ntheorem Ioo_ae_eq_Ioc' (hb : \u03bc {b} = 0) : Ioo a b =\u1d50[\u03bc] 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 : \u03bc {a} = 0) : Ioc a b =\u1d50[\u03bc] 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 : \u03bc {a} = 0) : Ioo a b =\u1d50[\u03bc] 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 : \u03bc {a} = 0) (hb : \u03bc {b} = 0) : Ioo a b =\u1d50[\u03bc] 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 : \u03bc {b} = 0) : Ico a b =\u1d50[\u03bc] 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 : \u03bc {a} = 0) (hb : \u03bc {b} = 0) : Ico a b =\u1d50[\u03bc] 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 \u03b1]\n\ntheorem mem_ae_dirac_iff {a : \u03b1} (hs : MeasurableSet s) : s \u2208 (dirac a).ae \u2194 a \u2208 s := by\n  by_cases a \u2208 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 : \u03b1} {p : \u03b1 \u2192 Prop} (hp : MeasurableSet { x | p x }) :\n    (\u2200\u1d50 x \u2202dirac a, p x) \u2194 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 \u03b1] (a : \u03b1) : (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 \u03b2] {a : \u03b1} {f : \u03b1 \u2192 \u03b2} (hf : Measurable f) :\n    f =\u1d50[dirac a] const \u03b1 (f a) :=\n  (ae_dirac_iff <| show MeasurableSet (f \u207b\u00b9' {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 \u03b1] {a : \u03b1} (f : \u03b1 \u2192 \u03b4) :\n    f =\u1d50[dirac a] const \u03b1 (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 `\u03bc` is called finite if `\u03bc univ < \u221e`. -/\nclass IsFiniteMeasure (\u03bc : Measure \u03b1) : Prop where\n  measure_univ_lt_top : \u03bc univ < \u221e\n#align measure_theory.is_finite_measure MeasureTheory.IsFiniteMeasure\n\ntheorem not_isFiniteMeasure_iff : \u00acIsFiniteMeasure \u03bc \u2194 \u03bc Set.univ = \u221e :=\n  by\n  refine' \u27e8fun h => _, fun h => fun h' => h'.measure_univ_lt_top.ne h\u27e9\n  by_contra h'\n  exact h \u27e8lt_top_iff_ne_top.mpr h'\u27e9\n#align measure_theory.not_is_finite_measure_iff MeasureTheory.not_isFiniteMeasure_iff\n\ninstance Restrict.isFiniteMeasure (\u03bc : Measure \u03b1) [hs : Fact (\u03bc s < \u221e)] :\n    IsFiniteMeasure (\u03bc.restrict s) :=\n  \u27e8by simp [hs.elim]\u27e9\n#align measure_theory.restrict.is_finite_measure MeasureTheory.Restrict.isFiniteMeasure\n\ntheorem measure_lt_top (\u03bc : Measure \u03b1) [IsFiniteMeasure \u03bc] (s : Set \u03b1) : \u03bc s < \u221e :=\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 (\u03bc : Measure \u03b1) (s : Set \u03b1) [h : IsFiniteMeasure \u03bc] :\n    IsFiniteMeasure (\u03bc.restrict s) :=\n  \u27e8by simp [measure_lt_top \u03bc s]\u27e9\n#align measure_theory.is_finite_measure_restrict MeasureTheory.isFiniteMeasureRestrict\n\ntheorem measure_ne_top (\u03bc : Measure \u03b1) [IsFiniteMeasure \u03bc] (s : Set \u03b1) : \u03bc s \u2260 \u221e :=\n  ne_of_lt (measure_lt_top \u03bc s)\n#align measure_theory.measure_ne_top MeasureTheory.measure_ne_top\n\ntheorem measure_compl_le_add_of_le_add [IsFiniteMeasure \u03bc] (hs : MeasurableSet s)\n    (ht : MeasurableSet t) {\u03b5 : \u211d\u22650\u221e} (h : \u03bc s \u2264 \u03bc t + \u03b5) : \u03bc (t\u1d9c) \u2264 \u03bc (s\u1d9c) + \u03b5 :=\n  by\n  rw [measure_compl ht (measure_ne_top \u03bc _), measure_compl hs (measure_ne_top \u03bc _),\n    tsub_le_iff_right]\n  calc\n    \u03bc univ = \u03bc univ - \u03bc s + \u03bc s := (tsub_add_cancel_of_le <| measure_mono s.subset_univ).symm\n    _ \u2264 \u03bc univ - \u03bc s + (\u03bc t + \u03b5) := (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 \u03bc] (hs : MeasurableSet s) (ht : MeasurableSet t)\n    {\u03b5 : \u211d\u22650\u221e} : \u03bc (s\u1d9c) \u2264 \u03bc (t\u1d9c) + \u03b5 \u2194 \u03bc t \u2264 \u03bc s + \u03b5 :=\n  \u27e8fun h => compl_compl s \u25b8 compl_compl t \u25b8 measure_compl_le_add_of_le_add hs.compl ht.compl h,\n    measure_compl_le_add_of_le_add ht hs\u27e9\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 `\u211d\u22650`. -/\ndef measureUnivNnreal (\u03bc : Measure \u03b1) : \u211d\u22650 :=\n  (\u03bc univ).toNNReal\n#align measure_theory.measure_univ_nnreal MeasureTheory.measureUnivNnreal\n\n@[simp]\ntheorem coe_measureUnivNnreal (\u03bc : Measure \u03b1) [IsFiniteMeasure \u03bc] :\n    \u2191(measureUnivNnreal \u03bc) = \u03bc univ :=\n  ENNReal.coe_toNNReal (measure_ne_top \u03bc univ)\n#align measure_theory.coe_measure_univ_nnreal MeasureTheory.coe_measureUnivNnreal\n\ninstance isFiniteMeasureZero : IsFiniteMeasure (0 : Measure \u03b1) :=\n  \u27e8by simp\u27e9\n#align measure_theory.is_finite_measure_zero MeasureTheory.isFiniteMeasureZero\n\ninstance (priority := 100) isFiniteMeasureOfIsEmpty [IsEmpty \u03b1] : IsFiniteMeasure \u03bc :=\n  by\n  rw [eq_zero_of_is_empty \u03bc]\n  infer_instance\n#align measure_theory.is_finite_measure_of_is_empty MeasureTheory.isFiniteMeasureOfIsEmpty\n\n@[simp]\ntheorem measureUnivNnreal_zero : measureUnivNnreal (0 : Measure \u03b1) = 0 :=\n  rfl\n#align measure_theory.measure_univ_nnreal_zero MeasureTheory.measureUnivNnreal_zero\n\nomit m0\n\ninstance isFiniteMeasureAdd [IsFiniteMeasure \u03bc] [IsFiniteMeasure \u03bd] : IsFiniteMeasure (\u03bc + \u03bd)\n    where measure_univ_lt_top :=\n    by\n    rw [measure.coe_add, Pi.add_apply, ENNReal.add_lt_top]\n    exact \u27e8measure_lt_top _ _, measure_lt_top _ _\u27e9\n#align measure_theory.is_finite_measure_add MeasureTheory.isFiniteMeasureAdd\n\ninstance isFiniteMeasureSmulNnreal [IsFiniteMeasure \u03bc] {r : \u211d\u22650} : IsFiniteMeasure (r \u2022 \u03bc)\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 \u211d\u22650] [SMul R \u211d\u22650\u221e] [IsScalarTower R \u211d\u22650 \u211d\u22650\u221e]\n    [IsScalarTower R \u211d\u22650\u221e \u211d\u22650\u221e] [IsFiniteMeasure \u03bc] {r : R} : IsFiniteMeasure (r \u2022 \u03bc) :=\n  by\n  rw [\u2190 smul_one_smul \u211d\u22650 r \u03bc]\n  infer_instance\n#align measure_theory.is_finite_measure_smul_of_nnreal_tower MeasureTheory.isFiniteMeasureSmulOfNnrealTower\n\ntheorem isFiniteMeasureOfLe (\u03bc : Measure \u03b1) [IsFiniteMeasure \u03bc] (h : \u03bd \u2264 \u03bc) : IsFiniteMeasure \u03bd :=\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 \u03b1} (\u03bc : Measure \u03b1) [IsFiniteMeasure \u03bc]\n    (f : \u03b1 \u2192 \u03b2) : IsFiniteMeasure (\u03bc.map f) :=\n  by\n  by_cases hf : AeMeasurable f \u03bc\n  \u00b7 constructor\n    rw [map_apply_of_ae_measurable hf MeasurableSet.univ]\n    exact measure_lt_top \u03bc _\n  \u00b7 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 \u03bc] : measureUnivNnreal \u03bc = 0 \u2194 \u03bc = 0 :=\n  by\n  rw [\u2190 MeasureTheory.Measure.measure_univ_eq_zero, \u2190 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 \u03bc] (h\u03bc : \u03bc \u2260 0) : 0 < measureUnivNnreal \u03bc :=\n  by\n  contrapose! h\u03bc\n  simpa [measure_univ_nnreal_eq_zero, le_zero_iff] using h\u03bc\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 \u03bc is finite. -/\ntheorem Measure.le_of_add_le_add_left [IsFiniteMeasure \u03bc] (A2 : \u03bc + \u03bd\u2081 \u2264 \u03bc + \u03bd\u2082) : \u03bd\u2081 \u2264 \u03bd\u2082 :=\n  fun S B1 => ENNReal.le_of_add_le_add_left (MeasureTheory.measure_ne_top \u03bc 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\u03bc : IsFiniteMeasure \u03bc] {f : \u2115 \u2192 Set \u03b1}\n    (hf\u2081 : \u2200 i : \u2115, MeasurableSet (f i)) (hf\u2082 : Pairwise (Disjoint on f)) :\n    Summable fun x => (\u03bc (f x)).toReal :=\n  by\n  apply ENNReal.summable_toReal\n  rw [\u2190 MeasureTheory.measure_union\u1d62 hf\u2082 hf\u2081]\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 \u03bc] (hs : NullMeasurableSet s \u03bc) :\n    s =\u1d50[\u03bc] univ \u2194 \u03bc s = \u03bc univ :=\n  by\n  refine' \u27e8measure_congr, fun h => _\u27e9\n  obtain \u27e8t, -, ht\u2081, ht\u2082\u27e9 := hs.exists_measurable_subset_ae_eq\n  exact\n    ht\u2082.symm.trans\n      (ae_eq_of_subset_of_measure_ge (subset_univ t) (Eq.le ((measure_congr ht\u2082).trans h).symm) ht\u2081\n        (measure_ne_top \u03bc 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 \u03bc] {p : \u03b1 \u2192 Prop}\n    (hp : NullMeasurableSet { a | p a } \u03bc) : (\u2200\u1d50 a \u2202\u03bc, p a) \u2194 \u03bc { a | p a } = \u03bc univ := by\n  rw [\u2190 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 \u03bc] {s : Set \u03b1} (hs : NullMeasurableSet s \u03bc) :\n    (\u2200\u1d50 a \u2202\u03bc, a \u2208 s) \u2194 \u03bc s = \u03bc 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 \u03b1] [MeasurableSpace \u03b1] : IsFiniteMeasure (Measure.count : Measure \u03b1) :=\n  \u27e8by\n    cases nonempty_fintype \u03b1\n    simpa [measure.count_apply, tsum_fintype] using (ENNReal.nat_ne_top _).lt_top\u27e9\n\nend IsFiniteMeasure\n\nsection IsProbabilityMeasure\n\ninclude m0\n\n/-- A measure `\u03bc` is called a probability measure if `\u03bc univ = 1`. -/\nclass IsProbabilityMeasure (\u03bc : Measure \u03b1) : Prop where\n  measure_univ : \u03bc 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 (\u03bc : Measure \u03b1)\n    [IsProbabilityMeasure \u03bc] : IsFiniteMeasure \u03bc :=\n  \u27e8by simp only [measure_univ, ENNReal.one_lt_top]\u27e9\n#align measure_theory.is_probability_measure.to_is_finite_measure MeasureTheory.IsProbabilityMeasure.toIsFiniteMeasure\n\ntheorem IsProbabilityMeasure.ne_zero (\u03bc : Measure \u03b1) [IsProbabilityMeasure \u03bc] : \u03bc \u2260 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 \u03bc] : NeBot \u03bc.ae :=\n  ae_neBot.2 (IsProbabilityMeasure.ne_zero \u03bc)\n#align measure_theory.is_probability_measure.ae_ne_bot MeasureTheory.IsProbabilityMeasure.ae_neBot\n\nomit m0\n\ninstance Measure.dirac.isProbabilityMeasure [MeasurableSpace \u03b1] {x : \u03b1} :\n    IsProbabilityMeasure (dirac x) :=\n  \u27e8dirac_apply_of_mem <| mem_univ x\u27e9\n#align measure_theory.measure.dirac.is_probability_measure MeasureTheory.Measure.dirac.isProbabilityMeasure\n\ntheorem prob_add_prob_compl [IsProbabilityMeasure \u03bc] (h : MeasurableSet s) : \u03bc s + \u03bc (s\u1d9c) = 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 \u03bc] : \u03bc s \u2264 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 \u03bc] (h : \u03bc \u2260 0) :\n    IsProbabilityMeasure ((\u03bc univ)\u207b\u00b9 \u2022 \u03bc) :=\n  by\n  constructor\n  rw [smul_apply, smul_eq_mul, ENNReal.inv_mul_cancel]\n  \u00b7 rwa [Ne, measure_univ_eq_zero]\n  \u00b7 exact measure_ne_top _ _\n#align measure_theory.is_probability_measure_smul MeasureTheory.isProbabilityMeasureSmul\n\ntheorem isProbabilityMeasureMap [IsProbabilityMeasure \u03bc] {f : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc) :\n    IsProbabilityMeasure (map f \u03bc) :=\n  \u27e8by simp [map_apply_of_ae_measurable, hf]\u27e9\n#align measure_theory.is_probability_measure_map MeasureTheory.isProbabilityMeasureMap\n\n@[simp]\ntheorem one_le_prob_iff [IsProbabilityMeasure \u03bc] : 1 \u2264 \u03bc s \u2194 \u03bc s = 1 :=\n  \u27e8fun h => le_antisymm prob_le_one h, fun h => h \u25b8 le_refl _\u27e9\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 `\u211d\u22650\u221e`.\nThus the subtraction appearing is the truncated subtraction of `\u211d\u22650\u221e`, rather than the\nbetter-behaved subtraction of `\u211d`. -/\ntheorem prob_compl_eq_one_sub [IsProbabilityMeasure \u03bc] (hs : MeasurableSet s) : \u03bc (s\u1d9c) = 1 - \u03bc s :=\n  by simpa only [measure_univ] using measure_compl hs (measure_lt_top \u03bc 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 \u03bc] (hs : MeasurableSet s) :\n    \u03bc (s\u1d9c) = 0 \u2194 \u03bc 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 \u03bc] (hs : MeasurableSet s) :\n    \u03bc (s\u1d9c) = 1 \u2194 \u03bc s = 0 := by rwa [\u2190 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 `\u03bc` *has no atoms* if the measure of each singleton is zero.\n\nNB: Wikipedia assumes that for any measurable set `s` with positive `\u03bc`-measure,\nthere exists a measurable `t \u2286 s` such that `0 < \u03bc t < \u03bc s`. While this implies `\u03bc {x} = 0`,\nthe converse is not true. -/\nclass HasNoAtoms {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) : Prop where\n  measure_singleton : \u2200 x, \u03bc {x} = 0\n#align measure_theory.has_no_atoms MeasureTheory.HasNoAtoms\n\nexport HasNoAtoms (measure_singleton)\n\nattribute [simp] measure_singleton\n\nvariable [HasNoAtoms \u03bc]\n\ntheorem Set.Subsingleton.measure_zero {\u03b1 : Type _} {m : MeasurableSpace \u03b1} {s : Set \u03b1}\n    (hs : s.Subsingleton) (\u03bc : Measure \u03b1) [HasNoAtoms \u03bc] : \u03bc 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 : \u03b1} : \u03bc.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 \u03b1) : HasNoAtoms (\u03bc.restrict s) :=\n  by\n  refine' \u27e8fun x => _\u27e9\n  obtain \u27e8t, hxt, ht1, ht2\u27e9 := exists_measurable_superset_of_null (measure_singleton x : \u03bc {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 {\u03b1 : Type _} {m : MeasurableSpace \u03b1} {s : Set \u03b1}\n    (h : s.Countable) (\u03bc : Measure \u03b1) [HasNoAtoms \u03bc] : \u03bc s = 0 :=\n  by\n  rw [\u2190 bUnion_of_singleton s, \u2190 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 {\u03b1 : Type _} {m : MeasurableSpace \u03b1} {s : Set \u03b1} (h : s.Countable)\n    (\u03bc : Measure \u03b1) [HasNoAtoms \u03bc] : \u2200\u1d50 x \u2202\u03bc, x \u2209 s := by\n  simpa only [ae_iff, Classical.not_not] using h.measure_zero \u03bc\n#align set.countable.ae_not_mem Set.Countable.ae_not_mem\n\ntheorem Set.Finite.measure_zero {\u03b1 : Type _} {m : MeasurableSpace \u03b1} {s : Set \u03b1} (h : s.Finite)\n    (\u03bc : Measure \u03b1) [HasNoAtoms \u03bc] : \u03bc s = 0 :=\n  h.Countable.measure_zero \u03bc\n#align set.finite.measure_zero Set.Finite.measure_zero\n\ntheorem Finset.measure_zero {\u03b1 : Type _} {m : MeasurableSpace \u03b1} (s : Finset \u03b1) (\u03bc : Measure \u03b1)\n    [HasNoAtoms \u03bc] : \u03bc s = 0 :=\n  s.finite_toSet.measure_zero \u03bc\n#align finset.measure_zero Finset.measure_zero\n\ntheorem insert_ae_eq_self (a : \u03b1) (s : Set \u03b1) : (insert a s : Set \u03b1) =\u1d50[\u03bc] 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 \u03b1] {a b : \u03b1}\n\ntheorem Iio_ae_eq_Iic : Iio a =\u1d50[\u03bc] 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 =\u1d50[\u03bc] 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 =\u1d50[\u03bc] 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 =\u1d50[\u03bc] 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 =\u1d50[\u03bc] 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 =\u1d50[\u03bc] 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 =\u1d50[\u03bc] 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 =\u1d50[\u03bc] 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 \u03b1] {a b : \u03b1} : \u0399 a b =\u1d50[\u03bc] [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 {\u03b3} (f : \u03b1 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b3) (s : Set \u03b1) (hs_zero : \u03bc s = 0) :\n    (fun x => ite (x \u2208 s) (f x) (g x)) =\u1d50[\u03bc] g :=\n  by\n  have h_ss : s\u1d9c \u2286 { a : \u03b1 | ite (a \u2208 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 [\u2190 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 {\u03b3} (f : \u03b1 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b3) (s : Set \u03b1)\n    (hs_zero : \u03bc (s\u1d9c) = 0) : (fun x => ite (x \u2208 s) (f x) (g x)) =\u1d50[\u03bc] 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 \u2208 f`.\nEquivalently, it is eventually finite at `s` in `f.small_sets`. -/\ndef FiniteAtFilter {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) (f : Filter \u03b1) : Prop :=\n  \u2203 s \u2208 f, \u03bc s < \u221e\n#align measure_theory.measure.finite_at_filter MeasureTheory.Measure.FiniteAtFilter\n\ntheorem finiteAtFilterOfFinite {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) [IsFiniteMeasure \u03bc]\n    (f : Filter \u03b1) : \u03bc.FiniteAtFilter f :=\n  \u27e8univ, univ_mem, measure_lt_top \u03bc univ\u27e9\n#align measure_theory.measure.finite_at_filter_of_finite MeasureTheory.Measure.finiteAtFilterOfFinite\n\ntheorem FiniteAtFilter.exists_mem_basis {f : Filter \u03b1} (h\u03bc : FiniteAtFilter \u03bc f) {p : \u03b9 \u2192 Prop}\n    {s : \u03b9 \u2192 Set \u03b1} (hf : f.HasBasis p s) : \u2203 (i : _)(hi : p i), \u03bc (s i) < \u221e :=\n  (hf.exists_iff fun s t hst ht => (measure_mono hst).trans_lt ht).1 h\u03bc\n#align measure_theory.measure.finite_at_filter.exists_mem_basis MeasureTheory.Measure.FiniteAtFilter.exists_mem_basis\n\ntheorem finiteAtBot {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) : \u03bc.FiniteAtFilter \u22a5 :=\n  \u27e8\u2205, mem_bot, by simp only [measure_empty, WithTop.zero_lt_top]\u27e9\n#align measure_theory.measure.finite_at_bot MeasureTheory.Measure.finiteAtBot\n\n/-- `\u03bc` 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: `\u03bc` is \u03c3-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 \u03b1} (\u03bc : Measure \u03b1) (C : Set (Set \u03b1)) where\n  Set : \u2115 \u2192 Set \u03b1\n  set_mem : \u2200 i, Set i \u2208 C\n  Finite : \u2200 i, \u03bc (Set i) < \u221e\n  spanning : (\u22c3 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 `\u03bc` is called \u03c3-finite if there is a countable collection of sets\n `{ A i | i \u2208 \u2115 }` such that `\u03bc (A i) < \u221e` and `\u22c3 i, A i = s`. -/\nclass SigmaFinite {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) : Prop where\n  out' : Nonempty (\u03bc.FiniteSpanningSetsIn univ)\n#align measure_theory.sigma_finite MeasureTheory.SigmaFinite\n\ntheorem sigmaFinite_iff : SigmaFinite \u03bc \u2194 Nonempty (\u03bc.FiniteSpanningSetsIn univ) :=\n  \u27e8fun h => h.1, fun h => \u27e8h\u27e9\u27e9\n#align measure_theory.sigma_finite_iff MeasureTheory.sigmaFinite_iff\n\ntheorem SigmaFinite.out (h : SigmaFinite \u03bc) : Nonempty (\u03bc.FiniteSpanningSetsIn univ) :=\n  h.1\n#align measure_theory.sigma_finite.out MeasureTheory.SigmaFinite.out\n\ninclude m0\n\n/-- If `\u03bc` is \u03c3-finite it has finite spanning sets in the collection of all measurable sets. -/\ndef Measure.toFiniteSpanningSetsIn (\u03bc : Measure \u03b1) [h : SigmaFinite \u03bc] :\n    \u03bc.FiniteSpanningSetsIn { s | MeasurableSet s }\n    where\n  Set n := toMeasurable \u03bc (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\u1d62_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 (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (i : \u2115) : Set \u03b1 :=\n  Accumulate \u03bc.toFiniteSpanningSetsIn.Set i\n#align measure_theory.spanning_sets MeasureTheory.spanningSets\n\ntheorem monotone_spanningSets (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] : Monotone (spanningSets \u03bc) :=\n  monotone_accumulate\n#align measure_theory.monotone_spanning_sets MeasureTheory.monotone_spanningSets\n\ntheorem measurable_spanningSets (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (i : \u2115) :\n    MeasurableSet (spanningSets \u03bc i) :=\n  MeasurableSet.union\u1d62 fun j => MeasurableSet.union\u1d62 fun hij => \u03bc.toFiniteSpanningSetsIn.set_mem j\n#align measure_theory.measurable_spanning_sets MeasureTheory.measurable_spanningSets\n\ntheorem measure_spanningSets_lt_top (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (i : \u2115) :\n    \u03bc (spanningSets \u03bc i) < \u221e :=\n  measure_bUnion_lt_top (finite_le_nat i) fun j _ => (\u03bc.toFiniteSpanningSetsIn.Finite j).Ne\n#align measure_theory.measure_spanning_sets_lt_top MeasureTheory.measure_spanningSets_lt_top\n\ntheorem union\u1d62_spanningSets (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] : (\u22c3 i : \u2115, spanningSets \u03bc i) = univ :=\n  by simp_rw [spanning_sets, Union_accumulate, \u03bc.to_finite_spanning_sets_in.spanning]\n#align measure_theory.Union_spanning_sets MeasureTheory.union\u1d62_spanningSets\n\ntheorem isCountablySpanning_spanningSets (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] :\n    IsCountablySpanning (range (spanningSets \u03bc)) :=\n  \u27e8spanningSets \u03bc, mem_range_self, union\u1d62_spanningSets \u03bc\u27e9\n#align measure_theory.is_countably_spanning_spanning_sets MeasureTheory.isCountablySpanning_spanningSets\n\n/-- `spanning_sets_index \u03bc x` is the least `n : \u2115` such that `x \u2208 spanning_sets \u03bc n`. -/\ndef spanningSetsIndex (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (x : \u03b1) : \u2115 :=\n  Nat.find <| union\u1d62_eq_univ_iff.1 (union\u1d62_spanningSets \u03bc) x\n#align measure_theory.spanning_sets_index MeasureTheory.spanningSetsIndex\n\ntheorem measurable_spanningSetsIndex (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] :\n    Measurable (spanningSetsIndex \u03bc) :=\n  measurable_find _ <| measurable_spanningSets \u03bc\n#align measure_theory.measurable_spanning_sets_index MeasureTheory.measurable_spanningSetsIndex\n\ntheorem preimage_spanningSetsIndex_singleton (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (n : \u2115) :\n    spanningSetsIndex \u03bc \u207b\u00b9' {n} = disjointed (spanningSets \u03bc) n :=\n  preimage_find_eq_disjointed _ _ _\n#align measure_theory.preimage_spanning_sets_index_singleton MeasureTheory.preimage_spanningSetsIndex_singleton\n\ntheorem spanningSetsIndex_eq_iff (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] {x : \u03b1} {n : \u2115} :\n    spanningSetsIndex \u03bc x = n \u2194 x \u2208 disjointed (spanningSets \u03bc) n := by\n  convert Set.ext_iff.1 (preimage_spanning_sets_index_singleton \u03bc n) x\n#align measure_theory.spanning_sets_index_eq_iff MeasureTheory.spanningSetsIndex_eq_iff\n\ntheorem mem_disjointed_spanningSetsIndex (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (x : \u03b1) :\n    x \u2208 disjointed (spanningSets \u03bc) (spanningSetsIndex \u03bc x) :=\n  (spanningSetsIndex_eq_iff \u03bc).1 rfl\n#align measure_theory.mem_disjointed_spanning_sets_index MeasureTheory.mem_disjointed_spanningSetsIndex\n\ntheorem mem_spanningSetsIndex (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (x : \u03b1) :\n    x \u2208 spanningSets \u03bc (spanningSetsIndex \u03bc x) :=\n  disjointed_subset _ _ (mem_disjointed_spanningSetsIndex \u03bc x)\n#align measure_theory.mem_spanning_sets_index MeasureTheory.mem_spanningSetsIndex\n\ntheorem mem_spanningSets_of_index_le (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (x : \u03b1) {n : \u2115}\n    (hn : spanningSetsIndex \u03bc x \u2264 n) : x \u2208 spanningSets \u03bc n :=\n  monotone_spanningSets \u03bc hn (mem_spanningSetsIndex \u03bc x)\n#align measure_theory.mem_spanning_sets_of_index_le MeasureTheory.mem_spanningSets_of_index_le\n\ntheorem eventually_mem_spanningSets (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (x : \u03b1) :\n    \u2200\u1da0 n in atTop, x \u2208 spanningSets \u03bc n :=\n  eventually_atTop.2 \u27e8spanningSetsIndex \u03bc x, fun b => mem_spanningSets_of_index_le \u03bc x\u27e9\n#align measure_theory.eventually_mem_spanning_sets MeasureTheory.eventually_mem_spanningSets\n\nomit m0\n\nnamespace Measure\n\ntheorem sup\u1d62_restrict_spanningSets [SigmaFinite \u03bc] (hs : MeasurableSet s) :\n    (\u2a06 i, \u03bc.restrict (spanningSets \u03bc i) s) = \u03bc s :=\n  calc\n    (\u2a06 i, \u03bc.restrict (spanningSets \u03bc i) s) = \u03bc.restrict (\u22c3 i, spanningSets \u03bc i) s :=\n      (restrict_union\u1d62_apply_eq_sup\u1d62 (directed_of_sup (monotone_spanningSets \u03bc)) hs).symm\n    _ = \u03bc s := by rw [Union_spanning_sets, restrict_univ]\n    \n#align measure_theory.measure.supr_restrict_spanning_sets MeasureTheory.Measure.sup\u1d62_restrict_spanningSets\n\n/-- In a \u03c3-finite space, any measurable set of measure `> r` contains a measurable subset of\nfinite measure `> r`. -/\ntheorem exists_subset_measure_lt_top [SigmaFinite \u03bc] {r : \u211d\u22650\u221e} (hs : MeasurableSet s)\n    (h's : r < \u03bc s) : \u2203 t, MeasurableSet t \u2227 t \u2286 s \u2227 r < \u03bc t \u2227 \u03bc t < \u221e :=\n  by\n  rw [\u2190 supr_restrict_spanning_sets hs,\n    @lt_sup\u1d62_iff _ _ _ r fun i : \u2115 => \u03bc.restrict (spanning_sets \u03bc i) s] at h's\n  rcases h's with \u27e8n, hn\u27e9\n  simp only [restrict_apply hs] at hn\n  refine'\n    \u27e8s \u2229 spanning_sets \u03bc n, hs.inter (measurable_spanning_sets _ _), inter_subset_left _ _, hn, _\u27e9\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 \u03c3-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 \u03b1] {\u03bc : Measure \u03b1}\n    [SigmaFinite \u03bc] (s : Set \u03b1) : (\u2200 n, \u03bc (s \u2229 spanningSets \u03bc n) = 0) \u2194 \u03bc s = 0 :=\n  by\n  nth_rw 1 [show s = \u22c3 n, s \u2229 spanning_sets \u03bc n by\n      rw [\u2190 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 \u03c3-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 \u03b1] {\u03bc : Measure \u03b1} [SigmaFinite \u03bc]\n    (s : Set \u03b1) : (\u2203 n, 0 < \u03bc (s \u2229 spanningSets \u03bc n)) \u2194 0 < \u03bc s :=\n  by\n  rw [\u2190 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\u1d62 {\u03b9 : Type _} [MeasurableSpace \u03b1] (\u03bc : Measure \u03b1)\n    {\u03b5 : \u211d\u22650\u221e} (\u03b5_pos : 0 < \u03b5) {As : \u03b9 \u2192 Set \u03b1} (As_mble : \u2200 i : \u03b9, MeasurableSet (As i))\n    (As_disj : Pairwise (Disjoint on As)) (Union_As_finite : \u03bc (\u22c3 i, As i) \u2260 \u221e) :\n    Set.Finite { i : \u03b9 | \u03b5 \u2264 \u03bc (As i) } := by\n  by_contra con\n  have aux :=\n    lt_of_le_of_lt (tsum_meas_le_meas_Union_of_disjoint \u03bc 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 \u03b5_pos.ne.symm)\n#align measure_theory.measure.finite_const_le_meas_of_disjoint_Union MeasureTheory.Measure.finite_const_le_meas_of_disjoint_union\u1d62\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\u1d62_ne_top {\u03b9 : Type _} [MeasurableSpace \u03b1]\n    (\u03bc : Measure \u03b1) {As : \u03b9 \u2192 Set \u03b1} (As_mble : \u2200 i : \u03b9, MeasurableSet (As i))\n    (As_disj : Pairwise (Disjoint on As)) (Union_As_finite : \u03bc (\u22c3 i, As i) \u2260 \u221e) :\n    Set.Countable { i : \u03b9 | 0 < \u03bc (As i) } :=\n  by\n  set posmeas := { i : \u03b9 | 0 < \u03bc (As i) } with posmeas_def\n  rcases exists_seq_strictAnti_tendsto' (zero_lt_one : (0 : \u211d\u22650\u221e) < 1) with\n    \u27e8as, as_decr, as_mem, as_lim\u27e9\n  set fairmeas := fun n : \u2115 => { i : \u03b9 | as n \u2264 \u03bc (As i) } with fairmeas_def\n  have countable_union : posmeas = \u22c3 n, fairmeas n :=\n    by\n    have fairmeas_eq : \u2200 n, fairmeas n = (fun i => \u03bc (As i)) \u207b\u00b9' Ici (as n) := fun n => by\n      simpa only [fairmeas_def]\n    simpa only [fairmeas_eq, posmeas_def, \u2190 preimage_Union,\n      union\u1d62_Ici_eq_Ioi_of_lt_of_tendsto (0 : \u211d\u22650\u221e) (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 \u03bc (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\u1d62_ne_top\n\n/-- In a \u03c3-finite space, among disjoint measurable sets, only countably many can have positive\nmeasure. -/\ntheorem countable_meas_pos_of_disjoint_Union {\u03b9 : Type _} [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1}\n    [SigmaFinite \u03bc] {As : \u03b9 \u2192 Set \u03b1} (As_mble : \u2200 i : \u03b9, MeasurableSet (As i))\n    (As_disj : Pairwise (Disjoint on As)) : Set.Countable { i : \u03b9 | 0 < \u03bc (As i) } :=\n  by\n  have obs : { i : \u03b9 | 0 < \u03bc (As i) } \u2286 \u22c3 n, { i : \u03b9 | 0 < \u03bc (As i \u2229 spanning_sets \u03bc 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 \u03bc _ _ _\n  \u00b7 exact fun i => MeasurableSet.inter (As_mble i) (measurable_spanning_sets \u03bc n)\n  \u00b7\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  \u00b7 refine' (lt_of_le_of_lt (measure_mono _) (measure_spanning_sets_lt_top \u03bc 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 {\u03b1 \u03b2 : Type _} [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1}\n    [SigmaFinite \u03bc] [MeasurableSpace \u03b2] [MeasurableSingletonClass \u03b2] {g : \u03b1 \u2192 \u03b2}\n    (g_mble : Measurable g) : Set.Countable { t : \u03b2 | 0 < \u03bc { a : \u03b1 | g a = t } } :=\n  haveI level_sets_disjoint : Pairwise (Disjoint on fun t : \u03b2 => { a : \u03b1 | 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 (\u2039MeasurableSingletonClass \u03b2\u203a.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' \u00abexpr \u2287 \u00bb t) -/\n/-- If a set `t` is covered by a countable family of finite measure sets, then its measurable\nsuperset `to_measurable \u03bc t` (which has the same measure as `t`) satisfies,\nfor any measurable set `s`, the equality `\u03bc (to_measurable \u03bc t \u2229 s) = \u03bc (t \u2229 s)`. -/\ntheorem measure_toMeasurable_inter_of_cover {s : Set \u03b1} (hs : MeasurableSet s) {t : Set \u03b1}\n    {v : \u2115 \u2192 Set \u03b1} (hv : t \u2286 \u22c3 n, v n) (h'v : \u2200 n, \u03bc (t \u2229 v n) \u2260 \u221e) :\n    \u03bc (toMeasurable \u03bc t \u2229 s) = \u03bc (t \u2229 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    \u2203 (t' : _)(_ : t' \u2287 t), MeasurableSet t' \u2227 \u2200 u, MeasurableSet u \u2192 \u03bc (t' \u2229 u) = \u03bc (t \u2229 u) :=\n    by\n    let w n := to_measurable \u03bc (t \u2229 v n)\n    have hw : \u2200 n, \u03bc (w n) < \u221e := by\n      intro n\n      simp_rw [w, measure_to_measurable]\n      exact (h'v n).lt_top\n    set t' := \u22c3 n, to_measurable \u03bc (t \u2229 disjointed w n) with ht'\n    have tt' : t \u2286 t' :=\n      calc\n        t \u2286 \u22c3 n, t \u2229 disjointed w n :=\n          by\n          rw [\u2190 inter_Union, union\u1d62_disjointed, inter_Union]\n          intro x hx\n          rcases mem_Union.1 (hv hx) with \u27e8n, hn\u27e9\n          refine' mem_Union.2 \u27e8n, _\u27e9\n          have : x \u2208 t \u2229 v n := \u27e8hx, hn\u27e9\n          exact \u27e8hx, subset_to_measurable \u03bc _ this\u27e9\n        _ \u2286 \u22c3 n, to_measurable \u03bc (t \u2229 disjointed w n) :=\n          Union_mono fun n => subset_to_measurable _ _\n        \n    refine' \u27e8t', tt', MeasurableSet.union\u1d62 fun n => measurable_set_to_measurable \u03bc _, fun u hu => _\u27e9\n    apply le_antisymm _ (measure_mono (inter_subset_inter tt' subset.rfl))\n    calc\n      \u03bc (t' \u2229 u) \u2264 \u2211' n, \u03bc (to_measurable \u03bc (t \u2229 disjointed w n) \u2229 u) :=\n        by\n        rw [ht', Union_inter]\n        exact measure_Union_le _\n      _ = \u2211' n, \u03bc (t \u2229 disjointed w n \u2229 u) := by\n        congr 1\n        ext1 n\n        apply measure_to_measurable_inter hu\n        apply ne_of_lt\n        calc\n          \u03bc (t \u2229 disjointed w n) \u2264 \u03bc (t \u2229 w n) :=\n            measure_mono (inter_subset_inter_right _ (disjointed_le w n))\n          _ \u2264 \u03bc (w n) := (measure_mono (inter_subset_right _ _))\n          _ < \u221e := hw n\n          \n      _ = \u2211' n, \u03bc.restrict (t \u2229 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      _ = \u03bc.restrict (t \u2229 u) (\u22c3 n, disjointed w n) :=\n        by\n        rw [measure_Union]\n        \u00b7 exact disjoint_disjointed _\n        \u00b7 intro i\n          apply MeasurableSet.disjointed fun n => _\n          exact measurable_set_to_measurable _ _\n      _ \u2264 \u03bc.restrict (t \u2229 u) univ := (measure_mono (subset_univ _))\n      _ = \u03bc (t \u2229 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 \u03bc t`, which is enough to conclude the proof.\n  rw [to_measurable]\n  split_ifs with ht\n  \u00b7 apply measure_congr\n    exact ae_eq_set_inter ht.some_spec.snd.2 (ae_eq_refl _)\n  \u00b7 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 \u03b1} {v : \u2115 \u2192 Set \u03b1} (hv : s \u2286 \u22c3 n, v n)\n    (h'v : \u2200 n, \u03bc (s \u2229 v n) \u2260 \u221e) : \u03bc.restrict (toMeasurable \u03bc s) = \u03bc.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 \u03bc t` of `t` (which has the same measure as `t`)\nsatisfies, for any measurable set `s`, the equality `\u03bc (to_measurable \u03bc t \u2229 s) = \u03bc (t \u2229 s)`.\nThis only holds when `\u03bc` is \u03c3-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 \u03bc] {s : Set \u03b1} (hs : MeasurableSet s)\n    (t : Set \u03b1) : \u03bc (toMeasurable \u03bc t \u2229 s) = \u03bc (t \u2229 s) :=\n  by\n  have : t \u2286 \u22c3 n, spanning_sets \u03bc 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    \u03bc (t \u2229 spanning_sets \u03bc n) \u2264 \u03bc (spanning_sets \u03bc n) := measure_mono (inter_subset_right _ _)\n    _ < \u221e := measure_spanning_sets_lt_top \u03bc 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 \u03bc] (s : Set \u03b1) :\n    \u03bc.restrict (toMeasurable \u03bc s) = \u03bc.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 \u03b1)}\n\n/-- If `\u03bc` has finite spanning sets in `C` and `C \u2229 {s | \u03bc s < \u221e} \u2286 D` then `\u03bc` has finite spanning\nsets in `D`. -/\nprotected def mono' (h : \u03bc.FiniteSpanningSetsIn C) (hC : C \u2229 { s | \u03bc s < \u221e } \u2286 D) :\n    \u03bc.FiniteSpanningSetsIn D :=\n  \u27e8h.Set, fun i => hC \u27e8h.set_mem i, h.Finite i\u27e9, h.Finite, h.spanning\u27e9\n#align measure_theory.measure.finite_spanning_sets_in.mono' MeasureTheory.Measure.FiniteSpanningSetsIn.mono'\n\n/-- If `\u03bc` has finite spanning sets in `C` and `C \u2286 D` then `\u03bc` has finite spanning sets in `D`. -/\nprotected def mono (h : \u03bc.FiniteSpanningSetsIn C) (hC : C \u2286 D) : \u03bc.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 `\u03bc` has finite spanning sets in the collection of measurable sets `C`, then `\u03bc` is \u03c3-finite.\n-/\nprotected theorem sigmaFinite (h : \u03bc.FiniteSpanningSetsIn C) : SigmaFinite \u03bc :=\n  \u27e8\u27e8h.mono <| subset_univ C\u27e9\u27e9\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 {\u03bd : Measure \u03b1} {C : Set (Set \u03b1)} (hA : \u2039_\u203a = generateFrom C)\n    (hC : IsPiSystem C) (h : \u03bc.FiniteSpanningSetsIn C) (h_eq : \u2200 s \u2208 C, \u03bc s = \u03bd s) : \u03bc = \u03bd :=\n  ext_of_generateFrom_of_union\u1d62 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 : \u03bc.FiniteSpanningSetsIn C) : IsCountablySpanning C :=\n  \u27e8h.Set, h.set_mem, h.spanning\u27e9\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 \u03b1)} (hc : S.Countable) (h\u03bc : \u2200 s \u2208 S, \u03bc s < \u221e)\n    (hU : \u22c3\u2080 S = univ) : SigmaFinite \u03bc :=\n  by\n  obtain \u27e8s, h\u03bc, hs\u27e9 : \u2203 s : \u2115 \u2192 Set \u03b1, (\u2200 n, \u03bc (s n) < \u221e) \u2227 (\u22c3 n, s n) = univ\n  exact (@exists_seq_cover_iff_countable _ (fun x => \u03bc x < \u22a4) \u27e8\u2205, by simp\u27e9).2 \u27e8S, hc, h\u03bc, hU\u27e9\n  exact \u27e8\u27e8\u27e8fun n => s n, fun n => trivial, h\u03bc, hs\u27e9\u27e9\u27e9\n#align measure_theory.measure.sigma_finite_of_countable MeasureTheory.Measure.sigmaFiniteOfCountable\n\n/-- Given measures `\u03bc`, `\u03bd` where `\u03bd \u2264 \u03bc`, `finite_spanning_sets_in.of_le` provides the induced\n`finite_spanning_set` with respect to `\u03bd` from a `finite_spanning_set` with respect to `\u03bc`. -/\ndef FiniteSpanningSetsIn.ofLe (h : \u03bd \u2264 \u03bc) {C : Set (Set \u03b1)} (S : \u03bc.FiniteSpanningSetsIn C) :\n    \u03bd.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 (\u03bc : Measure \u03b1) [hs : SigmaFinite \u03bc] (h : \u03bd \u2264 \u03bc) : SigmaFinite \u03bd :=\n  \u27e8hs.out.map <| FiniteSpanningSetsIn.ofLe h\u27e9\n#align measure_theory.measure.sigma_finite_of_le MeasureTheory.Measure.sigmaFiniteOfLe\n\nend Measure\n\n/-- Every finite measure is \u03c3-finite. -/\ninstance (priority := 100) IsFiniteMeasure.toSigmaFinite {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1)\n    [IsFiniteMeasure \u03bc] : SigmaFinite \u03bc :=\n  \u27e8\u27e8\u27e8fun _ => univ, fun _ => trivial, fun _ => measure_lt_top \u03bc _, union\u1d62_const _\u27e9\u27e9\u27e9\n#align measure_theory.is_finite_measure.to_sigma_finite MeasureTheory.IsFiniteMeasure.toSigmaFinite\n\ntheorem sigmaFinite_bot_iff (\u03bc : @Measure \u03b1 \u22a5) : SigmaFinite \u03bc \u2194 IsFiniteMeasure \u03bc :=\n  by\n  refine'\n    \u27e8fun h => \u27e8_\u27e9, fun h => by\n      haveI := h\n      infer_instance\u27e9\n  haveI : sigma_finite \u03bc := h\n  let s := spanning_sets \u03bc\n  have hs_univ : (\u22c3 i, s i) = Set.univ := Union_spanning_sets \u03bc\n  have hs_meas : \u2200 i, measurable_set[\u22a5] (s i) := measurable_spanning_sets \u03bc\n  simp_rw [MeasurableSpace.measurableSet_bot_iff] at hs_meas\n  by_cases h_univ_empty : Set.univ = \u2205\n  \u00b7 rw [h_univ_empty, measure_empty]\n    exact ennreal.zero_ne_top.lt_top\n  obtain \u27e8i, hsi\u27e9 : \u2203 i, s i = Set.univ :=\n    by\n    by_contra h_not_univ\n    push_neg  at h_not_univ\n    have h_empty : \u2200 i, s i = \u2205 := 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 [\u2190 hsi]\n  exact measure_spanning_sets_lt_top \u03bc i\n#align measure_theory.sigma_finite_bot_iff MeasureTheory.sigmaFinite_bot_iff\n\ninclude m0\n\ninstance Restrict.sigmaFinite (\u03bc : Measure \u03b1) [SigmaFinite \u03bc] (s : Set \u03b1) :\n    SigmaFinite (\u03bc.restrict s) :=\n  by\n  refine' \u27e8\u27e8\u27e8spanning_sets \u03bc, fun _ => trivial, fun i => _, Union_spanning_sets \u03bc\u27e9\u27e9\u27e9\n  rw [restrict_apply (measurable_spanning_sets \u03bc i)]\n  exact (measure_mono <| inter_subset_left _ _).trans_lt (measure_spanning_sets_lt_top \u03bc i)\n#align measure_theory.restrict.sigma_finite MeasureTheory.Restrict.sigmaFinite\n\ninstance Sum.sigmaFinite {\u03b9} [Finite \u03b9] (\u03bc : \u03b9 \u2192 Measure \u03b1) [\u2200 i, SigmaFinite (\u03bc i)] :\n    SigmaFinite (Sum \u03bc) := by\n  cases nonempty_fintype \u03b9\n  have : \u2200 n, MeasurableSet (\u22c2 i : \u03b9, spanning_sets (\u03bc i) n) := fun n =>\n    MeasurableSet.inter\u1d62 fun i => measurable_spanning_sets (\u03bc i) n\n  refine' \u27e8\u27e8\u27e8fun n => \u22c2 i, spanning_sets (\u03bc i) n, fun _ => trivial, fun n => _, _\u27e9\u27e9\u27e9\n  \u00b7 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 (\u03bc i) n)\n  \u00b7 rw [Union_Inter_of_monotone]\n    simp_rw [Union_spanning_sets, Inter_univ]\n    exact fun i => monotone_spanning_sets (\u03bc i)\n#align measure_theory.sum.sigma_finite MeasureTheory.Sum.sigmaFinite\n\ninstance Add.sigmaFinite (\u03bc \u03bd : Measure \u03b1) [SigmaFinite \u03bc] [SigmaFinite \u03bd] : SigmaFinite (\u03bc + \u03bd) :=\n  by\n  rw [\u2190 sum_cond]\n  refine' @sum.sigma_finite _ _ _ _ _ (Bool.rec _ _) <;> simpa\n#align measure_theory.add.sigma_finite MeasureTheory.Add.sigmaFinite\n\ntheorem SigmaFinite.ofMap (\u03bc : Measure \u03b1) {f : \u03b1 \u2192 \u03b2} (hf : AeMeasurable f \u03bc)\n    (h : SigmaFinite (\u03bc.map f)) : SigmaFinite \u03bc :=\n  \u27e8\u27e8\u27e8fun n => f \u207b\u00b9' spanningSets (\u03bc.map f) n, fun n => trivial, fun n => by\n        simp only [\u2190 map_apply_of_ae_measurable hf, measurable_spanning_sets,\n          measure_spanning_sets_lt_top],\n        by rw [\u2190 preimage_Union, Union_spanning_sets, preimage_univ]\u27e9\u27e9\u27e9\n#align measure_theory.sigma_finite.of_map MeasureTheory.SigmaFinite.ofMap\n\ntheorem MeasurableEquiv.sigmaFiniteMap {\u03bc : Measure \u03b1} (f : \u03b1 \u2243\u1d50 \u03b2) (h : SigmaFinite \u03bc) :\n    SigmaFinite (\u03bc.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 \u03c3-finite measure has finite values on `s`. -/\ntheorem ae_of_forall_measure_lt_top_ae_restrict' {\u03bc : Measure \u03b1} (\u03bd : Measure \u03b1) [SigmaFinite \u03bc]\n    [SigmaFinite \u03bd] (P : \u03b1 \u2192 Prop)\n    (h : \u2200 s, MeasurableSet s \u2192 \u03bc s < \u221e \u2192 \u03bd s < \u221e \u2192 \u2200\u1d50 x \u2202\u03bc.restrict s, P x) : \u2200\u1d50 x \u2202\u03bc, P x :=\n  by\n  have : \u2200 n, \u2200\u1d50 x \u2202\u03bc, x \u2208 spanning_sets (\u03bc + \u03bd) n \u2192 P x :=\n    by\n    intro n\n    have := h (spanning_sets (\u03bc + \u03bd) 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 (\u03bc + \u03bd) _),\n      (self_le_add_left _ _).trans_lt (measure_spanning_sets_lt_top (\u03bc + \u03bd) _)]\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 \u03c3-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 {\u03bc : Measure \u03b1} [SigmaFinite \u03bc] (P : \u03b1 \u2192 Prop)\n    (h : \u2200 s, MeasurableSet s \u2192 \u03bc s < \u221e \u2192 \u2200\u1d50 x \u2202\u03bc.restrict s, P x) : \u2200\u1d50 x \u2202\u03bc, P x :=\n  ae_of_forall_measure_lt_top_ae_restrict' \u03bc 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 \u03b1] (\u03bc : Measure \u03b1) : Prop where\n  finiteAtNhds : \u2200 x, \u03bc.FiniteAtFilter (\ud835\udcdd x)\n#align measure_theory.is_locally_finite_measure MeasureTheory.IsLocallyFiniteMeasure\n\n-- see Note [lower instance priority]\ninstance (priority := 100) IsFiniteMeasure.toIsLocallyFiniteMeasure [TopologicalSpace \u03b1]\n    (\u03bc : Measure \u03b1) [IsFiniteMeasure \u03bc] : IsLocallyFiniteMeasure \u03bc :=\n  \u27e8fun x => finiteAtFilterOfFinite _ _\u27e9\n#align measure_theory.is_finite_measure.to_is_locally_finite_measure MeasureTheory.IsFiniteMeasure.toIsLocallyFiniteMeasure\n\ntheorem Measure.finiteAtNhds [TopologicalSpace \u03b1] (\u03bc : Measure \u03b1) [IsLocallyFiniteMeasure \u03bc]\n    (x : \u03b1) : \u03bc.FiniteAtFilter (\ud835\udcdd x) :=\n  IsLocallyFiniteMeasure.finiteAtNhds x\n#align measure_theory.measure.finite_at_nhds MeasureTheory.Measure.finiteAtNhds\n\ntheorem Measure.smulFinite (\u03bc : Measure \u03b1) [IsFiniteMeasure \u03bc] {c : \u211d\u22650\u221e} (hc : c \u2260 \u221e) :\n    IsFiniteMeasure (c \u2022 \u03bc) := by\n  lift c to \u211d\u22650 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 \u03b1] (\u03bc : Measure \u03b1)\n    [IsLocallyFiniteMeasure \u03bc] (x : \u03b1) : \u2203 s : Set \u03b1, x \u2208 s \u2227 IsOpen s \u2227 \u03bc s < \u221e := by\n  simpa only [exists_prop, and_assoc] using\n    (\u03bc.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 \u03b1] (\u03bc : Measure \u03b1)\n    [IsLocallyFiniteMeasure \u03bc] (c : \u211d\u22650) : IsLocallyFiniteMeasure (c \u2022 \u03bc) :=\n  by\n  refine' \u27e8fun x => _\u27e9\n  rcases \u03bc.exists_is_open_measure_lt_top x with \u27e8o, xo, o_open, \u03bco\u27e9\n  refine' \u27e8o, o_open.mem_nhds xo, _\u27e9\n  apply ENNReal.mul_lt_top _ \u03bco.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 \u03b1] (\u03bc : Measure \u03b1)\n    [IsLocallyFiniteMeasure \u03bc] : TopologicalSpace.IsTopologicalBasis { s | IsOpen s \u2227 \u03bc s < \u221e } :=\n  by\n  refine' TopologicalSpace.isTopologicalBasis_of_open_of_nhds (fun s hs => hs.1) _\n  intro x s xs hs\n  rcases \u03bc.exists_is_open_measure_lt_top x with \u27e8v, xv, hv, \u03bcv\u27e9\n  refine' \u27e8v \u2229 s, \u27e8hv.inter hs, lt_of_le_of_lt _ \u03bcv\u27e9, \u27e8xv, xs\u27e9, inter_subset_right _ _\u27e9\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 `\u03bc` is finite on compacts if any compact set `K` satisfies `\u03bc K < \u221e`. -/\n@[protect_proj]\nclass IsFiniteMeasureOnCompacts [TopologicalSpace \u03b1] (\u03bc : Measure \u03b1) : Prop where\n  lt_top_of_isCompact : \u2200 \u2983K : Set \u03b1\u2984, IsCompact K \u2192 \u03bc K < \u221e\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 \u03b1] {\u03bc : Measure \u03b1} [IsFiniteMeasureOnCompacts \u03bc]\n    \u2983K : Set \u03b1\u2984 (hK : IsCompact K) : \u03bc K < \u221e :=\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 \u03b1] [ProperSpace \u03b1] {\u03bc : Measure \u03b1}\n    [IsFiniteMeasureOnCompacts \u03bc] \u2983s : Set \u03b1\u2984 (hs : Metric.Bounded s) : \u03bc s < \u221e :=\n  calc\n    \u03bc s \u2264 \u03bc (closure s) := measure_mono subset_closure\n    _ < \u221e := (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 \u03b1] [ProperSpace \u03b1] {\u03bc : Measure \u03b1}\n    [IsFiniteMeasureOnCompacts \u03bc] {x : \u03b1} {r : \u211d} : \u03bc (Metric.closedBall x r) < \u221e :=\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 \u03b1] [ProperSpace \u03b1] {\u03bc : Measure \u03b1}\n    [IsFiniteMeasureOnCompacts \u03bc] {x : \u03b1} {r : \u211d} : \u03bc (Metric.ball x r) < \u221e :=\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 \u03b1] (\u03bc : Measure \u03b1)\n    [IsFiniteMeasureOnCompacts \u03bc] {c : \u211d\u22650\u221e} (hc : c \u2260 \u221e) : IsFiniteMeasureOnCompacts (c \u2022 \u03bc) :=\n  \u27e8fun K hK => ENNReal.mul_lt_top hc hK.measure_lt_top.Ne\u27e9\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 \u03b1] [CompactSpace \u03b1]\n    [IsFiniteMeasureOnCompacts \u03bc] : IsFiniteMeasure \u03bc :=\n  \u27e8IsFiniteMeasureOnCompacts.lt_top_of_isCompact isCompact_univ\u27e9\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 \u03b1]\n    [SecondCountableTopology \u03b1] [IsLocallyFiniteMeasure \u03bc] : SigmaFinite \u03bc :=\n  by\n  choose s hsx hs\u03bc using \u03bc.finite_at_nhds\n  rcases TopologicalSpace.countable_cover_nhds hsx with \u27e8t, htc, htU\u27e9\n  refine' measure.sigma_finite_of_countable (htc.image s) (ball_image_iff.2 fun x hx => hs\u03bc 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 \u03b1]\n    [LocallyCompactSpace \u03b1] [IsFiniteMeasureOnCompacts \u03bc] : IsLocallyFiniteMeasure \u03bc :=\n  \u27e8by\n    intro x\n    rcases exists_compact_mem_nhds x with \u27e8K, K_compact, K_mem\u27e9\n    exact \u27e8K, K_mem, K_compact.measure_lt_top\u27e9\u27e9\n#align measure_theory.is_locally_finite_measure_of_is_finite_measure_on_compacts MeasureTheory.isLocallyFiniteMeasureOfIsFiniteMeasureOnCompacts\n\ntheorem exists_pos_measure_of_cover [Countable \u03b9] {U : \u03b9 \u2192 Set \u03b1} (hU : (\u22c3 i, U i) = univ)\n    (h\u03bc : \u03bc \u2260 0) : \u2203 i, 0 < \u03bc (U i) := by\n  contrapose! h\u03bc with H\n  rw [\u2190 measure_univ_eq_zero, \u2190 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 \u03b4] (f : \u03b1 \u2192 \u03b4) (x : \u03b4) (h\u03bc : \u03bc \u2260 0) :\n    \u2203 n : \u2115, 0 < \u03bc (f \u207b\u00b9' Metric.ball x n) :=\n  exists_pos_measure_of_cover (by rw [\u2190 preimage_Union, Metric.union\u1d62_ball_nat, preimage_univ]) h\u03bc\n#align measure_theory.exists_pos_preimage_ball MeasureTheory.exists_pos_preimage_ball\n\ntheorem exists_pos_ball [PseudoMetricSpace \u03b1] (x : \u03b1) (h\u03bc : \u03bc \u2260 0) :\n    \u2203 n : \u2115, 0 < \u03bc (Metric.ball x n) :=\n  exists_pos_preimage_ball id x h\u03bc\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 \u03b1] [SecondCountableTopology \u03b1] (s : Set \u03b1)\n    (hs : \u2200 x \u2208 s, \u2203 u \u2208 \ud835\udcdd[s] x, \u03bc u = 0) : \u03bc s = 0 :=\n  \u03bc.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 \u03b1]\n    [SecondCountableTopology \u03b1] {s : Set \u03b1} (hs : \u03bc s \u2260 0) : \u2203 x \u2208 s, \u2200 t \u2208 \ud835\udcdd[s] x, 0 < \u03bc t :=\n  \u03bc.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 {\u03b2} [TopologicalSpace \u03b2] [T1Space \u03b2]\n    [SecondCountableTopology \u03b2] [Nonempty \u03b2] {f : \u03b1 \u2192 \u03b2} (h : \u2200 b, \u2203\u1d50 x \u2202\u03bc, f x \u2260 b) :\n    \u2203 a b : \u03b2, a \u2260 b \u2227 (\u2200 s \u2208 \ud835\udcdd a, 0 < \u03bc (f \u207b\u00b9' s)) \u2227 \u2200 t \u2208 \ud835\udcdd b, 0 < \u03bc (f \u207b\u00b9' t) :=\n  by\n  -- We use an `outer_measure` so that the proof works without `measurable f`\n  set m : outer_measure \u03b2 := outer_measure.map f \u03bc.to_outer_measure\n  replace h : \u2200 b : \u03b2, m ({b}\u1d9c) \u2260 0 := fun b => not_eventually.mpr (h b)\n  inhabit \u03b2\n  have : m univ \u2260 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 \u27e8b, -, hb\u27e9\n  simp only [nhdsWithin_univ] at hb\n  rcases m.exists_mem_forall_mem_nhds_within_pos (h b) with \u27e8a, hab : a \u2260 b, ha\u27e9\n  simp only [is_open_compl_singleton.nhds_within_eq hab] at ha\n  exact \u27e8a, b, hab, ha, hb\u27e9\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 \u03c0-system made\nof measurable sets, then they coincide on all sets in the \u03c3-algebra generated by the \u03c0-system. -/\ntheorem ext_on_measurableSpace_of_generate_finite {\u03b1} (m\u2080 : MeasurableSpace \u03b1) {\u03bc \u03bd : Measure \u03b1}\n    [IsFiniteMeasure \u03bc] (C : Set (Set \u03b1)) (h\u03bc\u03bd : \u2200 s \u2208 C, \u03bc s = \u03bd s) {m : MeasurableSpace \u03b1}\n    (h : m \u2264 m\u2080) (hA : m = MeasurableSpace.generateFrom C) (hC : IsPiSystem C)\n    (h_univ : \u03bc Set.univ = \u03bd Set.univ) {s : Set \u03b1} (hs : measurable_set[m] s) : \u03bc s = \u03bd s :=\n  by\n  haveI : is_finite_measure \u03bd := by\n    constructor\n    rw [\u2190 h_univ]\n    apply is_finite_measure.measure_univ_lt_top\n  refine' induction_on_inter hA hC (by simp) h\u03bc\u03bd _ _ hs\n  \u00b7 intro t h1t h2t\n    have h1t_ : @MeasurableSet \u03b1 m\u2080 t := h _ h1t\n    rw [@measure_compl \u03b1 m\u2080 \u03bc t h1t_ (@measure_ne_top \u03b1 m\u2080 \u03bc _ t),\n      @measure_compl \u03b1 m\u2080 \u03bd t h1t_ (@measure_ne_top \u03b1 m\u2080 \u03bd _ t), h_univ, h2t]\n  \u00b7 intro f h1f h2f h3f\n    have h2f_ : \u2200 i : \u2115, @MeasurableSet \u03b1 m\u2080 (f i) := fun i => h _ (h2f i)\n    have h_Union : @MeasurableSet \u03b1 m\u2080 (\u22c3 i : \u2115, f i) := @MeasurableSet.union\u1d62 \u03b1 \u2115 m\u2080 _ 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 \u03c0-system generating the \u03c3-algebra\n  (and `univ`). -/\ntheorem ext_of_generate_finite (C : Set (Set \u03b1)) (hA : m0 = generateFrom C) (hC : IsPiSystem C)\n    [IsFiniteMeasure \u03bc] (h\u03bc\u03bd : \u2200 s \u2208 C, \u03bc s = \u03bd s) (h_univ : \u03bc univ = \u03bd univ) : \u03bc = \u03bd :=\n  Measure.ext fun s hs => ext_on_measurableSpace_of_generate_finite m0 C h\u03bc\u03bd 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 : \u03bc.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 {\u03bc : Measure \u03b1}\n    (S : \u03bc.FiniteSpanningSetsIn { s | MeasurableSet s }) :\n    \u03bc.FiniteSpanningSetsIn { s | MeasurableSet s } :=\n  \u27e8disjointed 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 \u25b8 union\u1d62_disjointed\u27e9\n#align measure_theory.measure.finite_spanning_sets_in.disjointed MeasureTheory.Measure.FiniteSpanningSetsIn.disjointed\n\ntheorem FiniteSpanningSetsIn.disjointed_set_eq {\u03bc : Measure \u03b1}\n    (S : \u03bc.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 (\u03bc \u03bd : Measure \u03b1) [SigmaFinite \u03bc] [SigmaFinite \u03bd] :\n    \u2203 (S : \u03bc.FiniteSpanningSetsIn { s | MeasurableSet s })(T :\n      \u03bd.FiniteSpanningSetsIn { s | MeasurableSet s }),\n      S.Set = T.Set \u2227 Pairwise (Disjoint on S.Set) :=\n  let S := (\u03bc + \u03bd).toFiniteSpanningSetsIn.disjointed\n  \u27e8S.of_le (Measure.le_add_right le_rfl), S.of_le (Measure.le_add_left le_rfl), rfl,\n    disjoint_disjointed _\u27e9\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 \u03b1}\n\ntheorem filterMono (h : f \u2264 g) : \u03bc.FiniteAtFilter g \u2192 \u03bc.FiniteAtFilter f := fun \u27e8s, hs, h\u03bc\u27e9 =>\n  \u27e8s, h hs, h\u03bc\u27e9\n#align measure_theory.measure.finite_at_filter.filter_mono MeasureTheory.Measure.FiniteAtFilter.filterMono\n\ntheorem infOfLeft (h : \u03bc.FiniteAtFilter f) : \u03bc.FiniteAtFilter (f \u2293 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 : \u03bc.FiniteAtFilter g) : \u03bc.FiniteAtFilter (f \u2293 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 : \u03bc.FiniteAtFilter (f \u2293 \u03bc.ae) \u2194 \u03bc.FiniteAtFilter f :=\n  by\n  refine' \u27e8_, fun h => h.filter_mono inf_le_left\u27e9\n  rintro \u27e8s, \u27e8t, ht, u, hu, rfl\u27e9, h\u03bc\u27e9\n  suffices : \u03bc t \u2264 \u03bc (t \u2229 u); exact \u27e8t, ht, this.trans_lt h\u03bc\u27e9\n  exact measure_mono_ae (mem_of_superset hu fun x hu ht => \u27e8ht, hu\u27e9)\n#align measure_theory.measure.finite_at_filter.inf_ae_iff MeasureTheory.Measure.FiniteAtFilter.inf_ae_iff\n\nalias inf_ae_iff \u2194 of_inf_ae _\n#align measure_theory.measure.finite_at_filter.of_inf_ae MeasureTheory.Measure.FiniteAtFilter.ofInfAe\n\ntheorem filterMonoAe (h : f \u2293 \u03bc.ae \u2264 g) (hg : \u03bc.FiniteAtFilter g) : \u03bc.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 : \u03bc \u2264 \u03bd) : \u03bd.FiniteAtFilter f \u2192 \u03bc.FiniteAtFilter f :=\n  fun \u27e8s, hs, h\u03bd\u27e9 => \u27e8s, hs, (Measure.le_iff'.1 h s).trans_lt h\u03bd\u27e9\n#align measure_theory.measure.finite_at_filter.measure_mono MeasureTheory.Measure.FiniteAtFilter.measureMono\n\n@[mono]\nprotected theorem mono (hf : f \u2264 g) (h\u03bc : \u03bc \u2264 \u03bd) : \u03bd.FiniteAtFilter g \u2192 \u03bc.FiniteAtFilter f :=\n  fun h => (h.filter_mono hf).measure_mono h\u03bc\n#align measure_theory.measure.finite_at_filter.mono MeasureTheory.Measure.FiniteAtFilter.mono\n\nprotected theorem eventually (h : \u03bc.FiniteAtFilter f) : \u2200\u1da0 s in f.smallSets, \u03bc s < \u221e :=\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 : \u03bc.FiniteAtFilter f \u2192 \u03bc.FiniteAtFilter g \u2192 \u03bc.FiniteAtFilter (f \u2294 g) :=\n  fun \u27e8s, hsf, hs\u03bc\u27e9 \u27e8t, htg, ht\u03bc\u27e9 =>\n  \u27e8s \u222a t, union_mem_sup hsf htg, (measure_union_le s t).trans_lt (ENNReal.add_lt_top.2 \u27e8hs\u03bc, ht\u03bc\u27e9)\u27e9\n#align measure_theory.measure.finite_at_filter.filter_sup MeasureTheory.Measure.FiniteAtFilter.filterSup\n\nend FiniteAtFilter\n\ntheorem finiteAtNhdsWithin [TopologicalSpace \u03b1] {m0 : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1)\n    [IsLocallyFiniteMeasure \u03bc] (x : \u03b1) (s : Set \u03b1) : \u03bc.FiniteAtFilter (\ud835\udcdd[s] x) :=\n  (finiteAtNhds \u03bc x).inf_of_left\n#align measure_theory.measure.finite_at_nhds_within MeasureTheory.Measure.finiteAtNhdsWithin\n\n@[simp]\ntheorem finite_at_principal : \u03bc.FiniteAtFilter (\ud835\udcdf s) \u2194 \u03bc s < \u221e :=\n  \u27e8fun \u27e8t, ht, h\u03bc\u27e9 => (measure_mono ht).trans_lt h\u03bc, fun h => \u27e8s, mem_principal_self s, h\u27e9\u27e9\n#align measure_theory.measure.finite_at_principal MeasureTheory.Measure.finite_at_principal\n\ntheorem isLocallyFiniteMeasureOfLe [TopologicalSpace \u03b1] {m : MeasurableSpace \u03b1} {\u03bc \u03bd : Measure \u03b1}\n    [H : IsLocallyFiniteMeasure \u03bc] (h : \u03bd \u2264 \u03bc) : IsLocallyFiniteMeasure \u03bd :=\n  let F := H.finiteAtNhds\n  \u27e8fun x => (F x).measure_mono h\u27e9\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 \u03b1} {m1 : MeasurableSpace \u03b2} {f : \u03b1 \u2192 \u03b2} (hf : MeasurableEmbedding f)\n\ninclude hf\n\ntheorem map_apply (\u03bc : Measure \u03b1) (s : Set \u03b2) : \u03bc.map f s = \u03bc (f \u207b\u00b9' s) :=\n  by\n  refine' le_antisymm _ (le_map_apply hf.measurable.ae_measurable s)\n  set t := f '' to_measurable \u03bc (f \u207b\u00b9' s) \u222a range f\u1d9c\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 \u2286 t :=\n    by\n    rw [subset_union_compl_iff_inter_subset, \u2190 image_preimage_eq_inter_range]\n    exact image_subset _ (subset_to_measurable _ _)\n  have hft : f \u207b\u00b9' t = to_measurable \u03bc (f \u207b\u00b9' s) := by\n    rw [preimage_union, preimage_compl, preimage_range, compl_univ, union_empty,\n      hf.injective.preimage_image]\n  calc\n    \u03bc.map f s \u2264 \u03bc.map f t := measure_mono hst\n    _ = \u03bc (f \u207b\u00b9' 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 (\u03bc : Measure \u03b2) : (comap f \u03bc).map f = \u03bc.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 (\u03bc : Measure \u03b2) (s : Set \u03b1) : comap f \u03bc s = \u03bc (f '' s) :=\n  calc\n    comap f \u03bc s = comap f \u03bc (f \u207b\u00b9' (f '' s)) := by rw [hf.injective.preimage_image]\n    _ = (comap f \u03bc).map f (f '' s) := (hf.map_apply _ _).symm\n    _ = \u03bc (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 : \u03b2 \u2192 Prop} {\u03bc : Measure \u03b1} : (\u2200\u1d50 x \u2202\u03bc.map f, p x) \u2194 \u2200\u1d50 x \u2202\u03bc, 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 (\u03bc : Measure \u03b1) (s : Set \u03b2) :\n    (\u03bc.map f).restrict s = (\u03bc.restrict <| f \u207b\u00b9' 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 (\u03bc : Measure \u03b2) {s : Set \u03b2} (hs : MeasurableSet s) :\n    \u03bc.comap f (f \u207b\u00b9' s) = \u03bc (s \u2229 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 \u03b1} {s : Set \u03b1} (hs : MeasurableSet s)\n    (\u03bc : Measure \u03b1) (t : Set s) : comap coe \u03bc t = \u03bc (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 \u03b1} {s : Set \u03b1} (hs : MeasurableSet s)\n    (\u03bc : Measure \u03b1) : (comap coe \u03bc).map (coe : s \u2192 \u03b1) = \u03bc.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 \u03b1} {\u03bc : Measure \u03b1} {s : Set \u03b1}\n    (hs : MeasurableSet s) {p : \u03b1 \u2192 Prop} :\n    (\u2200\u1d50 x \u2202\u03bc.restrict s, p x) \u2194 \u2200\u1d50 x \u2202comap (coe : s \u2192 \u03b1) \u03bc, p \u2191x := by\n  rw [\u2190 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 \u03b1] {s t : Set \u03b1}\n\n/-!\n### Volume on `s : set \u03b1`\n-/\n\n\ninstance SetCoe.measureSpace (s : Set \u03b1) : MeasureSpace s :=\n  \u27e8comap (coe : s \u2192 \u03b1) volume\u27e9\n#align set_coe.measure_space SetCoe.measureSpace\n\ntheorem volume_set_coe_def (s : Set \u03b1) : (volume : Measure s) = comap (coe : s \u2192 \u03b1) volume :=\n  rfl\n#align volume_set_coe_def volume_set_coe_def\n\ntheorem MeasurableSet.map_coe_volume {s : Set \u03b1} (hs : MeasurableSet s) :\n    volume.map (coe : s \u2192 \u03b1) = 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 \u03b1} (hs : MeasurableSet s) (t : Set s) :\n    volume (coe '' t : Set \u03b1) = 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 \u2192 \u03b1) \u207b\u00b9' t) = volume (t \u2229 s) := by\n  rw [volume_set_coe_def,\n    comap_apply\u2080 _ _ 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 \u03b1] [MeasurableSpace \u03b2] {\u03bc : Measure \u03b1} {\u03bd : Measure \u03b2}\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 : \u03b1 \u2243\u1d50 \u03b2) (s : Set \u03b2) : \u03bc.map f s = \u03bc (f \u207b\u00b9' s) :=\n  f.MeasurableEmbedding.map_apply _ _\n#align measurable_equiv.map_apply MeasurableEquiv.map_apply\n\n@[simp]\ntheorem map_symm_map (e : \u03b1 \u2243\u1d50 \u03b2) : (\u03bc.map e).map e.symm = \u03bc := 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 : \u03b1 \u2243\u1d50 \u03b2) : (\u03bd.map e.symm).map e = \u03bd := 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 : \u03b1 \u2243\u1d50 \u03b2) : Injective (map e) :=\n  by\n  intro \u03bc\u2081 \u03bc\u2082 h\u03bc\n  apply_fun map e.symm  at h\u03bc\n  simpa [map_symm_map e] using h\u03bc\n#align measurable_equiv.map_measurable_equiv_injective MeasurableEquiv.map_measurableEquiv_injective\n\ntheorem map_apply_eq_iff_map_symm_apply_eq (e : \u03b1 \u2243\u1d50 \u03b2) : \u03bc.map e = \u03bd \u2194 \u03bd.map e.symm = \u03bc := by\n  rw [\u2190 (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 : \u03b1 \u2243\u1d50 \u03b2) (s : Set \u03b2) :\n    (\u03bc.map e).restrict s = (\u03bc.restrict <| e \u207b\u00b9' s).map e :=\n  e.MeasurableEmbedding.restrict_map _ _\n#align measurable_equiv.restrict_map MeasurableEquiv.restrict_map\n\ntheorem map_ae (f : \u03b1 \u2243\u1d50 \u03b2) (\u03bc : Measure \u03b1) : Filter.map f \u03bc.ae = (map f \u03bc).ae :=\n  by\n  ext s\n  simp_rw [mem_map, mem_ae_iff, \u2190 preimage_compl, f.map_apply]\n#align measurable_equiv.map_ae MeasurableEquiv.map_ae\n\ntheorem quasiMeasurePreservingSymm (\u03bc : Measure \u03b1) (e : \u03b1 \u2243\u1d50 \u03b2) :\n    QuasiMeasurePreserving e.symm (map e \u03bc) \u03bc :=\n  \u27e8e.symm.Measurable, by rw [measure.map_map, e.symm_comp_self, measure.map_id] <;> measurability\u27e9\n#align measurable_equiv.quasi_measure_preserving_symm MeasurableEquiv.quasiMeasurePreservingSymm\n\nend MeasurableEquiv\n\nnamespace MeasureTheory\n\ntheorem OuterMeasure.toMeasure_zero [MeasurableSpace \u03b1] :\n    (0 : OuterMeasure \u03b1).toMeasure (le_top.trans OuterMeasure.zero_caratheodory.symm.le) = 0 := by\n  rw [\u2190 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 `\u03bc` on a measurable space structure `m0` as being also a measure on\nany `m \u2264 m0`. Since measures in mathlib have to be trimmed to the measurable space, `\u03bc` itself\ncannot be a measure on `m`, hence the definition of `\u03bc.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 \u03b1} (\u03bc : @Measure \u03b1 m0) (hm : m \u2264 m0) : @Measure \u03b1 m :=\n  @OuterMeasure.toMeasure \u03b1 m \u03bc.toOuterMeasure (hm.trans (le_toOuterMeasure_caratheodory \u03bc))\n#align measure_theory.measure.trim MeasureTheory.Measure.trim\n\n@[simp]\ntheorem trim_eq_self [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1} : \u03bc.trim le_rfl = \u03bc := by\n  simp [measure.trim]\n#align measure_theory.trim_eq_self MeasureTheory.trim_eq_self\n\nvariable {m m0 : MeasurableSpace \u03b1} {\u03bc : Measure \u03b1} {s : Set \u03b1}\n\ntheorem toOuterMeasure_trim_eq_trim_toOuterMeasure (\u03bc : Measure \u03b1) (hm : m \u2264 m0) :\n    @Measure.toOuterMeasure _ m (\u03bc.trim hm) = @OuterMeasure.trim _ m \u03bc.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 \u2264 m0) : (0 : Measure \u03b1).trim hm = (0 : @Measure \u03b1 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 \u2264 m0) (hs : @MeasurableSet \u03b1 m s) : \u03bc.trim hm s = \u03bc 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 \u2264 m0) : \u03bc s \u2264 \u03bc.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 \u2264 m0) (h : \u03bc.trim hm s = 0) : \u03bc 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 \u2264 m0} (hs : \u03bc.trim hm s = 0) :\n    \u03bc (@toMeasurable \u03b1 m (\u03bc.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 \u2264 m0) {\u03bc : Measure \u03b1} {P : \u03b1 \u2192 Prop} (h : \u2200\u1d50 x \u2202\u03bc.trim hm, P x) :\n    \u2200\u1d50 x \u2202\u03bc, 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 \u2264 m0} {f\u2081 f\u2082 : \u03b1 \u2192 E}\n    (h12 : f\u2081 =\u1da0[@Measure.ae \u03b1 m (\u03bc.trim hm)] f\u2082) : f\u2081 =\u1d50[\u03bc] f\u2082 :=\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 \u2264 m0} {f\u2081 f\u2082 : \u03b1 \u2192 E}\n    (h12 : f\u2081 \u2264\u1da0[@Measure.ae \u03b1 m (\u03bc.trim hm)] f\u2082) : f\u2081 \u2264\u1d50[\u03bc] f\u2082 :=\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\u2081 m\u2082 : MeasurableSpace \u03b1} {hm\u2081\u2082 : m\u2081 \u2264 m\u2082} {hm\u2082 : m\u2082 \u2264 m0} :\n    (\u03bc.trim hm\u2082).trim hm\u2081\u2082 = \u03bc.trim (hm\u2081\u2082.trans hm\u2082) :=\n  by\n  ext1 t ht\n  rw [trim_measurable_set_eq hm\u2081\u2082 ht, trim_measurable_set_eq (hm\u2081\u2082.trans hm\u2082) ht,\n    trim_measurable_set_eq hm\u2082 (hm\u2081\u2082 t ht)]\n#align measure_theory.trim_trim MeasureTheory.trim_trim\n\ntheorem restrict_trim (hm : m \u2264 m0) (\u03bc : Measure \u03b1) (hs : @MeasurableSet \u03b1 m s) :\n    @Measure.restrict \u03b1 m (\u03bc.trim hm) s = (\u03bc.restrict s).trim hm :=\n  by\n  ext1 t ht\n  rw [@measure.restrict_apply \u03b1 m _ _ _ ht, trim_measurable_set_eq hm ht,\n    measure.restrict_apply (hm t ht),\n    trim_measurable_set_eq hm (@MeasurableSet.inter \u03b1 m t s ht hs)]\n#align measure_theory.restrict_trim MeasureTheory.restrict_trim\n\ninstance isFiniteMeasureTrim (hm : m \u2264 m0) [IsFiniteMeasure \u03bc] : IsFiniteMeasure (\u03bc.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\u2082 m0 : MeasurableSpace \u03b1} {\u03bc : Measure \u03b1} (hm : m \u2264 m0)\n    (hm\u2082 : m\u2082 \u2264 m) [SigmaFinite (\u03bc.trim (hm\u2082.trans hm))] : SigmaFinite (\u03bc.trim hm) :=\n  by\n  have h := measure.finite_spanning_sets_in (\u03bc.trim (hm\u2082.trans hm)) Set.univ\n  refine' measure.finite_spanning_sets_in.sigma_finite _\n  \u00b7 use Set.univ\n  \u00b7 refine'\n      { Set := spanning_sets (\u03bc.trim (hm\u2082.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      (\u03bc.trim hm) (spanning_sets (\u03bc.trim (hm\u2082.trans hm)) i) =\n          ((\u03bc.trim hm).trim hm\u2082) (spanning_sets (\u03bc.trim (hm\u2082.trans hm)) i) :=\n        by rw [@trim_measurable_set_eq \u03b1 m\u2082 m (\u03bc.trim hm) _ hm\u2082 (measurable_spanning_sets _ _)]\n      _ = (\u03bc.trim (hm\u2082.trans hm)) (spanning_sets (\u03bc.trim (hm\u2082.trans hm)) i) := by\n        rw [@trim_trim _ _ \u03bc _ _ hm\u2082 hm]\n      _ < \u221e := measure_spanning_sets_lt_top _ _\n      \n#align measure_theory.sigma_finite_trim_mono MeasureTheory.sigmaFiniteTrimMono\n\ntheorem sigmaFinite_trim_bot_iff : SigmaFinite (\u03bc.trim bot_le) \u2194 IsFiniteMeasure \u03bc :=\n  by\n  rw [sigma_finite_bot_iff]\n  refine' \u27e8fun h => \u27e8_\u27e9, fun h => \u27e8_\u27e9\u27e9 <;> have h_univ := h.measure_univ_lt_top\n  \u00b7 rwa [trim_measurable_set_eq bot_le MeasurableSet.univ] at h_univ\n  \u00b7 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 \u03b1] [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1} {s : Set \u03b1}\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (U \u00abexpr \u2287 \u00bb s) -/\n/-- If `s` is a compact set and `\u03bc` is finite at `\ud835\udcdd x` for every `x \u2208 s`, then `s` admits an open\nsuperset of finite measure. -/\ntheorem exists_open_superset_measure_lt_top' (h : IsCompact s)\n    (h\u03bc : \u2200 x \u2208 s, \u03bc.FiniteAtFilter (\ud835\udcdd x)) : \u2203 (U : _)(_ : U \u2287 s), IsOpen U \u2227 \u03bc U < \u221e :=\n  by\n  refine' IsCompact.induction_on h _ _ _ _\n  \u00b7 use \u2205\n    simp [Superset]\n  \u00b7 rintro s t hst \u27e8U, htU, hUo, hU\u27e9\n    exact \u27e8U, hst.trans htU, hUo, hU\u27e9\n  \u00b7 rintro s t \u27e8U, hsU, hUo, hU\u27e9 \u27e8V, htV, hVo, hV\u27e9\n    refine'\n      \u27e8U \u222a V, union_subset_union hsU htV, hUo.union hVo,\n        (measure_union_le _ _).trans_lt <| ENNReal.add_lt_top.2 \u27e8hU, hV\u27e9\u27e9\n  \u00b7 intro x hx\n    rcases(h\u03bc x hx).exists_mem_basis (nhds_basis_opens _) with \u27e8U, \u27e8hx, hUo\u27e9, hU\u27e9\n    exact \u27e8U, nhdsWithin_le_nhds (hUo.mem_nhds hx), U, subset.rfl, hUo, hU\u27e9\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 \u00abexpr \u2287 \u00bb s) -/\n/-- If `s` is a compact set and `\u03bc` is a locally finite measure, then `s` admits an open superset of\nfinite measure. -/\ntheorem exists_open_superset_measure_lt_top (h : IsCompact s) (\u03bc : Measure \u03b1)\n    [IsLocallyFiniteMeasure \u03bc] : \u2203 (U : _)(_ : U \u2287 s), IsOpen U \u2227 \u03bc U < \u221e :=\n  h.exists_open_superset_measure_lt_top' fun x hx => \u03bc.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\u03bc : \u2200 x \u2208 s, \u03bc.FiniteAtFilter (\ud835\udcdd[s] x)) :\n    \u03bc s < \u221e :=\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 \u27e8hs, ht\u27e9)) h\u03bc\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    (\u2200 a \u2208 s, \u2203 t \u2208 \ud835\udcdd[s] a, \u03bc t = 0) \u2192 \u03bc s = 0 := by\n  simpa only [\u2190 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 \u03b1]\n    {m : MeasurableSpace \u03b1} {\u03bc : Measure \u03b1} [IsLocallyFiniteMeasure \u03bc] :\n    IsFiniteMeasureOnCompacts \u03bc :=\n  \u27e8fun s hs => hs.measure_lt_top_of_nhdsWithin fun x hx => \u03bc.finiteAtNhdsWithin _ _\u27e9\n#align is_finite_measure_on_compacts_of_is_locally_finite_measure isFiniteMeasureOnCompactsOfIsLocallyFiniteMeasure\n\ntheorem isFiniteMeasure_iff_isFiniteMeasureOnCompacts_of_compactSpace [TopologicalSpace \u03b1]\n    [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1} [CompactSpace \u03b1] :\n    IsFiniteMeasure \u03bc \u2194 IsFiniteMeasureOnCompacts \u03bc :=\n  by\n  constructor <;> intros\n  \u00b7 infer_instance\n  \u00b7 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 `\u03c3`-compact topological space as\n`measure_theory.measure.finite_spanning_sets_in`. -/\ndef MeasureTheory.Measure.finiteSpanningSetsInCompact [TopologicalSpace \u03b1] [SigmaCompactSpace \u03b1]\n    {m : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) [IsLocallyFiniteMeasure \u03bc] :\n    \u03bc.FiniteSpanningSetsIn { K | IsCompact K }\n    where\n  Set := compactCovering \u03b1\n  set_mem := isCompact_compactCovering \u03b1\n  Finite n := (isCompact_compactCovering \u03b1 n).measure_lt_top\n  spanning := union\u1d62_compactCovering \u03b1\n#align measure_theory.measure.finite_spanning_sets_in_compact MeasureTheory.Measure.finiteSpanningSetsInCompact\n\n/-- A locally finite measure on a `\u03c3`-compact topological space admits a finite spanning sequence\nof open sets. -/\ndef MeasureTheory.Measure.finiteSpanningSetsInOpen [TopologicalSpace \u03b1] [SigmaCompactSpace \u03b1]\n    {m : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) [IsLocallyFiniteMeasure \u03bc] :\n    \u03bc.FiniteSpanningSetsIn { K | IsOpen K }\n    where\n  Set n := ((isCompact_compactCovering \u03b1 n).exists_open_superset_measure_lt_top \u03bc).some\n  set_mem n :=\n    ((isCompact_compactCovering \u03b1 n).exists_open_superset_measure_lt_top \u03bc).choose_spec.snd.1\n  Finite n :=\n    ((isCompact_compactCovering \u03b1 n).exists_open_superset_measure_lt_top \u03bc).choose_spec.snd.2\n  spanning :=\n    eq_univ_of_subset\n      (union\u1d62_mono fun n =>\n        ((isCompact_compactCovering \u03b1 n).exists_open_superset_measure_lt_top \u03bc).choose_spec.fst)\n      (union\u1d62_compactCovering \u03b1)\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 \u03b1]\n  [SecondCountableTopology \u03b1] {m : MeasurableSpace \u03b1} (\u03bc : Measure \u03b1) [IsLocallyFiniteMeasure \u03bc] :\n  \u03bc.FiniteSpanningSetsIn { K | IsOpen K } :=\n  by\n  suffices H : Nonempty (\u03bc.finite_spanning_sets_in { K | IsOpen K })\n  exact H.some\n  cases isEmpty_or_nonempty \u03b1\n  \u00b7\n    exact\n      \u27e8{  Set := fun n => \u2205\n          set_mem := fun n => by simp\n          Finite := fun n => by simp\n          spanning := by simp }\u27e9\n  inhabit \u03b1\n  let S : Set (Set \u03b1) := { s | IsOpen s \u2227 \u03bc s < \u221e }\n  obtain \u27e8T, T_count, TS, hT\u27e9 : \u2203 T : Set (Set \u03b1), T.Countable \u2227 T \u2286 S \u2227 \u22c3\u2080 T = \u22c3\u2080 S :=\n    is_open_sUnion_countable S fun s hs => hs.1\n  rw [\u03bc.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 [\u2190 hT] using mem_univ (default : \u03b1)\n  obtain \u27e8f, hf\u27e9 : \u2203 f : \u2115 \u2192 Set \u03b1, T = range f\n  exact T_count.exists_eq_range T_ne\n  have fS : \u2200 n, f n \u2208 S := by\n    intro n\n    apply TS\n    rw [hf]\n    exact mem_range_self n\n  refine'\n    \u27e8{  Set := f\n        set_mem := fun n => (fS n).1\n        Finite := fun n => (fS n).2\n        spanning := _ }\u27e9\n  apply eq_univ_of_forall fun x => _\n  obtain \u27e8t, tT, xt\u27e9 : \u2203 t : Set \u03b1, t \u2208 range f \u2227 x \u2208 t :=\n    by\n    have : x \u2208 \u22c3\u2080 T := by simp only [hT]\n    simpa only [mem_sUnion, exists_prop, \u2190 hf]\n  obtain \u27e8n, rfl\u27e9 : \u2203 n : \u2115, 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 \u03b1] [TopologicalSpace \u03b1] [CompactIccSpace \u03b1] {m : MeasurableSpace \u03b1}\n  {\u03bc : Measure \u03b1} [IsLocallyFiniteMeasure \u03bc] {a b : \u03b1}\n\ntheorem measure_Icc_lt_top : \u03bc (Icc a b) < \u221e :=\n  isCompact_Icc.measure_lt_top\n#align measure_Icc_lt_top measure_Icc_lt_top\n\ntheorem measure_Ico_lt_top : \u03bc (Ico a b) < \u221e :=\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 : \u03bc (Ioc a b) < \u221e :=\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 : \u03bc (Ioo a b) < \u221e :=\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 \u03b1] {\u03bc : Measure \u03b1} {s t : Set \u03b1} {f g : \u03b1 \u2192 \u03b2}\n\ntheorem piecewise_ae_eq_restrict (hs : MeasurableSet s) : piecewise s f g =\u1d50[\u03bc.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 =\u1d50[\u03bc.restrict (s\u1d9c)] 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 =\u1d50[\u03bc] t) : s.piecewise f g =\u1d50[\u03bc] 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 \u03b1] {\u03bc : Measure \u03b1} {s t : Set \u03b1} {f : \u03b1 \u2192 \u03b2}\n\ntheorem mem_map_indicator_ae_iff_mem_map_restrict_ae_of_zero_mem [Zero \u03b2] {t : Set \u03b2}\n    (ht : (0 : \u03b2) \u2208 t) (hs : MeasurableSet s) :\n    t \u2208 Filter.map (s.indicator f) \u03bc.ae \u2194 t \u2208 Filter.map f (\u03bc.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 \u03bc (((f \u207b\u00b9' t)\u1d9c \u222a s\u1d9c) \u2229 ((fun x => (0 : \u03b2)) \u207b\u00b9' t \\ s)\u1d9c) = 0 \u2194 \u03bc ((f \u207b\u00b9' t)\u1d9c \u2229 s) = 0\n  simp only [ht, \u2190 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 \u03b2] {t : Set \u03b2} (ht : (0 : \u03b2) \u2209 t) :\n    t \u2208 Filter.map (s.indicator f) \u03bc.ae \u2194 \u03bc ((f \u207b\u00b9' t)\u1d9c \u222a s\u1d9c) = 0 :=\n  by\n  rw [mem_map, mem_ae_iff, Set.indicator_preimage, Set.ite, Set.compl_union, Set.compl_inter]\n  change \u03bc (((f \u207b\u00b9' t)\u1d9c \u222a s\u1d9c) \u2229 ((fun x => (0 : \u03b2)) \u207b\u00b9' t \\ s)\u1d9c) = 0 \u2194 \u03bc ((f \u207b\u00b9' t)\u1d9c \u222a s\u1d9c) = 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 \u03b2] (hs : MeasurableSet s) :\n    Filter.map f (\u03bc.restrict s).ae \u2264 Filter.map (s.indicator f) \u03bc.ae :=\n  by\n  intro t\n  by_cases ht : (0 : \u03b2) \u2208 t\n  \u00b7 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 \u03b2]\n\ntheorem indicator_ae_eq_restrict (hs : MeasurableSet s) : indicator s f =\u1d50[\u03bc.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 =\u1d50[\u03bc.restrict (s\u1d9c)] 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 =\u1d50[\u03bc.restrict (s\u1d9c)] 0) : s.indicator f =\u1d50[\u03bc] 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 \u2208 s\n  \u00b7 simp only [hxs, Set.indicator_of_mem]\n  \u00b7 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 =\u1d50[\u03bc.restrict s] 0) : s.indicator f =\u1d50[\u03bc] 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 \u2208 s\n  \u00b7 simp only [hxs, hx hxs, Set.indicator_of_mem]\n  \u00b7 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 =\u1d50[\u03bc] t) : s.indicator f =\u1d50[\u03bc] 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 : \u03bc s = 0) : indicator s f =\u1d50[\u03bc] 0 :=\n  indicator_empty' f \u25b8 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 : \u03b1 \u2192 \u03b2} (hs : MeasurableSet s) :\n    f =\u1d50[\u03bc.restrict s] g \u2194 s.indicator f =\u1d50[\u03bc] s.indicator g :=\n  by\n  rw [Filter.EventuallyEq, ae_restrict_iff' hs]\n  refine' \u27e8fun h => _, fun h => _\u27e9 <;> filter_upwards [h]with x hx\n  \u00b7 by_cases hxs : x \u2208 s\n    \u00b7 simp [hxs, hx hxs]\n    \u00b7 simp [hxs]\n  \u00b7 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) 2022 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jesse Vogel, Jannis Limperg\n-/\n\nimport Aesop\n\nset_option aesop.check.all true\n\naxiom Ring : Type\naxiom Morphism (R S : Ring) : Type\n\n@[aesop 99%]\naxiom ZZ : Ring\n\n@[aesop 99%]\naxiom f : Morphism ZZ ZZ\n\nnoncomputable example : \u03a3 (R : Ring), Morphism R R := by\n  aesop\n\naxiom domain (R : Ring) : Prop\n\n@[aesop 99%]\naxiom ZZ_domain : domain ZZ\n\nnoncomputable example : \u2203 (R : Ring), domain R := by\n  aesop\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/Jesse.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7931059511841119, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.47004740749162605}}
{"text": "import tactic.hint\n\n-- @[simp] theorem exists_prop {p q : Prop} : (\u2203 h : p, q) \u2194 p \u2227 q :=\n-- \u27e8\u03bb \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081, h\u2082\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081, h\u2082\u27e9\u27e9\n\nlemma ex1 (N : \u2115) : \u2203 (n : \u2115) (H : n \u2265 N), n \u2265 N :=\nbegin\n  refine \u27e8N, _\u27e9,\n  rw exists_prop,\n  rw and_self,\n  apply nat.less_than_or_equal.refl,\nend\n\n#print ex1\n\ntheorem mwe {P Q : nat \u2192 Prop} : \u2200 (x : nat), \u00ac (P x \u2192 Q x):=\nbegin\n    -- rw classical.not_implies_iff,\n    hint,\n    intros,\n    simp,\n    sorry,\nend\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/exists.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7981867777396212, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.47004351773346226}}
{"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\u00f6lzl\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 \u2124-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 (\u03b1 : Type u_3) [uniform_space \u03b1] [add_group \u03b1] \nwhere\n  uniform_continuous_sub : uniform_continuous fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p - prod.snd p\n\ntheorem uniform_add_group.mk' {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] (h\u2081 : uniform_continuous fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p + prod.snd p) (h\u2082 : uniform_continuous fun (p : \u03b1) => -p) : uniform_add_group \u03b1 := sorry\n\ntheorem uniform_continuous_sub {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : uniform_continuous fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p - prod.snd p :=\n  uniform_add_group.uniform_continuous_sub\n\ntheorem uniform_continuous.sub {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] [uniform_space \u03b2] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (hf : uniform_continuous f) (hg : uniform_continuous g) : uniform_continuous fun (x : \u03b2) => f x - g x :=\n  uniform_continuous.comp uniform_continuous_sub (uniform_continuous.prod_mk hf hg)\n\ntheorem uniform_continuous.neg {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] [uniform_space \u03b2] {f : \u03b2 \u2192 \u03b1} (hf : uniform_continuous f) : uniform_continuous fun (x : \u03b2) => -f x := sorry\n\ntheorem uniform_continuous_neg {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : uniform_continuous fun (x : \u03b1) => -x :=\n  uniform_continuous.neg uniform_continuous_id\n\ntheorem uniform_continuous.add {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] [uniform_space \u03b2] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (hf : uniform_continuous f) (hg : uniform_continuous g) : uniform_continuous fun (x : \u03b2) => f x + g x := sorry\n\ntheorem uniform_continuous_add {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : uniform_continuous fun (p : \u03b1 \u00d7 \u03b1) => 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 {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : topological_add_group \u03b1 :=\n  topological_add_group.mk (uniform_continuous.continuous uniform_continuous_neg)\n\nprotected instance prod.uniform_add_group {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] [uniform_space \u03b2] [add_group \u03b2] [uniform_add_group \u03b2] : uniform_add_group (\u03b1 \u00d7 \u03b2) :=\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 {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] (a : \u03b1) : filter.map (fun (x : \u03b1 \u00d7 \u03b1) => (prod.fst x + a, prod.snd x + a)) (uniformity \u03b1) = uniformity \u03b1 := sorry\n\ntheorem uniform_embedding_translate {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] (a : \u03b1) : uniform_embedding fun (x : \u03b1) => x + a := sorry\n\ntheorem uniformity_eq_comap_nhds_zero (\u03b1 : Type u_1) [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : uniformity \u03b1 = filter.comap (fun (x : \u03b1 \u00d7 \u03b1) => prod.snd x - prod.fst x) (nhds 0) := sorry\n\ntheorem group_separation_rel {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] (x : \u03b1) (y : \u03b1) : (x, y) \u2208 Mathlib.separation_rel \u03b1 \u2194 x - y \u2208 closure (singleton 0) := sorry\n\ntheorem uniform_continuous_of_tendsto_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] [uniform_space \u03b2] [add_group \u03b2] [uniform_add_group \u03b2] {f : \u03b1 \u2192 \u03b2} [is_add_group_hom f] (h : filter.tendsto f (nhds 0) (nhds 0)) : uniform_continuous f := sorry\n\ntheorem uniform_continuous_of_continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] [uniform_space \u03b2] [add_group \u03b2] [uniform_add_group \u03b2] {f : \u03b1 \u2192 \u03b2} [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 \u00d7 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 \u00d7 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 \u2124` from `tensor_product`. -/\n\n/-- `\u2124`-bilinearity for maps between additive commutative groups. -/\nclass is_Z_bilin {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) \nwhere\n  add_left : \u2200 (a a' : \u03b1) (b : \u03b2), f (a + a', b) = f (a, b) + f (a', b)\n  add_right : \u2200 (a : \u03b1) (b b' : \u03b2), f (a, b + b') = f (a, b) + f (a, b')\n\ntheorem is_Z_bilin.comp_hom {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] {g : \u03b3 \u2192 \u03b4} [add_comm_group \u03b4] [is_add_group_hom g] : is_Z_bilin (g \u2218 f) := sorry\n\nprotected instance is_Z_bilin.comp_swap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] : is_Z_bilin (f \u2218 prod.swap) :=\n  is_Z_bilin.mk (fun (a a' : \u03b2) (b : \u03b1) => is_Z_bilin.add_right f b a a')\n    fun (a : \u03b2) (b b' : \u03b1) => is_Z_bilin.add_left f b b' a\n\ntheorem is_Z_bilin.zero_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] (b : \u03b2) : f (0, b) = 0 := sorry\n\ntheorem is_Z_bilin.zero_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] (a : \u03b1) : f (a, 0) = 0 :=\n  is_Z_bilin.zero_left (f \u2218 prod.swap)\n\ntheorem is_Z_bilin.zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] : f (0, 0) = 0 :=\n  is_Z_bilin.zero_left f 0\n\ntheorem is_Z_bilin.neg_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] (a : \u03b1) (b : \u03b2) : f (-a, b) = -f (a, b) := sorry\n\ntheorem is_Z_bilin.neg_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] (a : \u03b1) (b : \u03b2) : f (a, -b) = -f (a, b) :=\n  is_Z_bilin.neg_left (f \u2218 prod.swap) b a\n\ntheorem is_Z_bilin.sub_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] (a : \u03b1) (a' : \u03b1) (b : \u03b2) : f (a - a', b) = f (a, b) - f (a', b) := sorry\n\ntheorem is_Z_bilin.sub_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b1] [add_comm_group \u03b2] [add_comm_group \u03b3] (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) [is_Z_bilin f] (a : \u03b1) (b : \u03b2) (b' : \u03b2) : f (a, b - b') = f (a, b) - f (a, b') :=\n  is_Z_bilin.sub_left (f \u2218 prod.swap) b b' a\n\nend add_comm_group\n\n\n-- \u03b1, \u03b2 and G are abelian topological groups, G is a uniform space\n\ntheorem is_Z_bilin.tendsto_zero_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [add_comm_group \u03b1] [topological_space \u03b2] [add_comm_group \u03b2] {G : Type u_5} [uniform_space G] [add_comm_group G] {\u03c8 : \u03b1 \u00d7 \u03b2 \u2192 G} (h\u03c8 : continuous \u03c8) [\u03c8bilin : add_comm_group.is_Z_bilin \u03c8] (x\u2081 : \u03b1) : filter.tendsto \u03c8 (nhds (x\u2081, 0)) (nhds 0) := sorry\n\ntheorem is_Z_bilin.tendsto_zero_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [add_comm_group \u03b1] [topological_space \u03b2] [add_comm_group \u03b2] {G : Type u_5} [uniform_space G] [add_comm_group G] {\u03c8 : \u03b1 \u00d7 \u03b2 \u2192 G} (h\u03c8 : continuous \u03c8) [\u03c8bilin : add_comm_group.is_Z_bilin \u03c8] (y\u2081 : \u03b2) : filter.tendsto \u03c8 (nhds (0, y\u2081)) (nhds 0) :=\n  eq.mp\n    (Eq._oldrec (Eq.refl (filter.tendsto \u03c8 (nhds (0, y\u2081)) (nhds (\u03c8 (0, y\u2081))))) (add_comm_group.is_Z_bilin.zero_left \u03c8 y\u2081))\n    (continuous.tendsto h\u03c8 (0, y\u2081))\n\n-- \u03b2 is a dense subgroup of \u03b1, inclusion is denoted by e\n\ntheorem tendsto_sub_comap_self {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [add_comm_group \u03b1] [topological_add_group \u03b1] [topological_space \u03b2] [add_comm_group \u03b2] {e : \u03b2 \u2192 \u03b1} [is_add_group_hom e] (de : dense_inducing e) (x\u2080 : \u03b1) : filter.tendsto (fun (t : \u03b2 \u00d7 \u03b2) => prod.snd t - prod.fst t)\n  (filter.comap (fun (p : \u03b2 \u00d7 \u03b2) => (e (prod.fst p), e (prod.snd p))) (nhds (x\u2080, x\u2080))) (nhds 0) := sorry\n\nnamespace dense_inducing\n\n\n-- \u03b2 is a dense subgroup of \u03b1, inclusion is denoted by e\n\n-- \u03b4 is a dense subgroup of \u03b3, inclusion is denoted by f\n\n/-- Bourbaki GT III.6.5 Theorem I:\n\u2124-bilinear continuous maps from dense images into a complete Hausdorff group extend by continuity.\nNote: Bourbaki assumes that \u03b1 and \u03b2 are also complete Hausdorff, but this is not necessary. -/\ntheorem extend_Z_bilin {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {G : Type u_5} [topological_space \u03b1] [add_comm_group \u03b1] [topological_add_group \u03b1] [topological_space \u03b2] [add_comm_group \u03b2] [topological_add_group \u03b2] [topological_space \u03b3] [add_comm_group \u03b3] [topological_add_group \u03b3] [topological_space \u03b4] [add_comm_group \u03b4] [topological_add_group \u03b4] [uniform_space G] [add_comm_group G] [uniform_add_group G] [separated_space G] [complete_space G] {e : \u03b2 \u2192 \u03b1} [is_add_group_hom e] (de : dense_inducing e) {f : \u03b4 \u2192 \u03b3} [is_add_group_hom f] (df : dense_inducing f) {\u03c6 : \u03b2 \u00d7 \u03b4 \u2192 G} (h\u03c6 : continuous \u03c6) [bilin : add_comm_group.is_Z_bilin \u03c6] : continuous (extend (dense_inducing.prod de df) \u03c6) := 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 \u2218 id = sym2.map id \u2218 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\u00ebl 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 (`\u03b5NFA`), 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 \u03b5-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 `\u03b5NFA`'s.\n-/\n\n\nopen Set\n\nopen Computability\n\n-- \"\u03b5_NFA\"\nset_option linter.uppercaseLean3 false\n\nuniverse u v\n\n/-- An `\u03b5NFA` is a set of states (`\u03c3`), 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 \u03b5-transitions by\n  inputing `none`.\n  Since this definition allows for Automata with infinite states, a `Fintype` instance must be\n  supplied for true `\u03b5NFA`'s. -/\nstructure \u03b5NFA (\u03b1 : Type u) (\u03c3 : Type v) where\n  step : \u03c3 \u2192 Option \u03b1 \u2192 Set \u03c3\n  start : Set \u03c3\n  accept : Set \u03c3\n#align \u03b5_NFA \u03b5NFA\n\nvariable {\u03b1 : Type u} {\u03c3 \u03c3' : Type v} (M : \u03b5NFA \u03b1 \u03c3) {S : Set \u03c3} {x : List \u03b1} {s : \u03c3} {a : \u03b1}\n\nnamespace \u03b5NFA\n\n/-- The `\u03b5Closure` of a set is the set of states which can be reached by taking a finite string of\n\u03b5-transitions from an element of the set. -/\ninductive \u03b5Closure (S : Set \u03c3) : Set \u03c3\n  | base : \u2200 s \u2208 S, \u03b5Closure S s\n  | step : \u2200 (s), \u2200 t \u2208 M.step s none, \u03b5Closure S s \u2192 \u03b5Closure S t\n#align \u03b5_NFA.\u03b5_closure \u03b5NFA.\u03b5Closure\n\n@[simp]\ntheorem subset_\u03b5Closure (S : Set \u03c3) : S \u2286 M.\u03b5Closure S :=\n  \u03b5Closure.base\n#align \u03b5_NFA.subset_\u03b5_closure \u03b5NFA.subset_\u03b5Closure\n\n@[simp]\ntheorem \u03b5Closure_empty : M.\u03b5Closure \u2205 = \u2205 :=\n  eq_empty_of_forall_not_mem fun s hs \u21a6 by induction hs <;> assumption\n#align \u03b5_NFA.\u03b5_closure_empty \u03b5NFA.\u03b5Closure_empty\n\n@[simp]\ntheorem \u03b5Closure_univ : M.\u03b5Closure univ = univ :=\n  eq_univ_of_univ_subset <| subset_\u03b5Closure _ _\n#align \u03b5_NFA.\u03b5_closure_univ \u03b5NFA.\u03b5Closure_univ\n\n/-- `M.stepSet S a` is the union of the \u03b5-closure of `M.step s a` for all `s \u2208 S`. -/\ndef stepSet (S : Set \u03c3) (a : \u03b1) : Set \u03c3 :=\n  \u22c3 s \u2208 S, M.\u03b5Closure <| M.step s a\n#align \u03b5_NFA.step_set \u03b5NFA.stepSet\n\nvariable {M}\n\n@[simp]\ntheorem mem_stepSet_iff : s \u2208 M.stepSet S a \u2194 \u2203 t \u2208 S, s \u2208 M.\u03b5Closure (M.step t a) := by\n  simp_rw [stepSet, mem_union\u1d62\u2082, exists_prop]\n#align \u03b5_NFA.mem_step_set_iff \u03b5NFA.mem_stepSet_iff\n\n@[simp]\ntheorem stepSet_empty (a : \u03b1) : M.stepSet \u2205 a = \u2205 := by\n  simp_rw [stepSet, mem_empty_iff_false, union\u1d62_false, union\u1d62_empty]\n#align \u03b5_NFA.step_set_empty \u03b5NFA.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 \u03c3) : List \u03b1 \u2192 Set \u03c3 :=\n  List.foldl M.stepSet (M.\u03b5Closure start)\n#align \u03b5_NFA.eval_from \u03b5NFA.evalFrom\n\n@[simp]\ntheorem evalFrom_nil (S : Set \u03c3) : M.evalFrom S [] = M.\u03b5Closure S :=\n  rfl\n#align \u03b5_NFA.eval_from_nil \u03b5NFA.evalFrom_nil\n\n@[simp]\ntheorem evalFrom_singleton (S : Set \u03c3) (a : \u03b1) : M.evalFrom S [a] = M.stepSet (M.\u03b5Closure S) a :=\n  rfl\n#align \u03b5_NFA.eval_from_singleton \u03b5NFA.evalFrom_singleton\n\n@[simp]\ntheorem evalFrom_append_singleton (S : Set \u03c3) (x : List \u03b1) (a : \u03b1) :\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 \u03b5_NFA.eval_from_append_singleton \u03b5NFA.evalFrom_append_singleton\n\n@[simp]\ntheorem evalFrom_empty (x : List \u03b1) : M.evalFrom \u2205 x = \u2205 := by\n  induction' x using List.reverseRecOn with x a ih\n  \u00b7 rw [evalFrom_nil, \u03b5Closure_empty]\n  \u00b7 rw [evalFrom_append_singleton, ih, stepSet_empty]\n#align \u03b5_NFA.eval_from_empty \u03b5NFA.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 \u03b5_NFA.eval \u03b5NFA.eval\n\n@[simp]\ntheorem eval_nil : M.eval [] = M.\u03b5Closure M.start :=\n  rfl\n#align \u03b5_NFA.eval_nil \u03b5NFA.eval_nil\n\n@[simp]\ntheorem eval_singleton (a : \u03b1) : M.eval [a] = M.stepSet (M.\u03b5Closure M.start) a :=\n  rfl\n#align \u03b5_NFA.eval_singleton \u03b5NFA.eval_singleton\n\n@[simp]\ntheorem eval_append_singleton (x : List \u03b1) (a : \u03b1) : M.eval (x ++ [a]) = M.stepSet (M.eval x) a :=\n  evalFrom_append_singleton _ _ _ _\n#align \u03b5_NFA.eval_append_singleton \u03b5NFA.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 \u03b1 :=\n  { x | \u2203 S \u2208 M.accept, S \u2208 M.eval x }\n#align \u03b5_NFA.accepts \u03b5NFA.accepts\n\n/-! ### Conversions between `\u03b5NFA` and `NFA` -/\n\n\n/-- `M.toNFA` is an `NFA` constructed from an `\u03b5NFA` `M`. -/\ndef toNFA : NFA \u03b1 \u03c3 where\n  step S a := M.\u03b5Closure (M.step S a)\n  start := M.\u03b5Closure M.start\n  accept := M.accept\n#align \u03b5_NFA.to_NFA \u03b5NFA.toNFA\n\n@[simp]\ntheorem toNFA_evalFrom_match (start : Set \u03c3) :\n    M.toNFA.evalFrom (M.\u03b5Closure start) = M.evalFrom start :=\n  rfl\n#align \u03b5_NFA.to_NFA_eval_from_match \u03b5NFA.toNFA_evalFrom_match\n\n@[simp]\ntheorem toNFA_correct : M.toNFA.accepts = M.accepts :=\n  rfl\n#align \u03b5_NFA.to_NFA_correct \u03b5NFA.toNFA_correct\n\ntheorem pumping_lemma [Fintype \u03c3] {x : List \u03b1} (hx : x \u2208 M.accepts)\n    (hlen : Fintype.card (Set \u03c3) \u2264 List.length x) :\n    \u2203 a b c, x = a ++ b ++ c \u2227\n      a.length + b.length \u2264 Fintype.card (Set \u03c3) \u2227 b \u2260 [] \u2227 {a} * {b}\u2217 * {c} \u2264 M.accepts :=\n  M.toNFA.pumping_lemma hx hlen\n#align \u03b5_NFA.pumping_lemma \u03b5NFA.pumping_lemma\n\nend \u03b5NFA\n\nnamespace NFA\n\n/-- `M.to\u03b5NFA` is an `\u03b5NFA` constructed from an `NFA` `M` by using the same start and accept\n  states and transition functions. -/\ndef to\u03b5NFA (M : NFA \u03b1 \u03c3) : \u03b5NFA \u03b1 \u03c3 where\n  step s a := a.casesOn' \u2205 fun a \u21a6 M.step s a\n  start := M.start\n  accept := M.accept\n#align NFA.to_\u03b5_NFA NFA.to\u03b5NFA\n\n@[simp]\ntheorem to\u03b5NFA_\u03b5Closure (M : NFA \u03b1 \u03c3) (S : Set \u03c3) : M.to\u03b5NFA.\u03b5Closure S = S := by\n  ext a\n  refine' \u27e8_, \u03b5NFA.\u03b5Closure.base _\u27e9\n  rintro (\u27e8_, h\u27e9 | \u27e8_, _, h, _\u27e9)\n  \u00b7 exact h\n  \u00b7 cases h\n#align NFA.to_\u03b5_NFA_\u03b5_closure NFA.to\u03b5NFA_\u03b5Closure\n\n@[simp]\ntheorem to\u03b5NFA_evalFrom_match (M : NFA \u03b1 \u03c3) (start : Set \u03c3) :\n    M.to\u03b5NFA.evalFrom start = M.evalFrom start := by\n  rw [evalFrom, \u03b5NFA.evalFrom, to\u03b5NFA_\u03b5Closure]\n  suffices \u03b5NFA.stepSet (to\u03b5NFA M) = stepSet M by rw [this]\n  ext S s\n  simp only [stepSet, \u03b5NFA.stepSet, exists_prop, Set.mem_union\u1d62]\n  apply exists_congr\n  simp only [and_congr_right_iff]\n  intro _ _\n  rw [M.to\u03b5NFA_\u03b5Closure]\n  rfl\n#align NFA.to_\u03b5_NFA_eval_from_match NFA.to\u03b5NFA_evalFrom_match\n\n@[simp]\ntheorem to\u03b5NFA_correct (M : NFA \u03b1 \u03c3) : M.to\u03b5NFA.accepts = M.accepts := by\n  rw [\u03b5NFA.accepts, \u03b5NFA.eval, to\u03b5NFA_evalFrom_match]\n  rfl\n#align NFA.to_\u03b5_NFA_correct NFA.to\u03b5NFA_correct\n\nend NFA\n\n/-! ### Regex-like operations -/\n\n\nnamespace \u03b5NFA\n\ninstance : Zero (\u03b5NFA \u03b1 \u03c3) :=\n  \u27e8\u27e8fun _ _ \u21a6 \u2205, \u2205, \u2205\u27e9\u27e9\n\ninstance : One (\u03b5NFA \u03b1 \u03c3) :=\n  \u27e8\u27e8fun _ _ \u21a6 \u2205, univ, univ\u27e9\u27e9\n\ninstance : Inhabited (\u03b5NFA \u03b1 \u03c3) :=\n  \u27e80\u27e9\n\nvariable (P : \u03b5NFA \u03b1 \u03c3) (Q : \u03b5NFA \u03b1 \u03c3')\n\n@[simp]\ntheorem step_zero (s a) : (0 : \u03b5NFA \u03b1 \u03c3).step s a = \u2205 :=\n  rfl\n#align \u03b5_NFA.step_zero \u03b5NFA.step_zero\n\n@[simp]\ntheorem step_one (s a) : (1 : \u03b5NFA \u03b1 \u03c3).step s a = \u2205 :=\n  rfl\n#align \u03b5_NFA.step_one \u03b5NFA.step_one\n\n@[simp]\ntheorem start_zero : (0 : \u03b5NFA \u03b1 \u03c3).start = \u2205 :=\n  rfl\n#align \u03b5_NFA.start_zero \u03b5NFA.start_zero\n\n@[simp]\ntheorem start_one : (1 : \u03b5NFA \u03b1 \u03c3).start = univ :=\n  rfl\n#align \u03b5_NFA.start_one \u03b5NFA.start_one\n\n@[simp]\ntheorem accept_zero : (0 : \u03b5NFA \u03b1 \u03c3).accept = \u2205 :=\n  rfl\n#align \u03b5_NFA.accept_zero \u03b5NFA.accept_zero\n\n@[simp]\ntheorem accept_one : (1 : \u03b5NFA \u03b1 \u03c3).accept = univ :=\n  rfl\n#align \u03b5_NFA.accept_one \u03b5NFA.accept_one\n\nend \u03b5NFA\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\u2082 \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 \u2964 C}\n    {c\u2081 : fan (functor.obj F)}\n    {c\u2082 :\n      fan\n        fun (f : sigma fun (p : J \u00d7 J) => prod.fst p \u27f6 prod.snd p) =>\n          functor.obj F (prod.snd (sigma.fst f))}\n    (s : cone.X c\u2081 \u27f6 cone.X c\u2082) (t : cone.X c\u2081 \u27f6 cone.X c\u2082)\n    (hs :\n      \u2200 (f : sigma fun (p : J \u00d7 J) => prod.fst p \u27f6 prod.snd p),\n        s \u226b nat_trans.app (cone.\u03c0 c\u2082) f =\n          nat_trans.app (cone.\u03c0 c\u2081) (prod.fst (sigma.fst f)) \u226b functor.map F (sigma.snd f))\n    (ht :\n      \u2200 (f : sigma fun (p : J \u00d7 J) => prod.fst p \u27f6 prod.snd p),\n        t \u226b nat_trans.app (cone.\u03c0 c\u2082) f = nat_trans.app (cone.\u03c0 c\u2081) (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.\u03b9 i \u226b nat_trans.app (cone.\u03c0 c\u2081) 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 \u2964 C}\n    {c\u2081 : fan (functor.obj F)}\n    {c\u2082 :\n      fan\n        fun (f : sigma fun (p : J \u00d7 J) => prod.fst p \u27f6 prod.snd p) =>\n          functor.obj F (prod.snd (sigma.fst f))}\n    (s : cone.X c\u2081 \u27f6 cone.X c\u2082) (t : cone.X c\u2081 \u27f6 cone.X c\u2082)\n    (hs :\n      \u2200 (f : sigma fun (p : J \u00d7 J) => prod.fst p \u27f6 prod.snd p),\n        s \u226b nat_trans.app (cone.\u03c0 c\u2082) f =\n          nat_trans.app (cone.\u03c0 c\u2081) (prod.fst (sigma.fst f)) \u226b functor.map F (sigma.snd f))\n    (ht :\n      \u2200 (f : sigma fun (p : J \u00d7 J) => prod.fst p \u27f6 prod.snd p),\n        t \u226b nat_trans.app (cone.\u03c0 c\u2082) f = nat_trans.app (cone.\u03c0 c\u2081) (prod.snd (sigma.fst f)))\n    {i : fork s t} (t\u2081 : is_limit c\u2081) (t\u2082 : is_limit c\u2082) (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_\u03b9 (is_limit.lift t\u2081 (fan.mk (cone.X q) fun (j : J) => nat_trans.app (cone.\u03c0 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 \u2964 C) [has_limit (discrete.functor (functor.obj F))]\n    [has_limit\n        (discrete.functor\n          fun (f : sigma fun (p : J \u00d7 J) => prod.fst p \u27f6 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) (\ud835\udca5 : small_category J) =>\n      has_limits_of_shape.mk fun (F : J \u2964 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 \u2964 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\u2082} [category D] [has_limits_of_shape (discrete J) C]\n    [has_limits_of_shape (discrete (sigma fun (p : J \u00d7 J) => prod.fst p \u27f6 prod.snd p)) C]\n    [has_equalizers C] (G : C \u2964 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 \u00d7 J) => prod.fst p \u27f6 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\u2082} [category D] [has_equalizers C] [has_finite_products C] (G : C \u2964 D)\n    [preserves_limits_of_shape walking_parallel_pair G]\n    [(J : Type v) \u2192 [_inst_8 : fintype J] \u2192 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\u2082}\n    [category D] [has_equalizers C] [has_products C] (G : C \u2964 D)\n    [preserves_limits_of_shape walking_parallel_pair G]\n    [(J : Type v) \u2192 preserves_limits_of_shape (discrete J) G] : preserves_limits G :=\n  preserves_limits.mk\n    fun (J : Type v) (\ud835\udca5 : 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\u2081 u\u2082 v\u2081 v\u2082 u\u2083 v\u2083 \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 `\u03b1 : F \u2245 G`, then `a.app X : F.obj X \u2245 G.obj X`,\nand building natural isomorphisms from components:\n*\n```\nnat_iso.of_components\n  (app : \u2200 X : C, F.obj X \u2245 G.obj X)\n  (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), F.map f \u226b (app Y).hom = (app X).hom \u226b G.map f) :\nF \u2245 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 `\u03b1.app` -/\n@[simp] theorem app_hom {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : hom (app \u03b1 X) = nat_trans.app (hom \u03b1) X :=\n  Eq.refl (hom (app \u03b1 X))\n\n@[simp] theorem hom_inv_id_app_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) {X' : D} (f' : functor.obj F X \u27f6 X') : nat_trans.app (hom \u03b1) X \u226b nat_trans.app (inv \u03b1) X \u226b f' = f' := sorry\n\n@[simp] theorem inv_hom_id_app_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) {X' : D} (f' : functor.obj G X \u27f6 X') : nat_trans.app (inv \u03b1) X \u226b nat_trans.app (hom \u03b1) X \u226b f' = f' := sorry\n\nend iso\n\n\nnamespace nat_iso\n\n\n@[simp] theorem trans_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : F \u2245 G) (\u03b2 : G \u2245 H) (X : C) : iso.app (\u03b1 \u226a\u226b \u03b2) X = iso.app \u03b1 X \u226a\u226b iso.app \u03b2 X :=\n  rfl\n\ntheorem app_hom {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : iso.hom (iso.app \u03b1 X) = nat_trans.app (iso.hom \u03b1) X :=\n  rfl\n\ntheorem app_inv {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : iso.inv (iso.app \u03b1 X) = nat_trans.app (iso.inv \u03b1) X :=\n  rfl\n\nprotected instance hom_app_is_iso {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : is_iso (nat_trans.app (iso.hom \u03b1) X) :=\n  is_iso.mk (nat_trans.app (iso.inv \u03b1) X)\n\nprotected instance inv_app_is_iso {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) (X : C) : is_iso (nat_trans.app (iso.inv \u03b1) X) :=\n  is_iso.mk (nat_trans.app (iso.hom \u03b1) X)\n\n/-!\nUnfortunately we need a separate set of cancellation lemmas for components of natural isomorphisms,\nbecause the `simp` normal form is `\u03b1.hom.app X`, rather than `\u03b1.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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {X : C} {Z : D} (g : functor.obj G X \u27f6 Z) (g' : functor.obj G X \u27f6 Z) : nat_trans.app (iso.hom \u03b1) X \u226b g = nat_trans.app (iso.hom \u03b1) X \u226b g' \u2194 g = g' := sorry\n\n@[simp] theorem cancel_nat_iso_inv_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {X : C} {Z : D} (g : functor.obj F X \u27f6 Z) (g' : functor.obj F X \u27f6 Z) : nat_trans.app (iso.inv \u03b1) X \u226b g = nat_trans.app (iso.inv \u03b1) X \u226b g' \u2194 g = g' := sorry\n\n@[simp] theorem cancel_nat_iso_hom_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {X : D} {Y : C} (f : X \u27f6 functor.obj F Y) (f' : X \u27f6 functor.obj F Y) : f \u226b nat_trans.app (iso.hom \u03b1) Y = f' \u226b nat_trans.app (iso.hom \u03b1) Y \u2194 f = f' := sorry\n\n@[simp] theorem cancel_nat_iso_inv_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {X : D} {Y : C} (f : X \u27f6 functor.obj G Y) (f' : X \u27f6 functor.obj G Y) : f \u226b nat_trans.app (iso.inv \u03b1) Y = f' \u226b nat_trans.app (iso.inv \u03b1) Y \u2194 f = f' := sorry\n\n@[simp] theorem cancel_nat_iso_hom_right_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {W : D} {X : D} {X' : D} {Y : C} (f : W \u27f6 X) (g : X \u27f6 functor.obj F Y) (f' : W \u27f6 X') (g' : X' \u27f6 functor.obj F Y) : f \u226b g \u226b nat_trans.app (iso.hom \u03b1) Y = f' \u226b g' \u226b nat_trans.app (iso.hom \u03b1) Y \u2194 f \u226b g = f' \u226b g' := sorry\n\n@[simp] theorem cancel_nat_iso_inv_right_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u2245 G) {W : D} {X : D} {X' : D} {Y : C} (f : W \u27f6 X) (g : X \u27f6 functor.obj G Y) (f' : W \u27f6 X') (g' : X' \u27f6 functor.obj G Y) : f \u226b g \u226b nat_trans.app (iso.inv \u03b1) Y = f' \u226b g' \u226b nat_trans.app (iso.inv \u03b1) Y \u2194 f \u226b g = f' \u226b g' := sorry\n\ntheorem naturality_1 {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} {X : C} {Y : C} (\u03b1 : F \u2245 G) (f : X \u27f6 Y) : nat_trans.app (iso.inv \u03b1) X \u226b functor.map F f \u226b nat_trans.app (iso.hom \u03b1) Y = functor.map G f := sorry\n\ntheorem naturality_2 {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} {X : C} {Y : C} (\u03b1 : F \u2245 G) (f : X \u27f6 Y) : nat_trans.app (iso.hom \u03b1) X \u226b functor.map G f \u226b nat_trans.app (iso.inv \u03b1) 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u27f6 G) [(X : C) \u2192 is_iso (nat_trans.app \u03b1 X)] : is_iso \u03b1 :=\n  is_iso.mk (nat_trans.mk fun (X : C) => inv (nat_trans.app \u03b1 X))\n\n/--\nThe components of a natural isomorphism are isomorphisms.\n-/\nprotected instance is_iso_app_of_is_iso {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (\u03b1 : F \u27f6 G) [is_iso \u03b1] (X : C) : is_iso (nat_trans.app \u03b1 X) :=\n  is_iso.mk (nat_trans.app (inv \u03b1) 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (app : (X : C) \u2192 functor.obj F X \u2245 functor.obj G X) (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), functor.map F f \u226b iso.hom (app Y) = iso.hom (app X) \u226b functor.map G f) : F \u2245 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (app' : (X : C) \u2192 functor.obj F X \u2245 functor.obj G X) (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), functor.map F f \u226b iso.hom (app' Y) = iso.hom (app' X) \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (app : (X : C) \u2192 functor.obj F X \u2245 functor.obj G X) (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), functor.map F f \u226b iso.hom (app Y) = iso.hom (app X) \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D} {G : C \u2964 D} (app : (X : C) \u2192 functor.obj F X \u2245 functor.obj G X) (naturality : \u2200 {X Y : C} (f : X \u27f6 Y), functor.map F f \u226b iso.hom (app Y) = iso.hom (app X) \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {F : C \u2964 D} {G : C \u2964 D} {H : D \u2964 E} {I : D \u2964 E} (\u03b1 : F \u2245 G) (\u03b2 : H \u2245 I) : F \u22d9 H \u2245 G \u22d9 I :=\n  iso.mk (iso.hom \u03b1 \u25eb iso.hom \u03b2) (iso.inv \u03b1 \u25eb iso.inv \u03b2)\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\u00e9my Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: R\u00e9my 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 : \u03b9 \u2192 \u03b1 \u2192 \u03b2` with hypothesis\n`hf : \u2200 i, ae_measurable (f i) \u03bc`, and a pointwise property `p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop` such that we\nhave `hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb 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* `\u03bc (ae_seq_set hf p)\u1d9c = 0`\n* `x \u2208 ae_seq_set hf p \u2192 \u2200 i : \u03b9, ae_seq hf hp i x = f i x`\n* `x \u2208 ae_seq_set hf p \u2192 p x (\u03bb n, f n x)`\n-/\n\nopen measure_theory\nopen_locale classical\n\nvariables {\u03b9 : Sort*} {\u03b1 \u03b2 \u03b3 : Type*} [measurable_space \u03b1] [measurable_space \u03b2]\n  {f : \u03b9 \u2192 \u03b1 \u2192 \u03b2} {\u03bc : measure \u03b1} {p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop}\n\n/-- If we have the additional hypothesis `\u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)`, this is a measurable set\nwhose complement has measure 0 such that for all `x \u2208 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 (\u03bb n, f n x)`. -/\ndef ae_seq_set (hf : \u2200 i, ae_measurable (f i) \u03bc) (p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop) : set \u03b1 :=\n(to_measurable \u03bc {x | (\u2200 i, f i x = (hf i).mk (f i) x) \u2227 p x (\u03bb n, f n x)}\u1d9c)\u1d9c\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 : \u2200 i, ae_measurable (f i) \u03bc) (p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop) : \u03b9 \u2192 \u03b1 \u2192 \u03b2 :=\n\u03bb i x, ite (x \u2208 ae_seq_set hf p) ((hf i).mk (f i) x) (\u27e8f i x\u27e9 : nonempty \u03b2).some\n\nnamespace ae_seq\n\nsection mem_ae_seq_set\n\nlemma mk_eq_fun_of_mem_ae_seq_set (hf : \u2200 i, ae_measurable (f i) \u03bc) {x : \u03b1}\n  (hx : x \u2208 ae_seq_set hf p) (i : \u03b9) :\n  (hf i).mk (f i) x = f i x :=\nbegin\n  have h_ss : ae_seq_set hf p \u2286 {x | \u2200 i, f i x = (hf i).mk (f i) x},\n  { rw [ae_seq_set, \u2190compl_compl {x | \u2200 i, f i x = (hf i).mk (f i) x}, set.compl_subset_compl],\n    refine set.subset.trans (set.compl_subset_compl.mpr (\u03bb 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 : \u2200 i, ae_measurable (f i) \u03bc) {x : \u03b1}\n  (hx : x \u2208 ae_seq_set hf p) (i : \u03b9) :\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 : \u2200 i, ae_measurable (f i) \u03bc) {x : \u03b1}\n  (hx : x \u2208 ae_seq_set hf p) (i : \u03b9) :\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 : \u2200 i, ae_measurable (f i) \u03bc)\n  {x : \u03b1} (hx : x \u2208 ae_seq_set hf p) :\n  p x (\u03bb n, ae_seq hf p n x) :=\nbegin\n  simp only [ae_seq, hx, if_true],\n  rw funext (\u03bb n, mk_eq_fun_of_mem_ae_seq_set hf hx n),\n  have h_ss : ae_seq_set hf p \u2286 {x | p x (\u03bb n, f n x)},\n  { rw [\u2190compl_compl {x | p x (\u03bb 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 \u03bb 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 : \u2200 i, ae_measurable (f i) \u03bc)\n  {x : \u03b1} (hx : x \u2208 ae_seq_set hf p) :\n  p x (\u03bb n, f n x) :=\nbegin\n  have h_eq : (\u03bb n, f n x) = \u03bb n, ae_seq hf p n x,\n    from funext (\u03bb 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 : \u2200 i, ae_measurable (f i) \u03bc) (p : \u03b1 \u2192 (\u03b9 \u2192 \u03b2) \u2192 Prop)\n  (i : \u03b9) :\n  measurable (ae_seq hf p i) :=\nmeasurable.ite ae_seq_set_measurable_set (hf i).measurable_mk $ measurable_const' $\n  \u03bb x y, rfl\n\nlemma measure_compl_ae_seq_set_eq_zero [countable \u03b9] (hf : \u2200 i, ae_measurable (f i) \u03bc)\n  (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) :\n  \u03bc (ae_seq_set hf p)\u1d9c = 0 :=\nbegin\n  rw [ae_seq_set, compl_compl, measure_to_measurable],\n  have hf_eq := \u03bb i, (hf i).ae_eq_mk,\n  simp_rw [filter.eventually_eq, \u2190ae_all_iff] at hf_eq,\n  exact filter.eventually.and hf_eq hp,\nend\n\nlemma ae_seq_eq_mk_ae [countable \u03b9] (hf : \u2200 i, ae_measurable (f i) \u03bc)\n  (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) :\n  \u2200\u1d50 (a : \u03b1) \u2202\u03bc, \u2200 (i : \u03b9), ae_seq hf p i a = (hf i).mk (f i) a :=\nbegin\n  have h_ss : ae_seq_set hf p \u2286 {a : \u03b1 | \u2200 i, ae_seq hf p i a = (hf i).mk (f i) a},\n    from \u03bb 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 \u03b9] (hf : \u2200 i, ae_measurable (f i) \u03bc)\n  (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) :\n  \u2200\u1d50 (a : \u03b1) \u2202\u03bc, \u2200 (i : \u03b9), ae_seq hf p i a = f i a :=\nbegin\n  have h_ss : {a : \u03b1 | \u00ac\u2200 (i : \u03b9), ae_seq hf p i a = f i a} \u2286 (ae_seq_set hf p)\u1d9c,\n    from \u03bb x, mt (\u03bb 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 \u03b9] (hf : \u2200 i, ae_measurable (f i) \u03bc)\n  (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) (n : \u03b9) :\n  ae_seq hf p n =\u1d50[\u03bc] f n:=\nae_all_iff.mp (ae_seq_eq_fun_ae hf hp) n\n\nlemma supr [complete_lattice \u03b2] [countable \u03b9]\n  (hf : \u2200 i, ae_measurable (f i) \u03bc) (hp : \u2200\u1d50 x \u2202\u03bc, p x (\u03bb n, f n x)) :\n  (\u2a06 n, ae_seq hf p n) =\u1d50[\u03bc] \u2a06 n, f n :=\nbegin\n  simp_rw [filter.eventually_eq, ae_iff, supr_apply],\n  have h_ss : ae_seq_set hf p \u2286 {a : \u03b1 | (\u2a06 (i : \u03b9), ae_seq hf p i a) = \u2a06 (i : \u03b9), f i a},\n  { intros x hx,\n    congr,\n    exact funext (\u03bb 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\u207b\u00b9 * b = a * b`.\n\nFirst we introduce the one step reduction relation\n  `free_group.red.step`:  w * x * x\u207b\u00b9 * 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 \u03b1` 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 {\u03b1 : Type*}\n\nlocal attribute [simp] list.append_eq_has_append\n\nnamespace free_group\nvariables {L L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)}\n\n/-- Reduction step: `w * x * x\u207b\u00b9 * v ~> w * v` -/\ninductive red.step : list (\u03b1 \u00d7 bool) \u2192 list (\u03b1 \u00d7 bool) \u2192 Prop\n| bnot {L\u2081 L\u2082 x b} : red.step (L\u2081 ++ (x, b) :: (x, bnot b) :: L\u2082) (L\u2081 ++ L\u2082)\nattribute [simp] red.step.bnot\n\n/-- Reflexive-transitive closure of red.step -/\ndef red : list (\u03b1 \u00d7 bool) \u2192 list (\u03b1 \u00d7 bool) \u2192 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\u2081 L\u2082 \u2192 red L\u2082 L\u2083 \u2192 red L\u2081 L\u2083 := refl_trans_gen.trans\n\nnamespace red\n\n/-- Predicate asserting that word `w\u2081` can be reduced to `w\u2082` in one step, i.e. there are words\n`w\u2083 w\u2084` and letter `x` such that `w\u2081 = w\u2083xx\u207b\u00b9w\u2084` and `w\u2082 = w\u2083w\u2084`  -/\ntheorem step.length : \u2200 {L\u2081 L\u2082 : list (\u03b1 \u00d7 bool)}, step L\u2081 L\u2082 \u2192 L\u2082.length + 2 = L\u2081.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\u2081 ++ (x, bnot b) :: (x, b) :: L\u2082) (L\u2081 ++ L\u2082) :=\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 : \u2200 {L\u2081 L\u2082 L\u2083 : list (\u03b1 \u00d7 bool)}, step L\u2082 L\u2083 \u2192 step (L\u2081 ++ L\u2082) (L\u2081 ++ L\u2083)\n| _ _ _ red.step.bnot := by rw [\u2190 list.append_assoc, \u2190 list.append_assoc]; constructor\n\ntheorem step.cons {x} (H : red.step L\u2081 L\u2082) : red.step (x :: L\u2081) (x :: L\u2082) :=\n@step.append_left _ [x] _ _ H\n\ntheorem step.append_right : \u2200 {L\u2081 L\u2082 L\u2083 : list (\u03b1 \u00d7 bool)}, step L\u2081 L\u2082 \u2192 step (L\u2081 ++ L\u2083) (L\u2082 ++ L\u2083)\n| _ _ _ red.step.bnot := by simp\n\nlemma not_step_nil : \u00ac step [] L :=\nbegin\n  generalize h' : [] = L',\n  assume h,\n  cases h with L\u2081 L\u2082,\n  simp [list.nil_eq_append_iff] at h',\n  contradiction\nend\n\nlemma step.cons_left_iff {a : \u03b1} {b : bool} :\n  step ((a, b) :: L\u2081) L\u2082 \u2194 (\u2203L, step L\u2081 L \u2227 L\u2082 = (a, b) :: L) \u2228 (L\u2081 = (a, bnot b)::L\u2082) :=\nbegin\n  split,\n  { generalize hL : ((a, b) :: L\u2081 : list _) = L,\n    assume h,\n    rcases h with \u27e8_ | \u27e8p, s'\u27e9, e, a', b'\u27e9,\n    { simp at hL, simp [*] },\n    { simp at hL,\n      rcases hL with \u27e8rfl, rfl\u27e9,\n      refine or.inl \u27e8s' ++ e, step.bnot, _\u27e9,\n      simp } },\n  { assume h,\n    rcases h with \u27e8L, h, rfl\u27e9 | rfl,\n    { exact step.cons h },\n    { exact step.cons_bnot } }\nend\n\nlemma not_step_singleton : \u2200 {p : \u03b1 \u00d7 bool}, \u00ac step [p] L\n| (a, b) := by simp [step.cons_left_iff, not_step_nil]\n\nlemma step.cons_cons_iff : \u2200{p : \u03b1 \u00d7 bool}, step (p :: L\u2081) (p :: L\u2082) \u2194 step L\u2081 L\u2082 :=\nby simp [step.cons_left_iff, iff_def, or_imp_distrib] {contextual := tt}\n\nlemma step.append_left_iff : \u2200L, step (L ++ L\u2081) (L ++ L\u2082) \u2194 step L\u2081 L\u2082\n| [] := by simp\n| (p :: l) := by simp [step.append_left_iff l, step.cons_cons_iff]\n\nprivate theorem step.diamond_aux : \u2200 {L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)} {x1 b1 x2 b2},\n  L\u2081 ++ (x1, b1) :: (x1, bnot b1) :: L\u2082 = L\u2083 ++ (x2, b2) :: (x2, bnot b2) :: L\u2084 \u2192\n  L\u2081 ++ L\u2082 = L\u2083 ++ L\u2084 \u2228 \u2203 L\u2085, red.step (L\u2081 ++ L\u2082) L\u2085 \u2227 red.step (L\u2083 ++ L\u2084) L\u2085\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 \u27e8_, red.step.bnot, red.step.cons_bnot\u27e9\n| ((x3,b3)::(x4,b4)::tl) _ []                     _ _ _ _ _ H :=\n  by injections; subst_vars; simp; right; exact \u27e8_, red.step.cons_bnot, red.step.bnot\u27e9\n| ((x3,b3)::tl) _ ((x4,b4)::tl2) _ _ _ _ _ H :=\n  let \u27e8H1, H2\u27e9 := 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 \u27e8L\u2085, H3, H4\u27e9 := or.inr\n      \u27e8_, step.cons H3, by simpa [H1] using step.cons H4\u27e9\n  end\n\ntheorem step.diamond : \u2200 {L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)},\n  red.step L\u2081 L\u2083 \u2192 red.step L\u2082 L\u2084 \u2192 L\u2081 = L\u2082 \u2192\n  L\u2083 = L\u2084 \u2228 \u2203 L\u2085, red.step L\u2083 L\u2085 \u2227 red.step L\u2084 L\u2085\n| _ _ _ _ red.step.bnot red.step.bnot H := step.diamond_aux H\n\nlemma step.to_red : step L\u2081 L\u2082 \u2192 red L\u2081 L\u2082 :=\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\u2081 L\u2082 \u2192 red L\u2081 L\u2083 \u2192 join red L\u2082 L\u2083 :=\nrelation.church_rosser (assume a b c hab hac,\nmatch b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := \u27e8b, by refl, by refl\u27e9\n| b, c, or.inr \u27e8d, hbd, hcd\u27e9 := \u27e8d, refl_gen.single hbd, hcd.to_red\u27e9\nend)\n\nlemma cons_cons {p} : red L\u2081 L\u2082 \u2192 red (p :: L\u2081) (p :: L\u2082) :=\nrefl_trans_gen_lift (list.cons p) (assume a b, step.cons)\n\nlemma cons_cons_iff (p) : red (p :: L\u2081) (p :: L\u2082) \u2194 red L\u2081 L\u2082 :=\niff.intro\n  begin\n    generalize eq\u2081 : (p :: L\u2081 : list _) = LL\u2081,\n    generalize eq\u2082 : (p :: L\u2082 : list _) = LL\u2082,\n    assume h,\n    induction h using relation.refl_trans_gen.head_induction_on\n      with L\u2081 L\u2082 h\u2081\u2082 h ih\n      generalizing L\u2081 L\u2082,\n    { subst_vars, cases eq\u2082, constructor },\n    { subst_vars,\n      cases p with a b,\n      rw [step.cons_left_iff] at h\u2081\u2082,\n      rcases h\u2081\u2082 with \u27e8L, h\u2081\u2082, rfl\u27e9 | rfl,\n      { exact (ih rfl rfl).head h\u2081\u2082 },\n      { exact (cons_cons h).tail step.cons_bnot_rev } }\n  end\n  cons_cons\n\nlemma append_append_left_iff : \u2200L, red (L ++ L\u2081) (L ++ L\u2082) \u2194 red L\u2081 L\u2082\n| []       := iff.refl _\n| (p :: L) := by simp [append_append_left_iff L, cons_cons_iff]\n\nlemma append_append (h\u2081 : red L\u2081 L\u2083) (h\u2082 : red L\u2082 L\u2084) : red (L\u2081 ++ L\u2082) (L\u2083 ++ L\u2084) :=\n(refl_trans_gen_lift (\u03bbL, L ++ L\u2082) (assume a b, step.append_right) h\u2081).trans\n  ((append_append_left_iff _).2 h\u2082)\n\nlemma to_append_iff : red L (L\u2081 ++ L\u2082) \u2194 (\u2203L\u2083 L\u2084, L = L\u2083 ++ L\u2084 \u2227 red L\u2083 L\u2081 \u2227 red L\u2084 L\u2082) :=\niff.intro\n  begin\n    generalize eq : L\u2081 ++ L\u2082 = L\u2081\u2082,\n    assume h,\n    induction h with L' L\u2081\u2082 hLL' h ih generalizing L\u2081 L\u2082,\n    { exact \u27e8_, _, eq.symm, by refl, by refl\u27e9 },\n    { cases h with s e a b,\n      rcases list.append_eq_append_iff.1 eq with \u27e8s', rfl, rfl\u27e9 | \u27e8e', rfl, rfl\u27e9,\n      { have : L\u2081 ++ (s' ++ ((a, b) :: (a, bnot b) :: e)) = (L\u2081 ++ s') ++ ((a, b) :: (a, bnot b) :: e),\n        { simp },\n        rcases ih this with \u27e8w\u2081, w\u2082, rfl, h\u2081, h\u2082\u27e9,\n        exact \u27e8w\u2081, w\u2082, rfl, h\u2081, h\u2082.tail step.bnot\u27e9 },\n      { have : (s ++ ((a, b) :: (a, bnot b) :: e')) ++ L\u2082 = s ++ ((a, b) :: (a, bnot b) :: (e' ++ L\u2082)),\n        { simp },\n        rcases ih this with \u27e8w\u2081, w\u2082, rfl, h\u2081, h\u2082\u27e9,\n        exact \u27e8w\u2081, w\u2082, rfl, h\u2081.tail step.bnot, h\u2082\u27e9 }, }\n  end\n  (assume \u27e8L\u2083, L\u2084, eq, h\u2083, h\u2084\u27e9, eq.symm \u25b8 append_append h\u2083 h\u2084)\n\n/-- The empty word `[]` only reduces to itself. -/\ntheorem nil_iff : red [] L \u2194 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\u2081 \u2194 L\u2081 = [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\u207b\u00b9` -/\ntheorem cons_nil_iff_singleton {x b} : red ((x, b) :: L) [] \u2194 red L [(x, bnot b)] :=\niff.intro\n  (assume h,\n    have h\u2081 : red ((x, bnot b) :: (x, b) :: L) [(x, bnot b)], from cons_cons h,\n    have h\u2082 : red ((x, bnot b) :: (x, b) :: L) L, from refl_trans_gen.single step.cons_bnot_rev,\n    let \u27e8L', h\u2081, h\u2082\u27e9 := church_rosser h\u2081 h\u2082 in\n    by rw [singleton_iff] at h\u2081; 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) \u2260 (x2, b2)) :\n  red [(x1, bnot b1), (x2, b2)] L \u2194 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 \u27e8rfl, \u27e8rfl, rfl\u27e9, \u27e8rfl, rfl\u27e9, rfl\u27e9, subst_vars,\n  simp at h,\n  contradiction\nend\n\n/-- If `x` and `y` are distinct letters and `w\u2081 w\u2082` are words such that `xw\u2081` reduces to `yw\u2082`, then\n`w\u2081` reduces to `x\u207b\u00b9yw\u2082`. -/\ntheorem inv_of_red_of_ne {x1 b1 x2 b2}\n  (H1 : (x1, b1) \u2260 (x2, b2))\n  (H2 : red ((x1, b1) :: L\u2081) ((x2, b2) :: L\u2082)) :\n  red L\u2081 ((x1, bnot b1) :: (x2, b2) :: L\u2082) :=\nbegin\n  have : red ((x1, b1) :: L\u2081) ([(x2, b2)] ++ L\u2082), from H2,\n  rcases to_append_iff.1 this with \u27e8_ | \u27e8p, L\u2083\u27e9, L\u2084, eq, h\u2081, h\u2082\u27e9,\n  { simp [nil_iff] at h\u2081, contradiction },\n  { cases eq,\n    show red (L\u2083 ++ L\u2084) ([(x1, bnot b1), (x2, b2)] ++ L\u2082),\n    apply append_append _ h\u2082,\n    have h\u2081 : red ((x1, bnot b1) :: (x1, b1) :: L\u2083) [(x1, bnot b1), (x2, b2)],\n    { exact cons_cons h\u2081 },\n    have h\u2082 : red ((x1, bnot b1) :: (x1, b1) :: L\u2083) L\u2083,\n    { exact step.cons_bnot_rev.to_red },\n    rcases church_rosser h\u2081 h\u2082 with \u27e8L', h\u2081, h\u2082\u27e9,\n    rw [red_iff_irreducible H1] at h\u2081,\n    rwa [h\u2081] at h\u2082 }\nend\n\ntheorem step.sublist (H : red.step L\u2081 L\u2082) : L\u2082 <+ L\u2081 :=\nby cases H; simp; constructor; constructor; refl\n\n/-- If `w\u2081 w\u2082` are words such that `w\u2081` reduces to `w\u2082`, then `w\u2082` is a sublist of `w\u2081`. -/\ntheorem sublist : red L\u2081 L\u2082 \u2192 L\u2082 <+ L\u2081 :=\nrefl_trans_gen_of_transitive_reflexive\n  (\u03bbl, list.sublist.refl l) (\u03bba b c hab hbc, list.sublist.trans hbc hab) (\u03bba b, red.step.sublist)\n\ntheorem sizeof_of_step : \u2200 {L\u2081 L\u2082 : list (\u03b1 \u00d7 bool)}, step L\u2081 L\u2082 \u2192 L\u2082.sizeof < L\u2081.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\u2081 L\u2082) : \u2203 n, L\u2081.length = L\u2082.length + 2 * n :=\nbegin\n  induction h with L\u2082 L\u2083 h\u2081\u2082 h\u2082\u2083 ih,\n  { exact \u27e80, rfl\u27e9 },\n  { rcases ih with \u27e8n, eq\u27e9,\n    existsi (1 + n),\n    simp [mul_add, eq, (step.length h\u2082\u2083).symm] }\nend\n\ntheorem antisymm (h\u2081\u2082 : red L\u2081 L\u2082) : red L\u2082 L\u2081 \u2192 L\u2081 = L\u2082 :=\nmatch L\u2081, h\u2081\u2082.cases_head with\n| _,  or.inl rfl            := assume h, rfl\n| L\u2081, or.inr \u27e8L\u2083, h\u2081\u2083, h\u2083\u2082\u27e9 := assume h\u2082\u2081,\n  let \u27e8n, eq\u27e9 := length (h\u2083\u2082.trans h\u2082\u2081) in\n  have list.length L\u2083 + 0 = list.length L\u2083 + (2 * n + 2),\n    by simpa [(step.length h\u2081\u2083).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 \u03b1)) :=\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           := \u27e8b, by refl, by refl\u27e9\n| b, c, or.inr \u27e8d, hbd, hcd\u27e9 := \u27e8d, refl_gen.single hbd, refl_trans_gen.single hcd\u27e9\nend)\n\ntheorem join_red_of_step (h : red.step L\u2081 L\u2082) : join red L\u2081 L\u2082 :=\njoin_of_single reflexive_refl_trans_gen h.to_red\n\ntheorem eqv_gen_step_iff_join_red : eqv_gen red.step L\u2081 L\u2082 \u2194 join red L\u2081 L\u2082 :=\niff.intro\n  (assume h,\n    have eqv_gen (join red) L\u2081 L\u2082 := 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 (\u03b1 : Type*) : Type* :=\nquot $ @free_group.red.step \u03b1\n\nnamespace free_group\n\nvariables {\u03b1} {L L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)}\n\ndef mk (L) : free_group \u03b1 := 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 (\u03b2 : Type*) (f : list (\u03b1 \u00d7 bool) \u2192 \u03b2)\n  (H : \u2200 L\u2081 L\u2082, red.step L\u2081 L\u2082 \u2192 f L\u2081 = f L\u2082) :\nquot.lift f H (mk L) = f L := rfl\n\n@[simp] lemma quot_lift_on_mk (\u03b2 : Type*) (f : list (\u03b1 \u00d7 bool) \u2192 \u03b2)\n  (H : \u2200 L\u2081 L\u2082, red.step L\u2081 L\u2082 \u2192 f L\u2081 = f L\u2082) :\nquot.lift_on (mk L) f H = f L := rfl\n\ninstance : has_one (free_group \u03b1) := \u27e8mk []\u27e9\nlemma one_eq_mk : (1 : free_group \u03b1) = mk [] := rfl\n\ninstance : has_mul (free_group \u03b1) :=\n\u27e8\u03bb x y, quot.lift_on x\n    (\u03bb L\u2081, quot.lift_on y (\u03bb L\u2082, mk $ L\u2081 ++ L\u2082) (\u03bb L\u2082 L\u2083 H, quot.sound $ red.step.append_left H))\n    (\u03bb L\u2081 L\u2082 H, quot.induction_on y $ \u03bb L\u2083, quot.sound $ red.step.append_right H)\u27e9\n@[simp] lemma mul_mk : mk L\u2081 * mk L\u2082 = mk (L\u2081 ++ L\u2082) := rfl\n\ninstance : has_inv (free_group \u03b1) :=\n\u27e8\u03bbx, quot.lift_on x (\u03bb L, mk (L.map $ \u03bb x : \u03b1 \u00d7 bool, (x.1, bnot x.2)).reverse)\n  (assume a b h, quot.sound $ by cases h; simp)\u27e9\n@[simp] lemma inv_mk : (mk L)\u207b\u00b9 = mk (L.map $ \u03bb x : \u03b1 \u00d7 bool, (x.1, bnot x.2)).reverse := rfl\n\ninstance : group (free_group \u03b1) :=\n{ mul := (*),\n  one := 1,\n  inv := has_inv.inv,\n  mul_assoc := by rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9 \u27e8L\u2083\u27e9; simp,\n  one_mul := by rintros \u27e8L\u27e9; refl,\n  mul_one := by rintros \u27e8L\u27e9; simp [one_eq_mk],\n  mul_left_inv := by rintros \u27e8L\u27e9; exact (list.rec_on L rfl $\n    \u03bb \u27e8x, b\u27e9 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 : \u03b1) : free_group \u03b1 :=\nmk [(x, tt)]\n\ntheorem red.exact : mk L\u2081 = mk L\u2082 \u2194 join red L\u2081 L\u2082 :=\ncalc (mk L\u2081 = mk L\u2082) \u2194 eqv_gen red.step L\u2081 L\u2082 : iff.intro (quot.exact _) quot.eqv_gen_sound\n  ... \u2194 join red L\u2081 L\u2082 : 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 : \u03b1} (H : of x = of y) : x = y :=\nlet \u27e8L\u2081, hx, hy\u27e9 := red.exact.1 H in\nby simp [red.singleton_iff] at hx hy; cc\n\nsection to_group\n\nvariables {\u03b2 : Type*} [group \u03b2] (f : \u03b1 \u2192 \u03b2) {x y : free_group \u03b1}\n\ndef to_group.aux : list (\u03b1 \u00d7 bool) \u2192 \u03b2 :=\n\u03bb L, list.prod $ L.map $ \u03bb x, cond x.2 (f x.1) (f x.1)\u207b\u00b9\n\ntheorem red.step.to_group {f : \u03b1 \u2192 \u03b2} (H : red.step L\u2081 L\u2082) :\n  to_group.aux f L\u2081 = to_group.aux f L\u2082 :=\nby cases H with _ _ _ b; cases b; simp [to_group.aux]\n\n/-- If `\u03b2` is a group, then any function from `\u03b1` to `\u03b2`\nextends uniquely to a group homomorphism from\nthe free group over `\u03b1` to `\u03b2` -/\ndef to_group : free_group \u03b1 \u2192 \u03b2 :=\nquot.lift (to_group.aux f) $ \u03bb L\u2081 L\u2082 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 $ \u03bb x, cond x.2 (f x.1) (f x.1)\u207b\u00b9) :=\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\u27e8by rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9; simp\u27e9\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\u207b\u00b9 = (to_group f x)\u207b\u00b9 :=\nis_group_hom.inv _ _\n\ntheorem to_group.unique (g : free_group \u03b1 \u2192 \u03b2) [is_group_hom g]\n  (hg : \u2200 x, g (of x) = f x) : \u2200{x}, g x = to_group f x :=\nby rintros \u27e8L\u27e9; exact list.rec_on L (is_group_hom.one g)\n(\u03bb \u27e8x, b\u27e9 t (ih : g (mk t) = _), bool.rec_on b\n  (show g ((of x)\u207b\u00b9 * 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 \u03b1) : to_group of x = x :=\neq.symm $ to_group.unique id (\u03bb x, rfl)\n\ntheorem to_group.range_subset {s : set \u03b2} [is_subgroup s] (H : set.range f \u2286 s) :\n  set.range (to_group f) \u2286 s :=\nby rintros _ \u27e8\u27e8L\u27e9, rfl\u27e9; exact list.rec_on L (is_submonoid.one_mem s)\n(\u03bb \u27e8x, b\u27e9 tl ih, bool.rec_on b\n    (by simp at ih \u22a2; from is_submonoid.mul_mem\n      (is_subgroup.inv_mem $ H \u27e8x, rfl\u27e9) ih)\n    (by simp at ih \u22a2; from is_submonoid.mul_mem (H \u27e8x, rfl\u27e9) 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 $ \u03bb y \u27e8x, hx\u27e9, \u27e8of x, by simpa\u27e9)\n\nend to_group\n\nsection map\n\nvariables {\u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) {x y : free_group \u03b1}\n\ndef map.aux (L : list (\u03b1 \u00d7 bool)) : list (\u03b2 \u00d7 bool) :=\nL.map $ \u03bb x, (f x.1, x.2)\n\n/-- Any function from `\u03b1` to `\u03b2` extends uniquely\nto a group homomorphism from the free group\nver `\u03b1` to the free group over `\u03b2`. -/\ndef map (x : free_group \u03b1) : free_group \u03b2 :=\nx.lift_on (\u03bb L, mk $ map.aux f L) $\n\u03bb L\u2081 L\u2082 H, quot.sound $ by cases H; simp [map.aux]\n\ninstance map.is_group_hom : is_group_hom (map f) :=\n\u27e8by rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9; simp [map, map.aux]\u27e9\n\nvariable {f}\n\n@[simp] lemma map.mk : map f (mk L) = mk (L.map (\u03bb x, (f x.1, x.2))) :=\nrfl\n\n@[simp] lemma map.id : map id x = x :=\nhave H1 : (\u03bb (x : \u03b1 \u00d7 bool), x) = id := rfl,\nby rcases x with \u27e8L\u27e9; simp [H1]\n\n@[simp] lemma map.id' : map (\u03bb z, z) x = x := map.id\n\ntheorem map.comp {\u03b3 : Type*} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} {x} :\n  map g (map f x) = map (g \u2218 f) x :=\nby rcases x with \u27e8L\u27e9; 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\u207b\u00b9 = (map f x)\u207b\u00b9 :=\nis_group_hom.inv _ x\n\ntheorem map.unique (g : free_group \u03b1 \u2192 free_group \u03b2) [is_group_hom g]\n  (hg : \u2200 x, g (of x) = of (f x)) : \u2200{x}, g x = map f x :=\nby rintros \u27e8L\u27e9; exact list.rec_on L (is_group_hom.one g)\n(\u03bb \u27e8x, b\u27e9 t (ih : g (mk t) = map f (mk t)), bool.rec_on b\n  (show g ((of x)\u207b\u00b9 * mk t) = map f ((of x)\u207b\u00b9 * 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 {\u03b1 \u03b2} (e : \u03b1 \u2243 \u03b2) : free_group \u03b1 \u2243 free_group \u03b2 :=\n\u27e8map e, map e.symm,\n \u03bb x, by simp [function.comp, map.comp],\n \u03bb x, by simp [function.comp, map.comp]\u27e9\n\ntheorem map_eq_to_group : map f x = to_group (of \u2218 f) x :=\neq.symm $ map.unique _ $ \u03bb x, by simp\n\nend map\n\nsection prod\n\nvariables [group \u03b1] (x y : free_group \u03b1)\n\n/-- If `\u03b1` is a group, then any function from `\u03b1` to `\u03b1`\nextends uniquely to a homomorphism from the\nfree group over `\u03b1` to `\u03b1`. This is the multiplicative\nversion of `sum`. -/\ndef prod : \u03b1 :=\nto_group id x\n\nvariables {x y}\n\n@[simp] lemma prod_mk :\n  prod (mk L) = list.prod (L.map $ \u03bb x, cond x.2 x.1 x.1\u207b\u00b9) :=\nrfl\n\n@[simp] lemma prod.of {x : \u03b1} : prod (of x) = x :=\nto_group.of\n\ninstance prod.is_group_hom : is_group_hom (@prod \u03b1 _) :=\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 \u03b1) = 1 :=\nto_group.one\n\n@[simp] lemma prod.inv : prod x\u207b\u00b9 = (prod x)\u207b\u00b9 :=\nto_group.inv\n\nlemma prod.unique (g : free_group \u03b1 \u2192 \u03b1) [is_group_hom g]\n  (hg : \u2200 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 {\u03b2 : Type*} [group \u03b2] {f : \u03b1 \u2192 \u03b2} {x} :\n  to_group f x = prod (map f x) :=\neq.symm $ to_group.unique (prod \u2218 map f) $ \u03bb _, by simp\n\nsection sum\n\nvariables [add_group \u03b1] (x y : free_group \u03b1)\n\n/-- If `\u03b1` is a group, then any function from `\u03b1` to `\u03b1`\nextends uniquely to a homomorphism from the\nfree group over `\u03b1` to `\u03b1`. This is the additive\nversion of `prod`. -/\ndef sum : \u03b1 :=\n@prod (multiplicative _) _ x\n\nvariables {x y}\n\n@[simp] lemma sum_mk :\n  sum (mk L) = list.sum (L.map $ \u03bb x, cond x.2 x.1 (-x.1)) :=\nrfl\n\n@[simp] lemma sum.of {x : \u03b1} : sum (of x) = x :=\nprod.of\n\ninstance sum.is_group_hom : is_group_hom (@sum \u03b1 _) :=\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 \u03b1) = 0 :=\nprod.one\n\n@[simp] lemma sum.inv : sum x\u207b\u00b9 = -sum x :=\nprod.inv\n\nend sum\n\ndef free_group_empty_equiv_unit : free_group empty \u2243 unit :=\n{ to_fun    := \u03bb _, (),\n  inv_fun   := \u03bb _, 1,\n  left_inv  := by rintros \u27e8_ | \u27e8\u27e8\u27e8\u27e9, _\u27e9, _\u27e9\u27e9; refl,\n  right_inv := \u03bb \u27e8\u27e9, rfl }\n\ndef free_group_unit_equiv_int : free_group unit \u2243 int :=\n{ to_fun    := \u03bb x, sum $ map (\u03bb _, 1) x,\n  inv_fun   := \u03bb x, of () ^ x,\n  left_inv  := by rintros \u27e8L\u27e9; exact list.rec_on L rfl\n    (\u03bb \u27e8\u27e8\u27e9, b\u27e9 tl ih, by cases b; simp [gpow_add] at ih \u22a2; rw ih; refl),\n  right_inv := \u03bb x, int.induction_on x (by simp)\n    (\u03bb i ih, by simp at ih; simp [gpow_add, ih])\n    (\u03bb i ih, by simp at ih; simp [gpow_add, ih]) }\n\nsection reduce\n\nvariable [decidable_eq \u03b1]\n\n/-- The maximal reduction of a word. It is computable\niff `\u03b1` has decidable equality. -/\ndef reduce (L : list (\u03b1 \u00d7 bool)) : list (\u03b1 \u00d7 bool) :=\nlist.rec_on L [] $ \u03bb hd1 tl1 ih,\nlist.cases_on ih [hd1] $ \u03bb hd2 tl2,\nif hd1.1 = hd2.1 \u2227 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] (\u03bb hd tl,\n  if x.1 = hd.1 \u2227 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 \u2227 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} : \u2200 {L\u2081 L\u2082 L\u2083 : list (\u03b1 \u00d7 bool)} {x b}, reduce L\u2081 = L\u2082 ++ (x, b) :: (x, bnot b) :: L\u2083 \u2192 p\n| [] L2 L3 _ _ := \u03bb 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 \u2227 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 _|\u27e8a, L2\u27e9,\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\u2081) L\u2082) : reduce L\u2081 = L\u2082 :=\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\u2081 L\u2082) : reduce L\u2081 = reduce L\u2082 :=\nlet \u27e8L\u2083, HR13, HR23\u27e9 := 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\u2081 L\u2082) : reduce L\u2081 = reduce L\u2082 :=\nlet \u27e8L\u2083, HR13, HR23\u27e9 := 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\u2081 = mk L\u2082) : reduce L\u2081 = reduce L\u2082 :=\nlet \u27e8L\u2083, H13, H23\u27e9 := 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\u2081 = reduce L\u2082) : mk L\u2081 = mk L\u2082 :=\nred.exact.2 \u27e8reduce L\u2082, H \u25b8 reduce.red, reduce.red\u27e9\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\u2081 w\u2082` are such that `w\u2081` reduces to `w\u2082`,\nthen `w\u2082` reduces to the maximal reduction of `w\u2081`. -/\ntheorem reduce.rev (H : red L\u2081 L\u2082) : red L\u2082 (reduce L\u2081) :=\n(reduce.eq_of_red H).symm \u25b8 reduce.red\n\n/-- The function that sends an element of the free\ngroup to its maximal reduction. -/\ndef to_word : free_group \u03b1 \u2192 list (\u03b1 \u00d7 bool) :=\nquot.lift reduce $ \u03bb L\u2081 L\u2082 H, reduce.step.eq H\n\ndef to_word.mk : \u2200{x : free_group \u03b1}, mk (to_word x) = x :=\nby rintros \u27e8L\u27e9; exact reduce.self\n\ndef to_word.inj : \u2200(x y : free_group \u03b1), to_word x = to_word y \u2192 x = y :=\nby rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9; exact reduce.exact\n\n/-- Constructive Church-Rosser theorem (compare `church_rosser`). -/\ndef reduce.church_rosser (H12 : red L\u2081 L\u2082) (H13 : red L\u2081 L\u2083) :\n  { L\u2084 // red L\u2082 L\u2084 \u2227 red L\u2083 L\u2084 } :=\n\u27e8reduce L\u2081, reduce.rev H12, reduce.rev H13\u27e9\n\ninstance : decidable_eq (free_group \u03b1) :=\nfunction.injective.decidable_eq to_word.inj\n\ninstance red.decidable_rel : decidable_rel (@red \u03b1)\n| [] []          := is_true red.refl\n| [] (hd2::tl2)  := is_false $ \u03bb 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 $ \u03bb 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 \u25b8 red.cons_cons H\n    | is_false H := is_false $ \u03bb H2, H $ h \u25b8 (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 $ \u03bb H2, H $ red.inv_of_red_of_ne h H2\n    end\n\n/-- A list containing every word that `w\u2081` reduces to. -/\ndef red.enum (L\u2081 : list (\u03b1 \u00d7 bool)) : list (list (\u03b1 \u00d7 bool)) :=\nlist.filter (\u03bb L\u2082, red L\u2081 L\u2082) (list.sublists L\u2081)\n\ntheorem red.enum.sound (H : L\u2082 \u2208 red.enum L\u2081) : red L\u2081 L\u2082 :=\nlist.of_mem_filter H\n\ntheorem red.enum.complete (H : red L\u2081 L\u2082) : L\u2082 \u2208 red.enum L\u2081 :=\nlist.mem_filter_of_mem (list.mem_sublists.2 $ red.sublist H) H\n\ninstance : fintype { L\u2082 // red L\u2081 L\u2082 } :=\nfintype.subtype (list.to_finset $ red.enum L\u2081) $\n\u03bb L\u2082, \u27e8\u03bb H, red.enum.sound $ list.mem_to_finset.1 H,\n  \u03bb H, list.mem_to_finset.2 $ red.enum.complete H\u27e9\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) \u2208 l :=match l, idx with\n  | a::_, \u27e80, _\u27e9 => List.Mem.head a _\n  | _::as, \u27e8n + 1, isLt\u27e9 => List.Mem.tail _ <| get_in as \u27e8n, Nat.le_of_succ_le_succ isLt\u27e9\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 \u27e8idx, isLt\u27e9 = 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 \u2208 (l.eraseIdx idx) \u2192 a \u2208 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 \u2208 (l.set idx new_value) \u2192 a = new_value \u2228 a \u2208 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 \u2208 l \u2192 \u2203 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 \u27e80, by simp_arith\u27e9\n      . apply (index_exists xs (by assumption)).elim\n        intro i xs_get_i\n        exists \u27e8i.val + 1, by simp_arith only [List.length] ; exact i.isLt\u27e9\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 \u2208 (l.map f) \u2192 \u2203 u, u \u2208 l \u2227 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 \u27e8head, List.Mem.head .., rfl\u27e9\n    . rename_i v_in_map_of_tail\n      cases IH v_in_map_of_tail\n      rename_i u u_hyp\n      exact \u27e8u, List.Mem.tail _ u_hyp.left, u_hyp.right\u27e9\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 :=\u03bb 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, \u27e80, isLt\u27e9 => rfl\n  | head :: tail, \u27e8n + 1, isLt\u27e9 => 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 {\u03b1 : Type*} [linear_ordered_semifield \u03b1] {a b : \u03b1} (ha : 0 < a)\n  (hb : 0 < b) (k : \u2115) : 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) (\u03b5 : \u211d) (\u03b5_pos : 0 < \u03b5)\n  {\u03d5 : X \u2192 \u211d} (cont : continuous \u03d5) (nonneg : \u2200 y, 0 \u2264 \u03d5 y) :\n  \u2203 (\u03b5' > 0) (x' : X), \u03b5' \u2264 \u03b5 \u2227\n                       d x' x \u2264 2*\u03b5 \u2227\n                       \u03b5 * \u03d5(x) \u2264 \u03b5' * \u03d5 x' \u2227\n                       \u2200 y, d x' y \u2264 \u03b5' \u2192 \u03d5 y \u2264 2*\u03d5 x' :=\nbegin\n  by_contradiction H,\n  have reformulation : \u2200 x' (k : \u2115), \u03b5 * \u03d5 x \u2264 \u03b5 / 2 ^ k * \u03d5 x' \u2194 2^k * \u03d5 x \u2264 \u03d5 x',\n  { intros x' k,\n    rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left \u03b5_pos, mul_comm],\n    positivity },\n  -- Now let's specialize to `\u03b5/2^k`\n  replace H : \u2200 k : \u2115, \u2200 x', d x' x \u2264 2 * \u03b5 \u2227 2^k * \u03d5 x \u2264 \u03d5 x' \u2192\n    \u2203 y, d x' y \u2264 \u03b5/2^k \u2227 2 * \u03d5 x' < \u03d5 y,\n  { intros k x',\n    push_neg at H,\n    simpa [reformulation] using H (\u03b5/2^k) (by simp [\u03b5_pos]) x' (by simp [\u03b5_pos.le, one_le_two]) },\n  clear reformulation,\n  haveI : nonempty X := \u27e8x\u27e9,\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 : \u2115 \u2192 X := \u03bb 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    \u2200 n,\n      d (u n) x \u2264 2 * \u03b5 \u2227 2^n * \u03d5 x \u2264 \u03d5 (u n) \u2192\n      d (u n) (u $ n + 1) \u2264 \u03b5 / 2 ^ n \u2227 2 * \u03d5 (u n) < \u03d5 (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 : \u2200 n, d (u n) (u (n + 1)) \u2264 \u03b5 / 2 ^ n \u2227 2 * \u03d5 (u n) < \u03d5 (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, \u03b5_pos.le, le_refl] using hu },\n    have A : d (u (n+1)) x \u2264 2 * \u03b5,\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          \u2264 \u2211 i in r, d (u i) (u $ i+1) : dist_le_range_sum_dist u (n + 1)\n      ... \u2264 \u2211 i in r, \u03b5/2^i             : sum_le_sum (\u03bb i i_in, (IH i $ nat.lt_succ_iff.mp $\n                                                                  finset.mem_range.mp i_in).1)\n      ... = \u2211 i in r, (1/2)^i*\u03b5         : by { congr' with i, field_simp }\n      ... = (\u2211 i in r, (1/2)^i)*\u03b5       : finset.sum_mul.symm\n      ... \u2264 2*\u03b5                         : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                            (le_of_lt \u03b5_pos), },\n    have B : 2^(n+1) * \u03d5 x \u2264 \u03d5 (u (n + 1)),\n    { refine @geom_le (\u03d5 \u2218 u) _ zero_le_two (n + 1) (\u03bb m hm, _),\n      exact (IH _ $ nat.lt_add_one_iff.1 hm).2.le },\n    exact hu (n+1) \u27e8A, B\u27e9, },\n  cases forall_and_distrib.mp key with key\u2081 key\u2082,\n  clear hu key,\n  -- Hence u is Cauchy\n  have cauchy_u : cauchy_seq u,\n  { refine cauchy_seq_of_le_geometric _ \u03b5 one_half_lt_one (\u03bb n, _),\n    simpa only [one_div, inv_pow] using key\u2081 n },\n  -- So u converges to some y\n  obtain \u27e8y, limy\u27e9 : \u2203 y, tendsto u at_top (\ud835\udcdd y),\n    from complete_space.complete cauchy_u,\n  -- And \u03d5 \u2218 u goes to +\u221e\n  have lim_top : tendsto (\u03d5 \u2218 u) at_top at_top,\n  { let v := \u03bb n, (\u03d5 \u2218 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\u2080 : 0 < v 0,\n    { have : 0 \u2264 \u03d5 (u 0) := nonneg x,\n      calc 0 \u2264 2 * \u03d5 (u 0) : by linarith\n      ... < \u03d5 (u (0 + 1)) : key\u2082 0 },\n    apply tendsto_at_top_of_geom_le hv\u2080 one_lt_two,\n    exact \u03bb n, (key\u2082 (n+1)).le },\n  -- But \u03d5 \u2218 u also needs to go to \u03d5(y)\n  have lim : tendsto (\u03d5 \u2218 u) at_top (\ud835\udcdd (\u03d5 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 : \u2115} : (n + 1 : with_bot \u2115) < \u2191n.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 \u2115 := \u27e8 \u03bb t k, npow_rec k t \u27e9\n\nnamespace mv_polynomial\n  variables\n    {A B : Type*}\n    [comm_ring A] [comm_ring B] [algebra A B] {\u03c3 : Type*}\n\n  open dvector\n\n  noncomputable instance coe_mv_poly_A_to_mv_poly_B :\n  has_coe (mv_polynomial \u03c3 A) (mv_polynomial \u03c3 B) :=\n  \u27e8 mv_polynomial.map (algebra_map A B)\u27e9\n\n  noncomputable instance coe_mv_poly_Z_to_mv_poly_A :\n  has_coe (mv_polynomial \u03c3 \u2124) (mv_polynomial \u03c3 A) :=\n  \u27e8 mv_polynomial.map (int.cast_ring_hom A) \u27e9\n\n  noncomputable instance coe_mv_poly_A_to_mv_poly_poly_A :\n  has_coe (mv_polynomial \u03c3 A) (mv_polynomial \u03c3 (polynomial A)) :=\n  \u27e8 @mv_polynomial.map A (polynomial A) \u03c3 _ _ polynomial.C \u27e9\n\n  @[simp] lemma coe_mv_poly_X {k : \u03c3} :\n    \u2191(mv_polynomial.X k : mv_polynomial \u03c3 \u2124) = (mv_polynomial.X k : mv_polynomial \u03c3 A) :=\n  begin unfold_coes, simp, end\n\n  @[simp] lemma coe_mv_poly_one : \u2191 (1 : mv_polynomial \u03c3 \u2124) = (1 : mv_polynomial \u03c3 A) :=\n  begin unfold_coes, simp, end\n\n  @[simp] lemma coe_mv_poly_neg {t}: \u2191 - (t : mv_polynomial \u03c3 \u2124) = - (\u2191t : mv_polynomial \u03c3 A) :=\n  begin unfold_coes, simp, end\n\n  @[simp] noncomputable def to_polynomial {n} (val : fin n \u2192 A)\n    (p : mv_polynomial (fin n.succ) A) :\n    polynomial A :=\n  mv_polynomial.eval (fin.x_val polynomial.X (polynomial.C \u2218 val)) p\n\n  lemma eval_eq_poly_eval_mv_coeffs_X\n  {n : \u2115} {val : fin n \u2192 A} (x : A) : \u03a0 {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  (\u03bb 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 : \u2115} {p : mv_polynomial (fin n.succ) A} {val : fin n \u2192 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    (\u03bb 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 \u2190 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 : \u03c3 \u2192 A} {p q : mv_polynomial \u03c3 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 {\u03c3 \u03c4 : Type v} (hequiv : equiv \u03c3 \u03c4) :\n  --   mv_polynomial \u03c3 R \u2243\u2090[R] mv_polynomial \u03c4 R :=\n  -- let f : mv_polynomial \u03c3 R \u2192+* mv_polynomial \u03c4 R :=\n  --     ring_hom.of (eval\u2082 C (\u03bb s,X (hequiv.to_fun s))),\n  --     g : mv_polynomial \u03c4 R \u2192+* mv_polynomial \u03c3 R :=\n  --     ring_hom.of (eval\u2082 C (\u03bb s, X (hequiv.inv_fun s)))\n  -- in\n  -- { to_fun    := eval\u2082 C (\u03bb s, X (hequiv.to_fun s)),\n  --   inv_fun   := eval\u2082 C (\u03bb t, X (hequiv.inv_fun t)),\n  --   left_inv  :=\n  --   begin\n  --     show \u2200 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 \u2200 p, f.comp g p = p,\n  --     apply is_id,\n  --     { intro a, simp },\n  --     { intro n, simp }\n  --   end,\n  --   map_mul'  := \u03bb _ _, eval\u2082_mul _ _,\n  --   map_add'  := \u03bb _ _, eval\u2082_add _ _,\n  --   commutes' := \u03bb _, eval\u2082_C _ _ _ }\n  -- end equiv\n\n  lemma is_empty {R : Type u} {\u03c3 : Type v} [comm_ring R] (h : is_empty \u03c3)\n    (f : mv_polynomial \u03c3 R) (as : \u03c3 \u2192 R) :\n    f = mv_polynomial.C (mv_polynomial.eval as f) :=\n  @mv_polynomial.induction_on R \u03c3 _\n  (\u03bb 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    {\u03b1 : Type u} {c : set (set \u03b1)} (hchain : zorn.chain has_subset.subset c) (hc0 : c.nonempty) :\n    \u03a0 {n : \u2115} (F : fin n \u2192 \u03b1), (\u03a0 k, F k \u2208 \u22c3\u2080 c)\n      \u2192 \u2203 (Y : set \u03b1), Y \u2208 c \u2227 (\u03a0 k, F k \u2208 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 \u2192 \u03b1 := \u03bb k, Fsucc (k.succ),\n    have hF : \u03a0 (k : fin n), Fsucc k.succ \u2208 \u22c3\u2080 c := \u03bb k, hFsucc (fin.succ k),\n    cases fin_range_sub_mem_chain_of_sub_union (\u03bbk, Fsucc (k.succ)) hF with Y hY,\n    have h0cup : Fsucc 0 \u2208 \u22c3\u2080 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 (\u03bb l, Fsucc l \u2208 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 (\u03bb l, Fsucc l \u2208 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 (\u03bb l, Fsucc l \u2208 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    {\u03b1 : Type u} {c : set (set \u03b1)} (hchain : zorn.chain has_subset.subset c) (hc0 : c.nonempty) :\n    \u03a0 (F : finset \u03b1), (\u2191F \u2286 \u22c3\u2080 c) \u2192 \u2203 (Y : set \u03b1), Y \u2208 c \u2227 \u2191F \u2286 Y :=\n  @finset.induction \u03b1 (\u03bb (F : finset \u03b1), (\u2191F \u2286 \u22c3\u2080 c) \u2192 \u2203 (Y : set \u03b1), Y \u2208 c \u2227 \u2191F \u2286 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 \u2208 \u22c3\u2080 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 : \u2191F \u2286 \u22c3\u2080 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 {\u03b1 : Type u} {B : set \u03b1} {x y} :\n    \u00acx = y \u2192 (B \u222a {x}) \\ {y} = B \\ {y} \u222a {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 {\u03b1 : Type u} {B : set \u03b1} {y} : y \u2208 B \u2192 B \\ {y} \u222a {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 {\u03b1 : Type u} {B : set \u03b1} {x} : x \u2209 B \u2192 B = (B \u222a {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 \u2286 V) :\n  --   (subfield.closure U : set L) \u2286 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] : \u03a0 {n : \u2115}, (fin n \u2192 A) \u2192 A\n| nat.zero := 0\n| (nat.succ n) := \u03bb as, (big_add (\u03bb k : fin n, as k)) + as n\n\ndef big_mul {A : Type u} [has_mul A] [has_one A] : \u03a0 {n : \u2115}, (fin n \u2192 A) \u2192 A\n| nat.zero := 1\n| (nat.succ n) := \u03bb as, (big_mul (\u03bb 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\u00f6lzl, 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 \u2964 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 \u2964 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\u2082 C D : C \u2964 D` such that `(forget\u2082 C D) \u22d9 (forget D) = forget C`,\nsee `class has_forget\u2082`.  Due to `faithful.div_comp`, it suffices\nto verify that `forget\u2082.obj` and `forget\u2082.map` agree with the equality\nabove; then `forget\u2082` will satisfy the functor laws automatically, see\n`has_forget\u2082.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 \u2964 Type`.\n\nNote that `concrete_category` potentially depends on three independent universe levels,\n* the universe level `w` appearing in `forget : C \u2964 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 \u2964 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 \u2964 Type u :=\nconcrete_category.forget C\n\ninstance concrete_category.types : concrete_category (Type u) :=\n{ forget := \ud835\udfed _ }\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\u27e8(concrete_category.forget C).obj\u27e9\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 \u27f6 Y) (\u03bb f, X \u2192 Y) :=\n\u27e8\u03bb f, (forget _).map f\u27e9\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 \u27f6 Y) (w : \u2200 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 \u27f6 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} : ((\ud835\udfd9 X) : X \u2192 X) = id :=\n(forget _).map_id X\n\nlemma coe_comp {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g : X \u2192 Z) = g \u2218 f :=\n(forget _).map_comp f g\n\n@[simp] lemma id_apply {X : C} (x : X) : ((\ud835\udfd9 X) : X \u2192 X) x = x :=\ncongr_fun ((forget _).map_id X) x\n\n@[simp] lemma comp_apply {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) (x : X) :\n  (f \u226b g) x = g (f x) :=\ncongr_fun ((forget _).map_comp _ _) x\n\nlemma concrete_category.congr_hom {X Y : C} {f g : X \u27f6 Y} (h : f = g) (x : X) : f x = g x :=\ncongr_fun (congr_arg (\u03bb f : X \u27f6 Y, (f : X \u2192 Y)) h) x\n\nlemma concrete_category.congr_arg {X Y : C} (f : X \u27f6 Y) {x x' : X} (h : x = x') : f x = f x' :=\ncongr_arg (f : X \u2192 Y) h\n\n/-- In any concrete category, injective morphisms are monomorphisms. -/\nlemma concrete_category.mono_of_injective {X Y : C} (f : X \u27f6 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 \u27f6 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 \u27f6 Y)\n  [preserves_limits_of_shape walking_cospan (forget C)] : mono f \u2194 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 \u27f6 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 \u27f6 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 \u27f6 Y)\n  [preserves_colimits_of_shape walking_span (forget C)] : epi f \u2194 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 \u27f6 Y) [is_iso f] :\n  function.bijective ((forget C).map f) :=\nby { rw \u2190 is_iso_iff_bijective, apply_instance, }\n\n@[simp] lemma concrete_category.has_coe_to_fun_Type {X Y : Type u} (f : X \u27f6 Y) :\n  coe_fn f = f :=\nrfl\n\nend\n\n/--\n`has_forget\u2082 C D`, where `C` and `D` are both concrete categories, provides a functor\n`forget\u2082 C D : C \u2964 D` and a proof that `forget\u2082 \u22d9 (forget D) = forget C`.\n-/\nclass has_forget\u2082 (C : Type v) (D : Type v') [category C] [concrete_category.{u} C] [category D]\n  [concrete_category.{u} D] :=\n(forget\u2082 : C \u2964 D)\n(forget_comp : forget\u2082 \u22d9 (forget D) = forget C . obviously)\n\n/-- The forgetful functor `C \u2964 D` between concrete categories for which we have an instance\n`has_forget\u2082 C `. -/\n@[reducible] def forget\u2082 (C : Type v) (D : Type v') [category C] [concrete_category C] [category D]\n  [concrete_category D] [has_forget\u2082 C D] : C \u2964 D :=\nhas_forget\u2082.forget\u2082\n\ninstance forget\u2082_faithful (C : Type v) (D : Type v') [category C] [concrete_category C] [category D]\n  [concrete_category D] [has_forget\u2082 C D] : faithful (forget\u2082 C D) :=\nhas_forget\u2082.forget_comp.faithful_of_comp\n\ninstance forget\u2082_preserves_monomorphisms (C : Type v) (D : Type v') [category C]\n  [concrete_category C] [category D] [concrete_category D] [has_forget\u2082 C D]\n  [(forget C).preserves_monomorphisms] : (forget\u2082 C D).preserves_monomorphisms :=\nhave (forget\u2082 C D \u22d9 forget D).preserves_monomorphisms,\n  by { simp only [has_forget\u2082.forget_comp], apply_instance },\nby exactI functor.preserves_monomorphisms_of_preserves_of_reflects _ (forget D)\n\ninstance forget\u2082_preserves_epimorphisms (C : Type v) (D : Type v') [category C]\n  [concrete_category C] [category D] [concrete_category D] [has_forget\u2082 C D]\n  [(forget C).preserves_epimorphisms] : (forget\u2082 C D).preserves_epimorphisms :=\nhave (forget\u2082 C D \u22d9 forget D).preserves_epimorphisms,\n  by { simp only [has_forget\u2082.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 \u2192 D) :\n  concrete_category (induced_category D f) :=\n{ forget := induced_functor f \u22d9 forget D }\n\ninstance induced_category.has_forget\u2082 {C : Type v} {D : Type v'} [category D] [concrete_category D]\n  (f : C \u2192 D) :\n  has_forget\u2082 (induced_category D f) D :=\n{ forget\u2082 := induced_functor f,\n  forget_comp := rfl }\n\ninstance full_subcategory.concrete_category {C : Type v} [category C] [concrete_category C]\n  (Z : C \u2192 Prop) : concrete_category (full_subcategory Z) :=\n{ forget := full_subcategory_inclusion Z \u22d9 forget C }\n\ninstance full_subcategory.has_forget\u2082 {C : Type v} [category C] [concrete_category C]\n  (Z : C \u2192 Prop) : has_forget\u2082 (full_subcategory Z) C :=\n{ forget\u2082 := full_subcategory_inclusion Z,\n  forget_comp := rfl }\n\n/--\nIn order to construct a \u201cpartially forgetting\u201d functor, we do not need to verify functor laws;\nit suffices to ensure that compositions agree with `forget\u2082 C D \u22d9 forget D = forget C`.\n-/\ndef has_forget\u2082.mk' {C : Type v} {D : Type v'} [category C] [concrete_category C] [category D]\n  [concrete_category D] (obj : C \u2192 D) (h_obj : \u2200 X, (forget D).obj (obj X) = (forget C).obj X)\n  (map : \u03a0 {X Y}, (X \u27f6 Y) \u2192 (obj X \u27f6 obj Y))\n  (h_map : \u2200 {X Y} {f : X \u27f6 Y}, (forget D).map (map f) == (forget C).map f) :\nhas_forget\u2082 C D :=\n{ forget\u2082 := 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\u2082 C (Type u) :=\n{ forget\u2082 := 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 {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) {a\u2081 a\u2082 : \u03b1} :\n  f a\u2081 \u2260 f a\u2082 \u2194 a\u2081 \u2260 a\u2082 :=\nnot_congr hf.eq_iff\nend function\n\n\ninductive dvector (\u03b1 : Type u) : \u2115 \u2192 Type u\n| nil {} : dvector 0\n| cons : \u2200{n} (x : \u03b1) (xs : dvector n), dvector (n+1)\n\ninductive dfin : \u2115 \u2192 Type\n| fz {n} : dfin (n+1)\n| fs {n} : dfin n \u2192 dfin (n+1)\n\ninstance has_zero_dfin {n} : has_zero $ dfin (n+1) := \u27e8dfin.fz\u27e9\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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {n : \u2115}\n\n@[simp] protected lemma zero_eq : \u2200(xs : dvector \u03b1 0), xs = []\n| [] := rfl\n\n@[simp] protected def concat : \u2200{n : \u2115} (xs : dvector \u03b1 n) (x : \u03b1), dvector \u03b1 (n+1)\n| _ []      x' := [x']\n| _ (x::xs) x' := x::concat xs x'\n\n@[simp] protected def nth : \u2200{n : \u2115} (xs : dvector \u03b1 n) (m : \u2115) (h : m < n), \u03b1\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 : \u2115} (x : \u03b1) (xs : dvector \u03b1 n) (m : \u2115) (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 : \u2115} (xs : dvector \u03b1 (n+1)) : \u03b1 :=\n  xs.nth n (by {repeat{constructor}})\n\nprotected def nth' {n : \u2115} (xs : dvector \u03b1 n) (m : fin n) : \u03b1 :=\nxs.nth m.1 m.2\n\nprotected def nth'' : \u2200 {n : \u2115} (xs : dvector \u03b1 n) (m : dfin n), \u03b1\n| _ (x::xs) dfin.fz       := x\n| _ (x::xs) (dfin.fs (m)) := nth'' xs m\n\nprotected def mem : \u2200{n : \u2115} (x : \u03b1) (xs : dvector \u03b1 n), Prop\n| _ x []       := false\n| _ x (x'::xs) := x = x' \u2228 mem x xs\ninstance {n : \u2115} : has_mem \u03b1 (dvector \u03b1 n) := \u27e8dvector.mem\u27e9\n\nprotected def pmem : \u2200{n : \u2115} (x : \u03b1) (xs : dvector \u03b1 n), Type\n| _ x []       := empty\n| _ x (x'::xs) := psum (x = x') (pmem x xs)\n\nprotected lemma mem_of_pmem : \u2200{n : \u2115} {x : \u03b1} {xs : dvector \u03b1 n} (hx : xs.pmem x), x \u2208 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 : \u03b1 \u2192 \u03b2) : \u2200{n : \u2115}, dvector \u03b1 n \u2192 dvector \u03b2 n\n| _ []      := []\n| _ (x::xs) := f x :: map xs\n\n@[simp] protected def map2 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u2200{n : \u2115}, dvector \u03b1 n \u2192 dvector \u03b2 n \u2192 dvector \u03b3 n\n| _ []      []      := []\n| _ (x::xs) (y::ys) := f x y :: map2 xs ys\n\n@[simp] protected lemma map_id : \u2200{n : \u2115} (xs : dvector \u03b1 n), xs.map (\u03bbx, x) = xs\n| _ []      := rfl\n| _ (x::xs) := by { dsimp, simp* }\n\n@[simp] protected lemma map_congr_pmem {f g : \u03b1 \u2192 \u03b2} :\n  \u2200{n : \u2115} {xs : dvector \u03b1 n} (h : \u2200x, xs.pmem x \u2192 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 : \u03b1 \u2192 \u03b2} {n : \u2115} {xs : dvector \u03b1 n}\n  (h : \u2200x, x \u2208 xs \u2192 f x = g x) : xs.map f = xs.map g :=\ndvector.map_congr_pmem $ \u03bbx hx, h x $ dvector.mem_of_pmem hx\n\n@[simp] protected lemma map_congr {f g : \u03b1 \u2192 \u03b2} (h : \u2200x, f x = g x) :\n  \u2200{n : \u2115} (xs : dvector \u03b1 n), xs.map f = xs.map g\n| _ []      := rfl\n| _ (x::xs) := by { dsimp, simp* }\n\n@[simp] protected lemma map_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2): \u2200{n : \u2115} (xs : dvector \u03b1 n),\n  (xs.map f).map g = xs.map (\u03bbx, g (f x))\n  | _ []      := rfl\n  | _ (x::xs) := by { dsimp, simp* }\n\nprotected lemma map_inj {f : \u03b1 \u2192 \u03b2} (hf : \u2200{{x x'}}, f x = f x' \u2192 x = x') {n : \u2115}\n  {xs xs' : dvector \u03b1 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 : \u03b1 \u2192 \u03b2) : \u2200{n : \u2115} (xs : dvector \u03b1 n) (x : \u03b1),\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 : \u03b1 \u2192 \u03b2) : \u2200{n : \u2115} (xs : dvector \u03b1 n) (m : \u2115) (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 : \u2200{n : \u2115} (xs : dvector \u03b1 n) (x : \u03b1) (m : \u2115) (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 : \u2200{n : \u2115} (xs : dvector \u03b1 n) (x : \u03b1) (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' : \u2200{n : \u2115} (xs : dvector \u03b1 n) (x : \u03b1) (h : n < n+1),\n  (xs.concat x).last = x\n:= by apply dvector.concat_nth_last\n\n@[simp] protected def append : \u2200{n m : \u2115} (xs : dvector \u03b1 n) (xs' : dvector \u03b1 m), dvector \u03b1 (m+n)\n| _ _ []       xs := xs\n| _ _ (x'::xs) xs' := x'::append xs xs'\n\n@[simp]protected def insert : \u2200{n : \u2115} (x : \u03b1) (k : \u2115) (xs : dvector \u03b1 n), dvector \u03b1 (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 : \u2200{n : \u2115} (x : \u03b1) (xs : dvector \u03b1 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 : \u2200{n : \u2115} (x : \u03b1) (k : \u2115) (xs : dvector \u03b1 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 : \u03b1} {v : dvector \u03b1 n} : (x::(v.insert y k)) = (x::v).insert y (k+1) :=\nby {induction v, refl, simp*}\n\n/- Given a proof that n \u2264 m, return the nth initial segment of -/\n@[simp]protected def trunc : \u2200 (n) {m : \u2115} (h : n \u2264 m) (xs : dvector \u03b1 m), dvector \u03b1 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 : \u2115} {h : n \u2264 n} {v : dvector \u03b1 n} : dvector.trunc n h v = v :=\n  by {induction v, refl, solve_by_elim}\n\n@[simp]protected lemma trunc_0_n {n : \u2115} {h : 0 \u2264 n} {v : dvector \u03b1 n} : dvector.trunc 0 h v = [] :=\n  by {induction v, refl, simp}\n\n@[simp]protected lemma trunc_nth {n m l: \u2115} {h : n \u2264 m} {h' : l < n} {v : dvector \u03b1 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 : \u2200{n k : \u2115} {h : k < n + 1} {h' : k < n + 1 + 1} (v : dvector \u03b1 (n+1)) (x : \u03b1),\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 \u03b1 n \u2192 dvector \u03b1 m :=\nby { subst p, exact id }\n\n@[simp] protected lemma cast_irrel {n m} {p p' : n = m} {v : dvector \u03b1 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 \u03b1 n} : (v.cast p).cast q = v := by {subst p, refl}\n\nprotected lemma cast_hrfl {n m} {p : n = m} {v : dvector \u03b1 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 \u03b1 n} : (v.cast p).cast q = v.cast (trans p q) :=\nby { subst p, subst q, refl }\n\n@[simp] lemma cast_cons {\u03b1} : \u2200{n m} (h : n + 1 = m + 1) (x : \u03b1) (v : dvector \u03b1 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 {\u03b1} : \u2200{n} (v : dvector \u03b1 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 : \u2200 {n : \u2115} (m : \u2115) (xs : dvector \u03b1 (n+1)) , dvector \u03b1 (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 : \u2200{n : \u2115} (x : \u03b1) (k : \u2115) (xs : dvector \u03b1 n), dvector \u03b1 (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 {\u03b1} : \u2200{n k l : \u2115} (x : \u03b1) (xs : dvector \u03b1 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' {\u03b1} : \u2200{n k l : \u2115} (x : \u03b1) (xs : dvector \u03b1 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 {\u03b1} : \u2200{n k l : \u2115} (x : \u03b1) (xs : dvector \u03b1 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\u03bb n k l x xs h' h2, dvector.insert_nth_gt' x xs _ h' h2\n\nprotected lemma insert_nth_gt {\u03b1} : \u2200{n k l : \u2115} (x : \u03b1) (xs : dvector \u03b1 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\u03bb 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 \u03b1 n} : (x::xs).replace z 0 = z::xs := rfl\n\n@[simp]lemma replace_neck {n x y z} {xs : dvector \u03b1 n} : (x::y::xs).replace z 1 = x::z::xs := rfl\n\n@[simp] def foldr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) : \u2200{n}, dvector \u03b1 n \u2192 \u03b2\n| _ []       := b\n| _ (a :: l) := f a (foldr l)\n\n@[simp] def zip : \u2200{n}, dvector \u03b1 n \u2192 dvector \u03b2 n \u2192 dvector (\u03b1 \u00d7 \u03b2) n\n| _ [] []               := []\n| _ (x :: xs) (y :: ys) := \u27e8x, y\u27e9 :: zip xs ys\n\nopen lattice\n/-- The finitary infimum -/\ndef fInf [semilattice_inf_top \u03b1] (xs : dvector \u03b1 n) : \u03b1 :=\nxs.foldr (\u03bb(x b : \u03b1), x \u2293 b) \u22a4\n\n@[simp] lemma fInf_nil [semilattice_inf_top \u03b1] : fInf [] = (\u22a4 : \u03b1) := by refl\n@[simp] lemma fInf_cons [semilattice_inf_top \u03b1] (x : \u03b1) (xs : dvector \u03b1 n) :\n  fInf (x::xs) = x \u2293 fInf xs := by refl\n\n/-- The finitary supremum -/\ndef fSup [semilattice_sup_bot \u03b1] (xs : dvector \u03b1 n) : \u03b1 :=\nxs.foldr (\u03bb(x b : \u03b1), x \u2294 b) \u22a5\n\n@[simp] lemma fSup_nil [semilattice_sup_bot \u03b1] : fSup [] = (\u22a5 : \u03b1) := by refl\n@[simp] lemma fSup_cons [semilattice_sup_bot \u03b1] (x : \u03b1) (xs : dvector \u03b1 n) :\n  fSup (x::xs) = x \u2294 fSup xs := by refl\n\n/- how to make this protected? -/\ninductive rel [setoid \u03b1] : \u2200{n}, dvector \u03b1 n \u2192 dvector \u03b1 n \u2192 Prop\n| rnil : rel [] []\n| rcons {n} {x x' : \u03b1} {xs xs' : dvector \u03b1 n} (hx : x \u2248 x') (hxs : rel xs xs') :\n    rel (x::xs) (x'::xs')\nopen dvector.rel\n\nprotected lemma rel_refl [setoid \u03b1] : \u2200{n} (xs : dvector \u03b1 n), xs.rel xs\n| _ []      := rnil\n| _ (x::xs) := rcons (setoid.refl _) (rel_refl xs)\n\nprotected lemma rel_symm [setoid \u03b1] {n} {{xs xs' : dvector \u03b1 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 \u03b1] {n} {{xs\u2081 xs\u2082 xs\u2083 : dvector \u03b1 n}}\n  (h\u2081 : xs\u2081.rel xs\u2082) (h\u2082 : xs\u2082.rel xs\u2083) : xs\u2081.rel xs\u2083 :=\nbegin\n  induction h\u2081 generalizing h\u2082, exact h\u2082,\n  cases h\u2082, constructor, exact setoid.trans h\u2081_hx h\u2082_hx, exact h\u2081_ih h\u2082_hxs\nend\n\n-- protected def rel [setoid \u03b1] : \u2200{n}, dvector \u03b1 n \u2192 dvector \u03b1 n \u2192 Prop\n-- | _ []      []        := true\n-- | _ (x::xs) (x'::xs') := x \u2248 x' \u2227 rel xs xs'\n\n-- protected def rel_refl [setoid \u03b1] : \u2200{n} (xs : dvector \u03b1 n), xs.rel xs\n-- | _ []      := trivial\n-- | _ (x::xs) := \u27e8by refl, rel_refl xs\u27e9\n\n-- protected def rel_symm [setoid \u03b1] : \u2200{n} {{xs xs' : dvector \u03b1 n}}, xs.rel xs' \u2192 xs'.rel xs\n-- | _ []      []        h := trivial\n-- | _ (x::xs) (x'::xs') h := \u27e8setoid.symm h.1, rel_symm h.2\u27e9\n\n-- protected def rel_trans [setoid \u03b1] : \u2200{n} {{xs\u2081 xs\u2082 xs\u2083 : dvector \u03b1 n}},\n--   xs\u2081.rel xs\u2082 \u2192 xs\u2082.rel xs\u2083 \u2192 xs\u2081.rel xs\u2083\n-- | _ []        []        []        h\u2081 h\u2082 := trivial\n-- | _ (x\u2081::xs\u2081) (x\u2082::xs\u2082) (x\u2083::xs\u2083) h\u2081 h\u2082 := \u27e8setoid.trans h\u2081.1 h\u2082.1, rel_trans h\u2081.2 h\u2082.2\u27e9\n\ninstance setoid [setoid \u03b1] : setoid (dvector \u03b1 n) :=\n\u27e8dvector.rel, dvector.rel_refl, dvector.rel_symm, dvector.rel_trans\u27e9\n\ndef quotient_lift {\u03b1 : Type u} {\u03b2 : Sort v} {R : setoid \u03b1} : \u2200{n} (f : dvector \u03b1 n \u2192 \u03b2)\n  (h : \u2200{{xs xs'}}, xs \u2248 xs' \u2192 f xs = f xs') (xs : dvector (quotient R) n), \u03b2\n| _     f h []      := f ([])\n| (n+1) f h (x::xs) :=\n  begin\n    refine quotient.lift\n      (\u03bbx, quotient_lift (\u03bb xs, f $ x::xs) (\u03bbxs 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 {\u03b1 : Type u} {\u03b2 : Sort v} {R : setoid \u03b1} {n} (f : dvector \u03b1 n \u2192 \u03b2)\n  (h : \u2200{{xs xs'}}, xs \u2248 xs' \u2192 f xs = f xs') (xs : dvector \u03b1 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 {\u03b1} {s t : set \u03b1} : disjoint s t \u2194 s \u2229 t = \u2205 := disjoint_iff\n\n@[simp] lemma not_nonempty_iff {\u03b1} {s : set \u03b1} : \u00acnonempty s \u2194 s = \u2205 :=\nby rw [coe_nonempty_iff_ne_empty, classical.not_not]\n\nlemma neq_neg_of_nonempty {\u03b1 : Type*} {P : set \u03b1} (H_nonempty : nonempty \u03b1) : P \u2260 - P :=\nbegin\n  intro H_eq, let a : \u03b1 := 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 {\u03b1 \u03b2} {s : set \u03b1} {t : set \u03b2} {u : \u03b1 \u2192 set \u03b2} :\n  t \u2286 (\u22c2 x \u2208 s, u x) \u2194 \u2200 x \u2208 s, t \u2286 u x :=\n\u27e8\u03bb h x hx y hy, by { have := h hy, rw mem_bInter_iff at this, exact this x hx }, subset_bInter\u27e9\n\n@[simp] lemma subset_sInter_iff {\u03b1} {s : set \u03b1} {C : set (set \u03b1)} :\n  s \u2286 \u22c2\u2080 C \u2194 \u2200 t \u2208 C, s \u2286 t :=\nby simp [sInter_eq_bInter]\n\nlemma ne_empty_of_subset {\u03b1} {s t : set \u03b1} (h : s \u2286 t) (hs : s \u2260 \u2205) : t \u2260 \u2205 :=\nby { rw [set.ne_empty_iff_exists_mem] at hs \u22a2, cases hs with x hx, exact \u27e8x, h hx\u27e9 }\n\nend set\n\nsection topological_space\nopen lattice filter topological_space set\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Type w} {\u03c0 : \u03b9 \u2192 Type w'} [\u2200x, topological_space (\u03c0 x)]\n\nvariables [t : topological_space \u03b1] [topological_space \u03b2]\n\nlemma subbasis_subset_basis {s : set (set \u03b1)} :\n  s \\ {\u2205} \u2286 ((\u03bbf, \u22c2\u2080 f) '' {f:set (set \u03b1) | finite f \u2227 f \u2286 s \u2227 \u22c2\u2080 f \u2260 \u2205}) :=\nbegin\n  intros o ho, refine \u27e8{o}, \u27e8finite_singleton o, _, _\u27e9, _\u27e9,\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 : \u03b1} {o : opens \u03b1} : x \u2208 o \u2194 x \u2208 o.1 := by refl\n\nlemma is_open_map_of_is_topological_basis {s : set (set \u03b1)}\n  (hs : is_topological_basis s) (f : \u03b1 \u2192 \u03b2) (hf : \u2200x \u2208 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 \u27e8\u03b3, g, rfl, hg\u27e9,\n  rw [image_Union], apply is_open_Union, intro i, apply hf, apply hg\nend\n\nlemma interior_bInter_subset {\u03b2} {s : set \u03b2} (f : \u03b2 \u2192 set \u03b1) :\n  interior (\u22c2i \u2208 s, f i) \u2286 \u22c2i \u2208 s, interior (f i) :=\nbegin\n  intros x hx, rw [mem_interior] at hx, rcases hx with \u27e8t, h1t, h2t, h3t\u27e9,\n  rw [subset_bInter_iff] at h1t,\n  rw [mem_bInter_iff], intros y hy, rw [mem_interior],\n  refine \u27e8t, h1t y hy, h2t, h3t\u27e9\nend\n\nlemma nonempty_basis_subset {b : set (set \u03b1)}\n  (hb : is_topological_basis b) {u : set \u03b1} (hu : u \u2260 \u2205) (ou : _root_.is_open u) :\n  \u2203v \u2208 b, v \u2260 \u2205 \u2227 v \u2286 u :=\nbegin\n  simp only [set.ne_empty_iff_exists_mem] at hu \u22a2, cases hu with x hx,\n  rcases mem_basis_subset_of_mem_open hb hx ou with \u27e8o, h1o, h2x, h2o\u27e9,\n  exact \u27e8o, h1o, \u27e8x, h2x\u27e9, h2o\u27e9\nend\n\nend topological_space\n\nnamespace ordinal\nvariable {\u03c3 : Type*}\n\ntheorem well_ordering_thm : \u2203 (r : \u03c3 \u2192 \u03c3 \u2192 Prop), is_well_order \u03c3 r :=\n\u27e8_, (order_embedding.preimage embedding_to_cardinal (<)).is_well_order\u27e9\n\ntheorem enum_typein' {\u03b1 : Type u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [is_well_order \u03b1 r] (a : \u03b1) :\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 {\u03b1 : Type u} {S T : set \u03b1} : mk (S \u222a T : set \u03b1) \u2264 mk S + mk T :=\nby { rw [\u2190 mk_union_add_mk_inter], apply le_add_right }\n\n\nlemma exists_mem_compl_of_mk_lt_mk {\u03b1} (P : set \u03b1) (H_lt : cardinal.mk P  < cardinal.mk \u03b1) : \u2203 x : \u03b1, x \u2208 (- P) :=\nbegin\n  haveI : decidable (\u2203 (x : \u03b1), x \u2208 - P) := classical.prop_decidable _,\n  by_contra, push_neg at a,\n  replace a := (by finish : \u2200 x, x \u2208 P),\n  suffices : mk \u03b1 \u2264 mk P ,\n    by {exact absurd H_lt (not_lt.mpr \u2039_\u203a)},\n  refine mk_le_of_injective _, from \u03bb _, \u27e8\u2039_\u203a, a \u2039_\u203a\u27e9, tidy\nend\n\n@[simp]lemma mk_union_countable_of_countable {\u03b1} {P Q : set \u03b1} (HP : #P \u2264 omega) (HQ : #Q \u2264 omega) :\n  #((P \u222a Q : set \u03b1)) \u2264 omega :=\nbegin\n  have this\u2081 := @mk_union_add_mk_inter _ (P) (Q),\n  transitivity (#\u21a5(P \u222a Q)) + #\u21a5(P \u2229 Q),\n    { apply cardinal.le_add_right },\n    { rw[this\u2081], rw[<-(add_eq_self (by refl : cardinal.omega \u2264 cardinal.omega))],\n      refine cardinal.add_le_add _ _; from \u2039_\u203a }\nend\n\nlemma nonzero_of_regular {\u03ba : cardinal} (H_reg : cardinal.is_regular \u03ba) : 0 < \u03ba.ord :=\nby {rw cardinal.lt_ord, from lt_of_lt_of_le omega_pos H_reg.left}\n\nlemma injection_of_mk_le {\u03b1 \u03b2 : Type u} (H_le : #\u03b1 \u2264 #\u03b2) : \u2203 f : \u03b1 \u2192 \u03b2, 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 : \u2203 g\u2081 : \u03b1 \u2192 quotient.out (#\u03b1), function.injective g\u2081 \u2227 \u2203 g\u2082 : quotient.out (#\u03b2) \u2192 \u03b2, function.injective g\u2082,\n    by {rcases this with \u27e8g\u2081,Hg\u2081,g\u2082,Hg\u2082\u27e9, use g\u2082 \u2218 f \u2218 g\u2081, simp[function.injective_comp, *] },\n  have this\u2081 : #(quotient.out (#\u03b1)) = #\u03b1 := mk_out _, have this\u2082 : #(quotient.out _) = #\u03b2 := mk_out _,\n  erw quotient.eq' at this\u2081 this\u2082, replace this\u2081 := classical.choice this\u2081, replace this\u2082 := classical.choice this\u2082,\n  cases this\u2081, cases this\u2082,\n  refine \u27e8this\u2081_inv_fun, _, this\u2082_to_fun, _\u27e9; apply function.injective_of_left_inverse; from \u2039_\u203a\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 : \u2115} (H : 1 \u2264 m) : pred m < n \u2194 m < succ n :=\nnat.sub_lt_right_iff_lt_add H\n\n@[simp]lemma le_of_le_and_ne_succ {x y : \u2115} (H : x \u2264 y + 1) (H' : x \u2260 y + 1) : x \u2264 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 \u2190 mk_fresh_name,\np \u2190 i_to_expr q,\ne \u2190 note n none p,\ntactic.exact e\n\nend interactive\nend tactic\n\n/- logic -/\nnamespace classical\n\nnoncomputable def psigma_of_exists {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} (h : \u2203x, p x) : \u03a3' x, p x :=\nbegin\n  haveI : nonempty \u03b1 := nonempty_of_exists h,\n  exact \u27e8epsilon p, epsilon_spec h\u27e9\nend\n\n/- this is a special case of `some_spec2` -/\nlemma some_eq {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} {h : \u2203 (a : \u03b1), p a} (x : \u03b1)\n  (hx : \u2200y, p y \u2192 y = x) : classical.some h = x :=\nclassical.some_spec2 _ hx\n\nlemma or_not_iff_true (p : Prop) : (p \u2228 \u00ac p) \u2194 true :=\n\u27e8\u03bb_, trivial, \u03bb_, or_not\u27e9\n\nlemma nonempty_of_not_empty {\u03b1 : Type u} (s : set \u03b1) (h : \u00ac s = \u2205) : nonempty s :=\nset.coe_nonempty_iff_ne_empty.mpr h\n\nlemma nonempty_of_not_empty_finset {\u03b1 : Type u} (s : finset \u03b1) (h : \u00ac s = \u2205) : 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 {\u03b1 : Type u} (l : list \u03b1) : set \u03b1 := { x | x \u2208 l }\n\nlemma to_set_map {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (l : list \u03b1) :\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 {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} {l : list \u03b2}\n  {t : set \u03b1} (h : l.to_set \u2286 f '' t) : \u2203(l' : list \u03b1), l'.to_set \u2286 t \u2227 map f l' = l :=\nbegin\n  induction l,\n  { exact \u27e8[], set.empty_subset t, rfl\u27e9 },\n  { rcases h (mem_cons_self _ _) with \u27e8x, hx, rfl\u27e9,\n    rcases l_ih (\u03bbx hx, h $ mem_cons_of_mem _ hx) with \u27e8xs, hxs, hxs'\u27e9,\n    exact \u27e8x::xs, set.union_subset (\u03bby hy, by induction hy; exact hx) hxs, by simp*\u27e9 }\nend\n\nend list\n\nnamespace nat\n/- nat.sub_add_comm -/\nlemma add_sub_swap {n k : \u2115} (h : k \u2264 n) (m : \u2115) : 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\u2081 : a = b) (h\u2082 : c = d) : (a \u2192 c) = (b \u2192 d) :=\nby subst h\u2081; subst h\u2082; refl\n\nlemma forall_eq_congr {\u03b1 : Sort u} {p q : \u03b1 \u2192 Prop} (h : \u2200 a, p a = q a) :\n  (\u2200 a, p a) = \u2200 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n\n/-set.ne_empty_iff_exists_mem.mpr-/\nlemma ne_empty_of_exists_mem {s : set \u03b1} : \u2200(h : \u2203x, x \u2208 s), s \u2260 \u2205\n| \u27e8x, hx\u27e9 := ne_empty_of_mem hx\n\nlemma inter_sUnion_ne_empty_of_exists_mem {b : set \u03b1} {\ud835\udcd5 : set $ set \u03b1} (H : \u2203 f \u2208 \ud835\udcd5, b \u2229 f \u2260 \u2205) : b \u2229 \u22c3\u2080 \ud835\udcd5 \u2260 \u2205 :=\nbegin\n  apply ne_empty_of_exists_mem, safe, change _ \u2260 _ at h_1, rw ne_empty_iff_exists_mem at h_1,\n  rcases h_1 with \u27e8x, H\u2081, H\u2082\u27e9, specialize a x, finish\nend\n\n@[simp]lemma mem_image_univ {f : \u03b1 \u2192 \u03b2} {x} : f x \u2208 f '' set.univ := \u27e8x, \u27e8trivial, rfl\u27e9\u27e9\n\n-- todo: only use image_preimage_eq_of_subset\nlemma image_preimage_eq_of_subset_image {f : \u03b1 \u2192 \u03b2} {s : set \u03b2}\n  {t : set \u03b1} (h : s \u2286 f '' t) : f '' (f \u207b\u00b9' s) = s :=\nsubset.antisymm\n  (image_preimage_subset f s)\n  (\u03bb x hx, begin rcases h hx with \u27e8a, ha, rfl\u27e9, apply mem_image_of_mem f, exact hx end)\n\nlemma subset_union_left_of_subset {s t : set \u03b1} (h : s \u2286 t) (u : set \u03b1) : s \u2286 t \u222a u :=\nsubset.trans h (subset_union_left t u)\n\nlemma subset_union_right_of_subset {s u : set \u03b1} (h : s \u2286 u) (t : set \u03b1) : s \u2286 t \u222a u :=\nsubset.trans h (subset_union_right t u)\n\n/- subset_sUnion_of_mem -/\nlemma subset_sUnion {s : set \u03b1} {t : set (set \u03b1)} (h : s \u2208 t) : s \u2286 \u22c3\u2080 t :=\n\u03bbx hx, \u27e8s, \u27e8h, hx\u27e9\u27e9\n\nlemma subset_union2_left {s t u : set \u03b1} : s \u2286 s \u222a t \u222a u :=\nsubset.trans (subset_union_left _ _) (subset_union_left _ _)\n\nlemma subset_union2_middle {s t u : set \u03b1} : t \u2286 s \u222a t \u222a u :=\nsubset.trans (subset_union_right _ _) (subset_union_left _ _)\n\n\ndef change {\u03c0 : \u03b1 \u2192 Type*} [decidable_eq \u03b1] (f : \u03a0a, \u03c0 a) {x : \u03b1} (z : \u03c0 x) (y : \u03b1) : \u03c0 y :=\nif h : x = y then (@eq.rec _ _ \u03c0 z _ h) else f y\n\nlemma dif_mem_pi {\u03c0 : \u03b1 \u2192 Type*} (i : set \u03b1) (s : \u03a0a, set (\u03c0 a)) [decidable_eq \u03b1]\n  (f : \u03a0a, \u03c0 a) (hf : f \u2208 pi i s) {x : \u03b1} (z : \u03c0 x) (h : x \u2208 i \u2192 z \u2208 s x) :\n  change f z \u2208 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 {\u03c0 : \u03b1 \u2192 Type*} (i : set \u03b1) (s : \u03a0a, set (\u03c0 a)) [decidable_eq \u03b1]\n  (hp : nonempty (pi i s)) (x : \u03b1) (hx : x \u2208 i) : (\u03bb(f : \u03a0a, \u03c0 a), f x) '' pi i s = s x :=\nbegin\n  apply subset.antisymm,\n  { rintro _ \u27e8f, hf, rfl\u27e9, exact hf x hx },\n  intros z hz, have := hp, rcases this with \u27e8f, hf\u27e9,\n  refine \u27e8_, dif_mem_pi i s f hf z (\u03bb _, hz), _\u27e9,\n  simp only [change, dif_pos rfl]\nend\n\nlemma image_pi_neg {\u03c0 : \u03b1 \u2192 Type*} (i : set \u03b1) (s : \u03a0a, set (\u03c0 a)) [decidable_eq \u03b1]\n  (hp : nonempty (pi i s)) (x : \u03b1) (hx : x \u2209 i) : (\u03bb(f : \u03a0a, \u03c0 a), f x) '' pi i s = univ :=\nbegin\n  rw [eq_univ_iff_forall], intro z, have := hp, rcases this with \u27e8f, hf\u27e9,\n  refine \u27e8_, dif_mem_pi i s f hf z _, _\u27e9,\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 {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w}\n\nprotected lemma iff (mp : \u03b1 \u2192 \u03b2) (mpr : \u03b2 \u2192 \u03b1) : nonempty \u03b1 \u2194 nonempty \u03b2 :=\n\u27e8nonempty.map mp, nonempty.map mpr\u27e9\n\nend nonempty\n\n/-- The type \u03b1 \u2192 (\u03b1 \u2192 ... (\u03b1 \u2192 \u03b2)...) with n \u03b1's. We require that \u03b1 and \u03b2 live in the same universe, otherwise we have to use ulift. -/\ndef arity' (\u03b1 \u03b2 : Type u) : \u2115 \u2192 Type u\n| 0     := \u03b2\n| (n+1) := \u03b1 \u2192 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 {\u03b1 \u03b2 : Type u} : \u2200{n : \u2115}, \u03b2 \u2192 arity' \u03b1 \u03b2 n\n| 0     b := b\n| (n+1) b := \u03bb_, arity'_constant b\n\n@[simp] def of_dvector_map {\u03b1 \u03b2 : Type u} : \u2200{l} (f : dvector \u03b1 l \u2192 \u03b2), arity' \u03b1 \u03b2 l\n| 0     f := f ([])\n| (l+1) f := \u03bbx, of_dvector_map $ \u03bbxs, f $ x::xs\n\n@[simp] def arity'_app {\u03b1 \u03b2 : Type u} : \u2200{l}, arity' \u03b1 \u03b2 l \u2192 dvector \u03b1 l \u2192 \u03b2\n| _ b []      := b\n| _ f (x::xs) := arity'_app (f x) xs\n\n@[simp] lemma arity'_app_zero {\u03b1 \u03b2 : Type u} (f : arity' \u03b1 \u03b2 0) (xs : dvector \u03b1 0) :\n  arity'_app f xs = f :=\nby cases xs; refl\n\ndef arity'_postcompose {\u03b1 \u03b2 \u03b3 : Type u} (g : \u03b2 \u2192 \u03b3) : \u2200{n} (f : arity' \u03b1 \u03b2 n), arity' \u03b1 \u03b3 n\n| 0     b := g b\n| (n+1) f := \u03bbx, arity'_postcompose (f x)\n\ndef arity'_postcompose2 {\u03b1 \u03b2 \u03b3 \u03b4 : Type u} (h : \u03b2 \u2192 \u03b3 \u2192 \u03b4) :\n  \u2200{n} (f : arity' \u03b1 \u03b2 n) (g : arity' \u03b1 \u03b3 n), arity' \u03b1 \u03b4 n\n| 0     b c := h b c\n| (n+1) f g := \u03bbx, arity'_postcompose2 (f x) (g x)\n\ndef arity'_precompose {\u03b1 \u03b2 \u03b3 : Type u} : \u2200{n} (g : arity' \u03b2 \u03b3 n) (f : \u03b1 \u2192 \u03b2), arity' \u03b1 \u03b3 n\n| 0     c f := c\n| (n+1) g f := \u03bbx, arity'_precompose (g (f x)) f\n\ninductive arity'_respect_setoid {\u03b1 \u03b2 : Type u} [R : setoid \u03b1] : \u2200{n}, arity' \u03b1 \u03b2 n \u2192 Type u\n| r_zero (b : \u03b2) : @arity'_respect_setoid 0 b\n| r_succ (n : \u2115) (f : arity' \u03b1 \u03b2 (n+1)) (h\u2081 : \u2200{{a a'}}, a \u2248 a' \u2192 f a = f a')\n  (h\u2082 : \u2200a, arity'_respect_setoid (f a)) : arity'_respect_setoid f\nopen arity'_respect_setoid\n\ninstance subsingleton_arity'_respect_setoid {\u03b1 \u03b2 : Type u} [R : setoid \u03b1] {n} (f : arity' \u03b1 \u03b2 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 {\u03b1 \u03b2 : Type u} {R : setoid \u03b1} :\n--   \u2200{n}, (\u03a3(f : arity' \u03b1 \u03b2 n), arity'_respect_setoid f) \u2192 arity' (quotient R) \u03b2 n\n-- | _ \u27e8_, r_zero b\u27e9         := b\n-- | _ \u27e8_, r_succ n f h\u2081 h\u2082\u27e9 :=\n--   begin\n--     apply quotient.lift (\u03bbx, arity'_quotient_lift \u27e8f x, h\u2082 x\u27e9),\n--     intros x x' r, dsimp,\n--     apply congr_arg, exact sigma.eq (h\u2081 r) (subsingleton.elim _ _)\n--   end\n\n-- def arity'_quotient_beta {\u03b1 \u03b2 : Type u} {R : setoid \u03b1} {n} (f : arity' \u03b1 \u03b2 n)\n--   (hf : arity'_respect_setoid f) (xs : dvector \u03b1 n) :\n--   arity'_app (arity'_quotient_lift \u27e8f, hf\u27e9) (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 {\u03b1 : Type u} (P : \u03b1 \u2192 Prop) : Prop := \u2200x, P x\n\n@[simp] def arity'_map2 {\u03b1 \u03b2 : Type u} (q : (\u03b1 \u2192 \u03b2) \u2192 \u03b2) (f : \u03b2 \u2192 \u03b2 \u2192 \u03b2) :\n  \u2200{n}, arity' \u03b1 \u03b2 n \u2192 arity' \u03b1 \u03b2 n \u2192 \u03b2\n| 0     x y := f x y\n| (n+1) x y := q (\u03bbz, arity'_map2 (x z) (y z))\n\n@[simp] lemma arity'_map2_refl {\u03b1 : Type} {f : Prop \u2192 Prop \u2192 Prop} (r : \u2200A, f A A) :\n  \u2200{n} (x : arity' \u03b1 Prop n), arity'_map2 for_all f x x\n| 0     x := r x\n| (n+1) x := \u03bby, arity'_map2_refl (x y)\n\ndef arity'_imp {\u03b1 : Type} {n : \u2115} (f\u2081 f\u2082 : arity' \u03b1 Prop n) : Prop :=\narity'_map2 for_all (\u03bbP Q, P \u2192 Q) f\u2081 f\u2082\n\ndef arity'_iff {\u03b1 : Type} {n : \u2115} (f\u2081 f\u2082 : arity' \u03b1 Prop n) : Prop :=\narity'_map2 for_all iff f\u2081 f\u2082\n\nlemma arity'_iff_refl {\u03b1 : Type} {n : \u2115} (f : arity' \u03b1 Prop n) : arity'_iff f f :=\narity'_map2_refl iff.refl f\n\nlemma arity'_iff_rfl {\u03b1 : Type} {n : \u2115} {f : arity' \u03b1 Prop n} : arity'_iff f f :=\narity'_iff_refl f\n\nend arity'\nend arity'\n\n@[simp]lemma lt_irrefl' {\u03b1} [preorder \u03b1] {\u0393 : \u03b1} (H_lt : \u0393 < \u0393) : false := lt_irrefl _ \u2039_\u203a\n\nnamespace lattice\n\n\n\ninstance complete_degenerate_boolean_algebra : complete_boolean_algebra unit :=\n{ sup := \u03bb _ _, (),\n  le := \u03bb _ _, true,\n  lt := \u03bb _ _, 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 := \u03bb _ _, (),\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 := \u03bb _, (),\n  sub := \u03bb _ _, (),\n  inf_neg_eq_bot :=  by tidy,\n  sup_neg_eq_top :=  by tidy,\n  sub_eq :=  by tidy,\n  Sup := \u03bb _, (),\n  Inf := \u03bb _, (),\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 (\u03b1 : Type*) extends complete_boolean_algebra \u03b1 :=\n  {bot_lt_top : (\u22a5 : \u03b1) < (\u22a4 : \u03b1)}\n\n@[simp]lemma nontrivial.bot_lt_top {\u03b1 : Type*} [H : nontrivial_complete_boolean_algebra \u03b1] : (\u22a5 : \u03b1) < \u22a4 :=\nH.bot_lt_top\n\n@[simp]lemma nontrivial.bot_neq_top {\u03b1 : Type*} [H : nontrivial_complete_boolean_algebra \u03b1] : \u00ac (\u22a5 = (\u22a4 : \u03b1)) :=\nby {change _ \u2260 _, rw[lt_top_iff_ne_top.symm], simp}\n\n@[simp]lemma nontrivial.top_neq_bot {\u03b1 : Type*} [H : nontrivial_complete_boolean_algebra \u03b1] : \u00ac (\u22a4 = (\u22a5 : \u03b1)) :=\n\u03bb _, nontrivial.bot_neq_top $ eq.symm \u2039_\u203a\n\ndef antichain {\u03b2 : Type*} [bounded_lattice \u03b2] (s : set \u03b2) :=\n  \u2200 x \u2208 s, \u2200 y \u2208 s, x \u2260 y \u2192 x \u2293 y = (\u22a5 : \u03b2)\n\ntheorem inf_supr_eq {\u03b1 \u03b9 : Type*} [complete_distrib_lattice \u03b1] {a : \u03b1} {s : \u03b9 \u2192 \u03b1} :\n  a \u2293 (\u2a06(i:\u03b9), s i) = \u2a06(i:\u03b9), a \u2293 s i :=\n  eq.trans inf_Sup_eq $\n    begin\n      rw[<-inf_Sup_eq], suffices : (\u2a06(i:\u03b9), a \u2293 s i) = \u2a06(b\u2208(set.range s)), a \u2293 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 {\u03b1 \u03b9 : Type*} [complete_distrib_lattice \u03b1] {a : \u03b1} {s : \u03b9 \u2192 \u03b1} :\n  (\u2a06(i:\u03b9), s i) \u2293 a = \u2a06(i:\u03b9), (s i \u2293 a) :=\nby simp[inf_comm,inf_supr_eq]\n\ntheorem sup_infi_eq {\u03b1 \u03b9 : Type*} [complete_distrib_lattice \u03b1] {a : \u03b1} {s : \u03b9 \u2192 \u03b1} :\n  a \u2294 (\u2a05(i:\u03b9), s i) = \u2a05(i:\u03b9), a \u2294 s i :=\n  eq.trans sup_Inf_eq $\n    begin\n      rw[<-sup_Inf_eq], suffices : (\u2a05(i:\u03b9), a \u2294 s i) = \u2a05(b\u2208(set.range s)), a \u2294 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 \u03b9, from \u2039\u03b9\u203a, show \u03b1, exact s i, refl, refl\n    end\n\ntheorem infi_sup_eq {\u03b1 \u03b9 : Type*} [complete_distrib_lattice \u03b1] {a : \u03b1} {s : \u03b9 \u2192 \u03b1} :\n (\u2a05(i:\u03b9), s i) \u2294 a = \u2a05(i:\u03b9), s i \u2294 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 {\u03b1 : Type*} [lattice \u03b1] {a : \u03b1} : a \u2293 a = a :=\n  inf_idem\n\n@[simp]lemma sup_self {\u03b1 : Type*} [lattice \u03b1] {a : \u03b1} : a \u2294 a = a :=\n  sup_idem\n\nlemma bot_lt_iff_not_le_bot {\u03b1} [bounded_lattice \u03b1] {a : \u03b1} : \u22a5 < a \u2194 (\u00ac a \u2264 \u22a5) :=\nby rw[le_bot_iff]; exact bot_lt_iff_ne_bot\n\nlemma false_of_bot_lt_and_le_bot {\u03b1} [bounded_lattice \u03b1] {a : \u03b1} (H_lt : \u22a5 < a) (H_le : a \u2264 \u22a5) : false :=\nabsurd H_le (bot_lt_iff_not_le_bot.mp \u2039_\u203a)\n\nlemma lt_top_iff_not_top_le {\u03b1} [bounded_lattice \u03b1] {a : \u03b1} : a < \u22a4 \u2194 (\u00ac \u22a4 \u2264 a) :=\nby rw[top_le_iff]; exact lt_top_iff_ne_top\n\nlemma bot_lt_resolve_left {\ud835\udd39} [bounded_lattice \ud835\udd39] {a b : \ud835\udd39} (H_lt' : \u22a5 < a \u2293 b) : \u22a5 < 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 {\ud835\udd39} [bounded_lattice \ud835\udd39] {a b : \ud835\udd39} (H_lt : \u22a5 < b)\n  (H_lt' : \u22a5 < a \u2293 b) : \u22a5 < a :=\nby rw[inf_comm] at H_lt'; exact bot_lt_resolve_left \u2039_\u203a\n\nlemma le_bot_iff_not_bot_lt {\ud835\udd39} [bounded_lattice \ud835\udd39] {a : \ud835\udd39} : \u00ac \u22a5 < a \u2194 a \u2264 \u22a5 :=\nby { rw bot_lt_iff_not_le_bot, tauto! }\n\n/--\n  Given an indexed supremum (\u2a06i, s i) and (H : \u0393 \u2264 \u2a06i, s i), there exists some i such that \u22a5 < \u0393 \u2293 s i.\n-/\nlemma nonzero_inf_of_nonzero_le_supr {\u03b1 : Type*} [complete_distrib_lattice \u03b1] {\u03b9 : Type*} {s : \u03b9 \u2192 \u03b1} {\u0393 : \u03b1} (H_nonzero : \u22a5 < \u0393) (H : \u0393 \u2264 \u2a06i, s i) : \u2203 i, \u22a5 < \u0393 \u2293 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 : \u0393 \u2293 (\u2a06(i : \u03b9), s i) = \u0393,\n    by {exact le_antisymm (inf_le_left) (le_inf (by refl) \u2039_\u203a)},\n  suffices this : (\u0393 \u2293 \u2a06 (i : \u03b9), s i) \u2264 \u22a5,\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 {\u03b1 : Type*} [boolean_algebra \u03b1] : \u03b1 \u2192 \u03b1 \u2192 \u03b1 :=\n  \u03bb a\u2081 a\u2082, (- a\u2081) \u2294 a\u2082\n\nlocal infix ` \u27f9 `:65 := lattice.imp\n\n@[reducible, simp]def biimp {\u03b1 : Type*} [boolean_algebra \u03b1] : \u03b1 \u2192 \u03b1 \u2192 \u03b1 :=\n  \u03bb a\u2081 a\u2082, (a\u2081 \u27f9 a\u2082) \u2293 (a\u2082 \u27f9 a\u2081)\n\nlocal infix ` \u21d4 `:50 := lattice.biimp\n\nlemma biimp_mp {\u03b1 : Type*} [boolean_algebra \u03b1] {a\u2081 a\u2082 : \u03b1} : (a\u2081 \u21d4 a\u2082) \u2264 (a\u2081 \u27f9 a\u2082) :=\n  by apply inf_le_left\n\nlemma biimp_mpr {\u03b1 : Type*} [boolean_algebra \u03b1] {a\u2081 a\u2082 : \u03b1} : (a\u2081 \u21d4 a\u2082) \u2264 (a\u2082 \u27f9 a\u2081) :=\n  by apply inf_le_right\n\nlemma biimp_comm {\u03b1 : Type*} [boolean_algebra \u03b1] {a\u2081 a\u2082 : \u03b1} : (a\u2081 \u21d4 a\u2082) = (a\u2082 \u21d4 a\u2081) :=\nby {unfold biimp, rw lattice.inf_comm}\n\nlemma biimp_symm {\u03b1 : Type*} [boolean_algebra \u03b1] {a\u2081 a\u2082 : \u03b1} {\u0393 : \u03b1} : \u0393 \u2264 (a\u2081 \u21d4 a\u2082) \u2194 \u0393 \u2264 (a\u2082 \u21d4 a\u2081) :=\nby rw biimp_comm\n\n@[simp]lemma imp_le_of_right_le {\u03b1 : Type*} [boolean_algebra \u03b1] {a a\u2081 a\u2082 : \u03b1} {h : a\u2081 \u2264 a\u2082} : a \u27f9 a\u2081 \u2264 (a \u27f9 a\u2082) :=\nsup_le (by apply le_sup_left) $ le_sup_right_of_le h\n\n@[simp]lemma imp_le_of_left_le {\u03b1 : Type*} [boolean_algebra \u03b1] {a a\u2081 a\u2082 : \u03b1} {h : a\u2082 \u2264 a\u2081} : a\u2081 \u27f9 a \u2264 (a\u2082 \u27f9 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 {\u03b1 : Type*} [boolean_algebra \u03b1] {a\u2081 a\u2082 b\u2081 b\u2082 : \u03b1}\n{h\u2081 : b\u2081 \u2264 a\u2081} {h\u2082 : a\u2082 \u2264 b\u2082} :\n  a\u2081 \u27f9 a\u2082 \u2264 b\u2081 \u27f9 b\u2082 :=\nsup_le (le_sup_left_of_le (neg_le_neg h\u2081)) (le_sup_right_of_le h\u2082)\n\nlemma neg_le_neg' {\u03b1 : Type*} [boolean_algebra \u03b1] {a b : \u03b1} : b \u2264 -a \u2192 a \u2264 -b :=\nby {intro H, rw[show b = - - b, by simp] at H, rwa[<-neg_le_neg_iff_le]}\n\nlemma inf_imp_eq {\u03b1 : Type*} [boolean_algebra \u03b1] {a b c : \u03b1} :\n  a \u2293 (b \u27f9 c) = (a \u27f9 b) \u27f9 (a \u2293 c) :=\nby unfold imp; simp[inf_sup_left]\n\n@[simp]lemma imp_bot {\u03b1 : Type*} [boolean_algebra \u03b1]  {a : \u03b1} : a \u27f9 \u22a5 = - a := by simp[imp]\n\n@[simp]lemma top_imp {\u03b1 : Type*} [boolean_algebra \u03b1] {a : \u03b1} : \u22a4 \u27f9 a = a := by simp[imp]\n\n@[simp]lemma imp_self {\u03b1 : Type*} [boolean_algebra \u03b1] {a : \u03b1} : a \u27f9 a = \u22a4 := by simp[imp]\n\nlemma imp_neg_sub {\u03b1 : Type*} [boolean_algebra \u03b1] {a\u2081 a\u2082 : \u03b1} :  -(a\u2081 \u27f9 a\u2082) = a\u2081 - a\u2082 :=\n  by rw[sub_eq, imp]; simp*\n\nlemma inf_eq_of_le {\u03b1 : Type*} [distrib_lattice \u03b1] {a b : \u03b1} (h : a \u2264 b) : a \u2293 b = a :=\n  by apply le_antisymm; simp[*,le_inf]\n\nlemma imp_inf_le {\u03b1 : Type*} [boolean_algebra \u03b1] (a b : \u03b1) : (a \u27f9 b) \u2293 a \u2264 b :=\nby { unfold imp, rw [inf_sup_right], simp }\n\nlemma le_of_sub_eq_bot {\u03b1 : Type*} [boolean_algebra \u03b1] {a b : \u03b1} (h : - b \u2293 a = \u22a5) : a \u2264 b :=\nbegin\n  apply le_of_inf_eq, rw [\u2190@neg_neg _ b _, \u2190sub_eq], apply sub_eq_left, rwa [inf_comm]\nend\n\nlemma le_neg_of_inf_eq_bot {\u03b1 : Type*} [boolean_algebra \u03b1] {a b : \u03b1} (h : b \u2293 a = \u22a5) : a \u2264 - b :=\nby { apply le_of_sub_eq_bot, rwa [neg_neg] }\n\nlemma sub_eq_bot_of_le {\u03b1 : Type*} [boolean_algebra \u03b1] {a b : \u03b1} (h : a \u2264 b) : - b \u2293 a = \u22a5 :=\nby rw [\u2190inf_eq_of_le h, inf_comm, inf_assoc, inf_neg_eq_bot, inf_bot_eq]\n\nlemma inf_eq_bot_of_le_neg {\u03b1 : Type*} [boolean_algebra \u03b1] {a b : \u03b1} (h : a \u2264 - b) : b \u2293 a = \u22a5 :=\nby { rw [\u2190@neg_neg _ b], exact sub_eq_bot_of_le h }\n\n/-- the deduction theorem in \u03b2 -/\n@[simp]lemma imp_top_iff_le {\u03b1 : Type*} [boolean_algebra \u03b1] {a\u2081 a\u2082 : \u03b1} : (a\u2081 \u27f9 a\u2082 = \u22a4) \u2194 a\u2081 \u2264 a\u2082 :=\nbegin\n  unfold imp, refine \u27e8_,_\u27e9; intro H,\n    { have := congr_arg (\u03bb x, x \u2293 a\u2081) H, rw[sup_comm] at this,\n      finish[inf_sup_right] },\n    { have := sup_le_sup_right H (-a\u2081), finish }\nend\n/- \u2200 {\u03b1 : Type u_1} [_inst_1 : boolean_algebra \u03b1] {a\u2081 a\u2082 : \u03b1}, a\u2081 \u27f9 a\u2082 = \u22a4 \u2194 a\u2081 \u2264 a\u2082 -/\n\nlemma curry_uncurry {\u03b1 : Type*} [boolean_algebra \u03b1] {a b c : \u03b1} : ((a \u2293 b) \u27f9 c) = (a \u27f9 (b \u27f9 c)) :=\n  by simp[imp]; ac_refl\n\n/-- the actual deduction theorem in \u03b2, thinking of \u2264 as a turnstile -/\n@[ematch]lemma deduction {\u03b1 : Type*} [boolean_algebra \u03b1] {a b c : \u03b1} : a \u2293 b \u2264 c \u2194 a \u2264 (b \u27f9 c) :=\n  by {[smt] eblast_using [curry_uncurry, imp_top_iff_le]}\n\nlemma deduction_simp {\u03b1 : Type*} [boolean_algebra \u03b1] {a b c : \u03b1} : a \u2264 (b \u27f9 c) \u2194 a \u2293 b \u2264 c := deduction.symm\n\nlemma imp_top {\u03b1 : Type*} [complete_boolean_algebra \u03b1] (a : \u03b1) : a \u2264 a \u27f9 \u22a4 :=\nby {rw[<-deduction]; simp}\n\n/-- Given an \u03b7 : option \u03b1 \u2192 \u03b2, where \u03b2 is a complete lattice, we have that the supremum of \u03b7\n    is equal to (\u03b7 none) \u2294 \u2a06(a:\u03b1) \u03b7 (some a)-/\n@[simp]lemma supr_option {\u03b1 \u03b2 : Type*} [complete_lattice \u03b2] {\u03b7 : option \u03b1 \u2192 \u03b2} : (\u2a06(x : option \u03b1), \u03b7 x) = (\u03b7 none) \u2294 \u2a06(a : \u03b1), \u03b7 (some a) :=\nbegin\n  apply le_antisymm, tidy, cases i, apply le_sup_left,\n  apply le_sup_right_of_le, apply le_supr (\u03bb x, \u03b7 (some x)) i, apply le_supr, apply le_supr\nend\n\n/-- Given an \u03b7 : option \u03b1 \u2192 \u03b2, where \u03b2 is a complete lattice, we have that the infimum of \u03b7\n    is equal to (\u03b7 none) \u2293 \u2a05(a:\u03b1) \u03b7 (some a)-/\n@[simp]lemma infi_option {\u03b1 \u03b2 : Type*} [complete_lattice \u03b2] {\u03b7 : option \u03b1 \u2192 \u03b2} : (\u2a05(x : option \u03b1), \u03b7 x) = (\u03b7 none) \u2293 \u2a05(a : \u03b1), \u03b7 (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 (\u03bb x, \u03b7 (some x)) i, apply infi_le, apply infi_le\nend\n\nlemma supr_option' {\u03b1 \u03b2 : Type*} [complete_lattice \u03b2] {\u03b7 : \u03b1 \u2192 \u03b2} {b : \u03b2} : (\u2a06(x : option \u03b1), (option.rec b \u03b7 x : \u03b2) : \u03b2) = b \u2294 \u2a06(a : \u03b1), \u03b7 a :=\n  by rw[supr_option]\n\nlemma infi_option' {\u03b1 \u03b2 : Type*} [complete_lattice \u03b2] {\u03b7 : \u03b1 \u2192 \u03b2} {b : \u03b2} : (\u2a05(x : option \u03b1), (option.rec b \u03b7 x : \u03b2) : \u03b2) = b \u2293 \u2a05(a : \u03b1), \u03b7 a :=\n  by rw[infi_option]\n\n/-- Let A : \u03b1 \u2192 \u03b2 such that b = \u2a06(a : \u03b1) A a. Let c < b. If, for all a : \u03b1, A a \u2260 b \u2192 A a \u2264 c,\nthen there exists some x : \u03b1 such that A x = b. -/\nlemma supr_max_of_bounded {\u03b1 \u03b2 : Type*} [complete_lattice \u03b2] {A : \u03b1 \u2192 \u03b2} {b c : \u03b2}\n{h : b = \u2a06(a:\u03b1), A a} {h_lt : c < b} {h_bounded : \u2200 a : \u03b1, A a \u2260 b \u2192 A a \u2264 c} :\n  \u2203 x : \u03b1, A x = b :=\nbegin\n  haveI : decidable \u2203 (x : \u03b1), A x = b := classical.prop_decidable _,\n  by_contra, rw[h] at a, simp at a,\n  suffices : b \u2264 c, by {suffices : c < c, by {exfalso, have this' := lt_irrefl,\n  show Type*, exact \u03b2, show preorder (id \u03b2), 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 : \u03b1 \u2192 \u03b2 such that b \u2264 \u2a06(a : \u03b1) A a. Let c < b. If, for all a : \u03b1, A a \u2260 b \u2192 A a \u2264 c,\nthen there exists some x : \u03b1 such that b \u2264 A x. -/\nlemma supr_max_of_bounded' {\u03b1 \u03b2 : Type*} [complete_lattice \u03b2] {A : \u03b1 \u2192 \u03b2} {b c : \u03b2}\n{h : b \u2264 \u2a06(a:\u03b1), A a} {h_lt : c < b} {h_bounded : \u2200 a : \u03b1, (\u00ac b \u2264 A a) \u2192 A a \u2264 c} :\n  \u2203 x : \u03b1, b \u2264 A x :=\nbegin\n  haveI : decidable \u2203 (x : \u03b1), b \u2264 A x := classical.prop_decidable _,\n  by_contra, simp at a,\n  suffices : b \u2264 c, by {suffices : c < c, by {exfalso, have this' := lt_irrefl,\n  show Type*, exact \u03b2, show preorder (id \u03b2), 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 \u2a06(a : \u03b1), A a = \u22a4 such that whenever A a \u2260 \u22a4 \u2192 A \u03b1 = \u22a5, there exists some x : \u03b1 such that A x = \u22a4. -/\nlemma supr_eq_top_max {\u03b1 \u03b2 : Type*} [complete_lattice \u03b2] {A : \u03b1 \u2192 \u03b2} {h_nondeg : \u22a5 < (\u22a4 : \u03b2)}\n{h_top : (\u2a06(a : \u03b1), A a) = \u22a4} {h_bounded : \u2200 a : \u03b1, A a \u2260 \u22a4 \u2192 A a = \u22a5} : \u2203 x : \u03b1, A x = \u22a4 :=\n  by {apply supr_max_of_bounded, cc, exact h_nondeg, tidy}\n\nlemma supr_eq_Gamma_max {\u03b1 \u03b2 : Type*} [complete_lattice \u03b2] {A : \u03b1 \u2192 \u03b2} {\u0393 : \u03b2} (h_nonzero : \u22a5 < \u0393)\n(h_\u0393 : \u0393 \u2264 (\u2a06a, A a)) (h_bounded : \u2200 a, (\u00ac \u0393 \u2264 A a) \u2192 A a = \u22a5) : \u2203 x : \u03b1, \u0393 \u2264 A x :=\nbegin\n  apply supr_max_of_bounded', from \u2039_\u203a, from \u2039_\u203a, intros a H,\n  specialize h_bounded a \u2039_\u203a, rwa[le_bot_iff]\nend\n\n/-- \"eoc\" means the opposite of \"coe\", of course -/\nlemma eoc_supr {\u03b9 \u03b2 : Type*} {s : \u03b9 \u2192 \u03b2} [complete_lattice \u03b2] {X : set \u03b9} :\n  (\u2a06(i : X), s i) = \u2a06(i \u2208 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 {\u03b9 \u03b2 : Type*} {s : \u03b9 \u2192 \u03b2} [complete_lattice \u03b2] :\n  (\u2a06(i:\u03b9), s i) = \u2a06(X : set \u03b9), (\u2a06(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' {\u03b9 \u03b2 : Type*} {s : \u03b9 \u2192 \u03b2} [complete_lattice \u03b2] :\n  (\u2a06(i:\u03b9), s i) = \u2a06(X : set \u03b9), (\u2a06(x \u2208 X), s x) :=\nby {convert supr_all_sets using 1, simp[eoc_supr]}\n\n-- `b \u2264 \u2a06(i:\u03b9) c i` if there exists an s : set \u03b9 such that b \u2264 \u2a06 (i : s), c s\nlemma le_supr_of_le' {\u03b9 \u03b2 : Type*} {s : \u03b9 \u2192 \u03b2} {b : \u03b2} [complete_lattice \u03b2]\n  (H : \u2203 X : set \u03b9, b \u2264 \u2a06(x:X), s x) : b \u2264 \u2a06(i:\u03b9), s i :=\nbegin\n  rcases H with \u27e8X, H_X\u27e9, 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'' {\u03b9 \u03b2 : Type*} {s : \u03b9 \u2192 \u03b2} {b : \u03b2} [complete_lattice \u03b2]\n  (H : \u2203 X : set \u03b9, b \u2264 \u2a06(x \u2208 X), s x) : b \u2264 \u2a06(i:\u03b9), s i :=\nby {apply le_supr_of_le', convert H using 1, simp[eoc_supr]}\n\nlemma infi_congr {\u03b9 \u03b2 : Type*} {s\u2081 s\u2082 : \u03b9 \u2192 \u03b2} [complete_lattice \u03b2] {h : \u2200 i : \u03b9, s\u2081 i = s\u2082 i} :\n  (\u2a05(i:\u03b9), s\u2081 i) = \u2a05(i:\u03b9), s\u2082 i :=\nby simp*\n\n@[simp]lemma supr_congr {\u03b9 \u03b2 : Type*} {s\u2081 s\u2082 : \u03b9 \u2192 \u03b2} [complete_lattice \u03b2] {h : \u2200 i : \u03b9, s\u2081 i = s\u2082 i} :\n  (\u2a06(i:\u03b9), s\u2081 i) = \u2a06(i:\u03b9), s\u2082 i :=\nby simp*\n\nlemma imp_iff {\u03b2 : Type*} {a b : \u03b2} [complete_boolean_algebra \u03b2] : a \u27f9 b = -a \u2294 b := by refl\n\nlemma sup_inf_left_right_eq {\u03b2} [distrib_lattice \u03b2] {a b c d : \u03b2} :\n  (a \u2293 b) \u2294 (c \u2293 d) = (a \u2294 c) \u2293 (a \u2294 d) \u2293 (b \u2294 c) \u2293 (b \u2294 d) :=\nby {rw[sup_inf_right, sup_inf_left, sup_inf_left]; ac_refl}\n\nlemma inf_sup_right_left_eq {\u03b2} [distrib_lattice \u03b2] {a b c d : \u03b2} :\n  (a \u2294 b) \u2293 (c \u2294 d) = (a \u2293 c) \u2294 (a \u2293 d) \u2294 (b \u2293 c) \u2294 (b \u2293 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 {\u03b2} [boolean_algebra \u03b2] {a\u2081 a\u2082 : \u03b2} (h_anti : a\u2081 \u2293 a\u2082 = \u22a5) (h_partition : a\u2081 \u2294 a\u2082 = \u22a4) :\n  a\u2082 = - a\u2081 :=\nbegin\n  rw[show -a\u2081 = \u22a4 \u2293 -a\u2081, 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' {\u03b2} [lattice \u03b2] {a\u2081 a\u2082 a\u2083 : \u03b2} (h\u2081 : a\u2081 \u2264 a\u2082) {h\u2082 : a\u2081 \u2293 a\u2082 \u2264 a\u2083} : a\u2081 \u2264 a\u2083 :=\nbegin\n  suffices : a\u2081 \u2264 a\u2081 \u2293 a\u2082, from le_trans this \u2039_\u203a,\n  rw[show a\u2081 = a\u2081 \u2293 a\u2081, 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 {\u03b2 : Type*} {b : \u03b2} [boolean_algebra \u03b2] : \u22a4 \u2264 b \u27f9 \u22a4 :=\nby rw[<-deduction]; apply le_top\n\nlemma poset_yoneda_iff {\u03b2 : Type*} [partial_order \u03b2] {a b : \u03b2} : a \u2264 b \u2194 (\u2200 {\u0393 : \u03b2}, \u0393 \u2264 a \u2192 \u0393 \u2264 b) := \u27e8\u03bb _, by finish, \u03bb H, by specialize @H a; finish\u27e9\n\nlemma poset_yoneda_top {\u03b2 : Type*} [bounded_lattice \u03b2] {b : \u03b2} : \u22a4 \u2264 b \u2194 (\u2200 {\u0393 : \u03b2}, \u0393 \u2264 b) := \u27e8\u03bb _, by finish, \u03bb H, by apply H\u27e9\n\nlemma poset_yoneda {\u03b2 : Type*} [partial_order \u03b2] {a b : \u03b2} (H : \u2200 \u0393 : \u03b2, \u0393 \u2264 a \u2192 \u0393 \u2264 b) : a \u2264 b :=\nby rwa poset_yoneda_iff\n\nlemma poset_yoneda_inv {\u03b2 : Type*} [partial_order \u03b2] {a b : \u03b2} (\u0393 : \u03b2) (H : a \u2264 b) :\n  \u0393 \u2264 a \u2192 \u0393 \u2264 b := by rw poset_yoneda_iff at H; apply H\n\nlemma split_context {\u03b2 : Type*} [lattice \u03b2] {a\u2081 a\u2082 b : \u03b2} {H : \u2200 \u0393 : \u03b2, \u0393 \u2264 a\u2081 \u2227 \u0393 \u2264 a\u2082 \u2192 \u0393 \u2264 b} : a\u2081 \u2293 a\u2082 \u2264 b :=\nby {apply poset_yoneda, intros \u0393 H', apply H, finish}\n\nexample {\u03b2 : Type*} [bounded_lattice \u03b2] : \u22a4 \u2293 (\u22a4 : \u03b2) \u2293 \u22a4 \u2264 \u22a4 :=\nbegin\n  apply split_context, intros, simp only [le_inf_iff] at a, auto.split_hyps, from \u2039_\u203a\nend\n\nlemma context_Or_elim {\u03b2 : Type*} [complete_boolean_algebra \u03b2] {\u03b9} {s : \u03b9 \u2192 \u03b2} {\u0393 b : \u03b2}\n  (h : \u0393 \u2264 \u2a06(i:\u03b9), s i) {h' : \u2200 i, s i \u2293 \u0393 \u2264 s i \u2192 s i \u2293 \u0393 \u2264 b} : \u0393 \u2264 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 {\u03b2 : Type*} [complete_boolean_algebra \u03b2] {\u0393 a\u2081 a\u2082 b : \u03b2}\n  (H : \u0393 \u2264 a\u2081 \u2294 a\u2082) {H\u2081 : a\u2081 \u2293 \u0393 \u2264 a\u2081 \u2192 a\u2081 \u2293 \u0393 \u2264 b} {H\u2082 : a\u2082 \u2293 \u0393 \u2264 a\u2082 \u2192 a\u2082 \u2293 \u0393 \u2264 b} : \u0393 \u2264 b :=\nbegin\n  apply le_trans' H, rw[inf_comm], rw[deduction], apply sup_le; rw[<-deduction];\n  [apply H\u2081, apply H\u2082]; from inf_le_left\nend\n\nlemma bv_em_aux {\u03b2 : Type*} [complete_boolean_algebra \u03b2] (\u0393 : \u03b2) (b : \u03b2) : \u0393 \u2264 b \u2294 -b :=\nle_trans le_top $ by simp\n\nlemma bv_em {\u03b2 : Type*} [complete_boolean_algebra \u03b2] {\u0393 : \u03b2} (b : \u03b2) : \u0393 \u2264 b \u2294 -b :=\nbv_em_aux _ _\n\nlemma diagonal_supr_le_supr {\u03b1} [complete_lattice \u03b1] {\u03b9} {s : \u03b9 \u2192 \u03b9 \u2192 \u03b1} {\u0393 : \u03b1} (H : \u0393 \u2264 \u2a06 i, s i i) : \u0393 \u2264 \u2a06 i j, s i j :=\n le_trans H $ supr_le $ \u03bb i,  le_supr_of_le i $ le_supr_of_le i $ by refl\n\nlemma diagonal_infi_le_infi {\u03b1} [complete_lattice \u03b1] {\u03b9} {s : \u03b9 \u2192 \u03b9 \u2192 \u03b1} {\u0393 : \u03b1} (H : \u0393 \u2264 \u2a05 i j, s i j) : \u0393 \u2264 \u2a05 i, s i i :=\n  le_trans H $ le_infi $ \u03bb i, infi_le_of_le i $ infi_le_of_le i $ by refl\n\nlemma context_and_intro {\u03b2 : Type*} [lattice \u03b2] {\u0393} {a\u2081 a\u2082 : \u03b2}\n  (H\u2081 : \u0393 \u2264 a\u2081) (H\u2082 : \u0393 \u2264 a\u2082) : \u0393 \u2264 a\u2081 \u2293 a\u2082 := le_inf \u2039_\u203a \u2039_\u203a\n\nlemma specialize_context {\u03b2 : Type*} [partial_order \u03b2] {\u0393 b : \u03b2} (\u0393' : \u03b2) {H_le : \u0393' \u2264 \u0393} (H : \u0393 \u2264 b)\n  : \u0393' \u2264 b :=\nle_trans H_le H\n\nlemma context_specialize_aux {\u03b2 : Type*} [complete_boolean_algebra \u03b2] {\u03b9 : Type*} {s : \u03b9 \u2192 \u03b2}\n  (j : \u03b9) {\u0393 : \u03b2} {H : \u0393 \u2264 (\u2a05 i, s i)} : \u0393 \u2264 (\u2a05i, s i) \u27f9 s j :=\nby {apply le_trans H, rw[<-deduction], apply inf_le_right_of_le, apply infi_le}\n\nlemma context_specialize {\u03b2 : Type*} [complete_lattice \u03b2] {\u03b9 : Type*} {s : \u03b9 \u2192 \u03b2}\n  {\u0393 : \u03b2} (H : \u0393 \u2264 (\u2a05 i, s i)) (j : \u03b9) : \u0393 \u2264 s j :=\nle_trans H (infi_le _ _)\n\nlemma context_specialize_strict {\u03b2 : Type*} [complete_lattice \u03b2] {\u03b9 : Type*} {s : \u03b9 \u2192 \u03b2}\n  {\u0393 : \u03b2} (H : \u0393 < (\u2a05 i, s i)) (j : \u03b9) : \u0393 < 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 \u03b2 _ _, show \u03b2, from (\u2a05 i, s i),\n  apply lt_of_le_of_lt, show \u03b2, from \u0393, rw[H'], apply infi_le, from \u2039_\u203a\nend\n\nlemma context_split_inf_left {\u03b2 : Type*} [complete_lattice \u03b2] {a\u2081 a\u2082 \u0393: \u03b2} (H : \u0393 \u2264 a\u2081 \u2293 a\u2082) : \u0393 \u2264 a\u2081 :=\nby {rw[le_inf_iff] at H, finish}\n\nlemma context_split_inf_right {\u03b2 : Type*} [complete_lattice \u03b2] {a\u2081 a\u2082 \u0393: \u03b2} (H : \u0393 \u2264 a\u2081 \u2293 a\u2082) :\n  \u0393 \u2264 a\u2082 :=\nby {rw[le_inf_iff] at H, finish}\n\nlemma context_imp_elim {\u03b2 : Type*} [complete_boolean_algebra \u03b2] {a b \u0393: \u03b2} (H\u2081 : \u0393 \u2264 a \u27f9 b) (H\u2082 : \u0393 \u2264 a) : \u0393 \u2264 b :=\nbegin\n  apply le_trans' H\u2081, apply le_trans, apply inf_le_inf H\u2082, refl,\n  rw[inf_comm], simp[imp, inf_sup_right]\nend\n\nlemma context_imp_intro {\u03b2 : Type*} [complete_boolean_algebra \u03b2] {a b \u0393 : \u03b2} (H : a \u2293 \u0393 \u2264 a \u2192 a \u2293 \u0393 \u2264 b) : \u0393 \u2264 a \u27f9 b :=\nby {rw[<-deduction, inf_comm], from H (inf_le_left)}\n\ninstance imp_to_pi {\u03b2 } [complete_boolean_algebra \u03b2] {\u0393 a b : \u03b2} : has_coe_to_fun (\u0393 \u2264 a \u27f9 b) :=\n{ F := \u03bb x, \u0393 \u2264 a \u2192 \u0393 \u2264 b,\n  coe := \u03bb H\u2081 H\u2082, by {apply context_imp_elim; from \u2039_\u203a}}\n\ninstance infi_to_pi {\u03b9 \u03b2} [complete_boolean_algebra \u03b2] {\u0393 : \u03b2} {\u03d5 : \u03b9 \u2192 \u03b2} : has_coe_to_fun (\u0393 \u2264 infi \u03d5) :=\n{ F := \u03bb x, \u03a0 i : \u03b9, \u0393 \u2264 \u03d5 i,\n  coe := \u03bb H\u2081 i, by {change \u0393 \u2264 \u03d5 i, change \u0393 \u2264 _ at H\u2081, finish}}\n\nlemma bv_absurd {\u03b2} [boolean_algebra \u03b2] {\u0393 : \u03b2} (b : \u03b2) (H\u2081 : \u0393 \u2264 b) (H\u2082 : \u0393 \u2264 -b) : \u0393 \u2264 \u22a5 :=\n@le_trans _ _ _ (b \u2293 -b) _ (le_inf \u2039_\u203a \u2039_\u203a) (by simp)\n\nlemma neg_imp {\u03b2 : Type*} [boolean_algebra \u03b2] {a b : \u03b2} : -(a \u27f9 b) = a \u2293 (-b) :=\nby simp[imp]\n\nlemma nonzero_wit {\u03b2 : Type*} [complete_lattice \u03b2] {\u03b9 : Type*} {s : \u03b9 \u2192 \u03b2} :\n  (\u22a5 < (\u2a06i, s i)) \u2192 \u2203 j, (\u22a5 < s j) :=\nbegin\n  intro H, have := bot_lt_iff_not_le_bot.mp \u2039_\u203a,\n  haveI : decidable (\u2203 (j : \u03b9), \u22a5 < 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 \u2264 \u22a5) := classical.prop_decidable _,\n  by_contra, have := @bot_lt_iff_not_le_bot \u03b2 _ (s i), tauto\nend\n\nlemma nonzero_wit' {\u03b2 : Type*} [complete_distrib_lattice \u03b2] {\u03b9 : Type*} {s : \u03b9 \u2192 \u03b2} {\u0393 : \u03b2}\n  (H_nonzero : \u22a5 < \u0393) (H_le : \u0393 \u2264 \u2a06 i , s i ):\n  \u2203 j, (\u22a5 < s j \u2293 \u0393) :=\nbegin\n  haveI : decidable (\u2203 j, (\u22a5 < s j \u2293 \u0393)) := 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 : (\u2a06j, s j \u2293 \u0393) \u2264 \u22a5 := supr_le (\u03bb i, classical.by_contradiction $ H \u2039_\u203a),\n  rw[<-supr_inf_eq] at this,\n  suffices H_bad : \u0393 \u2293 \u0393 \u2264 \u22a5,\n    by {[smt] eblast_using [bot_lt_iff_not_le_bot, inf_self]},\n  exact le_trans (inf_le_inf \u2039_\u203a (by refl)) \u2039_\u203a,\nend\n\ndef CCC (\ud835\udd39 : Type u) [boolean_algebra \ud835\udd39] : Prop :=\n  \u2200 \u03b9 : Type u, \u2200 \ud835\udcd0 : \u03b9 \u2192 \ud835\udd39, (\u2200 i, \u22a5 < \ud835\udcd0 i) \u2192\n    (\u2200 i j, i \u2260 j \u2192 \ud835\udcd0 i \u2293 \ud835\udcd0 j \u2264 \u22a5) \u2192 (cardinal.mk \u03b9) \u2264 cardinal.omega\n\n@[reducible]noncomputable def Prop_to_bot_top {\ud835\udd39 : Type u} [has_bot \ud835\udd39] [has_top \ud835\udd39] : Prop \u2192 \ud835\udd39 :=\n\u03bb p, by {haveI : decidable p := classical.prop_decidable _, by_cases p, from \u22a4, from \u22a5}\n\n@[simp]lemma Prop_to_bot_top_true {\ud835\udd39 : Type u} [has_bot \ud835\udd39] [has_top \ud835\udd39] {p : Prop} {H : p} : Prop_to_bot_top p = (\u22a4 : \ud835\udd39) := by simp[*, Prop_to_bot_top]\n\n@[simp]lemma Prop_to_bot_top_false {\ud835\udd39 : Type u} [has_bot \ud835\udd39] [has_top \ud835\udd39] {p : Prop} {H : \u00ac p} : Prop_to_bot_top p = (\u22a5 : \ud835\udd39) := by simp[*, Prop_to_bot_top]\n\nlemma bv_by_contra {\ud835\udd39} [boolean_algebra \ud835\udd39] {\u0393 b : \ud835\udd39} (H : \u0393 \u2264 -b \u27f9 \u22a5) : \u0393 \u2264 b := by simpa using H\n\n-- noncomputable def to_boolean_valued_set {\ud835\udd39} [has_bot \ud835\udd39] [has_top \ud835\udd39] {\u03b1} : set \u03b1 \u2192 (\u03b1 \u2192 \ud835\udd39) :=\n-- \u03bb s, Prop_to_bot_top \u2218 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_? \u2192 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 : \u2200(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 \u00d7 expr) :=\ndo `(%%x \u2264 %%y) <- pure e,\n   return (x,y)\n\nmeta def lhs_of_le (e : expr) : tactic expr :=\nlhs_rhs_of_le e >>= \u03bb x, return x.1\n\nmeta def rhs_of_le (e : expr) : tactic expr :=\nlhs_rhs_of_le e >>= \u03bb 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 \u2264 _),\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 = \u22a5)\n\nmeta def hyp_is_ineq (e : expr) : tactic bool :=\n  (do `(%%x \u2264 %%y) <- infer_type e,\n     return tt)<|> return ff\n\nmeta def hyp_is_neg_ineq (e : expr) : tactic bool :=\n  (do `(%%x \u2264 - %%y) <- infer_type e,\n     return tt) <|> return ff\n\nmeta def trace_inequalities : tactic unit :=\n  (local_context >>= \u03bb l, l.mfilter (hyp_is_ineq)) >>= trace\n\nmeta def hyp_is_ineq_sup (e : expr) : tactic bool :=\n  (do `(%%x \u2264 %%y \u2294 %%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 >>= \u03bb l, l.mfilter (hyp_is_ineq_sup)) >>= trace\n\nmeta def specialize_context_at (H : parse ident) (\u0393 : parse texpr) : tactic unit :=\ndo e <- resolve_name H,\n   tactic.replace H ``(lattice.specialize_context %%\u0393 %%e),\n   swap >> try `[refine lattice.le_top] >> skip\n\nmeta def specialize_context_core (\u0393_old : expr) : tactic unit :=\ndo  v_a <- target >>= lhs_of_le,\n    tp <- infer_type \u0393_old,\n    \u0393_name <- get_unused_name \"\u0393\",\n    v <- mk_mvar, v' <- mk_mvar,\n    \u0393_new <- pose \u0393_name none v,\n    -- TODO(jesse) try replacing to_expr with an expression via mk_app instead\n    new_goal <- to_expr ``((%%\u0393_new : %%tp) \u2264 %%v'),\n    tactic.change new_goal,\n    ctx <- local_context,\n    ctx' <- ctx.mfilter\n      (\u03bb e, (do infer_type e >>= lhs_of_le >>= \u03bb e', succeeds $ is_def_eq \u0393_old e') <|> return ff),\n      ctx'.mmap' (\u03bb H, tactic.replace (get_name H) ``(le_trans (by exact inf_le_right <|> simp : %%\u0393_new \u2264 _) %%H)),\n    ctx2 <- local_context,\n    ctx2' <- ctx.mfilter (\u03bb e, (do infer_type e >>= lhs_of_le >>= instantiate_mvars >>= \u03bb e', succeeds $ is_def_eq \u0393_new e') <|> return ff),\n    -- trace ctx2',\n    ctx2'.mmap' (\u03bb H, do H_tp <- infer_type H,\n                         e'' <- lhs_of_le H_tp,\n                         succeeds (unify \u0393_new e'') >>\n                   tactic.replace (get_name H) ``(_ : %%\u0393_new \u2264 _) >> swap >> assumption)\n\nmeta def specialize_context_core' (\u0393_old : expr) : tactic unit :=\ndo  v_a <- target >>= lhs_of_le,\n    tp <- infer_type \u0393_old,\n    \u0393_name <- get_unused_name \"\u0393\",\n    v <- mk_mvar, v' <- mk_mvar,\n    \u0393_new <- pose \u0393_name none v,\n    -- TODO(jesse) try replacing to_expr with an expression via mk_app instead\n    new_goal <- to_expr ``((%%\u0393_new : %%tp) \u2264 %%v'),\n    tactic.change new_goal,\n    ctx <- local_context,\n    ctx' <- ctx.mfilter\n      (\u03bb e, (do infer_type e >>= lhs_of_le >>= \u03bb e', succeeds $ is_def_eq \u0393_old e') <|> return ff),\n      ctx'.mmap' (\u03bb H, to_expr ``(le_trans (by exact inf_le_right <|> simp : %%\u0393_new \u2264 _) %%H) >>= \u03bb foo, tactic.note (get_name H) none foo),\n    ctx2 <- local_context,\n    ctx2' <- ctx.mfilter (\u03bb e, (do infer_type e >>= lhs_of_le >>= instantiate_mvars >>= \u03bb e', succeeds $ is_def_eq \u0393_new e') <|> return ff),\n    -- trace ctx2',\n    ctx2'.mmap' (\u03bb H, do H_tp <- infer_type H,\n                         e'' <- lhs_of_le H_tp,\n                         succeeds (unify \u0393_new e'') >>\n                   tactic.replace (get_name H) ``(_ : %%\u0393_new \u2264 _) >> swap >> assumption)\n\nmeta def specialize_context_assumption_core (\u0393_old : expr) : tactic unit :=\ndo  v_a <- target >>= lhs_of_le,\n    tp <- infer_type \u0393_old,\n    \u0393_name <- get_unused_name \"\u0393\",\n    v <- mk_mvar, v' <- mk_mvar,\n    \u0393_new <- pose \u0393_name none v,\n    -- TODO(jesse) try replacing to_expr with an expression via mk_app instead\n    new_goal <- to_expr ``((%%\u0393_new : %%tp) \u2264 %%v'),\n    tactic.change new_goal,\n    ctx <- local_context,\n    ctx' <- ctx.mfilter\n      (\u03bb e, (do infer_type e >>= lhs_of_le >>= \u03bb e', succeeds $ is_def_eq \u0393_old e') <|> return ff),\n      ctx'.mmap' (\u03bb H, tactic.replace (get_name H) ``(le_trans (by exact inf_le_right <|> assumption : %%\u0393_new \u2264 _) %%H)),\n    ctx2 <- local_context,\n    ctx2' <- ctx.mfilter (\u03bb e, (do infer_type e >>= lhs_of_le >>= instantiate_mvars >>= \u03bb e', succeeds $ is_def_eq \u0393_new e') <|> return ff),\n    -- trace ctx2',\n    ctx2'.mmap' (\u03bb H, do H_tp <- infer_type H,\n                         e'' <- lhs_of_le H_tp,\n                         succeeds (unify \u0393_new e'') >>\n                   tactic.replace (get_name H) ``(_ : %%\u0393_new \u2264 _) >> swap >> assumption)\n\n\n\n/-- If the goal is an inequality `a \u2264 b`, extracts `a` and attempts to specialize all\n  facts in context of the form `\u0393 \u2264 d` to `a \u2264 d` (this requires a \u2264 \u0393) -/\nmeta def specialize_context (\u0393 : parse texpr) : tactic unit :=\ndo\n  \u0393_old <- i_to_expr \u0393,\n  specialize_context_core \u0393_old\n\nmeta def specialize_context_assumption (\u0393 : parse texpr) : tactic unit :=\ndo\n  \u0393_old <- i_to_expr \u0393,\n  specialize_context_assumption_core \u0393_old\n\nmeta def specialize_context' (\u0393 : parse texpr) : tactic unit :=\ndo\n  \u0393_old <- i_to_expr \u0393,\n  specialize_context_core' \u0393_old\n\nexample {\u03b2 : Type u} [lattice.bounded_lattice \u03b2] {a b : \u03b2} {H : \u22a4 \u2264 b} : a \u2264 b :=\nby {specialize_context (\u22a4 : \u03b2), 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\u2080 <- resolve_name H,\n  e\u2080' <- to_expr e\u2080,\n  \u0393_old <- target >>= lhs_of_le,\n  `[refine lattice.context_Or_elim %%e\u2080'],\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 \u0393_old\n\n\nmeta def bv_cases_at' (H : parse ident) (i : parse ident_) (H_i : parse ident?)  : tactic unit :=\ndo\n  e\u2080 <- resolve_name H,\n  e\u2080' <- to_expr e\u2080,\n  \u0393_old <- target >>= lhs_of_le,\n  `[refine lattice.context_Or_elim %%e\u2080'],\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' \u0393_old\n\nmeta def bv_cases_at'' (H : parse ident) (i : parse ident_)  : tactic unit :=\ndo\n  e\u2080 <- resolve_name H,\n  e\u2080' <- to_expr e\u2080,\n  \u0393_old <- target >>= lhs_of_le,\n  `[refine lattice.context_Or_elim %%e\u2080'],\n  tactic.intro i >> ((get_unused_name H) >>= tactic.intro) >>\n  skip\n\n-- here `e` is the proof of \u0393 \u2264 a \u2294 b\nmeta def bv_or_elim_at_core (e : expr) (\u0393_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 \u0393_old, swap,\n   (tactic.intro n') >> specialize_context_core \u0393_old, swap\n\nmeta def bv_or_elim_at_core' (e : expr) (\u0393_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' \u0393_old, swap,\n   (tactic.intro n') >> specialize_context_core' \u0393_old, swap\n\nmeta def bv_or_elim_at_core'' (e : expr) (\u0393_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' \u0393_old, swap,\n   (tactic.intro n') >> specialize_context_core' \u0393_old, swap\n\nmeta def bv_or_elim_at (H : parse ident) : tactic unit :=\ndo \u0393_old <- target >>= lhs_of_le,\n   e <- resolve_name H >>= to_expr,\n   bv_or_elim_at_core e \u0393_old H\n\n-- `px` is a term of type `\ud835\udd39`; this cases on \"`px \u2228 \u00ac px`\"\nmeta def bv_cases_on (px : parse texpr) (opt_id : parse (tk \"with\" *> ident)?) : tactic unit :=\ndo \u0393_old \u2190 target >>= lhs_of_le,\n   e \u2190 to_expr ``(lattice.bv_em_aux %%\u0393_old %%px),\n   let nm := option.get_or_else opt_id \"H\",\n   get_unused_name nm >>= bv_or_elim_at_core e \u0393_old\n\nmeta def bv_or_elim_at' (H : parse ident) : tactic unit :=\ndo \u0393_old <- target >>= lhs_of_le,\n   e <- resolve_name H >>= to_expr,\n   bv_or_elim_at_core' e \u0393_old H\n\n-- `px` is a term of type `\ud835\udd39`; this cases on \"`px \u2228 \u00ac px`\"\nmeta def bv_cases_on' (px : parse texpr) (opt_id : parse (tk \"with\" *> ident)?) : tactic unit :=\ndo \u0393_old \u2190 target >>= lhs_of_le,\n   e \u2190 to_expr ``(lattice.bv_em_aux %%\u0393_old %%px),\n   let nm := option.get_or_else opt_id \"H\",\n   get_unused_name nm >>= bv_or_elim_at_core' e \u0393_old\n\nexample {\u03b2 : Type*} [lattice.nontrivial_complete_boolean_algebra \u03b2] {\u0393 : \u03b2} : \u0393 \u2264 \u22a4 :=\nbegin\n  bv_cases_on \u22a4,\n    { from \u2039_\u203a },\n    { by simp* }\nend\n\n-- TODO(jesse) debug these\n-- meta def auto_or_elim_step : tactic unit :=\n-- do  ctx <- local_context >>= (\u03bb l, l.mfilter hyp_is_ineq_sup),\n--     if ctx.length > 0 then\n--     ctx.mmap' (\u03bb e, do \u0393_old <- target >>= lhs_of_le, bv_or_elim_at_core e \u0393_old)\n--     else tactic.failed\n\n-- meta def auto_or_elim : tactic unit := tactic.repeat auto_or_elim_step\n\n-- example {\u03b2 \u03b9 : Type u} [lattice.complete_boolean_algebra \u03b2] {s : \u03b9 \u2192 \u03b2} {H' : \u22a4 \u2264 \u2a06i, s i} {b : \u03b2} : b \u2264 \u22a4 :=\n-- by {specialize_context \u22a4, bv_cases_at H' i, specialize_context \u0393, 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 >>= \u03bb 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 \u2a05 or an \u27f9\"\n\nmeta def bv_to_pi' : tactic unit :=\ndo ctx <- (local_context >>= (\u03bb l, l.mfilter hyp_is_ineq)),\n   ctx.mmap' (\u03bb 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 >>= (\u03bb l, l.mfilter hyp_is_ineq)),\n   ctx.mmap' (\u03bb e, try (tactic.replace (get_name e) ``(lattice.le_inf_iff.mp %%e))),\n   auto_cases >> skip\n\nmeta def bv_and_intro (H\u2081 H\u2082 : parse ident) : tactic unit :=\ndo\n  H\u2081 <- resolve_name H\u2081,\n  H\u2082 <- resolve_name H\u2082,\n  e <- to_expr ``(lattice.context_and_intro %%H\u2081 %%H\u2082),\n   n <- get_unused_name \"H\",\n   note n none e >> skip\n\nmeta def bv_imp_elim_at (H\u2081 : parse ident) (H\u2082 : parse texpr) : tactic unit :=\ndo n <- get_unused_name \"H\",\n   e\u2081 <- resolve_name H\u2081,\n   e <- to_expr ``(lattice.context_imp_elim %%e\u2081 %%H\u2082),\n   note n none e >>= \u03bb h, dsimp_hyp h none [] eta_beta_cfg\n\nmeta def bv_mp (H : parse ident) (H\u2082 : parse texpr) : tactic unit :=\ndo\n   n <- get_unused_name H,\n   e_H <- resolve_name H,\n   e_L <- to_expr H\u2082,\n   pr <- to_expr ``(le_trans %%e_H %%e_L),\n   note n none pr >>= \u03bb 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 \u0393_old <- target >>= lhs_of_le,\n  `[refine lattice.context_imp_intro _] >> (get_unused_name \"H\" >>= tactic.intro) >> skip,\n  specialize_context_core \u0393_old\n| (some n) := do \u0393_old <- target >>= lhs_of_le,\n  `[refine lattice.context_imp_intro _] >> (tactic.intro n) >> skip,\n  specialize_context_core \u0393_old\nend\n\nmeta def bv_imp_intro' (nm : parse $ optional ident_) : tactic unit :=\nmatch nm with\n| none := do \u0393_old <- target >>= lhs_of_le,\n  `[refine lattice.context_imp_intro _] >> (get_unused_name \"H\" >>= tactic.intro) >> skip,\n  specialize_context_core' \u0393_old\n| (some n) := do \u0393_old <- target >>= lhs_of_le,\n  `[refine lattice.context_imp_intro _] >> (tactic.intro n) >> skip,\n  specialize_context_core' \u0393_old\nend\n\nmeta def tidy_context_tactics : list (tactic string) :=\n[ reflexivity                                 >> pure \"refl\",\n  propositional_goal >> assumption            >> pure \"assumption\",\n  intros1                                     >>= \u03bb ns, pure (\"intros \" ++ (\" \".intercalate (ns.map (\u03bb 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 \u2264 - y\n-/\nprivate meta def is_le_neg (e : expr) : tactic (expr \u00d7 expr) :=\ndo `(%%x \u2264 - %%y) <- pure e, return (x,y)\n\n-- private meta def le_not (lhs : expr) (rhs : expr) : expr \u2192 tactic expr := \u03bb e,\n-- do `(%%x \u2264 - %%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 \u2264 -y`, succeed if an expression of type `x \u2264 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\u2081 \u2264 - %%y\u2082) <- (infer_type e),\n   match ctx_le with\n   | [] := tactic.fail \"there are no hypotheses\"\n   | hd :: tl := do b <- (succeeds (do `(%%x\u2081 \u2264 %%x\u2082) <- (infer_type hd),\n                                       is_def_eq x\u2081 y\u2081, is_def_eq x\u2082 y\u2082)),\n                    if b then return hd else by exact _match tl\n   end\n\nprivate meta def find_dual (xs : list expr) : tactic (expr \u00d7 expr) :=\ndo xs' <- (xs.mfilter (\u03bb 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 >>= \u03bb l, l.mfilter (hyp_is_ineq)),\n   (h\u2081,h\u2082) <- find_dual ctx,\n   bv_exfalso >> mk_app (`lattice.bv_absurd) [h\u2081,h\u2082] >>= 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 \u2192 cfg :=\n\u03bb 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 {\ud835\udd39} [lattice.lattice \ud835\udd39] (\u0393 : \ud835\udd39) : \u03a0 (xs : list (\ud835\udd39)) (g : \ud835\udd39), Prop\n | [] x := \u0393 \u2264 x\n | (x :: xs) y := \u0393 \u2264 x \u2192 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 : \u03b9 \u2192 \ud835\udd39\n\n-- this introduces a new index i : \u03b9 into context, and now we have to add additionally the assumption that \u0393 \u2264 S i.\n\n-- Therefore, the next step is to revert all dependences except for i, so that we then have\n\n-- \u2200 \u0393'', with_h_asms \u0393'' [p,q,r,S i] g \u2192 (\u0393' \u2264 p \u2192 \u0393' \u2264 q \u2192 \u0393' \u2264 r \u2192 \u0393' \u2264 S i \u2192 \u0393' \u2264 g)\n-- some work still has to be done in showing\n-- that \u0393' \u2264 \u0393 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 ` \u27f9 `:75 := lattice.imp\n\nexample {\ud835\udd39} [complete_boolean_algebra \ud835\udd39] {a b c : \ud835\udd39} :\n ( a \u27f9 b ) \u2293 ( b \u27f9 c ) \u2264 a \u27f9 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 \u0393 : \u03b2,\n-- \u0393_1 : \u03b2 := a \u2293 \u0393,\n-- a_1_left : \u0393_1 \u2264 a \u27f9 b,\n-- a_1_right : \u0393_1 \u2264 b \u27f9 c,\n-- Ha : \u0393_1 \u2264 a\n-- \u22a2 \u0393_1 \u2264 c\n\n\nexample {\u03b2 : Type*} [complete_boolean_algebra \u03b2] {a b c : \u03b2} :\n ( a \u27f9 b ) \u2293 ( b \u27f9 c ) \u2264 a \u27f9 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 \u2293 a) \u2293 (-b \u2294 c) \u2264 c,\n  from inf_le_left_of_le (by simp), rw[inf_sup_right],\n  let x := _, let y := _, change b \u2293 (x \u2294 y) \u2264 _,\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} {\u03b1 : Type*} {G : simple_graph V} {M : G.subgraph}\nvariables {u v : V}\nvariables {p: G.path u v}\n\nlemma sym2.mem_exists: \u2200 xy: sym2 V, \u2203 x : V, x \u2208 xy :=\nbegin\n  rw sym2.forall,\n  exact \u03bb x y, \u27e8x, sym2.mem_mk_left _ _\u27e9,\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 \u2208 xy := classical.some_spec (sym2.mem_exists xy)\n\ntheorem sym2.left.mem_of_eq {xy: sym2 V}: sym2.left xy = v \u2192 v \u2208 xy :=\nbegin\n  intro h,\n  rw [\u2190 h],\n  exact sym2.left.mem _\nend\n\ntheorem sym2.or_of_left (x y: V): x = sym2.left \u27e6(x, y)\u27e7 \u2228 y = sym2.left \u27e6(x, y)\u27e7 :=\nbegin\n  cases sym2.mem_iff.mp (sym2.left.mem \u27e6(x, y)\u27e7); 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 \u27e6(x, y)\u27e7 = z \u2192 x = z \u2228 y = z :=\nbegin\n  cases sym2.mem_iff.mp (sym2.left.mem \u27e6(x, y)\u27e7); 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 \u2208 M.edge_set \u2192 e.left \u2208 hM.left := set.mem_image_of_mem _\n\ntheorem is_matching.left_mem (hM: M.is_matching) {v: V}: v \u2208 hM.left \u2192 v \u2208 M.verts :=\nbegin\n  simp only [is_matching.left, set.mem_image, forall_exists_index, and_imp, sym2.forall],\n  exact \u03bb x y hxy hv, (hv.symm \u25b8 mem_verts_if_mem_edge) hxy (sym2.left.mem _),\nend\n\ntheorem is_matching.left_subset (hM: M.is_matching): hM.left \u2286 M.verts := \u03bb _, hM.left_mem\n\ntheorem is_matching.left_mem_of_right (hM: M.is_matching) {v: V}: v \u2208 hM.right \u2192 hM.other v \u2208 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 \u2208 hM.right \u2192 v \u2208 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 \u2208 hM.left \u2192 hM.other v \u2208 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 \u2208 hM.left \u2192 v \u2208 hM.right :=\nby simp [is_matching.right, hM.other_inj_iff']\n\ntheorem is_matching.right_mem (hM: M.is_matching) {v: V}: v \u2208 hM.right \u2192 v \u2208 M.verts :=\nbegin\n  simp only [is_matching.right, set.mem_image, forall_exists_index, and_imp, sym2.forall],\n  exact \u03bb x hxM hxv, hxv \u25b8 hM.other_mem_verts (hM.left_mem hxM)\nend\n\ntheorem is_matching.left_unique_edge  (hM: M.is_matching) {v: V}: v \u2208 hM.left \u2192 \u2203! u : sym2 V, u \u2208 M.edge_set \u2227 u.left = v :=\nbegin\n  unfold is_matching.left,\n  rw [set.mem_image],\n  intro h,\n  rcases h with \u27e8x, hxM, hxv\u27e9,\n  refine exists_unique_of_exists_of_unique \u27e8x, hxM, hxv\u27e9 _,\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 \u2208 hM.left \u2192 \u2203! u : sym2 V, u \u2208 M.edge_set \u2227 v \u2208 u :=\nbegin\n  unfold is_matching.left,\n  rw [set.mem_image],\n  intro h,\n  rcases h with \u27e8x, hxM, hxv\u27e9,\n  refine exists_unique_of_exists_of_unique \u27e8x, hxM, sym2.left.mem_of_eq hxv\u27e9 _,\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 \u2208 hM.left \u2192 v \u2208 e \u2192 e \u2208 M.edge_set \u2192 e.left = v :=\nbegin\n  intros hvM hve heM,\n  rcases exists_unique.exists (hM.left_unique_edge hvM) with \u27e8x, hxM, hxv\u27e9,\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 \u2208 hM.left \u2192 hM.other v \u2209 hM.left :=\nbegin\n  intros hv hv',\n  rcases hM.left_unique_edge' hv with \u27e8e, \u27e8hm, hve\u27e9, hu \u27e9,\n  rcases exists_unique.exists (hM.left_unique_edge' hv') with \u27e8e', hm', hve'\u27e9,\n  apply hM.ne_of_mem (hM.left_mem hv),\n  rw [\u2190 hM.left_of_edge hv' hve' hm', \u2190 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 \u2208 hM.left \u2192 v \u2209 hM.left :=\n   \u03bb h, hM.other_inverse v \u25b8 (hM.left_other h)\n  \ntheorem is_matching.right_other (hM: M.is_matching) {v: V}: v \u2208 hM.right \u2192 hM.other v \u2209 hM.right :=\n\u03bb 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 \u2208 hM.right \u2192 v \u2209 hM.right :=\n  \u03bb h, hM.other_inverse v \u25b8 (hM.right_other h)\n\ntheorem is_matching.left_independent (hM: M.is_matching) (x y: V): x \u2208 hM.left \u2192 y \u2208 hM.left \u2192 \u00ac 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 [\u2190 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 [\u2190 heq],\nend\n\ntheorem is_matching.left_edge_cover (hM: M.is_matching) {x y: V}:\n  M.adj x y \u2192 x \u2208 hM.left \u2228 y \u2208 hM.left :=\nbegin\n  rw [\u2190 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 \u2208 M.verts \u2192 x \u2208 hM.left \u2228 hM.other x \u2208 hM.left := hM.left_edge_cover \u2218 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 \u27e8\u27e8\n    \u03bb x, \u27e8hM.other x, (set.mem_image _ _ _).mpr \u27e8x, x.property, rfl\u27e9\u27e9,\n    \u03bb x, \u27e8hM.other x, _, \u27e9,\n      _, _\u27e9\u27e9,\n    { rcases x.property with \u27e8y, hys, hyx\u27e9,\n      unfold_coes,\n      rwa [\u2190 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 \u27e8\u27e8\n    \u03bb x, \u27e8hM.other x, (set.mem_image _ _ _).mpr \u27e8x, x.property, rfl\u27e9\u27e9,\n    \u03bb x, \u27e8hM.other x, hM.left_of_right.symm \u25b8 (set.mem_image _ _ _).mpr \u27e8x, x.property, rfl\u27e9\u27e9,\n    _, _ \u27e9\u27e9,\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 \u222a hM.right :=\nset.ext (\u03bb x, \u27e8\n    \u03bb hx, or.elim (hM.left_other_cover hx)\n      (\u03bb h, or.inl h)\n      (\u03bb h, or.inr ((set.mem_image _ _ _).mpr \u27e8hM.other x, h, hM.other_inverse _\u27e9)),\n    \u03bb h, or.elim h hM.left_mem hM.right_mem \u27e9)\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 \u03bb _ 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 \u2286 M.verts \u2192 is_antichain M.adj s \u2192 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 \u2260 v,\n  by contrapose! hu; simp [hu],\n  have hv' : u \u2260 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 \u2286 M.verts):\n  (\u2200 {v}, v \u2208 s \u2192 \u2203 u, u \u2208 s \u2227 M.adj v u) \u2192 (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 \u03bb x, \u27e8 and.right \u2218 and.right, \u03bb hadj, \u27e8 hv, _, hadj \u27e9 \u27e9,\n  rcases h hv with \u27e8u, hu, hadj'\u27e9,\n  rwa [exists_unique.unique (hM hv') hadj hadj'],\nend\n\ntheorem is_matching.exists_smaller (hM: M.is_matching) {c: cardinal} (hc: c \u2264 cardinal.mk M.verts) (hc': even c):\n  \u2203 M': G.subgraph, M'.verts \u2286 M.verts \u2227 cardinal.mk M'.verts = c \u2227 M'.is_matching :=\nbegin\n  cases hc' with d hd,\n  rcases @set.cardinal_embedding _ hM.left d  _ with \u27e8s, hcard, hsub\u27e9,\n  refine \u27e8M.induce (s \u2294 set.image hM.other s), _, _, _\u27e9,\n  { simp only [set.union_subset_iff, set.image_subset_iff, set.sup_eq_union, simple_graph.subgraph.induce_verts],\n    exact \u27e8 set.subset.trans hsub hM.left_subset, \u03bb x hx, hM.other_mem_verts (hM.left_mem (hsub hx)) \u27e9 },\n  { rwa [set.sup_eq_union, simple_graph.subgraph.induce_verts, cardinal.mk_union_of_disjoint, \u2190 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 \u03bb v  hv, or.elim hv\n        (set.mem_of_subset_of_mem (trans hsub hM.left_subset))\n        (\u03bb 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 \u03bb v hv, or.elim hv\n      (\u03bb hv, \u27e8hM.other v, or.inr ((set.mem_image _ _ _).mpr \u27e8_, hv, rfl\u27e9),\n        hM.other_adj (set.mem_of_subset_of_mem (trans hsub hM.left_subset) hv) \u27e9)\n      (\u03bb hv, \u27e8hM.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))) \u27e9) },\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, \u2190 hd, add_mul, (show 2 = 1 + 1, by refl)],\n    conv {\n      to_rhs,\n      congr,\n      skip,\n      rw [hM.other_card, \u2190 hM.right_of_left],\n    },\n    rwa [\u2190 cardinal.mk_union_of_disjoint hM.left_right_disjoint, \u2190 hM.left_right_total],\n  },\nend\n\nstructure alternating_path (p: path G u v) (M: G.subgraph): Prop :=\n  (start_inv: u \u2209 M.verts)\n  (alt_inv: \u2200 {x y z}, y \u2260 z \u2192 (p:G.subgraph).adj x y \u2192 (p:G.subgraph).adj x z \u2192\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 \u2208 (p: G.subgraph).verts \u2192 u = x \u2228 v = x \u2228 x \u2208 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 \u2192 (M \u2206 p).is_matching :=\n-- begin\n--   intro hM,\n--   intro x,\n--   intro hx,\n--   by_cases x \u2208 (p:G.subgraph).verts,\n--   { rw [p.coe_verts_iff_get_vert] at h,\n--     rcases h with \u27e8n, hn, h\u27e9,\n--     rw [\u2190 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' _ _ _ (\u03bb _, 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' _ _ _ (\u03bb _, 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--       (\u03bb _, 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 \u2260 v)\n  (end_inv: v \u2209 M.verts)\n\nnamespace augmenting_path\n\ntheorem mem_verts (ap: augmenting_path p M) {x: V}:\n  x \u2208 (p: G.subgraph).verts \u2192 u = x \u2228 v = x \u2228 x \u2208 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 \u2192 (M \u2206 p).is_matching :=\nbegin\n  intro hM,\n  intro x,\n  intro hx,\n  by_cases x \u2208 (p:G.subgraph).verts,\n  { rw [p.coe_verts_iff_get_vert] at h,\n    rcases h with \u27e8n, hn, h\u27e9,\n    rw [\u2190 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' _ _ _ (\u03bb _, 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' _ _ _ (\u03bb _, 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      (\u03bb _, 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}: (\u00ac p \u2227 q) \u2192 p \u2228 q := by tauto\n\ntheorem augmented_verts (ap: augmenting_path p M):\n  (M \u2206 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 \u2206 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 \u27e8ap.not_nil, ap.start_inv\u27e9,\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: \u2115) (hn: cardinal.mk M.verts = 2 * n) {N: subgraph G} (hN: is_matching N):\n--     \u2200 (u: V), u \u2209 M.verts \u2192 u \u2208 N.verts \u2192 \u2203 (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 \u27e8 hN.other u, path.singleton (N.adj_sub (hN.other_adj huN)), hN.ne_of_mem huN, huM, _, _\u27e9,\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 \u2208 M.verts,\n--   { specialize n_ih (hM.delete_pair \u27e8_, huM'\u27e9) _ (hN.delete_pair \u27e8_, huN\u27e9) (hM.other (hN.other)),\n    \n\n--   },\n--   { refine \u27e8 hN.other u, path.singleton (N.adj_sub (hN.other_adj huN)), hN.ne_of_mem huN, huM, huM', _\u27e9,\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--   (\u2203 {u v: V} (p: path G u v), augmenting_path p M) \u2194 \u00ac 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 \u27e8u, v, p, ap\u27e9,\n--     use ap.augmented_subgraph,\n--     refine \u27e8 ap.maintains_is_matching hM, _\u27e9,\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 [\u2190 nat.cast_two, \u2190 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 \u27e8N, hN, h\u27e9,\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\u2070 = R \\ {0}` (i.e. the field of fractions).\n * `fractional_ideal R\u2070 K` is the type of fractional ideals in the field of fractions\n * `has_div (fractional_ideal R\u2070 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 \u2286 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 `(+) := (\u2294)` and `\u22a5 := 0`,\nin order to re-use their respective proof terms.\nWe can still use `simp` to show `\u2191I + \u2191J = \u2191(I + J)` and `\u2191\u22a5 = \u21910`.\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\u2070`,\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 \u2286 R` for some `a \u2260 0`. -/\ndef is_fractional (I : submodule R P) :=\n\u2203 a \u2208 S, \u2200 b \u2208 I, is_integer R (a \u2022 b)\n\nvariables (S P)\n\n/-- The fractional ideals of a domain `R` are ideals of `R` divided by some `a \u2208 R`.\n\n  More precisely, let `P` be a localization of `R` at some submonoid `S`,\n  then a fractional ideal `I \u2286 P` is an `R`-submodule of `P`,\n  such that there is a nonzero `a : R` with `a I \u2286 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 `\u2203 a, a I \u2286 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 \u2192 submodule R P`\n(which we use to define `coe : ideal R \u2192 fractional_ideal S P`).\n-/\ninstance : has_coe (fractional_ideal S P) (submodule R P) := \u27e8\u03bb I, I.val\u27e9\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 := \u03bb I, \u2191(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 \u2208 (I : submodule R P) \u2194 x \u2208 I :=\niff.rfl\n\n@[ext] lemma ext {I J : fractional_ideal S P} : (\u2200 x, x \u2208 I \u2194 x \u2208 J) \u2192 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 = \u2191p) : fractional_ideal S P :=\n\u27e8submodule.copy p s hs, by { convert p.is_fractional, ext, simp only [hs], refl }\u27e9\n\n@[simp] lemma coe_copy (p : fractional_ideal S P) (s : set P) (hs : s = \u2191p) :\n  \u2191(p.copy s hs) = s :=\nrfl\n\nlemma coe_eq (p : fractional_ideal S P) (s : set P) (hs : s = \u2191p) : 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 \u2191I\ninstance (I : fractional_ideal S P) : module R I := submodule.module \u2191I\n\nlemma coe_to_submodule_injective :\n  function.injective (coe : fractional_ideal S P \u2192 submodule R P) :=\nsubtype.coe_injective\n\nlemma coe_to_submodule_inj {I J : fractional_ideal S P} : (I : submodule R P) = J \u2194 I = J :=\ncoe_to_submodule_injective.eq_iff\n\nlemma is_fractional_of_le_one (I : submodule R P) (h : I \u2264 1) : is_fractional S I :=\nbegin\n  use [1, S.one_mem],\n  intros b hb,\n  rw one_smul,\n  obtain \u27e8b', b'_mem, rfl\u27e9 := 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 \u2264 J) :\n  is_fractional S I :=\nbegin\n  obtain \u27e8a, a_mem, ha\u27e9 := 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 \u2192 submodule R P`,\nwhich is not to be confused with the `coe : fractional_ideal S P \u2192 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\u27e8\u03bb I, \u27e8coe_submodule P I,\n  is_fractional_of_le_one _ $ by simpa using coe_submodule_mono P (le_top : I \u2264 \u22a4)\u27e9\u27e9\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 \u2208 (I : fractional_ideal S P) \u2194 \u2203 x', x' \u2208 I \u2227 algebra_map R P x' = x :=\nmem_coe_submodule _ _\n\nlemma mem_coe_ideal_of_mem {x : R} {I : ideal R} (hx : x \u2208 I) :\n  algebra_map R P x \u2208 (I : fractional_ideal S P) :=\n(mem_coe_ideal S).mpr \u27e8x, hx, rfl\u27e9\n\nlemma coe_ideal_le_coe_ideal' [is_localization S P] (h : S \u2264 non_zero_divisors R)\n  {I J : ideal R} : (I : fractional_ideal S P) \u2264 J \u2194 I \u2264 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\u2070 K) \u2264 J \u2194 I \u2264 J :=\nis_fraction_ring.coe_submodule_le_coe_submodule\n\ninstance : has_zero (fractional_ideal S P) := \u27e8(0 : ideal R)\u27e9\n\n@[simp] lemma mem_zero_iff {x : P} : x \u2208 (0 : fractional_ideal S P) \u2194 x = 0 :=\n\u27e8(\u03bb \u27e8x', x'_mem_zero, x'_eq_x\u27e9,\n   have x'_eq_zero : x' = 0 := x'_mem_zero,\n   by simp [x'_eq_x.symm, x'_eq_zero]),\n (\u03bb hx, \u27e80, rfl, by simp [hx]\u27e9)\u27e9\n\nvariables {S}\n\n@[simp, norm_cast] lemma coe_zero : \u2191(0 : fractional_ideal S P) = (\u22a5 : submodule R P) :=\nsubmodule.ext $ \u03bb _, mem_zero_iff S\n\n@[simp, norm_cast] lemma coe_ideal_bot : ((\u22a5 : 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 \u2264 non_zero_divisors R) :\n  (\u2203 x', x' \u2208 I \u2227 algebra_map R P x' = algebra_map R P x) \u2194 x \u2208 I :=\n\u27e8\u03bb \u27e8x', hx', eq\u27e9, is_localization.injective _ h eq \u25b8 hx', \u03bb h, \u27e8x, h, rfl\u27e9\u27e9\n\nvariables {P}\n\nlemma coe_ideal_injective' (h : S \u2264 non_zero_divisors R) :\n  function.injective (coe : ideal R \u2192 fractional_ideal S P) :=\n\u03bb _ _ 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 \u2264 non_zero_divisors R) {I J : ideal R} :\n  (I : fractional_ideal S P) = J \u2194 I = J :=\n(coe_ideal_injective' h).eq_iff\n\n@[simp] lemma coe_ideal_eq_zero' {I : ideal R} (h : S \u2264 non_zero_divisors R) :\n  (I : fractional_ideal S P) = 0 \u2194 I = (\u22a5 : ideal R) :=\ncoe_ideal_inj' h\n\nlemma coe_ideal_ne_zero' {I : ideal R} (h : S \u2264 non_zero_divisors R) :\n  (I : fractional_ideal S P) \u2260 0 \u2194 I \u2260 (\u22a5 : 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) = \u22a5 \u2194 I = 0 :=\n\u27e8\u03bb h, coe_to_submodule_injective (by simp [h]),\n \u03bb h, by simp [h]\u27e9\n\nlemma coe_to_submodule_ne_bot {I : fractional_ideal S P} :\n  \u2191I \u2260 (\u22a5 : submodule R P) \u2194 I \u2260 0 :=\nnot_iff_not.mpr coe_to_submodule_eq_bot\n\ninstance : inhabited (fractional_ideal S P) := \u27e80\u27e9\n\ninstance : has_one (fractional_ideal S P) :=\n\u27e8(\u22a4 : ideal R)\u27e9\n\nvariables (S)\n\n@[simp, norm_cast] lemma coe_ideal_top : ((\u22a4 : ideal R) : fractional_ideal S P) = 1 := rfl\n\nlemma mem_one_iff {x : P} : x \u2208 (1 : fractional_ideal S P) \u2194 \u2203 x' : R, algebra_map R P x' = x :=\niff.intro (\u03bb \u27e8x', _, h\u27e9, \u27e8x', h\u27e9) (\u03bb \u27e8x', h\u27e9, \u27e8x', \u27e8\u27e9, h\u27e9)\n\nlemma coe_mem_one (x : R) : algebra_map R P x \u2208 (1 : fractional_ideal S P) :=\n(mem_one_iff S).mpr \u27e8x, rfl\u27e9\n\nlemma one_mem_one : (1 : P) \u2208 (1 : fractional_ideal S P) :=\n(mem_one_iff S).mpr \u27e81, ring_hom.map_one _\u27e9\n\nvariables {S}\n\n/-- `(1 : fractional_ideal S P)` is defined as the R-submodule `f(R) \u2264 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  \u2191(1 : fractional_ideal S P) = coe_submodule P (\u22a4 : ideal R) :=\nrfl\n\n@[simp, norm_cast] lemma coe_one :\n  (\u2191(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) \u2264 (J : submodule R P) \u2194 I \u2264 J :=\niff.rfl\n\nlemma zero_le (I : fractional_ideal S P) : 0 \u2264 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 : (\u22a5 : fractional_ideal S P) = 0 :=\nrfl\n\n@[simp] lemma le_zero_iff {I : fractional_ideal S P} : I \u2264 0 \u2194 I = 0 :=\nle_bot_iff\n\nlemma eq_zero_iff {I : fractional_ideal S P} : I = 0 \u2194 (\u2200 x \u2208 I, x = (0 : P)) :=\n\u27e8 (\u03bb h x hx, by simpa [h, mem_zero_iff] using hx),\n  (\u03bb h, le_bot_iff.mp (\u03bb x hx, (mem_zero_iff S).mpr (h x hx))) \u27e9\n\nlemma _root_.is_fractional.sup {I J : submodule R P} :\n  is_fractional S I \u2192 is_fractional S J \u2192 is_fractional S (I \u2294 J)\n| \u27e8aI, haI, hI\u27e9 \u27e8aJ, haJ, hJ\u27e9 := \u27e8aI * aJ, S.mul_mem haI haJ, \u03bb b hb, begin\n  rcases mem_sup.mp hb with \u27e8bI, hbI, bJ, hbJ, rfl\u27e9,\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\u27e9\n\nlemma _root_.is_fractional.inf_right {I : submodule R P} :\n  is_fractional S I \u2192 \u2200 J, is_fractional S (I \u2293 J)\n| \u27e8aI, haI, hI\u27e9 J := \u27e8aI, haI, \u03bb b hb, begin\n  rcases mem_inf.mp hb with \u27e8hbI, hbJ\u27e9,\n  exact hI b hbI\nend\u27e9\n\ninstance : has_inf (fractional_ideal S P) := \u27e8\u03bb I J, \u27e8I \u2293 J, I.is_fractional.inf_right J\u27e9\u27e9\n\n@[simp, norm_cast]\nlemma coe_inf (I J : fractional_ideal S P) : \u2191(I \u2293 J) = (I \u2293 J : submodule R P) := rfl\n\ninstance : has_sup (fractional_ideal S P) := \u27e8\u03bb I J, \u27e8I \u2294 J, I.is_fractional.sup J.is_fractional\u27e9\u27e9\n\n@[norm_cast]\nlemma coe_sup (I J : fractional_ideal S P) : \u2191(I \u2294 J) = (I \u2294 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) := \u27e8(\u2294)\u27e9\n\n@[simp]\nlemma sup_eq_add (I J : fractional_ideal S P) : I \u2294 J = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_add (I J : fractional_ideal S P) : (\u2191(I + J) : submodule R P) = I + J := rfl\n\n@[simp, norm_cast]\nlemma coe_ideal_sup (I J : ideal R) : \u2191(I \u2294 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  \u03a0 n : \u2115, is_fractional S I \u2192 is_fractional S (n \u2022 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 \u2115 (fractional_ideal S P) :=\n{ smul := \u03bb n I, \u27e8n \u2022 I, I.is_fractional.nsmul n\u27e9}\n\n@[norm_cast]\nlemma coe_nsmul (n : \u2115) (I : fractional_ideal S P) : (\u2191(n \u2022 I) : submodule R P) = n \u2022 I := rfl\n\nlemma _root_.is_fractional.mul {I J : submodule R P} :\n  is_fractional S I \u2192 is_fractional S J \u2192 is_fractional S (I * J : submodule R P)\n| \u27e8aI, haI, hI\u27e9 \u27e8aJ, haJ, hJ\u27e9 := \u27e8aI * aJ, S.mul_mem haI haJ, \u03bb b hb, begin\n  apply submodule.mul_induction_on hb,\n  { intros m hm n hn,\n    obtain \u27e8n', hn'\u27e9 := hJ n hn,\n    rw [mul_smul, mul_comm m, \u2190 smul_mul_assoc, \u2190 hn', \u2190 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\u27e9\n\nlemma _root_.is_fractional.pow {I : submodule R P} (h : is_fractional S I) :\n  \u2200 n : \u2115, 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 \u25b8 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\u27e8I * J, I.is_fractional.mul J.is_fractional\u27e9\n\n-- local attribute [semireducible] mul\n\ninstance : has_mul (fractional_ideal S P) := \u27e8\u03bb I J, mul I J\u27e9\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 = \u27e8I * J, I.is_fractional.mul J.is_fractional\u27e9 :=\nby simp only [\u2190 mul_eq_mul, mul]\n\n@[simp, norm_cast]\nlemma coe_mul (I J : fractional_ideal S P) : (\u2191(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) : (\u2191(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 (\u03bb x hx y hy, mul_mem_mul hx (h hy))\nend\n\nlemma mul_right_mono (I : fractional_ideal S P) : monotone (\u03bb J, J * I) :=\nbegin\n  intros J J' h,\n  simp only [mul_def],\n  exact mul_le.mpr (\u03bb 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 \u2208 I) (hj : j \u2208 J) :\n  i * j \u2208 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 \u2264 K \u2194 (\u2200 (i \u2208 I) (j \u2208 J), i * j \u2208 K) :=\nby { simp only [mul_def], exact submodule.mul_le }\n\ninstance : has_pow (fractional_ideal S P) \u2115 := \u27e8\u03bb I n, \u27e8I^n, I.is_fractional.pow n\u27e9\u27e9\n\n@[simp, norm_cast]\nlemma coe_pow (I : fractional_ideal S P) (n : \u2115) : \u2191(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 \u2192 Prop} {r : P} (hr : r \u2208 I * J)\n  (hm : \u2200 (i \u2208 I) (j \u2208 J), C (i * j))\n  (ha : \u2200 x y, C x \u2192 C y \u2192 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) := \u27e8nat.unary_cast\u27e9\n\nlemma coe_nat_cast (n : \u2115) : ((n : fractional_ideal S P) : submodule R P) = n :=\nshow \u2191n.unary_cast = \u2191n, 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 (\u03bb _ _, 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 \u2192+* submodule R P :=\n\u27e8coe, coe_one, coe_mul, coe_zero, coe_add\u27e9\nvariables {S P}\n\nsection order\n\nlemma add_le_add_left {I J : fractional_ideal S P} (hIJ : I \u2264 J) (J' : fractional_ideal S P) :\n  J' + I \u2264 J' + J :=\nsup_le_sup_left hIJ J'\n\nlemma mul_le_mul_left {I J : fractional_ideal S P} (hIJ : I \u2264 J) (J' : fractional_ideal S P) :\n  J' * I \u2264 J' * J :=\nmul_le.mpr (\u03bb k hk j hj, mul_mem_mul hk (hIJ hj))\n\nlemma le_self_mul_self {I : fractional_ideal S P} (hI: 1 \u2264 I) : I \u2264 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 \u2264 1) : I * I \u2264 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) \u2264 1 :=\n\u03bb x hx, let \u27e8y, _, hy\u27e9 := (mem_coe_ideal S).mp hx in (mem_one_iff S).mpr \u27e8y, hy\u27e9\n\nlemma le_one_iff_exists_coe_ideal {J : fractional_ideal S P} :\n  J \u2264 (1 : fractional_ideal S P) \u2194 \u2203 (I : ideal R), \u2191I = J :=\nbegin\n  split,\n  { intro hJ,\n    refine \u27e8\u27e8{x : R | algebra_map R P x \u2208 J}, _, _, _\u27e9, _\u27e9,\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, \u2190 algebra.smul_def],\n      exact J.val.smul_mem c hx },\n    { ext x,\n      split,\n      { rintros \u27e8y, hy, eq_y\u27e9,\n        rwa \u2190 eq_y },\n      { intro hx,\n        obtain \u27e8y, eq_x\u27e9 := (mem_one_iff S).mp (hJ hx),\n        rw \u2190 eq_x at *,\n        exact \u27e8y, hx, rfl\u27e9 } } },\n  { rintro \u27e8I, hI\u27e9,\n    rw \u2190 hI,\n    apply coe_ideal_le_one },\nend\n\n@[simp] lemma one_le {I : fractional_ideal S P} :\n  1 \u2264 I \u2194 (1 : P) \u2208 I :=\nby rw [\u2190 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 \u2192 fractional_ideal S P` as a ring hom -/\n@[simps]\ndef coe_ideal_hom : ideal R \u2192+* 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 : \u2115) : (\u2191(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] {\u03b1 : Sort*} {f : \u03b1 \u2192 ideal R}\n  (hS : S \u2264 non_zero_divisors R) :\n  ((\u220f\u1da0 a : \u03b1, f a : ideal R) : fractional_ideal S P) = \u220f\u1da0 a : \u03b1, (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 \u2192\u2090[R] P') {I : submodule R P} :\n  is_fractional S I \u2192 is_fractional S (submodule.map g.to_linear_map I)\n| \u27e8a, a_nonzero, hI\u27e9 := \u27e8a, a_nonzero, \u03bb b hb, begin\n  obtain \u27e8b', b'_mem, hb'\u27e9 := submodule.mem_map.mp hb,\n  obtain \u27e8x, hx\u27e9 := hI b' b'_mem,\n  use x,\n  erw [\u2190g.commutes, hx, g.map_smul, hb']\nend\u27e9\n\n/-- `I.map g` is the pushforward of the fractional ideal `I` along the algebra morphism `g` -/\ndef map (g : P \u2192\u2090[R] P') :\n  fractional_ideal S P \u2192 fractional_ideal S P' :=\n\u03bb I, \u27e8submodule.map g.to_linear_map I, I.is_fractional.map g\u27e9\n\n@[simp, norm_cast] lemma coe_map (g : P \u2192\u2090[R] P') (I : fractional_ideal S P) :\n  \u2191(map g I) = submodule.map g.to_linear_map I := rfl\n\n@[simp] lemma mem_map {I : fractional_ideal S P} {g : P \u2192\u2090[R] P'}\n  {y : P'} : y \u2208 I.map g \u2194 \u2203 x, x \u2208 I \u2227 g x = y :=\nsubmodule.mem_map\n\nvariables (I J : fractional_ideal S P) (g : P \u2192\u2090[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' \u2192\u2090[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 \u27e8_, \u27e8y, hy, rfl\u27e9, rfl\u27e9,\n    exact \u27e8y, hy, (g.commutes y).symm\u27e9 },\n  { rintro \u27e8y, hy, rfl\u27e9,\n    exact \u27e8_, \u27e8y, hy, rfl\u27e9, g.commutes y\u27e9 },\nend\n\n@[simp] lemma map_one :\n  (1 : fractional_ideal S P).map g = 1 :=\nmap_coe_ideal g \u22a4\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 \u2243\u2090[R] P') :\n  (I.map (g : P \u2192\u2090[R] P')).map (g.symm : P' \u2192\u2090[R] P) = I :=\nby rw [\u2190map_comp, g.symm_comp, map_id]\n\n@[simp] lemma map_symm_map (I : fractional_ideal S P') (g : P \u2243\u2090[R] P') :\n  (I.map (g.symm : P' \u2192\u2090[R] P)).map (g : P \u2192\u2090[R] P') = I :=\nby rw [\u2190map_comp, g.comp_symm, map_id]\n\nlemma map_mem_map {f : P \u2192\u2090[R] P'} (h : function.injective f) {x : P} {I : fractional_ideal S P} :\n  f x \u2208 map f I \u2194 x \u2208 I :=\nmem_map.trans \u27e8\u03bb \u27e8x', hx', x'_eq\u27e9, h x'_eq \u25b8 hx', \u03bb h, \u27e8x, h, rfl\u27e9\u27e9\n\nlemma map_injective (f : P \u2192\u2090[R] P') (h : function.injective f) :\n  function.injective (map f : fractional_ideal S P \u2192 fractional_ideal S P') :=\n\u03bb I J hIJ, ext (\u03bb x, (map_mem_map h).symm.trans (hIJ.symm \u25b8 map_mem_map h))\n\n/-- If `g` is an equivalence, `map g` is an isomorphism -/\ndef map_equiv (g : P \u2243\u2090[R] P') :\n  fractional_ideal S P \u2243+* fractional_ideal S P' :=\n{ to_fun := map g,\n  inv_fun := map g.symm,\n  map_add' := \u03bb I J, map_add I J _,\n  map_mul' := \u03bb I J, map_mul I J _,\n  left_inv := \u03bb I, by { rw [\u2190map_comp, alg_equiv.symm_comp, map_id] },\n  right_inv := \u03bb I, by { rw [\u2190map_comp, alg_equiv.comp_symm, map_id] } }\n\n@[simp] lemma coe_fun_map_equiv (g : P \u2243\u2090[R] P') :\n  (map_equiv g : fractional_ideal S P \u2192 fractional_ideal S P') = map g :=\nrfl\n\n@[simp] lemma map_equiv_apply (g : P \u2243\u2090[R] P') (I : fractional_ideal S P) :\n  map_equiv g I = map \u2191g I := rfl\n\n@[simp] lemma map_equiv_symm (g : P \u2243\u2090[R] P') :\n  ((map_equiv g).symm : fractional_ideal S P' \u2243+* _) = 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 (\u03bb x, by simp)\n\nlemma is_fractional_span_iff {s : set P} :\n  is_fractional S (span R s) \u2194 \u2203 a \u2208 S, \u2200 (b : P), b \u2208 s \u2192 is_integer R (a \u2022 b) :=\n\u27e8\u03bb \u27e8a, a_mem, h\u27e9, \u27e8a, a_mem, \u03bb b hb, h b (subset_span hb)\u27e9,\n \u03bb \u27e8a, a_mem, h\u27e9, \u27e8a, a_mem, \u03bb b hb, span_induction hb\n   h\n   (by { rw smul_zero, exact is_integer_zero })\n   (\u03bb x y hx hy, by { rw smul_add, exact is_integer_add hx hy })\n   (\u03bb s x hx, by { rw smul_comm, exact is_integer_smul hx })\u27e9\u27e9\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 \u27e8I, rfl\u27e9,\n  rcases exist_integer_multiples_of_finset S I with \u27e8\u27e8s, hs1\u27e9, hs\u27e9,\n  rw is_fractional_span_iff,\n  exact \u27e8s, hs1, hs\u27e9,\nend\n\nomit loc\n\nlemma mem_span_mul_finite_of_mem_mul {I J : fractional_ideal S P} {x : P} (hx : x \u2208 I * J) :\n  \u2203 (T T' : finset P), (T : set P) \u2286 I \u2227 (T' : set P) \u2286 J \u2227 x \u2208 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) \u2194 I.fg :=\ncoe_submodule_fg _ inj _\n\nvariables {S}\n\nlemma fg_unit (I : (fractional_ideal S P)\u02e3) :\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 \u2190 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 \u2243+* fractional_ideal S P' :=\nmap_equiv\n  { commutes' := \u03bb 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 \u2208 canonical_equiv S P P' I \u2194\n    \u2203 y \u2208 I, is_localization.map P' (ring_hom.id R)\n      (\u03bb y (hy : y \u2208 S), show ring_hom.id R y \u2208 S, from hy) (y : P) = x :=\nbegin\n  rw [canonical_equiv, map_equiv_apply, mem_map],\n  exact \u27e8\u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9, \u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9\u27e9\nend\n\n@[simp] lemma canonical_equiv_symm :\n  (canonical_equiv S P P').symm = canonical_equiv S P' P :=\nring_equiv.ext $ \u03bb I, set_like.ext_iff.mpr $ \u03bb x,\nby { rw [mem_canonical_equiv_apply, canonical_equiv, map_equiv_symm, map_equiv,\n         ring_equiv.coe_mk, mem_map],\n    exact \u27e8\u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9, \u03bb \u27e8y, mem, eq\u27e9, \u27e8y, mem, eq\u27e9\u27e9 }\n\nlemma canonical_equiv_flip (I) :\n  canonical_equiv S P P' (canonical_equiv S P' P I) = I :=\nby rw [\u2190canonical_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\u2082, 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 \u2190 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\u2070 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\u2070 K} (h : K \u2192\u2090[R] K')\n\n/-- Nonzero fractional ideals contain a nonzero integer. -/\nlemma exists_ne_zero_mem_is_integer [nontrivial R] (hI : I \u2260 0) :\n  \u2203 x \u2260 (0 : R), algebra_map R K x \u2208 I :=\nbegin\n  obtain \u27e8y, y_mem, y_not_mem\u27e9 := set_like.exists_of_lt\n    (by simpa only using bot_lt_iff_ne_bot.mpr hI),\n  have y_ne_zero : y \u2260 0 := by simpa using y_not_mem,\n  obtain \u27e8z, \u27e8x, hx\u27e9\u27e9 := exists_integer_multiple R\u2070 y,\n  refine \u27e8x, _, _\u27e9,\n  { rw [ne.def, \u2190 @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 \u2260 0) : I.map h \u2260 0 :=\nbegin\n  obtain \u27e8x, x_ne_zero, hx\u27e9 := 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 \u27e8algebra_map R K x, hx, h.commutes x\u27e9,\nend\n\n@[simp] lemma map_eq_zero_iff [nontrivial R] : I.map h = 0 \u2194 I = 0 :=\n\u27e8imp_of_not_imp_not _ _ (map_ne_zero _), \u03bb hI, hI.symm \u25b8 map_zero h\u27e9\n\nlemma coe_ideal_injective : function.injective (coe : ideal R \u2192 fractional_ideal R\u2070 K) :=\ncoe_ideal_injective' le_rfl\n\nlemma coe_ideal_inj {I J : ideal R} :\n  (I : fractional_ideal R\u2070 K) = (J : fractional_ideal R\u2070 K) \u2194 I = J :=\ncoe_ideal_inj' le_rfl\n\n@[simp] lemma coe_ideal_eq_zero {I : ideal R} : (I : fractional_ideal R\u2070 K) = 0 \u2194 I = \u22a5 :=\ncoe_ideal_eq_zero' le_rfl\n\nlemma coe_ideal_ne_zero {I : ideal R} : (I : fractional_ideal R\u2070 K) \u2260 0 \u2194 I \u2260 \u22a5 :=\ncoe_ideal_ne_zero' le_rfl\n\n@[simp] lemma coe_ideal_eq_one {I : ideal R} : (I : fractional_ideal R\u2070 K) = 1 \u2194 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\u2070 K) \u2260 1 \u2194 I \u2260 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\u2081 : Type*} [comm_ring R\u2081] {K : Type*} [field K]\nvariables [algebra R\u2081 K] [frac : is_fraction_ring R\u2081 K]\n\ninstance : nontrivial (fractional_ideal R\u2081\u2070 K) :=\n\u27e8\u27e80, 1, \u03bb h,\n  have this : (1 : K) \u2208 (0 : fractional_ideal R\u2081\u2070 K) :=\n    by { rw \u2190 (algebra_map R\u2081 K).map_one, simpa only [h] using coe_mem_one R\u2081\u2070 1 },\n  one_ne_zero ((mem_zero_iff _).mp this)\u27e9\u27e9\n\nlemma ne_zero_of_mul_eq_one (I J : fractional_ideal R\u2081\u2070 K) (h : I * J = 1) : I \u2260 0 :=\n\u03bb hI, zero_ne_one' (fractional_ideal R\u2081\u2070 K) (by { convert h, simp [hI], })\n\nvariables [is_domain R\u2081]\n\ninclude frac\n\nlemma _root_.is_fractional.div_of_nonzero {I J : submodule R\u2081 K} :\n  is_fractional R\u2081\u2070 I \u2192 is_fractional R\u2081\u2070 J \u2192 J \u2260 0 \u2192 is_fractional R\u2081\u2070 (I / J)\n| \u27e8aI, haI, hI\u27e9 \u27e8aJ, haJ, hJ\u27e9 h := begin\n  obtain \u27e8y, mem_J, not_mem_zero\u27e9 := set_like.exists_of_lt\n    (by simpa only using bot_lt_iff_ne_bot.mpr h),\n  obtain \u27e8y', hy'\u27e9 := hJ y mem_J,\n  use (aI * y'),\n  split,\n  { apply (non_zero_divisors R\u2081).mul_mem haI (mem_non_zero_divisors_iff_ne_zero.mpr _),\n    intro y'_eq_zero,\n    have : algebra_map R\u2081 K aJ * y = 0,\n    { rw [\u2190 algebra.smul_def, \u2190hy', 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\u2081 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\u2081\u2070).mpr y_zero, },\n  intros b hb,\n  convert hI _ (hb _ (submodule.smul_mem _ aJ mem_J)) using 1,\n  rw [\u2190 hy', mul_comm b, \u2190 algebra.smul_def, mul_smul]\nend\n\nlemma fractional_div_of_nonzero {I J : fractional_ideal R\u2081\u2070 K} (h : J \u2260 0) :\n  is_fractional R\u2081\u2070 (I / J : submodule R\u2081 K) :=\nI.is_fractional.div_of_nonzero J.is_fractional $ \u03bb H, h $\n  coe_to_submodule_injective $ H.trans coe_zero.symm\n\nnoncomputable instance : has_div (fractional_ideal R\u2081\u2070 K) :=\n\u27e8 \u03bb I J, if h : J = 0 then 0 else \u27e8I / J, fractional_div_of_nonzero h\u27e9 \u27e9\n\nvariables {I J : fractional_ideal R\u2081\u2070 K} [ J \u2260 0 ]\n\n@[simp] lemma div_zero {I : fractional_ideal R\u2081\u2070 K} :\n  I / 0 = 0 :=\ndif_pos rfl\n\nlemma div_nonzero {I J : fractional_ideal R\u2081\u2070 K} (h : J \u2260 0) :\n  (I / J) = \u27e8I / J, fractional_div_of_nonzero h\u27e9 :=\ndif_neg h\n\n@[simp] lemma coe_div {I J : fractional_ideal R\u2081\u2070 K} (hJ : J \u2260 0) :\n  (\u2191(I / J) : submodule R\u2081 K) = \u2191I / (\u2191J : submodule R\u2081 K) :=\ncongr_arg _ (dif_neg hJ)\n\n\n\nlemma mul_one_div_le_one {I : fractional_ideal R\u2081\u2070 K} : I * (1 / I) \u2264 1 :=\nbegin\n  by_cases hI : I = 0,\n  { rw [hI, div_zero, mul_zero],\n    exact zero_le 1 },\n  { rw [\u2190 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\u2081\u2070 K} (hI : I \u2264 (1 : fractional_ideal R\u2081\u2070 K)) :\n  I \u2264 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 [\u2190 coe_le_coe, coe_mul, coe_div hI_nz, coe_one],\n    rw [\u2190 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\u2081\u2070 K} (hJ' : J' \u2260 0) :\n  I \u2264 J / J' \u2194 \u2200 (x \u2208 I) (y \u2208 J'), x * y \u2208 J :=\n\u27e8 \u03bb h x hx, (mem_div_iff_of_nonzero hJ').mp (h hx),\n  \u03bb h x hx, (mem_div_iff_of_nonzero hJ').mpr (h x hx) \u27e9\n\nlemma le_div_iff_mul_le {I J J' : fractional_ideal R\u2081\u2070 K} (hJ' : J' \u2260 0) :\n  I \u2264 J / J' \u2194 I * J' \u2264 J :=\nbegin\n  rw div_nonzero hJ',\n  convert submodule.le_div_iff_mul_le using 1,\n  rw [\u2190 coe_mul, coe_le_coe]\nend\n\n@[simp] lemma div_one {I : fractional_ideal R\u2081\u2070 K} : I / 1 = I :=\nbegin\n  rw [div_nonzero (one_ne_zero' (fractional_ideal R\u2081\u2070 K))],\n  ext,\n  split; intro h,\n  { simpa using mem_div_iff_forall_mul_mem.mp h 1\n      ((algebra_map R\u2081 K).map_one \u25b8 coe_mem_one R\u2081\u2070 1) },\n  { apply mem_div_iff_forall_mul_mem.mpr,\n    rintros y \u27e8y', _, rfl\u27e9,\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\u2081\u2070 K) (h : I * J = 1) :\n  J = 1 / I :=\nbegin\n  have hI : I \u2260 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 \u2190 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\u2081\u2070 K} :\n  I * (1 / I) = 1 \u2194 \u2203 J, I * J = 1 :=\n\u27e8\u03bb h, \u27e8(1 / I), h\u27e9, \u03bb \u27e8J, hJ\u27e9, by rwa [\u2190 eq_one_div_of_mul_eq_one_right I J hJ]\u27e9\n\nvariables {K' : Type*} [field K'] [algebra R\u2081 K'] [is_fraction_ring R\u2081 K']\n\n@[simp] lemma map_div (I J : fractional_ideal R\u2081\u2070 K) (h : K \u2243\u2090[R\u2081] K') :\n  (I / J).map (h : K \u2192\u2090[R\u2081] 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\u2081\u2070 K) (h : K \u2243\u2090[R\u2081] K') :\n  (1 / I).map (h : K \u2192\u2090[R\u2081] K') = 1 / I.map h :=\nby rw [map_div, map_one]\n\nend quotient\n\nsection field\n\nvariables {R\u2081 K L : Type*} [comm_ring R\u2081] [field K] [field L]\nvariables [algebra R\u2081 K] [is_fraction_ring R\u2081 K] [algebra K L] [is_fraction_ring K L]\n\nlemma eq_zero_or_one (I : fractional_ideal K\u2070 L) : I = 0 \u2228 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 \u27e8n, d, rfl\u27e9 := is_localization.mk'_surjective K\u2070 x,\n    refine \u27e8n / d, _\u27e9,\n    rw [map_div\u2080, is_fraction_ring.mk'_eq_div] },\n  { rintro \u27e8x, rfl\u27e9,\n    obtain \u27e8y, y_ne, y_mem\u27e9 := exists_ne_zero_mem_is_integer hI,\n    rw [\u2190 div_mul_cancel x y_ne, ring_hom.map_mul, \u2190 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\u2081) (I : fractional_ideal R\u2081\u2070 K) : I = 0 \u2228 I = 1 :=\nby letI : field R\u2081 := hF.to_field; exact eq_zero_or_one I\n\nend field\n\nsection principal_ideal_ring\n\nvariables {R\u2081 : Type*} [comm_ring R\u2081] {K : Type*} [field K]\nvariables [algebra R\u2081 K] [is_fraction_ring R\u2081 K]\n\nopen_locale classical\n\nvariables (R\u2081)\n\n/-- `fractional_ideal.span_finset R\u2081 s f` is the fractional ideal of `R\u2081` generated by `f '' s`. -/\n@[simps] def span_finset {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 K) : fractional_ideal R\u2081\u2070 K :=\n\u27e8submodule.span R\u2081 (f '' s), begin\n  obtain \u27e8a', ha'\u27e9 := is_localization.exist_integer_multiples R\u2081\u2070 s f,\n  refine \u27e8a', a'.2, \u03bb x hx, submodule.span_induction hx _ _ _ _\u27e9,\n  { rintro _ \u27e8i, hi, rfl\u27e9, 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\u27e9\n\nvariables {R\u2081}\n\n@[simp] lemma span_finset_eq_zero {\u03b9 : Type*} {s : finset \u03b9} {f : \u03b9 \u2192 K} :\n  span_finset R\u2081 s f = 0 \u2194 \u2200 j \u2208 s, f j = 0 :=\nby simp only [\u2190 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\u2082]\n\nlemma span_finset_ne_zero {\u03b9 : Type*} {s : finset \u03b9} {f : \u03b9 \u2192 K} :\n  span_finset R\u2081 s f \u2260 0 \u2194 \u2203 j \u2208 s, f j \u2260 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 \u27e8a, ha\u27e9 := exists_integer_multiple S x in\nis_fractional_span_iff.mpr \u27e8a, a.2, \u03bb x' hx', (set.mem_singleton_iff.mp hx').symm \u25b8 ha\u27e9\n\nvariables (S)\n\n/-- `span_singleton x` is the fractional ideal generated by `x` if `0 \u2209 S` -/\n@[irreducible]\ndef span_singleton (x : P) : fractional_ideal S P :=\n\u27e8span R {x}, is_fractional_span_singleton x\u27e9\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 \u2208 span_singleton S y \u2194 \u2203 (z : R), z \u2022 y = x :=\nby { rw span_singleton, exact submodule.mem_span_singleton }\n\nlemma mem_span_singleton_self (x : P) :\n  x \u2208 span_singleton S x :=\n(mem_span_singleton S).mpr \u27e81, one_smul _ _\u27e9\n\nvariables {S}\n\n@[simp] lemma span_singleton_le_iff_mem {x : P} {I : fractional_ideal S P} :\n  span_singleton S x \u2264 I \u2194 x \u2208 I :=\nby rw [\u2190 coe_le_coe, coe_span_singleton, submodule.span_singleton_le_iff_mem x \u2191I, 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 \u2194 \u2203 z : R\u02e3, z \u2022 x = y :=\nby { rw [\u2190 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 \u2191I).symm }\n\nlemma is_principal_iff (I : fractional_ideal S P) :\n  is_principal (I : submodule R P) \u2194 \u2203 x, I = span_singleton S x :=\n\u27e8\u03bb h, \u27e8@generator _ _ _ _ _ \u2191I h, @eq_span_singleton_of_principal _ _ _ _ _ _ _ I h\u27e9,\n \u03bb \u27e8x, hx\u27e9, { principal := \u27e8x, trans (congr_arg _ hx) (coe_span_singleton _ x)\u27e9 } \u27e9\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 \u2194 y = 0 :=\n\u27e8\u03bb h, span_eq_bot.mp (by simpa using congr_arg subtype.val h : span R {y} = \u22a5) y (mem_singleton y),\n \u03bb h, by simp [h] \u27e9\n\nlemma span_singleton_ne_zero_iff {y : P} : span_singleton S y \u2260 0 \u2194 y \u2260 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 : \u2115) : 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  (\u2191(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 \u27e8y', hy', rfl\u27e9,\n    obtain \u27e8x', rfl\u27e9 := submodule.mem_span_singleton.mp hy',\n    use x',\n    rw [smul_eq_mul, ring_hom.map_mul, algebra.smul_def] },\n  { rintros \u27e8y', rfl\u27e9,\n    refine \u27e8y' * x, submodule.mem_span_singleton.mpr \u27e8y', rfl\u27e9, _\u27e9,\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      (\u03bb y (hy : y \u2208 S), show ring_hom.id R y \u2208 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 \u27e8x', hx', rfl\u27e9 := (mem_canonical_equiv_apply _ _ _).mp h,\n    obtain \u27e8z, rfl\u27e9 := (mem_span_singleton _).mp hx',\n    use z,\n    rw is_localization.map_smul,\n    refl },\n  { rw mem_canonical_equiv_apply,\n    obtain \u27e8z, rfl\u27e9 := (mem_span_singleton _).mp h,\n    use z \u2022 x,\n    use (mem_span_singleton _).mpr \u27e8z, rfl\u27e9,\n    simp [is_localization.map_smul] }\nend\n\nlemma mem_singleton_mul {x y : P} {I : fractional_ideal S P} :\n  y \u2208 span_singleton S x * I \u2194 \u2203 y' \u2208 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 \u27e8a, ha\u27e9 := (mem_span_singleton S).mp hx',\n      use [a \u2022 y', submodule.smul_mem I a hy'],\n      rw [\u2190ha, algebra.mul_smul_comm, algebra.smul_mul_assoc] },\n    { rintros _ _ \u27e8y, hy, rfl\u27e9 \u27e8y', hy', rfl\u27e9,\n      exact \u27e8y + y', submodule.add_mem I hy hy', (mul_add _ _ _).symm\u27e9 } },\n  { rintros \u27e8y', hy', rfl\u27e9,\n    exact mul_mem_mul ((mem_span_singleton S).mpr \u27e81, one_smul _ _\u27e9) hy' }\nend\n\nomit loc\n\nvariables (K)\n\nlemma mk'_mul_coe_ideal_eq_coe_ideal {I J : ideal R\u2081} {x y : R\u2081} (hy : y \u2208 R\u2081\u2070) :\n  span_singleton R\u2081\u2070 (is_localization.mk' K x \u27e8y, hy\u27e9) * I = (J : fractional_ideal R\u2081\u2070 K) \u2194\n  ideal.span {x} * I = ideal.span {y} * J :=\nbegin\n  have : span_singleton R\u2081\u2070 (is_localization.mk' _ (1 : R\u2081) \u27e8y, hy\u27e9) *\n           span_singleton R\u2081\u2070 (algebra_map R\u2081 K y) = 1,\n  { rw [span_singleton_mul_span_singleton, mul_comm, \u2190 is_localization.mk'_eq_mul_mk'_one,\n        is_localization.mk'_self, span_singleton_one] },\n  let y' : (fractional_ideal R\u2081\u2070 K)\u02e3 := units.mk_of_mul_eq_one _ _ this,\n  have coe_y' : \u2191y' = span_singleton R\u2081\u2070 (is_localization.mk' K (1 : R\u2081) \u27e8y, hy\u27e9) := 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    \u2190mul_assoc, span_singleton_mul_span_singleton, \u2190mul_assoc, span_singleton_mul_span_singleton,\n    mul_comm (mk' _ _ _), \u2190 is_localization.mk'_eq_mul_mk'_one,\n    mul_comm (mk' _ _ _), \u2190 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\u2081} {z : K} :\n  span_singleton R\u2081\u2070 z * (I : fractional_ideal R\u2081\u2070 K) = J \u2194\n  ideal.span {((is_localization.sec R\u2081\u2070 z).1 : R\u2081)} * I =\n    ideal.span {(is_localization.sec R\u2081\u2070 z).2} * J :=\n-- `erw` to deal with the distinction between `y` and `\u27e8y.1, y.2\u27e9`\nby erw [\u2190 mk'_mul_coe_ideal_eq_coe_ideal K (is_localization.sec R\u2081\u2070 z).2.prop,\n        is_localization.mk'_sec K z]\n\nvariables [is_domain R\u2081]\n\nlemma one_div_span_singleton (x : K) :\n  1 / span_singleton R\u2081\u2070 x = span_singleton R\u2081\u2070 (x\u207b\u00b9) :=\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\u2081\u2070 K) (d : K) :\n  J / span_singleton R\u2081\u2070 d = span_singleton R\u2081\u2070 (d\u207b\u00b9) * J :=\nbegin\n  rw \u2190 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\u2081\u2070 d \u2260 0 := mt span_singleton_eq_zero_iff.mp hd,\n  apply le_antisymm,\n  { intros x hx,\n    rw [\u2190 mem_coe, coe_div h_spand, submodule.mem_div_iff_forall_mul_mem] at hx,\n    specialize hx d (mem_span_singleton_self R\u2081\u2070 d),\n    have h_xd : x = d\u207b\u00b9 * (x * d), { field_simp },\n    rw [\u2190 mem_coe, coe_mul, one_div_span_singleton, h_xd],\n    exact submodule.mul_mem_mul (mem_span_singleton_self R\u2081\u2070 _) 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\u2081\u2070 K) :\n  \u2203 (a : R\u2081) (aI : ideal R\u2081), a \u2260 0 \u2227 I = span_singleton R\u2081\u2070 (algebra_map R\u2081 K a)\u207b\u00b9 * aI :=\nbegin\n  obtain \u27e8a_inv, nonzero, ha\u27e9 := I.is_fractional,\n  have nonzero := mem_non_zero_divisors_iff_ne_zero.mp nonzero,\n  have map_a_nonzero : algebra_map R\u2081 K a_inv \u2260 0 :=\n    mt is_fraction_ring.to_map_eq_zero_iff.mp nonzero,\n  refine \u27e8a_inv,\n          submodule.comap (algebra.linear_map R\u2081 K)\n            \u2191(span_singleton R\u2081\u2070 (algebra_map R\u2081 K a_inv) * I),\n          nonzero,\n          ext (\u03bb x, iff.trans \u27e8_, _\u27e9 mem_singleton_mul.symm)\u27e9,\n  { intro hx,\n    obtain \u27e8x', hx'\u27e9 := ha x hx,\n    rw algebra.smul_def at hx',\n    refine \u27e8algebra_map R\u2081 K x', (mem_coe_ideal _).mpr \u27e8x', mem_singleton_mul.mpr _, rfl\u27e9, _\u27e9,\n    { exact \u27e8x, hx, hx'\u27e9 },\n    { rw [hx', \u2190 mul_assoc, inv_mul_cancel map_a_nonzero, one_mul] } },\n  { rintros \u27e8y, hy, rfl\u27e9,\n    obtain \u27e8x', hx', rfl\u27e9 := (mem_coe_ideal _).mp hy,\n    obtain \u27e8y', hy', hx'\u27e9 := mem_singleton_mul.mp hx',\n    rw algebra.linear_map_apply at hx',\n    rwa [hx', \u2190mul_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\u2070 K) : (I : submodule R K).is_principal :=\nbegin\n  obtain \u27e8a, aI, -, ha\u27e9 := exists_eq_span_singleton_mul I,\n  use (algebra_map R K a)\u207b\u00b9 * algebra_map R K (generator aI),\n  suffices : I = span_singleton R\u2070 ((algebra_map R K a)\u207b\u00b9 * algebra_map R K (generator aI)),\n  { rw span_singleton at this, exact congr_arg subtype.val this },\n  conv_lhs { rw [ha, \u2190span_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 \u2264 span_singleton S x * J \u2194 \u2200 zI \u2208 I, \u2203 zJ \u2208 J, x * zJ = zI :=\nshow (\u2200 {zI} (hzI : zI \u2208 I), zI \u2208 span_singleton _ x * J) \u2194 \u2200 zI \u2208 I, \u2203 zJ \u2208 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 \u2264 J \u2194 \u2200 z \u2208 I, x * z \u2208 J :=\nbegin\n  simp only [mul_le, mem_singleton_mul, mem_span_singleton],\n  split,\n  { intros h zI hzI,\n    exact h x \u27e81, one_smul _ _\u27e9 zI hzI },\n  { rintros h _ \u27e8z, rfl\u27e9 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 \u2194 (\u2200 zI \u2208 I, \u2203 zJ \u2208 J, x * zJ = zI) \u2227 \u2200 z \u2208 J, x * z \u2208 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\u2081 : Type*} [comm_ring R\u2081]\nvariables {K : Type*} [field K] [algebra R\u2081 K] [frac : is_fraction_ring R\u2081 K]\n\nlocal attribute [instance] classical.prop_decidable\n\nlemma is_noetherian_zero : is_noetherian R\u2081 (0 : fractional_ideal R\u2081\u2070 K) :=\nis_noetherian_submodule.mpr (\u03bb I (hI : I \u2264 (0 : fractional_ideal R\u2081\u2070 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\u2081\u2070 K} :\n  is_noetherian R\u2081 I \u2194 \u2200 J \u2264 I, (J : submodule R\u2081 K).fg :=\nis_noetherian_submodule.trans \u27e8\u03bb h J hJ, h _ hJ, \u03bb h J hJ, h \u27e8J, is_fractional_of_le hJ\u27e9 hJ\u27e9\n\nlemma is_noetherian_coe_ideal [_root_.is_noetherian_ring R\u2081] (I : ideal R\u2081) :\n  is_noetherian R\u2081 (I : fractional_ideal R\u2081\u2070 K) :=\nbegin\n  rw is_noetherian_iff,\n  intros J hJ,\n  obtain \u27e8J, rfl\u27e9 := 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\u2081]\n\nlemma is_noetherian_span_singleton_inv_to_map_mul (x : R\u2081) {I : fractional_ideal R\u2081\u2070 K}\n  (hI : is_noetherian R\u2081 I) :\n  is_noetherian R\u2081 (span_singleton R\u2081\u2070 (algebra_map R\u2081 K x)\u207b\u00b9 * I : fractional_ideal R\u2081\u2070 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\u2081 K x \u2260 0,\n  from mt ((injective_iff_map_eq_zero (algebra_map R\u2081 K)).mp\n    (is_fraction_ring.injective _ _) x) hx,\n  have h_spanx : span_singleton R\u2081\u2070 (algebra_map R\u2081 K x) \u2260 0,\n    from span_singleton_ne_zero_iff.mpr h_gx,\n\n  rw is_noetherian_iff at \u22a2 hI,\n  intros J hJ,\n  rw [\u2190 div_span_singleton, le_div_iff_mul_le h_spanx] at hJ,\n  obtain \u27e8s, hs\u27e9 := hI _ hJ,\n  use s * {(algebra_map R\u2081 K x)\u207b\u00b9},\n  rw [finset.coe_mul, finset.coe_singleton, \u2190 span_mul_span, hs, \u2190 coe_span_singleton R\u2081\u2070,\n      \u2190 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\u2081] (I : fractional_ideal R\u2081\u2070 K) :\n  is_noetherian R\u2081 I :=\nbegin\n  obtain \u27e8d, J, h_nzd, rfl\u27e9 := 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\u27e8_, is_fractional_adjoin_integral S x hx\u27e9\n\nlemma mem_adjoin_integral_self :\n  x \u2208 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 \u2964 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 \u2192 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 \u2192 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\u2093'. -/\n/-- Morphisms for `with_terminal C`. -/\n@[simp, nolint has_nonempty_instance]\ndef Hom : WithTerminal C \u2192 WithTerminal C \u2192 Type v\n  | of X, of Y => X \u27f6 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\u2093'. -/\n/-- Identity morphisms for `with_terminal C`. -/\n@[simp]\ndef id : \u2200 X : WithTerminal C, Hom X X\n  | of X => \ud835\udfd9 _\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\u2093'. -/\n/-- Composition of morphisms for `with_terminal C`. -/\n@[simp]\ndef comp : \u2200 {X Y Z : WithTerminal C}, Hom X Y \u2192 Hom Y Z \u2192 Hom X Z\n  | of X, of Y, of Z => fun f g => f \u226b 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 \u2964 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 \u2964 _) where preimage X Y f := f\n\ninstance : Faithful (incl : C \u2964 _) where\n\n/-- Map `with_terminal` with respect to a functor `F : C \u2964 D`. -/\ndef map {D : Type _} [Category D] (F : C \u2964 D) : WithTerminal C \u2964 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 \u27f6 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 \u2964 D` to `with_term C \u2964 D`. -/\n@[simps]\ndef lift {D : Type _} [Category D] {Z : D} (F : C \u2964 D) (M : \u2200 x : C, F.obj x \u27f6 Z)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), F.map f \u226b M y = M x) : WithTerminal C \u2964 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 => \ud835\udfd9 Z\n#align category_theory.with_terminal.lift CategoryTheory.WithTerminal.lift\n\n/-- The isomorphism between `incl \u22d9 lift F _ _` with `F`. -/\n@[simps]\ndef inclLift {D : Type _} [Category D] {Z : D} (F : C \u2964 D) (M : \u2200 x : C, F.obj x \u27f6 Z)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), F.map f \u226b M y = M x) : incl \u22d9 lift F M hM \u2245 F\n    where\n  Hom := { app := fun X => \ud835\udfd9 _ }\n  inv := { app := fun X => \ud835\udfd9 _ }\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 \u2964 D) (M : \u2200 x : C, F.obj x \u27f6 Z)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), F.map f \u226b M y = M x) : (lift F M hM).obj star \u2245 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 \u2964 D) (M : \u2200 x : C, F.obj x \u27f6 Z)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), F.map f \u226b M y = M x) (x : C) :\n    (lift F M hM).map (starTerminal.from (incl.obj x)) \u226b (liftStar F M hM).Hom =\n      (inclLift F M hM).Hom.app x \u226b 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 \u2964 D) (M : \u2200 x : C, F.obj x \u27f6 Z)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), F.map f \u226b M y = M x) (G : WithTerminal C \u2964 D) (h : incl \u22d9 G \u2245 F)\n    (hG : G.obj star \u2245 Z)\n    (hh : \u2200 x : C, G.map (starTerminal.from (incl.obj x)) \u226b hG.Hom = h.Hom.app x \u226b M x) :\n    G \u2245 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      \u00b7 apply h.hom.naturality\n      \u00b7 cases f\n        exact hh _\n      \u00b7 cases f\n      \u00b7 cases f\n        change G.map (\ud835\udfd9 _) \u226b hG.hom = hG.hom \u226b \ud835\udfd9 _\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 \u2964 D) (hZ : Limits.IsTerminal Z) :\n    WithTerminal C \u2964 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 \u2964 D) (hZ : Limits.IsTerminal Z) :\n    incl \u22d9 liftToTerminal F hZ \u2245 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 \u2964 D) (hZ : Limits.IsTerminal Z)\n    (G : WithTerminal C \u2964 D) (h : incl \u22d9 G \u2245 F) (hG : G.obj star \u2245 Z) : G \u2245 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 \u27f6 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 \u27f6 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\u2093'. -/\n/-- Morphisms for `with_initial C`. -/\n@[simp, nolint has_nonempty_instance]\ndef Hom : WithInitial C \u2192 WithInitial C \u2192 Type v\n  | of X, of Y => X \u27f6 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\u2093'. -/\n/-- Identity morphisms for `with_initial C`. -/\n@[simp]\ndef id : \u2200 X : WithInitial C, Hom X X\n  | of X => \ud835\udfd9 _\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\u2093'. -/\n/-- Composition of morphisms for `with_initial C`. -/\n@[simp]\ndef comp : \u2200 {X Y Z : WithInitial C}, Hom X Y \u2192 Hom Y Z \u2192 Hom X Z\n  | of X, of Y, of Z => fun f g => f \u226b 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 \u2964 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 \u2964 _) where preimage X Y f := f\n\ninstance : Faithful (incl : C \u2964 _) where\n\n/-- Map `with_initial` with respect to a functor `F : C \u2964 D`. -/\ndef map {D : Type _} [Category D] (F : C \u2964 D) : WithInitial C \u2964 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 \u27f6 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 \u2964 D` to `with_initial C \u2964 D`. -/\n@[simps]\ndef lift {D : Type _} [Category D] {Z : D} (F : C \u2964 D) (M : \u2200 x : C, Z \u27f6 F.obj x)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), M x \u226b F.map f = M y) : WithInitial C \u2964 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 => \ud835\udfd9 _\n#align category_theory.with_initial.lift CategoryTheory.WithInitial.lift\n\n/-- The isomorphism between `incl \u22d9 lift F _ _` with `F`. -/\n@[simps]\ndef inclLift {D : Type _} [Category D] {Z : D} (F : C \u2964 D) (M : \u2200 x : C, Z \u27f6 F.obj x)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), M x \u226b F.map f = M y) : incl \u22d9 lift F M hM \u2245 F\n    where\n  Hom := { app := fun X => \ud835\udfd9 _ }\n  inv := { app := fun X => \ud835\udfd9 _ }\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 \u2964 D) (M : \u2200 x : C, Z \u27f6 F.obj x)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), M x \u226b F.map f = M y) : (lift F M hM).obj star \u2245 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 \u2964 D) (M : \u2200 x : C, Z \u27f6 F.obj x)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), M x \u226b F.map f = M y) (x : C) :\n    (liftStar F M hM).Hom \u226b (lift F M hM).map (starInitial.to (incl.obj x)) =\n      M x \u226b (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 \u2964 D) (M : \u2200 x : C, Z \u27f6 F.obj x)\n    (hM : \u2200 (x y : C) (f : x \u27f6 y), M x \u226b F.map f = M y) (G : WithInitial C \u2964 D) (h : incl \u22d9 G \u2245 F)\n    (hG : G.obj star \u2245 Z)\n    (hh : \u2200 x : C, hG.symm.Hom \u226b G.map (starInitial.to (incl.obj x)) = M x \u226b h.symm.Hom.app x) :\n    G \u2245 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      \u00b7 apply h.hom.naturality\n      \u00b7 cases f\n      \u00b7 cases f\n        change G.map _ \u226b h.hom.app _ = hG.hom \u226b _\n        symm\n        erw [\u2190 iso.eq_inv_comp, \u2190 category.assoc, hh]\n        simpa\n      \u00b7 cases f\n        change G.map (\ud835\udfd9 _) \u226b hG.hom = hG.hom \u226b \ud835\udfd9 _\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 \u2964 D) (hZ : Limits.IsInitial Z) :\n    WithInitial C \u2964 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 \u2964 D) (hZ : Limits.IsInitial Z) :\n    incl \u22d9 liftToInitial F hZ \u2245 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 \u2964 D) (hZ : Limits.IsInitial Z)\n    (G : WithInitial C \u2964 D) (h : incl \u22d9 G \u2245 F) (hG : G.obj star \u2245 Z) : G \u2245 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 \u27f6 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 \u27f6 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 \u03b1`, the partial values of a type.\n\n`o : part \u03b1` carries a proposition `o.dom`, its domain, along with a function `get : o.dom \u2192 \u03b1`, 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 \u03b1` behaves the same as `option \u03b1` except that `o : option \u03b1` is decidably `none` or `some a`\nfor some `a : \u03b1`, while the domain of `o : part \u03b1` 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 \u03b1` and `part \u03b1` are classically equivalent. In general, `part \u03b1` is bigger than `option \u03b1`.\n\nIn current mathlib, `part \u2115`, 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 `\u221e` 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 \u03b1` to a `part \u03b1` by sending `none` to `none` and `some a` to\n  `some a`.\n* `part.to_option`: Converts a `part \u03b1` with a decidable domain to an `option \u03b1`.\n* `part.equiv_option`: Classical equivalence between `part \u03b1` and `option \u03b1`.\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 \u03b1` by `p : Prop` so long as\n  `p \u2192 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 : \u03b1`, `o : part \u03b1`, `a \u2208 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 \u03b1` is the type of \"partial values\" of type `\u03b1`. It\n  is similar to `option \u03b1` except the domain condition can be an\n  arbitrary proposition, not necessarily decidable. -/\nstructure Part.{u} (\u03b1 : Type u) : Type u where\n  Dom : Prop\n  get : dom \u2192 \u03b1\n#align part Part\n-/\n\nnamespace Part\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _}\n\n#print Part.toOption /-\n/-- Convert a `part \u03b1` with a decidable domain to an option -/\ndef toOption (o : Part \u03b1) [Decidable o.Dom] : Option \u03b1 :=\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 \u03b1) [Decidable o.Dom] : o.toOption.isSome \u2194 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 \u03b1) [Decidable o.Dom] : o.toOption.isNone \u2194 \u00aco.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' : \u2200 {o p : Part \u03b1} (H1 : o.Dom \u2194 p.Dom) (H2 : \u2200 h\u2081 h\u2082, o.get h\u2081 = p.get h\u2082), o = p\n  | \u27e8od, o\u27e9, \u27e8pd, p\u27e9, 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 : \u2200 o : Part \u03b1, (\u27e8o.Dom, fun h => o.get h\u27e9 : Part \u03b1) = o\n  | \u27e8h, f\u27e9 => rfl\n#align part.eta Part.eta\n-/\n\n#print Part.Mem /-\n/-- `a \u2208 o` means that `o` is defined and equal to `a` -/\nprotected def Mem (a : \u03b1) (o : Part \u03b1) : Prop :=\n  \u2203 h, o.get h = a\n#align part.mem Part.Mem\n-/\n\ninstance : Membership \u03b1 (Part \u03b1) :=\n  \u27e8Part.Mem\u27e9\n\n#print Part.mem_eq /-\ntheorem mem_eq (a : \u03b1) (o : Part \u03b1) : (a \u2208 o) = \u2203 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 : \u2200 {o : Part \u03b1}, o.Dom \u2194 \u2203 y, y \u2208 o\n  | \u27e8p, f\u27e9 => \u27e8fun h => \u27e8f h, h, rfl\u27e9, fun \u27e8_, h, rfl\u27e9 => h\u27e9\n#align part.dom_iff_mem Part.dom_iff_mem\n-/\n\n#print Part.get_mem /-\ntheorem get_mem {o : Part \u03b1} (h) : get o h \u2208 o :=\n  \u27e8_, rfl\u27e9\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 \u2192 \u03b1} {a : \u03b1} : a \u2208 Part.mk p o \u2194 \u2203 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 \u03b1} (H : \u2200 a, a \u2208 o \u2194 a \u2208 p) : o = p :=\n  ext' \u27e8fun h => ((H _).1 \u27e8h, rfl\u27e9).fst, fun h => ((H _).2 \u27e8h, rfl\u27e9).fst\u27e9 fun a b =>\n    ((H _).2 \u27e8_, rfl\u27e9).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 \u03b1 :=\n  \u27e8False, False.ndrec _\u27e9\n#align part.none Part.none\n-/\n\ninstance : Inhabited (Part \u03b1) :=\n  \u27e8none\u27e9\n\n#print Part.not_mem_none /-\n@[simp]\ntheorem not_mem_none (a : \u03b1) : a \u2209 @none \u03b1 := 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 : \u03b1) : Part \u03b1 :=\n  \u27e8True, fun _ => a\u27e9\n#align part.some Part.some\n-/\n\n#print Part.some_dom /-\n@[simp]\ntheorem some_dom (a : \u03b1) : (some a).Dom :=\n  trivial\n#align part.some_dom Part.some_dom\n-/\n\n#print Part.mem_unique /-\ntheorem mem_unique : \u2200 {a b : \u03b1} {o : Part \u03b1}, a \u2208 o \u2192 b \u2208 o \u2192 a = b\n  | _, _, \u27e8p, f\u27e9, \u27e8h\u2081, rfl\u27e9, \u27e8h\u2082, rfl\u27e9 => rfl\n#align part.mem_unique Part.mem_unique\n-/\n\n#print Part.Mem.left_unique /-\ntheorem Mem.left_unique : Relator.LeftUnique ((\u00b7 \u2208 \u00b7) : \u03b1 \u2192 Part \u03b1 \u2192 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 \u03b1} {a} (h : a \u2208 o) (h') : get o h' = a :=\n  mem_unique \u27e8_, rfl\u27e9 h\n#align part.get_eq_of_mem Part.get_eq_of_mem\n-/\n\n#print Part.subsingleton /-\nprotected theorem subsingleton (o : Part \u03b1) : Set.Subsingleton { a | a \u2208 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 : \u03b1} (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 : \u03b1) : a \u2208 some a :=\n  \u27e8trivial, rfl\u27e9\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 \u2208 (some a : Part \u03b1) \u2194 b = a :=\n  \u27e8fun \u27e8h, e\u27e9 => e.symm, fun e => \u27e8trivial, e.symm\u27e9\u27e9\n#align part.mem_some_iff Part.mem_some_iff\n-/\n\n#print Part.eq_some_iff /-\ntheorem eq_some_iff {a : \u03b1} {o : Part \u03b1} : o = some a \u2194 a \u2208 o :=\n  \u27e8fun e => e.symm \u25b8 mem_some _, fun \u27e8h, e\u27e9 => e \u25b8 ext' (iff_true_intro h) fun _ _ => rfl\u27e9\n#align part.eq_some_iff Part.eq_some_iff\n-/\n\n#print Part.eq_none_iff /-\ntheorem eq_none_iff {o : Part \u03b1} : o = none \u2194 \u2200 a, a \u2209 o :=\n  \u27e8fun e => e.symm \u25b8 not_mem_none, fun h => ext (by simpa)\u27e9\n#align part.eq_none_iff Part.eq_none_iff\n-/\n\n#print Part.eq_none_iff' /-\ntheorem eq_none_iff' {o : Part \u03b1} : o = none \u2194 \u00aco.Dom :=\n  \u27e8fun e => e.symm \u25b8 id, fun h => eq_none_iff.2 fun a h' => h h'.fst\u27e9\n#align part.eq_none_iff' Part.eq_none_iff'\n-/\n\n#print Part.not_none_dom /-\n@[simp]\ntheorem not_none_dom : \u00ac(none : Part \u03b1).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 : \u03b1) : some x \u2260 none :=\n  by\n  intro h\n  change none.dom\n  rw [\u2190 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 : \u03b1) : none \u2260 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 \u03b1} : o \u2260 none \u2194 \u2203 x, o = some x :=\n  by\n  constructor\n  \u00b7 rw [Ne, eq_none_iff', Classical.not_not]\n    exact fun h => \u27e8o.get h, eq_some_iff.2 (get_mem h)\u27e9\n  \u00b7 rintro \u27e8x, rfl\u27e9\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 \u03b1) : o = none \u2228 \u2203 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 \u03b1) := 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 : \u03b1} : Part.some a = some b \u2194 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 \u03b1} (ha : a.Dom) : Part.some (Part.get a ha) = a :=\n  Eq.symm (eq_some_iff.2 \u27e8ha, rfl\u27e9)\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 \u03b1} {ha : a.Dom} {b : \u03b1} : a.get ha = b \u2194 a = some b :=\n  \u27e8fun h => by simp [h.symm], fun h => by simp [h]\u27e9\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 \u03b1) (ha : a.Dom) {b : Part \u03b1} (h : a = b) :\n    a.get ha = b.get (h \u25b8 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 \u03b1} {a : \u03b1} (h : o.Dom) : o.get h = a \u2194 a \u2208 o :=\n  \u27e8fun H => \u27e8h, H\u27e9, fun \u27e8h', H\u27e9 => H\u27e9\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 \u03b1} {a : \u03b1} (h : o.Dom) : a = o.get h \u2194 a \u2208 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 \u03b1).Dom] : (none : Part \u03b1).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 : \u03b1) [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 \u03b1).Dom :=\n  Decidable.false\n#align part.none_decidable Part.noneDecidable\n-/\n\n#print Part.someDecidable /-\ninstance someDecidable (a : \u03b1) : 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 \u03b1` if it exists, and return the provided default value\notherwise. -/\ndef getOrElse (a : Part \u03b1) [Decidable a.Dom] (d : \u03b1) :=\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 \u03b1) (h : a.Dom) [Decidable a.Dom] (d : \u03b1) :\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 \u03b1) (h : \u00aca.Dom) [Decidable a.Dom] (d : \u03b1) :\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 : \u03b1) [Decidable (none : Part \u03b1).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 : \u03b1) (d : \u03b1) [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 \u03b1} [Decidable o.Dom] {a : \u03b1} : a \u2208 toOption o \u2194 a \u2208 o :=\n  by\n  unfold to_option\n  by_cases h : o.dom <;> simp [h]\n  \u00b7 exact \u27e8fun h => \u27e8_, h\u27e9, fun \u27e8_, h\u27e9 => h\u27e9\n  \u00b7 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 \u03b1} [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 \u03b1} [Decidable a.Dom] : a.toOption = Option.none \u2194 \u00aca.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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (a : Part.{u1} \u03b1) [_inst_1 : Decidable (Part.Dom.{u1} \u03b1 a)] (b : \u03b2) (f : \u03b1 -> \u03b2), Eq.{succ u2} \u03b2 (Option.elim'.{u1, u2} \u03b1 \u03b2 b f (Part.toOption.{u1} \u03b1 a _inst_1)) (dite.{succ u2} \u03b2 (Part.Dom.{u1} \u03b1 a) _inst_1 (fun (h : Part.Dom.{u1} \u03b1 a) => f (Part.get.{u1} \u03b1 a h)) (fun (h : Not (Part.Dom.{u1} \u03b1 a)) => b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (a : Part.{u2} \u03b1) [_inst_1 : Decidable (Part.Dom.{u2} \u03b1 a)] (b : \u03b2) (f : \u03b1 -> \u03b2), Eq.{succ u1} \u03b2 (Option.elim.{u2, succ u1} \u03b1 \u03b2 (Part.toOption.{u2} \u03b1 a _inst_1) b f) (dite.{succ u1} \u03b2 (Part.Dom.{u2} \u03b1 a) _inst_1 (fun (h : Part.Dom.{u2} \u03b1 a) => f (Part.get.{u2} \u03b1 a h)) (fun (h : Not (Part.Dom.{u2} \u03b1 a)) => b))\nCase conversion may be inaccurate. Consider using '#align part.elim_to_option Part.elim_toOption\u2093'. -/\n@[simp]\ntheorem elim_toOption {\u03b1 \u03b2 : Type _} (a : Part \u03b1) [Decidable a.Dom] (b : \u03b2) (f : \u03b1 \u2192 \u03b2) :\n    a.toOption.elim b f = if h : a.Dom then f (a.get h) else b :=\n  by\n  split_ifs\n  \u00b7 rw [h.to_option]\n    rfl\n  \u00b7 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 \u03b1` into a `part \u03b1`. -/\ndef ofOption : Option \u03b1 \u2192 Part \u03b1\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 : \u03b1} : \u2200 {o : Option \u03b1}, a \u2208 ofOption o \u2194 a \u2208 o\n  | Option.none => \u27e8fun h => h.fst.elim, fun h => Option.noConfusion h\u27e9\n  | Option.some b => \u27e8fun h => congr_arg Option.some h.snd, fun h => \u27e8trivial, Option.some.inj h\u27e9\u27e9\n#align part.mem_of_option Part.mem_ofOption\n-/\n\n#print Part.ofOption_dom /-\n@[simp]\ntheorem ofOption_dom {\u03b1} : \u2200 o : Option \u03b1, (ofOption o).Dom \u2194 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 {\u03b1} (o : Option \u03b1) : ofOption o = \u27e8_, @Option.get _ o\u27e9 :=\n  Part.ext' (ofOption_dom o) fun h\u2081 h\u2082 => by cases o <;> [cases h\u2081, rfl]\n#align part.of_option_eq_get Part.ofOption_eq_get\n-/\n\ninstance : Coe (Option \u03b1) (Part \u03b1) :=\n  \u27e8ofOption\u27e9\n\n#print Part.mem_coe /-\n@[simp]\ntheorem mem_coe {a : \u03b1} {o : Option \u03b1} : a \u2208 (o : Part \u03b1) \u2194 a \u2208 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 \u03b1 : Part \u03b1) = none :=\n  rfl\n#align part.coe_none Part.coe_none\n-/\n\n#print Part.coe_some /-\n@[simp]\ntheorem coe_some (a : \u03b1) : (Option.some a : Part \u03b1) = 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 \u03b1 \u2192 Prop} (a : Part \u03b1) (hnone : P none)\n    (hsome : \u2200 a : \u03b1, P (some a)) : P a :=\n  (Classical.em a.Dom).elim (fun h => Part.some_get h \u25b8 hsome _) fun h =>\n    (eq_none_iff'.2 h).symm \u25b8 hnone\n#align part.induction_on Part.induction_on\n-/\n\n#print Part.ofOptionDecidable /-\ninstance ofOptionDecidable : \u2200 o : Option \u03b1, 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 \u03b1) : 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 \u03b1) [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 \u03b1` is (classically) equivalent to `option \u03b1`. -/\nnoncomputable def equivOption : Part \u03b1 \u2243 Option \u03b1 :=\n  haveI := Classical.dec\n  \u27e8fun o => to_option o, of_option, fun o => of_to_option o, fun o =>\n    Eq.trans (by dsimp <;> congr ) (to_of_option o)\u27e9\n#align part.equiv_option Part.equivOption\n-/\n\n/-- We give `part \u03b1` the order where everything is greater than `none`. -/\ninstance : PartialOrder (Part \u03b1)\n    where\n  le x y := \u2200 i, i \u2208 x \u2192 i \u2208 y\n  le_refl x y := id\n  le_trans x y z f g i := g _ \u2218 f _\n  le_antisymm x y f g := Part.ext fun z => \u27e8f _, g _\u27e9\n\ninstance : OrderBot (Part \u03b1) where\n  bot := none\n  bot_le := by\n    introv x\n    rintro \u27e8\u27e8_\u27e9, _\u27e9\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 {\u03b1 : Type.{u1}} {x : Part.{u1} \u03b1} {y : Part.{u1} \u03b1} (z : Part.{u1} \u03b1), (LE.le.{u1} (Part.{u1} \u03b1) (Preorder.toLE.{u1} (Part.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b1) (Part.partialOrder.{u1} \u03b1))) x z) -> (LE.le.{u1} (Part.{u1} \u03b1) (Preorder.toLE.{u1} (Part.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b1) (Part.partialOrder.{u1} \u03b1))) y z) -> (Or (LE.le.{u1} (Part.{u1} \u03b1) (Preorder.toLE.{u1} (Part.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b1) (Part.partialOrder.{u1} \u03b1))) x y) (LE.le.{u1} (Part.{u1} \u03b1) (Preorder.toLE.{u1} (Part.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b1) (Part.partialOrder.{u1} \u03b1))) y x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {x : Part.{u1} \u03b1} {y : Part.{u1} \u03b1} (z : Part.{u1} \u03b1), (LE.le.{u1} (Part.{u1} \u03b1) (Preorder.toLE.{u1} (Part.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b1) (Part.instPartialOrderPart.{u1} \u03b1))) x z) -> (LE.le.{u1} (Part.{u1} \u03b1) (Preorder.toLE.{u1} (Part.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b1) (Part.instPartialOrderPart.{u1} \u03b1))) y z) -> (Or (LE.le.{u1} (Part.{u1} \u03b1) (Preorder.toLE.{u1} (Part.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b1) (Part.instPartialOrderPart.{u1} \u03b1))) x y) (LE.le.{u1} (Part.{u1} \u03b1) (Preorder.toLE.{u1} (Part.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b1) (Part.instPartialOrderPart.{u1} \u03b1))) y x))\nCase conversion may be inaccurate. Consider using '#align part.le_total_of_le_of_le Part.le_total_of_le_of_le\u2093'. -/\ntheorem le_total_of_le_of_le {x y : Part \u03b1} (z : Part \u03b1) (hx : x \u2264 z) (hy : y \u2264 z) :\n    x \u2264 y \u2228 y \u2264 x := by\n  rcases Part.eq_none_or_eq_some x with (h | \u27e8b, h\u2080\u27e9)\n  \u00b7 rw [h]\n    left\n    apply OrderBot.bot_le _\n  right; intro b' h\u2081\n  rw [Part.eq_some_iff] at h\u2080\n  replace hx := hx _ h\u2080; replace hy := hy _ h\u2081\n  replace hx := Part.mem_unique hx hy; subst hx\n  exact h\u2080\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 \u2192 Part \u03b1) : Part \u03b1 :=\n  \u27e8\u2203 h : p, (f h).Dom, fun ha => (f ha.fst).get ha.snd\u27e9\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 \u03b1) (g : \u03b1 \u2192 Part \u03b2) : Part \u03b2 :=\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 : \u03b1 \u2192 \u03b2) (o : Part \u03b1) : Part \u03b2 :=\n  \u27e8o.Dom, f \u2218 o.get\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) {o : Part.{u1} \u03b1} {a : \u03b1}, (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) a o) -> (Membership.Mem.{u2, u2} \u03b2 (Part.{u2} \u03b2) (Part.hasMem.{u2} \u03b2) (f a) (Part.map.{u1, u2} \u03b1 \u03b2 f o))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) {o : Part.{u2} \u03b1} {a : \u03b1}, (Membership.mem.{u2, u2} \u03b1 (Part.{u2} \u03b1) (Part.instMembershipPart.{u2} \u03b1) a o) -> (Membership.mem.{u1, u1} \u03b2 (Part.{u1} \u03b2) (Part.instMembershipPart.{u1} \u03b2) (f a) (Part.map.{u2, u1} \u03b1 \u03b2 f o))\nCase conversion may be inaccurate. Consider using '#align part.mem_map Part.mem_map\u2093'. -/\ntheorem mem_map (f : \u03b1 \u2192 \u03b2) {o : Part \u03b1} : \u2200 {a}, a \u2208 o \u2192 f a \u2208 map f o\n  | _, \u27e8h, rfl\u27e9 => \u27e8_, rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) {o : Part.{u1} \u03b1} {b : \u03b2}, Iff (Membership.Mem.{u2, u2} \u03b2 (Part.{u2} \u03b2) (Part.hasMem.{u2} \u03b2) b (Part.map.{u1, u2} \u03b1 \u03b2 f o)) (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) a o) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) a o) => Eq.{succ u2} \u03b2 (f a) b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) {o : Part.{u2} \u03b1} {b : \u03b2}, Iff (Membership.mem.{u1, u1} \u03b2 (Part.{u1} \u03b2) (Part.instMembershipPart.{u1} \u03b2) b (Part.map.{u2, u1} \u03b1 \u03b2 f o)) (Exists.{succ u2} \u03b1 (fun (a : \u03b1) => And (Membership.mem.{u2, u2} \u03b1 (Part.{u2} \u03b1) (Part.instMembershipPart.{u2} \u03b1) a o) (Eq.{succ u1} \u03b2 (f a) b)))\nCase conversion may be inaccurate. Consider using '#align part.mem_map_iff Part.mem_map_iff\u2093'. -/\n@[simp]\ntheorem mem_map_iff (f : \u03b1 \u2192 \u03b2) {o : Part \u03b1} {b} : b \u2208 map f o \u2194 \u2203 a \u2208 o, f a = b :=\n  \u27e8match b with\n    | _, \u27e8h, rfl\u27e9 => \u27e8_, \u27e8_, rfl\u27e9, rfl\u27e9,\n    fun \u27e8a, h\u2081, h\u2082\u27e9 => h\u2082 \u25b8 mem_map f h\u2081\u27e9\n#align part.mem_map_iff Part.mem_map_iff\n\n#print Part.map_none /-\n@[simp]\ntheorem map_none (f : \u03b1 \u2192 \u03b2) : 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 : \u03b1 \u2192 \u03b2) (a : \u03b1) : 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 \u2192 Part \u03b1} : \u2200 {a} (h : p), a \u2208 f h \u2192 a \u2208 assert p f\n  | _, x, \u27e8h, rfl\u27e9 => \u27e8\u27e8x, h\u27e9, rfl\u27e9\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 \u2192 Part \u03b1} {a} : a \u2208 assert p f \u2194 \u2203 h : p, a \u2208 f h :=\n  \u27e8match a with\n    | _, \u27e8h, rfl\u27e9 => \u27e8_, \u27e8_, rfl\u27e9\u27e9,\n    fun \u27e8a, h\u27e9 => mem_assert _ h\u27e9\n#align part.mem_assert_iff Part.mem_assert_iff\n-/\n\n#print Part.assert_pos /-\ntheorem assert_pos {p : Prop} {f : p \u2192 Part \u03b1} (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  \u00b7 simp only [h, h', exists_prop_of_true]\n  \u00b7 cc\n#align part.assert_pos Part.assert_pos\n-/\n\n#print Part.assert_neg /-\ntheorem assert_neg {p : Prop} {f : p \u2192 Part \u03b1} (h : \u00acp) : assert p f = none :=\n  by\n  dsimp [assert, none]; congr\n  \u00b7 simp only [h, not_false_iff, exists_prop_of_false]\n  \u00b7 apply Function.hfunext\n    \u00b7 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : Part.{u1} \u03b1} {g : \u03b1 -> (Part.{u2} \u03b2)} {a : \u03b1} {b : \u03b2}, (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) a f) -> (Membership.Mem.{u2, u2} \u03b2 (Part.{u2} \u03b2) (Part.hasMem.{u2} \u03b2) b (g a)) -> (Membership.Mem.{u2, u2} \u03b2 (Part.{u2} \u03b2) (Part.hasMem.{u2} \u03b2) b (Part.bind.{u1, u2} \u03b1 \u03b2 f g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {f : Part.{u2} \u03b1} {g : \u03b1 -> (Part.{u1} \u03b2)} {a : \u03b1} {b : \u03b2}, (Membership.mem.{u2, u2} \u03b1 (Part.{u2} \u03b1) (Part.instMembershipPart.{u2} \u03b1) a f) -> (Membership.mem.{u1, u1} \u03b2 (Part.{u1} \u03b2) (Part.instMembershipPart.{u1} \u03b2) b (g a)) -> (Membership.mem.{u1, u1} \u03b2 (Part.{u1} \u03b2) (Part.instMembershipPart.{u1} \u03b2) b (Part.bind.{u2, u1} \u03b1 \u03b2 f g))\nCase conversion may be inaccurate. Consider using '#align part.mem_bind Part.mem_bind\u2093'. -/\ntheorem mem_bind {f : Part \u03b1} {g : \u03b1 \u2192 Part \u03b2} : \u2200 {a b}, a \u2208 f \u2192 b \u2208 g a \u2192 b \u2208 f.bind g\n  | _, _, \u27e8h, rfl\u27e9, \u27e8h\u2082, rfl\u27e9 => \u27e8\u27e8h, h\u2082\u27e9, rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : Part.{u1} \u03b1} {g : \u03b1 -> (Part.{u2} \u03b2)} {b : \u03b2}, Iff (Membership.Mem.{u2, u2} \u03b2 (Part.{u2} \u03b2) (Part.hasMem.{u2} \u03b2) b (Part.bind.{u1, u2} \u03b1 \u03b2 f g)) (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) a f) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) a f) => Membership.Mem.{u2, u2} \u03b2 (Part.{u2} \u03b2) (Part.hasMem.{u2} \u03b2) b (g a))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {f : Part.{u2} \u03b1} {g : \u03b1 -> (Part.{u1} \u03b2)} {b : \u03b2}, Iff (Membership.mem.{u1, u1} \u03b2 (Part.{u1} \u03b2) (Part.instMembershipPart.{u1} \u03b2) b (Part.bind.{u2, u1} \u03b1 \u03b2 f g)) (Exists.{succ u2} \u03b1 (fun (a : \u03b1) => And (Membership.mem.{u2, u2} \u03b1 (Part.{u2} \u03b1) (Part.instMembershipPart.{u2} \u03b1) a f) (Membership.mem.{u1, u1} \u03b2 (Part.{u1} \u03b2) (Part.instMembershipPart.{u1} \u03b2) b (g a))))\nCase conversion may be inaccurate. Consider using '#align part.mem_bind_iff Part.mem_bind_iff\u2093'. -/\n@[simp]\ntheorem mem_bind_iff {f : Part \u03b1} {g : \u03b1 \u2192 Part \u03b2} {b} : b \u2208 f.bind g \u2194 \u2203 a \u2208 f, b \u2208 g a :=\n  \u27e8match b with\n    | _, \u27e8\u27e8h\u2081, h\u2082\u27e9, rfl\u27e9 => \u27e8_, \u27e8_, rfl\u27e9, \u27e8_, rfl\u27e9\u27e9,\n    fun \u27e8a, h\u2081, h\u2082\u27e9 => mem_bind h\u2081 h\u2082\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {o : Part.{u1} \u03b1} (h : Part.Dom.{u1} \u03b1 o) (f : \u03b1 -> (Part.{u2} \u03b2)), Eq.{succ u2} (Part.{u2} \u03b2) (Part.bind.{u1, u2} \u03b1 \u03b2 o f) (f (Part.get.{u1} \u03b1 o h))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {o : Part.{u2} \u03b1} (h : Part.Dom.{u2} \u03b1 o) (f : \u03b1 -> (Part.{u1} \u03b2)), Eq.{succ u1} (Part.{u1} \u03b2) (Part.bind.{u2, u1} \u03b1 \u03b2 o f) (f (Part.get.{u2} \u03b1 o h))\nCase conversion may be inaccurate. Consider using '#align part.dom.bind Part.Dom.bind\u2093'. -/\nprotected theorem Dom.bind {o : Part \u03b1} (h : o.Dom) (f : \u03b1 \u2192 Part \u03b2) : o.bind f = f (o.get h) :=\n  by\n  ext b\n  simp only [Part.mem_bind_iff, exists_prop]\n  refine' \u27e8_, fun hb => \u27e8o.get h, Part.get_mem _, hb\u27e9\u27e9\n  rintro \u27e8a, ha, hb\u27e9\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 : \u03b1 \u2192 Part \u03b2} {a : Part \u03b1} (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 : \u03b1 \u2192 Part \u03b2) : 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 : \u03b1) (f : \u03b1 \u2192 Part \u03b2) : (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {o : Part.{u1} \u03b1} {a : \u03b1}, (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) a o) -> (forall (f : \u03b1 -> (Part.{u2} \u03b2)), Eq.{succ u2} (Part.{u2} \u03b2) (Part.bind.{u1, u2} \u03b1 \u03b2 o f) (f a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {o : Part.{u2} \u03b1} {a : \u03b1}, (Membership.mem.{u2, u2} \u03b1 (Part.{u2} \u03b1) (Part.instMembershipPart.{u2} \u03b1) a o) -> (forall (f : \u03b1 -> (Part.{u1} \u03b2)), Eq.{succ u1} (Part.{u1} \u03b2) (Part.bind.{u2, u1} \u03b1 \u03b2 o f) (f a))\nCase conversion may be inaccurate. Consider using '#align part.bind_of_mem Part.bind_of_mem\u2093'. -/\ntheorem bind_of_mem {o : Part \u03b1} {a : \u03b1} (h : a \u2208 o) (f : \u03b1 \u2192 Part \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) (x : Part.{u1} \u03b1), Eq.{succ u2} (Part.{u2} \u03b2) (Part.bind.{u1, u2} \u03b1 \u03b2 x (Function.comp.{succ u1, succ u2, succ u2} \u03b1 \u03b2 (Part.{u2} \u03b2) (Part.some.{u2} \u03b2) f)) (Part.map.{u1, u2} \u03b1 \u03b2 f x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) (x : Part.{u2} \u03b1), Eq.{succ u1} (Part.{u1} \u03b2) (Part.bind.{u2, u1} \u03b1 \u03b2 x (Function.comp.{succ u2, succ u1, succ u1} \u03b1 \u03b2 (Part.{u1} \u03b2) (Part.some.{u1} \u03b2) f)) (Part.map.{u2, u1} \u03b1 \u03b2 f x)\nCase conversion may be inaccurate. Consider using '#align part.bind_some_eq_map Part.bind_some_eq_map\u2093'. -/\ntheorem bind_some_eq_map (f : \u03b1 \u2192 \u03b2) (x : Part \u03b1) : x.bind (some \u2218 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 : \u03b1 \u2192 Part \u03b2) (o : Part \u03b1) [Decidable o.Dom] [\u2200 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  \u00b7 simp_rw [h.to_option, h.bind]\n    rfl\n  \u00b7 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : Part.{u1} \u03b1) (g : \u03b1 -> (Part.{u2} \u03b2)) (k : \u03b2 -> (Part.{u3} \u03b3)), Eq.{succ u3} (Part.{u3} \u03b3) (Part.bind.{u2, u3} \u03b2 \u03b3 (Part.bind.{u1, u2} \u03b1 \u03b2 f g) k) (Part.bind.{u1, u3} \u03b1 \u03b3 f (fun (x : \u03b1) => Part.bind.{u2, u3} \u03b2 \u03b3 (g x) k))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} (f : Part.{u2} \u03b1) (g : \u03b1 -> (Part.{u1} \u03b2)) (k : \u03b2 -> (Part.{u3} \u03b3)), Eq.{succ u3} (Part.{u3} \u03b3) (Part.bind.{u1, u3} \u03b2 \u03b3 (Part.bind.{u2, u1} \u03b1 \u03b2 f g) k) (Part.bind.{u2, u3} \u03b1 \u03b3 f (fun (x : \u03b1) => Part.bind.{u1, u3} \u03b2 \u03b3 (g x) k))\nCase conversion may be inaccurate. Consider using '#align part.bind_assoc Part.bind_assoc\u2093'. -/\ntheorem bind_assoc {\u03b3} (f : Part \u03b1) (g : \u03b1 \u2192 Part \u03b2) (k : \u03b2 \u2192 Part \u03b3) :\n    (f.bind g).bind k = f.bind fun x => (g x).bind k :=\n  ext fun a => by\n    simp <;>\n      exact\n        \u27e8fun \u27e8_, \u27e8_, h\u2081, h\u2082\u27e9, h\u2083\u27e9 => \u27e8_, h\u2081, _, h\u2082, h\u2083\u27e9, fun \u27e8_, h\u2081, _, h\u2082, h\u2083\u27e9 =>\n          \u27e8_, \u27e8_, h\u2081, h\u2082\u27e9, h\u2083\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2) (x : Part.{u1} \u03b1) (g : \u03b2 -> (Part.{u3} \u03b3)), Eq.{succ u3} (Part.{u3} \u03b3) (Part.bind.{u2, u3} \u03b2 \u03b3 (Part.map.{u1, u2} \u03b1 \u03b2 f x) g) (Part.bind.{u1, u3} \u03b1 \u03b3 x (fun (y : \u03b1) => g (f y)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} (f : \u03b1 -> \u03b2) (x : Part.{u2} \u03b1) (g : \u03b2 -> (Part.{u3} \u03b3)), Eq.{succ u3} (Part.{u3} \u03b3) (Part.bind.{u1, u3} \u03b2 \u03b3 (Part.map.{u2, u1} \u03b1 \u03b2 f x) g) (Part.bind.{u2, u3} \u03b1 \u03b3 x (fun (y : \u03b1) => g (f y)))\nCase conversion may be inaccurate. Consider using '#align part.bind_map Part.bind_map\u2093'. -/\n@[simp]\ntheorem bind_map {\u03b3} (f : \u03b1 \u2192 \u03b2) (x) (g : \u03b2 \u2192 Part \u03b3) :\n    (map f x).bind g = x.bind fun y => g (f y) := by rw [\u2190 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 {\u03b3} (f : \u03b1 \u2192 Part \u03b2) (x : Part \u03b1) (g : \u03b2 \u2192 \u03b3) :\n    map g (x.bind f) = x.bind fun y => map g (f y) := by\n  rw [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (g : \u03b2 -> \u03b3) (f : \u03b1 -> \u03b2) (o : Part.{u1} \u03b1), Eq.{succ u3} (Part.{u3} \u03b3) (Part.map.{u2, u3} \u03b2 \u03b3 g (Part.map.{u1, u2} \u03b1 \u03b2 f o)) (Part.map.{u1, u3} \u03b1 \u03b3 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 g f) o)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} (g : \u03b2 -> \u03b3) (f : \u03b1 -> \u03b2) (o : Part.{u3} \u03b1), Eq.{succ u2} (Part.{u2} \u03b3) (Part.map.{u1, u2} \u03b2 \u03b3 g (Part.map.{u3, u1} \u03b1 \u03b2 f o)) (Part.map.{u3, u2} \u03b1 \u03b3 (Function.comp.{succ u3, succ u1, succ u2} \u03b1 \u03b2 \u03b3 g f) o)\nCase conversion may be inaccurate. Consider using '#align part.map_map Part.map_map\u2093'. -/\ntheorem map_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) (o : Part \u03b1) : map g (map f o) = map (g \u2218 f) o := by\n  rw [\u2190 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 \u03b2 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 : \u03b1 \u2192 \u03b1} (H : \u2200 x : \u03b1, 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 \u03b1) : 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 {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (Pure.pure.{u1, u1} Part.{u1} (Applicative.toHasPure.{u1, u1} Part.{u1} (Monad.toApplicative.{u1, u1} Part.{u1} Part.monad.{u1})) \u03b1 a) (Part.some.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (Pure.pure.{u1, u1} Part.{u1} (Applicative.toPure.{u1, u1} Part.{u1} (Monad.toApplicative.{u1, u1} Part.{u1} Part.instMonadPart.{u1})) \u03b1 a) (Part.some.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.pure_eq_some Part.pure_eq_some\u2093'. -/\n@[simp]\ntheorem pure_eq_some (a : \u03b1) : 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 {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (return.{u1, u1} Part.{u1} Part.monad.{u1} \u03b1 a) (Part.some.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (a : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (Pure.pure.{u1, u1} Part.{u1} (Applicative.toPure.{u1, u1} Part.{u1} (Monad.toApplicative.{u1, u1} Part.{u1} Part.instMonadPart.{u1})) \u03b1 a) (Part.some.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.ret_eq_some Part.ret_eq_some\u2093'. -/\n@[simp]\ntheorem ret_eq_some (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) (o : Part.{u1} \u03b1), Eq.{succ u1} (Part.{u1} \u03b2) (Functor.map.{u1, u1} (fun {\u03b1 : Type.{u1}} => Part.{u1} \u03b1) (Applicative.toFunctor.{u1, u1} (fun {\u03b1 : Type.{u1}} => Part.{u1} \u03b1) (Monad.toApplicative.{u1, u1} (fun {\u03b1 : Type.{u1}} => Part.{u1} \u03b1) Part.monad.{u1})) \u03b1 \u03b2 f o) (Part.map.{u1, u1} \u03b1 \u03b2 f o)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) (o : Part.{u1} \u03b1), Eq.{succ u1} (Part.{u1} \u03b2) (Functor.map.{u1, u1} Part.{u1} (Applicative.toFunctor.{u1, u1} Part.{u1} (Monad.toApplicative.{u1, u1} Part.{u1} Part.instMonadPart.{u1})) \u03b1 \u03b2 f o) (Part.map.{u1, u1} \u03b1 \u03b2 f o)\nCase conversion may be inaccurate. Consider using '#align part.map_eq_map Part.map_eq_map\u2093'. -/\n@[simp]\ntheorem map_eq_map {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (o : Part \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}} (f : Part.{u1} \u03b1) (g : \u03b1 -> (Part.{u1} \u03b2)), Eq.{succ u1} (Part.{u1} \u03b2) (Bind.bind.{u1, u1} Part.{u1} (Monad.toHasBind.{u1, u1} Part.{u1} Part.monad.{u1}) \u03b1 \u03b2 f g) (Part.bind.{u1, u1} \u03b1 \u03b2 f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}} (f : Part.{u1} \u03b1) (g : \u03b1 -> (Part.{u1} \u03b2)), Eq.{succ u1} (Part.{u1} \u03b2) (Bind.bind.{u1, u1} Part.{u1} (Monad.toBind.{u1, u1} Part.{u1} Part.instMonadPart.{u1}) \u03b1 \u03b2 f g) (Part.bind.{u1, u1} \u03b1 \u03b2 f g)\nCase conversion may be inaccurate. Consider using '#align part.bind_eq_bind Part.bind_eq_bind\u2093'. -/\n@[simp]\ntheorem bind_eq_bind {\u03b1 \u03b2} (f : Part \u03b1) (g : \u03b1 \u2192 Part \u03b2) : 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 {\u03b2 : Type.{u1}} {\u03b1 : Type.{u1}} (x : Part.{u1} \u03b1) (f : \u03b1 -> (Part.{u1} \u03b2)) (y : Part.{u1} \u03b2), Iff (LE.le.{u1} (Part.{u1} \u03b2) (Preorder.toLE.{u1} (Part.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b2) (Part.partialOrder.{u1} \u03b2))) (Bind.bind.{u1, u1} Part.{u1} (Monad.toHasBind.{u1, u1} Part.{u1} Part.monad.{u1}) \u03b1 \u03b2 x f) y) (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) a x) -> (LE.le.{u1} (Part.{u1} \u03b2) (Preorder.toLE.{u1} (Part.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b2) (Part.partialOrder.{u1} \u03b2))) (f a) y))\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} {\u03b1 : Type.{u1}} (x : Part.{u1} \u03b1) (f : \u03b1 -> (Part.{u1} \u03b2)) (y : Part.{u1} \u03b2), Iff (LE.le.{u1} (Part.{u1} \u03b2) (Preorder.toLE.{u1} (Part.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b2) (Part.instPartialOrderPart.{u1} \u03b2))) (Bind.bind.{u1, u1} Part.{u1} (Monad.toBind.{u1, u1} Part.{u1} Part.instMonadPart.{u1}) \u03b1 \u03b2 x f) y) (forall (a : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) a x) -> (LE.le.{u1} (Part.{u1} \u03b2) (Preorder.toLE.{u1} (Part.{u1} \u03b2) (PartialOrder.toPreorder.{u1} (Part.{u1} \u03b2) (Part.instPartialOrderPart.{u1} \u03b2))) (f a) y))\nCase conversion may be inaccurate. Consider using '#align part.bind_le Part.bind_le\u2093'. -/\ntheorem bind_le {\u03b1} (x : Part \u03b1) (f : \u03b1 \u2192 Part \u03b2) (y : Part \u03b2) :\n    x >>= f \u2264 y \u2194 \u2200 a, a \u2208 x \u2192 f a \u2264 y :=\n  by\n  constructor <;> intro h\n  \u00b7 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  \u00b7 intro b h'\n    simp only [exists_prop, bind_eq_bind, mem_bind_iff] at h'\n    rcases h' with \u27e8a, h\u2080, h\u2081\u27e9\n    apply h _ h\u2080 _ h\u2081\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 \u03b1) (H : p \u2192 o.Dom) : Part \u03b1 :=\n  \u27e8p, fun h => o.get (H h)\u27e9\n#align part.restrict Part.restrict\n-/\n\n#print Part.mem_restrict /-\n@[simp]\ntheorem mem_restrict (p : Prop) (o : Part \u03b1) (h : p \u2192 o.Dom) (a : \u03b1) :\n    a \u2208 restrict p o h \u2194 p \u2227 a \u2208 o :=\n  by\n  dsimp [restrict, mem_eq]; constructor\n  \u00b7 rintro \u27e8h\u2080, h\u2081\u27e9\n    exact \u27e8h\u2080, \u27e8_, h\u2081\u27e9\u27e9\n  rintro \u27e8h\u2080, h\u2081, h\u2082\u27e9; exact \u27e8h\u2080, h\u2082\u27e9\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 \u03b1) : \u03b1 :=\n  o.get undefined\n#align part.unwrap Part.unwrap\n-/\n\n#print Part.assert_defined /-\ntheorem assert_defined {p : Prop} {f : p \u2192 Part \u03b1} : \u2200 h : p, (f h).Dom \u2192 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : Part.{u1} \u03b1} {g : \u03b1 -> (Part.{u2} \u03b2)} (h : Part.Dom.{u1} \u03b1 f), (Part.Dom.{u2} \u03b2 (g (Part.get.{u1} \u03b1 f h))) -> (Part.Dom.{u2} \u03b2 (Part.bind.{u1, u2} \u03b1 \u03b2 f g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {f : Part.{u2} \u03b1} {g : \u03b1 -> (Part.{u1} \u03b2)} (h : Part.Dom.{u2} \u03b1 f), (Part.Dom.{u1} \u03b2 (g (Part.get.{u2} \u03b1 f h))) -> (Part.Dom.{u1} \u03b2 (Part.bind.{u2, u1} \u03b1 \u03b2 f g))\nCase conversion may be inaccurate. Consider using '#align part.bind_defined Part.bind_defined\u2093'. -/\ntheorem bind_defined {f : Part \u03b1} {g : \u03b1 \u2192 Part \u03b2} :\n    \u2200 h : f.Dom, (g (f.get h)).Dom \u2192 (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : Part.{u1} \u03b1} {g : \u03b1 -> (Part.{u2} \u03b2)}, Iff (Part.Dom.{u2} \u03b2 (Part.bind.{u1, u2} \u03b1 \u03b2 f g)) (Exists.{0} (Part.Dom.{u1} \u03b1 f) (fun (h : Part.Dom.{u1} \u03b1 f) => Part.Dom.{u2} \u03b2 (g (Part.get.{u1} \u03b1 f h))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {f : Part.{u2} \u03b1} {g : \u03b1 -> (Part.{u1} \u03b2)}, Iff (Part.Dom.{u1} \u03b2 (Part.bind.{u2, u1} \u03b1 \u03b2 f g)) (Exists.{0} (Part.Dom.{u2} \u03b1 f) (fun (h : Part.Dom.{u2} \u03b1 f) => Part.Dom.{u1} \u03b2 (g (Part.get.{u2} \u03b1 f h))))\nCase conversion may be inaccurate. Consider using '#align part.bind_dom Part.bind_dom\u2093'. -/\n@[simp]\ntheorem bind_dom {f : Part \u03b1} {g : \u03b1 \u2192 Part \u03b2} : (f.bind g).Dom \u2194 \u2203 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 \u03b1` inherited from `\u03b1`.\n@[to_additive]\ninstance [One \u03b1] : One (Part \u03b1) where one := pure 1\n\n@[to_additive]\ninstance [Mul \u03b1] : Mul (Part \u03b1) where mul a b := (\u00b7 * \u00b7) <$> a <*> b\n\n@[to_additive]\ninstance [Inv \u03b1] : Inv (Part \u03b1) where inv := map Inv.inv\n\n@[to_additive]\ninstance [Div \u03b1] : Div (Part \u03b1) where div a b := (\u00b7 / \u00b7) <$> a <*> b\n\ninstance [Mod \u03b1] : Mod (Part \u03b1) where mod a b := (\u00b7 % \u00b7) <$> a <*> b\n\ninstance [Append \u03b1] : Append (Part \u03b1) where append a b := (\u00b7 ++ \u00b7) <$> a <*> b\n\ninstance [Inter \u03b1] : Inter (Part \u03b1) where inter a b := (\u00b7 \u2229 \u00b7) <$> a <*> b\n\ninstance [Union \u03b1] : Union (Part \u03b1) where union a b := (\u00b7 \u222a \u00b7) <$> a <*> b\n\ninstance [SDiff \u03b1] : SDiff (Part \u03b1) where sdiff a b := (\u00b7 \\ \u00b7) <$> a <*> b\n\n/- warning: part.one_mem_one -> Part.one_mem_one is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1], Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))) (OfNat.ofNat.{u1} (Part.{u1} \u03b1) 1 (OfNat.mk.{u1} (Part.{u1} \u03b1) 1 (One.one.{u1} (Part.{u1} \u03b1) (Part.hasOne.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1], Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} (Part.{u1} \u03b1) 1 (One.toOfNat1.{u1} (Part.{u1} \u03b1) (Part.instOnePart.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align part.one_mem_one Part.one_mem_one\u2093'. -/\n@[to_additive]\ntheorem one_mem_one [One \u03b1] : (1 : \u03b1) \u2208 (1 : Part \u03b1) :=\n  \u27e8trivial, rfl\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) ma a) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) mb b) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _inst_1) ma mb) (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.hasMul.{u1} \u03b1 _inst_1)) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) ma a) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) mb b) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _inst_1) ma mb) (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.instMulPart.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align part.mul_mem_mul Part.mul_mem_mul\u2093'. -/\n@[to_additive]\ntheorem mul_mem_mul [Mul \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma * mb \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.hasMul.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.instMulPart.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_mul_dom Part.left_dom_of_mul_dom\u2093'. -/\n@[to_additive]\ntheorem left_dom_of_mul_dom [Mul \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.hasMul.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.instMulPart.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_mul_dom Part.right_dom_of_mul_dom\u2093'. -/\n@[to_additive]\ntheorem right_dom_of_mul_dom [Mul \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.hasMul.{u1} \u03b1 _inst_1)) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.hasMul.{u1} \u03b1 _inst_1)) a b) hab) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _inst_1) (Part.get.{u1} \u03b1 a (Part.left_dom_of_mul_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_mul_dom.{u1} \u03b1 _inst_1 a b hab)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.instMulPart.{u1} \u03b1 _inst_1)) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.instMulPart.{u1} \u03b1 _inst_1)) a b) hab) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _inst_1) (Part.get.{u1} \u03b1 a (Part.left_dom_of_mul_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_mul_dom.{u1} \u03b1 _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.mul_get_eq Part.mul_get_eq\u2093'. -/\n@[simp, to_additive]\ntheorem mul_get_eq [Mul \u03b1] (a b : Part \u03b1) (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 {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.hasMul.{u1} \u03b1 _inst_1)) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _inst_1) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mul.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMul.{u1} (Part.{u1} \u03b1) (Part.instMulPart.{u1} \u03b1 _inst_1)) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.some_mul_some Part.some_mul_some\u2093'. -/\n@[to_additive]\ntheorem some_mul_some [Mul \u03b1] (a b : \u03b1) : 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 \u03b1] (a : Part \u03b1) (ma : \u03b1) (ha : ma \u2208 a) : ma\u207b\u00b9 \u2208 a\u207b\u00b9 := 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 \u03b1] (a : \u03b1) : (some a)\u207b\u00b9 = some a\u207b\u00b9 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) ma a) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) mb b) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 _inst_1) ma mb) (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.hasDiv.{u1} \u03b1 _inst_1)) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) ma a) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) mb b) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 _inst_1) ma mb) (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.instDivPart.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align part.div_mem_div Part.div_mem_div\u2093'. -/\n@[to_additive]\ntheorem div_mem_div [Div \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma / mb \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.hasDiv.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.instDivPart.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_div_dom Part.left_dom_of_div_dom\u2093'. -/\n@[to_additive]\ntheorem left_dom_of_div_dom [Div \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.hasDiv.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.instDivPart.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_div_dom Part.right_dom_of_div_dom\u2093'. -/\n@[to_additive]\ntheorem right_dom_of_div_dom [Div \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.hasDiv.{u1} \u03b1 _inst_1)) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.hasDiv.{u1} \u03b1 _inst_1)) a b) hab) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 _inst_1) (Part.get.{u1} \u03b1 a (Part.left_dom_of_div_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_div_dom.{u1} \u03b1 _inst_1 a b hab)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.instDivPart.{u1} \u03b1 _inst_1)) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.instDivPart.{u1} \u03b1 _inst_1)) a b) hab) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 _inst_1) (Part.get.{u1} \u03b1 a (Part.left_dom_of_div_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_div_dom.{u1} \u03b1 _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.div_get_eq Part.div_get_eq\u2093'. -/\n@[simp, to_additive]\ntheorem div_get_eq [Div \u03b1] (a b : Part \u03b1) (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 {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.hasDiv.{u1} \u03b1 _inst_1)) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 _inst_1) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Div.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (HDiv.hDiv.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHDiv.{u1} (Part.{u1} \u03b1) (Part.instDivPart.{u1} \u03b1 _inst_1)) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.some_div_some Part.some_div_some\u2093'. -/\n@[to_additive]\ntheorem some_div_some [Div \u03b1] (a b : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) ma a) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) mb b) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) (HMod.hMod.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMod.{u1} \u03b1 _inst_1) ma mb) (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.hasMod.{u1} \u03b1 _inst_1)) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) ma a) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) mb b) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) (HMod.hMod.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMod.{u1} \u03b1 _inst_1) ma mb) (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.instModPart.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align part.mod_mem_mod Part.mod_mem_mod\u2093'. -/\ntheorem mod_mem_mod [Mod \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma % mb \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.hasMod.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.instModPart.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_mod_dom Part.left_dom_of_mod_dom\u2093'. -/\ntheorem left_dom_of_mod_dom [Mod \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.hasMod.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.instModPart.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_mod_dom Part.right_dom_of_mod_dom\u2093'. -/\ntheorem right_dom_of_mod_dom [Mod \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.hasMod.{u1} \u03b1 _inst_1)) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.hasMod.{u1} \u03b1 _inst_1)) a b) hab) (HMod.hMod.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMod.{u1} \u03b1 _inst_1) (Part.get.{u1} \u03b1 a (Part.left_dom_of_mod_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_mod_dom.{u1} \u03b1 _inst_1 a b hab)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.instModPart.{u1} \u03b1 _inst_1)) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.instModPart.{u1} \u03b1 _inst_1)) a b) hab) (HMod.hMod.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMod.{u1} \u03b1 _inst_1) (Part.get.{u1} \u03b1 a (Part.left_dom_of_mod_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_mod_dom.{u1} \u03b1 _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.mod_get_eq Part.mod_get_eq\u2093'. -/\n@[simp]\ntheorem mod_get_eq [Mod \u03b1] (a b : Part \u03b1) (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 {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.hasMod.{u1} \u03b1 _inst_1)) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMod.{u1} \u03b1 _inst_1) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Mod.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (HMod.hMod.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHMod.{u1} (Part.{u1} \u03b1) (Part.instModPart.{u1} \u03b1 _inst_1)) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (HMod.hMod.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMod.{u1} \u03b1 _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.some_mod_some Part.some_mod_some\u2093'. -/\ntheorem some_mod_some [Mod \u03b1] (a b : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) ma a) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) mb b) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) (Append.append.{u1} \u03b1 _inst_1 ma mb) (Append.append.{u1} (Part.{u1} \u03b1) (Part.hasAppend.{u1} \u03b1 _inst_1) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) ma a) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) mb b) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) (HAppend.hAppend.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAppend.{u1} \u03b1 _inst_1) ma mb) (HAppend.hAppend.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHAppend.{u1} (Part.{u1} \u03b1) (Part.instAppendPart.{u1} \u03b1 _inst_1)) a b))\nCase conversion may be inaccurate. Consider using '#align part.append_mem_append Part.append_mem_append\u2093'. -/\ntheorem append_mem_append [Append \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma ++ mb \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Append.append.{u1} (Part.{u1} \u03b1) (Part.hasAppend.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HAppend.hAppend.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHAppend.{u1} (Part.{u1} \u03b1) (Part.instAppendPart.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_append_dom Part.left_dom_of_append_dom\u2093'. -/\ntheorem left_dom_of_append_dom [Append \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Append.append.{u1} (Part.{u1} \u03b1) (Part.hasAppend.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (HAppend.hAppend.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHAppend.{u1} (Part.{u1} \u03b1) (Part.instAppendPart.{u1} \u03b1 _inst_1)) a b)) -> (Part.Dom.{u1} \u03b1 b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_append_dom Part.right_dom_of_append_dom\u2093'. -/\ntheorem right_dom_of_append_dom [Append \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (Append.append.{u1} (Part.{u1} \u03b1) (Part.hasAppend.{u1} \u03b1 _inst_1) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (Append.append.{u1} (Part.{u1} \u03b1) (Part.hasAppend.{u1} \u03b1 _inst_1) a b) hab) (Append.append.{u1} \u03b1 _inst_1 (Part.get.{u1} \u03b1 a (Part.left_dom_of_append_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_append_dom.{u1} \u03b1 _inst_1 a b hab)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (HAppend.hAppend.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHAppend.{u1} (Part.{u1} \u03b1) (Part.instAppendPart.{u1} \u03b1 _inst_1)) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (HAppend.hAppend.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHAppend.{u1} (Part.{u1} \u03b1) (Part.instAppendPart.{u1} \u03b1 _inst_1)) a b) hab) (HAppend.hAppend.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAppend.{u1} \u03b1 _inst_1) (Part.get.{u1} \u03b1 a (Part.left_dom_of_append_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_append_dom.{u1} \u03b1 _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.append_get_eq Part.append_get_eq\u2093'. -/\n@[simp]\ntheorem append_get_eq [Append \u03b1] (a b : Part \u03b1) (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 {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (Append.append.{u1} (Part.{u1} \u03b1) (Part.hasAppend.{u1} \u03b1 _inst_1) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (Append.append.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Append.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (HAppend.hAppend.{u1, u1, u1} (Part.{u1} \u03b1) (Part.{u1} \u03b1) (Part.{u1} \u03b1) (instHAppend.{u1} (Part.{u1} \u03b1) (Part.instAppendPart.{u1} \u03b1 _inst_1)) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (HAppend.hAppend.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAppend.{u1} \u03b1 _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.some_append_some Part.some_append_some\u2093'. -/\ntheorem some_append_some [Append \u03b1] (a b : \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) ma a) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) mb b) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) (Inter.inter.{u1} \u03b1 _inst_1 ma mb) (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.hasInter.{u1} \u03b1 _inst_1) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) ma a) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) mb b) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) (Inter.inter.{u1} \u03b1 _inst_1 ma mb) (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.instInterPart.{u1} \u03b1 _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.inter_mem_inter Part.inter_mem_inter\u2093'. -/\ntheorem inter_mem_inter [Inter \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma \u2229 mb \u2208 a \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.hasInter.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.instInterPart.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_inter_dom Part.left_dom_of_inter_dom\u2093'. -/\ntheorem left_dom_of_inter_dom [Inter \u03b1] {a b : Part \u03b1} (hab : Dom (a \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.hasInter.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.instInterPart.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_inter_dom Part.right_dom_of_inter_dom\u2093'. -/\ntheorem right_dom_of_inter_dom [Inter \u03b1] {a b : Part \u03b1} (hab : Dom (a \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.hasInter.{u1} \u03b1 _inst_1) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.hasInter.{u1} \u03b1 _inst_1) a b) hab) (Inter.inter.{u1} \u03b1 _inst_1 (Part.get.{u1} \u03b1 a (Part.left_dom_of_inter_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_inter_dom.{u1} \u03b1 _inst_1 a b hab)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.instInterPart.{u1} \u03b1 _inst_1) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.instInterPart.{u1} \u03b1 _inst_1) a b) hab) (Inter.inter.{u1} \u03b1 _inst_1 (Part.get.{u1} \u03b1 a (Part.left_dom_of_inter_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_inter_dom.{u1} \u03b1 _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.inter_get_eq Part.inter_get_eq\u2093'. -/\n@[simp]\ntheorem inter_get_eq [Inter \u03b1] (a b : Part \u03b1) (hab : Dom (a \u2229 b)) :\n    (a \u2229 b).get hab = a.get (left_dom_of_inter_dom hab) \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.hasInter.{u1} \u03b1 _inst_1) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (Inter.inter.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Inter.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (Inter.inter.{u1} (Part.{u1} \u03b1) (Part.instInterPart.{u1} \u03b1 _inst_1) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (Inter.inter.{u1} \u03b1 _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align part.some_inter_some Part.some_inter_some\u2093'. -/\ntheorem some_inter_some [Inter \u03b1] (a b : \u03b1) : some a \u2229 some b = some (a \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) ma a) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) mb b) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) (Union.union.{u1} \u03b1 _inst_1 ma mb) (Union.union.{u1} (Part.{u1} \u03b1) (Part.hasUnion.{u1} \u03b1 _inst_1) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) ma a) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) mb b) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) (Union.union.{u1} \u03b1 _inst_1 ma mb) (Union.union.{u1} (Part.{u1} \u03b1) (Part.instUnionPart.{u1} \u03b1 _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.union_mem_union Part.union_mem_union\u2093'. -/\ntheorem union_mem_union [Union \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma \u222a mb \u2208 a \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Union.union.{u1} (Part.{u1} \u03b1) (Part.hasUnion.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Union.union.{u1} (Part.{u1} \u03b1) (Part.instUnionPart.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_union_dom Part.left_dom_of_union_dom\u2093'. -/\ntheorem left_dom_of_union_dom [Union \u03b1] {a b : Part \u03b1} (hab : Dom (a \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Union.union.{u1} (Part.{u1} \u03b1) (Part.hasUnion.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (Union.union.{u1} (Part.{u1} \u03b1) (Part.instUnionPart.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_union_dom Part.right_dom_of_union_dom\u2093'. -/\ntheorem right_dom_of_union_dom [Union \u03b1] {a b : Part \u03b1} (hab : Dom (a \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (Union.union.{u1} (Part.{u1} \u03b1) (Part.hasUnion.{u1} \u03b1 _inst_1) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (Union.union.{u1} (Part.{u1} \u03b1) (Part.hasUnion.{u1} \u03b1 _inst_1) a b) hab) (Union.union.{u1} \u03b1 _inst_1 (Part.get.{u1} \u03b1 a (Part.left_dom_of_union_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_union_dom.{u1} \u03b1 _inst_1 a b hab)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (Union.union.{u1} (Part.{u1} \u03b1) (Part.instUnionPart.{u1} \u03b1 _inst_1) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (Union.union.{u1} (Part.{u1} \u03b1) (Part.instUnionPart.{u1} \u03b1 _inst_1) a b) hab) (Union.union.{u1} \u03b1 _inst_1 (Part.get.{u1} \u03b1 a (Part.left_dom_of_union_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_union_dom.{u1} \u03b1 _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.union_get_eq Part.union_get_eq\u2093'. -/\n@[simp]\ntheorem union_get_eq [Union \u03b1] (a b : Part \u03b1) (hab : Dom (a \u222a b)) :\n    (a \u222a b).get hab = a.get (left_dom_of_union_dom hab) \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (Union.union.{u1} (Part.{u1} \u03b1) (Part.hasUnion.{u1} \u03b1 _inst_1) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (Union.union.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Union.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (Union.union.{u1} (Part.{u1} \u03b1) (Part.instUnionPart.{u1} \u03b1 _inst_1) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (Union.union.{u1} \u03b1 _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align part.some_union_some Part.some_union_some\u2093'. -/\ntheorem some_union_some [Union \u03b1] (a b : \u03b1) : some a \u222a some b = some (a \u222a 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 {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) ma a) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) mb b) -> (Membership.Mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.hasMem.{u1} \u03b1) (SDiff.sdiff.{u1} \u03b1 _inst_1 ma mb) (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.hasSdiff.{u1} \u03b1 _inst_1) a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (ma : \u03b1) (mb : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) ma a) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) mb b) -> (Membership.mem.{u1, u1} \u03b1 (Part.{u1} \u03b1) (Part.instMembershipPart.{u1} \u03b1) (SDiff.sdiff.{u1} \u03b1 _inst_1 ma mb) (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.instSDiffPart.{u1} \u03b1 _inst_1) a b))\nCase conversion may be inaccurate. Consider using '#align part.sdiff_mem_sdiff Part.sdiff_mem_sdiff\u2093'. -/\ntheorem sdiff_mem_sdiff [SDiff \u03b1] (a b : Part \u03b1) (ma mb : \u03b1) (ha : ma \u2208 a) (hb : mb \u2208 b) :\n    ma \\ mb \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.hasSdiff.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.instSDiffPart.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 a)\nCase conversion may be inaccurate. Consider using '#align part.left_dom_of_sdiff_dom Part.left_dom_of_sdiff_dom\u2093'. -/\ntheorem left_dom_of_sdiff_dom [SDiff \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.hasSdiff.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 b)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] {a : Part.{u1} \u03b1} {b : Part.{u1} \u03b1}, (Part.Dom.{u1} \u03b1 (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.instSDiffPart.{u1} \u03b1 _inst_1) a b)) -> (Part.Dom.{u1} \u03b1 b)\nCase conversion may be inaccurate. Consider using '#align part.right_dom_of_sdiff_dom Part.right_dom_of_sdiff_dom\u2093'. -/\ntheorem right_dom_of_sdiff_dom [SDiff \u03b1] {a b : Part \u03b1} (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 {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.hasSdiff.{u1} \u03b1 _inst_1) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.hasSdiff.{u1} \u03b1 _inst_1) a b) hab) (SDiff.sdiff.{u1} \u03b1 _inst_1 (Part.get.{u1} \u03b1 a (Part.left_dom_of_sdiff_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_sdiff_dom.{u1} \u03b1 _inst_1 a b hab)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] (a : Part.{u1} \u03b1) (b : Part.{u1} \u03b1) (hab : Part.Dom.{u1} \u03b1 (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.instSDiffPart.{u1} \u03b1 _inst_1) a b)), Eq.{succ u1} \u03b1 (Part.get.{u1} \u03b1 (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.instSDiffPart.{u1} \u03b1 _inst_1) a b) hab) (SDiff.sdiff.{u1} \u03b1 _inst_1 (Part.get.{u1} \u03b1 a (Part.left_dom_of_sdiff_dom.{u1} \u03b1 _inst_1 a b hab)) (Part.get.{u1} \u03b1 b (Part.right_dom_of_sdiff_dom.{u1} \u03b1 _inst_1 a b hab)))\nCase conversion may be inaccurate. Consider using '#align part.sdiff_get_eq Part.sdiff_get_eq\u2093'. -/\n@[simp]\ntheorem sdiff_get_eq [SDiff \u03b1] (a b : Part \u03b1) (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 {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.hasSdiff.{u1} \u03b1 _inst_1) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (SDiff.sdiff.{u1} \u03b1 _inst_1 a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : SDiff.{u1} \u03b1] (a : \u03b1) (b : \u03b1), Eq.{succ u1} (Part.{u1} \u03b1) (SDiff.sdiff.{u1} (Part.{u1} \u03b1) (Part.instSDiffPart.{u1} \u03b1 _inst_1) (Part.some.{u1} \u03b1 a) (Part.some.{u1} \u03b1 b)) (Part.some.{u1} \u03b1 (SDiff.sdiff.{u1} \u03b1 _inst_1 a b))\nCase conversion may be inaccurate. Consider using '#align part.some_sdiff_some Part.some_sdiff_some\u2093'. -/\ntheorem some_sdiff_some [SDiff \u03b1] (a b : \u03b1) : 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 := \u2203 S : finset M, closure L \u2191S = N\n\ntheorem fg_def {N : L.substructure M} :\n  N.fg \u2194 \u2203 S : set M, S.finite \u2227 closure L S = N :=\n\u27e8\u03bb \u27e8t, h\u27e9, \u27e8_, finset.finite_to_set t, h\u27e9, begin\n  rintro \u27e8t', h, rfl\u27e9,\n  rcases finite.exists_finset_coe h with \u27e8t, rfl\u27e9,\n  exact \u27e8t, rfl\u27e9\nend\u27e9\n\nlemma fg_iff_exists_fin_generating_family {N : L.substructure M} :\n  N.fg \u2194 \u2203 (n : \u2115) (s : fin n \u2192 M), closure L (range s) = N :=\nbegin\n  rw fg_def,\n  split,\n  { rintros \u27e8S, Sfin, hS\u27e9,\n    obtain \u27e8n, f, rfl\u27e9 := Sfin.fin_embedding,\n    exact \u27e8n, f, hS\u27e9, },\n  { rintros \u27e8n, s, hs\u27e9,\n    refine \u27e8range s, finite_range s, hs\u27e9 },\nend\n\ntheorem fg_bot : (\u22a5 : L.substructure M).fg :=\n\u27e8\u2205, by rw [finset.coe_empty, closure_empty]\u27e9\n\ntheorem fg_closure {s : set M} (hs : finite s) : fg (closure L s) :=\n\u27e8hs.to_finset, by rw [hs.coe_to_finset]\u27e9\n\ntheorem fg_closure_singleton (x : M) : fg (closure L ({x} : set M)) :=\nfg_closure (finite_singleton x)\n\ntheorem fg.sup {N\u2081 N\u2082 : L.substructure M}\n  (hN\u2081 : N\u2081.fg) (hN\u2082 : N\u2082.fg) : (N\u2081 \u2294 N\u2082).fg :=\nlet \u27e8t\u2081, ht\u2081\u27e9 := fg_def.1 hN\u2081, \u27e8t\u2082, ht\u2082\u27e9 := fg_def.1 hN\u2082 in\nfg_def.2 \u27e8t\u2081 \u222a t\u2082, ht\u2081.1.union ht\u2082.1, by rw [closure_union, ht\u2081.2, ht\u2082.2]\u27e9\n\ntheorem fg.map {N : Type*} [L.Structure N] (f : M \u2192[L] N) {s : L.substructure M} (hs : s.fg) :\n  (s.map f).fg :=\nlet \u27e8t, ht\u27e9 := fg_def.1 hs in fg_def.2 \u27e8f '' t, ht.1.image _, by rw [closure_image, ht.2]\u27e9\n\ntheorem fg.of_map_embedding {N : Type*} [L.Structure N] (f : M \u21aa[L] N) {s : L.substructure M}\n  (hs : (s.map f.to_hom).fg) : s.fg :=\nbegin\n  rcases hs with \u27e8t, h\u27e9,\n  rw fg_def,\n  refine \u27e8f \u207b\u00b9' t, t.finite_to_set.preimage (f.injective.inj_on _), _\u27e9,\n  have hf : function.injective f.to_hom := f.injective,\n  refine map_injective_of_injective hf _,\n  rw [\u2190 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 := \u2203 S : set M, S.countable \u2227 closure L S = N\n\n\n\ntheorem fg.cg {N : L.substructure M} (h : N.fg) : N.cg :=\nbegin\n  obtain \u27e8s, hf, rfl\u27e9 := fg_def.1 h,\n  refine \u27e8s, hf.countable, rfl\u27e9,\nend\n\nlemma cg_iff_empty_or_exists_nat_generating_family {N : L.substructure M} :\n  N.cg \u2194 (\u2191N = (\u2205 : set M)) \u2228 \u2203 (s : \u2115 \u2192 M), closure L (range s) = N :=\nbegin\n  rw cg_def,\n  split,\n  { rintros \u27e8S, Scount, hS\u27e9,\n    cases eq_empty_or_nonempty \u2191N with h h,\n    { exact or.intro_left _ h },\n    obtain \u27e8f, h'\u27e9 := (Scount.union (set.countable_singleton h.some)).exists_surjective\n      (singleton_nonempty h.some).inr,\n    refine or.intro_right _ \u27e8f, _\u27e9,\n    rw [\u2190 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 \u27e8\u2205, countable_empty, closure_eq_of_le (empty_subset _) _\u27e9,\n      rw [\u2190 set_like.coe_subset_coe, h],\n      exact empty_subset _ },\n    { obtain \u27e8f, rfl\u27e9 := h,\n      exact \u27e8range f, countable_range _, rfl\u27e9 } },\nend\n\ntheorem cg_bot : (\u22a5 : L.substructure M).cg := fg_bot.cg\n\ntheorem cg_closure {s : set M} (hs : s.countable) : cg (closure L s) :=\n\u27e8s, hs, rfl\u27e9\n\ntheorem cg_closure_singleton (x : M) : cg (closure L ({x} : set M)) := (fg_closure_singleton x).cg\n\ntheorem cg.sup {N\u2081 N\u2082 : L.substructure M}\n  (hN\u2081 : N\u2081.cg) (hN\u2082 : N\u2082.cg) : (N\u2081 \u2294 N\u2082).cg :=\nlet \u27e8t\u2081, ht\u2081\u27e9 := cg_def.1 hN\u2081, \u27e8t\u2082, ht\u2082\u27e9 := cg_def.1 hN\u2082 in\ncg_def.2 \u27e8t\u2081 \u222a t\u2082, ht\u2081.1.union ht\u2082.1, by rw [closure_union, ht\u2081.2, ht\u2082.2]\u27e9\n\ntheorem cg.map {N : Type*} [L.Structure N] (f : M \u2192[L] N) {s : L.substructure M} (hs : s.cg) :\n  (s.map f).cg :=\nlet \u27e8t, ht\u27e9 := cg_def.1 hs in cg_def.2 \u27e8f '' t, ht.1.image _, by rw [closure_image, ht.2]\u27e9\n\ntheorem cg.of_map_embedding {N : Type*} [L.Structure N] (f : M \u21aa[L] N) {s : L.substructure M}\n  (hs : (s.map f.to_hom).cg) : s.cg :=\nbegin\n  rcases hs with \u27e8t, h1, h2\u27e9,\n  rw cg_def,\n  refine \u27e8f \u207b\u00b9' t, h1.preimage f.injective, _\u27e9,\n  have hf : function.injective f.to_hom := f.injective,\n  refine map_injective_of_injective hf _,\n  rw [\u2190 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 \u2194 nonempty (encodable s) :=\nbegin\n  refine \u27e8_, \u03bb h, \u27e8s, h, s.closure_eq\u27e9\u27e9,\n  rintro \u27e8s, h, rfl\u27e9,\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 : (\u22a4 : L.substructure M).fg)\n\n/-- A structure is countably generated if it is the closure of a countable subset. -/\nclass cg : Prop := (out : (\u22a4 : L.substructure M).cg)\n\nvariables {L M}\n\nlemma fg_def : fg L M \u2194 (\u22a4 : L.substructure M).fg := \u27e8\u03bb h, h.1, \u03bb h, \u27e8h\u27e9\u27e9\n\n/-- An equivalent expression of `Structure.fg` in terms of `set.finite` instead of `finset`. -/\nlemma fg_iff : fg L M \u2194 \u2203 S : set M, S.finite \u2227 closure L S = (\u22a4 : 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 \u2192[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 \u2192[L] N)\n  (hs : function.surjective f) :\n  fg L N :=\nbegin\n  rw \u2190 hom.range_eq_top at hs,\n  rw [fg_def, \u2190 hs],\n  exact h.range f,\nend\n\n\n\n/-- An equivalent expression of `Structure.cg`. -/\nlemma cg_iff : cg L M \u2194 \u2203 S : set M, S.countable \u2227 closure L S = (\u22a4 : 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 \u2192[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 \u2192[L] N)\n  (hs : function.surjective f) :\n  cg L N :=\nbegin\n  rw \u2190 hom.range_eq_top at hs,\n  rw [cg_def, \u2190 hs],\n  exact h.range f,\nend\n\nlemma cg_iff_countable [L.countable_functions] :\n  cg L M \u2194 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 \u2243[L] N) :\n  Structure.fg L M \u2194 Structure.fg L N :=\n\u27e8\u03bb h, h.map_of_surjective f.to_hom f.to_equiv.surjective,\n  \u03bb h, h.map_of_surjective f.symm.to_hom f.to_equiv.symm.surjective\u27e9\n\nlemma substructure.fg_iff_Structure_fg (S : L.substructure M) :\n  S.fg \u2194 Structure.fg L S :=\nbegin\n  rw Structure.fg_def,\n  refine \u27e8\u03bb h, fg.of_map_embedding S.subtype _, \u03bb h, _\u27e9,\n  { rw [\u2190 hom.range_eq_map, range_subtype],\n    exact h },\n  { have h := h.map S.subtype.to_hom,\n    rw [\u2190 hom.range_eq_map, range_subtype] at h,\n    exact h }\nend\n\nlemma equiv.cg_iff {N : Type*} [L.Structure N] (f : M \u2243[L] N) :\n  Structure.cg L M \u2194 Structure.cg L N :=\n\u27e8\u03bb h, h.map_of_surjective f.to_hom f.to_equiv.surjective,\n  \u03bb h, h.map_of_surjective f.symm.to_hom f.to_equiv.symm.surjective\u27e9\n\nlemma substructure.cg_iff_Structure_cg (S : L.substructure M) :\n  S.cg \u2194 Structure.cg L S :=\nbegin\n  rw Structure.cg_def,\n  refine \u27e8\u03bb h, cg.of_map_embedding S.subtype _, \u03bb h, _\u27e9,\n  { rw [\u2190 hom.range_eq_map, range_subtype],\n    exact h },\n  { have h := h.map S.subtype.to_hom,\n    rw [\u2190 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u00a75 (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' {\u03b1 \u03b2} : option \u03b1 \u2192 \u03b2 \u2192 (\u03b1 \u2192 \u03b2) \u2192 \u03b2\n| none     n s := n\n| (some a) n s := s a\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n\nsection is_sum\nvariables [add_comm_monoid \u03b1] [topological_space \u03b1] [topological_add_monoid \u03b1]\n\n/-- Infinite sum on a topological monoid\nThe `at_top` filter on `finset \u03b1` 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 : \u03b2 \u2192 \u03b1) (a : \u03b1) : Prop := tendsto (\u03bbs:finset \u03b2, 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 : \u03b2 \u2192 \u03b1) : Prop := \u2203a, is_sum f a\n\n/-- `tsum f` is the sum of `f` it exists, or 0 otherwise -/\ndef tsum (f : \u03b2 \u2192 \u03b1) := if h : has_sum f then classical.some h else 0\n\nnotation `\u2211` binders `, ` r:(scoped f, tsum f) := r\n\nvariables {f g : \u03b2 \u2192 \u03b1} {a b : \u03b1} {s : finset \u03b2}\n\nlemma is_sum_tsum (ha : has_sum f) : is_sum f (\u2211b, f b) :=\nby simp [ha, tsum]; exact some_spec ha\n\nlemma has_sum_spec (ha : is_sum f a) : has_sum f := \u27e8a, ha\u27e9\n\nlemma is_sum_zero : is_sum (\u03bbb, 0 : \u03b2 \u2192 \u03b1) 0 :=\nby simp [is_sum, tendsto_const_nhds]\n\nlemma has_sum_zero : has_sum (\u03bbb, 0 : \u03b2 \u2192 \u03b1) := has_sum_spec is_sum_zero\n\nlemma is_sum_add (hf : is_sum f a) (hg : is_sum g b) : is_sum (\u03bbb, 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 (\u03bbb, f b + g b) :=\nhas_sum_spec $ is_sum_add (is_sum_tsum hf)(is_sum_tsum hg)\n\nlemma is_sum_sum {f : \u03b3 \u2192 \u03b2 \u2192 \u03b1} {a : \u03b3 \u2192 \u03b1} {s : finset \u03b3} :\n  (\u2200i\u2208s, is_sum (f i) (a i)) \u2192 is_sum (\u03bbb, s.sum $ \u03bbi, 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 : \u03b3 \u2192 \u03b2 \u2192 \u03b1} {s : finset \u03b3} (hf : \u2200i\u2208s, has_sum (f i)) :\n  has_sum (\u03bbb, s.sum $ \u03bbi, 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 : \u2200b\u2209s, f b = 0) : is_sum f (s.sum f) :=\ntendsto_infi' s $ tendsto.congr'\n  (assume t (ht : s \u2286 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 : \u2200b\u2209s, f b = 0) : has_sum f :=\nhas_sum_spec $ is_sum_sum_of_ne_finset_zero hf\n\nlemma is_sum_ite_eq (b : \u03b2) (a : \u03b1) : is_sum (\u03bbb', if b' = b then a else 0) a :=\nsuffices\n  is_sum (\u03bbb', if b' = b then a else 0) (({b} : finset \u03b2).sum (\u03bbb', if b' = b then a else 0)), from\n  by simpa,\nis_sum_sum_of_ne_finset_zero $ assume b' hb,\n  have b' \u2260 b, by simpa using hb,\n  by rw [if_neg this]\n\nlemma is_sum_of_iso {j : \u03b3 \u2192 \u03b2} {i : \u03b2 \u2192 \u03b3}\n  (hf : is_sum f a) (h\u2081 : \u2200x, i (j x) = x) (h\u2082 : \u2200x, j (i x) = x) : is_sum (f \u2218 j) a :=\nhave \u2200x y, j x = j y \u2192 x = y,\n  from assume x y h,\n  have i (j x) = i (j y), by rw [h],\n  by rwa [h\u2081, h\u2081] at this,\nhave (\u03bbs:finset \u03b3, s.sum (f \u2218 j)) = (\u03bbs:finset \u03b2, s.sum f) \u2218 (\u03bbs:finset \u03b3, s.image j),\n  from funext $ assume s, (sum_image $ assume x _ y _, this x y).symm,\nshow tendsto (\u03bbs:finset \u03b3, s.sum (f \u2218 j)) at_top (nhds a),\n   by rw [this]; apply (tendsto_finset_image_at_top_at_top h\u2082).comp hf\n\nlemma is_sum_iff_is_sum_of_iso {j : \u03b3 \u2192 \u03b2} (i : \u03b2 \u2192 \u03b3)\n  (h\u2081 : \u2200x, i (j x) = x) (h\u2082 : \u2200x, j (i x) = x) :\n  is_sum (f \u2218 j) a \u2194 is_sum f a :=\niff.intro\n  (assume hfj,\n    have is_sum ((f \u2218 j) \u2218 i) a, from is_sum_of_iso hfj h\u2082 h\u2081,\n    by simp [(\u2218), h\u2082] at this; assumption)\n  (assume hf, is_sum_of_iso hf h\u2081 h\u2082)\n\nlemma is_sum_hom (g : \u03b1 \u2192 \u03b3) [add_comm_monoid \u03b3] [topological_space \u03b3] [topological_add_monoid \u03b3]\n  [is_add_monoid_hom g] (h\u2083 : continuous g) (hf : is_sum f a) :\n  is_sum (g \u2218 f) (g a) :=\nhave (\u03bbs:finset \u03b2, s.sum (g \u2218 f)) = g \u2218 (\u03bbs:finset \u03b2, s.sum f),\n  from funext $ assume s, sum_hom g,\nshow tendsto (\u03bbs:finset \u03b2, s.sum (g \u2218 f)) at_top (nhds (g a)),\n  by rw [this]; exact hf.comp (continuous_iff_continuous_at.mp h\u2083 a)\n\nlemma tendsto_sum_nat_of_is_sum {f : \u2115 \u2192 \u03b1} (h : is_sum f a) :\n  tendsto (\u03bbn:\u2115, (range n).sum f) at_top (nhds a) :=\nsuffices map (\u03bb (n : \u2115), sum (range n) f) at_top \u2264 map (\u03bb (s : finset \u2115), sum s f) at_top,\n  from le_trans this h,\nassume s (hs : {t : finset \u2115 | t.sum f \u2208 s} \u2208 at_top),\nlet \u27e8t, ht\u27e9 := mem_at_top_sets.mp hs, \u27e8n, hn\u27e9 := @exists_nat_subset_range t in\nmem_at_top_sets.mpr \u27e8n, assume n' hn', ht _ $ finset.subset.trans hn $ range_subset.mpr hn'\u27e9\n\nlemma is_sum_sigma [regular_space \u03b1] {\u03b3 : \u03b2 \u2192 Type*} {f : (\u03a3 b:\u03b2, \u03b3 b) \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} {a : \u03b1}\n  (hf : \u2200b, is_sum (\u03bbc, f \u27e8b, c\u27e9) (g b)) (ha : is_sum f a) : is_sum g a :=\nassume s' hs',\nlet\n  \u27e8s, hs, hss', hsc\u27e9 := nhds_is_closed hs',\n  \u27e8u, hu\u27e9 := mem_at_top_sets.mp $ ha $ hs,\n  fsts := u.image sigma.fst,\n  snds := \u03bbb, u.bind (\u03bbp, (if h : p.1 = b then {cast (congr_arg \u03b3 h) p.2} else \u2205 : finset (\u03b3 b)))\nin\nhave u_subset : u \u2286 fsts.sigma snds,\n  from subset_iff.mpr $ assume \u27e8b, c\u27e9 hu,\n  have hb : b \u2208 fsts, from finset.mem_image.mpr \u27e8_, hu, rfl\u27e9,\n  have hc : c \u2208 snds b, from mem_bind.mpr \u27e8_, hu, by simp; refl\u27e9,\n  by simp [mem_sigma, hb, hc] ,\nmem_at_top_sets.mpr $ exists.intro fsts $ assume bs (hbs : fsts \u2286 bs),\n  have h : \u2200cs : \u03a0 b \u2208 bs, finset (\u03b3 b),\n      (\u22c2b (hb : b \u2208 bs), (\u03bbp:\u03a0b, finset (\u03b3 b), p b) \u207b\u00b9' {cs' | cs b hb \u2286 cs' }) \u2229\n      (\u03bbp, bs.sum (\u03bbb, (p b).sum (\u03bbc, f \u27e8b, c\u27e9))) \u207b\u00b9' s \u2260 \u2205,\n    from assume cs,\n    let cs' := \u03bbb, (if h : b \u2208 bs then cs b h else \u2205) \u222a snds b in\n    have sum_eq : bs.sum (\u03bbb, (cs' b).sum (\u03bbc, f \u27e8b, c\u27e9)) = (bs.sigma cs').sum f,\n      from sum_sigma.symm,\n    have (bs.sigma cs').sum f \u2208 s,\n      from hu _ $ finset.subset.trans u_subset $ sigma_mono hbs $\n        assume b, @finset.subset_union_right (\u03b3 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 (\u03bbp:(\u03a0b:\u03b2, finset (\u03b3 b)), bs.sum (\u03bbb, (p b).sum (\u03bbc, f \u27e8b, c\u27e9)))\n      (\u2a05b (h : b \u2208 bs), at_top.comap (\u03bbp, 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 \u2208 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\u2081 s\u2082 s\u2083 hs\u2081 hs\u2083 p hs\u2082 p' hp cs hp',\n        have (\u22c2b (h : b \u2208 bs), (\u03bbp:(\u03a0b, finset (\u03b3 b)), p b) \u207b\u00b9' {cs' | cs b h \u2286 cs' }) \u2264 (\u2a05b\u2208bs, 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\u2082) hs\u2083) hs\u2081),\n  hss' this\n\nlemma has_sum_sigma [regular_space \u03b1] {\u03b3 : \u03b2 \u2192 Type*} {f : (\u03a3b:\u03b2, \u03b3 b) \u2192 \u03b1}\n  (hf : \u2200b, has_sum (\u03bbc, f \u27e8b, c\u27e9)) (ha : has_sum f) : has_sum (\u03bbb, \u2211c, f \u27e8b, c\u27e9):=\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 \u03b1] [topological_space \u03b1] [topological_add_monoid \u03b1]\nvariables {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1} {a : \u03b1}\n\nlemma is_sum_of_is_sum\n  (h_eq : \u2200u:finset \u03b3, \u2203v:finset \u03b2, \u2200v', v \u2286 v' \u2192 \u2203u', u \u2286 u' \u2227 u'.sum g = v'.sum f)\n  (hf : is_sum g a) : is_sum f a :=\nsuffices at_top.map (\u03bbs:finset \u03b2, s.sum f) \u2264 at_top.map (\u03bbs:finset \u03b3, 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 \u27e8v, hv\u27e9 := 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\u2081 : \u2200u:finset \u03b3, \u2203v:finset \u03b2, \u2200v', v \u2286 v' \u2192 \u2203u', u \u2286 u' \u2227 u'.sum g = v'.sum f)\n  (h\u2082 : \u2200v:finset \u03b2, \u2203u:finset \u03b3, \u2200u', u \u2286 u' \u2192 \u2203v', v \u2286 v' \u2227 v'.sum f = u'.sum g) :\n  is_sum f a \u2194 is_sum g a :=\n\u27e8is_sum_of_is_sum h\u2082, is_sum_of_is_sum h\u2081\u27e9\n\nvariables\n  (i : \u03a0\u2983c\u2984, g c \u2260 0 \u2192 \u03b2) (hi : \u2200\u2983c\u2984 (h : g c \u2260 0), f (i h) \u2260 0)\n  (j : \u03a0\u2983b\u2984, f b \u2260 0 \u2192 \u03b3) (hj : \u2200\u2983b\u2984 (h : f b \u2260 0), g (j h) \u2260 0)\n  (hji : \u2200\u2983c\u2984 (h : g c \u2260 0), j (hi h) = c)\n  (hij : \u2200\u2983b\u2984 (h : f b \u2260 0), i (hj h) = b)\n  (hgj : \u2200\u2983b\u2984 (h : f b \u2260 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 \u2192 is_sum f a :=\nhave j_inj : \u2200x y (hx : f x \u2260 0) (hy : f y \u2260 0), (j hx = j hy \u2194 x = y),\n  from assume x y hx hy,\n  \u27e8assume 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}\u27e9,\nlet ii : finset \u03b3 \u2192 finset \u03b2 := \u03bbu, u.bind $ \u03bbc, if h : g c = 0 then \u2205 else {i h} in\nlet jj : finset \u03b2 \u2192 finset \u03b3 := \u03bbv, v.bind $ \u03bbb, if h : f b = 0 then \u2205 else {j h} in\nis_sum_of_is_sum $ assume u, exists.intro (ii u) $\n  assume v hv, exists.intro (u \u222a jj v) $ and.intro (subset_union_left _ _) $\n  have \u2200c:\u03b3, c \u2208 u \u222a jj v \u2192 c \u2209 jj v \u2192 g c = 0,\n    from assume c hc hnc, classical.by_contradiction $ assume h : g c \u2260 0,\n    have c \u2208 u,\n      from (finset.mem_union.1 hc).resolve_right hnc,\n    have i h \u2208 v,\n      from hv $ by simp [mem_bind]; existsi c; simp [h, this],\n    have j (hi h) \u2208 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 \u222a 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 \u2194 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 [\u2190hgj (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 \u2194 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 [\u2190hgj (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 \u03b1] [topological_space \u03b1] [topological_add_monoid \u03b1]\nvariables {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1} {a : \u03b1}\n  (i : \u03a0\u2983c\u2984, g c \u2260 0 \u2192 \u03b2)\n  (h\u2081 : \u2200\u2983c\u2081 c\u2082\u2984 (h\u2081 : g c\u2081 \u2260 0) (h\u2082 : g c\u2082 \u2260 0), i h\u2081 = i h\u2082 \u2192 c\u2081 = c\u2082)\n  (h\u2082 : \u2200\u2983b\u2984, f b \u2260 0 \u2192 \u2203c (h : g c \u2260 0), i h = b)\n  (h\u2083 : \u2200\u2983c\u2984 (h : g c \u2260 0), f (i h) = g c)\ninclude i h\u2081 h\u2082 h\u2083\n\nlemma is_sum_iff_is_sum_of_ne_zero_bij : is_sum f a \u2194 is_sum g a :=\nhave hi : \u2200\u2983c\u2984 (h : g c \u2260 0), f (i h) \u2260 0,\n  from assume c h, by simp [h\u2083, h],\nlet j : \u03a0\u2983b\u2984, f b \u2260 0 \u2192 \u03b3 := \u03bbb h, some $ h\u2082 h in\nhave hj : \u2200\u2983b\u2984 (h : f b \u2260 0), \u2203(h : g (j h) \u2260 0), i h = b,\n  from assume b h, some_spec $ h\u2082 h,\nhave hj\u2081 : \u2200\u2983b\u2984 (h : f b \u2260 0), g (j h) \u2260 0,\n  from assume b h, let \u27e8h\u2081, _\u27e9 := hj h in h\u2081,\nhave hj\u2082 : \u2200\u2983b\u2984 (h : f b \u2260 0), i (hj\u2081 h) = b,\n  from assume b h, let \u27e8h\u2081, h\u2082\u27e9 := hj h in h\u2082,\nis_sum_iff_is_sum_of_ne_zero i hi j hj\u2081\n  (assume c h, h\u2081 (hj\u2081 _) h $ hj\u2082 _) hj\u2082 (assume b h, by rw [\u2190h\u2083 (hj\u2081 _), hj\u2082])\n\nlemma has_sum_iff_has_sum_ne_zero_bij : has_sum f \u2194 has_sum g :=\nexists_congr $\n  assume a, is_sum_iff_is_sum_of_ne_zero_bij @i h\u2081 h\u2082 h\u2083\n\nend is_sum_iff_is_sum_of_bij_ne_zero\n\nsection tsum\nvariables [add_comm_monoid \u03b1] [topological_space \u03b1] [topological_add_monoid \u03b1] [t2_space \u03b1]\nvariables {f g : \u03b2 \u2192 \u03b1} {a a\u2081 a\u2082 : \u03b1}\n\nlemma is_sum_unique : is_sum f a\u2081 \u2192 is_sum f a\u2082 \u2192 a\u2081 = a\u2082 := tendsto_nhds_unique at_top_ne_bot\n\nlemma tsum_eq_is_sum (ha : is_sum f a) : (\u2211b, f b) = a := is_sum_unique (is_sum_tsum \u27e8a, ha\u27e9) ha\n\nlemma is_sum_iff_of_has_sum (h : has_sum f) : is_sum f a \u2194 (\u2211b, f b) = a :=\niff.intro tsum_eq_is_sum (assume eq, eq \u25b8 is_sum_tsum h)\n\n@[simp] lemma tsum_zero : (\u2211b:\u03b2, 0:\u03b1) = 0 := tsum_eq_is_sum is_sum_zero\n\nlemma tsum_add (hf : has_sum f) (hg : has_sum g) : (\u2211b, f b + g b) = (\u2211b, f b) + (\u2211b, g b) :=\ntsum_eq_is_sum $ is_sum_add (is_sum_tsum hf) (is_sum_tsum hg)\n\nlemma tsum_sum {f : \u03b3 \u2192 \u03b2 \u2192 \u03b1} {s : finset \u03b3} (hf : \u2200i\u2208s, has_sum (f i)) :\n  (\u2211b, s.sum (\u03bbi, f i b)) = s.sum (\u03bbi, \u2211b, 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 : \u03b2 \u2192 \u03b1} {s : finset \u03b2} (hf : \u2200b\u2209s, f b = 0)  :\n  (\u2211b, f b) = s.sum f :=\ntsum_eq_is_sum $ is_sum_sum_of_ne_finset_zero hf\n\nlemma tsum_fintype [fintype \u03b2] (f : \u03b2 \u2192 \u03b1) : (\u2211b, f b) = finset.univ.sum f :=\ntsum_eq_sum $ \u03bb a h, h.elim (mem_univ _)\n\nlemma tsum_eq_single {f : \u03b2 \u2192 \u03b1} (b : \u03b2) (hf : \u2200b' \u2260 b, f b' = 0)  :\n  (\u2211b, f b) = f b :=\ncalc (\u2211b, 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 \u03b1] {\u03b3 : \u03b2 \u2192 Type*} {f : (\u03a3b:\u03b2, \u03b3 b) \u2192 \u03b1}\n  (h\u2081 : \u2200b, has_sum (\u03bbc, f \u27e8b, c\u27e9)) (h\u2082 : has_sum f) : (\u2211p, f p) = (\u2211b c, f \u27e8b, c\u27e9):=\n(tsum_eq_is_sum $ is_sum_sigma (assume b, is_sum_tsum $ h\u2081 b) $ is_sum_tsum h\u2082).symm\n\n@[simp] lemma tsum_ite_eq (b : \u03b2) (a : \u03b1) : (\u2211b', 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 : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1}\n  (h : \u2200{a}, is_sum f a \u2194 is_sum g a) : (\u2211b, f b) = (\u2211c, g c) :=\nby_cases\n  (assume : \u2203a, is_sum f a,\n    let \u27e8a, hfa\u27e9 := 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 : \u00ac has_sum f,\n    have hg : \u00ac has_sum g, from assume \u27e8a, hga\u27e9, hf \u27e8a, h.mpr hga\u27e9,\n    by simp [tsum, hf, hg])\n\nlemma tsum_eq_tsum_of_ne_zero {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1}\n  (i : \u03a0\u2983c\u2984, g c \u2260 0 \u2192 \u03b2) (hi : \u2200\u2983c\u2984 (h : g c \u2260 0), f (i h) \u2260 0)\n  (j : \u03a0\u2983b\u2984, f b \u2260 0 \u2192 \u03b3) (hj : \u2200\u2983b\u2984 (h : f b \u2260 0), g (j h) \u2260 0)\n  (hji : \u2200\u2983c\u2984 (h : g c \u2260 0), j (hi h) = c)\n  (hij : \u2200\u2983b\u2984 (h : f b \u2260 0), i (hj h) = b)\n  (hgj : \u2200\u2983b\u2984 (h : f b \u2260 0), g (j h) = f b) :\n  (\u2211i, f i) = (\u2211j, 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 : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1}\n  (i : \u03a0\u2983c\u2984, g c \u2260 0 \u2192 \u03b2)\n  (h\u2081 : \u2200\u2983c\u2081 c\u2082\u2984 (h\u2081 : g c\u2081 \u2260 0) (h\u2082 : g c\u2082 \u2260 0), i h\u2081 = i h\u2082 \u2192 c\u2081 = c\u2082)\n  (h\u2082 : \u2200\u2983b\u2984, f b \u2260 0 \u2192 \u2203c (h : g c \u2260 0), i h = b)\n  (h\u2083 : \u2200\u2983c\u2984 (h : g c \u2260 0), f (i h) = g c) :\n  (\u2211i, f i) = (\u2211j, g j) :=\ntsum_eq_tsum_of_is_sum_iff_is_sum $ assume a, is_sum_iff_is_sum_of_ne_zero_bij i h\u2081 h\u2082 h\u2083\n\nlemma tsum_eq_tsum_of_iso (j : \u03b3 \u2192 \u03b2) (i : \u03b2 \u2192 \u03b3)\n  (h\u2081 : \u2200x, i (j x) = x) (h\u2082 : \u2200x, j (i x) = x) :\n  (\u2211c, f (j c)) = (\u2211b, f b) :=\ntsum_eq_tsum_of_is_sum_iff_is_sum $ assume a, is_sum_iff_is_sum_of_iso i h\u2081 h\u2082\n\nlemma tsum_equiv (j : \u03b3 \u2243 \u03b2) : (\u2211c, f (j c)) = (\u2211b, 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 \u03b1] [topological_space \u03b1] [topological_add_group \u03b1]\nvariables {f g : \u03b2 \u2192 \u03b1} {a a\u2081 a\u2082 : \u03b1}\n\nlemma is_sum_neg : is_sum f a \u2192 is_sum (\u03bbb, - f b) (- a) :=\nis_sum_hom has_neg.neg continuous_neg'\n\nlemma has_sum_neg (hf : has_sum f) : has_sum (\u03bbb, - f b) :=\nhas_sum_spec $ is_sum_neg $ is_sum_tsum $ hf\n\nlemma is_sum_sub (hf : is_sum f a\u2081) (hg : is_sum g a\u2082) : is_sum (\u03bbb, f b - g b) (a\u2081 - a\u2082) :=\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 (\u03bbb, f b - g b) :=\nhas_sum_spec $ is_sum_sub (is_sum_tsum hf) (is_sum_tsum hg)\n\nsection tsum\nvariables [t2_space \u03b1]\n\nlemma tsum_neg (hf : has_sum f) : (\u2211b, - f b) = - (\u2211b, 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) : (\u2211b, f b - g b) = (\u2211b, f b) - (\u2211b, 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 \u03b1] [topological_space \u03b1] [topological_semiring \u03b1]\nvariables {f g : \u03b2 \u2192 \u03b1} {a a\u2081 a\u2082 : \u03b1}\n\nlemma is_sum_mul_left (a\u2082) : is_sum f a\u2081 \u2192 is_sum (\u03bbb, a\u2082 * f b) (a\u2082 * a\u2081) :=\nis_sum_hom _ (continuous_mul continuous_const continuous_id)\n\nlemma is_sum_mul_right (a\u2082) (hf : is_sum f a\u2081) : is_sum (\u03bbb, f b * a\u2082) (a\u2081 * a\u2082) :=\n@is_sum_hom _ _ _ _ _ _ f a\u2081 (\u03bba, a * a\u2082) _ _ _ _\n  (continuous_mul continuous_id continuous_const) hf\n\nlemma has_sum_mul_left (a) (hf : has_sum f) : has_sum (\u03bbb, 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 (\u03bbb, f b * a) :=\nhas_sum_spec $ is_sum_mul_right _ $ is_sum_tsum hf\n\nsection tsum\nvariables [t2_space \u03b1]\n\nlemma tsum_mul_left (a) (hf : has_sum f) : (\u2211b, a * f b) = a * (\u2211b, f b) :=\ntsum_eq_is_sum $ is_sum_mul_left _ $ is_sum_tsum hf\n\nlemma tsum_mul_right (a) (hf : has_sum f) : (\u2211b, f b * a) = (\u2211b, 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 \u03b1] [topological_space \u03b1] [ordered_topology \u03b1]\n  [topological_add_monoid \u03b1]\nvariables {f g : \u03b2 \u2192 \u03b1} {a a\u2081 a\u2082 : \u03b1}\n\nlemma is_sum_le (h : \u2200b, f b \u2264 g b) (hf : is_sum f a\u2081) (hg : is_sum g a\u2082) : a\u2081 \u2264 a\u2082 :=\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 : \u03b3 \u2192 \u03b1} (i : \u03b2 \u2192 \u03b3) (hi : injective i) (hs : \u2200c\u2209set.range i, 0 \u2264 g c)\n  (h : \u2200b, f b \u2264 g (i b)) (hf : is_sum f a\u2081) (hg : is_sum g a\u2082) : a\u2081 \u2264 a\u2082 :=\nhave is_sum (\u03bbc, (partial_inv i c).cases_on' 0 f) a\u2081,\nbegin\n  refine (is_sum_iff_is_sum_of_ne_zero_bij (\u03bbb _, i b) _ _ _).2 hf,\n  { assume c\u2081 c\u2082 h\u2081 h\u2082 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 \u27e8b, hc, eq\u27e9 } },\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 \u2208 set.range i,\n  { rcases h with \u27e8b, rfl\u27e9,\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 : \u2200b, f b \u2264 g b) (hf : has_sum f) (hg : has_sum g) : (\u2211b, f b) \u2264 (\u2211b, 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 \u03b1] [uniform_space \u03b1] [complete_space \u03b1] [uniform_add_group \u03b1]\nvariables (f g : \u03b2 \u2192 \u03b1) {a a\u2081 a\u2082 : \u03b1}\n\nlemma has_sum_iff_cauchy : has_sum f \u2194 cauchy (map (\u03bb (s : finset \u03b2), 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 \u2194 \u2200 e \u2208 nhds (0:\u03b1), (\u2203s:finset \u03b2, \u2200t, disjoint t s \u2192 t.sum f \u2208 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 \u03b1, tendsto_comap_iff, (\u2218)],\n  rw [tendsto_at_top' (_ : finset \u03b2 \u00d7 finset \u03b2 \u2192 \u03b1)],\n  split,\n  { assume h e he,\n    rcases h e he with \u27e8\u27e8s\u2081, s\u2082\u27e9, h\u27e9,\n    use [s\u2081 \u222a s\u2082],\n    assume t ht,\n    have : (s\u2081 \u222a s\u2082) \u2229 t = \u2205 := finset.disjoint_iff_inter_eq_empty.1 ht.symm,\n    specialize h (s\u2081 \u222a s\u2082, (s\u2081 \u222a s\u2082) \u222a t) \u27e8le_sup_left, le_sup_left_of_le le_sup_right\u27e9,\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 \u27e8d, hd, hde\u27e9,\n    rcases h d hd with \u27e8s, h\u27e9,\n    use [(s, s)],\n    rintros \u27e8t\u2081, t\u2082\u27e9 \u27e8ht\u2081, ht\u2082\u27e9,\n    have : t\u2082.sum f - t\u2081.sum f = (t\u2082 \\ s).sum f - (t\u2081 \\ s).sum f,\n    { simp only [(finset.sum_sdiff ht\u2081).symm, (finset.sum_sdiff ht\u2082).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 : \u2200b, g b = 0 \u2228 g b = f b) : has_sum g :=\n(has_sum_iff_vanishing g).2 $\n  assume e he,\n  let \u27e8s, hs\u27e9 := (has_sum_iff_vanishing f).1 hf e he in\n  \u27e8s, assume t ht,\n    have eq : (t.filter (\u03bbb, g b = f b)).sum f = t.sum g :=\n      calc (t.filter (\u03bbb, g b = f b)).sum f = (t.filter (\u03bbb, 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 [(\u2209), finset.mem_filter, and_iff_right hbt] at hb,\n          exact (h b).resolve_right hb\n        end,\n    eq \u25b8 hs _ $ finset.disjoint_of_subset_left (finset.filter_subset _) ht\u27e9\n\nlemma has_sum_comp_of_has_sum_of_injective {i : \u03b3 \u2192 \u03b2} (hf : has_sum f) (hi : injective i) :\n  has_sum (f \u2218 i) :=\nsuffices has_sum (\u03bbb, if b \u2208 set.range i then f b else 0),\nbegin\n  refine (has_sum_iff_has_sum_ne_zero_bij (\u03bbc _, i c) _ _ _).1 this,\n  { assume c\u2081 c\u2082 hc\u2081 hc\u2082 eq, exact hi eq },\n  { assume b hb,\n    split_ifs at hb,\n    { rcases h with \u27e8c, rfl\u27e9,\n      exact \u27e8c, hb, rfl\u27e9 },\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 \u2208 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 \u03b1] {f : \u2115 \u2192 \u03b1}\n  (h : has_sum (\u03bbn, dist (f n) (f n.succ))) : cauchy_seq f :=\nbegin\n  let d := \u03bbn, dist (f n) (f (n+1)),\n  refine metric.cauchy_seq_iff'.2 (\u03bb\u03b5 \u03b5pos, _),\n  rcases (has_sum_iff_vanishing _).1 h {x : \u211d | x < \u03b5} (gt_mem_nhds \u03b5pos) with \u27e8s, hs\u27e9,\n  have : \u2203N:\u2115, \u2200x \u2208 s, x < N,\n  { by_cases h : s = \u2205,\n    { use 0, simp [h]},\n    { use s.max' h + 1,\n      exact \u03bbx hx, lt_of_le_of_lt (s.le_max' h x hx) (nat.lt_succ_self _) }},\n  rcases this with \u27e8N, hN\u27e9,\n  refine \u27e8N, \u03bbn hn, _\u27e9,\n  have : \u2200n, n \u2265 N \u2192 dist (f N) (f n) \u2264 (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)) \u2264 dist (f N) (f n) + d n : dist_triangle _ _ _\n        ... \u2264 (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) \u2264 (Ico N n).sum d : by rw dist_comm; apply this n hn\n    ... < \u03b5 : hs _ (finset.disjoint_iff_ne.2\n                     (\u03bba 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 : \u2115 \u2192 Option \u2115 :=\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 : \u2115) : \u2115 \u2192 Option \u2115 :=\n  sorry\n\ntheorem pred_eq_ppred (n : \u2115) : Nat.pred n = option.get_or_else (ppred n) 0 :=\n  nat.cases_on n (Eq.refl (Nat.pred 0)) fun (n : \u2115) => Eq.refl (Nat.pred (Nat.succ n))\n\ntheorem sub_eq_psub (m : \u2115) (n : \u2115) : m - n = option.get_or_else (psub m n) 0 := sorry\n\n@[simp] theorem ppred_eq_some {m : \u2115} {n : \u2115} : ppred n = some m \u2194 Nat.succ m = n := sorry\n\n@[simp] theorem ppred_eq_none {n : \u2115} : ppred n = none \u2194 n = 0 := sorry\n\ntheorem psub_eq_some {m : \u2115} {n : \u2115} {k : \u2115} : psub m n = some k \u2194 k + n = m := sorry\n\ntheorem psub_eq_none {m : \u2115} {n : \u2115} : psub m n = none \u2194 m < n := sorry\n\ntheorem ppred_eq_pred {n : \u2115} (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 : \u2115} {n : \u2115} (h : n \u2264 m) : psub m n = some (m - n) :=\n  iff.mpr psub_eq_some (nat.sub_add_cancel h)\n\ntheorem psub_add (m : \u2115) (n : \u2115) (k : \u2115) : psub m (n + k) =\n  do \n    let x \u2190 psub m n \n    psub x k := sorry\n\n/-- Same as `psub`, but with a more efficient implementation. -/\ndef psub' (m : \u2115) (n : \u2115) : Option \u2115 :=\n  ite (n \u2264 m) (some (m - n)) none\n\ntheorem psub'_eq_psub (m : \u2115) (n : \u2115) : 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\n-/\nimport data.set.finite group_theory.coset data.nat.totient\nopen function\n\nvariables {\u03b1 : Type*} {s : set \u03b1} {a a\u2081 a\u2082 b c: \u03b1}\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 \u03b1] {f : \u2124 \u2192 \u03b1} {a : \u03b1} {n : \u2115}\n  (hn : 0 < n) (h : \u2200i, f (i % n) = f i) :\n  a \u2208 set.range f \u2194 a \u2208 (finset.range n).image (\u03bbi, f i) :=\nsuffices (\u2203i, f (i % n) = a) \u2194 \u2203i, i < n \u2227 f \u2191i = a, by simpa [h],\nhave hn' : 0 < (n : \u2124), from int.coe_nat_lt.mpr hn,\niff.intro\n  (assume \u27e8i, hi\u27e9,\n    have 0 \u2264 i % \u2191n, from int.mod_nonneg _ (ne_of_gt hn'),\n    \u27e8int.to_nat (i % n),\n      by rw [\u2190int.coe_nat_lt, int.to_nat_of_nonneg this]; exact \u27e8int.mod_lt_of_pos i hn', hi\u27e9\u27e9)\n  (assume \u27e8i, hi, ha\u27e9,\n    \u27e8i, by rw [int.mod_eq_of_lt (int.coe_zero_le _) (int.coe_nat_lt_coe_nat_of_lt hi), ha]\u27e9)\n\nend finset\n\nlemma conj_inj [group \u03b1] {x : \u03b1} : function.injective (\u03bb (g : \u03b1), x * g * x\u207b\u00b9) :=\n\u03bb a b h, by simpa [mul_left_inj, mul_right_inj] using h\n\nlemma mem_normalizer_fintype [group \u03b1] {s : set \u03b1} [fintype s] {x : \u03b1}\n  (h : \u2200 n, n \u2208 s \u2192 x * n * x\u207b\u00b9 \u2208 s) : x \u2208 is_subgroup.normalizer s :=\nby haveI := classical.prop_decidable;\nhaveI := set.fintype_image s (\u03bb n, x * n * x\u207b\u00b9); exact\n\u03bb n, \u27e8h n, \u03bb h\u2081,\nhave heq : (\u03bb n, x * n * x\u207b\u00b9) '' s = s := set.eq_of_subset_of_card_le\n  (\u03bb n \u27e8y, hy\u27e9, hy.2 \u25b8 h y hy.1) (by rw set.card_image_of_injective s conj_inj),\nhave x * n * x\u207b\u00b9 \u2208 (\u03bb n, x * n * x\u207b\u00b9) '' s := heq.symm \u25b8 h\u2081,\nlet \u27e8y, hy\u27e9 := this in conj_inj hy.2 \u25b8 hy.1\u27e9\n\nsection order_of\nvariables [group \u03b1] [fintype \u03b1] [decidable_eq \u03b1]\nopen quotient_group set\n\ninstance quotient_group.fintype (s : set \u03b1) [is_subgroup s] [d : decidable_pred s] :\n  fintype (quotient s) :=\n@quotient.fintype _ _ (left_rel s) (\u03bb _ _, d _)\n\nlemma card_eq_card_quotient_mul_card_subgroup (s : set \u03b1) [hs : is_subgroup s] [fintype s]\n  [decidable_pred s] : fintype.card \u03b1 = fintype.card (quotient s) * fintype.card s :=\nby rw \u2190 fintype.card_prod;\n  exact fintype.card_congr (is_subgroup.group_equiv_quotient_times_subgroup hs)\n\nlemma card_subgroup_dvd_card (s : set \u03b1) [is_subgroup s] [fintype s] :\n  fintype.card s \u2223 fintype.card \u03b1 :=\nby haveI := classical.prop_decidable; simp [card_eq_card_quotient_mul_card_subgroup s]\n\nlemma card_quotient_dvd_card (s : set \u03b1) [is_subgroup s] [decidable_pred s] [fintype s] :\n  fintype.card (quotient s) \u2223 fintype.card \u03b1 :=\nby simp [card_eq_card_quotient_mul_card_subgroup s]\n\n@[simp] lemma card_trivial [fintype (is_subgroup.trivial \u03b1)] :\n  fintype.card (is_subgroup.trivial \u03b1) = 1 :=\nfintype.card_eq_one_iff.2\n  \u27e8\u27e8(1 : \u03b1), by simp\u27e9, \u03bb \u27e8y, hy\u27e9, subtype.eq $ is_subgroup.mem_trivial.1 hy\u27e9\n\nlemma exists_gpow_eq_one (a : \u03b1) : \u2203i\u22600, a ^ (i:\u2124) = 1 :=\nhave \u00ac injective (\u03bbi, a ^ i),\n  from not_injective_int_fintype,\nlet \u27e8i, j, a_eq, ne\u27e9 := show \u2203(i j : \u2124), a ^ i = a ^ j \u2227 i \u2260 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\u27e8i - j, sub_ne_zero.mpr ne, this\u27e9\n\nlemma exists_pow_eq_one (a : \u03b1) : \u2203i > 0, a ^ i = 1 :=\nlet \u27e8i, hi, eq\u27e9 := exists_gpow_eq_one a in\nbegin\n  cases i,\n  { exact \u27e8i, nat.pos_of_ne_zero (by simp [int.of_nat_eq_coe, *] at *), eq\u27e9 },\n  { exact \u27e8i + 1, dec_trivial, inv_eq_one.1 eq\u27e9 }\nend\n\n/-- `order_of a` is the order of the element `a`, i.e. the `n \u2265 1`, s.t. `a ^ n = 1` -/\ndef order_of (a : \u03b1) : \u2115 := nat.find (exists_pow_eq_one a)\n\nlemma pow_order_of_eq_one (a : \u03b1) : a ^ order_of a = 1 :=\nlet \u27e8h\u2081, h\u2082\u27e9 := nat.find_spec (exists_pow_eq_one a) in h\u2082\n\nlemma order_of_pos (a : \u03b1) : order_of a > 0 :=\nlet \u27e8h\u2081, h\u2082\u27e9 := nat.find_spec (exists_pow_eq_one a) in h\u2081\n\nprivate lemma pow_injective_aux {n m : \u2115} (a : \u03b1) (h : n \u2264 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 \u2260 m,\n  have h\u2081 : m - n > 0, from nat.pos_of_ne_zero (by simp [nat.sub_eq_iff_eq_add h, ne.symm]),\n  have h\u2082 : a ^ (m - n) = 1, by simp [pow_sub _ h, eq],\n  have le : order_of a \u2264 m - n, from nat.find_min' (exists_pow_eq_one a) \u27e8h\u2081, h\u2082\u27e9,\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 : \u2115} (a : \u03b1)\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 \u2264 fintype.card \u03b1 :=\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 : \u2115} : 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 : \u2124} : 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' : \u03b1} :\n  a' \u2208 gpowers a \u2194 a' \u2208 (finset.range (order_of a)).image ((^) a : \u2115 \u2192 \u03b1) :=\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' \u2208 (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 : \u2115} (h : a ^ n = 1) : order_of a \u2223 n :=\nby_contradiction\n  (\u03bb h\u2081, nat.find_min _ (show n % order_of a < order_of a,\n    from nat.mod_lt _ (order_of_pos _))\n      \u27e8nat.pos_of_ne_zero (mt nat.dvd_of_mod_eq_zero h\u2081), by rwa \u2190 pow_eq_mod_order_of\u27e9)\n\nlemma order_of_le_of_pow_eq_one {n : \u2115} (hn : 0 < n) (h : a ^ n = 1) : order_of a \u2264 n :=\nnat.find_min' (exists_pow_eq_one a) \u27e8hn, h\u27e9\n\nlemma sum_card_order_of_eq_card_pow_eq_one {n : \u2115} (hn : 0 < n) :\n  ((finset.range n.succ).filter (\u2223 n)).sum (\u03bb m, (finset.univ.filter (\u03bb a : \u03b1, order_of a = m)).card)\n  = (finset.univ.filter (\u03bb a : \u03b1, a ^ n = 1)).card :=\ncalc ((finset.range n.succ).filter (\u2223 n)).sum (\u03bb m, (finset.univ.filter (\u03bb a : \u03b1, 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 \u2264 n \u2227 order_of a \u2223 n \u2194 a ^ n = 1,\n  { simpa [nat.lt_succ_iff], },\n  exact \u27e8\u03bb h, let \u27e8m, hm\u27e9 := h.2 in by rw [hm, pow_mul, pow_order_of_eq_one, _root_.one_pow],\n    \u03bb h, \u27e8order_of_le_of_pow_eq_one hn h, order_of_dvd_of_pow_eq_one h\u27e9\u27e9\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 \u03bbn hn, \u27e8gpow a n, \u27e8n, rfl\u27e9\u27e9 },\n  { exact assume \u27e8_, i, rfl\u27e9 _,\n    have pos: (0:int) < order_of a,\n      from int.coe_nat_lt.mpr $ order_of_pos a,\n    have 0 \u2264 i % (order_of a),\n      from int.mod_nonneg _ $ ne_of_gt pos,\n    \u27e8int.to_nat (i % order_of a),\n      by rw [\u2190 int.coe_nat_lt, int.to_nat_of_nonneg this];\n        exact \u27e8int.mod_lt_of_pos _ pos, subtype.eq gpow_eq_mod_order_of.symm\u27e9\u27e9 },\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 : \u03b1) = 1 :=\nby rw [order_eq_card_gpowers, fintype.card_eq_one_iff];\n  exact \u27e8\u27e81, 0, rfl\u27e9, \u03bb \u27e8a, i, ha\u27e9, by simp [ha.symm]\u27e9\n\n@[simp] lemma order_of_eq_one_iff : order_of a = 1 \u2194 a = 1 :=\n\u27e8\u03bb h, by conv { to_lhs, rw [\u2190 pow_one a, \u2190 h, pow_order_of_eq_one] }, \u03bb h, by simp [h]\u27e9\n\nsection classical\nlocal attribute [instance] classical.prop_decidable\nopen quotient_group\n\n/- TODO: use cardinal theory, introduce `card : set \u03b1 \u2192 \u2115`, or setup decidability for cosets -/\nlemma order_of_dvd_card_univ : order_of a \u2223 fintype.card \u03b1 :=\nhave ft_prod : fintype (quotient (gpowers a) \u00d7 (gpowers a)),\n  from fintype.of_equiv \u03b1 (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 \u27e8\u27e81, is_submonoid.one_mem (gpowers a)\u27e9\u27e9,\nhave ft : fintype (quotient (gpowers a) \u00d7 (gpowers a)),\n  from @prod.fintype _ _ ft_cosets ft_s,\nhave eq\u2081 : fintype.card \u03b1 = @fintype.card _ ft_cosets * @fintype.card _ ft_s,\n  from calc fintype.card \u03b1 = @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\u2082 : 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\u2081, eq\u2082, mul_comm]\n\n\nend classical\n\n@[simp] lemma pow_card_eq_one (a : \u03b1) : a ^ fintype.card \u03b1 = 1 :=\nlet \u27e8m, hm\u27e9 := @order_of_dvd_card_univ _ a _ _ _ in\nby simp [hm, pow_mul, pow_order_of_eq_one]\n\nlemma powers_eq_gpowers (a : \u03b1) : powers a = gpowers a :=\nset.ext (\u03bb x, \u27e8\u03bb \u27e8n, hn\u27e9, \u27e8n, by simp * at *\u27e9,\n  \u03bb \u27e8i, hi\u27e9, \u27e8(i % order_of a).nat_abs,\n    by rwa [\u2190 gpow_coe_nat, int.nat_abs_of_nonneg (int.mod_nonneg _\n      (int.coe_nat_ne_zero_iff_pos.2 (order_of_pos _))), \u2190 gpow_eq_mod_order_of]\u27e9\u27e9)\n\nopen nat\n\nlemma order_of_pow (a : \u03b1) (n : \u2115) : 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 [\u2190 pow_mul, \u2190 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 \u2223 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 : \u2115} {a : \u03b1} :\n  a ^ n = 1 \u2194 a ^ (gcd n (fintype.card \u03b1)) = 1 :=\n\u27e8\u03bb h, have hn : order_of a \u2223 n, from dvd_of_mod_eq_zero $\n      by_contradiction (\u03bb 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 \u27e8m, hm\u27e9 := dvd_gcd hn order_of_dvd_card_univ in\n    by rw [hm, pow_mul, pow_order_of_eq_one, _root_.one_pow],\n  \u03bb h, let \u27e8m, hm\u27e9 := gcd_dvd_left n (fintype.card \u03b1) in\n    by rw [hm, pow_mul, h, _root_.one_pow]\u27e9\n\nend\n\nend order_of\n\nsection cyclic\n\nlocal attribute [instance] set_fintype\n\nclass is_cyclic (\u03b1 : Type*) [group \u03b1] : Prop :=\n(exists_generator : \u2203 g : \u03b1, \u2200 x, x \u2208 gpowers g)\n\ndef is_cyclic.comm_group [hg : group \u03b1] [is_cyclic \u03b1] : comm_group \u03b1 :=\n{ mul_comm := \u03bb x y, show x * y = y * x,\n    from let \u27e8g, hg\u27e9 := is_cyclic.exists_generator \u03b1 in\n    let \u27e8n, hn\u27e9 := hg x in let \u27e8m, hm\u27e9 := hg y in\n    hm \u25b8 hn \u25b8 gpow_mul_comm _ _ _,\n  ..hg }\n\nlemma is_cyclic_of_order_of_eq_card [group \u03b1] [fintype \u03b1] [decidable_eq \u03b1]\n  (x : \u03b1) (hx : order_of x = fintype.card \u03b1) : is_cyclic \u03b1 :=\n\u27e8\u27e8x, 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 \u03b1), \u2190 hx, order_eq_card_gpowers])\u27e9\u27e9\n\nlemma order_of_eq_card_of_forall_mem_gpowers [group \u03b1] [fintype \u03b1] [decidable_eq \u03b1]\n  {g : \u03b1} (hx : \u2200 x, x \u2208 gpowers g) : order_of g = fintype.card \u03b1 :=\nby rw [\u2190 fintype.card_congr (equiv.set.univ \u03b1), order_eq_card_gpowers];\n  simp [hx]; congr\n\ninstance [group \u03b1] : is_cyclic (is_subgroup.trivial \u03b1) :=\n\u27e8\u27e8(1 : is_subgroup.trivial \u03b1), \u03bb x, \u27e80, subtype.eq $ eq.symm (is_subgroup.mem_trivial.1 x.2)\u27e9\u27e9\u27e9\n\ninstance is_subgroup.is_cyclic [group \u03b1] [is_cyclic \u03b1] (H : set \u03b1) [is_subgroup H] : is_cyclic H :=\nby haveI := classical.prop_decidable; exact\nlet \u27e8g, hg\u27e9 := is_cyclic.exists_generator \u03b1 in\nif hx : \u2203 (x : \u03b1), x \u2208 H \u2227 x \u2260 (1 : \u03b1) then\n  let \u27e8x, hx\u2081, hx\u2082\u27e9 := hx in\n  let \u27e8k, hk\u27e9 := hg x in\n  have hex : \u2203 n : \u2115, 0 < n \u2227 g ^ n \u2208 H,\n    from \u27e8k.nat_abs, nat.pos_of_ne_zero\n      (\u03bb h, hx\u2082 $ by rw [\u2190 hk, int.eq_zero_of_nat_abs_eq_zero h, gpow_zero]),\n        match k, hk with\n        | (k : \u2115), hk := by rw [int.nat_abs_of_nat, \u2190 gpow_coe_nat, hk]; exact hx\u2081\n        | -[1+ k], hk := by rw [int.nat_abs_of_neg_succ_of_nat,\n          \u2190 is_subgroup.inv_mem_iff H]; simp * at *\n        end\u27e9,\n  \u27e8\u27e8\u27e8g ^ nat.find hex, (nat.find_spec hex).2\u27e9,\n    \u03bb \u27e8x, hx\u27e9, let \u27e8k, hk\u27e9 := hg x in\n      have hk\u2081 : g ^ ((nat.find hex : \u2124) * (k / nat.find hex)) \u2208 gpowers (g ^ nat.find hex),\n        from \u27e8k / nat.find hex, eq.symm $ gpow_mul _ _ _\u27e9,\n      have hk\u2082 : g ^ ((nat.find hex : \u2124) * (k / nat.find hex)) \u2208 H,\n        by rw gpow_mul; exact is_subgroup.gpow_mem (nat.find_spec hex).2,\n      have hk\u2083 : g ^ (k % nat.find hex) \u2208 H,\n        from (is_subgroup.mul_mem_cancel_left H hk\u2082).1 $\n          by rw [\u2190 gpow_add, int.mod_add_div, hk]; exact hx,\n      have hk\u2084 : 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\u2085 : g ^ (k % nat.find hex ).nat_abs \u2208 H,\n        by rwa [\u2190 gpow_coe_nat, \u2190 hk\u2084],\n      have hk\u2086 : (k % (nat.find hex : \u2124)).nat_abs = 0,\n        from by_contradiction (\u03bb h,\n          nat.find_min hex (int.coe_nat_lt.1 $ by rw [\u2190 hk\u2084];\n            exact int.mod_lt_of_pos _ (int.coe_nat_pos.2 (nat.find_spec hex).1))\n          \u27e8nat.pos_of_ne_zero h, hk\u2085\u27e9),\n      \u27e8k / (nat.find hex : \u2124), subtype.coe_ext.2 begin\n        suffices : g ^ ((nat.find hex : \u2124) * (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\u2086)), hk]\n      end\u27e9\u27e9\u27e9\nelse\n  have H = is_subgroup.trivial \u03b1,\n    from set.ext $ \u03bb x, \u27e8\u03bb h, by simp at *; tauto,\n      \u03bb h, by rw [is_subgroup.mem_trivial.1 h]; exact is_submonoid.one_mem _\u27e9,\n  by clear _let_match; subst this; apply_instance\n\nopen finset nat\n\nlemma is_cyclic.card_pow_eq_one_le [group \u03b1] [fintype \u03b1] [decidable_eq \u03b1] [is_cyclic \u03b1] {n : \u2115}\n  (hn0 : 0 < n) : (univ.filter (\u03bb a : \u03b1, a ^ n = 1)).card \u2264 n :=\nlet \u27e8g, hg\u27e9 := is_cyclic.exists_generator \u03b1 in\ncalc (univ.filter (\u03bb a : \u03b1, a ^ n = 1)).card \u2264 (gpowers (g ^ (fintype.card \u03b1 / (gcd n (fintype.card \u03b1))))).to_finset.card :\n  card_le_of_subset (\u03bb x hx, let \u27e8m, hm\u27e9 := show x \u2208 powers g, from (powers_eq_gpowers g).symm \u25b8 hg x in\n    set.mem_to_finset.2 \u27e8(m / (fintype.card \u03b1 / (gcd n (fintype.card \u03b1))) : \u2115),\n      have hgmn : g ^ (m * gcd n (fintype.card \u03b1)) = 1,\n        by rw [pow_mul, hm, \u2190 pow_gcd_card_eq_one_iff]; exact (mem_filter.1 hx).2,\n      begin\n        rw [gpow_coe_nat, \u2190 pow_mul, nat.mul_div_cancel_left', hm],\n        refine dvd_of_mul_dvd_mul_right (gcd_pos_of_pos_left (fintype.card \u03b1) hn0) _,\n        conv {to_lhs, rw [nat.div_mul_cancel (gcd_dvd_right _ _), \u2190 order_of_eq_card_of_forall_mem_gpowers hg]},\n        exact order_of_dvd_of_pow_eq_one hgmn\n      end\u27e9)\n... \u2264 n :\n  let \u27e8m, hm\u27e9 := gcd_dvd_right n (fintype.card \u03b1) in\n  have hm0 : 0 < m, from nat.pos_of_ne_zero\n    (\u03bb hm0, (by rw [hm0, mul_zero, fintype.card_eq_zero_iff] at hm; exact hm 1)),\n  begin\n    rw [\u2190 set.card_fintype_of_finset' _ (\u03bb _, set.mem_to_finset), \u2190 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 \u03b1] [fintype \u03b1] [decidable_eq \u03b1] (hn : \u2200 n : \u2115, 0 < n \u2192 (univ.filter (\u03bb a : \u03b1, a ^ n = 1)).card \u2264 n)\ninclude hn\n\nlemma card_pow_eq_one_eq_order_of_aux (a : \u03b1) :\n  (finset.univ.filter (\u03bb b : \u03b1, 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    ... \u2264 @fintype.card (\u2191(univ.filter (\u03bb b : \u03b1, b ^ order_of a = 1)) : set \u03b1)\n    (set.fintype_of_finset _ (\u03bb _, iff.rfl)) :\n      @fintype.card_le_of_injective (gpowers a) (\u2191(univ.filter (\u03bb b : \u03b1, b ^ order_of a = 1)) : set \u03b1)\n        (id _) (id _) (\u03bb b, \u27e8b.1, mem_filter.2 \u27e8mem_univ _,\n          let \u27e8i, hi\u27e9 := b.2 in\n          by rw [\u2190 hi, \u2190 gpow_coe_nat, \u2190 gpow_mul, mul_comm, gpow_mul, gpow_coe_nat,\n            pow_order_of_eq_one, one_gpow]\u27e9\u27e9) (\u03bb _ _ h, subtype.eq (subtype.mk.inj h))\n    ... = (univ.filter (\u03bb b : \u03b1, b ^ order_of a = 1)).card : set.card_fintype_of_finset _ _)\n\nlocal notation `\u03c6` := nat.totient\n\nprivate lemma card_order_of_eq_totient_aux\u2081 :\n  \u2200 {d : \u2115}, d \u2223 fintype.card \u03b1 \u2192 0 < (univ.filter (\u03bb a : \u03b1, order_of a = d)).card \u2192\n  (univ.filter (\u03bb a : \u03b1, order_of a = d)).card = \u03c6 d\n| 0     := \u03bb 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) := \u03bb hd hd0,\nlet \u27e8a, ha\u27e9 := 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 (\u2223 d.succ)).sum\n    (\u03bb m, (univ.filter (\u03bb a : \u03b1, order_of a = m)).card) =\n    ((range d.succ).filter (\u2223 d.succ)).sum \u03c6, from\n  finset.sum_congr rfl\n    (\u03bb m hm, have hmd : m < d.succ, from mem_range.1 (mem_filter.1 hm).1,\n      have hm : m \u2223 d.succ, from (mem_filter.1 hm).2,\n      card_order_of_eq_totient_aux\u2081 (dvd.trans hm hd) (finset.card_pos.2\n        (ne_empty_of_mem (show a ^ (d.succ / m) \u2208 _,\n          from mem_filter.2 \u27e8mem_univ _,\n          by rw [order_of_pow, ha, gcd_eq_right (div_dvd_of_dvd hm),\n            nat.div_div_self hm (succ_pos _)]\u27e9)))),\nhave hinsert : insert d.succ ((range d.succ).filter (\u2223 d.succ))\n    = (range d.succ.succ).filter (\u2223 d.succ),\n  from (finset.ext.2 $ \u03bb x, \u27e8\u03bb h, (mem_insert.1 h).elim (\u03bb 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\u27e9),\nhave hinsert\u2081 : d.succ \u2209 (range d.succ).filter (\u2223 d.succ),\n  by simp [mem_range, zero_le_one, le_succ],\n(add_right_inj (((range d.succ).filter (\u2223 d.succ)).sum\n  (\u03bb m, (univ.filter (\u03bb a : \u03b1, order_of a = m)).card))).1\n  (calc _ = (insert d.succ (filter (\u2223 d.succ) (range d.succ))).sum\n        (\u03bb m, (univ.filter (\u03bb a : \u03b1, 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 (\u2223 d.succ)).sum (\u03bb m,\n      (univ.filter (\u03bb a : \u03b1, order_of a = m)).card) :\n    sum_congr hinsert (\u03bb _ _, rfl)\n  ... = (univ.filter (\u03bb a : \u03b1, a ^ d.succ = 1)).card :\n    sum_card_order_of_eq_card_pow_eq_one (succ_pos d)\n  ... = ((range d.succ.succ).filter (\u2223 d.succ)).sum \u03c6 :\n    ha \u25b8 (card_pow_eq_one_eq_order_of_aux hn a).symm \u25b8 (sum_totient _).symm\n  ... = _ : by rw [h, \u2190 sum_insert hinsert\u2081];\n      exact finset.sum_congr hinsert.symm (\u03bb _ _, rfl))\n\nlemma card_order_of_eq_totient_aux\u2082 {d : \u2115} (hd : d \u2223 fintype.card \u03b1) :\n  (univ.filter (\u03bb a : \u03b1, order_of a = d)).card = \u03c6 d :=\nby_contradiction $ \u03bb h,\nhave h0 : (univ.filter (\u03bb a : \u03b1 , order_of a = d)).card = 0 :=\n  not_not.1 (mt nat.pos_iff_ne_zero.2 (mt (card_order_of_eq_totient_aux\u2081 hn hd) h)),\nlet c := fintype.card \u03b1 in\nhave hc0 : 0 < c, from fintype.card_pos_iff.2 \u27e81\u27e9,\nlt_irrefl c $\n  calc c = (univ.filter (\u03bb a : \u03b1, a ^ c = 1)).card :\n    congr_arg card $ by simp [finset.ext, c]\n  ... = ((range c.succ).filter (\u2223 c)).sum\n      (\u03bb m, (univ.filter (\u03bb a : \u03b1, order_of a = m)).card) :\n    (sum_card_order_of_eq_card_pow_eq_one hc0).symm\n  ... = (((range c.succ).filter (\u2223 c)).erase d).sum\n      (\u03bb m, (univ.filter (\u03bb a : \u03b1, order_of a = m)).card) :\n    eq.symm (sum_subset (erase_subset _ _) (\u03bb m hm\u2081 hm\u2082,\n      have m = d, by simp at *; cc,\n      by simp [*, finset.ext] at *; exact h0))\n  ... \u2264 (((range c.succ).filter (\u2223 c)).erase d).sum \u03c6 :\n    sum_le_sum (\u03bb m hm,\n      have hmc : m \u2223 c, by simp at hm; tauto,\n      (imp_iff_not_or.1 (card_order_of_eq_totient_aux\u2081 hn hmc)).elim\n        (\u03bb h, by simp [nat.le_zero_iff.1 (le_of_not_gt h), nat.zero_le])\n        (by simp [le_refl] {contextual := tt}))\n  ... < \u03c6 d + (((range c.succ).filter (\u2223 c)).erase d).sum \u03c6 :\n    lt_add_of_pos_left _ (totient_pos (nat.pos_of_ne_zero\n      (\u03bb h, nat.pos_iff_ne_zero.1 hc0 (eq_zero_of_zero_dvd $ h \u25b8 hd))))\n  ... = (insert d (((range c.succ).filter (\u2223 c)).erase d)).sum \u03c6 : eq.symm (sum_insert (by simp))\n  ... = ((range c.succ).filter (\u2223 c)).sum \u03c6 : finset.sum_congr\n      (finset.insert_erase (mem_filter.2 \u27e8mem_range.2 (lt_succ_of_le (le_of_dvd hc0 hd)), hd\u27e9)) (\u03bb _ _, rfl)\n  ... = c : sum_totient _\n\nlemma is_cyclic_of_card_pow_eq_one_le : is_cyclic \u03b1 :=\nhave \u2203 x, x \u2208 univ.filter (\u03bb a : \u03b1, order_of a = fintype.card \u03b1),\nfrom exists_mem_of_ne_empty (card_pos.1 $\n  by rw [card_order_of_eq_totient_aux\u2082 hn (dvd_refl _)];\n  exact totient_pos (fintype.card_pos_iff.2 \u27e81\u27e9)),\nlet \u27e8x, hx\u27e9 := 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 \u03b1] [is_cyclic \u03b1] [fintype \u03b1] [decidable_eq \u03b1]\n  {d : \u2115} (hd : d \u2223 fintype.card \u03b1) : (univ.filter (\u03bb a : \u03b1, order_of a = d)).card = totient d :=\ncard_order_of_eq_totient_aux\u2082 (\u03bb 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 {\u03b1 : 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 \u2192 alphabet \u2192 finset state)\n(start : finset state)\n(accept_states : finset state)\nnamespace NFA\n\n-- @[reducible] def start_dec (M : NFA \u03b1) := decidable_pred M.start\n-- @[reducible] def step_dec (M : NFA \u03b1) := \u03a0 (S : M.state) (a : \u03b1), decidable_pred (M.step S a)\n-- instance dec\u2081 (M : NFA \u03b1) := M.start_dec\n-- instance dec\u2082 (M : NFA \u03b1) := M.step_dec\n-- instance dec\u2083 (M : NFA \u03b1) := M.accept_dec\ninstance dec (M : NFA \u03b1) := M.state_dec\n\ninstance fin\u2081 (M : NFA \u03b1) := M.alphabet_fintype\ninstance fin\u2082 (M : NFA \u03b1) := M.state_fintype\n\ndef step_set (M : NFA \u03b1) : finset M.state \u2192 \u03b1 \u2192 finset M.state :=\n\u03bb Ss a, finset.bind Ss (\u03bb S, (M.step S a))\n\ndef eval (M : NFA \u03b1) : list \u03b1 \u2192 finset M.state := list.foldl M.step_set M.start\n\ndef accepts (M : NFA \u03b1) (s : list \u03b1) : Prop :=\n\u2203 S \u2208 M.accept_states, S \u2208 M.eval s\n\ndef NFA_of_DFA (M : DFA \u03b1) : NFA \u03b1 :=\n{ alphabet_fintype := M.alphabet_fintype,\n  state := M.state,\n  state_fintype := M.state_fintype,\n  step := \u03bb 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 \u03b1) [decidable_eq M.state] (s : list \u03b1) :\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 \u03b1) (s : list \u03b1) :\n  M.accepts s \u2194 (NFA_of_DFA M).accepts s :=\nbegin\n  rw [accepts, DFA.accepts, \u2190NFA_of_DFA_eval_match],\n  split,\n  { intro h,\n    use M.eval s,\n    finish },\n  { rintro \u27e8 S, hS\u2081, hS\u2082 \u27e9,\n    rw finset.mem_singleton at hS\u2082,\n    rw hS\u2082 at hS\u2081,\n    assumption }\nend\n\ndef DFA_of_NFA (M : NFA \u03b1) : DFA \u03b1 :=\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 (\u03bb S, \u2203 s \u2208 S, s \u2208 M.accept_states) }\n\nlemma DFA_of_NFA_correct (M : NFA \u03b1) (s : list \u03b1) :\n  M.accepts s \u2194 M.DFA_of_NFA.accepts s :=\nbegin\n  rw [accepts, DFA.accepts, eval, DFA.eval],\n  change (\u2203 (S : M.state) (H : S \u2208 M.accept_states), S \u2208 list.foldl M.step_set M.start s) \u2194 list.foldl M.step_set M.start s \u2208 finset.univ.filter (\u03bb S : finset M.state, \u2203 s \u2208 S, s \u2208 M.accept_states),\n  rw finset.mem_filter,\n  finish\nend\n\nend NFA\n\nstructure \u03b5_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 \u2192 option alphabet \u2192 finset state)\n(start : finset state)\n(accept_states : finset state)\n\nnamespace \u03b5_NFA\n\ninstance dec (M : \u03b5_NFA \u03b1) := M.state_dec\n\ninstance fin\u2081 (M : \u03b5_NFA \u03b1) : fintype \u03b1 := M.alphabet_fintype\ninstance fin\u2082 (M : \u03b5_NFA \u03b1) : fintype M.state := M.state_fintype\n\ndef step_set' (M : \u03b5_NFA \u03b1) : finset M.state \u2192 option \u03b1 \u2192 finset M.state :=\n\u03bb Ss a, finset.bind Ss (\u03bb S, M.step S a)\n\ninductive \u03b5_closure_set (M : \u03b5_NFA \u03b1) (Ss : finset M.state) : M.state \u2192 Prop\n| base : \u2200 (S \u2208 Ss), \u03b5_closure_set S\n| step : \u2200 S T, \u03b5_closure_set S \u2192 T \u2208 M.step S option.none \u2192 \u03b5_closure_set T\n\ndef sub_of_compl {\u03b2 : Type u} [fintype \u03b2] [decidable_eq \u03b2] : \u2200 T U : finset \u03b2, T\u1d9c \u2286 U\u1d9c \u2192 U \u2286 T :=\nbegin\n  intros T U h x hxU,\n  by_contra hTc,\n  rw \u2190finset.mem_compl at hTc,\n  have hUc := finset.mem_of_subset h hTc,\n  finish\nend\n\ninstance \u03b5_NFA_has_well_founded {\u03b2 : Type u} [fintype \u03b2] [decidable_eq \u03b2] : has_well_founded (finset \u03b2) :=\n{ r := (\u03bb S\u2081 S\u2082 : finset \u03b2, S\u2081\u1d9c < S\u2082\u1d9c), \n  wf := \n  inv_image.wf _ finset.lt_wf } \n\ndef \u03b5_closure (M : \u03b5_NFA \u03b1) : finset M.state \u2192 finset M.state\n| S :=\nbegin\n  let S' := S \u222a M.step_set' S none,\n  by_cases heq : S' = S,\n  { exact S },\n  { let : S'\u1d9c < S\u1d9c,\n    { have hsub : S'\u1d9c \u2286 S\u1d9c,\n      { intros s hs,\n        rw finset.mem_compl at hs \u22a2,\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 \u03b5_closure S' }\nend\nusing_well_founded {dec_tac := tactic.assumption}\n\nlemma step_set'_wf (M : \u03b5_NFA \u03b1) (S : finset M.state) (hneq : S \u222a M.step_set' S none \u2260 S) :\n  (S \u222a M.step_set' S none)\u1d9c < S\u1d9c :=\nbegin\n  have hsub : (S \u222a M.step_set' S none)\u1d9c \u2286 S\u1d9c,\n  { intros s hs,\n    rw finset.mem_compl at hs \u22a2,\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 \u03b5_closure_equiv_\u03b5_closure_set (M : \u03b5_NFA \u03b1) :\n  \u03a0 (S : finset M.state) (s : M.state), s \u2208 M.\u03b5_closure S \u2194 M.\u03b5_closure_set S s\n| S :=\nbegin\n  have IH := \u03bb T (h : T\u1d9c < S\u1d9c), \u03b5_closure_equiv_\u03b5_closure_set T,\n  intro s,\n  split,\n  { intro h,\n    rw \u03b5_closure at h,\n    dsimp at h,\n    split_ifs at h with heq,\n    { apply \u03b5_closure_set.base,\n      assumption },\n    { have hwf : (S \u222a M.step_set' S none)\u1d9c < S\u1d9c := M.step_set'_wf S heq,\n      have h' : M.\u03b5_closure_set (S \u222a M.step_set' S none) s,\n        rwa \u2190 IH (S \u222a 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 \u03b5_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 \u03b5_closure_set.step t' t,\n          { apply \u03b5_closure_set.base,\n            tauto },\n          { tauto } } },\n      { apply \u03b5_closure_set.step t' t,\n        { apply ih,\n          rwa IH (S \u222a M.step_set' S none) hwf },\n        assumption } } },\n  { intro h,\n    rw \u03b5_closure,\n    dsimp,\n    split_ifs with heq;\n    induction h with t ht t' t ht' ht ih,\n    { assumption },\n    { rw \u2190heq,\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 \u222a M.step_set' S none)\u1d9c < S\u1d9c := M.step_set'_wf S heq },\n    { rw IH (S \u222a M.step_set' S none) hwf,\n      apply \u03b5_closure_set.base,\n      rw finset.mem_union,\n      left,\n      assumption },\n    { rw IH (S \u222a M.step_set' S none) hwf,\n      apply \u03b5_closure_set.step t' t,\n      rwa \u2190IH (S \u222a M.step_set' S none) hwf,\n      assumption } }\nend\nusing_well_founded {dec_tac := tactic.assumption}\n\ndef step_set (M : \u03b5_NFA \u03b1) : finset M.state \u2192 \u03b1 \u2192 finset M.state :=\n\u03bb Ss a, M.\u03b5_closure $ finset.bind Ss (\u03bb S, M.step S (option.some a))\n\ndef eval (M : \u03b5_NFA \u03b1) : list \u03b1 \u2192 finset M.state := \n  list.foldl M.step_set (M.\u03b5_closure M.start)\n\ndef accepts (M : \u03b5_NFA \u03b1) (s : list \u03b1) : Prop :=\n\u2203 S \u2208 M.accept_states, S \u2208 M.eval s\n\ninstance accepts_dec (M : \u03b5_NFA \u03b1) : decidable_pred M.accepts :=\nbegin\n  intro s,\n  exact fintype.decidable_exists_fintype\nend\n\ndef NFA_of_\u03b5_NFA (M : \u03b5_NFA \u03b1) : NFA \u03b1 :=\n{ alphabet_fintype := M.alphabet_fintype,\n  state := M.state,\n  step := \u03bb S a, M.\u03b5_closure (M.step S (some a)),\n  start := M.\u03b5_closure M.start,\n  accept_states := M.accept_states }\n\nlemma NFA_of_\u03b5_NFA_step_set_match (M : \u03b5_NFA \u03b1) (Ss : finset M.state) (a : \u03b1) :\n  M.step_set Ss a = M.NFA_of_\u03b5_NFA.step_set Ss a :=\nbegin\n  rw [step_set, NFA.step_set],\n  simp,\n  ext b,\n  rw \u03b5_closure_equiv_\u03b5_closure_set,\n  split,\n  { intro h,\n    -- generalize_hyp hT : (Ss.bind (\u03bb (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 \u2190hT at h,\n      simp only [exists_prop, finset.mem_bind] at h \u22a2,\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 \u2208 M.\u03b5_closure (M.step i (some a)),\n      rw \u03b5_closure_equiv_\u03b5_closure_set,\n      apply \u03b5_closure_set.base,\n      tauto },\n    { rw @finset.mem_bind _ M.state M.state_dec at \u22a2 ih,\n      rcases ih with \u27e8 i, h\u2081, h\u2082 \u27e9,\n      existsi i,\n      existsi h\u2081,\n      change T \u2208 M.\u03b5_closure (M.step i (some a)),\n      rw \u03b5_closure_equiv_\u03b5_closure_set,\n      apply \u03b5_closure_set.step U _,\n      change U \u2208 M.\u03b5_closure (M.step _ (some _)) at h\u2082,\n      rw \u2190\u03b5_closure_equiv_\u03b5_closure_set,\n      assumption' } },\n  { rw @finset.mem_bind _ M.state M.state_dec,\n    rintro \u27e8 s, hsSs, hba \u27e9,\n    change b \u2208 M.\u03b5_closure (M.step _ (some _)) at hba,\n    rw \u03b5_closure_equiv_\u03b5_closure_set at hba,\n    induction hba with s h U T hU h ih,\n    { apply \u03b5_closure_set.base,\n      finish },\n    { specialize ih,\n      apply \u03b5_closure_set.step,\n      assumption' } }\nend\n\nlemma NFA_of_\u03b5_NFA_eval_match (M : \u03b5_NFA \u03b1) (s : list \u03b1) :\n  M.eval s = (NFA_of_\u03b5_NFA M).eval s :=\nbegin\n  change list.foldl M.step_set (M.\u03b5_closure M.start) s = list.foldl M.NFA_of_\u03b5_NFA.step_set (M.\u03b5_closure M.start) s,\n  congr,\n  ext1,\n  ext1,\n  rw NFA_of_\u03b5_NFA_step_set_match\nend\n\nlemma NFA_of_\u03b5_NFA_correct (M : \u03b5_NFA \u03b1) (s : list \u03b1) :\n  M.accepts s \u2194 M.NFA_of_\u03b5_NFA.accepts s :=\nbegin\n  rw [accepts, NFA.accepts, NFA_of_\u03b5_NFA_eval_match],\n  tauto\nend\n\nend \u03b5_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 {\u03c3 I V : Type} [linear_order I]\nvariables (s t : \u03c3) {a : iter \u03c3 I V}\n\nsection semantics\nvariables [add_monoid V]\n\n@[simp] lemma terminal_semantics\u2081_zero (h : a.terminal t) : a.semantics\u2081 t = 0 := by simp *\n\n@[simp]\ntheorem terminal_zero {t} {a : iter \u03c3 I V} (m : a.monotonic) (h : a.terminal t) (j:\u2115) : a.semantics t j = 0 := begin\ninduction j with _ jh generalizing t,\nall_goals {simp *}\nend\n\nlemma succ_of_ge_succ : \u2200 {i i' : \u2115}, i.succ \u2264 i' \u2192 \u2203 i'':\u2115, i' = i''.succ\n| i (nat.succ i'') hle := \u27e8_, rfl\u27e9\n\ntheorem semantics_mono {i i'} {s} : a.monotonic \u2192 a.terminal_by s i \u2192 i \u2264 i' \u2192 a.semantics s i = a.semantics s i' := \u03bb mono fin hle, begin\ninduction i with i hi generalizing i' s,\n{ simp * at * },\nobtain \u27e8i'', h1\u27e9 := succ_of_ge_succ hle,\nrw h1 at *,\nsimp only [semantics],\nhave : i \u2264 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 {\u03c3\u2081 \u03c3\u2082 I V : Type} [linear_order I] [decidable_eq \u03c3\u2081] [decidable_eq \u03c3\u2082] [add_comm_monoid V]\n{a : iter \u03c3\u2081 I V} {b : iter \u03c3\u2082 I V}\n{s\u2081 : \u03c3\u2081} {s\u2082 : \u03c3\u2082}\n\ntheorem add_iter_sound {i j}\n: a.monotonic \u2192 b.monotonic \u2192 a.terminal_by s\u2081 i \u2192 b.terminal_by s\u2082 j \u2192\n  (a +' b).semantics (s\u2081,s\u2082) (i+j) = a.semantics s\u2081 i + b.semantics s\u2082 j :=\n\u03bb amono bmono afin bfin, begin\ngeneralize hnij : i+j = n,\ninduction n with n hn generalizing s\u2081 s\u2082 i j,\n{ obtain \u27e8i0, j0\u27e9 := sum_zero.1 hnij.symm,\n  simp only [*, semantics, sum_zero, add_zero],\n},\n\nobtain (\u27e8hs,nta,h\u27e9|\u27e8hs,ntdi,h\u27e9|\u27e8hs,ntb,h\u27e9) := step_sem_trichotomy a b s\u2081 s\u2082,\n\n{ -- a.\u03b4\n  obtain \u27e8i', hisucc\u27e9 := 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.\u03b4, b.\u03b4\n  obtain (\u27e8ta, tb\u27e9|\u27e8nta,ntb\u27e9) := ntdi,\n\n  { simp only [*, terminal_zero, add_zero, add_iter_monotonic, add_iter_terminal] },\n\n  { obtain \u27e8i', hisucc\u27e9 := not_terminal_succ nta afin,\n    obtain \u27e8j', hjsucc\u27e9 := 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.\u03b4\n  obtain \u27e8j', hjsucc\u27e9 := 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 \u03c3\u2081 I V) (v : stream \u03c3\u2082 I V)\n\ntheorem add_stream_sound  {i j} : u.monotonic \u2192 v.monotonic \u2192 u.terminal_by i \u2192 v.terminal_by j \u2192\n\u27e6mk_add u v, i+j\u27e7 = \u27e6u, i\u27e7 + \u27e6v, j\u27e7 := 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\u2070 = R \\ {0}` (i.e. the field of fractions).\n * `fractional_ideal R\u2070 K` is the type of fractional ideals in the field of fractions\n * `has_div (fractional_ideal R\u2070 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 \u2286 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 `(+) := (\u2294)` and `\u22a5 := 0`,\nin order to re-use their respective proof terms.\nWe can still use `simp` to show `\u2191I + \u2191J = \u2191(I + J)` and `\u2191\u22a5 = \u21910`.\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\u2070`,\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 \u2286 R` for some `a \u2260 0`. -/\ndef IsFractional (I : Submodule R P) :=\n  \u2203 a \u2208 S, \u2200 b \u2208 I, IsInteger R (a \u2022 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 \u2208 R`.\n\n  More precisely, let `P` be a localization of `R` at some submonoid `S`,\n  then a fractional ideal `I \u2286 P` is an `R`-submodule of `P`,\n  such that there is a nonzero `a : R` with `a I \u2286 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 `\u2203 a, a I \u2286 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 \u2192 submodule R P`\n(which we use to define `coe : ideal R \u2192 fractional_ideal S P`).\n-/\ninstance : Coe (FractionalIdeal S P) (Submodule R P) :=\n  \u27e8fun I => I.val\u27e9\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 := \u2191(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 \u2208 (I : Submodule R P) \u2194 x \u2208 I :=\n  Iff.rfl\n#align fractional_ideal.mem_coe FractionalIdeal.mem_coe\n\n@[ext]\ntheorem ext {I J : FractionalIdeal S P} : (\u2200 x, x \u2208 I \u2194 x \u2208 J) \u2192 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 = \u2191p) : FractionalIdeal S P :=\n  \u27e8Submodule.copy p s hs, by\n    convert p.is_fractional\n    ext\n    simp only [hs]\n    rfl\u27e9\n#align fractional_ideal.copy FractionalIdeal.copy\n\n@[simp]\ntheorem coe_copy (p : FractionalIdeal S P) (s : Set P) (hs : s = \u2191p) : \u2191(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 = \u2191p) : 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 \u2191I\n\ninstance (I : FractionalIdeal S P) : Module R I :=\n  Submodule.module \u2191I\n\ntheorem coe_to_submodule_injective :\n    Function.Injective (coe : FractionalIdeal S P \u2192 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 \u2194 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 \u2264 1) : IsFractional S I :=\n  by\n  use 1, S.one_mem\n  intro b hb\n  rw [one_smul]\n  obtain \u27e8b', b'_mem, rfl\u27e9 := 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 \u2264 J) :\n    IsFractional S I := by\n  obtain \u27e8a, a_mem, ha\u27e9 := 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 \u2192 submodule R P`,\nwhich is not to be confused with the `coe : fractional_ideal S P \u2192 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  \u27e8fun I =>\n    \u27e8coeSubmodule P I,\n      isFractional_of_le_one _ <| by simpa using coe_submodule_mono P (le_top : I \u2264 \u22a4)\u27e9\u27e9\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 \u2208 (I : FractionalIdeal S P) \u2194 \u2203 x', x' \u2208 I \u2227 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 \u2208 I) :\n    algebraMap R P x \u2208 (I : FractionalIdeal S P) :=\n  (mem_coe_ideal S).mpr \u27e8x, hx, rfl\u27e9\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 \u2264 nonZeroDivisors R) {I J : Ideal R} :\n    (I : FractionalIdeal S P) \u2264 J \u2194 I \u2264 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\u2070 K) \u2264 J \u2194 I \u2264 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  \u27e8(0 : Ideal R)\u27e9\n\n@[simp]\ntheorem mem_zero_iff {x : P} : x \u2208 (0 : FractionalIdeal S P) \u2194 x = 0 :=\n  \u27e8fun \u27e8x', x'_mem_zero, x'_eq_x\u27e9 =>\n    by\n    have x'_eq_zero : x' = 0 := x'_mem_zero\n    simp [x'_eq_x.symm, x'_eq_zero], fun hx => \u27e80, rfl, by simp [hx]\u27e9\u27e9\n#align fractional_ideal.mem_zero_iff FractionalIdeal.mem_zero_iff\n\nvariable {S}\n\n@[simp, norm_cast]\ntheorem coe_zero : \u2191(0 : FractionalIdeal S P) = (\u22a5 : 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 : ((\u22a5 : 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 \u2264 nonZeroDivisors R) :\n    (\u2203 x', x' \u2208 I \u2227 algebraMap R P x' = algebraMap R P x) \u2194 x \u2208 I :=\n  \u27e8fun \u27e8x', hx', Eq\u27e9 => IsLocalization.injective _ h Eq \u25b8 hx', fun h => \u27e8x, h, rfl\u27e9\u27e9\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 \u2264 nonZeroDivisors R) :\n    Function.Injective (coe : Ideal R \u2192 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 \u2264 nonZeroDivisors R) {I J : Ideal R} :\n    (I : FractionalIdeal S P) = J \u2194 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 \u2264 nonZeroDivisors R) :\n    (I : FractionalIdeal S P) = 0 \u2194 I = (\u22a5 : 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 \u2264 nonZeroDivisors R) :\n    (I : FractionalIdeal S P) \u2260 0 \u2194 I \u2260 (\u22a5 : 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) = \u22a5 \u2194 I = 0 :=\n  \u27e8fun h => coe_to_submodule_injective (by simp [h]), fun h => by simp [h]\u27e9\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} : \u2191I \u2260 (\u22a5 : Submodule R P) \u2194 I \u2260 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  \u27e80\u27e9\n\ninstance : One (FractionalIdeal S P) :=\n  \u27e8(\u22a4 : Ideal R)\u27e9\n\nvariable (S)\n\n@[simp, norm_cast]\ntheorem coe_ideal_top : ((\u22a4 : 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 \u2208 (1 : FractionalIdeal S P) \u2194 \u2203 x' : R, algebraMap R P x' = x :=\n  Iff.intro (fun \u27e8x', _, h\u27e9 => \u27e8x', h\u27e9) fun \u27e8x', h\u27e9 => \u27e8x', \u27e8\u27e9, h\u27e9\n#align fractional_ideal.mem_one_iff FractionalIdeal.mem_one_iff\n\ntheorem coe_mem_one (x : R) : algebraMap R P x \u2208 (1 : FractionalIdeal S P) :=\n  (mem_one_iff S).mpr \u27e8x, rfl\u27e9\n#align fractional_ideal.coe_mem_one FractionalIdeal.coe_mem_one\n\ntheorem one_mem_one : (1 : P) \u2208 (1 : FractionalIdeal S P) :=\n  (mem_one_iff S).mpr \u27e81, RingHom.map_one _\u27e9\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) \u2264 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 : \u2191(1 : FractionalIdeal S P) = coeSubmodule P (\u22a4 : 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 : (\u2191(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) \u2264 (J : Submodule R P) \u2194 I \u2264 J :=\n  Iff.rfl\n#align fractional_ideal.coe_le_coe FractionalIdeal.coe_le_coe\n\ntheorem zero_le (I : FractionalIdeal S P) : 0 \u2264 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 : (\u22a5 : 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 \u2264 0 \u2194 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 \u2194 \u2200 x \u2208 I, x = (0 : P) :=\n  \u27e8fun 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)\u27e9\n#align fractional_ideal.eq_zero_iff FractionalIdeal.eq_zero_iff\n\ntheorem IsFractional.sup {I J : Submodule R P} :\n    IsFractional S I \u2192 IsFractional S J \u2192 IsFractional S (I \u2294 J)\n  | \u27e8aI, haI, hI\u27e9, \u27e8aJ, haJ, hJ\u27e9 =>\n    \u27e8aI * aJ, S.mul_mem haI haJ, fun b hb =>\n      by\n      rcases mem_sup.mp hb with \u27e8bI, hbI, bJ, hbJ, rfl\u27e9\n      rw [smul_add]\n      apply is_integer_add\n      \u00b7 rw [mul_smul, smul_comm]\n        exact is_integer_smul (hI bI hbI)\n      \u00b7 rw [mul_smul]\n        exact is_integer_smul (hJ bJ hbJ)\u27e9\n#align is_fractional.sup IsFractional.sup\n\ntheorem IsFractional.inf_right {I : Submodule R P} : IsFractional S I \u2192 \u2200 J, IsFractional S (I \u2293 J)\n  | \u27e8aI, haI, hI\u27e9, J =>\n    \u27e8aI, haI, fun b hb => by\n      rcases mem_inf.mp hb with \u27e8hbI, hbJ\u27e9\n      exact hI b hbI\u27e9\n#align is_fractional.inf_right IsFractional.inf_right\n\ninstance : Inf (FractionalIdeal S P) :=\n  \u27e8fun I J => \u27e8I \u2293 J, I.IsFractional.inf_right J\u27e9\u27e9\n\n@[simp, norm_cast]\ntheorem coe_inf (I J : FractionalIdeal S P) : \u2191(I \u2293 J) = (I \u2293 J : Submodule R P) :=\n  rfl\n#align fractional_ideal.coe_inf FractionalIdeal.coe_inf\n\ninstance : Sup (FractionalIdeal S P) :=\n  \u27e8fun I J => \u27e8I \u2294 J, I.IsFractional.sup J.IsFractional\u27e9\u27e9\n\n@[norm_cast]\ntheorem coe_sup (I J : FractionalIdeal S P) : \u2191(I \u2294 J) = (I \u2294 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  \u27e8(\u00b7 \u2294 \u00b7)\u27e9\n\n@[simp]\ntheorem sup_eq_add (I J : FractionalIdeal S P) : I \u2294 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) : (\u2191(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) : \u2191(I \u2294 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    \u2200 n : \u2115, IsFractional S I \u2192 IsFractional S (n \u2022 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 \u2115 (FractionalIdeal S P) where smul n I := \u27e8n \u2022 I, I.IsFractional.nsmul n\u27e9\n\n@[norm_cast]\ntheorem coe_nsmul (n : \u2115) (I : FractionalIdeal S P) : (\u2191(n \u2022 I) : Submodule R P) = n \u2022 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 \u2192 IsFractional S J \u2192 IsFractional S (I * J : Submodule R P)\n  | \u27e8aI, haI, hI\u27e9, \u27e8aJ, haJ, hJ\u27e9 =>\n    \u27e8aI * aJ, S.mul_mem haI haJ, fun b hb =>\n      by\n      apply Submodule.mul_induction_on hb\n      \u00b7 intro m hm n hn\n        obtain \u27e8n', hn'\u27e9 := hJ n hn\n        rw [mul_smul, mul_comm m, \u2190 smul_mul_assoc, \u2190 hn', \u2190 Algebra.smul_def]\n        apply hI\n        exact Submodule.smul_mem _ _ hm\n      \u00b7 intro x y hx hy\n        rw [smul_add]\n        apply is_integer_add hx hy\u27e9\n#align is_fractional.mul IsFractional.mul\n\ntheorem IsFractional.pow {I : Submodule R P} (h : IsFractional S I) :\n    \u2200 n : \u2115, IsFractional S (I ^ n : Submodule R P)\n  | 0 => isFractional_of_le_one _ (pow_zero _).le\n  | n + 1 => (pow_succ I n).symm \u25b8 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  \u27e8I * J, I.IsFractional.mul J.IsFractional\u27e9\n#align fractional_ideal.mul FractionalIdeal.mul\n\n-- local attribute [semireducible] mul\ninstance : Mul (FractionalIdeal S P) :=\n  \u27e8fun I J => mul I J\u27e9\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 = \u27e8I * J, I.IsFractional.mul J.IsFractional\u27e9 :=\n  by simp only [\u2190 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) : (\u2191(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) : (\u2191(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 ((\u00b7 * \u00b7) 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 \u2208 I) (hj : j \u2208 J) :\n    i * j \u2208 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 \u2264 K \u2194 \u2200 i \u2208 I, \u2200 j \u2208 J, i * j \u2208 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) \u2115 :=\n  \u27e8fun I n => \u27e8I ^ n, I.IsFractional.pow n\u27e9\u27e9\n\n@[simp, norm_cast]\ntheorem coe_pow (I : FractionalIdeal S P) (n : \u2115) : \u2191(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 \u2192 Prop} {r : P}\n    (hr : r \u2208 I * J) (hm : \u2200 i \u2208 I, \u2200 j \u2208 J, C (i * j)) (ha : \u2200 x y, C x \u2192 C y \u2192 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  \u27e8Nat.unaryCast\u27e9\n\ntheorem coe_nat_cast (n : \u2115) : ((n : FractionalIdeal S P) : Submodule R P) = n :=\n  show \u2191n.unaryCast = \u2191n 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 \u2192+* Submodule R P :=\n  \u27e8coe, coe_one, coe_mul, coe_zero, coe_add\u27e9\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 \u2264 J) (J' : FractionalIdeal S P) :\n    J' + I \u2264 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 \u2264 J) (J' : FractionalIdeal S P) :\n    J' * I \u2264 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 \u2264 I) : I \u2264 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 \u2264 1) : I * I \u2264 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) \u2264 1 := fun x hx =>\n  let \u27e8y, _, hy\u27e9 := (mem_coe_ideal S).mp hx\n  (mem_one_iff S).mpr \u27e8y, hy\u27e9\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 \u2264 (1 : FractionalIdeal S P) \u2194 \u2203 I : Ideal R, \u2191I = J :=\n  by\n  constructor\n  \u00b7 intro hJ\n    refine' \u27e8\u27e8{ x : R | algebraMap R P x \u2208 J }, _, _, _\u27e9, _\u27e9\n    \u00b7 intro a b ha hb\n      rw [mem_set_of_eq, RingHom.map_add]\n      exact J.val.add_mem ha hb\n    \u00b7 rw [mem_set_of_eq, RingHom.map_zero]\n      exact J.val.zero_mem\n    \u00b7 intro c x hx\n      rw [smul_eq_mul, mem_set_of_eq, RingHom.map_mul, \u2190 Algebra.smul_def]\n      exact J.val.smul_mem c hx\n    \u00b7 ext x\n      constructor\n      \u00b7 rintro \u27e8y, hy, eq_y\u27e9\n        rwa [\u2190 eq_y]\n      \u00b7 intro hx\n        obtain \u27e8y, eq_x\u27e9 := (mem_one_iff S).mp (hJ hx)\n        rw [\u2190 eq_x] at *\n        exact \u27e8y, hx, rfl\u27e9\n  \u00b7 rintro \u27e8I, hI\u27e9\n    rw [\u2190 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 \u2264 I \u2194 (1 : P) \u2208 I := by\n  rw [\u2190 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 \u2192 fractional_ideal S P` as a ring hom -/\n@[simps]\ndef coeIdealHom : Ideal R \u2192+* 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 : \u2115) : (\u2191(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] {\u03b1 : Sort _} {f : \u03b1 \u2192 Ideal R}\n    (hS : S \u2264 nonZeroDivisors R) :\n    ((\u220f\u1da0 a : \u03b1, f a : Ideal R) : FractionalIdeal S P) = \u220f\u1da0 a : \u03b1, (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 \u2192\u2090[R] P') {I : Submodule R P} :\n    IsFractional S I \u2192 IsFractional S (Submodule.map g.toLinearMap I)\n  | \u27e8a, a_nonzero, hI\u27e9 =>\n    \u27e8a, a_nonzero, fun b hb =>\n      by\n      obtain \u27e8b', b'_mem, hb'\u27e9 := submodule.mem_map.mp hb\n      obtain \u27e8x, hx\u27e9 := hI b' b'_mem\n      use x\n      erw [\u2190 g.commutes, hx, g.map_smul, hb']\u27e9\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 \u2192\u2090[R] P') : FractionalIdeal S P \u2192 FractionalIdeal S P' := fun I =>\n  \u27e8Submodule.map g.toLinearMap I, I.IsFractional.map g\u27e9\n#align fractional_ideal.map FractionalIdeal.map\n\n@[simp, norm_cast]\ntheorem coe_map (g : P \u2192\u2090[R] P') (I : FractionalIdeal S P) :\n    \u2191(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 \u2192\u2090[R] P'} {y : P'} :\n    y \u2208 I.map g \u2194 \u2203 x, x \u2208 I \u2227 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 \u2192\u2090[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' \u2192\u2090[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  \u00b7 rintro \u27e8_, \u27e8y, hy, rfl\u27e9, rfl\u27e9\n    exact \u27e8y, hy, (g.commutes y).symm\u27e9\n  \u00b7 rintro \u27e8y, hy, rfl\u27e9\n    exact \u27e8_, \u27e8y, hy, rfl\u27e9, g.commutes y\u27e9\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 \u22a4\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 \u2243\u2090[R] P') : (I.map (g : P \u2192\u2090[R] P')).map (g.symm : P' \u2192\u2090[R] P) = I := by\n  rw [\u2190 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 \u2243\u2090[R] P') :\n    (I.map (g.symm : P' \u2192\u2090[R] P)).map (g : P \u2192\u2090[R] P') = I := by\n  rw [\u2190 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 \u2192\u2090[R] P'} (h : Function.Injective f) {x : P} {I : FractionalIdeal S P} :\n    f x \u2208 map f I \u2194 x \u2208 I :=\n  mem_map.trans \u27e8fun \u27e8x', hx', x'_eq\u27e9 => h x'_eq \u25b8 hx', fun h => \u27e8x, h, rfl\u27e9\u27e9\n#align fractional_ideal.map_mem_map FractionalIdeal.map_mem_map\n\ntheorem map_injective (f : P \u2192\u2090[R] P') (h : Function.Injective f) :\n    Function.Injective (map f : FractionalIdeal S P \u2192 FractionalIdeal S P') := fun I J hIJ =>\n  ext fun x => (map_mem_map h).symm.trans (hIJ.symm \u25b8 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 \u2243\u2090[R] P') : FractionalIdeal S P \u2243+* 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 [\u2190 map_comp, AlgEquiv.symm_comp, map_id]\n  right_inv I := by rw [\u2190 map_comp, AlgEquiv.comp_symm, map_id]\n#align fractional_ideal.map_equiv FractionalIdeal.mapEquiv\n\n@[simp]\ntheorem coe_fun_mapEquiv (g : P \u2243\u2090[R] P') :\n    (mapEquiv g : FractionalIdeal S P \u2192 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 \u2243\u2090[R] P') (I : FractionalIdeal S P) : mapEquiv g I = map (\u2191g) I :=\n  rfl\n#align fractional_ideal.map_equiv_apply FractionalIdeal.mapEquiv_apply\n\n@[simp]\ntheorem mapEquiv_symm (g : P \u2243\u2090[R] P') :\n    ((mapEquiv g).symm : FractionalIdeal S P' \u2243+* _) = 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) \u2194 \u2203 a \u2208 S, \u2200 b : P, b \u2208 s \u2192 IsInteger R (a \u2022 b) :=\n  \u27e8fun \u27e8a, a_mem, h\u27e9 => \u27e8a, a_mem, fun b hb => h b (subset_span hb)\u27e9, fun \u27e8a, a_mem, h\u27e9 =>\n    \u27e8a, 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\u27e9\u27e9\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 \u27e8I, rfl\u27e9\n  rcases exist_integer_multiples_of_finset S I with \u27e8\u27e8s, hs1\u27e9, hs\u27e9\n  rw [is_fractional_span_iff]\n  exact \u27e8s, hs1, hs\u27e9\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 \u2208 I * J) :\n    \u2203 T T' : Finset P, (T : Set P) \u2286 I \u2227 (T' : Set P) \u2286 J \u2227 x \u2208 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) \u2194 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)\u02e3) : 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 [\u2190 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 \u2243+* 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 \u2208 canonicalEquiv S P P' I \u2194\n      \u2203 y \u2208 I,\n        IsLocalization.map P' (RingHom.id R) (fun y (hy : y \u2208 S) => show RingHom.id R y \u2208 S from hy)\n            (y : P) =\n          x :=\n  by\n  rw [canonical_equiv, map_equiv_apply, mem_map]\n  exact \u27e8fun \u27e8y, mem, Eq\u27e9 => \u27e8y, mem, Eq\u27e9, fun \u27e8y, mem, Eq\u27e9 => \u27e8y, mem, Eq\u27e9\u27e9\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 \u27e8fun \u27e8y, mem, Eq\u27e9 => \u27e8y, mem, Eq\u27e9, fun \u27e8y, mem, Eq\u27e9 => \u27e8y, mem, Eq\u27e9\u27e9\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 [\u2190 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\u2082, 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 [\u2190 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\u2070 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\u2070 K} (h : K \u2192\u2090[R] K')\n\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x \u00abexpr \u2260 \u00bb (0 : R)) -/\n/-- Nonzero fractional ideals contain a nonzero integer. -/\ntheorem exists_ne_zero_mem_is_integer [Nontrivial R] (hI : I \u2260 0) :\n    \u2203 (x : _)(_ : x \u2260 (0 : R)), algebraMap R K x \u2208 I :=\n  by\n  obtain \u27e8y, y_mem, y_not_mem\u27e9 :=\n    SetLike.exists_of_lt (by simpa only using bot_lt_iff_ne_bot.mpr hI)\n  have y_ne_zero : y \u2260 0 := by simpa using y_not_mem\n  obtain \u27e8z, \u27e8x, hx\u27e9\u27e9 := exists_integer_multiple R\u2070 y\n  refine' \u27e8x, _, _\u27e9\n  \u00b7 rw [Ne.def, \u2190 @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  \u00b7 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 \u2260 0) : I.map h \u2260 0 :=\n  by\n  obtain \u27e8x, x_ne_zero, hx\u27e9 := 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 \u27e8algebraMap R K x, hx, h.commutes x\u27e9\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 \u2194 I = 0 :=\n  \u27e8imp_of_not_imp_not _ _ (map_ne_zero _), fun hI => hI.symm \u25b8 map_zero h\u27e9\n#align fractional_ideal.map_eq_zero_iff FractionalIdeal.map_eq_zero_iff\n\ntheorem coe_ideal_injective : Function.Injective (coe : Ideal R \u2192 FractionalIdeal R\u2070 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\u2070 K) = (J : FractionalIdeal R\u2070 K) \u2194 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\u2070 K) = 0 \u2194 I = \u22a5 :=\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\u2070 K) \u2260 0 \u2194 I \u2260 \u22a5 :=\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\u2070 K) = 1 \u2194 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\u2070 K) \u2260 1 \u2194 I \u2260 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\u2081 : Type _} [CommRing R\u2081] {K : Type _} [Field K]\n\nvariable [Algebra R\u2081 K] [frac : IsFractionRing R\u2081 K]\n\ninstance : Nontrivial (FractionalIdeal R\u2081\u2070 K) :=\n  \u27e8\u27e80, 1, fun h =>\n      have this : (1 : K) \u2208 (0 : FractionalIdeal R\u2081\u2070 K) :=\n        by\n        rw [\u2190 (algebraMap R\u2081 K).map_one]\n        simpa only [h] using coe_mem_one R\u2081\u2070 1\n      one_ne_zero ((mem_zero_iff _).mp this)\u27e9\u27e9\n\ntheorem ne_zero_of_mul_eq_one (I J : FractionalIdeal R\u2081\u2070 K) (h : I * J = 1) : I \u2260 0 := fun hI =>\n  zero_ne_one' (FractionalIdeal R\u2081\u2070 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\u2081]\n\ninclude frac\n\ntheorem IsFractional.div_of_nonzero {I J : Submodule R\u2081 K} :\n    IsFractional R\u2081\u2070 I \u2192 IsFractional R\u2081\u2070 J \u2192 J \u2260 0 \u2192 IsFractional R\u2081\u2070 (I / J)\n  | \u27e8aI, haI, hI\u27e9, \u27e8aJ, haJ, hJ\u27e9, h =>\n    by\n    obtain \u27e8y, mem_J, not_mem_zero\u27e9 :=\n      SetLike.exists_of_lt (by simpa only using bot_lt_iff_ne_bot.mpr h)\n    obtain \u27e8y', hy'\u27e9 := hJ y mem_J\n    use aI * y'\n    constructor\n    \u00b7 apply (nonZeroDivisors R\u2081).mul_mem haI (mem_non_zero_divisors_iff_ne_zero.mpr _)\n      intro y'_eq_zero\n      have : algebraMap R\u2081 K aJ * y = 0 := by\n        rw [\u2190 Algebra.smul_def, \u2190 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\u2081 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\u2081\u2070).mpr y_zero\n    intro b hb\n    convert hI _ (hb _ (Submodule.smul_mem _ aJ mem_J)) using 1\n    rw [\u2190 hy', mul_comm b, \u2190 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\u2081\u2070 K} (h : J \u2260 0) :\n    IsFractional R\u2081\u2070 (I / J : Submodule R\u2081 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\u2081\u2070 K) :=\n  \u27e8fun I J => if h : J = 0 then 0 else \u27e8I / J, fractional_div_of_nonzero h\u27e9\u27e9\n\nvariable {I J : FractionalIdeal R\u2081\u2070 K} [J \u2260 0]\n\n@[simp]\ntheorem div_zero {I : FractionalIdeal R\u2081\u2070 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\u2081\u2070 K} (h : J \u2260 0) :\n    I / J = \u27e8I / J, fractional_div_of_nonzero h\u27e9 :=\n  dif_neg h\n#align fractional_ideal.div_nonzero FractionalIdeal.div_nonzero\n\n@[simp]\ntheorem coe_div {I J : FractionalIdeal R\u2081\u2070 K} (hJ : J \u2260 0) :\n    (\u2191(I / J) : Submodule R\u2081 K) = \u2191I / (\u2191J : Submodule R\u2081 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\u2081\u2070 K} (h : J \u2260 0) {x} :\n    x \u2208 I / J \u2194 \u2200 y \u2208 J, x * y \u2208 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\u2081\u2070 K} : I * (1 / I) \u2264 1 :=\n  by\n  by_cases hI : I = 0\n  \u00b7 rw [hI, div_zero, MulZeroClass.mul_zero]\n    exact zero_le 1\n  \u00b7 rw [\u2190 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\u2081\u2070 K} (hI : I \u2264 (1 : FractionalIdeal R\u2081\u2070 K)) :\n    I \u2264 I * (1 / I) := by\n  by_cases hI_nz : I = 0\n  \u00b7 rw [hI_nz, div_zero, MulZeroClass.mul_zero]\n    exact zero_le 0\n  \u00b7 rw [\u2190 coe_le_coe, coe_mul, coe_div hI_nz, coe_one]\n    rw [\u2190 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\u2081\u2070 K} (hJ' : J' \u2260 0) :\n    I \u2264 J / J' \u2194 \u2200 x \u2208 I, \u2200 y \u2208 J', x * y \u2208 J :=\n  \u27e8fun 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)\u27e9\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\u2081\u2070 K} (hJ' : J' \u2260 0) :\n    I \u2264 J / J' \u2194 I * J' \u2264 J := by\n  rw [div_nonzero hJ']\n  convert Submodule.le_div_iff_mul_le using 1\n  rw [\u2190 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\u2081\u2070 K} : I / 1 = I :=\n  by\n  rw [div_nonzero (one_ne_zero' (FractionalIdeal R\u2081\u2070 K))]\n  ext\n  constructor <;> intro h\n  \u00b7 simpa using mem_div_iff_forall_mul_mem.mp h 1 ((algebraMap R\u2081 K).map_one \u25b8 coe_mem_one R\u2081\u2070 1)\n  \u00b7 apply mem_div_iff_forall_mul_mem.mpr\n    rintro y \u27e8y', _, rfl\u27e9\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\u2081\u2070 K) (h : I * J = 1) : J = 1 / I :=\n  by\n  have hI : I \u2260 0 := ne_zero_of_mul_eq_one I J h\n  suffices h' : I * (1 / I) = 1\n  \u00b7\n    exact\n      congr_arg Units.inv <|\n        @Units.ext _ _ (Units.mkOfMulEqOne _ _ h) (Units.mkOfMulEqOne _ _ h') rfl\n  apply le_antisymm\n  \u00b7 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 [\u2190 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\u2081\u2070 K} : I * (1 / I) = 1 \u2194 \u2203 J, I * J = 1 :=\n  \u27e8fun h => \u27e81 / I, h\u27e9, fun \u27e8J, hJ\u27e9 => by rwa [\u2190 eq_one_div_of_mul_eq_one_right I J hJ]\u27e9\n#align fractional_ideal.mul_div_self_cancel_iff FractionalIdeal.mul_div_self_cancel_iff\n\nvariable {K' : Type _} [Field K'] [Algebra R\u2081 K'] [IsFractionRing R\u2081 K']\n\n@[simp]\ntheorem map_div (I J : FractionalIdeal R\u2081\u2070 K) (h : K \u2243\u2090[R\u2081] K') :\n    (I / J).map (h : K \u2192\u2090[R\u2081] K') = I.map h / J.map h :=\n  by\n  by_cases H : J = 0\n  \u00b7 rw [H, div_zero, map_zero, div_zero]\n  \u00b7 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\u2081\u2070 K) (h : K \u2243\u2090[R\u2081] K') :\n    (1 / I).map (h : K \u2192\u2090[R\u2081] 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\u2081 K L : Type _} [CommRing R\u2081] [Field K] [Field L]\n\nvariable [Algebra R\u2081 K] [IsFractionRing R\u2081 K] [Algebra K L] [IsFractionRing K L]\n\ntheorem eq_zero_or_one (I : FractionalIdeal K\u2070 L) : I = 0 \u2228 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  \u00b7 intro x_mem\n    obtain \u27e8n, d, rfl\u27e9 := IsLocalization.mk'_surjective K\u2070 x\n    refine' \u27e8n / d, _\u27e9\n    rw [map_div\u2080, IsFractionRing.mk'_eq_div]\n  \u00b7 rintro \u27e8x, rfl\u27e9\n    obtain \u27e8y, y_ne, y_mem\u27e9 := exists_ne_zero_mem_is_integer hI\n    rw [\u2190 div_mul_cancel x y_ne, RingHom.map_mul, \u2190 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\u2081) (I : FractionalIdeal R\u2081\u2070 K) : I = 0 \u2228 I = 1 :=\n  letI : Field R\u2081 := 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\u2081 : Type _} [CommRing R\u2081] {K : Type _} [Field K]\n\nvariable [Algebra R\u2081 K] [IsFractionRing R\u2081 K]\n\nopen Classical\n\nvariable (R\u2081)\n\n/-- `fractional_ideal.span_finset R\u2081 s f` is the fractional ideal of `R\u2081` generated by `f '' s`. -/\n@[simps]\ndef spanFinset {\u03b9 : Type _} (s : Finset \u03b9) (f : \u03b9 \u2192 K) : FractionalIdeal R\u2081\u2070 K :=\n  \u27e8Submodule.span R\u2081 (f '' s),\n    by\n    obtain \u27e8a', ha'\u27e9 := IsLocalization.exist_integer_multiples R\u2081\u2070 s f\n    refine' \u27e8a', a'.2, fun x hx => Submodule.span_induction hx _ _ _ _\u27e9\n    \u00b7 rintro _ \u27e8i, hi, rfl\u27e9\n      exact ha' i hi\n    \u00b7 rw [smul_zero]\n      exact IsLocalization.isInteger_zero\n    \u00b7 intro x y hx hy\n      rw [smul_add]\n      exact IsLocalization.isInteger_add hx hy\n    \u00b7 intro c x hx\n      rw [smul_comm]\n      exact IsLocalization.isInteger_smul hx\u27e9\n#align fractional_ideal.span_finset FractionalIdeal.spanFinset\n\nvariable {R\u2081}\n\n@[simp]\ntheorem spanFinset_eq_zero {\u03b9 : Type _} {s : Finset \u03b9} {f : \u03b9 \u2192 K} :\n    spanFinset R\u2081 s f = 0 \u2194 \u2200 j \u2208 s, f j = 0 := by\n  simp only [\u2190 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\u2082]\n#align fractional_ideal.span_finset_eq_zero FractionalIdeal.spanFinset_eq_zero\n\ntheorem spanFinset_ne_zero {\u03b9 : Type _} {s : Finset \u03b9} {f : \u03b9 \u2192 K} :\n    spanFinset R\u2081 s f \u2260 0 \u2194 \u2203 j \u2208 s, f j \u2260 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 \u27e8a, ha\u27e9 := exists_integer_multiple S x\n  isFractional_span_iff.mpr \u27e8a, a.2, fun x' hx' => (Set.mem_singleton_iff.mp hx').symm \u25b8 ha\u27e9\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 \u2209 S` -/\nirreducible_def spanSingleton (x : P) : FractionalIdeal S P :=\n  \u27e8span R {x}, isFractional_span_singleton x\u27e9\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 \u2208 spanSingleton S y \u2194 \u2203 z : R, z \u2022 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 \u2208 spanSingleton S x :=\n  (mem_spanSingleton S).mpr \u27e81, one_smul _ _\u27e9\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 \u2264 I \u2194 x \u2208 I := by\n  rw [\u2190 coe_le_coe, coe_span_singleton, Submodule.span_singleton_le_iff_mem x \u2191I, 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 \u2194 \u2203 z : R\u02e3, z \u2022 x = y :=\n  by\n  rw [\u2190 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 \u2191I).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) \u2194 \u2203 x, I = spanSingleton S x :=\n  \u27e8fun h => \u27e8@generator _ _ _ _ _ (\u2191I) h, @eq_spanSingleton_of_principal _ _ _ _ _ _ _ I h\u27e9,\n    fun \u27e8x, hx\u27e9 => { principal := \u27e8x, trans (congr_arg _ hx) (coe_spanSingleton _ x)\u27e9 }\u27e9\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 \u2194 y = 0 :=\n  \u27e8fun h =>\n    span_eq_bot.mp (by simpa using congr_arg Subtype.val h : span R {y} = \u22a5) y (mem_singleton y),\n    fun h => by simp [h]\u27e9\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 \u2260 0 \u2194 y \u2260 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 : \u2115) : spanSingleton S x ^ n = spanSingleton S (x ^ n) :=\n  by\n  induction' n with n hn\n  \u00b7 rw [pow_zero, pow_zero, span_singleton_one]\n  \u00b7 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    (\u2191(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  \u00b7 rintro \u27e8y', hy', rfl\u27e9\n    obtain \u27e8x', rfl\u27e9 := submodule.mem_span_singleton.mp hy'\n    use x'\n    rw [smul_eq_mul, RingHom.map_mul, Algebra.smul_def]\n  \u00b7 rintro \u27e8y', rfl\u27e9\n    refine' \u27e8y' * x, submodule.mem_span_singleton.mpr \u27e8y', rfl\u27e9, _\u27e9\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 \u2208 S) => show RingHom.id R y \u2208 S from hy) x) :=\n  by\n  apply set_like.ext_iff.mpr\n  intro y\n  constructor <;> intro h\n  \u00b7 rw [mem_span_singleton]\n    obtain \u27e8x', hx', rfl\u27e9 := (mem_canonical_equiv_apply _ _ _).mp h\n    obtain \u27e8z, rfl\u27e9 := (mem_span_singleton _).mp hx'\n    use z\n    rw [IsLocalization.map_smul]\n    rfl\n  \u00b7 rw [mem_canonical_equiv_apply]\n    obtain \u27e8z, rfl\u27e9 := (mem_span_singleton _).mp h\n    use z \u2022 x\n    use (mem_span_singleton _).mpr \u27e8z, rfl\u27e9\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 \u2208 spanSingleton S x * I \u2194 \u2203 y' \u2208 I, y = x * y' :=\n  by\n  constructor\n  \u00b7 intro h\n    apply FractionalIdeal.mul_induction_on h\n    \u00b7 intro x' hx' y' hy'\n      obtain \u27e8a, ha\u27e9 := (mem_span_singleton S).mp hx'\n      use a \u2022 y', Submodule.smul_mem I a hy'\n      rw [\u2190 ha, Algebra.mul_smul_comm, Algebra.smul_mul_assoc]\n    \u00b7 rintro _ _ \u27e8y, hy, rfl\u27e9 \u27e8y', hy', rfl\u27e9\n      exact \u27e8y + y', Submodule.add_mem I hy hy', (mul_add _ _ _).symm\u27e9\n  \u00b7 rintro \u27e8y', hy', rfl\u27e9\n    exact mul_mem_mul ((mem_span_singleton S).mpr \u27e81, one_smul _ _\u27e9) 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\u2081} {x y : R\u2081} (hy : y \u2208 R\u2081\u2070) :\n    spanSingleton R\u2081\u2070 (IsLocalization.mk' K x \u27e8y, hy\u27e9) * I = (J : FractionalIdeal R\u2081\u2070 K) \u2194\n      Ideal.span {x} * I = Ideal.span {y} * J :=\n  by\n  have :\n    span_singleton R\u2081\u2070 (IsLocalization.mk' _ (1 : R\u2081) \u27e8y, hy\u27e9) *\n        span_singleton R\u2081\u2070 (algebraMap R\u2081 K y) =\n      1 :=\n    by\n    rw [span_singleton_mul_span_singleton, mul_comm, \u2190 IsLocalization.mk'_eq_mul_mk'_one,\n      IsLocalization.mk'_self, span_singleton_one]\n  let y' : (FractionalIdeal R\u2081\u2070 K)\u02e3 := Units.mkOfMulEqOne _ _ this\n  have coe_y' : \u2191y' = span_singleton R\u2081\u2070 (IsLocalization.mk' K (1 : R\u2081) \u27e8y, hy\u27e9) := 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, \u2190\n    mul_assoc, span_singleton_mul_span_singleton, \u2190 mul_assoc, span_singleton_mul_span_singleton,\n    mul_comm (mk' _ _ _), \u2190 IsLocalization.mk'_eq_mul_mk'_one, mul_comm (mk' _ _ _), \u2190\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\u2081} {z : K} :\n    spanSingleton R\u2081\u2070 z * (I : FractionalIdeal R\u2081\u2070 K) = J \u2194\n      Ideal.span {((IsLocalization.sec R\u2081\u2070 z).1 : R\u2081)} * I =\n        Ideal.span {(IsLocalization.sec R\u2081\u2070 z).2} * J :=\n  by-- `erw` to deal with the distinction between `y` and `\u27e8y.1, y.2\u27e9`\n  erw [\u2190 mk'_mul_coe_ideal_eq_coe_ideal K (IsLocalization.sec R\u2081\u2070 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\u2081]\n\ntheorem one_div_spanSingleton (x : K) : 1 / spanSingleton R\u2081\u2070 x = spanSingleton R\u2081\u2070 x\u207b\u00b9 :=\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\u2081\u2070 K) (d : K) :\n    J / spanSingleton R\u2081\u2070 d = spanSingleton R\u2081\u2070 d\u207b\u00b9 * J :=\n  by\n  rw [\u2190 one_div_span_singleton]\n  by_cases hd : d = 0\n  \u00b7 simp only [hd, span_singleton_zero, div_zero, MulZeroClass.zero_mul]\n  have h_spand : span_singleton R\u2081\u2070 d \u2260 0 := mt span_singleton_eq_zero_iff.mp hd\n  apply le_antisymm\n  \u00b7 intro x hx\n    rw [\u2190 mem_coe, coe_div h_spand, Submodule.mem_div_iff_forall_mul_mem] at hx\n    specialize hx d (mem_span_singleton_self R\u2081\u2070 d)\n    have h_xd : x = d\u207b\u00b9 * (x * d) := by field_simp\n    rw [\u2190 mem_coe, coe_mul, one_div_span_singleton, h_xd]\n    exact Submodule.mul_mem_mul (mem_span_singleton_self R\u2081\u2070 _) hx\n  \u00b7 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\u2081\u2070 K) :\n    \u2203 (a : R\u2081)(aI : Ideal R\u2081), a \u2260 0 \u2227 I = spanSingleton R\u2081\u2070 (algebraMap R\u2081 K a)\u207b\u00b9 * aI :=\n  by\n  obtain \u27e8a_inv, nonzero, ha\u27e9 := I.is_fractional\n  have nonzero := mem_non_zero_divisors_iff_ne_zero.mp nonzero\n  have map_a_nonzero : algebraMap R\u2081 K a_inv \u2260 0 :=\n    mt is_fraction_ring.to_map_eq_zero_iff.mp nonzero\n  refine'\n    \u27e8a_inv,\n      Submodule.comap (Algebra.linearMap R\u2081 K) \u2191(span_singleton R\u2081\u2070 (algebraMap R\u2081 K a_inv) * I),\n      nonzero, ext fun x => Iff.trans \u27e8_, _\u27e9 mem_singleton_mul.symm\u27e9\n  \u00b7 intro hx\n    obtain \u27e8x', hx'\u27e9 := ha x hx\n    rw [Algebra.smul_def] at hx'\n    refine' \u27e8algebraMap R\u2081 K x', (mem_coe_ideal _).mpr \u27e8x', mem_singleton_mul.mpr _, rfl\u27e9, _\u27e9\n    \u00b7 exact \u27e8x, hx, hx'\u27e9\n    \u00b7 rw [hx', \u2190 mul_assoc, inv_mul_cancel map_a_nonzero, one_mul]\n  \u00b7 rintro \u27e8y, hy, rfl\u27e9\n    obtain \u27e8x', hx', rfl\u27e9 := (mem_coe_ideal _).mp hy\n    obtain \u27e8y', hy', hx'\u27e9 := mem_singleton_mul.mp hx'\n    rw [Algebra.linearMap_apply] at hx'\n    rwa [hx', \u2190 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\u2070 K) : (I : Submodule R K).IsPrincipal :=\n  by\n  obtain \u27e8a, aI, -, ha\u27e9 := exists_eq_span_singleton_mul I\n  use (algebraMap R K a)\u207b\u00b9 * algebraMap R K (generator aI)\n  suffices I = span_singleton R\u2070 ((algebraMap R K a)\u207b\u00b9 * 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, \u2190 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 \u2264 spanSingleton S x * J \u2194 \u2200 zI \u2208 I, \u2203 zJ \u2208 J, x * zJ = zI :=\n  show (\u2200 {zI} (hzI : zI \u2208 I), zI \u2208 spanSingleton _ x * J) \u2194 \u2200 zI \u2208 I, \u2203 zJ \u2208 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 \u2264 J \u2194 \u2200 z \u2208 I, x * z \u2208 J :=\n  by\n  simp only [mul_le, mem_singleton_mul, mem_span_singleton]\n  constructor\n  \u00b7 intro h zI hzI\n    exact h x \u27e81, one_smul _ _\u27e9 zI hzI\n  \u00b7 rintro h _ \u27e8z, rfl\u27e9 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 \u2194 (\u2200 zI \u2208 I, \u2203 zJ \u2208 J, x * zJ = zI) \u2227 \u2200 z \u2208 J, x * z \u2208 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\u2081 : Type _} [CommRing R\u2081]\n\nvariable {K : Type _} [Field K] [Algebra R\u2081 K] [frac : IsFractionRing R\u2081 K]\n\nattribute [local instance] Classical.propDecidable\n\ntheorem isNoetherian_zero : IsNoetherian R\u2081 (0 : FractionalIdeal R\u2081\u2070 K) :=\n  isNoetherian_submodule.mpr fun I (hI : I \u2264 (0 : FractionalIdeal R\u2081\u2070 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\u2081\u2070 K} :\n    IsNoetherian R\u2081 I \u2194 \u2200 J \u2264 I, (J : Submodule R\u2081 K).Fg :=\n  isNoetherian_submodule.trans \u27e8fun h J hJ => h _ hJ, fun h J hJ => h \u27e8J, isFractional_of_le hJ\u27e9 hJ\u27e9\n#align fractional_ideal.is_noetherian_iff FractionalIdeal.isNoetherian_iff\n\ntheorem isNoetherian_coe_ideal [IsNoetherianRing R\u2081] (I : Ideal R\u2081) :\n    IsNoetherian R\u2081 (I : FractionalIdeal R\u2081\u2070 K) :=\n  by\n  rw [is_noetherian_iff]\n  intro J hJ\n  obtain \u27e8J, rfl\u27e9 := 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\u2081]\n\ntheorem isNoetherian_spanSingleton_inv_to_map_mul (x : R\u2081) {I : FractionalIdeal R\u2081\u2070 K}\n    (hI : IsNoetherian R\u2081 I) :\n    IsNoetherian R\u2081 (spanSingleton R\u2081\u2070 (algebraMap R\u2081 K x)\u207b\u00b9 * I : FractionalIdeal R\u2081\u2070 K) :=\n  by\n  by_cases hx : x = 0\n  \u00b7 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\u2081 K x \u2260 0 :=\n    mt ((injective_iff_map_eq_zero (algebraMap R\u2081 K)).mp (IsFractionRing.injective _ _) x) hx\n  have h_spanx : span_singleton R\u2081\u2070 (algebraMap R\u2081 K x) \u2260 0 := span_singleton_ne_zero_iff.mpr h_gx\n  rw [is_noetherian_iff] at hI\u22a2\n  intro J hJ\n  rw [\u2190 div_span_singleton, le_div_iff_mul_le h_spanx] at hJ\n  obtain \u27e8s, hs\u27e9 := hI _ hJ\n  use s * {(algebraMap R\u2081 K x)\u207b\u00b9}\n  rw [Finset.coe_mul, Finset.coe_singleton, \u2190 span_mul_span, hs, \u2190 coe_span_singleton R\u2081\u2070, \u2190\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\u2081] (I : FractionalIdeal R\u2081\u2070 K) : IsNoetherian R\u2081 I :=\n  by\n  obtain \u27e8d, J, h_nzd, rfl\u27e9 := 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  \u27e8_, isFractional_adjoin_integral S x hx\u27e9\n#align fractional_ideal.adjoin_integral FractionalIdeal.adjoinIntegral\n\ntheorem mem_adjoinIntegral_self : x \u2208 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\u00f6lzl\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 \u03b1` and `Additive \u03b1`. -/\n\n\ninstance : \u2200 [LE \u03b1], LE (Multiplicative \u03b1) :=\n  fun {inst} => inst\n\ninstance : \u2200 [LE \u03b1], LE (Additive \u03b1) :=\n  fun {inst} => inst\n\ninstance : \u2200 [LT \u03b1], LT (Multiplicative \u03b1) :=\n  fun {inst} => inst\n\ninstance : \u2200 [LT \u03b1], LT (Additive \u03b1) :=\n  fun {inst} => inst\n\ninstance Multiplicative.preorder : \u2200 [Preorder \u03b1], Preorder (Multiplicative \u03b1) :=\n  fun {inst} => inst\n\ninstance Additive.preorder : \u2200 [Preorder \u03b1], Preorder (Additive \u03b1) :=\n  fun {inst} => inst\n\ninstance Multiplicative.partialOrder : \u2200 [PartialOrder \u03b1], PartialOrder (Multiplicative \u03b1) :=\n  fun {inst} => inst\n\ninstance Additive.partialOrder : \u2200 [PartialOrder \u03b1], PartialOrder (Additive \u03b1) :=\n  fun {inst} => inst\n\ninstance Multiplicative.linearOrder : \u2200 [LinearOrder \u03b1], LinearOrder (Multiplicative \u03b1) :=\n  fun {inst} => inst\n\ninstance Additive.linearOrder : \u2200 [LinearOrder \u03b1], LinearOrder (Additive \u03b1) :=\n  fun {inst} => inst\n\ninstance Multiplicative.orderBot [LE \u03b1] : \u2200 [OrderBot \u03b1], OrderBot (Multiplicative \u03b1) :=\n  fun {inst} => inst\n\ninstance Additive.orderBot [LE \u03b1] : \u2200 [OrderBot \u03b1], OrderBot (Additive \u03b1) :=\n  fun {inst} => inst\n\ninstance Multiplicative.orderTop [LE \u03b1] : \u2200 [OrderTop \u03b1], OrderTop (Multiplicative \u03b1) :=\n  fun {inst} => inst\n\ninstance Additive.orderTop [LE \u03b1] : \u2200 [OrderTop \u03b1], OrderTop (Additive \u03b1) :=\n  fun {inst} => inst\n\ninstance Multiplicative.boundedOrder [LE \u03b1] : \u2200 [BoundedOrder \u03b1], BoundedOrder (Multiplicative \u03b1) :=\n  fun {inst} => inst\n\ninstance Additive.boundedOrder [LE \u03b1] : \u2200 [BoundedOrder \u03b1], BoundedOrder (Additive \u03b1) :=\n  fun {inst} => inst\n\ninstance Multiplicative.orderedCommMonoid [OrderedAddCommMonoid \u03b1] :\n    OrderedCommMonoid (Multiplicative \u03b1) :=\n  { Multiplicative.partialOrder, Multiplicative.commMonoid with\n    mul_le_mul_left := @OrderedAddCommMonoid.add_le_add_left \u03b1 _ }\n\ninstance Additive.orderedAddCommMonoid [OrderedCommMonoid \u03b1] :\n    OrderedAddCommMonoid (Additive \u03b1) :=\n  { Additive.partialOrder, Additive.addCommMonoid with\n    add_le_add_left := @OrderedCommMonoid.mul_le_mul_left \u03b1 _ }\n\ninstance Multiplicative.orderedCancelAddCommMonoid [OrderedCancelAddCommMonoid \u03b1] :\n    OrderedCancelCommMonoid (Multiplicative \u03b1) :=\n  { Multiplicative.orderedCommMonoid with\n    le_of_mul_le_mul_left := @OrderedCancelAddCommMonoid.le_of_add_le_add_left \u03b1 _ }\n\ninstance Additive.orderedCancelAddCommMonoid [OrderedCancelCommMonoid \u03b1] :\n    OrderedCancelAddCommMonoid (Additive \u03b1) :=\n  { Additive.orderedAddCommMonoid with\n    le_of_add_le_add_left := @OrderedCancelCommMonoid.le_of_mul_le_mul_left \u03b1 _ }\n\ninstance Multiplicative.linearOrderedCommMonoid [LinearOrderedAddCommMonoid \u03b1] :\n    LinearOrderedCommMonoid (Multiplicative \u03b1) :=\n  { Multiplicative.linearOrder, Multiplicative.orderedCommMonoid with }\n\ninstance Additive.linearOrderedAddCommMonoid [LinearOrderedCommMonoid \u03b1] :\n    LinearOrderedAddCommMonoid (Additive \u03b1) :=\n  { Additive.linearOrder, Additive.orderedAddCommMonoid with }\n\ninstance Multiplicative.existsMulOfLe [Add \u03b1] [LE \u03b1] [ExistsAddOfLE \u03b1] :\n    ExistsMulOfLE (Multiplicative \u03b1) :=\n  \u27e8@exists_add_of_le \u03b1 _ _ _\u27e9\n\ninstance Additive.existsAddOfLe [Mul \u03b1] [LE \u03b1] [ExistsMulOfLE \u03b1] : ExistsAddOfLE (Additive \u03b1) :=\n  \u27e8@exists_mul_of_le \u03b1 _ _ _\u27e9\n\ninstance Multiplicative.canonicallyOrderedMonoid [CanonicallyOrderedAddMonoid \u03b1] :\n    CanonicallyOrderedMonoid (Multiplicative \u03b1) :=\n  { Multiplicative.orderedCommMonoid, Multiplicative.orderBot,\n    Multiplicative.existsMulOfLe with le_self_mul := @le_self_add \u03b1 _ }\n\ninstance Additive.canonicallyOrderedAddMonoid [CanonicallyOrderedMonoid \u03b1] :\n    CanonicallyOrderedAddMonoid (Additive \u03b1) :=\n  { Additive.orderedAddCommMonoid, Additive.orderBot, Additive.existsAddOfLe with\n    le_self_add := @le_self_mul \u03b1 _ }\n\ninstance Multiplicative.canonicallyLinearOrderedMonoid [CanonicallyLinearOrderedAddMonoid \u03b1] :\n    CanonicallyLinearOrderedMonoid (Multiplicative \u03b1) :=\n  { Multiplicative.canonicallyOrderedMonoid, Multiplicative.linearOrder with }\n\ninstance [CanonicallyLinearOrderedMonoid \u03b1] : CanonicallyLinearOrderedAddMonoid (Additive \u03b1) :=\n  { Additive.canonicallyOrderedAddMonoid, Additive.linearOrder with }\n\nnamespace Additive\n\nvariable [Preorder \u03b1]\n\n@[simp]\ntheorem ofMul_le {a b : \u03b1} : ofMul a \u2264 ofMul b \u2194 a \u2264 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 \u03b1} : toMul a \u2264 toMul b \u2194 a \u2264 b :=\n  Iff.rfl\n#align additive.to_mul_le Additive.toMul_le\n\n@[simp]\ntheorem toMul_lt {a b : Additive \u03b1} : toMul a < toMul b \u2194 a < b :=\n  Iff.rfl\n#align additive.to_mul_lt Additive.toMul_lt\n\nend Additive\n\nnamespace Multiplicative\n\nvariable [Preorder \u03b1]\n\n@[simp]\ntheorem ofAdd_le {a b : \u03b1} : ofAdd a \u2264 ofAdd b \u2194 a \u2264 b :=\n  Iff.rfl\n#align multiplicative.of_add_le Multiplicative.ofAdd_le\n\n@[simp]\ntheorem ofAdd_lt {a b : \u03b1} : ofAdd a < ofAdd b \u2194 a < b :=\n  Iff.rfl\n#align multiplicative.of_add_lt Multiplicative.ofAdd_lt\n\n@[simp]\ntheorem toAdd_le {a b : Multiplicative \u03b1} : toAdd a \u2264 toAdd b \u2194 a \u2264 b :=\n  Iff.rfl\n#align multiplicative.to_add_le Multiplicative.toAdd_le\n\n@[simp]\ntheorem toAdd_lt {a b : Multiplicative \u03b1} : toAdd a < toAdd b \u2194 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.\u03b1) :=\n{ add := \u03bb x y, ulift.rec_on x $ ulift.rec_on y $ \u03bb a b, up (b + a) }\n\n@[simp] lemma add_down (x y : ulift.{v} X.\u03b1) : down (x + y) = down x + down y := begin\n  induction x,\n  induction y,\n  refl,\nend\n\ninstance : has_zero (ulift.{v} X.\u03b1) :=\n{ zero := up 0 }\n\n@[simp] lemma zero_down : (0 : ulift.{v} X.\u03b1) .down = 0 := rfl\n\ninstance : add_zero_class (ulift.{v} X.\u03b1) :=\n{ zero := 0,\n  add := (+),\n  zero_add := \u03bb x, by induction x; ext; simp,\n  add_zero := \u03bb x, by induction x; ext; simp }\n\ninstance : add_semigroup (ulift.{v} X.\u03b1) :=\n{ add := (+),\n  add_assoc := \u03bb a b c, by induction a; induction b; induction c; ext; simp [add_assoc] }\n\ninstance : add_monoid (ulift.{v} X.\u03b1) := \n{ ..(_ : add_zero_class (ulift.{v} X.\u03b1)),\n  ..(_ : add_semigroup (ulift.{v} X.\u03b1)) }\n\ninstance : add_comm_monoid (ulift.{v} X.\u03b1) :=\n{ add_comm := \u03bb a b, by induction a; induction b; ext; simp [add_comm],\n  ..(_ : add_monoid (ulift.{v} X.\u03b1)) }\n\ninstance : sub_neg_monoid (ulift.{v} X.\u03b1) :=\n{ neg := \u03bb x, ulift.rec_on x $ \u03bb a, up (-a),\n  nsmul := \u03bb n x, ulift.rec_on x $ \u03bb a, up (n \u2022 a),\n  nsmul_zero' := \u03bb x, by { induction x, dsimp only, ext, simp, },\n  nsmul_succ' := \u03bb n x, by { induction x, dsimp only, ext, simp [succ_nsmul], },\n  zsmul := \u03bb n x, ulift.rec_on x $ \u03bb a, up (n \u2022 a),\n  zsmul_zero' := \u03bb x, by { induction x, dsimp only, ext, simp, },\n  zsmul_succ' := \u03bb n x, begin\n    induction x,\n    ext,\n    dsimp only,\n    simp [add_smul, add_comm],\n  end,\n  zsmul_neg' := \u03bb 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.\u03b1)) }\n\n@[simp] lemma neg_down (x : ulift.{v} X.\u03b1) : (-x).down = - x.down :=\nbegin\n  induction x,\n  dsimp,\n  refl,\nend\n\ninstance : add_group (ulift.{v} X.\u03b1) :=\n{ add_left_neg := \u03bb a, by induction a; ext; simp,\n  ..(_ : sub_neg_monoid (ulift.{v} X.\u03b1))}\n\ninstance : add_comm_group (ulift.{v} X.\u03b1) := \n{ ..(_ : add_comm_monoid (ulift.{v} X.\u03b1)),\n  ..(_ : add_group (ulift.{v} X.\u03b1))}\n\nend ulift\n\ndef ulift (X : Ab.{u}) : Ab.{max u v} :=\n{ \u03b1 := ulift.{v} X.\u03b1,\n  str := infer_instance }\n\ndef ulift_functor : Ab.{u} \u2964 Ab.{max u v} :=\n{ obj := \u03bb X, X.ulift,\n  map := \u03bb X Y f, \n  { to_fun := \u03bb x, up $ f x.down,\n    map_zero' := by ext; simp,\n    map_add' := \u03bb x y, by ext; simp },\n  map_id' := \u03bb X, by ext x; simp,\n  map_comp' := \u03bb X Y Z h g, by ext; simp }\n\nlemma ulift_functor_map_down {X Y : Ab.{u}} (h : X \u27f6 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 \u2245 Y) :\n  ulift_functor.obj X \u2245 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 [\u2190 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 [\u2190 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 \u27f6 Y) :\n  kernel (ulift_functor.map h) \u2245 ulift_functor.obj (kernel h) :=\nbegin\n  refine kernel_iso_ker _ \u226a\u226b _,\n  refine _ \u226a\u226b(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 \u27e8x.1.down, _\u27e9,\n      have := x.2,\n      rw add_monoid_hom.mem_ker at this \u22a2,\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 \u27e8up x.down.1, _\u27e9,\n        have := x.down.2,\n        rw add_monoid_hom.mem_ker at this \u22a2,\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 \u211d V] [finite_dimensional \u211d V]\n\nnoncomputable def translate_gen {k : \u2115} (v : V) (G : unbounded_microid_generator V k) :\nunbounded_microid_generator V k :=\n\u03bb l, G l + v\n\nnoncomputable def scale_gen {k : \u2115} (c : \u211d) (G : unbounded_microid_generator V k) :\nunbounded_microid_generator V k :=\n\u03bb l, c \u2022 G l\n\nnoncomputable def scale_translate_gen {k : \u2115} (c : \u211d) (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\u2081 k\u2082 : \u2115}\n(\u03c6 : fin k\u2081.succ \u2192 fin k\u2082.succ)\n(G : unbounded_microid_generator V k\u2082) :\nunbounded_microid_generator V k\u2081 := G \u2218 \u03c6\n\ndef chop_generator {k : \u2115} {c : \u2115}\n(\u03c6 : fin c.succ \u2192 fin k.succ)\n(G : microid_generator_space V k) :\nmicroid_generator_space V c :=\nbegin\n  have Gprop := G.property,\n  refine \u27e8chop_generator' \u03c6 G, _\u27e9,\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 \u22a2,\n  rw [pi_norm_le_iff zero_le_one] at Gprop \u22a2,\n  intro b,\n  apply Gprop,\nend\n\nlemma chop_def {k : \u2115} {c : \u2115}\n{\u03c6 : fin c.succ \u2192 fin k.succ} :\n(chop_generator \u03c6 : microid_generator_space V k \u2192 microid_generator_space V c)\n= (\u03bb G, chop_generator \u03c6 G) := rfl\n\n/- lemma chop_smul {k\u2081 k\u2082 : \u2115}  {c : \u211d}\n(\u03c6 : fin k\u2081.succ \u2192 fin k\u2082.succ)\n(G : microid_generator_space V k\u2082) :\nchop -/\n\nnoncomputable def diam_generator' {k : \u2115}\n(G : unbounded_microid_generator V k) : \u211d :=\nmetric.diam (G '' set.univ)\n\nlemma pi_range_bounded {\u03b1 : Type} [fintype \u03b1]\n(f : \u03b1 \u2192 V) : metric.bounded (set.range f) :=\nbegin\n  let C := finset.sup finset.univ (has_nnnorm.nnnorm \u2218f),\n  refine \u27e8C + C, _\u27e9,\n  intros x hx y hy,\n  rcases set.mem_range.mp hx with \u27e8x, rfl\u27e9,\n  rcases set.mem_range.mp hy with \u27e8y, rfl\u27e9,\n  have nx : \u2225 f x \u2225\u208a \u2264 C := finset.le_sup (finset.mem_univ x),\n  have ny : \u2225 f y \u2225\u208a \u2264 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 : \u2115}\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 : \u2115} {\u03b5 : \u211d} (h\u03b5 : \u03b5 > 0)\n(x y : unbounded_microid_generator V k) (h : dist x y < \u03b5 / 4) :\ndiam_generator' x < \u03b5 + diam_generator' y :=\nbegin\n  have hh : \u03b5 / 2 < \u03b5 := half_lt_self h\u03b5,\n  have h\u03b4' : 0 \u2264 \u03b5 / 2 := div_nonneg (le_of_lt h\u03b5) (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 [\u2190@add_zero \u211d _ 0],\n    exact add_le_add h\u03b4' metric.diam_nonneg,\n  },\n  {\n    intros u hu v hv,\n    rcases (set.mem_image _ _ _).mp hu with \u27e8pu, hpu, rfl\u27e9,\n    rcases (set.mem_image _ _ _).mp hv with \u27e8pv, hpv, rfl\u27e9,\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 : \u2200 x : \u211d, x + x = 2 * x := sorry,\n      -- have two_gt: 2 > 0 := by positivity,\n      -- rw [this],\n      rw [\u2190dist_eq_norm],\n      have := metric.mem_ball.mp h,\n      -- rw [dist_comm] at this,\n      change dist x y + dist x y \u2264 \u03b5 / 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[\u2190dist_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 : \u2115) :\ncontinuous (diam_generator' : unbounded_microid_generator V k \u2192 \u211d) :=\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 \u27e8\u03b5, h\u03b5, hx\u27e9,\n  let \u03b4 := \u03b5 / 2,\n  have h\u03b4 : \u03b4 > 0 := half_pos h\u03b5,\n  have h\u03b4' : \u03b4 \u2265 0 := le_of_lt h\u03b4,\n  let \u03b3 := \u03b5 / 4,\n  have h\u03b3 : \u03b3 > 0,\n  {\n    apply div_pos h\u03b5,\n    simp only [zero_lt_bit0, zero_lt_one],\n  },\n  have h\u03b3' : \u03b3 \u2265 0 := le_of_lt h\u03b3,\n  have hh : \u03b4 < \u03b5 := half_lt_self h\u03b5,\n  refine \u27e8\u03b3, h\u03b3, _\u27e9,\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 \u27e8_, _\u27e9,\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\u03b5 _ _ 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\u03b5 _ _ hy,\n  },\nend\n\nlemma const_of_diam_zero {k : \u2115}\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 [\u2190h],\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 : \u2115}\n(G : unbounded_microid_generator V k) : unbounded_microid_generator V k :=\nscale_translate_gen (diam_generator' G)\u207b\u00b9 (-(G 0)) G\n\nnoncomputable def norm_generator {k : \u2115}\n(G : microid_generator_space V k) : microid_generator_space V k :=\nbegin\n  refine \u27e8norm_generator' G.val, _\u27e9,\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 : \u2200 b : fin k.succ, \u2225G.val b - G.val 0\u2225 \u2264 diam_generator' G.val,\n  {\n    intro b,\n    rw [\u2190dist_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 [\u2190real.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, \u2190sub_eq_add_neg],\n  have lem: \u2200 r : nnreal, r\u207b\u00b9 * r \u2264 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 \u2225diam_generator' G.val\u2225\u208a),\n  apply mul_le_mul_of_nonneg_left,\n  {\n    rw [\u2190nnreal.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 [\u2190nnreal.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 : \u2115}\n(G : unbounded_microid_generator V k) :\nnorm_generator' G =\nscale_translate_gen (diam_generator' G)\u207b\u00b9 (-(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\u2081 {k : \u2115}\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 [\u2190sub_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\u2082 {k : \u2115}\n(G : unbounded_microid_generator V k) (h : diam_generator' G \u2260 0) :\n(diam_generator' G)\u207b\u00b9 > 0 \u2227\nnorm_generator' G =\nscale_translate_gen (diam_generator' G)\u207b\u00b9 (-(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 \u27e8_, _\u27e9,\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 : \u2115}\n(G : unbounded_microid_generator V k) :\n\u2203 c : \u211d, c > 0 \u2227\nnorm_generator' G = scale_translate_gen c (-(G 0)) G :=\nbegin\n  by_cases h : diam_generator' G = 0,\n  {\n    refine \u27e81, zero_lt_one, _\u27e9,\n    exact norm_generator_positive_factor\u2081 G h,\n  },\n  {\n    refine \u27e8(diam_generator' G)\u207b\u00b9, _\u27e9,\n    exact norm_generator_positive_factor\u2082 G h,\n  }\nend\n\nlemma scale_translate_scale_translate {k : \u2115}\n{c\u2081 c\u2082 : \u211d} {v\u2081 v\u2082 : V} {G : unbounded_microid_generator V k} (hc\u2082 : c\u2082 \u2260 0) :\nscale_translate_gen c\u2081 v\u2081 (scale_translate_gen c\u2082 v\u2082 G) =\nscale_translate_gen (c\u2081 * c\u2082) (c\u2082\u207b\u00b9 \u2022 v\u2081 + v\u2082) G :=\nbegin\n  funext,\n  simp only [scale_translate_gen, scale_gen, translate_gen],\n  rw [\u2190smul_eq_mul, smul_assoc],\n  congr,\n  simp only [smul_add, smul_inv_smul\u2080 hc\u2082],\n  ac_refl,\nend\n\nlemma scale_translate_scale_translate' {k : \u2115}\n{c\u2081 c\u2082 : \u211d} {v\u2081 v\u2082 : V} {G : unbounded_microid_generator V k} :\nscale_translate_gen c\u2081 v\u2081 (scale_translate_gen c\u2082 v\u2082 G) =\ntranslate_gen (c\u2081 \u2022 v\u2081 + (c\u2081 \u2022 c\u2082 \u2022 v\u2082)) (scale_gen (c\u2081 * c\u2082) G) :=\nbegin\n  funext,\n  simp only [scale_translate_gen, scale_gen, translate_gen],\n  simp only [\u2190smul_eq_mul, smul_assoc, smul_add],\n  ac_refl,\nend\n\nlemma scale_translate_eq_translate_scale {k : \u2115}\n{c : \u211d} {v : V} {G : unbounded_microid_generator V k} :\nscale_gen c (translate_gen v G) = translate_gen (c \u2022 v) (scale_gen c G) :=\nbegin\n  funext,\n  simp only [scale_gen, translate_gen],\n  simp only [\u2190smul_eq_mul, smul_assoc, smul_add],\nend\n\nlemma scale_scale {k : \u2115}\n{c\u2081 c\u2082 : \u211d} {G : unbounded_microid_generator V k} :\nscale_gen c\u2081 (scale_gen c\u2082 G) = scale_gen (c\u2081 * c\u2082) G :=\nbegin\n  funext,\n  simp only [scale_gen],\n  simp only [\u2190smul_eq_mul, smul_assoc],\nend\n\nlemma translate_translate {k : \u2115}\n{v\u2081 v\u2082 : V} {G : unbounded_microid_generator V k} :\ntranslate_gen v\u2081 (translate_gen v\u2082 G) = translate_gen (v\u2081 + v\u2082) G :=\nbegin\n  funext,\n  simp only [translate_gen],\n  ac_refl,\nend\n\nlemma translate_zero_scale_1 {k : \u2115}\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 : \u2115}\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 : \u2115}\n(G : unbounded_microid_generator V k) :\n\u2203 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 \u27e8_, _\u27e9, 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 \u27e8_, _\u27e9, 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 : \u211d) {A : set V} (hA : metric.bounded A) :\nmetric.bounded (c \u2022 A) :=\nbegin\n  rcases hA with \u27e8C, hC\u27e9,\n  refine \u27e8\u2225c\u2225 * C, _\u27e9,\n  intros x hx y hy,\n  rcases set.mem_smul_set.mp hx with \u27e8px, hpx, rfl\u27e9,\n  rcases set.mem_smul_set.mp hy with \u27e8py, hpy, rfl\u27e9,\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 : \u211d} (h : c > 0) {A : set V} (hA : metric.bounded (c \u2022 A)) :\nmetric.bounded A :=\nbegin\n  convert smul_set_bounded c\u207b\u00b9 hA,\n  rw [inv_smul_smul\u2080 (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 \u27e8C, hC\u27e9,\n  refine \u27e8C, _\u27e9,\n  intros x hx y hy,\n  rcases hx with \u27e8xa, xv, hxa, hxv, rfl\u27e9,\n  rcases hy with \u27e8ya, yv, hya, hyv, rfl\u27e9,\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 : \u211d} (h : c \u2265 0) :\nmetric.diam (c \u2022 A) = c * (metric.diam A) :=\nbegin\n  revert A c,\n  suffices hle : \u2200 {A : set V} (hA : metric.bounded A) {c : \u211d}, c \u2265 0 \u2192 metric.diam (c \u2022 A) \u2264 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 \u2218 eq.symm) hc,\n        have := hle (smul_set_bounded c hA) (le_of_lt (inv_pos_of_pos hc)),\n        rw [\u2190mul_le_mul_left (inv_pos_of_pos hc), \u2190mul_assoc],\n        rw [inv_mul_cancel (ne_of_gt hc), one_mul],\n        convert this,\n        rw [inv_smul_smul\u2080 (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 \u2265 0 := metric.diam_nonneg,\n      positivity,\n    },\n    {\n      intros x hx y hy,\n      rcases set.mem_smul_set.mp hx with \u27e8px, hpx, rfl\u27e9,\n      rcases set.mem_smul_set.mp hy with \u27e8py, hpy, rfl\u27e9,\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 : \u2200 {A : set V} (hA : metric.bounded A) (v : V), metric.diam (A + {v}) \u2264 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 \u27e8xa, xv, hxa, hxv, rfl\u27e9,\n      rcases hy with \u27e8ya, yv, hya, hyv, rfl\u27e9,\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\u2081 k\u2082 : \u2115} {c : \u211d} (v : V)\n(\u03c6 : fin k\u2081.succ \u2192 fin k\u2082.succ)\n(G : unbounded_microid_generator V k\u2082) :\nchop_generator' \u03c6 (scale_translate_gen c v G) = scale_translate_gen c v (chop_generator' \u03c6 G) :=\nbegin\n  simp only [chop_generator', scale_translate_gen, scale_gen, translate_gen],\nend\n\nlemma chop_scale_translate' {k\u2081 k\u2082 : \u2115} {c : \u211d} (v : V)\n(\u03c6 : fin k\u2081.succ \u2192 fin k\u2082.succ)\n(G : unbounded_microid_generator V k\u2082) :\n(scale_translate_gen c v G) \u2218 \u03c6 = scale_translate_gen c v (G \u2218 \u03c6) :=\nbegin\n  simp only [chop_generator', scale_translate_gen, scale_gen, translate_gen],\nend\n\nlemma diam_scale_translate {k : \u2115} {c : \u211d} (hc : c \u2265 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 [\u2190pi.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 (\u03bb 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\u2081 k\u2082 : \u2115}\n(\u03c6 : fin k\u2081.succ \u2192 fin k\u2082.succ)\n(G : unbounded_microid_generator V k\u2082) :\ndiam_generator' G = 0 \u2192 diam_generator' (chop_generator' \u03c6 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 [\u2190set.image_comp, set.image_univ],\n    apply pi_range_bounded,\n  }\nend\n\nlemma scale_translate_zero {k : \u2115} {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\u2081 k\u2082 : \u2115}\n(\u03c6 : fin k\u2081.succ \u2192 fin k\u2082.succ)\n(G : unbounded_microid_generator V k\u2082) :\nnorm_generator' (chop_generator' \u03c6 (norm_generator' G)) = norm_generator' (chop_generator' \u03c6 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 [\u2190mul_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\u2080 h, neg_add, neg_neg, add_assoc,\n        add_neg_self, add_zero],\n    },\n  },\nend\n\nnoncomputable def prunenorm_generator {k : \u2115} {c : \u2115}\n(\u03c6 : fin c.succ \u2192 fin k.succ)\n(G : microid_generator_space V k) : microid_generator_space V c :=\nnorm_generator (chop_generator \u03c6 G)\n\nlemma prunenorm_def {k : \u2115} {c : \u2115}\n(\u03c6 : fin c.succ \u2192 fin k.succ) :\n(prunenorm_generator \u03c6 : microid_generator_space V k \u2192 microid_generator_space V c) =\nnorm_generator \u2218 chop_generator \u03c6 := rfl\n\nlemma norm_generator_idempotent {k : \u2115} (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 \u2265 0 := metric.diam_nonneg,\n      have idnn: (diam_generator' G)\u207b\u00b9 \u2265 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 [\u2190inv_inv (diam_generator' G)],\n      generalize : (diam_generator' G)\u207b\u00b9 = 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 : \u2115}\n(G : unbounded_microid_generator V k) :\ndiam_generator' (norm_generator' G) = 1 \u2228 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 : \u2115}\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 [\u2190sub_eq_add_neg, sub_self, smul_zero],\nend\n\n/- lemma translate_scale_eq_norm_generator {k : \u2115}\n{c : \u211d} (hc : c \u2265 0) (v : V) (G : unbounded_microid_generator V k) :\ndiam_generator' (scale_translate_gen c v G) = 1 \u2227 (scale_translate_gen c v G 0 = 0) \u2192\ntranslate_gen v (scale_gen c G) = norm_generator' G :=\nbegin\n  admit,\nend -/\n\nlemma translate_scale_eq_norm_generator' {k : \u2115} {c : \u211d} {v : V}\n(G H : unbounded_microid_generator V k)\n(h : H = translate_gen v (scale_gen c G)) (hc : c \u2265 0) :\n(diam_generator' H = 1 \u2228 diam_generator' G = 0) \u2192 H 0 = 0 \u2192 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 \u22a2,\n    replace hz := eq_neg_of_add_eq_zero_right hz,\n    simp only [hz],\n    funext,\n    rw [\u2190sub_eq_add_neg],\n    rw [\u2190sub_eq_add_neg],\n    rw [\u2190smul_sub],\n    congr,\n    apply eq_inv_of_mul_eq_one_left,\n    rw [diam_generator', set.image_univ, \u2190diam_smul (pi_range_bounded _) hc],\n    rw [\u2190set.image_univ],\n    rw [\u2190set_image_smul', set.image_univ],\n    rw [\u2190diam_translate (pi_range_bounded _), \u2190set.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 \u22a2,\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, \u2190sub_eq_add_neg, \u2190sub_eq_add_neg],\n    simp only [sub_self, smul_zero],\n  }\nend\n\nlemma diam_zero_of_diam_norm_zero {k : \u2115}\n(G : unbounded_microid_generator V k) :\ndiam_generator' (norm_generator' G) = 0 \u2192 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 : \u2115}\n(G : unbounded_microid_generator V k) :\ndiam_generator' G \u2260 0 \u2192 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\u2081 c\u2082 c\u2083: \u2115}\n(\u03c6\u2081 : fin c\u2081.succ \u2192 fin c\u2082.succ) (\u03c6\u2082 : fin c\u2082.succ \u2192 fin c\u2083.succ)\n(G : microid_generator_space V c\u2083) :\nprunenorm_generator \u03c6\u2081 (prunenorm_generator \u03c6\u2082 G) =\nprunenorm_generator (\u03c6\u2082 \u2218 \u03c6\u2081) 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' (\u2191G \u2218 \u03c6\u2082 \u2218 \u03c6\u2081) = 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\u2083.succ \u2192 V) \u2218 \u03c6\u2082) > 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, \u2190function.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 \u27e8a, vv, ha, rfl, rfl\u27e9,\n    refine \u27e8a, _, ha, rfl, _\u27e9,\n    rw [\u2190sub_eq_add_neg],\n  },\nend\n\nlemma diam_norm_generator_eq {k : \u2115}\n(G : unbounded_microid_generator V k) :\ndiam_generator' G \u2260 0 \u2192 diam_generator' (norm_generator' G) = 1 :=\nbegin\n  intro h,\n  rcases norm_generator_positive_factor\u2082 G h with \u27e8hgt, heq\u27e9,\n  simp only [diam_generator', scale_translate_gen, scale_gen, translate_gen, heq],\n  rw [\u2190pi.smul_def, set_image_smul'],\n  rw [diam_smul],\n  {\n    simp only [\u2190sub_eq_add_neg],\n    simp only [\u2190pi.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 : \u2115}\n{c : \u211d} {v : V} {G : unbounded_microid_generator V k} :\n(scale_translate_gen c v G) '' set.univ = c \u2022 ((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 \u27e8l, -, rfl\u27e9,\n    apply set.smul_mem_smul_set,\n    refine \u27e8G l, v, _, _, rfl\u27e9,\n    {exact \u27e8l, set.mem_univ _, rfl\u27e9},\n    {apply set.mem_singleton},\n  },\n  {\n    intro h,\n    rcases h with \u27e8y, \u27e8py, vv, \u27e8ppy, -, rfl\u27e9, hvv, rfl\u27e9, rfl\u27e9,\n    cases set.eq_of_mem_singleton hvv,\n    refine \u27e8ppy, set.mem_univ _, rfl\u27e9,\n  },\nend\n\nlemma polytope_of_norm_generator_smul {k : \u2115}\n(G : microid_generator_space V k) :\n\u2203 c : \u211d, c > 0 \u2227\n(polytope_of_microid_generator (norm_generator G)).val =\nc \u2022 ((polytope_of_microid_generator G).val + {-(G.val 0)}) :=\nbegin\n  rcases norm_generator_positive_factor G.val with \u27e8c, hc\u2081, hc\u2082\u27e9,\n  refine \u27e8c, hc\u2081, _\u27e9,\n  simp only [polytope_of_microid_generator, hc\u2082, norm_generator],\n  rw [\u2190set.image_univ],\n  rw [range_scale_translate],\n  rw [/- set_image_smul', -/ convex_hull_smul],\n  congr,\n  conv {to_rhs, rw [\u2190@convex_hull_singleton \u211d V _ _ _ (-(G.val 0))]},\n  rw [\u2190convex_hull_add, set.image_univ],\nend\n\nlemma h_vector_span_homothety (A : set V) {c : \u211d} (v : V)\n(h : c > 0) :\nvector_span \u211d A \u2265 vector_span \u211d (c \u2022 (A + {v})) :=\nbegin\n  refine submodule.span_le.mpr _,\n  simp only [vector_span],\n  rintro x \u27e8a\u2081, a\u2082, ha\u2081, ha\u2082, rfl\u27e9,\n  rcases set.mem_smul_set.mp ha\u2081 with \u27e8d\u2081, \u27e8e\u2081, v\u2081, he\u2081, hv\u2081, rfl\u27e9, rfl\u27e9,\n  rcases set.mem_smul_set.mp ha\u2082 with \u27e8d\u2082, \u27e8e\u2082, v\u2082, he\u2082, hv\u2082, rfl\u27e9, rfl\u27e9,\n  rcases set.eq_of_mem_singleton hv\u2081,\n  rcases set.eq_of_mem_singleton hv\u2082,\n  simp only [vsub_eq_sub],\n  rw [\u2190smul_sub],\n  change c \u2022 (e\u2081 + v - (e\u2082 + v)) \u2208 /- need change to remove \u2191 here -/ (submodule.span \u211d (A -\u1d65 A)),\n  refine submodule.smul_mem _ c _,\n  rw [add_sub_add_right_eq_sub],\n  apply submodule.subset_span,\n  refine \u27e8e\u2081, e\u2082, he\u2081, he\u2082, rfl\u27e9,\nend\n\nlemma vector_span_homothety {A : set V} {c : \u211d} (v : V)\n(h : c > 0) :\nvector_span \u211d (c \u2022 (A + {v})) = vector_span \u211d 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\u207b\u00b9 \u2022 ((c \u2022 (A + {v})) + {-c \u2022 v}),\n    {\n      simp only [smul_add, neg_smul, set.smul_set_singleton, smul_neg],\n      simp only [inv_smul_smul\u2080 (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 \u2022 (A + {v})) (-c \u2022 v) (inv_pos_of_pos h),\n  },\nend\n\nlemma gen_lfe_norm {k : \u2115}\n(G : microid_generator_space V k) :\nlfe \u22a4 (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 \u27e8c, hc\u2081, hc\u2082\u27e9,\n  refine \u27e8c \u2022 (-G.val 0), c, hc\u2081, _\u27e9,\n  simp only [bm.\u03c4, convex_body_of_polytope, hc\u2082],\n  --simp only [face_smul hc\u2081, face_translate],\n  simp only [normal_face_homothety _ hc\u2081],\n  simp only [smul_add],\n  simp only [set.smul_set_Union\u2082],\n  simp only [set.add_Union\u2082],\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 : \u2115}\n{t : \u2115 \u2192 unbounded_microid_generator V k}\n{tl : unbounded_microid_generator V k }\n(htt : filter.tendsto t filter.at_top (\ud835\udcdd tl))\n(hd : \u2200 n : \u2115, diam_generator' (t n) = 1) :\ndiam_generator' tl = 1 :=\nbegin\n  simp only [diam_generator'],\n  have tt\u2081 : filter.tendsto (\u03bb n : \u2115, diam_generator' (t n)) filter.at_top (\ud835\udcdd (diam_generator' tl)),\n  {\n    have := @continuous.continuous_at (unbounded_microid_generator V k) \u211d _ _ _ _ (diam_continuous k),\n    convert (filter.tendsto.comp this htt),\n  },\n  have tt\u2082 : filter.tendsto (\u03bb n : \u2115, diam_generator' (t n)) filter.at_top (\ud835\udcdd 1),\n  {\n    simp only [hd],\n    exact tendsto_const_nhds,\n  },\n  exact tendsto_nhds_unique tt\u2081 tt\u2082,\nend\n\nlemma prunenorm_id_eq_norm {k : \u2115} :\n(prunenorm_generator id : microid_generator_space V k \u2192 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 {\u03b1 : Type*} {n : \u2115}\n\nattribute [simp] head_cons tail_cons\n\ninstance [inhabited \u03b1] : inhabited (vector \u03b1 n) :=\n\u27e8of_fn (\u03bb _, default \u03b1)\u27e9\n\ntheorem to_list_injective : function.injective (@to_list \u03b1 n) :=\nsubtype.val_injective\n\n@[simp] theorem to_list_of_fn : \u2200 {n} (f : fin n \u2192 \u03b1), 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  \u2200 (v : vector \u03b1 n) h, (\u27e8to_list v, h\u27e9 : vector \u03b1 n) = v\n| \u27e8l, h\u2081\u27e9 h\u2082 := rfl\n\ntheorem nth_eq_nth_le : \u2200 (v : vector \u03b1 n) (i),\n  nth v i = v.to_list.nth_le i.1 (by rw to_list_length; exact i.2)\n| \u27e8l, h\u27e9 i := rfl\n\n@[simp] theorem nth_of_fn {n} (f : fin n \u2192 \u03b1) (i) : nth (of_fn f) i = f i :=\nby rw [nth_eq_nth_le, \u2190 list.nth_le_of_fn f];\n   congr; apply to_list_of_fn\n\n@[simp] theorem of_fn_nth (v : vector \u03b1 n) : of_fn (nth v) = v :=\nbegin\n  rcases v with \u27e8l, rfl\u27e9,\n  apply to_list_injective,\n  change nth \u27e8l, eq.refl _\u27e9 with \u03bb i, nth \u27e8l, rfl\u27e9 i,\n  simp [nth, list.of_fn_nth_le]\nend\n\n@[simp] theorem nth_tail : \u2200 (v : vector \u03b1 n.succ) (i : fin n),\n  nth (tail v) i = nth v i.succ\n| \u27e8a::l, e\u27e9 \u27e8i, h\u27e9 := by simp [nth_eq_nth_le]; refl\n\n@[simp] theorem tail_of_fn {n : \u2115} (f : fin n.succ \u2192 \u03b1) :\n  tail (of_fn f) = of_fn (\u03bb i, f i.succ) :=\n(of_fn_nth _).symm.trans $ by congr; funext i; simp\n\ntheorem head'_to_list : \u2200 (v : vector \u03b1 n.succ),\n  (to_list v).head' = some (head v)\n| \u27e8a::l, e\u27e9 := rfl\n\ndef reverse (v : vector \u03b1 n) : vector \u03b1 n :=\n\u27e8v.to_list.reverse, by simp\u27e9\n\n@[simp] theorem nth_zero : \u2200 (v : vector \u03b1 n.succ), nth v 0 = head v\n| \u27e8a::l, e\u27e9 := rfl\n\n@[simp] theorem head_of_fn\n  {n : \u2115} (f : fin n.succ \u2192 \u03b1) : head (of_fn f) = f 0 :=\nby rw [\u2190 nth_zero, nth_of_fn]\n\n@[simp] theorem nth_cons_zero\n  (a : \u03b1) (v : vector \u03b1 n) : nth (a :: v) 0 = a :=\nby simp [nth_zero]\n\n@[simp] theorem nth_cons_succ\n  (a : \u03b1) (v : vector \u03b1 n) (i : fin n) : nth (a :: v) i.succ = nth v i :=\nby rw [\u2190 nth_tail, tail_cons]\n\ndef {u} m_of_fn {m} [monad m] {\u03b1 : Type u} : \u2200 {n}, (fin n \u2192 m \u03b1) \u2192 m (vector \u03b1 n)\n| 0     f := pure nil\n| (n+1) f := do a \u2190 f 0, v \u2190 m_of_fn (\u03bbi, f i.succ), pure (a :: v)\n\ntheorem m_of_fn_pure {m} [monad m] [is_lawful_monad m] {\u03b1} :\n  \u2200 {n} (f : fin n \u2192 \u03b1), @m_of_fn m _ _ _ (\u03bb 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] {\u03b1} {\u03b2 : Type u} (f : \u03b1 \u2192 m \u03b2) :\n  \u2200 {n}, vector \u03b1 n \u2192 m (vector \u03b2 n)\n| _ \u27e8[], rfl\u27e9   := pure nil\n| _ \u27e8a::l, rfl\u27e9 := do h' \u2190 f a, t' \u2190 mmap \u27e8l, rfl\u27e9, pure (h' :: t')\n\n@[simp] theorem mmap_nil {m} [monad m] {\u03b1 \u03b2} (f : \u03b1 \u2192 m \u03b2) :\n  mmap f nil = pure nil := rfl\n\n@[simp] theorem mmap_cons {m} [monad m] {\u03b1 \u03b2} (f : \u03b1 \u2192 m \u03b2) (a) :\n  \u2200 {n} (v : vector \u03b1 n), mmap f (a::v) =\n  do h' \u2190 f a, t' \u2190 mmap f v, pure (h' :: t')\n| _ \u27e8l, rfl\u27e9 := rfl\n\n@[extensionality] theorem ext : \u2200 {v w : vector \u03b1 n}\n  (h : \u2200 m : fin n, vector.nth v m = vector.nth w m), v = w\n| \u27e8v, hv\u27e9 \u27e8w, hw\u27e9 h := subtype.eq (list.ext_le (by rw [hv, hw])\n  (\u03bb m hm hn, h \u27e8m, hv \u25b8 hm\u27e9))\n\ndef to_array : vector \u03b1 n \u2192 array n \u03b1\n| \u27e8xs, h\u27e9 := cast (by rw h) xs.to_array\n\nend vector\n\nnamespace vector\n\nuniverses u\nvariables {n : \u2115}\n\nsection traverse\n\nvariables {F G : Type u \u2192 Type u}\nvariables [applicative F] [applicative G]\n\nopen applicative functor\nopen list (cons) nat\n\nprivate def traverse_aux {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 F \u03b2) :\n  \u03a0 (x : list \u03b1), F (vector \u03b2 x.length)\n| []      := pure vector.nil\n| (x::xs) := vector.cons <$> f x <*> traverse_aux xs\n\nprotected def traverse {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 F \u03b2) : vector \u03b1 n \u2192 F (vector \u03b2 n)\n| \u27e8v, Hv\u27e9 := cast (by rw Hv) $ traverse_aux f v\n\nvariables [is_lawful_applicative F] [is_lawful_applicative G]\nvariables {\u03b1 \u03b2 \u03b3 : Type u}\n\n@[simp] protected lemma traverse_def\n  (f : \u03b1 \u2192 F \u03b2) (x : \u03b1) : \u2200 (xs : vector \u03b1 n),\n  (x :: xs).traverse f = cons <$> f x <*> xs.traverse f :=\nby rintro \u27e8xs, rfl\u27e9; refl\n\nprotected lemma id_traverse : \u2200 (x : vector \u03b1 n), x.traverse id.mk = x :=\nbegin\n  rintro \u27e8x, rfl\u27e9, 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 : \u03b2 \u2192 F \u03b3) (g : \u03b1 \u2192 G \u03b2) : \u2200 (x : vector \u03b1 n),\n  vector.traverse (comp.mk \u2218 functor.map f \u2218 g) x =\n  comp.mk (vector.traverse f <$> vector.traverse g x) :=\nby rintro \u27e8x, rfl\u27e9; dsimp [vector.traverse, cast];\n   induction x with x xs; simp! [cast, *] with functor_norm;\n   [refl, simp [(\u2218)]]\n\nprotected lemma traverse_eq_map_id {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) : \u2200 (x : vector \u03b1 n),\n  x.traverse (id.mk \u2218 f) = id.mk (map f x) :=\nby rintro \u27e8x, rfl\u27e9; simp!;\n   induction x; simp! * with functor_norm; refl\n\nvariable (\u03b7 : applicative_transformation F G)\n\nprotected lemma naturality {\u03b1 \u03b2 : Type*}\n  (f : \u03b1 \u2192 F \u03b2) : \u2200 (x : vector \u03b1 n),\n  \u03b7 (x.traverse f) = x.traverse (@\u03b7 _ \u2218 f) :=\nby rintro \u27e8x, rfl\u27e9; 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 := \u03bb \u03b1 \u03b2, @vector.map.{u u} \u03b1 \u03b2 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 \u03b1] (as : List \u03b1) (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, \u27e80, _\u27e9 => simp_arith [get]\n  | a::as, \u27e8i+1, h\u27e9 =>\n    simp [get]\n    have h : i < as.length := Nat.lt_of_succ_lt_succ h\n    have ih := sizeOf_get_lt as \u27e8i, h\u27e9\n    exact Nat.lt_of_lt_of_le ih (Nat.le_add_left ..)\n\nnamespace Array\n\ninstance [DecidableEq \u03b1] : Membership \u03b1 (Array \u03b1) where\n  mem a as := as.contains a\n\ntheorem sizeOf_get_lt [SizeOf \u03b1] (as : Array \u03b1) (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 \u03b1] [SizeOf \u03b1] {as : Array \u03b1} (h : a \u2208 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    \u00b7 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    \u00b7 contradiction\n  apply aux 0 h\ntermination_by aux j _ => as.size - j\n\n@[simp] theorem sizeOf_get [SizeOf \u03b1] (as : Array \u03b1) (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 \u2192 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 : \u2200 a, a \u2208 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 \u2243 B \u2192 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    (\u03bb b,\n      have g b \u2208 elements_of A, from fintype.complete (g b),\n      have f (g b) \u2208 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 (\u03bb u, match u with star := dec_trivial end)\n\ndefinition fintype_bool [instance] : fintype bool :=\nfintype.mk [ff, tt]\n  dec_trivial\n  (\u03bb b, match b with | tt := dec_trivial | ff := dec_trivial end)\n\ndefinition fintype_product [instance] {A B : Type} : \u03a0 [h\u2081 : fintype A] [h\u2082 : fintype B], fintype (A \u00d7 B)\n| (fintype.mk e\u2081 u\u2081 c\u2081) (fintype.mk e\u2082 u\u2082 c\u2082) :=\n  fintype.mk\n    (product e\u2081 e\u2082)\n    (nodup_product u\u2081 u\u2082)\n    (\u03bb p,\n      match p with\n      (a, b) := mem_product (c\u2081 a) (c\u2082 b)\n      end)\n\n/- auxiliary function for finding 'a' s.t. f a \u2260 g a -/\nsection find_discr\nvariables {A B : Type}\nvariable  [h : decidable_eq B]\ninclude h\ndefinition find_discr (f g : A \u2192 B) : list A \u2192 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 \u2192 B) : find_discr f g [] = none :=\nrfl\n\ntheorem find_discr_cons_of_ne {f g : A \u2192 B} {a : A} (l : list A) : f a \u2260 g a \u2192 find_discr f g (a::l) = some a :=\nassume ne, if_neg ne\n\ntheorem find_discr_cons_of_eq {f g : A \u2192 B} {a : A} (l : list A) : f a = g a \u2192 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 \u2192 B} {a : A} : \u2200 {l}, find_discr f g l = some a \u2192 f a \u2260 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 \u2260 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 \u2192 B} : \u2200 {l}, find_discr f g l = none \u2192 \u2200 a, a \u2208 l \u2192 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 \u2208 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 \u2260 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\u2081 : fintype A] [h\u2082 : decidable_eq B] : decidable_eq (A \u2192 B) :=\n\u03bb f g,\n  match h\u2081 with\n  | fintype.mk e u c :=\n    match find_discr f g e with\n    | some a := \u03bb h : find_discr f g e = some a, inr (\u03bb f_eq_g : f = g, absurd (by rewrite f_eq_g; reflexivity) (ne_of_find_discr_eq_some h))\n    | none   := \u03bb h : find_discr f g e = none, inl (show f = g, from funext (\u03bb 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 \u2192 Prop) [h : decidable_pred p] : list A \u2192 bool\n| []     := tt\n| (a::l) := if p a then check_pred l else ff\n\ntheorem check_pred_cons_of_pos {p : A \u2192 Prop} [h : decidable_pred p] {a : A} (l : list A) : p a \u2192 check_pred p (a::l) = check_pred p l :=\nassume pa, if_pos pa\n\ntheorem check_pred_cons_of_neg {p : A \u2192 Prop} [h : decidable_pred p] {a : A} (l : list A) : \u00ac p a \u2192 check_pred p (a::l) = ff :=\nassume npa, if_neg npa\n\ntheorem all_of_check_pred_eq_tt {p : A \u2192 Prop} [h : decidable_pred p] : \u2200 {l : list A}, check_pred p l = tt \u2192 \u2200 {a}, a \u2208 l \u2192 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 \u2208 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 \u2208 l`))\n  (suppose \u00ac 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 \u2192 Prop} [h : decidable_pred p] : \u2200 {l : list A}, check_pred p l = ff \u2192 \u2203 w, \u00ac 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 \u00ac p a, exists.intro a this)\nend check_pred\n\ndefinition decidable_forall_finite [instance] {A : Type} {p : A \u2192 Prop} [h\u2081 : fintype A] [h\u2082 : decidable_pred p]\n           : decidable (\u2200 x : A, p x) :=\nmatch h\u2081 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 \u2200 x, p x,\n         obtain (a : A) (w : \u00ac 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 \u2192 Prop} [h\u2081 : fintype A] [h\u2082 : decidable_pred p]\n           : decidable (\u2203 x : A, p x) :=\nmatch h\u2081 with\n| fintype.mk e u c :=\n  match check_pred (\u03bb a, \u00ac p a) e with\n  | tt := \u03bb h : check_pred (\u03bb a, \u00ac p a) e = tt, inr (\u03bb ex : (\u2203 x, p x),\n          obtain x px, from ex,\n          absurd px (all_of_check_pred_eq_tt h (c x)))\n  | ff := \u03bb h : check_pred (\u03bb a, \u00ac p a) e = ff, inl (\n          have \u2203 x, \u00ac\u00acp 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 \u27eas\u27eb is notation for (list.as_type l)\n-- We use this function to define the instance for (fintype \u27eas\u27eb)\nprivate definition ltype_elems {A : Type} {s : list A} : \u03a0 {l : list A}, l \u2286 s \u2192 list \u27eas\u27eb\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                : \u03a0 {l : list A} {h : l \u2286 s} {m : a \u2208 s}, mk a m \u2208 ltype_elems h \u2192 a \u2208 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 (\u03bb aeqb em, by rewrite [aeqb]; exact !mem_cons))\n  (suppose mk a m \u2208 ltype_elems (sub_of_cons_sub h),\n     have a \u2208 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} : \u03a0 {l : list A} (d : nodup l) (h : l \u2286 s), nodup (ltype_elems h)\n| []     d h := nodup_nil\n| (a::l) d h :=\n  have d\u2081    : nodup l, from nodup_of_nodup_cons d,\n  have nainl : a \u2209 l, from not_mem_of_nodup_cons d,\n  let  h\u2081    : l \u2286 s := sub_of_cons_sub h in\n  have d\u2082    : nodup (ltype_elems h\u2081), from nodup_ltype_elems d\u2081 h\u2081,\n  have nin   : mk a (h a (mem_cons a l)) \u2209 ltype_elems h\u2081, from\n    assume ab, absurd (mem_of_mem_ltype_elems ab) nainl,\n  nodup_cons nin d\u2082\n\nprivate theorem mem_ltype_elems {A : Type} {s : list A} {a : \u27eas\u27eb}\n                : \u03a0 {l : list A} (h : l \u2286 s), value a \u2208 l \u2192 a \u2208 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  (\u03bb 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  (\u03bb vainl : value a \u2208 l,\n     have aux : a \u2208 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 \u27eas\u27eb :=\nlet  nds   : list A := erase_dup s in\nhave sub\u2081  : nds \u2286 s,   from erase_dup_sub s,\nhave sub\u2082  : s \u2286 nds,   from sub_erase_dup s,\nhave dnds  : nodup nds, from nodup_erase_dup s,\nlet  e     : list \u27eas\u27eb := ltype_elems sub\u2081 in\nfintype.mk\n  e\n  (nodup_ltype_elems dnds sub\u2081)\n  (take a : \u27eas\u27eb,\n   show a \u2208 e, from\n     have value a \u2208 s,   from is_member a,\n     have value a \u2208 nds, from sub\u2082 this,\n     mem_ltype_elems sub\u2081 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 : \u2115 \u2192 \u03b2` is Cauchy.\n* `CauSeq`: the type of Cauchy sequences valued in type `\u03b2` 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 {\u03b1} [LinearOrder \u03b1] {P Q : \u03b1 \u2192 Prop} :\n    (\u2203 i, \u2200 j \u2265 i, P j) \u2192 (\u2203 i, \u2200 j \u2265 i, Q j) \u2192 \u2203 i, \u2200 j \u2265 i, P j \u2227 Q j\n  | \u27e8a, h\u2081\u27e9, \u27e8b, h\u2082\u27e9 =>\n    let \u27e8c, ac, bc\u27e9 := exists_ge_of_linear a b\n    \u27e8c, fun _ hj => \u27e8h\u2081 _ (le_trans ac hj), h\u2082 _ (le_trans bc hj)\u27e9\u27e9\n#align exists_forall_ge_and exists_forall_ge_and\n\nsection\n\nvariable [LinearOrderedField \u03b1] [Ring \u03b2] (abv : \u03b2 \u2192 \u03b1) [IsAbsoluteValue abv]\n\ntheorem rat_add_continuous_lemma {\u03b5 : \u03b1} (\u03b50 : 0 < \u03b5) :\n    \u2203 \u03b4 > 0, \u2200 {a\u2081 a\u2082 b\u2081 b\u2082 : \u03b2}, abv (a\u2081 - b\u2081) < \u03b4 \u2192 abv (a\u2082 - b\u2082) < \u03b4 \u2192\n      abv (a\u2081 + a\u2082 - (b\u2081 + b\u2082)) < \u03b5 :=\n  \u27e8\u03b5 / 2, half_pos \u03b50, fun {a\u2081 a\u2082 b\u2081 b\u2082} h\u2081 h\u2082 => 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\u2081 h\u2082)\u27e9\n#align rat_add_continuous_lemma rat_add_continuous_lemma\n\ntheorem rat_mul_continuous_lemma {\u03b5 K\u2081 K\u2082 : \u03b1} (\u03b50 : 0 < \u03b5) :\n    \u2203 \u03b4 > 0, \u2200 {a\u2081 a\u2082 b\u2081 b\u2082 : \u03b2}, abv a\u2081 < K\u2081 \u2192 abv b\u2082 < K\u2082 \u2192 abv (a\u2081 - b\u2081) < \u03b4 \u2192\n      abv (a\u2082 - b\u2082) < \u03b4 \u2192 abv (a\u2081 * a\u2082 - b\u2081 * b\u2082) < \u03b5 := by\n  have K0 : (0 : \u03b1) < max 1 (max K\u2081 K\u2082) := lt_of_lt_of_le zero_lt_one (le_max_left _ _)\n  have \u03b5K := div_pos (half_pos \u03b50) K0\n  refine' \u27e8_, \u03b5K, fun {a\u2081 a\u2082 b\u2081 b\u2082} ha\u2081 hb\u2082 h\u2081 h\u2082 => _\u27e9\n  replace ha\u2081 := lt_of_lt_of_le ha\u2081 (le_trans (le_max_left _ K\u2082) (le_max_right 1 _))\n  replace hb\u2082 := lt_of_lt_of_le hb\u2082 (le_trans (le_max_right K\u2081 _) (le_max_right 1 _))\n  have :=\n    add_lt_add (mul_lt_mul' (le_of_lt h\u2081) hb\u2082 (abv_nonneg abv _) \u03b5K)\n      (mul_lt_mul' (le_of_lt h\u2082) ha\u2081 (abv_nonneg abv _) \u03b5K)\n  rw [\u2190 abv_mul abv, mul_comm, div_mul_cancel _ (ne_of_gt K0), \u2190 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 {\u03b2 : Type _} [DivisionRing \u03b2] (abv : \u03b2 \u2192 \u03b1) [IsAbsoluteValue abv]\n    {\u03b5 K : \u03b1} (\u03b50 : 0 < \u03b5) (K0 : 0 < K) :\n    \u2203 \u03b4 > 0, \u2200 {a b : \u03b2}, K \u2264 abv a \u2192 K \u2264 abv b \u2192 abv (a - b) < \u03b4 \u2192 abv (a\u207b\u00b9 - b\u207b\u00b9) < \u03b5 := by\n  refine' \u27e8K * \u03b5 * K, mul_pos (mul_pos K0 \u03b50) K0, fun {a b} ha hb h => _\u27e9\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\u2080 b0.ne', \u2190 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 \u03b50.le a0.le) hb K0.le (mul_nonneg a0.le \u03b50.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 {\u03b1 : Type _} [LinearOrderedField \u03b1] {\u03b2 : Type _} [Ring \u03b2] (abv : \u03b2 \u2192 \u03b1) (f : \u2115 \u2192 \u03b2) :\n    Prop :=\n  \u2200 \u03b5 > 0, \u2203 i, \u2200 j \u2265 i, abv (f j - f i) < \u03b5\n#align is_cau_seq IsCauSeq\n\nnamespace IsCauSeq\n\nvariable [LinearOrderedField \u03b1] [Ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [IsAbsoluteValue abv] {f g : \u2115 \u2192 \u03b2}\n\n-- see Note [nolint_ge]\n--@[nolint ge_or_gt] -- Porting note: restore attribute\ntheorem cauchy\u2082 (hf : IsCauSeq abv f) {\u03b5 : \u03b1} (\u03b50 : 0 < \u03b5) :\n    \u2203 i, \u2200 j \u2265 i, \u2200 k \u2265 i, abv (f j - f k) < \u03b5 := by\n  refine' (hf _ (half_pos \u03b50)).imp fun i hi j ij k ik => _\n  rw [\u2190 add_halves \u03b5]\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\u2082 IsCauSeq.cauchy\u2082\n\ntheorem cauchy\u2083 (hf : IsCauSeq abv f) {\u03b5 : \u03b1} (\u03b50 : 0 < \u03b5) :\n    \u2203 i, \u2200 j \u2265 i, \u2200 k \u2265 j, abv (f k - f j) < \u03b5 :=\n  let \u27e8i, H\u27e9 := hf.cauchy\u2082 \u03b50\n  \u27e8i, fun _ ij _ jk => H _ (le_trans ij jk) _ ij\u27e9\n#align is_cau_seq.cauchy\u2083 IsCauSeq.cauchy\u2083\n\ntheorem add (hf : IsCauSeq abv f) (hg : IsCauSeq abv g) : IsCauSeq abv (f + g) := fun _ \u03b50 =>\n  let \u27e8_, \u03b40, H\u03b4\u27e9 := rat_add_continuous_lemma abv \u03b50\n  let \u27e8i, H\u27e9 := exists_forall_ge_and (hf.cauchy\u2083 \u03b40) (hg.cauchy\u2083 \u03b40)\n  \u27e8i, fun _ ij =>\n    let \u27e8H\u2081, H\u2082\u27e9 := H _ le_rfl\n    H\u03b4 (H\u2081 _ ij) (H\u2082 _ ij)\u27e9\n#align is_cau_seq.add IsCauSeq.add\n\nend IsCauSeq\n\n/-- `CauSeq \u03b2 abv` is the type of `\u03b2`-valued Cauchy sequences, with respect to the absolute value\nfunction `abv`. -/\ndef CauSeq {\u03b1 : Type _} [LinearOrderedField \u03b1] (\u03b2 : Type _) [Ring \u03b2] (abv : \u03b2 \u2192 \u03b1) : Type _ :=\n  { f : \u2115 \u2192 \u03b2 // IsCauSeq abv f }\n#align cau_seq CauSeq\n\nnamespace CauSeq\n\nvariable [LinearOrderedField \u03b1]\n\nsection Ring\n\nvariable [Ring \u03b2] {abv : \u03b2 \u2192 \u03b1}\n\ninstance : CoeFun (CauSeq \u03b2 abv) fun _ => \u2115 \u2192 \u03b2 :=\n  \u27e8Subtype.val\u27e9\n\n-- Porting note: Remove coeFn theorem\n/-@[simp]\ntheorem mk_to_fun (f) (hf : IsCauSeq abv f) : @coeFn (CauSeq \u03b2 abv) _ _ \u27e8f, hf\u27e9 = f :=\n  rfl -/\n#noalign cau_seq.mk_to_fun\n\ntheorem ext {f g : CauSeq \u03b2 abv} (h : \u2200 i, f i = g i) : f = g :=\n  Subtype.eq (funext h)\n#align cau_seq.ext CauSeq.ext\n\ntheorem isCauSeq (f : CauSeq \u03b2 abv) : IsCauSeq abv f :=\n  f.2\n#align cau_seq.is_cau CauSeq.isCauSeq\n\ntheorem cauchy (f : CauSeq \u03b2 abv) : \u2200 {\u03b5}, 0 < \u03b5 \u2192 \u2203 i, \u2200 j \u2265 i, abv (f j - f i) < \u03b5 := @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 \u03b2 abv) (g : \u2115 \u2192 \u03b2) (e : \u2200 i, f i = g i) : CauSeq \u03b2 abv :=\n  \u27e8g, fun \u03b5 => by rw [show g = f from (funext e).symm]; exact f.cauchy\u27e9\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\u2082 (f : CauSeq \u03b2 abv) {\u03b5} :\n    0 < \u03b5 \u2192 \u2203 i, \u2200 (j) (_ : j \u2265 i) (k) (_ : k \u2265 i), abv (f j - f k) < \u03b5 :=\n  f.2.cauchy\u2082\n#align cau_seq.cauchy\u2082 CauSeq.cauchy\u2082\n\ntheorem cauchy\u2083 (f : CauSeq \u03b2 abv) {\u03b5} : 0 < \u03b5 \u2192 \u2203 i, \u2200 j \u2265 i, \u2200 k \u2265 j, abv (f k - f j) < \u03b5 :=\n  f.2.cauchy\u2083\n#align cau_seq.cauchy\u2083 CauSeq.cauchy\u2083\n\ntheorem bounded (f : CauSeq \u03b2 abv) : \u2203 r, \u2200 i, abv (f i) < r := by\n  cases' f.cauchy zero_lt_one with i h\n  set R : \u2115 \u2192 \u03b1 := @Nat.rec (fun _ => \u03b1) (abv (f 0)) fun i c => max c (abv (f i.succ)) with hR\n  have : \u2200 i, \u2200 j \u2264 i, abv (f j) \u2264 R i := by\n    refine' Nat.rec (by simp [hR]) _\n    rintro i hi j (rfl | hj)\n    \u00b7 simp\n    exact (hi j hj).trans (le_max_left _ _)\n  refine' \u27e8R i + 1, fun j => _\u27e9\n  cases' lt_or_le j i with ij ij\n  \u00b7 exact lt_of_le_of_lt (this i _ (le_of_lt ij)) (lt_add_one _)\n  \u00b7 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 \u03b2 abv) (x : \u03b1) : \u2203 r > x, \u2200 i, abv (f i) < r :=\n  let \u27e8r, h\u27e9 := f.bounded\n  \u27e8max 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 _ _)\u27e9\n#align cau_seq.bounded' CauSeq.bounded'\n\ninstance : Add (CauSeq \u03b2 abv) :=\n  \u27e8fun f g => \u27e8f + g, f.2.add g.2\u27e9\u27e9\n\n@[simp, norm_cast]\ntheorem coe_add (f g : CauSeq \u03b2 abv) : \u21d1(f + g) = (f : \u2115 \u2192 \u03b2) + g :=\n  rfl\n#align cau_seq.coe_add CauSeq.coe_add\n\n@[simp, norm_cast]\ntheorem add_apply (f g : CauSeq \u03b2 abv) (i : \u2115) : (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 : \u03b2) : CauSeq \u03b2 abv :=\n  \u27e8fun _ => x, fun \u03b5 \u03b50 => \u27e80, fun j _ => by simpa [abv_zero] using \u03b50\u27e9\u27e9\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 : \u03b2) : (const x : \u2115 \u2192 \u03b2) = Function.const \u2115 x :=\n  rfl\n#align cau_seq.coe_const CauSeq.coe_const\n\n@[simp, norm_cast]\ntheorem const_apply (x : \u03b2) (i : \u2115) : (const x : \u2115 \u2192 \u03b2) i = x :=\n  rfl\n#align cau_seq.const_apply CauSeq.const_apply\n\ntheorem const_inj {x y : \u03b2} : (const x : CauSeq \u03b2 abv) = const y \u2194 x = y :=\n  \u27e8fun h => congr_arg (fun f : CauSeq \u03b2 abv => (f : \u2115 \u2192 \u03b2) 0) h, congr_arg _\u27e9\n#align cau_seq.const_inj CauSeq.const_inj\n\ninstance : Zero (CauSeq \u03b2 abv) :=\n  \u27e8const 0\u27e9\n\ninstance : One (CauSeq \u03b2 abv) :=\n  \u27e8const 1\u27e9\n\ninstance : Inhabited (CauSeq \u03b2 abv) :=\n  \u27e80\u27e9\n\n@[simp, norm_cast]\ntheorem coe_zero : \u21d1(0 : CauSeq \u03b2 abv) = 0 :=\n  rfl\n#align cau_seq.coe_zero CauSeq.coe_zero\n\n@[simp, norm_cast]\ntheorem coe_one : \u21d1(1 : CauSeq \u03b2 abv) = 1 :=\n  rfl\n#align cau_seq.coe_one CauSeq.coe_one\n\n@[simp, norm_cast]\ntheorem zero_apply (i) : (0 : CauSeq \u03b2 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 \u03b2 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 : \u03b2) : const (x + y) = const x + const y :=\n  rfl\n#align cau_seq.const_add CauSeq.const_add\n\ninstance : Mul (CauSeq \u03b2 abv) :=\n  \u27e8fun f g =>\n    \u27e8f * g, fun _ \u03b50 =>\n      let \u27e8_, _, hF\u27e9 := f.bounded' 0\n      let \u27e8_, _, hG\u27e9 := g.bounded' 0\n      let \u27e8_, \u03b40, H\u03b4\u27e9 := rat_mul_continuous_lemma abv \u03b50\n      let \u27e8i, H\u27e9 := exists_forall_ge_and (f.cauchy\u2083 \u03b40) (g.cauchy\u2083 \u03b40)\n      \u27e8i, fun j ij =>\n        let \u27e8H\u2081, H\u2082\u27e9 := H _ le_rfl\n        H\u03b4 (hF j) (hG i) (H\u2081 _ ij) (H\u2082 _ ij)\u27e9\u27e9\u27e9\n\n@[simp, norm_cast]\ntheorem coe_mul (f g : CauSeq \u03b2 abv) : \u21d1(f * g) = (f : \u2115 \u2192 \u03b2) * g :=\n  rfl\n#align cau_seq.coe_mul CauSeq.coe_mul\n\n@[simp, norm_cast]\ntheorem mul_apply (f g : CauSeq \u03b2 abv) (i : \u2115) : (f * g) i = f i * g i :=\n  rfl\n#align cau_seq.mul_apply CauSeq.mul_apply\n\ntheorem const_mul (x y : \u03b2) : const (x * y) = const x * const y :=\n  rfl\n#align cau_seq.const_mul CauSeq.const_mul\n\ninstance : Neg (CauSeq \u03b2 abv) :=\n  \u27e8fun f => ofEq (const (-1) * f) (fun x => -f x) fun i => by simp\u27e9\n\n@[simp, norm_cast]\ntheorem coe_neg (f : CauSeq \u03b2 abv) : \u21d1(-f) = -f :=\n  rfl\n#align cau_seq.coe_neg CauSeq.coe_neg\n\n@[simp, norm_cast]\ntheorem neg_apply (f : CauSeq \u03b2 abv) (i) : (-f) i = -f i :=\n  rfl\n#align cau_seq.neg_apply CauSeq.neg_apply\n\ntheorem const_neg (x : \u03b2) : const (-x) = -const x :=\n  rfl\n#align cau_seq.const_neg CauSeq.const_neg\n\ninstance : Sub (CauSeq \u03b2 abv) :=\n  \u27e8fun f g => ofEq (f + -g) (fun x => f x - g x) fun i => by simp [sub_eq_add_neg]\u27e9\n\n@[simp, norm_cast]\ntheorem coe_sub (f g : CauSeq \u03b2 abv) : \u21d1(f - g) = (f : \u2115 \u2192 \u03b2) - g :=\n  rfl\n#align cau_seq.coe_sub CauSeq.coe_sub\n\n@[simp, norm_cast]\ntheorem sub_apply (f g : CauSeq \u03b2 abv) (i : \u2115) : (f - g) i = f i - g i :=\n  rfl\n#align cau_seq.sub_apply CauSeq.sub_apply\n\ntheorem const_sub (x y : \u03b2) : 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 \u03b2] [IsScalarTower G \u03b2 \u03b2]\n\ninstance : SMul G (CauSeq \u03b2 abv) :=\n  \u27e8fun a f => (ofEq (const (a \u2022 (1 : \u03b2)) * f) (a \u2022 (f : \u2115 \u2192 \u03b2))) fun _ => smul_one_mul _ _\u27e9\n\n@[simp, norm_cast]\ntheorem coe_smul (a : G) (f : CauSeq \u03b2 abv) : \u21d1(a \u2022 f) = a \u2022 (f : \u2115 \u2192 \u03b2) :=\n  rfl\n#align cau_seq.coe_smul CauSeq.coe_smul\n\n@[simp, norm_cast]\ntheorem smul_apply (a : G) (f : CauSeq \u03b2 abv) (i : \u2115) : (a \u2022 f) i = a \u2022 f i :=\n  rfl\n#align cau_seq.smul_apply CauSeq.smul_apply\n\ntheorem const_smul (a : G) (x : \u03b2) : const (a \u2022 x) = a \u2022 const x :=\n  rfl\n#align cau_seq.const_smul CauSeq.const_smul\n\ninstance : IsScalarTower G (CauSeq \u03b2 abv) (CauSeq \u03b2 abv) :=\n  \u27e8fun a f g => Subtype.ext <| smul_assoc a (f : \u2115 \u2192 \u03b2) (g : \u2115 \u2192 \u03b2)\u27e9\n\nend SMul\n\ninstance addGroup : AddGroup (CauSeq \u03b2 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 \u03b2 abv) := \u27e8fun n => const n\u27e9\n\ninstance instIntCast : IntCast (CauSeq \u03b2 abv) := \u27e8fun n => const n\u27e9\n\ninstance addGroupWithOne : AddGroupWithOne (CauSeq \u03b2 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 \u03b2 abv) \u2115 :=\n  \u27e8fun f n =>\n    (ofEq (npowRec n f) fun i => f i ^ n) <| by induction n <;> simp [*, npowRec, pow_succ]\u27e9\n\n@[simp, norm_cast]\ntheorem coe_pow (f : CauSeq \u03b2 abv) (n : \u2115) : \u21d1(f ^ n) = (f : \u2115 \u2192 \u03b2) ^ n :=\n  rfl\n#align cau_seq.coe_pow CauSeq.coe_pow\n\n@[simp, norm_cast]\ntheorem pow_apply (f : CauSeq \u03b2 abv) (n i : \u2115) : (f ^ n) i = f i ^ n :=\n  rfl\n#align cau_seq.pow_apply CauSeq.pow_apply\n\ntheorem const_pow (x : \u03b2) (n : \u2115) : const (x ^ n) = const x ^ n :=\n  rfl\n#align cau_seq.const_pow CauSeq.const_pow\n\ninstance ring : Ring (CauSeq \u03b2 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 {\u03b2 : Type _} [CommRing \u03b2] {abv : \u03b2 \u2192 \u03b1} [IsAbsoluteValue abv] : CommRing (CauSeq \u03b2 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 : \u03b2 \u2192 \u03b1} (f : CauSeq \u03b2 abv) : Prop :=\n  \u2200 \u03b5 > 0, \u2203 i, \u2200 j \u2265 i, abv (f j) < \u03b5\n#align cau_seq.lim_zero CauSeq.LimZero\n\ntheorem add_limZero {f g : CauSeq \u03b2 abv} (hf : LimZero f) (hg : LimZero g) : LimZero (f + g)\n  | \u03b5, \u03b50 =>\n    (exists_forall_ge_and (hf _ <| half_pos \u03b50) (hg _ <| half_pos \u03b50)).imp fun i H j ij => by\n      let \u27e8H\u2081, H\u2082\u27e9 := H _ ij\n      simpa [add_halves \u03b5] using lt_of_le_of_lt (abv_add abv _ _) (add_lt_add H\u2081 H\u2082)\n#align cau_seq.add_lim_zero CauSeq.add_limZero\n\ntheorem mul_limZero_right (f : CauSeq \u03b2 abv) {g} (hg : LimZero g) : LimZero (f * g)\n  | \u03b5, \u03b50 =>\n    let \u27e8F, F0, hF\u27e9 := f.bounded' 0\n    (hg _ <| div_pos \u03b50 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), \u2190 abv_mul] at this\n#align cau_seq.mul_lim_zero_right CauSeq.mul_limZero_right\n\ntheorem mul_limZero_left {f} (g : CauSeq \u03b2 abv) (hg : LimZero f) : LimZero (f * g)\n  | \u03b5, \u03b50 =>\n    let \u27e8G, G0, hG\u27e9 := g.bounded' 0\n    (hg _ <| div_pos \u03b50 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), \u2190 abv_mul] at this\n#align cau_seq.mul_lim_zero_left CauSeq.mul_limZero_left\n\ntheorem neg_limZero {f : CauSeq \u03b2 abv} (hf : LimZero f) : LimZero (-f) := by\n  rw [\u2190 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 \u03b2 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 \u03b2 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 \u03b2 abv)\n  | \u03b5, \u03b50 => \u27e80, fun j _ => by simpa [abv_zero abv] using \u03b50\u27e9\n#align cau_seq.zero_lim_zero CauSeq.zero_limZero\n\ntheorem const_limZero {x : \u03b2} : LimZero (const x) \u2194 x = 0 :=\n  \u27e8fun H =>\n    (abv_eq_zero abv).1 <|\n      (eq_of_le_of_forall_le_of_dense (abv_nonneg abv _)) fun _ \u03b50 =>\n        let \u27e8_, hi\u27e9 := H _ \u03b50\n        le_of_lt <| hi _ le_rfl,\n    fun e => e.symm \u25b8 zero_limZero\u27e9\n#align cau_seq.const_lim_zero CauSeq.const_limZero\n\ninstance equiv : Setoid (CauSeq \u03b2 abv) :=\n  \u27e8fun f g => LimZero (f - g),\n    \u27e8fun f => by simp [zero_limZero],\n    fun f \u03b5 h\u03b5 => by simpa using neg_limZero f \u03b5 h\u03b5,\n    fun fg gh => by simpa using add_limZero fg gh\u27e9\u27e9\n#align cau_seq.equiv CauSeq.equiv\n\ntheorem add_equiv_add {f1 f2 g1 g2 : CauSeq \u03b2 abv} (hf : f1 \u2248 f2) (hg : g1 \u2248 g2) :\n    f1 + g1 \u2248 f2 + g2 := by simpa only [\u2190 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 \u03b2 abv} (hf : f \u2248 g) : -f \u2248 -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 \u03b2 abv} (hf : f1 \u2248 f2) (hg : g1 \u2248 g2) :\n    f1 - g1 \u2248 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\u2083 {f g : CauSeq \u03b2 abv} (h : f \u2248 g) {\u03b5 : \u03b1} (\u03b50 : 0 < \u03b5) :\n    \u2203 i, \u2200 j \u2265 i, \u2200 k \u2265 j, abv (f k - g j) < \u03b5 :=\n  (exists_forall_ge_and (h _ <| half_pos \u03b50) (f.cauchy\u2083 <| half_pos \u03b50)).imp fun i H j ij k jk => by\n    let \u27e8h\u2081, h\u2082\u27e9 := H _ ij\n    have := lt_of_le_of_lt (abv_add abv (f j - g j) _) (add_lt_add h\u2081 (h\u2082 _ jk))\n    rwa [sub_add_sub_cancel', add_halves] at this\n#align cau_seq.equiv_def\u2083 CauSeq.equiv_def\u2083\n\ntheorem limZero_congr {f g : CauSeq \u03b2 abv} (h : f \u2248 g) : LimZero f \u2194 LimZero g :=\n  \u27e8fun l => by simpa using add_limZero (Setoid.symm h) l, fun l => by simpa using add_limZero h l\u27e9\n#align cau_seq.lim_zero_congr CauSeq.limZero_congr\n\ntheorem abv_pos_of_not_limZero {f : CauSeq \u03b2 abv} (hf : \u00acLimZero f) :\n    \u2203 K > 0, \u2203 i, \u2200 j \u2265 i, K \u2264 abv (f j) := by\n  haveI := Classical.propDecidable\n  by_contra nk\n  refine' hf fun \u03b5 \u03b50 => _\n  simp [not_forall] at nk\n  cases' f.cauchy\u2083 (half_pos \u03b50) with i hi\n  rcases nk _ (half_pos \u03b50) i with \u27e8j, ij, hj\u27e9\n  refine' \u27e8j, fun k jk => _\u27e9\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 : \u2115 \u2192 \u03b2) (g : CauSeq \u03b2 abv) (h : \u2200 \u03b5 > 0, \u2203 i, \u2200 j \u2265 i, abv (f j - g j) < \u03b5) :\n    IsCauSeq abv f\n  | \u03b5, \u03b50 =>\n    let \u27e8i, hi\u27e9 := exists_forall_ge_and (h _ (half_pos <| half_pos \u03b50)) (g.cauchy\u2083 <| half_pos \u03b50)\n    \u27e8i, fun j ij => by\n      cases' hi _ le_rfl with h\u2081 h\u2082; rw [abv_sub abv] at h\u2081\n      have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add (hi _ ij).1 h\u2081)\n      have := lt_of_le_of_lt (abv_add abv _ _) (add_lt_add this (h\u2082 _ ij))\n      rwa [add_halves, add_halves, add_right_comm, sub_add_sub_cancel, sub_add_sub_cancel] at this\u27e9\n#align cau_seq.of_near CauSeq.of_near\n\ntheorem not_limZero_of_not_congr_zero {f : CauSeq _ abv} (hf : \u00acf \u2248 0) : \u00acLimZero 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 \u2248 0) : g * f \u2248 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 \u2248 0) : f * g \u2248 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 : \u00acf \u2248 0) (hg : \u00acg \u2248 0) : \u00acf * g \u2248 0 :=\n  fun (this : LimZero (f * g - 0)) => by\n  have hlz : LimZero (f * g) := by simpa\n  have hf' : \u00acLimZero f := by simpa using show \u00acLimZero (f - 0) from hf\n  have hg' : \u00acLimZero g := by simpa using show \u00acLimZero (g - 0) from hg\n  rcases abv_pos_of_not_limZero hf' with \u27e8a1, ha1, N1, hN1\u27e9\n  rcases abv_pos_of_not_limZero hg' with \u27e8a2, ha2, N2, hN2\u27e9\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 _ \u2264 abv (_ * _)\n  rw [abv_mul abv]\n  apply mul_le_mul <;> try assumption\n  \u00b7 exact le_of_lt ha2\n  \u00b7 exact abv_nonneg abv _\n#align cau_seq.mul_not_equiv_zero CauSeq.mul_not_equiv_zero\n\ntheorem const_equiv {x y : \u03b2} : const x \u2248 const y \u2194 x = y :=\n  show LimZero _ \u2194 _ by rw [\u2190 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 \u03b2 abv} (hf : f1 \u2248 f2) (hg : g1 \u2248 g2) :\n    f1 * g1 \u2248 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 \u03b2] [IsScalarTower G \u03b2 \u03b2] {f1 f2 : CauSeq \u03b2 abv} (c : G)\n    (hf : f1 \u2248 f2) : c \u2022 f1 \u2248 c \u2022 f2 := by\n  simpa [const_smul, smul_one_mul _ _] using\n    mul_equiv_mul (const_equiv.mpr <| Eq.refl <| c \u2022 (1 : \u03b2)) hf\n#align cau_seq.smul_equiv_smul CauSeq.smul_equiv_smul\n\ntheorem pow_equiv_pow {f1 f2 : CauSeq \u03b2 abv} (hf : f1 \u2248 f2) (n : \u2115) : f1 ^ n \u2248 f2 ^ n := by\n  induction' n with n ih\n  \u00b7 simp only [Nat.zero_eq, pow_zero, Setoid.refl]\n  \u00b7 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 \u03b2] [IsDomain \u03b2] (abv : \u03b2 \u2192 \u03b1) [IsAbsoluteValue abv]\n\ntheorem one_not_equiv_zero : \u00acconst abv 1 \u2248 const abv 0 := fun h =>\n  have : \u2200 \u03b5 > 0, \u2203 i, \u2200 k, i \u2264 k \u2192 abv (1 - 0) < \u03b5 := h\n  have h1 : abv 1 \u2264 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 \u2264 abv 1 := abv_nonneg abv _\n  have : abv 1 = 0 := le_antisymm h1 h2\n  have : (1 : \u03b2) = 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 \u03b2] {abv : \u03b2 \u2192 \u03b1} [IsAbsoluteValue abv]\n\ntheorem inv_aux {f : CauSeq \u03b2 abv} (hf : \u00acLimZero f) :\n    \u2200 \u03b5 > 0, \u2203 i, \u2200 j \u2265 i, abv ((f j)\u207b\u00b9 - (f i)\u207b\u00b9) < \u03b5\n  | _, \u03b50 =>\n    let \u27e8_, K0, HK\u27e9 := abv_pos_of_not_limZero hf\n    let \u27e8_, \u03b40, H\u03b4\u27e9 := rat_inv_continuous_lemma abv \u03b50 K0\n    let \u27e8i, H\u27e9 := exists_forall_ge_and HK (f.cauchy\u2083 \u03b40)\n    \u27e8i, fun _ ij =>\n      let \u27e8iK, H'\u27e9 := H _ le_rfl\n      H\u03b4 (H _ ij).1 iK (H' _ ij)\u27e9\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 \u03b2 abv) (hf : \u00acLimZero f) : CauSeq \u03b2 abv :=\n  \u27e8_, inv_aux hf\u27e9\n#align cau_seq.inv CauSeq.inv\n\n@[simp, norm_cast]\ntheorem coe_inv {f : CauSeq \u03b2 abv} (hf) : \u21d1(inv f hf) = (f : \u2115 \u2192 \u03b2)\u207b\u00b9 :=\n  rfl\n#align cau_seq.coe_inv CauSeq.coe_inv\n\n@[simp, norm_cast]\ntheorem inv_apply {f : CauSeq \u03b2 abv} (hf i) : inv f hf i = (f i)\u207b\u00b9 :=\n  rfl\n#align cau_seq.inv_apply CauSeq.inv_apply\n\ntheorem inv_mul_cancel {f : CauSeq \u03b2 abv} (hf) : inv f hf * f \u2248 1 := fun \u03b5 \u03b50 =>\n  let \u27e8K, K0, i, H\u27e9 := abv_pos_of_not_limZero hf\n  \u27e8i, fun j ij => by simpa [(abv_pos abv).1 (lt_of_lt_of_le K0 (H _ ij)), abv_zero abv] using \u03b50\u27e9\n#align cau_seq.inv_mul_cancel CauSeq.inv_mul_cancel\n\ntheorem mul_inv_cancel {f : CauSeq \u03b2 abv} (hf) : f * inv f hf \u2248 1 := fun \u03b5 \u03b50 =>\n  let \u27e8K, K0, i, H\u27e9 := abv_pos_of_not_limZero hf\n  \u27e8i, fun j ij => by simpa [(abv_pos abv).1 (lt_of_lt_of_le K0 (H _ ij)), abv_zero abv] using \u03b50\u27e9\n#align cau_seq.mul_inv_cancel CauSeq.mul_inv_cancel\n\ntheorem const_inv {x : \u03b2} (hx : x \u2260 0) :\n    const abv x\u207b\u00b9 = 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 \u03b1 abs) : Prop :=\n  \u2203 K > 0, \u2203 i, \u2200 j \u2265 i, K \u2264 f j\n#align cau_seq.pos CauSeq.Pos\n\ntheorem not_limZero_of_pos {f : CauSeq \u03b1 abs} : Pos f \u2192 \u00acLimZero f\n  | \u27e8_, F0, hF\u27e9, H =>\n    let \u27e8_, h\u27e9 := exists_forall_ge_and hF (H _ F0)\n    let \u27e8h\u2081, h\u2082\u27e9 := h _ le_rfl\n    not_lt_of_le h\u2081 (abs_lt.1 h\u2082).2\n#align cau_seq.not_lim_zero_of_pos CauSeq.not_limZero_of_pos\n\ntheorem const_pos {x : \u03b1} : Pos (const x) \u2194 0 < x :=\n  \u27e8fun \u27e8_, K0, _, h\u27e9 => lt_of_lt_of_le K0 (h _ le_rfl), fun h => \u27e8x, h, 0, fun _ _ => le_rfl\u27e9\u27e9\n#align cau_seq.const_pos CauSeq.const_pos\n\ntheorem add_pos {f g : CauSeq \u03b1 abs} : Pos f \u2192 Pos g \u2192 Pos (f + g)\n  | \u27e8_, F0, hF\u27e9, \u27e8_, G0, hG\u27e9 =>\n    let \u27e8i, h\u27e9 := exists_forall_ge_and hF hG\n    \u27e8_, _root_.add_pos F0 G0, i, fun _ ij =>\n      let \u27e8h\u2081, h\u2082\u27e9 := h _ ij\n      add_le_add h\u2081 h\u2082\u27e9\n#align cau_seq.add_pos CauSeq.add_pos\n\ntheorem pos_add_limZero {f g : CauSeq \u03b1 abs} : Pos f \u2192 LimZero g \u2192 Pos (f + g)\n  | \u27e8F, F0, hF\u27e9, H =>\n    let \u27e8i, h\u27e9 := exists_forall_ge_and hF (H _ (half_pos F0))\n    \u27e8_, half_pos F0, i, fun j ij => by\n      cases' h j ij with h\u2081 h\u2082\n      have := add_le_add h\u2081 (le_of_lt (abs_lt.1 h\u2082).1)\n      rwa [\u2190 sub_eq_add_neg, sub_self_div_two] at this\u27e9\n#align cau_seq.pos_add_lim_zero CauSeq.pos_add_limZero\n\nprotected theorem mul_pos {f g : CauSeq \u03b1 abs} : Pos f \u2192 Pos g \u2192 Pos (f * g)\n  | \u27e8_, F0, hF\u27e9, \u27e8_, G0, hG\u27e9 =>\n    let \u27e8i, h\u27e9 := exists_forall_ge_and hF hG\n    \u27e8_, mul_pos F0 G0, i, fun _ ij =>\n      let \u27e8h\u2081, h\u2082\u27e9 := h _ ij\n      mul_le_mul h\u2081 h\u2082 (le_of_lt G0) (le_trans (le_of_lt F0) h\u2081)\u27e9\n#align cau_seq.mul_pos CauSeq.mul_pos\n\ntheorem trichotomy (f : CauSeq \u03b1 abs) : Pos f \u2228 LimZero f \u2228 Pos (-f) := by\n  cases' Classical.em (LimZero f) with h h <;> simp [*]\n  rcases abv_pos_of_not_limZero h with \u27e8K, K0, hK\u27e9\n  rcases exists_forall_ge_and hK (f.cauchy\u2083 K0) with \u27e8i, hi\u27e9\n  refine' (le_total 0 (f i)).imp _ _ <;>\n    refine' fun h => \u27e8K, K0, i, fun j ij => _\u27e9 <;>\n    have := (hi _ ij).1 <;>\n    cases' hi _ le_rfl with h\u2081 h\u2082\n  \u00b7 rwa [abs_of_nonneg] at this\n    rw [abs_of_nonneg h] at h\u2081\n    exact\n      (le_add_iff_nonneg_right _).1\n        (le_trans h\u2081 <| neg_le_sub_iff_le_add'.1 <| le_of_lt (abs_lt.1 <| h\u2082 _ ij).1)\n  \u00b7 rwa [abs_of_nonpos] at this\n    rw [abs_of_nonpos h] at h\u2081\n    rw [\u2190 sub_le_sub_iff_right, zero_sub]\n    exact le_trans (le_of_lt (abs_lt.1 <| h\u2082 _ ij).2) h\u2081\n#align cau_seq.trichotomy CauSeq.trichotomy\n\ninstance : LT (CauSeq \u03b1 abs) :=\n  \u27e8fun f g => Pos (g - f)\u27e9\n\ninstance : LE (CauSeq \u03b1 abs) :=\n  \u27e8fun f g => f < g \u2228 f \u2248 g\u27e9\n\ntheorem lt_of_lt_of_eq {f g h : CauSeq \u03b1 abs} (fg : f < g) (gh : g \u2248 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 \u03b1 abs} (fg : f \u2248 g) (gh : g < h) : f < h := by\n  have := pos_add_limZero gh (neg_limZero fg)\n  rwa [\u2190 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 \u03b1 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 \u03b1 abs} : \u00acf < 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 \u03b1 abs} (hfg : f \u2248 g) (hgh : g \u2264 h) : f \u2264 h :=\n  hgh.elim (Or.inl \u2218 CauSeq.lt_of_eq_of_lt hfg) (Or.inr \u2218 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 \u03b1 abs} (hfg : f \u2264 g) (hgh : g \u2248 h) : f \u2264 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 \u03b1 abs) where\n  lt := (\u00b7 < \u00b7)\n  le f g := f < g \u2228 f \u2248 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    \u27e8fun h => \u27e8Or.inl h, not_or_of_not (mt (lt_trans h) lt_irrefl) (not_limZero_of_pos h)\u27e9,\n      fun \u27e8h\u2081, h\u2082\u27e9 => h\u2081.resolve_right (mt (fun h => Or.inr (Setoid.symm h)) h\u2082)\u27e9\n\ntheorem le_antisymm {f g : CauSeq \u03b1 abs} (fg : f \u2264 g) (gf : g \u2264 f) : f \u2248 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 \u03b1 abs) : f < g \u2228 f \u2248 g \u2228 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 \u03b1 abs) : f \u2264 g \u2228 g \u2264 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 : \u03b1} : const x < const y \u2194 x < y :=\n  show Pos _ \u2194 _ by rw [\u2190 const_sub, const_pos, sub_pos]\n#align cau_seq.const_lt CauSeq.const_lt\n\ntheorem const_le {x y : \u03b1} : const x \u2264 const y \u2194 x \u2264 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 \u03b1 abs} (h : \u2203 i, \u2200 j \u2265 i, f j \u2264 g j) : f \u2264 g :=\n  let \u27e8i, hi\u27e9 := h\n  (or_assoc.2 (CauSeq.lt_total f g)).elim id fun hgf =>\n    False.elim\n      (let \u27e8_, hK0, j, hKj\u27e9 := 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 \u03b1 abs) : \u2203 a : \u03b1, f < const a :=\n  let \u27e8K, H\u27e9 := f.bounded\n  \u27e8K + 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\u27e9\n#align cau_seq.exists_gt CauSeq.exists_gt\n\ntheorem exists_lt (f : CauSeq \u03b1 abs) : \u2203 a : \u03b1, const a < f :=\n  let \u27e8a, h\u27e9 := (-f).exists_gt\n  \u27e8-a, show Pos _ by rwa [const_neg, sub_neg_eq_add, add_comm, \u2190 sub_neg_eq_add]\u27e9\n#align cau_seq.exists_lt CauSeq.exists_lt\n\n-- so named to match `rat_add_continuous_lemma`\ntheorem rat_sup_continuous_lemma {\u03b5 : \u03b1} {a\u2081 a\u2082 b\u2081 b\u2082 : \u03b1} :\n    abs (a\u2081 - b\u2081) < \u03b5 \u2192 abs (a\u2082 - b\u2082) < \u03b5 \u2192 abs (a\u2081 \u2294 a\u2082 - b\u2081 \u2294 b\u2082) < \u03b5 := fun h\u2081 h\u2082 =>\n  (abs_max_sub_max_le_max _ _ _ _).trans_lt (max_lt h\u2081 h\u2082)\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 {\u03b5 : \u03b1} {a\u2081 a\u2082 b\u2081 b\u2082 : \u03b1} :\n    abs (a\u2081 - b\u2081) < \u03b5 \u2192 abs (a\u2082 - b\u2082) < \u03b5 \u2192 abs (a\u2081 \u2293 a\u2082 - b\u2081 \u2293 b\u2082) < \u03b5 := fun h\u2081 h\u2082 =>\n  (abs_min_sub_min_le_max _ _ _ _).trans_lt (max_lt h\u2081 h\u2082)\n#align rat_inf_continuous_lemma CauSeq.rat_inf_continuous_lemma\n\ninstance : Sup (CauSeq \u03b1 abs) :=\n  \u27e8fun f g =>\n    \u27e8f \u2294 g, fun _ \u03b50 =>\n      (exists_forall_ge_and (f.cauchy\u2083 \u03b50) (g.cauchy\u2083 \u03b50)).imp fun _ H _ ij =>\n        let \u27e8H\u2081, H\u2082\u27e9 := H _ le_rfl\n        rat_sup_continuous_lemma (H\u2081 _ ij) (H\u2082 _ ij)\u27e9\u27e9\n\ninstance : Inf (CauSeq \u03b1 abs) :=\n  \u27e8fun f g =>\n    \u27e8f \u2293 g, fun _ \u03b50 =>\n      (exists_forall_ge_and (f.cauchy\u2083 \u03b50) (g.cauchy\u2083 \u03b50)).imp fun _ H _ ij =>\n        let \u27e8H\u2081, H\u2082\u27e9 := H _ le_rfl\n        rat_inf_continuous_lemma (H\u2081 _ ij) (H\u2082 _ ij)\u27e9\u27e9\n\n@[simp, norm_cast]\ntheorem coe_sup (f g : CauSeq \u03b1 abs) : \u21d1(f \u2294 g) = (f : \u2115 \u2192 \u03b1) \u2294 g :=\n  rfl\n#align cau_seq.coe_sup CauSeq.coe_sup\n\n@[simp, norm_cast]\ntheorem coe_inf (f g : CauSeq \u03b1 abs) : \u21d1(f \u2293 g) = (f : \u2115 \u2192 \u03b1) \u2293 g :=\n  rfl\n#align cau_seq.coe_inf CauSeq.coe_inf\n\ntheorem sup_limZero {f g : CauSeq \u03b1 abs} (hf : LimZero f) (hg : LimZero g) : LimZero (f \u2294 g)\n  | \u03b5, \u03b50 =>\n    (exists_forall_ge_and (hf _ \u03b50) (hg _ \u03b50)).imp fun i H j ij => by\n      let \u27e8H\u2081, H\u2082\u27e9 := H _ ij\n      rw [abs_lt] at H\u2081 H\u2082\u22a2\n      exact \u27e8lt_sup_iff.mpr (Or.inl H\u2081.1), sup_lt_iff.mpr \u27e8H\u2081.2, H\u2082.2\u27e9\u27e9\n#align cau_seq.sup_lim_zero CauSeq.sup_limZero\n\ntheorem inf_limZero {f g : CauSeq \u03b1 abs} (hf : LimZero f) (hg : LimZero g) : LimZero (f \u2293 g)\n  | \u03b5, \u03b50 =>\n    (exists_forall_ge_and (hf _ \u03b50) (hg _ \u03b50)).imp fun i H j ij => by\n      let \u27e8H\u2081, H\u2082\u27e9 := H _ ij\n      rw [abs_lt] at H\u2081 H\u2082\u22a2\n      exact \u27e8lt_inf_iff.mpr \u27e8H\u2081.1, H\u2082.1\u27e9, inf_lt_iff.mpr (Or.inl H\u2081.2)\u27e9\n#align cau_seq.inf_lim_zero CauSeq.inf_limZero\n\ntheorem sup_equiv_sup {a\u2081 b\u2081 a\u2082 b\u2082 : CauSeq \u03b1 abs} (ha : a\u2081 \u2248 a\u2082) (hb : b\u2081 \u2248 b\u2082) :\n    a\u2081 \u2294 b\u2081 \u2248 a\u2082 \u2294 b\u2082 := by\n  intro \u03b5 \u03b50\n  obtain \u27e8ai, hai\u27e9 := ha \u03b5 \u03b50\n  obtain \u27e8bi, hbi\u27e9 := hb \u03b5 \u03b50\n  exact\n    \u27e8ai \u2294 bi, fun i hi =>\n      (abs_max_sub_max_le_max (a\u2081 i) (b\u2081 i) (a\u2082 i) (b\u2082 i)).trans_lt\n        (max_lt (hai i (sup_le_iff.mp hi).1) (hbi i (sup_le_iff.mp hi).2))\u27e9\n#align cau_seq.sup_equiv_sup CauSeq.sup_equiv_sup\n\n\n\nprotected theorem sup_lt {a b c : CauSeq \u03b1 abs} (ha : a < c) (hb : b < c) : a \u2294 b < c := by\n  obtain \u27e8\u27e8\u03b5a, \u03b5a0, ia, ha\u27e9, \u27e8\u03b5b, \u03b5b0, ib, hb\u27e9\u27e9 := ha, hb\n  refine' \u27e8\u03b5a \u2293 \u03b5b, lt_inf_iff.mpr \u27e8\u03b5a0, \u03b5b0\u27e9, ia \u2294 ib, fun i hi => _\u27e9\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 \u03b1 abs} (hb : a < b) (hc : a < c) : a < b \u2293 c := by\n  obtain \u27e8\u27e8\u03b5b, \u03b5b0, ib, hb\u27e9, \u27e8\u03b5c, \u03b5c0, ic, hc\u27e9\u27e9 := hb, hc\n  refine' \u27e8\u03b5b \u2293 \u03b5c, lt_inf_iff.mpr \u27e8\u03b5b0, \u03b5c0\u27e9, ib \u2294 ic, fun i hi => _\u27e9\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 \u03b1 abs) : a \u2294 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 \u03b1 abs) : a \u2293 a = a :=\n  Subtype.ext inf_idem\n#align cau_seq.inf_idem CauSeq.inf_idem\n\nprotected theorem sup_comm (a b : CauSeq \u03b1 abs) : a \u2294 b = b \u2294 a :=\n  Subtype.ext sup_comm\n#align cau_seq.sup_comm CauSeq.sup_comm\n\nprotected theorem inf_comm (a b : CauSeq \u03b1 abs) : a \u2293 b = b \u2293 a :=\n  Subtype.ext inf_comm\n#align cau_seq.inf_comm CauSeq.inf_comm\n\nprotected theorem sup_eq_right {a b : CauSeq \u03b1 abs} (h : a \u2264 b) : a \u2294 b \u2248 b := by\n  obtain \u27e8\u03b5, \u03b50 : _ < _, i, h\u27e9 | h := h\n  \u00b7 intro _ _\n    refine' \u27e8i, fun j hj => _\u27e9\n    dsimp\n    erw [\u2190 max_sub_sub_right]\n    rwa [sub_self, max_eq_right, abs_zero]\n    rw [sub_nonpos, \u2190 sub_nonneg]\n    exact \u03b50.le.trans (h _ hj)\n  \u00b7 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 \u03b1 abs} (h : b \u2264 a) : a \u2293 b \u2248 b := by\n  obtain \u27e8\u03b5, \u03b50 : _ < _, i, h\u27e9 | h := h\n  \u00b7 intro _ _\n    refine' \u27e8i, fun j hj => _\u27e9\n    dsimp\n    erw [\u2190 min_sub_sub_right]\n    rwa [sub_self, min_eq_right, abs_zero]\n    exact \u03b50.le.trans (h _ hj)\n  \u00b7 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 \u03b1 abs} (h : b \u2264 a) : a \u2294 b \u2248 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 \u03b1 abs} (h : a \u2264 b) : a \u2293 b \u2248 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 \u03b1 abs} : a \u2264 a \u2294 b :=\n  le_of_exists \u27e80, fun _ _ => le_sup_left\u27e9\n#align cau_seq.le_sup_left CauSeq.le_sup_left\n\nprotected theorem inf_le_left {a b : CauSeq \u03b1 abs} : a \u2293 b \u2264 a :=\n  le_of_exists \u27e80, fun _ _ => inf_le_left\u27e9\n#align cau_seq.inf_le_left CauSeq.inf_le_left\n\nprotected theorem le_sup_right {a b : CauSeq \u03b1 abs} : b \u2264 a \u2294 b :=\n  le_of_exists \u27e80, fun _ _ => le_sup_right\u27e9\n#align cau_seq.le_sup_right CauSeq.le_sup_right\n\nprotected theorem inf_le_right {a b : CauSeq \u03b1 abs} : a \u2293 b \u2264 b :=\n  le_of_exists \u27e80, fun _ _ => inf_le_right\u27e9\n#align cau_seq.inf_le_right CauSeq.inf_le_right\n\nprotected theorem sup_le {a b c : CauSeq \u03b1 abs} (ha : a \u2264 c) (hb : b \u2264 c) : a \u2294 b \u2264 c := by\n  cases' ha with ha ha\n  \u00b7 cases' hb with hb hb\n    \u00b7 exact Or.inl (CauSeq.sup_lt ha hb)\n    \u00b7 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  \u00b7 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 \u03b1 abs} (hb : a \u2264 b) (hc : a \u2264 c) : a \u2264 b \u2293 c := by\n  cases' hb with hb hb\n  \u00b7 cases' hc with hc hc\n    \u00b7 exact Or.inl (CauSeq.lt_inf hb hc)\n    \u00b7 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  \u00b7 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 \u03b1 abs)` is not true because there is no `PartialOrder`. -/\n\n\nprotected theorem sup_inf_distrib_left (a b c : CauSeq \u03b1 abs) : a \u2294 b \u2293 c = (a \u2294 b) \u2293 (a \u2294 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 \u03b1 abs) : a \u2293 b \u2294 c = (a \u2294 c) \u2293 (b \u2294 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": "\ndef foo1(bar : Nat) : Bool := true\n                     --^ textDocument/documentHighlight\n\n#eval foo1 2\n#eval foo1 3\n     --^ textDocument/documentHighlight\n\ndef foo2 : Nat :=\n  let bar := 2\n  bar + 3\n --^ textDocument/documentHighlight\n\nstructure Baz where\n  bar : Nat\n  bar' : Nat\n --^ textDocument/documentHighlight\n\ndef foo3 (baz : Baz) : Nat :=\n  baz.bar\n     --^ textDocument/documentHighlight\n\ndef foo4 (bar : Nat) : Baz :=\n  { bar := bar, bar' := bar }\n   --^ textDocument/documentHighlight\n          --^ textDocument/documentHighlight\n\nexample : Nat := Id.run do\n  let mut x := 1\n  x := 2\n  x\n--^ textDocument/documentHighlight\n\nexample : Nat := Id.run do\n  let mut y : Nat := 0\n  for x in [0] do\n    y := y + x\n  if true then\n    y := y + 1\n  else\n    return y\n  pure y\n     --^ textDocument/documentHighlight\n\nexample : Nat := Id.run do\n  let mut y := 0\n  if true then\n    y := 1\n  return y  -- TODO: definition should be first `y`\n       --^ textDocument/documentHighlight\n\nexample (x : Option Nat) : Nat :=\n  match x with\n  | some x => 1\n       --^ textDocument/documentHighlight\n  | none   => 0\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/highlight.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6477982179521103, "lm_q2_score": 0.7248702642896702, "lm_q1q2_score": 0.46956966545332357}}
{"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  ((\u03b1_ (\ud835\udfd9_ C) X Y).hom) \u226b ((\u03bb_ (X \u2297 Y)).hom) = ((\u03bb_ X).hom \u2297 (\ud835\udfd9 Y)) :=\nby coherence\n\n@[reassoc, simp]\nlemma left_unitor_tensor (X Y : C) :\n  ((\u03bb_ (X \u2297 Y)).hom) = ((\u03b1_ (\ud835\udfd9_ C) X Y).inv) \u226b ((\u03bb_ X).hom \u2297 (\ud835\udfd9 Y)) :=\nby coherence\n\n@[reassoc]\nlemma left_unitor_tensor_inv (X Y : C) :\n  (\u03bb_ (X \u2297 Y)).inv = ((\u03bb_ X).inv \u2297 (\ud835\udfd9 Y)) \u226b (\u03b1_ (\ud835\udfd9_ C) X Y).hom :=\nby coherence\n\n@[reassoc]\nlemma id_tensor_right_unitor_inv (X Y : C) : \ud835\udfd9 X \u2297 (\u03c1_ Y).inv = (\u03c1_ _).inv \u226b (\u03b1_ _ _ _).hom :=\nby coherence\n\n@[reassoc]\nlemma left_unitor_inv_tensor_id (X Y : C) : (\u03bb_ X).inv \u2297 \ud835\udfd9 Y = (\u03bb_ _).inv \u226b (\u03b1_ _ _ _).inv :=\nby coherence\n\n@[reassoc]\nlemma pentagon_inv_inv_hom (W X Y Z : C) :\n  (\u03b1_ W (X \u2297 Y) Z).inv \u226b ((\u03b1_ W X Y).inv \u2297 (\ud835\udfd9 Z)) \u226b (\u03b1_ (W \u2297 X) Y Z).hom\n  = ((\ud835\udfd9 W) \u2297 (\u03b1_ X Y Z).hom) \u226b (\u03b1_ W X (Y \u2297 Z)).inv :=\nby coherence\n\n@[simp, reassoc] lemma triangle_assoc_comp_right_inv (X Y : C) :\n  ((\u03c1_ X).inv \u2297 \ud835\udfd9 Y) \u226b (\u03b1_ X (\ud835\udfd9_ C) Y).hom = ((\ud835\udfd9 X) \u2297 (\u03bb_ Y).inv) :=\nby coherence\n\nlemma unitors_equal : (\u03bb_ (\ud835\udfd9_ C)).hom = (\u03c1_ (\ud835\udfd9_ C)).hom :=\nby coherence\n\nlemma unitors_inv_equal : (\u03bb_ (\ud835\udfd9_ C)).inv = (\u03c1_ (\ud835\udfd9_ C)).inv :=\nby coherence\n\n@[reassoc]\nlemma pentagon_hom_inv {W X Y Z : C} :\n  (\u03b1_ W X (Y \u2297 Z)).hom \u226b (\ud835\udfd9 W \u2297 (\u03b1_ X Y Z).inv)\n  = (\u03b1_ (W \u2297 X) Y Z).inv \u226b ((\u03b1_ W X Y).hom \u2297 \ud835\udfd9 Z) \u226b (\u03b1_ W (X \u2297 Y) Z).hom :=\nby coherence\n\n@[reassoc]\nlemma pentagon_inv_hom (W X Y Z : C) :\n  (\u03b1_ (W \u2297 X) Y Z).inv \u226b ((\u03b1_ W X Y).hom \u2297 \ud835\udfd9 Z)\n  = (\u03b1_ W X (Y \u2297 Z)).hom \u226b (\ud835\udfd9 W \u2297 (\u03b1_ X Y Z).inv) \u226b (\u03b1_ W (X \u2297 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\u00ebl 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 `\u2264`\" means \"monotonicity of addition\"\n* \"`+` respects `<`\" means \"strict monotonicity of addition\"\n* \"`*` respects `\u2264`\" 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 `\u2264`.\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  `\u2264`.\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 `\u2264` and `*` respects `<`.\n* `ordered_comm_ring`: Commutative ring with a partial order such that `+` respects `\u2264` and\n  `*` respects `<`.\n* `linear_ordered_semiring`: Nontrivial semiring with a linear order such that `+` respects `\u2264` and\n  `*` respects `<`.\n* `linear_ordered_comm_semiring`: Nontrivial commutative semiring with a linear order such that `+`\n  respects `\u2264` and `*` respects `<`.\n* `linear_ordered_ring`: Nontrivial ring with a linear order such that `+` respects `\u2264` and `*`\n  respects `<`.\n* `linear_ordered_comm_ring`: Nontrivial commutative ring with a linear order such that `+` respects\n  `\u2264` and `*` respects `<`.\n* `canonically_ordered_comm_semiring`: Commutative semiring with a partial order such that `+`\n  respects `\u2264`, `*` respects `<`, and `a \u2264 b \u2194 \u2203 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 `\u2264`\n  - `semiring` & partial order structure & `+` respects `\u2264` & `*` respects `\u2264`\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 `\u2264` & `*` 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 `\u2264` & `*` 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 `\u2264` & `*` 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 {\u03b1 : Type u} {\u03b2 : 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 \u03b1] [semiring \u03b1] [covariant_class \u03b1 \u03b1 (+) (\u2264)]\n  {a : \u03b1} (a1 : 1 \u2264 a) :\n  a + 1 \u2264 2 * a :=\ncalc  a + 1 \u2264 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 (\u03b1 : Type u) extends semiring \u03b1, ordered_add_comm_monoid \u03b1 :=\n(zero_le_one : (0 : \u03b1) \u2264 1)\n(mul_le_mul_of_nonneg_left  : \u2200 a b c : \u03b1, a \u2264 b \u2192 0 \u2264 c \u2192 c * a \u2264 c * b)\n(mul_le_mul_of_nonneg_right : \u2200 a b c : \u03b1, a \u2264 b \u2192 0 \u2264 c \u2192 a * c \u2264 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 (\u03b1 : Type u) extends ordered_semiring \u03b1, comm_semiring \u03b1\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 (\u03b1 : Type u) extends ring \u03b1, ordered_add_comm_group \u03b1 :=\n(zero_le_one : 0 \u2264 (1 : \u03b1))\n(mul_nonneg : \u2200 a b : \u03b1, 0 \u2264 a \u2192 0 \u2264 b \u2192 0 \u2264 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 (\u03b1 : Type u) extends ordered_ring \u03b1, comm_ring \u03b1\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 (\u03b1 : Type u)\n  extends semiring \u03b1, ordered_cancel_add_comm_monoid \u03b1, nontrivial \u03b1 :=\n(zero_le_one : (0 : \u03b1) \u2264 1)\n(mul_lt_mul_of_pos_left  : \u2200 a b c : \u03b1, a < b \u2192 0 < c \u2192 c * a < c * b)\n(mul_lt_mul_of_pos_right : \u2200 a b c : \u03b1, a < b \u2192 0 < c \u2192 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 (\u03b1 : Type u) extends strict_ordered_semiring \u03b1, comm_semiring \u03b1\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 (\u03b1 : Type u) extends ring \u03b1, ordered_add_comm_group \u03b1, nontrivial \u03b1 :=\n(zero_le_one : 0 \u2264 (1 : \u03b1))\n(mul_pos     : \u2200 a b : \u03b1, 0 < a \u2192 0 < b \u2192 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 (\u03b1 : Type*) extends strict_ordered_ring \u03b1, comm_ring \u03b1\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 (\u03b1 : Type u)\n  extends strict_ordered_semiring \u03b1, linear_ordered_add_comm_monoid \u03b1\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 (\u03b1 : Type*)\n  extends strict_ordered_comm_semiring \u03b1, linear_ordered_semiring \u03b1\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 (\u03b1 : Type u) extends strict_ordered_ring \u03b1, linear_order \u03b1\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 (\u03b1 : Type u) extends linear_ordered_ring \u03b1, comm_monoid \u03b1\n\n\nsection ordered_semiring\nvariables [ordered_semiring \u03b1] {a b c d : \u03b1}\n\n@[priority 100] -- see Note [lower instance priority]\ninstance ordered_semiring.zero_le_one_class : zero_le_one_class \u03b1 :=\n{ ..\u2039ordered_semiring \u03b1\u203a }\n\n@[priority 200] -- see Note [lower instance priority]\ninstance ordered_semiring.to_pos_mul_mono : pos_mul_mono \u03b1 :=\n\u27e8\u03bb x a b h, ordered_semiring.mul_le_mul_of_nonneg_left _ _ _ h x.2\u27e9\n\n@[priority 200] -- see Note [lower instance priority]\ninstance ordered_semiring.to_mul_pos_mono : mul_pos_mono \u03b1 :=\n\u27e8\u03bb x a b h, ordered_semiring.mul_le_mul_of_nonneg_right _ _ _ h x.2\u27e9\n\nlemma bit1_mono : monotone (bit1 : \u03b1 \u2192 \u03b1) := \u03bb a b h, add_le_add_right (bit0_mono h) _\n\n@[simp] lemma pow_nonneg (H : 0 \u2264 a) : \u2200 (n : \u2115), 0 \u2264 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 \u2264 a) (b0 : 0 \u2264 b) : a + (2 + b) \u2264 a * (2 + b) :=\ncalc a + (2 + b) \u2264 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             ... \u2264 a * (2 + b) : by rw [mul_add, mul_two, add_assoc]\n\nlemma one_le_mul_of_one_le_of_one_le (ha : 1 \u2264 a) (hb : 1 \u2264 b) : (1 : \u03b1) \u2264 a * b :=\nleft.one_le_mul_of_le_of_le ha hb $ zero_le_one.trans ha\n\nsection monotone\nvariables [preorder \u03b2] {f g : \u03b2 \u2192 \u03b1}\n\nlemma monotone_mul_left_of_nonneg (ha : 0 \u2264 a) : monotone (\u03bb x, a * x) :=\n\u03bb b c h, mul_le_mul_of_nonneg_left h ha\n\nlemma monotone_mul_right_of_nonneg (ha : 0 \u2264 a) : monotone (\u03bb x, x * a) :=\n\u03bb b c h, mul_le_mul_of_nonneg_right h ha\n\nlemma monotone.mul_const (hf : monotone f) (ha : 0 \u2264 a) : monotone (\u03bb x, f x * a) :=\n(monotone_mul_right_of_nonneg ha).comp hf\n\nlemma monotone.const_mul (hf : monotone f) (ha : 0 \u2264 a) : monotone (\u03bb x, a * f x) :=\n(monotone_mul_left_of_nonneg ha).comp hf\n\nlemma antitone.mul_const (hf : antitone f) (ha : 0 \u2264 a) : antitone (\u03bb x, f x * a) :=\n(monotone_mul_right_of_nonneg ha).comp_antitone hf\n\nlemma antitone.const_mul (hf : antitone f) (ha : 0 \u2264 a) : antitone (\u03bb 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\u2080 : \u2200 x, 0 \u2264 f x) (hg\u2080 : \u2200 x, 0 \u2264 g x) :\n  monotone (f * g) :=\n\u03bb b c h, mul_le_mul (hf h) (hg h) (hg\u2080 _) (hf\u2080 _)\n\nend monotone\n\nlemma bit1_pos [nontrivial \u03b1] (h : 0 \u2264 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 \u2264 1) (hb' : 0 \u2264 b) (hb : b \u2264 1) : a * b \u2264 1 :=\none_mul (1 : \u03b1) \u25b8 mul_le_mul ha hb hb' zero_le_one\n\nlemma one_lt_mul_of_le_of_lt (ha : 1 \u2264 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 \u2264 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 \u2190 one_lt_mul\n\nlemma mul_lt_one_of_nonneg_of_lt_one_left (ha\u2080 : 0 \u2264 a) (ha : a < 1) (hb : b \u2264 1) : a * b < 1 :=\n(mul_le_of_le_one_right ha\u2080 hb).trans_lt ha\n\nlemma mul_lt_one_of_nonneg_of_lt_one_right (ha : a \u2264 1) (hb\u2080 : 0 \u2264 b) (hb : b < 1) : a * b < 1 :=\n(mul_le_of_le_one_left hb\u2080 ha).trans_lt hb\n\nend ordered_semiring\n\nsection ordered_ring\nvariables [ordered_ring \u03b1] {a b c d : \u03b1}\n\n@[priority 100] -- see Note [lower instance priority]\ninstance ordered_ring.to_ordered_semiring : ordered_semiring \u03b1 :=\n{ mul_le_mul_of_nonneg_left := \u03bb 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 := \u03bb a b c h hc,\n    by simpa only [sub_mul, sub_nonneg] using ordered_ring.mul_nonneg _ _ (sub_nonneg.2 h) hc,\n  ..\u2039ordered_ring \u03b1\u203a, ..ring.to_semiring }\n\nlemma mul_le_mul_of_nonpos_left (h : b \u2264 a) (hc : c \u2264 0) : c * a \u2264 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 \u2264 a) (hc : c \u2264 0) : a * c \u2264 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 \u2264 0) (hb : b \u2264 0) : 0 \u2264 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 \u2264 a) (hbd : b \u2264 d) (hc : 0 \u2264 c) (hb : b \u2264 0) :\n  a * b \u2264 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 \u2264 a) (hbd : b \u2264 d) (ha : 0 \u2264 a) (hd : d \u2264 0) :\n  a * b \u2264 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 \u2264 c) (hdb : d \u2264 b) (hc : c \u2264 0) (hb : 0 \u2264 b) :\n  a * b \u2264 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 \u2264 a) (hbd : b \u2264 d) (ha : 0 \u2264 a) (hd : d \u2264 0) :\n  a * b \u2264 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 \u2264 a) (hdb : d \u2264 b) (hc : c \u2264 0) (hb : b \u2264 0) :\n  a * b \u2264 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 \u2264 a) (hdb : d \u2264 b) (ha : a \u2264 0) (hd : d \u2264 0) :\n  a * b \u2264 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 \u03b2] {f g : \u03b2 \u2192 \u03b1}\n\nlemma antitone_mul_left {a : \u03b1} (ha : a \u2264 0) : antitone ((*) a) :=\n\u03bb b c b_le_c, mul_le_mul_of_nonpos_left b_le_c ha\n\nlemma antitone_mul_right {a : \u03b1} (ha : a \u2264 0) : antitone (\u03bb x, x * a) :=\n\u03bb 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 \u2264 0) : antitone (\u03bb x, a * f x) :=\n(antitone_mul_left ha).comp_monotone hf\n\nlemma monotone.mul_const_of_nonpos (hf : monotone f) (ha : a \u2264 0) : antitone (\u03bb x, f x * a) :=\n(antitone_mul_right ha).comp_monotone hf\n\nlemma antitone.const_mul_of_nonpos (hf : antitone f) (ha : a \u2264 0) : monotone (\u03bb x, a * f x) :=\n(antitone_mul_left ha).comp hf\n\nlemma antitone.mul_const_of_nonpos (hf : antitone f) (ha : a \u2264 0) : monotone (\u03bb x, f x * a) :=\n(antitone_mul_right ha).comp hf\n\nlemma antitone.mul_monotone (hf : antitone f) (hg : monotone g) (hf\u2080 : \u2200 x, f x \u2264 0)\n  (hg\u2080 : \u2200 x, 0 \u2264 g x) :\n  antitone (f * g) :=\n\u03bb b c h, mul_le_mul_of_nonpos_of_nonneg (hf h) (hg h) (hf\u2080 _) (hg\u2080 _)\n\nlemma monotone.mul_antitone (hf : monotone f) (hg : antitone g) (hf\u2080 : \u2200 x, 0 \u2264 f x)\n  (hg\u2080 : \u2200 x, g x \u2264 0) :\n  antitone (f * g) :=\n\u03bb b c h, mul_le_mul_of_nonneg_of_nonpos (hf h) (hg h) (hf\u2080 _) (hg\u2080 _)\n\nlemma antitone.mul (hf : antitone f) (hg : antitone g) (hf\u2080 : \u2200 x, f x \u2264 0) (hg\u2080 : \u2200 x, g x \u2264 0) :\n  monotone (f * g) :=\n\u03bb b c h, mul_le_mul_of_nonpos_of_nonpos (hf h) (hg h) (hf\u2080 _) (hg\u2080 _)\n\nend monotone\n\nlemma le_iff_exists_nonneg_add (a b : \u03b1) : a \u2264 b \u2194 \u2203 c \u2265 0, b = a + c :=\n\u27e8\u03bb h, \u27e8b - a, sub_nonneg.mpr h, by simp\u27e9,\n  \u03bb \u27e8c, hc, h\u27e9, by { rw [h, le_add_iff_nonneg_right], exact hc }\u27e9\n\nend ordered_ring\n\nsection ordered_comm_ring\nvariables [ordered_comm_ring \u03b1]\n\n@[priority 100] -- See note [lower instance priority]\ninstance ordered_comm_ring.to_ordered_comm_semiring : ordered_comm_semiring \u03b1 :=\n{ ..ordered_ring.to_ordered_semiring, ..\u2039ordered_comm_ring \u03b1\u203a }\n\nend ordered_comm_ring\n\nsection strict_ordered_semiring\nvariables [strict_ordered_semiring \u03b1] {a b c d : \u03b1}\n\n@[priority 200] -- see Note [lower instance priority]\ninstance strict_ordered_semiring.to_pos_mul_strict_mono : pos_mul_strict_mono \u03b1 :=\n\u27e8\u03bb x a b h, strict_ordered_semiring.mul_lt_mul_of_pos_left _ _ _ h x.prop\u27e9\n\n@[priority 200] -- see Note [lower instance priority]\ninstance strict_ordered_semiring.to_mul_pos_strict_mono : mul_pos_strict_mono \u03b1 :=\n\u27e8\u03bb x a b h, strict_ordered_semiring.mul_lt_mul_of_pos_right _ _ _ h x.prop\u27e9\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 \u03b1 (\u2264)] : ordered_semiring \u03b1 :=\n{ mul_le_mul_of_nonneg_left := \u03bb 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 := \u03bb 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  ..\u2039strict_ordered_semiring \u03b1\u203a }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_ordered_semiring.to_ordered_semiring : ordered_semiring \u03b1 :=\n{ mul_le_mul_of_nonneg_left := \u03bb _ _ _, begin\n    letI := @strict_ordered_semiring.to_ordered_semiring' \u03b1 _ (classical.dec_rel _),\n    exact mul_le_mul_of_nonneg_left,\n  end,\n  mul_le_mul_of_nonneg_right := \u03bb _ _ _, begin\n    letI := @strict_ordered_semiring.to_ordered_semiring' \u03b1 _ (classical.dec_rel _),\n    exact mul_le_mul_of_nonneg_right,\n  end,\n  ..\u2039strict_ordered_semiring \u03b1\u203a }\n\nlemma mul_lt_mul (hac : a < c) (hbd : b \u2264 d) (hb : 0 < b) (hc : 0 \u2264 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 \u2264 c) (hbd : b < d) (hb : 0 \u2264 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) : \u2200 (n : \u2115), 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 \u2264 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 \u2264 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 (\u03bb x : \u03b1, x * x) {x | 0 \u2264 x} :=\n\u03bb 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 \u03b1 (\u2264)]\n  (h1 : a < c) (h2 : b < d) (h3 : 0 \u2264 a) (h4 : 0 \u2264 b) : a * b < c * d :=\nh4.lt_or_eq_dec.elim\n  (\u03bb b0, mul_lt_mul h1 h2.le b0 $ h3.trans h1.le)\n  (\u03bb b0, by rw [\u2190 b0, mul_zero]; exact\n    mul_pos (h3.trans_lt h1) (h4.trans_lt h2))\n\nlemma mul_lt_mul'' : a < c \u2192 b < d \u2192 0 \u2264 a \u2192 0 \u2264 b \u2192 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 \u03b2] {f g : \u03b2 \u2192 \u03b1}\n\nlemma strict_mono_mul_left_of_pos (ha : 0 < a) : strict_mono (\u03bb 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 (\u03bb 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 (\u03bb 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 (\u03bb 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 (\u03bb 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 (\u03bb 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\u2080 : \u2200 x, 0 \u2264 f x)\n  (hg\u2080 : \u2200 x, 0 < g x) :\n  strict_mono (f * g) :=\n\u03bb b c h, mul_lt_mul (hf h) (hg h.le) (hg\u2080 _) (hf\u2080 _)\n\nlemma monotone.mul_strict_mono (hf : monotone f) (hg : strict_mono g) (hf\u2080 : \u2200 x, 0 < f x)\n  (hg\u2080 : \u2200 x, 0 \u2264 g x) :\n  strict_mono (f * g) :=\n\u03bb b c h, mul_lt_mul' (hf h.le) (hg h) (hg\u2080 _) (hf\u2080 _)\n\nlemma strict_mono.mul (hf : strict_mono f) (hg : strict_mono g) (hf\u2080 : \u2200 x, 0 \u2264 f x)\n  (hg\u2080 : \u2200 x, 0 \u2264 g x) :\n  strict_mono (f * g) :=\n\u03bb b c h, mul_lt_mul'' (hf h) (hg h) (hf\u2080 _) (hg\u2080 _)\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 \u03b1 :=\n\u27e8\u03bb a, \u27e8a + 1, lt_add_of_pos_right _ one_pos\u27e9\u27e9\n\nend strict_ordered_semiring\n\nsection strict_ordered_comm_semiring\nvariables [strict_ordered_comm_semiring \u03b1]\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 \u03b1 (\u2264)] :\n  ordered_comm_semiring \u03b1 :=\n{ ..\u2039strict_ordered_comm_semiring \u03b1\u203a, ..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 \u03b1 :=\n{ ..\u2039strict_ordered_comm_semiring \u03b1\u203a, ..strict_ordered_semiring.to_ordered_semiring }\n\nend strict_ordered_comm_semiring\n\nsection strict_ordered_ring\nvariables [strict_ordered_ring \u03b1] {a b c : \u03b1}\n\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_ordered_ring.to_strict_ordered_semiring : strict_ordered_semiring \u03b1 :=\n{ le_of_add_le_add_left := @le_of_add_le_add_left \u03b1 _ _ _,\n  mul_lt_mul_of_pos_left := \u03bb 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 := \u03bb 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  ..\u2039strict_ordered_ring \u03b1\u203a,  ..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 \u03b1 (\u2264)] : ordered_ring \u03b1 :=\n{ mul_nonneg := \u03bb a b ha hb, begin\n    obtain ha | ha := decidable.eq_or_lt_of_le ha,\n    { rw [\u2190ha, zero_mul] },\n    obtain hb | hb := decidable.eq_or_lt_of_le hb,\n    { rw [\u2190hb, mul_zero] },\n    { exact (strict_ordered_ring.mul_pos _ _ ha hb).le }\n  end,\n  ..\u2039strict_ordered_ring \u03b1\u203a,  ..ring.to_semiring }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance strict_ordered_ring.to_ordered_ring : ordered_ring \u03b1 :=\n{ mul_nonneg := \u03bb a b, begin\n    letI := @strict_ordered_ring.to_ordered_ring' \u03b1 _ (classical.dec_rel _),\n    exact mul_nonneg,\n  end,\n  ..\u2039strict_ordered_ring \u03b1\u203a }\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 : \u03b1} (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 \u03b2] {f g : \u03b2 \u2192 \u03b1}\n\nlemma strict_anti_mul_left {a : \u03b1} (ha : a < 0) : strict_anti ((*) a) :=\n\u03bb b c b_lt_c, mul_lt_mul_of_neg_left b_lt_c ha\n\nlemma strict_anti_mul_right {a : \u03b1} (ha : a < 0) : strict_anti (\u03bb x, x * a) :=\n\u03bb 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 (\u03bb 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 (\u03bb 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 (\u03bb 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 (\u03bb 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 \u03b1]\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 \u03b1 (\u2264)] : ordered_comm_ring \u03b1 :=\n{ ..\u2039strict_ordered_comm_ring \u03b1\u203a, ..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 \u03b1 :=\n{ ..\u2039strict_ordered_comm_ring \u03b1\u203a, ..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 \u03b1 :=\n{ ..\u2039strict_ordered_comm_ring \u03b1\u203a, ..strict_ordered_ring.to_ordered_ring }\n\nend strict_ordered_comm_ring\n\nsection linear_ordered_semiring\nvariables [linear_ordered_semiring \u03b1] {a b c d : \u03b1}\n\n@[priority 200] -- see Note [lower instance priority]\ninstance linear_ordered_semiring.to_pos_mul_reflect_lt : pos_mul_reflect_lt \u03b1 :=\n\u27e8\u03bb a b c, (monotone_mul_left_of_nonneg a.2).reflect_lt\u27e9\n\n@[priority 200] -- see Note [lower instance priority]\ninstance linear_ordered_semiring.to_mul_pos_reflect_lt : mul_pos_reflect_lt \u03b1 :=\n\u27e8\u03bb a b c, (monotone_mul_right_of_nonneg a.2).reflect_lt\u27e9\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 \u2264 a * b) :\n    (0 \u2264 a \u2227 0 \u2264 b) \u2228 (a \u2264 0 \u2227 b \u2264 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 \u2264 a * b) (hb : 0 < b) : 0 \u2264 a :=\nle_of_not_gt $ \u03bb ha, (mul_neg_of_neg_of_pos ha hb).not_le h\n\nlemma nonneg_of_mul_nonneg_right (h : 0 \u2264 a * b) (ha : 0 < a) : 0 \u2264 b :=\nle_of_not_gt $ \u03bb 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 \u2264 b) : a < 0 :=\nlt_of_not_ge $ \u03bb ha, (mul_nonneg ha hb).not_lt h\n\nlemma neg_of_mul_neg_right (h : a * b < 0) (ha : 0 \u2264 a) : b < 0 :=\nlt_of_not_ge $ \u03bb hb, (mul_nonneg ha hb).not_lt h\n\nlemma nonpos_of_mul_nonpos_left (h : a * b \u2264 0) (hb : 0 < b) : a \u2264 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 \u2264 0) (ha : 0 < a) : b \u2264 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 \u2264 c * b \u2194 0 \u2264 b :=\nby { convert mul_le_mul_left h, simp }\n\n@[simp] lemma zero_le_mul_right (h : 0 < c) : 0 \u2264 b * c \u2194 0 \u2264 b :=\nby { convert mul_le_mul_right h, simp }\n\nlemma add_le_mul_of_left_le_right (a2 : 2 \u2264 a) (ab : a \u2264 b) : a + b \u2264 a * b :=\nhave 0 < b, from\ncalc 0 < 2 : zero_lt_two\n   ... \u2264 a : a2\n   ... \u2264 b : ab,\ncalc a + b \u2264 b + b : add_le_add_right ab b\n       ... = 2 * b : (two_mul b).symm\n       ... \u2264 a * b : (mul_le_mul_right this).mpr a2\n\nlemma add_le_mul_of_right_le_left (b2 : 2 \u2264 b) (ba : b \u2264 a) : a + b \u2264 a * b :=\nhave 0 < a, from\ncalc 0 < 2 : zero_lt_two\n   ... \u2264 b : b2\n   ... \u2264 a : ba,\ncalc a + b \u2264 a + a : add_le_add_left ba a\n       ... = a * 2 : (mul_two a).symm\n       ... \u2264 a * b : (mul_le_mul_left this).mpr b2\n\nlemma add_le_mul (a2 : 2 \u2264 a) (b2 : 2 \u2264 b) : a + b \u2264 a * b :=\nif hab : a \u2264 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 \u2264 a) (b2 : 2 \u2264 b) : a + b \u2264 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 \u2264 bit0 b \u2194 a \u2264 b :=\nby rw [bit0, bit0, \u2190 two_mul, \u2190 two_mul, mul_le_mul_left (zero_lt_two : 0 < (2:\u03b1))]\n\n@[simp] lemma bit0_lt_bit0 : bit0 a < bit0 b \u2194 a < b :=\nby rw [bit0, bit0, \u2190 two_mul, \u2190 two_mul, mul_lt_mul_left (zero_lt_two : 0 < (2:\u03b1))]\n\n@[simp] lemma bit1_le_bit1 : bit1 a \u2264 bit1 b \u2194 a \u2264 b :=\n(add_le_add_iff_right 1).trans bit0_le_bit0\n\n@[simp] lemma bit1_lt_bit1 : bit1 a < bit1 b \u2194 a < b :=\n(add_lt_add_iff_right 1).trans bit0_lt_bit0\n\n@[simp] lemma one_le_bit1 : (1 : \u03b1) \u2264 bit1 a \u2194 0 \u2264 a :=\nby rw [bit1, le_add_iff_nonneg_left, bit0, \u2190 two_mul, zero_le_mul_left (zero_lt_two : 0 < (2:\u03b1))]\n\n@[simp] lemma one_lt_bit1 : (1 : \u03b1) < bit1 a \u2194 0 < a :=\nby rw [bit1, lt_add_iff_pos_left, bit0, \u2190 two_mul, zero_lt_mul_left (zero_lt_two : 0 < (2:\u03b1))]\n\n@[simp] lemma zero_le_bit0 : (0 : \u03b1) \u2264 bit0 a \u2194 0 \u2264 a :=\nby rw [bit0, \u2190 two_mul, zero_le_mul_left (zero_lt_two : 0 < (2:\u03b1))]\n\n@[simp] lemma zero_lt_bit0 : (0 : \u03b1) < bit0 a \u2194 0 < a :=\nby rw [bit0, \u2190 two_mul, zero_lt_mul_left (zero_lt_two : 0 < (2:\u03b1))]\n\nend\n\ntheorem mul_nonneg_iff_right_nonneg_of_pos (ha : 0 < a) : 0 \u2264 a * b \u2194 0 \u2264 b :=\n\u27e8\u03bb h, nonneg_of_mul_nonneg_right h ha, mul_nonneg ha.le\u27e9\n\ntheorem mul_nonneg_iff_left_nonneg_of_pos (hb : 0 < b) : 0 \u2264 a * b \u2194 0 \u2264 a :=\n\u27e8\u03bb h, nonneg_of_mul_nonneg_left h hb, \u03bb h, mul_nonneg h hb.le\u27e9\n\nlemma nonpos_of_mul_nonneg_left (h : 0 \u2264 a * b) (hb : b < 0) : a \u2264 0 :=\nle_of_not_gt (\u03bb ha, absurd h (mul_neg_of_pos_of_neg ha hb).not_le)\n\nlemma nonpos_of_mul_nonneg_right (h : 0 \u2264 a * b) (ha : a < 0) : b \u2264 0 :=\nle_of_not_gt (\u03bb hb, absurd h (mul_neg_of_neg_of_pos ha hb).not_le)\n\n@[simp] lemma units.inv_pos {u : \u03b1\u02e3} : (0 : \u03b1) < \u2191u\u207b\u00b9 \u2194 (0 : \u03b1) < u :=\nhave \u2200 {u : \u03b1\u02e3}, (0 : \u03b1) < u \u2192 (0 : \u03b1) < \u2191u\u207b\u00b9 := \u03bb u h,\n  (zero_lt_mul_left h).mp $ u.mul_inv.symm \u25b8 zero_lt_one,\n\u27e8this, this\u27e9\n\n@[simp] lemma units.inv_neg {u : \u03b1\u02e3} : \u2191u\u207b\u00b9 < (0 : \u03b1) \u2194 \u2191u < (0 : \u03b1) :=\nhave \u2200 {u : \u03b1\u02e3}, \u2191u < (0 : \u03b1) \u2192 \u2191u\u207b\u00b9 < (0 : \u03b1) := \u03bb u h,\n  neg_of_mul_pos_right (by exact (u.mul_inv.symm \u25b8 zero_lt_one)) h.le,\n\u27e8this, this\u27e9\n\nlemma cmp_mul_pos_left (ha : 0 < a) (b c : \u03b1) : 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 : \u03b1) : 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 : \u03b1) (ha : 0 \u2264 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 : \u03b1) (ha : 0 \u2264 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 : \u03b1) (hc : 0 \u2264 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 : \u03b1) (hc : 0 \u2264 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 : \u03b1} (h : a * c \u2264 b) (hb : 0 \u2264 b) (hc : 1 \u2264 c) : a \u2264 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 : \u03b1} (hb : 0 \u2264 b) (h : a * a \u2264 b * b) : a \u2264 b :=\nle_of_not_gt $ \u03bb hab, (mul_self_lt_mul_self hb hab).not_le h\n\nlemma mul_self_le_mul_self_iff {a b : \u03b1} (h1 : 0 \u2264 a) (h2 : 0 \u2264 b) : a \u2264 b \u2194 a * a \u2264 b * b :=\n\u27e8mul_self_le_mul_self h1, nonneg_le_nonneg_of_sq_le_sq h2\u27e9\n\nlemma mul_self_lt_mul_self_iff {a b : \u03b1} (h1 : 0 \u2264 a) (h2 : 0 \u2264 b) : a < b \u2194 a * a < b * b :=\n((@strict_mono_on_mul_self \u03b1 _).lt_iff_lt h1 h2).symm\n\nlemma mul_self_inj {a b : \u03b1} (h1 : 0 \u2264 a) (h2 : 0 \u2264 b) : a * a = b * b \u2194 a = b :=\n(@strict_mono_on_mul_self \u03b1 _).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 \u03b1] : linear_ordered_cancel_add_comm_monoid \u03b1 :=\n{ ..\u2039linear_ordered_comm_semiring \u03b1\u203a }\n\nsection linear_ordered_ring\nvariables [linear_ordered_ring \u03b1] {a b c : \u03b1}\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 \u03b1 :=\n{ ..\u2039linear_ordered_ring \u03b1\u203a, ..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 \u03b1 :=\n{ ..\u2039linear_ordered_ring \u03b1\u203a }\n\n@[priority 100] -- see Note [lower instance priority]\ninstance linear_ordered_ring.no_zero_divisors : no_zero_divisors \u03b1 :=\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 (\u03bb 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  .. \u2039linear_ordered_ring \u03b1\u203a }\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 \u03b1 :=\n{ mul_left_cancel_of_ne_zero := \u03bb a b c ha h,\n  begin\n    rw [\u2190 sub_eq_zero, \u2190 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 := \u03bb a b c hb h,\n  begin\n    rw [\u2190 sub_eq_zero, \u2190 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 \u03b1) }\n\nlemma mul_pos_iff : 0 < a * b \u2194 0 < a \u2227 0 < b \u2228 a < 0 \u2227 b < 0 :=\n\u27e8pos_and_pos_or_neg_and_neg_of_mul_pos,\n  \u03bb h, h.elim (and_imp.2 mul_pos) (and_imp.2 mul_pos_of_neg_of_neg)\u27e9\n\nlemma mul_neg_iff : a * b < 0 \u2194 0 < a \u2227 b < 0 \u2228 a < 0 \u2227 0 < b :=\nby rw [\u2190 neg_pos, neg_mul_eq_mul_neg, mul_pos_iff, neg_pos, neg_lt_zero]\n\nlemma mul_nonneg_iff : 0 \u2264 a * b \u2194 0 \u2264 a \u2227 0 \u2264 b \u2228 a \u2264 0 \u2227 b \u2264 0 :=\n\u27e8nonneg_and_nonneg_or_nonpos_and_nonpos_of_mul_nnonneg,\n  \u03bb h, h.elim (and_imp.2 mul_nonneg) (and_imp.2 mul_nonneg_of_nonpos_of_nonpos)\u27e9\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 : \u03b1) :\n  0 \u2264 a * b \u2228 0 \u2264 b * c \u2228 0 \u2264 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 \u2264 0 \u2194 0 \u2264 a \u2227 b \u2264 0 \u2228 a \u2264 0 \u2227 0 \u2264 b :=\nby rw [\u2190 neg_nonneg, neg_mul_eq_mul_neg, mul_nonneg_iff, neg_nonneg, neg_nonpos]\n\nlemma mul_self_nonneg (a : \u03b1) : 0 \u2264 a * a :=\n(le_total 0 a).elim (\u03bb h, mul_nonneg h h) (\u03bb h, mul_nonneg_of_nonpos_of_nonpos h h)\n\n@[simp] lemma neg_le_self_iff : -a \u2264 a \u2194 0 \u2264 a :=\nby simp [neg_le_iff_add_nonneg, \u2190 two_mul, mul_nonneg_iff, zero_le_one, (zero_lt_two' \u03b1).not_le]\n\n@[simp] lemma neg_lt_self_iff : -a < a \u2194 0 < a :=\nby simp [neg_lt_iff_pos_add, \u2190 two_mul, mul_pos_iff, zero_lt_one, (zero_lt_two' \u03b1).not_lt]\n\n@[simp] lemma le_neg_self_iff : a \u2264 -a \u2194 a \u2264 0 :=\ncalc a \u2264 -a \u2194 -(-a) \u2264 -a : by rw neg_neg\n... \u2194 0 \u2264 -a : neg_le_self_iff\n... \u2194 a \u2264 0 : neg_nonneg\n\n@[simp] lemma lt_neg_self_iff : a < -a \u2194 a < 0 :=\ncalc a < -a \u2194 -(-a) < -a : by rw neg_neg\n... \u2194 0 < -a : neg_lt_self_iff\n... \u2194 a < 0 : neg_pos\n\nlemma neg_one_lt_zero : -1 < (0:\u03b1) := neg_lt_zero.2 zero_lt_one\n\n@[simp] lemma mul_le_mul_left_of_neg {a b c : \u03b1} (h : c < 0) : c * a \u2264 c * b \u2194 b \u2264 a :=\n(strict_anti_mul_left h).le_iff_le\n\n@[simp] lemma mul_le_mul_right_of_neg {a b c : \u03b1} (h : c < 0) : a * c \u2264 b * c \u2194 b \u2264 a :=\n(strict_anti_mul_right h).le_iff_le\n\n@[simp] lemma mul_lt_mul_left_of_neg {a b c : \u03b1} (h : c < 0) : c * a < c * b \u2194 b < a :=\n(strict_anti_mul_left h).lt_iff_lt\n\n@[simp] lemma mul_lt_mul_right_of_neg {a b c : \u03b1} (h : c < 0) : a * c < b * c \u2194 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 \u2264 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 \u2264 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 : \u03b1} (ha : a < 0) (b c : \u03b1) : 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 : \u03b1} (ha : a < 0) (b c : \u03b1) : 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 : \u03b1) : a - 1 < a :=\nsub_lt_iff_lt_add.2 (lt_add_one a)\n\n@[simp] lemma mul_self_pos {a : \u03b1} : 0 < a * a \u2194 a \u2260 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 : \u03b1} (h\u2081 : x \u2264 y) (h\u2082 : -x \u2264 y) : x * x \u2264 y * y :=\n(le_total 0 x).elim (\u03bb h, mul_le_mul h\u2081 h\u2081 h (h.trans h\u2081))\n  (\u03bb h, le_of_eq_of_le (neg_mul_neg x x).symm\n    (mul_le_mul h\u2082 h\u2082 (neg_nonneg.mpr h) ((neg_nonneg.mpr h).trans h\u2082)))\n\nlemma nonneg_of_mul_nonpos_left {a b : \u03b1} (h : a * b \u2264 0) (hb : b < 0) : 0 \u2264 a :=\nle_of_not_gt (\u03bb ha, absurd h (mul_pos_of_neg_of_neg ha hb).not_le)\n\nlemma nonneg_of_mul_nonpos_right {a b : \u03b1} (h : a * b \u2264 0) (ha : a < 0) : 0 \u2264 b :=\nle_of_not_gt (\u03bb hb, absurd h (mul_pos_of_neg_of_neg ha hb).not_le)\n\nlemma pos_of_mul_neg_left {a b : \u03b1} (h : a * b < 0) (hb : b \u2264 0) : 0 < a :=\nlt_of_not_ge (\u03bb ha, absurd h (mul_nonneg_of_nonpos_of_nonpos ha hb).not_lt)\n\nlemma pos_of_mul_neg_right {a b : \u03b1} (h : a * b < 0) (ha : a \u2264 0) : 0 < b :=\nlt_of_not_ge (\u03bb 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 \u2194 0 < b :=\n\u27e8pos_of_mul_neg_right hab \u2218 le_of_lt, neg_of_mul_neg_left hab \u2218 le_of_lt\u27e9\n\nlemma pos_iff_neg_of_mul_neg (hab : a * b < 0) : 0 < a \u2194 b < 0 :=\n\u27e8neg_of_mul_neg_right hab \u2218 le_of_lt, pos_of_mul_neg_left hab \u2218 le_of_lt\u27e9\n\n/-- The sum of two squares is zero iff both elements are zero. -/\nlemma mul_self_add_mul_self_eq_zero {x y : \u03b1} : x * x + y * y = 0 \u2194 x = 0 \u2227 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 \u03b1] :\n  strict_ordered_comm_ring \u03b1 :=\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 \u03b1] :\n   linear_ordered_comm_semiring \u03b1 :=\n{ .. d, ..linear_ordered_ring.to_linear_ordered_semiring }\n\nsection linear_ordered_comm_ring\n\nvariables [linear_ordered_comm_ring \u03b1] {a b c d : \u03b1}\n\nlemma max_mul_mul_le_max_mul_max (b c : \u03b1) (ha : 0 \u2264 a) (hd: 0 \u2264 d) :\n  max (a * b) (d * c) \u2264 max a c * max d b :=\nhave ba : b * a \u2264 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 \u2264 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 \u00d7 List Nat) :=\n[(x, [x, x]), (x, [])]\n\ndef h (x : Nat) : List Nat :=\nlet xs := g x |>.filter (fun \u27e8_, xs\u27e9 => xs.isEmpty)\nxs.map (\u00b7.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 : \u2200 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\u27e8\u03bb X : LocallyRingedSpace, (X.to_Top : Type u)\u27e9\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 \ud835\udcaa 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 \ud835\udcaa : 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 \u27f6 Y.to_SheafedSpace //\n    \u2200 x, is_local_ring_hom (PresheafedSpace.stalk_map f x) }\n\ninstance : quiver LocallyRingedSpace := \u27e8hom\u27e9\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.\ud835\udcaa.stalk` here?\nnoncomputable\ndef stalk (X : LocallyRingedSpace) (x : X) : CommRing := X.presheaf.stalk x\n\n/--\nA morphism of locally ringed spaces `f : X \u27f6 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 \u27f6 Y) (x : X) :\n  Y.stalk (f.1.1 x) \u27f6 X.stalk x :=\nPresheafedSpace.stalk_map f.1 x\n\ninstance {X Y : LocallyRingedSpace} (f : X \u27f6 Y) (x : X) :\n  is_local_ring_hom (stalk_map f x) := f.2 x\n\ninstance {X Y : LocallyRingedSpace} (f : X \u27f6 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\u27e8\ud835\udfd9 _, \u03bb x, by { erw PresheafedSpace.stalk_map.id, apply is_local_ring_hom_id, }\u27e9\n\ninstance (X : LocallyRingedSpace) : inhabited (hom X X) := \u27e8id X\u27e9\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\u27e8f.val \u226b g.val, \u03bb x,\nbegin\n  erw PresheafedSpace.stalk_map.comp,\n  exact @is_local_ring_hom_comp _ _ _ _ _ _ _ _ (f.2 _) (g.2 _),\nend\u27e9\n\n/-- The category of locally ringed spaces. -/\ninstance : category LocallyRingedSpace :=\n{ hom := hom,\n  id := id,\n  comp := \u03bb 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 \u2964 SheafedSpace CommRing :=\n{ obj := \u03bb X, X.to_SheafedSpace,\n  map := \u03bb 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 \u2964 Top :=\nforget_to_SheafedSpace \u22d9 SheafedSpace.forget _\n\n@[simp] lemma comp_val {X Y Z : LocallyRingedSpace} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).val = f.val \u226b g.val := rfl\n\n@[simp] lemma comp_val_c {X Y Z : LocallyRingedSpace} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).val.c = g.val.c \u226b (presheaf.pushforward _ g.val.base).map f.val.c := rfl\n\nlemma comp_val_c_app {X Y Z : LocallyRingedSpace} (f : X \u27f6 Y) (g : Y \u27f6 Z) (U : (opens Z)\u1d52\u1d56) :\n  (f \u226b g).val.c.app U = g.val.c.app U \u226b 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 \u27f6 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 \u27f6 Y.to_SheafedSpace) [is_iso f] : X \u27f6 Y :=\nsubtype.mk f $ \u03bb 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 \u27f6 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 \u2245 Y.to_SheafedSpace) : X \u2245 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 := \u03bb X Y f i,\n  { out := by exactI\n    \u27e8hom_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 _)\u27e9 } }\n\ninstance is_SheafedSpace_iso {X Y : LocallyRingedSpace} (f : X \u27f6 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 \u27f6 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 \u27f6 X.to_Top}\n  (h : open_embedding f) : X.restrict h \u27f6 X :=\n\u27e8X.to_PresheafedSpace.of_restrict h, \u03bb x, infer_instance\u27e9\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 \u22a4) \u2245 X :=\n@iso_of_SheafedSpace_iso (X.restrict (opens.open_embedding \u22a4)) X\n  X.to_SheafedSpace.restrict_top_iso\n\n/--\nThe global sections, notated Gamma.\n-/\ndef \u0393 : LocallyRingedSpace\u1d52\u1d56 \u2964 CommRing :=\nforget_to_SheafedSpace.op \u22d9 SheafedSpace.\u0393\n\nlemma \u0393_def : \u0393 = forget_to_SheafedSpace.op \u22d9 SheafedSpace.\u0393 := rfl\n\n@[simp] lemma \u0393_obj (X : LocallyRingedSpace\u1d52\u1d56) : \u0393.obj X = (unop X).presheaf.obj (op \u22a4) := rfl\n\nlemma \u0393_obj_op (X : LocallyRingedSpace) : \u0393.obj (op X) = X.presheaf.obj (op \u22a4) := rfl\n\n@[simp] lemma \u0393_map {X Y : LocallyRingedSpace\u1d52\u1d56} (f : X \u27f6 Y) :\n  \u0393.map f = f.unop.1.c.app (op \u22a4) := rfl\n\nlemma \u0393_map_op {X Y : LocallyRingedSpace} (f : X \u27f6 Y) :\n  \u0393.map f.op = f.1.c.app (op \u22a4) := rfl\n\nlemma preimage_basic_open {X Y : LocallyRingedSpace} (f : X \u27f6 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 \u27e8\u27e8y, hyU\u27e9, (hy : is_unit _), (rfl : y = _)\u27e9,\n    erw RingedSpace.mem_basic_open _ _ \u27e8x, show x \u2208 (opens.map f.1.base).obj U, from hyU\u27e9,\n    rw \u2190 PresheafedSpace.stalk_map_germ_apply,\n    exact (PresheafedSpace.stalk_map f.1 _).is_unit_map hy },\n  { rintros \u27e8y, (hy : is_unit _), rfl\u27e9,\n    erw RingedSpace.mem_basic_open _ _ \u27e8f.1.base y.1, y.2\u27e9,\n    rw \u2190 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) = \u2205 :=\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 \u27e8\u27e8y, _\u27e9, h, e\u27e9,\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 \u2192 S0\n\n    def up (\u03c8: S0): S1 :=\n        const S0 \u03c8\n\n    theorem diag {f: S1 \u2192 S1 \u2192 S0} (sur_f: surjective f):\n        \u2200 \u03c6: S1,\n        \u2203 \u03c8: S0,\n        \u03c8 = f \u03c6 (up \u03c8) :=\n            assume \u03c6: S1,\n            let h: S0 \u2192 S0 := f \u03c6 \u2218 up in\n            simple_lawvere.{0 0} sur_f h\n\n\n    -- lob axioms:\n    constant Bew: S0 \u2192 S0\n\n    constant godnum: S1 \u2192 S0\n\n    def box: S0 \u2192 S0 := Bew \u2218 godnum \u2218 up\n\n    def proves: S0 \u2192 Prop := box\n\n    namespace hilbert_bernay\n        axiom a:\n            \u2200 {\u03c6: S0},\n            proves \u03c6 \u2192 proves (box \u03c6)\n\n        axiom b:\n            \u2200 {\u03c6: S0},\n            proves (box \u03c6 \u2192 box (box \u03c6))\n\n        axiom c:\n            \u2200 {\u03c6 \u03c8: S0},\n            proves (box (\u03c6 \u2192 \u03c8) \u2192 box \u03c6 \u2192 box \u03c8)\n    end hilbert_bernay\n\n    def f (\u03c6: S1) (\u03c8: S1): S0 :=\n        \u03c6 (godnum \u03c8)\n\n    @[instance] axiom f.sur: surjective f\n\n    axiom proves.mp:\n        \u2200 {\u03c6 \u03c8: S0},\n        proves (\u03c6 \u2192 \u03c8) \u2192 proves \u03c6 \u2192 proves \u03c8\n\n    axiom proves.implies_trans:\n        \u2200 {a b c: S0},\n        proves (a \u2192 b) \u2192 proves (b \u2192 c) \u2192 proves (a \u2192 c)\n\n    axiom proves.implies_middleman_elim:\n        \u2200 {a b c: S0},\n        proves (a \u2192 b \u2192 c) \u2192 proves (a \u2192 b) \u2192 proves (a \u2192 c)\n\n    axiom proves.diag:\n        \u2200 \u03c6: S1,\n        \u2203 \u03c8: S0,\n        proves (\u03c8 \u2194 f \u03c6 (up \u03c8))\n\n    axiom proves.iff_mp:\n        \u2200 {a b: S0},\n        proves (a \u2194 b) \u2192 proves (a \u2192 b)\n\n    axiom proves.iff_mpr:\n        \u2200 {a b: S0},\n        proves (a \u2194 b) \u2192 proves (b \u2192 a)\n\n\n    -- lob's theorem:\n    def h (\u03c8: S0) (x: S0): S0 :=\n        Bew x \u2192 \u03c8\n\n    @[simp] theorem f_of_h:\n        \u2200 {\u03c8 \u03c6: S0},\n        f (h \u03c8) (up \u03c6) = (box \u03c6 \u2192 \u03c8) :=\n            assume \u03c8 \u03c6: S0,\n            rfl\n\n    theorem lob {\u03c8: S0} (h0: proves (box \u03c8 \u2192 \u03c8)): proves \u03c8 :=\n        exists.elim (proves.diag (h \u03c8)) (\n            assume \u03c6: S0,\n            assume heq: proves (\u03c6 \u2194 f (h \u03c8) (up \u03c6)),\n            have h1: proves (\u03c6 \u2194 (box \u03c6 \u2192 \u03c8)),\n                by {simp at heq, exact heq},\n            have h1_forward: proves (\u03c6 \u2192 (box \u03c6 \u2192 \u03c8)),\n                from h1.iff_mp,\n            have h1_reverse: proves ((box \u03c6 \u2192 \u03c8) \u2192 \u03c6),\n                from h1.iff_mpr,\n            have h2: proves (box (\u03c6 \u2192 (box \u03c6 \u2192 \u03c8))),\n                from hilbert_bernay.a h1_forward,\n            have h3: proves (box \u03c6 \u2192 box (box \u03c6 \u2192 \u03c8)),\n                from hilbert_bernay.c.mp h2,\n            have h4: proves (box \u03c6 \u2192 box (box \u03c6) \u2192 box \u03c8),\n                from h3.implies_trans hilbert_bernay.c,\n            have h5: proves (box \u03c6 \u2192 box (box \u03c6)),\n                from hilbert_bernay.b,\n            have h6: proves (box \u03c6 \u2192 box \u03c8),\n                from h4.implies_middleman_elim h5,\n            have h7: proves (box \u03c6 \u2192 \u03c8),\n                from h6.implies_trans h0,\n            have h8: proves \u03c6,\n                from h1_reverse.mp h7,\n            have h9: proves (box \u03c6),\n                from hilbert_bernay.a h8,\n            show proves \u03c8,\n                from h7.mp h9\n        )\n\n\n    -- godel's second incompleteness theorem:\n    theorem godel: proves (\u00acbox false) \u2192 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 \u2192 Type v) (g : Type u' \u2192 Type v') :=\n (f_functor : functor f)\n (g_functor : functor g)\n (map : \u2200 {\u03b1 \u03b2}, (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 g \u03b2)\n (map_fmap_comm : \u2200 {\u03b1 \u03b2 \u03b2' \u03b3}\n            (h : \u03b2 \u2192 \u03b3)    (hp : \u03b1 \u2192 \u03b2)\n            (hp' : \u03b2' \u2192 \u03b3) (h' : \u03b1 \u2192 \u03b2')\n            (x : f \u03b1),\n    h \u2218 hp = hp' \u2218 h' \u2192\n    functor.map h (map hp x) = map hp' (functor.map h' x))\n\nsection thms\n\nvariables {F : Type u \u2192 Type v}\nvariables {\u03b1 \u03b2 \u03b3 : Type u}\nvariables [functor F] [is_lawful_functor F]\n\nlemma functor.id_map' : functor.map id = (id : F \u03b1 \u2192 F \u03b1) :=\nby { apply funext, apply is_lawful_functor.id_map }\n\nlemma functor.comp_map' (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3)\n: functor.map (g \u2218 f) = (functor.map g \u2218 functor.map f : F \u03b1 \u2192 F \u03b3) :=\nby { apply funext, intro, apply is_lawful_functor.comp_map }\n\n@[norm]\nlemma functor.map_map (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (x : F \u03b1) :\n  g <$> f <$> x = (g \u2218 f) <$> x :=\nby rw \u2190 comp_map\n\nend thms\n\n/- identity functor -/\n\nstructure identity (\u03b1 : Type u) : Type u :=\n  (run_identity : \u03b1)\n\nnamespace identity\n\nopen function\n\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type u'}\n\ndef map (f : \u03b1 \u2192 \u03b2) : identity \u03b1 \u2192 identity \u03b2\n  | \u27e8 x \u27e9 := \u27e8 f x \u27e9\n\nlocal infixr <$> := map\n\nlemma id_map : \u2200 (x : identity \u03b1), map id x = x\n | \u27e8 x \u27e9 := rfl\n\nlemma comp_map (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3)\n: \u2200 (x : identity \u03b1), map (g \u2218 f) x = g <$> f <$> x\n | \u27e8 x \u27e9 := 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 \u03b1 \u03b2 \u03b2' \u03b3,\n    intros h hp hp' h' x,\n    intros H,\n    rw [\u2190 identity.comp_map,\u2190 identity.comp_map,H],\n  end }\n\nlemma identity.fmap_mk {\u03b1 \u03b2 : Type v}  (f : \u03b1 \u2192 \u03b2) (x : \u03b1)\n: f <$> identity.mk x = identity.mk (f x) := rfl\n\n/- compose functor instance -/\n\nstructure compose (f : Type u \u2192 Type u') (g : Type v \u2192 Type u) (\u03b1 : Type v) : Type u' :=\n  (run : f $ g \u03b1)\n\nnamespace compose\n\nsection functor\n\nvariables {f : Type u \u2192 Type u'} {g : Type v \u2192 Type u}\n\nvariables [functor f] [functor g]\nvariables {\u03b1 \u03b2 \u03b3 : Type v}\n\ndef map (h : \u03b1 \u2192 \u03b2) : compose f g \u03b1 \u2192 compose f g \u03b2\n  | \u27e8 x \u27e9 := \u27e8 functor.map h <$> x \u27e9\n\nlocal infix ` <$> ` := map\n\nvariables [is_lawful_functor f] [is_lawful_functor g]\nvariables {\u03b1 \u03b2 \u03b3}\n\nlemma id_map : \u2200 (x : compose f g \u03b1), map id x = x\n  | \u27e8 x \u27e9 :=\nby simp! [functor.id_map']\n\nlemma comp_map (g_1 : \u03b1 \u2192 \u03b2) (h : \u03b2 \u2192 \u03b3) : \u2200 (x : compose f g \u03b1),\n           map (h \u2218 g_1) x = map h (map g_1 x)\n  | \u27e8 x \u27e9 :=\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  \u2192 Type w}  {g :  Type u  \u2192 Type v}\nvariables {f' : Type v' \u2192 Type w'} {g' : Type u' \u2192 Type v'}\n\nvariables [functor_pair f f'] [functor_pair g g']\nvariables {\u03b1 : Type u} {\u03b2 : Type u'}\n\ndef map_pair (h : \u03b1 \u2192 \u03b2) : compose f g \u03b1 \u2192 compose f' g' \u03b2\n  | \u27e8 x \u27e9 := \u27e8 functor_pair.map f' (functor_pair.map g' h) x \u27e9\n\nend functor_pair\nend compose\n\ninstance functor_compose {f : Type u \u2192 Type u'} {g : Type v \u2192 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 \u2192 Type u'} {g : Type v \u2192 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 := \u03bb _, @compose.id_map f g _ _ _ _ _\n, comp_map := \u03bb _ _ _, @compose.comp_map f g _ _ _ _ _ _ _ }\n\ninstance compose_functor_pair\n  {f :  Type v  \u2192 Type w}  {g  : Type u  \u2192 Type v}\n  {f' : Type v' \u2192 Type w'} {g' : Type u' \u2192 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 \u03b1 \u03b2 \u03b2' \u03b3,\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 {\u03b1 \u03b2 : Type u'}\n  {f : Type u \u2192 Type v} {g : Type u' \u2192 Type u}\n  [functor f] [functor g]\n  (h : \u03b1 \u2192 \u03b2) (x : f (g \u03b1))\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:\u211a}:q.num \u2264 0 \u2192 q \u2264 0  :=\nbegin\n  intro A1,\n  have A3:(0:\u2124) < (((0:rat).denom):\u2124),\n  {\n    simp,\n    apply (0:rat).pos,     \n  },\n  rw \u2190 @rat.num_denom q,\n  rw \u2190 @rat.num_denom 0,\n  rw rat.le_def,\n  simp,\n  have A4:(0:\u2124) < (((q:rat).denom):\u2124),\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:\u211a}:q\u2264 0 \u2192 q.num \u2264 0 :=\nbegin\n  intro A1,\n  have A3:(0:\u2124) < (((0:rat).denom):\u2124),\n  {\n    simp,\n    apply (0:rat).pos,     \n  },\n  have A4:(0:\u2124) < (((q:rat).denom):\u2124),\n  {\n    simp,\n    apply (q:rat).pos,     \n  },  \n  rw \u2190 @rat.num_denom q at A1,\n  rw \u2190 @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:\u211a}:q.num \u2264 0 \u2194 q \u2264 0  :=\nbegin\n  have A3:(0:\u2124) < (((0:rat).denom):\u2124),\n  {\n    simp,\n    apply (0:rat).pos,     \n  },\n  have A4:(0:\u2124) < (((q:rat).denom):\u2124),\n  {\n    simp,\n    apply (q:rat).pos,     \n  },\n\n  rw \u2190 @rat.num_denom q,\n  rw \u2190 @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:\u2124) * \u2191((0:\u211a).denom) = (0:\u2124) := zero_mul _,\n    rw \u2190 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:\u211a}:0 < q \u2192 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:\u211a}:0 < q \u2194 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:\u2124}:\n    ring_hom_int_rat.to_fun n = rat.of_int n := rfl\n\n\nlemma ring_hom_int_rat_to_fun_def2 {n:\u2124}:\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:\u2124}:(ring_hom_int_rat.to_fun a)=(ring_hom_int_rat.to_fun b) \u2194 (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:\u2115}:\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:\u2115}:\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:\u2115}:(ring_hom_nat_rat.to_fun a)=(ring_hom_nat_rat.to_fun b) \u2194 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:\u2115}:1 \u2264 a \u2194 0 < a :=\nbegin\n  rw \u2190 nat.succ_le_iff_lt,\nend\n\nlemma rat.exists_unit_frac_le_pos {q:\u211a}:0 < q \u2192 (\u2203 n:\u2115, (1/((n:rat) + 1)) \u2264 q) := \nbegin\n  intro A1,\n  have A3 := @rat.num_denom q,\n  rw \u2190 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 \u2115 _):\u211a) = 1 := rfl,\n    rw \u2190 A2A,\n    repeat {rw \u2190 ring_hom_nat_rat_to_fun_def2},\n    rw \u2190 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:\u2124):rat)/((q.denom:\u2124):rat)=1/(q.denom:rat),\n    {\n      refl,\n    },\n    rw \u2190 A3B,\n    rw \u2190 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 \u2190 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:\u2124} {n:pnat}:(rat.mk p (n:\u2124))=\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:\u2124}:(0 < p) \u2192 (1 \u2264 q) \u2192 \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:\u2124) = int.of_nat q.succ := rfl,\n      rw \u2190 B1,\n      rw rat.mk_pos_denom,\n      rw \u2190 rat.num_pos_iff_pos,\n      rw rat.mk_pnat_num,\n      simp,\n      cases p,\n      {\n        simp, \n        rw \u2190 int.coe_nat_div,\n        have B2:((0:\u2115):\u2124) = (0:\u2124) := rfl,\n        rw \u2190 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 \u2190 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 (i j : \u2124), i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u2260 (int.fract (\u03b1 * \u2191j)), from\n    assume (i j : \u2124) (hij : i \u2260 j),\n    have h2 : \u03b1 * \u2191i - \u2191(int.floor (\u03b1 * \u2191i)) = int.fract (\u03b1 * \u2191i), from by {\n      rw int.fract_def,\n      ring,\n    },\n    have h3 : \u03b1 * \u2191j - \u2191(int.floor (\u03b1 * \u2191j)) = int.fract (\u03b1 * \u2191j), from by {\n      rw int.fract_def,\n      ring,\n    },\n    have h4 : \u03b1 * \u2191i - \u2191(int.floor (\u03b1 * \u2191i)) = \u03b1 * \u2191j - \u2191(int.floor (\u03b1 * \u2191j)), from by {\n      rw h2, rw h3,\n    },\n    have h5 : \u03b1 = (int.floor (\u03b1 * \u2191i) - int.floor (\u03b1 * \u2191j)) / (i - j), from by {\n      rw \u2190 int.fract_add_floor_eq_of_lt (\u03b1 * \u2191i) (by {norm_num}),\n      rw \u2190 int.fract_add_floor_eq_of_lt (\u03b1 * \u2191j) (by {norm_num}),\n      rw h4,\n      rw int.fract_add_floor_eq_of_lt (\u03b1 * \u2191i) (by {norm_num}),\n      rw int.fract_add_floor_eq_of_lt (\u03b1 * \u2191j) (by {norm_num}),\n      rw \u2190 int.fract_add_floor_eq_of_lt (\u03b1 * \u2191i) (by {norm_num}),\n      rw \u2190 int.fract_add_floor_eq_of_lt (\u03b1 * \u2191j) (by {norm_num}),\n      rw int.fract_add_floor_eq_of_lt (\u03b1 * \u2191i) (by {norm_num}),\n      rw int.fract_add_floor_eq_of_lt (\u03b1 * \u2191j) (by {norm_num}),\n      ring,\n    },\n    have h6 : \u03b1 \u2208 \u211a, from by {\n      rw \u2190 h5,\n      apply int.cast_ne_zero.1 hij,\n    },\n    have h7 : irrational \u03b1, from h\u03b1_irrat,\n    have h8 : \u00ac(\u03b1 \u2208 \u211a), from h7,\n    have h9 : false, from by {\n      apply h8 h6,\n    },\n    show (int.fract (\u03b1 * \u2191i)) \u2260 (int.fract (\u03b1 * \u2191j)), from by {\n      apply h9,\n    },\n\n  have h2 : \u2200 (i : \u2124), int.fract (\u03b1 * \u2191i) \u2208 set.Icc 0 1, from \n    assume (i : \u2124),\n    have h3 : 0 \u2264 int.fract (\u03b1 * \u2191i), from by {\n      rw int.fract_def,\n      apply int.cast_nonneg,\n    },\n    have h4 : int.fract (\u03b1 * \u2191i) < 1, from by {\n      rw int.fract_def,\n      have h5 : \u03b1 * \u2191i - \u2191(int.floor (\u03b1 * \u2191i)) < 1, from by {\n        apply int.cast_lt.2,\n        rw \u2190 int.coe_nat_lt_coe_nat_iff,\n        apply int.fract_lt_one,\n      },\n      have h6 : 0 < \u03b1 * \u2191i - \u2191(int.floor (\u03b1 * \u2191i)), from by {\n        apply int.cast_pos,\n        rw \u2190 int.coe_nat_lt_coe_nat_iff,\n        apply int.fract_pos,\n        norm_num,\n      },\n      have h7 : 0 \u2264 \u2191(int.floor (\u03b1 * \u2191i)), from by {\n        apply int.cast_nonneg,\n      },\n      linarith,\n    },\n    show int.fract (\u03b1 * \u2191i) \u2208 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 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from h1,\n  have h4 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2209 set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)), from\n    assume (i j : \u2124) (hij : i \u2260 j),\n    have h5 : int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from h3 i j hij,\n    show int.fract (\u03b1 * \u2191i) \u2209 set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)), from by {\n      rw set.mem_range,\n      rw set.mem_range at h5,\n      exact h5,\n    },\n\n  have h5 : \u2200 (i : \u2124), int.fract (\u03b1 * \u2191i) \u2209 set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)), from \n    assume (i : \u2124),\n    have h6 : \u2203 (j : \u2124), i \u2260 j, from by {\n      have h7 : \u2200 (j : \u2124), i \u2260 j \u2192 \u2203 (k : \u2124), i \u2260 k, from by {\n        assume (j : \u2124) (hij : i \u2260 j),\n        have h8 : \u2203 (k : \u2124), k \u2260 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 : \u2203 (j : \u2124), \u2200 (k : \u2124), i \u2260 k \u2192 i \u2260 j, from by {\n        use i,\n        assume (k : \u2124) (hik : i \u2260 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 : \u2200 (i : \u2124), int.fract (\u03b1 * \u2191i) \u2208 closure (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))), from \n    assume (i : \u2124),\n    have h7 : \u2200 (j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2208 closure (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))), from by {\n      assume (j : \u2124) (hij : i \u2260 j),\n      have h8 : int.fract (\u03b1 * \u2191i) \u2208 set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)), from by {\n        rw set.mem_range,\n        use i,\n        refl,\n      },\n      have h9 : int.fract (\u03b1 * \u2191i) \u2209 closure (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))), 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 (\u03b1 * \u2191k),\n        assume h10,\n        have h11 : int.fract (\u03b1 * \u2191i) \u2209 set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)), 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 i j : \u2124, i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n    assume i j h,\n    assume h2 : int.fract (\u03b1 * \u2191i) = int.fract (\u03b1 * \u2191j),\n    have h3 : (\u03b1 * \u2191i) - (int.floor (\u03b1 * \u2191i)) = (int.floor (\u03b1 * \u2191j)) - (int.floor (\u03b1 * \u2191j)),\n    from by {rw h2, ring},\n    have h4 : (\u03b1 * \u2191i) - (int.floor (\u03b1 * \u2191i)) = (\u03b1 * \u2191j) - (int.floor (\u03b1 * \u2191j)),\n    from by {rw h3, ring},\n    have h5 : (\u03b1 * \u2191i) - (int.floor (\u03b1 * \u2191i)) = (\u03b1 * \u2191j) - (int.floor (\u03b1 * \u2191j)),\n    from by {rw h3, ring},\n    have h6 : \u03b1 = (int.floor (\u03b1 * \u2191i)) - (int.floor (\u03b1 * \u2191j)) / (i - j),\n    from by {rw h4, ring},\n    have h7 : (int.floor (\u03b1 * \u2191i)) - (int.floor (\u03b1 * \u2191j)) / (i - j) \u2208 \u211a,\n    from by {apply int.cast_div,},\n    have h8 : \u03b1 \u2208 \u211a, from by {rw h6, exact h7,},\n    have h9 : irrational \u03b1, from h\u03b1_irrat,\n    contradiction,\n  },\n  have h2 : set.finite (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))), from by {\n    apply set.finite_range,\n  },\n  have h3 : \u2200 x : \u2124, x \u2260 0 \u2192 int.fract (\u03b1 * \u2191x) \u2260 0, from by {\n    assume x h,\n    assume h2 : int.fract (\u03b1 * \u2191x) = 0,\n    have h3 : (\u03b1 * \u2191x) - (int.floor (\u03b1 * \u2191x)) = 0,\n    from by {rw h2, ring},\n    have h4 : (\u03b1 * \u2191x) - (int.floor (\u03b1 * \u2191x)) = 0,\n    from by {rw h3, ring},\n    have h5 : \u03b1 = (int.floor (\u03b1 * \u2191x)) / x,\n    from by {rw h4, ring},\n    have h6 : (int.floor (\u03b1 * \u2191x)) / x \u2208 \u211a,\n    from by {apply int.cast_div,},\n    have h7 : \u03b1 \u2208 \u211a, from by {rw h5, exact h6,},\n    have h8 : irrational \u03b1, from h\u03b1_irrat,\n    contradiction,\n  },\n  have h4 : \u2200 x : \u2124, x \u2260 0 \u2192 int.fract (\u03b1 * \u2191x) \u2260 1, from by {\n    assume x h,\n    assume h2 : int.fract (\u03b1 * \u2191x) = 1,\n    have h3 : (\u03b1 * \u2191x) - (int.floor (\u03b1 * \u2191x)) = 1,\n    from by {rw h2, ring},\n    have h4 : (\u03b1 * \u2191x) - (int.floor (\u03b1 * \u2191x)) = 1,\n    from by {rw h3, ring},\n    have h5 : \u03b1 = (int.floor (\u03b1 * \u2191x) + 1) / x,\n    from by {rw h4, ring},\n    have h6 : (int.floor (\u03b1 * \u2191x) + 1) / x \u2208 \u211a,\n    from by {apply int.cast_div,},\n    have h7 : \u03b1 \u2208 \u211a, from by {rw h5, exact h6,},\n    have h8 : irrational \u03b1, from h\u03b1_irrat,\n    contradiction,\n  },\n  have h5 : \u2200 x : \u2124, x \u2260 0 \u2192 int.fract (\u03b1 * \u2191x) \u2208 set.Icc 0 1, from by {\n    assume x h,\n    have h2 : int.fract (\u03b1 * \u2191x) \u2260 0, from h3 x h,\n    have h3 : int.fract (\u03b1 * \u2191x) \u2260 1, from h4 x h,\n    rw set.mem_Icc,\n    split,\n    exact h2,\n    exact h3,\n  },\n  have h6 : \u2200 x : \u2124, x \u2260 0 \u2192 int.fract (\u03b1 * \u2191x) \u2208 set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)), from by {\n    assume x h,\n    use x,\n    simp [h],\n  },\n  have h7 : \u2200 x : \u2124, x \u2260 0 \u2192 int.fract (\u03b1 * \u2191x) \u2208 (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))) \u2229 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 : \u2200 x : \u2124, x \u2260 0 \u2192 int.fract (\u03b1 * \u2191x) \u2208 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), from by {\n    assume x h,\n    have h2 : int.fract (\u03b1 * \u2191x) \u2208 (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))) \u2229 set.Icc 0 1, from h7 x h,\n    have h3 : (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))) \u2229 set.Icc 0 1 \u2286 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), from by {\n      assume x h,\n      have h2 : x \u2208 (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))) \u2229 set.Icc 0 1, from h,\n      have h3 : x \u2208 set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)), from h2.left,\n      have h4 : x \u2208 set.Icc 0 1, from h2.right,\n      rw set.mem_closure,\n      use (set.range (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m))),\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 : \u2200 x : \u2124, x \u2260 0 \u2192 int.fract (\u03b1 * \u2191x) \u2208 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), from h8,\n  have h10 : \u2200 x : \u2124, x \u2260 0 \u2192 int.fract (\u03b1 * \u2191x) \u2208 set.Icc 0 1, from by {\n    assume x h,\n    have h2 : int.fract (\u03b1 * \u2191x) \u2208 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), from h9 x h,\n    have h3 : closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) \u2286 set.Icc 0 1, from by {\n      assume x h,\n      have h2 : x \u2208 closure ((\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)), from h,\n      rw set.mem_Icc,\n      rw set.mem_closure at h2,\n      cases h2 with (h2_1 : x \u2208 (\u03bb (m : \u2124), int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) (h2_2 : \u2200 \u03b5 > 0, \u2203 (y : \u2124), y\nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 i j : \u2124, i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u2260 (int.fract (\u03b1 * \u2191j)), from by {\n    assume (i j : \u2124) (h : i \u2260 j),\n    have h1 : (int.fract (\u03b1 * \u2191i)) = (int.fract (\u03b1 * \u2191j)) \u2192 \u03b1 = (i - j)\u207b\u00b9 * (int.nat_abs (\u03b1 * \u2191i) - int.nat_abs (\u03b1 * \u2191j)) \u2208 \u211a, from by {\n      assume h2 : (int.fract (\u03b1 * \u2191i)) = (int.fract (\u03b1 * \u2191j)),\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 : \u03b1 = (i - j)\u207b\u00b9 * (int.nat_abs (\u03b1 * \u2191i) - int.nat_abs (\u03b1 * \u2191j)), 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from by {\n    assume (i j : \u2124) (hne : i \u2260 j),\n    have h2 : \u03b1 \u2209 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n      assume h3 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)),\n      cases h3 with i0 h4,\n      have h5 : \u03b1 = \u2191i0 / \u2191(i0 - j), from by {rw \u2190 h4, refl},\n      have h6 : \u2191i0 / \u2191(i0 - j) \u2208 \u211a, from by {\n        have h7 : \u2191i0 / \u2191(i0 - j) = \u2191i0 / \u2191(i0 - j), from by refl,\n        have h8 : \u2191i0 / \u2191(i0 - j) \u2208 \u211d, from by {rw h7, apply_instance},\n        have h9 : \u2191i0 / \u2191(i0 - j) \u2208 \u211a, from by {rw h7, apply_instance},\n        exact h9,\n      },\n      have h10 : \u2191i0 / \u2191(i0 - j) = \u2191i / \u2191(i - j), from by rw h5,\n      have h11 : \u2191i0 / \u2191(i0 - j) = \u03b1, from by {rw h10, refl},\n      have h12 : \u03b1 \u2208 \u211a, from by {rw h11, exact h6},\n      have h13 : \u03b1 \u2209 \u211a, from by {exact h\u03b1_irrat},\n      contradiction,\n    },\n    have h3 : \u2200 (i : \u2124), i \u2260 j \u2192 \u03b1 \u2260 \u2191i / \u2191(i - j), from by {\n      assume (i : \u2124) (hne : i \u2260 j),\n      have h4 : \u2191i / \u2191(i - j) \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h5 : \u00ac(\u2191i / \u2191(i - j) = \u03b1), from by {\n        assume h6 : \u2191i / \u2191(i - j) = \u03b1,\n        have h7 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {rw \u2190 h6, exact h4},\n        contradiction,\n      },\n      exact h5,\n    },\n    have h4 : \u2200 (i : \u2124), i \u2260 j \u2192 \u03b1 \u2260 \u2191i / \u2191(i - j), from by {\n      assume (i : \u2124) (hne : i \u2260 j),\n      have h5 : \u2191i / \u2191(i - j) \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h6 : \u00ac(\u2191i / \u2191(i - j) = \u03b1), from by {\n        assume h7 : \u2191i / \u2191(i - j) = \u03b1,\n        have h8 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {rw \u2190 h7, exact h5},\n        contradiction,\n      },\n      exact h6,\n    },\n    have h5 : i \u2260 j \u2192 \u03b1 \u2260 \u2191i / \u2191(i - j), from by {\n      assume hne : i \u2260 j,\n      have h6 : \u2191i / \u2191(i - j) \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h7 : \u00ac(\u2191i / \u2191(i - j) = \u03b1), from by {\n        assume h8 : \u2191i / \u2191(i - j) = \u03b1,\n        have h9 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {rw \u2190 h8, exact h6},\n        contradiction,\n      },\n      exact h7,\n    },\n    have h6 : i \u2260 j \u2192 \u03b1 \u2260 \u2191i / \u2191(i - j), from by {\n      assume hne : i \u2260 j,\n      have h7 : \u2191i / \u2191(i - j) \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h8 : \u00ac(\u2191i / \u2191(i - j) = \u03b1), from by {\n        assume h9 : \u2191i / \u2191(i - j) = \u03b1,\n        have h10 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {rw \u2190 h9, exact h7},\n        contradiction,\n      },\n      exact h8,\n    },\n    have h7 : i \u2260 j \u2192 \u03b1 \u2260 \u2191i / \u2191(i - j), from by {\n      assume hne : i \u2260 j,\n      have h8 : \u2191i / \u2191(i - j) \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h9 : \u00ac(\u2191i / \u2191(i - j) = \u03b1), from by {\n        assume h10 : \u2191i / \u2191(i - j) = \u03b1,\n        have h11 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {rw \u2190 h10, exact h8},\n        contradiction,\n      },\n      exact h9,\n    },\n    have h8 : i \u2260 j \u2192 \u03b1 \u2260 \u2191i / \u2191(i - j), from by {\n      assume hne : i \u2260 j,\n      have h9 : \u2191i / \u2191(i - j) \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h10 : \u00ac(\u2191i / \u2191(i - j) = \u03b1), from by {\n        assume h11 : \u2191i / \u2191(i - j) = \u03b1,\n        have h12 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {rw \u2190 h11, exact h9},\n        contradiction,\n      },\n      exact h10,\n    },\n    have h9 : i \u2260 j \u2192 \u03b1 \u2260 \u2191i / \u2191(i - j), from by {\n      assume hne : i \u2260 j,\n      have h10 : \u2191i / \u2191(i - j) \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h11 : \u00ac(\u2191i / \u2191(i - j) = \u03b1), from by {\n        assume h12 : \u2191i / \u2191(i - j) = \u03b1,\n        have h13 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {rw \u2190 h12, exact h10},\n        contradiction,\n      },\n      exact h11,\n    },\n    have h10 : i \u2260 j \u2192 \u03b1 \u2260 \u2191i / \u2191(i - j), from by {\n      assume hne : i \u2260 j,\n      have h11 : \u2191i / \u2191(i - j) \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {\n        use i,\n        refl,\n      },\n      have h12 : \u00ac(\u2191i / \u2191(i - j) = \u03b1), from by {\n        assume h13 : \u2191i / \u2191(i - j) = \u03b1,\n        have h14 : \u03b1 \u2208 set.range (\u03bb (i : \u2124), \u2191i / \u2191(i - j)), from by {rw \u2190 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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from begin\n    assume (i j : \u2124) (hij : i \u2260 j),\n    have h2 : (\u03b1 * \u2191i) - (int.floor (\u03b1 * \u2191i)) = int.fract (\u03b1 * \u2191i), from by {rw int.fract_def, ring},\n    have h3 : (\u03b1 * \u2191j) - (int.floor (\u03b1 * \u2191j)) = int.fract (\u03b1 * \u2191j), from by {rw int.fract_def, ring},\n    have h4 : (\u03b1 * \u2191i) - (int.floor (\u03b1 * \u2191i)) = (\u03b1 * \u2191j) - (int.floor (\u03b1 * \u2191j)), from by {rw [h2, h3]},\n    have h5 : \u03b1 = (int.floor (\u03b1 * \u2191i) - int.floor (\u03b1 * \u2191j)) / (i - j), from by {rw [h4, div_sub_div_same, div_self hij], ring},\n    have h6 : \u03b1 \u2208 \u211a, from by {apply q_of_rat, exact h5},\n    have h7 : irrational \u03b1, from h\u03b1_irrat,\n    have h8 : \u00ac (\u03b1 \u2208 \u211a), from h7,\n    have h9 : \u00ac (\u03b1 \u2208 \u211a), from h8,\n    exact absurd h6 h9,\n  end,\n\n  have h2 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) \u2260 int.fract (\u03b1 * \u2191j), from h1,\n\n  have h3 : \u2200 (i j : \u2124), i \u2260 j \u2192 int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) \u2260 0, from begin\n    assume (i j : \u2124) (hij : i \u2260 j),\n    have h4 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * \u2191i) + - int.fract (\u03b1 * \u2191j), from by ring,\n    have h5 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * \u2191i) + - (int.fract (\u03b1 * \u2191j)), from by {rw h4},\n    have h6 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * \u2191i) + int.fract (-(\u03b1 * \u2191j)), from by {rw \u2190 int.fract_neg, rw h5},\n    have h7 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * \u2191i - (\u03b1 * \u2191j)), from by {rw h6},\n    have h8 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (\u2191i - \u2191j)), from by {rw h7},\n    have h9 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h8},\n    have h10 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h9},\n    have h11 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract ((\u03b1 * i) - (\u03b1 * j)), from by {rw h10},\n    have h12 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract ((\u03b1 * i) - (\u03b1 * j)), from by {rw h11},\n    have h13 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * i - \u03b1 * j), from by {rw h12},\n    have h14 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * i - \u03b1 * j), from by {rw h13},\n    have h15 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h14},\n    have h16 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h15},\n    have h17 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h16},\n    have h18 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h17},\n    have h19 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h18},\n    have h20 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h19},\n    have h21 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h20},\n    have h22 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h21},\n    have h23 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h22},\n    have h24 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h23},\n    have h25 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h24},\n    have h26 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h25},\n    have h27 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h26},\n    have h28 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h27},\n    have h29 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h28},\n    have h30 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h29},\n    have h31 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h30},\n    have h32 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h31},\n    have h33 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h32},\n    have h34 : int.fract (\u03b1 * \u2191i) - int.fract (\u03b1 * \u2191j) = int.fract (\u03b1 * (i - j)), from by {rw h33},\n    have h35 : int.\nend --Needs more than 2000 tokens!\n\n--OUTPUT 6\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=\nbegin\n  have h1 : \u2200 i j : \u2124, i \u2260 j \u2192 (int.fract (\u03b1 * \u2191i)) \u2260 (int.fract (\u03b1 * \u2191j)), from by {\n    assume i j hne,\n    have h2 : (\u03b1 * \u2191i) - \u2191(int.floor (\u03b1 * \u2191i)) = (int.fract (\u03b1 * \u2191i)), from by {rw int.fract_eq_sub_floor},\n    have h3 : (\u03b1 * \u2191j) - \u2191(int.floor (\u03b1 * \u2191j)) = (int.fract (\u03b1 * \u2191j)), from by {rw int.fract_eq_sub_floor},\n    have h4 : (int.fract (\u03b1 * \u2191i)) = (int.fract (\u03b1 * \u2191j)), from by {rw h2, rw h3, linarith},\n    have h5 : (\u03b1 * \u2191i) - \u2191(int.floor (\u03b1 * \u2191i)) = (\u03b1 * \u2191j) - \u2191(int.floor (\u03b1 * \u2191j)), from by {rw h4},\n    have h6 : (\u03b1 * \u2191i) - (\u03b1 * \u2191j) = \u2191(int.floor (\u03b1 * \u2191i)) - \u2191(int.floor (\u03b1 * \u2191j)), from by {linarith},\n    have h7 : \u03b1 = (\u2191(int.floor (\u03b1 * \u2191i)) - \u2191(int.floor (\u03b1 * \u2191j))) / \u2191(i - j), from by {rw h6, rw mul_comm \u03b1 i, rw mul_comm \u03b1 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! y : G, y * a = a, from\n    assume a : G, h2 a a,\n\n  have h5 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from by \n  {\n    intro x0,\n    have h6 : |x0 - l| < \u03b5 \u2194 ((x0 - l) < \u03b5) \u2227 ((l - x0) < \u03b5), \n    from abs_sub_lt_iff, rw h6,\n    split, \n    rintro \u27e8 S_1, S_2 \u27e9, \n    split; linarith, \n    rintro \u27e8 S_3, S_4 \u27e9, \n    split; linarith,\n    },\n  \n  assume (h7 : \u03b5 > 0),\n  cases h2 \u03b5 h7 with N1 h8,\n  cases h3 \u03b5 h7 with N2 h9,\n\n  let N := max N1 N2,\n  use N,\n\n  have h10 : \u2200 n > N, n > N1 \u2227 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 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \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 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \n  from by {\n    intros n1 h16, cases (h11 n1 h16);\n    split; linarith,\n  },\n\n  show  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = 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 \u2964 D` for the type of all functors from `C` to `D`.\n    (I would like a better arrow here, unfortunately \u21d2 (`\\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\u2081 v\u2082 u\u2081 u\u2082 l u\u2083 v\u2083 \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\u2081) [category C] (D : Type u\u2082) [category D] \nwhere\n  obj : C \u2192 D\n  map : {X Y : C} \u2192 (X \u27f6 Y) \u2192 (obj X \u27f6 obj Y)\n  map_id' : autoParam (C \u2192 map \ud835\udfd9 = \ud835\udfd9)\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 (\u2200 {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z), map (f \u226b g) = map f \u226b 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 \" \u2964 \" => Mathlib.category_theory.functor\n\n-- A functor is basically a function, so give \u2964 a similar precedence to \u2192 (25).\n\n-- For example, `C \u00d7 D \u2964 E` should parse as `(C \u00d7 D) \u2964 E` not `C \u00d7 (D \u2964 E)`.\n\n@[simp] theorem functor.map_id {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (c : C \u2964 D) (X : C) : functor.map c \ud835\udfd9 = \ud835\udfd9 := sorry\n\n@[simp] theorem functor.map_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (c : C \u2964 D) {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) : functor.map c (f \u226b g) = functor.map c f \u226b functor.map c g := sorry\n\ntheorem functor.map_comp_assoc {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (c : C \u2964 D) {X : C} {Y : C} {Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) {X' : D} (f' : functor.obj c Z \u27f6 X') : functor.map c (f \u226b g) \u226b f' = functor.map c f \u226b functor.map c g \u226b f' := sorry\n\nnamespace functor\n\n\n/-- `\ud835\udfed C` is the identity functor on a category `C`. -/\nprotected def id (C : Type u\u2081) [category C] : C \u2964 C :=\n  mk (fun (X : C) => X) fun (_x _x_1 : C) (f : _x \u27f6 _x_1) => f\n\nnotation:1024 \"\ud835\udfed\" => Mathlib.category_theory.functor.id\n\nprotected instance inhabited (C : Type u\u2081) [category C] : Inhabited (C \u2964 C) :=\n  { default := \ud835\udfed }\n\n@[simp] theorem id_obj {C : Type u\u2081} [category C] (X : C) : obj \ud835\udfed X = X :=\n  rfl\n\n@[simp] theorem id_map {C : Type u\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 Y) : map \ud835\udfed f = f :=\n  rfl\n\n/--\n`F \u22d9 G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\ndef comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) (G : D \u2964 E) : C \u2964 E :=\n  mk (fun (X : C) => obj G (obj F X)) fun (_x _x_1 : C) (f : _x \u27f6 _x_1) => map G (map F f)\n\ninfixr:80 \" \u22d9 \" => Mathlib.category_theory.functor.comp\n\n@[simp] theorem comp_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) (G : D \u2964 E) (X : C) : obj (F \u22d9 G) X = obj G (obj F X) :=\n  rfl\n\n@[simp] theorem comp_map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) (G : D \u2964 E) {X : C} {Y : C} (f : X \u27f6 Y) : map (F \u22d9 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\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) : F \u22d9 \ud835\udfed = F := sorry\n\nprotected theorem id_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) : \ud835\udfed \u22d9 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 : \u2115) : \u2203 m : \u2115, n < m := \u27e8n + 1, by fconstructor\u27e9\n\nnoncomputable def nat_greater_res : \u2115 \u2192 \u2115 := nat_greater\nlemma nat_greater_spec_res : \u2200 (n : \u2115), n < nat_greater n := nat_greater_spec\n\n@[expand_exists dependent_type dependent_type_val dependent_type_spec]\nlemma dependent_type_exists {\u03b1 : Type*} (a : \u03b1) : \u2203 {\u03b2 : Type} (b : \u03b2), (a, b) = (a, b) :=\n\u27e8unit, (), rfl\u27e9\n\ndef dependent_type_res {\u03b1 : Type*} (a : \u03b1) : Type := dependent_type a\nnoncomputable def dependent_type_val_res {\u03b1 : Type*} (a : \u03b1) : dependent_type a :=\ndependent_type_val a\nlemma dependent_type_spec_res\n{\u03b1 : Type*} (a : \u03b1) : (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\u2082 (n : \u2115) : \u2203 m : \u2115, n < m \u2227 m \u2260 0 := begin\n  use n + 1,\n  split,\n  fconstructor,\n  finish,\nend\n\nnoncomputable def nat_greater_nosplit_res : \u2115 \u2192 \u2115 := nat_greater_nosplit\nnoncomputable def nat_greater_split_res : \u2115 \u2192 \u2115 := nat_greater_split\n\nlemma nat_greater_nosplit_spec_res :\n\u2200 (n : \u2115), n < nat_greater_nosplit n \u2227 nat_greater_nosplit n \u2260 0 := nat_greater_nosplit_spec\n\nlemma nat_greater_split_spec_lt_res : \u2200 (n : \u2115), n < nat_greater_nosplit n := nat_greater_split_lt\nlemma nat_greater_split_spec_neq_res : \u2200 (n : \u2115), nat_greater_nosplit n \u2260 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 {\u03b1 : Type} [semiring \u03b1] {\u03b2 : Type} (e : \u03b1 \u2243 \u03b2) : semiring \u03b2 :=\nby transport using e\n\n-- Indeed, it can equally well move a `semilattice_sup_top`.\ndef sup_top.map {\u03b1 : Type} [semilattice_sup_top \u03b1] {\u03b2 : Type} (e : \u03b1 \u2243 \u03b2) : semilattice_sup_top \u03b2 :=\nby transport using e\n\n-- Verify definitional equality of the new structure data.\nexample {\u03b1 : Type} [semilattice_sup_top \u03b1] {\u03b2 : Type} (e : \u03b1 \u2243 \u03b2) (x y : \u03b2) :\nbegin\n  haveI := sup_top.map e,\n  exact (x \u2264 y) = (e.symm x \u2264 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 \u2192 mynat\n\ndef mynat_equiv : \u2115 \u2243 mynat :=\n{ to_fun := \u03bb n, nat.rec_on n mynat.zero (\u03bb n, mynat.succ),\n  inv_fun := \u03bb n, mynat.rec_on n nat.zero (\u03bb n, nat.succ),\n  left_inv := \u03bb n, begin induction n, refl, exact congr_arg nat.succ n_ih, end,\n  right_inv := \u03bb 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 : \u2115) :\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 : \u2115) \u2022 (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 \u03b1 := \u03b1` for any type `\u03b1`, 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 \u27f6 Y` in `discrete \u03b1` as `X = Y`,\none might define it as `plift (X = Y)`.\nIn fact, to allow `discrete \u03b1` to be a `small_category`\n(i.e. with morphisms in the same universe as the objects),\nwe actually define the hom type `X \u27f6 Y` as `ulift (plift (X = Y))`.\n\n`discrete.functor` promotes a function `f : I \u2192 C` (for any category `C`) to a functor\n`discrete.functor f : discrete I \u2964 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\u2081 v\u2082 u\u2081 u\u2082 -- 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 (\u03b1 : Type u\u2081) := \u03b1\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 \u27f6 Y` as `ulift (plift (X = Y))`.\n\nSee https://stacks.math.columbia.edu/tag/001A\n-/\ninstance discrete_category (\u03b1 : Type u\u2081) : small_category (discrete \u03b1) :=\n{ hom  := \u03bb X Y, ulift (plift (X = Y)),\n  id   := \u03bb X, ulift.up (plift.up rfl),\n  comp := \u03bb X Y Z g f, by { rcases f with \u27e8\u27e8rfl\u27e9\u27e9, exact g } }\n\nnamespace discrete\n\nvariables {\u03b1 : Type u\u2081}\n\ninstance [inhabited \u03b1] : inhabited (discrete \u03b1) :=\nby { dsimp [discrete], apply_instance }\n\ninstance [subsingleton \u03b1] : subsingleton (discrete \u03b1) :=\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 \u03b1) : ulift.up (plift.up (eq.refl X)) = \ud835\udfd9 X := rfl\n\nvariables {C : Type u\u2082} [category.{v\u2082} C]\n\ninstance {I : Type u\u2081} {i j : discrete I} (f : i \u27f6 j) : is_iso f :=\n\u27e8\u27e8eq_to_hom (eq_of_hom f).symm, by tidy\u27e9\u27e9\n\n/--\nAny function `I \u2192 C` gives a functor `discrete I \u2964 C`.\n-/\ndef functor {I : Type u\u2081} (F : I \u2192 C) : discrete I \u2964 C :=\n{ obj := F,\n  map := \u03bb X Y f, begin cases f, cases f, cases f, exact \ud835\udfd9 (F X) end }\n\n@[simp] lemma functor_obj  {I : Type u\u2081} (F : I \u2192 C) (i : I) :\n  (discrete.functor F).obj i = F i := rfl\n\nlemma functor_map  {I : Type u\u2081} (F : I \u2192 C) {i : discrete I} (f : i \u27f6 i) :\n  (discrete.functor F).map f = \ud835\udfd9 (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\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u27f6 G.obj i) : F \u27f6 G :=\n{ app := f }\n\n@[simp] lemma nat_trans_app  {I : Type u\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u27f6 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\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u2245 G.obj i) : F \u2245 G :=\nnat_iso.of_components f (by tidy)\n\n@[simp]\nlemma nat_iso_hom_app {I : Type u\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u2245 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\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u2245 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\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u2245 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\u2081} {F : discrete I \u2964 C} : F \u2245 discrete.functor (F.obj) :=\nnat_iso $ \u03bb 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\u2081} {J : Type u\u2082} (e : I \u2243 J) : discrete I \u224c discrete J :=\n{ functor := discrete.functor (e : I \u2192 J),\n  inverse := discrete.functor (e.symm : J \u2192 I),\n  unit_iso := discrete.nat_iso (\u03bb i, eq_to_iso (by simp)),\n  counit_iso := discrete.nat_iso (\u03bb 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 {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (h : discrete \u03b1 \u224c discrete \u03b2) : \u03b1 \u2243 \u03b2 :=\n{ to_fun := h.functor.obj,\n  inv_fun := h.inverse.obj,\n  left_inv := \u03bb a, eq_of_hom (h.unit_iso.app a).2,\n  right_inv := \u03bb a, eq_of_hom (h.counit_iso.app a).1 }\n\nend discrete\n\nnamespace discrete\nvariables {J : Type v\u2081}\n\nopen opposite\n\n/-- A discrete category is equivalent to its opposite category. -/\nprotected def opposite (\u03b1 : Type u\u2081) : (discrete \u03b1)\u1d52\u1d56 \u224c discrete \u03b1 :=\nlet F : discrete \u03b1 \u2964 (discrete \u03b1)\u1d52\u1d56 := discrete.functor (\u03bb x, op x) in\nbegin\n  refine equivalence.mk (functor.left_op F) F _ (discrete.nat_iso $ \u03bb X, by simp [F]),\n  refine nat_iso.of_components (\u03bb X, by simp [F]) _,\n  tidy\nend\n\nvariables {C : Type u\u2082} [category.{v\u2082} C]\n\n@[simp] lemma functor_map_id\n  (F : discrete J \u2964 C) {j : discrete J} (f : j \u27f6 j) : F.map f = \ud835\udfd9 (F.obj j) :=\nbegin\n  have h : f = \ud835\udfd9 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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\u2093'. -/\n-- depending on cardinalities, an injective function may not exist\n/-- `\u03b1 \u21aa \u03b2` is a bundled injective function. -/\n@[nolint has_nonempty_instance]\nstructure Embedding (\u03b1 : Sort _) (\u03b2 : Sort _) where\n  toFun : \u03b1 \u2192 \u03b2\n  inj' : Injective to_fun\n#align function.embedding Function.Embedding\n\n-- mathport name: \u00abexpr \u21aa \u00bb\ninfixr:25 \" \u21aa \" => Embedding\n\ninstance {\u03b1 : Sort u} {\u03b2 : Sort v} : CoeFun (\u03b1 \u21aa \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\n  \u27e8Embedding.toFun\u27e9\n\ninitialize_simps_projections Embedding (toFun \u2192 apply)\n\ninstance {\u03b1 : Sort u} {\u03b2 : Sort v} : EmbeddingLike (\u03b1 \u21aa \u03b2) \u03b1 \u03b2\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 {\u03b1 \u03b2 : Sort _} : CanLift (\u03b1 \u2192 \u03b2) (\u03b1 \u21aa \u03b2) coeFn Injective where prf f hf := \u27e8\u27e8f, hf\u27e9, rfl\u27e9\n\nend Function\n\nsection Equiv\n\nvariable {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2243 \u03b2)\n\n#print Equiv.toEmbedding /-\n/-- Convert an `\u03b1 \u2243 \u03b2` to `\u03b1 \u21aa \u03b2`.\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 \u2243 fin 3` but is expected to have type `fin 3 \u21aa ?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 : \u03b1 \u21aa \u03b2 :=\n  \u27e8f, f.Injective\u27e9\n#align equiv.to_embedding Equiv.toEmbedding\n-/\n\n#print Equiv.coe_toEmbedding /-\n@[simp]\ntheorem Equiv.coe_toEmbedding : \u21d1f.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 : \u03b1) : 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}}, Coe.{max 1 (imax u1 u2) (imax u2 u1), max 1 (imax u1 u2)} (Equiv.{u1, u2} \u03b1 \u03b2) (Function.Embedding.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}}, Coe.{max (max 1 u2) u1, max (max 1 u2) u1} (Equiv.{u1, u2} \u03b1 \u03b2) (Function.Embedding.{u1, u2} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align equiv.coe_embedding Equiv.coeEmbedding\u2093'. -/\ninstance Equiv.coeEmbedding : Coe (\u03b1 \u2243 \u03b2) (\u03b1 \u21aa \u03b2) :=\n  \u27e8Equiv.toEmbedding\u27e9\n#align equiv.coe_embedding Equiv.coeEmbedding\n\n#print Equiv.Perm.coeEmbedding /-\n@[reducible]\ninstance Equiv.Perm.coeEmbedding : Coe (Equiv.Perm \u03b1) (\u03b1 \u21aa \u03b1) :=\n  Equiv.coeEmbedding\n#align equiv.perm.coe_embedding Equiv.Perm.coeEmbedding\n-/\n\n@[simp]\ntheorem Equiv.coe_eq_toEmbedding : \u2191f = 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : \u03b2 -> Prop}, (Equiv.{u1, max 1 u2} \u03b1 (Subtype.{u2} \u03b2 p)) -> (Function.Embedding.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {p : \u03b1 -> Prop}, (Equiv.{u2, max 1 u1} \u03b2 (Subtype.{u1} \u03b1 p)) -> (Function.Embedding.{u2, u1} \u03b2 \u03b1)\nCase conversion may be inaccurate. Consider using '#align equiv.as_embedding Equiv.asEmbedding\u2093'. -/\n/-- Given an equivalence to a subtype, produce an embedding to the elements of the corresponding\nset. -/\n@[simps]\ndef Equiv.asEmbedding {p : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 Subtype p) : \u03b1 \u21aa \u03b2 :=\n  \u27e8coe \u2218 e, Subtype.coe_injective.comp e.Injective\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}}, Function.Injective.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (\u03b1 -> \u03b2) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (\u1fb0 : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}}, Function.Injective.{max (max 1 u1) u2, imax u2 u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) (\u03b1 -> \u03b2) (fun (f : Function.Embedding.{u2, u1} \u03b1 \u03b2) => FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) a) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_injective Function.Embedding.coe_injective\u2093'. -/\ntheorem coe_injective {\u03b1 \u03b2} : @Function.Injective (\u03b1 \u21aa \u03b2) (\u03b1 \u2192 \u03b2) 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {f : Function.Embedding.{u1, u2} \u03b1 \u03b2} {g : Function.Embedding.{u1, u2} \u03b1 \u03b2}, (forall (x : \u03b1), Eq.{u2} \u03b2 (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) f x) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) g x)) -> (Eq.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} \u03b1 \u03b2) f g)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {f : Function.Embedding.{u2, u1} \u03b1 \u03b2} {g : Function.Embedding.{u2, u1} \u03b1 \u03b2}, (forall (x : \u03b1), Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) f x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) g x)) -> (Eq.{max (max 1 u1) u2} (Function.Embedding.{u2, u1} \u03b1 \u03b2) f g)\nCase conversion may be inaccurate. Consider using '#align function.embedding.ext Function.Embedding.ext\u2093'. -/\n@[ext]\ntheorem ext {\u03b1 \u03b2} {f g : Embedding \u03b1 \u03b2} (h : \u2200 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {f : Function.Embedding.{u1, u2} \u03b1 \u03b2} {g : Function.Embedding.{u1, u2} \u03b1 \u03b2}, Iff (forall (x : \u03b1), Eq.{u2} \u03b2 (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) f x) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) g x)) (Eq.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} \u03b1 \u03b2) f g)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {f : Function.Embedding.{u2, u1} \u03b1 \u03b2} {g : Function.Embedding.{u2, u1} \u03b1 \u03b2}, Iff (forall (x : \u03b1), Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) f x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) g x)) (Eq.{max (max 1 u1) u2} (Function.Embedding.{u2, u1} \u03b1 \u03b2) f g)\nCase conversion may be inaccurate. Consider using '#align function.embedding.ext_iff Function.Embedding.ext_iff\u2093'. -/\ntheorem ext_iff {\u03b1 \u03b2} {f g : Embedding \u03b1 \u03b2} : (\u2200 x, f x = g x) \u2194 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (f : Function.Embedding.{u1, u2} \u03b1 \u03b2), Eq.{imax u1 u2} (\u03b1 -> \u03b2) (Function.Embedding.toFun.{u1, u2} \u03b1 \u03b2 f) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (f : Function.Embedding.{u2, u1} \u03b1 \u03b2), Eq.{imax u2 u1} (\u03b1 -> \u03b2) (Function.Embedding.toFun.{u2, u1} \u03b1 \u03b2 f) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align function.embedding.to_fun_eq_coe Function.Embedding.toFun_eq_coe\u2093'. -/\n@[simp]\ntheorem toFun_eq_coe {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) : 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (f : \u03b1 -> \u03b2) (i : Function.Injective.{u1, u2} \u03b1 \u03b2 f), Eq.{imax u1 u2} ((fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.mk.{u1, u2} \u03b1 \u03b2 f i)) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) (Function.Embedding.mk.{u1, u2} \u03b1 \u03b2 f i)) f\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (f : \u03b1 -> \u03b2) (i : Function.Injective.{u2, u1} \u03b1 \u03b2 f), Eq.{imax u2 u1} (forall (a : \u03b1), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) a) (FunLike.coe.{max (max 1 u2) u1, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u2) u1, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) (Function.Embedding.mk.{u2, u1} \u03b1 \u03b2 f i)) f\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_fn_mk Function.Embedding.coeFn_mk\u2093'. -/\n@[simp]\ntheorem coeFn_mk {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (i) : (@mk _ _ f i : \u03b1 \u2192 \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (inj : Function.Injective.{succ u1, succ u2} \u03b1 \u03b2 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f)), Eq.{max 1 (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (Function.Embedding.mk.{succ u1, succ u2} \u03b1 \u03b2 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f) inj) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) (inj : Function.Injective.{succ u2, succ u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f)), Eq.{max (succ u2) (succ u1)} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) (Function.Embedding.mk.{succ u2, succ u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f) inj) f\nCase conversion may be inaccurate. Consider using '#align function.embedding.mk_coe Function.Embedding.mk_coe\u2093'. -/\n@[simp]\ntheorem mk_coe {\u03b1 \u03b2 : Type _} (f : \u03b1 \u21aa \u03b2) (inj) : (\u27e8f, inj\u27e9 : \u03b1 \u21aa \u03b2) = 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (f : Function.Embedding.{u1, u2} \u03b1 \u03b2), Function.Injective.{u1, u2} \u03b1 \u03b2 (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) f)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (f : Function.Embedding.{u2, u1} \u03b1 \u03b2), Function.Injective.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) f)\nCase conversion may be inaccurate. Consider using '#align function.embedding.injective Function.Embedding.injective\u2093'. -/\nprotected theorem injective {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) : 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (f : Function.Embedding.{u1, u2} \u03b1 \u03b2) (x : \u03b1) (y : \u03b1), Iff (Eq.{u2} \u03b2 (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) f x) (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) f y)) (Eq.{u1} \u03b1 x y)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (f : Function.Embedding.{u2, u1} \u03b1 \u03b2) (x : \u03b1) (y : \u03b1), Iff (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) f x) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) f y)) (Eq.{u2} \u03b1 x y)\nCase conversion may be inaccurate. Consider using '#align function.embedding.apply_eq_iff_eq Function.Embedding.apply_eq_iff_eq\u2093'. -/\ntheorem apply_eq_iff_eq {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) (x y : \u03b1) : f x = f y \u2194 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 (\u03b1 : Sort _) : \u03b1 \u21aa \u03b1 :=\n  \u27e8id, injective_id\u27e9\n#align function.embedding.refl Function.Embedding.refl\n-/\n\n#print Function.Embedding.trans /-\n/-- Composition of `f : \u03b1 \u21aa \u03b2` and `g : \u03b2 \u21aa \u03b3`. -/\n@[trans, simps (config := { simpRhs := true })]\nprotected def trans {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u21aa \u03b2) (g : \u03b2 \u21aa \u03b3) : \u03b1 \u21aa \u03b3 :=\n  \u27e8g \u2218 f, g.Injective.comp f.Injective\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (e : Equiv.{u1, u2} \u03b1 \u03b2), Eq.{max 1 u1} (Function.Embedding.{u1, u1} \u03b1 \u03b1) (Function.Embedding.trans.{u1, u2, u1} \u03b1 \u03b2 \u03b1 (Equiv.toEmbedding.{u1, u2} \u03b1 \u03b2 e) (Equiv.toEmbedding.{u2, u1} \u03b2 \u03b1 (Equiv.symm.{u1, u2} \u03b1 \u03b2 e))) (Function.Embedding.refl.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (e : Equiv.{u2, u1} \u03b1 \u03b2), Eq.{max 1 u2} (Function.Embedding.{u2, u2} \u03b1 \u03b1) (Function.Embedding.trans.{u2, u1, u2} \u03b1 \u03b2 \u03b1 (Equiv.toEmbedding.{u2, u1} \u03b1 \u03b2 e) (Equiv.toEmbedding.{u1, u2} \u03b2 \u03b1 (Equiv.symm.{u2, u1} \u03b1 \u03b2 e))) (Function.Embedding.refl.{u2} \u03b1)\nCase conversion may be inaccurate. Consider using '#align function.embedding.equiv_to_embedding_trans_symm_to_embedding Function.Embedding.equiv_toEmbedding_trans_symm_toEmbedding\u2093'. -/\n@[simp]\ntheorem equiv_toEmbedding_trans_symm_toEmbedding {\u03b1 \u03b2 : Sort _} (e : \u03b1 \u2243 \u03b2) :\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (e : Equiv.{u1, u2} \u03b1 \u03b2), Eq.{max 1 u2} (Function.Embedding.{u2, u2} \u03b2 \u03b2) (Function.Embedding.trans.{u2, u1, u2} \u03b2 \u03b1 \u03b2 (Equiv.toEmbedding.{u2, u1} \u03b2 \u03b1 (Equiv.symm.{u1, u2} \u03b1 \u03b2 e)) (Equiv.toEmbedding.{u1, u2} \u03b1 \u03b2 e)) (Function.Embedding.refl.{u2} \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (e : Equiv.{u2, u1} \u03b1 \u03b2), Eq.{max 1 u1} (Function.Embedding.{u1, u1} \u03b2 \u03b2) (Function.Embedding.trans.{u1, u2, u1} \u03b2 \u03b1 \u03b2 (Equiv.toEmbedding.{u1, u2} \u03b2 \u03b1 (Equiv.symm.{u2, u1} \u03b1 \u03b2 e)) (Equiv.toEmbedding.{u2, u1} \u03b1 \u03b2 e)) (Function.Embedding.refl.{u1} \u03b2)\nCase conversion may be inaccurate. Consider using '#align function.embedding.equiv_symm_to_embedding_trans_to_embedding Function.Embedding.equiv_symm_toEmbedding_trans_toEmbedding\u2093'. -/\n@[simp]\ntheorem equiv_symm_toEmbedding_trans_toEmbedding {\u03b1 \u03b2 : Sort _} (e : \u03b1 \u2243 \u03b2) :\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 {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {\u03b4 : Sort x} (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b3 \u2243 \u03b4)\n    (f : \u03b1 \u21aa \u03b3) : \u03b2 \u21aa \u03b4 :=\n  (Equiv.toEmbedding e\u2081.symm).trans (f.trans e\u2082.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 {\u03b1 \u03b2} (f : \u03b2 \u2192 \u03b1) (hf : Surjective f) : \u03b1 \u21aa \u03b2 :=\n  \u27e8surjInv hf, injective_surjInv _\u27e9\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 {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) (hf : Surjective f) : \u03b1 \u2243 \u03b2 :=\n  Equiv.ofBijective f \u27e8f.Injective, hf\u27e9\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 {\u03b1 \u03b2} [IsEmpty \u03b1] : \u03b1 \u21aa \u03b2 :=\n  \u27e8isEmptyElim, isEmptyElim\u27e9\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 {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) (a : \u03b1) (b : \u03b2) [\u2200 a', Decidable (a' = a)]\n    [\u2200 a', Decidable (f a' = b)] : \u03b1 \u21aa \u03b2 :=\n  \u27e8fun 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\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} (f : Function.Embedding.{u1, u2} \u03b1 \u03b2) (a : \u03b1) (b : \u03b2) [_inst_1 : forall (a' : \u03b1), Decidable (Eq.{u1} \u03b1 a' a)] [_inst_2 : forall (a' : \u03b1), Decidable (Eq.{u2} \u03b2 (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) f a') b)], Eq.{u2} \u03b2 (coeFn.{max 1 (imax u1 u2), imax u1 u2} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{u1, u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{u1, u2} \u03b1 \u03b2) (Function.Embedding.setValue.{u1, u2} \u03b1 \u03b2 f a b (fun (a' : \u03b1) => _inst_1 a') (fun (a' : \u03b1) => _inst_2 a')) a) b\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} (f : Function.Embedding.{u2, u1} \u03b1 \u03b2) (a : \u03b1) (b : \u03b2) [_inst_1 : forall (a' : \u03b1), Decidable (Eq.{u2} \u03b1 a' a)] [_inst_2 : forall (a' : \u03b1), Decidable (Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) a') (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) f a') b)], Eq.{u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) a) (FunLike.coe.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (max 1 u1) u2, u2, u1} (Function.Embedding.{u2, u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{u2, u1} \u03b1 \u03b2)) (Function.Embedding.setValue.{u2, u1} \u03b1 \u03b2 f a b (fun (a' : \u03b1) => _inst_1 a') (fun (a' : \u03b1) => _inst_2 a')) a) b\nCase conversion may be inaccurate. Consider using '#align function.embedding.set_value_eq Function.Embedding.setValue_eq\u2093'. -/\ntheorem setValue_eq {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) (a : \u03b1) (b : \u03b2) [\u2200 a', Decidable (a' = a)]\n    [\u2200 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 \u03b1` using `some`. -/\n@[simps (config := { fullyApplied := false })]\nprotected def some {\u03b1} : \u03b1 \u21aa Option \u03b1 :=\n  \u27e8some, Option.some_injective \u03b1\u27e9\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\u2093'. -/\n#print Function.Embedding.some /-\n/-- Embedding into `option \u03b1` using `coe`. Usually the correct synctatical form for `simp`. -/\n@[simps (config := { fullyApplied := false })]\ndef some {\u03b1} : \u03b1 \u21aa Option \u03b1 :=\n  \u27e8coe, Option.some_injective \u03b1\u27e9\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 {\u03b1 \u03b2} (f : \u03b1 \u21aa \u03b2) : Option \u03b1 \u21aa Option \u03b2 :=\n  \u27e8Option.map f, Option.map_injective f.Injective\u27e9\n#align function.embedding.option_map Function.Embedding.optionMap\n-/\n\n#print Function.Embedding.subtype /-\n/-- Embedding of a `subtype`. -/\ndef subtype {\u03b1} (p : \u03b1 \u2192 Prop) : Subtype p \u21aa \u03b1 :=\n  \u27e8coe, fun _ _ => Subtype.ext_val\u27e9\n#align function.embedding.subtype Function.Embedding.subtype\n-/\n\n#print Function.Embedding.coe_subtype /-\n@[simp]\ntheorem coe_subtype {\u03b1} (p : \u03b1 \u2192 Prop) : \u21d1(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 (\u03b1) [s : Setoid \u03b1] : Quotient s \u21aa \u03b1 :=\n  \u27e8_, Quotient.out_injective\u27e9\n#align function.embedding.quotient_out Function.Embedding.quotientOut\n-/\n\n#print Function.Embedding.coe_quotientOut /-\n@[simp]\ntheorem coe_quotientOut (\u03b1) [s : Setoid \u03b1] : \u21d1(quotientOut \u03b1) = 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 : \u03b2` gives an embedding of `punit` into `\u03b2`. -/\ndef punit {\u03b2 : Sort _} (b : \u03b2) : PUnit \u21aa \u03b2 :=\n  \u27e8fun _ => b, by\n    rintro \u27e8\u27e9 \u27e8\u27e9 _\n    rfl\u27e9\n#align function.embedding.punit Function.Embedding.punit\n-/\n\n#print Function.Embedding.sectl /-\n/-- Fixing an element `b : \u03b2` gives an embedding `\u03b1 \u21aa \u03b1 \u00d7 \u03b2`. -/\n@[simps]\ndef sectl (\u03b1 : Sort _) {\u03b2 : Sort _} (b : \u03b2) : \u03b1 \u21aa \u03b1 \u00d7 \u03b2 :=\n  \u27e8fun a => (a, b), fun a a' h => congr_arg Prod.fst h\u27e9\n#align function.embedding.sectl Function.Embedding.sectl\n-/\n\n#print Function.Embedding.sectr /-\n/-- Fixing an element `a : \u03b1` gives an embedding `\u03b2 \u21aa \u03b1 \u00d7 \u03b2`. -/\n@[simps]\ndef sectr {\u03b1 : Sort _} (a : \u03b1) (\u03b2 : Sort _) : \u03b2 \u21aa \u03b1 \u00d7 \u03b2 :=\n  \u27e8fun b => (a, b), fun b b' h => congr_arg Prod.snd h\u27e9\n#align function.embedding.sectr Function.Embedding.sectr\n-/\n\n#print Function.Embedding.prodMap /-\n/-- If `e\u2081` and `e\u2082` are embeddings, then so is `prod.map e\u2081 e\u2082 : (a, b) \u21a6 (e\u2081 a, e\u2082 b)`. -/\ndef prodMap {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) : \u03b1 \u00d7 \u03b3 \u21aa \u03b2 \u00d7 \u03b4 :=\n  \u27e8Prod.map e\u2081 e\u2082, e\u2081.Injective.Prod_map e\u2082.Injective\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} (e\u2081 : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (e\u2082 : Function.Embedding.{succ u3, succ u4} \u03b3 \u03b4), Eq.{max (max (succ u1) (succ u3)) (succ u2) (succ u4)} ((Prod.{u1, u3} \u03b1 \u03b3) -> (Prod.{u2, u4} \u03b2 \u03b4)) (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} \u03b1 \u03b3) (Prod.{u2, u4} \u03b2 \u03b4)) (fun (_x : Function.Embedding.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u4} \u03b2 \u03b4)) => (Prod.{u1, u3} \u03b1 \u03b3) -> (Prod.{u2, u4} \u03b2 \u03b4)) (Function.Embedding.hasCoeToFun.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Prod.{u1, u3} \u03b1 \u03b3) (Prod.{u2, u4} \u03b2 \u03b4)) (Function.Embedding.prodMap.{u1, u2, u3, u4} \u03b1 \u03b2 \u03b3 \u03b4 e\u2081 e\u2082)) (Prod.map.{u1, u2, u3, u4} \u03b1 \u03b2 \u03b3 \u03b4 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) e\u2081) (coeFn.{max 1 (succ u3) (succ u4), max (succ u3) (succ u4)} (Function.Embedding.{succ u3, succ u4} \u03b3 \u03b4) (fun (_x : Function.Embedding.{succ u3, succ u4} \u03b3 \u03b4) => \u03b3 -> \u03b4) (Function.Embedding.hasCoeToFun.{succ u3, succ u4} \u03b3 \u03b4) e\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} {\u03b4 : Type.{u1}} (e\u2081 : Function.Embedding.{succ u4, succ u3} \u03b1 \u03b2) (e\u2082 : Function.Embedding.{succ u2, succ u1} \u03b3 \u03b4), Eq.{max (max (max (succ u4) (succ u3)) (succ u2)) (succ u1)} (forall (\u1fb0 : Prod.{u4, u2} \u03b1 \u03b3), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u4, u2} \u03b1 \u03b3) => Prod.{u3, u1} \u03b2 \u03b4) \u1fb0) (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} \u03b1 \u03b3) (Prod.{u3, u1} \u03b2 \u03b4)) (Prod.{u4, u2} \u03b1 \u03b3) (fun (_x : Prod.{u4, u2} \u03b1 \u03b3) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Prod.{u4, u2} \u03b1 \u03b3) => Prod.{u3, u1} \u03b2 \u03b4) _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} \u03b1 \u03b3) (Prod.{u3, u1} \u03b2 \u03b4)) (Prod.{u4, u2} \u03b1 \u03b3) (Prod.{u3, u1} \u03b2 \u03b4) (Function.instEmbeddingLikeEmbedding.{max (succ u4) (succ u2), max (succ u3) (succ u1)} (Prod.{u4, u2} \u03b1 \u03b3) (Prod.{u3, u1} \u03b2 \u03b4))) (Function.Embedding.prodMap.{u4, u3, u2, u1} \u03b1 \u03b2 \u03b3 \u03b4 e\u2081 e\u2082)) (Prod.map.{u4, u3, u2, u1} \u03b1 \u03b2 \u03b3 \u03b4 (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (Function.Embedding.{succ u4, succ u3} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u4) (succ u3), succ u4, succ u3} (Function.Embedding.{succ u4, succ u3} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u4, succ u3} \u03b1 \u03b2)) e\u2081) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b3 \u03b4) \u03b3 (fun (_x : \u03b3) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b3) => \u03b4) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b3 \u03b4) \u03b3 \u03b4 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b3 \u03b4)) e\u2082))\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_prod_map Function.Embedding.coe_prodMap\u2093'. -/\n@[simp]\ntheorem coe_prodMap {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) :\n    \u21d1(e\u2081.Prod_map e\u2082) = Prod.map e\u2081 e\u2082 :=\n  rfl\n#align function.embedding.coe_prod_map Function.Embedding.coe_prodMap\n\n#print Function.Embedding.pprodMap /-\n/-- If `e\u2081` and `e\u2082` are embeddings, then so is `\u03bb \u27e8a, b\u27e9, \u27e8e\u2081 a, e\u2082 b\u27e9 : pprod \u03b1 \u03b3 \u2192 pprod \u03b2 \u03b4`. -/\ndef pprodMap {\u03b1 \u03b2 \u03b3 \u03b4 : Sort _} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) : PProd \u03b1 \u03b3 \u21aa PProd \u03b2 \u03b4 :=\n  \u27e8fun x => \u27e8e\u2081 x.1, e\u2082 x.2\u27e9, e\u2081.Injective.pprod_map e\u2082.Injective\u27e9\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\u2081` and `e\u2082` are embeddings, then so is `sum.map e\u2081 e\u2082`. -/\ndef sumMap {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) : Sum \u03b1 \u03b3 \u21aa Sum \u03b2 \u03b4 :=\n  \u27e8Sum.map e\u2081 e\u2082, fun s\u2081 s\u2082 h =>\n    match s\u2081, s\u2082, h with\n    | inl a\u2081, inl a\u2082, h => congr_arg inl <| e\u2081.Injective <| inl.inj h\n    | inr b\u2081, inr b\u2082, h => congr_arg inr <| e\u2082.Injective <| inr.inj h\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} (e\u2081 : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (e\u2082 : Function.Embedding.{succ u3, succ u4} \u03b3 \u03b4), Eq.{max (max (succ u1) (succ u3)) (succ u2) (succ u4)} ((Sum.{u1, u3} \u03b1 \u03b3) -> (Sum.{u2, u4} \u03b2 \u03b4)) (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} \u03b1 \u03b3) (Sum.{u2, u4} \u03b2 \u03b4)) (fun (_x : Function.Embedding.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Sum.{u1, u3} \u03b1 \u03b3) (Sum.{u2, u4} \u03b2 \u03b4)) => (Sum.{u1, u3} \u03b1 \u03b3) -> (Sum.{u2, u4} \u03b2 \u03b4)) (Function.Embedding.hasCoeToFun.{max (succ u1) (succ u3), max (succ u2) (succ u4)} (Sum.{u1, u3} \u03b1 \u03b3) (Sum.{u2, u4} \u03b2 \u03b4)) (Function.Embedding.sumMap.{u1, u2, u3, u4} \u03b1 \u03b2 \u03b3 \u03b4 e\u2081 e\u2082)) (Sum.map.{u1, u3, u2, u4} \u03b1 \u03b2 \u03b3 \u03b4 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) e\u2081) (coeFn.{max 1 (succ u3) (succ u4), max (succ u3) (succ u4)} (Function.Embedding.{succ u3, succ u4} \u03b3 \u03b4) (fun (_x : Function.Embedding.{succ u3, succ u4} \u03b3 \u03b4) => \u03b3 -> \u03b4) (Function.Embedding.hasCoeToFun.{succ u3, succ u4} \u03b3 \u03b4) e\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} {\u03b4 : Type.{u1}} (e\u2081 : Function.Embedding.{succ u4, succ u3} \u03b1 \u03b2) (e\u2082 : Function.Embedding.{succ u2, succ u1} \u03b3 \u03b4), Eq.{max (max (max (succ u1) (succ u2)) (succ u3)) (succ u4)} (forall (\u1fb0 : Sum.{u4, u2} \u03b1 \u03b3), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Sum.{u4, u2} \u03b1 \u03b3) => Sum.{u3, u1} \u03b2 \u03b4) \u1fb0) (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} \u03b1 \u03b3) (Sum.{u3, u1} \u03b2 \u03b4)) (Sum.{u4, u2} \u03b1 \u03b3) (fun (_x : Sum.{u4, u2} \u03b1 \u03b3) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Sum.{u4, u2} \u03b1 \u03b3) => Sum.{u3, u1} \u03b2 \u03b4) _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} \u03b1 \u03b3) (Sum.{u3, u1} \u03b2 \u03b4)) (Sum.{u4, u2} \u03b1 \u03b3) (Sum.{u3, u1} \u03b2 \u03b4) (Function.instEmbeddingLikeEmbedding.{max (succ u2) (succ u4), max (succ u1) (succ u3)} (Sum.{u4, u2} \u03b1 \u03b3) (Sum.{u3, u1} \u03b2 \u03b4))) (Function.Embedding.sumMap.{u4, u3, u2, u1} \u03b1 \u03b2 \u03b3 \u03b4 e\u2081 e\u2082)) (Sum.map.{u4, u2, u3, u1} \u03b1 \u03b2 \u03b3 \u03b4 (FunLike.coe.{max (succ u3) (succ u4), succ u4, succ u3} (Function.Embedding.{succ u4, succ u3} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u3) (succ u4), succ u4, succ u3} (Function.Embedding.{succ u4, succ u3} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u4, succ u3} \u03b1 \u03b2)) e\u2081) (FunLike.coe.{max (succ u1) (succ u2), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b3 \u03b4) \u03b3 (fun (_x : \u03b3) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b3) => \u03b4) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b3 \u03b4) \u03b3 \u03b4 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b3 \u03b4)) e\u2082))\nCase conversion may be inaccurate. Consider using '#align function.embedding.coe_sum_map Function.Embedding.coe_sumMap\u2093'. -/\n@[simp]\ntheorem coe_sumMap {\u03b1 \u03b2 \u03b3 \u03b4} (e\u2081 : \u03b1 \u21aa \u03b2) (e\u2082 : \u03b3 \u21aa \u03b4) : \u21d1(sumMap e\u2081 e\u2082) = Sum.map e\u2081 e\u2082 :=\n  rfl\n#align function.embedding.coe_sum_map Function.Embedding.coe_sumMap\n\n#print Function.Embedding.inl /-\n/-- The embedding of `\u03b1` into the sum `\u03b1 \u2295 \u03b2`. -/\n@[simps]\ndef inl {\u03b1 \u03b2 : Type _} : \u03b1 \u21aa Sum \u03b1 \u03b2 :=\n  \u27e8Sum.inl, fun a b => Sum.inl.inj\u27e9\n#align function.embedding.inl Function.Embedding.inl\n-/\n\n#print Function.Embedding.inr /-\n/-- The embedding of `\u03b2` into the sum `\u03b1 \u2295 \u03b2`. -/\n@[simps]\ndef inr {\u03b1 \u03b2 : Type _} : \u03b2 \u21aa Sum \u03b1 \u03b2 :=\n  \u27e8Sum.inr, fun a b => Sum.inr.inj\u27e9\n#align function.embedding.inr Function.Embedding.inr\n-/\n\nend Sum\n\nsection Sigma\n\nvariable {\u03b1 \u03b1' : Type _} {\u03b2 : \u03b1 \u2192 Type _} {\u03b2' : \u03b1' \u2192 Type _}\n\n#print Function.Embedding.sigmaMk /-\n/-- `sigma.mk` as an `function.embedding`. -/\n@[simps apply]\ndef sigmaMk (a : \u03b1) : \u03b2 a \u21aa \u03a3x, \u03b2 x :=\n  \u27e8Sigma.mk a, sigma_mk_injective\u27e9\n#align function.embedding.sigma_mk Function.Embedding.sigmaMk\n-/\n\n#print Function.Embedding.sigmaMap /-\n/-- If `f : \u03b1 \u21aa \u03b1'` is an embedding and `g : \u03a0 a, \u03b2 \u03b1 \u21aa \u03b2' (f \u03b1)` is a family\nof embeddings, then `sigma.map f g` is an embedding. -/\n@[simps apply]\ndef sigmaMap (f : \u03b1 \u21aa \u03b1') (g : \u2200 a, \u03b2 a \u21aa \u03b2' (f a)) : (\u03a3a, \u03b2 a) \u21aa \u03a3a', \u03b2' a' :=\n  \u27e8Sigma.map f fun a => g a, f.Injective.sigma_map fun a => (g a).Injective\u27e9\n#align function.embedding.sigma_map Function.Embedding.sigmaMap\n-/\n\nend Sigma\n\n#print Function.Embedding.piCongrRight /-\n/-- Define an embedding `(\u03a0 a : \u03b1, \u03b2 a) \u21aa (\u03a0 a : \u03b1, \u03b3 a)` from a family of embeddings\n`e : \u03a0 a, (\u03b2 a \u21aa \u03b3 a)`. This embedding sends `f` to `\u03bb a, e a (f a)`. -/\n@[simps]\ndef piCongrRight {\u03b1 : Sort _} {\u03b2 \u03b3 : \u03b1 \u2192 Sort _} (e : \u2200 a, \u03b2 a \u21aa \u03b3 a) : (\u2200 a, \u03b2 a) \u21aa \u2200 a, \u03b3 a :=\n  \u27e8fun f a => e a (f a), fun f\u2081 f\u2082 h => funext fun a => (e a).Injective (congr_fun h a)\u27e9\n#align function.embedding.Pi_congr_right Function.Embedding.piCongrRight\n-/\n\n#print Function.Embedding.arrowCongrRight /-\n/-- An embedding `e : \u03b1 \u21aa \u03b2` defines an embedding `(\u03b3 \u2192 \u03b1) \u21aa (\u03b3 \u2192 \u03b2)` that sends each `f`\nto `e \u2218 f`. -/\ndef arrowCongrRight {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (e : \u03b1 \u21aa \u03b2) : (\u03b3 \u2192 \u03b1) \u21aa \u03b3 \u2192 \u03b2 :=\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 {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (e : \u03b1 \u21aa \u03b2) (f : \u03b3 \u21aa \u03b1) :\n    arrowCongrRight e f = e \u2218 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 : \u03b1 \u21aa \u03b2` defines an embedding `(\u03b1 \u2192 \u03b3) \u21aa (\u03b2 \u2192 \u03b3)` for any inhabited type `\u03b3`.\nThis embedding sends each `f : \u03b1 \u2192 \u03b3` to a function `g : \u03b2 \u2192 \u03b3` such that `g \u2218 e = f` and\n`g y = default` whenever `y \u2209 range e`. -/\nnoncomputable def arrowCongrLeft {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} [Inhabited \u03b3] (e : \u03b1 \u21aa \u03b2) :\n    (\u03b1 \u2192 \u03b3) \u21aa \u03b2 \u2192 \u03b3 :=\n  \u27e8fun f => extend e f default, fun f\u2081 f\u2082 h =>\n    funext fun x => by simpa only [e.injective.extend_apply] using congr_fun h (e x)\u27e9\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 {\u03b1 \u03b2} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (f : \u03b1 \u21aa \u03b2)\n    (h : \u2200 \u2983x\u2984, p x \u2192 q (f x)) : { x : \u03b1 // p x } \u21aa { y : \u03b2 // q y } :=\n  \u27e8Subtype.map f h, Subtype.map_injective h f.2\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] (f : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (x : \u03b1) (y : \u03b1) (z : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{succ u2, succ u2} (Equiv.Perm.{succ u2} \u03b2) (fun (_x : Equiv.{succ u2, succ u2} \u03b2 \u03b2) => \u03b2 -> \u03b2) (Equiv.hasCoeToFun.{succ u2, succ u2} \u03b2 \u03b2) (Equiv.swap.{succ u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f x) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f y)) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f z)) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f (coeFn.{succ u1, succ u1} (Equiv.Perm.{succ u1} \u03b1) (fun (_x : Equiv.{succ u1, succ u1} \u03b1 \u03b1) => \u03b1 -> \u03b1) (Equiv.hasCoeToFun.{succ u1, succ u1} \u03b1 \u03b1) (Equiv.swap.{succ u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y) z))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] (f : Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) (x : \u03b1) (y : \u03b1) (z : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (a : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) a) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f z)) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.Perm.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x)) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x)) (Equiv.swap.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f y)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f z)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.Perm.{succ u2} \u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} \u03b1 \u03b1) (Equiv.swap.{succ u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y) z))\nCase conversion may be inaccurate. Consider using '#align function.embedding.swap_apply Function.Embedding.swap_apply\u2093'. -/\ntheorem swap_apply {\u03b1 \u03b2 : Type _} [DecidableEq \u03b1] [DecidableEq \u03b2] (f : \u03b1 \u21aa \u03b2) (x y z : \u03b1) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] [_inst_2 : DecidableEq.{succ u2} \u03b2] (f : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (x : \u03b1) (y : \u03b1), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (Function.comp.{succ u1, succ u2, succ u2} \u03b1 \u03b2 \u03b2 (coeFn.{succ u2, succ u2} (Equiv.Perm.{succ u2} \u03b2) (fun (_x : Equiv.{succ u2, succ u2} \u03b2 \u03b2) => \u03b2 -> \u03b2) (Equiv.hasCoeToFun.{succ u2, succ u2} \u03b2 \u03b2) (Equiv.swap.{succ u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f x) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f y))) (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f)) (Function.comp.{succ u1, succ u1, succ u2} \u03b1 \u03b1 \u03b2 (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) (fun (_x : Function.Embedding.{succ u1, succ u2} \u03b1 \u03b2) => \u03b1 -> \u03b2) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} \u03b1 \u03b2) f) (coeFn.{succ u1, succ u1} (Equiv.Perm.{succ u1} \u03b1) (fun (_x : Equiv.{succ u1, succ u1} \u03b1 \u03b1) => \u03b1 -> \u03b1) (Equiv.hasCoeToFun.{succ u1, succ u1} \u03b1 \u03b1) (Equiv.swap.{succ u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} \u03b1] [_inst_2 : DecidableEq.{succ u1} \u03b2] (f : Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) (x : \u03b1) (y : \u03b1), Eq.{max (succ u2) (succ u1)} (\u03b1 -> ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x)) (Function.comp.{succ u2, succ u1, succ u1} \u03b1 ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (FunLike.coe.{succ u1, succ u1, succ u1} (Equiv.Perm.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x)) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (fun (_x : \u03b2) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) _x) (Equiv.instFunLikeEquiv.{succ u1, succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x)) (Equiv.swap.{succ u1} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) x) (fun (a : \u03b2) (b : \u03b2) => _inst_2 a b) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f y))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f)) (Function.comp.{succ u2, succ u2, succ u1} \u03b1 \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) f) (FunLike.coe.{succ u2, succ u2, succ u2} (Equiv.Perm.{succ u2} \u03b1) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : \u03b1) => \u03b1) _x) (Equiv.instFunLikeEquiv.{succ u2, succ u2} \u03b1 \u03b1) (Equiv.swap.{succ u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) x y)))\nCase conversion may be inaccurate. Consider using '#align function.embedding.swap_comp Function.Embedding.swap_comp\u2093'. -/\ntheorem swap_comp {\u03b1 \u03b2 : Type _} [DecidableEq \u03b1] [DecidableEq \u03b2] (f : \u03b1 \u21aa \u03b2) (x y : \u03b1) :\n    Equiv.swap (f x) (f y) \u2218 f = f \u2218 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 (\u03b1 : Sort.{u1}) (\u03b2 : Sort.{u2}), Equiv.{max 1 (imax u1 u2), max 1 (imax u1 u2)} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (f : \u03b1 -> \u03b2) => Function.Injective.{u1, u2} \u03b1 \u03b2 f)) (Function.Embedding.{u1, u2} \u03b1 \u03b2)\nbut is expected to have type\n  forall (\u03b1 : Sort.{u1}) (\u03b2 : Sort.{u2}), Equiv.{max 1 (imax u1 u2), max (max 1 u2) u1} (Subtype.{imax u1 u2} (\u03b1 -> \u03b2) (fun (f : \u03b1 -> \u03b2) => Function.Injective.{u1, u2} \u03b1 \u03b2 f)) (Function.Embedding.{u1, u2} \u03b1 \u03b2)\nCase conversion may be inaccurate. Consider using '#align equiv.subtype_injective_equiv_embedding Equiv.subtypeInjectiveEquivEmbedding\u2093'. -/\n/-- The type of embeddings `\u03b1 \u21aa \u03b2` is equivalent to\n    the subtype of all injective functions `\u03b1 \u2192 \u03b2`. -/\ndef subtypeInjectiveEquivEmbedding (\u03b1 \u03b2 : Sort _) : { f : \u03b1 \u2192 \u03b2 // Function.Injective f } \u2243 (\u03b1 \u21aa \u03b2)\n    where\n  toFun f := \u27e8f.val, f.property\u27e9\n  invFun f := \u27e8f, f.Injective\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {\u03b4 : Sort.{u4}}, (Equiv.{u1, u2} \u03b1 \u03b2) -> (Equiv.{u3, u4} \u03b3 \u03b4) -> (Equiv.{max 1 (imax u1 u3), max 1 (imax u2 u4)} (Function.Embedding.{u1, u3} \u03b1 \u03b3) (Function.Embedding.{u2, u4} \u03b2 \u03b4))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {\u03b4 : Sort.{u4}}, (Equiv.{u1, u2} \u03b1 \u03b2) -> (Equiv.{u3, u4} \u03b3 \u03b4) -> (Equiv.{max (max 1 u3) u1, max (max 1 u4) u2} (Function.Embedding.{u1, u3} \u03b1 \u03b3) (Function.Embedding.{u2, u4} \u03b2 \u03b4))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr Equiv.embeddingCongr\u2093'. -/\n/-- If `\u03b1\u2081 \u2243 \u03b1\u2082` and `\u03b2\u2081 \u2243 \u03b2\u2082`, then the type of embeddings `\u03b1\u2081 \u21aa \u03b2\u2081`\nis equivalent to the type of embeddings `\u03b1\u2082 \u21aa \u03b2\u2082`. -/\n@[congr, simps apply]\ndef embeddingCongr {\u03b1 \u03b2 \u03b3 \u03b4 : Sort _} (h : \u03b1 \u2243 \u03b2) (h' : \u03b3 \u2243 \u03b4) : (\u03b1 \u21aa \u03b3) \u2243 (\u03b2 \u21aa \u03b4)\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}}, Eq.{max 1 (imax u1 u2)} (Equiv.{max 1 (imax u1 u2), max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} \u03b1 \u03b2) (Function.Embedding.{u1, u2} \u03b1 \u03b2)) (Equiv.embeddingCongr.{u1, u1, u2, u2} \u03b1 \u03b1 \u03b2 \u03b2 (Equiv.refl.{u1} \u03b1) (Equiv.refl.{u2} \u03b2)) (Equiv.refl.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} \u03b1 \u03b2))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}}, Eq.{max (max 1 u2) u1} (Equiv.{max (max 1 u1) u2, max (max 1 u1) u2} (Function.Embedding.{u2, u1} \u03b1 \u03b2) (Function.Embedding.{u2, u1} \u03b1 \u03b2)) (Equiv.embeddingCongr.{u2, u2, u1, u1} \u03b1 \u03b1 \u03b2 \u03b2 (Equiv.refl.{u2} \u03b1) (Equiv.refl.{u1} \u03b2)) (Equiv.refl.{max (max 1 u1) u2} (Function.Embedding.{u2, u1} \u03b1 \u03b2))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr_refl Equiv.embeddingCongr_refl\u2093'. -/\n@[simp]\ntheorem embeddingCongr_refl {\u03b1 \u03b2 : Sort _} :\n    embeddingCongr (Equiv.refl \u03b1) (Equiv.refl \u03b2) = Equiv.refl (\u03b1 \u21aa \u03b2) :=\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 {\u03b1\u2081 : Sort.{u1}} {\u03b2\u2081 : Sort.{u2}} {\u03b1\u2082 : Sort.{u3}} {\u03b2\u2082 : Sort.{u4}} {\u03b1\u2083 : Sort.{u5}} {\u03b2\u2083 : Sort.{u6}} (e\u2081 : Equiv.{u1, u3} \u03b1\u2081 \u03b1\u2082) (e\u2081' : Equiv.{u2, u4} \u03b2\u2081 \u03b2\u2082) (e\u2082 : Equiv.{u3, u5} \u03b1\u2082 \u03b1\u2083) (e\u2082' : Equiv.{u4, u6} \u03b2\u2082 \u03b2\u2083), 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} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u5, u6} \u03b1\u2083 \u03b2\u2083)) (Equiv.embeddingCongr.{u1, u5, u2, u6} \u03b1\u2081 \u03b1\u2083 \u03b2\u2081 \u03b2\u2083 (Equiv.trans.{u1, u3, u5} \u03b1\u2081 \u03b1\u2082 \u03b1\u2083 e\u2081 e\u2082) (Equiv.trans.{u2, u4, u6} \u03b2\u2081 \u03b2\u2082 \u03b2\u2083 e\u2081' e\u2082')) (Equiv.trans.{max 1 (imax u1 u2), max 1 (imax u3 u4), max 1 (imax u5 u6)} (Function.Embedding.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u3, u4} \u03b1\u2082 \u03b2\u2082) (Function.Embedding.{u5, u6} \u03b1\u2083 \u03b2\u2083) (Equiv.embeddingCongr.{u1, u3, u2, u4} \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 e\u2081 e\u2081') (Equiv.embeddingCongr.{u3, u5, u4, u6} \u03b1\u2082 \u03b1\u2083 \u03b2\u2082 \u03b2\u2083 e\u2082 e\u2082'))\nbut is expected to have type\n  forall {\u03b1\u2081 : Sort.{u6}} {\u03b2\u2081 : Sort.{u5}} {\u03b1\u2082 : Sort.{u4}} {\u03b2\u2082 : Sort.{u3}} {\u03b1\u2083 : Sort.{u2}} {\u03b2\u2083 : Sort.{u1}} (e\u2081 : Equiv.{u6, u4} \u03b1\u2081 \u03b1\u2082) (e\u2081' : Equiv.{u5, u3} \u03b2\u2081 \u03b2\u2082) (e\u2082 : Equiv.{u4, u2} \u03b1\u2082 \u03b1\u2083) (e\u2082' : Equiv.{u3, u1} \u03b2\u2082 \u03b2\u2083), 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} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u2, u1} \u03b1\u2083 \u03b2\u2083)) (Equiv.embeddingCongr.{u6, u2, u5, u1} \u03b1\u2081 \u03b1\u2083 \u03b2\u2081 \u03b2\u2083 (Equiv.trans.{u6, u4, u2} \u03b1\u2081 \u03b1\u2082 \u03b1\u2083 e\u2081 e\u2082) (Equiv.trans.{u5, u3, u1} \u03b2\u2081 \u03b2\u2082 \u03b2\u2083 e\u2081' e\u2082')) (Equiv.trans.{max (max 1 u6) u5, max (max 1 u4) u3, max (max 1 u1) u2} (Function.Embedding.{u6, u5} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u4, u3} \u03b1\u2082 \u03b2\u2082) (Function.Embedding.{u2, u1} \u03b1\u2083 \u03b2\u2083) (Equiv.embeddingCongr.{u6, u4, u5, u3} \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 e\u2081 e\u2081') (Equiv.embeddingCongr.{u4, u2, u3, u1} \u03b1\u2082 \u03b1\u2083 \u03b2\u2082 \u03b2\u2083 e\u2082 e\u2082'))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr_trans Equiv.embeddingCongr_trans\u2093'. -/\n@[simp]\ntheorem embeddingCongr_trans {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 \u03b1\u2083 \u03b2\u2083 : Sort _} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2081' : \u03b2\u2081 \u2243 \u03b2\u2082)\n    (e\u2082 : \u03b1\u2082 \u2243 \u03b1\u2083) (e\u2082' : \u03b2\u2082 \u2243 \u03b2\u2083) :\n    embeddingCongr (e\u2081.trans e\u2082) (e\u2081'.trans e\u2082') =\n      (embeddingCongr e\u2081 e\u2081').trans (embeddingCongr e\u2082 e\u2082') :=\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 {\u03b1\u2081 : Sort.{u1}} {\u03b2\u2081 : Sort.{u2}} {\u03b1\u2082 : Sort.{u3}} {\u03b2\u2082 : Sort.{u4}} (e\u2081 : Equiv.{u1, u3} \u03b1\u2081 \u03b1\u2082) (e\u2082 : Equiv.{u2, u4} \u03b2\u2081 \u03b2\u2082), 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} \u03b1\u2082 \u03b2\u2082) (Function.Embedding.{u1, u2} \u03b1\u2081 \u03b2\u2081)) (Equiv.symm.{max 1 (imax u1 u2), max 1 (imax u3 u4)} (Function.Embedding.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u3, u4} \u03b1\u2082 \u03b2\u2082) (Equiv.embeddingCongr.{u1, u3, u2, u4} \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 e\u2081 e\u2082)) (Equiv.embeddingCongr.{u3, u1, u4, u2} \u03b1\u2082 \u03b1\u2081 \u03b2\u2082 \u03b2\u2081 (Equiv.symm.{u1, u3} \u03b1\u2081 \u03b1\u2082 e\u2081) (Equiv.symm.{u2, u4} \u03b2\u2081 \u03b2\u2082 e\u2082))\nbut is expected to have type\n  forall {\u03b1\u2081 : Sort.{u4}} {\u03b2\u2081 : Sort.{u3}} {\u03b1\u2082 : Sort.{u2}} {\u03b2\u2082 : Sort.{u1}} (e\u2081 : Equiv.{u4, u2} \u03b1\u2081 \u03b1\u2082) (e\u2082 : Equiv.{u3, u1} \u03b2\u2081 \u03b2\u2082), 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} \u03b1\u2082 \u03b2\u2082) (Function.Embedding.{u4, u3} \u03b1\u2081 \u03b2\u2081)) (Equiv.symm.{max (max 1 u4) u3, max (max 1 u2) u1} (Function.Embedding.{u4, u3} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u2, u1} \u03b1\u2082 \u03b2\u2082) (Equiv.embeddingCongr.{u4, u2, u3, u1} \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 e\u2081 e\u2082)) (Equiv.embeddingCongr.{u2, u4, u1, u3} \u03b1\u2082 \u03b1\u2081 \u03b2\u2082 \u03b2\u2081 (Equiv.symm.{u4, u2} \u03b1\u2081 \u03b1\u2082 e\u2081) (Equiv.symm.{u3, u1} \u03b2\u2081 \u03b2\u2082 e\u2082))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr_symm Equiv.embeddingCongr_symm\u2093'. -/\n@[simp]\ntheorem embeddingCongr_symm {\u03b1\u2081 \u03b2\u2081 \u03b1\u2082 \u03b2\u2082 : Sort _} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    (embeddingCongr e\u2081 e\u2082).symm = embeddingCongr e\u2081.symm e\u2082.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 {\u03b1\u2081 : Sort.{u1}} {\u03b2\u2081 : Sort.{u2}} {\u03b3\u2081 : Sort.{u3}} {\u03b1\u2082 : Sort.{u4}} {\u03b2\u2082 : Sort.{u5}} {\u03b3\u2082 : Sort.{u6}} (ea : Equiv.{u1, u4} \u03b1\u2081 \u03b1\u2082) (eb : Equiv.{u2, u5} \u03b2\u2081 \u03b2\u2082) (ec : Equiv.{u3, u6} \u03b3\u2081 \u03b3\u2082) (f : Function.Embedding.{u1, u2} \u03b1\u2081 \u03b2\u2081) (g : Function.Embedding.{u2, u3} \u03b2\u2081 \u03b3\u2081), Eq.{max 1 (imax u4 u6)} (Function.Embedding.{u4, u6} \u03b1\u2082 \u03b3\u2082) (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} \u03b1\u2081 \u03b3\u2081) (Function.Embedding.{u4, u6} \u03b1\u2082 \u03b3\u2082)) (fun (_x : Equiv.{max 1 (imax u1 u3), max 1 (imax u4 u6)} (Function.Embedding.{u1, u3} \u03b1\u2081 \u03b3\u2081) (Function.Embedding.{u4, u6} \u03b1\u2082 \u03b3\u2082)) => (Function.Embedding.{u1, u3} \u03b1\u2081 \u03b3\u2081) -> (Function.Embedding.{u4, u6} \u03b1\u2082 \u03b3\u2082)) (Equiv.hasCoeToFun.{max 1 (imax u1 u3), max 1 (imax u4 u6)} (Function.Embedding.{u1, u3} \u03b1\u2081 \u03b3\u2081) (Function.Embedding.{u4, u6} \u03b1\u2082 \u03b3\u2082)) (Equiv.embeddingCongr.{u1, u4, u3, u6} \u03b1\u2081 \u03b1\u2082 \u03b3\u2081 \u03b3\u2082 ea ec) (Function.Embedding.trans.{u1, u2, u3} \u03b1\u2081 \u03b2\u2081 \u03b3\u2081 f g)) (Function.Embedding.trans.{u4, u5, u6} \u03b1\u2082 \u03b2\u2082 \u03b3\u2082 (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} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u4, u5} \u03b1\u2082 \u03b2\u2082)) (fun (_x : Equiv.{max 1 (imax u1 u2), max 1 (imax u4 u5)} (Function.Embedding.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u4, u5} \u03b1\u2082 \u03b2\u2082)) => (Function.Embedding.{u1, u2} \u03b1\u2081 \u03b2\u2081) -> (Function.Embedding.{u4, u5} \u03b1\u2082 \u03b2\u2082)) (Equiv.hasCoeToFun.{max 1 (imax u1 u2), max 1 (imax u4 u5)} (Function.Embedding.{u1, u2} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u4, u5} \u03b1\u2082 \u03b2\u2082)) (Equiv.embeddingCongr.{u1, u4, u2, u5} \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 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} \u03b2\u2081 \u03b3\u2081) (Function.Embedding.{u5, u6} \u03b2\u2082 \u03b3\u2082)) (fun (_x : Equiv.{max 1 (imax u2 u3), max 1 (imax u5 u6)} (Function.Embedding.{u2, u3} \u03b2\u2081 \u03b3\u2081) (Function.Embedding.{u5, u6} \u03b2\u2082 \u03b3\u2082)) => (Function.Embedding.{u2, u3} \u03b2\u2081 \u03b3\u2081) -> (Function.Embedding.{u5, u6} \u03b2\u2082 \u03b3\u2082)) (Equiv.hasCoeToFun.{max 1 (imax u2 u3), max 1 (imax u5 u6)} (Function.Embedding.{u2, u3} \u03b2\u2081 \u03b3\u2081) (Function.Embedding.{u5, u6} \u03b2\u2082 \u03b3\u2082)) (Equiv.embeddingCongr.{u2, u5, u3, u6} \u03b2\u2081 \u03b2\u2082 \u03b3\u2081 \u03b3\u2082 eb ec) g))\nbut is expected to have type\n  forall {\u03b1\u2081 : Sort.{u6}} {\u03b2\u2081 : Sort.{u5}} {\u03b3\u2081 : Sort.{u4}} {\u03b1\u2082 : Sort.{u3}} {\u03b2\u2082 : Sort.{u2}} {\u03b3\u2082 : Sort.{u1}} (ea : Equiv.{u6, u3} \u03b1\u2081 \u03b1\u2082) (eb : Equiv.{u5, u2} \u03b2\u2081 \u03b2\u2082) (ec : Equiv.{u4, u1} \u03b3\u2081 \u03b3\u2082) (f : Function.Embedding.{u6, u5} \u03b1\u2081 \u03b2\u2081) (g : Function.Embedding.{u5, u4} \u03b2\u2081 \u03b3\u2081), Eq.{max (max 1 u3) u1} ((fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Function.Embedding.{u6, u4} \u03b1\u2081 \u03b3\u2081) => Function.Embedding.{u3, u1} \u03b1\u2082 \u03b3\u2082) (Function.Embedding.trans.{u6, u5, u4} \u03b1\u2081 \u03b2\u2081 \u03b3\u2081 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} \u03b1\u2081 \u03b3\u2081) (Function.Embedding.{u3, u1} \u03b1\u2082 \u03b3\u2082)) (Function.Embedding.{u6, u4} \u03b1\u2081 \u03b3\u2081) (fun (_x : Function.Embedding.{u6, u4} \u03b1\u2081 \u03b3\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Function.Embedding.{u6, u4} \u03b1\u2081 \u03b3\u2081) => Function.Embedding.{u3, u1} \u03b1\u2082 \u03b3\u2082) _x) (Equiv.instFunLikeEquiv.{max (max 1 u6) u4, max (max 1 u3) u1} (Function.Embedding.{u6, u4} \u03b1\u2081 \u03b3\u2081) (Function.Embedding.{u3, u1} \u03b1\u2082 \u03b3\u2082)) (Equiv.embeddingCongr.{u6, u3, u4, u1} \u03b1\u2081 \u03b1\u2082 \u03b3\u2081 \u03b3\u2082 ea ec) (Function.Embedding.trans.{u6, u5, u4} \u03b1\u2081 \u03b2\u2081 \u03b3\u2081 f g)) (Function.Embedding.trans.{u3, u2, u1} \u03b1\u2082 \u03b2\u2082 \u03b3\u2082 (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} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u3, u2} \u03b1\u2082 \u03b2\u2082)) (Function.Embedding.{u6, u5} \u03b1\u2081 \u03b2\u2081) (fun (_x : Function.Embedding.{u6, u5} \u03b1\u2081 \u03b2\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Function.Embedding.{u6, u5} \u03b1\u2081 \u03b2\u2081) => Function.Embedding.{u3, u2} \u03b1\u2082 \u03b2\u2082) _x) (Equiv.instFunLikeEquiv.{max (max 1 u6) u5, max (max 1 u3) u2} (Function.Embedding.{u6, u5} \u03b1\u2081 \u03b2\u2081) (Function.Embedding.{u3, u2} \u03b1\u2082 \u03b2\u2082)) (Equiv.embeddingCongr.{u6, u3, u5, u2} \u03b1\u2081 \u03b1\u2082 \u03b2\u2081 \u03b2\u2082 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} \u03b2\u2081 \u03b3\u2081) (Function.Embedding.{u2, u1} \u03b2\u2082 \u03b3\u2082)) (Function.Embedding.{u5, u4} \u03b2\u2081 \u03b3\u2081) (fun (_x : Function.Embedding.{u5, u4} \u03b2\u2081 \u03b3\u2081) => (fun (x._@.Mathlib.Logic.Equiv.Defs._hyg.808 : Function.Embedding.{u5, u4} \u03b2\u2081 \u03b3\u2081) => Function.Embedding.{u2, u1} \u03b2\u2082 \u03b3\u2082) _x) (Equiv.instFunLikeEquiv.{max (max 1 u5) u4, max (max 1 u2) u1} (Function.Embedding.{u5, u4} \u03b2\u2081 \u03b3\u2081) (Function.Embedding.{u2, u1} \u03b2\u2082 \u03b3\u2082)) (Equiv.embeddingCongr.{u5, u2, u4, u1} \u03b2\u2081 \u03b2\u2082 \u03b3\u2081 \u03b3\u2082 eb ec) g))\nCase conversion may be inaccurate. Consider using '#align equiv.embedding_congr_apply_trans Equiv.embeddingCongr_apply_trans\u2093'. -/\ntheorem embeddingCongr_apply_trans {\u03b1\u2081 \u03b2\u2081 \u03b3\u2081 \u03b1\u2082 \u03b2\u2082 \u03b3\u2082 : Sort _} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082)\n    (ec : \u03b3\u2081 \u2243 \u03b3\u2082) (f : \u03b1\u2081 \u21aa \u03b2\u2081) (g : \u03b2\u2081 \u21aa \u03b3\u2081) :\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 {\u03b1 : Type _} : (Equiv.refl \u03b1).toEmbedding = Function.Embedding.refl \u03b1 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (e : Equiv.{succ u1, succ u2} \u03b1 \u03b2) (f : Equiv.{succ u2, succ u3} \u03b2 \u03b3), Eq.{max 1 (succ u1) (succ u3)} (Function.Embedding.{succ u1, succ u3} \u03b1 \u03b3) (Equiv.toEmbedding.{succ u1, succ u3} \u03b1 \u03b3 (Equiv.trans.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 e f)) (Function.Embedding.trans.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 (Equiv.toEmbedding.{succ u1, succ u2} \u03b1 \u03b2 e) (Equiv.toEmbedding.{succ u2, succ u3} \u03b2 \u03b3 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} (e : Equiv.{succ u3, succ u2} \u03b1 \u03b2) (f : Equiv.{succ u2, succ u1} \u03b2 \u03b3), Eq.{max (succ u3) (succ u1)} (Function.Embedding.{succ u3, succ u1} \u03b1 \u03b3) (Equiv.toEmbedding.{succ u3, succ u1} \u03b1 \u03b3 (Equiv.trans.{succ u3, succ u2, succ u1} \u03b1 \u03b2 \u03b3 e f)) (Function.Embedding.trans.{succ u3, succ u2, succ u1} \u03b1 \u03b2 \u03b3 (Equiv.toEmbedding.{succ u3, succ u2} \u03b1 \u03b2 e) (Equiv.toEmbedding.{succ u2, succ u1} \u03b2 \u03b3 f))\nCase conversion may be inaccurate. Consider using '#align equiv.trans_to_embedding Equiv.trans_toEmbedding\u2093'. -/\n@[simp]\ntheorem trans_toEmbedding {\u03b1 \u03b2 \u03b3 : Type _} (e : \u03b1 \u2243 \u03b2) (f : \u03b2 \u2243 \u03b3) :\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 {\u03b1 : Type _}\n\n#print subtypeOrLeftEmbedding /-\n/-- A subtype `{x // p x \u2228 q x}` over a disjunction of `p q : \u03b1 \u2192 Prop` can be injectively split\ninto a sum of subtypes `{x // p x} \u2295 {x // q x}` such that `\u00ac p x` is sent to the right. -/\ndef subtypeOrLeftEmbedding (p q : \u03b1 \u2192 Prop) [DecidablePred p] :\n    { x // p x \u2228 q x } \u21aa Sum { x // p x } { x // q x } :=\n  \u27e8fun x => if h : p x then Sum.inl \u27e8x, h\u27e9 else Sum.inr \u27e8x, x.Prop.resolve_left h\u27e9,\n    by\n    intro x y\n    dsimp only\n    split_ifs <;> simp [Subtype.ext_iff]\u27e9\n#align subtype_or_left_embedding subtypeOrLeftEmbedding\n-/\n\n#print subtypeOrLeftEmbedding_apply_left /-\ntheorem subtypeOrLeftEmbedding_apply_left {p q : \u03b1 \u2192 Prop} [DecidablePred p]\n    (x : { x // p x \u2228 q x }) (hx : p x) : subtypeOrLeftEmbedding p q x = Sum.inl \u27e8x, hx\u27e9 :=\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 : \u03b1 \u2192 Prop} [DecidablePred p]\n    (x : { x // p x \u2228 q x }) (hx : \u00acp x) :\n    subtypeOrLeftEmbedding p q x = Sum.inr \u27e8x, x.Prop.resolve_left hx\u27e9 :=\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 \u2192 q x` for all `x : \u03b1`. -/\n@[simps]\ndef Subtype.impEmbedding (p q : \u03b1 \u2192 Prop) (h : \u2200 x, p x \u2192 q x) : { x // p x } \u21aa { x // q x } :=\n  \u27e8fun x => \u27e8x, h x x.Prop\u27e9, fun x y => by simp [Subtype.ext_iff]\u27e9\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 {\u03b1 : Type*} (a : set \u03b1) {b c : set \u03b1} (h : c \u2286 b) :\n  a \\ b \u2229 c = \u2205 :=\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 {\u03b1 : Type*} {s : set (set \u03b1)} (a y : set \u03b1) (h : y \u2208 s) :\n  (a \\ \u22c3\u2080 s) \u2229 y = \u2205 :=\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 : \u2200 x \u2208 s, is_closed x) :\n  is_closed \u22c3\u2080 (s : set(set H)) :=\nby { simpa only [\u2190 is_open_compl_iff, set.compl_sUnion, set.sInter_image] using is_open_bInter\n    (finset.finite_to_set s) (\u03bb 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 : \u2200 x \u2208 s, is_clopen x) :\n  is_clopen \u22c3\u2080 (s : set(set H)) :=\n\u27e8is_open_sUnion (\u03bb t ht, (hs t ht).1), is_closed_sUnion (\u03bb t ht, (hs t ht).2) \u27e9\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 : \u2200 x \u2208 s, is_clopen x) :\n  is_clopen \u22c3\u2080 (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 : \u2200 x \u2208 s, is_clopen x) :\n  \u2203 (t : finset (set H)),\n  (\u2200 (x \u2208 (t : set (set H))), is_clopen x) \u2227\n  \u22c3\u2080 (s : set(set H)) = \u22c3\u2080 (t : set(set H)) \u2227\n  (\u2200 (x : set H) (hx : x \u2208 t), \u2203 z \u2208 s, x \u2286 z) \u2227\n  \u2200 (x y : set H) (hx : x \u2208 t) (hy : y \u2208 t) (h : x \u2260 y), x \u2229 y = \u2205 :=\nbegin\n  classical,\n  apply finset.induction_on' s,\n  { use \u2205, 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 \u27e8t, clo, union, sub, disj\u27e9,\n    set b := a \\ \u22c3\u2080 S with hb,\n    refine \u27e8insert b t, _, _, \u27e8\u03bb x hx, _, \u03bb x y hx hy ne, _\u27e9\u27e9,\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 _ (\u03bb y hy, (hs y (hS hy)))), },\n      { apply clo x hx, }, },\n    { simp only [finset.coe_insert, set.sUnion_insert], rw [\u2190union, 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 \u27e8z, hz, xz\u27e9, refine \u27e8z, _, xz\u27e9,\n        rw finset.mem_insert, right, assumption, }, },\n    { rw finset.mem_insert at hx, rw finset.mem_insert at hy,\n      have : \u2200 y \u2208 t, b \u2229 y = \u2205,\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 (\u03b5 : \u211d)\n\n/-- Takes an element of `A` to an `\u03b5/4`-ball centered around it. -/\nabbreviation h {A : Type*} [normed_group A] : A \u2192 set A :=\n  \u03bb (x : A), metric.ball x (\u03b5 / 4)\n\n/-- The set of (\u03b5/4)-balls. -/\nabbreviation S {A : Type*} [normed_group A] : set (set A) := set.range (h \u03b5)\n\nvariables {A} (f : C(X, A))\n\n/-- Preimage of (\u03b5/4)-balls. -/\nabbreviation B : set(set X) := { j : set X | \u2203 (U \u2208 ((S \u03b5) : set(set A))), j = f \u207b\u00b9' U }\n\nlemma opens {j : set X} (hj : j \u2208 (B \u03b5 f)) : is_open j :=\nbegin\n  rcases hj with \u27e8hj_w, \u27e8hj_h_w_w, rfl\u27e9, rfl\u27e9,\n  exact continuous.is_open_preimage f.2 _ (metric.is_open_ball),\nend\n\nvariable [fact (0 < \u03b5)]\n/-- `X` is covered by a union of preimage of finitely many elements of `S` under `f` -/\nlemma exists_finset_univ_sub : \u2203 (t : finset (set A)), set.univ \u2286 \u2a06 (i : set A) (H : i \u2208 t)\n  (H : i \u2208 ((S \u03b5) : set(set A))), f \u207b\u00b9' i :=\nbegin\n  have g : (\u22c3\u2080 S \u03b5) = (set.univ : set A),\n  { rw set.sUnion_eq_univ_iff, rintros, refine \u27e8metric.ball a (\u03b5/4), _, _\u27e9,\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 (\u22c3\u2080 S \u03b5) = 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 _ (\u03bb i, is_open_Union\n    (\u03bb hi, continuous.is_open_preimage (continuous_map.continuous f) i _)) g'.2,\n  cases hi with y hy, rw [\u2190hy], refine @metric.is_open_ball A _ y (\u03b5/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 \u03b5 f)\n\nlemma exists_finset_univ_sub_prop : set.univ \u2286 \u2a06 (i : set A) (H : i \u2208 t \u03b5 f)\n  (H : i \u2208 ((S \u03b5) : set(set A))), f \u207b\u00b9' i := classical.some_spec (exists_finset_univ_sub \u03b5 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 \u2286 set.sUnion (B \u03b5 f) :=\nbegin\n  rintros x hx,\n  obtain \u27e8-, \u27e8j, rfl\u27e9, -, \u27e8hj, rfl\u27e9, -, \u27e8\u27e8a, jS\u27e9, rfl\u27e9, fj\u27e9 := (exists_finset_univ_sub_prop \u03b5 f) hx,\n  exact \u27e8f\u207b\u00b9' j, \u27e8j, \u27e8_, jS\u27e9, rfl\u27e9, fj\u27e9,\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 | \u2203 (U : set X) (hU : U \u2208 (B \u03b5 f)),\n    j \u2208 classical.some (topological_space.is_topological_basis.open_eq_sUnion\n    (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _) (opens \u03b5 f hU))}\n\nlemma mem_set_clopen {x : set X} : x \u2208 (set_clopen \u03b5 f) \u2194 \u2203 (U : set X) (hU : U \u2208 (B \u03b5 f)),\n    x \u2208 classical.some (topological_space.is_topological_basis.open_eq_sUnion\n    (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _) (opens \u03b5 f hU)) := iff.rfl\n\n/-- Elements of `set_clopen` are clopen. -/\nlemma set_clopen_sub_clopen_set : (set_clopen \u03b5 f) \u2286 {s : set X | is_clopen s} :=\nbegin\n  intros j hj,\n  obtain \u27e8W, hW, hj\u27e9 := (mem_set_clopen \u03b5 f).1 hj,\n  obtain \u27e8H, -\u27e9 := classical.some_spec (topological_space.is_topological_basis.open_eq_sUnion\n    (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _) (opens \u03b5 f hW)),\n  exact H hj,\nend\n\n/-- `set_clopen` covers X. -/\nlemma univ_sub_sUnion_set_clopen : set.univ \u2286 \u22c3\u2080 (set_clopen \u03b5 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 \u03b5 f,\n-- writing `f\u207b\u00b9' 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 \u03b5 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 \u27e8U, hU, a, ha, xa\u27e9,\n  refine \u27e8a, _, xa\u27e9,\n  rw mem_set_clopen,\n  simp only [exists_prop, set.mem_range, exists_exists_eq_and, set.mem_set_of_eq],\n  refine \u27e8U, hU, ha\u27e9,\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 \u2208 set_clopen \u03b5 f) :\n  \u2203 (U : set X) (H : U \u2208 B \u03b5 f), x \u2286 U :=\nbegin\n  rcases hx with \u27e8U, hU, xU\u27e9, refine \u27e8U, hU, _\u27e9,\n  obtain \u27e8H, H1\u27e9 := classical.some_spec\n    (topological_space.is_topological_basis.open_eq_sUnion\n    (@loc_compact_Haus_tot_disc_of_zero_dim X _ _ _ _) (opens \u03b5 f hU)),\n  rw H1, intros u hu, simp only [exists_prop, set.mem_set_of_eq],\n  refine \u27e8x, _, hu\u27e9,\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 \u03b5 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 \u03b5 f) i.2)\n\n/-- A restatement of `univ_sub_sUnion_set_clopen`. -/\nlemma cover : (set.univ : set X) \u2286 \u22c3 (i : (set_clopen \u03b5 f)), \u2191i :=\nby { convert univ_sub_sUnion_set_clopen \u03b5 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 \u03b5 f) (cover \u03b5 f))\n\n/-- Coercing a subset of `set_clopen` in `s'` to `set X`. -/\nabbreviation s1 := \u03bb (x : s' \u03b5 f), (x.1 : set X)\n\n/-- The range of `s1` is finite. -/\nlemma fin : (set.range (s1 \u03b5 f)).finite :=\nby { apply set.finite_range _, exact plift.fintype (s' \u03b5 f), }\n\n/-- Any element in the range of `s1` is clopen. -/\nlemma is_clopen_x {x : set X} (hx : x \u2208 (fin \u03b5 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 \u27e8\u27e8\u27e8v, hv\u27e9, hw\u27e9, hU\u27e9,\n  convert (set_clopen_sub_clopen_set \u03b5 f) hv,\n  rw \u2190hU,\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 \u03b5 f)) (\u03bb x hx, (is_clopen_x \u03b5 f hx)))\n\n/-- Elements of `finset_clopen` are clopen. -/\nlemma finset_clopen_is_clopen {x : set X} (hx : x \u2208 finset_clopen \u03b5 f) : is_clopen x :=\n  (classical.some_spec (is_clopen.clopen_Union_disjoint (set.finite.to_finset (fin \u03b5 f))\n    (\u03bb x hx, (is_clopen_x \u03b5 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 \u2208 finset_clopen \u03b5 f) :\n  \u2203 U \u2208 ((S \u03b5) : set(set A)), (set.image f x : set A) \u2286 U :=\nbegin\n  rcases (classical.some_spec (is_clopen.clopen_Union_disjoint\n    (set.finite.to_finset (fin \u03b5 f)) (\u03bb x hx, (is_clopen_x \u03b5 f hx)))).2.2.1 x hx with \u27e8z, hz, wz\u27e9,\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 \u27e8\u27e8\u27e8z', h1\u27e9, h2\u27e9, h3\u27e9,\n  rcases exists_B_of_mem_clopen \u03b5 f h1 with \u27e8U, BU, xU\u27e9,\n  simp only [exists_prop, exists_exists_eq_and, set.mem_set_of_eq] at BU,\n  cases BU with U' h4,\n  refine \u27e8U', h4.1, _\u27e9, transitivity (set.image f z),\n  { apply set.image_subset _ wz, },\n  { simp only [set.image_subset_iff], rw [\u2190h4.2, \u2190h3],\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) : \u2203! (b \u2208 finset_clopen \u03b5 f), a \u2208 b :=\nbegin\n-- proving that every element `a : X` is contained in a unique element `j` of `s`\n  obtain \u27e8j, hj, aj\u27e9 : \u2203 j \u2208 finset_clopen \u03b5 f, a \u2208 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 \u03b5 f) (cover \u03b5 f)) (set.mem_univ a),\n    have hs := (classical.some_spec (is_clopen.clopen_Union_disjoint\n      (set.finite.to_finset (fin \u03b5 f)) (\u03bb x hx, (is_clopen_x \u03b5 f hx)))).2.1,\n    delta s1 at hs,\n    suffices : a \u2208 \u22c3\u2080 (finset_clopen \u03b5 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 \u27e8j, hj.1, hj.2\u27e9, },\n    { rw finset_clopen,\n      rw \u2190hs,\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 \u27e8U, \u27e8hU, s'U\u27e9, aU\u27e9,\n      delta s',\n      refine \u27e8\u27e8\u27e8U, hU\u27e9, s'U\u27e9, aU\u27e9, }, },\n  refine \u27e8j, _, \u03bb y hy, _\u27e9,\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 \u27e8hj, aj\u27e9, },\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 \u03b5 f)) (\u03bb x hx, (is_clopen_x \u03b5 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 \u2190set.mem_empty_eq, rw \u2190disj,\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' := \u03bb (s : set X) (H : s \u2208 (finset_clopen \u03b5 f) \u2227 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 \u2192 A :=\n\u03bb x, f (c' \u03b5 f (classical.some (exists_of_exists_unique (finset_clopen_prop \u03b5 f x)) )\nbegin\n  have := (exists_prop.1 (exists_of_exists_unique (classical.some_spec\n    (exists_of_exists_unique (finset_clopen_prop \u03b5 f x))))),\n  split,\n  refine finset.mem_coe.1 (this).1,\n  apply set.nonempty.to_subtype,\n  refine \u27e8x, this.2\u27e9,\nend).\n\n/-- Any element of `finset_clopen` is open. -/\nlemma mem_finset_clopen_is_open {U : set X} (hU : U \u2208 finset_clopen \u03b5 f) : is_open U :=\nby { rw finset_clopen at hU, apply (finset_clopen_is_clopen \u03b5 f hU).1, }\n\n/-- An equivalent version of `disj`. -/\nlemma mem_finset_clopen_unique' {U V : set X} {y : X}\n  (hU : U \u2208 finset_clopen \u03b5 f) (hUy : y \u2208 U) (hVy : y \u2208 V) (hV : V \u2208 finset_clopen \u03b5 f) : V = U :=\nbegin\n  by_contra,\n  have := (classical.some_spec (is_clopen.clopen_Union_disjoint\n    (set.finite.to_finset (fin \u03b5 f)) (\u03bb x hx, (is_clopen_x \u03b5 f hx)))).2.2.2 _ _ hV hU h,\n  revert this,\n  --change (V \u2229 U) \u2260 \u2205,\n  refine set.nonempty.ne_empty \u27e8y, set.mem_inter hVy hUy\u27e9,\nend\n\n/-- Given `x` in `X`, there is a unique element `U` of `finset_clopen` such that `x \u2208 U`. For any\n  `y \u2208 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 \u2208 finset_clopen \u03b5 f \u2227 x \u2208 U) \u2227 \u2200 (y : set X), y \u2208 finset_clopen \u03b5 f \u2192\n    x \u2208 y \u2192 y = U) (hy : y \u2208 U) (hV : V \u2208 finset_clopen \u03b5 f) : x \u2208 V \u2194 y \u2208 V :=\nbegin\n  obtain \u27e8W, hW\u27e9 := finset_clopen_prop \u03b5 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 \u2190(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 \u03b5 f) :=\nbegin\n  rw is_locally_constant.iff_exists_open, rintros x,\n  obtain \u27e8U, hU\u27e9 := finset_clopen_prop \u03b5 f x,\n  simp only [and_imp, exists_prop, exists_unique_iff_exists] at hU,\n  refine \u27e8U, mem_finset_clopen_is_open \u03b5 f hU.1.1, hU.1.2, \u03bb x' hx', _\u27e9,\n  delta c2,\n  congr',\n  swap 4, ext y, revert y, rw \u2190set.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 \u03b5 f hU hx' hy, },\nend\n\n/-- Given an `f \u2208 C(X, A)` and an `\u03b5 > 0`, one can find a locally constant function `b` which is in\n  an \u03b5-ball with center `f`, `b` is precisely `c2`. -/\ntheorem loc_const_dense' : \u2203 (b : C(X, A))\n  (H : b \u2208 set.range (@locally_constant.to_continuous_map X A _ _)),\n  dist f b < \u03b5 := \u27e8@locally_constant.to_continuous_map X A _ _ \u27e8c2 \u03b5 f, loc_const \u03b5 f\u27e9, \u27e8\u27e8c2 \u03b5 f, loc_const \u03b5 f\u27e9, rfl\u27e9,\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 `\u03b5/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 _ \u2265 dite _ _ _,\n    split_ifs with h,\n    { rcases h with \u27e8\u27e8_, x, _\u27e9, _\u27e9,\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 _ (\u03bb 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 \u2190hy,\n    -- reduced to proving \u2225f(y) - c2(y)\u2225 \u2264 \u03b5/2\n    obtain \u27e8w, wT, hw\u27e9 := finset_clopen_prop \u03b5 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 \u03b5 f y = f (c' \u03b5 f w \u27e8wT.1, \u27e8\u27e8y, wT.2\u27e9\u27e9\u27e9),\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 \u03b5 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 \u27e8U, hU, wU\u27e9 := exists_sub_S \u03b5 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 `\u03b5/4`-ball centered at `z`\n    have mem_U : f (c' \u03b5 f w \u27e8wT.1, \u27e8\u27e8y, wT.2\u27e9\u27e9\u27e9) \u2208 U :=\n      wU \u27e8(c' \u03b5 f w \u27e8wT.1, \u27e8\u27e8y, wT.2\u27e9\u27e9\u27e9), subtype.coe_prop _, rfl\u27e9,\n    have tS : f y \u2208 U := wU \u27e8y, wT.2, rfl\u27e9,\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 : \u03b5/2 = \u03b5/4 + \u03b5/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 \u2190norm_neg _, simp only [mem_U, neg_sub], },\nend \u27e9\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  \u03bb f, begin\n  rw metric.mem_closure_iff,\n  rintros \u03b5 h\u03b5,\n  haveI : fact (0 < \u03b5) := fact.mk h\u03b5,\n-- we have all the ingredients from `loc_const_dense'`, only need `exists_finset_univ_sub_prop`\n  apply loc_const_dense' \u03b5 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": "/-\n# The Real Number Game, version 1.0beta\n\n## By Kevin Buzzard, Dan Stanescu and Gavin Thomson\n\n# What is this game?\n\nWelcome to the real number game -- a game to help undergraduates learn analysis through Lean,\na formal proof verification system. Starting from the real numbers with its usual structure,\nwe develop the theory of bounds, least upper bounds and greatest lower bounds (sups and infs),\ninfinite sequences and infinite series. We develop the theory through problem-solving,\ngetting students to formalise proofs in the theory.\n\nThis game is a sequel to\n<a href=\"http://wwwf.imperial.ac.uk/~buzzard/xena/natural_number_game/\" target=\"blank\">the natural number game</a>.\nThe levels in the Real Number Game need to be solved using tactics. To learn how to use these tactics, I would\nrecommend that you first play the Natural Number Game up to at least \"Advanced Proposition world\". I will\nnot go through a careful explanation of the tactics taught by the natural number game here.\n\nBlue nodes on the graph are ones that you are ready to enter. Grey nodes you should stay away\nfrom -- try blue ones higher up the chain first. Green nodes are completed.\n\n# Thanks\n\nMany thanks to Mohammad Pedramfar, without whom this game would not exist.\n\nSeveral people contributed ideas and sometimes full proofs, most of which have found \ntheir place in the game in one way or another.\nThis aims at being a complete list eventually: Kenny Lau, Patrick Massot, Christopher Sumnicht, Aniruddh Agarwal.\n\n# Questions?\n\nYou can ask questions on the <a href=\"https://leanprover.zulipchat.com/\" target=\"blank\">Lean Zulip chat</a>,\nwhere I am often to be found. \n\nThe Real Number Game is brought to you by the Xena project, a project based at Imperial College London\nwhose aim is to get mathematics undergraduates using computer theorem provers.\nLean is a computer theorem prover being developed at Microsoft Research.\n\nProve a theorem. Write a function. <a href=\"https://twitter.com/XenaProject\" target=\"blank\">@XenaProject</a>.\n-/\n", "meta": {"author": "ImperialCollegeLondon", "repo": "real-number-game", "sha": "f9dcb7d9255a79b57e62038228a23346c2dc301b", "save_path": "github-repos/lean/ImperialCollegeLondon-real-number-game", "path": "github-repos/lean/ImperialCollegeLondon-real-number-game/real-number-game-f9dcb7d9255a79b57e62038228a23346c2dc301b/src/game/intro.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7122321842389469, "lm_q2_score": 0.6584174938590246, "lm_q1q2_score": 0.46894612979234646}}
{"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, +\u221e)` the same as it treats integrals over\n`[y, z]`. For example, the integral over `[1, +\u221e)` is **not** defined to be the limit of\nthe integral over `[1, x]` as `x` tends to `+\u221e`, which is known as an **improper integral**.\n\nIndeed, the \"proper\" definition is stronger than the \"improper\" one. The usual counterexample\nis `x \u21a6 sin(x)/x`, which has an improper integral over `[1, +\u221e)` 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 `\u03b9`, a\ncountably generated filter `l` over `\u03b9`, and an `\u03b9`-indexed family `\u03c6` of subsets of a measurable\nspace `\u03b1` equipped with a measure `\u03bc`, one should think of a hypothesis `h\u03c6 : ae_cover \u03bc l \u03c6` as\na sufficient condition for being able to interpret `\u222b x, f x \u2202\u03bc` (if it exists) as the limit\nof `\u222b x in \u03c6 i, f x \u2202\u03bc` 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 `(\u03bb x, Ioi x)`\nas an `ae_cover` w.r.t. `\u03bc.restrict (Iic b)`, instead of using `(\u03bb x, Ioc x b)`.\n\n## Main statements\n\n- `measure_theory.ae_cover.lintegral_tendsto_of_countably_generated` : if `\u03c6` is a `ae_cover \u03bc l`,\n  where `l` is a countably generated filter, and if `f` is a measurable `ennreal`-valued function,\n  then `\u222b\u207b x in \u03c6 n, f x \u2202\u03bc` tends to `\u222b\u207b x, f x \u2202\u03bc` as `n` tends to `l`\n- `measure_theory.ae_cover.integrable_of_integral_norm_tendsto` : if `\u03c6` is a `ae_cover \u03bc l`,\n  where `l` is a countably generated filter, if `f` is measurable and integrable on each `\u03c6 n`,\n  and if `\u222b x in \u03c6 n, \u2016f x\u2016 \u2202\u03bc` tends to some `I : \u211d` as n tends to `l`, then `f` is integrable\n- `measure_theory.ae_cover.integral_tendsto_of_countably_generated` : if `\u03c6` is a `ae_cover \u03bc l`,\n  where `l` is a countably generated filter, and if `f` is measurable and integrable (globally),\n  then `\u222b x in \u03c6 n, f x \u2202\u03bc` tends to `\u222b x, f x \u2202\u03bc` as `n` tends to `+\u221e`.\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 {\u03b1 \u03b9 : Type _} [MeasurableSpace \u03b1] (\u03bc : Measure \u03b1) (l : Filter \u03b9)\n\n/-- A sequence `\u03c6` of subsets of `\u03b1` is a `ae_cover` w.r.t. a measure `\u03bc` and a filter `l`\n    if almost every point (w.r.t. `\u03bc`) of `\u03b1` eventually belongs to `\u03c6 n` (w.r.t. `l`), and if\n    each `\u03c6 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    `\u222b x, f x \u2202\u03bc` (if it exists) as the limit of `\u222b x in \u03c6 n, f x \u2202\u03bc` 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 (\u03c6 : \u03b9 \u2192 Set \u03b1) : Prop where\n  ae_eventually_mem : \u2200\u1d50 x \u2202\u03bc, \u2200\u1da0 i in l, x \u2208 \u03c6 i\n  Measurable : \u2200 i, MeasurableSet <| \u03c6 i\n#align measure_theory.ae_cover MeasureTheory.AeCover\n\nvariable {\u03bc} {l}\n\nsection Preorder\u03b1\n\nvariable [Preorder \u03b1] [TopologicalSpace \u03b1] [OrderClosedTopology \u03b1] [OpensMeasurableSpace \u03b1]\n  {a b : \u03b9 \u2192 \u03b1} (ha : Tendsto a l atBot) (hb : Tendsto b l atTop)\n\ntheorem aeCoverIcc : AeCover \u03bc l fun i => Icc (a i) (b i) :=\n  { ae_eventually_mem :=\n      ae_of_all \u03bc fun x =>\n        (ha.Eventually <| eventually_le_atBot x).mp <|\n          (hb.Eventually <| eventually_ge_atTop x).mono fun i hbi hai => \u27e8hai, hbi\u27e9\n    Measurable := fun i => measurableSet_Icc }\n#align measure_theory.ae_cover_Icc MeasureTheory.aeCoverIcc\n\ntheorem aeCoverIci : AeCover \u03bc l fun i => Ici <| a i :=\n  { ae_eventually_mem :=\n      ae_of_all \u03bc 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 \u03bc l fun i => Iic <| b i :=\n  { ae_eventually_mem :=\n      ae_of_all \u03bc 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\u03b1\n\nsection LinearOrder\u03b1\n\nvariable [LinearOrder \u03b1] [TopologicalSpace \u03b1] [OrderClosedTopology \u03b1] [OpensMeasurableSpace \u03b1]\n  {a b : \u03b9 \u2192 \u03b1} (ha : Tendsto a l atBot) (hb : Tendsto b l atTop)\n\ntheorem aeCoverIoo [NoMinOrder \u03b1] [NoMaxOrder \u03b1] : AeCover \u03bc l fun i => Ioo (a i) (b i) :=\n  { ae_eventually_mem :=\n      ae_of_all \u03bc fun x =>\n        (ha.Eventually <| eventually_lt_atBot x).mp <|\n          (hb.Eventually <| eventually_gt_atTop x).mono fun i hbi hai => \u27e8hai, hbi\u27e9\n    Measurable := fun i => measurableSet_Ioo }\n#align measure_theory.ae_cover_Ioo MeasureTheory.aeCoverIoo\n\ntheorem aeCoverIoc [NoMinOrder \u03b1] : AeCover \u03bc l fun i => Ioc (a i) (b i) :=\n  { ae_eventually_mem :=\n      ae_of_all \u03bc fun x =>\n        (ha.Eventually <| eventually_lt_atBot x).mp <|\n          (hb.Eventually <| eventually_ge_atTop x).mono fun i hbi hai => \u27e8hai, hbi\u27e9\n    Measurable := fun i => measurableSet_Ioc }\n#align measure_theory.ae_cover_Ioc MeasureTheory.aeCoverIoc\n\ntheorem aeCoverIco [NoMaxOrder \u03b1] : AeCover \u03bc l fun i => Ico (a i) (b i) :=\n  { ae_eventually_mem :=\n      ae_of_all \u03bc fun x =>\n        (ha.Eventually <| eventually_le_atBot x).mp <|\n          (hb.Eventually <| eventually_gt_atTop x).mono fun i hbi hai => \u27e8hai, hbi\u27e9\n    Measurable := fun i => measurableSet_Ico }\n#align measure_theory.ae_cover_Ico MeasureTheory.aeCoverIco\n\ntheorem aeCoverIoi [NoMinOrder \u03b1] : AeCover \u03bc l fun i => Ioi <| a i :=\n  { ae_eventually_mem :=\n      ae_of_all \u03bc 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 \u03b1] : AeCover \u03bc l fun i => Iio <| b i :=\n  { ae_eventually_mem :=\n      ae_of_all \u03bc 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\u03b1\n\nsection FiniteIntervals\n\nvariable [LinearOrder \u03b1] [TopologicalSpace \u03b1] [OrderClosedTopology \u03b1] [OpensMeasurableSpace \u03b1]\n  {a b : \u03b9 \u2192 \u03b1} {A B : \u03b1} (ha : Tendsto a l (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B))\n\ntheorem aeCoverIooOfIcc : AeCover (\u03bc.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 \u03bc 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 => \u27e8hai, hbi\u27e9)\n    Measurable := fun i => measurableSet_Icc }\n#align measure_theory.ae_cover_Ioo_of_Icc MeasureTheory.aeCoverIooOfIcc\n\ntheorem aeCoverIooOfIco : AeCover (\u03bc.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 \u03bc 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 => \u27e8hai, hbi\u27e9)\n    Measurable := fun i => measurableSet_Ico }\n#align measure_theory.ae_cover_Ioo_of_Ico MeasureTheory.aeCoverIooOfIco\n\ntheorem aeCoverIooOfIoc : AeCover (\u03bc.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 \u03bc 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 => \u27e8hai, hbi\u27e9)\n    Measurable := fun i => measurableSet_Ioc }\n#align measure_theory.ae_cover_Ioo_of_Ioc MeasureTheory.aeCoverIooOfIoc\n\ntheorem aeCoverIooOfIoo : AeCover (\u03bc.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 \u03bc 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 => \u27e8hai, hbi\u27e9)\n    Measurable := fun i => measurableSet_Ioo }\n#align measure_theory.ae_cover_Ioo_of_Ioo MeasureTheory.aeCoverIooOfIoo\n\nvariable [HasNoAtoms \u03bc]\n\ntheorem aeCoverIocOfIcc (ha : Tendsto a l (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 (\ud835\udcdd A)) (hb : Tendsto b l (\ud835\udcdd B)) :\n    AeCover (\u03bc.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 {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {s : Set \u03b1} :\n    AeCover (\u03bc.restrict s) l \u03c6 :=\n  { ae_eventually_mem := ae_restrict_of_ae h\u03c6.ae_eventually_mem\n    Measurable := h\u03c6.Measurable }\n#align measure_theory.ae_cover.restrict MeasureTheory.AeCover.restrict\n\ntheorem aeCoverRestrictOfAeImp {s : Set \u03b1} {\u03c6 : \u03b9 \u2192 Set \u03b1} (hs : MeasurableSet s)\n    (ae_eventually_mem : \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 \u2200\u1da0 n in l, x \u2208 \u03c6 n)\n    (measurable : \u2200 n, MeasurableSet <| \u03c6 n) : AeCover (\u03bc.restrict s) l \u03c6 :=\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 {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {s : Set \u03b1}\n    (hs : MeasurableSet s) : AeCover (\u03bc.restrict s) l fun i => \u03c6 i \u2229 s :=\n  aeCoverRestrictOfAeImp hs\n    (h\u03c6.ae_eventually_mem.mono fun x hx hxs => hx.mono fun i hi => \u27e8hi, hxs\u27e9) fun i =>\n    (h\u03c6.Measurable i).inter hs\n#align measure_theory.ae_cover.inter_restrict MeasureTheory.AeCover.interRestrict\n\ntheorem AeCover.ae_tendsto_indicator {\u03b2 : Type _} [Zero \u03b2] [TopologicalSpace \u03b2] (f : \u03b1 \u2192 \u03b2)\n    {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) :\n    \u2200\u1d50 x \u2202\u03bc, Tendsto (fun i => (\u03c6 i).indicator f x) l (\ud835\udcdd <| f x) :=\n  h\u03c6.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 {\u03b2 : Type _} [MeasurableSpace \u03b2] [l.IsCountablyGenerated] [l.ne_bot]\n    {f : \u03b1 \u2192 \u03b2} {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6)\n    (hfm : \u2200 i, AeMeasurable f (\u03bc.restrict <| \u03c6 i)) : AeMeasurable f \u03bc :=\n  by\n  obtain \u27e8u, hu\u27e9 := l.exists_seq_tendsto\n  have := ae_measurable_Union_iff.mpr fun n : \u2115 => hfm (u n)\n  rwa [measure.restrict_eq_self_of_ae_mem] at this\n  filter_upwards [h\u03c6.ae_eventually_mem]with x hx using let \u27e8i, hi\u27e9 := (hu.eventually hx).exists\n    mem_Union.mpr \u27e8i, hi\u27e9\n#align measure_theory.ae_cover.ae_measurable MeasureTheory.AeCover.aeMeasurable\n\ntheorem AeCover.aeStronglyMeasurable {\u03b2 : Type _} [TopologicalSpace \u03b2] [PseudoMetrizableSpace \u03b2]\n    [l.IsCountablyGenerated] [l.ne_bot] {f : \u03b1 \u2192 \u03b2} {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6)\n    (hfm : \u2200 i, AeStronglyMeasurable f (\u03bc.restrict <| \u03c6 i)) : AeStronglyMeasurable f \u03bc :=\n  by\n  obtain \u27e8u, hu\u27e9 := l.exists_seq_tendsto\n  have := ae_strongly_measurable_Union_iff.mpr fun n : \u2115 => hfm (u n)\n  rwa [measure.restrict_eq_self_of_ae_mem] at this\n  filter_upwards [h\u03c6.ae_eventually_mem]with x hx using let \u27e8i, hi\u27e9 := (hu.eventually hx).exists\n    mem_Union.mpr \u27e8i, hi\u27e9\n#align measure_theory.ae_cover.ae_strongly_measurable MeasureTheory.AeCover.aeStronglyMeasurable\n\nend AeCover\n\ntheorem AeCover.compTendsto {\u03b1 \u03b9 \u03b9' : Type _} [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1} {l : Filter \u03b9}\n    {l' : Filter \u03b9'} {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {u : \u03b9' \u2192 \u03b9} (hu : Tendsto u l' l) :\n    AeCover \u03bc l' (\u03c6 \u2218 u) :=\n  { ae_eventually_mem := h\u03c6.ae_eventually_mem.mono fun x hx => hu.Eventually hx\n    Measurable := fun i => h\u03c6.Measurable (u i) }\n#align measure_theory.ae_cover.comp_tendsto MeasureTheory.AeCover.compTendsto\n\nsection AeCoverUnionInterCountable\n\nvariable {\u03b1 \u03b9 : Type _} [Countable \u03b9] [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1}\n\ntheorem AeCover.bUnionIicAeCover [Preorder \u03b9] {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc atTop \u03c6) :\n    AeCover \u03bc atTop fun n : \u03b9 => \u22c3 (k) (h : k \u2208 Iic n), \u03c6 k :=\n  { ae_eventually_mem :=\n      h\u03c6.ae_eventually_mem.mono fun x h => h.mono fun i hi => mem_bunion\u1d62 right_mem_Iic hi\n    Measurable := fun i => MeasurableSet.bunion\u1d62 (to_countable _) fun n _ => h\u03c6.Measurable n }\n#align measure_theory.ae_cover.bUnion_Iic_ae_cover MeasureTheory.AeCover.bUnionIicAeCover\n\ntheorem AeCover.bInterIciAeCover [SemilatticeSup \u03b9] [Nonempty \u03b9] {\u03c6 : \u03b9 \u2192 Set \u03b1}\n    (h\u03c6 : AeCover \u03bc atTop \u03c6) : AeCover \u03bc atTop fun n : \u03b9 => \u22c2 (k) (h : k \u2208 Ici n), \u03c6 k :=\n  { ae_eventually_mem :=\n      h\u03c6.ae_eventually_mem.mono\n        (by\n          intro x h\n          rw [eventually_at_top] at *\n          rcases h with \u27e8i, hi\u27e9\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\u1d62 (to_countable _) fun n _ => h\u03c6.Measurable n }\n#align measure_theory.ae_cover.bInter_Ici_ae_cover MeasureTheory.AeCover.bInterIciAeCover\n\nend AeCoverUnionInterCountable\n\nsection Lintegral\n\nvariable {\u03b1 \u03b9 : Type _} [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1} {l : Filter \u03b9}\n\nprivate theorem lintegral_tendsto_of_monotone_of_nat {\u03c6 : \u2115 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc atTop \u03c6)\n    (hmono : Monotone \u03c6) {f : \u03b1 \u2192 \u211d\u22650\u221e} (hfm : AeMeasurable f \u03bc) :\n    Tendsto (fun i => \u222b\u207b x in \u03c6 i, f x \u2202\u03bc) atTop (\ud835\udcdd <| \u222b\u207b x, f x \u2202\u03bc) :=\n  let F n := (\u03c6 n).indicator f\n  have key\u2081 : \u2200 n, AeMeasurable (F n) \u03bc := fun n => hfm.indicator (h\u03c6.Measurable n)\n  have key\u2082 : \u2200\u1d50 x : \u03b1 \u2202\u03bc, 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\u2083 : \u2200\u1d50 x : \u03b1 \u2202\u03bc, Tendsto (fun n => F n x) atTop (\ud835\udcdd (f x)) := h\u03c6.ae_tendsto_indicator f\n  (lintegral_tendsto_of_tendsto_of_monotone key\u2081 key\u2082 key\u2083).congr fun n =>\n    lintegral_indicator f (h\u03c6.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 {\u03c6 : \u2115 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc atTop \u03c6) {f : \u03b1 \u2192 \u211d\u22650\u221e}\n    (hfm : AeMeasurable f \u03bc) : Tendsto (fun i => \u222b\u207b x in \u03c6 i, f x \u2202\u03bc) atTop (\ud835\udcdd <| \u222b\u207b x, f x \u2202\u03bc) :=\n  by\n  have lim\u2081 :=\n    lintegral_tendsto_of_monotone_of_nat h\u03c6.bInter_Ici_ae_cover\n      (fun i j hij => bInter_subset_bInter_left (Ici_subset_Ici.mpr hij)) hfm\n  have lim\u2082 :=\n    lintegral_tendsto_of_monotone_of_nat h\u03c6.bUnion_Iic_ae_cover\n      (fun i j hij => bUnion_subset_bUnion_left (Iic_subset_Iic.mpr hij)) hfm\n  have le\u2081 := fun n => lintegral_mono_set (bInter_subset_of_mem left_mem_Ici)\n  have le\u2082 := fun n => lintegral_mono_set (subset_bUnion_of_mem right_mem_Iic)\n  exact tendsto_of_tendsto_of_tendsto_of_le_of_le lim\u2081 lim\u2082 le\u2081 le\u2082\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] {\u03c6 : \u03b9 \u2192 Set \u03b1}\n    (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 \u211d\u22650\u221e} (hfm : AeMeasurable f \u03bc) :\n    Tendsto (fun i => \u222b\u207b x in \u03c6 i, f x \u2202\u03bc) l (\ud835\udcdd <| \u222b\u207b x, f x \u2202\u03bc) :=\n  tendsto_of_seq_tendsto fun u hu => (h\u03c6.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] {\u03c6 : \u03b9 \u2192 Set \u03b1}\n    (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 \u211d\u22650\u221e} (I : \u211d\u22650\u221e) (hfm : AeMeasurable f \u03bc)\n    (htendsto : Tendsto (fun i => \u222b\u207b x in \u03c6 i, f x \u2202\u03bc) l (\ud835\udcdd I)) : (\u222b\u207b x, f x \u2202\u03bc) = I :=\n  tendsto_nhds_unique (h\u03c6.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\u1d62_lintegral_eq_of_countably_generated [Nonempty \u03b9] [l.ne_bot]\n    [l.IsCountablyGenerated] {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 \u211d\u22650\u221e}\n    (hfm : AeMeasurable f \u03bc) : (\u2a06 i : \u03b9, \u222b\u207b x in \u03c6 i, f x \u2202\u03bc) = \u222b\u207b x, f x \u2202\u03bc :=\n  by\n  have := h\u03c6.lintegral_tendsto_of_countably_generated hfm\n  refine'\n    csup\u1d62_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 \u27e8m, hm\u2081, hm\u2082\u27e9\n  rcases(eventually_ge_of_tendsto_gt hm\u2082 this).exists with \u27e8i, hi\u27e9\n  exact \u27e8i, lt_of_lt_of_le hm\u2081 hi\u27e9\n#align measure_theory.ae_cover.supr_lintegral_eq_of_countably_generated MeasureTheory.AeCover.sup\u1d62_lintegral_eq_of_countably_generated\n\nend Lintegral\n\nsection Integrable\n\nvariable {\u03b1 \u03b9 E : Type _} [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1} {l : Filter \u03b9} [NormedAddCommGroup E]\n\ntheorem AeCover.integrableOfLintegralNnnormBounded [l.ne_bot] [l.IsCountablyGenerated]\n    {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 E} (I : \u211d) (hfm : AeStronglyMeasurable f \u03bc)\n    (hbounded : \u2200\u1da0 i in l, (\u222b\u207b x in \u03c6 i, \u2016f x\u2016\u208a \u2202\u03bc) \u2264 ENNReal.ofReal I) : Integrable f \u03bc :=\n  by\n  refine' \u27e8hfm, (le_of_tendsto _ hbounded).trans_lt ENNReal.ofReal_lt_top\u27e9\n  exact h\u03c6.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    {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 E} (I : \u211d) (hfm : AeStronglyMeasurable f \u03bc)\n    (htendsto : Tendsto (fun i => \u222b\u207b x in \u03c6 i, \u2016f x\u2016\u208a \u2202\u03bc) l (\ud835\udcdd <| ENNReal.ofReal I)) :\n    Integrable f \u03bc :=\n  by\n  refine' h\u03c6.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    {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 E} (I : \u211d\u22650) (hfm : AeStronglyMeasurable f \u03bc)\n    (hbounded : \u2200\u1da0 i in l, (\u222b\u207b x in \u03c6 i, \u2016f x\u2016\u208a \u2202\u03bc) \u2264 I) : Integrable f \u03bc :=\n  h\u03c6.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    {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 E} (I : \u211d\u22650) (hfm : AeStronglyMeasurable f \u03bc)\n    (htendsto : Tendsto (fun i => \u222b\u207b x in \u03c6 i, \u2016f x\u2016\u208a \u2202\u03bc) l (\ud835\udcdd I)) : Integrable f \u03bc :=\n  h\u03c6.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] {\u03c6 : \u03b9 \u2192 Set \u03b1}\n    (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 E} (I : \u211d) (hfi : \u2200 i, IntegrableOn f (\u03c6 i) \u03bc)\n    (hbounded : \u2200\u1da0 i in l, (\u222b x in \u03c6 i, \u2016f x\u2016 \u2202\u03bc) \u2264 I) : Integrable f \u03bc :=\n  by\n  have hfm : ae_strongly_measurable f \u03bc :=\n    h\u03c6.ae_strongly_measurable fun i => (hfi i).AeStronglyMeasurable\n  refine' h\u03c6.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 [\u2190 coe_nnnorm]\n    rw [ENNReal.ofReal_coe_nnreal]\n  refine' hbounded.mono fun i hi => _\n  rw [\u2190 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] {\u03c6 : \u03b9 \u2192 Set \u03b1}\n    (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 E} (I : \u211d) (hfi : \u2200 i, IntegrableOn f (\u03c6 i) \u03bc)\n    (htendsto : Tendsto (fun i => \u222b x in \u03c6 i, \u2016f x\u2016 \u2202\u03bc) l (\ud835\udcdd I)) : Integrable f \u03bc :=\n  let \u27e8I', hI'\u27e9 := htendsto.isBoundedUnder_le\n  h\u03c6.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    {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 \u211d} (I : \u211d) (hfi : \u2200 i, IntegrableOn f (\u03c6 i) \u03bc)\n    (hnng : \u2200\u1d50 x \u2202\u03bc, 0 \u2264 f x) (hbounded : \u2200\u1da0 i in l, (\u222b x in \u03c6 i, f x \u2202\u03bc) \u2264 I) : Integrable f \u03bc :=\n  h\u03c6.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    {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 \u211d} (I : \u211d) (hfi : \u2200 i, IntegrableOn f (\u03c6 i) \u03bc)\n    (hnng : \u2200\u1d50 x \u2202\u03bc, 0 \u2264 f x) (htendsto : Tendsto (fun i => \u222b x in \u03c6 i, f x \u2202\u03bc) l (\ud835\udcdd I)) :\n    Integrable f \u03bc :=\n  let \u27e8I', hI'\u27e9 := htendsto.isBoundedUnder_le\n  h\u03c6.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 {\u03b1 \u03b9 E : Type _} [MeasurableSpace \u03b1] {\u03bc : Measure \u03b1} {l : Filter \u03b9} [NormedAddCommGroup E]\n  [NormedSpace \u211d E] [CompleteSpace E]\n\ntheorem AeCover.integral_tendsto_of_countably_generated [l.IsCountablyGenerated] {\u03c6 : \u03b9 \u2192 Set \u03b1}\n    (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 E} (hfi : Integrable f \u03bc) :\n    Tendsto (fun i => \u222b x in \u03c6 i, f x \u2202\u03bc) l (\ud835\udcdd <| \u222b x, f x \u2202\u03bc) :=\n  suffices h : Tendsto (fun i => \u222b x : \u03b1, (\u03c6 i).indicator f x \u2202\u03bc) l (\ud835\udcdd (\u222b x : \u03b1, f x \u2202\u03bc)) from\n    by\n    convert h\n    ext n\n    rw [integral_indicator (h\u03c6.measurable n)]\n  tendsto_integral_filter_of_dominated_convergence (fun x => \u2016f x\u2016)\n    (eventually_of_forall fun i => hfi.AeStronglyMeasurable.indicator <| h\u03c6.Measurable i)\n    (eventually_of_forall fun i => ae_of_all _ fun x => norm_indicator_le_norm_self _ _) hfi.norm\n    (h\u03c6.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] {\u03c6 : \u03b9 \u2192 Set \u03b1}\n    (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 E} (I : E) (hfi : Integrable f \u03bc)\n    (h : Tendsto (fun n => \u222b x in \u03c6 n, f x \u2202\u03bc) l (\ud835\udcdd I)) : (\u222b x, f x \u2202\u03bc) = I :=\n  tendsto_nhds_unique (h\u03c6.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    {\u03c6 : \u03b9 \u2192 Set \u03b1} (h\u03c6 : AeCover \u03bc l \u03c6) {f : \u03b1 \u2192 \u211d} (I : \u211d) (hnng : 0 \u2264\u1d50[\u03bc] f)\n    (hfi : \u2200 n, IntegrableOn f (\u03c6 n) \u03bc) (htendsto : Tendsto (fun n => \u222b x in \u03c6 n, f x \u2202\u03bc) l (\ud835\udcdd I)) :\n    (\u222b x, f x \u2202\u03bc) = I :=\n  have hfi' : Integrable f \u03bc := h\u03c6.integrableOfIntegralTendstoOfNonnegAe I hfi hnng htendsto\n  h\u03c6.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 {\u03b9 E : Type _} {\u03bc : Measure \u211d} {l : Filter \u03b9} [Filter.NeBot l] [IsCountablyGenerated l]\n  [NormedAddCommGroup E] {a b : \u03b9 \u2192 \u211d} {f : \u211d \u2192 E}\n\ntheorem integrableOfIntervalIntegralNormBounded (I : \u211d)\n    (hfi : \u2200 i, IntegrableOn f (Ioc (a i) (b i)) \u03bc) (ha : Tendsto a l atBot)\n    (hb : Tendsto b l atTop) (h : \u2200\u1da0 i in l, (\u222b x in a i..b i, \u2016f x\u2016 \u2202\u03bc) \u2264 I) : Integrable f \u03bc :=\n  by\n  have h\u03c6 : ae_cover \u03bc l _ := ae_cover_Ioc ha hb\n  refine' h\u03c6.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 [\u2190 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 -\u221e and `b i` tends to \u221e, and\n`\u222b x in a i .. b i, \u2016f x\u2016 \u2202\u03bc` converges to `I : \u211d` along a filter `l`,\nthen `f` is integrable on the interval (-\u221e, \u221e) -/\ntheorem integrableOfIntervalIntegralNormTendsto (I : \u211d)\n    (hfi : \u2200 i, IntegrableOn f (Ioc (a i) (b i)) \u03bc) (ha : Tendsto a l atBot)\n    (hb : Tendsto b l atTop) (h : Tendsto (fun i => \u222b x in a i..b i, \u2016f x\u2016 \u2202\u03bc) l (\ud835\udcdd I)) :\n    Integrable f \u03bc :=\n  let \u27e8I', hI'\u27e9 := 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 : \u211d)\n    (hfi : \u2200 i, IntegrableOn f (Ioc (a i) b) \u03bc) (ha : Tendsto a l atBot)\n    (h : \u2200\u1da0 i in l, (\u222b x in a i..b, \u2016f x\u2016 \u2202\u03bc) \u2264 I) : IntegrableOn f (Iic b) \u03bc :=\n  by\n  have h\u03c6 : ae_cover (\u03bc.restrict <| Iic b) l _ := ae_cover_Ioi ha\n  have hfi : \u2200 i, integrable_on f (Ioi (a i)) (\u03bc.restrict <| Iic b) :=\n    by\n    intro i\n    rw [integrable_on, measure.restrict_restrict (h\u03c6.measurable i)]\n    exact hfi i\n  refine' h\u03c6.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\u03c6.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 -\u221e, and\n`\u222b x in a i .. b, \u2016f x\u2016 \u2202\u03bc` converges to `I : \u211d` along a filter `l`,\nthen `f` is integrable on the interval (-\u221e, b) -/\ntheorem integrableOnIicOfIntervalIntegralNormTendsto (I b : \u211d)\n    (hfi : \u2200 i, IntegrableOn f (Ioc (a i) b) \u03bc) (ha : Tendsto a l atBot)\n    (h : Tendsto (fun i => \u222b x in a i..b, \u2016f x\u2016 \u2202\u03bc) l (\ud835\udcdd I)) : IntegrableOn f (Iic b) \u03bc :=\n  let \u27e8I', hI'\u27e9 := 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 : \u211d)\n    (hfi : \u2200 i, IntegrableOn f (Ioc a (b i)) \u03bc) (hb : Tendsto b l atTop)\n    (h : \u2200\u1da0 i in l, (\u222b x in a..b i, \u2016f x\u2016 \u2202\u03bc) \u2264 I) : IntegrableOn f (Ioi a) \u03bc :=\n  by\n  have h\u03c6 : ae_cover (\u03bc.restrict <| Ioi a) l _ := ae_cover_Iic hb\n  have hfi : \u2200 i, integrable_on f (Iic (b i)) (\u03bc.restrict <| Ioi a) :=\n    by\n    intro i\n    rw [integrable_on, measure.restrict_restrict (h\u03c6.measurable i), inter_comm]\n    exact hfi i\n  refine' h\u03c6.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\u03c6.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 \u221e, and\n`\u222b x in a .. b i, \u2016f x\u2016 \u2202\u03bc` converges to `I : \u211d` along a filter `l`,\nthen `f` is integrable on the interval (a, \u221e) -/\ntheorem integrableOnIoiOfIntervalIntegralNormTendsto (I a : \u211d)\n    (hfi : \u2200 i, IntegrableOn f (Ioc a (b i)) \u03bc) (hb : Tendsto b l atTop)\n    (h : Tendsto (fun i => \u222b x in a..b i, \u2016f x\u2016 \u2202\u03bc) l (\ud835\udcdd <| I)) : IntegrableOn f (Ioi a) \u03bc :=\n  let \u27e8I', hI'\u27e9 := 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\u2080 b\u2080 : \u211d}\n    (hfi : \u2200 i, IntegrableOn f <| Ioc (a i) (b i)) (ha : Tendsto a l <| \ud835\udcdd a\u2080)\n    (hb : Tendsto b l <| \ud835\udcdd b\u2080) (h : \u2200\u1da0 i in l, (\u222b x in Ioc (a i) (b i), \u2016f x\u2016) \u2264 I) :\n    IntegrableOn f (Ioc a\u2080 b\u2080) :=\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  \u00b7 apply ae_of_all\n    simp only [Pi.zero_apply, norm_nonneg, forall_const]\n  \u00b7 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\u2080 b : \u211d}\n    (hfi : \u2200 i, IntegrableOn f <| Ioc (a i) b) (ha : Tendsto a l <| \ud835\udcdd a\u2080)\n    (h : \u2200\u1da0 i in l, (\u222b x in Ioc (a i) b, \u2016f x\u2016) \u2264 I) : IntegrableOn f (Ioc a\u2080 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\u2080 : \u211d}\n    (hfi : \u2200 i, IntegrableOn f <| Ioc a (b i)) (hb : Tendsto b l <| \ud835\udcdd b\u2080)\n    (h : \u2200\u1da0 i in l, (\u222b x in Ioc a (b i), \u2016f x\u2016) \u2264 I) : IntegrableOn f (Ioc a b\u2080) :=\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 {\u03b9 E : Type _} {\u03bc : Measure \u211d} {l : Filter \u03b9} [IsCountablyGenerated l]\n  [NormedAddCommGroup E] [NormedSpace \u211d E] [CompleteSpace E] {a b : \u03b9 \u2192 \u211d} {f : \u211d \u2192 E}\n\ntheorem intervalIntegral_tendsto_integral (hfi : Integrable f \u03bc) (ha : Tendsto a l atBot)\n    (hb : Tendsto b l atTop) : Tendsto (fun i => \u222b x in a i..b i, f x \u2202\u03bc) l (\ud835\udcdd <| \u222b x, f x \u2202\u03bc) :=\n  by\n  let \u03c6 i := Ioc (a i) (b i)\n  have h\u03c6 : ae_cover \u03bc l \u03c6 := ae_cover_Ioc ha hb\n  refine' (h\u03c6.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 : \u211d) (hfi : IntegrableOn f (Iic b) \u03bc)\n    (ha : Tendsto a l atBot) :\n    Tendsto (fun i => \u222b x in a i..b, f x \u2202\u03bc) l (\ud835\udcdd <| \u222b x in Iic b, f x \u2202\u03bc) :=\n  by\n  let \u03c6 i := Ioi (a i)\n  have h\u03c6 : ae_cover (\u03bc.restrict <| Iic b) l \u03c6 := ae_cover_Ioi ha\n  refine' (h\u03c6.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\u03c6.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 : \u211d) (hfi : IntegrableOn f (Ioi a) \u03bc)\n    (hb : Tendsto b l atTop) :\n    Tendsto (fun i => \u222b x in a..b i, f x \u2202\u03bc) l (\ud835\udcdd <| \u222b x in Ioi a, f x \u2202\u03bc) :=\n  by\n  let \u03c6 i := Iic (b i)\n  have h\u03c6 : ae_cover (\u03bc.restrict <| Ioi a) l \u03c6 := ae_cover_Iic hb\n  refine' (h\u03c6.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\u03c6.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 _} {\u03bc : Measure \u211d} {f : \u211d \u2192 E} [NormedAddCommGroup E] [NormedSpace \u211d 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' : \u211d \u2192 \u211d} {g : \u211d \u2192 E} {a : \u211d}\n    (hf : ContinuousOn f <| Ici a) (hft : Tendsto f atTop atTop)\n    (hff' : \u2200 x \u2208 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 \u2022 (g \u2218 f) x) (Ici a)) :\n    (\u222b x in Ioi a, f' x \u2022 (g \u2218 f) x) = \u222b u in Ioi (f a), g u :=\n  by\n  have eq : \u2200 b : \u211d, a < b \u2192 (\u222b x in a..b, f' x \u2022 (g \u2218 f) x) = \u222b u in f a..f b, g u :=\n    by\n    intro b hb\n    have i1 : Ioo (min a b) (max a b) \u2286 Ioi a :=\n      by\n      rw [min_eq_left hb.le]\n      exact Ioo_subset_Ioi_self\n    have i2 : [a, b] \u2286 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    \u00b7 rw [min_eq_left hb.le]\n      exact Ioo_subset_Ioi_self\n    \u00b7 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) \u2286 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' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {a : \u211d}\n    (hf : ContinuousOn f <| Ici a) (hft : Tendsto f atTop atTop)\n    (hff' : \u2200 x \u2208 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 \u2218 f) x * f' x) (Ici a)) :\n    (\u222b x in Ioi a, (g \u2218 f) x * f' x) = \u222b u in Ioi (f a), g u :=\n  by\n  have hg2' : integrable_on (fun x => f' x \u2022 (g \u2218 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 : \u211d \u2192 E) {p : \u211d} (hp : p \u2260 0) :\n    (\u222b x in Ioi 0, (|p| * x ^ (p - 1)) \u2022 g (x ^ p)) = \u222b y in Ioi 0, g y :=\n  by\n  let S := Ioi (0 : \u211d)\n  have a1 : \u2200 x : \u211d, x \u2208 S \u2192 HasDerivWithinAt (fun t : \u211d => 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 : \u211d => x ^ p) S :=\n    by\n    rcases lt_or_gt_of_ne hp with \u27e8\u27e9\n    \u00b7 apply StrictAntiOn.injOn\n      intro x hx y hy hxy\n      rw [\u2190 inv_lt_inv (rpow_pos_of_pos hx p) (rpow_pos_of_pos hy p), \u2190 rpow_neg (le_of_lt hx), \u2190\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 : \u211d => t ^ p) '' S = S := by\n    ext1\n    rw [mem_image]\n    constructor\n    \u00b7 rintro \u27e8y, hy, rfl\u27e9\n      exact rpow_pos_of_pos hy p\n    \u00b7 intro hx\n      refine' \u27e8x ^ (1 / p), rpow_pos_of_pos hx _, _\u27e9\n      rw [\u2190 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 : \u211d \u2192 E} {p : \u211d} (hp : 0 < p) :\n    (\u222b x in Ioi 0, (p * x ^ (p - 1)) \u2022 g (x ^ p)) = \u222b 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 \u2192+* L) (a : K) (n : \u2124) : 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 : \u2124) :\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 : \u2124) :\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 \u2264 a) (z : \u2124) :\n    0 \u2264 a ^ z :=\n  int.cases_on z (fun (z : \u2115) => idRhs (0 \u2264 a ^ z) (pow_nonneg ha z))\n    fun (z : \u2115) => idRhs (0 \u2264 (a ^ Nat.succ z\u207b\u00b9)) (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 : \u2124) :\n    0 < a ^ z :=\n  int.cases_on z (fun (z : \u2115) => idRhs (0 < a ^ z) (pow_pos ha z))\n    fun (z : \u2115) => idRhs (0 < (a ^ Nat.succ z\u207b\u00b9)) (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 \u2264 x) {a : \u2124} {b : \u2124}\n    (h : a \u2264 b) : x ^ a \u2264 x ^ b :=\n  sorry\n\ntheorem pow_le_max_of_min_le {K : Type u} [linear_ordered_field K] {x : K} (hx : 1 \u2264 x) {a : \u2124}\n    {b : \u2124} {c : \u2124} (h : min a b \u2264 c) : x ^ (-c) \u2264 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 \u2264 p) {z : \u2124}\n    (hz : z \u2264 0) : p ^ z \u2264 1 :=\n  sorry\n\ntheorem one_le_fpow_of_nonneg {K : Type u} [linear_ordered_field K] {p : K} (hp : 1 \u2264 p) {z : \u2124}\n    (hz : 0 \u2264 z) : 1 \u2264 p ^ z :=\n  sorry\n\ntheorem one_lt_pow {K : Type u_1} [linear_ordered_semiring K] {p : K} (hp : 1 < p) {n : \u2115} :\n    1 \u2264 n \u2192 1 < p ^ n :=\n  sorry\n\ntheorem one_lt_fpow {K : Type u_1} [linear_ordered_field K] {p : K} (hp : 1 < p) (z : \u2124) :\n    0 < z \u2192 1 < p ^ z :=\n  sorry\n\ntheorem nat.fpow_pos_of_pos {K : Type u_1} [linear_ordered_field K] {p : \u2115} (h : 0 < p) (n : \u2124) :\n    0 < \u2191p ^ n :=\n  sorry\n\ntheorem nat.fpow_ne_zero_of_pos {K : Type u_1} [linear_ordered_field K] {p : \u2115} (h : 0 < p)\n    (n : \u2124) : \u2191p ^ n \u2260 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 : \u2124) => 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 : \u2124}\n    {n : \u2124} : x ^ m < x ^ n \u2194 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 : \u2124}\n    {n : \u2124} : x ^ m \u2264 x ^ n \u2194 m \u2264 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 : \u2115) : 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 \u2264 b) (k : \u2115) : a / b ^ k \u2264 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\u2080 : 0 < x) (h\u2081 : x \u2260 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\u2080 : 0 < x) (h\u2081 : x \u2260 1)\n    {m : \u2124} {n : \u2124} : x ^ m = x ^ n \u2194 m = n :=\n  function.injective.eq_iff (fpow_injective h\u2080 h\u2081)\n\n@[simp] theorem rat.cast_fpow {K : Type u_1} [field K] [char_zero K] (q : \u211a) (n : \u2124) :\n    \u2191(q ^ n) = \u2191q ^ 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 \u27f6 U` is in `R`.\n-/\ndef coveringOfPresieve (U : Opens X) (R : Presieve U) : (\u03a3V, { f : V \u27f6 U // R f }) \u2192 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 : \u03a3V, { f : V \u27f6 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\u1d62_eq_of_mem_grothendieck (hR : Sieve.generate R \u2208 Opens.grothendieckTopology X U) :\n    sup\u1d62 (coveringOfPresieve U R) = U := by\n  apply le_antisymm\n  \u00b7 refine' sup\u1d62_le _\n    intro f\n    exact f.2.1.le\n  intro x hxU\n  rw [opens.mem_supr]\n  obtain \u27e8V, iVU, \u27e8W, iVW, iWU, hiWU, -\u27e9, hxV\u27e9 := hR x hxU\n  exact \u27e8\u27e8W, \u27e8iWU, hiWU\u27e9\u27e9, iVW.le hxV\u27e9\n#align Top.presheaf.covering_of_presieve.supr_eq_of_mem_grothendieck TopCat.Presheaf.coveringOfPresieve.sup\u1d62_eq_of_mem_grothendieck\n\nend CoveringOfPresieve\n\n/-- Given a family of opens `U : \u03b9 \u2192 opens X` and any open `Y : opens X`, we obtain a presieve\non `Y` by declaring that a morphism `f : V \u27f6 Y` is a member of the presieve if and only if\nthere exists an index `i : \u03b9` such that `V = U i`.\n-/\ndef presieveOfCoveringAux {\u03b9 : Type v} (U : \u03b9 \u2192 Opens X) (Y : Opens X) : Presieve Y := fun V f =>\n  \u2203 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 {\u03b9 : Type v} (U : \u03b9 \u2192 Opens X) : Presieve (sup\u1d62 U) :=\n  presieveOfCoveringAux U (sup\u1d62 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 \u27e8fun \u27e8\u27e8_, _, h\u27e9, rfl\u27e9 => by convert h, fun h => \u27e8\u27e8Z, f, h\u27e9, rfl\u27e9\u27e9\n#align Top.presheaf.covering_presieve_eq_self TopCat.Presheaf.covering_presieve_eq_self\n\nnamespace PresieveOfCovering\n\nvariable {\u03b9 : Type v} (U : \u03b9 \u2192 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) \u2208 Opens.grothendieckTopology X (sup\u1d62 U) :=\n  by\n  intro x hx\n  obtain \u27e8i, hxi\u27e9 := opens.mem_supr.mp hx\n  exact \u27e8U i, opens.le_supr U i, \u27e8U i, \ud835\udfd9 _, opens.le_supr U i, \u27e8i, rfl\u27e9, category.id_comp _\u27e9, hxi\u27e9\n#align Top.presheaf.presieve_of_covering.mem_grothendieck_topology TopCat.Presheaf.presieveOfCovering.mem_grothendieckTopology\n\n/-- An index `i : \u03b9` can be turned into a dependent pair `(V, f)`, where `V` is an open set and\n`f : V \u27f6 supr U` is a member of `presieve_of_covering U f`.\n-/\ndef homOfIndex (i : \u03b9) : \u03a3V, { f : V \u27f6 sup\u1d62 U // presieveOfCovering U f } :=\n  \u27e8U i, Opens.leSupr U i, i, rfl\u27e9\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 \u27f6 supr U` is a member of\n`presieve_of_covering U f` can be turned into an index `i : \u03b9`, such that `V = U i`.\n-/\ndef indexOfHom (f : \u03a3V, { f : V \u27f6 sup\u1d62 U // presieveOfCovering U f }) : \u03b9 :=\n  f.2.2.some\n#align Top.presheaf.presieve_of_covering.index_of_hom TopCat.Presheaf.presieveOfCovering.indexOfHom\n\ntheorem indexOfHom_spec (f : \u03a3V, { f : V \u27f6 sup\u1d62 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} {\u03b9 : Type _}\n\ntheorem coverDense_iff_isBasis [Category \u03b9] (B : \u03b9 \u2964 Opens X) :\n    CoverDense (Opens.grothendieckTopology X) B \u2194 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 \u27e8V, f, \u27e8i, f\u2081, f\u2082, hc\u27e9, hV\u27e9\n  exact \u27e8B.obj i, \u27e8i, rfl\u27e9, f\u2081.le hV, f\u2082.le\u27e9\n  intro hb; constructor; intro U x hx; rcases hb hx with \u27e8_, \u27e8i, rfl\u27e9, hx, hi\u27e9\n  exact \u27e8B.obj i, \u27e8\u27e8hi\u27e9\u27e9, \u27e8\u27e8i, \ud835\udfd9 _, \u27e8\u27e8hi\u27e9\u27e9, rfl\u27e9\u27e9, hx\u27e9\n#align Top.opens.cover_dense_iff_is_basis TopCat.Opens.coverDense_iff_isBasis\n\ntheorem coverDense_inducedFunctor {B : \u03b9 \u2192 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 \u27f6 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    \u27e8(opens.map f).obj V, eq_to_iso <| opens.ext <| Set.image_preimage_eq_of_subset fun x h => _\u27e9\n  obtain \u27e8_, _, rfl\u27e9 := i.le h\n  exact \u27e8_, rfl\u27e9\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 _ \u27e8x, hx, rfl\u27e9\n  obtain \u27e8V, i, hV, hxV\u27e9 := hU x hx\n  exact \u27e8_, hf.functor.map i, \u27e8_, i, \ud835\udfd9 _, hV, rfl\u27e9, Set.mem_image_of_mem f hxV\u27e9\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 \u22d9 F) :=\n  pullback_isSheaf_of_coverPreserving h.CompatiblePreserving h.IsOpenMap.CoverPreserving \u27e8_, hF\u27e9\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}} {\u03b9 : Type _} {B : \u03b9 \u2192 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 \u22a5)) :=\n  F.isTerminalOfBotCover \u22a5 (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 = \u22a5) :\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    `\u03b9` of `B`, with the induced category structure on `\u03b9`. -/\ndef restrictHomEquivHom : ((inducedFunctor B).op \u22d9 F \u27f6 (inducedFunctor B).op \u22d9 F'.1) \u2243 (F \u27f6 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 (\u03b1 : (inducedFunctor B).op \u22d9 F \u27f6 (inducedFunctor B).op \u22d9 F'.1) (i : \u03b9) :\n    (restrictHomEquivHom F F' h \u03b1).app (op (B i)) = \u03b1.app (op i) :=\n  by\n  nth_rw 2 [\u2190 (restrict_hom_equiv_hom F F' h).left_inv \u03b1]\n  rfl\n#align Top.sheaf.extend_hom_app TopCat.Sheaf.extend_hom_app\n\ninclude h\n\ntheorem hom_ext {\u03b1 \u03b2 : F \u27f6 F'.1} (he : \u2200 i, \u03b1.app (op (B i)) = \u03b2.app (op (B i))) : \u03b1 = \u03b2 :=\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 {\u03b1 \u03b2 : Type}\n\n/-\nRequires : qfree arg0\nEnsures : nqfree ret\n-/\ndef nnf (\u03b2) [@atom_type \u03b1 \u03b2] : fm \u03b1 \u2192 fm \u03b1 \n| (fm.true \u03b1) := \u22a4'  \n| (fm.false \u03b1) := \u22a5' \n| (fm.atom a) := A' a\n| (fm.not (fm.true \u03b1)) := \u22a5' \n| (fm.not (fm.false \u03b1)) := \u22a4' \n| (fm.not (fm.atom a)) := atom_type.neg \u03b2 a\n| (fm.not (fm.not p)) := nnf p\n| (fm.not (fm.or p q)) := fm.and (nnf (\u00ac' p)) (nnf (\u00ac' q))\n| (fm.not (fm.and p q)) := fm.or (nnf (\u00ac' p)) (nnf (\u00ac' q))\n| (fm.not (fm.ex p)) := \u22a5' -- 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) := \u22a5' -- Invalid input\n\nlemma nnf_exp_and [atom_type \u03b1 \u03b2] (p q : fm \u03b1) :\n@nnf \u03b1 \u03b2 _ (fm.and p q) = fm.and (@nnf \u03b1 \u03b2 _ p) (@nnf \u03b1 \u03b2 _ q) := \nby unfold nnf\n\nlemma nnf_exp_or [atom_type \u03b1 \u03b2] (p q : fm \u03b1) : \n@nnf \u03b1 \u03b2 _ (p \u2228' q) = (@nnf \u03b1 \u03b2 _ p \u2228' @nnf \u03b1 \u03b2 _ q) := by unfold nnf\n\nlemma nnf_exp_not_and [H : atom_type \u03b1 \u03b2] (p q : fm \u03b1) : \n@nnf \u03b1 \u03b2 _ (\u00ac' (p \u2227' q)) = (@nnf \u03b1 \u03b2 _ (\u00ac' p) \u2228' @nnf \u03b1 \u03b2 _ (\u00ac' q)) := \nby unfold nnf\n\nlemma nnf_exp_not_or [H : atom_type \u03b1 \u03b2] (p q : fm \u03b1) : \n@nnf \u03b1 \u03b2 _ (\u00ac' (p \u2228' q)) = (@nnf \u03b1 \u03b2 _ (\u00ac' p) \u2227' @nnf \u03b1 \u03b2 _ (\u00ac' q)) := \nby unfold nnf\n\nlemma nqfree_not_eq_nqfree [atom_type \u03b1 \u03b2] : \u2200 (p : fm \u03b1) (Hp : qfree p), \nnqfree (@nnf \u03b1 \u03b2 _ (\u00ac' p)) = nqfree (@nnf \u03b1 \u03b2 _  p) :=\n\u03bb p, fm.rec_on p \n  (\u03bb _, eq.refl _) \n  (\u03bb _, eq.refl _) \n  (\u03bb _ a, propext (iff.intro (\u03bb _, trivial) (\u03bb H, atom_type.neg_nqfree _ _)))\n  (\u03bb 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  (\u03bb 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  (\u03bb q Hq Hp, begin rewrite (Hq Hp), unfold nnf end) \n  (\u03bb _ _ Hp, \n    begin \n      unfold qfree at Hp,\n      cases Hp \n    end)\n\nlemma nnf_nqfree [atom_type \u03b1 \u03b2] : \n  \u2200 (p : fm \u03b1), qfree p \u2192 nqfree (@nnf \u03b1 \u03b2 _ p) := \n\u03bb p, fm.rec_on p  \n(\u03bb _, trivial) \n(\u03bb _, trivial) \n(\u03bb _ _, trivial) \n(\u03bb 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(\u03bb 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(\u03bb q, fm.rec_on q \n  (\u03bb _ _, trivial) \n  (\u03bb _ _, trivial) \n  (\u03bb _ _ _, by apply atom_type.neg_nqfree) \n  (\u03bb 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 (\u03bb _, (H1 H2)^.left) H2^.left) \n              (Hs (\u03bb _, (H1 H2)^.right) H2^.right)),\n    end) \n  (\u03bb 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 (\u03bb _, (H1 H2)^.left) H2^.left) \n              (Hs (\u03bb _, (H1 H2)^.right) H2^.right)),\n    end) \n  (\u03bb 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  (\u03bb _ _ _ Hr, by cases Hr)) \n(\u03bb _ _ 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 \u03b1 \u03b2] : \n  \u2200 {p : fm \u03b1}, fnormal \u03b2 p \u2192 fnormal \u03b2 (nnf \u03b2 p) \u2227 fnormal \u03b2 (nnf \u03b2 \u00ac' p)\n| (fm.true \u03b1) hnm := and.intro trivial trivial \n| (fm.false \u03b1) 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 \u03b1 \u03b2] {p : fm \u03b1} (h : fnormal \u03b2 p) : fnormal \u03b2 (nnf \u03b2 p) :=\n(nnf_prsv_normal_core h)^.elim_left\n\nlemma nnf_prsv_core [atom_type \u03b1 \u03b2] : \u2200 (p : fm \u03b1), qfree p \u2192 \n  (\u2200 (xs : list \u03b2), (I (@nnf \u03b1 \u03b2 _ p) xs \u2194 I p xs) \u2227 (I (@nnf \u03b1 \u03b2 _ \u00ac' p) xs \u2194 I (\u00ac' p) xs))   \n| (fm.true \u03b1)  Hp xs := by nnf_prsv_lit\n| (fm.false \u03b1) 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 \u03b1 \u03b2] (p : fm \u03b1) (Hp : qfree p) (xs : list \u03b2) : \nI (@nnf \u03b1 \u03b2 _ p) xs \u2194 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": "/-\nCopyright (c) 2021 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg\n-/\n\nimport Aesop\n\nset_option aesop.check.all true\n\nexample (P : \u03b1 \u2192 Prop) (a : \u03b1) (h : P a) : \u2203 a, P a := by\n  aesop\n\nexample (P : \u03b1 \u2192 \u03b2 \u2192 Prop) (a : \u03b1) (b : \u03b2) (h : P a b) : \u2203 a b, P a b := by\n  aesop\n\nexample (P : \u03b1 \u2192 Type) (a : \u03b1) (h : P a) : \u03a3 a, P a := by\n  aesop\n\nexample (P : \u03b1 \u2192 \u03b2 \u2192 Type) (a : \u03b1) (b : \u03b2) (h : P a b) : \u03a3 a b, P a b := by\n  aesop\n\nexample (P Q : \u03b1 \u2192 Prop) (hPQ : \u2200 a, P a \u2192 Q a) (a : \u03b1) (h : P a) : \u2203 a, Q a := by\n  aesop\n\nset_option linter.unusedVariables false in\nexample (P Q Dead R : \u03b1 \u2192 Prop)\n    (hPQ : \u2200 a, P a \u2192 Q a)\n    (hDeadR : \u2200 a, Dead a \u2192 R a)\n    (hQR : \u2200 a, Q a \u2192 R a)\n    (a : \u03b1) (h : P a) :\n    \u2203 a, R a := by\n  aesop\n\nexample (R : \u03b1 \u2192 \u03b1 \u2192 Prop) (R_trans : \u2200 x y z, R x y \u2192 R y z \u2192 R x z) (a b c d)\n    (hab : R a b) (hbc : R b c) (hcd : R c d) : R a d := by\n  aesop\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/Metas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.63341027751814, "lm_q1q2_score": 0.4688340480709456}}
{"text": "import .order .split_ifs\n\nnamespace rb\nuniverses u v w\ninductive col |Red|Black\ninductive node (k : Type u) (\u03b1 : Type v) : Type max u v\n|Leaf {}: node\n|Node (c:col) (l:node) (v:k\u00d7\u03b1) (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 \u2192 k \u2192 Prop)]\nvariables {\u03b1 : Type v}\n\ndef empty : node k \u03b1 := Leaf\ninstance : has_emptyc (node k \u03b1) := \u27e8empty\u27e9\n\ndef mk_black : node k \u03b1 \u2192 node k \u03b1\n|(Leaf) := Leaf\n|(Node _ l a r) := Node Black l a r\n\ndef mk_red : node k \u03b1 \u2192 node k \u03b1 \n|Leaf := Leaf\n|(Node _ l a r) := Node Red l a r\n\n@[simp] def lbal : node k \u03b1 \u2192 k\u00d7\u03b1 \u2192 node k \u03b1 \u2192 node k \u03b1\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 \u03b1) (x y v : k\u00d7\u03b1)\n\ndef rbal : node k \u03b1 \u2192 k\u00d7\u03b1 \u2192 node k \u03b1 \u2192 node k \u03b1\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 \u03b1 \u2192 k\u00d7\u03b1 \u2192 node k \u03b1 \u2192 node k \u03b1\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 \u03b1 \u2192 k\u00d7\u03b1 \u2192 node k \u03b1 \u2192 node k \u03b1\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 \u03b1 \u2192 k\u00d7\u03b1 \u2192 node k \u03b1 \u2192 node k \u03b1\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\u2081 (Bk b v\u2082 c)) v\u2083 r := Rd (lbal (mk_red a) v\u2081 b) v\u2082 (Bk c v\u2083 r)\n| l v r := Rd l v r /- impossible -/\n\ndef ins_aux (key : k) (a : \u03b1) : node k \u03b1 \u2192 node k \u03b1 \n|Leaf := Rd Leaf \u27e8key,a\u27e9 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 \u27e8key,a\u27e9 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 \u27e8key,a\u27e9 r -- B\n\ndef insert : k \u2192 \u03b1 \u2192 node k \u03b1 \u2192 node k \u03b1 := \n    \u03bb key x s, mk_black (ins_aux key x s)\ninstance : has_insert (k\u00d7\u03b1) (node k \u03b1) := \u27e8\u03bb \u27e8key,a\u27e9 t, insert key a t\u27e9 \n\n/--Used to get the `append` method to be well-founded-/\ninstance custom_wf : has_well_founded (node k \u03b1 \u00d7 node k \u03b1) := \nhas_well_founded_of_has_sizeof (node k \u03b1 \u00d7 node k \u03b1) \n\ndef append : (node k \u03b1 \u00d7 node k \u03b1) \u2192 node k \u03b1\n|\u27e8Leaf, r\u27e9 := r\n|\u27e8 l,  Leaf\u27e9  := l\n|\u27e8(Rd ll lx lr),(Rd rl rx rr) \u27e9 :=\n    match append \u27e8lr, rl\u27e9 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|\u27e8 (Bk ll lx lr) ,(Bk rl rx rr) \u27e9 :=\n    match append \u27e8lr, rl\u27e9 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|\u27e8(Rd ll lx lr), r\u27e9 :=  Rd ll lx (append \u27e8lr, r\u27e9)\n|\u27e8 l, (Rd rl rx rr)\u27e9 := Rd (append \u27e8l, rl\u27e9) rx rr\n\ndef erase_aux (key : k) : node k \u03b1 \u2192 node k \u03b1\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 \u27e8l, r\u27e9\n\ndef erase (key : k) (t : node k \u03b1) : node k \u03b1 := \nmk_black (erase_aux key t)\n\ndef pop_min_aux : node k \u03b1 \u2192 k\u00d7\u03b1 \u2192 node k \u03b1 \u2192 k \u00d7 \u03b1 \u00d7 node k \u03b1\n|Leaf \u27e8k,x\u27e9 r := \u27e8k,x,r\u27e9\n|(Node lc ll lx lr) y r :=\n    let \u27e8k,x,l\u27e9 := pop_min_aux ll lx lr in\n    match lc with\n    |Black := \u27e8k,x, lbalS l y r\u27e9\n    |Red := \u27e8k,x, Rd l y r\u27e9\n    end\n\n/-- Remove the minimal element and key from the table. -/\ndef pop_min : node k \u03b1 \u2192 option (k \u00d7 \u03b1 \u00d7 node k \u03b1)\n|Leaf := none\n|(Node _ l y r) :=\n    let \u27e8k,x,t\u27e9 := pop_min_aux l y r in\n    some \u27e8k,x, mk_black t\u27e9\n\ndef fold {\u03b2 : Type w} (f : k \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) : \u03b2 \u2192 node k \u03b1 \u2192 \u03b2 \n|b Leaf := b\n|b (Node _ l \u27e8k,a\u27e9 r) := fold (f k a $ fold b l) r\n\ndef mfold {T : Type u \u2192 Type u} [monad T] {\u03b2} \n  (f : k \u2192 \u03b1 \u2192 \u03b2 \u2192 T \u03b2) : \u03b2 \u2192 node k \u03b1 \u2192 T \u03b2\n|b Leaf := pure b\n|b (Node _ l \u27e8k,a\u27e9 r) := do\n    b \u2190 mfold b l,\n    b \u2190 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 \u03b1 \u2192 \u2115\n|Leaf := 0\n|(Rd l _ _ ) := height l\n|(Bk l _ _ ) := nat.succ $ height l\n\n\nnamespace treeify \n    def bogus : node k \u03b1 \u00d7 list (k\u00d7\u03b1) := \u27e8Leaf, []\u27e9\n    def treeify_t (k : Type u) (\u03b1 : Type v) : Type max u v := list (k\u00d7\u03b1) \u2192 (node k \u03b1 \u00d7 list (k\u00d7\u03b1))\n    def treeify_zero : treeify_t k \u03b1 := \u03bb acc, \u27e8Leaf, acc\u27e9\n    def treeify_one : treeify_t k \u03b1 \n    |(x::acc) := \u27e8Rd Leaf x Leaf, acc\u27e9\n    |_ := bogus\n    def treeify_cont (f g : treeify_t k \u03b1) : treeify_t k \u03b1 :=\n    \u03bb acc, match f acc with\n    |\u27e8l, x::acc\u27e9 := let \u27e8r, acc\u27e9 := g acc in \u27e8Bk l x r, acc\u27e9\n    |_ := bogus\n    end\n    def positive := list bool\n    def treeify_aux : bool \u2192 positive \u2192 treeify_t k \u03b1\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 \u2192 positive \n    |[] := [ff]\n    |(ff::tail) := tt::tail\n    |(tt::tail) := ff :: (succ tail)\n    def plength_aux : list \u03b1 \u2192 positive \u2192 positive\n    |[] p := p\n    |(_::t) p := plength_aux t $ succ p\n    def plength (l : list \u03b1) := plength_aux l []\nend treeify\n/--Take an __ordered__ list and convert it to a node tree.-/\ndef treeify (l : list (k\u00d7\u03b1)) : node k \u03b1 := \nprod.fst $ treeify.treeify_aux tt (treeify.plength l) l\n\ndef filter (p : k \u2192 \u03b1 \u2192 bool) : node k \u03b1 \u2192 node k \u03b1 := \ntreeify \u2218 fold (\u03bb key a l, ite (p key a) (\u27e8key,a\u27e9::l) l) []\n\ndef get (key:k) : node k \u03b1 \u2192 option \u03b1\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 \u03b1 \u2192 bool\n:= option.is_some \u2218 get key\n\ninstance : has_mem (k) (node k \u03b1) := \u27e8\u03bb key t, contains key t\u27e9\n\ndef min : node k \u03b1 \u2192 option (k\u00d7\u03b1)\n|Leaf := none\n|(Node _ l x _) := (min l) <|> some x\ndef max : node k \u03b1 \u2192 option (k\u00d7 \u03b1 ) \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 \u03b1 \u2192 node k \u03b1 \u2192 node k \u03b1 := fold insert\n\ndef table (k : Type u) : Type u := node k unit\n\ndef intersect (t\u2081 t\u2082 : table k) : table k :=\n    if height t\u2081 < height t\u2082 \n    then filter (\u03bb k _, contains k t\u2082) t\u2081\n    else filter (\u03bb k _, contains k t\u2081) t\u2082\ninstance : has_inter (table k) := \u27e8intersect\u27e9 \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) := \u27e8union\u27e9\n\n/--Remove all of the keys found in the table `r` from the dictionary `l`. -/\ndef subtract (l : node k \u03b1) (r : table k) : node k \u03b1 := fold (\u03bb k _ l, erase k l) l r\n--instance : has_sub (table k) := \u27e8subtract\u27e9\n\ndef map {\u03b2 : Type w} (f : \u03b1 \u2192 \u03b2) : node k \u03b1 \u2192 node k \u03b2\n|Leaf := Leaf\n|(Node c l \u27e8k,a\u27e9 r) := Node c (map l) \u27e8k, f a\u27e9 (map r)\ninstance : functor (node k) :=\n{ map := \u03bb _ _ f t, map f t\n}\ndef keys_of : (node k \u03b1) \u2192 table k := map (\u03bb a, \u27e8\u27e9)\nend node\n\nnamespace proofs\nopen nat node\nvariables {k : Type u} {\u03b1 : Type v}\nvariables [decidable_linear_order k]\ninductive is_rb : node k \u03b1 \u2192 col \u2192 nat \u2192 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\u2081 v r c\u2082 n} (rb_l : is_rb l c\u2081 n) (rb_r : is_rb r c\u2082 n) : is_rb(Bk l v r) Black (succ n)\n\ninductive mem (key:k) : node k \u03b1 \u2192 Prop\n|left {c l v r} : mem l \u2192 mem (Node c l v r)\n|mid {c l v r} : (v:k\u00d7\u03b1).1 = key \u2192 mem (Node c l v r)\n|right {c l v r} : mem r \u2192 mem (Node c l v r)\ninstance : has_mem (k) (node k \u03b1) := \u27e8mem\u27e9\nlemma leaf_empty {key : k} : key \u2209 (@Leaf k \u03b1) := \u03bb h, by cases h\n\ndef dominates (k\u2081 : k) (t : node k \u03b1) : Prop\n:= \u2200 k\u2082 \u2208 t, k\u2081 > k\u2082\ndef dominated_by (k\u2081 : k) (t : node k \u03b1) : Prop\n:= \u2200 k\u2082 \u2208 t, k\u2081 < k\u2082\ninfix ` \u22d7 `: 50 := dominates\ninfix ` \u22d6 `: 50 := dominated_by\n\ninductive ordered : node k \u03b1 \u2192 Prop\n|o_leaf {} : ordered (Leaf) \n|o_node {c l} {v:k\u00d7\u03b1} {r} (ol:ordered l) (vdl :  v.1 \u22d7 l) (rdv : v.1 \u22d6 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 \u03b1) \u2192 ordered l := begin intros, cases a, assumption end\nlemma ordered.or {c l v r} : ordered (Node c l v r : node k \u03b1) \u2192 ordered r := begin intros, cases a, assumption end\nopen ordered\n@[simp] def is_wf (t: node k \u03b1) :  Prop := (\u2203 n, is_rb t Black n) \u2227 ordered t\n\n\nvariables {key k\u2081 k\u2082 :k} {a:\u03b1} {v v\u2081 v\u2082 : k \u00d7 \u03b1} {l r t : node k \u03b1} {c : col}\n\n@[trans] lemma dominates.trans : k\u2081 > k\u2082 \u2192 k\u2082 \u22d7 t \u2192 k\u2081 \u22d7 t\n:= \u03bb p q k\u2083 kt, lt.trans (q _ kt) p \nlemma dominates.leaf : k\u2081 \u22d7 (@Leaf k \u03b1) := \u03bb k\u2082 kt, false.rec_on _ $ leaf_empty kt\nlemma dominates.node (hl : k\u2081 \u22d7 l) (hv : k\u2081 > v.1) (hr : k\u2081 \u22d7 r) : k\u2081 \u22d7 (Node c l v r)\n|k\u2082 (mem.left xl) := hl _ xl\n|k\u2082 (mem.mid xm) := xm \u25b8 hv\n|k\u2082 (mem.right xr) := hr _ xr\nlemma dominates.l : k\u2081 \u22d7 (Node c l v r) \u2192 k\u2081 \u22d7 l := \u03bb h k\u2082 hl, h k\u2082 (mem.left hl)\nlemma dominates.r : k\u2081 \u22d7 (Node c l v r) \u2192 k\u2081 \u22d7 r := \u03bb h k\u2082 hr, h k\u2082 (mem.right hr)\nlemma dominates.v : k\u2081 \u22d7 (Node c l v r) \u2192 k\u2081 > v.1 := \u03bb h, h v.1 $ mem.mid rfl\n@[trans] lemma dominated_by.trans : k\u2081 < k\u2082 \u2192 k\u2082 \u22d6 t \u2192 k\u2081 \u22d6 t\n:= \u03bb p q k\u2083 kt, lt.trans p (q _ kt)\nlemma dominated_by.leaf : k\u2081 \u22d6 (@Leaf k \u03b1) := \u03bb k\u2082 kt, false.rec_on _ $ leaf_empty kt\nlemma dominated_by.node (hl : k\u2081 \u22d6 l) (hv : k\u2081 < v.1) (hr : k\u2081 \u22d6 r) : k\u2081 \u22d6 (Node c l v r)\n|k\u2082 (mem.left xl) := hl _ xl\n|k\u2082 (mem.mid xm) := xm \u25b8 hv\n|k\u2082 (mem.right xr) := hr _ xr\nlemma dominated_by.l : k\u2081 \u22d6 (Node c l v r) \u2192 k\u2081 \u22d6 l := \u03bb h k\u2082 hl, h k\u2082 (mem.left hl)\nlemma dominated_by.r : k\u2081 \u22d6 (Node c l v r) \u2192 k\u2081 \u22d6 r := \u03bb h k\u2082 hr, h k\u2082 (mem.right hr)\nlemma dominated_by.v : k\u2081 \u22d6 (Node c l v r) \u2192 k\u2081 < v.1 := \u03bb h, h v.1 $ mem.mid rfl\n\ndef all_below := \u03bb (t\u2081 t\u2082 : node k \u03b1), \u2200 (k\u2081 \u2208 t\u2081) (k\u2082 \u2208 t\u2082), k\u2081 < k\u2082\ninfix ` \u228f `: 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 \u2190 tactic.to_expr pe,\n    s_l \u2190 get_simp_lemmas_or_default none,\n    e \u2190 simp_lemmas.dsimplify s_l [`rec_on, `cases_on] e {fail_if_unchanged := ff}, -- rewrite alternative definitions of recursion.\n    --e \u2190 whnf e,\n    (fn,args) \u2190 pure $ expr.get_app_fn_args e,\n    fn_name \u2190 pure $ expr.const_name fn,\n    env \u2190 get_env,\n    is_rec \u2190 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 \u2190 pure $ expr.app_arg e,\n    is_local \u2190 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 \u2192 tactic expr := \u03bb 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 \u2190 target >>= instantiate_mvars,\n     cand \u2190 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 \u27e8\u27e9,\n    --  args \u2190 pure $ expr.get_app_args e,\n    --  list.any_of args cases_on_variable\n    --tactic.dsimplify (\u03bb e, pure \u27e8e,tt\u27e9) (dsimp_post) t,\n    pure \u27e8\u27e9\n\n#check node.cases_on\n#check node.rec_on\n\nmeta def cases_all : expr \u2192 tactic (list expr) := \u03bb h,\ndo \n    --h \u2190 get_local h_name,\n    --trace h,\n    ty \u2190 infer_type h >>= instantiate_mvars >>= whnf,\n    --trace ty,\n    --[c] \u2190 get_constructors_for ty | pure [],\n    -- count the number of non-named arguments\n    [(case_name,new_hyps,new_subs)] \u2190 cases_core h | fail \"more than one constructor\",\n    list.mfoldl (\u03bb l h, list.append l <$> ((cases_all h) <|> (pure [h]))) [] new_hyps\n\nmeta def one_of : list (tactic unit) \u2192 tactic unit\n|(h::t) := h <|> one_of t\n|[] := skip\n\nmeta def apply_pexpr : pexpr \u2192 tactic unit :=\n\u03bb p, ((to_expr p) >>= apply) $> \u27e8\u27e9\n\ninductive growth : node k \u03b1 \u2192 nat \u2192 Prop\n|stay {c n t} : is_rb t c n \u2192 growth t n\n|sprout_l {n l v r} : is_rb l Red n \u2192 is_rb r Black n \u2192 growth (Rd l v r) n\n|sprout_r {n l v r} : is_rb l Black n \u2192 is_rb r Red n \u2192 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 \u03b1 \u2192 Prop} {q : Q r}\n    (c\u2081 : \u03a0  {b c d w z}, Q(Rd (Rd b w c) z d) \u2192 P(Rd (Bk l v b) w (Bk c z d)))\n    (c\u2082 : \u03a0  {b c d w z}, Q(Rd b w (Rd c z d)) \u2192 P(Rd (Bk l v b) w (Bk c z d)))\n    (c\u2083 : 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\u2081 q),\n            apply_pexpr ```(c\u2082 q),\n            apply_pexpr ```(c\u2083)  \n        ]},\n    end\n\n-- lemma ins_aux_ind {P Q : node k \u03b1 \u2192 Prop} (q : Q t)\n--     (c\u2081 : P(Rd Leaf \u27e8key,a\u27e9 Leaf))\n--     (c\u2082 : \u03a0 {l v r}, Q(Bk l v r) \u2192 key < v.1 \u2192 P(ins_aux key a l) \u2192 P(lbal (ins_aux key a l) v r))\n--     (c\u2083 : \u03a0 {l v r}, Q(Bk l v r) \u2192 key > v.1 \u2192 P(ins_aux key a r) \u2192 P(rbal l v (ins_aux key a r)))\n--     (c\u2084 : \u03a0 {l v r}, Q(Bk l v r) \u2192 key = v.1 \u2192 P(Bk l \u27e8key,a\u27e9 r))\n--     (c\u2085 : \u03a0 {l v r}, Q(Rd l v r) \u2192 key < v.1 \u2192 P(ins_aux key a l) \u2192 P(Rd (ins_aux key a l) v r))\n--     (c\u2086 : \u03a0 {l v r}, Q(Rd l v r) \u2192 key > v.1 \u2192 P(ins_aux key a r) \u2192 P(Rd l v (ins_aux key a r)))\n--     (c\u2087 : \u03a0 {l v r}, Q(Rd l v r) \u2192 key = v.1 \u2192 P(Rd l \u27e8key,a\u27e9 r))\n--     : P(ins_aux key a t) :=\n-- begin\n--   induction t with c l v r, apply c\u2081, cases c,\n--   simp [ins_aux],\n--   --expand ``ins_aux, simp, dsimp_target none [`id_rhs],\n--   focus {\n--       split_ifs, apply c\u2085 _ _ (t_ih_l _), repeat {assumption}, \n--   }\n\n-- end\n\nlemma rbal.ordered (ol : ordered l) (vdl : v.1 \u22d7 l) (rdv : v.1 \u22d6 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 \u2208 r) \u2192 (key \u2208 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 \u2192 growth r n \u2192 \u2203 c', is_rb (rbal l v r) c' (succ n) := \nbegin\n    intros lrb rrg,\n    apply @rbal_ind k _ _ _ _ _  (\u03bb t, \u2203 c', is_rb (t) c' (succ n)) (\u03bb 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} : (\u00ac a < b) \u2192 \u00ac(b < a) \u2192 a = b := \u03bb 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 \u2192 v.1 \u22d7 l \u2192 v.1 \u22d6 r \u2192 ordered r \u2192 ordered (lbal l v r) := sorry\nlemma lbal.mem : (key \u2208 l) \u2192 (key \u2208 lbal l v r) := sorry\nlemma lbal.rb {cl cr n} : is_rb l cl n \u2192 is_rb r cr n \u2192 \u2203 c', is_rb (lbal l v r) c' (succ n) := sorry\nlemma ins_aux.mem : (k\u2081 \u2208 ins_aux key a t) \u2194 (k\u2081 \u2208 t \u2228 k\u2081 = key) := sorry\nlemma ins_aux.is_rb {n} : is_rb t c n \u2192 \u2203 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\u2081 v r c\u2082 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 \u2192 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\u2081 ki,\n                have h\u2082 := ins_aux.mem.1 ki, cases h\u2082,\n                apply o_vdl, assumption,\n                cases h\u2082, assumption,\n            },\n            split_ifs, focus {\n                apply o_node, any_goals {assumption}, intros k\u2081 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\u2081 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\u2081 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 _ _ \u03b1) := sorry\n\nlemma insert_is_wf :is_wf t \u2192 is_wf (insert key a t) := sorry\nlemma insert_works :  is_wf t \u2192 get key (insert key a t) = some a := sorry\n\nlemma erase_is_wf : is_wf t \u2192 is_wf (erase key t) := sorry \nlemma erase_works : is_wf t \u2192 get key (erase key t) = none := sorry\n\n/- [TODO] from mathlib -/\ninductive sorted (R : \u03b1 \u2192 \u03b1 \u2192 Prop) : list \u03b1 \u2192 Prop\n|nil {} : sorted []\n|cons {a} {l:list \u03b1} : (\u2200 b\u2208l, R a b) \u2192 sorted l \u2192 sorted (a::l)\nlemma treeify_works : \u2200 {l : list (k\u00d7\u03b1)}, sorted ((<) on prod.fst) l \u2192 is_wf (treeify l) := sorry\nlemma filter_works {p} : is_wf t \u2192 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\u1d52\u1d56`\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\u1d52\u1d56) :=\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\u1d52\u1d56) :=\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] : \u21d1(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] : \u21d1(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] : \u21d1(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] : \u21d1(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* `\u03b5 : \ud835\udfd9_ D \u27f6 F.obj (\ud835\udfd9_ C)` (called the unit morphism)\n* `\u03bc X Y : (F.obj X) \u2297 (F.obj Y) \u27f6 F.obj (X \u2297 Y)` (called the tensorator, or strength).\nsatisfying various axioms.\n\nA monoidal functor is a lax monoidal functor for which `\u03b5` and `\u03bc` 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\n\nopen category_theory.category\nopen category_theory.functor\n\nnamespace category_theory\n\nsection\n\nopen monoidal_category\n\nvariables (C : Type u\u2081) [category.{v\u2081} C] [monoidal_category.{v\u2081} C]\n          (D : Type u\u2082) [category.{v\u2082} D] [monoidal_category.{v\u2082} D]\n\n/-- A lax monoidal functor is a functor `F : C \u2964 D` between monoidal categories,\nequipped with morphisms `\u03b5 : \ud835\udfd9 _D \u27f6 F.obj (\ud835\udfd9_ C)` and `\u03bc X Y : F.obj X \u2297 F.obj Y \u27f6 F.obj (X \u2297 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 \u2964 D :=\n-- unit morphism\n(\u03b5               : \ud835\udfd9_ D \u27f6 obj (\ud835\udfd9_ C))\n-- tensorator\n(\u03bc                : \u03a0 X Y : C, (obj X) \u2297 (obj Y) \u27f6 obj (X \u2297 Y))\n(\u03bc_natural'       : \u2200 {X Y X' Y' : C}\n  (f : X \u27f6 Y) (g : X' \u27f6 Y'),\n  ((map f) \u2297 (map g)) \u226b \u03bc Y Y' = \u03bc X X' \u226b map (f \u2297 g)\n  . obviously)\n-- associativity of the tensorator\n(associativity'   : \u2200 (X Y Z : C),\n    (\u03bc X Y \u2297 \ud835\udfd9 (obj Z)) \u226b \u03bc (X \u2297 Y) Z \u226b map (\u03b1_ X Y Z).hom\n  = (\u03b1_ (obj X) (obj Y) (obj Z)).hom \u226b (\ud835\udfd9 (obj X) \u2297 \u03bc Y Z) \u226b \u03bc X (Y \u2297 Z)\n  . obviously)\n-- unitality\n(left_unitality'  : \u2200 X : C,\n    (\u03bb_ (obj X)).hom\n  = (\u03b5 \u2297 \ud835\udfd9 (obj X)) \u226b \u03bc (\ud835\udfd9_ C) X \u226b map (\u03bb_ X).hom\n  . obviously)\n(right_unitality' : \u2200 X : C,\n    (\u03c1_ (obj X)).hom\n  = (\ud835\udfd9 (obj X) \u2297 \u03b5) \u226b \u03bc X (\ud835\udfd9_ C) \u226b map (\u03c1_ X).hom\n  . obviously)\n\nrestate_axiom lax_monoidal_functor.\u03bc_natural'\nattribute [simp, reassoc] lax_monoidal_functor.\u03bc_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.\u03bc_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  (\u03bb_ (F.obj X)).inv \u226b (F.\u03b5 \u2297 \ud835\udfd9 (F.obj X)) \u226b F.\u03bc (\ud835\udfd9_ C) X = F.map (\u03bb_ X).inv :=\nbegin\n  rw [iso.inv_comp_eq, F.left_unitality, category.assoc, category.assoc,\n    \u2190F.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  (\u03c1_ (F.obj X)).inv \u226b (\ud835\udfd9 (F.obj X) \u2297 F.\u03b5) \u226b F.\u03bc X (\ud835\udfd9_ C) = F.map (\u03c1_ X).inv :=\nbegin\n  rw [iso.inv_comp_eq, F.right_unitality, category.assoc, category.assoc,\n    \u2190F.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  (\ud835\udfd9 (F.obj X) \u2297 F.\u03bc Y Z) \u226b F.\u03bc X (Y \u2297 Z) \u226b F.map (\u03b1_ X Y Z).inv =\n    (\u03b1_ (F.obj X) (F.obj Y) (F.obj Z)).inv \u226b (F.\u03bc X Y \u2297 \ud835\udfd9 (F.obj Z)) \u226b F.\u03bc (X \u2297 Y) Z :=\nbegin\n  rw [iso.eq_inv_comp, \u2190F.associativity_assoc,\n    \u2190F.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\u2081 v\u2082} C D :=\n(\u03b5_is_iso            : is_iso \u03b5 . tactic.apply_instance)\n(\u03bc_is_iso            : \u03a0 X Y : C, is_iso (\u03bc X Y) . tactic.apply_instance)\n\nattribute [instance] monoidal_functor.\u03b5_is_iso monoidal_functor.\u03bc_is_iso\n\nvariables {C D}\n\n/--\nThe unit morphism of a (strong) monoidal functor as an isomorphism.\n-/\nnoncomputable\ndef monoidal_functor.\u03b5_iso (F : monoidal_functor.{v\u2081 v\u2082} C D) :\n  tensor_unit D \u2245 F.obj (tensor_unit C) :=\nas_iso F.\u03b5\n\n/--\nThe tensorator of a (strong) monoidal functor as an isomorphism.\n-/\nnoncomputable\ndef monoidal_functor.\u03bc_iso (F : monoidal_functor.{v\u2081 v\u2082} C D) (X Y : C) :\n  (F.obj X) \u2297 (F.obj Y) \u2245 F.obj (X \u2297 Y) :=\nas_iso (F.\u03bc X Y)\n\nend\n\nopen monoidal_category\n\nnamespace lax_monoidal_functor\n\nvariables (C : Type u\u2081) [category.{v\u2081} C] [monoidal_category.{v\u2081} C]\n\n/-- The identity lax monoidal functor. -/\n@[simps] def id : lax_monoidal_functor.{v\u2081 v\u2081} C C :=\n{ \u03b5 := \ud835\udfd9 _,\n  \u03bc := \u03bb X Y, \ud835\udfd9 _,\n  .. \ud835\udfed C }\n\ninstance : inhabited (lax_monoidal_functor C C) := \u27e8id C\u27e9\n\nend lax_monoidal_functor\n\nnamespace monoidal_functor\n\nsection\nvariables {C : Type u\u2081} [category.{v\u2081} C] [monoidal_category.{v\u2081} C]\nvariables {D : Type u\u2082} [category.{v\u2082} D] [monoidal_category.{v\u2082} D]\n\nlemma map_tensor (F : monoidal_functor.{v\u2081 v\u2082} C D) {X Y X' Y' : C} (f : X \u27f6 Y) (g : X' \u27f6 Y') :\n  F.map (f \u2297 g) = inv (F.\u03bc X X') \u226b ((F.map f) \u2297 (F.map g)) \u226b F.\u03bc Y Y' :=\nby simp\n\nlemma map_left_unitor (F : monoidal_functor.{v\u2081 v\u2082} C D) (X : C) :\n  F.map (\u03bb_ X).hom = inv (F.\u03bc (\ud835\udfd9_ C) X) \u226b (inv F.\u03b5 \u2297 \ud835\udfd9 (F.obj X)) \u226b (\u03bb_ (F.obj X)).hom :=\nbegin\n  simp only [lax_monoidal_functor.left_unitality],\n  slice_rhs 2 3 { rw \u2190comp_tensor_id, simp, },\n  simp,\nend\n\nlemma map_right_unitor (F : monoidal_functor.{v\u2081 v\u2082} C D) (X : C) :\n  F.map (\u03c1_ X).hom = inv (F.\u03bc X (\ud835\udfd9_ C)) \u226b (\ud835\udfd9 (F.obj X) \u2297 inv F.\u03b5) \u226b (\u03c1_ (F.obj X)).hom :=\nbegin\n  simp only [lax_monoidal_functor.right_unitality],\n  slice_rhs 2 3 { rw \u2190id_tensor_comp, simp, },\n  simp,\nend\n\n/-- The tensorator as a natural isomorphism. -/\nnoncomputable\ndef \u03bc_nat_iso (F : monoidal_functor.{v\u2081 v\u2082} C D) :\n  (functor.prod F.to_functor F.to_functor) \u22d9 (tensor D) \u2245 (tensor C) \u22d9 F.to_functor :=\nnat_iso.of_components\n  (by { intros, apply F.\u03bc_iso })\n  (by { intros, apply F.to_lax_monoidal_functor.\u03bc_natural })\nend\n\nsection\nvariables (C : Type u\u2081) [category.{v\u2081} C] [monoidal_category.{v\u2081} C]\n\n/-- The identity monoidal functor. -/\n@[simps] def id : monoidal_functor.{v\u2081 v\u2081} C C :=\n{ \u03b5 := \ud835\udfd9 _,\n  \u03bc := \u03bb X Y, \ud835\udfd9 _,\n  .. \ud835\udfed C }\n\ninstance : inhabited (monoidal_functor C C) := \u27e8id C\u27e9\n\nend\n\nend monoidal_functor\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] [monoidal_category.{v\u2081} C]\nvariables {D : Type u\u2082} [category.{v\u2082} D] [monoidal_category.{v\u2082} D]\nvariables {E : Type u\u2083} [category.{v\u2083} E] [monoidal_category.{v\u2083} E]\n\nnamespace lax_monoidal_functor\nvariables (F : lax_monoidal_functor.{v\u2081 v\u2082} C D) (G : lax_monoidal_functor.{v\u2082 v\u2083} 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\u2081 v\u2083} C E :=\n{ \u03b5                := G.\u03b5 \u226b (G.map F.\u03b5),\n  \u03bc                := \u03bb X Y, G.\u03bc (F.obj X) (F.obj Y) \u226b G.map (F.\u03bc X Y),\n  \u03bc_natural'       := \u03bb _ _ _ _ f g,\n  begin\n    simp only [functor.comp_map, assoc],\n    rw [\u2190category.assoc, lax_monoidal_functor.\u03bc_natural, category.assoc, \u2190map_comp, \u2190map_comp,\n        \u2190lax_monoidal_functor.\u03bc_natural]\n  end,\n  associativity'   := \u03bb X Y Z,\n  begin\n    dsimp,\n    rw id_tensor_comp,\n    slice_rhs 3 4 { rw [\u2190 G.to_functor.map_id, G.\u03bc_natural], },\n    slice_rhs 1 3 { rw \u2190G.associativity, },\n    rw comp_tensor_id,\n    slice_lhs 2 3 { rw [\u2190 G.to_functor.map_id, G.\u03bc_natural], },\n    rw [category.assoc, category.assoc, category.assoc, category.assoc, category.assoc,\n        \u2190G.to_functor.map_comp, \u2190G.to_functor.map_comp, \u2190G.to_functor.map_comp,\n        \u2190G.to_functor.map_comp, F.associativity],\n  end,\n  left_unitality'  := \u03bb 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, \u2190nat_trans.id_app, \u2190category.assoc,\n        \u2190lax_monoidal_functor.\u03bc_natural, nat_trans.id_app, map_id, \u2190category.assoc, map_comp],\n  end,\n  right_unitality' := \u03bb 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, \u2190nat_trans.id_app, \u2190category.assoc,\n        \u2190lax_monoidal_functor.\u03bc_natural, nat_trans.id_app, map_id, \u2190category.assoc, map_comp],\n  end,\n  .. (F.to_functor) \u22d9 (G.to_functor) }.\n\ninfixr ` \u2297\u22d9 `:80 := comp\n\nend lax_monoidal_functor\n\nnamespace monoidal_functor\n\nvariables (F : monoidal_functor.{v\u2081 v\u2082} C D) (G : monoidal_functor.{v\u2082 v\u2083} D E)\n\n/-- The composition of two monoidal functors is again monoidal. -/\n@[simps]\ndef comp : monoidal_functor.{v\u2081 v\u2083} C E :=\n{ \u03b5_is_iso := by { dsimp, apply_instance },\n  \u03bc_is_iso := by { dsimp, apply_instance },\n  .. (F.to_lax_monoidal_functor).comp (G.to_lax_monoidal_functor) }.\n\ninfixr ` \u2297\u22d9 `: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 \u2964 C} (h : F.to_functor \u22a3 G) :\n  lax_monoidal_functor D C :=\n{ to_functor := G,\n  \u03b5 := h.hom_equiv _ _ (inv F.\u03b5),\n  \u03bc := \u03bb X Y,\n    h.hom_equiv _ (X \u2297 Y) (inv (F.\u03bc (G.obj X) (G.obj Y)) \u226b (h.counit.app X \u2297 h.counit.app Y)),\n  \u03bc_natural' := \u03bb X Y X' Y' f g,\n  begin\n    rw [\u2190h.hom_equiv_naturality_left, \u2190h.hom_equiv_naturality_right, equiv.apply_eq_iff_eq, assoc,\n      is_iso.eq_inv_comp, \u2190F.to_lax_monoidal_functor.\u03bc_natural_assoc, is_iso.hom_inv_id_assoc,\n      \u2190tensor_comp, adjunction.counit_naturality, adjunction.counit_naturality, tensor_comp],\n  end,\n  associativity' := \u03bb X Y Z,\n  begin\n    rw [\u2190h.hom_equiv_naturality_right, \u2190h.hom_equiv_naturality_left, \u2190h.hom_equiv_naturality_left,\n      \u2190h.hom_equiv_naturality_left, equiv.apply_eq_iff_eq,\n      \u2190 cancel_epi (F.to_lax_monoidal_functor.\u03bc (G.obj X \u2297 G.obj Y) (G.obj Z)),\n      \u2190 cancel_epi (F.to_lax_monoidal_functor.\u03bc (G.obj X) (G.obj Y) \u2297 \ud835\udfd9 (F.obj (G.obj Z))),\n      F.to_lax_monoidal_functor.associativity_assoc (G.obj X) (G.obj Y) (G.obj Z),\n      \u2190F.to_lax_monoidal_functor.\u03bc_natural_assoc, assoc, is_iso.hom_inv_id_assoc,\n      \u2190F.to_lax_monoidal_functor.\u03bc_natural_assoc, is_iso.hom_inv_id_assoc, \u2190tensor_comp,\n      \u2190tensor_comp, id_comp, functor.map_id, functor.map_id, id_comp, \u2190tensor_comp_assoc,\n      \u2190tensor_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' := \u03bb X,\n  begin\n    rw [\u2190h.hom_equiv_naturality_right, \u2190h.hom_equiv_naturality_left, \u2190equiv.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, \u2190tensor_comp_assoc, functor.map_id, id_comp,\n      functor.map_comp, assoc, h.counit_naturality, h.left_triangle_components_assoc,\n      \u2190left_unitor_naturality, \u2190tensor_comp_assoc, id_comp, comp_id],\n  end,\n  right_unitality' := \u03bb X,\n  begin\n    rw [\u2190h.hom_equiv_naturality_right, \u2190h.hom_equiv_naturality_left, \u2190equiv.symm_apply_eq,\n      h.hom_equiv_counit, F.map_right_unitor, assoc, assoc, \u2190right_unitor_naturality,\n      \u2190tensor_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, \u2190tensor_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  \u03b5_is_iso := by { dsimp [equivalence.to_adjunction], apply_instance },\n  \u03bc_is_iso := \u03bb 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl (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 {\u03b1 : Sort u} {p q : \u03b1 \u2192 Prop} (h : \u2200 a, Implies (p a) (q a)) :\n    Implies (\u2200 a, p a) (\u2200 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\u2081 : Implies p' q') (h\u2082 : Implies q p) :\n    Implies (p \u2192 p') (q \u2192 q') := fun h => h\u2081 \u2218 h \u2218 h\u2082\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 {\u03b1 : Sort u} {p q : \u03b1 \u2192 Prop} (h : \u2200 a, Implies (p a) (q a)) :\n    Implies (\u2203 a, p a) (\u2203 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 \u2227 q) (p' \u2227 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 \u2228 q) (p' \u2228 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 (\u00acq) \u00acp :=\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)) \u2190 target\n        (do\n              is_def_eq p q\n              eapplyc `monotone.const) <|>\n            do\n            let expr.pi pn pbi pd pb \u2190 whnf p\n            let expr.pi qn qbi qd qb \u2190 whnf q\n            let sort u \u2190 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 \u2227 is_arrow p \u2227 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 \u2190 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 \u2190 target\n  let t' \u2190 infer_type e\n  let ns \u2190 attribute.get_instances `monotonicity\n  let ((), p) \u2190 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 \u2192 Prop\n  | r : \u2200A 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 \u2192 Prop) : a \u2192 Prop\n  | r : \u2200a [f], b[pred/pred'] \u2192 pred.functional a [f] p\n\n  lemma {u} pred.functional.mono (A) ([pred\u2081] [pred\u2082] : a \u2192 Prop) [(h : \u2200b, pred\u2081 b \u2192 pred\u2082 b)] :\n    \u2200p, pred.functional A pred\u2081 p \u2192 pred.functional A pred\u2082 p\n\n  def {u} pred_i (A) (a) : Prop :=\n  \u2203[pred'], (\u039bi, \u2200a, pred_i a \u2192 pred_i.functional A [pred] a) \u2227 pred'_i a\n\n  lemma {u} pred_i.corec_functional (A) [\u039bi, C_i : a_i \u2192 Prop]\n    [\u039bi, h : \u2200a, C_i a \u2192 pred_i.functional A C_i a] :\n    \u2200a, C_i a \u2192 pred_i A a\n\n  lemma {u} pred_i.destruct (A) (a) : pred A a \u2192 pred.functional A [pred A] a\n\n  lemma {u} pred_i.construct (A) : \u2200a, pred_i.functional A [pred A] a \u2192 pred_i A a\n\n  lemma {u} pred_i.cases_on (A) (C : a \u2192 Prop) {a} (h : pred_i a) [\u039bi, \u2200a, b \u2192 C p] \u2192 C a\n\n  lemma {u} pred_i.corec_on (A) [(C : a \u2192 Prop)] (a) (h : C_i a)\n    [\u039bi, h_i : \u2200a, C_i a \u2192 [V j \u2203b, 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\u2081 f\u2082 : 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\u2081_l (pd : coind_pred) : expr :=\n  pd.f\u2081.app_of_list pd.locals\n#align tactic.add_coinductive_predicate.coind_pred.f\u2081_l tactic.add_coinductive_predicate.coind_pred.f\u2081_l\n\nunsafe def f\u2082_l (pd : coind_pred) : expr :=\n  pd.f\u2082.app_of_list pd.locals\n#align tactic.add_coinductive_predicate.coind_pred.f\u2082_l tactic.add_coinductive_predicate.coind_pred.f\u2082_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\u2081 f\u2082 : expr) : expr :=\n  (imp (f\u2081.app_of_list pd.locals) (f\u2082.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 \u2190 get_env\n  let decl \u2190 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 := \u03bb as, \u2203 bs, \u039b_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 \u2192 List (expr \u00d7 expr) \u2192 List expr \u00d7 List (expr \u00d7 expr)\n  | [], ps => ([], ps)\n  | List.cons b bs, ps =>\n    match ps.span\u2093 fun ap : expr \u00d7 expr => \u00acap.2 == b with\n    | (_, []) =>\n      let (bs, ps) := compact_relation bs ps\n      (b :: bs, ps)\n    | (ps\u2081, List.cons (a, _) ps\u2082) =>\n      let i := a.instantiate_local b.local_uniq_name\n      compact_relation (bs.map i) ((ps\u2081 ++ ps\u2082).map fun \u27e8a, p\u27e9 => (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 \u00d7 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 \u2190\n    preds.mapM fun \u27e8c, is\u27e9 => do\n        let (ls, t) \u2190 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\u2081 \u2190 mk_local_def (mkSimpleName <| \"C\" ++ n) c.local_type\n        let f\u2082 \u2190 mk_local_def (mkSimpleName <| \"C\u2082\" ++ n) c.local_type\n        return (ls, (f\u2081, f\u2082))\n  let fs := pre_info.map Prod.snd\n  let fs\u2081 := fs.map Prod.fst\n  let fs\u2082 := fs.map Prod.snd\n  let pds \u2190\n    (preds.zip pre_info).mapM fun \u27e8\u27e8c, is\u27e9, ls, f\u2081, f\u2082\u27e9 => do\n        let sort u_f \u2190 infer_type f\u2081 >>= infer_type\n        let pred_g := fun c : expr => (const c.local_uniq_name u_params : expr).app_of_list params\n        let intros \u2190\n          is.mapM fun i => do\n              let (args, t') \u2190 open_pis i.local_type\n              let Name.mk_string sub p \u2190 return i.local_uniq_name\n              let loc_args :=\n                args.map fun e =>\n                  (fs\u2081.zip preds).foldl (fun (e : expr) \u27e8f, c, _\u27e9 => e.replace_with (pred_g c) f) e\n              let t' := t'.replace_with (pred_g c) f\u2082\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\u2081\n              f\u2082\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\u2081 := pd <| fs\u2081\n      let func_f\u2082 := pd <| fs\u2082\n      let func_intros\n        \u2190-- Define functional for `pd` as inductive predicate\n            pd\n            fun r : coind_rule => do\n            let t := instantiate_local pd (pd fs\u2081) r\n            return (r, r, t <| params ++ fs\u2081)\n      add_inductive pd u_names (params + preds) (pd <| params ++ fs\u2081)\n          (func_intros fun \u27e8t, _, r\u27e9 => (t, r))\n      let mono_params\n        \u2190-- Prove monotonicity rule\n            pds\n            fun pd => do\n            let h \u2190 mk_local_def `h <| pd pd pd\n            return [pd, pd, h]\n      pd (pd ++ \"mono\") ((pd func_f\u2081 func_f\u2082).pis <| params ++ mono_params) do\n          let ps \u2190 intro_lst <| params expr.local_pp_name\n          let fs \u2190\n            pds fun pd => do\n                let [f\u2081, f\u2082, h] \u2190 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\u2081 pd) (f\u2082 pd)).pis pd).instantiate_locals <|\n                      (ps params).map fun \u27e8lv, p\u27e9 => (p, lv)\n                return (f\u2082, h')\n          let m \u2190 pd\n          eapply <| m ps\n          -- somehow `induction` / `cases` doesn't work?\n              func_intros\n              fun \u27e8n, pp_n, t\u27e9 =>\n              solve1 do\n                let bs \u2190 intros\n                let ms \u2190\n                  apply_core ((const n u_params).app_of_list <| ps ++ fs Prod.fst)\n                      { NewGoals := new_goals.all }\n                let params \u2190 (ms bs).enum.filterM fun \u27e8n, m, d\u27e9 => not <$> is_assigned m.2\n                params fun \u27e8n, m, d\u27e9 =>\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\u2081\n      let pred_body\n        \u2190-- define final predicate\n              mk_exists_lst\n              (pds coind_pred.f\u2081) <|\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        \u2190-- 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\u2081 ++ hs) do\n          intro_lst <| params local_pp_name\n          let fs \u2190 intro_lst <| fs\u2081 local_pp_name\n          let hs \u2190 intro_lst <| hs local_pp_name\n          let ls \u2190 intro_lst <| pd local_pp_name\n          let h \u2190 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 \u27e8n, pd\u27e9 => do\n      let destruct := pd pd (func_f pd)\n      pd (pd ++ \"destruct\") (destruct params) do\n          let ps \u2190 intro_lst <| params local_pp_name\n          let ls \u2190 intro_lst <| pd local_pp_name\n          let h \u2190 intro `h\n          let (fs, h, _) \u2190 elim_gen_prod pds h [] []\n          let (hs, h, _) \u2190 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' \u2190 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 \u2190 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 \u2190 mk_local_def `h <| pd pd\n      let rules \u2190\n        pd fun r : coind_rule => do\n            mk_local_def (mkSimpleName r) <| (C r).pis r\n      let cases_on \u2190\n        pd (pd ++ \"cases_on\") ((C pd).pis <| params ++ [C] ++ pd ++ [h] ++ rules) do\n            let ps \u2190 intro_lst <| params local_pp_name\n            let C \u2190 intro `C\n            let ls \u2190 intro_lst <| pd local_pp_name\n            let h \u2190 intro `h\n            let rules \u2190 intro_lst <| rules local_pp_name\n            let func_rec \u2190 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 \u2190\n        pds fun pd => do\n            let intros \u2190\n              pd fun r => do\n                  let (bs, eqs) := compact_relation r <| pd r\n                  let eqs \u2190\n                    eqs fun \u27e8l, i\u27e9 => do\n                        let sort u \u2190 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 \u2190 mk_local_def `h <| pd pd\n      pd (pd ++ \"corec_on\") ((pd <| pd).pis <| params ++ fs\u2081 ++ pd ++ [h] ++ rules) do\n          let ps \u2190 intro_lst <| params local_pp_name\n          let fs \u2190 intro_lst <| fs\u2081 local_pp_name\n          let ls \u2190 intro_lst <| pd local_pp_name\n          let h \u2190 intro `h\n          let rules \u2190 intro_lst <| rules local_pp_name\n          eapply <| pd <| ps ++ fs\n          (pds <| rules shape).mapM fun \u27e8pd, hr, s\u27e9 =>\n              solve1 do\n                let ls \u2190 intro_lst <| pd local_pp_name\n                let h' \u2190 intro `h\n                let h' \u2190 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 \u2190 elim_gen_sum n h'\n                    (hs <| pd s).mapM' fun \u27e8h, r, n_bs, n_eqs\u27e9 =>\n                        solve1 do\n                          let (as, h, _) \u2190 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', _) \u2190 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 \u2190 intro_lst <| params local_pp_name\n          let bs \u2190 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 \u2190 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 \u2190 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' \u2190 intros\n    let ctxts \u2190\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 \u2190\n      apply_core rule\n          { approx := false\n            NewGoals := NewGoals.all }\n    let g\n      \u2190-- analyse relation\n          List.headI <$>\n          get_goals\n    let List.cons _ m_is \u2190 return <| mvars.dropWhile\u2093 fun v => v.2 \u2260 g\n    let tgt \u2190 target\n    let (is, ty) \u2190 open_pis tgt\n    let-- construct coinduction predicate\n      (bs, eqs)\n      \u2190\n      compact_relation ctxts <$>\n          (is.zip m_is).mapM fun \u27e8i, m\u27e9 => Prod.mk i <$> instantiate_mvars m.2\n    solve1 do\n        let eqs \u2190\n          (mk_and_lst <$> eqs fun \u27e8i, m\u27e9 => mk_app `eq [m, i] >>= instantiate_mvars) <|> do\n              let x \u2190 mk_psigma (eqs Prod.fst)\n              let y \u2190 mk_psigma (eqs Prod.snd)\n              let t \u2190 infer_type x\n              mk_mapp `eq [t, x, y]\n        let rel \u2190 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          \u2190-- TODO: bug in subst when mvars in hyptohesis\n              intro_lst <|\n              is expr.local_pp_name\n        let h \u2190 intro1\n        let (_, h, ns) \u2190 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) \u2190 elim_gen_prod eqs h [] ns\n            (h :: hs hs.reverse : List _).foldlM\n                (fun (hs : List Name) (h : expr) => do\n                  let [(_, hs', \u03c3)] \u2190 cases_core h hs\n                  clear (h \u03c3)\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: \u00abexpr ?\u00bb\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 \u2190 mk_const corec_name\n  let locals \u2190 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\u2082` 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 {\u03b1 \u03b2 \u03b3 : 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 \u03b1) : \u03a0 (n : \u2115), oracle_comp spec (vector \u03b1 n)\n| 0 := return vector.nil\n| (n + 1) := do { a \u2190 oa, as \u2190 repeat n, return (a ::\u1d65 as) }\n\nvariables (oa : oracle_comp spec \u03b1) (n : \u2115) {m : \u2115} (x x' : \u03b1) (xs : vector \u03b1 m)\n  (xs\u2080 : vector \u03b1 0) (xs\u209b : vector \u03b1 m.succ)\n\nlemma repeat_zero : oa.repeat 0 = return vector.nil := rfl\n\nlemma repeat_succ : oa.repeat n.succ = do {a \u2190 oa, as \u2190 oa.repeat n, return (a ::\u1d65 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 \u03b1 := decidable_eq_of_decidable oa,\n    refine decidable.decidable_bind' _ _ _ _ hoa (\u03bb _, decidable.decidable_bind' _ _ _ _ hn\n      (\u03bb _, 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\u2082 :\n  (oa.repeat n).support = {xs | xs.to_list.all\u2082 (\u2208 oa.support)} :=\nbegin\n  induction n with n hn,\n  { exact set.ext (\u03bb x, by simp only [list.all\u2082, 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 \u27e8x, xs, rfl\u27e9 := 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\u2082_cons] }\nend\n\nlemma support_repeat_eq_forall : (oa.repeat n).support = {xs | \u2200 x \u2208 xs.to_list, x \u2208 oa.support} :=\nby simp_rw [support_repeat_eq_all\u2082, list.all\u2082_iff_forall]\n\nlemma mem_support_repeat_iff_all\u2082 : xs \u2208 (oa.repeat m).support \u2194 xs.to_list.all\u2082 (\u2208 oa.support) :=\nby rw [support_repeat_eq_all\u2082, set.mem_set_of_eq]\n\nlemma mem_support_repeat_iff_forall :\n  xs \u2208 (oa.repeat m).support \u2194 \u2200 x \u2208 xs.to_list, x \u2208 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\u2080 \u2208 (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 \u2208 oa.support \u2227 xs.tail \u2208 (oa.repeat n).support} :=\nbegin\n  refine set.ext (\u03bb xs, _),\n  obtain \u27e8x, xs, rfl\u27e9 := vector.exists_eq_cons xs,\n  simpa only [support_repeat_eq_all\u2082, set.mem_set_of_eq, vector.to_list_cons,\n    vector.head_cons, vector.tail_cons, list.all\u2082_cons]\nend\n\nlemma support_repeat_succ_eq_Union_image : (oa.repeat n.succ).support =\n  \u22c3 x \u2208 oa.support, (vector.cons x) '' (oa.repeat n).support :=\nbegin\n  refine set.ext (\u03bb xs, _),\n  obtain \u27e8x, xs, rfl\u27e9 := 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 \u27e8\u03bb h, \u27e8x, h.1, xs, h.2, rfl\u27e9, \u03bb h, _\u27e9,\n  obtain \u27e8y, hy, ys, hys, h\u27e9 := h,\n  rw [vector.cons_eq_cons] at h,\n  refine \u27e8h.1 \u25b8 hy, h.2 \u25b8 hys\u27e9,\nend\n\nlemma mem_support_repeat_succ_iff : xs\u209b \u2208 (oa.repeat m.succ).support \u2194\n  xs\u209b.head \u2208 oa.support \u2227 xs\u209b.tail \u2208 (oa.repeat m).support :=\nby rw [support_repeat_succ, set.mem_set_of_eq]\n\nlemma cons_mem_support_repeat_succ_iff : (x ::\u1d65 xs) \u2208 (oa.repeat m.succ).support \u2194\n  x \u2208 oa.support \u2227 xs \u2208 (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 \u03b1} {x : \u03b1} {xs : vector \u03b1 m}\n  (hxs : xs \u2208 (oa.repeat m).support) (hx : x \u2208 xs.to_list) : x \u2208 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 \u03b1} {x : \u03b1} (n : \u2115) (hx : x \u2208 oa.support) :\n  vector.repeat x n \u2208 (oa.repeat n).support :=\nby { rw [mem_support_repeat_iff_forall], exact (\u03bb y hy, (list.eq_of_mem_repeat hy).symm \u25b8 hx) }\n\nend support\n\nsection fin_support\n\nlemma mem_fin_support_repeat_iff_all\u2082 [oa.decidable] :\n  xs \u2208 (oa.repeat m).fin_support \u2194 xs.to_list.all\u2082 (\u2208 oa.fin_support) :=\nby simp only [mem_fin_support_iff_mem_support, mem_support_repeat_iff_all\u2082]\n\nlemma mem_fin_support_repeat_iff_forall [oa.decidable] :\n  xs \u2208 (oa.repeat m).fin_support \u2194 \u2200 x \u2208 xs.to_list, x \u2208 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 : \u2045oa.repeat m\u2046 xs = (xs.map \u2045oa\u2046).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 \u27e8x, xs, rfl\u27e9 := vector.exists_eq_cons xs,\n    calc \u2045oa.repeat m.succ\u2046 (x ::\u1d65 xs) =\n      \u2211' y ys, \u2045oa\u2046 y * \u2045oa.repeat m\u2046 ys * set.indicator {y ::\u1d65 ys} (\u03bb _, 1) (x ::\u1d65 xs) :\n        by simp only [repeat_succ, eval_dist_bind_apply_eq_tsum, \u2190 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      ... = \u2045oa\u2046 x * \u2045oa.repeat m\u2046 xs * set.indicator {x ::\u1d65 xs} (\u03bb _, 1) (x ::\u1d65 xs) :\n        begin\n          refine tsum_tsum_eq_single _ x xs (\u03bb y hy, mul_eq_zero_of_right _ $\n            set.indicator_apply_eq_zero.2 (\u03bb h, (hy _).elim)) (\u03bb y ys hys, mul_eq_zero_of_right _ $\n            set.indicator_apply_eq_zero.2 (\u03bb 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      ... = \u2045oa\u2046 x * \u2045oa.repeat m\u2046 xs :\n        by simp only [set.indicator_of_mem, set.mem_singleton, mul_one]\n      ... = (vector.map \u2045oa\u2046 (x ::\u1d65 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' : \u2045oa.repeat 0\u2046 = \u2045(return vector.nil : oracle_comp spec _)\u2046 := rfl\n\n@[simp] lemma eval_dist_repeat_zero : \u2045oa.repeat 0\u2046 = pmf.pure vector.nil :=\nby simp only [repeat_zero, eval_dist_return]\n\nlemma eval_dist_repeat_zero_apply : \u2045oa.repeat 0\u2046 xs\u2080 = 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  \u2045oa.repeat n.succ\u2046 = \u2045(\u03bb (x : \u03b1 \u00d7 vector \u03b1 n), x.1 ::\u1d65 x.2) <$> (oa \u00d7\u2098 oa.repeat n)\u2046 :=\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  \u2045oa.repeat n.succ\u2046 = \u2045oa \u00d7\u2098 oa.repeat n\u2046.map (\u03bb x, x.1 ::\u1d65 x.2) :=\n(oa.eval_dist_repeat_succ' n).trans (eval_dist_map _ _)\n\nlemma eval_dist_repeat_succ_apply :\n  \u2045oa.repeat m.succ\u2046 xs\u209b = \u2045oa\u2046 xs\u209b.head * \u2045oa.repeat m\u2046 xs\u209b.tail :=\ncalc \u2045oa.repeat m.succ\u2046 xs\u209b = \u2045(\u03bb (x : \u03b1 \u00d7 vector \u03b1 m), x.1 ::\u1d65 x.2) <$> (oa \u00d7\u2098 oa.repeat m)\u2046 xs\u209b :\n    by rw eval_dist_repeat_succ' oa m\n  ... = \u2045oa \u00d7\u2098 oa.repeat m\u2046 (xs\u209b.head, xs\u209b.tail) :\n    eval_dist_map_apply_eq_single' _ _ xs\u209b (xs\u209b.head, xs\u209b.tail) (xs\u209b.cons_head_tail)\n      (\u03bb x hx hx', by rw [\u2190 hx', vector.head_cons, vector.tail_cons, prod.mk.eta])\n  ... = \u2045oa\u2046 xs\u209b.head * \u2045oa.repeat m\u2046 xs\u209b.tail : by rw eval_dist_product_apply\n\nlemma eval_dist_map_nth_repeat (i : fin m) :\n  \u2045(\u03bb xs, vector.nth xs i) <$> oa.repeat m\u2046 = \u2045oa\u2046 :=\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 \u03b1 m.succ)) :\n  \u2045e | oa.repeat m.succ\u2046 = \u2211' (x : \u03b1) (xs : vector \u03b1 m), e.indicator \u2045oa.repeat m.succ\u2046 (x ::\u1d65 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 \u03b1) (i : fin m) :\n  \u2045\u03bb xs, xs.nth i \u2208 e | oa.repeat m\u2046 = \u2045e | oa\u2046 :=\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 \u03b1) :\n  \u2045\u03bb xs, xs.head \u2208 e | oa.repeat m.succ\u2046 = \u2045e | oa\u2046 :=\ncalc \u2045\u03bb xs, xs.head \u2208 e | oa.repeat m.succ\u2046 = \u2045\u03bb xs, xs.nth 0 \u2208 e | oa.repeat m.succ\u2046 :\n    by simp only [vector.nth_zero]\n  ... = \u2045e | oa\u2046 : prob_event_nth_repeat oa e 0\n\nlemma prob_event_all\u2082 (p : \u03b1 \u2192 Prop) :\n  \u2045\u03bb xs, xs.to_list.all\u2082 p | oa.repeat m\u2046 = \u2045p | oa\u2046 ^ 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 \u2264 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\u2093.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\u2093'. -/\ntheorem natCast_mem [AddSubmonoidWithOneClass S R] (n : \u2115) : (n : R) \u2208 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 := \u27e8_, one_mem s\u27e9\n    natCast := fun n => \u27e8n, natCast_mem s n\u27e9\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 \u2286 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 : \u2115) : (n : R) \u2208 s :=\n  by\n  rw [\u2190 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\u2093'. -/\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 \u2192+* 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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_subtype : (subtype s : s \u2192 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_pow {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] (x : s) (n : \u2115) :\n    ((x ^ n : s) : R) = (x ^ n : R) :=\n  by\n  induction' n with n ih\n  \u00b7 simp\n  \u00b7 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\u2093'. -/\n@[simp]\ntheorem mem_carrier {s : Subsemiring R} {x : R} : x \u2208 s.carrier \u2194 x \u2208 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\u2093'. -/\n/-- Two subsemirings are equal if they have the same elements. -/\n@[ext]\ntheorem ext {S T : Subsemiring R} (h : \u2200 x, x \u2208 S \u2194 x \u2208 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\u2093.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\u2093'. -/\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 = \u2191S) : 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_copy (S : Subsemiring R) (s : Set R) (hs : s = \u2191S) : (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\u2093.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\u2093'. -/\ntheorem copy_eq (S : Subsemiring R) (s : Set R) (hs : s = \u2191S) : 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 \u2192 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\u2093'. -/\n@[mono]\ntheorem toSubmonoid_strictMono : StrictMono (toSubmonoid : Subsemiring R \u2192 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\u2093'. -/\n@[mono]\ntheorem toSubmonoid_mono : Monotone (toSubmonoid : Subsemiring R \u2192 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 \u2192 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\u2093'. -/\n@[mono]\ntheorem toAddSubmonoid_strictMono : StrictMono (toAddSubmonoid : Subsemiring R \u2192 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\u2093'. -/\n@[mono]\ntheorem toAddSubmonoid_mono : Monotone (toAddSubmonoid : Subsemiring R \u2192 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\u2093.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\u2093.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'\u2093'. -/\n/-- Construct a `subsemiring R` from a set `s`, a submonoid `sm`, and an additive\nsubmonoid `sa` such that `x \u2208 s \u2194 x \u2208 sm \u2194 x \u2208 sa`. -/\nprotected def mk' (s : Set R) (sm : Submonoid R) (hm : \u2191sm = s) (sa : AddSubmonoid R)\n    (ha : \u2191sa = s) : Subsemiring R where\n  carrier := s\n  zero_mem' := ha \u25b8 sa.zero_mem\n  one_mem' := hm \u25b8 sm.one_mem\n  add_mem' x y := by simpa only [\u2190 ha] using sa.add_mem\n  mul_mem' x y := by simpa only [\u2190 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\u2093.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\u2093.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\u2093.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'\u2093'. -/\n@[simp]\ntheorem coe_mk' {s : Set R} {sm : Submonoid R} (hm : \u2191sm = s) {sa : AddSubmonoid R} (ha : \u2191sa = 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\u2093.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\u2093.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'\u2093'. -/\n@[simp]\ntheorem mem_mk' {s : Set R} {sm : Submonoid R} (hm : \u2191sm = s) {sa : AddSubmonoid R} (ha : \u2191sa = s)\n    {x : R} : x \u2208 Subsemiring.mk' s sm hm sa ha \u2194 x \u2208 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem mk'_toSubmonoid {s : Set R} {sm : Submonoid R} (hm : \u2191sm = s) {sa : AddSubmonoid R}\n    (ha : \u2191sa = 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem mk'_toAddSubmonoid {s : Set R} {sm : Submonoid R} (hm : \u2191sm = s) {sa : AddSubmonoid R}\n    (ha : \u2191sa = 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\u2093'. -/\n/-- A subsemiring contains the semiring's 1. -/\nprotected theorem one_mem : (1 : R) \u2208 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\u2093'. -/\n/-- A subsemiring contains the semiring's 0. -/\nprotected theorem zero_mem : (0 : R) \u2208 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\u2093'. -/\n/-- A subsemiring is closed under multiplication. -/\nprotected theorem mul_mem {x y : R} : x \u2208 s \u2192 y \u2208 s \u2192 x * y \u2208 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\u2093'. -/\n/-- A subsemiring is closed under addition. -/\nprotected theorem add_mem {x y : R} : x \u2208 s \u2192 y \u2208 s \u2192 x + y \u2208 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\u2093'. -/\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    (\u2200 x \u2208 l, x \u2208 s) \u2192 l.Prod \u2208 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\u2093'. -/\n/-- Sum of a list of elements in a `subsemiring` is in the `subsemiring`. -/\nprotected theorem list_sum_mem {l : List R} : (\u2200 x \u2208 l, x \u2208 s) \u2192 l.Sum \u2208 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\u2093'. -/\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    (\u2200 a \u2208 m, a \u2208 s) \u2192 m.Prod \u2208 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\u2093'. -/\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) : (\u2200 a \u2208 m, a \u2208 s) \u2192 m.Sum \u2208 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))) {\u03b9 : Type.{u2}} {t : Finset.{u2} \u03b9} {f : \u03b9 -> R}, (forall (c : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.hasMem.{u2} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u1} R _inst_4) t (fun (i : \u03b9) => 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))) {\u03b9 : Type.{u1}} {t : Finset.{u1} \u03b9} {f : \u03b9 -> R}, (forall (c : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u2} R _inst_4) t (fun (i : \u03b9) => f i)) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_mem Subsemiring.prod_mem\u2093'. -/\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) {\u03b9 : Type _}\n    {t : Finset \u03b9} {f : \u03b9 \u2192 R} (h : \u2200 c \u2208 t, f c \u2208 s) : (\u220f i in t, f i) \u2208 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) {\u03b9 : Type.{u2}} {t : Finset.{u2} \u03b9} {f : \u03b9 -> R}, (forall (c : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.hasMem.{u2} \u03b9) 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 \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1)) t (fun (i : \u03b9) => 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) {\u03b9 : Type.{u1}} {t : Finset.{u1} \u03b9} {f : \u03b9 -> R}, (forall (c : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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 \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R _inst_1)) t (fun (i : \u03b9) => f i)) s)\nCase conversion may be inaccurate. Consider using '#align subsemiring.sum_mem Subsemiring.sum_mem\u2093'. -/\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) {\u03b9 : Type _} {t : Finset \u03b9} {f : \u03b9 \u2192 R}\n    (h : \u2200 c \u2208 t, f c \u2208 s) : (\u2211 i in t, f i) \u2208 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\u2093'. -/\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 => \u27e8n, coe_nat_mem s n\u27e9\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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\nprotected theorem pow_mem {R : Type _} [Semiring R] (s : Subsemiring R) {x : R} (hx : x \u2208 s)\n    (n : \u2115) : x ^ n \u2208 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\u2093'. -/\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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_pow {R} [Semiring R] (s : Subsemiring R) (x : s) (n : \u2115) :\n    ((x ^ n : s) : R) = (x ^ n : R) :=\n  by\n  induction' n with n ih\n  \u00b7 simp\n  \u00b7 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\u2093'. -/\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\u2093'. -/\n/-- The natural ring hom from a subsemiring of semiring `R` to `R`. -/\ndef subtype : s \u2192+* 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\u2093.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 (\u1fb0 : 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) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_subtype : \u21d1s.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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\nprotected theorem nsmul_mem {x : R} (hx : x \u2208 s) (n : \u2115) : n \u2022 x \u2208 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\u2093'. -/\n@[simp]\ntheorem mem_toSubmonoid {s : Subsemiring R} {x : R} : x \u2208 s.toSubmonoid \u2194 x \u2208 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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem mem_toAddSubmonoid {s : Subsemiring R} {x : R} : x \u2208 s.toAddSubmonoid \u2194 x \u2208 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\u2093.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\u2093.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\u2093'. -/\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  \u27e8{ (\u22a4 : Submonoid R), (\u22a4 : AddSubmonoid R) with }\u27e9\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\u2093'. -/\n@[simp]\ntheorem mem_top (x : R) : x \u2208 (\u22a4 : 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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_top : ((\u22a4 : 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\u2093'. -/\n/-- The ring equiv between the top element of `subsemiring R` and `R`. -/\n@[simps]\ndef topEquiv : (\u22a4 : Subsemiring R) \u2243+* R\n    where\n  toFun r := r\n  invFun r := \u27e8r, Subsemiring.mem_top r\u27e9\n  left_inv r := SetLike.eta r _\n  right_inv r := [anonymous] r _\n  map_mul' := (\u22a4 : Subsemiring R).coe_mul\n  map_add' := (\u22a4 : 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 \u2192+* S) (s : Subsemiring S) : Subsemiring R :=\n  { s.toSubmonoid.comap (f : R \u2192* S), s.toAddSubmonoid.comap (f : R \u2192+ S) with carrier := f \u207b\u00b9' 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_comap (s : Subsemiring S) (f : R \u2192+* S) : (s.comap f : Set R) = f \u207b\u00b9' 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\u2093'. -/\n@[simp]\ntheorem mem_comap {s : Subsemiring S} {f : R \u2192+* S} {x : R} : x \u2208 s.comap f \u2194 f x \u2208 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 \u2192+* T) (f : R \u2192+* 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 \u2192+* S) (s : Subsemiring R) : Subsemiring S :=\n  { s.toSubmonoid.map (f : R \u2192* S), s.toAddSubmonoid.map (f : R \u2192+ 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_map (f : R \u2192+* 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\u2093'. -/\n@[simp]\ntheorem mem_map {f : R \u2192+* S} {s : Subsemiring R} {y : S} : y \u2208 s.map f \u2194 \u2203 x \u2208 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 \u2192+* T) (f : R \u2192+* 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\u2093'. -/\ntheorem map_le_iff_le_comap {f : R \u2192+* S} {s : Subsemiring R} {t : Subsemiring S} :\n    s.map f \u2264 t \u2194 s \u2264 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\u2093'. -/\ntheorem gc_map_comap (f : R \u2192+* 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\u2093'. -/\n/-- A subsemiring is isomorphic to its image under an injective function -/\nnoncomputable def equivMapOfInjective (f : R \u2192+* S) (hf : Function.Injective f) : s \u2243+* 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_equivMapOfInjective_apply (f : R \u2192+* 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 \u2192+* T) (f : R \u2192+* 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  ((\u22a4 : 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\u2093.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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem mem_rangeS {f : R \u2192+* S} {y : S} : y \u2208 f.srange \u2194 \u2203 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\u2093'. -/\ntheorem rangeS_eq_map (f : R \u2192+* S) : f.srange = (\u22a4 : 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\u2093'. -/\ntheorem mem_rangeS_self (f : R \u2192+* S) (x : R) : f x \u2208 f.srange :=\n  mem_rangeS.mpr \u27e8x, rfl\u27e9\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 (\u22a4 : 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\u2093'. -/\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 \u2192+* 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  \u27e8(Nat.castRingHom R).srange\u27e9\n\ninstance : Inhabited (Subsemiring R) :=\n  \u27e8\u22a5\u27e9\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\u2093.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\u2093.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\u2093'. -/\ntheorem coe_bot : ((\u22a5 : Subsemiring R) : Set R) = Set.range (coe : \u2115 \u2192 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\u2093.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\u2093'. -/\ntheorem mem_bot {x : R} : x \u2208 (\u22a5 : Subsemiring R) \u2194 \u2203 n : \u2115, \u2191n = 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  \u27e8fun s t =>\n    { s.toSubmonoid \u2293 t.toSubmonoid, s.toAddSubmonoid \u2293 t.toAddSubmonoid with carrier := s \u2229 t }\u27e9\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_inf (p p' : Subsemiring R) : ((p \u2293 p' : Subsemiring R) : Set R) = p \u2229 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\u2093'. -/\n@[simp]\ntheorem mem_inf {p p' : Subsemiring R} {x : R} : x \u2208 p \u2293 p' \u2194 x \u2208 p \u2227 x \u2208 p' :=\n  Iff.rfl\n#align subsemiring.mem_inf Subsemiring.mem_inf\n\ninstance : InfSet (Subsemiring R) :=\n  \u27e8fun s =>\n    Subsemiring.mk' (\u22c2 t \u2208 s, \u2191t) (\u2a05 t \u2208 s, Subsemiring.toSubmonoid t) (by simp)\n      (\u2a05 t \u2208 s, Subsemiring.toAddSubmonoid t) (by simp)\u27e9\n\n/- warning: subsemiring.coe_Inf -> Subsemiring.coe_inf\u209b 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\u2093.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\u209b.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasInf.{u1} R _inst_1) S)) (Set.inter\u1d62.{u1, succ u1} R (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Set.inter\u1d62.{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\u2093.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\u209b.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instInfSetSubsemiring.{u1} R _inst_1) S)) (Set.inter\u1d62.{u1, succ u1} R (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Set.inter\u1d62.{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\u209b\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_inf\u209b (S : Set (Subsemiring R)) : ((inf\u209b S : Subsemiring R) : Set R) = \u22c2 s \u2208 S, \u2191s :=\n  rfl\n#align subsemiring.coe_Inf Subsemiring.coe_inf\u209b\n\n/- warning: subsemiring.mem_Inf -> Subsemiring.mem_inf\u209b 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\u209b.{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\u209b.{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\u209b\u2093'. -/\ntheorem mem_inf\u209b {S : Set (Subsemiring R)} {x : R} : x \u2208 inf\u209b S \u2194 \u2200 p \u2208 S, x \u2208 p :=\n  Set.mem_inter\u1d62\u2082\n#align subsemiring.mem_Inf Subsemiring.mem_inf\u209b\n\n#print Subsemiring.inf\u209b_toSubmonoid /-\n@[simp]\ntheorem inf\u209b_toSubmonoid (s : Set (Subsemiring R)) :\n    (inf\u209b s).toSubmonoid = \u2a05 t \u2208 s, Subsemiring.toSubmonoid t :=\n  mk'_toSubmonoid _ _\n#align subsemiring.Inf_to_submonoid Subsemiring.inf\u209b_toSubmonoid\n-/\n\n#print Subsemiring.inf\u209b_toAddSubmonoid /-\n@[simp]\ntheorem inf\u209b_toAddSubmonoid (s : Set (Subsemiring R)) :\n    (inf\u209b s).toAddSubmonoid = \u2a05 t \u2208 s, Subsemiring.toAddSubmonoid t :=\n  mk'_toAddSubmonoid _ _\n#align subsemiring.Inf_to_add_submonoid Subsemiring.inf\u209b_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) \u2264 t \u2194 s \u2264 t from SetLike.coe_subset_coe)\n        isGLB_binf\u1d62 with\n    bot := \u22a5\n    bot_le := fun s x hx =>\n      let \u27e8n, hn\u27e9 := mem_bot.1 hx\n      hn \u25b8 coe_nat_mem s n\n    top := \u22a4\n    le_top := fun s x hx => trivial\n    inf := (\u00b7 \u2293 \u00b7)\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\u2081 t\u2082 h\u2081 h\u2082 x hx => \u27e8h\u2081 hx, h\u2082 hx\u27e9 }\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'\u2093'. -/\ntheorem eq_top_iff' (A : Subsemiring R) : A = \u22a4 \u2194 \u2200 x : R, x \u2208 A :=\n  eq_top_iff.trans \u27e8fun h m => h <| mem_top m, fun h m _ => h m\u27e9\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\u2093.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\u2093'. -/\ntheorem coe_center (R) [Semiring R] : \u2191(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\u2093'. -/\ntheorem mem_center_iff {R} [Semiring R] {z : R} : z \u2208 center R \u2194 \u2200 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\u2093'. -/\ninstance decidableMemCenter {R} [Semiring R] [DecidableEq R] [Fintype R] :\n    DecidablePred (\u00b7 \u2208 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\u2093'. -/\n@[simp]\ntheorem center_eq_top (R) [CommSemiring R] : center R = \u22a4 :=\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\u2093.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\u2093'. -/\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\u2093'. -/\ntheorem mem_centralizer_iff {R} [Semiring R] {s : Set R} {z : R} :\n    z \u2208 centralizer s \u2194 \u2200 g \u2208 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\u2093'. -/\ntheorem centralizer_le {R} [Semiring R] (s t : Set R) (h : s \u2286 t) : centralizer t \u2264 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\u209b { S | s \u2286 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\u2093.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\u2093'. -/\ntheorem mem_closure {x : R} {s : Set R} : x \u2208 closure s \u2194 \u2200 S : Subsemiring R, s \u2286 S \u2192 x \u2208 S :=\n  mem_inf\u209b\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\u2093.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\u2093'. -/\n/-- The subsemiring generated by a set includes the set. -/\n@[simp]\ntheorem subset_closure {s : Set R} : s \u2286 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\u2093'. -/\ntheorem not_mem_of_not_mem_closure {s : Set R} {P : R} (hP : P \u2209 closure s) : P \u2209 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\u2093.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\u2093'. -/\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 \u2264 t \u2194 s \u2286 t :=\n  \u27e8Set.Subset.trans subset_closure, fun h => inf\u209b_le h\u27e9\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\u2093'. -/\n/-- Subsemiring closure of a set is monotone in its argument: if `s \u2286 t`,\nthen `closure s \u2264 closure t`. -/\ntheorem closure_mono \u2983s t : Set R\u2984 (h : s \u2286 t) : closure s \u2264 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\u2093.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\u2093'. -/\ntheorem closure_eq_of_le {s : Set R} {t : Subsemiring R} (h\u2081 : s \u2286 t) (h\u2082 : t \u2264 closure s) :\n    closure s = t :=\n  le_antisymm (closure_le.2 h\u2081) h\u2082\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\u2093.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\u2093'. -/\ntheorem mem_map_equiv {f : R \u2243+* S} {K : Subsemiring R} {x : S} :\n    x \u2208 K.map (f : R \u2192+* S) \u2194 f.symm x \u2208 K :=\n  @Set.mem_image_equiv _ _ (\u2191K) 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\u2093.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\u2093.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\u2093'. -/\ntheorem map_equiv_eq_comap_symm (f : R \u2243+* S) (K : Subsemiring R) :\n    K.map (f : R \u2192+* 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\u2093.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\u2093.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\u2093'. -/\ntheorem comap_equiv_eq_map_symm (f : R \u2243+* S) (K : Subsemiring S) :\n    K.comap (f : R \u2192+* 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\u2093.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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093'. -/\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        \u27e8fun hx => _, fun hx =>\n          (subsemiring.mem_closure.mp hx) M.subsemiring_closure fun s sM => _\u27e9 <;>\n      rintro - \u27e8H1, rfl\u27e9 <;>\n    rintro - \u27e8H2, rfl\u27e9\n  \u00b7 exact add_submonoid.mem_closure.mp hx H1.to_add_submonoid H2\n  \u00b7 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 \u2191(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\u2093.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\u2093.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\u2093.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\u2093'. -/\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 [\u2190 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\u2093.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\u2093'. -/\ntheorem mem_closure_iff {s : Set R} {x} :\n    x \u2208 closure s \u2194 x \u2208 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 \u2191(AddSubmonoid.closure s) = closure s :=\n  by\n  ext x\n  refine' \u27e8fun hx => _, fun hx => closure_mono AddSubmonoid.subset_closure hx\u27e9\n  rintro - \u27e8H, rfl\u27e9\n  rintro - \u27e8J, rfl\u27e9\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\u2093'. -/\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 \u2192 Prop} {x} (h : x \u2208 closure s) (Hs : \u2200 x \u2208 s, p x)\n    (H0 : p 0) (H1 : p 1) (Hadd : \u2200 x y, p x \u2192 p y \u2192 p (x + y))\n    (Hmul : \u2200 x y, p x \u2192 p y \u2192 p (x * y)) : p x :=\n  (@closure_le _ _ _ \u27e8p, Hmul, H1, Hadd, H0\u27e9).2 Hs h\n#align subsemiring.closure_induction Subsemiring.closure_induction\n\n/- warning: subsemiring.closure_induction\u2082 -> Subsemiring.closure_induction\u2082 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\u2081 : R) (x\u2082 : R) (y : R), (p x\u2081 y) -> (p x\u2082 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\u2081 x\u2082) y)) -> (forall (x : R) (y\u2081 : R) (y\u2082 : R), (p x y\u2081) -> (p x y\u2082) -> (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\u2081 y\u2082))) -> (forall (x\u2081 : R) (x\u2082 : R) (y : R), (p x\u2081 y) -> (p x\u2082 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\u2081 x\u2082) y)) -> (forall (x : R) (y\u2081 : R) (y\u2082 : R), (p x y\u2081) -> (p x y\u2082) -> (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\u2081 y\u2082))) -> (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\u2081 : R) (x\u2082 : R) (y : R), (p x\u2081 y) -> (p x\u2082 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\u2081 x\u2082) y)) -> (forall (x : R) (y\u2081 : R) (y\u2082 : R), (p x y\u2081) -> (p x y\u2082) -> (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\u2081 y\u2082))) -> (forall (x\u2081 : R) (x\u2082 : R) (y : R), (p x\u2081 y) -> (p x\u2082 y) -> (p (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) x\u2081 x\u2082) y)) -> (forall (x : R) (y\u2081 : R) (y\u2082 : R), (p x y\u2081) -> (p x y\u2082) -> (p x (HMul.hMul.{u1, u1, u1} R R R (instHMul.{u1} R (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R _inst_1))) y\u2081 y\u2082))) -> (p x y)\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_induction\u2082 Subsemiring.closure_induction\u2082\u2093'. -/\n/-- An induction principle for closure membership for predicates with two arguments. -/\n@[elab_as_elim]\ntheorem closure_induction\u2082 {s : Set R} {p : R \u2192 R \u2192 Prop} {x} {y : R} (hx : x \u2208 closure s)\n    (hy : y \u2208 closure s) (Hs : \u2200 x \u2208 s, \u2200 y \u2208 s, p x y) (H0_left : \u2200 x, p 0 x)\n    (H0_right : \u2200 x, p x 0) (H1_left : \u2200 x, p 1 x) (H1_right : \u2200 x, p x 1)\n    (Hadd_left : \u2200 x\u2081 x\u2082 y, p x\u2081 y \u2192 p x\u2082 y \u2192 p (x\u2081 + x\u2082) y)\n    (Hadd_right : \u2200 x y\u2081 y\u2082, p x y\u2081 \u2192 p x y\u2082 \u2192 p x (y\u2081 + y\u2082))\n    (Hmul_left : \u2200 x\u2081 x\u2082 y, p x\u2081 y \u2192 p x\u2082 y \u2192 p (x\u2081 * x\u2082) y)\n    (Hmul_right : \u2200 x y\u2081 y\u2082, p x y\u2081 \u2192 p x y\u2082 \u2192 p x (y\u2081 * y\u2082)) : p x y :=\n  closure_induction hx\n    (fun x\u2081 x\u2081s =>\n      closure_induction hy (Hs x\u2081 x\u2081s) (H0_right x\u2081) (H1_right x\u2081) (Hadd_right x\u2081) (Hmul_right x\u2081))\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\u2082 Subsemiring.closure_induction\u2082\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\u2093'. -/\ntheorem mem_closure_iff_exists_list {R} [Semiring R] {s : Set R} {x} :\n    x \u2208 closure s \u2194 \u2203 L : List (List R), (\u2200 t \u2208 L, \u2200 y \u2208 t, y \u2208 s) \u2227 (L.map List.prod).Sum = x :=\n  \u27e8fun hx =>\n    AddSubmonoid.closure_induction (mem_closure_iff.1 hx)\n      (fun x hx =>\n        suffices \u2203 t : List R, (\u2200 y \u2208 t, y \u2208 s) \u2227 t.Prod = x from\n          let \u27e8t, ht1, ht2\u27e9 := this\n          \u27e8[t], List.forall_mem_singleton.2 ht1, by\n            rw [List.map_singleton, List.sum_singleton, ht2]\u27e9\n        Submonoid.closure_induction hx\n          (fun x hx => \u27e8[x], List.forall_mem_singleton.2 hx, one_mul x\u27e9)\n          \u27e8[], List.forall_mem_nil _, rfl\u27e9 fun x y \u27e8t, ht1, ht2\u27e9 \u27e8u, hu1, hu2\u27e9 =>\n          \u27e8t ++ u, List.forall_mem_append.2 \u27e8ht1, hu1\u27e9, by rw [List.prod_append, ht2, hu2]\u27e9)\n      \u27e8[], List.forall_mem_nil _, rfl\u27e9 fun x y \u27e8L, HL1, HL2\u27e9 \u27e8M, HM1, HM2\u27e9 =>\n      \u27e8L ++ M, List.forall_mem_append.2 \u27e8HL1, HM1\u27e9, by\n        rw [List.map_append, List.sum_append, HL2, HM2]\u27e9,\n    fun \u27e8L, HL1, HL2\u27e9 =>\n    HL2 \u25b8\n      list_sum_mem fun r hr =>\n        let \u27e8t, ht1, ht2\u27e9 := List.mem_map.1 hr\n        ht2 \u25b8 list_prod_mem _ fun y hy => subset_closure <| HL1 t ht1 y hy\u27e9\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\u2093.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\u2093'. -/\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 (\u2205 : Set R) = \u22a5 :=\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\u2093'. -/\n@[simp]\ntheorem closure_univ : closure (Set.univ : Set R) = \u22a4 :=\n  @coe_top R _ \u25b8 closure_eq \u22a4\n#align subsemiring.closure_univ Subsemiring.closure_univ\n\n#print Subsemiring.closure_union /-\ntheorem closure_union (s t : Set R) : closure (s \u222a t) = closure s \u2294 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\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {\u03b9 : Sort.{u2}} (s : \u03b9 -> (Set.{u1} R)), Eq.{succ u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.closure.{u1} R _inst_1 (Set.union\u1d62.{u1, u2} R \u03b9 (fun (i : \u03b9) => s i))) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => Subsemiring.closure.{u1} R _inst_1 (s i)))\nbut is expected to have type\n  forall {R : Type.{u2}} [_inst_1 : NonAssocSemiring.{u2} R] {\u03b9 : Sort.{u1}} (s : \u03b9 -> (Set.{u2} R)), Eq.{succ u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.closure.{u2} R _inst_1 (Set.union\u1d62.{u2, u1} R \u03b9 (fun (i : \u03b9) => s i))) (sup\u1d62.{u2, u1} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toSupSet.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1)) \u03b9 (fun (i : \u03b9) => Subsemiring.closure.{u2} R _inst_1 (s i)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.closure_Union Subsemiring.closure_union\u1d62\u2093'. -/\ntheorem closure_union\u1d62 {\u03b9} (s : \u03b9 \u2192 Set R) : closure (\u22c3 i, s i) = \u2a06 i, closure (s i) :=\n  (Subsemiring.gi R).gc.l_sup\u1d62\n#align subsemiring.closure_Union Subsemiring.closure_union\u1d62\n\n/- warning: subsemiring.closure_sUnion -> Subsemiring.closure_union\u209b 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\u209b.{u1} R s)) (sup\u1d62.{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\u1d62.{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\u209b.{u1} R s)) (sup\u1d62.{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\u1d62.{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\u209b\u2093'. -/\ntheorem closure_union\u209b (s : Set (Set R)) : closure (\u22c3\u2080 s) = \u2a06 t \u2208 s, closure t :=\n  (Subsemiring.gi R).gc.l_sup\u209b\n#align subsemiring.closure_sUnion Subsemiring.closure_union\u209b\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\u2093'. -/\ntheorem map_sup (s t : Subsemiring R) (f : R \u2192+* S) : (s \u2294 t).map f = s.map f \u2294 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\u1d62 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] {\u03b9 : Sort.{u3}} (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : \u03b9 -> (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\u1d62.{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))) \u03b9 s)) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => 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] {\u03b9 : Sort.{u1}} (f : RingHom.{u2, u3} R S _inst_1 _inst_2) (s : \u03b9 -> (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\u1d62.{u2, u1} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toSupSet.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1)) \u03b9 s)) (sup\u1d62.{u3, u1} (Subsemiring.{u3} S _inst_2) (CompleteLattice.toSupSet.{u3} (Subsemiring.{u3} S _inst_2) (Subsemiring.instCompleteLatticeSubsemiring.{u3} S _inst_2)) \u03b9 (fun (i : \u03b9) => 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\u1d62\u2093'. -/\ntheorem map_sup\u1d62 {\u03b9 : Sort _} (f : R \u2192+* S) (s : \u03b9 \u2192 Subsemiring R) :\n    (sup\u1d62 s).map f = \u2a06 i, (s i).map f :=\n  (gc_map_comap f).l_sup\u1d62\n#align subsemiring.map_supr Subsemiring.map_sup\u1d62\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\u2093'. -/\ntheorem comap_inf (s t : Subsemiring S) (f : R \u2192+* S) : (s \u2293 t).comap f = s.comap f \u2293 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\u1d62 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] {\u03b9 : Sort.{u3}} (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : \u03b9 -> (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\u1d62.{u2, u3} (Subsemiring.{u2} S _inst_2) (Subsemiring.hasInf.{u2} S _inst_2) \u03b9 s)) (inf\u1d62.{u1, u3} (Subsemiring.{u1} R _inst_1) (Subsemiring.hasInf.{u1} R _inst_1) \u03b9 (fun (i : \u03b9) => 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] {\u03b9 : Sort.{u1}} (f : RingHom.{u2, u3} R S _inst_1 _inst_2) (s : \u03b9 -> (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\u1d62.{u3, u1} (Subsemiring.{u3} S _inst_2) (Subsemiring.instInfSetSubsemiring.{u3} S _inst_2) \u03b9 s)) (inf\u1d62.{u2, u1} (Subsemiring.{u2} R _inst_1) (Subsemiring.instInfSetSubsemiring.{u2} R _inst_1) \u03b9 (fun (i : \u03b9) => 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\u1d62\u2093'. -/\ntheorem comap_inf\u1d62 {\u03b9 : Sort _} (f : R \u2192+* S) (s : \u03b9 \u2192 Subsemiring S) :\n    (inf\u1d62 s).comap f = \u2a05 i, (s i).comap f :=\n  (gc_map_comap f).u_inf\u1d62\n#align subsemiring.comap_infi Subsemiring.comap_inf\u1d62\n\n#print Subsemiring.map_bot /-\n@[simp]\ntheorem map_bot (f : R \u2192+* S) : (\u22a5 : Subsemiring R).map f = \u22a5 :=\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\u2093'. -/\n@[simp]\ntheorem comap_top (f : R \u2192+* S) : (\u22a4 : Subsemiring S).comap f = \u22a4 :=\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\u2093'. -/\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 \u00d7 t`\nas a subsemiring of `R \u00d7 S`. -/\ndef prod (s : Subsemiring R) (t : Subsemiring S) : Subsemiring (R \u00d7 S) :=\n  { s.toSubmonoid.Prod t.toSubmonoid, s.toAddSubmonoid.Prod t.toAddSubmonoid with\n    carrier := s \u00d7\u02e2 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\u2093.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\u2093.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\u2093.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\u2093'. -/\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 \u00d7 S)) = s \u00d7\u02e2 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\u2093'. -/\ntheorem mem_prod {s : Subsemiring R} {t : Subsemiring S} {p : R \u00d7 S} :\n    p \u2208 s.Prod t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 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\u2081 : Subsemiring.{u1} R _inst_1}} {{s\u2082 : 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\u2081 s\u2082) -> (forall {{t\u2081 : Subsemiring.{u2} S _inst_2}} {{t\u2082 : 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\u2081 t\u2082) -> (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\u2081 t\u2081) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s\u2082 t\u2082)))\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\u2081 : Subsemiring.{u1} R _inst_1}} {{s\u2082 : 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\u2081 s\u2082) -> (forall {{t\u2081 : Subsemiring.{u2} S _inst_2}} {{t\u2082 : 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\u2081 t\u2082) -> (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\u2081 t\u2081) (Subsemiring.prod.{u1, u2} R S _inst_1 _inst_2 s\u2082 t\u2082)))\nCase conversion may be inaccurate. Consider using '#align subsemiring.prod_mono Subsemiring.prod_mono\u2093'. -/\n@[mono]\ntheorem prod_mono \u2983s\u2081 s\u2082 : Subsemiring R\u2984 (hs : s\u2081 \u2264 s\u2082) \u2983t\u2081 t\u2082 : Subsemiring S\u2984 (ht : t\u2081 \u2264 t\u2082) :\n    s\u2081.Prod t\u2081 \u2264 s\u2082.Prod t\u2082 :=\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\u2093'. -/\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\u2093'. -/\ntheorem prod_mono_left (t : Subsemiring S) : Monotone fun s : Subsemiring R => s.Prod t :=\n  fun s\u2081 s\u2082 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\u2093'. -/\ntheorem prod_top (s : Subsemiring R) : s.Prod (\u22a4 : 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\u2093'. -/\ntheorem top_prod (s : Subsemiring S) : (\u22a4 : 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\u2093'. -/\n@[simp]\ntheorem top_prod_top : (\u22a4 : Subsemiring R).Prod (\u22a4 : Subsemiring S) = \u22a4 :=\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\u2093'. -/\n/-- Product of subsemirings is isomorphic to their product as monoids. -/\ndef prodEquiv (s : Subsemiring R) (t : Subsemiring S) : s.Prod t \u2243+* s \u00d7 t :=\n  { Equiv.Set.prod \u2191s \u2191t 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\u1d62_of_directed is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {\u03b9 : Sort.{u2}} [h\u03b9 : Nonempty.{u2} \u03b9] {S : \u03b9 -> (Subsemiring.{u1} R _inst_1)}, (Directed.{u1, u2} (Subsemiring.{u1} R _inst_1) \u03b9 (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\u1d62.{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))) \u03b9 (fun (i : \u03b9) => S i))) (Exists.{u2} \u03b9 (fun (i : \u03b9) => 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] {\u03b9 : Sort.{u1}} [h\u03b9 : Nonempty.{u1} \u03b9] {S : \u03b9 -> (Subsemiring.{u2} R _inst_1)}, (Directed.{u2, u1} (Subsemiring.{u2} R _inst_1) \u03b9 (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\u1d62.{u2, u1} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toSupSet.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1)) \u03b9 (fun (i : \u03b9) => S i))) (Exists.{u1} \u03b9 (fun (i : \u03b9) => 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\u1d62_of_directed\u2093'. -/\ntheorem mem_sup\u1d62_of_directed {\u03b9} [h\u03b9 : Nonempty \u03b9] {S : \u03b9 \u2192 Subsemiring R} (hS : Directed (\u00b7 \u2264 \u00b7) S)\n    {x : R} : (x \u2208 \u2a06 i, S i) \u2194 \u2203 i, x \u2208 S i :=\n  by\n  refine' \u27e8_, fun \u27e8i, hi\u27e9 => (SetLike.le_def.1 <| le_sup\u1d62 S i) hi\u27e9\n  let U : Subsemiring R :=\n    Subsemiring.mk' (\u22c3 i, (S i : Set R)) (\u2a06 i, (S i).toSubmonoid)\n      (Submonoid.coe_sup\u1d62_of_directed <| hS.mono_comp _ fun _ _ => id) (\u2a06 i, (S i).toAddSubmonoid)\n      (AddSubmonoid.coe_sup\u1d62_of_directed <| hS.mono_comp _ fun _ _ => id)\n  suffices (\u2a06 i, S i) \u2264 U by simpa using @this x\n  exact sup\u1d62_le fun i x hx => Set.mem_union\u1d62.2 \u27e8i, hx\u27e9\n#align subsemiring.mem_supr_of_directed Subsemiring.mem_sup\u1d62_of_directed\n\n/- warning: subsemiring.coe_supr_of_directed -> Subsemiring.coe_sup\u1d62_of_directed is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} R] {\u03b9 : Sort.{u2}} [h\u03b9 : Nonempty.{u2} \u03b9] {S : \u03b9 -> (Subsemiring.{u1} R _inst_1)}, (Directed.{u1, u2} (Subsemiring.{u1} R _inst_1) \u03b9 (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\u2093.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\u1d62.{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))) \u03b9 (fun (i : \u03b9) => S i))) (Set.union\u1d62.{u1, u2} R \u03b9 (fun (i : \u03b9) => (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\u2093.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] {\u03b9 : Sort.{u1}} [h\u03b9 : Nonempty.{u1} \u03b9] {S : \u03b9 -> (Subsemiring.{u2} R _inst_1)}, (Directed.{u2, u1} (Subsemiring.{u2} R _inst_1) \u03b9 (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\u1d62.{u2, u1} (Subsemiring.{u2} R _inst_1) (CompleteLattice.toSupSet.{u2} (Subsemiring.{u2} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u2} R _inst_1)) \u03b9 (fun (i : \u03b9) => S i))) (Set.union\u1d62.{u2, u1} R \u03b9 (fun (i : \u03b9) => 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\u1d62_of_directed\u2093'. -/\ntheorem coe_sup\u1d62_of_directed {\u03b9} [h\u03b9 : Nonempty \u03b9] {S : \u03b9 \u2192 Subsemiring R}\n    (hS : Directed (\u00b7 \u2264 \u00b7) S) : ((\u2a06 i, S i : Subsemiring R) : Set R) = \u22c3 i, \u2191(S i) :=\n  Set.ext fun x => by simp [mem_supr_of_directed hS]\n#align subsemiring.coe_supr_of_directed Subsemiring.coe_sup\u1d62_of_directed\n\n/- warning: subsemiring.mem_Sup_of_directed_on -> Subsemiring.mem_sup\u209b_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\u209b.{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\u209b.{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\u209b_of_directedOn\u2093'. -/\ntheorem mem_sup\u209b_of_directedOn {S : Set (Subsemiring R)} (Sne : S.Nonempty)\n    (hS : DirectedOn (\u00b7 \u2264 \u00b7) S) {x : R} : x \u2208 sup\u209b S \u2194 \u2203 s \u2208 S, x \u2208 s :=\n  by\n  haveI : Nonempty S := Sne.to_subtype\n  simp only [sup\u209b_eq_sup\u1d62', mem_supr_of_directed hS.directed_coe, SetCoe.exists, Subtype.coe_mk]\n#align subsemiring.mem_Sup_of_directed_on Subsemiring.mem_sup\u209b_of_directedOn\n\n/- warning: subsemiring.coe_Sup_of_directed_on -> Subsemiring.coe_sup\u209b_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\u2093.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\u209b.{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\u1d62.{u1, succ u1} R (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Set.union\u1d62.{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\u2093.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\u209b.{u1} (Subsemiring.{u1} R _inst_1) (CompleteLattice.toSupSet.{u1} (Subsemiring.{u1} R _inst_1) (Subsemiring.instCompleteLatticeSubsemiring.{u1} R _inst_1)) S)) (Set.union\u1d62.{u1, succ u1} R (Subsemiring.{u1} R _inst_1) (fun (s : Subsemiring.{u1} R _inst_1) => Set.union\u1d62.{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\u209b_of_directedOn\u2093'. -/\ntheorem coe_sup\u209b_of_directedOn {S : Set (Subsemiring R)} (Sne : S.Nonempty)\n    (hS : DirectedOn (\u00b7 \u2264 \u00b7) S) : (\u2191(sup\u209b S) : Set R) = \u22c3 s \u2208 S, \u2191s :=\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\u209b_of_directedOn\n\nend Subsemiring\n\nnamespace RingHom\n\nvariable [NonAssocSemiring T] {s : Subsemiring R}\n\nvariable {\u03c3R \u03c3S : Type _}\n\nvariable [SetLike \u03c3R R] [SetLike \u03c3S S] [SubsemiringClass \u03c3R R] [SubsemiringClass \u03c3S 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 \u2192+* S) (s : \u03c3R) : s \u2192+* 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] {\u03c3R : Type.{u3}} [_inst_5 : SetLike.{u3, u1} \u03c3R R] [_inst_7 : SubsemiringClass.{u1, u3} \u03c3R R _inst_1 _inst_5] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) {s : \u03c3R} (x : coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R 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)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s) S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s) _inst_2) (fun (_x : RingHom.{u1, u2} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s) S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s) _inst_2) => (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s) -> S) (RingHom.hasCoeToFun.{u1, u2} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s) S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s) _inst_2) (RingHom.domRestrict.{u1, u2, u3} R S _inst_1 _inst_2 \u03c3R _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)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s) R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s) R (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s) R (coeBase.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s) R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u3} R \u03c3R (SetLike.hasMem.{u3, u1} \u03c3R 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] {\u03c3R : Type.{u1}} [_inst_5 : SetLike.{u1, u2} \u03c3R R] [_inst_7 : SubsemiringClass.{u2, u1} \u03c3R R _inst_1 _inst_5] (f : RingHom.{u2, u3} R S _inst_1 _inst_2) {s : \u03c3R} (x : Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R 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 \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R 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 \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R \u03c3R _inst_1 _inst_5 _inst_7 s) _inst_2) (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) (fun (_x : Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R 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 \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R 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 \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R \u03c3R _inst_1 _inst_5 _inst_7 s) _inst_2) (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) S (NonUnitalNonAssocSemiring.toMul.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) (SubsemiringClass.toNonAssocSemiring.{u2, u1} R \u03c3R _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 \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R \u03c3R _inst_1 _inst_5 _inst_7 s) _inst_2) (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) (SubsemiringClass.toNonAssocSemiring.{u2, u1} R \u03c3R _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 \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R \u03c3R _inst_1 _inst_5 _inst_7 s) _inst_2) (Subtype.{succ u2} R (fun (x : R) => Membership.mem.{u2, u1} R \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R \u03c3R _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 \u03c3R (SetLike.instMembership.{u1, u2} \u03c3R R _inst_5) x s)) S (SubsemiringClass.toNonAssocSemiring.{u2, u1} R \u03c3R _inst_1 _inst_5 _inst_7 s) _inst_2)))) (RingHom.domRestrict.{u2, u3, u1} R S _inst_1 _inst_2 \u03c3R _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} \u03c3R R _inst_5 s)) x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.restrict_apply RingHom.restrict_apply\u2093'. -/\n@[simp]\ntheorem restrict_apply (f : R \u2192+* S) {s : \u03c3R} (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] {\u03c3S : Type.{u3}} [_inst_6 : SetLike.{u3, u2} \u03c3S S] [_inst_8 : SubsemiringClass.{u2, u3} \u03c3S S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : \u03c3S), (forall (x : R), Membership.Mem.{u2, u3} S \u03c3S (SetLike.hasMem.{u3, u2} \u03c3S 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)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u3, u2} \u03c3S S _inst_6) s) _inst_1 (SubsemiringClass.toNonAssocSemiring.{u2, u3} S \u03c3S _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] {\u03c3S : Type.{u3}} [_inst_6 : SetLike.{u3, u2} \u03c3S S] [_inst_8 : SubsemiringClass.{u2, u3} \u03c3S S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s : \u03c3S), (forall (x : R), Membership.mem.{u2, u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) \u03c3S (SetLike.instMembership.{u3, u2} \u03c3S 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 \u03c3S (SetLike.instMembership.{u3, u2} \u03c3S S _inst_6) x s)) _inst_1 (SubsemiringClass.toNonAssocSemiring.{u2, u3} S \u03c3S _inst_2 _inst_6 _inst_8 s))\nCase conversion may be inaccurate. Consider using '#align ring_hom.cod_restrict RingHom.codRestrict\u2093'. -/\n/-- Restriction of a ring homomorphism to a subsemiring of the codomain. -/\ndef codRestrict (f : R \u2192+* S) (s : \u03c3S) (h : \u2200 x, f x \u2208 s) : R \u2192+* s :=\n  { (f : R \u2192* S).codRestrict s h, (f : R \u2192+ S).codRestrict s h with toFun := fun n => \u27e8f n, h n\u27e9 }\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] {\u03c3R : Type.{u3}} {\u03c3S : Type.{u4}} [_inst_5 : SetLike.{u3, u1} \u03c3R R] [_inst_6 : SetLike.{u4, u2} \u03c3S S] [_inst_7 : SubsemiringClass.{u1, u3} \u03c3R R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u2, u4} \u03c3S S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s' : \u03c3R) (s : \u03c3S), (forall (x : R), (Membership.Mem.{u1, u3} R \u03c3R (SetLike.hasMem.{u3, u1} \u03c3R R _inst_5) x s') -> (Membership.Mem.{u2, u4} S \u03c3S (SetLike.hasMem.{u4, u2} \u03c3S 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)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S \u03c3S _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] {\u03c3R : Type.{u3}} {\u03c3S : Type.{u4}} [_inst_5 : SetLike.{u3, u1} \u03c3R R] [_inst_6 : SetLike.{u4, u2} \u03c3S S] [_inst_7 : SubsemiringClass.{u1, u3} \u03c3R R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u2, u4} \u03c3S S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s' : \u03c3R) (s : \u03c3S), (forall (x : R), (Membership.mem.{u1, u3} R \u03c3R (SetLike.instMembership.{u3, u1} \u03c3R R _inst_5) x s') -> (Membership.mem.{u2, u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) \u03c3S (SetLike.instMembership.{u4, u2} \u03c3S 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 \u03c3R (SetLike.instMembership.{u3, u1} \u03c3R R _inst_5) x s')) (Subtype.{succ u2} S (fun (x : S) => Membership.mem.{u2, u4} S \u03c3S (SetLike.instMembership.{u4, u2} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S \u03c3S _inst_2 _inst_6 _inst_8 s))\nCase conversion may be inaccurate. Consider using '#align ring_hom.restrict RingHom.restrict\u2093'. -/\n/-- The ring homomorphism from the preimage of `s` to `s`. -/\ndef restrict (f : R \u2192+* S) (s' : \u03c3R) (s : \u03c3S) (h : \u2200 x \u2208 s', f x \u2208 s) : s' \u2192+* 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] {\u03c3R : Type.{u3}} {\u03c3S : Type.{u4}} [_inst_5 : SetLike.{u3, u1} \u03c3R R] [_inst_6 : SetLike.{u4, u2} \u03c3S S] [_inst_7 : SubsemiringClass.{u1, u3} \u03c3R R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u2, u4} \u03c3S S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s' : \u03c3R) (s : \u03c3S) (h : forall (x : R), (Membership.Mem.{u1, u3} R \u03c3R (SetLike.hasMem.{u3, u1} \u03c3R R _inst_5) x s') -> (Membership.Mem.{u2, u4} S \u03c3S (SetLike.hasMem.{u4, u2} \u03c3S 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)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R 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)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) S (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) S (CoeTC\u2093.coe.{succ u2, succ u2} (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) S (coeBase.{succ u2, succ u2} (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) S (coeSubtype.{succ u2} S (fun (x : S) => Membership.Mem.{u2, u4} S \u03c3S (SetLike.hasMem.{u4, u2} \u03c3S 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)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S \u03c3S _inst_2 _inst_6 _inst_8 s)) (fun (_x : RingHom.{u1, u2} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S \u03c3S _inst_2 _inst_6 _inst_8 s)) => (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') -> (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s)) (RingHom.hasCoeToFun.{u1, u2} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S \u03c3S _inst_2 _inst_6 _inst_8 s)) (RingHom.restrict.{u1, u2, u3, u4} R S _inst_1 _inst_2 \u03c3R \u03c3S _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)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') R (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') R (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') R (coeBase.{succ u1, succ u1} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') R (coeSubtype.{succ u1} R (fun (x : R) => Membership.Mem.{u1, u3} R \u03c3R (SetLike.hasMem.{u3, u1} \u03c3R 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] {\u03c3R : Type.{u2}} {\u03c3S : Type.{u1}} [_inst_5 : SetLike.{u2, u3} \u03c3R R] [_inst_6 : SetLike.{u1, u4} \u03c3S S] [_inst_7 : SubsemiringClass.{u3, u2} \u03c3R R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u4, u1} \u03c3S S _inst_2 _inst_6] (f : RingHom.{u3, u4} R S _inst_1 _inst_2) (s' : \u03c3R) (s : \u03c3S) (h : forall (x : R), (Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s') -> (Membership.mem.{u4, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S 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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R 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} \u03c3S 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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _inst_2 _inst_6 _inst_8 s)) (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (fun (_x : Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R 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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) => Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S 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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _inst_2 _inst_6 _inst_8 s)) (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (NonUnitalNonAssocSemiring.toMul.{u3} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s'))) (NonUnitalNonAssocSemiring.toMul.{u4} (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _inst_2 _inst_6 _inst_8 s)) (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s')) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _inst_2 _inst_6 _inst_8 s)) (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _inst_2 _inst_6 _inst_8 s) (RingHom.instRingHomClassRingHom.{u3, u4} (Subtype.{succ u3} R (fun (x : R) => Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _inst_2 _inst_6 _inst_8 s))))) (RingHom.restrict.{u3, u4, u2, u1} R S _inst_1 _inst_2 \u03c3R \u03c3S _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} \u03c3R R _inst_5 s')) x))\nCase conversion may be inaccurate. Consider using '#align ring_hom.coe_restrict_apply RingHom.coe_restrict_apply\u2093'. -/\n@[simp]\ntheorem coe_restrict_apply (f : R \u2192+* S) (s' : \u03c3R) (s : \u03c3S) (h : \u2200 x \u2208 s', f x \u2208 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] {\u03c3R : Type.{u3}} {\u03c3S : Type.{u4}} [_inst_5 : SetLike.{u3, u1} \u03c3R R] [_inst_6 : SetLike.{u4, u2} \u03c3S S] [_inst_7 : SubsemiringClass.{u1, u3} \u03c3R R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u2, u4} \u03c3S S _inst_2 _inst_6] (f : RingHom.{u1, u2} R S _inst_1 _inst_2) (s' : \u03c3R) (s : \u03c3S) (h : forall (x : R), (Membership.Mem.{u1, u3} R \u03c3R (SetLike.hasMem.{u3, u1} \u03c3R R _inst_5) x s') -> (Membership.Mem.{u2, u4} S \u03c3S (SetLike.hasMem.{u4, u2} \u03c3S 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)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s') _inst_2) (RingHom.comp.{u1, u2, u2} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') (coeSort.{succ u4, succ (succ u2)} \u03c3S Type.{u2} (SetLike.hasCoeToSort.{u4, u2} \u03c3S S _inst_6) s) S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u2, u4} S \u03c3S _inst_2 _inst_6 _inst_8 s) _inst_2 (SubsemiringClass.subtype.{u2, u4} S \u03c3S _inst_2 _inst_6 _inst_8 s) (RingHom.restrict.{u1, u2, u3, u4} R S _inst_1 _inst_2 \u03c3R \u03c3S _inst_5 _inst_6 _inst_7 _inst_8 f s' s h)) (RingHom.comp.{u1, u1, u2} (coeSort.{succ u3, succ (succ u1)} \u03c3R Type.{u1} (SetLike.hasCoeToSort.{u3, u1} \u03c3R R _inst_5) s') R S (SubsemiringClass.toNonAssocSemiring.{u1, u3} R \u03c3R _inst_1 _inst_5 _inst_7 s') _inst_1 _inst_2 f (SubsemiringClass.subtype.{u1, u3} R \u03c3R _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] {\u03c3R : Type.{u2}} {\u03c3S : Type.{u1}} [_inst_5 : SetLike.{u2, u3} \u03c3R R] [_inst_6 : SetLike.{u1, u4} \u03c3S S] [_inst_7 : SubsemiringClass.{u3, u2} \u03c3R R _inst_1 _inst_5] [_inst_8 : SubsemiringClass.{u4, u1} \u03c3S S _inst_2 _inst_6] (f : RingHom.{u3, u4} R S _inst_1 _inst_2) (s' : \u03c3R) (s : \u03c3S) (h : forall (x : R), (Membership.mem.{u3, u2} R \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s') -> (Membership.mem.{u4, u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => S) x) \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S 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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) S (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) (Subtype.{succ u4} S (fun (x : S) => Membership.mem.{u4, u1} S \u03c3S (SetLike.instMembership.{u1, u4} \u03c3S S _inst_6) x s)) S (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s') (SubsemiringClass.toNonAssocSemiring.{u4, u1} S \u03c3S _inst_2 _inst_6 _inst_8 s) _inst_2 (SubsemiringClass.subtype.{u4, u1} S \u03c3S _inst_2 _inst_6 _inst_8 s) (RingHom.restrict.{u3, u4, u2, u1} R S _inst_1 _inst_2 \u03c3R \u03c3S _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 \u03c3R (SetLike.instMembership.{u2, u3} \u03c3R R _inst_5) x s')) R S (SubsemiringClass.toNonAssocSemiring.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s') _inst_1 _inst_2 f (SubsemiringClass.subtype.{u3, u2} R \u03c3R _inst_1 _inst_5 _inst_7 s'))\nCase conversion may be inaccurate. Consider using '#align ring_hom.comp_restrict RingHom.comp_restrict\u2093'. -/\n@[simp]\ntheorem comp_restrict (f : R \u2192+* S) (s' : \u03c3R) (s : \u03c3S) (h : \u2200 x \u2208 s', f x \u2208 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\u2093'. -/\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 \u2192+* S) : R \u2192+* 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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_rangeSRestrict (f : R \u2192+* 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\u2093'. -/\ntheorem rangeSRestrict_surjective (f : R \u2192+* S) : Function.Surjective f.srangeRestrict :=\n  fun \u27e8y, hy\u27e9 =>\n  let \u27e8x, hx\u27e9 := mem_rangeS.mp hy\n  \u27e8x, Subtype.ext hx\u27e9\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\u2093'. -/\ntheorem rangeS_top_iff_surjective {f : R \u2192+* S} :\n    f.srange = (\u22a4 : Subsemiring S) \u2194 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\u2093'. -/\n/-- The range of a surjective ring homomorphism is the whole of the codomain. -/\ntheorem rangeS_top_of_surjective (f : R \u2192+* S) (hf : Function.Surjective f) :\n    f.srange = (\u22a4 : 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 \u2192+* S) : Subsemiring R :=\n  { (f : R \u2192* S).eqLocus g, (f : R \u2192+ 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\u2093'. -/\n@[simp]\ntheorem eqLocusS_same (f : R \u2192+* S) : f.eqLocusS f = \u22a4 :=\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\u2093.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\u2093'. -/\n/-- If two ring homomorphisms are equal on a set, then they are equal on its subsemiring closure. -/\ntheorem eqOn_sclosure {f g : R \u2192+* S} {s : Set R} (h : Set.EqOn f g s) : Set.EqOn f g (closure s) :=\n  show closure s \u2264 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\u2093.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\u2093'. -/\ntheorem eq_of_eqOn_stop {f g : R \u2192+* S} (h : Set.EqOn f g (\u22a4 : 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\u2093'. -/\ntheorem eq_of_eqOn_sdense {s : Set R} (hs : closure s = \u22a4) {f g : R \u2192+* S} (h : s.EqOn f g) :\n    f = g :=\n  eq_of_eqOn_stop <| hs \u25b8 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\u2093'. -/\ntheorem sclosure_preimage_le (f : R \u2192+* S) (s : Set S) : closure (f \u207b\u00b9' s) \u2264 (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 \u2192+* 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\u2093'. -/\n/-- The ring homomorphism associated to an inclusion of subsemirings. -/\ndef inclusion {S T : Subsemiring R} (h : S \u2264 T) : S \u2192+* 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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem range_fst : (fst R S).srange = \u22a4 :=\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\u2093'. -/\n@[simp]\ntheorem range_snd : (snd R S).srange = \u22a4 :=\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\u2093'. -/\n@[simp]\ntheorem prod_bot_sup_bot_prod (s : Subsemiring R) (t : Subsemiring S) :\n    s.Prod \u22a5 \u2294 prod \u22a5 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 \u25b8\n      mul_mem\n        ((le_sup_left : s.Prod \u22a5 \u2264 s.Prod \u22a5 \u2294 prod \u22a5 t) \u27e8hp.1, SetLike.mem_coe.2 <| one_mem \u22a5\u27e9)\n        ((le_sup_right : prod \u22a5 t \u2264 s.Prod \u22a5 \u2294 prod \u22a5 t) \u27e8SetLike.mem_coe.2 <| one_mem \u22a5, hp.2\u27e9)\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\u2093'. -/\n/-- Makes the identity isomorphism from a proof two subsemirings of a multiplicative\n    monoid are equal. -/\ndef subsemiringCongr (h : s = t) : s \u2243+* 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\u2093'. -/\n/-- Restrict a ring homomorphism with a left inverse to a ring isomorphism to its\n`ring_hom.srange`. -/\ndef ofLeftInverseS {g : S \u2192 R} {f : R \u2192+* S} (h : Function.LeftInverse g f) : R \u2243+* f.srange :=\n  { f.srangeRestrict with\n    toFun := fun x => f.srangeRestrict x\n    invFun := fun x => (g \u2218 f.srange.Subtype) x\n    left_inv := h\n    right_inv := fun x =>\n      Subtype.ext <|\n        let \u27e8x', hx'\u27e9 := RingHom.mem_rangeS.mp x.Prop\n        show f (g x) = x by rw [\u2190 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\u2093.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\u2093'. -/\n@[simp]\ntheorem ofLeftInverseS_apply {g : S \u2192 R} {f : R \u2192+* S} (h : Function.LeftInverse g f) (x : R) :\n    \u2191(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\u2093.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\u2093'. -/\n@[simp]\ntheorem ofLeftInverseS_symm_apply {g : S \u2192 R} {f : R \u2192+* 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\u2093'. -/\n/-- Given an equivalence `e : R \u2243+* 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 \u2243+* S) (s : Subsemiring R) : s \u2243+* 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' \u03b1 \u03b2 : 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' \u03b1] (S : Subsemiring R') : SMul S \u03b1 :=\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}} {\u03b1 : Type.{u2}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u1, u2} R' \u03b1] {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 : \u03b1), Eq.{succ u2} \u03b1 (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) \u03b1 (Subsemiring.hasSmul.{u1, u2} R' \u03b1 _inst_4 _inst_5 S) g m) (SMul.smul.{u1, u2} R' \u03b1 _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\u2093.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}} {\u03b1 : Type.{u1}} [_inst_4 : NonAssocSemiring.{u2} R'] [_inst_5 : SMul.{u2, u1} R' \u03b1] {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 : \u03b1), Eq.{succ u1} \u03b1 (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)) \u03b1 \u03b1 (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)) \u03b1 (Subsemiring.smul.{u2, u1} R' \u03b1 _inst_4 _inst_5 S)) g m) (HSMul.hSMul.{u2, u1, u1} R' \u03b1 \u03b1 (instHSMul.{u2, u1} R' \u03b1 _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\u2093'. -/\ntheorem smul_def [SMul R' \u03b1] {S : Subsemiring R'} (g : S) (m : \u03b1) : g \u2022 m = (g : R') \u2022 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}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u1, u3} R' \u03b2] [_inst_6 : SMul.{u2, u3} \u03b1 \u03b2] [_inst_7 : SMulCommClass.{u1, u2, u3} R' \u03b1 \u03b2 _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) \u03b1 \u03b2 (Subsemiring.hasSmul.{u1, u3} R' \u03b2 _inst_4 _inst_5 S) _inst_6\nbut is expected to have type\n  forall {R' : Type.{u1}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u1, u3} R' \u03b2] [_inst_6 : SMul.{u2, u3} \u03b1 \u03b2] [_inst_7 : SMulCommClass.{u1, u2, u3} R' \u03b1 \u03b2 _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)) \u03b1 \u03b2 (Subsemiring.smul.{u1, u3} R' \u03b2 _inst_4 _inst_5 S) _inst_6\nCase conversion may be inaccurate. Consider using '#align subsemiring.smul_comm_class_left Subsemiring.smulCommClass_left\u2093'. -/\ninstance smulCommClass_left [SMul R' \u03b2] [SMul \u03b1 \u03b2] [SMulCommClass R' \u03b1 \u03b2] (S : Subsemiring R') :\n    SMulCommClass S \u03b1 \u03b2 :=\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}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u2, u3} \u03b1 \u03b2] [_inst_6 : SMul.{u1, u3} R' \u03b2] [_inst_7 : SMulCommClass.{u2, u1, u3} \u03b1 R' \u03b2 _inst_5 _inst_6] (S : Subsemiring.{u1} R' _inst_4), SMulCommClass.{u2, u1, u3} \u03b1 (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) \u03b2 _inst_5 (Subsemiring.hasSmul.{u1, u3} R' \u03b2 _inst_4 _inst_6 S)\nbut is expected to have type\n  forall {R' : Type.{u1}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_4 : NonAssocSemiring.{u1} R'] [_inst_5 : SMul.{u2, u3} \u03b1 \u03b2] [_inst_6 : SMul.{u1, u3} R' \u03b2] [_inst_7 : SMulCommClass.{u2, u1, u3} \u03b1 R' \u03b2 _inst_5 _inst_6] (S : Subsemiring.{u1} R' _inst_4), SMulCommClass.{u2, u1, u3} \u03b1 (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)) \u03b2 _inst_5 (Subsemiring.smul.{u1, u3} R' \u03b2 _inst_4 _inst_6 S)\nCase conversion may be inaccurate. Consider using '#align subsemiring.smul_comm_class_right Subsemiring.smulCommClass_right\u2093'. -/\ninstance smulCommClass_right [SMul \u03b1 \u03b2] [SMul R' \u03b2] [SMulCommClass \u03b1 R' \u03b2] (S : Subsemiring R') :\n    SMulCommClass \u03b1 S \u03b2 :=\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 \u03b1 \u03b2] [SMul R' \u03b1] [SMul R' \u03b2] [IsScalarTower R' \u03b1 \u03b2] (S : Subsemiring R') :\n    IsScalarTower S \u03b1 \u03b2 :=\n  S.toSubmonoid.IsScalarTower\n\ninstance [SMul R' \u03b1] [FaithfulSMul R' \u03b1] (S : Subsemiring R') : FaithfulSMul S \u03b1 :=\n  S.toSubmonoid.FaithfulSMul\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Zero \u03b1] [SMulWithZero R' \u03b1] (S : Subsemiring R') : SMulWithZero S \u03b1 :=\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' \u03b1] (S : Subsemiring R') : MulAction S \u03b1 :=\n  S.toSubmonoid.MulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [AddMonoid \u03b1] [DistribMulAction R' \u03b1] (S : Subsemiring R') : DistribMulAction S \u03b1 :=\n  S.toSubmonoid.DistribMulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Monoid \u03b1] [MulDistribMulAction R' \u03b1] (S : Subsemiring R') : MulDistribMulAction S \u03b1 :=\n  S.toSubmonoid.MulDistribMulAction\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Zero \u03b1] [MulActionWithZero R' \u03b1] (S : Subsemiring R') : MulActionWithZero S \u03b1 :=\n  MulActionWithZero.compHom _ S.Subtype.toMonoidWithZeroHom\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [AddCommMonoid \u03b1] [Module R' \u03b1] (S : Subsemiring R') : Module S \u03b1 :=\n  { Module.compHom _ S.Subtype with smul := (\u00b7 \u2022 \u00b7) }\n\n/-- The action by a subsemiring is the action by the underlying semiring. -/\ninstance [Semiring \u03b1] [MulSemiringAction R' \u03b1] (S : Subsemiring R') : MulSemiringAction S \u03b1 :=\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\n/-- If all the elements of a set `s` commute, then `closure s` is a commutative monoid. -/\ndef closureCommSemiringOfComm {s : Set R'} (hcomm : \u2200 a \u2208 s, \u2200 b \u2208 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\u2082 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\u2081 h\u2082 => by simp only [add_mul, mul_add, h\u2081, h\u2082])\n          (fun x y z h\u2081 h\u2082 => by simp only [add_mul, mul_add, h\u2081, h\u2082])\n          (fun x y z h\u2081 h\u2082 => by rw [mul_assoc, h\u2082, \u2190 mul_assoc, h\u2081, mul_assoc]) fun x y z h\u2081 h\u2082 =>\n          by rw [\u2190 mul_assoc, h\u2081, mul_assoc, h\u2082, \u2190 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem mem_posSubmonoid {R : Type _} [StrictOrderedSemiring R] (u : R\u02e3) :\n    \u2191u \u2208 posSubmonoid R \u2194 (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": "import Smt\n\ntheorem neq_zero : \u2200 (x : Nat), x \u2260 0 := by\n  smt\n  admit\n\ntheorem succ_neq_zero : \u2200 (x : Nat), x + 1 \u2260 0 := by\n  smt\n  admit\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/Nat/NeqZero.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8221891305219504, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.4685266559918339}}
{"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)) \u2192 (eta_equalizer_iso_forward : pq_group (eta_equalizer Q) \u2192* pq_group Q).ker :=\nbegin\n  intro x,\n  fconstructor,\n  exact x * ((eta_equalizer_iso_backward) (eta_equalizer_iso_forward x))\u207b\u00b9,\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))\u207b\u00b9  = \u2191(eq_left_split_fun x) := rfl\n\nlemma eq_left_split_coe_commutes (x y : pq_group (eta_equalizer Q)) : x * \u2191(eq_left_split_fun y) = \u2191(eq_left_split_fun y) * x :=\nbegin\n  rw \u2190eq_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 \u2190mul_assoc,\n    simp only [mul_left_inj],\n    clear hx x _inst,\n    sorry,\n  },\n  /-\n  rw \u2190eq_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)))\u207b\u00b9 =  of a * (eta_equalizer_iso_backward (eta_equalizer_iso_forward (of a)))\u207b\u00b9 * 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 (\u27e81, ha\u27e9 : eta_equalizer Q) = 1,\n      rw this,\n      simp only [mul_one, one_mul],\n      simp_rw \u2190of_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)) \u2192* (counit : pq_group (pq_group Q) \u2192* (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 \u2190mul_assoc b, \n    rw left_split_fun_def b,\n    rw \u2190mul_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) \u2192* (pq_group Q)).ker) : left_split_hom (\u2191x) = 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) \u2243* pq_group Q \u00d7 (counit : pq_group (pq_group Q) \u2192* pq_group Q).ker := { \n  to_fun := \u03bb x, \u27e8counit x, left_split_hom x\u27e9,\n  inv_fun := \u03bb 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 \u2245 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 \u2245 Y` is not empty. -/\ndef is_isomorphic {C : Type u} [category C] : C \u2192 C \u2192 Prop := fun (X Y : C) => Nonempty (X \u2245 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 \u2964 Type u :=\n  functor.mk (fun (C : Cat) => quotient (is_isomorphic_setoid (bundled.\u03b1 C)))\n    fun (C D : Cat) (F : C \u27f6 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 \u2194 Nonempty (X \u27f6 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\u00f6lzl, 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} {\u03b9 : 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\u27e8submodule.carrier, \u03bb p q h, by cases p; cases q; congr'\u27e9\n\n@[simp] theorem mem_to_add_submonoid (p : submodule R M) (x : M) : x \u2208 p.to_add_submonoid \u2194 x \u2208 p :=\niff.rfl\n\nvariables {p q : submodule R M}\n\n@[simp]\nlemma mem_mk {S : set M} {x : M} (h\u2081 h\u2082 h\u2083) : x \u2208 (\u27e8S, h\u2081, h\u2082, h\u2083\u27e9 : submodule R M) \u2194 x \u2208 S :=\niff.rfl\n\n@[simp] lemma coe_set_mk (S : set M) (h\u2081 h\u2082 h\u2083) :\n  ((\u27e8S, h\u2081, h\u2082, h\u2083\u27e9 : submodule R M) : set M) = S := rfl\n\n@[simp]\nlemma mk_le_mk {S S' : set M} (h\u2081 h\u2082 h\u2083 h\u2081' h\u2082' h\u2083') :\n  (\u27e8S, h\u2081, h\u2082, h\u2083\u27e9 : submodule R M) \u2264 (\u27e8S', h\u2081', h\u2082', h\u2083'\u27e9 : submodule R M) \u2194 S \u2286 S' := iff.rfl\n\n@[ext] theorem ext (h : \u2200 x, x \u2208 p \u2194 x \u2208 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 = \u2191p) : submodule R M :=\n{ carrier := s,\n  zero_mem' := hs.symm \u25b8 p.zero_mem',\n  add_mem' := hs.symm \u25b8 p.add_mem',\n  smul_mem' := hs.symm \u25b8 p.smul_mem' }\n\n@[simp] lemma coe_copy (S : submodule R M) (s : set M) (hs : s = \u2191S) :\n  (S.copy s hs : set M) = s := rfl\n\nlemma copy_eq (S : submodule R M) (s : set M) (hs : s = \u2191S) : S.copy s hs = S :=\nset_like.coe_injective hs\n\ntheorem to_add_submonoid_injective :\n  injective (to_add_submonoid : submodule R M \u2192 add_submonoid M) :=\n\u03bb 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 \u2194 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 \u2192 add_submonoid M) := \u03bb _ _, id\n\n@[mono]\nlemma to_add_submonoid_mono : monotone (to_add_submonoid : submodule R M \u2192 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 \u2192 sub_mul_action R M) :=\n\u03bb 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 \u2194 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 \u2192 sub_mul_action R M) := \u03bb _ _, id\n\n@[mono]\nlemma to_sub_mul_action_mono : monotone (to_sub_mul_action : submodule R M \u2192 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 \u2208 p.carrier \u2194 x \u2208 (p : set M) := iff.rfl\n\n@[simp] lemma zero_mem : (0 : M) \u2208 p := p.zero_mem'\n\nlemma add_mem (h\u2081 : x \u2208 p) (h\u2082 : y \u2208 p) : x + y \u2208 p := p.add_mem' h\u2081 h\u2082\n\nlemma smul_mem (r : R) (h : x \u2208 p) : r \u2022 x \u2208 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 \u2208 p) : r \u2022 x \u2208 p :=\np.to_sub_mul_action.smul_of_tower_mem r h\n\nlemma sum_mem {t : finset \u03b9} {f : \u03b9 \u2192 M} : (\u2200c\u2208t, f c \u2208 p) \u2192 (\u2211 i in t, f i) \u2208 p :=\np.to_add_submonoid.sum_mem\n\nlemma sum_smul_mem {t : finset \u03b9} {f : \u03b9 \u2192 M} (r : \u03b9 \u2192 R)\n    (hyp : \u2200 c \u2208 t, f c \u2208 p) : (\u2211 i in t, r i \u2022 f i) \u2208 p :=\nsubmodule.sum_mem _ (\u03bb 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 \u2022 x \u2208 p \u2194 x \u2208 p :=\np.to_sub_mul_action.smul_mem_iff' g\n\ninstance : has_add p := \u27e8\u03bbx y, \u27e8x.1 + y.1, add_mem _ x.2 y.2\u27e9\u27e9\ninstance : has_zero p := \u27e8\u27e80, zero_mem _\u27e9\u27e9\ninstance : inhabited p := \u27e80\u27e9\ninstance [has_scalar S R] [has_scalar S M] [is_scalar_tower S R M] :\n  has_scalar S p := \u27e8\u03bb c x, \u27e8c \u2022 x.1, smul_of_tower_mem _ c x.2\u27e9\u27e9\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 := \u27e80, p.zero_mem\u27e9\n\n@[simp] lemma mk_eq_zero {x} (h : x \u2208 p) : (\u27e8x, h\u27e9 : p) = 0 \u2194 x = 0 := subtype.ext_iff_val\n\nvariables {p}\n@[simp, norm_cast] lemma coe_eq_zero {x : p} : (x : M) = 0 \u2194 x = 0 :=\n(set_like.coe_eq_coe : (x : M) = (0 : p) \u2194 x = 0)\n@[simp, norm_cast] lemma coe_add (x y : p) : (\u2191(x + y) : M) = \u2191x + \u2191y := rfl\n@[simp, norm_cast] lemma coe_zero : ((0 : p) : M) = 0 := rfl\n@[norm_cast] lemma coe_smul (r : R) (x : p) : ((r \u2022 x : p) : M) = r \u2022 \u2191x := 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 \u2022 x : p) : M) = r \u2022 \u2191x := rfl\n@[simp, norm_cast] lemma coe_mk (x : M) (hx : x \u2208 p) : ((\u27e8x, hx\u27e9 : p) : M) = x := rfl\n@[simp] lemma coe_mem (x : p) : (x : M) \u2208 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 := (\u2022), ..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\u27e8\u03bb c x h,\n  have c = 0 \u2228 (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\u27e9\n\n/-- Embedding of a submodule `p` to the ambient space `M`. -/\nprotected def subtype : p \u2192\u2097[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 \u2192 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 : \u03b9 \u2192 p) (s : finset \u03b9) : \u2191(\u2211 i in s, x i) = \u2211 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' := \u03bb c m h, V.smul_of_tower_mem c h,\n  add_mem' := \u03bb 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 \u2208 V.restrict_scalars S \u2194 m \u2208 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 \u2192 submodule S M) :=\n\u03bb V\u2081 V\u2082 h, ext $ set.ext_iff.1 (set_like.ext'_iff.1 h : _)\n\n@[simp] lemma restrict_scalars_inj {V\u2081 V\u2082 : submodule R M} :\n  restrict_scalars S V\u2081 = restrict_scalars S V\u2082 \u2194 V\u2081 = V\u2082 :=\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 := \u03bb 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 \u21aao submodule S M :=\n{ to_fun := restrict_scalars S,\n  inj' := restrict_scalars_injective S R M,\n  map_rel_iff' := \u03bb 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 \u2243\u2097[R] p :=\n{ to_fun := id, inv_fun := id, map_smul' := \u03bb 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 \u2208 p) : -x \u2208 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' := \u03bb _, 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 \u2208 p.to_add_subgroup \u2194 x \u2208 p := iff.rfl\n\ninclude module_M\n\ntheorem to_add_subgroup_injective : injective (to_add_subgroup : submodule R M \u2192 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 \u2194 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 \u2192 add_subgroup M) := \u03bb _ _, id\n\n@[mono] lemma to_add_subgroup_mono : monotone (to_add_subgroup : submodule R M \u2192 add_subgroup M) :=\nto_add_subgroup_strict_mono.monotone\n\nomit module_M\n\nlemma sub_mem : x \u2208 p \u2192 y \u2208 p \u2192 x - y \u2208 p := p.to_add_subgroup.sub_mem\n\n@[simp] lemma neg_mem_iff : -x \u2208 p \u2194 x \u2208 p := p.to_add_subgroup.neg_mem_iff\n\nlemma add_mem_iff_left : y \u2208 p \u2192 (x + y \u2208 p \u2194 x \u2208 p) := p.to_add_subgroup.add_mem_cancel_right\n\nlemma add_mem_iff_right : x \u2208 p \u2192 (x + y \u2208 p \u2194 y \u2208 p) := p.to_add_subgroup.add_mem_cancel_left\n\ninstance : has_neg p := \u27e8\u03bbx, \u27e8-x.1, neg_mem _ x.2\u27e9\u27e9\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) : (\u2191(x - y) : M) = \u2191x - \u2191y := 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 : \u03b9 \u2192 M}\n\nlemma not_mem_of_ortho {x : M} {N : submodule R M}\n  (ortho : \u2200 (c : R) (y \u2208 N), c \u2022 x + y = (0 : M) \u2192 c = 0) :\n  x \u2209 N :=\nby { intro hx, simpa using ortho (-1) x hx }\n\nlemma ne_zero_of_ortho {x : M} {N : submodule R M}\n  (ortho : \u2200 (c : R) (y \u2208 N), c \u2022 x + y = (0 : M) \u2192 c = 0) :\n  x \u2260 0 :=\nmt (\u03bb h, show x \u2208 N, from h.symm \u25b8 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, 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 (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, 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 \u2260 0) : s \u2022 x \u2208 p \u2194 x \u2208 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 \u211d := {\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 \u2102 := {\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 \u211d \u211d :=\n{\n    exp                   := real.exp,\n    exp_homomorphism_zero := real.exp_zero,\n    exp_homomorphism      := real.exp_add,\n    exp_homomorphism_inv  := \u03bb _ _, by rw [real.exp_sub, division_def],\n    exp_injective         := \u03bb _ _ eq, real.exp_injective eq,\n    exp_monotonic         := \u03bb _ _ lt, real.exp_lt_exp.mpr lt,\n    exp_monotonic_reverse := \u03bb _ _ lt, real.exp_lt_exp.mp lt,\n    exp_positive          := real.exp_pos,\n    log                   := \u03bb a _, real.log a,\n    log_domain_irrel      := \u03bb _ _ _ _ eq, by rw eq,\n    log_inverted          := \u03bb _ apos, by rw real.exp_log apos,\n}\n\n/--\n-/\ndef complex_witness.proofs.abs_exp_is_exp_real_part\n    : \u03a0 z, complex.abs (complex.exp z) = real.exp (complex.re z) :=\nbegin\n    intros,\n    rw [\u2190 complex.exp_of_real_re,\n          complex.abs_exp_eq_iff_re_eq.mpr,\n        \u2190 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 \u211d abs) (g : cau_seq \u211d abs)\n    : (\u2203 j, \u2200 i, j \u2264 i \u2192 f i \u2264 g i) \u2192 f.lim \u2264 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    : \u03a0 x, complex.abs x \u2264 1 \u2192 \u03a0 (n : \u2115), complex.abs (x ^ n) \u2264 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    : \u03a0 x, complex.abs x \u2264 1\n    \u2192 \u03a0 z, complex.abs (complex.exp (x * z) - (x * z + 1))\n        \u2264 (complex.abs x * complex.abs x) * real.exp (complex.abs z) :=\nbegin\n    intros _ x_le_1 _,\n    rw complex.exp,\n    rw \u2190 cau_seq.lim_const (x*z+1),\n    rw sub_eq_add_neg,\n    rw \u2190 cau_seq.lim_neg,\n    rw cau_seq.lim_add,\n    rw \u2190 complex.lim_abs,\n    rw real.exp,\n    rw complex.exp,\n    rw \u2190 complex.lim_re,\n    rw \u2190 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' \u2191(complex.abs z))) i\n          = (\u2211 k in finset.range i, ((complex.abs z) : \u2102) ^ k / k.fact).re),\n\n    rw \u2190 (finset.range _).sum_hom complex.re,\n    norm_cast,\n\n    show complex.abs (\u2211 k in finset.range i, (x * z) ^ k / k.fact - (x * z + 1))\n            \u2264 (\u2211 k in finset.range i, (complex.abs z) ^ k / k.fact) * (complex.abs x * complex.abs x),\n\n    rw (_ : (x * z + 1) = \u2211 k in finset.range 2, (x * z) ^ k / \u2191(k.fact)),\n\n    rw sum_range_sub_sum_range i_ge_2,\n\n    rw (_ : complex.abs (\u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), (x * z) ^ k / \u2191(k.fact))\n          = complex.abs (\u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), x ^ 2 * x ^ (k - 2) * z ^ k / \u2191(k.fact))),\n\n    rw (_ : (\u2211 k in finset.range i, complex.abs z ^ k / \u2191(k.fact))\n          = (\u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs z ^ k / \u2191(k.fact) + (1 + complex.abs z))),\n\n    rw (_ : (\u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs z ^ k / \u2191(k.fact) + (1 + complex.abs z))\n          * (complex.abs x * complex.abs x)\n          = complex.abs x ^ 2\n          * (\u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs z ^ k / \u2191(k.fact) + (1 + complex.abs z))),\n\n    have drop_extra_powers_of_x\n        : complex.abs (\u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), x ^ 2 * x ^ (k - 2) * z ^ k / \u2191(k.fact))\n        \u2264 \u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs x ^ 2 * (complex.abs z ^ k / \u2191(k.fact)),\n    {\n        refine le_trans (abv_sum_le_sum_abv _ _) (finset.sum_le_sum (\u03bb 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 \u2190 mul_div_assoc,\n        rw division_def,\n        rw division_def,\n        rw \u2190 is_absolute_value.abv_pow complex.abs z,\n        rw \u2190 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)) \u2264 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 (_ : \u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs z ^ k / \u2191(k.fact)\n          = \u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs z ^ k / \u2191(k.fact) + 0),\n\n    rw (_ : \u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs z ^ k / \u2191(k.fact) + 0 + (1 + complex.abs z)\n          = \u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs z ^ k / \u2191(k.fact) + (1 + complex.abs z)),\n\n    refine add_le_add_left _ (\u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), complex.abs z ^ k / \u2191(k.fact)),\n    rw (_ : (0 : \u211d) = 0 + 0),\n    refine add_le_add (by linarith) (complex.abs_nonneg _),\n    simp,\n    simp,\n    simp,\n    rw (_ : (0 : \u211d) = \u2211 k in (finset.range i).filter (\u03bb k, 2 \u2264 k), 0),\n    refine finset.sum_le_sum _,\n    intros m _,\n    rw (_ : complex.abs z ^ m / (m.fact : \u211d) = complex.abs z ^ m * (1 / (m.fact : \u211d))),\n    refine mul_nonneg _ _,\n    rw \u2190 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) = \u2211 k in finset.range 2, (complex.abs z) ^ k / \u2191(k.fact)),\n    rw \u2190 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 \u2190 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    : \u03a0 (x : \u211d) (p : 0 < 1 - x),\n        complex.abs \u2191x \u2264 2\u207b\u00b9 \u2192 complex.abs \u2191(real.log (1 - x)) \u2264 complex.abs \u2191x + complex.abs \u2191x :=\nbegin\n    intros _ _ x_le_half,\n    rw complex.abs_of_real at x_le_half,\n    simp,\n\n    have ineq0 : abs (\u2211 i in finset.range 0, x ^ (i + 1) / (\u2191i + 1) + real.log (1 - x))\n               \u2264 abs x ^ (0 + 1) / (1 - abs x),\n    {\n        refine real.abs_log_sub_add_sum_range_le _ _,\n        rw (_ : (2 : \u211d)\u207b\u00b9 = 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\u207b\u00b9)),\n\n    have ineq1 : -(2\u207b\u00b9) \u2264 -(abs x),\n        by refine neg_le_neg x_le_half,\n\n    have ineq2 : 1 - 2\u207b\u00b9 \u2264 1 - abs x,\n        by refine sub_le_sub_left x_le_half _,\n\n    have ineq3 : (1 - abs x)\u207b\u00b9 \u2264 (1 - 2\u207b\u00b9)\u207b\u00b9,\n    {\n        refine inv_le_inv_of_le _ _,\n        simp,\n        rw (_ : (2 : \u211d)\u207b\u00b9 = 1 / 2),\n        linarith,\n        simp,\n        refine ineq2,\n    },\n\n    have ineq4 : abs x / (1 - abs x) \u2264 abs x / (1 - 2\u207b\u00b9) ,\n    {\n        rw (_ : abs x / (1 - abs x) = (1 - abs x)\u207b\u00b9 * abs x),\n        rw (_ : abs x / (1 - 2\u207b\u00b9) = (1 - 2\u207b\u00b9)\u207b\u00b9 * abs x),\n        refine mul_le_mul ineq3 _ _ _,\n        refine le_refl _,\n        refine abs_nonneg _,\n        rw (_: (1 - (2 : \u211d)\u207b\u00b9)\u207b\u00b9 = 2),\n        linarith,\n        ring,\n        ring,\n        ring,\n    },\n\n    linarith,\n    ring,\nend\n\n/--\n-/\ndef complex_witness : Complex \u2102 \u211d :=\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     := \u03bb _ _, by rw [complex.exp_sub, division_def],\n    real_part_scaling        := \u03bb _ _, 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 \u2192 cau_seq \u2192 cau_seq :=\n\u03bb f g, \u27e8\u03bb 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 \u03b5 h\u03b5,\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\u03b5fpos : 0 < (\u03b5 / 2) / ug,\n    rw [div_def, \u2190zero_mul (0 : myrat)],\n    apply @lt_mul_comb_nonneg _ _ (0 : myrat) _ 0 _ (by refl) (by refl),\n      from half_pos h\u03b5,\n    from pos_impl_inv_pos hugpos,\n  have h\u03b5gpos : 0 < (\u03b5 / 2) / uf,\n    rw [div_def, \u2190zero_mul (0 : myrat)],\n    apply @lt_mul_comb_nonneg _ _ (0 : myrat) _ 0 _ (by refl) (by refl),\n      from half_pos h\u03b5,\n    from pos_impl_inv_pos hufpos,\n  cases hf ((\u03b5 / 2) / ug) h\u03b5fpos with M hM,\n  cases hg ((\u03b5 / 2) / uf) h\u03b5gpos with N hN,\n  clear h\u03b5fpos h\u03b5gpos 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 \u2264 m, from mynat.max_le_cancel_left hm,\n  have hMn : M \u2264 n, from mynat.max_le_cancel_left hn,\n  have hNm : N \u2264 m, from mynat.max_le_cancel_right hm,\n  have hNn : N \u2264 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)) \u2264\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 \u2260 0,\n    assume hufeq0,\n    from lt_impl_ne hufpos hufeq0.symm,\n  -- hug0 is frying right now\n  have hug0 : ug \u2260 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 \u2190half_plus_half myrat.two_nzero \u03b5,\n    congr,\n      rw \u2190div_mul_cancel (\u03b5 / 2) uf huf0,\n      rw mul_comm,\n      skip,\n    rw \u2190div_mul_cancel (\u03b5 / 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\u27e9\n\ninstance: has_mul cau_seq := \u27e8mul\u27e9\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 \u2192 cau_seq :=\n\u03bb f : cau_seq, \u27e8(\u03bb n : mynat, if f \u2248 (0 : cau_seq) then 0 else (f.val n)\u207b\u00b9),\nbegin\n  unfold is_cau_seq,\n  intros \u03b5 h\u03b5,\n  by_cases (f \u2248 (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\u03b5 : 0 < A * (A * \u03b5), {\n    rw \u2190mul_zero (0 : myrat),\n    apply @lt_mul_comb_nonneg _ _ 0 A 0 (A*\u03b5) (by refl) (by refl) hN.left,\n    rw \u2190mul_zero (0 : myrat),\n    apply @lt_mul_comb_nonneg _ _ 0 A 0 \u03b5 (by refl) (by refl) hN.left,\n    assumption,\n  },\n  cases hf (A*(A*\u03b5)) h0AA\u03b5 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 \u2260 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 [\u2190abs_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 \u2260 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, \u2190abs_mul, mul_add, mul_one, \u2190mul_assoc,\n      myring.mul_comm, neg_mul, \u2190mul_assoc, inv_mul hmzero, one_mul, \u2190sub_def],\n  suffices: A * (A * \u03b5) \u2264 abs (f.val m) * ((abs (f.val n)) * \u03b5),\n    apply lt_le_chain (A * (A * \u03b5)),\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 \u2190zero_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\u03b5,\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\u03b5,\n  }, {\n    have := hN.right n (mynat.max_le_cancel_right hn),\n    apply lt_impl_le,\n    assumption,\n  },\n  refl,\nend\u27e9\n\ninstance: has_inv cau_seq := \u27e8inv\u27e9\n\n-- Lemma to help rewrite definitional equalities\nlemma inv_val (f : cau_seq) (n : mynat) :\n(f\u207b\u00b9).val n = if f \u2248 (0 : cau_seq) then 0 else (f.val n)\u207b\u00b9 :=\nrfl\n\ntheorem inv_equiv_zero (a : cau_seq) (h : a \u2248 0) : a\u207b\u00b9 \u2248 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 \u2248 b) : a * x \u2248 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\u207b\u00b9,\n    apply zero_lt_mul,\n      assumption,\n    apply pos_impl_inv_pos,\n    assumption,\n  cases hab (q * u\u207b\u00b9) hqu with N hN,\n  existsi N,\n  intros n hn,\n  rw [cau_seq.mul_val, cau_seq.mul_val, \u2190sub_mul, abs_mul,\n     lt_mul_pos_right u\u207b\u00b9 (pos_impl_inv_pos hu)],\n  apply le_lt_chain (abs (a.val n - b.val n)), {\n    conv {\n      to_rhs,\n      rw \u2190mul_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 \u2260 0,\n        assume hu0,\n        apply lt_impl_ne hu,\n        symmetry, assumption,\n      rw \u2190mul_inv this,\n      have huinv : 0 \u2264 u\u207b\u00b9,\n        apply lt_impl_le,\n        apply pos_impl_inv_pos,\n        assumption,\n      apply le_mul_nonneg_right _ _ u\u207b\u00b9 huinv,\n      apply lt_impl_le,\n      exact h n,\n    },\n  }, {\n    exact hN n hn,\n  },\nend\n\ndef mul : real \u2192 real \u2192 real :=\nquotient.lift\u2082 (\u03bb f g, \u27e6f * g\u27e7)\nbegin\n  intros a x b y hab hxy,\n  dsimp only [],\n  rw [cau_seq.class_equiv, \u2190cau_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 := \u27e8mul\u27e9\n\ntheorem mul_eq_cls {a b : cau_seq} {x y : real} :\nx = \u27e6a\u27e7 \u2192 y = \u27e6b\u27e7 \u2192 x * y = \u27e6a * b\u27e7 :=\n\u03bb hax hby, by rw [hax, hby]; refl\n\nopen classical\n\nlocal attribute [instance] classical.prop_decidable\n\ndef inv: real \u2192 real :=\nquotient.lift (\u03bb f, \u27e6f\u207b\u00b9\u27e7)\nbegin\n  intros a b hab,\n  have ha := a.property,\n  have hb := b.property,\n  dsimp only [],\n  by_cases ha0: a \u2248 (0 : cau_seq), {\n    have: b \u2248 (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, \u2190cau_seq.setoid_equiv],\n    apply @setoid.trans cau_seq _ a\u207b\u00b9 0 b\u207b\u00b9,\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 : \u00acb \u2248 (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\u2081 hN\u2081,\n    cases hB with N\u2082 hN\u2082,\n    rw cau_seq.class_equiv,\n    rw cau_seq.setoid_equiv at hab,\n    dsimp only [cau_seq.equivalent] at hab \u22a2,\n    intros \u03b5 h\u03b5,\n    have h0AB\u03b5 : 0 < A * (B * \u03b5), {\n      rw \u2190zero_mul (0 : myrat),\n      apply @lt_mul_comb_nonneg _ _  (0 : myrat) _ 0 _ (by refl) (by refl) hN\u2081.left,\n      rw \u2190zero_mul (0 : myrat),\n      apply @lt_mul_comb_nonneg _ _ (0 : myrat) _ 0 _ (by refl) (by refl) hN\u2082.left h\u03b5,\n    },\n    cases hab (A * (B * \u03b5)) h0AB\u03b5 with N\u2083 hN\u2083,\n    existsi mynat.max (mynat.max N\u2081 N\u2082) N\u2083,\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\u2081.left,\n      apply hN\u2081.right n,\n      apply @mynat.max_le_cancel_left _ N\u2082 _,\n      apply @mynat.max_le_cancel_left _ N\u2083 _,\n      assumption,\n    },\n    have hbnpos : 0 < abs (b.val n), {\n      transitivity B,\n        from hN\u2082.left,\n      apply hN\u2082.right n,\n      apply @mynat.max_le_cancel_right N\u2081 _ _,\n      apply @mynat.max_le_cancel_left _ N\u2083 _,\n      assumption,\n    },\n    have hanzero : a.val n \u2260 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 \u2260 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, \u2190abs_mul, sub_def, mul_add,\n        mul_inv hanzero, lt_mul_pos_left _ hbnpos, \u2190abs_mul,\n        mul_add, mul_one, mul_neg, mul_neg, add_comm,\n        mul_comm (a.val n), \u2190mul_assoc, mul_inv hbnzero,\n        one_mul, \u2190abs_neg, neg_distr, neg_neg, \u2190sub_def],\n    apply lt_le_chain (A * (B * \u03b5)), {\n      apply hN\u2083 n,\n      apply mynat.max_le_cancel_right hn,\n    }, {\n      rw [\u2190mul_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\u2081.left,\n      }, {\n        rw \u2190zero_mul (0 : myrat),\n        apply @le_mul_comb_nonneg _ _ (0 : myrat) _ _ _ (by refl) (by refl),\n        from lt_impl_le hN\u2082.left,\n        from lt_impl_le h\u03b5,\n      }, {\n        apply lt_impl_le,\n        apply hN\u2081.right n,\n        apply @mynat.max_le_cancel_left _ N\u2082 _,\n        apply @mynat.max_le_cancel_left _ N\u2083 _,\n        assumption,\n      },\n      apply le_mul_comb_nonneg, {\n        from lt_impl_le hN\u2082.left,\n      }, {\n        from lt_impl_le h\u03b5,\n      }, {\n        apply lt_impl_le,\n        apply hN\u2082.right n,\n        apply @mynat.max_le_cancel_right N\u2081 _ _,\n        apply @mynat.max_le_cancel_left _ N\u2083 _,\n        assumption,\n      },\n      refl,\n    },\n  },\nend\n\ninstance: has_inv real := \u27e8inv\u27e9\n\ntheorem inv_eq_cls {a : cau_seq} {x : real} :\nx = \u27e6a\u27e7 \u2192 x\u207b\u00b9 = \u27e6a\u207b\u00b9\u27e7 :=\n\u03bb 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\u2081: x * y * z = \u27e6a * b * c\u27e7,\n    rw mul_eq_cls, rw mul_eq_cls,\n    repeat { symmetry, assumption, },\n  have h\u2082: x * (y * z) = \u27e6a * (b * c)\u27e7,\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\u2081 h\u2082,\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\u2081: x * (y + z) = \u27e6a * (b + c)\u27e7,\n    rw mul_eq_cls,\n    symmetry, assumption,\n    rw add_eq_cls,\n    symmetry, assumption,\n    symmetry, assumption,\n  have h\u2082: x * y + x * z = \u27e6a * b + a * c\u27e7,\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\u2081 h\u2082,\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\u207b\u00b9 = (0 : real) :=\nbegin\n  have h : (0 : real)\u207b\u00b9 = \u27e60\u207b\u00b9\u27e7,\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\u00acf \u2248 0 \u2192 \u2203 N : mynat, \u2200 n, N \u2264 n \u2192 f.val n \u2260 0 :=\nbegin\n  intros hnf0,\n  cases cau_seq.nzero_impl_abs_eventually_bounded_below f hnf0 with \u03b4 h,\n  cases h with N h,\n  cases h with h\u03b4 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 \u03b4; assumption,\nend\n\nprivate theorem mul_inv : x \u2260 0 \u2192 x * x\u207b\u00b9 = 1 :=\nbegin\n  intro hx0,\n  cases quotient.exists_rep x with f hf,\n  rw [inv_eq_cls hf.symm, \u2190hf, @mul_eq_cls f f\u207b\u00b9 \u27e6f\u27e7 _ (by refl) (by refl)],\n  rw [real_one, coe_def, cau_seq.class_equiv],\n  unfold cau_seq.equivalent,\n  intros \u03b5 h\u03b5,\n  have hnf0 : \u00acf \u2248 0,\n    assume hf0,\n    apply hx0,\n    rwa [\u2190hf, 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 := \u27e8\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\u27e9\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 : \u2200 (l : list \u2115), list.append l (0 :: list.nil) \u2260 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u03b1 \u03b2` is an extension of `local_equiv \u03b1 \u03b2`, 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 \u2229 s` or `e.target \u2229 t`, not `s \u2229 e.source` or `t \u2229 e.target`.\n-/\n\nopen function set filter topological_space (second_countable_topology)\nopen_locale topology\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*}\n[topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3] [topological_space \u03b4]\n\n/-- local homeomorphisms, defined on open subsets of the space -/\n@[nolint has_nonempty_instance]\nstructure local_homeomorph (\u03b1 : Type*) (\u03b2 : Type*) [topological_space \u03b1] [topological_space \u03b2]\n  extends local_equiv \u03b1 \u03b2 :=\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 \u03b1 \u03b2) (e' : local_homeomorph \u03b2 \u03b3)\n\ninstance : has_coe_to_fun (local_homeomorph \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := \u27e8\u03bb e, e.to_fun\u27e9\n\n/-- The inverse of a local homeomorphism -/\nprotected def symm : local_homeomorph \u03b2 \u03b1 :=\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 \u03b1 \u03b2) : \u03b1 \u2192 \u03b2 := e\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (e : local_homeomorph \u03b1 \u03b2) : \u03b2 \u2192 \u03b1 := e.symm\n\ninitialize_simps_projections local_homeomorph\n  (to_local_equiv_to_fun \u2192 apply, to_local_equiv_inv_fun \u2192 symm_apply,\n   to_local_equiv_source \u2192 source, to_local_equiv_target \u2192 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 \u03b1 \u03b2) (a b c d) :\n  (local_homeomorph.mk e a b c d : \u03b1 \u2192 \u03b2) = e := rfl\n\n@[simp, mfld_simps] lemma mk_coe_symm (e : local_equiv \u03b1 \u03b2) (a b c d) :\n  ((local_homeomorph.mk e a b c d).symm : \u03b2 \u2192 \u03b1) = e.symm := rfl\n\nlemma to_local_equiv_injective : injective (to_local_equiv : local_homeomorph \u03b1 \u03b2 \u2192 local_equiv \u03b1 \u03b2)\n| \u27e8e, h\u2081, h\u2082, h\u2083, h\u2084\u27e9 \u27e8e', h\u2081', h\u2082', h\u2083', h\u2084'\u27e9 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 \u03b1 \u03b2) : e.to_fun = e := rfl\n\n@[simp, mfld_simps] lemma inv_fun_eq_coe (e : local_homeomorph \u03b1 \u03b2) : e.inv_fun = e.symm := rfl\n\n@[simp, mfld_simps] lemma coe_coe : (e.to_local_equiv : \u03b1 \u2192 \u03b2) = e := rfl\n\n@[simp, mfld_simps] lemma coe_coe_symm : (e.to_local_equiv.symm : \u03b2 \u2192 \u03b1) = e.symm := rfl\n\n@[simp, mfld_simps] lemma map_source {x : \u03b1} (h : x \u2208 e.source) : e x \u2208 e.target :=\ne.map_source' h\n\n@[simp, mfld_simps] lemma map_target {x : \u03b2} (h : x \u2208 e.target) : e.symm x \u2208 e.source :=\ne.map_target' h\n\n@[simp, mfld_simps] lemma left_inv {x : \u03b1} (h : x \u2208 e.source) : e.symm (e x) = x :=\ne.left_inv' h\n\n@[simp, mfld_simps] lemma right_inv {x : \u03b2} (h : x \u2208 e.target) : e (e.symm x) = x :=\ne.right_inv' h\n\nlemma eq_symm_apply {x : \u03b1} {y : \u03b2} (hx : x \u2208 e.source) (hy : y \u2208 e.target) :\n  x = e.symm y \u2194 e x = y := e.to_local_equiv.eq_symm_apply hx hy\n\nprotected lemma maps_to : maps_to e e.source e.target := \u03bb 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 := \u03bb x, e.left_inv\nprotected lemma right_inv_on : right_inv_on e.symm e e.target := \u03bb x, e.right_inv\nprotected lemma inv_on : inv_on e.symm e e.source e.target := \u27e8e.left_inv_on, e.right_inv_on\u27e9\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 : \u03b1 \u2243\u209c \u03b2) :\n  local_homeomorph \u03b1 \u03b2 :=\n{ open_source        := is_open_univ,\n  open_target        := is_open_univ,\n  continuous_to_fun  := by { erw \u2190 continuous_iff_continuous_on_univ, exact e.continuous_to_fun },\n  continuous_inv_fun := by { erw \u2190 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 \u03b1 \u03b2) (e' : local_equiv \u03b1 \u03b2) (h : e.to_local_equiv = e') :\n  local_homeomorph \u03b1 \u03b2 :=\n{ to_local_equiv := e',\n  open_source := h \u25b8 e.open_source,\n  open_target := h \u25b8 e.open_target,\n  continuous_to_fun := h \u25b8 e.continuous_to_fun,\n  continuous_inv_fun := h \u25b8 e.continuous_inv_fun }\n\nlemma replace_equiv_eq_self (e : local_homeomorph \u03b1 \u03b2) (e' : local_equiv \u03b1 \u03b2)\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 \u2286 e \u207b\u00b9' e.target := e.maps_to\n\nlemma eq_of_local_equiv_eq {e e' : local_homeomorph \u03b1 \u03b2}\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 \u03b1 \u03b2) {x} (hx : x \u2208 e.source) :\n  \u2200\u1da0 y in \ud835\udcdd 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 \u03b1 \u03b2) {x} (hx : x \u2208 e.target) :\n  \u2200\u1da0 y in \ud835\udcdd (e.symm x), e.symm (e y) = y :=\ne.eventually_left_inverse (e.map_target hx)\n\nlemma eventually_right_inverse (e : local_homeomorph \u03b1 \u03b2) {x} (hx : x \u2208 e.target) :\n  \u2200\u1da0 y in \ud835\udcdd 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 \u03b1 \u03b2) {x} (hx : x \u2208 e.source) :\n  \u2200\u1da0 y in \ud835\udcdd (e x), e (e.symm y) = y :=\ne.eventually_right_inverse (e.map_source hx)\n\nlemma eventually_ne_nhds_within (e : local_homeomorph \u03b1 \u03b2) {x} (hx : x \u2208 e.source) :\n  \u2200\u1da0 x' in \ud835\udcdd[\u2260] x, e x' \u2260 e x :=\neventually_nhds_within_iff.2 $ (e.eventually_left_inverse hx).mono $\n  \u03bb x' hx', mt $ \u03bb h, by rw [mem_singleton_iff, \u2190 e.left_inv hx, \u2190 h, hx']\n\nlemma nhds_within_source_inter {x} (hx : x \u2208 e.source) (s : set \u03b1) :\n  \ud835\udcdd[e.source \u2229 s] x = \ud835\udcdd[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 \u2208 e.target) (s : set \u03b2) :\n  \ud835\udcdd[e.target \u2229 s] x = \ud835\udcdd[s] x :=\ne.symm.nhds_within_source_inter hx s\n\nlemma image_eq_target_inter_inv_preimage {s : set \u03b1} (h : s \u2286 e.source) :\n  e '' s = e.target \u2229 e.symm \u207b\u00b9' s :=\ne.to_local_equiv.image_eq_target_inter_inv_preimage h\n\nlemma image_source_inter_eq' (s : set \u03b1) :\n  e '' (e.source \u2229 s) = e.target \u2229 e.symm \u207b\u00b9' s :=\ne.to_local_equiv.image_source_inter_eq' s\n\nlemma image_source_inter_eq (s : set \u03b1) :\n  e '' (e.source \u2229 s) = e.target \u2229 e.symm \u207b\u00b9' (e.source \u2229 s) :=\ne.to_local_equiv.image_source_inter_eq s\n\nlemma symm_image_eq_source_inter_preimage {s : set \u03b2} (h : s \u2286 e.target) :\n  e.symm '' s = e.source \u2229 e \u207b\u00b9' s :=\ne.symm.image_eq_target_inter_inv_preimage h\n\nlemma symm_image_target_inter_eq (s : set \u03b2) :\n  e.symm '' (e.target \u2229 s) = e.source \u2229 e \u207b\u00b9' (e.target \u2229 s) :=\ne.symm.image_source_inter_eq _\n\nlemma source_inter_preimage_inv_preimage (s : set \u03b1) :\n  e.source \u2229 e \u207b\u00b9' (e.symm \u207b\u00b9' s) = e.source \u2229 s :=\ne.to_local_equiv.source_inter_preimage_inv_preimage s\n\nlemma target_inter_inv_preimage_preimage (s : set \u03b2) :\n  e.target \u2229 e.symm \u207b\u00b9' (e \u207b\u00b9' s) = e.target \u2229 s :=\ne.symm.source_inter_preimage_inv_preimage _\n\nlemma source_inter_preimage_target_inter (s : set \u03b2) :\n  e.source \u2229 (e \u207b\u00b9' (e.target \u2229 s)) = e.source \u2229 (e \u207b\u00b9' s) :=\ne.to_local_equiv.source_inter_preimage_target_inter s\n\nlemma image_source_eq_target (e : local_homeomorph \u03b1 \u03b2) : e '' e.source = e.target :=\ne.to_local_equiv.image_source_eq_target\n\nlemma symm_image_target_eq_source (e : local_homeomorph \u03b1 \u03b2) : 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 \u03b1 \u03b2) (h : \u2200x, e x = e' x)\n  (hinv : \u2200x, 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 \u03b1 \u03b2} : e = e' \u2194 (\u2200 x, e x = e' x) \u2227\n  (\u2200 x, e.symm x = e'.symm x) \u2227 e.source = e'.source :=\n\u27e8by { rintro rfl, exact \u27e8\u03bb x, rfl, \u03bb x, rfl, rfl\u27e9 }, \u03bb h, e.ext e' h.1 h.2.1 h.2.2\u27e9\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 : \u03b2} (h : x \u2208 e.target) : continuous_at e.symm x :=\ne.symm.continuous_at h\n\nlemma tendsto_symm {x} (hx : x \u2208 e.source) :\n  tendsto e.symm (\ud835\udcdd (e x)) (\ud835\udcdd 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 \u2208 e.source) : map e (\ud835\udcdd x) = \ud835\udcdd (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 \u2208 e.source) :\n  map e.symm (\ud835\udcdd (e x)) = \ud835\udcdd 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 \u2208 e.source) {s : set \u03b1} (hs : s \u2208 \ud835\udcdd x) :\n  e '' s \u2208 \ud835\udcdd (e x) :=\ne.map_nhds_eq hx \u25b8 filter.image_mem_map hs\n\nlemma map_nhds_within_eq (e : local_homeomorph \u03b1 \u03b2) {x} (hx : x \u2208 e.source) (s : set \u03b1) :\n  map e (\ud835\udcdd[s] x) = \ud835\udcdd[e '' (e.source \u2229 s)] (e x) :=\ncalc map e (\ud835\udcdd[s] x) = map e (\ud835\udcdd[e.source \u2229 s] x) :\n  congr_arg (map e) (e.nhds_within_source_inter hx _).symm\n... = \ud835\udcdd[e '' (e.source \u2229 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 \u03b1 \u03b2) {x} (hx : x \u2208 e.source) (s : set \u03b2) :\n  map e (\ud835\udcdd[e \u207b\u00b9' s] x) = \ud835\udcdd[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 \u03b1 \u03b2) {x : \u03b1} (p : \u03b2 \u2192 Prop)\n  (hx : x \u2208 e.source) : (\u2200\u1da0 y in \ud835\udcdd (e x), p y) \u2194 \u2200\u1da0 x in \ud835\udcdd x, p (e x) :=\niff.trans (by rw [e.map_nhds_eq hx]) eventually_map\n\nlemma eventually_nhds' (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (p : \u03b1 \u2192 Prop)\n  (hx : x \u2208 e.source) : (\u2200\u1da0 y in \ud835\udcdd (e x), p (e.symm y)) \u2194 \u2200\u1da0 x in \ud835\udcdd x, p x :=\nbegin\n  rw [e.eventually_nhds _ hx],\n  refine eventually_congr ((e.eventually_left_inverse hx).mono $ \u03bb y hy, _),\n  rw [hy]\nend\n\nlemma eventually_nhds_within (e : local_homeomorph \u03b1 \u03b2) {x : \u03b1} (p : \u03b2 \u2192 Prop) {s : set \u03b1}\n  (hx : x \u2208 e.source) : (\u2200\u1da0 y in \ud835\udcdd[e.symm \u207b\u00b9' s] (e x), p y) \u2194 \u2200\u1da0 x in \ud835\udcdd[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 \u03b1 \u03b2) {x : \u03b1} (p : \u03b1 \u2192 Prop) {s : set \u03b1}\n  (hx : x \u2208 e.source) : (\u2200\u1da0 y in \ud835\udcdd[e.symm \u207b\u00b9' s] (e x), p (e.symm y)) \u2194 \u2200\u1da0 x in \ud835\udcdd[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 $ \u03bb 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 \u207b\u00b9' 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 `\u03b3`).  -/\nlemma preimage_eventually_eq_target_inter_preimage_inter\n  {e : local_homeomorph \u03b1 \u03b2} {s : set \u03b1} {t : set \u03b3} {x : \u03b1}\n  {f : \u03b1 \u2192 \u03b3} (hf : continuous_within_at f s x) (hxe : x \u2208 e.source) (ht : t \u2208 \ud835\udcdd (f x)) :\n  e.symm \u207b\u00b9' s =\u1da0[\ud835\udcdd (e x)] (e.target \u2229 e.symm \u207b\u00b9' (s \u2229 f \u207b\u00b9' t) : set \u03b2) :=\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 \u03b2} (hs : is_open s) : is_open (e.source \u2229 e \u207b\u00b9' 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 \u03b2` is an image of `s : set \u03b1` under a local homeomorphism `e` if any of the\nfollowing equivalent conditions hold:\n\n* `e '' (e.source \u2229 s) = e.target \u2229 t`;\n* `e.source \u2229 e \u207b\u00b9 t = e.source \u2229 s`;\n* `\u2200 x \u2208 e.source, e x \u2208 t \u2194 x \u2208 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 \u03b2` is an image of `s : set \u03b1` under a local homeomorphism `e` if any of the\nfollowing equivalent conditions hold:\n\n* `e '' (e.source \u2229 s) = e.target \u2229 t`;\n* `e.source \u2229 e \u207b\u00b9 t = e.source \u2229 s`;\n* `\u2200 x \u2208 e.source, e x \u2208 t \u2194 x \u2208 s` (this one is used in the definition).\n-/\ndef is_image (s : set \u03b1) (t : set \u03b2) : Prop := \u2200 \u2983x\u2984, x \u2208 e.source \u2192 (e x \u2208 t \u2194 x \u2208 s)\n\nnamespace is_image\n\nvariables {e} {s : set \u03b1} {t : set \u03b2} {x : \u03b1} {y : \u03b2}\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 \u2208 e.source) : e x \u2208 t \u2194 x \u2208 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 \u2208 e.target) : (e.symm y \u2208 s \u2194 y \u2208 t) :=\nh.symm hy\n\n@[simp] lemma symm_iff : e.symm.is_image t s \u2194 e.is_image s t := \u27e8\u03bb h, h.symm, \u03bb h, h.symm\u27e9\n\nprotected lemma maps_to (h : e.is_image s t) : maps_to e (e.source \u2229 s) (e.target \u2229 t) :=\nh.to_local_equiv.maps_to\n\nlemma symm_maps_to (h : e.is_image s t) : maps_to e.symm (e.target \u2229 t) (e.source \u2229 s) :=\nh.symm.maps_to\n\nlemma image_eq (h : e.is_image s t) : e '' (e.source \u2229 s) = e.target \u2229 t :=\nh.to_local_equiv.image_eq\n\nlemma symm_image_eq (h : e.is_image s t) : e.symm '' (e.target \u2229 t) = e.source \u2229 s :=\nh.symm.image_eq\n\nlemma iff_preimage_eq : e.is_image s t \u2194 e.source \u2229 e \u207b\u00b9' t = e.source \u2229 s :=\nlocal_equiv.is_image.iff_preimage_eq\n\nalias iff_preimage_eq \u2194 preimage_eq of_preimage_eq\n\nlemma iff_symm_preimage_eq : e.is_image s t \u2194 e.target \u2229 e.symm \u207b\u00b9' s = e.target \u2229 t :=\nsymm_iff.symm.trans iff_preimage_eq\n\nalias iff_symm_preimage_eq \u2194 symm_preimage_eq of_symm_preimage_eq\n\nlemma iff_symm_preimage_eq' :\n  e.is_image s t \u2194 e.target \u2229 e.symm \u207b\u00b9' (e.source \u2229 s) = e.target \u2229 t :=\nby rw [iff_symm_preimage_eq, \u2190 image_source_inter_eq, \u2190 image_source_inter_eq']\n\nalias iff_symm_preimage_eq' \u2194 symm_preimage_eq' of_symm_preimage_eq'\n\nlemma iff_preimage_eq' : e.is_image s t \u2194 e.source \u2229 e \u207b\u00b9' (e.target \u2229 t) = e.source \u2229 s :=\nsymm_iff.symm.trans iff_symm_preimage_eq'\n\nalias iff_preimage_eq' \u2194 preimage_eq' of_preimage_eq'\n\nlemma of_image_eq (h : e '' (e.source \u2229 s) = e.target \u2229 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 \u2229 t) = e.source \u2229 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\u1d9c t\u1d9c :=\n\u03bb 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 \u2229 s') (t \u2229 t') :=\n\u03bb 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 \u222a s') (t \u222a t') :=\n\u03bb 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 \u03b1 \u03b2} [\u2200 i, decidable (i \u2208 s)]\n  [\u2200 i, decidable (i \u2208 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 \u03b1 \u03b2} (h : e.is_image s t)\n  (h' : e'.is_image s t) (hs : e.source \u2229 s = e'.source \u2229 s) (Heq : eq_on e e' (e.source \u2229 s)) :\n  e.target \u2229 t = e'.target \u2229 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 \u03b1 \u03b2} (h : e.is_image s t)\n  (hs : e.source \u2229 s = e'.source \u2229 s) (Heq : eq_on e e' (e.source \u2229 s)) :\n  eq_on e.symm e'.symm (e.target \u2229 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 \u2208 e.source) :\n  map e (\ud835\udcdd[s] x) = \ud835\udcdd[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\u03bb x hx, by simp only [mem_closure_iff_nhds_within_ne_bot, \u2190 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 \u2229 s) \u2194 is_open (e.target \u2229 t) :=\n\u27e8\u03bb hs, h.symm_preimage_eq' \u25b8 e.symm.preimage_open_of_open hs,\n  \u03bb hs, h.preimage_eq' \u25b8 e.preimage_open_of_open hs\u27e9\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 \u2229 s)) :\n  local_homeomorph \u03b1 \u03b2 :=\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 \u03b1 \u03b2)\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 \u03b2) :\n  e.source \u2229 e \u207b\u00b9' (interior s) = e.source \u2229 interior (e \u207b\u00b9' s) :=\n(is_image.of_preimage_eq rfl).interior.preimage_eq\n\nlemma preimage_closure (s : set \u03b2) :\n  e.source \u2229 e \u207b\u00b9' (closure s) = e.source \u2229 closure (e \u207b\u00b9' s) :=\n(is_image.of_preimage_eq rfl).closure.preimage_eq\n\nlemma preimage_frontier (s : set \u03b2) :\n  e.source \u2229 e \u207b\u00b9' (frontier s) = e.source \u2229 frontier (e \u207b\u00b9' s) :=\n(is_image.of_preimage_eq rfl).frontier.preimage_eq\n\nlemma preimage_open_of_open_symm {s : set \u03b1} (hs : is_open s) :\n  is_open (e.target \u2229 e.symm \u207b\u00b9' 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 \u03b1} (hs : is_open s) (h : s \u2286 e.source) : is_open (e '' s) :=\nbegin\n  have : e '' s = e.target \u2229 e.symm \u207b\u00b9' 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 \u03b1} (hs : is_open s) : is_open (e '' (e.source \u2229 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 \u03b1 \u03b2) (hc : continuous_on e e.source)\n  (ho : is_open_map (e.source.restrict e)) (hs : is_open e.source) :\n  local_homeomorph \u03b1 \u03b2 :=\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 \u25b8\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 \u03b1 \u03b2) (hc : continuous_on e e.source)\n  (ho : is_open_map e) (hs : is_open e.source) :\n  local_homeomorph \u03b1 \u03b2 :=\nof_continuous_open_restrict e hc (ho.restrict hs) hs\n\n/-- Restricting a local homeomorphism `e` to `e.source \u2229 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 \u03b1) (hs : is_open s) :\n  local_homeomorph \u03b1 \u03b2 :=\n(@is_image.of_symm_preimage_eq \u03b1 \u03b2 _ _ e s (e.symm \u207b\u00b9' s) rfl).restr\n  (is_open.inter e.open_source hs)\n\n@[simp, mfld_simps] lemma restr_open_to_local_equiv (s : set \u03b1) (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 \u03b1) (hs : is_open s) :\n  (e.restr_open s hs).source = e.source \u2229 s := rfl\n\n/-- Restricting a local homeomorphism `e` to `e.source \u2229 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 \u03b1) : local_homeomorph \u03b1 \u03b2 :=\ne.restr_open (interior s) is_open_interior\n\n@[simp, mfld_simps] lemma restr_to_local_equiv (s : set \u03b1) :\n  (e.restr s).to_local_equiv = (e.to_local_equiv).restr (interior s) := rfl\n\nlemma restr_source' (s : set \u03b1) (hs : is_open s) : (e.restr s).source = e.source \u2229 s :=\nby rw [e.restr_source, hs.interior_eq]\n\nlemma restr_to_local_equiv' (s : set \u03b1) (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 \u03b1 \u03b2} {s : set \u03b1} (h : e.source \u2286 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 \u03b1 \u03b2} : e.restr univ = e :=\nrestr_eq_of_source_subset (subset_univ _)\n\nlemma restr_source_inter (s : set \u03b1) : e.restr (e.source \u2229 s) = e.restr s :=\nbegin\n  refine local_homeomorph.ext _ _ (\u03bbx, rfl) (\u03bbx, rfl) _,\n  simp [e.open_source.interior_eq, \u2190 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 (\u03b1 : Type*) [topological_space \u03b1] : local_homeomorph \u03b1 \u03b1 :=\n(homeomorph.refl \u03b1).to_local_homeomorph\n\n@[simp, mfld_simps] lemma refl_local_equiv :\n  (local_homeomorph.refl \u03b1).to_local_equiv = local_equiv.refl \u03b1 := rfl\n@[simp, mfld_simps] lemma refl_symm : (local_homeomorph.refl \u03b1).symm = local_homeomorph.refl \u03b1 :=\nrfl\n\nsection\nvariables {s : set \u03b1} (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 \u03b1) (hs : is_open s) : local_homeomorph \u03b1 \u03b1 :=\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 \u03b1 :=\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 \u03b1 \u03b3 :=\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 \u2190 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 \u03b1 \u03b3 :=\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' : \u03b1 \u2192 \u03b3) = e' \u2218 e := rfl\n@[simp, mfld_simps] lemma coe_trans_symm : ((e.trans e').symm : \u03b3 \u2192 \u03b1) = e.symm \u2218 e'.symm := rfl\nlemma trans_apply {x : \u03b1} : (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 \u2229 e \u207b\u00b9' e'.source :=\nlocal_equiv.trans_source e.to_local_equiv e'.to_local_equiv\n\nlemma trans_source' : (e.trans e').source = e.source \u2229 e \u207b\u00b9' (e.target \u2229 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 \u2229 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 \u2229 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 \u2229 e'.symm \u207b\u00b9' e.target := rfl\n\nlemma trans_target' : (e.trans e').target = e'.target \u2229 e'.symm \u207b\u00b9' (e'.source \u2229 e.target) :=\ntrans_source' e'.symm e.symm\n\nlemma trans_target'' : (e.trans e').target = e' '' (e'.source \u2229 e.target) :=\ntrans_source'' e'.symm e.symm\n\nlemma inv_image_trans_target : e'.symm '' (e.trans e').target = e'.source \u2229 e.target :=\nimage_trans_source e'.symm e.symm\n\nlemma trans_assoc (e'' : local_homeomorph \u03b3 \u03b4) :\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 \u03b2) = 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 \u03b1).trans e = e :=\neq_of_local_equiv_eq $ local_equiv.refl_trans e.to_local_equiv\n\nlemma trans_of_set {s : set \u03b2} (hs : is_open s) :\n  e.trans (of_set s hs) = e.restr (e \u207b\u00b9' s) :=\nlocal_homeomorph.ext _ _ (\u03bbx, rfl) (\u03bbx, rfl) $\n  by simp [local_equiv.trans_source, (e.preimage_interior _).symm, hs.interior_eq]\n\nlemma trans_of_set' {s : set \u03b2} (hs : is_open s) :\n  e.trans (of_set s hs) = e.restr (e.source \u2229 e \u207b\u00b9' s) :=\nby rw [trans_of_set, restr_source_inter]\n\nlemma of_set_trans {s : set \u03b1} (hs : is_open s) :\n  (of_set s hs).trans e = e.restr s :=\nlocal_homeomorph.ext _ _ (\u03bbx, rfl) (\u03bbx, rfl) $\n  by simp [local_equiv.trans_source, hs.interior_eq, inter_comm]\n\nlemma of_set_trans' {s : set \u03b1} (hs : is_open s) :\n  (of_set s hs).trans e = e.restr (e.source \u2229 s) :=\nby rw [of_set_trans, restr_source_inter]\n\n@[simp, mfld_simps] lemma of_set_trans_of_set\n  {s : set \u03b1} (hs : is_open s) {s' : set \u03b1} (hs' : is_open s') :\n  (of_set s hs).trans (of_set s' hs') = of_set (s \u2229 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 \u03b1) :\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' : \u03b2 \u2243\u209c \u03b3) : local_homeomorph \u03b1 \u03b3 :=\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 (\u03bb x h, h) }\n\nlemma trans_equiv_eq_trans (e' : \u03b2 \u2243\u209c \u03b3) : 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 : \u03b1 \u2243\u209c \u03b2) : local_homeomorph \u03b1 \u03b3 :=\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 (\u03bb 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 : \u03b1 \u2243\u209c \u03b2) :\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 \u03b1 \u03b2) : Prop :=\ne.source = e'.source \u2227 (eq_on e e' e.source)\n\nlemma eq_on_source_iff (e e' : local_homeomorph \u03b1 \u03b2) :\neq_on_source e e' \u2194 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 \u03b1 \u03b2) :=\n{ r     := eq_on_source,\n  iseqv := \u27e8\n    \u03bbe, (@local_equiv.eq_on_source_setoid \u03b1 \u03b2).iseqv.1 e.to_local_equiv,\n    \u03bbe e' h, (@local_equiv.eq_on_source_setoid \u03b1 \u03b2).iseqv.2.1 ((eq_on_source_iff e e').1 h),\n    \u03bbe e' e'' h h', (@local_equiv.eq_on_source_setoid \u03b1 \u03b2).iseqv.2.2\n      ((eq_on_source_iff e e').1 h) ((eq_on_source_iff e' e'').1 h')\u27e9 }\n\nlemma eq_on_source_refl : e \u2248 e := setoid.refl _\n\n/-- If two local homeomorphisms are equivalent, so are their inverses -/\nlemma eq_on_source.symm' {e e' : local_homeomorph \u03b1 \u03b2} (h : e \u2248 e') : e.symm \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2} {f f' : local_homeomorph \u03b2 \u03b3}\n  (he : e \u2248 e') (hf : f \u2248 f') : e.trans f \u2248 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 \u03b1 \u03b2} (he : e \u2248 e') (s : set \u03b1) :\n  e.restr s \u2248 e'.restr s :=\nlocal_equiv.eq_on_source.restr he _\n\nlemma set.eq_on.restr_eq_on_source {e e' : local_homeomorph \u03b1 \u03b2}\n  (h : eq_on e e' (e.source \u2229 e'.source)) :\n  e.restr e'.source \u2248 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 \u2248 local_homeomorph.of_set e.source e.open_source :=\nlocal_equiv.trans_self_symm _\n\nlemma trans_symm_self :\n  e.symm.trans e \u2248 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 \u03b1 \u03b2} (h : e \u2248 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 \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) :\n  local_homeomorph (\u03b1 \u00d7 \u03b3) (\u03b2 \u00d7 \u03b4) :=\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 \u03b1 \u03b2) (e' : local_homeomorph \u03b3 \u03b4) :\n  (e.prod e').symm = (e.symm.prod e'.symm) :=\nrfl\n\n@[simp]\nlemma refl_prod_refl {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2] :\n  (local_homeomorph.refl \u03b1).prod (local_homeomorph.refl \u03b2) = local_homeomorph.refl (\u03b1 \u00d7 \u03b2) :=\nby { ext1 \u27e8x, y\u27e9, { refl }, { rintro \u27e8x, y\u27e9, refl }, exact univ_prod_univ }\n\n@[simp, mfld_simps] lemma prod_trans\n  {\u03b7 : Type*} {\u03b5 : Type*} [topological_space \u03b7] [topological_space \u03b5]\n  (e : local_homeomorph \u03b1 \u03b2) (f : local_homeomorph \u03b2 \u03b3)\n  (e' : local_homeomorph \u03b4 \u03b7) (f' : local_homeomorph \u03b7 \u03b5) :\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\u2081 e\u2081' : local_homeomorph \u03b1 \u03b2} {e\u2082 e\u2082' : local_homeomorph \u03b3 \u03b4}\n  (h : (e\u2081.prod e\u2082).source.nonempty) :\n  e\u2081.prod e\u2082 = e\u2081'.prod e\u2082' \u2194 e\u2081 = e\u2081' \u2227 e\u2082 = e\u2082' :=\nbegin\n  obtain \u27e8\u27e8x, y\u27e9, -\u27e9 := id h,\n  haveI : nonempty \u03b1 := \u27e8x\u27e9,\n  haveI : nonempty \u03b2  := \u27e8e\u2081 x\u27e9,\n  haveI : nonempty \u03b3 := \u27e8y\u27e9,\n  haveI : nonempty \u03b4 := \u27e8e\u2082 y\u27e9,\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\u2081 e\u2081' : local_homeomorph \u03b1 \u03b2} {e\u2082 e\u2082' : local_homeomorph \u03b3 \u03b4}\n  (h : (e\u2081'.prod e\u2082').source.nonempty) :\n  e\u2081.prod e\u2082 = e\u2081'.prod e\u2082' \u2194 e\u2081 = e\u2081' \u2227 e\u2082 = e\u2082' :=\nby rw [eq_comm, prod_eq_prod_of_nonempty h, eq_comm, @eq_comm _ e\u2082']\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 \u2229 s \u222a e'.source \\ s`, and similarly for target.  The\nfunction sends `e.source \u2229 s` to `e.target \u2229 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 \u03b1 \u03b2) (s : set \u03b1) (t : set \u03b2)\n  [\u2200 x, decidable (x \u2208 s)] [\u2200 y, decidable (y \u2208 t)] (H : e.is_image s t) (H' : e'.is_image s t)\n  (Hs : e.source \u2229 frontier s = e'.source \u2229 frontier s)\n  (Heq : eq_on e e' (e.source \u2229 frontier s)) :\n  local_homeomorph \u03b1 \u03b2 :=\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 \u03b1 \u03b2) {s : set \u03b1} {t : set \u03b2}\n  [\u2200 x, decidable (x \u2208 s)] [\u2200 y, decidable (y \u2208 t)] (H : e.is_image s t) (H' : e'.is_image s t)\n  (Hs : e.source \u2229 frontier s = e'.source \u2229 frontier s)\n  (Heq : eq_on e e' (e.source \u2229 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 \u03b1 \u03b2)\n  [\u2200 x, decidable (x \u2208 e.source)] [\u2200 y, decidable (y \u2208 e.target)]\n  (Hs : disjoint e.source e'.source) (Ht : disjoint e.target e'.target) :\n  local_homeomorph \u03b1 \u03b2 :=\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 {\u03b9 : Type*} [fintype \u03b9] {Xi Yi : \u03b9 \u2192 Type*} [\u03a0 i, topological_space (Xi i)]\n  [\u03a0 i, topological_space (Yi i)] (ei : \u03a0 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 (\u03a0 i, Xi i) (\u03a0 i, Yi i) :=\n{ to_local_equiv := local_equiv.pi (\u03bb i, (ei i).to_local_equiv),\n  open_source := is_open_set_pi finite_univ $ \u03bb i hi, (ei i).open_source,\n  open_target := is_open_set_pi finite_univ $ \u03bb i hi, (ei i).open_target,\n  continuous_to_fun := continuous_on_pi.2 $ \u03bb i, (ei i).continuous_on.comp\n    (continuous_apply _).continuous_on (\u03bb f hf, hf i trivial),\n  continuous_inv_fun := continuous_on_pi.2 $ \u03bb i, (ei i).continuous_on_symm.comp\n    (continuous_apply _).continuous_on (\u03bb 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 : \u03b2 \u2192 \u03b3} {s : set \u03b2} {x : \u03b2} (h : x \u2208 e.target) :\n  continuous_within_at f s x \u2194 continuous_within_at (f \u2218 e) (e \u207b\u00b9' s) (e.symm x) :=\nby simp_rw [continuous_within_at, \u2190 @tendsto_map'_iff _ _ _ _ e,\n  e.map_nhds_within_preimage_eq (e.map_target h), (\u2218), 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 : \u03b2 \u2192 \u03b3} {x : \u03b2} (h : x \u2208 e.target) :\n  continuous_at f x \u2194 continuous_at (f \u2218 e) (e.symm x) :=\nby rw [\u2190 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 : \u03b2 \u2192 \u03b3} {s : set \u03b2} (h : s \u2286 e.target) :\n  continuous_on f s \u2194 continuous_on (f \u2218 e) (e.source \u2229 e \u207b\u00b9' s) :=\nbegin\n  simp only [\u2190 e.symm_image_eq_source_inter_preimage h, continuous_on, ball_image_iff],\n  refine forall\u2082_congr (\u03bb 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 : \u03b3 \u2192 \u03b1} {s : set \u03b3} {x : \u03b3} (hx : f x \u2208 e.source) (h : f \u207b\u00b9' e.source \u2208 \ud835\udcdd[s] x) :\n  continuous_within_at f s x \u2194 continuous_within_at (e \u2218 f) s x :=\nbegin\n  refine \u27e8(e.continuous_at hx).comp_continuous_within_at, \u03bb fe_cont, _\u27e9,\n  rw [\u2190 continuous_within_at_inter' h] at fe_cont \u22a2,\n  have : continuous_within_at (e.symm \u2218 (e \u2218 f)) (s \u2229 f \u207b\u00b9' 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 (\u03bby 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 : \u03b3 \u2192 \u03b1} {x : \u03b3} (h : f \u207b\u00b9' e.source \u2208 \ud835\udcdd x) :\n  continuous_at f x \u2194 continuous_at (e \u2218 f) x :=\nbegin\n  have hx : f x \u2208 e.source := (mem_of_mem_nhds h : _),\n  have h' : f \u207b\u00b9' e.source \u2208 \ud835\udcdd[univ] x, by rwa nhds_within_univ,\n  rw [\u2190 continuous_within_at_univ, \u2190 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 : \u03b3 \u2192 \u03b1} {s : set \u03b3} (h : s \u2286 f \u207b\u00b9' e.source) :\n  continuous_on f s \u2194 continuous_on (e \u2218 f) s :=\nforall\u2082_congr $ \u03bb 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 : \u03b3 \u2192 \u03b1} (h : f \u207b\u00b9' e.source = univ) :\n  continuous f \u2194 continuous (e \u2218 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 \u03b1} {t : set \u03b2} (hs : s \u2286 e.source) (ht : e '' s = t) : s \u2243\u209c t :=\n{ to_fun := \u03bb a, \u27e8e a, (congr_arg ((\u2208) (e a)) ht).mp \u27e8a, a.2, rfl\u27e9\u27e9,\n  inv_fun := \u03bb b, \u27e8e.symm b, let \u27e8a, ha1, ha2\u27e9 := (congr_arg ((\u2208) \u2191b) ht).mpr b.2 in\n    ha2 \u25b8 (e.left_inv (hs ha1)).symm \u25b8 ha1\u27e9,\n  left_inv := \u03bb a, subtype.ext (e.left_inv (hs a.2)),\n  right_inv := \u03bb b, let \u27e8a, ha1, ha2\u27e9 := (congr_arg ((\u2208) \u2191b) ht).mpr b.2 in\n    subtype.ext (e.right_inv (ha2 \u25b8 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 (\u03bb b hb, let \u27e8a, ha1, ha2\u27e9 := show b \u2208 e '' s, from ht.symm \u25b8 hb in\n      ha2 \u25b8 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 \u2243\u209c e.target :=\ne.homeomorph_of_image_subset_source subset_rfl e.image_source_eq_target\n\nlemma second_countable_topology_source [second_countable_topology \u03b2]\n  (e : local_homeomorph \u03b1 \u03b2) :\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 \u03b1))\n  (h' : e.target = univ) : \u03b1 \u2243\u209c \u03b2 :=\n{ to_fun := e,\n  inv_fun := e.symm,\n  left_inv := \u03bbx, e.left_inv $ by { rw h, exact mem_univ _ },\n  right_inv := \u03bbx, 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 `\u03b1` defines an open embedding of `\u03b1` into `\u03b2`.  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 \u2190 h,\n    exact e.continuous_to_fun },\n  { apply set.injective_iff_inj_on_univ.mpr,\n    rw \u2190 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 : \u03b1 \u2243\u209c \u03b2) (e' : \u03b2 \u2243\u209c \u03b3)\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 \u03b1).to_local_homeomorph = local_homeomorph.refl \u03b1 := 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 : \u03b1 \u2192 \u03b2) (h : open_embedding f)\n\n/-- An open embedding of `\u03b1` into `\u03b2`, with `\u03b1` nonempty, defines a local homeomorphism whose source\nis all of `\u03b1`.  The converse is also true; see `local_homeomorph.to_open_embedding`. -/\n@[simps apply source target (mfld_cfg)]\nnoncomputable def to_local_homeomorph [nonempty \u03b1] : local_homeomorph \u03b1 \u03b2 :=\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 : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} (hf : open_embedding f) {x : \u03b1} :\n  continuous_at (g \u2218 f) x \u2194 continuous_at g (f x) :=\nbegin\n  haveI : nonempty \u03b1 := \u27e8x\u27e9,\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 \u03b1) [nonempty s]\n\n/-- The inclusion of an open subset `s` of a space `\u03b1` into `\u03b1` is a local homeomorphism from the\nsubtype `s` to `\u03b1`. -/\nnoncomputable def local_homeomorph_subtype_coe : local_homeomorph s \u03b1 :=\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 \u2192 \u03b1) = 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 \u03b1 \u03b2)\nvariables (s : opens \u03b1) [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 \u03b2 := 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 \u03b2) : s \u2192 \u03b2)\n  = set.restrict \u2191s (e : \u03b1 \u2192 \u03b2) := rfl\n\n@[simp, mfld_simps] lemma subtype_restr_source : (e.subtype_restr s).source = coe \u207b\u00b9' 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 \u03b1 \u03b2) :\n  (f.subtype_restr s).symm.trans (f'.subtype_restr s)\n  \u2248 (f.symm.trans f').restr (f.target \u2229 (f.symm) \u207b\u00b9' s) :=\nbegin\n  simp only [subtype_restr_def, trans_symm_eq_symm_trans_symm],\n  have openness\u2081 : is_open (f.target \u2229 f.symm \u207b\u00b9' s) := f.preimage_open_of_open_symm s.2,\n  rw [\u2190 of_set_trans _ openness\u2081, \u2190 trans_assoc, \u2190 trans_assoc],\n  refine eq_on_source.trans' _ (eq_on_source_refl _),\n  -- f' has been eliminated !!!\n  have sets_identity : f.symm.source \u2229 (f.target \u2229 (f.symm) \u207b\u00b9' s) = f.symm.source \u2229 f.symm \u207b\u00b9' s,\n  { mfld_set_tac },\n  have openness\u2082 : is_open (s : set \u03b1) := s.2,\n  rw [of_set_trans', sets_identity, \u2190 trans_of_set' _ openness\u2082, 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 \u00d7 Nat :=\n(x, x)\n\ntheorem ex1 : p.1 = 0 :=\nrfl\n\ntheorem ex2 : (p (x := 1) |>.2) = 1 :=\nrfl\n\ndef c {\u03b1 : Type} [Inhabited \u03b1] : \u03b1 \u00d7 \u03b1 :=\n(arbitrary, arbitrary)\n\ntheorem ex3 {\u03b1} [Inhabited \u03b1] : c.1 = arbitrary (\u03b1 := \u03b1) :=\nrfl\n\ntheorem ex4 {\u03b1} [Inhabited \u03b1] : c.2 = arbitrary (\u03b1 := \u03b1) :=\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\u00f6lzl\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 {\u03b1 : Type u} {\u03b2 : Type v}\n\nopen Function\n\nnamespace WithTop\n\nsection One\n\nvariable [One \u03b1]\n\n@[to_additive]\ninstance : One (WithTop \u03b1) :=\n  \u27e8(1 : \u03b1)\u27e9\n\n#print WithTop.coe_one /-\n@[simp, norm_cast, to_additive]\ntheorem coe_one : ((1 : \u03b1) : WithTop \u03b1) = 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 : \u03b1} : (a : WithTop \u03b1) = 1 \u2194 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 \u03b1).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 : \u03b1) : (1 : WithTop \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 1 (One.one.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a)) (LE.le.{u1} \u03b1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (One.toOfNat1.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1))) (WithTop.some.{u1} \u03b1 a)) (LE.le.{u1} \u03b1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align with_top.one_le_coe WithTop.one_le_coe\u2093'. -/\n@[simp, norm_cast, to_additive coe_nonneg]\ntheorem one_le_coe [LE \u03b1] {a : \u03b1} : 1 \u2264 (a : WithTop \u03b1) \u2194 1 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 1 (One.one.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1))))) (LE.le.{u1} \u03b1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_2) (WithTop.some.{u1} \u03b1 a) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (One.toOfNat1.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1)))) (LE.le.{u1} \u03b1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_le_one WithTop.coe_le_one\u2093'. -/\n@[simp, norm_cast, to_additive coe_le_zero]\ntheorem coe_le_one [LE \u03b1] {a : \u03b1} : (a : WithTop \u03b1) \u2264 1 \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 1 (One.one.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a)) (LT.lt.{u1} \u03b1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (One.toOfNat1.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1))) (WithTop.some.{u1} \u03b1 a)) (LT.lt.{u1} \u03b1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align with_top.one_lt_coe WithTop.one_lt_coe\u2093'. -/\n@[simp, norm_cast, to_additive coe_pos]\ntheorem one_lt_coe [LT \u03b1] {a : \u03b1} : 1 < (a : WithTop \u03b1) \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 1 (One.one.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1))))) (LT.lt.{u1} \u03b1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) (WithTop.some.{u1} \u03b1 a) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (One.toOfNat1.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1)))) (LT.lt.{u1} \u03b1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align with_top.coe_lt_one WithTop.coe_lt_one\u2093'. -/\n@[simp, norm_cast, to_additive coe_lt_zero]\ntheorem coe_lt_one [LT \u03b1] {a : \u03b1} : (a : WithTop \u03b1) < 1 \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2), Eq.{succ u2} (WithTop.{u2} \u03b2) (WithTop.map.{u1, u2} \u03b1 \u03b2 f (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 1 (One.one.{u1} (WithTop.{u1} \u03b1) (WithTop.one.{u1} \u03b1 _inst_1))))) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) \u03b2 (WithTop.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} \u03b2 (WithTop.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} \u03b2 (WithTop.{u2} \u03b2) (WithTop.hasCoeT.{u2} \u03b2))) (f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : One.{u2} \u03b1] {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2), Eq.{succ u1} (WithTop.{u1} \u03b2) (WithTop.map.{u2, u1} \u03b1 \u03b2 f (OfNat.ofNat.{u2} (WithTop.{u2} \u03b1) 1 (One.toOfNat1.{u2} (WithTop.{u2} \u03b1) (WithTop.one.{u2} \u03b1 _inst_1)))) (WithTop.some.{u1} \u03b2 (f (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align with_top.map_one WithTop.map_one\u2093'. -/\n@[simp, to_additive]\nprotected theorem map_one {\u03b2} (f : \u03b1 \u2192 \u03b2) : (1 : WithTop \u03b1).map f = (f 1 : WithTop \u03b2) :=\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 : \u03b1} : 1 = (a : WithTop \u03b1) \u2194 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 : \u22a4 \u2260 (1 : WithTop \u03b1) :=\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 \u03b1) \u2260 \u22a4 :=\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 \u03b1] [LE \u03b1] [ZeroLEOneClass \u03b1] : ZeroLEOneClass (WithTop \u03b1) :=\n  \u27e8some_le_some.2 zero_le_one\u27e9\n\nend One\n\nsection Add\n\nvariable [Add \u03b1] {a b c d : WithTop \u03b1} {x y : \u03b1}\n\ninstance : Add (WithTop \u03b1) :=\n  \u27e8Option.map\u2082 (\u00b7 + \u00b7)\u27e9\n\n#print WithTop.coe_add /-\n@[norm_cast]\ntheorem coe_add : ((x + y : \u03b1) : WithTop \u03b1) = 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 : \u03b1) : WithTop \u03b1) = 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 \u03b1] {a : \u03b1} : ((bit1 a : \u03b1) : WithTop \u03b1) = 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 \u03b1) : \u22a4 + a = \u22a4 :=\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 \u03b1) : a + \u22a4 = \u22a4 := 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 = \u22a4 \u2194 a = \u22a4 \u2228 b = \u22a4 := by\n  cases a <;> cases b <;> simp [none_eq_top, some_eq_coe, \u2190 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 \u2260 \u22a4 \u2194 a \u2260 \u22a4 \u2227 b \u2260 \u22a4 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (And (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) b (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1}, Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) (And (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) b (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))))\nCase conversion may be inaccurate. Consider using '#align with_top.add_lt_top WithTop.add_lt_top\u2093'. -/\ntheorem add_lt_top [LT \u03b1] {a b : WithTop \u03b1} : a + b < \u22a4 \u2194 a < \u22a4 \u2227 b < \u22a4 := 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    \u2200 {a b : WithTop \u03b1} {c : \u03b1}, a + b = c \u2194 \u2203 a' b' : \u03b1, \u2191a' = a \u2227 \u2191b' = b \u2227 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, \u2190 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 \u03b1} {y : \u03b1} : x + y = \u22a4 \u2194 x = \u22a4 := by\n  induction x using WithTop.recTopCoe <;> simp [\u2190 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 \u03b1} : \u2191x + y = \u22a4 \u2194 y = \u22a4 := by\n  induction y using WithTop.recTopCoe <;> simp [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1)) (LE.le.{u1} \u03b1 _inst_2)], CovariantClass.{u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1))) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1184 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1186 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1201 : \u03b1) => LE.le.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1199 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1201)], CovariantClass.{u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1223 : WithTop.{u1} \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1225 : WithTop.{u1} \u03b1) => HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _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} \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1240 : WithTop.{u1} \u03b1) => LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _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\u2093'. -/\ninstance covariantClass_add_le [LE \u03b1] [CovariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] :\n    CovariantClass (WithTop \u03b1) (WithTop \u03b1) (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7) :=\n  \u27e8fun a b c h => by\n    cases a <;> cases c <;> try exact le_top\n    rcases le_coe_iff.1 h with \u27e8b, rfl, h'\u27e9\n    exact coe_le_coe.2 (add_le_add_left (coe_le_coe.1 h) _)\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1))) (LE.le.{u1} \u03b1 _inst_2)], CovariantClass.{u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (Function.swap.{succ u1, succ u1, succ u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (fun (\u1fb0 : WithTop.{u1} \u03b1) (\u1fb0 : WithTop.{u1} \u03b1) => WithTop.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)))) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1379 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1381 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1396 : \u03b1) => LE.le.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1394 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1396)], CovariantClass.{u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (Function.swap.{succ u1, succ u1, succ u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (fun (\u1fb0 : WithTop.{u1} \u03b1) (\u1fb0 : WithTop.{u1} \u03b1) => WithTop.{u1} \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1421 : WithTop.{u1} \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1423 : WithTop.{u1} \u03b1) => HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _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} \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1438 : WithTop.{u1} \u03b1) => LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _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\u2093'. -/\ninstance covariantClass_swap_add_le [LE \u03b1] [CovariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)] :\n    CovariantClass (WithTop \u03b1) (WithTop \u03b1) (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7) :=\n  \u27e8fun a b c h => by\n    cases a <;> cases c <;> try exact le_top\n    rcases le_coe_iff.1 h with \u27e8b, rfl, h'\u27e9\n    exact coe_le_coe.2 (add_le_add_right (coe_le_coe.1 h) _)\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] [_inst_3 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1)) (LT.lt.{u1} \u03b1 _inst_2)], ContravariantClass.{u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1))) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] [_inst_3 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1574 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1576 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1591 : \u03b1) => LT.lt.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1589 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1591)], ContravariantClass.{u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1613 : WithTop.{u1} \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1615 : WithTop.{u1} \u03b1) => HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _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} \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1630 : WithTop.{u1} \u03b1) => LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _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\u2093'. -/\ninstance contravariantClass_add_lt [LT \u03b1] [ContravariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)] :\n    ContravariantClass (WithTop \u03b1) (WithTop \u03b1) (\u00b7 + \u00b7) (\u00b7 < \u00b7) :=\n  \u27e8fun a b c h => by\n    induction a using WithTop.recTopCoe; \u00b7 exact (not_none_lt _ h).elim\n    induction b using WithTop.recTopCoe; \u00b7 exact (not_none_lt _ h).elim\n    induction c using WithTop.recTopCoe\n    \u00b7 exact coe_lt_top _\n    \u00b7 exact coe_lt_coe.2 (lt_of_add_lt_add_left <| coe_lt_coe.1 h)\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] [_inst_3 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1))) (LT.lt.{u1} \u03b1 _inst_2)], ContravariantClass.{u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (Function.swap.{succ u1, succ u1, succ u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (fun (\u1fb0 : WithTop.{u1} \u03b1) (\u1fb0 : WithTop.{u1} \u03b1) => WithTop.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)))) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] [_inst_3 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1724 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1726 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1741 : \u03b1) => LT.lt.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1739 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1741)], ContravariantClass.{u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (Function.swap.{succ u1, succ u1, succ u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (fun (\u1fb0 : WithTop.{u1} \u03b1) (\u1fb0 : WithTop.{u1} \u03b1) => WithTop.{u1} \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1766 : WithTop.{u1} \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1768 : WithTop.{u1} \u03b1) => HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _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} \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1783 : WithTop.{u1} \u03b1) => LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _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\u2093'. -/\ninstance contravariantClass_swap_add_lt [LT \u03b1] [ContravariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)] :\n    ContravariantClass (WithTop \u03b1) (WithTop \u03b1) (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7) :=\n  \u27e8fun a b c h => by\n    cases a <;> cases b <;> try exact (not_none_lt _ h).elim\n    cases c\n    \u00b7 exact coe_lt_top _\n    \u00b7 exact coe_lt_coe.2 (lt_of_add_lt_add_right <| coe_lt_coe.1 h)\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LE.{u1} \u03b1] [_inst_3 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1)) (LE.le.{u1} \u03b1 _inst_2)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a c)) -> (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) b c)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LE.{u1} \u03b1] [_inst_3 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1944 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1946 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1961 : \u03b1) => LE.le.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1959 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.1961)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a c)) -> (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _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\u2093'. -/\nprotected theorem le_of_add_le_add_left [LE \u03b1] [ContravariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] (ha : a \u2260 \u22a4)\n    (h : a + b \u2264 a + c) : b \u2264 c := by\n  lift a to \u03b1 using ha\n  induction c using WithTop.recTopCoe; \u00b7 exact le_top\n  induction b using WithTop.recTopCoe; \u00b7 exact (not_top_le_coe _ h).elim\n  simp only [\u2190 coe_add, coe_le_coe] at h\u22a2\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LE.{u1} \u03b1] [_inst_3 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1))) (LE.le.{u1} \u03b1 _inst_2)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) c a)) -> (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) b c)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LE.{u1} \u03b1] [_inst_3 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2071 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2073 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2088 : \u03b1) => LE.le.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2086 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2088)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) c a)) -> (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _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\u2093'. -/\nprotected theorem le_of_add_le_add_right [LE \u03b1] [ContravariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)]\n    (ha : a \u2260 \u22a4) (h : b + a \u2264 c + a) : b \u2264 c :=\n  by\n  lift a to \u03b1 using ha\n  cases c\n  \u00b7 exact le_top\n  cases b\n  \u00b7 exact (not_top_le_coe _ h).elim\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LT.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1)) (LT.lt.{u1} \u03b1 _inst_2)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) b c) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LT.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2206 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2208 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2223 : \u03b1) => LT.lt.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2221 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2223)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) b c) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a c))\nCase conversion may be inaccurate. Consider using '#align with_top.add_lt_add_left WithTop.add_lt_add_left\u2093'. -/\nprotected theorem add_lt_add_left [LT \u03b1] [CovariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)] (ha : a \u2260 \u22a4)\n    (h : b < c) : a + b < a + c := by\n  lift a to \u03b1 using ha\n  rcases lt_iff_exists_coe.1 h with \u27e8b, rfl, h'\u27e9\n  cases c\n  \u00b7 exact coe_lt_top _\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LT.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1))) (LT.lt.{u1} \u03b1 _inst_2)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) b c) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) c a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LT.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2335 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2337 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2352 : \u03b1) => LT.lt.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2350 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2352)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) b c) -> (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) c a))\nCase conversion may be inaccurate. Consider using '#align with_top.add_lt_add_right WithTop.add_lt_add_right\u2093'. -/\nprotected theorem add_lt_add_right [LT \u03b1] [CovariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)] (ha : a \u2260 \u22a4)\n    (h : b < c) : b + a < c + a := by\n  lift a to \u03b1 using ha\n  rcases lt_iff_exists_coe.1 h with \u27e8b, rfl, h'\u27e9\n  cases c\n  \u00b7 exact coe_lt_top _\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LE.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1)) (LE.le.{u1} \u03b1 _inst_2)] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1)) (LE.le.{u1} \u03b1 _inst_2)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a c)) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LE.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2461 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2463 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2478 : \u03b1) => LE.le.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2476 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2478)] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2495 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2497 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2512 : \u03b1) => LE.le.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2510 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2512)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a c)) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _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\u2093'. -/\nprotected theorem add_le_add_iff_left [LE \u03b1] [CovariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)]\n    [ContravariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] (ha : a \u2260 \u22a4) : a + b \u2264 a + c \u2194 b \u2264 c :=\n  \u27e8WithTop.le_of_add_le_add_left ha, fun h => add_le_add_left h a\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LE.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1))) (LE.le.{u1} \u03b1 _inst_2)] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1))) (LE.le.{u1} \u03b1 _inst_2)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) c a)) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLe.{u1} \u03b1 _inst_2) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LE.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2586 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2588 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2603 : \u03b1) => LE.le.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2601 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2603)] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2623 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2625 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2640 : \u03b1) => LE.le.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2638 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2640)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (Iff (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) c a)) (LE.le.{u1} (WithTop.{u1} \u03b1) (WithTop.le.{u1} \u03b1 _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\u2093'. -/\nprotected theorem add_le_add_iff_right [LE \u03b1] [CovariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)]\n    [ContravariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)] (ha : a \u2260 \u22a4) : b + a \u2264 c + a \u2194 b \u2264 c :=\n  \u27e8WithTop.le_of_add_le_add_right ha, fun h => add_le_add_right h a\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LT.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1)) (LT.lt.{u1} \u03b1 _inst_2)] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1)) (LT.lt.{u1} \u03b1 _inst_2)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a c)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LT.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2711 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2713 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2728 : \u03b1) => LT.lt.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2726 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2728)] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2745 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2747 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2762 : \u03b1) => LT.lt.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2760 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2762)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a c)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _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\u2093'. -/\nprotected theorem add_lt_add_iff_left [LT \u03b1] [CovariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)]\n    [ContravariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)] (ha : a \u2260 \u22a4) : a + b < a + c \u2194 b < c :=\n  \u27e8lt_of_add_lt_add_left, WithTop.add_lt_add_left ha\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LT.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1))) (LT.lt.{u1} \u03b1 _inst_2)] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _inst_1))) (LT.lt.{u1} \u03b1 _inst_2)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))) -> (Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) c a)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.hasLt.{u1} \u03b1 _inst_2) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] {a : WithTop.{u1} \u03b1} {b : WithTop.{u1} \u03b1} {c : WithTop.{u1} \u03b1} [_inst_2 : LT.{u1} \u03b1] [_inst_3 : CovariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2831 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2833 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2848 : \u03b1) => LT.lt.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2846 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2848)] [_inst_4 : ContravariantClass.{u1, u1} \u03b1 \u03b1 (Function.swap.{succ u1, succ u1, succ u1} \u03b1 \u03b1 (fun (\u1fb0 : \u03b1) (\u1fb0 : \u03b1) => \u03b1) (fun (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2868 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2870 : \u03b1) => HAdd.hAdd.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHAdd.{u1} \u03b1 _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 : \u03b1) (x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2885 : \u03b1) => LT.lt.{u1} \u03b1 _inst_2 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2883 x._@.Mathlib.Algebra.Order.Monoid.WithTop._hyg.2885)], (Ne.{succ u1} (WithTop.{u1} \u03b1) a (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))) -> (Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _inst_2) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) b a) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) c a)) (LT.lt.{u1} (WithTop.{u1} \u03b1) (WithTop.lt.{u1} \u03b1 _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\u2093'. -/\nprotected theorem add_lt_add_iff_right [LT \u03b1] [CovariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)]\n    [ContravariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)] (ha : a \u2260 \u22a4) : b + a < c + a \u2194 b < c :=\n  \u27e8lt_of_add_lt_add_right, WithTop.add_lt_add_right ha\u27e9\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 \u03b1] [CovariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)]\n    [CovariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)] (ha : a \u2260 \u22a4) (hab : a \u2264 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 \u03b1] [CovariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)]\n    [CovariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)] (hc : c \u2260 \u22a4) (hab : a < b) (hcd : c \u2264 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Add.{u1} \u03b1] {F : Type.{u3}} [_inst_2 : Add.{u2} \u03b2] [_inst_3 : AddHomClass.{u3, u1, u2} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : WithTop.{u1} \u03b1) (b : WithTop.{u1} \u03b1), Eq.{succ u2} (WithTop.{u2} \u03b2) (WithTop.map.{u1, u2} \u03b1 \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (AddHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)) f) (HAdd.hAdd.{u1, u1, u1} (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (WithTop.{u1} \u03b1) (instHAdd.{u1} (WithTop.{u1} \u03b1) (WithTop.add.{u1} \u03b1 _inst_1)) a b)) (HAdd.hAdd.{u2, u2, u2} (WithTop.{u2} \u03b2) (WithTop.{u2} \u03b2) (WithTop.{u2} \u03b2) (instHAdd.{u2} (WithTop.{u2} \u03b2) (WithTop.add.{u2} \u03b2 _inst_2)) (WithTop.map.{u1, u2} \u03b1 \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (AddHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)) f) a) (WithTop.map.{u1, u2} \u03b1 \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (AddHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)) f) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : Add.{u2} \u03b1] {F : Type.{u1}} [_inst_2 : Add.{u3} \u03b2] [_inst_3 : AddHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : WithTop.{u2} \u03b1) (b : WithTop.{u2} \u03b1), Eq.{succ u3} (WithTop.{u3} \u03b2) (WithTop.map.{u2, u3} \u03b1 \u03b2 (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3) f) (HAdd.hAdd.{u2, u2, u2} (WithTop.{u2} \u03b1) (WithTop.{u2} \u03b1) (WithTop.{u2} \u03b1) (instHAdd.{u2} (WithTop.{u2} \u03b1) (WithTop.add.{u2} \u03b1 _inst_1)) a b)) (HAdd.hAdd.{u3, u3, u3} (WithTop.{u3} \u03b2) (WithTop.{u3} \u03b2) (WithTop.{u3} \u03b2) (instHAdd.{u3} (WithTop.{u3} \u03b2) (WithTop.add.{u3} \u03b2 _inst_2)) (WithTop.map.{u2, u3} \u03b1 \u03b2 (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3) f) a) (WithTop.map.{u2, u3} \u03b1 \u03b2 (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3) f) b))\nCase conversion may be inaccurate. Consider using '#align with_top.map_add WithTop.map_add\u2093'. -/\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 \u03b2] [AddHomClass F \u03b1 \u03b2] (f : F) (a b : WithTop \u03b1) :\n    (a + b).map f = a.map f + b.map f :=\n  by\n  induction a using WithTop.recTopCoe\n  \u00b7 exact (top_add _).symm\n  \u00b7 induction b using WithTop.recTopCoe\n    \u00b7 exact (add_top _).symm\n    \u00b7 rw [map_coe, map_coe, \u2190 coe_add, \u2190 coe_add, \u2190 map_add]\n      rfl\n#align with_top.map_add WithTop.map_add\n\nend Add\n\ninstance [AddSemigroup \u03b1] : AddSemigroup (WithTop \u03b1) :=\n  { WithTop.add with add_assoc := fun _ _ _ => Option.map\u2082_assoc add_assoc }\n\ninstance [AddCommSemigroup \u03b1] : AddCommSemigroup (WithTop \u03b1) :=\n  { WithTop.addSemigroup with add_comm := fun _ _ => Option.map\u2082_comm add_comm }\n\ninstance [AddZeroClass \u03b1] : AddZeroClass (WithTop \u03b1) :=\n  { WithTop.zero,\n    WithTop.add with\n    zero_add := Option.map\u2082_left_identity zero_add\n    add_zero := Option.map\u2082_right_identity add_zero }\n\ninstance [AddMonoid \u03b1] : AddMonoid (WithTop \u03b1) :=\n  { WithTop.addZeroClass, WithTop.zero, WithTop.addSemigroup with }\n\ninstance [AddCommMonoid \u03b1] : AddCommMonoid (WithTop \u03b1) :=\n  { WithTop.addMonoid, WithTop.addCommSemigroup with }\n\ninstance [AddMonoidWithOne \u03b1] : AddMonoidWithOne (WithTop \u03b1) :=\n  { WithTop.one,\n    WithTop.addMonoid with\n    natCast := fun n => \u2191(n : \u03b1)\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 \u03b1] : AddCommMonoidWithOne (WithTop \u03b1) :=\n  { WithTop.addMonoidWithOne, WithTop.addCommMonoid with }\n\ninstance [OrderedAddCommMonoid \u03b1] : OrderedAddCommMonoid (WithTop \u03b1) :=\n  { WithTop.partialOrder, WithTop.addCommMonoid with\n    add_le_add_left := by\n      rintro a b h (_ | c); \u00b7 simp [none_eq_top]\n      rcases b with (_ | b); \u00b7 simp [none_eq_top]\n      rcases le_coe_iff.1 h with \u27e8a, rfl, h\u27e9\n      simp only [some_eq_coe, \u2190 coe_add, coe_le_coe] at h\u22a2\n      exact add_le_add_left h c }\n\ninstance [LinearOrderedAddCommMonoid \u03b1] : LinearOrderedAddCommMonoidWithTop (WithTop \u03b1) :=\n  { WithTop.orderTop, WithTop.linearOrder, WithTop.orderedAddCommMonoid, Option.nontrivial with\n    top_add' := WithTop.top_add }\n\ninstance [LE \u03b1] [Add \u03b1] [ExistsAddOfLE \u03b1] : ExistsAddOfLE (WithTop \u03b1) :=\n  \u27e8fun a b =>\n    match a, b with\n    | \u22a4, \u22a4 => by simp\n    | (a : \u03b1), \u22a4 => fun _ => \u27e8\u22a4, rfl\u27e9\n    | (a : \u03b1), (b : \u03b1) => fun h =>\n      by\n      obtain \u27e8c, rfl\u27e9 := exists_add_of_le (WithTop.coe_le_coe.1 h)\n      exact \u27e8c, rfl\u27e9\n    | \u22a4, (b : \u03b1) => fun h => (not_top_le_coe _ h).elim\u27e9\n\ninstance [CanonicallyOrderedAddMonoid \u03b1] : CanonicallyOrderedAddMonoid (WithTop \u03b1) :=\n  { WithTop.orderBot, WithTop.orderedAddCommMonoid, WithTop.existsAddOfLE with\n    le_self_add := fun a b =>\n      match a, b with\n      | \u22a4, \u22a4 => le_rfl\n      | (a : \u03b1), \u22a4 => le_top\n      | (a : \u03b1), (b : \u03b1) => WithTop.coe_le_coe.2 le_self_add\n      | \u22a4, (b : \u03b1) => le_rfl }\n\ninstance [CanonicallyLinearOrderedAddMonoid \u03b1] : CanonicallyLinearOrderedAddMonoid (WithTop \u03b1) :=\n  { WithTop.canonicallyOrderedAddMonoid, WithTop.linearOrder with }\n\n#print WithTop.coe_nat /-\n@[simp, norm_cast]\ntheorem coe_nat [AddMonoidWithOne \u03b1] (n : \u2115) : ((n : \u03b1) : WithTop \u03b1) = 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 \u03b1] (n : \u2115) : (n : WithTop \u03b1) \u2260 \u22a4 :=\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 \u03b1] (n : \u2115) : (\u22a4 : WithTop \u03b1) \u2260 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 `\u03b1` to `with_top \u03b1` as an `add_monoid_hom`. -/\ndef addHom [AddMonoid \u03b1] : \u03b1 \u2192+ WithTop \u03b1 :=\n  \u27e8coe, rfl, fun _ _ => rfl\u27e9\n#align with_top.coe_add_hom WithTop.addHom\n-/\n\n@[simp]\ntheorem coe_addHom [AddMonoid \u03b1] : \u21d1(addHom : \u03b1 \u2192+ WithTop \u03b1) = 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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedAddCommMonoid.{u1} \u03b1], LT.lt.{u1} (WithTop.{u1} \u03b1) (Preorder.toLT.{u1} (WithTop.{u1} \u03b1) (WithTop.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 _inst_1)))))))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.hasTop.{u1} \u03b1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedAddCommMonoid.{u1} \u03b1], LT.lt.{u1} (WithTop.{u1} \u03b1) (Preorder.toLT.{u1} (WithTop.{u1} \u03b1) (WithTop.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 _inst_1)))))) (Top.top.{u1} (WithTop.{u1} \u03b1) (WithTop.top.{u1} \u03b1))\nCase conversion may be inaccurate. Consider using '#align with_top.zero_lt_top WithTop.zero_lt_top\u2093'. -/\n@[simp]\ntheorem zero_lt_top [OrderedAddCommMonoid \u03b1] : (0 : WithTop \u03b1) < \u22a4 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : OrderedAddCommMonoid.{u1} \u03b1] (a : \u03b1), Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (Preorder.toLT.{u1} (WithTop.{u1} \u03b1) (WithTop.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (OfNat.mk.{u1} (WithTop.{u1} \u03b1) 0 (Zero.zero.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 _inst_1)))))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithTop.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithTop.{u1} \u03b1) (WithTop.hasCoeT.{u1} \u03b1))) a)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (AddZeroClass.toHasZero.{u1} \u03b1 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 _inst_1))))))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : OrderedAddCommMonoid.{u1} \u03b1] (a : \u03b1), Iff (LT.lt.{u1} (WithTop.{u1} \u03b1) (Preorder.toLT.{u1} (WithTop.{u1} \u03b1) (WithTop.preorder.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1)))) (OfNat.ofNat.{u1} (WithTop.{u1} \u03b1) 0 (Zero.toOfNat0.{u1} (WithTop.{u1} \u03b1) (WithTop.zero.{u1} \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 _inst_1)))))) (WithTop.some.{u1} \u03b1 a)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommMonoid.toPartialOrder.{u1} \u03b1 _inst_1))) (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (AddMonoid.toZero.{u1} \u03b1 (AddCommMonoid.toAddMonoid.{u1} \u03b1 (OrderedAddCommMonoid.toAddCommMonoid.{u1} \u03b1 _inst_1))))) a)\nCase conversion may be inaccurate. Consider using '#align with_top.zero_lt_coe WithTop.zero_lt_coe\u2093'. -/\n@[simp, norm_cast]\ntheorem zero_lt_coe [OrderedAddCommMonoid \u03b1] (a : \u03b1) : (0 : WithTop \u03b1) < a \u2194 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 \u2192+ N) : WithTop M \u2192+ 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 \u03b1] : One (WithBot \u03b1) :=\n  WithTop.one\n\ninstance [Add \u03b1] : Add (WithBot \u03b1) :=\n  WithTop.add\n\ninstance [AddSemigroup \u03b1] : AddSemigroup (WithBot \u03b1) :=\n  WithTop.addSemigroup\n\ninstance [AddCommSemigroup \u03b1] : AddCommSemigroup (WithBot \u03b1) :=\n  WithTop.addCommSemigroup\n\ninstance [AddZeroClass \u03b1] : AddZeroClass (WithBot \u03b1) :=\n  WithTop.addZeroClass\n\ninstance [AddMonoid \u03b1] : AddMonoid (WithBot \u03b1) :=\n  WithTop.addMonoid\n\ninstance [AddCommMonoid \u03b1] : AddCommMonoid (WithBot \u03b1) :=\n  WithTop.addCommMonoid\n\ninstance [AddMonoidWithOne \u03b1] : AddMonoidWithOne (WithBot \u03b1) :=\n  WithTop.addMonoidWithOne\n\ninstance [AddCommMonoidWithOne \u03b1] : AddCommMonoidWithOne (WithBot \u03b1) :=\n  WithTop.addCommMonoidWithOne\n\ninstance [Zero \u03b1] [One \u03b1] [LE \u03b1] [ZeroLEOneClass \u03b1] : ZeroLEOneClass (WithBot \u03b1) :=\n  \u27e8some_le_some.2 zero_le_one\u27e9\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 \u03b1] : ((1 : \u03b1) : WithBot \u03b1) = 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 \u03b1] {a : \u03b1} : (a : WithBot \u03b1) = 1 \u2194 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 \u03b1] : (1 : WithBot \u03b1).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 \u03b1] (d : \u03b1) : (1 : WithBot \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 1 (One.one.{u1} (WithBot.{u1} \u03b1) (WithBot.hasOne.{u1} \u03b1 _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a)) (LE.le.{u1} \u03b1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (One.toOfNat1.{u1} (WithBot.{u1} \u03b1) (WithBot.one.{u1} \u03b1 _inst_1))) (WithBot.some.{u1} \u03b1 a)) (LE.le.{u1} \u03b1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.one_le_coe WithBot.one_le_coe\u2093'. -/\n@[simp, norm_cast, to_additive coe_nonneg]\ntheorem one_le_coe [One \u03b1] [LE \u03b1] {a : \u03b1} : 1 \u2264 (a : WithBot \u03b1) \u2194 1 \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLe.{u1} \u03b1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 1 (One.one.{u1} (WithBot.{u1} \u03b1) (WithBot.hasOne.{u1} \u03b1 _inst_1))))) (LE.le.{u1} \u03b1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LE.{u1} \u03b1] {a : \u03b1}, Iff (LE.le.{u1} (WithBot.{u1} \u03b1) (WithBot.le.{u1} \u03b1 _inst_2) (WithBot.some.{u1} \u03b1 a) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (One.toOfNat1.{u1} (WithBot.{u1} \u03b1) (WithBot.one.{u1} \u03b1 _inst_1)))) (LE.le.{u1} \u03b1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_le_one WithBot.coe_le_one\u2093'. -/\n@[simp, norm_cast, to_additive coe_le_zero]\ntheorem coe_le_one [One \u03b1] [LE \u03b1] {a : \u03b1} : (a : WithBot \u03b1) \u2264 1 \u2194 a \u2264 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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 1 (One.one.{u1} (WithBot.{u1} \u03b1) (WithBot.hasOne.{u1} \u03b1 _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a)) (LT.lt.{u1} \u03b1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (One.toOfNat1.{u1} (WithBot.{u1} \u03b1) (WithBot.one.{u1} \u03b1 _inst_1))) (WithBot.some.{u1} \u03b1 a)) (LT.lt.{u1} \u03b1 _inst_2 (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align with_bot.one_lt_coe WithBot.one_lt_coe\u2093'. -/\n@[simp, norm_cast, to_additive coe_pos]\ntheorem one_lt_coe [One \u03b1] [LT \u03b1] {a : \u03b1} : 1 < (a : WithBot \u03b1) \u2194 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 {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_2) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) \u03b1 (WithBot.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} \u03b1 (WithBot.{u1} \u03b1) (WithBot.hasCoeT.{u1} \u03b1))) a) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 1 (One.one.{u1} (WithBot.{u1} \u03b1) (WithBot.hasOne.{u1} \u03b1 _inst_1))))) (LT.lt.{u1} \u03b1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_2) (WithBot.some.{u1} \u03b1 a) (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (One.toOfNat1.{u1} (WithBot.{u1} \u03b1) (WithBot.one.{u1} \u03b1 _inst_1)))) (LT.lt.{u1} \u03b1 _inst_2 a (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align with_bot.coe_lt_one WithBot.coe_lt_one\u2093'. -/\n@[simp, norm_cast, to_additive coe_lt_zero]\ntheorem coe_lt_one [One \u03b1] [LT \u03b1] {a : \u03b1} : (a : WithBot \u03b1) < 1 \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : One.{u1} \u03b1] (f : \u03b1 -> \u03b2), Eq.{succ u2} (WithBot.{u2} \u03b2) (WithBot.map.{u1, u2} \u03b1 \u03b2 f (OfNat.ofNat.{u1} (WithBot.{u1} \u03b1) 1 (OfNat.mk.{u1} (WithBot.{u1} \u03b1) 1 (One.one.{u1} (WithBot.{u1} \u03b1) (WithBot.hasOne.{u1} \u03b1 _inst_1))))) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) \u03b2 (WithBot.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} \u03b2 (WithBot.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} \u03b2 (WithBot.{u2} \u03b2) (WithBot.hasCoeT.{u2} \u03b2))) (f (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : One.{u2} \u03b1] (f : \u03b1 -> \u03b2), Eq.{succ u1} (WithBot.{u1} \u03b2) (WithBot.map.{u2, u1} \u03b1 \u03b2 f (OfNat.ofNat.{u2} (WithBot.{u2} \u03b1) 1 (One.toOfNat1.{u2} (WithBot.{u2} \u03b1) (WithBot.one.{u2} \u03b1 _inst_1)))) (WithBot.some.{u1} \u03b2 (f (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align with_bot.map_one WithBot.map_one\u2093'. -/\n@[simp, to_additive]\nprotected theorem map_one {\u03b2} [One \u03b1] (f : \u03b1 \u2192 \u03b2) : (1 : WithBot \u03b1).map f = (f 1 : WithBot \u03b2) :=\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 \u03b1] (n : \u2115) : ((n : \u03b1) : WithBot \u03b1) = 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 \u03b1] (n : \u2115) : (n : WithBot \u03b1) \u2260 \u22a5 :=\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 \u03b1] (n : \u2115) : (\u22a5 : WithBot \u03b1) \u2260 n :=\n  bot_ne_coe\n#align with_bot.bot_ne_nat WithBot.bot_ne_nat\n-/\n\nsection Add\n\nvariable [Add \u03b1] {a b c d : WithBot \u03b1} {x y : \u03b1}\n\n#print WithBot.coe_add /-\n-- `norm_cast` proves those lemmas, because `with_top`/`with_bot` are reducible\ntheorem coe_add (a b : \u03b1) : ((a + b : \u03b1) : WithBot \u03b1) = 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 : \u03b1) : WithBot \u03b1) = bit0 x :=\n  rfl\n#align with_bot.coe_bit0 WithBot.coe_bit0\n-/\n\n#print WithBot.coe_bit1 /-\ntheorem coe_bit1 [One \u03b1] {a : \u03b1} : ((bit1 a : \u03b1) : WithBot \u03b1) = 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 \u03b1) : \u22a5 + a = \u22a5 :=\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 \u03b1) : a + \u22a5 = \u22a5 := 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 = \u22a5 \u2194 a = \u22a5 \u2228 b = \u22a5 :=\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 \u2260 \u22a5 \u2194 a \u2260 \u22a5 \u2227 b \u2260 \u22a5 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_2) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) (HAdd.hAdd.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHAdd.{u1} (WithBot.{u1} \u03b1) (WithBot.hasAdd.{u1} \u03b1 _inst_1)) a b)) (And (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_2) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) a) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.hasLt.{u1} \u03b1 _inst_2) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.hasBot.{u1} \u03b1)) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Add.{u1} \u03b1] [_inst_2 : LT.{u1} \u03b1] {a : WithBot.{u1} \u03b1} {b : WithBot.{u1} \u03b1}, Iff (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_2) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) (HAdd.hAdd.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHAdd.{u1} (WithBot.{u1} \u03b1) (WithBot.add.{u1} \u03b1 _inst_1)) a b)) (And (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_2) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) a) (LT.lt.{u1} (WithBot.{u1} \u03b1) (WithBot.lt.{u1} \u03b1 _inst_2) (Bot.bot.{u1} (WithBot.{u1} \u03b1) (WithBot.bot.{u1} \u03b1)) b))\nCase conversion may be inaccurate. Consider using '#align with_bot.bot_lt_add WithBot.bot_lt_add\u2093'. -/\ntheorem bot_lt_add [LT \u03b1] {a b : WithBot \u03b1} : \u22a5 < a + b \u2194 \u22a5 < a \u2227 \u22a5 < b :=\n  @WithTop.add_lt_top \u03b1\u1d52\u1d48 _ _ _ _\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 \u2194 \u2203 a' b' : \u03b1, \u2191a' = a \u2227 \u2191b' = b \u2227 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 = \u22a5 \u2194 a = \u22a5 :=\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 : \u2191x + b = \u22a5 \u2194 b = \u22a5 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Add.{u1} \u03b1] {F : Type.{u3}} [_inst_2 : Add.{u2} \u03b2] [_inst_3 : AddHomClass.{u3, u1, u2} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : WithBot.{u1} \u03b1) (b : WithBot.{u1} \u03b1), Eq.{succ u2} (WithBot.{u2} \u03b2) (WithBot.map.{u1, u2} \u03b1 \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (AddHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)) f) (HAdd.hAdd.{u1, u1, u1} (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (WithBot.{u1} \u03b1) (instHAdd.{u1} (WithBot.{u1} \u03b1) (WithBot.hasAdd.{u1} \u03b1 _inst_1)) a b)) (HAdd.hAdd.{u2, u2, u2} (WithBot.{u2} \u03b2) (WithBot.{u2} \u03b2) (WithBot.{u2} \u03b2) (instHAdd.{u2} (WithBot.{u2} \u03b2) (WithBot.hasAdd.{u2} \u03b2 _inst_2)) (WithBot.map.{u1, u2} \u03b1 \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (AddHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)) f) a) (WithBot.map.{u1, u2} \u03b1 \u03b2 (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => \u03b1 -> \u03b2) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F \u03b1 (fun (_x : \u03b1) => \u03b2) (AddHomClass.toFunLike.{u3, u1, u2} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3)) f) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : Add.{u2} \u03b1] {F : Type.{u1}} [_inst_2 : Add.{u3} \u03b2] [_inst_3 : AddHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2] (f : F) (a : WithBot.{u2} \u03b1) (b : WithBot.{u2} \u03b1), Eq.{succ u3} (WithBot.{u3} \u03b2) (WithBot.map.{u2, u3} \u03b1 \u03b2 (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3) f) (HAdd.hAdd.{u2, u2, u2} (WithBot.{u2} \u03b1) (WithBot.{u2} \u03b1) (WithBot.{u2} \u03b1) (instHAdd.{u2} (WithBot.{u2} \u03b1) (WithBot.add.{u2} \u03b1 _inst_1)) a b)) (HAdd.hAdd.{u3, u3, u3} (WithBot.{u3} \u03b2) (WithBot.{u3} \u03b2) (WithBot.{u3} \u03b2) (instHAdd.{u3} (WithBot.{u3} \u03b2) (WithBot.add.{u3} \u03b2 _inst_2)) (WithBot.map.{u2, u3} \u03b1 \u03b2 (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3) f) a) (WithBot.map.{u2, u3} \u03b1 \u03b2 (FunLike.coe.{succ u1, succ u2, succ u3} F \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : \u03b1) => \u03b2) _x) (AddHomClass.toFunLike.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3) f) b))\nCase conversion may be inaccurate. Consider using '#align with_bot.map_add WithBot.map_add\u2093'. -/\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 \u03b2] [AddHomClass F \u03b1 \u03b2] (f : F) (a b : WithBot \u03b1) :\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 \u2192+ N) : WithBot M \u2192+ 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 \u03b1]\n\n#print WithBot.covariantClass_add_le /-\ninstance covariantClass_add_le [CovariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] :\n    CovariantClass (WithBot \u03b1) (WithBot \u03b1) (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7) :=\n  @OrderDual.covariantClass_add_le (WithTop \u03b1\u1d52\u1d48) _ _ _\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 \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)] :\n    CovariantClass (WithBot \u03b1) (WithBot \u03b1) (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7) :=\n  @OrderDual.covariantClass_swap_add_le (WithTop \u03b1\u1d52\u1d48) _ _ _\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 \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)] :\n    ContravariantClass (WithBot \u03b1) (WithBot \u03b1) (\u00b7 + \u00b7) (\u00b7 < \u00b7) :=\n  @OrderDual.contravariantClass_add_lt (WithTop \u03b1\u1d52\u1d48) _ _ _\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 \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)] :\n    ContravariantClass (WithBot \u03b1) (WithBot \u03b1) (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7) :=\n  @OrderDual.contravariantClass_swap_add_lt (WithTop \u03b1\u1d52\u1d48) _ _ _\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 \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] (ha : a \u2260 \u22a5)\n    (h : a + b \u2264 a + c) : b \u2264 c :=\n  @WithTop.le_of_add_le_add_left \u03b1\u1d52\u1d48 _ _ _ _ _ _ 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 \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)]\n    (ha : a \u2260 \u22a5) (h : b + a \u2264 c + a) : b \u2264 c :=\n  @WithTop.le_of_add_le_add_right \u03b1\u1d52\u1d48 _ _ _ _ _ _ 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 \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)] (ha : a \u2260 \u22a5) (h : b < c) :\n    a + b < a + c :=\n  @WithTop.add_lt_add_left \u03b1\u1d52\u1d48 _ _ _ _ _ _ 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 \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)] (ha : a \u2260 \u22a5)\n    (h : b < c) : b + a < c + a :=\n  @WithTop.add_lt_add_right \u03b1\u1d52\u1d48 _ _ _ _ _ _ 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 \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)]\n    [ContravariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] (ha : a \u2260 \u22a5) : a + b \u2264 a + c \u2194 b \u2264 c :=\n  \u27e8WithBot.le_of_add_le_add_left ha, fun h => add_le_add_left h a\u27e9\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 \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)]\n    [ContravariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)] (ha : a \u2260 \u22a5) : b + a \u2264 c + a \u2194 b \u2264 c :=\n  \u27e8WithBot.le_of_add_le_add_right ha, fun h => add_le_add_right h a\u27e9\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 \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)]\n    [ContravariantClass \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)] (ha : a \u2260 \u22a5) : a + b < a + c \u2194 b < c :=\n  \u27e8lt_of_add_lt_add_left, WithBot.add_lt_add_left ha\u27e9\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 \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)]\n    [ContravariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)] (ha : a \u2260 \u22a5) : b + a < c + a \u2194 b < c :=\n  \u27e8lt_of_add_lt_add_right, WithBot.add_lt_add_right ha\u27e9\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 \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 < \u00b7)]\n    [CovariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 \u2264 \u00b7)] (hb : b \u2260 \u22a5) (hab : a \u2264 b) (hcd : c < d) :\n    a + c < b + d :=\n  @WithTop.add_lt_add_of_le_of_lt \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ 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 \u03b1 \u03b1 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)]\n    [CovariantClass \u03b1 \u03b1 (swap (\u00b7 + \u00b7)) (\u00b7 < \u00b7)] (hd : d \u2260 \u22a5) (hab : a < b) (hcd : c \u2264 d) :\n    a + c < b + d :=\n  @WithTop.add_lt_add_of_lt_of_le \u03b1\u1d52\u1d48 _ _ _ _ _ _ _ _ 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 \u03b1] : OrderedAddCommMonoid (WithBot \u03b1) :=\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 \u03b1] : LinearOrderedAddCommMonoid (WithBot \u03b1) :=\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u211a 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, \u211a, numerator, denominator, num, denom, cast, coercion, casting\n-/\n\n\nvariable {F \u03b9 \u03b1 \u03b2 : Type _}\n\nnamespace Rat\n\nopen Rat\n\nsection WithDivRing\n\nvariable [DivisionRing \u03b1]\n\n@[simp, norm_cast]\ntheorem cast_coe_int (n : \u2124) : ((n : \u211a) : \u03b1) = n :=\n  (cast_def _).trans <| show (n / (1 : \u2115) : \u03b1) = 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 : \u211a) : \u03b1) = 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 : \u211a) : \u03b1) = 1 :=\n  (cast_coe_int _).trans Int.cast_one\n#align rat.cast_one Rat.cast_one\n\ntheorem cast_commute (r : \u211a) (a : \u03b1) : Commute (\u2191r) 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 : \u211a) (a : \u03b1) : (r : \u03b1) * a = a * r :=\n  (cast_commute r a).eq\n#align rat.cast_comm Rat.cast_comm\n\ntheorem commute_cast (a : \u03b1) (r : \u211a) : 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 : \u2124) (b0 : (b : \u03b1) \u2260 0) : (a /. b : \u03b1) = a / b := by\n  have b0' : b \u2260 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 : \u03b1) \u2260 0 := by\n    intro d0\n    have dd := den_dvd a b\n    cases' show (d : \u2124) \u2223 b by rwa [e] at dd with k ke\n    have : (b : \u03b1) = (d : \u03b1) * (k : \u03b1) := 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 ((\u2191) : \u2124 \u2192 \u03b1)\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, \u2190 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    \u2200 {m n : \u211a}, (m.den : \u03b1) \u2260 0 \u2192 (n.den : \u03b1) \u2260 0 \u2192 ((m + n : \u211a) : \u03b1) = m + n\n  | \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9, \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 => fun (d\u20810 : (d\u2081 : \u03b1) \u2260 0) (d\u20820 : (d\u2082 : \u03b1) \u2260 0) =>\n    by\n    have d\u20810' : (d\u2081 : \u2124) \u2260 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d\u20810 ; exact d\u20810 Nat.cast_zero\n    have d\u20820' : (d\u2082 : \u2124) \u2260 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d\u20820 ; exact d\u20820 Nat.cast_zero\n    rw [num_den', num_den', add_def'' d\u20810' d\u20820']\n    suffices (n\u2081 * (d\u2082 * ((d\u2082 : \u03b1)\u207b\u00b9 * (d\u2081 : \u03b1)\u207b\u00b9)) + n\u2082 * (d\u2081 * (d\u2082 : \u03b1)\u207b\u00b9) * (d\u2081 : \u03b1)\u207b\u00b9 : \u03b1)\n        = n\u2081 * (d\u2081 : \u03b1)\u207b\u00b9 + n\u2082 * (d\u2082 : \u03b1)\u207b\u00b9\n      by\n      rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero]\n      \u00b7 simpa [division_def, left_distrib, right_distrib, mul_inv_rev, d\u20810, d\u20820, mul_assoc]\n      all_goals simp [d\u20810, d\u20820]\n    rw [\u2190 mul_assoc (d\u2082 : \u03b1), mul_inv_cancel d\u20820, one_mul, (Nat.cast_commute _ _).eq]\n    simp [d\u20810, mul_assoc]\n#align rat.cast_add_of_ne_zero Rat.cast_add_of_ne_zero\n\n@[simp, norm_cast]\ntheorem cast_neg : \u2200 n, ((-n : \u211a) : \u03b1) = -n\n  | \u27e8n, d, h, c\u27e9 => by\n    simpa only [cast_def] using\n      show (\u2191(-n) / d : \u03b1) = -(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 : \u211a} (m0 : (m.den : \u03b1) \u2260 0) (n0 : (n.den : \u03b1) \u2260 0) :\n    ((m - n : \u211a) : \u03b1) = m - n := by\n  have : ((-n).den : \u03b1) \u2260 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    \u2200 {m n : \u211a}, (m.den : \u03b1) \u2260 0 \u2192 (n.den : \u03b1) \u2260 0 \u2192 ((m * n : \u211a) : \u03b1) = m * n\n  | \u27e8n\u2081, d\u2081, h\u2081, c\u2081\u27e9, \u27e8n\u2082, d\u2082, h\u2082, c\u2082\u27e9 => fun (d\u20810 : (d\u2081 : \u03b1) \u2260 0) (d\u20820 : (d\u2082 : \u03b1) \u2260 0) =>\n    by\n    have d\u20810' : (d\u2081 : \u2124) \u2260 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d\u20810 ; exact d\u20810 Nat.cast_zero\n    have d\u20820' : (d\u2082 : \u2124) \u2260 0 :=\n      Int.coe_nat_ne_zero.2 fun e => by rw [e] at d\u20820 ; exact d\u20820 Nat.cast_zero\n    rw [num_den', num_den', mul_def' d\u20810' d\u20820']\n    suffices (n\u2081 * (n\u2082 * (d\u2082 : \u03b1)\u207b\u00b9 * (d\u2081 : \u03b1)\u207b\u00b9) : \u03b1) = n\u2081 * ((d\u2081 : \u03b1)\u207b\u00b9 * (n\u2082 * (d\u2082 : \u03b1)\u207b\u00b9))\n      by\n      rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero, cast_mk_of_ne_zero]\n      \u00b7 simpa [division_def, mul_inv_rev, d\u20810, d\u20820, mul_assoc]\n      all_goals simp [d\u20810, d\u20820]\n    rw [(d\u2081.commute_cast (_ : \u03b1)).inv_right\u2080.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 : \u2115) : ((n\u207b\u00b9 : \u211a) : \u03b1) = (n : \u03b1)\u207b\u00b9 := by\n  cases' n with n\n  \u00b7 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 : \u2124) : ((n\u207b\u00b9 : \u211a) : \u03b1) = (n : \u03b1)\u207b\u00b9 := by\n  cases' n with n n\n  \u00b7 simp [ofInt_eq_cast, cast_inv_nat]\n  \u00b7 simp only [ofInt_eq_cast, Int.cast_negSucc, \u2190 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  \u2200 {n : \u211a}, (n.num : \u03b1) \u2260 0 \u2192 (n.den : \u03b1) \u2260 0 \u2192 ((n\u207b\u00b9 : \u211a) : \u03b1) = (n : \u03b1)\u207b\u00b9\n  | \u27e8n, d, h, c\u27e9 => fun (n0 : (n : \u03b1) \u2260 0) (d0 : (d : \u03b1) \u2260 0) =>\n    by\n    have _ : (n : \u2124) \u2260 0 := fun e => by rw [e] at n0 ; exact n0 Int.cast_zero\n    have _ : (d : \u2124) \u2260 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 : \u211a} (md : (m.den : \u03b1) \u2260 0) (nn : (n.num : \u03b1) \u2260 0)\n    (nd : (n.den : \u03b1) \u2260 0) : ((m / n : \u211a) : \u03b1) = m / n := by\n  have : (n\u207b\u00b9.den : \u2124) \u2223 n.num := by\n    conv in n\u207b\u00b9.den => rw [\u2190 @num_den n, inv_def']\n    apply den_dvd\n  have : (n\u207b\u00b9.den : \u03b1) = 0 \u2192 (n.num : \u03b1) = 0 := fun h =>\n    by\n    let \u27e8k, e\u27e9 := this\n    have := congr_arg ((\u2191) : \u2124 \u2192 \u03b1) 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 \u03b1] : \u2200 {m n : \u211a}, (m : \u03b1) = n \u2194 m = n\n  | \u27e8n\u2081, d\u2081, d\u20810, c\u2081\u27e9, \u27e8n\u2082, d\u2082, d\u20820, c\u2082\u27e9 =>\n    by\n    refine' \u27e8fun h => _, congr_arg _\u27e9\n    have d\u2081a : (d\u2081 : \u03b1) \u2260 0 := Nat.cast_ne_zero.2 d\u20810\n    have d\u2082a : (d\u2082 : \u03b1) \u2260 0 := Nat.cast_ne_zero.2 d\u20820\n    rw [num_den', num_den'] at h\u22a2\n    rw [cast_mk_of_ne_zero, cast_mk_of_ne_zero] at h <;> simp [d\u20810, d\u20820] at h\u22a2\n    rwa [eq_div_iff_mul_eq d\u2082a, division_def, mul_assoc, (d\u2081.cast_commute (d\u2082 : \u03b1)).inv_left\u2080.eq, \u2190\n      mul_assoc, \u2190 division_def, eq_comm, eq_div_iff_mul_eq d\u2081a, eq_comm, \u2190 Int.cast_ofNat d\u2081, \u2190\n      Int.cast_mul, \u2190 Int.cast_ofNat d\u2082, \u2190 Int.cast_mul, Int.cast_inj, \u2190 mkRat_eq_iff d\u20810 d\u20820] at h\n#align rat.cast_inj Rat.cast_inj\n\ntheorem cast_injective [CharZero \u03b1] : Function.Injective ((\u2191) : \u211a \u2192 \u03b1)\n  | _, _ => cast_inj.1\n#align rat.cast_injective Rat.cast_injective\n\n@[simp]\ntheorem cast_eq_zero [CharZero \u03b1] {n : \u211a} : (n : \u03b1) = 0 \u2194 n = 0 := by rw [\u2190 cast_zero, cast_inj]\n#align rat.cast_eq_zero Rat.cast_eq_zero\n\ntheorem cast_ne_zero [CharZero \u03b1] {n : \u211a} : (n : \u03b1) \u2260 0 \u2194 n \u2260 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 \u03b1] (m n) : ((m + n : \u211a) : \u03b1) = 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 \u03b1] (m n) : ((m - n : \u211a) : \u03b1) = 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 \u03b1] (m n) : ((m * n : \u211a) : \u03b1) = 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 \u03b1] (n : \u211a) : ((bit0 n : \u211a) : \u03b1) = (bit0 n : \u03b1) :=\n  cast_add _ _\n#align rat.cast_bit0 Rat.cast_bit0\n\n@[simp, norm_cast]\ntheorem cast_bit1 [CharZero \u03b1] (n : \u211a) : ((bit1 n : \u211a) : \u03b1) = (bit1 n : \u03b1) := by\n  rw [bit1, cast_add, cast_one, cast_bit0] ; rfl\n#align rat.cast_bit1 Rat.cast_bit1\n\nend\n\nvariable (\u03b1)\nvariable [CharZero \u03b1]\n\n/-- Coercion `\u211a \u2192 \u03b1` as a `RingHom`. -/\ndef castHom : \u211a \u2192+* \u03b1 where\n  toFun := (\u2191)\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 {\u03b1}\n\n@[simp]\ntheorem coe_cast_hom : \u21d1(castHom \u03b1) = ((\u2191) : \u211a \u2192 \u03b1) :=\n  rfl\n#align rat.coe_cast_hom Rat.coe_cast_hom\n\n@[simp, norm_cast]\ntheorem cast_inv (n) : ((n\u207b\u00b9 : \u211a) : \u03b1) = (n : \u03b1)\u207b\u00b9 :=\n  map_inv\u2080 (castHom \u03b1) _\n#align rat.cast_inv Rat.cast_inv\n\n@[simp, norm_cast]\ntheorem cast_div (m n) : ((m / n : \u211a) : \u03b1) = m / n :=\n  map_div\u2080 (castHom \u03b1) _ _\n#align rat.cast_div Rat.cast_div\n\n@[simp, norm_cast]\ntheorem cast_zpow (q : \u211a) (n : \u2124) : ((q ^ n : \u211a) : \u03b1) = (q : \u03b1) ^ n :=\n  map_zpow\u2080 (castHom \u03b1) q n\n#align rat.cast_zpow Rat.cast_zpow\n\n@[norm_cast]\ntheorem cast_mk (a b : \u2124) : (a /. b : \u03b1) = 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 : \u2115) : ((q : \u211a) ^ k : \u03b1) = (q : \u03b1) ^ k :=\n  (castHom \u03b1).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 : \u211a} (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 ((\u2191) : \u211a \u2192 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 ((\u2191) : \u211a \u2192 K) :=\n  cast_strictMono.monotone\n#align rat.cast_mono Rat.cast_mono\n\n/-- Coercion from `\u211a` as an order embedding. -/\n@[simps!]\ndef castOrderEmbedding : \u211a \u21aao K :=\n  OrderEmbedding.ofStrictMono (\u2191) 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 : \u211a} : (m : K) \u2264 n \u2194 m \u2264 n :=\n  castOrderEmbedding.le_iff_le\n#align rat.cast_le Rat.cast_le\n\n@[simp, norm_cast]\ntheorem cast_lt {m n : \u211a} : (m : K) < n \u2194 m < n :=\n  cast_strictMono.lt_iff_lt\n#align rat.cast_lt Rat.cast_lt\n\n@[simp]\ntheorem cast_nonneg {n : \u211a} : 0 \u2264 (n : K) \u2194 0 \u2264 n := by\n      norm_cast\n\n#align rat.cast_nonneg Rat.cast_nonneg\n\n@[simp]\ntheorem cast_nonpos {n : \u211a} : (n : K) \u2264 0 \u2194 n \u2264 0 := by\n      norm_cast\n#align rat.cast_nonpos Rat.cast_nonpos\n\n@[simp]\ntheorem cast_pos {n : \u211a} : (0 : K) < n \u2194 0 < n := by\n      norm_cast\n#align rat.cast_pos Rat.cast_pos\n\n@[simp]\ntheorem cast_lt_zero {n : \u211a} : (n : K) < 0 \u2194 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 : \u211a} : (\u2191(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 : \u211a} : (\u2191(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 : \u211a} : ((|q| : \u211a) : 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 : \u211a) : (\u2191) \u207b\u00b9' 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 : \u211a) : (\u2191) \u207b\u00b9' 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 : \u211a) : (\u2191) \u207b\u00b9' 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 : \u211a) : (\u2191) \u207b\u00b9' 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 : \u211a) : (\u2191) \u207b\u00b9' 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 : \u211a) : (\u2191) \u207b\u00b9' 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 : \u211a) : (\u2191) \u207b\u00b9' 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 : \u211a) : (\u2191) \u207b\u00b9' 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 : \u211a) : Rat.cast n = n := rfl\n#align rat.cast_id Rat.cast_id\n\n@[simp]\ntheorem cast_eq_id : ((\u2191) : \u211a \u2192 \u211a) = id :=\n  funext fun _ => rfl\n#align rat.cast_eq_id Rat.cast_eq_id\n\n@[simp]\ntheorem cast_hom_rat : castHom \u211a = RingHom.id \u211a :=\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 \u03b1] [DivisionRing \u03b2] [RingHomClass F \u03b1 \u03b2] (f : F) (q : \u211a) :\n    f q = q := by rw [cast_def, map_div\u2080, map_intCast, map_natCast, cast_def]\n#align map_rat_cast map_ratCast\n\n@[simp]\ntheorem eq_ratCast {k} [DivisionRing k] [RingHomClass F \u211a k] (f : F) (r : \u211a) : f r = r := by\n  rw [\u2190 map_ratCast f, Rat.cast_id]\n#align eq_rat_cast eq_ratCast\n\nnamespace MonoidWithZeroHom\n\nvariable {M\u2080 : Type _} [MonoidWithZero M\u2080] [MonoidWithZeroHomClass F \u211a M\u2080] {f g : F}\n\n\n/-- If `f` and `g` agree on the integers then they are equal `\u03c6`. -/\ntheorem ext_rat' (h : \u2200 m : \u2124, f m = g m) : f = g :=\n  (FunLike.ext f g) fun r => by\n    rw [\u2190 r.num_div_den, div_eq_mul_inv, map_mul, map_mul, h, \u2190 Int.cast_ofNat,\n      eq_on_inv\u2080 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 `\u03c6`.\n\nSee note [partially-applied ext lemmas] for why `comp` is used here. -/\n@[ext]\ntheorem ext_rat {f g : \u211a \u2192*\u2080 M\u2080}\n    (h : f.comp (Int.castRingHom \u211a : \u2124 \u2192*\u2080 \u211a) = g.comp (Int.castRingHom \u211a)) : 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 `\u03c6` and its value on `-1` completely determine `\u03c6`. -/\ntheorem ext_rat_on_pnat (same_on_neg_one : f (-1) = g (-1))\n    (same_on_pnat : \u2200 n : \u2115, 0 < n \u2192 f n = g n) : f = g :=\n  ext_rat' <|\n    FunLike.congr_fun <|\n      show\n        (f : \u211a \u2192*\u2080 M\u2080).comp (Int.castRingHom \u211a : \u2124 \u2192*\u2080 \u211a) =\n          (g : \u211a \u2192*\u2080 M\u2080).comp (Int.castRingHom \u211a : \u2124 \u2192*\u2080 \u211a)\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 `\u211a` 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 \u211a R] (f g : F) : f = g :=\n  MonoidWithZeroHom.ext_rat' <|\n    RingHom.congr_fun <|\n      ((f : \u211a \u2192+* R).comp (Int.castRingHom \u211a)).ext_int ((g : \u211a \u2192+* R).comp (Int.castRingHom \u211a))\n#align ring_hom.ext_rat RingHom.ext_rat\n\ninstance Rat.subsingleton_ringHom {R : Type _} [Semiring R] : Subsingleton (\u211a \u2192+* R) :=\n  \u27e8RingHom.ext_rat\u27e9\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 \u211a K where\n  smul := (\u00b7 \u2022 \u00b7)\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 \u211a K K :=\n  \u27e8fun a x y => by simp only [smul_def, smul_eq_mul, mul_assoc]\u27e9\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]\u2098` for `a : K\u02e3`, where `[a]\u2098` is the element of\nthe base-change `F \u2297[\u2124] (additive K\u02e3)` corresponding to `a`. \n-/\nnotation `[`:max a`]\u2098`:max := 1 \u2297\u209c (additive.of_mul a)\n\nlemma one_tmul_mul (a b : K\u02e3) : ([a * b]\u2098 : F \u2297[\u2124] additive K\u02e3) = \n  [a]\u2098 + [b]\u2098 := \ntensor_product.tmul_add _ _ _\n\nlemma one_tmul_inv (a : K\u02e3) : ([a\u207b\u00b9]\u2098 : F \u2297[\u2124] additive K\u02e3) = - [a]\u2098 :=\ntensor_product.tmul_neg _ _\n\n/-\nWe consider the weak topology on `dual F (F \u2297[\u2124] additive K\u02e3)`. \nThis is just the pointwise convergence topology, i.e. the topology\ninduced by the product topology on the type of functions `F \u2297[\u2124] additive K\u02e3 \u2192 F` \nwhere `F` is given the discrete topology.\n-/\ndef module.dual.weak_topology : \n  topological_space (dual F (F \u2297[\u2124] additive K\u02e3)) := \ntopological_space.induced (\u03bb e a, e a) $ \n(@Pi.topological_space (F \u2297[\u2124] additive K\u02e3) (\u03bb _, F) $ \u03bb a, \u22a5)\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 : \u2124` and some `n : \u2115` such that `(n : F) \u2260 0`.\nvariable [is_prime_field F]\n\nexample : is_prime_field \u211a := infer_instance\nexample (p : \u2115) [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 \u2297[\u2124] additive K\u02e3)`,\n  (D : submodule F (dual F (F \u2297[\u2124] additive K\u02e3))) \n  -- which is: (1) closed with respect to the topology introduced above; \n  (h1 : is_closed (D : set (dual F (F \u2297[\u2124] additive K\u02e3))))\n  -- (2) every element of `D` maps `[(-1 : K\u02e3)]\u2098` to zero;\n  (h2 : \u2200 (f : dual F (F \u2297[\u2124] additive K\u02e3)) (hf : f \u2208 D), f [-1]\u2098 = 0) \n  -- (3) satisfies the alternating condition, i.e. whenever `u v : K\u02e3` satisfy\n  -- `(u : K) + v = 1`, then `f [u]\u2098 * g [v]\u2098 = f [v]\u2098 * g [u]\u2098`.\n  (h3 : \u2200 (u v : K\u02e3) (huv : (u : K) + v = 1) \n    (f g : dual F (F \u2297[\u2124] additive K\u02e3))\n    (hf : f \u2208 D) (hg : g \u2208 D), \n    f [u]\u2098 * g [v]\u2098 = f [v]\u2098 * g [u]\u2098) : \n  -- Then there exists a valuation subring `R` of `K`, \n  \u2203 (R : valuation_subring K)\n  -- and another submodule `I` of `dual F (F \u2297[\u2124] additive K\u02e3)` \n    (I : submodule F (dual F (F \u2297[\u2124] additive K\u02e3)))\n    -- which is closed, and such that the following hold:\n    (Iclosed : is_closed (I : set (dual F (F \u2297[\u2124] additive K\u02e3))))\n    -- (1) `I` is contained in `D`;\n    (le : I \u2264 D)\n    -- (2) the elements `f` of `I` satisfy `f [u]\u2098 = 0` for `R`-units;\n    (units : \u2200 (u : K\u02e3) (hu : u \u2208 R.unit_group) \n      (f : dual F (F \u2297[\u2124] additive K\u02e3))\n      (hf : f \u2208 I), f [u]\u2098 = 0)\n    -- (3) the elements `f` of `D` satisfy `f [u]\u2098 = 0` for `R`-principal-units;\n    (punits : \u2200 (u : K\u02e3) (hu : u \u2208 R.principal_unit_group) \n      (f : dual F (F \u2297[\u2124] additive K\u02e3))\n      (hf : f \u2208 D), f [u]\u2098 = 0)\n    -- (4) the quotient `D / I` is finite dimensional;\n    (fd : finite_dimensional F (\u21a5D \u29f8 I.comap D.subtype)),\n    -- and `I` has codimension at most one in `D`.\n    finrank F (\u21a5D \u29f8 I.comap D.subtype) \u2264 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 \u27e8h1, h3, h2\u27e9 },\n  have hacl' : T.dual_annihilator.acl, \n  { convert hacl },\n  obtain \u27e8R,H,le,units,principal_units,fd,codim\u27e9 := main_theorem_mul T hacl',\n  let I := H.dual_annihilator,\n  obtain \u27e8e\u27e9 : nonempty ((\u21a5D \u29f8 submodule.comap D.subtype I) \u2243\u2097[F] \n    (dual F (\u21a5H \u29f8 T.comap H.subtype))), \n  { dsimp [I],\n    rw \u2190 hTD,\n    use submodule.dual_mod_comap_iso T H le,},\n  refine \u27e8R, I, _, _, _, _, _, _\u27e9,\n  { rw submodule.is_closed_iff, apply submodule.is_closed_dual_annihilator },\n  { intros f hf, rw [\u2190 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 \u2190 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 \u2190 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 \u03b1` as a structure containing a term `a : \u03b1` for any type `\u03b1`,\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 \u27f6 Y` in `discrete \u03b1` as `X = Y`,\none might define it as `plift (X = Y)`.\nIn fact, to allow `discrete \u03b1` to be a `small_category`\n(i.e. with morphisms in the same universe as the objects),\nwe actually define the hom type `X \u27f6 Y` as `ulift (plift (X = Y))`.\n\n`discrete.functor` promotes a function `f : I \u2192 C` (for any category `C`) to a functor\n`discrete.functor f : discrete I \u2964 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\u2081 v\u2082 v\u2083 u\u2081 u\u2082 u\u2083\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 \u03b1` and `\u03b1`. Otherwise there is too much API leakage.\n@[ext] structure discrete (\u03b1 : Type u\u2081) :=\n(as : \u03b1)\n\n@[simp] lemma discrete.mk_as {\u03b1 : Type u\u2081} (X : discrete \u03b1) : discrete.mk X.as = X :=\nby { ext, refl, }\n\n/-- `discrete \u03b1` is equivalent to the original type `\u03b1`.-/\n@[simps] def discrete_equiv {\u03b1 : Type u\u2081} : discrete \u03b1 \u2243 \u03b1 :=\n{ to_fun := discrete.as,\n  inv_fun := discrete.mk,\n  left_inv := by tidy,\n  right_inv := by tidy, }\n\ninstance {\u03b1 : Type u\u2081} [decidable_eq \u03b1] : decidable_eq (discrete \u03b1) :=\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 \u27f6 Y` as `ulift (plift (X = Y))`.\n\nSee <https://stacks.math.columbia.edu/tag/001A>\n-/\ninstance discrete_category (\u03b1 : Type u\u2081) : small_category (discrete \u03b1) :=\n{ hom  := \u03bb X Y, ulift (plift (X.as = Y.as)),\n  id   := \u03bb X, ulift.up (plift.up rfl),\n  comp := \u03bb X Y Z g f, by { cases X, cases Y, cases Z, rcases f with \u27e8\u27e8\u27e8\u27e9\u27e9\u27e9, exact g } }\n\nnamespace discrete\n\nvariables {\u03b1 : Type u\u2081}\n\ninstance [inhabited \u03b1] : inhabited (discrete \u03b1) :=\n\u27e8\u27e8default\u27e9\u27e9\n\ninstance [subsingleton \u03b1] : subsingleton (discrete \u03b1) :=\n\u27e8by { intros, ext, apply subsingleton.elim, }\u27e9\n\n/-- A simple tactic to run `cases` on any `discrete \u03b1` hypotheses. -/\nmeta def _root_.tactic.discrete_cases : tactic unit :=\n`[cases_matching* [discrete _, (_ : discrete _) \u27f6 (_ : discrete _), plift _]]\n\nrun_cmd add_interactive [``tactic.discrete_cases]\n\nlocal attribute [tidy] tactic.discrete_cases\n\ninstance [unique \u03b1] : unique (discrete \u03b1) :=\nunique.mk' (discrete \u03b1)\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 \u03b1` to a morphism `X \u27f6 Y`\nin the discrete category. -/\nabbreviation eq_to_hom {X Y : discrete \u03b1} (h : X.as = Y.as) : X \u27f6 Y :=\neq_to_hom (by { ext, exact h, })\n\n/-- Promote an equation between the wrapped terms in `X Y : discrete \u03b1` to an isomorphism `X \u2245 Y`\nin the discrete category. -/\nabbreviation eq_to_iso {X Y : discrete \u03b1} (h : X.as = Y.as) : X \u2245 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 : \u03b1} (h : a = b) : discrete.mk a \u27f6 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 : \u03b1} (h : a = b) : discrete.mk a \u2245 discrete.mk b :=\neq_to_iso h\n\n@[simp] lemma id_def (X : discrete \u03b1) : ulift.up (plift.up (eq.refl X.as)) = \ud835\udfd9 X := rfl\n\nvariables {C : Type u\u2082} [category.{v\u2082} C]\n\ninstance {I : Type u\u2081} {i j : discrete I} (f : i \u27f6 j) : is_iso f :=\n\u27e8\u27e8eq_to_hom (eq_of_hom f).symm, by tidy\u27e9\u27e9\n\n/--\nAny function `I \u2192 C` gives a functor `discrete I \u2964 C`.\n-/\ndef functor {I : Type u\u2081} (F : I \u2192 C) : discrete I \u2964 C :=\n{ obj := F \u2218 discrete.as,\n  map := \u03bb X Y f, by { discrete_cases, cases f, exact \ud835\udfd9 (F X), } }\n\n@[simp] lemma functor_obj  {I : Type u\u2081} (F : I \u2192 C) (i : I) :\n  (discrete.functor F).obj (discrete.mk i) = F i := rfl\n\nlemma functor_map  {I : Type u\u2081} (F : I \u2192 C) {i : discrete I} (f : i \u27f6 i) :\n  (discrete.functor F).map f = \ud835\udfd9 (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\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u27f6 G.obj i) : F \u27f6 G :=\n{ app := f,\n  naturality' := \u03bb 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\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u2245 G.obj i) : F \u2245 G :=\nnat_iso.of_components f (\u03bb X Y g, by { discrete_cases, cases g, simp, })\n\n@[simp]\nlemma nat_iso_app {I : Type u\u2081} {F G : discrete I \u2964 C}\n  (f : \u03a0 i : discrete I, F.obj i \u2245 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\u2081} {F : discrete I \u2964 C} :\n  F \u2245 discrete.functor (F.obj \u2218 discrete.mk) :=\nnat_iso $ \u03bb 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\u2081} {D : Type u\u2083} [category.{v\u2083} D]\n (F : I \u2192 C) (G : C \u2964 D) : discrete.functor F \u22d9 G \u2245 discrete.functor (G.obj \u2218 F) :=\nnat_iso $ \u03bb 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\u2081} {J : Type u\u2082} (e : I \u2243 J) : discrete I \u224c discrete J :=\n{ functor := discrete.functor (discrete.mk \u2218 (e : I \u2192 J)),\n  inverse := discrete.functor (discrete.mk \u2218 (e.symm : J \u2192 I)),\n  unit_iso := discrete.nat_iso (\u03bb i, eq_to_iso (by { discrete_cases, simp })),\n  counit_iso := discrete.nat_iso (\u03bb 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 {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (h : discrete \u03b1 \u224c discrete \u03b2) : \u03b1 \u2243 \u03b2 :=\n{ to_fun := discrete.as \u2218 h.functor.obj \u2218 discrete.mk,\n  inv_fun := discrete.as \u2218 h.inverse.obj \u2218 discrete.mk,\n  left_inv := \u03bb a, by simpa using eq_of_hom (h.unit_iso.app (discrete.mk a)).2,\n  right_inv := \u03bb 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\u2081}\n\nopen opposite\n\n/-- A discrete category is equivalent to its opposite category. -/\n@[simps functor_obj_as inverse_obj]\nprotected def opposite (\u03b1 : Type u\u2081) : (discrete \u03b1)\u1d52\u1d56 \u224c discrete \u03b1 :=\nlet F : discrete \u03b1 \u2964 (discrete \u03b1)\u1d52\u1d56 := discrete.functor (\u03bb x, op (discrete.mk x)) in\nbegin\n  refine equivalence.mk (functor.left_op F) F _\n    (discrete.nat_iso $ \u03bb X, by { discrete_cases, simp [F] }),\n  refine nat_iso.of_components (\u03bb X, by { tactic.op_induction', discrete_cases, simp [F], }) _,\n  tidy\nend\n\nvariables {C : Type u\u2082} [category.{v\u2082} C]\n\n@[simp] lemma functor_map_id\n  (F : discrete J \u2964 C) {j : discrete J} (f : j \u27f6 j) : F.map f = \ud835\udfd9 (F.obj j) :=\nbegin\n  have h : f = \ud835\udfd9 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\u00e9d\u00e9ric 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 `\ud835\udd5c` with `[is_R_or_C \ud835\udd5c]`, this map is an isometry.\n\nWe then consider inner product spaces, with base field over `\u211d` (the corresponding results for `\u2102`\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 `\u03bb y, \u27eax, y\u27eb`. 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 `\ud835\udd5c`\nwith `[is_R_or_C \ud835\udd5c]`; 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\u00e9chet-Riesz\nrepresentation (`to_dual_map_eq_top`), which states the surjectivity: every element of the dual\nof a Hilbert space `E` has the form `\u03bb u, \u27eax, u\u27eb` 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\u00e9chet-Riesz\n-/\n\nnamespace normed_space\n\n\n/-- The topological dual of a normed space `E`. -/\ndef dual (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] (E : Type u_2) [normed_group E] [normed_space \ud835\udd5c E] :=\n  continuous_linear_map \ud835\udd5c E \ud835\udd5c\n\nprotected instance dual.inhabited (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] (E : Type u_2) [normed_group E] [normed_space \ud835\udd5c E] : Inhabited (dual \ud835\udd5c E) :=\n  { default := 0 }\n\n/-- The inclusion of a normed space in its double (topological) dual. -/\ndef inclusion_in_double_dual' (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] (E : Type u_2) [normed_group E] [normed_space \ud835\udd5c E] (x : E) : dual \ud835\udd5c (dual \ud835\udd5c E) :=\n  linear_map.mk_continuous (linear_map.mk (fun (f : dual \ud835\udd5c E) => coe_fn f x) sorry sorry) (norm x) sorry\n\n@[simp] theorem dual_def (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] (E : Type u_2) [normed_group E] [normed_space \ud835\udd5c E] (x : E) (f : dual \ud835\udd5c E) : coe_fn (inclusion_in_double_dual' \ud835\udd5c E x) f = coe_fn f x :=\n  rfl\n\ntheorem double_dual_bound (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] (E : Type u_2) [normed_group E] [normed_space \ud835\udd5c E] (x : E) : norm (inclusion_in_double_dual' \ud835\udd5c E x) \u2264 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 (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] (E : Type u_2) [normed_group E] [normed_space \ud835\udd5c E] : continuous_linear_map \ud835\udd5c E (dual \ud835\udd5c (dual \ud835\udd5c E)) :=\n  linear_map.mk_continuous (linear_map.mk (fun (x : E) => inclusion_in_double_dual' \ud835\udd5c 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 {\ud835\udd5c : Type v} [is_R_or_C \ud835\udd5c] {E : Type u} [normed_group E] [normed_space \ud835\udd5c E] (x : E) {M : \u211d} (hMp : 0 \u2264 M) (hM : \u2200 (f : dual \ud835\udd5c E), norm (coe_fn f x) \u2264 M * norm f) : norm x \u2264 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 {\ud835\udd5c : Type v} [is_R_or_C \ud835\udd5c] {E : Type u} [normed_group E] [normed_space \ud835\udd5c E] (x : E) : norm (coe_fn (inclusion_in_double_dual \ud835\udd5c 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`\u03bb y, \u27eax, y\u27eb`. Consider using `to_dual` or `to_dual_map` instead in the real case.\n-/\ndef to_dual' (\ud835\udd5c : Type u_1) {E : Type u_2} [is_R_or_C \ud835\udd5c] [inner_product_space \ud835\udd5c E] : E \u2192+ normed_space.dual \ud835\udd5c 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 (\ud835\udd5c : Type u_1) {E : Type u_2} [is_R_or_C \ud835\udd5c] [inner_product_space \ud835\udd5c E] {x : E} {y : E} : coe_fn (coe_fn (to_dual' \ud835\udd5c) x) y = inner x y :=\n  rfl\n\n/-- In an inner product space, the norm of the dual of a vector `x` is `\u2225x\u2225` -/\n@[simp] theorem norm_to_dual'_apply (\ud835\udd5c : Type u_1) {E : Type u_2} [is_R_or_C \ud835\udd5c] [inner_product_space \ud835\udd5c E] (x : E) : norm (coe_fn (to_dual' \ud835\udd5c) x) = norm x := sorry\n\ntheorem to_dual'_isometry (\ud835\udd5c : Type u_1) (E : Type u_2) [is_R_or_C \ud835\udd5c] [inner_product_space \ud835\udd5c E] : isometry \u21d1(to_dual' \ud835\udd5c) :=\n  add_monoid_hom.isometry_of_norm (to_dual' \ud835\udd5c) (norm_to_dual'_apply \ud835\udd5c)\n\n/--\nFr\u00e9chet-Riesz representation: any `\u2113` in the dual of a Hilbert space `E` is of the form\n`\u03bb u, \u27eay, u\u27eb` for some `y : E`, i.e. `to_dual'` is surjective.\n-/\ntheorem to_dual'_surjective (\ud835\udd5c : Type u_1) (E : Type u_2) [is_R_or_C \ud835\udd5c] [inner_product_space \ud835\udd5c E] [complete_space E] : function.surjective \u21d1(to_dual' \ud835\udd5c) := sorry\n\n/-- In a real inner product space `F`, the function that takes a vector `x` in `F` to its dual\n`\u03bb y, \u27eax, y\u27eb` 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 \u211d F] : continuous_linear_map \u211d F (normed_space.dual \u211d F) :=\n  linear_map.mk_continuous (linear_map.mk \u21d1(to_dual' \u211d) sorry sorry) 1 sorry\n\n@[simp] theorem to_dual_map_apply {F : Type u_1} [inner_product_space \u211d 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 `\u2225x\u2225` -/\n@[simp] theorem norm_to_dual_map_apply {F : Type u_1} [inner_product_space \u211d F] (x : F) : norm (coe_fn to_dual_map x) = norm x :=\n  norm_to_dual'_apply \u211d x\n\ntheorem to_dual_map_isometry {F : Type u_1} [inner_product_space \u211d F] : isometry \u21d1to_dual_map :=\n  add_monoid_hom.isometry_of_norm (to_dual' \u211d) norm_to_dual_map_apply\n\ntheorem to_dual_map_injective {F : Type u_1} [inner_product_space \u211d F] : function.injective \u21d1to_dual_map :=\n  isometry.injective to_dual_map_isometry\n\n@[simp] theorem ker_to_dual_map {F : Type u_1} [inner_product_space \u211d F] : continuous_linear_map.ker to_dual_map = \u22a5 :=\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 \u211d F] {x : F} {y : F} : coe_fn to_dual_map x = coe_fn to_dual_map y \u2194 x = y :=\n  function.injective.eq_iff (iff.mp linear_map.ker_eq_bot ker_to_dual_map)\n\n/--\nFr\u00e9chet-Riesz representation: any `\u2113` in the dual of a real Hilbert space `F` is of the form\n`\u03bb u, \u27eay, u\u27eb` 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 \u211d F] [complete_space F] : continuous_linear_map.range to_dual_map = \u22a4 :=\n  iff.mpr linear_map.range_eq_top (to_dual'_surjective \u211d F)\n\n/--\nFr\u00e9chet-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 \u211d F] [complete_space F] : continuous_linear_equiv \u211d F (normed_space.dual \u211d 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\u00e9chet-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 \u211d F] [complete_space F] : F \u2243\u1d62 normed_space.dual \u211d F :=\n  isometric.mk (linear_equiv.to_equiv (continuous_linear_equiv.to_linear_equiv to_dual)) (to_dual'_isometry \u211d F)\n\n@[simp] theorem to_dual_apply {F : Type u_1} [inner_product_space \u211d 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 \u211d F] [complete_space F] {x : F} {y : F} : coe_fn to_dual x = coe_fn to_dual y \u2194 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 \u211d F] [complete_space F] {x : F} {x' : F} : (\u2200 (y : F), inner x y = inner x' y) \u2194 x = x' := sorry\n\n@[simp] theorem norm_to_dual_apply {F : Type u_1} [inner_product_space \u211d 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 \u211d F] [complete_space F] (\u2113 : normed_space.dual \u211d F) : norm (coe_fn (continuous_linear_equiv.symm to_dual) \u2113) = norm \u2113 := 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 : \u2115) : \u2115 := Id.run do\n  let mut r := 0\n  for _ in [: n] do\n    r \u2190 r + 1\n  return r\n\ndef incStep : \u2115 \u2192 \u2115 \u2192 Id (ForInStep \u2115) := \u03bb _ r => ForInStep.yield (r + 1)\n\nvariable {m : Type u \u2192 Type v} [Monad m]\n\n-- loop f start stop 1 init (Nat.zero_lt_one) = init\ntheorem singleIncStep {k : \u2115} : 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 `\u2115 \u2192 \u03b2 \u2192 Id (ForInStep \u03b2)` (I do not know how to do this)\ntheorem succInvariantLt {k : \u2115} {init : \u03b2} {f : \u2115 \u2192 \u03b2 \u2192 Id (ForInStep \u03b2)} (start stop skip : \u2115)\n  (hf : \u2200 i j : \u2115, f i = f j) (hs : start \u2264 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 = \u03bb _ 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 : \u2115} {init : \u03b2} {f : \u2115 \u2192 \u03b2 \u2192 Id (ForInStep \u03b2)} (start stop skip : \u2115)\n  (hf : \u2200 i j : \u2115, 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 : \u2200 (i r : \u2115), 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 : \u2115} (init : \u2115) :\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 \u2192 n = k + 1\n  simp [Id.run] at *\n  rw [rangeDecompose _ k.succ k.succ.succ _ incStepAlwaysYield, Id.run, \u2190 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, \u2190 succInvariant] at *\n  simp [Id.run, incStep, mkRange', Range.forIn] at h\n  conv_rhs => rw [\u2190 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 : \u2115) : \u2115 := 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 \u2190 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 \u2190 r + i\n      let r : \u2115 := 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 \u2190 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 \u2190 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 \u27f6 B` and `g : B \u27f6 C` satisfy `w : f \u226b g = 0`,\nwe have `image_le_kernel f g w : image_subobject f \u2264 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 {\u03b9 : 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 \u27f6 B) [has_image f] (g : B \u27f6 C) [has_kernel g]\n\nlemma image_le_kernel (w : f \u226b g = 0) :\n  image_subobject f \u2264 kernel_subobject g :=\nimage_subobject_le_mk _ _ (kernel.lift _ _ w) (by simp)\n\n/--\nThe canonical morphism `image_subobject f \u27f6 kernel_subobject g` when `f \u226b g = 0`.\n-/\n@[derive mono]\ndef image_to_kernel (w : f \u226b g = 0) :\n  (image_subobject f : V) \u27f6 (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 \u226b 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 \u226b g = 0) :\n  image_to_kernel f g w \u226b (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 \u226b g = 0) :\n  factor_thru_image_subobject f \u226b 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 \u27f6 B) (g : B \u27f6 C)\n\n@[simp]\nlemma image_to_kernel_zero_left [has_kernels V] [has_zero_object V] {w} :\n  image_to_kernel (0 : A \u27f6 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 \u27f6 C) w =\n    (image_subobject f).arrow \u226b inv (kernel_subobject (0 : B \u27f6 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 \u27f6 D) (w : f \u226b g = 0) :\n  image_to_kernel f (g \u226b h) (by simp [reassoc_of w]) =\n    image_to_kernel f g w \u226b subobject.of_le _ _ (kernel_subobject_comp_le g h) :=\nby { ext, simp }\n\nlemma image_to_kernel_comp_left {Z : V} (h : Z \u27f6 A) (w : f \u226b g = 0) :\n  image_to_kernel (h \u226b f) g (by simp [w]) =\n    subobject.of_le _ _ (image_subobject_comp_le h f) \u226b image_to_kernel f g w :=\nby { ext, simp }\n\n@[simp]\nlemma image_to_kernel_comp_mono {D : V} (h : C \u27f6 D) [mono h] (w) :\n  image_to_kernel f (g \u226b h) w =\n  image_to_kernel f g ((cancel_mono h).mp (by simpa using w : (f \u226b g) \u226b h = 0 \u226b h)) \u226b\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 \u27f6 A) [epi h] (w) :\n  image_to_kernel (h \u226b f) g w =\n  subobject.of_le _ _ (image_subobject_comp_le h f) \u226b\n    image_to_kernel f g ((cancel_epi h).mp (by simpa using w : h \u226b f \u226b g = h \u226b 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 \u2245 Z} (w) :\n  image_to_kernel (f \u226b i.hom) (i.inv \u226b g) w =\n  (image_subobject_comp_iso _ _).hom \u226b image_to_kernel f g (by simpa using w) \u226b\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 \u27f6 B) g (by simp)) :=\nepi_of_target_iso_zero _ (kernel_subobject_iso g \u226a\u226b 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 \u27f6 C) (by simp)) :=\nbegin\n  simp only [image_to_kernel_zero_right],\n  haveI := epi_image_of_epi f,\n  rw \u2190image_subobject_arrow,\n  refine @epi_comp _ _ _ _ _ _ (epi_comp _ _) _ _,\nend\n\nend\n\nsection\nvariables {A B C : V} (f : A \u27f6 B) [has_image f] (g : B \u27f6 C) [has_kernel g]\n\n/--\nThe homology of a pair of morphisms `f : A \u27f6 B` and `g : B \u27f6 C` satisfying `f \u226b g = 0`\nis the cokernel of the `image_to_kernel` morphism for `f` and `g`.\n-/\ndef homology {A B C : V} (f : A \u27f6 B) [has_image f] (g : B \u27f6 C) [has_kernel g]\n  (w : f \u226b g = 0) [has_cokernel (image_to_kernel f g w)] : V :=\ncokernel (image_to_kernel f g w)\n\nsection\nvariables (w : f \u226b g = 0) [has_cokernel (image_to_kernel f g w)]\n\n/-- The morphism from cycles to homology. -/\ndef homology.\u03c0 : (kernel_subobject g : V) \u27f6 homology f g w :=\ncokernel.\u03c0 _\n\n@[simp] lemma homology.condition : image_to_kernel f g w \u226b homology.\u03c0 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) \u27f6 D) (p : image_to_kernel f g w \u226b k = 0) :\n  homology f g w \u27f6 D :=\ncokernel.desc _ k p\n\n@[simp, reassoc]\nlemma homology.\u03c0_desc\n  {D : V} (k : (kernel_subobject g : V) \u27f6 D) (p : image_to_kernel f g w \u226b k = 0) :\n  homology.\u03c0 f g w \u226b homology.desc f g w k p = k :=\nby { simp [homology.\u03c0, 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 \u27f6 D}\n  (p : homology.\u03c0 f g w \u226b k = homology.\u03c0 f g w \u226b 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 \u27f6 B)] [has_cokernel (image_to_kernel (0 : A \u27f6 B) (0 : B \u27f6 C) (by simp))] :\n  homology (0 : A \u27f6 B) (0 : B \u27f6 C) (by simp) \u2245 B :=\n{ hom := homology.desc (0 : A \u27f6 B) (0 : B \u27f6 C) (by simp) (kernel_subobject 0).arrow (by simp),\n  inv := inv (kernel_subobject 0).arrow \u226b homology.\u03c0 _ _ _, }\n\nend\n\nsection\nvariables {f g} (w : f \u226b g = 0)\n  {A' B' C' : V} {f' : A' \u27f6 B'} [has_image f'] {g' : B' \u27f6 C'} [has_kernel g'] (w' : f' \u226b g' = 0)\n  (\u03b1 : arrow.mk f \u27f6 arrow.mk f') [has_image_map \u03b1] (\u03b2 : arrow.mk g \u27f6 arrow.mk g')\n  {A\u2081 B\u2081 C\u2081 : V} {f\u2081 : A\u2081 \u27f6 B\u2081} [has_image f\u2081] {g\u2081 : B\u2081 \u27f6 C\u2081} [has_kernel g\u2081] (w\u2081 : f\u2081 \u226b g\u2081 = 0)\n  {A\u2082 B\u2082 C\u2082 : V} {f\u2082 : A\u2082 \u27f6 B\u2082} [has_image f\u2082] {g\u2082 : B\u2082 \u27f6 C\u2082} [has_kernel g\u2082] (w\u2082 : f\u2082 \u226b g\u2082 = 0)\n  {A\u2083 B\u2083 C\u2083 : V} {f\u2083 : A\u2083 \u27f6 B\u2083} [has_image f\u2083] {g\u2083 : B\u2083 \u27f6 C\u2083} [has_kernel g\u2083] (w\u2083 : f\u2083 \u226b g\u2083 = 0)\n  (\u03b1\u2081 : arrow.mk f\u2081 \u27f6 arrow.mk f\u2082) [has_image_map \u03b1\u2081] (\u03b2\u2081 : arrow.mk g\u2081 \u27f6 arrow.mk g\u2082)\n  (\u03b1\u2082 : arrow.mk f\u2082 \u27f6 arrow.mk f\u2083) [has_image_map \u03b1\u2082] (\u03b2\u2082 : arrow.mk g\u2082 \u27f6 arrow.mk g\u2083)\n\n/--\nGiven compatible commutative squares between\na pair `f g` and a pair `f' g'` satisfying `f \u226b g = 0` and `f' \u226b 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 : \u03b1.right = \u03b2.left) :\n  image_to_kernel f g w \u226b kernel_subobject_map \u03b2 =\n    image_subobject_map \u03b1 \u226b 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\u2081 g\u2081 w\u2081)]\nvariables [has_cokernel (image_to_kernel f\u2082 g\u2082 w\u2082)]\nvariables [has_cokernel (image_to_kernel f\u2083 g\u2083 w\u2083)]\n\n/--\nGiven compatible commutative squares between\na pair `f g` and a pair `f' g'` satisfying `f \u226b g = 0` and `f' \u226b g' = 0`,\nwe get a morphism on homology.\n-/\ndef homology.map (p : \u03b1.right = \u03b2.left) :\n  homology f g w \u27f6 homology f' g' w' :=\ncokernel.desc _ (kernel_subobject_map \u03b2 \u226b cokernel.\u03c0 _)\n  begin\n    rw [image_subobject_map_comp_image_to_kernel_assoc w w' \u03b1 \u03b2 p],\n    simp only [cokernel.condition, comp_zero],\n  end\n\n@[simp, reassoc]\nlemma homology.\u03c0_map (p : \u03b1.right = \u03b2.left) :\n  homology.\u03c0 f g w \u226b homology.map w w' \u03b1 \u03b2 p = kernel_subobject_map \u03b2 \u226b homology.\u03c0 f' g' w' :=\nby simp only [homology.\u03c0, homology.map, cokernel.\u03c0_desc]\n\n@[simp, reassoc]\nlemma homology.map_desc (p : \u03b1.right = \u03b2.left)\n  {D : V} (k : (kernel_subobject g' : V) \u27f6 D) (z : image_to_kernel f' g' w' \u226b k = 0) :\n  homology.map w w' \u03b1 \u03b2 p \u226b homology.desc f' g' w' k z =\n    homology.desc f g w (kernel_subobject_map \u03b2 \u226b k)\n      (by simp only [image_subobject_map_comp_image_to_kernel_assoc w w' \u03b1 \u03b2 p, z, comp_zero]) :=\nby ext; simp only [homology.\u03c0_desc, homology.\u03c0_map_assoc]\n\n@[simp]\nlemma homology.map_id : homology.map w w (\ud835\udfd9 _) (\ud835\udfd9 _) rfl = \ud835\udfd9 _ :=\nby ext; simp only [homology.\u03c0_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\u2081 B\u2081 C\u2081 A\u2082 B\u2082 C\u2082 A\u2083 B\u2083 C\u2083 : V}\n  {f\u2081 : A\u2081 \u27f6 B\u2081} {g\u2081 : B\u2081 \u27f6 C\u2081} {f\u2082 : A\u2082 \u27f6 B\u2082} {g\u2082 : B\u2082 \u27f6 C\u2082} {f\u2083 : A\u2083 \u27f6 B\u2083} {g\u2083 : B\u2083 \u27f6 C\u2083}\n  {\u03b1\u2081 : arrow.mk f\u2081 \u27f6 arrow.mk f\u2082} {\u03b2\u2081 : arrow.mk g\u2081 \u27f6 arrow.mk g\u2082}\n  {\u03b1\u2082 : arrow.mk f\u2082 \u27f6 arrow.mk f\u2083} {\u03b2\u2082 : arrow.mk g\u2082 \u27f6 arrow.mk g\u2083}\n  (p\u2081 : \u03b1\u2081.right = \u03b2\u2081.left) (p\u2082 : \u03b1\u2082.right = \u03b2\u2082.left) :\n  (\u03b1\u2081 \u226b \u03b1\u2082).right = (\u03b2\u2081 \u226b \u03b2\u2082).left :=\nby simp only [comma.comp_left, comma.comp_right, p\u2081, p\u2082]\n\n@[reassoc]\nlemma homology.map_comp (p\u2081 : \u03b1\u2081.right = \u03b2\u2081.left) (p\u2082 : \u03b1\u2082.right = \u03b2\u2082.left) :\n  homology.map w\u2081 w\u2082 \u03b1\u2081 \u03b2\u2081 p\u2081 \u226b homology.map w\u2082 w\u2083 \u03b1\u2082 \u03b2\u2082 p\u2082 =\n    homology.map w\u2081 w\u2083 (\u03b1\u2081 \u226b \u03b1\u2082) (\u03b2\u2081 \u226b \u03b2\u2082) (homology.comp_right_eq_comp_left p\u2081 p\u2082) :=\nby ext; simp only [kernel_subobject_map_comp, homology.\u03c0_map_assoc, homology.\u03c0_map, category.assoc]\n\n/-- An isomorphism between two three-term complexes induces an isomorphism on homology. -/\ndef homology.map_iso (\u03b1 : arrow.mk f\u2081 \u2245 arrow.mk f\u2082) (\u03b2 : arrow.mk g\u2081 \u2245 arrow.mk g\u2082)\n  (p : \u03b1.hom.right = \u03b2.hom.left) :\n  homology f\u2081 g\u2081 w\u2081 \u2245 homology f\u2082 g\u2082 w\u2082 :=\n{ hom := homology.map w\u2081 w\u2082 \u03b1.hom \u03b2.hom p,\n  inv := homology.map w\u2082 w\u2081 \u03b1.inv \u03b2.inv\n  (by { rw [\u2190 cancel_mono (\u03b1.hom.right), \u2190 comma.comp_right, \u03b1.inv_hom_id, comma.id_right, p,\n      \u2190 comma.comp_left, \u03b2.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 \u27f6 B} {g : B \u27f6 C} (w : f \u226b g = 0)\n  {f' : A \u27f6 B} {g' : B \u27f6 C} (w' : f' \u226b 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 \u2245 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 \u2245 homology f' g' w' :=\n{ hom := homology.map w w' \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by aux_tac\u27e9 \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by aux_tac\u27e9 rfl,\n  inv := homology.map w' w \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by aux_tac\u27e9 \u27e8\ud835\udfd9 _, \ud835\udfd9 _, by aux_tac\u27e9 rfl,\n  hom_inv_id' := begin\n    cases pf, cases pg, rw [homology.map_comp, \u2190 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, \u2190 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 \u27f6 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 \u27f6 B) (g : B \u27f6 C) (w : f \u226b 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 \u27f6 kernel_subobject g`\nin terms of the subobject API,\nthis variant provides a morphism\n`image f \u27f6 kernel g`,\nwhich is sometimes more convenient.\n-/\ndef image_to_kernel' (w : f \u226b g = 0) : image f \u27f6 kernel g :=\nkernel.lift g (image.\u03b9 f) (by { ext, simpa using w, })\n\n@[simp] lemma image_subobject_iso_image_to_kernel' (w : f \u226b g = 0) :\n  (image_subobject_iso f).hom \u226b image_to_kernel' f g w =\n    image_to_kernel f g w \u226b (kernel_subobject_iso g).hom :=\nby { ext, simp [image_to_kernel'], }\n\n@[simp] lemma image_to_kernel'_kernel_subobject_iso (w : f \u226b g = 0) :\n  image_to_kernel' f g w \u226b (kernel_subobject_iso g).inv =\n    (image_subobject_iso f).inv \u226b 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 \u226b g = 0) :\n  homology f g w \u2245 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.\u03c0_desc, cokernel.\u03c0_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.\u03c0_desc, category.comp_id,\n    cokernel.\u03c0_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 \u226b g = 0) :\n  homology f g w \u2245 cokernel (kernel.lift g f w) :=\nbegin\n  refine homology_iso_cokernel_image_to_kernel' f g w \u226a\u226b _,\n  have p : factor_thru_image f \u226b image_to_kernel' f g w = kernel.lift g f w,\n  { ext, simp [image_to_kernel'], },\n  exact (cokernel_epi_comp _ _).symm \u226a\u226b 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 \u2192 Type v) [functor f] : Prop :=\n(map_const_eq : \u2200 {\u03b1 \u03b2 : Type u}, ((<$) : \u03b1 \u2192 f \u03b2 \u2192 f \u03b1) = (<$>) \u2218 const \u03b2 . control_laws_tac)\n-- `functor` is indeed a categorical functor\n(id_map       : \u03a0 {\u03b1 : Type u} (x : f \u03b1), id <$> x = x)\n(comp_map     : \u03a0 {\u03b1 \u03b2 \u03b3 : Type u} (g : \u03b1 \u2192 \u03b2) (h : \u03b2 \u2192 \u03b3) (x : f \u03b1), (h \u2218 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 \u2192 Type v) [applicative f] extends is_lawful_functor f : Prop :=\n(seq_left_eq  : \u2200 {\u03b1 \u03b2 : Type u} (a : f \u03b1) (b : f \u03b2), a <* b = const \u03b2 <$> a <*> b . control_laws_tac)\n(seq_right_eq : \u2200 {\u03b1 \u03b2 : Type u} (a : f \u03b1) (b : f \u03b2), a *> b = const \u03b1 id <$> a <*> b . control_laws_tac)\n-- applicative laws\n(pure_seq_eq_map : \u2200 {\u03b1 \u03b2 : Type u} (g : \u03b1 \u2192 \u03b2) (x : f \u03b1), pure g <*> x = g <$> x)\n(map_pure        : \u2200 {\u03b1 \u03b2 : Type u} (g : \u03b1 \u2192 \u03b2) (x : \u03b1), g <$> (pure x : f \u03b1) = pure (g x))\n(seq_pure        : \u2200 {\u03b1 \u03b2 : Type u} (g : f (\u03b1 \u2192 \u03b2)) (x : \u03b1), g <*> pure x = (\u03bb g : \u03b1 \u2192 \u03b2, g x) <$> g)\n(seq_assoc       : \u2200 {\u03b1 \u03b2 \u03b3 : Type u} (x : f \u03b1) (g : f (\u03b1 \u2192 \u03b2)) (h : f (\u03b2 \u2192 \u03b3)), h <*> (g <*> x) = (@comp \u03b1 \u03b2 \u03b3 <$> 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 {\u03b1 : Type u} {f : Type u \u2192 Type v} [applicative f] [is_lawful_applicative f] (x : f \u03b1) : pure id <*> x = x :=\nby simp [pure_seq_eq_map]\n\nclass is_lawful_monad (m : Type u \u2192 Type v) [monad m] extends is_lawful_applicative m : Prop :=\n(bind_pure_comp_eq_map : \u2200 {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) (x : m \u03b1), x >>= pure \u2218 f = f <$> x  . control_laws_tac)\n(bind_map_eq_seq : \u2200 {\u03b1 \u03b2 : Type u} (f : m (\u03b1 \u2192 \u03b2)) (x : m \u03b1), f >>= (<$> x) = f <*> x  . control_laws_tac)\n-- monad laws\n(pure_bind : \u2200 {\u03b1 \u03b2 : Type u} (x : \u03b1) (f : \u03b1 \u2192 m \u03b2), pure x >>= f = f x)\n(bind_assoc : \u2200 {\u03b1 \u03b2 \u03b3 : Type u} (x : m \u03b1) (f : \u03b1 \u2192 m \u03b2) (g : \u03b2 \u2192 m \u03b3),\n  x >>= f >>= g = x >>= \u03bb x, f x >>= g)\n(pure_seq_eq_map := by intros; rw \u2190bind_map_eq_seq; simp [pure_bind])\n(map_pure := by intros; rw \u2190bind_pure_comp_eq_map; simp [pure_bind])\n(seq_pure := by intros; rw \u2190bind_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 {\u03b1 : Type u} {m : Type u \u2192 Type v} [monad m] [is_lawful_monad m] (x : m \u03b1) : x >>= pure = x :=\nshow x >>= pure \u2218 id = x, by rw bind_pure_comp_eq_map; simp [id_map]\n\nlemma bind_ext_congr {\u03b1 \u03b2} {m : Type u \u2192 Type v} [has_bind m] {x : m \u03b1} {f g : \u03b1 \u2192 m \u03b2} :\n  (\u2200 a, f a = g a) \u2192\n  x >>= f = x >>= g :=\n\u03bb h, by simp [show f = g, from funext h]\n\nlemma map_ext_congr {\u03b1 \u03b2} {m : Type u \u2192 Type v} [functor m] {x : m \u03b1} {f g : \u03b1 \u2192 \u03b2} :\n  (\u2200 a, f a = g a) \u2192\n  (f <$> x : m \u03b2) = g <$> x :=\n\u03bb h, by simp [show f = g, from funext h]\n\n-- instances of previously defined monads\n\nnamespace id\nvariables {\u03b1 \u03b2 : Type}\n@[simp] lemma map_eq (x : id \u03b1) (f : \u03b1 \u2192 \u03b2) : f <$> x = f x := rfl\n@[simp] lemma bind_eq (x : id \u03b1) (f : \u03b1 \u2192 id \u03b2) : x >>= f = f x := rfl\n@[simp] lemma pure_eq (a : \u03b1) : (pure a : id \u03b1) = a := rfl\nend id\n\ninstance : is_lawful_monad id :=\nby refine { .. }; intros; refl\n\n\nnamespace state_t\nsection\n  variable  {\u03c3 : Type u}\n  variable  {m : Type u \u2192 Type v}\n  variables {\u03b1 \u03b2 : Type u}\n  variables (x : state_t \u03c3 m \u03b1) (st : \u03c3)\n\n  lemma ext {x x' : state_t \u03c3 m \u03b1} (h : \u2200 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 \u03c3 m \u03b1).run st = pure (a, st) := rfl\n  @[simp] lemma run_bind (f : \u03b1 \u2192 state_t \u03c3 m \u03b2) :\n    (x >>= f).run st = x.run st >>= \u03bb 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 : \u03b1 \u2192 \u03b2) [is_lawful_monad m] :\n    (f <$> x).run st = (\u03bb p : \u03b1 \u00d7 \u03c3, (f (prod.fst p), prod.snd p)) <$> x.run st :=\n  begin\n    rw \u2190 bind_pure_comp_eq_map _ (x.run st),\n    change (x >>= pure \u2218 f).run st = _,\n    simp\n  end\n  @[simp] \n\ninstance (m : Type u \u2192 Type v) [monad m] [is_lawful_monad m] (\u03c3 : Type u) : is_lawful_monad (state_t \u03c3 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 {\u03b1 \u03b2 \u03b5 : Type u} {m : Type u \u2192 Type v} (x : except_t \u03b5 m \u03b1)\n\n  lemma ext {x x' : except_t \u03b5 m \u03b1} (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 \u03b5 m \u03b1).run = pure (@except.ok \u03b5 \u03b1 a) := rfl\n  @[simp] lemma run_bind (f : \u03b1 \u2192 except_t \u03b5 m \u03b2) : (x >>= f).run = x.run >>= except_t.bind_cont f :=\n  rfl\n  @[simp] lemma run_map (f : \u03b1 \u2192 \u03b2) [is_lawful_monad m] : (f <$> x).run = except.map f <$> x.run :=\n  begin\n    rw \u2190 bind_pure_comp_eq_map _ x.run,\n    change x.run >>= except_t.bind_cont (pure \u2218 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 \u03b1) :\n    (monad_lift x : except_t \u03b5 m \u03b1).run = except.ok <$> (monad_lift x : m \u03b1) := rfl\n  @[simp] lemma run_monad_map {m' n n'} [monad m'] [monad_functor_t n n' m m'] (f : \u2200 {\u03b1}, n \u03b1 \u2192 n' \u03b1) :\n    (monad_map @f x : except_t \u03b5 m' \u03b1).run = monad_map @f x.run := rfl\nend except_t\n\ninstance (m : Type u \u2192 Type v) [monad m] [is_lawful_monad m] (\u03b5 : Type u) : is_lawful_monad (except_t \u03b5 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  {\u03c1 : Type u}\n  variable  {m : Type u \u2192 Type v}\n  variables {\u03b1 \u03b2 : Type u}\n  variables (x : reader_t \u03c1 m \u03b1) (r : \u03c1)\n\n  lemma ext {x x' : reader_t \u03c1 m \u03b1} (h : \u2200 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 \u03c1 m \u03b1).run r = pure a := rfl\n  @[simp] lemma run_bind (f : \u03b1 \u2192 reader_t \u03c1 m \u03b2) :\n    (x >>= f).run r = x.run r >>= \u03bb a, (f a).run r := rfl\n  @[simp] lemma run_map (f : \u03b1 \u2192 \u03b2) [is_lawful_monad m] : (f <$> x).run r = f <$> x.run r :=\n  by rw \u2190 bind_pure_comp_eq_map _ (x.run r); refl\n  @[simp] lemma run_monad_lift {n} [has_monad_lift_t n m] (x : n \u03b1) :\n    (monad_lift x : reader_t \u03c1 m \u03b1).run r = (monad_lift x : m \u03b1) := rfl\n  @[simp] lemma run_monad_map {m' n n'} [monad m'] [monad_functor_t n n' m m'] (f : \u2200 {\u03b1}, n \u03b1 \u2192 n' \u03b1) :\n    (monad_map @f x : reader_t \u03c1 m' \u03b1).run r = monad_map @f (x.run r) := rfl\n  @[simp] lemma run_read : (reader_t.read : reader_t \u03c1 m \u03c1).run r = pure r := rfl\nend\nend reader_t\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [monad m] [is_lawful_monad m] : is_lawful_monad (reader_t \u03c1 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 {\u03b1 \u03b2 : Type u} {m : Type u \u2192 Type v} (x : option_t m \u03b1)\n\n  lemma ext {x x' : option_t m \u03b1} (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 \u03b1).run = pure (some a) := rfl\n  @[simp] lemma run_bind (f : \u03b1 \u2192 option_t m \u03b2) : (x >>= f).run = x.run >>= option_t.bind_cont f :=\n  rfl\n  @[simp] lemma run_map (f : \u03b1 \u2192 \u03b2) [is_lawful_monad m] : (f <$> x).run = option.map f <$> x.run :=\n  begin\n    rw \u2190 bind_pure_comp_eq_map _ x.run,\n    change x.run >>= option_t.bind_cont (pure \u2218 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 \u03b1) :\n    (monad_lift x : option_t m \u03b1).run = some <$> (monad_lift x : m \u03b1) := rfl\n  @[simp] lemma run_monad_map {m' n n'} [monad m'] [monad_functor_t n n' m m'] (f : \u2200 {\u03b1}, n \u03b1 \u2192 n' \u03b1) :\n    (monad_map @f x : option_t m' \u03b1).run = monad_map @f x.run := rfl\nend option_t\n\ninstance (m : Type u \u2192 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 \u03b9\nnoncomputable def has_mul_of_table {\u03b9 R S : Type*} [fintype \u03b9] [semiring R]\n  [hS : add_comm_monoid S] [module R S] (b : basis \u03b9 R S) (table : \u03b9 \u2192 \u03b9 \u2192 \u03b9 \u2192 R) :\n    has_mul S :=\n{ mul := \u03bb x y, b.equiv_fun.symm (\u03bb k, \u2211 i j, b.repr x i * b.repr y j * table i j k) }\n\nlemma mul_def' {\u03b9 R S : Type*} [fintype \u03b9] [semiring R]\n  [hS : add_comm_monoid S] [module R S] (b : basis \u03b9 R S) (table : \u03b9 \u2192 \u03b9 \u2192 \u03b9 \u2192 R)\n  (x y : S) (k : \u03b9) :\n  b.repr (by { letI := has_mul_of_table b table; exact x * y }) k = \u2211 i j, b.repr x i * b.repr y j * table i j k :=\nshow b.repr (b.equiv_fun.symm (\u03bb k, \u2211 i j, b.repr x i * b.repr y j * table i j k)) k =\n  \u2211 i j, b.repr x i * b.repr y j * table i j k,\nby simp only [\u2190 b.equiv_fun_apply, b.equiv_fun.apply_symm_apply]\n\nlemma mul_def {\u03b9 R S : Type*} [fintype \u03b9] [semiring R]\n  [hS : add_comm_monoid S] [module R S] (b : basis \u03b9 R S) (table : \u03b9 \u2192 \u03b9 \u2192 \u03b9 \u2192 R)\n  (i j k : \u03b9) :\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 \u03b9,\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 \u03b9\n-- See note [reducible non-instances]\n@[reducible]\nnoncomputable def non_unital_non_assoc_semiring_of_table {\u03b9 R S : Type*} [fintype \u03b9] [semiring R]\n  [hS : add_comm_monoid S] [module R S] (b : basis \u03b9 R S) (table : \u03b9 \u2192 \u03b9 \u2192 \u03b9 \u2192 R) :\n    non_unital_non_assoc_semiring S :=\n{ zero := 0,\n  add := (+),\n  mul := \u03bb x y, b.equiv_fun.symm (\u03bb k, \u2211 i j, b.repr x i * b.repr y j * table i j k),\n  zero_mul := \u03bb x, b.ext_elem (\u03bb k, by { rw mul_def', simp only [_root_.map_zero, finsupp.zero_apply, zero_mul, finset.sum_const_zero] }),\n  mul_zero := \u03bb x, b.ext_elem (\u03bb k, by { rw mul_def', simp only [_root_.map_zero, finsupp.zero_apply, mul_zero, zero_mul, finset.sum_const_zero] }),\n  left_distrib := \u03bb x y z, b.ext_elem (\u03bb k, by { rw mul_def', simp only [_root_.map_add, finsupp.add_apply, mul_add, add_mul, finset.sum_add_distrib, \u2190 b.equiv_fun_apply, b.equiv_fun.apply_symm_apply] }),\n  right_distrib := \u03bb x y z, b.ext_elem (\u03bb k, by { rw mul_def', simp only [_root_.map_add, finsupp.add_apply, mul_add, add_mul, finset.sum_add_distrib, \u2190 b.equiv_fun_apply, b.equiv_fun.apply_symm_apply] }),\n  .. hS }\n\nnamespace sqrt_d\n\nvariables (d : \u211a)\n\ndef table : fin 2 \u2192 fin 2 \u2192 fin 2 \u2192 \u211a :=\n![![![1, 0], ![0, 1]],\n  ![![0, 1], ![d, 0]]]\n\n/-- Alternative definition of `quad_ring \u211a 0 d` -/\ndef sqrt_d (d : \u211a) := fin 2 \u2192 \u211a\n\nsection\n\nlocal attribute [semireducible] sqrt_d\n\nvariables {d}\n\ndef mk (a b : \u211a) : 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 \u211a (fin 2)) (table d)\n\ninstance : module \u211a (sqrt_d d) := pi.module _ _ _\n\nnoncomputable abbreviation basis : basis (fin 2) \u211a (sqrt_d d) := pi.basis_fun \u211a (fin 2)\n\ninstance : smul_comm_class \u211a (sqrt_d d) (sqrt_d d) :=\n\u27e8\u03bb m n a, (basis d).ext_elem (\u03bb 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 })\u27e9\n\ninstance : is_scalar_tower \u211a (sqrt_d d) (sqrt_d d) :=\n\u27e8\u03bb m n a, (basis d).ext_elem (\u03bb 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 })\u27e9\n\nnoncomputable def times_table : times_table (fin 2) \u211a (sqrt_d d) :=\n{ basis := by convert pi.basis_fun \u211a (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 : \u211a) (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 \u2192 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 \u211a 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 (\u03bb k, _),\n  fin_cases k; times_table,\nend\n\n-- 1.3s\nlemma mul_assoc' (x y z : quad_ring \u211a 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 (\u03bb k, _),\n  fin_cases k; times_table,\nend\n\ninstance : has_one (sqrt_d d) := \u27e8![1, 0]\u27e9\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 := \u03bb x, cases x ((sqrt_d.times_table d).ext (\u03bb k, by fin_cases k; times_table)),\n  mul_one := \u03bb x, cases x ((sqrt_d.times_table d).ext (\u03bb 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 \u211a 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 (\u03bb 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 \u211a 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 (\u03bb 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 : \u211a)\n\nnamespace sqrt_2_sqrt_3\n\ninstance : add_comm_group sqrt_2_sqrt_3 :=\n{ zero := \u27e80, 0, 0, 0\u27e9,\n  add := \u03bb x y, \u27e8x.a + y.a, x.b + y.b, x.c + y.c, x.d + y.d\u27e9,\n  add_comm := \u03bb x y, by { ext : 1; apply add_comm },\n  add_zero := \u03bb x, by { ext : 1; apply add_zero },\n  zero_add := \u03bb x, by { ext : 1; apply zero_add },\n  add_assoc := \u03bb x y z, by { ext : 1; apply add_assoc },\n  neg := \u03bb x, \u27e8-x.a, -x.b, -x.c, -x.d\u27e9,\n  add_left_neg := \u03bb x, by { ext : 1; apply add_left_neg },\n  sub := \u03bb x y, \u27e8x.a - y.a, x.b - y.b, x.c - y.c, x.d - y.d\u27e9 }\n\n.\n\ninstance : module \u211a sqrt_2_sqrt_3 :=\n{ smul := \u03bb c x, \u27e8c * x.a, c * x.b, c * x.c, c * x.d\u27e9,\n  add_smul := \u03bb c d x, by { ext : 1; apply add_mul },\n  smul_add := \u03bb c x y, by { ext : 1; apply mul_add },\n  mul_smul := \u03bb c d x, by { ext : 1; apply mul_assoc },\n  one_smul := \u03bb x, by { ext : 1; apply one_mul },\n  smul_zero := \u03bb c, by { ext : 1; apply mul_zero },\n  zero_smul := \u03bb x, by { ext : 1; apply zero_mul } }\n\nnoncomputable def basis : basis (fin 4) \u211a sqrt_2_sqrt_3 :=\nbasis.of_equiv_fun $\n{ to_fun := \u03bb x, ![x.a, x.b, x.c, x.d],\n  inv_fun := \u03bb x, \u27e8x 0, x 1, x 2, x 3\u27e9,\n  left_inv := \u03bb \u27e8a, b, c, d\u27e9, rfl,\n  right_inv := \u03bb x, by { ext i : 1, fin_cases i; simp },\n  map_add' := \u03bb \u27e8a, b, c, d\u27e9 \u27e8a', b', c', d'\u27e9, by { ext i : 1, fin_cases i; refl },\n  map_smul' := \u03bb r \u27e8a, b, c, d\u27e9, by { ext i : 1, fin_cases i; refl } }\n\ndef table : fin 4 \u2192 fin 4 \u2192 fin 4 \u2192 \u211a :=\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 \u2192\u2097[\u211a] sqrt_2_sqrt_3 \u2192\u2097[\u211a] sqrt_2_sqrt_3 :=\nsqrt_2_sqrt_3.basis.constr \u211a $ \u03bb i,\nsqrt_2_sqrt_3.basis.constr \u211a $ \u03bb j,\nsqrt_2_sqrt_3.basis.equiv_fun.symm (table i j)\n\nnoncomputable instance : has_mul sqrt_2_sqrt_3 :=\n{ mul := \u03bb x y, mul x y }\n\ninstance : has_one sqrt_2_sqrt_3 :=\n\u27e8\u27e81, 0, 0, 0\u27e9\u27e9\n\n@[simp] lemma sqrt_2_sqrt_3.basis_repr (x : sqrt_2_sqrt_3) :\n  \u21d1(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) \u211a 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 : \u211a) (i : fin 4) :\n  sqrt_2_sqrt_3.times_table.coord \u27e8a, b, c, d\u27e9 i = ![a, b, c, d] i := rfl\n\ndef sqrt_2 : sqrt_2_sqrt_3 := \u27e80, 1, 0, 0\u27e9\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 := \u27e80, 0, 1, 0\u27e9\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 {\u03b1 M : Type*} [add_monoid M] (f : \u03b1 \u2192\u2080 M) (i : \u03b1) : (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 (\u03bb 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 (\u03bb 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 (\u03bb 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 (\u03bb 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 := \u03bb x, by { cases x, apply sqrt_2_sqrt_3.times_table.ext (\u03bb k, _), fin_cases k; times_table },\n  mul_one := \u03bb x, by { cases x, apply sqrt_2_sqrt_3.times_table.ext (\u03bb 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\u2081 : (sqrt_2 + sqrt_3)^3 - 9 * (sqrt_2 + sqrt_3) = 2 * sqrt_2 :=\nbegin\n  apply sqrt_2_sqrt_3.times_table.ext (\u03bb k, _),\n  fin_cases k; times_table,\nend\n\nlemma eq\u2082 (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 (\u03bb k, _),\n  fin_cases k; times_table\nend\n\n@[times_table_simps] lemma coord_coe_int {a : \u2124} (k : fin 4) :\n  sqrt_2_sqrt_3.times_table.coord \u2191a 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 (\u03bb k, _),\n  fin_cases k; times_table,\nend\n\n-- More equations to solve\nexample (a b : \u2124) : (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 (\u03bb k, _),\n  fin_cases k; times_table,\nend\n\n-- More equations to solve\nexample (a b c d : \u2124) :\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 (\u03bb 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 \u2194 q) \u2192 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 (\u03b1 : Type u) (a b : \u03b1) (p : \u03b1 \u2192 Prop) (h1 : a = b) (h2 : p a) : p b :=\n  eq.subst h1 h2\n\nexample (\u03b1 : Type u) (a b : \u03b1) (p : \u03b1 \u2192 Prop) (h1 : a = b) (h2 : p a) : p b :=\n  h1 \u25b8 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\u00f4pital'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 `\ud835\udcdd a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `\u211d`.\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' \u2260 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 : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at f (f' x) x) (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at g (g' x) x) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\ntheorem lhopital_zero_right_on_Ico {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at f (f' x) x) (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at g (g' x) x) (hcf : continuous_on f (set.Ico a b)) (hcg : continuous_on g (set.Ico a b)) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 g' x \u2260 0) (hfa : f a = 0) (hga : g a = 0) (hdiv : filter.tendsto (fun (x : \u211d) => f' x / g' x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\ntheorem lhopital_zero_left_on_Ioo {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at f (f' x) x) (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at g (g' x) x) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within b (set.Iio b)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within b (set.Iio b)) l := sorry\n\ntheorem lhopital_zero_left_on_Ioc {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at f (f' x) x) (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 has_deriv_at g (g' x) x) (hcf : continuous_on f (set.Ioc a b)) (hcg : continuous_on g (set.Ioc a b)) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 g' x \u2260 0) (hfb : f b = 0) (hgb : g b = 0) (hdiv : filter.tendsto (fun (x : \u211d) => f' x / g' x) (nhds_within b (set.Iio b)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within b (set.Iio b)) l := sorry\n\ntheorem lhopital_zero_at_top_on_Ioi {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : \u2200 (x : \u211d), x \u2208 set.Ioi a \u2192 has_deriv_at f (f' x) x) (hgg' : \u2200 (x : \u211d), x \u2208 set.Ioi a \u2192 has_deriv_at g (g' x) x) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioi a \u2192 g' x \u2260 0) (hftop : filter.tendsto f filter.at_top (nhds 0)) (hgtop : filter.tendsto g filter.at_top (nhds 0)) (hdiv : filter.tendsto (fun (x : \u211d) => f' x / g' x) filter.at_top l) : filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_top l := sorry\n\ntheorem lhopital_zero_at_bot_on_Iio {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : \u2200 (x : \u211d), x \u2208 set.Iio a \u2192 has_deriv_at f (f' x) x) (hgg' : \u2200 (x : \u211d), x \u2208 set.Iio a \u2192 has_deriv_at g (g' x) x) (hg' : \u2200 (x : \u211d), x \u2208 set.Iio a \u2192 g' x \u2260 0) (hfbot : filter.tendsto f filter.at_bot (nhds 0)) (hgbot : filter.tendsto g filter.at_bot (nhds 0)) (hdiv : filter.tendsto (fun (x : \u211d) => f' x / g' x) filter.at_bot l) : filter.tendsto (fun (x : \u211d) => 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 : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : differentiable_on \u211d f (set.Ioo a b)) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\ntheorem lhopital_zero_right_on_Ico {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : differentiable_on \u211d f (set.Ioo a b)) (hcf : continuous_on f (set.Ico a b)) (hcg : continuous_on g (set.Ico a b)) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 deriv g x \u2260 0) (hfa : f a = 0) (hga : g a = 0) (hdiv : filter.tendsto (fun (x : \u211d) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\ntheorem lhopital_zero_left_on_Ioo {a : \u211d} {b : \u211d} (hab : a < b) {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : differentiable_on \u211d f (set.Ioo a b)) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioo a b \u2192 deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within b (set.Iio b)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within b (set.Iio b)) l := sorry\n\ntheorem lhopital_zero_at_top_on_Ioi {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : differentiable_on \u211d f (set.Ioi a)) (hg' : \u2200 (x : \u211d), x \u2208 set.Ioi a \u2192 deriv g x \u2260 0) (hftop : filter.tendsto f filter.at_top (nhds 0)) (hgtop : filter.tendsto g filter.at_top (nhds 0)) (hdiv : filter.tendsto (fun (x : \u211d) => deriv f x / deriv g x) filter.at_top l) : filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_top l := sorry\n\ntheorem lhopital_zero_at_bot_on_Iio {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : differentiable_on \u211d f (set.Iio a)) (hg' : \u2200 (x : \u211d), x \u2208 set.Iio a \u2192 deriv g x \u2260 0) (hfbot : filter.tendsto f filter.at_bot (nhds 0)) (hgbot : filter.tendsto g filter.at_bot (nhds 0)) (hdiv : filter.tendsto (fun (x : \u211d) => deriv f x / deriv g x) filter.at_bot l) : filter.tendsto (fun (x : \u211d) => 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\u00f4pital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) (nhds_within a (set.Ioi a))) (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) (nhds_within a (set.Ioi a))) (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\n/-- L'H\u00f4pital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) (nhds_within a (set.Iio a))) (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) (nhds_within a (set.Iio a))) (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within a (set.Iio a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Iio a)) l := sorry\n\n/-- L'H\u00f4pital'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 : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) (nhds_within a (set.univ \\ singleton a))) (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) (nhds_within a (set.univ \\ singleton a))) (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) (nhds_within a (set.univ \\ singleton a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l := sorry\n\n/-- L'H\u00f4pital's rule for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) (nhds a)) (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) (nhds a)) (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 0) (nhds a)) (hfa : filter.tendsto f (nhds a) (nhds 0)) (hga : filter.tendsto g (nhds a) (nhds 0)) (hdiv : filter.tendsto (fun (x : \u211d) => f' x / g' x) (nhds a) l) : filter.tendsto (fun (x : \u211d) => 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\u00f4pital's rule for approaching +\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) filter.at_top) (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) filter.at_top) (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) filter.at_top l) : filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_top l := sorry\n\n/-- L'H\u00f4pital's rule for approaching -\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot {l : filter \u211d} {f : \u211d \u2192 \u211d} {f' : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} {g' : \u211d \u2192 \u211d} (hff' : filter.eventually (fun (x : \u211d) => has_deriv_at f (f' x) x) filter.at_bot) (hgg' : filter.eventually (fun (x : \u211d) => has_deriv_at g (g' x) x) filter.at_bot) (hg' : filter.eventually (fun (x : \u211d) => g' x \u2260 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 : \u211d) => f' x / g' x) filter.at_bot l) : filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_bot l := sorry\n\nend has_deriv_at\n\n\nnamespace deriv\n\n\n/-- L'H\u00f4pital's rule for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) (nhds_within a (set.Ioi a))) (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within a (set.Ioi a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Ioi a)) l := sorry\n\n/-- L'H\u00f4pital's rule for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) (nhds_within a (set.Iio a))) (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within a (set.Iio a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.Iio a)) l := sorry\n\n/-- L'H\u00f4pital's rule for approaching a real, `deriv` version. This\n  does not require anything about the situation at `a` -/\ntheorem lhopital_zero_nhds' {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) (nhds_within a (set.univ \\ singleton a))) (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) (nhds_within a (set.univ \\ singleton a)) l) : filter.tendsto (fun (x : \u211d) => f x / g x) (nhds_within a (set.univ \\ singleton a)) l := sorry\n\n/-- L'H\u00f4pital's rule for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds {a : \u211d} {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) (nhds a)) (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 0) (nhds a)) (hfa : filter.tendsto f (nhds a) (nhds 0)) (hga : filter.tendsto g (nhds a) (nhds 0)) (hdiv : filter.tendsto (fun (x : \u211d) => deriv f x / deriv g x) (nhds a) l) : filter.tendsto (fun (x : \u211d) => 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\u00f4pital's rule for approaching +\u221e, `deriv` version -/\ntheorem lhopital_zero_at_top {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) filter.at_top) (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) filter.at_top l) : filter.tendsto (fun (x : \u211d) => f x / g x) filter.at_top l := sorry\n\n/-- L'H\u00f4pital's rule for approaching -\u221e, `deriv` version -/\ntheorem lhopital_zero_at_bot {l : filter \u211d} {f : \u211d \u2192 \u211d} {g : \u211d \u2192 \u211d} (hdf : filter.eventually (fun (x : \u211d) => differentiable_at \u211d f x) filter.at_bot) (hg' : filter.eventually (fun (x : \u211d) => deriv g x \u2260 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 : \u211d) => deriv f x / deriv g x) filter.at_bot l) : filter.tendsto (fun (x : \u211d) => 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' {\u03b1 : Type u_1} {\u03b9 : Type u_2} {A : Type u_4} [add_comm_monoid A] {s : finset \u03b1} {f : \u03b1 \u2192 \u03b9 \u2192\u2080 A} (i : \u03b9) : coe_fn (finset.sum s fun (k : \u03b1) => f k) i = finset.sum s fun (k : \u03b1) => coe_fn (f k) i :=\n  Eq.symm (finset.sum_hom s \u21d1(finsupp.apply_add_hom i))\n\ntheorem finsupp.sum_apply' {\u03b9 : Type u_2} {\u03b3 : Type u_3} {A : Type u_4} {B : Type u_5} [add_comm_monoid A] [add_comm_monoid B] (g : \u03b9 \u2192\u2080 A) (k : \u03b9 \u2192 A \u2192 \u03b3 \u2192 B) (x : \u03b3) : finsupp.sum g k x = finsupp.sum g fun (i : \u03b9) (b : A) => k i b x :=\n  finset.sum_apply x (finsupp.support g) fun (a : \u03b9) => k a (coe_fn g a)\n\ntheorem finsupp.sum_sum_index' {\u03b1 : Type u_1} {\u03b9 : Type u_2} {A : Type u_4} {C : Type u_6} [add_comm_monoid A] [add_comm_monoid C] {t : \u03b9 \u2192 A \u2192 C} (h0 : \u2200 (i : \u03b9), t i 0 = 0) (h1 : \u2200 (i : \u03b9) (x y : A), t i (x + y) = t i x + t i y) {s : finset \u03b1} {f : \u03b1 \u2192 \u03b9 \u2192\u2080 A} : finsupp.sum (finset.sum s fun (x : \u03b1) => f x) t = finset.sum s fun (x : \u03b1) => 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\u2081 u\u2082 v\u2081 v\u2082 \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\u2081} [category C] [monoidal_category C] {D : Type u\u2082}\n    [category D] (e : C \u224c D) : \ud835\udfd9_ = functor.obj (equivalence.functor e) \ud835\udfd9_ :=\n  Eq.refl \ud835\udfd9_\n\n/-- A type synonym for `D`, which will carry the transported monoidal structure. -/\ndef transported {C : Type u\u2081} [category C] [monoidal_category C] {D : Type u\u2082} [category D]\n    (e : C \u224c D) :=\n  D\n\nprotected instance transported.category_theory.monoidal_category {C : Type u\u2081} [category C]\n    [monoidal_category C] {D : Type u\u2082} [category D] (e : C \u224c D) :\n    monoidal_category (transported e) :=\n  transport e\n\nprotected instance transported.inhabited {C : Type u\u2081} [category C] [monoidal_category C]\n    {D : Type u\u2082} [category D] (e : C \u224c D) : Inhabited (transported e) :=\n  { default := \ud835\udfd9_ }\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\u2081} [category C] [monoidal_category C]\n    {D : Type u\u2082} [category D] (e : C \u224c D) {X : C} {Y : C} :\n    \u2200 (\u1fb0 : X \u27f6 Y),\n        functor.map (lax_monoidal_functor.to_functor (lax_to_transported e)) \u1fb0 =\n          functor.map (equivalence.functor e) \u1fb0 :=\n  fun (\u1fb0 : X \u27f6 Y) =>\n    Eq.refl (functor.map (lax_monoidal_functor.to_functor (lax_to_transported e)) \u1fb0)\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_\u03b5_is_iso {C : Type u\u2081} [category C] [monoidal_category C]\n    {D : Type u\u2082} [category D] (e : C \u224c D) :\n    monoidal_functor.\u03b5_is_iso (to_transported e) =\n        id (is_iso.id (functor.obj (equivalence.functor e) \ud835\udfd9_)) :=\n  Eq.refl (monoidal_functor.\u03b5_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\u2081} [category C] [monoidal_category C] {D : Type u\u2082} [category D]\n    (e : C \u224c 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) \ud835\udfd9_)\n    fun (X Y : transported e) =>\n      nat_trans.app (equivalence.unit e)\n        (functor.obj (equivalence.inverse e) X \u2297 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\u2081} [category C] [monoidal_category C] {D : Type u\u2082} [category D]\n    (e : C \u224c 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.\u03b5 (lax_from_transported e))\n      (lax_monoidal_functor.\u03bc (lax_from_transported e)))\n\n/-- The unit isomorphism upgrades to a monoidal isomorphism. -/\ndef transported_monoidal_unit_iso {C : Type u\u2081} [category C] [monoidal_category C] {D : Type u\u2082}\n    [category D] (e : C \u224c D) :\n    lax_monoidal_functor.id C \u2245 lax_to_transported e \u2297\u22d9 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\u2081} [category C]\n    [monoidal_category C] {D : Type u\u2082} [category D] (e : C \u224c 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\u00f6ving. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Henrik B\u00f6ving, 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 `\u2200 n : \u2115, prime n \u2192 n \u2264 100`,\n`SlimCheck` requires that `\u2115` 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 \u2115 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\u2264 100` will be tested. If it is false, `n` is a counter-example of `\u2200\nn : \u2115, prime n \u2192 n \u2264 100` and the test fails. If `n \u2264 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 `\u2115 \u2192 \u2115`.\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 : \u03b1`, `Shrinkable \u03b1` 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 : \u03b1`, `Shrinkable \u03b1` gives us a way to shrink it\nand suggest simpler examples. -/\nclass Shrinkable (\u03b1 : Type u) extends WellFoundedRelation \u03b1 where\n  shrink : (x : \u03b1) \u2192 List \u03b1 := \u03bb _ => []\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 `\u2115 \u2192 \u2115`.\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 (\u03b1 : Sort u) where\n  proxy : Type v\n  [proxyRepr : Repr proxy]\n  [shrink : Shrinkable proxy]\n  sample : Gen proxy\n  interp : proxy \u2192 \u03b1\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 \u03b1] [Shrinkable \u03b1] (sample : Gen \u03b1) : SampleableExt \u03b1 where\n  proxy := \u03b1\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 (\u03b1 : Type u) [SampleableExt \u03b1] : Gen \u03b1 := 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 := \u27e8Int.natAbs\u27e9\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 \u03b1] [shrB : Shrinkable \u03b2] : Shrinkable (Prod \u03b1 \u03b2) where\n  shrink := \u03bb (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 (\u2190 getSize))\n\ninstance Fin.sampleableExt {n : Nat} : SampleableExt (Fin (n.succ)) :=\n  mkSelfContained (do choose (Fin n.succ) (Fin.ofNat 0) (Fin.ofNat (\u2190 getSize)))\n\ninstance Int.sampleableExt : SampleableExt Int :=\n  mkSelfContained (do choose Int (-(\u2190 getSize)) (\u2190 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 \u2190  choose Nat 0 length\n      if x == 0 then\n        let n \u2190  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 {\u03b1 \u03b2 : Type u} [SampleableExt \u03b1] [SampleableExt \u03b2] :\n    SampleableExt (\u03b1 \u00d7 \u03b2) where\n  proxy := Prod (proxy \u03b1) (proxy \u03b2)\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 (\u03b1 : Type u) := \u03b1\n\nnamespace NoShrink\n\ndef mk (x : \u03b1) : NoShrink \u03b1 := x\ndef get (x : NoShrink \u03b1) : \u03b1 := x\n\ninstance inhabited [inst : Inhabited \u03b1] : Inhabited (NoShrink \u03b1) := inst\ninstance repr [inst : Repr \u03b1] : Repr (NoShrink \u03b1) := inst\n\ninstance shrinkable : Shrinkable (NoShrink \u03b1) where\n  shrink := \u03bb _ => []\n\ninstance sampleableExt [SampleableExt \u03b1] [Repr \u03b1] : SampleableExt (NoShrink \u03b1) :=\n  SampleableExt.mkSelfContained $ (NoShrink.mk \u2218 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 (\u03bb n : \u2115, (n : \u211d) / (n + 1)) at_top (\ud835\udcdd 1) :=\nbegin\n  suffices : tendsto (\u03bb n : \u2115, (1 : \u211d) - 1 / (n + 1)) at_top (\ud835\udcdd (1 - 0)),\n  { have hn : \u2200 n : \u2115, (n : \u211d) + 1 \u2260 0 := \u03bb 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 {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\n\nlemma function.left_inverse.mem_preimage_iff (hfg : left_inverse g f) {s : set \u03b1} {x : \u03b1} :\n  f x \u2208 g \u207b\u00b9' s \u2194 x \u2208 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 \u03b1) :\n  f '' s = range f \u2229 g \u207b\u00b9' s :=\n-- begin\n--   simp_rw [set.ext_iff, mem_image, mem_inter_iff, mem_range, and_comm (_ \u2208 _),\n--     @eq_comm _ (f _), \u2190 exists_and_distrib_right, \u2190 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 \u27e8x, hx, rfl\u27e9, exact \u27e8mem_range_self x, hfg.mem_preimage_iff.mpr hx\u27e9 },\n  { rintro \u27e8\u27e8x, rfl\u27e9, b\u27e9, exact mem_image_of_mem f (hfg.mem_preimage_iff.mp b) }\nend\n\nlemma function.left_inverse.is_open_map {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (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 {\u03b1} [topological_space \u03b1] [normal_space \u03b1] {C : set \u03b1}\n  {P : \u03b1 \u2192 Prop} (hP : \u2200\u1da0 x in \ud835\udcdd\u02e2 C, P x) (hC : is_closed C) :\n    \u2203 C' \u2208 \ud835\udcdd\u02e2 C, is_closed C' \u2227 \u2200\u1da0 x in \ud835\udcdd\u02e2 C', P x :=\nbegin\n  obtain \u27e8O, hO, hCO, hPO\u27e9 := mem_nhds_set_iff_exists.mp hP,\n  obtain \u27e8U, hU, hCU, hUO\u27e9 := normal_exists_closure_subset hC hO hCO,\n  exact \u27e8closure 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\u27e9\nend\n\nend\n\nsection\n\nvariables {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n\n\nlemma continuous_at.eventually {f : \u03b1 \u2192 \u03b2} {a\u2080 : \u03b1} (hf : continuous_at f a\u2080)\n  (P : \u03b2 \u2192 Prop) (hP : is_open {b | P b}) (ha\u2080 : P (f a\u2080)) :\n  \u2200\u1da0 a in \ud835\udcdd a\u2080, P (f a) :=\nhf (is_open_iff_mem_nhds.mp hP _ ha\u2080)\n\nlemma continuous_at.eventually' {f : \u03b1 \u2192 \u03b2} {a\u2080 : \u03b1} (hf : continuous_at f a\u2080)\n  (P : \u03b2 \u2192 Prop)(hP : \u2200\u1da0 y in \ud835\udcdd (f a\u2080), P y) :\n  \u2200\u1da0 a in \ud835\udcdd a\u2080, 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 : \u03b1 \u2192 \u03b2} {a\u2080 : \u03b1} (hf : continuous f) (P : \u03b2 \u2192 Prop)\n  (hP : is_open {b | P b}) (ha\u2080 : P (f a\u2080)) :\n  \u2200\u1da0 a in \ud835\udcdd a\u2080, P (f a) :=\nhf.continuous_at.eventually P hP ha\u2080\n\n-- (unused)\nlemma nhds_set_prod_le {s : set \u03b1} {t : set \u03b2} : \ud835\udcdd\u02e2 (s \u00d7\u02e2 t) \u2264 (\ud835\udcdd\u02e2 s).prod (\ud835\udcdd\u02e2 t) :=\nbegin\n  intros w hw,\n  obtain \u27e8u, hu, v, hv, huv\u27e9 := mem_prod_iff.mp hw,\n  rw [\u2190 subset_interior_iff_mem_nhds_set] at hu hv \u22a2,\n  refine (prod_mono hu hv).trans _,\n  rw [\u2190 interior_prod_eq],\n  exact interior_mono huv\nend\n\ninstance [sigma_compact_space \u03b1] [sigma_compact_space \u03b2] : sigma_compact_space (\u03b1 \u00d7 \u03b2) :=\nbegin\n  refine \u27e8\u27e8\u03bb n, compact_covering \u03b1 n.unpair.1 \u00d7\u02e2 compact_covering \u03b2 n.unpair.2, \u03bb n,\n    (is_compact_compact_covering _ _).prod (is_compact_compact_covering _ _), _\u27e9\u27e9,\n  simp_rw [set.Union_unpair (\u03bb n m, compact_covering \u03b1 n \u00d7\u02e2 compact_covering \u03b2 m), \u2190 prod_Union,\n    \u2190 Union_prod_const, Union_compact_covering, univ_prod_univ]\nend\n\nend\n\nsection\n\nlemma support_norm {\u03b1 E : Type*} [normed_add_comm_group E] (f : \u03b1 \u2192 E) : support (\u03bb a, \u2016f a\u2016) = support f :=\nfunction.support_comp_eq norm (\u03bb x, norm_eq_zero) f\n\n@[to_additive]\nlemma has_compact_mul_support_of_subset {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [t2_space \u03b1]\n  [has_one \u03b2] {f : \u03b1 \u2192 \u03b2} {K : set \u03b1} (hK : is_compact K) (hf : mul_support f \u2286 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 {\u03b1 \u03b2 : Type*} [has_add \u03b1] {a : \u03b1} {b : \u03b2} : periodic (\u03bb x, b) a :=\n\u03bb x, rfl\n\nlemma real.ball_zero_eq (r : \u211d) : metric.ball (0 : \u211d) r = Ioo (-r) r :=\nby { ext x, simp [real.norm_eq_abs, abs_lt] }\n\nend\n\nsection\n/-! ## The standard \u2124 action on \u211d is properly discontinuous\n\nTODO: use that in to_mathlib.topology.periodic?\n-/\ninstance : has_vadd \u2124 \u211d := \u27e8\u03bb n x, (n : \u211d) + x\u27e9\n\ninstance : properly_discontinuous_vadd \u2124 \u211d :=\n\u27e8begin\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 \u2308Inf L - Sup K\u2309 \u230aSup L - Inf K\u230b).subset,\n  rintros n (hn : has_vadd.vadd n '' K \u2229 L \u2260 \u2205),\n  rcases nonempty_iff_ne_empty.mpr hn with \u27e8l, \u27e8k, hk, rfl\u27e9, hnk : (n : \u211d) + k \u2208 L\u27e9,\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\u27e9\n\nend\n\nsection fract\n\nopen int\n/- properties of the (dis)continuity of `int.fract` on `\u211d`.\nTo be PRed to topology.algebra.floor_ring\n-/\n\nlemma floor_eq_self_iff {x : \u211d} : (\u230ax\u230b : \u211d) = x \u2194 \u2203 n : \u2124, x = n :=\nbegin\n  split,\n  { intro h,\n    exact \u27e8\u230ax\u230b, h.symm\u27e9 },\n  { rintros \u27e8n, rfl\u27e9,\n    rw floor_int_cast }\nend\n\nlemma fract_eq_zero_iff {x : \u211d} : fract x = 0 \u2194 \u2203 n : \u2124, x = n :=\nby rw [fract, sub_eq_zero, eq_comm, floor_eq_self_iff]\n\nlemma fract_ne_zero_iff {x : \u211d} : fract x \u2260 0 \u2194 \u2200 n : \u2124, x \u2260 n :=\nby rw [\u2190 not_exists, not_iff_not, fract_eq_zero_iff]\n\nlemma Ioo_floor_mem_nhds {x : \u211d} (h : \u2200 (n : \u2124), x \u2260 n) : Ioo (\u230ax\u230b : \u211d) (\u230ax\u230b + 1 : \u211d) \u2208 \ud835\udcdd x :=\nIoo_mem_nhds ((floor_le x).eq_or_lt.elim (\u03bb H, (h \u230ax\u230b H.symm).elim) id) (lt_floor_add_one x)\n\nlemma loc_constant_floor {x : \u211d} (h : \u2200 (n : \u2124), x \u2260 n) : floor =\u1da0[\ud835\udcdd x] (\u03bb x', \u230ax\u230b) :=\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 : \u211d}\n  (h : fract x \u2260 0) : fract =\u1da0[\ud835\udcdd x] (\u03bb 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 : \u211d} (h : fract x \u2260 0) : continuous_at fract x :=\n(continuous_at_id.sub continuous_at_const).congr (fract_eventually_eq h).symm\n\nlemma Ioo_inter_Iio {\u03b1 : Type*} [linear_order \u03b1] {a b c : \u03b1} : Ioo a b \u2229 Iio c = Ioo a (min b c) :=\nby { ext, simp [and_assoc] }\n\nlemma fract_lt {x y : \u211d} {n : \u2124} (h1 : (n : \u211d) \u2264 x) (h2 : x < n + y) : fract x < y :=\nbegin\n  cases le_total y 1 with hy hy,\n  { rw [\u2190 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 : \u211d} {n : \u2124} (hy : y \u2264 1) (h1 : (n : \u211d) - y < x) (h2 : x < n) :\n  1 - y < fract x :=\nbegin\n  have I\u2081 : 1 - y < x - (n-1), by linarith,\n  have I\u2082 : x - (n-1) < 1, by linarith,\n  norm_cast at I\u2081 I\u2082,\n  rw [\u2190 fract_sub_int x (n-1), fract_eq_self.mpr],\n  exact I\u2081,\n  split; linarith,\nend\n\nlemma is_open.preimage_fract' {s : set \u211d} (hs : is_open s)\n  (h2s : 0 \u2208 s \u2192 s \u2208 \ud835\udcdd[<] (1 : \u211d)) : is_open (fract \u207b\u00b9' s) :=\nbegin\n  rw is_open_iff_mem_nhds,\n  rintros x (hx : fract x \u2208 s),\n  rcases eq_or_ne (fract x)  0 with hx' | hx',\n  { have H : (0 : \u211d) \u2208 s, by rwa hx' at hx,\n    specialize h2s H,\n    rcases fract_eq_zero_iff.mp hx' with \u27e8n, rfl\u27e9, clear hx hx',\n    have s_mem_0 := hs.mem_nhds H,\n    rcases (nhds_basis_zero_abs_sub_lt \u211d).mem_iff.mp s_mem_0 with \u27e8\u03b4, \u03b4_pos, h\u03b4\u27e9,\n    rcases (nhds_within_has_basis (nhds_basis_Ioo_pos (1 : \u211d)) _).mem_iff.mp h2s with \u27e8\u03b5, \u03b5_pos, h\u03b5\u27e9,\n    rw [Ioo_inter_Iio, min_eq_right (le_add_of_nonneg_right \u03b5_pos.le)] at h\u03b5,\n    set \u03b5' := min \u03b5 (1/2),\n    have \u03b5'_pos : 0 < \u03b5',\n      from lt_min \u03b5_pos (by norm_num : (0 : \u211d) < 1/2),\n    have h\u03b5' : Ioo (1 - \u03b5') 1 \u2286 s,\n    { apply subset.trans _ h\u03b5,\n      apply Ioo_subset_Ioo_left,\n      linarith [min_le_left \u03b5 (1/2)] },\n    have mem : Ioo ((n : \u211d)-\u03b5') (n+\u03b4) \u2208 \ud835\udcdd (n : \u211d),\n    { apply Ioo_mem_nhds ; linarith },\n    apply mem_of_superset mem,\n    rintros x \u27e8hx, hx'\u27e9,\n    cases le_or_gt (n : \u211d) x with hx'' hx'',\n    { apply h\u03b4,\n      rw [mem_set_of_eq, abs_eq_self.mpr (fract_nonneg x)],\n      exact fract_lt hx'' hx' },\n    { apply h\u03b5',\n      split,\n      { refine one_sub_lt_fract (by linarith [min_le_right \u03b5 (1/2)]) (by linarith) hx'' },\n      { exact fract_lt_one x }, } },\n  { rw fract_ne_zero_iff at hx',\n    have H : Ico (\u230ax\u230b : \u211d) (\u230ax\u230b + 1) \u2208 \ud835\udcdd x,\n      from mem_of_superset (Ioo_floor_mem_nhds hx') Ioo_subset_Ico_self,\n    exact (continuous_on_fract \u230ax\u230b).continuous_at H (hs.mem_nhds hx) },\nend\n\nlemma is_open.preimage_fract {s : set \u211d} (hs : is_open s)\n  (h2s : (0 : \u211d) \u2208 s \u2192 (1 : \u211d) \u2208 s) : is_open (fract \u207b\u00b9' s) :=\nhs.preimage_fract' $ \u03bb h, nhds_within_le_nhds $ hs.mem_nhds (h2s h)\n\n-- is `s\u1d9c \u2209 \ud835\udcdd[<] (1 : \u211d)` equivalent to something like `cluster_pt (\ud835\udcdd[Iio (1 : \u211d) \u2229 s] (1 : \u211d)` ?\nlemma is_closed.preimage_fract {s : set \u211d} (hs : is_closed s)\n  (h2s : s\u1d9c \u2209 \ud835\udcdd[<] (1 : \u211d) \u2192 (0 : \u211d) \u2208 s) : is_closed (fract \u207b\u00b9' s) :=\nis_open_compl_iff.mp $ hs.is_open_compl.preimage_fract' $ \u03bb h, by_contra $ \u03bb h', h $ h2s h'\n\nlemma fract_preimage_mem_nhds {s : set \u211d} {x : \u211d} (h1 : s \u2208 \ud835\udcdd (fract x))\n  (h2 : fract x = 0 \u2192 s \u2208 \ud835\udcdd (1 : \u211d)) : fract \u207b\u00b9' s \u2208 \ud835\udcdd x :=\nbegin\n  by_cases hx : fract x = 0,\n  { obtain \u27e8u, hus, hu, hxu\u27e9 := mem_nhds_iff.mp h1,\n    obtain \u27e8v, hvs, hv, h1v\u27e9 := mem_nhds_iff.mp (h2 hx),\n    rw [mem_nhds_iff],\n    refine \u27e8fract \u207b\u00b9' (u \u222a v), preimage_mono (union_subset hus hvs),\n      (hu.union hv).preimage_fract (\u03bb _, subset_union_right _ _ h1v), subset_union_left _ _ hxu\u27e9 },\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 \u211d E] [normed_space \u211d F]\n\nlemma dist_smul_add_one_sub_smul_le {r : \u211d} {x y : E} (h : r \u2208 unit_interval) :\n  dist (r \u2022 x + (1 - r) \u2022 y) x \u2264 dist y x :=\ncalc\n  dist (r \u2022 x + (1 - r) \u2022 y) x = \u20161 - r\u2016 * \u2016x - y\u2016 : by simp_rw [dist_eq_norm', \u2190 norm_smul,\n    sub_smul, one_smul, smul_sub, \u2190 sub_sub, \u2190 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  ... \u2264 (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 {\u03b1 \u03b2 \u03b3 \u03b4 \u03b9 : Type*} [topological_space \u03b1] [topological_space \u03b2] {x : \u03b1}\n\nlemma is_open_slice_of_is_open_over {\u03a9 : set (\u03b1 \u00d7 \u03b2)} {x\u2080 : \u03b1}\n  (h\u03a9_op : \u2203 U \u2208 \ud835\udcdd x\u2080, is_open (\u03a9 \u2229 prod.fst \u207b\u00b9' U)) : is_open (prod.mk x\u2080 \u207b\u00b9' \u03a9) :=\nbegin\n  rcases h\u03a9_op with \u27e8U, hU, hU_op\u27e9, convert hU_op.preimage (continuous.prod.mk x\u2080) 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 {\u03b1 \u03b2 : Type*} [linear_ordered_semiring \u03b1] {x c : \u03b1}\n\n/-- If `\u03b1` is a `linear_ordered_semiring`, then `proj_I : \u03b1 \u2192 \u03b1` projection of `\u03b1` onto the unit\ninterval `[0, 1]`. -/\ndef proj_I : \u03b1 \u2192 \u03b1 := \u03bb x, proj_Icc (0 : \u03b1) 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 : \u03b1) 1 zero_le_one x : \u03b1) = proj_I x := rfl\n\nlemma proj_I_of_le_zero (hx : x \u2264 0) : proj_I x = 0 :=\ncongr_arg coe $ proj_Icc_of_le_left _ hx\n\n@[simp] lemma proj_I_zero : proj_I (0 : \u03b1) = 0 :=\ncongr_arg coe $ proj_Icc_left _\n\nlemma proj_I_of_one_le (hx : 1 \u2264 x) : proj_I x = 1 :=\ncongr_arg coe $ proj_Icc_of_right_le _ hx\n\n@[simp] lemma proj_I_one : proj_I (1 : \u03b1) = 1 :=\ncongr_arg coe $ proj_Icc_right _\n\n@[simp] lemma proj_I_eq_zero [nontrivial \u03b1] : proj_I x = 0 \u2194 x \u2264 0 :=\nby { rw [\u2190 proj_Icc_eq_left (zero_lt_one' \u03b1), subtype.ext_iff], refl }\n\n@[simp] lemma proj_I_eq_one : proj_I x = 1 \u2194 1 \u2264 x :=\nby { rw [\u2190 proj_Icc_eq_right (zero_lt_one' \u03b1), subtype.ext_iff], refl }\n\nlemma proj_I_mem_Icc : proj_I x \u2208 Icc (0 : \u03b1) 1 :=\n(proj_Icc (0 : \u03b1) 1 zero_le_one x).prop\n\nlemma proj_I_eq_self : proj_I x = x \u2194 x \u2208 Icc (0 : \u03b1) 1 :=\n\u27e8\u03bb h, h \u25b8 proj_I_mem_Icc, \u03bb h, congr_arg coe $ proj_Icc_of_mem _ h\u27e9\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 : \u03b1) 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 : \u03b1 \u2192 \u03b1) :=\nmonotone_proj_Icc _\n\nlemma strict_mono_on_proj_I : strict_mono_on proj_I (Icc (0 : \u03b1) 1) :=\nstrict_mono_on_proj_Icc _\n\nlemma proj_I_le_max : proj_I x \u2264 max 0 x :=\nmax_le_max le_rfl $ min_le_right _ _\n\nlemma min_le_proj_I : min 1 x \u2264 proj_I x :=\nle_max_right _ _\n\nlemma proj_I_le_iff : proj_I x \u2264 c \u2194 0 \u2264 c \u2227 (1 \u2264 c \u2228 x \u2264 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 \u2194 0 \u2264 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 \u2264 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 \u03b1] [order_topology \u03b1] :\n  continuous (proj_I : \u03b1 \u2192 \u03b1) :=\ncontinuous_proj_Icc.subtype_coe\n\nlemma proj_I_mapsto {\u03b1 : Type*} [linear_ordered_semiring \u03b1] {s : set \u03b1} (h0s : (0 : \u03b1) \u2208 s)\n  (h1s : (1 : \u03b1) \u2208 s) : maps_to proj_I s s :=\n\u03bb x hx, (le_total 1 x).elim (\u03bb h2x, by rwa [proj_I_eq_one.mpr h2x]) $\n  \u03bb h2x, (le_total 0 x).elim (\u03bb h3x, by rwa [proj_I_eq_self.mpr \u27e8h3x, h2x\u27e9]) $\n  \u03bb 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  (\u03b3 : path a b) (t\u2080 t\u2081 : \u211d) (s : I) :\n  \u03b3.truncate t\u2080 (proj_I t\u2081) s = \u03b3.truncate t\u2080 t\u2081 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 {\u03b1 \u03b2 \u03b3 : Type*} [topological_space \u03b1] [topological_space \u03b2]\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 `\u2115` (by adding some `\u2205` values).\n  This new sequence is still locally finite. -/\nlemma decode\u2082_locally_finite {\u03b9} [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1}\n  (hs : locally_finite s) : locally_finite (\u03bb i, (s <$> decode\u2082 \u03b9 i).get_or_else \u2205) :=\nbegin\n  intro x,\n  obtain \u27e8U, hxU, hU\u27e9 := hs x,\n  refine \u27e8U, hxU, _\u27e9,\n  have : encode \u207b\u00b9' {i : \u2115 | ((s <$> decode\u2082 \u03b9 i).get_or_else \u2205 \u2229 U).nonempty} =\n     {i : \u03b9 | (s i \u2229 U).nonempty},\n  { simp_rw [preimage_set_of_eq, decode\u2082_encode, map_some, get_or_else_some] },\n  rw [\u2190 this] at hU,\n  refine finite_of_finite_preimage hU _,\n  intros n hn,\n  rw [\u2190 decode\u2082_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 \u2192 Prop}\n  (hP : antitone P) (h0 : P \u2205) (hX : \u2200 x \u2208 C, \u2203 V \u2208 \ud835\udcdd (x : X), P V) :\n\u2203 (K : \u2115 \u2192 set X) (W : \u2115 \u2192 set X), (\u2200 n, is_compact (K n)) \u2227 (\u2200 n, is_open (W n)) \u2227\n  (\u2200 n, P (W n)) \u2227 (\u2200 n, K n \u2286 W n) \u2227 locally_finite W \u2227 C \u2286 \u22c3 n, K n :=\nbegin\n  choose V' hV' hPV' using set_coe.forall'.mp hX,\n  choose V hV hVV' hcV using \u03bb x : C, locally_compact_space.local_compact_nhds \u2191x (V' x) (hV' x),\n  simp_rw [\u2190 mem_interior_iff_mem_nhds] at hV,\n  have : C \u2286 (\u22c3 x : C, interior (V x)) :=\n  \u03bb x hx, by { rw [mem_Union], exact \u27e8\u27e8x, hx\u27e9, hV _\u27e9 },\n  obtain \u27e8s, hs, hsW\u2082\u27e9 := is_open_Union_countable (\u03bb x, interior (V x)) (\u03bb x, is_open_interior),\n  rw [\u2190 hsW\u2082, bUnion_eq_Union] at this, clear hsW\u2082,\n  obtain \u27e8W, hW, hUW, hlW, hWV\u27e9 :=\n    precise_refinement_set hC (\u03bb x : s, interior (V x)) (\u03bb x, is_open_interior) this,\n  obtain \u27e8K, hCK, hK, hKW\u27e9 :=\n    exists_subset_Union_closed_subset hC (\u03bb x : s, hW x) (\u03bb x _, hlW.point_finite x) hUW,\n  haveI : encodable s := hs.to_encodable,\n  let K' : \u2115 \u2192 set X := \u03bb n, (K <$> (decode\u2082 s n)).get_or_else \u2205,\n  let W' : \u2115 \u2192 set X := \u03bb n, (W <$> (decode\u2082 s n)).get_or_else \u2205,\n  refine \u27e8K', W', _, _, _, _, _, _\u27e9,\n  { intro n, cases h : decode\u2082 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\u2082 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\u2082 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\u2082 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\u2082_locally_finite hlW },\n  { intros x hx, obtain \u27e8i, hi\u27e9 := mem_Union.mp (hCK hx),\n    refine mem_Union.mpr \u27e8encode i, _\u27e9,\n    simp_rw [K', decode\u2082_encode, map_some, get_or_else_some, hi] }\nend\n\nend\n\nsection -- to subset_properties\n\nvariables {\u03b1 \u03b2 \u03b3 : Type*} [topological_space \u03b1] [topological_space \u03b2] [topological_space \u03b3]\n\nlemma is_compact.eventually_forall_mem {x\u2080 : \u03b1} {K : set \u03b2} (hK : is_compact K)\n  {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (hf : continuous \u21bff) {U : set \u03b3} (hU : \u2200 y \u2208 K, U \u2208 \ud835\udcdd (f x\u2080 y)) :\n  \u2200\u1da0 x in \ud835\udcdd x\u2080, \u2200 y \u2208 K, f x y \u2208 U :=\nhK.eventually_forall_of_forall_eventually $ \u03bb y hy, (hf.tendsto _).eventually $\n  show U \u2208 \ud835\udcdd (\u21bff (x\u2080, y)), from hU y hy\n\nend\n\nsection -- to separation\n\nvariables {\u03b1 : Type*} [topological_space \u03b1]\n\n/-\nneeds\nimport linear_algebra.affine_space.independent\nimport analysis.normed_space.finite_dimension\n-/\nlemma is_open_affine_independent (\ud835\udd5c E : Type*) {\u03b9 : Type*} [nontrivially_normed_field \ud835\udd5c]\n  [normed_add_comm_group E] [normed_space \ud835\udd5c E] [complete_space \ud835\udd5c] [finite \u03b9] :\n  is_open {p : \u03b9 \u2192 E | affine_independent \ud835\udd5c p} :=\nbegin\n  classical,\n  cases is_empty_or_nonempty \u03b9, { resetI, exact is_open_discrete _ },\n  obtain \u27e8i\u2080\u27e9 := h,\n  simp_rw [affine_independent_iff_linear_independent_vsub \ud835\udd5c _ i\u2080],\n  let \u03b9' := {x // x \u2260 i\u2080},\n  casesI nonempty_fintype \u03b9,\n  haveI : fintype \u03b9' := subtype.fintype _,\n  convert_to\n    is_open ((\u03bb (p : \u03b9 \u2192 E) (i : \u03b9'), p i -\u1d65 p i\u2080) \u207b\u00b9' {p : \u03b9' \u2192 E | linear_independent \ud835\udd5c p}),\n  refine is_open.preimage _ is_open_set_of_linear_independent,\n  refine continuous_pi (\u03bb i', continuous.vsub (continuous_apply i') $ continuous_apply i\u2080),\nend\n\nend\n\nsection convex\n\nvariables {E : Type*} [add_comm_group E] [module \u211d E] [topological_space E]\n  [topological_add_group E] [has_continuous_smul \u211d E] {s : set E}\n\nlemma convex.is_preconnected' (hs : convex \u211d 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 {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [pseudo_metric_space \u03b2] {s : set \u03b2}\n  {f : \u03b1 \u2192 \u03b2} (hf : continuous f) : continuous (\u03bb 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 \u211d E]\n\nlemma is_preconnected_ball (x : E) (r : \u211d) : is_preconnected (ball x r) :=\n(convex_ball x r).is_preconnected'\n\nlemma is_connected_ball {x : E} {r : \u211d} : is_connected (ball x r) \u2194 0 < r :=\nbegin\n  rw [\u2190 @nonempty_ball _ _ x],\n  refine \u27e8\u03bb h, h.nonempty, \u03bb h, ((convex_ball x r).is_path_connected $ h).is_connected\u27e9\nend\n\n-- todo: make metric.mem_nhds_iff protected\n\nend normed_space\n\nsection connected_component_in\n\nvariables {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n\nlemma continuous.image_connected_component_in_subset {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {x : \u03b1}\n  (hf : continuous f) (hx : x \u2208 s) :\n  f '' connected_component_in s x \u2286 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 : \u03b1 \u2243\u209c \u03b2) {s : set \u03b1} {x : \u03b1} (hx : x \u2208 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 {\u03b1} [topological_space \u03b1] [second_countable_topology \u03b1] {f : \u03b1 \u2192 set \u03b1}\n  {s : set \u03b1} (hf : \u2200 x \u2208 s, f x \u2208 \ud835\udcdd[s] x) (hs : s.nonempty) :\n  \u2203 x : \u2115 \u2192 \u03b1, range x \u2286 s \u2227 s \u2286 \u22c3 n, f (x n) :=\nbegin\n  obtain \u27e8t, hts, ht, hsf\u27e9 := 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 \u27e8x, rfl\u27e9 := ht.exists_eq_range hnt,\n  rw [bUnion_range] at hsf,\n  exact \u27e8x, hts, hsf\u27e9\nend\n\n/-- A version of `topological_space.cover_nat_nhds_within` where `f` is only defined on `s`. -/\nlemma cover_nat_nhds_within' {\u03b1} [topological_space \u03b1] [second_countable_topology \u03b1] {s : set \u03b1}\n  {f : \u2200 x \u2208 s, set \u03b1} (hf : \u2200 x (hx : x \u2208 s), f x hx \u2208 \ud835\udcdd[s] x) (hs : s.nonempty) :\n  \u2203 (x : \u2115 \u2192 \u03b1) (hx : range x \u2286 s), s \u2286 \u22c3 n, f (x n) (range_subset_iff.mp hx n) :=\nbegin\n  let g := \u03bb x, if hx : x \u2208 s then f x hx else \u2205,\n  have hg : \u2200 x \u2208 s, g x \u2208 \ud835\udcdd[s] x, { intros x hx, simp_rw [g, dif_pos hx], exact hf x hx },\n  obtain \u27e8x, hx, h\u27e9 := topological_space.cover_nat_nhds_within hg hs,\n  simp_rw [g, dif_pos (range_subset_iff.mp hx _)] at h,\n  refine \u27e8x, hx, h\u27e9,\nend\n\nend topological_space\n\nnamespace set\nnamespace subtype\nopen _root_.subtype\nvariables {\u03b1 : Type*}\n\nlemma image_coe_eq_iff_eq_univ {s : set \u03b1} {t : set s} : (coe : s \u2192 \u03b1) '' t = s \u2194 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 \u03b1} : (coe : s \u2192 \u03b1) \u207b\u00b9' t = univ \u2194 s \u2286 t :=\nby rw [\u2190 inter_eq_right_iff_subset, \u2190 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' {\u03b9 X : Type*} [topological_space X] {s : set X}\n  [paracompact_space s] (hs : is_open s)\n  (u : \u03b9 \u2192 set X) (uo : \u2200 i, is_open (u i)) (us : s \u2286 \u22c3 i, u i) :\n  \u2203 (v : \u03b9 \u2192 set X), (\u2200 i, is_open (v i)) \u2227 (s \u2286 \u22c3 i, v i) \u2227\n  locally_finite (\u03bb i, (coe : s \u2192 X) \u207b\u00b9' v i) \u2227 (\u2200 i, v i \u2286 s) \u2227 (\u2200 i, v i \u2286 u i) :=\nbegin\n  obtain \u27e8v, vo, vs, vl, vu\u27e9 := precise_refinement (\u03bb i, (coe : s \u2192 X) \u207b\u00b9' u i)\n    (\u03bb i, (uo i).preimage continuous_subtype_coe)\n    (by rwa [\u2190 preimage_Union, subtype.preimage_coe_eq_univ]),\n  refine \u27e8\u03bb i, coe '' v i, \u03bb i, hs.is_open_map_subtype_coe _ (vo i),\n    by rw [\u2190 image_Union, vs, subtype.coe_image_univ],\n    by simp_rw [preimage_image_eq _ subtype.coe_injective, vl],\n    \u03bb i, subtype.coe_image_subset _ _,\n    by { intro i, rw [image_subset_iff], exact vu i }\u27e9,\nend\n\nlemma point_finite_of_locally_finite_coe_preimage {\u03b9 X : Type*} [topological_space X] {s : set X}\n  {f : \u03b9 \u2192 set X} (hf : locally_finite (\u03bb i, (coe : s \u2192 X) \u207b\u00b9' f i)) (hfs : \u2200 i, f i \u2286 s) {x : X} :\n  {i | x \u2208 f i}.finite :=\nbegin\n  by_cases hx : x \u2208 s,\n  { exact hf.point_finite \u27e8x, hx\u27e9 },\n  { have : \u2200 i, x \u2209 f i := \u03bb 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 {\u03b9 X : Type*} [topological_space X]\nvariables {u : \u03b9 \u2192 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 : \u2200 i, is_open (u i))\n  (uc : \u2200 i, is_compact (closure (u i)))\n  (us : \u2200 i, closure (u i) \u2286 s)\n  (uf : \u2200 x \u2208 s, {i | x \u2208 u i}.finite) (uU : s \u2286 \u22c3 i, u i) :\n  \u2203 v : \u03b9 \u2192 set X, s \u2286 (\u22c3 i, interior (v i)) \u2227 (\u2200 i, is_compact (v i)) \u2227 \u2200 i, v i \u2286 u i :=\nbegin\n  obtain \u27e8v, vU, vo, hv\u27e9 := exists_Union_eq_closure_subset\n    (\u03bb i, (uo i).preimage (continuous_subtype_coe : continuous (coe : s \u2192 X)))\n    (\u03bb x, uf x x.prop)\n    (by simp_rw [\u2190 preimage_Union, subtype.preimage_coe_eq_univ, uU]),\n  have : \u2200 i, is_compact (closure ((coe : _ \u2192 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 \u27e8\u03bb i, closure (coe '' (v i)), _, this, _\u27e9,\n  { refine subset.trans _ (Union_mono $\n      \u03bb i, interior_maximal subset_closure (hs.is_open_map_subtype_coe _ (vo i))),\n    simp_rw [\u2190 image_Union, vU, subtype.coe_image_univ] },\n  { intro i,\n    have : coe '' v i \u2286 u i,\n    { rintro _ \u27e8x, hx, rfl\u27e9, exact hv i (subset_closure hx) },\n    intros x hx,\n    have hxs : x \u2208 s := us i (closure_mono this hx),\n    have : (\u27e8x, hxs\u27e9 : s) \u2208 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 {\u03b1 \u03b2 \u03b3 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n  {f g : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} {a : \u03b1} {b : \u03b2} (h : f =\u1da0[\ud835\udcdd (a, b)] g) : (\u03bb y, f (a, y)) =\u1da0[\ud835\udcdd b] (\u03bb y, g(a, y)) :=\nbegin\n  rw nhds_prod_eq at h,\n  have : (pure a : filter \u03b1) \u00d7\u1da0 \ud835\udcdd b \u2264 (\ud835\udcdd a) \u00d7\u1da0 (\ud835\udcdd 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' {\u03b1 : Type*} [topological_space \u03b1] [locally_compact_space \u03b1]\n  {K U : set \u03b1} (hK : is_compact K) (hU : is_open U) (h_KU : K \u2286 U) :\n  \u2203 L, is_compact L \u2227 L \u2208 \ud835\udcdd\u02e2 K \u2227 L \u2286 U :=\nlet \u27e8L, L_cpct, L_in, LU\u27e9 := exists_compact_between hK hU h_KU in\n  \u27e8L, L_cpct, subset_interior_iff_mem_nhds_set.mp L_in, LU\u27e9\n\nsection -- to topology/basic\n\n@[simp] lemma finset.is_closed_bUnion {\u03b1} [topological_space \u03b1]\n  {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 set \u03b1) (hf : \u2200 i \u2208 s, is_closed (f i)) :\n  is_closed (\u22c3 i \u2208 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 {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) (x : option \u03b1) (y : \u03b2) :\n  some y = x.map f \u2194 \u2203 a, x = some a \u2227 f a = y := by { cases x; simp, exact comm, }\n\n@[simp] lemma map_eq_none'_symm {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) (x : option \u03b1) :\n  none = x.map f \u2194 none = x := by cases x; simp\n\nend option\n\nnamespace part\n\n@[simp] lemma restrict_dom {\u03b1 : Type*} (x : part \u03b1) {p : Prop} (hp : p \u2192 x.dom) :\n  (x.restrict p hp).dom \u2194 p := by refl \n\nend part\n\nnamespace pfun\n\n@[simp] lemma res_dom {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) {p : set \u03b1} (hp : p \u2286 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 {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) (p : set \u03b1) : \u03b1 \u2192. \u03b2 :=\nf.restrict (set.inter_subset_right p f.dom)\n\n@[simp] lemma mem_res_inter {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} {p : set \u03b1} {x y} :\n  y \u2208 f.res_inter p x \u2194 x \u2208 p \u2227 y \u2208 f x :=\nby { simp [res_inter], tauto, }\n\n@[simp] lemma res_inter_res_inter {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} {p\u2081 p\u2082 : set \u03b1} :\n  (f.res_inter p\u2081).res_inter p\u2082 = f.res_inter (p\u2081 \u2229 p\u2082) :=\nby { ext, simp, tauto, }\n\n@[simp] lemma res_inter_dom {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192. \u03b2) (p : set \u03b1) :\n  (f.res_inter p).dom = p \u2229 f.dom := by simp [res_inter]\n\n@[simp] lemma res_inter_dom' {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192. \u03b2} {p : set \u03b1} :\n  \u2200 {x}, (f.res_inter p x).dom \u2194 x \u2208 p \u2227 (f x).dom :=\nset.ext_iff.mp (res_inter_dom f p)\n\n@[simp] lemma coe_res_inter {\u03b1 \u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) (p : set \u03b1) :\n  (f : \u03b1 \u2192. \u03b2).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 `\u03c3 \u2192 option \u03c3` \"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 {\u03c3} (f : \u03c3 \u2192. option \u03c3) : \u03c3 \u2192 part \u03c3 :=\npfun.fix (\u03bb s, (f s).map (\u03bb 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\u2081`, `f a\u2081 = some a\u2082`, ... such that `a\u2099 = b`.\nThis relation permits zero steps of the state transition function. -/\ndef reaches {\u03c3} (f : \u03c3 \u2192. option \u03c3) : \u03c3 \u2192 \u03c3 \u2192 Prop :=\nrefl_trans_gen (\u03bb a b, some b \u2208 f a)\n\n@[refl] lemma reaches.refl {\u03c3} (f : \u03c3 \u2192. option \u03c3) (x : \u03c3) :\n  reaches f x x := refl_trans_gen.refl\n\n@[trans] lemma reaches.trans {\u03c3} {f : \u03c3 \u2192. option \u03c3} {x y z : \u03c3} :\n  reaches f x y \u2192 reaches f y z \u2192 reaches f x z := refl_trans_gen.trans\n\nlemma reaches_fwd {\u03c3} {f : \u03c3 \u2192. option \u03c3} {x y : \u03c3} :\n  some y \u2208 f x \u2192 reaches f x y := @refl_trans_gen.single _ _ x y\n\ntheorem reaches_mono {\u03c3} {f : \u03c3 \u2192. option \u03c3} (S : set \u03c3) (hS : S \u2286 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' {\u03c3} {f g : \u03c3 \u2192. option \u03c3} (hfg : \u2200 \u2983x y\u2984, y \u2208 f x \u2192 y \u2208 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 {\u03c3} {f : \u03c3 \u2192. option \u03c3} (S : set \u03c3) (hS : \u2200 \u2983x y\u2984, x \u2208 S \u2192 some y \u2208 f x \u2192 y \u2208 S)\n  {x y} (hx : x \u2208 S) (hf : reaches f x y) : y \u2208 S :=\nby { induction hf with x' y' hfx' hfy' ih, { exact hx, }, exact hS ih hfy', }\n\ntheorem reaches_of_invariant {\u03c3} {f : \u03c3 \u2192. option \u03c3} (S : set \u03c3) (hS : \u2200 \u2983x y\u2984, x \u2208 S \u2192 some y \u2208 f x \u2192 y \u2208 S)\n  {x y} (hx : x \u2208 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 \u27e8hx, hx'\u27e9, }, { exact hS hx hx', }\nend\n\n/-- The transitive closure of a state transition function. `reaches\u2081 f a b` means there is a\nnonempty finite sequence of steps `f a = some a\u2081`, `f a\u2081 = some a\u2082`, ... such that `a\u2099 = b`.\nThis relation does not permit zero steps of the state transition function. -/\ndef reaches\u2081 {\u03c3} (f : \u03c3 \u2192. option \u03c3) : \u03c3 \u2192 \u03c3 \u2192 Prop :=\ntrans_gen (\u03bb a b, some b \u2208 f a)\n\ntheorem reaches_iff_eq_or_reaches\u2081 {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b} :\n  reaches f a b \u2194 b = a \u2228 reaches\u2081 f a b := refl_trans_gen_iff_eq_or_trans_gen\n\ntheorem reaches\u2081_head'_iff {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b} :\n  reaches\u2081 f a b \u2194 \u2203 c : \u03c3, some c \u2208 f a \u2227 reaches f c b := trans_gen.head'_iff\n\ntheorem reaches\u2081_eq {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b c}\n  (h : f a = f b) : reaches\u2081 f a c \u2194 reaches\u2081 f b c :=\ntrans_gen.head'_iff.trans (trans_gen.head'_iff.trans $ by rw h).symm\n\ntheorem reaches_total {\u03c3} {f : \u03c3 \u2192. option \u03c3}\n  {a b c} (hab : reaches f a b) (hac : reaches f a c) :\n  reaches f b c \u2228 reaches f c b :=\nrefl_trans_gen.total_of_right_unique (\u03bb x y z hx hy, option.some_injective _ (part.mem_unique hx hy)) hab hac\n\ntheorem reaches\u2081_fwd {\u03c3} {f : \u03c3 \u2192. option \u03c3}\n  {a b c} (h\u2081 : reaches\u2081 f a c) (h\u2082 : some b \u2208 f a) : reaches f b c :=\nbegin\n  rw reaches\u2081_head'_iff at h\u2081, rcases h\u2081 with \u27e8b', \u27e8h\u2082', H\u27e9\u27e9,\n  cases part.mem_unique h\u2082 h\u2082', exact H,\nend\n\ntheorem reaches\u2081_single {\u03c3} {f : \u03c3 \u2192. option \u03c3}\n  {a b} : some b \u2208 f a \u2192 reaches\u2081 f a b :=\n@trans_gen.single \u03c3 _ a b\n\n/-- A variation on `reaches`. `reaches\u2080 f a b` holds if whenever `reaches\u2081 f b c` then\n`reaches\u2081 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\u2080 {\u03c3} (f : \u03c3 \u2192. option \u03c3) (a b : \u03c3) : Prop :=\n\u2200 c, reaches\u2081 f b c \u2192 reaches\u2081 f a c\n\ntheorem reaches\u2080.trans {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b c : \u03c3}\n  (h\u2081 : reaches\u2080 f a b) (h\u2082 : reaches\u2080 f b c) : reaches\u2080 f a c\n| d h\u2083 := h\u2081 _ (h\u2082 _ h\u2083)\n\n@[refl] theorem reaches\u2080.refl {\u03c3} {f : \u03c3 \u2192. option \u03c3} (a : \u03c3) : reaches\u2080 f a a\n| b h := h\n\ntheorem reaches\u2080.single {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b : \u03c3}\n  (h : some b \u2208 f a) : reaches\u2080 f a b\n| c h\u2082 := h\u2082.head h\n\ntheorem reaches\u2080.head {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b c : \u03c3}\n  (h : some b \u2208 f a) (h\u2082 : reaches\u2080 f b c) : reaches\u2080 f a c :=\n(reaches\u2080.single h).trans h\u2082\n\ntheorem reaches\u2080.tail {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b c : \u03c3}\n  (h\u2081 : reaches\u2080 f a b) (h : some c \u2208 f b) : reaches\u2080 f a c :=\nh\u2081.trans (reaches\u2080.single h)\n\ntheorem reaches\u2080_eq {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b}\n  (e : f a = f b) : reaches\u2080 f a b\n| d h := (reaches\u2081_eq e).2 h\n\ntheorem reaches\u2081.to\u2080 {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b : \u03c3}\n  (h : reaches\u2081 f a b) : reaches\u2080 f a b\n| c h\u2082 := h.trans h\u2082\n\ntheorem reaches.to\u2080 {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b : \u03c3}\n  (h : reaches f a b) : reaches\u2080 f a b\n| c h\u2082 := h\u2082.trans_right h\n\ntheorem reaches\u2080.tail' {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b c : \u03c3}\n  (h : reaches\u2080 f a b) (h\u2082 : some c \u2208 f b) : reaches\u2081 f a c :=\nh _ (trans_gen.single h\u2082)\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 {\u03c3}\n  {f : \u03c3 \u2192. option \u03c3} {b : \u03c3} {C : \u03c3 \u2192 Sort*} {a : \u03c3} (h : b \u2208 eval f a)\n  (H : \u2200 a, b \u2208 eval f a \u2192\n    (\u2200 a', f a = part.some (some a') \u2192 C a') \u2192 C a) : C a :=\nby { dsimp only [eval] at *, exact pfun.fix_induction h (\u03bb _ b ih, H _ b (\u03bb _ ha, ih _ (by simp [ha]))) }\n\ntheorem mem_eval {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b} :\n  b \u2208 eval f a \u2194 reaches f a b \u2227 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 \u27e8a'|a', ha'\u27e9, rw \u2190 part.eq_some_iff at ha',\n    { rw [eval] at hb, cases (part.mem_unique hb (pfun.fix_stop a _) : b = a),\n      { exact \u27e8by refl, ha'\u27e9, }, { simp [ha'], } },\n    specialize ih a' (by rwa part.eq_some_iff),\n    exact \u27e8(reaches_fwd ha').trans ih.1, ih.2\u27e9, },\n  { rintro \u27e8h\u2081, h\u2082\u27e9,\n    induction h\u2081 using relation.refl_trans_gen.head_induction_on with a' b' ha' hb ih,\n    { apply pfun.fix_stop, simp [h\u2082], },\n    rw [eval, pfun.fix_fwd _ b'], { exact ih, },\n    rw \u2190 part.eq_some_iff at ha', simp [ha'], }\nend\n\nlemma eval_mono {\u03c3} {f g : \u03c3 \u2192. option \u03c3} (hfg : \u2200 \u2983x y\u2984, y \u2208 f x \u2192 y \u2208 g x) {x y} (h : y \u2208 eval f x) :\n  y \u2208 eval g x :=\nby { rw [mem_eval, part.eq_some_iff] at *, exact \u27e8reaches_mono' hfg h.1, hfg h.2\u27e9, }\n\nlemma eval_eq_of_invariant {\u03c3} (f : \u03c3 \u2192. option \u03c3) (S : set \u03c3) (hS : \u2200 \u2983x y\u2984, x \u2208 S \u2192 some y \u2208 f x \u2192 y \u2208 S) {x} (hx : x \u2208 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\u2081 H\u2082, exact \u27e8reaches_of_invariant S hS hx H\u2081, invariant_of_reaches _ hS hx H\u2081, H\u2082\u27e9, } \n\n@[simp] lemma eval_next_iter_eq_none {\u03c3} (f : \u03c3 \u2192. option \u03c3) (a : \u03c3) (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\u2081 {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b : \u03c3}\n  (h : b \u2208 eval f a) (c) : \u00ac reaches\u2081 f b c | bc :=\nlet \u27e8ab, b0\u27e9 := mem_eval.1 h, \u27e8b', h', _\u27e9 := trans_gen.head'_iff.1 bc in\nby { rw b0 at h', simpa using h', }\n\ntheorem eval_maximal {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b}\n  (h : b \u2208 eval f a) {c} : reaches f b c \u2194 c = b :=\nlet \u27e8ab, b0\u27e9 := mem_eval.1 h in\nrefl_trans_gen_iff_eq $ \u03bb b' h',\nby { rw b0 at h', simpa using h', }\n\ntheorem reaches_eval {\u03c3} {f : \u03c3 \u2192. option \u03c3} {a b}\n  (ab : reaches f a b) : eval f a = eval f b :=\npart.ext $ \u03bb c,\n \u27e8\u03bb h, let \u27e8ac, c0\u27e9 := mem_eval.1 h in\n    mem_eval.2 \u27e8(or_iff_left_of_imp $ by exact\n      \u03bb cb, (eval_maximal h).1 cb \u25b8 refl_trans_gen.refl).1\n      (reaches_total ab ac), c0\u27e9,\n  \u03bb h, let \u27e8bc, c0\u27e9 := mem_eval.1 h in mem_eval.2 \u27e8ab.trans bc, c0\u27e9,\u27e9\n\n/-- Given a relation `tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop` between state spaces, and state transition functions\n`f\u2081 : \u03c3\u2081 \u2192 option \u03c3\u2081` and `f\u2082 : \u03c3\u2082 \u2192 option \u03c3\u2082`, `respects f\u2081 f\u2082 tr` means that if `tr a\u2081 a\u2082` holds\ninitially and `f\u2081` takes a step to `a\u2082` then `f\u2082` will take one or more steps before reaching a\nstate `b\u2082` satisfying `tr a\u2082 b\u2082`, and if `f\u2081 a\u2081` terminates then `f\u2082 a\u2082` also terminates.\nSuch a relation `tr` is also known as a refinement. -/\n-- def respects {\u03c3\u2081 \u03c3\u2082}\n--   (f\u2081 : \u03c3\u2081 \u2192. option \u03c3\u2081) (f\u2082 : \u03c3\u2082 \u2192. option \u03c3\u2082) (tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop) :=\n-- \u2200 \u2983a\u2081 a\u2082\u2984, tr a\u2081 a\u2082 \u2192 (match f\u2081 a\u2081 with\n--   | part.none := f\u2082 a\u2082 = part.none \n--   | part.some (some b\u2081) := \u2203 b\u2082, tr b\u2081 b\u2082 \u2227 reaches\u2081 f\u2082 a\u2082 b\u2082\n--   | part.some none := f\u2082 a\u2082 = none\n--   end : Prop)\n\nstructure respects {\u03c3\u2081 \u03c3\u2082} (f\u2081 : \u03c3\u2081 \u2192. option \u03c3\u2081) (f\u2082 : \u03c3\u2082 \u2192. option \u03c3\u2082) (tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop) : Prop :=\n(dom_of_dom : \u2200 \u2983a\u2081 a\u2082\u2984, tr a\u2081 a\u2082 \u2192 (f\u2082 a\u2082).dom \u2192 (f\u2081 a\u2081).dom)\n(some_of_some : \u2200 \u2983a\u2081 a\u2082 b\u2081\u2984, tr a\u2081 a\u2082 \u2192 some b\u2081 \u2208 (f\u2081 a\u2081) \u2192 \u2203 b\u2082, tr b\u2081 b\u2082 \u2227 reaches\u2081 f\u2082 a\u2082 b\u2082)\n(none_of_none : \u2200 \u2983a\u2081 a\u2082\u2984, tr a\u2081 a\u2082 \u2192 none \u2208 (f\u2081 a\u2081) \u2192 none \u2208 (f\u2082 a\u2082))\n\nvariables {\u03c3\u2081 \u03c3\u2082 : Type*} {f\u2081 : \u03c3\u2081 \u2192. option \u03c3\u2081} {f\u2082 : \u03c3\u2082 \u2192. option \u03c3\u2082} {tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop}\n\nlemma respects.exists_some {a\u2081 a\u2082 b\u2081} (H : respects f\u2081 f\u2082 tr) (aa : tr a\u2081 a\u2082) (hb\u2081 : some b\u2081 \u2208 f\u2081 a\u2081) :\n  \u2203 b\u2082, some b\u2082 \u2208 f\u2082 a\u2082 :=\nby { obtain \u27e8b\u2082, \u27e8_, hb\u2082\u27e9\u27e9 := H.some_of_some aa hb\u2081, rw reaches\u2081_head'_iff at hb\u2082, tauto, }\n\nlemma respects.dom_iff_domm {a\u2081 a\u2082} (H : respects f\u2081 f\u2082 tr) (aa : tr a\u2081 a\u2082) :\n  (f\u2081 a\u2081).dom \u2194 (f\u2082 a\u2082).dom :=\nbegin\n  refine \u27e8\u03bb h, _, H.dom_of_dom aa\u27e9,\n  rw [part.dom_iff_mem] at h \u22a2, cases h with b\u2081 hb,\n  cases b\u2081,\n  { use none, exact H.none_of_none aa hb, },\n  { obtain \u27e8b\u2082, hb\u2082\u27e9 := H.exists_some aa hb, exact \u27e8_, hb\u2082\u27e9, }\nend\n\nlemma respects.none_iff_none {a\u2081 a\u2082} (H : respects f\u2081 f\u2082 tr) (aa : tr a\u2081 a\u2082) :\n  none \u2208 f\u2081 a\u2081 \u2194 none \u2208 f\u2082 a\u2082 :=\nbegin\n  refine \u27e8H.none_of_none aa, \u03bb h, _\u27e9,\n  obtain \u27e8x, hx\u27e9 : \u2203 x, x \u2208 f\u2081 a\u2081, { rw [\u2190 part.dom_iff_mem, H.dom_iff_domm aa, part.dom_iff_mem], exact \u27e8_, h\u27e9, },\n  cases x, { exact hx, },\n  obtain \u27e8_, hb\u27e9 := H.exists_some aa hx, cases part.mem_unique h hb,\nend\n\nlemma respects.some_iff_some {a\u2081 a\u2082} (H : respects f\u2081 f\u2082 tr) (aa : tr a\u2081 a\u2082) :\n  (\u2203 b\u2081, some b\u2081 \u2208 f\u2081 a\u2081) \u2194 (\u2203 b\u2082, some b\u2082 \u2208 f\u2082 a\u2082) :=\nbegin\n  refine \u27e8\u03bb \u27e8b\u2081, hb\u2081\u27e9, H.exists_some aa hb\u2081, _\u27e9,\n  rintro \u27e8b\u2082, hb\u2082\u27e9,\n  obtain \u27e8x, hx\u27e9 : \u2203 x, x \u2208 f\u2081 a\u2081, { rw [\u2190 part.dom_iff_mem, H.dom_iff_domm aa, part.dom_iff_mem], exact \u27e8_, hb\u2082\u27e9, },\n  cases x, { rw H.none_iff_none aa at hx, cases part.mem_unique hb\u2082 hx, },\n  exact \u27e8_, hx\u27e9,\nend \n\ntheorem tr_reaches\u2081\n  (H : respects f\u2081 f\u2082 tr) {a\u2081 a\u2082} (aa : tr a\u2081 a\u2082) {b\u2081} (ab : reaches\u2081 f\u2081 a\u2081 b\u2081) :\n  \u2203 b\u2082, tr b\u2081 b\u2082 \u2227 reaches\u2081 f\u2082 a\u2082 b\u2082 :=\nbegin\n  induction ab with c\u2081 ac c\u2081 d\u2081 ac cd IH,\n  { exact H.some_of_some aa ac, },\n  { rcases IH with \u27e8c\u2082, cc, ac\u2082\u27e9,\n    obtain \u27e8b\u2082, \u27e8h\u2081, h\u2082\u27e9\u27e9 := H.some_of_some cc cd,\n    exact \u27e8b\u2082, \u27e8h\u2081, ac\u2082.trans h\u2082\u27e9\u27e9, }\nend\n\ntheorem tr_reaches {\u03c3\u2081 \u03c3\u2082 f\u2081 f\u2082} {tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop}\n  (H : respects f\u2081 f\u2082 tr) {a\u2081 a\u2082} (aa : tr a\u2081 a\u2082) {b\u2081} (ab : reaches f\u2081 a\u2081 b\u2081) :\n  \u2203 b\u2082, tr b\u2081 b\u2082 \u2227 reaches f\u2082 a\u2082 b\u2082 :=\nbegin\n  rcases refl_trans_gen_iff_eq_or_trans_gen.1 ab with rfl | ab,\n  { exact \u27e8_, aa, refl_trans_gen.refl\u27e9 },\n  { exact let \u27e8b\u2082, bb, h\u27e9 := tr_reaches\u2081 H aa ab in\n    \u27e8b\u2082, bb, h.to_refl\u27e9 }\nend\n\ntheorem tr_reaches_rev {\u03c3\u2081 \u03c3\u2082 f\u2081 f\u2082} {tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop}\n  (H : respects f\u2081 f\u2082 tr) {a\u2081 a\u2082} (aa : tr a\u2081 a\u2082) {b\u2082} (ab : reaches f\u2082 a\u2082 b\u2082) :\n  \u2203 c\u2081 c\u2082, reaches f\u2082 b\u2082 c\u2082 \u2227 tr c\u2081 c\u2082 \u2227 reaches f\u2081 a\u2081 c\u2081 :=\nbegin\n  induction ab with a\u2082' a\u2082'' ha\u2082 ha\u2082' ih,\n  { refine \u27e8a\u2081, a\u2082, _, aa, _\u27e9; refl, },\n  rcases ih with \u27e8c\u2081, c\u2082, c\u2082h, trh, c\u2081h\u27e9,\n  by_cases H : c\u2082 = a\u2082',\n  { subst H, clear c\u2082h,\n    obtain \u27e8c\u2081', hc\u2081'\u27e9 := (H.some_iff_some trh).mpr \u27e8_, ha\u2082'\u27e9,\n    obtain \u27e8c\u2082', hc\u2082, hc\u2082'\u27e9 := H.some_of_some trh hc\u2081', \n    exact \u27e8c\u2081', c\u2082', reaches\u2081_fwd hc\u2082' ha\u2082', hc\u2082, c\u2081h.trans (reaches_fwd hc\u2081')\u27e9, },\n  refine \u27e8c\u2081, c\u2082, _, trh, c\u2081h\u27e9,\n  simp_rw [reaches_iff_eq_or_reaches\u2081, H, false_or] at c\u2082h,\n  apply reaches\u2081_fwd c\u2082h ha\u2082',\nend\n\ntheorem tr_eval {\u03c3\u2081 \u03c3\u2082 f\u2081 f\u2082} {tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop}\n  (H : respects f\u2081 f\u2082 tr) {a\u2081 b\u2081 a\u2082} (aa : tr a\u2081 a\u2082)\n  (ab : b\u2081 \u2208 eval f\u2081 a\u2081) : \u2203 b\u2082, tr b\u2081 b\u2082 \u2227 b\u2082 \u2208 eval f\u2082 a\u2082 :=\nbegin\n  cases mem_eval.1 ab with ab b0,\n  rcases tr_reaches H aa ab with \u27e8b\u2082, bb, ab\u27e9,\n  refine \u27e8_, bb, mem_eval.2 \u27e8ab, _\u27e9\u27e9,\n  rw part.eq_some_iff at \u22a2 b0, rwa \u2190 H.none_iff_none bb,\nend\n\ntheorem tr_eval_rev {\u03c3\u2081 \u03c3\u2082 f\u2081 f\u2082} {tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop}\n  (H : respects f\u2081 f\u2082 tr) {a\u2081 b\u2082 a\u2082} (aa : tr a\u2081 a\u2082)\n  (ab : b\u2082 \u2208 eval f\u2082 a\u2082) : \u2203 b\u2081, tr b\u2081 b\u2082 \u2227 b\u2081 \u2208 eval f\u2081 a\u2081 :=\nbegin\n  cases mem_eval.1 ab with ab b0,\n  rcases tr_reaches_rev H aa ab with \u27e8c\u2081, c\u2082, bc, cc, ac\u27e9,\n  cases (refl_trans_gen_iff_eq _).1 bc,\n  swap, { intros _ h, rw b0 at h, simpa using h, },\n  refine \u27e8_, cc, mem_eval.2 \u27e8ac, _\u27e9\u27e9,\n  rw part.eq_some_iff at b0 \u22a2, rwa H.none_iff_none cc,\nend\n\ntheorem tr_eval_dom {\u03c3\u2081 \u03c3\u2082 f\u2081 f\u2082} {tr : \u03c3\u2081 \u2192 \u03c3\u2082 \u2192 Prop}\n  (H : respects f\u2081 f\u2082 tr) {a\u2081 a\u2082} (aa : tr a\u2081 a\u2082) :\n  (eval f\u2082 a\u2082).dom \u2194 (eval f\u2081 a\u2081).dom :=\n\u27e8\u03bb h, let \u27e8b\u2082, tr, h, _\u27e9 := tr_eval_rev H aa \u27e8h, rfl\u27e9 in h,\n \u03bb h, let \u27e8b\u2082, tr, h, _\u27e9 := tr_eval H aa \u27e8h, rfl\u27e9 in h\u27e9\n\n/-- A simpler version of `respects` when the state transition relation `tr` is a function. -/\nstructure frespects {\u03c3\u2081 \u03c3\u2082} (f\u2081 : \u03c3\u2081 \u2192. option \u03c3\u2081) (f\u2082 : \u03c3\u2082 \u2192. option \u03c3\u2082) (tr : \u03c3\u2081 \u2192 \u03c3\u2082) : Prop :=\n(dom_of_dom : \u2200 \u2983a : \u03c3\u2081\u2984, (f\u2082 (tr a)).dom \u2192 (f\u2081 a).dom)\n(some_of_some : \u2200 \u2983a b : \u03c3\u2081\u2984, some b \u2208 f\u2081 a \u2192 reaches\u2081 f\u2082 (tr a) (tr b))\n(none_of_none : \u2200 \u2983a\u2984, none \u2208 f\u2081 a \u2192 none \u2208 f\u2082 (tr a))\n\n/-- An even simpler version where both take only one step each time -/\nstructure fcommutes {\u03c3\u2081 \u03c3\u2082} (f\u2081 : \u03c3\u2081 \u2192. option \u03c3\u2081) (f\u2082 : \u03c3\u2082 \u2192. option \u03c3\u2082) (tr : \u03c3\u2081 \u2192 \u03c3\u2082) : Prop :=\n(dom_of_dom : \u2200 \u2983a : \u03c3\u2081\u2984, (f\u2082 (tr a)).dom \u2192 (f\u2081 a).dom)\n(some_of_some : \u2200 \u2983a b : \u03c3\u2081\u2984, some b \u2208 f\u2081 a \u2192 some (tr b) \u2208 f\u2082 (tr a))\n(none_of_none : \u2200 \u2983a\u2984, none \u2208 f\u2081 a \u2192 none \u2208 f\u2082 (tr a))\n\nvariable {ftr : \u03c3\u2081 \u2192 \u03c3\u2082}\ntheorem fcommutes.to_frespects (H : fcommutes f\u2081 f\u2082 ftr) : frespects f\u2081 f\u2082 ftr :=\n{ dom_of_dom := H.dom_of_dom,\n  some_of_some := \u03bb a b h, by { apply reaches\u2081_single, exact H.some_of_some h, },\n  none_of_none := H.none_of_none }\n\nlemma fcommutes.some_of_some' (H : fcommutes f\u2081 f\u2082 ftr) {a b : \u03c3\u2081} \n  (h : some (ftr b) \u2208 f\u2082 (ftr a)) :\n  \u2203 y, ftr y = ftr b \u2227 some y \u2208 f\u2081 a :=\nbegin\n  obtain \u27e8y, hy\u27e9 := part.dom_iff_mem.mp (H.dom_of_dom (part.dom_iff_mem.mpr \u27e8_, h\u27e9)),\n  cases y, { cases part.mem_unique h (H.none_of_none hy), },\n  refine \u27e8_, _, hy\u27e9, exact (option.some.inj (part.mem_unique h (H.some_of_some hy))).symm,\nend\n\ntheorem fun_respects : respects f\u2081 f\u2082 (\u03bb a b, ftr a = b) \u2194 frespects f\u2081 f\u2082 ftr :=\nbegin\n  split,\n  { intro H,\n    refine \u27e8\u03bb a, H.dom_of_dom rfl, \u03bb a b hab, _, \u03bb a ha, H.none_of_none rfl ha\u27e9, \n    simpa using H.some_of_some rfl hab, },\n  { intro H,\n    refine \u27e8_, _, _\u27e9, { rintro a\u2081 a\u2082 rfl h, exact H.dom_of_dom h, },\n    { rintro a\u2081 a\u2082 b\u2081 rfl h, exact \u27e8_, rfl, H.some_of_some h\u27e9, },\n    rintro a\u2081 a\u2082 rfl h, exact H.none_of_none h, }\nend\n\nlemma frespects.dom_iff_dom (H : frespects f\u2081 f\u2082 ftr) \u2983x : \u03c3\u2081\u2984 :\n  (f\u2081 x).dom \u2194 (f\u2082 (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\u2081 f\u2082 ftr) {ftr_inv : \u03c3\u2082 \u2192 \u03c3\u2081} (hinv : function.right_inverse ftr_inv ftr) :\n--   fcommutes f\u2082 f\u2081 ftr_inv :=\n-- { dom_of_dom := \u03bb a, by simp [(fun_respects.mpr H.to_frespects).dom_iff_domm (hinv a)],\n--   some_of_some := \u03bb a b h,\n-- begin\n--   rw [\u2190 hinv b, \u2190 hinv a] at h, have := H.some_of_some' h,\n-- end,\n--   none_of_none := _ }\n\ntheorem frespects.eval_eq (H : frespects f\u2081 f\u2082 ftr)\n  (a\u2081 : \u03c3\u2081) : eval f\u2082 (ftr a\u2081) = (eval f\u2081 a\u2081).map ftr :=\nbegin\n  rw \u2190 fun_respects at H,\n  apply part.ext', { exact tr_eval_dom H rfl, },\n  intros h\u2082 h\u2081, simp at h\u2081,\n  have := tr_eval H rfl (part.get_mem h\u2081),\n  simp at this \u22a2, rwa part.get_eq_iff_mem,\nend\n\ntheorem frespects.of_eval (H : frespects f\u2081 f\u2082 ftr)\n  {a b : \u03c3\u2081} (h : b \u2208 eval f\u2081 a) : (ftr b) \u2208 eval f\u2082 (ftr a) :=\nby { rw H.eval_eq, exact part.mem_map ftr h, }\n\ntheorem frespects.none_iff_none (H : frespects f\u2081 f\u2082 ftr) (a : \u03c3\u2081) :\n  none \u2208 f\u2081 a \u2194 none \u2208 f\u2082 (ftr a) :=\nby { rw \u2190 fun_respects at H, rw H.none_iff_none rfl, }\n\ntheorem frespects.eval_dom (H : frespects f\u2081 f\u2082 ftr) (x : \u03c3\u2081) :\n  (eval f\u2082 (ftr x)).dom \u2194 (eval f\u2081 x).dom := by simp [H.eval_eq]\n\ntheorem frespects.eval_get_eq (H : frespects f\u2081 f\u2082 ftr) (a : \u03c3\u2081) :\n  \u2200 h, ftr ((eval f\u2081 a).get h) = (eval f\u2082 (ftr a)).get (by rwa H.eval_dom) :=\nby { intros, simp [H.eval_eq], refl, }\n\nsection track_with\nvariables {\u03c3 \u03b1 : Type*} (f : \u03c3 \u2192. option \u03c3) (t : \u03c3 \u2192. \u2115)\n\ndef with_time : \u2115 \u00d7 \u03c3 \u2192. option (\u2115 \u00d7 \u03c3) :=\n\u03bb tx, (f tx.2).bind (\u03bb r\u2081, (t tx.2).bind (\u03bb r\u2082 : \u2115, part.some (r\u2081.map $ \u03bb r\u2081', (tx.1 + r\u2082, r\u2081'))))\n\ntheorem with_time_respects {f : \u03c3 \u2192. option \u03c3} {t : \u03c3 \u2192. \u2115} (ht : \u2200 x, (t x).dom \u2194 (f x).dom) : frespects (with_time f t) f prod.snd :=\n{ dom_of_dom := \u03bb a, by simp [with_time, ht],\n  some_of_some := \u03bb \u27e8a\u2081, x\u2081\u27e9 \u27e8a\u2082, x\u2082\u27e9 h, by { apply reaches\u2081_single, simp [with_time] at h, rcases h with \u27e8_, h, _, _, rfl, rfl\u27e9, exact h, },\n  none_of_none := \u03bb \u27e8a, x\u27e9, by { simp [with_time], exact \u03bb h _ _, h, } }\n\ntheorem with_time_respects_self (n : \u2115) : frespects (with_time f t) (with_time f t) (prod.map (+n) id) :=\n{ dom_of_dom := \u03bb a, by { simp [with_time], exact and.intro, },\n  some_of_some := \u03bb \u27e8a\u2081, x\u2081\u27e9 \u27e8a\u2082, x\u2082\u27e9 h, \nbegin\n  apply reaches\u2081_single,\n  simp [with_time] at h \u22a2,\n  rcases h with \u27e8a, ha, t, ht\u2081, rfl, rfl\u27e9,\n  exact \u27e8_, ha, t, ht\u2081, rfl, by ac_refl\u27e9,\nend,\n  none_of_none := by { simp [with_time], tauto, } }\n\ndef time_iter : \u03c3 \u2192. \u2115 :=\n\u03bb s, (eval (with_time f t) (0, s)).bind (\u03bb r, (t r.2).map (+r.1))\n\nvariables {f t}\nlemma with_time_restrict (S : set \u03c3) :\n  with_time (f.res_inter S) t = (with_time f t).res_inter (prod.snd\u207b\u00b9' S) :=\nby { ext, simp [with_time], tauto, }\n\ntheorem time_iter_dom_iff (ht : \u2200 x, (t x).dom \u2194 (f x).dom) {x} :\n  (time_iter f t x).dom \u2194 (eval f x).dom :=\nbegin\n  simp [time_iter],\n  have := with_time_respects ht,\n  simp_rw [\u2190 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 : \u03c3 \u2192. option \u03c3} (hfg : \u2200 \u2983x y\u2984, y \u2208 f x \u2192 y \u2208 g x) :\n  \u2200 \u2983x y\u2984, y \u2208 with_time f t x \u2192 y \u2208 with_time g t x := by { simp [with_time], tauto, }\n\nlemma time_iter_mono {g : \u03c3 \u2192. option \u03c3} (hfg : \u2200 \u2983x y\u2984, y \u2208 f x \u2192 y \u2208 g x) {x y} (hx : y \u2208 time_iter f t x) :\n  y \u2208 time_iter g t x :=\nbegin\n  simp [time_iter] at hx \u22a2, rcases hx with \u27e8a, b, h\u2081, \u27e8a', h\u2082, rfl\u27e9\u27e9,\n  refine \u27e8a, b, _, \u27e8a', h\u2082, rfl\u27e9\u27e9, apply eval_mono (with_time_mono hfg) h\u2081,\nend\n\ntheorem time_iter_eq_iff (ht : \u2200 x, (t x).dom \u2194 (f x).dom) (x : \u03c3) (n : \u2115) :\n  n \u2208 time_iter f t x \u2194 \u2203 t' b, reaches (with_time f t) (0, x) (t', b) \u2227 none \u2208 f b \u2227 n \u2208 (+t') <$> (t b) :=\nbegin\n  simp [time_iter, mem_eval],\n  apply exists\u2082_congr, intros a b,\n  conv_lhs { rw and_assoc, }, apply and_congr, { refl, },\n  apply and_congr, { rw \u2190 (with_time_respects ht).none_iff_none (a, b), exact part.eq_some_iff, }, { refl, },\nend\n\n\nlemma time_iter_invariant {g : \u03c3 \u2192. option \u03c3} (S : set \u03c3) (hS : \u2200 \u2983x y\u2984, x \u2208 S \u2192 some y \u2208 g x \u2192 y \u2208 S) {x} (hx : x \u2208 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\u207b\u00b9' S), { simp [with_time_restrict], },\n  { rintros \u27e8x\u2081, x\u2082\u27e9 \u27e8y\u2081, y\u2082\u27e9, simp [with_time], rintros hx\u2082 x' hx' t' ht' rfl rfl, exact hS hx\u2082 hx', },\n  simpa, \nend\n\ntheorem time_iter_eq_iff_of_eval (ht : \u2200 x, (t x).dom \u2194 (f x).dom) {x n b} (hb : b \u2208 eval f x) :\n  n \u2208 time_iter f t x \u2194 \u2203 t', reaches (with_time f t) (0, x) (t', b) \u2227 none \u2208 f b \u2227 n \u2208 (+t') <$> (t b) :=\nbegin\n  suffices : \u2200 {t' b'}, reaches (with_time f t) (0, x) (t', b') \u2192 none \u2208 f b' \u2192 b = b',\n  { rw time_iter_eq_iff ht, apply exists_congr, intro n, split, { rintro \u27e8b, h\u2081, h\u2082, h\u2083\u27e9, cases this h\u2081 h\u2082, tauto, }, intro, use b, tauto, },\n  intros n b' h\u2081 h\u2082, rw [\u2190 (with_time_respects ht).none_iff_none (n, b'), \u2190 part.eq_some_iff] at h\u2082,\n  exact part.mem_unique hb ((with_time_respects ht).of_eval (mem_eval.mpr \u27e8h\u2081, h\u2082\u27e9)),\nend\n\n@[simp] lemma one_def : (1 : part \u2115) = part.some 1 := rfl\n\nlemma time_eval_const_respects (ht : \u2200 \u2983x\u2984, (f x).dom \u2192 (t x).dom) (J : \u2115) :\n  respects (with_time (f.res_inter {s | \u2200 k \u2208 t s, k \u2264 J}) (\u03bb _, 1))\n           (with_time (f.res_inter {s | \u2200 k \u2208 t s, k \u2264 J}) t) \n           (\u03bb s\u2081 s\u2082, s\u2081.2 = s\u2082.2 \u2227 s\u2082.1 \u2264 J * s\u2081.1) :=\n{ dom_of_dom := by { rintro \u27e8t\u2081, s\u27e9 \u27e8t\u2082, s\u27e9, dsimp only, rintro \u27e8rfl, _\u27e9, simp [with_time], tauto, },\n  some_of_some := \nbegin\n  rintro \u27e8t\u2081, s\u2081\u27e9 \u27e8t\u2082, s\u2081\u27e9 \u27e8t\u2083, s\u2082\u27e9, dsimp only, rintro \u27e8rfl, hb\u27e9,\n  simp [with_time], rintros s\u2082' hs hn rfl rfl, \n  rcases part.dom_iff_mem.mp (ht (part.dom_iff_mem.mpr \u27e8_, hn\u27e9)) with \u27e8tn, htn\u27e9,\n  use [t\u2082 + tn, s\u2082, rfl], { mono, }, apply reaches\u2081_single, simp, refine \u27e8\u27e8_, _\u27e9, _\u27e9; assumption,\nend,\n  none_of_none :=\nbegin\n  rintro \u27e8t\u2081, s\u2081\u27e9 \u27e8t\u2082, s\u2081\u27e9, dsimp only, rintro \u27e8rfl, _\u27e9,\n  simp [with_time, \u2190 part.dom_iff_mem],\n  refine \u03bb h\u2081 h\u2082, \u27e8\u27e8h\u2081, h\u2082\u27e9, ht _\u27e9, rw part.dom_iff_mem, exact \u27e8_, h\u2082\u27e9,\nend }\n\nlemma with_time_le_of_iters_le {x : \u03c3} {n J : \u2115} (ht : \u2200 x, (f x).dom \u2192 (t x).dom)\n  (h : n \u2208 time_iter (f.res_inter {s | \u2200 k \u2208 t s, k \u2264 J}) (pfun.pure 1) x) :\n  \u2203 k \u2208 time_iter f t x, k \u2264 n * J :=\nbegin\n  simp [time_iter, pfun.pure] at h, rcases h with \u27e8n, \u27e8\u27e8s, hs\u27e9, rfl\u27e9\u27e9,\n  obtain \u27e8\u27e8tf, sf\u27e9, h\u2081, h\u2082\u27e9 := tr_eval (time_eval_const_respects ht J) _ hs, swap, { use (0, x), }, swap, { split; refl, },\n  dsimp only at h\u2081, rcases h\u2081 with \u27e8rfl, h\u2081\u27e9,\n  simp [time_iter],\n  obtain \u27e8tl, htl, tl_le\u27e9 : \u2203 tl \u2208 t s, tl \u2264 J,\n  { rw mem_eval at h\u2082, rcases h\u2082 with \u27e8_, h\u2082\u27e9, simp [part.eq_some_iff, with_time] at h\u2082,\n    rcases h\u2082 with \u27e8\u27e8H, _\u27e9, \u27e8tl, htl\u27e9\u27e9, use [tl, htl, H _ htl], },\n  refine \u27e8tf + tl, \u27e8\u27e8tf, s, _, \u27e8tl, htl, by ac_refl\u27e9\u27e9, _\u27e9\u27e9,\n  { apply eval_mono (with_time_mono _) h\u2082, simp, },\n  conv_rhs { rw [add_mul, add_comm], }, mono, { rw mul_comm, exact h\u2081, }, simpa using tl_le,\nend\n\ntheorem fcommutes.to_time_frespects (H : fcommutes f\u2081 f\u2082 ftr) :\n  fcommutes (with_time f\u2081 (pfun.pure 1)) (with_time f\u2082 (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\u2081 b\u2081 \u27e8a\u2082, b\u2082\u27e9 x hx x rfl,\n  simp, rintro rfl rfl, refine \u27e8some (ftr x), _, rfl, rfl\u27e9,\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\u2081 f\u2082 ftr) (x : \u03c3\u2081) :\n  time_iter f\u2081 (pfun.pure 1) x = time_iter f\u2082 (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\u2081 f\u2082 ftr) (S : set \u03c3\u2082) :\n  fcommutes (f\u2081.res_inter (ftr\u207b\u00b9' S)) (f\u2082.res_inter S) ftr :=\n{ dom_of_dom := \u03bb x, by { simp, rw \u2190 H.to_frespects.dom_iff_dom, tauto, },\n  some_of_some := \u03bb a b, by { simp, intros h\u2081 h\u2082, exact \u27e8h\u2081, H.some_of_some h\u2082\u27e9, },\n  none_of_none := \u03bb a, by { simp, intros h\u2081 h\u2082, exact \u27e8h\u2081, H.none_of_none h\u2082\u27e9, } } \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 [] (\u03bb e n l, (e,n) :: l)\n-- constant \u03b1 : Type\n-- constant f : \u03b1 \u2192 \u03b1\n-- example : true := \n-- begin\n--   (to_expr ```(\u03bb x : \u03b1, (\u03bb y, x) $ f $ f x) >>= fold_test)\n-- end\n\n/-- Returns the condition of a  -/\nmeta def find_if_cond : expr \u2192 option expr | e := -- note the `| e` style.\ne.fold none $ \u03bb e _ acc, acc <|> do\n    c \u2190 match e with\n        | `(@ite %%c %%_ _ _ _) := some c\n        | `(@dite %%c %%_ _ _ _) := some c\n        | _ := none\n        end,\n    guard \u00acc.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 \u2190 at_.get_locals, -- get the local context\nlctx \u2190 lctx.mmap infer_type, --get the types\ntgt \u2190 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 \u2190 get_user_simp_lemmas `split_if_reduction,\nlet cfg : simp_config := { fail_if_unchanged := ff },\nlet discharger := assumption <|> (applyc `not_not_intro >> assumption),\nhs \u2190 at_.get_locals, \nhs.mmap' (\u03bb 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 \u2190 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 `(\u00ac%%c) $> tt)\n<|> (pure ff)\n\nprivate meta def split_ifs_core (at_: loc) (names : ref (list name)) : list expr \u2192 tactic unit := \u03bb done, do\nsome cond \u2190 find_if_cond_at at_ | fail \"no ite or dite expressions found\",\nlet cond := match cond with `(\u00ac%%p) := p | p := p end, -- strip off the \u00ac\nif cond \u2208 done then skip else do -- skip conditions which have already been done.\nno_split \u2190 value_known cond,\nif no_split then do\n    reduce_ifs_at at_,\n    try (split_ifs_core (cond :: done)) \nelse do\n    n \u2190 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 $ \u03bb 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 \u22a2 g x` and `\u00acp \u22a2 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\u2081 h\u2082 h\u2083` 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 : \u2200 g : M, (g \u2022 (1 : R) : R) = 1\n  /-- Scalara multiplication distributes across multiplication -/\n  smul_mul : \u2200 (g : M) (x y : R), g \u2022 (x * y) = g \u2022 x * g \u2022 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 \u2192+* 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 \u2243+* 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' \u2022 m`.\nSee note [reducible non-instances]. -/\n@[reducible]\ndef MulSemiringAction.compHom (f : N \u2192* 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 \u2022 m\u207b\u00b9 = (x \u2022 m)\u207b\u00b9 :=\n  map_inv\u2080 (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* \u2192 Type* \u2192 Type*` along with a bimap which turns `F \u03b1 \u03b2` into\n`F \u03b1' \u03b2'` given two functions `\u03b1 \u2192 \u03b1'` and `\u03b2 \u2192 \u03b2'`. It further\n* respects the identity: `bimap id id = id`\n* composes in the obvious way: `(bimap f' g') \u2218 (bimap f g) = bimap (f' \u2218 f) (g' \u2218 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\u2080 u\u2081 u\u2082 v\u2080 v\u2081 v\u2082\n\nopen function\n\n/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/\nclass bifunctor (F : Type u\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082) :=\n(bimap : \u03a0 {\u03b1 \u03b1' \u03b2 \u03b2'}, (\u03b1 \u2192 \u03b1') \u2192 (\u03b2 \u2192 \u03b2') \u2192 F \u03b1 \u03b2 \u2192 F \u03b1' \u03b2')\nexport bifunctor ( bimap )\n\n/-- Bifunctor. This typeclass asserts that a lawless `bifunctor` is lawful. -/\nclass is_lawful_bifunctor (F : Type u\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082) [bifunctor F] :=\n(id_bimap : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), bimap id id x = x)\n(bimap_bimap : \u03a0 {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 \u03b2\u2080 \u03b2\u2081 \u03b2\u2082} (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b1\u2081 \u2192 \u03b1\u2082)\n  (g : \u03b2\u2080 \u2192 \u03b2\u2081) (g' : \u03b2\u2081 \u2192 \u03b2\u2082) (x : F \u03b1\u2080 \u03b2\u2080),\n  bimap f' g' (bimap f g x) = bimap (f' \u2218 f) (g' \u2218 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\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082} [bifunctor F]\n\nnamespace bifunctor\n\n/-- Left map of a bifunctor. -/\n@[reducible] def fst {\u03b1 \u03b1' \u03b2} (f : \u03b1 \u2192 \u03b1') : F \u03b1 \u03b2 \u2192 F \u03b1' \u03b2 := bimap f id\n\n/-- Right map of a bifunctor. -/\n@[reducible] def snd {\u03b1 \u03b2 \u03b2'} (f : \u03b2 \u2192 \u03b2') : F \u03b1 \u03b2 \u2192 F \u03b1 \u03b2' := bimap id f\n\nvariable [is_lawful_bifunctor F]\n\n@[higher_order fst_id]\nlemma id_fst : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), fst id x = x :=\n@id_bimap _ _ _\n\n@[higher_order snd_id]\nlemma id_snd : \u03a0 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), 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 {\u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081}\n  (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b2\u2080 \u2192 \u03b2\u2081) (x : F \u03b1\u2080 \u03b2\u2080) :\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 {\u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081}\n  (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b2\u2080 \u2192 \u03b2\u2081) (x : F \u03b1\u2080 \u03b2\u2080) :\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 {\u03b1 \u03b2\u2080 \u03b2\u2081 \u03b2\u2082}\n  (g : \u03b2\u2080 \u2192 \u03b2\u2081) (g' : \u03b2\u2081 \u2192 \u03b2\u2082) (x : F \u03b1 \u03b2\u2080) :\n  snd g' (snd g x) = snd (g' \u2218 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 := (\u03bb \u03b1 \u03b1' \u03b2 \u03b2 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 := (\u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (bimap f' f x : F \u03b2' \u03b1')) }\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 {\u03b1} : functor (F \u03b1) :=\n{ map := \u03bb _ _, snd }\n\n@[priority 10]\ninstance bifunctor.is_lawful_functor [is_lawful_bifunctor F] {\u03b1} : is_lawful_functor (F \u03b1) :=\nby refine {..}; intros; simp [functor.map] with functor_norm\n\nsection bicompl\n\nvariables (G : Type* \u2192 Type u\u2080) (H : Type* \u2192 Type u\u2081) [functor G] [functor H]\n\ninstance : bifunctor (bicompl F G H) :=\n{ bimap := \u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (bimap (map f) (map f') x : F (G \u03b1') (H \u03b2')) }\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\u2082 \u2192 Type*) [functor G]\n\ninstance : bifunctor (bicompr G F) :=\n{ bimap := \u03bb \u03b1 \u03b1' \u03b2 \u03b2' f f' x, (map (bimap f f') x : G (F \u03b1' \u03b2')) }\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u03b1` and a type `M` with zero, we define the type `finsupp \u03b1 M` (notation: `\u03b1 \u2192\u2080 M`)\nof finitely supported functions from `\u03b1` to `M`, i.e. the functions which are zero everywhere\non `\u03b1` 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 \u2192\u2080 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 : (\u03b9 \u2192 M) \u2192 (\u03b9 \u2192\u2080 R) \u2192\u2097[R] M`.\n\nSome other constructions are naturally equivalent to `\u03b1 \u2192\u2080 M` with some `\u03b1` and `M` but are defined\nin a different way in the library:\n\n* `multiset \u03b1 \u2243+ \u03b1 \u2192\u2080 \u2115`;\n* `free_abelian_group \u03b1 \u2243+ \u03b1 \u2192\u2080 \u2124`.\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 `\u03b1 \u2192\u2080 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 `\u03b1 \u2192\u2080 M` as a global notation for `finsupp \u03b1 M`. We also use the following convention\nfor `Type*` variables in this file\n\n* `\u03b1`, `\u03b2`, `\u03b3`: types with no additional structure that appear as the first argument to `finsupp`\n  somewhere in the statement;\n\n* `\u03b9` : 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 `\u03b1 \u2192\u2080 \u03b2` as notation for `finsupp \u03b1 \u03b2`.\n\n-/\n\n/-- `finsupp \u03b1 M`, denoted `\u03b1 \u2192\u2080 M`, is the type of functions `f : \u03b1 \u2192 M` such that\n  `f x = 0` for all but finitely many `x`. -/\nstructure finsupp (\u03b1 : Type u_13) (M : Type u_14) [HasZero M] where\n  support : finset \u03b1\n  to_fun : \u03b1 \u2192 M\n  mem_support_to_fun : \u2200 (a : \u03b1), a \u2208 support \u2194 to_fun a \u2260 0\n\ninfixr:25 \" \u2192\u2080 \" => Mathlib.finsupp\n\nnamespace finsupp\n\n\n/-! ### Basic declarations about `finsupp` -/\n\nprotected instance has_coe_to_fun {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] :\n    has_coe_to_fun (\u03b1 \u2192\u2080 M) :=\n  has_coe_to_fun.mk (fun (_x : \u03b1 \u2192\u2080 M) => \u03b1 \u2192 M) to_fun\n\n@[simp] theorem coe_mk {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (f : \u03b1 \u2192 M) (s : finset \u03b1)\n    (h : \u2200 (a : \u03b1), a \u2208 s \u2194 f a \u2260 0) : \u21d1(mk s f h) = f :=\n  rfl\n\nprotected instance has_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] : HasZero (\u03b1 \u2192\u2080 M) :=\n  { zero := mk \u2205 (fun (_x : \u03b1) => 0) sorry }\n\n@[simp] theorem coe_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] : \u21d10 = fun (_x : \u03b1) => 0 := rfl\n\ntheorem zero_apply {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} : coe_fn 0 a = 0 := rfl\n\n@[simp] theorem support_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] : support 0 = \u2205 := rfl\n\nprotected instance inhabited {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] : Inhabited (\u03b1 \u2192\u2080 M) :=\n  { default := 0 }\n\n@[simp] theorem mem_support_iff {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {a : \u03b1} :\n    a \u2208 support f \u2194 coe_fn f a \u2260 0 :=\n  mem_support_to_fun f\n\n@[simp] theorem fun_support_eq {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (f : \u03b1 \u2192\u2080 M) :\n    function.support \u21d1f = \u2191(support f) :=\n  set.ext fun (x : \u03b1) => iff.symm mem_support_iff\n\ntheorem not_mem_support_iff {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {a : \u03b1} :\n    \u00aca \u2208 support f \u2194 coe_fn f a = 0 :=\n  iff.mp not_iff_comm (iff.symm mem_support_iff)\n\ntheorem coe_fn_injective {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] :\n    function.injective fun (f : \u03b1 \u2192\u2080 M) (x : \u03b1) => coe_fn f x :=\n  sorry\n\ntheorem ext {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192\u2080 M}\n    (h : \u2200 (a : \u03b1), coe_fn f a = coe_fn g a) : f = g :=\n  coe_fn_injective (funext h)\n\ntheorem ext_iff {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192\u2080 M} :\n    f = g \u2194 \u2200 (a : \u03b1), coe_fn f a = coe_fn g a :=\n  { mp := fun (\u1fb0 : f = g) (a : \u03b1) => Eq._oldrec (Eq.refl (coe_fn f a)) \u1fb0, mpr := ext }\n\ntheorem ext_iff' {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192\u2080 M} :\n    f = g \u2194 support f = support g \u2227 \u2200 (x : \u03b1), x \u2208 support f \u2192 coe_fn f x = coe_fn g x :=\n  sorry\n\n@[simp] theorem support_eq_empty {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} :\n    support f = \u2205 \u2194 f = 0 :=\n  sorry\n\ntheorem card_support_eq_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} :\n    finset.card (support f) = 0 \u2194 f = 0 :=\n  sorry\n\nprotected instance finsupp.decidable_eq {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] [DecidableEq \u03b1]\n    [DecidableEq M] : DecidableEq (\u03b1 \u2192\u2080 M) :=\n  fun (f g : \u03b1 \u2192\u2080 M) =>\n    decidable_of_iff (support f = support g \u2227 \u2200 (a : \u03b1), a \u2208 support f \u2192 coe_fn f a = coe_fn g a)\n      sorry\n\ntheorem finite_supp {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (f : \u03b1 \u2192\u2080 M) :\n    set.finite (set_of fun (a : \u03b1) => coe_fn f a \u2260 0) :=\n  Nonempty.intro (fintype.of_finset (support f) fun (_x : \u03b1) => mem_support_iff)\n\ntheorem support_subset_iff {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {s : set \u03b1} {f : \u03b1 \u2192\u2080 M} :\n    \u2191(support f) \u2286 s \u2194 \u2200 (a : \u03b1), \u00aca \u2208 s \u2192 coe_fn f a = 0 :=\n  sorry\n\n/-- Given `fintype \u03b1`, `equiv_fun_on_fintype` is the `equiv` between `\u03b1 \u2192\u2080 \u03b2` and `\u03b1 \u2192 \u03b2`.\n  (All functions on a finite type are finitely supported.) -/\ndef equiv_fun_on_fintype {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] [fintype \u03b1] :\n    (\u03b1 \u2192\u2080 M) \u2243 (\u03b1 \u2192 M) :=\n  equiv.mk (fun (f : \u03b1 \u2192\u2080 M) (a : \u03b1) => coe_fn f a)\n    (fun (f : \u03b1 \u2192 M) => mk (finset.filter (fun (a : \u03b1) => f a \u2260 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 {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (a : \u03b1) (b : M) : \u03b1 \u2192\u2080 M :=\n  mk (ite (b = 0) \u2205 (singleton a)) (fun (a' : \u03b1) => ite (a = a') b 0) sorry\n\ntheorem single_apply {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {a' : \u03b1} {b : M} :\n    coe_fn (single a b) a' = ite (a = a') b 0 :=\n  rfl\n\ntheorem single_eq_indicator {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M} :\n    \u21d1(single a b) = set.indicator (singleton a) fun (_x : \u03b1) => b :=\n  sorry\n\n@[simp] theorem single_eq_same {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M} :\n    coe_fn (single a b) a = b :=\n  if_pos rfl\n\n@[simp] theorem single_eq_of_ne {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {a' : \u03b1} {b : M}\n    (h : a \u2260 a') : coe_fn (single a b) a' = 0 :=\n  if_neg h\n\ntheorem single_eq_update {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M} :\n    \u21d1(single a b) = function.update 0 a b :=\n  sorry\n\n@[simp] theorem single_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} : single a 0 = 0 :=\n  sorry\n\ntheorem single_of_single_apply {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (a : \u03b1) (a' : \u03b1) (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 {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M}\n    (hb : b \u2260 0) : support (single a b) = singleton a :=\n  if_neg hb\n\ntheorem support_single_subset {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M} :\n    support (single a b) \u2286 singleton a :=\n  sorry\n\ntheorem single_apply_mem {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M} (x : \u03b1) :\n    coe_fn (single a b) x \u2208 insert 0 (singleton b) :=\n  sorry\n\ntheorem range_single_subset {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M} :\n    set.range \u21d1(single a b) \u2286 insert 0 (singleton b) :=\n  iff.mpr set.range_subset_iff single_apply_mem\n\ntheorem single_injective {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (a : \u03b1) :\n    function.injective (single a) :=\n  sorry\n\ntheorem single_apply_eq_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {x : \u03b1} {b : M} :\n    coe_fn (single a b) x = 0 \u2194 x = a \u2192 b = 0 :=\n  sorry\n\ntheorem mem_support_single {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (a : \u03b1) (a' : \u03b1) (b : M) :\n    a \u2208 support (single a' b) \u2194 a = a' \u2227 b \u2260 0 :=\n  sorry\n\ntheorem eq_single_iff {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {a : \u03b1} {b : M} :\n    f = single a b \u2194 support f \u2286 singleton a \u2227 coe_fn f a = b :=\n  sorry\n\ntheorem single_eq_single_iff {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b\u2081 : M)\n    (b\u2082 : M) : single a\u2081 b\u2081 = single a\u2082 b\u2082 \u2194 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082 \u2228 b\u2081 = 0 \u2227 b\u2082 = 0 :=\n  sorry\n\ntheorem single_left_inj {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {a' : \u03b1} {b : M}\n    (h : b \u2260 0) : single a b = single a' b \u2194 a = a' :=\n  sorry\n\n@[simp] theorem single_eq_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M} :\n    single a b = 0 \u2194 b = 0 :=\n  sorry\n\ntheorem single_swap {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b : M) :\n    coe_fn (single a\u2081 b) a\u2082 = coe_fn (single a\u2082 b) a\u2081 :=\n  sorry\n\nprotected instance nontrivial {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] [Nonempty \u03b1]\n    [nontrivial M] : nontrivial (\u03b1 \u2192\u2080 M) :=\n  nonempty.elim_to_inhabited\n    fun (inst : Inhabited \u03b1) =>\n      Exists.dcases_on (exists_ne 0)\n        fun (x : M) (hx : x \u2260 0) =>\n          nontrivial_of_ne (single Inhabited.default x) 0 (mt (iff.mp single_eq_zero) hx)\n\ntheorem unique_single {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] [unique \u03b1] (x : \u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] [unique \u03b1] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192\u2080 M}\n    (h : coe_fn f Inhabited.default = coe_fn g Inhabited.default) : f = g :=\n  ext\n    fun (a : \u03b1) =>\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 {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] [unique \u03b1] {f : \u03b1 \u2192\u2080 M}\n    {g : \u03b1 \u2192\u2080 M} : f = g \u2194 coe_fn f Inhabited.default = coe_fn g Inhabited.default :=\n  { mp := fun (h : f = g) => h \u25b8 rfl, mpr := unique_ext }\n\n@[simp] theorem unique_single_eq_iff {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {a' : \u03b1}\n    {b : M} [unique \u03b1] {b' : M} : single a b = single a' b' \u2194 b = b' :=\n  sorry\n\ntheorem support_eq_singleton {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {a : \u03b1} :\n    support f = singleton a \u2194 coe_fn f a \u2260 0 \u2227 f = single a (coe_fn f a) :=\n  sorry\n\ntheorem support_eq_singleton' {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {a : \u03b1} :\n    support f = singleton a \u2194 \u2203 (b : M), \u2203 (H : b \u2260 0), f = single a b :=\n  sorry\n\ntheorem card_support_eq_one {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} :\n    finset.card (support f) = 1 \u2194 \u2203 (a : \u03b1), coe_fn f a \u2260 0 \u2227 f = single a (coe_fn f a) :=\n  sorry\n\ntheorem card_support_eq_one' {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} :\n    finset.card (support f) = 1 \u2194 \u2203 (a : \u03b1), \u2203 (b : M), \u2203 (H : b \u2260 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 {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (s : finset \u03b1) (f : \u03b1 \u2192 M)\n    (hf : \u2200 (a : \u03b1), f a \u2260 0 \u2192 a \u2208 s) : \u03b1 \u2192\u2080 M :=\n  mk (finset.filter (fun (a : \u03b1) => f a \u2260 0) s) f sorry\n\n@[simp] theorem on_finset_apply {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {s : finset \u03b1} {f : \u03b1 \u2192 M}\n    {hf : \u2200 (a : \u03b1), f a \u2260 0 \u2192 a \u2208 s} {a : \u03b1} : coe_fn (on_finset s f hf) a = f a :=\n  rfl\n\n@[simp] theorem support_on_finset_subset {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {s : finset \u03b1}\n    {f : \u03b1 \u2192 M} {hf : \u2200 (a : \u03b1), f a \u2260 0 \u2192 a \u2208 s} : support (on_finset s f hf) \u2286 s :=\n  finset.filter_subset (fun (a : \u03b1) => f a \u2260 0) s\n\n@[simp] theorem mem_support_on_finset {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {s : finset \u03b1}\n    {f : \u03b1 \u2192 M} (hf : \u2200 (a : \u03b1), f a \u2260 0 \u2192 a \u2208 s) {a : \u03b1} :\n    a \u2208 support (on_finset s f hf) \u2194 f a \u2260 0 :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (a \u2208 support (on_finset s f hf) \u2194 f a \u2260 0)) (propext mem_support_iff)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (coe_fn (on_finset s f hf) a \u2260 0 \u2194 f a \u2260 0)) on_finset_apply))\n      (iff.refl (f a \u2260 0)))\n\ntheorem support_on_finset {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {s : finset \u03b1} {f : \u03b1 \u2192 M}\n    (hf : \u2200 (a : \u03b1), f a \u2260 0 \u2192 a \u2208 s) :\n    support (on_finset s f hf) = finset.filter (fun (a : \u03b1) => f a \u2260 0) s :=\n  rfl\n\n/-! ### Declarations about `map_range` -/\n\n/-- The composition of `f : M \u2192 N` and `g : \u03b1 \u2192\u2080 M` is\n`map_range f hf g : \u03b1 \u2192\u2080 N`, well-defined when `f 0 = 0`. -/\ndef map_range {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [HasZero N] (f : M \u2192 N)\n    (hf : f 0 = 0) (g : \u03b1 \u2192\u2080 M) : \u03b1 \u2192\u2080 N :=\n  on_finset (support g) (f \u2218 \u21d1g) sorry\n\n@[simp] theorem map_range_apply {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [HasZero N]\n    {f : M \u2192 N} {hf : f 0 = 0} {g : \u03b1 \u2192\u2080 M} {a : \u03b1} :\n    coe_fn (map_range f hf g) a = f (coe_fn g a) :=\n  rfl\n\n@[simp] theorem map_range_zero {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [HasZero N]\n    {f : M \u2192 N} {hf : f 0 = 0} : map_range f hf 0 = 0 :=\n  sorry\n\ntheorem support_map_range {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [HasZero N]\n    {f : M \u2192 N} {hf : f 0 = 0} {g : \u03b1 \u2192\u2080 M} : support (map_range f hf g) \u2286 support g :=\n  support_on_finset_subset\n\n@[simp] theorem map_range_single {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [HasZero N] {f : M \u2192 N} {hf : f 0 = 0} {a : \u03b1} {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 : \u03b1 \u21aa \u03b2` and `v : \u03b1 \u2192\u2080 M`, `emb_domain f v : \u03b2 \u2192\u2080 M`\nis the finitely supported function whose value at `f a : \u03b2` is `v a`.\nFor a `b : \u03b2` outside the range of `f`, it is zero. -/\ndef emb_domain {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M] (f : \u03b1 \u21aa \u03b2) (v : \u03b1 \u2192\u2080 M) :\n    \u03b2 \u2192\u2080 M :=\n  mk (finset.map f (support v))\n    (fun (a\u2082 : \u03b2) =>\n      dite (a\u2082 \u2208 finset.map f (support v))\n        (fun (h : a\u2082 \u2208 finset.map f (support v)) =>\n          coe_fn v (finset.choose (fun (a\u2081 : \u03b1) => coe_fn f a\u2081 = a\u2082) (support v) sorry))\n        fun (h : \u00aca\u2082 \u2208 finset.map f (support v)) => 0)\n    sorry\n\n@[simp] theorem support_emb_domain {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M]\n    (f : \u03b1 \u21aa \u03b2) (v : \u03b1 \u2192\u2080 M) : support (emb_domain f v) = finset.map f (support v) :=\n  rfl\n\n@[simp] theorem emb_domain_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M]\n    (f : \u03b1 \u21aa \u03b2) : emb_domain f 0 = 0 :=\n  rfl\n\n@[simp] theorem emb_domain_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M]\n    (f : \u03b1 \u21aa \u03b2) (v : \u03b1 \u2192\u2080 M) (a : \u03b1) : coe_fn (emb_domain f v) (coe_fn f a) = coe_fn v a :=\n  sorry\n\ntheorem emb_domain_notin_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M] (f : \u03b1 \u21aa \u03b2)\n    (v : \u03b1 \u2192\u2080 M) (a : \u03b2) (h : \u00aca \u2208 set.range \u21d1f) : coe_fn (emb_domain f v) a = 0 :=\n  sorry\n\ntheorem emb_domain_injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M] (f : \u03b1 \u21aa \u03b2) :\n    function.injective (emb_domain f) :=\n  sorry\n\n@[simp] theorem emb_domain_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M] {f : \u03b1 \u21aa \u03b2}\n    {l\u2081 : \u03b1 \u2192\u2080 M} {l\u2082 : \u03b1 \u2192\u2080 M} : emb_domain f l\u2081 = emb_domain f l\u2082 \u2194 l\u2081 = l\u2082 :=\n  function.injective.eq_iff (emb_domain_injective f)\n\n@[simp] theorem emb_domain_eq_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M]\n    {f : \u03b1 \u21aa \u03b2} {l : \u03b1 \u2192\u2080 M} : emb_domain f l = 0 \u2194 l = 0 :=\n  function.injective.eq_iff' (emb_domain_injective f) (emb_domain_zero f)\n\ntheorem emb_domain_map_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [HasZero N] (f : \u03b1 \u21aa \u03b2) (g : M \u2192 N) (p : \u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M]\n    (l : \u03b1 \u2192\u2080 M) (f : \u03b1 \u21aa \u03b2) (a : \u03b2) (b : M) (hb : b \u2260 0) (h : emb_domain f l = single a b) :\n    \u2203 (x : \u03b1), l = single x b \u2227 coe_fn f x = a :=\n  sorry\n\n/-! ### Declarations about `zip_with` -/\n\n/-- `zip_with f hf g\u2081 g\u2082` is the finitely supported function satisfying\n  `zip_with f hf g\u2081 g\u2082 a = f (g\u2081 a) (g\u2082 a)`, and it is well-defined when `f 0 0 = 0`. -/\ndef zip_with {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8} [HasZero M] [HasZero N]\n    [HasZero P] (f : M \u2192 N \u2192 P) (hf : f 0 0 = 0) (g\u2081 : \u03b1 \u2192\u2080 M) (g\u2082 : \u03b1 \u2192\u2080 N) : \u03b1 \u2192\u2080 P :=\n  on_finset (support g\u2081 \u222a support g\u2082) (fun (a : \u03b1) => f (coe_fn g\u2081 a) (coe_fn g\u2082 a)) sorry\n\n@[simp] theorem zip_with_apply {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8}\n    [HasZero M] [HasZero N] [HasZero P] {f : M \u2192 N \u2192 P} {hf : f 0 0 = 0} {g\u2081 : \u03b1 \u2192\u2080 M} {g\u2082 : \u03b1 \u2192\u2080 N}\n    {a : \u03b1} : coe_fn (zip_with f hf g\u2081 g\u2082) a = f (coe_fn g\u2081 a) (coe_fn g\u2082 a) :=\n  rfl\n\ntheorem support_zip_with {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} {P : Type u_8} [HasZero M]\n    [HasZero N] [HasZero P] {f : M \u2192 N \u2192 P} {hf : f 0 0 = 0} {g\u2081 : \u03b1 \u2192\u2080 M} {g\u2082 : \u03b1 \u2192\u2080 N} :\n    support (zip_with f hf g\u2081 g\u2082) \u2286 support g\u2081 \u222a support g\u2082 :=\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 {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (a : \u03b1) (f : \u03b1 \u2192\u2080 M) : \u03b1 \u2192\u2080 M :=\n  mk (finset.erase (support f) a) (fun (a' : \u03b1) => ite (a' = a) 0 (coe_fn f a')) sorry\n\n@[simp] theorem support_erase {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {f : \u03b1 \u2192\u2080 M} :\n    support (erase a f) = finset.erase (support f) a :=\n  rfl\n\n@[simp] theorem erase_same {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {f : \u03b1 \u2192\u2080 M} :\n    coe_fn (erase a f) a = 0 :=\n  if_pos rfl\n\n@[simp] theorem erase_ne {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {a' : \u03b1} {f : \u03b1 \u2192\u2080 M}\n    (h : a' \u2260 a) : coe_fn (erase a f) a' = coe_fn f a' :=\n  if_neg h\n\n@[simp] theorem erase_single {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {b : M} :\n    erase a (single a b) = 0 :=\n  sorry\n\ntheorem erase_single_ne {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {a : \u03b1} {a' : \u03b1} {b : M}\n    (h : a \u2260 a') : erase a (single a' b) = single a' b :=\n  sorry\n\n@[simp] theorem erase_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (a : \u03b1) : erase a 0 = 0 :=\n  sorry\n\n/-!\n### Declarations about `sum` and `prod`\n\nIn most of this section, the domain `\u03b2` 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 {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [add_comm_monoid N] (f : \u03b1 \u2192\u2080 M)\n    (g : \u03b1 \u2192 M \u2192 N) : N :=\n  finset.sum (support f) fun (a : \u03b1) => 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 {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [comm_monoid N] (f : \u03b1 \u2192\u2080 M)\n    (g : \u03b1 \u2192 M \u2192 N) : N :=\n  finset.prod (support f) fun (a : \u03b1) => g a (coe_fn f a)\n\ntheorem sum_of_support_subset {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] (f : \u03b1 \u2192\u2080 M) {s : finset \u03b1} (hs : support f \u2286 s) (g : \u03b1 \u2192 M \u2192 N)\n    (h : \u2200 (i : \u03b1), i \u2208 s \u2192 g i 0 = 0) : sum f g = finset.sum s fun (x : \u03b1) => g x (coe_fn f x) :=\n  finset.sum_subset hs\n    fun (x : \u03b1) (hxs : x \u2208 s) (hx : \u00acx \u2208 support f) =>\n      Eq.subst (h x hxs) (congr_arg (g x)) (iff.mp not_mem_support_iff hx)\n\ntheorem prod_fintype {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [comm_monoid N]\n    [fintype \u03b1] (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 N) (h : \u2200 (i : \u03b1), g i 0 = 1) :\n    prod f g = finset.prod finset.univ fun (i : \u03b1) => g i (coe_fn f i) :=\n  prod_of_support_subset f (finset.subset_univ (support f)) g\n    fun (x : \u03b1) (_x : x \u2208 finset.univ) => h x\n\n@[simp] theorem prod_single_index {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [comm_monoid N] {a : \u03b1} {b : M} {h : \u03b1 \u2192 M \u2192 N} (h_zero : h a 0 = 1) :\n    prod (single a b) h = h a b :=\n  sorry\n\ntheorem prod_map_range_index {\u03b1 : 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 \u2192 M'} {hf : f 0 = 0} {g : \u03b1 \u2192\u2080 M}\n    {h : \u03b1 \u2192 M' \u2192 N} (h0 : \u2200 (a : \u03b1), h a 0 = 1) :\n    prod (map_range f hf g) h = prod g fun (a : \u03b1) (b : M) => h a (f b) :=\n  sorry\n\n@[simp] theorem sum_zero_index {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {h : \u03b1 \u2192 M \u2192 N} : sum 0 h = 0 :=\n  rfl\n\ntheorem sum_comm {\u03b1 : Type u_1} {\u03b2 : 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 : \u03b1 \u2192\u2080 M) (g : \u03b2 \u2192\u2080 M')\n    (h : \u03b1 \u2192 M \u2192 \u03b2 \u2192 M' \u2192 N) :\n    (sum f fun (x : \u03b1) (v : M) => sum g fun (x' : \u03b2) (v' : M') => h x v x' v') =\n        sum g fun (x' : \u03b2) (v' : M') => sum f fun (x : \u03b1) (v : M) => h x v x' v' :=\n  finset.sum_comm\n\n@[simp] theorem prod_ite_eq {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [comm_monoid N]\n    [DecidableEq \u03b1] (f : \u03b1 \u2192\u2080 M) (a : \u03b1) (b : \u03b1 \u2192 M \u2192 N) :\n    (prod f fun (x : \u03b1) (v : M) => ite (a = x) (b x v) 1) =\n        ite (a \u2208 support f) (b a (coe_fn f a)) 1 :=\n  sorry\n\n@[simp] theorem sum_ite_self_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] {N : Type u_2} [add_comm_monoid N]\n    (f : \u03b1 \u2192\u2080 N) (a : \u03b1) : (sum f fun (x : \u03b1) (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' {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] [DecidableEq \u03b1] (f : \u03b1 \u2192\u2080 M) (a : \u03b1) (b : \u03b1 \u2192 M \u2192 N) :\n    (sum f fun (x : \u03b1) (v : M) => ite (x = a) (b x v) 0) =\n        ite (a \u2208 support f) (b a (coe_fn f a)) 0 :=\n  sorry\n\n@[simp] theorem sum_ite_self_eq' {\u03b1 : Type u_1} [DecidableEq \u03b1] {N : Type u_2} [add_comm_monoid N]\n    (f : \u03b1 \u2192\u2080 N) (a : \u03b1) : (sum f fun (x : \u03b1) (v : N) => ite (x = a) v 0) = coe_fn f a :=\n  sorry\n\n@[simp] theorem prod_pow {\u03b1 : Type u_1} {N : Type u_7} [comm_monoid N] [fintype \u03b1] (f : \u03b1 \u2192\u2080 \u2115)\n    (g : \u03b1 \u2192 N) :\n    (prod f fun (a : \u03b1) (b : \u2115) => g a ^ b) =\n        finset.prod finset.univ fun (a : \u03b1) => g a ^ coe_fn f a :=\n  prod_fintype f (fun (a : \u03b1) (b : \u2115) => g a ^ b) fun (a : \u03b1) => 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 {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [add_comm_monoid N]\n    {s : finset \u03b1} {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M \u2192 N} (hf : \u2200 (a : \u03b1), f a \u2260 0 \u2192 a \u2208 s)\n    (hg : \u2200 (a : \u03b1), g a 0 = 0) :\n    sum (on_finset s f hf) g = finset.sum s fun (a : \u03b1) => g a (f a) :=\n  sorry\n\n/-!\n### Additive monoid structure on `\u03b1 \u2192\u2080 M`\n-/\n\nprotected instance has_add {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] : Add (\u03b1 \u2192\u2080 M) :=\n  { add := zip_with Add.add sorry }\n\n@[simp] theorem coe_add {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192\u2080 M) :\n    \u21d1(f + g) = \u21d1f + \u21d1g :=\n  rfl\n\ntheorem add_apply {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] {g\u2081 : \u03b1 \u2192\u2080 M} {g\u2082 : \u03b1 \u2192\u2080 M} {a : \u03b1} :\n    coe_fn (g\u2081 + g\u2082) a = coe_fn g\u2081 a + coe_fn g\u2082 a :=\n  rfl\n\ntheorem support_add {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] {g\u2081 : \u03b1 \u2192\u2080 M} {g\u2082 : \u03b1 \u2192\u2080 M} :\n    support (g\u2081 + g\u2082) \u2286 support g\u2081 \u222a support g\u2082 :=\n  support_zip_with\n\ntheorem support_add_eq {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] {g\u2081 : \u03b1 \u2192\u2080 M} {g\u2082 : \u03b1 \u2192\u2080 M}\n    (h : disjoint (support g\u2081) (support g\u2082)) : support (g\u2081 + g\u2082) = support g\u2081 \u222a support g\u2082 :=\n  sorry\n\n@[simp] theorem single_add {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] {a : \u03b1} {b\u2081 : M} {b\u2082 : M} :\n    single a (b\u2081 + b\u2082) = single a b\u2081 + single a b\u2082 :=\n  sorry\n\nprotected instance add_monoid {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] : add_monoid (\u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] (a : \u03b1) : M \u2192+ \u03b1 \u2192\u2080 M :=\n  add_monoid_hom.mk (single a) sorry sorry\n\n/-- Evaluation of a function `f : \u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] (a : \u03b1)\n    (g : \u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] (a : \u03b1) (f : \u03b1 \u2192\u2080 M) :\n    single a (coe_fn f a) + erase a f = f :=\n  sorry\n\ntheorem erase_add_single {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] (a : \u03b1) (f : \u03b1 \u2192\u2080 M) :\n    erase a f + single a (coe_fn f a) = f :=\n  sorry\n\n@[simp] theorem erase_add {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] (a : \u03b1) (f : \u03b1 \u2192\u2080 M)\n    (f' : \u03b1 \u2192\u2080 M) : erase a (f + f') = erase a f + erase a f' :=\n  sorry\n\nprotected theorem induction {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] {p : (\u03b1 \u2192\u2080 M) \u2192 Prop}\n    (f : \u03b1 \u2192\u2080 M) (h0 : p 0)\n    (ha : \u2200 (a : \u03b1) (b : M) (f : \u03b1 \u2192\u2080 M), \u00aca \u2208 support f \u2192 b \u2260 0 \u2192 p f \u2192 p (single a b + f)) :\n    p f :=\n  sorry\n\ntheorem induction\u2082 {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] {p : (\u03b1 \u2192\u2080 M) \u2192 Prop} (f : \u03b1 \u2192\u2080 M)\n    (h0 : p 0)\n    (ha : \u2200 (a : \u03b1) (b : M) (f : \u03b1 \u2192\u2080 M), \u00aca \u2208 support f \u2192 b \u2260 0 \u2192 p f \u2192 p (f + single a b)) :\n    p f :=\n  sorry\n\n@[simp] theorem add_closure_Union_range_single {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] :\n    add_submonoid.closure (set.Union fun (a : \u03b1) => set.range (single a)) = \u22a4 :=\n  sorry\n\n/-- If two additive homomorphisms from `\u03b1 \u2192\u2080 M` are equal on each `single a b`, then\nthey are equal. -/\ntheorem add_hom_ext {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [add_monoid N]\n    {f : (\u03b1 \u2192\u2080 M) \u2192+ N} {g : (\u03b1 \u2192\u2080 M) \u2192+ N}\n    (H : \u2200 (x : \u03b1) (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 `\u03b1 \u2192\u2080 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 `\u2115` or `\u2124`, then it suffices to\nverify `f (single a 1) = g (single a 1)`. -/\ntheorem add_hom_ext' {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [add_monoid N]\n    {f : (\u03b1 \u2192\u2080 M) \u2192+ N} {g : (\u03b1 \u2192\u2080 M) \u2192+ N}\n    (H :\n      \u2200 (x : \u03b1),\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 : \u03b1) => add_monoid_hom.congr_fun (H x)\n\ntheorem mul_hom_ext {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [monoid N]\n    {f : multiplicative (\u03b1 \u2192\u2080 M) \u2192* N} {g : multiplicative (\u03b1 \u2192\u2080 M) \u2192* N}\n    (H :\n      \u2200 (x : \u03b1) (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' {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [monoid N]\n    {f : multiplicative (\u03b1 \u2192\u2080 M) \u2192* N} {g : multiplicative (\u03b1 \u2192\u2080 M) \u2192* N}\n    (H :\n      \u2200 (x : \u03b1),\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 : \u03b1) => monoid_hom.congr_fun (H x)\n\ntheorem map_range_add {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_monoid M] [add_monoid N]\n    {f : M \u2192 N} {hf : f 0 = 0} (hf' : \u2200 (x y : M), f (x + y) = f x + f y) (v\u2081 : \u03b1 \u2192\u2080 M)\n    (v\u2082 : \u03b1 \u2192\u2080 M) : map_range f hf (v\u2081 + v\u2082) = map_range f hf v\u2081 + map_range f hf v\u2082 :=\n  sorry\n\nend finsupp\n\n\ntheorem mul_equiv.map_finsupp_prod {\u03b1 : 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 \u2243* P) (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 N) :\n    coe_fn h (finsupp.prod f g) = finsupp.prod f fun (a : \u03b1) (b : M) => coe_fn h (g a b) :=\n  mul_equiv.map_prod h (fun (a : \u03b1) => g a (coe_fn f a)) (finsupp.support f)\n\ntheorem add_monoid_hom.map_finsupp_sum {\u03b1 : 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 \u2192+ P) (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 N) :\n    coe_fn h (finsupp.sum f g) = finsupp.sum f fun (a : \u03b1) (b : M) => coe_fn h (g a b) :=\n  add_monoid_hom.map_sum h (fun (a : \u03b1) => g a (coe_fn f a)) (finsupp.support f)\n\ntheorem ring_hom.map_finsupp_sum {\u03b1 : Type u_1} {M : Type u_5} {R : Type u_11} {S : Type u_12}\n    [HasZero M] [semiring R] [semiring S] (h : R \u2192+* S) (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 R) :\n    coe_fn h (finsupp.sum f g) = finsupp.sum f fun (a : \u03b1) (b : M) => coe_fn h (g a b) :=\n  ring_hom.map_sum h (fun (a : \u03b1) => g a (coe_fn f a)) (finsupp.support f)\n\ntheorem ring_hom.map_finsupp_prod {\u03b1 : 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 \u2192+* S) (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192 M \u2192 R) :\n    coe_fn h (finsupp.prod f g) = finsupp.prod f fun (a : \u03b1) (b : M) => coe_fn h (g a b) :=\n  ring_hom.map_prod h (fun (a : \u03b1) => g a (coe_fn f a)) (finsupp.support f)\n\ntheorem monoid_hom.coe_finsupp_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {N : Type u_7} {P : Type u_8}\n    [HasZero \u03b2] [monoid N] [comm_monoid P] (f : \u03b1 \u2192\u2080 \u03b2) (g : \u03b1 \u2192 \u03b2 \u2192 N \u2192* P) :\n    \u21d1(finsupp.prod f g) = finsupp.prod f fun (i : \u03b1) (fi : \u03b2) => \u21d1(g i fi) :=\n  monoid_hom.coe_prod (fun (a : \u03b1) => g a (coe_fn f a)) (finsupp.support f)\n\n@[simp] theorem add_monoid_hom.finsupp_sum_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {N : Type u_7}\n    {P : Type u_8} [HasZero \u03b2] [add_monoid N] [add_comm_monoid P] (f : \u03b1 \u2192\u2080 \u03b2) (g : \u03b1 \u2192 \u03b2 \u2192 N \u2192+ P)\n    (x : N) :\n    coe_fn (finsupp.sum f g) x = finsupp.sum f fun (i : \u03b1) (fi : \u03b2) => coe_fn (g i fi) x :=\n  add_monoid_hom.finset_sum_apply (fun (a : \u03b1) => g a (coe_fn f a)) (finsupp.support f) x\n\nnamespace finsupp\n\n\nprotected instance nat_sub {\u03b1 : Type u_1} : Sub (\u03b1 \u2192\u2080 \u2115) :=\n  { sub := zip_with (fun (m n : \u2115) => m - n) sorry }\n\n@[simp] theorem nat_sub_apply {\u03b1 : Type u_1} {g\u2081 : \u03b1 \u2192\u2080 \u2115} {g\u2082 : \u03b1 \u2192\u2080 \u2115} {a : \u03b1} :\n    coe_fn (g\u2081 - g\u2082) a = coe_fn g\u2081 a - coe_fn g\u2082 a :=\n  rfl\n\n@[simp] theorem single_sub {\u03b1 : Type u_1} {a : \u03b1} {n\u2081 : \u2115} {n\u2082 : \u2115} :\n    single a (n\u2081 - n\u2082) = single a n\u2081 - single a n\u2082 :=\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 {\u03b1 : Type u_1} {a : \u03b1} {u : \u03b1 \u2192\u2080 \u2115} {u' : \u03b1 \u2192\u2080 \u2115} (h : coe_fn u a \u2260 0) :\n    u - single a 1 + u' = u + u' - single a 1 :=\n  sorry\n\ntheorem add_sub_single_one {\u03b1 : Type u_1} {a : \u03b1} {u : \u03b1 \u2192\u2080 \u2115} {u' : \u03b1 \u2192\u2080 \u2115} (h : coe_fn u' a \u2260 0) :\n    u + (u' - single a 1) = u + u' - single a 1 :=\n  sorry\n\n@[simp] theorem nat_zero_sub {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) : 0 - f = 0 :=\n  ext fun (x : \u03b1) => nat.zero_sub (coe_fn f x)\n\nprotected instance add_comm_monoid {\u03b1 : Type u_1} {M : Type u_5} [add_comm_monoid M] :\n    add_comm_monoid (\u03b1 \u2192\u2080 M) :=\n  add_comm_monoid.mk add_monoid.add sorry add_monoid.zero sorry sorry sorry\n\nprotected instance has_sub {\u03b1 : Type u_1} {G : Type u_9} [add_group G] : Sub (\u03b1 \u2192\u2080 G) :=\n  { sub := zip_with Sub.sub sorry }\n\nprotected instance add_group {\u03b1 : Type u_1} {G : Type u_9} [add_group G] : add_group (\u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {G : Type u_9} [add_comm_group G] :\n    add_comm_group (\u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} [add_comm_monoid M] (s : multiset M)\n    (a : \u03b1) : single a (multiset.sum s) = multiset.sum (multiset.map (single a) s) :=\n  sorry\n\ntheorem single_finset_sum {\u03b1 : Type u_1} {\u03b9 : Type u_4} {M : Type u_5} [add_comm_monoid M]\n    (s : finset \u03b9) (f : \u03b9 \u2192 M) (a : \u03b1) :\n    single a (finset.sum s fun (b : \u03b9) => f b) = finset.sum s fun (b : \u03b9) => single a (f b) :=\n  sorry\n\ntheorem single_sum {\u03b1 : Type u_1} {\u03b9 : Type u_4} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] (s : \u03b9 \u2192\u2080 M) (f : \u03b9 \u2192 M \u2192 N) (a : \u03b1) :\n    single a (sum s f) = sum s fun (d : \u03b9) (c : M) => single a (f d c) :=\n  single_finset_sum (support s) (fun (a : \u03b9) => f a (coe_fn s a)) a\n\ntheorem sum_neg_index {\u03b1 : Type u_1} {M : Type u_5} {G : Type u_9} [add_group G] [add_comm_monoid M]\n    {g : \u03b1 \u2192\u2080 G} {h : \u03b1 \u2192 G \u2192 M} (h0 : \u2200 (a : \u03b1), h a 0 = 0) :\n    sum (-g) h = sum g fun (a : \u03b1) (b : G) => h a (-b) :=\n  sum_map_range_index h0\n\n@[simp] theorem neg_apply {\u03b1 : Type u_1} {G : Type u_9} [add_group G] {g : \u03b1 \u2192\u2080 G} {a : \u03b1} :\n    coe_fn (-g) a = -coe_fn g a :=\n  rfl\n\n@[simp] theorem sub_apply {\u03b1 : Type u_1} {G : Type u_9} [add_group G] {g\u2081 : \u03b1 \u2192\u2080 G} {g\u2082 : \u03b1 \u2192\u2080 G}\n    {a : \u03b1} : coe_fn (g\u2081 - g\u2082) a = coe_fn g\u2081 a - coe_fn g\u2082 a :=\n  rfl\n\n@[simp] theorem support_neg {\u03b1 : Type u_1} {G : Type u_9} [add_group G] {f : \u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192 M \u2192 \u03b2 \u2192\u2080 N} {a\u2082 : \u03b2} :\n    coe_fn (sum f g) a\u2082 = sum f fun (a\u2081 : \u03b1) (b : M) => coe_fn (g a\u2081 b) a\u2082 :=\n  add_monoid_hom.map_sum (apply_add_hom a\u2082) (fun (a : \u03b1) => g a (coe_fn f a)) (support f)\n\ntheorem support_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192 M \u2192 \u03b2 \u2192\u2080 N} :\n    support (sum f g) \u2286 finset.bUnion (support f) fun (a : \u03b1) => support (g a (coe_fn f a)) :=\n  sorry\n\n@[simp] theorem sum_zero {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {f : \u03b1 \u2192\u2080 M} : (sum f fun (a : \u03b1) (b : M) => 0) = 0 :=\n  finset.sum_const_zero\n\n@[simp] theorem prod_mul {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M] [comm_monoid N]\n    {f : \u03b1 \u2192\u2080 M} {h\u2081 : \u03b1 \u2192 M \u2192 N} {h\u2082 : \u03b1 \u2192 M \u2192 N} :\n    (prod f fun (a : \u03b1) (b : M) => h\u2081 a b * h\u2082 a b) = prod f h\u2081 * prod f h\u2082 :=\n  finset.prod_mul_distrib\n\n@[simp] theorem sum_neg {\u03b1 : Type u_1} {M : Type u_5} {G : Type u_9} [HasZero M] [add_comm_group G]\n    {f : \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M \u2192 G} : (sum f fun (a : \u03b1) (b : M) => -h a b) = -sum f h :=\n  Eq.symm\n    (add_monoid_hom.map_sum (-add_monoid_hom.id G) (fun (x : \u03b1) => h x (coe_fn f x)) (support f))\n\n@[simp] theorem sum_sub {\u03b1 : Type u_1} {M : Type u_5} {G : Type u_9} [HasZero M] [add_comm_group G]\n    {f : \u03b1 \u2192\u2080 M} {h\u2081 : \u03b1 \u2192 M \u2192 G} {h\u2082 : \u03b1 \u2192 M \u2192 G} :\n    (sum f fun (a : \u03b1) (b : M) => h\u2081 a b - h\u2082 a b) = sum f h\u2081 - sum f h\u2082 :=\n  finset.sum_sub_distrib\n\ntheorem prod_add_index {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [comm_monoid N] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M \u2192 N} (h_zero : \u2200 (a : \u03b1), h a 0 = 1)\n    (h_add : \u2200 (a : \u03b1) (b\u2081 b\u2082 : M), h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082) :\n    prod (f + g) h = prod f h * prod g h :=\n  sorry\n\n@[simp] theorem sum_add_index' {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192\u2080 M} (h : \u03b1 \u2192 M \u2192+ N) :\n    (sum (f + g) fun (x : \u03b1) => \u21d1(h x)) =\n        (sum f fun (x : \u03b1) => \u21d1(h x)) + sum g fun (x : \u03b1) => \u21d1(h x) :=\n  sum_add_index (fun (a : \u03b1) => add_monoid_hom.map_zero (h a))\n    fun (a : \u03b1) => add_monoid_hom.map_add (h a)\n\n@[simp] theorem prod_add_index' {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [comm_monoid N] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192\u2080 M} (h : \u03b1 \u2192 multiplicative M \u2192* N) :\n    (prod (f + g) fun (a : \u03b1) (b : M) => coe_fn (h a) (coe_fn multiplicative.of_add b)) =\n        (prod f fun (a : \u03b1) (b : M) => coe_fn (h a) (coe_fn multiplicative.of_add b)) *\n          prod g fun (a : \u03b1) (b : M) => coe_fn (h a) (coe_fn multiplicative.of_add b) :=\n  prod_add_index (fun (a : \u03b1) => monoid_hom.map_one (h a)) fun (a : \u03b1) => monoid_hom.map_mul (h a)\n\n/-- The canonical isomorphism between families of additive monoid homomorphisms `\u03b1 \u2192 (M \u2192+ N)`\nand monoid homomorphisms `(\u03b1 \u2192\u2080 M) \u2192+ N`. -/\ndef lift_add_hom {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] : (\u03b1 \u2192 M \u2192+ N) \u2243+ ((\u03b1 \u2192\u2080 M) \u2192+ N) :=\n  add_equiv.mk\n    (fun (F : \u03b1 \u2192 M \u2192+ N) =>\n      add_monoid_hom.mk (fun (f : \u03b1 \u2192\u2080 M) => sum f fun (x : \u03b1) => \u21d1(F x)) sorry sorry)\n    (fun (F : (\u03b1 \u2192\u2080 M) \u2192+ N) (x : \u03b1) => add_monoid_hom.comp F (single_add_hom x)) sorry sorry sorry\n\n@[simp] theorem lift_add_hom_apply {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] (F : \u03b1 \u2192 M \u2192+ N) (f : \u03b1 \u2192\u2080 M) :\n    coe_fn (coe_fn lift_add_hom F) f = sum f fun (x : \u03b1) => \u21d1(F x) :=\n  rfl\n\n@[simp] theorem lift_add_hom_symm_apply {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (F : (\u03b1 \u2192\u2080 M) \u2192+ N) (x : \u03b1) :\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 {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (F : (\u03b1 \u2192\u2080 M) \u2192+ N) (x : \u03b1) (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 {\u03b1 : Type u_1} {M : Type u_5} [add_comm_monoid M] :\n    coe_fn lift_add_hom single_add_hom = add_monoid_hom.id (\u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} [add_comm_monoid M] (f : \u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (f : \u03b1 \u2192 M \u2192+ N) (a : \u03b1) (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 {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (f : \u03b1 \u2192 M \u2192+ N) (a : \u03b1) :\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 {\u03b1 : 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 \u2192+ P) (f : \u03b1 \u2192 M \u2192+ N) :\n    add_monoid_hom.comp g (coe_fn lift_add_hom f) =\n        coe_fn lift_add_hom fun (a : \u03b1) => add_monoid_hom.comp g (f a) :=\n  sorry\n\ntheorem sum_sub_index {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [add_comm_group \u03b2]\n    [add_comm_group \u03b3] {f : \u03b1 \u2192\u2080 \u03b2} {g : \u03b1 \u2192\u2080 \u03b2} {h : \u03b1 \u2192 \u03b2 \u2192 \u03b3}\n    (h_sub : \u2200 (a : \u03b1) (b\u2081 b\u2082 : \u03b2), h a (b\u2081 - b\u2082) = h a b\u2081 - h a b\u2082) :\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 : \u03b1) => add_monoid_hom.of_map_sub (h a) (h_sub a)) f g\n\ntheorem sum_emb_domain {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {v : \u03b1 \u2192\u2080 M} {f : \u03b1 \u21aa \u03b2} {g : \u03b2 \u2192 M \u2192 N} :\n    sum (emb_domain f v) g = sum v fun (a : \u03b1) (b : M) => g (coe_fn f a) b :=\n  sorry\n\ntheorem sum_finset_sum_index {\u03b1 : Type u_1} {\u03b9 : Type u_4} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] {s : finset \u03b9} {g : \u03b9 \u2192 \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M \u2192 N}\n    (h_zero : \u2200 (a : \u03b1), h a 0 = 0)\n    (h_add : \u2200 (a : \u03b1) (b\u2081 b\u2082 : M), h a (b\u2081 + b\u2082) = h a b\u2081 + h a b\u2082) :\n    (finset.sum s fun (i : \u03b9) => sum (g i) h) = sum (finset.sum s fun (i : \u03b9) => g i) h :=\n  sorry\n\ntheorem prod_sum_index {\u03b1 : Type u_1} {\u03b2 : 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 : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192 M \u2192 \u03b2 \u2192\u2080 N}\n    {h : \u03b2 \u2192 N \u2192 P} (h_zero : \u2200 (a : \u03b2), h a 0 = 1)\n    (h_add : \u2200 (a : \u03b2) (b\u2081 b\u2082 : N), h a (b\u2081 + b\u2082) = h a b\u2081 * h a b\u2082) :\n    prod (sum f g) h = prod f fun (a : \u03b1) (b : M) => prod (g a b) h :=\n  Eq.symm (prod_finset_sum_index h_zero h_add)\n\ntheorem multiset_sum_sum_index {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] (f : multiset (\u03b1 \u2192\u2080 M)) (h : \u03b1 \u2192 M \u2192 N) (h\u2080 : \u2200 (a : \u03b1), h a 0 = 0)\n    (h\u2081 : \u2200 (a : \u03b1) (b\u2081 b\u2082 : M), h a (b\u2081 + b\u2082) = h a b\u2081 + h a b\u2082) :\n    sum (multiset.sum f) h = multiset.sum (multiset.map (fun (g : \u03b1 \u2192\u2080 M) => sum g h) f) :=\n  sorry\n\ntheorem multiset_map_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {M : Type u_5} [HasZero M]\n    {f : \u03b1 \u2192\u2080 M} {m : \u03b2 \u2192 \u03b3} {h : \u03b1 \u2192 M \u2192 multiset \u03b2} :\n    multiset.map m (sum f h) = sum f fun (a : \u03b1) (b : M) => multiset.map m (h a b) :=\n  Eq.symm (finset.sum_hom (support f) (multiset.map m))\n\ntheorem multiset_sum_sum {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] {f : \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M \u2192 multiset N} :\n    multiset.sum (sum f h) = sum f fun (a : \u03b1) (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 {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] (f : M \u2192+ N) : (\u03b1 \u2192\u2080 M) \u2192+ \u03b1 \u2192\u2080 N :=\n  add_monoid_hom.mk (map_range \u21d1f sorry) sorry sorry\n\ntheorem map_range_multiset_sum {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [add_comm_monoid M]\n    [add_comm_monoid N] (f : M \u2192+ N) (m : multiset (\u03b1 \u2192\u2080 M)) :\n    map_range (\u21d1f) (add_monoid_hom.map_zero f) (multiset.sum m) =\n        multiset.sum\n          (multiset.map (fun (x : \u03b1 \u2192\u2080 M) => map_range (\u21d1f) (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 {\u03b1 : Type u_1} {\u03b9 : Type u_4} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (f : M \u2192+ N) (s : finset \u03b9) (g : \u03b9 \u2192 \u03b1 \u2192\u2080 M) :\n    map_range (\u21d1f) (add_monoid_hom.map_zero f) (finset.sum s fun (x : \u03b9) => g x) =\n        finset.sum s fun (x : \u03b9) => map_range (\u21d1f) (add_monoid_hom.map_zero f) (g x) :=\n  sorry\n\n/-! ### Declarations about `map_domain` -/\n\n/-- Given `f : \u03b1 \u2192 \u03b2` and `v : \u03b1 \u2192\u2080 M`, `map_domain f v : \u03b2 \u2192\u2080 M`\n  is the finitely supported function whose value at `a : \u03b2` is the sum\n  of `v x` over all `x` such that `f x = a`. -/\ndef map_domain {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M] (f : \u03b1 \u2192 \u03b2)\n    (v : \u03b1 \u2192\u2080 M) : \u03b2 \u2192\u2080 M :=\n  sum v fun (a : \u03b1) => single (f a)\n\ntheorem map_domain_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) (x : \u03b1 \u2192\u2080 M) (a : \u03b1) :\n    coe_fn (map_domain f x) (f a) = coe_fn x a :=\n  sorry\n\ntheorem map_domain_notin_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : \u03b1 \u2192 \u03b2} (x : \u03b1 \u2192\u2080 M) (a : \u03b2) (h : \u00aca \u2208 set.range f) : coe_fn (map_domain f x) a = 0 :=\n  sorry\n\ntheorem map_domain_id {\u03b1 : Type u_1} {M : Type u_5} [add_comm_monoid M] {v : \u03b1 \u2192\u2080 M} :\n    map_domain id v = v :=\n  sum_single v\n\ntheorem map_domain_comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {M : Type u_5}\n    [add_comm_monoid M] {v : \u03b1 \u2192\u2080 M} {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} :\n    map_domain (g \u2218 f) v = map_domain g (map_domain f v) :=\n  Eq.symm\n    (Eq.trans (sum_sum_index (fun (a : \u03b2) => single_zero) fun (a : \u03b2) (b\u2081 b\u2082 : M) => single_add)\n      (finset.sum_congr rfl fun (_x : \u03b1) (_x_1 : _x \u2208 support v) => sum_single_index single_zero))\n\ntheorem map_domain_single {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : \u03b1 \u2192 \u03b2} {a : \u03b1} {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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : \u03b1 \u2192 \u03b2} : map_domain f 0 = 0 :=\n  sum_zero_index\n\ntheorem map_domain_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {v : \u03b1 \u2192\u2080 M} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} (h : \u2200 (x : \u03b1), x \u2208 support v \u2192 f x = g x) :\n    map_domain f v = map_domain g v :=\n  sorry\n\ntheorem map_domain_add {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {v\u2081 : \u03b1 \u2192\u2080 M} {v\u2082 : \u03b1 \u2192\u2080 M} {f : \u03b1 \u2192 \u03b2} :\n    map_domain f (v\u2081 + v\u2082) = map_domain f v\u2081 + map_domain f v\u2082 :=\n  sum_add_index (fun (_x : \u03b1) => single_zero) fun (_x : \u03b1) (_x_1 _x_2 : M) => single_add\n\ntheorem map_domain_finset_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b9 : Type u_4} {M : Type u_5}\n    [add_comm_monoid M] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b9} {v : \u03b9 \u2192 \u03b1 \u2192\u2080 M} :\n    map_domain f (finset.sum s fun (i : \u03b9) => v i) =\n        finset.sum s fun (i : \u03b9) => map_domain f (v i) :=\n  Eq.symm\n    (sum_finset_sum_index (fun (_x : \u03b1) => single_zero) fun (_x : \u03b1) (_x_1 _x_2 : M) => single_add)\n\ntheorem map_domain_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [HasZero N] {f : \u03b1 \u2192 \u03b2} {s : \u03b1 \u2192\u2080 N} {v : \u03b1 \u2192 N \u2192 \u03b1 \u2192\u2080 M} :\n    map_domain f (sum s v) = sum s fun (a : \u03b1) (b : N) => map_domain f (v a b) :=\n  Eq.symm\n    (sum_finset_sum_index (fun (_x : \u03b1) => single_zero) fun (_x : \u03b1) (_x_1 _x_2 : M) => single_add)\n\ntheorem map_domain_support {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : \u03b1 \u2192 \u03b2} {s : \u03b1 \u2192\u2080 M} : support (map_domain f s) \u2286 finset.image f (support s) :=\n  sorry\n\ntheorem sum_map_domain_index {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] {f : \u03b1 \u2192 \u03b2} {s : \u03b1 \u2192\u2080 M} {h : \u03b2 \u2192 M \u2192 N}\n    (h_zero : \u2200 (a : \u03b2), h a 0 = 0)\n    (h_add : \u2200 (a : \u03b2) (b\u2081 b\u2082 : M), h a (b\u2081 + b\u2082) = h a b\u2081 + h a b\u2082) :\n    sum (map_domain f s) h = sum s fun (a : \u03b1) (b : M) => h (f a) b :=\n  Eq.trans (sum_sum_index h_zero h_add)\n    (finset.sum_congr rfl fun (_x : \u03b1) (_x_1 : _x \u2208 support s) => sum_single_index (h_zero (f _x)))\n\ntheorem emb_domain_eq_map_domain {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : \u03b1 \u21aa \u03b2) (v : \u03b1 \u2192\u2080 M) : emb_domain f v = map_domain (\u21d1f) v :=\n  sorry\n\ntheorem sum_map_domain_index_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] {f : \u03b1 \u2192 \u03b2} {s : \u03b1 \u2192\u2080 M} {h : \u03b2 \u2192 M \u2192 N}\n    (hf : function.injective f) : sum (map_domain f s) h = sum s fun (a : \u03b1) (b : M) => h (f a) b :=\n  sorry\n\ntheorem map_domain_injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) : function.injective (map_domain f) :=\n  sorry\n\n/-! ### Declarations about `comap_domain` -/\n\n/-- Given `f : \u03b1 \u2192 \u03b2`, `l : \u03b2 \u2192\u2080 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 `\u03b1` to `M` given by composing `l` with `f`. -/\ndef comap_domain {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M] (f : \u03b1 \u2192 \u03b2) (l : \u03b2 \u2192\u2080 M)\n    (hf : set.inj_on f (f \u207b\u00b9' \u2191(support l))) : \u03b1 \u2192\u2080 M :=\n  mk (finset.preimage (support l) f hf) (fun (a : \u03b1) => coe_fn l (f a)) sorry\n\n@[simp] theorem comap_domain_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [HasZero M]\n    (f : \u03b1 \u2192 \u03b2) (l : \u03b2 \u2192\u2080 M) (hf : set.inj_on f (f \u207b\u00b9' \u2191(support l))) (a : \u03b1) :\n    coe_fn (comap_domain f l hf) a = coe_fn l (f a) :=\n  rfl\n\ntheorem sum_comap_domain {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7} [HasZero M]\n    [add_comm_monoid N] (f : \u03b1 \u2192 \u03b2) (l : \u03b2 \u2192\u2080 M) (g : \u03b2 \u2192 M \u2192 N)\n    (hf : set.bij_on f (f \u207b\u00b9' \u2191(support l)) \u2191(support l)) :\n    sum (comap_domain f l (set.bij_on.inj_on hf)) (g \u2218 f) = sum l g :=\n  sorry\n\ntheorem eq_zero_of_comap_domain_eq_zero {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5}\n    [add_comm_monoid M] (f : \u03b1 \u2192 \u03b2) (l : \u03b2 \u2192\u2080 M)\n    (hf : set.bij_on f (f \u207b\u00b9' \u2191(support l)) \u2191(support l)) :\n    comap_domain f l (set.bij_on.inj_on hf) = 0 \u2192 l = 0 :=\n  sorry\n\ntheorem map_domain_comap_domain {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : \u03b1 \u2192 \u03b2) (l : \u03b2 \u2192\u2080 M) (hf : function.injective f) (hl : \u2191(support l) \u2286 set.range f) :\n    map_domain f (comap_domain f l (function.injective.inj_on hf (f \u207b\u00b9' \u2191(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 {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop) (f : \u03b1 \u2192\u2080 M) : \u03b1 \u2192\u2080 M :=\n  mk (finset.filter (fun (a : \u03b1) => p a) (support f)) (fun (a : \u03b1) => ite (p a) (coe_fn f a) 0)\n    sorry\n\ntheorem filter_apply {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop) (f : \u03b1 \u2192\u2080 M) (a : \u03b1) :\n    coe_fn (filter p f) a = ite (p a) (coe_fn f a) 0 :=\n  rfl\n\ntheorem filter_eq_indicator {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop) (f : \u03b1 \u2192\u2080 M) :\n    \u21d1(filter p f) = set.indicator (set_of fun (x : \u03b1) => p x) \u21d1f :=\n  rfl\n\n@[simp] theorem filter_apply_pos {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop)\n    (f : \u03b1 \u2192\u2080 M) {a : \u03b1} (h : p a) : coe_fn (filter p f) a = coe_fn f a :=\n  if_pos h\n\n@[simp] theorem filter_apply_neg {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop)\n    (f : \u03b1 \u2192\u2080 M) {a : \u03b1} (h : \u00acp a) : coe_fn (filter p f) a = 0 :=\n  if_neg h\n\n@[simp] theorem support_filter {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop)\n    (f : \u03b1 \u2192\u2080 M) : support (filter p f) = finset.filter p (support f) :=\n  rfl\n\ntheorem filter_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop) : filter p 0 = 0 :=\n  sorry\n\n@[simp] theorem filter_single_of_pos {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop)\n    {a : \u03b1} {b : M} (h : p a) : filter p (single a b) = single a b :=\n  sorry\n\n@[simp] theorem filter_single_of_neg {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop)\n    {a : \u03b1} {b : M} (h : \u00acp a) : filter p (single a b) = 0 :=\n  sorry\n\ntheorem filter_pos_add_filter_neg {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] (f : \u03b1 \u2192\u2080 M)\n    (p : \u03b1 \u2192 Prop) : filter p f + filter (fun (a : \u03b1) => \u00acp a) f = f :=\n  coe_fn_injective (set.indicator_self_add_compl (set_of fun (x : \u03b1) => p x) \u21d1f)\n\n/-! ### Declarations about `frange` -/\n\n/-- `frange f` is the image of `f` on the support of `f`. -/\ndef frange {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (f : \u03b1 \u2192\u2080 M) : finset M :=\n  finset.image (\u21d1f) (support f)\n\ntheorem mem_frange {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} {y : M} :\n    y \u2208 frange f \u2194 y \u2260 0 \u2227 \u2203 (x : \u03b1), coe_fn f x = y :=\n  sorry\n\ntheorem zero_not_mem_frange {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {f : \u03b1 \u2192\u2080 M} :\n    \u00ac0 \u2208 frange f :=\n  fun (H : 0 \u2208 frange f) => and.left (iff.mp mem_frange H) rfl\n\ntheorem frange_single {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {x : \u03b1} {y : M} :\n    frange (single x y) \u2286 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 {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] (p : \u03b1 \u2192 Prop) (f : \u03b1 \u2192\u2080 M) :\n    Subtype p \u2192\u2080 M :=\n  mk (finset.subtype p (support f)) (\u21d1f \u2218 coe) sorry\n\n@[simp] theorem support_subtype_domain {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {p : \u03b1 \u2192 Prop}\n    {f : \u03b1 \u2192\u2080 M} : support (subtype_domain p f) = finset.subtype p (support f) :=\n  rfl\n\n@[simp] theorem subtype_domain_apply {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {p : \u03b1 \u2192 Prop}\n    {a : Subtype p} {v : \u03b1 \u2192\u2080 M} : coe_fn (subtype_domain p v) a = coe_fn v (subtype.val a) :=\n  rfl\n\n@[simp] theorem subtype_domain_zero {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {p : \u03b1 \u2192 Prop} :\n    subtype_domain p 0 = 0 :=\n  rfl\n\ntheorem subtype_domain_eq_zero_iff' {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {p : \u03b1 \u2192 Prop}\n    {f : \u03b1 \u2192\u2080 M} : subtype_domain p f = 0 \u2194 \u2200 (x : \u03b1), p x \u2192 coe_fn f x = 0 :=\n  sorry\n\ntheorem subtype_domain_eq_zero_iff {\u03b1 : Type u_1} {M : Type u_5} [HasZero M] {p : \u03b1 \u2192 Prop}\n    {f : \u03b1 \u2192\u2080 M} (hf : \u2200 (x : \u03b1), x \u2208 support f \u2192 p x) : subtype_domain p f = 0 \u2194 f = 0 :=\n  sorry\n\ntheorem prod_subtype_domain_index {\u03b1 : Type u_1} {M : Type u_5} {N : Type u_7} [HasZero M]\n    {p : \u03b1 \u2192 Prop} [comm_monoid N] {v : \u03b1 \u2192\u2080 M} {h : \u03b1 \u2192 M \u2192 N}\n    (hp : \u2200 (x : \u03b1), x \u2208 support v \u2192 p x) :\n    (prod (subtype_domain p v) fun (a : Subtype p) (b : M) => h (\u2191a) b) = prod v h :=\n  sorry\n\n@[simp] theorem subtype_domain_add {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] {p : \u03b1 \u2192 Prop}\n    {v : \u03b1 \u2192\u2080 M} {v' : \u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M]\n    {p : \u03b1 \u2192 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 {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] (p : \u03b1 \u2192 Prop) :\n    (\u03b1 \u2192\u2080 M) \u2192+ \u03b1 \u2192\u2080 M :=\n  add_monoid_hom.mk (filter p) sorry sorry\n\n@[simp] theorem filter_add {\u03b1 : Type u_1} {M : Type u_5} [add_monoid M] {p : \u03b1 \u2192 Prop} {v : \u03b1 \u2192\u2080 M}\n    {v' : \u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {\u03b9 : Type u_4} {M : Type u_5} [add_comm_monoid M]\n    {p : \u03b1 \u2192 Prop} {s : finset \u03b9} {h : \u03b9 \u2192 \u03b1 \u2192\u2080 M} :\n    subtype_domain p (finset.sum s fun (c : \u03b9) => h c) =\n        finset.sum s fun (c : \u03b9) => subtype_domain p (h c) :=\n  Eq.symm (finset.sum_hom s (subtype_domain p))\n\ntheorem subtype_domain_finsupp_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] {p : \u03b1 \u2192 Prop} [HasZero N] {s : \u03b2 \u2192\u2080 N} {h : \u03b2 \u2192 N \u2192 \u03b1 \u2192\u2080 M} :\n    subtype_domain p (sum s h) = sum s fun (c : \u03b2) (d : N) => subtype_domain p (h c d) :=\n  subtype_domain_sum\n\ntheorem filter_sum {\u03b1 : Type u_1} {\u03b9 : Type u_4} {M : Type u_5} [add_comm_monoid M] {p : \u03b1 \u2192 Prop}\n    (s : finset \u03b9) (f : \u03b9 \u2192 \u03b1 \u2192\u2080 M) :\n    filter p (finset.sum s fun (a : \u03b9) => f a) = finset.sum s fun (a : \u03b9) => filter p (f a) :=\n  add_monoid_hom.map_sum (filter_add_hom p) f s\n\ntheorem filter_eq_sum {\u03b1 : Type u_1} {M : Type u_5} [add_comm_monoid M] (p : \u03b1 \u2192 Prop)\n    (f : \u03b1 \u2192\u2080 M) :\n    filter p f = finset.sum (finset.filter p (support f)) fun (i : \u03b1) => single i (coe_fn f i) :=\n  sorry\n\n@[simp] theorem subtype_domain_neg {\u03b1 : Type u_1} {G : Type u_9} [add_group G] {p : \u03b1 \u2192 Prop}\n    {v : \u03b1 \u2192\u2080 G} : subtype_domain p (-v) = -subtype_domain p v :=\n  ext fun (_x : Subtype p) => rfl\n\n@[simp] theorem subtype_domain_sub {\u03b1 : Type u_1} {G : Type u_9} [add_group G] {p : \u03b1 \u2192 Prop}\n    {v : \u03b1 \u2192\u2080 G} {v' : \u03b1 \u2192\u2080 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 : \u03b1 \u2192\u2080 \u2115`, `f.to_multiset` is the multiset with multiplicities given by the values of\n`f` on the elements of `\u03b1`. We define this function as an `add_equiv`. -/\ndef to_multiset {\u03b1 : Type u_1} : (\u03b1 \u2192\u2080 \u2115) \u2243+ multiset \u03b1 :=\n  add_equiv.mk (fun (f : \u03b1 \u2192\u2080 \u2115) => sum f fun (a : \u03b1) (n : \u2115) => n \u2022\u2115 singleton a)\n    (fun (s : multiset \u03b1) => mk (multiset.to_finset s) (fun (a : \u03b1) => multiset.count a s) sorry)\n    sorry sorry sorry\n\ntheorem to_multiset_zero {\u03b1 : Type u_1} : coe_fn to_multiset 0 = 0 := rfl\n\ntheorem to_multiset_add {\u03b1 : Type u_1} (m : \u03b1 \u2192\u2080 \u2115) (n : \u03b1 \u2192\u2080 \u2115) :\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 {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) :\n    coe_fn to_multiset f = sum f fun (a : \u03b1) (n : \u2115) => n \u2022\u2115 singleton a :=\n  rfl\n\n@[simp] theorem to_multiset_single {\u03b1 : Type u_1} (a : \u03b1) (n : \u2115) :\n    coe_fn to_multiset (single a n) = n \u2022\u2115 singleton a :=\n  sorry\n\ntheorem card_to_multiset {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) :\n    coe_fn multiset.card (coe_fn to_multiset f) = sum f fun (a : \u03b1) => id :=\n  sorry\n\ntheorem to_multiset_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192\u2080 \u2115) (g : \u03b1 \u2192 \u03b2) :\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 \u2192\u2080 \u2115) :\n    multiset.prod (coe_fn to_multiset f) = prod f fun (a : M) (n : \u2115) => a ^ n :=\n  sorry\n\n@[simp] theorem to_finset_to_multiset {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) :\n    multiset.to_finset (coe_fn to_multiset f) = support f :=\n  sorry\n\n@[simp] theorem count_to_multiset {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) (a : \u03b1) :\n    multiset.count a (coe_fn to_multiset f) = coe_fn f a :=\n  sorry\n\ntheorem mem_support_multiset_sum {\u03b1 : Type u_1} {M : Type u_5} [add_comm_monoid M]\n    {s : multiset (\u03b1 \u2192\u2080 M)} (a : \u03b1) :\n    a \u2208 support (multiset.sum s) \u2192 \u2203 (f : \u03b1 \u2192\u2080 M), \u2203 (H : f \u2208 s), a \u2208 support f :=\n  sorry\n\ntheorem mem_support_finset_sum {\u03b1 : Type u_1} {\u03b9 : Type u_4} {M : Type u_5} [add_comm_monoid M]\n    {s : finset \u03b9} {h : \u03b9 \u2192 \u03b1 \u2192\u2080 M} (a : \u03b1) (ha : a \u2208 support (finset.sum s fun (c : \u03b9) => h c)) :\n    \u2203 (c : \u03b9), \u2203 (H : c \u2208 s), a \u2208 support (h c) :=\n  sorry\n\n@[simp] theorem mem_to_multiset {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) (i : \u03b1) :\n    i \u2208 coe_fn to_multiset f \u2194 i \u2208 support f :=\n  sorry\n\n/-! ### Declarations about `curry` and `uncurry` -/\n\n/-- Given a finitely supported function `f` from a product type `\u03b1 \u00d7 \u03b2` to `\u03b3`,\n`curry f` is the \"curried\" finitely supported function from `\u03b1` to the type of\nfinitely supported functions from `\u03b2` to `\u03b3`. -/\nprotected def curry {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : \u03b1 \u00d7 \u03b2 \u2192\u2080 M) : \u03b1 \u2192\u2080 \u03b2 \u2192\u2080 M :=\n  sum f fun (p : \u03b1 \u00d7 \u03b2) (c : M) => single (prod.fst p) (single (prod.snd p) c)\n\ntheorem sum_curry_index {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {N : Type u_7}\n    [add_comm_monoid M] [add_comm_monoid N] (f : \u03b1 \u00d7 \u03b2 \u2192\u2080 M) (g : \u03b1 \u2192 \u03b2 \u2192 M \u2192 N)\n    (hg\u2080 : \u2200 (a : \u03b1) (b : \u03b2), g a b 0 = 0)\n    (hg\u2081 : \u2200 (a : \u03b1) (b : \u03b2) (c\u2080 c\u2081 : M), g a b (c\u2080 + c\u2081) = g a b c\u2080 + g a b c\u2081) :\n    (sum (finsupp.curry f) fun (a : \u03b1) (f : \u03b2 \u2192\u2080 M) => sum f (g a)) =\n        sum f fun (p : \u03b1 \u00d7 \u03b2) (c : M) => g (prod.fst p) (prod.snd p) c :=\n  sorry\n\n/-- Given a finitely supported function `f` from `\u03b1` to the type of\nfinitely supported functions from `\u03b2` to `M`,\n`uncurry f` is the \"uncurried\" finitely supported function from `\u03b1 \u00d7 \u03b2` to `M`. -/\nprotected def uncurry {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : \u03b1 \u2192\u2080 \u03b2 \u2192\u2080 M) : \u03b1 \u00d7 \u03b2 \u2192\u2080 M :=\n  sum f fun (a : \u03b1) (g : \u03b2 \u2192\u2080 M) => sum g fun (b : \u03b2) (c : M) => single (a, b) c\n\n/-- `finsupp_prod_equiv` defines the `equiv` between `((\u03b1 \u00d7 \u03b2) \u2192\u2080 M)` and `(\u03b1 \u2192\u2080 (\u03b2 \u2192\u2080 M))` given by\ncurrying and uncurrying. -/\ndef finsupp_prod_equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M] :\n    (\u03b1 \u00d7 \u03b2 \u2192\u2080 M) \u2243 (\u03b1 \u2192\u2080 \u03b2 \u2192\u2080 M) :=\n  equiv.mk finsupp.curry finsupp.uncurry sorry sorry\n\ntheorem filter_curry {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : \u03b1 \u00d7 \u03b2 \u2192\u2080 M) (p : \u03b1 \u2192 Prop) :\n    finsupp.curry (filter (fun (a : \u03b1 \u00d7 \u03b2) => p (prod.fst a)) f) = filter p (finsupp.curry f) :=\n  sorry\n\ntheorem support_curry {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (f : \u03b1 \u00d7 \u03b2 \u2192\u2080 M) : support (finsupp.curry f) \u2286 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\u207b\u00b9 on the domain.\n-/\ndef comap_has_scalar {\u03b1 : Type u_1} {M : Type u_5} {G : Type u_9} [group G] [mul_action G \u03b1]\n    [add_comm_monoid M] : has_scalar G (\u03b1 \u2192\u2080 M) :=\n  has_scalar.mk fun (g : G) (f : \u03b1 \u2192\u2080 M) => comap_domain (fun (a : \u03b1) => g\u207b\u00b9 \u2022 a) f sorry\n\n/--\nScalar multiplication by a group element,\ngiven by precomposition with the action of g\u207b\u00b9 on the domain,\nis multiplicative in g.\n-/\ndef comap_mul_action {\u03b1 : Type u_1} {M : Type u_5} {G : Type u_9} [group G] [mul_action G \u03b1]\n    [add_comm_monoid M] : mul_action G (\u03b1 \u2192\u2080 M) :=\n  mul_action.mk sorry sorry\n\n/--\nScalar multiplication by a group element,\ngiven by precomposition with the action of g\u207b\u00b9 on the domain,\nis additive in the second argument.\n-/\ndef comap_distrib_mul_action {\u03b1 : Type u_1} {M : Type u_5} {G : Type u_9} [group G] [mul_action G \u03b1]\n    [add_comm_monoid M] : distrib_mul_action G (\u03b1 \u2192\u2080 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\u207b\u00b9. -/\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 \u2192\u2080 M) :=\n  comap_distrib_mul_action\n\n@[simp] theorem comap_smul_single {\u03b1 : Type u_1} {M : Type u_5} {G : Type u_9} [group G]\n    [mul_action G \u03b1] [add_comm_monoid M] (g : G) (a : \u03b1) (b : M) :\n    g \u2022 single a b = single (g \u2022 a) b :=\n  sorry\n\n@[simp] theorem comap_smul_apply {\u03b1 : Type u_1} {M : Type u_5} {G : Type u_9} [group G]\n    [mul_action G \u03b1] [add_comm_monoid M] (g : G) (f : \u03b1 \u2192\u2080 M) (a : \u03b1) :\n    coe_fn (g \u2022 f) a = coe_fn f (g\u207b\u00b9 \u2022 a) :=\n  rfl\n\nprotected instance has_scalar {\u03b1 : Type u_1} {M : Type u_5} {R : Type u_11} [semiring R]\n    [add_comm_monoid M] [semimodule R M] : has_scalar R (\u03b1 \u2192\u2080 M) :=\n  has_scalar.mk fun (a : R) (v : \u03b1 \u2192\u2080 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' (\u03b1 : Type u_1) (M : Type u_5) {R : Type u_11} {_x : semiring R}\n    [add_comm_monoid M] [semimodule R M] {a : \u03b1} {b : R} {v : \u03b1 \u2192\u2080 M} :\n    coe_fn (b \u2022 v) a = b \u2022 coe_fn v a :=\n  rfl\n\nprotected instance semimodule (\u03b1 : Type u_1) (M : Type u_5) {R : Type u_11} [semiring R]\n    [add_comm_monoid M] [semimodule R M] : semimodule R (\u03b1 \u2192\u2080 M) :=\n  semimodule.mk sorry sorry\n\ntheorem support_smul {\u03b1 : 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 : \u03b1 \u2192\u2080 M} : support (b \u2022 g) \u2286 support g :=\n  sorry\n\n@[simp] theorem filter_smul {\u03b1 : Type u_1} {M : Type u_5} {R : Type u_11} {p : \u03b1 \u2192 Prop}\n    {_x : semiring R} [add_comm_monoid M] [semimodule R M] {b : R} {v : \u03b1 \u2192\u2080 M} :\n    filter p (b \u2022 v) = b \u2022 filter p v :=\n  coe_fn_injective (set.indicator_smul (set_of fun (x : \u03b1) => p x) b \u21d1v)\n\ntheorem map_domain_smul {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} {R : Type u_11}\n    {_x : semiring R} [add_comm_monoid M] [semimodule R M] {f : \u03b1 \u2192 \u03b2} (b : R) (v : \u03b1 \u2192\u2080 M) :\n    map_domain f (b \u2022 v) = b \u2022 map_domain f v :=\n  sorry\n\n@[simp] theorem smul_single {\u03b1 : 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 : \u03b1) (b : M) :\n    c \u2022 single a b = single a (c \u2022 b) :=\n  map_range_single\n\n@[simp] theorem smul_single' {\u03b1 : Type u_1} {R : Type u_11} {_x : semiring R} (c : R) (a : \u03b1)\n    (b : R) : c \u2022 single a b = single a (c * b) :=\n  smul_single c a b\n\ntheorem smul_single_one {\u03b1 : Type u_1} {R : Type u_11} [semiring R] (a : \u03b1) (b : R) :\n    b \u2022 single a 1 = single a b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (b \u2022 single a 1 = single a b)) (smul_single b a 1)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (single a (b \u2022 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 {\u03b1 : Type u_1} {R : Type u_11} [semiring R] {a : \u03b1} {b : R}\n    {v : \u03b1 \u2192\u2080 R} : coe_fn (b \u2022 v) a = b \u2022 coe_fn v a :=\n  rfl\n\ntheorem sum_smul_index {\u03b1 : Type u_1} {M : Type u_5} {R : Type u_11} [semiring R]\n    [add_comm_monoid M] {g : \u03b1 \u2192\u2080 R} {b : R} {h : \u03b1 \u2192 R \u2192 M} (h0 : \u2200 (i : \u03b1), h i 0 = 0) :\n    sum (b \u2022 g) h = sum g fun (i : \u03b1) (a : R) => h i (b * a) :=\n  sum_map_range_index h0\n\ntheorem sum_smul_index' {\u03b1 : 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 : \u03b1 \u2192\u2080 M} {b : R} {h : \u03b1 \u2192 M \u2192 N}\n    (h0 : \u2200 (i : \u03b1), h i 0 = 0) : sum (b \u2022 g) h = sum g fun (i : \u03b1) (c : M) => h i (b \u2022 c) :=\n  sum_map_range_index h0\n\ntheorem sum_mul {\u03b1 : Type u_1} {R : Type u_11} {S : Type u_12} [semiring R] [semiring S] (b : S)\n    (s : \u03b1 \u2192\u2080 R) {f : \u03b1 \u2192 R \u2192 S} : sum s f * b = sum s fun (a : \u03b1) (c : R) => f a c * b :=\n  sorry\n\ntheorem mul_sum {\u03b1 : Type u_1} {R : Type u_11} {S : Type u_12} [semiring R] [semiring S] (b : S)\n    (s : \u03b1 \u2192\u2080 R) {f : \u03b1 \u2192 R \u2192 S} : b * sum s f = sum s fun (a : \u03b1) (c : R) => b * f a c :=\n  sorry\n\nprotected instance unique_of_right {\u03b1 : Type u_1} {R : Type u_11} [semiring R] [subsingleton R] :\n    unique (\u03b1 \u2192\u2080 R) :=\n  unique.mk { default := Inhabited.default } sorry\n\n/-- Given an `add_comm_monoid M` and `s : set \u03b1`, `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 {\u03b1 : Type u_1} (s : set \u03b1) (M : Type u_2) [add_comm_monoid M] :\n    (Subtype fun (f : \u03b1 \u2192\u2080 M) => \u2191(support f) \u2286 s) \u2243 (\u21a5s \u2192\u2080 M) :=\n  equiv.mk\n    (fun (f : Subtype fun (f : \u03b1 \u2192\u2080 M) => \u2191(support f) \u2286 s) =>\n      subtype_domain (fun (x : \u03b1) => x \u2208 s) (subtype.val f))\n    (fun (f : \u21a5s \u2192\u2080 M) => { val := map_domain subtype.val f, property := sorry }) sorry sorry\n\n/-- Given `add_comm_monoid M` and `e : \u03b1 \u2243 \u03b2`, `dom_congr e` is the corresponding `equiv` between\n`\u03b1 \u2192\u2080 M` and `\u03b2 \u2192\u2080 M`. -/\nprotected def dom_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_5} [add_comm_monoid M]\n    (e : \u03b1 \u2243 \u03b2) : (\u03b1 \u2192\u2080 M) \u2243+ (\u03b2 \u2192\u2080 M) :=\n  add_equiv.mk (map_domain \u21d1e) (map_domain \u21d1(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 `\u03a3 (i : \u03b9), \u03b1s i` to `M` and\nan index element `i : \u03b9`, `split l i` is the `i`th component of `l`,\na finitely supported function from `as i` to `M`. -/\ndef split {\u03b9 : Type u_4} {M : Type u_5} {\u03b1s : \u03b9 \u2192 Type u_13} [HasZero M]\n    (l : (sigma fun (i : \u03b9) => \u03b1s i) \u2192\u2080 M) (i : \u03b9) : \u03b1s i \u2192\u2080 M :=\n  comap_domain (sigma.mk i) l sorry\n\ntheorem split_apply {\u03b9 : Type u_4} {M : Type u_5} {\u03b1s : \u03b9 \u2192 Type u_13} [HasZero M]\n    (l : (sigma fun (i : \u03b9) => \u03b1s i) \u2192\u2080 M) (i : \u03b9) (x : \u03b1s 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 `\u03a3 (i : \u03b9), \u03b1s i` to `\u03b2`,\n`split_support l` is the finset of indices in `\u03b9` that appear in the support of `l`. -/\ndef split_support {\u03b9 : Type u_4} {M : Type u_5} {\u03b1s : \u03b9 \u2192 Type u_13} [HasZero M]\n    (l : (sigma fun (i : \u03b9) => \u03b1s i) \u2192\u2080 M) : finset \u03b9 :=\n  finset.image sigma.fst (support l)\n\ntheorem mem_split_support_iff_nonzero {\u03b9 : Type u_4} {M : Type u_5} {\u03b1s : \u03b9 \u2192 Type u_13} [HasZero M]\n    (l : (sigma fun (i : \u03b9) => \u03b1s i) \u2192\u2080 M) (i : \u03b9) : i \u2208 split_support l \u2194 split l i \u2260 0 :=\n  sorry\n\n/-- Given `l`, a finitely supported function from the sigma type `\u03a3 i, \u03b1s i` to `\u03b2` and\nan `\u03b9`-indexed family `g` of functions from `(\u03b1s i \u2192\u2080 \u03b2)` to `\u03b3`, `split_comp` defines a\nfinitely supported function from the index type `\u03b9` to `\u03b3` given by composing `g i` with\n`split l i`. -/\ndef split_comp {\u03b9 : Type u_4} {M : Type u_5} {N : Type u_7} {\u03b1s : \u03b9 \u2192 Type u_13} [HasZero M]\n    (l : (sigma fun (i : \u03b9) => \u03b1s i) \u2192\u2080 M) [HasZero N] (g : (i : \u03b9) \u2192 (\u03b1s i \u2192\u2080 M) \u2192 N)\n    (hg : \u2200 (i : \u03b9) (x : \u03b1s i \u2192\u2080 M), x = 0 \u2194 g i x = 0) : \u03b9 \u2192\u2080 N :=\n  mk (split_support l) (fun (i : \u03b9) => g i (split l i)) sorry\n\ntheorem sigma_support {\u03b9 : Type u_4} {M : Type u_5} {\u03b1s : \u03b9 \u2192 Type u_13} [HasZero M]\n    (l : (sigma fun (i : \u03b9) => \u03b1s i) \u2192\u2080 M) :\n    support l = finset.sigma (split_support l) fun (i : \u03b9) => support (split l i) :=\n  sorry\n\ntheorem sigma_sum {\u03b9 : Type u_4} {M : Type u_5} {N : Type u_7} {\u03b1s : \u03b9 \u2192 Type u_13} [HasZero M]\n    (l : (sigma fun (i : \u03b9) => \u03b1s i) \u2192\u2080 M) [add_comm_monoid N]\n    (f : (sigma fun (i : \u03b9) => \u03b1s i) \u2192 M \u2192 N) :\n    sum l f =\n        finset.sum (split_support l)\n          fun (i : \u03b9) => sum (split l i) fun (a : \u03b1s 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 `\u2115` given by\nthe multiplicities of the elements of `s`. -/\ndef to_finsupp {\u03b1 : Type u_1} : multiset \u03b1 \u2243+ (\u03b1 \u2192\u2080 \u2115) := add_equiv.symm finsupp.to_multiset\n\n@[simp] theorem to_finsupp_support {\u03b1 : Type u_1} (s : multiset \u03b1) :\n    finsupp.support (coe_fn to_finsupp s) = to_finset s :=\n  rfl\n\n@[simp] theorem to_finsupp_apply {\u03b1 : Type u_1} (s : multiset \u03b1) (a : \u03b1) :\n    coe_fn (coe_fn to_finsupp s) a = count a s :=\n  rfl\n\ntheorem to_finsupp_zero {\u03b1 : Type u_1} : coe_fn to_finsupp 0 = 0 := add_equiv.map_zero to_finsupp\n\ntheorem to_finsupp_add {\u03b1 : Type u_1} (s : multiset \u03b1) (t : multiset \u03b1) :\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 {\u03b1 : Type u_1} (a : \u03b1) :\n    coe_fn to_finsupp (a ::\u2098 0) = finsupp.single a 1 :=\n  sorry\n\n@[simp] theorem to_finsupp_to_multiset {\u03b1 : Type u_1} (s : multiset \u03b1) :\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 {\u03b1 : Type u_1} {s : multiset \u03b1} {f : \u03b1 \u2192\u2080 \u2115} :\n    coe_fn to_finsupp s = f \u2194 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 {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) :\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 {\u03b1 : Type u_1} {M : Type u_5} [preorder M] [HasZero M] :\n    preorder (\u03b1 \u2192\u2080 M) :=\n  preorder.mk (fun (f g : \u03b1 \u2192\u2080 M) => \u2200 (s : \u03b1), coe_fn f s \u2264 coe_fn g s)\n    (fun (a b : \u03b1 \u2192\u2080 M) =>\n      (\u2200 (s : \u03b1), coe_fn a s \u2264 coe_fn b s) \u2227 \u00ac\u2200 (s : \u03b1), coe_fn b s \u2264 coe_fn a s)\n    sorry sorry\n\nprotected instance partial_order {\u03b1 : Type u_1} {M : Type u_5} [partial_order M] [HasZero M] :\n    partial_order (\u03b1 \u2192\u2080 M) :=\n  partial_order.mk preorder.le preorder.lt sorry sorry sorry\n\nprotected instance add_left_cancel_semigroup {\u03b1 : Type u_1} {M : Type u_5}\n    [ordered_cancel_add_comm_monoid M] : add_left_cancel_semigroup (\u03b1 \u2192\u2080 M) :=\n  add_left_cancel_semigroup.mk add_monoid.add sorry sorry\n\nprotected instance add_right_cancel_semigroup {\u03b1 : Type u_1} {M : Type u_5}\n    [ordered_cancel_add_comm_monoid M] : add_right_cancel_semigroup (\u03b1 \u2192\u2080 M) :=\n  add_right_cancel_semigroup.mk add_monoid.add sorry sorry\n\nprotected instance ordered_cancel_add_comm_monoid {\u03b1 : Type u_1} {M : Type u_5}\n    [ordered_cancel_add_comm_monoid M] : ordered_cancel_add_comm_monoid (\u03b1 \u2192\u2080 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 {\u03b1 : Type u_1} {M : Type u_5} [preorder M] [HasZero M] {f : \u03b1 \u2192\u2080 M} {g : \u03b1 \u2192\u2080 M} :\n    f \u2264 g \u2194 \u2200 (x : \u03b1), coe_fn f x \u2264 coe_fn g x :=\n  iff.rfl\n\ntheorem le_iff {\u03b1 : Type u_1} {M : Type u_5} [canonically_ordered_add_monoid M] (f : \u03b1 \u2192\u2080 M)\n    (g : \u03b1 \u2192\u2080 M) : f \u2264 g \u2194 \u2200 (s : \u03b1), s \u2208 support f \u2192 coe_fn f s \u2264 coe_fn g s :=\n  sorry\n\n@[simp] theorem add_eq_zero_iff {\u03b1 : Type u_1} {M : Type u_5} [canonically_ordered_add_monoid M]\n    (f : \u03b1 \u2192\u2080 M) (g : \u03b1 \u2192\u2080 M) : f + g = 0 \u2194 f = 0 \u2227 g = 0 :=\n  sorry\n\n/-- `finsupp.to_multiset` as an order isomorphism. -/\ndef order_iso_multiset {\u03b1 : Type u_1} : (\u03b1 \u2192\u2080 \u2115) \u2243o multiset \u03b1 :=\n  rel_iso.mk (add_equiv.to_equiv to_multiset) sorry\n\n@[simp] theorem coe_order_iso_multiset {\u03b1 : Type u_1} : \u21d1order_iso_multiset = \u21d1to_multiset := rfl\n\n@[simp] theorem coe_order_iso_multiset_symm {\u03b1 : Type u_1} :\n    \u21d1(order_iso.symm order_iso_multiset) = \u21d1multiset.to_finsupp :=\n  rfl\n\ntheorem to_multiset_strict_mono {\u03b1 : Type u_1} : strict_mono \u21d1to_multiset :=\n  order_iso.strict_mono order_iso_multiset\n\ntheorem sum_id_lt_of_lt {\u03b1 : Type u_1} (m : \u03b1 \u2192\u2080 \u2115) (n : \u03b1 \u2192\u2080 \u2115) (h : m < n) :\n    (sum m fun (_x : \u03b1) => id) < sum n fun (_x : \u03b1) => id :=\n  sorry\n\n/-- The order on `\u03c3 \u2192\u2080 \u2115` is well-founded.-/\ntheorem lt_wf (\u03b1 : Type u_1) : well_founded Less :=\n  subrelation.wf sum_id_lt_of_lt\n    (inv_image.wf (fun (x : \u03b1 \u2192\u2080 \u2115) => sum x fun (_x : \u03b1) => id) nat.lt_wf)\n\nprotected instance decidable_le (\u03b1 : Type u_1) : DecidableRel LessEq :=\n  fun (m n : \u03b1 \u2192\u2080 \u2115) => eq.mpr sorry finset.decidable_dforall_finset\n\n@[simp] theorem nat_add_sub_cancel {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) (g : \u03b1 \u2192\u2080 \u2115) : f + g - g = f :=\n  ext fun (a : \u03b1) => nat.add_sub_cancel (coe_fn f a) (coe_fn g a)\n\n@[simp] theorem nat_add_sub_cancel_left {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) (g : \u03b1 \u2192\u2080 \u2115) : f + g - f = g :=\n  ext fun (a : \u03b1) => nat.add_sub_cancel_left (coe_fn f a) (coe_fn g a)\n\ntheorem nat_add_sub_of_le {\u03b1 : Type u_1} {f : \u03b1 \u2192\u2080 \u2115} {g : \u03b1 \u2192\u2080 \u2115} (h : f \u2264 g) : f + (g - f) = g :=\n  ext fun (a : \u03b1) => nat.add_sub_of_le (h a)\n\ntheorem nat_sub_add_cancel {\u03b1 : Type u_1} {f : \u03b1 \u2192\u2080 \u2115} {g : \u03b1 \u2192\u2080 \u2115} (h : f \u2264 g) : g - f + f = g :=\n  ext fun (a : \u03b1) => nat.sub_add_cancel (h a)\n\nprotected instance canonically_ordered_add_monoid {\u03b1 : Type u_1} :\n    canonically_ordered_add_monoid (\u03b1 \u2192\u2080 \u2115) :=\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 : \u03b1 \u2192\u2080 \u2115` consists of all pairs `(t\u2081, t\u2082) : (\u03b1 \u2192\u2080 \u2115) \u00d7 (\u03b1 \u2192\u2080 \u2115)` such that `t\u2081 + t\u2082 = s`.\nThe finitely supported function `antidiagonal s` is equal to the multiplicities of these pairs. -/\ndef antidiagonal {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) : (\u03b1 \u2192\u2080 \u2115) \u00d7 (\u03b1 \u2192\u2080 \u2115) \u2192\u2080 \u2115 :=\n  coe_fn multiset.to_finsupp\n    (multiset.map (prod.map \u21d1multiset.to_finsupp \u21d1multiset.to_finsupp)\n      (multiset.antidiagonal (coe_fn to_multiset f)))\n\n@[simp] theorem mem_antidiagonal_support {\u03b1 : Type u_1} {f : \u03b1 \u2192\u2080 \u2115} {p : (\u03b1 \u2192\u2080 \u2115) \u00d7 (\u03b1 \u2192\u2080 \u2115)} :\n    p \u2208 support (antidiagonal f) \u2194 prod.fst p + prod.snd p = f :=\n  sorry\n\ntheorem swap_mem_antidiagonal_support {\u03b1 : Type u_1} {n : \u03b1 \u2192\u2080 \u2115} {f : (\u03b1 \u2192\u2080 \u2115) \u00d7 (\u03b1 \u2192\u2080 \u2115)} :\n    prod.swap f \u2208 support (antidiagonal n) \u2194 f \u2208 support (antidiagonal n) :=\n  sorry\n\ntheorem antidiagonal_support_filter_fst_eq {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) (g : \u03b1 \u2192\u2080 \u2115) :\n    finset.filter (fun (p : (\u03b1 \u2192\u2080 \u2115) \u00d7 (\u03b1 \u2192\u2080 \u2115)) => prod.fst p = g) (support (antidiagonal f)) =\n        ite (g \u2264 f) (singleton (g, f - g)) \u2205 :=\n  sorry\n\ntheorem antidiagonal_support_filter_snd_eq {\u03b1 : Type u_1} (f : \u03b1 \u2192\u2080 \u2115) (g : \u03b1 \u2192\u2080 \u2115) :\n    finset.filter (fun (p : (\u03b1 \u2192\u2080 \u2115) \u00d7 (\u03b1 \u2192\u2080 \u2115)) => prod.snd p = g) (support (antidiagonal f)) =\n        ite (g \u2264 f) (singleton (f - g, g)) \u2205 :=\n  sorry\n\n@[simp] theorem antidiagonal_zero {\u03b1 : 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 {\u03b1 : Type u_1} {M : Type u_2} [add_comm_monoid M] (n : \u03b1 \u2192\u2080 \u2115)\n    (f : (\u03b1 \u2192\u2080 \u2115) \u2192 (\u03b1 \u2192\u2080 \u2115) \u2192 M) :\n    (finset.sum (support (antidiagonal n))\n          fun (p : (\u03b1 \u2192\u2080 \u2115) \u00d7 (\u03b1 \u2192\u2080 \u2115)) => f (prod.fst p) (prod.snd p)) =\n        finset.sum (support (antidiagonal n))\n          fun (p : (\u03b1 \u2192\u2080 \u2115) \u00d7 (\u03b1 \u2192\u2080 \u2115)) => f (prod.snd p) (prod.fst p) :=\n  sorry\n\n/-- The set `{m : \u03b1 \u2192\u2080 \u2115 | m \u2264 n}` as a `finset`. -/\ndef Iic_finset {\u03b1 : Type u_1} (n : \u03b1 \u2192\u2080 \u2115) : finset (\u03b1 \u2192\u2080 \u2115) :=\n  finset.image prod.fst (support (antidiagonal n))\n\n@[simp] theorem mem_Iic_finset {\u03b1 : Type u_1} {m : \u03b1 \u2192\u2080 \u2115} {n : \u03b1 \u2192\u2080 \u2115} :\n    m \u2208 Iic_finset n \u2194 m \u2264 n :=\n  sorry\n\n@[simp] theorem coe_Iic_finset {\u03b1 : Type u_1} (n : \u03b1 \u2192\u2080 \u2115) : \u2191(Iic_finset n) = set.Iic n := sorry\n\n/-- Let `n : \u03b1 \u2192\u2080 \u2115` be a finitely supported function.\nThe set of `m : \u03b1 \u2192\u2080 \u2115` that are coordinatewise less than or equal to `n`,\nis a finite set. -/\ntheorem finite_le_nat {\u03b1 : Type u_1} (n : \u03b1 \u2192\u2080 \u2115) : set.finite (set_of fun (m : \u03b1 \u2192\u2080 \u2115) => m \u2264 n) :=\n  sorry\n\n/-- Let `n : \u03b1 \u2192\u2080 \u2115` be a finitely supported function.\nThe set of `m : \u03b1 \u2192\u2080 \u2115` that are coordinatewise less than or equal to `n`,\nbut not equal to `n` everywhere, is a finite set. -/\ntheorem finite_lt_nat {\u03b1 : Type u_1} (n : \u03b1 \u2192\u2080 \u2115) : set.finite (set_of fun (m : \u03b1 \u2192\u2080 \u2115) => m < n) :=\n  set.finite.subset (finite_le_nat n) fun (m : \u03b1 \u2192\u2080 \u2115) => le_of_lt\n\nend finsupp\n\n\nnamespace multiset\n\n\ntheorem to_finsuppstrict_mono {\u03b1 : Type u_1} : strict_mono \u21d1to_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 \u2964 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 \u22d9 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\u2081 u\u2082\n\nvariables {C : Type u\u2081} [category.{v} C] [has_limits C]\nvariables {D : Type u\u2082} [category.{v} D] [has_limits D]\nvariables (G : C \u2964 D) [preserves_limits G]\nvariables {X : Top.{v}} (F : presheaf C X)\nvariables {\u03b9 : Type v} (U : \u03b9 \u2192 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 \u22d9 G`.\n-/\ndef diagram_comp_preserves_limits :\n  diagram F U \u22d9 G \u2245 diagram.{v} (F \u22d9 G) U :=\nbegin\n  fapply nat_iso.of_components,\n  rintro \u27e8j\u27e9,\n  exact (preserves_product.iso _ _),\n  exact (preserves_product.iso _ _),\n  rintros \u27e8\u27e9 \u27e8\u27e9 \u27e8\u27e9,\n  { ext, simp, dsimp, simp, }, -- non-terminal `simp`, but `squeeze_simp` fails\n  { ext,\n    simp only [limit.lift_\u03c0, functor.comp_map, map_lift_pi_comparison, fan.mk_\u03c0_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_\u03c0, functor.comp_map, parallel_pair_map_right, fan.mk_\u03c0_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 \u22d9 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) \u2245\n  (cones.postcompose (diagram_comp_preserves_limits G F U).inv).obj (fork (F \u22d9 G) U) :=\ncones.ext (iso.refl _) (\u03bb 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_\u03c0, fan.mk_\u03c0_app, \u2190G.map_comp, limit.lift_\u03c0_assoc, fan.mk_\u03c0_app] }\nend)\n\nend sheaf_condition\n\nuniverses v u\u2081 u\u2082\n\nopen sheaf_condition sheaf_condition_equalizer_products\n\nvariables {C : Type u\u2081} [category.{v} C] {D : Type u\u2082} [category.{v} D]\nvariables (G : C \u2964 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 \u2964 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 \u22d9 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 \u2964 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 \u2194 presheaf.is_sheaf (F \u22d9 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 \u03b9 U,\n    -- We have that the sheaf condition fork for `F` is a limit fork,\n    obtain \u27e8t\u2081\u27e9 := 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\u2082 := @preserves_limit.preserves _ _ _ _ _ _ _ G _ _ t\u2081,\n    -- As we established above, that image is just the sheaf condition fork\n    -- for `F \u22d9 G` postcomposed with some natural isomorphism,\n    have t\u2083 := is_limit.of_iso_limit t\u2082 (map_cone_fork G F U),\n    -- and as postcomposing by a natural isomorphism preserves limit cones,\n    have t\u2084 := is_limit.postcompose_inv_equiv _ _ t\u2083,\n    -- we have our desired conclusion.\n    exact \u27e8t\u2084\u27e9, },\n  { intros S \u03b9 U,\n    refine \u27e8_\u27e9,\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 \u27e8_|_\u27e9; { 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 \u22d9 G` to the\n      -- image under `G` of the equalizer cone for the sheaf condition diagram.\n      let c := fork (F \u22d9 G) U,\n      obtain \u27e8hc\u27e9 := 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 \u27f6 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.\u03b9,\n        ext1 j,\n        dsimp,\n        simp only [category.assoc, \u2190functor.map_comp_assoc, equalizer.lift_\u03b9,\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 \u22d9 (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 : \u2115)\n\n/-- Constant multivariate functor -/\n@[nolint unused_arguments]\ndef const (A : Type*) (v : typevec.{u} n) : Type* :=\nA\n\ninstance const.inhabited {A \u03b1} [inhabited A] : inhabited (const n A \u03b1) :=\n\u27e8 (default A : A) \u27e9\n\nnamespace const\nopen mvfunctor mvpfunctor\nvariables {n} {A : Type u} {\u03b1 \u03b2 : typevec.{u} n} (f : \u03b1 \u27f9 \u03b2)\n\n/-- Constructor for constant functor -/\nprotected def mk (x : A) : (const n A) \u03b1 := x\n\n/-- Destructor for constant functor -/\nprotected def get (x : (const n A) \u03b1) : A := x\n\n@[simp] protected lemma mk_get (x : (const n A) \u03b1) : const.mk (const.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : A) : const.get (const.mk x : const n A \u03b1) = x := rfl\n\n/-- `map` for constant functor -/\nprotected def map : (const n A) \u03b1 \u2192 (const n A) \u03b2 :=\n\u03bb x, x\n\ninstance : mvfunctor (const n A) :=\n{ map := \u03bb \u03b1 \u03b2 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) \u03b1) :\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       := \u03bb \u03b1 x, mvpfunctor.const.get x,\n  repr      := \u03bb \u03b1 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 \u03c3 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 _) {\u03c3 : 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}} {\u03c3 : 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 : \u03c3 -> B) (p : MvPolynomial.{u4, u1} \u03c3 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} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u2, u2, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u2} A _inst_2)) _inst_5) (fun (_x : AlgHom.{u2, max u4 u2, u3} A (MvPolynomial.{u4, u2} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u2, u2, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u2} A _inst_2)) _inst_5) => (MvPolynomial.{u4, u2} \u03c3 A _inst_2) -> B) ([anonymous].{u2, max u4 u2, u3} A (MvPolynomial.{u4, u2} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u2, u2, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u2} A _inst_2)) _inst_5) (MvPolynomial.aeval.{u2, u3, u4} A B \u03c3 _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} \u03c3 R _inst_1) (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A \u03c3 _inst_2)))) (fun (_x : RingHom.{max u4 u1, max u4 u2} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A \u03c3 _inst_2)))) => (MvPolynomial.{u4, u1} \u03c3 R _inst_1) -> (MvPolynomial.{u4, u2} \u03c3 A _inst_2)) (RingHom.hasCoeToFun.{max u4 u1, max u4 u2} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u4 u2} (MvPolynomial.{u4, u2} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u2, u4} A \u03c3 _inst_2)))) (MvPolynomial.map.{u1, u2, u4} R A \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) => (MvPolynomial.{u4, u1} \u03c3 R _inst_1) -> B) ([anonymous].{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.aeval.{u1, u3, u4} R B \u03c3 _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}} {\u03c3 : 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 : \u03c3 -> B) (p : MvPolynomial.{u4, u3} \u03c3 R _inst_1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u1} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (fun (a : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => MvPolynomial.{u4, u1} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonUnitalNonAssocSemiring.toMul.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _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} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _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} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))) (RingHom.instRingHomClassRingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))))))) (MvPolynomial.map.{u3, u1, u4} R A \u03c3 _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} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (fun (_x : MvPolynomial.{u4, u1} \u03c3 A _inst_2) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u1} \u03c3 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} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) B (SMulZeroClass.toSMul.{u1, max u4 u1} A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (AddMonoid.toZero.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (AddCommMonoid.toAddMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))))))) (DistribSMul.toSMulZeroClass.{u1, max u4 u1} A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (AddMonoid.toAddZeroClass.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (AddCommMonoid.toAddMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))))))) (DistribMulAction.toDistribSMul.{u1, max u4 u1} A (MvPolynomial.{u4, u1} \u03c3 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} \u03c3 A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))))) (Module.toDistribMulAction.{u1, max u4 u1} A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))))) (Algebra.toModule.{u1, max u4 u1} A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _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} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) A (MvPolynomial.{u4, u1} \u03c3 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} \u03c3 A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _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} \u03c3 A _inst_2) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))))) (Algebra.toModule.{u1, max u4 u1} A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _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} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) A (MvPolynomial.{u4, u1} \u03c3 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} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _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} \u03c3 A _inst_2) (CommSemiring.toSemiring.{u1} A _inst_2) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))))) (Algebra.toModule.{u1, max u4 u1} A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _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} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5 (AlgHom.{u1, max u1 u4, u2} A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5) (AlgHom.algHomClass.{u1, max u4 u1, u2} A (MvPolynomial.{u4, u1} \u03c3 A _inst_2) B _inst_2 (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} A A \u03c3 _inst_2 _inst_2 (Algebra.id.{u1} A _inst_2)) _inst_5))))) (MvPolynomial.aeval.{u1, u2, u4} A B \u03c3 _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} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => MvPolynomial.{u4, u1} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonUnitalNonAssocSemiring.toMul.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (NonUnitalNonAssocSemiring.toMul.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _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} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _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} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2)))) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))) (RingHom.instRingHomClassRingHom.{max u3 u4, max u1 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (Semiring.toNonAssocSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))) (Semiring.toNonAssocSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (CommSemiring.toSemiring.{max u1 u4} (MvPolynomial.{u4, u1} \u03c3 A _inst_2) (MvPolynomial.commSemiring.{u1, u4} A \u03c3 _inst_2))))))) (MvPolynomial.map.{u3, u1, u4} R A \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, max u4 u3, u2} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6))))) (MvPolynomial.aeval.{u3, u2, u4} R B \u03c3 _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\u2093'. -/\ntheorem aeval_map_algebraMap (x : \u03c3 \u2192 B) (p : MvPolynomial \u03c3 R) :\n    aeval x (map (algebraMap R A) p) = aeval x p := by\n  rw [aeval_def, aeval_def, eval\u2082_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}) {\u03c3 : 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 : \u03c3 -> A) (p : MvPolynomial.{u4, u1} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) => (MvPolynomial.{u4, u1} \u03c3 R _inst_1) -> B) ([anonymous].{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.aeval.{u1, u3, u4} R B \u03c3 _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u2, succ u3} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) => (MvPolynomial.{u4, u1} \u03c3 R _inst_1) -> A) ([anonymous].{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (MvPolynomial.aeval.{u1, u2, u4} R A \u03c3 _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}) {\u03c3 : 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 : \u03c3 -> A) (p : MvPolynomial.{u4, u3} \u03c3 R _inst_1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, max u4 u3, u2} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6))))) (MvPolynomial.aeval.{u3, u2, u4} R B \u03c3 _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u1, succ u2} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) A (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4 (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u3, max u4 u3, u1} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4))))) (MvPolynomial.aeval.{u3, u1, u4} R A \u03c3 _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\u2093'. -/\ntheorem aeval_algebraMap_apply (x : \u03c3 \u2192 A) (p : MvPolynomial \u03c3 R) :\n    aeval (algebraMap A B \u2218 x) p = algebraMap A B (MvPolynomial.aeval x p) := by\n  rw [aeval_def, aeval_def, \u2190 coe_eval\u2082_hom, \u2190 coe_eval\u2082_hom, map_eval\u2082_hom, \u2190\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}) {\u03c3 : 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 : \u03c3 -> A) (p : MvPolynomial.{u4, u1} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) => (MvPolynomial.{u4, u1} \u03c3 R _inst_1) -> B) ([anonymous].{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.aeval.{u1, u3, u4} R B \u03c3 _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u2, succ u3} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) => (MvPolynomial.{u4, u1} \u03c3 R _inst_1) -> A) ([anonymous].{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (MvPolynomial.aeval.{u1, u2, u4} R A \u03c3 _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}) {\u03c3 : 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 : \u03c3 -> A) (p : MvPolynomial.{u2, u1} \u03c3 R _inst_1), Iff (Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u2, u1} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) B (SMulZeroClass.toSMul.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (AddMonoid.toZero.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6 (AlgHom.{u1, max u1 u2, u3} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u1, max u2 u1, u3} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6))))) (MvPolynomial.aeval.{u1, u3, u2} R B \u03c3 _inst_1 _inst_3 _inst_6 (Function.comp.{succ u2, succ u4, succ u3} \u03c3 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} \u03c3 R _inst_1) => B) p) 0 (Zero.toOfNat0.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 R _inst_1) => B) p) (CommMonoidWithZero.toZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 R _inst_1) => B) p) (CommSemiring.toCommMonoidWithZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 R _inst_1) => B) p) _inst_3))))) (Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u2, u1} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) A (SMulZeroClass.toSMul.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (AddMonoid.toZero.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) R (MvPolynomial.{u2, u1} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u1} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u2 u1} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1))))) (Algebra.toModule.{u1, max u2 u1} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4 (AlgHom.{u1, max u1 u2, u4} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u1, max u2 u1, u4} R (MvPolynomial.{u2, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u1 u2} (MvPolynomial.{u2, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u2} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u4} A _inst_2) (MvPolynomial.algebra.{u1, u1, u2} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4))))) (MvPolynomial.aeval.{u1, u4, u2} R A \u03c3 _inst_1 _inst_2 _inst_4 x) p) (OfNat.ofNat.{u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 R _inst_1) => A) p) 0 (Zero.toOfNat0.{u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 R _inst_1) => A) p) (CommMonoidWithZero.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 R _inst_1) => A) p) (CommSemiring.toCommMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u2, u1} \u03c3 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\u2093'. -/\ntheorem aeval_algebraMap_eq_zero_iff [NoZeroSMulDivisors A B] [Nontrivial B] (x : \u03c3 \u2192 A)\n    (p : MvPolynomial \u03c3 R) : aeval (algebraMap A B \u2218 x) p = 0 \u2194 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}) {\u03c3 : 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 : \u03c3 -> A} {p : MvPolynomial.{u4, u1} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (fun (_x : AlgHom.{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) => (MvPolynomial.{u4, u1} \u03c3 R _inst_1) -> B) ([anonymous].{u1, max u4 u1, u3} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u3} B _inst_3) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_6) (MvPolynomial.aeval.{u1, u3, u4} R B \u03c3 _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u2, succ u3} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (fun (_x : AlgHom.{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) => (MvPolynomial.{u4, u1} \u03c3 R _inst_1) -> A) ([anonymous].{u1, max u4 u1, u2} R (MvPolynomial.{u4, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u4 u1} (MvPolynomial.{u4, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_4) (MvPolynomial.aeval.{u1, u2, u4} R A \u03c3 _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}) {\u03c3 : 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 : \u03c3 -> A} {p : MvPolynomial.{u4, u3} \u03c3 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} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6 (AlgHom.{u3, max u3 u4, u1} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6) (AlgHom.algHomClass.{u3, max u4 u3, u1} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) B _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u1} B _inst_3) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_6))))) (MvPolynomial.aeval.{u3, u1, u4} R B \u03c3 _inst_1 _inst_3 _inst_6 (Function.comp.{succ u4, succ u2, succ u1} \u03c3 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} \u03c3 R _inst_1) => B) p) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => B) p) (CommMonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => B) p) (CommSemiring.toCommMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => B) p) _inst_3))))) (Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) A (SMulZeroClass.toSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toZero.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) R (MvPolynomial.{u4, u3} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u4 u3} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u4 u3} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4 (AlgHom.{u3, max u3 u4, u2} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4) (AlgHom.algHomClass.{u3, max u4 u3, u2} R (MvPolynomial.{u4, u3} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u4} (MvPolynomial.{u4, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u4} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u4} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_4))))) (MvPolynomial.aeval.{u3, u2, u4} R A \u03c3 _inst_1 _inst_2 _inst_4 x) p) (OfNat.ofNat.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => A) p) 0 (Zero.toOfNat0.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => A) p) (CommMonoidWithZero.toZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 R _inst_1) => A) p) (CommSemiring.toCommMonoidWithZero.{u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u4, u3} \u03c3 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\u2093'. -/\ntheorem aeval_algebraMap_eq_zero_iff_of_injective {x : \u03c3 \u2192 A} {p : MvPolynomial \u03c3 R}\n    (h : Function.Injective (algebraMap A B)) : aeval (algebraMap A B \u2218 x) p = 0 \u2194 aeval x p = 0 :=\n  by rw [aeval_algebra_map_apply, \u2190 (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}} {\u03c3 : 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 : \u03c3 -> (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} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u3} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_3) (fun (_x : AlgHom.{u1, max u3 u1, u2} R (MvPolynomial.{u3, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u3} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_3) => (MvPolynomial.{u3, u1} \u03c3 R _inst_1) -> A) ([anonymous].{u1, max u3 u1, u2} R (MvPolynomial.{u3, u1} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u3, u1} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u1, u1, u3} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u1} R _inst_1)) _inst_3) (MvPolynomial.aeval.{u1, u2, u3} R A \u03c3 _inst_1 _inst_2 _inst_3 (fun (i : \u03c3) => (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\u2093.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\u2093.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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R \u03c3 _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 \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R \u03c3 _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 \u03c3 _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} \u03c3 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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u1, u3} R \u03c3 _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 \u03c3 _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) \u03c3 _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}} {\u03c3 : 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 : \u03c3 -> (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} \u03c3 R _inst_1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u1, u3} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u1, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u1, u3} \u03c3 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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) A (SMulZeroClass.toSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (AddMonoid.toZero.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) R (MvPolynomial.{u1, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) R (MvPolynomial.{u1, u3} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3 (AlgHom.{u3, max u3 u1, u2} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3) (AlgHom.algHomClass.{u3, max u1 u3, u2} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) A _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (CommSemiring.toSemiring.{u2} A _inst_2) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _inst_1 _inst_1 (Algebra.id.{u3} R _inst_1)) _inst_3))))) (MvPolynomial.aeval.{u3, u2, u1} R A \u03c3 _inst_1 _inst_2 _inst_3 (fun (i : \u03c3) => 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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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 \u03c3 _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} \u03c3 R _inst_1) (fun (_x : MvPolynomial.{u1, u3} \u03c3 R _inst_1) => (fun (x._@.Mathlib.Algebra.Hom.GroupAction._hyg.2186 : MvPolynomial.{u1, u3} \u03c3 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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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 \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (AddMonoid.toZero.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))))) (DistribSMul.toSMulZeroClass.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (AddMonoid.toAddZeroClass.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (AddCommMonoid.toAddMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))))) (DistribMulAction.toDistribSMul.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)))))) (Module.toDistribMulAction.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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 \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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 \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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} \u03c3 R _inst_1) (CommSemiring.toSemiring.{u3} R _inst_1) (NonUnitalNonAssocSemiring.toAddCommMonoid.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (Semiring.toNonAssocSemiring.{max u1 u3} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1))))) (Algebra.toModule.{u3, max u1 u3} R (MvPolynomial.{u1, u3} \u03c3 R _inst_1) _inst_1 (CommSemiring.toSemiring.{max u3 u1} (MvPolynomial.{u1, u3} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _inst_1)) (MvPolynomial.algebra.{u3, u3, u1} R R \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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 \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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 \u03c3 _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} \u03c3 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} \u03c3 R _inst_1) (MvPolynomial.commSemiring.{u3, u1} R \u03c3 _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 \u03c3 _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)) \u03c3 _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\u2093'. -/\n@[simp]\ntheorem mvPolynomial_aeval_coe (S : Subalgebra R A) (x : \u03c3 \u2192 S) (p : MvPolynomial \u03c3 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 \u2192 Q)\n(i : Q \u2192 R)\n(j : Q \u2192 T)\n(k : S \u2192 T)\n(l : T \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 `\u220f` and `\u2211` operations.\n\n-/\n\n\nopen Function\n\nopen BigOperators\n\nvariable {\u03b9 \u03b1 \u03b2 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 {\u03b9 : 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 : \u03b9 -> M) (s : Finset.{u1} \u03b9), (Finset.Nonempty.{u1} \u03b9 s) -> (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 _inst_1 s (fun (i : \u03b9) => g i))) (Finset.prod.{u3, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : \u03b9) => f (g i)))))\nbut is expected to have type\n  forall {\u03b9 : 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 : \u03b9 -> M) (s : Finset.{u1} \u03b9), (Finset.Nonempty.{u1} \u03b9 s) -> (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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 \u03b9 _inst_1 s (fun (i : \u03b9) => g i))) (Finset.prod.{u3, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : \u03b9) => 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\u2093'. -/\n/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M \u2192 N` be a map\nsubmultiplicative on `{x | p x}`, i.e., `p x \u2192 p y \u2192 f (x * y) \u2264 f x * f y`. Let `g i`, `i \u2208 s`, be\na nonempty finite family of elements of `M` such that `\u2200 i \u2208 s, p (g i)`. Then\n`f (\u220f x in s, g x) \u2264 \u220f 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 \u2192 N) (p : M \u2192 Prop)\n    (h_mul : \u2200 x y, p x \u2192 p y \u2192 f (x * y) \u2264 f x * f y) (hp_mul : \u2200 x y, p x \u2192 p y \u2192 p (x * y))\n    (g : \u03b9 \u2192 M) (s : Finset \u03b9) (hs_nonempty : s.Nonempty) (hs : \u2200 i \u2208 s, p (g i)) :\n    f (\u220f i in s, g i) \u2264 \u220f 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  \u00b7 simp [hs_nonempty.ne_empty]\n  \u00b7 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 \u2192 N` be a map subadditive on `{x | p x}`, i.e., `p x \u2192 p y \u2192 f (x + y) \u2264 f x + f y`. Let\n`g i`, `i \u2208 s`, be a nonempty finite family of elements of `M` such that `\u2200 i \u2208 s, p (g i)`. Then\n`f (\u2211 i in s, g i) \u2264 \u2211 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 {\u03b9 : 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} \u03b9}, (Finset.Nonempty.{u1} \u03b9 s) -> (forall (g : \u03b9 -> 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 \u03b9 _inst_1 s (fun (i : \u03b9) => g i))) (Finset.prod.{u3, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : \u03b9) => f (g i)))))\nbut is expected to have type\n  forall {\u03b9 : 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} \u03b9}, (Finset.Nonempty.{u1} \u03b9 s) -> (forall (g : \u03b9 -> 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 \u03b9 _inst_1 s (fun (i : \u03b9) => g i))) (Finset.prod.{u3, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : \u03b9) => f (g i)))))\nCase conversion may be inaccurate. Consider using '#align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative\u2093'. -/\n/-- If `f : M \u2192 N` is a submultiplicative function, `f (x * y) \u2264 f x * f y` and `g i`, `i \u2208 s`, is a\nnonempty finite family of elements of `M`, then `f (\u220f i in s, g i) \u2264 \u220f i in s, f (g i)`. -/\n@[to_additive le_sum_nonempty_of_subadditive]\ntheorem le_prod_nonempty_of_submultiplicative (f : M \u2192 N) (h_mul : \u2200 x y, f (x * y) \u2264 f x * f y)\n    {s : Finset \u03b9} (hs : s.Nonempty) (g : \u03b9 \u2192 M) : f (\u220f i in s, g i) \u2264 \u220f 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 \u2192 N` is a subadditive function, `f (x + y) \u2264 f x + f y` and `g i`, `i \u2208 s`, is a\nnonempty finite family of elements of `M`, then `f (\u2211 i in s, g i) \u2264 \u2211 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 {\u03b9 : 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 : \u03b9 -> M) {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 _inst_1 s (fun (i : \u03b9) => g i))) (Finset.prod.{u3, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : \u03b9) => f (g i)))))\nbut is expected to have type\n  forall {\u03b9 : 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 : \u03b9 -> M) {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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 \u03b9 _inst_1 s (fun (i : \u03b9) => g i))) (Finset.prod.{u3, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : \u03b9) => 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\u2093'. -/\n/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M \u2192 N` be a map\nsuch that `f 1 = 1` and `f` is submultiplicative on `{x | p x}`, i.e.,\n`p x \u2192 p y \u2192 f (x * y) \u2264 f x * f y`. Let `g i`, `i \u2208 s`, be a finite family of elements of `M` such\nthat `\u2200 i \u2208 s, p (g i)`. Then `f (\u220f i in s, g i) \u2264 \u220f i in s, f (g i)`. -/\n@[to_additive le_sum_of_subadditive_on_pred]\ntheorem le_prod_of_submultiplicative_on_pred (f : M \u2192 N) (p : M \u2192 Prop) (h_one : f 1 = 1)\n    (h_mul : \u2200 x y, p x \u2192 p y \u2192 f (x * y) \u2264 f x * f y) (hp_mul : \u2200 x y, p x \u2192 p y \u2192 p (x * y))\n    (g : \u03b9 \u2192 M) {s : Finset \u03b9} (hs : \u2200 i \u2208 s, p (g i)) : f (\u220f i in s, g i) \u2264 \u220f i in s, f (g i) :=\n  by\n  rcases eq_empty_or_nonempty s with (rfl | hs_nonempty)\n  \u00b7 simp [h_one]\n  \u00b7 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 \u2192 N` be a map\nsuch that `f 0 = 0` and `f` is subadditive on `{x | p x}`, i.e. `p x \u2192 p y \u2192 f (x + y) \u2264 f x + f y`.\nLet `g i`, `i \u2208 s`, be a finite family of elements of `M` such that `\u2200 i \u2208 s, p (g i)`. Then\n`f (\u2211 x in s, g x) \u2264 \u2211 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 {\u03b9 : 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} \u03b9) (g : \u03b9 -> 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 \u03b9 _inst_1 s (fun (i : \u03b9) => g i))) (Finset.prod.{u3, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : \u03b9) => f (g i))))\nbut is expected to have type\n  forall {\u03b9 : 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} \u03b9) (g : \u03b9 -> 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 \u03b9 _inst_1 s (fun (i : \u03b9) => g i))) (Finset.prod.{u3, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u3} N _inst_2) s (fun (i : \u03b9) => f (g i))))\nCase conversion may be inaccurate. Consider using '#align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative\u2093'. -/\n/-- If `f : M \u2192 N` is a submultiplicative function, `f (x * y) \u2264 f x * f y`, `f 1 = 1`, and `g i`,\n`i \u2208 s`, is a finite family of elements of `M`, then `f (\u220f i in s, g i) \u2264 \u220f i in s, f (g i)`. -/\n@[to_additive le_sum_of_subadditive]\ntheorem le_prod_of_submultiplicative (f : M \u2192 N) (h_one : f 1 = 1)\n    (h_mul : \u2200 x y, f (x * y) \u2264 f x * f y) (s : Finset \u03b9) (g : \u03b9 \u2192 M) :\n    f (\u220f i in s, g i) \u2264 \u220f 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 \u2192 N` is a subadditive function, `f (x + y) \u2264 f x + f y`, `f 0 = 0`, and `g i`,\n`i \u2208 s`, is a finite family of elements of `M`, then `f (\u2211 i in s, g i) \u2264 \u2211 i in s, f (g i)`. -/\nadd_decl_doc le_sum_of_subadditive\n\nvariable {f g : \u03b9 \u2192 N} {s t : Finset \u03b9}\n\n/- warning: finset.prod_le_prod' -> Finset.prod_le_prod' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {g : \u03b9 -> N} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => g i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : \u03b9 -> N} {g : \u03b9 -> N} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : \u03b9) => f i)) (Finset.prod.{u1, u2} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : \u03b9) => g i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod' Finset.prod_le_prod'\u2093'. -/\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`\u220f i in s, f i \u2264 \u220f i in s, g i`. -/\n@[to_additive sum_le_sum]\ntheorem prod_le_prod' (h : \u2200 i \u2208 s, f i \u2264 g i) : (\u220f i in s, f i) \u2264 \u220f 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`\u2211 i in s, f i \u2264 \u2211 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : \u03b9 -> N} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.one_le_prod' Finset.one_le_prod'\u2093'. -/\n@[to_additive sum_nonneg]\ntheorem one_le_prod' (h : \u2200 i \u2208 s, 1 \u2264 f i) : 1 \u2264 \u220f 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.one_le_prod'' Finset.one_le_prod''\u2093'. -/\n@[to_additive Finset.sum_nonneg']\ntheorem one_le_prod'' (h : \u2200 i : \u03b9, 1 \u2264 f i) : 1 \u2264 \u220f i : \u03b9 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => 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 {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : \u03b9 -> N} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : \u03b9) => 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'\u2093'. -/\n@[to_additive sum_nonpos]\ntheorem prod_le_one' (h : \u2200 i \u2208 s, f i \u2264 1) : (\u220f i in s, f i) \u2264 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {s : Finset.{u1} \u03b9} {t : Finset.{u1} \u03b9}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) s t) -> (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i t) -> (Not (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : \u03b9 -> N} {s : Finset.{u2} \u03b9} {t : Finset.{u2} \u03b9}, (HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) s t) -> (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i t) -> (Not (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : \u03b9) => f i)) (Finset.prod.{u1, u2} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) t (fun (i : \u03b9) => 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'\u2093'. -/\n@[to_additive sum_le_sum_of_subset_of_nonneg]\ntheorem prod_le_prod_of_subset_of_one_le' (h : s \u2286 t) (hf : \u2200 i \u2208 t, i \u2209 s \u2192 1 \u2264 f i) :\n    (\u220f i in s, f i) \u2264 \u220f i in t, f i := by\n  classical calc\n      (\u220f i in s, f i) \u2264 (\u220f i in t \\ s, f i) * \u220f i in s, f i :=\n        le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp]\n      _ = \u220f i in t \\ s \u222a s, f i := (prod_union sdiff_disjoint).symm\n      _ = \u220f 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N}, (forall (x : \u03b9), 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} \u03b9) N (PartialOrder.toPreorder.{u1} (Finset.{u1} \u03b9) (Finset.partialOrder.{u1} \u03b9)) (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2)) (fun (s : Finset.{u1} \u03b9) => Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : \u03b9) => f x)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N}, (forall (x : \u03b9), 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} \u03b9) N (PartialOrder.toPreorder.{u1} (Finset.{u1} \u03b9) (Finset.partialOrder.{u1} \u03b9)) (PartialOrder.toPreorder.{u2} N (OrderedCommMonoid.toPartialOrder.{u2} N _inst_2)) (fun (s : Finset.{u1} \u03b9) => Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : \u03b9) => f x)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le'\u2093'. -/\n@[to_additive sum_mono_set_of_nonneg]\ntheorem prod_mono_set_of_one_le' (hf : \u2200 x, 1 \u2264 f x) : Monotone fun s => \u220f 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} [_inst_3 : Fintype.{u1} \u03b9] {s : Finset.{u1} \u03b9}, (forall (x : \u03b9), 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : \u03b9) => f x)) (Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.univ.{u1} \u03b9 _inst_3) (fun (x : \u03b9) => f x)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : \u03b9 -> N} [_inst_3 : Fintype.{u2} \u03b9] {s : Finset.{u2} \u03b9}, (forall (x : \u03b9), 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (x : \u03b9) => f x)) (Finset.prod.{u1, u2} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) (Finset.univ.{u2} \u03b9 _inst_3) (fun (x : \u03b9) => 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'\u2093'. -/\n@[to_additive sum_le_univ_sum_of_nonneg]\ntheorem prod_le_univ_prod_of_one_le' [Fintype \u03b9] {s : Finset \u03b9} (w : \u2200 x, 1 \u2264 f x) :\n    (\u220f x in s, f x) \u2264 \u220f 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : \u03b9 -> N} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : \u03b9) => 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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'\u2093'. -/\n@[to_additive sum_eq_zero_iff_of_nonneg]\ntheorem prod_eq_one_iff_of_one_le' :\n    (\u2200 i \u2208 s, 1 \u2264 f i) \u2192 ((\u220f i in s, f i) = 1 \u2194 \u2200 i \u2208 s, f i = 1) := by\n  classical\n    apply Finset.induction_on s\n    exact fun _ => \u27e8fun _ _ => False.elim, fun _ => rfl\u27e9\n    intro a s ha ih H\n    have : \u2200 i \u2208 s, 1 \u2264 f i := fun _ => H _ \u2218 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (i : \u03b9) => 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : \u03b9 -> N} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (i : \u03b9) => 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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'\u2093'. -/\n@[to_additive sum_eq_zero_iff_of_nonneg]\ntheorem prod_eq_one_iff_of_le_one' :\n    (\u2200 i \u2208 s, f i \u2264 1) \u2192 ((\u220f i in s, f i) = 1 \u2194 \u2200 i \u2208 s, f i = 1) :=\n  @prod_eq_one_iff_of_one_le' _ N\u1d52\u1d48 _ _ _\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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {f : \u03b9 -> N} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 : \u03b9}, (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : \u03b9) => f x))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] {f : \u03b9 -> N} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 : \u03b9}, (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} N _inst_2) s (fun (x : \u03b9) => f x))))\nCase conversion may be inaccurate. Consider using '#align finset.single_le_prod' Finset.single_le_prod'\u2093'. -/\n@[to_additive single_le_sum]\ntheorem single_le_prod' (hf : \u2200 i \u2208 s, 1 \u2264 f i) {a} (h : a \u2208 s) : f a \u2264 \u220f x in s, f x :=\n  calc\n    f a = \u220f i in {a}, f i := prod_singleton.symm\n    _ \u2264 \u220f 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] (s : Finset.{u1} \u03b9) (f : \u03b9 -> N) (n : N), (forall (x : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (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} \u03b9 s)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] (s : Finset.{u2} \u03b9) (f : \u03b9 -> N) (n : N), (forall (x : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (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} \u03b9 s)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_pow_card Finset.prod_le_pow_card\u2093'. -/\n@[to_additive sum_le_card_nsmul]\ntheorem prod_le_pow_card (s : Finset \u03b9) (f : \u03b9 \u2192 N) (n : N) (h : \u2200 x \u2208 s, f x \u2264 n) :\n    s.Prod f \u2264 n ^ s.card :=\n  by\n  refine' (Multiset.prod_le_pow_card (s.val.map f) n _).trans _\n  \u00b7 simpa using h\n  \u00b7 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] (s : Finset.{u1} \u03b9) (f : \u03b9 -> N) (n : N), (forall (x : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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} \u03b9 s)) (Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s f))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {N : Type.{u1}} [_inst_2 : OrderedCommMonoid.{u1} N] (s : Finset.{u2} \u03b9) (f : \u03b9 -> N) (n : N), (forall (x : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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} \u03b9 s)) (Finset.prod.{u1, u2} N \u03b9 (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\u2093'. -/\n@[to_additive card_nsmul_le_sum]\ntheorem pow_card_le_prod (s : Finset \u03b9) (f : \u03b9 \u2192 N) (n : N) (h : \u2200 x \u2208 s, n \u2264 f x) :\n    n ^ s.card \u2264 s.Prod f :=\n  @Finset.prod_le_pow_card _ N\u1d52\u1d48 _ _ _ _ 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\u1d62_le_card_mul /-\ntheorem card_bunion\u1d62_le_card_mul [DecidableEq \u03b2] (s : Finset \u03b9) (f : \u03b9 \u2192 Finset \u03b2) (n : \u2115)\n    (h : \u2200 a \u2208 s, (f a).card \u2264 n) : (s.bunion\u1d62 f).card \u2264 s.card * n :=\n  card_bunion\u1d62_le.trans <| sum_le_card_nsmul _ _ _ h\n#align finset.card_bUnion_le_card_mul Finset.card_bunion\u1d62_le_card_mul\n-/\n\nvariable {\u03b9' : Type _} [DecidableEq \u03b9']\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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {s : Finset.{u1} \u03b9} {\u03b9' : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b9'] {t : Finset.{u3} \u03b9'} {g : \u03b9 -> \u03b9'} {f : \u03b9 -> N}, (forall (y : \u03b9'), (Not (Membership.Mem.{u3, u3} \u03b9' (Finset.{u3} \u03b9') (Finset.hasMem.{u3} \u03b9') 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} \u03b9 (fun (x : \u03b9) => Eq.{succ u3} \u03b9' (g x) y) (fun (a : \u03b9) => _inst_3 (g a) y) s) (fun (x : \u03b9) => 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 \u03b9' (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (y : \u03b9') => Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} \u03b9 (fun (x : \u03b9) => Eq.{succ u3} \u03b9' (g x) y) (fun (a : \u03b9) => _inst_3 (g a) y) s) (fun (x : \u03b9) => f x))) (Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : \u03b9) => f x)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {s : Finset.{u1} \u03b9} {\u03b9' : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b9'] {t : Finset.{u3} \u03b9'} {g : \u03b9 -> \u03b9'} {f : \u03b9 -> N}, (forall (y : \u03b9'), (Not (Membership.mem.{u3, u3} \u03b9' (Finset.{u3} \u03b9') (Finset.instMembershipFinset.{u3} \u03b9') 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} \u03b9 (fun (x : \u03b9) => Eq.{succ u3} \u03b9' (g x) y) (fun (a : \u03b9) => _inst_3 (g a) y) s) (fun (x : \u03b9) => 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 \u03b9' (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (y : \u03b9') => Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} \u03b9 (fun (x : \u03b9) => Eq.{succ u3} \u03b9' (g x) y) (fun (a : \u03b9) => _inst_3 (g a) y) s) (fun (x : \u03b9) => f x))) (Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : \u03b9) => 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'\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y \u00abexpr \u2209 \u00bb t) -/\n@[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg]\ntheorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset \u03b9'} {g : \u03b9 \u2192 \u03b9'} {f : \u03b9 \u2192 N}\n    (h : \u2200 (y) (_ : y \u2209 t), (1 : N) \u2264 \u220f x in s.filter\u2093 fun x => g x = y, f x) :\n    (\u220f y in t, \u220f x in s.filter\u2093 fun x => g x = y, f x) \u2264 \u220f x in s, f x :=\n  calc\n    (\u220f y in t, \u220f x in s.filter\u2093 fun x => g x = y, f x) \u2264\n        \u220f y in t \u222a s.image g, \u220f x in s.filter\u2093 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    _ = \u220f 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 {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {s : Finset.{u1} \u03b9} {\u03b9' : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b9'] {t : Finset.{u3} \u03b9'} {g : \u03b9 -> \u03b9'} {f : \u03b9 -> N}, (forall (y : \u03b9'), (Not (Membership.Mem.{u3, u3} \u03b9' (Finset.{u3} \u03b9') (Finset.hasMem.{u3} \u03b9') 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} \u03b9 (fun (x : \u03b9) => Eq.{succ u3} \u03b9' (g x) y) (fun (a : \u03b9) => _inst_3 (g a) y) s) (fun (x : \u03b9) => 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : \u03b9) => f x)) (Finset.prod.{u2, u3} N \u03b9' (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (y : \u03b9') => Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} \u03b9 (fun (x : \u03b9) => Eq.{succ u3} \u03b9' (g x) y) (fun (a : \u03b9) => _inst_3 (g a) y) s) (fun (x : \u03b9) => f x))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {N : Type.{u2}} [_inst_2 : OrderedCommMonoid.{u2} N] {s : Finset.{u1} \u03b9} {\u03b9' : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b9'] {t : Finset.{u3} \u03b9'} {g : \u03b9 -> \u03b9'} {f : \u03b9 -> N}, (forall (y : \u03b9'), (Not (Membership.mem.{u3, u3} \u03b9' (Finset.{u3} \u03b9') (Finset.instMembershipFinset.{u3} \u03b9') 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} \u03b9 (fun (x : \u03b9) => Eq.{succ u3} \u03b9' (g x) y) (fun (a : \u03b9) => _inst_3 (g a) y) s) (fun (x : \u03b9) => 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) s (fun (x : \u03b9) => f x)) (Finset.prod.{u2, u3} N \u03b9' (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) t (fun (y : \u03b9') => Finset.prod.{u2, u1} N \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} N _inst_2) (Finset.filter.{u1} \u03b9 (fun (x : \u03b9) => Eq.{succ u3} \u03b9' (g x) y) (fun (a : \u03b9) => _inst_3 (g a) y) s) (fun (x : \u03b9) => 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'\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (y \u00abexpr \u2209 \u00bb t) -/\n@[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos]\ntheorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset \u03b9'} {g : \u03b9 \u2192 \u03b9'} {f : \u03b9 \u2192 N}\n    (h : \u2200 (y) (_ : y \u2209 t), (\u220f x in s.filter\u2093 fun x => g x = y, f x) \u2264 1) :\n    (\u220f x in s, f x) \u2264 \u220f y in t, \u220f x in s.filter\u2093 fun x => g x = y, f x :=\n  @prod_fiberwise_le_prod_of_one_le_prod_fiber' _ N\u1d52\u1d48 _ _ _ _ _ _ _ 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 {\u03b9 : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] (f : \u03b9 -> G) (s : Finset.{u1} \u03b9), 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 \u03b9 (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} G \u03b9 (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : \u03b9) => 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 {\u03b9 : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] (f : \u03b9 -> G) (s : Finset.{u1} \u03b9), 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 \u03b9 (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} G \u03b9 (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : \u03b9) => 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\u2093'. -/\ntheorem abs_sum_le_sum_abs {G : Type _} [LinearOrderedAddCommGroup G] (f : \u03b9 \u2192 G) (s : Finset \u03b9) :\n    |\u2211 i in s, f i| \u2264 \u2211 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 {\u03b9 : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] {f : \u03b9 -> G} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} G \u03b9 (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] {f : \u03b9 -> G} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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 \u03b9 (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} G \u03b9 (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg\u2093'. -/\ntheorem abs_sum_of_nonneg {G : Type _} [LinearOrderedAddCommGroup G] {f : \u03b9 \u2192 G} {s : Finset \u03b9}\n    (hf : \u2200 i \u2208 s, 0 \u2264 f i) : |\u2211 i : \u03b9 in s, f i| = \u2211 i : \u03b9 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 {\u03b9 : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] {f : \u03b9 -> G} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), 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 \u03b9 (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} G \u03b9 (AddCommGroup.toAddCommMonoid.{u2} G (OrderedAddCommGroup.toAddCommGroup.{u2} G (LinearOrderedAddCommGroup.toOrderedAddCommGroup.{u2} G _inst_1))) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {G : Type.{u2}} [_inst_1 : LinearOrderedAddCommGroup.{u2} G] {f : \u03b9 -> G} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), 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 \u03b9 (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} G \u03b9 (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} G (LinearOrderedCancelAddCommMonoid.toOrderedCancelAddCommMonoid.{u2} G (LinearOrderedAddCommGroup.toLinearOrderedAddCancelCommMonoid.{u2} G _inst_1))) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.abs_sum_of_nonneg' Finset.abs_sum_of_nonneg'\u2093'. -/\ntheorem abs_sum_of_nonneg' {G : Type _} [LinearOrderedAddCommGroup G] {f : \u03b9 \u2192 G} {s : Finset \u03b9}\n    (hf : \u2200 i, 0 \u2264 f i) : |\u2211 i : \u03b9 in s, f i| = \u2211 i : \u03b9 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : LinearOrderedCommRing.{u2} R] {f : \u03b9 -> R} {s : Finset.{u1} \u03b9}, 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 \u03b9 (LinearOrderedCommRing.toCommMonoid.{u2} R _inst_1) s (fun (x : \u03b9) => f x))) (Finset.prod.{u2, u1} R \u03b9 (LinearOrderedCommRing.toCommMonoid.{u2} R _inst_1) s (fun (x : \u03b9) => 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : LinearOrderedCommRing.{u2} R] {f : \u03b9 -> R} {s : Finset.{u1} \u03b9}, 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 \u03b9 (LinearOrderedCommRing.toCommMonoid.{u2} R _inst_1) s (fun (x : \u03b9) => f x))) (Finset.prod.{u2, u1} R \u03b9 (LinearOrderedCommRing.toCommMonoid.{u2} R _inst_1) s (fun (x : \u03b9) => 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\u2093'. -/\ntheorem abs_prod {R : Type _} [LinearOrderedCommRing R] {f : \u03b9 \u2192 R} {s : Finset \u03b9} :\n    |\u220f x in s, f x| = \u220f x in s, |f x| :=\n  (absHom.toMonoidHom : R \u2192* R).map_prod _ _\n#align finset.abs_prod Finset.abs_prod\n\nsection Pigeonhole\n\nvariable [DecidableEq \u03b2]\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) -> (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) (f a) t)) -> (forall (n : Nat), (forall (a : \u03b2), (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) a t) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} \u03b1 (Finset.filter.{u1} \u03b1 (fun (x : \u03b1) => Eq.{succ u2} \u03b2 (f x) a) (fun (a_1 : \u03b1) => _inst_1 (f a_1) a) s)) n)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} \u03b1 s) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) n (Finset.card.{u2} \u03b2 t))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (forall (a : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) a s) -> (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) (f a) t)) -> (forall (n : Nat), (forall (a : \u03b2), (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) a t) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b1 (Finset.filter.{u2} \u03b1 (fun (x : \u03b1) => Eq.{succ u1} \u03b2 (f x) a) (fun (a_1 : \u03b1) => _inst_1 (f a_1) a) s)) n)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b1 s) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) n (Finset.card.{u1} \u03b2 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\u2093'. -/\ntheorem card_le_mul_card_image_of_maps_to {f : \u03b1 \u2192 \u03b2} {s : Finset \u03b1} {t : Finset \u03b2}\n    (Hf : \u2200 a \u2208 s, f a \u2208 t) (n : \u2115) (hn : \u2200 a \u2208 t, (s.filter\u2093 fun x => f x = a).card \u2264 n) :\n    s.card \u2264 n * t.card :=\n  calc\n    s.card = \u2211 a in t, (s.filter\u2093 fun x => f x = a).card := card_eq_sum_card_fiberwise Hf\n    _ \u2264 \u2211 _ 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} (s : Finset.{u1} \u03b1) (n : Nat), (forall (a : \u03b2), (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) a (Finset.image.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_1 a b) f s)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} \u03b1 (Finset.filter.{u1} \u03b1 (fun (x : \u03b1) => Eq.{succ u2} \u03b2 (f x) a) (fun (a_1 : \u03b1) => _inst_1 (f a_1) a) s)) n)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} \u03b1 s) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) n (Finset.card.{u2} \u03b2 (Finset.image.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_1 a b) f s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} (s : Finset.{u2} \u03b1) (n : Nat), (forall (a : \u03b2), (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) a (Finset.image.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_1 a b) f s)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b1 (Finset.filter.{u2} \u03b1 (fun (x : \u03b1) => Eq.{succ u1} \u03b2 (f x) a) (fun (a_1 : \u03b1) => _inst_1 (f a_1) a) s)) n)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b1 s) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) n (Finset.card.{u1} \u03b2 (Finset.image.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _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\u2093'. -/\ntheorem card_le_mul_card_image {f : \u03b1 \u2192 \u03b2} (s : Finset \u03b1) (n : \u2115)\n    (hn : \u2200 a \u2208 s.image f, (s.filter\u2093 fun x => f x = a).card \u2264 n) : s.card \u2264 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) -> (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) (f a) t)) -> (forall (n : Nat), (forall (a : \u03b2), (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) a t) -> (LE.le.{0} Nat Nat.hasLe n (Finset.card.{u1} \u03b1 (Finset.filter.{u1} \u03b1 (fun (x : \u03b1) => Eq.{succ u2} \u03b2 (f x) a) (fun (a_1 : \u03b1) => _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} \u03b2 t)) (Finset.card.{u1} \u03b1 s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (forall (a : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) a s) -> (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) (f a) t)) -> (forall (n : Nat), (forall (a : \u03b2), (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) a t) -> (LE.le.{0} Nat instLENat n (Finset.card.{u2} \u03b1 (Finset.filter.{u2} \u03b1 (fun (x : \u03b1) => Eq.{succ u1} \u03b2 (f x) a) (fun (a_1 : \u03b1) => _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} \u03b2 t)) (Finset.card.{u2} \u03b1 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\u2093'. -/\ntheorem mul_card_image_le_card_of_maps_to {f : \u03b1 \u2192 \u03b2} {s : Finset \u03b1} {t : Finset \u03b2}\n    (Hf : \u2200 a \u2208 s, f a \u2208 t) (n : \u2115) (hn : \u2200 a \u2208 t, n \u2264 (s.filter\u2093 fun x => f x = a).card) :\n    n * t.card \u2264 s.card :=\n  calc\n    n * t.card = \u2211 _ in t, n := by simp [mul_comm]\n    _ \u2264 \u2211 a in t, (s.filter\u2093 fun x => f x = a).card := (sum_le_sum hn)\n    _ = s.card := by rw [\u2190 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b2} (s : Finset.{u1} \u03b1) (n : Nat), (forall (a : \u03b2), (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) a (Finset.image.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_1 a b) f s)) -> (LE.le.{0} Nat Nat.hasLe n (Finset.card.{u1} \u03b1 (Finset.filter.{u1} \u03b1 (fun (x : \u03b1) => Eq.{succ u2} \u03b2 (f x) a) (fun (a_1 : \u03b1) => _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} \u03b2 (Finset.image.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_1 a b) f s))) (Finset.card.{u1} \u03b1 s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b2} (s : Finset.{u2} \u03b1) (n : Nat), (forall (a : \u03b2), (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) a (Finset.image.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_1 a b) f s)) -> (LE.le.{0} Nat instLENat n (Finset.card.{u2} \u03b1 (Finset.filter.{u2} \u03b1 (fun (x : \u03b1) => Eq.{succ u1} \u03b2 (f x) a) (fun (a_1 : \u03b1) => _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} \u03b2 (Finset.image.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_1 a b) f s))) (Finset.card.{u2} \u03b1 s))\nCase conversion may be inaccurate. Consider using '#align finset.mul_card_image_le_card Finset.mul_card_image_le_card\u2093'. -/\ntheorem mul_card_image_le_card {f : \u03b1 \u2192 \u03b2} (s : Finset \u03b1) (n : \u2115)\n    (hn : \u2200 a \u2208 s.image f, n \u2264 (s.filter\u2093 fun x => f x = a).card) : n * (s.image f).card \u2264 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 \u03b1] {s : Finset \u03b1} {B : Finset (Finset \u03b1)} {n : \u2115}\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 : \u2200 a \u2208 s, (B.filter\u2093 <| (\u00b7 \u2208 \u00b7) a).card \u2264 n) :\n    (\u2211 t in B, (s \u2229 t).card) \u2264 s.card * n :=\n  by\n  refine' le_trans _ (s.sum_le_card_nsmul _ _ h)\n  simp_rw [\u2190 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 \u03b1] (h : \u2200 a, (B.filter\u2093 <| (\u00b7 \u2208 \u00b7) a).card \u2264 n) :\n    (\u2211 s in B, s.card) \u2264 Fintype.card \u03b1 * n :=\n  calc\n    (\u2211 s in B, s.card) = \u2211 s in B, (univ \u2229 s).card := by simp_rw [univ_inter]\n    _ \u2264 Fintype.card \u03b1 * 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 : \u2200 a \u2208 s, n \u2264 (B.filter\u2093 <| (\u00b7 \u2208 \u00b7) a).card) :\n    s.card * n \u2264 \u2211 t in B, (s \u2229 t).card :=\n  by\n  apply (s.card_nsmul_le_sum _ _ h).trans\n  simp_rw [\u2190 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 \u03b1] (h : \u2200 a, n \u2264 (B.filter\u2093 <| (\u00b7 \u2208 \u00b7) a).card) :\n    Fintype.card \u03b1 * n \u2264 \u2211 s in B, s.card :=\n  calc\n    Fintype.card \u03b1 * n \u2264 \u2211 s in B, (univ \u2229 s).card := le_sum_card_inter fun a _ => h a\n    _ = \u2211 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 : \u2200 a \u2208 s, (B.filter\u2093 <| (\u00b7 \u2208 \u00b7) a).card = n) :\n    (\u2211 t in B, (s \u2229 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 \u03b1] (h : \u2200 a, (B.filter\u2093 <| (\u00b7 \u2208 \u00b7) a).card = n) :\n    (\u2211 s in B, s.card) = Fintype.card \u03b1 * n := by\n  simp_rw [Fintype.card, \u2190 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\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b1] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (Finset.{u2} \u03b1)}, (Set.PairwiseDisjoint.{u2, u1} (Finset.{u2} \u03b1) \u03b9 (Finset.partialOrder.{u2} \u03b1) (Finset.orderBot.{u2} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (Finset.Set.hasCoeT.{u1} \u03b9))) s) f) -> (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) -> (Finset.Nonempty.{u2} \u03b1 (f i))) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} \u03b9 s) (Finset.card.{u2} \u03b1 (Finset.bunion\u1d62.{u1, u2} \u03b9 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s f)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u2} \u03b9} {f : \u03b9 -> (Finset.{u1} \u03b1)}, (Set.PairwiseDisjoint.{u1, u2} (Finset.{u1} \u03b1) \u03b9 (Finset.partialOrder.{u1} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1) (Finset.toSet.{u2} \u03b9 s) f) -> (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) -> (Finset.Nonempty.{u1} \u03b1 (f i))) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b9 s) (Finset.card.{u1} \u03b1 (Finset.bunion\u1d62.{u2, u1} \u03b9 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s f)))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_bUnion Finset.card_le_card_bunion\u1d62\u2093'. -/\ntheorem card_le_card_bunion\u1d62 {s : Finset \u03b9} {f : \u03b9 \u2192 Finset \u03b1} (hs : (s : Set \u03b9).PairwiseDisjoint f)\n    (hf : \u2200 i \u2208 s, (f i).Nonempty) : s.card \u2264 (s.bunion\u1d62 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\u1d62\n\n/- warning: finset.card_le_card_bUnion_add_card_fiber -> Finset.card_le_card_bunion\u1d62_add_card_fiber is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b1] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (Finset.{u2} \u03b1)}, (Set.PairwiseDisjoint.{u2, u1} (Finset.{u2} \u03b1) \u03b9 (Finset.partialOrder.{u2} \u03b1) (Finset.orderBot.{u2} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (Finset.Set.hasCoeT.{u1} \u03b9))) s) f) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} \u03b9 s) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u2} \u03b1 (Finset.bunion\u1d62.{u1, u2} \u03b9 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s f)) (Finset.card.{u1} \u03b9 (Finset.filter.{u1} \u03b9 (fun (i : \u03b9) => Eq.{succ u2} (Finset.{u2} \u03b1) (f i) (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b1) (Finset.hasEmptyc.{u2} \u03b1))) (fun (a : \u03b9) => Finset.decidableEq.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (f a) (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b1) (Finset.hasEmptyc.{u2} \u03b1))) s))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u2} \u03b9} {f : \u03b9 -> (Finset.{u1} \u03b1)}, (Set.PairwiseDisjoint.{u1, u2} (Finset.{u1} \u03b1) \u03b9 (Finset.partialOrder.{u1} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1) (Finset.toSet.{u2} \u03b9 s) f) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b9 s) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} \u03b1 (Finset.bunion\u1d62.{u2, u1} \u03b9 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) s f)) (Finset.card.{u2} \u03b9 (Finset.filter.{u2} \u03b9 (fun (i : \u03b9) => Eq.{succ u1} (Finset.{u1} \u03b1) (f i) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b1) (Finset.instEmptyCollectionFinset.{u1} \u03b1))) (fun (a : \u03b9) => Finset.decidableEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (f a) (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b1) (Finset.instEmptyCollectionFinset.{u1} \u03b1))) s))))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_bUnion_add_card_fiber Finset.card_le_card_bunion\u1d62_add_card_fiber\u2093'. -/\ntheorem card_le_card_bunion\u1d62_add_card_fiber {s : Finset \u03b9} {f : \u03b9 \u2192 Finset \u03b1}\n    (hs : (s : Set \u03b9).PairwiseDisjoint f) :\n    s.card \u2264 (s.bunion\u1d62 f).card + (s.filter\u2093 fun i => f i = \u2205).card :=\n  by\n  rw [\u2190 Finset.filter_card_add_filter_neg_card_eq_card fun i => f i = \u2205, 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\u1d62_add_card_fiber\n\n/- warning: finset.card_le_card_bUnion_add_one -> Finset.card_le_card_bunion\u1d62_add_one is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {\u03b1 : Type.{u2}} [_inst_1 : DecidableEq.{succ u2} \u03b1] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (Finset.{u2} \u03b1)}, (Function.Injective.{succ u1, succ u2} \u03b9 (Finset.{u2} \u03b1) f) -> (Set.PairwiseDisjoint.{u2, u1} (Finset.{u2} \u03b1) \u03b9 (Finset.partialOrder.{u2} \u03b1) (Finset.orderBot.{u2} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b9) (Set.{u1} \u03b9) (Finset.Set.hasCoeT.{u1} \u03b9))) s) f) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} \u03b9 s) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u2} \u03b1 (Finset.bunion\u1d62.{u1, u2} \u03b9 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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 {\u03b9 : Type.{u2}} {\u03b1 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {s : Finset.{u2} \u03b9} {f : \u03b9 -> (Finset.{u1} \u03b1)}, (Function.Injective.{succ u2, succ u1} \u03b9 (Finset.{u1} \u03b1) f) -> (Set.PairwiseDisjoint.{u1, u2} (Finset.{u1} \u03b1) \u03b9 (Finset.partialOrder.{u1} \u03b1) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1) (Finset.toSet.{u2} \u03b9 s) f) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b9 s) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} \u03b1 (Finset.bunion\u1d62.{u2, u1} \u03b9 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _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\u1d62_add_one\u2093'. -/\ntheorem card_le_card_bunion\u1d62_add_one {s : Finset \u03b9} {f : \u03b9 \u2192 Finset \u03b1} (hf : Injective f)\n    (hs : (s : Set \u03b9).PairwiseDisjoint f) : s.card \u2264 (s.bunion\u1d62 f).card + 1 :=\n  (card_le_card_bunion\u1d62_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\u1d62_add_one\n\nend DoubleCounting\n\nsection CanonicallyOrderedMonoid\n\nvariable [CanonicallyOrderedMonoid M] {f : \u03b9 \u2192 M} {s t : Finset \u03b9}\n\n/- warning: finset.prod_eq_one_iff' -> Finset.prod_eq_one_iff' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9}, Iff (Eq.{succ u2} M (Finset.prod.{u2, u1} M \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : \u03b9) => 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9}, Iff (Eq.{succ u2} M (Finset.prod.{u2, u1} M \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : \u03b9) => 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 : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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'\u2093'. -/\n@[simp, to_additive sum_eq_zero_iff]\ntheorem prod_eq_one_iff' : (\u220f x in s, f x) = 1 \u2194 \u2200 x \u2208 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9} {t : Finset.{u1} \u03b9}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : \u03b9) => f x)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) t (fun (x : \u03b9) => f x)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : CanonicallyOrderedMonoid.{u1} M] {f : \u03b9 -> M} {s : Finset.{u2} \u03b9} {t : Finset.{u2} \u03b9}, (HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) s (fun (x : \u03b9) => f x)) (Finset.prod.{u1, u2} M \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) t (fun (x : \u03b9) => f x)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod_of_subset' Finset.prod_le_prod_of_subset'\u2093'. -/\n@[to_additive sum_le_sum_of_subset]\ntheorem prod_le_prod_of_subset' (h : s \u2286 t) : (\u220f x in s, f x) \u2264 \u220f x in t, f x :=\n  prod_le_prod_of_subset_of_one_le' h fun x h\u2081 h\u2082 => 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] (f : \u03b9 -> M), Monotone.{u1, u2} (Finset.{u1} \u03b9) M (PartialOrder.toPreorder.{u1} (Finset.{u1} \u03b9) (Finset.partialOrder.{u1} \u03b9)) (PartialOrder.toPreorder.{u2} M (OrderedCommMonoid.toPartialOrder.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1))) (fun (s : Finset.{u1} \u03b9) => Finset.prod.{u2, u1} M \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : \u03b9) => f x))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : CanonicallyOrderedMonoid.{u1} M] (f : \u03b9 -> M), Monotone.{u2, u1} (Finset.{u2} \u03b9) M (PartialOrder.toPreorder.{u2} (Finset.{u2} \u03b9) (Finset.partialOrder.{u2} \u03b9)) (PartialOrder.toPreorder.{u1} M (OrderedCommMonoid.toPartialOrder.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1))) (fun (s : Finset.{u2} \u03b9) => Finset.prod.{u1, u2} M \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) s (fun (x : \u03b9) => f x))\nCase conversion may be inaccurate. Consider using '#align finset.prod_mono_set' Finset.prod_mono_set'\u2093'. -/\n@[to_additive sum_mono_set]\ntheorem prod_mono_set' (f : \u03b9 \u2192 M) : Monotone fun s => \u220f x in s, f x := fun s\u2081 s\u2082 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : CanonicallyOrderedMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9} {t : Finset.{u1} \u03b9}, (forall (x : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) s (fun (x : \u03b9) => f x)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u2} M _inst_1)) t (fun (x : \u03b9) => f x)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : CanonicallyOrderedMonoid.{u1} M] {f : \u03b9 -> M} {s : Finset.{u2} \u03b9} {t : Finset.{u2} \u03b9}, (forall (x : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) s (fun (x : \u03b9) => f x)) (Finset.prod.{u1, u2} M \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} M (CanonicallyOrderedMonoid.toOrderedCommMonoid.{u1} M _inst_1)) t (fun (x : \u03b9) => f x)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod_of_ne_one' Finset.prod_le_prod_of_ne_one'\u2093'. -/\n@[to_additive sum_le_sum_of_ne_zero]\ntheorem prod_le_prod_of_ne_one' (h : \u2200 x \u2208 s, f x \u2260 1 \u2192 x \u2208 t) : (\u220f x in s, f x) \u2264 \u220f x in t, f x :=\n  by\n  classical calc\n      (\u220f x in s, f x) =\n          (\u220f x in s.filter fun x => f x = 1, f x) * \u220f x in s.filter fun x => f x \u2260 1, f x :=\n        by\n        rw [\u2190 prod_union, filter_union_filter_neg_eq] <;>\n          exact disjoint_filter.2 fun _ _ h n_h => n_h h\n      _ \u2264 \u220f 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 : \u03b9 \u2192 M} {s t : Finset \u03b9}\n\n/- warning: finset.prod_lt_prod' -> Finset.prod_lt_prod' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {g : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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} \u03b9 (fun (i : \u03b9) => Exists.{0} (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => g i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {g : \u03b9 -> M} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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} \u03b9 (fun (i : \u03b9) => And (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => f i)) (Finset.prod.{u1, u2} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => g i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_lt_prod' Finset.prod_lt_prod'\u2093'. -/\n@[to_additive sum_lt_sum]\ntheorem prod_lt_prod' (Hle : \u2200 i \u2208 s, f i \u2264 g i) (Hlt : \u2203 i \u2208 s, f i < g i) :\n    (\u220f i in s, f i) < \u220f i in s, g i := by\n  classical\n    rcases Hlt with \u27e8i, hi, hlt\u27e9\n    rw [\u2190 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {g : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (Finset.Nonempty.{u1} \u03b9 s) -> (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => g i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {g : \u03b9 -> M} {s : Finset.{u2} \u03b9}, (Finset.Nonempty.{u2} \u03b9 s) -> (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => f i)) (Finset.prod.{u1, u2} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => g i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_lt_prod_of_nonempty' Finset.prod_lt_prod_of_nonempty'\u2093'. -/\n@[to_additive sum_lt_sum_of_nonempty]\ntheorem prod_lt_prod_of_nonempty' (hs : s.Nonempty) (Hlt : \u2200 i \u2208 s, f i < g i) :\n    (\u220f i in s, f i) < \u220f i in s, g i := by\n  apply prod_lt_prod'\n  \u00b7 intro i hi\n    apply le_of_lt (Hlt i hi)\n  cases' hs with i hi\n  exact \u27e8i, hi, Hlt i hi\u27e9\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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9} {t : Finset.{u1} \u03b9}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b9) (Finset.hasSubset.{u1} \u03b9) s t) -> (forall {i : \u03b9}, (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i t) -> (Not (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) j t) -> (Not (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (j : \u03b9) => f j)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) t (fun (j : \u03b9) => f j))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {s : Finset.{u2} \u03b9} {t : Finset.{u2} \u03b9}, (HasSubset.Subset.{u2} (Finset.{u2} \u03b9) (Finset.instHasSubsetFinset.{u2} \u03b9) s t) -> (forall {i : \u03b9}, (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i t) -> (Not (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) j t) -> (Not (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (j : \u03b9) => f j)) (Finset.prod.{u1, u2} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) t (fun (j : \u03b9) => f j))))\nCase conversion may be inaccurate. Consider using '#align finset.prod_lt_prod_of_subset' Finset.prod_lt_prod_of_subset'\u2093'. -/\n@[to_additive sum_lt_sum_of_subset]\ntheorem prod_lt_prod_of_subset' (h : s \u2286 t) {i : \u03b9} (ht : i \u2208 t) (hs : i \u2209 s) (hlt : 1 < f i)\n    (hle : \u2200 j \u2208 t, j \u2209 s \u2192 1 \u2264 f j) : (\u220f j in s, f j) < \u220f j in t, f j := by\n  classical calc\n      (\u220f j in s, f j) < \u220f j in insert i s, f j :=\n        by\n        rw [prod_insert hs]\n        exact lt_mul_of_one_lt_left' (\u220f j in s, f j) hlt\n      _ \u2264 \u220f j in t, f j := by\n        apply prod_le_prod_of_subset_of_one_le'\n        \u00b7 simp [Finset.insert_subset, h, ht]\n        \u00b7 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9} {i : \u03b9} {j : \u03b9}, (Ne.{succ u1} \u03b9 j i) -> (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) -> (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) k s) -> (Ne.{succ u1} \u03b9 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (k : \u03b9) => f k)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {s : Finset.{u2} \u03b9} {i : \u03b9} {j : \u03b9}, (Ne.{succ u2} \u03b9 j i) -> (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) i s) -> (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) k s) -> (Ne.{succ u2} \u03b9 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (k : \u03b9) => f k)))\nCase conversion may be inaccurate. Consider using '#align finset.single_lt_prod' Finset.single_lt_prod'\u2093'. -/\n@[to_additive single_lt_sum]\ntheorem single_lt_prod' {i j : \u03b9} (hij : j \u2260 i) (hi : i \u2208 s) (hj : j \u2208 s) (hlt : 1 < f j)\n    (hle : \u2200 k \u2208 s, k \u2260 i \u2192 1 \u2264 f k) : f i < \u220f k in s, f k :=\n  calc\n    f i = \u220f k in {i}, f k := prod_singleton.symm\n    _ < \u220f 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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} \u03b9 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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} \u03b9 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.one_lt_prod Finset.one_lt_prod\u2093'. -/\n@[to_additive sum_pos]\ntheorem one_lt_prod (h : \u2200 i \u2208 s, 1 < f i) (hs : s.Nonempty) : 1 < \u220f 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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} \u03b9 s) -> (LT.lt.{u2} M (Preorder.toLT.{u2} M (PartialOrder.toPreorder.{u2} M (OrderedCancelCommMonoid.toPartialOrder.{u2} M _inst_1))) (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => 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 {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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} \u03b9 s) -> (LT.lt.{u1} M (Preorder.toLT.{u1} M (PartialOrder.toPreorder.{u1} M (OrderedCancelCommMonoid.toPartialOrder.{u1} M _inst_1))) (Finset.prod.{u1, u2} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => 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\u2093'. -/\n@[to_additive]\ntheorem prod_lt_one (h : \u2200 i \u2208 s, f i < 1) (hs : s.Nonempty) : (\u220f 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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} \u03b9 (fun (i : \u03b9) => Exists.{0} (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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} \u03b9 (fun (i : \u03b9) => And (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.one_lt_prod' Finset.one_lt_prod'\u2093'. -/\n@[to_additive sum_pos']\ntheorem one_lt_prod' (h : \u2200 i \u2208 s, 1 \u2264 f i) (hs : \u2203 i \u2208 s, 1 < f i) : 1 < \u220f 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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} \u03b9 (fun (i : \u03b9) => Exists.{0} (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => 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 {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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} \u03b9 (fun (i : \u03b9) => And (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => 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'\u2093'. -/\n@[to_additive]\ntheorem prod_lt_one' (h : \u2200 i \u2208 s, f i \u2264 1) (hs : \u2203 i \u2208 s, f i < 1) : (\u220f 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : OrderedCancelCommMonoid.{u2} M] {s : Finset.{u1} \u03b9} {f : \u03b9 -> M} {g : \u03b9 -> M}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => g i))) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) -> (Eq.{succ u2} M (f i) (g i))))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : OrderedCancelCommMonoid.{u1} M] {s : Finset.{u2} \u03b9} {f : \u03b9 -> M} {g : \u03b9 -> M}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => f i)) (Finset.prod.{u1, u2} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M _inst_1) s (fun (i : \u03b9) => g i))) (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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\u2093'. -/\n@[to_additive]\ntheorem prod_eq_prod_iff_of_le {f g : \u03b9 \u2192 M} (h : \u2200 i \u2208 s, f i \u2264 g i) :\n    ((\u220f i in s, f i) = \u220f i in s, g i) \u2194 \u2200 i \u2208 s, f i = g i := by\n  classical\n    revert h\n    refine'\n      Finset.induction_on s (fun _ => \u27e8fun _ _ => False.elim, fun _ => rfl\u27e9) fun a s ha ih H => _\n    specialize ih fun i => H i \u2218 Finset.mem_insert_of_mem\n    rw [Finset.prod_insert ha, Finset.prod_insert ha, Finset.forall_mem_insert, \u2190 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 \u2218 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 : \u03b9 \u2192 M} {s t : Finset \u03b9}\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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {g : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : \u03b9) => g i))) -> (Exists.{succ u1} \u03b9 (fun (i : \u03b9) => Exists.{0} (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {g : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : \u03b9) => g i))) -> (Exists.{succ u1} \u03b9 (fun (i : \u03b9) => And (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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'\u2093'. -/\n@[to_additive exists_lt_of_sum_lt]\ntheorem exists_lt_of_prod_lt' (Hlt : (\u220f i in s, f i) < \u220f i in s, g i) : \u2203 i \u2208 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {f : \u03b9 -> M} {g : \u03b9 -> M} {s : Finset.{u1} \u03b9}, (Finset.Nonempty.{u1} \u03b9 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : \u03b9) => g i))) -> (Exists.{succ u1} \u03b9 (fun (i : \u03b9) => Exists.{0} (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u2}} {M : Type.{u1}} [_inst_1 : LinearOrderedCancelCommMonoid.{u1} M] {f : \u03b9 -> M} {g : \u03b9 -> M} {s : Finset.{u2} \u03b9}, (Finset.Nonempty.{u2} \u03b9 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 \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u1} M _inst_1)) s (fun (i : \u03b9) => f i)) (Finset.prod.{u1, u2} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u1} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u1} M _inst_1)) s (fun (i : \u03b9) => g i))) -> (Exists.{succ u2} \u03b9 (fun (i : \u03b9) => And (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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'\u2093'. -/\n@[to_additive exists_le_of_sum_le]\ntheorem exists_le_of_prod_le' (hs : s.Nonempty) (Hle : (\u220f i in s, f i) \u2264 \u220f i in s, g i) :\n    \u2203 i \u2208 s, f i \u2264 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {s : Finset.{u1} \u03b9} (f : \u03b9 -> M), (Eq.{succ u2} M (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : \u03b9) => 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} \u03b9 (fun (i : \u03b9) => Exists.{0} (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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} \u03b9 (fun (i : \u03b9) => Exists.{0} (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : LinearOrderedCancelCommMonoid.{u2} M] {s : Finset.{u1} \u03b9} (f : \u03b9 -> M), (Eq.{succ u2} M (Finset.prod.{u2, u1} M \u03b9 (OrderedCancelCommMonoid.toCommMonoid.{u2} M (LinearOrderedCancelCommMonoid.toOrderedCancelCommMonoid.{u2} M _inst_1)) s (fun (i : \u03b9) => 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} \u03b9 (fun (i : \u03b9) => And (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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} \u03b9 (fun (i : \u03b9) => And (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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'\u2093'. -/\n@[to_additive exists_pos_of_sum_zero_of_exists_nonzero]\ntheorem exists_one_lt_of_prod_one_of_exists_ne_one' (f : \u03b9 \u2192 M) (h\u2081 : (\u220f i in s, f i) = 1)\n    (h\u2082 : \u2203 i \u2208 s, f i \u2260 1) : \u2203 i \u2208 s, 1 < f i :=\n  by\n  contrapose! h\u2081\n  obtain \u27e8i, m, i_ne\u27e9 : \u2203 i \u2208 s, f i \u2260 1 := h\u2082\n  apply ne_of_lt\n  calc\n    (\u220f j in s, f j) < \u220f j in s, 1 := prod_lt_prod' h\u2081 \u27e8i, m, (h\u2081 i m).lt_of_ne i_ne\u27e9\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 : \u03b9 \u2192 R} {s t : Finset \u03b9}\n\nopen Classical\n\n/- warning: finset.prod_nonneg -> Finset.prod_nonneg is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : OrderedCommSemiring.{u2} R] {f : \u03b9 -> R} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {R : Type.{u1}} [_inst_1 : OrderedCommSemiring.{u1} R] {f : \u03b9 -> R} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_nonneg Finset.prod_nonneg\u2093'. -/\n-- this is also true for a ordered commutative multiplicative monoid with zero\ntheorem prod_nonneg (h0 : \u2200 i \u2208 s, 0 \u2264 f i) : 0 \u2264 \u220f i in s, f i :=\n  prod_induction f (fun i => 0 \u2264 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : OrderedCommSemiring.{u2} R] {f : \u03b9 -> R} {g : \u03b9 -> R} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : \u03b9) => f i)) (Finset.prod.{u2, u1} R \u03b9 (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : \u03b9) => g i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {R : Type.{u1}} [_inst_1 : OrderedCommSemiring.{u1} R] {f : \u03b9 -> R} {g : \u03b9 -> R} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : \u03b9) => f i)) (Finset.prod.{u1, u2} R \u03b9 (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : \u03b9) => g i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_le_prod Finset.prod_le_prod\u2093'. -/\n/-- If all `f i`, `i \u2208 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 : \u2200 i \u2208 s, 0 \u2264 f i) (h1 : \u2200 i \u2208 s, f i \u2264 g i) :\n    (\u220f i in s, f i) \u2264 \u220f i in s, g i :=\n  by\n  induction' s using Finset.induction with a s has ih h\n  \u00b7 simp\n  \u00b7 simp only [prod_insert has]\n    apply mul_le_mul\n    \u00b7 exact h1 a (mem_insert_self a s)\n    \u00b7 apply ih (fun x H => h0 _ _) fun x H => h1 _ _ <;> exact mem_insert_of_mem H\n    \u00b7 apply prod_nonneg fun x H => h0 x (mem_insert_of_mem H)\n    \u00b7 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : OrderedCommSemiring.{u2} R] {f : \u03b9 -> R} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : \u03b9) => 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 {\u03b9 : Type.{u2}} {R : Type.{u1}} [_inst_1 : OrderedCommSemiring.{u1} R] {f : \u03b9 -> R} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : \u03b9) => 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\u2093'. -/\n/-- If each `f i`, `i \u2208 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 : \u2200 i \u2208 s, 0 \u2264 f i) (h1 : \u2200 i \u2208 s, f i \u2264 1) : (\u220f i in s, f i) \u2264 1 :=\n  by\n  convert\u2190 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : OrderedCommSemiring.{u2} R] {s : Finset.{u1} \u03b9} {i : \u03b9} {f : \u03b9 -> R} {g : \u03b9 -> R} {h : \u03b9 -> R}, (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) j s) -> (Ne.{succ u1} \u03b9 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) j s) -> (Ne.{succ u1} \u03b9 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : \u03b9) => g i)) (Finset.prod.{u2, u1} R \u03b9 (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : \u03b9) => h i))) (Finset.prod.{u2, u1} R \u03b9 (CommSemiring.toCommMonoid.{u2} R (OrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {R : Type.{u1}} [_inst_1 : OrderedCommSemiring.{u1} R] {s : Finset.{u2} \u03b9} {i : \u03b9} {f : \u03b9 -> R} {g : \u03b9 -> R} {h : \u03b9 -> R}, (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) j s) -> (Ne.{succ u2} \u03b9 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) j s) -> (Ne.{succ u2} \u03b9 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : \u03b9) => g i)) (Finset.prod.{u1, u2} R \u03b9 (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : \u03b9) => h i))) (Finset.prod.{u1, u2} R \u03b9 (CommSemiring.toCommMonoid.{u1} R (OrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_add_prod_le Finset.prod_add_prod_le\u2093'. -/\n/-- If `g, h \u2264 f` and `g i + h i \u2264 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 : \u03b9} {f g h : \u03b9 \u2192 R} (hi : i \u2208 s) (h2i : g i + h i \u2264 f i)\n    (hgf : \u2200 j \u2208 s, j \u2260 i \u2192 g j \u2264 f j) (hhf : \u2200 j \u2208 s, j \u2260 i \u2192 h j \u2264 f j) (hg : \u2200 i \u2208 s, 0 \u2264 g i)\n    (hh : \u2200 i \u2208 s, 0 \u2264 h i) : ((\u220f i in s, g i) + \u220f i in s, h i) \u2264 \u220f 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  \u00b7 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  \u00b7 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 : \u03b9 \u2192 R} {s : Finset \u03b9}\n\n/- warning: finset.prod_pos -> Finset.prod_pos is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : StrictOrderedCommSemiring.{u2} R] [_inst_2 : Nontrivial.{u2} R] {f : \u03b9 -> R} {s : Finset.{u1} \u03b9}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u2} R (StrictOrderedCommSemiring.toCommSemiring.{u2} R _inst_1)) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {R : Type.{u1}} [_inst_1 : StrictOrderedCommSemiring.{u1} R] [_inst_2 : Nontrivial.{u1} R] {f : \u03b9 -> R} {s : Finset.{u2} \u03b9}, (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 \u03b9 (CommSemiring.toCommMonoid.{u1} R (StrictOrderedCommSemiring.toCommSemiring.{u1} R _inst_1)) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_pos Finset.prod_pos\u2093'. -/\n-- This is also true for a ordered commutative multiplicative monoid with zero\ntheorem prod_pos (h0 : \u2200 i \u2208 s, 0 < f i) : 0 < \u220f 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 : \u03b9 \u2192 R} {s : Finset \u03b9} {i : \u03b9}\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\u2093'. -/\n@[simp]\ntheorem CanonicallyOrderedCommSemiring.multiset_prod_pos [Nontrivial R] {m : Multiset R} :\n    0 < m.Prod \u2194 \u2200 x \u2208 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : CanonicallyOrderedCommSemiring.{u2} R] {f : \u03b9 -> R} {s : Finset.{u1} \u03b9} [_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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : \u03b9) => f i))) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : CanonicallyOrderedCommSemiring.{u2} R] {f : \u03b9 -> R} {s : Finset.{u1} \u03b9} [_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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : \u03b9) => f i))) (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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\u2093'. -/\n/-- Note that the name is to match `canonically_ordered_comm_semiring.mul_pos`. -/\n@[simp]\ntheorem CanonicallyOrderedCommSemiring.prod_pos [Nontrivial R] :\n    (0 < \u220f i in s, f i) \u2194 \u2200 i \u2208 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : CanonicallyOrderedCommSemiring.{u2} R] {f : \u03b9 -> R} {g : \u03b9 -> R} {h : \u03b9 -> R} {s : Finset.{u1} \u03b9} {i : \u03b9}, (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) j s) -> (Ne.{succ u1} \u03b9 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 : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) j s) -> (Ne.{succ u1} \u03b9 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : \u03b9) => g i)) (Finset.prod.{u2, u1} R \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : \u03b9) => h i))) (Finset.prod.{u2, u1} R \u03b9 (OrderedCommMonoid.toCommMonoid.{u2} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u2} R _inst_1)) s (fun (i : \u03b9) => f i)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {R : Type.{u1}} [_inst_1 : CanonicallyOrderedCommSemiring.{u1} R] {f : \u03b9 -> R} {g : \u03b9 -> R} {h : \u03b9 -> R} {s : Finset.{u2} \u03b9} {i : \u03b9}, (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) j s) -> (Ne.{succ u2} \u03b9 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) j s) -> (Ne.{succ u2} \u03b9 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 \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u1} R _inst_1)) s (fun (i : \u03b9) => g i)) (Finset.prod.{u1, u2} R \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u1} R _inst_1)) s (fun (i : \u03b9) => h i))) (Finset.prod.{u1, u2} R \u03b9 (OrderedCommMonoid.toCommMonoid.{u1} R (CanonicallyOrderedCommSemiring.toOrderedCommMonoid.{u1} R _inst_1)) s (fun (i : \u03b9) => f i)))\nCase conversion may be inaccurate. Consider using '#align finset.prod_add_prod_le' Finset.prod_add_prod_le'\u2093'. -/\n/-- If `g, h \u2264 f` and `g i + h i \u2264 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 \u2208 s) (h2i : g i + h i \u2264 f i) (hgf : \u2200 j \u2208 s, j \u2260 i \u2192 g j \u2264 f j)\n    (hhf : \u2200 j \u2208 s, j \u2260 i \u2192 h j \u2264 f j) : ((\u220f i in s, g i) + \u220f i in s, h i) \u2264 \u220f 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 \u03b9]\n\n#print Fintype.prod_mono' /-\n@[to_additive sum_mono, mono]\ntheorem prod_mono' [OrderedCommMonoid M] : Monotone fun f : \u03b9 \u2192 M => \u220f 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 : \u03b9 \u2192 M => \u220f x, f x :=\n  fun f g hfg =>\n  let \u27e8hle, i, hlt\u27e9 := Pi.lt_def.mp hfg\n  Finset.prod_lt_prod' (fun i _ => hle i) \u27e8i, Finset.mem_univ i, hlt\u27e9\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 {\u03b9 : 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} \u03b9} {f : \u03b9 -> (WithTop.{u2} R)}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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) \u03b9 (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 : \u03b9) => f i)) (Top.top.{u2} (WithTop.{u2} R) (WithTop.hasTop.{u2} R)))\nbut is expected to have type\n  forall {\u03b9 : 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} \u03b9} {f : \u03b9 -> (WithTop.{u2} R)}, (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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) \u03b9 (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 : \u03b9) => 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\u2093'. -/\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 \u03b9} {f : \u03b9 \u2192 WithTop R} (h : \u2200 i \u2208 s, f i \u2260 \u22a4) : (\u220f i in s, f i) < \u22a4 :=\n  prod_induction f (fun a => a < \u22a4) (fun a b h\u2081 h\u2082 => mul_lt_top' h\u2081 h\u2082) (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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (WithTop.{u2} M)}, Iff (Eq.{succ u2} (WithTop.{u2} M) (Finset.sum.{u2, u1} (WithTop.{u2} M) \u03b9 (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M))) (Exists.{succ u1} \u03b9 (fun (i : \u03b9) => Exists.{0} (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) i s) (fun (H : Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (WithTop.{u2} M)}, Iff (Eq.{succ u2} (WithTop.{u2} M) (Finset.sum.{u2, u1} (WithTop.{u2} M) \u03b9 (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.top.{u2} M))) (Exists.{succ u1} \u03b9 (fun (i : \u03b9) => And (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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\u2093'. -/\n/-- A sum of numbers is infinite iff one of them is infinite -/\ntheorem sum_eq_top_iff [AddCommMonoid M] {s : Finset \u03b9} {f : \u03b9 \u2192 WithTop M} :\n    (\u2211 i in s, f i) = \u22a4 \u2194 \u2203 i \u2208 s, f i = \u22a4 := 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] [_inst_2 : LT.{u2} M] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (WithTop.{u2} M)}, Iff (LT.lt.{u2} (WithTop.{u2} M) (WithTop.hasLt.{u2} M _inst_2) (Finset.sum.{u2, u1} (WithTop.{u2} M) \u03b9 (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M))) (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] [_inst_2 : LT.{u2} M] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (WithTop.{u2} M)}, Iff (LT.lt.{u2} (WithTop.{u2} M) (WithTop.lt.{u2} M _inst_2) (Finset.sum.{u2, u1} (WithTop.{u2} M) \u03b9 (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.top.{u2} M))) (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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\u2093'. -/\n/-- A sum of finite numbers is still finite -/\ntheorem sum_lt_top_iff [AddCommMonoid M] [LT M] {s : Finset \u03b9} {f : \u03b9 \u2192 WithTop M} :\n    (\u2211 i in s, f i) < \u22a4 \u2194 \u2200 i \u2208 s, f i < \u22a4 := 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 {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] [_inst_2 : LT.{u2} M] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (WithTop.{u2} M)}, (forall (i : \u03b9), (Membership.Mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.hasMem.{u1} \u03b9) 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) \u03b9 (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => f i)) (Top.top.{u2} (WithTop.{u2} M) (WithTop.hasTop.{u2} M)))\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {M : Type.{u2}} [_inst_1 : AddCommMonoid.{u2} M] [_inst_2 : LT.{u2} M] {s : Finset.{u1} \u03b9} {f : \u03b9 -> (WithTop.{u2} M)}, (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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) \u03b9 (WithTop.addCommMonoid.{u2} M _inst_1) s (fun (i : \u03b9) => 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\u2093'. -/\n/-- A sum of finite numbers is still finite -/\ntheorem sum_lt_top [AddCommMonoid M] [LT M] {s : Finset \u03b9} {f : \u03b9 \u2192 WithTop M}\n    (h : \u2200 i \u2208 s, f i \u2260 \u22a4) : (\u2211 i in s, f i) < \u22a4 :=\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 {\u03b9 : 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} \u03b9) (f : \u03b9 -> 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 \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u3, u1} S \u03b9 (OrderedAddCommMonoid.toAddCommMonoid.{u3} S (OrderedSemiring.toOrderedAddCommMonoid.{u3} S _inst_2)) s (fun (i : \u03b9) => 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 {\u03b9 : 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} \u03b9) (f : \u03b9 -> R), LE.le.{u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.sum.{u3, u1} R \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : \u03b9) => f i))) (Preorder.toLE.{u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.sum.{u3, u1} R \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : \u03b9) => f i))) (PartialOrder.toPreorder.{u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.sum.{u3, u1} R \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : \u03b9) => f i))) (OrderedSemiring.toPartialOrder.{u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.sum.{u3, u1} R \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : \u03b9) => 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 \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} S \u03b9 (OrderedAddCommMonoid.toAddCommMonoid.{u2} S (OrderedSemiring.toOrderedAddCommMonoid.{u2} S _inst_2)) s (fun (i : \u03b9) => 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\u2093'. -/\ntheorem AbsoluteValue.sum_le [Semiring R] [OrderedSemiring S] (abv : AbsoluteValue R S)\n    (s : Finset \u03b9) (f : \u03b9 \u2192 R) : abv (\u2211 i in s, f i) \u2264 \u2211 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 {\u03b9 : 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 : \u03b9 -> R) (s : Finset.{u1} \u03b9), 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 \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} R (Semiring.toNonAssocSemiring.{u2} R _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u3, u1} S \u03b9 (OrderedAddCommMonoid.toAddCommMonoid.{u3} S (OrderedSemiring.toOrderedAddCommMonoid.{u3} S _inst_2)) s (fun (i : \u03b9) => abv (f i)))\nbut is expected to have type\n  forall {\u03b9 : 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 : \u03b9 -> R) (s : Finset.{u1} \u03b9), LE.le.{u2} S (Preorder.toLE.{u2} S (PartialOrder.toPreorder.{u2} S (OrderedSemiring.toPartialOrder.{u2} S _inst_2))) (abv (Finset.sum.{u3, u1} R \u03b9 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u3} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R (Semiring.toNonAssocSemiring.{u3} R _inst_1))) s (fun (i : \u03b9) => f i))) (Finset.sum.{u2, u1} S \u03b9 (OrderedAddCommMonoid.toAddCommMonoid.{u2} S (OrderedSemiring.toOrderedAddCommMonoid.{u2} S _inst_2)) s (fun (i : \u03b9) => abv (f i)))\nCase conversion may be inaccurate. Consider using '#align is_absolute_value.abv_sum IsAbsoluteValue.abv_sum\u2093'. -/\ntheorem IsAbsoluteValue.abv_sum [Semiring R] [OrderedSemiring S] (abv : R \u2192 S) [IsAbsoluteValue abv]\n    (f : \u03b9 \u2192 R) (s : Finset \u03b9) : abv (\u2211 i in s, f i) \u2264 \u2211 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 {\u03b9 : 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 : \u03b9 -> R) (s : Finset.{u1} \u03b9), 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 \u03b9 (CommSemiring.toCommMonoid.{u2} R _inst_1) s (fun (i : \u03b9) => f i))) (Finset.prod.{u3, u1} S \u03b9 (LinearOrderedCommRing.toCommMonoid.{u3} S _inst_3) s (fun (i : \u03b9) => 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 {\u03b9 : 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 : \u03b9 -> R) (s : Finset.{u1} \u03b9), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Order.Hom.Basic._hyg.99 : R) => S) (Finset.prod.{u3, u1} R \u03b9 (CommSemiring.toCommMonoid.{u3} R _inst_1) s (fun (i : \u03b9) => 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 \u03b9 (CommSemiring.toCommMonoid.{u3} R _inst_1) s (fun (i : \u03b9) => f i))) (Finset.prod.{u2, u1} S \u03b9 (LinearOrderedCommRing.toCommMonoid.{u2} S _inst_3) s (fun (i : \u03b9) => 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\u2093'. -/\ntheorem AbsoluteValue.map_prod [CommSemiring R] [Nontrivial R] [LinearOrderedCommRing S]\n    (abv : AbsoluteValue R S) (f : \u03b9 \u2192 R) (s : Finset \u03b9) :\n    abv (\u220f i in s, f i) = \u220f 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 {\u03b9 : 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 : \u03b9 -> R) (s : Finset.{u1} \u03b9), Eq.{succ u3} S (abv (Finset.prod.{u2, u1} R \u03b9 (CommSemiring.toCommMonoid.{u2} R _inst_1) s (fun (i : \u03b9) => f i))) (Finset.prod.{u3, u1} S \u03b9 (LinearOrderedCommRing.toCommMonoid.{u3} S _inst_3) s (fun (i : \u03b9) => abv (f i)))\nbut is expected to have type\n  forall {\u03b9 : 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 : \u03b9 -> R) (s : Finset.{u1} \u03b9), Eq.{succ u2} S (abv (Finset.prod.{u3, u1} R \u03b9 (CommSemiring.toCommMonoid.{u3} R _inst_1) s (fun (i : \u03b9) => f i))) (Finset.prod.{u2, u1} S \u03b9 (LinearOrderedCommRing.toCommMonoid.{u2} S _inst_3) s (fun (i : \u03b9) => abv (f i)))\nCase conversion may be inaccurate. Consider using '#align is_absolute_value.map_prod IsAbsoluteValue.map_prod\u2093'. -/\ntheorem IsAbsoluteValue.map_prod [CommSemiring R] [Nontrivial R] [LinearOrderedCommRing S]\n    (abv : R \u2192 S) [IsAbsoluteValue abv] (f : \u03b9 \u2192 R) (s : Finset \u03b9) :\n    abv (\u220f i in s, f i) = \u220f 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 \u2192 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)\u207b\u00b9 \u2022 (f b -\u1d65 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 \u2192 PE) (a : k) (b : k) : E :=\n  b - a\u207b\u00b9 \u2022 (f b -\u1d65 f a)\n\ntheorem slope_def_field {k : Type u_1} [field k] (f : k \u2192 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 \u2192 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 \u2192 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 \u2192 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 \u2260 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 \u2192 PE) (a : k) (b : k) (c : k) : ((b - a) / (c - a)) \u2022 slope f a b + ((c - b) / (c - a)) \u2022 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 \u2192 PE) (a : k) (b : k) (c : k) (h : a \u2260 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 \u2192 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 \u2264 a') (hr : r \u2264 1) : coe_fn (affine_map.line_map a b) r \u2264 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 \u2264 b') (hr : 0 \u2264 r) : coe_fn (affine_map.line_map a b) r \u2264 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 \u2264 a') (hb : b \u2264 b') (h\u2080 : 0 \u2264 r) (h\u2081 : r \u2264 1) : coe_fn (affine_map.line_map a b) r \u2264 coe_fn (affine_map.line_map a' b') r :=\n  has_le.le.trans (line_map_mono_left ha h\u2081) (line_map_mono_right hb h\u2080)\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\u2080 : 0 \u2264 r) (h\u2081 : r \u2264 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' \u2194 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 \u2194 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 \u2194 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 \u2194 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 \u2194 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 \u2264 coe_fn (affine_map.line_map a b) r' \u2194 a \u2264 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 \u2264 coe_fn (affine_map.line_map a b) r \u2194 a \u2264 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 \u2264 midpoint k a b \u2194 a \u2264 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 \u2264 a \u2194 b \u2264 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 \u2264 a \u2194 b \u2264 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 \u2264 b \u2194 a \u2264 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 \u2264 b \u2194 a \u2264 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 \u2264 coe_fn (affine_map.line_map a b) r \u2194 b \u2264 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 \u2264 midpoint k a b \u2194 b \u2264 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 \u2208 (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 \u2264 line_map (f a) (f b) r \u2194 slope f a c \u2264 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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) : f (coe_fn (affine_map.line_map a b) r) \u2264 coe_fn (affine_map.line_map (f a) (f b)) r \u2194\n  slope f a (coe_fn (affine_map.line_map a b) r) \u2264 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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (h : 0 < r * (b - a)) : coe_fn (affine_map.line_map (f a) (f b)) r \u2264 f (coe_fn (affine_map.line_map a b) r) \u2194\n  slope f a b \u2264 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 \u2192 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 \u2194\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 \u2192 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) \u2194\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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) : f (coe_fn (affine_map.line_map a b) r) \u2264 coe_fn (affine_map.line_map (f a) (f b)) r \u2194\n  slope f a b \u2264 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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (h : 0 < (1 - r) * (b - a)) : coe_fn (affine_map.line_map (f a) (f b)) r \u2264 f (coe_fn (affine_map.line_map a b) r) \u2194\n  slope f (coe_fn (affine_map.line_map a b) r) b \u2264 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 \u2192 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 \u2194\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 \u2192 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) \u2194\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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (hab : a < b) (h\u2080 : 0 < r) (h\u2081 : r < 1) : f (coe_fn (affine_map.line_map a b) r) \u2264 coe_fn (affine_map.line_map (f a) (f b)) r \u2194\n  slope f a (coe_fn (affine_map.line_map a b) r) \u2264 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 \u2264 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 \u2192 E} {a : k} {b : k} {r : k} (hab : a < b) (h\u2080 : 0 < r) (h\u2081 : r < 1) : coe_fn (affine_map.line_map (f a) (f b)) r \u2264 f (coe_fn (affine_map.line_map a b) r) \u2194\n  slope f (coe_fn (affine_map.line_map a b) r) b \u2264 slope f a (coe_fn (affine_map.line_map a b) r) :=\n  map_le_line_map_iff_slope_le_slope hab h\u2080 h\u2081\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 \u2192 E} {a : k} {b : k} {r : k} (hab : a < b) (h\u2080 : 0 < r) (h\u2081 : r < 1) : f (coe_fn (affine_map.line_map a b) r) < coe_fn (affine_map.line_map (f a) (f b)) r \u2194\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\u2080 h\u2081) (map_le_line_map_iff_slope_le_slope hab h\u2080 h\u2081)\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 \u2192 E} {a : k} {b : k} {r : k} (hab : a < b) (h\u2080 : 0 < r) (h\u2081 : r < 1) : coe_fn (affine_map.line_map (f a) (f b)) r < f (coe_fn (affine_map.line_map a b) r) \u2194\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\u2080 h\u2081\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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\u2082 : Type w} {V\u2082 : Type w'}\nvariables {M\u2083 : Type y} {V\u2083 : Type y'} {M\u2084 : Type z} {\u03b9 : Type x}\nvariables {M\u2085 M\u2086 : 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\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\nvariables [add_comm_monoid M\u2085] [add_comm_monoid M\u2086]\nvariables [module R M] [module R M\u2082] [module R M\u2083] [module R M\u2084]\nvariables [module R M\u2085] [module R M\u2086]\nvariables (f : M \u2192\u2097[R] M\u2082)\n\nsection\nvariables (R M M\u2082)\n\n/-- The first projection of a product is a linear map. -/\ndef fst : M \u00d7 M\u2082 \u2192\u2097[R] M := { to_fun := prod.fst, map_add' := \u03bb x y, rfl, map_smul' := \u03bb x y, rfl }\n\n/-- The second projection of a product is a linear map. -/\ndef snd : M \u00d7 M\u2082 \u2192\u2097[R] M\u2082 := { to_fun := prod.snd, map_add' := \u03bb x y, rfl, map_smul' := \u03bb x y, rfl }\nend\n\n@[simp] theorem fst_apply (x : M \u00d7 M\u2082) : fst R M M\u2082 x = x.1 := rfl\n@[simp] theorem snd_apply (x : M \u00d7 M\u2082) : snd R M M\u2082 x = x.2 := rfl\n\ntheorem fst_surjective : function.surjective (fst R M M\u2082) := \u03bb x, \u27e8(x, 0), rfl\u27e9\ntheorem snd_surjective : function.surjective (snd R M M\u2082) := \u03bb x, \u27e8(0, x), rfl\u27e9\n\n/-- The prod of two linear maps is a linear map. -/\n@[simps] def prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) : (M \u2192\u2097[R] M\u2082 \u00d7 M\u2083) :=\n{ to_fun    := pi.prod f g,\n  map_add'  := \u03bb x y, by simp only [pi.prod, prod.mk_add_mk, map_add],\n  map_smul' := \u03bb c x, by simp only [pi.prod, prod.smul_mk, map_smul, ring_hom.id_apply] }\n\nlemma coe_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) : \u21d1(f.prod g) = pi.prod f g := rfl\n\n@[simp] theorem fst_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) :\n  (fst R M\u2082 M\u2083).comp (prod f g) = f := by ext; refl\n\n@[simp] theorem snd_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) :\n  (snd R M\u2082 M\u2083).comp (prod f g) = g := by ext; refl\n\n@[simp] theorem pair_fst_snd : prod (fst R M M\u2082) (snd R M M\u2082) = 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\u2082] [module S M\u2083] [smul_comm_class R S M\u2082] [smul_comm_class R S M\u2083] :\n  ((M \u2192\u2097[R] M\u2082) \u00d7 (M \u2192\u2097[R] M\u2083)) \u2243\u2097[S] (M \u2192\u2097[R] M\u2082 \u00d7 M\u2083) :=\n{ to_fun := \u03bb f, f.1.prod f.2,\n  inv_fun := \u03bb f, ((fst _ _ _).comp f, (snd _ _ _).comp f),\n  left_inv := \u03bb f, by ext; refl,\n  right_inv := \u03bb f, by ext; refl,\n  map_add' := \u03bb a b, rfl,\n  map_smul' := \u03bb r a, rfl }\n\nsection\nvariables (R M M\u2082)\n\n/-- The left injection into a product is a linear map. -/\ndef inl : M \u2192\u2097[R] M \u00d7 M\u2082 := prod linear_map.id 0\n\n/-- The right injection into a product is a linear map. -/\ndef inr : M\u2082 \u2192\u2097[R] M \u00d7 M\u2082 := prod 0 linear_map.id\n\ntheorem range_inl : range (inl R M M\u2082) = ker (snd R M M\u2082) :=\nbegin\n  ext x,\n  simp only [mem_ker, mem_range],\n  split,\n  { rintros \u27e8y, rfl\u27e9, refl },\n  { intro h, exact \u27e8x.fst, prod.ext rfl h.symm\u27e9 }\nend\n\ntheorem ker_snd : ker (snd R M M\u2082) = range (inl R M M\u2082) :=\neq.symm $ range_inl R M M\u2082\n\ntheorem range_inr : range (inr R M M\u2082) = ker (fst R M M\u2082) :=\nbegin\n  ext x,\n  simp only [mem_ker, mem_range],\n  split,\n  { rintros \u27e8y, rfl\u27e9, refl },\n  { intro h, exact \u27e8x.snd, prod.ext h.symm rfl\u27e9 }\nend\n\ntheorem ker_fst : ker (fst R M M\u2082) = range (inr R M M\u2082) :=\neq.symm $ range_inr R M M\u2082\n\nend\n\n@[simp] theorem coe_inl : (inl R M M\u2082 : M \u2192 M \u00d7 M\u2082) = \u03bb x, (x, 0) := rfl\ntheorem inl_apply (x : M) : inl R M M\u2082 x = (x, 0) := rfl\n\n@[simp] theorem coe_inr : (inr R M M\u2082 : M\u2082 \u2192 M \u00d7 M\u2082) = prod.mk 0 := rfl\ntheorem inr_apply (x : M\u2082) : inr R M M\u2082 x = (0, x) := rfl\n\ntheorem inl_eq_prod : inl R M M\u2082 = prod linear_map.id 0 := rfl\n\ntheorem inr_eq_prod : inr R M M\u2082 = prod 0 linear_map.id := rfl\n\ntheorem inl_injective : function.injective (inl R M M\u2082) :=\n\u03bb _, by simp\n\n\n\n/-- The coprod function `\u03bb x : M \u00d7 M\u2082, f x.1 + g x.2` is a linear map. -/\ndef coprod (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) : M \u00d7 M\u2082 \u2192\u2097[R] M\u2083 :=\nf.comp (fst _ _ _) + g.comp (snd _ _ _)\n\n@[simp] theorem coprod_apply (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) (x : M \u00d7 M\u2082) :\n  coprod f g x = f x.1 + g x.2 := rfl\n\n@[simp] theorem coprod_inl (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) :\n  (coprod f g).comp (inl R M M\u2082) = f :=\nby ext; simp only [map_zero, add_zero, coprod_apply, inl_apply, comp_apply]\n\n@[simp] theorem coprod_inr (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) :\n  (coprod f g).comp (inr R M M\u2082) = 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\u2082) (inr R M M\u2082) = 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\u2083 \u2192\u2097[R] M\u2084) (g\u2081 : M \u2192\u2097[R] M\u2083) (g\u2082 : M\u2082 \u2192\u2097[R] M\u2083) :\n  f.comp (g\u2081.coprod g\u2082) = (f.comp g\u2081).coprod (f.comp g\u2082) :=\next $ \u03bb x, f.map_add (g\u2081 x.1) (g\u2082 x.2)\n\ntheorem fst_eq_coprod : fst R M M\u2082 = coprod linear_map.id 0 := by ext; simp\n\ntheorem snd_eq_coprod : snd R M M\u2082 = coprod 0 linear_map.id := by ext; simp\n\n@[simp] theorem coprod_comp_prod (f : M\u2082 \u2192\u2097[R] M\u2084) (g : M\u2083 \u2192\u2097[R] M\u2084)\n  (f' : M \u2192\u2097[R] M\u2082) (g' : M \u2192\u2097[R] M\u2083) :\n  (f.coprod g).comp (f'.prod g') = f.comp f' + g.comp g' :=\nrfl\n\n@[simp]\nlemma coprod_map_prod (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) (S : submodule R M)\n  (S' : submodule R M\u2082) :\n  (submodule.prod S S').map (linear_map.coprod f g) = S.map f \u2294 S'.map g :=\nset_like.coe_injective $ begin\n  simp only [linear_map.coprod_apply, submodule.coe_sup, submodule.map_coe],\n  rw [\u2190set.image2_add, set.image2_image_left, set.image2_image_right],\n  exact set.image_prod (\u03bb m m\u2082, f m + g m\u2082),\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\u2083] [smul_comm_class R S M\u2083] :\n  ((M \u2192\u2097[R] M\u2083) \u00d7 (M\u2082 \u2192\u2097[R] M\u2083)) \u2243\u2097[S] (M \u00d7 M\u2082 \u2192\u2097[R] M\u2083) :=\n{ to_fun := \u03bb f, f.1.coprod f.2,\n  inv_fun := \u03bb f, (f.comp (inl _ _ _), f.comp (inr _ _ _)),\n  left_inv := \u03bb f, by simp only [prod.mk.eta, coprod_inl, coprod_inr],\n  right_inv := \u03bb f, by simp only [\u2190comp_coprod, comp_id, coprod_inl_inr],\n  map_add' := \u03bb a b,\n    by { ext, simp only [prod.snd_add, add_apply, coprod_apply, prod.fst_add, add_add_add_comm] },\n  map_smul' := \u03bb 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 \u00d7 M\u2082 \u2192\u2097[R] M\u2083} :\n  f = g \u2194 f.comp (inl _ _ _) = g.comp (inl _ _ _) \u2227 f.comp (inr _ _ _) = g.comp (inr _ _ _) :=\n(coprod_equiv \u2115).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 \u2192\u2097 M\u2083` and `M\u2082 \u2192\u2097 M\u2083`.\n\nSee note [partially-applied ext lemmas]. -/\n@[ext] theorem prod_ext {f g : M \u00d7 M\u2082 \u2192\u2097[R] M\u2083}\n  (hl : f.comp (inl _ _ _) = g.comp (inl _ _ _))\n  (hr : f.comp (inr _ _ _) = g.comp (inr _ _ _)) :\n  f = g :=\nprod_ext_iff.2 \u27e8hl, hr\u27e9\n\n/-- `prod.map` of two linear maps. -/\ndef prod_map (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2084) : (M \u00d7 M\u2082) \u2192\u2097[R] (M\u2083 \u00d7 M\u2084) :=\n(f.comp (fst R M M\u2082)).prod (g.comp (snd R M M\u2082))\n\nlemma coe_prod_map (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2084) :\n  \u21d1(f.prod_map g) = prod.map f g := rfl\n  \n@[simp] theorem prod_map_apply (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2084) (x) :\n  f.prod_map g x = (f x.1, g x.2) := rfl\n\nlemma prod_map_comap_prod (f : M \u2192\u2097[R] M\u2082) (g : M\u2083 \u2192\u2097[R] M\u2084) (S : submodule R M\u2082)\n  (S' : submodule R M\u2084) :\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 \u2192\u2097[R] M\u2082) (g : M\u2083 \u2192\u2097[R] M\u2084) :\n  (linear_map.prod_map f g).ker = submodule.prod f.ker g.ker :=\nbegin\n  dsimp only [ker],\n  rw [\u2190prod_map_comap_prod, submodule.prod_bot],\nend\n\n@[simp]\nlemma prod_map_id : (id : M \u2192\u2097[R] M).prod_map (id : M\u2082 \u2192\u2097[R] M\u2082) = id :=\nlinear_map.ext $ \u03bb _, prod.mk.eta\n\n@[simp]\nlemma prod_map_one : (1 : M \u2192\u2097[R] M).prod_map (1 : M\u2082 \u2192\u2097[R] M\u2082) = 1 :=\nlinear_map.ext $ \u03bb _, prod.mk.eta\n\nlemma prod_map_comp (f\u2081\u2082 : M \u2192\u2097[R] M\u2082) (f\u2082\u2083 : M\u2082 \u2192\u2097[R] M\u2083) (g\u2081\u2082 : M\u2084 \u2192\u2097[R] M\u2085) (g\u2082\u2083 : M\u2085 \u2192\u2097[R] M\u2086) :\n  f\u2082\u2083.prod_map g\u2082\u2083 \u2218\u2097 f\u2081\u2082.prod_map g\u2081\u2082 = (f\u2082\u2083 \u2218\u2097 f\u2081\u2082).prod_map (g\u2082\u2083 \u2218\u2097 g\u2081\u2082) := rfl\n\nlemma prod_map_mul (f\u2081\u2082 : M \u2192\u2097[R] M) (f\u2082\u2083 : M \u2192\u2097[R] M) (g\u2081\u2082 : M\u2082 \u2192\u2097[R] M\u2082) (g\u2082\u2083 : M\u2082 \u2192\u2097[R] M\u2082) :\n  f\u2082\u2083.prod_map g\u2082\u2083 * f\u2081\u2082.prod_map g\u2081\u2082 = (f\u2082\u2083 * f\u2081\u2082).prod_map (g\u2082\u2083 * g\u2081\u2082) := rfl\n\nlemma prod_map_add (f\u2081 : M \u2192\u2097[R] M\u2083) (f\u2082 : M \u2192\u2097[R] M\u2083) (g\u2081 : M\u2082 \u2192\u2097[R] M\u2084) (g\u2082 : M\u2082 \u2192\u2097[R] M\u2084) :\n  (f\u2081 + f\u2082).prod_map (g\u2081 + g\u2082) = f\u2081.prod_map g\u2081 + f\u2082.prod_map g\u2082 := rfl\n\n@[simp] lemma prod_map_zero :\n  (0 : M \u2192\u2097[R] M\u2082).prod_map (0 : M\u2083 \u2192\u2097[R] M\u2084) = 0 := rfl\n\n@[simp] lemma prod_map_smul\n [module S M\u2083] [module S M\u2084] [smul_comm_class R S M\u2083] [smul_comm_class R S M\u2084]\n (s : S) (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2084) : prod_map (s \u2022 f) (s \u2022 g) = s \u2022 prod_map f g := rfl\n\nvariables (R M M\u2082 M\u2083 M\u2084)\n\n/-- `linear_map.prod_map` as a `linear_map` -/\n@[simps]\ndef prod_map_linear\n [module S M\u2083] [module S M\u2084] [smul_comm_class R S M\u2083] [smul_comm_class R S M\u2084] :\n ((M \u2192\u2097[R] M\u2083) \u00d7 (M\u2082 \u2192\u2097[R] M\u2084)) \u2192\u2097[S] ((M \u00d7 M\u2082) \u2192\u2097[R] (M\u2083 \u00d7 M\u2084)) :=\n{ to_fun := \u03bb f, prod_map f.1 f.2,\n  map_add' := \u03bb _ _, rfl,\n  map_smul' := \u03bb _ _, rfl}\n\n/-- `linear_map.prod_map` as a `ring_hom` -/\n@[simps]\ndef prod_map_ring_hom : (M \u2192\u2097[R] M) \u00d7 (M\u2082 \u2192\u2097[R] M\u2082) \u2192+* ((M \u00d7 M\u2082) \u2192\u2097[R] (M \u00d7 M\u2082)) :=\n{ to_fun := \u03bb f, prod_map f.1 f.2,\n  map_one' := prod_map_one,\n  map_zero' := rfl,\n  map_add' := \u03bb _ _, rfl,\n  map_mul' := \u03bb _ _, rfl }\n\nvariables {R M M\u2082 M\u2083 M\u2084}\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\u2081 a\u2082 : A) : linear_map.inl R A B (a\u2081 * a\u2082) =\n  linear_map.inl R A B a\u2081 * linear_map.inl R A B a\u2082 :=\nprod.ext rfl (by simp)\n\nlemma inr_map_mul (b\u2081 b\u2082 : B) : linear_map.inr R A B (b\u2081 * b\u2082) =\n  linear_map.inr R A B b\u2081 * linear_map.inr R A B b\u2082 :=\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\u2082)\n\nvariables [comm_semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M\u2082]\nvariables [module R M] [module R M\u2082]\n\n/-- `linear_map.prod_map` as an `algebra_hom` -/\n@[simps]\ndef prod_map_alg_hom : (module.End R M) \u00d7 (module.End R M\u2082) \u2192\u2090[R] module.End R (M \u00d7 M\u2082) :=\n{ commutes' := \u03bb _, rfl, ..prod_map_ring_hom R M M\u2082 }\n\nend linear_map\n\nnamespace linear_map\nopen submodule\n\nvariables [semiring R]\n  [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\n  [module R M] [module R M\u2082] [module R M\u2083] [module R M\u2084]\n\nlemma range_coprod (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) :\n  (f.coprod g).range = f.range \u2294 g.range :=\nsubmodule.ext $ \u03bb x, by simp [mem_sup]\n\nlemma is_compl_range_inl_inr : is_compl (inl R M M\u2082).range (inr R M M\u2082).range :=\nbegin\n  split,\n  { rw disjoint_def,\n    rintros \u27e8_, _\u27e9 \u27e8x, hx\u27e9 \u27e8y, hy\u27e9,\n    simp only [prod.ext_iff, inl_apply, inr_apply, mem_bot] at hx hy \u22a2,\n    exact \u27e8hy.1.symm, hx.2.symm\u27e9 },\n  { rw codisjoint_iff_le_sup,\n    rintros \u27e8x, y\u27e9 -,\n    simp only [mem_sup, mem_range, exists_prop],\n    refine \u27e8(x, 0), \u27e8x, rfl\u27e9, (0, y), \u27e8y, rfl\u27e9, _\u27e9,\n    simp }\nend\n\nlemma sup_range_inl_inr : (inl R M M\u2082).range \u2294 (inr R M M\u2082).range = \u22a4 :=\nis_compl.sup_eq_top is_compl_range_inl_inr\n\nlemma disjoint_inl_inr : disjoint (inl R M M\u2082).range (inr R M M\u2082).range :=\nby simp [disjoint_def, @eq_comm M 0, @eq_comm M\u2082 0] {contextual := tt}; intros; refl\ntheorem map_coprod_prod (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083)\n  (p : submodule R M) (q : submodule R M\u2082) :\n  map (coprod f g) (p.prod q) = map f p \u2294 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 _ \u27e8x, \u27e8h\u2081, h\u2082\u27e9, rfl\u27e9,\n    exact mem_sup.2 \u27e8_, \u27e8_, h\u2081, rfl\u27e9, _, \u27e8_, h\u2082, rfl\u27e9, rfl\u27e9 },\n  { exact \u03bb x hx, \u27e8(x, 0), by simp [hx]\u27e9 },\n  { exact \u03bb x hx, \u27e8(0, x), by simp [hx]\u27e9 }\nend\n\ntheorem comap_prod_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083)\n  (p : submodule R M\u2082) (q : submodule R M\u2083) :\n  comap (prod f g) (p.prod q) = comap f p \u2293 comap g q :=\nsubmodule.ext $ \u03bb x, iff.rfl\n\ntheorem prod_eq_inf_comap (p : submodule R M) (q : submodule R M\u2082) :\n  p.prod q = p.comap (linear_map.fst R M M\u2082) \u2293 q.comap (linear_map.snd R M M\u2082) :=\nsubmodule.ext $ \u03bb x, iff.rfl\n\ntheorem prod_eq_sup_map (p : submodule R M) (q : submodule R M\u2082) :\n  p.prod q = p.map (linear_map.inl R M M\u2082) \u2294 q.map (linear_map.inr R M M\u2082) :=\nby rw [\u2190 map_coprod_prod, coprod_inl_inr, map_id]\n\nlemma span_inl_union_inr {s : set M} {t : set M\u2082} :\n  span R (inl R M  M\u2082 '' s \u222a inr R M M\u2082 '' t) = (span R s).prod (span R t) :=\nby rw [span_union, prod_eq_sup_map, \u2190 span_image, \u2190 span_image]\n\n@[simp] lemma ker_prod (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) :\n  ker (prod f g) = ker f \u2293 ker g :=\nby rw [ker, \u2190 prod_bot, comap_prod_prod]; refl\n\nlemma range_prod_le (f : M \u2192\u2097[R] M\u2082) (g : M \u2192\u2097[R] M\u2083) :\n  range (prod f g) \u2264 (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 \u27e8\u27e8x, rfl\u27e9, \u27e8x, rfl\u27e9\u27e9\nend\n\nlemma ker_prod_ker_le_ker_coprod {M\u2082 : Type*} [add_comm_group M\u2082] [module R M\u2082]\n  {M\u2083 : Type*} [add_comm_group M\u2083] [module R M\u2083]\n  (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) :\n  (ker f).prod (ker g) \u2264 ker (f.coprod g) :=\nby { rintros \u27e8y, z\u27e9, simp {contextual := tt} }\n\nlemma ker_coprod_of_disjoint_range {M\u2082 : Type*} [add_comm_group M\u2082] [module R M\u2082]\n  {M\u2083 : Type*} [add_comm_group M\u2083] [module R M\u2083]\n  (f : M \u2192\u2097[R] M\u2083) (g : M\u2082 \u2192\u2097[R] M\u2083) (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 \u27e8y, z\u27e9 h,\n  simp only [mem_ker, mem_prod, coprod_apply] at h \u22a2,\n  have : f y \u2208 f.range \u2293 g.range,\n  { simp only [true_and, mem_range, mem_inf, exists_apply_eq_apply],\n    use -z,\n    rwa [eq_comm, map_neg, \u2190 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\u2082]\nvariables [module R M] [module R M\u2082]\n\nlemma sup_eq_range (p q : submodule R M) : p \u2294 q = (p.subtype.coprod q.subtype).range :=\nsubmodule.ext $ \u03bb x, by simp [submodule.mem_sup, set_like.exists]\n\nvariables (p : submodule R M) (q : submodule R M\u2082)\n\n@[simp] theorem map_inl : p.map (inl R M M\u2082) = prod p \u22a5 :=\nby { ext \u27e8x, y\u27e9, 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\u2082) = prod \u22a5 q :=\nby ext \u27e8x, y\u27e9; simp [and.left_comm, eq_comm]\n\n@[simp] theorem comap_fst : p.comap (fst R M M\u2082) = prod p \u22a4 :=\nby ext \u27e8x, y\u27e9; simp\n\n@[simp] theorem comap_snd : q.comap (snd R M M\u2082) = prod \u22a4 q :=\nby ext \u27e8x, y\u27e9; simp\n\n@[simp] theorem prod_comap_inl : (prod p q).comap (inl R M M\u2082) = p := by ext; simp\n\n@[simp] theorem prod_comap_inr : (prod p q).comap (inr R M M\u2082) = q := by ext; simp\n\n@[simp] theorem prod_map_fst : (prod p q).map (fst R M M\u2082) = p :=\nby ext x; simp [(\u27e80, zero_mem _\u27e9 : \u2203 x, x \u2208 q)]\n\n@[simp] theorem prod_map_snd : (prod p q).map (snd R M M\u2082) = q :=\nby ext x; simp [(\u27e80, zero_mem _\u27e9 : \u2203 x, x \u2208 p)]\n\n@[simp] theorem ker_inl : (inl R M M\u2082).ker = \u22a5 :=\nby rw [ker, \u2190 prod_bot, prod_comap_inl]\n\n@[simp] theorem ker_inr : (inr R M M\u2082).ker = \u22a5 :=\nby rw [ker, \u2190 prod_bot, prod_comap_inr]\n\n@[simp] theorem range_fst : (fst R M M\u2082).range = \u22a4 :=\nby rw [range_eq_map, \u2190 prod_top, prod_map_fst]\n\n@[simp] theorem range_snd : (snd R M M\u2082).range = \u22a4 :=\nby rw [range_eq_map, \u2190 prod_top, prod_map_snd]\n\nvariables (R M M\u2082)\n\n/-- `M` as a submodule of `M \u00d7 N`. -/\ndef fst : submodule R (M \u00d7 M\u2082) := (\u22a5 : submodule R M\u2082).comap (linear_map.snd R M M\u2082)\n\n/-- `M` as a submodule of `M \u00d7 N` is isomorphic to `M`. -/\n@[simps] def fst_equiv : submodule.fst R M M\u2082 \u2243\u2097[R] M :=\n{ to_fun := \u03bb x, x.1.1,\n  inv_fun := \u03bb m, \u27e8\u27e8m, 0\u27e9, by tidy\u27e9,\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\u2082).map (linear_map.fst R M M\u2082) = \u22a4 :=\nby tidy\nlemma fst_map_snd : (submodule.fst R M M\u2082).map (linear_map.snd R M M\u2082) = \u22a5 :=\nby { tidy, exact 0, }\n\n/-- `N` as a submodule of `M \u00d7 N`. -/\ndef snd : submodule R (M \u00d7 M\u2082) := (\u22a5 : submodule R M).comap (linear_map.fst R M M\u2082)\n\n/-- `N` as a submodule of `M \u00d7 N` is isomorphic to `N`. -/\n@[simps] def snd_equiv : submodule.snd R M M\u2082 \u2243\u2097[R] M\u2082 :=\n{ to_fun := \u03bb x, x.1.2,\n  inv_fun := \u03bb n, \u27e8\u27e80, n\u27e9, by tidy\u27e9,\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\u2082).map (linear_map.fst R M M\u2082) = \u22a5 :=\nby { tidy, exact 0, }\nlemma snd_map_snd : (submodule.snd R M M\u2082).map (linear_map.snd R M M\u2082) = \u22a4 :=\nby tidy\n\nlemma fst_sup_snd : submodule.fst R M M\u2082 \u2294 submodule.snd R M M\u2082 = \u22a4 :=\nbegin\n  rw eq_top_iff,\n  rintro \u27e8m, n\u27e9 -,\n  rw [show (m, n) = (m, 0) + (0, n), by simp],\n  apply submodule.add_mem (submodule.fst R M M\u2082 \u2294 submodule.snd R M M\u2082),\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\u2082 \u2293 submodule.snd R M M\u2082 = \u22a5 := by tidy\n\nlemma le_prod_iff {p\u2081 : submodule R M} {p\u2082 : submodule R M\u2082} {q : submodule R (M \u00d7 M\u2082)} :\n  q \u2264 p\u2081.prod p\u2082 \u2194 map (linear_map.fst R M M\u2082) q \u2264 p\u2081 \u2227 map (linear_map.snd R M M\u2082) q \u2264 p\u2082 :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros x \u27e8\u27e8y1,y2\u27e9, \u27e8hy1,rfl\u27e9\u27e9, exact (h hy1).1 },\n    { rintros x \u27e8\u27e8y1,y2\u27e9, \u27e8hy1,rfl\u27e9\u27e9, exact (h hy1).2 }, },\n  { rintros \u27e8hH, hK\u27e9 \u27e8x1, x2\u27e9 h, exact \u27e8hH \u27e8_ , h, rfl\u27e9, hK \u27e8 _, h, rfl\u27e9\u27e9, }\nend\n\nlemma prod_le_iff {p\u2081 : submodule R M} {p\u2082 : submodule R M\u2082} {q : submodule R (M \u00d7 M\u2082)} :\n  p\u2081.prod p\u2082 \u2264 q \u2194 map (linear_map.inl R M M\u2082) p\u2081 \u2264 q \u2227 map (linear_map.inr R M M\u2082) p\u2082 \u2264 q :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros _ \u27e8x, hx, rfl\u27e9, apply h, exact \u27e8hx, zero_mem p\u2082\u27e9, },\n    { rintros _ \u27e8x, hx, rfl\u27e9, apply h, exact \u27e8zero_mem p\u2081, hx\u27e9, }, },\n  { rintros \u27e8hH, hK\u27e9 \u27e8x1, x2\u27e9 \u27e8h1, h2\u27e9,\n    have h1' : (linear_map.inl R _ _) x1 \u2208 q, { apply hH, simpa using h1, },\n    have h2' : (linear_map.inr R _ _) x2 \u2208 q, { apply hK, simpa using h2, },\n    simpa using add_mem h1' h2', }\nend\n\nlemma prod_eq_bot_iff {p\u2081 : submodule R M} {p\u2082 : submodule R M\u2082} :\n  p\u2081.prod p\u2082 = \u22a5 \u2194 p\u2081 = \u22a5 \u2227 p\u2082 = \u22a5 :=\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\u2081 : submodule R M} {p\u2082 : submodule R M\u2082} :\n  p\u2081.prod p\u2082 = \u22a4 \u2194 p\u2081 = \u22a4 \u2227 p\u2082 = \u22a4 :=\nby simp only [eq_top_iff, le_prod_iff, \u2190 (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 \u00d7 N) \u2243\u2097[R] (N \u00d7 M) :=\n{ to_fun := prod.swap,\n  map_smul' := \u03bb r \u27e8m, n\u27e9, rfl,\n  ..add_equiv.prod_comm }\n\nsection\n\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\nvariables {module_M : module R M} {module_M\u2082 : module R M\u2082}\nvariables {module_M\u2083 : module R M\u2083} {module_M\u2084 : module R M\u2084}\nvariables (e\u2081 : M \u2243\u2097[R] M\u2082) (e\u2082 : M\u2083 \u2243\u2097[R] M\u2084)\n\n/-- Product of linear equivalences; the maps come from `equiv.prod_congr`. -/\nprotected def prod :\n  (M \u00d7 M\u2083) \u2243\u2097[R] (M\u2082 \u00d7 M\u2084) :=\n{ map_smul' := \u03bb c x, prod.ext (e\u2081.map_smul\u209b\u2097 c _) (e\u2082.map_smul\u209b\u2097 c _),\n  .. e\u2081.to_add_equiv.prod_congr e\u2082.to_add_equiv }\n\nlemma prod_symm : (e\u2081.prod e\u2082).symm = e\u2081.symm.prod e\u2082.symm := rfl\n\n@[simp] lemma prod_apply (p) :\n  e\u2081.prod e\u2082 p = (e\u2081 p.1, e\u2082 p.2) := rfl\n\n@[simp, norm_cast] lemma coe_prod :\n  (e\u2081.prod e\u2082 : (M \u00d7 M\u2083) \u2192\u2097[R] (M\u2082 \u00d7 M\u2084)) = (e\u2081 : M \u2192\u2097[R] M\u2082).prod_map (e\u2082 : M\u2083 \u2192\u2097[R] M\u2084) := rfl\n\nend\n\nsection\nvariables [semiring R]\nvariables [add_comm_monoid M] [add_comm_monoid M\u2082] [add_comm_monoid M\u2083] [add_comm_group M\u2084]\nvariables {module_M : module R M} {module_M\u2082 : module R M\u2082}\nvariables {module_M\u2083 : module R M\u2083} {module_M\u2084 : module R M\u2084}\nvariables (e\u2081 : M \u2243\u2097[R] M\u2082) (e\u2082 : M\u2083 \u2243\u2097[R] M\u2084)\n\n/-- Equivalence given by a block lower diagonal matrix. `e\u2081` and `e\u2082` are diagonal square blocks,\n  and `f` is a rectangular block below the diagonal. -/\nprotected def skew_prod (f : M \u2192\u2097[R] M\u2084) :\n  (M \u00d7 M\u2083) \u2243\u2097[R] M\u2082 \u00d7 M\u2084 :=\n{ inv_fun := \u03bb p : M\u2082 \u00d7 M\u2084, (e\u2081.symm p.1, e\u2082.symm (p.2 - f (e\u2081.symm p.1))),\n  left_inv := \u03bb p, by simp,\n  right_inv := \u03bb p, by simp,\n  .. ((e\u2081 : M \u2192\u2097[R] M\u2082).comp (linear_map.fst R M M\u2083)).prod\n    ((e\u2082 : M\u2083 \u2192\u2097[R] M\u2084).comp (linear_map.snd R M M\u2083) +\n      f.comp (linear_map.fst R M M\u2083)) }\n\n@[simp] lemma skew_prod_apply (f : M \u2192\u2097[R] M\u2084) (x) :\n  e\u2081.skew_prod e\u2082 f x = (e\u2081 x.1, e\u2082 x.2 + f x.1) := rfl\n\n@[simp] lemma skew_prod_symm_apply (f : M \u2192\u2097[R] M\u2084) (x) :\n  (e\u2081.skew_prod e\u2082 f).symm x = (e\u2081.symm x.1, e\u2082.symm (x.2 - f (e\u2081.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\u2082] [add_comm_group M\u2083]\nvariables [module R M] [module R M\u2082] [module R M\u2083]\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 \u2192\u2097[R] M\u2082} {g : M \u2192\u2097[R] M\u2083} (h : ker f \u2294 ker g = \u22a4) :\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, \u2190 sub_mem_ker_iff],\n  have : y - x \u2208 ker f \u2294 ker g, { simp only [h, mem_top] },\n  rcases mem_sup.1 this with \u27e8x', hx', y', hy', H\u27e9,\n  refine \u27e8x' + x, _, _\u27e9,\n  { simp only [mem_ker.mp hx', map_add, zero_add]},\n  { simp [\u2190eq_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 \u00d7 N \u2192\u2097[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 \u00d7 N \u2192\u2097[R] M) (K\u03c6 : \u03a3 K : submodule R M, K \u2243\u2097[R] M) :\n  M \u00d7 N \u2192\u2097[R] M :=\n(K\u03c6.1.subtype.comp K\u03c6.2.symm.to_linear_map).comp f\n\nlemma tunnel_aux_injective\n  (f : M \u00d7 N \u2192\u2097[R] M) (i : injective f) (K\u03c6 : \u03a3 K : submodule R M, K \u2243\u2097[R] M) :\n  injective (tunnel_aux f K\u03c6) :=\n(subtype.val_injective.comp K\u03c6.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 \u00d7 N \u2192\u2097[R] M) (i : injective f) :\n  \u2115 \u2192 \u03a3 (K : submodule R M), K \u2243\u2097[R] M\n| 0 := \u27e8\u22a4, linear_equiv.of_top \u22a4 rfl\u27e9\n| (n+1) :=\n\u27e8(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)\u27e9\n\n/--\nGive an injective map `f : M \u00d7 N \u2192\u2097[R] M` we can find a nested sequence of submodules\nall isomorphic to `M`.\n-/\ndef tunnel (f : M \u00d7 N \u2192\u2097[R] M) (i : injective f) : \u2115 \u2192o (submodule R M)\u1d52\u1d48 :=\n\u27e8\u03bb n, order_dual.to_dual (tunnel' f i n).1, monotone_nat_of_le_succ (\u03bb n, begin\n    dsimp [tunnel', tunnel_aux],\n    rw [submodule.map_comp, submodule.map_comp],\n    apply submodule.map_subtype_le,\n  end)\u27e9\n\n/--\nGive an injective map `f : M \u00d7 N \u2192\u2097[R] M` we can find a sequence of submodules\nall isomorphic to `N`.\n-/\ndef tailing (f : M \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) : 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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) : tailing f i n \u2243\u2097[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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\n  tailing f i n \u2264 (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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\n  tailing f i n \u2294 (tunnel f i (n+1)).of_dual \u2264 (tunnel f i n).of_dual :=\nbegin\n  dsimp [tailing, tunnel, tunnel', tunnel_aux],\n  rw [\u2190submodule.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 \u00d7 N \u2192\u2097[R] M) (i : injective f) : \u2115 \u2192 submodule R M :=\npartial_sups (tailing f i)\n\n@[simp] lemma tailings_zero (f : M \u00d7 N \u2192\u2097[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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\n  tailings f i (n+1) = tailings f i n \u2294 tailing f i (n+1) :=\nby simp [tailings]\n\nlemma tailings_disjoint_tunnel (f : M \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\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 \u00d7 N \u2192\u2097[R] M) (i : injective f) (n : \u2115) :\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\u2082]\n  [add_comm_group M\u2083] [add_comm_group M\u2084] [module R M] [module R M\u2082]\n  [module R M\u2083] [module R M\u2084] (f : M \u2192\u2097[R] M\u2082) (g : M\u2083 \u2192\u2097[R] M\u2084)\n\n/-- Graph of a linear map. -/\ndef graph : submodule R (M \u00d7 M\u2082) :=\n{ carrier := {p | p.2 = f p.1},\n  add_mem' := \u03bb 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' := \u03bb c x (hx : _ = _),\n  begin\n    change _ \u2022 _ = f (_ \u2022 _),\n    rw [map_smul, hx]\n  end }\n\n@[simp] lemma mem_graph_iff (x : M \u00d7 M\u2082) : x \u2208 f.graph \u2194 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 _ = _ \u2194 -(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 \u27e8\u03bb hx, \u27e8x.1, prod.ext rfl hx.symm\u27e9, \u03bb \u27e8u, hu\u27e9, hu \u25b8 rfl\u27e9\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 (\u03b1 : Type) where\n  size : Nat\n  val :  Nat \u2192 \u03b1\n\ndef Tensor1d.empty [Inhabited \u03b1] : Tensor1d \u03b1 where\n  size := 0\n  val := fun _ => default\n\ndef Tensor1d.extract (t: Tensor1d \u03b1) (l: Nat) (len: Nat) : Tensor1d \u03b1 where\n  size := len\n  val := fun ix => t.val (l + ix)\n\ndef Tensor1d.map (f : \u03b1 \u2192 \u03b1) (t : Tensor1d \u03b1) : Tensor1d \u03b1 where\n  size := t.size\n  val := fun ix => f (t.val ix)\n\ndef Tensor1d.fill (t: Tensor1d \u03b1) (v: \u03b1) : Tensor1d \u03b1 where\n  size := t.size\n  val := fun _ix => v\n\n-- insert a slice into a tensor.\ndef Tensor1d.insertslice (t: Tensor1d \u03b1) (ix: Nat) (slice : Tensor1d \u03b1) : Tensor1d \u03b1 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 \u2192 \u03b1) (f: \u03b2 \u2192 \u03b1 \u2192 \u03b2) (seed: \u03b2): \u03b2 :=\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 : \u03b2 \u2192 \u03b1 \u2192 \u03b2)  (seed : \u03b2) (t : Tensor1d \u03b1) : \u03b2 :=\n  Tensor1d.fold_rec t.size t.val f seed\n\nstructure Tensor2d (\u03b1 : Type) where\n  size : Nat \u00d7 Nat\n  val :  Nat \u00d7 Nat \u2192 \u03b1\n\ndef Tensor2d.transpose (t: Tensor2d \u03b1) : Tensor2d \u03b1 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 \u03b1):\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 \u03b1):\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 \u2218 g) = map f \u2218 map g\ntheorem Tensor1d.map_fusion (t: Tensor1d \u03b1):\n  (t.map (g \u2218 f)) = (t.map f).map g := by {\n    simp[Tensor1d.map]\n}\n\n-- for loop\ndef scf.for.loop (f : Nat \u2192 \u03b2 \u2192 \u03b2) (n n_minus_i: Nat) (acc: \u03b2) : \u03b2 :=\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 \u2192 \u03b2 \u2192 \u03b2) (seed: \u03b2) : \u03b2 :=\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 \u2192 \u03b2 \u2192 \u03b2) (seed : \u03b2) :\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 \u2192 \u03b2 \u2192 \u03b2) (seed : \u03b2) :\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 \u2192 \u03b2 \u2192 \u03b2)  (seed : \u03b2)\n  (COMMUTE : \u2200 (ix : \u2115)  (v : \u03b2),  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 \u2192 \u03b2 \u2192 \u03b2) (seed : \u03b2) :\n  scf.for 0 f seed = seed := by {\n    simp[scf.for, loop]\n  }\n\n  def scf.for.one_n (f: Nat \u2192 \u03b2 \u2192 \u03b2) (seed : \u03b2) :\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 \u2192 \u03b2 \u2192 \u03b2) (seed : \u03b2)  :\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 \u03b1] (t : Tensor1d \u03b1) (SIZE :4 \u2223 t.size) (f : \u03b1 \u2192 \u03b1):\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 \u22a2;\n    have : { n : Nat //  size = n * 4 } := by {\n      norm_num at SIZE\n      -- have \u27e8x, y\u27e9 := SIZE\n      sorry\n    }\n    have \u27e8n, N\u27e9 := 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 \u03b1):\n  (t.transpose).transpose = t := by {\n    simp[Tensor2d.transpose]\n}\n\n\n\ninductive Val where\n| int : Int \u2192 Val\n| unit : Val\n| nat : Nat \u2192 Val\n| bool : Bool \u2192 Val\n| tensor1d : Tensor1d Int \u2192 Val\n| tensor2d : Tensor2d Int \u2192 Val\n| pair : Val \u2192 Val \u2192 Val\n| triple : Val \u2192 Val \u2192 Val \u2192 Val\n| inl : Val \u2192 Val\n| inr : Val \u2192 Val\nderiving Inhabited\n\n\ndef Val.int! : Val \u2192 Int\n| .int i => i\n| _ => default\n\ndef Val.nat! : Val \u2192 Nat\n| .nat i => i\n| _ => default\n\ndef Val.bool! : Val \u2192 Bool\n| .bool i => i\n| _ => default\n\n\nabbrev Var := Int\n\nabbrev Env (\u03b1: Type) := Var \u2192 \u03b1\n\ndef Env.empty {\u03b1 : Type} [Inhabited \u03b1]: Env \u03b1 := fun _ => default\nnotation \"\u2205\" =>  Env.empty\n\ndef Env.set (e: Env \u03b1) (var: Var) (val: \u03b1) :=\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 \u2192 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) \u2192 (arg: Val) \u2192 (rgn: Val \u2192 Val) \u2192 Val\n\ndef SSAIndex.eval : SSAIndex \u2192 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 \u2192 Val)) : SSA Op k \u2192 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 {\u03b1 \u03b2 \u03b3 : Type}\nvariable {X Y Z : Type} [SemiHilbert X] [SemiHilbert Y] [SemiHilbert Z] \nvariable {Y\u2081 Y\u2082 : Type} [SemiHilbert Y\u2081] [SemiHilbert Y\u2082]\nvariable {\u03b9 : Type} [Enumtype \u03b9]\n\n\n-- noncomputable \n-- def adjointDifferential (f : X \u2192 Y) (x : X) (dy' : Y) : X := (\u2202 f x)\u2020 dy'\n\n-- @[default_instance]\n-- instance (f : X \u2192 Y) : PartialDagger f (adjointDifferential f) := \u27e8\u27e9\n\n-- Someting wrong here :(\n-- noncomputable \n-- def Smooth.adjointDifferential {X Y} [Hilbert X] [Hilbert Y] (f : X \u27ff Y) : X\u27ffY\u22b8X := \u03bb x \u27ff \u03bb dy \u22b8 adjoint (\u2202 f x) dy\n\n-- @[default_instance]\n-- instance (f : X \u2192 Y) : PartialDagger f (adjointDifferential f) := \u27e8\u27e9\n\n\n-- Question: Should there be `\ud835\udcaf[y] Y` or `\ud835\udcaf[f x] Y`?\n-- Maybe return `(y:Y)\u00d7(\ud835\udcaf[y] Y \u2192 \ud835\udcaf[x] X)\u00d7(f x = y)` but there is a problem with `Sigma` vs `PSigma`\n-- noncomputable\n-- def reverseDifferential (f : X \u2192 Y) (x : X) : Y\u00d7(Y\u2192X) := (f x, \u03bb dy => \u2202\u2020 f x dy)\n\n-- instance (priority:=low) (f : X \u2192 Y) : ReverseDifferential f (reverseDifferential f) := \u27e8\u27e9\n\n\n-- noncomputable\n-- abbrev gradient (f : X \u2192 \u211d) (x : X) : X := \u2202\u2020 f x 1\n\n-- @[default_instance]\n-- instance (f : X \u2192 \u211d) : Nabla f (gradient f) := \u27e8\u27e9\n\n-- noncomputable\n-- abbrev Smooth.gradient (f : X \u27ff \u211d) : X\u27ffX := SmoothMap.mk (\u03bb x => adjoint (\u03bb dx => \u2202 f x dx) 1) sorry_proof\n\n-- instance (f : X \u27ff \u211d) : Nabla f (Smooth.gradient f) := \u27e8\u27e9\n\n\n-- Notation \n-- \u2207 s, f s         --> \u2207 \u03bb s => f s\n-- \u2207 s : \u211d, f s     --> \u2207 \u03bb s : \u211d => f s\n-- \u2207 s := t, f s    --> (\u2207 \u03bb s => f s) t\nsyntax \"\u2207\" diffBinder \",\" term:66 : term\nsyntax \"\u2207\" \"(\" diffBinder \")\" \",\" term:66 : term\nmacro_rules \n| `(\u2207 $x:ident, $f) =>\n  `(\u2207 \u03bb $x => $f)\n| `(\u2207 $x:ident : $type:term, $f) =>\n  `(\u2207 \u03bb $x : $type => $f)\n| `(\u2207 $x:ident := $val:term, $f) =>\n  `((\u2207 \u03bb $x => $f) $val)\n| `(\u2207 ($b:diffBinder), $f) =>\n  `(\u2207 $b, $f)\n\n\ninstance (f : X \u2192 Y) [HasAdjDiff f] (x : X) : IsLin (\u2202\u2020 f x) := sorry\n\n----------------------------------------------------------------------\n\n\n@[simp \u2193, diff]\ntheorem id.arg_x.adjDiff_simp\n  : \u2202\u2020 (\u03bb x : X => x) = \u03bb x dx => dx := by symdiff; simp[adjointDifferential]; done\n\n@[simp \u2193, diff]\ntheorem const.arg_x.adjDiff_simp \n  : \u2202\u2020 (\u03bb (x : X) (i : \u03b9) => x) = \u03bb x f => \u2211 i, f i := by simp[adjointDifferential]; done\n\n@[simp \u2193, diff]\ntheorem const.arg_y.adjDiff_simp (x : X)\n  : \u2202\u2020 (\u03bb (y : Y) => x) = (\u03bb y dy' => (0 : Y)) := by simp[adjointDifferential]; done\n\n@[simp \u2193 low-4, diff low-4]\ntheorem swap.arg_y.adjDiff_simp\n  (f : \u03b9 \u2192 X \u2192 Z) [inst : \u2200 i, HasAdjDiffT (f i)]\n  : \u2202\u2020 (\u03bb x y => f y x) = (\u03bb x dx' => \u2211 i, (\u2202\u2020 (f i) x) (dx' i)) := \nby \n  have := \u03bb i => (inst i).1\n  have := \u03bb i => (inst i).2\n\n  simp[adjointDifferential]; done\n\n@[simp \u2193 low-3, diff low-3]\ntheorem subst.arg_x.adjDiff_simp\n  (f : X \u2192 Y \u2192 Z) [instf : HasAdjDiffNT 2 f]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u2202\u2020 (\u03bb x => f x (g x)) \n    = \n    \u03bb x dz =>\n      let (y,dg') := \u211b g x\n      -- let (dx,dy) := \u2202\u2020 (uncurryN 2 f) (x,y) dz\n      -- dx + dg' dy\n      (\u2202\u2020 (\u03bb x' => f x' y)) x dz\n      +\n      dg' (\u2202\u2020 (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 : \u2200 x y, HasAdjointT (\u03bb dx => \u2202 f x dx y) := sorry_proof\n  have : \u2200 x y, HasAdjointT (\u03bb dy => \u2202 (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 \u2193 low-2, diff low-2, simp_guard g (\u03bb x => x)]\ntheorem subst.arg_x.parm1.adjDiff_simp\n  (a : \u03b1)\n  (f : X \u2192 Y \u2192 \u03b1 \u2192 Z) [HasAdjDiffNT 2 \u03bb x y => f x y a]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u2202\u2020 (\u03bb x => f x (g x) a) \n    = \n    \u03bb x dz => \n      let (y,dg') := \u211b g x\n      -- let (dx,dy) := \u2202\u2020 (uncurryN 2 (\u03bb x y => f x y a)) (x,y) dz\n      -- dx + dg' dy\n      (\u2202\u2020 (\u03bb x' => f x' y a)) x dz\n      +\n      dg' (\u2202\u2020 (\u03bb y' => f x y' a) y dz)\n    := \nby \n  rw[subst.arg_x.adjDiff_simp (\u03bb x y => f x y a) g]\n  done\n\n@[simp \u2193 low-2, diff low-2, simp_guard g (\u03bb x => x)]\ntheorem subst.arg_x.parm2.adjDiff_simp\n  (a : \u03b1) (b : \u03b2)\n  (f : X \u2192 Y \u2192 \u03b1 \u2192 \u03b2 \u2192 Z) [HasAdjDiffNT 2 \u03bb x y => f x y a b]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u2202\u2020 (\u03bb x => f x (g x) a b) \n    = \n    \u03bb x dz => \n      let (y,dg') := \u211b g x\n      (\u2202\u2020 (\u03bb x' => f x' y a b)) x dz\n      +\n      dg' (\u2202\u2020 (\u03bb y' => f x y' a b) y dz)\n    := \nby \n  apply subst.arg_x.adjDiff_simp (\u03bb x y => f x y a b) g\n  done\n\n@[simp \u2193 low-2, diff low-2, simp_guard g (\u03bb x => x)]\ntheorem subst.arg_x.parm3.adjDiff_simp\n  (a : \u03b1) (b : \u03b2) (c : \u03b3)\n  (f : X \u2192 Y \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 Z) [HasAdjDiffNT 2 \u03bb x y => f x y a b c]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u2202\u2020 (\u03bb x => f x (g x) a b c) \n    = \n    \u03bb x dz => \n      let (y,dg') := \u211b g x\n      (\u2202\u2020 (\u03bb x' => f x' y a b c)) x dz\n      +\n      dg' (\u2202\u2020 (\u03bb y' => f x y' a b c) y dz)\n    := \nby \n  apply subst.arg_x.adjDiff_simp (\u03bb x y => f x y a b c) g\n  done\n\n@[simp \u2193 low-1, diff low-1, simp_guard g (\u03bb x => x)]\ntheorem comp.arg_x.adjDiff_simp\n  (f : Y \u2192 Z) [instf : HasAdjDiffT f]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u2202\u2020 (\u03bb x => f (g x)) \n    = \n    \u03bb x dz => \n      let (y,dg') := \u211b g x\n      dg' ((\u2202\u2020 f y) dz) \n  := by simp; done\n\n@[simp \u2193 low-2, diff low-2, simp_guard g\u2081 Prod.fst, g\u2082 Prod.snd]\ntheorem diag.arg_x.adjDiff_simp\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 Z) [HasAdjDiffNT 2 f]\n  (g\u2081 : X \u2192 Y\u2081) [hg : HasAdjDiffT g\u2081]\n  (g\u2082 : X \u2192 Y\u2082) [HasAdjDiffT g\u2082]\n  : \u2202\u2020 (\u03bb x => f (g\u2081 x) (g\u2082 x)) \n    = \n    \u03bb x dz => \n      let (y\u2081,dg\u2081') := \u211b g\u2081 x\n      let (y\u2082,dg\u2082') := \u211b g\u2082 x\n      dg\u2081' ((\u2202\u2020 \u03bb y\u2081' => f y\u2081' y\u2082) y\u2081 dz)\n      +\n      dg\u2082' ((\u2202\u2020 \u03bb y\u2082' => f y\u2081 y\u2082') y\u2082 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 (\u03bb y\u2081 => f y\u2081 (g\u2082 x))]\n  simp only [reverseDifferential]\n  done\n\n@[simp \u2193 low, diff low]\ntheorem eval.arg_f.adjDiff_simp\n  (i : \u03b9)\n  : \u2202\u2020 (\u03bb (f : \u03b9 \u2192 X) => f i) \n    = \n    (\u03bb f df' j => ([[i = j]] \u2022 df' : X))\n:= sorry\n\n@[simp \u2193 low-1, diff low-1]\ntheorem eval.arg_x.parm1.adjDiff_simp\n  (f : X \u2192 \u03b9 \u2192 Z) [HasAdjDiff f]\n  : \u2202\u2020 (\u03bb x => f x i) \n    = \n    (\u03bb x dx' => (\u2202\u2020 f x) (\u03bb j => ([[i = j]] \u2022 dx' : Z)))\n:= \nby \n  rw [comp.arg_x.adjDiff_simp (\u03bb (x : \u03b9 \u2192 Z) => x i) f]\n  simp[reverseDifferential]\n\n\n--------------------------------------------------------\n-- These theorems are problematic when used with simp --\n\n\n@[simp \u2193 low-1, diff low-1]\ntheorem comp.arg_x.parm1.adjDiff_simp\n  (a : \u03b1) \n  (f : Y \u2192 \u03b1 \u2192 Z) [HasAdjDiff \u03bb y => f y a]\n  (g : X \u2192 Y) [HasAdjDiff g]\n  : \n    \u2202\u2020 (\u03bb x => f (g x) a) \n    = \n    \u03bb x dz => \n      let (y,dg') := \u211b g x\n      dg' ((\u2202\u2020 (hold \u03bb 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 \u2193 low-1, diff low-1]\ntheorem comp.arg_x.parm2.adjDiff_simp\n  (a : \u03b1) (b : \u03b2)\n  (f : Y \u2192 \u03b1 \u2192 \u03b2 \u2192 Z) [HasAdjDiff \u03bb y => f y a b]\n  (g : X \u2192 Y) [HasAdjDiff g]\n  : \n    \u2202\u2020 (\u03bb x => f (g x) a b) \n    = \n    \u03bb x dz => \n      let (y,dg') := \u211b g x\n      dg' ((\u2202\u2020 (hold \u03bb 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 \u2193 low-1, diff low-1]\ntheorem comp.arg_x.parm3.adjDiff_simp\n  (a : \u03b1) (b : \u03b2) (c : \u03b3)\n  (f : Y \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 Z) [HasAdjDiff \u03bb y => f y a b c]\n  (g : X \u2192 Y) [HasAdjDiff g]\n  : \n    \u2202\u2020 (\u03bb x => f (g x) a b c) \n    = \n    \u03bb x dx' => \n      let (y,dg') := \u211b g x\n      dg' ((\u2202\u2020 (hold \u03bb 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 : \u03b1) (f : Y\u2081 \u2192 Y\u2082 \u2192 \u03b1 \u2192 Z) [IsSmoothT \u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a]\n  (g\u2081 : X \u2192 Y\u2081) [hg : IsSmoothT g\u2081] : IsSmoothT (\u03bb x y => f (g\u2081 x) y a) := by (try infer_instance); admit\n\n\n@[simp \u2193 low-1, diff low-1] -- try to avoid using this theorem\ntheorem diag.arg_x.parm1.adjDiff_simp\n  (a : \u03b1)\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 \u03b1 \u2192 Z) [HasAdjDiffNT 2 \u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a]\n  (g\u2081 : X \u2192 Y\u2081) [HasAdjDiffT g\u2081]\n  (g\u2082 : X \u2192 Y\u2082) [HasAdjDiffT g\u2082]\n  : \u2202\u2020 (\u03bb x => f (g\u2081 x) (g\u2082 x) a)\n    = \n    \u03bb x dz => \n      let (y\u2081,dg\u2081') := \u211b g\u2081 x\n      let (y\u2082,dg\u2082') := \u211b g\u2082 x\n      dg\u2081' ((\u2202\u2020 (hold \u03bb y\u2081' => f y\u2081' y\u2082 a)) y\u2081 dz)\n      +\n      dg\u2082' ((\u2202\u2020 (hold \u03bb y\u2082' => f y\u2081 y\u2082' a)) y\u2082 dz)\n:= by \n  (apply diag.arg_x.adjDiff_simp (\u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a) g\u2081 g\u2082)\n  \n@[simp \u2193 low-1, diff low-1] -- try to avoid using this theorem\ntheorem diag.arg_x.parm2.adjDiff_simp\n  (a : \u03b1) (b : \u03b2)\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 \u03b1 \u2192 \u03b2 \u2192 Z) [HasAdjDiffNT 2 \u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a b]\n  (g\u2081 : X \u2192 Y\u2081) [HasAdjDiffT g\u2081]\n  (g\u2082 : X \u2192 Y\u2082) [HasAdjDiffT g\u2082]\n  : \u2202\u2020 (\u03bb x => f (g\u2081 x) (g\u2082 x) a b)\n    = \n    \u03bb x dz => \n      let (y\u2081,dg\u2081') := \u211b g\u2081 x\n      let (y\u2082,dg\u2082') := \u211b g\u2082 x\n      dg\u2081' ((\u2202\u2020 (hold \u03bb y\u2081' => f y\u2081' y\u2082 a b)) y\u2081 dz)\n      +\n      dg\u2082' ((\u2202\u2020 (hold \u03bb y\u2082' => f y\u2081 y\u2082' a b)) y\u2082 dz)\n:= by \n  (apply diag.arg_x.adjDiff_simp (\u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a b) g\u2081 g\u2082)\n  done\n\n@[simp \u2193 low-1, diff low-1] -- try to avoid using this theorem\ntheorem diag.arg_x.parm3.adjDiff_simp\n  (a : \u03b1) (b : \u03b2) (c : \u03b3)\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 Z) [HasAdjDiffNT 2 \u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a b c]\n  (g\u2081 : X \u2192 Y\u2081) [HasAdjDiffT g\u2081]\n  (g\u2082 : X \u2192 Y\u2082) [HasAdjDiffT g\u2082]\n  : \u2202\u2020 (\u03bb x => f (g\u2081 x) (g\u2082 x) a b c)\n    = \n    \u03bb x dz => \n      let (y\u2081,dg\u2081') := \u211b g\u2081 x\n      let (y\u2082,dg\u2082') := \u211b g\u2082 x\n      dg\u2081' ((\u2202\u2020 (hold \u03bb y\u2081' => f y\u2081' y\u2082 a b c)) y\u2081 dz)\n      +\n      dg\u2082' ((\u2202\u2020 (hold \u03bb y\u2082' => f y\u2081 y\u2082' a b c)) y\u2082 dz)\n:= by \n  (apply diag.arg_x.adjDiff_simp (\u03bb y\u2081 y\u2082 => f y\u2081 y\u2082 a b c) g\u2081 g\u2082)\n  done\n\n----------------------------------------------------------------------\n\n\n\n@[simp \u2193, diff]\ntheorem id.arg_x.revDiff_simp\n  : \u211b (\u03bb x : X => x) = \u03bb x => (x, \u03bb x => x) := by simp[reverseDifferential]; done\n\n@[simp \u2193, diff]\ntheorem const.arg_x.revDiff_simp \n  : \u211b (\u03bb (x : X) (i : \u03b9) => x) \n    = \n    \u03bb x => ((\u03bb i => x), (\u03bb f => \u2211 i, f i))\n  := by simp[reverseDifferential]; done\n\n@[simp \u2193, diff]\ntheorem const.arg_y.revDiff_simp (x : X)\n  : \u211b (\u03bb (y : Y) => x) \n    =\n    \u03bb y => \n      (x, (\u03bb dy' => 0))\n  := by simp[reverseDifferential]; done\n\n@[simp \u2193 low-4, diff low-4]\ntheorem swap.arg_y.revDiff_simp\n  (f : \u03b9 \u2192 X \u2192 Z) [inst : \u2200 i, HasAdjDiffT (f i)]\n  : \u2202\u2020 (\u03bb x y => f y x) = (\u03bb x dx' => \u2211 i, (\u2202\u2020 (f i) x) (dx' i)) := \nby \n  have := \u03bb i => (inst i).1\n  have := \u03bb i => (inst i).2\n\n  simp[adjointDifferential]; done\n\n@[simp \u2193 low-3, diff low-3, simp_guard g (\u03bb x => x)]\ntheorem subst.arg_x.revDiff_simp\n  (f : X \u2192 Y \u2192 Z) [instf : HasAdjDiffNT 2 f]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u211b (\u03bb x => f x (g x)) \n    = \n    \u03bb x => \n      let (y,dg') := \u211b g x\n      let (z,df') := \u211b (uncurryN 2 f) (x,y)\n      (z, \u03bb dz' => \n           let (dx\u2081,dy) := df' dz'\n           dx\u2081 + 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 \u2193 low-2, diff low-2, simp_guard g (\u03bb x => x)]\ntheorem subst.arg_x.parm1.revDiff_simp\n  (a : \u03b1)\n  (f : X \u2192 Y \u2192 \u03b1 \u2192 Z) [HasAdjDiffNT 2 \u03bb x y => f x y a]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u211b (\u03bb x => f x (g x) a) \n    = \n    \u03bb x => \n      let (y,dg') := \u211b g x\n      let (z,df') := \u211b (uncurryN 2 (\u03bb x y => f x y a)) (x,y)\n      (z, \u03bb dz' => \n           let (dx\u2081,dy) := df' dz'\n           dx\u2081 + dg' dy)\n    := \nby \n  apply subst.arg_x.revDiff_simp (\u03bb x y => f x y a) g\n  done\n\n@[simp \u2193 low-2, diff low-2, simp_guard g (\u03bb x => x)]\ntheorem subst.arg_x.parm2.revDiff_simp\n  (a : \u03b1) (b : \u03b2)\n  (f : X \u2192 Y \u2192 \u03b1 \u2192 \u03b2 \u2192 Z) [HasAdjDiffNT 2 \u03bb x y => f x y a b]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u211b (\u03bb x => f x (g x) a b) \n    = \n    \u03bb x => \n      let (y,dg') := \u211b g x\n      let (z,df') := \u211b (uncurryN 2 (\u03bb x y => f x y a b)) (x,y)\n      (z, \u03bb dz' => \n           let (dx\u2081,dy) := df' dz'\n           dx\u2081 + dg' dy)\n    := \nby \n  apply subst.arg_x.revDiff_simp (\u03bb x y => f x y a b) g\n  done\n\n@[simp \u2193 low-2, diff low-2, simp_guard g (\u03bb x => x)]\ntheorem subst.arg_x.parm3.revDiff_simp\n  (a : \u03b1) (b : \u03b2) (c : \u03b3)\n  (f : X \u2192 Y \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 Z) [HasAdjDiffNT 2 \u03bb x y => f x y a b c]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u211b (\u03bb x => f x (g x) a b c) \n    = \n    \u03bb x => \n      let (y,dg') := \u211b g x\n      let (z,df') := \u211b (uncurryN 2 (\u03bb x y => f x y a b c)) (x,y)\n      (z, \u03bb dz' => let (dx\u2081,dy) := df' dz'; dx\u2081 + dg' dy)\n    := \nby \n  apply subst.arg_x.revDiff_simp (\u03bb x y => f x y a b c) g\n  done\n\n\n-- @[simp \u2193 low-10, diff low-10]\ntheorem uncurryN2.arg_x.diff_simp\n  (f : X \u2192 Y \u2192 Z) [HasAdjDiffNT 2 f]\n  : \u2202\u2020 (uncurryN 2 f) \n    =\n    \u03bb (x,y) dz =>\n      (\u2202\u2020 (\u03bb x' => f x' y) x dz, \u2202\u2020 (\u03bb y' => f x y') y dz)\n  := sorry_proof\n\n@[simp \u2193 low-1, diff low-1]\ntheorem comp.arg_x.revDiff_simp\n  (f : Y \u2192 Z) [instf : HasAdjDiffT f]\n  (g : X \u2192 Y) [instg : HasAdjDiffT g]\n  : \u211b (\u03bb x => f (g x)) \n    = \n    \u03bb x => \n      let (y,dg') := \u211b g x\n      let (z,df') := \u211b f y\n      (z, \u03bb 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 \u2193 low-2, diff low-2]\ntheorem diag.arg_x.revDiff_simp\n  (f : Y\u2081 \u2192 Y\u2082 \u2192 Z) [HasAdjDiffNT 2 f]\n  (g\u2081 : X \u2192 Y\u2081) [hg : HasAdjDiffT g\u2081]\n  (g\u2082 : X \u2192 Y\u2082) [HasAdjDiffT g\u2082]\n  : \u211b (\u03bb x => f (g\u2081 x) (g\u2082 x)) \n    = \n    \u03bb x => \n      let (y\u2081,dg\u2081') := \u211b g\u2081 x\n      let (y\u2082,dg\u2082') := \u211b g\u2082 x\n      let (z, df') := \u211b (uncurryN 2 f) (y\u2081,y\u2082)\n      (z, \u03bb dz => let (dy\u2081,dy\u2082) := df' dz; dg\u2081' dy\u2081 + dg\u2082' dy\u2082)\n      -- dg\u2081' ((\u2202\u2020 \u03bb y\u2081 => f y\u2081 y\u2082) y\u2081 (h\u2081 \u25b8 h\u2082 \u25b8 dx'))\n      -- +\n      -- dg\u2082' ((\u2202\u2020 \u03bb y\u2082 => f y\u2081 y\u2082) y\u2082 (h\u2082 \u25b8 h\u2081 \u25b8 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 \u2193 low, diff low]\ntheorem eval.arg_f.revDiff_simp\n  (i : \u03b9)\n  : \u211b (\u03bb (f : \u03b9 \u2192 X) => f i) \n    = \n    \u03bb f => (f i, (\u03bb dx j => ([[i=j]] \u2022 dx : X)))\n  := \nby \n  simp[reverseDifferential,adjointDifferential]; done\n\n@[simp \u2193 low-1, diff low-1]\ntheorem eval.arg_x.parm1.revDiff_simp\n  (f : X \u2192 \u03b9 \u2192 Z) [HasAdjDiff f] (i : \u03b9)\n  : \u211b (\u03bb x => f x i)\n    = \n    \u03bb x =>\n      let (fx, df') := \u211b f x\n      (fx i, \n      \u03bb dz => df' (\u03bb j => ([[i=j]] \u2022 dz)))\n  := \nby \n  rw [comp.arg_x.revDiff_simp (\u03bb (x : \u03b9 \u2192 Z) => x i) f]\n  simp[reverseDifferential,adjointDifferential]\n\n\n-- @[simp \u2193]\n-- theorem subst.arg_x.revDiff_simp'''\n--   (f : X \u2192 Y \u2192 Z) [IsSmooth f]\n--   [instfx : \u2200 y, HasAdjDiff \u03bb x => f x y]\n--   [instfy : \u2200 x, HasAdjDiff (f x)]\n--   (g : Y \u2192 X) [instg : HasAdjDiff g]\n--   : \u2202\u2020 (\u03bb y => f (g y) y) \n--     = \n--     \u03bb y dy' => \n--       (\u2202\u2020 (\u03bb y' => f (g y) y')) y dy'\n--       +\n--       (\u2202\u2020 g y) (\u2202\u2020 (\u03bb 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u201ctoo simple to be simple\u201d\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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Type _} {\u03c0 : \u03b9 \u2192 Type _} [TopologicalSpace \u03b1]\n  {s t u v : Set \u03b1}\n\nsection Preconnected\n\n/-- A preconnected set is one where there is no non-trivial open partition. -/\ndef IsPreconnected (s : Set \u03b1) : Prop :=\n  \u2200 u v : Set \u03b1, IsOpen u \u2192 IsOpen v \u2192 s \u2286 u \u222a v \u2192 (s \u2229 u).Nonempty \u2192 (s \u2229 v).Nonempty \u2192\n    (s \u2229 (u \u2229 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 \u03b1) : Prop :=\n  s.Nonempty \u2227 IsPreconnected s\n#align is_connected IsConnected\n\ntheorem IsConnected.nonempty {s : Set \u03b1} (h : IsConnected s) : s.Nonempty :=\n  h.1\n#align is_connected.nonempty IsConnected.nonempty\n\ntheorem IsConnected.isPreconnected {s : Set \u03b1} (h : IsConnected s) : IsPreconnected s :=\n  h.2\n#align is_connected.is_preconnected IsConnected.isPreconnected\n\ntheorem IsPreirreducible.isPreconnected {s : Set \u03b1} (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 \u03b1} (H : IsIrreducible s) : IsConnected s :=\n  \u27e8H.nonempty, H.isPreirreducible.isPreconnected\u27e9\n#align is_irreducible.is_connected IsIrreducible.isConnected\n\ntheorem isPreconnected_empty : IsPreconnected (\u2205 : Set \u03b1) :=\n  isPreirreducible_empty.isPreconnected\n#align is_preconnected_empty isPreconnected_empty\n\ntheorem isConnected_singleton {x} : IsConnected ({x} : Set \u03b1) :=\n  isIrreducible_singleton.isConnected\n#align is_connected_singleton isConnected_singleton\n\ntheorem isPreconnected_singleton {x} : IsPreconnected ({x} : Set \u03b1) :=\n  isConnected_singleton.isPreconnected\n#align is_preconnected_singleton isPreconnected_singleton\n\ntheorem Set.Subsingleton.isPreconnected {s : Set \u03b1} (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 \u03b1} (x : \u03b1)\n    (H : \u2200 y \u2208 s, \u2203 t, t \u2286 s \u2227 x \u2208 t \u2227 y \u2208 t \u2227 IsPreconnected t) : IsPreconnected s := by\n  rintro u v hu hv hs \u27e8z, zs, zu\u27e9 \u27e8y, ys, yv\u27e9\n  have xs : x \u2208 s := by\n    rcases H y ys with \u27e8t, ts, xt, -, -\u27e9\n    exact ts xt\n  -- porting note: todo: use `wlog xu : x \u2208 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 \u27e8t, ts, xt, yt, ht\u27e9\n    have := ht u v hu hv (ts.trans hs) \u27e8x, xt, xu\u27e9 \u27e8y, yt, yv\u27e9\n    exact this.imp fun z hz => \u27e8ts hz.1, hz.2\u27e9\n  case inr xv =>\n    rcases H z zs with \u27e8t, ts, xt, zt, ht\u27e9\n    have := ht v u hv hu (ts.trans <| by rwa [union_comm]) \u27e8x, xt, xv\u27e9 \u27e8z, zt, zu\u27e9\n    exact this.imp fun _ h => \u27e8ts h.1, h.2.2, h.2.1\u27e9\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 \u03b1}\n    (H : \u2200 x, x \u2208 s \u2192 \u2200 y, y \u2208 s \u2192 \u2203 t, t \u2286 s \u2227 x \u2208 t \u2227 y \u2208 t \u2227 IsPreconnected t) :\n    IsPreconnected s := by\n  rcases eq_empty_or_nonempty s with (rfl | \u27e8x, hx\u27e9)\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\u209b (x : \u03b1) (c : Set (Set \u03b1)) (H1 : \u2200 s \u2208 c, x \u2208 s)\n    (H2 : \u2200 s \u2208 c, IsPreconnected s) : IsPreconnected (\u22c3\u2080 c) := by\n  apply isPreconnected_of_forall x\n  rintro y \u27e8s, sc, ys\u27e9\n  exact \u27e8s, subset_union\u209b_of_mem sc, H1 s sc, ys, H2 s sc\u27e9\n#align is_preconnected_sUnion isPreconnected_union\u209b\n\ntheorem isPreconnected_union\u1d62 {\u03b9 : Sort _} {s : \u03b9 \u2192 Set \u03b1} (h\u2081 : (\u22c2 i, s i).Nonempty)\n    (h\u2082 : \u2200 i, IsPreconnected (s i)) : IsPreconnected (\u22c3 i, s i) :=\n  Exists.elim h\u2081 fun f hf => isPreconnected_union\u209b f _ hf (forall_range_iff.2 h\u2082)\n#align is_preconnected_Union isPreconnected_union\u1d62\n\ntheorem IsPreconnected.union (x : \u03b1) {s t : Set \u03b1} (H1 : x \u2208 s) (H2 : x \u2208 t) (H3 : IsPreconnected s)\n    (H4 : IsPreconnected t) : IsPreconnected (s \u222a t) :=\n  union\u209b_pair s t \u25b8 isPreconnected_union\u209b 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 \u03b1} (H : (s \u2229 t).Nonempty) (hs : IsPreconnected s)\n    (ht : IsPreconnected t) : IsPreconnected (s \u222a t) := by\n  rcases H with \u27e8x, hxs, hxt\u27e9\n  exact hs.union x hxs hxt ht\n#align is_preconnected.union' IsPreconnected.union'\n\ntheorem IsConnected.union {s t : Set \u03b1} (H : (s \u2229 t).Nonempty) (Hs : IsConnected s)\n    (Ht : IsConnected t) : IsConnected (s \u222a t) := by\n  rcases H with \u27e8x, hx\u27e9\n  refine' \u27e8\u27e8x, mem_union_left t (mem_of_mem_inter_left hx)\u27e9, _\u27e9\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\u209b of a set S of preconnected subsets is preconnected. -/\ntheorem IsPreconnected.union\u209b_directed {S : Set (Set \u03b1)} (K : DirectedOn (\u00b7 \u2286 \u00b7) S)\n    (H : \u2200 s \u2208 S, IsPreconnected s) : IsPreconnected (\u22c3\u2080 S) := by\n  rintro u v hu hv Huv \u27e8a, \u27e8s, hsS, has\u27e9, hau\u27e9 \u27e8b, \u27e8t, htS, hbt\u27e9, hbv\u27e9\n  obtain \u27e8r, hrS, hsr, htr\u27e9 : \u2203 r \u2208 S, s \u2286 r \u2227 t \u2286 r := K s hsS t htS\n  have Hnuv : (r \u2229 (u \u2229 v)).Nonempty :=\n    H _ hrS u v hu hv ((subset_union\u209b_of_mem hrS).trans Huv) \u27e8a, hsr has, hau\u27e9 \u27e8b, htr hbt, hbv\u27e9\n  have Kruv : r \u2229 (u \u2229 v) \u2286 \u22c3\u2080 S \u2229 (u \u2229 v) := inter_subset_inter_left _ (subset_union\u209b_of_mem hrS)\n  exact Hnuv.mono Kruv\n#align is_preconnected.sUnion_directed IsPreconnected.union\u209b_directed\n\n/-- The bunion\u1d62 of a family of preconnected sets is preconnected if the graph determined by\nwhether two sets intersect is preconnected. -/\ntheorem IsPreconnected.bunion\u1d62_of_reflTransGen {\u03b9 : Type _} {t : Set \u03b9} {s : \u03b9 \u2192 Set \u03b1}\n    (H : \u2200 i \u2208 t, IsPreconnected (s i))\n    (K : \u2200 i, i \u2208 t \u2192 \u2200 j, j \u2208 t \u2192 ReflTransGen (fun i j => (s i \u2229 s j).Nonempty \u2227 i \u2208 t) i j) :\n    IsPreconnected (\u22c3 n \u2208 t, s n) := by\n  let R := fun i j : \u03b9 => (s i \u2229 s j).Nonempty \u2227 i \u2208 t\n  have P : \u2200 i, i \u2208 t \u2192 \u2200 j, j \u2208 t \u2192 ReflTransGen R i j \u2192\n      \u2203 p, p \u2286 t \u2227 i \u2208 p \u2227 j \u2208 p \u2227 IsPreconnected (\u22c3 j \u2208 p, s j) := fun i hi j hj h => by\n    induction h\n    case refl =>\n      refine \u27e8{i}, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_\u27e9\n      rw [bunion\u1d62_singleton]\n      exact H i hi\n    case tail j k _ hjk ih =>\n      obtain \u27e8p, hpt, hip, hjp, hp\u27e9 := ih hjk.2\n      refine \u27e8insert k p, insert_subset.mpr \u27e8hj, hpt\u27e9, mem_insert_of_mem k hip, mem_insert k p, ?_\u27e9\n      rw [bunion\u1d62_insert]\n      refine (H k hj).union' (hjk.1.mono ?_) hp\n      rw [inter_comm]\n      exact inter_subset_inter_right _ (subset_bunion\u1d62_of_mem hjp)\n  refine' isPreconnected_of_forall_pair _\n  intro x hx y hy\n  obtain \u27e8i : \u03b9, hi : i \u2208 t, hxi : x \u2208 s i\u27e9 := mem_union\u1d62\u2082.1 hx\n  obtain \u27e8j : \u03b9, hj : j \u2208 t, hyj : y \u2208 s j\u27e9 := mem_union\u1d62\u2082.1 hy\n  obtain \u27e8p, hpt, hip, hjp, hp\u27e9 := P i hi j hj (K i hi j hj)\n  exact \u27e8\u22c3 j \u2208 p, s j, bunion\u1d62_subset_bunion\u1d62_left hpt, mem_bunion\u1d62 hip hxi,\n    mem_bunion\u1d62 hjp hyj, hp\u27e9\n#align is_preconnected.bUnion_of_refl_trans_gen IsPreconnected.bunion\u1d62_of_reflTransGen\n\n/-- The bunion\u1d62 of a family of preconnected sets is preconnected if the graph determined by\nwhether two sets intersect is preconnected. -/\ntheorem IsConnected.bunion\u1d62_of_reflTransGen {\u03b9 : Type _} {t : Set \u03b9} {s : \u03b9 \u2192 Set \u03b1}\n    (ht : t.Nonempty) (H : \u2200 i \u2208 t, IsConnected (s i))\n    (K : \u2200 i, i \u2208 t \u2192 \u2200 j, j \u2208 t \u2192 ReflTransGen (fun i j : \u03b9 => (s i \u2229 s j).Nonempty \u2227 i \u2208 t) i j) :\n    IsConnected (\u22c3 n \u2208 t, s n) :=\n  \u27e8nonempty_bunion\u1d62.2 <| \u27e8ht.some, ht.some_mem, (H _ ht.some_mem).nonempty\u27e9,\n    IsPreconnected.bunion\u1d62_of_reflTransGen (fun i hi => (H i hi).isPreconnected) K\u27e9\n#align is_connected.bUnion_of_refl_trans_gen IsConnected.bunion\u1d62_of_reflTransGen\n\n/-- Preconnectedness of the union\u1d62 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\u1d62_of_reflTransGen {\u03b9 : Type _} {s : \u03b9 \u2192 Set \u03b1}\n    (H : \u2200 i, IsPreconnected (s i))\n    (K : \u2200 i j, ReflTransGen (fun i j : \u03b9 => (s i \u2229 s j).Nonempty) i j) :\n    IsPreconnected (\u22c3 n, s n) := by\n  rw [\u2190 bunion\u1d62_univ]\n  exact IsPreconnected.bunion\u1d62_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\u1d62_of_reflTransGen\n\ntheorem IsConnected.union\u1d62_of_reflTransGen {\u03b9 : Type _} [Nonempty \u03b9] {s : \u03b9 \u2192 Set \u03b1}\n    (H : \u2200 i, IsConnected (s i))\n    (K : \u2200 i j, ReflTransGen (fun i j : \u03b9 => (s i \u2229 s j).Nonempty) i j) : IsConnected (\u22c3 n, s n) :=\n  \u27e8nonempty_union\u1d62.2 <| Nonempty.elim \u2039_\u203a fun i : \u03b9 => \u27e8i, (H _).nonempty\u27e9,\n    IsPreconnected.union\u1d62_of_reflTransGen (fun i => (H i).isPreconnected) K\u27e9\n#align is_connected.Union_of_refl_trans_gen IsConnected.union\u1d62_of_reflTransGen\n\nsection SuccOrder\n\nopen Order\n\nvariable [LinearOrder \u03b2] [SuccOrder \u03b2] [IsSuccArchimedean \u03b2]\n\n/-- The union\u1d62 of connected sets indexed by a type with an archimedean successor (like `\u2115` or `\u2124`)\n  such that any two neighboring sets meet is preconnected. -/\ntheorem IsPreconnected.union\u1d62_of_chain {s : \u03b2 \u2192 Set \u03b1} (H : \u2200 n, IsPreconnected (s n))\n    (K : \u2200 n, (s n \u2229 s (succ n)).Nonempty) : IsPreconnected (\u22c3 n, s n) :=\n  IsPreconnected.union\u1d62_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\u1d62_of_chain\n\n/-- The union\u1d62 of connected sets indexed by a type with an archimedean successor (like `\u2115` or `\u2124`)\n  such that any two neighboring sets meet is connected. -/\ntheorem IsConnected.union\u1d62_of_chain [Nonempty \u03b2] {s : \u03b2 \u2192 Set \u03b1} (H : \u2200 n, IsConnected (s n))\n    (K : \u2200 n, (s n \u2229 s (succ n)).Nonempty) : IsConnected (\u22c3 n, s n) :=\n  IsConnected.union\u1d62_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\u1d62_of_chain\n\n/-- The union\u1d62 of preconnected sets indexed by a subset of a type with an archimedean successor\n  (like `\u2115` or `\u2124`) such that any two neighboring sets meet is preconnected. -/\ntheorem IsPreconnected.bunion\u1d62_of_chain {s : \u03b2 \u2192 Set \u03b1} {t : Set \u03b2} (ht : OrdConnected t)\n    (H : \u2200 n \u2208 t, IsPreconnected (s n))\n    (K : \u2200 n : \u03b2, n \u2208 t \u2192 succ n \u2208 t \u2192 (s n \u2229 s (succ n)).Nonempty) :\n    IsPreconnected (\u22c3 n \u2208 t, s n) := by\n  have h1 : \u2200 {i j k : \u03b2}, i \u2208 t \u2192 j \u2208 t \u2192 k \u2208 Ico i j \u2192 k \u2208 t := fun hi hj hk =>\n    ht.out hi hj (Ico_subset_Icc_self hk)\n  have h2 : \u2200 {i j k : \u03b2}, i \u2208 t \u2192 j \u2208 t \u2192 k \u2208 Ico i j \u2192 succ k \u2208 t := fun hi hj hk =>\n    ht.out hi hj \u27e8hk.1.trans <| le_succ _, succ_le_of_lt hk.2\u27e9\n  have h3 : \u2200 {i j k : \u03b2}, i \u2208 t \u2192 j \u2208 t \u2192 k \u2208 Ico i j \u2192 (s k \u2229 s (succ k)).Nonempty :=\n    fun hi hj hk => K _ (h1 hi hj hk) (h2 hi hj hk)\n  refine' IsPreconnected.bunion\u1d62_of_reflTransGen H fun i hi j hj => _\n  exact reflTransGen_of_succ _ (fun k hk => \u27e8h3 hi hj hk, h1 hi hj hk\u27e9) fun k hk =>\n      \u27e8by rw [inter_comm]; exact h3 hj hi hk, h2 hj hi hk\u27e9\n#align is_preconnected.bUnion_of_chain IsPreconnected.bunion\u1d62_of_chain\n\n/-- The union\u1d62 of connected sets indexed by a subset of a type with an archimedean successor\n  (like `\u2115` or `\u2124`) such that any two neighboring sets meet is preconnected. -/\ntheorem IsConnected.bunion\u1d62_of_chain {s : \u03b2 \u2192 Set \u03b1} {t : Set \u03b2} (hnt : t.Nonempty)\n    (ht : OrdConnected t) (H : \u2200 n \u2208 t, IsConnected (s n))\n    (K : \u2200 n : \u03b2, n \u2208 t \u2192 succ n \u2208 t \u2192 (s n \u2229 s (succ n)).Nonempty) : IsConnected (\u22c3 n \u2208 t, s n) :=\n  \u27e8nonempty_bunion\u1d62.2 <| \u27e8hnt.some, hnt.some_mem, (H _ hnt.some_mem).nonempty\u27e9,\n    IsPreconnected.bunion\u1d62_of_chain ht (fun i hi => (H i hi).isPreconnected) K\u27e9\n#align is_connected.bUnion_of_chain IsConnected.bunion\u1d62_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 \u03b1} {t : Set \u03b1} (H : IsPreconnected s)\n    (Kst : s \u2286 t) (Ktcs : t \u2286 closure s) : IsPreconnected t :=\n  fun u v hu hv htuv \u27e8_y, hyt, hyu\u27e9 \u27e8_z, hzt, hzv\u27e9 =>\n  let \u27e8p, hpu, hps\u27e9 := mem_closure_iff.1 (Ktcs hyt) u hu hyu\n  let \u27e8q, hqv, hqs\u27e9 := mem_closure_iff.1 (Ktcs hzt) v hv hzv\n  let \u27e8r, hrs, hruv\u27e9 := H u v hu hv (Subset.trans Kst htuv) \u27e8p, hps, hpu\u27e9 \u27e8q, hqs, hqv\u27e9\n  \u27e8r, Kst hrs, hruv\u27e9\n#align is_preconnected.subset_closure IsPreconnected.subset_closure\n\nprotected theorem IsConnected.subset_closure {s : Set \u03b1} {t : Set \u03b1} (H : IsConnected s)\n    (Kst : s \u2286 t) (Ktcs : t \u2286 closure s) : IsConnected t :=\n  \u27e8Nonempty.mono Kst H.left, IsPreconnected.subset_closure H.right Kst Ktcs\u27e9\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 \u03b1} (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 \u03b1} (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 \u03b2] {s : Set \u03b1} (H : IsPreconnected s)\n    (f : \u03b1 \u2192 \u03b2) (hf : ContinuousOn f s) : IsPreconnected (f '' s) := by\n  -- Unfold/destruct definitions in hypotheses\n  rintro u v hu hv huv \u27e8_, \u27e8x, xs, rfl\u27e9, xu\u27e9 \u27e8_, \u27e8y, ys, rfl\u27e9, yv\u27e9\n  rcases continuousOn_iff'.1 hf u hu with \u27e8u', hu', u'_eq\u27e9\n  rcases continuousOn_iff'.1 hf v hv with \u27e8v', hv', v'_eq\u27e9\n  -- Reformulate `huv : f '' s \u2286 u \u222a v` in terms of `u'` and `v'`\n  replace huv : s \u2286 u' \u222a v'\n  \u00b7 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, \u2190 inter_distrib_right] at huv\n    exact (subset_inter_iff.1 huv).1\n  -- Now `s \u2286 u' \u222a v'`, so we can apply `\u2039IsPreconnected s\u203a`\n  obtain \u27e8z, hz\u27e9 : (s \u2229 (u' \u2229 v')).Nonempty := by\n    refine H u' v' hu' hv' huv \u27e8x, ?_\u27e9 \u27e8y, ?_\u27e9 <;> rw [inter_comm]\n    exacts [u'_eq \u25b8 \u27e8xu, xs\u27e9, v'_eq \u25b8 \u27e8yv, ys\u27e9]\n  rw [\u2190 inter_self s, inter_assoc, inter_left_comm s u', \u2190 inter_assoc, inter_comm s, inter_comm s,\n    \u2190 u'_eq, \u2190 v'_eq] at hz\n  exact \u27e8f z, \u27e8z, hz.1.2, rfl\u27e9, hz.1.1, hz.2.1\u27e9\n#align is_preconnected.image IsPreconnected.image\n\nprotected theorem IsConnected.image [TopologicalSpace \u03b2] {s : Set \u03b1} (H : IsConnected s) (f : \u03b1 \u2192 \u03b2)\n    (hf : ContinuousOn f s) : IsConnected (f '' s) :=\n  \u27e8nonempty_image_iff.mpr H.nonempty, H.isPreconnected.image f hf\u27e9\n#align is_connected.image IsConnected.image\n\ntheorem isPreconnected_closed_iff {s : Set \u03b1} :\n    IsPreconnected s \u2194 \u2200 t t', IsClosed t \u2192 IsClosed t' \u2192\n      s \u2286 t \u222a t' \u2192 (s \u2229 t).Nonempty \u2192 (s \u2229 t').Nonempty \u2192 (s \u2229 (t \u2229 t')).Nonempty :=\n  \u27e8by\n    rintro h t t' ht ht' htt' \u27e8x, xs, xt\u27e9 \u27e8y, ys, yt'\u27e9\n    rw [\u2190 not_disjoint_iff_nonempty_inter, \u2190 subset_compl_iff_disjoint_right, compl_inter]\n    intro h'\n    have xt' : x \u2209 t' := (h' xs).resolve_left (absurd xt)\n    have yt : y \u2209 t := (h' ys).resolve_right (absurd yt')\n    have := h _ _ ht.isOpen_compl ht'.isOpen_compl h' \u27e8y, ys, yt\u27e9 \u27e8x, xs, xt'\u27e9\n    rw [\u2190 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 \u27e8x, xs, xu\u27e9 \u27e8y, ys, yv\u27e9\n    rw [\u2190 not_disjoint_iff_nonempty_inter, \u2190 subset_compl_iff_disjoint_right, compl_inter]\n    intro h'\n    have xv : x \u2209 v := (h' xs).elim (absurd xu) id\n    have yu : y \u2209 u := (h' ys).elim id (absurd yv)\n    have := h _ _ hu.isClosed_compl hv.isClosed_compl h' \u27e8y, ys, yu\u27e9 \u27e8x, xs, xv\u27e9\n    rw [\u2190 compl_union] at this\n    exact this.ne_empty huv.disjoint_compl_right.inter_eq\u27e9\n#align is_preconnected_closed_iff isPreconnected_closed_iff\n\ntheorem Inducing.isPreconnected_image [TopologicalSpace \u03b2] {s : Set \u03b1} {f : \u03b1 \u2192 \u03b2}\n    (hf : Inducing f) : IsPreconnected (f '' s) \u2194 IsPreconnected s := by\n  refine' \u27e8fun h => _, fun h => h.image _ hf.continuous.continuousOn\u27e9\n  rintro u v hu' hv' huv \u27e8x, hxs, hxu\u27e9 \u27e8y, hys, hyv\u27e9\n  rcases hf.isOpen_iff.1 hu' with \u27e8u, hu, rfl\u27e9\n  rcases hf.isOpen_iff.1 hv' with \u27e8v, hv, rfl\u27e9\n  replace huv : f '' s \u2286 u \u222a v; \u00b7 rwa [image_subset_iff]\n  rcases h u v hu hv huv \u27e8f x, mem_image_of_mem _ hxs, hxu\u27e9 \u27e8f y, mem_image_of_mem _ hys, hyv\u27e9 with\n    \u27e8_, \u27e8z, hzs, rfl\u27e9, hzuv\u27e9\n  exact \u27e8z, hzs, hzuv\u27e9\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 \u03b2] {s : Set \u03b2} (hs : IsPreconnected s)\n    {f : \u03b1 \u2192 \u03b2} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s \u2286 range f) :\n    IsPreconnected (f \u207b\u00b9' s) := fun u v hu hv hsuv hsu hsv => by\n  replace hsf : f '' (f \u207b\u00b9' s) = s := image_preimage_eq_of_subset hsf\n  obtain \u27e8_, has, \u27e8a, hau, rfl\u27e9, hav\u27e9 : (s \u2229 (f '' u \u2229 f '' v)).Nonempty\n  \u00b7 refine hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_\n    \u00b7 simpa only [hsf, image_union] using image_subset f hsuv\n    \u00b7 simpa only [image_preimage_inter] using hsu.image f\n    \u00b7 simpa only [image_preimage_inter] using hsv.image f\n  \u00b7 exact \u27e8a, has, hau, hinj.mem_set_image.1 hav\u27e9\n#align is_preconnected.preimage_of_open_map IsPreconnected.preimage_of_open_map\n\ntheorem IsPreconnected.preimage_of_closed_map [TopologicalSpace \u03b2] {s : Set \u03b2}\n    (hs : IsPreconnected s) {f : \u03b1 \u2192 \u03b2} (hinj : Function.Injective f) (hf : IsClosedMap f)\n    (hsf : s \u2286 range f) : IsPreconnected (f \u207b\u00b9' s) :=\n  isPreconnected_closed_iff.2 fun u v hu hv hsuv hsu hsv => by\n    replace hsf : f '' (f \u207b\u00b9' s) = s := image_preimage_eq_of_subset hsf\n    obtain \u27e8_, has, \u27e8a, hau, rfl\u27e9, hav\u27e9 : (s \u2229 (f '' u \u2229 f '' v)).Nonempty\n    \u00b7 refine isPreconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_\n      \u00b7 simpa only [hsf, image_union] using image_subset f hsuv\n      \u00b7 simpa only [image_preimage_inter] using hsu.image f\n      \u00b7 simpa only [image_preimage_inter] using hsv.image f\n    \u00b7 exact \u27e8a, has, hau, hinj.mem_set_image.1 hav\u27e9\n#align is_preconnected.preimage_of_closed_map IsPreconnected.preimage_of_closed_map\n\ntheorem IsConnected.preimage_of_openMap [TopologicalSpace \u03b2] {s : Set \u03b2} (hs : IsConnected s)\n    {f : \u03b1 \u2192 \u03b2} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s \u2286 range f) :\n    IsConnected (f \u207b\u00b9' s) :=\n  \u27e8hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_open_map hinj hf hsf\u27e9\n#align is_connected.preimage_of_open_map IsConnected.preimage_of_openMap\n\ntheorem IsConnected.preimage_of_closedMap [TopologicalSpace \u03b2] {s : Set \u03b2} (hs : IsConnected s)\n    {f : \u03b1 \u2192 \u03b2} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s \u2286 range f) :\n    IsConnected (f \u207b\u00b9' s) :=\n  \u27e8hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_closed_map hinj hf hsf\u27e9\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 \u2286 u \u222a v) (hs : IsPreconnected s) : s \u2286 u \u2228 s \u2286 v := by\n  specialize hs u v hu hv hsuv\n  obtain hsu | hsu := (s \u2229 u).eq_empty_or_nonempty\n  \u00b7 exact Or.inr ((Set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv)\n  \u00b7 replace hs := mt (hs hsu)\n    simp_rw [Set.not_nonempty_iff_eq_empty, \u2190 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 \u2286 u \u222a v) (hsu : (s \u2229 u).Nonempty) (hs : IsPreconnected s) :\n    s \u2286 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 \u27e8x, _, hx\u27e9 := 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 \u2286 u \u222a v) (hsv : (s \u2229 v).Nonempty) (hs : IsPreconnected s) :\n    s \u2286 v :=\n  hs.subset_left_of_subset_union hv hu huv.symm (union_comm u v \u25b8 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 \u03b1} (hs : IsPreconnected s) (ht : IsClopen t)\n    (hne : (s \u2229 t).Nonempty) : s \u2286 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 \u2229 u).Nonempty) (h : closure u \u2229 s \u2286 u) : s \u2286 u := by\n  have A : s \u2286 u \u222a closure u\u1d9c := by\n    intro x hx\n    by_cases xu : x \u2208 u\n    \u00b7 exact Or.inl xu\n    \u00b7 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 \u03b2] {s : Set \u03b1} {t : Set \u03b2} (hs : IsPreconnected s)\n    (ht : IsPreconnected t) : IsPreconnected (s \u00d7\u02e2 t) := by\n  apply isPreconnected_of_forall_pair\n  rintro \u27e8a\u2081, b\u2081\u27e9 \u27e8ha\u2081, hb\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9 \u27e8ha\u2082, hb\u2082\u27e9\n  refine' \u27e8Prod.mk a\u2081 '' t \u222a flip Prod.mk b\u2082 '' s, _, .inl \u27e8b\u2081, hb\u2081, rfl\u27e9, .inr \u27e8a\u2082, ha\u2082, rfl\u27e9, _\u27e9\n  \u00b7 rintro _ (\u27e8y, hy, rfl\u27e9 | \u27e8x, hx, rfl\u27e9)\n    exacts [\u27e8ha\u2081, hy\u27e9, \u27e8hx, hb\u2082\u27e9]\n  \u00b7 exact (ht.image _ (Continuous.Prod.mk _).continuousOn).union (a\u2081, b\u2082) \u27e8b\u2082, hb\u2082, rfl\u27e9\n      \u27e8a\u2081, ha\u2081, rfl\u27e9 (hs.image _ (continuous_id.prod_mk continuous_const).continuousOn)\n#align is_preconnected.prod IsPreconnected.prod\n\ntheorem IsConnected.prod [TopologicalSpace \u03b2] {s : Set \u03b1} {t : Set \u03b2} (hs : IsConnected s)\n    (ht : IsConnected t) : IsConnected (s \u00d7\u02e2 t) :=\n  \u27e8hs.1.prod ht.1, hs.2.prod ht.2\u27e9\n#align is_connected.prod IsConnected.prod\n\ntheorem isPreconnected_univ_pi [\u2200 i, TopologicalSpace (\u03c0 i)] {s : \u2200 i, Set (\u03c0 i)}\n    (hs : \u2200 i, IsPreconnected (s i)) : IsPreconnected (pi univ s) := by\n  rintro u v uo vo hsuv \u27e8f, hfs, hfu\u27e9 \u27e8g, hgs, hgv\u27e9\n  rcases exists_finset_piecewise_mem_of_mem_nhds (uo.mem_nhds hfu) g with \u27e8I, hI\u27e9\n  induction' I using Finset.induction_on with i I _ ihI\n  \u00b7 refine' \u27e8g, hgs, \u27e8_, hgv\u27e9\u27e9\n    simpa using hI\n  \u00b7 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 \u2286 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 \u2229 u).Nonempty := \u27e8_, mem_image_of_mem _ (hfs _ trivial), hI\u27e9\n    have hSv : (S \u2229 v).Nonempty := \u27e8_, \u27e8_, this _ trivial, update_eq_self _ _\u27e9, h\u27e9\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 [\u2200 i, TopologicalSpace (\u03c0 i)] {s : \u2200 i, Set (\u03c0 i)} :\n    IsConnected (pi univ s) \u2194 \u2200 i, IsConnected (s i) := by\n  simp only [IsConnected, \u2190 univ_pi_nonempty_iff, forall_and, and_congr_right_iff]\n  refine' fun hne => \u27e8fun hc i => _, isPreconnected_univ_pi\u27e9\n  rw [\u2190 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 [\u2200 i, TopologicalSpace (\u03c0 i)] {s : Set (\u03a3i, \u03c0 i)} :\n    IsConnected s \u2194 \u2203 i t, IsConnected t \u2227 s = Sigma.mk i '' t := by\n  refine' \u27e8fun hs => _, _\u27e9\n  \u00b7 obtain \u27e8\u27e8i, x\u27e9, hx\u27e9 := hs.nonempty\n    have : s \u2286 range (Sigma.mk i) :=\n      hs.isPreconnected.subset_clopen isClopen_range_sigmaMk \u27e8\u27e8i, x\u27e9, hx, x, rfl\u27e9\n    exact \u27e8i, Sigma.mk i \u207b\u00b9' s, hs.preimage_of_openMap sigma_mk_injective isOpenMap_sigmaMk this,\n      (Set.image_preimage_eq_of_subset this).symm\u27e9\n  \u00b7 rintro \u27e8i, t, ht, rfl\u27e9\n    exact ht.image _ continuous_sigmaMk.continuousOn\n#align sigma.is_connected_iff Sigma.isConnected_iff\n\ntheorem Sigma.isPreconnected_iff [h\u03b9 : Nonempty \u03b9] [\u2200 i, TopologicalSpace (\u03c0 i)]\n    {s : Set (\u03a3i, \u03c0 i)} : IsPreconnected s \u2194 \u2203 i t, IsPreconnected t \u2227 s = Sigma.mk i '' t := by\n  refine' \u27e8fun hs => _, _\u27e9\n  \u00b7 obtain rfl | h := s.eq_empty_or_nonempty\n    \u00b7 exact \u27e8Classical.choice h\u03b9, \u2205, isPreconnected_empty, (Set.image_empty _).symm\u27e9\n    \u00b7 obtain \u27e8a, t, ht, rfl\u27e9 := Sigma.isConnected_iff.1 \u27e8h, hs\u27e9\n      refine' \u27e8a, t, ht.isPreconnected, rfl\u27e9\n  \u00b7 rintro \u27e8a, t, ht, rfl\u27e9\n    exact ht.image _ continuous_sigmaMk.continuousOn\n#align sigma.is_preconnected_iff Sigma.isPreconnected_iff\n\ntheorem Sum.isConnected_iff [TopologicalSpace \u03b2] {s : Set (Sum \u03b1 \u03b2)} :\n    IsConnected s \u2194\n      (\u2203 t, IsConnected t \u2227 s = Sum.inl '' t) \u2228 \u2203 t, IsConnected t \u2227 s = Sum.inr '' t := by\n  refine' \u27e8fun hs => _, _\u27e9\n  \u00b7 obtain \u27e8x | x, hx\u27e9 := hs.nonempty\n    \u00b7 have h : s \u2286 range Sum.inl :=\n        hs.isPreconnected.subset_clopen isClopen_range_inl \u27e8.inl x, hx, x, rfl\u27e9\n      refine' Or.inl \u27e8Sum.inl \u207b\u00b9' s, _, _\u27e9\n      \u00b7 exact hs.preimage_of_openMap Sum.inl_injective isOpenMap_inl h\n      \u00b7 exact (image_preimage_eq_of_subset h).symm\n    \u00b7 have h : s \u2286 range Sum.inr :=\n        hs.isPreconnected.subset_clopen isClopen_range_inr \u27e8.inr x, hx, x, rfl\u27e9\n      refine' Or.inr \u27e8Sum.inr \u207b\u00b9' s, _, _\u27e9\n      \u00b7 exact hs.preimage_of_openMap Sum.inr_injective isOpenMap_inr h\n      \u00b7 exact (image_preimage_eq_of_subset h).symm\n  \u00b7 rintro (\u27e8t, ht, rfl\u27e9 | \u27e8t, ht, rfl\u27e9)\n    \u00b7 exact ht.image _ continuous_inl.continuousOn\n    \u00b7 exact ht.image _ continuous_inr.continuousOn\n#align sum.is_connected_iff Sum.isConnected_iff\n\ntheorem Sum.isPreconnected_iff [TopologicalSpace \u03b2] {s : Set (Sum \u03b1 \u03b2)} :\n    IsPreconnected s \u2194\n      (\u2203 t, IsPreconnected t \u2227 s = Sum.inl '' t) \u2228 \u2203 t, IsPreconnected t \u2227 s = Sum.inr '' t := by\n  refine' \u27e8fun hs => _, _\u27e9\n  \u00b7 obtain rfl | h := s.eq_empty_or_nonempty\n    \u00b7 exact Or.inl \u27e8\u2205, isPreconnected_empty, (Set.image_empty _).symm\u27e9\n    obtain \u27e8t, ht, rfl\u27e9 | \u27e8t, ht, rfl\u27e9 := Sum.isConnected_iff.1 \u27e8h, hs\u27e9\n    \u00b7 exact Or.inl \u27e8t, ht.isPreconnected, rfl\u27e9\n    \u00b7 exact Or.inr \u27e8t, ht.isPreconnected, rfl\u27e9\n  \u00b7 rintro (\u27e8t, ht, rfl\u27e9 | \u27e8t, ht, rfl\u27e9)\n    \u00b7 exact ht.image _ continuous_inl.continuousOn\n    \u00b7 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 : \u03b1) : Set \u03b1 :=\n  \u22c3\u2080 { s : Set \u03b1 | IsPreconnected s \u2227 x \u2208 s }\n#align connected_component connectedComponent\n\n/-- Given a set `F` in a topological space `\u03b1` and a point `x : \u03b1`, the connected\ncomponent of `x` in `F` is the connected component of `x` in the subtype `F` seen as\na set in `\u03b1`. 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 \u03b1) (x : \u03b1) : Set \u03b1 :=\n  if h : x \u2208 F then (\u2191) '' connectedComponent (\u27e8x, h\u27e9 : F) else \u2205\n#align connected_component_in connectedComponentIn\n\ntheorem connectedComponentIn_eq_image {F : Set \u03b1} {x : \u03b1} (h : x \u2208 F) :\n    connectedComponentIn F x = (\u2191) '' connectedComponent (\u27e8x, h\u27e9 : F) :=\n  dif_pos h\n#align connected_component_in_eq_image connectedComponentIn_eq_image\n\ntheorem connectedComponentIn_eq_empty {F : Set \u03b1} {x : \u03b1} (h : x \u2209 F) :\n    connectedComponentIn F x = \u2205 :=\n  dif_neg h\n#align connected_component_in_eq_empty connectedComponentIn_eq_empty\n\ntheorem mem_connectedComponent {x : \u03b1} : x \u2208 connectedComponent x :=\n  mem_union\u209b_of_mem (mem_singleton x) \u27e8isPreconnected_singleton, mem_singleton x\u27e9\n#align mem_connected_component mem_connectedComponent\n\ntheorem mem_connectedComponentIn {x : \u03b1} {F : Set \u03b1} (hx : x \u2208 F) : x \u2208 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 : \u03b1} : (connectedComponent x).Nonempty :=\n  \u27e8x, mem_connectedComponent\u27e9\n#align connected_component_nonempty connectedComponent_nonempty\n\ntheorem connectedComponentIn_nonempty_iff {x : \u03b1} {F : Set \u03b1} :\n    (connectedComponentIn F x).Nonempty \u2194 x \u2208 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 \u03b1) (x : \u03b1) : connectedComponentIn F x \u2286 F := by\n  rw [connectedComponentIn]\n  split_ifs <;> simp\n#align connected_component_in_subset connectedComponentIn_subset\n\ntheorem isPreconnected_connectedComponent {x : \u03b1} : IsPreconnected (connectedComponent x) :=\n  isPreconnected_union\u209b x _ (fun _ => And.right) fun _ => And.left\n#align is_preconnected_connected_component isPreconnected_connectedComponent\n\ntheorem isPreconnected_connectedComponentIn {x : \u03b1} {F : Set \u03b1} :\n    IsPreconnected (connectedComponentIn F x) := by\n  rw [connectedComponentIn]; split_ifs\n  \u00b7 exact inducing_subtype_val.isPreconnected_image.mpr isPreconnected_connectedComponent\n  \u00b7 exact isPreconnected_empty\n#align is_preconnected_connected_component_in isPreconnected_connectedComponentIn\n\ntheorem isConnected_connectedComponent {x : \u03b1} : IsConnected (connectedComponent x) :=\n  \u27e8\u27e8x, mem_connectedComponent\u27e9, isPreconnected_connectedComponent\u27e9\n#align is_connected_connected_component isConnected_connectedComponent\n\ntheorem isConnected_connectedComponentIn_iff {x : \u03b1} {F : Set \u03b1} :\n    IsConnected (connectedComponentIn F x) \u2194 x \u2208 F := by\n  simp_rw [\u2190 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 : \u03b1} {s : Set \u03b1} (H1 : IsPreconnected s)\n    (H2 : x \u2208 s) : s \u2286 connectedComponent x := fun _z hz => mem_union\u209b_of_mem hz \u27e8H1, H2\u27e9\n#align is_preconnected.subset_connected_component IsPreconnected.subset_connectedComponent\n\ntheorem IsPreconnected.subset_connectedComponentIn {x : \u03b1} {F : Set \u03b1} (hs : IsPreconnected s)\n    (hxs : x \u2208 s) (hsF : s \u2286 F) : s \u2286 connectedComponentIn F x := by\n  have : IsPreconnected (((\u2191) : F \u2192 \u03b1) \u207b\u00b9' 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 : (\u27e8x, hsF hxs\u27e9 : F) \u2208 (\u2191) \u207b\u00b9' 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 : \u03b1} {s : Set \u03b1} (H1 : IsConnected s)\n    (H2 : x \u2208 s) : s \u2286 connectedComponent x :=\n  H1.2.subset_connectedComponent H2\n#align is_connected.subset_connected_component IsConnected.subset_connectedComponent\n\ntheorem IsPreconnected.connectedComponentIn {x : \u03b1} {F : Set \u03b1} (h : IsPreconnected F)\n    (hx : x \u2208 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 : \u03b1} (h : y \u2208 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 : \u03b1} :\n    connectedComponent x = connectedComponent y \u2194 x \u2208 connectedComponent y :=\n  \u27e8fun h => h \u25b8 mem_connectedComponent, fun h => (connectedComponent_eq h).symm\u27e9\n#align connected_component_eq_iff_mem connectedComponent_eq_iff_mem\n\ntheorem connectedComponentIn_eq {x y : \u03b1} {F : Set \u03b1} (h : y \u2208 connectedComponentIn F x) :\n    connectedComponentIn F x = connectedComponentIn F y := by\n  have hx : x \u2208 F := connectedComponentIn_nonempty_iff.mp \u27e8y, h\u27e9\n  simp_rw [connectedComponentIn_eq_image hx] at h\u22a2\n  obtain \u27e8\u27e8y, hy\u27e9, h2y, rfl\u27e9 := 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 : \u03b1) : 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 : \u03b1} (h : connectedComponent x \u2260 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 : \u03b1} : 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 \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (h : Continuous f) (a : \u03b1) : f '' connectedComponent a \u2286 connectedComponent (f a) :=\n  (isConnected_connectedComponent.image f h.continuousOn).subset_connectedComponent\n    ((mem_image f (connectedComponent a) (f a)).2 \u27e8a, mem_connectedComponent, rfl\u27e9)\n#align continuous.image_connected_component_subset Continuous.image_connectedComponent_subset\n\ntheorem Continuous.mapsTo_connectedComponent [TopologicalSpace \u03b2] {f : \u03b1 \u2192 \u03b2} (h : Continuous f)\n    (a : \u03b1) : 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 : \u03b1} :\n    irreducibleComponent x \u2286 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 : \u03b1) {F G : Set \u03b1} (h : F \u2286 G) :\n    connectedComponentIn F x \u2286 connectedComponentIn G x := by\n  by_cases hx : x \u2208 F\n  \u00b7 rw [connectedComponentIn_eq_image hx, connectedComponentIn_eq_image (h hx), \u2190\n      show ((\u2191) : G \u2192 \u03b1) \u2218 inclusion h = (\u2191) from rfl, image_comp]\n    exact image_subset _ ((continuous_inclusion h).image_connectedComponent_subset \u27e8x, hx\u27e9)\n  \u00b7 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 (\u03b1 : Type u) [TopologicalSpace \u03b1] : Prop where\n  /-- The universal set `Set.univ` in a preconnected space is a preconnected set. -/\n  isPreconnected_univ : IsPreconnected (univ : Set \u03b1)\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 (\u03b1 : Type u) [TopologicalSpace \u03b1] extends PreconnectedSpace \u03b1 : Prop where\n  /-- A connected space is nonempty. -/\n  toNonempty : Nonempty \u03b1\n#align connected_space ConnectedSpace\n\nattribute [instance] ConnectedSpace.toNonempty\n\n-- see Note [lower instance priority]\ntheorem isConnected_univ [ConnectedSpace \u03b1] : IsConnected (univ : Set \u03b1) :=\n  \u27e8univ_nonempty, isPreconnected_univ\u27e9\n#align is_connected_univ isConnected_univ\n\ntheorem isPreconnected_range [TopologicalSpace \u03b2] [PreconnectedSpace \u03b1] {f : \u03b1 \u2192 \u03b2}\n    (h : Continuous f) : IsPreconnected (range f) :=\n  @image_univ _ _ f \u25b8 isPreconnected_univ.image _ h.continuousOn\n#align is_preconnected_range isPreconnected_range\n\ntheorem isConnected_range [TopologicalSpace \u03b2] [ConnectedSpace \u03b1] {f : \u03b1 \u2192 \u03b2} (h : Continuous f) :\n    IsConnected (range f) :=\n  \u27e8range_nonempty f, isPreconnected_range h\u27e9\n#align is_connected_range isConnected_range\n\ntheorem DenseRange.preconnectedSpace [TopologicalSpace \u03b2] [PreconnectedSpace \u03b1] {f : \u03b1 \u2192 \u03b2}\n    (hf : DenseRange f) (hc : Continuous f) : PreconnectedSpace \u03b2 :=\n  \u27e8hf.closure_eq \u25b8 (isPreconnected_range hc).closure\u27e9\n#align dense_range.preconnected_space DenseRange.preconnectedSpace\n\ntheorem connectedSpace_iff_connectedComponent :\n    ConnectedSpace \u03b1 \u2194 \u2203 x : \u03b1, connectedComponent x = univ := by\n  constructor\n  \u00b7 rintro \u27e8\u27e8x\u27e9\u27e9\n    exact\n      \u27e8x, eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x)\u27e9\n  \u00b7 rintro \u27e8x, h\u27e9\n    haveI : PreconnectedSpace \u03b1 :=\n      \u27e8by rw [\u2190 h]; exact isPreconnected_connectedComponent\u27e9\n    exact \u27e8\u27e8x\u27e9\u27e9\n#align connected_space_iff_connected_component connectedSpace_iff_connectedComponent\n\ntheorem preconnectedSpace_iff_connectedComponent :\n    PreconnectedSpace \u03b1 \u2194 \u2200 x : \u03b1, connectedComponent x = univ := by\n  constructor\n  \u00b7 intro h x\n    exact eq_univ_of_univ_subset <| isPreconnected_univ.subset_connectedComponent (mem_univ x)\n  \u00b7 intro h\n    cases' isEmpty_or_nonempty \u03b1 with h\u03b1 h\u03b1\n    \u00b7 exact \u27e8by rw [univ_eq_empty_iff.mpr h\u03b1]; exact isPreconnected_empty\u27e9\n    \u00b7 exact \u27e8by rw [\u2190 h (Classical.choice h\u03b1)]; exact isPreconnected_connectedComponent\u27e9\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 \u03b2] [PreconnectedSpace \u03b1] [PreconnectedSpace \u03b2] :\n    PreconnectedSpace (\u03b1 \u00d7 \u03b2) :=\n  \u27e8by\n    rw [\u2190 univ_prod_univ]\n    exact isPreconnected_univ.prod isPreconnected_univ\u27e9\n\ninstance [TopologicalSpace \u03b2] [ConnectedSpace \u03b1] [ConnectedSpace \u03b2] : ConnectedSpace (\u03b1 \u00d7 \u03b2) :=\n  \u27e8inferInstance\u27e9\n\ninstance [\u2200 i, TopologicalSpace (\u03c0 i)] [\u2200 i, PreconnectedSpace (\u03c0 i)] :\n    PreconnectedSpace (\u2200 i, \u03c0 i) :=\n  \u27e8by rw [\u2190 pi_univ univ]; exact isPreconnected_univ_pi fun i => isPreconnected_univ\u27e9\n\ninstance [\u2200 i, TopologicalSpace (\u03c0 i)] [\u2200 i, ConnectedSpace (\u03c0 i)] : ConnectedSpace (\u2200 i, \u03c0 i) :=\n  \u27e8inferInstance\u27e9\n\n-- see Note [lower instance priority]\ninstance (priority := 100) PreirreducibleSpace.preconnectedSpace (\u03b1 : Type u) [TopologicalSpace \u03b1]\n    [PreirreducibleSpace \u03b1] : PreconnectedSpace \u03b1 :=\n  \u27e8isPreirreducible_univ.isPreconnected\u27e9\n#align preirreducible_space.preconnected_space PreirreducibleSpace.preconnectedSpace\n\n-- see Note [lower instance priority]\ninstance (priority := 100) IrreducibleSpace.connectedSpace (\u03b1 : Type u) [TopologicalSpace \u03b1]\n    [IrreducibleSpace \u03b1] : ConnectedSpace \u03b1 where toNonempty := IrreducibleSpace.toNonempty\n#align irreducible_space.connected_space IrreducibleSpace.connectedSpace\n\ntheorem nonempty_inter [PreconnectedSpace \u03b1] {s t : Set \u03b1} :\n    IsOpen s \u2192 IsOpen t \u2192 s \u222a t = univ \u2192 s.Nonempty \u2192 t.Nonempty \u2192 (s \u2229 t).Nonempty := by\n  simpa only [univ_inter, univ_subset_iff] using @PreconnectedSpace.isPreconnected_univ \u03b1 _ _ s t\n#align nonempty_inter nonempty_inter\n\ntheorem isClopen_iff [PreconnectedSpace \u03b1] {s : Set \u03b1} : IsClopen s \u2194 s = \u2205 \u2228 s = univ :=\n  \u27e8fun hs =>\n    by_contradiction fun h =>\n      have h1 : s \u2260 \u2205 \u2227 s\u1d9c \u2260 \u2205 :=\n        \u27e8mt Or.inl h,\n          mt (fun h2 => Or.inr <| (by rw [\u2190 compl_compl s, h2, compl_empty] : s = univ)) h\u27e9\n      let \u27e8_, h2, h3\u27e9 :=\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]\u27e9\n#align is_clopen_iff isClopen_iff\n\ntheorem IsClopen.eq_univ [PreconnectedSpace \u03b1] {s : Set \u03b1} (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 \u03b1] {s : Set \u03b1} :\n    frontier s = \u2205 \u2194 s = \u2205 \u2228 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 \u03b1] {s : Set \u03b1} :\n    (frontier s).Nonempty \u2194 s.Nonempty \u2227 s \u2260 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 \u03b1} (h : IsPreconnected s) : PreconnectedSpace s where\n  isPreconnected_univ := by\n    rwa [\u2190 inducing_subtype_val.isPreconnected_image, image_univ, Subtype.range_val]\n#align subtype.preconnected_space Subtype.preconnectedSpace\n\ntheorem Subtype.connectedSpace {s : Set \u03b1} (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 \u03b1} : IsPreconnected s \u2194 PreconnectedSpace s :=\n  \u27e8Subtype.preconnectedSpace, fun h => by\n    simpa using isPreconnected_univ.image ((\u2191) : s \u2192 \u03b1) continuous_subtype_val.continuousOn\u27e9\n#align is_preconnected_iff_preconnected_space isPreconnected_iff_preconnectedSpace\n\ntheorem isConnected_iff_connectedSpace {s : Set \u03b1} : IsConnected s \u2194 ConnectedSpace s :=\n  \u27e8Subtype.connectedSpace, fun h =>\n    \u27e8nonempty_subtype.mp h.2, isPreconnected_iff_preconnectedSpace.mpr h.1\u27e9\u27e9\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 \u03b1} :\n    IsPreconnected s \u2194\n      \u2200 u v, IsOpen u \u2192 IsOpen v \u2192 s \u2286 u \u222a v \u2192 s \u2229 (u \u2229 v) = \u2205 \u2192 s \u2286 u \u2228 s \u2286 v := by\n  constructor <;> intro h\n  \u00b7 intro u v hu hv hs huv\n    specialize h u v hu hv hs\n    contrapose! huv\n    rw [\u2190 nonempty_iff_ne_empty]\n    simp [not_subset] at huv\n    rcases huv with \u27e8\u27e8x, hxs, hxu\u27e9, \u27e8y, hys, hyv\u27e9\u27e9\n    have hxv : x \u2208 v := or_iff_not_imp_left.mp (hs hxs) hxu\n    have hyu : y \u2208 u := or_iff_not_imp_right.mp (hs hys) hyv\n    exact h \u27e8y, hys, hyu\u27e9 \u27e8x, hxs, hxv\u27e9\n  \u00b7 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    \u00b7 rcases hsv with \u27e8x, hxs, hxv\u27e9\n      exact \u27e8x, hxs, \u27e8h hxs, hxv\u27e9\u27e9\n    \u00b7 rcases hsu with \u27e8x, hxs, hxu\u27e9\n      exact \u27e8x, hxs, \u27e8hxu, h hxs\u27e9\u27e9\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\u209b_disjoint_open {s : Set \u03b1} :\n    IsConnected s \u2194\n      \u2200 U : Finset (Set \u03b1), (\u2200 u v : Set \u03b1, u \u2208 U \u2192 v \u2208 U \u2192 (s \u2229 (u \u2229 v)).Nonempty \u2192 u = v) \u2192\n        (\u2200 u \u2208 U, IsOpen u) \u2192 (s \u2286 \u22c3\u2080 \u2191U) \u2192 \u2203 u \u2208 U, s \u2286 u := by\n  rw [IsConnected, isPreconnected_iff_subset_of_disjoint]\n  refine \u27e8fun \u27e8hne, h\u27e9 U hU hUo hsU => ?_, fun h => \u27e8?_, fun u v hu hv hs hsuv => ?_\u27e9\u27e9\n  \u00b7 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 [\u2190 ball_cond_comm, Finset.forall_mem_insert, Finset.exists_mem_insert,\n        Finset.coe_insert, union\u209b_insert, implies_true, true_and] at *\n      refine (h _ hUo.1 (\u22c3\u2080 \u2191U) (isOpen_union\u209b hUo.2) hsU ?_).imp_right ?_\n      \u00b7 refine subset_empty_iff.1 fun x \u27e8hxs, hxu, v, hvU, hxv\u27e9 => ?_\n        exact ne_of_mem_of_not_mem hvU uU (hU.1 v hvU \u27e8x, hxs, hxu, hxv\u27e9).symm\n      \u00b7 exact IH (fun u hu => (hU.2 u hu).2) hUo.2\n  \u00b7 simpa [subset_empty_iff, nonempty_iff_ne_empty] using h \u2205\n  \u00b7 rw [\u2190 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\u209b_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 \u03b1} (hs : IsPreconnected s) (ht : IsClopen t) :\n    Disjoint s t \u2228 s \u2286 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 \u2194\n      \u2200 u v, IsClosed u \u2192 IsClosed v \u2192 s \u2286 u \u222a v \u2192 s \u2229 (u \u2229 v) = \u2205 \u2192 s \u2286 u \u2228 s \u2286 v := by\n  constructor <;> intro h\n  \u00b7 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 [\u2190 nonempty_iff_ne_empty]\n    simp [not_subset] at huv\n    rcases huv with \u27e8\u27e8x, hxs, hxu\u27e9, \u27e8y, hys, hyv\u27e9\u27e9\n    have hxv : x \u2208 v := or_iff_not_imp_left.mp (hs hxs) hxu\n    have hyu : y \u2208 u := or_iff_not_imp_right.mp (hs hys) hyv\n    exact h \u27e8y, hys, hyu\u27e9 \u27e8x, hxs, hxv\u27e9\n  \u00b7 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    \u00b7 rcases hsv with \u27e8x, hxs, hxv\u27e9\n      exact \u27e8x, hxs, \u27e8h hxs, hxv\u27e9\u27e9\n    \u00b7 rcases hsu with \u27e8x, hxs, hxu\u27e9\n      exact \u27e8x, hxs, \u27e8hxu, h hxs\u27e9\u27e9\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 \u03b1} (hs : IsClosed s) :\n    IsPreconnected s \u2194\n      \u2200 u v, IsClosed u \u2192 IsClosed v \u2192 s \u2286 u \u222a v \u2192 Disjoint u v \u2192 s \u2286 u \u2228 s \u2286 v := by\n  refine isPreconnected_iff_subset_of_disjoint_closed.trans \u27e8?_, ?_\u27e9 <;> intro H u v hu hv hss huv\n  \u00b7 apply H u v hu hv hss\n    rw [huv.inter_eq, inter_empty]\n  have H1 := H (u \u2229 s) (v \u2229 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  \u00b7 rw [\u2190 inter_distrib_right]\n    exact subset_inter hss Subset.rfl\n  \u00b7 rwa [disjoint_iff_inter_eq_empty, \u2190 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 \u2208 s) :\n    connectedComponent x \u2286 s :=\n  isPreconnected_connectedComponent.subset_clopen hs \u27e8x, mem_connectedComponent, hx\u27e9\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\u1d62_clopen {x : \u03b1} :\n    connectedComponent x \u2286 \u22c2 Z : { Z : Set \u03b1 // IsClopen Z \u2227 x \u2208 Z }, Z :=\n  subset_inter\u1d62 fun Z => Z.2.1.connectedComponent_subset Z.2.2\n#align connected_component_subset_Inter_clopen connectedComponent_subset_inter\u1d62_clopen\n\n/-- A clopen set is the union of its connected components. -/\ntheorem IsClopen.bunion\u1d62_connectedComponent_eq {Z : Set \u03b1} (h : IsClopen Z) :\n    (\u22c3 x \u2208 Z, connectedComponent x) = Z :=\n  Subset.antisymm (union\u1d62\u2082_subset fun _ => h.connectedComponent_subset) fun _ h =>\n    mem_union\u1d62\u2082_of_mem h mem_connectedComponent\n#align is_clopen.bUnion_connected_component_eq IsClopen.bunion\u1d62_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 \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (connected_fibers : \u2200 t : \u03b2, IsConnected (f \u207b\u00b9' {t}))\n    (hcl : \u2200 T : Set \u03b2, IsClosed T \u2194 IsClosed (f \u207b\u00b9' T)) (t : \u03b2) :\n    IsConnected (f \u207b\u00b9' 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 : \u03b2 => (connected_fibers t).1\n  refine \u27e8Nonempty.preimage connectedComponent_nonempty hf, ?_\u27e9\n  have hT : IsClosed (f \u207b\u00b9' connectedComponent t) :=\n    (hcl (connectedComponent t)).1 isClosed_connectedComponent\n  -- To show it's preconnected we decompose (f \u207b\u00b9' connectedComponent t) as a subset of two\n  -- closed disjoint sets in \u03b1. 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\u2081 and T\u2082\n  -- we will show that connectedComponent t is a subset of either and hence\n  -- (f \u207b\u00b9' connectedComponent t) is a subset of u or v\n  let T\u2081 := { t' \u2208 connectedComponent t | f \u207b\u00b9' {t'} \u2286 u }\n  let T\u2082 := { t' \u2208 connectedComponent t | f \u207b\u00b9' {t'} \u2286 v }\n  have fiber_decomp : \u2200 t' \u2208 connectedComponent t, f \u207b\u00b9' {t'} \u2286 u \u2228 f \u207b\u00b9' {t'} \u2286 v := by\n    intro t' ht'\n    apply isPreconnected_iff_subset_of_disjoint_closed.1 (connected_fibers t').2 u v hu hv\n    \u00b7 exact Subset.trans (preimage_mono (singleton_subset_iff.2 ht')) huv\n    rw [uv_disj.inter_eq, inter_empty]\n  have T\u2081_u : f \u207b\u00b9' T\u2081 = f \u207b\u00b9' connectedComponent t \u2229 u := by\n    apply eq_of_subset_of_subset\n    \u00b7 rw [\u2190 bunion\u1d62_preimage_singleton]\n      refine' union\u1d62\u2082_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 \u27e8hat, hau\u27e9\n    constructor\n    \u00b7 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\u2082_v : f \u207b\u00b9' T\u2082 = f \u207b\u00b9' connectedComponent t \u2229 v :=\n    by\n    apply eq_of_subset_of_subset\n    \u00b7 rw [\u2190 bunion\u1d62_preimage_singleton]\n      refine' union\u1d62\u2082_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 \u27e8hat, hav\u27e9\n    constructor\n    \u00b7 exact mem_preimage.1 hat\n    \u00b7 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\u2081, T\u2082 are closed, cover connectedComponent t and are disjoint.\n  have hT\u2081 : IsClosed T\u2081 := (hcl T\u2081).2 (T\u2081_u.symm \u25b8 IsClosed.inter hT hu)\n  have hT\u2082 : IsClosed T\u2082 := (hcl T\u2082).2 (T\u2082_v.symm \u25b8 IsClosed.inter hT hv)\n  have T_decomp : connectedComponent t \u2286 T\u2081 \u222a T\u2082 := fun t' ht' => by\n    rw [mem_union t' T\u2081 T\u2082]\n    cases' fiber_decomp t' ht' with htu htv\n    \u00b7 left\n      exact \u27e8ht', htu\u27e9\n    right\n    exact \u27e8ht', htv\u27e9\n  have T_disjoint : Disjoint T\u2081 T\u2082 := by\n    refine' Disjoint.of_preimage hf _\n    rw [T\u2081_u, T\u2082_v, disjoint_iff_inter_eq_empty, \u2190 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\u2081 or T\u2082 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\u2081 T\u2082 hT\u2081 hT\u2082 T_decomp T_disjoint with h h\n  \u00b7 left\n    rw [Subset.antisymm_iff] at T\u2081_u\n    suffices f \u207b\u00b9' connectedComponent t \u2286 f \u207b\u00b9' T\u2081\n      from (this.trans T\u2081_u.1).trans (inter_subset_right _ _)\n    exact preimage_mono h\n  \u00b7 right\n    rw [Subset.antisymm_iff] at T\u2082_v\n    suffices f \u207b\u00b9' connectedComponent t \u2286 f \u207b\u00b9' T\u2082\n      from (this.trans T\u2082_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 \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (hf : QuotientMap f) (h_fibers : \u2200 y : \u03b2, IsConnected (f \u207b\u00b9' {y})) (a : \u03b1) :\n    f \u207b\u00b9' 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 \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : QuotientMap f)\n    (h_fibers : \u2200 y : \u03b2, IsConnected (f \u207b\u00b9' {y})) (a : \u03b1) :\n    f '' connectedComponent a = connectedComponent (f a) := by\n  rw [\u2190 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 (\u03b1 : Type _) [TopologicalSpace \u03b1] : Prop where\n  /-- Open connected neighborhoods form a basis of the neighborhoods filter. -/\n  open_connected_basis : \u2200 x, (\ud835\udcdd x).HasBasis (fun s : Set \u03b1 => IsOpen s \u2227 x \u2208 s \u2227 IsConnected s) id\n#align locally_connected_space LocallyConnectedSpace\n\ntheorem locallyConnectedSpace_iff_open_connected_basis :\n    LocallyConnectedSpace \u03b1 \u2194\n      \u2200 x, (\ud835\udcdd x).HasBasis (fun s : Set \u03b1 => IsOpen s \u2227 x \u2208 s \u2227 IsConnected s) id :=\n  \u27e8@LocallyConnectedSpace.open_connected_basis _ _, LocallyConnectedSpace.mk\u27e9\n#align locally_connected_space_iff_open_connected_basis locallyConnectedSpace_iff_open_connected_basis\n\ntheorem locallyConnectedSpace_iff_open_connected_subsets :\n    LocallyConnectedSpace \u03b1 \u2194\n      \u2200 x, \u2200 U \u2208 \ud835\udcdd x, \u2203 V : Set \u03b1, V \u2286 U \u2227 IsOpen V \u2227 x \u2208 V \u2227 IsConnected V := by\n  simp_rw [locallyConnectedSpace_iff_open_connected_basis]\n  refine forall_congr' fun _ => ?_\n  constructor\n  \u00b7 intro h U hU\n    rcases h.mem_iff.mp hU with \u27e8V, hV, hVU\u27e9\n    exact \u27e8V, hVU, hV\u27e9\n  \u00b7 exact fun h => \u27e8fun U => \u27e8fun hU =>\n      let \u27e8V, hVU, hV\u27e9 := h U hU\n      \u27e8V, hV, hVU\u27e9, fun \u27e8V, \u27e8hV, hxV, _\u27e9, hVU\u27e9 => mem_nhds_iff.mpr \u27e8V, hVU, hV, hxV\u27e9\u27e9\u27e9\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 (\u03b1) [TopologicalSpace \u03b1]\n    [DiscreteTopology \u03b1] : LocallyConnectedSpace \u03b1 :=\n  locallyConnectedSpace_iff_open_connected_subsets.2 fun x _U hU =>\n    \u27e8{x}, singleton_subset_iff.2 <| mem_of_mem_nhds hU, isOpen_discrete _, rfl,\n      isConnected_singleton\u27e9\n#align discrete_topology.to_locally_connected_space DiscreteTopology.toLocallyConnectedSpace\n\ntheorem connectedComponentIn_mem_nhds [LocallyConnectedSpace \u03b1] {F : Set \u03b1} {x : \u03b1} (h : F \u2208 \ud835\udcdd x) :\n    connectedComponentIn F x \u2208 \ud835\udcdd x := by\n  rw [(LocallyConnectedSpace.open_connected_basis x).mem_iff] at h\n  rcases h with \u27e8s, \u27e8h1s, hxs, h2s\u27e9, hsF\u27e9\n  exact mem_nhds_iff.mpr \u27e8s, h2s.isPreconnected.subset_connectedComponentIn hxs hsF, h1s, hxs\u27e9\n#align connected_component_in_mem_nhds connectedComponentIn_mem_nhds\n\nprotected theorem IsOpen.connectedComponentIn [LocallyConnectedSpace \u03b1] {F : Set \u03b1} {x : \u03b1}\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 \u03b1] {x : \u03b1} :\n    IsOpen (connectedComponent x) := by\n  rw [\u2190 connectedComponentIn_univ]\n  exact isOpen_univ.connectedComponentIn\n#align is_open_connected_component isOpen_connectedComponent\n\ntheorem isClopen_connectedComponent [LocallyConnectedSpace \u03b1] {x : \u03b1} :\n    IsClopen (connectedComponent x) :=\n  \u27e8isOpen_connectedComponent, isClosed_connectedComponent\u27e9\n#align is_clopen_connected_component isClopen_connectedComponent\n\ntheorem locallyConnectedSpace_iff_connectedComponentIn_open :\n    LocallyConnectedSpace \u03b1 \u2194\n      \u2200 F : Set \u03b1, IsOpen F \u2192 \u2200 x \u2208 F, IsOpen (connectedComponentIn F x) := by\n  constructor\n  \u00b7 intro h\n    exact fun F hF x _ => hF.connectedComponentIn\n  \u00b7 intro h\n    rw [locallyConnectedSpace_iff_open_connected_subsets]\n    refine' fun x U hU =>\n        \u27e8connectedComponentIn (interior U) x,\n          (connectedComponentIn_subset _ _).trans interior_subset, h _ isOpen_interior x _,\n          mem_connectedComponentIn _, isConnected_connectedComponentIn_iff.mpr _\u27e9 <;>\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 \u03b1 \u2194 \u2200 (x : \u03b1), \u2200 U \u2208 \ud835\udcdd x, \u2203 V \u2208 \ud835\udcdd x, IsPreconnected V \u2227 V \u2286 U := by\n  constructor\n  \u00b7 rw [locallyConnectedSpace_iff_open_connected_subsets]\n    intro h x U hxU\n    rcases h x U hxU with \u27e8V, hVU, hV\u2081, hxV, hV\u2082\u27e9\n    exact \u27e8V, hV\u2081.mem_nhds hxV, hV\u2082.isPreconnected, hVU\u27e9\n  \u00b7 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 \u27e8V, hVy, hV, hVU\u27e9\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 \u03b1 \u2194\n      \u2200 x, (\ud835\udcdd x).HasBasis (fun s : Set \u03b1 => s \u2208 \ud835\udcdd x \u2227 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 {\u03b9 : Type _} (b : \u03b1 \u2192 \u03b9 \u2192 Set \u03b1) (p : \u03b1 \u2192 \u03b9 \u2192 Prop)\n    (hbasis : \u2200 x, (\ud835\udcdd x).HasBasis (p x) (b x))\n    (hconnected : \u2200 x i, p x i \u2192 IsPreconnected (b x i)) : LocallyConnectedSpace \u03b1 := by\n  rw [locallyConnectedSpace_iff_connected_basis]\n  exact fun x =>\n    (hbasis x).to_hasBasis\n      (fun i hi => \u27e8b x i, \u27e8(hbasis x).mem_of_mem hi, hconnected x i hi\u27e9, subset_rfl\u27e9) fun s hs =>\n      \u27e8(hbasis x).index s hs.1, \u27e8(hbasis x).property_index hs.1, (hbasis x).set_index_subset hs.1\u27e9\u27e9\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 \u2286 s` which is preconnected is\na subsingleton, ie either empty or a singleton.-/\ndef IsTotallyDisconnected (s : Set \u03b1) : Prop :=\n  \u2200 t, t \u2286 s \u2192 IsPreconnected t \u2192 t.Subsingleton\n#align is_totally_disconnected IsTotallyDisconnected\n\ntheorem isTotallyDisconnected_empty : IsTotallyDisconnected (\u2205 : Set \u03b1) := 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 \u03b1) := 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 (\u03b1 : Type u) [TopologicalSpace \u03b1] : Prop where\n  /-- The universal set `Set.univ` in a totally disconnected space is totally disconnected. -/\n  isTotallyDisconnected_univ : IsTotallyDisconnected (univ : Set \u03b1)\n#align totally_disconnected_space TotallyDisconnectedSpace\n\ntheorem IsPreconnected.subsingleton [TotallyDisconnectedSpace \u03b1] {s : Set \u03b1}\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 {\u03b1 : Type _} {\u03b2 : \u03b1 \u2192 Type _}\n    [\u2200 a, TopologicalSpace (\u03b2 a)] [\u2200 a, TotallyDisconnectedSpace (\u03b2 a)] :\n    TotallyDisconnectedSpace (\u2200 a : \u03b1, \u03b2 a) :=\n  \u27e8fun t _ h2 =>\n    have this : \u2200 a, IsPreconnected ((fun x : \u2200 a, \u03b2 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 \u27e8x, x_in, rfl\u27e9 \u27e8y, y_in, rfl\u27e9\u27e9\n#align pi.totally_disconnected_space Pi.totallyDisconnectedSpace\n\ninstance Prod.totallyDisconnectedSpace [TopologicalSpace \u03b2] [TotallyDisconnectedSpace \u03b1]\n    [TotallyDisconnectedSpace \u03b2] : TotallyDisconnectedSpace (\u03b1 \u00d7 \u03b2) :=\n  \u27e8fun 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 \u27e8x, hx, rfl\u27e9 \u27e8y, hy, rfl\u27e9)\n      (H2.subsingleton \u27e8x, hx, rfl\u27e9 \u27e8y, hy, rfl\u27e9)\u27e9\n#align prod.totally_disconnected_space Prod.totallyDisconnectedSpace\n\ninstance [TopologicalSpace \u03b2] [TotallyDisconnectedSpace \u03b1] [TotallyDisconnectedSpace \u03b2] :\n    TotallyDisconnectedSpace (Sum \u03b1 \u03b2) := by\n  refine' \u27e8fun s _ hs => _\u27e9\n  obtain \u27e8t, ht, rfl\u27e9 | \u27e8t, ht, rfl\u27e9 := Sum.isPreconnected_iff.1 hs\n  \u00b7 exact ht.subsingleton.image _\n  \u00b7 exact ht.subsingleton.image _\n\ninstance [\u2200 i, TopologicalSpace (\u03c0 i)] [\u2200 i, TotallyDisconnectedSpace (\u03c0 i)] :\n    TotallyDisconnectedSpace (\u03a3i, \u03c0 i) := by\n  refine' \u27e8fun s _ hs => _\u27e9\n  obtain rfl | h := s.eq_empty_or_nonempty\n  \u00b7 exact subsingleton_empty\n  \u00b7 obtain \u27e8a, t, ht, rfl\u27e9 := Sigma.isConnected_iff.1 \u27e8h, hs\u27e9\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 \u2208 X`, there\n  is some clopen set `U` such that `x \u2208 U` and `y \u2209 U`. Then `X` is totally disconnected. -/\ntheorem isTotallyDisconnected_of_clopen_set {X : Type _} [TopologicalSpace X]\n    (hX : Pairwise fun x y => \u2203 (U : Set X), IsClopen U \u2227 x \u2208 U \u2227 y \u2209 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 \u27e8x, hx, y, hy, hxy\u27e9\n  obtain \u27e8U, h_clopen, hxU, hyU\u27e9 := hX hxy\n  specialize\n    hS U (U\u1d9c) h_clopen.1 h_clopen.compl.1 (fun a _ => em (a \u2208 U)) \u27e8x, hx, hxU\u27e9 \u27e8y, hy, hyU\u27e9\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 \u03b1 \u2194 \u2200 x : \u03b1, (connectedComponent x).Subsingleton := by\n  constructor\n  \u00b7 intro h x\n    apply h.1\n    \u00b7 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 | \u27e8x, x_in\u27e9)\n  \u00b7 exact subsingleton_empty\n  \u00b7 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 \u03b1 \u2194 \u2200 x : \u03b1, 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 \u03b1] (x : \u03b1) :\n    connectedComponent x = {x} :=\n  totallyDisconnectedSpace_iff_connectedComponent_singleton.1 \u2039_\u203a 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 {\u03b2 : Type _} [TopologicalSpace \u03b2]\n    [TotallyDisconnectedSpace \u03b2] {f : \u03b1 \u2192 \u03b2} (h : Continuous f) (a : \u03b1) :\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 \u03b1] (s : Set \u03b1) :\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 \u03b2] {f : \u03b1 \u2192 \u03b2} (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 \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : Embedding f)\n    {s : Set \u03b1} (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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} [TopologicalSpace \u03b1]\n    [TotallyDisconnectedSpace \u03b1] : TotallyDisconnectedSpace (Subtype p) :=\n  \u27e8embedding_subtype_val.isTotallyDisconnected\n      (isTotallyDisconnected_of_totallyDisconnectedSpace _)\u27e9\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 \u03b1) : Prop :=\n  \u2200 x \u2208 s, \u2200 y \u2208 s, x \u2260 y \u2192\n    \u2203 u v : Set \u03b1, IsOpen u \u2227 IsOpen v \u2227 x \u2208 u \u2227 y \u2208 v \u2227 s \u2286 u \u222a v \u2227 Disjoint u v\n#align is_totally_separated IsTotallySeparated\n\ntheorem isTotallySeparated_empty : IsTotallySeparated (\u2205 : Set \u03b1) := fun _ => False.elim\n#align is_totally_separated_empty isTotallySeparated_empty\n\ntheorem isTotallySeparated_singleton {x} : IsTotallySeparated ({x} : Set \u03b1) := fun _ hp _ hq hpq =>\n  (hpq <| (eq_of_mem_singleton hp).symm \u25b8 (eq_of_mem_singleton hq).symm).elim\n#align is_totally_separated_singleton isTotallySeparated_singleton\n\ntheorem isTotallyDisconnected_of_isTotallySeparated {s : Set \u03b1} (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    \u27e8u : Set \u03b1, v : Set \u03b1, hu : IsOpen u, hv : IsOpen v, hxu : x \u2208 u, hyv : y \u2208 v, hs : s \u2286 u \u222a v,\n      huv\u27e9 :=\n    H x (hts x_in) y (hts y_in) h\n  refine' (ht _ _ hu hv (hts.trans hs) \u27e8x, x_in, hxu\u27e9 \u27e8y, y_in, hyv\u27e9).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 \u2190 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 (\u03b1 : Type u) [TopologicalSpace \u03b1] : Prop where\n  /-- The universal set `Set.univ` in a totally separated space is totally separated. -/\n  isTotallySeparated_univ : IsTotallySeparated (univ : Set \u03b1)\n#align totally_separated_space TotallySeparatedSpace\n\n-- see Note [lower instance priority]\ninstance (priority := 100) TotallySeparatedSpace.totallyDisconnectedSpace (\u03b1 : Type u)\n    [TopologicalSpace \u03b1] [TotallySeparatedSpace \u03b1] : TotallyDisconnectedSpace \u03b1 :=\n  \u27e8TotallySeparatedSpace.isTotallySeparated_univ.isTotallyDisconnected\u27e9\n#align totally_separated_space.totally_disconnected_space TotallySeparatedSpace.totallyDisconnectedSpace\n\n-- see Note [lower instance priority]\ninstance (priority := 100) TotallySeparatedSpace.of_discrete (\u03b1 : Type _) [TopologicalSpace \u03b1]\n    [DiscreteTopology \u03b1] : TotallySeparatedSpace \u03b1 :=\n  \u27e8fun _ _ b _ h => \u27e8{b}\u1d9c, {b}, isOpen_discrete _, isOpen_discrete _, h, rfl,\n    (compl_union_self _).symm.subset, disjoint_compl_left\u27e9\u27e9\n#align totally_separated_space.of_discrete TotallySeparatedSpace.of_discrete\n\ntheorem exists_clopen_of_totally_separated {\u03b1 : Type _} [TopologicalSpace \u03b1]\n    [TotallySeparatedSpace \u03b1] {x y : \u03b1} (hxy : x \u2260 y) :\n    \u2203 U : Set \u03b1, IsClopen U \u2227 x \u2208 U \u2227 y \u2208 U\u1d9c := by\n  obtain \u27e8U, V, hU, hV, Ux, Vy, f, disj\u27e9 :=\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 [\u2190 Set.subset_compl_iff_disjoint_right, subset_compl_comm] at disj\n  exact \u27e8U, clopen_U, Ux, disj Vy\u27e9\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 (\u03b1 : Type _) [TopologicalSpace \u03b1] : Setoid \u03b1 :=\n  \u27e8fun x y => connectedComponent x = connectedComponent y,\n    \u27e8fun x => by trivial, fun h1 => h1.symm, fun h1 h2 => h1.trans h2\u27e9\u27e9\n#align connected_component_setoid connectedComponentSetoid\n\n/-- The quotient of a space by its connected components -/\ndef ConnectedComponents (\u03b1 : Type u) [TopologicalSpace \u03b1] :=\n  Quotient (connectedComponentSetoid \u03b1)\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 : \u03b1 \u2192 ConnectedComponents \u03b1 := Quotient.mk''\n\ninstance : CoeTC \u03b1 (ConnectedComponents \u03b1) := \u27e8mk\u27e9\n\n@[simp]\ntheorem coe_eq_coe {x y : \u03b1} :\n    (x : ConnectedComponents \u03b1) = y \u2194 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 : \u03b1} :\n    (x : ConnectedComponents \u03b1) \u2260 y \u2194 connectedComponent x \u2260 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 : \u03b1} : (x : ConnectedComponents \u03b1) = y \u2194 x \u2208 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 \u03b1] : Inhabited (ConnectedComponents \u03b1) :=\n  \u27e8mk default\u27e9\n\ninstance : TopologicalSpace (ConnectedComponents \u03b1) :=\n  inferInstanceAs (TopologicalSpace (Quotient _))\n\ntheorem surjective_coe : Surjective (mk : \u03b1 \u2192 ConnectedComponents \u03b1) :=\n  surjective_quot_mk _\n#align connected_components.surjective_coe ConnectedComponents.surjective_coe\n\ntheorem quotientMap_coe : QuotientMap (mk : \u03b1 \u2192 ConnectedComponents \u03b1) :=\n  quotientMap_quot_mk\n#align connected_components.quotient_map_coe ConnectedComponents.quotientMap_coe\n\n@[continuity]\ntheorem continuous_coe : Continuous (mk : \u03b1 \u2192 ConnectedComponents \u03b1) :=\n  quotientMap_coe.continuous\n#align connected_components.continuous_coe ConnectedComponents.continuous_coe\n\n@[simp]\ntheorem range_coe : range (mk : \u03b1 \u2192 ConnectedComponents \u03b1) = univ :=\n  surjective_coe.range_eq\n#align connected_components.range_coe ConnectedComponents.range_coe\n\nend ConnectedComponents\n\nvariable [TopologicalSpace \u03b2] [TotallyDisconnectedSpace \u03b2] {f : \u03b1 \u2192 \u03b2}\n\ntheorem Continuous.image_eq_of_connectedComponent_eq (h : Continuous f) (a b : \u03b1)\n    (hab : connectedComponent a = connectedComponent b) : f a = f b :=\n  singleton_eq_singleton_iff.1 <|\n    h.image_connectedComponent_eq_singleton a \u25b8\n      h.image_connectedComponent_eq_singleton b \u25b8 hab \u25b8 rfl\n#align continuous.image_eq_of_connected_component_eq Continuous.image_eq_of_connectedComponent_eq\n\n/--\nThe lift to `connectedComponents \u03b1` of a continuous map from `\u03b1` to a totally disconnected space\n-/\ndef Continuous.connectedComponentsLift (h : Continuous f) : ConnectedComponents \u03b1 \u2192 \u03b2 := 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 : \u03b1) :\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 \u2218 (\u2191) = f :=\n  rfl\n#align continuous.connected_components_lift_comp_coe Continuous.connectedComponentsLift_comp_coe\n\ntheorem connectedComponents_lift_unique' {\u03b2 : Sort _} {g\u2081 g\u2082 : ConnectedComponents \u03b1 \u2192 \u03b2}\n    (hg : g\u2081 \u2218 ((\u2191) : \u03b1 \u2192 ConnectedComponents \u03b1) = g\u2082 \u2218 (\u2191)) : g\u2081 = g\u2082 :=\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 \u03b1 \u2192 \u03b2)\n    (hg : g \u2218 (\u2191) = 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 : \u03b1} :\n    (\u2191) \u207b\u00b9' ({\u2191x} : Set (ConnectedComponents \u03b1)) = 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 \u03b1`\nis the union of the connected components of the elements in it. -/\ntheorem connectedComponents_preimage_image (U : Set \u03b1) :\n    (\u2191) \u207b\u00b9' ((\u2191) '' U : Set (ConnectedComponents \u03b1)) = \u22c3 x \u2208 U, connectedComponent x := by\n  simp only [connectedComponents_preimage_singleton, preimage_union\u1d62\u2082, image_eq_union\u1d62]\n#align connected_components_preimage_image connectedComponents_preimage_image\n\ninstance ConnectedComponents.totallyDisconnectedSpace :\n    TotallyDisconnectedSpace (ConnectedComponents \u03b1) := by\n  rw [totallyDisconnectedSpace_iff_connectedComponent_singleton]\n  refine' ConnectedComponents.surjective_coe.forall.2 fun x => _\n  rw [\u2190 ConnectedComponents.quotientMap_coe.image_connectedComponent, \u2190\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 {\u03b2 : Type _} [TopologicalSpace \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (h : Continuous f) : ConnectedComponents \u03b1 \u2192 ConnectedComponents \u03b2 :=\n  Continuous.connectedComponentsLift (ConnectedComponents.continuous_coe.comp h)\n#align continuous.connected_components_map Continuous.connectedComponentsMap\n\ntheorem Continuous.connectedComponentsMap_continuous {\u03b2 : Type _} [TopologicalSpace \u03b2] {f : \u03b1 \u2192 \u03b2}\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 \u03b1}\n    (hs : IsPreconnected s) {f : \u03b1 \u2192 Y} (hf : ContinuousOn f s) {x y : \u03b1} (hx : x \u2208 s)\n    (hy : y \u2208 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 \u03b1}\n    (hs : \u2200 f : \u03b1 \u2192 Bool, ContinuousOn f s \u2192 \u2200 x \u2208 s, \u2200 y \u2208 s, f x = f y) : IsPreconnected s := by\n  unfold IsPreconnected\n  by_contra'\n  rcases this with \u27e8u, v, u_op, v_op, hsuv, \u27e8x, x_in_s, x_in_u\u27e9, \u27e8y, y_in_s, y_in_v\u27e9, H\u27e9\n  rw [not_nonempty_iff_eq_empty] at H\n  have hy : y \u2209 u := fun y_in_u => eq_empty_iff_forall_not_mem.mp H y \u27e8y_in_s, \u27e8y_in_u, y_in_v\u27e9\u27e9\n  have : ContinuousOn u.boolIndicator s := by\n    apply (continuousOn_boolIndicator_iff_clopen _ _).mpr \u27e8_, _\u27e9\n    \u00b7 exact u_op.preimage continuous_subtype_val\n    \u00b7 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 \u03b1) {f : \u03b1 \u2192 Y} (hf : Continuous f) {x y : \u03b1} : 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 : \u2200 f : \u03b1 \u2192 Bool, Continuous f \u2192 \u2200 x y, f x = f y) : PreconnectedSpace \u03b1 :=\n  \u27e8isPreconnected_of_forall_constant fun f hf x _ y _ =>\n      hs f (continuous_iff_continuousOn_univ.mpr hf) x y\u27e9\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 \u03b2] {S : Set \u03b1} (hS : IsPreconnected S)\n    {T : Set \u03b2} [DiscreteTopology T] {f : \u03b1 \u2192 \u03b2} (hc : ContinuousOn f S) (hTm : MapsTo f S T)\n    {x y : \u03b1} (hx : x \u2208 S) (hy : y \u2208 S) : f x = f y := by\n  let F : S \u2192 T := hTm.restrict f S T\n  suffices F \u27e8x, hx\u27e9 = F \u27e8y, hy\u27e9 by rwa [\u2190 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 \u03b1 y` on `S` for some `y \u2208 T`. -/\ntheorem IsPreconnected.eqOn_const_of_mapsTo [TopologicalSpace \u03b2] {S : Set \u03b1} (hS : IsPreconnected S)\n    {T : Set \u03b2} [DiscreteTopology T] {f : \u03b1 \u2192 \u03b2} (hc : ContinuousOn f S) (hTm : MapsTo f S T)\n    (hne : T.Nonempty) : \u2203 y \u2208 T, EqOn f (const \u03b1 y) S := by\n  rcases S.eq_empty_or_nonempty with (rfl | \u27e8x, hx\u27e9)\n  \u00b7 exact hne.imp fun _ hy => \u27e8hy, eqOn_empty _ _\u27e9\n  \u00b7 exact \u27e8f x, hTm hx, fun x' hx' => hS.constant_of_mapsTo hc hTm hx' hx\u27e9\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u03b1` is the type of open subsets of a topological space `\u03b1`.\n- `open_nhds_of x` is the type of open subsets of a topological space `\u03b1` containing `x : \u03b1`.\n-\n-/\n\nnamespace topological_space\n\n\n/-- The type of open subsets of a topological space. -/\ndef opens (\u03b1 : Type u_1) [topological_space \u03b1] := Subtype fun (s : set \u03b1) => is_open s\n\nnamespace opens\n\n\nprotected instance set.has_coe {\u03b1 : Type u_1} [topological_space \u03b1] : has_coe (opens \u03b1) (set \u03b1) :=\n  has_coe.mk subtype.val\n\ntheorem val_eq_coe {\u03b1 : Type u_1} [topological_space \u03b1] (U : opens \u03b1) : subtype.val U = \u2191U := rfl\n\n/-- the coercion `opens \u03b1 \u2192 set \u03b1` applied to a pair is the same as taking the first component -/\ntheorem coe_mk {\u03b1 : Type u_1} [topological_space \u03b1] {U : set \u03b1} {hU : is_open U} :\n    \u2191{ val := U, property := hU } = U :=\n  rfl\n\nprotected instance has_subset {\u03b1 : Type u_1} [topological_space \u03b1] : has_subset (opens \u03b1) :=\n  has_subset.mk fun (U V : opens \u03b1) => \u2191U \u2286 \u2191V\n\nprotected instance has_mem {\u03b1 : Type u_1} [topological_space \u03b1] : has_mem \u03b1 (opens \u03b1) :=\n  has_mem.mk fun (a : \u03b1) (U : opens \u03b1) => a \u2208 \u2191U\n\n@[simp] theorem subset_coe {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} :\n    \u2191U \u2286 \u2191V = (U \u2286 V) :=\n  rfl\n\n@[simp] theorem mem_coe {\u03b1 : Type u_1} [topological_space \u03b1] {x : \u03b1} {U : opens \u03b1} :\n    x \u2208 \u2191U = (x \u2208 U) :=\n  rfl\n\ntheorem ext {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} (h : \u2191U = \u2191V) :\n    U = V :=\n  iff.mpr subtype.ext_iff h\n\ntheorem ext_iff {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} :\n    \u2191U = \u2191V \u2194 U = V :=\n  { mp := ext, mpr := congr_arg coe }\n\nprotected instance partial_order {\u03b1 : Type u_1} [topological_space \u03b1] : partial_order (opens \u03b1) :=\n  subtype.partial_order fun (s : set \u03b1) => is_open s\n\n/-- The interior of a set, as an element of `opens`. -/\ndef interior {\u03b1 : Type u_1} [topological_space \u03b1] (s : set \u03b1) : opens \u03b1 :=\n  { val := interior s, property := is_open_interior }\n\ntheorem gc {\u03b1 : Type u_1} [topological_space \u03b1] : galois_connection coe interior :=\n  fun (U : opens \u03b1) (s : set \u03b1) =>\n    { mp := fun (h : \u2191U \u2264 s) => interior_maximal h (subtype.property U),\n      mpr := fun (h : U \u2264 interior s) => le_trans h interior_subset }\n\n/-- The galois insertion between sets and opens, but ordered by reverse inclusion. -/\ndef gi {\u03b1 : Type u_1} [topological_space \u03b1] : galois_insertion interior subtype.val :=\n  galois_insertion.mk\n    (fun (s : order_dual (set \u03b1)) (hs : subtype.val (interior s) \u2264 s) =>\n      { val := s, property := sorry })\n    sorry sorry sorry\n\n@[simp] theorem gi_choice_val {\u03b1 : Type u_1} [topological_space \u03b1] {s : order_dual (set \u03b1)}\n    {hs : subtype.val (interior s) \u2264 s} : subtype.val (galois_insertion.choice gi s hs) = s :=\n  rfl\n\nprotected instance complete_lattice {\u03b1 : Type u_1} [topological_space \u03b1] :\n    complete_lattice (opens \u03b1) :=\n  complete_lattice.copy (order_dual.complete_lattice (order_dual (opens \u03b1)))\n    (fun (U V : opens \u03b1) => U \u2286 V) sorry { val := set.univ, property := is_open_univ } sorry\n    { val := \u2205, property := is_open_empty } sorry\n    (fun (U V : opens \u03b1) => { val := \u2191U \u222a \u2191V, property := sorry }) sorry\n    (fun (U V : opens \u03b1) => { val := \u2191U \u2229 \u2191V, property := sorry }) sorry\n    (fun (Us : set (opens \u03b1)) => { val := \u22c3\u2080(coe '' Us), property := sorry }) sorry\n    complete_lattice.Inf sorry\n\n/- le  -/ (\u03bb U V, U \u2286 V) rfl\n/- top -/ \u27e8set.univ, is_open_univ\u27e9 (subtype.ext_iff_val.mpr interior_univ.symm)\n/- bot -/ \u27e8\u2205, is_open_empty\u27e9 rfl\n/- sup -/ (\u03bb U V, \u27e8\u2191U \u222a \u2191V, is_open_union U.2 V.2\u27e9) rfl\n/- inf -/ (\u03bb U V, \u27e8\u2191U \u2229 \u2191V, is_open_inter U.2 V.2\u27e9)\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 -/ (\u03bb Us, \u27e8\u22c3\u2080 (coe '' Us), is_open_sUnion $ \u03bb U hU,\nby { rcases hU with \u27e8\u27e8V, hV\u27e9, h, h'\u27e9, dsimp at h', subst h', exact hV}\u27e9)\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 \u03b1} : U \u2264 V \u2194 (U : set \u03b1) \u2264 (V : set \u03b1) :=\nby refl\ntheorem le_def {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} : U \u2264 V \u2194 \u2191U \u2264 \u2191V :=\n  iff.refl (U \u2264 V)\n\n\n@[simp] lemma mk_inf_mk {U V : set \u03b1} {hU : is_open U} {hV : is_open V} :\n  (\u27e8U, hU\u27e9 \u2293 \u27e8V, hV\u27e9 : opens \u03b1) = \u27e8U \u2293 V, is_open_inter hU hV\u27e9 := rfl\n@[simp] theorem mk_inf_mk {\u03b1 : Type u_1} [topological_space \u03b1] {U : set \u03b1} {V : set \u03b1}\n    {hU : is_open U} {hV : is_open V} :\n    { val := U, property := hU } \u2293 { val := V, property := hV } =\n        { val := U \u2293 V, property := is_open_inter hU hV } :=\n  rfl\n\n@[simp,norm_cast] lemma coe_inf {U V : opens \u03b1} :\n  ((U \u2293 V : opens \u03b1) : set \u03b1) = (U : set \u03b1) \u2293 (V : set \u03b1) := rfl\n@[simp] theorem coe_inf {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1} :\n    \u2191(U \u2293 V) = \u2191U \u2293 \u2191V :=\n  rfl\n\n\ninstance : has_inter (opens \u03b1) := \u27e8\u03bb U V, U \u2293 V\u27e9\ninstance : has_union (opens \u03b1) := \u27e8\u03bb U V, U \u2294 V\u27e9\nprotected instance has_inter {\u03b1 : Type u_1} [topological_space \u03b1] : has_inter (opens \u03b1) :=\n  has_inter.mk fun (U V : opens \u03b1) => U \u2293 V\n\ninstance : has_emptyc (opens \u03b1) := \u27e8\u22a5\u27e9\nprotected instance has_union {\u03b1 : Type u_1} [topological_space \u03b1] : has_union (opens \u03b1) :=\n  has_union.mk fun (U V : opens \u03b1) => U \u2294 V\n\ninstance : inhabited (opens \u03b1) := \u27e8\u2205\u27e9\nprotected instance has_emptyc {\u03b1 : Type u_1} [topological_space \u03b1] : has_emptyc (opens \u03b1) :=\n  has_emptyc.mk \u22a5\n\n\nprotected instance inhabited {\u03b1 : Type u_1} [topological_space \u03b1] : Inhabited (opens \u03b1) :=\n  { default := \u2205 }\n\n@[simp] lemma inter_eq (U V : opens \u03b1) : U \u2229 V = U \u2293 V := rfl\n@[simp] lemma union_eq (U V : opens \u03b1) : U \u222a V = U \u2294 V := rfl\n@[simp] theorem inter_eq {\u03b1 : Type u_1} [topological_space \u03b1] (U : opens \u03b1) (V : opens \u03b1) :\n    U \u2229 V = U \u2293 V :=\n  rfl\n\n@[simp] lemma empty_eq : (\u2205 : opens \u03b1) = \u22a5 := rfl\n@[simp] theorem union_eq {\u03b1 : Type u_1} [topological_space \u03b1] (U : opens \u03b1) (V : opens \u03b1) :\n    U \u222a V = U \u2294 V :=\n  rfl\n\n\n@[simp] theorem empty_eq {\u03b1 : Type u_1} [topological_space \u03b1] : \u2205 = \u22a5 := rfl\n\n@[simp] lemma Sup_s {Us : set (opens \u03b1)} : \u2191(Sup Us) = \u22c3\u2080 ((coe : _ \u2192 set \u03b1) '' Us) :=\nbegin\n@[simp] theorem Sup_s {\u03b1 : Type u_1} [topological_space \u03b1] {Us : set (opens \u03b1)} :\n    \u2191(Sup Us) = \u22c3\u2080(coe '' Us) :=\n  sorry\n\n  rw [@galois_connection.l_Sup (opens \u03b1) (set \u03b1) _ _ (coe : opens \u03b1 \u2192 set \u03b1) interior gc Us],\n  rw [set.sUnion_image]\nend\n\nlemma supr_def {\u03b9} (s : \u03b9 \u2192 opens \u03b1) : (\u2a06 i, s i) = \u27e8\u22c3 i, s i, is_open_Union $ \u03bb i, (s i).2\u27e9 :=\nby { ext, simp only [supr, opens.Sup_s, sUnion_image, bUnion_range], refl }\ntheorem supr_def {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Sort u_2} (s : \u03b9 \u2192 opens \u03b1) :\n    (supr fun (i : \u03b9) => s i) =\n        { val := set.Union fun (i : \u03b9) => \u2191(s i),\n          property := is_open_Union fun (i : \u03b9) => subtype.property (s i) } :=\n  sorry\n\n\n@[simp] lemma supr_mk {\u03b9} (s : \u03b9 \u2192 set \u03b1) (h : \u03a0 i, is_open (s i)) :\n  (\u2a06 i, \u27e8s i, h i\u27e9 : opens \u03b1) = \u27e8\u2a06 i, s i, is_open_Union h\u27e9 :=\n@[simp] theorem supr_mk {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Sort u_2} (s : \u03b9 \u2192 set \u03b1)\n    (h : \u2200 (i : \u03b9), is_open (s i)) :\n    (supr fun (i : \u03b9) => { val := s i, property := h i }) =\n        { val := supr fun (i : \u03b9) => s i, property := is_open_Union h } :=\n  sorry\n\nby { rw supr_def, simp }\n\n@[simp] lemma supr_s {\u03b9} (s : \u03b9 \u2192 opens \u03b1) : ((\u2a06 i, s i : opens \u03b1) : set \u03b1) = \u22c3 i, s i :=\nby simp [supr_def]\n@[simp] theorem supr_s {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Sort u_2} (s : \u03b9 \u2192 opens \u03b1) :\n    \u2191(supr fun (i : \u03b9) => s i) = set.Union fun (i : \u03b9) => \u2191(s i) :=\n  sorry\n\n\ntheorem mem_supr {\u03b9} {x : \u03b1} {s : \u03b9 \u2192 opens \u03b1} : x \u2208 supr s \u2194 \u2203 i, x \u2208 s i :=\nby { rw [\u2190mem_coe], simp, }\ntheorem mem_supr {\u03b1 : Type u_1} [topological_space \u03b1] {\u03b9 : Sort u_2} {x : \u03b1} {s : \u03b9 \u2192 opens \u03b1} :\n    x \u2208 supr s \u2194 \u2203 (i : \u03b9), x \u2208 s i :=\n  sorry\n\n\nlemma open_embedding_of_le {U V : opens \u03b1} (i : U \u2264 V) :\n  open_embedding (set.inclusion i) :=\ntheorem open_embedding_of_le {\u03b1 : Type u_1} [topological_space \u03b1] {U : opens \u03b1} {V : opens \u03b1}\n    (i : U \u2264 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 \u03b1)) : Prop := is_topological_basis ((coe : _ \u2192 set \u03b1) '' B)\n\ndef is_basis {\u03b1 : Type u_1} [topological_space \u03b1] (B : set (opens \u03b1)) :=\n  is_topological_basis (coe '' B)\n\nlemma is_basis_iff_nbhd {B : set (opens \u03b1)} :\n  is_basis B \u2194 \u2200 {U : opens \u03b1} {x}, x \u2208 U \u2192 \u2203 U' \u2208 B, x \u2208 U' \u2227 U' \u2286 U :=\ntheorem is_basis_iff_nbhd {\u03b1 : Type u_1} [topological_space \u03b1] {B : set (opens \u03b1)} :\n    is_basis B \u2194\n        \u2200 {U : opens \u03b1} {x : \u03b1}, x \u2208 U \u2192 \u2203 (U' : opens \u03b1), \u2203 (H : U' \u2208 B), x \u2208 U' \u2227 U' \u2286 U :=\n  sorry\n\nbegin\n  split; intro h,\n  { rintros \u27e8sU, hU\u27e9 x hx,\n    rcases (mem_nhds_of_is_topological_basis h).mp (mem_nhds_sets hU hx)\n      with \u27e8sV, \u27e8\u27e8V, H\u2081, H\u2082\u27e9, hsV\u27e9\u27e9,\n    refine \u27e8V, H\u2081, _\u27e9,\n    cases V, dsimp at H\u2082, subst H\u2082, exact hsV },\n  { refine is_topological_basis_of_open_of_nhds _ _,\n    { rintros sU \u27e8U, \u27e8H\u2081, H\u2082\u27e9\u27e9, subst H\u2082, exact U.property },\n    { intros x sU hx hsU,\n      rcases @h (\u27e8sU, hsU\u27e9 : opens \u03b1) x hx with \u27e8V, hV, H\u27e9,\n      exact \u27e8V, \u27e8V, hV, rfl\u27e9, H\u27e9 } }\nend\n\nlemma is_basis_iff_cover {B : set (opens \u03b1)} :\n  is_basis B \u2194 \u2200 U : opens \u03b1, \u2203 Us \u2286 B, U = Sup Us :=\ntheorem is_basis_iff_cover {\u03b1 : Type u_1} [topological_space \u03b1] {B : set (opens \u03b1)} :\n    is_basis B \u2194 \u2200 (U : opens \u03b1), \u2203 (Us : set (opens \u03b1)), \u2203 (H : Us \u2286 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 \u27e8sUs, H, hU\u27e9,\n    existsi {U : opens \u03b1 | U \u2208 B \u2227 \u2191U \u2208 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 \u27e8V, hV\u27e9,\n        rw \u2190 hV.right at hs,\n        refine \u27e8V, \u27e8\u27e8hV.left, hs\u27e9, hV.right\u27e9\u27e9 },\n      { rcases hs with \u27e8V, \u27e8\u27e8H\u2081, H\u2082\u27e9, H\u2083\u27e9\u27e9,\n        subst H\u2083, exact H\u2082 } } },\n  { intro h,\n    rw is_basis_iff_nbhd,\n    intros U x hx,\n    rcases h U with \u27e8Us, hUs, H\u27e9,\n    replace H := congr_arg (coe : _ \u2192 set \u03b1) H,\n    rw Sup_s at H,\n    change x \u2208 \u2191U at hx,\n    rw H at hx,\n    rcases set.mem_sUnion.mp hx with \u27e8sV, \u27e8\u27e8V, H\u2081, H\u2082\u27e9, hsV\u27e9\u27e9,\n    refine \u27e8V,hUs H\u2081,_\u27e9,\n    cases V with V hV,\n    dsimp at H\u2082, subst H\u2082,\n    refine \u27e8hsV,_\u27e9,\n    change V \u2286 U, rw H,\n    exact set.subset_sUnion_of_mem \u27e8\u27e8V, _\u27e9, \u27e8H\u2081, rfl\u27e9\u27e9 }\nend\n\n/-- The preimage of an open set, as an open set. -/\n\ndef comap {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (V : opens \u03b2) : opens \u03b1 :=\n\u27e8f \u207b\u00b9' V.1, V.2.preimage hf\u27e9\ndef comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (hf : continuous f) (V : opens \u03b2) : opens \u03b1 :=\n  { val := f \u207b\u00b9' subtype.val V, property := sorry }\n\n\n@[simp] lemma comap_id (U : opens \u03b1) : U.comap continuous_id = U := by { ext, refl }\n\n@[simp] theorem comap_id {\u03b1 : Type u_1} [topological_space \u03b1] (U : opens \u03b1) :\n    comap continuous_id U = U :=\n  ext (set.ext fun (x : \u03b1) => iff.refl (x \u2208 \u2191(comap continuous_id U)))\n\nlemma comap_mono {f : \u03b1 \u2192 \u03b2} (hf : continuous f) {V W : opens \u03b2} (hVW : V \u2286 W) :\n  V.comap hf \u2286 W.comap hf :=\ntheorem comap_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (hf : continuous f) {V : opens \u03b2} {W : opens \u03b2} (hVW : V \u2286 W) :\n    comap hf V \u2286 comap hf W :=\n  fun (_x : \u03b1) (h : _x \u2208 \u2191(comap hf V)) => hVW h\n\n\u03bb _ h, hVW h\n\n@[simp] lemma coe_comap {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (U : opens \u03b2) :\n  \u2191(U.comap hf) = f \u207b\u00b9' U := rfl\n@[simp] theorem coe_comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (U : opens \u03b2) : \u2191(comap hf U) = f \u207b\u00b9' \u2191U :=\n  rfl\n\n\n@[simp] lemma comap_val {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (U : opens \u03b2) :\n  (U.comap hf).1 = f \u207b\u00b9' U := rfl\n@[simp] theorem comap_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (U : opens \u03b2) : subtype.val (comap hf U) = f \u207b\u00b9' \u2191U :=\n  rfl\n\n\nprotected lemma comap_comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : continuous g) (hf : continuous f)\n  (U : opens \u03b3) : U.comap (hg.comp hf) = (U.comap hg).comap hf :=\nprotected theorem comap_comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1]\n    [topological_space \u03b2] [topological_space \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : continuous g)\n    (hf : continuous f) (U : opens \u03b3) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1]\n    [topological_space \u03b2] (f : \u03b1 \u2243\u209c \u03b2) : opens \u03b1 \u2243 opens \u03b2 :=\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 {\u03b1 : Type u_1} [topological_space \u03b1] (x : \u03b1) :=\n  Subtype fun (s : set \u03b1) => is_open s \u2227 x \u2208 s\n\nprotected instance open_nhds_of.inhabited {\u03b1 : Type u_1} [topological_space \u03b1] (x : \u03b1) :\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u03b1` is just a \"copy\" of a type `\u03b1` in a higher universe.)\n-/\n\nuniverses u v\nvariables {\u03b1 : Type u} {x y : ulift.{v} \u03b1}\n\nnamespace ulift\n\ninstance [has_rat_cast \u03b1] : has_rat_cast (ulift \u03b1) := \u27e8\u03bb a, up a\u27e9\n\n@[simp, norm_cast] lemma up_rat_cast [has_rat_cast \u03b1] (q : \u211a) : up (q : \u03b1) = q := rfl\n@[simp, norm_cast] lemma down_rat_cast [has_rat_cast \u03b1] (q : \u211a) : down (q : ulift \u03b1) = q := rfl\n\ninstance division_semiring [division_semiring \u03b1] : division_semiring (ulift \u03b1) :=\nby refine down_injective.division_semiring down _ _ _ _ _ _ _ _ _ _; intros; refl\n\ninstance semifield [semifield \u03b1] : semifield (ulift \u03b1) :=\n{ ..ulift.division_semiring, ..ulift.comm_group_with_zero }\n\ninstance division_ring [division_ring \u03b1] : division_ring (ulift \u03b1) :=\n{ ..ulift.division_semiring, ..ulift.add_group }\n\ninstance field [field \u03b1] : field (ulift \u03b1) :=\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 \u2192+* L) :\n  \u2200 (a : K) (n : \u2124), 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 \u2243+* L) :\n  \u2200 (a : K) (n : \u2124), 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 : \u2124) :\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 : \u2124}\n\nlemma zpow_nonneg {a : K} (ha : 0 \u2264 a) : \u2200 (z : \u2124), 0 \u2264 a ^ z\n| (n : \u2115) := 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) : \u2200 (z : \u2124), 0 < a ^ z\n| (n : \u2115) := 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 \u2264 x) {a b : \u2124} (h : a \u2264 b) : x ^ a \u2264 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 : -(\u2191(a+1) : \u2124) \u2264 -(\u2191(b+1) : \u2124), 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 \u2264 x) {a b c : \u2124} (h : min a b \u2264 c) :\n      x ^ (-c) \u2264 max (x ^ (-a)) (x ^ (-b)) :=\nbegin\n  wlog hle : a \u2264 b,\n  have hnle : -b \u2264 -a, from neg_le_neg hle,\n  have hfle : x ^ (-b) \u2264 x ^ (-a), from zpow_le_of_le hx hnle,\n  have : x ^ (-c) \u2264 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 \u2264 p) {z : \u2124} (hz : z \u2264 0) : p ^ z \u2264 1 :=\ncalc p ^ z \u2264 p ^ 0 : zpow_le_of_le hp hz\n          ... = 1        : by simp\n\nlemma one_le_zpow_of_nonneg {p : K} (hp : 1 \u2264 p) {z : \u2124} (hz : 0 \u2264 z) : 1 \u2264 p ^ z :=\ncalc p ^ z \u2265 p ^ 0 : zpow_le_of_le hp hz\n          ... = 1        : by simp\n\ntheorem zpow_bit0_nonneg (a : K) (n : \u2124) : 0 \u2264 a ^ bit0 n :=\nby { rw zpow_bit0, exact mul_self_nonneg _ }\n\ntheorem zpow_two_nonneg (a : K) : 0 \u2264 a ^ (2 : \u2124) :=\nzpow_bit0_nonneg a 1\n\ntheorem zpow_bit0_pos {a : K} (h : a \u2260 0) (n : \u2124) : 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 \u2260 0) : 0 < a ^ (2 : \u2124) :=\nzpow_bit0_pos h 1\n\n@[simp] theorem zpow_bit1_neg_iff : a ^ bit1 n < 0 \u2194 a < 0 :=\n\u27e8\u03bb h, not_le.1 $ \u03bb h', not_le.2 h $ zpow_nonneg h' _,\n \u03bb h, by rw [bit1, zpow_add_one\u2080 h.ne]; exact mul_neg_of_pos_of_neg (zpow_bit0_pos h.ne _) h\u27e9\n\n@[simp] theorem zpow_bit1_nonneg_iff : 0 \u2264 a ^ bit1 n \u2194 0 \u2264 a :=\nle_iff_le_iff_lt_iff_lt.2 zpow_bit1_neg_iff\n\n@[simp] theorem zpow_bit1_nonpos_iff : a ^ bit1 n \u2264 0 \u2194 a \u2264 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 \u2194 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  \u2200 z : \u2124, 0 < z \u2192 1 < p ^ z\n| (n : \u2115) 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 : \u2115} (h : 0 < p) (n:\u2124) : 0 < (p:K)^n :=\nby { apply zpow_pos_of_pos, exact_mod_cast h }\n\nlemma nat.zpow_ne_zero_of_pos {p : \u2115} (h : 0 < p) (n:\u2124) : (p:K)^n \u2260 0 :=\nne_of_gt (nat.zpow_pos_of_pos h n)\n\nlemma zpow_strict_mono {x : K} (hx : 1 < x) :\n  strict_mono (\u03bb n:\u2124, x ^ n) :=\nstrict_mono_int_of_lt_succ $ \u03bb 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\u2080 xpos.ne' _).symm\n\nlemma zpow_strict_anti {x : K} (h\u2080 : 0 < x) (h\u2081 : x < 1) : strict_anti (\u03bb n : \u2124, x ^ n) :=\nstrict_anti_int_of_succ_lt $ \u03bb n,\ncalc x ^ (n + 1) = x ^ n * x : zpow_add_one\u2080 h\u2080.ne' _\n... < x ^ n * 1 : (mul_lt_mul_left $ zpow_pos_of_pos h\u2080 _).2 h\u2081\n... = x ^ n : mul_one _\n\n@[simp] lemma zpow_lt_iff_lt {x : K} (hx : 1 < x) {m n : \u2124} :\n  x ^ m < x ^ n \u2194 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 : \u2124} :\n  x ^ m \u2264 x ^ n \u2194 m \u2264 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 : \u2124}\n  (h_max : x ^ (-c) \u2264 max (x ^ (-a)) (x ^ (-b)) ) : min a b \u2264 c :=\nbegin\n  rw min_le_iff,\n  refine or.imp (\u03bb h, _) (\u03bb 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 : \u2115) : 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 \u2264 b) (k : \u2115) : a/b^k \u2264 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   ...  \u2264 a*b^k : (mul_le_mul_left ha).mpr $ one_le_pow_of_one_le hb _)\n\nlemma zpow_injective {x : K} (h\u2080 : 0 < x) (h\u2081 : x \u2260 1) :\n  function.injective ((^) x : \u2124 \u2192 K) :=\nbegin\n  intros m n h,\n  rcases h\u2081.lt_or_lt with H|H,\n  { apply (zpow_strict_mono (one_lt_inv h\u2080 H)).injective,\n    show x\u207b\u00b9 ^ m = x\u207b\u00b9 ^ n,\n    rw [\u2190 zpow_neg_one, \u2190 zpow_mul, \u2190 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\u2080 : 0 < x) (h\u2081 : x \u2260 1) {m n : \u2124} :\n  x ^ m = x ^ n \u2194 m = n :=\n(zpow_injective h\u2080 h\u2081).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 : \u211a) (n : \u2124) :\n  ((q ^ n : \u211a) : 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 : \u2115 \u2192 Sort u} (zero : motive zero)\n  (succ : (n : \u2115) \u2192 motive n \u2192 motive (succ n)) :\n  (t : \u2115) \u2192 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, \u2190ih]\n\nend recursor_workarounds\n\nset_option linter.deprecated false\n\nprotected \n\nprotected theorem zero_lt_bit0 : \u2200 {n : Nat}, n \u2260 0 \u2192 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 : \u2200 {n : \u2115}, n \u2260 0 \u2192 bit0 n \u2260 0\n  | 0, h => absurd rfl h\n  | n + 1, _ =>\n    suffices n + 1 + (n + 1) \u2260 0 from this\n    suffices succ (n + 1 + n) \u2260 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 : \u2115) : bit1 n \u2260 0 :=\n  show succ (n + n) \u2260 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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) \u2208 s)\n(add_mem {a b} : a \u2208 s \u2192 b \u2208 s \u2192 a + b \u2208 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) \u2208 s)\n(mul_mem {a b} : a \u2208 s \u2192 b \u2208 s \u2192 a * b \u2208 s)\n\nlemma additive.is_add_submonoid\n  (s : set M) : \u2200 [is_submonoid s], @is_add_submonoid (additive M) _ s\n| \u27e8h\u2081, h\u2082\u27e9 := \u27e8h\u2081, @h\u2082\u27e9\n\ntheorem additive.is_add_submonoid_iff\n  {s : set M} : @is_add_submonoid (additive M) _ s \u2194 is_submonoid s :=\n\u27e8\u03bb \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081, @h\u2082\u27e9, \u03bb h, by exactI additive.is_add_submonoid _\u27e9\n\nlemma multiplicative.is_submonoid\n  (s : set A) : \u2200 [is_add_submonoid s], @is_submonoid (multiplicative A) _ s\n| \u27e8h\u2081, h\u2082\u27e9 := \u27e8h\u2081, @h\u2082\u27e9\n\ntheorem multiplicative.is_submonoid_iff\n  {s : set A} : @is_submonoid (multiplicative A) _ s \u2194 is_add_submonoid s :=\n\u27e8\u03bb \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081, @h\u2082\u27e9, \u03bb h, by exactI multiplicative.is_submonoid _\u27e9\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\u2081 s\u2082 : set M) [is_submonoid s\u2081] [is_submonoid s\u2082] :\n  is_submonoid (s\u2081 \u2229 s\u2082) :=\n{ one_mem := \u27e8is_submonoid.one_mem, is_submonoid.one_mem\u27e9,\n  mul_mem := \u03bb x y hx hy,\n    \u27e8is_submonoid.mul_mem hx.1 hy.1, is_submonoid.mul_mem hx.2 hy.2\u27e9 }\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 {\u03b9 : Sort*} (s : \u03b9 \u2192 set M) [h : \u2200 y : \u03b9, is_submonoid (s y)] :\n  is_submonoid (set.Inter s) :=\n{ one_mem := set.mem_Inter.2 $ \u03bb y, is_submonoid.one_mem,\n  mul_mem := \u03bb x\u2081 x\u2082 h\u2081 h\u2082, set.mem_Inter.2 $\n    \u03bb y, is_submonoid.mul_mem (set.mem_Inter.1 h\u2081 y) (set.mem_Inter.1 h\u2082 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 {\u03b9 : Type*} [h\u03b9 : nonempty \u03b9]\n  (s : \u03b9 \u2192 set M) [\u2200 i, is_submonoid (s i)]\n  (directed : \u2200 i j, \u2203 k, s i \u2286 s k \u2227 s j \u2286 s k) :\n  is_submonoid (\u22c3i, s i) :=\n{ one_mem := let \u27e8i\u27e9 := h\u03b9 in set.mem_Union.2 \u27e8i, is_submonoid.one_mem\u27e9,\n  mul_mem := \u03bb a b ha hb,\n    let \u27e8i, hi\u27e9 := set.mem_Union.1 ha in\n    let \u27e8j, hj\u27e9 := set.mem_Union.1 hb in\n    let \u27e8k, hk\u27e9 := directed i j in\n    set.mem_Union.2 \u27e8k, is_submonoid.mul_mem (hk.1 hi) (hk.2 hj)\u27e9 }\n\nsection powers\n\n/-- The set of natural number powers `1, x, x\u00b2, ...` of an element `x` of a monoid. -/\ndef powers (x : M) : set M := {y | \u2203 n:\u2115, 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 | \u2203 n:\u2115, n \u2022 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) \u2208 powers x := \u27e80, pow_zero _\u27e9\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) \u2208 multiples x := \u27e80, zero_nsmul _\u27e9\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 \u2208 powers x := \u27e81, pow_one _\u27e9\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 \u2208 multiples x := \u27e81, one_nsmul _\u27e9\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 \u2208 powers x) \u2192 (z \u2208 powers x) \u2192 (y * z \u2208 powers x) :=\n\u03bb \u27e8n\u2081, h\u2081\u27e9 \u27e8n\u2082, h\u2082\u27e9, \u27e8n\u2081 + n\u2082, by simp only [pow_add, *]\u27e9\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 \u2208 multiples x) \u2192 (z \u2208 multiples x) \u2192 (y + z \u2208 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 := \u03bb 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 \u2192 N) [is_monoid_hom f]\n  (s : set N) [is_submonoid s] : is_submonoid (f \u207b\u00b9' s) :=\n{ one_mem := show f 1 \u2208 s, by rw is_monoid_hom.map_one f; exact is_submonoid.one_mem,\n  mul_mem := \u03bb a b (ha : f a \u2208 s) (hb : f b \u2208 s),\n    show f (a * b) \u2208 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 {\u03b3 : Type*} [monoid \u03b3] (f : M \u2192 \u03b3) [is_monoid_hom f]\n  (s : set M) [is_submonoid s] : is_submonoid (f '' s) :=\n{ one_mem := \u27e81, is_submonoid.one_mem, is_monoid_hom.map_one f\u27e9,\n  mul_mem := \u03bb a b \u27e8x, hx\u27e9 \u27e8y, hy\u27e9, \u27e8x * y, is_submonoid.mul_mem hx.1 hy.1,\n    by rw [is_monoid_hom.map_mul f, hx.2, hy.2]\u27e9 }\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 {\u03b3 : Type*} [monoid \u03b3] (f : M \u2192 \u03b3) [is_monoid_hom f] :\n  is_submonoid (set.range f) :=\nby rw \u2190 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 \u2208 s) : \u2200 {n : \u2115}, a ^ n \u2208 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  \u2200 (h : a \u2208 t) {n : \u2115}, n \u2022 a \u2208 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 \u2208 s) : powers a \u2286 s :=\nassume x \u27e8n, hx\u27e9, hx \u25b8 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 \u2208 t \u2192 multiples a \u2286 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] : \u2200{l : list M}, (\u2200x\u2208l, x \u2208 s) \u2192 l.prod \u2208 s\n| []     h := one_mem\n| (a::l) h :=\n  suffices a * l.prod \u2208 s, by simpa,\n  have a \u2208 s \u2227 (\u2200x\u2208l, x \u2208 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  (\u2200a\u2208m, a \u2208 s) \u2192 m.prod \u2208 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 \u2192 M) :\n  \u2200(t : finset A), (\u2200b\u2208t, f b \u2208 s) \u2192 \u220f b in t, f b \u2208 s\n| \u27e8m, hm\u27e9 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 := \u27e81, is_submonoid.one_mem\u27e9,\n  mul := \u03bb x y, \u27e8x * y, is_submonoid.mul_mem x.2 y.2\u27e9,\n  mul_one := \u03bb x, subtype.eq $ mul_one x.1,\n  one_mul := \u03bb x, subtype.eq $ one_mul x.1,\n  mul_assoc := \u03bb 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 := \u03bb 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 : \u2115) :\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 : \u2115) : ((n \u2022 a : s) : A) = n \u2022 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 \u2192 M) :=\n{ map_one := rfl, map_mul := \u03bb _ _, 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 \u2192 M) :=\nsubtype_val.is_monoid_hom\n\n/-- Given a monoid hom `f : \u03b3 \u2192 M` whose image is contained in a submonoid `s`, the induced map\n    from `\u03b3` to `s` is a monoid hom. -/\n@[to_additive \"Given an `add_monoid` hom `f : \u03b3 \u2192 M` whose image is contained in\nan `add_submonoid` s, the induced map from `\u03b3` to `s` is an `add_monoid` hom.\"]\ninstance subtype_mk.is_monoid_hom {\u03b3 : Type*} [monoid \u03b3] [is_submonoid s] (f : \u03b3 \u2192 M)\n  [is_monoid_hom f] (h : \u2200 x, f x \u2208 s) : is_monoid_hom (\u03bb x, (\u27e8f x, h x\u27e9 : s)) :=\n{ map_one := subtype.eq (is_monoid_hom.map_one f),\n  map_mul := \u03bb x y, subtype.eq (is_monoid_hom.map_mul f x y) }\n\n/-- Given two submonoids `s` and `t` such that `s \u2286 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 \u2286 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 \u2286 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 \u2192 Prop\n| basic {a : A} : a \u2208 s \u2192 in_closure a\n| zero : in_closure 0\n| add {a b : A} : in_closure a \u2192 in_closure b \u2192 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 \u2192 Prop\n| basic {a : M} : a \u2208 s \u2192 in_closure a\n| one : in_closure 1\n| mul {a b : M} : in_closure a \u2192 in_closure b \u2192 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 \u2286 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 \u2286 t) : closure s \u2286 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 \u2286 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 \u2286 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 \u2286 t) : closure s \u2286 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 \u2192 A) [is_monoid_hom f] (s : set M) :\n  f '' closure s = closure (f '' s) :=\nle_antisymm\n  begin\n    rintros _ \u27e8x, hx, rfl\u27e9,\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 \u2208 closure s) :\n  (\u2203l:list M, (\u2200x\u2208l, x \u2208 s) \u2227 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 \u27e8la, ha, eqa\u27e9,\n    rcases hb with \u27e8lb, hb, eqb\u27e9,\n    existsi (la ++ lb),\n    simp [eqa.symm, eqb.symm, or_imp_distrib],\n    exact assume a, \u27e8ha a, hb a\u27e9\n  }\nend\n\n/-- Given sets `s, t` of a commutative monoid `M`, `x \u2208 M` is in the submonoid of `M` generated by\n    `s \u222a 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 \u2208 M` is in the `add_submonoid`\nof `M` generated by `s \u222a 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 \u2208 closure (s \u222a t) \u2194 \u2203 y \u2208 closure s, \u2203 z \u2208 closure t, y * z = x :=\n\u27e8\u03bb hx, let \u27e8L, HL1, HL2\u27e9 := exists_list_of_mem_closure hx in HL2 \u25b8\n  list.rec_on L (\u03bb _, \u27e81, is_submonoid.one_mem, 1, is_submonoid.one_mem, mul_one _\u27e9)\n    (\u03bb hd tl ih HL1, let \u27e8y, hy, z, hz, hyzx\u27e9 := ih (list.forall_mem_of_forall_mem_cons HL1) in\n      or.cases_on (HL1 hd $ list.mem_cons_self _ _)\n        (\u03bb hs, \u27e8hd * y, is_submonoid.mul_mem (subset_closure hs) hy, z, hz,\n          by rw [mul_assoc, list.prod_cons, \u2190 hyzx]; refl\u27e9)\n        (\u03bb ht, \u27e8y, hy, z * hd, is_submonoid.mul_mem hz (subset_closure ht),\n          by rw [\u2190 mul_assoc, list.prod_cons, \u2190 hyzx, mul_comm hd]; refl\u27e9)) HL1,\n\u03bb \u27e8y, hy, z, hz, hyzx\u27e9, hyzx \u25b8 is_submonoid.mul_mem (closure_mono (set.subset_union_left _ _) hy)\n  (closure_mono (set.subset_union_right _ _) hz)\u27e9\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 := \u27e8s, h.1, h.2\u27e9\n\n@[to_additive]\ninstance submonoid.is_submonoid (S : submonoid M) : is_submonoid (S : set M) := \u27e8S.2, S.3\u27e9\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 {\u03b1 : Type*} [group \u03b1]\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 \u03b1} (hs : \u2200 n \u2208 s, \u2200 g : \u03b1, g * n * g\u207b\u00b9 \u2208 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, \u2190mul_assoc g\u207b\u00b9, inv_mul_cancel_left, \u2190mul_assoc, mul_assoc g] at this },\nend\n\n/-- The smallest set containing s closed under conjugations -/\ninductive conjugates (s : set \u03b1) : set \u03b1\n| base : \u03a0{{x}}, x \u2208 s \u2192 conjugates x\n| normal : \u03a0{{x}} y, conjugates x \u2192 conjugates (y * x * y\u207b\u00b9)\n\n/-- Given a set s of group elements, return the normal subgroup of \u03b1 generated by s.\n  This is called the conjugate closure, normal closure or the normal subgroup generated by s. -/\ndef normal_closure (s : set \u03b1) : set \u03b1 :=\ngroup.closure (conjugates s)\n\ninstance (s : set \u03b1) : normal_subgroup (normal_closure s) :=\nclosure.normal_subgroup $ \u03bb x hx y, conjugates.normal y hx\n\ndef group_modulo_relations (\u03b1 : Type*) [group \u03b1] (s : set \u03b1) : Group :=\nmk_ob $ quotient_group.quotient (normal_closure s)\n\nnotation \u03b1 `/\u27ea`:95 R `\u27eb`:90 := group_modulo_relations \u03b1 R\n\ndef group_of_generators_relations (gen : Type*) (relations : set (free_group gen)) : Group :=\n(free_group gen)/\u27earelations\u27eb\n\nnotation `\u27ea`:95 G `|`:90 R`\u27eb`:0 := group_of_generators_relations G R\n\ndef generated_of {G : Type*} {R : set (free_group G)} : G \u2192 \u27eaG | R\u27eb :=\n  \u03bb g, quotient_group.mk $ free_group.of g\n\nlocal notation `\u27ea`:50 a `\u27eb`:50 := free_group.of a\n\ndef cyclic_group_presentation (n : \u2115) : Group := \u27eaunit |{ \u27ea()\u27eb^n }\u27eb\n\n/- The dihedral groups -/\n\n/- The dihedral groups are an easy case of the Coxeter groups -/\nnamespace dihedral_group\ndef r := \u27eaff\u27eb\ndef s := \u27eatt\u27eb\nend dihedral_group\nopen dihedral_group\n\n/-- The dihedral group of order 2n -/\ndef dihedral_group (n : \u2115) : Group := \u27eabool | {r^n, s^2, s * r * s * r}\u27eb\n\n/-- The Coxeter group is the group with presentation \u27e8 r_1, ... r_n | (r_ir_j)^{m_{i,j}} = 1 \u27e9\nIf m_{i,j} = \u221e, 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 \u2265 2 for i \u2260 j.\ndef coxeter_group {\u03b1 : Type*} (m : \u03b1 \u2192 \u03b1 \u2192 enat) : Group :=\n\u27ea\u03b1 | set.range (\u03bb(x : \u03b1 \u00d7 \u03b1), (\u27eax.1\u27eb * \u27eax.2\u27eb)^(m x.1 x.2)) \u27eb\n\n/-- coxeter_group' adds new generators with no Coxeter relations on them -/\ndef coxeter_group' {\u03b1 : Type*} (m : \u03b1 \u2192 \u03b1 \u2192 enat) (\u03b2 : Type*) : Group :=\n\u27ea\u03b1\u2295\u03b2 | set.range (\u03bb(x : \u03b1 \u00d7 \u03b1), (\u27easum.inl x.1\u27eb * \u27easum.inl x.2\u27eb)^m x.1 x.2) \u27eb\n\ndef matrix_of_graph {\u03b1 : Type*} [decidable_eq \u03b1] (E : \u03b1 \u2192 \u03b1 \u2192 Prop) [decidable_rel E] (x y : \u03b1) :\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 \u2192 vertex \u2192 Prop)\n  (annotation : \u03a0{{x y}}, edge x y \u2192 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 {\u03b1 : Type*} (E : \u03b1 \u2192 \u03b1 \u2192 Prop) : annotated_graph :=\n{ vertex := \u03b1,\n  edge := E,\n  annotation := \u03bb _ _ _, 3}\n\ndef matrix_of_annotated_graph (\u0393 : annotated_graph) [decidable_eq \u0393.vertex] [decidable_rel \u0393.edge]\n  (x y : \u0393.vertex) : enat :=\nif x = y then 1 else if h : \u0393.edge x y then \u0393.annotation h else 2\n\n/-- \"annotate \u0393 (a,b) n\" returns an annotated graph \u0393' which is identical to \u0393, except that \u0393'.annotation a b = n. -/\ndef annotate (\u0393 : annotated_graph) [decidable_rel \u0393.edge] [decidable_eq \u0393.vertex] (x : \u0393.vertex \u00d7 \u0393.vertex) (n : \u2115+) : annotated_graph :=\n{ vertex := \u0393.vertex,\n  edge := \u0393.edge,\n  annotation := \u03bb a b H, if (a = x.1 \u2227 b = x.2) \u2228 (a = x.2 \u2227 b = x.1) then n else \u0393.annotation H }\n\n/-- \"insert edge \u0393 (a,b) n\" returns \u0393' which is \u0393 except \u0393'.edge a b and \u0393'.edge b a are true and annotated with n.\nIf an edge is already present, this does nothing. -/\ndef insert_edge (\u0393 : annotated_graph) [decidable_rel \u0393.edge] [decidable_eq \u0393.vertex] (x : \u0393.vertex \u00d7 \u0393.vertex) (n : \u2115+) : annotated_graph :=\n{ vertex := \u0393.vertex,\n  edge := \u03bb a b, if (a = x.1 \u2227 b = x.2) \u2228 (a = x.2 \u2227 b = x.1) then true else \u0393.edge a b,\n  annotation := \u03bb a b H, if h : \u0393.edge a b then \u0393.annotation h else n }\n\n/- Coxeter Y-diagrams -/\n@[derive decidable_eq] inductive coxeter_vertices {n} (xs : dvector \u2115+ n) : Type\n| torso {} : coxeter_vertices\n| arm : \u2200 x : dfin n, dfin (xs.nth'' x) \u2192 coxeter_vertices\n\nopen coxeter_vertices\n\ninductive coxeter_edges_directed {n} (xs : dvector \u2115+ n) :\n  coxeter_vertices xs \u2192 coxeter_vertices xs \u2192 Prop\n| edge_torso : \u2200 i : dfin n , coxeter_edges_directed torso (arm i dfin.fz')\n| edge_arm : \u2200 i : dfin n, \u2200 v : dfin (xs.nth'' i), v.to_nat + 1 \u2260 xs.nth'' i \u2192\n    coxeter_edges_directed (arm i v) (arm i (v+1))\n\ninductive symmetric_closure {\u03b1 : Type*} (E : \u03b1 \u2192 \u03b1 \u2192 Prop) : \u03b1 \u2192 \u03b1 \u2192 Prop\n| incl : \u2200 a b : \u03b1, E a b \u2192 symmetric_closure a b\n| symm : \u2200 a b : \u03b1, E a b \u2192 symmetric_closure b a\n\ndef coxeter_edges {n} (xs : dvector \u2115+ n) : coxeter_vertices xs \u2192 coxeter_vertices xs \u2192 Prop :=\nsymmetric_closure (coxeter_edges_directed xs)\n\n-- TODO derive decidability instances\nnoncomputable instance decidable_coxeter_edges {n} (xs : dvector \u2115+ n) :\n  decidable_rel $ coxeter_edges xs :=\n\u03bb _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_rel_annotated_coxeter_edges {n} (xs : dvector \u2115+ n) :\n  decidable_rel $ (annotated_graph_of_graph (coxeter_edges xs)).edge :=\n\u03bb _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_eq_annotate_of_decidable (\u0393 : annotated_graph)\n  [decidable_eq \u0393.vertex] [decidable_rel \u0393.edge] (x n) : decidable_eq $ (annotate \u0393 x n).vertex :=\n\u03bb _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_rel_annotate_of_decidable (\u0393 : annotated_graph)\n  [decidable_eq \u0393.vertex] [decidable_rel \u0393.edge] (x n) : decidable_rel $ (annotate \u0393 x n).edge :=\n\u03bb _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_eq_insert_edge_of_decidable (\u0393 : annotated_graph)\n  [decidable_rel \u0393.edge] [decidable_eq \u0393.vertex] (x n) : decidable_eq $ (insert_edge \u0393 x n).vertex :=\n\u03bb _ _, classical.prop_decidable _\n\nnoncomputable instance decidable_rel_insert_edge_of_decidable (\u0393 : annotated_graph)\n  [decidable_rel \u0393.edge] [decidable_eq \u0393.vertex] (x n) : decidable_rel $ (insert_edge \u0393 x n).edge :=\n\u03bb _ _, classical.prop_decidable _\n\n/- Derived subgroups -/\n\ndef commutator {\u03b1 : Type*} [group \u03b1] : \u03b1 \u00d7 \u03b1 \u2192 \u03b1\n| \u27e8x, y\u27e9 :=  x * y * x\u207b\u00b9 * y\u207b\u00b9\n\nnotation `\u27e6`:95 x `,` y `\u27e7`:0 := commutator (x,y)\n\ndef commutators_of {\u03b1 : Type*} [group \u03b1] (s : set \u03b1) : set \u03b1 :=\ngroup.closure $ commutator '' s.prod s\n\n/-- the derived subgroup of commutator subgroup is the subgroup generated by all commutators -/\ndef derived_subgroup (\u03b1 : Type*) [group \u03b1] : set \u03b1 :=\ncommutators_of set.univ\n\ninstance (\u03b1 : Type*) [group \u03b1] : normal_subgroup (derived_subgroup \u03b1) :=\nbegin\n  apply closure.normal_subgroup, intros x hx g, rcases hx with \u27e8\u27e8y, z\u27e9, h, rfl\u27e9,\n  use \u27e8g * y * g\u207b\u00b9, g * z * g\u207b\u00b9\u27e9,\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 (\u03b1 : Type*) [group \u03b1] (n : \u2115) : set \u03b1 :=\nnat.iterate commutators_of n set.univ\n\n/-- the abelianization of G is the group G quotiented by its derived subgroup -/\ndef abelianization (\u03b1 : Type*) [group \u03b1] : Group :=\nmk_ob $ quotient_group.quotient $ derived_subgroup \u03b1\n\n/-- A group is called perfect if its derived subgroup is the whole group -/\ndef is_perfect (\u03b1 : Type*) [group \u03b1] : Prop := derived_subgroup \u03b1 = set.univ\n\n/-- A group is called solvable if its derived series eventually becomes trivial -/\ndef is_solvable (\u03b1 : Type*) [group \u03b1] : Prop := \u2203 n, iterated_derived_subgroup \u03b1 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 : \u2115)\n\n/-- Constant multivariate functor -/\n@[nolint unused_arguments]\ndef const (A : Type*) (v : typevec.{u} n) : Type* :=\nA\n\ninstance const.inhabited {A \u03b1} [inhabited A] : inhabited (const n A \u03b1) :=\n\u27e8 (default : A) \u27e9\n\nnamespace const\nopen mvfunctor mvpfunctor\nvariables {n} {A : Type u} {\u03b1 \u03b2 : typevec.{u} n} (f : \u03b1 \u27f9 \u03b2)\n\n/-- Constructor for constant functor -/\nprotected def mk (x : A) : (const n A) \u03b1 := x\n\n/-- Destructor for constant functor -/\nprotected def get (x : (const n A) \u03b1) : A := x\n\n@[simp] protected lemma mk_get (x : (const n A) \u03b1) : const.mk (const.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : A) : const.get (const.mk x : const n A \u03b1) = x := rfl\n\n/-- `map` for constant functor -/\nprotected def map : (const n A) \u03b1 \u2192 (const n A) \u03b2 :=\n\u03bb x, x\n\ninstance : mvfunctor (const n A) :=\n{ map := \u03bb \u03b1 \u03b2 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) \u03b1) :\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       := \u03bb \u03b1 x, mvpfunctor.const.get x,\n  repr      := \u03bb \u03b1 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 \u2192 C \u2192 C)\n-- curried tensor product of morphisms:\n(tensor_hom               : \u03a0 {X\u2081 Y\u2081 X\u2082 Y\u2082 : C}, hom X\u2081 Y\u2081 \u2192 hom X\u2082 Y\u2082 \u2192 hom (tensor_obj X\u2081 X\u2082) (tensor_obj Y\u2081 Y\u2082))\n-- tensor product laws:\n(tensor_map_id'           : \u2200 (X\u2081 X\u2082 : C), tensor_hom (\ud835\udfd9 X\u2081) (\ud835\udfd9 X\u2082) = \ud835\udfd9 (tensor_obj X\u2081 X\u2082) . obviously)\n(tensor_map_comp'         : \u2200 {X\u2081 Y\u2081 Z\u2081 X\u2082 Y\u2082 Z\u2082 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (g\u2081 : Y\u2081 \u27f6 Z\u2081) (g\u2082 : Y\u2082 \u27f6 Z\u2082),\n  tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082) = (tensor_hom f\u2081 f\u2082) \u226b (tensor_hom g\u2081 g\u2082) . obviously)\n-- tensor unit:\n(tensor_unit              : C)\n-- associator:\n(associator               : \u03a0 X Y Z : C, (tensor_obj (tensor_obj X Y) Z) \u2245 (tensor_obj X (tensor_obj Y Z)))\n(associator_naturality'   : assoc_natural tensor_obj @tensor_hom associator . obviously)\n-- left unitor:\n(left_unitor              : \u03a0 X : C, tensor_obj tensor_unit X \u2245 X)\n(left_unitor_naturality'  : left_unitor_natural tensor_obj @tensor_hom tensor_unit left_unitor . obviously)\n-- right unitor:\n(right_unitor             : \u03a0 X : C, tensor_obj X tensor_unit \u2245 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 \u2245 X :=\n{ hom := \ud835\udfd9 X,\n  inv := \ud835\udfd9 X }\n\ndef tensor_iso {C : Sort u} {X Y X' Y' : C} [monoidal_category.{v} C] (f : X \u2245 Y) (g : X' \u2245 Y') :\n    tensor_obj X X' \u2245 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) [\ud835\udc9e : monoidal_category.{v} C]\ninclude \ud835\udc9e\n\ninstance : category C := \ud835\udc9e.to_category\n\ninfixr ` \u2297 `:80 := tensor_obj\ninfixr ` \u2297 `:80 := tensor_hom\ninfixr ` \u2297 `:80 := tensor_iso\n\nvariables {U V W X Y Z : C}\n\n@[search] definition interchange (f : U \u27f6 V) (g : V \u27f6 W) (h : X \u27f6 Y) (k : Y \u27f6 Z)\n  : (f \u226b g) \u2297 (h \u226b k) = (f \u2297 h) \u226b (g \u2297 k) :=\ntensor_map_comp C f h g k\n\n@[simp,search] lemma interchange_left_identity (f : W \u27f6 X) (g : X \u27f6 Y) :\n  (f \u2297 (\ud835\udfd9 Z)) \u226b (g \u2297 (\ud835\udfd9 Z)) = (f \u226b g) \u2297 (\ud835\udfd9 Z) :=\nbegin\n  rw \u2190interchange,\n  simp\nend\n\n@[simp,search] lemma interchange_right_identity (f : W \u27f6 X) (g : X \u27f6 Y) :\n  (\ud835\udfd9 Z \u2297 f) \u226b (\ud835\udfd9 Z \u2297 g) = (\ud835\udfd9 Z) \u2297 (f \u226b g) :=\nbegin\n  rw \u2190interchange,\n  simp\nend\n\n@[search] lemma interchange_identities (f : W \u27f6 X) (g : Y \u27f6 Z) :\n  ((\ud835\udfd9 Y) \u2297 f) \u226b (g \u2297 (\ud835\udfd9 X)) = (g \u2297 (\ud835\udfd9 W)) \u226b ((\ud835\udfd9 Z) \u2297 f) :=\nbegin\n  rw \u2190interchange,\n  rw \u2190interchange,\n  simp\nend\n\ninstance tensor_iso_of_iso\n    {X Y X' Y' : C} (f : X \u27f6 Y) (g : X' \u27f6 Y')\n    [is_iso f] [is_iso g] : is_iso (f \u2297 g) :=\n{ inv := (is_iso.inv f) \u2297 (is_iso.inv g) }\n\n@[simp,search] lemma tensor_left_equiv\n    {X Y : C} (f g : X \u27f6 Y) :\n    ((\ud835\udfd9 (tensor_unit C)) \u2297 f = (\ud835\udfd9 (tensor_unit C)) \u2297 g) \u2194 (f = g) :=\nsorry\n\n@[simp,search] lemma tensor_right_equiv\n    {X Y : C} (f g : X \u27f6 Y) :\n    (f \u2297 (\ud835\udfd9 (tensor_unit C)) = g \u2297 (\ud835\udfd9 (tensor_unit C))) \u2194 (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 \u2297 (\ud835\udfd9 Y)) \u226b\n    (associator (tensor_unit C) ((tensor_unit C) \u2297 X) Y).hom \u226b\n    ((\ud835\udfd9 (tensor_unit C)) \u2297 (associator (tensor_unit C) X Y).hom) \u226b\n    ((\ud835\udfd9 (tensor_unit C)) \u2297 (left_unitor (X \u2297 Y)).hom)\n  = (((right_unitor (tensor_unit C)).hom \u2297 (\ud835\udfd9 X)) \u2297 (\ud835\udfd9 Y)) \u226b\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 \u2297 (\ud835\udfd9 Y)) \u226b\n    (((\ud835\udfd9 (tensor_unit C)) \u2297 (left_unitor X).hom) \u2297 (\ud835\udfd9 Y))\n  = ((right_unitor (tensor_unit C)).hom \u2297 (\ud835\udfd9 X)) \u2297 (\ud835\udfd9 Y) := by obviously\n\n@[search] lemma left_unitor_product_aux_square (X Y : C) :\n    (associator (tensor_unit C) ((tensor_unit C) \u2297 X) Y).hom \u226b\n    ((\ud835\udfd9 (tensor_unit C)) \u2297 (left_unitor X).hom \u2297 (\ud835\udfd9 Y))\n  = (((\ud835\udfd9 (tensor_unit C)) \u2297 (left_unitor X).hom) \u2297 (\ud835\udfd9 Y)) \u226b\n    (associator (tensor_unit C) X Y).hom := by obviously\n\n@[search] lemma left_unitor_product_aux (X Y : C) :\n    ((\ud835\udfd9 (tensor_unit C)) \u2297 (associator (tensor_unit C) X Y).hom) \u226b\n    ((\ud835\udfd9 (tensor_unit C)) \u2297 (left_unitor (X \u2297 Y)).hom)\n  = (\ud835\udfd9 (tensor_unit C)) \u2297 ((left_unitor X).hom \u2297 (\ud835\udfd9 Y)) :=\nbegin\n  rw <-(cancel_epi (associator (tensor_unit C) ((tensor_unit C) \u2297 X) Y).hom),\n  rw left_unitor_product_aux_square,\n  rw <-(cancel_epi ((associator (tensor_unit C) (tensor_unit C) X).hom \u2297 (\ud835\udfd9 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 \u2297 (\ud835\udfd9 (tensor_unit C))) \u226b\n    (associator X (Y \u2297 (tensor_unit C)) (tensor_unit C)).hom \u226b\n    ((\ud835\udfd9 X) \u2297 (associator Y (tensor_unit C) (tensor_unit C)).hom) \u226b\n    ((\ud835\udfd9 X) \u2297 (\ud835\udfd9 Y) \u2297 (left_unitor (tensor_unit C)).hom)\n  = ((right_unitor (X \u2297 Y)).hom \u2297 (\ud835\udfd9 (tensor_unit C))) \u226b\n    (associator X Y (tensor_unit C)).hom := by obviously\n\n@[search] lemma right_unitor_product_aux_triangle (X Y : C) :\n    ((\ud835\udfd9 X) \u2297 (associator Y (tensor_unit C) (tensor_unit C)).hom) \u226b\n    ((\ud835\udfd9 X) \u2297 (\ud835\udfd9 Y) \u2297 (left_unitor (tensor_unit C)).hom)\n  = (\ud835\udfd9 X) \u2297 (right_unitor Y).hom \u2297 (\ud835\udfd9 (tensor_unit C)) := by obviously\n\n@[search] lemma right_unitor_product_aux_square (X Y : C) :\n    (associator X (Y \u2297 (tensor_unit C)) (tensor_unit C)).hom \u226b\n    ((\ud835\udfd9 X) \u2297 (right_unitor Y).hom \u2297 (\ud835\udfd9 (tensor_unit C)))\n  = (((\ud835\udfd9 X) \u2297 (right_unitor Y).hom) \u2297 (\ud835\udfd9 (tensor_unit C))) \u226b\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 \u2297 (\ud835\udfd9 (tensor_unit C))) \u226b\n    (((\ud835\udfd9 X) \u2297 (right_unitor Y).hom) \u2297 (\ud835\udfd9 (tensor_unit C)))\n  = ((right_unitor (X \u2297 Y)).hom \u2297 (\ud835\udfd9 (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) \u226b\n    ((left_unitor (X \u2297 Y)).hom)\n  = ((left_unitor X).hom \u2297 (\ud835\udfd9 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) \u226b\n    ((\ud835\udfd9 X) \u2297 (right_unitor Y).hom)\n  = ((right_unitor (X \u2297 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) [\ud835\udc9e : monoidal_category.{v+1} C]\ninclude \ud835\udc9e\n\n@[reducible] def monoidal_category.tensor : (C \u00d7 C) \u2964 C :=\n{ obj := \u03bb X, tensor_obj X.1 X.2,\n  map := \u03bb {X Y : C \u00d7 C} (f : X \u27f6 Y), tensor_hom f.1 f.2 }\n\n@[reducible] def monoidal_category.left_assoc_functor : (C \u00d7 C \u00d7 C) \u2964 C :=\n{ obj := \u03bb X, (X.1 \u2297 X.2.1) \u2297 X.2.2,\n  map := \u03bb {X Y : C \u00d7 C \u00d7 C} (f : X \u27f6 Y),\n    (f.1 \u2297 f.2.1) \u2297 f.2.2 }\n@[reducible] def monoidal_category.right_assoc_functor : (C \u00d7 C \u00d7 C) \u2964 C :=\n{ obj := \u03bb X, X.1 \u2297 (X.2.1 \u2297 X.2.2),\n  map := \u03bb {X Y : C \u00d7 C \u00d7 C} (f : X \u27f6 Y),\n    f.1 \u2297 (f.2.1 \u2297 f.2.2) }\n@[reducible] def monoidal_category.left_unitor_functor : C \u2964 C :=\n{ obj := \u03bb X, tensor_unit C \u2297 X,\n  map := \u03bb {X Y : C} (f : X \u27f6 Y), (\ud835\udfd9 (tensor_unit C)) \u2297 f }\n@[reducible] def monoidal_category.right_unitor_functor : C \u2964 C :=\n{ obj := \u03bb X, X \u2297 tensor_unit C,\n  map := \u03bb {X Y : C} (f : X \u27f6 Y), f \u2297 (\ud835\udfd9 (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 \u2245 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 \u2245 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 \u2245 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\u00e9mi Bottinelli. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: R\u00e9mi 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 `\ud835\udfd9 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 : \u2200 c d : C, Set (c \u27f6 d)\n  inv : \u2200 {c d} {p : c \u27f6 d} (hp : p \u2208 arrows c d), inv p \u2208 arrows d c\n  mul : \u2200 {c d e} {p} (hp : p \u2208 arrows c d) {q} (hq : q \u2208 arrows d e), p \u226b q \u2208 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 \u27f6 d) : inv f \u2208 S.arrows d c \u2194 f \u2208 S.arrows c d :=\n  by\n  constructor\n  \u00b7 rintro h\n    suffices inv (inv f) \u2208 S.arrows c d by simpa only [inv_eq_inv, is_iso.inv_inv] using this\n    \u00b7 apply S.inv h\n  \u00b7 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 \u27f6 d} {g : d \u27f6 e} (hf : f \u2208 S.arrows c d) :\n    f \u226b g \u2208 S.arrows c e \u2194 g \u2208 S.arrows d e :=\n  by\n  constructor\n  \u00b7 rintro h\n    suffices inv f \u226b f \u226b g \u2208 S.arrows d e by\n      simpa only [inv_eq_inv, is_iso.inv_hom_id_assoc] using this\n    \u00b7 apply S.mul (S.inv hf) h\n  \u00b7 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 \u27f6 d} {g : d \u27f6 e} (hg : g \u2208 S.arrows d e) :\n    f \u226b g \u2208 S.arrows c e \u2194 f \u2208 S.arrows c d :=\n  by\n  constructor\n  \u00b7 rintro h\n    suffices (f \u226b g) \u226b inv g \u2208 S.arrows c d by\n      simpa only [inv_eq_inv, is_iso.hom_inv_id, category.comp_id, category.assoc] using this\n    \u00b7 apply S.mul h (S.inv hg)\n  \u00b7 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 \u27f6 d} (h : f \u2208 S.arrows c d) : c \u2208 S.objs :=\n  \u27e8f \u226b inv f, S.mul h (S.inv h)\u27e9\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 \u27f6 d} (h : f \u2208 S.arrows c d) : d \u2208 S.objs :=\n  \u27e8inv f \u226b f, S.mul (S.inv h) h\u27e9\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 \u2208 objs S \u2192 \ud835\udfd9 c \u2208 S.arrows c c :=\n  by\n  rintro \u27e8\u03b3, h\u03b3\u27e9\n  convert S.mul h\u03b3 (S.inv h\u03b3)\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 \u27f6 d} (h : f \u2208 S.arrows c d) : \ud835\udfd9 c \u2208 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 \u27f6 d} (h : f \u2208 S.arrows c d) : \ud835\udfd9 d \u2208 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  \u27e8fun c d => Subtype <| S.arrows c d\u27e9\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 := \u27e8\ud835\udfd9 a.val, id_mem_of_nonempty_isotropy S a.val a.Prop\u27e9\n  comp a b c p q := \u27e8p.val \u226b q.val, S.mul p.Prop q.Prop\u27e9\n  id_comp' := fun a b \u27e8p, hp\u27e9 => by simp only [category.id_comp]\n  comp_id' := fun a b \u27e8p, hp\u27e9 => by simp only [category.comp_id]\n  assoc' := fun a b c d \u27e8p, hp\u27e9 \u27e8q, hq\u27e9 \u27e8r, hr\u27e9 => by simp only [category.assoc]\n  inv a b p := \u27e8inv p.val, S.inv p.Prop\u27e9\n  inv_comp' := fun a b \u27e8p, hp\u27e9 => by simp only [inv_comp]\n  comp_inv' := fun a b \u27e8p, hp\u27e9 => 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 \u27f6 d) :\n    (CategoryTheory.inv p).val = CategoryTheory.inv p.val := by\n  simp only [Subtype.val_eq_coe, \u2190 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 \u2964 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 \u27e8c, hc\u27e9 \u27e8d, hd\u27e9 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 : \u2200 c d, Function.Injective fun f : c \u27f6 d => (hom S).map f :=\n  by\n  rintro \u27e8c, hc\u27e9 \u27e8d, hd\u27e9 \u27e8f, hf\u27e9 \u27e8g, hg\u27e9 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 \u2208 S.objs) : Subgroup (c \u27f6 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) (\u03a3c d : C, c \u27f6 d)\n    where\n  coe S := { F | F.2.2 \u2208 S.arrows F.1 F.2.1 }\n  coe_injective' := fun \u27e8S, _, _\u27e9 \u27e8T, _, _\u27e9 h =>\n    by\n    ext (c d f)\n    apply Set.ext_iff.1 h \u27e8c, d, f\u27e9\n\ntheorem mem_iff (S : Subgroupoid C) (F : \u03a3c d, c \u27f6 d) : F \u2208 S \u2194 F.2.2 \u2208 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 \u2264 T \u2194 \u2200 {c d}, S.arrows c d \u2286 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  \u27e8{  arrows := fun _ _ => Set.univ\n      mul := by\n        rintro\n        trivial\n      inv := by\n        rintro\n        trivial }\u27e9\n\ntheorem mem_top {c d : C} (f : c \u27f6 d) : f \u2208 (\u22a4 : 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 \u2208 (\u22a4 : 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  \u27e8{  arrows := fun _ _ => \u2205\n      mul := fun _ _ _ _ => False.elim\n      inv := fun _ _ _ => False.elim }\u27e9\n\ninstance : Inhabited (Subgroupoid C) :=\n  \u27e8\u22a4\u27e9\n\ninstance : Inf (Subgroupoid C) :=\n  \u27e8fun S T =>\n    { arrows := fun c d => S.arrows c d \u2229 T.arrows c d\n      inv := by\n        rintro\n        exact \u27e8S.inv hp.1, T.inv hp.2\u27e9\n      mul := by\n        rintro\n        exact \u27e8S.mul hp.1 hq.1, T.mul hp.2 hq.2\u27e9 }\u27e9\n\ninstance : InfSet (Subgroupoid C) :=\n  \u27e8fun s =>\n    { arrows := fun c d => \u22c2 S \u2208 s, Subgroupoid.arrows S c d\n      inv := by\n        intros\n        rw [mem_Inter\u2082] at hp\u22a2\n        exact fun S hS => S.inv (hp S hS)\n      mul := by\n        intros\n        rw [mem_Inter\u2082] at hp hq\u22a2\n        exact fun S hS => S.mul (hp S hS) (hq S hS) }\u27e9\n\ninstance : CompleteLattice (Subgroupoid C) :=\n  {\n    completeLatticeOfInf (Subgroupoid C)\n      (by\n        refine' fun s => \u27e8fun S Ss F => _, fun T Tl F fT => _\u27e9 <;>\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 := \u22a5\n    bot_le := fun S => empty_subset _\n    top := \u22a4\n    le_top := fun S => subset_univ _\n    inf := (\u00b7 \u2293 \u00b7)\n    le_inf := fun R S T RS RT _ pR => \u27e8RS pR, RT pR\u27e9\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 \u2264 T) : S.objs \u2286 T.objs := fun s \u27e8\u03b3, h\u03b3\u27e9 =>\n  \u27e8\u03b3, @h \u27e8s, s, \u03b3\u27e9 h\u03b3\u27e9\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 \u2264 T) : S.objs \u2964 T.objs\n    where\n  obj s := \u27e8s.val, le_objs h s.Prop\u27e9\n  map s t f := \u27e8f.val, @h \u27e8s, t, f.val\u27e9 f.Prop\u27e9\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 \u2264 T) :\n    Function.Injective (inclusion h).obj := fun \u27e8s, hs\u27e9 \u27e8t, ht\u27e9 => 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 \u2264 T) (s t : S.objs) :\n    Function.Injective fun f : s \u27f6 t => (inclusion h).map f := fun \u27e8f, hf\u27e9 \u27e8g, hg\u27e9 =>\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) = \ud835\udfed S.objs :=\n  Functor.hext (fun \u27e8s, hs\u27e9 => rfl) fun \u27e8s, hs\u27e9 \u27e8t, ht\u27e9 \u27e8f, hf\u27e9 => 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 \u2264 S) (h : S \u2264 T) :\n    inclusion (k.trans h) = inclusion k \u22d9 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 \u2264 T) : inclusion h \u22d9 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 : \u2200 c d : C, (c \u27f6 d) \u2192 Prop\n  | id (c : C) : discrete.arrows c c (\ud835\udfd9 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 _ _ _ \u27e8\u27e9\n    simp only [inv_eq_inv, is_iso.inv_id]\n    constructor\n  mul := by\n    rintro _ _ _ _ \u27e8\u27e9 _ \u27e8\u27e9\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 \u27f6 d) :\n    f \u2208 discrete.arrows c d \u2194 \u2203 h : c = d, f = eqToHom h :=\n  \u27e8by\n    rintro \u27e8\u27e9\n    exact \u27e8rfl, rfl\u27e9, by\n    rintro \u27e8rfl, rfl\u27e9\n    constructor\u27e9\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 : \u2200 c, \ud835\udfd9 c \u2208 S.arrows c c\n#align category_theory.subgroupoid.is_wide CategoryTheory.Subgroupoid.IsWide\n\ntheorem isWide_iff_objs_eq_univ : S.IsWide \u2194 S.objs = Set.univ :=\n  by\n  constructor\n  \u00b7 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  \u00b7 rintro h\n    refine' \u27e8fun c => _\u27e9\n    obtain \u27e8\u03b3, \u03b3S\u27e9 := (le_of_eq h.symm : \u22a4 \u2286 S.objs) (Set.mem_univ c)\n    exact id_mem_of_src S \u03b3S\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) : \ud835\udfd9 c \u2208 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 \u2208 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\u00a0subgroupoid is normal if it is wide and satisfies the expected stability under conjugacy. -/\nstructure IsNormal extends IsWide S : Prop where\n  conj : \u2200 {c d} (p : c \u27f6 d) {\u03b3 : c \u27f6 c} (hs : \u03b3 \u2208 S.arrows c c), inv p \u226b \u03b3 \u226b p \u2208 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    \u2200 {c d} (p : d \u27f6 c) {\u03b3 : c \u27f6 c} (hs : \u03b3 \u2208 S.arrows c c), p \u226b \u03b3 \u226b inv p \u2208 S.arrows d d :=\n  fun c d p \u03b3 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 \u27f6 d) :\n    Set.BijOn (fun \u03b3 : c \u27f6 c => inv p \u226b \u03b3 \u226b p) (S.arrows c c) (S.arrows d d) :=\n  by\n  refine'\n    \u27e8fun \u03b3 \u03b3S => Sn.conj p \u03b3S, fun \u03b3\u2081 \u03b3\u2081S \u03b3\u2082 \u03b3\u2082S h => _, fun \u03b4 \u03b4S =>\n      \u27e8p \u226b \u03b4 \u226b inv p, Sn.conj' p \u03b4S, _\u27e9\u27e9\n  \u00b7\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 \u226b= h =\u226b inv p\n  \u00b7\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 (\u22a4 : 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\u209b_isNormal (s : Set <| Subgroupoid C) (sn : \u2200 S \u2208 s, IsNormal S) : IsNormal (inf\u209b s) :=\n  { wide := by\n      simp_rw [Inf, mem_Inter\u2082]\n      exact fun c S Ss => (sn S Ss).wide c\n    conj := by\n      simp_rw [Inf, mem_Inter\u2082]\n      exact fun c d p \u03b3 h\u03b3 S Ss => (sn S Ss).conj p (h\u03b3 S Ss) }\n#align category_theory.subgroupoid.Inf_is_normal CategoryTheory.Subgroupoid.inf\u209b_isNormal\n\ntheorem discrete_isNormal : (@discrete C _).IsNormal :=\n  { wide := fun c => by constructor\n    conj := fun c d f \u03b3 h\u03b3 => by\n      cases h\u03b3\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 \u2208 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:\u00a0proof that generated is just \"words in X\" and generated_normal is similarly\nvariable (X : \u2200 c d : C, Set (c \u27f6 d))\n\n/-- The subgropoid generated by the set of arrows `X` -/\ndef generated : Subgroupoid C :=\n  inf\u209b { S : Subgroupoid C | \u2200 c d, X c d \u2286 S.arrows c d }\n#align category_theory.subgroupoid.generated CategoryTheory.Subgroupoid.generated\n\ntheorem subset_generated (c d : C) : X c d \u2286 (generated X).arrows c d :=\n  by\n  dsimp only [generated, Inf]\n  simp only [subset_Inter\u2082_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\u209b { S : Subgroupoid C | (\u2200 c d, X c d \u2286 S.arrows c d) \u2227 S.IsNormal }\n#align category_theory.subgroupoid.generated_normal CategoryTheory.Subgroupoid.generatedNormal\n\ntheorem generated_le_generatedNormal : generated X \u2264 generatedNormal X :=\n  by\n  apply @inf\u209b_le_inf\u209b (subgroupoid C) _\n  exact fun S \u27e8h, _\u27e9 => h\n#align category_theory.subgroupoid.generated_le_generated_normal CategoryTheory.Subgroupoid.generated_le_generatedNormal\n\ntheorem generatedNormal_isNormal : (generatedNormal X).IsNormal :=\n  inf\u209b_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 \u2264 S \u2194 \u2200 c d, X c d \u2286 S.arrows c d :=\n  by\n  constructor\n  \u00b7 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  \u00b7 rintro h\n    apply @inf\u209b_le (subgroupoid C) _\n    exact \u27e8h, Sn\u27e9\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] (\u03c6 : C \u2964 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 \u27f6 d | \u03c6.map f \u2208 S.arrows (\u03c6.obj c) (\u03c6.obj d) }\n  inv c d p hp := by\n    rw [mem_set_of, inv_eq_inv, \u03c6.map_inv p, \u2190 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 \u2264 T \u2192 comap \u03c6 S \u2264 comap \u03c6 T := fun ST \u27e8c, d, p\u27e9 =>\n  @ST \u27e8_, _, _\u27e9\n#align category_theory.subgroupoid.comap_mono CategoryTheory.Subgroupoid.comap_mono\n\ntheorem isNormal_comap {S : Subgroupoid D} (Sn : IsNormal S) : IsNormal (comap \u03c6 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 \u03b3 h\u03b3 =>\n      by\n      simp_rw [inv_eq_inv f, comap, mem_set_of, functor.map_comp, functor.map_inv, \u2190 inv_eq_inv]\n      exact Sn.conj _ h\u03b3 }\n#align category_theory.subgroupoid.is_normal_comap CategoryTheory.Subgroupoid.isNormal_comap\n\n@[simp]\ntheorem comap_comp {E : Type _} [Groupoid E] (\u03c8 : D \u2964 E) : comap (\u03c6 \u22d9 \u03c8) = comap \u03c6 \u2218 comap \u03c8 :=\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 \u03c6 discrete\n#align category_theory.subgroupoid.ker CategoryTheory.Subgroupoid.ker\n\ntheorem mem_ker_iff {c d : C} (f : c \u27f6 d) :\n    f \u2208 (ker \u03c6).arrows c d \u2194 \u2203 h : \u03c6.obj c = \u03c6.obj d, \u03c6.map f = eqToHom h :=\n  mem_discrete_iff (\u03c6.map f)\n#align category_theory.subgroupoid.mem_ker_iff CategoryTheory.Subgroupoid.mem_ker_iff\n\ntheorem ker_isNormal : (ker \u03c6).IsNormal :=\n  isNormal_comap \u03c6 discrete_isNormal\n#align category_theory.subgroupoid.ker_is_normal CategoryTheory.Subgroupoid.ker_isNormal\n\n@[simp]\ntheorem ker_comp {E : Type _} [Groupoid E] (\u03c8 : D \u2964 E) : ker (\u03c6 \u22d9 \u03c8) = comap \u03c6 (ker \u03c8) :=\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\u03c6 : Function.Injective \u03c6.obj) (S : Subgroupoid C) : \u2200 c d : D, (c \u27f6 d) \u2192 Prop\n  | im {c d : C} (f : c \u27f6 d) (hf : f \u2208 S.arrows c d) : map.arrows (\u03c6.obj c) (\u03c6.obj d) (\u03c6.map f)\n#align category_theory.subgroupoid.map.arrows CategoryTheory.Subgroupoid.Map.Arrows\n\ntheorem Map.arrows_iff (h\u03c6 : Function.Injective \u03c6.obj) (S : Subgroupoid C) {c d : D} (f : c \u27f6 d) :\n    Map.Arrows \u03c6 h\u03c6 S c d f \u2194\n      \u2203 (a b : C)(g : a \u27f6 b)(ha : \u03c6.obj a = c)(hb : \u03c6.obj b = d)(hg : g \u2208 S.arrows a b),\n        f = eqToHom ha.symm \u226b \u03c6.map g \u226b eqToHom hb :=\n  by\n  constructor\n  \u00b7 rintro \u27e8g, hg\u27e9\n    exact \u27e8_, _, g, rfl, rfl, hg, eq_conj_eq_to_hom _\u27e9\n  \u00b7 rintro \u27e8a, b, g, rfl, rfl, hg, rfl\u27e9\n    rw [\u2190 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\u03c6 : Function.Injective \u03c6.obj) (S : Subgroupoid C) : Subgroupoid D\n    where\n  arrows := Map.Arrows \u03c6 h\u03c6 S\n  inv := by\n    rintro _ _ _ \u27e8\u27e9\n    rw [inv_eq_inv, \u2190 functor.map_inv, \u2190 inv_eq_inv]\n    constructor; apply S.inv; assumption\n  mul := by\n    rintro _ _ _ _ \u27e8f, hf\u27e9 q hq\n    obtain \u27e8c\u2083, c\u2084, g, he, rfl, hg, gq\u27e9 := (map.arrows_iff \u03c6 h\u03c6 S q).mp hq\n    cases h\u03c6 he; rw [gq, \u2190 eq_conj_eq_to_hom, \u2190 \u03c6.map_comp]\n    constructor; exact S.mul hf hg\n#align category_theory.subgroupoid.map CategoryTheory.Subgroupoid.map\n\ntheorem mem_map_iff (h\u03c6 : Function.Injective \u03c6.obj) (S : Subgroupoid C) {c d : D} (f : c \u27f6 d) :\n    f \u2208 (map \u03c6 h\u03c6 S).arrows c d \u2194\n      \u2203 (a b : C)(g : a \u27f6 b)(ha : \u03c6.obj a = c)(hb : \u03c6.obj b = d)(hg : g \u2208 S.arrows a b),\n        f = eqToHom ha.symm \u226b \u03c6.map g \u226b eqToHom hb :=\n  Map.arrows_iff \u03c6 h\u03c6 S f\n#align category_theory.subgroupoid.mem_map_iff CategoryTheory.Subgroupoid.mem_map_iff\n\ntheorem galoisConnection_map_comap (h\u03c6 : Function.Injective \u03c6.obj) :\n    GaloisConnection (map \u03c6 h\u03c6) (comap \u03c6) :=\n  by\n  rintro S T; simp_rw [le_iff]; constructor\n  \u00b7 exact fun h c d f fS => h (map.arrows.im f fS)\n  \u00b7 rintro h _ _ g \u27e8a, g\u03c6S\u27e9\n    exact h g\u03c6S\n#align category_theory.subgroupoid.galois_connection_map_comap CategoryTheory.Subgroupoid.galoisConnection_map_comap\n\ntheorem map_mono (h\u03c6 : Function.Injective \u03c6.obj) (S T : Subgroupoid C) :\n    S \u2264 T \u2192 map \u03c6 h\u03c6 S \u2264 map \u03c6 h\u03c6 T := fun h => (galoisConnection_map_comap \u03c6 h\u03c6).monotone_l h\n#align category_theory.subgroupoid.map_mono CategoryTheory.Subgroupoid.map_mono\n\ntheorem le_comap_map (h\u03c6 : Function.Injective \u03c6.obj) (S : Subgroupoid C) :\n    S \u2264 comap \u03c6 (map \u03c6 h\u03c6 S) :=\n  (galoisConnection_map_comap \u03c6 h\u03c6).le_u_l S\n#align category_theory.subgroupoid.le_comap_map CategoryTheory.Subgroupoid.le_comap_map\n\ntheorem map_comap_le (h\u03c6 : Function.Injective \u03c6.obj) (T : Subgroupoid D) :\n    map \u03c6 h\u03c6 (comap \u03c6 T) \u2264 T :=\n  (galoisConnection_map_comap \u03c6 h\u03c6).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\u03c6 : Function.Injective \u03c6.obj) (S : Subgroupoid C)\n    (T : Subgroupoid D) : map \u03c6 h\u03c6 S \u2264 T \u2194 S \u2264 comap \u03c6 T :=\n  (galoisConnection_map_comap \u03c6 h\u03c6).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\u03c6 : Function.Injective \u03c6.obj) (d : D) :\n    d \u2208 (map \u03c6 h\u03c6 S).objs \u2194 \u2203 c \u2208 S.objs, \u03c6.obj c = d :=\n  by\n  dsimp [objs, map]\n  constructor\n  \u00b7 rintro \u27e8f, hf\u27e9\n    change map.arrows \u03c6 h\u03c6 S d d f at hf\n    rw [map.arrows_iff] at hf\n    obtain \u27e8c, d, g, ec, ed, eg, gS, eg\u27e9 := hf\n    exact \u27e8c, \u27e8mem_objs_of_src S eg, ec\u27e9\u27e9\n  \u00b7 rintro \u27e8c, \u27e8\u03b3, \u03b3S\u27e9, rfl\u27e9\n    exact \u27e8\u03c6.map \u03b3, \u27e8\u03b3, \u03b3S\u27e9\u27e9\n#align category_theory.subgroupoid.mem_map_objs_iff CategoryTheory.Subgroupoid.mem_map_objs_iff\n\n@[simp]\ntheorem map_objs_eq (h\u03c6 : Function.Injective \u03c6.obj) : (map \u03c6 h\u03c6 S).objs = \u03c6.obj '' S.objs :=\n  by\n  ext\n  convert mem_map_objs_iff S \u03c6 h\u03c6 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\u03c6 : Function.Injective \u03c6.obj) :=\n  map \u03c6 h\u03c6 \u22a4\n#align category_theory.subgroupoid.im CategoryTheory.Subgroupoid.im\n\ntheorem mem_im_iff (h\u03c6 : Function.Injective \u03c6.obj) {c d : D} (f : c \u27f6 d) :\n    f \u2208 (im \u03c6 h\u03c6).arrows c d \u2194\n      \u2203 (a b : C)(g : a \u27f6 b)(ha : \u03c6.obj a = c)(hb : \u03c6.obj b = d),\n        f = eqToHom ha.symm \u226b \u03c6.map g \u226b eqToHom hb :=\n  by\n  convert map.arrows_iff \u03c6 h\u03c6 \u22a4 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\u03c6 : Function.Injective \u03c6.obj) (d : D) :\n    d \u2208 (im \u03c6 h\u03c6).objs \u2194 \u2203 c : C, \u03c6.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\u03c6 : Function.Injective \u03c6.obj) (h\u03c6' : im \u03c6 h\u03c6 = \u22a4) :\n    Function.Surjective \u03c6.obj := by\n  rintro d\n  rw [\u2190 mem_im_objs_iff, h\u03c6']\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\u03c6 : Function.Injective \u03c6.obj) (h\u03c6' : im \u03c6 h\u03c6 = \u22a4) (Sn : S.IsNormal) :\n    (map \u03c6 h\u03c6 S).IsNormal :=\n  { wide := fun d => by\n      obtain \u27e8c, rfl\u27e9 := obj_surjective_of_im_eq_top \u03c6 h\u03c6 h\u03c6' d\n      change map.arrows \u03c6 h\u03c6 S _ _ (\ud835\udfd9 _)\n      rw [\u2190 Functor.map_id]\n      constructor\n      exact Sn.wide c\n    conj := fun d d' g \u03b4 h\u03b4 => by\n      rw [mem_map_iff] at h\u03b4\n      obtain \u27e8c, c', \u03b3, cd, cd', \u03b3S, h\u03b3\u27e9 := h\u03b4\n      subst_vars\n      cases h\u03c6 cd'\n      have : d' \u2208 (im \u03c6 h\u03c6).objs := by\n        rw [h\u03c6']\n        apply mem_top_objs\n      rw [mem_im_objs_iff] at this\n      obtain \u27e8c', rfl\u27e9 := this\n      have : g \u2208 (im \u03c6 h\u03c6).arrows (\u03c6.obj c) (\u03c6.obj c') :=\n        by\n        rw [h\u03c6']\n        trivial\n      rw [mem_im_iff] at this\n      obtain \u27e8b, b', f, hb, hb', _, hf\u27e9 := this\n      subst_vars\n      cases h\u03c6 hb\n      cases h\u03c6 hb'\n      change map.arrows \u03c6 h\u03c6 S (\u03c6.obj c') (\u03c6.obj c') _\n      simp only [eq_to_hom_refl, category.comp_id, category.id_comp, inv_eq_inv]\n      suffices map.arrows \u03c6 h\u03c6 S (\u03c6.obj c') (\u03c6.obj c') (\u03c6.map <| inv f \u226b \u03b3 \u226b f)\n        by\n        simp only [inv_eq_inv, functor.map_comp, functor.map_inv] at this\n        exact this\n      \u00b7 constructor\n        apply Sn.conj f \u03b3S }\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 \u2194 \u2200 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 \u2194 \u2200 c d, (S.arrows c d).Nonempty \u2192 c = d :=\n  by\n  constructor\n  \u00b7 rintro h c d \u27e8f, fS\u27e9\n    rw [\u2190 @Subtype.mk_eq_mk _ _ c (mem_objs_of_src S fS) d (mem_objs_of_tgt S fS)]\n    exact h \u27e8c, mem_objs_of_src S fS\u27e9 \u27e8d, mem_objs_of_tgt S fS\u27e9 \u27e8f, fS\u27e9\n  \u00b7 rintro h \u27e8c, hc\u27e9 \u27e8d, hd\u27e9 \u27e8f, fS\u27e9\n    simp only [Subtype.mk_eq_mk]\n    exact h c d \u27e8f, fS\u27e9\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 \u2227 f \u2208 S.arrows c d\n  inv := by\n    rintro _ _ _ \u27e8rfl, h\u27e9\n    exact \u27e8rfl, S.inv h\u27e9\n  mul := by\n    rintro _ _ _ _ \u27e8rfl, h\u27e9 _ \u27e8rfl, h'\u27e9\n    exact \u27e8rfl, S.mul h h'\u27e9\n#align category_theory.subgroupoid.disconnect CategoryTheory.Subgroupoid.disconnect\n\ntheorem disconnect_le : S.disconnect \u2264 S := by\n  rw [le_iff]\n  rintro _ _ _ \u27e8\u27e9\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 => \u27e8rfl, Sn.wide c\u27e9\n    conj := fun c d p \u03b3 \u27e8_, h'\u27e9 => \u27e8rfl, Sn.conj _ h'\u27e9 }\n#align category_theory.subgroupoid.disconnect_normal CategoryTheory.Subgroupoid.disconnect_normal\n\n@[simp]\ntheorem mem_disconnect_objs_iff {c : C} : c \u2208 S.disconnect.objs \u2194 c \u2208 S.objs :=\n  \u27e8fun \u27e8\u03b3, h, \u03b3S\u27e9 => \u27e8\u03b3, \u03b3S\u27e9, fun \u27e8\u03b3, \u03b3S\u27e9 => \u27e8\u03b3, rfl, \u03b3S\u27e9\u27e9\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 \u27e8f, h, fS\u27e9 => 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 \u2208 D \u2227 d \u2208 D\n  inv := by\n    rintro _ _ _ \u27e8\u27e9\n    constructor <;> assumption\n  mul := by\n    rintro _ _ _ _ \u27e8\u27e9 _ \u27e8\u27e9\n    constructor <;> assumption\n#align category_theory.subgroupoid.full CategoryTheory.Subgroupoid.full\n\ntheorem full_objs : (full D).objs = D :=\n  Set.ext fun _ => \u27e8fun \u27e8f, h, _\u27e9 => h, fun h => \u27e8\ud835\udfd9 _, h, h\u27e9\u27e9\n#align category_theory.subgroupoid.full_objs CategoryTheory.Subgroupoid.full_objs\n\n@[simp]\ntheorem mem_full_iff {c d : C} {f : c \u27f6 d} : f \u2208 (full D).arrows c d \u2194 c \u2208 D \u2227 d \u2208 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 \u2208 (full D).objs \u2194 c \u2208 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 \u2205 = (\u22a5 : 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 = (\u22a4 : 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 \u2264 E) : full D \u2264 full E :=\n  by\n  rw [le_iff]\n  rintro c d f\n  simp only [mem_full_iff]\n  exact fun \u27e8hc, hd\u27e9 => \u27e8h hc, h hd\u27e9\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 \u27f6 d} : f = g \u2194 (\u2191f : c.val \u27f6 d.val) = \u2191g :=\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 \u2192 pid_t \u2192 ballot_t)\n  (stored : sys_state_t \u2192 pid_t \u2192 slot_t \u2192 option (proposal ballot_t value_t))\n  (proposed : sys_state_t \u2192 slot_t \u2192 ballot_t \u2192 value_t \u2192 Prop)\n  (voted : sys_state_t \u2192 pid_t \u2192 slot_t \u2192 ballot_t \u2192 Prop)\n  (quorum : finset pid_t \u2192 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 \u2192 slot_t \u2192 ballot_t \u2192 Prop :=\n  (\u03bb state slot ballot,\n    \u2203 q : finset pid_t, defs.quorum q \u2227\n      \u2200 voter \u2208 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 \u2192 slot_t \u2192 value_t \u2192 Prop :=\n  (\u03bb state slot value,\n    \u2203 ballot, defs.chosen_ballot state slot ballot \u2227 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 \u00d7 (pid_t \u2192 slot_t \u2192 set (interval ballot_t value_t))) :=\n{ init := (\u03bb hist_state, proto.init hist_state.fst \u2227\n  (\u2200 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 := (\u03bb fst_state snd_state, proto.next fst_state.fst snd_state.fst \u2227\n  (\u2200 p s, snd_state.snd p s = fst_state.snd p s \u222a\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    \u2200 q\u2081 q\u2082, defs.quorum q\u2081 \u2192 defs.quorum q\u2082 \u2192 (q\u2081 \u2229 q\u2082).nonempty)\n  (none_proposed_at_init :\n    \u2200 state slot ballot value, proto.init state \u2192 \u00acdefs.proposed state slot ballot value)\n  (proposed_stable :\n    \u2200 slot ballot value,\n      proto.stable (\u03bb state, defs.proposed state slot ballot value))\n  (proposals_unique :\n    \u2200 slot ballot v\u2081 v\u2082,\n      proto.invariant (\u03bb state,\n        defs.proposed state slot ballot v\u2081 \u2192 defs.proposed state slot ballot v\u2082 \u2192 v\u2081 = v\u2082))\n  (at_most_one_proposal_per_slot_per_step :\n    \u2200 slot s',\n      proto.invariant (\u03bb state,\n        proto.next state s' \u2192\n          \u2203 b v, \u2200 bal val, defs.proposed s' slot bal val \u2192\n                 (defs.proposed state slot bal val \u2228 (bal = b \u2227 val = v))))\n  (curr_increases :\n    \u2200 process s',\n      proto.invariant (\u03bb state,\n        proto.next state s' \u2192 defs.curr state process \u2264 defs.curr s' process))\n  (stored_ballot_increases :\n    \u2200 process slot prop s',\n      proto.invariant (\u03bb state,\n        proto.next state s' \u2192\n          defs.stored state process slot = some prop \u2192\n            \u2203 prop', defs.stored s' process slot = some prop' \u2227 prop.b \u2264 prop'.b))\n  (stored_is_proposed :\n    \u2200 process slot prop,\n      proto.invariant (\u03bb state,\n        defs.stored state process slot = some prop \u2192\n          defs.proposed state slot prop.b prop.v))\n  (new_votes_ge_curr_ballot :\n    \u2200 process slot ballot s',\n      proto.invariant (\u03bb state,\n        proto.next state s' \u2192\n          defs.voted s' process slot ballot \u2192\n            defs.voted state process slot ballot \u2228 defs.curr state process \u2264 ballot))\n  (voted_stable :\n    \u2200 process slot ballot,\n      proto.stable (\u03bb state, defs.voted state process slot ballot))\n  (voted_imp_proposed :\n    \u2200 process slot ballot,\n      proto.invariant (\u03bb state,\n        defs.voted state process slot ballot \u2192\n          \u2203 value, defs.proposed state slot ballot value))\n  (voted_le_stored :\n    \u2200 process slot ballot,\n      proto.invariant (\u03bb state,\n        defs.voted state process slot ballot \u2192\n          \u2203 prop, defs.stored state process slot = some prop \u2227 ballot \u2264 prop.b))\n  (majority_have_upper_interval_if_proposed :\n    \u2200 slot ballot value,\n      (state_with_past_intervals defs proto).invariant (\u03bb state,\n        defs.proposed state.fst slot ballot value \u2192\n        \u2203 (q : finset pid_t)\n             (promised_prop : pid_t \u2192 option (proposal ballot_t value_t)),\n          defs.quorum q \u2227\n          (\u2200 (a \u2208 q),\n            {interval . lower := (promised_prop a), upper := ballot} \u2208 state.snd a slot) \u2227\n          (\u2200 (a \u2208 q) prop_a, promised_prop a = some prop_a \u2192 prop_a.b < ballot) \u2227\n          ((\u2200 (a \u2208 q), promised_prop a = none) \u2228\n           (\u2203 (a \u2208 q) prop_a,\n             promised_prop a = some prop_a \u2227\n             (\u2200 (a' \u2208 q) prop_a', promised_prop a' = some prop_a' \u2192 prop_a'.b \u2264 prop_a.b) \u2227\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 (\u03bb state, (\u2200 slot v v', defs.chosen state slot v \u2192 defs.chosen state slot v' \u2192 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 (\u03bb state, (\u2200 later_state slot v v', proto.reachable_from state later_state \u2192\n                                  defs.chosen state slot v \u2192 defs.chosen later_state slot v' \u2192 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 := \u03bb state p, defs.curr state p,\n  stored := \u03bb state p, defs.stored state p slot,\n  proposed := \u03bb state ballot value, defs.proposed state slot ballot value,\n  voted := \u03bb 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 := \u03bb state ballot value is_init,\n    multipaxos_constraints_met.none_proposed_at_init state slot ballot value is_init,\n  proposed_stable := \u03bb ballot value,\n    multipaxos_constraints_met.proposed_stable slot ballot value,\n  proposals_unique := \u03bb ballot v\u2081 v\u2082,\n    multipaxos_constraints_met.proposals_unique slot ballot v\u2081 v\u2082,\n  at_most_one_proposal_per_step := \u03bb 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 := \u03bb process prop s',\n    multipaxos_constraints_met.stored_ballot_increases process slot prop s',\n  stored_is_proposed := \u03bb process prop,\n    multipaxos_constraints_met.stored_is_proposed process slot prop,\n  new_votes_ge_curr_ballot := \u03bb process ballot s',\n    multipaxos_constraints_met.new_votes_ge_curr_ballot process slot ballot s',\n  voted_stable := \u03bb process ballot,\n    multipaxos_constraints_met.voted_stable process slot ballot,\n  voted_imp_proposed := \u03bb process ballot,\n    multipaxos_constraints_met.voted_imp_proposed process slot ballot,\n  voted_le_stored := \u03bb 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      (\u03bb restricted_state,\n        \u2203 full_state, (multipaxos.state_with_past_intervals defs proto).reachable full_state \u2227\n                      full_state.fst = restricted_state.fst \u2227\n                      restricted_state.snd = \u03bb p, full_state.snd p slot),\n    by {\n      intros ballot value state reachable,\n      rcases key state reachable\n        with \u27e8lift_state, lift_reachable, lift_state_is_lift, lift_snd_restriction_gives_snd\u27e9,\n      rw lift_snd_restriction_gives_snd, rw \u2190 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 \u27e8s.fst, (\u03bb p slot, {{upper := defs.curr s.fst p, lower := defs.stored s.fst p slot}})\u27e9,\n      split,\n      { exact \u27e80, is_init.left, by { intros p slot, refl }\u27e9 },\n      split,\n      { refl },\n      rw function.funext_iff,\n      exact is_init.right },\n    rintros start start_reachable next \u27e8lift_start, lift_reachable, lift_start_is_lift, lift_snd_restriction_gives_snd\u27e9 next_reachable,\n    use \u27e8next.fst, \u03bb p s, lift_start.snd p s \u222a\n                       {{upper := defs.curr next.fst p, lower := defs.stored next.fst p s}}\u27e9,\n    split,\n    { rcases lift_reachable with \u27e8n, hn\u27e9,\n      exact \u27e8n.succ, lift_start, hn, by { rw lift_start_is_lift, exact next_reachable.left },\n            by { intros p s, refl }\u27e9 },\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 \u2192 multipaxos.safety proto defs :=\nbegin\nintro multipaxos_constraints_met,\nsuffices key : \u2200 slot, proto.invariant (\u03bb state, (\u2200 v v', defs.chosen state slot v \u2192 defs.chosen state slot v' \u2192 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 \u2192 multipaxos.safety_v2 proto defs :=\nbegin\nintro multipaxos_constraints_met,\nsuffices key : \u2200 slot, proto.invariant (\u03bb state, (\u2200 later_state v v', proto.reachable_from state later_state \u2192\n                                                    defs.chosen state slot v \u2192 defs.chosen later_state slot v' \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u03b1` explicitly.\n* `Classical.arbitrary`: Extracts a witness of nonemptiness using choice. Takes `Nonempty \u03b1` as an\n  instance.\n-/\n\n\nvariable {\u03b3 : \u03b1 \u2192 Type _}\n\ninstance (priority := 20) Zero.nonempty [Zero \u03b1] : Nonempty \u03b1 :=\n  \u27e80\u27e9\n\ninstance (priority := 20) One.nonempty [One \u03b1] : Nonempty \u03b1 :=\n  \u27e81\u27e9\n\ntheorem exists_true_iff_nonempty {\u03b1 : Sort _} : (\u2203 _ : \u03b1, True) \u2194 Nonempty \u03b1 :=\n  Iff.intro (fun \u27e8a, _\u27e9 \u21a6 \u27e8a\u27e9) fun \u27e8a\u27e9 \u21a6 \u27e8a, trivial\u27e9\n#align exists_true_iff_nonempty exists_true_iff_nonempty\n\n@[simp]\ntheorem nonempty_Prop {p : Prop} : Nonempty p \u2194 p :=\n  Iff.intro (fun \u27e8h\u27e9 \u21a6 h) fun h \u21a6 \u27e8h\u27e9\n#align nonempty_Prop nonempty_Prop\n\ntheorem not_nonempty_iff_imp_false {\u03b1 : Sort _} : \u00acNonempty \u03b1 \u2194 \u03b1 \u2192 False :=\n  \u27e8fun h a \u21a6 h \u27e8a\u27e9, fun h \u27e8a\u27e9 \u21a6 h a\u27e9\n#align not_nonempty_iff_imp_false not_nonempty_iff_imp_false\n\n@[simp]\ntheorem nonempty_sigma : Nonempty (\u03a3a : \u03b1, \u03b3 a) \u2194 \u2203 a : \u03b1, Nonempty (\u03b3 a) :=\n  Iff.intro (fun \u27e8\u27e8a, c\u27e9\u27e9 \u21a6 \u27e8a, \u27e8c\u27e9\u27e9) fun \u27e8a, \u27e8c\u27e9\u27e9 \u21a6 \u27e8\u27e8a, c\u27e9\u27e9\n#align nonempty_sigma nonempty_sigma\n\n@[simp]\ntheorem nonempty_psigma {\u03b1} {\u03b2 : \u03b1 \u2192 Sort _} : Nonempty (PSigma \u03b2) \u2194 \u2203 a : \u03b1, Nonempty (\u03b2 a) :=\n  Iff.intro (fun \u27e8\u27e8a, c\u27e9\u27e9 \u21a6 \u27e8a, \u27e8c\u27e9\u27e9) fun \u27e8a, \u27e8c\u27e9\u27e9 \u21a6 \u27e8\u27e8a, c\u27e9\u27e9\n#align nonempty_psigma nonempty_psigma\n\n@[simp]\ntheorem nonempty_subtype {\u03b1} {p : \u03b1 \u2192 Prop} : Nonempty (Subtype p) \u2194 \u2203 a : \u03b1, p a :=\n  Iff.intro (fun \u27e8\u27e8a, h\u27e9\u27e9 \u21a6 \u27e8a, h\u27e9) fun \u27e8a, h\u27e9 \u21a6 \u27e8\u27e8a, h\u27e9\u27e9\n#align nonempty_subtype nonempty_subtype\n\n@[simp]\ntheorem nonempty_prod : Nonempty (\u03b1 \u00d7 \u03b2) \u2194 Nonempty \u03b1 \u2227 Nonempty \u03b2 :=\n  Iff.intro (fun \u27e8\u27e8a, b\u27e9\u27e9 \u21a6 \u27e8\u27e8a\u27e9, \u27e8b\u27e9\u27e9) fun \u27e8\u27e8a\u27e9, \u27e8b\u27e9\u27e9 \u21a6 \u27e8\u27e8a, b\u27e9\u27e9\n#align nonempty_prod nonempty_prod\n\n@[simp]\ntheorem nonempty_pprod {\u03b1 \u03b2} : Nonempty (PProd \u03b1 \u03b2) \u2194 Nonempty \u03b1 \u2227 Nonempty \u03b2 :=\n  Iff.intro (fun \u27e8\u27e8a, b\u27e9\u27e9 \u21a6 \u27e8\u27e8a\u27e9, \u27e8b\u27e9\u27e9) fun \u27e8\u27e8a\u27e9, \u27e8b\u27e9\u27e9 \u21a6 \u27e8\u27e8a, b\u27e9\u27e9\n#align nonempty_pprod nonempty_pprod\n\n@[simp]\ntheorem nonempty_sum : Nonempty (Sum \u03b1 \u03b2) \u2194 Nonempty \u03b1 \u2228 Nonempty \u03b2 :=\n  Iff.intro\n    (fun \u27e8h\u27e9 \u21a6\n      match h with\n      | Sum.inl a => Or.inl \u27e8a\u27e9\n      | Sum.inr b => Or.inr \u27e8b\u27e9)\n    fun h \u21a6\n    match h with\n    | Or.inl \u27e8a\u27e9 => \u27e8Sum.inl a\u27e9\n    | Or.inr \u27e8b\u27e9 => \u27e8Sum.inr b\u27e9\n#align nonempty_sum nonempty_sum\n\n@[simp]\ntheorem nonempty_psum {\u03b1 \u03b2} : Nonempty (PSum \u03b1 \u03b2) \u2194 Nonempty \u03b1 \u2228 Nonempty \u03b2 :=\n  Iff.intro\n    (fun \u27e8h\u27e9 \u21a6\n      match h with\n      | PSum.inl a => Or.inl \u27e8a\u27e9\n      | PSum.inr b => Or.inr \u27e8b\u27e9)\n    fun h \u21a6\n    match h with\n    | Or.inl \u27e8a\u27e9 => \u27e8PSum.inl a\u27e9\n    | Or.inr \u27e8b\u27e9 => \u27e8PSum.inr b\u27e9\n#align nonempty_psum nonempty_psum\n\n@[simp]\ntheorem nonempty_ulift : Nonempty (ULift \u03b1) \u2194 Nonempty \u03b1 :=\n  Iff.intro (fun \u27e8\u27e8a\u27e9\u27e9 \u21a6 \u27e8a\u27e9) fun \u27e8a\u27e9 \u21a6 \u27e8\u27e8a\u27e9\u27e9\n#align nonempty_ulift nonempty_ulift\n\n@[simp]\ntheorem nonempty_plift {\u03b1} : Nonempty (PLift \u03b1) \u2194 Nonempty \u03b1 :=\n  Iff.intro (fun \u27e8\u27e8a\u27e9\u27e9 \u21a6 \u27e8a\u27e9) fun \u27e8a\u27e9 \u21a6 \u27e8\u27e8a\u27e9\u27e9\n#align nonempty_plift nonempty_plift\n\n@[simp]\ntheorem Nonempty.forall {\u03b1} {p : Nonempty \u03b1 \u2192 Prop} : (\u2200 h : Nonempty \u03b1, p h) \u2194 \u2200 a, p \u27e8a\u27e9 :=\n  Iff.intro (fun h _ \u21a6 h _) fun h \u27e8a\u27e9 \u21a6 h a\n#align nonempty.forall Nonempty.forall\n\n@[simp]\ntheorem Nonempty.exists {\u03b1} {p : Nonempty \u03b1 \u2192 Prop} : (\u2203 h : Nonempty \u03b1, p h) \u2194 \u2203 a, p \u27e8a\u27e9 :=\n  Iff.intro (fun \u27e8\u27e8a\u27e9, h\u27e9 \u21a6 \u27e8a, h\u27e9) fun \u27e8a, h\u27e9 \u21a6 \u27e8\u27e8a\u27e9, h\u27e9\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' {\u03b1} [h : Nonempty \u03b1] : Inhabited \u03b1 :=\n  \u27e8Classical.choice h\u27e9\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 {\u03b1} (h : Nonempty \u03b1) : \u03b1 :=\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 (\u03b1) [h : Nonempty \u03b1] : \u03b1 :=\n  Classical.choice h\n#align classical.arbitrary Classical.arbitrary\n\n/-- Given `f : \u03b1 \u2192 \u03b2`, if `\u03b1` is nonempty then `\u03b2` is also nonempty.\n  `Nonempty` cannot be a `functor`, because `Functor` is restricted to `Type`. -/\ntheorem Nonempty.map {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) : Nonempty \u03b1 \u2192 Nonempty \u03b2\n  | \u27e8h\u27e9 => \u27e8f h\u27e9\n#align nonempty.map Nonempty.map\n\nprotected theorem Nonempty.map2 {\u03b1 \u03b2 \u03b3 : Sort _} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :\n    Nonempty \u03b1 \u2192 Nonempty \u03b2 \u2192 Nonempty \u03b3\n  | \u27e8x\u27e9, \u27e8y\u27e9 => \u27e8f x y\u27e9\n#align nonempty.map2 Nonempty.map2\n\nprotected theorem Nonempty.congr {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) : Nonempty \u03b1 \u2194 Nonempty \u03b2 :=\n  \u27e8Nonempty.map f, Nonempty.map g\u27e9\n#align nonempty.congr Nonempty.congr\n\ntheorem Nonempty.elim_to_inhabited {\u03b1 : Sort _} [h : Nonempty \u03b1] {p : Prop} (f : Inhabited \u03b1 \u2192 p) :\n    p :=\n  h.elim <| f \u2218 Inhabited.mk\n#align nonempty.elim_to_inhabited Nonempty.elim_to_inhabited\n\nprotected instance Prod.Nonempty {\u03b1 \u03b2} [h : Nonempty \u03b1] [h2 : Nonempty \u03b2] : Nonempty (\u03b1 \u00d7 \u03b2) :=\n  h.elim fun g \u21a6 h2.elim fun g2 \u21a6 \u27e8\u27e8g, g2\u27e9\u27e9\n\nprotected instance Pi.Nonempty {\u03b9 : Sort _} {\u03b1 : \u03b9 \u2192 Sort _} [\u2200 i, Nonempty (\u03b1 i)] :\n    Nonempty (\u2200 i, \u03b1 i) :=\n  \u27e8fun _ \u21a6 Classical.arbitrary _\u27e9\n\ntheorem Classical.nonempty_pi {\u03b9} {\u03b1 : \u03b9 \u2192 Sort _} : Nonempty (\u2200 i, \u03b1 i) \u2194 \u2200 i, Nonempty (\u03b1 i) :=\n  \u27e8fun \u27e8f\u27e9 a \u21a6 \u27e8f a\u27e9, @Pi.Nonempty _ _\u27e9\n#align classical.nonempty_pi Classical.nonempty_pi\n\ntheorem subsingleton_of_not_nonempty {\u03b1 : Sort _} (h : \u00acNonempty \u03b1) : Subsingleton \u03b1 :=\n  \u27e8fun x \u21a6 False.elim <| not_nonempty_iff_imp_false.mp h x\u27e9\n#align subsingleton_of_not_nonempty subsingleton_of_not_nonempty\n\ntheorem Function.Surjective.nonempty [h : Nonempty \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : Function.Surjective f) :\n      Nonempty \u03b1 :=\n  let \u27e8y\u27e9 := h\n  let \u27e8x, _\u27e9 := hf y\n  \u27e8x\u27e9\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\u00e9d\u00e9ric Dupuis. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Fr\u00e9d\u00e9ric Dupuis, Ya\u00ebl 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\u1d52\u1d48\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\u2093'. -/\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 \u2022 a < 0 \u2194 a < 0 :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem smul_lt_smul_of_neg (h : a < b) (hc : c < 0) : c \u2022 b < c \u2022 a :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem smul_le_smul_of_nonpos (h : a \u2264 b) (hc : c \u2264 0) : c \u2022 b \u2264 c \u2022 a :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem eq_of_smul_eq_smul_of_neg_of_le (hab : c \u2022 a = c \u2022 b) (hc : c < 0) (h : a \u2264 b) : a = b :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem lt_of_smul_lt_smul_of_nonpos (h : c \u2022 a < c \u2022 b) (hc : c \u2264 0) : b < a :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem smul_lt_smul_iff_of_neg (hc : c < 0) : c \u2022 a < c \u2022 b \u2194 b < a :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem smul_neg_iff_of_neg (hc : c < 0) : c \u2022 a < 0 \u2194 0 < a :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem smul_pos_iff_of_neg (hc : c < 0) : 0 < c \u2022 a \u2194 a < 0 :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem smul_nonpos_of_nonpos_of_nonneg (hc : c \u2264 0) (ha : 0 \u2264 a) : c \u2022 a \u2264 0 :=\n  calc\n    c \u2022 a \u2264 c \u2022 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\u2093'. -/\ntheorem smul_nonneg_of_nonpos_of_nonpos (hc : c \u2264 0) (ha : a \u2264 0) : 0 \u2264 c \u2022 a :=\n  @smul_nonpos_of_nonpos_of_nonneg k M\u1d52\u1d48 _ _ _ _ _ _ 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\u2093'. -/\nalias smul_pos_iff_of_neg \u2194 _ 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\u2093'. -/\nalias smul_neg_iff_of_pos \u2194 _ 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\u2093'. -/\nalias smul_neg_iff_of_neg \u2194 _ 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\u2093'. -/\ntheorem antitone_smul_left (hc : c \u2264 0) : Antitone (SMul.smul c : M \u2192 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\u2093'. -/\ntheorem strict_anti_smul_left (hc : c < 0) : StrictAnti (SMul.smul c : M \u2192 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\u2093'. -/\n/-- Binary **rearrangement inequality**. -/\ntheorem smul_add_smul_le_smul_add_smul [ContravariantClass M M (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] {a b : k} {c d : M}\n    (hab : a \u2264 b) (hcd : c \u2264 d) : a \u2022 d + b \u2022 c \u2264 a \u2022 c + b \u2022 d :=\n  by\n  obtain \u27e8b, rfl\u27e9 := exists_add_of_le hab\n  obtain \u27e8d, rfl\u27e9 := exists_add_of_le hcd\n  rw [smul_add, add_right_comm, smul_add, \u2190 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'\u2093'. -/\n/-- Binary **rearrangement inequality**. -/\ntheorem smul_add_smul_le_smul_add_smul' [ContravariantClass M M (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)] {a b : k} {c d : M}\n    (hba : b \u2264 a) (hdc : d \u2264 c) : a \u2022 d + b \u2022 c \u2264 a \u2022 c + b \u2022 d :=\n  by\n  rw [add_comm (a \u2022 d), add_comm (a \u2022 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\u2093'. -/\n/-- Binary strict **rearrangement inequality**. -/\ntheorem smul_add_smul_lt_smul_add_smul [CovariantClass M M (\u00b7 + \u00b7) (\u00b7 < \u00b7)]\n    [ContravariantClass M M (\u00b7 + \u00b7) (\u00b7 < \u00b7)] {a b : k} {c d : M} (hab : a < b) (hcd : c < d) :\n    a \u2022 d + b \u2022 c < a \u2022 c + b \u2022 d :=\n  by\n  obtain \u27e8b, rfl\u27e9 := exists_add_of_le hab.le\n  obtain \u27e8d, rfl\u27e9 := exists_add_of_le hcd.le\n  rw [smul_add, add_right_comm, smul_add, \u2190 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'\u2093'. -/\n/-- Binary strict **rearrangement inequality**. -/\ntheorem smul_add_smul_lt_smul_add_smul' [CovariantClass M M (\u00b7 + \u00b7) (\u00b7 < \u00b7)]\n    [ContravariantClass M M (\u00b7 + \u00b7) (\u00b7 < \u00b7)] {a b : k} {c d : M} (hba : b < a) (hdc : d < c) :\n    a \u2022 d + b \u2022 c < a \u2022 c + b \u2022 d :=\n  by\n  rw [add_comm (a \u2022 d), add_comm (a \u2022 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\u2093'. -/\ntheorem smul_le_smul_iff_of_neg (hc : c < 0) : c \u2022 a \u2264 c \u2022 b \u2194 b \u2264 a :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem inv_smul_le_iff_of_neg (h : c < 0) : c\u207b\u00b9 \u2022 a \u2264 b \u2194 c \u2022 b \u2264 a :=\n  by\n  rw [\u2190 smul_le_smul_iff_of_neg h, smul_inv_smul\u2080 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\u2093'. -/\ntheorem inv_smul_lt_iff_of_neg (h : c < 0) : c\u207b\u00b9 \u2022 a < b \u2194 c \u2022 b < a :=\n  by\n  rw [\u2190 smul_lt_smul_iff_of_neg h, smul_inv_smul\u2080 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\u2093'. -/\ntheorem smul_inv_le_iff_of_neg (h : c < 0) : a \u2264 c\u207b\u00b9 \u2022 b \u2194 b \u2264 c \u2022 a :=\n  by\n  rw [\u2190 smul_le_smul_iff_of_neg h, smul_inv_smul\u2080 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\u2093'. -/\ntheorem smul_inv_lt_iff_of_neg (h : c < 0) : a < c\u207b\u00b9 \u2022 b \u2194 b < c \u2022 a :=\n  by\n  rw [\u2190 smul_lt_smul_iff_of_neg h, smul_inv_smul\u2080 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\u2093'. -/\n/-- Left scalar multiplication as an order isomorphism. -/\n@[simps]\ndef OrderIso.smulLeftDual {c : k} (hc : c < 0) : M \u2243o M\u1d52\u1d48\n    where\n  toFun b := OrderDual.toDual (c \u2022 b)\n  invFun b := c\u207b\u00b9 \u2022 OrderDual.ofDual b\n  left_inv := inv_smul_smul\u2080 hc.Ne\n  right_inv := smul_inv_smul\u2080 hc.Ne\n  map_rel_iff' b\u2081 b\u2082 := 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\u2093'. -/\ntheorem smul_lowerBounds_subset_upperBounds_smul (hc : c \u2264 0) :\n    c \u2022 lowerBounds s \u2286 upperBounds (c \u2022 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\u2093'. -/\ntheorem smul_upperBounds_subset_lowerBounds_smul (hc : c \u2264 0) :\n    c \u2022 upperBounds s \u2286 lowerBounds (c \u2022 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\u2093'. -/\ntheorem BddBelow.smul_of_nonpos (hc : c \u2264 0) (hs : BddBelow s) : BddAbove (c \u2022 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\u2093'. -/\ntheorem BddAbove.smul_of_nonpos (hc : c \u2264 0) (hs : BddAbove s) : BddBelow (c \u2022 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\u2093'. -/\n@[simp]\ntheorem lowerBounds_smul_of_neg (hc : c < 0) : lowerBounds (c \u2022 s) = c \u2022 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\u2093'. -/\n@[simp]\ntheorem upperBounds_smul_of_neg (hc : c < 0) : upperBounds (c \u2022 s) = c \u2022 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\u2093'. -/\n@[simp]\ntheorem bddBelow_smul_iff_of_neg (hc : c < 0) : BddBelow (c \u2022 s) \u2194 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\u2093'. -/\n@[simp]\ntheorem bddAbove_smul_iff_of_neg (hc : c < 0) : BddAbove (c \u2022 s) \u2194 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\u00e4rn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David W\u00e4rn\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 \u2964 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 \u2964 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 : \u2200 {a b : IsFreeGroupoid.Generators G}, (a \u27f6 b) \u2192 ((show G from a) \u27f6 b)\n  unique_lift :\n    \u2200 {X : Type v} [Group X] (f : Labelling (IsFreeGroupoid.Generators G) X),\n      \u2203! F : G \u2964 CategoryTheory.SingleObj X, \u2200 (a b) (g : a \u27f6 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 \u2964 CategoryTheory.SingleObj X) (h : \u2200 (a b) (e : a \u27f6 b), f.map (of e) = g.map (of e)) :\n    f = g :=\n  let \u27e8_, _, u\u27e9 := @unique_lift G _ _ X _ fun (a b : Generators G) (e : a \u27f6 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    \u27e8fun a b => { e : IsFreeGroup.Generators G // IsFreeGroup.of e \u2022 a.back = b.back }\u27e9\n  of a b e := \u27e8IsFreeGroup.of e, e.property\u27e9\n  unique_lift := by\n    intro X _ f\n    let f' : fgp.generators G \u2192 (A \u2192 X) \u22ca[mulAutArrow] G := fun e =>\n      \u27e8fun b => @f \u27e8(), _\u27e9 \u27e8(), b\u27e9 \u27e8e, smul_inv_smul _ b\u27e9, fgp.of e\u27e9\n    rcases fgp.unique_lift f' with \u27e8F', hF', uF'\u27e9\n    refine' \u27e8uncurry F' _, _, _\u27e9\n    \u00b7 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    \u00b7 rintro \u27e8\u27e8\u27e9, a : A\u27e9 \u27e8\u27e8\u27e9, b\u27e9 \u27e8e, h : fgp.of e \u2022 a = b\u27e9\n      change (F' (fgp.of _)).left _ = _\n      rw [hF']\n      cases inv_smul_eq_iff.mpr h.symm\n      rfl\n    \u00b7 intro E hE\n      have : curry E = F' := by\n        apply uF'\n        intro e\n        ext\n        \u00b7 convert hE _ _ _\n          rfl\n        \u00b7 rfl\n      apply functor.hext\n      \u00b7 intro\n        apply Unit.ext\n      \u00b7 refine' action_category.cases _\n        intros\n        simp only [\u2190 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 : \u2200 {a : G}, Path (root T) a \u2192 (root' T \u27f6 a)\n  | _, path.nil => \ud835\udfd9 _\n  | a, path.cons p f => hom_of_path p \u226b 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 \u27f6 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) = \ud835\udfd9 _ :=\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 \u27f6 b) : End (root' T) :=\n  treeHom T a \u226b p \u226b 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 \u00abexpr \u2208 \u00bb 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 \u2208 wideSubquiverSymmetrify T a b) :\n    loopOfHom T (of e) = \ud835\udfd9 (root' T) :=\n  by\n  rw [loop_of_hom, \u2190 category.assoc, is_iso.comp_inv_eq, category.id_comp]\n  cases H\n  \u00b7 rw [tree_hom_eq T (path.cons default \u27e8Sum.inl e, H\u27e9), hom_of_path]\n    rfl\n  \u00b7 rw [tree_hom_eq T (path.cons default \u27e8Sum.inr e, H\u27e9), 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) \u2192* X) : G \u2964 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, \u2190 End.one_def, f.map_one, id_as_one]\n  map_comp' := by\n    intros\n    rw [comp_as_mul, \u2190 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)\u1d9c : 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 \u2208 wide_subquiver_symmetrify T a b then 1 else f \u27e8\u27e8a, b, e\u27e9, h\u27e9\n      rcases unique_lift f' with \u27e8F', hF', uF'\u27e9\n      refine' \u27e8F'.map_End _, _, _\u27e9\n      \u00b7 suffices \u2200 {x y} (q : x \u27f6 y), F'.map (loop_of_hom T q) = (F'.map q : X)\n          by\n          rintro \u27e8\u27e8a, b, e\u27e9, h\u27e9\n          rw [functor.map_End_apply, this, hF']\n          exact dif_neg h\n        intros\n        suffices \u2200 {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        \u00b7 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 \u27e8e | e, eT\u27e9\n        \u00b7 rw [hF']\n          exact dif_pos (Or.inl eT)\n        \u00b7 rw [F'.map_inv, inv_as_inv, inv_eq_one, hF']\n          exact dif_pos (Or.inr eT)\n      \u00b7 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        \u00b7 rw [loop_of_hom_eq_id T e h, \u2190 End.one_def, E.map_one]\n        \u00b7 exact hE \u27e8\u27e8a, b, e\u27e9, h\u27e9)\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 \u2192 G`, to help type checking. -/\nprivate def symgen {G : Type u} [Groupoid.{v} G] [IsFreeGroupoid G] :\n    G \u2192 Symmetrify (Generators G) :=\n  id\n#align is_free_groupoid.symgen is_free_groupoid.symgen\n\n/-- If there exists a morphism `a \u2192 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 \u27f6 b) \u2192 Nonempty (Path (symgen a) (symgen b)) :=\n  by\n  rintro \u27e8p\u27e9\n  rw [\u2190 @weakly_connected_component.eq (generators G), eq_comm, \u2190 free_group.of_injective.eq_iff, \u2190\n    mul_inv_eq_one]\n  let X := FreeGroup (weakly_connected_component <| generators G)\n  let f : G \u2192 X := fun g => FreeGroup.of (weakly_connected_component.mk g)\n  let F : G \u2964 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 \u27e8hom.to_path (Sum.inr e)\u27e9\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  \u27e8fun b => path_nonempty_of_hom (CategoryTheory.nonempty_hom_of_connected_groupoid r b)\u27e9\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\u2082 \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 \u00d7 -)` 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 \u00d7 -)` 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 \u2a2f 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 \u2a2f 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 (\u22a4_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 \u2964 C :=\n  is_left_adjoint.right (monoidal_category.tensor_left A)\n\n/-- The adjunction between A \u2a2f - 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 \u22a3 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 \u22d9 functor.obj limits.prod.functor A \u27f6 \ud835\udfed :=\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] : \ud835\udfed \u27f6 functor.obj limits.prod.functor A \u22d9 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 \u27f6 Y) : limits.prod.map \ud835\udfd9 (functor.map (exp A) f) \u226b nat_trans.app (ev A) Y = nat_trans.app (ev A) X \u226b 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 \u27f6 Y) {X' : C} (f' : functor.obj (functor.obj limits.prod.functor A \u22d9 exp A) Y \u27f6 X') : f \u226b nat_trans.app (coev A) Y \u226b f' = nat_trans.app (coev A) X \u226b functor.map (exp A) (limits.prod.map \ud835\udfd9 f) \u226b 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 \ud835\udfd9 (nat_trans.app (coev A) B) \u226b nat_trans.app (ev A) (A \u2a2f B) = \ud835\udfd9 :=\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) \u226b functor.map (exp A) (nat_trans.app (ev A) B) = \ud835\udfd9 :=\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 \u2a2f Y \u27f6 X) \u2192 (Y \u27f6 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 \u27f6 functor.obj (exp A) X) \u2192 (A \u2a2f Y \u27f6 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 \u27f6 X') (g : A \u2a2f X' \u27f6 Y) : \u2200 {X'_1 : C} (f' : functor.obj (exp A) Y \u27f6 X'_1),\n  cartesian_closed.curry (limits.prod.map \ud835\udfd9 f \u226b g) \u226b f' = f \u226b cartesian_closed.curry g \u226b 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 \u2a2f X \u27f6 Y) (g : Y \u27f6 Y') {X' : C} (f' : functor.obj (exp A) Y' \u27f6 X') : cartesian_closed.curry (f \u226b g) \u226b f' = cartesian_closed.curry f \u226b functor.map (exp A) g \u226b 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 \u27f6 functor.obj (exp A) Y) (g : Y \u27f6 Y') : cartesian_closed.uncurry (f \u226b functor.map (exp A) g) = cartesian_closed.uncurry f \u226b 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 \u27f6 X') (g : X' \u27f6 functor.obj (exp A) Y) : cartesian_closed.uncurry (f \u226b g) = limits.prod.map \ud835\udfd9 f \u226b 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 \u2a2f X \u27f6 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 \u27f6 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 \u2a2f Y \u27f6 X) (g : Y \u27f6 functor.obj (exp A) X) : cartesian_closed.curry f = g \u2194 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 \u2a2f Y \u27f6 X) (g : Y \u27f6 functor.obj (exp A) X) : g = cartesian_closed.curry f \u2194 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 \u27f6 functor.obj (exp A) X) : cartesian_closed.uncurry g = limits.prod.map \ud835\udfd9 g \u226b 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 \u2a2f Y \u27f6 X) : cartesian_closed.curry g = nat_trans.app (coev A) Y \u226b 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 \ud835\udfd9 = 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 \ud835\udfd9 = 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 \u2245 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 (\u22a4_C)] : functor.obj (exp (\u22a4_C)) X \u2245 X :=\n  yoneda.ext (functor.obj (exp (\u22a4_C)) X) X\n    (fun (Y : C) (f : Y \u27f6 functor.obj (exp (\u22a4_C)) X) => iso.inv (limits.prod.left_unitor Y) \u226b cartesian_closed.uncurry f)\n    (fun (Y : C) (f : Y \u27f6 X) => cartesian_closed.curry (iso.hom (limits.prod.left_unitor Y) \u226b 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 \u27f6 Y) : \u22a4_C \u27f6 functor.obj (exp A) Y :=\n  cartesian_closed.curry (limits.prod.fst \u226b 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 \u27f6 A) [exponentiable B] : exp A \u27f6 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 \u27f6 A) [exponentiable B] (X : C) : limits.prod.map \ud835\udfd9 (nat_trans.app (pre f) X) \u226b nat_trans.app (ev B) X = limits.prod.map f \ud835\udfd9 \u226b 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 \u27f6 A) [exponentiable B] (X : C) : cartesian_closed.uncurry (nat_trans.app (pre f) X) = limits.prod.map f \ud835\udfd9 \u226b 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 \u27f6 A) [exponentiable B] : nat_trans.app (coev A) X \u226b nat_trans.app (pre f) (A \u2a2f X) =\n  nat_trans.app (coev B) X \u226b functor.map (exp B) (limits.prod.map f \ud835\udfd9) :=\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 \ud835\udfd9 = \ud835\udfd9 := sorry\n\n@[simp] theorem pre_map {C : Type u} [category C] [limits.has_finite_products C] {A\u2081 : C} {A\u2082 : C} {A\u2083 : C} [exponentiable A\u2081] [exponentiable A\u2082] [exponentiable A\u2083] (f : A\u2081 \u27f6 A\u2082) (g : A\u2082 \u27f6 A\u2083) : pre (f \u226b g) = pre g \u226b 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\u1d52\u1d56 \u2964 C \u2964 C :=\n  functor.mk (fun (X : C\u1d52\u1d56) => exp (opposite.unop X)) fun (X Y : C\u1d52\u1d56) (f : X \u27f6 Y) => pre (has_hom.hom.unop f)\n\n/-- If an initial object `I` exists in a CCC, then `A \u2a2f I \u2245 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 \u2a2f A \u2245 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 \u2a2f A \u2245 I :=\n  limits.prod.braiding I A \u226a\u226b zero_mul t\n\n/-- If an initial object `0` exists in a CCC then `0^B \u2245 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 \u2245 \u22a4_C :=\n  iso.mk Inhabited.default (cartesian_closed.curry (iso.hom (mul_zero t) \u226b 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 \u2a2f X \u2a3f (Z \u2a2f Y) \u2245 Z \u2a2f (X \u2a3f Y) :=\n  iso.mk (limits.coprod.desc (limits.prod.map \ud835\udfd9 limits.coprod.inl) (limits.prod.map \ud835\udfd9 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 \u27f6 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 \u27f6 \u22a5_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 \u27f6 I) (_x : g \u226b limits.is_initial.to t B = h \u226b 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\u2082} [category D] [limits.has_finite_products D] (e : C \u224c 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 \u22d9 equivalence.inverse e \u22d9 equivalence.functor e) \u226a\u226b\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 `(\u2022) : A i \u2192 M j \u2192 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 {\u03b9 : Type _}\n\nnamespace GradedMonoid\n\n/-! ### Typeclasses -/\n\n\nsection Defs\n\nvariable (A : \u03b9 \u2192 Type _) (M : \u03b9 \u2192 Type _)\n\n#print GradedMonoid.GSmul /-\n/-- A graded version of `has_smul`. Scalar multiplication combines grades additively, i.e.\nif `a \u2208 A i` and `m \u2208 M j`, then `a \u2022 b` must be in `M (i + j)`-/\nclass GSmul [Add \u03b9] where\n  smul {i j} : A i \u2192 M j \u2192 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 \u03b9] [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 \u03b9] [GSmul A M] : SMul (GradedMonoid A) (GradedMonoid M) :=\n  \u27e8fun (x : GradedMonoid A) (y : GradedMonoid M) => \u27e8_, GSmul.smul x.snd y.snd\u27e9\u27e9\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 {\u03b9 : Type.{u1}} (A : \u03b9 -> Type.{u2}) (M : \u03b9 -> Type.{u3}) [_inst_1 : Add.{u1} \u03b9] [_inst_2 : GradedMonoid.GSmul.{u1, u2, u3} \u03b9 A M _inst_1] {i : \u03b9} {j : \u03b9} (a : A i) (b : M j), Eq.{succ (max u1 u3)} (GradedMonoid.{u1, u3} \u03b9 (fun {j : \u03b9} => M j)) (SMul.smul.{max u1 u2, max u1 u3} (GradedMonoid.{u1, u2} \u03b9 (fun {i : \u03b9} => A i)) (GradedMonoid.{u1, u3} \u03b9 (fun {j : \u03b9} => M j)) (GradedMonoid.GSmul.toSMul.{u1, u2, u3} \u03b9 (fun {i : \u03b9} => A i) (fun {j : \u03b9} => M j) _inst_1 _inst_2) (GradedMonoid.mk.{u1, u2} \u03b9 (fun {i : \u03b9} => A i) i a) (GradedMonoid.mk.{u1, u3} \u03b9 (fun {j : \u03b9} => M j) j b)) (GradedMonoid.mk.{u1, u3} \u03b9 (fun {j : \u03b9} => M j) (HAdd.hAdd.{u1, u1, u1} \u03b9 \u03b9 \u03b9 (instHAdd.{u1} \u03b9 _inst_1) i j) (GradedMonoid.GSmul.smul.{u1, u2, u3} \u03b9 (fun {i : \u03b9} => A i) M _inst_1 _inst_2 i j a b))\nbut is expected to have type\n  forall {\u03b9 : Type.{u3}} (A : \u03b9 -> Type.{u2}) (M : \u03b9 -> Type.{u1}) [_inst_1 : Add.{u3} \u03b9] [_inst_2 : GradedMonoid.GSmul.{u3, u2, u1} \u03b9 A M _inst_1] {i : \u03b9} {j : \u03b9} (a : A i) (b : M j), Eq.{max (succ u3) (succ u1)} (GradedMonoid.{u3, u1} \u03b9 M) (HSMul.hSMul.{max u2 u3, max u1 u3, max u3 u1} (GradedMonoid.{u3, u2} \u03b9 A) (GradedMonoid.{u3, u1} \u03b9 M) (GradedMonoid.{u3, u1} \u03b9 M) (instHSMul.{max u3 u2, max u3 u1} (GradedMonoid.{u3, u2} \u03b9 A) (GradedMonoid.{u3, u1} \u03b9 M) (GradedMonoid.GSmul.toSMul.{u3, u2, u1} \u03b9 A M _inst_1 _inst_2)) (GradedMonoid.mk.{u3, u2} \u03b9 A i a) (GradedMonoid.mk.{u3, u1} \u03b9 M j b)) (GradedMonoid.mk.{u3, u1} \u03b9 M (HAdd.hAdd.{u3, u3, u3} \u03b9 \u03b9 \u03b9 (instHAdd.{u3} \u03b9 _inst_1) i j) (GradedMonoid.GSmul.smul.{u3, u2, u1} \u03b9 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\u2093'. -/\ntheorem mk_smul_mk [Add \u03b9] [GSmul A M] {i j} (a : A i) (b : M j) :\n    mk i a \u2022 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 \u03b9] [GMonoid A] extends GSmul A M where\n  one_smul (b : GradedMonoid M) : (1 : GradedMonoid A) \u2022 b = b\n  mul_smul (a a' : GradedMonoid A) (b : GradedMonoid M) : (a * a') \u2022 b = a \u2022 a' \u2022 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 \u03b9] [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 \u03b9] [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 \u03b9]\n  (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) : Prop where\n  smul_mem : \u2200 \u2983i j : \u03b9\u2984 {ai bj}, ai \u2208 A i \u2192 bj \u2208 B j \u2192 ai \u2022 bj \u2208 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 \u03b9]\n    (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) [SetLike.GradedSmul A B] :\n    GradedMonoid.GSmul (fun i => A i) fun i => B i\n    where smul i j a b := \u27e8(a : R) \u2022 b, SetLike.GradedSmul.smul_mem a.2 b.2\u27e9\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 {\u03b9 : 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} \u03b9] (A : \u03b9 -> S) (B : \u03b9 -> N) [_inst_5 : SetLike.GradedSmul.{u1, u2, u3, u4, u5} \u03b9 S R N M _inst_1 _inst_2 _inst_3 _inst_4 A B] {i : \u03b9} {j : \u03b9} (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 : \u03b9) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) (HAdd.hAdd.{u1, u1, u1} \u03b9 \u03b9 \u03b9 (instHAdd.{u1} \u03b9 _inst_4) i j)) M (HasLiftT.mk.{succ u5, succ u5} ((fun (i : \u03b9) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) (HAdd.hAdd.{u1, u1, u1} \u03b9 \u03b9 \u03b9 (instHAdd.{u1} \u03b9 _inst_4) i j)) M (CoeTC\u2093.coe.{succ u5, succ u5} ((fun (i : \u03b9) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) (HAdd.hAdd.{u1, u1, u1} \u03b9 \u03b9 \u03b9 (instHAdd.{u1} \u03b9 _inst_4) i j)) M (coeBase.{succ u5, succ u5} ((fun (i : \u03b9) => coeSort.{succ u4, succ (succ u5)} N Type.{u5} (SetLike.hasCoeToSort.{u4, u5} N M _inst_2) (B i)) (HAdd.hAdd.{u1, u1, u1} \u03b9 \u03b9 \u03b9 (instHAdd.{u1} \u03b9 _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} \u03b9 \u03b9 \u03b9 (instHAdd.{u1} \u03b9 _inst_4) i j))))))) (GradedMonoid.GSmul.smul.{u1, u3, u5} \u03b9 (fun (i : \u03b9) => coeSort.{succ u2, succ (succ u3)} S Type.{u3} (SetLike.hasCoeToSort.{u2, u3} S R _inst_1) (A i)) (fun (i : \u03b9) => 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} \u03b9 S R N M _inst_1 _inst_2 _inst_3 _inst_4 (fun (i : \u03b9) => A i) (fun (i : \u03b9) => 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\u2093.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\u2093.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 {\u03b9 : 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} \u03b9] (A : \u03b9 -> S) (B : \u03b9 -> N) [_inst_5 : SetLike.GradedSmul.{u1, u5, u4, u3, u2} \u03b9 S R N M _inst_1 _inst_2 _inst_3 _inst_4 A B] {i : \u03b9} {j : \u03b9} (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} \u03b9 \u03b9 \u03b9 (instHAdd.{u1} \u03b9 _inst_4) i j)))) (GradedMonoid.GSmul.smul.{u1, u4, u2} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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} \u03b9 S R N M _inst_1 _inst_2 _inst_3 _inst_4 (fun (i : \u03b9) => A i) (fun (i : \u03b9) => 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\u2093'. -/\n@[simp]\ntheorem SetLike.coe_GSmul {S R N M : Type _} [SetLike S R] [SetLike N M] [SMul R M] [Add \u03b9]\n    (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) [SetLike.GradedSmul A B] {i j : \u03b9} (x : A i) (y : B j) :\n    (@GradedMonoid.GSmul.smul \u03b9 (fun i => A i) (fun i => B i) _ _ i j x y : M) = (x : R) \u2022 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 {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : AddMonoid.{u1} \u03b9] [_inst_2 : Monoid.{u2} R] {S : Type.{u3}} [_inst_3 : SetLike.{u3, u2} S R] (A : \u03b9 -> S) [_inst_4 : SetLike.GradedMonoid.{u1, u2, u3} \u03b9 R S _inst_3 _inst_2 _inst_1 A], SetLike.GradedSmul.{u1, u3, u2, u3, u2} \u03b9 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} \u03b9 (AddMonoid.toAddZeroClass.{u1} \u03b9 _inst_1)) A A\nbut is expected to have type\n  forall {\u03b9 : Type.{u1}} {R : Type.{u2}} [_inst_1 : AddMonoid.{u1} \u03b9] [_inst_2 : Monoid.{u2} R] {S : Type.{u3}} [_inst_3 : SetLike.{u3, u2} S R] (A : \u03b9 -> S) [_inst_4 : SetLike.GradedMonoid.{u1, u2, u3} \u03b9 R S _inst_3 _inst_2 _inst_1 A], SetLike.GradedSmul.{u1, u3, u2, u3, u2} \u03b9 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} \u03b9 (AddMonoid.toAddZeroClass.{u1} \u03b9 _inst_1)) A A\nCase conversion may be inaccurate. Consider using '#align set_like.has_graded_mul.to_has_graded_smul SetLike.GradedMul.toGradedSmul\u2093'. -/\n/-- Internally graded version of `has_mul.to_has_smul`. -/\ninstance SetLike.GradedMul.toGradedSmul [AddMonoid \u03b9] [Monoid R] {S : Type _} [SetLike S R]\n    (A : \u03b9 \u2192 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 {\u03b9 : 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} \u03b9] [_inst_4 : SMul.{u3, u5} R M] {A : \u03b9 -> S} {B : \u03b9 -> N} [_inst_5 : SetLike.GradedSmul.{u1, u2, u3, u4, u5} \u03b9 S R N M _inst_1 _inst_2 _inst_4 _inst_3 A B] {a : R} {b : M}, (SetLike.Homogeneous.{u1, u3, u2} \u03b9 R S _inst_1 A a) -> (SetLike.Homogeneous.{u1, u5, u4} \u03b9 M N _inst_2 B b) -> (SetLike.Homogeneous.{u1, u5, u4} \u03b9 M N _inst_2 B (SMul.smul.{u3, u5} R M _inst_4 a b))\nbut is expected to have type\n  forall {\u03b9 : 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} \u03b9] [_inst_4 : SMul.{u4, u3} R M] {A : \u03b9 -> S} {B : \u03b9 -> N} [_inst_5 : SetLike.GradedSmul.{u5, u2, u4, u1, u3} \u03b9 S R N M _inst_1 _inst_2 _inst_4 _inst_3 A B] {a : R} {b : M}, (SetLike.Homogeneous.{u5, u4, u2} \u03b9 R S _inst_1 A a) -> (SetLike.Homogeneous.{u5, u3, u1} \u03b9 M N _inst_2 B b) -> (SetLike.Homogeneous.{u5, u3, u1} \u03b9 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\u2093'. -/\ntheorem SetLike.Homogeneous.graded_smul [Add \u03b9] [SMul R M] {A : \u03b9 \u2192 S} {B : \u03b9 \u2192 N}\n    [SetLike.GradedSmul A B] {a : R} {b : M} :\n    SetLike.Homogeneous A a \u2192 SetLike.Homogeneous B b \u2192 SetLike.Homogeneous B (a \u2022 b)\n  | \u27e8i, hi\u27e9, \u27e8j, hj\u27e9 => \u27e8i + j, SetLike.GradedSmul.smul_mem hi hj\u27e9\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 \u2192 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 \u2102)`\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 \u2192 Type v) : X.presheaf (Type v) :=\n{ obj := \u03bb U, \u03a0 x : (unop U), T x,\n  map := \u03bb U V i g, \u03bb (x : unop V), g (i.unop x) }\n\n@[simp] lemma presheaf_to_Types_obj\n  {T : X \u2192 Type v} {U : (opens X)\u1d52\u1d56} :\n  (presheaf_to_Types X T).obj U = \u03a0 x : (unop U), T x :=\nrfl\n\n@[simp] lemma presheaf_to_Types_map\n  {T : X \u2192 Type v} {U V : (opens X)\u1d52\u1d56} {i : U \u27f6 V} {f} :\n  (presheaf_to_Types X T).map i f = \u03bb 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 := \u03bb U, (unop U) \u2192 T,\n  map := \u03bb U V i g, g \u2218 i.unop }\n\n@[simp] lemma presheaf_to_Type_obj\n  {T : Type v} {U : (opens X)\u1d52\u1d56} :\n  (presheaf_to_Type X T).obj U = ((unop U) \u2192 T) :=\nrfl\n\n@[simp] lemma presheaf_to_Type_map\n  {T : Type v} {U V : (opens X)\u1d52\u1d56} {i : U \u27f6 V} {f} :\n  (presheaf_to_Type X T).map i f = f \u2218 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 \u22d9 (yoneda.obj T)\n\n@[simp] lemma presheaf_to_Top_obj (T : Top.{v}) (U : (opens X)\u1d52\u1d56) :\n  (presheaf_to_Top X T).obj U = ((opens.to_Top X).obj (unop U) \u27f6 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}\u1d52\u1d56) (R : TopCommRing.{v}) : CommRing.{v} :=\nCommRing.of (unop X \u27f6 (forget\u2082 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\u1d52\u1d56} (f : X \u27f6 Y) (R : TopCommRing) :\n  continuous_functions X R \u27f6 continuous_functions Y R :=\n{ to_fun := \u03bb g, f.unop \u226b 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}\u1d52\u1d56) {R S : TopCommRing.{u}} (\u03c6 : R \u27f6 S) :\n  continuous_functions X R \u27f6 continuous_functions X S :=\n{ to_fun := \u03bb g, g \u226b ((forget\u2082 TopCommRing Top).map \u03c6),\n  map_one' := by ext; exact \u03c6.1.map_one,\n  map_zero' := by ext; exact \u03c6.1.map_zero,\n  map_add' := by intros; ext; apply \u03c6.1.map_add,\n  map_mul' := by intros; ext; apply \u03c6.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} \u2964 (Top.{u}\u1d52\u1d56 \u2964 CommRing.{u}) :=\n{ obj := \u03bb R,\n  { obj := \u03bb X, continuous_functions X R,\n    map := \u03bb X Y f, continuous_functions.pullback f R },\n  map := \u03bb R S \u03c6,\n  { app := \u03bb X, continuous_functions.map X \u03c6 } }\n\n/--\nThe presheaf (of commutative rings), consisting of functions on an open set `U \u2286 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 \u2102)\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 \u22d9 (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 : \u03b1\n    set : Set \u03b1\n\n  @[simp]\n  def All.mem (self : All) (elm : self.Elm) : Prop :=\n    elm \u2208 self.set\n\n  --- `Membership` would be nice but the dependent nature of `All.mem` prevents it AFAICT.\n  infixr:60 \" \u220b \" => All.mem\n\n\n\n  structure Fn (s\u2081 s\u2082 : All) where\n    apply (a\u2081 : s\u2081.Elm) : s\u2081 \u220b a\u2081 \u2192 s\u2082.Elm\n    apply_post (a\u2081 : s\u2081.Elm) (legal\u2081 : s\u2081 \u220b a\u2081) :\n      s\u2082 \u220b apply a\u2081 legal\u2081\n\n  def Fn.compose\n    (g : Fn s\u2082 s\u2083)\n    (f : Fn s\u2081 s\u2082)\n    : Fn s\u2081 s\u2083\n  where\n    apply (a\u2081 : s\u2081.Elm) (legal\u2081 : s\u2081 \u220b a\u2081) :=\n      let a\u2082 := f.apply a\u2081 legal\u2081\n      let legal\u2082 := f.apply_post a\u2081 legal\u2081\n      g.apply a\u2082 legal\u2082\n    apply_post (a\u2081 : s\u2081.Elm) (legal\u2081 : s\u2081 \u220b a\u2081) :=\n      let a\u2082 := f.apply a\u2081 legal\u2081\n      let legal\u2082 := f.apply_post a\u2081 legal\u2081\n      g.apply_post a\u2082 legal\u2082\n\n  theorem Fn.compose_assoc\n    (h : Fn s\u2083 s\u2084)\n    (g : Fn s\u2082 s\u2083)\n    (f : Fn s\u2081 s\u2082)\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\u2081 s\u2082)\n    : f.compose Fn.id = f\n  :=\n    rfl\n\n  theorem Fn.id_compose\n    (f : Fn s\u2081 s\u2082)\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 ` \u2218 `:80 g:80 := g \u226b 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' \u27f6 X := incl A\n\nsection homeomorphism\n\ndef Top.homeomorphism.of_pairs (h : homeomorphism X Y) : Prop := A = h.hom \u207b\u00b9' B\nstructure pair.homeomorphism :=\n(h : homeomorphism X Y)\n(is_of_pairs : h.of_pairs P Q)\n\nnotation P ` \u2245\u209a ` Q := pair.homeomorphism P Q\n\nvariables {P Q R}\ninclude P Q\n\nlemma pair.homeomorphism.is_of_pairs' (h : P \u2245\u209a Q) : A = h.h.equiv \u207b\u00b9' B :=\nh.is_of_pairs\n\nlemma pair.homeomorphism.is_of_pairs.mk' (h : homeomorphism X Y)\n  (ha : \u2200 a \u2208 A, h.hom a \u2208 B) (hb : \u2200 b \u2208 B, h.inv b \u2208 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) \u2208 _ \u2192 p \u2208 _,\n    simp }\nend\n\ndef pair.homeomorphism.on_subspaces (h : P \u2245\u209a Q) : homeomorphism A' B' :=\nh.h.restrict h.is_of_pairs\n\nlemma is_closed_congr (h : P \u2245\u209a Q) : is_closed A \u2194 is_closed B :=\nby rw [h.is_of_pairs', h.h.is_closed_iff]; refl\n\n@[symm] def pair.homeomorphism.symm (h : P \u2245\u209a Q) : Q \u2245\u209a P :=\npair.homeomorphism.mk h.h.symm $\n  show B = h.h.equiv.symm \u207b\u00b9' A, from\n  by rw [h.is_of_pairs', \u2190set.preimage_comp]; simp [preimage_id]\n\ninclude R\n\n@[trans] def pair.homeomorphism.trans (h\u2081 : P \u2245\u209a Q) (h\u2082 : Q \u2245\u209a R) : P \u2245\u209a R :=\npair.homeomorphism.mk (h\u2081.h.trans h\u2082.h) $\n  show A = (function.comp h\u2082.h.equiv h\u2081.h.equiv) \u207b\u00b9' C, from\n  by rw [set.preimage_comp, h\u2081.is_of_pairs', h\u2082.is_of_pairs']\n\nend homeomorphism\n\n@[reducible] def pair.empty (W : Top) : pair := pair.mk W \u2205\n\nsection prod\n\ndef pair.prod : pair :=\npair.mk (Top.prod X Y) {p | p.1 \u2208 A \u2228 p.2 \u2208 B}\n\nnotation P ` \u2297 `: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 \u2297 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 \u2297 Q) (Q \u2297 P) :=\nby ext pq; cases pq; exact or.comm\n\ndef pair.prod_comm : P \u2297 Q \u2245\u209a Q \u2297 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 \u2297 Q) \u2297 R) (P \u2297 (Q \u2297 R)) :=\nby ext pqr; rcases pqr with \u27e8\u27e8p, q\u27e9, r\u27e9; exact or.assoc\n\ndef pair.prod_assoc : (P \u2297 Q) \u2297 R \u2245\u209a P \u2297 (Q \u2297 R) :=\npair.homeomorphism.mk prod_assoc prod_assoc_is_of_pairs\n\n-- Maybe we should have made `pair` a category and P \u2297 - a functor\ndef pair.prod.congr_right (h : Q \u2245\u209a R) : P \u2297 Q \u2245\u209a P \u2297 R :=\npair.homeomorphism.mk h.h.prod_congr_right\n  begin\n    ext pq, cases pq with p q,\n    change p \u2208 A \u2228 q \u2208 B \u2194 p \u2208 A \u2228 q \u2208 h.h.equiv \u207b\u00b9' 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 \u00d7 B \u2192 X \u00d7 B\n    \u2193       \u2193\n  A \u00d7 Y \u2192 (P \u2297 Q).subspace = A \u00d7 Y \u222a X \u00d7 B.\n\nNote that A \u00d7 B here denotes the product of the (sub)spaces A and B,\nnot the subspace of X \u00d7 Y on the product of the subsets A and B; and\nthe same for A \u00d7 Y and X \u00d7 B.\n\n-/\n\nvariables (ha : is_closed A) (hb : is_closed B)\n\n-- TODO: product bifunctor\nprotected def pair.i\u2080 : Top.prod A' B' \u27f6 Top.prod A' Y :=\nTop.mk_hom (\u03bb p, (p.1, p.2.val)) (by continuity!)\n\nprotected def pair.i\u2081 : Top.prod A' B' \u27f6 Top.prod X B' :=\nTop.mk_hom (\u03bb p, (p.1.val, p.2)) (by continuity!)\n\nprotected def pair.j\u2080 : Top.prod A' Y \u27f6 (P \u2297 Q).subspace :=\nTop.mk_hom (\u03bb p, \u27e8(p.1.val, p.2), or.inl p.1.property\u27e9)\n  (by continuity!)\n\nprotected def pair.j\u2081 : Top.prod X B' \u27f6 (P \u2297 Q).subspace :=\nTop.mk_hom (\u03bb p, \u27e8(p.1, p.2.val), or.inr p.2.property\u27e9)\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 \u00d7 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 \u2208 A \u2227 p.2 \u2208 B}) :=\n{ hom :=\n    Top.mk_hom\n      (\u03bb p, \u27e8(p.1.val, p.2.val), \u27e8p.1.property, p.2.property\u27e9\u27e9)\n      (by continuity!),\n  inv :=\n    Top.mk_hom\n      (\u03bb p, (\u27e8p.val.1, p.property.left\u27e9, \u27e8p.val.2, p.property.right\u27e9))\n      (by continuity!),\n  hom_inv_id' := by ext p; rcases p with \u27e8\u27e8a, ha\u27e9, \u27e8b, hb\u27e9\u27e9; refl,\n  inv_hom_id' := by ext p; rcases p with \u27e8\u27e8a, b\u27e9, \u27e8ha, hb\u27e9\u27e9; refl }\n\nprotected def pair.l1 : homeomorphism (Top.prod A' Y) (Top.mk_ob {p : XY | p.1 \u2208 A}) :=\n{ hom := Top.mk_hom (\u03bb p, \u27e8(p.1.val, p.2), p.1.property\u27e9) (by continuity!),\n  inv := Top.mk_hom (\u03bb p, (\u27e8p.val.1, p.property\u27e9, p.val.2)) (by continuity!),\n  hom_inv_id' := by ext p; rcases p with \u27e8\u27e8a, ha\u27e9, y\u27e9; refl,\n  inv_hom_id' := by ext p; rcases p with \u27e8\u27e8a, y\u27e9, ha\u27e9; refl }\n\nprotected def pair.l2 : homeomorphism (Top.prod X B') (Top.mk_ob {p : XY | p.2 \u2208 B}) :=\n{ hom := Top.mk_hom (\u03bb p, \u27e8(p.1, p.2.val), p.2.property\u27e9) (by continuity!),\n  inv := Top.mk_hom (\u03bb p, (p.val.1, \u27e8p.val.2, p.property\u27e9)) (by continuity!),\n  hom_inv_id' := by ext p; rcases p with \u27e8x, \u27e8b, hb\u27e9\u27e9; refl,\n  inv_hom_id' := by ext p; rcases p with \u27e8\u27e8x, b\u27e9, hb\u27e9; refl }\n\nprotected def pair.po :\n  Is_pushout (pair.i\u2080 P Q) (pair.i\u2081 P Q) (pair.j\u2080 P Q) (pair.j\u2081 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\u2080 P Q) (pair.i\u2081 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\u27e8\u27e8(0 : I01), mem_singleton _\u27e9\u27e9\n\ndef I_0.subspace.singleton : * \u2243 I_0.subspace :=\n{ to_fun := \u03bb _, 0,\n  inv_fun := \u03bb _, punit.star,\n  left_inv := \u03bb \u27e8\u27e9, rfl,\n  right_inv := \u03bb 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 \u27e8_,\u27e8\u27e9\u27e9),\nhep_initial_induced 0 this\n  (preserves_initial_object.Is_initial_object_of_Is_initial_object this)\n\ndef pair.admits_retract : Prop := \u2203 r : X \u27f6 A', r \u2218 P.incl = \ud835\udfd9 A'\n\n-- A pair (X, A) is cofibered if and only if the inclusion map of the\n-- pair (X \u00d7 I, A \u00d7 I \u222a X \u00d7 {0}) admits a retract.\n--\n-- This result holds even without the assumption that A is closed; see\n-- [Str\u00f8m, Note on Cofibrations II, Theorem 2]. However, a more\n-- intricate argument is then needed to show that A \u00d7 I \u222a X \u00d7 {0} is a\n-- pushout when (X, A) is cofibered.\nlemma pair.cofibered_iff (ha : is_closed A) :\n  P.cofibered \u2194 (P \u2297 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 \u2297 I_0) = po'.transpose.induced (i 0 @> X) (I &> pair.incl P) _, {\n    apply po'.uniqueness,\n    { rw [Is_pushout.induced_commutes\u2081], refl },\n    { rw [Is_pushout.induced_commutes\u2080], refl },\n  },\n  unfold pair.admits_retract, rw this, refl\nend\n\nvariables {P Q}\n-- TODO: Should these be \u2194?\nlemma admits_retract_congr (h : P \u2245\u209a Q) : P.admits_retract \u2192 Q.admits_retract :=\nassume \u27e8r, hr\u27e9,\n\u27e8h.on_subspaces.hom \u2218 r \u2218 h.h.inv, calc\n  h.on_subspaces.hom \u2218 r \u2218 h.h.inv \u2218 Q.incl\n    = h.on_subspaces.hom \u2218 r \u2218 h.h.inv \u2218\n      (Q.incl \u2218 h.on_subspaces.hom) \u2218 h.on_subspaces.inv      : by simp\n... = h.on_subspaces.hom \u2218 (r \u2218 P.incl) \u2218 h.on_subspaces.inv\n    : by simp [pair.homeomorphism.on_subspaces, homeomorphism.restriction_commutes]\n... = \ud835\udfd9 _  : by rw hr; simp\u27e9\n\nlemma cofibered_congr (h : P \u2245\u209a Q) (ha : is_closed A) : P.cofibered \u2192 Q.cofibered :=\nhave P \u2297 I_0 \u2245\u209a Q \u2297 I_0, from calc\n  P \u2297 I_0 \u2245\u209a I_0 \u2297 P  : pair.prod_comm\n  ...     \u2245\u209a I_0 \u2297 Q  : pair.prod.congr_right h -- TODO: congr_left\n  ...     \u2245\u209a Q \u2297 I_0  : pair.prod_comm,\ncalc\n  P.cofibered\n    \u2192 (P \u2297 I_0).admits_retract  : (P.cofibered_iff ha).mp\n... \u2192 (Q \u2297 I_0).admits_retract  : admits_retract_congr this\n... \u2192 Q.cofibered               : (Q.cofibered_iff ((is_closed_congr h).mp ha)).mpr\n\nlemma prod_empty_admits_retract (K : Top) :\n  P.admits_retract \u2192 (P \u2297 pair.empty K).admits_retract :=\nassume \u27e8r, hr\u27e9,\nlet r' : Top.prod X K \u27f6 (P \u2297 pair.empty K).subspace :=\n  pair.j\u2080 P (pair.empty K) \u2218 Top.prod_maps r (\ud835\udfd9 K) in\nbegin\n  existsi r',\n  ext p; rcases p with \u27e8\u27e8a, k\u27e9, h|\u27e8\u27e8\u27e9\u27e9\u27e9,\n  { change (r a).val = a,\n    exact congr_arg subtype.val (@@Top.hom_congr hr \u27e8a, h\u27e9) },\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\u00f8m, 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\u207f, S\u207f\u207b\u00b9)\n-- satisfies the hypothesis on Q.\nlemma prod_cofibered (ha : is_closed A) (hb : is_closed B)\n  (hq : Q \u2297 I_0 \u2245\u209a pair.empty Y \u2297 I_0) :\n  P.cofibered \u2192 (P \u2297 Q).cofibered :=\nlet Q' := pair.empty Y in\nhave _ := calc\n  (P \u2297 I_0) \u2297 Q'\n    \u2245\u209a P \u2297 (I_0 \u2297 Q')  : pair.prod_assoc\n... \u2245\u209a P \u2297 (Q' \u2297 I_0)  : pair.prod.congr_right pair.prod_comm\n... \u2245\u209a P \u2297 (Q \u2297 I_0)   : pair.prod.congr_right hq.symm\n... \u2245\u209a (P \u2297 Q) \u2297 I_0   : pair.prod_assoc.symm,\ncalc\n  P.cofibered\n    \u2192 (P \u2297 I_0).admits_retract         : (pair.cofibered_iff P ha).mp\n... \u2192 ((P \u2297 I_0) \u2297 Q').admits_retract  : prod_empty_admits_retract _\n... \u2192 ((P \u2297 Q) \u2297 I_0).admits_retract   : admits_retract_congr this\n... \u2192 (P \u2297 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 : \u211d)}\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 \u2297 I_0 \u2245\u209a pair.empty (unit_disk V) \u2297 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 \u00d7 I01 | _ \u2228 p.2 \u2208 ({0} : set I01)} =\n      (smush.H V) \u207b\u00b9' {p : unit_disk V \u00d7 I01 | p.1 \u2208 \u2205 \u2228 p.2 \u2208 ({0} : set I01)},\n    convert smush.Ht0 V;\n    { ext p, change _ \u2228 _ \u2194 _ \u2228 _, 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 \u2192 (P \u2297 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 \u2245\u209a unit_disk_sphere \u211d :=\npair.homeomorphism.mk\n  { hom :=\n      Top.mk_hom\n        (\u03bb t, \u27e82 * t.val - 1, by cases t.property; erw abs_le; split; linarith\u27e9)\n        (by continuity!),\n    inv :=\n      Top.mk_hom\n        (\u03bb t, by refine \u27e8(1 / 2) * (t.val + 1), _, _\u27e9; 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 \u2208 {(0 : I01), (1 : I01)} at ha,\n      have ha' : a = (0 : I01) \u2228 a = (1 : I01) := by simp at ha; exact ha,\n      cases ha' with ha' ha',\n      { subst ha', change abs (2 * (0 : \u211d) - 1) = 1, norm_num },\n      { subst ha', change abs (2 * (1 : \u211d) - 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 _ _ \u2208 I_01.subset,\n      { subst hb, have : (1 : I01) \u2208 ({0, 1} : set I01), by simp, convert this, norm_num },\n      { subst hb, have : (0 : I01) \u2208 ({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 \u211d)\n\nlemma prod_I_01_cofibered (ha : is_closed A) :\n  P.cofibered \u2192 (P \u2297 I_01).cofibered :=\ncalc\n  P.cofibered\n    \u2192 (P \u2297 unit_disk_sphere \u211d).cofibered\n    : prod_disk_sphere_cofibered P \u211d ha\n... \u2192 (P \u2297 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 \u211d))\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: \u2115) : Inhabited (\u2124 ^ n) := \u27e8zeros n\u27e9\n\ndef \u2124basisElem (n : \u2115) (j : \u2115) : \u2124 ^ n := \u2124basis n |>.get! j\n\ntheorem List.get!_of_get [Inhabited \u03b1] : (k : \u2115) \u2192 (l : List \u03b1) \u2192 (hk : k < l.length) \u2192 l.get! k = l.get \u27e8k, hk\u27e9\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 : \u2115} (l : List A) (h : l.length = n) (k: \u2115) (hk : k < n) :\n (inducedFreeMap l h) (\u2124basisElem n k) = l.get \u27e8k, h \u25b8 hk\u27e9 := by\n   rw [\u2124basisElem, List.get!_of_get, List.mapget (inducedFreeMap l h)]\n   apply List.get_index_eq; apply map_basis\n   \u00b7 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 \u00d7 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 : \u2115) \u2192 ToExpr (A ^ n)\n  | .zero => inferInstanceAs (ToExpr Unit)\n  | .succ m => @prodToExpr _ _ inferInstance $ powToExpr m\n\ninstance {\u03b1 : Type _} [ToExpr \u03b1] : ToExpr (List \u03b1) where\n  toExpr :=\n    let rec lstexpr : List \u03b1 \u2192 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 \u03b1\n\nend ToExpr\n\n\ndef zeroExpr : \u2115 \u2192 TermElabM Expr\n| 0 => return mkConst ``Unit.unit\n| n + 1 => do mkAppM ``Prod.mk #[toExpr (0 : Int), \u2190  zeroExpr n]\n\ndef \u2124basisExpr : \u2115 \u2192 \u2115 \u2192 TermElabM Expr\n| 0, _ => return mkConst ``Unit.unit\n| n + 1, 0 => do mkAppM ``Prod.mk #[toExpr (1 : Int), \u2190  zeroExpr n]\n| n + 1, k + 1 => do mkAppM ``Prod.mk #[toExpr (1 : Int), \u2190 \u2124basisExpr n k]\n\nelab \"\u2124basisElem#\"  n:term \"at\" j:term  : term => do\n      let nExp \u2190 elabTerm n (some <| mkConst ``Nat)\n      let jExp \u2190 elabTerm j (some <| mkConst ``Nat)\n      mkAppM ``\u2124basisElem #[nExp, jExp]\n\nelab \"\u2124basisExpr#\"  n:term \"at\" j:term  : term => do\n      let nExp \u2190 elabTerm n (some <| mkConst ``Nat)\n      let jExp \u2190 elabTerm j (some <| mkConst ``Nat)\n      let n \u2190 exprNat nExp\n      let j \u2190 exprNat jExp\n      \u2124basisExpr n j\n\n#eval \u2124basisElem# 3 at 1\n#eval \u2124basisExpr# 3 at 1\n\ndef \u2124basisArrM (n: \u2115): TermElabM (Array Expr) := do\n  let mut arr := #[]\n  for j in [0:n] do\n    arr := arr.push (\u2190 mkAppM ``\u2124basisElem #[toExpr n, toExpr j])\n  return arr\n\n-- def \u2124basisArrM (n: \u2115): TermElabM (Array Expr) := do\n--  return \u2124basis n |>.map toExpr |>.toArray\n\nelab \"arr#\"  n:term \"at\" j:term  : term => do\n      let nExp \u2190 elabTerm n (some <| mkConst ``Nat)\n      let jExp \u2190 elabTerm j (some <| mkConst ``Nat)\n      let n' \u2190 exprNat nExp\n      let j' \u2190 exprNat jExp\n      let arr \u2190 \u2124basisArrM n'\n      return arr[j']\n\n#eval arr# 7 at 2\n\ndef toFreeM (e : Expr) : TermElabM Expr := do\n  let t \u2190 addTreeM e\n  let (indTree, lst) \u2190 AddTree.indexTreeM'' t\n  let arr \u2190  \u2124basisArrM (lst.length)\n  IndexAddTree.foldMapM indTree arr\n\nelab \"free#\" t:term : term => do\n  let e \u2190 elabTerm t none\n  toFreeM e\n\ndef egFree {\u03b1 : Type _}[AddCommGroup \u03b1][Repr \u03b1][DecidableEq \u03b1][Inhabited \u03b1]\n    (x y : \u03b1) := free# (x + y + x - y + x + y)\n\n#eval egFree (5 : \u2124) (2 : \u2124 )\n\ndef provedLength{\u03b1 : Type _}(l: List \u03b1) : PSigma (fun n : \u2115  => 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 \u2190 addTreeM e\n  let (indTree, lst) \u2190 AddTree.indexTreeM'' t\n  let lstPackPair \u2190  listToExpr lst\n  let (lstPack, \u03b1) := lstPackPair\n  let pl \u2190 mkAppM ``provedLength #[lstPack]\n  let n \u2190 exprNat (\u2190 mkAppM ``PSigma.fst #[pl])\n  let pf \u2190 mkAppM ``PSigma.snd #[pl]\n  let pf' \u2190 mkAppOptM\n      ``Eq.trans #[none, none, none, toExpr n, pf, \n        \u2190 mkAppM ``Eq.refl #[toExpr n]]\n  let n := List.length lst\n--  let pf \u2190 mkAppM ``Eq.refl #[toExpr lst.length]\n  let arr \u2190  \u2124basisArrM n\n  let freeElem \u2190 IndexAddTree.foldMapM indTree arr\n  let fromFree \u2190 mkAppOptM \n      ``inducedFreeMap #[some \u03b1, none, some <| toExpr n, some lstPack, some (pf')]\n  mkAppM' fromFree #[freeElem]\n\nelab \"viafree#\" t:term : term => do\n  let e \u2190 elabTerm t none\n  viaFreeM e\n\ndef egViaFree {\u03b1 : Type}[AddCommGroup \u03b1][Repr \u03b1][DecidableEq \u03b1][Inhabited \u03b1]\n   (x y : \u03b1) := viafree# (x + y + x - y + x + y)\n\n#eval egViaFree (5 : \u2124) (2 : \u2124)\n\ntheorem egViaFreeEql{\u03b1 : Type}[AddCommGroup \u03b1][Repr \u03b1][DecidableEq \u03b1][Inhabited \u03b1]\n    (x y z : \u03b1) : 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 \u2190 viaFreeM e\n  let eqn \u2190 mkEq e freeElemIm\n  let mvar \u2190 mkFreshExprMVar $ some eqn\n  let tac \u2190 `(tactic| simp only [AddCommGroup.Homomorphism.neg_dist, AddCommGroup.add_distrib, induced_free_map_at, List.get])\n  let (goals, _) \u2190 Elab.runTactic mvar.mvarId! tac\n  guard goals.isEmpty\n  match freeElemIm with\n    | .app \u03d5 freeElem _ =>\n      let freeElemR \u2190 reduce freeElem -- the transparency here can be adjusted\n      let res \u2190 mkFreshExprMVar $ some $ \u2190 mkEq e (mkApp \u03d5 freeElemR)\n      assignExprMVar res.mvarId! mvar\n      return res\n    | _ => failure\n\nelab \"freeGroupEq#\" t:term : term => do\n  freeGroupEqM $ \u2190 elabTerm t none\n\n#check (fun (x y z : \u2124) => freeGroupEq# x + x + y - x - y + z - x)\n\nexample {x y z : \u2124} : 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u03b1`, a measure on `\u03b1` is a function that sends measurable sets to the\nextended nonnegative reals that satisfies the following conditions:\n1. `\u03bc \u2205 = 0`;\n2. `\u03bc` 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 `\u03b1` form a complete lattice, and are closed under scalar multiplication with `\u211d\u22650\u221e`.\n\nWe introduce the following typeclasses for measures:\n\n* `is_probability_measure \u03bc`: `\u03bc univ = 1`;\n* `is_finite_measure \u03bc`: `\u03bc univ < \u221e`;\n* `sigma_finite \u03bc`: there exists a countable collection of sets that cover `univ`\n  where `\u03bc` is finite;\n* `is_locally_finite_measure \u03bc` : `\u2200 x, \u2203 s \u2208 \ud835\udcdd x, \u03bc s < \u221e`;\n* `has_no_atoms \u03bc` : `\u2200 x, \u03bc {x} = 0`; possibly should be redefined as\n  `\u2200 s, 0 < \u03bc s \u2192 \u2203 t \u2286 s, 0 < \u03bc t \u2227 \u03bc t < \u03bc s`.\n\nGiven a measure, the null sets are the sets where `\u03bc s = 0`, where `\u03bc` denotes the corresponding\nouter measure (so `s` might not be measurable). We can then define the completion of `\u03bc` as the\nmeasure on the least `\u03c3`-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 `\u03bc : measure \u03b1`, `\u03bc 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\u00e9odory 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 \u03c0-system generating\n  the measurable sets, if the \u03c0-system contains a spanning increasing sequence of sets where the\n  measures take finite value (in particular the measures are \u03c3-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 \u03c0-system\n  generating the measurable sets. This is a special case of `ext_of_generate_from_of_Union` using\n  `C \u222a {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 {\u03b1 \u03b2 \u03b3 \u03b4 \u03b9 : Type*}\n\nnamespace measure_theory\n\nsection\n\nvariables {m : measurable_space \u03b1} {\u03bc \u03bc\u2081 \u03bc\u2082 : measure \u03b1} {s s\u2081 s\u2082 t : set \u03b1}\n\ninstance ae_is_measurably_generated : is_measurably_generated \u03bc.ae :=\n\u27e8\u03bb s hs, let \u27e8t, hst, htm, ht\u03bc\u27e9 := exists_measurable_superset_of_null hs in\n  \u27e8t\u1d9c, compl_mem_ae_iff.2 ht\u03bc, htm.compl, compl_subset_comm.1 hst\u27e9\u27e9\n\nlemma measure_union (hd : disjoint s\u2081 s\u2082) (h\u2081 : measurable_set s\u2081) (h\u2082 : measurable_set s\u2082) :\n  \u03bc (s\u2081 \u222a s\u2082) = \u03bc s\u2081 + \u03bc s\u2082 :=\nmeasure_union\u2080 h\u2081.null_measurable_set h\u2082.null_measurable_set hd\n\nlemma measure_add_measure_compl (h : measurable_set s) :\n  \u03bc s + \u03bc s\u1d9c = \u03bc univ :=\nby { rw [\u2190 union_compl_self s, measure_union _ h h.compl], exact disjoint_compl_right }\n\nlemma measure_bUnion {s : set \u03b2} {f : \u03b2 \u2192 set \u03b1} (hs : countable s)\n  (hd : s.pairwise (disjoint on f)) (h : \u2200 b \u2208 s, measurable_set (f b)) :\n  \u03bc (\u22c3 b \u2208 s, f b) = \u2211' p : s, \u03bc (f p) :=\nbegin\n  haveI := hs.to_encodable,\n  rw bUnion_eq_Union,\n  exact measure_Union (hd.on_injective subtype.coe_injective $ \u03bb x, x.2) (\u03bb x, h x x.2)\nend\n\nlemma measure_sUnion {S : set (set \u03b1)} (hs : countable S)\n  (hd : S.pairwise disjoint) (h : \u2200 s \u2208 S, measurable_set s) :\n  \u03bc (\u22c3\u2080 S) = \u2211' s : S, \u03bc s :=\nby rw [sUnion_eq_bUnion, measure_bUnion hs hd h]\n\nlemma measure_bUnion_finset {s : finset \u03b9} {f : \u03b9 \u2192 set \u03b1} (hd : set.pairwise \u2191s (disjoint on f))\n  (hm : \u2200 b \u2208 s, measurable_set (f b)) :\n  \u03bc (\u22c3 b \u2208 s, f b) = \u2211 p in s, \u03bc (f p) :=\nbegin\n  rw [\u2190 finset.sum_attach, finset.attach_eq_univ, \u2190 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 \u207b\u00b9' {y}`. -/\nlemma tsum_measure_preimage_singleton {s : set \u03b2} (hs : countable s) {f : \u03b1 \u2192 \u03b2}\n  (hf : \u2200 y \u2208 s, measurable_set (f \u207b\u00b9' {y})) :\n  \u2211' b : s, \u03bc (f \u207b\u00b9' {\u2191b}) = \u03bc (f \u207b\u00b9' s) :=\nby rw [\u2190 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 \u207b\u00b9' {y}`. -/\nlemma sum_measure_preimage_singleton (s : finset \u03b2) {f : \u03b1 \u2192 \u03b2}\n  (hf : \u2200 y \u2208 s, measurable_set (f \u207b\u00b9' {y})) :\n  \u2211 b in s, \u03bc (f \u207b\u00b9' {b}) = \u03bc (f \u207b\u00b9' \u2191s) :=\nby simp only [\u2190 measure_bUnion_finset (pairwise_disjoint_fiber _ _) hf,\n  finset.set_bUnion_preimage_singleton]\n\nlemma measure_diff_null' (h : \u03bc (s\u2081 \u2229 s\u2082) = 0) : \u03bc (s\u2081 \\ s\u2082) = \u03bc s\u2081 :=\nmeasure_congr $ diff_ae_eq_self.2 h\n\nlemma measure_diff_null (h : \u03bc s\u2082 = 0) : \u03bc (s\u2081 \\ s\u2082) = \u03bc s\u2081 :=\nmeasure_diff_null' $ measure_mono_null (inter_subset_right _ _) h\n\nlemma measure_diff (h : s\u2082 \u2286 s\u2081) (h\u2081 : measurable_set s\u2081) (h\u2082 : measurable_set s\u2082)\n  (h_fin : \u03bc s\u2082 \u2260 \u221e) :\n  \u03bc (s\u2081 \\ s\u2082) = \u03bc s\u2081 - \u03bc s\u2082 :=\nbegin\n  refine (ennreal.add_sub_self' h_fin).symm.trans _,\n  rw [\u2190 measure_union disjoint_diff h\u2082 (h\u2081.diff h\u2082), union_diff_cancel h]\nend\n\nlemma le_measure_diff : \u03bc s\u2081 - \u03bc s\u2082 \u2264 \u03bc (s\u2081 \\ s\u2082) :=\ntsub_le_iff_left.2 $\ncalc \u03bc s\u2081 \u2264 \u03bc (s\u2082 \u222a s\u2081)        : measure_mono (subset_union_right _ _)\n      ... = \u03bc (s\u2082 \u222a s\u2081 \\ s\u2082)   : congr_arg \u03bc union_diff_self.symm\n      ... \u2264 \u03bc s\u2082 + \u03bc (s\u2081 \\ s\u2082) : measure_union_le _ _\n\nlemma measure_diff_lt_of_lt_add (hs : measurable_set s) (ht : measurable_set t) (hst : s \u2286 t)\n  (hs' : \u03bc s \u2260 \u221e) {\u03b5 : \u211d\u22650\u221e} (h : \u03bc t < \u03bc s + \u03b5) : \u03bc (t \\ s) < \u03b5 :=\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 \u2286 t)\n  (hs' : \u03bc s \u2260 \u221e) {\u03b5 : \u211d\u22650\u221e} : \u03bc (t \\ s) \u2264 \u03b5 \u2194 \u03bc t \u2264 \u03bc s + \u03b5 :=\nby rwa [measure_diff hst ht hs hs', tsub_le_iff_left]\n\nlemma measure_eq_measure_of_null_diff {s t : set \u03b1}\n  (hst : s \u2286 t) (h_nulldiff : \u03bc (t.diff s) = 0) : \u03bc s = \u03bc t :=\nby { rw [\u2190diff_diff_cancel_left hst, \u2190@measure_diff_null _ _ _ t _ h_nulldiff], refl, }\n\nlemma measure_eq_measure_of_between_null_diff {s\u2081 s\u2082 s\u2083 : set \u03b1}\n  (h12 : s\u2081 \u2286 s\u2082) (h23 : s\u2082 \u2286 s\u2083) (h_nulldiff : \u03bc (s\u2083 \\ s\u2081) = 0) :\n  (\u03bc s\u2081 = \u03bc s\u2082) \u2227 (\u03bc s\u2082 = \u03bc s\u2083) :=\nbegin\n  have le12 : \u03bc s\u2081 \u2264 \u03bc s\u2082 := measure_mono h12,\n  have le23 : \u03bc s\u2082 \u2264 \u03bc s\u2083 := measure_mono h23,\n  have key : \u03bc s\u2083 \u2264 \u03bc s\u2081 := calc\n    \u03bc s\u2083 = \u03bc ((s\u2083 \\ s\u2081) \u222a s\u2081)  : by rw (diff_union_of_subset (h12.trans h23))\n     ... \u2264 \u03bc (s\u2083 \\ s\u2081) + \u03bc s\u2081  : measure_union_le _ _\n     ... = \u03bc s\u2081                : by simp only [h_nulldiff, zero_add],\n  exact \u27e8le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)\u27e9,\nend\n\nlemma measure_eq_measure_smaller_of_between_null_diff {s\u2081 s\u2082 s\u2083 : set \u03b1}\n  (h12 : s\u2081 \u2286 s\u2082) (h23 : s\u2082 \u2286 s\u2083) (h_nulldiff : \u03bc (s\u2083.diff s\u2081) = 0) : \u03bc s\u2081 = \u03bc s\u2082 :=\n(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).1\n\nlemma measure_eq_measure_larger_of_between_null_diff {s\u2081 s\u2082 s\u2083 : set \u03b1}\n  (h12 : s\u2081 \u2286 s\u2082) (h23 : s\u2082 \u2286 s\u2083) (h_nulldiff : \u03bc (s\u2083.diff s\u2081) = 0) : \u03bc s\u2082 = \u03bc s\u2083 :=\n(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2\n\nlemma measure_compl (h\u2081 : measurable_set s) (h_fin : \u03bc s \u2260 \u221e) : \u03bc (s\u1d9c) = \u03bc univ - \u03bc s :=\nby { rw compl_eq_univ_diff, exact measure_diff (subset_univ s) measurable_set.univ h\u2081 h_fin }\n\nlemma sum_measure_le_measure_univ {s : finset \u03b9} {t : \u03b9 \u2192 set \u03b1} (h : \u2200 i \u2208 s, measurable_set (t i))\n  (H : set.pairwise \u2191s (disjoint on t)) :\n  \u2211 i in s, \u03bc (t i) \u2264 \u03bc (univ : set \u03b1) :=\nby { rw \u2190 measure_bUnion_finset H h, exact measure_mono (subset_univ _) }\n\nlemma tsum_measure_le_measure_univ {s : \u03b9 \u2192 set \u03b1} (hs : \u2200 i, measurable_set (s i))\n  (H : pairwise (disjoint on s)) :\n  \u2211' i, \u03bc (s i) \u2264 \u03bc (univ : set \u03b1) :=\nbegin\n  rw [ennreal.tsum_eq_supr_sum],\n  exact supr_le (\u03bb s, sum_measure_le_measure_univ (\u03bb i hi, hs i) (\u03bb i hi j hj hij, H i j hij))\nend\n\n/-- If `s\u1d62` is a countable family of measurable sets such that all pairwise intersections have\nmeasure `0`, then there exists a subordinate family `t\u1d62 \u2286 s\u1d62` of measurable pairwise disjoint sets\nsuch that `t\u1d62 =\u1d50[\u03bc] s\u1d62`. -/\nlemma exists_subordinate_pairwise_disjoint [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1}\n  (h : \u2200 i, measurable_set (s i)) (hd : pairwise (\u03bb i j, \u03bc (s i \u2229 s j) = 0)) :\n  \u2203 t : \u03b9 \u2192 set \u03b1, (\u2200 i, t i \u2286 s i) \u2227 (\u2200 i, s i =\u1d50[\u03bc] t i) \u2227 (\u2200 i, measurable_set (t i)) \u2227\n    pairwise (disjoint on t) :=\nbegin\n  set t : \u03b9 \u2192 set \u03b1 := \u03bb i, s i \\ \u22c3 j \u2208 ({i}\u1d9c : set \u03b9), s j,\n  refine \u27e8t, \u03bb i, diff_subset _ _, \u03bb i, _, \u03bb i, (h i).diff $\n    measurable_set.bUnion (countable_encodable _) $ \u03bb j hj, h j, _\u27e9,\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 \u03bb j hj, hd _ _ (ne.symm hj) },\n  { rintros i j hne x \u27e8\u27e8hsi, -\u27e9, -, Hj\u27e9,\n    exact Hj (mem_bUnion hne hsi) }\nend\n\nlemma measure_Union_of_null_inter [encodable \u03b9] {f : \u03b9 \u2192 set \u03b1} (h : \u2200 i, measurable_set (f i))\n  (hn : pairwise ((\u03bb S T, \u03bc (S \u2229 T) = 0) on f)) : \u03bc (\u22c3 i, f i) = \u2211' i, \u03bc (f i) :=\nbegin\n  rcases exists_subordinate_pairwise_disjoint h hn with \u27e8t, ht_sub, ht_eq, htm, htd\u27e9,\n  calc \u03bc (\u22c3 i, f i) = \u03bc (\u22c3 i, t i)  : measure_congr (eventually_eq.countable_Union ht_eq)\n                ... = \u2211' i, \u03bc (t i) : measure_Union htd htm\n                ... = \u2211' i, \u03bc (f i) : tsum_congr (\u03bb i, measure_congr (ht_eq i).symm)\nend\n\n/-- Pigeonhole principle for measure spaces: if `\u2211' i, \u03bc (s i) > \u03bc univ`, then\none of the intersections `s i \u2229 s j` is not empty. -/\nlemma exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : measurable_space \u03b1} (\u03bc : measure \u03b1)\n  {s : \u03b9 \u2192 set \u03b1} (hs : \u2200 i, measurable_set (s i)) (H : \u03bc (univ : set \u03b1) < \u2211' i, \u03bc (s i)) :\n  \u2203 i j (h : i \u2260 j), (s i \u2229 s j).nonempty :=\nbegin\n  contrapose! H,\n  apply tsum_measure_le_measure_univ hs,\n  exact \u03bb i j hij x hx, H i j hij \u27e8x, hx\u27e9\nend\n\n/-- Pigeonhole principle for measure spaces: if `s` is a `finset` and\n`\u2211 i in s, \u03bc (t i) > \u03bc univ`, then one of the intersections `t i \u2229 t j` is not empty. -/\nlemma exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : measurable_space \u03b1} (\u03bc : measure \u03b1)\n  {s : finset \u03b9} {t : \u03b9 \u2192 set \u03b1} (h : \u2200 i \u2208 s, measurable_set (t i))\n  (H : \u03bc (univ : set \u03b1) < \u2211 i in s, \u03bc (t i)) :\n  \u2203 (i \u2208 s) (j \u2208 s) (h : i \u2260 j), (t i \u2229 t j).nonempty :=\nbegin\n  contrapose! H,\n  apply sum_measure_le_measure_univ h,\n  exact \u03bb i hi j hj hij x hx, H i hi j hj hij \u27e8x, hx\u27e9\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 \u03b9] {s : \u03b9 \u2192 set \u03b1} (h : \u2200 i, measurable_set (s i))\n  (hd : directed (\u2286) s) : \u03bc (\u22c3 i, s i) = \u2a06 i, \u03bc (s i) :=\nbegin\n  casesI is_empty_or_nonempty \u03b9,\n  { simp only [supr_of_empty, Union], exact measure_empty },\n  refine le_antisymm _ (supr_le $ \u03bb i, measure_mono $ subset_Union _ _),\n  have : \u2200 n, measurable_set (disjointed (\u03bb n, \u22c3 b \u2208 encodable.decode\u2082 \u03b9 n, s b) n) :=\n    measurable_set.disjointed (measurable_set.bUnion_decode\u2082 h),\n  have hn : pairwise (disjoint on\n    \u03bb (n : \u2115), disjointed (\u03bb (n : \u2115), \u22c3 (b : \u03b9) (H : b \u2208 encodable.decode\u2082 \u03b9 n), s b) n) :=\n    disjoint_disjointed _,\n  rw [\u2190 encodable.Union_decode\u2082, \u2190 Union_disjointed, measure_Union hn this,\n    ennreal.tsum_eq_supr_nat],\n  simp only [\u2190 measure_bUnion_finset (hn.set_pairwise _) (\u03bb n _, this n)],\n  refine supr_le (\u03bb n, _),\n  refine le_trans (_ : _ \u2264 \u03bc (\u22c3 (k \u2208 finset.range n) (i \u2208 encodable.decode\u2082 \u03b9 k), s i)) _,\n  exact measure_mono (bUnion_mono (\u03bb k hk, disjointed_subset _ _)),\n  simp only [\u2190 finset.set_bUnion_option_to_finset, \u2190 finset.set_bUnion_bUnion],\n  generalize : (finset.range n).bUnion (\u03bb k, (encodable.decode\u2082 \u03b9 k).to_finset) = t,\n  rcases hd.finset_le t with \u27e8i, hi\u27e9,\n  exact le_supr_of_le i (measure_mono $ bUnion_subset hi)\nend\n\nlemma measure_bUnion_eq_supr {s : \u03b9 \u2192 set \u03b1} {t : set \u03b9} (ht : countable t)\n  (h : \u2200 i \u2208 t, measurable_set (s i)) (hd : directed_on ((\u2286) on s) t) :\n  \u03bc (\u22c3 i \u2208 t, s i) = \u2a06 i \u2208 t, \u03bc (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 \u03b9] {s : \u03b9 \u2192 set \u03b1}\n  (h : \u2200 i, measurable_set (s i)) (hd : directed (\u2287) s) (hfin : \u2203 i, \u03bc (s i) \u2260 \u221e) :\n  \u03bc (\u22c2 i, s i) = (\u2a05 i, \u03bc (s i)) :=\nbegin\n  rcases hfin with \u27e8k, hk\u27e9,\n  have : \u2200 t \u2286 s k, \u03bc t \u2260 \u221e, from \u03bb t ht, ne_top_of_le_ne_top hk (measure_mono ht),\n  rw [\u2190 ennreal.sub_sub_cancel (by exact hk) (infi_le _ k), ennreal.sub_infi,\n    \u2190 ennreal.sub_sub_cancel (by exact hk) (measure_mono (Inter_subset _ k)),\n    \u2190 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 $ \u03bb i, _) (supr_le_supr $ \u03bb i, _),\n    { rcases hd i k with \u27e8j, hji, hjk\u27e9,\n      use j,\n      rw [\u2190 measure_diff hjk (h _) (h _) (this _ hjk)],\n      exact measure_mono (diff_subset_diff_right hji) },\n    { rw [tsub_le_iff_right, \u2190 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 \u03bb i, (h k).diff (h i) },\n  { exact hd.mono_comp _ (\u03bb _ _, 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 \u03b9] [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1}\n  (hs : \u2200 n, measurable_set (s n)) (hm : monotone s) :\n  tendsto (\u03bc \u2218 s) at_top (\ud835\udcdd (\u03bc (\u22c3 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 \u03b9] [semilattice_sup \u03b9] {s : \u03b9 \u2192 set \u03b1}\n  (hs : \u2200 n, measurable_set (s n)) (hm : antitone s) (hf : \u2203 i, \u03bc (s i) \u2260 \u221e) :\n  tendsto (\u03bc \u2218 s) at_top (\ud835\udcdd (\u03bc (\u22c2 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\u1d62) is a sequence of sets such\nthat `\u2211 \u03bc s\u1d62` is finite, then the limit superior of the `s\u1d62` is a null set. -/\nlemma measure_limsup_eq_zero {s : \u2115 \u2192 set \u03b1} (hs : \u2211' i, \u03bc (s i) \u2260 \u221e) : \u03bc (limsup at_top s) = 0 :=\nbegin\n  -- First we replace the sequence `s\u2099` with a sequence of measurable sets `t\u2099 \u2287 s\u2099` of the same\n  -- measure.\n  set t : \u2115 \u2192 set \u03b1 := \u03bb n, to_measurable \u03bc (s n),\n  have ht : \u2211' i, \u03bc (t i) \u2260 \u221e, by simpa only [t, measure_to_measurable] using hs,\n  suffices : \u03bc (limsup at_top t) = 0,\n  { have A : s \u2264 t := \u03bb n, subset_to_measurable \u03bc (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    \u2190 nonpos_iff_eq_zero],\n  -- Finally, we estimate `\u03bc (\u22c3 i, t (i + n))` by `\u2211 i', \u03bc (t (i + n))`\n  refine le_of_tendsto_of_tendsto'\n    (tendsto_measure_Inter (\u03bb i, measurable_set.Union (\u03bb b, measurable_set_to_measurable _ _)) _\n      \u27e80, ne_top_of_le_ne_top ht (measure_Union_le t)\u27e9)\n    (ennreal.tendsto_sum_nat_add (\u03bc \u2218 t) ht) (\u03bb n, measure_Union_le _),\n  intros n m hnm x,\n  simp only [set.mem_Union],\n  exact \u03bb \u27e8i, hi\u27e9, \u27e8i + (m - n), by simpa only [add_assoc, tsub_add_cancel_of_le hnm] using hi\u27e9\nend\n\nlemma measure_if {x : \u03b2} {t : set \u03b2} {s : set \u03b1} :\n  \u03bc (if x \u2208 t then s else \u2205) = indicator t (\u03bb _, \u03bc s) x :=\nby { split_ifs; simp [h] }\n\nend\n\nsection outer_measure\n\nvariables [ms : measurable_space \u03b1] {s t : set \u03b1}\ninclude ms\n\n/-- Obtain a measure by giving an outer measure where all sets in the \u03c3-algebra are\n  Carath\u00e9odory measurable. -/\ndef outer_measure.to_measure (m : outer_measure \u03b1) (h : ms \u2264 m.caratheodory) : measure \u03b1 :=\nmeasure.of_measurable (\u03bb s _, m s) m.empty\n  (\u03bb f hf hd, m.Union_eq_of_caratheodory (\u03bb i, h _ (hf i)) hd)\n\nlemma le_to_outer_measure_caratheodory (\u03bc : measure \u03b1) : ms \u2264 \u03bc.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 (\u03bb t, le_infi $ \u03bb ht, _),\n  rw [\u2190 measure_eq_extend (ht.inter hs),\n    \u2190 measure_eq_extend (ht.diff hs),\n    \u2190 measure_union _ (ht.inter hs) (ht.diff hs),\n    inter_union_diff],\n  exact le_refl _,\n  exact \u03bb x \u27e8\u27e8_, h\u2081\u27e9, _, h\u2082\u27e9, h\u2082 h\u2081\nend\n\n@[simp] lemma to_measure_to_outer_measure (m : outer_measure \u03b1) (h : ms \u2264 m.caratheodory) :\n  (m.to_measure h).to_outer_measure = m.trim := rfl\n\n@[simp] lemma to_measure_apply (m : outer_measure \u03b1) (h : ms \u2264 m.caratheodory)\n  {s : set \u03b1} (hs : measurable_set s) : m.to_measure h s = m s :=\nm.trim_eq hs\n\nlemma le_to_measure_apply (m : outer_measure \u03b1) (h : ms \u2264 m.caratheodory) (s : set \u03b1) :\n  m s \u2264 m.to_measure h s :=\nm.le_trim s\n\nlemma to_measure_apply\u2080 (m : outer_measure \u03b1) (h : ms \u2264 m.caratheodory)\n  {s : set \u03b1} (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 \u27e8t, hts, htm, heq\u27e9,\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                    ... \u2264 m s              : m.mono hts\nend\n\n@[simp] lemma to_outer_measure_to_measure {\u03bc : measure \u03b1} :\n  \u03bc.to_outer_measure.to_measure (le_to_outer_measure_caratheodory _) = \u03bc :=\nmeasure.ext $ \u03bb s, \u03bc.to_outer_measure.trim_eq\n\n@[simp] lemma bounded_by_measure (\u03bc : measure \u03b1) :\n  outer_measure.bounded_by \u03bc = \u03bc.to_outer_measure :=\n\u03bc.to_outer_measure.bounded_by_eq_self\n\nend outer_measure\n\nvariables {m0 : measurable_space \u03b1} [measurable_space \u03b2] [measurable_space \u03b3]\nvariables {\u03bc \u03bc\u2081 \u03bc\u2082 \u03bc\u2083 \u03bd \u03bd' \u03bd\u2081 \u03bd\u2082 : measure \u03b1} {s s' t : set \u03b1}\n\nlemma measure_inter_add_diff (s : set \u03b1) (ht : measurable_set t) :\n  \u03bc (s \u2229 t) + \u03bc (s \\ t) = \u03bc s :=\n(le_to_outer_measure_caratheodory \u03bc _ ht _).symm\n\nlemma measure_union_add_inter (s : set \u03b1) (ht : measurable_set t) :\n  \u03bc (s \u222a t) + \u03bc (s \u2229 t) = \u03bc s + \u03bc t :=\nby { rw [\u2190 measure_inter_add_diff (s \u222a t) ht, set.union_inter_cancel_right,\n  union_diff_right, \u2190 measure_inter_add_diff s ht], ac_refl }\n\nlemma measure_union_add_inter' (hs : measurable_set s) (t : set \u03b1) :\n  \u03bc (s \u222a t) + \u03bc (s \u2229 t) = \u03bc s + \u03bc 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 `\u03bc (t \u2229 s) = \u03bc (u \u2229 s)`. -/\nlemma measure_inter_eq_of_measure_eq {s t u : set \u03b1} (hs : measurable_set s)\n  (h : \u03bc t = \u03bc u) (htu : t \u2286 u) (ht_ne_top : \u03bc t \u2260 \u221e) :\n  \u03bc (t \u2229 s) = \u03bc (u \u2229 s) :=\nbegin\n  rw h at ht_ne_top,\n  refine le_antisymm (measure_mono (inter_subset_inter_left _ htu)) _,\n  have A : \u03bc (u \u2229 s) + \u03bc (u \\ s) \u2264 \u03bc (t \u2229 s) + \u03bc (u \\ s) := calc\n    \u03bc (u \u2229 s) + \u03bc (u \\ s) = \u03bc u : measure_inter_add_diff _ hs\n    ... = \u03bc t : h.symm\n    ... = \u03bc (t \u2229 s) + \u03bc (t \\ s) : (measure_inter_add_diff _ hs).symm\n    ... \u2264 \u03bc (t \u2229 s) + \u03bc (u \\ s) :\n      add_le_add le_rfl (measure_mono (diff_subset_diff htu subset.rfl)),\n  have B : \u03bc (u \\ s) \u2260 \u221e := (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 \u03b1} (hs : measurable_set s) (ht : \u03bc t \u2260 \u221e) :\n  \u03bc (to_measurable \u03bc t \u2229 s) = \u03bc (t \u2229 s) :=\n(measure_inter_eq_of_measure_eq hs (measure_to_measurable t).symm\n  (subset_to_measurable \u03bc t) ht).symm\n\n/-! ### The `\u211d\u22650\u221e`-module of measures -/\n\ninstance [measurable_space \u03b1] : has_zero (measure \u03b1) :=\n\u27e8{ to_outer_measure := 0,\n   m_Union := \u03bb f hf hd, tsum_zero.symm,\n   trimmed := outer_measure.trim_zero }\u27e9\n\n@[simp] theorem zero_to_outer_measure {m : measurable_space \u03b1} :\n  (0 : measure \u03b1).to_outer_measure = 0 := rfl\n\n@[simp, norm_cast] theorem coe_zero {m : measurable_space \u03b1} : \u21d1(0 : measure \u03b1) = 0 := rfl\n\nlemma eq_zero_of_is_empty [is_empty \u03b1] {m : measurable_space \u03b1} (\u03bc : measure \u03b1) : \u03bc = 0 :=\next $ \u03bb s hs, by simp only [eq_empty_of_is_empty s, measure_empty]\n\ninstance [measurable_space \u03b1] : inhabited (measure \u03b1) := \u27e80\u27e9\n\ninstance [measurable_space \u03b1] : has_add (measure \u03b1) :=\n\u27e8\u03bb \u03bc\u2081 \u03bc\u2082,\n{ to_outer_measure := \u03bc\u2081.to_outer_measure + \u03bc\u2082.to_outer_measure,\n  m_Union := \u03bb s hs hd,\n    show \u03bc\u2081 (\u22c3 i, s i) + \u03bc\u2082 (\u22c3 i, s i) = \u2211' i, (\u03bc\u2081 (s i) + \u03bc\u2082 (s i)),\n    by rw [ennreal.tsum_add, measure_Union hd hs, measure_Union hd hs],\n  trimmed := by rw [outer_measure.trim_add, \u03bc\u2081.trimmed, \u03bc\u2082.trimmed] }\u27e9\n\n@[simp] theorem add_to_outer_measure {m : measurable_space \u03b1} (\u03bc\u2081 \u03bc\u2082 : measure \u03b1) :\n  (\u03bc\u2081 + \u03bc\u2082).to_outer_measure = \u03bc\u2081.to_outer_measure + \u03bc\u2082.to_outer_measure := rfl\n\n@[simp, norm_cast] theorem coe_add {m : measurable_space \u03b1} (\u03bc\u2081 \u03bc\u2082 : measure \u03b1) :\n  \u21d1(\u03bc\u2081 + \u03bc\u2082) = \u03bc\u2081 + \u03bc\u2082 := rfl\n\ntheorem add_apply {m : measurable_space \u03b1} (\u03bc\u2081 \u03bc\u2082 : measure \u03b1) (s : set \u03b1) :\n  (\u03bc\u2081 + \u03bc\u2082) s = \u03bc\u2081 s + \u03bc\u2082 s := rfl\n\ninstance add_comm_monoid [measurable_space \u03b1] : add_comm_monoid (measure \u03b1) :=\nto_outer_measure_injective.add_comm_monoid to_outer_measure zero_to_outer_measure\n  add_to_outer_measure\n\ninstance [measurable_space \u03b1] : has_scalar \u211d\u22650\u221e (measure \u03b1) :=\n\u27e8\u03bb c \u03bc,\n  { to_outer_measure := c \u2022 \u03bc.to_outer_measure,\n    m_Union := \u03bb s hs hd, by simp [measure_Union, *, ennreal.tsum_mul_left],\n    trimmed := by rw [outer_measure.trim_smul, \u03bc.trimmed] }\u27e9\n\n@[simp] theorem smul_to_outer_measure {m : measurable_space \u03b1} (c : \u211d\u22650\u221e) (\u03bc : measure \u03b1) :\n  (c \u2022 \u03bc).to_outer_measure = c \u2022 \u03bc.to_outer_measure :=\nrfl\n\n@[simp, norm_cast] theorem coe_smul {m : measurable_space \u03b1} (c : \u211d\u22650\u221e) (\u03bc : measure \u03b1) :\n  \u21d1(c \u2022 \u03bc) = c \u2022 \u03bc :=\nrfl\n\n@[simp] theorem smul_apply {m : measurable_space \u03b1} (c : \u211d\u22650\u221e) (\u03bc : measure \u03b1) (s : set \u03b1) :\n  (c \u2022 \u03bc) s = c * \u03bc s :=\nrfl\n\ninstance [measurable_space \u03b1] : module \u211d\u22650\u221e (measure \u03b1) :=\ninjective.module \u211d\u22650\u221e \u27e8to_outer_measure, zero_to_outer_measure, add_to_outer_measure\u27e9\n  to_outer_measure_injective smul_to_outer_measure\n\n@[simp, norm_cast] theorem coe_nnreal_smul {m : measurable_space \u03b1} (c : \u211d\u22650) (\u03bc : measure \u03b1) :\n  \u21d1(c \u2022 \u03bc) = c \u2022 \u03bc :=\nrfl\n\n@[simp] theorem coe_nnreal_smul_apply {m : measurable_space \u03b1} (c : \u211d\u22650) (\u03bc : measure \u03b1)\n  (s : set \u03b1) :\n  (c \u2022 \u03bc) s = c * \u03bc s :=\nrfl\n\nlemma measure_eq_left_of_subset_of_measure_add_eq {s t : set \u03b1}\n  (h : (\u03bc + \u03bd) t \u2260 \u221e) (h' : s \u2286 t) (h'' : (\u03bc + \u03bd) s = (\u03bc + \u03bd) t) :\n  \u03bc s = \u03bc t :=\nbegin\n  refine le_antisymm (measure_mono h') _,\n  have : \u03bc t + \u03bd t \u2264 \u03bc s + \u03bd t := calc\n    \u03bc t + \u03bd t = \u03bc s + \u03bd s : h''.symm\n    ... \u2264 \u03bc s + \u03bd 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 \u03b1}\n  (h : (\u03bc + \u03bd) t \u2260 \u221e) (h' : s \u2286 t) (h'' : (\u03bc + \u03bd) s = (\u03bc + \u03bd) t) :\n  \u03bd s = \u03bd 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 \u03b1}\n  (hs : measurable_set s) (ht : (\u03bc + \u03bd) t \u2260 \u221e) :\n  \u03bc (to_measurable (\u03bc + \u03bd) t \u2229 s) = \u03bc (t \u2229 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 \u03b1}\n  (hs : measurable_set s) (ht : (\u03bc + \u03bd) t \u2260 \u221e) :\n  \u03bd (to_measurable (\u03bc + \u03bd) t \u2229 s) = \u03bd (t \u2229 s) :=\nbegin\n  rw add_comm at ht \u22a2,\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 `\u03bc \u2264 \u03bd`, we may simply `intros s hs` instead of rewriting followed\nby `intros s hs`. -/\ninstance [measurable_space \u03b1] : partial_order (measure \u03b1) :=\n{ le          := \u03bb m\u2081 m\u2082, \u2200 s, measurable_set s \u2192 m\u2081 s \u2264 m\u2082 s,\n  le_refl     := assume m s hs, le_refl _,\n  le_trans    := assume m\u2081 m\u2082 m\u2083 h\u2081 h\u2082 s hs, le_trans (h\u2081 s hs) (h\u2082 s hs),\n  le_antisymm := assume m\u2081 m\u2082 h\u2081 h\u2082, ext $\n    assume s hs, le_antisymm (h\u2081 s hs) (h\u2082 s hs) }\n\ntheorem le_iff : \u03bc\u2081 \u2264 \u03bc\u2082 \u2194 \u2200 s, measurable_set s \u2192 \u03bc\u2081 s \u2264 \u03bc\u2082 s := iff.rfl\n\ntheorem to_outer_measure_le : \u03bc\u2081.to_outer_measure \u2264 \u03bc\u2082.to_outer_measure \u2194 \u03bc\u2081 \u2264 \u03bc\u2082 :=\nby rw [\u2190 \u03bc\u2082.trimmed, outer_measure.le_trim_iff]; refl\n\ntheorem le_iff' : \u03bc\u2081 \u2264 \u03bc\u2082 \u2194 \u2200 s, \u03bc\u2081 s \u2264 \u03bc\u2082 s :=\nto_outer_measure_le.symm\n\ntheorem lt_iff : \u03bc < \u03bd \u2194 \u03bc \u2264 \u03bd \u2227 \u2203 s, measurable_set s \u2227 \u03bc s < \u03bd 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' : \u03bc < \u03bd \u2194 \u03bc \u2264 \u03bd \u2227 \u2203 s, \u03bc s < \u03bd 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 \u03b1] : covariant_class (measure \u03b1) (measure \u03b1) (+) (\u2264) :=\n\u27e8\u03bb \u03bd \u03bc\u2081 \u03bc\u2082 h\u03bc s hs, add_le_add_left (h\u03bc s hs) _\u27e9\n\nprotected lemma le_add_left (h : \u03bc \u2264 \u03bd) : \u03bc \u2264 \u03bd' + \u03bd :=\n\u03bb s hs, le_add_left (h s hs)\n\nprotected lemma le_add_right (h : \u03bc \u2264 \u03bd) : \u03bc \u2264 \u03bd + \u03bd' :=\n\u03bb s hs, le_add_right (h s hs)\n\nsection Inf\nvariables {m : set (measure \u03b1)}\n\nlemma Inf_caratheodory (s : set \u03b1) (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 (\u03bb 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 \u03bc h\u03bc u htu hu,\n  have hm : \u2200 {s t}, s \u2286 t \u2192 outer_measure.Inf_gen (to_outer_measure '' m) s \u2264 \u03bc t,\n  { intros s t hst,\n    rw [outer_measure.Inf_gen_def],\n    refine infi_le_of_le (\u03bc.to_outer_measure) (infi_le_of_le (mem_image_of_mem _ h\u03bc) _),\n    rw [to_outer_measure_apply],\n    refine measure_mono hst },\n  rw [\u2190 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 \u03b1] : has_Inf (measure \u03b1) :=\n\u27e8\u03bb m, (Inf (to_outer_measure '' m)).to_measure $ Inf_caratheodory\u27e9\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 : \u03bc \u2208 m) : Inf m \u2264 \u03bc :=\nhave Inf (to_outer_measure '' m) \u2264 \u03bc.to_outer_measure := Inf_le (mem_image_of_mem _ h),\nassume s hs, by rw [Inf_apply hs, \u2190 to_outer_measure_apply]; exact this s\n\nprivate lemma measure_le_Inf (h : \u2200 \u03bc' \u2208 m, \u03bc \u2264 \u03bc') : \u03bc \u2264 Inf m :=\nhave \u03bc.to_outer_measure \u2264 Inf (to_outer_measure '' m) :=\n  le_Inf $ ball_image_of_ball $ assume \u03bc h\u03bc, to_outer_measure_le.2 $ h _ h\u03bc,\nassume s hs, by rw [Inf_apply hs, \u2190 to_outer_measure_apply]; exact this s\n\ninstance [measurable_space \u03b1] : complete_semilattice_Inf (measure \u03b1) :=\n{ Inf_le := \u03bb s a, measure_Inf_le,\n  le_Inf := \u03bb s a, measure_le_Inf,\n  ..(by apply_instance : partial_order (measure \u03b1)),\n  ..(by apply_instance : has_Inf (measure \u03b1)), }\n\ninstance [measurable_space \u03b1] : complete_lattice (measure \u03b1) :=\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 := (\u22a4 : outer_measure \u03b1).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 \u22a4 _ hs, outer_measure.top_apply],\n-/\n  .. complete_lattice_of_complete_semilattice_Inf (measure \u03b1) }\n\nend Inf\n\nprotected lemma zero_le {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) : 0 \u2264 \u03bc := bot_le\n\nlemma nonpos_iff_eq_zero' : \u03bc \u2264 0 \u2194 \u03bc = 0 :=\n\u03bc.zero_le.le_iff_eq\n\n@[simp] lemma measure_univ_eq_zero : \u03bc univ = 0 \u2194 \u03bc = 0 :=\n\u27e8\u03bb h, bot_unique $ \u03bb s hs, trans_rel_left (\u2264) (measure_mono (subset_univ s)) h, \u03bb h, h.symm \u25b8 rfl\u27e9\n\n/-! ### Pushforward and pullback -/\n\n/-- Lift a linear map between `outer_measure` spaces such that for each measure `\u03bc` every measurable\nset is caratheodory-measurable w.r.t. `f \u03bc` to a linear map between `measure` spaces. -/\ndef lift_linear {m0 : measurable_space \u03b1} (f : outer_measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] outer_measure \u03b2)\n  (hf : \u2200 \u03bc : measure \u03b1, \u2039_\u203a \u2264 (f \u03bc.to_outer_measure).caratheodory) :\n  measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] measure \u03b2 :=\n{ to_fun := \u03bb \u03bc, (f \u03bc.to_outer_measure).to_measure (hf \u03bc),\n  map_add' := \u03bb \u03bc\u2081 \u03bc\u2082, ext $ \u03bb s hs, by simp [hs],\n  map_smul' := \u03bb c \u03bc, ext $ \u03bb s hs, by simp [hs] }\n\n@[simp] lemma lift_linear_apply {f : outer_measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] outer_measure \u03b2} (hf)\n  {s : set \u03b2} (hs : measurable_set s) : lift_linear f hf \u03bc s = f \u03bc.to_outer_measure s :=\nto_measure_apply _ _ hs\n\nlemma le_lift_linear_apply {f : outer_measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] outer_measure \u03b2} (hf) (s : set \u03b2) :\n  f \u03bc.to_outer_measure s \u2264 lift_linear f hf \u03bc 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 \u03b1] (f : \u03b1 \u2192 \u03b2) : measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] measure \u03b2 :=\nif hf : measurable f then\n  lift_linear (outer_measure.map f) $ \u03bb \u03bc s hs t,\n    le_to_outer_measure_caratheodory \u03bc _ (hf hs) (f \u207b\u00b9' 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 : \u03b1 \u2192 \u03b2} (hf : measurable f) {s : set \u03b2} (hs : measurable_set s) :\n  map f \u03bc s = \u03bc (f \u207b\u00b9' s) :=\nby simp [map, dif_pos hf, hs]\n\nlemma map_to_outer_measure {f : \u03b1 \u2192 \u03b2} (hf : measurable f) :\n  (map f \u03bc).to_outer_measure = (outer_measure.map f \u03bc.to_outer_measure).trim :=\nbegin\n  rw [\u2190 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 : \u03b1 \u2192 \u03b2} (hf : \u00acmeasurable f) :\n  map f \u03bc = 0 :=\nby rw [map, dif_neg hf, linear_map.zero_apply]\n\n@[simp] lemma map_id : map id \u03bc = \u03bc :=\next $ \u03bb s, map_apply measurable_id\n\nlemma map_map {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : measurable g) (hf : measurable f) :\n  map g (map f \u03bc) = map (g \u2218 f) \u03bc :=\next $ \u03bb s hs,\nby simp [hf, hg, hs, hg hs, hg.comp hf, \u2190 preimage_comp]\n\n@[mono] lemma map_mono (f : \u03b1 \u2192 \u03b2) (h : \u03bc \u2264 \u03bd) : map f \u03bc \u2264 map f \u03bd :=\nif hf : measurable f then \u03bb 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 \u03bc s` from below.\n  See also `measurable_equiv.map_apply`. -/\ntheorem le_map_apply {f : \u03b1 \u2192 \u03b2} (hf : measurable f) (s : set \u03b2) : \u03bc (f \u207b\u00b9' s) \u2264 map f \u03bc s :=\ncalc \u03bc (f \u207b\u00b9' s) \u2264 \u03bc (f \u207b\u00b9' (to_measurable (map f \u03bc) s)) :\n  measure_mono $ preimage_mono $ subset_to_measurable _ _\n... = map f \u03bc (to_measurable (map f \u03bc) s) : (map_apply hf $ measurable_set_to_measurable _ _).symm\n... = map f \u03bc s : measure_to_measurable _\n\n/-- Even if `s` is not measurable, `map f \u03bc s = 0` implies that `\u03bc (f \u207b\u00b9' s) = 0`. -/\nlemma preimage_null_of_map_null {f : \u03b1 \u2192 \u03b2} (hf : measurable f) {s : set \u03b2}\n  (hs : map f \u03bc s = 0) : \u03bc (f \u207b\u00b9' s) = 0 :=\nnonpos_iff_eq_zero.mp $ (le_map_apply hf s).trans_eq hs\n\nlemma tendsto_ae_map {f : \u03b1 \u2192 \u03b2} (hf : measurable f) : tendsto f \u03bc.ae (map f \u03bc).ae :=\n\u03bb 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 \u03bc s = \u03bc (f '' s)`. -/\ndef comap [measurable_space \u03b1] (f : \u03b1 \u2192 \u03b2) : measure \u03b2 \u2192\u2097[\u211d\u22650\u221e] measure \u03b1 :=\nif hf : injective f \u2227 \u2200 s, measurable_set s \u2192 measurable_set (f '' s) then\n  lift_linear (outer_measure.comap f) $ \u03bb \u03bc s hs t,\n  begin\n    simp only [coe_to_outer_measure, outer_measure.comap_apply, \u2190 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 {\u03b2} [measurable_space \u03b1] {m\u03b2 : measurable_space \u03b2} (f : \u03b1 \u2192 \u03b2) (hfi : injective f)\n  (hf : \u2200 s, measurable_set s \u2192 measurable_set (f '' s)) (\u03bc : measure \u03b2) (hs : measurable_set s) :\n  comap f \u03bc s = \u03bc (f '' s) :=\nbegin\n  rw [comap, dif_pos, lift_linear_apply _ hs, outer_measure.comap_apply, coe_to_outer_measure],\n  exact \u27e8hfi, hf\u27e9\nend\n\n/-! ### Restricting a measure -/\n\n/-- Restrict a measure `\u03bc` to a set `s` as an `\u211d\u22650\u221e`-linear map. -/\ndef restrict\u2097 {m0 : measurable_space \u03b1} (s : set \u03b1) : measure \u03b1 \u2192\u2097[\u211d\u22650\u221e] measure \u03b1 :=\nlift_linear (outer_measure.restrict s) $ \u03bb \u03bc s' hs' t,\nbegin\n  suffices : \u03bc (s \u2229 t) = \u03bc (s \u2229 t \u2229 s') + \u03bc (s \u2229 t \\ s'),\n  { simpa [\u2190 set.inter_assoc, set.inter_comm _ s, \u2190 inter_diff_assoc] },\n  exact le_to_outer_measure_caratheodory _ _ hs' _,\nend\n\n/-- Restrict a measure `\u03bc` to a set `s`. -/\ndef restrict {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) (s : set \u03b1) : measure \u03b1 := restrict\u2097 s \u03bc\n\n@[simp] lemma restrict\u2097_apply {m0 : measurable_space \u03b1} (s : set \u03b1) (\u03bc : measure \u03b1) :\n  restrict\u2097 s \u03bc = \u03bc.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    (\u03bc.restrict s).to_outer_measure = outer_measure.restrict s \u03bc.to_outer_measure :=\nby simp_rw [restrict, restrict\u2097, lift_linear, linear_map.coe_mk, to_measure_to_outer_measure,\n  outer_measure.restrict_trim h, \u03bc.trimmed]\n\nlemma restrict_apply\u2080 (ht : null_measurable_set t (\u03bc.restrict s)) :\n  \u03bc.restrict s t = \u03bc (t \u2229 s) :=\n(to_measure_apply\u2080 _ _ 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 \u2229 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) : \u03bc.restrict s t = \u03bc (t \u2229 s) :=\nrestrict_apply\u2080 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 \u2229 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) : \u03bc.restrict s t = \u03bc (t \u2229 s) :=\nby rw [\u2190 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 \u2286 s) :\n  \u03bc.restrict s t = \u03bc 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 \u2286 s) : \u03bc.restrict s t = \u03bc t :=\nby rw [restrict_apply h_meas_t, inter_eq_left_iff_subset.mpr h]\n\nlemma restrict_apply_self {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) (h_meas_s : measurable_set s) :\n  (\u03bc.restrict s) s = \u03bc s := (restrict_eq_self h_meas_s (set.subset.refl _))\n\nlemma restrict_apply_univ (s : set \u03b1) : \u03bc.restrict s univ = \u03bc s :=\nby rw [restrict_apply measurable_set.univ, set.univ_inter]\n\nlemma le_restrict_apply (s t : set \u03b1) :\n  \u03bc (t \u2229 s) \u2264 \u03bc.restrict s t :=\nby { rw [restrict, restrict\u2097], convert le_lift_linear_apply _ t, simp }\n\n@[simp] lemma restrict_add {m0 : measurable_space \u03b1} (\u03bc \u03bd : measure \u03b1) (s : set \u03b1) :\n  (\u03bc + \u03bd).restrict s = \u03bc.restrict s + \u03bd.restrict s :=\n(restrict\u2097 s).map_add \u03bc \u03bd\n\n@[simp] lemma restrict_zero {m0 : measurable_space \u03b1} (s : set \u03b1) :\n  (0 : measure \u03b1).restrict s = 0 :=\n(restrict\u2097 s).map_zero\n\n@[simp] lemma restrict_smul {m0 : measurable_space \u03b1} (c : \u211d\u22650\u221e) (\u03bc : measure \u03b1) (s : set \u03b1) :\n  (c \u2022 \u03bc).restrict s = c \u2022 \u03bc.restrict s :=\n(restrict\u2097 s).map_smul c \u03bc\n\n@[simp] lemma restrict_restrict (hs : measurable_set s) :\n  (\u03bc.restrict t).restrict s = \u03bc.restrict (s \u2229 t) :=\next $ \u03bb u hu, by simp [*, set.inter_assoc]\n\nlemma restrict_comm (hs : measurable_set s) (ht : measurable_set t) :\n  (\u03bc.restrict t).restrict s = (\u03bc.restrict s).restrict t :=\nby rw [restrict_restrict hs, restrict_restrict ht, inter_comm]\n\nlemma restrict_apply_eq_zero (ht : measurable_set t) : \u03bc.restrict s t = 0 \u2194 \u03bc (t \u2229 s) = 0 :=\nby rw [restrict_apply ht]\n\nlemma measure_inter_eq_zero_of_restrict (h : \u03bc.restrict s t = 0) : \u03bc (t \u2229 s) = 0 :=\nnonpos_iff_eq_zero.1 (h \u25b8 le_restrict_apply _ _)\n\nlemma restrict_apply_eq_zero' (hs : measurable_set s) : \u03bc.restrict s t = 0 \u2194 \u03bc (t \u2229 s) = 0 :=\nby rw [restrict_apply' hs]\n\n@[simp] lemma restrict_eq_zero : \u03bc.restrict s = 0 \u2194 \u03bc s = 0 :=\nby rw [\u2190 measure_univ_eq_zero, restrict_apply_univ]\n\nlemma restrict_zero_set {s : set \u03b1} (h : \u03bc s = 0) :\n  \u03bc.restrict s = 0 :=\nby simp only [measure.restrict_eq_zero, h]\n\n@[simp] lemma restrict_empty : \u03bc.restrict \u2205 = 0 := restrict_zero_set measure_empty\n\n@[simp] lemma restrict_univ : \u03bc.restrict univ = \u03bc := ext $ \u03bb s hs, by simp [hs]\n\nlemma restrict_union_apply (h : disjoint (t \u2229 s) (t \u2229 s')) (hs : measurable_set s)\n  (hs' : measurable_set s') (ht : measurable_set t) :\n  \u03bc.restrict (s \u222a s') t = \u03bc.restrict s t + \u03bc.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  \u03bc.restrict (s \u222a t) = \u03bc.restrict s + \u03bc.restrict t :=\next $ \u03bb t' ht', restrict_union_apply (h.mono inf_le_right inf_le_right) hs ht ht'\n\nlemma restrict_union_add_inter (s : set \u03b1) (ht : measurable_set t) :\n  \u03bc.restrict (s \u222a t) + \u03bc.restrict (s \u2229 t) = \u03bc.restrict s + \u03bc.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 \u2229 s) (hu.inter ht) using 3,\n  rw [set.inter_left_comm (u \u2229 s), set.inter_assoc, \u2190 set.inter_assoc u u, set.inter_self]\nend\n\n@[simp] lemma restrict_add_restrict_compl (hs : measurable_set s) :\n  \u03bc.restrict s + \u03bc.restrict s\u1d9c = \u03bc :=\nby rw [\u2190 restrict_union (@disjoint_compl_right (set \u03b1) _ _) hs hs.compl,\n    union_compl_self, restrict_univ]\n\n@[simp] lemma restrict_compl_add_restrict (hs : measurable_set s) :\n  \u03bc.restrict s\u1d9c + \u03bc.restrict s = \u03bc :=\nby rw [add_comm, restrict_add_restrict_compl hs]\n\nlemma restrict_union_le (s s' : set \u03b1) : \u03bc.restrict (s \u222a s') \u2264 \u03bc.restrict s + \u03bc.restrict s' :=\nbegin\n  intros t ht,\n  suffices : \u03bc (t \u2229 s \u222a t \u2229 s') \u2264 \u03bc (t \u2229 s) + \u03bc (t \u2229 s'),\n    by simpa [ht, inter_union_distrib_left],\n  apply measure_union_le\nend\n\nlemma restrict_Union_apply_ae [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1}\n  (hd : pairwise (\u03bb i j, \u03bc (s i \u2229 s j) = 0))\n  (hm : \u2200 i, measurable_set (s i)) {t : set \u03b1} (ht : measurable_set t) :\n  \u03bc.restrict (\u22c3 i, s i) t = \u2211' i, \u03bc.restrict (s i) t :=\nbegin\n  simp only [restrict_apply, ht, inter_Union],\n  exact measure_Union_of_null_inter (\u03bb i, ht.inter (hm _)) (\u03bb 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 \u03b9] {s : \u03b9 \u2192 set \u03b1} (hd : pairwise (disjoint on s))\n  (hm : \u2200 i, measurable_set (s i)) {t : set \u03b1} (ht : measurable_set t) :\n  \u03bc.restrict (\u22c3 i, s i) t = \u2211' i, \u03bc.restrict (s i) t :=\nrestrict_Union_apply_ae (\u03bb 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 \u03b9] {s : \u03b9 \u2192 set \u03b1}\n  (hm : \u2200 i, measurable_set (s i)) (hd : directed (\u2286) s) {t : set \u03b1} (ht : measurable_set t) :\n  \u03bc.restrict (\u22c3 i, s i) t = \u2a06 i, \u03bc.restrict (s i) t :=\nbegin\n  simp only [restrict_apply ht, inter_Union],\n  rw [measure_Union_eq_supr],\n  exacts [\u03bb i, ht.inter (hm i), hd.mono_comp _ (\u03bb s\u2081 s\u2082, inter_subset_inter_right _)]\nend\n\nlemma restrict_map {f : \u03b1 \u2192 \u03b2} (hf : measurable f) {s : set \u03b2} (hs : measurable_set s) :\n  (map f \u03bc).restrict s = map f (\u03bc.restrict $ f \u207b\u00b9' s) :=\next $ \u03bb 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 \u03b1} \u2983s s' : set \u03b1\u2984 \u2983\u03bc \u03bd : measure \u03b1\u2984\n  (hs : s \u2264\u1d50[\u03bc] s') (h\u03bc\u03bd : \u03bc \u2264 \u03bd) :\n  \u03bc.restrict s \u2264 \u03bd.restrict s' :=\nassume t ht,\ncalc \u03bc.restrict s t = \u03bc (t \u2229 s) : restrict_apply ht\n... \u2264 \u03bc (t \u2229 s') : measure_mono_ae $ hs.mono $ \u03bb x hx \u27e8hxt, hxs\u27e9, \u27e8hxt, hx hxs\u27e9\n... \u2264 \u03bd (t \u2229 s') : le_iff'.1 h\u03bc\u03bd (t \u2229 s')\n... = \u03bd.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 \u03b1} \u2983s s' : set \u03b1\u2984 (hs : s \u2286 s') \u2983\u03bc \u03bd : measure \u03b1\u2984\n  (h\u03bc\u03bd : \u03bc \u2264 \u03bd) :\n  \u03bc.restrict s \u2264 \u03bd.restrict s' :=\nrestrict_mono' (ae_of_all _ hs) h\u03bc\u03bd\n\nlemma restrict_le_self : \u03bc.restrict s \u2264 \u03bc :=\nassume t ht,\ncalc \u03bc.restrict s t = \u03bc (t \u2229 s) : restrict_apply ht\n... \u2264 \u03bc t : measure_mono $ inter_subset_left t s\n\nlemma restrict_mono_ae (h : s \u2264\u1d50[\u03bc] t) : \u03bc.restrict s \u2264 \u03bc.restrict t :=\nrestrict_mono' h (le_refl \u03bc)\n\nlemma restrict_congr_set (h : s =\u1d50[\u03bc] t) : \u03bc.restrict s = \u03bc.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 \u03b1} \u2983s : set \u03b1\u2984 \u2983\u03bc : measure \u03b1\u2984\n  (hs : \u2200\u1d50 x \u2202\u03bc, x \u2208 s) :\n  \u03bc.restrict s = \u03bc :=\ncalc \u03bc.restrict s = \u03bc.restrict univ : restrict_congr_set (eventually_eq_univ.mpr hs)\n... = \u03bc : restrict_univ\n\nlemma restrict_congr_meas (hs : measurable_set s) :\n  \u03bc.restrict s = \u03bd.restrict s \u2194 \u2200 t \u2286 s, measurable_set t \u2192 \u03bc t = \u03bd t :=\n\u27e8\u03bb H t hts ht,\n   by rw [\u2190 inter_eq_self_of_subset_left hts, \u2190 restrict_apply ht, H, restrict_apply ht],\n \u03bb H, ext $ \u03bb t ht,\n   by rw [restrict_apply ht, restrict_apply ht, H _ (inter_subset_right _ _) (ht.inter hs)]\u27e9\n\nlemma restrict_congr_mono (hs : s \u2286 t) (hm : measurable_set s) (h : \u03bc.restrict t = \u03bd.restrict t) :\n  \u03bc.restrict s = \u03bd.restrict s :=\nby rw [\u2190 inter_eq_self_of_subset_left hs, \u2190 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 \u222a t`. -/\nlemma restrict_union_congr (hsm : measurable_set s) (htm : measurable_set t) :\n  \u03bc.restrict (s \u222a t) = \u03bd.restrict (s \u222a t) \u2194\n    \u03bc.restrict s = \u03bd.restrict s \u2227 \u03bc.restrict t = \u03bd.restrict t :=\nbegin\n  refine \u27e8\u03bb h, \u27e8restrict_congr_mono (subset_union_left _ _) hsm h,\n    restrict_congr_mono (subset_union_right _ _) htm h\u27e9, _\u27e9,\n  simp only [restrict_congr_meas, hsm, htm, hsm.union htm],\n  rintros \u27e8hs, ht\u27e9 u hu hum,\n  rw [\u2190 measure_inter_add_diff u hsm, \u2190 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 \u03b9} {t : \u03b9 \u2192 set \u03b1}\n  (htm : \u2200 i \u2208 s, measurable_set (t i)) :\n  \u03bc.restrict (\u22c3 i \u2208 s, t i) = \u03bd.restrict (\u22c3 i \u2208 s, t i) \u2194\n    \u2200 i \u2208 s, \u03bc.restrict (t i) = \u03bd.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 \u22a2,\n  simp only [finset.set_bUnion_insert, \u2190 hs htm.2],\n  exact restrict_union_congr htm.1 (s.measurable_set_bUnion htm.2)\nend\n\nlemma restrict_Union_congr [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1} (hm : \u2200 i, measurable_set (s i)) :\n  \u03bc.restrict (\u22c3 i, s i) = \u03bd.restrict (\u22c3 i, s i) \u2194\n    \u2200 i, \u03bc.restrict (s i) = \u03bd.restrict (s i) :=\nbegin\n  refine \u27e8\u03bb h i, restrict_congr_mono (subset_Union _ _) (hm i) h, \u03bb h, _\u27e9,\n  ext1 t ht,\n  have M : \u2200 t : finset \u03b9, measurable_set (\u22c3 i \u2208 t, s i) :=\n    \u03bb t, t.measurable_set_bUnion (\u03bb i _, hm i),\n  have D : directed (\u2286) (\u03bb t : finset \u03b9, \u22c3 i \u2208 t, s i) :=\n    directed_of_sup (\u03bb t\u2081 t\u2082 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 (\u03bb i hi, hm i)).2 (\u03bb i hi, h i)],\nend\n\nlemma restrict_bUnion_congr {s : set \u03b9} {t : \u03b9 \u2192 set \u03b1} (hc : countable s)\n  (htm : \u2200 i \u2208 s, measurable_set (t i)) :\n  \u03bc.restrict (\u22c3 i \u2208 s, t i) = \u03bd.restrict (\u22c3 i \u2208 s, t i) \u2194\n    \u2200 i \u2208 s, \u03bc.restrict (t i) = \u03bd.restrict (t i) :=\nbegin\n  simp only [bUnion_eq_Union, set_coe.forall'] at htm \u22a2,\n  haveI := hc.to_encodable,\n  exact restrict_Union_congr htm\nend\n\nlemma restrict_sUnion_congr {S : set (set \u03b1)} (hc : countable S) (hm : \u2200 s \u2208 S, measurable_set s) :\n  \u03bc.restrict (\u22c3\u2080 S) = \u03bd.restrict (\u22c3\u2080 S) \u2194 \u2200 s \u2208 S, \u03bc.restrict s = \u03bd.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 \u03b1} {m : set (measure \u03b1)}\n  (hm : m.nonempty) (ht : measurable_set t) :\n  (Inf m).restrict t = Inf ((\u03bb \u03bc : measure \u03b1, \u03bc.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, \u2190 set.image_image _ to_outer_measure,\n    \u2190 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 \u03b9] {s : \u03b9 \u2192 set \u03b1}\n  (hm : \u2200 i, measurable_set (s i)) (hs : (\u22c3 i, s i) = univ) :\n  \u03bc = \u03bd \u2194 \u2200 i, \u03bc.restrict (s i) = \u03bd.restrict (s i) :=\nby rw [\u2190 restrict_Union_congr hm, hs, restrict_univ, restrict_univ]\n\nalias ext_iff_of_Union_eq_univ \u2194 _ 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 \u03b9} {s : \u03b9 \u2192 set \u03b1} (hc : countable S)\n  (hm : \u2200 i \u2208 S, measurable_set (s i)) (hs : (\u22c3 i \u2208 S, s i) = univ) :\n  \u03bc = \u03bd \u2194 \u2200 i \u2208 S, \u03bc.restrict (s i) = \u03bd.restrict (s i) :=\nby rw [\u2190 restrict_bUnion_congr hc hm, hs, restrict_univ, restrict_univ]\n\nalias ext_iff_of_bUnion_eq_univ \u2194 _ 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 \u03b1)} (hc : countable S)\n  (hm : \u2200 s \u2208 S, measurable_set s) (hs : (\u22c3\u2080 S) = univ) :\n  \u03bc = \u03bd \u2194 \u2200 s \u2208 S, \u03bc.restrict s = \u03bd.restrict s :=\next_iff_of_bUnion_eq_univ hc hm $ by rwa \u2190 sUnion_eq_bUnion\n\nalias ext_iff_of_sUnion_eq_univ \u2194 _ measure_theory.measure.ext_of_sUnion_eq_univ\n\nlemma ext_of_generate_from_of_cover {S T : set (set \u03b1)}\n  (h_gen : \u2039_\u203a = generate_from S) (hc : countable T)\n  (h_inter : is_pi_system S)\n  (hm : \u2200 t \u2208 T, measurable_set t) (hU : \u22c3\u2080 T = univ) (htop : \u2200 t \u2208 T, \u03bc t \u2260 \u221e)\n  (ST_eq : \u2200 (t \u2208 T) (s \u2208 S), \u03bc (s \u2229 t) = \u03bd (s \u2229 t)) (T_eq : \u2200 t \u2208 T, \u03bc t = \u03bd t) :\n  \u03bc = \u03bd :=\nbegin\n  refine ext_of_sUnion_eq_univ hc hm hU (\u03bb 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 \u22a2,\n    rwa [\u2190 measure_inter_add_diff t hv, \u2190 measure_inter_add_diff t hv, \u2190 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 \u03bb n, f n \u2229 t) :=\n      \u03bb m n hmn, (hfd m n hmn).mono (inter_subset_left _ _) (inter_subset_left _ _),\n    simp only [Union_inter, measure_Union this (\u03bb n, (hfm n).inter (hm t ht)), h_eq] }\nend\n\n/-- Two measures are equal if they are equal on the \u03c0-system generating the \u03c3-algebra,\n  and they are both finite on a increasing spanning sequence of sets in the \u03c0-system.\n  This lemma is formulated using `sUnion`. -/\nlemma ext_of_generate_from_of_cover_subset {S T : set (set \u03b1)}\n  (h_gen : \u2039_\u203a = generate_from S)\n  (h_inter : is_pi_system S)\n  (h_sub : T \u2286 S) (hc : countable T) (hU : \u22c3\u2080 T = univ) (htop : \u2200 s \u2208 T, \u03bc s \u2260 \u221e)\n  (h_eq : \u2200 s \u2208 S, \u03bc s = \u03bd s) :\n  \u03bc = \u03bd :=\nbegin\n  refine ext_of_generate_from_of_cover h_gen hc h_inter _ hU htop _ (\u03bb 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 \u2229 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 \u03c0-system generating the \u03c3-algebra,\n  and they are both finite on a increasing spanning sequence of sets in the \u03c0-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 \u03b1)) (B : \u2115 \u2192 set \u03b1)\n  (hA : \u2039_\u203a = generate_from C) (hC : is_pi_system C) (h1B : (\u22c3 i, B i) = univ)\n  (h2B : \u2200 i, B i \u2208 C) (h\u03bcB : \u2200 i, \u03bc (B i) \u2260 \u221e) (h_eq : \u2200 s \u2208 C, \u03bc s = \u03bd s) : \u03bc = \u03bd :=\nbegin\n  refine ext_of_generate_from_of_cover_subset hA hC _ (countable_range B) h1B _ h_eq,\n  { rintro _ \u27e8i, rfl\u27e9, apply h2B },\n  { rintro _ \u27e8i, rfl\u27e9, apply h\u03bcB }\nend\n\nsection dirac\nvariable [measurable_space \u03b1]\n\n/-- The dirac measure. -/\ndef dirac (a : \u03b1) : measure \u03b1 :=\n(outer_measure.dirac a).to_measure (by simp)\n\ninstance : measure_space punit := \u27e8dirac punit.star\u27e9\n\nlemma le_dirac_apply {a} : s.indicator 1 a \u2264 dirac a s :=\nouter_measure.dirac_apply a s \u25b8 le_to_measure_apply _ _ _\n\n@[simp] lemma dirac_apply' (a : \u03b1) (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 : \u03b1} (h : a \u2208 s) :\n  dirac a s = 1 :=\nbegin\n  have : \u2200 t : set \u03b1, a \u2208 t \u2192 t.indicator (1 : \u03b1 \u2192 \u211d\u22650\u221e) a = 1,\n    from \u03bb t ht, indicator_of_mem ht 1,\n  refine le_antisymm (this univ trivial \u25b8 _) (this s h \u25b8 le_dirac_apply),\n  rw [\u2190 dirac_apply' a measurable_set.univ],\n  exact measure_mono (subset_univ s)\nend\n\n@[simp] lemma dirac_apply [measurable_singleton_class \u03b1] (a : \u03b1) (s : set \u03b1) :\n  dirac a s = s.indicator 1 a :=\nbegin\n  by_cases h : a \u2208 s, by rw [dirac_apply_of_mem h, indicator_of_mem h, pi.one_apply],\n  rw [indicator_of_not_mem h, \u2190 nonpos_iff_eq_zero],\n  calc dirac a s \u2264 dirac a {a}\u1d9c : 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 : \u03b1 \u2192 \u03b2} (hf : measurable f) (a : \u03b1) :\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 (\u03bc : measure \u03b1) (a : \u03b1) : \u03bc.restrict {a} = \u03bc {a} \u2022 dirac a :=\nbegin\n  ext1 s hs,\n  by_cases ha : a \u2208 s,\n  { have : s \u2229 {a} = {a}, by simpa,\n    simp * },\n  { have : s \u2229 {a} = \u2205, 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 : \u03b9 \u2192 measure \u03b1) : measure \u03b1 :=\n(outer_measure.sum (\u03bb i, (f i).to_outer_measure)).to_measure $\nle_trans\n  (by exact le_infi (\u03bb i, le_to_outer_measure_caratheodory _))\n  (outer_measure.le_sum_caratheodory _)\n\nlemma le_sum_apply (f : \u03b9 \u2192 measure \u03b1) (s : set \u03b1) : (\u2211' i, f i s) \u2264 sum f s :=\nle_to_measure_apply _ _ _\n\n@[simp] lemma sum_apply (f : \u03b9 \u2192 measure \u03b1) {s : set \u03b1} (hs : measurable_set s) :\n  sum f s = \u2211' i, f i s :=\nto_measure_apply _ _ hs\n\nlemma le_sum (\u03bc : \u03b9 \u2192 measure \u03b1) (i : \u03b9) : \u03bc i \u2264 sum \u03bc :=\n\u03bb s hs, by simp only [sum_apply \u03bc hs, ennreal.le_tsum i]\n\n@[simp] lemma sum_apply_eq_zero [encodable \u03b9] {\u03bc : \u03b9 \u2192 measure \u03b1} {s : set \u03b1} :\n  sum \u03bc s = 0 \u2194 \u2200 i, \u03bc i s = 0 :=\nbegin\n  refine \u27e8\u03bb h i, nonpos_iff_eq_zero.1 $ h \u25b8 le_iff'.1 (le_sum \u03bc i) _, \u03bb h, nonpos_iff_eq_zero.1 _\u27e9,\n  rcases exists_measurable_superset_forall_eq \u03bc s with \u27e8t, hst, htm, ht\u27e9,\n  calc sum \u03bc s \u2264 sum \u03bc t : measure_mono hst\n           ... = 0       : by simp *\nend\n\nlemma sum_apply_eq_zero' {\u03bc : \u03b9 \u2192 measure \u03b1} {s : set \u03b1} (hs : measurable_set s) :\n  sum \u03bc s = 0 \u2194 \u2200 i, \u03bc i s = 0 :=\nby simp [hs]\n\nlemma ae_sum_iff [encodable \u03b9] {\u03bc : \u03b9 \u2192 measure \u03b1} {p : \u03b1 \u2192 Prop} :\n  (\u2200\u1d50 x \u2202(sum \u03bc), p x) \u2194 \u2200 i, \u2200\u1d50 x \u2202(\u03bc i), p x :=\nsum_apply_eq_zero\n\nlemma ae_sum_iff' {\u03bc : \u03b9 \u2192 measure \u03b1} {p : \u03b1 \u2192 Prop} (h : measurable_set {x | p x}) :\n  (\u2200\u1d50 x \u2202(sum \u03bc), p x) \u2194 \u2200 i, \u2200\u1d50 x \u2202(\u03bc i), p x :=\nsum_apply_eq_zero' h.compl\n\n@[simp] lemma ae_sum_eq [encodable \u03b9] (\u03bc : \u03b9 \u2192 measure \u03b1) : (sum \u03bc).ae = \u2a06 i, (\u03bc i).ae :=\nfilter.ext $ \u03bb s, ae_sum_iff.trans mem_supr.symm\n\n@[simp] lemma sum_bool (f : bool \u2192 measure \u03b1) : sum f = f tt + f ff :=\next $ \u03bb s hs, by simp [hs, tsum_fintype]\n\n@[simp] lemma sum_cond (\u03bc \u03bd : measure \u03b1) : sum (\u03bb b, cond b \u03bc \u03bd) = \u03bc + \u03bd := sum_bool _\n\n@[simp] lemma restrict_sum (\u03bc : \u03b9 \u2192 measure \u03b1) {s : set \u03b1} (hs : measurable_set s) :\n  (sum \u03bc).restrict s = sum (\u03bb i, (\u03bc i).restrict s) :=\next $ \u03bb t ht, by simp only [sum_apply, restrict_apply, ht, ht.inter hs]\n\n@[simp] lemma sum_of_empty [is_empty \u03b9] (\u03bc : \u03b9 \u2192 measure \u03b1) : sum \u03bc = 0 :=\nby rw [\u2190 measure_univ_eq_zero, sum_apply _ measurable_set.univ, tsum_empty]\n\nlemma sum_congr {\u03bc \u03bd : \u2115 \u2192 measure \u03b1} (h : \u2200 n, \u03bc n = \u03bd n) : sum \u03bc = sum \u03bd :=\nby { congr, ext1 n, exact h n }\n\nlemma sum_add_sum (\u03bc \u03bd : \u2115 \u2192 measure \u03b1) : sum \u03bc + sum \u03bd = sum (\u03bb n, \u03bc n + \u03bd 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 \u03bc` is the sum of Dirac measures -/\nlemma map_eq_sum [encodable \u03b2] [measurable_singleton_class \u03b2]\n  (\u03bc : measure \u03b1) (f : \u03b1 \u2192 \u03b2) (hf : measurable f) :\n  map f \u03bc = sum (\u03bb b : \u03b2, \u03bc (f \u207b\u00b9' {b}) \u2022 dirac b) :=\nbegin\n  ext1 s hs,\n  have : \u2200 y \u2208 s, measurable_set (f \u207b\u00b9' {y}), from \u03bb y _, hf (measurable_set_singleton _),\n  simp [\u2190 tsum_measure_preimage_singleton (countable_encodable s) this, *,\n    tsum_subtype s (\u03bb b, \u03bc (f \u207b\u00b9' {b})), \u2190 indicator_mul_right s (\u03bb b, \u03bc (f \u207b\u00b9' {b}))]\nend\n\n/-- A measure on an encodable type is a sum of dirac measures. -/\n@[simp] lemma sum_smul_dirac [encodable \u03b1] [measurable_singleton_class \u03b1] (\u03bc : measure \u03b1) :\n  sum (\u03bb a, \u03bc {a} \u2022 dirac a) = \u03bc :=\nby simpa using (map_eq_sum \u03bc id measurable_id).symm\n\nomit m0\nend sum\n\nlemma restrict_Union_ae [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1} (hd : pairwise (\u03bb i j, \u03bc (s i \u2229 s j) = 0))\n  (hm : \u2200 i, measurable_set (s i)) :\n  \u03bc.restrict (\u22c3 i, s i) = sum (\u03bb i, \u03bc.restrict (s i)) :=\next $ \u03bb t ht, by simp only [sum_apply _ ht, restrict_Union_apply_ae hd hm ht]\n\nlemma restrict_Union [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1} (hd : pairwise (disjoint on s))\n  (hm : \u2200 i, measurable_set (s i)) :\n  \u03bc.restrict (\u22c3 i, s i) = sum (\u03bb i, \u03bc.restrict (s i)) :=\next $ \u03bb t ht, by simp only [sum_apply _ ht, restrict_Union_apply hd hm ht]\n\nlemma restrict_Union_le [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1} :\n  \u03bc.restrict (\u22c3 i, s i) \u2264 sum (\u03bb i, \u03bc.restrict (s i)) :=\nbegin\n  intros t ht,\n  suffices : \u03bc (\u22c3 i, t \u2229 s i) \u2264 \u2211' i, \u03bc (t \u2229 s i), by simpa [ht, inter_Union],\n  apply measure_Union_le\nend\n\nsection count\n\nvariable [measurable_space \u03b1]\n\n/-- Counting measure on any measurable space. -/\ndef count : measure \u03b1 := sum dirac\n\nlemma le_count_apply : (\u2211' i : s, 1 : \u211d\u22650\u221e) \u2264 count s :=\ncalc (\u2211' i : s, 1 : \u211d\u22650\u221e) = \u2211' i, indicator s 1 i : tsum_subtype s 1\n... \u2264 \u2211' i, dirac i s : ennreal.tsum_le_tsum $ \u03bb x, le_dirac_apply\n... \u2264 count s : le_sum_apply _ _\n\nlemma count_apply (hs : measurable_set s) : count s = \u2211' i : s, 1 :=\nby simp only [count, sum_apply, hs, dirac_apply', \u2190 tsum_subtype s 1, pi.one_apply]\n\n@[simp] lemma count_apply_finset [measurable_singleton_class \u03b1] (s : finset \u03b1) :\n  count (\u2191s : set \u03b1) = s.card :=\ncalc count (\u2191s : set \u03b1) = \u2211' i : (\u2191s : set \u03b1), 1 : count_apply s.measurable_set\n                    ... = \u2211 i in s, 1 : s.tsum_subtype 1\n                    ... = s.card : by simp\n\nlemma count_apply_finite [measurable_singleton_class \u03b1] (s : set \u03b1) (hs : finite s) :\n  count s = hs.to_finset.card :=\nby rw [\u2190 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 = \u221e :=\nbegin\n  refine top_unique (le_of_tendsto' ennreal.tendsto_nat_nhds_top $ \u03bb n, _),\n  rcases hs.exists_subset_card_eq n with \u27e8t, ht, rfl\u27e9,\n  calc (t.card : \u211d\u22650\u221e) = \u2211 i in t, 1 : by simp\n  ... = \u2211' i : (t : set \u03b1), 1 : (t.tsum_subtype 1).symm\n  ... \u2264 count (t : set \u03b1) : le_count_apply\n  ... \u2264 count s : measure_mono ht\nend\n\n@[simp] lemma count_apply_eq_top [measurable_singleton_class \u03b1] : count s = \u221e \u2194 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 \u03b1] : count s < \u221e \u2194 s.finite :=\ncalc count s < \u221e \u2194 count s \u2260 \u221e : lt_top_iff_ne_top\n             ... \u2194 \u00acs.infinite : not_congr count_apply_eq_top\n             ... \u2194 s.finite    : not_not\n\nend count\n\n/-! ### Absolute continuity -/\n\n/-- We say that `\u03bc` is absolutely continuous with respect to `\u03bd`, or that `\u03bc` is dominated by `\u03bd`,\n  if `\u03bd(A) = 0` implies that `\u03bc(A) = 0`. -/\ndef absolutely_continuous {m0 : measurable_space \u03b1} (\u03bc \u03bd : measure \u03b1) : Prop :=\n\u2200 \u2983s : set \u03b1\u2984, \u03bd s = 0 \u2192 \u03bc s = 0\n\nlocalized \"infix ` \u226a `:50 := measure_theory.measure.absolutely_continuous\" in measure_theory\n\nlemma absolutely_continuous_of_le (h : \u03bc \u2264 \u03bd) : \u03bc \u226a \u03bd :=\n\u03bb s hs, nonpos_iff_eq_zero.1 $ hs \u25b8 le_iff'.1 h s\n\nalias absolutely_continuous_of_le \u2190 has_le.le.absolutely_continuous\n\nlemma absolutely_continuous_of_eq (h : \u03bc = \u03bd) : \u03bc \u226a \u03bd :=\nh.le.absolutely_continuous\n\nalias absolutely_continuous_of_eq \u2190 eq.absolutely_continuous\n\nnamespace absolutely_continuous\n\nlemma mk (h : \u2200 \u2983s : set \u03b1\u2984, measurable_set s \u2192 \u03bd s = 0 \u2192 \u03bc s = 0) : \u03bc \u226a \u03bd :=\nbegin\n  intros s hs,\n  rcases exists_measurable_superset_of_null hs with \u27e8t, h1t, h2t, h3t\u27e9,\n  exact measure_mono_null h1t (h h2t h3t),\nend\n\n@[refl] protected lemma refl {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) : \u03bc \u226a \u03bc :=\nrfl.absolutely_continuous\n\nprotected lemma rfl : \u03bc \u226a \u03bc := \u03bb s hs, hs\n\ninstance [measurable_space \u03b1] : is_refl (measure \u03b1) (\u226a) := \u27e8\u03bb \u03bc, absolutely_continuous.rfl\u27e9\n\n@[trans] protected lemma trans (h1 : \u03bc\u2081 \u226a \u03bc\u2082) (h2 : \u03bc\u2082 \u226a \u03bc\u2083) : \u03bc\u2081 \u226a \u03bc\u2083 :=\n\u03bb s hs, h1 $ h2 hs\n\n@[mono] protected lemma map (h : \u03bc \u226a \u03bd) (f : \u03b1 \u2192 \u03b2) : map f \u03bc \u226a map f \u03bd :=\nif hf : measurable f then absolutely_continuous.mk $ \u03bb s hs, by simpa [hf, hs] using @h _\nelse by simp only [map_of_not_measurable hf]\n\nprotected lemma smul (h : \u03bc \u226a \u03bd) (c : \u211d\u22650\u221e) : c \u2022 \u03bc \u226a \u03bd :=\nmk (\u03bb s hs h\u03bds, by simp only [h h\u03bds, algebra.id.smul_eq_mul, coe_smul, pi.smul_apply, mul_zero])\n\nprotected lemma coe_nnreal_smul (h : \u03bc \u226a \u03bd) (c : \u211d\u22650) : c \u2022 \u03bc \u226a \u03bd :=\nh.smul c\n\nend absolutely_continuous\n\nlemma ae_le_iff_absolutely_continuous : \u03bc.ae \u2264 \u03bd.ae \u2194 \u03bc \u226a \u03bd :=\n\u27e8\u03bb h s, by { rw [measure_zero_iff_ae_nmem, measure_zero_iff_ae_nmem], exact \u03bb hs, h hs },\n  \u03bb h s hs, h hs\u27e9\n\nalias ae_le_iff_absolutely_continuous \u2194 has_le.le.absolutely_continuous_of_ae\n  measure_theory.measure.absolutely_continuous.ae_le\nalias absolutely_continuous.ae_le \u2190 ae_mono'\n\nlemma absolutely_continuous.ae_eq (h : \u03bc \u226a \u03bd) {f g : \u03b1 \u2192 \u03b4} (h' : f =\u1d50[\u03bd] g) : f =\u1d50[\u03bc] g :=\nh.ae_le h'\n\n/-! ### Quasi measure preserving maps (a.k.a. non-singular maps) -/\n\n/-- A map `f : \u03b1 \u2192 \u03b2` is said to be *quasi measure preserving* (a.k.a. non-singular) w.r.t. measures\n`\u03bca` and `\u03bcb` if it is measurable and `\u03bcb s = 0` implies `\u03bca (f \u207b\u00b9' s) = 0`. -/\n@[protect_proj]\nstructure quasi_measure_preserving {m0 : measurable_space \u03b1} (f : \u03b1 \u2192 \u03b2)\n  (\u03bca : measure \u03b1 . volume_tac) (\u03bcb : measure \u03b2 . volume_tac) : Prop :=\n(measurable : measurable f)\n(absolutely_continuous : map f \u03bca \u226a \u03bcb)\n\nnamespace quasi_measure_preserving\n\nprotected lemma id {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) : quasi_measure_preserving id \u03bc \u03bc :=\n\u27e8measurable_id, map_id.absolutely_continuous\u27e9\n\nvariables {\u03bca \u03bca' : measure \u03b1} {\u03bcb \u03bcb' : measure \u03b2} {\u03bcc : measure \u03b3} {f : \u03b1 \u2192 \u03b2}\n\nlemma mono_left (h : quasi_measure_preserving f \u03bca \u03bcb)\n  (ha : \u03bca' \u226a \u03bca) : quasi_measure_preserving f \u03bca' \u03bcb :=\n\u27e8h.1, (ha.map f).trans h.2\u27e9\n\nlemma mono_right (h : quasi_measure_preserving f \u03bca \u03bcb)\n  (ha : \u03bcb \u226a \u03bcb') : quasi_measure_preserving f \u03bca \u03bcb' :=\n\u27e8h.1, h.2.trans ha\u27e9\n\n@[mono] lemma mono (ha : \u03bca' \u226a \u03bca) (hb : \u03bcb \u226a \u03bcb') (h : quasi_measure_preserving f \u03bca \u03bcb) :\n  quasi_measure_preserving f \u03bca' \u03bcb' :=\n(h.mono_left ha).mono_right hb\n\nprotected lemma comp {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2} (hg : quasi_measure_preserving g \u03bcb \u03bcc)\n  (hf : quasi_measure_preserving f \u03bca \u03bcb) :\n  quasi_measure_preserving (g \u2218 f) \u03bca \u03bcc :=\n\u27e8hg.measurable.comp hf.measurable, by { rw \u2190 map_map hg.1 hf.1, exact (hf.2.map g).trans hg.2 }\u27e9\n\nprotected lemma iterate {f : \u03b1 \u2192 \u03b1} (hf : quasi_measure_preserving f \u03bca \u03bca) :\n  \u2200 n, quasi_measure_preserving (f^[n]) \u03bca \u03bca\n| 0 := quasi_measure_preserving.id \u03bca\n| (n + 1) := (iterate n).comp hf\n\nlemma ae_map_le (h : quasi_measure_preserving f \u03bca \u03bcb) : (map f \u03bca).ae \u2264 \u03bcb.ae :=\nh.2.ae_le\n\nlemma tendsto_ae (h : quasi_measure_preserving f \u03bca \u03bcb) : tendsto f \u03bca.ae \u03bcb.ae :=\n(tendsto_ae_map h.1).mono_right h.ae_map_le\n\nlemma ae (h : quasi_measure_preserving f \u03bca \u03bcb) {p : \u03b2 \u2192 Prop} (hg : \u2200\u1d50 x \u2202\u03bcb, p x) :\n  \u2200\u1d50 x \u2202\u03bca, p (f x) :=\nh.tendsto_ae hg\n\nlemma ae_eq (h : quasi_measure_preserving f \u03bca \u03bcb) {g\u2081 g\u2082 : \u03b2 \u2192 \u03b4} (hg : g\u2081 =\u1d50[\u03bcb] g\u2082) :\n  g\u2081 \u2218 f =\u1d50[\u03bca] g\u2082 \u2218 f :=\nh.ae hg\n\nlemma preimage_null (h : quasi_measure_preserving f \u03bca \u03bcb) {s : set \u03b2} (hs : \u03bcb s = 0) :\n  \u03bca (f \u207b\u00b9' 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\u1d9c` has finite measure. -/\ndef cofinite {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) : filter \u03b1 :=\n{ sets := {s | \u03bc s\u1d9c < \u221e},\n  univ_sets := by simp,\n  inter_sets := \u03bb s t hs ht, by { simp only [compl_inter, mem_set_of_eq],\n    calc \u03bc (s\u1d9c \u222a t\u1d9c) \u2264 \u03bc s\u1d9c + \u03bc t\u1d9c : measure_union_le _ _\n                ... < \u221e : ennreal.add_lt_top.2 \u27e8hs, ht\u27e9 },\n  sets_of_superset := \u03bb s t hs hst, lt_of_le_of_lt (measure_mono $ compl_subset_compl.2 hst) hs }\n\nlemma mem_cofinite : s \u2208 \u03bc.cofinite \u2194 \u03bc s\u1d9c < \u221e := iff.rfl\n\nlemma compl_mem_cofinite : s\u1d9c \u2208 \u03bc.cofinite \u2194 \u03bc s < \u221e :=\nby rw [mem_cofinite, compl_compl]\n\nlemma eventually_cofinite {p : \u03b1 \u2192 Prop} : (\u2200\u1da0 x in \u03bc.cofinite, p x) \u2194 \u03bc {x | \u00acp x} < \u221e := iff.rfl\n\nend measure\n\nopen measure\nopen_locale measure_theory\n\nlemma null_measurable_set.mono_ac (h : null_measurable_set s \u03bc) (hle : \u03bd \u226a \u03bc) :\n  null_measurable_set s \u03bd :=\n\u27e8to_measurable \u03bc s, measurable_set_to_measurable _ _, hle.ae_eq h.to_measurable_ae_eq.symm\u27e9\n\nlemma null_measurable_set.mono (h : null_measurable_set s \u03bc) (hle : \u03bd \u2264 \u03bc) :\n  null_measurable_set s \u03bd :=\nh.mono_ac hle.absolutely_continuous\n\n@[simp] lemma ae_eq_bot : \u03bc.ae = \u22a5 \u2194 \u03bc = 0 :=\nby rw [\u2190 empty_mem_iff_bot, mem_ae_iff, compl_empty, measure_univ_eq_zero]\n\n@[simp] lemma ae_ne_bot : \u03bc.ae.ne_bot \u2194 \u03bc \u2260 0 :=\nne_bot_iff.trans (not_congr ae_eq_bot)\n\n@[simp] lemma ae_zero {m0 : measurable_space \u03b1} : (0 : measure \u03b1).ae = \u22a5 := ae_eq_bot.2 rfl\n\n@[mono] lemma ae_mono (h : \u03bc \u2264 \u03bd) : \u03bc.ae \u2264 \u03bd.ae := h.absolutely_continuous.ae_le\n\nlemma mem_ae_map_iff {f : \u03b1 \u2192 \u03b2} (hf : measurable f) {s : set \u03b2} (hs : measurable_set s) :\n  s \u2208 (map f \u03bc).ae \u2194 (f \u207b\u00b9' s) \u2208 \u03bc.ae :=\nby simp only [mem_ae_iff, map_apply hf hs.compl, preimage_compl]\n\nlemma mem_ae_of_mem_ae_map {f : \u03b1 \u2192 \u03b2} (hf : measurable f) {s : set \u03b2} (hs : s \u2208 (map f \u03bc).ae) :\n  f \u207b\u00b9' s \u2208 \u03bc.ae :=\n(tendsto_ae_map hf).eventually hs\n\nlemma ae_map_iff {f : \u03b1 \u2192 \u03b2} (hf : measurable f) {p : \u03b2 \u2192 Prop} (hp : measurable_set {x | p x}) :\n  (\u2200\u1d50 y \u2202 (map f \u03bc), p y) \u2194 \u2200\u1d50 x \u2202 \u03bc, p (f x) :=\nmem_ae_map_iff hf hp\n\nlemma ae_of_ae_map {f : \u03b1 \u2192 \u03b2} (hf : measurable f) {p : \u03b2 \u2192 Prop} (h : \u2200\u1d50 y \u2202 (map f \u03bc), p y) :\n  \u2200\u1d50 x \u2202 \u03bc, p (f x) :=\nmem_ae_of_mem_ae_map hf h\n\nlemma ae_map_mem_range {m0 : measurable_space \u03b1} (f : \u03b1 \u2192 \u03b2) (hf : measurable_set (range f))\n  (\u03bc : measure \u03b1) :\n  \u2200\u1d50 x \u2202(map f \u03bc), x \u2208 range f :=\nbegin\n  by_cases h : measurable f,\n  { change range f \u2208 (map f \u03bc).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 : \u03b1 \u2192 Prop} (hp : measurable_set {x | p x}) :\n  (\u2200\u1d50 x \u2202(\u03bc.restrict s), p x) \u2194 \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 p x :=\nbegin\n  simp only [ae_iff, \u2190 compl_set_of, restrict_apply hp.compl],\n  congr' with x, simp [and_comm]\nend\n\nlemma ae_imp_of_ae_restrict {s : set \u03b1} {p : \u03b1 \u2192 Prop} (h : \u2200\u1d50 x \u2202(\u03bc.restrict s), p x) :\n  \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 p x :=\nbegin\n  simp only [ae_iff] at h \u22a2,\n  simpa [set_of_and, inter_comm] using measure_inter_eq_zero_of_restrict h\nend\n\nlemma ae_restrict_iff' {s : set \u03b1} {p : \u03b1 \u2192 Prop} (hs : measurable_set s) :\n  (\u2200\u1d50 x \u2202(\u03bc.restrict s), p x) \u2194 \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 p x :=\nbegin\n  simp only [ae_iff, \u2190 compl_set_of, restrict_apply_eq_zero' hs],\n  congr' with x, simp [and_comm]\nend\n\nlemma ae_restrict_mem {s : set \u03b1} (hs : measurable_set s) :\n  \u2200\u1d50 x \u2202(\u03bc.restrict s), x \u2208 s :=\n(ae_restrict_iff' hs).2 (filter.eventually_of_forall (\u03bb x, id))\n\nlemma ae_restrict_of_ae {s : set \u03b1} {p : \u03b1 \u2192 Prop} (h : \u2200\u1d50 x \u2202\u03bc, p x) :\n  (\u2200\u1d50 x \u2202(\u03bc.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 \u03b1} {p : \u03b1 \u2192 Prop} (hst : s \u2286 t)\n  (h : \u2200\u1d50 x \u2202(\u03bc.restrict t), p x) :\n  (\u2200\u1d50 x \u2202(\u03bc.restrict s), p x) :=\nh.filter_mono (ae_mono $ measure.restrict_mono hst (le_refl \u03bc))\n\nlemma ae_of_ae_restrict_of_ae_restrict_compl {t : set \u03b1} {p : \u03b1 \u2192 Prop}\n  (ht : \u2200\u1d50 x \u2202(\u03bc.restrict t), p x) (htc : \u2200\u1d50 x \u2202(\u03bc.restrict t\u1d9c), p x) :\n  \u2200\u1d50 x \u2202\u03bc, p x :=\nnonpos_iff_eq_zero.1 $\ncalc \u03bc {x | \u00acp x} = \u03bc ({x | \u00acp x} \u2229 t \u222a {x | \u00acp x} \u2229 t\u1d9c) :\n  by rw [\u2190 inter_union_distrib_left, union_compl_self, inter_univ]\n... \u2264 \u03bc ({x | \u00acp x} \u2229 t) + \u03bc ({x | \u00acp x} \u2229 t\u1d9c) : measure_union_le _ _\n... \u2264 \u03bc.restrict t {x | \u00acp x} + \u03bc.restrict t\u1d9c {x | \u00acp 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 {\u03b2} {s : set \u03b1} {t : set \u03b2} {f : \u03b1 \u2192 \u03b2} (hs : measurable_set s) :\n  t \u2208 filter.map f (\u03bc.restrict s).ae \u2194 \u03bc ((f \u207b\u00b9' t)\u1d9c \u2229 s) = 0 :=\nby rw [mem_map, mem_ae_iff, measure.restrict_apply' hs]\n\nlemma ae_smul_measure {p : \u03b1 \u2192 Prop} (h : \u2200\u1d50 x \u2202\u03bc, p x) (c : \u211d\u22650\u221e) : \u2200\u1d50 x \u2202(c \u2022 \u03bc), p x :=\nae_iff.2 $ by rw [smul_apply, ae_iff.1 h, mul_zero]\n\nlemma ae_smul_measure_iff {p : \u03b1 \u2192 Prop} {c : \u211d\u22650\u221e} (hc : c \u2260 0) :\n  (\u2200\u1d50 x \u2202(c \u2022 \u03bc), p x) \u2194 \u2200\u1d50 x \u2202\u03bc, p x :=\nby simp [ae_iff, hc]\n\nlemma ae_add_measure_iff {p : \u03b1 \u2192 Prop} {\u03bd} : (\u2200\u1d50 x \u2202\u03bc + \u03bd, p x) \u2194 (\u2200\u1d50 x \u2202\u03bc, p x) \u2227 \u2200\u1d50 x \u2202\u03bd, p x :=\nadd_eq_zero_iff\n\nlemma ae_eq_comp' {\u03bd : measure \u03b2} {f : \u03b1 \u2192 \u03b2} {g g' : \u03b2 \u2192 \u03b4} (hf : measurable f)\n  (h : g =\u1d50[\u03bd] g') (h2 : map f \u03bc \u226a \u03bd) : g \u2218 f =\u1d50[\u03bc] g' \u2218 f :=\n(quasi_measure_preserving.mk hf h2).ae_eq h\n\nlemma ae_eq_comp {f : \u03b1 \u2192 \u03b2} {g g' : \u03b2 \u2192 \u03b4} (hf : measurable f)\n  (h : g =\u1d50[measure.map f \u03bc] g') : g \u2218 f =\u1d50[\u03bc] g' \u2218 f :=\nae_eq_comp' hf h absolutely_continuous.rfl\n\nlemma sub_ae_eq_zero {\u03b2} [add_group \u03b2] (f g : \u03b1 \u2192 \u03b2) : f - g =\u1d50[\u03bc] 0 \u2194 f =\u1d50[\u03bc] g :=\nbegin\n  refine \u27e8\u03bb h, h.mono (\u03bb x hx, _), \u03bb h, h.mono (\u03bb x hx, _)\u27e9,\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 : \u03bc.ae \u2293 \ud835\udcdf s \u2264 (\u03bc.restrict s).ae :=\n\u03bb s hs, eventually_inf_principal.2 (ae_imp_of_ae_restrict hs)\n\n@[simp] lemma ae_restrict_eq (hs : measurable_set s) : (\u03bc.restrict s).ae = \u03bc.ae \u2293 \ud835\udcdf 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 (_ \u2208 s)],\n  refl\nend\n\n@[simp] lemma ae_restrict_eq_bot {s} : (\u03bc.restrict s).ae = \u22a5 \u2194 \u03bc s = 0 :=\nae_eq_bot.trans restrict_eq_zero\n\n@[simp] lemma ae_restrict_ne_bot {s} : (\u03bc.restrict s).ae.ne_bot \u2194 0 < \u03bc 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 \u2208 (\u03bc.restrict s).ae :=\nby simp only [ae_restrict_eq hs, exists_prop, mem_principal, mem_inf_iff];\n  exact \u27e8_, univ_mem, s, subset.rfl, (univ_inter s).symm\u27e9\n\n/-- A version of the **Borel-Cantelli lemma**: if `p\u1d62` is a sequence of predicates such that\n`\u2211 \u03bc {x | p\u1d62 x}` is finite, then the measure of `x` such that `p\u1d62 x` holds frequently as `i \u2192 \u221e` (or\nequivalently, `p\u1d62 x` holds for infinitely many `i`) is equal to zero. -/\nlemma measure_set_of_frequently_eq_zero {p : \u2115 \u2192 \u03b1 \u2192 Prop} (hp : \u2211' i, \u03bc {x | p i x} \u2260 \u221e) :\n  \u03bc {x | \u2203\u1da0 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\u1d62` is a sequence of sets such that\n`\u2211 \u03bc s\u1d62` exists, then for almost all `x`, `x` does not belong to almost all `s\u1d62`. -/\nlemma ae_eventually_not_mem {s : \u2115 \u2192 set \u03b1} (hs : \u2211' i, \u03bc (s i) \u2260 \u221e) :\n  \u2200\u1d50 x \u2202 \u03bc, \u2200\u1da0 n in at_top, x \u2209 s n :=\nmeasure_set_of_frequently_eq_zero hs\n\nsection dirac\nvariable [measurable_space \u03b1]\n\nlemma mem_ae_dirac_iff {a : \u03b1} (hs : measurable_set s) : s \u2208 (dirac a).ae \u2194 a \u2208 s :=\nby by_cases a \u2208 s; simp [mem_ae_iff, dirac_apply', hs.compl, indicator_apply, *]\n\nlemma ae_dirac_iff {a : \u03b1} {p : \u03b1 \u2192 Prop} (hp : measurable_set {x | p x}) :\n  (\u2200\u1d50 x \u2202(dirac a), p x) \u2194 p a :=\nmem_ae_dirac_iff hp\n\n@[simp] lemma ae_dirac_eq [measurable_singleton_class \u03b1] (a : \u03b1) : (dirac a).ae = pure a :=\nby { ext s, simp [mem_ae_iff, imp_false] }\n\nlemma ae_eq_dirac' [measurable_singleton_class \u03b2] {a : \u03b1} {f : \u03b1 \u2192 \u03b2} (hf : measurable f) :\n  f =\u1d50[dirac a] const \u03b1 (f a) :=\n(ae_dirac_iff $ show measurable_set (f \u207b\u00b9' {f a}), from hf $ measurable_set_singleton _).2 rfl\n\nlemma ae_eq_dirac [measurable_singleton_class \u03b1] {a : \u03b1} (f : \u03b1 \u2192 \u03b4) :\n  f =\u1d50[dirac a] const \u03b1 (f a) :=\nby simp [filter.eventually_eq]\n\nend dirac\n\nsection is_finite_measure\n\ninclude m0\n\n/-- A measure `\u03bc` is called finite if `\u03bc univ < \u221e`. -/\nclass is_finite_measure (\u03bc : measure \u03b1) : Prop := (measure_univ_lt_top : \u03bc univ < \u221e)\n\ninstance restrict.is_finite_measure (\u03bc : measure \u03b1) [hs : fact (\u03bc s < \u221e)] :\n  is_finite_measure (\u03bc.restrict s) :=\n\u27e8by simp [hs.elim]\u27e9\n\nlemma measure_lt_top (\u03bc : measure \u03b1) [is_finite_measure \u03bc] (s : set \u03b1) : \u03bc s < \u221e :=\n(measure_mono (subset_univ s)).trans_lt is_finite_measure.measure_univ_lt_top\n\nlemma measure_ne_top (\u03bc : measure \u03b1) [is_finite_measure \u03bc] (s : set \u03b1) : \u03bc s \u2260 \u221e :=\nne_of_lt (measure_lt_top \u03bc s)\n\nlemma measure_compl_le_add_of_le_add [is_finite_measure \u03bc] (hs : measurable_set s)\n  (ht : measurable_set t) {\u03b5 : \u211d\u22650\u221e} (h : \u03bc s \u2264 \u03bc t + \u03b5) :\n  \u03bc t\u1d9c \u2264 \u03bc s\u1d9c + \u03b5 :=\nbegin\n  rw [measure_compl ht (measure_ne_top \u03bc _), measure_compl hs (measure_ne_top \u03bc _),\n    tsub_le_iff_right],\n  calc \u03bc univ = \u03bc univ - \u03bc s + \u03bc s :\n    (tsub_add_cancel_of_le $ measure_mono s.subset_univ).symm\n  ... \u2264 \u03bc univ - \u03bc s + (\u03bc t + \u03b5) : add_le_add_left h _\n  ... = _ : by rw [add_right_comm, add_assoc]\nend\n\nlemma measure_compl_le_add_iff [is_finite_measure \u03bc] (hs : measurable_set s)\n  (ht : measurable_set t) {\u03b5 : \u211d\u22650\u221e} :\n  \u03bc s\u1d9c \u2264 \u03bc t\u1d9c + \u03b5 \u2194 \u03bc t \u2264 \u03bc s + \u03b5 :=\n\u27e8\u03bb h, compl_compl s \u25b8 compl_compl t \u25b8 measure_compl_le_add_of_le_add hs.compl ht.compl h,\n  measure_compl_le_add_of_le_add ht hs\u27e9\n\n/-- The measure of the whole space with respect to a finite measure, considered as `\u211d\u22650`. -/\ndef measure_univ_nnreal (\u03bc : measure \u03b1) : \u211d\u22650 := (\u03bc univ).to_nnreal\n\n@[simp] lemma coe_measure_univ_nnreal (\u03bc : measure \u03b1) [is_finite_measure \u03bc] :\n  \u2191(measure_univ_nnreal \u03bc) = \u03bc univ :=\nennreal.coe_to_nnreal (measure_ne_top \u03bc univ)\n\ninstance is_finite_measure_zero : is_finite_measure (0 : measure \u03b1) := \u27e8by simp\u27e9\n\n@[priority 100]\ninstance is_finite_measure_of_is_empty [is_empty \u03b1] : is_finite_measure \u03bc :=\nby { rw eq_zero_of_is_empty \u03bc, apply_instance }\n\n@[simp] lemma measure_univ_nnreal_zero : measure_univ_nnreal (0 : measure \u03b1) = 0 := rfl\n\nomit m0\n\ninstance is_finite_measure_add [is_finite_measure \u03bc] [is_finite_measure \u03bd] :\n  is_finite_measure (\u03bc + \u03bd) :=\n{ measure_univ_lt_top :=\n  begin\n    rw [measure.coe_add, pi.add_apply, ennreal.add_lt_top],\n    exact \u27e8measure_lt_top _ _, measure_lt_top _ _\u27e9,\n  end }\n\ninstance is_finite_measure_smul_nnreal [is_finite_measure \u03bc] {r : \u211d\u22650} :\n  is_finite_measure (r \u2022 \u03bc) :=\n{ measure_univ_lt_top := ennreal.mul_lt_top ennreal.coe_ne_top (measure_ne_top _ _) }\n\nlemma is_finite_measure_of_le (\u03bc : measure \u03b1) [is_finite_measure \u03bc] (h : \u03bd \u2264 \u03bc) :\n  is_finite_measure \u03bd :=\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 \u03b1}\n  (\u03bc : measure \u03b1) [is_finite_measure \u03bc] (f : \u03b1 \u2192 \u03b2) :\n  is_finite_measure (map f \u03bc) :=\nbegin\n  by_cases hf : measurable f,\n  { constructor, rw map_apply hf measurable_set.univ, exact measure_lt_top \u03bc _ },\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 \u03bc] :\n  measure_univ_nnreal \u03bc = 0 \u2194 \u03bc = 0 :=\nbegin\n  rw [\u2190 measure_theory.measure.measure_univ_eq_zero, \u2190 coe_measure_univ_nnreal],\n  norm_cast\nend\n\nlemma measure_univ_nnreal_pos [is_finite_measure \u03bc] (h\u03bc : \u03bc \u2260 0) : 0 < measure_univ_nnreal \u03bc :=\nbegin\n  contrapose! h\u03bc,\n  simpa [measure_univ_nnreal_eq_zero, le_zero_iff] using h\u03bc\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 \u03bc is finite. -/\nlemma measure.le_of_add_le_add_left [is_finite_measure \u03bc] (A2 : \u03bc + \u03bd\u2081 \u2264 \u03bc + \u03bd\u2082) : \u03bd\u2081 \u2264 \u03bd\u2082 :=\n\u03bb S B1, ennreal.le_of_add_le_add_left (measure_theory.measure_ne_top \u03bc S) (A2 S B1)\n\nlemma summable_measure_to_real [h\u03bc : is_finite_measure \u03bc]\n  {f : \u2115 \u2192 set \u03b1} (hf\u2081 : \u2200 (i : \u2115), measurable_set (f i)) (hf\u2082 : pairwise (disjoint on f)) :\n  summable (\u03bb x, (\u03bc (f x)).to_real) :=\nbegin\n  apply ennreal.summable_to_real,\n  rw \u2190 measure_theory.measure_Union hf\u2082 hf\u2081,\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 `\u03bc` is called a probability measure if `\u03bc univ = 1`. -/\nclass is_probability_measure (\u03bc : measure \u03b1) : Prop := (measure_univ : \u03bc univ = 1)\n\nexport is_probability_measure (measure_univ)\n\n@[priority 100]\ninstance is_probability_measure.to_is_finite_measure (\u03bc : measure \u03b1) [is_probability_measure \u03bc] :\n  is_finite_measure \u03bc :=\n\u27e8by simp only [measure_univ, ennreal.one_lt_top]\u27e9\n\nlemma is_probability_measure.ne_zero (\u03bc : measure \u03b1) [is_probability_measure \u03bc] : \u03bc \u2260 0 :=\nmt measure_univ_eq_zero.2 $ by simp [measure_univ]\n\nomit m0\n\ninstance measure.dirac.is_probability_measure [measurable_space \u03b1] {x : \u03b1} :\n  is_probability_measure (dirac x) :=\n\u27e8dirac_apply_of_mem $ mem_univ x\u27e9\n\nlemma prob_add_prob_compl [is_probability_measure \u03bc]\n  (h : measurable_set s) : \u03bc s + \u03bc s\u1d9c = 1 :=\n(measure_add_measure_compl h).trans measure_univ\n\nlemma prob_le_one [is_probability_measure \u03bc] : \u03bc s \u2264 1 :=\n(measure_mono $ set.subset_univ _).trans_eq measure_univ\n\nend is_probability_measure\n\nsection no_atoms\n\n/-- Measure `\u03bc` *has no atoms* if the measure of each singleton is zero.\n\nNB: Wikipedia assumes that for any measurable set `s` with positive `\u03bc`-measure,\nthere exists a measurable `t \u2286 s` such that `0 < \u03bc t < \u03bc s`. While this implies `\u03bc {x} = 0`,\nthe converse is not true. -/\nclass has_no_atoms {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) : Prop :=\n(measure_singleton : \u2200 x, \u03bc {x} = 0)\n\nexport has_no_atoms (measure_singleton)\nattribute [simp] measure_singleton\n\nvariables [has_no_atoms \u03bc]\n\nlemma _root_.set.subsingleton.measure_zero {\u03b1 : Type*} {m : measurable_space \u03b1} {s : set \u03b1}\n  (hs : s.subsingleton) (\u03bc : measure \u03b1) [has_no_atoms \u03bc] :\n  \u03bc s = 0 :=\nhs.induction_on measure_empty measure_singleton\n\nlemma measure.restrict_singleton' {a : \u03b1} :\n  \u03bc.restrict {a} = 0 :=\nby simp only [measure_singleton, measure.restrict_eq_zero]\n\ninstance (s : set \u03b1) : has_no_atoms (\u03bc.restrict s) :=\nbegin\n  refine \u27e8\u03bb x, _\u27e9,\n  obtain \u27e8t, hxt, ht1, ht2\u27e9 := exists_measurable_superset_of_null (measure_singleton x : \u03bc {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 {\u03b1 : Type*} {m : measurable_space \u03b1} {s : set \u03b1}\n  (h : countable s) (\u03bc : measure \u03b1) [has_no_atoms \u03bc] :\n  \u03bc s = 0 :=\nbegin\n  rw [\u2190 bUnion_of_singleton s, \u2190 nonpos_iff_eq_zero],\n  refine le_trans (measure_bUnion_le h _) _,\n  simp\nend\n\nlemma _root_.set.finite.measure_zero {\u03b1 : Type*} {m : measurable_space \u03b1} {s : set \u03b1}\n  (h : s.finite) (\u03bc : measure \u03b1) [has_no_atoms \u03bc] : \u03bc s = 0 :=\nh.countable.measure_zero \u03bc\n\nlemma _root_.finset.measure_zero {\u03b1 : Type*} {m : measurable_space \u03b1}\n  (s : finset \u03b1) (\u03bc : measure \u03b1) [has_no_atoms \u03bc] : \u03bc s = 0 :=\ns.finite_to_set.measure_zero \u03bc\n\nlemma insert_ae_eq_self (a : \u03b1) (s : set \u03b1) :\n  (insert a s : set \u03b1) =\u1d50[\u03bc] s :=\nunion_ae_eq_right.2 $ measure_mono_null (diff_subset _ _) (measure_singleton _)\n\nvariables [partial_order \u03b1] {a b : \u03b1}\n\nlemma Iio_ae_eq_Iic : Iio a =\u1d50[\u03bc] Iic a :=\nby simp only [\u2190 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 =\u1d50[\u03bc] Ici a :=\n@Iio_ae_eq_Iic (order_dual \u03b1) \u2039_\u203a \u2039_\u203a _ _ _\n\nlemma Ioo_ae_eq_Ioc : Ioo a b =\u1d50[\u03bc] Ioc a b :=\n(ae_eq_refl _).inter Iio_ae_eq_Iic\n\nlemma Ioc_ae_eq_Icc : Ioc a b =\u1d50[\u03bc] Icc a b :=\nIoi_ae_eq_Ici.inter (ae_eq_refl _)\n\nlemma Ioo_ae_eq_Ico : Ioo a b =\u1d50[\u03bc] Ico a b :=\nIoi_ae_eq_Ici.inter (ae_eq_refl _)\n\nlemma Ioo_ae_eq_Icc : Ioo a b =\u1d50[\u03bc] Icc a b :=\nIoi_ae_eq_Ici.inter Iio_ae_eq_Iic\n\nlemma Ico_ae_eq_Icc : Ico a b =\u1d50[\u03bc] Icc a b :=\n(ae_eq_refl _).inter Iio_ae_eq_Iic\n\nlemma Ico_ae_eq_Ioc : Ico a b =\u1d50[\u03bc] 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 {\u03b3} (f : \u03b1 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b3) (s : set \u03b1) (hs_zero : \u03bc s = 0) :\n  (\u03bb x, ite (x \u2208 s) (f x) (g x)) =\u1d50[\u03bc] g :=\nbegin\n  have h_ss : s\u1d9c \u2286 {a : \u03b1 | ite (a \u2208 s) (f a) (g a) = g a},\n    from \u03bb x hx, by simp [(set.mem_compl_iff _ _).mp hx],\n  refine measure_mono_null _ hs_zero,\n  nth_rewrite 0 \u2190compl_compl s,\n  rwa set.compl_subset_compl,\nend\n\nlemma ite_ae_eq_of_measure_compl_zero {\u03b3} (f : \u03b1 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b3) (s : set \u03b1) (hs_zero : \u03bc s\u1d9c = 0) :\n  (\u03bb x, ite (x \u2208 s) (f x) (g x)) =\u1d50[\u03bc] 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 \u2208 f`.\nEquivalently, it is eventually finite at `s` in `f.lift' powerset`. -/\ndef finite_at_filter {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) (f : filter \u03b1) : Prop :=\n\u2203 s \u2208 f, \u03bc s < \u221e\n\nlemma finite_at_filter_of_finite {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) [is_finite_measure \u03bc]\n  (f : filter \u03b1) :\n  \u03bc.finite_at_filter f :=\n\u27e8univ, univ_mem, measure_lt_top \u03bc univ\u27e9\n\nlemma finite_at_filter.exists_mem_basis {f : filter \u03b1} (h\u03bc : finite_at_filter \u03bc f)\n  {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 set \u03b1} (hf : f.has_basis p s) :\n  \u2203 i (hi : p i), \u03bc (s i) < \u221e :=\n(hf.exists_iff (\u03bb s t hst ht, (measure_mono hst).trans_lt ht)).1 h\u03bc\n\nlemma finite_at_bot {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) : \u03bc.finite_at_filter \u22a5 :=\n\u27e8\u2205, mem_bot, by simp only [measure_empty, with_top.zero_lt_top]\u27e9\n\n/-- `\u03bc` 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: `\u03bc` is \u03c3-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 \u03b1} (\u03bc : measure \u03b1) (C : set (set \u03b1)) :=\n(set : \u2115 \u2192 set \u03b1)\n(set_mem : \u2200 i, set i \u2208 C)\n(finite : \u2200 i, \u03bc (set i) < \u221e)\n(spanning : (\u22c3 i, set i) = univ)\n\nend measure\nopen measure\n\n/-- A measure `\u03bc` is called \u03c3-finite if there is a countable collection of sets\n `{ A i | i \u2208 \u2115 }` such that `\u03bc (A i) < \u221e` and `\u22c3 i, A i = s`. -/\nclass sigma_finite {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1) : Prop :=\n(out' : nonempty (\u03bc.finite_spanning_sets_in univ))\n\ntheorem sigma_finite_iff :\n  sigma_finite \u03bc \u2194 nonempty (\u03bc.finite_spanning_sets_in univ) :=\n\u27e8\u03bb h, h.1, \u03bb h, \u27e8h\u27e9\u27e9\n\ntheorem sigma_finite.out (h : sigma_finite \u03bc) :\n  nonempty (\u03bc.finite_spanning_sets_in univ) := h.1\n\ninclude m0\n\n/-- If `\u03bc` is \u03c3-finite it has finite spanning sets in the collection of all measurable sets. -/\ndef measure.to_finite_spanning_sets_in (\u03bc : measure \u03b1) [h : sigma_finite \u03bc] :\n  \u03bc.finite_spanning_sets_in {s | measurable_set s} :=\n{ set := \u03bb n, to_measurable \u03bc (h.out.some.set n),\n  set_mem := \u03bb n, measurable_set_to_measurable _ _,\n  finite := \u03bb n, by { rw measure_to_measurable, exact h.out.some.finite n },\n  spanning := eq_univ_of_subset (Union_subset_Union $ \u03bb 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 (\u03bc : measure \u03b1) [sigma_finite \u03bc] (i : \u2115) : set \u03b1 :=\naccumulate \u03bc.to_finite_spanning_sets_in.set i\n\nlemma monotone_spanning_sets (\u03bc : measure \u03b1) [sigma_finite \u03bc] :\n  monotone (spanning_sets \u03bc) :=\nmonotone_accumulate\n\nlemma measurable_spanning_sets (\u03bc : measure \u03b1) [sigma_finite \u03bc] (i : \u2115) :\n  measurable_set (spanning_sets \u03bc i) :=\nmeasurable_set.Union $ \u03bb j, measurable_set.Union_Prop $\n  \u03bb hij, \u03bc.to_finite_spanning_sets_in.set_mem j\n\nlemma measure_spanning_sets_lt_top (\u03bc : measure \u03b1) [sigma_finite \u03bc] (i : \u2115) :\n  \u03bc (spanning_sets \u03bc i) < \u221e :=\nmeasure_bUnion_lt_top (finite_le_nat i) $ \u03bb j _, (\u03bc.to_finite_spanning_sets_in.finite j).ne\n\nlemma Union_spanning_sets (\u03bc : measure \u03b1) [sigma_finite \u03bc] :\n  (\u22c3 i : \u2115, spanning_sets \u03bc i) = univ :=\nby simp_rw [spanning_sets, Union_accumulate, \u03bc.to_finite_spanning_sets_in.spanning]\n\nlemma is_countably_spanning_spanning_sets (\u03bc : measure \u03b1) [sigma_finite \u03bc] :\n  is_countably_spanning (range (spanning_sets \u03bc)) :=\n\u27e8spanning_sets \u03bc, mem_range_self, Union_spanning_sets \u03bc\u27e9\n\n/-- `spanning_sets_index \u03bc x` is the least `n : \u2115` such that `x \u2208 spanning_sets \u03bc n`. -/\ndef spanning_sets_index (\u03bc : measure \u03b1) [sigma_finite \u03bc] (x : \u03b1) : \u2115 :=\nnat.find $ Union_eq_univ_iff.1 (Union_spanning_sets \u03bc) x\n\nlemma measurable_spanning_sets_index (\u03bc : measure \u03b1) [sigma_finite \u03bc] :\n  measurable (spanning_sets_index \u03bc) :=\nmeasurable_find _ $ measurable_spanning_sets \u03bc\n\nlemma preimage_spanning_sets_index_singleton (\u03bc : measure \u03b1) [sigma_finite \u03bc] (n : \u2115) :\n  spanning_sets_index \u03bc \u207b\u00b9' {n} = disjointed (spanning_sets \u03bc) n :=\npreimage_find_eq_disjointed _ _ _\n\nlemma spanning_sets_index_eq_iff (\u03bc : measure \u03b1) [sigma_finite \u03bc] {x : \u03b1} {n : \u2115} :\n  spanning_sets_index \u03bc x = n \u2194 x \u2208 disjointed (spanning_sets \u03bc) n :=\nby convert set.ext_iff.1 (preimage_spanning_sets_index_singleton \u03bc n) x\n\nlemma mem_disjointed_spanning_sets_index (\u03bc : measure \u03b1) [sigma_finite \u03bc] (x : \u03b1) :\n  x \u2208 disjointed (spanning_sets \u03bc) (spanning_sets_index \u03bc x) :=\n(spanning_sets_index_eq_iff \u03bc).1 rfl\n\nlemma mem_spanning_sets_index (\u03bc : measure \u03b1) [sigma_finite \u03bc] (x : \u03b1) :\n  x \u2208 spanning_sets \u03bc (spanning_sets_index \u03bc x) :=\ndisjointed_subset _ _ (mem_disjointed_spanning_sets_index \u03bc x)\n\nlemma mem_spanning_sets_of_index_le (\u03bc : measure \u03b1) [sigma_finite \u03bc] (x : \u03b1)\n  {n : \u2115} (hn : spanning_sets_index \u03bc x \u2264 n) :\n  x \u2208 spanning_sets \u03bc n :=\nmonotone_spanning_sets \u03bc hn (mem_spanning_sets_index \u03bc x)\n\nlemma eventually_mem_spanning_sets (\u03bc : measure \u03b1) [sigma_finite \u03bc] (x : \u03b1) :\n  \u2200\u1da0 n in at_top, x \u2208 spanning_sets \u03bc n :=\neventually_at_top.2 \u27e8spanning_sets_index \u03bc x, \u03bb b, mem_spanning_sets_of_index_le \u03bc x\u27e9\n\nlemma ae_of_forall_measure_lt_top_ae_restrict {\u03bc : measure \u03b1} [sigma_finite \u03bc] (P : \u03b1 \u2192 Prop)\n  (h : \u2200 s, measurable_set s \u2192 \u03bc s < \u221e \u2192 \u2200\u1d50 x \u2202(\u03bc.restrict s), P x) :\n  \u2200\u1d50 x \u2202\u03bc, P x :=\nbegin\n  have : \u2200 n, \u2200\u1d50 x \u2202\u03bc, x \u2208 spanning_sets \u03bc n \u2192 P x,\n  { assume n,\n    have := h (spanning_sets \u03bc 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 \u03bc] (hs : measurable_set s) :\n  (\u2a06 i, \u03bc.restrict (spanning_sets \u03bc i) s) = \u03bc s :=\nbegin\n  convert (restrict_Union_apply_eq_supr (measurable_spanning_sets \u03bc) _ hs).symm,\n  { simp [Union_spanning_sets] },\n  { exact directed_of_sup (monotone_spanning_sets \u03bc) }\nend\n\nnamespace finite_spanning_sets_in\n\nvariables {C D : set (set \u03b1)}\n\n/-- If `\u03bc` has finite spanning sets in `C` and `C \u2229 {s | \u03bc s < \u221e} \u2286 D` then `\u03bc` has finite spanning\nsets in `D`. -/\nprotected def mono' (h : \u03bc.finite_spanning_sets_in C) (hC : C \u2229 {s | \u03bc s < \u221e} \u2286 D) :\n  \u03bc.finite_spanning_sets_in D :=\n\u27e8h.set, \u03bb i, hC \u27e8h.set_mem i, h.finite i\u27e9, h.finite, h.spanning\u27e9\n\n/-- If `\u03bc` has finite spanning sets in `C` and `C \u2286 D` then `\u03bc` has finite spanning sets in `D`. -/\nprotected def mono (h : \u03bc.finite_spanning_sets_in C) (hC : C \u2286 D) : \u03bc.finite_spanning_sets_in D :=\nh.mono' (\u03bb s hs, hC hs.1)\n\n/-- If `\u03bc` has finite spanning sets in the collection of measurable sets `C`, then `\u03bc` is \u03c3-finite.\n-/\nprotected lemma sigma_finite (h : \u03bc.finite_spanning_sets_in C) :\n  sigma_finite \u03bc :=\n\u27e8\u27e8h.mono $ subset_univ C\u27e9\u27e9\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 {\u03bd : measure \u03b1} {C : set (set \u03b1)} (hA : \u2039_\u203a = generate_from C)\n  (hC : is_pi_system C) (h : \u03bc.finite_spanning_sets_in C) (h_eq : \u2200 s \u2208 C, \u03bc s = \u03bd s) : \u03bc = \u03bd :=\next_of_generate_from_of_Union C _ hA hC h.spanning h.set_mem (\u03bb i, (h.finite i).ne) h_eq\n\nprotected lemma is_countably_spanning (h : \u03bc.finite_spanning_sets_in C) : is_countably_spanning C :=\n\u27e8h.set, h.set_mem, h.spanning\u27e9\n\nend finite_spanning_sets_in\n\nlemma sigma_finite_of_countable {S : set (set \u03b1)} (hc : countable S)\n  (h\u03bc : \u2200 s \u2208 S, \u03bc s < \u221e) (hU : \u22c3\u2080 S = univ) :\n  sigma_finite \u03bc :=\nbegin\n  obtain \u27e8s, h\u03bc, hs\u27e9 : \u2203 s : \u2115 \u2192 set \u03b1, (\u2200 n, \u03bc (s n) < \u221e) \u2227 (\u22c3 n, s n) = univ,\n    from (@exists_seq_cover_iff_countable _ (\u03bb x, \u03bc x < \u22a4) \u27e8\u2205, by simp\u27e9).2 \u27e8S, hc, h\u03bc, hU\u27e9,\n  exact \u27e8\u27e8\u27e8\u03bb n, s n, \u03bb n, trivial, h\u03bc, hs\u27e9\u27e9\u27e9,\nend\n\n/-- Given measures `\u03bc`, `\u03bd` where `\u03bd \u2264 \u03bc`, `finite_spanning_sets_in.of_le` provides the induced\n`finite_spanning_set` with respect to `\u03bd` from a `finite_spanning_set` with respect to `\u03bc`. -/\ndef finite_spanning_sets_in.of_le (h : \u03bd \u2264 \u03bc) {C : set (set \u03b1)}\n  (S : \u03bc.finite_spanning_sets_in C) : \u03bd.finite_spanning_sets_in C :=\n{ set := S.set,\n  set_mem := S.set_mem,\n  finite := \u03bb n, lt_of_le_of_lt (le_iff'.1 h _) (S.finite n),\n  spanning := S.spanning }\n\nlemma sigma_finite_of_le (\u03bc : measure \u03b1) [hs : sigma_finite \u03bc]\n  (h : \u03bd \u2264 \u03bc) : sigma_finite \u03bd :=\n\u27e8hs.out.map $ finite_spanning_sets_in.of_le h\u27e9\n\nend measure\n\ninclude m0\n\n/-- Every finite measure is \u03c3-finite. -/\n@[priority 100]\ninstance is_finite_measure.to_sigma_finite (\u03bc : measure \u03b1) [is_finite_measure \u03bc] :\n  sigma_finite \u03bc :=\n\u27e8\u27e8\u27e8\u03bb _, univ, \u03bb _, trivial, \u03bb _, measure_lt_top \u03bc _, Union_const _\u27e9\u27e9\u27e9\n\ninstance restrict.sigma_finite (\u03bc : measure \u03b1) [sigma_finite \u03bc] (s : set \u03b1) :\n  sigma_finite (\u03bc.restrict s) :=\nbegin\n  refine \u27e8\u27e8\u27e8spanning_sets \u03bc, \u03bb _, trivial, \u03bb i, _, Union_spanning_sets \u03bc\u27e9\u27e9\u27e9,\n  rw [restrict_apply (measurable_spanning_sets \u03bc i)],\n  exact (measure_mono $ inter_subset_left _ _).trans_lt (measure_spanning_sets_lt_top \u03bc i)\nend\n\ninstance sum.sigma_finite {\u03b9} [fintype \u03b9] (\u03bc : \u03b9 \u2192 measure \u03b1) [\u2200 i, sigma_finite (\u03bc i)] :\n  sigma_finite (sum \u03bc) :=\nbegin\n  haveI : encodable \u03b9 := fintype.encodable \u03b9,\n  have : \u2200 n, measurable_set (\u22c2 (i : \u03b9), spanning_sets (\u03bc i) n) :=\n    \u03bb n, measurable_set.Inter (\u03bb i, measurable_spanning_sets (\u03bc i) n),\n  refine \u27e8\u27e8\u27e8\u03bb n, \u22c2 i, spanning_sets (\u03bc i) n, \u03bb _, trivial, \u03bb n, _, _\u27e9\u27e9\u27e9,\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 (\u03bc i) n) },\n  { rw [Union_Inter_of_monotone], simp_rw [Union_spanning_sets, Inter_univ],\n    exact \u03bb i, monotone_spanning_sets (\u03bc i), }\nend\n\ninstance add.sigma_finite (\u03bc \u03bd : measure \u03b1) [sigma_finite \u03bc] [sigma_finite \u03bd] :\n  sigma_finite (\u03bc + \u03bd) :=\nby { rw [\u2190 sum_cond], refine @sum.sigma_finite _ _ _ _ _ (bool.rec _ _); simpa }\n\nlemma sigma_finite.of_map (\u03bc : measure \u03b1) {f : \u03b1 \u2192 \u03b2} (hf : measurable f)\n  (h : sigma_finite (map f \u03bc)) :\n  sigma_finite \u03bc :=\n\u27e8\u27e8\u27e8\u03bb n, f \u207b\u00b9' (spanning_sets (map f \u03bc) n),\n   \u03bb n, trivial,\n   \u03bb n, by simp only [\u2190 map_apply hf, measurable_spanning_sets, measure_spanning_sets_lt_top],\n   by rw [\u2190 preimage_Union, Union_spanning_sets, preimage_univ]\u27e9\u27e9\u27e9\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 \u03b1] (\u03bc : measure \u03b1) : Prop :=\n(finite_at_nhds : \u2200 x, \u03bc.finite_at_filter (\ud835\udcdd x))\n\n@[priority 100] -- see Note [lower instance priority]\ninstance is_finite_measure.to_is_locally_finite_measure [topological_space \u03b1] (\u03bc : measure \u03b1)\n  [is_finite_measure \u03bc] :\n  is_locally_finite_measure \u03bc :=\n\u27e8\u03bb x, finite_at_filter_of_finite _ _\u27e9\n\nlemma measure.finite_at_nhds [topological_space \u03b1] (\u03bc : measure \u03b1)\n  [is_locally_finite_measure \u03bc] (x : \u03b1) :\n  \u03bc.finite_at_filter (\ud835\udcdd x) :=\nis_locally_finite_measure.finite_at_nhds x\n\nlemma measure.smul_finite (\u03bc : measure \u03b1) [is_finite_measure \u03bc] {c : \u211d\u22650\u221e} (hc : c \u2260 \u221e) :\n  is_finite_measure (c \u2022 \u03bc) :=\nbegin\n  lift c to \u211d\u22650 using hc,\n  exact measure_theory.is_finite_measure_smul_nnreal,\nend\n\nlemma measure.exists_is_open_measure_lt_top [topological_space \u03b1] (\u03bc : measure \u03b1)\n  [is_locally_finite_measure \u03bc] (x : \u03b1) :\n  \u2203 s : set \u03b1, x \u2208 s \u2227 is_open s \u2227 \u03bc s < \u221e :=\nby simpa only [exists_prop, and.assoc]\n  using (\u03bc.finite_at_nhds x).exists_mem_basis (nhds_basis_opens x)\n\ninstance is_locally_finite_measure_smul_nnreal [topological_space \u03b1] (\u03bc : measure \u03b1)\n  [is_locally_finite_measure \u03bc] (c : \u211d\u22650) : is_locally_finite_measure (c \u2022 \u03bc) :=\nbegin\n  refine \u27e8\u03bb x, _\u27e9,\n  rcases \u03bc.exists_is_open_measure_lt_top x with \u27e8o, xo, o_open, \u03bco\u27e9,\n  refine \u27e8o, o_open.mem_nhds xo, _\u27e9,\n  apply ennreal.mul_lt_top _ \u03bco.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 \u03b1]\n  [topological_space.second_countable_topology \u03b1] [is_locally_finite_measure \u03bc] :\n  sigma_finite \u03bc :=\nbegin\n  choose s hsx hs\u03bc using \u03bc.finite_at_nhds,\n  rcases topological_space.countable_cover_nhds hsx with \u27e8t, htc, htU\u27e9,\n  refine measure.sigma_finite_of_countable (htc.image s) (ball_image_iff.2 $ \u03bb x hx, hs\u03bc 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 \u03b1] [topological_space.second_countable_topology \u03b1]\n  (s : set \u03b1) (hs : \u2200 x \u2208 s, \u2203 u \u2208 \ud835\udcdd[s] x, \u03bc (s \u2229 u) = 0) :\n  \u03bc s = 0 :=\nbegin\n  choose! u hu using hs,\n  obtain \u27e8t, ts, t_count, ht\u27e9 : \u2203 t \u2286 s, t.countable \u2227 s \u2286 \u22c3 x \u2208 t, u x :=\n    topological_space.countable_cover_nhds_within (\u03bb x hx, (hu x hx).1),\n  replace ht : s \u2286 \u22c3 x \u2208 t, s \u2229 u x,\n    by { rw \u2190 inter_bUnion, exact subset_inter (subset.refl _) ht },\n  apply measure_mono_null ht,\n  exact (measure_bUnion_null_iff t_count).2 (\u03bb 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 \u03c0-system made\nof measurable sets, then they coincide on all sets in the \u03c3-algebra generated by the \u03c0-system. -/\nlemma ext_on_measurable_space_of_generate_finite {\u03b1} (m\u2080 : measurable_space \u03b1)\n  {\u03bc \u03bd : measure \u03b1} [is_finite_measure \u03bc]\n  (C : set (set \u03b1)) (h\u03bc\u03bd : \u2200 s \u2208 C, \u03bc s = \u03bd s) {m : measurable_space \u03b1}\n  (h : m \u2264 m\u2080) (hA : m = measurable_space.generate_from C) (hC : is_pi_system C)\n  (h_univ : \u03bc set.univ = \u03bd set.univ) {s : set \u03b1} (hs : m.measurable_set' s) :\n  \u03bc s = \u03bd s :=\nbegin\n  haveI : is_finite_measure \u03bd := begin\n     constructor,\n     rw \u2190 h_univ,\n     apply is_finite_measure.measure_univ_lt_top,\n  end,\n  refine induction_on_inter hA hC (by simp) h\u03bc\u03bd _ _ hs,\n  { intros t h1t h2t,\n    have h1t_ : @measurable_set \u03b1 m\u2080 t, from h _ h1t,\n    rw [@measure_compl \u03b1 m\u2080 \u03bc t h1t_ (@measure_ne_top \u03b1 m\u2080 \u03bc _ t),\n      @measure_compl \u03b1 m\u2080 \u03bd t h1t_ (@measure_ne_top \u03b1 m\u2080 \u03bd _ t), h_univ, h2t], },\n  { intros f h1f h2f h3f,\n    have h2f_ : \u2200 (i : \u2115), @measurable_set \u03b1 m\u2080 (f i), from (\u03bb i, h _ (h2f i)),\n    have h_Union : @measurable_set \u03b1 m\u2080 (\u22c3 (i : \u2115), f i),from @measurable_set.Union \u03b1 \u2115 m\u2080 _ 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 \u03c0-system generating the \u03c3-algebra\n  (and `univ`). -/\nlemma ext_of_generate_finite (C : set (set \u03b1)) (hA : m0 = generate_from C) (hC : is_pi_system C)\n  [is_finite_measure \u03bc] (h\u03bc\u03bd : \u2200 s \u2208 C, \u03bc s = \u03bd s) (h_univ : \u03bc univ = \u03bd univ) :\n  \u03bc = \u03bd :=\nmeasure.ext (\u03bb s hs, ext_on_measurable_space_of_generate_finite m0 C h\u03bc\u03bd le_rfl hA hC h_univ hs)\n\nnamespace measure\n\nsection disjointed\n\ninclude m0\n\n/-- Given `S : \u03bc.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 {\u03bc : measure \u03b1}\n  (S : \u03bc.finite_spanning_sets_in {s | measurable_set s}) :\n   \u03bc.finite_spanning_sets_in {s | measurable_set s} :=\n\u27e8disjointed S.set, measurable_set.disjointed S.set_mem,\n  \u03bb n, lt_of_le_of_lt (measure_mono (disjointed_subset S.set n)) (S.finite _),\n  S.spanning \u25b8 Union_disjointed\u27e9\n\nlemma finite_spanning_sets_in.disjointed_set_eq {\u03bc : measure \u03b1}\n  (S : \u03bc.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  (\u03bc \u03bd : measure \u03b1) [sigma_finite \u03bc] [sigma_finite \u03bd] :\n  \u2203 (S : \u03bc.finite_spanning_sets_in {s | measurable_set s})\n    (T : \u03bd.finite_spanning_sets_in {s | measurable_set s}),\n    S.set = T.set \u2227 pairwise (disjoint on S.set) :=\nlet S := (\u03bc + \u03bd).to_finite_spanning_sets_in.disjointed in\n\u27e8S.of_le (measure.le_add_right le_rfl), S.of_le (measure.le_add_left le_rfl),\n  rfl, disjoint_disjointed _\u27e9\n\nend disjointed\n\nnamespace finite_at_filter\n\nvariables {f g : filter \u03b1}\n\nlemma filter_mono (h : f \u2264 g) : \u03bc.finite_at_filter g \u2192 \u03bc.finite_at_filter f :=\n\u03bb \u27e8s, hs, h\u03bc\u27e9, \u27e8s, h hs, h\u03bc\u27e9\n\nlemma inf_of_left (h : \u03bc.finite_at_filter f) : \u03bc.finite_at_filter (f \u2293 g) :=\nh.filter_mono inf_le_left\n\nlemma inf_of_right (h : \u03bc.finite_at_filter g) : \u03bc.finite_at_filter (f \u2293 g) :=\nh.filter_mono inf_le_right\n\n@[simp] lemma inf_ae_iff : \u03bc.finite_at_filter (f \u2293 \u03bc.ae) \u2194 \u03bc.finite_at_filter f :=\nbegin\n  refine \u27e8_, \u03bb h, h.filter_mono inf_le_left\u27e9,\n  rintros \u27e8s, \u27e8t, ht, u, hu, rfl\u27e9, h\u03bc\u27e9,\n  suffices : \u03bc t \u2264 \u03bc (t \u2229 u), from \u27e8t, ht, this.trans_lt h\u03bc\u27e9,\n  exact measure_mono_ae (mem_of_superset hu (\u03bb x hu ht, \u27e8ht, hu\u27e9))\nend\n\nalias inf_ae_iff \u2194 measure_theory.measure.finite_at_filter.of_inf_ae _\n\nlemma filter_mono_ae (h : f \u2293 \u03bc.ae \u2264 g) (hg : \u03bc.finite_at_filter g) : \u03bc.finite_at_filter f :=\ninf_ae_iff.1 (hg.filter_mono h)\n\nprotected lemma measure_mono (h : \u03bc \u2264 \u03bd) : \u03bd.finite_at_filter f \u2192 \u03bc.finite_at_filter f :=\n\u03bb \u27e8s, hs, h\u03bd\u27e9, \u27e8s, hs, (measure.le_iff'.1 h s).trans_lt h\u03bd\u27e9\n\n@[mono] protected lemma mono (hf : f \u2264 g) (h\u03bc : \u03bc \u2264 \u03bd) :\n  \u03bd.finite_at_filter g \u2192 \u03bc.finite_at_filter f :=\n\u03bb h, (h.filter_mono hf).measure_mono h\u03bc\n\nprotected lemma eventually (h : \u03bc.finite_at_filter f) : \u2200\u1da0 s in f.lift' powerset, \u03bc s < \u221e :=\n(eventually_lift'_powerset' $ \u03bb s t hst ht, (measure_mono hst).trans_lt ht).2 h\n\nlemma filter_sup : \u03bc.finite_at_filter f \u2192 \u03bc.finite_at_filter g \u2192 \u03bc.finite_at_filter (f \u2294 g) :=\n\u03bb \u27e8s, hsf, hs\u03bc\u27e9 \u27e8t, htg, ht\u03bc\u27e9,\n \u27e8s \u222a t, union_mem_sup hsf htg, (measure_union_le s t).trans_lt (ennreal.add_lt_top.2 \u27e8hs\u03bc, ht\u03bc\u27e9)\u27e9\n\nend finite_at_filter\n\nlemma finite_at_nhds_within [topological_space \u03b1] {m0 : measurable_space \u03b1} (\u03bc : measure \u03b1)\n  [is_locally_finite_measure \u03bc] (x : \u03b1) (s : set \u03b1) :\n  \u03bc.finite_at_filter (\ud835\udcdd[s] x) :=\n(finite_at_nhds \u03bc x).inf_of_left\n\n@[simp] lemma finite_at_principal : \u03bc.finite_at_filter (\ud835\udcdf s) \u2194 \u03bc s < \u221e :=\n\u27e8\u03bb \u27e8t, ht, h\u03bc\u27e9, (measure_mono ht).trans_lt h\u03bc, \u03bb h, \u27e8s, mem_principal_self s, h\u27e9\u27e9\n\nlemma is_locally_finite_measure_of_le [topological_space \u03b1] {m : measurable_space \u03b1}\n  {\u03bc \u03bd : measure \u03b1} [H : is_locally_finite_measure \u03bc] (h : \u03bd \u2264 \u03bc) :\n  is_locally_finite_measure \u03bd :=\nlet F := H.finite_at_nhds in \u27e8\u03bb x, (F x).measure_mono h\u27e9\n\n/-! ### Subtraction of measures -/\n\n/-- The measure `\u03bc - \u03bd` is defined to be the least measure `\u03c4` such that `\u03bc \u2264 \u03c4 + \u03bd`.\nIt is the equivalent of `(\u03bc - \u03bd) \u2294 0` if `\u03bc` and `\u03bd` were signed measures.\nCompare with `ennreal.has_sub`.\nSpecifically, note that if you have `\u03b1 = {1,2}`, and  `\u03bc {1} = 2`, `\u03bc {2} = 0`, and\n`\u03bd {2} = 2`, `\u03bd {1} = 0`, then `(\u03bc - \u03bd) {1, 2} = 2`. However, if `\u03bc \u2264 \u03bd`, and\n`\u03bd univ \u2260 \u221e`, then `(\u03bc - \u03bd) + \u03bd = \u03bc`. -/\nnoncomputable instance has_sub {\u03b1 : Type*} [measurable_space \u03b1] : has_sub (measure \u03b1) :=\n\u27e8\u03bb \u03bc \u03bd, Inf {\u03c4 | \u03bc \u2264 \u03c4 + \u03bd} \u27e9\n\nsection measure_sub\n\nlemma sub_def : \u03bc - \u03bd = Inf {d | \u03bc \u2264 d + \u03bd} := rfl\n\nlemma sub_eq_zero_of_le (h : \u03bc \u2264 \u03bd) : \u03bc - \u03bd = 0 :=\nbegin\n  rw [\u2190 nonpos_iff_eq_zero', measure.sub_def],\n  apply @Inf_le (measure \u03b1) _ _,\n  simp [h],\nend\n\n/-- This application lemma only works in special circumstances. Given knowledge of\nwhen `\u03bc \u2264 \u03bd` and `\u03bd \u2264 \u03bc`, a more general application lemma can be written. -/\nlemma sub_apply [is_finite_measure \u03bd] (h\u2081 : measurable_set s) (h\u2082 : \u03bd \u2264 \u03bc) :\n  (\u03bc - \u03bd) s = \u03bc s - \u03bd s :=\nbegin\n  -- We begin by defining `measure_sub`, which will be equal to `(\u03bc - \u03bd)`.\n  let measure_sub : measure \u03b1 := @measure_theory.measure.of_measurable \u03b1 _\n    (\u03bb (t : set \u03b1) (h_t_measurable_set : measurable_set t), (\u03bc t - \u03bd 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 \u2190 measure_theory.measure_Union h_disj h_meas },\n      exacts [measure_theory.measure_ne_top _ _, \u03bb i, h\u2082 _ (h_meas _)]\n    end,\n  -- Now, we demonstrate `\u03bc - \u03bd = measure_sub`, and apply it.\n  begin\n    have h_measure_sub_add : (\u03bd + measure_sub = \u03bc),\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\u2082 t h_t_measurable_set)] },\n    have h_measure_sub_eq : (\u03bc - \u03bd) = measure_sub,\n    { rw measure_theory.measure.sub_def, apply le_antisymm,\n      { apply @Inf_le (measure \u03b1) measure.complete_semilattice_Inf,\n        simp [le_refl, add_comm, h_measure_sub_add] },\n      apply @le_Inf (measure \u03b1) measure.complete_semilattice_Inf,\n      intros d h_d, rw [\u2190 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\u2081,\n  end\nend\n\nlemma sub_add_cancel_of_le [is_finite_measure \u03bd] (h\u2081 : \u03bd \u2264 \u03bc) : \u03bc - \u03bd + \u03bd = \u03bc :=\nbegin\n  ext s h_s_meas,\n  rw [add_apply, sub_apply h_s_meas h\u2081, tsub_add_cancel_of_le (h\u2081 s h_s_meas)],\nend\n\nlemma sub_le : \u03bc - \u03bd \u2264 \u03bc :=\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  (\u03bc - \u03bd).restrict s = (\u03bc.restrict s) - (\u03bd.restrict s) :=\nbegin\n  repeat {rw sub_def},\n  have h_nonempty : {d | \u03bc \u2264 d + \u03bd}.nonempty,\n  { apply @set.nonempty_of_mem _ _ \u03bc, 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 \u03b1) _,\n    intros \u03bd' h_\u03bd'_in, rw mem_set_of_eq at h_\u03bd'_in, apply exists.intro (\u03bd'.restrict s),\n    split,\n    { rw mem_image, apply exists.intro (\u03bd' + (\u22a4 : measure_theory.measure \u03b1).restrict s\u1d9c),\n      rw mem_set_of_eq,\n      split,\n      { rw [add_assoc, add_comm _ \u03bd, \u2190 add_assoc, measure_theory.measure.le_iff],\n        intros t h_meas_t,\n        have h_inter_inter_eq_inter : \u2200 t' : set \u03b1 , t \u2229 t' \u2229 t' = t \u2229 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 \u2229 s) :=\n           h_meas_t.inter h_meas_s,\n        repeat { rw \u2190 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 \u2190 @restrict_eq_self _ _ \u03bc s _ h_meas_t_inter_s (set.inter_subset_right _ _),\n          rw \u2190 @restrict_eq_self _ _ \u03bd s _ h_meas_t_inter_s (set.inter_subset_right _ _),\n          apply h_\u03bd'_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\u1d9c],\n          have h_mu_le_add_top : \u03bc \u2264 \u03bd' + \u03bd + \u22a4,\n          { rw add_comm,\n            have h_le_top : \u03bc \u2264 \u22a4 := le_top,\n            apply (\u03bb t\u2082 h_meas, le_add_right (h_le_top t\u2082 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 \u03b1) _,\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, \u2190 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 : \u03bc.restrict s \u2264 \u03bd.restrict s) (h_meas_s : measurable_set s) :\n  (\u03bc - \u03bd) s = 0 :=\nbegin\n  rw [\u2190 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 \u03bc] : is_finite_measure (\u03bc - \u03bd) :=\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 \u03b1} {m1 : measurable_space \u03b2} {f : \u03b1 \u2192 \u03b2}\n  (hf : measurable_embedding f)\ninclude hf\n\ntheorem map_apply (\u03bc : measure \u03b1) (s : set \u03b2) : map f \u03bc s = \u03bc (f \u207b\u00b9' s) :=\nbegin\n  refine le_antisymm _ (le_map_apply hf.measurable s),\n  set t := f '' (to_measurable \u03bc (f \u207b\u00b9' s)) \u222a (range f)\u1d9c,\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 \u2286 t,\n  { rw [subset_union_compl_iff_inter_subset, \u2190 image_preimage_eq_inter_range],\n    exact image_subset _ (subset_to_measurable _ _) },\n  have hft : f \u207b\u00b9' t = to_measurable \u03bc (f \u207b\u00b9' s),\n    by rw [preimage_union, preimage_compl, preimage_range, compl_univ, union_empty,\n      hf.injective.preimage_image],\n  calc map f \u03bc s \u2264 map f \u03bc t : measure_mono hst\n            ... = \u03bc (f \u207b\u00b9' s) :\n    by rw [map_apply hf.measurable htm, hft, measure_to_measurable]\nend\n\nlemma map_comap (\u03bc : measure \u03b2) : map f (comap f \u03bc) = \u03bc.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 (\u03bc : measure \u03b2) (s : set \u03b1) : comap f \u03bc s = \u03bc (f '' s) :=\ncalc comap f \u03bc s = comap f \u03bc (f \u207b\u00b9' (f '' s)) : by rw hf.injective.preimage_image\n... = map f (comap f \u03bc) (f '' s) : (hf.map_apply _ _).symm\n... = \u03bc (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 : \u03b2 \u2192 Prop} {\u03bc : measure \u03b1} : (\u2200\u1d50 x \u2202(map f \u03bc), p x) \u2194 \u2200\u1d50 x \u2202\u03bc, p (f x) :=\nby simp only [ae_iff, hf.map_apply, preimage_set_of_eq]\n\nlemma restrict_map (\u03bc : measure \u03b1) (s : set \u03b2) :\n  (map f \u03bc).restrict s = map f (\u03bc.restrict $ f \u207b\u00b9' s) :=\nmeasure.ext $ \u03bb 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 \u03b1} {s : set \u03b1} (hs : measurable_set s)\n  (\u03bc : measure \u03b1) (t : set s) :\n  comap coe \u03bc t = \u03bc (coe '' t) :=\n(measurable_embedding.subtype_coe hs).comap_apply _ _\n\nlemma map_comap_subtype_coe {m0 : measurable_space \u03b1} {s : set \u03b1} (hs : measurable_set s)\n  (\u03bc : measure \u03b1) : map (coe : s \u2192 \u03b1) (comap coe \u03bc) = \u03bc.restrict s :=\nby rw [(measurable_embedding.subtype_coe hs).map_comap, subtype.range_coe]\n\nlemma ae_restrict_iff_subtype {m0 : measurable_space \u03b1} {\u03bc : measure \u03b1} {s : set \u03b1}\n  (hs : measurable_set s) {p : \u03b1 \u2192 Prop} :\n  (\u2200\u1d50 x \u2202(\u03bc.restrict s), p x) \u2194 \u2200\u1d50 x \u2202(comap (coe : s \u2192 \u03b1) \u03bc), p \u2191x :=\nby rw [\u2190 map_comap_subtype_coe hs, (measurable_embedding.subtype_coe hs).ae_map_iff]\n\nvariables [measure_space \u03b1]\n\n/-!\n### Volume on `s : set \u03b1`\n-/\n\ninstance _root_.set_coe.measure_space (s : set \u03b1) : measure_space s :=\n\u27e8comap (coe : s \u2192 \u03b1) volume\u27e9\n\nlemma volume_set_coe_def (s : set \u03b1) : (volume : measure s) = comap (coe : s \u2192 \u03b1) volume := rfl\n\nlemma measurable_set.map_coe_volume {s : set \u03b1} (hs : measurable_set s) :\n  map (coe : s \u2192 \u03b1) 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 \u03b1} (hs : measurable_set s) (t : set s) :\n  volume (coe '' t : set \u03b1) = 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 \u03b1] [measurable_space \u03b2] {\u03bc : measure \u03b1} {\u03bd : measure \u03b2}\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 : \u03b1 \u2243\u1d50 \u03b2) (s : set \u03b2) : map f \u03bc s = \u03bc (f \u207b\u00b9' s) :=\nf.measurable_embedding.map_apply _ _\n\n@[simp] lemma map_symm_map (e : \u03b1 \u2243\u1d50 \u03b2) : map e.symm (map e \u03bc) = \u03bc :=\nby simp [map_map e.symm.measurable e.measurable]\n\n@[simp] lemma map_map_symm (e : \u03b1 \u2243\u1d50 \u03b2) : map e (map e.symm \u03bd) = \u03bd :=\nby simp [map_map e.measurable e.symm.measurable]\n\nlemma map_measurable_equiv_injective (e : \u03b1 \u2243\u1d50 \u03b2) : injective (map e) :=\nby { intros \u03bc\u2081 \u03bc\u2082 h\u03bc, apply_fun map e.symm at h\u03bc, simpa [map_symm_map e] using h\u03bc }\n\nlemma map_apply_eq_iff_map_symm_apply_eq (e : \u03b1 \u2243\u1d50 \u03b2) : map e \u03bc = \u03bd \u2194 map e.symm \u03bd = \u03bc :=\nby rw [\u2190 (map_measurable_equiv_injective e).eq_iff, map_map_symm, eq_comm]\n\nlemma restrict_map (e : \u03b1 \u2243\u1d50 \u03b2) (s : set \u03b2) : (map e \u03bc).restrict s = map e (\u03bc.restrict $ e \u207b\u00b9' s) :=\ne.measurable_embedding.restrict_map _ _\n\nend measurable_equiv\n\n\nnamespace measure_theory\n\nlemma outer_measure.to_measure_zero [measurable_space \u03b1] : (0 : outer_measure \u03b1).to_measure\n  ((le_top).trans outer_measure.zero_caratheodory.symm.le) = 0 :=\nby rw [\u2190 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 `\u03bc` on a measurable space structure `m0` as being also a measure on\nany `m \u2264 m0`. Since measures in mathlib have to be trimmed to the measurable space, `\u03bc` itself\ncannot be a measure on `m`, hence the definition of `\u03bc.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 \u03b1} (\u03bc : @measure \u03b1 m0) (hm : m \u2264 m0) : @measure \u03b1 m :=\n@outer_measure.to_measure \u03b1 m \u03bc.to_outer_measure (hm.trans (le_to_outer_measure_caratheodory \u03bc))\n\n@[simp] lemma trim_eq_self [measurable_space \u03b1] {\u03bc : measure \u03b1} : \u03bc.trim le_rfl = \u03bc :=\nby simp [measure.trim]\n\nvariables {m m0 : measurable_space \u03b1} {\u03bc : measure \u03b1} {s : set \u03b1}\n\nlemma to_outer_measure_trim_eq_trim_to_outer_measure (\u03bc : measure \u03b1) (hm : m \u2264 m0) :\n  @measure.to_outer_measure _ m (\u03bc.trim hm) = @outer_measure.trim _ m \u03bc.to_outer_measure :=\nby rw [measure.trim, to_measure_to_outer_measure]\n\n@[simp] lemma zero_trim (hm : m \u2264 m0) : (0 : measure \u03b1).trim hm = (0 : @measure \u03b1 m) :=\nby simp [measure.trim, outer_measure.to_measure_zero]\n\nlemma trim_measurable_set_eq (hm : m \u2264 m0) (hs : @measurable_set \u03b1 m s) : \u03bc.trim hm s = \u03bc s :=\nby simp [measure.trim, hs]\n\nlemma le_trim (hm : m \u2264 m0) : \u03bc s \u2264 \u03bc.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 \u2264 m0) (h : \u03bc.trim hm s = 0) : \u03bc s = 0 :=\nle_antisymm ((le_trim hm).trans (le_of_eq h)) (zero_le _)\n\nlemma measure_trim_to_measurable_eq_zero {hm : m \u2264 m0} (hs : \u03bc.trim hm s = 0) :\n  \u03bc (@to_measurable \u03b1 m (\u03bc.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 \u2264 m0} {f\u2081 f\u2082 : \u03b1 \u2192 E}\n  (h12 : f\u2081 =\u1da0[@measure.ae \u03b1 m (\u03bc.trim hm)] f\u2082) :\n  f\u2081 =\u1d50[\u03bc] f\u2082 :=\nmeasure_eq_zero_of_trim_eq_zero hm h12\n\nlemma restrict_trim (hm : m \u2264 m0) (\u03bc : measure \u03b1) (hs : @measurable_set \u03b1 m s) :\n  @measure.restrict \u03b1 m (\u03bc.trim hm) s = (\u03bc.restrict s).trim hm :=\nbegin\n  ext1 t ht,\n  rw [@measure.restrict_apply \u03b1 m _ _ _ ht, trim_measurable_set_eq hm ht,\n    measure.restrict_apply (hm t ht),\n    trim_measurable_set_eq hm (@measurable_set.inter \u03b1 m t s ht hs)],\nend\n\ninstance is_finite_measure_trim (hm : m \u2264 m0) [is_finite_measure \u03bc] :\n  is_finite_measure (\u03bc.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 \u03bc`, 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 \u03b1] [measurable_space \u03b2]\n{f g : \u03b1 \u2192 \u03b2} {\u03bc \u03bd : measure \u03b1}\n\n@[nontriviality, measurability]\nlemma subsingleton.ae_measurable [subsingleton \u03b1] : ae_measurable f \u03bc :=\nsubsingleton.measurable.ae_measurable\n\n@[nontriviality, measurability]\nlemma ae_measurable_of_subsingleton_codomain [subsingleton \u03b2] : ae_measurable f \u03bc :=\n(measurable_of_subsingleton_codomain f).ae_measurable\n\n@[simp, measurability] lemma ae_measurable_zero_measure : ae_measurable f (0 : measure \u03b1) :=\nbegin\n  nontriviality \u03b1, inhabit \u03b1,\n  exact \u27e8\u03bb x, f (default \u03b1), measurable_const, rfl\u27e9\nend\n\nnamespace ae_measurable\n\nlemma mono_measure (h : ae_measurable f \u03bc) (h' : \u03bd \u2264 \u03bc) : ae_measurable f \u03bd :=\n\u27e8h.mk f, h.measurable_mk, eventually.filter_mono (ae_mono h') h.ae_eq_mk\u27e9\n\nlemma mono_set {s t} (h : s \u2286 t) (ht : ae_measurable f (\u03bc.restrict t)) :\n  ae_measurable f (\u03bc.restrict s) :=\nht.mono_measure (restrict_mono h le_rfl)\n\nprotected lemma mono' (h : ae_measurable f \u03bc) (h' : \u03bd \u226a \u03bc) : ae_measurable f \u03bd :=\n\u27e8h.mk f, h.measurable_mk, h' h.ae_eq_mk\u27e9\n\nlemma ae_mem_imp_eq_mk {s} (h : ae_measurable f (\u03bc.restrict s)) :\n  \u2200\u1d50 x \u2202\u03bc, x \u2208 s \u2192 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 (\u03bc.restrict s)) :\n  f =\u1da0[\u03bc.ae \u2293 \ud835\udcdf s] h.mk f :=\nle_ae_restrict h.ae_eq_mk\n\n@[measurability]\nlemma sum_measure [encodable \u03b9] {\u03bc : \u03b9 \u2192 measure \u03b1} (h : \u2200 i, ae_measurable f (\u03bc i)) :\n  ae_measurable f (sum \u03bc) :=\nbegin\n  nontriviality \u03b2, inhabit \u03b2,\n  set s : \u03b9 \u2192 set \u03b1 := \u03bb i, to_measurable (\u03bc i) {x | f x \u2260 (h i).mk f x},\n  have hs\u03bc : \u2200 i, \u03bc i (s i) = 0,\n  { intro i, rw measure_to_measurable, exact (h i).ae_eq_mk },\n  have hsm : measurable_set (\u22c2 i, s i),\n    from measurable_set.Inter (\u03bb i, measurable_set_to_measurable _ _),\n  have hs : \u2200 i x, x \u2209 s i \u2192 f x = (h i).mk f x,\n  { intros i x hx, contrapose! hx, exact subset_to_measurable _ _ hx },\n  set g : \u03b1 \u2192 \u03b2 := (\u22c2 i, s i).piecewise (const \u03b1 (default \u03b2)) f,\n  refine \u27e8g, measurable_of_restrict_of_restrict_compl hsm _ _, ae_sum_iff.mpr $ \u03bb i, _\u27e9,\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 \u27e8\u22c3 i, ((h i).mk f \u207b\u00b9' t) \u2229 (s i)\u1d9c, measurable_set.Union $\n      \u03bb i, (measurable_mk _ ht).inter (measurable_set_to_measurable _ _).compl, _\u27e9,\n    ext \u27e8x, hx\u27e9,\n    simp only [mem_preimage, mem_Union, subtype.coe_mk, set.restrict, mem_inter_eq,\n      mem_compl_iff] at hx \u22a2,\n    split,\n    { rintro \u27e8i, hxt, hxs\u27e9, rwa hs _ _ hxs },\n    { rcases hx with \u27e8i, hi\u27e9, rw hs _ _ hi, exact \u03bb h, \u27e8i, h, hi\u27e9 } },\n  { refine measure_mono_null (\u03bb x (hx : f x \u2260 g x), _) (hs\u03bc i),\n    contrapose! hx, refine (piecewise_eq_of_not_mem _ _ _ _).symm,\n    exact \u03bb h, hx (mem_Inter.1 h i) }\nend\n\n@[simp] lemma _root_.ae_measurable_sum_measure_iff [encodable \u03b9] {\u03bc : \u03b9 \u2192 measure \u03b1} :\n  ae_measurable f (sum \u03bc) \u2194 \u2200 i, ae_measurable f (\u03bc i) :=\n\u27e8\u03bb h i, h.mono_measure (le_sum _ _), sum_measure\u27e9\n\n@[simp] lemma _root_.ae_measurable_add_measure_iff :\n  ae_measurable f (\u03bc + \u03bd) \u2194 ae_measurable f \u03bc \u2227 ae_measurable f \u03bd :=\nby { rw [\u2190 sum_cond, ae_measurable_sum_measure_iff, bool.forall_bool, and.comm], refl }\n\n@[measurability]\nlemma add_measure {f : \u03b1 \u2192 \u03b2} (h\u03bc : ae_measurable f \u03bc) (h\u03bd : ae_measurable f \u03bd) :\n  ae_measurable f (\u03bc + \u03bd) :=\nae_measurable_add_measure_iff.2 \u27e8h\u03bc, h\u03bd\u27e9\n\n@[measurability]\nprotected lemma Union [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1} (h : \u2200 i, ae_measurable f (\u03bc.restrict (s i))) :\n  ae_measurable f (\u03bc.restrict (\u22c3 i, s i)) :=\n(sum_measure h).mono_measure $ restrict_Union_le\n\n@[simp] lemma _root_.ae_measurable_Union_iff [encodable \u03b9] {s : \u03b9 \u2192 set \u03b1} :\n  ae_measurable f (\u03bc.restrict (\u22c3 i, s i)) \u2194 \u2200 i, ae_measurable f (\u03bc.restrict (s i)) :=\n\u27e8\u03bb h i, h.mono_measure $ restrict_mono (subset_Union _ _) le_rfl, ae_measurable.Union\u27e9\n\n@[measurability]\nlemma smul_measure (h : ae_measurable f \u03bc) (c : \u211d\u22650\u221e) :\n  ae_measurable f (c \u2022 \u03bc) :=\n\u27e8h.mk f, h.measurable_mk, ae_smul_measure h.ae_eq_mk c\u27e9\n\nlemma comp_measurable [measurable_space \u03b4] {f : \u03b1 \u2192 \u03b4} {g : \u03b4 \u2192 \u03b2}\n  (hg : ae_measurable g (map f \u03bc)) (hf : measurable f) : ae_measurable (g \u2218 f) \u03bc :=\n\u27e8hg.mk g \u2218 f, hg.measurable_mk.comp hf, ae_eq_comp hf hg.ae_eq_mk\u27e9\n\nlemma comp_measurable' {\u03b4} [measurable_space \u03b4] {\u03bd : measure \u03b4} {f : \u03b1 \u2192 \u03b4} {g : \u03b4 \u2192 \u03b2}\n  (hg : ae_measurable g \u03bd) (hf : measurable f) (h : map f \u03bc \u226a \u03bd) : ae_measurable (g \u2218 f) \u03bc :=\n(hg.mono' h).comp_measurable hf\n\n@[measurability]\nlemma prod_mk {\u03b3 : Type*} [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3}\n  (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) : ae_measurable (\u03bb x, (f x, g x)) \u03bc :=\n\u27e8\u03bb 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\u27e9\n\nlemma subtype_mk (h : ae_measurable f \u03bc) {s : set \u03b2} {hfs : \u2200 x, f x \u2208 s} (hs : measurable_set s) :\n  ae_measurable (cod_restrict f s hfs) \u03bc :=\nbegin\n  nontriviality \u03b1, inhabit \u03b1,\n  rcases h with \u27e8g, hgm, hg\u27e9,\n  rcases hs.exists_measurable_proj \u27e8f (default \u03b1), hfs _\u27e9 with \u27e8\u03c0, h\u03c0m, h\u03c0\u27e9,\n  refine \u27e8\u03c0 \u2218 g, h\u03c0m.comp hgm, hg.mono $ \u03bb x hx, _\u27e9,\n  rw [comp_apply, \u2190 hx, \u2190 coe_cod_restrict_apply f s hfs, h\u03c0]\nend\n\nprotected lemma null_measurable (h : ae_measurable f \u03bc) : null_measurable f \u03bc :=\nlet \u27e8g, hgm, hg\u27e9 := h in hgm.null_measurable.congr hg.symm\n\nend ae_measurable\n\nlemma ae_measurable_iff_measurable [\u03bc.is_complete] :\n  ae_measurable f \u03bc \u2194 measurable f :=\n\u27e8\u03bb h, h.null_measurable.measurable_of_complete, \u03bb h, h.ae_measurable\u27e9\n\nlemma measurable_embedding.ae_measurable_map_iff [measurable_space \u03b3] {f : \u03b1 \u2192 \u03b2}\n  (hf : measurable_embedding f) {\u03bc : measure \u03b1} {g : \u03b2 \u2192 \u03b3} :\n  ae_measurable g (map f \u03bc) \u2194 ae_measurable (g \u2218 f) \u03bc :=\nbegin\n  refine \u27e8\u03bb H, H.comp_measurable hf.measurable, _\u27e9,\n  rintro \u27e8g\u2081, hgm\u2081, heq\u27e9,\n  rcases hf.exists_measurable_extend hgm\u2081 (\u03bb x, \u27e8g x\u27e9) with \u27e8g\u2082, hgm\u2082, rfl\u27e9,\n  exact \u27e8g\u2082, hgm\u2082, hf.ae_map_iff.2 heq\u27e9\nend\n\nlemma measurable_embedding.ae_measurable_comp_iff [measurable_space \u03b3] {g : \u03b2 \u2192 \u03b3}\n  (hg : measurable_embedding g) {\u03bc : measure \u03b1} {f : \u03b1 \u2192 \u03b2} :\n  ae_measurable (g \u2218 f) \u03bc \u2194 ae_measurable f \u03bc :=\nbegin\n  refine \u27e8\u03bb H, _, hg.measurable.comp_ae_measurable\u27e9,\n  suffices : ae_measurable ((range_splitting g \u2218 range_factorization g) \u2218 f) \u03bc,\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 \u03b1} (hs : measurable_set s)\n  {\u03bc : measure \u03b1} {f : \u03b1 \u2192 \u03b2} :\n  ae_measurable f (\u03bc.restrict s) \u2194 ae_measurable (f \u2218 coe : s \u2192 \u03b2) (comap coe \u03bc) :=\nby rw [\u2190 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 \u03b2] : ae_measurable (\u03bb a : \u03b1, (1 : \u03b2)) \u03bc :=\nmeasurable_one.ae_measurable\n\n@[simp] lemma ae_measurable_smul_measure_iff {c : \u211d\u22650\u221e} (hc : c \u2260 0) :\n  ae_measurable f (c \u2022 \u03bc) \u2194 ae_measurable f \u03bc :=\n\u27e8\u03bb h, \u27e8h.mk f, h.measurable_mk, (ae_smul_measure_iff hc).1 h.ae_eq_mk\u27e9,\n  \u03bb h, \u27e8h.mk f, h.measurable_mk, (ae_smul_measure_iff hc).2 h.ae_eq_mk\u27e9\u27e9\n\nlemma ae_measurable_of_ae_measurable_trim {\u03b1} {m m0 : measurable_space \u03b1}\n  {\u03bc : measure \u03b1} (hm : m \u2264 m0) {f : \u03b1 \u2192 \u03b2} (hf : ae_measurable f (\u03bc.trim hm)) :\n  ae_measurable f \u03bc :=\n\u27e8hf.mk f, measurable.mono hf.measurable_mk hm le_rfl, ae_eq_of_ae_eq_trim hf.ae_eq_mk\u27e9\n\nlemma ae_measurable_restrict_of_measurable_subtype {s : set \u03b1}\n  (hs : measurable_set s) (hf : measurable (\u03bb x : s, f x)) : ae_measurable f (\u03bc.restrict s) :=\n(ae_measurable_restrict_iff_comap_subtype hs).2 hf.ae_measurable\n\nlemma ae_measurable_map_equiv_iff [measurable_space \u03b3] (e : \u03b1 \u2243\u1d50 \u03b2) {f : \u03b2 \u2192 \u03b3} :\n  ae_measurable f (map e \u03bc) \u2194 ae_measurable (f \u2218 e) \u03bc :=\ne.measurable_embedding.ae_measurable_map_iff\n\nend\n\nnamespace is_compact\n\nvariables [topological_space \u03b1] [measurable_space \u03b1] {\u03bc : measure \u03b1} {s : set \u03b1}\n\n/-- If `s` is a compact set and `\u03bc` is finite at `\ud835\udcdd x` for every `x \u2208 s`, then `s` admits an open\nsuperset of finite measure. -/\nlemma exists_open_superset_measure_lt_top' (h : is_compact s)\n  (h\u03bc : \u2200 x \u2208 s, \u03bc.finite_at_filter (\ud835\udcdd x)) :\n  \u2203 U \u2287 s, is_open U \u2227 \u03bc U < \u221e :=\nbegin\n  refine is_compact.induction_on h _ _ _ _,\n  { use \u2205, simp [superset] },\n  { rintro s t hst \u27e8U, htU, hUo, hU\u27e9, exact \u27e8U, hst.trans htU, hUo, hU\u27e9 },\n  { rintro s t \u27e8U, hsU, hUo, hU\u27e9 \u27e8V, htV, hVo, hV\u27e9,\n    refine \u27e8U \u222a V, union_subset_union hsU htV, hUo.union hVo,\n      (measure_union_le _ _).trans_lt $ ennreal.add_lt_top.2 \u27e8hU, hV\u27e9\u27e9 },\n  { intros x hx,\n    rcases (h\u03bc x hx).exists_mem_basis (nhds_basis_opens _) with \u27e8U, \u27e8hx, hUo\u27e9, hU\u27e9,\n    exact \u27e8U, nhds_within_le_nhds (hUo.mem_nhds hx), U, subset.rfl, hUo, hU\u27e9 }\nend\n\n/-- If `s` is a compact set and `\u03bc` 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  (\u03bc : measure \u03b1) [is_locally_finite_measure \u03bc] :\n  \u2203 U \u2287 s, is_open U \u2227 \u03bc U < \u221e :=\nh.exists_open_superset_measure_lt_top' $ \u03bb x hx, \u03bc.finite_at_nhds x\n\nlemma measure_lt_top_of_nhds_within (h : is_compact s) (h\u03bc : \u2200 x \u2208 s, \u03bc.finite_at_filter (\ud835\udcdd[s] x)) :\n  \u03bc s < \u221e :=\nis_compact.induction_on h (by simp) (\u03bb s t hst ht, (measure_mono hst).trans_lt ht)\n  (\u03bb s t hs ht, (measure_union_le s t).trans_lt (ennreal.add_lt_top.2 \u27e8hs, ht\u27e9)) h\u03bc\n\nlemma measure_lt_top (h : is_compact s) {\u03bc : measure \u03b1} [is_locally_finite_measure \u03bc] :\n  \u03bc s < \u221e :=\nh.measure_lt_top_of_nhds_within $ \u03bb x hx, \u03bc.finite_at_nhds_within _ _\n\nlemma measure_zero_of_nhds_within (hs : is_compact s) :\n  (\u2200 a \u2208 s, \u2203 t \u2208 \ud835\udcdd[s] a, \u03bc t = 0) \u2192 \u03bc s = 0 :=\nby simpa only [\u2190 compl_mem_ae_iff] using hs.compl_mem_sets_of_nhds_within\n\nend is_compact\n\n/-- Compact covering of a `\u03c3`-compact topological space as\n`measure_theory.measure.finite_spanning_sets_in`. -/\ndef measure_theory.measure.finite_spanning_sets_in_compact [topological_space \u03b1]\n  [sigma_compact_space \u03b1] {m : measurable_space \u03b1} (\u03bc : measure \u03b1) [is_locally_finite_measure \u03bc] :\n  \u03bc.finite_spanning_sets_in {K | is_compact K} :=\n{ set := compact_covering \u03b1,\n  set_mem := is_compact_compact_covering \u03b1,\n  finite := \u03bb n, (is_compact_compact_covering \u03b1 n).measure_lt_top,\n  spanning := Union_compact_covering \u03b1 }\n\n/-- A locally finite measure on a `\u03c3`-compact topological space admits a finite spanning sequence\nof open sets. -/\ndef measure_theory.measure.finite_spanning_sets_in_open [topological_space \u03b1]\n  [sigma_compact_space \u03b1] {m : measurable_space \u03b1} (\u03bc : measure \u03b1) [is_locally_finite_measure \u03bc] :\n  \u03bc.finite_spanning_sets_in {K | is_open K} :=\n{ set := \u03bb n, ((is_compact_compact_covering \u03b1 n).exists_open_superset_measure_lt_top \u03bc).some,\n  set_mem := \u03bb n,\n    ((is_compact_compact_covering \u03b1 n).exists_open_superset_measure_lt_top \u03bc).some_spec.snd.1,\n  finite := \u03bb n,\n    ((is_compact_compact_covering \u03b1 n).exists_open_superset_measure_lt_top \u03bc).some_spec.snd.2,\n  spanning := eq_univ_of_subset (Union_subset_Union $ \u03bb n,\n    ((is_compact_compact_covering \u03b1 n).exists_open_superset_measure_lt_top \u03bc).some_spec.fst)\n    (Union_compact_covering \u03b1) }\n\nsection measure_Ixx\n\nvariables [preorder \u03b1] [topological_space \u03b1] [compact_Icc_space \u03b1]\n  {m : measurable_space \u03b1} {\u03bc : measure \u03b1} [is_locally_finite_measure \u03bc] {a b : \u03b1}\n\nlemma measure_Icc_lt_top : \u03bc (Icc a b) < \u221e := is_compact_Icc.measure_lt_top\n\nlemma measure_Ico_lt_top : \u03bc (Ico a b) < \u221e :=\n(measure_mono Ico_subset_Icc_self).trans_lt measure_Icc_lt_top\n\nlemma measure_Ioc_lt_top : \u03bc (Ioc a b) < \u221e :=\n(measure_mono Ioc_subset_Icc_self).trans_lt measure_Icc_lt_top\n\nlemma measure_Ioo_lt_top : \u03bc (Ioo a b) < \u221e :=\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 \u03b1] [proper_space \u03b1]\n  [measurable_space \u03b1] {\u03bc : measure \u03b1} [is_locally_finite_measure \u03bc] {s : set \u03b1}\n  (hs : metric.bounded s) :\n  \u03bc s < \u221e :=\n(measure_mono subset_closure).trans_lt (metric.compact_iff_closed_bounded.2\n  \u27e8is_closed_closure, metric.bounded_closure_of_bounded hs\u27e9).measure_lt_top\n\nsection piecewise\n\nvariables [measurable_space \u03b1] {\u03bc : measure \u03b1} {s t : set \u03b1} {f g : \u03b1 \u2192 \u03b2}\n\nlemma piecewise_ae_eq_restrict (hs : measurable_set s) : piecewise s f g =\u1d50[\u03bc.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 =\u1d50[\u03bc.restrict s\u1d9c] 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 =\u1d50[\u03bc] t) : s.piecewise f g =\u1d50[\u03bc] t.piecewise f g :=\nbegin\n  filter_upwards [hst],\n  intros x hx,\n  replace hx : x \u2208 s \u2194 x \u2208 t := iff_of_eq hx,\n  by_cases h : x \u2208 s; have h' := h; rw hx at h'; simp [h, h']\nend\n\nend piecewise\n\nsection indicator_function\n\nvariables [measurable_space \u03b1] {\u03bc : measure \u03b1} {s t : set \u03b1} {f : \u03b1 \u2192 \u03b2}\n\nlemma mem_map_indicator_ae_iff_mem_map_restrict_ae_of_zero_mem [has_zero \u03b2] {t : set \u03b2}\n  (ht : (0 : \u03b2) \u2208 t) (hs : measurable_set s) :\n  t \u2208 filter.map (s.indicator f) \u03bc.ae \u2194 t \u2208 filter.map f (\u03bc.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 \u03bc (((f \u207b\u00b9' t)\u1d9c \u222a s\u1d9c) \u2229 ((\u03bb x, (0 : \u03b2)) \u207b\u00b9' t \\ s)\u1d9c) = 0 \u2194 \u03bc ((f \u207b\u00b9' t)\u1d9c \u2229 s) = 0,\n  simp only [ht, \u2190 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 \u03b2] {t : set \u03b2} (ht : (0 : \u03b2) \u2209 t)  :\n  t \u2208 filter.map (s.indicator f) \u03bc.ae \u2194 \u03bc ((f \u207b\u00b9' t)\u1d9c \u222a s\u1d9c) = 0 :=\nbegin\n  rw [mem_map, mem_ae_iff, set.indicator_preimage, set.ite, set.compl_union, set.compl_inter],\n  change \u03bc (((f \u207b\u00b9' t)\u1d9c \u222a s\u1d9c) \u2229 ((\u03bb x, (0 : \u03b2)) \u207b\u00b9' t \\ s)\u1d9c) = 0 \u2194 \u03bc ((f \u207b\u00b9' t)\u1d9c \u222a s\u1d9c) = 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 \u03b2] (hs : measurable_set s) :\n  filter.map f (\u03bc.restrict s).ae \u2264 filter.map (s.indicator f) \u03bc.ae :=\nbegin\n  intro t,\n  by_cases ht : (0 : \u03b2) \u2208 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 \u03bb h, measure_mono_null ((set.inter_subset_left _ _).trans (set.subset_union_left _ _)) h,\nend\n\nlemma ae_measurable.restrict [measurable_space \u03b2] (hfm : ae_measurable f \u03bc) {s} :\n  ae_measurable f (\u03bc.restrict s) :=\n\u27e8ae_measurable.mk f hfm, hfm.measurable_mk, ae_restrict_of_ae hfm.ae_eq_mk\u27e9\n\nvariables [has_zero \u03b2]\n\nlemma indicator_ae_eq_restrict (hs : measurable_set s) : indicator s f =\u1d50[\u03bc.restrict s] f :=\npiecewise_ae_eq_restrict hs\n\nlemma indicator_ae_eq_restrict_compl (hs : measurable_set s) : indicator s f =\u1d50[\u03bc.restrict s\u1d9c] 0 :=\npiecewise_ae_eq_restrict_compl hs\n\nlemma indicator_ae_eq_of_ae_eq_set (hst : s =\u1d50[\u03bc] t) : s.indicator f =\u1d50[\u03bc] t.indicator f :=\npiecewise_ae_eq_of_ae_eq_set hst\n\nvariables [measurable_space \u03b2]\n\nlemma ae_measurable_indicator_iff {s} (hs : measurable_set s) :\n  ae_measurable (indicator s f) \u03bc \u2194 ae_measurable f (\u03bc.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 \u27e8indicator s (h.mk f), h.measurable_mk.indicator hs, _\u27e9,\n    have A : s.indicator f =\u1d50[\u03bc.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 =\u1d50[\u03bc.restrict s\u1d9c] 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 \u03bc) {s} (hs : measurable_set s) :\n  ae_measurable (s.indicator f) \u03bc :=\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) : Prop := sorry\n\nclass IsSmooth {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) : Prop where\n  (proof : is_smooth f)\n\ninstance identity : IsSmooth fun a : \u03b1 => a := sorry\ninstance const (b : \u03b2) : IsSmooth fun a : \u03b1 => b := sorry\ninstance swap (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) [\u2200 a, IsSmooth (f a)] : IsSmooth (\u03bb b a => f a b) := sorry\ninstance parm (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) [IsSmooth f] (b : \u03b2) : IsSmooth (\u03bb a => f a b) := sorry\ninstance comp (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) [IsSmooth f] [IsSmooth g] : IsSmooth (fun a => f (g a)) := sorry\ninstance diag (f : \u03b2 \u2192 \u03b4 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) (h : \u03b1 \u2192 \u03b4) [IsSmooth f] [\u2200 b, IsSmooth (f b)] [IsSmooth g] [IsSmooth h] : IsSmooth (\u03bb a => f (g a) (h a)) := sorry\n\nset_option trace.Meta.synthInstance true\nset_option trace.Meta.synthInstance.unusedArgs true\nexample (f : \u03b2 \u2192 \u03b4 \u2192 \u03b3) [IsSmooth f] (d : \u03b4) : IsSmooth (\u03bb (g : \u03b1 \u2192 \u03b2) 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 : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b1 \u2192 \u03b2 := sorry\n\nprefix:max \"\u2202\" => diff\n\ntheorem diff_I  : \u2202 (\u03bb x : \u03b1 => x) = \u03bb x dx => dx := sorry\n-- theorem diff_K : \u2202 (\u03bb (x : \u03b1) (y : \u03b2) => x) = \u03bb x dx y => dx := sorry\ntheorem diff_K [OfNat \u03b1 0] (\u03b2 : Type _) (x : \u03b1) : \u2202 (\u03bb (y : \u03b2) => x) = \u03bb y dy => 0 := sorry\ntheorem diff_B (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) \n  : \u2202 (\u03bb x => f (g x)) \n    = \n    \u03bb x dx => \u2202 f (g x) (\u2202 g x dx) := sorry\ntheorem diff_S [Add \u03b3] (f : \u03b2 \u2192 \u03b1 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) \n  : \u2202 (\u03bb x => f (g x) x) \n    = \n    \u03bb x dx => \n      \u2202 (f (g x)) x dx \n      + \n      \u2202 (\u03bb y' => f y' x) (g x) (\u2202 g x dx) := sorry\ntheorem diff_C (f : \u03b2 \u2192 \u03b1 \u2192 \u03b3)\n  : \u2202 (\u03bb (x : \u03b1) (y : \u03b2) => f y x)\n    =\n    \u03bb x dx y => \u2202 (f y) x dx := sorry\ntheorem diff_eval (\u03b2) (x : \u03b1)\n  : \u2202 (\u03bb (f : \u03b1 \u2192 \u03b2) => f x)\n    =\n    \u03bb f df => df x := sorry\n\ntheorem diff_let [Add \u03b3] (f : \u03b2 \u2192 \u03b1 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2)\n  : \u2202 (\u03bb x => \n      let y := g x\n      f y x)\n    =\n    \u03bb x dx =>\n      let y  := g x\n      let dy := \u2202 g x dx\n      \u2202 (\u03bb yx' : \u03b2 \u00d7 \u03b1 => f yx'.1 yx'.2) (y,x) (dy,dx) := \nby \n  dsimp\n  sorry\n\ntheorem diff_let_B (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2)\n  : \u2202 (\u03bb x => \n      let y := g x\n      f y)\n    =\n    \u03bb x dx =>\n      let y  := g x\n      let dy := \u2202 g x dx\n      \u2202 f y dy := \nby \n  dsimp\n  sorry\n\nabbrev uncurry (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) := \u03bb (x,y) => f x y\nabbrev uncurry3 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4) := \u03bb (x,y,z) => f x y z\n\n@[simp \u2193]\ntheorem diff_uncurry_add [Add \u03b3] (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) \n  : \u2202(uncurry \u03bb x y => f x y)\n    =\n    \u03bb (x,y) (dx,dy) => \n      \u2202 (\u03bb x' => f x' y) x dx\n      +\n      \u2202 (f x) y dy := sorry\n\n@[simp \u2193]\ntheorem diff_prod_map (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3)\n  : \u2202 (\u03bb x => (f x, g x))\n    =\n    \u03bb x dx => (\u2202 f x dx, \u2202 g x dx) := sorry\n\ndef adj (f : \u03b1 \u2192 \u03b2) : \u03b2 \u2192 \u03b1 := sorry\n\npostfix:max \"\u2020\" => adj\n\ntheorem adj_I  : \u2202 (\u03bb x : \u03b1 => x) = \u03bb x dx => dx := sorry\ntheorem adj_B (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) \n  : (\u03bb x => f (g x))\u2020\n    = \n    \u03bb z => g\u2020 (f\u2020 z) := sorry\n\ntheorem adj_S [Add \u03b1] (f : \u03b2 \u2192 \u03b1 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) \n  : (\u03bb x => f (g x) x)\u2020\n    = \n    \u03bb z => \n      let (b,a) := (\u03bb (b,a) => f b a)\u2020 z\n      g\u2020 b + a := sorry\n\ndef sum (f : \u03b1 \u2192 \u03b2) : \u03b2 := sorry\n\n@[simp \u2193] theorem sum_diff\n  : \u2202 (\u03bb (f : \u03b1 \u2192 \u03b2) => sum f)\n    =\n    \u03bb f df => sum df := sorry\n\n@[simp \u2193] theorem sum_adj\n  : (\u03bb (f : \u03b1 \u2192 \u03b2) => sum f)\u2020\n    =\n    \u03bb x i => x := sorry\n\n\n@[simp] theorem sum_eval (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (b : \u03b2)\n  : sum f b\n    =\n    sum (\u03bb a => f a b) := sorry\n\ntheorem adj_C (f : \u03b2 \u2192 \u03b1 \u2192 \u03b3)\n  : (\u03bb (x : \u03b1) (y : \u03b2) => f y x)\u2020\n    =\n    \u03bb g => sum \u03bb y => (f y)\u2020 (g y) := sorry\n\ndef kron (i i' : \u03b1) (b : \u03b2) : \u03b2 := sorry\n\ntheorem adj_eval (\u03b2) (x : \u03b1)\n  : (\u03bb (f : \u03b1 \u2192 \u03b2) => f x)\u2020\n    =\n    \u03bb y x' => kron x x' y := sorry\n\ntheorem adj_let {\u03b1 \u03b2 \u03b3 : Type} [Add \u03b1] (f : \u03b2 \u2192 \u03b1 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2)\n  : (\u03bb x => \n      let y := g x\n      f y x)\u2020\n    =\n    \u03bb z =>\n      let yx := (\u03bb yx' : \u03b2 \u00d7 \u03b1 => f yx'.1 yx'.2)\u2020 z\n      g\u2020 yx.1 + yx.2 := \nby \n  sorry\n\ntheorem adj_let_B {\u03b1 \u03b2 \u03b3 : Type} [Add \u03b1] (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2)\n  : (\u03bb x => \n      let y := g x\n      f y)\u2020\n    =\n    \u03bb z =>\n      let y := f\u2020 z\n      g\u2020 y := \nby \n  sorry\n\n@[simp \u2193]\ntheorem adj_prod_map (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) [Add \u03b1]\n  : (\u03bb x => (f x, g x))\u2020\n    =\n    \u03bb (y,z) => f\u2020 y + g\u2020 z := sorry\n\n@[simp \u2193]\ntheorem ajd_uncurry_add [Add \u03b1]\n  : (uncurry \u03bb x y : \u03b1 => x + y)\u2020\n    =\n    \u03bb 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 : \u03b1 \u2192 Bool) (as : Array \u03b1) : Array Nat :=\n  as |>.mapIdx (\u03bb i a => if p a then some i.1 else none) \n     |>.filterMap id\n\ndef _root_.Array.findRevIdx? {\u03b1 : Type} (as : Array \u03b1) (p : \u03b1 \u2192 Bool) : Option Nat :=\n  as.reverse.findIdx? p |>.map \u03bb 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\u00d7Expr)) := do\n  if let .some rule := getNameOfRuleI transName then\n    let proof \u2190 Meta.mkAppOptM rule #[X]\n    let rhs := (\u2190 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\u00d7Expr)) := do\n  if let .some rule := getNameOfRuleK transName then\n    let proof \u2190 Meta.mkAppM rule #[Y, x]\n    let rhs := (\u2190 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\u00d7Expr)) := do\n  if let .some rule := getNameOfRuleS transName then\n    let proof \u2190 Meta.mkAppM rule #[f,g]\n    let rhs := (\u2190 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\u00d7Expr)) := do\n  if let .some rule := getNameOfRuleB transName then\n    let proof \u2190 Meta.mkAppM rule #[f,g]\n    trace[Meta.Tactic.fun_trans.trans] s!\"case: B '{\u2190 Meta.ppExpr (\u2190 inferType proof)}'\"\n    let rhs := (\u2190 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\u00d7Expr)) := do\n  if let .some rule := getNameOfRuleC transName then\n    let proof \u2190 Meta.mkAppM rule #[f]\n    let rhs := (\u2190 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\u00d7Expr)) := do\n  if let .some rule := getNameOfRuleEval transName then\n    let proof \u2190 Meta.mkAppM rule #[Y, x]\n    let rhs := (\u2190 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\u00d7Expr)) := do\n  if let .some rule := getNameOfRuleLet transName then\n    let proof \u2190 Meta.mkAppM rule #[f, g]\n    let rhs := (\u2190 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\u00d7Expr)) := do\n  if let .some rule := getNameOfRuleLetB transName then\n    let proof \u2190 Meta.mkAppM rule #[f, g]\n    let rhs := (\u2190 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\u2080 x\u2081 .. x\u2099` where `T` is some function transformation?\n -/\ndef getFunctionTransform (e : Expr) : Option (Name \u00d7 Expr \u00d7 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 \u2192 Expr \u2192 MetaM \u03b1) : MetaM \u03b1 := \n  lambdaLetTelescope e \u03bb xs b => do\n    if let .some i \u2190 xs.findIdxM? (\u03bb x => do pure \u00ac(\u2190 x.fvarId!.isLetVar)) then\n      k xs[0:i] (\u2190 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 \u03bb as fVal => do\n    let a := as[0]!\n    let aId := a.fvarId!\n    if let .some aVal \u2190 aId.getValue? then\n      match aVal with\n      | .letE .. => letTelescope aVal \u03bb bs gVal => do\n        withLetDecl (\u2190 aId.getUserName) (\u2190 aId.getType) gVal \u03bb a' => do\n          let fVal \u2190 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 \u00d7 Expr)) := do\n  match f with \n  | .lam .. => lambdaLetTelescope f \u03bb xs b => do\n    trace[Meta.Tactic.fun_trans.trans] s!\"Transforming '{\u2190 Meta.ppExpr f}'\"\n    if h : xs.size > 0 then\n\n\n      if (xs.size \u2260 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 \u2190 yId.getValue? then\n\n          let g \u2190 mkLambdaFVars #[x] yVal\n          return \u2190 withLocalDecl\n            (\u2190 yId.getUserName) default (\u2190 yId.getType) \u03bb y' => do\n            let b' \u2190 mkLambdaFVars (xs[2:]) b\n\n            if b'.containsFVar xId then\n              let f \u2190 mkLambdaFVars #[y', x] (b'.replaceFVar y y')\n\n              trace[Meta.Tactic.fun_trans.trans] s!\"case: let 'f:{\u2190 Meta.ppExpr f}' 'g:{\u2190 Meta.ppExpr g}'\"\n              applyRuleLet transName f.eta g.eta\n            else\n              let f \u2190 mkLambdaFVars #[y'] (b'.replaceFVar y y')\n\n              trace[Meta.Tactic.fun_trans.trans] s!\"case: letB 'f:{\u2190 Meta.ppExpr f}' 'g:{\u2190 Meta.ppExpr g}'\"\n              applyRuleLetB transName f.eta g.eta\n        \n  \n        -- rule C: \u03bb x y => f y x\n        else \n          trace[Meta.Tactic.fun_trans.trans] s!\"case: C 'f:{\u2190 Meta.ppExpr f}'\"\n          let f \u2190 Meta.mkLambdaFVars (#[xs[1]!, xs[0]!].append xs[2:]) b\n          return \u2190 applyRuleC transName f.eta\n      else \n\n        let x := xs[0]\n        let xId := x.fvarId!\n\n        -- rule I: \u03bb x => x \n        if (b == x) then\n          trace[Meta.Tactic.fun_trans.trans] s!\"case: I '{\u2190 Meta.ppExpr f}'\"\n          return \u2190 applyRuleI transName (\u2190 inferType x)\n\n        -- rule K: \u03bb x => y\n        if \u00ac(b.containsFVar xId) then\n          trace[Meta.Tactic.fun_trans.trans] s!\"case: K '{\u2190 Meta.ppExpr f}'\" \n          return \u2190 applyRuleK transName b (\u2190 inferType x)\n\n        -- case: \u03bb 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:{\u2190 Meta.ppExpr F}' 'args:{\u2190 args.mapM Meta.ppExpr}'\"\n\n          if let some info \u2190 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 (\u03bb 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 \u2190 \n                (depArgs[0:depArgs.size-1]).foldrM (init:=depArgs[depArgs.size-1]!.1) \n                  (\u03bb y ys => mkAppOptM ``Prod.mk #[none, none, y.1,ys]) >>=\n                \u03bb g => mkLambdaFVars #[x] g\n\n              let Ys := depArgs.map \u03bb (arg, _) => (Name.anonymous, \u03bb _ => inferType arg)\n              let f \u2190 \n                withLocalDeclsD Ys \u03bb 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' \u2190 mkAppOptM' F (args'.map some)\n                  mkLambdaFVars ys b'\n                  -- mkAppM ``uncurry #[\u2190 mkLambdaFVars ys b']\n\n              if depArgs.size == 2 then\n                let f \u2190 mkAppM ``uncurry #[f]\n                trace[Meta.Tactic.fun_trans.trans] s!\"case: binary operation 'f:{\u2190 Meta.ppExpr f}' 'g:{\u2190 Meta.ppExpr g}'\"\n                return \u2190 applyRuleB transName f g\n              if depArgs.size == 3 then\n                let f \u2190 mkAppM ``uncurry3 #[f]\n                trace[Meta.Tactic.fun_trans.trans] s!\"case: ternary operation 'f:{\u2190 Meta.ppExpr f}' 'g:{\u2190 Meta.ppExpr g}'\"\n                return \u2190 applyRuleB transName f g\n              \n            \n          -- the first arguments with non-trivial occurence of `x`        \n          let id? := args.findIdx? (\u03bb 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 \u2190 inferType yVal\n            let g \u2190 mkLambdaFVars #[x] yVal\n            let f'proof : Option (Expr \u00d7 Expr) \u2190 \n              withLocalDecl `y .default yType \u03bb y => do\n              let fbody \u2190 mkAppOptM' F ((args.set! id y).map .some)\n              -- rule B: \u03bb x => f (g x)\n              if \u00ac(fbody.containsFVar xId) then\n                let f \u2190 mkLambdaFVars #[y] fbody\n                trace[Meta.Tactic.fun_trans.trans] s!\"case: B 'f:{\u2190 Meta.ppExpr f}' 'g:{\u2190 Meta.ppExpr g}'\"\n                return \u2190 applyRuleB transName f.eta g.eta\n  \n              -- rule S: \u03bb x => f x (g x)\n              else\n                let f \u2190 mkLambdaFVars #[y,x] fbody\n                trace[Meta.Tactic.fun_trans.trans] s!\"case: S 'f:{\u2190 Meta.ppExpr f}' 'g:{\u2190 Meta.ppExpr g}'\"\n                return \u2190 applyRuleS transName f.eta g.eta\n            return f'proof\n\n          \n          -- arguments containing `x`\n          let ids := args.filterIdx (\u03bb arg => arg.containsFVar xId)\n\n          -- case: \u03bb f => f x\u2080 .. x\u2099\n          if (ids.size == 0) && (F == x) then  \n            trace[Meta.Tactic.fun_trans.trans] s!\"case: \u03c0 '{\u2190 Meta.ppExpr f}'\"\n            let lastId  := args.size - 1\n            let lastArg := args[args.size - 1]!\n            let \u03b1type \u2190 inferType lastArg\n            let \u03b2type \u2190 inferType b\n            if args.size == 1 then\n              return \u2190 applyRuleEval transName lastArg \u03b2type \n            else\n              let g \u2190 mkLambdaFVars #[x] (\u2190 mkAppM' F args[0:lastId])\n              let f \u2190 withLocalDecl `F .default (\u2190 mkArrow \u03b1type \u03b2type) \u03bb F => do\n                mkLambdaFVars #[F] (\u2190 mkAppM' F #[lastArg])\n              return \u2190 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 {\u2190 Meta.ppExpr e}\"\n  else \n    trace[Meta.Tactic.fun_trans.step] s!\"Pre-step through {\u2190 Meta.ppExpr e}\"\n\n  if post then \n    if let .some e' \u2190 normalizeLetBindings e then\n      trace[Meta.Tactic.fun_trans.trans] s!\"Normalizing let binding from:\\n{\u2190 Meta.ppExpr e} \\n\\nto:\\n\\n{\u2190 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) \u2190 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'' \u2190 mkAppM' f' args\n        let proof' \u2190 mkAppM ``congr_fun #[proof, args[0]!]\n        return some (.visit (.mk f'' proof' 0))\n      else if args.size == 2 then\n        let f'' \u2190 mkAppM' f' args\n        let proof' \u2190 mkAppM ``congr_fun\u2082 #[proof, args[0]!, args[1]!]\n        return some (.visit (.mk f'' proof' 0))\n      else if args.size == 3 then\n        let f'' \u2190 mkAppM' f' args\n        let proof' \u2190 mkAppM ``congr_fun\u2083 #[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 (\u2190 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 \u21a6 do\n        Simp.andThen (\u2190 Simp.preDefault e discharge) tryFunTrans?\n      post := fun e \u21a6 do\n        Simp.andThen (\u2190 Simp.postDefault e discharge) (tryFunTrans? (post := true))\n      discharge? := discharge\n    } else {\n      pre := fun e \u21a6 Simp.andThen (.visit { expr := e }) tryFunTrans?\n      post := fun e \u21a6 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    (\u00b7.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 \u00d7 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 \u2190 fvarId.getDecl\n    let type \u2190 instantiateMVars localDecl.type\n    let ctx := { ctx with simpTheorems := ctx.simpTheorems.eraseTheorem (.fvar localDecl.fvarId) }\n    let r \u2190 deriveSimp ctx useSimp type\n    match r.proof? with\n    | some _ =>\n      let some (value, type) \u2190 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 (\u2190 mkFalseElim (\u2190 g.getType) (mkFVar fvarId))\n        return none\n      g \u2190 g.replaceLocalDeclDefEq fvarId r.expr\n      replaced := replaced.push fvarId\n  if simplifyTarget then\n    let res \u2190 g.withContext do\n      let target \u2190 instantiateMVars (\u2190 g.getType)\n      let r \u2190 deriveSimp ctx useSimp target\n      let some proof \u2190 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) \u2190 g.assertHypotheses toAssert\n  let toClear := fvarIdsToSimp.filter fun fvarId \u21a6 !replaced.contains fvarId\n  let gNew \u2190 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 \u2190\n    if simpOnly then simpOnlyBuiltins.foldlM (\u00b7.addConst \u00b7) {} else getSimpTheorems\n  let mut { ctx, starArg } \u2190 elabSimpArgs args (eraseLocal := false) (kind := .simp)\n    { simpTheorems := #[simpTheorems], congrTheorems := \u2190 getSimpCongrTheorems }\n  unless starArg do return ctx\n  let mut simpTheorems := ctx.simpTheorems\n  for h in \u2190 getPropHyps do\n    unless simpTheorems.isErased (.fvar h) do\n      simpTheorems \u2190 simpTheorems.addTheorem (.fvar h) (\u2190 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 \u2190 getSimpContext args (!useSimp || simpOnly)\n  let ctx := {ctx with config := {ctx.config with iota := true, zeta := false, singlePass := true}}\n  let g \u2190 getMainGoal\n  let res \u2190 match expandOptLocation loc with\n  | .targets hyps simplifyTarget => funTransAt g ctx (\u2190 getFVarIds hyps) simplifyTarget useSimp\n  | .wildcard => funTransAt g ctx (\u2190 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\u2080` to be a mixin typeclass a type with `has_inv` and\n`has_zero` (e.g., a `group_with_zero`) such that `\u03bb x, x\u207b\u00b9` is continuous at all nonzero points. Any\nnormed (semi)field has this property. Currently the only example of `has_continuous_inv\u2080` in\n`mathlib` which is not a normed field is the type `nnnreal` (a.k.a. `\u211d\u22650`) of nonnegative real\nnumbers.\n\nThen we prove lemmas about continuity of `x \u21a6 x\u207b\u00b9` 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 `(\u207b\u00b9)` 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\u2080` 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\u2080` 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 {\u03b1 \u03b2 G\u2080 : Type _}\n\nsection DivConst\n\nvariable [GroupWithZero G\u2080] [TopologicalSpace G\u2080] [ContinuousMul G\u2080] {f : \u03b1 \u2192 G\u2080} {s : Set \u03b1}\n  {l : Filter \u03b1}\n\n/- warning: filter.tendsto.div_const -> Filter.Tendsto.div_const is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {l : Filter.{u1} \u03b1} {x : G\u2080}, (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 f l (nhds.{u2} G\u2080 _inst_2 x)) -> (forall (y : G\u2080), Filter.Tendsto.{u1, u2} \u03b1 G\u2080 (fun (a : \u03b1) => HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) (f a) y) l (nhds.{u2} G\u2080 _inst_2 (HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) x y)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : ContinuousMul.{u1} G\u2080 _inst_2 (MulOneClass.toMul.{u1} G\u2080 (Monoid.toMulOneClass.{u1} G\u2080 (DivInvMonoid.toMonoid.{u1} G\u2080 _inst_1)))] {f : \u03b1 -> G\u2080} {l : Filter.{u2} \u03b1} {x : G\u2080}, (Filter.Tendsto.{u2, u1} \u03b1 G\u2080 f l (nhds.{u1} G\u2080 _inst_2 x)) -> (forall (y : G\u2080), Filter.Tendsto.{u2, u1} \u03b1 G\u2080 (fun (a : \u03b1) => HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toDiv.{u1} G\u2080 _inst_1)) (f a) y) l (nhds.{u1} G\u2080 _inst_2 (HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toDiv.{u1} G\u2080 _inst_1)) x y)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.div_const Filter.Tendsto.div_const\u2093'. -/\ntheorem Filter.Tendsto.div_const {x : G\u2080} (hf : Tendsto f l (\ud835\udcdd x)) (y : G\u2080) :\n    Tendsto (fun a => f a / y) l (\ud835\udcdd (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 \u03b1]\n\n/- warning: continuous_at.div_const -> ContinuousAt.div_const is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} [_inst_4 : TopologicalSpace.{u1} \u03b1] {a : \u03b1}, (ContinuousAt.{u1, u2} \u03b1 G\u2080 _inst_4 _inst_2 f a) -> (forall (y : G\u2080), ContinuousAt.{u1, u2} \u03b1 G\u2080 _inst_4 _inst_2 (fun (x : \u03b1) => HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) (f x) y) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : ContinuousMul.{u1} G\u2080 _inst_2 (MulOneClass.toMul.{u1} G\u2080 (Monoid.toMulOneClass.{u1} G\u2080 (DivInvMonoid.toMonoid.{u1} G\u2080 _inst_1)))] {f : \u03b1 -> G\u2080} [_inst_4 : TopologicalSpace.{u2} \u03b1] {a : \u03b1}, (ContinuousAt.{u2, u1} \u03b1 G\u2080 _inst_4 _inst_2 f a) -> (forall (y : G\u2080), ContinuousAt.{u2, u1} \u03b1 G\u2080 _inst_4 _inst_2 (fun (x : \u03b1) => HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toDiv.{u1} G\u2080 _inst_1)) (f x) y) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at.div_const ContinuousAt.div_const\u2093'. -/\ntheorem ContinuousAt.div_const {a : \u03b1} (hf : ContinuousAt f a) (y : G\u2080) :\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 {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {s : Set.{u1} \u03b1} [_inst_4 : TopologicalSpace.{u1} \u03b1] {a : \u03b1}, (ContinuousWithinAt.{u1, u2} \u03b1 G\u2080 _inst_4 _inst_2 f s a) -> (forall (y : G\u2080), ContinuousWithinAt.{u1, u2} \u03b1 G\u2080 _inst_4 _inst_2 (fun (x : \u03b1) => HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) (f x) y) s a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : ContinuousMul.{u1} G\u2080 _inst_2 (MulOneClass.toMul.{u1} G\u2080 (Monoid.toMulOneClass.{u1} G\u2080 (DivInvMonoid.toMonoid.{u1} G\u2080 _inst_1)))] {f : \u03b1 -> G\u2080} {s : Set.{u2} \u03b1} [_inst_4 : TopologicalSpace.{u2} \u03b1] {a : \u03b1}, (ContinuousWithinAt.{u2, u1} \u03b1 G\u2080 _inst_4 _inst_2 f s a) -> (forall (y : G\u2080), ContinuousWithinAt.{u2, u1} \u03b1 G\u2080 _inst_4 _inst_2 (fun (x : \u03b1) => HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toDiv.{u1} G\u2080 _inst_1)) (f x) y) s a)\nCase conversion may be inaccurate. Consider using '#align continuous_within_at.div_const ContinuousWithinAt.div_const\u2093'. -/\ntheorem ContinuousWithinAt.div_const {a} (hf : ContinuousWithinAt f s a) (y : G\u2080) :\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 {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {s : Set.{u1} \u03b1} [_inst_4 : TopologicalSpace.{u1} \u03b1], (ContinuousOn.{u1, u2} \u03b1 G\u2080 _inst_4 _inst_2 f s) -> (forall (y : G\u2080), ContinuousOn.{u1, u2} \u03b1 G\u2080 _inst_4 _inst_2 (fun (x : \u03b1) => HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) (f x) y) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : ContinuousMul.{u1} G\u2080 _inst_2 (MulOneClass.toMul.{u1} G\u2080 (Monoid.toMulOneClass.{u1} G\u2080 (DivInvMonoid.toMonoid.{u1} G\u2080 _inst_1)))] {f : \u03b1 -> G\u2080} {s : Set.{u2} \u03b1} [_inst_4 : TopologicalSpace.{u2} \u03b1], (ContinuousOn.{u2, u1} \u03b1 G\u2080 _inst_4 _inst_2 f s) -> (forall (y : G\u2080), ContinuousOn.{u2, u1} \u03b1 G\u2080 _inst_4 _inst_2 (fun (x : \u03b1) => HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toDiv.{u1} G\u2080 _inst_1)) (f x) y) s)\nCase conversion may be inaccurate. Consider using '#align continuous_on.div_const ContinuousOn.div_const\u2093'. -/\ntheorem ContinuousOn.div_const (hf : ContinuousOn f s) (y : G\u2080) :\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 {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} [_inst_4 : TopologicalSpace.{u1} \u03b1], (Continuous.{u1, u2} \u03b1 G\u2080 _inst_4 _inst_2 f) -> (forall (y : G\u2080), Continuous.{u1, u2} \u03b1 G\u2080 _inst_4 _inst_2 (fun (x : \u03b1) => HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) (f x) y))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : ContinuousMul.{u1} G\u2080 _inst_2 (MulOneClass.toMul.{u1} G\u2080 (Monoid.toMulOneClass.{u1} G\u2080 (DivInvMonoid.toMonoid.{u1} G\u2080 _inst_1)))] {f : \u03b1 -> G\u2080} [_inst_4 : TopologicalSpace.{u2} \u03b1], (Continuous.{u2, u1} \u03b1 G\u2080 _inst_4 _inst_2 f) -> (forall (y : G\u2080), Continuous.{u2, u1} \u03b1 G\u2080 _inst_4 _inst_2 (fun (x : \u03b1) => HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toDiv.{u1} G\u2080 _inst_1)) (f x) y))\nCase conversion may be inaccurate. Consider using '#align continuous.div_const Continuous.div_const\u2093'. -/\n@[continuity]\ntheorem Continuous.div_const (hf : Continuous f) (y : G\u2080) : 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\u2080 /-\n/-- A type with `0` and `has_inv` such that `\u03bb x, x\u207b\u00b9` is continuous at all nonzero points. Any\nnormed (semi)field has this property. -/\nclass HasContinuousInv\u2080 (G\u2080 : Type _) [Zero G\u2080] [Inv G\u2080] [TopologicalSpace G\u2080] : Prop where\n  continuousAt_inv\u2080 : \u2200 \u2983x : G\u2080\u2984, x \u2260 0 \u2192 ContinuousAt Inv.inv x\n#align has_continuous_inv\u2080 HasContinuousInv\u2080\n-/\n\nexport HasContinuousInv\u2080 (continuousAt_inv\u2080)\n\nsection Inv\u2080\n\nvariable [Zero G\u2080] [Inv G\u2080] [TopologicalSpace G\u2080] [HasContinuousInv\u2080 G\u2080] {l : Filter \u03b1} {f : \u03b1 \u2192 G\u2080}\n  {s : Set \u03b1} {a : \u03b1}\n\n/-!\n### Continuity of `\u03bb x, x\u207b\u00b9` at a non-zero point\n\nWe define `topological_group_with_zero` to be a `group_with_zero` such that the operation `x \u21a6 x\u207b\u00b9`\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\u2080 /-\ntheorem tendsto_inv\u2080 {x : G\u2080} (hx : x \u2260 0) : Tendsto Inv.inv (\ud835\udcdd x) (\ud835\udcdd x\u207b\u00b9) :=\n  continuousAt_inv\u2080 hx\n#align tendsto_inv\u2080 tendsto_inv\u2080\n-/\n\n/- warning: continuous_on_inv\u2080 -> continuousOn_inv\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_1 : Zero.{u1} G\u2080] [_inst_2 : Inv.{u1} G\u2080] [_inst_3 : TopologicalSpace.{u1} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u1} G\u2080 _inst_1 _inst_2 _inst_3], ContinuousOn.{u1, u1} G\u2080 G\u2080 _inst_3 _inst_3 (Inv.inv.{u1} G\u2080 _inst_2) (HasCompl.compl.{u1} (Set.{u1} G\u2080) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} G\u2080) (Set.booleanAlgebra.{u1} G\u2080)) (Singleton.singleton.{u1, u1} G\u2080 (Set.{u1} G\u2080) (Set.hasSingleton.{u1} G\u2080) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 _inst_1)))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : Zero.{u1} G\u2080] [_inst_2 : Inv.{u1} G\u2080] [_inst_3 : TopologicalSpace.{u1} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u1} G\u2080 _inst_1 _inst_2 _inst_3], ContinuousOn.{u1, u1} G\u2080 G\u2080 _inst_3 _inst_3 (Inv.inv.{u1} G\u2080 _inst_2) (HasCompl.compl.{u1} (Set.{u1} G\u2080) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} G\u2080) (Set.instBooleanAlgebraSet.{u1} G\u2080)) (Singleton.singleton.{u1, u1} G\u2080 (Set.{u1} G\u2080) (Set.instSingletonSet.{u1} G\u2080) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align continuous_on_inv\u2080 continuousOn_inv\u2080\u2093'. -/\ntheorem continuousOn_inv\u2080 : ContinuousOn (Inv.inv : G\u2080 \u2192 G\u2080) ({0}\u1d9c) := fun x hx =>\n  (continuousAt_inv\u2080 hx).ContinuousWithinAt\n#align continuous_on_inv\u2080 continuousOn_inv\u2080\n\n/- warning: filter.tendsto.inv\u2080 -> Filter.Tendsto.inv\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : Zero.{u2} G\u2080] [_inst_2 : Inv.{u2} G\u2080] [_inst_3 : TopologicalSpace.{u2} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u2} G\u2080 _inst_1 _inst_2 _inst_3] {l : Filter.{u1} \u03b1} {f : \u03b1 -> G\u2080} {a : G\u2080}, (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 f l (nhds.{u2} G\u2080 _inst_3 a)) -> (Ne.{succ u2} G\u2080 a (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 _inst_1)))) -> (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 (fun (x : \u03b1) => Inv.inv.{u2} G\u2080 _inst_2 (f x)) l (nhds.{u2} G\u2080 _inst_3 (Inv.inv.{u2} G\u2080 _inst_2 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : Zero.{u1} G\u2080] [_inst_2 : Inv.{u1} G\u2080] [_inst_3 : TopologicalSpace.{u1} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u1} G\u2080 _inst_1 _inst_2 _inst_3] {l : Filter.{u2} \u03b1} {f : \u03b1 -> G\u2080} {a : G\u2080}, (Filter.Tendsto.{u2, u1} \u03b1 G\u2080 f l (nhds.{u1} G\u2080 _inst_3 a)) -> (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 _inst_1))) -> (Filter.Tendsto.{u2, u1} \u03b1 G\u2080 (fun (x : \u03b1) => Inv.inv.{u1} G\u2080 _inst_2 (f x)) l (nhds.{u1} G\u2080 _inst_3 (Inv.inv.{u1} G\u2080 _inst_2 a)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.inv\u2080 Filter.Tendsto.inv\u2080\u2093'. -/\n/-- If a function converges to a nonzero value, its inverse converges to the inverse of this value.\nWe use the name `tendsto.inv\u2080` as `tendsto.inv` is already used in multiplicative topological\ngroups. -/\ntheorem Filter.Tendsto.inv\u2080 {a : G\u2080} (hf : Tendsto f l (\ud835\udcdd a)) (ha : a \u2260 0) :\n    Tendsto (fun x => (f x)\u207b\u00b9) l (\ud835\udcdd a\u207b\u00b9) :=\n  (tendsto_inv\u2080 ha).comp hf\n#align filter.tendsto.inv\u2080 Filter.Tendsto.inv\u2080\n\nvariable [TopologicalSpace \u03b1]\n\n/- warning: continuous_within_at.inv\u2080 -> ContinuousWithinAt.inv\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : Zero.{u2} G\u2080] [_inst_2 : Inv.{u2} G\u2080] [_inst_3 : TopologicalSpace.{u2} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u2} G\u2080 _inst_1 _inst_2 _inst_3] {f : \u03b1 -> G\u2080} {s : Set.{u1} \u03b1} {a : \u03b1} [_inst_5 : TopologicalSpace.{u1} \u03b1], (ContinuousWithinAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_3 f s a) -> (Ne.{succ u2} G\u2080 (f a) (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 _inst_1)))) -> (ContinuousWithinAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_3 (fun (x : \u03b1) => Inv.inv.{u2} G\u2080 _inst_2 (f x)) s a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : Zero.{u1} G\u2080] [_inst_2 : Inv.{u1} G\u2080] [_inst_3 : TopologicalSpace.{u1} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u1} G\u2080 _inst_1 _inst_2 _inst_3] {f : \u03b1 -> G\u2080} {s : Set.{u2} \u03b1} {a : \u03b1} [_inst_5 : TopologicalSpace.{u2} \u03b1], (ContinuousWithinAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_3 f s a) -> (Ne.{succ u1} G\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 _inst_1))) -> (ContinuousWithinAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_3 (fun (x : \u03b1) => Inv.inv.{u1} G\u2080 _inst_2 (f x)) s a)\nCase conversion may be inaccurate. Consider using '#align continuous_within_at.inv\u2080 ContinuousWithinAt.inv\u2080\u2093'. -/\ntheorem ContinuousWithinAt.inv\u2080 (hf : ContinuousWithinAt f s a) (ha : f a \u2260 0) :\n    ContinuousWithinAt (fun x => (f x)\u207b\u00b9) s a :=\n  hf.inv\u2080 ha\n#align continuous_within_at.inv\u2080 ContinuousWithinAt.inv\u2080\n\n/- warning: continuous_at.inv\u2080 -> ContinuousAt.inv\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : Zero.{u2} G\u2080] [_inst_2 : Inv.{u2} G\u2080] [_inst_3 : TopologicalSpace.{u2} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u2} G\u2080 _inst_1 _inst_2 _inst_3] {f : \u03b1 -> G\u2080} {a : \u03b1} [_inst_5 : TopologicalSpace.{u1} \u03b1], (ContinuousAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_3 f a) -> (Ne.{succ u2} G\u2080 (f a) (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 _inst_1)))) -> (ContinuousAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_3 (fun (x : \u03b1) => Inv.inv.{u2} G\u2080 _inst_2 (f x)) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : Zero.{u1} G\u2080] [_inst_2 : Inv.{u1} G\u2080] [_inst_3 : TopologicalSpace.{u1} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u1} G\u2080 _inst_1 _inst_2 _inst_3] {f : \u03b1 -> G\u2080} {a : \u03b1} [_inst_5 : TopologicalSpace.{u2} \u03b1], (ContinuousAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_3 f a) -> (Ne.{succ u1} G\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 _inst_1))) -> (ContinuousAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_3 (fun (x : \u03b1) => Inv.inv.{u1} G\u2080 _inst_2 (f x)) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at.inv\u2080 ContinuousAt.inv\u2080\u2093'. -/\ntheorem ContinuousAt.inv\u2080 (hf : ContinuousAt f a) (ha : f a \u2260 0) :\n    ContinuousAt (fun x => (f x)\u207b\u00b9) a :=\n  hf.inv\u2080 ha\n#align continuous_at.inv\u2080 ContinuousAt.inv\u2080\n\n/- warning: continuous.inv\u2080 -> Continuous.inv\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : Zero.{u2} G\u2080] [_inst_2 : Inv.{u2} G\u2080] [_inst_3 : TopologicalSpace.{u2} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u2} G\u2080 _inst_1 _inst_2 _inst_3] {f : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u1} \u03b1], (Continuous.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_3 f) -> (forall (x : \u03b1), Ne.{succ u2} G\u2080 (f x) (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 _inst_1)))) -> (Continuous.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_3 (fun (x : \u03b1) => Inv.inv.{u2} G\u2080 _inst_2 (f x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : Zero.{u1} G\u2080] [_inst_2 : Inv.{u1} G\u2080] [_inst_3 : TopologicalSpace.{u1} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u1} G\u2080 _inst_1 _inst_2 _inst_3] {f : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u2} \u03b1], (Continuous.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_3 f) -> (forall (x : \u03b1), Ne.{succ u1} G\u2080 (f x) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 _inst_1))) -> (Continuous.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_3 (fun (x : \u03b1) => Inv.inv.{u1} G\u2080 _inst_2 (f x)))\nCase conversion may be inaccurate. Consider using '#align continuous.inv\u2080 Continuous.inv\u2080\u2093'. -/\n@[continuity]\ntheorem Continuous.inv\u2080 (hf : Continuous f) (h0 : \u2200 x, f x \u2260 0) : Continuous fun x => (f x)\u207b\u00b9 :=\n  continuous_iff_continuousAt.2 fun x => (hf.Tendsto x).inv\u2080 (h0 x)\n#align continuous.inv\u2080 Continuous.inv\u2080\n\n/- warning: continuous_on.inv\u2080 -> ContinuousOn.inv\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : Zero.{u2} G\u2080] [_inst_2 : Inv.{u2} G\u2080] [_inst_3 : TopologicalSpace.{u2} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u2} G\u2080 _inst_1 _inst_2 _inst_3] {f : \u03b1 -> G\u2080} {s : Set.{u1} \u03b1} [_inst_5 : TopologicalSpace.{u1} \u03b1], (ContinuousOn.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_3 f s) -> (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (Ne.{succ u2} G\u2080 (f x) (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 _inst_1))))) -> (ContinuousOn.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_3 (fun (x : \u03b1) => Inv.inv.{u2} G\u2080 _inst_2 (f x)) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : Zero.{u1} G\u2080] [_inst_2 : Inv.{u1} G\u2080] [_inst_3 : TopologicalSpace.{u1} G\u2080] [_inst_4 : HasContinuousInv\u2080.{u1} G\u2080 _inst_1 _inst_2 _inst_3] {f : \u03b1 -> G\u2080} {s : Set.{u2} \u03b1} [_inst_5 : TopologicalSpace.{u2} \u03b1], (ContinuousOn.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_3 f s) -> (forall (x : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x s) -> (Ne.{succ u1} G\u2080 (f x) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 _inst_1)))) -> (ContinuousOn.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_3 (fun (x : \u03b1) => Inv.inv.{u1} G\u2080 _inst_2 (f x)) s)\nCase conversion may be inaccurate. Consider using '#align continuous_on.inv\u2080 ContinuousOn.inv\u2080\u2093'. -/\ntheorem ContinuousOn.inv\u2080 (hf : ContinuousOn f s) (h0 : \u2200 x \u2208 s, f x \u2260 0) :\n    ContinuousOn (fun x => (f x)\u207b\u00b9) s := fun x hx => (hf x hx).inv\u2080 (h0 x hx)\n#align continuous_on.inv\u2080 ContinuousOn.inv\u2080\n\nend Inv\u2080\n\n/- warning: units.embedding_coe\u2080 -> Units.embedding_val\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1)) _inst_2], Embedding.{u1, u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))) G\u2080 (Units.topologicalSpace.{u1} G\u2080 _inst_2 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))) _inst_2 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2], Embedding.{u1, u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))) G\u2080 (Units.instTopologicalSpaceUnits.{u1} G\u2080 _inst_2 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))) _inst_2 (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align units.embedding_coe\u2080 Units.embedding_val\u2080\u2093'. -/\n/-- If `G\u2080` is a group with zero with topology such that `x \u21a6 x\u207b\u00b9` is continuous at all nonzero\npoints. Then the coercion `M\u02e3 \u2192 M` is a topological embedding. -/\ntheorem Units.embedding_val\u2080 [GroupWithZero G\u2080] [TopologicalSpace G\u2080] [HasContinuousInv\u2080 G\u2080] :\n    Embedding (coe : G\u2080\u02e3 \u2192 G\u2080) :=\n  Units.embedding_val_mk <| continuousOn_inv\u2080.mono fun x => IsUnit.ne_zero\n#align units.embedding_coe\u2080 Units.embedding_val\u2080\n\n/-!\n### Continuity of division\n\nIf `G\u2080` is a `group_with_zero` with `x \u21a6 x\u207b\u00b9` 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\u2080] [TopologicalSpace G\u2080] [HasContinuousInv\u2080 G\u2080] [ContinuousMul G\u2080]\n  {f g : \u03b1 \u2192 G\u2080}\n\n/- warning: filter.tendsto.div -> Filter.Tendsto.div is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} {l : Filter.{u1} \u03b1} {a : G\u2080} {b : G\u2080}, (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 f l (nhds.{u2} G\u2080 _inst_2 a)) -> (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 g l (nhds.{u2} G\u2080 _inst_2 b)) -> (Ne.{succ u2} G\u2080 b (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))))))) -> (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u1 u2} (\u03b1 -> G\u2080) (Pi.instDiv.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)))) f g) l (nhds.{u2} G\u2080 _inst_2 (HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} {l : Filter.{u2} \u03b1} {a : G\u2080} {b : G\u2080}, (Filter.Tendsto.{u2, u1} \u03b1 G\u2080 f l (nhds.{u1} G\u2080 _inst_2 a)) -> (Filter.Tendsto.{u2, u1} \u03b1 G\u2080 g l (nhds.{u1} G\u2080 _inst_2 b)) -> (Ne.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) -> (Filter.Tendsto.{u2, u1} \u03b1 G\u2080 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u2 u1} (\u03b1 -> G\u2080) (Pi.instDiv.{u2, u1} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => GroupWithZero.toDiv.{u1} G\u2080 _inst_1))) f g) l (nhds.{u1} G\u2080 _inst_2 (HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (GroupWithZero.toDiv.{u1} G\u2080 _inst_1)) a b)))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.div Filter.Tendsto.div\u2093'. -/\ntheorem Filter.Tendsto.div {l : Filter \u03b1} {a b : G\u2080} (hf : Tendsto f l (\ud835\udcdd a))\n    (hg : Tendsto g l (\ud835\udcdd b)) (hy : b \u2260 0) : Tendsto (f / g) l (\ud835\udcdd (a / b)) := by\n  simpa only [div_eq_mul_inv] using hf.mul (hg.inv\u2080 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 {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] [_inst_5 : T1Space.{u2} G\u2080 _inst_2] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} {l : Filter.{u1} \u03b1} {x : G\u2080} {y : G\u2080}, (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 g l (nhds.{u2} G\u2080 _inst_2 y)) -> (Ne.{succ u2} G\u2080 y (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))))))) -> (Iff (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 (fun (n : \u03b1) => HMul.hMul.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHMul.{u2} G\u2080 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) (f n) (g n)) l (nhds.{u2} G\u2080 _inst_2 (HMul.hMul.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHMul.{u2} G\u2080 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) x y))) (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 f l (nhds.{u2} G\u2080 _inst_2 x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)) (GroupWithZero.toInv.{u2} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] [_inst_5 : T1Space.{u2} G\u2080 _inst_2] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} {l : Filter.{u1} \u03b1} {x : G\u2080} {y : G\u2080}, (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 g l (nhds.{u2} G\u2080 _inst_2 y)) -> (Ne.{succ u2} G\u2080 y (OfNat.ofNat.{u2} G\u2080 0 (Zero.toOfNat0.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) -> (Iff (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 (fun (n : \u03b1) => HMul.hMul.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHMul.{u2} G\u2080 (MulZeroClass.toMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) (f n) (g n)) l (nhds.{u2} G\u2080 _inst_2 (HMul.hMul.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHMul.{u2} G\u2080 (MulZeroClass.toMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) x y))) (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 f l (nhds.{u2} G\u2080 _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\u2093'. -/\ntheorem Filter.tendsto_mul_iff_of_ne_zero [T1Space G\u2080] {f g : \u03b1 \u2192 G\u2080} {l : Filter \u03b1} {x y : G\u2080}\n    (hg : Tendsto g l (\ud835\udcdd y)) (hy : y \u2260 0) :\n    Tendsto (fun n => f n * g n) l (\ud835\udcdd <| x * y) \u2194 Tendsto f l (\ud835\udcdd x) :=\n  by\n  refine' \u27e8fun hfg => _, fun hf => hf.mul hg\u27e9\n  rw [\u2190 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 \u03b1] [TopologicalSpace \u03b2] {s : Set \u03b1} {a : \u03b1}\n\n/- warning: continuous_within_at.div -> ContinuousWithinAt.div is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u1} \u03b1] {s : Set.{u1} \u03b1} {a : \u03b1}, (ContinuousWithinAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 f s a) -> (ContinuousWithinAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 g s a) -> (Ne.{succ u2} G\u2080 (g a) (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))))))) -> (ContinuousWithinAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u1 u2} (\u03b1 -> G\u2080) (Pi.instDiv.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)))) f g) s a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u2} \u03b1] {s : Set.{u2} \u03b1} {a : \u03b1}, (ContinuousWithinAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 f s a) -> (ContinuousWithinAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 g s a) -> (Ne.{succ u1} G\u2080 (g a) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) -> (ContinuousWithinAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u2 u1} (\u03b1 -> G\u2080) (Pi.instDiv.{u2, u1} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => GroupWithZero.toDiv.{u1} G\u2080 _inst_1))) f g) s a)\nCase conversion may be inaccurate. Consider using '#align continuous_within_at.div ContinuousWithinAt.div\u2093'. -/\ntheorem ContinuousWithinAt.div (hf : ContinuousWithinAt f s a) (hg : ContinuousWithinAt g s a)\n    (h\u2080 : g a \u2260 0) : ContinuousWithinAt (f / g) s a :=\n  hf.div hg h\u2080\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 {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u1} \u03b1] {s : Set.{u1} \u03b1}, (ContinuousOn.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 f s) -> (ContinuousOn.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 g s) -> (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (Ne.{succ u2} G\u2080 (g x) (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))))))) -> (ContinuousOn.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u1 u2} (\u03b1 -> G\u2080) (Pi.instDiv.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)))) f g) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u2} \u03b1] {s : Set.{u2} \u03b1}, (ContinuousOn.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 f s) -> (ContinuousOn.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 g s) -> (forall (x : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x s) -> (Ne.{succ u1} G\u2080 (g x) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))))) -> (ContinuousOn.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u2 u1} (\u03b1 -> G\u2080) (Pi.instDiv.{u2, u1} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => GroupWithZero.toDiv.{u1} G\u2080 _inst_1))) f g) s)\nCase conversion may be inaccurate. Consider using '#align continuous_on.div ContinuousOn.div\u2093'. -/\ntheorem ContinuousOn.div (hf : ContinuousOn f s) (hg : ContinuousOn g s) (h\u2080 : \u2200 x \u2208 s, g x \u2260 0) :\n    ContinuousOn (f / g) s := fun x hx => (hf x hx).div (hg x hx) (h\u2080 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 {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u1} \u03b1] {a : \u03b1}, (ContinuousAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 f a) -> (ContinuousAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 g a) -> (Ne.{succ u2} G\u2080 (g a) (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))))))) -> (ContinuousAt.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u1 u2} (\u03b1 -> G\u2080) (Pi.instDiv.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)))) f g) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u2} \u03b1] {a : \u03b1}, (ContinuousAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 f a) -> (ContinuousAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 g a) -> (Ne.{succ u1} G\u2080 (g a) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) -> (ContinuousAt.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u2 u1} (\u03b1 -> G\u2080) (Pi.instDiv.{u2, u1} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => GroupWithZero.toDiv.{u1} G\u2080 _inst_1))) f g) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at.div ContinuousAt.div\u2093'. -/\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\u2080 : g a \u2260 0) :\n    ContinuousAt (f / g) a :=\n  hf.div hg h\u2080\n#align continuous_at.div ContinuousAt.div\n\n/- warning: continuous.div -> Continuous.div is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u1} \u03b1], (Continuous.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 f) -> (Continuous.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 g) -> (forall (x : \u03b1), Ne.{succ u2} G\u2080 (g x) (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))))))) -> (Continuous.{u1, u2} \u03b1 G\u2080 _inst_5 _inst_2 (HDiv.hDiv.{max u1 u2, max u1 u2, max u1 u2} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u1 u2} (\u03b1 -> G\u2080) (Pi.instDiv.{u1, u2} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => DivInvMonoid.toHasDiv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)))) f g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} [_inst_5 : TopologicalSpace.{u2} \u03b1], (Continuous.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 f) -> (Continuous.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 g) -> (forall (x : \u03b1), Ne.{succ u1} G\u2080 (g x) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) -> (Continuous.{u2, u1} \u03b1 G\u2080 _inst_5 _inst_2 (HDiv.hDiv.{max u2 u1, max u2 u1, max u2 u1} (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (\u03b1 -> G\u2080) (instHDiv.{max u2 u1} (\u03b1 -> G\u2080) (Pi.instDiv.{u2, u1} \u03b1 (fun (\u1fb0 : \u03b1) => G\u2080) (fun (i : \u03b1) => GroupWithZero.toDiv.{u1} G\u2080 _inst_1))) f g))\nCase conversion may be inaccurate. Consider using '#align continuous.div Continuous.div\u2093'. -/\n@[continuity]\ntheorem Continuous.div (hf : Continuous f) (hg : Continuous g) (h\u2080 : \u2200 x, g x \u2260 0) :\n    Continuous (f / g) := by simpa only [div_eq_mul_inv] using hf.mul (hg.inv\u2080 h\u2080)\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\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))], ContinuousOn.{u1, u1} (Prod.{u1, u1} G\u2080 G\u2080) G\u2080 (Prod.topologicalSpace.{u1, u1} G\u2080 G\u2080 _inst_2 _inst_2) _inst_2 (fun (p : Prod.{u1, u1} G\u2080 G\u2080) => HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toHasDiv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (Prod.fst.{u1, u1} G\u2080 G\u2080 p) (Prod.snd.{u1, u1} G\u2080 G\u2080 p)) (setOf.{u1} (Prod.{u1, u1} G\u2080 G\u2080) (fun (p : Prod.{u1, u1} G\u2080 G\u2080) => Ne.{succ u1} G\u2080 (Prod.snd.{u1, u1} G\u2080 G\u2080 p) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))], ContinuousOn.{u1, u1} (Prod.{u1, u1} G\u2080 G\u2080) G\u2080 (instTopologicalSpaceProd.{u1, u1} G\u2080 G\u2080 _inst_2 _inst_2) _inst_2 (fun (p : Prod.{u1, u1} G\u2080 G\u2080) => HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (GroupWithZero.toDiv.{u1} G\u2080 _inst_1)) (Prod.fst.{u1, u1} G\u2080 G\u2080 p) (Prod.snd.{u1, u1} G\u2080 G\u2080 p)) (setOf.{u1} (Prod.{u1, u1} G\u2080 G\u2080) (fun (p : Prod.{u1, u1} G\u2080 G\u2080) => Ne.{succ u1} G\u2080 (Prod.snd.{u1, u1} G\u2080 G\u2080 p) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align continuous_on_div continuousOn_div\u2093'. -/\ntheorem continuousOn_div : ContinuousOn (fun p : G\u2080 \u00d7 G\u2080 => p.1 / p.2) { p | p.2 \u2260 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {G\u2080 : Type.{u3}} [_inst_1 : GroupWithZero.{u3} G\u2080] [_inst_2 : TopologicalSpace.{u3} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u3} G\u2080 (MulZeroClass.toHasZero.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u3} G\u2080 (GroupWithZero.toDivInvMonoid.{u3} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u3} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1))))] [_inst_5 : TopologicalSpace.{u1} \u03b1] [_inst_6 : TopologicalSpace.{u2} \u03b2] {a : \u03b1} {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} (h : \u03b1 -> G\u2080 -> \u03b2), (ContinuousAt.{u1, u3} \u03b1 G\u2080 _inst_5 _inst_2 f a) -> (ContinuousAt.{u1, u3} \u03b1 G\u2080 _inst_5 _inst_2 g a) -> ((Ne.{succ u3} G\u2080 (g a) (OfNat.ofNat.{u3} G\u2080 0 (OfNat.mk.{u3} G\u2080 0 (Zero.zero.{u3} G\u2080 (MulZeroClass.toHasZero.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1)))))))) -> (ContinuousAt.{max u1 u3, u2} (Prod.{u1, u3} \u03b1 G\u2080) \u03b2 (Prod.topologicalSpace.{u1, u3} \u03b1 G\u2080 _inst_5 _inst_2) _inst_6 (Function.HasUncurry.uncurry.{max u1 u3 u2, max u1 u3, u2} (\u03b1 -> G\u2080 -> \u03b2) (Prod.{u1, u3} \u03b1 G\u2080) \u03b2 (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} \u03b1 (G\u2080 -> \u03b2) G\u2080 \u03b2 (Function.hasUncurryBase.{u3, u2} G\u2080 \u03b2)) h) (Prod.mk.{u1, u3} \u03b1 G\u2080 a (HDiv.hDiv.{u3, u3, u3} G\u2080 G\u2080 G\u2080 (instHDiv.{u3} G\u2080 (DivInvMonoid.toHasDiv.{u3} G\u2080 (GroupWithZero.toDivInvMonoid.{u3} G\u2080 _inst_1))) (f a) (g a))))) -> ((Eq.{succ u3} G\u2080 (g a) (OfNat.ofNat.{u3} G\u2080 0 (OfNat.mk.{u3} G\u2080 0 (Zero.zero.{u3} G\u2080 (MulZeroClass.toHasZero.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1)))))))) -> (Filter.Tendsto.{max u1 u3, u2} (Prod.{u1, u3} \u03b1 G\u2080) \u03b2 (Function.HasUncurry.uncurry.{max u1 u3 u2, max u1 u3, u2} (\u03b1 -> G\u2080 -> \u03b2) (Prod.{u1, u3} \u03b1 G\u2080) \u03b2 (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} \u03b1 (G\u2080 -> \u03b2) G\u2080 \u03b2 (Function.hasUncurryBase.{u3, u2} G\u2080 \u03b2)) h) (Filter.prod.{u1, u3} \u03b1 G\u2080 (nhds.{u1} \u03b1 _inst_5 a) (Top.top.{u3} (Filter.{u3} G\u2080) (Filter.hasTop.{u3} G\u2080))) (nhds.{u2} \u03b2 _inst_6 (h a (OfNat.ofNat.{u3} G\u2080 0 (OfNat.mk.{u3} G\u2080 0 (Zero.zero.{u3} G\u2080 (MulZeroClass.toHasZero.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1))))))))))) -> (ContinuousAt.{u1, u2} \u03b1 \u03b2 _inst_5 _inst_6 (fun (x : \u03b1) => h x (HDiv.hDiv.{u3, u3, u3} G\u2080 G\u2080 G\u2080 (instHDiv.{u3} G\u2080 (DivInvMonoid.toHasDiv.{u3} G\u2080 (GroupWithZero.toDivInvMonoid.{u3} G\u2080 _inst_1))) (f x) (g x))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)) (GroupWithZero.toInv.{u2} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] [_inst_5 : TopologicalSpace.{u3} \u03b1] [_inst_6 : TopologicalSpace.{u1} \u03b2] {a : \u03b1} {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} (h : \u03b1 -> G\u2080 -> \u03b2), (ContinuousAt.{u3, u2} \u03b1 G\u2080 _inst_5 _inst_2 f a) -> (ContinuousAt.{u3, u2} \u03b1 G\u2080 _inst_5 _inst_2 g a) -> ((Ne.{succ u2} G\u2080 (g a) (OfNat.ofNat.{u2} G\u2080 0 (Zero.toOfNat0.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) -> (ContinuousAt.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 G\u2080) \u03b2 (instTopologicalSpaceProd.{u3, u2} \u03b1 G\u2080 _inst_5 _inst_2) _inst_6 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (\u03b1 -> G\u2080 -> \u03b2) (Prod.{u3, u2} \u03b1 G\u2080) \u03b2 (Function.hasUncurryInduction.{u3, max u1 u2, u2, u1} \u03b1 (G\u2080 -> \u03b2) G\u2080 \u03b2 (Function.hasUncurryBase.{u2, u1} G\u2080 \u03b2)) h) (Prod.mk.{u3, u2} \u03b1 G\u2080 a (HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (GroupWithZero.toDiv.{u2} G\u2080 _inst_1)) (f a) (g a))))) -> ((Eq.{succ u2} G\u2080 (g a) (OfNat.ofNat.{u2} G\u2080 0 (Zero.toOfNat0.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) -> (Filter.Tendsto.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 G\u2080) \u03b2 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (\u03b1 -> G\u2080 -> \u03b2) (Prod.{u3, u2} \u03b1 G\u2080) \u03b2 (Function.hasUncurryInduction.{u3, max u1 u2, u2, u1} \u03b1 (G\u2080 -> \u03b2) G\u2080 \u03b2 (Function.hasUncurryBase.{u2, u1} G\u2080 \u03b2)) h) (Filter.prod.{u3, u2} \u03b1 G\u2080 (nhds.{u3} \u03b1 _inst_5 a) (Top.top.{u2} (Filter.{u2} G\u2080) (Filter.instTopFilter.{u2} G\u2080))) (nhds.{u1} \u03b2 _inst_6 (h a (OfNat.ofNat.{u2} G\u2080 0 (Zero.toOfNat0.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))))))) -> (ContinuousAt.{u3, u1} \u03b1 \u03b2 _inst_5 _inst_6 (fun (x : \u03b1) => h x (HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (GroupWithZero.toDiv.{u2} G\u2080 _inst_1)) (f x) (g x))) a)\nCase conversion may be inaccurate. Consider using '#align continuous_at.comp_div_cases ContinuousAt.comp_div_cases\u2093'. -/\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 `\u22a4` 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 : \u03b1 \u2192 G\u2080} (h : \u03b1 \u2192 G\u2080 \u2192 \u03b2) (hf : ContinuousAt f a)\n    (hg : ContinuousAt g a) (hh : g a \u2260 0 \u2192 ContinuousAt (\u21bfh) (a, f a / g a))\n    (h2h : g a = 0 \u2192 Tendsto (\u21bfh) (\ud835\udcdd a \u00d7\u1da0 \u22a4) (\ud835\udcdd (h a 0))) :\n    ContinuousAt (fun x => h x (f x / g x)) a :=\n  by\n  show ContinuousAt (\u21bfh \u2218 fun x => (x, f x / g x)) a\n  by_cases hga : g a = 0\n  \u00b7 rw [ContinuousAt]\n    simp_rw [comp_app, hga, div_zero]\n    exact (h2h hga).comp (continuous_at_id.prod_mk tendsto_top)\n  \u00b7 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {G\u2080 : Type.{u3}} [_inst_1 : GroupWithZero.{u3} G\u2080] [_inst_2 : TopologicalSpace.{u3} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u3} G\u2080 (MulZeroClass.toHasZero.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u3} G\u2080 (GroupWithZero.toDivInvMonoid.{u3} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u3} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1))))] [_inst_5 : TopologicalSpace.{u1} \u03b1] [_inst_6 : TopologicalSpace.{u2} \u03b2] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} (h : \u03b1 -> G\u2080 -> \u03b2), (Continuous.{u1, u3} \u03b1 G\u2080 _inst_5 _inst_2 f) -> (Continuous.{u1, u3} \u03b1 G\u2080 _inst_5 _inst_2 g) -> (forall (a : \u03b1), (Ne.{succ u3} G\u2080 (g a) (OfNat.ofNat.{u3} G\u2080 0 (OfNat.mk.{u3} G\u2080 0 (Zero.zero.{u3} G\u2080 (MulZeroClass.toHasZero.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1)))))))) -> (ContinuousAt.{max u1 u3, u2} (Prod.{u1, u3} \u03b1 G\u2080) \u03b2 (Prod.topologicalSpace.{u1, u3} \u03b1 G\u2080 _inst_5 _inst_2) _inst_6 (Function.HasUncurry.uncurry.{max u1 u3 u2, max u1 u3, u2} (\u03b1 -> G\u2080 -> \u03b2) (Prod.{u1, u3} \u03b1 G\u2080) \u03b2 (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} \u03b1 (G\u2080 -> \u03b2) G\u2080 \u03b2 (Function.hasUncurryBase.{u3, u2} G\u2080 \u03b2)) h) (Prod.mk.{u1, u3} \u03b1 G\u2080 a (HDiv.hDiv.{u3, u3, u3} G\u2080 G\u2080 G\u2080 (instHDiv.{u3} G\u2080 (DivInvMonoid.toHasDiv.{u3} G\u2080 (GroupWithZero.toDivInvMonoid.{u3} G\u2080 _inst_1))) (f a) (g a))))) -> (forall (a : \u03b1), (Eq.{succ u3} G\u2080 (g a) (OfNat.ofNat.{u3} G\u2080 0 (OfNat.mk.{u3} G\u2080 0 (Zero.zero.{u3} G\u2080 (MulZeroClass.toHasZero.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1)))))))) -> (Filter.Tendsto.{max u1 u3, u2} (Prod.{u1, u3} \u03b1 G\u2080) \u03b2 (Function.HasUncurry.uncurry.{max u1 u3 u2, max u1 u3, u2} (\u03b1 -> G\u2080 -> \u03b2) (Prod.{u1, u3} \u03b1 G\u2080) \u03b2 (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} \u03b1 (G\u2080 -> \u03b2) G\u2080 \u03b2 (Function.hasUncurryBase.{u3, u2} G\u2080 \u03b2)) h) (Filter.prod.{u1, u3} \u03b1 G\u2080 (nhds.{u1} \u03b1 _inst_5 a) (Top.top.{u3} (Filter.{u3} G\u2080) (Filter.hasTop.{u3} G\u2080))) (nhds.{u2} \u03b2 _inst_6 (h a (OfNat.ofNat.{u3} G\u2080 0 (OfNat.mk.{u3} G\u2080 0 (Zero.zero.{u3} G\u2080 (MulZeroClass.toHasZero.{u3} G\u2080 (MulZeroOneClass.toMulZeroClass.{u3} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u3} G\u2080 (GroupWithZero.toMonoidWithZero.{u3} G\u2080 _inst_1))))))))))) -> (Continuous.{u1, u2} \u03b1 \u03b2 _inst_5 _inst_6 (fun (x : \u03b1) => h x (HDiv.hDiv.{u3, u3, u3} G\u2080 G\u2080 G\u2080 (instHDiv.{u3} G\u2080 (DivInvMonoid.toHasDiv.{u3} G\u2080 (GroupWithZero.toDivInvMonoid.{u3} G\u2080 _inst_1))) (f x) (g x))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)) (GroupWithZero.toInv.{u2} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] [_inst_5 : TopologicalSpace.{u3} \u03b1] [_inst_6 : TopologicalSpace.{u1} \u03b2] {f : \u03b1 -> G\u2080} {g : \u03b1 -> G\u2080} (h : \u03b1 -> G\u2080 -> \u03b2), (Continuous.{u3, u2} \u03b1 G\u2080 _inst_5 _inst_2 f) -> (Continuous.{u3, u2} \u03b1 G\u2080 _inst_5 _inst_2 g) -> (forall (a : \u03b1), (Ne.{succ u2} G\u2080 (g a) (OfNat.ofNat.{u2} G\u2080 0 (Zero.toOfNat0.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) -> (ContinuousAt.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 G\u2080) \u03b2 (instTopologicalSpaceProd.{u3, u2} \u03b1 G\u2080 _inst_5 _inst_2) _inst_6 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (\u03b1 -> G\u2080 -> \u03b2) (Prod.{u3, u2} \u03b1 G\u2080) \u03b2 (Function.hasUncurryInduction.{u3, max u1 u2, u2, u1} \u03b1 (G\u2080 -> \u03b2) G\u2080 \u03b2 (Function.hasUncurryBase.{u2, u1} G\u2080 \u03b2)) h) (Prod.mk.{u3, u2} \u03b1 G\u2080 a (HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (GroupWithZero.toDiv.{u2} G\u2080 _inst_1)) (f a) (g a))))) -> (forall (a : \u03b1), (Eq.{succ u2} G\u2080 (g a) (OfNat.ofNat.{u2} G\u2080 0 (Zero.toOfNat0.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))) -> (Filter.Tendsto.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 G\u2080) \u03b2 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (\u03b1 -> G\u2080 -> \u03b2) (Prod.{u3, u2} \u03b1 G\u2080) \u03b2 (Function.hasUncurryInduction.{u3, max u1 u2, u2, u1} \u03b1 (G\u2080 -> \u03b2) G\u2080 \u03b2 (Function.hasUncurryBase.{u2, u1} G\u2080 \u03b2)) h) (Filter.prod.{u3, u2} \u03b1 G\u2080 (nhds.{u3} \u03b1 _inst_5 a) (Top.top.{u2} (Filter.{u2} G\u2080) (Filter.instTopFilter.{u2} G\u2080))) (nhds.{u1} \u03b2 _inst_6 (h a (OfNat.ofNat.{u2} G\u2080 0 (Zero.toOfNat0.{u2} G\u2080 (MonoidWithZero.toZero.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))))))) -> (Continuous.{u3, u1} \u03b1 \u03b2 _inst_5 _inst_6 (fun (x : \u03b1) => h x (HDiv.hDiv.{u2, u2, u2} G\u2080 G\u2080 G\u2080 (instHDiv.{u2} G\u2080 (GroupWithZero.toDiv.{u2} G\u2080 _inst_1)) (f x) (g x))))\nCase conversion may be inaccurate. Consider using '#align continuous.comp_div_cases Continuous.comp_div_cases\u2093'. -/\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 : \u03b1 \u2192 G\u2080} (h : \u03b1 \u2192 G\u2080 \u2192 \u03b2) (hf : Continuous f)\n    (hg : Continuous g) (hh : \u2200 a, g a \u2260 0 \u2192 ContinuousAt (\u21bfh) (a, f a / g a))\n    (h2h : \u2200 a, g a = 0 \u2192 Tendsto (\u21bfh) (\ud835\udcdd a \u00d7\u1da0 \u22a4) (\ud835\udcdd (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 \u03b1] [GroupWithZero \u03b1] [ContinuousMul \u03b1]\n\n/- warning: homeomorph.mul_left\u2080 -> Homeomorph.mulLeft\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1), (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2)))))))) -> (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1), (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) -> (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align homeomorph.mul_left\u2080 Homeomorph.mulLeft\u2080\u2093'. -/\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\u2080 (c : \u03b1) (hc : c \u2260 0) : \u03b1 \u2243\u209c \u03b1 :=\n  { Equiv.mulLeft\u2080 c hc with\n    continuous_toFun := continuous_mul_left _\n    continuous_invFun := continuous_mul_left _ }\n#align homeomorph.mul_left\u2080 Homeomorph.mulLeft\u2080\n\n/- warning: homeomorph.mul_right\u2080 -> Homeomorph.mulRight\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1), (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2)))))))) -> (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1), (Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) -> (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align homeomorph.mul_right\u2080 Homeomorph.mulRight\u2080\u2093'. -/\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\u2080 (c : \u03b1) (hc : c \u2260 0) : \u03b1 \u2243\u209c \u03b1 :=\n  { Equiv.mulRight\u2080 c hc with\n    continuous_toFun := continuous_mul_right _\n    continuous_invFun := continuous_mul_right _ }\n#align homeomorph.mul_right\u2080 Homeomorph.mulRight\u2080\n\n/- warning: homeomorph.coe_mul_left\u2080 -> Homeomorph.coe_mulLeft\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1) (hc : Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2)))))))), Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (Homeomorph.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (Homeomorph.mulLeft\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) c)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1) (hc : Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))), Eq.{succ u1} (\u03b1 -> \u03b1) (FunLike.coe.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => \u03b1) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Homeomorph.instEquivLikeHomeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1))) (Homeomorph.mulLeft\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc)) (fun (x._@.Mathlib.Topology.Algebra.GroupWithZero._hyg.2184 : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) c x._@.Mathlib.Topology.Algebra.GroupWithZero._hyg.2184)\nCase conversion may be inaccurate. Consider using '#align homeomorph.coe_mul_left\u2080 Homeomorph.coe_mulLeft\u2080\u2093'. -/\n@[simp]\ntheorem coe_mulLeft\u2080 (c : \u03b1) (hc : c \u2260 0) : \u21d1(Homeomorph.mulLeft\u2080 c hc) = (\u00b7 * \u00b7) c :=\n  rfl\n#align homeomorph.coe_mul_left\u2080 Homeomorph.coe_mulLeft\u2080\n\n/- warning: homeomorph.mul_left\u2080_symm_apply -> Homeomorph.mulLeft\u2080_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1) (hc : Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2)))))))), Eq.{succ u1} ((fun (_x : Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (Homeomorph.symm.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (Homeomorph.mulLeft\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc))) (coeFn.{succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (Homeomorph.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (Homeomorph.symm.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (Homeomorph.mulLeft\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _inst_2)) c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1) (hc : Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))), Eq.{succ u1} (\u03b1 -> \u03b1) (FunLike.coe.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => \u03b1) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Homeomorph.instEquivLikeHomeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1))) (Homeomorph.symm.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (Homeomorph.mulLeft\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc))) (fun (x._@.Mathlib.Topology.Algebra.GroupWithZero._hyg.2233 : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) (Inv.inv.{u1} \u03b1 (GroupWithZero.toInv.{u1} \u03b1 _inst_2) c) x._@.Mathlib.Topology.Algebra.GroupWithZero._hyg.2233)\nCase conversion may be inaccurate. Consider using '#align homeomorph.mul_left\u2080_symm_apply Homeomorph.mulLeft\u2080_symm_apply\u2093'. -/\n@[simp]\ntheorem mulLeft\u2080_symm_apply (c : \u03b1) (hc : c \u2260 0) :\n    ((Homeomorph.mulLeft\u2080 c hc).symm : \u03b1 \u2192 \u03b1) = (\u00b7 * \u00b7) c\u207b\u00b9 :=\n  rfl\n#align homeomorph.mul_left\u2080_symm_apply Homeomorph.mulLeft\u2080_symm_apply\n\n/- warning: homeomorph.coe_mul_right\u2080 -> Homeomorph.coe_mulRight\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1) (hc : Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2)))))))), Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (Homeomorph.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (Homeomorph.mulRight\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc)) (fun (x : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) x c)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1) (hc : Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))), Eq.{succ u1} (\u03b1 -> \u03b1) (FunLike.coe.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => \u03b1) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Homeomorph.instEquivLikeHomeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1))) (Homeomorph.mulRight\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc)) (fun (x : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) x c)\nCase conversion may be inaccurate. Consider using '#align homeomorph.coe_mul_right\u2080 Homeomorph.coe_mulRight\u2080\u2093'. -/\n@[simp]\ntheorem coe_mulRight\u2080 (c : \u03b1) (hc : c \u2260 0) : \u21d1(Homeomorph.mulRight\u2080 c hc) = fun x => x * c :=\n  rfl\n#align homeomorph.coe_mul_right\u2080 Homeomorph.coe_mulRight\u2080\n\n/- warning: homeomorph.mul_right\u2080_symm_apply -> Homeomorph.mulRight\u2080_symm_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1) (hc : Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2)))))))), Eq.{succ u1} ((fun (_x : Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (Homeomorph.symm.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (Homeomorph.mulRight\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc))) (coeFn.{succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (fun (_x : Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) => \u03b1 -> \u03b1) (Homeomorph.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (Homeomorph.symm.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (Homeomorph.mulRight\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc))) (fun (x : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toHasMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) x (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 _inst_2)) c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : TopologicalSpace.{u1} \u03b1] [_inst_2 : GroupWithZero.{u1} \u03b1] [_inst_3 : ContinuousMul.{u1} \u03b1 _inst_1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))] (c : \u03b1) (hc : Ne.{succ u1} \u03b1 c (OfNat.ofNat.{u1} \u03b1 0 (Zero.toOfNat0.{u1} \u03b1 (MonoidWithZero.toZero.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))), Eq.{succ u1} (\u03b1 -> \u03b1) (FunLike.coe.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 (fun (_x : \u03b1) => \u03b1) (EmbeddingLike.toFunLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (EquivLike.toEmbeddingLike.{succ u1, succ u1, succ u1} (Homeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) \u03b1 \u03b1 (Homeomorph.instEquivLikeHomeomorph.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1))) (Homeomorph.symm.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 (Homeomorph.mulRight\u2080.{u1} \u03b1 _inst_1 _inst_2 _inst_3 c hc))) (fun (x : \u03b1) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulZeroClass.toMul.{u1} \u03b1 (MulZeroOneClass.toMulZeroClass.{u1} \u03b1 (MonoidWithZero.toMulZeroOneClass.{u1} \u03b1 (GroupWithZero.toMonoidWithZero.{u1} \u03b1 _inst_2))))) x (Inv.inv.{u1} \u03b1 (GroupWithZero.toInv.{u1} \u03b1 _inst_2) c))\nCase conversion may be inaccurate. Consider using '#align homeomorph.mul_right\u2080_symm_apply Homeomorph.mulRight\u2080_symm_apply\u2093'. -/\n@[simp]\ntheorem mulRight\u2080_symm_apply (c : \u03b1) (hc : c \u2260 0) :\n    ((Homeomorph.mulRight\u2080 c hc).symm : \u03b1 \u2192 \u03b1) = fun x => x * c\u207b\u00b9 :=\n  rfl\n#align homeomorph.mul_right\u2080_symm_apply Homeomorph.mulRight\u2080_symm_apply\n\nend Homeomorph\n\nsection Zpow\n\nvariable [GroupWithZero G\u2080] [TopologicalSpace G\u2080] [HasContinuousInv\u2080 G\u2080] [ContinuousMul G\u2080]\n\n/- warning: continuous_at_zpow\u2080 -> continuousAt_zpow\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] (x : G\u2080) (m : Int), (Or (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _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\u2080 G\u2080 _inst_2 _inst_2 (fun (x : G\u2080) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) x m) x)\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] (x : G\u2080) (m : Int), (Or (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (ContinuousAt.{u1, u1} G\u2080 G\u2080 _inst_2 _inst_2 (fun (x : G\u2080) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) x m) x)\nCase conversion may be inaccurate. Consider using '#align continuous_at_zpow\u2080 continuousAt_zpow\u2080\u2093'. -/\ntheorem continuousAt_zpow\u2080 (x : G\u2080) (m : \u2124) (h : x \u2260 0 \u2228 0 \u2264 m) : ContinuousAt (fun x => x ^ m) x :=\n  by\n  cases m\n  \u00b7 simpa only [zpow_ofNat] using continuousAt_pow x m\n  \u00b7 simp only [zpow_negSucc]\n    have hx : x \u2260 0 := h.resolve_right (Int.negSucc_lt_zero m).not_le\n    exact (continuousAt_pow x (m + 1)).inv\u2080 (pow_ne_zero _ hx)\n#align continuous_at_zpow\u2080 continuousAt_zpow\u2080\n\n/- warning: continuous_on_zpow\u2080 -> continuousOn_zpow\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] (m : Int), ContinuousOn.{u1, u1} G\u2080 G\u2080 _inst_2 _inst_2 (fun (x : G\u2080) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) x m) (HasCompl.compl.{u1} (Set.{u1} G\u2080) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} G\u2080) (Set.booleanAlgebra.{u1} G\u2080)) (Singleton.singleton.{u1, u1} G\u2080 (Set.{u1} G\u2080) (Set.hasSingleton.{u1} G\u2080) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] (m : Int), ContinuousOn.{u1, u1} G\u2080 G\u2080 _inst_2 _inst_2 (fun (x : G\u2080) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) x m) (HasCompl.compl.{u1} (Set.{u1} G\u2080) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} G\u2080) (Set.instBooleanAlgebraSet.{u1} G\u2080)) (Singleton.singleton.{u1, u1} G\u2080 (Set.{u1} G\u2080) (Set.instSingletonSet.{u1} G\u2080) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))))\nCase conversion may be inaccurate. Consider using '#align continuous_on_zpow\u2080 continuousOn_zpow\u2080\u2093'. -/\ntheorem continuousOn_zpow\u2080 (m : \u2124) : ContinuousOn (fun x : G\u2080 => x ^ m) ({0}\u1d9c) := fun x hx =>\n  (continuousAt_zpow\u2080 _ _ (Or.inl hx)).ContinuousWithinAt\n#align continuous_on_zpow\u2080 continuousOn_zpow\u2080\n\n/- warning: filter.tendsto.zpow\u2080 -> Filter.Tendsto.zpow\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {G\u2080 : Type.{u2}} [_inst_1 : GroupWithZero.{u2} G\u2080] [_inst_2 : TopologicalSpace.{u2} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u2} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {l : Filter.{u1} \u03b1} {a : G\u2080}, (Filter.Tendsto.{u1, u2} \u03b1 G\u2080 f l (nhds.{u2} G\u2080 _inst_2 a)) -> (forall (m : Int), (Or (Ne.{succ u2} G\u2080 a (OfNat.ofNat.{u2} G\u2080 0 (OfNat.mk.{u2} G\u2080 0 (Zero.zero.{u2} G\u2080 (MulZeroClass.toHasZero.{u2} G\u2080 (MulZeroOneClass.toMulZeroClass.{u2} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u2} G\u2080 (GroupWithZero.toMonoidWithZero.{u2} G\u2080 _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} \u03b1 G\u2080 (fun (x : \u03b1) => HPow.hPow.{u2, 0, u2} G\u2080 Int G\u2080 (instHPow.{u2, 0} G\u2080 Int (DivInvMonoid.Pow.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) (f x) m) l (nhds.{u2} G\u2080 _inst_2 (HPow.hPow.{u2, 0, u2} G\u2080 Int G\u2080 (instHPow.{u2, 0} G\u2080 Int (DivInvMonoid.Pow.{u2} G\u2080 (GroupWithZero.toDivInvMonoid.{u2} G\u2080 _inst_1))) a m))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {f : \u03b1 -> G\u2080} {l : Filter.{u2} \u03b1} {a : G\u2080}, (Filter.Tendsto.{u2, u1} \u03b1 G\u2080 f l (nhds.{u1} G\u2080 _inst_2 a)) -> (forall (m : Int), (Or (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (Filter.Tendsto.{u2, u1} \u03b1 G\u2080 (fun (x : \u03b1) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m) l (nhds.{u1} G\u2080 _inst_2 (HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) a m))))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.zpow\u2080 Filter.Tendsto.zpow\u2080\u2093'. -/\ntheorem Filter.Tendsto.zpow\u2080 {f : \u03b1 \u2192 G\u2080} {l : Filter \u03b1} {a : G\u2080} (hf : Tendsto f l (\ud835\udcdd a)) (m : \u2124)\n    (h : a \u2260 0 \u2228 0 \u2264 m) : Tendsto (fun x => f x ^ m) l (\ud835\udcdd (a ^ m)) :=\n  (continuousAt_zpow\u2080 _ m h).Tendsto.comp hf\n#align filter.tendsto.zpow\u2080 Filter.Tendsto.zpow\u2080\n\nvariable {X : Type _} [TopologicalSpace X] {a : X} {s : Set X} {f : X \u2192 G\u2080}\n\n/- warning: continuous_at.zpow\u2080 -> ContinuousAt.zpow\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {a : X} {f : X -> G\u2080}, (ContinuousAt.{u2, u1} X G\u2080 _inst_5 _inst_2 f a) -> (forall (m : Int), (Or (Ne.{succ u1} G\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _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\u2080 _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m) a))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {a : X} {f : X -> G\u2080}, (ContinuousAt.{u2, u1} X G\u2080 _inst_5 _inst_2 f a) -> (forall (m : Int), (Or (Ne.{succ u1} G\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (ContinuousAt.{u2, u1} X G\u2080 _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m) a))\nCase conversion may be inaccurate. Consider using '#align continuous_at.zpow\u2080 ContinuousAt.zpow\u2080\u2093'. -/\ntheorem ContinuousAt.zpow\u2080 (hf : ContinuousAt f a) (m : \u2124) (h : f a \u2260 0 \u2228 0 \u2264 m) :\n    ContinuousAt (fun x => f x ^ m) a :=\n  hf.zpow\u2080 m h\n#align continuous_at.zpow\u2080 ContinuousAt.zpow\u2080\n\n/- warning: continuous_within_at.zpow\u2080 -> ContinuousWithinAt.zpow\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {a : X} {s : Set.{u2} X} {f : X -> G\u2080}, (ContinuousWithinAt.{u2, u1} X G\u2080 _inst_5 _inst_2 f s a) -> (forall (m : Int), (Or (Ne.{succ u1} G\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _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\u2080 _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m) s a))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {a : X} {s : Set.{u2} X} {f : X -> G\u2080}, (ContinuousWithinAt.{u2, u1} X G\u2080 _inst_5 _inst_2 f s a) -> (forall (m : Int), (Or (Ne.{succ u1} G\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (ContinuousWithinAt.{u2, u1} X G\u2080 _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m) s a))\nCase conversion may be inaccurate. Consider using '#align continuous_within_at.zpow\u2080 ContinuousWithinAt.zpow\u2080\u2093'. -/\ntheorem ContinuousWithinAt.zpow\u2080 (hf : ContinuousWithinAt f s a) (m : \u2124) (h : f a \u2260 0 \u2228 0 \u2264 m) :\n    ContinuousWithinAt (fun x => f x ^ m) s a :=\n  hf.zpow\u2080 m h\n#align continuous_within_at.zpow\u2080 ContinuousWithinAt.zpow\u2080\n\n/- warning: continuous_on.zpow\u2080 -> ContinuousOn.zpow\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {s : Set.{u2} X} {f : X -> G\u2080}, (ContinuousOn.{u2, u1} X G\u2080 _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\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _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\u2080 _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m) s))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {s : Set.{u2} X} {f : X -> G\u2080}, (ContinuousOn.{u2, u1} X G\u2080 _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\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m))) -> (ContinuousOn.{u2, u1} X G\u2080 _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m) s))\nCase conversion may be inaccurate. Consider using '#align continuous_on.zpow\u2080 ContinuousOn.zpow\u2080\u2093'. -/\ntheorem ContinuousOn.zpow\u2080 (hf : ContinuousOn f s) (m : \u2124) (h : \u2200 a \u2208 s, f a \u2260 0 \u2228 0 \u2264 m) :\n    ContinuousOn (fun x => f x ^ m) s := fun a ha => (hf a ha).zpow\u2080 m (h a ha)\n#align continuous_on.zpow\u2080 ContinuousOn.zpow\u2080\n\n/- warning: continuous.zpow\u2080 -> Continuous.zpow\u2080 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)))) (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1)) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {f : X -> G\u2080}, (Continuous.{u2, u1} X G\u2080 _inst_5 _inst_2 f) -> (forall (m : Int), (forall (a : X), Or (Ne.{succ u1} G\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _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\u2080 _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m)))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_1 : GroupWithZero.{u1} G\u2080] [_inst_2 : TopologicalSpace.{u1} G\u2080] [_inst_3 : HasContinuousInv\u2080.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1)) (GroupWithZero.toInv.{u1} G\u2080 _inst_1) _inst_2] [_inst_4 : ContinuousMul.{u1} G\u2080 _inst_2 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))] {X : Type.{u2}} [_inst_5 : TopologicalSpace.{u2} X] {f : X -> G\u2080}, (Continuous.{u2, u1} X G\u2080 _inst_5 _inst_2 f) -> (forall (m : Int), (forall (a : X), Or (Ne.{succ u1} G\u2080 (f a) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_1))))) (LE.le.{0} Int Int.instLEInt (OfNat.ofNat.{0} Int 0 (instOfNatInt 0)) m)) -> (Continuous.{u2, u1} X G\u2080 _inst_5 _inst_2 (fun (x : X) => HPow.hPow.{u1, 0, u1} G\u2080 Int G\u2080 (instHPow.{u1, 0} G\u2080 Int (DivInvMonoid.Pow.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_1))) (f x) m)))\nCase conversion may be inaccurate. Consider using '#align continuous.zpow\u2080 Continuous.zpow\u2080\u2093'. -/\n@[continuity]\ntheorem Continuous.zpow\u2080 (hf : Continuous f) (m : \u2124) (h0 : \u2200 a, f a \u2260 0 \u2228 0 \u2264 m) :\n    Continuous fun x => f x ^ m :=\n  continuous_iff_continuousAt.2 fun x => (hf.Tendsto x).zpow\u2080 m (h0 x)\n#align continuous.zpow\u2080 Continuous.zpow\u2080\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 \u03b2, 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:\u03b2),\n     X b and Y b are identical, and for any (b b':\u03b2), 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 {\u03b1 \u03b2:Type*} (M\u03b1:measure_theory.measure_space \u03b1) (M\u03b2:measure_theory.measure_space \u03b2):measure_theory.measure_space (\u03b1 \u00d7 \u03b2) :=\n  @measure_theory.measure_space.mk (\u03b1 \u00d7 \u03b2) (@prod.measurable_space \u03b1 \u03b2 M\u03b1.to_measurable_space M\u03b2.to_measurable_space) (prod.measure M\u03b1.volume M\u03b2.volume)\n\nlemma prod.measure_space.apply (\u03b1 \u03b2:Type*) (M\u03b1:measure_theory.measure_space \u03b1) (M\u03b2:measure_theory.measure_space \u03b2) (S:set (\u03b1 \u00d7 \u03b2)):\n  @measure_theory.measure_space.volume _ (prod.measure_space M\u03b1 M\u03b2) S =\n  (prod.measure M\u03b1.volume M\u03b2.volume) S := rfl \n\n\n\nlemma prod.measure_space.apply_prod (\u03b1 \u03b2:Type*) (M\u03b1:measure_theory.measure_space \u03b1) (M\u03b2:measure_theory.measure_space \u03b2) (A:set \u03b1) (B:set \u03b2):measurable_set A \u2192\n  measurable_set B \u2192\n  @measure_theory.measure_space.volume _ (prod.measure_space M\u03b1 M\u03b2) (A.prod B) = \n  (@measure_theory.measure_space.volume _ M\u03b1 (A)) * \n  (@measure_theory.measure_space.volume _ M\u03b2 (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 {\u03b1 \u03b2:Type*} (P\u03b1:probability_space \u03b1) (P\u03b2:probability_space \u03b2):probability_space (\u03b1 \u00d7 \u03b2) := \n@probability_space.mk (\u03b1 \u00d7 \u03b2) \n  (prod.measure_space P\u03b1.to_measure_space P\u03b2.to_measure_space)\n  begin\n  simp,\n  have A1:(@set.univ \u03b1).prod (@set.univ \u03b2) = (@set.univ (\u03b1 \u00d7 \u03b2)),\n  { simp },\n  rw \u2190 A1,  \n  rw prod.measure_space.apply_prod,\n  repeat { simp },\nend\n\ndef event.prod {\u03b1 \u03b2:Type*} {P\u03b1:probability_space \u03b1} {P\u03b2:probability_space \u03b2} \n  (A:event P\u03b1) (B:event P\u03b2):\n  event (P\u03b1.prod P\u03b2) := measurable_setB.prod A B\n\nlemma event.prod_def {\u03b1 \u03b2:Type*} {P\u03b1:probability_space \u03b1} {P\u03b2:probability_space \u03b2} \n  (A:event P\u03b1) (B:event P\u03b2):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 (\u03b1 \u03b2:Type*) (P\u03b1:probability_space \u03b1) (P\u03b2:probability_space \u03b2) (A:event P\u03b1) (B:event P\u03b2):\n  Pr[A.prod B] = Pr[A] * Pr[B] := begin\n  rw \u2190 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 {\u03b1 \u03b2:Type*} (P\u03b1:probability_space \u03b1) (P\u03b2:probability_space \u03b2):\n(P\u03b1.prod P\u03b2) \u2192\u1d63 P\u03b1.to_measurable_space := mf_fst\n\ndef rv_prod_snd {\u03b1 \u03b2:Type*} (P\u03b1:probability_space \u03b1) (P\u03b2:probability_space \u03b2):\n(P\u03b1.prod P\u03b2) \u2192\u1d63 P\u03b2.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 {\u03b1 \u03b2 \u03b3:Type*} {P\u03b1:probability_space \u03b1} {P\u03b2:probability_space \u03b2}\n{M\u03b3:measurable_space \u03b3} (X:P\u03b2 \u2192\u1d63 M\u03b3) (Y:P\u03b1 \u2192\u1d63 P\u03b2.to_measurable_space):P\u03b1 \u2192\u1d63 M\u03b3 := \ncompose_measurable_fun X Y\n\n\n\n\nnoncomputable def random_variable.on_fst {\u03b1 \u03b2 \u03b3:Type*} {P\u03b1:probability_space \u03b1} {M\u03b3:measurable_space \u03b3} \n(X:P\u03b1 \u2192\u1d63 M\u03b3) (P\u03b2:probability_space \u03b2) := rv_compose_rv X (rv_prod_fst P\u03b1 P\u03b2)\n\nnoncomputable def random_variable.on_snd {\u03b1 \u03b2 \u03b3:Type*} {P\u03b2:probability_space \u03b2} {M\u03b3:measurable_space \u03b3} \n(X:P\u03b2 \u2192\u1d63 M\u03b3) (P\u03b1:probability_space \u03b1) := rv_compose_rv X (rv_prod_snd P\u03b1 P\u03b2)\n\n\nlemma Pr_rv_prod_fst_eq {\u03b1 \u03b2:Type*} {P\u03b1:probability_space \u03b1} \n  {P\u03b2:probability_space \u03b2} (A:event P\u03b1):\n\n  Pr[(rv_prod_fst P\u03b1 P\u03b2) \u2208\u1d63 A] = Pr[A] :=\nbegin\n  have h_event_rw:(rv_prod_fst P\u03b1 P\u03b2 \u2208\u1d63 A) = \n           A.prod event_univ,\n  { apply event.eq, simp [rv_prod_fst, event_univ, event.prod], ext \u03c9, 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 {\u03b1 \u03b2:Type*} {P\u03b1:probability_space \u03b1} \n  {P\u03b2:probability_space \u03b2} (B:event P\u03b2):\n  Pr[(rv_prod_snd P\u03b1 P\u03b2) \u2208\u1d63 B] = Pr[B] :=\nbegin\n  have h_event_rw:(rv_prod_snd P\u03b1 P\u03b2 \u2208\u1d63 B) = \n           event_univ.prod B,\n  { apply event.eq, simp [rv_prod_snd, event_univ, event.prod], ext \u03c9, 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 {\u03b1 \u03b2:Type*} {P\u03b1:probability_space \u03b1} \n  {P\u03b2:probability_space \u03b2}:\n  random_variable_independent_pair (rv_prod_fst P\u03b1 P\u03b2) (rv_prod_snd P\u03b1 P\u03b2) :=\nbegin\n  intros A B,\n  let A':event P\u03b1 := A,\n  let B':event P\u03b2 := B,\n  begin\n    unfold independent_event_pair,\n    have h_event_rw:(rv_prod_fst P\u03b1 P\u03b2 \u2208\u1d63 A\u2227rv_prod_snd P\u03b1 P\u03b2 \u2208\u1d63 B) = \n             A'.prod B',\n    { apply event.eq, simp [rv_prod_fst, rv_prod_snd, A', B', event.prod], ext \u03c9, 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 {\u03b1 \u03b2 \u03b3 \u03ba:Type*} {P\u03b1:probability_space \u03b1} \n  {P\u03b2:probability_space \u03b2} {M\u03b3:measurable_space \u03b3} {M\u03ba:measurable_space \u03ba} \n{X:P\u03b1 \u2192\u1d63 M\u03b3} {Y:P\u03b2 \u2192\u1d63 M\u03ba}:\n  random_variable_independent_pair (X.on_fst P\u03b2) (Y.on_snd P\u03b1) :=\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 {\u03b1 \u03b2 \u03b3 \u03ba:Type*} {P\u03b1:probability_space \u03b1} \n  {P\u03b2:probability_space \u03b2} {M\u03b3:measurable_space \u03b3} {M\u03ba:measurable_space \u03ba} \n(X:P\u03b1 \u2192\u1d63 M\u03b3) (Y:P\u03b2 \u2192\u1d63 M\u03ba):prod (P\u03b1.prod P\u03b2 \u2192\u1d63 M\u03b3) (P\u03b1.prod P\u03b2 \u2192\u1d63 M\u03ba) :=\n   prod.mk (X.on_fst P\u03b2) (Y.on_snd P\u03b1)\n\nnoncomputable def pi.measure_space {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} (M:\u2200 a, measure_theory.measure_space (\u03b2 a)):\n  measure_theory.measure_space (\u03a0 a, \u03b2 a) :=\n  @measure_theory.measure_space.mk (\u03a0 a, \u03b2 a) (@measurable_space.pi \u03b1 \u03b2 (\u03bb a, (M a).to_measurable_space)) (pi.measure (\u03bb a, (M a).volume))\n\nlemma pi.measure_space.apply {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} (M:\u2200 a, measure_theory.measure_space (\u03b2 a)) (S:set (\u03a0 a, \u03b2 a)):\n  @measure_theory.measure_space.volume _ (pi.measure_space M) S =\n  (pi.measure  (\u03bb a, (M a).volume)) S := rfl \n\n\nlemma pi.measure_space.apply_prod {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} (M:\u2200 a, measure_theory.measure_space (\u03b2 a)) {S:\u03a0 a, set (\u03b2 a)}:\n  (\u2200 a, measurable_set (S a)) \u2192\n  @measure_theory.measure_space.volume _ (pi.measure_space M) (set.pi set.univ S) =\n  finset.univ.prod (\u03bb 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 {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*} (M:\u03a0 (a:\u03b1), measure_theory.measure_space (\u03b2 a)) {P:set (\u03a0 (a:\u03b1), \u03b2 a)}:\n  measurable_set P \u2192\n  @measure_theory.measure_space.volume _ (pi.measure_space M) P = \n\n  (\u2a05 (f:\u2115 \u2192 (\u03a0 (a:\u03b1), set (\u03b2 a))) (h\u2081:\u2200 n m, measurable_set (f n m))\n  (h\u2083:P \u2286 \u22c3 (n:\u2115), set.pi set.univ (f n)), \n  \u2211' (n:\u2115), finset.univ.prod (\u03bb (m:\u03b1), \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 {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] {\u03b2:\u03b1 \u2192 Type*}\n   (P:\u03a0 a, probability_space (\u03b2 a)):probability_space (\u03a0 a, \u03b2 a) := \n  @probability_space.mk (\u03a0 a, \u03b2 a) \n  (pi.measure_space (\u03bb a, (P a).to_measure_space))\n  begin\n  simp,\n  have A1:set.pi set.univ (\u03bb a, @set.univ (\u03b2 a)) = (@set.univ (\u03a0 a, \u03b2 a)),\n  { ext1 \u03c9, split;intros A1_1; simp at A1_1, simp, },\n  rw \u2190 A1,\n  rw pi.measure_space.apply_prod,\n  simp,\n  simp, \nend\n\n\ndef set.pi_event {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  {P:\u03a0 a, probability_space (\u03b2 a)}\n  (T:set \u03b1) (E:\u03a0 a, event (P a)):event (pi.probability_space P) := T.pi_measurable E\n\n\nlemma set.pi_event_univ {\u03b1:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n{\u03b2:\u03b1 \u2192 Type*} {P:\u03a0 a, probability_space (\u03b2 a)}\n(S:\u03a0 a, event (P a)) (T:set \u03b1) [decidable_pred T]:set.pi_event T S = set.pi_event \n(@set.univ \u03b1) (\u03bb (a:\u03b1), if (a\u2208 T) then (S a) else (@event_univ (\u03b2 a) (P a))) :=\nbegin\n  apply set.pi_measurable_univ,\nend\n\n\nlemma pi.probability_space.apply_prod {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  {P:\u03a0 a, probability_space (\u03b2 a)}\n  (E:\u03a0 a, event (P a)):Pr[set.pi_event set.univ E] = finset.univ.prod (\u03bb a, Pr[E a]) := begin  \n  rw \u2190 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' {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  {P:\u03a0 a, probability_space (\u03b2 a)} {T:finset \u03b1}\n  (E:\u03a0 a, event (P a)):Pr[set.pi_event (\u2191T) E] = T.prod (\u03bb 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 (\u03bb (a:\u03b1), if (a \u2208 @coe (finset \u03b1) (set \u03b1) _ T) then Pr[E a] else 1) = \n          T.prod (\u03bb (a:\u03b1), if (a \u2208 @coe (finset \u03b1) (set \u03b1) _ T) then Pr[E a] else 1),\n  { rw \u2190 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 \u2190 finset.mem_coe,\n    apply contra },\n  have A3:T.prod (\u03bb (a:\u03b1), if (a \u2208 @coe (finset \u03b1) (set \u03b1) _ T) then Pr[E a] else 1) =\n          T.prod (\u03bb (a:\u03b1), 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 \u2190 A3,\n  rw \u2190 A2,\n  apply finset.prod_congr,\n  { refl },\n  { intros x A4, \n    cases classical.em (x \u2208 @coe (finset \u03b1) (set \u03b1) _ 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 {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} (M:\u03a0 a, measurable_space (\u03b2 a)) \n   (a:\u03b1):measurable_fun (@measurable_space.pi \u03b1 \u03b2 M) (M a) := @subtype.mk\n  ((\u03a0 a, \u03b2 a) \u2192 (\u03b2 a))\n  measurable\n  (\u03bb (d:\u03a0 a, \u03b2 a), d a)\n  begin\n    apply measurable_pi_apply,\n  end\n\n\ndef pi.rv {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  (P:\u03a0 a, probability_space (\u03b2 a)) (a:\u03b1):(pi.probability_space P) \u2192\u1d63 (P a).to_measurable_space := mf_pi (\u03bb a, (P a).to_measurable_space) a\n\nnoncomputable def pi.random_variable_proj {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} {\u03b3:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  (P:\u03a0 a, probability_space (\u03b2 a)) (a:\u03b1) {M:measurable_space \u03b3} (X:(P a) \u2192\u1d63 (M)):(pi.probability_space P) \u2192\u1d63 M := X \u2218r (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 {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} {\u03b3:\u03b1 \u2192 Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  {P:\u03a0 a, probability_space (\u03b2 a)} {M:\u03a0 a, measurable_space (\u03b3 a)} (X:\u03a0 a, (P a) \u2192\u1d63 (M a)):\u03a0 a, (pi.probability_space P) \u2192\u1d63 (M a) := (\u03bb a, pi.random_variable_proj P a (X a))\n\nlemma pi.rv_eq {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  (P:\u03a0 a, probability_space (\u03b2 a)) (a:\u03b1) (E:event (P a)):\n  Pr[(pi.rv P a)\u2208\u1d63 E] = Pr[E] := begin\n  classical,\n  have A1:\u2200 (a':\u03b1), \u2203 (E':event (P a')), \u03a0 (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 (\u03b2 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 \u03b1) (set \u03b1) _ {a}) E') = ((pi.rv P a)\u2208\u1d63 E),\n  { apply event.eq,\n    ext \u03c9,\n    simp [set.pi_event,pi.rv,set.pi_measurable,mf_pi],\n    subst E,\n    refl, \n     },\n  rw \u2190 A3,\n  rw pi.probability_space.apply_prod',\n  simp,\n  subst E,\n  refl,\nend\n\nlemma pi.random_variable_proj_identical {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} {\u03b3:Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  (P:\u03a0 a, probability_space (\u03b2 a)) (a:\u03b1) {M:measurable_space \u03b3} (X:(P a) \u2192\u1d63 (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) \u2192\u1d63 M := X \u2218r (pi.rv P a)\n\n\n\nlemma pi.rv_independent {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} [F:fintype \u03b1] [N:nonempty \u03b1] \n  (P:\u03a0 a, probability_space (\u03b2 a)):\n  random_variable_independent (pi.rv P) :=\nbegin\n  classical,\n  intros S,\n  intros T,\n  have h1:(\u2200\u1d63 (s : \u03b1) in T,(\u03bb (b : \u03b1), @pi.rv \u03b1 (\u03bb (a : \u03b1), \u03b2 a) F N P b \u2208\u1d63 S b) s) =\n          set.pi_event (\u2191T) S,\n  { apply event.eq,\n    ext1 \u03c9,\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 {\u03b1:Type*} {\u03b2:\u03b1 \u2192 Type*} {\u03b3:\u03b1 \u2192 Type*} [F:fintype \u03b1] \n  [N:nonempty \u03b1] (P:\u03a0 a, probability_space (\u03b2 a)) {M:\u03a0 a, measurable_space (\u03b3 a)} \n  (X:\u03a0 a, (P a) \u2192\u1d63 (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 {\u03b2 \u03b3:Type*} {P:probability_space \u03b2} \n  {M:measurable_space \u03b3} (X:P \u2192\u1d63 M) (m:nat):(fin m.succ) \u2192 \n  (pi.probability_space (\u03bb (m:fin m.succ), P) \u2192\u1d63 M)\n\n := \n@pi.random_variable (fin m.succ) (\u03bb (a:fin m.succ), \u03b2) \n  (\u03bb (a:fin m.succ), \u03b3) _  _ \n  (\u03bb a, P) (\u03bb a, M) (\u03bb a, X) \n\n\nlemma pi.random_variable_IID_independent {\u03b2 \u03b3:Type*} {P:probability_space \u03b2} \n  {M:measurable_space \u03b3} (X:P \u2192\u1d63 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 {\u03b2 \u03b3:Type*} {P:probability_space \u03b2} \n  {M:measurable_space \u03b3} (X:P \u2192\u1d63 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' {\u03b2 \u03b3:Type*} {P:probability_space \u03b2} \n  {M:measurable_space \u03b3} (X:P \u2192\u1d63 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 {\u03b2 \u03b3:Type*} {P:probability_space \u03b2} \n  {M:measurable_space \u03b3} (X:P \u2192\u1d63 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\u03b1 and P\u03b2. -/\nnoncomputable def random_variable.pair_collection {\u03b1 \u03b2 \u03b3 \u03ba \u03b4:Type*}  \n  {P\u03b1:probability_space \u03b1} \n  {P\u03b2:probability_space \u03b2} {M\u03b3:measurable_space \u03b3} {M\u03ba:measurable_space \u03ba} \n(X:\u03b4 \u2192 P\u03b1 \u2192\u1d63 M\u03b3) (Y:P\u03b2 \u2192\u1d63 M\u03ba):prod (\u03b4 \u2192 P\u03b1.prod P\u03b2 \u2192\u1d63 M\u03b3) (P\u03b1.prod P\u03b2 \u2192\u1d63 M\u03ba) :=\n   prod.mk (\u03bb (d:\u03b4), (X d).on_fst P\u03b2) (Y.on_snd P\u03b1)\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\u2081 u\u2081 u\u2082 \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, \u03b1)` is the pair of morphisms `(F \u03b1, \u03b5_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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] (A : algebra (left_adjoint G \u22d9 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, \u03b1)` is the pair of morphisms `(F \u03b1, \u03b5_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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] (A : algebra (left_adjoint G \u22d9 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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] (A : algebra (left_adjoint G \u22d9 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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] (A : algebra (left_adjoint G \u22d9 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 \u27f6 B) \u2243 (A \u27f6 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 \u27f6 functor.obj G B) =>\n            functor.map G (functor.map (left_adjoint G) g) \u226b\n                functor.map G (nat_trans.app (adjunction.counit (adjunction.of_right_adjoint G)) B) =\n              algebra.a A \u226b g) =>\n        algebra.hom.mk \u2191g)\n      (fun (f : A \u27f6 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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] [\u2200 (A : algebra (left_adjoint G \u22d9 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 \u22d9 G) \u2964 D :=\n  adjunction.left_adjoint_of_equiv\n    (fun (A : algebra (left_adjoint G \u22d9 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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] [\u2200 (A : algebra (left_adjoint G \u22d9 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 \u22a3 comparison G :=\n  adjunction.adjunction_of_equiv_left\n    (fun (A : algebra (left_adjoint G \u22d9 G)) (B : D) => comparison_left_adjoint_hom_equiv A B) sorry\n\ntheorem comparison_adjunction_unit_f_aux {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] [\u2200 (A : algebra (left_adjoint G \u22d9 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 \u22d9 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.\u03c0 (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_\u03b9_app {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] (A : algebra (left_adjoint G \u22d9 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.\u03b9 (unit_cofork A)) X =\n  limits.walking_parallel_pair.rec\n    (functor.map G (functor.map (left_adjoint G) (algebra.a A)) \u226b\n      functor.map G\n        (limits.coequalizer.\u03c0 (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.\u03c0 (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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] [\u2200 (A : algebra (left_adjoint G \u22d9 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 \u22d9 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_\u03b9_app {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] (B : D) (X : limits.walking_parallel_pair) : nat_trans.app (limits.cocone.\u03b9 (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)) \u226b\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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] (A : algebra (left_adjoint G \u22d9 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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 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\u2081} {D : Type u\u2082} [category C] [category D] {G : D \u2964 C} [is_right_adjoint G] [\u2200 (A : algebra (left_adjoint G \u22d9 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\u2081} {D : Type u\u2082} [category C] [category D] (G : D \u2964 C) [monadic_right_adjoint G] {A : D} {B : D} (f : A \u27f6 B) (g : A \u27f6 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\u2081} {D : Type u\u2082} [category C] [category D] (G : D \u2964 C) [is_right_adjoint G] [\u2200 {A B : D} (f g : A \u27f6 B) [_inst_5 : functor.is_split_pair G f g], limits.has_coequalizer f g] [{A B : D} \u2192\n  (f g : A \u27f6 B) \u2192 [_inst_7 : functor.is_split_pair G f g] \u2192 limits.preserves_colimit (limits.parallel_pair f g) G] [{A B : D} \u2192\n  (f g : A \u27f6 B) \u2192 [_inst_9 : functor.is_split_pair G f g] \u2192 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\u2081} {D : Type u\u2082} [category C] [category D] (G : D \u2964 C) [is_right_adjoint G] [{A B : D} \u2192 (f g : A \u27f6 B) \u2192 [_inst_5 : functor.is_split_pair G f g] \u2192 creates_colimit (limits.parallel_pair f g) G] : monadic_right_adjoint G :=\n  let _inst :\n    \u2200 {A B : D} (f g : A \u27f6 B) [_inst_6 : functor.is_split_pair G f g],\n      limits.has_colimit (limits.parallel_pair f g \u22d9 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\u2081} {D : Type u\u2082} [category C] [category D] (G : D \u2964 C) [is_right_adjoint G] [reflects_isomorphisms G] [\u2200 {A B : D} (f g : A \u27f6 B) [_inst_6 : functor.is_split_pair G f g], limits.has_coequalizer f g] [{A B : D} \u2192\n  (f g : A \u27f6 B) \u2192 [_inst_8 : functor.is_split_pair G f g] \u2192 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\u2081} {D : Type u\u2082} [category C] [category D] (G : D \u2964 C) [is_right_adjoint G] [limits.has_reflexive_coequalizers D] [reflects_isomorphisms G] [{A B : D} \u2192 (f g : A \u27f6 B) \u2192 [_inst_7 : is_reflexive_pair f g] \u2192 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    | \u03b5\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 \u2192 PEG n \u2192 Prop where\n    | refl        : le p p\n    | seq_left    : le e p1 \u2192 le e (.seq p1 p2)\n    | seq_right   : le e p2 \u2192 le e (.seq p1 p2)\n    | prior_left  : le e p1 \u2192 le e (.prior p1 p2)\n    | prior_right : le e p2 \u2192 le e (.prior p1 p2)\n    | star        : le e p \u2192 le e (.star p)\n    | notP        : le e p \u2192 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 \u2264 G := by exact .refl;\n\n  theorem PEG.le_trans {G1 G2 G3 : PEG n} : G1 \u2264 G2 \u2192 G2 \u2264 G3 \u2192 G1 \u2264 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      | [] => \u03b5\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 \u2192 PEG n \n\n  -- Maybe Type for known and unknown properties\n  inductive Maybe (p : \u03b1 \u2192 Prop) (a : \u03b1) where\n    | found : p a \u2192 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 \u2192 PEG n \u2192 Prop where\n      | any : PropF Pexp any\n      | terminal : \u2200 (c : Char), PropF Pexp (terminal c)\n      | nonTerminal : \u2200 (vn : Fin n), PropF Pexp (Pexp.f vn) \u2192 PropF Pexp (nonTerminal vn)\n      | seq_F : \u2200 (e1 e2 : PEG n), PropF Pexp e1 \u2192 PropF Pexp (seq e1 e2)\n      | seq_0F : \u2200 (e1 e2 : PEG n), Prop0 Pexp e1 \u2192 PropF Pexp e2 \u2192 PropF Pexp (seq e1 e2)\n      | seq_SF : \u2200 (e1 e2 : PEG n), PropS Pexp e1 \u2192 PropF Pexp e2 \u2192 PropF Pexp (seq e1 e2)\n      | prior : \u2200 (e1 e2 : PEG n), PropF Pexp e1 \u2192 PropF Pexp e2 \u2192 PropF Pexp (prior e1 e2)\n      | notP_0 : \u2200 (e : PEG n), Prop0 Pexp e \u2192 PropF Pexp (notP e)\n      | notP_S : \u2200 (e : PEG n), PropS Pexp e \u2192 PropF Pexp (notP e)\n\n    -- Property of PEG grammar that can succeed without consuming input\n    inductive Prop0 : GProd n \u2192 PEG n \u2192 Prop where\n      | \u03b5 : Prop0 Pexp \u03b5\n      | nonTerminal : \u2200 (vn : Fin n), Prop0 Pexp (Pexp.f vn) \u2192 Prop0 Pexp (nonTerminal vn)\n      | seq : \u2200 (e1 e2 : PEG n), Prop0 Pexp e1 \u2192 Prop0 Pexp e2 \u2192 Prop0 Pexp (seq e1 e2)\n      | prior_0 : \u2200 (e1 e2 : PEG n), Prop0 Pexp e1 \u2192 Prop0 Pexp (prior e1 e2)\n      | prior_F0 : \u2200 (e1 e2 : PEG n), PropF Pexp e1 \u2192 Prop0 Pexp e2 \u2192 Prop0 Pexp (prior e1 e2)\n      | star : \u2200 (e : PEG n), PropF Pexp e \u2192 Prop0 Pexp (star e)\n      | notP : \u2200 (e : PEG n), PropF Pexp e \u2192 Prop0 Pexp (notP e)\n\n    -- Property of PEG grammar that can succeed only by consuming input\n    inductive PropS : GProd n \u2192 PEG n \u2192 Prop where\n      | any : PropS Pexp any\n      | terminal : \u2200 (c : Char), PropS Pexp (terminal c)\n      | nonTerminal : \u2200 (vn : Fin n), PropS Pexp (Pexp.f vn) \u2192 PropS Pexp (nonTerminal vn)\n      | seq_S0 : \u2200 (e1 e2 : PEG n), PropS Pexp e1 \u2192 Prop0 Pexp e2 \u2192 PropS Pexp (seq e1 e2)\n      | seq_0S : \u2200 (e1 e2 : PEG n), Prop0 Pexp e1 \u2192 PropS Pexp e2 \u2192 PropS Pexp (seq e1 e2)\n      | seq_SS : \u2200 (e1 e2 : PEG n), PropS Pexp e1 \u2192 PropS Pexp e2 \u2192 PropS Pexp (seq e1 e2)\n      | prior_S : \u2200 (e1 e2 : PEG n), PropS Pexp e1 \u2192 PropS Pexp (prior e1 e2)\n      | prior_FS : \u2200 (e1 e2 : PEG n), PropF Pexp e1 \u2192 PropS Pexp e2 \u2192 PropS Pexp (prior e1 e2)\n      | star : \u2200 (e : PEG n), PropS Pexp e \u2192 PropS Pexp (star e)\n  end\n\n  abbrev PropsTriple (Pexp : GProd n) (G : PEG n) := Maybe (PropF Pexp) G \u00d7 Maybe (Prop0 Pexp) G \u00d7 Maybe (PropS Pexp) G\n  abbrev PropsTriplePred (Pexp : GProd n) := \u2200 (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    | \u03b5 => (unknown, found (Prop0.\u03b5), 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 \u2192 Maybe p a \u2192 Prop where\n    | lhs_unknown : \u2200 {p : \u03b1 \u2192 Prop} {a : \u03b1} {mr : Maybe p a}, Maybe.le unknown mr\n    | all_found : \u2200 {p : \u03b1 \u2192 Prop} {a : \u03b1}, (l r : p a) \u2192 Maybe.le (found l) (found r)\n\n  instance : LE (Maybe p a) where\n    le := Maybe.le\n\n  theorem Maybe.le_refl : \u2200 {x : Maybe p a}, x \u2264 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 : \u2200 {x y z : Maybe p a}, x \u2264 y \u2192 y \u2264 z \u2192 x \u2264 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 : \u2200 {p : \u03b1 \u2192 Prop} {a : \u03b1}, (pa : p a) \u2192 \u00ac (found pa \u2264 unknown) := by\n    intro p a pa h\n    cases h\n\n  theorem Maybe.le.equiv_to_imply : \u2200 {p : \u03b1 \u2192 Prop} {a : \u03b1} {x y : Maybe p a}, x \u2264 y \u2194 (x = unknown) \u2228 (\u2203 x' y', x = found x' \u2227 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 \u27e8x',\u27e8y', \u27e8fx, fy\u27e9\u27e9\u27e9 => simp [fx, fy]; exact Maybe.le.all_found x' y'\n    }\n  \n  theorem Maybe.eq_of_le_le : \u2200 {p : \u03b1 \u2192 Prop} {a : \u03b1} {x y : Maybe p a}, x \u2264 y \u2192 y \u2264 x \u2192 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 \u2264 Q.fst \u2192 P.snd.fst \u2264 Q.snd.fst \u2192 P.snd.snd \u2264 Q.snd.snd \u2192 PropsTriple.le P Q\n\n  instance : LE (PropsTriple Pexp G) where\n    le := PropsTriple.le\n\n  theorem PropsTriple.le_refl : \u2200 {x : PropsTriple Pexp G}, x \u2264 x := by\n    intro x\n    apply PropsTriple.le.mk <;> apply Maybe.le_refl\n\n  theorem PropsTriple.le_trans : \u2200 {x y z : PropsTriple Pexp G}, x \u2264 y \u2192 y \u2264 z \u2192 x \u2264 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 : \u2200 {x y : PropsTriple Pexp G}, x \u2264 y \u2192 y \u2264 x \u2192 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 : (\u2200 (i : Fin n), (P i) \u2264 (Q i)) \u2192 PropsTriplePred.le P Q\n\n  instance : LE (PropsTriplePred Pexp) where\n    le := PropsTriplePred.le\n\n  theorem PropsTriplePred.le_refl : \u2200 {x : PropsTriplePred Pexp}, x \u2264 x := by\n    intro x\n    constructor\n    intro i\n    apply PropsTriple.le_refl\n\n  theorem PropsTriplePred.le_trans : \u2200 {x y z : PropsTriplePred Pexp}, x \u2264 y \u2192 y \u2264 z \u2192 x \u2264 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 : \u2200 {x y : PropsTriplePred Pexp}, x \u2264 y \u2192 y \u2264 x \u2192 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 : \u2200 {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {e1 e2 : PEG n}, g_props e1 P \u2264 g_props e1 Q \u2192 g_props e2 P \u2264 g_props e2 Q \u2192 g_props (.seq e1 e2) P \u2264 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; cases (g_props e1 Q).fst <;> simp <;> apply Maybe.le.all_found\n            | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; apply Maybe.le.all_found\n            | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; cases (g_props e1 Q).snd.snd <;> simp <;> apply Maybe.le.all_found\n              | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; cases (g_props e2 Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n                | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; apply Maybe.le.all_found\n          }\n        }\n\n  theorem g_props_growth_nonterminal : \u2200 {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {vn} , P \u2264 Q \u2192 g_props (.nonTerminal vn) P \u2264 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; apply Maybe.le.all_found\n        }\n      }\n\n  theorem g_props_growth_prior : \u2200 {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {e1 e2 : PEG n}, g_props e1 P \u2264 g_props e1 Q \u2192 g_props e2 P \u2264 g_props e2 Q  \u2192 g_props (.prior e1 e2) P \u2264 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; apply Maybe.le.all_found\n            | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; cases (g_props e1 Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n              | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 : \u2200 {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {e : PEG n}, g_props e P \u2264 g_props e Q \u2192 g_props (.star e) P \u2264 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; apply Maybe.le.all_found\n        }\n      }\n\n  theorem g_props_growth_notP : \u2200 {Pexp : GProd n} {P Q : PropsTriplePred Pexp} {e : PEG n}, g_props e P \u2264 g_props e Q \u2192 g_props (.notP e) P \u2264 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; cases (g_props e Q).snd.fst <;> simp <;> apply Maybe.le.all_found\n          | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy']; apply Maybe.le.all_found\n        }\n        {\n          apply Maybe.le.lhs_unknown\n        }\n      }\n\n  theorem g_props_growth : \u2200 {Pexp : GProd n} {G : PEG n} {P Q : PropsTriplePred Pexp}, P \u2264 Q \u2192 g_props G P \u2264 g_props G Q := by\n    intro Pexp G P Q hpq\n    cases G with\n      | \u03b5 => 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 \u2264 g_props e1 Q := g_props_growth hpq;\n          have e2_growth : g_props e2 P \u2264 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 \u2264 g_props e1 Q := g_props_growth hpq;\n          have e2_growth : g_props e2 P \u2264 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 \u2264 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 \u2264 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 : \u2200 (i : Fin n), pred i \u2264 g_props (Pexp.f i) pred\n\n  instance : LE (CoherentPred Pexp) where\n    le := fun P Q => P.pred \u2264 Q.pred\n  \n  theorem CoherentPred.eq_of_eq_pred : \u2200 {x y : CoherentPred Pexp}, x.pred = y.pred \u2192 x = y := by\n    intro x y h;\n    cases x; cases y; simp_all;\n\n  theorem CoherentPred.eq_of_le_le : \u2200 {x y : CoherentPred Pexp}, x \u2264 y \u2192 y \u2264 x \u2192 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 : \u2200 {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp), P \u2264 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 : \u2200 {Pexp : GProd n} (a : Fin n) (P Q : CoherentPred Pexp), P \u2264 Q \u2192 g_extend a P \u2264 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 : \u2200 {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp), P \u2264 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 : \u2200 {Pexp : GProd n} (a : Fin n) (P Q : CoherentPred Pexp), P \u2264 Q \u2192 recompute_props a P \u2264 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 : \u2200 {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp), (hne : \u00ac(a.val.succ = n)) \u2192 recompute_props (Fin.inbound_succ a hne) P \u2264 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 : \u2200 {Pexp : GProd n} (a : Fin n) (P : CoherentPred Pexp), recompute_props a P \u2264 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 \u2264 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 : \u2200 {x y : Fixpoint Pexp}, x.coherent_pred = y.coherent_pred \u2192 x = y := by\n    intro x y h;\n    cases x; cases y; simp_all;\n  \n  theorem Fixpoint.recompute_le_self : \u2200 {Pexp : GProd n} (a : Fin n) (P : Fixpoint Pexp), recompute_props a P.coherent_pred \u2264 P.coherent_pred := by\n    intro Pexp a P;\n    have helper : (recompute_props a P.coherent_pred \u2264 P.coherent_pred) = (recompute_props a P.coherent_pred \u2264 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 : \u2200 {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 \u2264 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 \u2192 Fin 2\n    | found _ => Fin.mk 1 (by trivial)\n    | unknown => Fin.mk 0 (by trivial)\n\n  theorem Maybe.count_growth : \u2200 (P Q : Maybe p a), P \u2264 Q \u2192 P.count_found \u2264 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 : \u2200 (P Q : Maybe p a), P.count_found = Q.count_found \u2192 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 : \u2200 (P Q : PropsTriple Pexp G), P \u2264 Q \u2192 P.count_found \u2264 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 : \u2200 {a b c d : Nat}, a \u2264 c \u2192 b \u2264 d \u2192 a + b = c + d \u2192 (a = c \u2227 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 \u2260 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 : \u2200 (P Q : PropsTriple Pexp G), P \u2264 Q \u2192 P.count_found = Q.count_found \u2192 P = Q := by\n    intro P Q hle hcount;\n    simp [count_found, Fin.extended_add] at hcount;\n    match hle with\n    | \u27e8hf,h0,hs\u27e9 => \n      match P with\n      | \u27e8pf,p0,ps\u27e9 => match Q with\n        | \u27e8qf,q0,qs\u27e9 => \n          simp at *;\n          have g1 : (Maybe.count_found pf).val = (Maybe.count_found qf).val \u2227 ((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 \u2227 (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 [\u2190Nat.add_sub_assoc (by rw[\u2190Nat.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 [\u2190Nat.add_one, \u2190Nat.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 [\u2190Nat.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 [\u2190Nat.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), \u2190Nat.add_assoc];\n        apply Nat.add_le_add_right;\n        have g : 2 + 3 * i.val \u2264 3 + 3 * i.val := by apply Nat.add_le_add_right; trivial;\n        apply Nat.le_trans g;\n        rw [Nat.add_comm, \u2190Nat.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 [\u2190Nat.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 \u2264 res2 \u2192 P.count_found_helper i res1 \u2264 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 \u2264 Q \u2192 P.count_found_helper i res \u2264 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              | \u27e8h, _, _\u27e9 => match Maybe.le.equiv_to_imply.mp h with\n                | Or.inl h => simp [h]; cases (Q i).fst <;> simp;\n                | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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                | \u27e8_, h, _\u27e9 => match Maybe.le.equiv_to_imply.mp h with\n                  | Or.inl h => simp [h]; cases (Q i).snd.fst <;> simp;\n                  | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy'];\n              }\n              {\n                rw [count_found, count_found];\n                simp;\n                match (h i) with\n                | \u27e8_, _, h\u27e9 => match Maybe.le.equiv_to_imply.mp h with\n                  | Or.inl h => simp [h]; cases (Q i).snd.snd <;> simp;\n                  | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u2264 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                | \u27e8h, _, _\u27e9 => match Maybe.le.equiv_to_imply.mp h with\n                  | Or.inl h => simp [h]; cases (Q i).fst <;> simp;\n                  | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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                  | \u27e8_, h, _\u27e9 => match Maybe.le.equiv_to_imply.mp h with\n                    | Or.inl h => simp [h]; cases (Q i).snd.fst <;> simp;\n                    | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => simp [hx', hy'];\n                }\n                {\n                  rw [count_found, count_found];\n                  simp;\n                  match (h i) with\n                  | \u27e8_, _, h\u27e9 => match Maybe.le.equiv_to_imply.mp h with\n                    | Or.inl h => simp [h]; cases (Q i).snd.snd <;> simp;\n                    | Or.inr \u27e8x',\u27e8y',\u27e8hx', hy'\u27e9\u27e9\u27e9 => 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 \u2264 Q \u2192 res1 \u2264 res2 \u2192 P.count_found_helper i res1 = Q.count_found_helper i res2 \u2192 P i = Q i \u2227 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 \u27e8PropsTriple.eq_of_le_with_same_count _ _ (f i) g.left,g.right\u27e9;\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 \u2264 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 \u27e8PropsTriple.eq_of_le_with_same_count _ _ (f i) g.left,g.right\u27e9;\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 \u2264 Q \u2192 res1 \u2264 res2 \u2192 P.count_found_helper i res1 = Q.count_found_helper i res2 \u2192 (\u2200 j, j \u2264 i \u2192 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 : \u2200 {Pexp : GProd n} {P Q : PropsTriplePred Pexp}, P \u2264 Q \u2192 P.count_found \u2264 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 : \u2200 {Pexp : GProd n} (P Q : PropsTriplePred Pexp), P \u2264 Q \u2192 P.count_found = Q.count_found \u2192 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 : \u2200 {Pexp : GProd n} {P Q : CoherentPred Pexp}, P \u2264 Q \u2192 P.count_found \u2264 Q.count_found := by\n    intros;\n    apply PropsTriplePred.count_growth;\n    assumption;\n\n  theorem CoherentPred.eq_of_le_with_same_count : \u2200 {Pexp : GProd n} (P Q : CoherentPred Pexp), P \u2264 Q \u2192 P.count_found = Q.count_found \u2192 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 \u2264 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 : \u2200 {a b c : Nat}, b < a \u2192 c < a \u2192 b < c \u2192 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 : \u2200 (h : p a), m = found h \u2192 IsKnown m\n\n  theorem IsKnown.ne_of_unknown : \u2200 m : Maybe p a, m = unknown \u2192 \u00acIsKnown m := by\n    intro m h_unknown h\n    cases h;\n    cases h_unknown;\n    contradiction;\n  \n  theorem IsKnown.unknown_of_ne : \u2200 m : Maybe p a, \u00acIsKnown m \u2192 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 \u2192 Prop where\n    | \u03b5 : StructuralWF Pexp \u03b5\n    | any : StructuralWF Pexp any\n    | terminal : \u2200 (c : Char), StructuralWF Pexp (terminal c)\n    | nonTerminal : \u2200 (vn : Fin n), StructuralWF Pexp (nonTerminal vn)\n    | seq : \u2200 (e1 e2 : PEG n), StructuralWF Pexp e1 \u2192 StructuralWF Pexp e2 \u2192 StructuralWF Pexp (seq e1 e2)\n    | prior : \u2200 (e1 e2 : PEG n), StructuralWF Pexp e1 \u2192 StructuralWF Pexp e2 \u2192 StructuralWF Pexp (prior e1 e2)\n    | star : \u2200 (e : PEG n), StructuralWF Pexp e \u2192 \u00acIsKnown (getProp0 Pexp e) \u2192 StructuralWF Pexp (star e)\n    | notP : \u2200 (e : PEG n), StructuralWF Pexp e \u2192 StructuralWF Pexp (notP e)\n\n  def check_StructuralWF (Pexp : GProd n) (G : PEG n) : Maybe (StructuralWF Pexp) G :=\n    match G with\n    | \u03b5 => found .\u03b5\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) := \u2200 (i : Fin n), StructuralWF Pexp (Pexp.f i)\n  abbrev StructuralWF_GProd_partial (u : Fin n) (Pexp : GProd n) := \u2200 (i : Fin n), i \u2264 u \u2192 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 \u2192 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 [\u2190Nat.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 \u2192 Fin n} (Pexp : GProd n) (\u03c3 : Bijective p) (A : Fin n) : PEG n \u2192 Prop where\n    | \u03b5 : PatternWF Pexp \u03c3 A \u03b5\n    | any : PatternWF Pexp \u03c3 A any\n    | terminal : \u2200 (c : Char), PatternWF Pexp \u03c3 A (terminal c)\n    | nonTerminal : \u2200 (B : Fin n), p B < p A \u2192 PatternWF Pexp \u03c3 A (nonTerminal B)\n    | seq : \u2200 (e1 e2 : PEG n), PatternWF Pexp \u03c3 A e1 \u2192 (IsKnown (getProp0 Pexp e1) \u2192 PatternWF Pexp \u03c3 A e2) \u2192 PatternWF Pexp \u03c3 A (seq e1 e2)  \n    | prior : \u2200 (e1 e2 : PEG n), PatternWF Pexp \u03c3 A e1 \u2192 PatternWF Pexp \u03c3 A e2 \u2192 PatternWF Pexp \u03c3 A (prior e1 e2)\n    | star : \u2200 (e : PEG n), PatternWF Pexp \u03c3 A e \u2192 PatternWF Pexp \u03c3 A (star e)\n    | notP : \u2200 (e : PEG n), PatternWF Pexp \u03c3 A e \u2192 PatternWF Pexp \u03c3 A (notP e)\n  \n  def check_PatternWF {p : Fin n \u2192 Fin n} (Pexp : GProd n) (\u03c3 : Bijective p) (A : Fin n) (G : PEG n) : Maybe (PatternWF Pexp \u03c3 A) G :=\n    match G with\n    | \u03b5 => found .\u03b5\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 \u03c3 A e1, check_PatternWF Pexp \u03c3 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 \u03c3 A e1, check_PatternWF Pexp \u03c3 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 \u03c3 A e with\n      | found h => found (.star e h)\n      | unknown => unknown\n    | notP e => match check_PatternWF Pexp \u03c3 A e with\n      | found h => found (.notP e h)\n      | unknown => unknown\n\n  abbrev PatternWF_GProd {p : Fin n \u2192 Fin n} (Pexp : GProd n) (\u03c3 : Bijective p) := \u2200 (i : Fin n), PatternWF Pexp \u03c3 i (Pexp.f i)\n  abbrev PatternWF_GProd_partial (u : Fin n) {p : Fin n \u2192 Fin n} (Pexp : GProd n) (\u03c3 : Bijective p) := \u2200 (i : Fin n), i \u2264 u \u2192 PatternWF Pexp \u03c3 i (Pexp.f i)\n\n  theorem PatternWF_GProd.from_partial {p : Fin n \u2192 Fin n} {Pexp : GProd n} {\u03c3 : Bijective p} {hlt : n-1 < n} : PatternWF_GProd_partial {val := n-1, isLt := hlt} Pexp \u03c3 \u2192 PatternWF_GProd Pexp \u03c3 := 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 \u2192 Fin n} (Pexp : GProd n) (\u03c3 : Bijective p) : Maybe (PatternWF_GProd_partial u Pexp) \u03c3 :=\n    let curr_check := check_PatternWF Pexp \u03c3 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 \u03c3 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 [\u2190Nat.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 \u03c3 => u.val\n\n  def check_PatternWF_GProd {p : Fin n \u2192 Fin n} (Pexp : GProd n) (\u03c3 : Bijective p) : Maybe (PatternWF_GProd Pexp) \u03c3 :=\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 \u03c3 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 : \u2203 \u03c3 : Bijective p, PatternWF_GProd Pexp \u03c3\n\n  def mapping_from_list (l : List (Fin n)) (length_eq : l.length = n) : Fin n \u2192 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 : \u2200 {i j}, l.get i = l.get j \u2192 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 `(\ud835\udd5c, E, H)`, and `F` is a normed vector space over `\ud835\udd5c`, 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`\u03a3 (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 `\ud835\udd5c`, 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c F] \nwhere\n  coord_change : \u21a5(charted_space.atlas H M) \u2192 \u21a5(charted_space.atlas H M) \u2192 H \u2192 F \u2192 F\n  coord_change_self : \u2200 (i : \u21a5(charted_space.atlas H M)) (x : H),\n  x \u2208 local_equiv.target (local_homeomorph.to_local_equiv (subtype.val i)) \u2192 \u2200 (v : F), coord_change i i x v = v\n  coord_change_comp : \u2200 (i j k : \u21a5(charted_space.atlas H M)) (x : H),\n  x \u2208\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)))) \u2192\n    \u2200 (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 : \u2200 (i j : \u21a5(charted_space.atlas H M)),\n  times_cont_diff_on \ud835\udd5c \u22a4\n    (fun (p : E \u00d7 F) => coord_change i j (coe_fn (model_with_corners.symm I) (prod.fst p)) (prod.snd p))\n    (set.prod\n      (\u21d1I ''\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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c F] : basic_smooth_bundle_core I M F :=\n  basic_smooth_bundle_core.mk (fun (i j : \u21a5(charted_space.atlas H M)) (x : H) (v : F) => v) sorry sorry sorry\n\nnamespace basic_smooth_bundle_core\n\n\nprotected instance inhabited {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c F] (Z : basic_smooth_bundle_core I M F) : topological_fiber_bundle_core (\u21a5(charted_space.atlas H M)) M F :=\n  topological_fiber_bundle_core.mk\n    (fun (i : \u21a5(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 : \u21a5(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c F] (Z : basic_smooth_bundle_core I M F) (i : \u21a5(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c F] (Z : basic_smooth_bundle_core I M F) {e : local_homeomorph M H} (he : e \u2208 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c F] (Z : basic_smooth_bundle_core I M F) (e : local_homeomorph M H) (he : e \u2208 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) \u207b\u00b9'\n    local_equiv.source (local_homeomorph.to_local_equiv e) := sorry\n\n@[simp] theorem chart_target {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c F] (Z : basic_smooth_bundle_core I M F) (e : local_homeomorph M H) (he : e \u2208 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c 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 \u2245 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 \u2245 Y` is not empty. -/\ndef IsIsomorphic : C \u2192 C \u2192 Prop := fun X Y => Nonempty (X \u2245 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 := \u27e8fun X => \u27e8Iso.refl X\u27e9, fun \u27e8\u03b1\u27e9 => \u27e8\u03b1.symm\u27e9, fun \u27e8\u03b1\u27e9 \u27e8\u03b2\u27e9 => \u27e8\u03b1.trans \u03b2\u27e9\u27e9\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} \u2964 Type u where\n  obj C := Quotient (isIsomorphicSetoid C.\u03b1)\n  map {C D} F := Quot.map F.obj fun X Y \u27e8f\u27e9 => \u27e8F.mapIso f\u27e9\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    \u00b7 intro _ _ p\n      simp only [types_id_apply]\n    \u00b7 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    \u00b7 intro _ _ _\n      simp only [types_id_apply]\n    \u00b7 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 {\u03b1} (\u03b2 : \u03b1 \u2192 Type _) [DecidableEq \u03b1] [(x : \u03b1) \u2192 DecidableEq (\u03b2 x)] : DecidableEq ((x : \u03b1) \u00d7 \u03b2 x)\n| a\u2081, a\u2082 =>\n  match a\u2081, a\u2082, inferInstanceAs (Decidable (a\u2081.fst = a\u2082.fst)) with\n  | \u27e8_,y\u2081\u27e9, \u27e8_,y\u2082\u27e9, isTrue rfl =>\n    if h : y\u2081 = y\u2082 then\n      isTrue <| Sigma.eq rfl (heq_of_eq h)\n    else\n      isFalse fun | rfl => h rfl\n  | \u27e8_,_\u27e9, \u27e8_,_\u27e9, isFalse hne => isFalse fun | rfl => hne rfl\n\nclass Finite (\u03b1 : Type _) extends Array \u03b1 where\n  find : \u03b1 \u2192 Fin toArray.size\n  find_eq_iff_get_eq (x : \u03b1) (i : Fin toArray.size) : find x = i \u2194 toArray.get i = x\n  decEq : DecidableEq \u03b1 := by infer_instance\n\nattribute [instance] Finite.decEq\n\nnamespace Finite\nvariable (\u03b1) [inst : Finite \u03b1]\n\nprotected abbrev size := inst.toArray.size\n\nprotected abbrev get := inst.toArray.get\n\ntheorem get_find (x : \u03b1) : Finite.get \u03b1 (Finite.find x) = x := by\n  rw [\u2190find_eq_iff_get_eq]\n\ntheorem find_get (i : Fin (Finite.size \u03b1)) : Finite.find (Finite.get \u03b1 i) = i := by\n  rw [find_eq_iff_get_eq]\n\nprotected def toEquiv : Equiv \u03b1 (Fin (Finite.size \u03b1)) where\n  fwd := Finite.find\n  rev := Finite.get \u03b1\n  spec {x i} := Finite.find_eq_iff_get_eq x i\n\nprotected def ofEquiv {\u03b1 n} [DecidableEq \u03b1] (e : Equiv \u03b1 (Fin n)) : Finite \u03b1 where\n  toArray := Array.ofFun e.rev\n  find x := (Array.ofFun_size e.rev).symm \u25b8 e.fwd x\n  find_eq_iff_get_eq x i := by\n    constr\n    \u00b7 intro h\n      rw [Array.ofFun_get]\n      rw [\u2190e.spec]\n      rw [\u2190h]\n      elim_casts\n    \u00b7 intro h\n      rw [Array.ofFun_get] at h\n      rw [\u2190e.spec] at h\n      clean\n      rw [h]\n      elim_casts\n\nprotected abbrev all {\u03b1} [Finite \u03b1] (p : \u03b1 \u2192 Bool) : Bool :=\n  Fin.all fun i => p (Finite.get \u03b1 i)\n\ntheorem forall_eq_true_of_all_eq_true {\u03b1} [Finite \u03b1] {p : \u03b1 \u2192 Bool} : Finite.all p = true \u2192 \u2200 x, p x = true := by\n  intro h x\n  have hall := Fin.forall_eq_true_of_all_eq_true h\n  rw [\u2190hall (Finite.find x)]\n  rw [Finite.get_find]\n\ntheorem exists_eq_false_of_all_eq_false {\u03b1} [Finite \u03b1] {p : \u03b1 \u2192 Bool} : Finite.all p = false \u2192 \u2203 x, p x = false := by\n  intro h\n  match Fin.exists_eq_false_of_all_eq_false h with\n  | \u27e8i, h\u27e9 => exists (Finite.get \u03b1 i)\n\ninstance (p : \u03b1 \u2192 Prop) [DecidablePred p] : Decidable (\u2200 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    | \u27e8x, hx\u27e9 => 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 : \u03b1 \u2192 Prop) [DecidablePred p] : decide (\u2200 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    | \u27e8x, hx\u27e9 =>\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 {\u03b1} (p : \u03b1 \u2192 Bool) [Finite \u03b1] [(x : \u03b1) \u2192 DecLift (p x)] : DecLift (Finite.all p) where\n  toProp := \u2200 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 {\u03b1} [Finite \u03b1] (p : \u03b1 \u2192 Bool) : Bool :=\n  Fin.any fun i => p (Finite.get \u03b1 i)\n\ntheorem exists_eq_true_of_any_eq_true {\u03b1} [Finite \u03b1] {p : \u03b1 \u2192 Bool} : Finite.any p = true \u2192 \u2203 x, p x = true := by\n  intro h\n  match Fin.exists_eq_true_of_any_eq_true h with\n  | \u27e8i, h\u27e9 => exists (Finite.get \u03b1 i)\n\ntheorem forall_eq_false_of_any_eq_false {\u03b1} [Finite \u03b1] {p : \u03b1 \u2192 Bool} : Finite.any p = false \u2192 \u2200 x, p x = false := by\n  intro h x\n  have hany := Fin.forall_eq_false_of_any_eq_false h\n  rw [\u2190hany (Finite.find x)]\n  rw [Finite.get_find]\n\ninstance (p : \u03b1 \u2192 Prop) [DecidablePred p] : Decidable (\u2203 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    | \u27e8x, hx\u27e9 => exists x; exact of_decide_eq_true hx\n  | false => isFalse $ by\n    intro \u27e8x, hx\u27e9\n    absurd hx\n    apply of_decide_eq_false\n    exact forall_eq_false_of_any_eq_false hany ..\n\ntheorem decide_exists (p : \u03b1 \u2192 Prop) [DecidablePred p] : decide (\u2203 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    | \u27e8x, hx\u27e9 =>\n      exists x\n      exact of_decide_eq_true hx\n  | false =>\n    apply decide_eq_false\n    intro \u27e8x, hx\u27e9\n    absurd forall_eq_false_of_any_eq_false h x\n    rw [decide_eq_true hx]\n    trivial\n\ninstance {\u03b1} (p : \u03b1 \u2192 Bool) [Finite \u03b1] [(x : \u03b1) \u2192 DecLift (p x)] : DecLift (Finite.any p) where\n  toProp := \u2203 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 (\u03b1) [Finite \u03b1] : Finite (Option \u03b1) :=\n  let e\u2081 := Fin.equivOption (Finite.size \u03b1)\n  let e\u2082 := Option.equiv (Finite.toEquiv \u03b1)\n  Finite.ofEquiv <| Equiv.comp e\u2081.inv e\u2082\n\ninstance (\u03b1 \u03b2) [DecidableEq \u03b2] [Finite \u03b1] [Finite \u03b2] : Finite (\u03b1 \u2295 \u03b2) :=\n  let e\u2081 := Fin.equivSum (Finite.size \u03b1) (Finite.size \u03b2)\n  let e\u2082 := Sum.equiv (Finite.toEquiv \u03b1) (Finite.toEquiv \u03b2)\n  Finite.ofEquiv <| Equiv.comp e\u2081.inv e\u2082\n\ninstance (\u03b1 \u03b2) [DecidableEq \u03b2] [Finite \u03b1] [Finite \u03b2] : Finite (\u03b1 \u00d7 \u03b2) :=\n  let e\u2081 := Fin.equivProd (Finite.size \u03b1) (Finite.size \u03b2)\n  let e\u2082 := Prod.equiv (Finite.toEquiv \u03b1) (Finite.toEquiv \u03b2)\n  Finite.ofEquiv <| Equiv.comp e\u2081.inv e\u2082\n\ninstance {\u03b1 : Type _} (\u03b2 : \u03b1 \u2192 Type _) [Finite \u03b1] [(x : \u03b1) \u2192 Finite (\u03b2 x)] : Finite ((x : \u03b1) \u00d7 (\u03b2 x)) :=\n  let e\u2081 := Fin.equivSigma (fun i => Finite.size (\u03b2 ((Finite.toEquiv \u03b1).rev i)))\n  let e\u2082 := Sigma.equiv (Finite.toEquiv \u03b1).inv (fun i => (Finite.toEquiv (\u03b2 ((Finite.toEquiv \u03b1).inv.fwd i))).inv)\n  Finite.ofEquiv <| Equiv.comp e\u2081.inv e\u2082.inv\n\ninstance (\u03b1 \u03b2) [Finite \u03b1] [DecidableEq \u03b2] : DecidableEq (\u03b1 \u2192 \u03b2)\n| f\u2081, f\u2082 =>\n  if h : \u2200 x, f\u2081 x = f\u2082 x then\n    isTrue <| funext h\n  else\n    isFalse fun | rfl => h fun _ => rfl\n\ninstance (\u03b1 \u03b2) [DecidableEq \u03b2] [Finite \u03b1] [Finite \u03b2] : Finite (\u03b1 \u2192 \u03b2) :=\n  let e\u2081 := Fin.equivFun (Finite.size \u03b2) (Finite.size \u03b1)\n  let e\u2082 := Fun.equivND (Finite.toEquiv \u03b1) (Finite.toEquiv \u03b2)\n  Finite.ofEquiv <| Equiv.comp e\u2081.inv e\u2082\n\ninstance {\u03b1} (\u03b2 : \u03b1 \u2192 Type _) [Finite \u03b1] [(x : \u03b1) \u2192 DecidableEq (\u03b2 x)] : DecidableEq ((x : \u03b1) \u2192 \u03b2 x)\n| f\u2081, f\u2082 =>\n  if h : \u2200 x, f\u2081 x = f\u2082 x then\n    isTrue <| funext h\n  else\n    isFalse fun | rfl => h fun _ => rfl\n\ninstance {\u03b1 : Type _} (\u03b2 : \u03b1 \u2192 Type _) [Finite \u03b1] [(x : \u03b1) \u2192 Finite (\u03b2 x)] : Finite ((x : \u03b1) \u2192 \u03b2 x) :=\n  let e\u2081 := Fin.equivPi (fun i => Finite.size (\u03b2 ((Finite.toEquiv \u03b1).rev i)))\n  let e\u2082 := Fun.equiv (Finite.toEquiv \u03b1).inv (fun i => (Finite.toEquiv (\u03b2 ((Finite.toEquiv \u03b1).inv.fwd i))).inv)\n  Finite.ofEquiv <| Equiv.comp e\u2081.inv e\u2082.inv\n\ninstance (p : \u03b1 \u2192 Prop) [DecidablePred p] [Finite \u03b1] : Finite (Subtype p) :=\n  let e\u2081 := Fin.equivSubtype fun i => p ((Finite.toEquiv \u03b1).rev i)\n  let e\u2082 := Subtype.equiv (Finite.toEquiv \u03b1) (by intro; simp [Equiv.rev_fwd])\n  Finite.ofEquiv <| Equiv.comp e\u2081.inv e\u2082\n\ninstance (s : Setoid \u03b1) [DecidableRel s.r] [Finite \u03b1] : Finite (Quotient s) :=\n  let s' : Setoid (Fin (Finite.size \u03b1)) := {\n    r := fun i j => (Finite.toEquiv \u03b1).rev i \u2248 (Finite.toEquiv \u03b1).rev j\n    iseqv := Equivalence.mk (fun _ => s.refl _) s.symm s.trans\n  }\n  let e\u2081 := Fin.equivQuotient s'\n  let e\u2082 := Quotient.equiv (s\u2081:=s) (s\u2082:=s') (Finite.toEquiv \u03b1) $ by\n    intro x y\n    constr\n    \u00b7 intro h\n      show (Finite.toEquiv \u03b1).rev ((Finite.toEquiv \u03b1).fwd x) \u2248 (Finite.toEquiv \u03b1).rev ((Finite.toEquiv \u03b1).fwd y)\n      rw [Equiv.rev_fwd, Equiv.rev_fwd]\n      exact h\n    \u00b7 intro h\n      have h : (Finite.toEquiv \u03b1).rev ((Finite.toEquiv \u03b1).fwd x) \u2248 (Finite.toEquiv \u03b1).rev ((Finite.toEquiv \u03b1).fwd y) := h\n      rw [Equiv.rev_fwd, Equiv.rev_fwd] at h\n      exact h\n  Finite.ofEquiv <| Equiv.comp e\u2081.inv e\u2082\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 := \u03bb 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}) := \u27e8X.presheaf, X.is_sheaf\u27e9\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 \u27e8\u27e8\u27e9\u27e9 }\n\ninstance : inhabited (SheafedSpace (discrete _root_.unit)) := \u27e8unit (Top.of pempty)\u27e9\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) \u2964 (PresheafedSpace.{v} C) :=\ninduced_functor _\n\ninstance is_PresheafedSpace_iso {X Y : SheafedSpace.{v} C} (f : X \u27f6 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  ((\ud835\udfd9 X) : X \u27f6 X).base = (\ud835\udfd9 (X : Top.{v})) := rfl\n\nlemma id_c (X : SheafedSpace C) :\n  ((\ud835\udfd9 X) : X \u27f6 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  ((\ud835\udfd9 X) : X \u27f6 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 \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).base = f.base \u226b g.base := rfl\n\n@[simp] lemma comp_c_app {X Y Z : SheafedSpace C} (\u03b1 : X \u27f6 Y) (\u03b2 : Y \u27f6 Z) (U) :\n  (\u03b1 \u226b \u03b2).c.app U = (\u03b2.c).app U \u226b (\u03b1.c).app (op ((opens.map (\u03b2.base)).obj (unop U)))\n:= rfl\n\nlemma comp_c_app' {X Y Z : SheafedSpace C} (\u03b1 : X \u27f6 Y) (\u03b2 : Y \u27f6 Z) (U) :\n  (\u03b1 \u226b \u03b2).c.app (op U) = (\u03b2.c).app (op U) \u226b (\u03b1.c).app (op ((opens.map (\u03b2.base)).obj U))\n:= rfl\n\nlemma congr_app {X Y : SheafedSpace C} {\u03b1 \u03b2 : X \u27f6 Y} (h : \u03b1 = \u03b2) (U) :\n  \u03b1.c.app U = \u03b2.c.app U \u226b 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 \u2964 Top :=\n{ obj := \u03bb X, (X : Top.{v}),\n  map := \u03bb 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 \u27f6 (X : Top.{v})} (h : open_embedding f) : SheafedSpace C :=\n{ is_sheaf := \u03bb \u03b9 \ud835\udcb0, \u27e8is_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 \ud835\udcb0).symm\u27e9,\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 \u22a4) \u2245 X :=\nforget_to_PresheafedSpace.preimage_iso X.to_PresheafedSpace.restrict_top_iso\n\n/--\nThe global sections, notated Gamma.\n-/\ndef \u0393 : (SheafedSpace C)\u1d52\u1d56 \u2964 C :=\nforget_to_PresheafedSpace.op \u22d9 PresheafedSpace.\u0393\n\nlemma \u0393_def : (\u0393 : _ \u2964 C) = forget_to_PresheafedSpace.op \u22d9 PresheafedSpace.\u0393 := rfl\n\n@[simp] lemma \u0393_obj (X : (SheafedSpace C)\u1d52\u1d56) : \u0393.obj X = (unop X).presheaf.obj (op \u22a4) := rfl\n\nlemma \u0393_obj_op (X : SheafedSpace C) : \u0393.obj (op X) = X.presheaf.obj (op \u22a4) := rfl\n\n@[simp] lemma \u0393_map {X Y : (SheafedSpace C)\u1d52\u1d56} (f : X \u27f6 Y) :\n  \u0393.map f = f.unop.c.app (op \u22a4) := rfl\n\nlemma \u0393_map_op {X Y : SheafedSpace C} (f : X \u27f6 Y) :\n  \u0393.map f.op = f.c.app (op \u22a4) := rfl\n\nnoncomputable\ninstance [has_limits C] : creates_colimits (forget_to_PresheafedSpace : SheafedSpace C \u2964 _) :=\n\u27e8\u03bb J hJ, by exactI \u27e8\u03bb K, creates_colimit_of_fully_faithful_of_iso\n  \u27e8(PresheafedSpace.colimit_cocone (K \u22d9 forget_to_PresheafedSpace)).X,\n    limit_is_sheaf _ (\u03bb j, sheaf.pushforward_sheaf_of_sheaf _ (K.obj (unop j)).2)\u27e9\n  (colimit.iso_colimit_cocone \u27e8_, PresheafedSpace.colimit_cocone_is_colimit _\u27e9).symm\u27e9\u27e9\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\u00f6lzl, 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\u2082` 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\u2082_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\u2082 (algebra_map R A) a p) = eval\u2082 (algebra_map R B) (coe_fn f a) p :=\n  sorry\n\n@[simp] theorem eval\u2082_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\u2082 (algebra_map R A) (coe_fn f X) p = coe_fn f p :=\n  sorry\n\n@[simp] theorem ring_hom_eval\u2082_algebra_map_int {R : Type u_1} {S : Type u_2} [ring R] [ring S]\n    (p : polynomial \u2124) (f : R \u2192+* S) (r : R) :\n    coe_fn f (eval\u2082 (algebra_map \u2124 R) r p) = eval\u2082 (algebra_map \u2124 S) (coe_fn f r) p :=\n  alg_hom_eval\u2082_algebra_map p (ring_hom.to_int_alg_hom f) r\n\n@[simp] theorem eval\u2082_algebra_map_int_X {R : Type u_1} [ring R] (p : polynomial \u2124)\n    (f : polynomial \u2124 \u2192+* R) : eval\u2082 (algebra_map \u2124 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\u2082_comp {R : Type u} {S : Type v} [comm_semiring R] {p : polynomial R} {q : polynomial R}\n    [comm_semiring S] (f : R \u2192+* S) {x : S} : eval\u2082 f x (comp p q) = eval\u2082 f (eval\u2082 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\u2082_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 \u2192 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\u2082 C p q)\n        (funext fun (q : polynomial R) => comp.equations._eqn_1 q p)))\n    (eval\u2082.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\u2082_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\u2082 (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\u2082_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\u2082_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 : \u2115} {r : R} :\n    coe_fn (aeval x) (coe_fn (monomial n) r) = coe_fn (algebra_map R A) r * x ^ n :=\n  eval\u2082_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 : \u2115} : coe_fn (aeval x) (X ^ n) = x ^ n :=\n  eval\u2082_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 : \u2115) : coe_fn (aeval x) \u2191n = \u2191n :=\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\u2082_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    (\u03c6 : alg_hom R (polynomial R) A) (p : polynomial R) :\n    coe_fn \u03c6 p = eval\u2082 (algebra_map R A) (coe_fn \u03c6 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) : \u21d1(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 : \u2115) :\n    comp (p ^ k) q = comp p q ^ k :=\n  sorry\n\ntheorem is_root_of_eval\u2082_map_eq_zero {R : Type u} {S : Type v} [comm_semiring R] {p : polynomial R}\n    [comm_ring S] {f : R \u2192+* S} (hf : function.injective \u21d1f) {r : R} :\n    eval\u2082 f (coe_fn f r) p = 0 \u2192 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 \u21d1(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\u2082_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 : \u2115) (dvd_eval : p \u2223 eval z f)\n    (dvd_terms : \u2200 (j : \u2115), j \u2260 i \u2192 p \u2223 coeff f j * z ^ j) : p \u2223 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 : \u2115) (hr : is_root f r) (h : \u2200 (j : \u2115), j \u2260 i \u2192 p \u2223 coeff f j * r ^ j) :\n    p \u2223 coeff f i * r ^ i :=\n  dvd_term_of_dvd_eval_of_dvd_terms i (Eq.symm hr \u25b8 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 : \u2115) => coeff p i \u2022 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 : \u2115} (hn : nat_degree p < n) (x : S) :\n    coe_fn (aeval x) p = finset.sum (finset.range n) fun (i : \u2115) => coeff p i \u2022 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    \u00acis_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 : \u2115) (b : R) => b \u2022 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 \u2192 imp \u2192 imp\n| Modify : (st \u2192 st) \u2192 imp\n| If : (st \u2192 Prop) \u2192 imp \u2192 imp \u2192 imp\n| While : (st \u2192 Prop) \u2192 imp \u2192 imp\n\ndef Skip {\u03b1 : Type u}: imp \u03b1 := imp.Modify id\n\ndef repeat {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1) : \u03b1 \u2192 \u2115 \u2192 \u03b1\n| v 0 := v\n| v (nat.succ a) := repeat (f v) a\n\ndef imp_repeat {\u03b1 : Type u} (f : imp \u03b1): \u2115 \u2192 imp \u03b1 := repeat (imp.Seq f) Skip\n\nlemma repeat_succ {\u03b1 : Type u} (f : \u03b1 \u2192 \u03b1) (s : \u03b1) (n : \u2115):\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Alex J. Best, Ya\u00ebl 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* `\u2192+*o`: Ordered ring homomorphisms.\n* `\u2243+*o`: Ordered ring isomorphisms.\n\n## Tags\n\nordered ring homomorphism, order homomorphism\n-/\n\n\nopen Function\n\nvariable {F \u03b1 \u03b2 \u03b3 \u03b4 : Type _}\n\n#print OrderRingHom /-\n/-- `order_ring_hom \u03b1 \u03b2` is the type of monotone semiring homomorphisms from `\u03b1` to `\u03b2`.\n\nWhen possible, instead of parametrizing results over `(f : order_ring_hom \u03b1 \u03b2)`,\nyou should parametrize over `(F : Type*) [order_ring_hom_class F \u03b1 \u03b2] (f : F)`.\n\nWhen you extend this structure, make sure to extend `order_ring_hom_class`. -/\nstructure OrderRingHom (\u03b1 \u03b2 : Type _) [NonAssocSemiring \u03b1] [Preorder \u03b1] [NonAssocSemiring \u03b2]\n  [Preorder \u03b2] extends \u03b1 \u2192+* \u03b2 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: \u00abexpr \u2192+*o \u00bb\ninfixl:25 \" \u2192+*o \" => OrderRingHom\n\n/- warning: order_ring_iso -> OrderRingIso is a dubious translation:\nlean 3 declaration is\n  forall (\u03b1 : Type.{u1}) (\u03b2 : Type.{u2}) [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2], Sort.{max (succ u1) (succ u2)}\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) (\u03b2 : Type.{u2}) [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Mul.{u2} \u03b2] [_inst_3 : Add.{u1} \u03b1] [_inst_4 : Add.{u2} \u03b2] [_inst_5 : LE.{u1} \u03b1] [_inst_6 : LE.{u2} \u03b2], Sort.{max (succ u1) (succ u2)}\nCase conversion may be inaccurate. Consider using '#align order_ring_iso OrderRingIso\u2093'. -/\n/-- `order_ring_hom \u03b1 \u03b2` is the type of order-preserving semiring isomorphisms between `\u03b1` and `\u03b2`.\n\nWhen possible, instead of parametrizing results over `(f : order_ring_iso \u03b1 \u03b2)`,\nyou should parametrize over `(F : Type*) [order_ring_iso_class F \u03b1 \u03b2] (f : F)`.\n\nWhen you extend this structure, make sure to extend `order_ring_iso_class`. -/\nstructure OrderRingIso (\u03b1 \u03b2 : Type _) [Mul \u03b1] [Add \u03b1] [LE \u03b1] [Mul \u03b2] [Add \u03b2] [LE \u03b2] extends\n  \u03b1 \u2243+* \u03b2 where\n  map_le_map_iff' {a b : \u03b1} : to_fun a \u2264 to_fun b \u2194 a \u2264 b\n#align order_ring_iso OrderRingIso\n\n-- mathport name: \u00abexpr \u2243+*o \u00bb\ninfixl:25 \" \u2243+*o \" => OrderRingIso\n\n#print OrderRingHomClass /-\n/-- `order_ring_hom_class F \u03b1 \u03b2` 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 _) (\u03b1 \u03b2 : outParam <| Type _) [NonAssocSemiring \u03b1] [Preorder \u03b1]\n  [NonAssocSemiring \u03b2] [Preorder \u03b2] extends RingHomClass F \u03b1 \u03b2 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 \u03b1 \u03b2` 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 _) (\u03b1 \u03b2 : outParam (Type _)) [Mul \u03b1] [Add \u03b1] [LE \u03b1] [Mul \u03b2]\n  [Add \u03b2] [LE \u03b2] extends RingEquivClass F \u03b1 \u03b2 where\n  map_le_map_iff (f : F) {a b : \u03b1} : f a \u2264 f b \u2194 a \u2264 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 \u03b1]\n    [Preorder \u03b1] [NonAssocSemiring \u03b2] [Preorder \u03b2] [OrderRingHomClass F \u03b1 \u03b2] :\n    OrderAddMonoidHomClass F \u03b1 \u03b2 :=\n  { \u2039OrderRingHomClass F \u03b1 \u03b2\u203a 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 \u03b1]\n    [Preorder \u03b1] [NonAssocSemiring \u03b2] [Preorder \u03b2] [OrderRingHomClass F \u03b1 \u03b2] :\n    OrderMonoidWithZeroHomClass F \u03b1 \u03b2 :=\n  { \u2039OrderRingHomClass F \u03b1 \u03b2\u203a 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 \u03b1] [Add \u03b1] [LE \u03b1] [Mul \u03b2] [Add \u03b2]\n    [LE \u03b2] [OrderRingIsoClass F \u03b1 \u03b2] : OrderIsoClass F \u03b1 \u03b2 :=\n  { \u2039OrderRingIsoClass F \u03b1 \u03b2\u203a 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}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u3} \u03b2] [_inst_4 : Preorder.{u3} \u03b2] [_inst_5 : OrderRingIsoClass.{u1, u2, u3} F \u03b1 \u03b2 (Distrib.toHasMul.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toHasAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Distrib.toHasMul.{u3} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 _inst_3))) (Distrib.toHasAdd.{u3} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 _inst_3))) (Preorder.toLE.{u3} \u03b2 _inst_4)], OrderRingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4\nbut is expected to have type\n  forall {F : Type.{u1}} {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {_inst_1 : NonAssocSemiring.{u2} \u03b1} {_inst_2 : Preorder.{u2} \u03b1} {_inst_3 : NonAssocSemiring.{u3} \u03b2} {_inst_4 : Preorder.{u3} \u03b2} [_inst_5 : OrderRingIsoClass.{u1, u2, u3} F \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Preorder.toLE.{u2} \u03b1 _inst_2) (NonUnitalNonAssocSemiring.toMul.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 _inst_3)) (Distrib.toAdd.{u3} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u3} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} \u03b2 _inst_3))) (Preorder.toLE.{u3} \u03b2 _inst_4)], OrderRingHomClass.{u1, u2, u3} F \u03b1 \u03b2 _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\u2093'. -/\n-- See note [lower instance priority]\ninstance (priority := 100) OrderRingIsoClass.toOrderRingHomClass [NonAssocSemiring \u03b1] [Preorder \u03b1]\n    [NonAssocSemiring \u03b2] [Preorder \u03b2] [OrderRingIsoClass F \u03b1 \u03b2] : OrderRingHomClass F \u03b1 \u03b2 :=\n  { \u2039OrderRingIsoClass F \u03b1 \u03b2\u203a with Monotone := fun f => OrderHomClass.mono f }\n#align order_ring_iso_class.to_order_ring_hom_class OrderRingIsoClass.toOrderRingHomClass\n\ninstance [NonAssocSemiring \u03b1] [Preorder \u03b1] [NonAssocSemiring \u03b2] [Preorder \u03b2]\n    [OrderRingHomClass F \u03b1 \u03b2] : CoeTC F (\u03b1 \u2192+*o \u03b2) :=\n  \u27e8fun f => \u27e8f, OrderHomClass.mono f\u27e9\u27e9\n\ninstance [Mul \u03b1] [Add \u03b1] [LE \u03b1] [Mul \u03b2] [Add \u03b2] [LE \u03b2] [OrderRingIsoClass F \u03b1 \u03b2] :\n    CoeTC F (\u03b1 \u2243+*o \u03b2) :=\n  \u27e8fun f => \u27e8f, fun a b => map_le_map_iff f\u27e9\u27e9\n\n/-! ### Ordered ring homomorphisms -/\n\n\nnamespace OrderRingHom\n\nvariable [NonAssocSemiring \u03b1] [Preorder \u03b1]\n\nsection Preorder\n\nvariable [NonAssocSemiring \u03b2] [Preorder \u03b2] [NonAssocSemiring \u03b3] [Preorder \u03b3] [NonAssocSemiring \u03b4]\n  [Preorder \u03b4]\n\n#print OrderRingHom.toOrderAddMonoidHom /-\n/-- Reinterpret an ordered ring homomorphism as an ordered additive monoid homomorphism. -/\ndef toOrderAddMonoidHom (f : \u03b1 \u2192+*o \u03b2) : \u03b1 \u2192+o \u03b2 :=\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 : \u03b1 \u2192+*o \u03b2) : \u03b1 \u2192*\u2080o \u03b2 :=\n  { f with }\n#align order_ring_hom.to_order_monoid_with_zero_hom OrderRingHom.toOrderMonoidWithZeroHom\n-/\n\ninstance : OrderRingHomClass (\u03b1 \u2192+*o \u03b2) \u03b1 \u03b2\n    where\n  coe f := f.toFun\n  coe_injective' f g h := by obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := f <;> obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := 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 (\u03b1 \u2192+*o \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\n  \u27e8fun f => f.toFun\u27e9\n\n/- warning: order_ring_hom.to_fun_eq_coe -> OrderRingHom.toFun_eq_coe is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (RingHom.toFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3 (OrderRingHom.toRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (OneHom.toFun.{u2, u1} \u03b1 \u03b2 (MulOneClass.toOne.{u2} \u03b1 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1))) (MulOneClass.toOne.{u1} \u03b2 (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3))) (MonoidHom.toOneHom.{u2, u1} \u03b1 \u03b2 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) (RingHom.toMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3 (OrderRingHom.toRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 f)))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (f : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) f) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\ntheorem toFun_eq_coe (f : \u03b1 \u2192+*o \u03b2) : f.toFun = \u21d1f :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] {f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4} {g : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4}, (forall (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) g a)) -> (Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] {f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4} {g : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4}, (forall (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)))) f a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)))) g a)) -> (Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f g)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.ext OrderRingHom.ext\u2093'. -/\n@[ext]\ntheorem ext {f g : \u03b1 \u2192+*o \u03b2} (h : \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (OrderRingHom.toRingHom.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (RingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) (OrderRingHom.toRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 f) (RingHomClass.toRingHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem toRingHom_eq_coe (f : \u03b1 \u2192+*o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (OrderRingHom.toOrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (OrderAddMonoidHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (OrderAddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))) (OrderRingHom.toOrderAddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 f) (OrderAddMonoidHomClass.toOrderAddMonoidHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem toOrderAddMonoidHom_eq_coe (f : \u03b1 \u2192+*o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (OrderRingHom.toOrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (OrderMonoidWithZeroHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2], (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) -> (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.to_order_monoid_with_zero_hom_eq_coe OrderRingHom.toOrderMonoidWithZeroHom\u2093'. -/\n@[simp]\ntheorem toOrderMonoidWithZeroHom (f : \u03b1 \u2192+*o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (RingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) \u03b1 \u03b2 _inst_1 _inst_3 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3)))) (RingHomClass.toRingHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem coe_coe_ringHom (f : \u03b1 \u2192+*o \u03b2) : \u21d1(f : \u03b1 \u2192+* \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (fun (_x : OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) => \u03b1 -> \u03b2) (OrderAddMonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (OrderAddMonoidHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderAddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderAddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderAddMonoidHom.instOrderAddMonoidHomClassOrderAddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))))) (OrderAddMonoidHomClass.toOrderAddMonoidHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem coe_coe_orderAddMonoidHom (f : \u03b1 \u2192+*o \u03b2) : \u21d1(f : \u03b1 \u2192+o \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (fun (_x : OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) => \u03b1 -> \u03b2) (OrderMonoidWithZeroHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (OrderMonoidWithZeroHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) \u03b1 \u03b2 _inst_2 _inst_4 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) (OrderMonoidWithZeroHomClass.toOrderMonoidHomClass.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3) (OrderMonoidWithZeroHom.instOrderMonoidWithZeroHomClassOrderMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3))))) (OrderMonoidWithZeroHomClass.toOrderMonoidWithZeroHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem coe_coe_orderMonoidWithZeroHom (f : \u03b1 \u2192+*o \u03b2) : \u21d1(f : \u03b1 \u2192*\u2080o \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (fun (_x : RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) => \u03b1 -> \u03b2) (RingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (RingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_3) (RingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f) a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : \u03b1) => \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) \u03b1 \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3) \u03b1 \u03b2 _inst_1 _inst_3 (RingHom.instRingHomClassRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_3)))) (RingHomClass.toRingHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_3 (OrderRingHomClass.toRingHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)) f) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[norm_cast]\ntheorem coe_ringHom_apply (f : \u03b1 \u2192+*o \u03b2) (a : \u03b1) : (f : \u03b1 \u2192+* \u03b2) 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (fun (_x : OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) => \u03b1 -> \u03b2) (OrderAddMonoidHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderAddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3))))) (OrderAddMonoidHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f) a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderAddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderAddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderAddMonoidHom.instOrderAddMonoidHomClassOrderAddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3))))))) (OrderAddMonoidHomClass.toOrderAddMonoidHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)) f) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[norm_cast]\ntheorem coe_orderAddMonoidHom_apply (f : \u03b1 \u2192+*o \u03b2) (a : \u03b1) : (f : \u03b1 \u2192+o \u03b2) 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (fun (_x : OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) => \u03b1 -> \u03b2) (OrderMonoidWithZeroHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderMonoidWithZeroHom.{u1, u2} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3)) (OrderMonoidWithZeroHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b2 _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.orderRingHomClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4))))) f) a) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) \u03b1 \u03b2 _inst_2 _inst_4 (MulZeroOneClass.toMulOneClass.{u2} \u03b1 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1)) (MulZeroOneClass.toMulOneClass.{u1} \u03b2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) (OrderMonoidWithZeroHomClass.toOrderMonoidHomClass.{max u2 u1, u2, u1} (OrderMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3)) \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3) (OrderMonoidWithZeroHom.instOrderMonoidWithZeroHomClassOrderMonoidWithZeroHom.{u2, u1} \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3))))) (OrderMonoidWithZeroHomClass.toOrderMonoidWithZeroHom.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (NonAssocSemiring.toMulZeroOneClass.{u2} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b2 _inst_3) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)) f) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[norm_cast]\ntheorem coe_orderMonoidWithZeroHom_apply (f : \u03b1 \u2192+*o \u03b2) (a : \u03b1) : (f : \u03b1 \u2192*\u2080o \u03b2) 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f)) -> (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (f' : \u03b1 -> \u03b2), (Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddMonoidWithOne.toAddMonoid.{u2} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)))) f)) -> (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.copy OrderRingHom.copy\u2093'. -/\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 : \u03b1 \u2192+*o \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u03b1 \u2192+*o \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f)), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.copy.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 f f' h)) f'\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)))) f)), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)))) (OrderRingHom.copy.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem coe_copy (f : \u03b1 \u2192+*o \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) f' (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) f)), Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.copy.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 f f' h) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (f' : \u03b1 -> \u03b2) (h : Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) f' (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)))) f)), Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.copy.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\ntheorem copy_eq (f : \u03b1 \u2192+*o \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : f.copy f' h = f :=\n  FunLike.ext' h\n#align order_ring_hom.copy_eq OrderRingHom.copy_eq\n\nvariable (\u03b1)\n\n#print OrderRingHom.id /-\n/-- The identity as an ordered ring homomorphism. -/\nprotected def id : \u03b1 \u2192+*o \u03b1 :=\n  { RingHom.id _, OrderHom.id with }\n#align order_ring_hom.id OrderRingHom.id\n-/\n\ninstance : Inhabited (\u03b1 \u2192+*o \u03b1) :=\n  \u27e8OrderRingHom.id \u03b1\u27e9\n\n/- warning: order_ring_hom.coe_id -> OrderRingHom.coe_id is a dubious translation:\nlean 3 declaration is\n  forall (\u03b1 : Type.{u1}) [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (\u03b1 -> \u03b1) (coeFn.{succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (fun (_x : OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) => \u03b1 -> \u03b1) (OrderRingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) (id.{succ u1} \u03b1)\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b1) \u1fb0) (FunLike.coe.{succ u1, succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b1) _x) (RelHomClass.toFunLike.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2)))) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) (id.{succ u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_id OrderRingHom.coe_id\u2093'. -/\n@[simp]\ntheorem coe_id : \u21d1(OrderRingHom.id \u03b1) = id :=\n  rfl\n#align order_ring_hom.coe_id OrderRingHom.coe_id\n\nvariable {\u03b1}\n\n/- warning: order_ring_hom.id_apply -> OrderRingHom.id_apply is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (fun (_x : OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) => \u03b1 -> \u03b1) (OrderRingHom.hasCoeToFun.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2) a) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b1) a) (FunLike.coe.{succ u1, succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b1) _x) (RelHomClass.toFunLike.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1918 x._@.Mathlib.Order.Hom.Basic._hyg.1920) (OrderAddMonoidHomClass.toOrderHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2)))) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2) a) a\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.id_apply OrderRingHom.id_apply\u2093'. -/\n@[simp]\ntheorem id_apply (a : \u03b1) : OrderRingHom.id \u03b1 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (RingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (HasLiftT.mk.{succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (RingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (CoeTC\u2093.coe.{succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (RingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (RingHom.hasCoeT.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_1 (OrderRingHomClass.toRingHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.orderRingHomClass.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2))))) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) (RingHom.id.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (RingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) (RingHomClass.toRingHom.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_1 (OrderRingHomClass.toRingHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2)) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) (RingHom.id.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_ring_hom_id OrderRingHom.coe_RingHom_id\u2093'. -/\n@[simp]\ntheorem coe_RingHom_id : (OrderRingHom.id \u03b1 : \u03b1 \u2192+* \u03b1) = RingHom.id \u03b1 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (OrderAddMonoidHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderAddMonoidHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1))))) (HasLiftT.mk.{succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderAddMonoidHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1))))) (CoeTC\u2093.coe.{succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderAddMonoidHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1))))) (OrderAddMonoidHom.hasCoeT.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.orderRingHomClass.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2))))) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) (OrderAddMonoidHom.id.{u1} \u03b1 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (OrderAddMonoidHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1))))) (OrderAddMonoidHomClass.toOrderAddMonoidHom.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_2 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2)) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) (OrderAddMonoidHom.id.{u1} \u03b1 _inst_2 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_order_add_monoid_hom_id OrderRingHom.coe_OrderAddMonoidHom_id\u2093'. -/\n@[simp]\ntheorem coe_OrderAddMonoidHom_id : (OrderRingHom.id \u03b1 : \u03b1 \u2192+o \u03b1) = OrderAddMonoidHom.id \u03b1 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (OrderMonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderMonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (HasLiftT.mk.{succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderMonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (CoeTC\u2093.coe.{succ u1, succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderMonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (OrderMonoidWithZeroHom.hasCoeT.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.orderRingHomClass.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2))))) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) (OrderMonoidWithZeroHom.id.{u1} \u03b1 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (OrderMonoidWithZeroHom.{u1, u1} \u03b1 \u03b1 _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1)) (OrderMonoidWithZeroHomClass.toOrderMonoidWithZeroHom.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_2 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1) (OrderRingHomClass.toOrderMonoidWithZeroHomClass.{u1, u1, u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2)) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) (OrderMonoidWithZeroHom.id.{u1} \u03b1 _inst_2 (NonAssocSemiring.toMulZeroOneClass.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.coe_order_monoid_with_zero_hom_id OrderRingHom.coe_OrderMonoidWithZeroHom_id\u2093'. -/\n@[simp]\ntheorem coe_OrderMonoidWithZeroHom_id :\n    (OrderRingHom.id \u03b1 : \u03b1 \u2192*\u2080o \u03b1) = OrderMonoidWithZeroHom.id \u03b1 :=\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 : \u03b2 \u2192+*o \u03b3) (g : \u03b1 \u2192+*o \u03b2) : \u03b1 \u2192+*o \u03b3 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] [_inst_5 : NonAssocSemiring.{u3} \u03b3] [_inst_6 : Preorder.{u3} \u03b3] (f : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u3)} (\u03b1 -> \u03b3) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) => \u03b1 -> \u03b3) (OrderRingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g)) (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b2 -> \u03b3) (OrderRingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) f) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u3} \u03b2] [_inst_4 : Preorder.{u3} \u03b2] [_inst_5 : NonAssocSemiring.{u2} \u03b3] [_inst_6 : Preorder.{u2} \u03b3] (f : OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b3) \u1fb0) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (OrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b3) _x) (RelHomClass.toFunLike.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) \u03b1 \u03b3 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b3) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b3) => LE.le.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 _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} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) \u03b1 \u03b3 _inst_2 _inst_6 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddMonoidWithOne.toAddMonoid.{u2} \u03b3 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b3 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b3 _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6)))) (OrderRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g)) (Function.comp.{succ u1, succ u3, succ u2} \u03b1 \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b2) => \u03b3) _x) (RelHomClass.toFunLike.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b2) => LE.le.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b3) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b3) => LE.le.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 _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} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 _inst_4 _inst_6 (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddMonoidWithOne.toAddMonoid.{u3} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u3} \u03b2 _inst_3)))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddMonoidWithOne.toAddMonoid.{u2} \u03b3 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b3 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b3 _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6)))) f) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddMonoidWithOne.toAddMonoid.{u3} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u3} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u3} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem coe_comp (f : \u03b2 \u2192+*o \u03b3) (g : \u03b1 \u2192+*o \u03b2) : \u21d1(f.comp g) = f \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] [_inst_5 : NonAssocSemiring.{u3} \u03b3] [_inst_6 : Preorder.{u3} \u03b3] (f : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (a : \u03b1), Eq.{succ u3} \u03b3 (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) => \u03b1 -> \u03b3) (OrderRingHom.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _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} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b2 -> \u03b3) (OrderRingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) f (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) g a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u3} \u03b2] [_inst_4 : Preorder.{u3} \u03b2] [_inst_5 : NonAssocSemiring.{u2} \u03b3] [_inst_6 : Preorder.{u2} \u03b3] (f : OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (a : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b3) a) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (OrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b3) _x) (RelHomClass.toFunLike.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) \u03b1 \u03b3 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b3) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b3) => LE.le.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 _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} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) \u03b1 \u03b3 _inst_2 _inst_6 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddMonoidWithOne.toAddMonoid.{u2} \u03b3 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b3 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b3 _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u2, u1, u2} (OrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6)))) (OrderRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _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} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b2) => \u03b3) _x) (RelHomClass.toFunLike.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b2) => LE.le.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b3) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b3) => LE.le.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 _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} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 _inst_4 _inst_6 (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddMonoidWithOne.toAddMonoid.{u3} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u3} \u03b2 _inst_3)))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddMonoidWithOne.toAddMonoid.{u2} \u03b3 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b3 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b3 _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6)))) f (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddMonoidWithOne.toAddMonoid.{u3} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u3} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u3} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem comp_apply (f : \u03b2 \u2192+*o \u03b3) (g : \u03b1 \u2192+*o \u03b2) (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] [_inst_5 : NonAssocSemiring.{u3} \u03b3] [_inst_6 : Preorder.{u3} \u03b3] [_inst_7 : NonAssocSemiring.{u4} \u03b4] [_inst_8 : Preorder.{u4} \u03b4] (f : OrderRingHom.{u3, u4} \u03b3 \u03b4 _inst_5 _inst_6 _inst_7 _inst_8) (g : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (h : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u4)} (OrderRingHom.{u1, u4} \u03b1 \u03b4 _inst_1 _inst_2 _inst_7 _inst_8) (OrderRingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_3 _inst_4 _inst_7 _inst_8 (OrderRingHom.comp.{u2, u3, u4} \u03b2 \u03b3 \u03b4 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 f g) h) (OrderRingHom.comp.{u1, u3, u4} \u03b1 \u03b3 \u03b4 _inst_1 _inst_2 _inst_5 _inst_6 _inst_7 _inst_8 f (OrderRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 g h))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] [_inst_5 : NonAssocSemiring.{u4} \u03b3] [_inst_6 : Preorder.{u4} \u03b3] [_inst_7 : NonAssocSemiring.{u3} \u03b4] [_inst_8 : Preorder.{u3} \u03b4] (f : OrderRingHom.{u4, u3} \u03b3 \u03b4 _inst_5 _inst_6 _inst_7 _inst_8) (g : OrderRingHom.{u2, u4} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (h : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} \u03b1 \u03b4 _inst_1 _inst_2 _inst_7 _inst_8) (OrderRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b4 _inst_1 _inst_2 _inst_3 _inst_4 _inst_7 _inst_8 (OrderRingHom.comp.{u2, u4, u3} \u03b2 \u03b3 \u03b4 _inst_3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 f g) h) (OrderRingHom.comp.{u1, u4, u3} \u03b1 \u03b3 \u03b4 _inst_1 _inst_2 _inst_5 _inst_6 _inst_7 _inst_8 f (OrderRingHom.comp.{u1, u2, u4} \u03b1 \u03b2 \u03b3 _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\u2093'. -/\ntheorem comp_assoc (f : \u03b3 \u2192+*o \u03b4) (g : \u03b2 \u2192+*o \u03b3) (h : \u03b1 \u2192+*o \u03b2) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.comp.{u1, u1, u2} \u03b1 \u03b1 \u03b2 _inst_1 _inst_2 _inst_1 _inst_2 _inst_3 _inst_4 f (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.comp.{u2, u2, u1} \u03b1 \u03b1 \u03b2 _inst_1 _inst_2 _inst_1 _inst_2 _inst_3 _inst_4 f (OrderRingHom.id.{u2} \u03b1 _inst_1 _inst_2)) f\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.comp_id OrderRingHom.comp_id\u2093'. -/\n@[simp]\ntheorem comp_id (f : \u03b1 \u2192+*o \u03b2) : f.comp (OrderRingHom.id \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.comp.{u1, u2, u2} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_3 _inst_4 (OrderRingHom.id.{u2} \u03b2 _inst_3 _inst_4) f) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4), Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.comp.{u2, u1, u1} \u03b1 \u03b2 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_3 _inst_4 (OrderRingHom.id.{u1} \u03b2 _inst_3 _inst_4) f) f\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.id_comp OrderRingHom.id_comp\u2093'. -/\n@[simp]\ntheorem id_comp (f : \u03b1 \u2192+*o \u03b2) : (OrderRingHom.id \u03b2).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] [_inst_5 : NonAssocSemiring.{u3} \u03b3] [_inst_6 : Preorder.{u3} \u03b3] {f\u2081 : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6} {f\u2082 : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6} {g : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4}, (Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) g)) -> (Iff (Eq.{max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f\u2081 g) (OrderRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f\u2082 g)) (Eq.{max (succ u2) (succ u3)} (OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) f\u2081 f\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u3} \u03b2] [_inst_4 : Preorder.{u3} \u03b2] [_inst_5 : NonAssocSemiring.{u2} \u03b3] [_inst_6 : Preorder.{u2} \u03b3] {f\u2081 : OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6} {f\u2082 : OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6} {g : OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4}, (Function.Surjective.{succ u1, succ u3} \u03b1 \u03b2 (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u1} \u03b1 (AddMonoidWithOne.toAddMonoid.{u1} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddMonoidWithOne.toAddMonoid.{u3} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u3} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u1 u3, u1, u3} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)))) g)) -> (Iff (Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f\u2081 g) (OrderRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f\u2082 g)) (Eq.{max (succ u3) (succ u2)} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.cancel_right OrderRingHom.cancel_right\u2093'. -/\ntheorem cancel_right {f\u2081 f\u2082 : \u03b2 \u2192+*o \u03b3} {g : \u03b1 \u2192+*o \u03b2} (hg : Surjective g) :\n    f\u2081.comp g = f\u2082.comp g \u2194 f\u2081 = f\u2082 :=\n  \u27e8fun h => ext <| hg.forall.2 <| FunLike.ext_iff.1 h, congr_arg _\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] [_inst_5 : NonAssocSemiring.{u3} \u03b3] [_inst_6 : Preorder.{u3} \u03b3] {f : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6} {g\u2081 : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4} {g\u2082 : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4}, (Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingHom.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b2 -> \u03b3) (OrderRingHom.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) f)) -> (Iff (Eq.{max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g\u2081) (OrderRingHom.comp.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g\u2082)) (Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) g\u2081 g\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u3} \u03b2] [_inst_4 : Preorder.{u3} \u03b2] [_inst_5 : NonAssocSemiring.{u2} \u03b3] [_inst_6 : Preorder.{u2} \u03b3] {f : OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6} {g\u2081 : OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4} {g\u2082 : OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4}, (Function.Injective.{succ u3, succ u2} \u03b2 \u03b3 (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b2) => \u03b3) _x) (RelHomClass.toFunLike.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b2) => LE.le.{u3} \u03b2 (Preorder.toLE.{u3} \u03b2 _inst_4) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b3) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b3) => LE.le.{u2} \u03b3 (Preorder.toLE.{u2} \u03b3 _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} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 _inst_4 _inst_6 (AddMonoid.toAddZeroClass.{u3} \u03b2 (AddMonoidWithOne.toAddMonoid.{u3} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u3} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u3} \u03b2 _inst_3)))) (AddMonoid.toAddZeroClass.{u2} \u03b3 (AddMonoidWithOne.toAddMonoid.{u2} \u03b3 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b3 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b3 _inst_5)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u3 u2, u3, u2} (OrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6) \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u3, u2} \u03b2 \u03b3 _inst_3 _inst_4 _inst_5 _inst_6)))) f)) -> (Iff (Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b3 _inst_1 _inst_2 _inst_5 _inst_6) (OrderRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g\u2081) (OrderRingHom.comp.{u1, u3, u2} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f g\u2082)) (Eq.{max (succ u1) (succ u3)} (OrderRingHom.{u1, u3} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) g\u2081 g\u2082))\nCase conversion may be inaccurate. Consider using '#align order_ring_hom.cancel_left OrderRingHom.cancel_left\u2093'. -/\ntheorem cancel_left {f : \u03b2 \u2192+*o \u03b3} {g\u2081 g\u2082 : \u03b1 \u2192+*o \u03b2} (hf : Injective f) :\n    f.comp g\u2081 = f.comp g\u2082 \u2194 g\u2081 = g\u2082 :=\n  \u27e8fun h => ext fun a => hf <| by rw [\u2190 comp_apply, h, comp_apply], congr_arg _\u27e9\n#align order_ring_hom.cancel_left OrderRingHom.cancel_left\n\nend Preorder\n\nvariable [NonAssocSemiring \u03b2]\n\ninstance [Preorder \u03b2] : Preorder (OrderRingHom \u03b1 \u03b2) :=\n  Preorder.lift (coeFn : _ \u2192 \u03b1 \u2192 \u03b2)\n\ninstance [PartialOrder \u03b2] : PartialOrder (OrderRingHom \u03b1 \u03b2) :=\n  PartialOrder.lift _ FunLike.coe_injective\n\nend OrderRingHom\n\n/-! ### Ordered ring isomorphisms -/\n\n\nnamespace OrderRingIso\n\nsection LE\n\nvariable [Mul \u03b1] [Add \u03b1] [LE \u03b1] [Mul \u03b2] [Add \u03b2] [LE \u03b2] [Mul \u03b3] [Add \u03b3] [LE \u03b3] [Mul \u03b4] [Add \u03b4] [LE \u03b4]\n\n/- warning: order_ring_iso.to_order_iso -> OrderRingIso.toOrderIso is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2], (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) -> (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2], (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) -> (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_order_iso OrderRingIso.toOrderIso\u2093'. -/\n/-- Reinterpret an ordered ring isomorphism as an order isomorphism. -/\ndef toOrderIso (f : \u03b1 \u2243+*o \u03b2) : \u03b1 \u2243o \u03b2 :=\n  \u27e8f.toRingEquiv.toEquiv, fun _ _ => f.map_le_map_iff'\u27e9\n#align order_ring_iso.to_order_iso OrderRingIso.toOrderIso\n\ninstance : OrderRingIsoClass (\u03b1 \u2243+*o \u03b2) \u03b1 \u03b2\n    where\n  coe f := f.toFun\n  inv f := f.invFun\n  coe_injective' f g h\u2081 h\u2082 := by\n    obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := f\n    obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := 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 (\u03b1 \u2243+*o \u03b2) fun _ => \u03b1 \u2192 \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (f : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (RingEquiv.toFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIso.toRingEquiv.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b1 -> \u03b2) (OrderRingIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (f : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (Equiv.toFun.{succ u2, succ u1} \u03b1 \u03b2 (RingEquiv.toEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 (OrderRingIso.toRingEquiv.{u2, u1} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\ntheorem toFun_eq_coe (f : \u03b1 \u2243+*o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] {f : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6} {g : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6}, (forall (a : \u03b1), Eq.{succ u2} \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b1 -> \u03b2) (OrderRingIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b1 -> \u03b2) (OrderRingIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) g a)) -> (Eq.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] {f : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6} {g : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6}, (forall (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) g a)) -> (Eq.{max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[ext]\ntheorem ext {f g : \u03b1 \u2243+*o \u03b2} (h : \u2200 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (e : RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (h : forall {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u2} \u03b2 _inst_6 (RingEquiv.toFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 e a) (RingEquiv.toFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 e b)) (LE.le.{u1} \u03b1 _inst_3 a b)), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b1 -> \u03b2) (OrderRingIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderRingIso.mk.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (fun (_x : RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) => \u03b1 -> \u03b2) (RingEquiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) e)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (e : RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) (h : forall {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b2 _inst_6 (Equiv.toFun.{succ u2, succ u1} \u03b1 \u03b2 (RingEquiv.toEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 e) a) (Equiv.toFun.{succ u2, succ u1} \u03b1 \u03b2 (RingEquiv.toEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 e) b)) (LE.le.{u2} \u03b1 _inst_3 a b)), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)))) (OrderRingIso.mk.{u2, u1} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 \u03b2 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 \u03b2 (MulEquivClass.toEquivLike.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 \u03b2 _inst_1 _inst_4 (RingEquivClass.toMulEquivClass.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (RingEquiv.instRingEquivClassRingEquiv.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem coe_mk (e : \u03b1 \u2243+* \u03b2) (h) : \u21d1(\u27e8e, h\u27e9 : \u03b1 \u2243+*o \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (e : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (h : forall {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u2} \u03b2 _inst_6 (RingEquiv.toFun.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) e) a) (RingEquiv.toFun.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) e) b)) (LE.le.{u1} \u03b1 _inst_3 a b)), Eq.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderRingIso.mk.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) e) h) e\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (e : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (h : forall {a : \u03b1} {b : \u03b1}, Iff (LE.le.{u1} \u03b2 _inst_6 (Equiv.toFun.{succ u2, succ u1} \u03b1 \u03b2 (RingEquiv.toEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) e)) a) (Equiv.toFun.{succ u2, succ u1} \u03b1 \u03b2 (RingEquiv.toEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)) e)) b)) (LE.le.{u2} \u03b1 _inst_3 a b)), Eq.{max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (OrderRingIso.mk.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6 (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem mk_coe (e : \u03b1 \u2243+*o \u03b2) (h) : (\u27e8e, h\u27e9 : \u03b1 \u2243+*o \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (f : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (OrderRingIso.toRingEquiv.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (f : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) (OrderRingIso.toRingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6 f) (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem toRingEquiv_eq_coe (f : \u03b1 \u2243+*o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (f : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6) (OrderRingIso.toOrderIso.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6) (OrderIso.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (f : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (OrderIso.{u2, u1} \u03b1 \u03b2 _inst_3 _inst_6) (OrderRingIso.toOrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 f) (OrderIsoClass.toOrderIso.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem toOrderIso_eq_coe (f : \u03b1 \u2243+*o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (f : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (fun (_x : RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) => \u03b1 -> \u03b2) (RingEquiv.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (RingEquiv.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5) (RingEquiv.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b1 -> \u03b2) (OrderRingIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (f : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 \u03b2 (EquivLike.toEmbeddingLike.{max (succ u2) (succ u1), succ u2, succ u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 \u03b2 (MulEquivClass.toEquivLike.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 \u03b2 _inst_1 _inst_4 (RingEquivClass.toMulEquivClass.{max u2 u1, u2, u1} (RingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (RingEquiv.instRingEquivClassRingEquiv.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5))))) (RingEquivClass.toRingEquiv.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_4 _inst_5 (OrderRingIsoClass.toRingEquivClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_toRingEquiv (f : \u03b1 \u2243+*o \u03b2) : \u21d1(f : \u03b1 \u2243+* \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (f : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_3) (LE.le.{u2} \u03b2 _inst_6)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_3) (LE.le.{u2} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_6) (OrderIso.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b1 -> \u03b2) (OrderRingIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (f : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderIso.{u2, u1} \u03b1 \u03b2 _inst_3 _inst_6) \u03b1 (fun (_x : \u03b1) => \u03b2) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderIso.{u2, u1} \u03b1 \u03b2 _inst_3 _inst_6) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.instRelHomClassRelIso.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_toOrderIso (f : \u03b1 \u2243+*o \u03b2) : \u21d1(f : \u03b1 \u2243o \u03b2) = f :=\n  rfl\n#align order_ring_iso.coe_to_order_iso OrderRingIso.coe_toOrderIso\n\nvariable (\u03b1)\n\n/- warning: order_ring_iso.refl -> OrderRingIso.refl is a dubious translation:\nlean 3 declaration is\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1], OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1], OrderRingIso.{u1, u1} \u03b1 \u03b1 _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\u2093'. -/\n/-- The identity map as an ordered ring isomorphism. -/\n@[refl]\nprotected def refl : \u03b1 \u2243+*o \u03b1 :=\n  \u27e8RingEquiv.refl \u03b1, fun _ _ => Iff.rfl\u27e9\n#align order_ring_iso.refl OrderRingIso.refl\n\ninstance : Inhabited (\u03b1 \u2243+*o \u03b1) :=\n  \u27e8OrderRingIso.refl \u03b1\u27e9\n\n#print OrderRingIso.refl_apply /-\n@[simp]\ntheorem refl_apply (x : \u03b1) : OrderRingIso.refl \u03b1 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 (\u03b1 : Type.{u1}) [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1], Eq.{succ u1} (RingEquiv.{u1, u1} \u03b1 \u03b1 _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} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (RingEquiv.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (HasLiftT.mk.{succ u1, succ u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (RingEquiv.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (CoeTC\u2093.coe.{succ u1, succ u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (RingEquiv.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (RingEquiv.hasCoeT.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIsoClass.toRingEquivClass.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3 (OrderRingIso.orderRingIsoClass.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3))))) (OrderRingIso.refl.{u1} \u03b1 _inst_1 _inst_2 _inst_3)) (RingEquiv.refl.{u1} \u03b1 _inst_1 _inst_2)\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1], Eq.{succ u1} (RingEquiv.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 _inst_2 _inst_2) (RingEquivClass.toRingEquiv.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIsoClass.toRingEquivClass.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3)) (OrderRingIso.refl.{u1} \u03b1 _inst_1 _inst_2 _inst_3)) (RingEquiv.refl.{u1} \u03b1 _inst_1 _inst_2)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_ring_equiv_refl OrderRingIso.coe_ringEquiv_refl\u2093'. -/\n@[simp]\ntheorem coe_ringEquiv_refl : (OrderRingIso.refl \u03b1 : \u03b1 \u2243+* \u03b1) = RingEquiv.refl \u03b1 :=\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 (\u03b1 : Type.{u1}) [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1], Eq.{succ u1} (OrderIso.{u1, u1} \u03b1 \u03b1 _inst_3 _inst_3) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (OrderIso.{u1, u1} \u03b1 \u03b1 _inst_3 _inst_3) (HasLiftT.mk.{succ u1, succ u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (OrderIso.{u1, u1} \u03b1 \u03b1 _inst_3 _inst_3) (CoeTC\u2093.coe.{succ u1, succ u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (OrderIso.{u1, u1} \u03b1 \u03b1 _inst_3 _inst_3) (OrderIso.hasCoeT.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) \u03b1 \u03b1 _inst_3 _inst_3 (OrderRingIsoClass.toOrderIsoClass.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3 (OrderRingIso.orderRingIsoClass.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3))))) (OrderRingIso.refl.{u1} \u03b1 _inst_1 _inst_2 _inst_3)) (OrderIso.refl.{u1} \u03b1 _inst_3)\nbut is expected to have type\n  forall (\u03b1 : Type.{u1}) [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1], Eq.{succ u1} (OrderIso.{u1, u1} \u03b1 \u03b1 _inst_3 _inst_3) (OrderIsoClass.toOrderIso.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) \u03b1 \u03b1 _inst_3 _inst_3 (OrderRingIsoClass.toOrderIsoClass.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3)) (OrderRingIso.refl.{u1} \u03b1 _inst_1 _inst_2 _inst_3)) (OrderIso.refl.{u1} \u03b1 _inst_3)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_order_iso_refl OrderRingIso.coe_orderIso_refl\u2093'. -/\n@[simp]\ntheorem coe_orderIso_refl : (OrderRingIso.refl \u03b1 : \u03b1 \u2243o \u03b1) = OrderIso.refl \u03b1 :=\n  rfl\n#align order_ring_iso.coe_order_iso_refl OrderRingIso.coe_orderIso_refl\n\nvariable {\u03b1}\n\n/- warning: order_ring_iso.symm -> OrderRingIso.symm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2], (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) -> (OrderRingIso.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2], (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) -> (OrderRingIso.{u2, u1} \u03b2 \u03b1 _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\u2093'. -/\n/-- The inverse of an ordered ring isomorphism as an ordered ring isomorphism. -/\n@[symm]\nprotected def symm (e : \u03b1 \u2243+*o \u03b2) : \u03b2 \u2243+*o \u03b1 :=\n  \u27e8e.toRingEquiv.symm, fun a b => by\n    erw [\u2190 map_le_map_iff e, e.1.apply_symm_apply, e.1.apply_symm_apply]\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2], (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) -> \u03b2 -> \u03b1\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2], (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) -> \u03b2 -> \u03b1\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.simps.symm_apply OrderRingIso.Simps.symm_apply\u2093'. -/\n/-- See Note [custom simps projection] -/\ndef Simps.symm_apply (e : \u03b1 \u2243+*o \u03b2) : \u03b2 \u2192 \u03b1 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (e : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderRingIso.symm.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 (OrderRingIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e)) e\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (e : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (OrderRingIso.symm.{u1, u2} \u03b2 \u03b1 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 (OrderRingIso.symm.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem symm_symm (e : \u03b1 \u2243+*o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] [_inst_7 : Mul.{u3} \u03b3] [_inst_8 : Add.{u3} \u03b3] [_inst_9 : LE.{u3} \u03b3], (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) -> (OrderRingIso.{u2, u3} \u03b2 \u03b3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) -> (OrderRingIso.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] [_inst_7 : Mul.{u3} \u03b3] [_inst_8 : Add.{u3} \u03b3] [_inst_9 : LE.{u3} \u03b3], (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) -> (OrderRingIso.{u2, u3} \u03b2 \u03b3 _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) -> (OrderRingIso.{u1, u3} \u03b1 \u03b3 _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\u2093'. -/\n/-- Composition of `order_ring_iso`s as an `order_ring_iso`. -/\n@[trans, simps]\nprotected def trans (f : \u03b1 \u2243+*o \u03b2) (g : \u03b2 \u2243+*o \u03b3) : \u03b1 \u2243+*o \u03b3 :=\n  \u27e8f.toRingEquiv.trans g.toRingEquiv, fun a b => (map_le_map_iff g).trans (map_le_map_iff f)\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] [_inst_7 : Mul.{u3} \u03b3] [_inst_8 : Add.{u3} \u03b3] [_inst_9 : LE.{u3} \u03b3] (f : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (g : OrderRingIso.{u2, u3} \u03b2 \u03b3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) (a : \u03b1), Eq.{succ u3} \u03b3 (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (OrderRingIso.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9) (fun (_x : OrderRingIso.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9) => \u03b1 -> \u03b3) (OrderRingIso.hasCoeToFun.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9) (OrderRingIso.trans.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _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} \u03b2 \u03b3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) (fun (_x : OrderRingIso.{u2, u3} \u03b2 \u03b3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9) => \u03b2 -> \u03b3) (OrderRingIso.hasCoeToFun.{u2, u3} \u03b2 \u03b3 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (fun (_x : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) => \u03b1 -> \u03b2) (OrderRingIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) f a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : Mul.{u3} \u03b1] [_inst_2 : Add.{u3} \u03b1] [_inst_3 : LE.{u3} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] [_inst_7 : Mul.{u1} \u03b3] [_inst_8 : Add.{u1} \u03b3] [_inst_9 : LE.{u1} \u03b3] (f : OrderRingIso.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (g : OrderRingIso.{u2, u1} \u03b2 \u03b3 _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) (a : \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b3) a) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (OrderRingIso.{u3, u1} \u03b1 \u03b3 _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b3) _x) (RelHomClass.toFunLike.{max u3 u1, u3, u1} (OrderRingIso.{u3, u1} \u03b1 \u03b3 _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9) \u03b1 \u03b3 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u3} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b3) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b3) => LE.le.{u1} \u03b3 _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} \u03b1 \u03b3 _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9) \u03b1 \u03b3 _inst_3 _inst_9 (OrderRingIsoClass.toOrderIsoClass.{max u3 u1, u3, u1} (OrderRingIso.{u3, u1} \u03b1 \u03b3 _inst_1 _inst_7 _inst_2 _inst_8 _inst_3 _inst_9) \u03b1 \u03b3 _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u3, u1} \u03b1 \u03b3 _inst_1 _inst_2 _inst_3 _inst_7 _inst_8 _inst_9)))) (OrderRingIso.trans.{u3, u2, u1} \u03b1 \u03b2 \u03b3 _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} \u03b2 \u03b3 _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b2) => \u03b3) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b2 \u03b3 _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) \u03b2 \u03b3 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b2) => LE.le.{u2} \u03b2 _inst_6 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b3) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b3) => LE.le.{u1} \u03b3 _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} \u03b2 \u03b3 _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) \u03b2 \u03b3 _inst_6 _inst_9 (OrderRingIsoClass.toOrderIsoClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b2 \u03b3 _inst_4 _inst_7 _inst_5 _inst_8 _inst_6 _inst_9) \u03b2 \u03b3 _inst_4 _inst_5 _inst_6 _inst_7 _inst_8 _inst_9 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b2 \u03b3 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u3 u2, u3, u2} (OrderRingIso.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u3} \u03b1 _inst_3 x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u2} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_3 _inst_6 (OrderRingIsoClass.toOrderIsoClass.{max u3 u2, u3, u2} (OrderRingIso.{u3, u2} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u3, u2} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem trans_apply (f : \u03b1 \u2243+*o \u03b2) (g : \u03b2 \u2243+*o \u03b3) (a : \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (e : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{succ u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_3 _inst_1 _inst_2 _inst_3) (OrderRingIso.trans.{u1, u2, u1} \u03b1 \u03b2 \u03b1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 e (OrderRingIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e)) (OrderRingIso.refl.{u1} \u03b1 _inst_1 _inst_2 _inst_3)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (e : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{succ u2} (OrderRingIso.{u2, u2} \u03b1 \u03b1 _inst_1 _inst_1 _inst_2 _inst_2 _inst_3 _inst_3) (OrderRingIso.trans.{u2, u1, u2} \u03b1 \u03b2 \u03b1 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 e (OrderRingIso.symm.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e)) (OrderRingIso.refl.{u2} \u03b1 _inst_1 _inst_2 _inst_3)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.self_trans_symm OrderRingIso.self_trans_symm\u2093'. -/\n@[simp]\ntheorem self_trans_symm (e : \u03b1 \u2243+*o \u03b2) : e.trans e.symm = OrderRingIso.refl \u03b1 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2] (e : OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6), Eq.{succ u2} (OrderRingIso.{u2, u2} \u03b2 \u03b2 _inst_4 _inst_5 _inst_6 _inst_4 _inst_5 _inst_6) (OrderRingIso.trans.{u2, u1, u2} \u03b2 \u03b1 \u03b2 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e) e) (OrderRingIso.refl.{u2} \u03b2 _inst_4 _inst_5 _inst_6)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2] (e : OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6), Eq.{succ u1} (OrderRingIso.{u1, u1} \u03b2 \u03b2 _inst_4 _inst_4 _inst_5 _inst_5 _inst_6 _inst_6) (OrderRingIso.trans.{u1, u2, u1} \u03b2 \u03b1 \u03b2 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 (OrderRingIso.symm.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6 e) e) (OrderRingIso.refl.{u1} \u03b2 _inst_4 _inst_5 _inst_6)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.symm_trans_self OrderRingIso.symm_trans_self\u2093'. -/\n@[simp]\ntheorem symm_trans_self (e : \u03b1 \u2243+*o \u03b2) : e.symm.trans e = OrderRingIso.refl \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Mul.{u1} \u03b1] [_inst_2 : Add.{u1} \u03b1] [_inst_3 : LE.{u1} \u03b1] [_inst_4 : Mul.{u2} \u03b2] [_inst_5 : Add.{u2} \u03b2] [_inst_6 : LE.{u2} \u03b2], Function.Bijective.{max (succ u1) (succ u2), max (succ u2) (succ u1)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6) (OrderRingIso.{u2, u1} \u03b2 \u03b1 _inst_4 _inst_5 _inst_6 _inst_1 _inst_2 _inst_3) (OrderRingIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 _inst_5 _inst_6)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Mul.{u2} \u03b1] [_inst_2 : Add.{u2} \u03b1] [_inst_3 : LE.{u2} \u03b1] [_inst_4 : Mul.{u1} \u03b2] [_inst_5 : Add.{u1} \u03b2] [_inst_6 : LE.{u1} \u03b2], Function.Bijective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_4 _inst_2 _inst_5 _inst_3 _inst_6) (OrderRingIso.{u1, u2} \u03b2 \u03b1 _inst_4 _inst_1 _inst_5 _inst_2 _inst_6 _inst_3) (OrderRingIso.symm.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\ntheorem symm_bijective : Bijective (OrderRingIso.symm : \u03b1 \u2243+*o \u03b2 \u2192 \u03b2 \u2243+*o \u03b1) :=\n  \u27e8fun f g h => f.symm_symm.symm.trans <| (congr_arg OrderRingIso.symm h).trans g.symm_symm,\n    fun f => \u27e8f.symm, f.symm_symm\u27e9\u27e9\n#align order_ring_iso.symm_bijective OrderRingIso.symm_bijective\n\nend LE\n\nsection NonAssocSemiring\n\nvariable [NonAssocSemiring \u03b1] [Preorder \u03b1] [NonAssocSemiring \u03b2] [Preorder \u03b2] [NonAssocSemiring \u03b3]\n  [Preorder \u03b3]\n\n/- warning: order_ring_iso.to_order_ring_hom -> OrderRingIso.toOrderRingHom is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2], (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) -> (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2], (OrderRingIso.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3)) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Preorder.toLE.{u2} \u03b2 _inst_4)) -> (OrderRingHom.{u1, u2} \u03b1 \u03b2 _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\u2093'. -/\n/-- Reinterpret an ordered ring isomorphism as an ordered ring homomorphism. -/\ndef toOrderRingHom (f : \u03b1 \u2243+*o \u03b2) : \u03b1 \u2192+*o \u03b2 :=\n  \u27e8f.toRingEquiv.toRingHom, fun a b => (map_le_map_iff f).2\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)), Eq.{max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingIso.toOrderRingHom.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)), Eq.{max (succ u2) (succ u1)} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingIso.toOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 f) (OrderRingHomClass.toOrderRingHom.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Preorder.toLE.{u2} \u03b1 _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u1} \u03b2 _inst_4))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.to_order_ring_hom_eq_coe OrderRingIso.toOrderRingHom_eq_coe\u2093'. -/\n@[simp]\ntheorem toOrderRingHom_eq_coe (f : \u03b1 \u2243+*o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2] (f : OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)), Eq.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (fun (_x : OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) => \u03b1 -> \u03b2) (OrderRingHom.hasCoeToFun.{u1, u2} \u03b1 \u03b2 _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} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (HasLiftT.mk.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (CoeTC\u2093.coe.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingHom.hasCoeT.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u1 u2, u1, u2} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.orderRingIsoClass.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)))))) f)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) (fun (_x : OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) => \u03b1 -> \u03b2) (OrderRingIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2] (f : OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)), Eq.{max (succ u2) (succ u1)} (forall (\u1fb0 : \u03b1), (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) \u1fb0) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingHom.instOrderRingHomClassOrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)))) (OrderRingHomClass.toOrderRingHom.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Preorder.toLE.{u2} \u03b1 _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u1} \u03b2 _inst_4))) f)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Order.RelIso.Basic._hyg.867 : \u03b1) => \u03b2) _x) (RelHomClass.toFunLike.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1896 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1898 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1896 x._@.Mathlib.Order.Hom.Basic._hyg.1898) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1918 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1920 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _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} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_2 _inst_4 (AddMonoid.toAddZeroClass.{u2} \u03b1 (AddMonoidWithOne.toAddMonoid.{u2} \u03b1 (AddCommMonoidWithOne.toAddMonoidWithOne.{u2} \u03b1 (NonAssocSemiring.toAddCommMonoidWithOne.{u2} \u03b1 _inst_1)))) (AddMonoid.toAddZeroClass.{u1} \u03b2 (AddMonoidWithOne.toAddMonoid.{u1} \u03b2 (AddCommMonoidWithOne.toAddMonoidWithOne.{u1} \u03b2 (NonAssocSemiring.toAddCommMonoidWithOne.{u1} \u03b2 _inst_3)))) (OrderRingHomClass.toOrderAddMonoidHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIsoClass.toOrderRingHomClass.{max u2 u1, u2, u1} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Preorder.toLE.{u2} \u03b1 _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u1} \u03b2 _inst_4)))))) f)\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.coe_to_order_ring_hom OrderRingIso.coe_toOrderRingHom\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_toOrderRingHom (f : \u03b1 \u2243+*o \u03b2) : \u21d1(f : \u03b1 \u2192+*o \u03b2) = 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 {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _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} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2)) (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (HasLiftT.mk.{succ u1, succ u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2)) (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (CoeTC\u2093.coe.{succ u1, succ u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2)) (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderRingHom.hasCoeT.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2)) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIsoClass.toOrderRingHomClass.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2)) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIso.orderRingIsoClass.{u1, u1} \u03b1 \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2)))))) (OrderRingIso.refl.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2))) (OrderRingHom.id.{u1} \u03b1 _inst_1 _inst_2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1], Eq.{succ u1} (OrderRingHom.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2) (OrderRingHomClass.toOrderRingHom.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b1 _inst_2)) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIsoClass.toOrderRingHomClass.{u1, u1, u1} (OrderRingIso.{u1, u1} \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b1 _inst_2)) \u03b1 \u03b1 _inst_1 _inst_2 _inst_1 _inst_2 (OrderRingIso.instOrderRingIsoClassOrderRingIso.{u1, u1} \u03b1 \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2))) (OrderRingIso.refl.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMul.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1)) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2))) (OrderRingHom.id.{u1} \u03b1 _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\u2093'. -/\n@[simp]\ntheorem coe_toOrderRingHom_refl : (OrderRingIso.refl \u03b1 : \u03b1 \u2192+*o \u03b1) = OrderRingHom.id \u03b1 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : NonAssocSemiring.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] [_inst_3 : NonAssocSemiring.{u2} \u03b2] [_inst_4 : Preorder.{u2} \u03b2], Function.Injective.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 _inst_1))) (Preorder.toLE.{u1} \u03b1 _inst_2) (Distrib.toHasMul.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Distrib.toHasAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b2 _inst_4)) (OrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingIso.toOrderRingHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : NonAssocSemiring.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] [_inst_3 : NonAssocSemiring.{u1} \u03b2] [_inst_4 : Preorder.{u1} \u03b2], Function.Injective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderRingIso.{u2, u1} \u03b1 \u03b2 (NonUnitalNonAssocSemiring.toMul.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1)) (NonUnitalNonAssocSemiring.toMul.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3)) (Distrib.toAdd.{u2} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b1 _inst_1))) (Distrib.toAdd.{u1} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 _inst_3))) (Preorder.toLE.{u2} \u03b1 _inst_2) (Preorder.toLE.{u1} \u03b2 _inst_4)) (OrderRingHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 _inst_3 _inst_4) (OrderRingIso.toOrderRingHom.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\ntheorem toOrderRingHom_injective : Injective (toOrderRingHom : \u03b1 \u2243+*o \u03b2 \u2192 \u03b1 \u2192+*o \u03b2) := 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 \u03b1] [LinearOrderedField \u03b2] [Archimedean \u03b2] :\n    Subsingleton (\u03b1 \u2192+*o \u03b2) :=\n  \u27e8fun f g => by\n    ext x\n    by_contra' h' : f x \u2260 g x\n    wlog h : f x < g x\n    \u00b7 exact this g f x (Ne.symm h') (h'.lt_or_lt.resolve_left h)\n    obtain \u27e8q, hf, hg\u27e9 := exists_rat_btwn h\n    rw [\u2190 map_ratCast f] at hf\n    rw [\u2190 map_ratCast g] at hg\n    exact\n      (lt_asymm ((OrderHomClass.mono g).reflect_lt hg) <|\n          (OrderHomClass.mono f).reflect_lt hf).elim\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : LinearOrderedField.{u2} \u03b2] [_inst_3 : Archimedean.{u2} \u03b2 (OrderedSemiring.toOrderedAddCommMonoid.{u2} \u03b2 (StrictOrderedSemiring.toOrderedSemiring.{u2} \u03b2 (StrictOrderedRing.toStrictOrderedSemiring.{u2} \u03b2 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b2 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b2 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b2 _inst_2))))))], Subsingleton.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Distrib.toHasMul.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 (DivisionRing.toRing.{u2} \u03b2 (Field.toDivisionRing.{u2} \u03b2 (LinearOrderedField.toField.{u2} \u03b2 _inst_2))))) (Distrib.toHasAdd.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 (DivisionRing.toRing.{u2} \u03b2 (Field.toDivisionRing.{u2} \u03b2 (LinearOrderedField.toField.{u2} \u03b2 _inst_2))))) (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommGroup.toPartialOrder.{u2} \u03b2 (StrictOrderedRing.toOrderedAddCommGroup.{u2} \u03b2 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b2 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b2 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b2 _inst_2))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : LinearOrderedField.{u2} \u03b2] [_inst_3 : Archimedean.{u2} \u03b2 (OrderedSemiring.toOrderedAddCommMonoid.{u2} \u03b2 (OrderedCommSemiring.toOrderedSemiring.{u2} \u03b2 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} \u03b2 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} \u03b2 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b2 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b2 _inst_2))))))], Subsingleton.{max (succ u2) (succ u1)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))) (NonUnitalNonAssocRing.toMul.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (DivisionRing.toRing.{u2} \u03b2 (Field.toDivisionRing.{u2} \u03b2 (LinearOrderedField.toField.{u2} \u03b2 _inst_2)))))) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))) (Distrib.toAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (DivisionRing.toRing.{u2} \u03b2 (Field.toDivisionRing.{u2} \u03b2 (LinearOrderedField.toField.{u2} \u03b2 _inst_2)))))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (StrictOrderedRing.toPartialOrder.{u2} \u03b2 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b2 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b2 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b2 _inst_2)))))))\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.subsingleton_right OrderRingIso.subsingleton_right\u2093'. -/\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 \u03b1] [LinearOrderedField \u03b2]\n    [Archimedean \u03b2] : Subsingleton (\u03b1 \u2243+*o \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))] [_inst_3 : LinearOrderedField.{u2} \u03b2], Subsingleton.{max (succ u1) (succ u2)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Distrib.toHasAdd.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Distrib.toHasMul.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 (DivisionRing.toRing.{u2} \u03b2 (Field.toDivisionRing.{u2} \u03b2 (LinearOrderedField.toField.{u2} \u03b2 _inst_3))))) (Distrib.toHasAdd.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 (DivisionRing.toRing.{u2} \u03b2 (Field.toDivisionRing.{u2} \u03b2 (LinearOrderedField.toField.{u2} \u03b2 _inst_3))))) (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommGroup.toPartialOrder.{u2} \u03b2 (StrictOrderedRing.toOrderedAddCommGroup.{u2} \u03b2 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b2 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b2 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b2 _inst_3))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))] [_inst_3 : LinearOrderedField.{u2} \u03b2], Subsingleton.{max (succ u2) (succ u1)} (OrderRingIso.{u1, u2} \u03b1 \u03b2 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))) (NonUnitalNonAssocRing.toMul.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (DivisionRing.toRing.{u2} \u03b2 (Field.toDivisionRing.{u2} \u03b2 (LinearOrderedField.toField.{u2} \u03b2 _inst_3)))))) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (DivisionRing.toRing.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1)))))))) (Distrib.toAdd.{u2} \u03b2 (NonUnitalNonAssocSemiring.toDistrib.{u2} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 (DivisionRing.toRing.{u2} \u03b2 (Field.toDivisionRing.{u2} \u03b2 (LinearOrderedField.toField.{u2} \u03b2 _inst_3)))))))) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (StrictOrderedRing.toPartialOrder.{u2} \u03b2 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b2 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b2 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b2 _inst_3)))))))\nCase conversion may be inaccurate. Consider using '#align order_ring_iso.subsingleton_left OrderRingIso.subsingleton_left\u2093'. -/\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 \u03b1] [Archimedean \u03b1]\n    [LinearOrderedField \u03b2] : Subsingleton (\u03b1 \u2243+*o \u03b2) :=\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": "namespace Foo\nnamespace Bla\n\ntheorem ex1 {a b : Nat} (h : a \u2264 b) : a + a \u2264 b + b :=\n  sorry\n\ntheorem ex2 {a b : Nat} (h : a \u2264 b) : a + 2 \u2264 b + 2 :=\n  sorry\n\ntheorem ex3 {a b c d : Nat} (h : a \u2264 b) (h : c \u2264 d) : a + c \u2264 b + d :=\n  sorry\n\ntheorem ax1 {a b : Nat} (h : a \u2264 b) : a - a \u2264 b - b :=\n  sorry\n\nend Bla\nend Foo\n\ntheorem tst1 (h : a \u2264 b) : a + 2 \u2264 b + 2 :=\n  Foo.Bla.\n        --^ textDocument/completion\n#print \"\"\n\nopen Foo in\ntheorem tst2 (h : a \u2264 b) : a + 2 \u2264 b + 2 :=\n  Bla.\n    --^ textDocument/completion\n#print \"\"\n\ntheorem tst3 (h : a \u2264 b) : a + 2 \u2264 b + 2 :=\n  let aux := Foo.Bla.  -- we don't have the expected type here\n                   --^ textDocument/completion\n  aux\n\n#print \"\"\n\ntheorem tst4 (h : a \u2264 b) : a + 2 \u2264 b + 2 :=\n  let aux := Foo.Bla.e  -- we don't have the expected type here\n                    --^ textDocument/completion\n  aux\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/completion2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.6442250928250375, "lm_q1q2_score": 0.4669796209561255}}
{"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\u2081 v\u2082 u\u2081 u\u2082\n\nclass graph (vertices : Type u\u2081) :=\n(edges : vertices \u2192 vertices \u2192 Sort v\u2081)\n\nvariable {C : Type u\u2081}\nvariables {W X Y Z : C}\nvariable [\ud835\udc9e : graph.{v\u2081} C]\n\ndef edges : C \u2192 C \u2192 Sort v\u2081 := @graph.edges.{v\u2081} C \ud835\udc9e\n\nstructure graph_hom (G : Type u\u2081) [graph.{v\u2081} G] (H : Type u\u2082) [graph.{v\u2082} H] :=\n(onVertices : G \u2192 H)\n(onEdges    : \u2200 {X Y : G}, edges X Y \u2192 edges (onVertices X) (onVertices Y))\n\nsection\nvariables {G : Type u\u2081} [\ud835\udca2 : graph.{v\u2081} G] {H : Type u\u2082} [\u210b : graph.{v\u2082} H]\ninclude \ud835\udca2 \u210b\n\n@[extensionality] lemma graph_hom_pointwise_equal\n  {p q : graph_hom G H}\n  (vertexWitness : \u2200 X : G, p.onVertices X = q.onVertices X)\n  (edgeWitness : \u2200 X Y : G, \u2200 f : edges X Y, \u27ec p.onEdges f \u27ed = 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\u2081} [\ud835\udca2 : graph.{v\u2081} G]\ninclude \ud835\udca2\n\ninductive path : G \u2192 G \u2192 Type (max u\u2081 v\u2081)\n| nil  : \u03a0 (h : G), path h h\n| cons : \u03a0 {h s t : G} (e : edges h s) (l : path s t), path h t\n\ndef path.length : \u03a0 {s t : G}, path s t \u2192 \u2115\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 \u2192 G \u2192 Type (max u\u2081 v\u2081)\n| nil  : \u03a0 (h : G), path_of_paths h h\n| cons : \u03a0 {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 : \u03a0 {x y z : G}, path x y \u2192 path y z \u2192 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 : \u03a0 {x y : G}, path_of_paths x y \u2192 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  {\u03b1 : Type*} [linear_order \u03b1] {C : config \u03b1} \n  {S : finset \u03b1} (l : C.label S)\n\nprivate lemma mem_imply_nnil \n  {\u03b1 : Type*} (a : \u03b1) {l : list \u03b1} (ha : a \u2208 l) : l \u2260 [] := \n  by intro eq; subst eq; simp at ha; tauto\n\nnamespace config.label\n\ndef is_alpha_cup (a : \u03b1) (c : list \u03b1) : Prop :=\n  (c ++ [a]).in S \u2227 (c ++ [a]).sorted (<) \u2227 (c ++ [a]).chain' l.slope\u1d9c\n\ninstance decidable_is_alpha_cup (a : \u03b1) (c : list \u03b1) :\n  decidable (l.is_alpha_cup a c) := by rw is_alpha_cup; apply_instance\n\ntheorem alpha_cup_is_cup (c : list \u03b1)\n  (c_in_S : c.in S) (c_sorted : c.sorted (<))\n  (c_chain : c.chain' l.slope\u1d9c) : 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 \u27e8_, _, _\u27e9,\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 \u22a2 c_in_S c_chain c_sorted; tauto,\nend\n\ndef alpha_cups' (a : \u03b1) : list (list \u03b1) :=\n  (S.sort (\u2264)).sublists.filter (l.is_alpha_cup a)\n\ndef alpha_cup' (a : \u03b1) : option (list \u03b1) :=\n  (l.alpha_cups' a).argmax list.length\n\ndef alpha_cup'_is_some {a : \u03b1} (ha : a \u2208 S) : \n  option.is_some (l.alpha_cup' a) :=\nbegin\n  rw [\u2190option.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 : \u03b1) : \u2115 := \n  if ha : a \u2208 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 : \u03b1} (ha : a \u2208 S) : \n  \u03a3' c : list \u03b1, c.length = l.alpha a + 1 \u2227 \n    c.in S \u2227 c.sorted (<) \u2227 c.chain' l.slope\u1d9c \u2227 a \u2208 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 \u2190def_c,\n  have h_argmax := option.get_mem some, \n  rw [\u2190def_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 : \u03b1} {c : list \u03b1}\n  (c_in_S : c.in S) \n  (c_sorted : c.sorted (<))\n  (c_chain : c.chain' l.slope\u1d9c)\n  (c_last : a \u2208 c.last') : c.length \u2264 l.alpha a + 1 :=\nbegin\n  have ha : a \u2208 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 \u2190def_d,\n  have h_argmax := option.get_mem some, \n  rw [\u2190def_d, alpha_cup'] at h_argmax,\n  rcases list.take_last' c_last with \u27e8c', eq_c\u27e9,\n  subst eq_c, simp,\n  have c'_alpha_cup : c' \u2208 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 \u27e8_, _, _\u27e9; assumption },\n  end,\n  exact list.le_of_mem_argmax c'_alpha_cup h_argmax,\nend\n\ntheorem add_alpha {a : \u03b1} (ha : a \u2208 S)\n  {n : \u2115} {c : list \u03b1} (c_in_S : c.in S)\n  (c_cup : C.ncup n c) (c_head : a \u2208 c.head') : \n  C.has_ncup (n + l.alpha a) S :=\nbegin\n  rcases (l.alpha_cup ha) with \n    \u27e8d, d_length, d_in_S, d_sorted, d_chain, d_last\u27e9,\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 \u27e8d', eq_d\u27e9,\n  rcases list.take_head' c_head with \u27e8c', eq_c\u27e9,\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 \u2190eq_c, split; simp; assumption, },\n  rcases list.take_last hd' with \u27e8p, d'', eq_d'\u27e9,\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 \u2190eq_d, refine \u27e8\u27e8_, _\u27e9, _\u27e9,\n    assumption, rw d_length, exact add_comm _ _, assumption, },\n  rw eq_d', split, \n  { rw [config.ncup], split, simp, refine \u27e8_, _, _\u27e9,\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 \u2190eq_c, exact c_cup.left,\n    rw eq_d at d_length, simp at d_length,\n    rw \u2190eq_c, rw \u2190eq_d', simp, rw d_length,\n    rw c_cup.right, exact add_comm _ _, },\n  { rw \u2190eq_c, rw \u2190eq_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 : \u03b1) (c : list \u03b1) : Prop :=\n  (c ++ [a]).in S \u2227 C.cup (c ++ [a])\n\ninstance decidable_is_beta_cup (a : \u03b1) (c : list \u03b1) :\n  decidable (C.is_beta_cup S a c) := by rw is_beta_cup; apply_instance\n\ndef beta_cups' (a : \u03b1) : list (list \u03b1) :=\n  (S.sort (\u2264)).sublists.filter (C.is_beta_cup S a)\n\ndef beta_cup' (a : \u03b1) : option (list \u03b1) :=\n  (C.beta_cups' S a).argmax list.length\n\ndef beta_cup'_is_some {a : \u03b1} (ha : a \u2208 S) : \n  option.is_some (C.beta_cup' S a) :=\nbegin\n  rw \u2190option.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 : \u03b1) : \u2115 := \n  if ha : a \u2208 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 : \u03b1} (ha : a \u2208 S) : \n  \u03a3' c : list \u03b1, c.in S \u2227 C.ncup (C.beta S a + 1) c \u2227 a \u2208 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 \u2190def_c,\n  have h_argmax := option.get_mem some, \n  rw [\u2190def_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 : \u03b1} (ha : a \u2208 S) :\n  C.has_ncup (C.beta S a + 1) S :=\nbegin\n  rcases C.beta_cup S ha with \u27e8c, c_in, c_cup, -\u27e9,\n  use c, tauto,\nend\n\n-- Next, maximality of the cup with length alpha + 1\ndef cup_length_le_beta {a : \u03b1} {c : list \u03b1}\n  (c_in_S : c.in S) \n  (c_cup : C.cup c)\n  (c_last : a \u2208 c.last') : c.length \u2264 C.beta S a + 1 :=\nbegin\n  have ha : a \u2208 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 \u2190def_d,\n  have h_argmax := option.get_mem some, \n  rw [\u2190def_d, beta_cup'] at h_argmax,\n  rcases list.take_last' c_last with \u27e8c', eq_c\u27e9,\n  subst eq_c, simp,\n  have c_sorted := list.chain'_iff_pairwise.mp c_cup.left,\n  have c'_beta_cup : c' \u2208 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 : \u03b1} (ha : a \u2208 S) : \n  l.alpha a \u2264 C.beta S a :=\nbegin\n  rcases (l.alpha_cup ha) with \n    \u27e8c, c_length, c_in, c_sorted, c_chain, c_last\u27e9,\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 : \u03b1} (sab : \u00acl.slope a b)\n  (ha : a \u2208 S) (hb : b \u2208 S) (a_le_b : a < b) : \n  l.alpha a < l.alpha b :=\nbegin\n  rcases (l.alpha_cup ha) with \n    \u27e8c, c_length, c_in, c_sorted, c_chain, c_last\u27e9,\n  rcases list.take_last' c_last with \u27e8c', c_eq\u27e9,\n  rw [nat.lt_iff_add_one_le, \u2190(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 \u2190d_length,\n  apply l.cup_length_le_alpha,\n  { rw def_d, simp, tauto, },\n  { rw [def_d, c_eq, list.sorted, \u2190list.chain'_iff_pairwise], \n    simp, rw [list.chain'_iff_pairwise, \u2190list.sorted],\n    rw \u2190c_eq, exact \u27e8c_sorted, a_le_b\u27e9, },\n  { rw [def_d, c_eq], simp, rw \u2190c_eq,\n    exact \u27e8c_chain, sab\u27e9, },\n  { rw def_d, simp, },\nend\n\ntheorem slope_tt_inc_beta\n  {a b : \u03b1} (sab : l.slope a b)\n  (ha : a \u2208 S) (hb : b \u2208 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    \u27e8c, c_in, \u27e8c_cup, c_length\u27e9, c_last\u27e9,\n  rcases list.take_last' c_last with \u27e8c', c_eq\u27e9,\n  rw [nat.lt_iff_add_one_le, \u2190(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 \u2190d_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 : \u03b1} \n  (ha : a \u2208 S) (hb : b \u2208 S) (h : l.alpha a = l.alpha b) :\n  a < b \u2194 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 : \u03b1} \n  (ha : a \u2208 S) (hb : b \u2208 S) (h : C.beta S a = C.beta S b) :\n  a < b \u2194 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 `\u211d` is\naffine. We formalize it in three definitions:\n\n* `isometric.to_real_linear_isometry_equiv_of_map_zero` : given `E \u2243\u1d62 F` sending `0` to `0`,\n  returns `E \u2243\u2097\u1d62[\u211d] F` with the same `to_fun` and `inv_fun`;\n* `isometric.to_real_linear_isometry_equiv` : given `f : E \u2243\u1d62 F`,\n  returns `g : E \u2243\u2097\u1d62[\u211d] F` with `g x = f x - f 0`.\n* `isometric.to_affine_equiv` : given `PE \u2243\u1d62 PF`, returns `g : PE \u2243\u1d43[\u211d] PF` with the same\n  `to_equiv`.\n\nThe formalization is based on [Jussi V\u00e4is\u00e4l\u00e4, *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 `\u211d` 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 \u211d E] [metric_space PE] [normed_add_torsor E PE] {x : PE} {y : PE} (e : PE \u2243\u1d62 PE) : coe_fn e x = x \u2192 coe_fn e y = y \u2192 coe_fn e (midpoint \u211d x y) = midpoint \u211d 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 \u211d E] [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F] [normed_space \u211d F] [metric_space PF] [normed_add_torsor F PF] (f : PE \u2243\u1d62 PF) (x : PE) (y : PE) : coe_fn f (midpoint \u211d x y) = midpoint \u211d (coe_fn f x) (coe_fn f y) := sorry\n\n/-!\nSince `f : PE \u2243\u1d62 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 `\u211d` 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 \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 F) (h0 : coe_fn f 0 = 0) : linear_isometry_equiv \u211d 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 \u211d \u211d (\u21d1f) 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 \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 F) (h0 : coe_fn f 0 = 0) : \u21d1(to_real_linear_isometry_equiv_of_map_zero f h0) = \u21d1f :=\n  rfl\n\n@[simp] theorem coe_to_real_linear_equiv_of_map_zero_symm {E : Type u_1} [normed_group E] [normed_space \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 F) (h0 : coe_fn f 0 = 0) : \u21d1(linear_isometry_equiv.symm (to_real_linear_isometry_equiv_of_map_zero f h0)) = \u21d1(isometric.symm f) :=\n  rfl\n\n/-- Mazur-Ulam Theorem: if `f` is an isometric bijection between two normed vector spaces\nover `\u211d`, then `x \u21a6 f x - f 0` is a linear equivalence. -/\ndef to_real_linear_isometry_equiv {E : Type u_1} [normed_group E] [normed_space \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 F) : linear_isometry_equiv \u211d 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 \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 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 \u211d E] {F : Type u_3} [normed_group F] [normed_space \u211d F] (f : E \u2243\u1d62 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 \u211d E] [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F] [normed_space \u211d F] [metric_space PF] [normed_add_torsor F PF] (f : PE \u2243\u1d62 PF) : affine_equiv \u211d 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 \u211d E] [metric_space PE] [normed_add_torsor E PE] {F : Type u_3} {PF : Type u_4} [normed_group F] [normed_space \u211d F] [metric_space PF] [normed_add_torsor F PF] (f : PE \u2243\u1d62 PF) : \u21d1(to_affine_equiv f) = \u21d1f :=\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\u1d63 v u\n\nopen category_theory opposite\n\nnamespace Ext\n\nvariables (R : Type u\u1d63) [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 \u03b4 (n : \u2115) (A : short_exact_sequence C) (B : C) :\n  (Ext n , A.1 , B) \u27f6 (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 \u27f6 E.obj A.1, from functor.left_derived.\u03b4 _ _ _)\n\nlemma six_term_exact_seq (n : \u2115) (A : short_exact_sequence C) (B : C) :\n  exact_seq (Module.{v} R) [\n    ((\u00abExt\u00bb R C n).map A.g.op).app B, ((\u00abExt\u00bb R C n).map A.f.op).app B,\n    \u03b4 R n A B,\n    ((\u00abExt\u00bb R C (n+1)).map A.g.op).app B, ((\u00abExt\u00bb 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 \u00abExt\u00bb\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 {\u03b1 \u03b2 : Type*} [topological_space \u03b1] [topological_space \u03b2]\n  (e : \u03b1 \u2243\u209c \u03b2) [totally_disconnected_space \u03b1]\n\ninclude e\n\n--TODO: Golf and add to mathlib\nprotected lemma totally_disconnected_space : totally_disconnected_space \u03b2 :=\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 \u27e8x, hx, rfl\u27e9,\n    exact \u27e8y, hy, rfl\u27e9 },\n  obtain \u27e8h\u27e9 := (infer_instance : totally_disconnected_space \u03b1),\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 \u2192 \u2124\n\nnoncomputable theory\nopen_locale classical\n\ninstance : has_nnnorm (free_pfpng S) :=\n\u27e8\u03bb f, \u2211 s, \u2225f s\u2225\u208a\u27e9\n\nnamespace free_pfpng\n\n@[simp] lemma nnnorm_zero : \u2225(0 : free_pfpng S)\u2225\u208a = 0 :=\nby { change \u2211 _, _ = _, simp }\n\n@[simp] lemma nnnorm_neg (f : free_pfpng S) : \u2225(-f)\u2225\u208a = \u2225f\u2225\u208a :=\nby { change \u2211 _, _ = _, simpa }\n\nlemma nnnorm_add (f\u2081 f\u2082 : free_pfpng S) : \u2225f\u2081 + f\u2082\u2225\u208a \u2264 \u2225f\u2081\u2225\u208a + \u2225f\u2082\u2225\u208a :=\nbegin\n  change \u2211 _, _ \u2264 \u2211 _, _ + \u2211 _, _,\n  rw \u2190 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 | \u2225f\u2225\u208a \u2264 c } := \u22a5\ninstance (c) : discrete_topology { f : free_pfpng S | \u2225f\u2225\u208a \u2264 c } := \u27e8rfl\u27e9\n\nlemma norm_eval_le {c : nnreal} {s : S}\n  (f : free_pfpng S) (hf : \u2225f\u2225\u208a \u2264 c) : \u2225f s\u2225\u208a \u2264 c :=\nle_trans (begin\n  apply @finset.single_le_sum S nnreal _ (\u03bb t, \u2225f t\u2225\u208a) finset.univ,\n  { intros _ _, apply zero_le },\n  { exact finset.mem_univ s }\nend) hf\n\ninstance (c) : fintype { f : free_pfpng S | \u2225f\u2225\u208a \u2264 c } :=\nbegin\n  let A := { f : free_pfpng S | \u2225f\u2225\u208a \u2264 c },\n  have h : \u2203 (N : \u2115), c \u2264 N := \u27e8nat.ceil c, nat.le_ceil c\u27e9,\n  let N := h.some, let hN : c \u2264 N := h.some_spec,\n  let \u03b9 : A \u2192 S \u2192 set.Icc (-(N : \u2124)) N :=\n    \u03bb a s, \u27e8a.1 s, _, _\u27e9,\n  rotate,\n  { -- I'm sure there is a more efficient way to do this...\n    have : - \u2225a.val s\u2225 \u2264 a.val s := neg_abs_le_self \u2191(a.val s),\n    replace this : - (c : \u211d) \u2264 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 : \u211d) \u2264 _ := le_trans _ this,\n    swap,\n    { rw [neg_le_neg_iff], exact_mod_cast hN },\n    exact_mod_cast this },\n  { have : \u2191(a.val s) \u2264 \u2225a.val s\u2225 := le_max_left _ _,\n    replace this : \u2191(a.val s) \u2264 (c : \u211d) := 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 \u03b9,\n  { rintros \u27e8f,hf\u27e9 \u27e8g,hg\u27e9 h,\n    ext s,\n    apply_fun (\u03bb e, (e s).1) at h,\n    assumption },\n  apply fintype.of_injective \u03b9 this,\nend\n\ninstance : profinitely_filtered_pseudo_normed_group (free_pfpng S) :=\n{ filtration := \u03bb c, { f | \u2225 f \u2225\u208a \u2264 c },\n  filtration_mono := \u03bb c\u2081 c\u2082 h f hf, le_trans hf h,\n  zero_mem_filtration := \u03bb c, by simp,\n  neg_mem_filtration := \u03bb c f hf, by simpa,\n  add_mem_filtration := \u03bb c\u2081 c\u2082 f\u2081 f\u2082 h\u2081 h\u2082,\n    le_trans (nnnorm_add _ _ _) (add_le_add h\u2081 h\u2082),\n  continuous_add' := \u03bb c\u2081 c\u2082,\n    continuous_of_discrete_topology,\n  continuous_neg' := \u03bb c, continuous_of_discrete_topology,\n  continuous_cast_le := \u03bb _ _ _, continuous_of_discrete_topology,\n  ..(infer_instance : add_comm_group (free_pfpng S)) }\n\ndef map {S\u2081 S\u2082 : Fintype.{u}} (g : S\u2081 \u27f6 S\u2082) :\n  strict_comphaus_filtered_pseudo_normed_group_hom\n  (free_pfpng S\u2081) (free_pfpng S\u2082) :=\n{ to_fun := \u03bb f s, \u2211 t in finset.univ.filter (\u03bb w, g w = s), f t,\n  map_zero' := by simpa,\n  map_add' := \u03bb f g, by simpa [finset.sum_add_distrib],\n  strict' := begin\n    intros c f hf,\n    refine le_trans _ hf,\n    change \u2211 s\u2082, \u2225(\u2211 t in finset.univ.filter (\u03bb w, g w = s\u2082), f t)\u2225\u208a \u2264\n      \u2211 s\u2081, _,\n    have : \u2211 s\u2082, \u2225(\u2211 t in finset.univ.filter (\u03bb w, g w = s\u2082), f t)\u2225\u208a \u2264\n      \u2211 s\u2082 : S\u2082, \u2211 t in finset.univ.filter (\u03bb w, g w = s\u2082), \u2225f t\u2225\u208a,\n    { apply finset.sum_le_sum,\n      intros i _,\n      apply nnnorm_sum_le },\n    refine le_trans this _,\n    rw \u2190 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\u2081 _, 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 [\u2190 hh.1, \u2190 hh.2] }\n  end,\n  continuous' := \u03bb c, continuous_of_discrete_topology }\n\n@[simp]\nlemma map_id : map (\ud835\udfd9 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\u2081 S\u2082 S\u2083 : Fintype.{u}}\n  (g\u2081 : S\u2081 \u27f6 S\u2082) (g\u2082 : S\u2082 \u27f6 S\u2083) :\n  map (g\u2081 \u226b g\u2082) =\n  (map g\u2082).comp (map g\u2081) :=\nbegin\n  ext s\u2083,\n  dsimp [map],\n  erw \u2190 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\u2081 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\u2081 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 [\u2190 ha.1, \u2190 ha.2] }\nend\n\nend free_pfpng\n\n@[simps]\ndef free_pfpng_functor : Fintype \u2964 ProFiltPseuNormGrp\u2081 :=\n{ obj := \u03bb S,\n  { M := free_pfpng S,\n    exhaustive' := \u03bb f, \u27e8\u2225f\u2225\u208a, le_refl _\u27e9 },\n  map := \u03bb S\u2081 S\u2082 f, free_pfpng.map f,\n  map_id' := free_pfpng.map_id,\n  map_comp' := \u03bb _ _ _ g\u2081 g\u2082, free_pfpng.map_comp g\u2081 g\u2082 }\n\ndef Fintype.free_pfpng (T : Fintype) : ProFiltPseuNormGrp\u2081 :=\nfree_pfpng_functor.obj T\n\ndef Fintype.free_pfpng_unit :\n  Fintype.to_Profinite \u27f6 free_pfpng_functor \u22d9 ProFiltPseuNormGrp\u2081.level.obj 1 :=\n{ app := \u03bb S,\n  { to_fun := \u03bb s,\n    { val := \u03bb t, if s = t then 1 else 0,\n      property := begin\n        show finset.sum _ _ \u2264 _,\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' := \u03bb S T f, begin\n    ext s t,\n    delta ProFiltPseuNormGrp\u2081.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\u2081 :=\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\u2081.level.obj r).obj S.free_pfpng \u2245\n  limits.limit (S.fintype_diagram \u22d9 free_pfpng_functor \u22d9 ProFiltPseuNormGrp\u2081.level.obj r) :=\n(is_limit_of_preserves (ProFiltPseuNormGrp\u2081.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 \u27f6 (ProFiltPseuNormGrp\u2081.level.obj 1).obj S.free_pfpng :=\n(limit.is_limit _).map S.as_limit_cone (whisker_left _ $ Fintype.free_pfpng_unit.{u u}) \u226b\n(S.free_pfpng_level_iso 1).inv\n\n--(limits.is_limit_of_preserves (ProFiltPseuNormGrp\u2081.level.obj 1) (limits.limit.is_limit _)).map\n--  S.as_limit_cone $ whisker_left _ (Fintype.free_pfpng_unit) \u226b (functor.associator _ _ _).inv\n\ndef Profinite.free_pfpng_\u03c0 (S : Profinite) (T : discrete_quotient S) :\n  S.free_pfpng \u27f6 (Fintype.of T).free_pfpng :=\ncategory_theory.limits.limit.\u03c0 _ _\n\nlemma Profinite.free_pfpng_\u03c0_w (S : Profinite) {T\u2081 T\u2082 : discrete_quotient S} (f : T\u2081 \u27f6 T\u2082) :\n  Profinite.free_pfpng_\u03c0 S T\u2081 \u226b (S.fintype_diagram \u22d9 free_pfpng_functor).map f =\n  Profinite.free_pfpng_\u03c0 S T\u2082 :=\ncategory_theory.limits.limit.w (S.fintype_diagram \u22d9 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\u2081 v\u2082 u\u2081 u\u2082 -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u\u2081} [category.{v\u2081} 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 (\ud835\udfed 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 := \ud835\udfd9 _ } }\n\nnamespace over\n\nvariables {X : T}\n\n@[ext] lemma over_morphism.ext {X : T} {U V : over X} {f g : U \u27f6 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 (\ud835\udfd9 U) = \ud835\udfd9 U.left := rfl\n@[simp] lemma comp_left (a b c : over X) (f : a \u27f6 b) (g : b \u27f6 c) :\n  (f \u226b g).left = f.left \u226b g.left := rfl\n\n@[simp, reassoc] lemma w {A B : over X} (f : A \u27f6 B) : f.left \u226b 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 V.left) (w : f \u226b V.hom = U.hom . obviously) :\n  U \u27f6 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 \u2245 g.left) (hw : hl.hom \u226b g.hom = f.hom . obviously) :\n  f \u2245 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 \u2964 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 \u27f6 V} : (forget X).map f = f.left := rfl\n\n/--\nA morphism `f : X \u27f6 Y` induces a functor `over X \u2964 over Y` in the obvious way.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef map {Y : T} (f : X \u27f6 Y) : over X \u2964 over Y := comma.map_right _ $ discrete.nat_trans (\u03bb _, f)\n\nsection\nvariables {Y : T} {f : X \u27f6 Y} {U V : over X} {g : U \u27f6 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 \u226b 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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f \u226b g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map f \u22d9 map g :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := \u03bb Y Z f t, by exactI\n  \u27e8\u27e8over.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\u27e9\u27e9 }\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 \u27f6 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 \u27f6 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 \u27f6 g) [mono k] : mono k.left :=\nbegin\n  refine \u27e8\u03bb (Y : T) l m a, _\u27e9,\n  let l' : mk (m \u226b f.hom) \u27f6 f := hom_mk l (by { dsimp, rw [\u2190over.w k, reassoc_of a] }),\n  suffices : l' = hom_mk m,\n  { apply congr_arg comma_morphism.left this },\n  rw \u2190 cancel_mono k,\n  ext,\n  apply a,\nend\n\nsection iterated_slice\nvariables (f : over X)\n\n/-- Given f : Y \u27f6 X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iterated_slice_forward : over f \u2964 over f.left :=\n{ obj := \u03bb \u03b1, over.mk \u03b1.hom.left,\n  map := \u03bb \u03b1 \u03b2 \u03ba, over.hom_mk \u03ba.left.left (by { rw auto_param_eq, rw \u2190 over.w \u03ba, refl }) }\n\n/-- Given f : Y \u27f6 X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iterated_slice_backward : over f.left \u2964 over f :=\n{ obj := \u03bb g, mk (hom_mk g.hom : mk (g.hom \u226b f.hom) \u27f6 f),\n  map := \u03bb g h \u03b1, hom_mk (hom_mk \u03b1.left (w_assoc \u03b1 f.hom)) (over_morphism.ext (w \u03b1)) }\n\n/-- Given f : Y \u27f6 X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iterated_slice_equiv : over f \u224c over f.left :=\n{ functor := iterated_slice_forward f,\n  inverse := iterated_slice_backward f,\n  unit_iso :=\n    nat_iso.of_components\n    (\u03bb g, over.iso_mk (over.iso_mk (iso.refl _) (by tidy)) (by tidy))\n    (\u03bb X Y g, by { ext, dsimp, simp }),\n  counit_iso :=\n    nat_iso.of_components\n    (\u03bb g, over.iso_mk (iso.refl _) (by tidy))\n    (\u03bb X Y g, by { ext, dsimp, simp }) }\n\nlemma iterated_slice_forward_forget :\n  iterated_slice_forward f \u22d9 forget f.left = forget f \u22d9 forget X :=\nrfl\n\nlemma iterated_slice_backward_forget_forget :\n  iterated_slice_backward f \u22d9 forget f \u22d9 forget X = forget f.left :=\nrfl\n\nend iterated_slice\n\nsection\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `F : T \u2964 D` induces a functor `over X \u2964 over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T \u2964 D) : over X \u2964 over (F.obj X) :=\n{ obj := \u03bb Y, mk $ F.map Y.hom,\n  map := \u03bb Y\u2081 Y\u2082 f,\n  { left := F.map f.left,\n    w' := by tidy; erw [\u2190 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 (\ud835\udfed T)\n\n-- Satisfying the inhabited linter\ninstance under.inhabited [inhabited T] : inhabited (under (default T)) :=\n{ default :=\n  { right := default T,\n    hom := \ud835\udfd9 _ } }\n\nnamespace under\n\nvariables {X : T}\n\n@[ext] lemma under_morphism.ext {X : T} {U V : under X} {f g : U \u27f6 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 (\ud835\udfd9 U) = \ud835\udfd9 U.right := rfl\n@[simp] lemma comp_right (a b c : under X) (f : a \u27f6 b) (g : b \u27f6 c) :\n  (f \u226b g).right = f.right \u226b g.right := rfl\n\n@[simp, reassoc] lemma w {A B : under X} (f : A \u27f6 B) : A.hom \u226b 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 \u27f6 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 \u27f6 V.right) (w : U.hom \u226b f = V.hom . obviously) :\n  U \u27f6 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 \u2245 g.right) (hw : f.hom \u226b hr.hom = g.hom) : f \u2245 g :=\nstructured_arrow.iso_mk hr hw\n\n@[simp]\nlemma iso_mk_hom_right {f g : under X} (hr : f.right \u2245 g.right) (hw : f.hom \u226b 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 \u2245 g.right) (hw : f.hom \u226b 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 \u2964 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 \u27f6 V} : (forget X).map f = f.right := rfl\n\n/-- A morphism `X \u27f6 Y` induces a functor `under Y \u2964 under X` in the obvious way. -/\ndef map {Y : T} (f : X \u27f6 Y) : under Y \u2964 under X := comma.map_left _ $ discrete.nat_trans (\u03bb _, f)\n\nsection\nvariables {Y : T} {f : X \u27f6 Y} {U V : under Y} {g : U \u27f6 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 \u226b 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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f \u226b g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map g \u22d9 map f :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\nsection\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `F : T \u2964 D` induces a functor `under X \u2964 under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T \u2964 D) : under X \u2964 under (F.obj X) :=\n{ obj := \u03bb Y, mk $ F.map Y.hom,\n  map := \u03bb Y\u2081 Y\u2082 f,\n  { right := F.map f.right,\n    w' := by tidy; erw [\u2190 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 \u27f6[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\u2081 u\u2082 u\u2083\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 `\u00abexpr \u27f6[] \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr \u27f6[] \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr \u27f6[] \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr \u27f6[] \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr \u27f6[] \u00bb -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:207:4: warning: unsupported notation `\u00abexpr \u27f6[] \u00bb -/\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\u2081) where\n  Hom : C \u2192 C \u2192 V\n  id : \u2200 X, \ud835\udfd9_ V \u27f6 \u00abexpr \u27f6[] \u00bb X X\n  comp : \u2200 X Y Z, \u00abexpr \u27f6[] \u00bb X Y \u2297 \u00abexpr \u27f6[] \u00bb Y Z \u27f6 \u00abexpr \u27f6[] \u00bb X Z\n  id_comp : \u2200 X Y, (\u03bb_ (\u00abexpr \u27f6[] \u00bb X Y)).inv \u226b (id X \u2297 \ud835\udfd9 _) \u226b comp X X Y = \ud835\udfd9 _ := by obviously\n  comp_id : \u2200 X Y, (\u03c1_ (\u00abexpr \u27f6[] \u00bb X Y)).inv \u226b (\ud835\udfd9 _ \u2297 id Y) \u226b comp X Y Y = \ud835\udfd9 _ := by obviously\n  and_assoc :\n    \u2200 W X Y Z,\n      (\u03b1_ _ _ _).inv \u226b (comp W X Y \u2297 \ud835\udfd9 _) \u226b comp W Y Z = (\ud835\udfd9 _ \u2297 comp X Y Z) \u226b comp W X Z := by\n    obviously\n#align category_theory.enriched_category CategoryTheory.EnrichedCategory\n\n-- mathport name: enriched_category.hom\nnotation X \" \u27f6[\" V \"] \" Y:10 => (EnrichedCategory.hom X Y : V)\n\nvariable (V) {C : Type u\u2081} [EnrichedCategory V C]\n\n/-- The `\ud835\udfd9_ V`-shaped generalized element giving the identity in a `V`-enriched category.\n-/\ndef eId (X : C) : \ud835\udfd9_ V \u27f6 X \u27f6[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 \u27f6[V] Y) \u2297 Y \u27f6[V] Z) \u27f6 X \u27f6[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) : (\u03bb_ (X \u27f6[V] Y)).inv \u226b (eId V X \u2297 \ud835\udfd9 _) \u226b eComp V X X Y = \ud835\udfd9 (X \u27f6[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) : (\u03c1_ (X \u27f6[V] Y)).inv \u226b (\ud835\udfd9 _ \u2297 eId V Y) \u226b eComp V X Y Y = \ud835\udfd9 (X \u27f6[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    (\u03b1_ _ _ _).inv \u226b (eComp V W X Y \u2297 \ud835\udfd9 _) \u226b eComp V W Y Z =\n      (\ud835\udfd9 _ \u2297 eComp V X Y Z) \u226b 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\u2081) :=\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 \u27f6[V] Y)\n  id := fun X : C => F.\u03b5 \u226b F.map (eId V X)\n  comp := fun X Y Z : C => F.\u03bc _ _ \u226b F.map (eComp V X Y Z)\n  id_comp X Y := by\n    rw [comp_tensor_id, category.assoc, \u2190 F.to_functor.map_id, F.\u03bc_natural_assoc,\n      F.to_functor.map_id, F.left_unitality_inv_assoc, \u2190 F.to_functor.map_comp, \u2190\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, \u2190 F.to_functor.map_id, F.\u03bc_natural_assoc,\n      F.to_functor.map_id, F.right_unitality_inv_assoc, \u2190 F.to_functor.map_comp, \u2190\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, \u2190 F.to_functor.map_id, F.\u03bc_natural_assoc,\n      F.to_functor.map_id, \u2190 F.associativity_inv_assoc, \u2190 F.to_functor.map_comp, \u2190\n      F.to_functor.map_comp, e_assoc, id_tensor_comp, category.assoc, \u2190 F.to_functor.map_id,\n      F.\u03bc_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\u2081) [\ud835\udc9e : EnrichedCategory (Type v) C] : Category.{v} C\n    where\n  Hom := \ud835\udc9e.Hom\n  id X := eId (Type v) X PUnit.unit\n  comp X Y Z f g := eComp (Type v) X Y Z \u27e8f, g\u27e9\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) \u27e8f, g, h\u27e9 : _)\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\u2081) [\ud835\udc9e : Category.{v} C] : EnrichedCategory (Type v) C\n    where\n  Hom := \ud835\udc9e.Hom\n  id X p := \ud835\udfd9 X\n  comp X Y Z p := p.1 \u226b 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 \u27e8f, g, h\u27e9\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\u2081) : EnrichedCategory (Type v) C \u2243 Category.{v} C\n    where\n  toFun \ud835\udc9e := category_of_enriched_category_Type C\n  invFun \ud835\udc9e := enriched_category_Type_of_category C\n  left_inv \ud835\udc9e := by\n    cases \ud835\udc9e\n    dsimp [enriched_category_Type_of_category]\n    congr\n    \u00b7 ext (X\u27e8\u27e9)\n      rfl\n    \u00b7 ext (X Y Z\u27e8f, g\u27e9)\n      rfl\n  right_inv \ud835\udc9e := by\n    rcases \ud835\udc9e with @\u27e8@\u27e8\u27e8\u27e9\u27e9\u27e9\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 \u27f6 Y` is `(\ud835\udfd9_ W) \u27f6 (X \u27f6[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\u2081)\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 `(\ud835\udfd9_ W) \u27f6 (X \u27f6[W] Y)`.\n-/\nexample (X Y : ForgetEnrichment W C) :\n    (X \u27f6 Y) = (\ud835\udfd9_ W \u27f6 ForgetEnrichment.to W X \u27f6[W] ForgetEnrichment.to W Y) :=\n  rfl\n\n/-- Typecheck a `(\ud835\udfd9_ W)`-shaped `W`-morphism as a morphism in `forget_enrichment W C`. -/\ndef ForgetEnrichment.homOf {X Y : C} (f : \ud835\udfd9_ W \u27f6 X \u27f6[W] Y) :\n    ForgetEnrichment.of W X \u27f6 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 `(\ud835\udfd9_ W)`-shaped `W`-morphism. -/\ndef ForgetEnrichment.homTo {X Y : ForgetEnrichment W C} (f : X \u27f6 Y) :\n    \ud835\udfd9_ W \u27f6 ForgetEnrichment.to W X \u27f6[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 : \ud835\udfd9_ W \u27f6 X \u27f6[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 \u27f6 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 (\ud835\udfd9 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) = \ud835\udfd9 (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 \u27f6 Y) (g : Y \u27f6 Z) :\n    ForgetEnrichment.homTo W (f \u226b g) =\n      ((\u03bb_ (\ud835\udfd9_ W)).inv \u226b (ForgetEnrichment.homTo W f \u2297 ForgetEnrichment.homTo W g)) \u226b\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 \u27f6[V] Y` to `F.obj X \u27f6[V] F.obj Y`,\nsatisfying the usual axioms.\n-/\nstructure EnrichedFunctor (C : Type u\u2081) [EnrichedCategory V C] (D : Type u\u2082)\n  [EnrichedCategory V D] where\n  obj : C \u2192 D\n  map : \u2200 X Y : C, (X \u27f6[V] Y) \u27f6 obj X \u27f6[V] obj Y\n  map_id' : \u2200 X : C, eId V X \u226b map X X = eId V (obj X) := by obviously\n  map_comp' :\n    \u2200 X Y Z : C,\n      eComp V X Y Z \u226b map X Z = (map X Y \u2297 map Y Z) \u226b 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\u2081) [EnrichedCategory V C] : EnrichedFunctor V C C\n    where\n  obj X := X\n  map X Y := \ud835\udfd9 _\n#align category_theory.enriched_functor.id CategoryTheory.EnrichedFunctor.id\n\ninstance : Inhabited (EnrichedFunctor V C C) :=\n  \u27e8EnrichedFunctor.id V C\u27e9\n\n/-- Composition of enriched functors. -/\n@[simps]\ndef EnrichedFunctor.comp {C : Type u\u2081} {D : Type u\u2082} {E : Type u\u2083} [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 _ _ \u226b 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 `(\ud835\udfd9_ W)`-shaped morphisms.\n-/\ndef EnrichedFunctor.forget {C : Type u\u2081} {D : Type u\u2082} [EnrichedCategory W C] [EnrichedCategory W D]\n    (F : EnrichedFunctor W C D) : ForgetEnrichment W C \u2964 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 \u226b 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    \u00b7 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    \u00b7 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\u2082} [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(\ud835\udfd9_ W) \u27f6 (F.obj X \u27f6[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 \u27f6 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 \u2243 (\ud835\udfd9_ V) \u27f6 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 \u27f6 (F.obj X \u27f6[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 := \ud835\udfd9_ 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 : \u2200 X : C, A.1 \u27f6 F.obj X \u27f6[V] G.obj X\n  naturality :\n    \u2200 X Y : C,\n      (A.2.\u03b2 (X \u27f6[V] Y)).Hom \u226b (F.map X Y \u2297 app Y) \u226b eComp V _ _ _ =\n        (app X \u2297 G.map X Y) \u226b 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\u1d52\u1d56 \u2964 Type max u\u2081 w\n    where\n  obj A := GradedNatTrans ((Center.ofBraided V).obj (unop A)) F G\n  map A A' f \u03c3 :=\n    { app := fun X => f.unop \u226b \u03c3.app X\n      naturality := fun X Y => by\n        have p := \u03c3.naturality X Y\n        dsimp at p\u22a2\n        rw [\u2190 id_tensor_comp_tensor_id (f.unop \u226b \u03c3.app Y) _, id_tensor_comp, category.assoc,\n          category.assoc, \u2190 braiding_naturality_assoc, id_tensor_comp_tensor_id_assoc, p, \u2190\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\u2081} [\ud835\udc9e : EnrichedCategory (Type v) C] {D : Type u\u2082}\n    [\ud835\udc9f : EnrichedCategory (Type v) D] : EnrichedFunctor (Type v) C D \u2243 C \u2964 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) \u27e8f, g\u27e9 }\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 \u27e8\u27e9\n        exact F.map_id X\n      map_comp' := fun X Y Z => by\n        ext \u27e8f, g\u27e9\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 \u2245\n      yoneda.obj (enrichedFunctorTypeEquivFunctor F \u27f6 enrichedFunctorTypeEquivFunctor G) :=\n  NatIso.ofComponents\n    (fun \u03b1 =>\n      { Hom := fun \u03c3 x =>\n          { app := fun X => \u03c3.app X x\n            naturality' := fun X Y f => congr_fun (\u03c3.naturality X Y) \u27e8x, f\u27e9 }\n        inv := fun \u03c3 =>\n          { app := fun X x => (\u03c3 x).app X\n            naturality := fun X Y => by\n              ext \u27e8x, f\u27e9\n              exact (\u03c3 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*} (\u0393\u2081 \u0393\u2082 : measurable_space S ) : Prop :=\n  \u2200 (E : set S ) , (\u0393\u2081.is_measurable' E) \u2192 (\u0393\u2082.is_measurable' E)\n\nlemma is_subsigmaalg_iff_le {S : Type*} {\u0393\u2081 \u0393\u2082 : measurable_space S } :\n  is_subsigmaalg \u0393\u2081 \u0393\u2082 \u2194 \u0393\u2081 \u2264 \u0393\u2082 :=\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*} (\u0393 : measurable_space S ) :\n  is_subsigmaalg \u0393 \u0393 := by { intros E hE , exact hE , }\n\n@[simp]\nlemma self_le_self_sigmaalg {S : Type*} (\u0393 : measurable_space S ) :\n  \u0393 \u2264 \u0393 := by { intros E hE , exact hE , }\n\nlemma self_is_subsigmaalg' {S : Type*} (\u0393 : measurable_space S ) :\n  is_subsigmaalg \u0393 \u0393 :=\nbegin\n  have key : \u0393 \u2264 \u0393 ,\n  { intros E hE ,\n    exact hE , } , \n  rwa is_subsigmaalg_iff_le ,\nend\n\ndef is_trivial_sigmaalg {S : Type*} (\u0393 : measurable_space S ) : Prop :=\n  \u2200 (E : set S ) , (\u0393.is_measurable' E) \u2192 (E = \u2205 \u2228 E = univ) \n\n@[simp]\nlemma trivial_is_subsigmaalg {S : Type*}\n  (\u0393triv \u0393 : measurable_space S ) [htriv : is_trivial_sigmaalg \u0393triv] :\n  is_subsigmaalg \u0393triv \u0393 :=\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 \u0393 , } , \n  { rw huniv ,\n    have mbleuniv := (\u0393.is_measurable_compl \u2205 \u0393.is_measurable_empty) ,\n    simp at mbleuniv ,\n    exact mbleuniv , } ,\nend\n\n@[simp]\nlemma trivial_le_sigmaalg {S : Type*}\n  (\u0393triv \u0393 : measurable_space S ) [htriv : is_trivial_sigmaalg \u0393triv] :\n  \u0393triv \u2264 \u0393 :=\nbegin\n  have key := ( @trivial_is_subsigmaalg S \u0393triv \u0393 htriv ) ,\n  rw \u2190 is_subsigmaalg_iff_le ,\n  exact key ,\nend\n\nlemma mble_of_submble {S T : Type*} [measurable_space T] (f : S \u2192 T)\n  (\u0393sub \u0393full : measurable_space S ) [hsub : \u0393sub \u2264 \u0393full] :\n  (@measurable S T \u0393sub _ f) \u2192 (@measurable S T \u0393full _ f) :=\nbegin\n  intros hf B hB ,\n  exact hsub (f\u207b\u00b9' B) (hf hB) ,\nend\n\nstructure cond_exp_enn {S : Type*} (f : S \u2192 ennreal)\n  (\u0393sub \u0393full : measurable_space S ) [hsub : \u0393sub \u2264 \u0393full]\n  (\u03bc : @measure_theory.measure S \u0393full) :=\n  -- In the current version I am not requiring measurability\n  --     [hf : @measurable S ennreal \u0393full _ f]\n  -- and integrability. I even failed to state integrability,\n  -- the following does not work:\n  --     [hintble : measure_theory.has_finite_integral f \u03bc]\n  -- Also I'm not requiring that the measure is a\n  -- probability measure.\n  --     [hproba : probability_measure \u03bc]\n  -- All of these would almost always\n  -- be needed, so should they be a part of the definition?\n    ( to_fun : S \u2192 ennreal )\n    ( is_submeasurable : @measurable S ennreal \u0393sub _ to_fun )\n    ( equal_subintegrals : \u2200 (E : set S) , \u0393sub.is_measurable' E \u2192\n        \u222b\u207b x in E , to_fun(x) \u2202 \u03bc = \u222b\u207b x in E , f(x) \u2202 \u03bc )\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  {\u0393sub \u0393full : measurable_space S} [hsub : is_subsigmaalg \u0393sub \u0393full]\n  {f : S \u2192 ennreal} {\u03bc : @measure_theory.measure S \u0393full} :\n  has_coe_to_fun (@cond_exp_enn S f \u0393sub \u0393full hsub \u03bc)  :=\n{ coe := sorry ,\n  F := sorry ,\n}\n\n\nlemma cond_exp_enn_full {S : Type*} \n  {\u0393 : measurable_space S}\n  {f : S \u2192 ennreal} [hf : @measurable S ennreal \u0393 _ f]\n  {\u03bc : @measure_theory.measure S \u0393} :\n  @cond_exp_enn S f \u0393 \u0393 (self_le_self_sigmaalg \u0393) \u03bc :=\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  {\u0393triv \u0393 : measurable_space S} [htriv  : is_trivial_sigmaalg \u0393triv]\n  {f : S \u2192 ennreal} [hf : @measurable S ennreal \u0393 _ f]\n  {\u03bc : @measure_theory.measure S \u0393} [hproba : probability_measure \u03bc] :\n  @cond_exp_enn S f \u0393triv \u0393 (@trivial_le_sigmaalg S \u0393triv \u0393 htriv) \u03bc :=\n{ to_fun := ( \u03bb (z : S) , ( \u222b\u207b x , f(x) \u2202 \u03bc ) ) ,\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": "example (P Q : Prop) : Q \u2192 (P \u2228 Q) :=\nbegin\nintro h,\nright,\nexact h,\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/Advanced_Proposition/6.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7090191214879992, "lm_q2_score": 0.658417487156366, "lm_q1q2_score": 0.46683058831594265}}
{"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\u00e9ories galoisiennes page 45\n          exemple : in the category of presheaf.\n          in Ring ? Idem ?\n     contexte : \ud835\udc9e a un objet final et a les produit finis !\nPour coder \u03bc X \u00d7 X \u27f6 X  We see that has X \u27f6 T cospan f f)\n\n-/\n-- notation         f ` \u2297 `: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 \u27f6 X \u2a2f Y  \n#         T X       :  X \u27f6 T C\n#         (f \u2297 g)  :  Z1 \u2a2f Z2 \u27f6 X1 \u2a2f X2 \n!-/\n\nstructure group_obj (C : Type u)[ \ud835\udc9e : category.{v} C ] [ (has_binary_products.{v} C) ] [ (has_terminal.{v} C) ] :=\n(X : C)\n(\u03bc : X \u2a2f X \u27f6 X)\n(inv : X \u27f6 X)\n(\u03b5 :  T C \u27f6 X)\n(hyp_one_mul  :  (T X | \ud835\udfd9 X) \u226b (\u03b5 \u2297 \ud835\udfd9 X) \u226b  \u03bc  = \ud835\udfd9 X)\n(hyp_mul_one  :  (\ud835\udfd9 X | T X) \u226b ( \ud835\udfd9 X \u2297 \u03b5) \u226b \u03bc  = \ud835\udfd9 X)\n(hyp_inv_mul  :  (inv | \ud835\udfd9 X) \u226b  \u03bc = (T X) \u226b \u03b5 )\n(hyp_assoc    :  (\u03bc \u2297 \ud835\udfd9 X) \u226b (\u03bc) = (prod.associator X X X).hom \u226b (\ud835\udfd9 X \u2297 \u03bc)  \u226b \u03bc )   -- (a *b) * c = (a * (b * c))\n\nvariables (C : Type u)\nvariables [\ud835\udc9e : category.{v} C]\nvariables  [has_binary_products.{v} C][has_terminal.{v} C]\ninclude \ud835\udc9e\ninstance coee : has_coe (group_obj C) C := \u27e8\u03bb F, F.X\u27e9 --- ?\nvariables (G : group_obj C)\ninclude G\n-- we start by rewriting a little \nlemma mul_one' : (\ud835\udfd9 G.X | T G.X) \u226b ( \ud835\udfd9 G.X \u2297 G.\u03b5) \u226b G.\u03bc  = (\ud835\udfd9 G.X  | (T G.X) \u226b G.\u03b5) \u226b G.\u03bc :=\nbegin\n     rw \u2190 assoc,\n     rw prod.prod_comp_otimes,\n     rw comp_id,\nend\nlemma one_mul' : (T G.X | \ud835\udfd9 G.X) \u226b (G.\u03b5 \u2297 \ud835\udfd9 G.X) \u226b  G.\u03bc  = ((T G.X) \u226b G.\u03b5 | \ud835\udfd9 G.X) \u226b G.\u03bc := \nbegin \n     rw \u2190 assoc,\n     rw prod.prod_comp_otimes,\n     rw comp_id,\nend \nlemma one_mul_R (R A : C) (\u03b6 : R\u27e6G.X\u27e7 ): R < ((T G.X) \u226b G.\u03b5 | \ud835\udfd9 G.X) \u226b G.\u03bc > \u03b6  =  \u03b6 :=\n begin \n     rw \u2190 one_mul',\n     rw G.hyp_one_mul,\n     rw Yoneda.id,exact rfl,\nend\nlemma mul_one_R (R A : C) (\u03b6 : R\u27e6G.X\u27e7 ): R < ( \ud835\udfd9 G.X | (T G.X) \u226b G.\u03b5 ) \u226b G.\u03bc > \u03b6  =  \u03b6 := \nbegin\n     rw \u2190 mul_one', rw G.hyp_mul_one,rw Yoneda.id,\n     exact rfl, \n end\ndef one   (R : C) : R \u27e6(G.X) \u27e7  :=  \nbegin                                   ---- ici l'unit\u00e9 est R<\u03b5> (T G.X) l'image du terminal \n     exact (terminal.from R \u226b G.\u03b5),\nend\ndef mul (R : C) : R\u27e6 G.X\u27e7   \u2192 R\u27e6 G.X\u27e7  \u2192 R \u27e6 G.X \u27e7  :=  \u03bb g1 g2, \nbegin \n     let \u03c6 := ( g1 | g2),\n     let \u03b2 := (R< (G.\u03bc) > : R\u27e6 G.X \u2a2f G.X\u27e7  \u27f6 R\u27e6G.X\u27e7),\n     exact \u03b2 \u03c6,\nend\nvariables (R : C)\ninclude R\ninstance yoneda_mul : has_mul (R\u27e6 G.X\u27e7) := \u27e8mul C G R \u27e9 \ninstance yoneda_one : has_one (R\u27e6 G.X\u27e7) := \u27e8one C G R \u27e9\n@[PRODUCT]lemma mul_comp (a b : R \u27e6 G.X\u27e7 ) : a * b = (R < G.\u03bc >) (a | b) := rfl -- priority R < g.\u03bc > (a | b) not ()\n@[PRODUCT]lemma one_comp :  (1 : R \u27e6 G.X \u27e7) = terminal.from R \u226b G.\u03b5 := rfl\n\nnotation Y `\u27f6\u2022`  := T Y \n@[PRODUCT]lemma Terminal_comp{Y : C} ( a : R \u27f6 Y) : a \u226b (Y \u27f6\u2022) = (R \u27f6\u2022) := \nby exact subsingleton.elim (a \u226b T Y) (T R)\n\nlemma one_mulf' (\u03b6  : R\u27e6G.X \u27e7) :    1 * \u03b6  = \u03b6  := begin\n     rw mul_comp,rw one_comp, --- (T X | \ud835\udfd9 X) \u226b (\u03b5 \u2297 \ud835\udfd9 X) \u226b  \u03bc  = \ud835\udfd9 X)\n     let V := one_mul_R C G R R \u03b6,\n     rw [Yoneda.apply_to_composition, \u2190 assoc,prod.left_composition,comp_id\n     ,\u2190 assoc,Terminal_comp,Yoneda.composition_to_apply] at V,\n     exact V,\n     use G,\nend\nlemma mul_onef'(\u03b6 : R\u27e6G.X \u27e7)  : \u03b6 * 1 = \u03b6 := begin \n     rw mul_comp,rw one_comp,\n     have V := mul_one_R C G R R \u03b6,\n     rw [Yoneda.apply_to_composition, \u2190 assoc,prod.left_composition,comp_id,\u2190 assoc\n     ,Terminal_comp,Yoneda.composition_to_apply] at V,\n     exact V,\n     use G,\nend \ndef inv' (R :C) : R\u27e6 G.X\u27e7 \u2192 R\u27e6 G.X\u27e7   := \u03bb  \u03b6, begin \n     exact R<G.inv> \u03b6, \nend\ninstance yoneda_inv (R :C) : has_inv (R\u27e6G.X\u27e7) := \u27e8inv' C G R\u27e9\nlemma  inv_comp (\u03b6 : R \u27e6 G.X\u27e7 ) : \u03b6\u207b\u00b9  =  (R<G.inv>) \u03b6  := rfl\nlemma mul_left_inv' (\u03b6 : R \u27e6 G.X \u27e7) : (\u03b6\u207b\u00b9 * \u03b6 ) = 1 :=  begin \n     rw inv_comp,rw mul_comp,rw one_comp,\n      rw Yoneda.apply_to_composition,\n     have V : R< (G.inv | \ud835\udfd9 G.X )   \u226b  G.\u03bc> \u03b6 = (R<(T G.X) \u226b G.\u03b5>) \u03b6 ,\n          rw G.hyp_inv_mul,\n     rw [Yoneda.apply_to_composition,Yoneda.apply_to_composition,\n     \u2190 assoc,prod.left_composition,comp_id,\u2190 assoc,Terminal_comp,Yoneda.composition_to_apply] at V,\n     assumption, use G, \nend\nlemma Grall (a b c : R \u27e6G.X \u27e7) : R < (prod.associator G.X G.X G.X).hom \u226b (\ud835\udfd9 G.X \u2297 G.\u03bc) \u226b G.\u03bc> (a | b | c) \n     =(R < G.\u03bc>) (a | (R < G.\u03bc> (b | c))) := begin \n     tidy,\n     rw [Yoneda.apply_to_composition, \u2190 assoc,prod.left_composition,\n     \u2190 assoc,prod.prod_comp_otimes,Yoneda.apply_to_composition,Yoneda.apply_to_composition],\n     rw comp_id,\n     rw [\u2190 assoc,prod.left_composition,prod.lift_fst,prod.lift_fst,\n     prod.lift_snd,\u2190 assoc,prod.lift_fst,prod.lift_snd],\nend \n-- (hyp_mul_inv  :  (inv | \ud835\udfd9 X ) \u226b  \u03bc = (T X) \u226b \u03b5 )\nlemma mul_assoc' (a b c : R \u27e6G.X \u27e7) : a * b *c = a * ( b * c ) := begin \n     iterate 4 { rw mul_comp}, PRODUCT_CAT,\n     have ASSOC : R<((G.\u03bc \u2297 (\ud835\udfd9 G.X)) \u226b (G.\u03bc)) >(a | b | c) = (R<(prod.associator G.X G.X G.X).hom \u226b (\ud835\udfd9 G.X \u2297 G.\u03bc)  \u226b G.\u03bc>) (a | b | c),\n          rw G.hyp_assoc,\n     rw [Yoneda.apply_to_composition,\u2190 assoc,prod.prod_comp_otimes,comp_id,\n     \u2190 Yoneda.apply_to_composition, \u2190 Yoneda.apply_to_composition] at ASSOC,\n     have G_hyp : R < (prod.associator G.X G.X G.X).hom \u226b (\ud835\udfd9 G.X \u2297 G.\u03bc) \u226b G.\u03bc> (a | b | c) \n     =(R < G.\u03bc>) (a | (R < G.\u03bc> (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 \u226b (\ud835\udfd9 G.X \u2297 G.\u03bc)  \u226b G.\u03bc> (a | b | c),\n\nend\n\ninstance : group (R\u27e6G.X\u27e7) :=  \n{    \n     mul := has_mul.mul,\n     mul_assoc := mul_assoc' C G R,\n     one    := (1 : R\u27e6 G.X\u27e7),\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 \u2113objx \u2113homx \u2113obj \u2113hom \u2113obj\u2081 \u2113hom\u2081 \u2113obj\u2082 \u2113hom\u2082\n\n\n\n/- -----------------------------------------------------------------------\nPullbacks.\n----------------------------------------------------------------------- -/\n\n/-! #brief Homs in a cospan category.\n-/\ninductive CoSpanHom (N : \u2115) : option (fin N) \u2192 option (fin N) \u2192 Type\n| id : \u2200 (x : option (fin N)), CoSpanHom x x\n| hom : \u2200 (n : fin N), CoSpanHom (some n) none\n\n/-! #brief A cospan category.\n-/\ndefinition CoSpanCat (N : \u2115) : Cat.{0 1}\n:= { obj := option (fin N)\n   , hom := CoSpanHom N\n   , id := CoSpanHom.id\n   , circ := \u03bb x y z g f, begin cases f, { exact g }, { cases g, apply CoSpanHom.hom } end\n   , circ_assoc := \u03bb x y z w h g f, begin cases f, { trivial }, { cases g, trivial } end\n   , circ_id_left := \u03bb x y f, begin cases f, { trivial }, { trivial } end\n   , circ_id_right := \u03bb 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 : \u2115)\n    : Fun (CoSpanCat N) (CoSpanCat (nat.succ N))\n:= { obj := \u03bb n, option.cases_on n option.none (\u03bb n', option.some (stdaux.fin.add n' 1))\n   , hom := \u03bb x y f\n            , begin\n                cases f,\n                { apply CoSpanHom.id },\n                { apply CoSpanHom.hom }\n              end\n   , hom_id := \u03bb x, rfl\n   , hom_circ := \u03bb 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.{\u2113obj \u2113hom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    : Fun (CoSpanCat (list.length factor)) C\n:= { obj := \u03bb a, option.cases_on a t (list.get factor)\n   , hom := \u03bb a\u2081 a\u2082 f, begin cases f, { apply C^.id }, { exact HomsIn.get maps n } end\n   , hom_id := \u03bb a, rfl\n   , hom_circ := \u03bb a\u2081 a\u2082 a\u2083 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.{\u2113obj \u2113hom}}\n    : \u2200 {N : \u2115}\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 \u25a1\u25a1 CoSpanCat.forget_base N)\n\n/-! #brief Every functor out of CoSpanCat is a PullbackDrgm.\n-/\ntheorem PullbackDrgm.length_mk_doms {C : Cat.{\u2113obj \u2113hom}}\n    : \u2200 {N : \u2115}\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 \u25a1\u25a1 CoSpanCat.forget_base N))\n\n/-! #brief Every functor out of CoSpanCat is a PullbackDrgm.\n-/\ndefinition PullbackDrgm.mk_homs {C : Cat.{\u2113obj \u2113hom}}\n    : \u2200 {N : \u2115}\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 \u25a1\u25a1 CoSpanCat.forget_base N))\n\n/-! #brief Every functor out of CoSpanCat is a PullbackDrgm.\n-/\ntheorem PullbackDrgm.uniq {C : Cat.{\u2113obj \u2113hom}}\n    {N : \u2115}\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\u2081 n\u2082 \u03c9n,\n       dsimp [PullbackDrgm],\n       cases n\u2081 with n\u2081 \u03c9n\u2081,\n       { cases n\u2082 with n\u2082 \u03c9n\u2082,\n         { trivial },\n         { exact sorry } -- TODO\n       },\n       { cases n\u2082 with n\u2082 \u03c9n\u2082,\n         { exact sorry }, -- TODO\n         { exact sorry } -- TODO\n       } \n     },\n     { intros x\u2081 y\u2081 x\u2082 y\u2082 f\u2081 f\u2082 \u03c9f,\n       cases f\u2081,\n       { cases f\u2082,\n         { exact sorry }, -- TODO\n         { exact sorry } -- TODO\n       },\n       { cases f\u2082,\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.{\u2113obj \u2113hom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    : Type (max \u2113obj \u2113hom)\n:= Cone (PullbackDrgm C maps)\n\n/-! #brief Helper for making a pullback cone.\n-/\ndefinition PullbackCone.mk {C : Cat.{\u2113obj \u2113hom}}\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    (\u03c9proj : HomsList.repeat to_t (list.length factor)\n              = homs_in_comp_out maps proj)\n    : PullbackCone C maps\n:= { obj := c\n   , hom := \u03bb x, option.cases_on x to_t (HomsOut.get proj)\n   , comm := \u03bb x\u2081 x\u2082 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 \u03c9proj\n                         }\n                       end\n   }\n\n/-! #brief The projections out of a pullback cone.\n-/\ndefinition PullbackCone.Proj {C : Cat.{\u2113obj \u2113hom}}\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.{\u2113obj \u2113hom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n:= HasLimit (PullbackDrgm C maps)\n\ninstance HasPullback.HasLimit {C : Cat.{\u2113obj \u2113hom}}\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.{\u2113obj \u2113hom})\n:= (has_pullback : \u2200 {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.{\u2113obj \u2113hom})\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.{\u2113obj \u2113hom})\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    (N : \u2115)\n    : HasAllLimitsFrom C (CoSpanCat (nat.succ N))\n:= { has_limit := \u03bb 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.{\u2113obj \u2113hom})\n    {base t : C^.obj} (f : C^.hom base t)\n:= (has_pullback : \u2200 {y : C^.obj} (map : C^.hom y t)\n                   , HasPullback C (f \u2197\u2192 map \u2197\u2192\u2197))\n\ninstance HasPullbacksAlong.HasPullback (C : Cat.{\u2113obj \u2113hom})\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 \u2197\u2192 map \u2197\u2192\u2197)\n:= HasPullbacksAlong.has_pullback f map\n\ninstance HasAllPullbacks.HasPullbacksAlong (C : Cat.{\u2113obj \u2113hom})\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {base t : C^.obj} (f : C^.hom base t)\n    : HasPullbacksAlong C f\n:= { has_pullback := \u03bb y map, HasAllPullbacks.has_pullback (f \u2197\u2192 map \u2197\u2192\u2197)\n   }\n\n/-! #brief Helper for showing a category has a pullback.\n-/\ndefinition HasPullback.show (C : Cat.{\u2113obj \u2113hom})\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    (\u03c9proj : HomsList.repeat to_t (list.length factor)\n              = homs_in_comp_out maps proj)\n    (univ : \u2200 {c : C^.obj} (to_t' : C^.hom c t) (hom : HomsOut c factor)\n              (\u03c9hom : HomsList.repeat\n                       to_t'\n                       (list.length factor)\n                       = homs_in_comp_out maps hom)\n            , C^.hom c p)\n    (\u03c9univ : \u2200 {c : C^.obj} (to_t' : C^.hom c t) (hom : HomsOut c factor)\n              (\u03c9hom : 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 \u03c9hom))\n    (\u03c9uniq : \u2200 {c : C^.obj} (to_t' : C^.hom c t) (hom : HomsOut c factor)\n              (\u03c9hom : HomsList.repeat\n                       to_t'\n                       (list.length factor)\n                       = homs_in_comp_out maps hom)\n               (h : C^.hom c p)\n               (\u03c9comm : hom = HomsOut.comp proj h)\n             , h = univ to_t' hom \u03c9hom)\n    : HasPullback C maps\n:= HasLimit.show p (\u03bb x, option.cases_on x to_t ((HomsOut.get proj)))\n    (\u03bb x\u2081 x\u2082 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 \u03c9proj\n                 }\n               end)\n    (\u03bb c hom \u03c9comm, univ (hom none) (HomsOut.enum (\u03bb n, hom (some n)))\n     begin\n       exact sorry\n     end)\n    (\u03bb c hom \u03c9comm a, begin exact sorry end)\n    (\u03bb c hom \u03c9comm h \u03c9h, begin exact sorry end)\n\n/-! #brief Pullbacks are cones.\n-/\ndefinition pullback.cone (C : Cat.{\u2113obj \u2113hom})\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.{\u2113obj \u2113hom})\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.\u03c0 (C : Cat.{\u2113obj \u2113hom})\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.\u03c0_comm (C : Cat.{\u2113obj \u2113hom})\n    {factor : list C^.obj} {t : C^.obj}\n    (maps : HomsIn factor t)\n    [maps_HasPullback : HasPullback C maps]\n    (n\u2081 n\u2082 : fin (list.length factor))\n    : HomsIn.get maps n\u2081 \u2218\u2218 pullback.\u03c0 C maps n\u2081\n       = HomsIn.get maps n\u2082 \u2218\u2218 pullback.\u03c0 C maps n\u2082\n:= sorry\n\n/-! #brief Projection out of a pullback to the base.\n-/\ndefinition pullback.\u03c0base (C : Cat.{\u2113obj \u2113hom})\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.{\u2113obj \u2113hom})\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.{\u2113obj \u2113hom})\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.\u03c0 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.{\u2113obj \u2113hom})\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.\u03c0base 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.{\u2113obj \u2113hom})\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    (\u03c9 : \u2200 (n : fin (list.length factor))\n         , c^.hom (some n) = (@pullback.\u03c0 C factor t maps maps_HasPullback n) \u2218\u2218 m)\n    (\u03c9base : c^.hom none = (@pullback.\u03c0base C factor t maps maps_HasPullback) \u2218\u2218 m)\n    : m = pullback.univ C maps c\n:= limit.univ.uniq c m (\u03bb x, option.cases_on x \u03c9base \u03c9)\n\n/-! #brief The unique iso between two pullbacks of the same homs.\n-/\ndefinition pullback.iso {C : Cat.{\u2113obj \u2113hom}}\n    {factor : list C^.obj} {t : C^.obj}\n    {maps : HomsIn factor t}\n    (maps_HasPullback\u2081 maps_HasPullback\u2082 : HasPullback C maps)\n    : C^.hom (@pullback C factor t maps maps_HasPullback\u2081)\n             (@pullback C factor t maps maps_HasPullback\u2082)\n:= limit.iso maps_HasPullback\u2081 maps_HasPullback\u2082\n\n/-! #brief Pullbacks are unique up-to unique isomorphism.\n-/\ndefinition pullback.uniq {C : Cat.{\u2113obj \u2113hom}}\n    {factor : list C^.obj} {t : C^.obj}\n    {maps : HomsIn factor t}\n    (maps_HasPullback\u2081 maps_HasPullback\u2082 : HasPullback C maps)\n    : Iso (pullback.iso maps_HasPullback\u2081 maps_HasPullback\u2082)\n          (pullback.iso maps_HasPullback\u2082 maps_HasPullback\u2081)\n:= limit.uniq maps_HasPullback\u2081 maps_HasPullback\u2082\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    [D_HasAllPullbacks : HasAllPullbacks D]\n    : HasAllPullbacks (FunCat C D)\n:= { has_pullback := \u03bb 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.{\u2113obj \u2113hom}}\n    {p x y t : C^.obj}\n    (base : C^.hom x t) (p\u2081 : C^.hom p x)\n    (map : C^.hom y t)  (p\u2082 : C^.hom p y)\n:= (has_pullback : HasPullback C (base \u2197\u2192 map \u2197\u2192\u2197))\n   (\u03c9pullback : @pullback C [x, y] t _ has_pullback = p)\n   (\u03c9\u03c0\u2081 : @pullback.\u03c0 C [x, y] t _ has_pullback (@fin_of 1 0) = p\u2081 \u2218\u2218 cast_hom \u03c9pullback)\n   (\u03c9\u03c0\u2082 : @pullback.\u03c0 C [x, y] t _ has_pullback (@fin_of 0 1) = p\u2082 \u2218\u2218 cast_hom \u03c9pullback)\n\n/-! #brief Pullback squares have the usual commutative diagram.\n-/\ntheorem ispullback.square {C : Cat.{\u2113obj \u2113hom}}\n    {p x y t : C^.obj}\n    {base : C^.hom x t} {p\u2081 : C^.hom p x}\n    {map : C^.hom y t}  {p\u2082 : C^.hom p y}\n    (isPullback : IsPullback base p\u2081 map p\u2082)\n    : C^.circ base p\u2081 = C^.circ map p\u2082\n:= sorry\n\n/-! #brief The universal map into a pullback square.\n-/\ndefinition ispullback.univ {C : Cat.{\u2113obj \u2113hom}}\n    {p x y t : C^.obj}\n    {base : C^.hom x t} {p\u2081 : C^.hom p x}\n    {map : C^.hom y t}  {p\u2082 : C^.hom p y}\n    (isPullback : IsPullback base p\u2081 map p\u2082)\n    {c : C^.obj} (h\u2081 : C^.hom c x) (h\u2082 : C^.hom c y)\n    (\u03c9square : C^.circ base h\u2081 = C^.circ map h\u2082)\n    : C^.hom c p\n:= C^.circ\n    (cast_hom (IsPullback.\u03c9pullback base p\u2081 map p\u2082))\n    (@pullback.univ _ _ _ _ (IsPullback.has_pullback base p\u2081 map p\u2082)\n      (PullbackCone.mk _ c (C^.circ base h\u2081) (h\u2081 \u2197\u2190 h\u2082 \u2197\u2190\u2197)\n        begin\n          apply dlist.eq,\n          { trivial },\n          apply dlist.eq,\n          { exact \u03c9square },\n          trivial\n        end))\n\n/-! #brief Helper for showing one has a pullback square.\n-/\ndefinition IsPullback.show {C : Cat.{\u2113obj \u2113hom}}\n    {p x y t : C^.obj}\n    {base : C^.hom x t} {p\u2081 : C^.hom p x}\n    {map : C^.hom y t}  {p\u2082 : C^.hom p y}\n    (univ\n      : \u2200 {c : C^.obj} (h\u2081 : C^.hom c x) (h\u2082 : C^.hom c y)\n          (\u03c9square : C^.circ base h\u2081 = C^.circ map h\u2082)\n        , C^.hom c p)\n    (\u03c9square\n      : C^.circ base p\u2081 = C^.circ map p\u2082)\n    (\u03c9univ\u2081\n      : \u2200 {c : C^.obj} (h\u2081 : C^.hom c x) (h\u2082 : C^.hom c y)\n          (\u03c9square : C^.circ base h\u2081 = C^.circ map h\u2082)\n        , h\u2081 = C^.circ p\u2081 (univ h\u2081 h\u2082 \u03c9square))\n    (\u03c9univ\u2082\n      : \u2200 {c : C^.obj} (h\u2081 : C^.hom c x) (h\u2082 : C^.hom c y)\n          (\u03c9square : C^.circ base h\u2081 = C^.circ map h\u2082)\n        , h\u2082 = C^.circ p\u2082 (univ h\u2081 h\u2082 \u03c9square))\n    (\u03c9univ_uniq\n      : \u2200 {c : C^.obj} (h\u2081 : C^.hom c x) (h\u2082 : C^.hom c y)\n          (\u03c9square : C^.circ base h\u2081 = C^.circ map h\u2082)\n          (univ' : C^.hom c p)\n          (\u03c9univ'\u2081 : h\u2081 = C^.circ p\u2081 univ')\n          (\u03c9univ'\u2082 : h\u2082 = C^.circ p\u2082 univ')\n        , univ' = univ h\u2081 h\u2082 \u03c9square)\n    : IsPullback base p\u2081 map p\u2082\n:= { has_pullback\n      := HasPullback.show C (base \u2197\u2192 map \u2197\u2192\u2197) p\n          (C^.circ base p\u2081)\n          (p\u2081 \u2197\u2190 p\u2082 \u2197\u2190\u2197)\n          begin\n            apply dlist.eq,\n            { trivial },\n            apply dlist.eq,\n            { exact \u03c9square },\n            trivial\n          end\n          (\u03bb c to_t homs \u03c9homs\n           , begin\n               cases homs with _ h\u2081 _ homs,\n               cases homs with _ h\u2082 _ _,\n               cases bb,\n               apply univ h\u2081 h\u2082,\n               refine @eq.trans _  _ to_t _  _ _,\n               { apply eq.symm,\n                 apply HomsList.congr_get \u03c9homs (@fin_of 1 0)\n               },\n               { apply HomsList.congr_get \u03c9homs (@fin_of 0 1) }\n             end)\n          (\u03bb c to_t homs \u03c9homs\n           , begin\n               cases homs with _ h\u2081 _ homs,\n               cases homs with _ h\u2082 _ _,\n               cases bb,\n               apply dlist.eq,\n               { apply \u03c9univ\u2081 },\n               apply dlist.eq,\n               { apply \u03c9univ\u2082 },\n               trivial\n             end)\n          (\u03bb c to_t homs \u03c9homs h \u03c9h\n           , begin\n               cases homs with _ h\u2081 _ homs,\n               cases homs with _ h\u2082 _ _,\n               cases bb,\n               apply \u03c9univ_uniq,\n               { apply dlist.congr_get \u03c9h (@fin_of 1 0) },\n               { apply dlist.congr_get \u03c9h (@fin_of 0 1) }\n             end)\n   , \u03c9pullback := rfl\n   , \u03c9\u03c0\u2081 := eq.symm C^.circ_id_right\n   , \u03c9\u03c0\u2082 := 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.{\u2113obj \u2113hom})\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.{\u2113obj \u2113hom})\n    (base : C^.obj \u00d7 C^.obj) (factor : list (C^.obj \u00d7 C^.obj)) {t : C^.obj}\n    (maps\u2081 : HomsIn (list.map prod.fst (base :: factor)) t)\n    [maps\u2081_HasPullback : HasPullback C maps\u2081]\n    (maps\u2082 : HomsIn (list.map prod.snd (base :: factor)) t)\n    [maps\u2082_HasPullback : HasPullback C maps\u2082]\n    (fns : HomsList C (base :: factor))\n    : C^.hom (pullback C maps\u2081)\n             (pullback C maps\u2082)\n:= pullback.univ _ _\n    (PullbackCone.mk maps\u2082 (pullback C maps\u2081)\n      (HomsIn.get maps\u2082 fin.zero\n        \u2218\u2218 HomsList.get fns fin.zero\n        \u2218\u2218 pullback.\u03c0 C maps\u2081 fin.zero)\n      (homs_comp_out fns (pullback.cone C maps\u2081)^.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.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x y : C^.obj} (f : C^.hom x y)\n    (y\u2080 : C^.hom (final C) y)\n    : C^.obj\n:= pullback C (f \u2197\u2192 y\u2080 \u2197\u2192\u2197)\n\n/-! #brief Projection out of a fiber.\n-/\ndefinition Fiber.\u03c0 {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x y : C^.obj} (f : C^.hom x y)\n    (y\u2080 : C^.hom (final C) y)\n    : C^.hom (Fiber f y\u2080) x\n:= pullback.\u03c0 C (f \u2197\u2192 y\u2080 \u2197\u2192\u2197) (@fin_of 1 0)\n\n/-! #brief A hom into a fiber.\n-/\ndefinition Fiber.into {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x y : C^.obj} (f : C^.hom x y)\n    (y\u2080 : C^.hom (final C) y)\n    {z : C^.obj}\n    (h : C^.hom z x)\n    (\u03c9h : f \u2218\u2218 h = y\u2080 \u2218\u2218 final_hom z)\n    : C^.hom z (Fiber f y\u2080)\n:= pullback.univ C (f \u2197\u2192 y\u2080 \u2197\u2192\u2197)\n    (PullbackCone.mk (f \u2197\u2192 y\u2080 \u2197\u2192\u2197) z\n      (C^.circ f h)\n      (h \u2197\u2190 final_hom z \u2197\u2190\u2197)\n      begin\n        apply HomsList.eq, { trivial },\n        apply HomsList.eq, { exact \u03c9h },\n        trivial\n      end)\n\n/-! #brief A cone over a fiber.\n-/\ndefinition Fiber.cone {C : Cat.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x\u2081 x\u2082 y : C^.obj} {f\u2081 : C^.hom x\u2081 y} {f\u2082 : C^.hom x\u2082 y}\n    {y\u2080 : C^.hom (final C) y}\n    (h : C^.hom x\u2081 x\u2082)\n    (\u03c9h : y\u2080 \u2218\u2218 final_hom (Fiber f\u2081 y\u2080)\n           = f\u2082 \u2218\u2218 h \u2218\u2218 pullback.\u03c0 C (f\u2081 \u2197\u2192 y\u2080 \u2197\u2192\u2197) (@fin_of 1 0))\n:= PullbackCone.mk (f\u2082 \u2197\u2192 y\u2080 \u2197\u2192\u2197) (Fiber f\u2081 y\u2080)\n      (y\u2080 \u2218\u2218 final_hom (Fiber f\u2081 y\u2080))\n      (h \u2218\u2218 pullback.\u03c0 C (f\u2081 \u2197\u2192 y\u2080 \u2197\u2192\u2197) (@fin_of 1 0) \u2197\u2190 final_hom (Fiber f\u2081 y\u2080) \u2197\u2190\u2197)\n      begin\n        apply HomsList.eq, { exact eq.trans \u03c9h (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.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    {x\u2081 x\u2082 y : C^.obj} {f\u2081 : C^.hom x\u2081 y} {f\u2082 : C^.hom x\u2082 y}\n    {y\u2080 : C^.hom (final C) y}\n    (h : C^.hom x\u2081 x\u2082)\n    (\u03c9h : y\u2080 \u2218\u2218 final_hom (Fiber f\u2081 y\u2080)\n           = f\u2082 \u2218\u2218 h \u2218\u2218 pullback.\u03c0 C (f\u2081 \u2197\u2192 y\u2080 \u2197\u2192\u2197) (@fin_of 1 0))\n    : C^.hom (Fiber f\u2081 y\u2080) (Fiber f\u2082 y\u2080)\n:= pullback.univ C (f\u2082 \u2197\u2192 y\u2080 \u2197\u2192\u2197) (Fiber.cone h \u03c9h)\n\n\n\n/- -----------------------------------------------------------------------\nProducts in OverCat.\n----------------------------------------------------------------------- -/\n\n/-! #brief Existence of products in an over-category.\n-/\ndefinition OverCat.HasFinProduct\u2080 (C : Cat.{\u2113obj \u2113hom}) (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    (\u03bb X homs, @final_hom (OverCat C c) (OverCat.HasFinal C c) X)\n    (\u03bb X homs, begin cases homs, trivial end)\n    (\u03bb X homs h \u03c9h, @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\u2081 (C : Cat.{\u2113obj \u2113hom}) (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.\u03c0base C (HomsIn.of_list_OverObj factors)\n            }\nin HasProduct.show (OverCat C c) (list.get factors)\n    pb\n    (\u03bb n, { hom := cast_hom sorry\n                    \u2218\u2218 pullback.\u03c0 C (HomsIn.of_list_OverObj factors)\n                        { val := n^.val, is_lt := cast sorry n^.is_lt }\n          , triangle := sorry\n          })\n    (\u03bb 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                     (\u03bb n, cast_hom sorry\n                            \u2218\u2218 (homs { val := n^.val, is_lt := cast sorry n^.is_lt})^.hom))\n                   sorry)\n       , triangle := sorry\n       })\n    (\u03bb X hom n, sorry)\n    (\u03bb X hom h \u03c9h, sorry)\n\n/-! #brief Existence of products in an over-category.\n-/\ninstance OverCat.HasFinProduct (C : Cat.{\u2113obj \u2113hom}) (c : C^.obj)\n    [C_HasAllPullbacks : HasAllPullbacks C]\n    : \u2200 (factors : list (OverCat C c)^.obj)\n      , HasFinProduct (OverCat C c) factors\n| [] := OverCat.HasFinProduct\u2080 C c\n| (factor\u2080 :: factors)\n:= @OverCat.HasFinProduct\u2081 C c (factor\u2080 :: factors)\n     (HasAllPullbacks.HasPullback C _)\n\ninstance OverCat.HasAllFinProducts (C : Cat.{\u2113obj \u2113hom}) (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.{\u2113obj \u2113hom}}\n    [C_HasFinal : HasFinal C]\n    [C_HasAllFinProducts : HasAllFinProducts C]\n    (x : C^.obj)\n    : HasPullbacksAlong C (final_hom x)\n:= { has_pullback\n      := \u03bb y map\n         , HasPullback.show C (final_hom x \u2197\u2192 map \u2197\u2192\u2197)\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 \u27f6 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\u1d52\u1d56 \u2964 Type v}\n\nvariable {X Y : C} {S : Sieve X} {R : Presieve X}\n\nvariable (J J\u2082 : 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\u1d52\u1d56 \u2964 Type v) (U : Sieve X) (B : \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984, U f \u2192 Sieve Y)\n    (hU : Presieve.IsSheafFor P U) (hB : \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984 (hf : U f), Presieve.IsSheafFor P (B hf))\n    (hB' :\n      \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984 (h : U f) \u2983Z\u2984 (g : Z \u27f6 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 : \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984 (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 : \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984 (hf : U f), (y hf).Compatible :=\n    by\n    intro Y f H Y\u2081 Y\u2082 Z g\u2081 g\u2082 f\u2081 f\u2082 hf\u2081 hf\u2082 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 : \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984 (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 \u226b h)).ext\n    intro M m hm\n    have : bind U B (m \u226b l \u226b h \u226b f) :=\n      by\n      have : bind U B _ := presieve.bind_comp f hf hm\n      simpa using this\n    trans s (m \u226b l \u226b h \u226b f) this\n    \u00b7 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    \u00b7 have : s _ _ = _ := (ht hf _ hm).symm\n      simp only [assoc] at this\n      rw [this]\n      simp\n  refine' \u27e8hU.amalgamate t hT, _, _\u27e9\n  \u00b7 rintro Z _ \u27e8Y, f, g, hg, hf, rfl\u27e9\n    rw [op_comp, functor_to_types.map_comp_apply, presieve.is_sheaf_for.valid_glue _ _ _ hg]\n    apply ht hg _ hf\n  \u00b7 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 [\u2190 functor_to_types.map_comp_apply, \u2190 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\u1d52\u1d56 \u2964 Type v) (R S : Sieve X) (hR : Presieve.IsSheafFor P R)\n    (hR' : \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984 (hf : S f), Presieve.IsSeparatedFor P (R.pullback f))\n    (hS : \u2200 \u2983Y\u2984 \u2983f : Y \u27f6 X\u2984 (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) \u2264 S :=\n    by\n    rintro Z f \u27e8W, f, g, hg, hf : S _, rfl\u27e9\n    apply hf\n  apply presieve.is_sheaf_for_subsieve_aux P this\n  apply is_sheaf_for_bind _ _ _ hR hS\n  \u00b7 intro Y f hf Z g\n    dsimp\n    rw [\u2190 pullback_comp]\n    apply (hS (R.downward_closed hf _)).IsSeparatedFor\n  \u00b7 intro Y f hf\n    have : sieve.pullback f (bind R fun T (k : T \u27f6 X) (hf : R k) => pullback k S) = R.pullback f :=\n      by\n      ext (Z g)\n      constructor\n      \u00b7 rintro \u27e8W, k, l, hl, _, comm\u27e9\n        rw [pullback_apply, \u2190 comm]\n        simp [hl]\n      \u00b7 intro a\n        refine' \u27e8Z, \ud835\udfd9 Z, _, a, _\u27e9\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\u1d52\u1d56 \u2964 Type v) : GrothendieckTopology C\n    where\n  sieves X S := \u2200 (Y) (f : Y \u27f6 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 [\u2190 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    \u00b7 intro Y f hf\n      rw [\u2190 pullback_comp]\n      apply (hS _ _).IsSeparatedFor\n    \u00b7 intro Y f hf\n      have := hR hf _ (\ud835\udfd9 _)\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\u1d52\u1d56 \u2964 Type v)) : GrothendieckTopology C :=\n  inf\u209b (finestTopologySingle '' Ps)\n#align category_theory.sheaf.finest_topology CategoryTheory.Sheaf.finestTopology\n\n/-- Check that if `P \u2208 Ps`, then `P` is indeed a sheaf for the finest topology on `Ps`. -/\ntheorem sheaf_for_finestTopology (Ps : Set (C\u1d52\u1d56 \u2964 Type v)) (h : P \u2208 Ps) :\n    Presieve.IsSheaf (finestTopology Ps) P := fun X S hS => by\n  simpa using hS _ \u27e8\u27e8_, _, \u27e8_, h, rfl\u27e9, rfl\u27e9, rfl\u27e9 _ (\ud835\udfd9 _)\n#align category_theory.sheaf.sheaf_for_finest_topology CategoryTheory.Sheaf.sheaf_for_finestTopology\n\n/--\nCheck that if each `P \u2208 Ps` is a sheaf for `J`, then `J` is a subtopology of `finest_topology Ps`.\n-/\ntheorem le_finestTopology (Ps : Set (C\u1d52\u1d56 \u2964 Type v)) (J : GrothendieckTopology C)\n    (hJ : \u2200 P \u2208 Ps, Presieve.IsSheaf J P) : J \u2264 finestTopology Ps :=\n  by\n  rintro X S hS _ \u27e8\u27e8_, _, \u27e8P, hP, rfl\u27e9, rfl\u27e9, rfl\u27e9\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\u1d52\u1d56 \u2964 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 \u2264 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 : \u2200 X, Presieve.IsSheaf J (yoneda.obj X)) : Subcanonical J :=\n  le_finestTopology _ _\n    (by\n      rintro P \u27e8X, rfl\u27e9\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\u1d52\u1d56 \u2964 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 `\u03d1` converges\n* In Section `theta_surjective` We define the map \u03d1 : (laurent_measures r `S`) \u2192 \u211d and we\n  show it is surjective.\n* Section `ker_theta` studies the kernel of `\u03d1`, in particular showing it is principal.\n\n   VARIABLES\n* The variable `\u03be : \u211d` here corresponds to `r'` of `Analytic.pdf`, so that, for every `r`, `\u03d1 \u03be r`\n  is`\u03b8_r'` as a map from `r`-convergent Laurent measures to `\u211d`. It is supposed to be positive almost\neverywhere, and this is recorded as a `fact`.\n* The variable `x : \u211d` is defined globally in Sections `aux_lemmas` and `summability`.\n* The variable `r : \u211d\u22650` (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 : \u211d\u22650) :\n--   (laurent_measures r (Fintype.of punit)) \u2192 (\u2124 \u2192 \u2124) := \u03bb \u27e8F, _\u27e9, (F punit.star)\n\nnamespace theta\n\nvariable (\u03be : \u211d)\n\n/--The basic function computing the **integer-valued** `\u03be`-adic expansion of `x` -/\nnoncomputable def y (x : \u211d) : \u2115 \u2192 \u211d\n| 0         := x\n| (n + 1)   := (y n) - (\u230a(((y n) / \u03be ^ n) : \u211d)\u230b : \u211d) * \u03be ^ n\n\nsection aux_lemmas\n\nvariable (x : \u211d)\nvariable [fact (0 < \u03be)]\n\nlemma bdd_floor : bdd_above (range (\u03bb n : \u2115, (\u230a y \u03be x n / \u03be ^ n\u230b : \u211d))) :=\nbegin\n  use (max x \u03be \u207b\u00b9 : \u211d),\n  intros z hz,\n  obtain \u27e8m, h_mz\u27e9 := (set.mem_range).mp hz,\n    by_cases hm : m = 0,\n  { rw [hm, pow_zero, div_one] at h_mz,\n    rw [\u2190 h_mz, y, le_max_iff],\n    apply or.intro_left,\n    exact int.floor_le x },\n  rw \u2190 h_mz,\n  apply (int.floor_le _).trans,\n  obtain \u27e8k, hk\u27e9 : \u2203 k : \u2115, m = k + 1 := nat.exists_eq_succ_of_ne_zero hm,\n  rw [hk, y],\n  have : \u03be ^ k \u2260 0 := ne_of_gt (pow_pos (fact.out _) k),\n  calc (y \u03be x k - \u2191\u230ay \u03be x k / \u03be ^ k\u230b * \u03be ^ k) / \u03be ^ (k + 1) =\n              (y \u03be x k - \u2191\u230ay \u03be x k / \u03be ^ k\u230b * \u03be ^ k) / (\u03be ^ k * \u03be) : by {rw [pow_add, pow_one]}\n        ... = (y \u03be x k - \u2191\u230ay \u03be x k / \u03be ^ k\u230b * \u03be ^ k) / \u03be ^ k / \u03be : by {field_simp}\n        ... = (y \u03be x k / \u03be ^ k - \u2191\u230ay \u03be x k / \u03be ^ k\u230b * \u03be ^ k / \u03be ^ k) / \u03be : by {rw [sub_div]}\n        ... = (y \u03be x k / \u03be ^ k - \u2191\u230ay \u03be x k / \u03be ^ k\u230b) / \u03be : by {simp only [mul_div_cancel,\n                                                                      this, ne.def, not_false_iff]}\n        ... \u2264 1 / \u03be : div_le_div_of_le (le_of_lt _) (le_of_lt _)\n        ... \u2264 max x \u03be \u207b\u00b9 : 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 : \u2200 n : \u2115, n \u2265 1 \u2192 0 \u2264 y \u03be x n :=\nbegin\n  have h_pos : \u2200 n : \u2115, n \u2265 1 \u2192 \u03be ^ n > 0 := \u03bb n _, pow_pos (fact.out _) n,\n  have : \u2200 n : \u2115, n \u2265 1 \u2192  (y \u03be x n) / \u03be ^ n \u2265 \u230a(((y \u03be x n) / \u03be ^ n) : \u211d)\u230b := \u03bb n _, int.floor_le _,\n  intros n hn\u2081,\n  by_cases hn\u2080 : n = 1,\n  { rw [hn\u2080, y,pow_zero, div_one, mul_one, sub_nonneg], apply int.floor_le },\n  { replace hn\u2081 : n > 1, {apply (lt_of_le_of_ne hn\u2081), tauto },\n    obtain \u27e8m, hm\u27e9 : \u2203 m : \u2115, m \u2265 1 \u2227 n = m + 1,\n    use \u27e8n - 1, and.intro (nat.le_pred_of_lt hn\u2081) (nat.sub_add_cancel (le_of_lt hn\u2081)).symm\u27e9,\n    rw [hm.2, y],\n    replace this := (le_div_iff (h_pos m hm.1)).mp (this m hm.1),\n    rwa \u2190 sub_nonneg at this },\nend\n\nlemma eventually_pos_floor : \u2200 n : \u2115, n \u2265 1 \u2192 (\u230a((y \u03be x n) / \u03be ^ n )\u230b : \u211d) \u2265 0 :=\nbegin\n  have h_pos : \u2200 n : \u2115, n \u2265 1 \u2192 \u03be ^ n > 0 := \u03bb 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 \u03be x n hn) (le_of_lt (h_pos n hn)),\nend\n\nlemma eventually_le : \u2200 n, n \u2265 1 \u2192 y \u03be x (n + 1) \u2264 (y \u03be x n) :=\nbegin\n  have h_pos : \u2200 n : \u2115, n \u2265 1 \u2192 \u03be ^ n > 0 := \u03bb n _, pow_pos (fact.out _) n,\n  intros n hn,\n  rw y,\n  apply sub_le_self (y \u03be x n),\n  apply mul_nonneg _ (le_of_lt (h_pos n hn)),\n  exact eventually_pos_floor \u03be x n hn,\nend\n\nlemma eventually_le_one {n : \u2115} (hn : n \u2265 1) : (y \u03be x n) \u2264 (y \u03be x 1) :=\nbegin\n  induction hn with n hn h_ind,\n  exact le_of_eq (refl _),\n  have := (eventually_le \u03be x n hn).trans h_ind,\n  rwa nat.succ_eq_add_one,\nend\n\ndef aux_y : \u2115 \u2192 \u211d := \u03bb n, if n = 0 then y \u03be x 1 else y \u03be x n\n\nlemma eventually_antitone : antitone (aux_y \u03be 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 \u2265 1 := le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr hn),\n    exact eventually_le \u03be x n hn },\nend\n\nlemma limit_neg_geometric [fact (\u03be < 1)] : tendsto (\u03bb i : \u2115, - \u03be ^ i) at_top (\ud835\udcdd 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 : \u211d)\n\nlemma finite_sum (n : \u2115) : (y \u03be x (n + 1) : \u211d) =\n  x - \u2211 i in range(n + 1),  (\u230a(((y \u03be x i) / \u03be ^ i) : \u211d)\u230b : \u211d) * (\u03be ^ i) :=\nbegin\n  induction n with n h_ind,\n  { rw [zero_add, range_one, sum_singleton], refl },\n  { replace h_ind : (x - (y \u03be x (n + 1)) : \u211d) =\n    \u2211 i in range(n + 1),  (\u230a(y \u03be x i / \u03be ^ i : \u211d)\u230b : \u211d) * \u03be ^ i := by {rw [sub_eq_iff_eq_add,\n      \u2190 sub_eq_iff_eq_add', h_ind] },\n    nth_rewrite_rhs 2 [nat.succ_eq_add_one, \u2190 nat.succ_eq_add_one, range_succ],\n    rw [sum_insert, nat.succ_eq_add_one, \u2190 sub_sub, \u2190 h_ind, sub_sub, add_sub, add_comm _ x,\n      \u2190 add_sub, \u2190 sub_sub, sub_self, zero_sub, neg_sub],\n    refl,\n    simp },\nend\n\nlemma finite_sum' (n : \u2115) : x - (y \u03be x n : \u211d) =\n  \u2211 i in range (n),  (\u230a(((y \u03be x i) / \u03be ^ i) : \u211d)\u230b : \u211d) * (\u03be ^ i) :=\nbegin\n  by_cases hn : n =0,\n  { rw [hn, range_zero, sum_empty, sub_eq_zero], refl },\n  { replace hn : n \u2265 1 := le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr hn),\n    rw [\u2190 (nat.sub_add_cancel hn), finite_sum \u03be x (n - 1)],\n    simp only [sub_sub_cancel] at * },\nend\n\nvariable [fact (0 < \u03be)]\n\nlemma exists_limit_y : \u2203 a, tendsto (\u03bb n, y \u03be x n) at_top (\ud835\udcdd a) :=\nbegin\n  have h_bdd : bdd_below (range (aux_y \u03be x)),\n  { use 0,\n    intros z hz,\n    obtain \u27e8m, h_mz\u27e9 := (set.mem_range).mp hz,\n    by_cases hm : m = 0,\n    { simp_rw [hm, aux_y, if_pos] at h_mz,\n      rw \u2190 h_mz,\n      exact eventually_pos_y \u03be x 1 (le_of_eq (refl _)), },\n      simp_rw [aux_y, (if_neg hm)] at h_mz,\n      rw \u2190 h_mz,\n      replace hm : m \u2265 1 := le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr hm),\n      exact eventually_pos_y \u03be x m hm },\n  have := tendsto_at_top_cinfi (eventually_antitone \u03be x) h_bdd,\n  use (\u2a05 (i : \u2115), aux_y \u03be x i),\n  apply @tendsto.congr' _ _ (aux_y \u03be x) _ _ _ _ this,\n  apply (filter.eventually_eq_iff_exists_mem).mpr,\n  use {n | n \u2265 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 \u2265 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 : \u211d\u22650) (hr\u2081 : r < 1) :\n      summable (\u03bb i, \u2225\u230a(y \u03be x i / \u03be ^ i : \u211d)\u230b\u2225 * (r ^ i)) :=\nbegin\n  by_cases hr\u2080 : r = 0,\n  { rw hr\u2080,\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 : \u2200 n : \u2115, n \u2265 1 \u2192 (r ^ n : \u211d) \u2265 0 := \u03bb n _, pow_nonneg (r.2) n,\n  have H : \u2200 j : {i // i \u2209 range 1}, j.1 \u2265 1,\n  { rintro \u27e8n, h_n\u27e9,\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 : \u2200 i : {i // i \u2209 range 1}, (\u2225\u230a(y \u03be x i.1 / \u03be ^ i.1 : \u211d)\u230b\u2225) * r ^ i.1 \u2265 0,\n    { intro i,\n      apply mul_nonneg _ (h_nonneg i.1 (H i)),\n      simp only [norm_nonneg] },\n  obtain \u27e8\u03bc, h\u03bc\u27e9  := bdd_floor \u03be x,\n  have h_bdd : \u2200 i : {i // i \u2209 range 1}, (\u2225\u230a(y \u03be x i.1 / \u03be ^ i.1 : \u211d)\u230b\u2225) \u2264 \u03bc,\n  { rw upper_bounds at h\u03bc,\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 \u2265 1 := le_of_not_gt ((not_iff_not.mpr nat.lt_one_iff).mpr ha),\n    rwa [abs_eq_self.mpr (eventually_pos_floor \u03be x a ha)],\n    exact h\u03bc a },\n  replace h_bdd : \u2200 i : {i // i \u2209 range 1}, (\u2225\u230a(y \u03be x i.1 / \u03be ^ i.1 : \u211d)\u230b\u2225) * r ^ i.1\n      \u2264 \u03bc * r ^ i.1,\n    { intro i,\n    rw mul_le_mul_right,\n    exacts [h_bdd i, pow_pos ((ne.symm hr\u2080).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 _ _ _ _ _ (\u03bb i, \u03bc * r ^ i) (finset.range 1)).mpr,\n  apply summable.mul_left,\n  apply summable_geometric_of_abs_lt_1,\n  rwa [\u2190 nnreal.val_eq_coe, abs_eq_self.mpr r.2],\nend\n\nlemma summable_nnnorm (r : \u211d\u22650) (hr\u2081 : r < 1) :\n      summable (\u03bb i, \u2225\u230a(y \u03be x i / \u03be ^ i : \u211d)\u230b\u2225\u208a * (r ^ i)) :=\nby simpa only [\u2190 nnreal.summable_coe, nonneg.coe_mul, coe_nnnorm, nnreal.coe_pow]\n  using summable_norm \u03be x r hr\u2081\n\nlemma summable_floor (r : \u211d\u22650) (hr\u2081 : r < 1) :\n   summable (\u03bb i, (\u230a(y \u03be x i / \u03be ^ i : \u211d)\u230b : \u211d) * r ^ i) :=\nbegin\n  have h_norm_eq : (\u03bb i : \u2115, (\u2225\u230ay \u03be x i / \u03be ^ i\u230b\u2225 * (r ^ i : \u211d))) =\n    (\u03bb i : \u2115, (\u2225(\u230ay \u03be x i / \u03be ^ i\u230b : \u211d) * (r ^ i)\u2225)),\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 \u03be x r hr\u2081,\n  rw h_norm_eq at this,\n  apply summable_of_summable_norm (this),\nend\n\nlemma limit_y [fact (\u03be < 1)]: tendsto (\u03bb n, y \u03be x n) at_top (\ud835\udcdd 0) :=\nbegin\n  have h_pos : 0 < \u03be := fact.out _,\n  let \u03be\u2080 : \u211d\u22650 := \u27e8\u03be, le_of_lt (fact.out _)\u27e9,\n  have h_right : \u2200 n, n \u2265 1 \u2192 (\u230a(y \u03be x n / \u03be ^ n)\u230b : \u211d) \u2264 (y \u03be x n / \u03be ^ n) :=\n    (\u03bb _ _, int.floor_le _),\n  replace h_right : \u2200 n, n \u2265 1 \u2192 (\u230a(y \u03be x n / \u03be ^ n)\u230b : \u211d) * \u03be ^ n  \u2264 y \u03be x n :=\n    (\u03bb n hn, (le_div_iff (pow_pos h_pos n)).mp (h_right n hn)),\n  replace h_right : \u2200\u1da0 n in at_top, (\u230a(y \u03be x n / \u03be ^ n)\u230b : \u211d) * \u03be ^ n  \u2264 y \u03be x n,\n  { simp only [ge_iff_le, eventually_at_top], use [1, h_right] },\n  have h_left : \u2200 n, n \u2265 1 \u2192 (y \u03be x n / \u03be ^ n) - 1 \u2264 \u230a(y \u03be x n / \u03be ^ n)\u230b :=\n    (\u03bb n hn, le_of_lt (int.sub_one_lt_floor _)),\n  replace h_left : \u2200 n, n \u2265 1 \u2192 (y \u03be x n - \u03be ^ n) \u2264 \u230a(y \u03be x n / \u03be ^ n)\u230b * \u03be ^ n,\n  { have h_one : \u2200 n : \u2115, 0 < \u03be ^ n := (\u03bb n, pow_pos h_pos n),\n    intros n hn,\n    calc y \u03be x n - \u03be ^ n\n        = ((y \u03be x n / \u03be ^ n) - 1) * \u03be ^ n : by { rw [sub_mul, one_mul, div_mul_cancel _ (h_one _).ne'], }\n    ... \u2264 \u230a(y \u03be x n / \u03be ^ n)\u230b * \u03be ^ n : (mul_le_mul_right (h_one n)).mpr (h_left n hn) },\n  replace h_left : \u2200\u1da0 n in at_top, y \u03be x n - \u03be ^ n \u2264 (\u230a(y \u03be x n / \u03be ^ n)\u230b : \u211d) * \u03be ^ n,\n  { simp only [eventually_at_top], use [1, h_left] },\n  have : tendsto (\u03bb n, y \u03be x n - \u03be ^ n) at_top (\ud835\udcdd (exists_limit_y \u03be x).some),\n  { convert tendsto.add (exists_limit_y \u03be x).some_spec (limit_neg_geometric \u03be),\n    rw add_zero } ,\n  have h\u2081 := (le_of_tendsto_of_tendsto this\n    (summable_floor \u03be x \u03be\u2080 _).tendsto_at_top_zero h_left).antisymm (le_of_tendsto_of_tendsto\n    (summable_floor \u03be x \u03be\u2080 _).tendsto_at_top_zero (exists_limit_y \u03be x).some_spec h_right),\n  have := (exists_limit_y \u03be x).some_spec,\n  rwa h\u2081 at this,\n  all_goals {rw [\u2190 nnreal.coe_lt_coe, nnreal.coe_one, subtype.coe_mk], exact fact.out _},\nend\n\nlemma has_sum_x [fact (\u03be < 1)] : has_sum (\u03bb i, (\u230a(((y \u03be x i) / \u03be ^ i) : \u211d)\u230b : \u211d) * (\u03be ^ i)) x :=\nbegin\n  let \u03be\u2080 : \u211d\u22650 := \u27e8\u03be, le_of_lt (fact.out _)\u27e9,\n  apply (summable_floor \u03be x \u03be\u2080 _).has_sum_iff_tendsto_nat.mpr,\n  simp_rw [subtype.coe_mk, \u2190 (finite_sum' \u03be x), sub_eq_add_neg],\n  nth_rewrite_rhs 0 [\u2190 add_zero x],\n  apply @tendsto.const_add \u2115 \u211d _ _ _ x 0 _ at_top,\n  rw \u2190 neg_zero,\n  refine tendsto.neg (limit_y \u03be x),\n  { rw [\u2190 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 `\u03d1` defined in Theorem 6.9 of Analytic.pdf. Given the definition of `tsum` we do not need\n to require that `r \u2264 \u03be` to simply define `\u03d1`.-/\n\ndef seval_\u2112 {r : \u211d\u22650} (S : Fintype) (s : S): (laurent_measures r S) \u2192\n  (laurent_measures r (Fintype.of punit)) := \u03bb F, \u27e8(\u03bb _, F s), (\u03bb _, F.2 s)\u27e9\n\ndef \u03d1\u2080 (r : \u211d\u22650) : (laurent_measures r (Fintype.of punit)) \u2192 \u211d :=\n  \u03bb F, tsum (\u03bb n, (F punit.star n) * \u03be ^ n)--TODO: remove this\n\ndef \u03d1 (r p : \u211d\u22650) (S : Fintype) : (laurent_measures r S) \u2192 real_measures p S :=\n  \u03bb F s, tsum (\u03bb n, (F s n) * \u03be ^ n)\n\n@[nolint unused_arguments]\ndef \u03d1' (r p: \u211d\u22650) (S : Fintype) : (laurent_measures r S) \u2192 (S \u2192 \u211d) :=\n  \u03bb F s, (\u03d1\u2080 \u03be r) (seval_\u2112 S s F)\n\n\nlemma \u03d1_eq_\u03d1' : \u03d1 = \u03d1' := rfl\n\ndef \u03d1_section (r p : \u211d\u22650) (S : Fintype) (g : real_measures p S) [fact (r < 1)] [fact (0 < \u03be)]\n   [fact (\u03be < 1)] : (S \u2192 \u2124 \u2192 \u2124) := \u03bb s m, int.rec_on m (\u03bb i, \u230a((y \u03be (g s) i) / \u03be ^ i)\u230b) (0)\n\nlemma summable_\u03d1_section (r p : \u211d\u22650) (S : Fintype) (g : real_measures p S) [fact (r < 1)]\n  [fact (0 < \u03be)] [fact (\u03be < 1)] : \u2200 s, summable (\u03bb n, \u2225(\u03d1_section \u03be r p S g ) s n\u2225\u208a * r ^ n) :=\nbegin\n  let F\u2080 := \u03d1_section \u03be r p S g,\n  have hinj : function.injective (coe : \u2115 \u2192 \u2124) := by {apply int.coe_nat_inj},\n  have h_aux : \u2200 s : S, \u2200 n : \u2124, n \u2209 set.range (coe : \u2115 \u2192 \u2124) \u2192 F\u2080 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 : \u2200 s : S, \u2200 n : \u2124, n \u2209 set.range (coe : \u2115 \u2192 \u2124) \u2192 \u2225F\u2080 s n \u2225\u208a * 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 \u03be (g s) r (fact.out _),\nend\n\ntheorem \u03d1_surjective (r p : \u211d\u22650) (S : Fintype) (g : real_measures p S) [fact (r < 1)] [fact (0 < \u03be)]\n   [fact (\u03be < 1)] : \u2203 (F : laurent_measures r S), (\u03d1 \u03be r p S F) = g :=\nbegin\n  have hinj : function.injective (coe : \u2115 \u2192 \u2124) := by {apply int.coe_nat_inj},\n    let F : laurent_measures r S := \u27e8\u03d1_section \u03be r p S g, summable_\u03d1_section \u03be r p S g\u27e9,\n    have h_aux : \u2200 s : S, \u2200 n : \u2124, n \u2209 set.range (coe : \u2115 \u2192 \u2124) \u2192 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 : \u2200 s : S, \u2200 n : \u2124, n \u2209 set.range (coe : \u2115 \u2192 \u2124) \u2192 (F s n : \u211d) * \u03be ^ 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 : \u2200 s : S, has_sum (\u03bb n, ((F s n) : \u211d) * \u03be ^ 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 \u03be (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 \u03d1\u2080_surjective (x : \u211d) (r : \u211d\u22650) [fact (r < 1)] [fact (0 < \u03be)] [fact (\u03be < 1)] :\n--   \u2203 (F : laurent_measures r (Fintype.of punit)), (\u03d1\u2080 \u03be r F) = x :=\n-- begin\n--   let f\u2080 : \u2124 \u2192 \u2124 := \u03bb m, int.rec_on m (\u03bb i, \u230a((y \u03be x i) / \u03be ^ i)\u230b) (0),\n--   let F\u2080 : Fintype.of punit \u2192 \u2124 \u2192 \u2124 := \u03bb a, f\u2080,\n--   have hinj : function.injective (coe : \u2115 \u2192 \u2124) := by {apply int.coe_nat_inj},\n--   have h_aux : \u2200 n : \u2124, n \u2209 set.range (coe : \u2115 \u2192 \u2124) \u2192 f\u2080 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 : \u2200 n : \u2124,\n--     n \u2209 set.range (coe : \u2115 \u2192 \u2124) \u2192 (F\u2080 punit.star n : \u211d) * \u03be ^ n = 0,\n--   swap,\n--   have h_range_norm : \u2200 n : \u2124,\n--     n \u2209 set.range (coe : \u2115 \u2192 \u2124) \u2192 \u2225F\u2080 punit.star n \u2225 * r ^ n = 0,\n--   swap,\n--   { have HF\u2080 : \u2200 (s : Fintype.of punit), summable (\u03bb (n : \u2124), \u2225F\u2080 s n\u2225 * r ^ n),\n--     { intro s,\n--       apply (@function.injective.summable_iff _ _ _ _ _ _ _ hinj h_range_norm).mp,\n--       apply summable_norm \u03be x r (fact.out _) },\n--     let F : laurent_measures r (Fintype.of punit) := \u27e8F\u2080, HF\u2080\u27e9,\n--     use F,\n--     have : has_sum (\u03bb n, ((F\u2080 punit.star n) : \u211d) * \u03be ^ n) x,\n--     { apply (@function.injective.has_sum_iff _ _ _ _ _ _ x _ hinj h_range).mp,\n--       exact has_sum_x \u03be 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": "namespace Test\n\nstructure Monoid where\n  type : Type u\n  mul : type \u2192 type \u2192 type\n  one : type\n  mul_one : \u2200 x, mul x one = one\n  one_mul : \u2200 x, mul one x = one\n\ninfixl:60 \" * \" => Monoid.mul _\n\n-- @[appUnexpander Monoid.mul]\n-- def unexpandMonoidMul : Lean.PrettyPrinter.Unexpander\n-- | `($_ $_ $x $y) => `($x * $y)\n-- | _ => throw ()\n\nstructure Group extends Monoid where\n  inv : type \u2192 type\n  mul_inv : \u2200 x, mul x (inv x) = one\n  inv_mul : \u2200 x, mul (inv x) x = one\n\npostfix:max \" \u207b\u00b9 \" => Group.inv _\n\n-- @[appUnexpander Group.inv]\n-- def unexpandGroupInv : Lean.PrettyPrinter.Unexpander\n-- | `($_ $_ $x) => `($x\u207b\u00b9)\n-- | _ => throw ()\n\n@[appUnexpander Group.toMonoid]\ndef unexpandGroupToMonoid : Lean.PrettyPrinter.Unexpander\n| `($_) => `(TEST)\n-- | _ => throw ()\n\nexample {G : Group} (x y : G.type) : x * y = y * x := by {\n  \n}\n\nend Test\n", "meta": {"author": "jessetvogel", "repo": "Math4", "sha": "1d6a30589c7b3b3c70e968985d0c1f6f9f242938", "save_path": "github-repos/lean/jessetvogel-Math4", "path": "github-repos/lean/jessetvogel-Math4/Math4-1d6a30589c7b3b3c70e968985d0c1f6f9f242938/Math/Test/Scratch.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8244619350028204, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4666607367752398}}
{"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 \u2192 S) :=\n  \u2200 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, \u2190 sub_add_sub_comm, \u2190 mul_sub_one,\n    \u2190 neg_sub y, \u2190 sub_eq_add_neg, \u2190 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, \u2190 add_one_mul, add_comm 1 x, \u2190 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 (\u03bb (_ : R), (0 : S)) :=\n  \u03bb x y, by rw [sub_zero, mul_zero]\n\nprivate lemma good_hom_sub_one [ring S] (\u03c6 : R \u2192+* S) :\n  good (\u03bb (x : R), \u03c6 x - 1) :=\n  \u03bb x y, by rw [sub_sub_sub_cancel_right, \u03c6.map_add, \u03c6.map_one, \u03c6.map_add, \u03c6.map_mul];\n    exact one_add_mul_sub_add (\u03c6 x) (\u03c6 y)\n\nprivate lemma good_hom_sq_sub_one [comm_ring S] (\u03c6 : R \u2192+* S) :\n  good (\u03bb (x : R), \u03c6 x ^ 2 - 1) :=\n  \u03bb x y, by rw [sub_sub_sub_cancel_right, \u03c6.map_add, \u03c6.map_one, \u03c6.map_add, \u03c6.map_mul, sq_sub_sq,\n    one_add_mul_sub_add, one_add_mul_add_add, mul_mul_mul_comm, \u2190 sq_sub_sq, \u2190 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 \u2192 S} (h : good f) (x : R) :\n  f x - f (-x) = f (-1) * f (1 - x) :=\n  by rw [\u2190 h, neg_one_mul, neg_sub, add_sub_cancel'_right, \u2190 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 \u2192 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 \u2260 -1) : f = 0 :=\n  funext (\u03bb x, by have h1 := h x 0; rwa [mul_zero, add_zero, good_map_one h, zero_sub,\n    add_zero, \u2190 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 : \u211d \u2192 R} (feq : good f)\ninclude feq\n\n\nsection case_fneg1_ne_0\n\nvariable (fneg1_ne_0 : f (-1) \u2260 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 : \u211d) : f (2 - x) = -f x :=\nbegin\n  have h := good_subst_neg_one feq (-(1 - x)),\n  rwa [neg_neg, \u2190 neg_sub, good_subst_neg_one feq (1 - x), \u2190 mul_neg, mul_eq_mul_left_iff,\n       or_iff_left fneg1_ne_0, sub_sub_cancel, sub_neg_eq_add, \u2190 add_sub_assoc, eq_comm] at h\nend\n\nprivate lemma lem2_3 (x : \u211d) : f (x + 2) = f x + 2 :=\nbegin\n  revert x; suffices : \u2200 x : \u211d, x \u2264 0 \u2192 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 [\u2190 h0, zero_add, h, lem2_1 feq fneg1_ne_0, sub_neg_eq_add, \u2190 bit0] at this,\n    clear h0; intros x,\n    cases le_total x 0 with h0 h0,\n    rw [\u2190 sub_eq_iff_eq_add', this x h0],\n    rw [\u2190 this (-x) (by rwa neg_nonpos), add_comm (-x), \u2190 sub_eq_add_neg,\n        lem2_2 feq fneg1_ne_0, \u2190 add_sub_assoc, add_neg_self, zero_sub,\n        \u2190 lem2_2 feq fneg1_ne_0, sub_neg_eq_add, add_comm] },\n  intros x h,\n  obtain \u27e8u, v, h0, h1\u27e9 : \u2203 u v : \u211d, u + v = 1 \u2227 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, \u2190 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, \u2190 bit0] },\n  rw [add_comm (1 : \u211d), \u2190 sub_eq_sub_iff_add_eq_add, \u2190 h1, sub_mul, mul_sub,\n      mul_sub, \u2190 sub_add, sub_sub, mul_comm u 2, \u2190 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 : \u211d) : f (-x) = -(2 + f x) :=\nbegin\n  have h := lem2_3 feq fneg1_ne_0 (-x),\n  rw [add_comm, \u2190 sub_eq_add_neg, lem2_2 feq fneg1_ne_0, \u2190 sub_eq_iff_eq_add] at h,\n  rw [\u2190 h, sub_eq_add_neg, add_comm, neg_add]\nend\n\nprivate lemma lem2_5 (x y : \u211d) : f (x + y) = f x + f y + 1 :=\nbegin\n  have h := feq (-x) (-y),\n  rw [neg_mul_neg, \u2190 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, \u2190 feq, \u2190 sub_eq_zero] at h,\n  replace h : 2 * (f (x + y) - (f x + f y + 1)) = 0 := by rw \u2190 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 : \u2203 \u03c6 : \u211d \u2192+* R, f = \u03c6 - 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 : \u211d) : f (-x) = f x :=\n  by rw [eq_comm, \u2190 sub_eq_zero, good_subst_neg_one feq x, fneg1_eq_0, zero_mul]\n\nprivate lemma lem3_2 (u v : \u211d\u22650) : f (1 + v / 4) - f (1 - v / 4) = f (sqrt (u + v)) - f (sqrt u) :=\nbegin\n  obtain \u27e8x, y, h, h0\u27e9 : \u2203 x y : \u211d, x + y = sqrt (u + v) \u2227 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 [\u2190 h, \u2190 h0, sub_eq_sub_iff_sub_eq_sub, feq, \u2190 lem3_1 feq fneg1_eq_0 y,\n      \u2190 feq, mul_neg, \u2190 sub_eq_add_neg, sub_right_inj, \u2190 sub_eq_add_neg],\n  suffices : (u : \u211d) = (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 (\u03bb x, x ^ 2) h; simp only [] at h,\n  rw [\u2190 nonneg.coe_pow, sq_sqrt, nonneg.coe_add, \u2190 sub_eq_iff_eq_add] at h,\n  rw [\u2190 h, sub_eq_iff_eq_add', \u2190 sub_eq_iff_eq_add, add_sq, sub_sq, add_sub_add_right_eq_sub,\n      add_sub_sub_cancel, mul_assoc, \u2190 add_mul, h0, \u2190 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 : \u211d\u22650) : f (sqrt (u + v)) = f (sqrt u) + f (sqrt v) + 1 :=\n  by rw [add_assoc, \u2190 sub_eq_iff_eq_add', \u2190 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 : \u211d\u22650) : f (u * v) + 1 = (f u + 1) * (f v + 1) :=\nbegin\n  revert u v; suffices : \u2200 u v : \u211d\u22650, 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 [\u2190 nonneg.coe_one, \u2190 nonneg.coe_mul, this, nonneg.coe_one, \u2190 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, \u2190 add_assoc] at h,\n    rw [h, add_one_mul, mul_add_one, \u2190 add_assoc] },\n  intros u v,\n  have h := lem3_3 feq fneg1_eq_0 f0_eq_neg1,\n  rw [\u2190 nonneg.coe_add, \u2190 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, \u2190 bit0]\nend\n\nprivate lemma lem3_5 : \u2203 \u03c6 : \u211d\u22650 \u2192+* R, f = \u03bb x : \u211d, \u03c6 (x.nnabs ^ 2) - 1 :=\nbegin\n  use \u03bb 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 : \u211d \u2192 R) : good f \u2194\n  f = 0 \u2228 (\u2203 \u03c6 : \u211d \u2192+* R, f = \u03c6 - 1) \u2228 (\u2203 \u03c6 : \u211d\u22650 \u2192+* R, f = \u03bb x : \u211d, \u03c6 (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 | \u27e8\u03c6, rfl\u27e9 | \u27e8\u03c6, h\u27e9),\n    exact good_zero,\n    exact good_hom_sub_one \u03c6,\n    intros x y,\n    conv at h { congr, skip, funext,\n      rw [\u2190 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, \u2190 add_sub_assoc,\n        \u2190 sub_add, add_comm, add_sub_right_comm] }\nend\n\n/-- Final solution, case char(R) \u2260 0 -/\ntheorem final_solution_char_ne_0 {R : Type*} [comm_ring R] [is_domain R]\n    (p : \u2115) [fact (p \u2260 0)] [char_p R p] (f : \u211d \u2192 R) : good f \u2194 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 = \u211d -/\ntheorem final_solution_real (f : \u211d \u2192 \u211d) : good f \u2194 f = 0 \u2228 (f = id - 1) \u2228 (f = \u03bb 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 \u2192 unexists) (renaming some_spec \u2192 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 \u2192 T') :=\n        (g: T' \u2192 T)\n        (left_inv:\n            \u2200 x: T,\n            g (f x) = x)\n\n    @[reducible, inline] def inv {T T': Sort _} (f: T \u2192 T') [hf: invertible.one_sided f]:\n        T' \u2192 T := hf.g\n\n    @[simp] theorem inv.elim {T T': Sort _} (f: T \u2192 T') [hf: invertible.one_sided f]:\n        \u2200 x: T,\n        inv f (f x) = x := by apply hf.left_inv\n\n    instance inv.surjective {T T': Sort _} (f: T \u2192 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 \u2192 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 \u2192 T') (y: T'): T :=\n        if h: \u2203 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 \u2192 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 (\u2203 (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 \u2192 T') extends invertible.one_sided f :=\n        (right_inv:\n            \u2200 y: T',\n            f (g y) = y)\n\n    instance invertible.surjective {T T': Sort _} (f: T \u2192 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 \u2192 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 \u2192 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 [\u2190hx],\n            exact congr rfl (invertible.one_sided.left_inv f x),\n        end\n\n    instance inv.invertible {T T': Sort _} (f: T \u2192 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 \u2192 T') [hf: invertible f]:\n        inv (inv f) = f := by rw [inv.invertible]\n\n    theorem inv.uniq {T T': Sort _} (f: T \u2192 T') [hf: invertible f]:\n        \u2200 {g: T' \u2192 T},\n        (\u2200 x: T, g (f x) = x) \u2192\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 [\u2190hy, hg y],\n            rw [inv, hf.left_inv],\n        end\n\n    instance inv.injective {T T': Sort _} (f: T \u2192 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 [\u2190ha, \u2190hb] 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 : \u2115) : (a : \u211a) \u2264 b \u2194 a \u2264 b := by qify ; refl\nexample (a b : \u2115) : (a : \u211a) < b \u2194 a < b := by qify ; refl\nexample (a b : \u2115) : (a : \u211a) = b \u2194 a = b := by qify ; refl\nexample (a b : \u2115) : (a : \u211a) \u2260 b \u2194 a \u2260 b := by qify ; refl\n\nexample (a b : \u2124) : (a : \u211a) \u2264 b \u2194 a \u2264 b := by qify ; refl\nexample (a b : \u2124) : (a : \u211a) < b \u2194 a < b := by qify ; refl\nexample (a b : \u2124) : (a : \u211a) = b \u2194 a = b := by qify ; refl\nexample (a b : \u2124) : (a : \u211a) \u2260 b \u2194 a \u2260 b := by qify ; refl\n\nexample (a b c : \u2115) (h : a - b = c) (hab : b \u2264 a) : a = c + b :=\nbegin\n  qify [hab] at h \u22a2, -- `zify` does the same thing here.\n  exact sub_eq_iff_eq_add.1 h,\nend\n\nexample (a b c : \u2124) (h : a / b = c) (hab : b \u2223 a) (hb : b \u2260 0) : a = c * b :=\nbegin\n  qify [hab] at h hb \u22a2,\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\u2082` says that `\u03bb p : \u03b1 \u00d7 \u03b1, 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 `\u03b1` equipped with the Borel `\u03c3`-algebra, instances for `has_measurable_mul\u2082`\netc require `\u03b1` to have a second countable topology.\n\nWe define separate classes for `has_measurable_div`/`has_measurable_sub`\nbecause on some types (e.g., `\u2115`, `\u211d\u22650\u221e`) division and/or subtraction are not defined as `a * b\u207b\u00b9` /\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\u2082`.\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\u2082`. -/\nclass has_measurable_add (M : Type*) [measurable_space M] [has_add M] : Prop :=\n(measurable_const_add : \u2200 c : M, measurable ((+) c))\n(measurable_add_const : \u2200 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\u2082 (M : Type*) [measurable_space M] [has_add M] : Prop :=\n(measurable_add : measurable (\u03bb p : M \u00d7 M, p.1 + p.2))\n\nexport has_measurable_add\u2082 (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\u2082`. -/\n@[to_additive]\nclass has_measurable_mul (M : Type*) [measurable_space M] [has_mul M] : Prop :=\n(measurable_const_mul : \u2200 c : M, measurable ((*) c))\n(measurable_mul_const : \u2200 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\u2082]\nclass has_measurable_mul\u2082 (M : Type*) [measurable_space M] [has_mul M] : Prop :=\n(measurable_mul : measurable (\u03bb p : M \u00d7 M, p.1 * p.2))\n\nexport has_measurable_mul\u2082 (measurable_mul)\n\nsection mul\n\nvariables {M \u03b1 : Type*} [measurable_space M] [has_mul M] {m : measurable_space \u03b1}\n  {f g : \u03b1 \u2192 M} {\u03bc : measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.const_mul [has_measurable_mul M] (hf : measurable f) (c : M) :\n  measurable (\u03bb 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 \u03bc) (c : M) :\n  ae_measurable (\u03bb x, c * f x) \u03bc :=\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 (\u03bb 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 \u03bc) (c : M) :\n  ae_measurable (\u03bb x, f x * c) \u03bc :=\n(measurable_mul_const c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.mul' [has_measurable_mul\u2082 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\u2082 M] (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb a, f a * g a) :=\nmeasurable_mul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.mul' [has_measurable_mul\u2082 M] (hf : ae_measurable f \u03bc)\n  (hg : ae_measurable g \u03bc) :\n  ae_measurable (f * g) \u03bc :=\nmeasurable_mul.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.mul [has_measurable_mul\u2082 M] (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  ae_measurable (\u03bb a, f a * g a) \u03bc :=\nmeasurable_mul.comp_ae_measurable (hf.prod_mk hg)\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_mul\u2082.to_has_measurable_mul [has_measurable_mul\u2082 M] :\n  has_measurable_mul M :=\n\u27e8\u03bb c, measurable_const.mul measurable_id, \u03bb c, measurable_id.mul measurable_const\u27e9\n\n@[to_additive]\ninstance pi.has_measurable_mul {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_mul (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_mul (\u03b1 i)] :\n  has_measurable_mul (\u03a0 i, \u03b1 i) :=\n\u27e8\u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).const_mul _,\n \u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).mul_const _\u27e9\n\n@[to_additive pi.has_measurable_add\u2082]\ninstance pi.has_measurable_mul\u2082 {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_mul (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_mul\u2082 (\u03b1 i)] :\n  has_measurable_mul\u2082 (\u03a0 i, \u03b1 i) :=\n\u27e8measurable_pi_iff.mpr $ \u03bb i, measurable_fst.eval.mul measurable_snd.eval\u27e9\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 (\u03bb h, h / g) :=\nby simp_rw [div_eq_mul_inv, measurable_mul_const]\n\n/-- This class assumes that the map `\u03b2 \u00d7 \u03b3 \u2192 \u03b2` given by `(x, y) \u21a6 x ^ y` is measurable. -/\nclass has_measurable_pow (\u03b2 \u03b3 : Type*) [measurable_space \u03b2] [measurable_space \u03b3] [has_pow \u03b2 \u03b3] :=\n(measurable_pow : measurable (\u03bb p : \u03b2 \u00d7 \u03b3, 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\u2082 M] : has_measurable_pow M \u2115 :=\n\u27e8measurable_from_prod_countable $ \u03bb n, begin\n  induction n with n ih,\n  { simp only [pow_zero, \u2190pi.one_def, measurable_one] },\n  { simp only [pow_succ], exact measurable_id.mul ih }\nend\u27e9\n\nsection pow\n\nvariables {\u03b2 \u03b3 \u03b1 : Type*} [measurable_space \u03b2] [measurable_space \u03b3] [has_pow \u03b2 \u03b3]\n  [has_measurable_pow \u03b2 \u03b3] {m : measurable_space \u03b1} {\u03bc : measure \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3}\n\ninclude m\n\n@[measurability]\nlemma measurable.pow (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb x, f x ^ g x) :=\nmeasurable_pow.comp (hf.prod_mk hg)\n\n@[measurability]\nlemma ae_measurable.pow (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  ae_measurable (\u03bb x, f x ^ g x) \u03bc :=\nmeasurable_pow.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability]\nlemma measurable.pow_const (hf : measurable f) (c : \u03b3) :\n  measurable (\u03bb x, f x ^ c) :=\nhf.pow measurable_const\n\n@[measurability]\nlemma ae_measurable.pow_const (hf : ae_measurable f \u03bc) (c : \u03b3) :\n  ae_measurable (\u03bb x, f x ^ c) \u03bc :=\nhf.pow ae_measurable_const\n\n@[measurability]\nlemma measurable.const_pow (hg : measurable g) (c : \u03b2) :\n  measurable (\u03bb x, c ^ g x) :=\nmeasurable_const.pow hg\n\n@[measurability]\nlemma ae_measurable.const_pow (hg : ae_measurable g \u03bc) (c : \u03b2) :\n  ae_measurable (\u03bb x, c ^ g x) \u03bc :=\nae_measurable_const.pow hg\n\nomit m\n\nend pow\n\n/-- We say that a type `has_measurable_sub` if `(\u03bb x, c - x)` and `(\u03bb x, x - c)` are measurable\nfunctions. For a typeclass assuming measurability of `uncurry (-)` see `has_measurable_sub\u2082`. -/\nclass has_measurable_sub (G : Type*) [measurable_space G] [has_sub G] : Prop :=\n(measurable_const_sub : \u2200 c : G, measurable (\u03bb x, c - x))\n(measurable_sub_const : \u2200 c : G, measurable (\u03bb 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\u2082 (G : Type*) [measurable_space G] [has_sub G] : Prop :=\n(measurable_sub : measurable (\u03bb p : G \u00d7 G, p.1 - p.2))\n\nexport has_measurable_sub\u2082 (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\u2082`. -/\n@[to_additive] class has_measurable_div (G\u2080: Type*) [measurable_space G\u2080] [has_div G\u2080] : Prop :=\n(measurable_const_div : \u2200 c : G\u2080, measurable ((/) c))\n(measurable_div_const : \u2200 c : G\u2080, 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\u2082]\nclass has_measurable_div\u2082 (G\u2080: Type*) [measurable_space G\u2080] [has_div G\u2080] : Prop :=\n(measurable_div : measurable (\u03bb p : G\u2080\u00d7 G\u2080, p.1 / p.2))\n\nexport has_measurable_div\u2082 (measurable_div)\n\nsection div\n\nvariables {G \u03b1 : Type*} [measurable_space G] [has_div G] {m : measurable_space \u03b1} {f g : \u03b1 \u2192 G}\n  {\u03bc : measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.const_div [has_measurable_div G] (hf : measurable f) (c : G) :\n  measurable (\u03bb 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 \u03bc) (c : G) :\n  ae_measurable (\u03bb x, c / f x) \u03bc :=\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 (\u03bb 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 \u03bc) (c : G) :\n  ae_measurable (\u03bb x, f x / c) \u03bc :=\n(has_measurable_div.measurable_div_const c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.div' [has_measurable_div\u2082 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\u2082 G] (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb a, f a / g a) :=\nmeasurable_div.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.div' [has_measurable_div\u2082 G] (hf : ae_measurable f \u03bc)\n  (hg : ae_measurable g \u03bc) :\n  ae_measurable (f / g) \u03bc :=\nmeasurable_div.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.div [has_measurable_div\u2082 G] (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  ae_measurable (\u03bb a, f a / g a) \u03bc :=\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\u2082.to_has_measurable_div [has_measurable_div\u2082 G] :\n  has_measurable_div G :=\n\u27e8\u03bb c, measurable_const.div measurable_id, \u03bb c, measurable_id.div measurable_const\u27e9\n\n@[to_additive]\ninstance pi.has_measurable_div {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_div (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_div (\u03b1 i)] :\n  has_measurable_div (\u03a0 i, \u03b1 i) :=\n\u27e8\u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).const_div _,\n \u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).div_const _\u27e9\n\n@[to_additive pi.has_measurable_sub\u2082]\ninstance pi.has_measurable_div\u2082 {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_div (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_div\u2082 (\u03b1 i)] :\n  has_measurable_div\u2082 (\u03a0 i, \u03b1 i) :=\n\u27e8measurable_pi_iff.mpr $ \u03bb i, measurable_fst.eval.div measurable_snd.eval\u27e9\n\n@[measurability]\nlemma measurable_set_eq_fun {m : measurable_space \u03b1} {E} [measurable_space E] [add_group E]\n  [measurable_singleton_class E] [has_measurable_sub\u2082 E] {f g : \u03b1 \u2192 E}\n  (hf : measurable f) (hg : measurable g) :\n  measurable_set {x | f x = g x} :=\nbegin\n  suffices h_set_eq : {x : \u03b1 | 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\u2082 E] {f g : \u03b1 \u2192 E}\n  (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  null_measurable_set {x | f x = g x} \u03bc :=\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 \u03b1} {E} [measurable_space E]\n  [measurable_singleton_class E] [countable E] {f g : \u03b1 \u2192 E}\n  (hf : measurable f) (hg : measurable g) :\n  measurable_set {x | f x = g x} :=\nbegin\n  have : {x | f x = g x} = \u22c3 j, {x | f x = j} \u2229 {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 (\u03bb 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 {\u03b1 E} {m m0 : measurable_space \u03b1} {\u03bc : measure \u03b1}\n  [measurable_space E] [add_group E] [measurable_singleton_class E] [has_measurable_sub\u2082 E]\n  (hm : m \u2264 m0) {f g : \u03b1 \u2192 E} (hf : measurable[m] f) (hg : measurable[m] g)\n  (hfg : f =\u1d50[\u03bc] g) :\n  f =\u1da0[@measure.ae \u03b1 m (\u03bc.trim hm)] g :=\nbegin\n  rwa [filter.eventually_eq, ae_iff, trim_measurable_set_eq hm _],\n  exact (@measurable_set.compl \u03b1 _ m (@measurable_set_eq_fun \u03b1 m E _ _ _ _ _ _ hf hg)),\nend\n\nend div\n\n/-- We say that a type `has_measurable_neg` if `x \u21a6 -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 \u2192 G))\n\n/-- We say that a type `has_measurable_inv` if `x \u21a6 x\u207b\u00b9` 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 \u2192 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 := \u03bb c,\n    by { convert (measurable_inv.const_mul c), ext1, apply div_eq_mul_inv },\n  measurable_div_const := \u03bb c,\n    by { convert (measurable_id.mul_const c\u207b\u00b9), ext1, apply div_eq_mul_inv } }\n\nsection inv\n\nvariables {G \u03b1 : Type*} [has_inv G] [measurable_space G] [has_measurable_inv G]\n  {m : measurable_space \u03b1} {f : \u03b1 \u2192 G} {\u03bc : measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.inv (hf : measurable f) : measurable (\u03bb x, (f x)\u207b\u00b9) := measurable_inv.comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.inv (hf : ae_measurable f \u03bc) : ae_measurable (\u03bb x, (f x)\u207b\u00b9) \u03bc :=\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 : \u03b1 \u2192 G} : measurable (\u03bb x, (f x)\u207b\u00b9) \u2194 measurable f :=\n\u27e8\u03bb h, by simpa only [inv_inv] using h.inv, \u03bb h, h.inv\u27e9\n\n@[simp, to_additive] lemma ae_measurable_inv_iff {G : Type*} [group G] [measurable_space G]\n  [has_measurable_inv G] {f : \u03b1 \u2192 G} :\n  ae_measurable (\u03bb x, (f x)\u207b\u00b9) \u03bc \u2194 ae_measurable f \u03bc :=\n\u27e8\u03bb h, by simpa only [inv_inv] using h.inv, \u03bb h, h.inv\u27e9\n\n@[simp] lemma measurable_inv_iff\u2080 {G\u2080 : Type*} [group_with_zero G\u2080]\n  [measurable_space G\u2080] [has_measurable_inv G\u2080] {f : \u03b1 \u2192 G\u2080} :\n  measurable (\u03bb x, (f x)\u207b\u00b9) \u2194 measurable f :=\n\u27e8\u03bb h, by simpa only [inv_inv] using h.inv, \u03bb h, h.inv\u27e9\n\n@[simp] lemma ae_measurable_inv_iff\u2080 {G\u2080 : Type*} [group_with_zero G\u2080]\n  [measurable_space G\u2080] [has_measurable_inv G\u2080] {f : \u03b1 \u2192 G\u2080} :\n  ae_measurable (\u03bb x, (f x)\u207b\u00b9) \u03bc \u2194 ae_measurable f \u03bc :=\n\u27e8\u03bb h, by simpa only [inv_inv] using h.inv, \u03bb h, h.inv\u27e9\n\nomit m\n\n@[to_additive]\ninstance pi.has_measurable_inv {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_inv (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_inv (\u03b1 i)] :\n  has_measurable_inv (\u03a0 i, \u03b1 i) :=\n\u27e8measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).inv\u27e9\n\n@[to_additive] lemma measurable_set.inv {s : set G} (hs : measurable_set s) : measurable_set s\u207b\u00b9 :=\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\u2082 G] [has_measurable_inv G] :\n  has_measurable_pow G \u2124 :=\n\u27e8measurable_from_prod_countable $ \u03bb 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\u27e9\n\n@[priority 100, to_additive]\ninstance has_measurable_div\u2082_of_mul_inv (G : Type*) [measurable_space G]\n  [div_inv_monoid G] [has_measurable_mul\u2082 G] [has_measurable_inv G] :\n  has_measurable_div\u2082 G :=\n\u27e8by { simp only [div_eq_mul_inv], exact measurable_fst.mul measurable_snd.inv }\u27e9\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_vadd` if for each `c` the map `x \u21a6 c +\u1d65 x`\nis a measurable function and for each `x` the map `c \u21a6 c +\u1d65 x` is a measurable function. -/\nclass has_measurable_vadd (M \u03b1 : Type*) [has_vadd M \u03b1] [measurable_space M] [measurable_space \u03b1] :\n  Prop :=\n(measurable_const_vadd : \u2200 c : M, measurable ((+\u1d65) c : \u03b1 \u2192 \u03b1))\n(measurable_vadd_const : \u2200 x : \u03b1, measurable (\u03bb c : M, c +\u1d65 x))\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_smul` if for each `c` the map `x \u21a6 c \u2022 x`\nis a measurable function and for each `x` the map `c \u21a6 c \u2022 x` is a measurable function. -/\n@[to_additive]\nclass has_measurable_smul (M \u03b1 : Type*) [has_smul M \u03b1] [measurable_space M] [measurable_space \u03b1] :\n  Prop :=\n(measurable_const_smul : \u2200 c : M, measurable ((\u2022) c : \u03b1 \u2192 \u03b1))\n(measurable_smul_const : \u2200 x : \u03b1, measurable (\u03bb c : M, c \u2022 x))\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_vadd\u2082` if the map\n`(c, x) \u21a6 c +\u1d65 x` is a measurable function. -/\nclass has_measurable_vadd\u2082 (M \u03b1 : Type*) [has_vadd M \u03b1] [measurable_space M]\n  [measurable_space \u03b1] : Prop :=\n(measurable_vadd : measurable (function.uncurry (+\u1d65) : M \u00d7 \u03b1 \u2192 \u03b1))\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_smul\u2082` if the map\n`(c, x) \u21a6 c \u2022 x` is a measurable function. -/\n@[to_additive has_measurable_vadd\u2082]\nclass has_measurable_smul\u2082 (M \u03b1 : Type*) [has_smul M \u03b1] [measurable_space M]\n  [measurable_space \u03b1] : Prop :=\n(measurable_smul : measurable (function.uncurry (\u2022) : M \u00d7 \u03b1 \u2192 \u03b1))\n\nexport has_measurable_smul (measurable_const_smul measurable_smul_const)\nexport has_measurable_smul\u2082 (measurable_smul)\nexport has_measurable_vadd (measurable_const_vadd measurable_vadd_const)\nexport has_measurable_vadd\u2082 (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\u27e8measurable_id.const_mul, measurable_id.mul_const\u27e9\n\n@[to_additive]\ninstance has_measurable_smul\u2082_of_mul (M : Type*) [has_mul M] [measurable_space M]\n  [has_measurable_mul\u2082 M] :\n  has_measurable_smul\u2082 M M :=\n\u27e8measurable_mul\u27e9\n\n@[to_additive] instance submonoid.has_measurable_smul {M \u03b1} [measurable_space M]\n  [measurable_space \u03b1] [monoid M] [mul_action M \u03b1] [has_measurable_smul M \u03b1] (s : submonoid M) :\n  has_measurable_smul s \u03b1 :=\n\u27e8\u03bb c, by simpa only using measurable_const_smul (c : M),\n  \u03bb x, (measurable_smul_const x : measurable (\u03bb c : M, c \u2022 x)).comp measurable_subtype_coe\u27e9\n\n@[to_additive] instance subgroup.has_measurable_smul {G \u03b1} [measurable_space G]\n  [measurable_space \u03b1] [group G] [mul_action G \u03b1] [has_measurable_smul G \u03b1] (s : subgroup G) :\n  has_measurable_smul s \u03b1 :=\ns.to_submonoid.has_measurable_smul\n\nsection smul\n\nvariables {M \u03b2 \u03b1 : Type*} [measurable_space M] [measurable_space \u03b2] [has_smul M \u03b2]\n  {m : measurable_space \u03b1} {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 \u03b2}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.smul [has_measurable_smul\u2082 M \u03b2] (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb x, f x \u2022 g x) :=\nmeasurable_smul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.smul [has_measurable_smul\u2082 M \u03b2]\n  {\u03bc : measure \u03b1} (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  ae_measurable (\u03bb x, f x \u2022 g x) \u03bc :=\nhas_measurable_smul\u2082.measurable_smul.comp_ae_measurable (hf.prod_mk hg)\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_smul\u2082.to_has_measurable_smul [has_measurable_smul\u2082 M \u03b2] :\n  has_measurable_smul M \u03b2 :=\n\u27e8\u03bb c, measurable_const.smul measurable_id, \u03bb y, measurable_id.smul measurable_const\u27e9\n\ninclude m\n\nvariables [has_measurable_smul M \u03b2] {\u03bc : measure \u03b1}\n\n@[measurability, to_additive]\nlemma measurable.smul_const (hf : measurable f) (y : \u03b2) :\n  measurable (\u03bb x, f x \u2022 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 \u03bc) (y : \u03b2) :\n  ae_measurable (\u03bb x, f x \u2022 y) \u03bc :=\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 (\u03bb x, c \u2022 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 \u2022 g) :=\nhg.const_smul' c\n\n@[measurability, to_additive]\nlemma ae_measurable.const_smul' (hg : ae_measurable g \u03bc) (c : M) :\n  ae_measurable (\u03bb x, c \u2022 g x) \u03bc :=\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 \u03bc) (c : M) :\n  ae_measurable (c \u2022 g) \u03bc :=\nhf.const_smul' c\n\nomit m\n\n@[to_additive]\ninstance pi.has_measurable_smul {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_smul M (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_smul M (\u03b1 i)] :\n  has_measurable_smul M (\u03a0 i, \u03b1 i) :=\n\u27e8\u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).const_smul _,\n \u03bb g, measurable_pi_iff.mpr $ \u03bb i, measurable_smul_const _\u27e9\n\n/-- `add_monoid.has_smul_nat` is measurable. -/\ninstance add_monoid.has_measurable_smul_nat\u2082 (M : Type*) [add_monoid M] [measurable_space M]\n  [has_measurable_add\u2082 M] : has_measurable_smul\u2082 \u2115 M :=\n\u27e8begin\n  suffices : measurable (\u03bb p : M \u00d7 \u2115, p.2 \u2022 p.1),\n  { apply this.comp measurable_swap, },\n  refine measurable_from_prod_countable (\u03bb n, _),\n  induction n with n ih,\n  { simp only [zero_smul, \u2190pi.zero_def, measurable_zero] },\n  { simp only [succ_nsmul], exact measurable_id.add ih }\nend\u27e9\n\n/-- `sub_neg_monoid.has_smul_int` is measurable. -/\ninstance sub_neg_monoid.has_measurable_smul_int\u2082 (M : Type*) [sub_neg_monoid M] [measurable_space M]\n  [has_measurable_add\u2082 M] [has_measurable_neg M] : has_measurable_smul\u2082 \u2124 M :=\n\u27e8begin\n  suffices : measurable (\u03bb p : M \u00d7 \u2124, p.2 \u2022 p.1),\n  { apply this.comp measurable_swap, },\n  refine measurable_from_prod_countable (\u03bb 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\u27e9\n\nend smul\n\nsection mul_action\n\nvariables {M \u03b2 \u03b1 : Type*} [measurable_space M] [measurable_space \u03b2] [monoid M] [mul_action M \u03b2]\n  [has_measurable_smul M \u03b2] [measurable_space \u03b1] {f : \u03b1 \u2192 \u03b2} {\u03bc : measure \u03b1}\n\nvariables {G : Type*} [group G] [measurable_space G] [mul_action G \u03b2]\n  [has_measurable_smul G \u03b2]\n\n@[to_additive]\nlemma measurable_const_smul_iff (c : G) :\n  measurable (\u03bb x, c \u2022 f x) \u2194 measurable f :=\n\u27e8\u03bb h, by simpa only [inv_smul_smul] using h.const_smul' c\u207b\u00b9, \u03bb h, h.const_smul c\u27e9\n\n@[to_additive]\nlemma ae_measurable_const_smul_iff (c : G) :\n  ae_measurable (\u03bb x, c \u2022 f x) \u03bc \u2194 ae_measurable f \u03bc :=\n\u27e8\u03bb h, by simpa only [inv_smul_smul] using h.const_smul' c\u207b\u00b9, \u03bb h, h.const_smul c\u27e9\n\n@[to_additive]\ninstance : measurable_space M\u02e3 := measurable_space.comap (coe : M\u02e3 \u2192 M) \u2039_\u203a\n\n@[to_additive]\ninstance units.has_measurable_smul : has_measurable_smul M\u02e3 \u03b2 :=\n{ measurable_const_smul := \u03bb c, (measurable_const_smul (c : M) : _),\n  measurable_smul_const := \u03bb x,\n    (measurable_smul_const x : measurable (\u03bb c : M, c \u2022 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 (\u03bb x, c \u2022 f x) \u2194 measurable f :=\nlet \u27e8u, hu\u27e9 := hc in hu \u25b8 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 (\u03bb x, c \u2022 f x) \u03bc \u2194 ae_measurable f \u03bc :=\nlet \u27e8u, hu\u27e9 := hc in hu \u25b8 ae_measurable_const_smul_iff u\n\nvariables {G\u2080 : Type*} [group_with_zero G\u2080] [measurable_space G\u2080] [mul_action G\u2080 \u03b2]\n  [has_measurable_smul G\u2080 \u03b2]\n\nlemma measurable_const_smul_iff\u2080 {c : G\u2080} (hc : c \u2260 0) :\n  measurable (\u03bb x, c \u2022 f x) \u2194 measurable f :=\n(is_unit.mk0 c hc).measurable_const_smul_iff\n\nlemma ae_measurable_const_smul_iff\u2080 {c : G\u2080} (hc : c \u2260 0) :\n  ae_measurable (\u03bb x, c \u2022 f x) \u03bc \u2194 ae_measurable f \u03bc :=\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 {\u03b1 : Type*} [h : measurable_space \u03b1] : measurable_space \u03b1\u1d50\u1d52\u1d56 := measurable_space.map op h\n\n@[to_additive]\nlemma measurable_mul_op {\u03b1 : Type*} [measurable_space \u03b1] : measurable (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := \u03bb s, id\n\n@[to_additive]\nlemma measurable_mul_unop {\u03b1 : Type*} [measurable_space \u03b1] : measurable (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := \u03bb s, id\n\n@[to_additive]\ninstance {M : Type*} [has_mul M] [measurable_space M] [has_measurable_mul M] :\n  has_measurable_mul M\u1d50\u1d52\u1d56 :=\n\u27e8\u03bb c, measurable_mul_op.comp (measurable_mul_unop.mul_const _),\n  \u03bb c, measurable_mul_op.comp (measurable_mul_unop.const_mul _)\u27e9\n\n@[to_additive]\ninstance {M : Type*} [has_mul M] [measurable_space M] [has_measurable_mul\u2082 M] :\n  has_measurable_mul\u2082 M\u1d50\u1d52\u1d56 :=\n\u27e8measurable_mul_op.comp ((measurable_mul_unop.comp measurable_snd).mul\n  (measurable_mul_unop.comp measurable_fst))\u27e9\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance has_measurable_smul.op {M \u03b1} [measurable_space M]\n  [measurable_space \u03b1] [has_smul M \u03b1] [has_smul M\u1d50\u1d52\u1d56 \u03b1] [is_central_scalar M \u03b1]\n  [has_measurable_smul M \u03b1] : has_measurable_smul M\u1d50\u1d52\u1d56 \u03b1 :=\n\u27e8 mul_opposite.rec $ \u03bb c, show measurable (\u03bb x, op c \u2022 x),\n                          by simpa only [op_smul_eq_smul] using measurable_const_smul c,\n  \u03bb x, show measurable (\u03bb c, op (unop c) \u2022 x),\n       by simpa only [op_smul_eq_smul] using (measurable_smul_const x).comp measurable_mul_unop\u27e9\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance has_measurable_smul\u2082.op {M \u03b1} [measurable_space M]\n  [measurable_space \u03b1] [has_smul M \u03b1] [has_smul M\u1d50\u1d52\u1d56 \u03b1] [is_central_scalar M \u03b1]\n  [has_measurable_smul\u2082 M \u03b1] : has_measurable_smul\u2082 M\u1d50\u1d52\u1d56 \u03b1 :=\n\u27e8show measurable (\u03bb x : M\u1d50\u1d52\u1d56 \u00d7 \u03b1, op (unop x.1) \u2022 x.2), begin\n  simp_rw op_smul_eq_smul,\n  refine (measurable_mul_unop.comp measurable_fst).smul measurable_snd,\nend\u27e9\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\u1d50\u1d52\u1d56 M :=\n\u27e8\u03bb c, measurable_mul_const (unop c), \u03bb x, measurable_mul_unop.const_mul x\u27e9\n\n@[to_additive]\ninstance has_measurable_smul\u2082_opposite_of_mul {M : Type*} [has_mul M] [measurable_space M]\n  [has_measurable_mul\u2082 M] : has_measurable_smul\u2082 M\u1d50\u1d52\u1d56 M :=\n\u27e8measurable_snd.mul (measurable_mul_unop.comp measurable_fst)\u27e9\n\nend opposite\n\n/-!\n### Big operators: `\u220f` and `\u2211`\n-/\n\nsection monoid\nvariables {M \u03b1 : Type*} [monoid M] [measurable_space M] [has_measurable_mul\u2082 M]\n  {m : measurable_space \u03b1} {\u03bc : measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\nlemma list.measurable_prod' (l : list (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 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 (\u03b1 \u2192 M))\n  (hl : \u2200 f \u2208 l, ae_measurable f \u03bc) : ae_measurable l.prod \u03bc :=\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 (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, measurable f) :\n  measurable (\u03bb x, (l.map (\u03bb f : \u03b1 \u2192 M, f x)).prod) :=\nby simpa only [\u2190 pi.list_prod_apply] using l.measurable_prod' hl\n\n@[measurability, to_additive]\nlemma list.ae_measurable_prod (l : list (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, ae_measurable f \u03bc) :\n  ae_measurable (\u03bb x, (l.map (\u03bb f : \u03b1 \u2192 M, f x)).prod) \u03bc :=\nby simpa only [\u2190 pi.list_prod_apply] using l.ae_measurable_prod' hl\n\nomit m\n\nend monoid\n\nsection comm_monoid\nvariables {M \u03b9 \u03b1 : Type*} [comm_monoid M] [measurable_space M] [has_measurable_mul\u2082 M]\n  {m : measurable_space \u03b1} {\u03bc : measure \u03b1} {f : \u03b9 \u2192 \u03b1 \u2192 M}\n\ninclude m\n\n@[measurability, to_additive]\nlemma multiset.measurable_prod' (l : multiset (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, measurable f) :\n  measurable l.prod :=\nby { rcases l with \u27e8l\u27e9, simpa using l.measurable_prod' (by simpa using hl) }\n\n@[measurability, to_additive]\nlemma multiset.ae_measurable_prod' (l : multiset (\u03b1 \u2192 M))\n  (hl : \u2200 f \u2208 l, ae_measurable f \u03bc) : ae_measurable l.prod \u03bc :=\nby { rcases l with \u27e8l\u27e9, simpa using l.ae_measurable_prod' (by simpa using hl) }\n\n@[measurability, to_additive]\nlemma multiset.measurable_prod (s : multiset (\u03b1 \u2192 M)) (hs : \u2200 f \u2208 s, measurable f) :\n  measurable (\u03bb x, (s.map (\u03bb f : \u03b1 \u2192 M, f x)).prod) :=\nby simpa only [\u2190 pi.multiset_prod_apply] using s.measurable_prod' hs\n\n@[measurability, to_additive]\nlemma multiset.ae_measurable_prod (s : multiset (\u03b1 \u2192 M))\n  (hs : \u2200 f \u2208 s, ae_measurable f \u03bc) : ae_measurable (\u03bb x, (s.map (\u03bb f : \u03b1 \u2192 M, f x)).prod) \u03bc :=\nby simpa only [\u2190 pi.multiset_prod_apply] using s.ae_measurable_prod' hs\n\n@[measurability, to_additive]\nlemma finset.measurable_prod' (s : finset \u03b9) (hf : \u2200i \u2208 s, measurable (f i)) :\n  measurable (\u220f i in s, f i) :=\nfinset.prod_induction _ _ (\u03bb _ _, measurable.mul) (@measurable_one M _ _ _ _) hf\n\n@[measurability, to_additive]\nlemma finset.measurable_prod (s : finset \u03b9) (hf : \u2200i \u2208 s, measurable (f i)) :\n  measurable (\u03bb a, \u220f i in s, f i a) :=\nby simpa only [\u2190 finset.prod_apply] using s.measurable_prod' hf\n\n@[measurability, to_additive]\nlemma finset.ae_measurable_prod' (s : finset \u03b9) (hf : \u2200i \u2208 s, ae_measurable (f i) \u03bc) :\n  ae_measurable (\u220f i in s, f i) \u03bc :=\nmultiset.ae_measurable_prod' _ $\n  \u03bb g hg, let \u27e8i, hi, hg\u27e9 := multiset.mem_map.1 hg in (hg \u25b8 hf _ hi)\n\n@[measurability, to_additive]\nlemma finset.ae_measurable_prod (s : finset \u03b9) (hf : \u2200i \u2208 s, ae_measurable (f i) \u03bc) :\n  ae_measurable (\u03bb a, \u220f i in s, f i a) \u03bc :=\nby simpa only [\u2190 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": "/-\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 \u2228 (0xdfff < n \u2227 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 \u2264 b.val\n\ninstance : LT Char := \u27e8Char.lt\u27e9\ninstance : LE Char := \u27e8Char.le\u27e9\n\ninstance (a b : Char) :  Decidable (a < b) :=\n  UInt32.decLt _ _\n\ninstance (a b : Char) : Decidable (a \u2264 b) :=\n  UInt32.decLe _ _\n\nabbrev isValidCharNat (n : Nat) : Prop :=\n  n < 0xd800 \u2228 (0xdfff < n \u2227 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.lt_trans h\n    decide\n  | Or.inr \u27e8h\u2081, h\u2082\u27e9 =>\n    apply Nat.lt_trans h\u2082\n    decide\n\ntheorem isValidChar_of_isValidChar_Nat (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 \u27e8h\u2081, h\u2082\u27e9 => Or.inr \u27e8h\u2081, h\u2082\u27e9\n\ntheorem isValidChar_zero : 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 \u2265 65 && c.val \u2264 90\n\ndef isLower (c : Char) : Bool :=\n  c.val \u2265 97 && c.val \u2264 122\n\ndef isAlpha (c : Char) : Bool :=\n  c.isUpper || c.isLower\n\ndef isDigit (c : Char) : Bool :=\n  c.val \u2265 48 && c.val \u2264 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 \u2227 n <= 90 then ofNat (n + 32) else c\n\ndef toUpper (c : Char) : Char :=\n  let n := toNat c;\n  if n >= 97 \u2227 n <= 122 then ofNat (n - 32) else c\n\nend Char\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/stage0/src/Init/Data/Char/Basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7122321720225278, "lm_q2_score": 0.6548947357776795, "lm_q1q2_score": 0.4664371001090561}}
{"text": "import lang\nimport normalization\nimport data.set\n\n-- V\u27e6\u2212\u27e7 : type \u2192 PowerSet(ClosedVal)\n-- V\u27e6\u2212\u27e7 : type \u2192 (ClosedVal \u2192 2)\n-- interp_val : type \u2192 val \u2192 Prop\n--\n\nopen exp typ\n\nnotation e ` \u21a6* `:90 e' := is_many_step e e'\n\ndef irred (e:exp) := \u00ac(\u2203 e', e \u21a6str 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 | \u2200 e', (e \u21a6* e') \u2227 irred(e') \u2192 e' \u2208 s }\n\ninductive rel_arrow: T \u2192 T \u2192 T\n| Rlam (R\u03c41 R\u03c42:T) (x:string) (\u03c4:typ) (e:exp)\n  (Hfunc: \u2200 (v:exp), (v \u2208 R\u03c41) \u2192 (substitute x v e) \u2208 step_closure R\u03c42) :\n  (rel_arrow R\u03c41 R\u03c42 (lam x \u03c4 e))\n\ndef closed_vals := { e : exp | is_val e }\n\ndef interp_val : typ \u2192 (set exp)\n| unitT := (singleton exp.unit)\n| (arrowT \u03c41 \u03c42) := (rel_arrow (interp_val \u03c41) (interp_val \u03c42)) \u2229 closed_vals\n\ndef interp_exp (\u03c4:typ) := step_closure (interp_val \u03c4)\n\nnotation `V\u27e6` \u03c4 `\u27e7` := interp_val \u03c4\nnotation `E\u27e6` \u03c4 `\u27e7` := interp_exp \u03c4\n\n-- XXX: now, we're gonna call context_list \u0393, and have to explicitly to\n-- (mk_context \u0393) in has_type.\ndef interp_ctx : context_list \u2192 set env\n| [] [] := true\n| ((y,\u03c4)::\u0393) ((x,v)::\u03b3) := x=y \u2227 interp_ctx \u0393 \u03b3 \u2227 (v \u2208 V\u27e6\u03c4\u27e7)\n| _ _ := false\n\nnotation `G\u27e6` \u0393 `\u27e7` := interp_ctx \u0393\n\ndef semantic_has_type (\u0393:context_list) (e:exp) (\u03c4:typ) : Prop :=\n  \u2200 \u03b3, \u03b3 \u2208 G\u27e6\u0393\u27e7 \u2192 env_sub \u03b3 e \u2208 E\u27e6\u03c4\u27e7\n\nnotation \u0393 ` \u22a8 `:90 e:90 ` : `:90 \u03c4 := semantic_has_type \u0393 e \u03c4\n\ndef safe (e:exp) : Prop :=\n\u2200 e', (e \u21a6* e') \u2192 (is_val e') \u2228 (\u2203 e'', e' \u21a6str e'')\n\nlemma interp_val_implies_closedval :\n\u2200 v \u03c4, v \u2208 V\u27e6\u03c4\u27e7 \u2192 v \u2208 closed_vals :=\nbegin\n  introv Hval,\n  cases \u03c4,\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\u2200 e \u03c4,\n  ([] \u22a8 e : \u03c4) \u2192\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' \u27e8Hstep, h\u27e9,\n    left,\n    apply interp_val_implies_closedval,\n    assumption\n  }\nend\n\ndef not_in_env (\u03b3:env) (x:string) : Prop := (\u2200 v, (x, v) \u2209 \u03b3)\n\nlemma env_sub_lam_notin :\n\u2200 \u03b3 x \u03c4 e,\n  not_in_env \u03b3 x \u2192\n  env_sub \u03b3 (lam x \u03c4 e) = lam x \u03c4 (env_sub \u03b3 e) :=\nbegin\n  introv Hnot,\n  induction \u03b3,\n  { unfold env_sub },\n  cases \u03b3_hd,\n  unfold env_sub,\n  sorry,\nend\n\nlemma env_sub_lam_in :\n\u2200 \u03b3 x \u03c4 e v,\n  ((x, v) \u2208 \u03b3) \u2192\n  env_sub \u03b3 (lam x \u03c4 e) = lam x \u03c4 e :=\nbegin\nsorry\nend\n\n-- This is the \"substitution lemma\" on page 13 of notes.\nlemma substitution_lemma :\n  \u2200 \u03b3 x vx e,\n  not_in_env \u03b3 x \u2192\n  env_sub ((x,vx)::\u03b3) e = substitute x vx (env_sub \u03b3 e) :=\nbegin\n  introv Hnot,\n  unfold env_sub,\n  induction \u03b3 generalizing e,\n  { unfold env_sub },\n  cases \u03b3_hd,\n  unfold env_sub,\n  rw <- \u03b3_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\u2200 \u0393 e \u03c4,\n  (mk_context \u0393 \u22a2 e : \u03c4) \u2192\n  (\u0393 \u22a8 e : \u03c4) :=\nbegin\n  introv Hty,\n  generalize h : (mk_context \u0393) = (ctx),\n  rw h at *,\n  induction Hty generalizing \u0393; subst h; unfold semantic_has_type,\n  { -- case: unit\n    introv H\u03b3, 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\u03b3,\n    rename [Hty_x \u2192 x, Hty_\u03c4 \u2192 \u03c4],\n    -- Argument:\n    -- Knowing (mk_context \u0393) x = some \u03c4 and \u03b3 \u2208 G\u27e6\u0393\u27e7 should tells us:\n    -- \u2203 (x,vx) \u2208 \u03b3, vx \u2208 V\u27e6\u03c4\u27e7,\n    --    env_sub \u03b3 (var x) = vx\n    -- At that point, we're done because V\u27e6\u03c4\u27e7 \u2286 E\u27e6\u03c4\u27e7.\n    sorry,\n  },\n  { -- case: abs; this is where induction will be a bit tricky.\n    introv H\u03b3,\n    rename [Hty_x \u2192 x, Hty_\u03c41 \u2192 \u03c41, Hty_\u03c42 \u2192 \u03c42, Hty_e \u2192 e],\n    -- FIXME: using this false lemma (could be made true modulo \u03b1-substitutions)\n    -- to mimic the argument in the lecture notes for now.\n    by_cases (not_in_env \u03b3 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\u27e6\u03c42\u27e7 is the same as E\u27e6\u03c42\u27e7.\n      rw (_:step_closure V\u27e6\u03c42\u27e7 = E\u27e6\u03c42\u27e7), tactic.swap,\n      { unfold interp_exp },\n\n      -- Apply inductive hypothesis\n      specialize Hty_ih ((x,\u03c41)::\u0393) _,\n      { unfold mk_context },\n      specialize Hty_ih ((x,v)::\u03b3) _,\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 \u29f8 R \u2219 (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 ^ \u221e`-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 ^ \u221e`-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    \u2203 (\u03b9 : Type u)(_ : Fintype \u03b9)(_ : DecidableEq \u03b9)(p : \u03b9 \u2192 R)(h : \u2200 i, Irreducible <| p i)(e :\n      \u03b9 \u2192 \u2115), DirectSum.IsInternal fun i => torsion_by R M <| p i ^ e i :=\n  by\n  obtain \u27e8P, dec, hP, e, this\u27e9 := is_internal_prime_power_torsion hM\n  refine' \u27e8P, inferInstance, dec, fun p => is_principal.generator (p : Ideal R), _, e, _\u27e9\n  \u00b7 rintro \u27e8p, hp\u27e9\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  \u00b7 convert this\n    ext p : 1\n    rw [\u2190 torsion_by_span_singleton_eq, Ideal.submodule_span_eq, \u2190 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 : \u2200 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 [\u2190 (torsion_of R M x).span_singleton_generator, Ideal.span_singleton_eq_span_singleton, \u2190\n    Associates.mk_eq_mk_iff_associated, Associates.mk_pow]\n  have prop :\n    (fun n : \u2115 => p ^ n \u2022 x = 0) = fun n : \u2115 =>\n      (Associates.mk <| generator <| torsion_of R M x) \u2223 Associates.mk p ^ n :=\n    by\n    ext n\n    rw [\u2190 Associates.mk_pow, Associates.mk_dvd_mk, \u2190 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 : \u2115} (hM' : Module.IsTorsionBy R M (p ^ pOrder hM y))\n    (h : p ^ k \u2022 x \u2208 R \u2219 y) : \u2203 a : R, p ^ k \u2022 x = p ^ k \u2022 a \u2022 y :=\n  by\n  by_cases hk : k \u2264 p_order hM y\n  \u00b7 let f :=\n      ((R \u2219 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 \u27e8p ^ k \u2022 x, h\u27e9 \u2208 R \u2219 Ideal.Quotient.mk (R \u2219 p ^ (p_order hM y - k) * p ^ k) (p ^ k) :=\n      by\n      rw [\u2190 quotient.torsion_by_eq_span_singleton, mem_torsion_by_iff, \u2190 f.symm.map_smul]\n      convert f.symm.map_zero\n      ext\n      rw [coe_smul_of_tower, coe_mk, coe_zero, smul_smul, \u2190 pow_add, Nat.sub_add_cancel hk, @hM' x]\n      \u00b7 exact mem_nonZeroDivisors_of_ne_zero (pow_ne_zero _ hp.ne_zero)\n    rw [Submodule.mem_span_singleton] at this\n    obtain \u27e8a, ha\u27e9 := this\n    use a\n    rw [f.eq_symm_apply, \u2190 Ideal.Quotient.mk_eq_mk, \u2190 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    \u00b7 symm\n      convert Ideal.torsionOf_eq_span_pow_pOrder hp hM y\n      rw [\u2190 pow_add, Nat.sub_add_cancel hk]\n  \u00b7 use 0\n    rw [zero_smul, smul_zero, \u2190 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 : \u2115} (f : (R \u29f8 R \u2219 p ^ k) \u2192\u2097[R] M \u29f8 R \u2219 z) :\n    \u2203 x : M, p ^ k \u2022 x = 0 \u2227 Submodule.Quotient.mk x = f 1 :=\n  by\n  have f1 := mk_surjective (R \u2219 z) (f 1)\n  have : p ^ k \u2022 f1.some \u2208 R \u2219 z :=\n    by\n    rw [\u2190 quotient.mk_eq_zero, mk_smul, f1.some_spec, \u2190 f.map_smul]\n    convert f.map_zero\n    change _ \u2022 Submodule.Quotient.mk _ = _\n    rw [\u2190 mk_smul, quotient.mk_eq_zero, Algebra.id.smul_eq_mul, mul_one]\n    exact Submodule.mem_span_singleton_self _\n  obtain \u27e8a, ha\u27e9 := p_pow_smul_lift hp hM hz this\n  refine' \u27e8f1.some - a \u2022 z, by rw [smul_sub, sub_eq_zero, ha], _\u27e9\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 ^ \u221e`-torsion module over a PID is isomorphic to a direct sum of some\n  `R \u29f8 R \u2219 (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    \u2203 (d : \u2115)(k : Fin d \u2192 \u2115), Nonempty <| N \u2243\u2097[R] \u2a01 i : Fin d, R \u29f8 R \u2219 p ^ (k i : \u2115) :=\n  by\n  obtain \u27e8d, s, hs\u27e9 := @Module.Finite.exists_fin _ _ _ _ _ h'; use d; clear h'\n  induction' d with d IH generalizing N\n  \u00b7 use fun i => finZeroElim i\n    rw [Set.range_eq_empty, Submodule.span_empty] at hs\n    haveI : Unique N :=\n      \u27e8\u27e80\u27e9, fun x => by\n        rw [\u2190 mem_bot _, hs]\n        trivial\u27e9\n    exact \u27e80\u27e9\n  \u00b7 have : \u2200 x : N, Decidable (x = 0)\n    classical\n      infer_instance\n      obtain \u27e8j, hj\u27e9 := exists_is_torsion_by hN d.succ d.succ_ne_zero s hs\n      let s' : Fin d \u2192 N \u29f8 R \u2219 s j := Submodule.Quotient.mk \u2218 s \u2218 j.succ_above\n      obtain \u27e8k, \u27e8f\u27e9\u27e9 := IH _ s' _ <;> clear IH\n      \u00b7 have :\n          \u2200 i : Fin d,\n            \u2203 x : N, p ^ k i \u2022 x = 0 \u2227 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 \u27e8x, h0, h1\u27e9 := exists_smul_eq_zero_and_mk_eq hp hN hj fi\n          refine' \u27e8x, h0, _\u27e9\n          rw [h1]\n          simp only [LinearMap.coe_comp, f.symm.coe_to_linear_map, f.apply_symm_apply]\n        refine'\n          \u27e8_,\n            \u27e8(((@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 \u29f8 _ \u2192\u2097[R] _)).comp\n                                ulift.module_equiv.to_linear_map)\n                              (R \u2219 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 \u29f8 R \u2219 p ^ @Option.rec _ (fun _ => \u2115) (p_order hN <| s j) k i) _\n                        _).symm).trans <|\n                DirectSum.lequivCongrLeft R (finSuccEquiv d).symm\u27e9\u27e9\n        \u00b7 rw [range_subtype, LinearEquiv.toLinearMap_eq_coe, LinearEquiv.ker_comp, ker_mkq]\n        \u00b7 rw [LinearEquiv.toLinearMap_eq_coe, \u2190 f.comp_coe, LinearMap.comp_assoc,\n            LinearMap.comp_assoc, \u2190 LinearEquiv.toLinearMap_eq_coe,\n            LinearEquiv.toLinearMap_symm_comp_eq, LinearMap.comp_id, \u2190 LinearMap.comp_assoc, \u2190\n            LinearMap.comp_assoc]\n          suffices (f.to_linear_map.comp (R \u2219 s j).mkQ).comp _ = LinearMap.id by\n            rw [\u2190 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      \u00b7\n        exact\n          (mk_surjective _).forall.mpr fun x =>\n            \u27e8(@hN x).some, by rw [\u2190 quotient.mk_smul, (@hN x).choose_spec, quotient.mk_zero]\u27e9\n      \u00b7 have hs' := congr_arg (Submodule.map <| mkq <| R \u2219 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 (_ \u2218 s), Fin.range_succAbove]\n        rw [\u2190 Set.range_comp, \u2190 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 \u29f8 R \u2219 (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    \u2203 (\u03b9 : Type u)(_ : Fintype \u03b9)(p : \u03b9 \u2192 R)(h : \u2200 i, Irreducible <| p i)(e : \u03b9 \u2192 \u2115),\n      Nonempty <| N \u2243\u2097[R] \u2a01 i : \u03b9, R \u29f8 R \u2219 p i ^ e i :=\n  by\n  obtain \u27e8I, fI, _, p, hp, e, h\u27e9 := Submodule.isInternal_prime_power_torsion_of_pid hN\n  haveI := fI\n  have :\n    \u2200 i,\n      \u2203 (d : \u2115)(k : Fin d \u2192 \u2115),\n        Nonempty <| torsion_by R N (p i ^ e i) \u2243\u2097[R] \u2a01 j, R \u29f8 R \u2219 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 => \u27e8e i, smul_torsion_by _ _\u27e9)\n  classical\n    refine'\n      \u27e8\u03a3i, Fin (this i).some, inferInstance, fun \u27e8i, j\u27e9 => p i, fun \u27e8i, j\u27e9 => hp i, fun \u27e8i, j\u27e9 =>\n        (this i).choose_spec.some j,\n        \u27e8(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 _ _ _)\u27e9\u27e9\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 \u29f8 R \u2219 (p i ^ e i)` where the `p i ^ e i` are prime powers.-/\ntheorem equiv_free_prod_directSum [h' : Module.Finite R N] :\n    \u2203 (n : \u2115)(\u03b9 : Type u)(_ : Fintype \u03b9)(p : \u03b9 \u2192 R)(h : \u2200 i, Irreducible <| p i)(e : \u03b9 \u2192 \u2115),\n      Nonempty <| N \u2243\u2097[R] (Fin n \u2192\u2080 R) \u00d7 \u2a01 i : \u03b9, R \u29f8 R \u2219 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 \u27e8I, fI, p, hp, e, \u27e8h\u27e9\u27e9 := equiv_direct_sum_of_is_torsion (@torsion_is_torsion R N _ _ _)\n  obtain \u27e8n, \u27e8g\u27e9\u27e9 := @Module.basisOfFiniteTypeTorsionFree' R _ _ _ (N \u29f8 torsion R N) _ _ _ _\n  haveI : Module.Projective R (N \u29f8 torsion R N) := Module.projectiveOfBasis \u27e8g\u27e9\n  obtain \u27e8f, hf\u27e9 := Module.projective_lifting_property _ LinearMap.id (torsion R N).mkQ_surjective\n  refine'\n    \u27e8n, I, fI, p, hp, e,\n      \u27e8(lequivProdOfRightSplitExact (torsion R N).injective_subtype _ hf).symm.trans <|\n          (h.prod g).trans <| LinearEquiv.prodComm R _ _\u27e9\u27e9\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 \u00a9 2019 Fran\u00e7ois 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 (\u03b1 : Type*) :=\n(op : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n\nnamespace magma_sig\nvariables {\u03b1 : Type*} (s : magma_sig \u03b1)\n\n@[signature_instance]\ndefinition to_left_action : left_action_sig \u03b1 \u03b1 :=\n{ act := s.op\n}\n\n@[signature_instance]\ndefinition to_right_action : right_action_sig \u03b1 \u03b1 :=\n{ act := s.op\n}\n\nend magma_sig\n\nclass magma {\u03b1} (s : magma_sig \u03b1) : Prop := intro [] ::\n\nabbreviation magma.infer {\u03b1} (s : magma_sig \u03b1) : magma s := magma.intro _\n\n@[theory]\nclass cancel_magma {\u03b1} (s : magma_sig \u03b1) : 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 {\u03b1} (s : magma_sig \u03b1) [i : cancel_magma s] : magma s := magma.infer _ \n\n@[theory]\nclass comm_magma {\u03b1} (s : magma_sig \u03b1) : Prop := intro ::\n(commutative : identity.op_commutative s.op)\n\ninstance comm_magma.to_magma {\u03b1} (s : magma_sig \u03b1) [i : comm_magma s] : magma s := magma.infer _ \n\n@[theory]\nclass cancel_comm_magma {\u03b1} (s : magma_sig \u03b1) : 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 {\u03b1} (s : magma_sig \u03b1) [i : cancel_comm_magma s] : comm_magma s := comm_magma.infer _\n\n@[identity_instance]\ntheorem cancel_comm_magma.left_cancellative {\u03b1} (s : magma_sig \u03b1) [i : cancel_comm_magma s] :\nidentity.op_left_cancellative s.op :=\n\u03bb 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 {\u03b1} (s : magma_sig \u03b1) [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 `\u2115` 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 (\u03b1 : Type*) [linear_order \u03b1] :=\n(from_nat : \u2115 \u2192 \u03b1)\n(to_nat : \u03b1 \u2192 \u2115)\n(mono_from : monotone from_nat)\n(from_to : \u2200 a, from_nat (to_nat a) = a)\n\n@[priority 100]\ninstance indexing.has_coe (\u03b1 : Type*) [linear_order \u03b1] [indexing \u03b1] : has_coe \u2115 \u03b1 :=\n\u27e8indexing.from_nat\u27e9\n\n@[simp]\nlemma indexing.coe_to {\u03b1 : Type*} [linear_order \u03b1] [indexing \u03b1] (i : \u03b1) :\n  ((indexing.to_nat i) : \u03b1) = i :=\nindexing.from_to i\n\nlemma indexing.coe_mono {\u03b1 : Type*} [linear_order \u03b1] [indexing \u03b1] {i j : \u2115} (h : i \u2264 j) :\n  (i : \u03b1) \u2264 j :=\nindexing.mono_from h\n\ninstance indexing.nonempty (\u03b1 : Type*) [linear_order \u03b1] [indexing \u03b1] : nonempty \u03b1 :=\n\u27e8indexing.from_nat 0\u27e9\n\ninstance : indexing \u2115 :=\n{ from_nat := id,\n  to_nat := id,\n  mono_from := monotone_id,\n  from_to := \u03bb n, rfl }\n\ndef fin.indexing (n : \u2115) : indexing (fin $ n + 1) :=\n{ from_nat := \u03bb k, if h : k < n + 1 then \u27e8k, h\u27e9 else fin.last n,\n  to_nat := coe,\n  mono_from := \u03bb 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 \u27e8k, hk\u27e9,\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 : \u2115` is `\u2115` if `n = 0` and `fin n` otherwise-/\ndef index_type (n : \u2115) : Type :=\nnat.cases_on n \u2115 (\u03bb k, fin $ k + 1)\n\n@[simp] lemma index_type_zero : index_type 0 = \u2115 := rfl\n\n@[simp] lemma index_type_succ (n : \u2115) : index_type (n + 1) = fin (n + 1) := rfl\n\n@[simp] lemma index_type_of_zero_lt {n : \u2115} (h : 0 < n) : index_type n = fin n :=\nby rw [\u2190 nat.succ_pred_eq_of_pos h, index_type_succ]\n\ninstance (n : \u2115) : linear_order (index_type n) :=\nnat.cases_on n nat.linear_order (\u03bb _, fin.linear_order)\n\ninstance (n : \u2115) : indexing (index_type n) :=\nnat.cases_on n nat.indexing (\u03bb _, fin.indexing _)\n\ninstance (n : \u2115) : locally_finite_order (index_type n) :=\nnat.cases_on n nat.locally_finite_order (\u03bb _, fin.locally_finite_order _)\n\ninstance (n : \u2115) : order_bot (index_type n) :=\nnat.cases_on n nat.order_bot (\u03bb k, show order_bot $ fin (k + 1), by apply_instance)\n\ninstance (N : \u2115) : has_zero (index_type N) := \u27e8indexing.from_nat 0\u27e9\n\nlemma set.countable_iff_exists_nonempty_index_type_equiv\n  {\u03b1 : Type*} {s : set \u03b1} (hne : s.nonempty) :\n  s.countable \u2194 \u2203 n, nonempty (index_type n \u2243 s) :=\nbegin\n  -- Huge golfing opportunity.\n  cases @set.finite_or_infinite _ s,\n  { refine \u27e8\u03bb hh, \u27e8h.to_finset.card, _\u27e9, \u03bb _, h.countable\u27e9,\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\u2081 := fintype.equiv_fin h.to_finset,\n    rw [fintype.card_coe, h.coe_sort_to_finset] at e\u2081,\n    exact \u27e8e\u2081.symm\u27e9, },\n  { refine \u27e8\u03bb hh, \u27e80, _\u27e9, _\u27e9,\n    { simp only [index_type_zero],\n      obtain \u27e8_i\u27e9 := set.countable_infinite_iff_nonempty_denumerable.mp \u27e8hh, h\u27e9,\n      haveI := _i,\n      exact \u27e8(denumerable.eqv s).symm\u27e9, },\n    { rintros \u27e8n, \u27e8fn\u27e9\u27e9,\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 \u27e8fintype.of_equiv (fin n) fn\u27e9 h, },\n      simp only [hn, index_type_zero] at fn,\n      exact set.countable_iff_exists_injective.mpr \u27e8fn.symm, fn.symm.injective\u27e9, }, },\nend\n\nopen filter\n\nlemma index_type.lt_or_eq_succ (N n : \u2115) :\n  (n : index_type N) < (n+1 : \u2115) \u2228 (n : index_type N) = (n+1 : \u2115) :=\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 : \u2115} (hn : (n : index_type N) < (n+1 : \u2115)) (j : index_type N) :\n  j \u2264 n \u2194 j < (n + 1 : \u2115) :=\nbegin\n  cases N, { exact nat.lt_succ_iff.symm, },\n  refine \u27e8\u03bb h, lt_of_le_of_lt h hn, \u03bb h, _\u27e9,\n  clear hn,\n  obtain \u27e8j, hj\u27e9 := j,\n  change _ \u2264 indexing.from_nat n,\n  change _ < indexing.from_nat (n + 1) at h,\n  unfold indexing.from_nat at \u22a2 h,\n  rcases lt_trichotomy N n with hNn | rfl | hNn,\n  { replace hNn : \u00ac (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 : \u2115} (j : index_type N) : \u00ac (j < 0) :=\nnat.cases_on N nat.not_lt_zero (\u03bb 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\u2080-/\ntheorem is_complete'_ACF\u2080 : is_complete' ACF\u2080 :=\nbegin\n  sorry\nend\n\n/-- Lefschetz part 1. Being true in a model of ACF\u2080 implies being true for any model of ACF\u2080-/\ntheorem is_complete''_ACF\u2080 : is_complete'' ACF\u2080 :=\nis_complete''_to_is_complete' (is_complete'_ACF\u2080)\n\n/-- Lefschetz part 3. Any sentence or its negation can be deduced in ACF\u209a-/\ntheorem is_complete'_ACF\u209a {p : \u2115} (hp : nat.prime p) : is_complete' (ACF\u209a hp) :=\nbegin\n  sorry\nend\n\n/-- Lefcschetz part 3. Being true in a model of ACF\u209a implies being true for any model of ACF\u209a-/\ntheorem is_complete''_ACF\u209a {p : \u2115} (hp : nat.prime p) :\n  is_complete'' (ACF\u209a hp) :=\nis_complete''_to_is_complete' (is_complete'_ACF\u209a hp)\n\n/-- Lefchetz part 2. A sentence holds for ACF\u2080 if and only if it holds for ACF\u209a for large enough p -/\ntheorem characteristic_change_left (\u03d5 : sentence ring_signature) :\nACF\u2080 \u22a8 \u03d5 \u2192 \u2203 (n : \u2115), \u2200 {p : \u2115} (hp : nat.prime p), n < p \u2192 ACF\u209a hp \u22a8 \u03d5 :=\nbegin\n  rw compactness,\n  intro hsatis,\n  obtain \u27e8 fs , hsatis , hsub \u27e9 := hsatis,\n  classical,\n  obtain \u27e8 fsACF , fsrange , hunion, hACF , hrange \u27e9 :=\n    finset.subset_union_elim hsub,\n  set fsnat : finset \u2115 := 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 \u22a8 ACF) := \u27e8 (models_ACF\u209a_iff.mp hmodel).2 \u27e9,\n  have hchar := @models_ACF\u209a_char _ _ _inst_1 _ hmodel,\n  apply hsatis hMx,\n  rw [\u2190 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\u209a,\n  },\n  {\n    have hSTS :(\u2200 n : \u2115, n \u2208 fsnat \u2192 M \u22a8 plus_one_ne_zero n) \u2192 M \u22a8 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 [\u2190 hfsnat, finset.filter_mem_set_of_subset_set (\u03bb x hx, (hrange hx).1)]\n        at hrw0,\n      rw \u2190 hrw0,\n      simp only [all_realize_sentence],\n      intros hrealize \u03d5 h\u03d5,\n      simp only [set.mem_preimage, set.mem_image,\n        finset.coe_preimage, finset.mem_coe, finset.coe_image] at h\u03d5,\n      obtain \u27e8 n , hn , h\u03d5 \u27e9 := h\u03d5,\n      rw [\u2190 h\u03d5],\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      \u2200 x : \u2115, x.succ < p \u2192 (x.succ : M) \u2260 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 \u2190 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\u2080 if and only if for all large p it holds for all ACF\u209a-/\ntheorem characteristic_change (\u03d5 : sentence ring_signature) :\nACF\u2080 \u22a8 \u03d5 \u2194 (\u2203 (n : \u2115), \u2200 {p : \u2115} (hp : nat.prime p), n < p \u2192 ACF\u209a hp \u22a8 \u03d5) :=\nbegin\n  split,\n  { apply characteristic_change_left },\n  {\n    intro hn,\n    cases is_complete'_ACF\u2080 \u03d5 with hsatis hsatis,\n    { exact hsatis },\n    {\n      have hm := characteristic_change_left (\u223c \u03d5) hsatis,\n      cases hn with n hn,\n      cases hm with m hm,\n      obtain \u27e8 p , hle , hp \u27e9 := 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\u209a hp,\n      specialize @hn p hp hnp _ \u27e8 0 \u27e9 hS,\n      specialize @hm p hp hmp _ \u27e8 0 \u27e9 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 {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\n  {E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E]\n  {H : Type*} [topological_space H]\n  {M : Type*} [topological_space M] (f : local_homeomorph M H) (I : model_with_corners \ud835\udd5c E H)\n\nend model_with_corners\n\n\n-- todo: make `vector_bundle_core.total_space` protected!\nnamespace vector_bundle_core\n\nvariables {\ud835\udd5c B F : Type*} [nontrivially_normed_field \ud835\udd5c]\n  [normed_add_comm_group F] [normed_space \ud835\udd5c F] [topological_space B]\n  {\u03b9 : Type*} (Z : vector_bundle_core \ud835\udd5c B F \u03b9) {i j : \u03b9}\n\n@[simp, mfld_simps] lemma local_triv_continuous_linear_map_at {b : B} (hb : b \u2208 Z.base_set i) :\n  (Z.local_triv i).continuous_linear_map_at \ud835\udd5c 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 \ud835\udd5c, (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\u2080 b : B}\n  (hb : b \u2208 (trivialization_at F Z.fiber b\u2080).base_set) :\n  (trivialization_at F Z.fiber b\u2080).continuous_linear_map_at \ud835\udd5c b =\n  Z.coord_change (Z.index_at b) (Z.index_at b\u2080) b :=\nZ.local_triv_continuous_linear_map_at hb\n\n@[simp, mfld_simps] lemma local_triv_symmL {b : B} (hb : b \u2208 Z.base_set i) :\n  (Z.local_triv i).symmL \ud835\udd5c b = Z.coord_change i (Z.index_at b) b :=\nby { ext1 v, rw [(Z.local_triv i).symmL_apply \ud835\udd5c, (Z.local_triv i).symm_apply], exacts [rfl, hb] }\n\n@[simp, mfld_simps] lemma trivialization_at_symmL {b\u2080 b : B}\n  (hb : b \u2208 (trivialization_at F Z.fiber b\u2080).base_set) :\n  (trivialization_at F Z.fiber b\u2080).symmL \ud835\udd5c b = Z.coord_change (Z.index_at b\u2080) (Z.index_at b) b :=\nZ.local_triv_symmL hb\n\n@[simp, mfld_simps] lemma trivialization_at_coord_change_eq {b\u2080 b\u2081 b : B}\n  (hb : b \u2208 (trivialization_at F Z.fiber b\u2080).base_set \u2229 (trivialization_at F Z.fiber b\u2081).base_set)\n  (v : F) :\n  (trivialization_at F Z.fiber b\u2080).coord_changeL \ud835\udd5c (trivialization_at F Z.fiber b\u2081) b v =\n  Z.coord_change (Z.index_at b\u2080) (Z.index_at b\u2081) b v :=\nZ.local_triv_coord_change_eq _ _ hb v\n\nend vector_bundle_core\n\nnamespace tangent_bundle\n\nvariables {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\n{E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E]\n{H : Type*} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c 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 \ud835\udcd8(\ud835\udd5c, 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 {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\n  {E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E]\n  {E' : Type*} [normed_add_comm_group E'] [normed_space \ud835\udd5c E']\n  {F : Type*} [normed_add_comm_group F] [normed_space \ud835\udd5c F]\n  {F' : Type*} [normed_add_comm_group F'] [normed_space \ud835\udd5c F']\n  {H : Type*} [topological_space H] {I : model_with_corners \ud835\udd5c E H}\n  {H' : Type*} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'}\n  {G : Type*} [topological_space G] {J : model_with_corners \ud835\udd5c F G}\n  {G' : Type*} [topological_space G'] {J' : model_with_corners \ud835\udd5c 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 \ud835\udd5c F'']\nvariables {f : M \u2192 M'} {m n : \u2115\u221e} {s : set M} {x x' : M}\n-- declare some additional normed spaces, used for fibers of vector bundles\n{F\u2081 : Type*} [normed_add_comm_group F\u2081] [normed_space \ud835\udd5c F\u2081]\n{F\u2082 : Type*} [normed_add_comm_group F\u2082] [normed_space \ud835\udd5c F\u2082]\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 \ud835\udd5c (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 \ud835\udd5c (ext_chart_at I x' \u2218 (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 \u2192 M' \u00d7 N'} :\n  cont_mdiff I (I'.prod J') n f \u2194\n  cont_mdiff I I' n (\u03bb x, (f x).1) \u2227 cont_mdiff I J' n (\u03bb x, (f x).2) :=\n\u27e8\u03bb h, \u27e8h.fst, h.snd\u27e9, \u03bb h, by { convert h.1.prod_mk h.2, ext x; refl }\u27e9\n\nlemma cont_mdiff_at_prod {f : M \u2192 M' \u00d7 N'} {x : M} :\n  cont_mdiff_at I (I'.prod J') n f x \u2194\n  cont_mdiff_at I I' n (\u03bb x, (f x).1) x \u2227 cont_mdiff_at I J' n (\u03bb x, (f x).2) x :=\n\u27e8\u03bb h, \u27e8h.fst, h.snd\u27e9, \u03bb h, by { convert h.1.prod_mk h.2, ext x; refl }\u27e9\n\nlemma model_with_corners.fderiv_within_comp_symm (x : H) :\n  fderiv_within \ud835\udd5c (I \u2218 I.symm) (range I) (I x) = continuous_linear_map.id \ud835\udd5c E :=\nbegin\n  have : fderiv_within \ud835\udd5c (I \u2218 I.symm) (range I) (I x) = fderiv_within \ud835\udd5c id (range I) (I x),\n  { refine fderiv_within_congr I.unique_diff_at_image (\u03bb 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 \ud835\udd5c 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 \u2208 atlas H M) (h' : e' \u2208 atlas H M) :\n  cont_diff_on \ud835\udd5c \u22a4 (I \u2218 (e.symm \u226b\u2095 e') \u2218 I.symm) (I.symm \u207b\u00b9' (e.symm \u226b\u2095 e').source \u2229 range I) :=\n(has_groupoid.compatible (cont_diff_groupoid \u22a4 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 \u2192L[\ud835\udd5c] 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 \u2192 M'} (h : f = f') :\n  @eq (E \u2192L[\ud835\udd5c] E') (mfderiv I I' f x) (mfderiv I I' f' x) :=\nby subst h\n\n/-- The derivative of the projection `M \u00d7 M' \u2192 M` is the projection `TM \u00d7 TM' \u2192 TM` -/\nlemma mfderiv_fst (x : M \u00d7 M') :\n  mfderiv (I.prod I') I prod.fst x = continuous_linear_map.fst \ud835\udd5c 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 \ud835\udd5c (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      (\u03bb 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 \u00d7 M' \u2192 M'` is the projection `TM \u00d7 TM' \u2192 TM'` -/\nlemma mfderiv_snd (x : M \u00d7 M') :\n  mfderiv (I.prod I') I' prod.snd x = continuous_linear_map.snd \ud835\udd5c 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 \ud835\udd5c (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      (\u03bb 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 \u2192 M} {g : N \u2192 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') (\u03bb x, (f x, g x)) x :=\n\u27e8hf.1.prod hg.1, hf.2.prod hg.2\u27e9\n\n\n-- todo: rename differentiable_at.fderiv_within_prod -> differentiable_within_at.fderiv_within_prod\nlemma mdifferentiable_at.mfderiv_prod {f : N \u2192 M} {g : N \u2192 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') (\u03bb 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\u2080 : M} {y\u2080 : M'} :\n  mfderiv I (I.prod I') (\u03bb x, (x, y\u2080)) x\u2080 = continuous_linear_map.inl \ud835\udd5c 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\u2080 : M} {y\u2080 : M'} :\n  mfderiv I' (I.prod I') (\u03bb y, (x\u2080, y)) y\u2080 = continuous_linear_map.inr \ud835\udd5c 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 \u00d7 M \u2192 M'} {p : N \u00d7 M}\n  (hf : mdifferentiable_at (J.prod I) I' f p) :\n  mfderiv (J.prod I) I' f p =\n  (show F \u00d7 E \u2192L[\ud835\udd5c] E', from mfderiv (J.prod I) I' (\u03bb (z : N \u00d7 M), f (z.1, p.2)) p +\n  mfderiv (J.prod I) I' (\u03bb (z : N \u00d7 M), f (p.1, z.2)) p) :=\nbegin\n  dsimp only,\n  rw [\u2190 @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    \u2190 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 \u2194 cont_mdiff_within_at I I' n f s x :=\n-- begin\n--   sorry\n-- end\n\n-- alias cont_mdiff_within_at_insert \u2194 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 \u2192 Type*} [topological_space (total_space Z)] [\u2200 b, topological_space (Z b)]\n  [\u2200 b, add_comm_monoid (Z b)] [\u2200 b, module \ud835\udd5c (Z b)]\n  [fiber_bundle F\u2081 Z] [vector_bundle \ud835\udd5c F\u2081 Z] [smooth_vector_bundle F\u2081 Z I]\n  {Z\u2082 : M' \u2192 Type*} [topological_space (total_space Z\u2082)] [\u2200 b, topological_space (Z\u2082 b)]\n  [\u2200 b, add_comm_monoid (Z\u2082 b)] [\u2200 b, module \ud835\udd5c (Z\u2082 b)]\n  [fiber_bundle F\u2082 Z\u2082] [vector_bundle \ud835\udd5c F\u2082 Z\u2082] [smooth_vector_bundle F\u2082 Z\u2082 I']\n\nvariables (I I' Z Z\u2082 F\u2081 F\u2082)\n\n/-- When `\u03d5` is a continuous linear map that changes vectors in charts around `x` to vectors\n  in charts around `y`, `in_coordinates' Z Z\u2082 x\u2080 x y\u2080 y \u03d5` is a coordinate change of this continuous\n  linear map that makes sense from charts around `x\u2080` to charts around `y\u2080`\n  by composing it with appropriate coordinate changes given by smooth vector bundles `Z` and `Z\u2082`.\n-/\ndef in_coordinates' (x\u2080 x : M) (y\u2080 y : M') (\u03d5 : Z x \u2192L[\ud835\udd5c] Z\u2082 y) : F\u2081 \u2192L[\ud835\udd5c] F\u2082 :=\n(trivialization_at F\u2082 Z\u2082 y\u2080).continuous_linear_map_at \ud835\udd5c y \u2218L \u03d5 \u2218L\n(trivialization_at F\u2081 Z x\u2080).symmL \ud835\udd5c x\n\n/-- When `\u03d5 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 \u03d5 x\u2080 x` is a coordinate change of this continuous\n  linear map that makes sense from charts around `f x\u2080` to charts around `g x\u2080`\n  by composing it with appropriate coordinate changes. -/\ndef in_coordinates (f : N \u2192 M) (g : N \u2192 M')\n  (\u03d5 : \u03a0 x : N, tangent_space I (f x) \u2192L[\ud835\udd5c] tangent_space I' (g x)) : N \u2192 N \u2192 E \u2192L[\ud835\udd5c] E' :=\n\u03bb x\u2080 x, in_coordinates' E E' (tangent_space I) (tangent_space I') (f x\u2080) (f x) (g x\u2080) (g x) (\u03d5 x)\n\nvariables {F\u2081 F\u2082}\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' {\u03b9\u2081 \u03b9\u2082} (Z\u2081 : vector_bundle_core \ud835\udd5c M F\u2081 \u03b9\u2081)\n  (Z\u2082 : vector_bundle_core \ud835\udd5c M' F\u2082 \u03b9\u2082) (x\u2080 x : M) (y\u2080 y : M') (\u03d5 : F\u2081 \u2192L[\ud835\udd5c] F\u2082) : F\u2081 \u2192L[\ud835\udd5c] F\u2082 :=\nZ\u2082.coord_change (Z\u2082.index_at y) (Z\u2082.index_at y\u2080) y \u2218L \u03d5 \u2218L\n  Z\u2081.coord_change (Z\u2081.index_at x\u2080) (Z\u2081.index_at x) x\n\ndef in_coordinates_core (f : N \u2192 M) (g : N \u2192 M') (\u03d5 : N \u2192 E \u2192L[\ud835\udd5c] E') :\n  N \u2192 N \u2192 E \u2192L[\ud835\udd5c] E' :=\n\u03bb x\u2080 x, in_coordinates_core' (tangent_bundle_core I M) (tangent_bundle_core I' M')\n  (f x\u2080) (f x) (g x\u2080) (g x) (\u03d5 x)\n\n/-- rewrite `in_coordinates'` using continuous linear equivalences. -/\nlemma in_coordinates'_eq (x\u2080 x : M) (y\u2080 y : M') (\u03d5 : Z x \u2192L[\ud835\udd5c] Z\u2082 y)\n  (hx : x \u2208 (trivialization_at F\u2081 Z x\u2080).base_set)\n  (hy : y \u2208 (trivialization_at F\u2082 Z\u2082 y\u2080).base_set) :\n  in_coordinates' F\u2081 F\u2082 Z Z\u2082 x\u2080 x y\u2080 y \u03d5 =\n  ((trivialization_at F\u2082 Z\u2082 y\u2080).continuous_linear_equiv_at \ud835\udd5c y hy : Z\u2082 y \u2192L[\ud835\udd5c] F\u2082) \u2218L \u03d5 \u2218L\n  (((trivialization_at F\u2081 Z x\u2080).continuous_linear_equiv_at \ud835\udd5c x hx).symm : F\u2081 \u2192L[\ud835\udd5c] 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\u2080 x : H) (y\u2080 y : H') (\u03d5 : E \u2192L[\ud835\udd5c] E') :\n    in_coordinates_core' (tangent_bundle_core I H) (tangent_bundle_core I' H') x\u2080 x y\u2080 y \u03d5 = \u03d5 :=\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 \u2192 H) (g : N \u2192 H') (\u03d5 : N \u2192 E \u2192L[\ud835\udd5c] E') (x\u2080 : N) :\n    in_coordinates_core I I' f g \u03d5 x\u2080 = \u03d5 :=\nby simp_rw [in_coordinates_core, in_coordinates_core'_tangent_bundle_core_model_space]\n\nlemma in_coordinates_core'_eq {\u03b9\u2081 \u03b9\u2082} (Z\u2081 : vector_bundle_core \ud835\udd5c M F\u2081 \u03b9\u2081)\n  (Z\u2082 : vector_bundle_core \ud835\udd5c M' F\u2082 \u03b9\u2082)\n  {x\u2080 x : M} {y\u2080 y : M'} (\u03d5 : F\u2081 \u2192L[\ud835\udd5c] F\u2082)\n  (hx : x \u2208 Z\u2081.base_set (Z\u2081.index_at x\u2080))\n  (hy : y \u2208 Z\u2082.base_set (Z\u2082.index_at y\u2080)) :\n    in_coordinates' F\u2081 F\u2082 Z\u2081.fiber Z\u2082.fiber x\u2080 x y\u2080 y \u03d5 =\n    in_coordinates_core' Z\u2081 Z\u2082 x\u2080 x y\u2080 y \u03d5 :=\nby simp_rw [in_coordinates', in_coordinates_core',\n    Z\u2082.trivialization_at_continuous_linear_map_at hy, Z\u2081.trivialization_at_symmL hx]\n\nvariables {I I'}\n\n-- lemma cont_mdiff_within_at.mfderiv {s : set N} {x : N} (f : N \u2192 M \u2192 M') (g : N \u2192 M)\n--   (hf : cont_mdiff_within_at (J.prod I) I' n (function.uncurry f) (prod.fst \u207b\u00b9' s) (x, g x))\n--   (hg : cont_mdiff_within_at J I m g s x) (hmn : m + 1 \u2264 n) (hxs : x \u2208 s) :\n--   -- todo: remove x \u2208 s hypothesis by working with `insert x s` everywhere.\n--   cont_mdiff_within_at J \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n--     (in_coordinates_core I I' g (\u03bb x, f x (g x)) (\u03bb x', mfderiv I I' (f x') (g x')) x) s x :=\n-- begin\n--   have h4f : continuous_within_at (\u03bb 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 : \u2200\u1da0 x\u2082 in \ud835\udcdd[s] x, cont_mdiff_at I I' 1 (f x\u2082) (g x\u2082),\n--   sorry,\n--   -- { refine ((continuous_within_at_id.prod hg.continuous_within_at).tendsto.eventually h3f).mono (\u03bb 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 \ud835\udd5c m (\u03bb x', fderiv_within \ud835\udd5c\n--     (ext_chart_at I' (f x (g x)) \u2218 f ((ext_chart_at J x).symm x') \u2218 (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 \u207b\u00b9' s \u2229 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 \u22a2,\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 \u207b\u00b9' s \u2229 (ext_chart_at J x).target \u2229\n--         (ext_chart_at J x).symm \u207b\u00b9' (g \u207b\u00b9' (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 \u27e8\u27e8hxs, local_equiv.maps_to _ (mem_ext_chart_source J x)\u27e9,\n--         mem_ext_chart_source I (g x)\u27e9 },\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 (\u03bb 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 (\u03bb a, chart_at H (g x) $ g $ (chart_at G x).symm $ J.symm a) I },\n--   have : cont_mdiff_within_at J \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n--     (\u03bb x', fderiv_within \ud835\udd5c (ext_chart_at I' (f x (g x)) \u2218 f x' \u2218 (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 \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n--     (\u03bb x', fderiv_within \ud835\udd5c (ext_chart_at I' (f x (g x)) \u2218 (ext_chart_at I' (f x' (g x'))).symm \u2218\n--       written_in_ext_chart_at I I' (g x') (f x') \u2218 ext_chart_at I (g x') \u2218\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\u2082 hx\u2082 h2x\u2082,\n--     have : \u2200 x' \u2208 (ext_chart_at I (g x)).symm \u207b\u00b9' (ext_chart_at I (g x\u2082)).source \u2229\n--         (ext_chart_at I (g x)).symm \u207b\u00b9' (f x\u2082 \u207b\u00b9' (ext_chart_at I' (f x\u2082 (g x\u2082))).source),\n--       (ext_chart_at I' (f x (g x)) \u2218 (ext_chart_at I' (f x\u2082 (g x\u2082))).symm \u2218\n--       written_in_ext_chart_at I I' (g x\u2082) (f x\u2082) \u2218 ext_chart_at I (g x\u2082) \u2218\n--       (ext_chart_at I (g x)).symm) x' =\n--       ext_chart_at I' (f x (g x)) (f x\u2082 ((ext_chart_at I (g x)).symm x')),\n--     { rintro x' \u27e8hx', h2x'\u27e9,\n--       simp_rw [written_in_ext_chart_at, function.comp_apply],\n--       rw [(ext_chart_at I (g x\u2082)).left_inv hx', (ext_chart_at I' (f x\u2082 (g x\u2082))).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\u2082 (ext_chart_at_source_mem_nhds I (g x\u2082)) },\n--     refine ext_chart_at_preimage_mem_nhds' _ _ hx\u2082 _,\n--     exact h2x\u2082.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 \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n--     (\u03bb x', (fderiv_within \ud835\udd5c (ext_chart_at I' (f x (g x)) \u2218 (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 \ud835\udd5c (ext_chart_at I (g x') \u2218\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\u2082 hx\u2082 h2x\u2082 h3x\u2082,\n--   symmetry,\n--   rw [(h2x\u2082.mdifferentiable_at le_rfl).mfderiv],\n--   have hI := (cont_diff_within_at_ext_coord_change I (g x\u2082) (g x) $\n--     local_equiv.mem_symm_trans_source _ hx\u2082 $ mem_ext_chart_source I (g x\u2082))\n--     .differentiable_within_at le_top,\n--   have hI' := (cont_diff_within_at_ext_coord_change I' (f x (g x)) (f x\u2082 (g x\u2082)) $\n--     local_equiv.mem_symm_trans_source _\n--     (mem_ext_chart_source I' (f x\u2082 (g x\u2082))) h3x\u2082).differentiable_within_at le_top,\n--   have h3f := (h2x\u2082.mdifferentiable_at le_rfl).2,\n--   refine fderiv_within.comp\u2083 _ hI' h3f hI _ _ _ _ (I.unique_diff _ $ mem_range_self _),\n--   { exact \u03bb x _, mem_range_self _ },\n--   { exact \u03bb x _, mem_range_self _ },\n--   { simp_rw [written_in_ext_chart_at, function.comp_apply,\n--       (ext_chart_at I (g x\u2082)).left_inv (mem_ext_chart_source I (g x\u2082))] },\n--   { simp_rw [function.comp_apply, (ext_chart_at I (g x)).left_inv hx\u2082] }\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 \u2192 M \u2192 M') (g : N \u2192 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 \u2264 n) :\n  cont_mdiff_at J \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n    (in_coordinates_core I I' g (\u03bb x, f x (g x)) (\u03bb x', mfderiv I I' (f x') (g x')) x) x :=\nbegin\n  have h4f : continuous_at (\u03bb 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 : \u2200\u1da0 x\u2082 in \ud835\udcdd x, cont_mdiff_at I I' 1 (f x\u2082) (g x\u2082),\n  { refine ((continuous_at_id.prod hg.continuous_at).tendsto.eventually h3f).mono (\u03bb 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 \ud835\udd5c m (\u03bb x', fderiv_within \ud835\udd5c\n    (ext_chart_at I' (f x (g x)) \u2218 f ((ext_chart_at J x).symm x') \u2218 (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 \u22a2,\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 \u2229\n      (\u03bb x', (ext_chart_at J x).symm x') \u207b\u00b9' (g \u207b\u00b9' (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 \u27e8local_equiv.maps_to _ (mem_ext_chart_source J x), mem_ext_chart_source I (g x)\u27e9 },\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 (\u03bb 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 (\u03bb a, chart_at H (g x) $ g $ (chart_at G x).symm $ J.symm a) I },\n  have : cont_mdiff_at J \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n    (\u03bb x', fderiv_within \ud835\udd5c (ext_chart_at I' (f x (g x)) \u2218 f x' \u2218 (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 \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n    (\u03bb x', fderiv_within \ud835\udd5c (ext_chart_at I' (f x (g x)) \u2218 (ext_chart_at I' (f x' (g x'))).symm \u2218\n      written_in_ext_chart_at I I' (g x') (f x') \u2218 ext_chart_at I (g x') \u2218\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\u2082 hx\u2082 h2x\u2082,\n    have : \u2200 x' \u2208 (ext_chart_at I (g x)).symm \u207b\u00b9' (ext_chart_at I (g x\u2082)).source \u2229\n        (ext_chart_at I (g x)).symm \u207b\u00b9' (f x\u2082 \u207b\u00b9' (ext_chart_at I' (f x\u2082 (g x\u2082))).source),\n      (ext_chart_at I' (f x (g x)) \u2218 (ext_chart_at I' (f x\u2082 (g x\u2082))).symm \u2218\n      written_in_ext_chart_at I I' (g x\u2082) (f x\u2082) \u2218 ext_chart_at I (g x\u2082) \u2218\n      (ext_chart_at I (g x)).symm) x' =\n      ext_chart_at I' (f x (g x)) (f x\u2082 ((ext_chart_at I (g x)).symm x')),\n    { rintro x' \u27e8hx', h2x'\u27e9,\n      simp_rw [written_in_ext_chart_at, function.comp_apply],\n      rw [(ext_chart_at I (g x\u2082)).left_inv hx', (ext_chart_at I' (f x\u2082 (g x\u2082))).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\u2082 (ext_chart_at_source_mem_nhds I (g x\u2082)) },\n    refine ext_chart_at_preimage_mem_nhds' _ _ hx\u2082 _,\n    exact (h2x\u2082.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 \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n    (\u03bb x', (fderiv_within \ud835\udd5c (ext_chart_at I' (f x (g x)) \u2218 (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 \ud835\udd5c (ext_chart_at I (g x') \u2218\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\u2082 hx\u2082 h2x\u2082 h3x\u2082,\n  symmetry,\n  rw [(h2x\u2082.mdifferentiable_at le_rfl).mfderiv],\n  have hI := (cont_diff_within_at_ext_coord_change I (g x\u2082) (g x) $\n    local_equiv.mem_symm_trans_source _ hx\u2082 $ mem_ext_chart_source I (g x\u2082))\n    .differentiable_within_at le_top,\n  have hI' := (cont_diff_within_at_ext_coord_change I' (f x (g x)) (f x\u2082 (g x\u2082)) $\n    local_equiv.mem_symm_trans_source _\n    (mem_ext_chart_source I' (f x\u2082 (g x\u2082))) h3x\u2082).differentiable_within_at le_top,\n  have h3f := (h2x\u2082.mdifferentiable_at le_rfl).2,\n  refine fderiv_within.comp\u2083 _ hI' h3f hI _ _ _ _ (I.unique_diff _ $ mem_range_self _),\n  { exact \u03bb x _, mem_range_self _ },\n  { exact \u03bb x _, mem_range_self _ },\n  { simp_rw [written_in_ext_chart_at, function.comp_apply,\n      (ext_chart_at I (g x\u2082)).left_inv (mem_ext_chart_source I (g x\u2082))] },\n  { simp_rw [function.comp_apply, (ext_chart_at I (g x)).left_inv hx\u2082] }\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 \u2192 M \u2192 M')\n  (hf : cont_mdiff_at (I.prod I) I' n (function.uncurry f) (x, x)) (hmn : m + 1 \u2264 n) :\n  cont_mdiff_at I \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] E') m\n    (in_coordinates_core I I' id (\u03bb x, f x x) (\u03bb 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 \u2192 M'}\n  (hf : cont_mdiff_at I I' n f x) (hmn : m + 1 \u2264 n) :\n  cont_mdiff_at I \ud835\udcd8(\ud835\udd5c, E \u2192L[\ud835\udd5c] 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 (\u03bb x : M \u00d7 M, f x.2) (x, x) :=\n  cont_mdiff_at.comp (x, x) hf cont_mdiff_at_snd,\n  apply cont_mdiff_at.mfderiv'' (\u03bb x, f) this hmn\n  -- apply cont_mdiff_at.mfderiv''' (\u03bb x, f) id this cont_mdiff_at_id hmn\nend\n\ninstance has_smooth_add_self : has_smooth_add \ud835\udcd8(\ud835\udd5c, F) F :=\n\u27e8by { convert cont_diff_add.cont_mdiff, exact model_with_corners_self_prod.symm,\n  exact charted_space_self_prod }\u27e9\n\nend smooth_manifold_with_corners\n\nsection maps\n\nvariables {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\n{E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E]\n{E' : Type*} [normed_add_comm_group E'] [normed_space \ud835\udd5c E']\n{F : Type*} [normed_add_comm_group F] [normed_space \ud835\udd5c 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 \ud835\udd5c E H} {I' : model_with_corners \ud835\udd5c E' H'}\n{J : model_with_corners \ud835\udd5c F G} {J' : model_with_corners \ud835\udd5c 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 : \u2115\u221e}\n(f : C^\u221e\u27eeI, M; J, N\u27ef)\n\nnamespace cont_mdiff_map\n\n/-- The first projection of a product, as a smooth map. -/\ndef fst : C^n\u27eeI.prod I', M \u00d7 M'; I, M\u27ef := \u27e8prod.fst, cont_mdiff_fst\u27e9\n\n/-- The second projection of a product, as a smooth map. -/\ndef snd : C^n\u27eeI.prod I', M \u00d7 M'; I', M'\u27ef := \u27e8prod.snd, cont_mdiff_snd\u27e9\n\n/-- Given two smooth maps `f` and `g`, this is the smooth map `(x, y) \u21a6 (f x, g y)`. -/\ndef prod_mk (f : C^n\u27eeJ, N; I, M\u27ef) (g : C^n\u27eeJ, N; I', M'\u27ef) : C^n\u27eeJ, N; I.prod I', M \u00d7 M'\u27ef :=\n\u27e8\u03bb x, (f x, g x), f.2.prod_mk g.2\u27e9\n\nend cont_mdiff_map\n\nnamespace diffeomorph\n\ninstance : continuous_map_class (M \u2243\u2098\u27eeI, J\u27ef N) M N :=\n{ coe := coe_fn,\n  coe_injective' := coe_fn_injective,\n  map_continuous := \u03bb f, f.continuous }\n\nend diffeomorph\n\nend maps\n\nsection\nvariables {E : Type*} [normed_add_comm_group E] [normed_space \u211d E]\n  {H : Type*} [topological_space H] (I : model_with_corners \u211d 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 \u211d G] [finite_dimensional \u211d G]\n  {HG : Type*} [topological_space HG] (IG : model_with_corners \u211d 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} (\u03c6 : germ (\ud835\udcdd x) N) (n : \u2115\u221e) : Prop :=\nquotient.lift_on' \u03c6 (\u03bb f, cont_mdiff_at I IG n f x) (\u03bb f g h, propext begin\n  split,\n  all_goals { refine \u03bb 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 := \u27e8Fin.ofNat n\u27e9\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 := \u27e8a.val + b.val\u27e9\n@[extern c inline \"#1 - #2\"]\ndef UInt8.sub (a b : UInt8) : UInt8 := \u27e8a.val - b.val\u27e9\n@[extern c inline \"#1 * #2\"]\ndef UInt8.mul (a b : UInt8) : UInt8 := \u27e8a.val * b.val\u27e9\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef UInt8.div (a b : UInt8) : UInt8 := \u27e8a.val / b.val\u27e9\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef UInt8.mod (a b : UInt8) : UInt8 := \u27e8a.val % b.val\u27e9\n@[extern \"lean_uint8_modn\"]\ndef UInt8.modn (a : UInt8) (n : @& Nat) : UInt8 := \u27e8a.val % n\u27e9\n@[extern c inline \"#1 & #2\"]\ndef UInt8.land (a b : UInt8) : UInt8 := \u27e8Fin.land a.val b.val\u27e9\n@[extern c inline \"#1 | #2\"]\ndef UInt8.lor (a b : UInt8) : UInt8 := \u27e8Fin.lor a.val b.val\u27e9\n@[extern c inline \"#1 ^ #2\"]\ndef UInt8.xor (a b : UInt8) : UInt8 := \u27e8Fin.xor a.val b.val\u27e9\n@[extern c inline \"#1 << #2 % 8\"]\ndef UInt8.shiftLeft (a b : UInt8) : UInt8 := \u27e8a.val <<< (modn b 8).val\u27e9\n@[extern c inline \"#1 >> #2 % 8\"]\ndef UInt8.shiftRight (a b : UInt8) : UInt8 := \u27e8a.val >>> (modn b 8).val\u27e9\ndef UInt8.lt (a b : UInt8) : Prop := a.val < b.val\ndef UInt8.le (a b : UInt8) : Prop := a.val \u2264 b.val\n\ninstance : OfNat UInt8 n   := \u27e8UInt8.ofNat n\u27e9\ninstance : Add UInt8       := \u27e8UInt8.add\u27e9\ninstance : Sub UInt8       := \u27e8UInt8.sub\u27e9\ninstance : Mul UInt8       := \u27e8UInt8.mul\u27e9\ninstance : Mod UInt8       := \u27e8UInt8.mod\u27e9\ninstance : HMod UInt8 Nat UInt8 := \u27e8UInt8.modn\u27e9\ninstance : Div UInt8       := \u27e8UInt8.div\u27e9\ninstance : LT UInt8        := \u27e8UInt8.lt\u27e9\ninstance : LE UInt8        := \u27e8UInt8.le\u27e9\n\n@[extern c inline \"~ #1\"]\ndef UInt8.complement (a:UInt8) : UInt8 := 0-(a+1)\n\ninstance : Complement UInt8 := \u27e8UInt8.complement\u27e9\ninstance : AndOp UInt8     := \u27e8UInt8.land\u27e9\ninstance : OrOp UInt8      := \u27e8UInt8.lor\u27e9\ninstance : Xor UInt8       := \u27e8UInt8.xor\u27e9\ninstance : ShiftLeft UInt8  := \u27e8UInt8.shiftLeft\u27e9\ninstance : ShiftRight UInt8 := \u27e8UInt8.shiftRight\u27e9\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  | \u27e8n\u27e9, \u27e8m\u27e9 => 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 \u2264 b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (n <= m))\n\ninstance (a b : UInt8) : Decidable (a < b) := UInt8.decLt a b\ninstance (a b : UInt8) : Decidable (a \u2264 b) := UInt8.decLe a b\n\n@[extern \"lean_uint16_of_nat\"]\ndef UInt16.ofNat (n : @& Nat) : UInt16 := \u27e8Fin.ofNat n\u27e9\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 := \u27e8a.val + b.val\u27e9\n@[extern c inline \"#1 - #2\"]\ndef UInt16.sub (a b : UInt16) : UInt16 := \u27e8a.val - b.val\u27e9\n@[extern c inline \"#1 * #2\"]\ndef UInt16.mul (a b : UInt16) : UInt16 := \u27e8a.val * b.val\u27e9\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef UInt16.div (a b : UInt16) : UInt16 := \u27e8a.val / b.val\u27e9\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef UInt16.mod (a b : UInt16) : UInt16 := \u27e8a.val % b.val\u27e9\n@[extern \"lean_uint16_modn\"]\ndef UInt16.modn (a : UInt16) (n : @& Nat) : UInt16 := \u27e8a.val % n\u27e9\n@[extern c inline \"#1 & #2\"]\ndef UInt16.land (a b : UInt16) : UInt16 := \u27e8Fin.land a.val b.val\u27e9\n@[extern c inline \"#1 | #2\"]\ndef UInt16.lor (a b : UInt16) : UInt16 := \u27e8Fin.lor a.val b.val\u27e9\n@[extern c inline \"#1 ^ #2\"]\ndef UInt16.xor (a b : UInt16) : UInt16 := \u27e8Fin.xor a.val b.val\u27e9\n@[extern c inline \"#1 << #2 % 16\"]\ndef UInt16.shiftLeft (a b : UInt16) : UInt16 := \u27e8a.val <<< (modn b 16).val\u27e9\n@[extern c inline \"#1 >> #2 % 16\"]\ndef UInt16.shiftRight (a b : UInt16) : UInt16 := \u27e8a.val >>> (modn b 16).val\u27e9\ndef UInt16.lt (a b : UInt16) : Prop := a.val < b.val\ndef UInt16.le (a b : UInt16) : Prop := a.val \u2264 b.val\n\n\ninstance : OfNat UInt16 n   := \u27e8UInt16.ofNat n\u27e9\ninstance : Add UInt16       := \u27e8UInt16.add\u27e9\ninstance : Sub UInt16       := \u27e8UInt16.sub\u27e9\ninstance : Mul UInt16       := \u27e8UInt16.mul\u27e9\ninstance : Mod UInt16       := \u27e8UInt16.mod\u27e9\ninstance : HMod UInt16 Nat UInt16 := \u27e8UInt16.modn\u27e9\ninstance : Div UInt16       := \u27e8UInt16.div\u27e9\ninstance : LT UInt16        := \u27e8UInt16.lt\u27e9\ninstance : LE UInt16        := \u27e8UInt16.le\u27e9\n\n@[extern c inline \"~ #1\"]\ndef UInt16.complement (a:UInt16) : UInt16 := 0-(a+1)\n\ninstance : Complement UInt16 := \u27e8UInt16.complement\u27e9\ninstance : AndOp UInt16     := \u27e8UInt16.land\u27e9\ninstance : OrOp UInt16      := \u27e8UInt16.lor\u27e9\ninstance : Xor UInt16       := \u27e8UInt16.xor\u27e9\ninstance : ShiftLeft UInt16  := \u27e8UInt16.shiftLeft\u27e9\ninstance : ShiftRight UInt16 := \u27e8UInt16.shiftRight\u27e9\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  | \u27e8n\u27e9, \u27e8m\u27e9 => 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 \u2264 b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (n <= m))\n\ninstance (a b : UInt16) : Decidable (a < b) := UInt16.decLt a b\ninstance (a b : UInt16) : Decidable (a \u2264 b) := UInt16.decLe a b\n\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNat (n : @& Nat) : UInt32 := \u27e8Fin.ofNat n\u27e9\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNat' (n : Nat) (h : n < UInt32.size) : UInt32 := \u27e8\u27e8n, h\u27e9\u27e9\nabbrev Nat.toUInt32 := UInt32.ofNat\n@[extern c inline \"#1 + #2\"]\ndef UInt32.add (a b : UInt32) : UInt32 := \u27e8a.val + b.val\u27e9\n@[extern c inline \"#1 - #2\"]\ndef UInt32.sub (a b : UInt32) : UInt32 := \u27e8a.val - b.val\u27e9\n@[extern c inline \"#1 * #2\"]\ndef UInt32.mul (a b : UInt32) : UInt32 := \u27e8a.val * b.val\u27e9\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef UInt32.div (a b : UInt32) : UInt32 := \u27e8a.val / b.val\u27e9\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef UInt32.mod (a b : UInt32) : UInt32 := \u27e8a.val % b.val\u27e9\n@[extern \"lean_uint32_modn\"]\ndef UInt32.modn (a : UInt32) (n : @& Nat) : UInt32 := \u27e8a.val % n\u27e9\n@[extern c inline \"#1 & #2\"]\ndef UInt32.land (a b : UInt32) : UInt32 := \u27e8Fin.land a.val b.val\u27e9\n@[extern c inline \"#1 | #2\"]\ndef UInt32.lor (a b : UInt32) : UInt32 := \u27e8Fin.lor a.val b.val\u27e9\n@[extern c inline \"#1 ^ #2\"]\ndef UInt32.xor (a b : UInt32) : UInt32 := \u27e8Fin.xor a.val b.val\u27e9\n@[extern c inline \"#1 << #2 % 32\"]\ndef UInt32.shiftLeft (a b : UInt32) : UInt32 := \u27e8a.val <<< (modn b 32).val\u27e9\n@[extern c inline \"#1 >> #2 % 32\"]\ndef UInt32.shiftRight (a b : UInt32) : UInt32 := \u27e8a.val >>> (modn b 32).val\u27e9\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   := \u27e8UInt32.ofNat n\u27e9\ninstance : Add UInt32       := \u27e8UInt32.add\u27e9\ninstance : Sub UInt32       := \u27e8UInt32.sub\u27e9\ninstance : Mul UInt32       := \u27e8UInt32.mul\u27e9\ninstance : Mod UInt32       := \u27e8UInt32.mod\u27e9\ninstance : HMod UInt32 Nat UInt32 := \u27e8UInt32.modn\u27e9\ninstance : Div UInt32       := \u27e8UInt32.div\u27e9\n\n@[extern c inline \"~ #1\"]\ndef UInt32.complement (a:UInt32) : UInt32 := 0-(a+1)\n\ninstance : Complement UInt32 := \u27e8UInt32.complement\u27e9\ninstance : AndOp UInt32     := \u27e8UInt32.land\u27e9\ninstance : OrOp UInt32      := \u27e8UInt32.lor\u27e9\ninstance : Xor UInt32       := \u27e8UInt32.xor\u27e9\ninstance : ShiftLeft UInt32  := \u27e8UInt32.shiftLeft\u27e9\ninstance : ShiftRight UInt32 := \u27e8UInt32.shiftRight\u27e9\n\n@[extern \"lean_uint64_of_nat\"]\ndef UInt64.ofNat (n : @& Nat) : UInt64 := \u27e8Fin.ofNat n\u27e9\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 := \u27e8a.val + b.val\u27e9\n@[extern c inline \"#1 - #2\"]\ndef UInt64.sub (a b : UInt64) : UInt64 := \u27e8a.val - b.val\u27e9\n@[extern c inline \"#1 * #2\"]\ndef UInt64.mul (a b : UInt64) : UInt64 := \u27e8a.val * b.val\u27e9\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef UInt64.div (a b : UInt64) : UInt64 := \u27e8a.val / b.val\u27e9\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef UInt64.mod (a b : UInt64) : UInt64 := \u27e8a.val % b.val\u27e9\n@[extern \"lean_uint64_modn\"]\ndef UInt64.modn (a : UInt64) (n : @& Nat) : UInt64 := \u27e8a.val % n\u27e9\n@[extern c inline \"#1 & #2\"]\ndef UInt64.land (a b : UInt64) : UInt64 := \u27e8Fin.land a.val b.val\u27e9\n@[extern c inline \"#1 | #2\"]\ndef UInt64.lor (a b : UInt64) : UInt64 := \u27e8Fin.lor a.val b.val\u27e9\n@[extern c inline \"#1 ^ #2\"]\ndef UInt64.xor (a b : UInt64) : UInt64 := \u27e8Fin.xor a.val b.val\u27e9\n@[extern c inline \"#1 << #2 % 64\"]\ndef UInt64.shiftLeft (a b : UInt64) : UInt64 := \u27e8a.val <<< (modn b 64).val\u27e9\n@[extern c inline \"#1 >> #2 % 64\"]\ndef UInt64.shiftRight (a b : UInt64) : UInt64 := \u27e8a.val >>> (modn b 64).val\u27e9\ndef UInt64.lt (a b : UInt64) : Prop := a.val < b.val\ndef UInt64.le (a b : UInt64) : Prop := a.val \u2264 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   := \u27e8UInt64.ofNat n\u27e9\ninstance : Add UInt64       := \u27e8UInt64.add\u27e9\ninstance : Sub UInt64       := \u27e8UInt64.sub\u27e9\ninstance : Mul UInt64       := \u27e8UInt64.mul\u27e9\ninstance : Mod UInt64       := \u27e8UInt64.mod\u27e9\ninstance : HMod UInt64 Nat UInt64 := \u27e8UInt64.modn\u27e9\ninstance : Div UInt64       := \u27e8UInt64.div\u27e9\ninstance : LT UInt64        := \u27e8UInt64.lt\u27e9\ninstance : LE UInt64        := \u27e8UInt64.le\u27e9\n\n@[extern c inline \"~ #1\"]\ndef UInt64.complement (a:UInt64) : UInt64 := 0-(a+1)\n\ninstance : Complement UInt64 := \u27e8UInt64.complement\u27e9\ninstance : AndOp UInt64     := \u27e8UInt64.land\u27e9\ninstance : OrOp UInt64      := \u27e8UInt64.lor\u27e9\ninstance : Xor UInt64       := \u27e8UInt64.xor\u27e9\ninstance : ShiftLeft UInt64  := \u27e8UInt64.shiftLeft\u27e9\ninstance : ShiftRight UInt64 := \u27e8UInt64.shiftRight\u27e9\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  | \u27e8n\u27e9, \u27e8m\u27e9 => 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 \u2264 b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (n <= m))\n\ninstance (a b : UInt64) : Decidable (a < b) := UInt64.decLt a b\ninstance (a b : UInt64) : Decidable (a \u2264 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 := \u27e8Fin.ofNat' n usizeSzGt0\u27e9\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 := \u27e8a.val + b.val\u27e9\n@[extern c inline \"#1 - #2\"]\ndef USize.sub (a b : USize) : USize := \u27e8a.val - b.val\u27e9\n@[extern c inline \"#1 * #2\"]\ndef USize.mul (a b : USize) : USize := \u27e8a.val * b.val\u27e9\n@[extern c inline \"#2 == 0 ? 0 : #1 / #2\"]\ndef USize.div (a b : USize) : USize := \u27e8a.val / b.val\u27e9\n@[extern c inline \"#2 == 0 ? #1 : #1 % #2\"]\ndef USize.mod (a b : USize) : USize := \u27e8a.val % b.val\u27e9\n@[extern \"lean_usize_modn\"]\ndef USize.modn (a : USize) (n : @& Nat) : USize := \u27e8a.val % n\u27e9\n@[extern c inline \"#1 & #2\"]\ndef USize.land (a b : USize) : USize := \u27e8Fin.land a.val b.val\u27e9\n@[extern c inline \"#1 | #2\"]\ndef USize.lor (a b : USize) : USize := \u27e8Fin.lor a.val b.val\u27e9\n@[extern c inline \"#1 ^ #2\"]\ndef USize.xor (a b : USize) : USize := \u27e8Fin.xor a.val b.val\u27e9\n@[extern c inline \"#1 << #2 % (sizeof(size_t) * 8)\"]\ndef USize.shiftLeft (a b : USize) : USize := \u27e8a.val <<< (modn b System.Platform.numBits).val\u27e9\n@[extern c inline \"#1 >> #2 % (sizeof(size_t) * 8)\"]\ndef USize.shiftRight (a b : USize) : USize := \u27e8a.val >>> (modn b System.Platform.numBits).val\u27e9\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 \u2264 b.val\n\ninstance : OfNat USize n   := \u27e8USize.ofNat n\u27e9\ninstance : Add USize       := \u27e8USize.add\u27e9\ninstance : Sub USize       := \u27e8USize.sub\u27e9\ninstance : Mul USize       := \u27e8USize.mul\u27e9\ninstance : Mod USize       := \u27e8USize.mod\u27e9\ninstance : HMod USize Nat USize := \u27e8USize.modn\u27e9\ninstance : Div USize       := \u27e8USize.div\u27e9\ninstance : LT USize        := \u27e8USize.lt\u27e9\ninstance : LE USize        := \u27e8USize.le\u27e9\n\n@[extern c inline \"~ #1\"]\ndef USize.complement (a:USize) : USize := 0-(a+1)\n\ninstance : Complement USize := \u27e8USize.complement\u27e9\ninstance : AndOp USize      := \u27e8USize.land\u27e9\ninstance : OrOp USize       := \u27e8USize.lor\u27e9\ninstance : Xor USize        := \u27e8USize.xor\u27e9\ninstance : ShiftLeft USize  := \u27e8USize.shiftLeft\u27e9\ninstance : ShiftRight USize := \u27e8USize.shiftRight\u27e9\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  | \u27e8n\u27e9, \u27e8m\u27e9 => 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 \u2264 b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (n <= m))\n\ninstance (a b : USize) : Decidable (a < b) := USize.decLt a b\ninstance (a b : USize) : Decidable (a \u2264 b) := USize.decLe a b\n\ntheorem USize.modn_lt {m : Nat} : \u2200 (u : USize), m > 0 \u2192 USize.toNat (u % m) < m\n  | \u27e8u\u27e9, 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 (\u03b1: \u211d)\n\ndef abvs_equiv {\u03b2} [ring \u03b2] (abv: \u03b2 \u2192 \u211d) (abv': \u03b2 \u2192 \u211d) [is_absolute_value abv] [is_absolute_value abv'] :=\n  \u2203 \u03b1: \u211d, 0 < \u03b1 \u2227 (\u03bb x: \u03b2, (abv x) ^ \u03b1) = abv'\n\ntheorem abvs_equiv_reflexive {\u03b2} [ring \u03b2]:\n  \u2200 (abv: \u03b2 \u2192 \u211d) [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 {\u03b2} [ring \u03b2]:\n  \u2200 (abv abv': \u03b2 \u2192 \u211d) [abv_abv: is_absolute_value abv] [abv'_abv: is_absolute_value abv'],\n    @abvs_equiv _ _ abv abv' abv_abv abv'_abv \u2192 @abvs_equiv _ _ abv' abv abv'_abv abv_abv :=\nbegin\n  intros abv abv' abv_abv abv'_abv p,\n  rcases p with \u27e8 \u03b1, zero_lt_\u03b1, h\u03b1 \u27e9,\n  use [\u03b1\u207b\u00b9, by simp [zero_lt_\u03b1]],\n  ext x,\n  have abvx_nonneg: 0 \u2264 abv x,\n  from @abv_nonneg _ _ _ _ abv abv_abv x,\n  symmetry,\n  calc abv x = abv x ^ (1: \u211d)          : by rw real.rpow_one\n    ... = abv x ^ (\u03b1 * \u03b1\u207b\u00b9)            : by { simp [(ne.symm \u2218 ne_of_lt) zero_lt_\u03b1], }\n    ... = (abv x ^ \u03b1) ^ (\u03b1\u207b\u00b9)          : by { rw real.rpow_mul abvx_nonneg, }\n    ... = ((\u03bb x, abv x ^ \u03b1) x) ^ (\u03b1\u207b\u00b9) : by simp\n    ... = (abv' x) ^ (\u03b1\u207b\u00b9)             : by rw h\u03b1,\nend\n\n\ntheorem abvs_equiv_transitive {\u03b2} [ring \u03b2]:\n  \u2200 (abv abv' abv'': \u03b2 \u2192 \u211d) [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 \u2192 @abvs_equiv _ _ abv' abv'' abv'_abv abv''_abv \u2192\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 \u27e8 \u03b1, zero_lt_\u03b1, h\u03b1 \u27e9,\n  rcases abv'_equiv_abv'' with \u27e8 \u03b3, zero_lt_\u03b3, h\u03b3 \u27e9,\n  use [\u03b1 * \u03b3, by simp [zero_lt_\u03b1, zero_lt_\u03b3]],\n  ext x,\n  have abvx_nonneg: 0 \u2264 abv x,\n  from @abv_nonneg _ _ _ _ abv abv_abv x,\n  rw real.rpow_mul abvx_nonneg,\n  rw [\u2190 h\u03b3, \u2190 h\u03b1],\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\u2081 P\u2082` (notation: `P\u2081 \u2243\u1d43[k] P\u2082`) to be the type of affine\nequivalences between `P\u2081` and `P\u2082, 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\u2081 P\u2082 : Type*) {V\u2081 V\u2082 : Type*} [ring k]\n  [add_comm_group V\u2081] [module k V\u2081] [add_torsor V\u2081 P\u2081]\n  [add_comm_group V\u2082] [module k V\u2082] [add_torsor V\u2082 P\u2082] extends P\u2081 \u2243 P\u2082 :=\n(linear : V\u2081 \u2243\u2097[k] V\u2082)\n(map_vadd' : \u2200 (p : P\u2081) (v : V\u2081), to_equiv (v +\u1d65 p) = linear v +\u1d65 to_equiv p)\n\nnotation P\u2081 ` \u2243\u1d43[`:25 k:25 `] `:0 P\u2082:0 := affine_equiv k P\u2081 P\u2082\n\nvariables {k P\u2081 P\u2082 P\u2083 P\u2084 V\u2081 V\u2082 V\u2083 V\u2084 : Type*} [ring k]\n  [add_comm_group V\u2081] [module k V\u2081] [add_torsor V\u2081 P\u2081]\n  [add_comm_group V\u2082] [module k V\u2082] [add_torsor V\u2082 P\u2082]\n  [add_comm_group V\u2083] [module k V\u2083] [add_torsor V\u2083 P\u2083]\n  [add_comm_group V\u2084] [module k V\u2084] [add_torsor V\u2084 P\u2084]\n\nnamespace affine_equiv\n\ninclude V\u2081 V\u2082\n\ninstance : has_coe_to_fun (P\u2081 \u2243\u1d43[k] P\u2082) (\u03bb _, P\u2081 \u2192 P\u2082) := \u27e8\u03bb e, e.to_fun\u27e9\n\ninstance : has_coe (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2243 P\u2082) := \u27e8affine_equiv.to_equiv\u27e9\n\nvariables (k P\u2081)\n\nomit V\u2082\n\n/-- Identity map as an `affine_equiv`. -/\n@[refl] def refl : P\u2081 \u2243\u1d43[k] P\u2081 :=\n{ to_equiv := equiv.refl P\u2081,\n  linear := linear_equiv.refl k V\u2081,\n  map_vadd' := \u03bb _ _, rfl }\n\n@[simp] lemma coe_refl : \u21d1(refl k P\u2081) = id := rfl\n\nlemma refl_apply (x : P\u2081) : refl k P\u2081 x = x := rfl\n\n@[simp] lemma to_equiv_refl : (refl k P\u2081).to_equiv = equiv.refl P\u2081 := rfl\n\n@[simp] lemma linear_refl : (refl k P\u2081).linear = linear_equiv.refl k V\u2081 := rfl\n\nvariables {k P\u2081}\n\ninclude V\u2082\n\n@[simp] lemma map_vadd (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2081) (v : V\u2081) : e (v +\u1d65 p) = e.linear v +\u1d65 e p :=\ne.map_vadd' p v\n\n@[simp] lemma coe_to_equiv (e : P\u2081 \u2243\u1d43[k] P\u2082) : \u21d1e.to_equiv = e := rfl\n\n/-- Reinterpret an `affine_equiv` as an `affine_map`. -/\ndef to_affine_map (e : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192\u1d43[k] P\u2082 := { to_fun := e, .. e }\n\ninstance : has_coe (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2192\u1d43[k] P\u2082) := \u27e8to_affine_map\u27e9\n\n@[simp] lemma coe_to_affine_map (e : P\u2081 \u2243\u1d43[k] P\u2082) :\n  (e.to_affine_map : P\u2081 \u2192 P\u2082) = (e : P\u2081 \u2192 P\u2082) :=\nrfl\n\n@[simp] lemma to_affine_map_mk (f : P\u2081 \u2243 P\u2082) (f' : V\u2081 \u2243\u2097[k] V\u2082) (h) :\n  to_affine_map (mk f f' h) = \u27e8f, f', h\u27e9 :=\nrfl\n\n@[norm_cast, simp] lemma coe_coe (e : P\u2081 \u2243\u1d43[k] P\u2082) : ((e : P\u2081 \u2192\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082) = e := rfl\n\n@[simp] lemma linear_to_affine_map (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.to_affine_map.linear = e.linear := rfl\n\nlemma to_affine_map_injective : injective (to_affine_map : (P\u2081 \u2243\u1d43[k] P\u2082) \u2192 (P\u2081 \u2192\u1d43[k] P\u2082)) :=\nbegin\n  rintros \u27e8e, el, h\u27e9 \u27e8e', el', h'\u27e9 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\u2081 \u2243\u1d43[k] P\u2082} :\n  e.to_affine_map = e'.to_affine_map \u2194 e = e' :=\nto_affine_map_injective.eq_iff\n\n@[ext] lemma ext {e e' : P\u2081 \u2243\u1d43[k] P\u2082} (h : \u2200 x, e x = e' x) : e = e' :=\nto_affine_map_injective $ affine_map.ext h\n\nlemma coe_fn_injective : @injective (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2192 P\u2082) coe_fn :=\n\u03bb e e' H, ext $ congr_fun H\n\n@[simp, norm_cast] lemma coe_fn_inj {e e' : P\u2081 \u2243\u1d43[k] P\u2082} : (e : P\u2081 \u2192 P\u2082) = e' \u2194 e = e' :=\ncoe_fn_injective.eq_iff\n\nlemma to_equiv_injective : injective (to_equiv : (P\u2081 \u2243\u1d43[k] P\u2082) \u2192 (P\u2081 \u2243 P\u2082)) :=\n\u03bb e e' H, ext $ equiv.ext_iff.1 H\n\n@[simp] lemma to_equiv_inj {e e' : P\u2081 \u2243\u1d43[k] P\u2082} : e.to_equiv = e'.to_equiv \u2194 e = e' :=\nto_equiv_injective.eq_iff\n\n@[simp] lemma coe_mk (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (h) :\n  ((\u27e8e, e', h\u27e9 : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082) = 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\u2081 \u2192 P\u2082`, a linear equivalence\n`e' : V\u2081 \u2243\u2097[k] V\u2082`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -\u1d65 p) +\u1d65 e p`. -/\ndef mk' (e : P\u2081 \u2192 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (p : P\u2081) (h : \u2200 p' : P\u2081, e p' = e' (p' -\u1d65 p) +\u1d65 e p) :\n  P\u2081 \u2243\u1d43[k] P\u2082 :=\n{ to_fun := e,\n  inv_fun := \u03bb q' : P\u2082, e'.symm (q' -\u1d65 e p) +\u1d65 p,\n  left_inv := \u03bb p', by simp [h p'],\n  right_inv := \u03bb q', by simp [h (e'.symm (q' -\u1d65 e p) +\u1d65 p)],\n  linear := e',\n  map_vadd' := \u03bb p' v, by { simp [h p', h (v +\u1d65 p'), vadd_vsub_assoc, vadd_vadd] } }\n\n@[simp] lemma coe_mk' (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (p h) : \u21d1(mk' e e' p h) = e := rfl\n@[simp] lemma linear_mk' (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (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\u2081 \u2243\u1d43[k] P\u2082) : P\u2082 \u2243\u1d43[k] P\u2081 :=\n{ to_equiv := e.to_equiv.symm,\n  linear := e.linear.symm,\n  map_vadd' := \u03bb 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\u2081 \u2243\u1d43[k] P\u2082) : e.to_equiv.symm = e.symm.to_equiv := rfl\n\n@[simp] lemma symm_linear (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.linear.symm = e.symm.linear := rfl\n\n/-- See Note [custom simps projection] -/\ndef simps.apply (e : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082 := e\n\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2082 \u2192 P\u2081 := e.symm\n\ninitialize_simps_projections affine_equiv\n  (to_equiv_to_fun \u2192 apply, to_equiv_inv_fun \u2192 symm_apply, linear \u2192 linear as_prefix, -to_equiv)\n\nprotected lemma bijective (e : P\u2081 \u2243\u1d43[k] P\u2082) : bijective e := e.to_equiv.bijective\nprotected lemma surjective (e : P\u2081 \u2243\u1d43[k] P\u2082) : surjective e := e.to_equiv.surjective\nprotected lemma injective (e : P\u2081 \u2243\u1d43[k] P\u2082) : injective e := e.to_equiv.injective\n\n@[simp] lemma range_eq (e : P\u2081 \u2243\u1d43[k] P\u2082) : range e = univ := e.surjective.range_eq\n\n@[simp] lemma apply_symm_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2082) : e (e.symm p) = p :=\ne.to_equiv.apply_symm_apply p\n\n@[simp] lemma symm_apply_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2081) : e.symm (e p) = p :=\ne.to_equiv.symm_apply_apply p\n\nlemma apply_eq_iff_eq_symm_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) {p\u2081 p\u2082} : e p\u2081 = p\u2082 \u2194 p\u2081 = e.symm p\u2082 :=\ne.to_equiv.apply_eq_iff_eq_symm_apply\n\n@[simp] lemma apply_eq_iff_eq (e : P\u2081 \u2243\u1d43[k] P\u2082) {p\u2081 p\u2082 : P\u2081} : e p\u2081 = e p\u2082 \u2194 p\u2081 = p\u2082 :=\ne.to_equiv.apply_eq_iff_eq\n\nomit V\u2082\n\n@[simp] lemma symm_refl : (refl k P\u2081).symm = refl k P\u2081 := rfl\n\ninclude V\u2082 V\u2083\n\n/-- Composition of two `affine_equiv`alences, applied left to right. -/\n@[trans] def trans (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) : P\u2081 \u2243\u1d43[k] P\u2083 :=\n{ to_equiv := e.to_equiv.trans e'.to_equiv,\n  linear := e.linear.trans e'.linear,\n  map_vadd' := \u03bb p v, by simp only [linear_equiv.trans_apply, coe_to_equiv, (\u2218),\n    equiv.coe_trans, map_vadd] }\n\n@[simp] lemma coe_trans (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) : \u21d1(e.trans e') = e' \u2218 e := rfl\n\nlemma trans_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) (p : P\u2081) : e.trans e' p = e' (e p) := rfl\n\ninclude V\u2084\n\nlemma trans_assoc (e\u2081 : P\u2081 \u2243\u1d43[k] P\u2082) (e\u2082 : P\u2082 \u2243\u1d43[k] P\u2083) (e\u2083 : P\u2083 \u2243\u1d43[k] P\u2084) :\n  (e\u2081.trans e\u2082).trans e\u2083 = e\u2081.trans (e\u2082.trans e\u2083) :=\next $ \u03bb _, rfl\n\nomit V\u2083 V\u2084\n\n@[simp] lemma trans_refl (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.trans (refl k P\u2082) = e :=\next $ \u03bb _, rfl\n\n@[simp] lemma refl_trans (e : P\u2081 \u2243\u1d43[k] P\u2082) : (refl k P\u2081).trans e = e :=\next $ \u03bb _, rfl\n\n@[simp] lemma self_trans_symm (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.trans e.symm = refl k P\u2081 :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.symm.trans e = refl k P\u2082 :=\next e.apply_symm_apply\n\n@[simp] lemma apply_line_map (e : P\u2081 \u2243\u1d43[k] P\u2082) (a b : P\u2081) (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\u2082\n\ninstance : group (P\u2081 \u2243\u1d43[k] P\u2081) :=\n{ one := refl k P\u2081,\n  mul := \u03bb e e', e'.trans e,\n  inv := symm,\n  mul_assoc := \u03bb e\u2081 e\u2082 e\u2083, 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\u2081 \u2243\u1d43[k] P\u2081) = refl k P\u2081 := rfl\n\n@[simp] lemma coe_one : \u21d1(1 : P\u2081 \u2243\u1d43[k] P\u2081) = id := rfl\n\nlemma mul_def (e e' : P\u2081 \u2243\u1d43[k] P\u2081) : e * e' = e'.trans e := rfl\n\n@[simp] lemma coe_mul (e e' : P\u2081 \u2243\u1d43[k] P\u2081) : \u21d1(e * e') = e \u2218 e' := rfl\n\nlemma inv_def (e : P\u2081 \u2243\u1d43[k] P\u2081) : e\u207b\u00b9 = e.symm := rfl\n\n/-- `affine_equiv.linear` on automorphisms is a `monoid_hom`. -/\n@[simps] def linear_hom : (P\u2081 \u2243\u1d43[k] P\u2081) \u2192* (V\u2081 \u2243\u2097[k] V\u2081) :=\n{ to_fun := linear,\n  map_one' := rfl,\n  map_mul' := \u03bb _ _, 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\u2081 \u2243\u1d43[k] P\u2081) \u2243* (P\u2081 \u2192\u1d43[k] P\u2081)\u02e3 :=\n{ to_fun := \u03bb e, \u27e8e, e.symm, congr_arg coe e.symm_trans_self, congr_arg coe e.self_trans_symm\u27e9,\n  inv_fun := \u03bb u,\n  { to_fun := (u : P\u2081 \u2192\u1d43[k] P\u2081), inv_fun := (\u2191(u\u207b\u00b9) : P\u2081 \u2192\u1d43[k] P\u2081),\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' := \u03bb _ _, (u : P\u2081 \u2192\u1d43[k] P\u2081).map_vadd _ _ },\n  left_inv := \u03bb e, affine_equiv.ext $ \u03bb x, rfl,\n  right_inv := \u03bb u, units.ext $ affine_map.ext $ \u03bb x, rfl,\n  map_mul' := \u03bb e\u2081 e\u2082, rfl }\n\nvariable (k)\n\n/-- The map `v \u21a6 v +\u1d65 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\u2081) : V\u2081 \u2243\u1d43[k] P\u2081 :=\n{ to_equiv := equiv.vadd_const b,\n  linear := linear_equiv.refl _ _,\n  map_vadd' := \u03bb p v, add_vadd _ _ _ }\n\n/-- `p' \u21a6 p -\u1d65 p'` as an equivalence. -/\ndef const_vsub (p : P\u2081) : P\u2081 \u2243\u1d43[k] V\u2081 :=\n{ to_equiv := equiv.const_vsub p,\n  linear := linear_equiv.neg k,\n  map_vadd' := \u03bb p' v, by simp [vsub_vadd_eq_vsub_sub, neg_add_eq_sub] }\n\n@[simp] lemma coe_const_vsub (p : P\u2081) : \u21d1(const_vsub k p) = (-\u1d65) p := rfl\n\n@[simp] lemma coe_const_vsub_symm (p : P\u2081) : \u21d1(const_vsub k p).symm = \u03bb v, -v +\u1d65 p := rfl\n\nvariable (P\u2081)\n\n/-- The map `p \u21a6 v +\u1d65 p` as an affine automorphism of an affine space. -/\n@[simps]\ndef const_vadd (v : V\u2081) : P\u2081 \u2243\u1d43[k] P\u2081 :=\n{ to_equiv := equiv.const_vadd P\u2081 v,\n  linear := linear_equiv.refl _ _,\n  map_vadd' := \u03bb p w, vadd_comm _ _ _ }\n\nsection homothety\n\nomit V\u2081\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\u02e3 \u2192* P \u2243\u1d43[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\u02e3) :\n  (homothety_units_mul_hom p t : P \u2192 P) = affine_map.homothety p (t : R) :=\nrfl\n\n@[simp] lemma coe_homothety_units_mul_hom_apply_symm (p : P) (t : R\u02e3) :\n  ((homothety_units_mul_hom p t).symm : P \u2192 P) = affine_map.homothety p (\u2191t\u207b\u00b9 : R) :=\nrfl\n\n@[simp] lemma coe_homothety_units_mul_hom_eq_homothety_hom_coe (p : P) :\n  (coe : (P \u2243\u1d43[R] P) \u2192 P \u2192\u1d43[R] P) \u2218 homothety_units_mul_hom p =\n  (affine_map.homothety_hom p) \u2218 (coe : R\u02e3 \u2192 R) :=\nfunext $ \u03bb _, rfl\n\nend homothety\n\nvariable {P\u2081}\nopen function\n\n/-- Point reflection in `x` as a permutation. -/\ndef point_reflection (x : P\u2081) : P\u2081 \u2243\u1d43[k] P\u2081 := (const_vsub k x).trans (vadd_const k x)\n\nlemma point_reflection_apply (x y : P\u2081) : point_reflection k x y = x -\u1d65 y +\u1d65 x := rfl\n\n@[simp] lemma point_reflection_symm (x : P\u2081) : (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\u2081) :\n  (point_reflection k x).to_equiv = equiv.point_reflection x :=\nrfl\n\n@[simp] lemma point_reflection_self (x : P\u2081) : point_reflection k x x = x := vsub_vadd _ _\n\nlemma point_reflection_involutive (x : P\u2081) : involutive (point_reflection k x : P\u2081 \u2192 P\u2081) :=\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 \u2194 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\u2081} (h : injective (bit0 : V\u2081 \u2192 V\u2081)) :\n  point_reflection k x y = y \u2194 y = x :=\nequiv.point_reflection_fixed_iff_of_injective_bit0 h\n\nlemma injective_point_reflection_left_of_injective_bit0 (h : injective (bit0 : V\u2081 \u2192 V\u2081)) (y : P\u2081) :\n  injective (\u03bb x : P\u2081, 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  \u2200 y, injective (\u03bb x : P\u2081, point_reflection k x y) :=\ninjective_point_reflection_left_of_injective_bit0 k $ \u03bb x y h,\n  by rwa [bit0, bit0, \u2190 two_smul k x, \u2190 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\u2081} :\n  point_reflection k x y = y \u2194 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\u2081 \u2243\u2097[k] V\u2082) : V\u2081 \u2243\u1d43[k] V\u2082 :=\n{ to_equiv := e.to_equiv,\n  linear := e,\n  map_vadd' := \u03bb p v, e.map_add v p }\n\n@[simp] lemma coe_to_affine_equiv (e : V\u2081 \u2243\u2097[k] V\u2082) : \u21d1e.to_affine_equiv = e := rfl\n\nend linear_equiv\n\nnamespace affine_map\n\nopen affine_equiv\n\ninclude V\u2081\n\nlemma line_map_vadd (v v' : V\u2081) (p : P\u2081) (c : k) :\n  line_map v v' c +\u1d65 p = line_map (v +\u1d65 p) (v' +\u1d65 p) c :=\n(vadd_const k p).apply_line_map v v' c\n\nlemma line_map_vsub (p\u2081 p\u2082 p\u2083 : P\u2081) (c : k) :\n  line_map p\u2081 p\u2082 c -\u1d65 p\u2083 = line_map (p\u2081 -\u1d65 p\u2083) (p\u2082 -\u1d65 p\u2083) c :=\n(vadd_const k p\u2083).symm.apply_line_map p\u2081 p\u2082 c\n\nlemma vsub_line_map (p\u2081 p\u2082 p\u2083 : P\u2081) (c : k) :\n  p\u2081 -\u1d65 line_map p\u2082 p\u2083 c = line_map (p\u2081 -\u1d65 p\u2082) (p\u2081 -\u1d65 p\u2083) c :=\n(const_vsub k p\u2081).apply_line_map p\u2082 p\u2083 c\n\nlemma vadd_line_map (v : V\u2081) (p\u2081 p\u2082 : P\u2081) (c : k) :\n  v +\u1d65 line_map p\u2081 p\u2082 c = line_map (v +\u1d65 p\u2081) (v +\u1d65 p\u2082) c :=\n(const_vadd k P\u2081 v).apply_line_map p\u2081 p\u2082 c\n\nvariables {R' : Type*} [comm_ring R'] [module R' V\u2081]\n\nlemma homothety_neg_one_apply (c p : P\u2081) :\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 : \u211d) (s_pos : 0 < s) (s_max : s \u2264 1): (s + 1) ^ (s + 1) / s ^ s \u2264 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 : \u211d), by norm_num), \u2190 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 [\u2190 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 : \u2200 {x : \u211d}, 0 < x \u2192 0 < deriv (\u03bb (x : \u211d), (x + 1) * log (x + 1) - x * log x) x,\n    { intros x x_pos, \n      rw diff_helper,\n      rw \u2190 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    { -- \u2200 (x : \u211d), x \u2208 interior (Icc 0 1) \u2192 0 < deriv (\u03bb (x : \u211d), (x + 1) * log (x + 1) - x * log x) x\n      sorry},\n    \n    all_goals{sorry} -- (s + 1) * log (s + 1) \u2264 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\u2081,...t\u2098],[s\u2081,...,s\u2099]) : clause) encodes the constraints\n0 = \u27e6t\u2081\u27e7 \u2227 ... \u2227 0 = \u27e6t\u2098\u27e7 \u2227 0 \u2264 \u27e6s\u2081\u27e7 \u2227 ... \u2227 0 \u2264 \u27e6s\u2099\u27e7, where\n\u27e6t\u27e7 is the value of (t : term). -/\ndef clause :=\n  List term \u00d7 List term\n\nnamespace clause\n\n\n/-- holds v c := clause c holds under valuation v -/\ndef holds (v : \u2115 \u2192 \u2124) : clause \u2192 Prop :=\n  sorry\n\n/-- sat c := there exists a valuation v under which c holds -/\ndef sat (c : clause) :=\n  \u2203 (v : \u2115 \u2192 \u2124), holds v c\n\n/-- unsat c := there is no valuation v under which c holds -/\ndef unsat (c : clause) :=\n  \u00acsat 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 : \u2115 \u2192 \u2124} {c1 : clause} {c2 : clause} : holds v c1 \u2192 holds v c2 \u2192 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  \u2203 (c : clause), \u2203 (H : c \u2208 cs), clause.sat c\n\n/-- There is no satisfiable clause c in argument -/\ndef clauses.unsat (cs : List clause) :=\n  \u00acclauses.sat cs\n\ntheorem clauses.unsat_nil : clauses.unsat [] := sorry\n\ntheorem clauses.unsat_cons (c : clause) (cs : List clause) : clause.unsat c \u2192 clauses.unsat cs \u2192 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 \u2192 !p \u2192 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 \u2192 Prop)\n\nexample (h\u2081 : x + 0 = x') (h\u2082 : 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 \uff1d Y \u2192 (Quot.mk Class.Eq X) = (Quot.mk Class.Eq Y) :=\nfun h => Quot.sound h\n\ntheorem Classoid.refl : \u2200(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 \u2192 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\u00fcrer, 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 {\u03b1} (A : set \u03b1) : set (F \u03b1) :=\n{ x | \u2200 \u03b2 (f g : \u03b1 \u2192 \u03b2), (\u2200 a \u2208 A, f a = g a) \u2192 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' {\u03b1} (x : F \u03b1) : set \u03b1 :=\n\u22c2 A \u2208 { A : set \u03b1 | x \u2208 box F A}, A\n\n/--\nAlternate notion of predicate lifting based on `box`.\nTaken from the QBNF paper\n-/\ndef liftp' {\u03b1} (x : F \u03b1) (p : \u03b1 \u2192 Prop) : Prop :=\n\u2200 a \u2208 supp' x, p a\n\nend box\n\nend qpf\n\n\nnamespace ex\n\n/-- polynomial functor isomorph to `\u03b1 \u00d7 _` for some `\u03b1` -/\ndef prod.pfunctor (\u03b1 : Type) : pfunctor :=\n\u27e8 \u03b1, \u03bb _, unit \u27e9\n\ninstance {\u03b1} : qpf (prod \u03b1) :=\n{ P := prod.pfunctor \u03b1,\n  abs := \u03bb \u03b2 \u27e8a,f\u27e9, (a, f ()),\n  repr := \u03bb \u03b2 \u27e8x,y\u27e9, \u27e8x, \u03bb _, y\u27e9,\n  abs_repr := \u03bb \u03b2 \u27e8x,y\u27e9, rfl,\n  abs_map := \u03bb \u03b2 \u03b3 f \u27e8a,g\u27e9, rfl }\n\n/-- example relation for products -/\ndef foo.R (\u03b1 : Type) (x y : bool \u00d7 \u03b1) : Prop :=\nx.1 = y.1 \u2227 (x.1 \u2192 x.2 = y.2)\n\nlemma equivalence_foo.R (\u03b1) : equivalence (foo.R \u03b1) :=\nbegin\n  refine \u27e8_,_,_\u27e9,\n  { intro, exact \u27e8rfl,\u03bb _, rfl\u27e9 },\n  { intros x y h, refine \u27e8h.1.symm, \u03bb _, (h.2 _).symm\u27e9,\n    rwa h.1 },\n  { rintros x y z \u27e8ha,ha'\u27e9 \u27e8hb,hb'\u27e9,\n    refine \u27e8ha.trans hb, \u03bb hh, _\u27e9,\n    refine (ha' hh).trans (hb' _),\n    rwa \u2190 ha }\nend\n\n/-- example of a qpf -/\ndef foo (\u03b1 : Type) :=\nquot $ foo.R \u03b1\n\ninstance {\u03b1} [inhabited \u03b1] : inhabited (foo \u03b1) := \u27e8 quot.mk _ default \u27e9\n\n/-- functor operation of `foo` -/\ndef foo.map {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (x : foo \u03b1) : foo \u03b2 :=\nquot.lift_on x (\u03bb x : bool \u00d7 \u03b1, quot.mk (foo.R \u03b2) $ f <$> x)\n  (\u03bb \u27e8a\u2080,a\u2081\u27e9 \u27e8b\u2080,b\u2081\u27e9 h, quot.sound \u27e8h.1,\u03bb h', show f a\u2081 = f b\u2081, from congr_arg f (h.2 h')\u27e9)\n\ninstance : functor foo :=\n{ map := @foo.map }\n\n@[simp]\nlemma foo.map_mk {\u03b1 \u03b2 : Type} (f : \u03b1 \u2192 \u03b2) (x : bool \u00d7 \u03b1) :\n  (f <$> quot.mk _ x : foo \u03b2) = 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 _ (\u03bb \u03b1, quot.mk _) (\u03bb \u03b1, quot.out)\n  (by simp)\n  (by intros; simp)\n\n/-- constructor for `foo` -/\ndef foo.mk {\u03b1} (b : bool) (x : \u03b1) : foo \u03b1 := quot.mk _ (b, x)\n\n@[simp]\nlemma foo.map_mk' {\u03b1 \u03b2 : Type} (f : \u03b1 \u2192 \u03b2) (b : bool) (x : \u03b1) :\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 {\u03b1 : Type} (x y : \u03b1) :\n  foo.mk tt x = foo.mk tt y \u2194 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 `\u03b1`, then the support of `foo.mk ff x` is empty -/\nlemma supp_mk_ff\u2080 {\u03b1} (x y : \u03b1) (h : \u00ac 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 (\u03bb a, \u00ac z = a), subst z,\n    dsimp [functor.liftp],\n    simp, refine \u27e8foo.mk ff \u27e8y,h\u27e9,_\u27e9,\n    simp, apply quot.sound, simp [foo.R] },\n  { use (\u03bb a, x = a),\n    dsimp [functor.liftp],\n    simp [h], use foo.mk ff \u27e8x,rfl\u27e9,\n    simp }\nend\n\n/-- consequence of original definition of `supp`. If there exists only\none value of type `\u03b1`, then the support of `foo.mk ff x` contains that value -/\nlemma supp_mk_ff\u2081 {\u03b1} (x : \u03b1) (h : \u2200 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 \u27e8x,rfl\u27e9, refl },\n  { introv hp, simp [functor.liftp] at hp,\n    rcases hp with \u27e8\u27e8z,z',hz\u27e9,hp\u27e9,\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 : \u00ac @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,\u03bb a : unit, tt,\u03bb 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 \u03bb h, h () }\nend\n\n/-- intuitive consequence of original definition of `supp`. -/\nlemma supp_mk_tt {\u03b1} (x : \u03b1) : 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 \u27e8x,rfl\u27e9, refl },\n  { introv hp, simp [functor.liftp] at hp,\n    rcases hp with \u27e8\u27e8z,z',hz\u27e9,hp\u27e9,\n    simp at hp, replace hp := quot.exact _ hp,\n    rw (equivalence_foo.R _).eqv_gen_iff at hp,\n    rcases hp with \u27e8\u27e8\u27e9,hp\u27e9, 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' {\u03b1} (x : \u03b1) : qpf.supp' (foo.mk ff x) = {} :=\nbegin\n  dsimp [qpf.supp'], ext, simp, dsimp [qpf.box],\n  use \u2205, simp [foo.mk], intros, apply quot.sound,\n  dsimp [foo.R], split, refl, rintro \u27e8 \u27e9\nend\n\n/-- simple consequence of the definition of `supp` from the QBNF paper -/\nlemma supp_mk_tt' {\u03b1} (x : \u03b1) : 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 : \u03b1 \u2192 \u03b1 \u2295 bool := \u03bb x, if x \u2208 i then sum.inl x else sum.inr tt,\n    let g : \u03b1 \u2192 \u03b1 \u2295 bool := \u03bb x, if x \u2208 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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R`, where `I\u2081 : R\u2081 \u2192+* R` and `I\u2082 : R\u2082 \u2192+* R` are ring homomorphisms and\n`M\u2081` is a module over `R\u2081` and `M\u2082` is a module over `R\u2082`.\nSesquilinear forms are the special case that `M\u2081 = M\u2082`, `R\u2081 = R\u2082 = R`, and `I\u2081 = ring_hom.id R`.\nTaking additionally `I\u2082 = 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\u2081 R\u2082 R\u2083 M M\u2081 M\u2082 K K\u2081 K\u2082 V V\u2081 V\u2082 n: Type*}\n\nnamespace linear_map\n\n/-! ### Orthogonal vectors -/\n\nsection comm_ring\n\n-- the `\u2097` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariables [comm_semiring R] [comm_semiring R\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  [comm_semiring R\u2082] [add_comm_monoid M\u2082] [module R\u2082 M\u2082]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2082 \u2192+* R} {I\u2081' : R\u2081 \u2192+* R}\n\n/-- The proposition that two elements of a sesquilinear form space are orthogonal -/\ndef is_ortho (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x y) : Prop := B x y = 0\n\nlemma is_ortho_def {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} {x y} : B.is_ortho x y \u2194 B x y = 0 := iff.rfl\n\nlemma is_ortho_zero_left (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x) : is_ortho B (0 : M\u2081) x :=\nby { dunfold is_ortho, rw [ map_zero B, zero_apply] }\n\nlemma is_ortho_zero_right (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x) : is_ortho B x (0 : M\u2082) :=\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 \u2260 j`, `B (v i) (v j) = 0`. For orthogonality between two elements, use\n`bilin_form.is_ortho` -/\ndef is_Ortho (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2081'] R) (v : n \u2192 M\u2081) : Prop :=\npairwise (B.is_ortho on v)\n\nlemma is_Ortho_def {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2081'] R} {v : n \u2192 M\u2081} :\n  B.is_Ortho v \u2194 \u2200 i j : n, i \u2260 j \u2192 B (v i) (v j) = 0 := iff.rfl\n\nlemma is_Ortho_flip (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2081'] R) {v : n \u2192 M\u2081} :\n  B.is_Ortho v \u2194 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\u2081] [add_comm_group V\u2081] [module K\u2081 V\u2081]\n  [field K\u2082] [add_comm_group V\u2082] [module K\u2082 V\u2082]\n  {I\u2081 : K\u2081 \u2192+* K} {I\u2082 : K\u2082 \u2192+* K} {I\u2081' : K\u2081 \u2192+* K}\n  {J\u2081 : K \u2192+* K} {J\u2082 : K \u2192+* K}\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J\u2081 is invertible\nlemma ortho_smul_left {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2082 \u2192\u209b\u2097[I\u2082] K} {x y} {a : K\u2081} (ha : a \u2260 0) :\n  (is_ortho B x y) \u2194 (is_ortho B (a \u2022 x) y) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smul\u209b\u2097\u2082, H, smul_zero]},\n  { rw [map_smul\u209b\u2097\u2082, smul_eq_zero] at H,\n    cases H,\n    { rw I\u2081.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\u2082 is invertible\nlemma ortho_smul_right {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2082 \u2192\u209b\u2097[I\u2082] K} {x y} {a : K\u2082} {ha : a \u2260 0} :\n(is_ortho B x y) \u2194 (is_ortho B x (a \u2022 y)) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smul\u209b\u2097, H, smul_zero] },\n  { rw [map_smul\u209b\u2097, 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) \u2260 0`. -/\nlemma linear_independent_of_is_Ortho {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2081 \u2192\u209b\u2097[I\u2081'] K} {v : n \u2192 V\u2081}\n  (hv\u2081 : B.is_Ortho v) (hv\u2082 : \u2200 i, \u00ac B.is_ortho (v i) (v i)) : linear_independent K\u2081 v :=\nbegin\n  classical,\n  rw linear_independent_iff',\n  intros s w hs i hi,\n  have : B (s.sum $ \u03bb (i : n), w i \u2022 v i) (v i) = 0,\n  { rw [hs, map_zero, zero_apply] },\n  have hsum : s.sum (\u03bb (j : n), I\u2081(w j) * B (v j) (v i)) = I\u2081(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\u2081 _ _ hij, mul_zero], },\n  simp_rw [B.map_sum\u2082, map_smul\u209b\u2097\u2082, smul_eq_mul, hsum] at this,\n  apply I\u2081.map_eq_zero.mp,\n  exact eq_zero_of_ne_zero_of_mul_right_eq_zero (hv\u2082 i) this,\nend\n\nend field\n\n\n/-! ### Reflexive bilinear forms -/\n\nsection reflexive\n\nvariables [comm_semiring R] [comm_semiring R\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2081 \u2192+* R}\n  {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R}\n\n/-- The proposition that a sesquilinear form is reflexive -/\ndef is_refl (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : Prop :=\n  \u2200 (x y), B x y = 0 \u2192 B y x = 0\n\nnamespace is_refl\n\nvariable (H : B.is_refl)\n\nlemma eq_zero : \u2200 {x y}, B x y = 0 \u2192 B y x = 0 := \u03bb x y, H x y\n\nlemma ortho_comm {x y} : is_ortho B x y \u2194 is_ortho B y x := \u27e8eq_zero H, eq_zero H\u27e9\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 \u2192+* R} {B : M \u2192\u209b\u2097[I] M \u2192\u2097[R] R}\n\n/-- The proposition that a sesquilinear form is symmetric -/\ndef is_symm (B : M \u2192\u209b\u2097[I] M \u2192\u2097[R] R) : Prop :=\n  \u2200 (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 := \u03bb x y H1, by { rw \u2190H.eq, simp [H1] }\n\nlemma ortho_comm (H : B.is_symm) {x y} : is_ortho B x y \u2194 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\u2081\u2082 p p).is_symm :=\nbegin\n  intros x y,\n  simp_rw dom_restrict\u2081\u2082_apply,\n  exact H x y,\nend\n\nend is_symm\n\nlemma is_symm_iff_eq_flip {B : M \u2192\u2097[R] M \u2192\u2097[R] R} : B.is_symm \u2194 B = B.flip :=\nbegin\n  split; intro h,\n  { ext,\n    rw [\u2190h, 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\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2081 \u2192+* R} {I : R\u2081 \u2192+* R} {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R}\n\n/-- The proposition that a sesquilinear form is alternating -/\ndef is_alt (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : Prop := \u2200 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 [\u2190neg H, h, neg_zero],\nend\n\nlemma ortho_comm {x y} : is_ortho B x y \u2194 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\u2081 \u2192\u209b\u2097[I] M\u2081 \u2192\u209b\u2097[I] R} :\n  B.is_alt \u2194 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\u2082 h x x,\n  simp only [neg_apply, flip_apply, \u2190add_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\u2081] [add_comm_group M\u2081] [module R\u2081 M\u2081]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2081 \u2192+* R}\n  {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] 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\u2081 M\u2081) (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : submodule R\u2081 M\u2081 :=\n{ carrier := { m | \u2200 n \u2208 N, B.is_ortho n m },\n  zero_mem' := \u03bb x _, B.is_ortho_zero_right x,\n  add_mem' := \u03bb 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' := \u03bb c x hx n hn,\n    by rw [linear_map.is_ortho, linear_map.map_smul\u209b\u2097, show B n x = 0, by exact hx n hn,\n        smul_zero] }\n\nvariables {N L : submodule R\u2081 M\u2081}\n\n@[simp] lemma mem_orthogonal_bilin_iff {m : M\u2081} :\n  m \u2208 N.orthogonal_bilin B \u2194 \u2200 n \u2208 N, B.is_ortho n m := iff.rfl\n\nlemma orthogonal_bilin_le (h : N \u2264 L) : L.orthogonal_bilin B \u2264 N.orthogonal_bilin B :=\n\u03bb _ hn l hl, hn l (h hl)\n\nlemma le_orthogonal_bilin_orthogonal_bilin (b : B.is_refl) :\n  N \u2264 (N.orthogonal_bilin B).orthogonal_bilin B :=\n\u03bb 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\u2081] [add_comm_group V\u2081] [module K\u2081 V\u2081]\n  {J : K \u2192+* K} {J\u2081 : K\u2081 \u2192+* K} {J\u2081' : K\u2081 \u2192+* K}\n\n-- \u2193 This lemma only applies in fields as we require `a * b = 0 \u2192 a = 0 \u2228 b = 0`\nlemma span_singleton_inf_orthogonal_eq_bot\n  (B : V\u2081 \u2192\u209b\u2097[J\u2081] V\u2081 \u2192\u209b\u2097[J\u2081'] K) (x : V\u2081) (hx : \u00ac B.is_ortho x x) :\n  (K\u2081 \u2219 x) \u2293 submodule.orthogonal_bilin (K\u2081 \u2219 x) B = \u22a5 :=\nbegin\n  rw \u2190 finset.coe_singleton,\n  refine eq_bot_iff.2 (\u03bb y h, _),\n  rcases mem_span_finset.1 h.1 with \u27e8\u03bc, rfl\u27e9,\n  have := h.2 x _,\n  { rw finset.sum_singleton at this \u22a2,\n    suffices h\u03bczero : \u03bc x = 0,\n    { rw [h\u03bczero, zero_smul, submodule.mem_bot] },\n    change B x (\u03bc x \u2022 x) = 0 at this, rw [map_smul\u209b\u2097, smul_eq_mul] at this,\n    exact or.elim (zero_eq_mul.mp this.symm)\n    (\u03bb y, by { simp at y, exact y })\n    (\u03bb hfalse, false.elim $ hx hfalse) },\n  { rw submodule.mem_span; exact \u03bb _ hp, hp $ finset.mem_singleton_self _ }\nend\n\n-- \u2193 This lemma only applies in fields since we use the `mul_eq_zero`\nlemma orthogonal_span_singleton_eq_to_lin_ker {B : V \u2192\u2097[K] V \u2192\u209b\u2097[J] K} (x : V) :\n  submodule.orthogonal_bilin (K \u2219 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 \u03bb h, h x \u27e81, one_smul _ _\u27e9 },\n  { rintro h _ \u27e8z, rfl\u27e9,\n    rw [is_ortho, map_smul\u209b\u2097\u2082, 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 \u2192\u2097[K] V \u2192\u2097[K] K}\n  {x : V} (hx : \u00ac B.is_ortho x x) :\n  (K \u2219 x) \u2294 submodule.orthogonal_bilin (K \u2219 x) B = \u22a4 :=\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 \u2260 0`, the span of the singleton of `x`\n  is complement to its orthogonal complement. -/\nlemma is_compl_span_singleton_orthogonal {B : V \u2192\u2097[K] V \u2192\u2097[K] K}\n  {x : V} (hx : \u00ac B.is_ortho x x) : is_compl (K \u2219 x) (submodule.orthogonal_bilin (K \u2219 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\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  [comm_semiring R\u2082] [add_comm_monoid M\u2082] [module R\u2082 M\u2082]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2082 \u2192+* R} {I\u2081' : R\u2081 \u2192+* 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\u2081`, there exists `y` in `M\u2082` with `B x y \u2260 0`.-/\ndef separating_left (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) : Prop :=\n\u2200 x : M\u2081, (\u2200 y : M\u2082, B x y = 0) \u2192 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\u2082`, there exists `x` in `M\u2081` with `B x y \u2260 0`.-/\ndef separating_right (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) : Prop :=\n\u2200 y : M\u2082, (\u2200 x : M\u2081, B x y = 0) \u2192 y = 0\n\n/-- A bilinear form is called non-degenerate if it is left-separating and right-separating. -/\ndef nondegenerate (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) : Prop := separating_left B \u2227 separating_right B\n\n@[simp] lemma flip_separating_right {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.flip.separating_right \u2194 B.separating_left := \u27e8\u03bb hB x hy, hB x hy, \u03bb hB x hy, hB x hy\u27e9\n\n@[simp] lemma flip_separating_left {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.flip.separating_left \u2194 separating_right B := by rw [\u2190flip_separating_right, flip_flip]\n\n@[simp] lemma flip_nondegenerate {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.flip.nondegenerate \u2194 B.nondegenerate :=\niff.trans and.comm (and_congr flip_separating_right flip_separating_left)\n\nlemma separating_left_iff_linear_nontrivial {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.separating_left \u2194 \u2200 x : M\u2081, B x = 0 \u2192 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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.separating_right \u2194 \u2200 y : M\u2082, B.flip y = 0 \u2192 y = 0 :=\nby rw [\u2190flip_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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.separating_left \u2194 B.ker = \u22a5 :=\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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.separating_right \u2194 B.flip.ker = \u22a5 :=\nby rw [\u2190flip_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 \u2192+* R}\n\nlemma is_symm.nondegenerate_of_separating_left {B : M \u2192\u2097[R] M \u2192\u2097[R] R}\n  (hB : B.is_symm) (hB' : B.separating_left) : B.nondegenerate :=\nbegin\n  refine \u27e8hB', _\u27e9,\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 \u2192\u2097[R] M \u2192\u2097[R] R}\n  (hB : B.is_symm) (hB' : B.separating_right) : B.nondegenerate :=\nbegin\n  refine \u27e8_, hB'\u27e9,\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 \u2192\u2097[R] M \u2192\u2097[R] R} (hB : B.is_symm)\n  {W : submodule R M} (hW : disjoint W (W.orthogonal_bilin B)) :\n  (B.dom_restrict\u2081\u2082 W W).nondegenerate :=\nbegin\n  refine (hB.dom_restrict_symm W).nondegenerate_of_separating_left  _,\n  rintro \u27e8x, hx\u27e9 b\u2081,\n  rw [submodule.mk_eq_zero, \u2190 submodule.mem_bot R],\n  refine hW \u27e8hx, \u03bb y hy, _\u27e9,\n  specialize b\u2081 \u27e8y, hy\u27e9,\n  simp_rw [dom_restrict\u2081\u2082_apply, submodule.coe_mk] at b\u2081,\n  rw hB.ortho_comm,\n  exact b\u2081,\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 \u2192\u209b\u2097[I] M \u2192\u209b\u2097[I'] R} {v : basis n R M} (h : B.is_Ortho v) (hB : B.separating_left)\n  (i : n) : \u00acB.is_ortho (v i) (v i) :=\nbegin\n  intro ho,\n  refine v.ne_zero i (hB (v i) $ \u03bb m, _),\n  obtain \u27e8vi, rfl\u27e9 := 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\u209b\u2097,\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 \u2192\u209b\u2097[I] M \u2192\u209b\u2097[I'] R} {v : basis n R M} (h : B.is_Ortho v) (hB : B.separating_right)\n  (i : n) : \u00acB.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 \u2192\u2097[R] M \u2192\u2097[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : \u2200 i, \u00acB.is_ortho (v i) (v i)) :\n  B.separating_left :=\nbegin\n  intros m hB,\n  obtain \u27e8vi, rfl\u27e9 := 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\u2082, map_smul\u209b\u2097\u2082,\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 \u2192\u2097[R] M \u2192\u2097[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : \u2200 i, \u00acB.is_ortho (v i) (v i)) :\n  B.separating_right :=\nbegin\n  rw is_Ortho_flip at hO,\n  rw [\u2190flip_separating_left],\n  refine is_Ortho.separating_left_of_not_is_ortho_basis_self v hO (\u03bb 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 \u2192\u2097[R] M \u2192\u2097[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : \u2200 i, \u00acB.is_ortho (v i) (v i)) :\n  B.nondegenerate :=\n\u27e8is_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\u27e9\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 \u2192\u1d43[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 \u2192\u1d43[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 \u2192 P2)\n(linear : V1 \u2192\u2097[k] V2)\n(map_vadd' : \u2200 (p : P1) (v : V1), to_fun (v +\u1d65 p) =  linear v +\u1d65 to_fun p)\n\nnotation P1 ` \u2192\u1d43[`: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 \u2192\u1d43[k] P2) P1 (\u03bb _, P2) :=\n{ coe := affine_map.to_fun,\n  coe_injective' := \u03bb \u27e8f, f_linear, f_add\u27e9 \u27e8g, g_linear, g_add\u27e9 (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 [\u2190 f_add, h, \u2190 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 \u2192\u1d43[k] P2) (\u03bb _, P1 \u2192 P2) := fun_like.has_coe_to_fun\n\nnamespace linear_map\n\nvariables {k : Type*} {V\u2081 : Type*} {V\u2082 : Type*} [ring k] [add_comm_group V\u2081] [module k V\u2081]\n  [add_comm_group V\u2082] [module k V\u2082] (f : V\u2081 \u2192\u2097[k] V\u2082)\n\n/-- Reinterpret a linear map as an affine map. -/\ndef to_affine_map : V\u2081 \u2192\u1d43[k] V\u2082 :=\n{ to_fun := f,\n  linear := f,\n  map_vadd' := \u03bb p v, f.map_add v p }\n\n@[simp] lemma coe_to_affine_map : \u21d1f.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 \u2192 P2) (linear add) :\n  ((mk f linear add : P1 \u2192\u1d43[k] P2) : P1 \u2192 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 \u2192\u1d43[k] P2) : f.to_fun = \u21d1f := 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 \u2192\u1d43[k] P2) (p : P1) (v : V1) :\n  f (v +\u1d65 p) = f.linear v +\u1d65 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 \u2192\u1d43[k] P2) (p1 p2 : P1) :\n  f.linear (p1 -\u1d65 p2) = f p1 -\u1d65 f p2 :=\nby conv_rhs { rw [\u2190vsub_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 \u2192\u1d43[k] P2} (h : \u2200 p, f p = g p) : f = g :=\nfun_like.ext _ _ h\n\nlemma ext_iff {f g : P1 \u2192\u1d43[k] P2} : f = g \u2194 \u2200 p, f p = g p := \u27e8\u03bb h p, h \u25b8 rfl, ext\u27e9\n\nlemma coe_fn_injective : @function.injective (P1 \u2192\u1d43[k] P2) (P1 \u2192 P2) coe_fn :=\nfun_like.coe_injective\n\nprotected lemma congr_arg (f : P1 \u2192\u1d43[k] P2) {x y : P1} (h : x = y) : f x = f y :=\ncongr_arg _ h\n\nprotected lemma congr_fun {f g : P1 \u2192\u1d43[k] P2} (h : f = g) (x : P1) : f x = g x :=\nh \u25b8 rfl\n\nvariables (k P1)\n\n/-- Constant function as an `affine_map`. -/\ndef const (p : P2) : P1 \u2192\u1d43[k] P2 :=\n{ to_fun := function.const P1 p,\n  linear := 0,\n  map_vadd' := \u03bb p v, by simp }\n\n@[simp] lemma coe_const (p : P2) : \u21d1(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 \u2192\u1d43[k] P2) :\n  f.linear = 0 \u2194 \u2203 q, f = const k P1 q :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { use f (classical.arbitrary P1),\n    ext,\n    rw [coe_const, function.const_apply, \u2190 @vsub_eq_zero_iff_eq V2, \u2190 f.linear_map_vsub, h,\n      linear_map.zero_apply], },\n  { rcases h with \u27e8q, rfl\u27e9,\n    exact const_linear k P1 q, },\nend\n\ninstance nonempty : nonempty (P1 \u2192\u1d43[k] P2) :=\n(add_torsor.nonempty : nonempty P2).elim $ \u03bb p, \u27e8const k P1 p\u27e9\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\u2081 \u2192 P\u2082`, a linear map `f' : V\u2081 \u2192\u2097[k] V\u2082`, and\na point `p` such that for any other point `p'` we have `f p' = f' (p' -\u1d65 p) +\u1d65 f p`. -/\ndef mk' (f : P1 \u2192 P2) (f' : V1 \u2192\u2097[k] V2) (p : P1) (h : \u2200 p' : P1, f p' = f' (p' -\u1d65 p) +\u1d65 f p) :\n  P1 \u2192\u1d43[k] P2 :=\n{ to_fun := f,\n  linear := f',\n  map_vadd' := \u03bb p' v, by rw [h, h p', vadd_vsub_assoc, f'.map_add, vadd_vadd] }\n\n@[simp] lemma coe_mk' (f : P1 \u2192 P2) (f' : V1 \u2192\u2097[k] V2) (p h) : \u21d1(mk' f f' p h) = f := rfl\n\n@[simp] lemma mk'_linear (f : P1 \u2192 P2) (f' : V1 \u2192\u2097[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 \u2192\u1d43[k] V2) :=\n{ smul := \u03bb c f, \u27e8c \u2022 f, c \u2022 f.linear, \u03bb p v, by simp [smul_add]\u27e9,\n  one_smul := \u03bb f, ext $ \u03bb p, one_smul _ _,\n  mul_smul := \u03bb c\u2081 c\u2082 f, ext $ \u03bb p, mul_smul _ _ _ }\n\n@[simp, norm_cast] lemma coe_smul (c : R) (f : P1 \u2192\u1d43[k] V2) : \u21d1(c \u2022 f) = c \u2022 f := rfl\n\n@[simp] lemma smul_linear (t : R) (f : P1 \u2192\u1d43[k] V2) : (t \u2022 f).linear = t \u2022 f.linear := rfl\n\ninstance [distrib_mul_action R\u1d50\u1d52\u1d56 V2] [is_central_scalar R V2] :\n  is_central_scalar R (P1 \u2192\u1d43[k] V2) :=\n{ op_smul_eq_smul := \u03bb r x, ext $ \u03bb _, op_smul_eq_smul _ _ }\n\nend has_smul\n\ninstance : has_zero (P1 \u2192\u1d43[k] V2) := { zero := \u27e80, 0, \u03bb p v, (zero_vadd _ _).symm\u27e9 }\ninstance : has_add (P1 \u2192\u1d43[k] V2) :=\n{ add := \u03bb f g, \u27e8f + g, f.linear + g.linear, \u03bb p v, by simp [add_add_add_comm]\u27e9 }\ninstance : has_sub (P1 \u2192\u1d43[k] V2) :=\n{ sub := \u03bb f g, \u27e8f - g, f.linear - g.linear, \u03bb p v, by simp [sub_add_sub_comm]\u27e9 }\ninstance : has_neg (P1 \u2192\u1d43[k] V2) := { neg := \u03bb f, \u27e8-f, -f.linear, \u03bb p v, by simp [add_comm]\u27e9 }\n\n@[simp, norm_cast] lemma coe_zero : \u21d1(0 : P1 \u2192\u1d43[k] V2) = 0 := rfl\n@[simp, norm_cast] lemma coe_add (f g : P1 \u2192\u1d43[k] V2) : \u21d1(f + g) = f + g := rfl\n@[simp, norm_cast] lemma coe_neg (f : P1 \u2192\u1d43[k] V2) : \u21d1(-f) = -f := rfl\n@[simp, norm_cast] lemma coe_sub (f g : P1 \u2192\u1d43[k] V2) : \u21d1(f - g) = f - g := rfl\n@[simp] lemma zero_linear : (0 : P1 \u2192\u1d43[k] V2).linear = 0 := rfl\n@[simp] lemma add_linear (f g : P1 \u2192\u1d43[k] V2) : (f + g).linear = f.linear + g.linear := rfl\n@[simp] lemma sub_linear (f g : P1 \u2192\u1d43[k] V2) : (f - g).linear = f.linear - g.linear := rfl\n@[simp] lemma neg_linear (f : P1 \u2192\u1d43[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 \u2192\u1d43[k] V2) :=\ncoe_fn_injective.add_comm_group _\n  coe_zero coe_add coe_neg coe_sub (\u03bb _ _, coe_smul _ _) (\u03bb _ _, 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 \u2192\u1d43[k] V2) (P1 \u2192\u1d43[k] P2) :=\n{ vadd := \u03bb f g, \u27e8\u03bb p, f p +\u1d65 g p, f.linear + g.linear, \u03bb p v,\n    by simp [vadd_vadd, add_right_comm]\u27e9,\n  zero_vadd := \u03bb f, ext $ \u03bb p, zero_vadd _ (f p),\n  add_vadd := \u03bb f\u2081 f\u2082 f\u2083, ext $ \u03bb p, add_vadd (f\u2081 p) (f\u2082 p) (f\u2083 p),\n  vsub := \u03bb f g, \u27e8\u03bb p, f p -\u1d65 g p, f.linear - g.linear, \u03bb p v,\n    by simp [vsub_vadd_eq_vsub_sub, vadd_vsub_assoc, add_sub, sub_add_eq_add_sub]\u27e9,\n  vsub_vadd' := \u03bb f g, ext $ \u03bb p, vsub_vadd (f p) (g p),\n  vadd_vsub' := \u03bb f g, ext $ \u03bb p, vadd_vsub (f p) (g p) }\n\n@[simp] lemma vadd_apply (f : P1 \u2192\u1d43[k] V2) (g : P1 \u2192\u1d43[k] P2) (p : P1) :\n  (f +\u1d65 g) p = f p +\u1d65 g p :=\nrfl\n\n@[simp] lemma vsub_apply (f g : P1 \u2192\u1d43[k] P2) (p : P1) :\n  (f -\u1d65 g : P1 \u2192\u1d43[k] V2) p = f p -\u1d65 g p :=\nrfl\n\n/-- `prod.fst` as an `affine_map`. -/\ndef fst : (P1 \u00d7 P2) \u2192\u1d43[k] P1 :=\n{ to_fun := prod.fst,\n  linear := linear_map.fst k V1 V2,\n  map_vadd' := \u03bb _ _, rfl }\n\n@[simp] lemma coe_fst : \u21d1(fst : (P1 \u00d7 P2) \u2192\u1d43[k] P1) = prod.fst := rfl\n@[simp] lemma fst_linear : (fst : (P1 \u00d7 P2) \u2192\u1d43[k] P1).linear = linear_map.fst k V1 V2 := rfl\n\n/-- `prod.snd` as an `affine_map`. -/\ndef snd : (P1 \u00d7 P2) \u2192\u1d43[k] P2 :=\n{ to_fun := prod.snd,\n  linear := linear_map.snd k V1 V2,\n  map_vadd' := \u03bb _ _, rfl }\n\n@[simp] lemma coe_snd : \u21d1(snd : (P1 \u00d7 P2) \u2192\u1d43[k] P2) = prod.snd := rfl\n@[simp] lemma snd_linear : (snd : (P1 \u00d7 P2) \u2192\u1d43[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 \u2192\u1d43[k] P1 :=\n{ to_fun := id,\n  linear := linear_map.id,\n  map_vadd' := \u03bb p v, rfl }\n\n/-- The identity affine map acts as the identity. -/\n@[simp] lemma coe_id : \u21d1(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 \u2192\u1d43[k] P1) := \u27e8id k P1\u27e9\n\ninclude V2 V3\n\n/-- Composition of affine maps. -/\ndef comp (f : P2 \u2192\u1d43[k] P3) (g : P1 \u2192\u1d43[k] P2) : P1 \u2192\u1d43[k] P3 :=\n{ to_fun := f \u2218 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 \u2192\u1d43[k] P3) (g : P1 \u2192\u1d43[k] P2) :\n  \u21d1(f.comp g) = f \u2218 g := rfl\n\n/-- Composition of affine maps acts as applying the two functions. -/\nlemma comp_apply (f : P2 \u2192\u1d43[k] P3) (g : P1 \u2192\u1d43[k] P2) (p : P1) :\n  f.comp g p = f (g p) := rfl\n\nomit V3\n\n@[simp] lemma comp_id (f : P1 \u2192\u1d43[k] P2) : f.comp (id k P1) = f := ext $ \u03bb p, rfl\n\n@[simp] lemma id_comp (f : P1 \u2192\u1d43[k] P2) : (id k P2).comp f = f := ext $ \u03bb p, rfl\n\ninclude V3 V4\n\nlemma comp_assoc (f\u2083\u2084 : P3 \u2192\u1d43[k] P4) (f\u2082\u2083 : P2 \u2192\u1d43[k] P3) (f\u2081\u2082 : P1 \u2192\u1d43[k] P2) :\n  (f\u2083\u2084.comp f\u2082\u2083).comp f\u2081\u2082 = f\u2083\u2084.comp (f\u2082\u2083.comp f\u2081\u2082) :=\nrfl\n\nomit V2 V3 V4\n\ninstance : monoid (P1 \u2192\u1d43[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 \u2192\u1d43[k] P1) : \u21d1(f * g) = f \u2218 g := rfl\n@[simp] lemma coe_one : \u21d1(1 : P1 \u2192\u1d43[k] P1) = _root_.id := rfl\n\n/-- `affine_map.linear` on endomorphisms is a `monoid_hom`. -/\n@[simps] def linear_hom : (P1 \u2192\u1d43[k] P1) \u2192* (V1 \u2192\u2097[k] V1) :=\n{ to_fun := linear,\n  map_one' := rfl,\n  map_mul' := \u03bb _ _, rfl }\n\ninclude V2\n\n@[simp] lemma linear_injective_iff (f : P1 \u2192\u1d43[k] P2) :\n  function.injective f.linear \u2194 function.injective f :=\nbegin\n  obtain \u27e8p\u27e9 := (infer_instance : nonempty P1),\n  have h : \u21d1f.linear = (equiv.vadd_const (f p)).symm \u2218 f \u2218 (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 \u2192\u1d43[k] P2) :\n  function.surjective f.linear \u2194 function.surjective f :=\nbegin\n  obtain \u27e8p\u27e9 := (infer_instance : nonempty P1),\n  have h : \u21d1f.linear = (equiv.vadd_const (f p)).symm \u2218 f \u2218 (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 \u2192\u1d43[k] P2) :\n  function.bijective f.linear \u2194 function.bijective f :=\nand_congr f.linear_injective_iff f.linear_surjective_iff\n\nlemma image_vsub_image {s t : set P1} (f : P1 \u2192\u1d43[k] P2) :\n  (f '' s) -\u1d65 (f '' t) = f.linear '' (s -\u1d65 t) :=\nbegin\n  ext v,\n  simp only [set.mem_vsub, set.mem_image, exists_exists_and_eq_and, exists_and_distrib_left,\n    \u2190 f.linear_map_vsub],\n  split,\n  { rintros \u27e8x, hx, y, hy, hv\u27e9,\n    exact \u27e8x -\u1d65 y, \u27e8x, hx, y, hy, rfl\u27e9, hv\u27e9, },\n  { rintros \u27e8-, \u27e8x, hx, y, hy, rfl\u27e9, rfl\u27e9,\n    exact \u27e8x, hx, y, hy, rfl\u27e9, },\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\u2080` and `1` to `p\u2081`. -/\ndef line_map (p\u2080 p\u2081 : P1) : k \u2192\u1d43[k] P1 :=\n((linear_map.id : k \u2192\u2097[k] k).smul_right (p\u2081 -\u1d65 p\u2080)).to_affine_map +\u1d65 const k k p\u2080\n\nlemma coe_line_map (p\u2080 p\u2081 : P1) : (line_map p\u2080 p\u2081 : k \u2192 P1) = \u03bb c, c \u2022 (p\u2081 -\u1d65 p\u2080) +\u1d65 p\u2080 := rfl\n\nlemma line_map_apply (p\u2080 p\u2081 : P1) (c : k) : line_map p\u2080 p\u2081 c = c \u2022 (p\u2081 -\u1d65 p\u2080) +\u1d65 p\u2080 := rfl\n\nlemma line_map_apply_module' (p\u2080 p\u2081 : V1) (c : k) : line_map p\u2080 p\u2081 c = c \u2022 (p\u2081 - p\u2080) + p\u2080 := 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 +\u1d65 p) c = c \u2022 v +\u1d65 p :=\nby rw [line_map_apply, vadd_vsub]\n\n@[simp] lemma line_map_linear (p\u2080 p\u2081 : P1) :\n  (line_map p\u2080 p\u2081 : k \u2192\u1d43[k] P1).linear = linear_map.id.smul_right (p\u2081 -\u1d65 p\u2080) :=\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\u2080 p\u2081 : P1) : line_map p\u2080 p\u2081 (0:k) = p\u2080 :=\nby simp [line_map_apply]\n\n@[simp] lemma line_map_apply_one (p\u2080 p\u2081 : P1) : line_map p\u2080 p\u2081 (1:k) = p\u2081 :=\nby simp [line_map_apply]\n\n@[simp] lemma line_map_eq_line_map_iff [no_zero_smul_divisors k V1] {p\u2080 p\u2081 : P1} {c\u2081 c\u2082 : k} :\n  line_map p\u2080 p\u2081 c\u2081 = line_map p\u2080 p\u2081 c\u2082 \u2194 p\u2080 = p\u2081 \u2228 c\u2081 = c\u2082 :=\nby rw [line_map_apply, line_map_apply, \u2190@vsub_eq_zero_iff_eq V1, vadd_vsub_vadd_cancel_right,\n       \u2190sub_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\u2080 p\u2081 : P1} {c : k} :\n  line_map p\u2080 p\u2081 c = p\u2080 \u2194 p\u2080 = p\u2081 \u2228 c = 0 :=\nby rw [\u2190@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\u2080 p\u2081 : P1} {c : k} :\n  line_map p\u2080 p\u2081 c = p\u2081 \u2194 p\u2080 = p\u2081 \u2228 c = 1 :=\nby rw [\u2190@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\u2080 p\u2081 : P1} (h : p\u2080 \u2260 p\u2081) :\n  function.injective (line_map p\u2080 p\u2081 : k \u2192 P1) :=\n\u03bb c\u2081 c\u2082 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 \u2192\u1d43[k] P2) (p\u2080 p\u2081 : P1) (c : k) :\n  f (line_map p\u2080 p\u2081 c) = line_map (f p\u2080) (f p\u2081) c :=\nby simp [line_map_apply]\n\n@[simp] lemma comp_line_map (f : P1 \u2192\u1d43[k] P2) (p\u2080 p\u2081 : P1) :\n  f.comp (line_map p\u2080 p\u2081) = line_map (f p\u2080) (f p\u2081) :=\next $ f.apply_line_map p\u2080 p\u2081\n\n@[simp] lemma fst_line_map (p\u2080 p\u2081 : P1 \u00d7 P2) (c : k) :\n  (line_map p\u2080 p\u2081 c).1 = line_map p\u2080.1 p\u2081.1 c :=\nfst.apply_line_map p\u2080 p\u2081 c\n\n@[simp] lemma snd_line_map (p\u2080 p\u2081 : P1 \u00d7 P2) (c : k) :\n  (line_map p\u2080 p\u2081 c).2 = line_map p\u2080.2 p\u2081.2 c :=\nsnd.apply_line_map p\u2080 p\u2081 c\n\nomit V2\n\nlemma line_map_symm (p\u2080 p\u2081 : P1) :\n  line_map p\u2080 p\u2081 = (line_map p\u2081 p\u2080).comp (line_map (1:k) (0:k)) :=\nby { rw [comp_line_map], simp }\n\nlemma line_map_apply_one_sub (p\u2080 p\u2081 : P1) (c : k) :\n  line_map p\u2080 p\u2081 (1 - c) = line_map p\u2081 p\u2080 c :=\nby { rw [line_map_symm p\u2080, comp_apply], congr, simp [line_map_apply] }\n\n@[simp] lemma line_map_vsub_left (p\u2080 p\u2081 : P1) (c : k) :\n  line_map p\u2080 p\u2081 c -\u1d65 p\u2080 = c \u2022 (p\u2081 -\u1d65 p\u2080) :=\nvadd_vsub _ _\n\n@[simp] lemma left_vsub_line_map (p\u2080 p\u2081 : P1) (c : k) :\n  p\u2080 -\u1d65 line_map p\u2080 p\u2081 c = c \u2022 (p\u2080 -\u1d65 p\u2081) :=\nby rw [\u2190 neg_vsub_eq_vsub_rev, line_map_vsub_left, \u2190 smul_neg, neg_vsub_eq_vsub_rev]\n\n@[simp] lemma line_map_vsub_right (p\u2080 p\u2081 : P1) (c : k) :\n  line_map p\u2080 p\u2081 c -\u1d65 p\u2081 = (1 - c) \u2022 (p\u2080 -\u1d65 p\u2081) :=\nby rw [\u2190 line_map_apply_one_sub, line_map_vsub_left]\n\n@[simp] lemma right_vsub_line_map (p\u2080 p\u2081 : P1) (c : k) :\n  p\u2081 -\u1d65 line_map p\u2080 p\u2081 c = (1 - c) \u2022 (p\u2081 -\u1d65 p\u2080) :=\nby rw [\u2190 line_map_apply_one_sub, left_vsub_line_map]\n\nlemma line_map_vadd_line_map (v\u2081 v\u2082 : V1) (p\u2081 p\u2082 : P1) (c : k) :\n  line_map v\u2081 v\u2082 c +\u1d65 line_map p\u2081 p\u2082 c = line_map (v\u2081 +\u1d65 p\u2081) (v\u2082 +\u1d65 p\u2082) c :=\n((fst : V1 \u00d7 P1 \u2192\u1d43[k] V1) +\u1d65 snd).apply_line_map  (v\u2081, p\u2081) (v\u2082, p\u2082) c\n\nlemma line_map_vsub_line_map (p\u2081 p\u2082 p\u2083 p\u2084 : P1) (c : k) :\n  line_map p\u2081 p\u2082 c -\u1d65 line_map p\u2083 p\u2084 c = line_map (p\u2081 -\u1d65 p\u2083) (p\u2082 -\u1d65 p\u2084) c :=\n-- Why Lean fails to find this instance without a hint?\nby letI : affine_space (V1 \u00d7 V1) (P1 \u00d7 P1) := prod.add_torsor; exact\n((fst : P1 \u00d7 P1 \u2192\u1d43[k] P1) -\u1d65 (snd : P1 \u00d7 P1 \u2192\u1d43[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 \u2192\u1d43[k] V2) : (f : V1 \u2192 V2) = f.linear + (\u03bb z, f 0) :=\nbegin\n  ext x,\n  calc\n    f x = f.linear x +\u1d65 f 0                      : by simp [\u2190 f.map_vadd]\n    ... = (f.linear.to_fun + \u03bb (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 \u2192\u1d43[k] V2) : (f.linear : V1 \u2192 V2) = f - (\u03bb 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 \u2192\u1d43[k] k)\n  (a b : k) :\n  f '' set.uIcc a b = set.uIcc (f a) (f b) :=\nbegin\n  have : \u21d1f = (\u03bb x, x + f 0) \u2218 \u03bb x, x * (f 1 - f 0),\n  { ext x,\n    change f x = x \u2022 (f 1 -\u1d65 f 0) +\u1d65 f 0,\n    rw [\u2190 f.linear_map_vsub, \u2190 f.linear.map_smul, \u2190 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 {\u03b9 : Type*} {V : \u03a0 i : \u03b9, Type*} {P : \u03a0 i : \u03b9, Type*} [\u03a0 i, add_comm_group (V i)]\n  [\u03a0 i, module k (V i)] [\u03a0 i, add_torsor (V i) (P i)]\n\ninclude V\n\n/-- Evaluation at a point as an affine map. -/\ndef proj (i : \u03b9) : (\u03a0 i : \u03b9, P i) \u2192\u1d43[k] P i :=\n{ to_fun := \u03bb f, f i,\n  linear := @linear_map.proj k \u03b9 _ V _ _ i,\n  map_vadd' := \u03bb p v, rfl }\n\n@[simp] lemma proj_apply (i : \u03b9) (f : \u03a0 i, P i) : @proj k _ \u03b9 V P _ _ _ i f = f i := rfl\n\n@[simp] lemma proj_linear (i : \u03b9) :\n   (@proj k _ \u03b9 V P _ _ _ i).linear = @linear_map.proj k \u03b9 _ V _ _ i := rfl\n\nlemma pi_line_map_apply (f g : \u03a0 i, P i) (c : k) (i : \u03b9) :\n  line_map f g c i = line_map (f i) (g i) c :=\n(proj i : (\u03a0 i, P i) \u2192\u1d43[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 \u2192\u1d43[k] V2) :=\n{ smul_add := \u03bb c f g, ext $ \u03bb p, smul_add _ _ _,\n  smul_zero := \u03bb c, ext $ \u03bb 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 \u2192\u1d43[k] V2) :=\n{ smul := (\u2022),\n  add_smul := \u03bb c\u2081 c\u2082 f, ext $ \u03bb p, add_smul _ _ _,\n  zero_smul := \u03bb f, ext $ \u03bb 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 \u2192\u1d43[k] V2) \u2243\u2097[R] V2 \u00d7 (V1 \u2192\u2097[k] V2) :=\n{ to_fun    := \u03bb f, \u27e8f 0, f.linear\u27e9,\n  inv_fun   := \u03bb p, p.2.to_affine_map + const k V1 p.1,\n  left_inv  := \u03bb f, by { ext, rw f.decomp, simp, },\n  right_inv := by { rintros \u27e8v, f\u27e9, 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 \u2192\u1d43[k] P1 :=\nr \u2022 (id k P1 -\u1d65 const k P1 c) +\u1d65 const k P1 c\n\nlemma homothety_def (c : P1) (r : k) :\n  homothety c r = r \u2022 (id k P1 -\u1d65 const k P1 c) +\u1d65 const k P1 c :=\nrfl\n\nlemma homothety_apply (c : P1) (r : k) (p : P1) : homothety c r p = r \u2022 (p -\u1d65 c : V1) +\u1d65 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\u2081 r\u2082 : k) (p : P1) :\n  homothety c (r\u2081 * r\u2082) p = homothety c r\u2081 (homothety c r\u2082 p) :=\nby simp [homothety_apply, mul_smul]\n\nlemma homothety_mul (c : P1) (r\u2081 r\u2082 : k) :\n  homothety c (r\u2081 * r\u2082) = (homothety c r\u2081).comp (homothety c r\u2082) :=\next $ homothety_mul_apply c r\u2081 r\u2082\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\u2081 r\u2082 : k) :\n  homothety c (r\u2081 + r\u2082) = r\u2081 \u2022 (id k P1 -\u1d65 const k P1 c) +\u1d65 homothety c r\u2082 :=\nby simp only [homothety_def, add_smul, vadd_vadd]\n\n/-- `homothety` as a multiplicative monoid homomorphism. -/\ndef homothety_hom (c : P1) : k \u2192* P1 \u2192\u1d43[k] P1 :=\n\u27e8homothety c, homothety_one c, homothety_mul c\u27e9\n\n@[simp] lemma coe_homothety_hom (c : P1) : \u21d1(homothety_hom c : k \u2192* _) = homothety c := rfl\n\n/-- `homothety` as an affine map. -/\ndef homothety_affine (c : P1) : k \u2192\u1d43[k] (P1 \u2192\u1d43[k] P1) :=\n\u27e8homothety c, (linear_map.lsmul k _).flip (id k P1 -\u1d65 const k P1 c),\n  function.swap (homothety_add c)\u27e9\n\n@[simp] lemma coe_homothety_affine (c : P1) :\n  \u21d1(homothety_affine c : k \u2192\u1d43[k] _) = homothety c :=\nrfl\n\nend comm_ring\n\nend affine_map\n\nsection\nvariables {\ud835\udd5c E F : Type*} [ring \ud835\udd5c] [add_comm_group E] [add_comm_group F] [module \ud835\udd5c E] [module \ud835\udd5c 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 : \ud835\udd5c} {f : E \u2192\u1d43[\ud835\udd5c] F} (h : a + b = 1) :\n  f (a \u2022 x + b \u2022 y) = a \u2022 f x + b \u2022 f y :=\nby { simp only [convex.combo_eq_smul_sub_add h, \u2190vsub_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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u2260 1`. In vector spaces, this is equivalent to positive dimension. -/\nclass nontrivial (\u03b1 : Type u_3) where\n  exists_pair_ne : \u2203 (x : \u03b1), \u2203 (y : \u03b1), x \u2260 y\n\ntheorem nontrivial_iff {\u03b1 : Type u_1} : nontrivial \u03b1 \u2194 \u2203 (x : \u03b1), \u2203 (y : \u03b1), x \u2260 y :=\n  { mp := fun (h : nontrivial \u03b1) => nontrivial.exists_pair_ne,\n    mpr := fun (h : \u2203 (x : \u03b1), \u2203 (y : \u03b1), x \u2260 y) => nontrivial.mk h }\n\ntheorem exists_pair_ne (\u03b1 : Type u_1) [nontrivial \u03b1] : \u2203 (x : \u03b1), \u2203 (y : \u03b1), x \u2260 y :=\n  nontrivial.exists_pair_ne\n\ntheorem exists_ne {\u03b1 : Type u_1} [nontrivial \u03b1] (x : \u03b1) : \u2203 (y : \u03b1), y \u2260 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 {\u03b1 : Type u_1} (x : \u03b1) (y : \u03b1) (h : x \u2260 y) : nontrivial \u03b1 :=\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 {\u03b1 : Type u_1} [preorder \u03b1] (x : \u03b1) (y : \u03b1) (h : x < y) : nontrivial \u03b1 :=\n  nontrivial.mk (Exists.intro x (Exists.intro y (ne_of_lt h)))\n\nprotected instance nontrivial.to_nonempty {\u03b1 : Type u_1} [nontrivial \u03b1] : Nonempty \u03b1 := sorry\n\n/-- An inhabited type is either nontrivial, or has a unique element. -/\ndef nontrivial_psum_unique (\u03b1 : Type u_1) [Inhabited \u03b1] : psum (nontrivial \u03b1) (unique \u03b1) :=\n  dite (nontrivial \u03b1) (fun (h : nontrivial \u03b1) => psum.inl h)\n    fun (h : \u00acnontrivial \u03b1) => psum.inr (unique.mk { default := Inhabited.default } sorry)\n\ntheorem subsingleton_iff {\u03b1 : Type u_1} : subsingleton \u03b1 \u2194 \u2200 (x y : \u03b1), x = y :=\n  { mp := fun (h : subsingleton \u03b1) => subsingleton.elim,\n    mpr := fun (h : \u2200 (x y : \u03b1), x = y) => subsingleton.intro h }\n\ntheorem not_nontrivial_iff_subsingleton {\u03b1 : Type u_1} : \u00acnontrivial \u03b1 \u2194 subsingleton \u03b1 := sorry\n\ntheorem not_subsingleton (\u03b1 : Type u_1) [h : nontrivial \u03b1] : \u00acsubsingleton \u03b1 := sorry\n\n/-- A type is either a subsingleton or nontrivial. -/\ntheorem subsingleton_or_nontrivial (\u03b1 : Type u_1) : subsingleton \u03b1 \u2228 nontrivial \u03b1 :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (subsingleton \u03b1 \u2228 nontrivial \u03b1))\n        (Eq.symm (propext not_nontrivial_iff_subsingleton))))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl (\u00acnontrivial \u03b1 \u2228 nontrivial \u03b1))\n          (propext (or_comm (\u00acnontrivial \u03b1) (nontrivial \u03b1)))))\n      (classical.em (nontrivial \u03b1)))\n\ntheorem false_of_nontrivial_of_subsingleton (\u03b1 : Type u_1) [nontrivial \u03b1] [subsingleton \u03b1] :\n    False :=\n  sorry\n\nprotected instance option.nontrivial {\u03b1 : Type u_1} [Nonempty \u03b1] : nontrivial (Option \u03b1) :=\n  nonempty.elim_to_inhabited\n    fun (inst : Inhabited \u03b1) =>\n      nontrivial.mk\n        (Exists.intro none\n          (Exists.intro (some Inhabited.default)\n            (id (id fun (\u1fb0 : none = some Inhabited.default) => option.no_confusion \u1fb0))))\n\n/-- Pushforward a `nontrivial` instance along an injective function. -/\nprotected theorem function.injective.nontrivial {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b1]\n    {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) : nontrivial \u03b2 :=\n  sorry\n\n/-- Pullback a `nontrivial` instance along a surjective function. -/\nprotected theorem function.surjective.nontrivial {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (hf : function.surjective f) : nontrivial \u03b1 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b1]\n    {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) (y : \u03b2) : \u2203 (x : \u03b1), f x \u2260 y :=\n  sorry\n\nprotected instance nontrivial_prod_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [Nonempty \u03b1] [nontrivial \u03b2] :\n    nontrivial (\u03b1 \u00d7 \u03b2) :=\n  function.surjective.nontrivial prod.snd_surjective\n\nprotected instance nontrivial_prod_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b1] [Nonempty \u03b2] :\n    nontrivial (\u03b1 \u00d7 \u03b2) :=\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 \u2192 Type u_4} (i' : I) [inst : \u2200 (i : I), Nonempty (f i)]\n    [nontrivial (f i')] : nontrivial ((i : I) \u2192 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 \u2192 Type u_4} [Inhabited I]\n    [inst : \u2200 (i : I), Nonempty (f i)] [nontrivial (f Inhabited.default)] :\n    nontrivial ((i : I) \u2192 f i) :=\n  nontrivial_at Inhabited.default\n\nend pi\n\n\nprotected instance function.nontrivial {\u03b1 : Type u_1} {\u03b2 : Type u_2} [h : Nonempty \u03b1]\n    [nontrivial \u03b2] : nontrivial (\u03b1 \u2192 \u03b2) :=\n  nonempty.elim h fun (a : \u03b1) => pi.nontrivial_at a\n\nprotected theorem subsingleton.le {\u03b1 : Type u_1} [preorder \u03b1] [subsingleton \u03b1] (x : \u03b1) (y : \u03b1) :\n    x \u2264 y :=\n  le_of_eq (subsingleton.elim x y)\n\nnamespace tactic\n\n\n/--\nTries to generate a `nontrivial \u03b1` instance by performing case analysis on\n`subsingleton_or_nontrivial \u03b1`,\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 \u03b1` 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 \u03b1` hypothesis.\n\nThe tactic first looks for an instance using `apply_instance`.\n\nIf the goal is an (in)equality, the type `\u03b1` is inferred from the goal.\nOtherwise, the type needs to be specified in the tactic invocation, as `nontriviality \u03b1`.\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 \u03b1 \u2228 nontrivial \u03b1`, 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 \u03b1 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 : \u2115) \u2223 4 :=\nbegin\n  nontriviality R, -- there is now a `nontrivial R` hypothesis available.\n  dec_trivial\nend\n```\n\n```\ndef myeq {\u03b1 : Type} (a b : \u03b1) : Prop := a = b\n\nexample {\u03b1 : Type} (a b : \u03b1) (h : a = b) : myeq a b :=\nbegin\n  success_if_fail { nontriviality \u03b1 }, -- Fails\n  nontriviality \u03b1 using [myeq], -- There is now a `nontrivial \u03b1` 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\u00f4pital'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 `\ud835\udcdd a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `\u211d`.\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\u00f4pital's rule, L'Hopital's rule\n-/\n\nopen filter set\nopen_locale filter topological_space pointwise\n\nvariables {a b : \u211d} (hab : a < b) {l : filter \u211d} {f f' g g' : \u211d \u2192 \u211d}\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' \u2260 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[>] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[>] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  have sub : \u2200 x \u2208 Ioo a b, Ioo a x \u2286 Ioo a b := \u03bb x hx, Ioo_subset_Ioo (le_refl a) (le_of_lt hx.2),\n  have hg : \u2200 x \u2208 (Ioo a b), g x \u2260 0,\n  { intros x hx h,\n    have : tendsto g (\ud835\udcdd[<] x) (\ud835\udcdd 0),\n    { rw [\u2190 h, \u2190 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 \u27e8y, hyx, hy\u27e9 : \u2203 c \u2208 Ioo a x, g' c = 0,\n      from exists_has_deriv_at_eq_zero' hx.1 hga this (\u03bb y hy, hgg' y $ sub x hx hy),\n    exact hg' y (sub x hx hyx) hy },\n  have : \u2200 x \u2208 Ioo a b, \u2203 c \u2208 Ioo a x, (f x) * (g' c) = (g x) * (f' c),\n  { intros x hx,\n    rw [\u2190 sub_zero (f x), \u2190 sub_zero (g x)],\n    exact exists_ratio_has_deriv_at_eq_ratio_slope' g g' hx.1 f f'\n      (\u03bb y hy, hgg' y $ sub x hx hy) (\u03bb 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 : \u2200 x \u2208 Ioo a b, ((\u03bb x', (f' x') / (g' x')) \u2218 c) x = f x / g x,\n  { intros x hx,\n    rcases hc x hx with \u27e8h\u2081, h\u2082\u27e9,\n    field_simp [hg x hx, hg' (c x) ((sub x hx) h\u2081)],\n    simp only [h\u2082],\n    rwa mul_comm },\n  have cmp : \u2200 x \u2208 Ioo a b, a < c x \u2227 c x < x,\n    from \u03bb x hx, (hc x hx).1,\n  rw \u2190 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 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' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (nhds_within a (Ioi a)) l) :\n  tendsto (\u03bb 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 [\u2190 hfa, \u2190 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 [\u2190 hga, \u2190 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfb : tendsto f (nhds_within b (Iio b)) (\ud835\udcdd 0)) (hgb : tendsto g (nhds_within b (Iio b)) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (nhds_within b (Iio b)) l) :\n  tendsto (\u03bb 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 : \u2200 x \u2208 -Ioo a b, has_deriv_at (f \u2218 has_neg.neg) (f' (-x) * (-1)) x,\n    from \u03bb x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : \u2200 x \u2208 -Ioo a b, has_deriv_at (g \u2218 has_neg.neg) (g' (-x) * (-1)) x,\n    from \u03bb 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 \u2190 preimage_neg_Ioo at hx, exact hx}),\n          rwa [mul_comm, \u2190 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 $ \u03bb 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 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' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfb : f b = 0) (hgb : g b = 0)\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (nhds_within b (Iio b)) l) :\n  tendsto (\u03bb 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 [\u2190 hfb, \u2190 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 [\u2190 hgb, \u2190 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' : \u2200 x \u2208 Ioi a, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioi a, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioi a, g' x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  obtain \u27e8 a', haa', ha'\u27e9 : \u2203 a', a < a' \u2227 0 < a' :=\n    \u27e81 + max a 0, \u27e8lt_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 _)\u27e9\u27e9,\n  have fact1 : \u2200 (x:\u211d), x \u2208 Ioo 0 a'\u207b\u00b9 \u2192 x \u2260 0 := \u03bb _ hx, (ne_of_lt hx.1).symm,\n  have fact2 : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, a < x\u207b\u00b9,\n    from \u03bb _ hx, lt_trans haa' ((lt_inv ha' hx.1).mpr hx.2),\n  have hdnf : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, has_deriv_at (f \u2218 has_inv.inv) (f' (x\u207b\u00b9) * (-(x^2)\u207b\u00b9)) x,\n    from \u03bb x hx, comp x (hff' (x\u207b\u00b9) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have hdng : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, has_deriv_at (g \u2218 has_inv.inv) (g' (x\u207b\u00b9) * (-(x^2)\u207b\u00b9)) x,\n    from \u03bb x hx, comp x (hgg' (x\u207b\u00b9) $ 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\u2080],\nend\n\ntheorem lhopital_zero_at_bot_on_Iio\n  (hff' : \u2200 x \u2208 Iio a, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Iio a, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Iio a, g' x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_bot l) :\n  tendsto (\u03bb 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 : \u2200 x \u2208 -Iio a, has_deriv_at (f \u2218 has_neg.neg) (f' (-x) * (-1)) x,\n    from \u03bb x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : \u2200 x \u2208 -Iio a, has_deriv_at (g \u2218 has_neg.neg) (g' (-x) * (-1)) x,\n    from \u03bb 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 \u2190 preimage_neg_Iio at hx, exact hx}),\n          rwa [mul_comm, \u2190 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 $ \u03bb 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 \u211d f (Ioo a b)) (hg' : \u2200 x \u2208 Ioo a b, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[>] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[>] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioo a b, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : \u2200 x \u2208 Ioo a b, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_right_on_Ioo hab (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb x hx, (hdg x hx).has_deriv_at) hg' hfa hga hdiv\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hdf : differentiable_on \u211d f (Ioo a b))\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : \u2200 x \u2208 (Ioo a b), (deriv g) x \u2260 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (nhds_within a (Ioi a)) l) :\n  tendsto (\u03bb 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 [\u2190 hfa, \u2190 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 [\u2190 hga, \u2190 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 \u211d f (Ioo a b))\n  (hg' : \u2200 x \u2208 (Ioo a b), (deriv g) x \u2260 0)\n  (hfb : tendsto f (nhds_within b (Iio b)) (\ud835\udcdd 0)) (hgb : tendsto g (nhds_within b (Iio b)) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (nhds_within b (Iio b)) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (nhds_within b (Iio b)) l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioo a b, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : \u2200 x \u2208 Ioo a b, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_left_on_Ioo hab (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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 \u211d f (Ioi a))\n  (hg' : \u2200 x \u2208 (Ioi a), (deriv g) x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioi a, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioi_mem_nhds hx),\n  have hdg : \u2200 x \u2208 Ioi a, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_top_on_Ioi (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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 \u211d f (Iio a))\n  (hg' : \u2200 x \u2208 (Iio a), (deriv g) x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdf : \u2200 x \u2208 Iio a, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Iio_mem_nhds hx),\n  have hdg : \u2200 x \u2208 Iio a, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_bot_on_Iio (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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\u00f4pital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right\n  (hff' : \u2200\u1da0 x in \ud835\udcdd[>] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[>] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[>] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[>] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[>] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 \ud835\udcdd[>] a := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_nhds_within_Ioi_iff_exists_Ioo_subset at hs,\n  rcases hs with \u27e8u, hau, hu\u27e9,\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\u00f4pital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left\n  (hff' : \u2200\u1da0 x in \ud835\udcdd[<] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[<] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[<] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[<] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[<] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[<] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[<] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 \ud835\udcdd[<] a := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_nhds_within_Iio_iff_exists_Ioo_subset at hs,\n  rcases hs with \u27e8l, hal, hl\u27e9,\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\u00f4pital'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' : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[univ \\ {a}] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[univ \\ {a}] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[univ \\ {a}] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[univ \\ {a}] a) l :=\nbegin\n  have : univ \\ {a} = Iio a \u222a 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 \u27e8lhopital_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\u27e9\nend\n\n/-- **L'H\u00f4pital's rule** for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds\n  (hff' : \u2200\u1da0 x in \ud835\udcdd a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, f' x / g' x) (\ud835\udcdd a) l) :\n  tendsto (\u03bb x, f x / g x) (\ud835\udcdd[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\u00f4pital's rule for approaching +\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top\n  (hff' : \u2200\u1da0 x in at_top, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in at_top, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in at_top, g' x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 at_top := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_at_top_sets at hs,\n  rcases hs with \u27e8l, hl\u27e9,\n  have hl' : Ioi l \u2286 s := \u03bb x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_top_on_Ioi _ _ (\u03bb 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\u00f4pital's rule for approaching -\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot\n  (hff' : \u2200\u1da0 x in at_bot, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in at_bot, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in at_bot, g' x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 at_bot := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_at_bot_sets at hs,\n  rcases hs with \u27e8l, hl\u27e9,\n  have hl' : Iio l \u2286 s := \u03bb x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_bot_on_Iio _ _ (\u03bb 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\u00f4pital's rule** for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right\n  (hdf : \u2200\u1da0 x in \ud835\udcdd[>] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[>] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[>] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[>] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[>] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[>] a) l :=\nbegin\n  have hdg : \u2200\u1da0 x in \ud835\udcdd[>] a, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in \ud835\udcdd[>] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in \ud835\udcdd[>] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital's rule** for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left\n  (hdf : \u2200\u1da0 x in \ud835\udcdd[<] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[<] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[<] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[<] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[<] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[<] a) l :=\nbegin\n  have hdg : \u2200\u1da0 x in \ud835\udcdd[<] a, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in \ud835\udcdd[<] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in \ud835\udcdd[<] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital'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 : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[univ \\ {a}] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[univ \\ {a}] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[univ \\ {a}] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[univ \\ {a}] a) l :=\nbegin\n  have : univ \\ {a} = Iio a \u222a 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 \u27e8lhopital_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\u27e9,\nend\n\n/-- **L'H\u00f4pital's rule** for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds\n  (hdf : \u2200\u1da0 x in \ud835\udcdd a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[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\u00f4pital's rule** for approaching +\u221e, `deriv` version -/\ntheorem lhopital_zero_at_top\n  (hdf : \u2200\u1da0 (x : \u211d) in at_top, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 (x : \u211d) in at_top, deriv g x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  have hdg : \u2200\u1da0 x in at_top, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in at_top, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in at_top, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital's rule** for approaching -\u221e, `deriv` version -/\ntheorem lhopital_zero_at_bot\n  (hdf : \u2200\u1da0 (x : \u211d) in at_bot, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 (x : \u211d) in at_bot, deriv g x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdg : \u2200\u1da0 x in at_bot, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in at_bot, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in at_bot, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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 \u2192 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\u2082` (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\u2082 u\u2081 u\u2082 -- morphism levels before object levels. See note [category_theory universes].\n\nsection induced\n\nvariables {C : Type u\u2081} (D : Type u\u2082) [category.{v} D]\nvariables (F : C \u2192 D)\ninclude F\n\n/--\n`induced_category D F`, where `F : C \u2192 D`, is a typeclass synonym for `C`,\nwhich provides a category structure so that the morphisms `X \u27f6 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\u2081 := C\n\nvariables {D}\n\ninstance induced_category.has_coe_to_sort {\u03b1 : Sort*} [has_coe_to_sort D \u03b1] :\n  has_coe_to_sort (induced_category D F) \u03b1 :=\n\u27e8\u03bb c, \u21a5(F c)\u27e9\n\ninstance induced_category.category : category.{v} (induced_category D F) :=\n{ hom  := \u03bb X Y, F X \u27f6 F Y,\n  id   := \u03bb X, \ud835\udfd9 (F X),\n  comp := \u03bb _ _ _ f g, f \u226b 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 \u2964 D :=\n{ obj := F, map := \u03bb x y f, f }\n\ninstance induced_category.full : full (induced_functor F) :=\n{ preimage := \u03bb 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\u2081} [category.{v} C]\nvariables (Z : C \u2192 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 `\u2191X` 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 \u2964 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 \u27f6 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 \u2192 Prop}\n\n/-- An implication of predicates `Z \u2192 Z'` induces a functor between full subcategories. -/\n@[simps]\ndef full_subcategory.map (h : \u2200 \u2983X\u2984, Z X \u2192 Z' X) : full_subcategory Z \u2964 full_subcategory Z' :=\n{ obj := \u03bb X, \u27e8X.1, h X.2\u27e9,\n  map := \u03bb X Y f, f }\n\ninstance (h : \u2200 \u2983X\u2984, Z X \u2192 Z' X) : full (full_subcategory.map h) :=\n{ preimage := \u03bb X Y f, f }\n\ninstance (h : \u2200 \u2983X\u2984, Z X \u2192 Z' X) : faithful (full_subcategory.map h) := {}\n\n@[simp] lemma full_subcategory.map_inclusion (h : \u2200 \u2983X\u2984, Z X \u2192 Z' X) :\n  full_subcategory.map h \u22d9 full_subcategory_inclusion Z' = full_subcategory_inclusion Z :=\nrfl\n\nsection lift\nvariables {D : Type u\u2082} [category.{v\u2082} D] (P Q : D \u2192 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 \u2964 D) (hF : \u2200 X, P (F.obj X)) : C \u2964 full_subcategory P :=\n{ obj := \u03bb X, \u27e8F.obj X, hF X\u27e9,\n  map := \u03bb 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 \u2964 D) (hF : \u2200 X, P (F.obj X)) :\n  full_subcategory.lift P F hF \u22d9 full_subcategory_inclusion P \u2245 F :=\nnat_iso.of_components (\u03bb X, iso.refl _) (by simp)\n\n@[simp]\nlemma full_subcategory.inclusion_obj_lift_obj (F : C \u2964 D) (hF : \u2200 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 \u2964 D) (hF : \u2200 X, P (F.obj X)) {X Y : C}\n  (f : X \u27f6 Y) :\n  (full_subcategory_inclusion P).map ((full_subcategory.lift P F hF).map f) = F.map f :=\nrfl\n\ninstance (F : C \u2964 D) (hF : \u2200 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 \u2964 D) (hF : \u2200 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 \u2964 D) (hF : \u2200 X, P (F.obj X)) (h : \u2200 \u2983X\u2984, P X \u2192 Q X) :\n  full_subcategory.lift P F hF \u22d9 full_subcategory.map h =\n    full_subcategory.lift Q F (\u03bb 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\u2080 u\u2081 l \n\nnamespace Mathlib\n\n/-!\n# Functions functorial with respect to equivalences\n\nAn `equiv_functor` is a function from `Type \u2192 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 \u03b1 \u2192 f \u03b2` from\nan equivalence `\u03b1 \u2243 \u03b2`, 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\u2080 \u2192 Type u\u2081) where\n  map : {\u03b1 \u03b2 : Type u\u2080} \u2192 \u03b1 \u2243 \u03b2 \u2192 f \u03b1 \u2192 f \u03b2\n  map_refl' :\n    autoParam (\u2200 (\u03b1 : Type u\u2080), map (equiv.refl \u03b1) = 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 (\u2200 {\u03b1 \u03b2 \u03b3 : Type u\u2080} (k : \u03b1 \u2243 \u03b2) (h : \u03b2 \u2243 \u03b3), map (equiv.trans k h) = map h \u2218 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\u2080 \u2192 Type u\u2081} [c : equiv_functor f] (\u03b1 : Type u\u2080) :\n    equiv_functor.map (equiv.refl \u03b1) = id :=\n  sorry\n\ntheorem equiv_functor.map_trans {f : Type u\u2080 \u2192 Type u\u2081} [c : equiv_functor f] {\u03b1 : Type u\u2080}\n    {\u03b2 : Type u\u2080} {\u03b3 : Type u\u2080} (k : \u03b1 \u2243 \u03b2) (h : \u03b2 \u2243 \u03b3) :\n    equiv_functor.map (equiv.trans k h) = equiv_functor.map h \u2218 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\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} (e : \u03b1 \u2243 \u03b2) :\n    f \u03b1 \u2243 f \u03b2 :=\n  equiv.mk (map e) (map (equiv.symm e)) sorry sorry\n\n@[simp] theorem map_equiv_apply (f : Type u\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080}\n    {\u03b2 : Type u\u2080} (e : \u03b1 \u2243 \u03b2) (x : f \u03b1) : coe_fn (map_equiv f e) x = map e x :=\n  rfl\n\ntheorem map_equiv_symm_apply (f : Type u\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080}\n    (e : \u03b1 \u2243 \u03b2) (y : f \u03b2) : 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\u2080 \u2192 Type u\u2081) [equiv_functor f] (\u03b1 : Type u\u2080) :\n    map_equiv f (equiv.refl \u03b1) = equiv.refl (f \u03b1) :=\n  sorry\n\n@[simp] theorem map_equiv_symm (f : Type u\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080}\n    (e : \u03b1 \u2243 \u03b2) : 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\u2080 \u2192 Type u\u2081) [equiv_functor f] {\u03b1 : Type u\u2080}\n    {\u03b2 : Type u\u2080} {\u03b3 : Type u\u2080} (ab : \u03b1 \u2243 \u03b2) (bc : \u03b2 \u2243 \u03b3) :\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\u2080 \u2192 Type u\u2081) [Functor f] [is_lawful_functor f] :\n    equiv_functor f :=\n  mk fun (\u03b1 \u03b2 : Type u\u2080) (e : \u03b1 \u2243 \u03b2) => Functor.map \u21d1e\n\ntheorem map_equiv.injective (f : Type u\u2080 \u2192 Type u\u2081) [Applicative f] [is_lawful_applicative f]\n    {\u03b1 : Type u\u2080} {\u03b2 : Type u\u2080} (h : Type u\u2080 \u2192 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 {\u03b1 : Type u} {o n m : \u2115} {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' \u03b1)` to\nprevent immediate decay to a function. -/\nmeta instance matrix.reflect [reflected_univ.{u}] [reflected_univ.{u_1}] [reflected_univ.{u_2}]\n  [reflected _ \u03b1] [reflected _ m'] [reflected _ n']\n  [h : has_reflect (m' \u2192 n' \u2192 \u03b1)] : has_reflect (matrix m' n' \u03b1) :=\n\u03bb m, (by reflect_name : reflected _ @id.{(max u_1 u_2 u) + 1}).subst\u2082\n  ((by reflect_name : reflected _ @matrix.{u_1 u_2 u}).subst\u2083 `(_) `(_) `(_)) $\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 {\u03b1 : Type} (p : parser \u03b1) :\n  parser (\u03a3 m n, fin m \u2192 fin n \u2192 \u03b1) :=\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 \u03b1) \u2295 \u2115) :=\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 \u2190 p,\n  match which with\n  | (sum.inl l) := do\n    h :: tl \u2190 pure l,\n    let n := h.length,\n    l : list (vector \u03b1 n) \u2190 l.mmap (\u03bb row,\n      if h : row.length = n then\n        pure (\u27e8row, h\u27e9 : vector \u03b1 n)\n      else\n        interaction_monad.fail \"Rows must be of equal length\"),\n    pure \u27e8l.length, n, \u03bb i j, (l.nth_le _ i.prop).nth j\u27e9\n  | (sum.inr n) :=\n    pure \u27e80, n, fin_zero_elim\u27e9\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 {\u03b1 : Type}\n  [has_reflect \u03b1] [reflected _ \u03b1] :\n  has_reflect (\u03a3 (m n : \u2115), fin m \u2192 fin n \u2192 \u03b1) :=\n@sigma.reflect.{0 0} _ _ \u2115 (\u03bb m, \u03a3 n, fin m \u2192 fin n \u2192 \u03b1) _ _ _ $ \u03bb i,\n  @sigma.reflect.{0 0} _ _ \u2115 _ _ _ _ (\u03bb 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 \u00abnotation\u00bb (_ : parse $ tk \"!![\")\n  (val : parse (entry_parser (parser.pexpr 1) <* tk \"]\")) : parser pexpr :=\ndo\n  let \u27e8m, n, entries\u27e9 := val,\n  let entry_vals := pi_fin.to_pexpr (pi_fin.to_pexpr \u2218 entries),\n  pure (``(@matrix.of (fin %%`(m)) (fin %%`(n)) _).app entry_vals)\n\nend parser\n\nvariables (a b : \u2115)\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 \u03b1] : has_repr (matrix (fin m) (fin n) \u03b1) :=\n{ repr := \u03bb f,\n  \"!![\" ++ (string.intercalate \"; \" $ (list.fin_range m).map $ \u03bb i,\n    string.intercalate \", \" $ (list.fin_range n).map (\u03bb j, repr (f i j)))  ++ \"]\" }\n\n@[simp] lemma cons_val' (v : n' \u2192 \u03b1) (B : fin m \u2192 n' \u2192 \u03b1) (i j) :\n  vec_cons v B i j = vec_cons (v j) (\u03bb i, B i j) i :=\nby { refine fin.cases _ _ i; simp }\n\n@[simp] lemma head_val' (B : fin m.succ \u2192 n' \u2192 \u03b1) (j : n') :\n  vec_head (\u03bb i, B i j) = vec_head B j := rfl\n\n@[simp] lemma tail_val' (B : fin m.succ \u2192 n' \u2192 \u03b1) (j : n') :\n  vec_tail (\u03bb i, B i j) = \u03bb i, vec_tail B i j :=\nby { ext, simp [vec_tail] }\n\nsection dot_product\n\nvariables [add_comm_monoid \u03b1] [has_mul \u03b1]\n\n@[simp] lemma dot_product_empty (v w : fin 0 \u2192 \u03b1) :\n  dot_product v w = 0 := finset.sum_empty\n\n@[simp] lemma cons_dot_product (x : \u03b1) (v : fin n \u2192 \u03b1) (w : fin n.succ \u2192 \u03b1) :\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 \u2192 \u03b1) (x : \u03b1) (w : fin n \u2192 \u03b1) :\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 : \u03b1) (v : fin n \u2192 \u03b1) (y : \u03b1) (w : fin n \u2192 \u03b1) :\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 \u2192 \u03b1) : col v = vec_empty :=\nempty_eq _\n\n@[simp] lemma col_cons (x : \u03b1) (u : fin m \u2192 \u03b1) :\n  col (vec_cons x u) = vec_cons (\u03bb _, 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 \u2192 \u03b1) = \u03bb _, vec_empty :=\nby { ext, refl }\n\n@[simp] lemma row_cons (x : \u03b1) (u : fin m \u2192 \u03b1) :\n  row (vec_cons x u) = \u03bb _, 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) \u03b1) : A\u1d40 = of ![] := empty_eq _\n\n@[simp] lemma transpose_empty_cols (A : matrix (fin 0) m' \u03b1) : A\u1d40 = of (\u03bb i, ![]) :=\nfunext (\u03bb i, empty_eq _)\n\n@[simp] lemma cons_transpose (v : n' \u2192 \u03b1) (A : matrix (fin m) n' \u03b1) :\n  (of (vec_cons v A))\u1d40 = of (\u03bb i, vec_cons (v i) (A\u1d40 i)) :=\nby { ext i j, refine fin.cases _ _ j; simp }\n\n@[simp] lemma head_transpose (A : matrix m' (fin n.succ) \u03b1) :\n  vec_head (of.symm A\u1d40) = vec_head \u2218 (of.symm A) :=\nrfl\n\n@[simp] lemma tail_transpose (A : matrix m' (fin n.succ) \u03b1) :\n  vec_tail (of.symm A\u1d40) = (vec_tail \u2218 A)\u1d40 :=\nby { ext i j, refl }\n\nend transpose\n\nsection mul\n\nvariables [semiring \u03b1]\n\n@[simp] lemma empty_mul [fintype n'] (A : matrix (fin 0) n' \u03b1) (B : matrix n' o' \u03b1) :\n  A \u2b1d B = of ![] :=\nempty_eq _\n\n@[simp] lemma empty_mul_empty (A : matrix m' (fin 0) \u03b1) (B : matrix (fin 0) o' \u03b1) :\n  A \u2b1d B = 0 :=\nrfl\n\n@[simp] lemma mul_empty [fintype n'] (A : matrix m' n' \u03b1) (B : matrix n' (fin 0) \u03b1) :\n  A \u2b1d B = of (\u03bb _, ![]) :=\nfunext (\u03bb _, empty_eq _)\n\nlemma mul_val_succ [fintype n']\n  (A : matrix (fin m.succ) n' \u03b1) (B : matrix n' o' \u03b1) (i : fin m) (j : o') :\n  (A \u2b1d B) i.succ j = (of (vec_tail (of.symm A)) \u2b1d B) i j := rfl\n\n@[simp] lemma cons_mul [fintype n'] (v : n' \u2192 \u03b1) (A : fin m \u2192 n' \u2192 \u03b1) (B : matrix n' o' \u03b1) :\n  of (vec_cons v A) \u2b1d B = of (vec_cons (vec_mul v B) (of.symm (of A \u2b1d B))) :=\nby { ext i j, refine fin.cases _ _ i, { refl },  simp [mul_val_succ], }\n\nend mul\n\nsection vec_mul\n\nvariables [semiring \u03b1]\n\n@[simp] lemma empty_vec_mul (v : fin 0 \u2192 \u03b1) (B : matrix (fin 0) o' \u03b1) :\n  vec_mul v B = 0 :=\nrfl\n\n@[simp] lemma vec_mul_empty [fintype n'] (v : n' \u2192 \u03b1) (B : matrix n' (fin 0) \u03b1) :\n  vec_mul v B = ![] :=\nempty_eq _\n\n@[simp] lemma cons_vec_mul (x : \u03b1) (v : fin n \u2192 \u03b1) (B : fin n.succ \u2192 o' \u2192 \u03b1) :\n  vec_mul (vec_cons x v) (of B) = x \u2022 (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 \u2192 \u03b1) (w : o' \u2192 \u03b1) (B : fin n \u2192 o' \u2192 \u03b1) :\n  vec_mul v (of $ vec_cons w B) = vec_head v \u2022 w + vec_mul (vec_tail v) (of B) :=\nby { ext i, simp [vec_mul] }\n\n@[simp] lemma cons_vec_mul_cons (x : \u03b1) (v : fin n \u2192 \u03b1) (w : o' \u2192 \u03b1) (B : fin n \u2192 o' \u2192 \u03b1) :\n  vec_mul (vec_cons x v) (of $ vec_cons w B) = x \u2022 w + vec_mul v (of B) :=\nby simp\n\nend vec_mul\n\nsection mul_vec\n\nvariables [semiring \u03b1]\n\n@[simp] lemma empty_mul_vec [fintype n'] (A : matrix (fin 0) n' \u03b1) (v : n' \u2192 \u03b1) :\n  mul_vec A v = ![] :=\nempty_eq _\n\n@[simp] lemma mul_vec_empty (A : matrix m' (fin 0) \u03b1) (v : fin 0 \u2192 \u03b1) :\n  mul_vec A v = 0 :=\nrfl\n\n@[simp] lemma cons_mul_vec [fintype n'] (v : n' \u2192 \u03b1) (A : fin m \u2192 n' \u2192 \u03b1) (w : n' \u2192 \u03b1) :\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 {\u03b1} [comm_semiring \u03b1] (A : m' \u2192 (fin n.succ) \u2192 \u03b1) (x : \u03b1)\n  (v : fin n \u2192 \u03b1) :\n  mul_vec (of A) (vec_cons x v) = (x \u2022 vec_head \u2218 A) + mul_vec (of (vec_tail \u2218 A)) v :=\nby { ext i, simp [mul_vec, mul_comm] }\n\nend mul_vec\n\nsection vec_mul_vec\n\nvariables [semiring \u03b1]\n\n@[simp] lemma empty_vec_mul_vec (v : fin 0 \u2192 \u03b1) (w : n' \u2192 \u03b1) :\n  vec_mul_vec v w = ![] :=\nempty_eq _\n\n@[simp] lemma vec_mul_vec_empty (v : m' \u2192 \u03b1) (w : fin 0 \u2192 \u03b1) :\n  vec_mul_vec v w = \u03bb _, ![] :=\nfunext (\u03bb i, empty_eq _)\n\n@[simp] lemma cons_vec_mul_vec (x : \u03b1) (v : fin m \u2192 \u03b1) (w : n' \u2192 \u03b1) :\n  vec_mul_vec (vec_cons x v) w = vec_cons (x \u2022 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' \u2192 \u03b1) (x : \u03b1) (w : fin n \u2192 \u03b1) :\n  vec_mul_vec v (vec_cons x w) = \u03bb i, v i \u2022 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 \u03b1]\n\n@[simp] lemma smul_mat_empty {m' : Type*} (x : \u03b1) (A : fin 0 \u2192 m' \u2192 \u03b1) : x \u2022 A = ![] := empty_eq _\n\n@[simp] lemma smul_mat_cons (x : \u03b1) (v : n' \u2192 \u03b1) (A : fin m \u2192 n' \u2192 \u03b1) :\n  x \u2022 vec_cons v A = vec_cons (x \u2022 v) (x \u2022 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' \u03b1) (row : fin 0 \u2192 m') (col : o' \u2192 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 \u03b1] [has_one \u03b1]\n\nlemma one_fin_two : (1 : matrix (fin 2) (fin 2) \u03b1) = !![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) \u03b1) = !![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) \u03b1) : 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) \u03b1) :\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 \u03b1] [has_mul \u03b1] (a\u2081\u2081 a\u2081\u2082 a\u2082\u2081 a\u2082\u2082 b\u2081\u2081 b\u2081\u2082 b\u2082\u2081 b\u2082\u2082 : \u03b1) :\n  !![a\u2081\u2081, a\u2081\u2082;\n     a\u2082\u2081, a\u2082\u2082] \u2b1d !![b\u2081\u2081, b\u2081\u2082;\n                    b\u2082\u2081, b\u2082\u2082] = !![a\u2081\u2081 * b\u2081\u2081 + a\u2081\u2082 * b\u2082\u2081, a\u2081\u2081 * b\u2081\u2082 + a\u2081\u2082 * b\u2082\u2082;\n                                   a\u2082\u2081 * b\u2081\u2081 + a\u2082\u2082 * b\u2082\u2081, a\u2082\u2081 * b\u2081\u2082 + a\u2082\u2082 * b\u2082\u2082] :=\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 \u03b1] [has_mul \u03b1]\n  (a\u2081\u2081 a\u2081\u2082 a\u2081\u2083 a\u2082\u2081 a\u2082\u2082 a\u2082\u2083 a\u2083\u2081 a\u2083\u2082 a\u2083\u2083 b\u2081\u2081 b\u2081\u2082 b\u2081\u2083 b\u2082\u2081 b\u2082\u2082 b\u2082\u2083 b\u2083\u2081 b\u2083\u2082 b\u2083\u2083 : \u03b1) :\n  !![a\u2081\u2081, a\u2081\u2082, a\u2081\u2083;\n     a\u2082\u2081, a\u2082\u2082, a\u2082\u2083;\n     a\u2083\u2081, a\u2083\u2082, a\u2083\u2083] \u2b1d !![b\u2081\u2081, b\u2081\u2082, b\u2081\u2083;\n                         b\u2082\u2081, b\u2082\u2082, b\u2082\u2083;\n                         b\u2083\u2081, b\u2083\u2082, b\u2083\u2083] =\n  !![a\u2081\u2081*b\u2081\u2081 + a\u2081\u2082*b\u2082\u2081 + a\u2081\u2083*b\u2083\u2081, a\u2081\u2081*b\u2081\u2082 + a\u2081\u2082*b\u2082\u2082 + a\u2081\u2083*b\u2083\u2082, a\u2081\u2081*b\u2081\u2083 + a\u2081\u2082*b\u2082\u2083 + a\u2081\u2083*b\u2083\u2083;\n     a\u2082\u2081*b\u2081\u2081 + a\u2082\u2082*b\u2082\u2081 + a\u2082\u2083*b\u2083\u2081, a\u2082\u2081*b\u2081\u2082 + a\u2082\u2082*b\u2082\u2082 + a\u2082\u2083*b\u2083\u2082, a\u2082\u2081*b\u2081\u2083 + a\u2082\u2082*b\u2082\u2083 + a\u2082\u2083*b\u2083\u2083;\n     a\u2083\u2081*b\u2081\u2081 + a\u2083\u2082*b\u2082\u2081 + a\u2083\u2083*b\u2083\u2081, a\u2083\u2081*b\u2081\u2082 + a\u2083\u2082*b\u2082\u2082 + a\u2083\u2083*b\u2083\u2082, a\u2083\u2081*b\u2081\u2083 + a\u2083\u2082*b\u2082\u2083 + a\u2083\u2083*b\u2083\u2083] :=\nbegin\n  ext i j,\n  fin_cases i; fin_cases j; simp [matrix.mul, dot_product, fin.sum_univ_succ, \u2190add_assoc],\nend\n\nlemma vec2_eq {a\u2080 a\u2081 b\u2080 b\u2081 : \u03b1} (h\u2080 : a\u2080 = b\u2080) (h\u2081 : a\u2081 = b\u2081) :\n  ![a\u2080, a\u2081] = ![b\u2080, b\u2081] :=\nby subst_vars\n\nlemma vec3_eq {a\u2080 a\u2081 a\u2082 b\u2080 b\u2081 b\u2082 : \u03b1} (h\u2080 : a\u2080 = b\u2080) (h\u2081 : a\u2081 = b\u2081) (h\u2082 : a\u2082 = b\u2082) :\n  ![a\u2080, a\u2081, a\u2082] = ![b\u2080, b\u2081, b\u2082] :=\nby subst_vars\n\nlemma vec2_add [has_add \u03b1] (a\u2080 a\u2081 b\u2080 b\u2081 : \u03b1) :\n  ![a\u2080, a\u2081] + ![b\u2080, b\u2081] = ![a\u2080 + b\u2080, a\u2081 + b\u2081] :=\nby rw [cons_add_cons, cons_add_cons, empty_add_empty]\n\nlemma vec3_add [has_add \u03b1] (a\u2080 a\u2081 a\u2082 b\u2080 b\u2081 b\u2082 : \u03b1) :\n  ![a\u2080, a\u2081, a\u2082] + ![b\u2080, b\u2081, b\u2082] = ![a\u2080 + b\u2080, a\u2081 + b\u2081, a\u2082 + b\u2082] :=\nby rw [cons_add_cons, cons_add_cons, cons_add_cons, empty_add_empty]\n\nlemma smul_vec2 {R : Type*} [has_smul R \u03b1] (x : R) (a\u2080 a\u2081 : \u03b1) :\n  x \u2022 ![a\u2080, a\u2081] = ![x \u2022 a\u2080, x \u2022 a\u2081] :=\nby rw [smul_cons, smul_cons, smul_empty]\n\nlemma smul_vec3 {R : Type*} [has_smul R \u03b1] (x : R) (a\u2080 a\u2081 a\u2082 : \u03b1) :\n  x \u2022 ![a\u2080, a\u2081, a\u2082] = ![x \u2022 a\u2080, x \u2022 a\u2081, x \u2022 a\u2082] :=\nby rw [smul_cons, smul_cons, smul_cons, smul_empty]\n\nvariables [add_comm_monoid \u03b1] [has_mul \u03b1]\n\nlemma vec2_dot_product' {a\u2080 a\u2081 b\u2080 b\u2081 : \u03b1} :\n  ![a\u2080, a\u2081] \u2b1d\u1d65 ![b\u2080, b\u2081] = a\u2080 * b\u2080 + a\u2081 * b\u2081 :=\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 \u2192 \u03b1) :\n  v \u2b1d\u1d65 w = v 0 * w 0 + v 1 * w 1 :=\nvec2_dot_product'\n\nlemma vec3_dot_product' {a\u2080 a\u2081 a\u2082 b\u2080 b\u2081 b\u2082 : \u03b1} :\n  ![a\u2080, a\u2081, a\u2082] \u2b1d\u1d65 ![b\u2080, b\u2081, b\u2082] = a\u2080 * b\u2080 + a\u2081 * b\u2081 + a\u2082 * b\u2082 :=\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 \u2192 \u03b1) :\n  v \u2b1d\u1d65 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 \u2192 wide_pullback_shape J \u2192 Type v where\n| id : (X : wide_pullback_shape J) \u2192 hom X X\n| term : (j : J) \u2192 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 \u27f6 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 = \ud835\udfd9 := 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 \u2192 C)\n    (arrows : (j : J) \u2192 objs j \u27f6 B) (X : wide_pullback_shape J) (Y : wide_pullback_shape J)\n    (f : X \u27f6 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 \u27f6 X) (H_3 : f == hom.id X) =>\n                    Eq._oldrec \ud835\udfd9 (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 \u27f6 Y) (H_2 : Y = none) =>\n                Eq._oldrec\n                  (fun (f : some j \u27f6 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 \u2964 C) :\n    F \u2245\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 \u2192 wide_pushout_shape J \u2192 Type v where\n| id : (X : wide_pushout_shape J) \u2192 hom X X\n| init : (j : J) \u2192 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 \u27f6 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 = \ud835\udfd9 := 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 \u2192 C)\n    (arrows : (j : J) \u2192 B \u27f6 objs j) (X : wide_pushout_shape J) (Y : wide_pushout_shape J)\n    (f : X \u27f6 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 \u27f6 X) (H_3 : f == hom.id X) =>\n                    Eq._oldrec \ud835\udfd9 (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 \u27f6 Y) (H_2 : Y = some j) =>\n                Eq._oldrec\n                  (fun (f : none \u27f6 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 \u2964 C) :\n    F \u2245\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  \u2200 (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  \u2200 (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 \u211d) (HS : \u2203 a : \u211d, a \u2208 S) (u : \u211d) (Hu : u \u2208 upper_bounds S) :\nis_lub S u \u2194 \u2200 \u03b5 > 0, \u2203 s \u2208 S, s > u - \u03b5 :=\nbegin\n  split,\n  { intro Hu,\n    intros \u03b5 H\u03b5,\n    let v := u - \u03b5,\n    have Hv : \u00ac (u \u2264 v),\n      change \u00ac (u \u2264 u - \u03b5),\n      linarith,\n    have Hv' : v \u2209 upper_bounds S,\n      intro Hv'',\n      apply Hv,\n      apply Hu.2,\n      assumption,\n    change \u00ac (v \u2208 {x : \u211d | \u2200 s, s \u2208 S \u2192 s \u2264 v}) at Hv', -- bug in Lean?\n    change \u00ac (v \u2208 {x : \u211d | \u2200 s, s \u2208 S \u2192 s \u2264 x}) at Hv', -- bug in Lean?\n  --  change \u00ac (\u2200 s : \u211d, s \u2208 S \u2192 s \u2264 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  \u27e81\u27e9\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 : \u2200 x : U, Localizations R x) : Prop :=\n  \u2203 r s : R, \u2200 x : U, \u00acs \u2208 x.1.asIdeal \u2227 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 : \u2200 x : U, Localizations R x}\n    (hf : IsFraction f) :\n    \u2203 r s : R,\n      \u2200 x : U,\n        \u2203 hs : s \u2209 x.1.asIdeal,\n          f x =\n            IsLocalization.mk' (Localization.AtPrime _) r\n              (\u27e8s, hs\u27e9 : (x : PrimeSpectrum.top R).asIdeal.primeCompl) :=\n  by\n  rcases hf with \u27e8r, s, h\u27e9\n  refine' \u27e8r, s, fun x => \u27e8(h x).1, (is_localization.mk'_eq_iff_eq_mul.mpr _).symm\u27e9\u27e9\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 \u27e8r, s, w\u27e9\n    exact \u27e8r, s, fun x => w (i x)\u27e9\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 `\u03a0 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 \u2286 Spec A$, we define $\ud835\udcaa(U)$ to be the set of functions\n$s : U \u2192 \u2a06_{\ud835\udd2d \u2208 U} A_\ud835\udd2d$, such that $s(\ud835\udd2d) \u2208 A_\ud835\udd2d$ for each $\ud835\udd2d$,\nand such that $s$ is locally a quotient of elements of $A$:\nto be precise, we require that for each $\ud835\udd2d \u2208 U$, there is a neighborhood $V$ of $\ud835\udd2d$,\ncontained in $U$, and elements $a, f \u2208 A$, such that for each $\ud835\udd2e \u2208 V, f \u2209 \ud835\udd2e$,\nand $s(\ud835\udd2e) = a/f$ in $A_\ud835\udd2e$.\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`\u03a0 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 : \u2200 x : U, Localizations R x) :\n    (isLocallyFraction R).pred f =\n      \u2200 x : U,\n        \u2203 (V : _)(m : x.1 \u2208 V)(i : V \u27f6 U),\n          \u2203 r s : R,\n            \u2200 y : V, \u00acs \u2208 y.1.asIdeal \u2227 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))\u1d52\u1d56) :\n    Subring (\u2200 x : unop U, Localizations R x)\n    where\n  carrier := { f | (isLocallyFraction R).pred f }\n  zero_mem' := by\n    refine' fun x => \u27e8unop U, x.2, \ud835\udfd9 _, 0, 1, fun y => \u27e8_, _\u27e9\u27e9\n    \u00b7 rw [\u2190 Ideal.ne_top_iff_one]\n      exact y.1.IsPrime.1\n    \u00b7 simp\n  one_mem' := by\n    refine' fun x => \u27e8unop U, x.2, \ud835\udfd9 _, 1, 1, fun y => \u27e8_, _\u27e9\u27e9\n    \u00b7 rw [\u2190 Ideal.ne_top_iff_one]\n      exact y.1.IsPrime.1\n    \u00b7 simp\n  add_mem' := by\n    intro a b ha hb x\n    rcases ha x with \u27e8Va, ma, ia, ra, sa, wa\u27e9\n    rcases hb x with \u27e8Vb, mb, ib, rb, sb, wb\u27e9\n    refine' \u27e8Va \u2293 Vb, \u27e8ma, mb\u27e9, opens.inf_le_left _ _ \u226b ia, ra * sb + rb * sa, sa * sb, _\u27e9\n    intro y\n    rcases wa (opens.inf_le_left _ _ y) with \u27e8nma, wa\u27e9\n    rcases wb (opens.inf_le_right _ _ y) with \u27e8nmb, wb\u27e9\n    fconstructor\n    \u00b7 intro H\n      cases y.1.IsPrime.mem_or_mem H <;> contradiction\n    \u00b7 simp only [add_mul, RingHom.map_add, Pi.add_apply, RingHom.map_mul]\n      erw [\u2190 wa, \u2190 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 \u27e8V, m, i, r, s, w\u27e9\n    refine' \u27e8V, m, i, -r, s, _\u27e9\n    intro y\n    rcases w y with \u27e8nm, w\u27e9\n    fconstructor\n    \u00b7 exact nm\n    \u00b7 simp only [RingHom.map_neg, Pi.neg_apply]\n      erw [\u2190 w]\n      simp only [neg_mul]\n  mul_mem' := by\n    intro a b ha hb x\n    rcases ha x with \u27e8Va, ma, ia, ra, sa, wa\u27e9\n    rcases hb x with \u27e8Vb, mb, ib, rb, sb, wb\u27e9\n    refine' \u27e8Va \u2293 Vb, \u27e8ma, mb\u27e9, opens.inf_le_left _ _ \u226b ia, ra * rb, sa * sb, _\u27e9\n    intro y\n    rcases wa (opens.inf_le_left _ _ y) with \u27e8nma, wa\u27e9\n    rcases wb (opens.inf_le_right _ _ y) with \u27e8nmb, wb\u27e9\n    fconstructor\n    \u00b7 intro H\n      cases y.1.IsPrime.mem_or_mem H <;> contradiction\n    \u00b7 simp only [Pi.mul_apply, RingHom.map_mul]\n      erw [\u2190 wa, \u2190 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))\u1d52\u1d56) :\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 \u22d9 forget CommRingCat \u2245 (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  \u27e8structurePresheafInCommRing 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)\u27e9\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 \u27f6 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 \u2264 D_g) : OX(V) [for api]\n2. def to_open (U) : R \u27f6 OX(U)\n3. [2] def to_stalk (p : Spec R) : R \u27f6 OX_p\n4. [2] def to_basic_open (f : R) : R_f \u27f6 OX(D_f)\n5. [3] def localization_to_stalk (p : Spec R) : R_p \u27f6 OX_p\n6. def open_to_localization (U) (p) (hp : p \u2208 U) : OX(U) \u27f6 R_p\n7. [6] def stalk_to_fiber_ring_hom (p : Spec R) : OX_p \u27f6 R_p\n8. [5,7] def stalk_iso (p : Spec R) : OX_p \u2245 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 \u2208 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 : \u2200 x \u2208 U, g \u2208 (x : PrimeSpectrum.top R).asIdeal.primeCompl) :\n    (structureSheaf R).1.obj (op U) :=\n  \u27e8fun x => IsLocalization.mk' _ f \u27e8g, hu x x.2\u27e9, fun x =>\n    \u27e8U, x.2, \ud835\udfd9 _, f, g, fun y => \u27e8hu y y.2, IsLocalization.mk'_spec _ _ _\u27e9\u27e9\u27e9\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 : \u2200 x \u2208 U, g \u2208 (x : PrimeSpectrum.top R).asIdeal.primeCompl) (x : U) :\n    (const R f g U hu).1 x = IsLocalization.mk' _ f \u27e8g, hu x x.2\u27e9 :=\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 : \u2200 x \u2208 U, g \u2208 (x : PrimeSpectrum.top R).asIdeal.primeCompl) (x : U)\n    (hx : g \u2208 (asIdeal (x : PrimeSpectrum.top R)).primeCompl) :\n    (const R f g U hu).1 x = IsLocalization.mk' _ f \u27e8g, hx\u27e9 :=\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 \u2208 U) :\n    \u2203 (V : Opens (PrimeSpectrum.top R))(hxV : x \u2208 V)(i : V \u27f6 U)(f g : R)(hg : _),\n      const R f g V hg = (structureSheaf R).1.map i.op s :=\n  let \u27e8V, hxV, iVU, f, g, hfg\u27e9 := s.2 \u27e8x, hx\u27e9\n  \u27e8V, hxV, iVU, f, g, fun y hyV => (hfg \u27e8y, hyV\u27e9).1,\n    Subtype.eq <| funext fun y => IsLocalization.mk'_eq_iff_eq_mul.2 <| Eq.symm <| (hfg y).2\u27e9\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\u2081 f\u2082 g\u2081 g\u2082 : R) (U hu\u2081 hu\u2082) :\n    const R f\u2081 g\u2081 U hu\u2081 + const R f\u2082 g\u2082 U hu\u2082 =\n      const R (f\u2081 * g\u2082 + f\u2082 * g\u2081) (g\u2081 * g\u2082) U fun x hx =>\n        Submonoid.mul_mem _ (hu\u2081 x hx) (hu\u2082 x hx) :=\n  Subtype.eq <|\n    funext fun x =>\n      Eq.symm <| by convert IsLocalization.mk'_add f\u2081 f\u2082 \u27e8g\u2081, hu\u2081 x x.2\u27e9 \u27e8g\u2082, hu\u2082 x x.2\u27e9\n#align algebraic_geometry.structure_sheaf.const_add AlgebraicGeometry.StructureSheaf.const_add\n\ntheorem const_mul (f\u2081 f\u2082 g\u2081 g\u2082 : R) (U hu\u2081 hu\u2082) :\n    const R f\u2081 g\u2081 U hu\u2081 * const R f\u2082 g\u2082 U hu\u2082 =\n      const R (f\u2081 * f\u2082) (g\u2081 * g\u2082) U fun x hx => Submonoid.mul_mem _ (hu\u2081 x hx) (hu\u2082 x hx) :=\n  Subtype.eq <|\n    funext fun x =>\n      Eq.symm <| by convert IsLocalization.mk'_mul _ f\u2081 f\u2082 \u27e8g\u2081, hu\u2081 x x.2\u27e9 \u27e8g\u2082, hu\u2082 x x.2\u27e9\n#align algebraic_geometry.structure_sheaf.const_mul AlgebraicGeometry.StructureSheaf.const_mul\n\ntheorem const_ext {f\u2081 f\u2082 g\u2081 g\u2082 : R} {U hu\u2081 hu\u2082} (h : f\u2081 * g\u2082 = f\u2082 * g\u2081) :\n    const R f\u2081 g\u2081 U hu\u2081 = const R f\u2082 g\u2082 U hu\u2082 :=\n  Subtype.eq <|\n    funext fun x =>\n      IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, \u2190 h, mul_comm, Subtype.coe_mk])\n#align algebraic_geometry.structure_sheaf.const_ext AlgebraicGeometry.StructureSheaf.const_ext\n\ntheorem const_congr {f\u2081 f\u2082 g\u2081 g\u2082 : R} {U hu} (hf : f\u2081 = f\u2082) (hg : g\u2081 = g\u2082) :\n    const R f\u2081 g\u2081 U hu = const R f\u2082 g\u2082 U (hg \u25b8 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\u2081 hu\u2082) : const R f g U hu\u2081 * const R g f U hu\u2082 = 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\u2081 g\u2082 : R) (U hu\u2081 hu\u2082) :\n    const R f g\u2081 U hu\u2081 * const R g\u2081 g\u2082 U hu\u2082 = const R f g\u2082 U hu\u2082 :=\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\u2081 g\u2082 : R) (U hu\u2081 hu\u2082) :\n    const R g\u2081 g\u2082 U hu\u2082 * const R f g\u2081 U hu\u2081 = const R f g\u2082 U hu\u2082 := 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 \u27f6 (structureSheaf R).1.obj (op U)\n    where\n  toFun f :=\n    \u27e8fun x => algebraMap R _ f, fun x =>\n      \u27e8U, x.2, \ud835\udfd9 _, f, 1, fun y =>\n        \u27e8(Ideal.ne_top_iff_one _).1 y.1.2.1,\n          by\n          rw [RingHom.map_one, mul_one]\n          rfl\u27e9\u27e9\u27e9\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 \u27f6 U) :\n    toOpen R U \u226b (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 \u27f6 (structureSheaf R).Presheaf.stalk x :=\n  (toOpen R \u22a4 \u226b (structureSheaf R).Presheaf.germ \u27e8x, \u27e8\u27e9\u27e9 : _)\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 \u226b (structureSheaf R).Presheaf.germ x = toStalk R x :=\n  by\n  rw [\u2190 to_open_res R \u22a4 U (hom_of_le le_top : U \u27f6 \u22a4), 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 [\u2190 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 (\u27e8x, trivial\u27e9 : (\u22a4 : Opens (PrimeSpectrum.top R)))\n        (toOpen R \u22a4 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 [\u2190 germ_to_open R (basic_open (f : R)) \u27e8x, f.2\u27e9 (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) \u27f6 (structureSheaf R).Presheaf.stalk x :=\n  show Localization.AtPrime x.asIdeal \u2192+* _ 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 (\u27e8x, s.2\u27e9 : basicOpen (s : R))\n        (const R f s (basicOpen s) fun _ => id) :=\n  (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by\n    erw [\u2190 germ_to_open R (basic_open s) \u27e8x, s.2\u27e9, \u2190 germ_to_open R (basic_open s) \u27e8x, s.2\u27e9, \u2190\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 \u2208 U) :\n    (structureSheaf R).1.obj (op U) \u27f6 CommRingCat.of (Localization.AtPrime x.asIdeal)\n    where\n  toFun s := (s.1 \u27e8x, hx\u27e9 : _)\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 \u2208 U) :\n    (openToLocalization R U x hx :\n        (structureSheaf R).1.obj (op U) \u2192 Localization.AtPrime x.asIdeal) =\n      fun s => (s.1 \u27e8x, hx\u27e9 : _) :=\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 \u2208 U) (s : (structureSheaf R).1.obj (op U)) :\n    openToLocalization R U x hx s = (s.1 \u27e8x, hx\u27e9 : _) :=\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 \u27f6 CommRingCat.of (Localization.AtPrime x.asIdeal) :=\n  Limits.colimit.desc ((OpenNhds.inclusion x).op \u22d9 (structureSheaf R).1)\n    { X := _\n      \u03b9 :=\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 \u226b stalkToFiberRingHom R x = openToLocalization R U x x.2 :=\n  Limits.colimit.\u03b9_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 \u2208 U) (s : (structureSheaf R).1.obj (op U)) :\n    stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ \u27e8x, hx\u27e9 s) = (s.1 \u27e8x, hx\u27e9 : _) :=\n  RingHom.ext_iff.1 (germ_comp_stalkToFiberRingHom R U \u27e8x, hx\u27e9 : _) 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 \u226b stalkToFiberRingHom R x = (algebraMap _ _ : R \u2192+* 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 \u2245 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 \u27e8V, hxV, iVU, f, g, hg, hs\u27e9 := exists_const _ _ s x hxU\n      erw [\u2190 res_apply R U V iVU s \u27e8x, hxV\u27e9, \u2190 hs, const_apply, localization_to_stalk_mk']\n      refine' (structure_sheaf R).Presheaf.germ_ext V hxV (hom_of_le hg) iVU _\n      erw [\u2190 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 \u226b localizationToStalk R x = \ud835\udfd9 _ :=\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 \u226b stalkToFiberRingHom R x = \ud835\udfd9 _ :=\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 \u2208 R_f` as a section of the structure sheaf\non the basic open defined by `f \u2208 R`. -/\ndef toBasicOpen (f : R) : Localization.Away f \u2192+* (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 \u27e8a, \u27e8b, hb\u27e9, rfl\u27e9 := IsLocalization.mk'_surjective (Submonoid.powers f) s\n  obtain \u27e8c, \u27e8d, hd\u27e9, rfl\u27e9 := 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\u2081 r\u2082 hr\u2081 hr\u2082 => by\n        dsimp at hr\u2081 hr\u2082\u22a2\n        simp only [add_mul, hr\u2081, hr\u2082]\n      smul_mem' := fun r\u2081 r\u2082 hr\u2082 => by\n        dsimp at hr\u2082\u22a2\n        simp only [mul_assoc, hr\u2082] }\n  -- Our claim now reduces to showing that `f` is contained in the radical of `I`\n  suffices f \u2208 I.radical by\n    cases' this with n hn\n    exact \u27e8\u27e8f ^ n, n, rfl\u27e9, hn\u27e9\n  rw [\u2190 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) \u27e8p, hfp\u27e9\n  rw [const_apply, const_apply, IsLocalization.eq] at this\n  cases' this with r hr\n  exact \u27e8r.1, hr, r.2\u27e9\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    \u2203 (f g : R)(i : basicOpen g \u27f6 U),\n      x.1 \u2208 basicOpen g \u2227\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 \u27e8V, hxV : x.1 \u2208 V.1, iVU, f, g, hVDg : V \u2264 basic_open g, s_eq\u27e9 :=\n    exists_const R U s x.1 x.2\n  obtain \u27e8_, \u27e8h, rfl\u27e9, hxDh, hDhV : basic_open h \u2264 V\u27e9 :=\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 \u2264 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 [\u2190 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 \u226b 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 \u226b iVU, (basic_opens_eq.symm.le : _) hxDh\n  rw [op_comp, functor.map_comp, comp_apply, \u2190 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  \u00b7 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 \u00abexpr \u2208 \u00bb 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)) {\u03b9 : Type _} (t : Finset \u03b9) (a h : \u03b9 \u2192 R)\n    (iDh : \u2200 i : \u03b9, basicOpen (h i) \u27f6 U) (h_cover : U \u2264 \u2a06 i \u2208 t, basicOpen (h i))\n    (hs :\n      \u2200 i : \u03b9,\n        (const R (a i) (h i) (basicOpen (h i)) fun y hy => hy) =\n          (structureSheaf R).1.map (iDh i).op s) :\n    \u2203 (a' h' : \u03b9 \u2192 R)(iDh' : \u2200 i : \u03b9, basicOpen (h' i) \u27f6 U),\n      (U \u2264 \u2a06 i \u2208 t, basicOpen (h' i)) \u2227\n        (\u2200 (i) (_ : i \u2208 t) (j) (_ : j \u2208 t), a' i * h' j = h' i * a' j) \u2227\n          \u2200 i \u2208 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    \u2200 i j : \u03b9,\n      IsLocalization.mk' (Localization.Away _) (a i * h j) \u27e8h i * h j, Submonoid.mem_powers _\u27e9 =\n        IsLocalization.mk' _ (h i * a j) \u27e8h i * h j, Submonoid.mem_powers _\u27e9 :=\n    by\n    intro i j\n    let D := basic_open (h i * h j)\n    let iDi : D \u27f6 basic_open (h i) := hom_of_le (basic_open_mul_le_left _ _)\n    let iDj : D \u27f6 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    \u2200 i j : \u03b9, \u2203 n : \u2115, 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 \u27e8\u27e8c, n, rfl\u27e9, hc\u27e9 := 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 : \u03b9 \u00d7 \u03b9 => (exists_power p.1 p.2).some\n  have n_spec := fun p : \u03b9 \u00d7 \u03b9 => (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 \u00d7\u02e2 t).sup n\n  have basic_opens_eq : \u2200 i : \u03b9, 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    \u27e8fun i => a i * h i ^ N, fun i => h i ^ (N + 1), fun i => eq_to_hom (basic_opens_eq i) \u226b iDh i,\n      _, _, _\u27e9\n  \u00b7 simpa only [basic_opens_eq] using h_cover\n  \u00b7 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) \u2264 N := Finset.le_sup (finset.mem_product.mpr \u27e8hi, hj\u27e9)\n    cases' Nat.le.dest n_le_N with k hk\n    simp only [\u2190 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      \u00b7 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, \u2190 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 `\u03b9` that is used whenever we want think of it as an indexing type.\n  let \u03b9 : 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 \u27e8t, ht_cover'\u27e9 :=\n    (is_compact_basic_open f).elim_finite_subcover (fun i : \u03b9 => basic_open (h' i))\n      (fun i => is_open_basic_open) fun x hx => _\n  swap\n  \u00b7 -- Here, we need to show that our basic opens actually form a cover of `basic_open f`\n    rw [Set.mem_union\u1d62]\n    exact \u27e8\u27e8x, hx\u27e9, hxDh' \u27e8x, hx\u27e9\u27e9\n  simp only [\u2190 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 \u27e8a, h, iDh, ht_cover, ah_ha, s_eq\u27e9 :=\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 [\u2190 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 \u27e8n, hn\u27e9 : f \u2208 (Ideal.span (h '' \u2191t)).radical :=\n    by\n    rw [\u2190 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\u1d62, compl_compl, \u2190 zero_locus_Union, \u2190 Finset.set_bunion\u1d62_coe, \u2190\n      Set.image_eq_union\u1d62] 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 [\u2190 pow_succ, Finsupp.mem_span_image_iff_total] at hn\n  rcases hn with \u27e8b, b_supp, hb\u27e9\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 `(\u2211 (i : \u03b9) in t, b i * a i) / f ^ (n+1)`\n  use\n    IsLocalization.mk' (Localization.Away f) (\u2211 i : \u03b9 in t, b i * a i)\n      (\u27e8f ^ (n + 1), n + 1, rfl\u27e9 : 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  \u00b7 -- 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\u1d62]\n    have := ht_cover hx\n    rw [\u2190 Finset.set_bunion\u1d62_coe, Set.mem_union\u1d62\u2082] at this\n    rcases this with \u27e8i, i_mem, x_mem\u27e9\n    use i, i_mem\n  rintro \u27e8i, hi\u27e9\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  \u00b7 intro y hy\n    change y \u2208 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 [\u2190 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 _ \u27f6 _ from toBasicOpen R f) :=\n  haveI : is_iso ((forget CommRingCat).map (show CommRingCat.of _ \u27f6 _ from to_basic_open R f)) :=\n    (is_iso_iff_bijective _).mpr \u27e8to_basic_open_injective R f, to_basic_open_surjective R f\u27e9\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)) \u2245 CommRingCat.of (Localization.Away f) :=\n  (asIso (show CommRingCat.of _ \u27f6 _ 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))\u1d52\u1d56) : 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))\u1d52\u1d56) (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  \u27e8fun 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\u27e9\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 \u22a4 =\n      CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R))) \u226b\n        toBasicOpen R (1 : R) \u226b (structureSheaf R).1.map (eqToHom basicOpen_one.symm).op :=\n  by\n  rw [\u2190 category.assoc]\n  change to_open R \u22a4 = (to_basic_open R 1).comp _ \u226b _\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 \u22a4) :=\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 `\u0393(X, \ud835\udcaa\u2093)`. -/\n@[simps (config := { rhsMd := Tactic.Transparency.semireducible })]\ndef globalSectionsIso : CommRingCat.of R \u2245 (structureSheaf R).1.obj (op \u22a4) :=\n  asIso (toOpen R \u22a4)\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 \u22a4 :=\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 \u2933 y) :\n    toStalk R y \u226b (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 \u2933 y) :\n    StructureSheaf.localizationToStalk R y \u226b (structureSheaf R).Presheaf.stalkSpecializes h =\n      CommRingCat.ofHom (PrimeSpectrum.localizationMapOfSpecializes h) \u226b\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 \u2933 y) :\n    (structureSheaf R).Presheaf.stalkSpecializes h \u226b StructureSheaf.stalkToFiberRingHom R x =\n      StructureSheaf.stalkToFiberRingHom R y \u226b PrimeSpectrum.localizationMapOfSpecializes h :=\n  by\n  change _ \u226b (structure_sheaf.stalk_iso R x).hom = (structure_sheaf.stalk_iso R y).hom \u226b _\n  rw [\u2190 iso.eq_comp_inv, category.assoc, \u2190 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 \u2192+* 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 \u2286 (comap f) \u207b\u00b9' 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 : \u03a0 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 \u2192+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpectrum.top S))\n    (hUV : V.1 \u2286 PrimeSpectrum.comap f \u207b\u00b9' U.1) (s : \u2200 x : U, Localizations R x) (y : V) :\n    Localizations S y :=\n  Localization.localRingHom (PrimeSpectrum.comap f y.1).asIdeal _ f rfl\n    (s \u27e8PrimeSpectrum.comap f y.1, hUV y.2\u27e9 : _)\n#align algebraic_geometry.structure_sheaf.comap_fun AlgebraicGeometry.StructureSheaf.comapFun\n\ntheorem comapFun_isLocallyFraction (f : R \u2192+* S) (U : Opens (PrimeSpectrum.top R))\n    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 \u2286 PrimeSpectrum.comap f \u207b\u00b9' U.1)\n    (s : \u2200 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 \u27e8p, hpV\u27e9\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 \u27e8PrimeSpectrum.comap f p, hUV hpV\u27e9 with \u27e8W, m, iWU, a, b, h_frac\u27e9\n  -- We claim that we can write our new section as the fraction `f a / f b` on the neighborhood\n  -- `(comap f) \u207b\u00b9 W \u2293 V` of `p`.\n  refine' \u27e8opens.comap (comap f) W \u2293 V, \u27e8m, hpV\u27e9, opens.inf_le_right _ _, f a, f b, _\u27e9\n  rintro \u27e8q, \u27e8hqW, hqV\u27e9\u27e9\n  specialize h_frac \u27e8PrimeSpectrum.comap f q, hqW\u27e9\n  refine' \u27e8h_frac.1, _\u27e9\n  dsimp only [comap_fun]\n  erw [\u2190 Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal, \u2190 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 \u2192+* S` and open sets `U` and `V` of the prime spectra of `R` and\n`S` such that `V \u2286 (comap f) \u207b\u00b9 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 \u2192+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpectrum.top S))\n    (hUV : V.1 \u2286 PrimeSpectrum.comap f \u207b\u00b9' U.1) :\n    (structureSheaf R).1.obj (op U) \u2192+* (structureSheaf S).1.obj (op V)\n    where\n  toFun s := \u27e8comapFun f U V hUV s.1, comapFun_isLocallyFraction f U V hUV s.1 s.2\u27e9\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 \u2192+* S) (U : Opens (PrimeSpectrum.top R))\n    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 \u2286 PrimeSpectrum.comap f \u207b\u00b9' 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 \u27e8PrimeSpectrum.comap f p.1, hUV p.2\u27e9 : _) :=\n  rfl\n#align algebraic_geometry.structure_sheaf.comap_apply AlgebraicGeometry.StructureSheaf.comap_apply\n\ntheorem comap_const (f : R \u2192+* S) (U : Opens (PrimeSpectrum.top R))\n    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 \u2286 PrimeSpectrum.comap f \u207b\u00b9' U.1) (a b : R)\n    (hb : \u2200 x : PrimeSpectrum R, x \u2208 U \u2192 b \u2208 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 \u27f6 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 \u27f6 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 \u27e8W, hpW, iWU, h\u27e9 := s.2 (iVU p)\n        obtain \u27e8a, b, h'\u27e9 := h.eq_mk'\n        obtain \u27e8hb\u2081, s_eq\u2081\u27e9 := h' \u27e8p, hpW\u27e9\n        obtain \u27e8hb\u2082, s_eq\u2082\u27e9 :=\n          h' \u27e8PrimeSpectrum.comap (RingHom.id _) p.1, by rwa [PrimeSpectrum.comap_id]\u27e9\n        dsimp only at s_eq\u2081 s_eq\u2082\n        erw [s_eq\u2082, Localization.localRingHom_mk', \u2190 s_eq\u2081, \u2190 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 \u2192+* S) (g : S \u2192+* P) (U : Opens (PrimeSpectrum.top R))\n    (V : Opens (PrimeSpectrum.top S)) (W : Opens (PrimeSpectrum.top P))\n    (hUV : \u2200 p \u2208 V, PrimeSpectrum.comap f p \u2208 U) (hVW : \u2200 p \u2208 W, PrimeSpectrum.comap g p \u2208 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 \u2192+* S) (U : Opens (PrimeSpectrum.top R)) :\n    (toOpen R U \u226b comap f U (Opens.comap (PrimeSpectrum.comap f) U) fun _ => id) =\n      CommRingCat.ofHom f \u226b 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 (\u03b1 \u03b2 : Type u) (f : \u03b1 \u27f6 \u03b2) : (forget (Type u)).map f = f := rfl\n\ntheorem forall_congr_forget_Type (\u03b1 : Type u) (p : \u03b1 \u2192 Prop) :\n  (\u2200 (x : ConcreteCategory.Forget.obj \u03b1), p x) \u2194 \u2200 (x : \u03b1), 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 \u27f6 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 \u27f6 Y` in a category `C`\n(possibly after a `\u2200` binder), produce the equation `\u2200 (x : X), f x = g x` or\n`\u2200 [ConcreteCategory C] (x : X), f x = g x` as needed (after the `\u2200` 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 \u00d7 Option Level) := do\n  let type := (\u2190 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' \u2190 simpType (simpOnlyNames elementwiseThms (config := { decide := false })) eqPf\n      if (\u2190 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 := { \u2190 Simp.Context.mkDefault with config.decide := false }\n        let (ty', eqPf'') \u2190 simpEq (fun e => return (\u2190 simp e ctx).1) (\u2190 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 \u2190 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' \u2190 mkExpectedTypeHint eqPf'' ty'\n      if let some (w, instConcr) := instConcr? then\n        return (\u2190 Meta.mkLambdaFVars (fvars.push instConcr) eqPf', w)\n      else\n        return (\u2190 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 \u00d7 Expr) := do\n    let some (\u03b1, _, _) := eqTy.cleanupAnnotations.eq? | failure\n    let (``Quiver.Hom, #[_, instQuiv, _, _]) := \u03b1.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 {\u03b1} (eqTy eqPf : Expr) (k : Expr \u2192 Option (Level \u00d7 Expr) \u2192 MetaM \u03b1) :\n      MetaM \u03b1 := do\n    let (C, instC) \u2190 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' \u2190 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]) _ \u2190 inferType instC\n        | throwError \"internal error in elementwise\"\n      let w \u2190 mkFreshLevelMVar\n      let cty : Expr := mkApp2 (.const ``ConcreteCategory [w, v, u]) C instC\n      withLocalDecl `inst .instImplicit cty fun cfvar => do\n        let eqPf' \u2190 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 \u27f6 Y) (g : Y \u27f6 Z) (h : X \u27f6 Z) (w : ...) : f \u226b g = h := ...\n```\n\nproduces\n\n```lean\nlemma some_lemma_apply {C : Type _} [Category C]\n    {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) (h : X \u27f6 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 : ((\ud835\udfd9 X) : X \u2192 X) x = x` and\n`CategoryTheory.coe_comp : (f \u226b 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?) \u2190 elementwiseExpr src type value (simpSides := nosimp?.isNone)\n      let newLevels \u2190 if let some level := level? then do\n        let w := mkUnusedName levels `w\n        unless \u2190 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 \u27f6 Y` in a concrete category (possibly after a `\u2200` binder),\nproduces a proof of equation `\u2200 (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 \u27f6 N) (g : N \u27f6 K) (h : M \u27f6 K) (w : f \u226b 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 `\u2200 (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 \u2190 Term.elabTerm t none\n  let (pf, _) \u2190 elementwiseExpr .anonymous (\u2190 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 (\u03b1 : Type u) := reader_t (ulift \u2115) rand \u03b1\n\nvariable (\u03b1 : 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 {\u03b1} (x : gen \u03b1) (i : \u2115) : io \u03b1 :=\nio.run_rand (x.run \u27e8i\u27e9)\n\nnamespace gen\n\nsection rand\n\n/-- Lift `random.random` to the `gen` monad. -/\ndef choose_any [random \u03b1] : gen \u03b1 :=\n\u27e8 \u03bb _, rand.random \u03b1 \u27e9\n\nvariables {\u03b1} [preorder \u03b1]\n\n/-- Lift `random.random_r` to the `gen` monad. -/\ndef choose [bounded_random \u03b1] (x y : \u03b1) (p : x \u2264 y) : gen (x .. y) :=\n\u27e8 \u03bb _, rand.random_r x y p \u27e9\n\nend rand\n\nopen nat\n\n/-- Generate a `nat` example between `x` and `y`. -/\ndef choose_nat (x y : \u2115) (p : x \u2264 y) : gen (x .. y) :=\nchoose x y p\n\n/-- Generate a `nat` example between `x` and `y`. -/\ndef choose_nat' (x y : \u2115) (p : x < y) : gen (set.Ico x y) :=\nhave \u2200 i, x < i \u2192 i \u2264 y \u2192 i.pred < y,\n  from \u03bb i h\u2080 h\u2081,\n     show i.pred.succ \u2264 y,\n     by rwa succ_pred_eq_of_pos; apply lt_of_le_of_lt (nat.zero_le _) h\u2080,\nsubtype.map pred (\u03bb i (h : x+1 \u2264 i \u2227 i \u2264 y), \u27e8le_pred_of_lt h.1, this _ h.1 h.2\u27e9) <$>\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\u27e8 \u03bb \u03b1 x y, do\n  b \u2190 uliftable.up $ choose_any bool,\n  if b.down then x else y \u27e9\n\nvariable {\u03b1}\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 : \u2115 \u2192 gen \u03b1) : gen \u03b1 :=\n\u27e8 \u03bb \u27e8sz\u27e9, reader_t.run (cmd sz) \u27e8sz\u27e9 \u27e9\n\n/-- Apply a function to the size parameter. -/\ndef resize (f : \u2115 \u2192 \u2115) (cmd : gen \u03b1) : gen \u03b1 :=\n\u27e8 \u03bb \u27e8sz\u27e9, reader_t.run cmd \u27e8f sz\u27e9 \u27e9\n\n/-- Create `n` examples using `cmd`. -/\ndef vector_of : \u2200 (n : \u2115) (cmd : gen \u03b1), gen (vector \u03b1 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 \u03b1) : gen (list \u03b1) :=\nsized $ \u03bb sz, do\ndo \u27e8 n \u27e9 \u2190 uliftable.up $ choose_nat 0 (sz + 1) dec_trivial,\n   v \u2190 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 \u03b1)) (pos : 0 < xs.length) : gen \u03b1 := do\n\u27e8\u27e8n, h, h'\u27e9\u27e9 \u2190 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 \u03b1) (pos : 0 < xs.length) : gen \u03b1 := do\n\u27e8\u27e8n,h\u2080,h\u2081\u27e9\u27e9 \u2190 uliftable.up $ choose_nat' 0 xs.length pos,\npure $ list.nth_le xs n h\u2081\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 : \u03a0 (xs : list (\u2115+ \u00d7 gen \u03b1)) i, i < (xs.map (subtype.val \u2218 prod.fst)).sum \u2192 gen \u03b1\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 (\u2115+ \u00d7 gen \u03b1)) (pos : 0 < xs.length) : gen \u03b1 :=\nlet s := (xs.map (subtype.val \u2218 prod.fst)).sum in\nhave ha : 1 \u2264 s, from\n  (le_trans pos $\n    list.length_map (subtype.val \u2218 prod.fst) xs \u25b8\n      (list.length_le_sum_of_one_le _ (\u03bb i, by { simp, intros, assumption }))),\nhave 0 \u2264 s - 1, from le_tsub_of_add_le_right ha,\nuliftable.adapt_up gen.{0} gen.{u} (choose_nat 0 (s-1) this) $ \u03bb i,\nfreq_aux xs i.1 (by rcases i with \u27e8i,h\u2080,h\u2081\u27e9; rwa le_tsub_iff_right at h\u2081; exact ha)\n\n/-- Generate a random permutation of a given list. -/\ndef permutation_of {\u03b1 : Type u} : \u03a0 xs : list \u03b1, gen (subtype $ list.perm xs)\n| [] := pure \u27e8[], list.perm.nil \u27e9\n| (x :: xs) := do\n\u27e8xs',h\u27e9 \u2190 permutation_of xs,\n\u27e8\u27e8n,_,h'\u27e9\u27e9 \u2190 uliftable.up $ choose_nat 0 xs'.length dec_trivial,\npure \u27e8list.insert_nth n x xs',\n  list.perm.trans (list.perm.cons _ h)\n    (list.perm_insert_nth _ _ h').symm \u27e9\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 (\u00abhave\u00bb)\n\nexample (a b : \u2115) (h : a = b) : b = a := eq.symm h\n\nmeta def my_symm : tactic unit := \ndo \n  eq1 \u2190 get_local `h,\n  \u00abhave\u00bb none none ``(eq.symm %%eq1) \n\nexample (a b : \u2115) (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 \u2190 get_local eq1,\n  \u00abhave\u00bb none none ``(eq.symm %%eq1)\n\nexample (a b : \u2115) (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 \u03b1 \u03b2 \u03b3 : Type _}\n\nvariable [Monoid \u03b1] {s t : Set \u03b1} {a : \u03b1} {m n : \u2115}\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 {\u03b1 : Type.{u1}} [_inst_1 : Monoid.{u1} \u03b1] {n : Nat} {a : \u03b1} {s : (Fin n) -> (Set.{u1} \u03b1)}, Iff (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (List.prod.{u1} (Set.{u1} \u03b1) (Set.mul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (Set.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (List.ofFn.{u1} (Set.{u1} \u03b1) n s))) (Exists.{succ u1} (forall (i : Fin n), coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (s i)) (fun (f : forall (i : Fin n), coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (s i)) => Eq.{succ u1} \u03b1 (List.prod.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (List.ofFn.{u1} \u03b1 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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (s i)) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (s i)) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (s i)) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (s i)) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (s i)))))) (f i)))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Monoid.{u1} \u03b1] {n : Nat} {a : \u03b1} {s : (Fin n) -> (Set.{u1} \u03b1)}, Iff (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) a (List.prod.{u1} (Set.{u1} \u03b1) (Set.mul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (Set.one.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 _inst_1)) (List.ofFn.{u1} (Set.{u1} \u03b1) n s))) (Exists.{succ u1} (forall (i : Fin n), Set.Elem.{u1} \u03b1 (s i)) (fun (f : forall (i : Fin n), Set.Elem.{u1} \u03b1 (s i)) => Eq.{succ u1} \u03b1 (List.prod.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (Monoid.toOne.{u1} \u03b1 _inst_1) (List.ofFn.{u1} \u03b1 n (fun (i : Fin n) => Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) 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\u2093'. -/\n@[to_additive]\ntheorem mem_prod_list_ofFn {a : \u03b1} {s : Fin n \u2192 Set \u03b1} :\n    a \u2208 (List.ofFn s).Prod \u2194 \u2203 f : \u2200 i : Fin n, s i, (List.ofFn fun i => (f i : \u03b1)).Prod = a :=\n  by\n  induction' n with n ih generalizing a\n  \u00b7 simp_rw [List.ofFn_zero, List.prod_nil, Fin.exists_fin_zero_pi, eq_comm, Set.mem_one]\n  \u00b7\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 {\u03b1 : Type.{u1}} [_inst_1 : Monoid.{u1} \u03b1] {l : List.{u1} (Set.{u1} \u03b1)} {a : \u03b1}, Iff (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (List.prod.{u1} (Set.{u1} \u03b1) (Set.mul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (Set.one.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) l)) (Exists.{succ u1} (List.{u1} (Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s))) (fun (l' : List.{u1} (Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s))) => And (Eq.{succ u1} \u03b1 (List.prod.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (List.map.{u1, u1} (Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)) \u03b1 (fun (x : Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) 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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Sigma.fst.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) x)) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Sigma.fst.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) x)) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Sigma.fst.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) x)) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Sigma.fst.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) x)) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x_1 : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x_1 (Sigma.fst.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) x)))))) (Sigma.snd.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) x)) l')) a) (Eq.{succ u1} (List.{u1} (Set.{u1} \u03b1)) (List.map.{u1, u1} (Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)) (Set.{u1} \u03b1) (Sigma.fst.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)) l') l)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Monoid.{u1} \u03b1] {l : List.{u1} (Set.{u1} \u03b1)} {a : \u03b1}, Iff (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) a (List.prod.{u1} (Set.{u1} \u03b1) (Set.mul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1))) (Set.one.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 _inst_1)) l)) (Exists.{succ u1} (List.{u1} (Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => Set.Elem.{u1} \u03b1 s))) (fun (l' : List.{u1} (Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => Set.Elem.{u1} \u03b1 s))) => And (Eq.{succ u1} \u03b1 (List.prod.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (Monoid.toOne.{u1} \u03b1 _inst_1) (List.map.{u1, u1} (Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => Set.Elem.{u1} \u03b1 s)) \u03b1 (fun (x : Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => Set.Elem.{u1} \u03b1 s)) => Subtype.val.{succ u1} \u03b1 (fun (x_1 : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x_1 (Sigma.fst.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => Set.Elem.{u1} \u03b1 s) x)) (Sigma.snd.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => Set.Elem.{u1} \u03b1 s) x)) l')) a) (Eq.{succ u1} (List.{u1} (Set.{u1} \u03b1)) (List.map.{u1, u1} (Sigma.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => Set.Elem.{u1} \u03b1 s)) (Set.{u1} \u03b1) (Sigma.fst.{u1, u1} (Set.{u1} \u03b1) (fun (s : Set.{u1} \u03b1) => Set.Elem.{u1} \u03b1 s)) l') l)))\nCase conversion may be inaccurate. Consider using '#align set.mem_list_prod Set.mem_list_prod\u2093'. -/\n@[to_additive]\ntheorem mem_list_prod {l : List (Set \u03b1)} {a : \u03b1} :\n    a \u2208 l.Prod \u2194\n      \u2203 l' : List (\u03a3s : Set \u03b1, \u21a5s),\n        List.prod (l'.map fun x => (Sigma.snd x : \u03b1)) = a \u2227 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  \u00b7 rintro \u27e8fi, rfl\u27e9\n    exact \u27e8fun i => \u27e8_, fi i\u27e9, rfl, rfl\u27e9\n  \u00b7 rintro \u27e8fi, rfl, rfl\u27e9\n    exact \u27e8fun i => _, rfl\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : Monoid.{u1} \u03b1] {s : Set.{u1} \u03b1} {a : \u03b1} {n : Nat}, Iff (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a (HPow.hPow.{u1, 0, u1} (Set.{u1} \u03b1) Nat (Set.{u1} \u03b1) (instHPow.{u1, 0} (Set.{u1} \u03b1) Nat (Set.NPow.{u1} \u03b1 (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)))) s n)) (Exists.{succ u1} ((Fin n) -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)) (fun (f : (Fin n) -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)) => Eq.{succ u1} \u03b1 (List.prod.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (MulOneClass.toHasOne.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (List.ofFn.{u1} \u03b1 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} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (HasLiftT.mk.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (CoeTC\u2093.coe.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeBase.{succ u1, succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s) \u03b1 (coeSubtype.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s))))) (f i)))) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : Monoid.{u1} \u03b1] {s : Set.{u1} \u03b1} {a : \u03b1} {n : Nat}, Iff (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) a (HPow.hPow.{u1, 0, u1} (Set.{u1} \u03b1) Nat (Set.{u1} \u03b1) (instHPow.{u1, 0} (Set.{u1} \u03b1) Nat (Set.NPow.{u1} \u03b1 (Monoid.toOne.{u1} \u03b1 _inst_1) (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)))) s n)) (Exists.{succ u1} ((Fin n) -> (Set.Elem.{u1} \u03b1 s)) (fun (f : (Fin n) -> (Set.Elem.{u1} \u03b1 s)) => Eq.{succ u1} \u03b1 (List.prod.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 _inst_1)) (Monoid.toOne.{u1} \u03b1 _inst_1) (List.ofFn.{u1} \u03b1 n (fun (i : Fin n) => Subtype.val.{succ u1} \u03b1 (fun (x : \u03b1) => Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) (f i)))) a))\nCase conversion may be inaccurate. Consider using '#align set.mem_pow Set.mem_pow\u2093'. -/\n@[to_additive]\ntheorem mem_pow {a : \u03b1} {n : \u2115} :\n    a \u2208 s ^ n \u2194 \u2203 f : Fin n \u2192 s, (List.ofFn fun i => (f i : \u03b1)).Prod = a := by\n  rw [\u2190 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\u2082, ..., a\u2099]` is a `chain` starting at `a\u2081` with respect to the relation `r` if `r a\u2081 a\u2082`\nand `r a\u2082 a\u2083` and ... and `r a\u2099\u208b\u2081 a\u2099`. We write it `chain r a\u2081 [a\u2082, ..., a\u2099]`.\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 {\u03b1 : Type u} {\u03b2 : Type v} {R r : \u03b1 \u2192 \u03b1 \u2192 Prop} {l l\u2081 l\u2082 : list \u03b1} {a b : \u03b1}\n\nmk_iff_of_inductive_prop list.chain list.chain_iff\n\ntheorem rel_of_chain_cons {a b : \u03b1} {l : list \u03b1}\n  (p : chain R a (b :: l)) : R a b :=\n(chain_cons.1 p).1\n\ntheorem chain_of_chain_cons {a b : \u03b1} {l : list \u03b1}\n  (p : chain R a (b :: l)) : chain R b l :=\n(chain_cons.1 p).2\n\ntheorem chain.imp' {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (HRS : \u2200 \u2983a b\u2984, R a b \u2192 S a b) {a b : \u03b1} (Hab : \u2200 \u2983c\u2984, R a c \u2192 S b c)\n  {l : list \u03b1} (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 : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b) {a : \u03b1} {l : list \u03b1} (p : chain R a l) : chain S a l :=\np.imp' H (H a)\n\ntheorem chain.iff {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2194 S a b) {a : \u03b1} {l : list \u03b1} : chain R a l \u2194 chain S a l :=\n\u27e8chain.imp (\u03bb a b, (H a b).1), chain.imp (\u03bb a b, (H a b).2)\u27e9\n\ntheorem chain.iff_mem {a : \u03b1} {l : list \u03b1} :\n  chain R a l \u2194 chain (\u03bb x y, x \u2208 a :: l \u2227 y \u2208 l \u2227 R x y) a l :=\n\u27e8\u03bb p, by induction p with _ a b l r p IH; constructor;\n  [exact \u27e8mem_cons_self _ _, mem_cons_self _ _, r\u27e9,\n   exact IH.imp (\u03bb a b \u27e8am, bm, h\u27e9,\n    \u27e8mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h\u27e9)],\n chain.imp (\u03bb a b h, h.2.2)\u27e9\n\ntheorem chain_singleton {a b : \u03b1} : chain R a [b] \u2194 R a b :=\nby simp only [chain_cons, chain.nil, and_true]\n\ntheorem chain_split {a b : \u03b1} {l\u2081 l\u2082 : list \u03b1} : chain R a (l\u2081 ++ b :: l\u2082) \u2194\n  chain R a (l\u2081 ++ [b]) \u2227 chain R b l\u2082 :=\nby induction l\u2081 with x l\u2081 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 : \u03b1} {l\u2081 l\u2082 : list \u03b1} :\n  chain R a (l\u2081 ++ b :: c :: l\u2082) \u2194 chain R a (l\u2081 ++ [b]) \u2227 R b c \u2227 chain R c l\u2082 :=\nby rw [chain_split, chain_cons]\n\ntheorem chain_iff_forall\u2082 :\n  \u2200 {a : \u03b1} {l : list \u03b1}, chain R a l \u2194 l = [] \u2228 forall\u2082 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\u2082 b]\n\ntheorem chain_append_singleton_iff_forall\u2082 :\n  chain R a (l ++ [b]) \u2194 forall\u2082 R (a :: l) (l ++ [b]) :=\nby simp [chain_iff_forall\u2082, init]\n\ntheorem chain_map (f : \u03b2 \u2192 \u03b1) {b : \u03b2} {l : list \u03b2} :\n  chain R (f b) (map f l) \u2194 chain (\u03bb a b : \u03b2, 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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, S (f a) (f b) \u2192 R a b) {a : \u03b1} {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, R a b \u2192 S (f a) (f b)) {a : \u03b1} {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} {p : \u03b1 \u2192 Prop}\n  {f : \u03a0 a, p a \u2192 \u03b2}\n  (H : \u2200 a b ha hb, R a b \u2192 S (f a ha) (f b hb))\n  {a : \u03b1} {l : list \u03b1}\n  (hl\u2081 : chain R a l) (ha : p a) (hl\u2082 : \u2200 a \u2208 l, p a) :\n  chain S (f a ha) (list.pmap f l hl\u2082) :=\nbegin\n  induction l with lh lt l_ih generalizing a,\n  { simp },\n  { simp [H _ _ _ _ (rel_of_chain_cons hl\u2081), l_ih _ (chain_of_chain_cons hl\u2081)] }\nend\n\ntheorem chain_of_chain_pmap {S : \u03b2 \u2192 \u03b2 \u2192 Prop} {p : \u03b1 \u2192 Prop}\n  (f : \u03a0 a, p a \u2192 \u03b2) {l : list \u03b1} (hl\u2081 : \u2200 a \u2208 l, p a)\n  {a : \u03b1} (ha : p a) (hl\u2082 : chain S (f a ha) (list.pmap f l hl\u2081))\n  (H : \u2200 a b ha hb, S (f a ha) (f b hb) \u2192 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\u2082), l_ih _ _ (chain_of_chain_cons hl\u2082)] }\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 \u27e8r.1, IH r'\u27e9\nend\n\nprotected lemma chain.pairwise [is_trans \u03b1 R] :\n  \u2200 {a : \u03b1} {l : list \u03b1}, chain R a l \u2192 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 \u03bb c hc, trans h (rel_of_pairwise_cons hb.pairwise hc),\n  end\n\ntheorem chain_iff_pairwise [is_trans \u03b1 R] {a : \u03b1} {l : list \u03b1} :\n  chain R a l \u2194 pairwise R (a :: l) :=\n\u27e8chain.pairwise, pairwise.chain\u27e9\n\nprotected lemma chain.sublist [is_trans \u03b1 R] (hl : l\u2082.chain R a) (h : l\u2081 <+ l\u2082) : l\u2081.chain R a :=\nby { rw chain_iff_pairwise at \u22a2 hl, exact hl.sublist (h.cons_cons a) }\n\nprotected lemma chain.rel [is_trans \u03b1 R] (hl : l.chain R a) (hb : b \u2208 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} : \u2200 {a : \u03b1} {l : list \u03b1},\n  chain R a l \u2194 (\u2200 h : 0 < length l, R a (nth_le l 0 h)) \u2227 (\u2200 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 \u27e8R, \u27e8h0, h\u27e9\u27e9,\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 \u27e8h0, h\u27e9, 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 : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2192 S a b) {l : list \u03b1} (p : chain' R l) : chain' S l :=\nby cases l; [trivial, exact p.imp H]\n\ntheorem chain'.iff {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  (H : \u2200 a b, R a b \u2194 S a b) {l : list \u03b1} : chain' R l \u2194 chain' S l :=\n\u27e8chain'.imp (\u03bb a b, (H a b).1), chain'.imp (\u03bb a b, (H a b).2)\u27e9\n\ntheorem chain'.iff_mem : \u2200 {l : list \u03b1}, chain' R l \u2194 chain' (\u03bb x y, x \u2208 l \u2227 y \u2208 l \u2227 R x y) l\n| []       := iff.rfl\n| (x :: l) :=\n  \u27e8\u03bb h, (chain.iff_mem.1 h).imp $ \u03bb a b \u27e8h\u2081, h\u2082, h\u2083\u27e9, \u27e8h\u2081, or.inr h\u2082, h\u2083\u27e9,\n   chain'.imp $ \u03bb a b h, h.2.2\u27e9\n\n@[simp] theorem chain'_nil : chain' R [] := trivial\n\n@[simp] theorem chain'_singleton (a : \u03b1) : chain' R [a] := chain.nil\n\n@[simp] theorem chain'_cons {x y l} : chain' R (x :: y :: l) \u2194 R x y \u2227 chain' R (y :: l) :=\nchain_cons\n\ntheorem chain'_is_infix : \u2200 l : list \u03b1, chain' (\u03bb x y, [x, y] <:+: l) l\n| [] := chain'_nil\n| [a] := chain'_singleton _\n| (a::b::l) := chain'_cons.2 \u27e8\u27e8[], l, by simp\u27e9,\n  (chain'_is_infix (b::l)).imp $ \u03bb x y h, h.trans \u27e8[a], [], by simp\u27e9\u27e9\n\ntheorem chain'_split {a : \u03b1} : \u2200 {l\u2081 l\u2082 : list \u03b1}, chain' R (l\u2081 ++ a :: l\u2082) \u2194\n  chain' R (l\u2081 ++ [a]) \u2227 chain' R (a :: l\u2082)\n| []        l\u2082 := (and_iff_right (chain'_singleton a)).symm\n| (b :: l\u2081) l\u2082 := chain_split\n\n@[simp] theorem chain'_append_cons_cons {b c : \u03b1} {l\u2081 l\u2082 : list \u03b1} :\n  chain' R (l\u2081 ++ b :: c :: l\u2082) \u2194 chain' R (l\u2081 ++ [b]) \u2227 R b c \u2227 chain' R (c :: l\u2082) :=\nby rw [chain'_split, chain'_cons]\n\ntheorem chain'_map (f : \u03b2 \u2192 \u03b1) {l : list \u03b2} :\n  chain' R (map f l) \u2194 chain' (\u03bb a b : \u03b2, R (f a) (f b)) l :=\nby cases l; [refl, exact chain_map _]\n\ntheorem chain'_of_chain'_map {S : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, S (f a) (f b) \u2192 R a b) {l : list \u03b1}\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 : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (H : \u2200 a b : \u03b1, R a b \u2192 S (f a) (f b)) {l : list \u03b1}\n  (p : chain' R l) : chain' S (map f l) :=\n(chain'_map f).2 $ p.imp H\n\ntheorem pairwise.chain' : \u2200 {l : list \u03b1}, pairwise R l \u2192 chain' R l\n| []       _ := trivial\n| (a :: l) h := pairwise.chain h\n\ntheorem chain'_iff_pairwise [is_trans \u03b1 R] : \u2200 {l : list \u03b1},\n  chain' R l \u2194 pairwise R l\n| []       := (iff_true_intro pairwise.nil).symm\n| (a :: l) := chain_iff_pairwise\n\nprotected lemma chain'.sublist [is_trans \u03b1 R] (hl : l\u2082.chain' R) (h : l\u2081 <+ l\u2082) : l\u2081.chain' R :=\nby { rw chain'_iff_pairwise at \u22a2 hl, exact hl.sublist h }\n\ntheorem chain'.cons {x y l} (h\u2081 : R x y) (h\u2082 : chain' R (y :: l)) :\n  chain' R (x :: y :: l) :=\nchain'_cons.2 \u27e8h\u2081, h\u2082\u27e9\n\ntheorem chain'.tail : \u2200 {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)) \u2983y\u2984 (hy : y \u2208 head' l) : R x y :=\nby { rw \u2190 cons_head'_tail hy at h, exact h.rel_head }\n\ntheorem chain'.cons' {x} :\n  \u2200 {l : list \u03b1},  chain' R l \u2192 (\u2200 y \u2208 l.head', R x y) \u2192 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) \u2194 (\u2200 y \u2208 head' l, R x y) \u2227 chain' R l :=\n\u27e8\u03bb h, \u27e8h.rel_head', h.tail\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, h\u2082.cons' h\u2081\u27e9\n\n\n\ntheorem chain'.append (h\u2081 : chain' R l\u2081) (h\u2082 : chain' R l\u2082)\n  (h : \u2200 (x \u2208 l\u2081.last') (y \u2208 l\u2082.head'), R x y) :\n  chain' R (l\u2081 ++ l\u2082) :=\nchain'_append.2 \u27e8h\u2081, h\u2082, h\u27e9\n\ntheorem chain'.left_of_append (h : chain' R (l\u2081 ++ l\u2082)) : chain' R l\u2081 := (chain'_append.1 h).1\ntheorem chain'.right_of_append (h : chain' R (l\u2081 ++ l\u2082)) : chain' R l\u2082 := (chain'_append.1 h).2.1\n\ntheorem chain'.infix (h : chain' R l) (h' : l\u2081 <:+: l) : chain' R l\u2081 :=\nby { rcases h' with \u27e8l\u2082, l\u2083, rfl\u27e9, exact h.left_of_append.right_of_append }\n\ntheorem chain'.suffix (h : chain' R l) (h' : l\u2081 <:+ l) : chain' R l\u2081 := h.infix h'.is_infix\ntheorem chain'.prefix (h : chain' R l) (h' : l\u2081 <+: l) : chain' R l\u2081 := h.infix h'.is_infix\ntheorem chain'.drop (h : chain' R l) (n : \u2115) : 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 : \u2115) : chain' R (take n l) := h.prefix (take_prefix _ _)\n\ntheorem chain'_pair {x y} : chain' R [x, y] \u2194 R x y :=\nby simp only [chain'_singleton, chain'_cons, and_true]\n\ntheorem chain'.imp_head {x y} (h : \u2200 {z}, R x z \u2192 R y z) {l} (hl : chain' R (x :: l)) :\n  chain' R (y :: l) :=\nhl.tail.cons' $ \u03bb z hz, h $ hl.rel_head' hz\n\ntheorem chain'_reverse : \u2200 {l}, chain' R (reverse l) \u2194 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, \u2190 reverse_cons, @chain'_reverse (b :: l), and_comm, chain'_pair, flip]\n\ntheorem chain'_iff_nth_le {R} : \u2200 {l : list \u03b1},\n  chain' R l \u2194 \u2200 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 [\u2190 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\u2081 l\u2082` and `l\u2083` are lists and `l\u2081 ++ l\u2082` and `l\u2082 ++ l\u2083` both satisfy\n  `chain' R`, then so does `l\u2081 ++ l\u2082 ++ l\u2083` provided `l\u2082 \u2260 []` -/\nlemma chain'.append_overlap {l\u2081 l\u2082 l\u2083 : list \u03b1}\n  (h\u2081 : chain' R (l\u2081 ++ l\u2082)) (h\u2082 : chain' R (l\u2082 ++ l\u2083)) (hn : l\u2082 \u2260 []) :\n  chain' R (l\u2081 ++ l\u2082 ++ l\u2083) :=\nh\u2081.append h\u2082.right_of_append $\n  by simpa only [last'_append_of_ne_nil _ hn] using (chain'_append.1 h\u2082).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  \u2203 l, chain r a l \u2227 last (a :: l) (cons_ne_nil _ _) = b :=\nbegin\n  apply relation.refl_trans_gen.head_induction_on h,\n  { exact \u27e8[], chain.nil, rfl\u27e9 },\n  { intros c d e t ih,\n    obtain \u27e8l, hl\u2081, hl\u2082\u27e9 := ih,\n    refine \u27e8d :: l, chain.cons e hl\u2081, _\u27e9,\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 \u2192 p y \u2192 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 : \u03b1 \u2192 Prop)\n  (l : list \u03b1) (h : chain r a l)\n  (hb : last (a :: l) (cons_ne_nil _ _) = b)\n  (carries : \u2200 \u2983x y : \u03b1\u2984, r x y \u2192 p y \u2192 p x) (final : p b) : \u2200 i \u2208 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 \u2192 p y \u2192 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 : \u03b1 \u2192 Prop)\n  (l : list \u03b1) (h : chain r a l)\n  (hb : last (a :: l) (cons_ne_nil _ _) = b)\n  (carries : \u2200 \u2983x y : \u03b1\u2984, r x y \u2192 p y \u2192 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\u2081 : chain r a l)\n  (hl\u2082 : last (a :: l) (cons_ne_nil _ _) = b) :\n  relation.refl_trans_gen r a b :=\nchain.induction_head _ l hl\u2081 hl\u2082 (\u03bb 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\u00f6lzl, 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 `\u03a0\u2080 a, \u03b2 a` as notation for `dfinsupp \u03b2`, mirroring the `\u03b1 \u2192\u2080 \u03b2`\nnotation used for `finsupp`. This works for nested binders too, with `\u03a0\u2080 a b, \u03b3 a b` as notation\nfor `dfinsupp (\u03bb a, dfinsupp (\u03b3 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 : \u03b2 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\u2081 u\u2082 v v\u2081 v\u2082 v\u2083 w x y l\n\nopen_locale big_operators\n\nvariables {\u03b9 : Type u} {\u03b3 : Type w} {\u03b2 : \u03b9 \u2192 Type v} {\u03b2\u2081 : \u03b9 \u2192 Type v\u2081} {\u03b2\u2082 : \u03b9 \u2192 Type v\u2082}\n\n\nvariable (\u03b2)\n/-- A dependent function `\u03a0 i, \u03b2 i` with finite support, with notation `\u03a0\u2080 i, \u03b2 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 [\u03a0 i, has_zero (\u03b2 i)] : Type (max u v) :=\nmk' ::\n(to_fun : \u03a0 i, \u03b2 i)\n(support' : trunc {s : multiset \u03b9 // \u2200 i, i \u2208 s \u2228 to_fun i = 0})\nvariable {\u03b2}\n\nnotation `\u03a0\u2080` binders `, ` r:(scoped f, dfinsupp f) := r\ninfix ` \u2192\u209a `:25 := dfinsupp\n\nnamespace dfinsupp\n\nsection basic\nvariables [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i, has_zero (\u03b2\u2081 i)] [\u03a0 i, has_zero (\u03b2\u2082 i)]\n\ninstance fun_like : fun_like (\u03a0\u2080 i, \u03b2 i) \u03b9 \u03b2 :=\n\u27e8\u03bb f, f.to_fun, \u03bb \u27e8f\u2081, s\u2081\u27e9 \u27e8f\u2082, s\u2081\u27e9 (h : f\u2081= f\u2082), by { subst h, congr'} \u27e9\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 (\u03a0\u2080 i, \u03b2 i) (\u03bb _, \u03a0 i, \u03b2 i) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe (f : \u03a0\u2080 i, \u03b2 i) : f.to_fun = f := rfl\n\n@[ext] lemma ext {f g : \u03a0\u2080 i, \u03b2 i} (h : \u2200 i, f i = g i) : f = g := fun_like.ext _ _ h\n/-- Deprecated. Use `fun_like.ext_iff` instead. -/\nlemma ext_iff {f g : \u03a0\u2080 i, \u03b2 i} : f = g \u2194 \u2200 i, f i = g i := fun_like.ext_iff\n/-- Deprecated. Use `fun_like.coe_injective` instead. -/\nlemma coe_fn_injective : @function.injective (\u03a0\u2080 i, \u03b2 i) (\u03a0 i, \u03b2 i) coe_fn := fun_like.coe_injective\n\ninstance : has_zero (\u03a0\u2080 i, \u03b2 i) := \u27e8\u27e80, trunc.mk $ \u27e8\u2205, \u03bb i, or.inr rfl\u27e9\u27e9\u27e9\ninstance : inhabited (\u03a0\u2080 i, \u03b2 i) := \u27e80\u27e9\n\n@[simp]\nlemma coe_mk' (f : \u03a0 i, \u03b2 i) (s) : \u21d1(\u27e8f, s\u27e9 : \u03a0\u2080 i, \u03b2 i) = f := rfl\n\n@[simp] lemma coe_zero : \u21d1(0 : \u03a0\u2080 i, \u03b2 i) = 0 := rfl\nlemma zero_apply (i : \u03b9) : (0 : \u03a0\u2080 i, \u03b2 i) i = 0 := rfl\n\n/-- The composition of `f : \u03b2\u2081 \u2192 \u03b2\u2082` and `g : \u03a0\u2080 i, \u03b2\u2081 i` is\n  `map_range f hf g : \u03a0\u2080 i, \u03b2\u2082 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 : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (hf : \u2200 i, f i 0 = 0) (x : \u03a0\u2080 i, \u03b2\u2081 i) : \u03a0\u2080 i, \u03b2\u2082 i :=\n\u27e8\u03bb i, f i (x i), x.support'.map $ \u03bb s, \u27e8s, \u03bb i, (s.2 i).imp_right $ \u03bb h : x i = 0, h.symm \u25b8 hf i\u27e9\u27e9\n\n@[simp] lemma map_range_apply\n  (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (hf : \u2200 i, f i 0 = 0) (g : \u03a0\u2080 i, \u03b2\u2081 i) (i : \u03b9) :\n  map_range f hf g i = f i (g i) :=\nrfl\n\n@[simp] lemma map_range_id (h : \u2200 i, id (0 : \u03b2\u2081 i) = 0 := \u03bb i, rfl) (g : \u03a0\u2080 (i : \u03b9), \u03b2\u2081 i) :\n  map_range (\u03bb i, (id : \u03b2\u2081 i \u2192 \u03b2\u2081 i)) h g = g :=\nby { ext, refl }\n\nlemma map_range_comp (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (f\u2082 : \u03a0 i, \u03b2 i \u2192 \u03b2\u2081 i)\n  (hf : \u2200 i, f i 0 = 0) (hf\u2082 : \u2200 i, f\u2082 i 0 = 0) (h : \u2200 i, (f i \u2218 f\u2082 i) 0 = 0)\n  (g : \u03a0\u2080 (i : \u03b9), \u03b2 i) :\n  map_range (\u03bb i, f i \u2218 f\u2082 i) h g = map_range f hf (map_range f\u2082 hf\u2082 g) :=\nby { ext, simp only [map_range_apply] }\n\n@[simp] lemma map_range_zero (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (hf : \u2200 i, f i 0 = 0) :\n  map_range f hf (0 : \u03a0\u2080 i, \u03b2\u2081 i) = 0 :=\nby { ext, simp only [map_range_apply, coe_zero, pi.zero_apply, hf] }\n\n/-- Let `f i` be a binary operation `\u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i` such that `f i 0 0 = 0`.\nThen `zip_with f hf` is a binary operation `\u03a0\u2080 i, \u03b2\u2081 i \u2192 \u03a0\u2080 i, \u03b2\u2082 i \u2192 \u03a0\u2080 i, \u03b2 i`. -/\ndef zip_with (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i) (hf : \u2200 i, f i 0 0 = 0)\n  (x : \u03a0\u2080 i, \u03b2\u2081 i) (y : \u03a0\u2080 i, \u03b2\u2082 i) : (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8\u03bb i, f i (x i) (y i), begin\n  refine x.support'.bind (\u03bb xs, _),\n  refine y.support'.map (\u03bb ys, _),\n  refine \u27e8xs + ys, \u03bb i, _\u27e9,\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\u27e9\n\n@[simp] lemma zip_with_apply\n  (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i) (hf : \u2200 i, f i 0 0 = 0) (g\u2081 : \u03a0\u2080 i, \u03b2\u2081 i) (g\u2082 : \u03a0\u2080 i, \u03b2\u2082 i) (i : \u03b9) :\n  zip_with f hf g\u2081 g\u2082 i = f i (g\u2081 i) (g\u2082 i) :=\nrfl\n\nsection piecewise\nvariables (x y : \u03a0\u2080 i, \u03b2 i) (s : set \u03b9) [\u03a0 i, decidable (i \u2208 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 : \u03a0\u2080 i, \u03b2 i := zip_with (\u03bb i x y, if i \u2208 s then x else y) (\u03bb _, if_t_t _ 0) x y\n\nlemma piecewise_apply (i : \u03b9) : x.piecewise y s i = if i \u2208 s then x i else y i :=\nzip_with_apply _ _ x y i\n\n@[simp, norm_cast] lemma coe_piecewise : \u21d1(x.piecewise y s) = s.piecewise x y :=\nby { ext, apply piecewise_apply }\n\nend piecewise\n\nend basic\n\nsection algebra\n\ninstance [\u03a0 i, add_zero_class (\u03b2 i)] : has_add (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8zip_with (\u03bb _, (+)) (\u03bb _, add_zero 0)\u27e9\n\nlemma add_apply [\u03a0 i, add_zero_class (\u03b2 i)] (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\n  (g\u2081 + g\u2082) i = g\u2081 i + g\u2082 i :=\nrfl\n\n@[simp] lemma coe_add [\u03a0 i, add_zero_class (\u03b2 i)] (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i) :\n  \u21d1(g\u2081 + g\u2082) = g\u2081 + g\u2082 :=\nrfl\n\ninstance [\u03a0 i, add_zero_class (\u03b2 i)] : add_zero_class (\u03a0\u2080 i, \u03b2 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 `\u2115` is not distributive\nunless `\u03b2 i`'s addition is commutative. -/\ninstance has_nat_scalar [\u03a0 i, add_monoid (\u03b2 i)] : has_smul \u2115 (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8\u03bbc v, v.map_range (\u03bb _, (\u2022) c) (\u03bb _, nsmul_zero _)\u27e9\n\nlemma nsmul_apply [\u03a0 i, add_monoid (\u03b2 i)] (b : \u2115) (v : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\n  (b \u2022 v) i = b \u2022 (v i) :=\nrfl\n\n@[simp] lemma coe_nsmul [\u03a0 i, add_monoid (\u03b2 i)] (b : \u2115) (v : \u03a0\u2080 i, \u03b2 i) : \u21d1(b \u2022 v) = b \u2022 v :=\nrfl\n\ninstance [\u03a0 i, add_monoid (\u03b2 i)] : add_monoid (\u03a0\u2080 i, \u03b2 i) :=\nfun_like.coe_injective.add_monoid _ coe_zero coe_add (\u03bb _ _, coe_nsmul _ _)\n\n/-- Coercion from a `dfinsupp` to a pi type is an `add_monoid_hom`. -/\ndef coe_fn_add_monoid_hom [\u03a0 i, add_zero_class (\u03b2 i)] : (\u03a0\u2080 i, \u03b2 i) \u2192+ (\u03a0 i, \u03b2 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 [\u03a0 i, add_zero_class (\u03b2 i)] (i : \u03b9) : (\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b2 i :=\n(pi.eval_add_monoid_hom \u03b2 i).comp coe_fn_add_monoid_hom\n\ninstance [\u03a0 i, add_comm_monoid (\u03b2 i)] : add_comm_monoid (\u03a0\u2080 i, \u03b2 i) :=\nfun_like.coe_injective.add_comm_monoid _ coe_zero coe_add (\u03bb _ _, coe_nsmul _ _)\n\n@[simp] lemma coe_finset_sum {\u03b1} [\u03a0 i, add_comm_monoid (\u03b2 i)] (s : finset \u03b1) (g : \u03b1 \u2192 \u03a0\u2080 i, \u03b2 i) :\n  \u21d1(\u2211 a in s, g a) = \u2211 a in s, g a :=\n(coe_fn_add_monoid_hom : _ \u2192+ (\u03a0 i, \u03b2 i)).map_sum g s\n\n@[simp] lemma finset_sum_apply {\u03b1} [\u03a0 i, add_comm_monoid (\u03b2 i)] (s : finset \u03b1) (g : \u03b1 \u2192 \u03a0\u2080 i, \u03b2 i)\n  (i : \u03b9) :\n  (\u2211 a in s, g a) i = \u2211 a in s, g a i :=\n(eval_add_monoid_hom i : _ \u2192+ \u03b2 i).map_sum g s\n\ninstance [\u03a0 i, add_group (\u03b2 i)] : has_neg (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8\u03bb f, f.map_range (\u03bb _, has_neg.neg) (\u03bb _, neg_zero)\u27e9\n\nlemma neg_apply [\u03a0 i, add_group (\u03b2 i)] (g : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) : (- g) i = - g i :=\nrfl\n\n@[simp] lemma coe_neg [\u03a0 i, add_group (\u03b2 i)] (g : \u03a0\u2080 i, \u03b2 i) : \u21d1(- g) = - g :=\nrfl\n\ninstance [\u03a0 i, add_group (\u03b2 i)] : has_sub (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8zip_with (\u03bb _, has_sub.sub) (\u03bb _, sub_zero 0)\u27e9\n\nlemma sub_apply [\u03a0 i, add_group (\u03b2 i)] (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\n  (g\u2081 - g\u2082) i = g\u2081 i - g\u2082 i :=\nrfl\n\n@[simp] lemma coe_sub [\u03a0 i, add_group (\u03b2 i)] (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i) :\n  \u21d1(g\u2081 - g\u2082) = g\u2081 - g\u2082 :=\nrfl\n\n/-- Note the general `dfinsupp.has_smul` instance doesn't apply as `\u2124` is not distributive\nunless `\u03b2 i`'s addition is commutative. -/\ninstance has_int_scalar [\u03a0 i, add_group (\u03b2 i)] : has_smul \u2124 (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8\u03bbc v, v.map_range (\u03bb _, (\u2022) c) (\u03bb _, zsmul_zero _)\u27e9\n\nlemma zsmul_apply [\u03a0 i, add_group (\u03b2 i)] (b : \u2124) (v : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) : (b \u2022 v) i = b \u2022 (v i) :=\nrfl\n\n@[simp] lemma coe_zsmul [\u03a0 i, add_group (\u03b2 i)] (b : \u2124) (v : \u03a0\u2080 i, \u03b2 i) : \u21d1(b \u2022 v) = b \u2022 v :=\nrfl\n\ninstance [\u03a0 i, add_group (\u03b2 i)] : add_group (\u03a0\u2080 i, \u03b2 i) :=\nfun_like.coe_injective.add_group _\n  coe_zero coe_add coe_neg coe_sub (\u03bb _ _, coe_nsmul _ _) (\u03bb _ _, coe_zsmul _ _)\n\ninstance [\u03a0 i, add_comm_group (\u03b2 i)] : add_comm_group (\u03a0\u2080 i, \u03b2 i) :=\nfun_like.coe_injective.add_comm_group _\n  coe_zero coe_add coe_neg coe_sub (\u03bb _ _, coe_nsmul _ _) (\u03bb _ _, coe_zsmul _ _)\n\n/-- Dependent functions with finite support inherit a semiring action from an action on each\ncoordinate. -/\ninstance [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] :\n  has_smul \u03b3 (\u03a0\u2080 i, \u03b2 i) :=\n\u27e8\u03bbc v, v.map_range (\u03bb _, (\u2022) c) (\u03bb _, smul_zero _)\u27e9\n\nlemma smul_apply [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)]\n  [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] (b : \u03b3) (v : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\n  (b \u2022 v) i = b \u2022 (v i) :=\nrfl\n\n@[simp] lemma coe_smul [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)]\n  [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] (b : \u03b3) (v : \u03a0\u2080 i, \u03b2 i) :\n  \u21d1(b \u2022 v) = b \u2022 v :=\nrfl\n\ninstance {\u03b4 : Type*} [monoid \u03b3] [monoid \u03b4]\n  [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b4 (\u03b2 i)]\n  [\u03a0 i, smul_comm_class \u03b3 \u03b4 (\u03b2 i)] :\n  smul_comm_class \u03b3 \u03b4 (\u03a0\u2080 i, \u03b2 i) :=\n{ smul_comm := \u03bb r s m, ext $ \u03bb i, by simp only [smul_apply, smul_comm r s (m i)] }\n\ninstance {\u03b4 : Type*} [monoid \u03b3] [monoid \u03b4]\n  [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b4 (\u03b2 i)]\n  [has_smul \u03b3 \u03b4] [\u03a0 i, is_scalar_tower \u03b3 \u03b4 (\u03b2 i)] :\n  is_scalar_tower \u03b3 \u03b4 (\u03a0\u2080 i, \u03b2 i) :=\n{ smul_assoc := \u03bb r s m, ext $ \u03bb i, by simp only [smul_apply, smul_assoc r s (m i)] }\n\ninstance [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)]\n  [\u03a0 i, distrib_mul_action \u03b3\u1d50\u1d52\u1d56 (\u03b2 i)] [\u2200 i, is_central_scalar \u03b3 (\u03b2 i)] :\n  is_central_scalar \u03b3 (\u03a0\u2080 i, \u03b2 i) :=\n{ op_smul_eq_smul := \u03bb r m, ext $ \u03bb 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 \u03b3] [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] :\n  distrib_mul_action \u03b3 (\u03a0\u2080 i, \u03b2 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 \u03b3] [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i, module \u03b3 (\u03b2 i)] :\n  module \u03b3 (\u03a0\u2080 i, \u03b2 i) :=\n{ zero_smul := \u03bb c, ext $ \u03bb i, by simp only [smul_apply, zero_smul, zero_apply],\n  add_smul := \u03bb c x y, ext $ \u03bb 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 [\u03a0 i, has_zero (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p] (x : \u03a0\u2080 i, \u03b2 i) : \u03a0\u2080 i, \u03b2 i :=\n\u27e8\u03bb i, if p i then x i else 0, x.support'.map\n  (\u03bb xs, \u27e8xs, \u03bb i, (xs.prop i).imp_right $ \u03bb H : x i = 0, by rw [H, if_t_t]\u27e9)\u27e9\n\n@[simp] lemma filter_apply [\u03a0 i, has_zero (\u03b2 i)]\n  (p : \u03b9 \u2192 Prop) [decidable_pred p] (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) :\n  f.filter p i = if p i then f i else 0 :=\nrfl\n\nlemma filter_apply_pos [\u03a0 i, has_zero (\u03b2 i)]\n  {p : \u03b9 \u2192 Prop} [decidable_pred p] (f : \u03a0\u2080 i, \u03b2 i) {i : \u03b9} (h : p i) :\n  f.filter p i = f i :=\nby simp only [filter_apply, if_pos h]\n\nlemma filter_apply_neg [\u03a0 i, has_zero (\u03b2 i)]\n  {p : \u03b9 \u2192 Prop} [decidable_pred p] (f : \u03a0\u2080 i, \u03b2 i) {i : \u03b9} (h : \u00ac p i) :\n  f.filter p i = 0 :=\nby simp only [filter_apply, if_neg h]\n\nlemma filter_pos_add_filter_neg [\u03a0 i, add_zero_class (\u03b2 i)] (f : \u03a0\u2080 i, \u03b2 i)\n  (p : \u03b9 \u2192 Prop) [decidable_pred p] :\n  f.filter p + f.filter (\u03bbi, \u00ac p i) = f :=\next $ \u03bb i, by simp only [add_apply, filter_apply]; split_ifs; simp only [add_zero, zero_add]\n\n@[simp] lemma filter_zero [\u03a0 i, has_zero (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p] :\n  (0 : \u03a0\u2080 i, \u03b2 i).filter p = 0 :=\nby { ext, simp }\n\n@[simp] lemma filter_add [\u03a0 i, add_zero_class (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p]\n  (f g : \u03a0\u2080 i, \u03b2 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 \u03b3] [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)]\n  (p : \u03b9 \u2192 Prop) [decidable_pred p] (r : \u03b3) (f : \u03a0\u2080 i, \u03b2 i) :\n  (r \u2022 f).filter p = r \u2022 f.filter p :=\nby { ext, simp [smul_ite] }\n\nvariables (\u03b3 \u03b2)\n\n/-- `dfinsupp.filter` as an `add_monoid_hom`. -/\n@[simps]\ndef filter_add_monoid_hom [\u03a0 i, add_zero_class (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p] :\n  (\u03a0\u2080 i, \u03b2 i) \u2192+ (\u03a0\u2080 i, \u03b2 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 \u03b3] [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i, module \u03b3 (\u03b2 i)]\n  (p : \u03b9 \u2192 Prop) [decidable_pred p] :\n  (\u03a0\u2080 i, \u03b2 i) \u2192\u2097[\u03b3] (\u03a0\u2080 i, \u03b2 i) :=\n{ to_fun := filter p,\n  map_add' := filter_add p,\n  map_smul' := filter_smul p }\n\nvariables {\u03b3 \u03b2}\n\n@[simp] lemma filter_neg [\u03a0 i, add_group (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p]\n  (f : \u03a0\u2080 i, \u03b2 i) :\n  (-f).filter p = -f.filter p :=\n(filter_add_monoid_hom \u03b2 p).map_neg f\n\n@[simp] lemma filter_sub [\u03a0 i, add_group (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p]\n  (f g : \u03a0\u2080 i, \u03b2 i) :\n  (f - g).filter p = f.filter p - g.filter p :=\n(filter_add_monoid_hom \u03b2 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 [\u03a0 i, has_zero (\u03b2 i)] (p : \u03b9 \u2192 Prop) [decidable_pred p] (x : \u03a0\u2080 i, \u03b2 i) :\n  \u03a0\u2080 i : subtype p, \u03b2 i :=\n\u27e8\u03bb i, x (i : \u03b9), x.support'.map\n  (\u03bb xs, \u27e8(multiset.filter p xs).attach.map $ \u03bb j, \u27e8j, (multiset.mem_filter.1 j.2).2\u27e9,\n      \u03bb i, (xs.prop i).imp_left $ \u03bb H, multiset.mem_map.2\n        \u27e8\u27e8i, multiset.mem_filter.2 \u27e8H, i.2\u27e9\u27e9, multiset.mem_attach _ _, subtype.eta _ _\u27e9\u27e9)\u27e9\n\n@[simp] lemma subtype_domain_zero [\u03a0 i, has_zero (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p] :\n  subtype_domain p (0 : \u03a0\u2080 i, \u03b2 i) = 0 :=\nrfl\n\n@[simp] lemma subtype_domain_apply [\u03a0 i, has_zero (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {i : subtype p} {v : \u03a0\u2080 i, \u03b2 i} :\n  (subtype_domain p v) i = v i :=\nrfl\n\n@[simp] lemma subtype_domain_add [\u03a0 i, add_zero_class (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  (v v' : \u03a0\u2080 i, \u03b2 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 \u03b3] [\u03a0 i, add_monoid (\u03b2 i)]\n  [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p] (r : \u03b3) (f : \u03a0\u2080 i, \u03b2 i) :\n  (r \u2022 f).subtype_domain p = r \u2022 f.subtype_domain p :=\ncoe_fn_injective rfl\n\nvariables (\u03b3 \u03b2)\n\n/-- `subtype_domain` but as an `add_monoid_hom`. -/\n@[simps] def subtype_domain_add_monoid_hom [\u03a0 i, add_zero_class (\u03b2 i)]\n  (p : \u03b9 \u2192 Prop) [decidable_pred p] : (\u03a0\u2080 i : \u03b9, \u03b2 i) \u2192+ \u03a0\u2080 i : subtype p, \u03b2 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 \u03b3] [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i, module \u03b3 (\u03b2 i)]\n  (p : \u03b9 \u2192 Prop) [decidable_pred p] :\n  (\u03a0\u2080 i, \u03b2 i) \u2192\u2097[\u03b3] (\u03a0\u2080 i : subtype p, \u03b2 i) :=\n{ to_fun := subtype_domain p,\n  map_add' := subtype_domain_add,\n  map_smul' := subtype_domain_smul }\n\nvariables {\u03b3 \u03b2}\n\n@[simp]\nlemma subtype_domain_neg [\u03a0 i, add_group (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p] {v : \u03a0\u2080 i, \u03b2 i} :\n  (- v).subtype_domain p = - v.subtype_domain p :=\ncoe_fn_injective rfl\n\n@[simp] lemma subtype_domain_sub [\u03a0 i, add_group (\u03b2 i)] {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {v v' : \u03a0\u2080 i, \u03b2 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 \u03b9]\ninclude dec\n\nsection basic\nvariable [\u03a0 i, has_zero (\u03b2 i)]\n\nomit dec\nlemma finite_support (f : \u03a0\u2080 i, \u03b2 i) : set.finite {i | f i \u2260 0} :=\nbegin\n  classical,\n  exact trunc.induction_on f.support' (\u03bb xs, (multiset.to_finset \u2191xs).finite_to_set.subset (\u03bb i H,\n    multiset.mem_to_finset.2 ((xs.prop i).resolve_right H)))\nend\ninclude dec\n\n/-- Create an element of `\u03a0\u2080 i, \u03b2 i` from a finset `s` and a function `x`\ndefined on this `finset`. -/\ndef mk (s : finset \u03b9) (x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 (i : \u03b9)) : \u03a0\u2080 i, \u03b2 i :=\n\u27e8\u03bb i, if H : i \u2208 s then x \u27e8i, H\u27e9 else 0, trunc.mk \u27e8s.1,\n  \u03bb i, if H : i \u2208 s then or.inl H else or.inr $ dif_neg H\u27e9\u27e9\n\nvariables {s : finset \u03b9} {x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i} {i : \u03b9}\n\n@[simp] lemma mk_apply : (mk s x : \u03a0 i, \u03b2 i) i = if H : i \u2208 s then x \u27e8i, H\u27e9 else 0 := rfl\nlemma mk_of_mem (hi : i \u2208 s) : (mk s x : \u03a0 i, \u03b2 i) i = x \u27e8i, hi\u27e9 := dif_pos hi\nlemma mk_of_not_mem (hi : i \u2209 s) : (mk s x : \u03a0 i, \u03b2 i) i = 0 := dif_neg hi\n\ntheorem mk_injective (s : finset \u03b9) : function.injective (@mk \u03b9 \u03b2 _ _ s) :=\nbegin\n  intros x y H,\n  ext i,\n  have h1 : (mk s x : \u03a0 i, \u03b2 i) i = (mk s y : \u03a0 i, \u03b2 i) i, {rw H},\n  cases i with i hi,\n  change i \u2208 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 [\u2200 i, subsingleton (\u03b2 i)] : unique (\u03a0\u2080 i, \u03b2 i) := fun_like.coe_injective.unique\n\ninstance unique_of_is_empty [is_empty \u03b9] : unique (\u03a0\u2080 i, \u03b2 i) := fun_like.coe_injective.unique\n\n/-- Given `fintype \u03b9`, `equiv_fun_on_fintype` is the `equiv` between `\u03a0\u2080 i, \u03b2 i` and `\u03a0 i, \u03b2 i`.\n  (All dependent functions on a finite type are finitely supported.) -/\n@[simps apply] def equiv_fun_on_fintype [fintype \u03b9] : (\u03a0\u2080 i, \u03b2 i) \u2243 (\u03a0 i, \u03b2 i) :=\n{ to_fun := coe_fn,\n  inv_fun := \u03bb f, \u27e8f, trunc.mk \u27e8finset.univ.1, \u03bb i, or.inl $ finset.mem_univ_val _\u27e9\u27e9,\n  left_inv := \u03bb x, coe_fn_injective rfl,\n  right_inv := \u03bb x, rfl }\n\n@[simp] lemma equiv_fun_on_fintype_symm_coe [fintype \u03b9] (f : \u03a0\u2080 i, \u03b2 i) :\n  equiv_fun_on_fintype.symm f = f :=\nequiv.symm_apply_apply _ _\ninclude dec\n\n/-- The function `single i b : \u03a0\u2080 i, \u03b2 i` sends `i` to `b`\nand all other points to `0`. -/\ndef single (i : \u03b9) (b : \u03b2 i) : \u03a0\u2080 i, \u03b2 i :=\n\u27e8pi.single i b,\n  trunc.mk \u27e8{i}, \u03bb j, (decidable.eq_or_ne j i).imp (by simp) (\u03bb h, pi.single_eq_of_ne h _)\u27e9\u27e9\n\nlemma single_eq_pi_single {i b} : \u21d1(single i b : \u03a0\u2080 i, \u03b2 i) = pi.single i b :=\nrfl\n\n@[simp] lemma single_apply {i i' b} :\n  (single i b : \u03a0\u2080 i, \u03b2 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 : \u03a0\u2080 i, \u03b2 i) = 0 :=\nfun_like.coe_injective $ pi.single_zero _\n\n@[simp] lemma single_eq_same {i b} : (single i b : \u03a0\u2080 i, \u03b2 i) i = b :=\nby simp only [single_apply, dif_pos rfl]\n\nlemma single_eq_of_ne {i i' b} (h : i \u2260 i') : (single i b : \u03a0\u2080 i, \u03b2 i) i' = 0 :=\nby simp only [single_apply, dif_neg h]\n\nlemma single_injective {i} : function.injective (single i : \u03b2 i \u2192 \u03a0\u2080 i, \u03b2 i) :=\n\u03bb x y H, pi.single_injective \u03b2 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 : \u03b9) (xi : \u03b2 i) (xj : \u03b2 j) :\n  dfinsupp.single i xi = dfinsupp.single j xj \u2194 i = j \u2227 xi == xj \u2228 xi = 0 \u2227 xj = 0 :=\nbegin\n  split,\n  { intro h,\n    by_cases hij : i = j,\n    { subst hij,\n      exact or.inl \u27e8rfl, heq_of_eq (dfinsupp.single_injective h)\u27e9, },\n    { have h_coe : \u21d1(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 \u27e8hci, hcj.symm\u27e9, }, },\n  { rintros (\u27e8rfl, hxi\u27e9 | \u27e8hi, hj\u27e9),\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 : \u03a0 (i : \u03b9), \u03b2 i} (h : \u2200 i, b i \u2260 0) :\n  function.injective (\u03bb i, single i (b i) : \u03b9 \u2192 \u03a0\u2080 i, \u03b2 i) :=\n\u03bb a a' H, (((single_eq_single_iff _ _ _ _).mp H).resolve_right $ \u03bb hb, h _ hb.1).left\n\n@[simp] lemma single_eq_zero {i : \u03b9} {xi : \u03b2 i} : single i xi = 0 \u2194 xi = 0 :=\nbegin\n  rw [\u2190single_zero i, single_eq_single_iff],\n  simp,\nend\n\nlemma filter_single (p : \u03b9 \u2192 Prop) [decidable_pred p] (i : \u03b9) (x : \u03b2 i) :\n  (single i x).filter p = if p i then single i x else 0 :=\nbegin\n  ext j,\n  have := apply_ite (\u03bb x : \u03a0\u2080 i, \u03b2 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 : \u03b9 \u2192 Prop} [decidable_pred p] (i : \u03b9) (x : \u03b2 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 : \u03b9 \u2192 Prop} [decidable_pred p] (i : \u03b9) (x : \u03b2 i) (h : \u00acp 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 : \u03b2 i} {xj : \u03b2 j} (h : (\u27e8i, xi\u27e9 : sigma \u03b2) = \u27e8j, xj\u27e9) :\n  dfinsupp.single i xi = dfinsupp.single j xj :=\nby { cases h, refl }\n\n@[simp] lemma equiv_fun_on_fintype_single [fintype \u03b9] (i : \u03b9) (m : \u03b2 i) :\n  (@dfinsupp.equiv_fun_on_fintype \u03b9 \u03b2 _ _) (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 \u03b9] (i : \u03b9) (m : \u03b2 i) :\n  (@dfinsupp.equiv_fun_on_fintype \u03b9 \u03b2 _ _).symm (pi.single i m) = dfinsupp.single i m :=\nby { ext i', simp only [\u2190 single_eq_pi_single, equiv_fun_on_fintype_symm_coe] }\n\n/-- Redefine `f i` to be `0`. -/\ndef erase (i : \u03b9) (x : \u03a0\u2080 i, \u03b2 i) : \u03a0\u2080 i, \u03b2 i :=\n\u27e8\u03bb j, if j = i then 0 else x.1 j, x.support'.map $ \u03bb xs,\n  \u27e8xs, \u03bb j, (xs.prop j).imp_right $ \u03bb H, by simp only [H, if_t_t]\u27e9\u27e9\n\n@[simp] lemma erase_apply {i j : \u03b9} {f : \u03a0\u2080 i, \u03b2 i} :\n  (f.erase i) j = if j = i then 0 else f j :=\nrfl\n\n@[simp] lemma erase_same {i : \u03b9} {f : \u03a0\u2080 i, \u03b2 i} : (f.erase i) i = 0 :=\nby simp\n\nlemma erase_ne {i i' : \u03b9} {f : \u03a0\u2080 i, \u03b2 i} (h : i' \u2260 i) : (f.erase i) i' = f i' :=\nby simp [h]\n\nlemma piecewise_single_erase (x : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\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 {\u03b2 : \u03b9 \u2192 Type*} [\u03a0 i, add_group (\u03b2 i)] (f : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) :\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 : \u03b9) : erase i (0 : \u03a0\u2080 i, \u03b2 i) = 0 :=\next $ \u03bb _, if_t_t _ _\n\n@[simp] lemma filter_ne_eq_erase (f : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) : f.filter (\u2260 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 : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) : f.filter ((\u2260) i) = f.erase i :=\nbegin\n  rw \u2190filter_ne_eq_erase f i,\n  congr' with j,\n  exact ne_comm,\nend\n\nlemma erase_single (j : \u03b9) (i : \u03b9) (x : \u03b2 i) :\n  (single i x).erase j = if i = j then 0 else single i x :=\nby rw [\u2190filter_ne_eq_erase, filter_single, ite_not]\n\n@[simp] lemma erase_single_same (i : \u03b9) (x : \u03b2 i) : (single i x).erase i = 0 :=\nby rw [erase_single, if_pos rfl]\n\n@[simp] lemma erase_single_ne {i j : \u03b9} (x : \u03b2 i) (h : i \u2260 j) : (single i x).erase j = single i x :=\nby rw [erase_single, if_neg h]\n\nsection update\n\nvariables (f : \u03a0\u2080 i, \u03b2 i) (i) (b : \u03b2 i)\n\n/-- Replace the value of a `\u03a0\u2080 i, \u03b2 i` at a given point `i : \u03b9` by a given value `b : \u03b2 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 : \u03a0\u2080 i, \u03b2 i :=\n\u27e8function.update f i b, f.support'.map $ \u03bb s,\n  \u27e8i ::\u2098 s, \u03bb 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\u27e9\u27e9\n\nvariables (j : \u03b9)\n\n@[simp] lemma coe_update : (f.update i b : \u03a0 (i : \u03b9), \u03b2 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 {\u03b2 : \u03b9 \u2192 Type*} [\u03a0 i, add_zero_class (\u03b2 i)] (f : \u03a0\u2080 i, \u03b2 i) (i : \u03b9)\n  (b : \u03b2 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 {\u03b2 : \u03b9 \u2192 Type*} [\u03a0 i, add_zero_class (\u03b2 i)] (f : \u03a0\u2080 i, \u03b2 i) (i : \u03b9)\n  (b : \u03b2 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 {\u03b2 : \u03b9 \u2192 Type*} [\u03a0 i, add_group (\u03b2 i)] (f : \u03a0\u2080 i, \u03b2 i) (i : \u03b9)\n  (b : \u03b2 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 [\u03a0 i, add_zero_class (\u03b2 i)]\n\n@[simp] lemma single_add (i : \u03b9) (b\u2081 b\u2082 : \u03b2 i) : single i (b\u2081 + b\u2082) = single i b\u2081 + single i b\u2082 :=\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 : \u03b9) (f\u2081 f\u2082 : \u03a0\u2080 i, \u03b2 i) : erase i (f\u2081 + f\u2082) = erase i f\u2081 + erase i f\u2082 :=\next $ \u03bb _, by simp [ite_zero_add]\n\nvariables (\u03b2)\n\n/-- `dfinsupp.single` as an `add_monoid_hom`. -/\n@[simps] def single_add_hom (i : \u03b9) : \u03b2 i \u2192+ \u03a0\u2080 i, \u03b2 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 : \u03b9) : (\u03a0\u2080 i, \u03b2 i) \u2192+ \u03a0\u2080 i, \u03b2 i :=\n{ to_fun := erase i, map_zero' := erase_zero i, map_add' := erase_add i }\n\nvariables {\u03b2}\n\n@[simp] lemma single_neg {\u03b2 : \u03b9 \u2192 Type v} [\u03a0 i, add_group (\u03b2 i)] (i : \u03b9) (x : \u03b2 i) :\n  single i (-x) = -single i x :=\n(single_add_hom \u03b2 i).map_neg x\n\n@[simp] lemma single_sub {\u03b2 : \u03b9 \u2192 Type v} [\u03a0 i, add_group (\u03b2 i)] (i : \u03b9) (x y : \u03b2 i) :\n  single i (x - y) = single i x - single i y :=\n(single_add_hom \u03b2 i).map_sub x y\n\n@[simp] lemma erase_neg {\u03b2 : \u03b9 \u2192 Type v} [\u03a0 i, add_group (\u03b2 i)] (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) :\n  (-f).erase i = -f.erase i :=\n(erase_add_hom \u03b2 i).map_neg f\n\n@[simp] lemma erase_sub {\u03b2 : \u03b9 \u2192 Type v} [\u03a0 i, add_group (\u03b2 i)] (i : \u03b9) (f g : \u03a0\u2080 i, \u03b2 i) :\n  (f - g).erase i = f.erase i - g.erase i :=\n(erase_add_hom \u03b2 i).map_sub f g\n\nlemma single_add_erase (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) : single i (f i) + f.erase i = f :=\next $ \u03bb 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 : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) : f.erase i + single i (f i) = f :=\next $ \u03bb 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 : (\u03a0\u2080 i, \u03b2 i) \u2192 Prop} (f : \u03a0\u2080 i, \u03b2 i)\n  (h0 : p 0) (ha : \u2200i b (f : \u03a0\u2080 i, \u03b2 i), f i = 0 \u2192 b \u2260 0 \u2192 p f \u2192 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 (\u03bb i, (H i).resolve_left id),\n    subst this,\n    exact h0 },\n  have H2 : p (erase i \u27e8f, trunc.mk \u27e8i ::\u2098 s, H\u27e9\u27e9),\n  { dsimp only [erase, trunc.map, trunc.bind, trunc.lift_on, trunc.lift_mk, function.comp,\n      subtype.coe_mk],\n    have H2 : \u2200 j, j \u2208 s \u2228 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 : (\u27e8\u03bb (j : \u03b9), ite (j = i) 0 (f j), trunc.mk \u27e8i ::\u2098 s, _\u27e9\u27e9 : \u03a0\u2080 i, \u03b2 i)\n      = \u27e8\u03bb (j : \u03b9), ite (j = i) 0 (f j), trunc.mk \u27e8s, H2\u27e9\u27e9 := ext (\u03bb _, rfl),\n    rw H3, apply ih },\n  have H3 : single i _ + _ = (\u27e8f, trunc.mk \u27e8i ::\u2098 s, H\u27e9\u27e9 : \u03a0\u2080 i, \u03b2 i) :=\n    single_add_erase _ _,\n  rw \u2190 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\u2082 {p : (\u03a0\u2080 i, \u03b2 i) \u2192 Prop} (f : \u03a0\u2080 i, \u03b2 i)\n  (h0 : p 0) (ha : \u2200i b (f : \u03a0\u2080 i, \u03b2 i), f i = 0 \u2192 b \u2260 0 \u2192 p f \u2192 p (f + single i b)) :\n  p f :=\ndfinsupp.induction f h0 $ \u03bb 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 (\u22c3 i : \u03b9, set.range (single i : \u03b2 i \u2192 (\u03a0\u2080 i, \u03b2 i))) = \u22a4 :=\ntop_unique $ \u03bb x hx, (begin\n  apply dfinsupp.induction x,\n  exact add_submonoid.zero_mem _,\n  exact \u03bb a b f ha hb hf, add_submonoid.add_mem _\n    (add_submonoid.subset_closure $ set.mem_Union.2 \u27e8a, set.mem_range_self _\u27e9) hf\nend)\n\n/-- If two additive homomorphisms from `\u03a0\u2080 i, \u03b2 i` are equal on each `single a b`, then\nthey are equal. -/\n\n\n/-- If two additive homomorphisms from `\u03a0\u2080 i, \u03b2 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' {\u03b3 : Type w} [add_zero_class \u03b3] \u2983f g : (\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b3\u2984\n  (H : \u2200 x, f.comp (single_add_hom \u03b2 x) = g.comp (single_add_hom \u03b2 x)) :\n  f = g :=\nadd_hom_ext $ \u03bb x, add_monoid_hom.congr_fun (H x)\n\nend add_monoid\n\n@[simp] lemma mk_add [\u03a0 i, add_zero_class (\u03b2 i)] {s : finset \u03b9} {x y : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i} :\n  mk s (x + y) = mk s x + mk s y :=\next $ \u03bb i, by simp only [add_apply, mk_apply]; split_ifs; [refl, rw zero_add]\n\n@[simp] lemma mk_zero [\u03a0 i, has_zero (\u03b2 i)] {s : finset \u03b9} :\n  mk s (0 : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1) = 0 :=\next $ \u03bb i, by simp only [mk_apply]; split_ifs; refl\n\n@[simp] lemma mk_neg [\u03a0 i, add_group (\u03b2 i)] {s : finset \u03b9} {x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1} :\n  mk s (-x) = -mk s x :=\next $ \u03bb i, by simp only [neg_apply, mk_apply]; split_ifs; [refl, rw neg_zero]\n\n@[simp] lemma mk_sub [\u03a0 i, add_group (\u03b2 i)] {s : finset \u03b9} {x y : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1} :\n  mk s (x - y) = mk s x - mk s y :=\next $ \u03bb i, by simp only [sub_apply, mk_apply]; split_ifs; [refl, rw sub_zero]\n\n/-- If `s` is a subset of `\u03b9` 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 [\u03a0 i, add_group (\u03b2 i)] (s : finset \u03b9) :\n  (\u03a0 (i : (s : set \u03b9)), \u03b2 \u2191i) \u2192+ (\u03a0\u2080 (i : \u03b9), \u03b2 i) :=\n{ to_fun := mk s,\n  map_zero' := mk_zero,\n  map_add' := \u03bb _ _, mk_add }\n\nsection\nvariables [monoid \u03b3] [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)]\n\n@[simp] lemma mk_smul {s : finset \u03b9} (c : \u03b3) (x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 (i : \u03b9)) :\n  mk s (c \u2022 x) = c \u2022 mk s x :=\next $ \u03bb i, by simp only [smul_apply, mk_apply]; split_ifs; [refl, rw smul_zero]\n\n@[simp] lemma single_smul {i : \u03b9} (c : \u03b3) (x : \u03b2 i) :\n  single i (c \u2022 x) = c \u2022 single i x :=\next $ \u03bb i, by simp only [smul_apply, single_apply]; split_ifs; [cases h, rw smul_zero]; refl\n\nend\n\nsection support_basic\n\nvariables [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n\n/-- Set `{i | f x \u2260 0}` as a `finset`. -/\ndef support (f : \u03a0\u2080 i, \u03b2 i) : finset \u03b9 :=\nf.support'.lift (\u03bb xs, (multiset.to_finset \u2191xs).filter $ \u03bb i, f i \u2260 0) $\nbegin\n  rintros \u27e8sx, hx\u27e9 \u27e8sy, hy\u27e9,\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 \u27e8h1, h2\u27e9,\n    exact finset.mem_filter.2 \u27e8multiset.mem_to_finset.2 $ (hy i).resolve_right h2, h2\u27e9 },\n  { intro H,\n    rcases finset.mem_filter.1 H with \u27e8h1, h2\u27e9,\n    exact finset.mem_filter.2 \u27e8multiset.mem_to_finset.2 $ (hx i).resolve_right h2, h2\u27e9 },\nend\n\n@[simp] theorem support_mk_subset {s : finset \u03b9} {x : \u03a0 i : (\u2191s : set \u03b9), \u03b2 i.1} :\n  (mk s x).support \u2286 s :=\n\u03bb i H, multiset.mem_to_finset.1 (finset.mem_filter.1 H).1\n\n@[simp] theorem support_mk'_subset {f : \u03a0 i, \u03b2 i} {s : multiset \u03b9} {h} :\n  (mk' f $ trunc.mk \u27e8s, h\u27e9).support \u2286 s.to_finset :=\n\u03bb 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 : \u03a0\u2080 i, \u03b2 i) (i) : i \u2208 f.support \u2194 f i \u2260 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 : \u03a0\u2080 i, \u03b2 i) : f = mk f.support (\u03bb i, f i) :=\nbegin\n  change f = mk f.support (\u03bb i, f i.1),\n  ext i,\n  by_cases h : f i \u2260 0; [skip, rw [not_not] at h];\n    simp [h]\nend\n\n@[simp] lemma support_zero : (0 : \u03a0\u2080 i, \u03b2 i).support = \u2205 := rfl\n\nlemma mem_support_iff {f : \u03a0\u2080 i, \u03b2 i} {i : \u03b9} : i \u2208 f.support \u2194 f i \u2260 0 := f.mem_support_to_fun _\n\nlemma not_mem_support_iff {f : \u03a0\u2080 i, \u03b2 i} {i : \u03b9} : i \u2209 f.support \u2194 f i = 0 :=\nnot_iff_comm.1 mem_support_iff.symm\n\n@[simp] lemma support_eq_empty {f : \u03a0\u2080 i, \u03b2 i} : f.support = \u2205 \u2194 f = 0 :=\n\u27e8\u03bb H, ext $ by simpa [finset.ext_iff] using H, by simp {contextual:=tt}\u27e9\n\ninstance decidable_zero : decidable_pred (eq (0 : \u03a0\u2080 i, \u03b2 i)) :=\n\u03bb f, decidable_of_iff _ $ support_eq_empty.trans eq_comm\n\nlemma support_subset_iff {s : set \u03b9} {f : \u03a0\u2080 i, \u03b2 i} :\n  \u2191f.support \u2286 s \u2194 (\u2200i\u2209s, f i = 0) :=\nby simp [set.subset_def];\n   exact forall_congr (assume i, not_imp_comm)\n\nlemma support_single_ne_zero {i : \u03b9} {b : \u03b2 i} (hb : b \u2260 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 : \u03b9} {b : \u03b2 i} : (single i b).support \u2286 {i} :=\nsupport_mk'_subset\n\nsection map_range_and_zip_with\n\nvariables [\u03a0 i, has_zero (\u03b2\u2081 i)] [\u03a0 i, has_zero (\u03b2\u2082 i)]\n\nlemma map_range_def [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i} {hf : \u2200 i, f i 0 = 0} {g : \u03a0\u2080 i, \u03b2\u2081 i} :\n  map_range f hf g = mk g.support (\u03bb i, f i.1 (g i.1)) :=\nbegin\n  ext i,\n  by_cases h : g i \u2260 0; simp at h; simp [h, hf]\nend\n\n@[simp] lemma map_range_single {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i} {hf : \u2200 i, f i 0 = 0} {i : \u03b9} {b : \u03b2\u2081 i} :\n  map_range f hf (single i b) = single i (f i b) :=\ndfinsupp.ext $ \u03bb i', by by_cases i = i'; [{subst i', simp}, simp [h, hf]]\n\nvariables [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)] [\u03a0 i (x : \u03b2\u2082 i), decidable (x \u2260 0)]\n\nlemma support_map_range {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i} {hf : \u2200 i, f i 0 = 0} {g : \u03a0\u2080 i, \u03b2\u2081 i} :\n  (map_range f hf g).support \u2286 g.support :=\nby simp [map_range_def]\n\nlemma zip_with_def {\u03b9 : Type u} {\u03b2 : \u03b9 \u2192 Type v} {\u03b2\u2081 : \u03b9 \u2192 Type v\u2081} {\u03b2\u2082 : \u03b9 \u2192 Type v\u2082}\n  [dec : decidable_eq \u03b9] [\u03a0 (i : \u03b9), has_zero (\u03b2 i)] [\u03a0 (i : \u03b9), has_zero (\u03b2\u2081 i)]\n  [\u03a0 (i : \u03b9), has_zero (\u03b2\u2082 i)] [\u03a0 (i : \u03b9) (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  [\u03a0 (i : \u03b9) (x : \u03b2\u2082 i), decidable (x \u2260 0)]\n  {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i} {hf : \u2200 i, f i 0 0 = 0}\n  {g\u2081 : \u03a0\u2080 i, \u03b2\u2081 i} {g\u2082 : \u03a0\u2080 i, \u03b2\u2082 i} :\n  zip_with f hf g\u2081 g\u2082 = mk (g\u2081.support \u222a g\u2082.support) (\u03bb i, f i.1 (g\u2081 i.1) (g\u2082 i.1)) :=\nbegin\n  ext i,\n  by_cases h1 : g\u2081 i \u2260 0; by_cases h2 : g\u2082 i \u2260 0;\n    simp only [not_not, ne.def] at h1 h2; simp [h1, h2, hf]\nend\n\nlemma support_zip_with {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i \u2192 \u03b2 i} {hf : \u2200 i, f i 0 0 = 0}\n  {g\u2081 : \u03a0\u2080 i, \u03b2\u2081 i} {g\u2082 : \u03a0\u2080 i, \u03b2\u2082 i} :\n  (zip_with f hf g\u2081 g\u2082).support \u2286 g\u2081.support \u222a g\u2082.support :=\nby simp [zip_with_def]\n\nend map_range_and_zip_with\n\nlemma erase_def (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 i) :\n  f.erase i = mk (f.support.erase i) (\u03bb j, f j.1) :=\nby { ext j, by_cases h1 : j = i; by_cases h2 : f j \u2260 0; simp at h2; simp [h1, h2] }\n\n@[simp] lemma support_erase (i : \u03b9) (f : \u03a0\u2080 i, \u03b2 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 \u2260 0; simp at h2; simp [h1, h2] }\n\nlemma support_update_ne_zero (f : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) {b : \u03b2 i} (h : b \u2260 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 : \u03a0\u2080 i, \u03b2 i) (i : \u03b9) (b : \u03b2 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 : \u03b9 \u2192 Prop} [decidable_pred p]\n\nlemma filter_def (f : \u03a0\u2080 i, \u03b2 i) :\n  f.filter p = mk (f.support.filter p) (\u03bb i, f i.1) :=\nby ext i; by_cases h1 : p i; by_cases h2 : f i \u2260 0;\n simp at h2; simp [h1, h2]\n\n@[simp] lemma support_filter (f : \u03a0\u2080 i, \u03b2 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 : \u03a0\u2080 i, \u03b2 i) :\n  f.subtype_domain p = mk (f.support.subtype p) (\u03bb i, f i) :=\nby ext i; by_cases h2 : f i \u2260 0; try {simp at h2}; dsimp; simp [h2]\n\n@[simp] lemma support_subtype_domain {f : \u03a0\u2080 i, \u03b2 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 [\u03a0 i, add_zero_class (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  {g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2 i} :\n  (g\u2081 + g\u2082).support \u2286 g\u2081.support \u222a g\u2082.support :=\nsupport_zip_with\n\n@[simp] lemma support_neg [\u03a0 i, add_group (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  {f : \u03a0\u2080 i, \u03b2 i} :\n  support (-f) = support f :=\nby ext i; simp\n\nlemma support_smul {\u03b3 : Type w} [semiring \u03b3] [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i, module \u03b3 (\u03b2 i)]\n  [\u03a0 ( i : \u03b9) (x : \u03b2 i), decidable (x \u2260 0)]\n  (b : \u03b3) (v : \u03a0\u2080 i, \u03b2 i) : (b \u2022 v).support \u2286 v.support :=\nsupport_map_range\n\ninstance [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i, decidable_eq (\u03b2 i)] : decidable_eq (\u03a0\u2080 i, \u03b2 i) :=\nassume f g, decidable_of_iff (f.support = g.support \u2227 (\u2200i\u2208f.support, f i = g i))\n  \u27e8assume \u27e8h\u2081, h\u2082\u27e9, ext $ assume i,\n      if h : i \u2208 f.support then h\u2082 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\u2081, mem_support_iff, not_not] at h,\n        by rw [hf, hg],\n    by { rintro rfl, simp }\u27e9\n\nsection equiv\nopen finset\n\nvariables {\u03ba : Type*}\n/--Reindexing (and possibly removing) terms of a dfinsupp.-/\nnoncomputable def comap_domain [\u03a0 i, has_zero (\u03b2 i)] (h : \u03ba \u2192 \u03b9) (hh : function.injective h)\n  (f : \u03a0\u2080 i, \u03b2 i) : \u03a0\u2080 k, \u03b2 (h k) :=\n{ to_fun := \u03bb x, f (h x),\n  support' := f.support'.map $ \u03bb s,\n    \u27e8((multiset.to_finset \u2191s).preimage h (hh.inj_on _)).val,\n    \u03bb x, (s.prop (h x)).imp_left $ \u03bb hx, mem_preimage.mpr $ multiset.mem_to_finset.mpr hx \u27e9 }\n\n@[simp] lemma comap_domain_apply [\u03a0 i, has_zero (\u03b2 i)] (h : \u03ba \u2192 \u03b9) (hh : function.injective h)\n  (f : \u03a0\u2080 i, \u03b2 i) (k : \u03ba) :\n  comap_domain h hh f k = f (h k) :=\nrfl\n\n@[simp] lemma comap_domain_zero [\u03a0 i, has_zero (\u03b2 i)] (h : \u03ba \u2192 \u03b9) (hh : function.injective h) :\n  comap_domain h hh (0 : \u03a0\u2080 i, \u03b2 i) = 0 :=\nby { ext, rw [zero_apply, comap_domain_apply, zero_apply] }\n\n@[simp] lemma comap_domain_add [\u03a0 i, add_zero_class (\u03b2 i)] (h : \u03ba \u2192 \u03b9) (hh : function.injective h)\n  (f g : \u03a0\u2080 i, \u03b2 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 \u03b3] [\u03a0 i, add_monoid (\u03b2 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)]\n  (h : \u03ba \u2192 \u03b9) (hh : function.injective h) (r : \u03b3) (f : \u03a0\u2080 i, \u03b2 i) :\n  comap_domain h hh (r \u2022 f) = r \u2022 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 \u03ba] [\u03a0 i, has_zero (\u03b2 i)]\n  (h : \u03ba \u2192 \u03b9) (hh : function.injective h) (k : \u03ba) (x : \u03b2 (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' [\u03a0 i, has_zero (\u03b2 i)] (h : \u03ba \u2192 \u03b9) {h' : \u03b9 \u2192 \u03ba}\n  (hh' : function.left_inverse h' h) (f : \u03a0\u2080 i, \u03b2 i) : (\u03a0\u2080 k, \u03b2 (h k)) :=\n{ to_fun := \u03bb x, f (h x),\n  support' := f.support'.map $ \u03bb s, \u27e8multiset.map h' s, \u03bb x,\n    (s.prop (h x)).imp_left $ \u03bb hx, multiset.mem_map.mpr \u27e8_, hx, hh' _\u27e9\u27e9 }\n\n@[simp] lemma comap_domain'_apply [\u03a0 i, has_zero (\u03b2 i)] (h : \u03ba \u2192 \u03b9) {h' : \u03b9 \u2192 \u03ba}\n  (hh' : function.left_inverse h' h) (f : \u03a0\u2080 i, \u03b2 i) (k : \u03ba) : comap_domain' h hh' f k = f (h k) :=\nrfl\n\n@[simp] lemma comap_domain'_zero [\u03a0 i, has_zero (\u03b2 i)] (h : \u03ba \u2192 \u03b9) {h' : \u03b9 \u2192 \u03ba}\n  (hh' : function.left_inverse h' h) :\n  comap_domain' h hh' (0 : \u03a0\u2080 i, \u03b2 i) = 0 :=\nby { ext, rw [zero_apply, comap_domain'_apply, zero_apply] }\n\n@[simp] lemma comap_domain'_add [\u03a0 i, add_zero_class (\u03b2 i)] (h : \u03ba \u2192 \u03b9) {h' : \u03b9 \u2192 \u03ba}\n  (hh' : function.left_inverse h' h) (f g : \u03a0\u2080 i, \u03b2 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 \u03b3] [\u03a0 i, add_monoid (\u03b2 i)]\n  [\u03a0 i, distrib_mul_action \u03b3 (\u03b2 i)] (h : \u03ba \u2192 \u03b9) {h' : \u03b9 \u2192 \u03ba}\n  (hh' : function.left_inverse h' h) (r : \u03b3) (f : \u03a0\u2080 i, \u03b2 i) :\n  comap_domain' h hh' (r \u2022 f) = r \u2022 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 \u03b9] [decidable_eq \u03ba] [\u03a0 i, has_zero (\u03b2 i)]\n  (h : \u03ba \u2192 \u03b9) {h' : \u03b9 \u2192 \u03ba} (hh' : function.left_inverse h' h) (k : \u03ba) (x : \u03b2 (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 [\u03a0 i, has_zero (\u03b2 i)] (h : \u03b9 \u2243 \u03ba) : (\u03a0\u2080 i, \u03b2 i) \u2243 (\u03a0\u2080 k, \u03b2 (h.symm k)) :=\n{ to_fun := comap_domain' h.symm h.right_inv,\n  inv_fun := \u03bb f, map_range (\u03bb i, equiv.cast $ congr_arg \u03b2 $ h.symm_apply_apply i)\n    (\u03bb 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 := \u03bb 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 := \u03bb 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 {\u03b1 : \u03b9 \u2192 Type*} {\u03b4 : \u03a0 i, \u03b1 i \u2192 Type v}\n\n-- lean can't find these instances\ninstance has_add\u2082 [\u03a0 i j, add_zero_class (\u03b4 i j)] : has_add (\u03a0\u2080 (i : \u03b9) (j : \u03b1 i), \u03b4 i j) :=\n@dfinsupp.has_add \u03b9 (\u03bb i, \u03a0\u2080 j, \u03b4 i j) _\n\ninstance add_zero_class\u2082 [\u03a0 i j, add_zero_class (\u03b4 i j)] :\n  add_zero_class (\u03a0\u2080 (i : \u03b9) (j : \u03b1 i), \u03b4 i j) :=\n@dfinsupp.add_zero_class \u03b9 (\u03bb i, \u03a0\u2080 j, \u03b4 i j) _\n\ninstance add_monoid\u2082 [\u03a0 i j, add_monoid (\u03b4 i j)] :\n  add_monoid (\u03a0\u2080 (i : \u03b9) (j : \u03b1 i), \u03b4 i j) :=\n@dfinsupp.add_monoid \u03b9 (\u03bb i, \u03a0\u2080 j, \u03b4 i j) _\n\ninstance distrib_mul_action\u2082 [monoid \u03b3] [\u03a0 i j, add_monoid (\u03b4 i j)]\n  [\u03a0 i j, distrib_mul_action \u03b3 (\u03b4 i j)] :\n  distrib_mul_action \u03b3 (\u03a0\u2080 (i : \u03b9) (j : \u03b1 i), \u03b4 i j) :=\n@dfinsupp.distrib_mul_action \u03b9 _ (\u03bb i, \u03a0\u2080 j, \u03b4 i j) _ _ _\n\n/--The natural map between `\u03a0\u2080 (i : \u03a3 i, \u03b1 i), \u03b4 i.1 i.2` and `\u03a0\u2080 i (j : \u03b1 i), \u03b4 i j`.  -/\nnoncomputable def sigma_curry [\u03a0 i j, has_zero (\u03b4 i j)] (f : \u03a0\u2080 (i : \u03a3 i, _), \u03b4 i.1 i.2) :\n  \u03a0\u2080 i j, \u03b4 i j :=\nby { classical,\n  exact mk (f.support.image $ \u03bb i, i.1)\n    (\u03bb i, mk (f.support.preimage (sigma.mk i) $ sigma_mk_injective.inj_on _) $ \u03bb j, f \u27e8i, j\u27e9) }\n\n@[simp] lemma sigma_curry_apply [\u03a0 i j, has_zero (\u03b4 i j)] (f : \u03a0\u2080 (i : \u03a3 i, _), \u03b4 i.1 i.2)\n  (i : \u03b9) (j : \u03b1 i) :\n  sigma_curry f i j = f \u27e8i, j\u27e9 :=\nbegin\n  dunfold sigma_curry, by_cases h : f \u27e8i, j\u27e9 = 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 \u27e8\u27e8i, j\u27e9, _, rfl\u27e9, rw mem_support_to_fun, exact h } }\nend\n\n@[simp] lemma sigma_curry_zero [\u03a0 i j, has_zero (\u03b4 i j)] :\n  sigma_curry (0 : \u03a0\u2080 (i : \u03a3 i, _), \u03b4 i.1 i.2) = 0 :=\nby { ext i j, rw sigma_curry_apply, refl }\n\n@[simp] lemma sigma_curry_add [\u03a0 i j, add_zero_class (\u03b4 i j)] (f g : \u03a0\u2080 (i : \u03a3 i, \u03b1 i), \u03b4 i.1 i.2) :\n  @sigma_curry _ _ \u03b4 _ (f + g) = (@sigma_curry _ _ \u03b4 _ f + @sigma_curry \u03b9 \u03b1 \u03b4 _ g) :=\nbegin\n  ext i j,\n  rw [@add_apply _ (\u03bb i, \u03a0\u2080 j, \u03b4 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 \u03b3] [\u03a0 i j, add_monoid (\u03b4 i j)]\n  [\u03a0 i j, distrib_mul_action \u03b3 (\u03b4 i j)] (r : \u03b3) (f : \u03a0\u2080 (i : \u03a3 i, \u03b1 i), \u03b4 i.1 i.2) :\n  @sigma_curry _ _ \u03b4 _ (r \u2022 f) = r \u2022 @sigma_curry _ _ \u03b4 _ f :=\nbegin\n  ext i j,\n  rw [@smul_apply _ _ (\u03bb i, \u03a0\u2080 j, \u03b4 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 \u03b9] [\u03a0 i, decidable_eq (\u03b1 i)]\n  [\u03a0 i j, has_zero (\u03b4 i j)] (ij : \u03a3 i, \u03b1 i) (x : \u03b4 ij.1 ij.2) :\n  @sigma_curry _ _ _ _ (single ij x) = single ij.1 (single ij.2 x : \u03a0\u2080 j, \u03b4 ij.1 j) :=\nbegin\n  obtain \u27e8i, j\u27e9 := 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 `\u03a0\u2080 i (j : \u03b1 i), \u03b4 i j` and `\u03a0\u2080 (i : \u03a3 i, \u03b1 i), \u03b4 i.1 i.2`, inverse of\n`curry`.-/\ndef sigma_uncurry [\u03a0 i j, has_zero (\u03b4 i j)]\n  [\u03a0 i, decidable_eq (\u03b1 i)] [\u03a0 i j (x : \u03b4 i j), decidable (x \u2260 0)] (f : \u03a0\u2080 i j, \u03b4 i j) :\n  \u03a0\u2080 (i : \u03a3 i, _), \u03b4 i.1 i.2 :=\n{ to_fun := \u03bb i, f i.1 i.2,\n  support' := f.support'.map $ \u03bb s,\n    \u27e8(multiset.bind \u2191s $ \u03bb i, ((f i).support.map \u27e8sigma.mk i, sigma_mk_injective\u27e9).val), \u03bb i, begin\n      simp_rw [multiset.mem_bind, map_val, multiset.mem_map, function.embedding.coe_fn_mk,\n        \u2190finset.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 \u27e8_, hi, i.2, hi', sigma.eta _\u27e9 } },\n      { right,\n        rw [hi, zero_apply] }\n    end\u27e9 }\n\n@[simp] lemma sigma_uncurry_apply [\u03a0 i j, has_zero (\u03b4 i j)]\n  [\u03a0 i, decidable_eq (\u03b1 i)] [\u03a0 i j (x : \u03b4 i j), decidable (x \u2260 0)]\n  (f : \u03a0\u2080 i j, \u03b4 i j) (i : \u03b9) (j : \u03b1 i) :\n  sigma_uncurry f \u27e8i, j\u27e9 = f i j :=\nrfl\n\n@[simp] lemma sigma_uncurry_zero [\u03a0 i j, has_zero (\u03b4 i j)]\n  [\u03a0 i, decidable_eq (\u03b1 i)] [\u03a0 i j (x : \u03b4 i j), decidable (x \u2260 0)]:\n  sigma_uncurry (0 : \u03a0\u2080 i j, \u03b4 i j) = 0 :=\nrfl\n\n@[simp] lemma sigma_uncurry_add [\u03a0 i j, add_zero_class (\u03b4 i j)]\n  [\u03a0 i, decidable_eq (\u03b1 i)] [\u03a0 i j (x : \u03b4 i j), decidable (x \u2260 0)]\n  (f g : \u03a0\u2080 i j, \u03b4 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 \u03b3] [\u03a0 i j, add_monoid (\u03b4 i j)]\n  [\u03a0 i, decidable_eq (\u03b1 i)] [\u03a0 i j (x : \u03b4 i j), decidable (x \u2260 0)]\n  [\u03a0 i j, distrib_mul_action \u03b3 (\u03b4 i j)] (r : \u03b3) (f : \u03a0\u2080 i j, \u03b4 i j) :\n  sigma_uncurry (r \u2022 f) = r \u2022 sigma_uncurry f :=\ncoe_fn_injective rfl\n\n@[simp] lemma sigma_uncurry_single [\u03a0 i j, has_zero (\u03b4 i j)]\n  [decidable_eq \u03b9] [\u03a0 i, decidable_eq (\u03b1 i)] [\u03a0 i j (x : \u03b4 i j), decidable (x \u2260 0)]\n  (i) (j : \u03b1 i) (x : \u03b4 i j) :\n  sigma_uncurry (single i (single j x : \u03a0\u2080 (j : \u03b1 i), \u03b4 i j)) = single \u27e8i, j\u27e9 x:=\nbegin\n  ext \u27e8i', j'\u27e9,\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 `\u03a0\u2080 (i : \u03a3 i, \u03b1 i), \u03b4 i.1 i.2` and `\u03a0\u2080 i (j : \u03b1 i), \u03b4 i j`.\n\nThis is the dfinsupp version of `equiv.Pi_curry`. -/\nnoncomputable def sigma_curry_equiv [\u03a0 i j, has_zero (\u03b4 i j)]\n  [\u03a0 i, decidable_eq (\u03b1 i)] [\u03a0 i j (x : \u03b4 i j), decidable (x \u2260 0)] :\n  (\u03a0\u2080 (i : \u03a3 i, _), \u03b4 i.1 i.2) \u2243 \u03a0\u2080 i j, \u03b4 i j :=\n{ to_fun := sigma_curry,\n  inv_fun := sigma_uncurry,\n  left_inv := \u03bb f, by { ext \u27e8i, j\u27e9, rw [sigma_uncurry_apply, sigma_curry_apply] },\n  right_inv := \u03bb f, by { ext i j, rw [sigma_curry_apply, sigma_uncurry_apply] } }\n\nend curry\n\nvariables {\u03b1 : option \u03b9 \u2192 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 [\u03a0 i, has_zero (\u03b1 i)] (a : \u03b1 none) (f : \u03a0\u2080 i, \u03b1 (some i)) : \u03a0\u2080 i, \u03b1 i :=\n{ to_fun := option.rec a f,\n  support' := f.support'.map $ \u03bb s, \u27e8none ::\u2098 multiset.map some s, \u03bb i,\n    option.rec (or.inl $ multiset.mem_cons_self _ _)\n      (\u03bb i, (s.prop i).imp_left $ \u03bb h, multiset.mem_cons_of_mem $ multiset.mem_map_of_mem _ h) i\u27e9 }\n\n@[simp] lemma extend_with_none [\u03a0 i, has_zero (\u03b1 i)] (f : \u03a0\u2080 i, \u03b1 (some i)) (a : \u03b1 none) :\n  f.extend_with a none = a :=\nrfl\n@[simp] lemma extend_with_some [\u03a0 i, has_zero (\u03b1 i)] (f : \u03a0\u2080 i, \u03b1 (some i)) (a : \u03b1 none) (i : \u03b9) :\n  f.extend_with a (some i) = f i :=\nrfl\n\n@[simp] lemma extend_with_single_zero [decidable_eq \u03b9] [\u03a0 i, has_zero (\u03b1 i)]\n  (i : \u03b9) (x : \u03b1 (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 \u03b9] [\u03a0 i, has_zero (\u03b1 i)] (x : \u03b1 none) :\n  (0 : \u03a0\u2080 i, \u03b1 (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 \u03b9`.\n\nThis is the dfinsupp version of `equiv.pi_option_equiv_prod`. -/\n@[simps] noncomputable def equiv_prod_dfinsupp [\u03a0 i, has_zero (\u03b1 i)] :\n  (\u03a0\u2080 i, \u03b1 i) \u2243 \u03b1 none \u00d7 \u03a0\u2080 i, \u03b1 (some i) :=\n{ to_fun := \u03bb f, (f none, comap_domain some (option.some_injective _) f),\n  inv_fun := \u03bb f, f.2.extend_with f.1,\n  left_inv := \u03bb 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 := \u03bb 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 [\u03a0 i, add_zero_class (\u03b1 i)] (f g : \u03a0\u2080 i, \u03b1 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 \u03b3] [\u03a0 i, add_monoid (\u03b1 i)] [\u03a0 i, distrib_mul_action \u03b3 (\u03b1 i)]\n  (r : \u03b3) (f : \u03a0\u2080 i, \u03b1 i) :\n  equiv_prod_dfinsupp (r \u2022 f) = r \u2022 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 [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 \u03b3) : \u03b3 :=\n\u220f i in f.support, g i (f i)\n\n@[to_additive]\nlemma prod_map_range_index {\u03b2\u2081 : \u03b9 \u2192 Type v\u2081} {\u03b2\u2082 : \u03b9 \u2192 Type v\u2082}\n  [\u03a0 i, has_zero (\u03b2\u2081 i)] [\u03a0 i, has_zero (\u03b2\u2082 i)]\n  [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)] [\u03a0 i (x : \u03b2\u2082 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  {f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i} {hf : \u2200 i, f i 0 = 0} {g : \u03a0\u2080 i, \u03b2\u2081 i} {h : \u03a0 i, \u03b2\u2082 i \u2192 \u03b3}\n  (h0 : \u2200i, h i 0 = 1) :\n  (map_range f hf g).prod h = g.prod (\u03bbi 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 [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {h : \u03a0 i, \u03b2 i \u2192 \u03b3} : (0 : \u03a0\u2080 i, \u03b2 i).prod h = 1 :=\nrfl\n\n@[to_additive]\nlemma prod_single_index [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  {i : \u03b9} {b : \u03b2 i} {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_zero : h i 0 = 1) :\n  (single i b).prod h = h i b :=\nbegin\n  by_cases h : b \u2260 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 [\u03a0 i, add_group (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  {g : \u03a0\u2080 i, \u03b2 i} {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h0 : \u2200i, h i 0 = 1) :\n  (-g).prod h = g.prod (\u03bbi b, h i (- b)) :=\nprod_map_range_index h0\n\nomit dec\n@[to_additive]\nlemma prod_comm {\u03b9\u2081 \u03b9\u2082 : Sort*} {\u03b2\u2081 : \u03b9\u2081 \u2192 Type*} {\u03b2\u2082 : \u03b9\u2082 \u2192 Type*}\n  [decidable_eq \u03b9\u2081] [decidable_eq \u03b9\u2082] [\u03a0 i, has_zero (\u03b2\u2081 i)] [\u03a0 i, has_zero (\u03b2\u2082 i)]\n  [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)] [\u03a0 i (x : \u03b2\u2082 i), decidable (x \u2260 0)] [comm_monoid \u03b3]\n  (f\u2081 : \u03a0\u2080 i, \u03b2\u2081 i) (f\u2082 : \u03a0\u2080 i, \u03b2\u2082 i) (h : \u03a0 i, \u03b2\u2081 i \u2192 \u03a0 i, \u03b2\u2082 i \u2192 \u03b3) :\n  f\u2081.prod (\u03bb i\u2081 x\u2081, f\u2082.prod $ \u03bb i\u2082 x\u2082, h i\u2081 x\u2081 i\u2082 x\u2082) =\n  f\u2082.prod (\u03bb i\u2082 x\u2082, f\u2081.prod $ \u03bb i\u2081 x\u2081, h i\u2081 x\u2081 i\u2082 x\u2082) := finset.prod_comm\n\n@[simp] lemma sum_apply {\u03b9\u2081 : Type u\u2081} [decidable_eq \u03b9\u2081] {\u03b2\u2081 : \u03b9\u2081 \u2192 Type v\u2081}\n  [\u03a0 i\u2081, has_zero (\u03b2\u2081 i\u2081)] [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  {f : \u03a0\u2080 i\u2081, \u03b2\u2081 i\u2081} {g : \u03a0 i\u2081, \u03b2\u2081 i\u2081 \u2192 \u03a0\u2080 i, \u03b2 i} {i\u2082 : \u03b9} :\n  (f.sum g) i\u2082 = f.sum (\u03bbi\u2081 b, g i\u2081 b i\u2082) :=\n(eval_add_monoid_hom i\u2082 : (\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b2 i\u2082).map_sum  _ f.support\n\ninclude dec\n\nlemma support_sum {\u03b9\u2081 : Type u\u2081} [decidable_eq \u03b9\u2081] {\u03b2\u2081 : \u03b9\u2081 \u2192 Type v\u2081}\n  [\u03a0 i\u2081, has_zero (\u03b2\u2081 i\u2081)] [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  {f : \u03a0\u2080 i\u2081, \u03b2\u2081 i\u2081} {g : \u03a0 i\u2081, \u03b2\u2081 i\u2081 \u2192 \u03a0\u2080 i, \u03b2 i} :\n  (f.sum g).support \u2286 f.support.bUnion (\u03bbi, (g i (f i)).support) :=\nhave \u2200i\u2081 : \u03b9, f.sum (\u03bb (i : \u03b9\u2081) (b : \u03b2\u2081 i), (g i b) i\u2081) \u2260 0 \u2192\n    (\u2203 (i : \u03b9\u2081), f i \u2260 0 \u2227 \u00ac (g i (f i)) i\u2081 = 0),\n  from assume i\u2081 h,\n  let \u27e8i, hi, ne\u27e9 := finset.exists_ne_zero_of_sum_ne_zero h in\n  \u27e8i, mem_support_iff.1 hi, ne\u27e9,\nby simpa [finset.subset_iff, mem_support_iff, finset.mem_bUnion, sum_apply] using this\n\n@[simp, to_additive] lemma prod_one [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {f : \u03a0\u2080 i, \u03b2 i} :\n  f.prod (\u03bbi b, (1 : \u03b3)) = 1 :=\nfinset.prod_const_one\n\n@[simp, to_additive] lemma prod_mul [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {f : \u03a0\u2080 i, \u03b2 i} {h\u2081 h\u2082 : \u03a0 i, \u03b2 i \u2192 \u03b3} :\n  f.prod (\u03bbi b, h\u2081 i b * h\u2082 i b) = f.prod h\u2081 * f.prod h\u2082 :=\nfinset.prod_mul_distrib\n\n@[simp, to_additive] lemma prod_inv [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_group \u03b3] {f : \u03a0\u2080 i, \u03b2 i} {h : \u03a0 i, \u03b2 i \u2192 \u03b3} :\n  f.prod (\u03bbi b, (h i b)\u207b\u00b9) = (f.prod h)\u207b\u00b9 :=\n((inv_monoid_hom : \u03b3 \u2192* \u03b3).map_prod _ f.support).symm\n\n@[to_additive] lemma prod_eq_one [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {f : \u03a0\u2080 i, \u03b2 i} {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (hyp : \u2200 i, h i (f i) = 1) :\n  f.prod h = 1 := finset.prod_eq_one $ \u03bb i hi, hyp i\n\nlemma smul_sum {\u03b1 : Type*} [monoid \u03b1] [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [add_comm_monoid \u03b3] [distrib_mul_action \u03b1 \u03b3] {f : \u03a0\u2080 i, \u03b2 i} {h : \u03a0 i, \u03b2 i \u2192 \u03b3} {c : \u03b1} :\n  c \u2022 f.sum h = f.sum (\u03bb a b, c \u2022 h a b) := finset.smul_sum\n\n@[to_additive]\nlemma prod_add_index [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {f g : \u03a0\u2080 i, \u03b2 i}\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_zero : \u2200i, h i 0 = 1) (h_add : \u2200i b\u2081 b\u2082, h i (b\u2081 + b\u2082) = h i b\u2081 * h i b\u2082) :\n  (f + g).prod h = f.prod h * g.prod h :=\nhave f_eq : \u220f i in f.support \u222a 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 : \u220f i in f.support \u222a 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 \u220f i in (f + g).support, h i ((f + g) i) =\n      \u220f i in f.support \u222a g.support, h i ((f + g) i) :\n    finset.prod_subset support_add $\n      by simp [mem_support_iff, h_zero] {contextual := tt}\n  ... = (\u220f i in f.support \u222a g.support, h i (f i)) *\n      (\u220f i in f.support \u222a 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 [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {S : Type*} [set_like S \u03b3] [submonoid_class S \u03b3] (s : S)\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 \u03b3) (h : \u2200 c, f c \u2260 0 \u2192 g c (f c) \u2208 s) : f.prod g \u2208 s :=\nprod_mem $ \u03bb i hi, h _ $ mem_support_iff.1 hi\n\n@[simp, to_additive] lemma prod_eq_prod_fintype [fintype \u03b9] [\u03a0 i, has_zero (\u03b2 i)]\n  [\u03a0 (i : \u03b9) (x : \u03b2 i), decidable (x \u2260 0)] [comm_monoid \u03b3] (v : \u03a0\u2080 i, \u03b2 i) [f : \u03a0 i, \u03b2 i \u2192 \u03b3]\n  (hf : \u2200 i, f i 0 = 1) :\n  v.prod f = \u220f i, f i (dfinsupp.equiv_fun_on_fintype v i) :=\nbegin\n  suffices : \u220f i in v.support, f i (v i) = \u220f 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3] (\u03c6 : \u03a0 i, \u03b2 i \u2192+ \u03b3) :\n  (\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b3 :=\n{ to_fun := (\u03bb f,\n    f.support'.lift (\u03bb s, \u2211 i in multiset.to_finset \u2191s, \u03c6 i (f i)) $\n    begin\n      rintros \u27e8sx, hx\u27e9 \u27e8sy, hy\u27e9,\n      dsimp only [subtype.coe_mk, to_fun_eq_coe] at *,\n      have H1 : sx.to_finset \u2229 sy.to_finset \u2286 sx.to_finset, from finset.inter_subset_left _ _,\n      have H2 : sx.to_finset \u2229 sy.to_finset \u2286 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 (\u03bb H3, and.intro H3 H1) H2), add_monoid_hom.map_zero] }\n    end),\n  map_add' := begin\n    rintros \u27e8f, sf, hf\u27e9 \u27e8g, sg, hg\u27e9,\n    change \u2211 i in _, _ = (\u2211 i in _, _) + (\u2211 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (\u03c6 : \u03a0 i, \u03b2 i \u2192+ \u03b3) (i) (x : \u03b2 i) : sum_add_hom \u03c6 (single i x) = \u03c6 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) (i : \u03b9) :\n  (sum_add_hom f).comp (single_add_hom \u03b2 i) = f i :=\nadd_monoid_hom.ext $ \u03bb 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 [\u03a0 i, add_zero_class (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [add_comm_monoid \u03b3] (\u03c6 : \u03a0 i, \u03b2 i \u2192+ \u03b3) (f : \u03a0\u2080 i, \u03b2 i) :\n  sum_add_hom \u03c6 f = f.sum (\u03bb x, \u03c6 x) :=\nbegin\n  rcases f with \u27e8f, s, hf\u27e9,\n  change \u2211 i in _, _ = (\u2211 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3] {S : Type*}\n  [set_like S \u03b3] [add_submonoid_class S \u03b3] (s : S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ \u03b3)\n  (h : \u2200 c, f c \u2260 0 \u2192 g c (f c) \u2208 s) : dfinsupp.sum_add_hom g f \u2208 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 `\u03b3`, and summing them. -/\nlemma _root_.add_submonoid.supr_eq_mrange_dfinsupp_sum_add_hom [add_comm_monoid \u03b3]\n  (S : \u03b9 \u2192 add_submonoid \u03b3) : supr S = (dfinsupp.sum_add_hom (\u03bb i, (S i).subtype)).mrange :=\nbegin\n  apply le_antisymm,\n  { apply supr_le _,\n    intros i y hy,\n    exact \u27e8dfinsupp.single i \u27e8y, hy\u27e9, dfinsupp.sum_add_hom_single _ _ _\u27e9, },\n  { rintros x \u27e8v, rfl\u27e9,\n    exact dfinsupp_sum_add_hom_mem _ v _ (\u03bb i _, (le_supr S i : S i \u2264 _) (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 `\u03b3`, and summing them. -/\nlemma _root_.add_submonoid.bsupr_eq_mrange_dfinsupp_sum_add_hom (p : \u03b9 \u2192 Prop)\n  [decidable_pred p] [add_comm_monoid \u03b3] (S : \u03b9 \u2192 add_submonoid \u03b3) :\n  (\u2a06 i (h : p i), S i) =\n    ((sum_add_hom (\u03bb i, (S i).subtype)).comp (filter_add_monoid_hom _ p)).mrange :=\nbegin\n  apply le_antisymm,\n  { refine supr\u2082_le (\u03bb i hi y hy, \u27e8dfinsupp.single i \u27e8y, hy\u27e9, _\u27e9),\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 \u27e8v, rfl\u27e9,\n    refine dfinsupp_sum_add_hom_mem _ _ _ (\u03bb 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 \u03b3]\n  (S : \u03b9 \u2192 add_submonoid \u03b3) (x : \u03b3) :\n  x \u2208 supr S \u2194 \u2203 f : \u03a0\u2080 i, S i, dfinsupp.sum_add_hom (\u03bb 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 \u03b3]\n  (S : \u03b9 \u2192 add_submonoid \u03b3) [\u03a0 i (x : S i), decidable (x \u2260 0)] (x : \u03b3) :\n  x \u2208 supr S \u2194 \u2203 f : \u03a0\u2080 i, S i, f.sum (\u03bb i xi, \u2191xi) = 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 : \u03b9 \u2192 Prop)\n  [decidable_pred p] [add_comm_monoid \u03b3] (S : \u03b9 \u2192 add_submonoid \u03b3) (x : \u03b3) :\n  x \u2208 (\u2a06 i (h : p i), S i) \u2194\n    \u2203 f : \u03a0\u2080 i, S i, dfinsupp.sum_add_hom (\u03bb 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 {\u03b9\u2081 \u03b9\u2082 : Sort*} {\u03b2\u2081 : \u03b9\u2081 \u2192 Type*} {\u03b2\u2082 : \u03b9\u2082 \u2192 Type*} {\u03b3 : Type*}\n  [decidable_eq \u03b9\u2081] [decidable_eq \u03b9\u2082] [\u03a0 i, add_zero_class (\u03b2\u2081 i)] [\u03a0 i, add_zero_class (\u03b2\u2082 i)]\n  [add_comm_monoid \u03b3]\n  (f\u2081 : \u03a0\u2080 i, \u03b2\u2081 i) (f\u2082 : \u03a0\u2080 i, \u03b2\u2082 i) (h : \u03a0 i j, \u03b2\u2081 i \u2192+ \u03b2\u2082 j \u2192+ \u03b3) :\n  sum_add_hom (\u03bb i\u2082, sum_add_hom (\u03bb i\u2081, h i\u2081 i\u2082) f\u2081) f\u2082 =\n  sum_add_hom (\u03bb i\u2081, sum_add_hom (\u03bb i\u2082, (h i\u2081 i\u2082).flip) f\u2082) f\u2081 :=\nbegin\n  obtain \u27e8\u27e8f\u2081, s\u2081, h\u2081\u27e9, \u27e8f\u2082, s\u2082, h\u2082\u27e9\u27e9 := \u27e8f\u2081, f\u2082\u27e9,\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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3] :\n  (\u03a0 i, \u03b2 i \u2192+ \u03b3) \u2243+ ((\u03a0\u2080 i, \u03b2 i) \u2192+ \u03b3) :=\n{ to_fun := sum_add_hom,\n  inv_fun := \u03bb F i, F.comp (single_add_hom \u03b2 i),\n  left_inv := \u03bb x, by { ext, simp },\n  right_inv := \u03bb \u03c8, by { ext, simp },\n  map_add' := \u03bb 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 [\u03a0 i, add_comm_monoid (\u03b2 i)] :\n  lift_add_hom (single_add_hom \u03b2) = add_monoid_hom.id (\u03a0\u2080 i, \u03b2 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) (i : \u03b9) (x : \u03b2 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) (i : \u03b9) :\n  (lift_add_hom f).comp (single_add_hom \u03b2 i) = f i :=\nby simp\n\n/-- The `dfinsupp` version of `finsupp.comp_lift_add_hom`,-/\nlemma comp_lift_add_hom {\u03b4 : Type*} [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  [add_comm_monoid \u03b4] (g : \u03b3 \u2192+ \u03b4) (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) :\n  g.comp (lift_add_hom f) = lift_add_hom (\u03bb a, g.comp (f a)) :=\nlift_add_hom.symm_apply_eq.1 $ funext $ \u03bb 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 [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3] :\n  sum_add_hom (\u03bb i, (0 : \u03b2 i \u2192+ \u03b3)) = 0 :=\n(lift_add_hom : (\u03a0 i, \u03b2 i \u2192+ \u03b3) \u2243+ _).map_zero\n\n@[simp]\nlemma sum_add_hom_add [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  (g : \u03a0 i, \u03b2 i \u2192+ \u03b3) (h : \u03a0 i, \u03b2 i \u2192+ \u03b3) :\n  sum_add_hom (\u03bb 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 [\u03a0 i, add_comm_monoid (\u03b2 i)] :\n  sum_add_hom (single_add_hom \u03b2) = add_monoid_hom.id _ :=\nlift_add_hom_single_add_hom\n\nlemma comp_sum_add_hom {\u03b4 : Type*} [\u03a0 i, add_zero_class (\u03b2 i)] [add_comm_monoid \u03b3]\n  [add_comm_monoid \u03b4] (g : \u03b3 \u2192+ \u03b4) (f : \u03a0 i, \u03b2 i \u2192+ \u03b3) :\n  g.comp (sum_add_hom f) = sum_add_hom (\u03bb a, g.comp (f a)) :=\ncomp_lift_add_hom _ _\n\nlemma sum_sub_index [\u03a0 i, add_group (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [add_comm_group \u03b3] {f g : \u03a0\u2080 i, \u03b2 i}\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_sub : \u2200i b\u2081 b\u2082, h i (b\u2081 - b\u2082) = h i b\u2081 - h i b\u2082) :\n  (f - g).sum h = f.sum h - g.sum h :=\nbegin\n  have := (lift_add_hom (\u03bb 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 {\u03b3 : Type w} {\u03b1 : Type x}\n  [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3]\n  {s : finset \u03b1} {g : \u03b1 \u2192 \u03a0\u2080 i, \u03b2 i}\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_zero : \u2200i, h i 0 = 1) (h_add : \u2200i b\u2081 b\u2082, h i (b\u2081 + b\u2082) = h i b\u2081 * h i b\u2082) :\n  \u220f i in s, (g i).prod h = (\u2211 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 {\u03b9\u2081 : Type u\u2081} [decidable_eq \u03b9\u2081] {\u03b2\u2081 : \u03b9\u2081 \u2192 Type v\u2081}\n  [\u03a0 i\u2081, has_zero (\u03b2\u2081 i\u2081)] [\u03a0 i (x : \u03b2\u2081 i), decidable (x \u2260 0)]\n  [\u03a0 i, add_comm_monoid (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3]\n  {f : \u03a0\u2080 i\u2081, \u03b2\u2081 i\u2081} {g : \u03a0 i\u2081, \u03b2\u2081 i\u2081 \u2192 \u03a0\u2080 i, \u03b2 i}\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (h_zero : \u2200i, h i 0 = 1) (h_add : \u2200i b\u2081 b\u2082, h i (b\u2081 + b\u2082) = h i b\u2081 * h i b\u2082) :\n  (f.sum g).prod h = f.prod (\u03bbi b, (g i b).prod h) :=\n(prod_finset_sum_index h_zero h_add).symm\n\n@[simp] lemma sum_single [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)] {f : \u03a0\u2080 i, \u03b2 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 [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n  [comm_monoid \u03b3] {v : \u03a0\u2080 i, \u03b2 i} {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {h : \u03a0 i, \u03b2 i \u2192 \u03b3} (hp : \u2200 x \u2208 v.support, p x) :\n  (v.subtype_domain p).prod (\u03bbi b, h i b) = v.prod h :=\nfinset.prod_bij (\u03bbp _, p)\n  (by simp) (by simp)\n  (assume \u27e8a\u2080, ha\u2080\u27e9 \u27e8a\u2081, ha\u2081\u27e9, by simp)\n  (\u03bb i hi, \u27e8\u27e8i, hp i hi\u27e9, by simpa using hi, rfl\u27e9)\n\nomit dec\nlemma subtype_domain_sum [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  {s : finset \u03b3} {h : \u03b3 \u2192 \u03a0\u2080 i, \u03b2 i} {p : \u03b9 \u2192 Prop} [decidable_pred p] :\n  (\u2211 c in s, h c).subtype_domain p = \u2211 c in s, (h c).subtype_domain p :=\n(subtype_domain_add_monoid_hom \u03b2 p).map_sum  _ s\n\nlemma subtype_domain_finsupp_sum {\u03b4 : \u03b3 \u2192 Type x} [decidable_eq \u03b3]\n  [\u03a0 c, has_zero (\u03b4 c)] [\u03a0 c (x : \u03b4 c), decidable (x \u2260 0)]\n  [\u03a0 i, add_comm_monoid (\u03b2 i)]\n  {p : \u03b9 \u2192 Prop} [decidable_pred p]\n  {s : \u03a0\u2080 c, \u03b4 c} {h : \u03a0 c, \u03b4 c \u2192 \u03a0\u2080 i, \u03b2 i} :\n  (s.sum h).subtype_domain p = s.sum (\u03bbc 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 [\u03a0 i, add_zero_class (\u03b2 i)] [\u03a0 i, add_zero_class (\u03b2\u2081 i)] [\u03a0 i, add_zero_class (\u03b2\u2082 i)]\n\nlemma map_range_add (f : \u03a0 i, \u03b2\u2081 i \u2192 \u03b2\u2082 i) (hf : \u2200 i, f i 0 = 0)\n  (hf' : \u2200 i x y, f i (x + y) = f i x + f i y) (g\u2081 g\u2082 : \u03a0\u2080 i, \u03b2\u2081 i):\n  map_range f hf (g\u2081 + g\u2082) = map_range f hf g\u2081 + map_range f hf g\u2082 :=\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 : \u03a0 i, \u03b2\u2081 i \u2192+ \u03b2\u2082 i) : (\u03a0\u2080 i, \u03b2\u2081 i) \u2192+ (\u03a0\u2080 i, \u03b2\u2082 i) :=\n{ to_fun := map_range (\u03bb i x, f i x) (\u03bb i, (f i).map_zero),\n  map_zero' := map_range_zero _ _,\n  map_add' := map_range_add _ _ (\u03bb i, (f i).map_add) }\n\n@[simp]\nlemma map_range.add_monoid_hom_id :\n  map_range.add_monoid_hom (\u03bb i, add_monoid_hom.id (\u03b2\u2082 i)) = add_monoid_hom.id _ :=\nadd_monoid_hom.ext map_range_id\n\nlemma map_range.add_monoid_hom_comp (f : \u03a0 i, \u03b2\u2081 i \u2192+ \u03b2\u2082 i) (f\u2082 : \u03a0 i, \u03b2 i \u2192+ \u03b2\u2081 i):\n  map_range.add_monoid_hom (\u03bb i, (f i).comp (f\u2082 i)) =\n    (map_range.add_monoid_hom f).comp (map_range.add_monoid_hom f\u2082) :=\nadd_monoid_hom.ext $ map_range_comp (\u03bb i x, f i x) (\u03bb i x, f\u2082 i x) _ _ _\n\n/-- `dfinsupp.map_range.add_monoid_hom` as an `add_equiv`. -/\n@[simps apply]\ndef map_range.add_equiv (e : \u03a0 i, \u03b2\u2081 i \u2243+ \u03b2\u2082 i) : (\u03a0\u2080 i, \u03b2\u2081 i) \u2243+ (\u03a0\u2080 i, \u03b2\u2082 i) :=\n{ to_fun := map_range (\u03bb i x, e i x) (\u03bb i, (e i).map_zero),\n  inv_fun := map_range (\u03bb i x, (e i).symm x) (\u03bb i, (e i).symm.map_zero),\n  left_inv := \u03bb x, by rw \u2190map_range_comp; { simp_rw add_equiv.symm_comp_self, simp },\n  right_inv := \u03bb x, by rw \u2190map_range_comp; { simp_rw add_equiv.self_comp_symm, simp },\n  .. map_range.add_monoid_hom (\u03bb i, (e i).to_add_monoid_hom) }\n\n@[simp]\nlemma map_range.add_equiv_refl :\n  (map_range.add_equiv $ \u03bb i, add_equiv.refl (\u03b2\u2081 i)) = add_equiv.refl _ :=\nadd_equiv.ext map_range_id\n\nlemma map_range.add_equiv_trans (f : \u03a0 i, \u03b2 i \u2243+ \u03b2\u2081 i) (f\u2082 : \u03a0 i, \u03b2\u2081 i \u2243+ \u03b2\u2082 i):\n  map_range.add_equiv (\u03bb i, (f i).trans (f\u2082 i)) =\n    (map_range.add_equiv f).trans (map_range.add_equiv f\u2082) :=\nadd_equiv.ext $ map_range_comp (\u03bb i x, f\u2082 i x) (\u03bb i x, f i x) _ _ _\n\n@[simp]\nlemma map_range.add_equiv_symm (e : \u03a0 i, \u03b2\u2081 i \u2243+ \u03b2\u2082 i) :\n  (map_range.add_equiv e).symm = map_range.add_equiv (\u03bb 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 \u03b9]\n\nnamespace monoid_hom\nvariables {R S : Type*}\nvariables [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n\n@[simp, to_additive]\nlemma map_dfinsupp_prod [comm_monoid R] [comm_monoid S]\n  (h : R \u2192* S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R) :\n  h (f.prod g) = f.prod (\u03bb a b, h (g a b)) := h.map_prod _ _\n\n@[to_additive]\nlemma coe_dfinsupp_prod [monoid R] [comm_monoid S]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R \u2192* S) :\n  \u21d1(f.prod g) = f.prod (\u03bb a b, (g a b)) := coe_finset_prod _ _\n\n@[simp, to_additive]\nlemma dfinsupp_prod_apply [monoid R] [comm_monoid S]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R \u2192* S) (r : R) :\n  (f.prod g) r = f.prod (\u03bb a b, (g a b) r) := finset_prod_apply _ _ _\n\nend monoid_hom\n\nnamespace ring_hom\nvariables {R S : Type*}\nvariables [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n\n@[simp]\nlemma map_dfinsupp_prod [comm_semiring R] [comm_semiring S]\n  (h : R \u2192+* S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R) :\n  h (f.prod g) = f.prod (\u03bb 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 \u2192+* S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R) :\n  h (f.sum g) = f.sum (\u03bb a b, h (g a b)) := h.map_sum _ _\n\nend ring_hom\n\nnamespace mul_equiv\nvariables {R S : Type*}\nvariables [\u03a0 i, has_zero (\u03b2 i)] [\u03a0 i (x : \u03b2 i), decidable (x \u2260 0)]\n\n@[simp, to_additive]\nlemma map_dfinsupp_prod [comm_monoid R] [comm_monoid S]\n  (h : R \u2243* S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192 R) :\n  h (f.prod g) = f.prod (\u03bb 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] [\u03a0 i, add_zero_class (\u03b2 i)]\n  (h : R \u2192+ S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ R) :\n  h (sum_add_hom g f) = sum_add_hom (\u03bb 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] [\u03a0 i, add_zero_class (\u03b2 i)]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ R \u2192+ S) (r : R) :\n  (sum_add_hom g f) r = sum_add_hom (\u03bb 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] [\u03a0 i, add_zero_class (\u03b2 i)]\n  (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ R \u2192+ S) :\n  \u21d1(sum_add_hom g f) = sum_add_hom (\u03bb 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  [\u03a0 i, add_zero_class (\u03b2 i)] (h : R \u2192+* S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ R) :\n  h (sum_add_hom g f) = sum_add_hom (\u03bb 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] [\u03a0 i, add_zero_class (\u03b2 i)]\n  (h : R \u2243+ S) (f : \u03a0\u2080 i, \u03b2 i) (g : \u03a0 i, \u03b2 i \u2192+ R) :\n  h (sum_add_hom g f) = sum_add_hom (\u03bb 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 {\u03b9 : Sort*} {\u03c0 : \u03b9 \u2192 Sort*} [decidable_eq \u03b9] [\u03a0 i, has_zero (\u03c0 i)]\n  [fintype \u03b9] [\u2200 i, fintype (\u03c0 i)] :\n  fintype (\u03a0\u2080 i, \u03c0 i) :=\nfintype.of_equiv (\u03a0 i, \u03c0 i) dfinsupp.equiv_fun_on_fintype.symm\n\ninstance dfinsupp.infinite_of_left {\u03b9 : Sort*} {\u03c0 : \u03b9 \u2192 Sort*}\n  [\u2200 i, nontrivial (\u03c0 i)] [\u03a0 i, has_zero (\u03c0 i)] [infinite \u03b9] :\n  infinite (\u03a0\u2080 i, \u03c0 i) :=\nby letI := classical.dec_eq \u03b9; choose m hm using (\u03bb i, exists_ne (0 : \u03c0 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 `\u03c0 i` to be infinite. -/\nlemma dfinsupp.infinite_of_exists_right {\u03b9 : Sort*} {\u03c0 : \u03b9 \u2192 Sort*}\n  (i : \u03b9) [infinite (\u03c0 i)] [\u03a0 i, has_zero (\u03c0 i)] :\n  infinite (\u03a0\u2080 i, \u03c0 i) :=\nby letI := classical.dec_eq \u03b9; exact\ninfinite.of_injective (\u03bb j, dfinsupp.single i j) dfinsupp.single_injective\n\n/-- See `dfinsupp.infinite_of_exists_right` for the case that only one `\u03c0 \u03b9` is infinite. -/\ninstance dfinsupp.infinite_of_right {\u03b9 : Sort*} {\u03c0 : \u03b9 \u2192 Sort*}\n  [\u2200 i, infinite (\u03c0 i)] [\u03a0 i, has_zero (\u03c0 i)] [nonempty \u03b9] :\n  infinite (\u03a0\u2080 i, \u03c0 i) :=\ndfinsupp.infinite_of_exists_right (classical.arbitrary \u03b9)\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\u2081, ..., l\u2099]` is a list whose `i`-th element comes from the `i`-th list.\n-/\n\n\nopen nat function\n\nnamespace list\nvariables {\u03b1 \u03b2 : Type*}\n\ntheorem mem_sections {L : list (list \u03b1)} {f} : f \u2208 sections L \u2194 forall\u2082 (\u2208) f L :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { induction L generalizing f, {cases mem_singleton.1 h, exact forall\u2082.nil},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map] at h,\n    rcases h with \u27e8_, _, _, _, rfl\u27e9,\n    simp only [*, forall\u2082_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 \u27e8_, fs, _, al, rfl, rfl\u27e9 }\nend\n\n\n\nlemma rel_sections {r : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  (forall\u2082 (forall\u2082 r) \u21d2 forall\u2082 (forall\u2082 r)) sections sections\n| _ _ forall\u2082.nil := forall\u2082.cons forall\u2082.nil forall\u2082.nil\n| _ _ (forall\u2082.cons h\u2080 h\u2081) :=\n  rel_bind (rel_sections h\u2081) (assume _ _ hl, rel_map (assume _ _ ha, forall\u2082.cons ha hl) h\u2080)\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 \u21aa V')\n  (df       : \u03a0 e : G.dart, G'.walk (f e.fst) (f e.snd))\n  --\n  (nodup    : \u2200 e : G.dart, (df e).support.nodup)\n  (sym      : \u2200 e : G.dart, df e.symm = (df e).reverse)\n  --\n  (endpoint : \u2200 {e x}, f x \u2208 (df e).support \u2192 x \u2208 e.edge)\n  --\n  (disjoint : \u2200 {e e' z}, z \u2208 (df e).support \u2192 z \u2208 (df e').support \u2192\n    e.edge = e'.edge \u2228 \u2203 x, z = f x)\n\ndef embeds_into (G : simple_graph V) (G' : simple_graph V') := nonempty (path_embedding G G')\n\ninfix ` \u227ct `: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 $ \u03bb h, G.ne_of_adj e.is_adj $ F.f.injective $ point_of_size_0 h\n\n@[simp] def follow : \u03a0 {x y : V}, walk G x y \u2192 walk G' (F.f x) (F.f y)\n| _ _ nil        := nil\n| _ _ (cons h p) := F.df \u27e8\u27e8_,_\u27e9,h\u27e9 ++ 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\u2081 : 0 < p.length) (h\u2082 : z' \u2208 (follow F p).support) :\n  \u2203 e \u2208 darts p, z' \u2208 (F.df e).support :=\nbegin\n  induction p with u u v w h p ih, {simp at h\u2081, contradiction}, clear h\u2081,\n  simp only [follow, mem_support_append_iff] at h\u2082, cases h\u2082,\n  { exact \u27e8\u27e8\u27e8_,_\u27e9, h\u27e9, or.inl rfl, h\u2082\u27e9 },\n  { cases p,\n    { refine \u27e8\u27e8\u27e8_,_\u27e9,h\u27e9, or.inl rfl, _\u27e9, simp only [follow, support_nil, list.mem_singleton] at h\u2082,\n      rw h\u2082, exact end_mem_support _ },\n    { specialize ih _ h\u2082, simp only [length_cons, nat.succ_pos'],\n      choose e h\u2083 h\u2084 using ih, exact \u27e8e, or.inr h\u2083, h\u2084\u27e9 } }\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 \u27e8F.nodup _, ih h.2, _\u27e9, 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 \u27e8e,h7,h8\u27e9 := 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 \u27e8e,h7,_\u27e9, rw <-h9,\n        exact sym2.mem_mk_left _ _ },\n      { obtain \u27e8v,_\u27e9 := 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 \u27e8\u27e8ex,ey\u27e9,he\u27e9, 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 \u27e8\u27e8_,_\u27e9,h\u27e9\nend\n\ndef comp (F : path_embedding G G') (F' : path_embedding G' G'') : path_embedding G G'' :=\n{ f := \u27e8F'.f \u2218 F.f, injective.comp F'.f.inj' F.f.inj'\u27e9,\n  df := \u03bb e, follow F' (F.df e),\n  --\n  nodup := \u03bb 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 \u27e8e',h4,h5\u27e9 := mem_follow F' (nop F) h1,\n    exact F.endpoint ((walk.mem_of_edges (nop _)).mpr \u27e8e',h4,F'.endpoint h5\u27e9)\n  },\n  --\n  disjoint := by {\n    intros e e' z h1 h2,\n    replace h1 := mem_follow _ (nop _) h1, obtain \u27e8e1,h3,h4\u27e9 := h1,\n    replace h2 := mem_follow _ (nop _) h2, obtain \u27e8e2,h5,h6\u27e9 := 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 \u2208 (F.df e').support \u2227 e1.snd \u2208 (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 \u27e8x,h10\u27e9 := h10, rw h10 at h3 h5,\n      cases F.disjoint h3.2 h5.2 with h11 h11, exact h11, obtain \u27e8y,h11\u27e9 := 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 \u2260 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 \u27e8y,h8\u27e9 := 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 \u2208 (F.df e).support, by { simp only [dart.edge, sym2.mem_iff] at h4,\n        rcases e1 with \u27e8\u27e8e1x,e1y\u27e9,e1h\u27e9, simp at h4,\n        cases h4; subst h4, exact h3.1, exact h3.2 },\n      replace h5 : y \u2208 (F.df e').support, by { simp only [dart.edge, sym2.mem_iff] at h6,\n        rcases e2 with \u27e8\u27e8e2x,e2y\u27e9,e2h\u27e9, 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 \u27e8x,h9\u27e9 := h9, subst h9, right, use x, refl } } } }\n\ntheorem trans : embeds_into G G' \u2192 embeds_into G' G'' \u2192 embeds_into G G'' :=\n\u03bb \u27e8F\u27e9 \u27e8F'\u27e9, \u27e8comp F F'\u27e9\n\ndef from_hom (f : G \u2192g G') (inj : injective f) : path_embedding G G' :=\n{ f := \u27e8f, inj\u27e9,\n  df := \u03bb e, cons (f.map_rel' e.is_adj) nil,\n  nodup := \u03bb 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 := \u03bb 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 := \u03bb 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 \u27e8\u27e8ex,ey\u27e9,eh\u27e9, simp,\n    cases h, { left, exact inj h }, { right, exact inj h } },\n  --\n  disjoint := by { intros e e' z h\u2081 h\u2082, right, cases h\u2081, subst h\u2081, exact \u27e8e.fst,rfl\u27e9,\n    cases h\u2081, subst h\u2081, exact \u27e8e.snd,rfl\u27e9, cases h\u2081 } }\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 : \u00ac nat.coprime 0 0 := by norm_num\nexample : \u00ac nat.coprime 0 3 := by norm_num\nexample : \u00ac nat.coprime 2 0 := by norm_num\nexample : nat.coprime 2 3 := by norm_num\nexample : \u00ac 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 : \u00ac nat.prime 0 := by norm_num\nexample : \u00ac nat.prime 1 := by norm_num\nexample : nat.prime 2 := by norm_num\nexample : nat.prime 3 := by norm_num\nexample : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac 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 : \u00ac squarefree 0 := by norm_num\nexample : squarefree 1 := by norm_num\nexample : squarefree 2 := by norm_num\nexample : squarefree 3 := by norm_num\nexample : \u00ac squarefree 4 := by norm_num\nexample : squarefree 5 := by norm_num\nexample : squarefree 6 := by norm_num\nexample : squarefree 7 := by norm_num\nexample : \u00ac squarefree 8 := by norm_num\nexample : \u00ac squarefree 9 := by norm_num\nexample : squarefree 10 := by norm_num\nexample : squarefree (2*3*5*17) := by norm_num\nexample : \u00ac 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 : \u211d) ^ (3 : \u211d) = 8 := by norm_num\nexample : (1 : \u211d) ^ (20 : \u211d) = 1 := by norm_num\nexample : (2 : \u211d) ^ (-3 : \u211d) = 1/8 := by norm_num\n\nsection big_operators\n\nvariables {\u03b1 : Type*} [comm_ring \u03b1]\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 \u211a).map (\u03bb 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 ::\u2098 2 ::\u2098 1 ::\u2098 3 ::\u2098 {}).sum = 7 := by norm_num [-multiset.sum_cons]\nexample : ((1 ::\u2098 2 ::\u2098 1 ::\u2098 3 ::\u2098 {}).map (\u03bb i, i^2)).sum = 15 := by norm_num [-multiset.map_cons]\nexample : (({1, 2, 1, 3} : multiset \u211a).map (\u03bb 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 : (\u2191[1, 2, 1, 3] : multiset \u2115).sum = 7 := by norm_num\n\n-- Finsets:\nexample (f : fin 0 \u2192 \u03b1) : \u2211 i : fin 0, f i = 0 := by norm_num\nexample (f : \u2115 \u2192 \u03b1) : \u2211 i in (\u2205 : finset \u2115), f i = 0 := by norm_num\nexample (f : fin 3 \u2192 \u03b1) : \u2211 i : fin 3, f i = f 0 + f 1 + f 2 := by norm_num; ring\nexample (f : fin 4 \u2192 \u03b1) : \u2211 i : fin 4, f i = f 0 + f 1 + f 2 + f 3 := by norm_num; ring\nexample (f : \u2115 \u2192 \u03b1) : \u2211 i in {0, 1, 2}, f i = f 0 + f 1 + f 2 := by norm_num; ring\nexample (f : \u2115 \u2192 \u03b1) : \u2211 i in {0, 2, 2, 3, 1, 0}, f i = f 0 + f 1 + f 2 + f 3 := by norm_num; ring\nexample (f : \u2115 \u2192 \u03b1) : \u2211 i in {0, 2, 2 - 3, 3 - 1, 1, 0}, f i = f 0 + f 1 + f 2 := by norm_num; ring\nexample : (\u2211 i in finset.range 10, (i^2 : \u2115)) = 285 := by norm_num\nexample : (\u2211 i in finset.Icc 5 10, (i^2 : \u2115)) = 355 := by norm_num\nexample : (\u2211 i in finset.Ico 5 10, (i^2 : \u2115)) = 255 := by norm_num\nexample : (\u2211 i in finset.Ioc 5 10, (i^2 : \u2115)) = 330 := by norm_num\nexample : (\u2211 i in finset.Ioo 5 10, (i^2 : \u2115)) = 230 := by norm_num\nexample : (\u2211 i : \u2124 in finset.Ioo (-5) 5, i^2) = 60 := by norm_num\nexample (f : \u2115 \u2192 \u03b1) : \u2211 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 : \u220f i in finset.range 9, nat.sqrt (i + 1) = 96 := by norm_num\nexample : \u220f i in {1, 4, 9, 16}, nat.sqrt i = 24 := by norm_num\nexample : \u220f i in finset.Icc 0 8, nat.sqrt (i + 1) = 96 := by norm_num\n\n-- Nested operations:\nexample : \u2211 i : fin 2, \u2211 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) := \u27e8by norm_num\u27e9\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 (\u03b1\u2081 : Type _) (\u03b1\u2082 : Type _) [NCSemiring \u03b1\u2081] [NCSemiring \u03b1\u2082] : NCSemiring (\u03b1\u2081 \u00d7 \u03b1\u2082) where\n      one               := (1, 1)\n      mul               := fun (a\u2081, a\u2082) (b\u2081, b\u2082) => (a\u2081 * b\u2081, a\u2082 * b\u2082)\n      mul_one           := fun (a\u2081, a\u2082) => by simp [HMul.hMul, Mul.mul]; exact \u27e8mul_one a\u2081, mul_one a\u2082\u27e9\n      one_mul           := fun (a\u2081, a\u2082) => by simp [HMul.hMul, Mul.mul]; exact \u27e8one_mul a\u2081, one_mul a\u2082\u27e9\n      mul_assoc         := fun (a\u2081, a\u2082) (b\u2081, b\u2082) (c\u2081, c\u2082) => by\n        simp [HMul.hMul, Mul.mul];exact \u27e8mul_assoc a\u2081 b\u2081 c\u2081, mul_assoc a\u2082 b\u2082 c\u2082\u27e9\n      mul_distrib_left  := fun (a\u2081, a\u2082) (b\u2081, b\u2082) (c\u2081, c\u2082) => by\n        simp [HMul.hMul, Mul.mul, HAdd.hAdd, Add.add]; exact \u27e8mul_distrib_left a\u2081 b\u2081 c\u2081, mul_distrib_left a\u2082 b\u2082 c\u2082\u27e9\n      mul_distrib_right := fun (a\u2081, a\u2082) (b\u2081, b\u2082) (c\u2081, c\u2082) => by\n        simp [HMul.hMul, Mul.mul, HAdd.hAdd, Add.add]; exact \u27e8mul_distrib_right a\u2081 b\u2081 c\u2081, mul_distrib_right a\u2082 b\u2082 c\u2082\u27e9\n      mul_zero          := fun (a\u2081, a\u2082) => by\n        simp [HMul.hMul, Mul.mul, Monoid.product_zero]; exact \u27e8mul_zero a\u2081, mul_zero a\u2082\u27e9\n      zero_mul          := fun (a\u2081, a\u2082) => by\n        simp [HMul.hMul, Mul.mul, Monoid.product_zero]; exact \u27e8zero_mul a\u2081, zero_mul a\u2082\u27e9\n\n    theorem product_mul {\u03b1\u2081 : Type _} {\u03b1\u2082 : Type _} [NCSemiring \u03b1\u2081] [NCSemiring \u03b1\u2082] : \u2200 x y : \u03b1\u2081 \u00d7 \u03b1\u2082, x * y = (x.fst * y.fst, x.snd * y.snd) :=\n      fun (x\u2081, x\u2082) (y\u2081, y\u2082) => rfl\n\n    protected instance multi_product.One {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, One (f\u03b9 i)] : One (MultiProd f\u03b9) where\n      one := fun _ => 1\n    protected theorem multi_product.One_def {\u03b9 : Type _} {f\u03b9 : \u03b9 \u2192 Type _} [\u2200 i, One (f\u03b9 i)] : \u2200 i, (1 : MultiProd f\u03b9) i = 1 :=\n      fun _ => rfl\n\n    protected instance multi_product.Mul {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, Mul (f\u03b9 i)] : Mul (MultiProd f\u03b9) where\n      mul := fun a b i => a i * b i\n    protected theorem multi_product.Mul_def {\u03b9 : Type _} {f\u03b9 : \u03b9 \u2192 Type _} [\u2200 i, Mul (f\u03b9 i)] (a b : MultiProd f\u03b9) :\n      \u2200 i, (a * b) i = a i * b i := fun _ => rfl\n\n    protected instance multi_product {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, NCSemiring (f\u03b9 i)] : NCSemiring (MultiProd f\u03b9) 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 \u03b1] (n : Nat) : n.succ = (n : \u03b1) + 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 \u03b1] (m n : Nat) : m + n = (m : \u03b1) + 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 \u03b1] (a : \u03b1) (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 \u03b1] (a : \u03b1) (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 \u03b1] (n : Nat) : (1 : \u03b1)^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 \u03b1] (a : \u03b1) : a ^ (0 : Nat) = 1 := rfl\n    theorem pow_nat_1 [NCSemiring \u03b1] (a : \u03b1) : a ^ (1 : Nat) = a := rfl\n\n    theorem pow_nat_add_distrib [NCSemiring \u03b1] (a : \u03b1) (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, \u2190mul_assoc, ih]\n\n    protected class constructor_ncsr (\u03b1 : Type _) extends CommMonoid.constructor_cm \u03b1, One \u03b1, Mul \u03b1 where\n      mul_one           : \u2200 a : \u03b1, a * 1 = a\n      one_mul           : \u2200 a : \u03b1, 1 * a = a\n      mul_assoc         : \u2200 a b c : \u03b1, (a * b) * c = a * (b * c)\n      mul_distrib_left  : \u2200 a b c : \u03b1, a * (b + c) = a * b + a * c\n      mul_distrib_right : \u2200 a b c : \u03b1, (a + b) * c = a * c + b * c\n      mul_zero          : \u2200 a : \u03b1, a * 0 = 0\n      zero_mul          : \u2200 a : \u03b1, 0 * a = 0\n\n    protected def construct {\u03b1 : Type _} (c : NCSemiring.constructor_ncsr \u03b1) : NCSemiring \u03b1 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 (\u03b1 : Type _) [NCSemiring \u03b1] : NCSemiring.constructor_ncsr \u03b1 where\n      toconstructor_cm := CommMonoid.to_constructor \u03b1\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 (\u03b1\u2081 : Type _) (\u03b1\u2082 : Type _) [Semiring \u03b1\u2081] [Semiring \u03b1\u2082] : Semiring (\u03b1\u2081 \u00d7 \u03b1\u2082) where\n      mul_comm := fun (a\u2081, a\u2082) (b\u2081, b\u2082) => by simp [HMul.hMul, Mul.mul]; exact \u27e8mul_comm a\u2081 b\u2081, mul_comm a\u2082 b\u2082\u27e9\n\n    protected instance multi_product {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, Semiring (f\u03b9 i)] : Semiring (MultiProd f\u03b9) where\n      mul_comm := fun a b => funext fun i => Semiring.mul_comm (a i) (b i)\n\n    theorem mul_right_comm [Semiring \u03b1] (a b c : \u03b1) : a * b * c = a * c * b := by\n      rw [mul_assoc, mul_comm b, \u2190mul_assoc]\n    theorem mul_left_comm [Semiring \u03b1] (a b c : \u03b1) : a * (b * c) = b * (a * c) := by\n      rw [\u2190mul_assoc, mul_comm a, mul_assoc]\n\n    theorem divides_self [Semiring \u03b1] (a : \u03b1) : a \u00f7 a := \u27e81, mul_one a\u27e9\n    theorem divides_zero [Semiring \u03b1] (a : \u03b1) : a \u00f7 0 := \u27e80, mul_zero a\u27e9\n    theorem divides_add [Semiring \u03b1] {a b c : \u03b1} : a \u00f7 b \u2192 a \u00f7 c \u2192 a \u00f7 (b + c)\n    | \u27e8x, axb\u27e9, \u27e8y, ayc\u27e9 => \u27e8x + y, by rw [mul_distrib_left, axb, ayc]\u27e9\n    theorem divides_mul [Semiring \u03b1] {a b : \u03b1} (c : \u03b1) : a \u00f7 b \u2192 a \u00f7 (b * c)\n    | \u27e8x, axb\u27e9 => \u27e8x * c, by rw [\u2190mul_assoc, axb]\u27e9\n    theorem divides_mul' [Semiring \u03b1] {a c : \u03b1} (b : \u03b1) : a \u00f7 c \u2192 a \u00f7 (b * c) := by\n      rw [mul_comm]; exact divides_mul b\n\n    theorem isUnit_1 [Semiring \u03b1] : isUnit (1 : \u03b1) := \u27e81, by simp [one_mul]\u27e9\n    theorem notUnit_0 [Semiring \u03b1] : (0 : \u03b1) \u2260 (1 : \u03b1) \u2192 \u00acisUnit (0 : \u03b1) := by\n      intro h\u2081 \u27e8_, h\u2082\u27e9; rw [zero_mul] at h\u2082; exact h\u2081 h\u2082\n    theorem unit_mul [Semiring \u03b1] {a b : \u03b1} : isUnit a \u2192 isUnit b \u2192 isUnit (a * b)\n    | \u27e8x, xs\u27e9, \u27e8y, ys\u27e9 => by\n      apply Exists.intro (y * x); rw [mul_assoc, \u2190mul_assoc b, ys, one_mul, xs]\n    theorem divides_unit [Semiring \u03b1] {a b : \u03b1} : isUnit b \u2192 a \u00f7 b \u2192 isUnit a := by\n      intro ub ab\n      let \u27e8binv, bbinv\u27e9 := Classical.indefiniteDescription _ ub\n      let \u27e8c, ac\u27e9 := Classical.indefiniteDescription _ ab\n      exact \u27e8c * binv, by rw [\u2190mul_assoc, ac, bbinv]\u27e9\n    theorem unit_divides [Semiring \u03b1] : \u2200 a b : \u03b1, isUnit a \u2192 a \u00f7 b := by\n      intro a b \u27e8c, ac\u27e9; exact \u27e8c * b, by rw [\u2190mul_assoc, ac, one_mul]\u27e9\n\n    def unit_set (\u03b1 : Type _) [Semiring \u03b1] : Set \u03b1 := {x | isUnit x}\n\n    noncomputable def unit_inv [Semiring \u03b1] {a : \u03b1} (h : isUnit a) : \u03b1 :=\n      Classical.choose h\n    theorem mul_unit_inv [Semiring \u03b1] {a : \u03b1} (h : isUnit a) : a * unit_inv h = 1 :=\n      Classical.choose_spec h\n    theorem unit_inv_mul [Semiring \u03b1] {a : \u03b1} (h : isUnit a) : unit_inv h * a = 1 := by\n      rw [mul_comm]; exact mul_unit_inv h\n\n    noncomputable instance UnitGroup [Semiring \u03b1] : Group \u2191(unit_set \u03b1) := Group.construct\n    {\n      zero := \u27e81, \u27e81, by rw [mul_one]\u27e9\u27e9\n      add := fun a b => \u27e8a.val * b.val, unit_mul a.property b.property\u27e9\n      neg := fun \u27e8x, xs\u27e9 => \u27e8unit_inv xs, x, unit_inv_mul xs\u27e9\n      add_zero := fun \u27e8a, _\u27e9 => Set.elementExt (mul_one a)\n      add_assoc := fun \u27e8a, _\u27e9 \u27e8b, _\u27e9 \u27e8c, _\u27e9 => Set.elementExt (mul_assoc a b c)\n      add_neg := fun \u27e8a, as\u27e9 => Set.elementExt (mul_unit_inv as)\n    }\n\n    theorem pow_nat_mul_distrib [Semiring \u03b1] (a b : \u03b1) (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, \u2190mul_assoc, ih, mul_comm]\n\n    theorem pow_nat_comp [Semiring \u03b1] (a : \u03b1) (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 (\u03b1 : Type _) extends CommMonoid.constructor_cm \u03b1, One \u03b1, Mul \u03b1 where\n      mul_one           : \u2200 a : \u03b1, a * 1 = a\n      mul_assoc         : \u2200 a b c : \u03b1, (a * b) * c = a * (b * c)\n      mul_distrib_left  : \u2200 a b c : \u03b1, a * (b + c) = a * b + a * c\n      mul_zero          : \u2200 a : \u03b1, a * 0 = 0\n      mul_comm          : \u2200 a b : \u03b1, a * b = b * a\n\n    protected def construct {\u03b1 : Type _} (c : Semiring.constructor_sr \u03b1) : Semiring \u03b1 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 (\u03b1 : Type _) [Semiring \u03b1] : Semiring.constructor_sr \u03b1 where\n      toconstructor_cm  := CommMonoid.to_constructor \u03b1\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 : (\u22a4 : 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\u27e8subalgebra.fg_of_submodule_fg hRA.1\u27e9\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 := \u27e8\u27e8{1}, subsingleton.elim _ _\u27e9\u27e9\n\nprotected lemma polynomial : finite_type R R[X] :=\n\u27e8\u27e8{polynomial.X}, by { rw finset.coe_singleton, exact polynomial.adjoin_X }\u27e9\u27e9\n\nopen_locale classical\n\nprotected lemma mv_polynomial (\u03b9 : Type*) [finite \u03b9] : finite_type R (mv_polynomial \u03b9 R) :=\nby casesI nonempty_fintype \u03b9; exact \u27e8\u27e8finset.univ.image mv_polynomial.X,\n  by {rw [finset.coe_image, finset.coe_univ, set.image_univ], exact mv_polynomial.adjoin_range_X}\u27e9\u27e9\n\n\n\nvariables {R A B}\n\nlemma of_surjective (hRA : finite_type R A) (f : A \u2192\u2090[R] B) (hf : surjective f) :\n  finite_type R B :=\n\u27e8begin\n  convert hRA.1.map f,\n  simpa only [map_top f, @eq_comm _ \u22a4, eq_top_iff, alg_hom.mem_range] using hf\nend\u27e9\n\nlemma equiv (hRA : finite_type R A) (e : A \u2243\u2090[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\u27e8fg_trans' hRA.1 hAB.1\u27e9\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) \u2194 \u2203 (s : finset A)\n  (f : (mv_polynomial {x // x \u2208 s} R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rintro \u27e8s, hs\u27e9,\n    use [s, mv_polynomial.aeval coe],\n    intro x,\n    have hrw : (\u2191s : set A) = (\u03bb (x : A), x \u2208 s.val) := rfl,\n    rw [\u2190 set.mem_range, \u2190 alg_hom.coe_range, \u2190 adjoin_eq_range, \u2190 hrw, hs],\n    exact set.mem_univ x },\n  { rintro \u27e8s, \u27e8f, hsur\u27e9\u27e9,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R {x // x \u2208 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) \u2194 \u2203 (\u03b9 : Type u_2) (_ : fintype \u03b9)\n  (f : (mv_polynomial \u03b9 R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial,\n    rintro \u27e8s, \u27e8f, hsur\u27e9\u27e9,\n    use [{x // x \u2208 s}, by apply_instance, f, hsur] },\n  { rintro \u27e8\u03b9, \u27e8hfintype, \u27e8f, hsur\u27e9\u27e9\u27e9,\n    letI : fintype \u03b9 := hfintype,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R \u03b9) 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) \u2194 \u2203 (n : \u2115)\n  (f : (mv_polynomial (fin n) R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial',\n    rintro \u27e8\u03b9, hfintype, \u27e8f, hsur\u27e9\u27e9,\n    resetI,\n    have equiv := mv_polynomial.rename_equiv R (fintype.equiv_fin \u03b9),\n    exact \u27e8fintype.card \u03b9, alg_hom.comp f equiv.symm, function.surjective.comp hsur\n      (alg_equiv.symm equiv).surjective\u27e9 },\n  { rintro \u27e8n, \u27e8f, hsur\u27e9\u27e9,\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 \u00d7 B) :=\n\u27e8begin\n  rw \u2190 subalgebra.prod_top,\n  exact hA.1.prod hB.1\nend\u27e9\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 \u27e8s, hs\u27e9 := h.1,\n  apply is_noetherian_ring_of_surjective\n    (mv_polynomial s R) S (mv_polynomial.aeval coe : mv_polynomial s R \u2192\u2090[R] S),\n  rw [\u2190 set.range_iff_surjective, alg_hom.coe_to_ring_hom, \u2190 alg_hom.coe_range,\n    \u2190 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 \u2194 algebra.finite_type R S :=\nS.fg_top.symm.trans \u27e8\u03bb h, \u27e8h\u27e9, \u03bb h, h.out\u27e9\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 \u2192+* B` is of `finite_type` if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A \u2192+* B) : Prop := @algebra.finite_type A B _ _ f.to_algebra\n\nnamespace finite\n\nvariables {A}\n\nlemma finite_type {f : A \u2192+* 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 \u2192+* B} {g : B \u2192+* 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' := \u03bb a, rfl, .. g } hg\n\nlemma of_surjective (f : A \u2192+* B) (hf : surjective f) : f.finite_type :=\nby { rw \u2190 f.comp_id, exact (id A).comp_surjective hf }\n\nlemma comp {g : B \u2192+* C} {f : A \u2192+* 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 \u2192+* B} (hf : f.finite) : f.finite_type :=\n@module.finite.finite_type _ _ _ _ f.to_algebra hf\n\nalias of_finite \u2190 _root_.ring_hom.finite.to_finite_type\n\nlemma of_comp_finite_type {f : A \u2192+* B} {g : B \u2192+* 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 \u2192\u2090[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 \u2192\u2090[R] B) : Prop := f.to_ring_hom.finite_type\n\nnamespace finite\n\nvariables {R A}\n\nlemma finite_type {f : A \u2192\u2090[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 \u2192\u2090[R] C} {f : A \u2192\u2090[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 \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[R] B) (hf : surjective f) : f.finite_type :=\nring_hom.finite_type.of_surjective f hf\n\nlemma of_comp_finite_type {f : A \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2208 adjoin R (of' R M '' f.support) :=\nbegin\n  suffices : span R (of' R M '' f.support) \u2264 (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 = \u22a4) :\n  algebra.adjoin R (\u22c3 f \u2208 S, (of' R M '' (f.support : set M))) = \u22a4 :=\nbegin\n  refine le_antisymm le_top _,\n  rw [\u2190 hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : of' R M '' f.support \u2286\n    \u22c3 (g : add_monoid_algebra R M) (H : g \u2208 S), of' R M '' g.support,\n  { intros s hs,\n    exact set.mem_Union\u2082.2 \u27e8f, \u27e8hf, hs\u27e9\u27e9 },\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 = \u22a4) :\n  algebra.adjoin R (of' R M '' (\u22c3 f \u2208 S, (f.support : set M))) = \u22a4 :=\nbegin\n  suffices : of' R M '' (\u22c3 f \u2208 S, (f.support : set M)) = \u22c3 f \u2208 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  \u2203 G : finset M, algebra.adjoin R (of' R M '' G) = \u22a4 :=\nbegin\n  unfreezingI { obtain \u27e8S, hS\u27e9 := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (\u03bb f, f.support),\n  have : (finset.bUnion S (\u03bb f, f.support) : set M) = \u22c3 f \u2208 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 \u2208 S`. -/\nlemma of'_mem_span [nontrivial R] {m : M} {S : set M} :\n  of' R M m \u2208 span R (of' R M '' S) \u2194 m \u2208 S :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, submodule.subset_span $ set.mem_image_of_mem (of R M) h\u27e9,\n  rw [of', \u2190 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 \u2208 closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of' R M m \u2208 span R (submonoid.closure (of' R M '' S) : set (add_monoid_algebra R M))) :\n  m \u2208 closure S :=\nbegin\n  suffices : multiplicative.of_add m \u2208 submonoid.closure (multiplicative.to_add \u207b\u00b9' S),\n  { simpa [\u2190 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 ((\u03bb (x : M), (of R M) x) '' S) :=\n    monoid_hom.map_mclosure _ _,\n  rw [set.image_congr' (show \u2200 x, of' R M x = of R M x, from \u03bb x, of'_eq_of x), \u2190 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 = \u22a4) : function.surjective (mv_polynomial.aeval\n  (\u03bb (s : S), of' R M \u2191s) : mv_polynomial S R \u2192 add_monoid_algebra R M) :=\nbegin\n  refine \u03bb f, induction_on f (\u03bb m, _) _ _,\n  { have : m \u2208 closure S := hS.symm \u25b8 mem_top _,\n    refine closure_induction this (\u03bb m hm, _) _ _,\n    { exact \u27e8mv_polynomial.X \u27e8m, hm\u27e9, mv_polynomial.aeval_X _ _\u27e9 },\n    { exact \u27e81, alg_hom.map_one _\u27e9 },\n    { rintro m\u2081 m\u2082 \u27e8P\u2081, hP\u2081\u27e9 \u27e8P\u2082, hP\u2082\u27e9,\n      exact \u27e8P\u2081 * P\u2082, by rw [alg_hom.map_mul, hP\u2081, hP\u2082, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]; refl\u27e9 } },\n  { rintro f g \u27e8P, rfl\u27e9 \u27e8Q, rfl\u27e9,\n    exact \u27e8P + Q, alg_hom.map_add _ _ _\u27e9 },\n  { rintro r f \u27e8P, rfl\u27e9,\n    exact \u27e8r \u2022 P, alg_hom.map_smul _ _ _\u27e9 }\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 \u27e8S, hS\u27e9 := h.out,\n  exact (finite_type.mv_polynomial R (S : set M)).of_surjective (mv_polynomial.aeval\n    (\u03bb (s : (S : set M)), of' R M \u2191s)) (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) \u2194 add_monoid.fg M :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, @add_monoid_algebra.finite_type_of_fg _ _ _ _ h\u27e9,\n  obtain \u27e8S, hS\u27e9 := @exists_finset_adjoin_eq_top R M _ _ h,\n  refine add_monoid.fg_def.2 \u27e8S, (eq_top_iff' _).2 (\u03bb m, _)\u27e9,\n  have hm : of' R M m \u2208 (adjoin R (of' R M '' \u2191S)).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) \u2194 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 \u2208 adjoin R (of R M '' f.support) :=\nbegin\n  suffices : span R (of R M '' f.support) \u2264 (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 = \u22a4) :\n  algebra.adjoin R (\u22c3 f \u2208 S, (of R M '' (f.support : set M))) = \u22a4 :=\nbegin\n  refine le_antisymm le_top _,\n  rw [\u2190 hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : (of R M) '' f.support \u2286\n    \u22c3 (g : monoid_algebra R M) (H : g \u2208 S), of R M '' g.support,\n  { intros s hs,\n    exact set.mem_Union\u2082.2 \u27e8f, \u27e8hf, hs\u27e9\u27e9 },\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 = \u22a4) :\n  algebra.adjoin R (of R M '' (\u22c3 f \u2208 S, (f.support : set M))) = \u22a4 :=\nbegin\n  suffices : of R M '' (\u22c3 f \u2208 S, (f.support : set M)) = \u22c3 f \u2208 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  \u2203 G : finset M, algebra.adjoin R (of R M '' G) = \u22a4 :=\nbegin\n  unfreezingI { obtain \u27e8S, hS\u27e9 := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (\u03bb f, f.support),\n  have : (finset.bUnion S (\u03bb f, f.support) : set M) = \u22c3 f \u2208 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 \u2208 S`. -/\nlemma of_mem_span_of_iff [nontrivial R] {m : M} {S : set M} :\n  of R M m \u2208 span R (of R M '' S) \u2194 m \u2208 S :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, submodule.subset_span $ set.mem_image_of_mem (of R M) h\u27e9,\n  rw [of, monoid_hom.coe_mk, \u2190 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 \u2208 closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of R M m \u2208 span R (submonoid.closure (of R M '' S) : set (monoid_algebra R M))) :\n  m \u2208 closure S :=\nbegin\n  rw \u2190 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 = \u22a4) : function.surjective (mv_polynomial.aeval\n  (\u03bb (s : S), of R M \u2191s) : mv_polynomial S R \u2192 monoid_algebra R M) :=\nbegin\n  refine \u03bb f, induction_on f (\u03bb m, _) _ _,\n  { have : m \u2208 closure S := hS.symm \u25b8 mem_top _,\n    refine closure_induction this (\u03bb m hm, _) _ _,\n    { exact \u27e8mv_polynomial.X \u27e8m, hm\u27e9, mv_polynomial.aeval_X _ _\u27e9 },\n    { exact \u27e81, alg_hom.map_one _\u27e9 },\n    { rintro m\u2081 m\u2082 \u27e8P\u2081, hP\u2081\u27e9 \u27e8P\u2082, hP\u2082\u27e9,\n      exact \u27e8P\u2081 * P\u2082, by rw [alg_hom.map_mul, hP\u2081, hP\u2082, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]\u27e9 } },\n  { rintro f g \u27e8P, rfl\u27e9 \u27e8Q, rfl\u27e9,\n    exact \u27e8P + Q, alg_hom.map_add _ _ _\u27e9 },\n  { rintro r f \u27e8P, rfl\u27e9,\n    exact \u27e8r \u2022 P, alg_hom.map_smul _ _ _\u27e9 }\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) \u2194 monoid.fg M :=\n\u27e8\u03bb h, monoid.fg_iff_add_fg.2 $ add_monoid_algebra.finite_type_iff_fg.1 $ h.equiv $\n  to_additive_alg_equiv R M, \u03bb h, @monoid_algebra.finite_type_of_fg _ _ _ _ h\u27e9\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) \u2194 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 \u2192\u2097[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 \u2192\u2097[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 : \u2200 o, (X : R[X]) \u2022 o = f o,\n  { intro,\n    simp, },\n  have : (\u22a4 : submodule R[X] M) \u2264 ideal.span {X} \u2022 \u22a4,\n  { intros a ha,\n    obtain \u27e8y, rfl\u27e9 := f_surj a,\n    rw [\u2190 X_mul y],\n    exact submodule.smul_mem_smul (ideal.mem_span_singleton.mpr (dvd_refl _)) trivial, },\n  obtain \u27e8F, hFa, hFb\u27e9 := submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul _\n    (\u22a4 : submodule R[X] M) (finite_def.mp hfgpoly) this,\n  rw [\u2190 linear_map.ker_eq_bot, linear_map.ker_eq_bot'],\n  intros m hm,\n  rw ideal.mem_span_singleton' at hFa,\n  obtain \u27e8G, hG\u27e9 := hFa,\n  suffices : (F - 1) \u2022 m = 0,\n  { have Fmzero := hFb m (by simp),\n    rwa [\u2190 sub_add_cancel F 1, add_smul, one_smul, this, zero_add] at Fmzero, },\n  rw [\u2190 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 \u2192 q \u2192 p := \u03bb (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), \u2203! ( i : I \u27f6  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 \u2192 Y` and a unique morphism `from : Y \u2192 X`.\n\nThis is a characteristic predicate for `has_zero_object`. -/\nstructure is_zero (X : C) : Prop :=\n(unique_to   : \u2200 Y, nonempty (unique (X \u27f6 Y)))\n(unique_from : \u2200 Y, nonempty (unique (Y \u27f6 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 \u2192 Y`. -/\nprotected def \u00abto\u00bb (h : is_zero X) (Y : C) : X \u27f6 Y :=\n@default (X \u27f6 Y) $ @unique.inhabited _ $ (h.unique_to Y).some\n\nlemma eq_to (h : is_zero X) (f : X \u27f6 Y) : f = h.to Y :=\n@unique.eq_default _ (id _) _\n\nlemma to_eq (h : is_zero X) (f : X \u27f6 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 \u2192 X`. -/\nprotected def \u00abfrom\u00bb (h : is_zero X) (Y : C) : Y \u27f6 X :=\n@default (Y \u27f6 X) $ @unique.inhabited _ $ (h.unique_from Y).some\n\nlemma eq_from (h : is_zero X) (f : Y \u27f6 X) : f = h.from Y :=\n@unique.eq_default _ (id _) _\n\nlemma from_eq (h : is_zero X) (f : Y \u27f6 X) : h.from Y = f :=\n(h.eq_from f).symm\n\nlemma eq_of_src (hX : is_zero X) (f g : X \u27f6 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 \u27f6 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 \u2245 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 $ \u03bb 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 $ \u03bb 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 \u2245 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 \u2245 Y :=\nhX.is_terminal.unique_up_to_iso hY\n\nlemma of_iso (hY : is_zero Y) (e : X \u2245 Y) : is_zero X :=\nbegin\n  refine \u27e8\u03bb Z, \u27e8\u27e8\u27e8e.hom \u226b hY.to Z\u27e9, \u03bb f, _\u27e9\u27e9, \u03bb Z, \u27e8\u27e8\u27e8hY.from Z \u226b e.inv\u27e9, \u03bb f, _\u27e9\u27e9\u27e9,\n  { rw \u2190 cancel_epi e.inv, apply hY.eq_of_src, },\n  { rw \u2190 cancel_mono e.hom, apply hY.eq_of_tgt, },\nend\n\nlemma op (h : is_zero X) : is_zero (opposite.op X) :=\n\u27e8\u03bb Y, \u27e8\u27e8\u27e8(h.from (opposite.unop Y)).op\u27e9, \u03bb f, quiver.hom.unop_inj (h.eq_of_tgt _ _)\u27e9\u27e9,\n  \u03bb Y, \u27e8\u27e8\u27e8(h.to (opposite.unop Y)).op\u27e9, \u03bb f, quiver.hom.unop_inj (h.eq_of_src _ _)\u27e9\u27e9\u27e9\n\nlemma unop {X : C\u1d52\u1d56} (h : is_zero X) : is_zero (opposite.unop X) :=\n\u27e8\u03bb Y, \u27e8\u27e8\u27e8(h.from (opposite.op Y)).unop\u27e9, \u03bb f, quiver.hom.op_inj (h.eq_of_tgt _ _)\u27e9\u27e9,\n  \u03bb Y, \u27e8\u27e8\u27e8(h.to (opposite.op Y)).unop\u27e9, \u03bb f, quiver.hom.op_inj (h.eq_of_src _ _)\u27e9\u27e9\u27e9\n\nend is_zero\n\nend limits\n\nopen category_theory.limits\n\nlemma iso.is_zero_iff {X Y : C} (e : X \u2245 Y) :\n  is_zero X \u2194 is_zero Y :=\n\u27e8\u03bb h, h.of_iso e.symm, \u03bb h, h.of_iso e\u27e9\n\nlemma functor.is_zero (F : C \u2964 D) (hF : \u2200 X, is_zero (F.obj X)) :\n  is_zero F :=\nbegin\n  split; intros G; refine \u27e8\u27e8\u27e8_\u27e9, _\u27e9\u27e9,\n  { refine { app := \u03bb X, (hF _).to _, naturality' := _ },\n    intros, exact (hF _).eq_of_src _ _ },\n  { intro f, ext, apply (hF _).eq_of_src _ _ },\n  { refine { app := \u03bb 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 : \u2203 X : C, is_zero X)\n\ninstance has_zero_object_punit : has_zero_object (discrete punit) :=\n{ zero := \u27e8\u27e8\u27e8\u27e9\u27e9, by tidy, by tidy\u27e9, }\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\u1d52\u1d56 := \u27e8\u27e8opposite.op 0, is_zero.op (is_zero_zero C)\u27e9\u27e9\n\nend\n\nopen_locale zero_object\n\nlemma has_zero_object_unop [has_zero_object C\u1d52\u1d56] : has_zero_object C :=\n\u27e8\u27e8opposite.unop 0, is_zero.unop (is_zero_zero C\u1d52\u1d56)\u27e9\u27e9\n\nvariables {C}\n\nlemma is_zero.has_zero_object {X : C} (hX : is_zero X) : has_zero_object C := \u27e8\u27e8X, hX\u27e9\u27e9\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 \u2245 0 :=\nhX.iso (is_zero_zero C)\n\nlemma is_zero.obj [has_zero_object D] {F : C \u2964 D} (hF : is_zero F) (X : C) :\n  is_zero (F.obj X) :=\nbegin\n  let G : C \u2964 D := (category_theory.functor.const C).obj 0,\n  have hG : is_zero G := functor.is_zero _ (\u03bb X, is_zero_zero _),\n  let e : F \u2245 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 \u27f6 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 \u27f6 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 \u27f6 0) : f = g :=\n(is_zero_zero C).eq_of_tgt _ _\n\n@[ext]\nlemma from_zero_ext {X : C} (f g : 0 \u27f6 X) : f = g :=\n(is_zero_zero C).eq_of_src _ _\n\ninstance (X : C) : subsingleton (X \u2245 0) := by tidy\n\ninstance {X : C} (f : 0 \u27f6 X) : mono f :=\n{ right_cancellation := \u03bb Z g h w, by ext, }\n\ninstance {X : C} (f : X \u27f6 0) : epi f :=\n{ left_cancellation := \u03bb Z g h w, by ext, }\n\ninstance zero_to_zero_is_iso (f : (0 : C) \u27f6 0) :\n  is_iso f :=\nby convert (show is_iso (\ud835\udfd9 (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 \u2245 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 \u2245 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 \u2245 \u22a5_ 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 \u2245 \u22a4_ 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 (\u03bb 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 \u2964 D) :\n  is_zero F \u2194 \u2200 X, is_zero (F.obj X) :=\n\u27e8\u03bb hF X, hF.obj X, functor.is_zero _\u27e9\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 \u201cvaluations\u201d in algebraic number theory.\n\nUsually, in the informal literature, these objects are constructed\nby taking a linearly ordered commutative group \u0393 and formally adjoining a zero element: \u0393 \u222a {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 (\u03b1 : Type u_1)\n    extends comm_group_with_zero \u03b1, linear_ordered_comm_monoid_with_zero \u03b1 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' {\u03b1 : Type u_1} {x : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1]\n    {n : \u2115} (H : 1 \u2264 x) : 1 \u2264 x ^ n :=\n  Nat.rec (le_refl 1) (fun (n : \u2115) (ih : 1 \u2264 x ^ n) => one_le_mul H ih) n\n\ntheorem pow_le_one_of_le_one {\u03b1 : Type u_1} {x : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] {n : \u2115}\n    (H : x \u2264 1) : x ^ n \u2264 1 :=\n  Nat.rec (le_refl 1) (fun (n : \u2115) (ih : x ^ n \u2264 1) => mul_le_one' H ih) n\n\ntheorem eq_one_of_pow_eq_one {\u03b1 : Type u_1} {x : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] {n : \u2115}\n    (hn : n \u2260 0) (H : x ^ n = 1) : x = 1 :=\n  sorry\n\ntheorem pow_eq_one_iff {\u03b1 : Type u_1} {x : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] {n : \u2115}\n    (hn : n \u2260 0) : x ^ n = 1 \u2194 x = 1 :=\n  { mp := eq_one_of_pow_eq_one hn, mpr := fun (\u1fb0 : x = 1) => Eq._oldrec (one_pow n) (Eq.symm \u1fb0) }\n\ntheorem one_le_pow_iff {\u03b1 : Type u_1} {x : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] {n : \u2115}\n    (hn : n \u2260 0) : 1 \u2264 x ^ n \u2194 1 \u2264 x :=\n  sorry\n\ntheorem pow_le_one_iff {\u03b1 : Type u_1} {x : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] {n : \u2115}\n    (hn : n \u2260 0) : x ^ n \u2264 1 \u2194 x \u2264 1 :=\n  sorry\n\ntheorem zero_le_one' {\u03b1 : Type u_1} [linear_ordered_comm_monoid_with_zero \u03b1] : 0 \u2264 1 :=\n  linear_ordered_comm_monoid_with_zero.zero_le_one\n\n@[simp] theorem zero_le' {\u03b1 : Type u_1} {a : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] : 0 \u2264 a :=\n  sorry\n\n@[simp] theorem not_lt_zero' {\u03b1 : Type u_1} {a : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] :\n    \u00aca < 0 :=\n  not_lt_of_le zero_le'\n\n@[simp] theorem le_zero_iff {\u03b1 : Type u_1} {a : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] :\n    a \u2264 0 \u2194 a = 0 :=\n  { mp := fun (h : a \u2264 0) => le_antisymm h zero_le', mpr := fun (h : a = 0) => h \u25b8 le_refl a }\n\ntheorem zero_lt_iff {\u03b1 : Type u_1} {a : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1] :\n    0 < a \u2194 a \u2260 0 :=\n  { mp := ne_of_gt, mpr := fun (h : a \u2260 0) => lt_of_le_of_ne zero_le' (ne.symm h) }\n\ntheorem ne_zero_of_lt {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} [linear_ordered_comm_monoid_with_zero \u03b1]\n    (h : b < a) : a \u2260 0 :=\n  fun (h1 : a = 0) => not_lt_zero' ((fun (this : b < 0) => this) (h1 \u25b8 h))\n\ntheorem zero_lt_one'' {\u03b1 : Type u_1} [linear_ordered_comm_group_with_zero \u03b1] : 0 < 1 :=\n  lt_of_le_of_ne zero_le_one' zero_ne_one\n\ntheorem le_of_le_mul_right {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} {c : \u03b1}\n    [linear_ordered_comm_group_with_zero \u03b1] (h : c \u2260 0) (hab : a * c \u2264 b * c) : a \u2264 b :=\n  sorry\n\ntheorem le_mul_inv_of_mul_le {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} {c : \u03b1}\n    [linear_ordered_comm_group_with_zero \u03b1] (h : c \u2260 0) (hab : a * c \u2264 b) : a \u2264 b * (c\u207b\u00b9) :=\n  sorry\n\ntheorem mul_inv_le_of_le_mul {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} {c : \u03b1}\n    [linear_ordered_comm_group_with_zero \u03b1] (h : c \u2260 0) (hab : a \u2264 b * c) : a * (c\u207b\u00b9) \u2264 b :=\n  sorry\n\ntheorem div_le_div' {\u03b1 : Type u_1} [linear_ordered_comm_group_with_zero \u03b1] (a : \u03b1) (b : \u03b1) (c : \u03b1)\n    (d : \u03b1) (hb : b \u2260 0) (hd : d \u2260 0) : a * (b\u207b\u00b9) \u2264 c * (d\u207b\u00b9) \u2194 a * d \u2264 c * b :=\n  sorry\n\n@[simp] theorem units.zero_lt {\u03b1 : Type u_1} [linear_ordered_comm_group_with_zero \u03b1] (u : units \u03b1) :\n    0 < \u2191u :=\n  iff.mpr zero_lt_iff (units.ne_zero u)\n\ntheorem mul_lt_mul'''' {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} {c : \u03b1} {d : \u03b1}\n    [linear_ordered_comm_group_with_zero \u03b1] (hab : a < b) (hcd : c < d) : a * c < b * d :=\n  sorry\n\ntheorem mul_inv_lt_of_lt_mul' {\u03b1 : Type u_1} {x : \u03b1} {y : \u03b1} {z : \u03b1}\n    [linear_ordered_comm_group_with_zero \u03b1] (h : x < y * z) : x * (z\u207b\u00b9) < y :=\n  sorry\n\ntheorem mul_lt_right' {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} [linear_ordered_comm_group_with_zero \u03b1] (c : \u03b1)\n    (h : a < b) (hc : c \u2260 0) : a * c < b * c :=\n  sorry\n\ntheorem pow_lt_pow_succ {\u03b1 : Type u_1} [linear_ordered_comm_group_with_zero \u03b1] {x : \u03b1} {n : \u2115}\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' {\u03b1 : Type u_1} [linear_ordered_comm_group_with_zero \u03b1] {x : \u03b1} {m : \u2115} {n : \u2115}\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 : \u2115} (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'' {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} [linear_ordered_comm_group_with_zero \u03b1]\n    (ha : a \u2260 0) (hb : b \u2260 0) : a\u207b\u00b9 < (b\u207b\u00b9) \u2194 b < a :=\n  inv_lt_inv_iff\n\ntheorem inv_le_inv'' {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} [linear_ordered_comm_group_with_zero \u03b1]\n    (ha : a \u2260 0) (hb : b \u2260 0) : a\u207b\u00b9 \u2264 (b\u207b\u00b9) \u2194 b \u2264 a :=\n  inv_le_inv_iff\n\nnamespace monoid_hom\n\n\ntheorem map_neg_one {\u03b1 : Type u_1} [linear_ordered_comm_group_with_zero \u03b1] {R : Type u_2} [ring R]\n    (f : R \u2192* \u03b1) : coe_fn f (-1) = 1 :=\n  sorry\n\n@[simp] theorem map_neg {\u03b1 : Type u_1} [linear_ordered_comm_group_with_zero \u03b1] {R : Type u_2}\n    [ring R] (f : R \u2192* \u03b1) (x : R) : coe_fn f (-x) = coe_fn f x :=\n  sorry\n\ntheorem map_sub_swap {\u03b1 : Type u_1} [linear_ordered_comm_group_with_zero \u03b1] {R : Type u_2} [ring R]\n    (f : R \u2192* \u03b1) (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 : \u2115} {\u03b1 : fin n \u2192 Type u}\n\ninstance [\u2200 i, inhabited (\u03b1 i)] : inhabited (d_array n \u03b1) :=\n\u27e8\u27e8default\u27e9\u27e9\n\nend d_array\n\nnamespace array\n\ninstance {n \u03b1} [inhabited \u03b1] : inhabited (array n \u03b1) :=\nd_array.inhabited\n\ntheorem to_list_of_heq {n\u2081 n\u2082 \u03b1} {a\u2081 : array n\u2081 \u03b1} {a\u2082 : array n\u2082 \u03b1}\n  (hn : n\u2081 = n\u2082) (ha : a\u2081 == a\u2082) : a\u2081.to_list = a\u2082.to_list :=\nby congr; assumption\n\n/- rev_list -/\n\nsection rev_list\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem rev_list_reverse_aux : \u2200 i (h : i \u2264 n) (t : list \u03b1),\n  (a.iterate_aux (\u03bb _, (::)) i h []).reverse_core t = a.rev_iterate_aux (\u03bb _, (::)) 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 [\u2190rev_list_reverse, list.reverse_reverse]\n\nend rev_list\n\n/- mem -/\n\nsection mem\nvariables {n : \u2115} {\u03b1 : Type u} {v : \u03b1} {a : array n \u03b1}\n\ntheorem mem.def : v \u2208 a \u2194 \u2203 i, a.read i = v :=\niff.rfl\n\ntheorem mem_rev_list_aux : \u2200 {i} (h : i \u2264 n),\n  (\u2203 (j : fin n), (j : \u2115) < i \u2227 read a j = v) \u2194 v \u2208 a.iterate_aux (\u03bb _, (::)) i h []\n| 0     _ := \u27e8\u03bb \u27e8i, n, _\u27e9, absurd n i.val.not_lt_zero, false.elim\u27e9\n| (i+1) h := let IH := mem_rev_list_aux (le_of_lt h) in\n  \u27e8\u03bb \u27e8j, ji1, e\u27e9, or.elim (lt_or_eq_of_le $ nat.le_of_succ_le_succ ji1)\n    (\u03bb ji, list.mem_cons_of_mem _ $ IH.1 \u27e8j, ji, e\u27e9)\n    (\u03bb je, by simp [d_array.iterate_aux]; apply or.inl; unfold read at e;\n          have H : j = \u27e8i, h\u27e9 := fin.eq_of_veq je; rwa [\u2190H, e]),\n  \u03bb m, begin\n    simp [d_array.iterate_aux, list.mem] at m,\n    cases m with e m',\n    exact \u27e8\u27e8i, h\u27e9, nat.lt_succ_self _, eq.symm e\u27e9,\n    exact let \u27e8j, ji, e\u27e9 := IH.2 m' in\n    \u27e8j, nat.le_succ_of_le ji, e\u27e9\n  end\u27e9\n\n@[simp] theorem mem_rev_list : v \u2208 a.rev_list \u2194 v \u2208 a :=\niff.symm $ iff.trans\n  (exists_congr $ \u03bb j, iff.symm $\n    show j.1 < n \u2227 read a j = v \u2194 read a j = v,\n    from and_iff_right j.2)\n  (mem_rev_list_aux _)\n\n@[simp] theorem mem_to_list : v \u2208 a.to_list \u2194 v \u2208 a :=\nby rw \u2190rev_list_reverse; exact list.mem_reverse.trans mem_rev_list\n\nend mem\n\n/- foldr -/\n\nsection foldr\nvariables {n : \u2115} {\u03b1 : Type u} {\u03b2 : Type w} {b : \u03b2} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem rev_list_foldr_aux : \u2200 {i} (h : i \u2264 n),\n  (d_array.iterate_aux a (\u03bb _, (::)) i h []).foldr f b = d_array.iterate_aux a (\u03bb _, f) i h b\n| 0     h := rfl\n| (j+1) h := congr_arg (f (read a \u27e8j, h\u27e9)) (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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type w} {b : \u03b2} {f : \u03b2 \u2192 \u03b1 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem to_list_foldl : a.to_list.foldl f b = a.foldl b (function.swap f) :=\nby rw [\u2190rev_list_reverse, list.foldl_reverse, rev_list_foldr]\n\nend foldl\n\n/- length -/\n\nsection length\nvariables {n : \u2115} {\u03b1 : Type u}\n\ntheorem rev_list_length_aux (a : array n \u03b1) (i h) :\n  (a.iterate_aux (\u03bb _, (::)) i h []).length = i :=\nby induction i; simp [*, d_array.iterate_aux]\n\n@[simp] theorem rev_list_length (a : array n \u03b1) : a.rev_list.length = n :=\nrev_list_length_aux a _ _\n\n@[simp] theorem to_list_length (a : array n \u03b1) : a.to_list.length = n :=\nby rw[\u2190rev_list_reverse, list.length_reverse, rev_list_length]\n\nend length\n\n/- nth -/\n\nsection nth\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem to_list_nth_le_aux (i : \u2115) (ih : i < n) : \u2200 j {jh t h'},\n  (\u2200 k tl, j + k = i \u2192 list.nth_le t k tl = a.read \u27e8i, ih\u27e9) \u2192\n  (a.rev_iterate_aux (\u03bb _, (::)) j jh t).nth_le i h' = a.read \u27e8i, ih\u27e9\n| 0     _  _ _  al := al i _ $ zero_add _\n| (j+1) jh t h' al := to_list_nth_le_aux j $ \u03bb k tl hjk,\n  show list.nth_le (a.read \u27e8j, jh\u27e9 :: t) k tl = a.read \u27e8i, ih\u27e9, 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 : \u2115) (h h') : list.nth_le a.to_list i h' = a.read \u27e8i, h\u27e9 :=\nto_list_nth_le_aux _ _ _ (\u03bb k tl, absurd tl k.not_lt_zero)\n\n@[simp] theorem to_list_nth_le' (a : array n \u03b1) (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 \u2194 \u2203 h, a.read \u27e8i, h\u27e9 = 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 \u27e8ll \u25b8 h, (to_list_nth_le _ _ _).symm\u27e9 },\n  { exact \u27e8ll.symm \u25b8 h, to_list_nth_le _ _ _\u27e9 }\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) $ \u03bb j h\u2081 h\u2082, begin\n  have h\u2083 : j < n, {simpa using h\u2081},\n  rw [to_list_nth_le _ h\u2083],\n  refine let \u27e8_, e\u27e9 := list.nth_eq_some.1 _ in e.symm,\n  by_cases ij : (i : \u2115) = j,\n  { subst j, rw [show (\u27e8(i : \u2115), h\u2083\u27e9 : fin _) = i, from fin.eq_of_veq rfl,\n      array.read_write, list.nth_update_nth_of_lt],\n    simp [h\u2083] },\n  { rw [list.nth_update_nth_ne _ _ ij, a.read_write_of_ne,\n        to_list_nth.2 \u27e8h\u2083, rfl\u27e9],\n    exact fin.ne_of_vne ij }\nend\n\nend nth\n\n/- enum -/\n\nsection enum\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem mem_to_list_enum {i v} : (i, v) \u2208 a.to_list.enum \u2194 \u2203 h, a.read \u27e8i, h\u27e9 = 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 : \u2115} {\u03b1 : Type u}\n\n@[simp] theorem to_list_to_array (a : array n \u03b1) : a.to_list.to_array == a :=\nheq_of_heq_of_eq\n  (@@eq.drec_on (\u03bb m (e : a.to_list.length = m), (d_array.mk (\u03bb v, a.to_list.nth_le v.1 v.2)) ==\n    (@d_array.mk m (\u03bb _, \u03b1) $ \u03bb v, a.to_list.nth_le v.1 $ e.symm \u25b8 v.2)) a.to_list_length heq.rfl) $\n  d_array.ext $ \u03bb \u27e8i, h\u27e9, to_list_nth_le i h _\n\n@[simp] theorem to_array_to_list (l : list \u03b1) : l.to_array.to_list = l :=\nlist.ext_le (to_list_length _) $ \u03bb n h1 h2, to_list_nth_le _ h2 _\n\nend to_array\n\n/- push_back -/\n\nsection push_back\nvariables {n : \u2115} {\u03b1 : Type u} {v : \u03b1} {a : array n \u03b1}\n\nlemma push_back_rev_list_aux : \u2200 i h h',\n  d_array.iterate_aux (a.push_back v) (\u03bb _, (::)) i h [] = d_array.iterate_aux a (\u03bb _, (::)) i h' []\n| 0 h h' := rfl\n| (i+1) h h' := begin\n  simp [d_array.iterate_aux],\n  refine \u27e8_, push_back_rev_list_aux _ _ _\u27e9,\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 [\u2190rev_list_reverse, \u2190rev_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 : \u00ac 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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type v} {i : fin n} {f : fin n \u2192 \u03b1 \u2192 \u03b2} {a : array n \u03b1}\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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type v} {i : fin n} {f : \u03b1 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem read_map : (a.map f).read i = f (a.read i) :=\nread_foreach\n\nend map\n\n/- map\u2082 -/\n\nsection map\u2082\nvariables {n : \u2115} {\u03b1 : Type u} {i : fin n} {f : \u03b1 \u2192 \u03b1 \u2192 \u03b1} {a\u2081 a\u2082 : array n \u03b1}\n\n@[simp] theorem read_map\u2082 : (map\u2082 f a\u2081 a\u2082).read i = f (a\u2081.read i) (a\u2082.read i) :=\nread_foreach\n\nend map\u2082\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 `\u03b1 \u2192 \u03b2` functions and\n`\u2124 \u2192 \u2124` 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 : \u03b1 \u2192 \u03b1` could be generated easily instead of\n`\u2124 \u2192 \u2124` by generating a `list \u03b1`, 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 : \u2124 \u2192 \u2124` 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 `\u03b1 \u2192 \u03b1` 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 \u21a6 f x` when `x \u2208 f` and `x \u21a6 y`\notherwise.\n\nWe use `\u03a3` to encode mappings instead of `\u00d7` because we\nrely on the association list API defined in `data.list.sigma`.\n -/\ninductive total_function (\u03b1 : Type u) (\u03b2 : Type v) \nwhere\n| with_default : List (sigma fun (_x : \u03b1) => \u03b2) \u2192 \u03b2 \u2192 total_function \u03b1 \u03b2\n\nprotected instance total_function.inhabited {\u03b1 : Type u_1} {\u03b2 : Type u_2} [Inhabited \u03b2] : Inhabited (total_function \u03b1 \u03b2) :=\n  { default := total_function.with_default \u2205 Inhabited.default }\n\nnamespace total_function\n\n\n/-- Apply a total function to an argument. -/\ndef apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] : total_function \u03b1 \u03b2 \u2192 \u03b1 \u2192 \u03b2 :=\n  sorry\n\n/--\nImplementation of `has_repr (total_function \u03b1 \u03b2)`.\n\nCreates a string for a given `finmap` and output, `x\u2080 \u21a6 y\u2080, .. x\u2099 \u21a6 y\u2099`\nfor each of the entries. The brackets are provided by the calling function.\n-/\ndef repr_aux {\u03b1 : Type u} [has_repr \u03b1] {\u03b2 : Type v} [has_repr \u03b2] (m : List (sigma fun (_x : \u03b1) => \u03b2)) : string :=\n  string.join\n    (list.qsort (fun (x y : string) => to_bool (x < y))\n      (list.map\n        (fun (x : sigma fun (_x : \u03b1) => \u03b2) =>\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\u2080 \u21a6 f x\u2080, .. x\u2099 \u21a6 f x\u2099, _ \u21a6 y]`.\n-/\nprotected def repr {\u03b1 : Type u} [has_repr \u03b1] {\u03b2 : Type v} [has_repr \u03b2] : total_function \u03b1 \u03b2 \u2192 string :=\n  sorry\n\nprotected instance has_repr (\u03b1 : Type u) (\u03b2 : Type v) [has_repr \u03b1] [has_repr \u03b2] : has_repr (total_function \u03b1 \u03b2) :=\n  has_repr.mk total_function.repr\n\n/-- Create a `finmap` from a list of pairs. -/\ndef list.to_finmap' {\u03b1 : Type u_1} {\u03b2 : Type u_2} (xs : List (\u03b1 \u00d7 \u03b2)) : List (sigma fun (_x : \u03b1) => \u03b2) :=\n  list.map prod.to_sigma xs\n\n/-- Redefine `sizeof` to follow the structure of `sampleable` instances. -/\ndef total.sizeof {\u03b1 : Type u} {\u03b2 : Type v} [sampleable \u03b1] [sampleable \u03b2] : total_function \u03b1 \u03b2 \u2192 \u2115 :=\n  sorry\n\nprotected instance has_sizeof {\u03b1 : Type u} {\u03b2 : Type v} [sampleable \u03b1] [sampleable \u03b2] : SizeOf (total_function \u03b1 \u03b2) :=\n  { sizeOf := total.sizeof }\n\n/-- Shrink a total function by shrinking the lists that represent it. -/\nprotected def shrink {\u03b1 : Type u} {\u03b2 : Type v} [sampleable \u03b1] [sampleable \u03b2] [DecidableEq \u03b1] : shrink_fn (total_function \u03b1 \u03b2) :=\n  sorry\n\nprotected instance pi.sampleable_ext {\u03b1 : Type u} {\u03b2 : Type v} [sampleable \u03b1] [sampleable \u03b2] [DecidableEq \u03b1] [has_repr \u03b1] [has_repr \u03b2] : sampleable_ext (\u03b1 \u2192 \u03b2) :=\n  sampleable_ext.mk (total_function \u03b1 \u03b2)\n    (do \n      sample (List (\u03b1 \u00d7 \u03b2))\n      uliftable.up (sample \u03b2)\n      sorry)\n    total_function.shrink\n\nprotected instance pi_pred.sampleable_ext {\u03b1 : Type u} [sampleable_ext (\u03b1 \u2192 Bool)] : sampleable_ext (\u03b1 \u2192 Prop) :=\n  sampleable_ext.mk (sampleable_ext.proxy_repr (\u03b1 \u2192 Bool)) (sampleable_ext.sample (\u03b1 \u2192 Bool)) sampleable_ext.shrink\n\nprotected instance pi_uncurry.sampleable_ext {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Sort w} [sampleable_ext (\u03b1 \u00d7 \u03b2 \u2192 \u03b3)] : sampleable_ext (\u03b1 \u2192 \u03b2 \u2192 \u03b3) :=\n  sampleable_ext.mk (sampleable_ext.proxy_repr (\u03b1 \u00d7 \u03b2 \u2192 \u03b3)) (sampleable_ext.sample (\u03b1 \u00d7 \u03b2 \u2192 \u03b3)) 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 \u21a6 f x` when `x \u2208 f` and `x \u21a6 x`,\ni.e. `x` to itself, otherwise.\n\nWe use `\u03a3` to encode mappings instead of `\u00d7` because we\nrely on the association list API defined in `data.list.sigma`.\n-/\ninductive injective_function (\u03b1 : Type u) \nwhere\n| map_to_self : (xs : List (sigma fun (_x : \u03b1) => \u03b1)) \u2192\n  list.map sigma.fst xs ~ list.map sigma.snd xs \u2192 list.nodup (list.map sigma.snd xs) \u2192 injective_function \u03b1\n\nprotected instance injective_function.inhabited {\u03b1 : Type u_1} : Inhabited (injective_function \u03b1) :=\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 {\u03b1 : Type u} [DecidableEq \u03b1] : injective_function \u03b1 \u2192 \u03b1 \u2192 \u03b1 :=\n  sorry\n\n/--\nProduce a string for a given `total_function`.\nThe output is of the form `[x\u2080 \u21a6 f x\u2080, .. x\u2099 \u21a6 f x\u2099, x \u21a6 x]`.\nUnlike for `total_function`, the default value is not a constant\nbut the identity function.\n-/\nprotected def repr {\u03b1 : Type u} [has_repr \u03b1] : injective_function \u03b1 \u2192 string :=\n  sorry\n\nprotected instance has_repr (\u03b1 : Type u) [has_repr \u03b1] : has_repr (injective_function \u03b1) :=\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 {\u03b1 : Type u} [DecidableEq \u03b1] (xs : List (\u03b1 \u00d7 \u03b1)) (x : \u03b1) : \u03b1 :=\n  option.get_or_else (list.lookup x (list.map prod.to_sigma xs)) x\n\n@[simp] theorem list.apply_id_cons {\u03b1 : Type u} [DecidableEq \u03b1] (xs : List (\u03b1 \u00d7 \u03b1)) (x : \u03b1) (y : \u03b1) (z : \u03b1) : list.apply_id ((y, z) :: xs) x = ite (y = x) z (list.apply_id xs x) := sorry\n\ntheorem list.apply_id_zip_eq {\u03b1 : Type u} [DecidableEq \u03b1] {xs : List \u03b1} {ys : List \u03b1} (h\u2080 : list.nodup xs) (h\u2081 : list.length xs = list.length ys) (x : \u03b1) (y : \u03b1) (i : \u2115) (h\u2082 : list.nth xs i = some x) : list.apply_id (list.zip xs ys) x = y \u2194 list.nth ys i = some y := sorry\n\ntheorem apply_id_mem_iff {\u03b1 : Type u} [DecidableEq \u03b1] {xs : List \u03b1} {ys : List \u03b1} (h\u2080 : list.nodup xs) (h\u2081 : xs ~ ys) (x : \u03b1) : list.apply_id (list.zip xs ys) x \u2208 ys \u2194 x \u2208 xs := sorry\n\ntheorem list.apply_id_eq_self {\u03b1 : Type u} [DecidableEq \u03b1] {xs : List \u03b1} {ys : List \u03b1} (x : \u03b1) : \u00acx \u2208 xs \u2192 list.apply_id (list.zip xs ys) x = x := sorry\n\ntheorem apply_id_injective {\u03b1 : Type u} [DecidableEq \u03b1] {xs : List \u03b1} {ys : List \u03b1} (h\u2080 : list.nodup xs) (h\u2081 : 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (n : \u2115) (m : \u2115) : (psigma fun (xs : List \u03b1) => psigma fun (ys : List \u03b1) => xs ~ ys \u2227 list.nodup ys) \u2192\n  psigma fun (xs : List \u03b1) => psigma fun (ys : List \u03b1) => xs ~ ys \u2227 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 : \u2115 \u2192 lazy_list \u2115+ :=\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 {\u03b1 : Type} [DecidableEq \u03b1] [SizeOf \u03b1] : shrink_fn (psigma fun (xs : List \u03b1) => psigma fun (ys : List \u03b1) => xs ~ ys \u2227 list.nodup ys) :=\n  sorry\n\nprotected instance has_sizeof {\u03b1 : Type u_1} [SizeOf \u03b1] : SizeOf (injective_function \u03b1) :=\n  { sizeOf := fun (_x : injective_function \u03b1) => 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 {\u03b1 : Type} [SizeOf \u03b1] [DecidableEq \u03b1] : shrink_fn (injective_function \u03b1) :=\n  sorry\n\n/-- Create an injective function from one list and a permutation of that list. -/\nprotected def mk {\u03b1 : Type (max u_1 u_2)} (xs : List \u03b1) (ys : List \u03b1) (h : xs ~ ys) (h' : list.nodup ys) : injective_function \u03b1 :=\n  (fun (h\u2080 : list.length xs \u2264 list.length ys) =>\n      (fun (h\u2081 : list.length ys \u2264 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 {\u03b1 : Type u} [DecidableEq \u03b1] (f : injective_function \u03b1) : function.injective (apply f) := sorry\n\nprotected instance pi_injective.sampleable_ext : sampleable_ext (Subtype fun (f : \u2124 \u2192 \u2124) => function.injective f) :=\n  sampleable_ext.mk (injective_function \u2124)\n    (gen.sized\n      fun (sz : \u2115) =>\n        let xs' : List \u2124 := int.range (-(bit0 1 * \u2191sz + bit0 1)) (bit0 1 * \u2191sz + bit0 1);\n        do \n          let ys \u2190 gen.permutation_of xs'\n          (fun (Hinj : function.injective fun (r : \u2115) => -(bit0 1 * \u2191sz + bit0 1) + \u2191r) =>\n                let r : injective_function \u2124 := 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 {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (f : \u03b1 \u2192 \u03b2) [I : testable\n  (named_binder (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit1 (bit1 (bit1 1))))))))\n    (\u2200 (x : \u03b1),\n      named_binder (string.str string.empty (char.of_nat (bit1 (bit0 (bit0 (bit1 (bit1 (bit1 1))))))))\n        (\u2200 (y : \u03b1),\n          named_binder (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit1 (bit0 (bit0 1))))))))\n            (f x = f y \u2192 x = y))))] : testable (function.injective f) :=\n  I\n\nprotected instance monotone.testable {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u2192 \u03b2) [I : testable\n  (named_binder (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit1 (bit1 (bit1 1))))))))\n    (\u2200 (x : \u03b1),\n      named_binder (string.str string.empty (char.of_nat (bit1 (bit0 (bit0 (bit1 (bit1 (bit1 1))))))))\n        (\u2200 (y : \u03b1),\n          named_binder (string.str string.empty (char.of_nat (bit0 (bit0 (bit0 (bit1 (bit0 (bit0 1))))))))\n            (x \u2264 y \u2192 f x \u2264 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 := \u27e8\u27e9\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 \u2192* Y) : of X \u27f6 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 \u2192* 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 := \u27e8Group.of punit\u27e9\n\n@[to_additive]\ninstance : inhabited Group := \u27e81\u27e9\n\n@[to_additive]\ninstance one.unique : unique (1 : Group) :=\n{ default := 1,\n  uniq := \u03bb a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : Group) (g : G) : (1 : G \u27f6 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\u2082 Group Mon := bundled_hom.forget\u2082 _ _\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 := \u27e8\u27e9\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 \u2192* Y) :\n  of X \u27f6 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 \u2192* 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 := \u27e8CommGroup.of punit\u27e9\n\n@[to_additive] instance : inhabited CommGroup := \u27e81\u27e9\n\n@[to_additive]\ninstance one.unique : unique (1 : CommGroup) :=\n{ default := 1,\n  uniq := \u03bb a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : CommGroup) (g : G) : (1 : G \u27f6 H) g = 1 := rfl\n\n@[ext, to_additive]\nlemma ext (G H : CommGroup) (f\u2081 f\u2082 : G \u27f6 H) (w : \u2200 x, f\u2081 x = f\u2082 x) : f\u2081 = f\u2082 :=\nby { ext1, apply w }\n\n@[to_additive has_forget_to_AddGroup]\ninstance has_forget_to_Group : has_forget\u2082 CommGroup Group := bundled_hom.forget\u2082 _ _\n\n@[to_additive has_forget_to_AddCommMon]\ninstance has_forget_to_CommMon : has_forget\u2082 CommGroup CommMon :=\ninduced_category.has_forget\u2082 (\u03bb 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 \u27f6 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 `\u2124` sending\n`1` to that element. -/\n-- Note that because `\u2124 : 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 \u2124) \u27f6 G :=\nzmultiples_hom G g\n\n@[simp]\nlemma as_hom_apply {G : AddCommGroup.{0}} (g : G) (i : \u2124) : (as_hom g) i = i \u2022 g := rfl\n\nlemma as_hom_injective {G : AddCommGroup.{0}} : function.injective (@as_hom G) :=\n\u03bb h k w, by convert congr_arg (\u03bb k : (AddCommGroup.of \u2124) \u27f6 G, (k : \u2124 \u2192 G) (1 : \u2124)) w; simp\n\n@[ext]\nlemma int_hom_ext\n  {G : AddCommGroup.{0}} (f g : (AddCommGroup.of \u2124) \u27f6 G) (w : f (1 : \u2124) = g (1 : \u2124)) : 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 \u27f6 H) [mono f] : function.injective f :=\n\u03bb g\u2081 g\u2082 h,\nbegin\n  have t0 : as_hom g\u2081 \u226b f = as_hom g\u2082 \u226b f :=\n  begin\n    ext,\n    simpa [as_hom_apply] using h,\n  end,\n  have t1 : as_hom g\u2081 = as_hom g\u2082 := (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 \u2243* Y) : X \u2245 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 \u2243* Y) : X \u2245 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 \u2245 Y) : X \u2243* 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 \u2245 Y) : X \u2243* 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 \u2243* Y) \u2245 (X \u2245 Y) :=\n{ hom := \u03bb e, e.to_Group_iso,\n  inv := \u03bb 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 \u2243* Y \u2245 (X \u2245 Y) :=\n{ hom := \u03bb e, e.to_CommGroup_iso,\n  inv := \u03bb 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 {\u03b1 : Type u} : Group.of (Aut \u03b1) \u2245 Group.of (equiv.perm \u03b1) :=\n{ hom := \u27e8\u03bb g, g.to_equiv, (by tidy), (by tidy)\u27e9,\n  inv := \u27e8\u03bb g, g.to_iso, (by tidy), (by tidy)\u27e9 }\n\n/-- The (unbundled) group of automorphisms of a type is `mul_equiv` to the (unbundled) group\nof permutations. -/\ndef mul_equiv_perm {\u03b1 : Type u} : Aut \u03b1 \u2243* equiv.perm \u03b1 :=\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 := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Group).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Group_iso).1\u27e9,\n  end }\n\n@[to_additive]\ninstance CommGroup.forget_reflects_isos : reflects_isomorphisms (forget CommGroup.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommGroup).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommGroup_iso).1\u27e9,\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 \u2115) := \n\u27e8{ val := \u03bb a b, tt, rel := \u03bb a b, tt }\u27e9\n\n@[simp] def force {states : Type} (k : KT states) : states \u2192 nnf \u2192 Prop\n| s (var n)    := k.val n s\n| s (neg n)    := \u00ac k.val n s\n| s (and \u03c6 \u03c8)  := force s \u03c6 \u2227 force s \u03c8\n| s (or \u03c6 \u03c8)   := force s \u03c6 \u2228 force s \u03c8\n| s (box \u03c6)    := \u2200 s', k.rel s s' \u2192 force s' \u03c6\n| s (dia \u03c6)    := \u2203 s', k.rel s s' \u2227 force s' \u03c6\n\ndef sat {st} (k : KT st) (s) (\u0393 : list nnf) : Prop := \n\u2200 \u03c6 \u2208 \u0393, force k s \u03c6\n\ndef unsatisfiable (\u0393 : list nnf) : Prop := \n\u2200 (st) (k : KT st) s, \u00ac sat k s \u0393\n\ntheorem unsat_singleton {\u03c6} : unsatisfiable [\u03c6] \u2192 \u2200 (st) (k : KT st) s, \u00ac force k s \u03c6\n := \nbegin\n  intro h, intros, intro hf, \n  apply h, intros \u03c8 h\u03c8, rw list.mem_singleton at h\u03c8, rw h\u03c8, exact hf\nend\n\ntheorem sat_of_empty {st} (k : KT st) (s) : sat k s [] :=\n\u03bb \u03c6 h, absurd h $ list.not_mem_nil _\n\ntheorem ne_empty_of_unsat {\u0393} (h : unsatisfiable \u0393): \u0393 \u2260 [] := \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 \u2115 \u2192 list model \u2192 model\n\ninstance : decidable_eq model := by tactic.mk_dec_eq_instance\n\nopen model\n\n@[simp] def mval : \u2115 \u2192 model \u2192 bool\n| p (cons v r) := p \u2208 v\n\n@[simp] def mrel : model \u2192 model \u2192 bool\n| m\u2081@(cons v r) m\u2082 := m\u2082 \u2208 r \u2228 m\u2081 = m\u2082\n\ntheorem refl_mrel (s : model) : mrel s s := by cases s with v r; simp\n\ntheorem mem_of_mrel_tt : \u03a0 {v r m}, mrel (cons v r) m = tt \u2192 m \u2208 r \u2228 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 : \u03a0 {v m}, mrel (cons v []) m = tt \u2192 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 := \u03bb n s, mval n s, rel := \u03bb s\u2081 s\u2082, mrel s\u2081 s\u2082, refl := refl_mrel}\n\ntheorem force_box_of_leaf {v \u03c6} (h : force builder (cons v []) \u03c6): \nforce builder (cons v []) (box \u03c6) :=\nbegin\n  dsimp, intros s' hs',\n  have : cons v [] = s', {apply mem_of_mrel_empty, exact hs'},\n  rw \u2190this, assumption\nend\n\ndef srefl (m h : list nnf) := \n\u2200 {v l \u03c6}, sat builder (cons v l) m \u2192 \nbox \u03c6 \u2208 h \u2192 \n(\u2200 \u03c8, box \u03c8 \u2208 h \u2192 \u2200 m \u2208 l, force builder m \u03c8) \u2192 \nforce builder (cons v l) \u03c6\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 (\u0393 : seqt) :=\n(satu : saturated \u0393.main)\n(no_box_main : \u2200 {\u03c6}, box \u03c6 \u2209 \u0393.main)\n(no_contra_main : \u2200 {n}, var n \u2208 \u0393.main \u2192 neg n \u2209 \u0393.main)\n(v : list \u2115)\n(hv : \u2200 n, var n \u2208 \u0393.main \u2194 n \u2208 v)\n\nclass modal_applicable (\u0393 : seqt) extends val_constructible \u0393 :=\n(\u03c6 : nnf)\n(ex : dia \u03c6 \u2208 \u0393.main)\n\nclass model_constructible (\u0393 : seqt) extends val_constructible \u0393 :=\n(no_dia : \u2200 {\u03c6}, nnf.dia \u03c6 \u2209 \u0393.main)\n\ntheorem build_model : \u03a0 \u0393 (h : model_constructible \u0393), \nsat builder (cons h.v []) \u0393.main := \nbegin\n  intros, intro, intro hmem,\n  cases heq : \u03c6,\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\u2081 := h.hv, rw heq at hmem, have := h.no_contra_main, simp, rw \u2190h\u2081, intro hvar, apply this, swap, exact hmem, exact hvar},\n  case nnf.box : \u03c8 {dsimp, intros, have := h.no_box_main, exfalso, rw heq at hmem, exact this hmem},\n  case nnf.and : \u03c6 \u03c8 { rw heq at hmem, have := h.satu.no_and, have := @this \u03c6 \u03c8, contradiction},\n  case nnf.or : \u03c6 \u03c8 { rw heq at hmem, have := h.satu.no_or, have := @this \u03c6 \u03c8, contradiction},\n  case nnf.dia : \u03c6 { rw heq at hmem, have := h.no_dia, have := @this \u03c6, contradiction},\nend\n\n\n/- Regular lemmas for the propositional part. -/\n\nsection\nvariables (\u03c6 \u03c8 : nnf) (\u0393\u2081 \u0393\u2082 \u0394 \u039b: list nnf) {st : Type}\nvariables (k : KT st) (s : st)\nopen list\n\ntheorem sat_subset (h\u2081 : \u0393\u2081 \u2286 \u0393\u2082) (h\u2082 : sat k s \u0393\u2082) : sat k s \u0393\u2081 :=\n\u03bb x hx, h\u2082 _ (h\u2081 hx)\n\ntheorem sat_sublist (h\u2081 : \u0393\u2081 <+ \u0393\u2082) (h\u2082 :sat k s \u0393\u2082) : sat k s \u0393\u2081 := \nsat_subset _ _ _ _ (sublist.subset h\u2081) h\u2082\n\ntheorem sat_append (h\u2081 : sat k s \u0393\u2081) (h\u2082 : sat k s \u0393\u2082) : sat k s (\u0393\u2081 ++ \u0393\u2082) :=\nbegin\n  intros \u03c6 h, rw mem_append at h, cases h,\n  apply h\u2081 _ h, apply h\u2082 _ h\nend\n\ntheorem unsat_contra  {\u0394 n} : var n \u2208 \u0394 \u2192  neg n \u2208 \u0394 \u2192  unsatisfiable \u0394:= \nbegin\n  intros h\u2081 h\u2082, intros v hsat, intros s hsat,\n  have := hsat _ h\u2081, have := hsat _ h\u2082, simpa\nend\n\ntheorem unsat_contra_seqt {\u0394 : seqt} {n} : var n \u2208 \u0394.main \u2192  neg n \u2208 \u0394.main \u2192  unsatisfiable (\u0394.main ++ \u0394.hdld):= \nbegin\n  intros h\u2081 h\u2082, intros st m, intros s hsat,\n  have := unsat_contra h\u2081 h\u2082,\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 \u03c6 \u03c8) \u2194 (force k s \u03c6) \u2227 (force k s \u03c8) := \nby split; {intro, simpa}\n\ntheorem sat_of_sat_erase (h\u2081 : sat k s $ \u0394.erase \u03c6) (h\u2082 : force k s \u03c6) : sat k s \u0394 := \nbegin\n  intro \u03c8, intro h,\n  by_cases (\u03c8 = \u03c6),\n  {rw h, assumption},\n  {have : \u03c8 \u2208 \u0394.erase \u03c6,\n   rw mem_erase_of_ne, assumption, exact h,\n   apply h\u2081, assumption}\nend\n\ntheorem unsat_and_of_unsat_split \n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : unsatisfiable $ \u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)) : \n        unsatisfiable \u0394 :=\nbegin\n  intro st, intros, intro h,\n  apply h\u2082, swap 3, exact k, swap, exact s,\n  intro e, intro he,\n  cases he,\n  {rw he, have := h _ h\u2081, rw sat_of_and at this, exact this.1},\n  {cases he, \n    {rw he, have := h _ h\u2081, rw sat_of_and at this, exact this.2}, \n    {have := h _ h\u2081, apply h, apply mem_of_mem_erase he} }\nend\n\ntheorem unsat_and_of_unsat_split_seqt {\u0393}\n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : unsatisfiable $ (\u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)++\u0393)) : \n        unsatisfiable (\u0394++\u0393) :=\nbegin\n  intro st, intros, intro h,\n  apply h\u2082, swap 3, exact k, swap, exact s,\n  intro e, intro he,\n  cases he,\n  {rw he, have := h _ (mem_append_left _ h\u2081), rw sat_of_and at this, exact this.1},\n  {cases he, \n    {rw he, have := h _ (mem_append_left _ h\u2081), rw sat_of_and at this, exact this.2},\n    {have := h _ (mem_append_left _ h\u2081), apply h, apply mem_of_mem_erase, rw erase_append_left, exact he, exact h\u2081} }\nend\n\ntheorem sat_and_of_sat_split\n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : sat k s $ \u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)) : \n        sat k s \u0394 := \nbegin\n  intro e, intro he,\n  by_cases (e = and \u03c6 \u03c8),\n  { rw h, dsimp, split, repeat {apply h\u2082, simp} },\n  { have : e \u2208 \u0394.erase (and \u03c6 \u03c8),\n      { rw mem_erase_of_ne, repeat { assumption } },\n    apply h\u2082, simp [this] }\nend\n\ntheorem sat_and_of_sat_split_seqt {\u0393}\n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : sat k s $ (\u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)++\u0393)) : \n        sat k s (\u0394++\u0393) := \nbegin\n  intro e, intro he,\n  by_cases (e = and \u03c6 \u03c8),\n  { rw h, dsimp, split, repeat {apply h\u2082, simp} },\n  { have : e \u2208 \u0394.erase (and \u03c6 \u03c8) ++ \u0393,\n      { rw \u2190erase_append_left, rw mem_erase_of_ne, repeat {assumption} },\n    apply h\u2082, simp [this] }\nend\n\ntheorem sat_split_of_sat_and_seqt {\u0393}\n        (h\u2081 : and \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2082 : sat k s (\u0394++\u0393)) : \n        sat k s $ (\u03c6 :: \u03c8 :: \u0394.erase (and \u03c6 \u03c8)++\u0393) := \nbegin\n  intros e he, rw mem_append at he, cases he,\n  have : force k s (and \u03c6 \u03c8), {apply h\u2082, simp [h\u2081]}, 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\u2082, rw mem_append, left, apply mem_of_mem_erase he}\n  },\n  {apply h\u2082, rw mem_append, right, exact he}\nend\n\ntheorem unsat_or_of_unsat_split_seqt {\u0393}\n        (h : or \u03c6 \u03c8 \u2208 \u0394) \n        (h\u2081 : unsatisfiable $ (\u03c6 :: \u0394.erase (nnf.or \u03c6 \u03c8)++\u0393)) \n        (h\u2082 : unsatisfiable $ (\u03c8 :: \u0394.erase (nnf.or \u03c6 \u03c8)++\u0393)) : \n        unsatisfiable $ (\u0394++\u0393) := \nbegin\n  intro, intros, intro hsat,\n  have := hsat _ (mem_append_left _ h),\n  dsimp at this,\n  cases this,\n  {apply h\u2081, 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\u2082, 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 \u03c6 \u03c8 \u2208 \u0394) \n        (hl : sat k s $ \u03c6 :: \u0394.erase (nnf.or \u03c6 \u03c8)) :\n        sat k s \u0394 := \nbegin\n  intros e he,\n  by_cases (e = or \u03c6 \u03c8),\n  { rw h, dsimp, left, apply hl, simp},\n  {have : e \u2208 \u0394.erase (or \u03c6 \u03c8),\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 \u03c6 \u03c8 \u2208 \u0394) \n        (hl : sat k s $ \u03c8 :: \u0394.erase (nnf.or \u03c6 \u03c8)) :\n        sat k s \u0394 := \nbegin\n  intros e he,\n  by_cases (e = or \u03c6 \u03c8),\n  { rw h, dsimp, right, apply hl, simp},\n  { have : e \u2208 \u0394.erase (or \u03c6 \u03c8),\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 \u03c6) : force k s \u03c6 \n:= begin dsimp at h, apply h, apply k.refl end\n\ntheorem unsat_copy_of_unsat_box \n        (h\u2081 : box \u03c6 \u2208 \u0394) \n        (h\u2082 : unsatisfiable $ (\u03c6 :: \u0394.erase (box \u03c6)) ++ box \u03c6 :: \u039b) : \n        unsatisfiable (\u0394 ++ \u039b) :=\nbegin\n  intros st k s h,\n  apply h\u2082, 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 \u03c6), simp [h\u2081]},\n    {apply h, rw mem_append, left, apply mem_of_mem_erase he }},\n  {cases he, \n    {rw \u2190he at h\u2081, apply h, rw mem_append, left, exact h\u2081},\n    {apply h, rw mem_append, right, assumption}}\nend\n\ntheorem sat_copy_of_sat_box \n        (h\u2081 : box \u03c6 \u2208 \u0394) \n        (h\u2082 : sat k s $ (\u03c6 :: \u0394.erase (box \u03c6)) ++ box \u03c6 :: \u039b) : \n        sat k s (\u0394 ++ \u039b) :=\nbegin\n  intros \u03c8 h\u03c6,\n  rw mem_append at h\u03c6,\n  cases h\u03c6,\n  {by_cases heq : \u03c8 = box \u03c6, \n    {rw heq, apply h\u2082 (box \u03c6), simp}, \n    {have := mem_erase_of_ne heq, rw \u2190this at h\u03c6, apply h\u2082, simp, right, left, exact h\u03c6}},\n  {apply h\u2082, simp, repeat {right}, exact h\u03c6}\nend\n\ntheorem sat_box_of_sat_copy\n        (h\u2081 : box \u03c6 \u2208 \u0394) \n        (h\u2082 : sat k s (\u0394 ++ \u039b)) : \n        sat k s $ (\u03c6 :: \u0394.erase (box \u03c6)) ++ box \u03c6 :: \u039b :=\nbegin\n  apply sat_append,\n  {intros \u03c8 h, cases h, have : sat k s \u0394, {apply sat_subset \u0394 (\u0394++\u039b), simp, assumption}, have := this _ h\u2081, apply force_of_force_box, rw h, exact this, apply h\u2082, have := mem_of_mem_erase h, simp [this]},\n  {intros \u03c8 h, cases h, rw h, have := h\u2082 (box \u03c6), apply this, simp [h\u2081], apply h\u2082, rw mem_append, right, exact h}\nend\n\nend\n\ndef and_child {\u03c6 \u03c8} (\u0393 : seqt) (h : nnf.and \u03c6 \u03c8 \u2208 \u0393.main) : seqt :=\n\u27e8\u03c6 :: \u03c8 :: \u0393.main.erase (and \u03c6 \u03c8), \u0393.hdld, \nbegin \n  intros k s \u03b3 hsat hin hall, \n  by_cases heq : \u03b3 = and \u03c6 \u03c8,\n  {rw heq, split, apply hsat, simp, apply hsat, simp},\n  {apply \u0393.pmain _ hin hall, apply sat_and_of_sat_split _ _ _ _ _ h hsat}\nend, \n\u0393.phdld\u27e9\n\ninductive and_instance_seqt (\u0393 : seqt) : seqt \u2192 Type\n| cons : \u03a0 {\u03c6 \u03c8} (h : nnf.and \u03c6 \u03c8 \u2208 \u0393.main), \n         and_instance_seqt $ and_child \u0393 h\n\ndef or_child_left {\u03c6 \u03c8} (\u0393 : seqt) (h : nnf.or \u03c6 \u03c8 \u2208 \u0393.main) : seqt :=\n\u27e8\u03c6 :: \u0393.main.erase (or \u03c6 \u03c8), \u0393.hdld, \nbegin \n  intros k s \u03b3 hsat hin hall, \n  by_cases heq : \u03b3 = or \u03c6 \u03c8,\n  {rw heq, dsimp, left, apply hsat, simp},\n  {apply \u0393.pmain, apply sat_or_of_sat_split_left, exact h, exact hsat, exact hin, exact hall}\nend, \n\u0393.phdld\u27e9\n\ndef or_child_right {\u03c6 \u03c8} (\u0393 : seqt) (h : nnf.or \u03c6 \u03c8 \u2208 \u0393.main) : seqt :=\n\u27e8\u03c8 :: \u0393.main.erase (or \u03c6 \u03c8), \u0393.hdld, \nbegin \n  intros k s \u03b3 hsat hin hall, \n  by_cases heq : \u03b3 = or \u03c6 \u03c8,\n  {rw heq, dsimp, right, apply hsat, simp},\n  {apply \u0393.pmain, apply sat_or_of_sat_split_right, exact h, exact hsat, exact hin, exact hall}\nend, \n\u0393.phdld\u27e9\n\ninductive or_instance_seqt (\u0393 : seqt) : seqt \u2192 seqt \u2192 Type\n| cons : \u03a0 {\u03c6 \u03c8} (h : nnf.or \u03c6 \u03c8 \u2208 \u0393.main),\n         or_instance_seqt (or_child_left \u0393 h) (or_child_right \u0393 h)\n\ndef box_child {\u03c6} (\u0393 : seqt) (h : nnf.box \u03c6 \u2208 \u0393.main) : seqt :=\n\u27e8\u03c6 :: \u0393.main.erase (box \u03c6), box \u03c6 :: \u0393.hdld, \nbegin \n  intros k s \u03b3 hsat hin hall, \n  cases hin,\n  {simp at hin, rw hin, apply hsat, simp},\n  {apply \u0393.pmain, intros \u03c8 h\u03c8,\n   by_cases heq : \u03c8 = box \u03c6,\n   {rw heq, dsimp, intros s' hs', \n    have := mem_of_mrel_tt hs', cases this,\n    {apply hall, simp, assumption},\n    {rw \u2190this, apply hsat, simp} },\n   {apply hsat, right, \n    have := list.mem_erase_of_ne heq, swap, exact \u0393.main, \n    rw \u2190this at h\u03c8, assumption},\n  {assumption},{intros, apply hall, simp [a], exact H} }\nend, \ncons_box_only \u0393.phdld\u27e9\n\ninductive copy_instance_seqt (\u0393 : seqt) : seqt \u2192 Type\n| cons : \u03a0 {\u03c6} (h : nnf.box \u03c6 \u2208 \u0393.main), \n         copy_instance_seqt $ box_child \u0393 h\n\ntheorem build_model_seqt : \u03a0 \u0393 (h : model_constructible \u0393), \nsat builder (cons h.v []) (\u0393.main ++ \u0393.hdld) := \nbegin \n  intros \u0393 h, apply sat_append, apply build_model,\n  intros \u03c8 h\u03c8, \n  have := box_only_ex \u0393.phdld h\u03c8, cases this with w hw,\n  rw hw, apply force_box_of_leaf, apply \u0393.pmain _ _,\n  {intros \u03c8 hin m hm, exfalso, apply list.not_mem_nil, exact hm},\n  {apply build_model},\n  {rw hw at h\u03c8, 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 `\u03c6 \u03c8 : mv_polynomial \u03c3 R`\n  over an infinite integral domain `R` are equal if `eval x \u03c6 = eval x \u03c8` for all `x : \u03c3 \u2192 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] {\u03c3 : Type u_2}\n    {p : mv_polynomial \u03c3 R} {q : mv_polynomial \u03c3 R}\n    (h : \u2200 (x : \u03c3 \u2192 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] {\u03c3 : Type u_2}\n    {p : mv_polynomial \u03c3 R} {q : mv_polynomial \u03c3 R} :\n    p = q \u2194 \u2200 (x : \u03c3 \u2192 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 {\u03b1  : Type*} [topological_space \u03b1 ] \nvariables {\u03b2  : Type*} [topological_space \u03b2 ] { x y z w : \u03b2  }\nvariables ( x0 : \u03b2  )\nvariable s : I01 \n\nnoncomputable theory\n\nlocal attribute [instance] classical.prop_decidable \n\n-- HOMOTOPY \n\n\n-- General Homotopy \nstructure homotopy  {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} ( hcf : continuous f) ( hcg : continuous g) :=\n(to_fun : I01 \u00d7 \u03b1 \u2192  \u03b2 )  \n(at_zero : ( \u03bb x, to_fun ( 0 , x) ) = f )\n(at_one : ( \u03bb 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 \u00d7 I01 \u2192  \u03b2 )\n(path_s : \u2200 s : I01, is_path x y ( \u03bb t, to_fun (s, t) ) ) \n(at_zero : \u2200 y, to_fun (0,y) = f.to_fun y ) \n(at_one :  \u2200 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 \u00d7 I01 \u2192  \u03b2) (start_pt : \u2200 s : I01, F (s, 0) = x) (end_pt : \u2200 s : I01, F (s, 1) = y) \n  (at_zero : \u2200 y, F (0,y) = f.to_fun y ) (at_one : \u2200 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 : \u03b2 } { f g : path x y } ( F : path_homotopy f g ) : \n\u2200 s : I01, check_pts x y ( \u03bb t,  F.to_fun (s, t)) := \nbegin \n  intro s, unfold check_pts, split, \n    have h\u2081 : F.to_fun (s, 0) =  ( \u03bb t,  F.to_fun (s, t)) 0, by simp, \n    rw h\u2081 , exact (F.path_s s).left,\n    have h\u2082  : F.to_fun (s, 1) =  ( \u03bb t,  F.to_fun (s, t)) 1, by simp, \n    rw h\u2082 , exact (F.path_s s).right.left \nend \n\n--- (Can Remove - not Used)\nlemma hom_path_is_cont { x y : \u03b2 } { f g : path x y } ( F : path_homotopy f g ) : \n\u2200 s : I01, continuous ( \u03bb 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 ( \u03bb 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 : \u03b2} (f : path x y) : path_homotopy f f := \n{   to_fun :=  \u03bb st  , f.to_fun (prod.snd st) ,  \n\n    path_s := begin  intro s, unfold is_path, exact \u27e8 f.at_zero,  f.at_one, f.cont \u27e9 end, \n\n    at_zero := by simp , \n    at_one := by simp ,  \n\n    cont := \n    begin \n      let h := \u03bb 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 : (\u03bb (st : \u21a5I01 \u00d7 \u21a5I01), F.to_fun (par_inv (st.fst), st.snd)) = \n  ((\u03bb (st : \u21a5I01 \u00d7 \u21a5I01), F.to_fun (st.fst , st.snd)) \u2218 \n     (\u03bb (x : I01 \u00d7 I01) , (( par_inv x.1 , x.2 ) : I01 \u00d7 I01))) := by trivial\n\ndef path_homotopy_inverse { x y : \u03b2} {f : path x y} {g : path x y} ( F : path_homotopy f g) : path_homotopy g f := \n{   to_fun :=   \u03bb 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 ((\u03bb (st : \u21a5I01 \u00d7 \u21a5I01), F.to_fun (st.fst , st.snd)) \u2218 (\u03bb (x : I01 \u00d7 I01) , (( par_inv x.1 , x.2 ) : I01 \u00d7 I01))), \n      have H : continuous (\u03bb (x : I01 \u00d7 I01) , (( par_inv x.1 , x.2 ) : I01 \u00d7 I01)),\n        { exact continuous.prod_mk ( continuous.comp  continuous_fst continuous_par_inv) \n          ( @continuous.comp (I01\u00d7I01) I01 I01 _ _ _ (\u03bb x : I01\u00d7I01, 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 \u00d7 I01, T2 \u00d7 I01 cover I01 \u00d7 I01 \nlemma cover_prod_I01 : ( (set.prod T1 (@set.univ I01)) \u222a (set.prod T2 (@set.univ I01)) ) = \n  @set.univ (I01 \u00d7 I01) := \nbegin \n  apply set.ext, intro x, split, simp [mem_set_of_eq], \n  intro H, simp, have H : 0 \u2264 x.1.val \u2227 x.1.val \u2264 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 :\u211d )< x.1.val, by exact nL H.1, \n  exact \u27e8 le_of_lt H2, H.2 \u27e9 ,\nend\n\n-- Closedness and intersection of T1 \u00d7 I01, T2 \u00d7 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 \u2228 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 : \u03b1 } {r s : \u211d} {f g: path x y } (Hrs : r < s)\n ( F : path_homotopy f g) : (set.prod (T r s Hrs ) I) \u2192 \u03b1 := \n\u03bb st, F.to_fun (( par Hrs \u27e8st.1.1, (mem_prod.1 st.2).1 \u27e9) , st.1.2 )\n\n\ntheorem p_hom_cont { x y : \u03b1 } {r s : \u211d} {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 : \u03b1 }{f g: path x y } ( F : path_homotopy f g) : (set.prod T1 I) \u2192 \u03b1  := \n@fgen_hom _ _ _ _ 0 (1/2 : \u211d ) _ _  zero_lt_half F \n\nlemma CA_hom { x y : \u03b1 }{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 : \u03b1 }{f g: path x y } ( F : path_homotopy f g) : (set.prod T2 I) \u2192 \u03b1  := \n@fgen_hom _ _ _ _ (1/2 : \u211d ) 1 _ _  half_lt_one F \n\nlemma CB_hom { x y : \u03b1 }{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 := \u03bb st, ( @paste (I01 \u00d7 I01) \u03b2 (set.prod T1 I) (set.prod T2 I)  cover_prod_I01 ( \u03bb st , (fa_hom F ) st ) ) ( \u03bb 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 : \u2200 t : I01, (s, t) \u2208 set.prod T1 I, simp [H],  \n        refine (F.path_s (par zero_lt_half \u27e8 s, _ \u27e9  )).2.2, unfold set.prod at H, \n        have H2 : (s, s) \u2208 {p : \u21a5I01 \u00d7 \u21a5I01 | p.fst \u2208 T1 \u2227 p.snd \u2208 univ}, exact H s, simp [mem_set_of_eq] at H2, exact H2, \n        simp at H,\n        have H3:  s \u2209 T1, simp [not_forall] at H, exact H.2,\n        simp [H3], refine (G.path_s (par half_lt_one \u27e8 s, _ \u27e9  )).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 \u2208 set.inter (set.prod T1 I) (set.prod T2 I), exact \u27e8 B1 , B2 \u27e9 , \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 = \u27e8 1/2 , help_01 \u27e9 , apply subtype.eq, rw V,\n        simp [xeq, -one_div_eq_inv], \n        show fa_hom F \u27e8(\u27e81 / 2, help_01\u27e9, x_snd), _\u27e9 = fb_hom G \u27e8(\u27e81 / 2, help_01\u27e9, x_snd), _\u27e9 , 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 \u27e8 H \u27e9 \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 \u27e8path_homotopy_inverse  F\u27e9,\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 \u27e8 path_homotopy_comp F G\u27e9 , \nend \n\n\ntheorem is_equivalence : @equivalence (path x y)  (is_homotopic_to) := \n\u27e8 is_reflexive, is_symmetric, is_transitive\u27e9 \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 : \u2115) : \u2115 \u2192 \u2115 := well_founded.fix lt_wf div.F\n\nprotected instance has_div : Div \u2115 := { div := nat.div }\n\ntheorem div_def_aux (x : \u2115) (y : \u2115) :\n    x / y =\n        dite (0 < y \u2227 y \u2264 x) (fun (h : 0 < y \u2227 y \u2264 x) => (x - y) / y + 1)\n          fun (h : \u00ac(0 < y \u2227 y \u2264 x)) => 0 :=\n  congr_fun (well_founded.fix_eq lt_wf div.F x) y\n\nprotected def mod (x : \u2115) : \u2115 \u2192 \u2115 := well_founded.fix lt_wf mod.F\n\nprotected instance has_mod : Mod \u2115 := { mod := nat.mod }\n\ntheorem mod_def_aux (x : \u2115) (y : \u2115) :\n    x % y =\n        dite (0 < y \u2227 y \u2264 x) (fun (h : 0 < y \u2227 y \u2264 x) => (x - y) % y)\n          fun (h : \u00ac(0 < y \u2227 y \u2264 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  \u2200 {nodes : list node} (inputs : env) (tgts : list reference),\n  \u2200 {tgt : reference} {idx : \u2115}, at_idx tgts idx tgt \u2192\n  nodup (tgts ++ map node.ref nodes) \u2192\n  well_formed_at costs nodes inputs tgt \u2192\n  grads_exist_at nodes inputs tgt \u2192\n  pdfs_exist_at nodes inputs \u2192\n  is_gintegrable (\u03bb m, \u27e6compute_grad_slow costs nodes m tgt\u27e7) inputs nodes dvec.head \u2192\n  can_differentiate_under_integrals costs nodes inputs tgt \u2192\n\n  \u2207 (\u03bb \u03b8\u2080, E (graph.to_dist (\u03bb m, \u27e6sum_costs m costs\u27e7) (env.insert tgt \u03b8\u2080 inputs) nodes) dvec.head) (env.get tgt inputs)\n  =\n  E (graph.to_dist (\u03bb m, backprop costs nodes m tgts) inputs nodes) (\u03bb dict, dvec.get tgt.2 dict idx) :=\n\nassume (nodes : list node) (inputs : env) (tgts : list reference)\n       (tgt : reference) (idx : \u2115) (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 (\u03bb m, \u27e6compute_grad_slow costs nodes m tgt\u27e7) inputs nodes dvec.head)\n       (H_diff_under_int : can_differentiate_under_integrals costs nodes inputs tgt),\n\nhave H_gdiff : is_gdifferentiable (\u03bb m, \u27e6sum_costs m costs\u27e7) 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 (\u03bb m, \u27e6sum_costs m costs\u27e7) 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 _ _ _ (\u03bb dict, dvec.get tgt.2 dict idx)),\ndunfold backprop, dsimp,\nsimp only [(\u03bb m, tvec.get_from_env H_at_idx m), (\u03bb 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}} (\ud835\udcd5 : sheaf Ab X) (U : X.oc)\n\nsection C_alt\n\nvariables {\ud835\udcd5 U}\ndef C.pre.is_skewsymmetric {n : \u2115} (f : C.pre \ud835\udcd5 U n) : Prop :=\n\u2200 (i j : fin n) (\u03b1 : fin n \u2192 U.\u03b9),\n  f \u03b1 =\n  \ud835\udcd5.1.map (eq_to_hom (face.swap_eq \u03b1 i j)).op (- f (swap i j \u03b1))\n\ndef C.pre.is_skewsymmetric' {n : \u2115} (f : C.pre \ud835\udcd5 U n) : Prop :=\n\u2200 (i j : fin n) (\u03b1 : fin n \u2192 U.\u03b9),\n  f (swap i j \u03b1) =\n  - \ud835\udcd5.1.map (eq_to_hom (face.swap_eq \u03b1 i j).symm).op (f \u03b1)\n\nlemma is_skewsymmetric_iff_is_skewsymmetric' {n} (f : C.pre \ud835\udcd5 U n) :\n  C.pre.is_skewsymmetric f \u2194 C.pre.is_skewsymmetric' f :=\n{ mp := \u03bb h i j \u03b1, begin\n    specialize h i j \u03b1,\n    rw [h, map_neg, map_neg, neg_neg, \u2190 comp_apply, \u2190 \ud835\udcd5.1.map_comp, \u2190 op_comp, eq_to_hom_trans, eq_to_hom_refl],\n    simp,\n  end,\n  mpr := \u03bb h i j \u03b1, begin\n    specialize h i j \u03b1,\n    rw [h, neg_neg, \u2190 comp_apply, \u2190 \ud835\udcd5.1.map_comp, \u2190 op_comp, eq_to_hom_trans, eq_to_hom_refl],\n    simp\n  end }\n\nend C_alt\n\ndef C_alt.pre (n : \u2115) : add_subgroup (C \ud835\udcd5 U n) :=\n{ carrier := { f : C.pre \ud835\udcd5 U n | f.is_skewsymmetric \u2227 \u2200 (\u03b1 : fin n \u2192 U.\u03b9), \u00ac function.injective \u03b1 \u2192 f \u03b1 = 0},\n  add_mem' := \u03bb f g hf hg, begin\n    rcases hf with \u27e8hf1, hf2\u27e9,\n    rcases hg with \u27e8hg1, hg2\u27e9,\n    split,\n    intros i j \u03b1,\n    change f \u03b1 + g \u03b1 = \ud835\udcd5.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 \u03b1 ha,\n    change f \u03b1 + g \u03b1 = 0,\n    rw [hf2, hg2, add_zero];\n    assumption,\n  end,\n  zero_mem' := begin\n    split,\n    intros i j \u03b1,\n    simp only [C_pre.zero_apply, neg_zero, map_zero],\n\n    intros \u03b1 ha,\n    simp,\n  end,\n  neg_mem' := \u03bb f \u27e8hf1, hf2\u27e9, begin\n    split,\n    intros i j \u03b1,\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 \u03b1 ha,\n    change - (f \u03b1) = 0,\n    rw hf2 _ ha,\n    rw neg_zero,\n  end }\n\ndef C_alt (n : \u2115) : Ab := AddCommGroup.of $ C_alt.pre \ud835\udcd5 U n\n\ndef d_alt (n : \u2115) : C_alt \ud835\udcd5 U n \u27f6 C_alt \ud835\udcd5 U (n + 1) :=\n{ to_fun := \u03bb f, \u27e8d \ud835\udcd5 U n f.1, sorry\u27e9,\n  map_zero' := begin\n    rw subtype.ext_iff_val,\n    simp,\n  end,\n  map_add' := begin\n    rintros \u27e8f, hf\u27e9 \u27e8g, hg\u27e9,\n    rw subtype.ext_iff_val,\n    simp,\n  end }\n\nlemma d_alt_d_alt_eq_zero (n : \u2115) :\n  d_alt \ud835\udcd5 U n \u226b d_alt \ud835\udcd5 U (n + 1) = 0 :=\nbegin\n  ext f \u03b1,\n  rw [comp_apply],\n  simp only [AddCommGroup.zero_apply, add_subgroup.coe_zero, C_pre.zero_apply],\n  convert dd_eq_zero \ud835\udcd5 U n f.1 \u03b1,\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\u2081 Y\u2082 : Type} [SemiHilbert Y\u2081] [SemiHilbert Y\u2082]\n         {\u03b9 \u03ba : Type} [Enumtype \u03b9] [Enumtype \u03ba]\n\n\nexample {n : Nat} : (\u2207 (x : \u211d^{n}), \u2016x\u2016\u00b2) = \u03bb x : \u211d^{n} => (2:\u211d)*x := by symdiff; done\nexample {n : Nat} (m : \u211d) : (\u2207 (x : \u211d^{n}), 1/2 * m * \u2016x\u2016\u00b2) = \u03bb x : \u211d^{n} => m*x := by symdiff; done\n\n\n@[diff]\ntheorem adjoint_sum_eval_rank1 (f : \u03b9 \u2192 X \u2192 Y) [\u2200 i, HasAdjointT (f i)]\n  : (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, f i (x i))\u2020\n    =\n    \u03bb y i => (f i)\u2020 y := by symdiff; sorry\n\n\n\n\n@[diff]\ntheorem adjDiff_sum_eval_rank1 (f : \u03b9 \u2192 X \u2192 Y) [hf : \u2200 i, HasAdjDiffT (f i)]\n  : \u2202\u2020 (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, f i (x i))\n    =\n    \u03bb x dy' i => \u2202\u2020 (f i) (x i) dy' := \nby \n  unfold adjointDifferential\n  have := \u03bb i => (hf i).1\n  have := \u03bb i => (hf i).2\n  symdiff; symdiff; done\n\n@[diff]\ntheorem revDiff_sum_eval_rank1 (f : \u03b9 \u2192 X \u2192 Y) [hf : \u2200 i, HasAdjDiffT (f i)]\n  : \u211b (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, f i (x i))\n    =\n    \u03bb x => (\u2211 i, f i (x i), \u03bb dy' i => \u2202\u2020 (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? : \u03b9 \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 W \u2192 Y) (h : X \u2192 W)\nwhere\n  f? =?= \u03bb i x => f i (h x)\n  |-\n  (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, (f? i) (x i))\u2020 \n  =?= \n  (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, f i (h (x i)))\u2020\n\n\n\nunif_hint adjoint_sum_eval_rank1.unif_hint_1 \n  (f? : \u03b9 \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 X \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03b1)\nwhere\n  f? =?= \u03bb i x => f i x (g i)\n  |-\n  (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, (f? i) (x i))\u2020 \n  =?= \n  (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, f i (x i) (g i))\u2020\n\n\nunif_hint adjDiff_sum_eval_rank1.unif_hint_1\n  (f? : \u03b9 \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 X \u2192 W) (h : \u03b9 \u2192 W \u2192 Y)\nwhere\n  f? =?= \u03bb i x => h i (f i x)\n  |-\n  \u2202\u2020 (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, (f? i) (x i))\n  =?= \n  \u2202\u2020 (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, h i (f i (x i)))\n\nunif_hint adjDiff_sum_eval_rank1.unif_hint_2\n  (f? : \u03b9 \u2192 X \u2192 Y) \n  (op : Y\u2081 \u2192 Y\u2082 \u2192 Y)\n  (f\u2081 : \u03b9 \u2192 X \u2192 Y\u2081) (f\u2082 : \u03b9 \u2192 X \u2192 Y\u2082)-- (h : \u03b9 \u2192 W \u2192 Y)\nwhere\n  f? =?= \u03bb i x => op (f\u2081 i x) (f\u2082 i x)\n  |-\n  \u2202\u2020 (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, (f? i) (x i))\n  =?= \n  \u2202\u2020 (\u03bb (x : \u03b9 \u2192 X) => \u2211 i, (op (f\u2081 i (x i)) (f\u2082 i (x i))))\n\n\nunif_hint adjDiff_sum_eval_rank1.unif_hint_3\n  (f? : \u03b9 \u2192 \u211d \u2192 \u211d) \n  -- (op : Y\u2081 \u2192 Y\u2082 \u2192 Y)\n  -- (f\u2081 : \u03b9 \u2192 X \u2192 Y\u2081) (f\u2082 : \u03b9 \u2192 X \u2192 Y\u2082)-- (h : \u03b9 \u2192 W \u2192 Y)\nwhere\n  f? =?= \u03bb i x => x * x\n  |-\n  \u2202\u2020 (\u03bb (x : \u03b9 \u2192 \u211d) => \u2211 i, (f? i) (x i))\n  =?= \n  \u2202\u2020 (\u03bb (x : \u03b9 \u2192 \u211d) => \u2211 i, x i * x i)\n\n\n@[simp]\ntheorem sum_setElem_zero {X\u03b9} [ArrayType X\u03b9 \u03b9 X]\n  : \u2211 i, setElem (0 : X\u03b9) i (f i) = introElem f := sorry\n\n@[diff]\ntheorem adjDiff_ArrayType_rule_forall\u2082 {X\u03b9} [ArrayType X\u03b9 \u03b9 X] (f : \u03b9 \u2192 X \u2192 Y) [\u2200 i, HasAdjDiffT (f i)]\n  : \u2202\u2020 (\u03bb (x : X\u03b9) i => f i x[i])\n    =\n    \u03bb x dx' => introElem \u03bb i => \u2202\u2020 (f i) x[i] (dx' i) := \nby\n  symdiff; simp; done\n\n\nunif_hint adjDiff_ArrayType_rule_forall\u2082.unif_hint_2 {X\u03b9} [ArrayType X\u03b9 \u03b9 X]\n  (f? : \u03b9 \u2192 X \u2192 Y)\n  (f : \u03b9 \u2192 X \u2192 W) (h : \u03b9 \u2192 W \u2192 Y)\nwhere\n  f? =?= \u03bb i x => h i (f i x)\n  |-\n  \u2202\u2020 (\u03bb (x : X\u03b9) i => f? i x[i])\n  =?= \n  \u2202\u2020 (\u03bb (x : X\u03b9) i => h i (f i x[i]))\n\n@[diff]\ntheorem adjDiff_ArrayType_rule_forall\u2082.unif_hint_1 {X\u03b9} [ArrayType X\u03b9 \u03b9 X]\n  (f : \u03b9 \u2192 X \u2192 Y) [\u2200 i, HasAdjDiffT (f i)]\n  (h : \u03b9 \u2192 Y \u2192 Z) [\u2200 i, HasAdjDiffT (h i)]\n  : \u2202\u2020 (\u03bb (x : X\u03b9) i => h i (f i x[i]))\n    =\n    \u03bb x dx' => introElem \u03bb i => \u2202\u2020 (\u03bb x => h i (f i x)) x[i] (dx' i) := \nby\n  symdiff; done\n\n\nexample {X} [Hilbert X] (c : \u211d) : HasAdjDiffT (fun x : X => c * \u2016 x \u2016\u00b2) := by infer_instance\n\nexample (c : \u211d) : HasAdjDiffT (fun x : \u211d => c * \u2016 x \u2016\u00b2 ) := by infer_instance\nexample {X} [Hilbert X] (c : \u211d) : HasAdjDiffT (fun x : X => c * \u27eax,x\u27eb) := by infer_instance\n\nset_option trace.Meta.Tactic.simp.rewrite true in\nexample {n : Nat} : \u2207 (x : Fin n \u2192 \u211d), \u2211 i, x i  = \u03bb x i =>    1 := by symdiff; done\nset_option trace.Meta.Tactic.simp.rewrite true in\nexample {n : Nat} : \u2207 (x : \u211d^{n}),      \u2211 i, x[i] = \u03bb x => \u229e i, 1 := by symdiff; rfl; done\n\nexample {n : Nat} : \u2207 (x : Fin n \u2192 \u211d), \u2211 i, \u2016x i\u2016\u00b2  = \u03bb x i =>    (2:\u211d) * x i := by symdiff; done\nexample {n : Nat} : \u2207 (x : \u211d^{n}),      \u2211 i, \u2016x[i]\u2016\u00b2 = \u03bb x => \u229e i, (2:\u211d) * x[i] := by symdiff; rfl; done\n\nexample {n : Nat} (c : \u211d) : \u2207 (x : Fin n \u2192 \u211d), \u2211 i, c * \u2016x i\u2016\u00b2  = \u03bb 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 : \u211d) : \u2207 (x : \u211d^{n}),      \u2211 i, c * \u2016x[i]\u2016\u00b2 = \u03bb x => \u229e i, 2 * c * x[i] := by symdiff; rfl; done \n\nset_option trace.Meta.Tactic.simp.discharge true in\nexample {n : Nat} (c : \u211d) : \u2202\u2020 (\u03bb (x : \u211d^{n}) i => c * \u2016x[i]\u2016\u00b2) = \u03bb x dx' => \u229e i, 2 * c * dx' i * x[i] := by \n  symdiff\n  rw[adjDiff_ArrayType_rule_forall\u2082.unif_hint]; symdiff; rfl -- (\u03bb _ (x : \u211d) => \u2016x\u2016\u00b2) (\u03bb _ (x : \u211d) => c * x)\n  done\n\n\nexample {n : Nat} (c : \u211d) : \u2207 (x : Fin n \u2192 \u211d), \u2211 i, (c + i) * \u2016x i\u2016\u00b2 = \u03bb x (i : Fin n) => 2 * (c + i) * x i := by symdiff; done \nset_option trace.Meta.Tactic.simp.unify true in\nexample {n : Nat} : \u2207 (x : Fin n \u2192 \u211d), \u2211 i, x i * x i = \u03bb x i => 2 * x i := \nby \n  unfold gradient; funext x; \n  rw[adjDiff_sum_eval_rank1 (\u03bb i xi => xi * xi)]\n  symdiff; done\nexample {n : Nat} : \u2207 (x : \u211d^{n}), \u2211 i, x[i]*x[i] = \u03bb x => \u229e i, (2:\u211d) * 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 \u2190 Meta.ppExpr lhs\n  let ppRhs \u2190 Meta.ppExpr rhs\n  let test \u2190 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  (\u03b1 \u03b2 \u03b3 : Type) (F : (\u03b1\u2192\u03b2) \u2192 (\u03b1\u2192\u03b3)) (g : \u03b2 \u2192 \u03b3)\nwhere\n  F =?= \u03bb f x => g (f x)\n  |-\n  (\u03bb f x => g (f x))\n  =?=\n  \u03bb f => F f\n\nunif_hint \n  (\u03b1 \u03b2 \u03b3 : Type) (F : (\u03b1\u2192\u03b2) \u2192 (\u03b1\u2192\u03b3)) (g : \u03b2 \u2192 \u03b3)\nwhere\n  F =?= \u03bb f x => g (f x)\n  |-\n  \u03bb f => F f\n  =?=\n  (\u03bb 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\u2192Nat) \u2190 mkFreshExprMVar q(Nat\u2192Nat)\n\n  unifyTest q(\u03bb (x : Nat) => $f? x)\n            q(\u03bb (x : Nat) => Nat.succ (Nat.succ x))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) \u2190 mkFreshExprMVarQ q(Nat)\n  let f? : Q(Nat\u2192Nat) \u2190 mkFreshExprMVarQ q(Nat\u2192Nat)\n\n  unifyTest q(\u03bb (x : Fin $n? \u2192 Nat) i => $f? (x i))\n            q(\u03bb (x : Fin $n? \u2192 Nat) i => Nat.succ (x i))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) \u2190 mkFreshExprMVarQ q(Nat)\n  let f? : Q(Nat\u2192Nat) \u2190 mkFreshExprMVarQ q(Nat\u2192Nat)\n  let g? : Q(Nat\u2192Nat) \u2190 mkFreshExprMVarQ q(Nat\u2192Nat)\n\n  unifyTest q(\u03bb (x : Fin $n? \u2192 Nat) i => $f? (x i))\n            q(\u03bb (x : Fin $n? \u2192 Nat) i => $g? (x i))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) \u2190 mkFreshExprMVarQ q(Nat)\n  let F? : Q((Fin $n?\u2192Nat)\u2192(Fin $n?\u2192Nat)) \u2190 mkFreshExprMVarQ q((Fin $n?\u2192Nat)\u2192(Fin $n?\u2192Nat))\n  let g? : Q(Nat\u2192Nat) \u2190 mkFreshExprMVarQ q(Nat\u2192Nat)\n\n  unifyTest q(\u03bb (x : Fin $n? \u2192 Nat) => $F? x)\n            q(\u03bb (x : Fin $n? \u2192 Nat) i => $g? (x i))\n\n\n#eval show MetaM Unit from do\n  let X? : Q(Type) \u2190 mkFreshExprMVarQ q(Type)\n  let Y? : Q(Type) \u2190 mkFreshExprMVarQ q(Type)\n  let Z? : Q(Type) \u2190 mkFreshExprMVarQ q(Type)\n  let g? : Q($Y?\u2192$Z?) \u2190 mkFreshExprMVarQ q($Y?\u2192$Z?)\n  let h? : Q($Y?\u2192$Z?) \u2190 mkFreshExprMVarQ q($Y?\u2192$Z?)\n\n  q(\u03bb (f : $X? \u2192 $Y?) x => $g? (f x))\n  =?= \n  q(\u03bb (f : $X? \u2192 $Y?) x => $h? (f x))\n\n\n#eval show MetaM Unit from do\n  let X? : Q(Type) \u2190 mkFreshExprMVarQ q(Type)\n  let Y? : Q(Type) \u2190 mkFreshExprMVarQ q(Type)\n  let F? : Q(($X?\u2192$Y?)\u2192($X?\u2192$Y?)) \u2190 mkFreshExprMVarQ q(($X?\u2192$Y?)\u2192($X?\u2192$Y?))\n  let G? : Q(($X?\u2192$Y?)\u2192($X?\u2192$Y?)) \u2190 mkFreshExprMVarQ q(($X?\u2192$Y?)\u2192($X?\u2192$Y?))\n  let g? : Q($Y?\u2192$Y?) \u2190 mkFreshExprMVarQ q($Y?\u2192$Y?)\n\n  q(\u03bb (f : $X? \u2192 $Y?) => $F? f)\n  =?=\n  q(\u03bb (f : $X? \u2192 $Y?) x => $g? (f x))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) \u2190 mkFreshExprMVarQ q(Nat)\n  let f? : Q(Nat\u2192Nat) \u2190 mkFreshExprMVarQ q(Nat\u2192Nat)\n\n  unifyTest q(id $ \u03bb (x : Fin $n? \u2192 Nat) i => $f? (x i))\n            q(id $ \u03bb (x : Fin $n? \u2192 Nat) i => Nat.succ (x i))\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) \u2190 mkFreshExprMVarQ q(Nat)\n  let op? : Q(\u211d \u2192 \u211d \u2192 \u211d) \u2190 mkFreshExprMVarQ q(\u211d \u2192 \u211d \u2192 \u211d)\n\n  unifyTest q(\u03bb (x : Fin $n? \u2192 \u211d) i => $op? (x i) (x i))\n            q(\u03bb (x : Fin $n? \u2192 \u211d) i => x i * x i)\n\n\n#eval show MetaM Unit from do\n  let n? : Q(Nat) \u2190 mkFreshExprMVarQ q(Nat)\n  let f? : Q(Fin $n? \u2192 \u211d \u2192 \u211d) \u2190 mkFreshExprMVarQ q(Fin $n? \u2192 \u211d \u2192 \u211d)\n\n  unifyTest q(\u03bb (x : Fin $n? \u2192 \u211d) i => $f? i (x i))\n            q(\u03bb (x : Fin $n? \u2192 \u211d) 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 '\u00ab$n\u00bb'\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 \u00d7 Fin ($n + 1))) : Q(Fin ($n + 3)) :=\n  q(\u27e8$x.2, Nat.lt_of_lt_of_le $x.2.2 (Nat.le_add_right _ 2)\u27e9)\n\n\n#eval show MetaM Unit from do\n  let a? \u2190 mkFreshExprMVar q(Nat)\n  let b? \u2190 mkFreshExprMVar q(Nat)\n  pure ()\n\n#eval show MetaM Unit from do\n  let a? \u2190 mkFreshExprMVarQ q(Nat)\n  let b? \u2190 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 \u27f6 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 \u27f6 R` is mono if and only if `g \u226b f = 0 \u2192 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 \u226b (-g)` and `(-f) \u226b g` both become `-(f \u226b g)`, and `(-f) \u226b (-g)`\nis simplified to `f \u226b 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 \u27f6 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) \u2192 add_comm_group (P \u27f6 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 (\u2200 (P Q R : C) (f f' : P \u27f6 Q) (g : Q \u27f6 R), (f + f') \u226b g = f \u226b g + f' \u226b 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 (\u2200 (P Q R : C) (f : P \u27f6 Q) (g g' : Q \u27f6 R), f \u226b (g + g') = f \u226b g + f \u226b 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 \u27f6 Q) (f' : P \u27f6 Q) (g : Q \u27f6 R) : (f + f') \u226b g = f \u226b g + f' \u226b 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 \u27f6 Q) (g : Q \u27f6 R) (g' : Q \u27f6 R) : f \u226b (g + g') = f \u226b g + f \u226b 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 \u27f6 Q) (f' : P \u27f6 Q) (g : Q \u27f6 R) {X' : C} :\n    \u2200 (f'_1 : R \u27f6 X'), (f + f') \u226b g \u226b f'_1 = (f \u226b g + f' \u226b g) \u226b 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 \u27f6 Q) (g : Q \u27f6 R) (g' : Q \u27f6 R) {X' : C} (f' : R \u27f6 X') :\n    f \u226b (g + g') \u226b f' = (f \u226b g + f \u226b g') \u226b 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 \u27f6 Q) :\n    (Q \u27f6 R) \u2192+ (P \u27f6 R) :=\n  add_monoid_hom.mk' (fun (g : Q \u27f6 R) => f \u226b 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 \u27f6 R) :\n    (P \u27f6 Q) \u2192+ (P \u27f6 R) :=\n  add_monoid_hom.mk' (fun (f : P \u27f6 Q) => f \u226b 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 \u27f6 Q) (f' : P \u27f6 Q) (g : Q \u27f6 R) {X' : C} :\n    \u2200 (f'_1 : R \u27f6 X'), (f - f') \u226b g \u226b f'_1 = (f \u226b g - f' \u226b g) \u226b 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 \u27f6 Q) (g : Q \u27f6 R) (g' : Q \u27f6 R) : f \u226b (g - g') = f \u226b g - f \u226b 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 \u27f6 Q) (g : Q \u27f6 R) : (-f) \u226b g = -f \u226b 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 \u27f6 Q)\n    (g : Q \u27f6 R) {X' : C} (f' : R \u27f6 X') : f \u226b (-g) \u226b f' = (-f \u226b g) \u226b f' :=\n  sorry\n\ntheorem neg_comp_neg {C : Type u} [category C] [preadditive C] {P : C} {Q : C} {R : C} (f : P \u27f6 Q)\n    (g : Q \u27f6 R) : (-f) \u226b (-g) = f \u226b 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 \u27f6 Q) (g : J \u2192 (Q \u27f6 R)) :\n    (f \u226b finset.sum s fun (j : J) => g j) = finset.sum s fun (j : J) => f \u226b 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 \u2192 (P \u27f6 Q)) (g : Q \u27f6 R) {X' : C} (f' : R \u27f6 X') :\n    finset.sum s f \u226b g \u226b f' = (finset.sum s fun (j : J) => f j \u226b g) \u226b 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 \u27f6 Q} [epi f] : epi (-f) :=\n  epi.mk\n    fun (R : C) (g g' : Q \u27f6 R) (H : (-f) \u226b g = (-f) \u226b g') =>\n      eq.mp (Eq._oldrec (Eq.refl (-g = -g')) (propext neg_inj))\n        (eq.mp (Eq._oldrec (Eq.refl (f \u226b (-g) = f \u226b (-g'))) (propext (cancel_epi f)))\n          (eq.mp (Eq._oldrec (Eq.refl (f \u226b (-g) = -f \u226b g')) (Eq.symm (comp_neg f g')))\n            (eq.mp (Eq._oldrec (Eq.refl (-f \u226b g = -f \u226b g')) (Eq.symm (comp_neg f g)))\n              (eq.mp (Eq._oldrec (Eq.refl (-f \u226b g = (-f) \u226b g')) (neg_comp f g'))\n                (eq.mp (Eq._oldrec (Eq.refl ((-f) \u226b g = (-f) \u226b 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 \u27f6 Q} [mono f] : mono (-f) :=\n  mono.mk\n    fun (R : C) (g g' : R \u27f6 P) (H : g \u226b (-f) = g' \u226b (-f)) =>\n      eq.mp (Eq._oldrec (Eq.refl (-g = -g')) (propext neg_inj))\n        (eq.mp (Eq._oldrec (Eq.refl ((-g) \u226b f = (-g') \u226b f)) (propext (cancel_mono f)))\n          (eq.mp (Eq._oldrec (Eq.refl ((-g) \u226b f = -g' \u226b f)) (Eq.symm (neg_comp g' f)))\n            (eq.mp (Eq._oldrec (Eq.refl (-g \u226b f = -g' \u226b f)) (Eq.symm (neg_comp g f)))\n              (eq.mp (Eq._oldrec (Eq.refl (-g \u226b f = g' \u226b (-f))) (comp_neg g' f))\n                (eq.mp (Eq._oldrec (Eq.refl (g \u226b (-f) = g' \u226b (-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 \u27f6 R)\n    (h : \u2200 {P : C} (g : P \u27f6 Q), g \u226b f = 0 \u2192 g = 0) : mono f :=\n  mono.mk\n    fun (P : C) (g g' : P \u27f6 Q) (hg : g \u226b f = g' \u226b 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 \u27f6 R) :\n    mono f \u2194 \u2200 (P : C) (g : P \u27f6 Q), g \u226b f = 0 \u2192 g = 0 :=\n  { mp := fun (m : mono f) (P : C) (g : P \u27f6 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 \u27f6 Y}\n    [limits.has_limit (limits.parallel_pair f 0)] (w : limits.kernel.\u03b9 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 \u27f6 Q)\n    (h : \u2200 {R : C} (g : Q \u27f6 R), f \u226b g = 0 \u2192 g = 0) : epi f :=\n  epi.mk\n    fun (R : C) (g g' : Q \u27f6 R) (hg : f \u226b g = f \u226b 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 \u27f6 Q) :\n    epi f \u2194 \u2200 (R : C) (g : Q \u27f6 R), f \u226b g = 0 \u2192 g = 0 :=\n  { mp := fun (e : epi f) (R : C) (g : Q \u27f6 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 \u27f6 Y)\n    [limits.has_colimit (limits.parallel_pair f 0)] (w : limits.cokernel.\u03c0 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Y) (g : X \u27f6 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": "/-\n# Expressions\n\nExpressions (terms of type `Expr`) are an abstract syntax tree for Lean\nprograms. This means that each term which can be written in Lean has a\ncorresponding `Expr`. For example, the application `f e` is represented by the\nexpression `Expr.app \u27e6f\u27e7 \u27e6e\u27e7`, where `\u27e6f\u27e7` is a representation of `f` and `\u27e6e\u27e7`\na representation of `e`. Similarly, the term `Nat` is represented by the\nexpression ``Expr.const `Nat []``. (The backtick and empty list are discussed\nbelow.)\n\nThe ultimate purpose of a Lean tactic block is to generate a term which serves\nas a proof of the theorem we want to prove. Thus, the purpose of a tactic is to\nproduce (part of) an `Expr` of the right type. Much metaprogramming therefore\ncomes down to manipulating expressions: constructing new ones and taking apart\nexisting ones.\n\nOnce a tactic block is finished, the `Expr` is sent to the kernel, which checks\nwhether it is well-typed and whether it really has the type claimed by the\ntheorem. As a result, tactic bugs are not fatal: if you make a mistake, the\nkernel will ultimately catch it. However, many internal Lean functions also\nassume that expressions are well-typed, so you may crash Lean before the\nexpression ever reaches the kernel. To avoid this, Lean provides many functions\nwhich help with the manipulation of expressions. This chapter and the next\nsurvey the most important ones.\n\nLet's get concrete and look at the\n[`Expr`](https://github.com/leanprover/lean4/blob/master/src/Lean/Expr.lean)\ntype:\n-/\n\nimport Lean\n\nnamespace Playground\n\ninductive Expr where\n  | bvar    : Nat \u2192 Expr                              -- bound variables\n  | fvar    : FVarId \u2192 Expr                           -- free variables\n  | mvar    : MVarId \u2192 Expr                           -- meta variables\n  | sort    : Level \u2192 Expr                            -- Sort\n  | const   : Name \u2192 List Level \u2192 Expr                -- constants\n  | app     : Expr \u2192 Expr \u2192 Expr                      -- application\n  | lam     : Name \u2192 Expr \u2192 Expr \u2192 BinderInfo \u2192 Expr  -- lambda abstraction\n  | forallE : Name \u2192 Expr \u2192 Expr \u2192 BinderInfo \u2192 Expr  -- (dependent) arrow\n  | letE    : Name \u2192 Expr \u2192 Expr \u2192 Expr \u2192 Bool \u2192 Expr -- let expressions\n  -- less essential constructors:\n  | lit     : Literal \u2192 Expr                          -- literals\n  | mdata   : MData \u2192 Expr \u2192 Expr                     -- metadata\n  | proj    : Name \u2192 Nat \u2192 Expr \u2192 Expr                -- projection\n\nend Playground\n\n/-! What is each of these constructors doing?\n\n- `bvar` is a __bound variable__. For example, the `x` in `fun x => x + 2` or\n  `\u2211 x, x\u00b2`. This is any occurrence of a variable in an expression where there\n  is a binder above it. Why is the argument a `Nat`? This is called a de Bruijn\n  index and will be explained later. You can figure out the type of a bound\n  variable by looking at its binder, since the binder always has the type\n  information for it.\n- `fvar` is a __free variable__. These are variables which are not bound by a\n  binder. An example is `x` in `x + 2`. Note that you can't just look at a free\n  variable `x` and tell what its type is, there needs to be a context\n  which contains a declaration for `x` and its type. A free variable has an ID\n  that tells you where to look for it in a `LocalContext`. In Lean 3, free\n  variables were called \"local constants\" or \"locals\".\n- `mvar` is a __metavariable__. There will be much more on these later, but you\n  can think of it as a placeholder or a 'hole' in an expression that needs to be\n  filled at a later point.\n- `sort` is used for `Type u`, `Prop` etc.\n- `const` is a constant that has been defined earlier in the Lean document.\n- `app` is a function application. Multiple arguments are done using _partial\n  application_: `f x y \u219d app (app f x) y`.\n- `lam n t b` is a lambda expression (`fun ($n : $t) => $b`). The `b` argument\n  is called the __body__. Note that you have to give the type of the variable\n  you are binding.\n- `forallE n t b` is a dependent arrow expression (`($n : $t) \u2192 $b`). This is\n  also sometimes called a \u03a0-type or \u03a0-expression and is often written `\u2200 $n :\n  $t, $b`. Note that the non-dependent arrow `\u03b1 \u2192 \u03b2` is a special case of `(a :\n  \u03b1) \u2192 \u03b2` where `\u03b2` doesn't depend on `a`. The `E` on the end of `forallE` is to\n  distinguish it from the `forall` keyword.\n- `letE n t v b` is a __let binder__ (`let ($n : $t) := $v in $b`).\n- `lit` is a __literal__, this is a number or string literal like `4` or\n  `\"hello world\"`. Literals help with performance: we don't want to represent\n  the expression `(10000 : Nat)` as `Nat.succ $ ... $ Nat.succ Nat.zero`.\n- `mdata` is just a way of storing extra information on expressions that might\n  be useful, without changing the nature of the expression.\n- `proj` is for projection. Suppose you have a structure such as `p : \u03b1 \u00d7 \u03b2`,\n  rather than storing the projection `\u03c0\u2081 p` as `app \u03c0\u2081 p`, it is expressed as\n  `proj Prod 0 p`. This is for efficiency reasons ([todo] find link to docstring\n  explaining this).\n\nYou've probably noticed that you can write many Lean programs which do not have\nan obvious corresponding `Expr`. For example, what about `match` statements,\n`do` blocks or `by` blocks? These constructs, and many more, must indeed first\nbe translated into expressions. The part of Lean which performs this\n(substantial) task is called the elaborator and is discussed in its own chapter.\nThe benefit of this setup is that once the translation to `Expr` is done, we\nhave a relatively simple structure to work with. (The downside is that going\nback from `Expr` to a high-level Lean program can be challenging.)\n\nThe elaborator also fills in any implicit or typeclass instance arguments which\nyou may have omitted from your Lean program. Thus, at the `Expr` level,\nconstants are always applied to all their arguments, implicit or not. This is\nboth a blessing (because you get a lot of information which is not obvious from\nthe source code) and a curse (because when you build an `Expr`, you must supply\nany implicit or instance arguments yourself).\n\n## De Bruijn Indexes\n\nConsider the following lambda expression `(\u03bb f x => f x x) (\u03bb x y => x + y) 5`,\nwe have to be very careful when we reduce this, because we get a clash in the\nvariable `x`.\n\nTo avoid variable name-clash carnage, `Expr`s use a nifty trick called\n__de Bruijn indexes__. In de Bruijn indexing, each variable bound by a `lam` or\na `forallE` is converted into a number `#n`. The number says how many binders up\nthe `Expr` tree we should look to find the binder which binds this variable.\nSo our above example would become (putting wildcards `_` in the type arguments\nfor now for brevity):\n``app (app (lam `f _ (lam `x _ (app (app #1 #0) #0))) (lam `x _ (lam `y _ (app (app plus #1) #0)))) five``\nNow we don't need to rename variables when we perform \u03b2-reduction. We also\nreally easily check if two `Expr`s containing bound expressions are equal. This\nis why the signature of the `bvar` case is `Nat \u2192 Expr` and not\n`Name \u2192 Expr`.\n\nIf a de Bruijn index is too large for the number of binders preceding it, we say\nit is a __loose `bvar`__; otherwise we say it is __bound__. For example, in the\nexpression ``lam `x _ (app #0 #1)`` the `bvar` `#0` is bound by the preceding\nbinder and `#1` is loose. The fact that Lean calls all de Bruijn indexes `bvar`s\n(\"bound variables\") points to an important invariant: outside of some very\nlow-level functions, Lean expects that expressions do not contain any loose\n`bvar`s. Instead, whenever we would be tempted to introduce a loose `bvar`, we\nimmediately convert it into an `fvar` (\"free variable\"). Precisely how that\nworks is discussed in the next chapter.\n\nIf there are no loose `bvar`s in an expression, we say that the expression is\n__closed__. The process of replacing all instances of a loose `bvar` with an\n`Expr` is called __instantiation__. Going the other way is called\n__abstraction__.\n\nIf you are familiar with the standard terminology around variables, Lean's\nterminology may be confusing, so here's a map: Lean's \"bvars\" are usually called\njust \"variables\"; Lean's \"loose\" is usually called \"free\"; and Lean's \"fvars\"\nmight be called \"local hypotheses\".\n\n## Universe Levels\n\nSome expressions involve universe levels, represented by the `Lean.Level` type.\nA universe level is a natural number, a universe parameter (introduced with a\n`universe` declaration), a universe metavariable or the maximum of two\nuniverses. They are relevant for two kinds of expressions.\n\nFirst, sorts are represented by `Expr.sort u`, where `u` is a `Level`. `Prop` is\n`sort Level.zero`; `Type` is `sort (Level.succ Level.zero)`.\n\nSecond, universe-polymorphic constants have universe arguments. A\nuniverse-polymorphic constant is one whose type contains universe parameters.\nFor example, the `List.map` function is universe-polymorphic, as the\n`pp.universes` pretty-printing option shows: -/\n\nset_option pp.universes true in\n#check @List.map\n\n/-!\nThe `.{u_1,u_2}` suffix after `List.map` means that `List.map` has two universe\narguments, `u_1` and `u_2`. The `.{u_1}` suffix after `List` (which is itself a\nuniverse-polymorphic constant) means that `List` is applied to the universe\nargument `u_1`, and similar for `.{u_2}`.\n\nIn fact, whenever you use a universe-polymorphic constant, you must apply it to\nthe correct universe arguments. This application is represented by the `List\nLevel` argument of `Expr.const`. When we write regular Lean code, Lean infers\nthe universes automatically, so we do not need think about them much. But when\nwe construct `Expr`s, we must be careful to apply each universe-polymorphic\nconstant to the right universe arguments.\n\n## Constructing Expressions\n\nThe simplest expressions we can construct are constants. We use the `const`\nconstructor and give it a name and a list of universe levels. Most of our\nexamples only involve non-universe-polymorphic constants, in which case the list\nis empty.\n\nWe also show a second form where we write the name with double backticks. This\nchecks that the name in fact refers to a defined constant, which is useful to\navoid typos. -/\n\nopen Lean\n\ndef z' := Expr.const `Nat.zero []\n#eval z' -- Lean.Expr.const `Nat.zero []\n\ndef z := Expr.const ``Nat.zero []\n#eval z -- Lean.Expr.const `Nat.zero []\n\n/- The double-backtick variant also resolves the given name, making it\nfully-qualified. To illustrate this mechanism, here are two further examples.\nThe first expression, `z\u2081`, is unsafe: if we use it in a context where the `Nat`\nnamespace is not open, Lean will complain that there is no constant called\n`zero` in the environment. In contrast, the second expression, `z\u2082`, contains\nthe fully-qualified name `Nat.zero` and does not have this problem. -/\n\nopen Nat\n\ndef z\u2081 := Expr.const `zero []\n#eval z\u2081 -- Lean.Expr.const `zero []\n\ndef z\u2082 := Expr.const ``zero []\n#eval z\u2082 -- Lean.Expr.const `Nat.zero []\n\n/- The next class of expressions we consider are function applications. These\ncan be built using the `app` constructor, with the first argument being an\nexpression for the function and the second being an expression for the argument.\n\nHere are two examples. The first is simply a constant applied to another. The\nsecond is a recursive definition giving an expression as a function of a natural\nnumber. -/\n\ndef one := Expr.app (.const ``Nat.succ []) z\n#eval one\n-- Lean.Expr.app (Lean.Expr.const `Nat.succ []) (Lean.Expr.const `Nat.zero [])\n\ndef natExpr: Nat \u2192 Expr \n| 0     => z\n| n + 1 => .app (.const ``Nat.succ []) (natExpr n)\n\n/-  Next we use the variant `mkAppN` which allows application with multiple\narguments. -/\n\ndef sumExpr : Nat \u2192 Nat \u2192 Expr \n| n, m => mkAppN (.const ``Nat.add []) #[natExpr n, natExpr m]\n\n/- As you may have noticed, we didn't show `#eval` outputs for the two last\nfunctions. That's because the resulting expressions can grow so large that it's\nhard to make sense of them.\n\nWe next use the constructor `lam` to construct a simple function which takes any\nnatural number `x` and returns `Nat.zero`. The argument `BinderInfo.default`\nsays that `x` is an explicit argument (rather than an implicit or typeclass\nargument). -/\n\ndef constZero : Expr := \n  .lam `x (.const ``Nat []) (.const ``Nat.zero []) BinderInfo.default\n\n#eval constZero\n-- Lean.Expr.lam `x (Lean.Expr.const `Nat []) (Lean.Expr.const `Nat.zero [])\n--   (Lean.BinderInfo.default)\n\n/-! As a more elaborate example which also involves universe levels, here is the\n`Expr` that represents `List.map (\u03bb x => Nat.add x 1) []` (broken up into\nseveral definitions to make it somewhat readable): -/\n\ndef nat : Expr := .const ``Nat []\n\ndef addOne : Expr :=\n  .lam `x nat\n    (mkAppN (.const ``Nat.add []) #[.bvar 0, mkNatLit 1])\n    BinderInfo.default\n\ndef mapAddOneNil : Expr :=\n  mkAppN (.const ``List.map [levelOne, levelOne])\n    #[nat, nat, addOne, .app (.const ``List.nil [levelOne]) nat]\n\n/-! With a little trick (more about which in the Elaboration chapter), we can\nturn our `Expr` into a Lean term, which allows us to inspect it more easily. -/\n\nelab \"mapAddOneNil\" : term => return mapAddOneNil\n\n#check mapAddOneNil\n-- List.map (fun x => Nat.add x 1) [] : List Nat\n\nset_option pp.universes true in\nset_option pp.explicit true in\n#check mapAddOneNil\n-- @List.map.{1, 1} Nat Nat (fun x => Nat.add x 1) (@List.nil.{1} Nat) : List.{1} Nat\n\n#reduce mapAddOneNil\n-- []\n\n/- In the next chapter we explore the `MetaM` monad, which, among many other\nthings, allows us to more conveniently construct and destruct larger\nexpressions.\n\n## Exercises\n\n1. Create expression `1 + 2` with `Expr.app`.\n2. Create expression `1 + 2` with `Lean.mkAppN`.\n3. Create expression `fun x => 1 + x`.\n4. [**De Bruijn Indexes**] Create expression `fun a, fun b, fun c, (b * a) + c`.\n5. Create expression `fun x y => x + y`.\n6. Create expression `fun x, String.append \"hello, \" x`.\n7. Create expression `\u2200 x : Prop, x \u2227 x`.\n8. Create expression `Nat \u2192 String`.\n9. Create expression `fun (p : Prop) => (\u03bb hP : p => hP)`.\n10. [**Universe levels**] Create expression `Type 6`.\n-/\n", "meta": {"author": "leanprover-community", "repo": "lean4-metaprogramming-book", "sha": "0b2e7e2c0cacac530ed947df878088c5d9715412", "save_path": "github-repos/lean/leanprover-community-lean4-metaprogramming-book", "path": "github-repos/lean/leanprover-community-lean4-metaprogramming-book/lean4-metaprogramming-book-0b2e7e2c0cacac530ed947df878088c5d9715412/lean/main/expressions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6654105454764747, "lm_q2_score": 0.6992544210587585, "lm_q1q2_score": 0.465291265743545}}
{"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 {\u03b1 : Type _}\n\nsection CanonicallyLinearOrderedSemifield\n\nvariable [CanonicallyLinearOrderedSemifield \u03b1] [Sub \u03b1] [OrderedSub \u03b1]\n\n/- warning: tsub_div -> tsub_div is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedSemifield.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedCancelAddCommMonoid.toPartialOrder.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))))) (Distrib.toHasAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))) _inst_2] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 _inst_2) a b) c) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 _inst_2) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (GroupWithZero.toDivInvMonoid.{u1} \u03b1 (DivisionSemiring.toGroupWithZero.{u1} \u03b1 (Semifield.toDivisionSemiring.{u1} \u03b1 (LinearOrderedSemifield.toSemifield.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) b c))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CanonicallyLinearOrderedSemifield.{u1} \u03b1] [_inst_2 : Sub.{u1} \u03b1] [_inst_3 : OrderedSub.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedSemiring.toPartialOrder.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))) (Distrib.toAdd.{u1} \u03b1 (NonUnitalNonAssocSemiring.toDistrib.{u1} \u03b1 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b1 (Semiring.toNonAssocSemiring.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))) _inst_2] (a : \u03b1) (b : \u03b1) (c : \u03b1), Eq.{succ u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 _inst_2) a b) c) (HSub.hSub.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHSub.{u1} \u03b1 _inst_2) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) a c) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (CanonicallyLinearOrderedSemifield.toDiv.{u1} \u03b1 _inst_1)) b c))\nCase conversion may be inaccurate. Consider using '#align tsub_div tsub_div\u2093'. -/\ntheorem tsub_div (a b c : \u03b1) : (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 `(\u2022) 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 `\u03bb x, c +\u1d65 x` is uniformly continuous. -/\nclass has_uniform_continuous_const_vadd [uniform_space X] [has_vadd M X] : Prop :=\n(uniform_continuous_const_vadd : \u2200 (c : M), uniform_continuous ((+\u1d65) c : X \u2192 X))\n\n/-- A multiplicative action such that for all `c`, the map `\u03bb x, c \u2022 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 : \u2200 (c : M), uniform_continuous ((\u2022) c : X \u2192 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 \u2115 X :=\n\u27e8uniform_continuous_const_nsmul\u27e9\n\ninstance add_group.has_uniform_continuous_const_smul_int [add_group X] [uniform_add_group X] :\n  has_uniform_continuous_const_smul \u2124 X :=\n\u27e8uniform_continuous_const_zsmul\u27e9\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\u27e8\u03bb c, (uniform_continuous_const_smul c).continuous\u27e9\n\nvariables {M X Y}\n\n@[to_additive] lemma uniform_continuous.const_smul [has_uniform_continuous_const_smul M X]\n  {f : Y \u2192 X} (hf : uniform_continuous f) (c : M) :\n  uniform_continuous (c \u2022 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\u1d50\u1d52\u1d56 X] [is_central_scalar M X]\n  [has_uniform_continuous_const_smul M X] : has_uniform_continuous_const_smul M\u1d50\u1d52\u1d56 X :=\n\u27e8mul_opposite.rec $ \u03bb c, begin\n  change uniform_continuous (\u03bb m, mul_opposite.op c \u2022 m),\n  simp_rw op_smul_eq_smul,\n  exact uniform_continuous_const_smul c,\nend\u27e9\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\u1d50\u1d52\u1d56 :=\n\u27e8\u03bb c, mul_opposite.uniform_continuous_op.comp $ mul_opposite.uniform_continuous_unop.const_smul c\u27e9\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\u27e8\u03bb c, uniform_continuous_const.mul uniform_continuous_id\u27e9\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\u27e8\u03bb c, completion.map ((\u2022) c)\u27e9\n\n@[to_additive] instance : has_uniform_continuous_const_smul M (completion X) :=\n\u27e8\u03bb c, uniform_continuous_map\u27e9\n\ninstance [has_scalar M\u1d50\u1d52\u1d56 X] [is_central_scalar M X] : is_central_scalar M (completion X) :=\n\u27e8\u03bb c a, congr_arg (\u03bb f, completion.map f a) $ by exact funext (op_smul_eq_smul c)\u27e9\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 := (\u2022),\n  one_smul := ext' (continuous_const_smul _) continuous_id $ \u03bb a, by rw [\u2190 coe_smul, one_smul],\n  mul_smul := \u03bb x y, ext' (continuous_const_smul _) ((continuous_const_smul _).const_smul _) $\n    \u03bb a, by simp only [\u2190 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 (\u00b7.append <| char \u00b7 |> (\u00b7.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 -> \u00ac (a < b) -> b * 2 - 1 - a < b := by \n    intros u p q\n    rw [<-Nat.sub_add_eq] \n    have p\u2082: b = b * 2 - b := by \n      rw [Nat.mul_add b 1 1]\n      simp\n    conv => rhs; rw [p\u2082]\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 \u27e8 r', p \u27e9\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\u2082\n                rw [Nat.le_zero] at p\u2082\n                have bq: base' = base * 2 + 1 := Eq.refl _\n                conv at bq =>\n                  rw [p\u2082]\n                  rhs\n                  simp\n                have rp: r = x % base' := Eq.refl _\n                have rp\u2082 : x % base' < 1 := by \n                  rw [<-bq]\n                  apply Nat.mod_lt\n                  apply Nat.zero_lt_of_ne_zero\n                  simp\n                rw [\u2190rp, q] at rp\u2082\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 \u2218 Array.toList \u2218 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 <| \u03bb (x: SNAFU) => \u2191x\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 : \u2115 \u2192 \u211d} : (\u2203 (r : \u211d),\n    filter.tendsto (fun (n : \u2115) => finset.sum (finset.range n) fun (i : \u2115) => abs (f i)) filter.at_top (nhds r)) \u2192\n  summable f := sorry\n\ntheorem tendsto_inverse_at_top_nhds_0_nat : filter.tendsto (fun (n : \u2115) => \u2191n\u207b\u00b9) 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 : \u211d) : filter.tendsto (fun (n : \u2115) => C / \u2191n) filter.at_top (nhds 0) := sorry\n\ntheorem nnreal.tendsto_inverse_at_top_nhds_0_nat : filter.tendsto (fun (n : \u2115) => \u2191n\u207b\u00b9) filter.at_top (nhds 0) := sorry\n\ntheorem nnreal.tendsto_const_div_at_top_nhds_0_nat (C : nnreal) : filter.tendsto (fun (n : \u2115) => C / \u2191n) filter.at_top (nhds 0) := sorry\n\ntheorem tendsto_one_div_add_at_top_nhds_0_nat : filter.tendsto (fun (n : \u2115) => 1 / (\u2191n + 1)) filter.at_top (nhds 0) := sorry\n\n/-! ### Powers -/\n\ntheorem tendsto_add_one_pow_at_top_at_top_of_pos {\u03b1 : Type u_1} [linear_ordered_semiring \u03b1] [archimedean \u03b1] {r : \u03b1} (h : 0 < r) : filter.tendsto (fun (n : \u2115) => (r + 1) ^ n) filter.at_top filter.at_top :=\n  filter.tendsto_at_top_at_top_of_monotone' (fun (n m : \u2115) => pow_le_pow (le_add_of_nonneg_left (le_of_lt h)))\n    (iff.mpr not_bdd_above_iff fun (x : \u03b1) => 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 {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [archimedean \u03b1] {r : \u03b1} (h : 1 < r) : filter.tendsto (fun (n : \u2115) => r ^ n) filter.at_top filter.at_top :=\n  sub_add_cancel r 1 \u25b8 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 : \u2115} (h : 1 < m) : filter.tendsto (fun (n : \u2115) => m ^ n) filter.at_top filter.at_top :=\n  nat.sub_add_cancel (le_of_lt h) \u25b8 tendsto_add_one_pow_at_top_at_top_of_pos (nat.sub_pos_of_lt h)\n\ntheorem tendsto_norm_zero' {\ud835\udd5c : Type u_1} [normed_group \ud835\udd5c] : filter.tendsto norm (nhds_within 0 (set_of fun (x : \ud835\udd5c) => x \u2260 0)) (nhds_within 0 (set.Ioi 0)) :=\n  filter.tendsto.inf tendsto_norm_zero\n    (iff.mpr filter.tendsto_principal_principal\n      fun (x : \ud835\udd5c) (hx : x \u2208 set_of fun (x : \ud835\udd5c) => x \u2260 0) => iff.mpr norm_pos_iff hx)\n\ntheorem normed_field.tendsto_norm_inverse_nhds_within_0_at_top {\ud835\udd5c : Type u_1} [normed_field \ud835\udd5c] : filter.tendsto (fun (x : \ud835\udd5c) => norm (x\u207b\u00b9)) (nhds_within 0 (set_of fun (x : \ud835\udd5c) => x \u2260 0)) filter.at_top :=\n  filter.tendsto.congr (fun (x : \ud835\udd5c) => 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 {\ud835\udd5c : Type u_1} [linear_ordered_field \ud835\udd5c] [archimedean \ud835\udd5c] [topological_space \ud835\udd5c] [order_topology \ud835\udd5c] {r : \ud835\udd5c} (h\u2081 : 0 \u2264 r) (h\u2082 : r < 1) : filter.tendsto (fun (n : \u2115) => r ^ n) filter.at_top (nhds 0) := sorry\n\ntheorem tendsto_pow_at_top_nhds_within_0_of_lt_1 {\ud835\udd5c : Type u_1} [linear_ordered_field \ud835\udd5c] [archimedean \ud835\udd5c] [topological_space \ud835\udd5c] [order_topology \ud835\udd5c] {r : \ud835\udd5c} (h\u2081 : 0 < r) (h\u2082 : r < 1) : filter.tendsto (fun (n : \u2115) => 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\u2081) h\u2082,\n      right := iff.mpr filter.tendsto_principal (filter.eventually_of_forall fun (n : \u2115) => pow_pos h\u2081 n) }\n\ntheorem is_o_pow_pow_of_lt_left {r\u2081 : \u211d} {r\u2082 : \u211d} (h\u2081 : 0 \u2264 r\u2081) (h\u2082 : r\u2081 < r\u2082) : asymptotics.is_o (fun (n : \u2115) => r\u2081 ^ n) (fun (n : \u2115) => r\u2082 ^ n) filter.at_top := sorry\n\ntheorem is_O_pow_pow_of_le_left {r\u2081 : \u211d} {r\u2082 : \u211d} (h\u2081 : 0 \u2264 r\u2081) (h\u2082 : r\u2081 \u2264 r\u2082) : asymptotics.is_O (fun (n : \u2115) => r\u2081 ^ n) (fun (n : \u2115) => r\u2082 ^ n) filter.at_top :=\n  or.elim (has_le.le.eq_or_lt h\u2082) (fun (h : r\u2081 = r\u2082) => h \u25b8 asymptotics.is_O_refl (fun (n : \u2115) => r\u2081 ^ n) filter.at_top)\n    fun (h : r\u2081 < r\u2082) => asymptotics.is_o.is_O (is_o_pow_pow_of_lt_left h\u2081 h)\n\ntheorem is_o_pow_pow_of_abs_lt_left {r\u2081 : \u211d} {r\u2082 : \u211d} (h : abs r\u2081 < abs r\u2082) : asymptotics.is_o (fun (n : \u2115) => r\u2081 ^ n) (fun (n : \u2115) => r\u2082 ^ 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\u2081) (pow_abs r\u2082) (is_o_pow_pow_of_lt_left (abs_nonneg r\u2081) 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| \u2264 Ca^n$\n     for all `n`;\n* 5: there exists `0 < a < R` and a positive `C` such that $|f n| \u2264 Ca^n$ for all `n`;\n* 6: there exists `a < R` such that $|f n| \u2264 a ^ n$ for sufficiently large `n`;\n* 7: there exists `0 < a < R` such that $|f n| \u2264 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 : \u2115 \u2192 \u211d) (R : \u211d) : tfae\n  [\u2203 (a : \u211d), \u2203 (H : a \u2208 set.Ioo (-R) R), asymptotics.is_o f (pow a) filter.at_top,\n    \u2203 (a : \u211d), \u2203 (H : a \u2208 set.Ioo 0 R), asymptotics.is_o f (pow a) filter.at_top,\n    \u2203 (a : \u211d), \u2203 (H : a \u2208 set.Ioo (-R) R), asymptotics.is_O f (pow a) filter.at_top,\n    \u2203 (a : \u211d), \u2203 (H : a \u2208 set.Ioo 0 R), asymptotics.is_O f (pow a) filter.at_top,\n    \u2203 (a : \u211d), \u2203 (H : a < R), \u2203 (C : \u211d), \u2203 (h\u2080 : 0 < C \u2228 0 < R), \u2200 (n : \u2115), abs (f n) \u2264 C * a ^ n,\n    \u2203 (a : \u211d), \u2203 (H : a \u2208 set.Ioo 0 R), \u2203 (C : \u211d), \u2203 (H : C > 0), \u2200 (n : \u2115), abs (f n) \u2264 C * a ^ n,\n    \u2203 (a : \u211d), \u2203 (H : a < R), filter.eventually (fun (n : \u2115) => abs (f n) \u2264 a ^ n) filter.at_top,\n    \u2203 (a : \u211d), \u2203 (H : a \u2208 set.Ioo 0 R), filter.eventually (fun (n : \u2115) => abs (f n) \u2264 a ^ n) filter.at_top] := sorry\n\ntheorem uniformity_basis_dist_pow_of_lt_1 {\u03b1 : Type u_1} [metric_space \u03b1] {r : \u211d} (h\u2080 : 0 < r) (h\u2081 : r < 1) : filter.has_basis (uniformity \u03b1) (fun (k : \u2115) => True)\n  fun (k : \u2115) => set_of fun (p : \u03b1 \u00d7 \u03b1) => dist (prod.fst p) (prod.snd p) < r ^ k :=\n  metric.mk_uniformity_basis (fun (i : \u2115) (_x : True) => pow_pos h\u2080 i)\n    fun (\u03b5 : \u211d) (\u03b50 : 0 < \u03b5) =>\n      Exists.imp (fun (k : \u2115) (hk : r ^ k < \u03b5) => Exists.intro trivial (has_lt.lt.le hk)) (exists_pow_lt_of_lt_one \u03b50 h\u2081)\n\ntheorem geom_lt {u : \u2115 \u2192 \u211d} {c : \u211d} (hc : 0 \u2264 c) {n : \u2115} (hn : 0 < n) (h : \u2200 (k : \u2115), k < n \u2192 c * u k < u (k + 1)) : c ^ n * u 0 < u n := sorry\n\ntheorem geom_le {u : \u2115 \u2192 \u211d} {c : \u211d} (hc : 0 \u2264 c) (n : \u2115) (h : \u2200 (k : \u2115), k < n \u2192 c * u k \u2264 u (k + 1)) : c ^ n * u 0 \u2264 u n := sorry\n\n/-- For any natural `k` and a real `r > 1` we have `n ^ k = o(r ^ n)` as `n \u2192 \u221e`. -/\ntheorem is_o_pow_const_const_pow_of_one_lt {R : Type u_1} [normed_ring R] (k : \u2115) {r : \u211d} (hr : 1 < r) : asymptotics.is_o (fun (n : \u2115) => \u2191n ^ k) (fun (n : \u2115) => r ^ n) filter.at_top := sorry\n\n/-- For a real `r > 1` we have `n = o(r ^ n)` as `n \u2192 \u221e`. -/\ntheorem is_o_coe_const_pow_of_one_lt {R : Type u_1} [normed_ring R] {r : \u211d} (hr : 1 < r) : asymptotics.is_o coe (fun (n : \u2115) => r ^ n) filter.at_top := sorry\n\n/-- If `\u2225r\u2081\u2225 < r\u2082`, then for any naturak `k` we have `n ^ k r\u2081 ^ n = o (r\u2082 ^ n)` as `n \u2192 \u221e`. -/\ntheorem is_o_pow_const_mul_const_pow_const_pow_of_norm_lt {R : Type u_1} [normed_ring R] (k : \u2115) {r\u2081 : R} {r\u2082 : \u211d} (h : norm r\u2081 < r\u2082) : asymptotics.is_o (fun (n : \u2115) => \u2191n ^ k * r\u2081 ^ n) (fun (n : \u2115) => r\u2082 ^ n) filter.at_top := sorry\n\ntheorem tendsto_pow_const_div_const_pow_of_one_lt (k : \u2115) {r : \u211d} (hr : 1 < r) : filter.tendsto (fun (n : \u2115) => \u2191n ^ 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 : \u2115) {r : \u211d} (hr : abs r < 1) : filter.tendsto (fun (n : \u2115) => \u2191n ^ k * r ^ n) filter.at_top (nhds 0) := sorry\n\n/-- If a sequence `v` of real numbers satisfies `k * v n \u2264 v (n+1)` with `1 < k`,\nthen it goes to +\u221e. -/\ntheorem tendsto_at_top_of_geom_le {v : \u2115 \u2192 \u211d} {c : \u211d} (h\u2080 : 0 < v 0) (hc : 1 < c) (hu : \u2200 (n : \u2115), c * v n \u2264 v (n + 1)) : filter.tendsto v filter.at_top filter.at_top :=\n  filter.tendsto_at_top_mono\n    (fun (n : \u2115) => geom_le (has_le.le.trans zero_le_one (has_lt.lt.le hc)) n fun (k : \u2115) (hk : k < n) => hu k)\n    (filter.tendsto.at_top_mul_const h\u2080 (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 : \u2115) => 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 : \u2115) => r ^ n) filter.at_top (nhds 0) := sorry\n\n/-- In a normed ring, the powers of an element x with `\u2225x\u2225 < 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 : \u2115) => 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 : \u211d} (h : abs r < 1) : filter.tendsto (fun (n : \u2115) => 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 : \u211d} (h\u2081 : 0 \u2264 r) (h\u2082 : r < 1) : has_sum (fun (n : \u2115) => r ^ n) (1 - r\u207b\u00b9) := sorry\n\ntheorem summable_geometric_of_lt_1 {r : \u211d} (h\u2081 : 0 \u2264 r) (h\u2082 : r < 1) : summable fun (n : \u2115) => r ^ n :=\n  Exists.intro (1 - r\u207b\u00b9) (has_sum_geometric_of_lt_1 h\u2081 h\u2082)\n\ntheorem tsum_geometric_of_lt_1 {r : \u211d} (h\u2081 : 0 \u2264 r) (h\u2082 : r < 1) : (tsum fun (n : \u2115) => r ^ n) = (1 - r\u207b\u00b9) :=\n  has_sum.tsum_eq (has_sum_geometric_of_lt_1 h\u2081 h\u2082)\n\ntheorem has_sum_geometric_two : has_sum (fun (n : \u2115) => (1 / bit0 1) ^ n) (bit0 1) := sorry\n\ntheorem summable_geometric_two : summable fun (n : \u2115) => (1 / bit0 1) ^ n :=\n  Exists.intro (bit0 1) has_sum_geometric_two\n\ntheorem tsum_geometric_two : (tsum fun (n : \u2115) => (1 / bit0 1) ^ n) = bit0 1 :=\n  has_sum.tsum_eq has_sum_geometric_two\n\ntheorem sum_geometric_two_le (n : \u2115) : (finset.sum (finset.range n) fun (i : \u2115) => (1 / bit0 1) ^ i) \u2264 bit0 1 := sorry\n\ntheorem has_sum_geometric_two' (a : \u211d) : has_sum (fun (n : \u2115) => a / bit0 1 / bit0 1 ^ n) a := sorry\n\ntheorem summable_geometric_two' (a : \u211d) : summable fun (n : \u2115) => a / bit0 1 / bit0 1 ^ n :=\n  Exists.intro a (has_sum_geometric_two' a)\n\ntheorem tsum_geometric_two' (a : \u211d) : (tsum fun (n : \u2115) => 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 : \u2115) => r ^ n) (1 - r\u207b\u00b9) := sorry\n\ntheorem nnreal.summable_geometric {r : nnreal} (hr : r < 1) : summable fun (n : \u2115) => r ^ n :=\n  Exists.intro (1 - r\u207b\u00b9) (nnreal.has_sum_geometric hr)\n\ntheorem tsum_geometric_nnreal {r : nnreal} (hr : r < 1) : (tsum fun (n : \u2115) => r ^ n) = (1 - r\u207b\u00b9) :=\n  has_sum.tsum_eq (nnreal.has_sum_geometric hr)\n\n/-- The series `pow r` converges to `(1-r)\u207b\u00b9`. For `r < 1` the RHS is a finite number,\nand for `1 \u2264 r` the RHS equals `\u221e`. -/\ntheorem ennreal.tsum_geometric (r : ennreal) : (tsum fun (n : \u2115) => r ^ n) = (1 - r\u207b\u00b9) := sorry\n\ntheorem has_sum_geometric_of_norm_lt_1 {K : Type u_4} [normed_field K] {\u03be : K} (h : norm \u03be < 1) : has_sum (fun (n : \u2115) => \u03be ^ n) (1 - \u03be\u207b\u00b9) := sorry\n\ntheorem summable_geometric_of_norm_lt_1 {K : Type u_4} [normed_field K] {\u03be : K} (h : norm \u03be < 1) : summable fun (n : \u2115) => \u03be ^ n :=\n  Exists.intro (1 - \u03be\u207b\u00b9) (has_sum_geometric_of_norm_lt_1 h)\n\ntheorem tsum_geometric_of_norm_lt_1 {K : Type u_4} [normed_field K] {\u03be : K} (h : norm \u03be < 1) : (tsum fun (n : \u2115) => \u03be ^ n) = (1 - \u03be\u207b\u00b9) :=\n  has_sum.tsum_eq (has_sum_geometric_of_norm_lt_1 h)\n\ntheorem has_sum_geometric_of_abs_lt_1 {r : \u211d} (h : abs r < 1) : has_sum (fun (n : \u2115) => r ^ n) (1 - r\u207b\u00b9) :=\n  has_sum_geometric_of_norm_lt_1 h\n\ntheorem summable_geometric_of_abs_lt_1 {r : \u211d} (h : abs r < 1) : summable fun (n : \u2115) => r ^ n :=\n  summable_geometric_of_norm_lt_1 h\n\ntheorem tsum_geometric_of_abs_lt_1 {r : \u211d} (h : abs r < 1) : (tsum fun (n : \u2115) => r ^ n) = (1 - r\u207b\u00b9) :=\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] {\u03be : K} : (summable fun (n : \u2115) => \u03be ^ n) \u2194 norm \u03be < 1 := sorry\n\ntheorem summable_norm_pow_mul_geometric_of_norm_lt_1 {R : Type u_1} [normed_ring R] (k : \u2115) {r : R} (hr : norm r < 1) : summable fun (n : \u2115) => norm (\u2191n ^ 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 : \u2115) {r : R} (hr : norm r < 1) : summable fun (n : \u2115) => \u2191n ^ k * r ^ n :=\n  summable_of_summable_norm (summable_norm_pow_mul_geometric_of_norm_lt_1 k hr)\n\n/-- If `\u2225r\u2225 < 1`, then `\u2211' n : \u2115, n * r ^ n = r / (1 - r) ^ 2`, `has_sum` version. -/\ntheorem has_sum_coe_mul_geometric_of_norm_lt_1 {\ud835\udd5c : Type u_1} [normed_field \ud835\udd5c] [complete_space \ud835\udd5c] {r : \ud835\udd5c} (hr : norm r < 1) : has_sum (fun (n : \u2115) => \u2191n * r ^ n) (r / (1 - r) ^ bit0 1) := sorry\n\n/-- If `\u2225r\u2225 < 1`, then `\u2211' n : \u2115, n * r ^ n = r / (1 - r) ^ 2`. -/\ntheorem tsum_coe_mul_geometric_of_norm_lt_1 {\ud835\udd5c : Type u_1} [normed_field \ud835\udd5c] [complete_space \ud835\udd5c] {r : \ud835\udd5c} (hr : norm r < 1) : (tsum fun (n : \u2115) => \u2191n * 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 \u2260 \u221e`, `r < 1`,\nthen `f` is a Cauchy sequence.-/\ntheorem cauchy_seq_of_edist_le_geometric {\u03b1 : Type u_1} [emetric_space \u03b1] (r : ennreal) (C : ennreal) (hr : r < 1) (hC : C \u2260 \u22a4) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), edist (f n) (f (n + 1)) \u2264 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 {\u03b1 : Type u_1} [emetric_space \u03b1] (r : ennreal) (C : ennreal) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), edist (f n) (f (n + 1)) \u2264 C * r ^ n) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) (n : \u2115) : edist (f n) a \u2264 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\u2080 {\u03b1 : Type u_1} [emetric_space \u03b1] (r : ennreal) (C : ennreal) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), edist (f n) (f (n + 1)) \u2264 C * r ^ n) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) : edist (f 0) a \u2264 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 {\u03b1 : Type u_1} [emetric_space \u03b1] (C : ennreal) (hC : C \u2260 \u22a4) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), edist (f n) (f (n + 1)) \u2264 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 {\u03b1 : Type u_1} [emetric_space \u03b1] (C : ennreal) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), edist (f n) (f (n + 1)) \u2264 C / bit0 1 ^ n) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) (n : \u2115) : edist (f n) a \u2264 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\u2080 {\u03b1 : Type u_1} [emetric_space \u03b1] (C : ennreal) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), edist (f n) (f (n + 1)) \u2264 C / bit0 1 ^ n) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) : edist (f 0) a \u2264 bit0 1 * C := sorry\n\ntheorem aux_has_sum_of_le_geometric {\u03b1 : Type u_1} [metric_space \u03b1] {r : \u211d} {C : \u211d} (hr : r < 1) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), dist (f n) (f (n + 1)) \u2264 C * r ^ n) : has_sum (fun (n : \u2115) => 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 \u2264 C` or `0 \u2264 r`. -/\ntheorem cauchy_seq_of_le_geometric {\u03b1 : Type u_1} [metric_space \u03b1] (r : \u211d) (C : \u211d) (hr : r < 1) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), dist (f n) (f (n + 1)) \u2264 C * r ^ n) : cauchy_seq f :=\n  cauchy_seq_of_dist_le_of_summable (fun (n : \u2115) => 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\u2080 {\u03b1 : Type u_1} [metric_space \u03b1] (r : \u211d) (C : \u211d) (hr : r < 1) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), dist (f n) (f (n + 1)) \u2264 C * r ^ n) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) : dist (f 0) a \u2264 C / (1 - r) :=\n  has_sum.tsum_eq (aux_has_sum_of_le_geometric hr hu) \u25b8\n    dist_le_tsum_of_dist_le_of_tendsto\u2080 (fun (b : \u2115) => 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 {\u03b1 : Type u_1} [metric_space \u03b1] (r : \u211d) (C : \u211d) (hr : r < 1) {f : \u2115 \u2192 \u03b1} (hu : \u2200 (n : \u2115), dist (f n) (f (n + 1)) \u2264 C * r ^ n) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) (n : \u2115) : dist (f n) a \u2264 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 {\u03b1 : Type u_1} [metric_space \u03b1] (C : \u211d) {f : \u2115 \u2192 \u03b1} (hu\u2082 : \u2200 (n : \u2115), dist (f n) (f (n + 1)) \u2264 C / bit0 1 / bit0 1 ^ n) : cauchy_seq f :=\n  cauchy_seq_of_dist_le_of_summable (fun (n : \u2115) => C / bit0 1 / bit0 1 ^ n) hu\u2082\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\u2080 {\u03b1 : Type u_1} [metric_space \u03b1] (C : \u211d) {f : \u2115 \u2192 \u03b1} (hu\u2082 : \u2200 (n : \u2115), dist (f n) (f (n + 1)) \u2264 C / bit0 1 / bit0 1 ^ n) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) : dist (f 0) a \u2264 C :=\n  tsum_geometric_two' C \u25b8\n    dist_le_tsum_of_dist_le_of_tendsto\u2080 (fun (n : \u2115) => C / bit0 1 / bit0 1 ^ n) hu\u2082 (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 {\u03b1 : Type u_1} [metric_space \u03b1] (C : \u211d) {f : \u2115 \u2192 \u03b1} (hu\u2082 : \u2200 (n : \u2115), dist (f n) (f (n + 1)) \u2264 C / bit0 1 / bit0 1 ^ n) {a : \u03b1} (ha : filter.tendsto f filter.at_top (nhds a)) (n : \u2115) : dist (f n) a \u2264 C / bit0 1 ^ n := sorry\n\ntheorem dist_partial_sum_le_of_le_geometric {\u03b1 : Type u_1} [normed_group \u03b1] {r : \u211d} {C : \u211d} {f : \u2115 \u2192 \u03b1} (hf : \u2200 (n : \u2115), norm (f n) \u2264 C * r ^ n) (n : \u2115) : dist (finset.sum (finset.range n) fun (i : \u2115) => f i) (finset.sum (finset.range (n + 1)) fun (i : \u2115) => f i) \u2264 C * r ^ n := sorry\n\n/-- If `\u2225f n\u2225 \u2264 C * r ^ n` for all `n : \u2115` and some `r < 1`, then the partial sums of `f` form a\nCauchy sequence. This lemma does not assume `0 \u2264 r` or `0 \u2264 C`. -/\ntheorem cauchy_seq_finset_of_geometric_bound {\u03b1 : Type u_1} [normed_group \u03b1] {r : \u211d} {C : \u211d} {f : \u2115 \u2192 \u03b1} (hr : r < 1) (hf : \u2200 (n : \u2115), norm (f n) \u2264 C * r ^ n) : cauchy_seq fun (s : finset \u2115) => finset.sum s fun (x : \u2115) => f x :=\n  cauchy_seq_finset_of_norm_bounded (fun (n : \u2115) => 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 `\u2225f n\u2225 \u2264 C * r ^ n` for all `n : \u2115` 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 \u2264 r` or\n`0 \u2264 C`. -/\ntheorem norm_sub_le_of_geometric_bound_of_has_sum {\u03b1 : Type u_1} [normed_group \u03b1] {r : \u211d} {C : \u211d} {f : \u2115 \u2192 \u03b1} (hr : r < 1) (hf : \u2200 (n : \u2115), norm (f n) \u2264 C * r ^ n) {a : \u03b1} (ha : has_sum f a) (n : \u2115) : norm ((finset.sum (finset.range n) fun (x : \u2115) => f x) - a) \u2264 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 : \u2115) => 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 `\u22251\u2225 = 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 : \u2115) => x ^ n) \u2264 norm 1 - 1 + (1 - norm x\u207b\u00b9) := 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 : \u2115) => 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 : \u2115) => x ^ i) = 1 := sorry\n\n/-! ### Positive sequences with small sums on encodable types -/\n\n/-- For any positive `\u03b5`, define on an encodable type a positive sequence with sum less than `\u03b5` -/\ndef pos_sum_of_encodable {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5) (\u03b9 : Type u_1) [encodable \u03b9] : Subtype fun (\u03b5' : \u03b9 \u2192 \u211d) => (\u2200 (i : \u03b9), 0 < \u03b5' i) \u2227 \u2203 (c : \u211d), has_sum \u03b5' c \u2227 c \u2264 \u03b5 :=\n  let f : \u2115 \u2192 \u211d := fun (n : \u2115) => \u03b5 / bit0 1 / bit0 1 ^ n;\n  { val := f \u2218 encodable.encode, property := sorry }\n\nnamespace nnreal\n\n\ntheorem exists_pos_sum_of_encodable {\u03b5 : nnreal} (h\u03b5 : 0 < \u03b5) (\u03b9 : Type u_1) [encodable \u03b9] : \u2203 (\u03b5' : \u03b9 \u2192 nnreal), (\u2200 (i : \u03b9), 0 < \u03b5' i) \u2227 \u2203 (c : nnreal), has_sum \u03b5' c \u2227 c < \u03b5 := sorry\n\nend nnreal\n\n\nnamespace ennreal\n\n\ntheorem exists_pos_sum_of_encodable {\u03b5 : ennreal} (h\u03b5 : 0 < \u03b5) (\u03b9 : Type u_1) [encodable \u03b9] : \u2203 (\u03b5' : \u03b9 \u2192 nnreal), (\u2200 (i : \u03b9), 0 < \u03b5' i) \u2227 (tsum fun (i : \u03b9) => \u2191(\u03b5' i)) < \u03b5 := 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 : \u2115) => Exists.intro n (nat.self_le_factorial n)\n\ntheorem tendsto_factorial_div_pow_self_at_top : filter.tendsto (fun (n : \u2115) => \u2191(nat.factorial n) / \u2191n ^ 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: \u2115}\n\nlocal notation `rvec`:2000 n := matrix (fin 1) (fin n) \u211a\nlocal notation `cvec`:2000 m := matrix (fin m) (fin 1) \u211a\nlocal infix ` \u2b1d `:70 := matrix.mul\nlocal postfix `\u1d40` : 1500 := transpose\nlocal attribute [instance] matrix.partial_order\n\nnamespace simplex'\n\ndef choose_pivot_column (AN_bar : matrix (fin m) (fin (n - m)) \u211a)\n  (c : rvec (n - m)) : option (fin (n - m)) :=\nfin.find (\u03bb s : fin (n - m), 0 < c 0 s)\n\ndef choose_pivot_row (AN_bar : matrix (fin m) (fin (n - m)) \u211a) (b_bar : cvec m)\n  (s : fin (n - m)) : option (fin m) :=\nfin.find (\u03bb r : fin m, 0 < AN_bar r s \u2227 \u2200 i : fin m, 0 < AN_bar i s \u2192\n  (AN_bar r s)\u207b\u00b9 * b_bar r 0 \u2264 (AN_bar i s)\u207b\u00b9 * b_bar i 0)\n\nlemma choose_pivot_column_eq_none (B : prebasis m n) (A_bar : matrix (fin m) (fin n) \u211a)\n  (b_bar : cvec m) (c : rvec n) (hA_bar : A_bar \u2b1d B.basis.to_matrix\u1d40 = 1)\n  (h0b : 0 \u2264 b_bar)\n  (h : choose_pivot_column (A_bar \u2b1d B.nonbasis.to_matrix\u1d40) (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) \u211a)\n  (b_bar : cvec m) (r : fin m) (s : fin (n - m))\n  (hn : choose_pivot_row (A_bar \u2b1d B.nonbasis.to_matrix\u1d40) b_bar s = none) :\n  (A_bar \u2b1d B.nonbasis.to_matrix\u1d40) r s \u2264 0 :=\nle_of_not_gt $ \u03bb (hpivot : _ < _), begin\n  rw [choose_pivot_row, fin.find_eq_none_iff] at hn,\n  cases @finset.min_of_mem _ _\n    ((univ.filter (\u03bb j : fin m, 0 < (A_bar \u2b1d B.nonbasis.to_matrix\u1d40) j s)).image\n      (\u03bb i, ((A_bar \u2b1d B.nonbasis.to_matrix\u1d40) i s)\u207b\u00b9 * b_bar i 0))\n      (((A_bar \u2b1d B.nonbasis.to_matrix\u1d40) r s)\u207b\u00b9 * b_bar r 0)\n     (mem_image_of_mem _ (by simp *)) with q hq,\n  rcases mem_image.1 (mem_of_min hq) with \u27e8i, hip, hiq\u27e9,\n  subst hiq,\n  refine hn i \u27e8(finset.mem_filter.1 hip).2, \u03bb j hj, _\u27e9,\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)) \u211a) (c : rvec (n - m))\n  (s : fin (n - m)) (hs : s \u2208 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)) \u211a) (r : fin m) (s : fin (n - m)) :\n  matrix (fin m) (fin m) \u211a :=\nlet pivot_inv := (AN_bar r s)\u207b\u00b9 in\n(1 : matrix (fin m) (fin m) \u211a).write_column r\n  (\u03bb 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) \u211a)\n  (r : fin m) (s : fin (n - m)) :\n  (pivot_element B A_bar r s) = (\u03bb _ _, (A_bar \u2b1d B.nonbasis.to_matrix\u1d40) 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 {\u03b1 \u03b2 : Type*} [decidable_eq \u03b1] [decidable_eq \u03b2] (a a' : \u03b1) (b : \u03b2) :\n  single a b a' = if a' = a then some b else none := rfl\n\n@[simp] lemma add_add_neg_cancel'_right {\u03b1 : Type*} [add_comm_group \u03b1] (a b : \u03b1) : 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)) \u211a)\n  (r : fin m) (s : fin (n - m)) (hpivot : AN_bar r s \u2260 0) :\n  swap_inverse AN_bar r s =\n  simplex.swap_inverse B (AN_bar \u2b1d B.nonbasis.to_matrix) r s :=\nhave \u2200 i j r s, (AN_bar \u2b1d ((single s (0 : fin 1)).to_matrix \u2b1d (\u03bb (_ _ : fin 1), (AN_bar r s)\u207b\u00b9))) i j\n  = (AN_bar r s)\u207b\u00b9 * AN_bar i s,\n  begin\n    intros, fin_cases j,\n    rw [\u2190 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 _ _ \u211a)\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\u1d40 : matrix _ _ \u211a) \u2b1d (single i j).to_matrix =\n  (single (B.nonbasisg i) j).to_matrix :=\nby rw [\u2190 to_matrix_symm, \u2190 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\u1d40 : matrix _ _ \u211a) \u2b1d (single i j).to_matrix =\n  (single (B.basisg i) j).to_matrix :=\nby rw [\u2190 to_matrix_symm, \u2190 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\u1d40 : matrix _ _ \u211a) \u2b1d (single s (0 : fin 1)).to_matrix =\n  B.basis.to_matrix\u1d40 \u2b1d (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 \u2260 j) :\n  ((B.swap r s).nonbasis.to_matrix\u1d40 : matrix _ _ \u211a) \u2b1d (single j (0 : fin 1)).to_matrix =\n  B.nonbasis.to_matrix\u1d40 \u2b1d (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) \u211a) (c : rvec n)\n  (r : fin m) (s : fin (n - m)) (hA_bar : A_bar \u2b1d B.basis.to_matrix\u1d40 = 1)\n  (hpivot : pivot_element B A_bar r s \u2260 0) :\n  reduced_cost (B.swap r s) (simplex.swap_inverse B A_bar r s \u2b1d A_bar) c =\n  reduced_cost B A_bar c \u2b1d (1 - (single s (0 : fin 1)).to_matrix \u2b1d\n    (pivot_element B A_bar r s)\u207b\u00b9 \u2b1d (single 0 r).to_matrix \u2b1d A_bar \u2b1d B.nonbasis.to_matrix\u1d40 -\n    (single s 0).to_matrix \u2b1d (pivot_element B A_bar r s)\u207b\u00b9 \u2b1d (single 0 s).to_matrix) :=\nhave h\u2081 : simplex.swap_inverse B A_bar r s \u2b1d A_bar \u2b1d (to_matrix ((swap B r s).basis))\u1d40 = 1,\n  by rw [matrix.mul_assoc, swap_mul_swap_inverse hA_bar hpivot],\nhave h\u2082 : \u2200 {k : \u2115}, \u2200 {M : matrix (fin 1) (fin k) \u211a},\n    to_matrix (single s r) \u2b1d (A_bar \u2b1d ((to_matrix (B.nonbasis))\u1d40 \u2b1d\n    (to_matrix (single s 0) \u2b1d ((pivot_element B A_bar r s)\u207b\u00b9 \u2b1d M)))) =\n    (single s 0).to_matrix \u2b1d M,\n  begin\n    intros,\n    rw [\u2190 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 \u22a2 hpivot,\n    rw [one_by_one_mul_inv_cancel hpivot, matrix.one_mul]\n  end,\nbegin\n  refine mul_single_ext (\u03bb j, _),\n  let x : matrix _ _ \u211a := (B.swap r s).nonbasis.to_matrix\u1d40 \u2b1d\n    (single j (0 : fin 1)).to_matrix,\n  have hxdef : x = (B.swap r s).nonbasis.to_matrix\u1d40 \u2b1d\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 \u2b1d x,\n  { simp [x, (matrix.mul_assoc _ _ _).symm] },\n  let b_bar := (simplex.swap_inverse B A_bar r s \u2b1d A_bar) \u2b1d x,\n  rw [hx, \u2190 matrix.mul_assoc, \u2190 add_left_inj (c \u2b1d (B.swap r s).basis.to_matrix\u1d40 \u2b1d b_bar),\n    \u2190 objective_function_eq rfl h\u2081, matrix.mul_assoc c _ b_bar],\n  have h\u2083 : A_bar \u2b1d ((to_matrix ((swap B r s).basis))\u1d40 \u2b1d b_bar) = A_bar \u2b1d 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\u2083 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\u2082],\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 : \u03a0 (B : prebasis m n) (AN_bar : matrix (fin m) (fin (n - m)) \u211a) (b_bar : cvec m)\n  (c : rvec (n - m)),\n  option (prebasis m n \u00d7 matrix (fin m) (fin (n - m)) \u211a \u00d7 (cvec m) \u00d7 (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)) \u211a :=\n        AN_bar.write_column s (\u03bb j, if j = r then (1 : \u211a) else 0) in\n      simplex (B.swap r s) (S \u2b1d AN_bar') (S \u2b1d b_bar)\n        ((c - (c 0 s / AN_bar r s) \u2022 (\u03bb _, AN_bar r) -\n          (0 : matrix _ _ \u211a).write_column s (\u03bb _, c 0 s / AN_bar r s)))\n    end\n  end\nusing_well_founded { rel_tac := \u03bb _ _, `[exact \u27e8_, empty_wf\u27e9], dec_tac := tactic.assumption }\n\nlemma simplex_spec : \u03a0 (B : prebasis m n) (A_bar : matrix (fin m) (fin n) \u211a)\n  (b_bar : cvec m) (c : rvec n) (hA_bar : A_bar \u2b1d B.basis.to_matrix\u1d40 = 1) (h0b : 0 \u2264 b_bar),\n  (option.cases_on (simplex B (A_bar \u2b1d B.nonbasis.to_matrix\u1d40) b_bar (reduced_cost B A_bar c))\n    (is_unbounded A_bar b_bar c)\n    (\u03bb 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 \u2b1d B.nonbasis.to_matrix\u1d40)\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 \u2b1d B.nonbasis.to_matrix\u1d40) b_bar s with r,\n      { dsimp [simplex'.simplex._match_4],\n        have : 0 < reduced_cost B A_bar c \u2b1d (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          (\u03bb 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 \u2b1d B.nonbasis.to_matrix\u1d40,\n        let S := simplex'.swap_inverse AN_bar r s,\n        let AN_bar' : matrix (fin m) (fin (n - m)) \u211a :=\n          AN_bar.write_column s (\u03bb j, if j = r then (1 : \u211a) 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 := (\u03bb i _, list.nth_le [0,0,1] i sorry)\n--#eval ex.b\ndef ex.c : rvec 4 := \u03bb _ 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 \u2192 X) (g : Y \u2192 Y) : Type :=\n{ h : X \u2192 Y // \u2200 z, h (f z) = g (h z) }\n\ninstance {X Y : Type} (f : X \u2192 X) (g : Y \u2192 Y) :\n  has_coe_to_fun (hom f g) (\u03bb _, X \u2192 Y) :=\n{ coe := subtype.val }\n\n-- \u03a3 (X : Type) (x : X), (X \u2192 X)\n\n-- def T := \u03a3 (X : Type), X \u2192 X\n\n-- def C := \u03a3 t : T, t.fst\n\n@[simp] lemma map_f {X Y : Type} (f : X \u2192 X) (g : Y \u2192 Y)\n  (h : hom f g) : \u2200 z, h (f z) = g (h z) := h.2\n\n@[simp] def iterate_aux {X : Type} (x : X) (f : X \u2192 X) : \u2115 \u2192 X\n| 0     := x\n| (n+1) := f (iterate_aux n)\n\ndef iterate {X : Sort*} (x : X) (f : X \u2192 X) : \u2115 \u2192 X :=\niterate_aux x f\n-- #print nat.rec_on\ndef nat.rec_on2 {motive : \u2115 \u2192 Sort*} (n : \u2115) (h0 : motive 0) \n  (h1 : \u03a0 (n : \u2115), motive n \u2192 motive n.succ) : motive n :=\nlet x : \u03a3 n, motive n := iterate \u27e80, h0\u27e9 (\u03bb x, \u27e8x.1 + 1, h1 x.1 x.2\u27e9) n in\n\n\ndef factorial (n : \u2115) : \u2115 :=\n(iterate (1, 1) (\u03bb 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 \u2192 X) :\n  iterate x f 0 = x := rfl\n\n@[simp] lemma iterate_succ {X : Type} (x : X) (f : X \u2192 X) (n : \u2115) :\n  iterate x f n.succ = f (iterate x f n) := rfl\n\nlemma factorial_succ_aux (n : \u2115) :\n  (iterate (1, 1) (\u03bb x, (x.1 + 1, x.1 * x.2)) (n + 1)) =\n    let x := iterate (1, 1) (\u03bb 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 : \u2115) : 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 \u2192 Y) (x : X) (n : \u2115) (f : X \u2192 X)\n  (g : Y \u2192 Y)\n  (H : \u2200 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 \u2192 X) (x : X) (g : \u2115 \u2192 \u2115) (y : \u2115) (n : \u2115)\n  (H : \u2200 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 : \u21d1(iterate 0 nat.succ) = id :=\n-- by funext n; induction n; simp *\n\n-- @[simp] lemma iterate_one_succ : \u21d1(iterate 1 nat.succ) = nat.succ :=\n-- by funext n; induction n; simp *\n\nlemma succ_iterate (g : \u2115 \u2192 \u2115) (y : \u2115) (n : \u2115)\n  (H : \u2200 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}: \u21d1(iterate x id) = (\u03bb _, x) :=\nby funext n; induction n; simp *\n\nlemma iterate_eq (x : \u2115) (f : \u2115 \u2192 \u2115) (g : \u2115 \u2192 \u2115) (n : \u2115)\n  (h0 : x = g 0)\n  (h1 : \u2200 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 : \u2115) : \u2115 \u2192 \u2115 := iterate a nat.succ\n@[simp] def mul (a : \u2115) : \u2115 \u2192 \u2115 := iterate 0 (add a)\n\ninfix ` + ` := add\ninfix ` * ` := mul\n\nlemma add_assoc' (a b c : \u2115) : 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 : \u2115) : (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 [\u2190 add] }, repeat { rw \u2190 mul}]\n\nlemma mul_add' (a b c : \u2115) : 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 : \u2115) : n.succ = iterate n nat.succ 1 := rfl\n\nlemma mul_assoc' (a b c : \u2115) : 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 : (\u22a4 : 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 : (\u22a4 : 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\u2203 (n : \u2115) (f : mv_polynomial (fin n) R \u2192\u2090[R] A),\n  surjective f \u2227 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 \u2194 (\u22a4 : submodule R M).fg := \u27e8\u03bb h, h.1, \u03bb h, \u27e8h\u27e9\u27e9\n\n@[priority 100] -- see Note [lower instance priority]\ninstance is_noetherian.finite [is_noetherian R M] : finite R M :=\n\u27e8is_noetherian.noetherian \u22a4\u27e9\n\nnamespace finite\nopen _root_.submodule set\n\nlemma iff_add_monoid_fg {M : Type*} [add_comm_monoid M] : module.finite \u2115 M \u2194 add_monoid.fg M :=\n\u27e8\u03bb h, add_monoid.fg_def.2 $ (fg_iff_add_submonoid_fg \u22a4).1 (finite_def.1 h),\n  \u03bb h, finite_def.2 $ (fg_iff_add_submonoid_fg \u22a4).2 (add_monoid.fg_def.1 h)\u27e9\n\nlemma iff_add_group_fg {G : Type*} [add_comm_group G] : module.finite \u2124 G \u2194 add_group.fg G :=\n\u27e8\u03bb h, add_group.fg_def.2 $ (fg_iff_add_subgroup_fg \u22a4).1 (finite_def.1 h),\n  \u03bb h, finite_def.2 $ (fg_iff_add_subgroup_fg \u22a4).2 (add_group.fg_def.1 h)\u27e9\n\nvariables {R M N}\n\nlemma exists_fin [finite R M] : \u2203 (n : \u2115) (s : fin n \u2192 M), span R (range s) = \u22a4 :=\nsubmodule.fg_iff_exists_fin_generating_family.mp out\n\nlemma of_surjective [hM : finite R M] (f : M \u2192\u2097[R] N) (hf : surjective f) :\n  finite R N :=\n\u27e8begin\n  rw [\u2190 linear_map.range_eq_top.2 hf, \u2190 submodule.map_top],\n  exact hM.1.map f\nend\u27e9\n\nlemma of_injective [is_noetherian R N] (f : M \u2192\u2097[R] N)\n  (hf : function.injective f) : finite R M :=\n\u27e8fg_of_injective f hf\u27e9\n\nvariables (R)\n\ninstance self : finite R R :=\n\u27e8\u27e8{1}, by simpa only [finset.coe_singleton] using ideal.span_singleton_one\u27e9\u27e9\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 \u22a2,\n  obtain \u27e8S, hSfin, hSgen\u27e9 := hM,\n  refine \u27e8S, hSfin, eq_top_iff.2 _\u27e9,\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 \u00d7 N) :=\n\u27e8begin\n  rw \u2190 submodule.prod_top,\n  exact submodule.fg_prod hM.1 hN.1\nend\u27e9\n\ninstance pi {\u03b9 : Type*} {M : \u03b9 \u2192 Type*} [fintype \u03b9] [\u03a0 i, add_comm_monoid (M i)]\n  [\u03a0 i, module R (M i)] [h : \u2200 i, finite R (M i)] : finite R (\u03a0 i, M i) :=\n\u27e8begin\n  rw \u2190 submodule.pi_top,\n  exact submodule.fg_pi (\u03bb i, (h i).1),\nend\u27e9\n\nlemma equiv [hM : finite R M] (e : M \u2243\u2097[R] N) : finite R N :=\nof_surjective (e : M \u2192\u2097[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  \u2200 [finite R A] [finite A B], finite R B\n| \u27e8\u27e8s, hs\u27e9\u27e9 \u27e8\u27e8t, ht\u27e9\u27e9 := \u27e8submodule.fg_def.2\n  \u27e8set.image2 (\u2022) (\u2191s : set A) (\u2191t : set B),\n    set.finite.image2 _ s.finite_to_set t.finite_to_set,\n    by rw [set.image2_smul, submodule.span_smul hs (\u2191t : set B),\n      ht, submodule.restrict_scalars_top]\u27e9\u27e9\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\u27e8subalgebra.fg_of_submodule_fg hRA.1\u27e9\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 := \u27e8\u27e8{1}, subsingleton.elim _ _\u27e9\u27e9\n\nsection\nopen_locale classical\n\nprotected lemma mv_polynomial (\u03b9 : Type*) [fintype \u03b9] : finite_type R (mv_polynomial \u03b9 R) :=\n\u27e8\u27e8finset.univ.image mv_polynomial.X, begin\n  rw eq_top_iff, refine \u03bb p, mv_polynomial.induction_on' p\n    (\u03bb u x, finsupp.induction u (subalgebra.algebra_map_mem _ x)\n      (\u03bb i n f hif hn ih, _))\n    (\u03bb 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\u27e9\u27e9\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 \u27e8S, hS\u27e9 := hB.out,\n  refine \u27e8\u27e8S, eq_top_iff.2 (\u03bb b, _)\u27e9\u27e9,\n  have le : adjoin R (S : set B) \u2264 subalgebra.restrict_scalars R (adjoin A S),\n  { apply (algebra.adjoin_le _ : _ \u2264 (subalgebra.restrict_scalars R (adjoin A \u2191S))),\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 \u2192\u2090[R] B) (hf : surjective f) :\n  finite_type R B :=\n\u27e8begin\n  convert subalgebra.fg_map _ f hRA.1,\n  simpa only [map_top f, @eq_comm _ \u22a4, eq_top_iff, alg_hom.mem_range] using hf\nend\u27e9\n\nlemma equiv (hRA : finite_type R A) (e : A \u2243\u2090[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\u27e8fg_trans' hRA.1 hAB.1\u27e9\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) \u2194 \u2203 (s : finset A)\n  (f : (mv_polynomial {x // x \u2208 s} R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rintro \u27e8s, hs\u27e9,\n    use [s, mv_polynomial.aeval coe],\n    intro x,\n    have hrw : (\u2191s : set A) = (\u03bb (x : A), x \u2208 s.val) := rfl,\n    rw [\u2190 set.mem_range, \u2190 alg_hom.coe_range, \u2190 adjoin_eq_range, \u2190 hrw, hs],\n    exact set.mem_univ x },\n  { rintro \u27e8s, \u27e8f, hsur\u27e9\u27e9,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R {x // x \u2208 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) \u2194 \u2203 (\u03b9 : Type u_2) (_ : fintype \u03b9)\n  (f : (mv_polynomial \u03b9 R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial,\n    rintro \u27e8s, \u27e8f, hsur\u27e9\u27e9,\n    use [{x // x \u2208 s}, by apply_instance, f, hsur] },\n  { rintro \u27e8\u03b9, \u27e8hfintype, \u27e8f, hsur\u27e9\u27e9\u27e9,\n    letI : fintype \u03b9 := hfintype,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R \u03b9) 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) \u2194 \u2203 (n : \u2115)\n  (f : (mv_polynomial (fin n) R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial',\n    rintro \u27e8\u03b9, hfintype, \u27e8f, hsur\u27e9\u27e9,\n    letI := hfintype,\n    obtain \u27e8equiv\u27e9 := @fintype.trunc_equiv_fin \u03b9 (classical.dec_eq \u03b9) hfintype,\n    replace equiv := mv_polynomial.rename_equiv R equiv,\n    exact \u27e8fintype.card \u03b9, alg_hom.comp f equiv.symm, function.surjective.comp hsur\n      (alg_equiv.symm equiv).surjective\u27e9 },\n  { rintro \u27e8n, \u27e8f, hsur\u27e9\u27e9,\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 \u2192 finite_type R A :=\nbegin\n  rintro \u27e8n, f, hf\u27e9,\n  apply (finite_type.iff_quotient_mv_polynomial'').2,\n  exact \u27e8n, f, hf.1\u27e9\nend\n\ninstance prod [hA : finite_type R A] [hB : finite_type R B] : finite_type R (A \u00d7 B) :=\n\u27e8begin\n  rw \u2190 subalgebra.prod_top,\n  exact subalgebra.fg_prod hA.1 hB.1\nend\u27e9\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 \u2194 finite_presentation R A :=\nbegin\n  refine \u27e8\u03bb h, _, algebra.finite_type.of_finite_presentation\u27e9,\n  obtain \u27e8n, f, hf\u27e9 := algebra.finite_type.iff_quotient_mv_polynomial''.1 h,\n  refine \u27e8n, f, hf, _\u27e9,\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 \u2243\u2090[R] B` and `A` is finitely presented, then so is `B`. -/\nlemma equiv (hfp : finite_presentation R A) (e : A \u2243\u2090[R] B) : finite_presentation R B :=\nbegin\n  obtain \u27e8n, f, hf\u27e9 := hfp,\n  use [n, alg_hom.comp \u2191e f],\n  split,\n  { exact function.surjective.comp e.surjective hf.1 },\n  suffices hker : (alg_hom.comp \u2191e f).to_ring_hom.ker = f.to_ring_hom.ker,\n  { rw hker, exact hf.2 },\n  { have hco : (alg_hom.comp \u2191e f).to_ring_hom = ring_hom.comp \u2191e.to_ring_equiv f.to_ring_hom,\n    { have h : (alg_hom.comp \u2191e f).to_ring_hom = e.to_alg_hom.to_ring_hom.comp f.to_ring_hom := rfl,\n      have h1 : \u2191(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, \u2190 ideal.comap_comap, \u2190 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 (\u03b9 : Type u_2) [fintype \u03b9] :\n  finite_presentation R (mv_polynomial \u03b9 R) :=\nbegin\n  obtain \u27e8equiv\u27e9 := @fintype.trunc_equiv_fin \u03b9 (classical.dec_eq \u03b9) _,\n  replace equiv := mv_polynomial.rename_equiv R equiv,\n  refine \u27e8_, alg_equiv.to_alg_hom equiv.symm, _\u27e9,\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 \u29f8 I) :=\nbegin\n  obtain \u27e8n, f, hf\u27e9 := hfp,\n  refine \u27e8n, (ideal.quotient.mk\u2090 R I).comp f, _, _\u27e9,\n  { exact (ideal.quotient.mk\u2090_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 \u2192\u2090[R] B` is surjective with finitely generated kernel and `A` is finitely presented,\nthen so is `B`. -/\nlemma of_surjective {f : A \u2192\u2090[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 \u2194\n  \u2203 n (I : ideal (mv_polynomial (fin n) R)) (e : (_ \u29f8 I) \u2243\u2090[R] A), I.fg :=\nbegin\n  split,\n  { rintros \u27e8n, f, hf\u27e9,\n    exact \u27e8n, f.to_ring_hom.ker, ideal.quotient_ker_alg_equiv_of_surjective hf.1, hf.2\u27e9 },\n  { rintros \u27e8n, I, e, hfg\u27e9,\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 \u2194 \u2203 (\u03b9 : Type u_2) (_ : fintype \u03b9)\n  (f : mv_polynomial \u03b9 R \u2192\u2090[R] A), surjective f \u2227 f.to_ring_hom.ker.fg :=\nbegin\n  split,\n  { rintro \u27e8n, f, hfs, hfk\u27e9,\n    set ulift_var := mv_polynomial.rename_equiv R equiv.ulift,\n    refine \u27e8ulift (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\u27e9,\n    convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv ulift_var.to_ring_equiv, },\n  { rintro \u27e8\u03b9, hfintype, f, hf\u27e9,\n    haveI : fintype \u03b9 := hfintype,\n    obtain \u27e8equiv\u27e9 := @fintype.trunc_equiv_fin \u03b9 (classical.dec_eq \u03b9) _,\n    replace equiv := mv_polynomial.rename_equiv R equiv,\n    refine \u27e8fintype.card \u03b9, f.comp equiv.symm,\n      hf.1.comp (alg_equiv.symm equiv).surjective,\n      ideal.fg_ker_comp _ f _ hf.2 equiv.symm.surjective\u27e9,\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) (\u03b9 : Type*)\n  [fintype \u03b9] : finite_presentation R (mv_polynomial \u03b9 A) :=\nbegin\n  rw iff_quotient_mv_polynomial' at hfp \u22a2,\n  classical,\n  obtain \u27e8\u03b9', _, f, hf_surj, hf_ker\u27e9 := hfp,\n  resetI,\n  let g := (mv_polynomial.map_alg_hom f).comp (mv_polynomial.sum_alg_equiv R \u03b9 \u03b9').to_alg_hom,\n  refine \u27e8\u03b9 \u2295 \u03b9', 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 _)\u27e9,\n  { convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv (mv_polynomial.sum_alg_equiv R \u03b9 \u03b9').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 \u27e8n, I, e, hfg\u27e9 := 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 \u2192+* B` is `finite` if `B` is finitely generated as `A`-module. -/\ndef finite (f : A \u2192+* B) : Prop :=\nby letI : algebra A B := f.to_algebra; exact module.finite A B\n\n/-- A ring morphism `A \u2192+* B` is of `finite_type` if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A \u2192+* B) : Prop := @algebra.finite_type A B _ _ f.to_algebra\n\n/-- A ring morphism `A \u2192+* B` is of `finite_presentation` if `B` is finitely presented as\n`A`-algebra. -/\ndef finite_presentation (f : A \u2192+* 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 \u2192+* 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 \u2192+* C} {f : A \u2192+* 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 \u2192+* B} (hf : f.finite) : finite_type f :=\n@module.finite.finite_type _ _ _ _ f.to_algebra hf\n\nlemma of_comp_finite {f : A \u2192+* B} {g : B \u2192+* 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 \u2192+* B} {g : B \u2192+* 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' := \u03bb a, rfl, .. g } hg\n\nlemma of_surjective (f : A \u2192+* B) (hf : surjective f) : f.finite_type :=\nby { rw \u2190 f.comp_id, exact (id A).comp_surjective hf }\n\nlemma comp {g : B \u2192+* C} {f : A \u2192+* 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 \u2192+* 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 \u2192+* B} {g : B \u2192+* 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 \u2192+* B} {g : B \u2192+* 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' := \u03bb a, rfl, .. g } hg hker hf\n\nlemma of_surjective (f : A \u2192+* B) (hf : surjective f) (hker : f.ker.fg) : f.finite_presentation :=\nby { rw \u2190 f.comp_id, exact (id A).comp_surjective hf hker}\n\nlemma of_finite_type [is_noetherian_ring A] {f : A \u2192+* B} : f.finite_type \u2194 f.finite_presentation :=\n@algebra.finite_presentation.of_finite_type A B _ _ f.to_algebra _\n\nlemma comp {g : B \u2192+* C} {f : A \u2192+* 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 := \u03bb 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 \u2192\u2090[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 \u2192\u2090[R] B) : Prop := f.to_ring_hom.finite\n\n/-- An algebra morphism `A \u2192\u2090[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 \u2192\u2090[R] B) : Prop := f.to_ring_hom.finite_type\n\n/-- An algebra morphism `A \u2192\u2090[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 \u2192\u2090[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 \u2192\u2090[R] C} {f : A \u2192\u2090[R] B} (hg : g.finite) (hf : f.finite) : (g.comp f).finite :=\nring_hom.finite.comp hg hf\n\nlemma of_surjective (f : A \u2192\u2090[R] B) (hf : surjective f) : f.finite :=\nring_hom.finite.of_surjective f hf\n\nlemma finite_type {f : A \u2192\u2090[R] B} (hf : f.finite) : finite_type f :=\nring_hom.finite.finite_type hf\n\nlemma of_comp_finite {f : A \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[R] C} {f : A \u2192\u2090[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 \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[R] B) (hf : surjective f) : f.finite_type :=\nring_hom.finite_type.of_surjective f hf\n\nlemma of_finite_presentation {f : A \u2192\u2090[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 \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[R] C} {f : A \u2192\u2090[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 \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[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 \u2192\u2090[R] B} :\n  f.finite_type \u2194 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 \u2208 adjoin R (of' R M '' f.support) :=\nbegin\n  suffices : span R (of' R M '' f.support) \u2264 (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 = \u22a4) :\n  algebra.adjoin R (\u22c3 f \u2208 S, (of' R M '' (f.support : set M))) = \u22a4 :=\nbegin\n  refine le_antisymm le_top _,\n  rw [\u2190 hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : of' R M '' f.support \u2286\n    \u22c3 (g : add_monoid_algebra R M) (H : g \u2208 S), of' R M '' g.support,\n  { intros s hs,\n    exact set.mem_Union\u2082.2 \u27e8f, \u27e8hf, hs\u27e9\u27e9 },\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 = \u22a4) :\n  algebra.adjoin R (of' R M '' (\u22c3 f \u2208 S, (f.support : set M))) = \u22a4 :=\nbegin\n  suffices : of' R M '' (\u22c3 f \u2208 S, (f.support : set M)) = \u22c3 f \u2208 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  \u2203 G : finset M, algebra.adjoin R (of' R M '' G) = \u22a4 :=\nbegin\n  unfreezingI { obtain \u27e8S, hS\u27e9 := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (\u03bb f, f.support),\n  have : (finset.bUnion S (\u03bb f, f.support) : set M) = \u22c3 f \u2208 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 \u2208 S`. -/\nlemma of'_mem_span [nontrivial R] {m : M} {S : set M} :\n  of' R M m \u2208 span R (of' R M '' S) \u2194 m \u2208 S :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, submodule.subset_span $ set.mem_image_of_mem (of R M) h\u27e9,\n  rw [of', \u2190 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 \u2208 closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of' R M m \u2208 span R (submonoid.closure (of' R M '' S) : set (add_monoid_algebra R M))) :\n  m \u2208 closure S :=\nbegin\n  suffices : multiplicative.of_add m \u2208 submonoid.closure (multiplicative.to_add \u207b\u00b9' S),\n  { simpa [\u2190 to_submonoid_closure] },\n  rw [set.image_congr' (show \u2200 x, of' R M x = of R M x, from \u03bb x, of'_eq_of x),\n    \u2190 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 = \u22a4) : function.surjective (mv_polynomial.aeval\n  (\u03bb (s : S), of' R M \u2191s) : mv_polynomial S R \u2192 add_monoid_algebra R M) :=\nbegin\n  refine \u03bb f, induction_on f (\u03bb m, _) _ _,\n  { have : m \u2208 closure S := hS.symm \u25b8 mem_top _,\n    refine closure_induction this (\u03bb m hm, _) _ _,\n    { exact \u27e8mv_polynomial.X \u27e8m, hm\u27e9, mv_polynomial.aeval_X _ _\u27e9 },\n    { exact \u27e81, alg_hom.map_one _\u27e9 },\n    { rintro m\u2081 m\u2082 \u27e8P\u2081, hP\u2081\u27e9 \u27e8P\u2082, hP\u2082\u27e9,\n      exact \u27e8P\u2081 * P\u2082, by rw [alg_hom.map_mul, hP\u2081, hP\u2082, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]; refl\u27e9 } },\n  { rintro f g \u27e8P, rfl\u27e9 \u27e8Q, rfl\u27e9,\n    exact \u27e8P + Q, alg_hom.map_add _ _ _\u27e9 },\n  { rintro r f \u27e8P, rfl\u27e9,\n    exact \u27e8r \u2022 P, alg_hom.map_smul _ _ _\u27e9 }\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 \u27e8S, hS\u27e9 := h.out,\n  exact (finite_type.mv_polynomial R (S : set M)).of_surjective (mv_polynomial.aeval\n    (\u03bb (s : (S : set M)), of' R M \u2191s)) (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) \u2194 add_monoid.fg M :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, @add_monoid_algebra.finite_type_of_fg _ _ _ _ h\u27e9,\n  obtain \u27e8S, hS\u27e9 := @exists_finset_adjoin_eq_top R M _ _ h,\n  refine add_monoid.fg_def.2 \u27e8S, (eq_top_iff' _).2 (\u03bb m, _)\u27e9,\n  have hm : of' R M m \u2208 (adjoin R (of' R M '' \u2191S)).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) \u2194 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 \u2208 adjoin R (of R M '' f.support) :=\nbegin\n  suffices : span R (of R M '' f.support) \u2264 (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 = \u22a4) :\n  algebra.adjoin R (\u22c3 f \u2208 S, (of R M '' (f.support : set M))) = \u22a4 :=\nbegin\n  refine le_antisymm le_top _,\n  rw [\u2190 hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : (of R M) '' f.support \u2286\n    \u22c3 (g : monoid_algebra R M) (H : g \u2208 S), of R M '' g.support,\n  { intros s hs,\n    exact set.mem_Union\u2082.2 \u27e8f, \u27e8hf, hs\u27e9\u27e9 },\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 = \u22a4) :\n  algebra.adjoin R (of R M '' (\u22c3 f \u2208 S, (f.support : set M))) = \u22a4 :=\nbegin\n  suffices : of R M '' (\u22c3 f \u2208 S, (f.support : set M)) = \u22c3 f \u2208 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  \u2203 G : finset M, algebra.adjoin R (of R M '' G) = \u22a4 :=\nbegin\n  unfreezingI { obtain \u27e8S, hS\u27e9 := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (\u03bb f, f.support),\n  have : (finset.bUnion S (\u03bb f, f.support) : set M) = \u22c3 f \u2208 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 \u2208 S`. -/\nlemma of_mem_span_of_iff [nontrivial R] {m : M} {S : set M} :\n  of R M m \u2208 span R (of R M '' S) \u2194 m \u2208 S :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, submodule.subset_span $ set.mem_image_of_mem (of R M) h\u27e9,\n  rw [of, monoid_hom.coe_mk, \u2190 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 \u2208 closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of R M m \u2208 span R (submonoid.closure (of R M '' S) : set (monoid_algebra R M))) :\n  m \u2208 closure S :=\nbegin\n  rw \u2190 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 = \u22a4) : function.surjective (mv_polynomial.aeval\n  (\u03bb (s : S), of R M \u2191s) : mv_polynomial S R \u2192 monoid_algebra R M) :=\nbegin\n  refine \u03bb f, induction_on f (\u03bb m, _) _ _,\n  { have : m \u2208 closure S := hS.symm \u25b8 mem_top _,\n    refine closure_induction this (\u03bb m hm, _) _ _,\n    { exact \u27e8mv_polynomial.X \u27e8m, hm\u27e9, mv_polynomial.aeval_X _ _\u27e9 },\n    { exact \u27e81, alg_hom.map_one _\u27e9 },\n    { rintro m\u2081 m\u2082 \u27e8P\u2081, hP\u2081\u27e9 \u27e8P\u2082, hP\u2082\u27e9,\n      exact \u27e8P\u2081 * P\u2082, by rw [alg_hom.map_mul, hP\u2081, hP\u2082, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]\u27e9 } },\n  { rintro f g \u27e8P, rfl\u27e9 \u27e8Q, rfl\u27e9,\n    exact \u27e8P + Q, alg_hom.map_add _ _ _\u27e9 },\n  { rintro r f \u27e8P, rfl\u27e9,\n    exact \u27e8r \u2022 P, alg_hom.map_smul _ _ _\u27e9 }\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) \u2194 monoid.fg M :=\n\u27e8\u03bb h, monoid.fg_iff_add_fg.2 $ add_monoid_algebra.finite_type_iff_fg.1 $ h.equiv $\n  to_additive_alg_equiv R M, \u03bb h, @monoid_algebra.finite_type_of_fg _ _ _ _ h\u27e9\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) \u2194 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 \u2192\u2097[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 \u2192\u2097[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 : \u2200 o, (X : R[X]) \u2022 o = f o,\n  { intro,\n    simp, },\n  have : (\u22a4 : submodule R[X] M) \u2264 ideal.span {X} \u2022 \u22a4,\n  { intros a ha,\n    obtain \u27e8y, rfl\u27e9 := f_surj a,\n    rw [\u2190 X_mul y],\n    exact submodule.smul_mem_smul (ideal.mem_span_singleton.mpr (dvd_refl _)) trivial, },\n  obtain \u27e8F, hFa, hFb\u27e9 := submodule.exists_sub_one_mem_and_smul_eq_zero_of_fg_of_le_smul _\n    (\u22a4 : submodule R[X] M) (finite_def.mp hfgpoly) this,\n  rw [\u2190 linear_map.ker_eq_bot, linear_map.ker_eq_bot'],\n  intros m hm,\n  rw ideal.mem_span_singleton' at hFa,\n  obtain \u27e8G, hG\u27e9 := hFa,\n  suffices : (F - 1) \u2022 m = 0,\n  { have Fmzero := hFb m (by simp),\n    rwa [\u2190 sub_add_cancel F 1, add_smul, one_smul, this, zero_add] at Fmzero, },\n  rw [\u2190 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\u2081 w\u2082 v u\n\nvariable {C : Type u} [Category.{v} C] (J : GrothendieckTopology C)\n\nvariable {D : Type w\u2081} [Category.{max v u} D]\n\nvariable {E : Type w\u2082} [Category.{max v u} E]\n\nvariable (F : D \u2964 E)\n\nnoncomputable section\n\nvariable [\u2200 (\u03b1 \u03b2 : Type max v u) (fst snd : \u03b2 \u2192 \u03b1), HasLimitsOfShape (WalkingMulticospan fst snd) D]\n\nvariable [\u2200 (\u03b1 \u03b2 : Type max v u) (fst snd : \u03b2 \u2192 \u03b1), HasLimitsOfShape (WalkingMulticospan fst snd) E]\n\nvariable [\u2200 (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 D), PreservesLimit (W.index P).multicospan F]\n\nvariable (P : C\u1d52\u1d56 \u2964 D)\n\n/-- The diagram used to define `P\u207a`, composed with `F`, is isomorphic\nto the diagram used to define `P \u22d9 F`. -/\ndef diagramCompIso (X : C) : J.diagram P X \u22d9 F \u2245 J.diagram (P \u22d9 F) X :=\n  NatIso.ofComponents\n    (fun W => by\n      refine' _ \u226a\u226b 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_\u03c0_app, multiequalizer.multifork_\u03c0_app_left, iso.symm_hom,\n        multiequalizer.lift_\u03b9, 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_\u03c0,\n        category.assoc]\n      simp only [\u2190 F.map_comp, multiequalizer.lift_\u03b9])\n#align category_theory.grothendieck_topology.diagram_comp_iso CategoryTheory.GrothendieckTopology.diagramCompIso\n\n@[simp, reassoc.1]\ntheorem diagramCompIso_hom_\u03b9 (X : C) (W : (J.cover X)\u1d52\u1d56) (i : W.unop.arrow) :\n    (J.diagramCompIso F P X).Hom.app W \u226b Multiequalizer.\u03b9 _ i = F.map (Multiequalizer.\u03b9 _ _) :=\n  by\n  delta diagram_comp_iso\n  dsimp\n  simp\n#align category_theory.grothendieck_topology.diagram_comp_iso_hom_\u03b9 CategoryTheory.GrothendieckTopology.diagramCompIso_hom_\u03b9\n\nvariable [\u2200 X : C, HasColimitsOfShape (J.cover X)\u1d52\u1d56 D]\n\nvariable [\u2200 X : C, HasColimitsOfShape (J.cover X)\u1d52\u1d56 E]\n\nvariable [\u2200 X : C, PreservesColimitsOfShape (J.cover X)\u1d52\u1d56 F]\n\n/-- The isomorphism between `P\u207a \u22d9 F` and `(P \u22d9 F)\u207a`. -/\ndef plusCompIso : J.plusObj P \u22d9 F \u2245 J.plusObj (P \u22d9 F) :=\n  NatIso.ofComponents\n    (fun X => by\n      refine' _ \u226a\u226b 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 [\u2190 F.map_comp]\n        dsimp [colim_map, is_colimit.map, colimit.pre]\n        simp only [colimit.\u03b9_desc_assoc, colimit.\u03b9_desc]\n        dsimp [cocones.precompose]\n        rw [category.assoc, colimit.\u03b9_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_\u03b9_hom_assoc, grothendieck_topology.diagram_pullback_app,\n        colimit.\u03b9_pre, has_colimit.iso_of_nat_iso_\u03b9_hom, \u03b9_colim_map_assoc]\n      simp only [\u2190 category.assoc]\n      congr 1\n      ext\n      dsimp\n      simp only [category.assoc]\n      erw [multiequalizer.lift_\u03b9, diagram_comp_iso_hom_\u03b9, diagram_comp_iso_hom_\u03b9, \u2190 F.map_comp,\n        multiequalizer.lift_\u03b9])\n#align category_theory.grothendieck_topology.plus_comp_iso CategoryTheory.GrothendieckTopology.plusCompIso\n\n@[simp, reassoc.1]\ntheorem \u03b9_plusCompIso_hom (X) (W) :\n    F.map (colimit.\u03b9 _ W) \u226b (J.plusCompIso F P).Hom.app X =\n      (J.diagramCompIso F P X.unop).Hom.app W \u226b colimit.\u03b9 _ 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, \u2190\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_\u03c0, 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_\u03c0_app,\n    multiequalizer.multifork_\u03c0_app_left, multiequalizer.lift_\u03b9, 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_\u03b9, category.assoc, has_colimit.iso_of_nat_iso_\u03b9_hom]\n#align category_theory.grothendieck_topology.\u03b9_plus_comp_iso_hom CategoryTheory.GrothendieckTopology.\u03b9_plusCompIso_hom\n\n@[simp, reassoc.1]\ntheorem plusCompIso_whiskerLeft {F G : D \u2964 E} (\u03b7 : F \u27f6 G) (P : C\u1d52\u1d56 \u2964 D)\n    [\u2200 X : C, PreservesColimitsOfShape (J.cover X)\u1d52\u1d56 F]\n    [\u2200 (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 D), PreservesLimit (W.index P).multicospan F]\n    [\u2200 X : C, PreservesColimitsOfShape (J.cover X)\u1d52\u1d56 G]\n    [\u2200 (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 D), PreservesLimit (W.index P).multicospan G] :\n    whiskerLeft _ \u03b7 \u226b (J.plusCompIso G P).Hom =\n      (J.plusCompIso F P).Hom \u226b J.plusMap (whiskerLeft _ \u03b7) :=\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 [\u03b9_plus_comp_iso_hom, \u03b9_colim_map, whisker_left_app, \u03b9_plus_comp_iso_hom_assoc,\n    nat_trans.naturality_assoc, grothendieck_topology.diagram_nat_trans_app]\n  simp only [\u2190 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\u207a \u22d9 F` and `(P \u22d9 F)\u207a`, functorially in `F`. -/\n@[simps hom_app inv_app]\ndef plusFunctorWhiskerLeftIso (P : C\u1d52\u1d56 \u2964 D)\n    [\u2200 (F : D \u2964 E) (X : C), PreservesColimitsOfShape (J.cover X)\u1d52\u1d56 F]\n    [\u2200 (F : D \u2964 E) (X : C) (W : J.cover X) (P : C\u1d52\u1d56 \u2964 D),\n        PreservesLimit (W.index P).multicospan F] :\n    (whiskeringLeft _ _ E).obj (J.plusObj P) \u2245 (whiskeringLeft _ _ _).obj P \u22d9 J.plusFunctor E :=\n  NatIso.ofComponents (fun X => plusCompIso _ _ _) fun F G \u03b7 => 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\u1d52\u1d56 \u2964 D} (\u03b7 : P \u27f6 Q) :\n    whiskerRight (J.plusMap \u03b7) F \u226b (J.plusCompIso F Q).Hom =\n      (J.plusCompIso F P).Hom \u226b J.plusMap (whiskerRight \u03b7 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 [\u03b9_colim_map, whisker_right_app, \u03b9_plus_comp_iso_hom_assoc,\n    grothendieck_topology.diagram_nat_trans_app]\n  simp only [\u2190 category.assoc, \u2190 F.map_comp]\n  dsimp [colim_map, is_colimit.map]\n  simp only [colimit.\u03b9_desc]\n  dsimp [cocones.precompose]\n  simp only [functor.map_comp, category.assoc, \u03b9_plus_comp_iso_hom]\n  simp only [\u2190 category.assoc]\n  congr 1\n  ext\n  dsimp\n  simp only [diagram_comp_iso_hom_\u03b9_assoc, multiequalizer.lift_\u03b9, diagram_comp_iso_hom_\u03b9,\n    category.assoc]\n  simp only [\u2190 F.map_comp, multiequalizer.lift_\u03b9]\n#align category_theory.grothendieck_topology.plus_comp_iso_whisker_right CategoryTheory.GrothendieckTopology.plusCompIso_whiskerRight\n\n/-- The isomorphism between `P\u207a \u22d9 F` and `(P \u22d9 F)\u207a`, functorially in `P`. -/\n@[simps hom_app inv_app]\ndef plusFunctorWhiskerRightIso :\n    J.plusFunctor D \u22d9 (whiskeringRight _ _ _).obj F \u2245\n      (whiskeringRight _ _ _).obj F \u22d9 J.plusFunctor E :=\n  NatIso.ofComponents (fun P => J.plusCompIso _ _) fun P Q \u03b7 => 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 _) _ \u226b (J.plusCompIso F P).Hom = J.toPlus _ :=\n  by\n  ext\n  dsimp [to_plus]\n  simp only [\u03b9_plus_comp_iso_hom, functor.map_comp, category.assoc]\n  simp only [\u2190 category.assoc]\n  congr 1\n  ext\n  delta cover.to_multiequalizer\n  simp only [diagram_comp_iso_hom_\u03b9, category.assoc, \u2190 F.map_comp]\n  erw [multiequalizer.lift_\u03b9, multiequalizer.lift_\u03b9]\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 _ \u226b (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 \u22d9 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}} {\u03bc : Type v} {n : \u2115} {I : Type u} [inhabited I] (F : ultrafilter I)\n  {\ud835\udd04 : I \u2192 nonempty_Structure L}\n\ndef uequiv : (\u03a0 i, \ud835\udd04 i) \u2192 (\u03a0 i, \ud835\udd04 i) \u2192 Prop :=\n\u03bb u\u2081 u\u2082, {i | u\u2081 i = u\u2082 i} \u2208 F\n\nnotation u` ~[`:80 F`] `v:80 := uequiv F u v\n\n@[simp] lemma uequiv_refl (u : \u03a0 i, \ud835\udd04 i) : u ~[F] u :=\nby { simp[uequiv], exact F.univ_sets }\n\nlemma uequiv_symm {u\u2081 u\u2082 : \u03a0 i, \ud835\udd04 i} : u\u2081 ~[F] u\u2082 \u2192 u\u2082 ~[F] u\u2081 :=\nby { simp[uequiv], have : {i | u\u2081 i = u\u2082 i} = {i | u\u2082 i = u\u2081 i}, { ext, simp, exact eq_comm }, simp[this] }\n\nlemma uequiv_trans {u\u2081 u\u2082 u\u2083 : \u03a0 i, \ud835\udd04 i} : u\u2081 ~[F] u\u2082 \u2192 u\u2082 ~[F] u\u2083 \u2192 u\u2081 ~[F] u\u2083 :=\nby { simp[uequiv], intros h\u2081 h\u2082,\n     have : {i | u\u2081 i = u\u2082 i} \u2229 {i | u\u2082 i = u\u2083 i} \u2286 {i | u\u2081 i = u\u2083 i},\n     { intros i hi, simp* at* },\n     exact F.sets_of_superset (F.inter_sets h\u2081 h\u2082) this }\n\ntheorem uequiv_equivalence : equivalence (@uequiv L I _ F \ud835\udd04) :=\n\u27e8uequiv_refl F, \u03bb _ _ , uequiv_symm F, \u03bb _ _ _, uequiv_trans F\u27e9\n\n\n@[reducible, simp, instance]\ndef ult (\ud835\udd04 : I \u2192 nonempty_Structure L) (F : ultrafilter I) : setoid (\u03a0 i, \ud835\udd04 i) := \u27e8@uequiv L I _ F \ud835\udd04, uequiv_equivalence F\u27e9\n\ndef Ult (\ud835\udd04 : I \u2192 nonempty_Structure L) (F : ultrafilter I) : Type* :=\nquotient (ult \ud835\udd04 F: setoid (\u03a0 i, \ud835\udd04 i))\n\ndef to_quotient {\ud835\udd04 : I \u2192 nonempty_Structure L} {F : ultrafilter I} (u : \u03a0 i, \ud835\udd04 i) : Ult \ud835\udd04 F := quotient.mk' u\n\nnotation `\u27e6`u`\u27e7*` :max := to_quotient u\n\ninstance : inhabited (Ult \ud835\udd04 F) := \u27e8\u27e6\u03bb i, default\u27e7*\u27e9\n\nnamespace Ult\nopen logic.semantics\n\n@[elab_as_eliminator]\nprotected lemma ind_on {C : Ult \ud835\udd04 F \u2192 Prop} (u : Ult \ud835\udd04 F)\n  (h : \u2200 u : \u03a0 i, \ud835\udd04 i, C \u27e6u\u27e7*) : C u :=\nquotient.induction_on' u h\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on {\u03c6} (d : Ult \ud835\udd04 F) (f : (\u03a0 i, \ud835\udd04 i) \u2192 \u03c6)\n  (h : \u2200 (v u : \u03a0 i, \ud835\udd04 i), v ~[F] u \u2192 f v = f u) : \u03c6 :=\nquotient.lift_on' d f h\n\n@[simp]\nprotected lemma lift_on_eq {\u03c6} (u\u2080 : \u03a0 i, \ud835\udd04 i) (f : (\u03a0 i, \ud835\udd04 i) \u2192 \u03c6)\n  (h : \u2200 v u, v ~[F] u \u2192 f v = f u) : fol.Ult.lift_on F \u27e6u\u2080\u27e7* f h = f u\u2080 := rfl\n\n@[elab_as_eliminator, reducible, simp]\nprotected def lift_on\u2082 {\u03c6} (u\u2081 u\u2082 : Ult \ud835\udd04 F) (f : (\u03a0 i, \ud835\udd04 i) \u2192 (\u03a0 i, \ud835\udd04 i) \u2192 \u03c6)\n  (h : \u2200 u\u2081 u\u2082 v\u2081 v\u2082, u\u2081 ~[F] v\u2081 \u2192 u\u2082 ~[F] v\u2082 \u2192 f u\u2081 u\u2082 = f v\u2081 v\u2082) : \u03c6 :=\nquotient.lift_on\u2082' u\u2081 u\u2082 f h\n\n@[simp]\nprotected lemma lift_on\u2082_eq {\u03c6} (u\u2081 u\u2082 : \u03a0 i, \ud835\udd04 i) (f : (\u03a0 i, \ud835\udd04 i) \u2192 (\u03a0 i, \ud835\udd04 i) \u2192 \u03c6)\n  (h : \u2200 t\u2081 t\u2082 u\u2081 u\u2082, (t\u2081 ~[F] u\u2081) \u2192 (t\u2082 ~[F] u\u2082) \u2192 f t\u2081 t\u2082 = f u\u2081 u\u2082) :\n  fol.Ult.lift_on\u2082 F \u27e6u\u2081\u27e7* \u27e6u\u2082\u27e7* f h = f u\u2081 u\u2082 := rfl\n\n@[elab_as_eliminator, reducible]\nprotected def lift_on_finitary {\u03c6} {n : \u2115} (v : finitary (Ult \ud835\udd04 F) n) (f : finitary (\u03a0 i, \ud835\udd04 i) n \u2192 \u03c6)\n  (h : \u2200 v\u2081 v\u2082 : finitary (\u03a0 i, \ud835\udd04 i) n, (\u2200 n, (v\u2081 n) ~[F] (v\u2082 n)) \u2192 f v\u2081 = f v\u2082) : \u03c6 :=\nquotient.lift_on_finitary v f h \n\n@[simp]\nprotected lemma lift_on_finitary_eq {\u03c6} {n} (v : finitary (\u03a0 i, \ud835\udd04 i) n) (f : finitary (\u03a0 i, \ud835\udd04 i) n \u2192 \u03c6)\n  (h : \u2200 v\u2081 v\u2082 : finitary (\u03a0 i, \ud835\udd04 i) n, (\u2200 n, (v\u2081 n) ~[F] (v\u2082 n)) \u2192 f v\u2081 = f v\u2082) :\n  fol.Ult.lift_on_finitary F (\u03bb x, \u27e6v x\u27e7*) f h = f v :=\nquotient.lift_on_finitary_eq v f h\n\n@[simp] lemma of_eq_of {u\u2081 u\u2082 : \u03a0 i, \ud835\udd04 i} : (\u27e6u\u2081\u27e7* : Ult \ud835\udd04 F) = \u27e6u\u2082\u27e7* \u2194 u\u2081 ~[F] u\u2082 :=\nby simp[to_quotient, quotient.eq']\n\nlemma equivs_mem {n} {v\u2081 v\u2082 : finitary (\u03a0 i, \ud835\udd04 i) n} (h : \u2200 (x : fin n), {i : I | v\u2081 x i = v\u2082 x i} \u2208 F) :\n  {i | (\u03bb x, v\u2081 x i) = (\u03bb x, v\u2082 x i)} \u2208 F := \nbegin\n  induction n with n IH,\n  { have : {i : I | (\u03bb x, v\u2081 x i) = (\u03bb x, v\u2082 x i)} = set.univ,\n    { ext i, simp }, rw this, exact F.univ_sets },\n  { have ss : {i | v\u2081 0 i = v\u2082 0 i} \u2229 {i | (\u03bb x, v\u2081.tail x i) = (\u03bb x, v\u2082.tail x i)} \u2286 {i : I | (\u03bb x, v\u2081 x i) = (\u03bb x, v\u2082 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\u2081 0 i = v\u2082 0 i} \u2229 {i | (\u03bb x, v\u2081.tail x i) = (\u03bb x, v\u2082.tail x i)} \u2208 F,\n      from (F.inter_sets (h _) (@IH v\u2081.tail v\u2082.tail (\u03bb x, h _))),\n    refine F.sets_of_superset this ss }\nend\n\nlemma fn_equiv {n} {v\u2081 v\u2082 : finitary (\u03a0 i, \ud835\udd04 i) n} (h : \u2200 x, v\u2081 x ~[F] v\u2082 x) (f : L.fn n) :\n  (\u03bb i, (\ud835\udd04 i).fn f (\u03bb x, v\u2081 x i)) ~[F] (\u03bb i, (\ud835\udd04 i).fn f (\u03bb x, v\u2082 x i)) :=\nbegin\n  simp[uequiv] at*,\n  have : {i | (\u03bb x, v\u2081 x i) = (\u03bb x, v\u2082 x i)} \u2286 {i | (\ud835\udd04 i).fn f (\u03bb x, v\u2081 x i) = (\ud835\udd04 i).fn f (\u03bb x, v\u2082 x i)},\n  { intros i hi, simp* at* },\n  exact F.sets_of_superset (equivs_mem F h) this\nend\n\nlemma pr_equiv : \u2200 {n} {v\u2081 v\u2082 : finitary (\u03a0 i, \ud835\udd04 i) n} (h : \u2200 x, v\u2081 x ~[F] v\u2082 x) (p : L.pr n),\n  {i | (\ud835\udd04 i).pr p (\u03bb x, v\u2081 x i)} \u2208 F \u2194 {i | (\ud835\udd04 i).pr p (\u03bb x, v\u2082 x i)} \u2208 F :=\nbegin\n  suffices : \u2200 {n} {v\u2081 v\u2082 : finitary (\u03a0 i, \ud835\udd04 i) n} (h : \u2200 x, v\u2081 x ~[F] v\u2082 x) (p : L.pr n),\n  {i | (\ud835\udd04 i).pr p (\u03bb x, v\u2081 x i)} \u2208 F \u2192 {i | (\ud835\udd04 i).pr p (\u03bb x, v\u2082 x i)} \u2208 F,\n  { intros n v\u2081 v\u2082 eqn p, refine \u27e8this eqn p, this (\u03bb x, uequiv_symm _ (eqn x)) p\u27e9 },\n  intros n v\u2081 v\u2082 eqn p h,\n  have : {i | (\ud835\udd04 i).pr p (\u03bb x, v\u2081 x i)} \u2229 {i | (\u03bb x, v\u2081 x i) = (\u03bb x, v\u2082 x i)} \u2286 {i | (\ud835\udd04 i).pr p (\u03bb x, v\u2082 x i)},\n  { intros i hi, simp* at*, simp[\u2190hi.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 \ud835\udd04 F) k \u2192 Ult \ud835\udd04 F :=\n\u03bb v, fol.Ult.lift_on_finitary F v (\u03bb v, (\u27e6\u03bb i, (\ud835\udd04 i).fn f (\u03bb x, v x i)\u27e7* : Ult \ud835\udd04 F)) $ \u03bb u\u2081 u\u2082 eqn,\nby { simp, exact fn_equiv F eqn f }\n\ndef product_pr (n) (p : L.pr n) : finitary (Ult \ud835\udd04 F) n \u2192 Prop :=\n\u03bb v, fol.Ult.lift_on_finitary F v (\u03bb v, {i | (\ud835\udd04 i).pr p (\u03bb x, v x i)} \u2208 F) $ \u03bb u\u2081 u\u2082 eqn,\nby { simp, exact pr_equiv F eqn p }\n\n@[reducible] def product (\ud835\udd04 : I \u2192 nonempty_Structure L) (F : ultrafilter I) : nonempty_Structure L :=\n{ dom := Ult \ud835\udd04 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 \ud835\udd04 F).fn f = product_fn F _ f := rfl\n\nlemma Structure_pr_eq {n} (r : L.pr n) : (product \ud835\udd04 F).pr r = product_pr F _ r := rfl\n\nvariables (\u03a6 : \u03a0 i, \u03bc \u2192 \ud835\udd04 i) (e : \u03a0 i, fin n \u2192 \ud835\udd04 i)\n\nlemma val_subterm (t : subterm L \u03bc n) :\n  subterm.val (product \ud835\udd04 F : Structure L) (\u03bb x, \u27e6\u03bb i, \u03a6 i x\u27e7*) (\u03bb x, \u27e6\u03bb i, e i x\u27e7*) t = \u27e6\u03bb i, subterm.val (\ud835\udd04 i) (\u03a6 i) (e i) t\u27e7* :=\nby induction t; simp[Structure_fn_eq, product_fn, *]\n\nprivate lemma concat_to_quo (u : \u03a0 i, \ud835\udd04 i) :\n  ((\u27e6u\u27e7* : Ult \ud835\udd04 F) *> \u03bb x, \u27e6\u03bb i, e i x\u27e7*) = \u03bb x, \u27e6\u03bb i, (u i *> e i) x\u27e7* :=\nby ext x; refine fin.cases _ _ x; simp\n\ntheorem subval_subformula : \u2200 {n} (e : \u03a0 i, fin n \u2192 \ud835\udd04 i) (p : subformula L \u03bc n),\n  subval (product \ud835\udd04 F : Structure L) (\u03bb x, \u27e6\u03bb i, \u03a6 i x\u27e7*) (\u03bb x, \u27e6\u03bb i, e i x\u27e7*) p \u2194 {i | subval (\ud835\udd04 i : Structure L) (\u03a6 i) (e i) p} \u2208 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, (\u2218)]\n| n e (imply p q)    :=\n    by simp[imply_eq, subval_subformula _ p, subval_subformula _ q, decidable.imp_iff_not_or,\n      \u2190ultrafilter.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' := \u03bb (u : \u03a0 i, \ud835\udd04 i), (\u03bb i, u i *> e i),\n      calc (\u2200 u : product \ud835\udd04 F, subval (product \ud835\udd04 F : Structure L) (\u03bb x, \u27e6\u03bb i, \u03a6 i x\u27e7*) (u *> \u03bb x, \u27e6\u03bb i, e i x\u27e7*) p)\n          \u2194 (\u2200 u : \u03a0 i, \ud835\udd04 i, subval (product \ud835\udd04 F : Structure L) (\u03bb x, \u27e6\u03bb i, \u03a6 i x\u27e7*) (\u03bb x, \u27e6\u03bb i, e' u i x\u27e7*) p)\n      : by { split,\n             { intros h u, simpa[e', concat_to_quo] using h \u27e6u\u27e7* },\n             { intros h u, induction u using fol.Ult.ind_on, simpa[concat_to_quo] using h u } }\n      ... \u2194 \u2200 u : \u03a0 i, \ud835\udd04 i, {i | subval (\ud835\udd04 i : Structure L) (\u03a6 i) (e' u i) p} \u2208 F\n      : by { exact forall_congr (\u03bb u, subval_subformula (e' u) p) }\n      ... \u2194 {i : I | \u2200 (x : \ud835\udd04 i), subval (\ud835\udd04 i : Structure L) (\u03a6 i) (x *> e i) p} \u2208 F\n      : by { simp[e'], split,\n            { intros h,\n              let u : \u03a0 i, \ud835\udd04 i := \u03bb i, classical.epsilon (\u03bb u, \u00acsubval \u2191(\ud835\udd04 i) (\u03a6 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 : \u00acsubval \u2191(\ud835\udd04 i) (\u03a6 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-- \u0141o\u015b's theorem\ntheorem fundamental_param (p : formula L \u03bc) (\u03a6 : \u2200 i, \u03bc \u2192 \ud835\udd04 i) :\n  val (product \ud835\udd04 F : Structure L) (\u03bb x, \u27e6\u03bb i, \u03a6 i x\u27e7*) p \u2194 {i | val (\ud835\udd04 i : Structure L) (\u03a6 i) p} \u2208 F :=\nby have := @subval_subformula L _ _ _ F _ \u03a6 _ (\u03bb i, fin.nil) p; exact cast (by congr) this\n\ntheorem fundamental {\u03c3 : sentence L} :\n  product \ud835\udd04 F \u22a7 \u03c3 \u2194 {i | \ud835\udd04 i \u22a7 \u03c3} \u2208 F :=\nby have := @fundamental_param L _ _ _ F \ud835\udd04 \u03c3 (\u03bb 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) // \u2191s \u2286 T}\n\nvariables {T : Theory L}\n\ndef finTheory.empty {T : Theory L} : finTheory T := \u27e8\u2205, by simp\u27e9\ninstance : inhabited (finTheory T) := \u27e8\u27e8\u2205, by simp\u27e9\u27e9\n\nnoncomputable def finTheory.insert (P : finTheory T) {\u03c3 : sentence L} (h : \u03c3 \u2208 T) : finTheory T :=\n\u27e8insert \u03c3 P.val, \u03bb x hx,  by { simp at hx, cases hx, simp[hx, h], refine P.property hx }\u27e9\n\n@[simp] lemma finTheory.insert_val (P : finTheory T) {\u03c3 : sentence L} (h : \u03c3 \u2208 T) :\n  (P.insert h).val = insert \u03c3 P.val := rfl\n\ninstance : has_coe (finTheory T) (Theory L) := \u27e8\u03bb s, {p | p \u2208 s.val}\u27e9\n\nnamespace compactness\nopen nonempty_Structure\n\nvariables (\ud835\udd04 : finTheory T \u2192 nonempty_Structure L) \n\ndef formdomain (p : sentence L) : set (finTheory T) := {i | \ud835\udd04 i \u22a7 p}\n\ndef F : set (set (finTheory T)) := {x | \u2203 p, T p \u2227 x = formdomain \ud835\udd04 p}\n\nprivate lemma finite_intersection_lmm (nonempty : \u2203 p, T p) (H : \u2200 (i : finTheory T) p, p \u2208 i.val \u2192 \ud835\udd04 i \u22a7 p) :\n  \u2200 S : finset (set (finTheory T)), (\u2191S : set (set (finTheory T))) \u2286 F \ud835\udd04 \u2192\n  \u2203 P : finTheory T,\n  (\u2200 p, p \u2208 P.val \u2192 formdomain \ud835\udd04 p \u2208 S) \u2227 (\u2200 S', S' \u2208 S \u2192 \u2203 p, p \u2208 P.val \u2227 S' = formdomain \ud835\udd04 p) :=\nbegin\n  intros S, induction S using finset.induction with i S i_fresh IH,\n  { intros _, simp[set.nonempty], rcases nonempty with \u27e8p\u2080, hyp_p\u2080\u27e9,\n    refine \u27e8\u27e8\u2205, by simp\u27e9, _\u27e9, unfold_coes, simp },\n  { intros h, simp at*,\n    have lmm\u2081 : \u2191S \u2286 F \ud835\udd04, from set.subset.trans (set.subset_insert _ _) h,\n    have : \u2203 (P : finTheory T),\n      (\u2200 p, p \u2208 \u2191P \u2192 formdomain \ud835\udd04 p \u2208 S) \u2227 (\u2200 S', S' \u2208 S \u2192 \u2203 p, p \u2208 \u2191P \u2227 S' = formdomain \ud835\udd04 p),\n    from IH lmm\u2081, rcases this with \u27e8P, IH\u2081, IH\u2082\u27e9,\n    have : \u2203 p, T p \u2227 i = formdomain \ud835\udd04 p, from h (set.mem_insert i \u2191S),\n    rcases this with \u27e8p, hyp_p, rfl\u27e9,\n    refine \u27e8P.insert hyp_p, _, _, _\u27e9; unfold_coes; simp,\n    { refine \u03bb q hyp_q, or.inr (IH\u2081 _ hyp_q) },\n    { refine \u27e8p, or.inl rfl, rfl\u27e9 },\n    { intros S' hyp_S',\n      have : \u2203 p, p \u2208 \u2191P \u2227 S' = formdomain \ud835\udd04 p, from IH\u2082 _ hyp_S', rcases this with \u27e8p, hyp, rfl\u27e9,\n      refine \u27e8p, or.inr hyp, rfl\u27e9 } }\nend\n\ntheorem finite_intersection (h : \u2203 p, T p) (H : \u2200 (i : finTheory T) p, p \u2208 i.val \u2192 \ud835\udd04 i \u22a7 p) :\n  \u2200 S : finset (set (finTheory T)), \n  (\u2191S : set (set (finTheory T))) \u2286 F \ud835\udd04 \u2192 (\u22c2\u2080 (\u2191S : set (set (finTheory T)))).nonempty :=\nbegin\n  intros S hS, have := finite_intersection_lmm _ h H S hS, rcases this with \u27e8P, hyp\u27e9,\n  refine \u27e8P, \u03bb S' hS', _\u27e9, \n  have := hyp.2 S' hS', rcases this with \u27e8p, hyp_p, rfl\u27e9, simp[formdomain] at*,\n  refine H _ _ hyp_p\nend\n\ntheorem ultrafilter_exists (h : \u2203 p, p \u2208 T) (H : \u2200 (i : finTheory T) p, p \u2208 i.val \u2192 \ud835\udd04 i \u22a7 p) :\n  \u2203 U : ultrafilter (finTheory T), F \ud835\udd04 \u2286 U.to_filter.sets :=\nultrafilter.exists_ultrafilter_of_finite_inter_nonempty _ (finite_intersection _ h H)\n\ntheorem compact (T : Theory L) :\n  Satisfiable T \u2194 \u2200 S : finset (sentence L), \u2191S \u2286 T \u2192 Satisfiable (S : Theory L) :=\n  \u27e8by { intros H S hyp_S, rcases H with \u27e8\ud835\udd04, hyp\u27e9,\n        refine \u27e8\ud835\udd04, \u03bb p h, hyp (hyp_S h)\u27e9 },\n   by { suffices : (\u2200 S : finTheory T, Satisfiable (\u2191S : Theory L)) \u2192 Satisfiable T,\n        { intros h, refine this (\u03bb S, _),\n          rcases h S.val S.property with \u27e8\ud835\udd04, hyp_\ud835\udd04\u27e9, refine \u27e8\ud835\udd04, hyp_\ud835\udd04\u27e9 },\n    intros H, by_cases C : T = \u2205,\n        { rcases C with rfl, refine \u27e8default, by intros p; simp\u27e9 },\n        { have ex : \u2203 p, p \u2208 T, { by_contra, simp at*, refine C _, { ext x, simp, refine h _ } }, \n          have : \u2203 (\ud835\udd04 : finTheory T \u2192 nonempty_Structure L), \u2200 (i : finTheory T) p, p \u2208 i.val \u2192 \ud835\udd04 i \u22a7 p,\n          from classical.skolem.mp H, rcases this with \u27e8\ud835\udd04, hyp_\ud835\udd04\u27e9,\n          have := @ultrafilter_exists _ _ \ud835\udd04 ex hyp_\ud835\udd04, rcases this with \u27e8U, hyp_U\u27e9,\n          refine \u27e8Ult.product \ud835\udd04 U, _\u27e9, intros p hyp_p, rw Ult.fundamental,\n          have : {i | \ud835\udd04 i \u22a7 p} \u2208 F \ud835\udd04, { refine \u27e8p, hyp_p, rfl\u27e9 },\n          exact hyp_U this } }\u27e9\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} (\u03b8 : X \u27f6 Y)\ninstance : strong_epi (factor_thru_image \u03b8) :=\nstrong_epi_factor_thru_image_of_strong_epi_mono_factorisation\n  (has_strong_epi_mono_factorisations.has_fac \u03b8).some\n\nlemma is_iso_of_epi_and_card [h\u03b8 : epi \u03b8] (h : X.len = Y.len) : is_iso \u03b8 :=\nbegin\n  apply is_iso_of_bijective,\n  split,\n  { by_contra h',\n    rw epi_iff_surjective at h\u03b8,\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\u03b8 h', },\n  { change function.surjective \u03b8.to_order_hom,\n    rw \u2190 epi_iff_surjective,\n    apply_instance, },\nend\n\nend\n\n--protected def rec {F : \u03a0 (X : simplex_category), Sort u} (h : \u2200 (n : \u2115), F [n]) :\n--  \u03a0 X, F X := \u03bb n, h n.len\n\nend simplex_category\n\nnamespace sSet\n\nlemma map_comp' (X : sSet) {\u0394\u2080 \u0394\u2081 \u0394\u2082 : simplex_category\u1d52\u1d56} (\u03b8 : \u0394\u2080 \u27f6 \u0394\u2081) (\u03b8' : \u0394\u2081 \u27f6 \u0394\u2082)\n  (x : X.obj \u0394\u2080) : X.map (\u03b8 \u226b \u03b8') x = X.map \u03b8' (X.map \u03b8 x) :=\ncongr_fun (X.map_comp \u03b8 \u03b8') x\n\nnamespace truncated\n\ndef i (n : \u2115) : truncated n \u2964 sSet.{u} :=\nLan simplex_category.truncated.inclusion.op\n\ndef adjunction (n : \u2115) : i n \u22a3 sk n :=\ncategory_theory.Lan.adjunction _ simplex_category.truncated.inclusion.op\n\ninstance adjunction.unit_is_iso (n : \u2115) : is_iso (adjunction n).unit :=\nLan.coreflective _ _\n\nend truncated\n\ndef sk' (n : \u2115) : sSet \u2964 sSet := sk n \u22d9 truncated.i n\n\ndef \u03b9_sk' (n : \u2115) : sk' n \u27f6 \ud835\udfed sSet := (truncated.adjunction n).counit\n\ninstance sk_\u03b9_sk'_is_iso (n : \u2115) : is_iso (whisker_right (\u03b9_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 \u226b 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 \u03b9_sk'_bij (X : sSet) (n : \u2115) (\u0394 : simplex_category\u1d52\u1d56) (h : \u0394.unop.len \u2264 n) :\n  is_iso (((\u03b9_sk' n).app X).app \u0394) :=\nbegin\n  induction \u0394 using opposite.rec,\n  have h' : \u2203 (\u0394' : simplex_category.truncated n), \u0394 = \u0394'.1 := \u27e8\u27e8\u0394, h\u27e9, rfl\u27e9,\n  cases h' with \u0394' h\u0394',\n  subst h\u0394',\n  let e := as_iso (whisker_right (\u03b9_sk' n) (sk n)),\n  exact is_iso.of_iso ((e.app X).app (opposite.op \u0394')),\nend\n\ndef simplex_is_degenerate {X : sSet} {\u0394 : simplex_category\u1d52\u1d56} (x : X.obj \u0394) : Prop :=\n\u2203 (\u0394' : simplex_category\u1d52\u1d56) (\u03b8 : \u0394' \u27f6 \u0394) (h\u03b8\u2081 : epi \u03b8.unop) (h\u03b8\u2082 : \u00acmono \u03b8.unop)\n  (y : X.obj \u0394'), x = X.map \u03b8 y\n\n@[simp]\ndef nondegenerate_simplices (X : sSet) (\u0394 : simplex_category\u1d52\u1d56) : set (X.obj \u0394) :=\ncompl simplex_is_degenerate\n\nlemma is_iso_of_nondegenerate_simplices {X : sSet} {\u0394 \u0394' : simplex_category\u1d52\u1d56}\n  (x : X.nondegenerate_simplices \u0394) (\u03b8 : \u0394' \u27f6 \u0394) (h\u03b8 : epi \u03b8.unop) (y : X.obj \u0394')\n  (hy : x.1 = X.map \u03b8 y) : is_iso \u03b8 :=\nbegin\n  suffices : is_iso \u03b8.unop,\n  { haveI := this,\n    change is_iso \u03b8.unop.op,\n    apply_instance, },\n  apply simplex_category.is_iso_of_bijective,\n  split,\n  { change function.injective \u03b8.unop.to_order_hom,\n    rw \u2190 simplex_category.mono_iff_injective,\n    by_contra,\n    exact x.2 \u27e8\u0394', \u03b8, h\u03b8, h, y, hy\u27e9, },\n  { change function.surjective \u03b8.unop.to_order_hom,\n    rw \u2190 simplex_category.epi_iff_surjective,\n    exact h\u03b8, },\nend\n\n@[simp]\ndef \u03b9_nondegenerate_simplices (X : sSet.{u}) (\u0394 : simplex_category\u1d52\u1d56) :\n  (X.nondegenerate_simplices \u0394 : Type u) \u27f6 X.obj \u0394 := subtype.val\n\nlemma zero_simplices_are_nondegenerate (X : sSet) : X.nondegenerate_simplices (op [0]) = \u22a4 :=\nbegin\n  ext,\n  split,\n  { intro h,\n    simp only [set.top_eq_univ], },\n  { intros h\u2080 h,\n    rcases h with \u27e8\u0394', \u03b8, h\u03b8\u2081, h\u03b8\u2082, y, hy\u27e9,\n    apply h\u03b8\u2082,\n    rw simplex_category.mono_iff_injective,\n    intros a\u2081 a\u2082 h,\n    rw [fin.eq_zero a\u2081, fin.eq_zero a\u2082], },\nend\n\nlemma is_epi_image_of_nondegenerate_simplex (X : sSet) {\u0394 : simplex_category\u1d52\u1d56} (x : X.obj \u0394) :\n  \u2203 (\u0394' : simplex_category\u1d52\u1d56) (\u03b8 : \u0394' \u27f6 \u0394) (h\u03b8 : epi \u03b8.unop) (y : X.obj \u0394')\n    (hy : y \u2208 X.nondegenerate_simplices \u0394'), x = X.map \u03b8 y :=\nbegin\n  induction \u0394 using opposite.rec,\n  induction \u0394 with n,\n  induction n using nat.strong_rec' with n hn,\n  cases n,\n  { refine \u27e8op [0], \ud835\udfd9 _, infer_instance, x, _, by simp only [functor_to_types.map_id_apply]\u27e9,\n    rw zero_simplices_are_nondegenerate,\n    simp only [set.top_eq_univ], },\n { by_cases x \u2208 X.nondegenerate_simplices (op [n.succ]),\n    { exact \u27e8_, \ud835\udfd9 _, infer_instance, x, h, by simp only [functor_to_types.map_id_apply]\u27e9, },\n    { dsimp [nondegenerate_simplices] at h,\n      simp only [set.not_not_mem] at h,\n      rcases h with \u27e8\u0394', \u03c0, h\u03c0\u2081, h\u03c0\u2082, y, hy\u27e9,\n      induction \u0394' using opposite.rec,\n      induction \u0394' with m,\n      have hm : m < n.succ,\n      { have h\u03c0\u2081' := (simplex_category.len_le_of_epi h\u03c0\u2081),\n        dsimp at h\u03c0\u2081',\n        cases h\u03c0\u2081'.lt_or_eq,\n        { assumption, },\n        { subst h,\n          exfalso,\n          apply h\u03c0\u2082,\n          rw simplex_category.mono_iff_injective,\n          rw simplex_category.epi_iff_surjective at h\u03c0\u2081,\n          rw finite.injective_iff_bijective at \u22a2,\n          rw finite.surjective_iff_bijective at h\u03c0\u2081,\n          assumption, }, },\n      rcases hn m hm y with \u27e8\u0394'', \u03b8, h\u03b8, z, hz, eq\u27e9,\n      haveI := h\u03c0\u2081,\n      haveI := h\u03b8,\n      refine \u27e8\u0394'', \u03b8 \u226b \u03c0, by { rw unop_comp, apply epi_comp, }, z, hz, _\u27e9,\n      simp only [functor_to_types.map_comp_apply, hy, eq], }, },\nend\n\n--lemma splitting.sum.concrete_bijective (N : \u2115 \u2192 Type u) (\u0394 : simplex_category\u1d52\u1d56) :\n--  function.bijective (limits.concrete.coproduct_map (simplicial_object.splitting.summand N \u0394) :\n--    sigma (simplicial_object.splitting.summand N \u0394) \u2192 simplicial_object.splitting.sum N \u0394) :=\n--limits.concrete.coproduct_map_bijective _\n\nlemma image_of_nondegenerate_simplex_uniqueness\u2080 (X : sSet)\n  {\u0394 \u0394\u2081 \u0394\u2082 : simplex_category\u1d52\u1d56} (y\u2081 : X.obj \u0394\u2081) (y\u2082 : X.obj \u0394\u2082)\n  (hy\u2081 : y\u2081 \u2208 X.nondegenerate_simplices \u0394\u2081)\n  (\u03b8\u2081 : \u0394\u2081 \u27f6 \u0394) (\u03b8\u2082 : \u0394\u2082 \u27f6 \u0394) (h\u03b8\u2081 : epi \u03b8\u2081.unop) (h\u03b8\u2082 : epi \u03b8\u2082.unop)\n  (eq : X.map \u03b8\u2081 y\u2081 = X.map \u03b8\u2082 y\u2082) : \u0394\u2081.unop.len \u2264 \u0394\u2082.unop.len :=\nbegin\n  haveI := is_split_epi_of_epi \u03b8\u2081.unop,\n  let f := section_ \u03b8\u2081.unop \u226b \u03b8\u2082.unop,\n  have eq\u2081 : y\u2081 = X.map f.op y\u2082,\n  { dsimp only [f],\n    rw [op_comp, X.map_comp', quiver.hom.op_unop, \u2190 eq, \u2190 X.map_comp'],\n    change _ = X.map (\u03b8\u2081.unop.op \u226b _) _,\n    rw [\u2190 op_comp, is_split_epi.id \u03b8\u2081.unop, op_id, X.map_id, types_id_apply], },\n  let F := limits.image.mono_factorisation f,\n  rw [\u2190 F.fac, op_comp, X.map_comp'] at eq\u2081,\n  haveI : epi F.e := by { simp only [limits.as_factor_thru_image], apply_instance, },\n  haveI he := is_iso_of_nondegenerate_simplices \u27e8y\u2081, hy\u2081\u27e9 F.e.op infer_instance _ eq\u2081,\n  haveI : is_iso F.e,\n  { change is_iso F.e.op.unop,\n    apply_instance, },\n  have hf : mono f,\n  { rw \u2190 F.fac,\n    apply mono_comp, },\n  exact simplex_category.len_le_of_mono hf,\nend\n\nlemma image_of_nondegenerate_simplex_uniqueness\u2081 (X : sSet)\n  {\u0394 \u0394\u2081 \u0394\u2082 : simplex_category\u1d52\u1d56} (y\u2081 : X.obj \u0394\u2081) (y\u2082 : X.obj \u0394\u2082)\n  (hy\u2081 : y\u2081 \u2208 X.nondegenerate_simplices \u0394\u2081) (hy\u2082 : y\u2082 \u2208 X.nondegenerate_simplices \u0394\u2082)\n  (\u03b8\u2081 : \u0394\u2081 \u27f6 \u0394) (\u03b8\u2082 : \u0394\u2082 \u27f6 \u0394) (h\u03b8\u2081 : epi \u03b8\u2081.unop) (h\u03b8\u2082 : epi \u03b8\u2082.unop)\n  (eq : X.map \u03b8\u2081 y\u2081 = X.map \u03b8\u2082 y\u2082) : \u0394\u2081 = \u0394\u2082 :=\nbegin\n  unfreezingI { induction \u0394\u2081 using opposite.rec, induction \u0394\u2082 using opposite.rec, },\n  congr,\n  ext,\n  apply le_antisymm,\n  { exact image_of_nondegenerate_simplex_uniqueness\u2080 X y\u2081 y\u2082 hy\u2081 \u03b8\u2081 \u03b8\u2082 h\u03b8\u2081 h\u03b8\u2082 eq, },\n  { exact image_of_nondegenerate_simplex_uniqueness\u2080 X y\u2082 y\u2081 hy\u2082 \u03b8\u2082 \u03b8\u2081 h\u03b8\u2082 h\u03b8\u2081 eq.symm, },\nend\n\nlemma image_of_nondegenerate_simplex_uniqueness\u2082 (X : sSet)\n  {\u0394 \u0394' : simplex_category\u1d52\u1d56} (y\u2081 : X.obj \u0394') (y\u2082 : X.obj \u0394')\n  (hy\u2081 : y\u2081 \u2208 X.nondegenerate_simplices \u0394') (hy\u2082 : y\u2082 \u2208 X.nondegenerate_simplices \u0394')\n  (\u03b8\u2081 : \u0394' \u27f6 \u0394) (\u03b8\u2082 : \u0394' \u27f6 \u0394) (h\u03b8\u2081 : epi \u03b8\u2081.unop) (h\u03b8\u2082 : epi \u03b8\u2082.unop)\n  (eq : X.map \u03b8\u2081 y\u2081 = X.map \u03b8\u2082 y\u2082) : y\u2081 = y\u2082 :=\nbegin\n  haveI := is_split_epi_of_epi \u03b8\u2081.unop,\n  let f := section_ \u03b8\u2081.unop \u226b \u03b8\u2082.unop,\n  have eq\u2081 : y\u2081 = X.map f.op y\u2082,\n  { dsimp only [f],\n    rw [op_comp, X.map_comp', quiver.hom.op_unop, \u2190 eq, \u2190 X.map_comp'],\n    change _ = X.map (\u03b8\u2081.unop.op \u226b _) _,\n    rw [\u2190 op_comp, is_split_epi.id \u03b8\u2081.unop, op_id, X.map_id, types_id_apply], },\n  have eq\u2082 := eq\u2081,\n  let F := limits.image.mono_factorisation f,\n  rw [\u2190 F.fac, op_comp, X.map_comp'] at eq\u2082,\n  haveI : epi F.e := by { simp only [limits.as_factor_thru_image], apply_instance, },\n  haveI he := is_iso_of_nondegenerate_simplices \u27e8y\u2081, hy\u2081\u27e9 F.e.op infer_instance _ eq\u2082,\n  haveI : is_iso F.e,\n  { change is_iso F.e.op.unop,\n    apply_instance, },\n  haveI : mono f,\n  { rw \u2190 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\u2081,\nend\n\nlemma ext_epi_of_sections {\u0394\u2081 \u0394\u2082 : simplex_category} (\u03b8\u2081 \u03b8\u2082 : \u0394\u2081 \u27f6 \u0394\u2082) [epi \u03b8\u2081]\n  (h : \u2200 (s : split_epi \u03b8\u2081), s.section_ \u226b \u03b8\u2082 = \ud835\udfd9 _) : \u03b8\u2081 = \u03b8\u2082 :=\nbegin\n  ext1, ext1, ext1 x,\n  have h\u2082 : \u2203 (s : split_epi \u03b8\u2081), s.section_.to_order_hom (\u03b8\u2081.to_order_hom x) = x,\n  { haveI := is_split_epi_of_epi \u03b8\u2081,\n    let \u03b1 : fin (\u0394\u2082.len+1) \u2192 fin (\u0394\u2081.len+1) := \u03bb y,\n      if (y = \u03b8\u2081.to_order_hom x) then x else (section_ \u03b8\u2081).to_order_hom y,\n    have h\u03b1 : \u2200 y, \u03b8\u2081.to_order_hom (\u03b1 y) = y,\n    { intro y,\n      dsimp [\u03b1],\n      split_ifs with h\u2081,\n      { rw \u2190 h\u2081, },\n      { have h\u2083 := congr_arg order_hom.to_fun (congr_arg simplex_category.hom.to_order_hom (is_split_epi.id \u03b8\u2081)),\n        exact congr_fun h\u2083 y, }, },\n    let \u03b2 : \u0394\u2082 \u27f6 \u0394\u2081 := simplex_category.hom.mk \u27e8\u03b1, begin\n      intros x\u2081 x\u2082,\n      contrapose,\n      intro h,\n      simp only [not_le] at h \u22a2,\n      suffices : x\u2082 \u2264 x\u2081,\n      { cases this.lt_or_eq with h\u2081 h\u2082,\n        { assumption, },\n        { exfalso,\n          simpa only [h\u2082, lt_self_iff_false] using h, }, },\n      simpa only [h\u03b1, order_hom.to_fun_eq_coe] using \u03b8\u2081.to_order_hom.monotone' h.le,\n    end\u27e9,\n    refine \u27e8\u27e8\u03b2, _\u27e9, _\u27e9,\n    { ext1, ext1, ext1 y,\n      apply h\u03b1, },\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\u2082 with \u27e8s, hs\u27e9,\n  rw \u2190 hs,\n  have eq := h s,\n  have h\u2083 := s.id',\n  simp only [auto_param_eq] at h\u2083,\n  rw \u2190 h\u2083 at eq,\n  have h\u2084 : (\u03b8\u2081 \u226b s.section_ \u226b \u03b8\u2081).to_order_hom x =\n    (\u03b8\u2081 \u226b s.section_ \u226b \u03b8\u2082).to_order_hom x := by rw eq,\n  exact h\u2084,\nend\n\nlemma image_of_nondegenerate_simplex_uniqueness\u2083 (X : sSet)\n  {\u0394 \u0394' : simplex_category\u1d52\u1d56} (y : X.obj \u0394')\n  (hy : y \u2208 X.nondegenerate_simplices \u0394')\n  (\u03b8\u2081 : \u0394' \u27f6 \u0394) (\u03b8\u2082 : \u0394' \u27f6 \u0394) (h\u03b8\u2081 : epi \u03b8\u2081.unop) (h\u03b8\u2082 : epi \u03b8\u2082.unop)\n  (eq : X.map \u03b8\u2081 y = X.map \u03b8\u2082 y) : \u03b8\u2081 = \u03b8\u2082 :=\nbegin\n  apply quiver.hom.unop_inj,\n  apply ext_epi_of_sections,\n  introI s,\n  let f := s.section_ \u226b \u03b8\u2082.unop,\n  change f = \ud835\udfd9 _,\n  have eq\u2081 : y = X.map f.op y,\n  { dsimp only [f],\n    rw [op_comp, X.map_comp', quiver.hom.op_unop, \u2190 eq, \u2190 X.map_comp'],\n    change _ = X.map (\u03b8\u2081.unop.op \u226b _) _,\n    rw [\u2190 op_comp, s.id, op_id, X.map_id, types_id_apply], },\n  let F := limits.image.mono_factorisation f,\n  rw [\u2190 F.fac, op_comp, X.map_comp'] at eq\u2081,\n  haveI : epi F.e := by { simp only [limits.as_factor_thru_image], apply_instance, },\n  haveI he := is_iso_of_nondegenerate_simplices \u27e8y, hy\u27e9 F.e.op infer_instance _ eq\u2081,\n  haveI : is_iso F.e,\n  { change is_iso F.e.op.unop,\n    apply_instance, },\n  haveI : mono f,\n  { rw \u2190 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}) (\u0394 : simplex_category\u1d52\u1d56) :\n  sigma (simplicial_object.splitting.summand\n    (\u03bb n, (X.nondegenerate_simplices (op [n]) : Type u)) \u0394) \u2192 X.obj \u0394 :=\n\u03bb s, X.map s.1.e.op s.2.1\n\nlemma splitting_map_bijective (X : sSet.{u}) (\u0394 : simplex_category\u1d52\u1d56) :\n  function.bijective (X.splitting_map \u0394) :=\nbegin\n  split,\n  { rintros \u27e8\u27e8\u0394\u2081, \u03b8\u2081, h\u03b8\u2081\u27e9, y\u2081, hy\u2081\u27e9 \u27e8\u27e8\u0394\u2082, \u03b8\u2082, h\u03b8\u2082\u27e9, y\u2082, hy\u2082\u27e9 eq,\n    induction \u0394\u2081 using opposite.rec,\n    induction \u0394\u2082 using opposite.rec,\n    have h\u2081 := X.image_of_nondegenerate_simplex_uniqueness\u2081 y\u2081 y\u2082 hy\u2081 hy\u2082 \u03b8\u2081.op \u03b8\u2082.op\n      h\u03b8\u2081 h\u03b8\u2082 eq,\n    simp only [simplex_category.mk_len, op_inj_iff, unop_op] at h\u2081,\n    subst h\u2081,\n    have h\u2082 := X.image_of_nondegenerate_simplex_uniqueness\u2082 y\u2081 y\u2082 hy\u2081 hy\u2082 \u03b8\u2081.op \u03b8\u2082.op\n      h\u03b8\u2081 h\u03b8\u2082 eq,\n    subst h\u2082,\n    have h\u2083 := X.image_of_nondegenerate_simplex_uniqueness\u2083 y\u2081 hy\u2081 \u03b8\u2081.op \u03b8\u2082.op h\u03b8\u2081 h\u03b8\u2082 eq,\n    have h\u2083' : \u03b8\u2081 = \u03b8\u2082 := by { apply quiver.hom.op_inj, exact h\u2083, },\n    subst h\u2083', },\n  { intro y,\n    rcases X.is_epi_image_of_nondegenerate_simplex y with \u27e8\u0394', \u03b8, h\u03b8, y, hy, eq\u27e9,\n    exact \u27e8\u27e8\u27e8\u0394', \u27e8\u03b8.unop, h\u03b8\u27e9\u27e9, \u27e8y, hy\u27e9\u27e9, eq.symm\u27e9, },\nend\n\n@[simps]\ndef splitting (X : sSet.{u}) : simplicial_object.splitting X :=\nbegin\n  let N : \u2115 \u2192 Type u := \u03bb n, X.nondegenerate_simplices (op [n]),\n  let \u03b9 : \u03a0 (n : \u2115), N n \u2192 X.obj (op [n]) := \u03bb n, subtype.val,\n  exact\n  { N := N,\n    \u03b9 := \u03b9,\n    map_is_iso' := \u03bb \u0394, begin\n      rw is_iso_iff_bijective,\n      let \u03b1 := X.splitting_map \u0394,\n      let \u03b2 := simplicial_object.splitting.map X \u03b9 \u0394,\n      let \u03b3 := concrete.coproduct_map (simplicial_object.splitting.summand N \u0394),\n      have h\u03b3 : function.bijective \u03b3 := concrete.coproduct_map_bijective _,\n      change function.bijective \u03b2,\n      have eq : \u03b2 \u2218 \u03b3 = \u03b1,\n      { ext s,\n        rcases s with \u27e8A, x\u27e9,\n        dsimp [\u03b1, \u03b2, \u03b3],\n        have h := comp_apply (simplicial_object.splitting.\u03b9_coprod N A)\n          (simplicial_object.splitting.map X \u03b9 \u0394) x,\n        simp only [concrete_category.has_coe_to_fun_Type,\n          simplicial_object.splitting.\u03b9_coprod, simplicial_object.splitting.map] at h,\n        erw [colimit.\u03b9_desc, cofan.mk_\u03b9_app] at h,\n        exact h.symm, },\n      rw [\u2190 function.bijective.of_comp_iff \u03b2 h\u03b3, 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 \u2192 Q` is a hypothesis, and the goal is `\u22a2 Q` then\n`apply h` changes the goal to `\u22a2 P`. \n\n## Details\n\nIf you have a function `h : P \u2192 Q` and your goal is `\u22a2 Q`\nthen `apply h` changes the goal to `\u22a2 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 \u2208 A, and we know that x \u2208 A \u2192 x \u2208 B and that x \u2208 B \u2192 x \u2208 C, then\nwe can deduce that x \u2208 C.\n-/\nlemma subset_transitive_basic (A B C : set X) (x : X) (hAB : x \u2208 A \u2192 x \u2208 B) (hBC : x \u2208 B \u2192 x \u2208 C) :\n  x \u2208 A \u2192 x \u2208 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 `\u03b1` to the type `\u03a3 a : A, B a \u27f9 \u03b1`, with `A : Type` and\n`B : A \u2192 typevec n`. They interact well with Lean's inductive definitions because\nthey guarantee that occurrences of `\u03b1` are positive.\n-/\n\n/--\nmultivariate polynomial functors\n-/\nstructure mvpfunctor (n : \u2115) \nwhere\n  A : Type u\n  B : A \u2192 typevec n\n\nnamespace mvpfunctor\n\n\n/-- Applying `P` to an object of `Type` -/\ndef obj {n : \u2115} (P : mvpfunctor n) (\u03b1 : typevec n) :=\n  sigma fun (a : A P) => typevec.arrow (B P a) \u03b1\n\n/-- Applying `P` to a morphism of `Type` -/\ndef map {n : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} {\u03b2 : typevec n} (f : typevec.arrow \u03b1 \u03b2) : obj P \u03b1 \u2192 obj P \u03b2 :=\n  fun (_x : obj P \u03b1) => sorry\n\nprotected instance inhabited {n : \u2115} : Inhabited (mvpfunctor n) :=\n  { default := mk Inhabited.default fun (_x : Inhabited.default) => Inhabited.default }\n\nprotected instance obj.inhabited {n : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} [Inhabited (A P)] [(i : fin2 n) \u2192 Inhabited (\u03b1 i)] : Inhabited (obj P \u03b1) :=\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 : \u2115} (P : mvpfunctor n) : mvfunctor (obj P) :=\n  mvfunctor.mk (map P)\n\ntheorem map_eq {n : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} {\u03b2 : typevec n} (g : typevec.arrow \u03b1 \u03b2) (a : A P) (f : typevec.arrow (B P a) \u03b1) : mvfunctor.map g (sigma.mk a f) = sigma.mk a (typevec.comp g f) :=\n  rfl\n\ntheorem id_map {n : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} (x : obj P \u03b1) : 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) \u03b1) =>\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 : \u2115} (P : mvpfunctor n) {\u03b1 : typevec n} {\u03b2 : typevec n} {\u03b3 : typevec n} (f : typevec.arrow \u03b1 \u03b2) (g : typevec.arrow \u03b2 \u03b3) (x : obj P \u03b1) : mvfunctor.map (typevec.comp g f) x = mvfunctor.map g (mvfunctor.map f x) := sorry\n\nprotected instance obj.is_lawful_mvfunctor {n : \u2115} (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 : \u2115) (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 : \u2115) {A : Type u} (x : A) {\u03b1 : typevec n} : obj (const n A) \u03b1 :=\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 : \u2115} {A : Type u} {\u03b1 : typevec n} (x : obj (const n A) \u03b1) : A :=\n  sigma.fst x\n\n@[simp] theorem const.get_map {n : \u2115} {A : Type u} {\u03b1 : typevec n} {\u03b2 : typevec n} (f : typevec.arrow \u03b1 \u03b2) (x : obj (const n A) \u03b1) : 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) \u03b1) =>\n      Eq.refl (const.get (mvfunctor.map f (sigma.mk x_fst x_snd)))\n\n@[simp] theorem const.get_mk {n : \u2115} {A : Type u} {\u03b1 : 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 : \u2115} {A : Type u} {\u03b1 : typevec n} (x : obj (const n A) \u03b1) : const.mk n (const.get x) = x := sorry\n\n/-- Functor composition on polynomial functors -/\ndef comp {n : \u2115} {m : \u2115} (P : mvpfunctor n) (Q : fin2 n \u2192 mvpfunctor m) : mvpfunctor m :=\n  mk (sigma fun (a\u2082 : A P) => (i : fin2 n) \u2192 B P a\u2082 i \u2192 A (Q i))\n    fun (a : sigma fun (a\u2082 : A P) => (i : fin2 n) \u2192 B P a\u2082 i \u2192 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 : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m} {\u03b1 : typevec m} (x : obj P fun (i : fin2 n) => obj (Q i) \u03b1) : obj (comp P Q) \u03b1 :=\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 : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m} {\u03b1 : typevec m} (x : obj (comp P Q) \u03b1) : obj P fun (i : fin2 n) => obj (Q i) \u03b1 :=\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 : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m} {\u03b1 : typevec m} {\u03b2 : typevec m} (f : typevec.arrow \u03b1 \u03b2) (x : obj (comp P Q) \u03b1) : comp.get (mvfunctor.map f x) = mvfunctor.map (fun (i : fin2 n) (x : obj (Q i) \u03b1) => 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) \u03b1) =>\n      Eq.refl (comp.get (mvfunctor.map f (sigma.mk x_fst x_snd)))\n\n@[simp] theorem comp.get_mk {n : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m} {\u03b1 : typevec m} (x : obj P fun (i : fin2 n) => obj (Q i) \u03b1) : comp.get (comp.mk x) = x := sorry\n\n@[simp] theorem comp.mk_get {n : \u2115} {m : \u2115} {P : mvpfunctor n} {Q : fin2 n \u2192 mvpfunctor m} {\u03b1 : typevec m} (x : obj (comp P Q) \u03b1) : comp.mk (comp.get x) = x := sorry\n\n/-\nlifting predicates and relations\n-/\n\ntheorem liftp_iff {n : \u2115} {P : mvpfunctor n} {\u03b1 : typevec n} (p : {i : fin2 n} \u2192 \u03b1 i \u2192 Prop) (x : obj P \u03b1) : mvfunctor.liftp p x \u2194\n  \u2203 (a : A P), \u2203 (f : typevec.arrow (B P a) \u03b1), x = sigma.mk a f \u2227 \u2200 (i : fin2 n) (j : B P a i), p (f i j) := sorry\n\ntheorem liftp_iff' {n : \u2115} {P : mvpfunctor n} {\u03b1 : typevec n} (p : {i : fin2 n} \u2192 \u03b1 i \u2192 Prop) (a : A P) (f : typevec.arrow (B P a) \u03b1) : mvfunctor.liftp p (sigma.mk a f) \u2194 \u2200 (i : fin2 n) (x : B P a i), p (f i x) := sorry\n\ntheorem liftr_iff {n : \u2115} {P : mvpfunctor n} {\u03b1 : typevec n} (r : {i : fin2 n} \u2192 \u03b1 i \u2192 \u03b1 i \u2192 Prop) (x : obj P \u03b1) (y : obj P \u03b1) : mvfunctor.liftr r x y \u2194\n  \u2203 (a : A P),\n    \u2203 (f\u2080 : typevec.arrow (B P a) \u03b1),\n      \u2203 (f\u2081 : typevec.arrow (B P a) \u03b1),\n        x = sigma.mk a f\u2080 \u2227 y = sigma.mk a f\u2081 \u2227 \u2200 (i : fin2 n) (j : B P a i), r (f\u2080 i j) (f\u2081 i j) := sorry\n\ntheorem supp_eq {n : \u2115} {P : mvpfunctor n} {\u03b1 : typevec n} (a : A P) (f : typevec.arrow (B P a) \u03b1) (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 : \u2115} (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 : \u2115} (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 : \u2115} (P : mvpfunctor (n + 1)) {\u03b1 : typevec n} {\u03b2 : Type u_1} {a : A P} (f' : typevec.arrow (B (drop P) a) \u03b1) (f : pfunctor.B (last P) a \u2192 \u03b2) : typevec.arrow (B P a) (\u03b1 ::: \u03b2) :=\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": "import Smt\n\ndef curryAdd : Int \u2192 Int \u2192 Int := Int.add\n\nexample (a b : Int) : curryAdd a b = curryAdd b a := by\n  smt [curryAdd]\n  sorry\n\ndef partCurryAdd (a : Int) : Int \u2192 Int := Int.add a\n\nexample (a b : Int) : partCurryAdd a b = partCurryAdd b a := by\n  smt [partCurryAdd]\n  sorry\n\nexample (a b : Int)\n    : let partCurryAdd' := fun a => Int.add a;\n    partCurryAdd' a b = partCurryAdd' b a := by\n  intro partCurryAdd'\n  smt [partCurryAdd']\n  sorry\n\nset_option linter.unusedVariables false in\ndef mismatchNamesAdd : \u2200 (a b : Int), Int := fun c d => c + d\n\nexample (a b : Int) : mismatchNamesAdd a b = mismatchNamesAdd b a := by\n  smt [mismatchNamesAdd]\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/Int/Binders.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6442251064863697, "lm_q1q2_score": 0.4649650939328839}}
{"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| \u03b9   : (n : Nat) \u2192 A\n| mid : (x y : A) \u2192 (p : lt' x y) \u2192 A\n\niit lt' : (x : A) \u2192 (y : A) \u2192 Type\n| \u03b9'    : (m n : Nat) \u2192 (p : m < n) \u2192 lt' (A.\u03b9 m) (A.\u03b9 n)\n| mid_l : (x y : A) \u2192 (p : lt' x y) \u2192 lt' x (A.mid x y p)\n| mid_r : (x y : A) \u2192 (p : lt' x y) \u2192 lt' (A.mid x y p) y\n-/\n\nmutual\ninductive A\u2091 : Type 1\n| \u03b9\u2091   : Nat \u2192 A\u2091\n| mid\u2091 : (x y : A\u2091) \u2192 (p : lt'\u2091) \u2192 A\u2091\n\n\ninductive lt'\u2091 : Type 1\n| \u03b9'\u2091 : (m n : Nat) \u2192 (p : m < n) \u2192 lt'\u2091\n| mid_l\u2091 : (x y : A\u2091) \u2192 (p : lt'\u2091) \u2192 lt'\u2091\n| mid_r\u2091 : (x y : A\u2091) \u2192 (p : lt'\u2091) \u2192 lt'\u2091\nend\n\nopen A\u2091 lt'\u2091\n\nmutual\ninductive A_w : A\u2091 \u2192 Prop\n| \u03b9_w : \u2200 n, A_w (\u03b9\u2091 n)\n| mid_w : \u2200 {x}, A_w x \u2192 \u2200 {y}, A_w y \u2192 \u2200 {p}, lt'_w x y p \u2192 A_w (mid\u2091 x y p)\n\ninductive lt'_w : A\u2091 \u2192 A\u2091 \u2192 lt'\u2091 \u2192 Prop\n| \u03b9'_w : \u2200 m n p, lt'_w (\u03b9\u2091 m) (\u03b9\u2091 n) (\u03b9'\u2091 m n p)\n| mid_l_w : \u2200 {x}, A_w x \u2192 \u2200 {y}, A_w y \u2192 \u2200 {p}, lt'_w x y p \n    \u2192 lt'_w x (mid\u2091 x y p) (mid_l\u2091 x y p)\n| mid_r_w : \u2200 {x}, A_w x \u2192 \u2200 {y}, A_w y \u2192 \u2200 {p}, lt'_w x y p \n    \u2192 lt'_w (mid\u2091 x y p) y (mid_r\u2091 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 \u03b9 : Nat \u2192 A := fun n => \u27e8\u03b9\u2091 n, \u03b9_w n\u27e9\ndef mid (x y : A) (p : lt' x y) : A := \u27e8mid\u2091 x.1 y.1 p.1, mid_w x.2 y.2 p.2\u27e9 \ndef \u03b9' (m n : Nat) (p : m < n) : lt' (\u03b9 m) (\u03b9 n) := \u27e8\u03b9'\u2091 m n p, \u03b9'_w m n p\u27e9\ndef mid_l (x y : A) (p : lt' x y) : lt' x (mid x y p) :=\n  \u27e8mid_l\u2091 x.1 y.1 p.1, mid_l_w x.2 y.2 p.2\u27e9\ndef mid_r (x y : A) (p : lt' x y) : lt' (mid x y p) y :=\n  \u27e8mid_r\u2091 x.1 y.1 p.1, mid_r_w x.2 y.2 p.2\u27e9\n\nsection\nvariable\n  (A\u2098     : A \u2192 Type 1)\n  (lt'\u2098   : \u2200 {x}, A\u2098 x \u2192 \u2200 {y}, A\u2098 y \u2192 lt' x y \u2192 Type 1)\n  (\u03b9\u2098     : \u2200 n, A\u2098 (\u03b9 n))\n  (mid\u2098   : \u2200 {x}, (x\u2098 : A\u2098 x) \u2192 \u2200 {y}, (y\u2098 : A\u2098 y) \u2192 \u2200 {p}, (p\u2098 : lt'\u2098 x\u2098 y\u2098 p) \u2192 A\u2098 (mid x y p))\n  (\u03b9'\u2098    : \u2200 m n p, lt'\u2098 (\u03b9\u2098 m) (\u03b9\u2098 n) (\u03b9' m n p))\n  (mid_l\u2098 : \u2200 {x}, (x\u2098 : A\u2098 x) \u2192 \u2200 {y}, (y\u2098 : A\u2098 y) \u2192 \u2200 {p}, (p\u2098 : lt'\u2098 x\u2098 y\u2098 p)\n    \u2192 lt'\u2098 x\u2098 (mid\u2098 x\u2098 y\u2098 p\u2098) (mid_l x y p))\n  (mid_r\u2098 : \u2200 {x}, (x\u2098 : A\u2098 x) \u2192 \u2200 {y}, (y\u2098 : A\u2098 y) \u2192 \u2200 {p}, (p\u2098 : lt'\u2098 x\u2098 y\u2098 p)\n    \u2192 lt'\u2098 (mid\u2098 x\u2098 y\u2098 p\u2098) y\u2098 (mid_r x y p))\n\nmutual\ninductive A\u1d63 : (x : A) \u2192 A\u2098 x \u2192 Type 1\n| \u03b9\u1d63 : \u2200 n, A\u1d63 (\u03b9 n) (\u03b9\u2098 n)\n| mid\u1d63 : \u2200 {x} {x\u2098 : A\u2098 x}, A\u1d63 x x\u2098 \u2192\n           \u2200 {y} {y\u2098 : A\u2098 y}, A\u1d63 y y\u2098 \u2192\n             \u2200 {p} {p\u2098 : lt'\u2098 x\u2098 y\u2098 p}, lt'\u1d63 x\u2098 y\u2098 p p\u2098 \u2192 A\u1d63 (mid x y p) (mid\u2098 x\u2098 y\u2098 p\u2098)\n\ninductive lt'\u1d63 : {x : A} \u2192 (x\u2098 : A\u2098 x) \u2192 {y : A} \u2192 (y\u2098 : A\u2098 y) \u2192 (p : lt' x y) \u2192 lt'\u2098 x\u2098 y\u2098 p \u2192 Type 1\n| \u03b9'\u1d63 : \u2200 m n p, lt'\u1d63 (\u03b9\u2098 m) (\u03b9\u2098 n) (\u03b9' m n p) (\u03b9'\u2098 m n p)\n| mid_l\u1d63 : \u2200 {x} {x\u2098 : A\u2098 x}, A\u1d63 x x\u2098 \u2192\n             \u2200 {y} {y\u2098 : A\u2098 y}, A\u1d63 y y\u2098 \u2192\n               \u2200 {p} {p\u2098 : lt'\u2098 x\u2098 y\u2098 p}, lt'\u1d63 x\u2098 y\u2098 p p\u2098 \u2192\n                 lt'\u1d63 x\u2098 (mid\u2098 x\u2098 y\u2098 p\u2098) (mid_l x y p) (mid_l\u2098 x\u2098 y\u2098 p\u2098)\n| mid_r\u1d63 : \u2200 {x} {x\u2098 : A\u2098 x}, A\u1d63 x x\u2098 \u2192\n             \u2200 {y} {y\u2098 : A\u2098 y}, A\u1d63 y y\u2098 \u2192\n               \u2200 {p} {p\u2098 : lt'\u2098 x\u2098 y\u2098 p}, lt'\u1d63 x\u2098 y\u2098 p p\u2098 \u2192\n                 lt'\u1d63 (mid\u2098 x\u2098 y\u2098 p\u2098) y\u2098 (mid_r x y p) (mid_r\u2098 x\u2098 y\u2098 p\u2098)\nend\n\nopen A\u1d63 lt'\u1d63\n\nstructure PSigmaUnique {\u03b1 : Type _} (\u03b2 : \u03b1 \u2192 Type _) :=\n  fst : \u03b1\n  snd : \u03b2 fst\n  unique : \u2200 {a}, \u03b2 a \u2192 a = fst\n\nnoncomputable def A_tot (x : A) : PSigmaUnique (A\u1d63 A\u2098 lt'\u2098 \u03b9\u2098 mid\u2098 \u03b9'\u2098 mid_l\u2098 mid_r\u2098 x) := by\n  cases x with | mk x\u2091 x_w => ?_\n  apply A\u2091.recOn x\u2091\n    (motive_1 := fun x\u2091 => \u2200 x_w, PSigmaUnique (A\u1d63 A\u2098 lt'\u2098 \u03b9\u2098 mid\u2098 \u03b9'\u2098 mid_l\u2098 mid_r\u2098 \u27e8x\u2091, x_w\u27e9))\n    (motive_2 := fun p\u2091 => \u2200 {x x\u2098} (x\u1d63 : A\u1d63 A\u2098 lt'\u2098 \u03b9\u2098 mid\u2098 \u03b9'\u2098 mid_l\u2098 mid_r\u2098 x x\u2098)\n                  {y y\u2098} (y\u1d63 : A\u1d63 A\u2098 lt'\u2098 \u03b9\u2098 mid\u2098 \u03b9'\u2098 mid_l\u2098 mid_r\u2098 y y\u2098)\n                   p_w, PSigmaUnique (lt'\u1d63 A\u2098 lt'\u2098 \u03b9\u2098 mid\u2098 \u03b9'\u2098 mid_l\u2098 mid_r\u2098 x\u2098 y\u2098 \u27e8p\u2091, p_w\u27e9))\n  skip\n  \u00b7 intro n _\n    exact \u27e8\u03b9\u2098 n, \u03b9\u1d63 n, fun {x\u2098} x\u1d63 => by cases x\u1d63; rfl\u27e9\n  \u00b7 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\u2098 x\u1d63 x_unique => ?_\n    cases y_ih y_w with | mk y\u2098 y\u1d63 y_unique => ?_\n    cases p_ih x\u1d63 y\u1d63 p_w with | mk p\u2098 p\u1d63 p_unique => ?_\n    exact \u27e8mid\u2098 x\u2098 y\u2098 p\u2098, mid\u1d63 x\u1d63 y\u1d63 p\u1d63, fun {z\u2098} z\u1d63 => by \n      cases z\u1d63 with | @mid\u1d63 x' x'\u2098 x'\u1d63 y' y'\u2098 y'\u1d63 p' p'\u2098 p'\u1d63 => ?_\n      cases x_unique x'\u1d63\n      cases y_unique y'\u1d63\n      cases p_unique p'\u1d63\n      rfl \u27e9\n  \u00b7 intro m n p x x\u2098 x\u1d63 y y\u2098 y\u1d63 ctor_w\n    cases x with | mk x\u2091 x_w => ?_\n    cases y with | mk y\u2091 y_w => ?_\n    simp only at ctor_w\n    clarifyIndices ctor_w\n    cases x\u1d63\n    cases y\u1d63\n    exact \u27e8\u03b9'\u2098 m n p, \u03b9'\u1d63 m n p, fun {q\u2098} q\u1d63 => by\n      cases q\u1d63\n      rfl \u27e9\n  \u00b7 intro y\u2091 z\u2091 p\u2091 y_ih z_ih p_ih x' x'\u2098 x'\u1d63 y' y'\u2098 y'\u1d63 ctor_w\n    cases x' with | mk x'\u2091 x'_w => ?_\n    cases y' with | mk y'\u2091 y'_w => ?_\n    simp only at ctor_w\n    clarifyIndices ctor_w\n    cases y'\u1d63 with | @mid\u1d63 x'' x''\u2098 x''\u1d63 y'' y''\u2098 y''\u1d63 p'' p''\u2098 p''\u1d63 => ?_\n    simp only at ctor_w\n    cases x'' with | mk x''\u2091 x''_w => ?_\n    cases y'' with | mk y''\u2091 y''_w => ?_\n    cases p'' with | mk p''\u2091 p''_w => ?_\n    clarifyIndices ctor_w\n    simp only at ctor_w\n    cases y_ih x''_w with | mk x'''\u2098 x'''\u1d63 x'''_unique => ?_\n    cases z_ih y''_w with | mk y'''\u2098 y'''\u1d63 y'''_unique => ?_\n    cases p_ih x'''\u1d63 y'''\u1d63 p''_w with | mk p'''\u2098 p'''\u1d63 p'''_unique => ?_\n    simp only at *\n    cases x'''_unique x'\u1d63\n    cases x'''_unique x''\u1d63\n    cases y'''_unique y''\u1d63\n    cases p'''_unique p''\u1d63\n    exact \u27e8mid_l\u2098 _ _ _, mid_l\u1d63 x''\u1d63 y''\u1d63 p''\u1d63, fun {q\u2098} q\u1d63 => by\n      match q\u1d63 with\n      | mid_l\u1d63 x'''\u1d63 y'''\u1d63 p'''\u1d63 => skip \u27e9\n  \n    \nnoncomputable def Ty_tot (\u0393 : Con) (A : Ty \u0393) :\n  PSigma (Ty\u1d63 Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 (Con_tot Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393).1 A) := by\n  cases \u0393 with | mk \u0393\u2091 \u0393_w => ?_\n  cases A with | mk A\u2091 A_w => ?_\n  apply Ty\u2091.recOn A\u2091\n    (motive_1 := fun \u0393\u2091 => \u2200 \u0393_w, PSigma (Con\u1d63 Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u27e8\u0393\u2091, \u0393_w\u27e9))\n    (motive_2 := fun A\u2091 => \u2200 {\u0393 \u0393\u2098} (\u0393\u1d63 : Con\u1d63 Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393 \u0393\u2098)\n                   A_w, PSigma (Ty\u1d63 Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393\u2098 \u27e8A\u2091, A_w\u27e9))\n  \u00b7 intro \u0393_w\n    exact PSigma.mk nil\u2098 nil\u1d63\n  \u00b7 intro \u0394\u2091 A\u2091 \u0394_ih A_ih ctor_w\n    inversion ctor_w with \u0394_w A_w\n    cases \u0394_ih \u0394_w with | mk \u0394\u2098 \u0394\u1d63 => ?_\n    cases A_ih \u0394\u1d63 A_w with | mk A\u2098 A\u1d63 => ?_\n    exact PSigma.mk (ext\u2098 \u0394\u2098 A\u2098) (ext\u1d63 \u0394\u1d63 A\u1d63)\n  \u00b7 intro \u0393\u2091 \u0393_ih \u0394 \u0394\u2098 \u0394\u1d63 ctor_w\n    cases \u0394 with | mk \u0394\u2091 \u0394_w => ?_\n    simp only at ctor_w\n    clarifyIndices ctor_w\n    exact PSigma.mk (base\u2098 \u0394\u2098) (base\u1d63 \u0394\u1d63)\n  \u00b7 intro \u0394\u2091 A\u2091 B\u2091 \u0394_ih A_ih B_ih \u0394' \u0394'\u2098 \u0394'\u1d63 ctor_w\n    cases \u0394' with | mk \u0394'\u2091 \u0394_w => ?_\n    simp only at ctor_w\n    clarifyIndices ctor_w\n    inversion ctor_w with \u0394_w A_w B_w\n    cases A_ih \u0394'\u1d63 A_w with | mk A\u2098 A\u1d63 => ?_\n    cases B_ih (ext\u1d63 \u0394'\u1d63 A\u1d63) B_w with | mk B\u2098 B\u1d63 => ?_ \n    exact PSigma.mk (pi\u2098 \u0394'\u2098 A\u2098 B\u2098) (pi\u1d63 \u0394'\u1d63 A\u1d63 B\u1d63)\n  \u00b7 exact (Con_tot Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u27e8\u0393\u2091, \u0393_w\u27e9).2\n\nnoncomputable def Con.rec (\u0393 : Con) : Con\u2098 \u0393 :=\n(Con_tot Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393).1\n\nnoncomputable def Ty.rec (\u0393 : Con) (A : Ty \u0393) : Ty\u2098 (Con.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393) A :=\n(Ty_tot Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393 A).1\n\ntheorem nil_beta : Con.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 nil = nil\u2098 :=\nrfl\n\ntheorem ext_beta (\u0393 : Con) (A : Ty \u0393) :\n  Con.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 (ext \u0393 A) \n  = ext\u2098 (Con.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393)\n    (Ty.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393 A) :=\nrfl\n\ntheorem base_beta (\u0393 : Con) :\n  Ty.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393 (base \u0393)\n  = base\u2098 (Con.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393) :=\nrfl\n\ntheorem pi_beta (\u0393 : Con) (A : Ty \u0393) (B : Ty (ext \u0393 A)) :\n  Ty.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393 (pi \u0393 A B)\n  = pi\u2098 (Con.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393)\n      (Ty.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 \u0393 A)\n      (Ty.rec Con\u2098 Ty\u2098 nil\u2098 ext\u2098 base\u2098 pi\u2098 (ext \u0393 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 \u226b 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 \u27f6 Q) : Prop :=\n(epi : epi f)\n(llp : \u2200 \u2983X Y : C\u2984 (z : X \u27f6 Y) [mono z], has_lifting_property f z)\n\nlemma strong_epi.mk' {f : P \u27f6 Q} [epi f]\n  (hf : \u2200 (X Y : C) (z : X \u27f6 Y) (hz : mono z) (u : P \u27f6 X) (v : Q \u27f6 Y)\n    (sq : comm_sq u f z v), sq.has_lift) : strong_epi f :=\n{ epi := infer_instance,\n  llp := \u03bb X Y z hz, \u27e8\u03bb u v sq, hf X Y z hz u v sq\u27e9, }\n\n/-- A strong monomorphism `f` is a monomorphism which has the right lifting property\nwith respect to epimorphisms. -/\nclass strong_mono (f : P \u27f6 Q) : Prop :=\n(mono : mono f)\n(rlp : \u2200 \u2983X Y : C\u2984 (z : X \u27f6 Y) [epi z], has_lifting_property z f)\n\nlemma strong_mono.mk' {f : P \u27f6 Q} [mono f]\n  (hf : \u2200 (X Y : C) (z : X \u27f6 Y) (hz : epi z) (u : X \u27f6 P) (v : Y \u27f6 Q)\n    (sq : comm_sq u z f v), sq.has_lift) : strong_mono f :=\n{ mono := infer_instance,\n  rlp := \u03bb X Y z hz, \u27e8\u03bb u v sq, hf X Y z hz u v sq\u27e9, }\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 \u27f6 Q) [strong_epi f] : epi f := strong_epi.epi\n\n@[priority 100]\ninstance mono_of_strong_mono (f : P \u27f6 Q) [strong_mono f] : mono f := strong_mono.mono\n\nsection\nvariables {R : C} (f : P \u27f6 Q) (g : Q \u27f6 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 \u226b 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 \u226b g) :=\n{ mono := mono_comp _ _,\n  rlp := by { introsI, apply_instance, }, }\n\n/-- If `f \u226b g` is a strong epimorphism, then so is `g`. -/\nlemma strong_epi_of_strong_epi [strong_epi (f \u226b 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\u2080 : (f \u226b u) \u226b z = (f \u226b g) \u226b v, by simp only [category.assoc, sq.w],\n    exact comm_sq.has_lift.mk' \u27e8(comm_sq.mk h\u2080).lift,\n      by simp only [\u2190 cancel_mono z, category.assoc, comm_sq.fac_right, sq.w], by simp\u27e9,\n  end, }\n\n/-- If `f \u226b 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 := \u03bb 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 := \u03bb X Y z hz, has_lifting_property.of_right_iso _ _, }\n\nlemma strong_epi.of_arrow_iso {A B A' B' : C} {f : A \u27f6 B} {g : A' \u27f6 B'}\n  (e : arrow.mk f \u2245 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 := \u03bb 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 \u27f6 B} {g : A' \u27f6 B'}\n  (e : arrow.mk f \u2245 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 := \u03bb 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 \u27f6 B} {g : A' \u27f6 B'}\n  (e : arrow.mk f \u2245 arrow.mk g) : strong_epi f \u2194 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 \u27f6 B} {g : A' \u27f6 B'}\n  (e : arrow.mk f \u2245 arrow.mk g) : strong_mono f \u2194 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 \u27f6 Q) [mono f] [strong_epi f] : is_iso f :=\n\u27e8\u27e8(comm_sq.mk (show \ud835\udfd9 P \u226b f = f \u226b \ud835\udfd9 Q, by simp)).lift, by tidy\u27e9\u27e9\n\n/-- A strong monomorphism that is an epimorphism is an isomorphism. -/\nlemma is_iso_of_epi_of_strong_mono (f : P \u27f6 Q) [epi f] [strong_mono f] : is_iso f :=\n\u27e8\u27e8(comm_sq.mk (show \ud835\udfd9 P \u226b f = f \u226b \ud835\udfd9 Q, by simp)).lift, by tidy\u27e9\u27e9\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 : \u2200 {X Y : C} (f : X \u27f6 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 : \u2200 {X Y : C} (f : X \u27f6 Y) [mono f], strong_mono f)\n\nend\n\nlemma strong_epi_of_epi [strong_epi_category C] (f : P \u27f6 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 \u27f6 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 := \u03bb _ _ _ _ _, 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 := \u03bb _ _ _ _ _, 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.\u03c0 f)`, and\n* `abelian.coimage f` is `cokernel (kernel.\u03b9 f)`.\n\n## Main results\n\n* In an abelian category, mono + epi = iso.\n* If `f : X \u27f6 Y`, then the map `factor_thru_image f : X \u27f6 image f` is an epimorphism, and the map\n  `factor_thru_coimage f : coimage f \u27f6 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 \u2245 limits.image f`.\n  * the canonical morphism `coimage_image_comparison : coimage f \u27f6 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 \u27f6 Y) : MonoFactorisation f\n    where\n  i := Abelian.image f\n  m := kernel.\u03b9 _\n  m_mono := inferInstance\n  e := kernel.lift _ f (cokernel.condition _)\n  fac := kernel.lift_\u03b9 _ _ _\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 \u27f6 Y) :\n    (imageMonoFactorisation f).e = cokernel.\u03c0 _ \u226b Abelian.coimageImageComparison f :=\n  by\n  ext\n  simp only [abelian.coimage_image_comparison, image_mono_factorisation_e, category.assoc,\n    cokernel.\u03c0_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 \u27f6 Y) [IsIso (Abelian.coimageImageComparison f)] :\n    ImageFactorisation f where\n  f := imageMonoFactorisation f\n  IsImage :=\n    { lift := fun F => inv (Abelian.coimageImageComparison f) \u226b cokernel.desc _ F.e F.kernel_\u03b9_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.\u03c0_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 \u27f6 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 \u27f6 Y) [Epi f] : IsIso (imageMonoFactorisation f).m :=\n  by\n  dsimp\n  infer_instance\n\nvariable [\u2200 {X Y : C} (f : X \u27f6 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 := \u27e8imageFactorisation f\u27e9 } }\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.\u03c0 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 _ _ \u226b inv (image_mono_factorisation f).e) aux _\n        \u00b7 intro A g hg\n          rw [kernel_fork.\u03b9_of_\u03b9] at hg\n          rw [\u2190 cancel_mono f, hg, \u2190 aux, kernel_fork.\u03b9_of_\u03b9]\n        \u00b7 intro A\n          simp only [kernel_fork.\u03b9_of_\u03b9, category.assoc]\n          convert limit.lift_\u03c0 _ _ 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.\u03b9 _\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 \u226b\n                inv (abelian.coimage_image_comparison f) \u226b colimit.desc _ _)\n            aux _\n        \u00b7 intro A g hg\n          rw [cokernel_cofork.\u03c0_of_\u03c0] at hg\n          rw [\u2190 cancel_epi f, hg, \u2190 aux, cokernel_cofork.\u03c0_of_\u03c0]\n        \u00b7 intro A\n          simp only [cokernel_cofork.\u03c0_of_\u03c0, \u2190 category.assoc]\n          convert colimit.\u03b9_desc _ _ using 2\n          rw [is_iso.comp_inv_eq, is_iso.comp_inv_eq, eq_comm, \u2190 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 [\u2200 {X Y : C} (f : X \u27f6 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  { \u2039Abelian C\u203a 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 \u27f6 Q)\n\n/-- The map `p : P \u27f6 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 \u27f6 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 \u27f6 Q)\n\nsection\n\ntheorem mono_of_kernel_\u03b9_eq_zero (h : kernel.\u03b9 f = 0) : Mono f :=\n  mono_of_kernel_zero h\n#align category_theory.abelian.mono_of_kernel_\u03b9_eq_zero CategoryTheory.Abelian.mono_of_kernel_\u03b9_eq_zero\n\ntheorem epi_of_cokernel_\u03c0_eq_zero (h : cokernel.\u03c0 f = 0) : Epi f :=\n  by\n  apply normal_mono_category.epi_of_zero_cokernel _ (cokernel f)\n  simp_rw [\u2190 h]\n  exact is_colimit.of_iso_colimit (colimit.is_colimit (parallel_pair f 0)) (iso_of_\u03c0 _)\n#align category_theory.abelian.epi_of_cokernel_\u03c0_eq_zero CategoryTheory.Abelian.epi_of_cokernel_\u03c0_eq_zero\n\nend\n\nsection\n\nvariable {f}\n\ntheorem image_\u03b9_comp_eq_zero {R : C} {g : Q \u27f6 R} (h : f \u226b g = 0) : Abelian.image.\u03b9 f \u226b g = 0 :=\n  zero_of_epi_comp (Abelian.factorThruImage f) <| by simp [h]\n#align category_theory.abelian.image_\u03b9_comp_eq_zero CategoryTheory.Abelian.image_\u03b9_comp_eq_zero\n\ntheorem comp_coimage_\u03c0_eq_zero {R : C} {g : Q \u27f6 R} (h : f \u226b g = 0) : f \u226b Abelian.coimage.\u03c0 g = 0 :=\n  zero_of_comp_mono (Abelian.factorThruCoimage g) <| by simp [h]\n#align category_theory.abelian.comp_coimage_\u03c0_eq_zero CategoryTheory.Abelian.comp_coimage_\u03c0_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.\u03b9 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.\u03c0 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 \u27f6 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 _ = _ \u226b (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 \u2245 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 \u2245 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 [\u2190 cancel_mono (limits.image.\u03b9 f)]) :=\n  by\n  ext\n  simp only [\u2190 cancel_mono (limits.image.\u03b9 f), is_image.iso_ext_hom, cokernel.\u03c0_desc,\n    category.assoc, is_image.lift_\u03b9, 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 \u226b (coimageIsoImage' f).inv = cokernel.\u03c0 _ := 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 \u2245 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_\u03b9 : (imageIsoImage f).Hom \u226b Limits.image.\u03b9 _ = kernel.\u03b9 _ := by\n  simp only [is_image.iso_ext_hom, is_image.lift_\u03b9,\n    image_strong_epi_mono_factorisation_to_mono_factorisation_m]\n#align category_theory.abelian.image_iso_image_hom_comp_image_\u03b9 CategoryTheory.Abelian.imageIsoImage_hom_comp_image_\u03b9\n\ntheorem imageIsoImage_inv :\n    (imageIsoImage f).inv =\n      kernel.lift _ (Limits.image.\u03b9 f) (by simp [\u2190 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_\u03b9,\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 \u27f6 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.\u03b9 s`. -/\ndef epiIsCokernelOfKernel [Epi f] (s : Fork f 0) (h : IsLimit s) :\n    IsColimit (CokernelCofork.of\u03c0 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.\u03c0 s`. -/\ndef monoIsKernelOfCokernel [Mono f] (s : Cofork f 0) (h : IsColimit s) :\n    IsLimit (KernelFork.of\u03b9 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 \u27f6 T) (hg : kernel.\u03b9 f \u226b g = 0) : Y \u27f6 T :=\n  (epiIsCokernelOfKernel _ (limit.isLimit _)).desc (CokernelCofork.of\u03c0 _ 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 \u27f6 T) (hg : kernel.\u03b9 f \u226b g = 0) :\n    f \u226b epiDesc f g hg = g :=\n  (epiIsCokernelOfKernel _ (limit.isLimit _)).fac (CokernelCofork.of\u03c0 _ 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 \u27f6 Y) (hg : g \u226b cokernel.\u03c0 f = 0) : T \u27f6 X :=\n  (monoIsKernelOfCokernel _ (colimit.isColimit _)).lift (KernelFork.of\u03b9 _ 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 \u27f6 Y) (hg : g \u226b cokernel.\u03c0 f = 0) :\n    monoLift f g hg \u226b f = g :=\n  (monoIsKernelOfCokernel _ (colimit.isColimit _)).fac (KernelFork.of\u03b9 _ 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 X \u229e Y` -/\nabbrev pullbackToBiproduct : pullback f g \u27f6 X \u229e 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 \u27f6 X \u229e Y` induces a kernel cone on the map\n    `biproduct X Y \u27f6 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\u03b9 (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 \u27f6 X \u229e 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.\u03b9 s \u226b biprod.fst) (Fork.\u03b9 s \u226b biprod.snd) <|\n        sub_eq_zero.1 <| by\n          rw [category.assoc, category.assoc, \u2190 comp_sub, sub_eq_add_neg, \u2190 comp_neg, \u2190\n            biprod.desc_eq, kernel_fork.condition s])\n    (fun s => by\n      ext <;> rw [fork.\u03b9_of_\u03b9, category.assoc]\n      \u00b7 rw [biprod.lift_fst, pullback.lift_fst]\n      \u00b7 rw [biprod.lift_snd, pullback.lift_snd])\n    fun s m h => by ext <;> simp [\u2190 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 \u27f6 Y) (g : X \u27f6 Z)\n\n/-- The canonical map `Y \u229e Z \u27f6 pushout f g` -/\nabbrev biproductToPushout : Y \u229e Z \u27f6 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 \u229e Z \u27f6 pushout f g` induces a cokernel cofork on the map\n    `X \u27f6 Y \u229e Z` induced by `f` and `-g`. -/\nabbrev biproductToPushoutCofork : CokernelCofork (biprod.lift f (-g)) :=\n  CokernelCofork.of\u03c0 (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 \u229e Z \u27f6 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 \u226b Cofork.\u03c0 s) (biprod.inr \u226b Cofork.\u03c0 s) <|\n        sub_eq_zero.1 <| by\n          rw [\u2190 category.assoc, \u2190 category.assoc, \u2190 sub_comp, sub_eq_add_neg, \u2190 neg_comp, \u2190\n            biprod.lift_eq, cofork.condition s, zero_comp])\n    (fun s => by ext <;> simp) fun s m h => by ext <;> simp [\u2190 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) :=\n  -- It will suffice to consider some morphism e : Y \u27f6 R such that\n    -- pullback.snd \u226b 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 \u229e Y\u27f6 R.\n    let u := biprod.desc (0 : X \u27f6 R) e\n    -- The composite pullback f g \u27f6 X \u229e Y \u27f6 R is zero by assumption.\n    have hu : pullback_to_biproduct_is_kernel.pullback_to_biproduct f g \u226b 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 \u27f6 R.\n    obtain \u27e8d, hd\u27e9 := cokernel_cofork.is_colimit.desc' this u hu\n    change Z \u27f6 R at d\n    change biprod.desc f (-g) \u226b d = u at hd\n    -- But then f \u226b d = 0:\n    have : f \u226b d = 0;\n    calc\n      f \u226b d = (biprod.inl \u226b biprod.desc f (-g)) \u226b d := by rw [biprod.inl_desc]\n      _ = biprod.inl \u226b 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 \u226b u := by rw [biprod.inr_desc]\n      _ = biprod.inr \u226b biprod.desc f (-g) \u226b d := by rw [\u2190 hd]\n      _ = biprod.inr \u226b biprod.desc f (-g) \u226b 0 := by rw [this]\n      _ = (biprod.inr \u226b biprod.desc f (-g)) \u226b 0 := by rw [\u2190 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 \u27f6 X) :=\n  -- It will suffice to consider some morphism e : X \u27f6 R such that\n    -- pullback.fst \u226b 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 \u229e Y \u27f6 R.\n    let u := biprod.desc e (0 : Y \u27f6 R)\n    -- The composite pullback f g \u27f6 X \u229e Y \u27f6 R is zero by assumption.\n    have hu : pullback_to_biproduct_is_kernel.pullback_to_biproduct f g \u226b 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 \u27f6 R.\n    obtain \u27e8d, hd\u27e9 := cokernel_cofork.is_colimit.desc' this u hu\n    change Z \u27f6 R at d\n    change biprod.desc f (-g) \u226b d = u at hd\n    -- But then (-g) \u226b d = 0:\n    have : (-g) \u226b d = 0;\n    calc\n      (-g) \u226b d = (biprod.inr \u226b biprod.desc f (-g)) \u226b d := by rw [biprod.inr_desc]\n      _ = biprod.inr \u226b 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 \u226b u := by rw [biprod.inl_desc]\n      _ = biprod.inl \u226b biprod.desc f (-g) \u226b d := by rw [\u2190 hd]\n      _ = biprod.inl \u226b biprod.desc f (-g) \u226b 0 := by rw [this]\n      _ = (biprod.inl \u226b biprod.desc f (-g)) \u226b 0 := by rw [\u2190 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  \u00b7 rfl\n  \u00b7 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  \u00b7 rfl\n  \u00b7 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\u2081 : Y \u27f6 W) [Epi g\u2081] (g\u2082 : W \u27f6 Z) [Mono g\u2082]\n    (hg : g\u2081 \u226b g\u2082 = g) (f' : X \u27f6 W) (hf : f' \u226b g\u2082 = 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\u2082 f' g\u2081 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 \u27f6 Y) (g : X \u27f6 Z)\n\ninstance mono_pushout_of_mono_f [Mono f] : Mono (pushout.inr : Z \u27f6 pushout f g) :=\n  mono_of_cancel_zero _ fun R e h =>\n    by\n    let u := biprod.lift (0 : R \u27f6 Y) e\n    have hu : u \u226b 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 \u27e8d, hd\u27e9 := kernel_fork.is_limit.lift' this u hu\n    change R \u27f6 X at d\n    change d \u226b biprod.lift f (-g) = u at hd\n    have : d \u226b f = 0;\n    calc\n      d \u226b f = d \u226b biprod.lift f (-g) \u226b biprod.fst := by rw [biprod.lift_fst]\n      _ = u \u226b biprod.fst := by rw [\u2190 category.assoc, hd]\n      _ = 0 := biprod.lift_fst _ _\n      \n    have : d = 0 := (cancel_mono f).1 (by simpa)\n    calc\n      e = u \u226b biprod.snd := by rw [biprod.lift_snd]\n      _ = (d \u226b biprod.lift f (-g)) \u226b biprod.snd := by rw [\u2190 hd]\n      _ = (0 \u226b biprod.lift f (-g)) \u226b biprod.snd := by rw [this]\n      _ = 0 \u226b biprod.lift f (-g) \u226b 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 \u27f6 pushout f g) :=\n  mono_of_cancel_zero _ fun R e h =>\n    by\n    let u := biprod.lift e (0 : R \u27f6 Z)\n    have hu : u \u226b 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 \u27e8d, hd\u27e9 := kernel_fork.is_limit.lift' this u hu\n    change R \u27f6 X at d\n    change d \u226b biprod.lift f (-g) = u at hd\n    have : d \u226b (-g) = 0;\n    calc\n      d \u226b (-g) = d \u226b biprod.lift f (-g) \u226b biprod.snd := by rw [biprod.lift_snd]\n      _ = u \u226b biprod.snd := by rw [\u2190 category.assoc, hd]\n      _ = 0 := biprod.lift_snd _ _\n      \n    have : d = 0 := (cancel_mono (-g)).1 (by simpa)\n    calc\n      e = u \u226b biprod.fst := by rw [biprod.lift_fst]\n      _ = (d \u226b biprod.lift f (-g)) \u226b biprod.fst := by rw [\u2190 hd]\n      _ = (0 \u226b biprod.lift f (-g)) \u226b biprod.fst := by rw [this]\n      _ = 0 \u226b biprod.lift f (-g) \u226b 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  \u00b7 rfl\n  \u00b7 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  \u00b7 rfl\n  \u00b7 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 \u27f6 Y) (g : X \u27f6 Z) (g\u2081 : X \u27f6 W) [Epi g\u2081]\n    (g\u2082 : W \u27f6 Z) [Mono g\u2082] (hg : g\u2081 \u226b g\u2082 = g) (f' : W \u27f6 Y) (hf : g\u2081 \u226b 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\n-/\nimport data.multiset.nodup\n\n/-!\n# The cartesian product of multisets\n-/\n\nnamespace multiset\n\nsection pi\nvariables {\u03b1 : Type*}\nopen function\n\n/-- Given `\u03b4 : \u03b1 \u2192 Type*`, `pi.empty \u03b4` is the trivial dependent function out of the empty\nmultiset. -/\ndef pi.empty (\u03b4 : \u03b1 \u2192 Type*) : (\u03a0a\u2208(0:multiset \u03b1), \u03b4 a) .\n\nvariables [decidable_eq \u03b1] {\u03b4 : \u03b1 \u2192 Type*}\n\n/-- Given `\u03b4 : \u03b1 \u2192 Type*`, a multiset `m` and a term `a`, as well as a term `b : \u03b4 a` and a\nfunction `f` such that `f a' : \u03b4 a'` for all `a'` in `m`, `pi.cons m a b f` is a function `g` such\nthat `g a'' : \u03b4 a''` for all `a''` in `a ::\u2098 m`. -/\ndef pi.cons (m : multiset \u03b1) (a : \u03b1) (b : \u03b4 a) (f : \u03a0a\u2208m, \u03b4 a) : \u03a0a'\u2208a ::\u2098 m, \u03b4 a' :=\n\u03bba' 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 \u03b1} {a : \u03b1} {b : \u03b4 a} {f : \u03a0a\u2208m, \u03b4 a} (h : a \u2208 a ::\u2098 m) :\n  pi.cons m a b f a h = b :=\ndif_pos rfl\n\nlemma pi.cons_ne {m : multiset \u03b1} {a a' : \u03b1} {b : \u03b4 a} {f : \u03a0a\u2208m, \u03b4 a}\n  (h' : a' \u2208 a ::\u2098 m) (h : a' \u2260 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' : \u03b1} {b : \u03b4 a} {b' : \u03b4 a'} {m : multiset \u03b1} {f : \u03a0a\u2208m, \u03b4 a} (h : a \u2260 a') :\n  pi.cons (a' ::\u2098 m) a b (pi.cons m a' b' f) == pi.cons (a ::\u2098 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\u2081 ha\u2082 h,\n  by_cases h\u2081 : a'' = a; by_cases h\u2082 : a'' = a';\n    simp [*, pi.cons_same, pi.cons_ne] at *,\n  { subst h\u2081, rw [pi.cons_same, pi.cons_same] },\n  { subst h\u2082, 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 \u03b1) (t : \u03a0a, multiset (\u03b4 a)) : multiset (\u03a0a\u2208m, \u03b4 a) :=\nm.rec_on {pi.empty \u03b4} (\u03bba m (p : multiset (\u03a0a\u2208m, \u03b4 a)), (t a).bind $ \u03bbb, 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 : \u03a0a, multiset (\u03b4 a)) : pi 0 t = pi.empty \u03b4 ::\u2098 0 := rfl\n\n@[simp] lemma pi_cons (m : multiset \u03b1) (t : \u03a0a, multiset (\u03b4 a)) (a : \u03b1) :\n  pi (a ::\u2098 m) t = ((t a).bind $ \u03bbb, (pi m t).map $ pi.cons m a b) :=\nrec_on_cons a m\n\nlemma pi_cons_injective {a : \u03b1} {b : \u03b4 a} {s : multiset \u03b1} (hs : a \u2209 s) :\n  function.injective (pi.cons s a b) :=\nassume f\u2081 f\u2082 eq, funext $ assume a', funext $ assume h',\nhave ne : a \u2260 a', from assume h, hs $ h.symm \u25b8 h',\nhave a' \u2208 a ::\u2098 s, from mem_cons_of_mem h',\ncalc f\u2081 a' h' = pi.cons s a b f\u2081 a' this : by rw [pi.cons_ne this ne.symm]\n  ... = pi.cons s a b f\u2082 a' this : by rw [eq]\n  ... = f\u2082 a' h' : by rw [pi.cons_ne this ne.symm]\n\nlemma card_pi (m : multiset \u03b1) (t : \u03a0a, multiset (\u03b4 a)) :\n  card (pi m t) = prod (m.map $ \u03bba, card (t a)) :=\nmultiset.induction_on m (by simp) (by simp [mul_comm] {contextual := tt})\n\nlemma nodup_pi {s : multiset \u03b1} {t : \u03a0a, multiset (\u03b4 a)} :\n  nodup s \u2192 (\u2200a\u2208s, nodup (t a)) \u2192 nodup (pi s t) :=\nmultiset.induction_on s (assume _ _, nodup_singleton _)\nbegin\n  assume a s ih hs ht,\n  have has : a \u2209 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\u2081 hb\u2081 b\u2082 hb\u2082 neb, disjoint_map_map.2 (assume f hf g hg eq,\n      have pi.cons s a b\u2081 f a (mem_cons_self _ _) = pi.cons s a b\u2082 g a (mem_cons_self _ _),\n        by rw [eq],\n      neb $ show b\u2081 = b\u2082, by rwa [pi.cons_same, pi.cons_same] at this) }\nend\n\nlemma mem_pi (m : multiset \u03b1) (t : \u03a0a, multiset (\u03b4 a)) :\n  \u2200f:\u03a0a\u2208m, \u03b4 a, (f \u2208 pi m t) \u2194 (\u2200a (h : a \u2208 m), f a h \u2208 t a) :=\nbegin\n  refine multiset.induction_on m (\u03bb f, _) (\u03bb a m ih f, _),\n  { simpa using show f = pi.empty \u03b4, by funext a ha; exact ha.elim },\n  simp only [mem_bind, exists_prop, mem_cons, pi_cons, mem_map], split,\n  { rintro \u27e8b, hb, f', hf', rfl\u27e9 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 \u27e8_, hf a (mem_cons_self a _), \u03bba ha, f a (mem_cons_of_mem ha),\n      (ih _).2 (\u03bb a' h', hf _ _), _\u27e9,\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 (\u03b1 : Type w) (m : Type u \u2192 Type v) (\u03b2 : Type u) :=\n(apply : \u03b1 \u2192 m \u03b2)\n\ndef monad_cont.goto {\u03b1 \u03b2} {m : Type u \u2192 Type v} (f : monad_cont.label \u03b1 m \u03b2) (x : \u03b1) := f.apply x\n\nclass monad_cont (m : Type u \u2192 Type v)\nextends monad m :=\n(call_cc : \u03a0 {\u03b1 \u03b2}, ((monad_cont.label \u03b1 m \u03b2) \u2192 m \u03b1) \u2192 m \u03b1)\n\nopen monad_cont\n\nclass is_lawful_monad_cont (m : Type u \u2192 Type v) [monad_cont m]\nextends is_lawful_monad m :=\n(call_cc_bind_right {\u03b1 \u03c9 \u03b3} (cmd : m \u03b1) (next : (label \u03c9 m \u03b3) \u2192 \u03b1 \u2192 m \u03c9) :\n  call_cc (\u03bb f, cmd >>= next f) = cmd >>= \u03bb x, call_cc (\u03bb f, next f x))\n(call_cc_bind_left {\u03b1} (\u03b2) (x : \u03b1) (dead : label \u03b1 m \u03b2 \u2192 \u03b2 \u2192 m \u03b1) :\n  call_cc (\u03bb f : label \u03b1 m \u03b2, goto f x >>= dead f) = pure x)\n(call_cc_dummy {\u03b1 \u03b2} (dummy : m \u03b1) :\n  call_cc (\u03bb f : label \u03b1 m \u03b2, dummy) = dummy)\n\nexport is_lawful_monad_cont\n\ndef cont_t (r : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type w) := (\u03b1 \u2192 m r) \u2192 m r\n\nnamespace cont_t\n\nexport monad_cont (label goto)\n\nvariables {r : Type u} {m : Type u \u2192 Type v} {\u03b1 \u03b2 \u03b3 \u03c9 : Type w}\n\ndef run : cont_t r m \u03b1 \u2192 (\u03b1 \u2192 m r) \u2192 m r := id\n\ndef map (f : m r \u2192 m r) (x : cont_t r m \u03b1) : cont_t r m \u03b1 := f \u2218 x\n\nlemma run_cont_t_map_cont_t (f : m r \u2192 m r) (x : cont_t r m \u03b1) :\n  run (map f x) = f \u2218 run x := rfl\n\ndef with_cont_t (f : (\u03b2 \u2192 m r) \u2192 \u03b1 \u2192 m r) (x : cont_t r m \u03b1) : cont_t r m \u03b2 :=\n\u03bb g, x $ f g\n\nlemma run_with_cont_t (f : (\u03b2 \u2192 m r) \u2192 \u03b1 \u2192 m r) (x : cont_t r m \u03b1) :\n  run (with_cont_t f x) = run x \u2218 f := rfl\n\ninstance : monad (cont_t r m) :=\n{ pure := \u03bb \u03b1 x f, f x,\n  bind := \u03bb \u03b1 \u03b2 x f g, x $ \u03bb 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 := \u03bb a x f, x >>= f }\n\nlemma monad_lift_bind [monad m] [is_lawful_monad m] {\u03b1 \u03b2} (x : m \u03b1) (f : \u03b1 \u2192 m \u03b2) :\n  (monad_lift (x >>= f) : cont_t r m \u03b2) = monad_lift x >>= monad_lift \u2218 f :=\nby { ext, simp only [monad_lift,has_monad_lift.monad_lift,(\u2218),(>>=),bind_assoc,id.def] }\n\ninstance : monad_cont (cont_t r m) :=\n{ call_cc := \u03bb \u03b1 \u03b2 f g, f \u27e8\u03bb x h, g x\u27e9 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\u00e9mi Bottinelli. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: R\u00e9mi 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 \u2964 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 \u27f6 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 \u27f6 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 \u27f6 Z) :\n    red_step (\ud835\udfd9 X) (f.to_path \u226b (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) := \u27e8\u27e8h.some\u27e9\u27e9\n\nlemma congr_reverse {X Y : paths $ quiver.symmetrify V} (p q : X \u27f6 Y) :\n  quotient.comp_closure red_step p q \u2192\n  quotient.comp_closure red_step (p.reverse) (q.reverse) :=\nbegin\n  rintro \u27e8XW, pp, qq, WY, _, Z, f\u27e9,\n  have : quotient.comp_closure red_step (WY.reverse \u226b \ud835\udfd9 _ \u226b XW.reverse)\n    (WY.reverse \u226b (f.to_path \u226b (quiver.reverse f).to_path) \u226b 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 \u27f6 Y) :\n  quot.mk (@quotient.comp_closure _ _ red_step _ _) (p \u226b p.reverse) =\n  quot.mk (@quotient.comp_closure _ _ red_step _ _) (\ud835\udfd9 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 \u226b q.reverse, },\n    { apply eqv_gen.symm, apply eqv_gen.rel,\n      have : quotient.comp_closure\n               red_step (q \u226b (\ud835\udfd9 _) \u226b q.reverse)\n               (q \u226b (f.to_path \u226b (quiver.reverse f).to_path) \u226b 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 \u22a2,\n      simp only [category_struct.comp, quiver.path.comp_assoc] at this \u22a2,\n      exact this, },\n    { exact ih }, },\nend\n\nlemma congr_reverse_comp {X Y : paths $ quiver.symmetrify V} (p : X \u27f6 Y) :\n  quot.mk (@quotient.comp_closure _ _ red_step _ _) (p.reverse \u226b p) =\n  quot.mk (@quotient.comp_closure _ _ red_step _ _) (\ud835\udfd9 Y) :=\nbegin\n  nth_rewrite 1 \u2190quiver.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 \u27f6 Y) : Y \u27f6 X :=\nquot.lift_on f\n            (\u03bb pp, quot.mk _ $ pp.reverse)\n            (\u03bb pp qq con, quot.sound $ congr_reverse pp qq con)\n\ninstance : groupoid (free_groupoid V) :=\n{ inv := \u03bb X Y f, quot_inv f,\n  inv_comp' := \u03bb X Y p, quot.induction_on p $ \u03bb pp, congr_reverse_comp pp,\n  comp_inv' := \u03bb X Y p, quot.induction_on p $ \u03bb 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 \u2964q (free_groupoid V) :=\n{ obj := \u03bb X, \u27e8X\u27e9,\n  map := \u03bb X Y f, quot.mk _ f.to_pos_path }\n\nlemma of_eq : of V =\n  (quiver.symmetrify.of \u22d9q 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'] (\u03c6 : V \u2964q V')\n\n/-- The lift of a prefunctor to a groupoid, to a functor from `free_groupoid V` -/\ndef lift (\u03c6 : V \u2964q V') : free_groupoid V \u2964 V' :=\nquotient.lift _\n  (paths.lift $ quiver.symmetrify.lift \u03c6)\n  (by\n    { rintros _ _ _ _ \u27e8X,Y,f\u27e9,\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 (\u03c6 : V \u2964q V') : of V \u22d9q (lift \u03c6).to_prefunctor = \u03c6 :=\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 (\u03c6 : V \u2964q V') (\u03a6 : free_groupoid V \u2964 V')\n  (h\u03a6 : of V \u22d9q \u03a6.to_prefunctor = \u03c6) : \u03a6 = lift \u03c6 :=\nbegin\n  apply quotient.lift_unique,\n  apply paths.lift_unique,\n  fapply @quiver.symmetrify.lift_unique _ _ _ _ _ _ _ _ _,\n  { rw \u2190functor.to_prefunctor_comp, exact h\u03a6, },\n  { constructor, rintros X Y f,\n    simp only [\u2190functor.to_prefunctor_comp,prefunctor.comp_map, paths.of_map, inv_eq_inv],\n    change \u03a6.map (inv ((quotient.functor red_step).to_prefunctor.map f.to_path)) =\n           inv (\u03a6.map ((quotient.functor red_step).to_prefunctor.map f.to_path)),\n    have := functor.map_inv \u03a6 ((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 (\u03c6 : V \u2964q V') :\n  free_groupoid V \u2964 free_groupoid V' := lift (\u03c6 \u22d9q of V')\n\n\n\nlemma free_groupoid_functor_comp\n  (\u03c6 : V \u2964q V') (\u03c6' : V' \u2964q V'') :\n  free_groupoid_functor (\u03c6 \u22d9q \u03c6') = free_groupoid_functor \u03c6 \u22d9 free_groupoid_functor \u03c6' :=\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\u207b\u00b9 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 \u2124 \u2192 \u2243 \u2192 \u2243\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 : \u2124) (f : X \u2243 X) : X \u2243 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 `\u2983`:1 n `\u2984^`:1 f := int.iterate n f\n\nnamespace iterate\n\nvariables {X : Type} (m n : \u2124) (f : X \u2243 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 : \u2124) : iterate (-a) f = iterate a f.symm :=\nby show f^(-a) = f\u207b\u00b9^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 \u2243 X) (a b : \u2124) (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 (\u03b1 : Type*) [has_le \u03b1] :=\n(to_fun : \u03b1 \u2192 \u03b1)\n(ord' : \u2200 {x y : \u03b1}, x \u2264 y \u2192 to_fun x \u2264 to_fun y)\n(inflate' : \u2200 x, x \u2264 to_fun x)\n(idem' : \u2200 x, to_fun (to_fun x) = to_fun x)\n\ninstance (\u03b1 : Type*) [has_le \u03b1] : has_coe_to_fun (closure_operator \u03b1) :=\n\u27e8_, closure_operator.to_fun\u27e9\n\ninstance (\u03b1 : Type*) [has_le \u03b1] : has_le (closure_operator \u03b1) :=\n\u27e8\u03bb c\u2081 c\u2082, \u2200 x, c\u2081 x \u2264 c\u2082 x\u27e9\n\nlemma closure_operator.ord {\u03b1 : Type*} [has_le \u03b1] (c : closure_operator \u03b1) {x y : \u03b1} (h : x \u2264 y) :\n  c x \u2264 c y :=\nc.ord' h\n\nlemma closure_operator.inflate {\u03b1 : Type*} [has_le \u03b1] (c : closure_operator \u03b1) (x : \u03b1) :\n  x \u2264 c x := c.inflate' x\n\nlemma closure_operator.idem {\u03b1 : Type*} [has_le \u03b1] (c : closure_operator \u03b1) (x : \u03b1) :\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 : \u03a0 (X : C), closure_operator (sieve X)) :\n  sieve_set C :=\n\u03bb X S, c X S = \u22a4\n\n/-- If a closure operator on sieves is natural, it induces a Grothendieck topology. -/\ninstance natural_operator_is_grothendieck (c : \u03a0 (X : C), closure_operator (sieve X))\n  (hc : \u2200 (X Y : C) (f : X \u27f6 Y) (S : sieve Y), (c Y S).pullback f = c _ (S.pullback f)) :\ngrothendieck (grothendieck_from_natural_operator c) :=\n{ max := \u03bb X,\n  begin\n    apply top_unique,\n    apply (c _).inflate,\n  end,\n  stab := \u03bb X Y S hS f,\n  begin\n    change _ = _ at hS,\n    change _ = _,\n    rw [\u2190 hc, hS, sieve.pullback_top],\n  end,\n  trans := \u03bb X S hS T hT,\n  begin\n    change _ = _,\n    rw \u2190 (c X).idem,\n    apply top_unique,\n    change _ = _ at hS,\n    rw \u2190 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 := \u03bb g, grothendieck.covers J S g.hom,\n  subs := \u03bb d e f h k,\n  begin\n    change S.pullback (h \u226b f) \u2208 J e,\n    change S.pullback f \u2208 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 \u2264 T) :\n  close J S \u2264 close J T :=\nbegin\n  intros d g hg,\n  change S.pullback g \u2208 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 \u2264 close J S :=\nbegin\n  intros d g hg,\n  change S.pullback g \u2208 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 \u2208 J d at hg,\n    apply grothendieck.trans _ hg,\n    intros e g' hg',\n    change (S.pullback g).pullback g' \u2208 J e,\n    rw \u2190 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 \u2293 T) = close J S \u2293 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 \u27e8hg\u2081, hg\u2082\u27e9,\n  change S.pullback g \u2208 J d at hg\u2081,\n  change (S \u2293 T).pullback g \u2208 J d,\n  rw sieve.pullback_inter,\n  apply grothendieck.intersection_covering hg\u2081 hg\u2082,\nend\n\nlemma close_pullback (c d : C) (S : sieve c) (f : d \u27f6 c) :\n  close J (S.pullback f) = (close J S).pullback f :=\nbegin\n  ext e g,\n  change (S.pullback f).pullback g \u2208 J e \u2194 S.pullback (g \u226b f) \u2208 J e,\n  rw S.pullback_comp,\nend\n\nlemma incl_iff_closure_eq_top (c : C) (S : sieve c) : S \u2208 J c \u2194 close J S = \u22a4 :=\nbegin\n  split,\n    intro h,\n    ext d f,\n    change S.pullback f \u2208 J d \u2194 true,\n    simpa using grothendieck.stab S h f,\n  rw [close],\n  intro q,\n  refine grothendieck.trans \u22a4 (grothendieck.max _) _ _,\n  intros d g hg,\n  rw \u2190 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 : \u03a0 (X : C), closure_operator (sieve X) // \u2200 X Y f S, (c Y S).pullback f = c X (S.pullback f)}\n\u2243 {J : sieve_set C // grothendieck J} :=\n{ to_fun := \u03bb c, \u27e8grothendieck_from_natural_operator c.1, category_theory.natural_operator_is_grothendieck _ c.2\u27e9,\n  inv_fun := \u03bb J, by { haveI := J.2, refine \u27e8\u03bb X, \u27e8close J.1, \u03bb x y, close_preserves_order _, close_inflationary _, close_idem _ _\u27e9, \u03bb X Y f S, _\u27e9, symmetry, apply close_pullback, },\n  left_inv :=\n  begin\n    rintro \u27e8c\u2081, c\u2082\u27e9,\n    ext x S y f,\n    dsimp [close, grothendieck.covers, grothendieck_from_natural_operator],\n    change c\u2081 y (S.pullback f) = \u22a4 \u2194 over.mk f \u2208 (c\u2081 x S).arrows,\n    rw \u2190 c\u2082,\n    rw sieve.pullback_eq_top_iff_mem,\n  end,\n  right_inv :=\n  begin\n    rintro \u27e8J, _\u27e9,\n    resetI,\n    ext c S,\n    apply (incl_iff_closure_eq_top J c S).symm,\n  end }\n\n@[simps]\ndef j : \u03a9 (C\u1d52\u1d56 \u2964 Type u) \u27f6 \u03a9 (C\u1d52\u1d56 \u2964 Type u) :=\n{ app := \u03bb c S, close J S,\n  naturality' := \u03bb 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\u1d52\u1d56 \u2964 Type u) (f g : X \u27f6 Y)\n  (h : \u2200 (c : C\u1d52\u1d56) (k : yoneda.obj c.unop \u27f6 X), k \u226b f = k \u226b 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 (\u03bb 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 (\ud835\udfd9 _)),\n  dsimp at z,\n  rw [X.map_id] at z,\n  exact z,\nend\n\ndef sieve_equiv_arrow (c : C) : sieve c \u2243 (yoneda.obj c \u27f6 \u03a9 _) :=\n(yoneda_sections_small c (\u03a9 _)).to_equiv.symm\n\nlemma equiv_close (c : C) (S : sieve c) :\n  sieve_equiv_arrow _ (close J S) = sieve_equiv_arrow _ S \u226b j J :=\nbegin\n  ext d f : 3,\n  symmetry,\n  apply close_pullback,\nend\n\ndef sub_repr (c : C) : sieve c \u2243 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 \u2190 classification.eq_symm_apply,\n  ext c' f c'' g,\n  change over.mk (g \u226b f) \u2208 S.arrows \u2194 \u2203 (x : {h // over.mk h \u2208 S.arrows}), x.1 = g \u226b f,\n  rw [subtype.exists],\n  simp,\nend\n\ndef sieve_subq (c : C) :\nsieve c \u2243o 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 \u2264 T \u2194 nonempty (_ \u27f6 _),\n    split,\n    intro h,\n      exact \u27e8sub.hom_mk (sieve.le_as_functor h) (sieve.le_as_functor_comm h)\u27e9,\n    rintro \u27e8a\u27e9 d f hf,\n    let f' := a.left.app (opposite.op d) \u27e8f, hf\u27e9,\n    have := sub.w a,\n    dsimp at *,\n    have q := congr_arg (\u03bb t, nat_trans.app t (opposite.op d)) this,\n    dsimp at q,\n    replace q := congr_fun q \u27e8f, hf\u27e9,\n    dsimp at q,\n    rw \u2190 q,\n    apply (a.left.app (opposite.op d) \u27e8f, hf\u27e9).2,\n  end }\n\nlemma inclusion_inter (c : C) (S T : sieve c) :\n  sieve_subq _ (S \u2293 T) = sieve_subq _ S \u2293 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) \u226b and_arrow _) = sieve_equiv_arrow _ (S \u2293 T) :=\nbegin\n  have : \u2200 (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 \u27e8\u27e9 d f,\n    change J d ((\u22a4 : sieve _).pullback f) \u2194 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) (\u03a9 _) (\u03a9 _) at k,\n    cases k with k\u2081 k\u2082,\n    change prod.lift k\u2081 k\u2082 \u226b _ = prod.lift k\u2081 k\u2082 \u226b _ \u226b _,\n    rw prod.lift_map_assoc,\n    equiv_rw (sieve_equiv_arrow c.unop).symm at k\u2081,\n    equiv_rw (sieve_equiv_arrow c.unop).symm at k\u2082,\n\n    rw [\u2190 equiv_close, \u2190 equiv_close, and_arrow_sieve, and_arrow_sieve_assoc, \u2190 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 \u2208 J c) : closure.dense (j J) S.functor_inclusion :=\nbegin\n  constructor,\n  change classification (classify (subq.mk _) \u226b _) = _,\n  rw \u2190 sub_repr_eq,\n  dsimp only [sub_repr, equiv.trans],\n  change classification (classification.symm (classification _) \u226b _) = _,\n  rw classification.symm_apply_apply,\n  erw \u2190 equiv_close,\n  change sieve_subq _ _ = _,\n  rw \u2190 order_iso.map_top (sieve_subq c),\n  congr' 1,\n  ext d f,\n  change S.pullback f \u2208 J d \u2194 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 \u2208 J c :=\nbegin\n  have := h.closure_eq_top,\n  change classification (classify (subq.mk _) \u226b _) = _ at this,\n  rw \u2190 sub_repr_eq at this,\n  dsimp only [sub_repr, equiv.trans] at this,\n  change classification (classification.symm (classification _) \u226b _) = _ at this,\n  rw classification.symm_apply_apply at this,\n  erw \u2190 equiv_close at this,\n  change sieve_subq _ _ = _ at this,\n  rw \u2190 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 \u22a4 (grothendieck.max _) _ _,\n  intros d g hg,\n  rw \u2190 this at hg,\n  exact hg,\nend\n\ndef jsheaf_is_Jsheaf (P : C\u1d52\u1d56 \u2964 Type u) (h : sheaf_condition (j J) P) : grothendieck.sheaf_condition J P :=\nbegin\n  intros c S \u03b3 hS,\n  change S.as_functor \u27f6 _ at \u03b3,\n  haveI : closure.dense (j J) S.functor_inclusion := dense_inclusion _ _ _ hS,\n  apply h S.functor_inclusion \u03b3,\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\u1d52\u1d56 \u2964 Type u)\n  (h : \u03a0 c S f' (m : S \u27f6 yoneda.obj c) [closure.dense (j J) m], {f : yoneda.obj c \u27f6 P // m \u226b f = f' \u2227 \u2200 a, m \u226b a = f' \u2192 a = f}) :\n  sheaf_condition (j J) P :=\nsheaf_condition.mk' _ _\nbegin\n  introsI E A m \u03c3 _,\n  let A' : (E.elements)\u1d52\u1d56 \u2192 (C\u1d52\u1d56 \u2964 Type u) := \u03bb i, pullback ((the_cocone E).\u03b9.app i) m,\n  let m' : \u03a0 (i : E.elements\u1d52\u1d56), A' i \u27f6 yoneda.obj i.unop.1.unop := \u03bb i, pullback.fst,\n  let top_map : \u03a0 (i : E.elements\u1d52\u1d56), A' i \u27f6 A := \u03bb i, pullback.snd,\n  have pb : \u2200 (i : E.elements\u1d52\u1d56), m' i \u226b _ = top_map i \u226b m := \u03bb i, pullback.condition,\n  let A'diagram : E.elements\u1d52\u1d56 \u2964 (C\u1d52\u1d56 \u2964 Type u),\n  { refine { functor . obj := A',\n             map := \u03bb i j f,\n              pullback.lift (m' i \u226b yoneda.map f.unop.1.unop) (top_map i)\n                (by erw [\u2190 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\u2081 i\u2082 i\u2083 f g,\n      apply pullback.hom_ext; simp } },\n  let \u03c4 : A'diagram \u27f6 ((category_of_elements.\u03c0 E).left_op \u22d9 yoneda) :=\n    { nat_trans . app := m', naturality' := \u03bb i j f, pullback.lift_fst _ _ _ },\n  let A'cocone : cocone A'diagram,\n    refine \u27e8A, \u03bb i, top_map i, _\u27e9,\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) \u03c4 m pb (\u03bb i, cone_is_pullback _ _),\n  let h' : \u03a0 (i : E.elements\u1d52\u1d56), {f // m' i \u226b f = top_map i \u226b \u03c3 \u2227 \u2200 a, m' i \u226b a = top_map i \u226b \u03c3 \u2192 a = f} :=\n    \u03bb i, (h _ _ (top_map i \u226b \u03c3) (m' i)),\n  let h'\u2081 : \u03a0 (i : E.elements\u1d52\u1d56), yoneda.obj i.unop.1.unop \u27f6 P := \u03bb i, (h' i).1,\n  have h'\u2082 : \u2200 (i : E.elements\u1d52\u1d56), m' i \u226b h'\u2081 i = top_map i \u226b \u03c3 := \u03bb i, (h' i).2.1,\n  have h'\u2083 : \u2200 (i : E.elements\u1d52\u1d56) a, m' i \u226b a = top_map i \u226b \u03c3 \u2192 a = h'\u2081 i := \u03bb i, (h' i).2.2,\n  have legs : \u2200 (i j : E.elements\u1d52\u1d56) (f : i \u27f6 j), yoneda.map (has_hom.hom.unop f).1.unop \u226b h'\u2081 j = h'\u2081 i \u226b \ud835\udfd9 P,\n  { intros,\n    rw comp_id,\n    apply h'\u2083 i,\n    let hf : A' i \u27f6 A' j := pullback.lift (m' i \u226b yoneda.map f.unop.1.unop) (top_map i)\n                              (by erw [\u2190 pb i, assoc, (the_cocone E).w f]),\n    have : hf \u226b m' j = m' i \u226b yoneda.map _ := pullback.lift_fst _ _ _,\n    rw \u2190 reassoc_of this,\n    rw h'\u2082 j,\n    apply pullback.lift_snd_assoc },\n  refine \u27e8(is_a_limit E).desc \u27e8P, h'\u2081, legs\u27e9, _, _\u27e9,\n  { apply A'colimit.hom_ext,\n    intro i,\n    rw \u2190 pullback.condition_assoc,\n    rw (is_a_limit E).fac,\n    apply h'\u2082 },\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'\u2083 i,\n    rw pullback.condition_assoc,\n    rw hq }\nend.\n\ndef Jsheaf_is_jsheaf (P : C\u1d52\u1d56 \u2964 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 \u27e6sub.mk' m\u27e7,\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 \u27e8_\u27e9,\n  change closure.operator _ (subq.mk _) = _,\n  rw \u2190 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 \u27e6sub.mk' m\u27e7 = classify \u27e6sub.mk' S.functor_inclusion\u27e7,\n    rw same_class,\n  let i := how_inj_is_classifier m S.functor_inclusion this,\n  have hi : i.hom \u226b _ = _ := c_very_inj this,\n  refine \u27e8(h _ S (i.inv \u226b f') \u2039S \u2208 J c\u203a).1.1.1, _, _\u27e9,\n  rw [\u2190 hi, assoc, (h _ S (i.inv \u226b f') \u2039S \u2208 J c\u203a).1.1.2], simp,\n  intros a ha,\n  apply subtype.ext_iff.1 ((h _ S (i.inv \u226b f') \u2039S \u2208 J c\u203a).2 \u27e8a, _\u27e9),\n  rw iso.eq_inv_comp,\n  rw reassoc_of hi,\n  rw ha,\nend\n\ndef equivalent_sheaf_conditions (P : C\u1d52\u1d56 \u2964 Type u) :\n  grothendieck.sheaf_condition J P \u2243 sheaf_condition (j J) P :=\n{ to_fun := Jsheaf_is_jsheaf _ _,\n  inv_fun := jsheaf_is_Jsheaf _ _,\n  left_inv := \u03bb _, subsingleton.elim _ _,\n  right_inv := \u03bb _, 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": "/-\nCopyright (c) 2022 James Gallicchio.\n\nAuthors: James Gallicchio\n-/\n\nnamespace LeanColls\n\n@[extern \"leancolls_array_initialize\"] private opaque arrayInit : IO Unit\n\nbuiltin_initialize arrayInit\n\nopaque ArrayUninit.Pointed (\u03b1 : Type u) (n m : Nat) (h : m \u2264 n): NonemptyType.{u}\n\ndef ArrayUninit (\u03b1) (n m : Nat) (h : m \u2264 n) := (ArrayUninit.Pointed \u03b1 n m h).type\n\nnamespace ArrayUninit\n\ninstance : Nonempty (ArrayUninit \u03b1 n m h) := (ArrayUninit.Pointed \u03b1 n m h).property\n\naxiom partiallyInit_inhabited {\u03b1 n m h} (A : ArrayUninit \u03b1 n (.succ m) h) : Inhabited \u03b1\n\n@[extern \"leancolls_array_new\"]\nopaque new (n : @& Nat) : ArrayUninit \u03b1 n 0 (Nat.zero_le _)\n\n@[extern \"leancolls_array_get\"]\nopaque get {n m : @& Nat} {h} (A : @& ArrayUninit \u03b1 n m h) (i : @& Nat) (h_in : i < n) (h_im : i < m) : \u03b1\n  := match m with\n  | 0 => by contradiction\n  | m+1 => (partiallyInit_inhabited A).default\n\n@[extern \"leancolls_array_push\"]\nopaque push {n m : @& Nat} {h} (A : ArrayUninit \u03b1 n m h) (x : \u03b1) (h' : m < n) : ArrayUninit \u03b1 n m.succ h'\n\n@[extern \"leancolls_array_pop\"]\nopaque pop {n m : @& Nat} {h} (A : ArrayUninit \u03b1 n m.succ h) : ArrayUninit \u03b1 n m (Nat.le_of_succ_le h)\n\n@[extern \"leancolls_array_set\"]\nopaque set {n m : @& Nat} {h} (A : ArrayUninit \u03b1 n m h) (i : @& Nat) (h_i : i < n) (x : \u03b1) : ArrayUninit \u03b1 n m h\n\n@[extern \"leancolls_array_resize\"]\nopaque resize {n m : @& Nat} {h} (A : ArrayUninit \u03b1 n m h) (n' : @& Nat) (h' : m <= n') : ArrayUninit \u03b1 n' m h'\n\n@[extern \"leancolls_array_isexclusive\"]\nopaque isExclusive (a : @& A) : Bool\n\n@[simp]\naxiom get_push {\u03b1 n m h} {A : ArrayUninit \u03b1 n m h} {x h' i hn hm}\n  : get (push A x h') i hn hm =\n    if h_i : i = m then x\n    else get A i hn (Nat.lt_of_le_of_ne (Nat.le_of_succ_le_succ hm) h_i)\n\n@[simp]\naxiom get_pop {\u03b1 n m h} {A : ArrayUninit \u03b1 n (.succ m) h} {i hn hm}\n  : get (pop A) i hn hm = get A i hn (Nat.le_step hm)\n\n@[simp]\naxiom get_set {\u03b1 n m h} {A : ArrayUninit \u03b1 n m h} {i hi x j hn hm}\n  : get (set A i hi x) j hn hm =\n    if i = j then x\n    else get A j hn hm\n\n@[simp]\naxiom get_resize {\u03b1 n m h} {A : ArrayUninit \u03b1 n m h} {n' h' i hn hm}\n  : get (resize A n' h') i hn hm = get A i (Nat.lt_of_lt_of_le hm h) hm\n\naxiom ext {\u03b1 n m h} {A B : ArrayUninit \u03b1 n m h} : A.get = B.get \u2192 A = B\n\n@[simp]\ntheorem ext_iff {\u03b1 n m h} {A B : ArrayUninit \u03b1 n m h}\n  : A = B \u2194 A.get = B.get := by\n  constructor\n  intro eq; rw [eq]\n  exact ext\n", "meta": {"author": "JamesGallicchio", "repo": "LeanColls", "sha": "9cb0a0c9a838bea24be80eace168bcc5f9481596", "save_path": "github-repos/lean/JamesGallicchio-LeanColls", "path": "github-repos/lean/JamesGallicchio-LeanColls/LeanColls-9cb0a0c9a838bea24be80eace168bcc5f9481596/LeanColls/Array/ArrayUninit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7690802370707283, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.46447203785651964}}
{"text": "import simplifier.level_commutator_2\n\n/-\nHere you might want to use `simp` together with the fact that multiplication is associative \n(this lemma is called `mul_assoc` as you might have guessed). Recall that you can tell \n`simp` to use lemma `h` when simplifying by writing `simp[h]`.  \n-/\n\n/- Lemma :\n-/\nlemma commutator_inv {G : Type*} [group G] {x y : G} : [y, x] = [x, y]\u207b\u00b9 :=\nbegin\n  rw [commutator_def, commutator_def, mul_inv_rev, mul_inv_rev, mul_inv_rev, inv_inv, inv_inv,\n    mul_assoc, mul_assoc],\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nend\n", "meta": {"author": "alexjbest", "repo": "CAP-game", "sha": "d823def7325d7142d61e766b2e027f936685a8ff", "save_path": "github-repos/lean/alexjbest-CAP-game", "path": "github-repos/lean/alexjbest-CAP-game/CAP-game-d823def7325d7142d61e766b2e027f936685a8ff/src/simplifier/level_commutator_3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7690802370707281, "lm_q2_score": 0.6039318337259583, "lm_q1q2_score": 0.4644720378565196}}
{"text": "import TBA.Eulerian.Nat\n\nopen Nat List\n\nnamespace Eq\n\nprotected theorem symm_iff {a b : \u03b1} : b = a \u2194 a = b := \u27e8Eq.symm, Eq.symm\u27e9 \n\nend Eq\n\nnamespace List\n\n@[simp] theorem length_append {as bs : List \u03b1} :\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 \u03b1} : length as = 0 \u2194 as = [] :=\n\u27e8fun e => by cases as; rfl; simp [length_cons] at e, fun e => by rw [e]; rfl\u27e9\n\ntheorem length_cons_ne_zero {as : List \u03b1} {a : \u03b1} : length (a :: as) \u2260 0 := by\n  rw [List.length_cons]; exact Nat.succNeZero _\n\n-- Some lemmas about filters\n\n@[simp] theorem filter_nil {p : \u03b1 \u2192 Bool} : filter p [] = [] := by\n  simp [filter, filterAux, reverse, reverseAux]\n\ntheorem cons_eq_append (a : \u03b1) (as : List \u03b1) : a :: as = [a] ++ as := rfl\n\ntheorem reverseAux_append {rs as : List \u03b1} : 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 : \u03b1 \u2192 Bool} (as : List \u03b1) :\n  (rs : List \u03b1) \u2192 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 : \u03b1) (as : List \u03b1) :\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 \u03b1} {p : \u03b1 \u2192 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 : \u03b1 \u2192 List \u03b1 \u2192 Prop where\n  | head (a : \u03b1) (as : List \u03b1)   : Mem a (a::as)\n  | tail (a b : \u03b1) (bs : List \u03b1) : Mem a bs \u2192 Mem a (b::bs)\n\ninfix:50 \" \u2208 \" => Mem\n\nclass IsBEqEq (\u03b1 : Type) [BEq \u03b1] : Prop where\n  beq_is_eq {a b : \u03b1} : (a == b) = (a = b)\n\ninstance [DecidableEq \u03b1] : IsBEqEq \u03b1 where\n  beq_is_eq := @fun a b => by byCases h : a = b <;> simp_all [BEq.beq, decideEqTrue, decideEqFalse]\n\ninstance [DecidableEq \u03b1] : IsBEqEq (\u03b1 \u00d7 \u03b1) where\n  beq_is_eq := @fun (a\u2081, a\u2082) (b\u2081, b\u2082) => by byCases h\u2081 : a\u2081 = b\u2081 <;> byCases h\u2082 : a\u2082 = b\u2082 <;> 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 \u03b1] [IsBEqEq \u03b1] : ((a : \u03b1) == a) = true := by\n  simp\n\n@[simp] theorem beq_neq [BEq \u03b1] [IsBEqEq \u03b1] {a b : \u03b1} (h : \u00ac a = b) : (a == b) = false := by\n   cases hbeq : a == b <;> simp_all\n\ntheorem length_erase_mem [BEq \u03b1] [IsBEqEq \u03b1] {a : \u03b1} {as : List \u03b1} (h : a \u2208 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 [\u2190length_erase_mem h] }\n\ntheorem mem_singleton [BEq \u03b1] [IsBEqEq \u03b1] {a b : \u03b1} (h : a \u2208 [b]) : a = b := by\n  cases h with\n  | head h       => rfl\n  | tail _ _ _ h => cases h\n\ndef mem_of_nonzero_length [BEq \u03b1] [IsBEqEq \u03b1] {as : List \u03b1} :\n  (h : length as > 0) \u2192 { a // a \u2208 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 \u03b1} : \u2200 a, a \u2208 (as ++ bs) \u2192 a \u2208 as \u2228 a \u2208 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 \u03b1} {a : \u03b1} {p : \u03b1 \u2192 Bool} : a \u2208 filter p as \u2192 a \u2208 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 \u03b1} {a : \u03b1} {p : \u03b1 \u2192 Bool} (ha : a \u2208 as) (hpa : p a = true) :\n  a \u2208 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 \u03b1} {p : \u03b1 \u2192 Bool} {a : \u03b1} : a \u2208 filter p as \u2192 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 : \u03b1} {as : List \u03b1} (h : a \u2208 as) : \u2203 s t, as = s ++ a :: t :=\n  match a, as, h with\n  | _, _, Mem.head a bs     => \u27e8[], \u27e8bs, rfl\u27e9\u27e9\n  | _, _, Mem.tail a b bs h =>\n    match bs, mem_split h with\n    | _, \u27e8s, \u27e8t, rfl\u27e9\u27e9 => \u27e8b::s, \u27e8t, List.cons_append .. \u25b8 rfl\u27e9\u27e9\n\n-- Couting elements\n\nsection Count\nvariable [BEq \u03b1] [IsBEqEq \u03b1] (as bs as' bs' : List \u03b1) (a b : \u03b1)\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 : \u03b1} (h : \u00ac 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 \u03b1} {a b : \u03b1} :\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 \u2264 (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 \u03b1} {a : \u03b1}: a \u2208 as \u2194 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 \u27e8a', ha'\u27e9 := mem_of_nonzero_length h\n    let foo := filterProp_of_mem ha'\n    rw [\u2190beq_is_eq.mp foo]\n    apply mem_of_mem_filter ha'\n    \n-- Erasing elements from lists\n  \ntheorem erase_comm {as : List \u03b1} : (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 \u03b1} {a : \u03b1} {p : \u03b1 \u2192 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 \u03b1} {a : \u03b1} {p : \u03b1 \u2192 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 \u03b1) : List \u03b1 :=\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 \u03b1} {a : \u03b1} : (as.erase a) -l bs = (as -l bs).erase a :=\n  match bs with\n  | [] => rfl\n  | b :: bs => by simp only [eraseAll]; rw [\u2190erase_eraseAll, erase_comm]\n\n@[simp] theorem count_eraseAll (as bs : List \u03b1) (a : \u03b1) :\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 := \u2200 a, as.count a = bs.count a\ninfixl:50 \" \u2243 \" => isPermEqvTo -- Type as \\simeq\n\ndef isPermSubOf : Prop := \u2200 a, as.count a \u2264 bs.count a\ninfixl:50 \" \u2286 \" => isPermSubOf -- Type as \\sub\n\ntheorem permSubOfEraseSub : (as -l bs) \u2286 as := fun a => by simp [Nat.subLe]\n\ntheorem mem_of_mem_eraseAll {as bs : List \u03b1} {a : \u03b1} : a \u2208 (as -l bs) \u2192 a \u2208 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 \u03b1} : bs \u2286 as \u2192 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 \u2208 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', \u2190length_erase_mem hbas, Nat.succ_sub_succ]\n\ntheorem permSubExtend {as bs : List \u03b1} {b} (hsub : bs \u2286 as) (ha : b \u2208 (as -l bs)) : (b :: bs) \u2286 as := by\n  intro a\n  rw [mem_nonzeroCount, count_eraseAll, \u2190zeroLtIffSub] 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 \u03b1} (hsub : bs \u2286 as) \n    (hlength : bs.length < as.length) : { e // e \u2208 as -l bs} := by\n  have hl : (as -l bs).length > 0 := by rw [permSubEraseAllLength hsub, \u2190zeroLtIffSub]; assumption\n  revert hl; cases as -l bs\n  case nil => simp only [length_nil]; intro hl'; cases hl'\n  case cons => intros; exact \u27e8_, Mem.head _ _\u27e9\n\ntheorem permSubEqvClosed {as bs bs' : List \u03b1} (heqv : bs \u2243 bs') (hsub : bs \u2286 as) : bs' \u2286 as :=\n  fun a => by rw [\u2190heqv a]; exact hsub a\n\ntheorem permSubSingleton {as : List \u03b1} {a : \u03b1} : a \u2208 as \u2192 [a] \u2286 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) \u2243 (bs ++ as) :=\n  fun a => by simp [Nat.add_comm];\n\ntheorem permEqvRefl {as : List \u03b1} : as \u2243 as :=\n  fun a => rfl\n\ntheorem permEqvTrans {as bs cs : List \u03b1} (h : as \u2243 bs) (h' : bs \u2243 cs) : as \u2243 cs :=\n  fun a => Eq.trans (h a) (h' a)\n\ntheorem permEqvSymm {as bs : List \u03b1} (h : as \u2243 bs) : bs \u2243 as :=\n  fun a => by simp [Nat.add_comm, h a]\n\ntheorem permEqvToEraseAppend {as bs : List \u03b1} (ps : bs \u2286 as) : as \u2243 ((as -l bs) ++ bs) :=\n  fun a => by simp only [count_append, count_eraseAll]; rw [\u2190Nat.le_subAdd (ps a)]\n\ntheorem permEqvToEraseCons {as : List \u03b1} {a : \u03b1} (h : a \u2208 as) : as \u2243 (a :: (as.erase a)) := by\n  exact permEqvTrans (permEqvToEraseAppend (permSubSingleton h)) (permEqvRotate _ _)\n\ntheorem permEqvCons {as bs : List \u03b1} {a : \u03b1} (h : as \u2243 bs) : (a :: as) \u2243 (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 \u03b1} {a : \u03b1} (h : (a :: as) \u2286 bs) :\n  as \u2286 (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 \u03b1} : as \u2286 bs \u2192 as.length = bs.length \u2192 as \u2243 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 \u2208 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, \u2190hl, 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 \u03b1} {a : \u03b1} (hp : as \u2243 bs) : a \u2208 as \u2192 a \u2208 bs := by\n  rw [mem_nonzeroCount, mem_nonzeroCount, hp a]; intros; assumption\n\ntheorem permEqvEraseOfpermEqvCons {as bs : List \u03b1} {a : \u03b1} (h : (a :: as) \u2243 bs) : as \u2243 (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 [\u2190ha, 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 \u03b1} : as \u2243 bs \u2192 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 \u03b1} {a : \u03b1} {p : \u03b1 \u2192 Bool} (hpa : p a = true) (ha : a \u2208 as) :\n  (a :: filter p (List.erase as a)) \u2243 (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 \u2264 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 \u03b1} (p : \u03b1 \u2192 Bool) : as \u2243 bs \u2192 (filter p as) \u2243 (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 \u2208 bs := by rw [mem_nonzeroCount, \u2190h 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\u2019s 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 : \u2115}\n\n/-- u_stmt and u_wit are fin-indexed collections of polynomials from the square span program -/\nparameter {u_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {u_wit : fin n_wit \u2192 (polynomial F) }\nparameter {v_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {v_wit : fin n_wit \u2192 (polynomial F) }\nparameter {w_stmt : fin n_stmt \u2192 (polynomial F) }\nparameter {w_wit : fin n_wit \u2192 (polynomial F) }\n\n\n/-- The roots of the polynomial t -/\nparameter {r : fin n_wit \u2192 F} \n/-- t is the polynomial divisibility by which is used to verify satisfaction of the SSP -/\ndef t : polynomial F := \u220f 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 \u2192 F ) (a_wit : fin n_wit \u2192 F) := \n((\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 u_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 u_wit i))\n  * \n(\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 v_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 v_wit i))\n  -\n(\u2211 i in (finset.fin_range n_stmt), a_stmt i \u2022 w_stmt i\n  + (\u2211 i in (finset.fin_range n_wit), a_wit i \u2022 w_wit i)))\n   %\u2098 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_\u03b1  (f : groth16.vars \u2192 F) : polynomial F := polynomial.C (f vars.\u03b1)\n@[crs]\ndef crs_\u03b2 (f : groth16.vars \u2192 F) : polynomial F := polynomial.C (f vars.\u03b2)\n@[crs]\ndef crs_\u03b3 (f : groth16.vars \u2192 F) : polynomial F := polynomial.C (f vars.\u03b3)\n@[crs]\ndef crs_\u03b4 (f : groth16.vars \u2192 F) : polynomial F := polynomial.C (f vars.\u03b4)\n@[crs]\ndef crs_powers_of_x (i : fin n_var) (f : groth16.vars \u2192 F) : polynomial F := ((polynomial.X)^(i : \u2115))\n@[crs]\ndef crs_l (i : fin n_stmt) (f : groth16.vars \u2192 F) : polynomial F := \npolynomial.C (1 / f vars.\u03b3) * (polynomial.C (f vars.\u03b2 / f vars.\u03b3) * u_stmt i\n+\npolynomial.C  (f vars.\u03b1 / f vars.\u03b3) * v_stmt i\n+\n(w_stmt i)) \n@[crs]\ndef crs_m (i : fin n_wit) (f : groth16.vars \u2192 F) : polynomial F := \npolynomial.C (1 / f vars.\u03b4) * (polynomial.C  (f vars.\u03b2 / f vars.\u03b4) * (u_wit i)\n+\npolynomial.C  (f vars.\u03b1 / f vars.\u03b4) * (v_wit i)\n+\n(w_wit i)) \n@[crs]\ndef crs_n (i : fin (n_var - 1)) (f : groth16.vars \u2192 F) : polynomial F := \n(polynomial.X)^(i : \u2115) * t * polynomial.C (1 / f vars.\u03b4)\n\n/-- The coefficients of the CRS elements in the algebraic adversary's representation -/\nparameters {A_\u03b1 A_\u03b2 A_\u03b3 A_\u03b4 B_\u03b1 B_\u03b2 B_\u03b3 B_\u03b4 C_\u03b1 C_\u03b2 C_\u03b3 C_\u03b4  : F}\nparameters {A_x B_x C_x : fin n_var \u2192 F}\nparameters {A_l B_l C_l : fin n_stmt \u2192 F}\nparameters {A_m B_m C_m : fin n_wit \u2192 F}\nparameters {A_h B_h C_h : fin (n_var-1) \u2192 F}\n\n\n/-- Polynomial forms of the adversary's proof representation -/\ndef A : (groth16.vars \u2192 F) -> polynomial F := \u03bb f,\n  polynomial.C A_\u03b1 * (crs_\u03b1 f)\n\n\ndef B : (groth16.vars \u2192 F) -> polynomial F  :=  \u03bb f,\n  polynomial.C B_\u03b2 * crs_\u03b2 f\n\n\ndef C : (groth16.vars \u2192 F) -> polynomial F  :=  \u03bb f,\n  polynomial.C C_\u03b1 * crs_\u03b1 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 \u03b3\u03b4. \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'_\u03b1  : groth16polynomial := X vars.\u03b1 * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_\u03b2 : groth16polynomial := X vars.\u03b2 * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_\u03b3 : groth16polynomial := X vars.\u03b3 * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_\u03b4 : groth16polynomial := X vars.\u03b4 * X vars.\u03b3 * X vars.\u03b4\n@[crs]\ndef crs'_powers_of_x (i : fin n_var) : (groth16polynomial) := mv_polynomial.C (polynomial.X ^ (i : \u2115)) * X vars.\u03b3 * X vars.\u03b4\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.\u03b2 * X vars.\u03b4) * mv_polynomial.C (u_stmt i)\n+\n(X vars.\u03b1 * X vars.\u03b4) * mv_polynomial.C (v_stmt i)\n+\nX vars.\u03b4 * mv_polynomial.C (w_stmt i)\n@[crs]\ndef crs'_m (i : fin n_wit) : (groth16polynomial) := \n(X vars.\u03b2 * X vars.\u03b3) * mv_polynomial.C (u_wit i)\n+\n(X vars.\u03b1 * X vars.\u03b3) * mv_polynomial.C (v_wit i)\n+\nX vars.\u03b3 * mv_polynomial.C (w_wit i)\n@[crs]\ndef crs'_t (i : fin (n_var - 1)) : (groth16polynomial) := \nX vars.\u03b3 * mv_polynomial.C ((polynomial.X)^(i : \u2115) * t)\n\n\n/-- Polynomial form of A in the adversary's proof representation -/\ndef A'  : groth16polynomial := \n  crs'_\u03b1 * mv_polynomial.C (polynomial.C (A_\u03b1))\n  +\n  crs'_\u03b2 * mv_polynomial.C (polynomial.C (A_\u03b2))\n\n\n/-- Polynomial form of B in the adversary's proof representation -/\ndef B'  : groth16polynomial := \n  crs'_\u03b2 * mv_polynomial.C (polynomial.C (B_\u03b2))\n\n\n/-- Polynomial form of C in the adversary's proof representation -/\ndef C'  : groth16polynomial := \n  crs'_\u03b1 * mv_polynomial.C (polynomial.C (C_\u03b1))\n  +\n  crs'_\u03b2 * mv_polynomial.C (polynomial.C (C_\u03b2))\n  + \n  crs'_\u03b4 * mv_polynomial.C (polynomial.C (C_\u03b4))\n\n\n\n\n\n\nlemma modification_equivalence (a_stmt : fin n_stmt \u2192 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) : (\u00ac Q \u2192 \u00ac P) \u2192 (P \u2192 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u2192 B` and a homeomorphism `h : Z' \u2243\u209c Z`, returns a local trivialization of the fiber bundle\n  `p \u2218 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 `\u2102` and as a\nvector bundle over `\u211d`, 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 {\u03b9 : Type _} {B : Type _} {F : Type _} {E : B \u2192 Type _}\n\nvariable (F) {Z : Type _} [TopologicalSpace B] [TopologicalSpace F] {proj : Z \u2192 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 \u2192 B) extends LocalEquiv Z (B \u00d7 F) where\n  open_target : IsOpen target\n  baseSet : Set B\n  open_baseSet : IsOpen baseSet\n  source_eq : source = proj \u207b\u00b9' baseSet\n  target_eq : target = baseSet \u00d7\u02e2 univ\n  proj_toFun : \u2200 p \u2208 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 \u2192 (B \u00d7 F) := e.toFun\n\ninstance : CoeFun (Pretrivialization F proj) fun _ => Z \u2192 B \u00d7 F := \u27e8toFun'\u27e9\n\n@[ext]\nlemma ext' (e e' : Pretrivialization F proj) (h\u2081 : e.toLocalEquiv = e'.toLocalEquiv)\n    (h\u2082 : 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\u2081 : \u2200 x, e x = e' x)\n    (h\u2082 : \u2200 x, e.toLocalEquiv.symm x = e'.toLocalEquiv.symm x) (h\u2083 : e.baseSet = e'.baseSet) :\n    e = e' := by\n  ext1 <;> [ext1, exact h\u2083]\n  \u00b7 apply h\u2081\n  \u00b7 apply h\u2082\n  \u00b7 rw [e.source_eq, e'.source_eq, h\u2083]\n\n/-- If the fiber is nonempty, then the projection to -/\nlemma toLocalEquiv_injective [Nonempty F] :\n    Injective (toLocalEquiv : Pretrivialization F proj \u2192 LocalEquiv Z (B \u00d7 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 \u00b7) h\n\n@[simp, mfld_simps]\ntheorem coe_coe : \u21d1e.toLocalEquiv = e :=\n  rfl\n#align pretrivialization.coe_coe Pretrivialization.coe_coe\n\n@[simp, mfld_simps]\ntheorem coe_fst (ex : x \u2208 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 \u2208 e.source \u2194 proj x \u2208 e.baseSet := by rw [e.source_eq, mem_preimage]\n#align pretrivialization.mem_source Pretrivialization.mem_source\n\ntheorem coe_fst' (ex : proj x \u2208 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 \u2218 e) proj e.source := fun _ hx => e.coe_fst hx\n#align pretrivialization.eq_on Pretrivialization.eqOn\n\ntheorem mk_proj_snd (ex : x \u2208 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 \u2208 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 \u2192 Z :=\n  e.target.restrict e.toLocalEquiv.symm\n#align pretrivialization.set_symm Pretrivialization.setSymm\n\ntheorem mem_target {x : B \u00d7 F} : x \u2208 e.target \u2194 x.1 \u2208 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 \u00d7 F} (hx : x \u2208 e.target) : proj (e.toLocalEquiv.symm x) = x.1 := by\n  have := (e.coe_fst (e.map_target hx)).symm\n  rwa [\u2190 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 \u2208 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 \u27e8y\u27e9 := \u2039Nonempty F\u203a\n  \u27e8e.toLocalEquiv.symm (b, y), e.toLocalEquiv.map_target <| e.mem_target.2 hb,\n    e.proj_symm_apply' hb\u27e9\n#align pretrivialization.proj_surj_on_base_set Pretrivialization.proj_surjOn_baseSet\n\ntheorem apply_symm_apply {x : B \u00d7 F} (hx : x \u2208 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 \u2208 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 \u2208 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 \u2208 e.source) :\n    e.toLocalEquiv.symm (proj x, (e x).2) = x := by\n  rw [\u2190 e.coe_fst ex, Prod.mk.eta, \u2190 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 \u207b\u00b9' (proj \u207b\u00b9' e.baseSet) \u2229 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 \u207b\u00b9' (proj \u207b\u00b9' s) \u2229 e.baseSet \u00d7\u02e2 univ = (s \u2229 e.baseSet) \u00d7\u02e2 univ := by\n  ext \u27e8x, y\u27e9\n  suffices x \u2208 e.baseSet \u2192 (proj (e.toLocalEquiv.symm (x, y)) \u2208 s \u2194 x \u2208 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 \u2229 f.toLocalEquiv.symm \u207b\u00b9' e.source = (e.baseSet \u2229 f.baseSet) \u00d7\u02e2 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 \u2229 f.baseSet) \u00d7\u02e2 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 \u2229 e'.baseSet) \u00d7\u02e2 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 (\u03c0 E)) {x' : TotalSpace E} {b : B} {y : E b}\n\ntheorem coe_mem_source : \u2191y \u2208 e'.source \u2194 b \u2208 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 \u2208 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) \u2208 e'.target \u2194 x \u2208 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 (\u03c0 E)) (h : x \u2208 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 [\u2200 x, Zero (E x)]\n\n/-- A fiberwise inverse to `e`. This is the function `F \u2192 E b` that induces a local inverse\n`B \u00d7 F \u2192 total_space E` of `e` on `e.baseSet`. It is defined to be `0` outside `e.baseSet`. -/\nprotected noncomputable def symm (e : Pretrivialization F (\u03c0 E)) (b : B) (y : F) : E b :=\n  if hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2209 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 (\u03c0 E)) {b : B} (hb : b \u2209 e.baseSet) :\n    (e.symm b : F \u2192 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) (z : TotalSpace E)\n    (hz : z.proj \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 \u2192 B` with fiber `F`, as a local homeomorphism between `Z` and `B \u00d7 F` defined between two\nsets of the form `proj \u207b\u00b9' baseSet` and `baseSet \u00d7 F`, acting trivially on the first coordinate.\n-/\n-- porting note: todo: was @[nolint has_nonempty_instance]\nstructure Trivialization (proj : Z \u2192 B) extends LocalHomeomorph Z (B \u00d7 F) where\n  baseSet : Set B\n  open_baseSet : IsOpen baseSet\n  source_eq : source = proj \u207b\u00b9' baseSet\n  target_eq : target = baseSet \u00d7\u02e2 univ\n  proj_toFun : \u2200 p \u2208 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\u2081 : e.toLocalHomeomorph = e'.toLocalHomeomorph)\n    (h\u2082 : 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 \u2192 (B \u00d7 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 \u2192 B \u00d7 F := \u27e8toFun'\u27e9\n\ninstance : Coe (Trivialization F proj) (Pretrivialization F proj) :=\n  \u27e8toPretrivialization\u27e9\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 : \u21d1e.toLocalHomeomorph = e :=\n  rfl\n#align trivialization.coe_coe Trivialization.coe_coe\n\n@[simp, mfld_simps]\ntheorem coe_fst (ex : x \u2208 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 \u2218 e) proj e.source := fun _x hx => e.coe_fst hx\n#align trivialization.eq_on Trivialization.eqOn\n\ntheorem mem_source : x \u2208 e.source \u2194 proj x \u2208 e.baseSet := by rw [e.source_eq, mem_preimage]\n#align trivialization.mem_source Trivialization.mem_source\n\ntheorem coe_fst' (ex : proj x \u2208 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 \u2208 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 \u2208 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 \u00d7 F)) :\n    e.source \u2229 e \u207b\u00b9' (e.target \u2229 s) = e.source \u2229 e \u207b\u00b9' 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 \u00d7 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 \u00d7 F} : x \u2208 e.target \u2194 x.1 \u2208 e.baseSet :=\n  e.toPretrivialization.mem_target\n#align trivialization.mem_target Trivialization.mem_target\n\ntheorem map_target {x : B \u00d7 F} (hx : x \u2208 e.target) : e.toLocalHomeomorph.symm x \u2208 e.source :=\n  e.toLocalHomeomorph.map_target hx\n#align trivialization.map_target Trivialization.map_target\n\ntheorem proj_symm_apply {x : B \u00d7 F} (hx : x \u2208 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 \u2208 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 \u00d7 F} (hx : x \u2208 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 \u2208 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 \u2208 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 \u2229 e'.baseSet) \u00d7\u02e2 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 \u2229 e'.baseSet) \u00d7\u02e2 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 \u2208 e.source) : Prod.fst \u2218 e =\u1da0[\ud835\udcdd x] proj :=\n  mem_nhds_iff.2 \u27e8e.source, fun _y hy => e.coe_fst hy, e.open_source, ex\u27e9\n#align trivialization.coe_fst_eventually_eq_proj Trivialization.coe_fst_eventuallyEq_proj\n\ntheorem coe_fst_eventuallyEq_proj' (ex : proj x \u2208 e.baseSet) : Prod.fst \u2218 e =\u1da0[\ud835\udcdd 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 \u2208 e.source) : map proj (\ud835\udcdd x) = \ud835\udcdd (proj x) := by\n  rw [\u2190 e.coe_fst ex, \u2190 map_congr (e.coe_fst_eventuallyEq_proj ex), \u2190 map_map, \u2190 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 \u2286 e.baseSet) : proj \u207b\u00b9' s \u2286 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 \u2286 e.baseSet) :\n    e '' (proj \u207b\u00b9' s) = s \u00d7\u02e2 univ :=\n  Subset.antisymm\n    (image_subset_iff.mpr fun p hp =>\n      \u27e8(e.proj_toFun p (e.preimage_subset_source hb hp)).symm \u25b8 hp, trivial\u27e9)\n    fun p hp =>\n    let hp' : p \u2208 e.target := e.mem_target.mpr (hb hp.1)\n    \u27e8e.invFun p, mem_preimage.mpr ((e.proj_symm_apply hp').symm \u25b8 hp.1), e.apply_symm_apply hp'\u27e9\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 \u2286 e.baseSet) : proj \u207b\u00b9' s \u2243\u209c s \u00d7 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 \u2286 e.baseSet) (p : proj \u207b\u00b9' s) :\n    e.preimageHomeomorph hb p = (\u27e8proj p, p.2\u27e9, (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 \u2286 e.baseSet) (p : s \u00d7 F) :\n    (e.preimageHomeomorph hb).symm p = \u27e8e.symm (p.1, p.2), ((e.preimageHomeomorph hb).symm p).2\u27e9 :=\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 \u2243\u209c e.baseSet \u00d7 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 = (\u27e8proj p, e.mem_source.mp p.2\u27e9, (e p).2) :=\n  e.preimageHomeomorph_apply subset_rfl \u27e8p, e.mem_source.mp p.2\u27e9\n#align trivialization.source_homeomorph_base_set_prod_apply Trivialization.sourceHomeomorphBaseSetProd_apply\n\n@[simp]\ntheorem sourceHomeomorphBaseSetProd_symm_apply (p : e.baseSet \u00d7 F) :\n    e.sourceHomeomorphBaseSetProd.symm p =\n      \u27e8e.symm (p.1, p.2), (e.sourceHomeomorphBaseSetProd.symm p).2\u27e9 :=\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 \u2208 e.baseSet) : proj \u207b\u00b9' {b} \u2243\u209c 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 \u2208 e.baseSet) (p : proj \u207b\u00b9' {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 \u2208 e.baseSet) (p : F) :\n    (e.preimageSingletonHomeomorph hb).symm p =\n      \u27e8e.symm (b, p), by rw [mem_preimage, e.proj_symm_apply' hb, mem_singleton_iff]\u27e9 :=\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 \u2208 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' \u2243\u209c Z) :\n    Trivialization F (proj \u2218 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, (\u00b7 \u2218 \u00b7)]\n  target_eq := by simp [target_eq]\n  proj_toFun p hp := by\n    have hp : h p \u2208 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 \u2192 X` at `z : Z` by transferring via a\ntrivialization of `Z` containing `z`. -/\ntheorem continuousAt_of_comp_right {X : Type _} [TopologicalSpace X] {f : Z \u2192 X} {z : Z}\n    (e : Trivialization F proj) (he : proj z \u2208 e.baseSet)\n    (hf : ContinuousAt (f \u2218 e.toLocalEquiv.symm) (e z)) : ContinuousAt f z := by\n  have hez : z \u2208 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 \u2192 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 \u2192 Z} {x : X}\n    (e : Trivialization F proj) (hf_proj : ContinuousAt (proj \u2218 f) x) (he : proj (f x) \u2208 e.baseSet)\n    (hf : ContinuousAt (e \u2218 f) x) : ContinuousAt f x := by\n  rw [e.continuousAt_iff_continuousAt_comp_left]\n  \u00b7 exact hf\n  rw [e.source_eq, \u2190 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 (\u03c0 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 : \u2191y \u2208 e'.source \u2194 b \u2208 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 \u2208 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) \u2208 e'.target \u2194 b \u2208 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 \u2208 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 (\u03c0 E)) (h : x \u2208 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 [\u2200 x, Zero (E x)]\n\n/-- A fiberwise inverse to `e'`. The function `F \u2192 E x` that induces a local inverse\n`B \u00d7 F \u2192 total_space E` of `e'` on `e'.baseSet`. It is defined to be `0` outside `e'.baseSet`. -/\nprotected noncomputable def symm (e : Trivialization F (\u03c0 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2209 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) (z : TotalSpace E) (hz : z.proj \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) {b : B} (hb : b \u2208 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 (\u03c0 E)) :\n    ContinuousOn (fun z : B \u00d7 F => totalSpaceMk z.1 (e.symm z.1 z.2)) (e.baseSet \u00d7\u02e2 univ) := by\n  have : \u2200 z \u2208 e.baseSet \u00d7\u02e2 (univ : Set F),\n      totalSpaceMk z.1 (e.symm z.1 z.2) = e.toLocalHomeomorph.symm z := by\n    rintro x \u27e8hx : x.1 \u2208 e.baseSet, _\u27e9\n    rw [e.mk_symm hx]\n  refine' ContinuousOn.congr _ this\n  rw [\u2190 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 \u2192 B` with fiber `F` and `h` is a homeomorphism\n`F \u2243\u209c 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 \u2243\u209c 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 \u2243\u209c 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 \u2243\u209c F`. -/\ndef coordChange (e\u2081 e\u2082 : Trivialization F proj) (b : B) (x : F) : F :=\n  (e\u2082 <| e\u2081.toLocalHomeomorph.symm (b, x)).2\n#align trivialization.coord_change Trivialization.coordChange\n\ntheorem mk_coordChange (e\u2081 e\u2082 : Trivialization F proj) {b : B} (h\u2081 : b \u2208 e\u2081.baseSet)\n    (h\u2082 : b \u2208 e\u2082.baseSet) (x : F) :\n    (b, e\u2081.coordChange e\u2082 b x) = e\u2082 (e\u2081.toLocalHomeomorph.symm (b, x)) := by\n  refine' Prod.ext _ rfl\n  rw [e\u2082.coe_fst', \u2190 e\u2081.coe_fst', e\u2081.apply_symm_apply' h\u2081]\n  \u00b7 rwa [e\u2081.proj_symm_apply' h\u2081]\n  \u00b7 rwa [e\u2081.proj_symm_apply' h\u2081]\n#align trivialization.mk_coord_change Trivialization.mk_coordChange\n\ntheorem coordChange_apply_snd (e\u2081 e\u2082 : Trivialization F proj) {p : Z} (h : proj p \u2208 e\u2081.baseSet) :\n    e\u2081.coordChange e\u2082 (proj p) (e\u2081 p).snd = (e\u2082 p).snd := by\n  rw [coordChange, e\u2081.symm_apply_mk_proj (e\u2081.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 \u2208 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 \u2208 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\u2081 e\u2082 e\u2083 : Trivialization F proj) {b : B} (h\u2081 : b \u2208 e\u2081.baseSet)\n    (h\u2082 : b \u2208 e\u2082.baseSet) (x : F) :\n    e\u2082.coordChange e\u2083 b (e\u2081.coordChange e\u2082 b x) = e\u2081.coordChange e\u2083 b x := by\n  rw [coordChange, e\u2081.mk_coordChange _ h\u2081 h\u2082, \u2190 e\u2082.coe_coe, e\u2082.left_inv, coordChange]\n  rwa [e\u2082.mem_source, e\u2081.proj_symm_apply' h\u2081]\n#align trivialization.coord_change_coord_change Trivialization.coordChange_coordChange\n\ntheorem continuous_coordChange (e\u2081 e\u2082 : Trivialization F proj) {b : B} (h\u2081 : b \u2208 e\u2081.baseSet)\n    (h\u2082 : b \u2208 e\u2082.baseSet) : Continuous (e\u2081.coordChange e\u2082 b) := by\n  refine' continuous_snd.comp (e\u2082.toLocalHomeomorph.continuousOn.comp_continuous\n    (e\u2081.toLocalHomeomorph.continuousOn_symm.comp_continuous _ _) _)\n  \u00b7 exact continuous_const.prod_mk continuous_id\n  \u00b7 exact fun x => e\u2081.mem_target.2 h\u2081\n  \u00b7 intro x\n    rwa [e\u2082.mem_source, e\u2081.proj_symm_apply' h\u2081]\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\u2081 e\u2082 : Trivialization F proj) {b : B} (h\u2081 : b \u2208 e\u2081.baseSet)\n    (h\u2082 : b \u2208 e\u2082.baseSet) : F \u2243\u209c F where\n  toFun := e\u2081.coordChange e\u2082 b\n  invFun := e\u2082.coordChange e\u2081 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\u2081.continuous_coordChange e\u2082 h\u2081 h\u2082\n  continuous_invFun := e\u2082.continuous_coordChange e\u2081 h\u2082 h\u2081\n#align trivialization.coord_change_homeomorph Trivialization.coordChangeHomeomorph\n\n@[simp]\ntheorem coordChangeHomeomorph_coe (e\u2081 e\u2082 : Trivialization F proj) {b : B} (h\u2081 : b \u2208 e\u2081.baseSet)\n    (h\u2082 : b \u2208 e\u2082.baseSet) : \u21d1(e\u2081.coordChangeHomeomorph e\u2082 h\u2081 h\u2082) = e\u2081.coordChange e\u2082 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 \u207b\u00b9' s) (s \u00d7\u02e2 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 \u2229 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 \u2229 frontier (proj \u207b\u00b9' s) = proj \u207b\u00b9' (e.baseSet \u2229 frontier s) := by\n  rw [\u2190 (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 \u2192 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 \u2208 e.baseSet \u2229 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 \u207b\u00b9 s` and is equal to `e'`\notherwise. -/\nnoncomputable def piecewise (e e' : Trivialization F proj) (s : Set B)\n    (Hs : e.baseSet \u2229 frontier s = e'.baseSet \u2229 frontier s)\n    (Heq : EqOn e e' <| proj \u207b\u00b9' (e.baseSet \u2229 frontier s)) : Trivialization F proj where\n  toLocalHomeomorph :=\n    e.toLocalHomeomorph.piecewise e'.toLocalHomeomorph (proj \u207b\u00b9' s) (s \u00d7\u02e2 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 (\u27e8he, hs\u27e9 | \u27e8he, hs\u27e9)\n    -- porting note: was `<;> simp [*]`\n    \u00b7 simp [piecewise_eq_of_mem _ _ _ hs, *]\n    \u00b7 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 \u2192 B`\nover a linearly ordered base `B` and a point `a \u2208 e.baseSet \u2229 e'.baseSet` such that\n`e` equals `e'` on `proj \u207b\u00b9' {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 \u2264 a` and is equal to `e'` otherwise. -/\nnoncomputable def piecewiseLeOfEq [LinearOrder B] [OrderTopology B] (e e' : Trivialization F proj)\n    (a : B) (He : a \u2208 e.baseSet) (He' : a \u2208 e'.baseSet) (Heq : \u2200 p, proj p = a \u2192 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 \u2192 B` over a\nlinearly ordered base `B` and a point `a \u2208 e.baseSet \u2229 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 \u2264 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 \u2208 e.baseSet) (He' : a \u2208 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    \u00b7 simp [e.coe_fst', e'.coe_fst', *]\n    \u00b7 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 \u27e8hx.1.1, hx.2.1\u27e9)\n  baseSet := e.baseSet \u222a e'.baseSet\n  open_baseSet := IsOpen.union e.open_baseSet e'.open_baseSet\n  source_eq := congr_arg\u2082 (\u00b7 \u222a \u00b7) e.source_eq e'.source_eq\n  target_eq := (congr_arg\u2082 (\u00b7 \u222a \u00b7) e.target_eq e'.target_eq).trans union_prod.symm\n  proj_toFun := by\n    rintro p (hp | hp')\n    \u00b7 show (e.source.piecewise e e' p).1 = proj p\n      rw [piecewise_eq_of_mem, e.coe_fst] <;> exact hp\n    \u00b7 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' \u22a2\n      exact fun h => H.le_bot \u27e8h, hp'\u27e9\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 : \u2200 x y : Nat, x = y \u2192 y = x := by\n  intros\n  apply Eq.symm\n  assumption\n\nexample : \u2200 x y : Nat, x = y \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 : Sort*} {\u03b2 : Sort*}\n\nnamespace setoid\n\nlemma ext {\u03b1 : Sort*} :\n  \u2200{s t : setoid \u03b1}, (\u2200a b, @setoid.r \u03b1 s a b \u2194 @setoid.r \u03b1 t a b) \u2192 s = t\n| \u27e8r, _\u27e9 \u27e8p, _\u27e9 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} {rb : \u03b2 \u2192 \u03b2 \u2192 Prop} {\u03c6 : quot ra \u2192 quot rb \u2192 Sort*}\nlocal notation `\u27e6`:max a `\u27e7` := quot.mk _ a\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [inhabited \u03b1] : inhabited (quot r) := \u27e8\u27e6default\u27e7\u27e9\n\ninstance [subsingleton \u03b1] : subsingleton (quot ra) :=\n\u27e8\u03bb x, quot.induction_on x (\u03bb y, quot.ind (\u03bb b, congr_arg _ (subsingleton.elim _ _)))\u27e9\n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082 (qa : quot ra) (qb : quot rb) (f : \u03a0 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n  (ca : \u2200 {b a\u2081 a\u2082}, ra a\u2081 a\u2082 \u2192 f a\u2081 b == f a\u2082 b)\n  (cb : \u2200 {a b\u2081 b\u2082}, rb b\u2081 b\u2082 \u2192 f a b\u2081 == f a b\u2082) : \u03c6 qa qb :=\nquot.hrec_on qa (\u03bb a, quot.hrec_on qb (f a) (\u03bb b\u2081 b\u2082 pb, cb pb)) $ \u03bb a\u2081 a\u2082 pa,\n  quot.induction_on qb $ \u03bb b,\n    calc @quot.hrec_on _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2081) (@cb _)\n          == f a\u2081 b                                     : by simp [heq_self_iff_true]\n      ... == f a\u2082 b                                     : ca pa\n      ... == @quot.hrec_on _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2082) (@cb _) : by simp [heq_self_iff_true]\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` such that `ra x y` implies `rb (f x) (f y)`\nto a map `quot ra \u2192 quot rb`. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : (ra \u21d2 rb) f f) : quot ra \u2192 quot rb :=\nquot.lift (\u03bb x, \u27e6f x\u27e7) $ assume x y (h\u2081 : ra x y), quot.sound $ h h\u2081\n\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `quot ra \u2192 quot ra'`. -/\nprotected def map_right {ra' : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : \u2200a\u2081 a\u2082, ra a\u2081 a\u2082 \u2192 ra' a\u2081 a\u2082) :\n  quot ra \u2192 quot ra' :=\nquot.map id h\n\n/-- weaken the relation of a quotient -/\ndef factor {\u03b1 : Type*} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) :\n  quot r \u2192 quot s :=\nquot.lift (quot.mk s) (\u03bb x y rxy, quot.sound (h x y rxy))\n\nlemma factor_mk_eq {\u03b1 : Type*} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) :\n  factor r s h \u2218 quot.mk _ = quot.mk _ := rfl\n\nvariables {\u03b3 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n\n/-- **Alias** of `quot.lift_beta`. -/\nlemma lift_mk (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) (a : \u03b1) :\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 : \u03b1) (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) :\n  quot.lift_on (quot.mk r a) f h = f a := rfl\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2`. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift\u2082\n  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b)\n  (q\u2081 : quot r) (q\u2082 : quot s) : \u03b3 :=\nquot.lift (\u03bb a, quot.lift (f a) (hr a))\n(\u03bb a\u2081 a\u2082 ha, funext (\u03bb q, quot.induction_on q (\u03bb b, hs a\u2081 a\u2082 b ha)))\nq\u2081 q\u2082\n\n@[simp]\nlemma lift\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) (a : \u03b1) (b : \u03b2) :\n  quot.lift\u2082 f hr hs (quot.mk r a) (quot.mk s b) = f a b := rfl\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` and applies it. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift_on\u2082 (p : quot r) (q : quot s) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) : \u03b3 := quot.lift\u2082 f hr hs p q\n\n@[simp]\nlemma lift_on\u2082_mk (a : \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) :\n  quot.lift_on\u2082 (quot.mk r a) (quot.mk s b) f hr hs = f a b := rfl\n\nvariables {t : \u03b3 \u2192 \u03b3 \u2192 Prop}\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` wih values in a quotient of\n`\u03b3`. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b))\n  (q\u2081 : quot r) (q\u2082 : quot s) : quot t :=\nquot.lift\u2082 (\u03bb a b, quot.mk t $ f a b) (\u03bb a b\u2081 b\u2082 hb, quot.sound (hr a b\u2081 b\u2082 hb))\n(\u03bb a\u2081 a\u2082 b ha, quot.sound (hs a\u2081 a\u2082 b ha)) q\u2081 q\u2082\n\n@[simp]\nlemma map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b))\n  (a : \u03b1) (b : \u03b2) : quot.map\u2082 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\u2082\n  {\u03b4 : quot r \u2192 quot s \u2192 Prop} (q\u2081 : quot r) (q\u2082 : quot s)\n  (h : \u2200 a b, \u03b4 (quot.mk r a) (quot.mk s b)) : \u03b4 q\u2081 q\u2082 :=\nquot.ind (\u03bb a\u2081, quot.ind (\u03bb a\u2082, h a\u2081 a\u2082) q\u2082) q\u2081\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on\u2083\n  {\u03b4 : quot r \u2192 quot s \u2192 quot t \u2192 Prop} (q\u2081 : quot r) (q\u2082 : quot s) (q\u2083 : quot t)\n  (h : \u2200 a b c, \u03b4 (quot.mk r a) (quot.mk s b) (quot.mk t c)) : \u03b4 q\u2081 q\u2082 q\u2083 :=\nquot.ind (\u03bb a\u2081, quot.ind (\u03bb a\u2082, quot.ind (\u03bb a\u2083, h a\u2081 a\u2082 a\u2083) q\u2083) q\u2082) q\u2081\n\nend quot\n\nnamespace quotient\nvariables [sa : setoid \u03b1] [sb : setoid \u03b2]\nvariables {\u03c6 : quotient sa \u2192 quotient sb \u2192 Sort*}\n\ninstance (s : setoid \u03b1) [inhabited \u03b1] : inhabited (quotient s) := \u27e8\u27e6default\u27e7\u27e9\n\ninstance (s : setoid \u03b1) [subsingleton \u03b1] : subsingleton (quotient s) :=\nquot.subsingleton\n\n/-- Induction on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082 (qa : quotient sa) (qb : quotient sb) (f : \u03a0 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) : \u03c6 qa qb :=\nquot.hrec_on\u2082 qa qb f\n  (\u03bb _ _ _ p, c _ _ _ _ p (setoid.refl _))\n  (\u03bb _ _ _ p, c _ _ _ _ (setoid.refl _) p)\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `quotient sa \u2192 quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : ((\u2248) \u21d2 (\u2248)) f f) : quotient sa \u2192 quotient sb :=\nquot.map f h\n\n@[simp] lemma map_mk (f : \u03b1 \u2192 \u03b2) (h : ((\u2248) \u21d2 (\u2248)) f f) (x : \u03b1) :\n  quotient.map f h (\u27e6x\u27e7 : quotient sa) = (\u27e6f x\u27e7 : quotient sb) :=\nrfl\n\nvariables {\u03b3 : Sort*} [sc : setoid \u03b3]\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` that sends equivalent elements to equivalent elements\nto a function `f : quotient sa \u2192 quotient sb \u2192 quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u2248) \u21d2 (\u2248) \u21d2 (\u2248)) f f) :\n  quotient sa \u2192 quotient sb \u2192 quotient sc :=\nquotient.lift\u2082 (\u03bb x y, \u27e6f x y\u27e7) (\u03bb x\u2081 y\u2081 x\u2082 y\u2082 h\u2081 h\u2082, quot.sound $ h h\u2081 h\u2082)\n\n@[simp] lemma map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u2248) \u21d2 (\u2248) \u21d2 (\u2248)) f f) (x : \u03b1) (y : \u03b2) :\n  quotient.map\u2082 f h (\u27e6x\u27e7 : quotient sa) (\u27e6y\u27e7 : quotient sb) = (\u27e6f x y\u27e7 : quotient sc) := rfl\n\nend quotient\n\nlemma quot.eq {\u03b1 : Type*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {x y : \u03b1} :\n  quot.mk r x = quot.mk r y \u2194 eqv_gen r x y :=\n\u27e8quot.exact r, quot.eqv_gen_sound\u27e9\n\n@[simp] theorem quotient.eq [r : setoid \u03b1] {x y : \u03b1} : \u27e6x\u27e7 = \u27e6y\u27e7 \u2194 x \u2248 y :=\n\u27e8quotient.exact, quotient.sound\u27e9\n\ntheorem forall_quotient_iff {\u03b1 : Type*} [r : setoid \u03b1] {p : quotient r \u2192 Prop} :\n  (\u2200a:quotient r, p a) \u2194 (\u2200a:\u03b1, p \u27e6a\u27e7) :=\n\u27e8assume h x, h _, assume h a, a.induction_on h\u27e9\n\n@[simp] lemma quotient.lift_mk [s : setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b)\n  (x : \u03b1) :\n  quotient.lift f h (quotient.mk x) = f x := rfl\n\n@[simp] lemma quotient.lift_comp_mk [setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b) :\n  quotient.lift f h \u2218 quotient.mk = f :=\nrfl\n\n@[simp] lemma quotient.lift\u2082_mk {\u03b1 : Sort*} {\u03b2 : Sort*} {\u03b3 : Sort*} [setoid \u03b1] [setoid \u03b2]\n  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (h : \u2200 (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082)\n  (a : \u03b1) (b : \u03b2) :\n  quotient.lift\u2082 f h (quotient.mk a) (quotient.mk b) = f a b := rfl\n\n@[simp] lemma quotient.lift_on_mk [s : setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b)\n  (x : \u03b1) :\n  quotient.lift_on (quotient.mk x) f h = f x := rfl\n\n@[simp] theorem quotient.lift_on\u2082_mk {\u03b1 : Sort*} {\u03b2 : Sort*} [setoid \u03b1] (f : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n  (h : \u2200 (a\u2081 a\u2082 b\u2081 b\u2082 : \u03b1), a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) (x y : \u03b1) :\n  quotient.lift_on\u2082 (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 : \u03b1 \u2192 \u03b1 \u2192 Prop) : function.surjective (quot.mk r) :=\nquot.exists_rep\n\n/-- `quotient.mk` is a surjective function. -/\nlemma surjective_quotient_mk (\u03b1 : Sort*) [s : setoid \u03b1] :\n  function.surjective (quotient.mk : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} (q : quot r) : \u03b1 :=\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 : \u03b1 \u2192 \u03b1 \u2192 Prop} : quot r \u2192 \u03b1 := unchecked_cast\n\n@[simp] theorem quot.out_eq {r : \u03b1 \u2192 \u03b1 \u2192 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 \u03b1] : quotient s \u2192 \u03b1 := quot.out\n\n@[simp] theorem quotient.out_eq [s : setoid \u03b1] (q : quotient s) : \u27e6q.out\u27e7 = q := q.out_eq\n\ntheorem quotient.mk_out [s : setoid \u03b1] (a : \u03b1) : \u27e6a\u27e7.out \u2248 a :=\nquotient.exact (quotient.out_eq _)\n\nlemma quotient.mk_eq_iff_out [s : setoid \u03b1] {x : \u03b1} {y : quotient s} :\n  \u27e6x\u27e7 = y \u2194 x \u2248 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 \u03b1] {x : quotient s} {y : \u03b1} :\n  x = \u27e6y\u27e7 \u2194 quotient.out x \u2248 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 \u03b1} {x y : quotient s} :\n  x.out \u2248 y.out \u2194 x = y :=\nby rw [\u2190 quotient.eq_mk_iff_out, quotient.out_eq]\n\n@[simp] lemma quotient.out_inj {s : setoid \u03b1} {x y : quotient s} :\n  x.out = y.out \u2194 x = y :=\n\u27e8\u03bb h, quotient.out_equiv_out.1 $ h \u25b8 setoid.refl _, \u03bb h, h \u25b8 rfl\u27e9\n\nsection pi\n\ninstance pi_setoid {\u03b9 : Sort*} {\u03b1 : \u03b9 \u2192 Sort*} [\u2200 i, setoid (\u03b1 i)] : setoid (\u03a0 i, \u03b1 i) :=\n{ r := \u03bb a b, \u2200 i, a i \u2248 b i,\n  iseqv := \u27e8\n    \u03bb a i, setoid.refl _,\n    \u03bb a b h i, setoid.symm (h _),\n    \u03bb a b c h\u2081 h\u2082 i, setoid.trans (h\u2081 _) (h\u2082 _)\u27e9 }\n\n/-- Given a function `f : \u03a0 i, quotient (S i)`, returns the class of functions `\u03a0 i, \u03b1 i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def quotient.choice {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [S : \u03a0 i, setoid (\u03b1 i)]\n  (f : \u03a0 i, quotient (S i)) : @quotient (\u03a0 i, \u03b1 i) (by apply_instance) :=\n\u27e6\u03bb i, (f i).out\u27e7\n\n@[simp] theorem quotient.choice_eq {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u03a0 i, setoid (\u03b1 i)]\n  (f : \u03a0 i, \u03b1 i) : quotient.choice (\u03bb i, \u27e6f i\u27e7) = \u27e6f\u27e7 :=\nquotient.sound $ \u03bb i, quotient.mk_out _\n\n@[elab_as_eliminator] lemma quotient.induction_on_pi\n   {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Sort*} [s : \u2200 i, setoid (\u03b1 i)]\n   {p : (\u03a0 i, quotient (s i)) \u2192 Prop} (f : \u03a0 i, quotient (s i))\n   (h : \u2200 a : \u03a0 i, \u03b1 i, p (\u03bb i, \u27e6a i\u27e7)) : p f :=\nbegin\n  rw \u2190 (funext (\u03bb i, quotient.out_eq (f i)) : (\u03bb i,  \u27e6(f i).out\u27e7) = f),\n  apply h,\nend\n\nend pi\n\nlemma nonempty_quotient_iff (s : setoid \u03b1) : nonempty (quotient s) \u2194 nonempty \u03b1 :=\n\u27e8assume \u27e8a\u27e9, quotient.induction_on a nonempty.intro, assume \u27e8a\u27e9, \u27e8\u27e6a\u27e7\u27e9\u27e9\n\n/-- `trunc \u03b1` is the quotient of `\u03b1` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty \u03b1`, but unlike `nonempty \u03b1`, `trunc \u03b1` is data,\n  so the VM representation is the same as `\u03b1`, and so this can be used to\n  maintain computability. -/\ndef {u} trunc (\u03b1 : Sort u) : Sort u := @quot \u03b1 (\u03bb _ _, true)\n\ntheorem true_equivalence : @equivalence \u03b1 (\u03bb _ _, true) :=\n\u27e8\u03bb _, trivial, \u03bb _ _ _, trivial, \u03bb _ _ _ _ _, trivial\u27e9\n\nnamespace trunc\n\n/-- Constructor for `trunc \u03b1` -/\ndef mk (a : \u03b1) : trunc \u03b1 := quot.mk _ a\n\ninstance [inhabited \u03b1] : inhabited (trunc \u03b1) := \u27e8mk default\u27e9\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : \u03b1 \u2192 \u03b2) (c : \u2200 a b : \u03b1, f a = f b) : trunc \u03b1 \u2192 \u03b2 :=\nquot.lift f (\u03bb a b _, c a b)\n\ntheorem ind {\u03b2 : trunc \u03b1 \u2192 Prop} : (\u2200 a : \u03b1, \u03b2 (mk a)) \u2192 \u2200 q : trunc \u03b1, \u03b2 q := quot.ind\n\nprotected theorem lift_mk (f : \u03b1 \u2192 \u03b2) (c) (a : \u03b1) : lift f c (mk a) = f a := rfl\n\n/-- Lift a constant function on `q : trunc \u03b1`. -/\n@[reducible, elab_as_eliminator]\nprotected def lift_on (q : trunc \u03b1) (f : \u03b1 \u2192 \u03b2)\n  (c : \u2200 a b : \u03b1, f a = f b) : \u03b2 := lift f c q\n\n@[elab_as_eliminator]\nprotected theorem induction_on {\u03b2 : trunc \u03b1 \u2192 Prop} (q : trunc \u03b1)\n  (h : \u2200 a, \u03b2 (mk a)) : \u03b2 q := ind h q\n\ntheorem exists_rep (q : trunc \u03b1) : \u2203 a : \u03b1, mk a = q := quot.exists_rep q\n\nattribute [elab_as_eliminator]\nprotected theorem induction_on\u2082 {C : trunc \u03b1 \u2192 trunc \u03b2 \u2192 Prop} (q\u2081 : trunc \u03b1) (q\u2082 : trunc \u03b2)\n  (h : \u2200 a b, C (mk a) (mk b)) : C q\u2081 q\u2082 :=\ntrunc.induction_on q\u2081 $ \u03bb a\u2081, trunc.induction_on q\u2082 (h a\u2081)\n\nprotected theorem eq (a b : trunc \u03b1) : a = b :=\ntrunc.induction_on\u2082 a b (\u03bb x y, quot.sound trivial)\n\ninstance : subsingleton (trunc \u03b1) := \u27e8trunc.eq\u27e9\n\n/-- The `bind` operator for the `trunc` monad. -/\ndef bind (q : trunc \u03b1) (f : \u03b1 \u2192 trunc \u03b2) : trunc \u03b2 :=\ntrunc.lift_on q f (\u03bb a b, trunc.eq _ _)\n\n/-- A function `f : \u03b1 \u2192 \u03b2` defines a function `map f : trunc \u03b1 \u2192 trunc \u03b2`. -/\ndef map (f : \u03b1 \u2192 \u03b2) (q : trunc \u03b1) : trunc \u03b2 := bind q (trunc.mk \u2218 f)\n\ninstance : monad trunc :=\n{ pure := @trunc.mk,\n  bind := @trunc.bind }\n\ninstance : is_lawful_monad trunc :=\n{ id_map := \u03bb \u03b1 q, trunc.eq _ _,\n  pure_bind := \u03bb \u03b1 \u03b2 q f, rfl,\n  bind_assoc := \u03bb \u03b1 \u03b2 \u03b3 x f g, trunc.eq _ _ }\n\nvariable {C : trunc \u03b1 \u2192 Sort*}\n\n/-- Recursion/induction principle for `trunc`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec\n   (f : \u03a0 a, C (mk a)) (h : \u2200 (a b : \u03b1), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n   (q : trunc \u03b1) : C q :=\nquot.rec f (\u03bb a b _, h a b) q\n\n/-- A version of `trunc.rec` taking `q : trunc \u03b1` as the first argument. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on (q : trunc \u03b1) (f : \u03a0 a, C (mk a))\n  (h : \u2200 (a b : \u03b1), (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   [\u2200 a, subsingleton (C (mk a))] (q : trunc \u03b1) (f : \u03a0 a, C (mk a)) : C q :=\ntrunc.rec f (\u03bb a b, subsingleton.elim _ (f b)) q\n\n/-- Noncomputably extract a representative of `trunc \u03b1` (using the axiom of choice). -/\nnoncomputable def out : trunc \u03b1 \u2192 \u03b1 := quot.out\n\n@[simp] theorem out_eq (q : trunc \u03b1) : mk q.out = q := trunc.eq _ _\n\nprotected theorem nonempty (q : trunc \u03b1) : nonempty \u03b1 :=\nnonempty_of_exists q.exists_rep\n\nend trunc\n\nnamespace quotient\nvariables {\u03b3 : Sort*} {\u03c6 : Sort*}\n  {s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2} {s\u2083 : setoid \u03b3}\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 \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk' (a : \u03b1) : quotient s\u2081 := quot.mk s\u2081.1 a\n\n/-- `quotient.mk'` is a surjective function. -/\nlemma surjective_quotient_mk' : function.surjective (quotient.mk' : \u03b1 \u2192 quotient s\u2081) :=\nquot.exists_rep\n\n/-- A version of `quotient.lift_on` taking `{s : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on' (q : quotient s\u2081) (f : \u03b1 \u2192 \u03c6)\n  (h : \u2200 a b, @setoid.r \u03b1 s\u2081 a b \u2192 f a = f b) : \u03c6 := quotient.lift_on q f h\n\n@[simp]\nprotected lemma lift_on'_mk' (f : \u03b1 \u2192 \u03c6) (h) (x : \u03b1) :\n  quotient.lift_on' (@quotient.mk' _ s\u2081 x) f h = f x := rfl\n\n/-- A version of `quotient.lift_on\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on\u2082' (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082, @setoid.r \u03b1 s\u2081 a\u2081 b\u2081 \u2192 @setoid.r \u03b2 s\u2082 a\u2082 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) : \u03b3 :=\nquotient.lift_on\u2082 q\u2081 q\u2082 f h\n\n@[simp]\nprotected lemma lift_on\u2082'_mk' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (a : \u03b1) (b : \u03b2) :\n  quotient.lift_on\u2082' (@quotient.mk' _ s\u2081 a) (@quotient.mk' _ s\u2082 b) f h = f a b := rfl\n\n/-- A version of `quotient.ind` taking `{s : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator]\nprotected lemma ind' {p : quotient s\u2081 \u2192 Prop}\n  (h : \u2200 a, p (quotient.mk' a)) (q : quotient s\u2081) : p q :=\nquotient.ind h q\n\n/-- A version of `quotient.ind\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma ind\u2082' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Prop}\n  (h : \u2200 a\u2081 a\u2082, p (quotient.mk' a\u2081) (quotient.mk' a\u2082))\n  (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) : p q\u2081 q\u2082 :=\nquotient.ind\u2082 h q\u2081 q\u2082\n\n/-- A version of `quotient.induction_on` taking `{s : setoid \u03b1}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_eliminator]\nprotected lemma induction_on' {p : quotient s\u2081 \u2192 Prop} (q : quotient s\u2081)\n  (h : \u2200 a, p (quotient.mk' a)) : p q := quotient.induction_on q h\n\n/-- A version of `quotient.induction_on\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on\u2082' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Prop} (q\u2081 : quotient s\u2081)\n  (q\u2082 : quotient s\u2082) (h : \u2200 a\u2081 a\u2082, p (quotient.mk' a\u2081) (quotient.mk' a\u2082)) : p q\u2081 q\u2082 :=\nquotient.induction_on\u2082 q\u2081 q\u2082 h\n\n/-- A version of `quotient.induction_on\u2083` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2} {s\u2083 : setoid \u03b3}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on\u2083' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 quotient s\u2083 \u2192 Prop}\n  (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (q\u2083 : quotient s\u2083)\n  (h : \u2200 a\u2081 a\u2082 a\u2083, p (quotient.mk' a\u2081) (quotient.mk' a\u2082) (quotient.mk' a\u2083)) : p q\u2081 q\u2082 q\u2083 :=\nquotient.induction_on\u2083 q\u2081 q\u2082 q\u2083 h\n\n/-- A version of `quotient.rec_on_subsingleton` taking `{s\u2081 : setoid \u03b1}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_eliminator]\nprotected def rec_on_subsingleton' {\u03c6 : quotient s\u2081 \u2192 Sort*}\n  [h : \u2200 a, subsingleton (\u03c6 \u27e6a\u27e7)] (q : quotient s\u2081) (f : \u03a0 a, \u03c6 (quotient.mk' a)) : \u03c6 q :=\nquotient.rec_on_subsingleton q f\n\n/-- A version of `quotient.rec_on_subsingleton\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b1}`\nas implicit arguments instead of instance arguments. -/\nattribute [reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton\u2082'\n   {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*} [h : \u2200 a b, subsingleton (\u03c6 \u27e6a\u27e7 \u27e6b\u27e7)]\n   (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (f : \u03a0 a\u2081 a\u2082, \u03c6 (quotient.mk' a\u2081) (quotient.mk' a\u2082)) :\n   \u03c6 q\u2081 q\u2082 :=\nquotient.rec_on_subsingleton\u2082 q\u2081 q\u2082 f\n\n/-- Recursion on a `quotient` argument `a`, result type depends on `\u27e6a\u27e7`. -/\nprotected def hrec_on' {\u03c6 : quotient s\u2081 \u2192 Sort*} (qa : quotient s\u2081) (f : \u03a0 a, \u03c6 (quotient.mk' a))\n  (c : \u2200 a\u2081 a\u2082, a\u2081 \u2248 a\u2082 \u2192 f a\u2081 == f a\u2082) : \u03c6 qa :=\nquot.hrec_on qa f c\n\n@[simp] \n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082' {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*} (qa : quotient s\u2081)\n  (qb : quotient s\u2082) (f : \u2200 a b, \u03c6 (quotient.mk' a) (quotient.mk' b))\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) : \u03c6 qa qb :=\nquotient.hrec_on\u2082 qa qb f c\n\n@[simp] lemma hrec_on\u2082'_mk' {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*}\n  (f : \u2200 a b, \u03c6 (quotient.mk' a) (quotient.mk' b))\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) (x : \u03b1) (qb : quotient s\u2082) :\n  (quotient.mk' x).hrec_on\u2082' qb f c = qb.hrec_on' (f x) (\u03bb b\u2081 b\u2082, c _ _ _ _ (setoid.refl _)) :=\nrfl\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `quotient sa \u2192 quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : \u03b1 \u2192 \u03b2) (h : (s\u2081.r \u21d2 s\u2082.r) f f) :\n  quotient s\u2081 \u2192 quotient s\u2082 :=\nquot.map f h\n\n@[simp] lemma map'_mk' (f : \u03b1 \u2192 \u03b2) (h) (x : \u03b1) :\n  (quotient.mk' x : quotient s\u2081).map' f h = (quotient.mk' (f x) : quotient s\u2082) :=\nrfl\n\n/-- A version of `quotient.map\u2082` using curly braces and unification. -/\nprotected def map\u2082' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : (s\u2081.r \u21d2 s\u2082.r \u21d2 s\u2083.r) f f) :\n  quotient s\u2081 \u2192 quotient s\u2082 \u2192 quotient s\u2083 :=\nquotient.map\u2082 f h\n\n@[simp] lemma map\u2082'_mk' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (x : \u03b1) :\n  (quotient.mk' x : quotient s\u2081).map\u2082' f h =\n    (quotient.map' (f x) (h (setoid.refl x)) : quotient s\u2082 \u2192 quotient s\u2083) :=\nrfl\n\nlemma exact' {a b : \u03b1} :\n  (quotient.mk' a : quotient s\u2081) = quotient.mk' b \u2192 @setoid.r _ s\u2081 a b :=\nquotient.exact\n\nlemma sound' {a b : \u03b1} : @setoid.r _ s\u2081 a b \u2192 @quotient.mk' \u03b1 s\u2081 a = quotient.mk' b :=\nquotient.sound\n\n@[simp]\nprotected lemma eq' {a b : \u03b1} : @quotient.mk' \u03b1 s\u2081 a = quotient.mk' b \u2194 @setoid.r _ s\u2081 a b :=\nquotient.eq\n\n/-- A version of `quotient.out` taking `{s\u2081 : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : quotient s\u2081) : \u03b1 := quotient.out a\n\n@[simp] theorem out_eq' (q : quotient s\u2081) : quotient.mk' q.out' = q := q.out_eq\n\ntheorem mk_out' (a : \u03b1) : @setoid.r \u03b1 s\u2081 (quotient.mk' a : quotient s\u2081).out' a :=\nquotient.exact (quotient.out_eq _)\n\nsection\n\nvariables [setoid \u03b1]\n\nprotected lemma mk'_eq_mk (x : \u03b1) : quotient.mk' x = \u27e6x\u27e7 := rfl\n\n@[simp] protected lemma lift_on'_mk (x : \u03b1) (f : \u03b1 \u2192 \u03b2) (h) : \u27e6x\u27e7.lift_on' f h = f x := rfl\n\n@[simp] protected lemma lift_on\u2082'_mk [setoid \u03b2] (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (a : \u03b1) (b : \u03b2) :\n  quotient.lift_on\u2082' \u27e6a\u27e7 \u27e6b\u27e7 f h = f a b := quotient.lift_on\u2082'_mk' _ _ _ _\n\n@[simp] lemma map'_mk [setoid \u03b2] (f : \u03b1 \u2192 \u03b2) (h) (x : \u03b1) : \u27e6x\u27e7.map' f h = \u27e6f x\u27e7 := 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 : \u2115)\n\n/-- Constant multivariate functor -/\n@[nolint unused_arguments]\ndef const (A : Type*) (v : typevec.{u} n) : Type* :=\nA\n\ninstance const.inhabited {A \u03b1} [inhabited A] : inhabited (const n A \u03b1) :=\n\u27e8 (default : A) \u27e9\n\nnamespace const\nopen mvfunctor mvpfunctor\nvariables {n} {A : Type u} {\u03b1 \u03b2 : typevec.{u} n} (f : \u03b1 \u27f9 \u03b2)\n\n/-- Constructor for constant functor -/\nprotected def mk (x : A) : (const n A) \u03b1 := x\n\n/-- Destructor for constant functor -/\nprotected def get (x : (const n A) \u03b1) : A := x\n\n@[simp] protected lemma mk_get (x : (const n A) \u03b1) : const.mk (const.get x) = x := rfl\n\n@[simp] protected lemma get_mk (x : A) : const.get (const.mk x : const n A \u03b1) = x := rfl\n\n/-- `map` for constant functor -/\nprotected def map : (const n A) \u03b1 \u2192 (const n A) \u03b2 :=\n\u03bb x, x\n\ninstance : mvfunctor (const n A) :=\n{ map := \u03bb \u03b1 \u03b2 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) \u03b1) :\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       := \u03bb \u03b1 x, mvpfunctor.const.get x,\n  repr      := \u03bb \u03b1 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 \u03b1 \u2192 Type\n  | []     => PUnit\n  | a :: _ => \u03b1\n\ndef hd : (as : List \u03b1) \u2192 Hd as\n  | []     => ()\n  | a :: l => a\n\ntheorem inj_hd (\u03b1 : Type) : (a a': \u03b1) \u2192 (l l' : List \u03b1) \u2192 a :: l = a' :: l' \u2192 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 \"\u2264\", 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 (\u03b1 : Type u) := (le : \u03b1 \u2192 \u03b1 \u2192 Type u)\nclass has_lt (\u03b1 : Type u) := (lt : \u03b1 \u2192 \u03b1 \u2192 Type u)\n\n@[reducible] def ge {\u03b1 : Type u} [has_le \u03b1] (a b : \u03b1) : Type u := has_le.le b a\n@[reducible] def gt {\u03b1 : Type u} [has_lt \u03b1] (a b : \u03b1) : Type u := has_lt.lt b a\n\nhott_theory_cmd \"local infix [parsing_only] ` <= ` := hott.has_le.le\"\nhott_theory_cmd \"local infix ` \u2264 `  := 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 ` \u2265 `  := 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 : \u03a0a, le a a)\n(le_trans : \u03a0a b c, le a b \u2192 le b c \u2192 le a c)\n(le_antisymm : \u03a0a b, le a b \u2192 le b a \u2192 a = b)\n\nsection\n  variable [s : weak_order A]\n  include s\n\n  @[hott, refl] def le.rfl {a : A} : a \u2264 a := weak_order.le_refl _\n  @[hott] def le.refl (a : A) : a \u2264 a := weak_order.le_refl _\n\n  @[hott] def le_of_eq {a b : A} (H : a = b) : a \u2264 b := transport (\u03bbx, a \u2264 x) H (le.refl a)\n  @[hott] def ge_of_eq {a b : A} (H : a = b) : a \u2265 b := le_of_eq H\u207b\u00b9\n\n  @[hott, trans] def le.trans {a b c : A} : a \u2264 b \u2192 b \u2264 c \u2192 a \u2264 c := weak_order.le_trans _ _ _\n\n  @[hott, trans] def le.trans_eq {a b c : A} (H1 : a \u2264 b) (H2 : b = c) : a \u2264 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 \u2264 c) : a \u2264 c :=\n  le.trans (le_of_eq H1) H2\n\n  @[hott, trans] def ge.trans {a b c : A} (H1 : a \u2265 b) (H2: b \u2265 c) : a \u2265 c := le.trans H2 H1\n\n  @[hott, trans] def ge.trans_eq {a b c : A} (H1 : a \u2265 b) (H2 : b = c) : a \u2265 c :=\n  le.eq_trans H2\u207b\u00b9 H1\n\n  @[hott, trans] def ge.eq_trans {a b c : A} (H1 : a = b) (H2 : b \u2265 c) : a \u2265 c :=\n  le.trans_eq H2 H1\u207b\u00b9\n\n  @[hott] def le.antisymm {a b : A} : a \u2264 b \u2192 b \u2264 a \u2192 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 \u2264 b \u2192 b \u2264 a \u2192 a = b := le.antisymm\nend\n\n@[hott, class] structure linear_weak_order (A : Type _) extends weak_order A :=\n(le_total : \u03a0a b, le a b \u228e le b a)\n\nsection\n  variables [linear_weak_order A]\n\n  @[hott] def le.total (a b : A) : a \u2264 b \u228e b \u2264 a := linear_weak_order.le_total _ _\n\n  @[hott] theorem le_of_not_ge {a b : A} (H : \u00ac a \u2265 b) : a \u2264 b := sum.resolve_left (le.total _ _) H\n\n  @[hott] def le_by_cases (a b : A) {P : Type _} (H1 : a \u2264 b \u2192 P) (H2 : b \u2264 a \u2192 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 : \u03a0a, \u00ac lt a a)\n(lt_trans : \u03a0a b c, lt a b \u2192 lt b c \u2192 lt a c)\n\nsection\n  variable [s : strict_order A]\n  include s\n\n  @[hott] def lt.irrefl (a : A) : \u00ac a < a := strict_order.lt_irrefl _\n  @[hott] def not_lt_self (a : A) : \u00ac a < a := lt.irrefl _   -- alternate syntax\n\n  @[hott] theorem lt_self_iff_empty (a : A) : a < a \u2194 empty :=\n  iff_empty_intro (lt.irrefl a)\n\n  @[hott, trans] def lt.trans {a b c : A} : a < b \u2192 b < c \u2192 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 \u2260 b :=\n  assume eq_ab : a = b,\n  show empty, from lt.irrefl b (eq_ab \u25b8 lt_ab)\n\n  @[hott] theorem ne_of_gt {a b : A} (gt_ab : a > b) : a \u2260 b :=\n  ne.symm (ne_of_lt gt_ab)\n\n  @[hott] theorem lt.asymm {a b : A} (H : a < b) : \u00ac 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) : \u00ac 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 : \u03a0P : A \u2192 Type _, (\u03a0x, (\u03a0y, lt y x \u2192 P y) \u2192 P x) \u2192 \u03a0x, P x)\n\n@[hott] def wf.rec_on {A : Type _} [s : wf_strict_order A] {P : A \u2192 Type _}\n    (x : A) (H : \u03a0x, (\u03a0y, wf_strict_order.lt y x \u2192 P y) \u2192 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 : \u03a0 a b, lt a b \u2192 le a b)\n(lt_of_lt_of_le : \u03a0 a b c, lt a b \u2192 le b c \u2192 lt a c)\n(lt_of_le_of_lt : \u03a0 a b c, le a b \u2192 lt b c \u2192 lt a c)\n(lt_irrefl : \u03a0 a, \u00ac 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 \u2192 a \u2264 b := order_pair.le_of_lt _ _\n\n  @[hott, trans] def lt_of_lt_of_le : a < b \u2192 b \u2264 c \u2192 a < c := order_pair.lt_of_lt_of_le _ _ _\n\n  @[hott, trans] def lt_of_le_of_lt : a \u2264 b \u2192 b < c \u2192 a < c := order_pair.lt_of_le_of_lt _ _ _\n\n  @[hott] private def lt_irrefl (s' : order_pair A) (a : A) : \u00ac 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 \u2265 c) : a > c := lt_of_le_of_lt H2 H1\n\n  @[hott, trans] def gt_of_ge_of_gt (H1 : a \u2265 b) (H2 : b > c) : a > c := lt_of_lt_of_le H2 H1\n\n  @[hott] def not_le_of_gt (H : a > b) : \u00ac a \u2264 b :=\n  assume H1 : a \u2264 b,\n  lt.irrefl _ (lt_of_lt_of_le H H1)\n\n  @[hott] theorem not_lt_of_ge (H : a \u2265 b) : \u00ac 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 : \u03a0a b, le a b \u2194 lt a b \u228e a = b)\n(lt_irrefl : \u03a0 a, \u00ac lt a a)\n\n@[hott] def le_iff_lt_sum_eq [s : strong_order_pair A] {a b : A} : a \u2264 b \u2194 a < b \u228e 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 \u2264 b) : a < b \u228e 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 \u228e a = b) :\n  a \u2264 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) : \u00ac 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 \u2192 a \u2264 b :=\n\u03bbHlt, 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 \u2194 (a \u2264 b \u00d7 a \u2260 b) :=\niff.intro\n  (\u03bbHlt, pair (le_of_lt_sum_eq (sum.inl Hlt)) (\u03bbHab, absurd (Hab \u25b8 Hlt) (lt_irrefl' _)))\n  (\u03bbHand,\n   have Hor : a < b \u228e 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 \u2264 b \u2192 a \u2260 b \u2192 a < b :=\n\u03bbH1 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 \u2260 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 \u2192 b \u2264 c \u2192 a < c :=\nassume lt_ab : a < b,\nassume le_bc : b \u2264 c,\nhave le_ac : a \u2264 c, from le.trans (le_of_lt' _ _ lt_ab) le_bc,\nhave ne_ac : a \u2260 c, from\n  assume eq_ac : a = c,\n  have le_ba : b \u2264 a, from eq_ac\u207b\u00b9 \u25b8 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 \u2264 b \u2192 b < c \u2192 a < c :=\nassume le_ab : a \u2264 b,\nassume lt_bc : b < c,\nhave le_ac : a \u2264 c, from le.trans le_ab (le_of_lt' _ _ lt_bc),\nhave ne_ac : a \u2260 c, from\n  assume eq_ac : a = c,\n  have le_cb : c \u2264 b, from eq_ac \u25b8 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 \u228e a = b \u228e b < a :=\n  sum.elim (le.total a b)\n    (assume H : a \u2264 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 \u2264 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\u207b\u00b9))))\n\n  @[hott] def lt.by_cases {a b : A} {P : Type _}\n    (H1 : a < b \u2192 P) (H2 : a = b \u2192 P) (H3 : b < a \u2192 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 \u2192 P) (H2 : a \u2265 b \u2192 P) : P :=\n  lt.by_cases H1 (\u03bbH, H2 (le_of_eq H\u207b\u00b9)) (\u03bbH, H2 (le_of_lt H))\n\n  @[hott] def le_of_not_gt {a b : A} (H : \u00ac a > b) : a \u2264 b :=\n  lt.by_cases (assume H', absurd H' H) (assume H', le_of_eq H'\u207b\u00b9) (assume H', le_of_lt H')\n\n  @[hott] theorem lt_of_not_ge {a b : A} (H : \u00ac a \u2265 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 \u228e a \u2265 b :=\n  lt.by_cases\n    (assume H1 : a < b, sum.inl H1)\n    (assume H1 : a = b, sum.inr (le_of_eq H1\u207b\u00b9))\n    (assume H1 : a > b, sum.inr (le_of_lt H1))\n\n  @[hott] theorem le_sum_gt : a \u2264 b \u228e a > b :=\n  sum.swap (lt_sum_ge b a)\n\n  @[hott] theorem lt_sum_gt_of_ne {a b : A} (H : a \u2260 b) : a < b \u228e 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 \u2264 b) :=\n  by_cases\n    (assume H : a < b, inl (le_of_lt H))\n    (assume H : \u00ac a < b,\n      have H1 : b \u2264 a, from le_of_not_gt H,\n      by_cases\n        (assume H2 : b < a, inr (not_le_of_gt H2))\n        (assume H2 : \u00ac 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 \u2264 b,\n      by_cases\n        (assume H1 : b \u2264 a, inl (le.antisymm H H1))\n        (assume H1 : \u00ac b \u2264 a, inr (assume H2 : a = b, H1 (le_of_eq H2\u207b\u00b9))))\n    (assume H : \u00ac a \u2264 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 : \u00ac a < b) : a = b \u228e b < a :=\n  if Heq :: a = b then sum.inl Heq else sum.inr (lt_of_not_ge (\u03bb Hge, H (lt_of_le_of_ne Hge Heq)))\n\n  @[hott] theorem eq_sum_lt_of_le {a b : A} (H : a \u2264 b) : a = b \u228e 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'\u207b\u00b9,\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) \u2b1d 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)) \u2b1d if_neg (lt.asymm H)\n\n  @[hott] def min (a b : A) : A := if' a \u2264 b then a else b\n  @[hott] def max (a b : A) : A := if' a \u2264 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 \u2264 a :=\n  hott.decidable.by_cases\n    (assume H : a \u2264 b, by dsimp [min]; rwr [if_pos H])\n    (assume H : \u00ac a \u2264 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 \u2264 b :=\n  hott.decidable.by_cases\n    (assume H : a \u2264 b, by dsimp [min]; rwr [if_pos H]; apply H)\n    (assume H : \u00ac a \u2264 b, by dsimp [min]; rwr [if_neg H])\n\n  @[hott] theorem le_min {a b c : A} (H\u2081 : c \u2264 a) (H\u2082 : c \u2264 b) : c \u2264 min a b :=\n  hott.decidable.by_cases\n    (assume H : a \u2264 b, by dsimp [min]; rwr [if_pos H]; apply H\u2081)\n    (assume H : \u00ac a \u2264 b, by dsimp [min]; rwr [if_neg H]; apply H\u2082)\n\n  @[hott] theorem le_max_left (a b : A) : a \u2264 max a b :=\n  hott.decidable.by_cases\n    (assume H : a \u2264 b, by dsimp [max]; rwr [if_pos H]; apply H)\n    (assume H : \u00ac a \u2264 b, by dsimp [max]; rwr [if_neg H])\n\n  @[hott] theorem le_max_right (a b : A) : b \u2264 max a b :=\n  hott.decidable.by_cases\n    (assume H : a \u2264 b, by dsimp [max]; rwr [if_pos H])\n    (assume H : \u00ac a \u2264 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\u2081 : a \u2264 c) (H\u2082 : b \u2264 c) : max a b \u2264 c :=\n  hott.decidable.by_cases\n    (assume H : a \u2264 b, by dsimp [max]; rwr [if_pos H]; apply H\u2082)\n    (assume H : \u00ac a \u2264 b, by dsimp [max]; rwr [if_neg H]; apply H\u2081)\n\n  @[hott] theorem le_max_left_iff_unit (a b : A) : a \u2264 max a b \u2194 unit :=\n  iff_unit_intro (le_max_left a b)\n\n  @[hott] theorem le_max_right_iff_unit (a b : A) : b \u2264 max a b \u2194 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\u2081 : c \u2264 a) (H\u2082 : c \u2264 b) (H\u2083 : \u03a0{d}, d \u2264 a \u2192 d \u2264 b \u2192 d \u2264 c) :\n    c = min a b :=\n  le.antisymm (le_min H\u2081 H\u2082) (H\u2083 (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 _ _) (\u03bb c H\u2081 H\u2082, le_min H\u2082 H\u2081)\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\u2081 H\u2082, apply le_min, apply le_min H\u2081, apply le.trans H\u2082, apply min_le_left,\n      apply le.trans H\u2082, 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 \u2264 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 \u2264 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\u2081 : a \u2264 c) (H\u2082 : b \u2264 c) (H\u2083 : \u03a0{d}, a \u2264 d \u2192 b \u2264 d \u2192 c \u2264 d) :\n    c = max a b :=\n  le.antisymm (H\u2083 (le_max_left _ _) (le_max_right _ _)) (max_le H\u2081 H\u2082)\n\n  @[hott] theorem max.comm (a b : A) : max a b = max b a :=\n  eq_max (le_max_right _ _) (le_max_left _ _) (\u03bb c H\u2081 H\u2082, max_le H\u2082 H\u2081)\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\u2081 H\u2082, apply max_le, apply max_le H\u2081, apply le.trans (le_max_left _ _) H\u2082,\n      apply le.trans (le_max_right _ _) H\u2082}\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 \u2264 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 \u2264 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\u2081 : a < b) (H\u2082 : a < c) : a < min b c :=\n  sum.elim (le_sum_gt _ _)\n    (assume H : b \u2264 c, by rwr (min_eq_left H); apply H\u2081)\n    (assume H : b > c, by rwr (min_eq_right_of_lt H); apply H\u2082)\n\n  @[hott] theorem max_lt {a b c : A} (H\u2081 : a < c) (H\u2082 : b < c) : max a b < c :=\n  sum.elim (le_sum_gt _ _)\n    (assume H : a \u2264 b, by rwr (max_eq_right H); apply H\u2082)\n    (assume H : a > b, by rwr (max_eq_left_of_lt H); apply H\u2081)\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 `\u03b1` to the type `\u03a3 a : A, B a \u27f9 \u03b1`, with `A : Type` and\n`B : A \u2192 typevec n`. They interact well with Lean's inductive definitions because\nthey guarantee that occurrences of `\u03b1` are positive.\n-/\n\n\nuniverse u v\n\nopen MvFunctor\n\n#print MvPFunctor /-\n/-- multivariate polynomial functors\n-/\nstructure MvPFunctor (n : \u2115) where\n  A : Type u\n  B : A \u2192 TypeVec.{u} n\n#align mvpfunctor MvPFunctor\n-/\n\nnamespace MvPFunctor\n\nopen MvFunctor (Liftp Liftr)\n\nvariable {n m : \u2115} (P : MvPFunctor.{u} n)\n\n#print MvPFunctor.Obj /-\n/-- Applying `P` to an object of `Type` -/\ndef Obj (\u03b1 : TypeVec.{u} n) : Type u :=\n  \u03a3a : P.A, P.B a \u27f9 \u03b1\n#align mvpfunctor.obj MvPFunctor.Obj\n-/\n\n#print MvPFunctor.map /-\n/-- Applying `P` to a morphism of `Type` -/\ndef map {\u03b1 \u03b2 : TypeVec n} (f : \u03b1 \u27f9 \u03b2) : P.Obj \u03b1 \u2192 P.Obj \u03b2 := fun \u27e8a, g\u27e9 => \u27e8a, TypeVec.comp f g\u27e9\n#align mvpfunctor.map MvPFunctor.map\n-/\n\ninstance : Inhabited (MvPFunctor n) :=\n  \u27e8\u27e8default, default\u27e9\u27e9\n\n#print MvPFunctor.Obj.inhabited /-\ninstance Obj.inhabited {\u03b1 : TypeVec n} [Inhabited P.A] [\u2200 i, Inhabited (\u03b1 i)] :\n    Inhabited (P.Obj \u03b1) :=\n  \u27e8\u27e8default, fun _ _ => default\u27e9\u27e9\n#align mvpfunctor.obj.inhabited MvPFunctor.Obj.inhabited\n-/\n\ninstance : MvFunctor P.Obj :=\n  \u27e8@MvPFunctor.map n P\u27e9\n\n#print MvPFunctor.map_eq /-\ntheorem map_eq {\u03b1 \u03b2 : TypeVec n} (g : \u03b1 \u27f9 \u03b2) (a : P.A) (f : P.B a \u27f9 \u03b1) :\n    @MvFunctor.map _ P.Obj _ _ _ g \u27e8a, f\u27e9 = \u27e8a, g \u229a f\u27e9 :=\n  rfl\n#align mvpfunctor.map_eq MvPFunctor.map_eq\n-/\n\n#print MvPFunctor.id_map /-\ntheorem id_map {\u03b1 : TypeVec n} : \u2200 x : P.Obj \u03b1, TypeVec.id <$$> x = x\n  | \u27e8a, g\u27e9 => rfl\n#align mvpfunctor.id_map MvPFunctor.id_map\n-/\n\n#print MvPFunctor.comp_map /-\ntheorem comp_map {\u03b1 \u03b2 \u03b3 : TypeVec n} (f : \u03b1 \u27f9 \u03b2) (g : \u03b2 \u27f9 \u03b3) :\n    \u2200 x : P.Obj \u03b1, (g \u229a f) <$$> x = g <$$> f <$$> x\n  | \u27e8a, h\u27e9 => 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 : \u2115) (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} {\u03b1 \u03b2 : TypeVec.{u} n}\n\n#print MvPFunctor.const.mk /-\n/-- Constructor for the constant functor -/\ndef const.mk (x : A) {\u03b1} : (const n A).Obj \u03b1 :=\n  \u27e8x, fun i a => PEmpty.elim a\u27e9\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 \u03b1) : 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 : \u03b1 \u27f9 \u03b2) (x : (const n A).Obj \u03b1) : 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 \u03b1) = 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 \u03b1) : const.mk n (const.get x) = x :=\n  by\n  cases x\n  dsimp [const.get, const.mk]\n  congr with (_\u27e8\u27e9)\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 \u2192 MvPFunctor.{u} m) : MvPFunctor m\n    where\n  A := \u03a3a\u2082 : P.1, \u2200 i, P.2 a\u2082 i \u2192 (Q i).1\n  B a i := \u03a3(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 \u2192 MvPFunctor.{u} m} {\u03b1 \u03b2 : 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 \u03b1) : (comp P Q).Obj \u03b1 :=\n  \u27e8\u27e8x.1, fun i a => (x.2 _ a).1\u27e9, fun i a => (x.snd a.fst a.snd.fst).snd i a.snd.snd\u27e9\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 \u03b1) : P.Obj fun i => (Q i).Obj \u03b1 :=\n  \u27e8x.1.1, fun i a => \u27e8x.fst.snd i a, fun (j : Fin2 m) (b : (Q i).B _ j) => x.snd j \u27e8i, \u27e8a, b\u27e9\u27e9\u27e9\u27e9\n#align mvpfunctor.comp.get MvPFunctor.comp.get\n-/\n\n#print MvPFunctor.comp.get_map /-\ntheorem comp.get_map (f : \u03b1 \u27f9 \u03b2) (x : (comp P Q).Obj \u03b1) :\n    comp.get (f <$$> x) = (fun i (x : (Q i).Obj \u03b1) => 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 \u03b1) : 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 \u03b1) : 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 \u27e8a, b, c\u27e9 <;> 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 {\u03b1 : TypeVec n} (p : \u2200 \u2983i\u2984, \u03b1 i \u2192 Prop) (x : P.Obj \u03b1) :\n    LiftP p x \u2194 \u2203 a f, x = \u27e8a, f\u27e9 \u2227 \u2200 i j, p (f i j) :=\n  by\n  constructor\n  \u00b7 rintro \u27e8y, hy\u27e9\n    cases' h : y with a f\n    refine' \u27e8a, fun i j => (f i j).val, _, fun i j => (f i j).property\u27e9\n    rw [\u2190 hy, h, map_eq]\n    rfl\n  rintro \u27e8a, f, xeq, pf\u27e9\n  use \u27e8a, fun i j => \u27e8f i j, pf i j\u27e9\u27e9\n  rw [xeq]; rfl\n#align mvpfunctor.liftp_iff MvPFunctor.liftP_iff\n-/\n\n#print MvPFunctor.liftP_iff' /-\ntheorem liftP_iff' {\u03b1 : TypeVec n} (p : \u2200 \u2983i\u2984, \u03b1 i \u2192 Prop) (a : P.A) (f : P.B a \u27f9 \u03b1) :\n    @LiftP.{u} _ P.Obj _ \u03b1 p \u27e8a, f\u27e9 \u2194 \u2200 i x, p (f i x) :=\n  by\n  simp only [liftp_iff, Sigma.mk.inj_iff] <;> constructor <;> intro\n  \u00b7 casesm*Exists _, _ \u2227 _\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 {\u03b1 : TypeVec n} (r : \u2200 \u2983i\u2984, \u03b1 i \u2192 \u03b1 i \u2192 Prop) (x y : P.Obj \u03b1) :\n    LiftR r x y \u2194 \u2203 a f\u2080 f\u2081, x = \u27e8a, f\u2080\u27e9 \u2227 y = \u27e8a, f\u2081\u27e9 \u2227 \u2200 i j, r (f\u2080 i j) (f\u2081 i j) :=\n  by\n  constructor\n  \u00b7 rintro \u27e8u, xeq, yeq\u27e9\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    \u00b7 rw [\u2190 xeq, h]\n      rfl\n    constructor\n    \u00b7 rw [\u2190 yeq, h]\n      rfl\n    intro i j\n    exact (f i j).property\n  rintro \u27e8a, f\u2080, f\u2081, xeq, yeq, h\u27e9\n  use \u27e8a, fun i j => \u27e8(f\u2080 i j, f\u2081 i j), h i j\u27e9\u27e9\n  dsimp; constructor\n  \u00b7 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 {\u03b1 : TypeVec n} (a : P.A) (f : P.B a \u27f9 \u03b1) (i) :\n    @supp.{u} _ P.Obj _ \u03b1 (\u27e8a, f\u27e9 : P.Obj \u03b1) i = f i '' univ :=\n  by\n  ext; simp only [supp, image_univ, mem_range, mem_set_of_eq]\n  constructor <;> intro h\n  \u00b7 apply @h fun i x => \u2203 y : P.B a i, f i y = x\n    rw [liftp_iff']\n    intros\n    refine' \u27e8_, rfl\u27e9\n  \u00b7 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 : \u2115} (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 {\u03b1 : TypeVec n} {\u03b2 : Type _} {a : P.A} (f' : P.drop.B a \u27f9 \u03b1)\n    (f : P.getLast.B a \u2192 \u03b2) : P.B a \u27f9 (\u03b1 ::: \u03b2) :=\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,\u211d)` is linearly equivalent to\nthe weak dual of `locally_constant X \u211d`. -/\ndef weak_dual_C_equiv_LC (X : Profinite.{0}) :\n  weak_dual \u211d C(X,\u211d) \u2243\u2097[\u211d] weak_dual \u211d (locally_constant X \u211d) :=\n{ inv_fun := X.weak_dual_LC_to_C,\n  left_inv := begin\n    intros f, ext t,\n    show (locally_constant.pkg X \u211d).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 \u211d).induction_on t,\n    { apply is_closed_eq,\n      refine (locally_constant.pkg X \u211d).continuous_extend,\n      exact f.2 },\n    { intros e,\n      rw (locally_constant.pkg X \u211d).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 \u211d).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 \u211d).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 : \u211d\u22650) :\n  X.Radon p c \u27f6 X.Radon_LC p c :=\n{ to_fun := \u03bb \u03bc, \u27e8weak_dual_C_to_LC _ \u03bc.1, \u03bc.2\u27e9,\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 : \u211d\u22650) :\n  X.Radon_LC p c \u2192 X.Radon p c :=\n\u03bb \u03bc, \u27e8weak_dual_LC_to_C _ \u03bc.1, begin\n    change (weak_dual_C_to_LC _ (weak_dual_LC_to_C _ \u03bc.1)).bdd_LC p c,\n    erw X.weak_dual_C_equiv_LC.apply_symm_apply,\n    exact \u03bc.2,\n  end\u27e9\n\n/-- An auxiliary definition to be used in the constructions below. -/\ndef Radon_LC_to_weak_dual (X : Profinite.{0}) (p c : \u211d\u22650) :\n  X.Radon_LC p c \u2192 weak_dual \u211d (locally_constant X \u211d) := 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 \u211d (locally_constant X \u211d) \u2192 locally_constant X \u211d \u2192 \u211d := \u03bb \u03bc x, \u03bc 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 \u211d (locally_constant X \u211d)) :=\n\u27e8\u03bb x y h, separated_by_continuous (X.continuous_weak_dual_LC_to_fun) $\n  \u03bb c, h $ by { ext t, apply_fun (\u03bb e, e t) at c, exact c } \u27e9\n\nlemma Radon_LC_closed_embedding (X : Profinite.{0}) (p c : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 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 : \u211d\u22650) :\n  X.Radon p c \u2192 weak_dual \u211d C(X,\u211d) := subtype.val\n\nlemma Radon_closed_embedding (X : Profinite.{0}) (p c : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  closed_embedding (X.Radon_to_weak_dual p c) :=\nclosed_embedding_subtype_coe\nbegin\n  let T : set (weak_dual \u211d (locally_constant X \u211d)) :=\n    { f | f.bdd_LC p c },\n  change is_closed (X.weak_dual_C_to_LC \u207b\u00b9' 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] : metric.bounded\n  (normed_space.dual.to_weak_dual \u207b\u00b9' set.range (X.Radon_to_weak_dual p c)) :=\nbegin\n  -- Use c^(1/p)\n  letI : uniform_space (locally_constant.pkg X \u211d).space :=\n    (locally_constant.pkg X \u211d).uniform_struct,\n  refine (metric.bounded_iff_subset_ball 0).mpr _,\n  refine \u27e8c^(1/(p : \u211d)), \u03bb \u03bc h\u03bc, mem_closed_ball_zero_iff.mpr _\u27e9,\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 \u211d).induction_on f,\n  { apply is_closed_le,\n    refine continuous.comp (continuous_norm) _,\n    exact \u03bc.continuous,\n    refine continuous.comp (continuous_mul_left _) continuous_norm },\n  { intros e,\n    let \u03b3 : weak_dual \u211d (locally_constant X \u211d) :=\n      X.weak_dual_C_to_LC \u03bc,\n    dsimp [locally_constant.pkg],\n    have : \u03bc e = \u03b3 e, refl, rw this, clear this,\n    have : \u2225 e.to_continuous_map \u2225 = \u2225 e \u2225,\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 : \u2225 \u03b3 e \u2225\u208a \u2264 c^(1 / (p : \u211d)) * \u2225 e \u2225\u208a, by exact_mod_cast this,\n    have hp : 0 < (p : \u211d) := nnreal.coe_pos.mpr (fact.out (0 < p)),\n    have hp' : (p : \u211d) \u2260 0,\n    { exact ne_of_gt hp },\n    rw [\u2190 nnreal.rpow_le_rpow_iff hp, nnreal.mul_rpow, \u2190 nnreal.rpow_mul],\n    rw [(show 1 / (p : \u211d) * p = 1, from (eq_div_iff hp').mp rfl), nnreal.rpow_one],\n    obtain \u27e8\u03b4,h\u03b4\u27e9 := h\u03bc,\n    have H := \u03b4.2 e.discrete_quotient,\n    replace H := mul_le_mul H (le_refl (\u2225 e \u2225\u208a^(p : \u211d))) (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 [\u03b3.map_sum, \u03b3.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 \u27e8x,rfl\u27e9 := discrete_quotient.proj_surjective _ x,\n    change \u2225 e x \u2225\u208a \u2264 _,\n    apply locally_constant.nnnorm_apply_le_nnnorm,\n    congr' 2,\n    change _ = X.Radon_to_weak_dual p c \u03b4 _, rw h\u03b4, refl },\nend\n\ninstance compact_space_Radon (X : Profinite) (p c : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  compact_space (X.Radon p c) :=\nbegin\n  let e : X.Radon p c \u2243\u209c 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 \u2190 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 : \u211d\u22650) :\n  X.Radon p c \u2243 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 : \u211d\u22650) :\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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  continuous (X.Radon_equiv_Radon_LC p c).symm :=\nbegin\n  rw continuous_iff_is_closed,\n  intros T hT,\n  rw \u2190 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  X.Radon p c \u2243\u209c 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  X.Radon p c \u2245 X.Radon_LC p c :=\nTop.iso_of_homeo (X.Radon_homeomorph_Radon_LC p c)\n\n/-- The functor `X \u21a6 X.Radon p c` is isomorphic to its locally constant variant. -/\ndef Radon_functor_iso_Radon_LC_functor (p c : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  Radon_functor p c \u2245 Radon_LC_functor p c :=\nnat_iso.of_components\n(\u03bb 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  Profinite.{0} \u2964 CompHaus.{0} :=\n{ obj := \u03bb X, CompHaus.of $ X.Radon p c,\n  map := \u03bb X Y f, (Radon_functor p c).map f,\n  map_id' := (Radon_functor p c).map_id,\n  map_comp' := \u03bb _ _ _ f g, (Radon_functor p c).map_comp f g }\n\n/-- The functor `X \u21a6 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  Radon_CompHaus_functor p c \u2245 Radon_LC_CompHaus_functor p c :=\nnat_iso.of_components\n(\u03bb 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 [\u2190 nat_trans.comp_app, iso.hom_inv_id], refl,\n  end,\n  inv_hom_id' := begin\n    erw [\u2190 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  cone (X.diagram \u22d9 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  is_limit (X.Radon_CompHaus_cone p c) :=\n{ lift := \u03bb S,\n    (X.is_limit_Radon_LC_CompHaus_cone p c).lift\n    \u27e8S.X, S.\u03c0 \u226b whisker_left _ (Radon_CompHaus_functor_iso_Radon_LC_CompHaus_functor p c).hom\u27e9 \u226b\n    (Radon_CompHaus_functor_iso_Radon_LC_CompHaus_functor p c).inv.app _,\n  fac' := begin\n    intros S j,\n    erw [category.assoc, \u2190 nat_trans.naturality,\n      (X.is_limit_Radon_LC_CompHaus_cone p c).fac_assoc,\n      \u2190 nat_iso.app_inv, iso.comp_inv_eq], refl,\n  end,\n  uniq' := begin\n    intros S m hm,\n    rw [\u2190 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 \u2190 hm,\n    simp only [category.assoc],\n    erw \u2190 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  X.diagram \u22d9 Radon_LC_CompHaus_functor p c \u2245\n  X.fintype_diagram \u22d9 real_measures.functor p \u22d9 CompHausFiltPseuNormGrp\u2081.level.obj c :=\nnat_iso.of_components\n(\u03bb 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 [\u2190 nat_trans.comp_app, iso.hom_inv_id], refl,\n  end,\n  inv_hom_id' := begin\n    erw [\u2190 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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  X.diagram \u22d9 Radon_CompHaus_functor p c \u2245\n  X.fintype_diagram \u22d9 real_measures.functor p \u22d9 CompHausFiltPseuNormGrp\u2081.level.obj c :=\niso_whisker_left _ (Radon_CompHaus_functor_iso_Radon_LC_CompHaus_functor _ _) \u226a\u226b\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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  CompHaus.of (X.Radon p c) \u2245\n  limit (X.fintype_diagram \u22d9 real_measures.functor p \u22d9 CompHausFiltPseuNormGrp\u2081.level.obj c) :=\n(X.is_limit_Radon_CompHaus_cone p c).cone_point_unique_up_to_iso (limit.is_limit _) \u226a\u226b\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 : \u211d\u22650)\n  [fact (0 < p)] [fact (p \u2264 1)] :\n  CompHaus.of (X.Radon p c) \u2245\n  (CompHausFiltPseuNormGrp\u2081.level.obj c).obj\n  ((Profinite.extend (real_measures.functor p)).obj X) :=\nRadon_iso_limit _ _ _ \u226a\u226b\nhas_limit.iso_of_nat_iso (functor.associator _ _ _).symm \u226a\u226b\n(limit.is_limit _).cone_point_unique_up_to_iso\n(is_limit_of_preserves ((CompHausFiltPseuNormGrp\u2081.level.obj c))\n  (limit.is_limit (X.fintype_diagram \u22d9 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 \u2964 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) [\ud835\udca5 : small_category J] [@fin_category J \ud835\udca5] : @has_limits_of_shape J \ud835\udca5 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\u27e8\u03bb 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) }\u27e9\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 : \u2200 (J : Type w) {\ud835\udca5 : small_category J} (hJ : @fin_category J \ud835\udca5),\n    by { resetI, exact has_limits_of_shape J C }) :\n  has_finite_limits C :=\n\u27e8\u03bb 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 \u27e9\n\n/--\nA category has all finite colimits if every functor `J \u2964 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) [\ud835\udca5 : small_category J] [@fin_category J \ud835\udca5] : @has_colimits_of_shape J \ud835\udca5 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\u27e8\u03bb 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) }\u27e9\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 : \u2200 (J : Type w) {\ud835\udca5 : small_category J} (hJ : @fin_category J \ud835\udca5),\n    by { resetI, exact has_colimits_of_shape J C }) :\n  has_finite_colimits C :=\n\u27e8\u03bb 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 \u27e9\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 := \u03bb 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' \u2205 [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 \u27f6 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 \u2205 } }\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 \u27f6 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 \u2205 } }\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\u27e8\u03bb J _, by exactI has_finite_limits.out _\u27e9\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\u27e8\u03bb J _, by exactI has_finite_colimits.out _\u27e9\n\ninstance fintype_walking_pair : fintype walking_pair :=\n{ elems := {walking_pair.left, walking_pair.right},\n  complete := \u03bb 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 {\u03b1 : Type*} {P : \u2115 \u2192 \u03b1 \u2192 Prop}\n  (h\u2080 : \u2203 a, P 0 a)\n  (ih : \u2200 n a, P n a \u2192 \u2203 a', P (n+1) a') :\n  \u2203 f : \u2115 \u2192 \u03b1, \u2200 n, P n (f n) :=\nbegin\n  choose f\u2080 hf\u2080 using h\u2080,\n  choose! F hF using ih,\n  exact \u27e8\u03bb n, nat.rec_on n f\u2080 F, \u03bb n, nat.rec hf\u2080 (\u03bb n ih, hF n _ ih) n\u27e9\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' {\u03b1 : Type*} (P : \u2115 \u2192 \u03b1 \u2192 Prop) (Q : \u2115 \u2192 \u03b1 \u2192 \u03b1 \u2192 Prop)\n  (h\u2080 : \u2203 a, P 0 a)\n  (ih : \u2200 n a, P n a \u2192 \u2203 a', P (n+1) a' \u2227 Q n a a') :\n  \u2203 f : \u2115 \u2192 \u03b1, \u2200 n, P n (f n) \u2227 Q n (f n) (f $ n+1) :=\nbegin\n  choose f\u2080 hf\u2080 using h\u2080,\n  choose! F hF hF' using ih,\n  have key : \u2200 n, P n (nat.rec_on n f\u2080 F), from \u03bb n, nat.rec hf\u2080 (\u03bb n ih, hF n _ ih) n,\n  exact \u27e8\u03bb n, nat.rec_on n f\u2080 F, \u03bb n, \u27e8key n, hF' n _ (key n)\u27e9\u27e9\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\u2081 T\u2082 : Structure} (e : T\u2081 \u2243 T\u2082) :\n  StructureFunctor (functorStructure S T\u2081) (functorStructure S T\u2082) :=\ncompFun.congrArg_right.functor S e.toFun\n\nnamespace outgoingToFun\n\ndef respectsEquiv {T\u2081 T\u2082 : Structure} :\n  GeneralizedFunctor.Functor (S := StructureEquiv.equivStructure T\u2081 T\u2082)\n                             (T := functorStructure (functorStructure S T\u2081) (functorStructure S T\u2082))\n                             (outgoingToFun S) :=\n(compFun.congrArg_right.functor.functorFunctor S \u2299 StructureEquiv.toFunProj T\u2081 T\u2082).functor\n\ndef respectsComp {T\u2081 T\u2082 T\u2083 : Structure} (e : T\u2081 \u2243 T\u2082) (f : T\u2082 \u2243 T\u2083) :\n  outgoingToFun S (f \u2022 e) \u2243 outgoingToFun S f \u2299 outgoingToFun S e :=\ncompFun.congrArg_right.functor.respectsCompFun S e.toFun f.toFun\n\ntheorem respectsComp.nat {T\u2081 T\u2082 T\u2083 : Structure} {e\u2081 e\u2082 : T\u2081 \u2243 T\u2082} {f\u2081 f\u2082 : T\u2082 \u2243 T\u2083} (\u03b7 : e\u2081 \u2243 e\u2082) (\u03b8 : f\u2081 \u2243 f\u2082) :\n  compFun.congrArg (respectsEquiv S \u03b7) (respectsEquiv S \u03b8) \u2022 respectsComp S e\u2081 f\u2081 \u2248 respectsComp S e\u2082 f\u2082 \u2022 respectsEquiv S (StructureEquiv.comp_congrArg \u03b7 \u03b8) :=\ncompFun.congrArg_right.functor.respectsCompFun.nat S \u03b7.toFunEquiv \u03b8.toFunEquiv\n\ndef respectsId (T : Structure) :\n  outgoingToFun S (id_ T) \u2243 @idFun (functorStructure S T) :=\ncompFun.congrArg_right.functor.respectsIdFun S T\n\nend outgoingToFun\n\ndef outgoingFunctorDesc : UniverseStructureFunctorDesc :=\n{ map             := \u03bb 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\u2081 T\u2082 : Structure} (e : T\u2081 \u2243 T\u2082) :\n  StructureFunctor (functorStructure T\u2081 S) (functorStructure T\u2082 S) :=\ncompFun.congrArg_left.functor S e.invFun\n\nnamespace incomingToFun\n\ndef respectsEquiv {T\u2081 T\u2082 : Structure} :\n  GeneralizedFunctor.Functor (S := StructureEquiv.equivStructure T\u2081 T\u2082)\n                             (T := functorStructure (functorStructure T\u2081 S) (functorStructure T\u2082 S))\n                             (incomingToFun S) :=\n(compFun.congrArg_left.functor.functorFunctor S \u2299 StructureEquiv.invFunProj T\u2081 T\u2082).functor\n\ndef respectsComp {T\u2081 T\u2082 T\u2083 : Structure} (e : T\u2081 \u2243 T\u2082) (f : T\u2082 \u2243 T\u2083) :\n  incomingToFun S (f \u2022 e) \u2243 incomingToFun S f \u2299 incomingToFun S e :=\ncompFun.congrArg_left.functor.respectsCompFun S f.invFun e.invFun\n\ntheorem respectsComp.nat {T\u2081 T\u2082 T\u2083 : Structure} {e\u2081 e\u2082 : T\u2081 \u2243 T\u2082} {f\u2081 f\u2082 : T\u2082 \u2243 T\u2083} (\u03b7 : e\u2081 \u2243 e\u2082) (\u03b8 : f\u2081 \u2243 f\u2082) :\n  compFun.congrArg (respectsEquiv S \u03b7) (respectsEquiv S \u03b8) \u2022 respectsComp S e\u2081 f\u2081 \u2248 respectsComp S e\u2082 f\u2082 \u2022 respectsEquiv S (StructureEquiv.comp_congrArg \u03b7 \u03b8) :=\ncompFun.congrArg_left.functor.respectsCompFun.nat S \u03b8.invFunEquiv \u03b7.invFunEquiv\n\ndef respectsId (T : Structure) :\n  incomingToFun S (id_ T) \u2243 @idFun (functorStructure T S) :=\ncompFun.congrArg_left.functor.respectsIdFun S T\n\nend incomingToFun\n\ndef incomingFunctorDesc : UniverseStructureFunctorDesc :=\n{ map             := \u03bb 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  := \u03bb e => { ext := \u03bb 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  := \u03bb e => { ext := \u03bb 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) \u21a6 (S \u2192 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' \u2264 1`\n* `BD` denotes a Breen-Deligne package\n* `\u03ba'` is a sequence of nonnegative real numbers\n* `\u039b` denotes a polyhedral lattice\n\nThe main goal of this file is to define sequences of constants `k\u2081`, `K\u2081`, `k'`, `N\u2082`, `b`, `H`,\nsatisfying the inequalities below.\nBut first we make some abbreviations:\n\n* `k\u2080 m := normed_spectral.k\u2080 m (k\u2081 m)`\n* `K\u2080 m := normed_spectral.K\u2080 m (K\u2081 m)`\n* `\u03b5 m := normed_spectral.\u03b5 m (K\u2081 m)`\n* `k m := (k' m)^2`\n* `K m := 2 * K\u2080 m * H m`\n\nIt is known that:\n\n* `normed_spectral.k\u2080` always returns a number larger or equal to `1`.\n* `normed_spectral.K\u2080` always returns a number larger or equal to `1`.\n* `normed_spectral.\u03b5` 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\u2081 m`\n* `1 \u2264 K\u2081 m`\n* `1 \u2264 k' m`\n* `k (m - 1) \u2264 k\u2081 m`, for `m > 0`\n* `K (m - 1) \u2264 K\u2081 m`, for `m > 0`\n* `m + 2 + (r + 1) / (r * (1 - r)) * (m + 2) ^ 2 \u2264 K\u2081 m`\n* `k\u2080 m \u2264 k' m`\n* `\u03ba' i \u2264 k' m` for all `i \u2264 m+1`\n* `(2 * k' m) * (r / r') ^ (b m) \u2264 \u03b5 m`\n* `k' m \u2264 2 ^ N\u2082 m`\n* `k' m / (2 ^ N\u2082 m) \u2264 r' ^ (b m)`\n* `r ^ (b m) * (2 ^ N\u2082 m) \u2264 2 * k' m * (r / r') ^ (b m)`\n* For `q \u2264 m`, the technical condition\n  `((BD.data.homotopy_mul BD.homotopy (N\u2082 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\u2082 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 `\u03b5`, we define `b` to be the smallest natural number\nlarger than `log(\u03b5 / (2 * k')) / log(r/r')`. -/\ndef b (r r' k' \u03b5 : \u211d) : \u2115 := nat.ceil ((log $ \u03b5/(2 * k')) / log (r/r'))\n\n/-- Under the constraints that `r`, `r'`, `k'`, and `\u03b5` are positive real numbers\nsatisfying `r < r'`, the natural number `b = b r r' k' \u03b5` satisfies\n`(2 * k') * (r/r') ^ b \u2264 \u03b5`. -/\nlemma b_spec {r r' k' \u03b5 : \u211d} (hr : 0 < r) (hr' : 0 < r') (hrr' : r < r')\n  (hk' : 0 < k') (h\u03b5 : 0 < \u03b5) : (2 * k') * (r / r') ^ (b r r' k' \u03b5) \u2264 \u03b5 :=\nbegin\n  have f\u2081 : 0 < 2*k' := mul_pos zero_lt_two hk',\n  have f\u2082 : r/r' < 1 := (div_lt_one hr').mpr hrr',\n  have f\u2083 : 0 < r/r' := div_pos hr hr',\n  have f\u2084 :0 < (r / r') ^ b r r' k' \u03b5 := pow_pos f\u2083 _,\n  rw [\u2190 le_div_iff' f\u2081, \u2190 log_le_log f\u2084 (div_pos h\u03b5 f\u2081), log_pow, \u2190 div_le_iff_of_neg (log_neg f\u2083 f\u2082)],\n  exact nat.le_ceil (log (\u03b5 / (2 * k')) / log (r / r')),\nend\n\n/-- Given real numbers `r'`, `k'`, and `b`, we define `N\u2082` to be the smallest natural number\nlarger than `log(k' / r'^b) / log(2)`. -/\ndef N\u2082 (r' k' b : \u211d) := 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\u2082 = N\u2082 r' k' b` satisfies `k' / (2 ^ N\u2082) \u2264 r' ^ b`. -/\nlemma N\u2082_spec {r' k' b : \u211d} (hr' : 0 < r') (hk' : 0 < k') : k'/ (2 ^ (N\u2082 r' k' b)) \u2264 r' ^ b :=\nbegin\n  have f\u2081 : (0 : \u211d) < 2 ^ N\u2082 r' k' b := pow_pos zero_lt_two _,\n  have f\u2082 : (0 : \u211d) < r' ^ b := rpow_pos_of_pos hr' _,\n  have f\u2083 : 0 < k' / r' ^ b := div_pos hk' f\u2082,\n  have f\u2084 : 0 < log 2 := log_pos one_lt_two,\n  rw [div_le_iff' f\u2081, \u2190 div_le_iff f\u2082,  \u2190 log_le_log f\u2083 f\u2081, log_pow, \u2190 div_le_iff f\u2084],\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\u2082 = N\u2082 r' k' b` satisfies `r' ^b < 2 * k' / (2 ^ N\u2082)`. -/\nlemma N\u2082_spec_of_pos' {r' k' b} (h : 0 < N\u2082 r' k' b) (hr' : 0 < r') (hk' : 0 \u2264 k') :\n  r' ^ b < 2 * k'  / 2 ^ N\u2082 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\u2081 : 0 < 2 ^ N\u2082 r' k' b := pow_pos zero_lt_two _,\n  have Hk' : k' \u2260 0,\n  { intro H,\n    simpa [H, N\u2082] using h },\n  have f\u2082 : 0 < r' ^ b := rpow_pos_of_pos hr' b,\n\n  have f\u2083 : 0 < k' / r' ^ b := div_pos ((ne.symm Hk').le_iff_lt.mp hk') f\u2082,\n  have f\u2083' : k' / r' ^ b \u2260 0 := f\u2083.ne.symm,\n  have f\u2084 : (N\u2082 r' k' b : \u211d) < _ := nat.ceil_lt_add_one this.le,\n\n  rwa [lt_div_iff, \u2190 lt_div_iff', mul_div_assoc, \u2190 log_lt_log_iff, log_mul, log_pow,\n       \u2190 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* `\u03ba` and `\u03ba'` 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* `\u039b` denotes a polyhedral lattice\n-/\n\nparameters (r r' : \u211d\u22650)\nparameters (BD : breen_deligne.package) (\u03ba \u03ba' : \u2115 \u2192 \u211d\u22650)\nparameters (\u039b : PolyhedralLattice)\n\n/-!\nWe also let `m` denote a variable natural number.\n-/\n\nvariables  (m : \u2115)\n\nnamespace thm95\n\nopen system_of_double_complexes\n\nnamespace universal_constants\n\nopen breen_deligne\n\n/-- `k\u2081 m` is a sequence of nonnegative real numbers, defined recursively via\n* `k\u2081 0 = 2` (the important property being `k\u2081 0 > 1`) and\n* `k\u2081 (m+1)` is the maximum of `2` and `c`,\n  where `c` is the square of the maximum of `k\u2080 m (k\u2081 m)`, and `\u03ba' 0`, `\u03ba' 1`, ..., `\u03ba' (m+1)`.\n  Here `k\u2080 m k` is the sequence of constants used in the proof of `normed_spectral`. -/\nnoncomputable def k\u2081 : \u2115 \u2192 \u211d\u22650\n| 0     := 2 -- should be anything > 1\n| (m+1) := max 2 ((max (normed_spectral.k\u2080 m (k\u2081 m)) $ (range $ m+2).sup \u03ba')^2)\n\n/-- All the numbers `k\u2081 m` are larger than `1`. -/\ninstance one_lt_k\u2081 : \u03a0 (m : \u2115), fact (1 < k\u2081 m)\n| 0     := \u27e8one_lt_two\u27e9\n| (m+1) := \u27e8lt_of_lt_of_le one_lt_two (le_max_left _ _)\u27e9\n\n/-- `k\u2080 m` is the constant `k\u2080 m (k m)` used in the proof of `normed_spectral`. -/\nabbreviation k\u2080 : \u211d\u22650 := normed_spectral.k\u2080 m (k\u2081 m)\n\n/-- `k' m` is the maximum of `k\u2080 m` and the constants `\u03ba' 0`, `\u03ba' 1`, ..., `\u03ba' m`, `\u03ba' (m+1)` -/\ndef k' : \u211d\u22650 := max (k\u2080 m) $ (range $ m+2).sup \u03ba'\n\n/-- For indices `i` ranging over `0` up to `m+1`, we have `\u03ba' i \u2264 k' m`. -/\nlemma \u03ba'_le_k' {i : \u2115} (hi : i \u2264 m+1) : \u03ba' i \u2264 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_\u03ba'_le_k' {i : \u2115} (hi : fact (i \u2264 m+1)) : fact (\u03ba' i \u2264 k' m) := \u27e8\u03ba'_le_k' _ hi.1\u27e9\n\n/-- We always have `1 \u2264 k' m` for all `m`, since `1 \u2264 k\u2080 m`. -/\ninstance one_le_k' : fact (1 \u2264 k' m) := \u27e8le_trans (fact.out _) $ le_max_left _ _\u27e9\n\n/-- We always `k\u2080 m \u2264 k' m`. -/\ninstance k\u2080_le_k' : fact (k\u2080 m \u2264 k' m) := \u27e8le_max_left _ _\u27e9\n\n/-- `k m` is the square of `k' m`. -/\ndef k : \u211d\u22650 := k' m * k' m\n\ninstance one_le_k : fact (1 \u2264 k m) := by { delta k, apply_instance }\n\n/-- For positive `m`, we have `k (m-1) \u2264 k\u2081 m`. -/\ninstance k_le_k\u2081 [fact (0 < m)] : fact (k (m - 1) \u2264 k\u2081 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\u2081],\n    convert le_max_right _ _,\n    rw pow_two,\n    refl }\nend\n\n/-- `k\u2081_sqrt m` denotes the square root of `k\u2081 m`. -/\ndef k\u2081_sqrt : \u211d\u22650 := \u27e8real.sqrt (k\u2081 m), real.sqrt_nonneg _\u27e9\n\ninstance one_lt_k\u2081_sqrt : fact (1 < k\u2081_sqrt m) := \u27e8begin\n  change (1 : \u211d) < real.sqrt (k\u2081 \u03ba' m),\n  rw [real.lt_sqrt zero_le_one, pow_two, mul_one],\n  exact (universal_constants.one_lt_k\u2081 \u03ba' m).elim,\nend\u27e9\n\n/-- `y m r` denotes `m + 2 + (r + 1) / (r - r^2) * (m + 2)^2`. -/\ndef y (m : \u2115) (r : \u211d\u22650) := (m + 2 : \u211d\u22650) + (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 : \u2115) :=\nmax 1 ((range $ m+1).sup $ \u03bb q, ((BD.data.homotopy_mul BD.homotopy n).hom q (q + 1)).bound)\n\n/-- `K\u2081` is a sequence of nonnegative real numbers, defined recursively via\n* `K\u2081 0 = 2 + (r + 1) / (r * (1 - r)) * 4`\n* `K\u2081 (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\u2080 m (K\u2081 m) * (H' m N\u2082)`\n  - `K\u2080 m K\u2081` denotes one of the constants used in the proof of `normed_spectral`\n  - `N\u2082` denotes the natural number `N\u2082 r' (k' m) (b r r' (k' m) \u03b5)` defined before\n  - `\u03b5` denotes the constant `\u03b5 m (K\u2081 m)` used in the proof of `normed_spectral`. -/\nnoncomputable def K\u2081 : \u2115 \u2192 \u211d\u22650\n| 0     := 2 + (r + 1) / (r * (1 - r)) * 4\n| (m+1) :=\nmax (y (m+1) r)\n    (2 * normed_spectral.K\u2080 m (K\u2081 m) *\n         (H' m $ helper.N\u2082 r' (k' m) (helper.b r r' (k' m) (normed_spectral.\u03b5 m (K\u2081 m)))))\n\n/-- For all `m`, the number `K\u2081 m` is larger than `1`. -/\ninstance one_le_K\u2081 : \u2200 m, fact (1 \u2264 K\u2081 m)\n| 0     := \u27e8begin\n             dsimp [K\u2081],\n             apply le_add_right,\n             exact one_le_two\n            end\u27e9\n| (m+1) := \u27e8begin\n              dsimp [K\u2081],\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\u27e9\n\n/-- `K\u2080 m` is the constant `K\u2080 m (K m)` used in the proof of `normed_spectral` -/\nabbreviation K\u2080 : \u211d\u22650 := normed_spectral.K\u2080 m (K\u2081 m)\n\n/-- `\u03b5 m` is the constant `\u03b5 m (K m)` used in the proof of `normed_spectral` -/\nabbreviation \u03b5 : \u211d\u22650 := normed_spectral.\u03b5 m (K\u2081 m)\n\ninstance \u03b5_pos : fact (0 < \u03b5 m) := \u27e8normed_spectral.\u03b5_pos _ _\u27e9\n\nvariables [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' \u2264 1)]\n\n/-- `b \u03ba' r r' m` is the smallest `b` such that `2 * (k' m) * (r / r') ^ b \u2264 (\u03b5 m)`. -/\ndef b : \u2115 := helper.b r r' (k' m) (\u03b5 m)\n\n/-- `b \u03ba' r r' m` is the smallest `b` such that `2 * (k' m) * (r / r') ^ b \u2264 (\u03b5 m)`.\nThis lemma proves that `b` indeed satisfies the property claimed at its definition. -/\nlemma b_spec : (2 * k' m) * (r / r') ^ (b m) \u2264 \u03b5 m :=\nbegin\n  suffices : 2 * (k' \u03ba' m : \u211d) * (r / r') ^ b r r' BD \u03ba' m \u2264 \u03b5 r r' BD \u03ba' m,\n  exact_mod_cast this,\n  apply helper.b_spec \u2039fact (0 < r)\u203a.out \u2039fact (0 < r')\u203a.out \u2039fact (r < r')\u203a.out ; norm_cast ;\n  apply fact.out\nend\n\n/-- `N\u2082 \u03ba' r r' m` is the smallest `N\u2082` such that `N = 2 ^ N\u2082` satisfies\n`(k' m) / N \u2264 r' ^ (b \u03ba' r r' m)`. -/\ndef N\u2082 : \u2115 := helper.N\u2082 r' (k' m) (b m)\n\n/-- `N\u2082 \u03ba' r r' m` is the smallest `N\u2082` such that `N = 2 ^ N\u2082` satisfies\n`(k' m) / N \u2264 r' ^ (b \u03ba' r r' m)`.\nThis lemma proves that `N\u2082` indeed satisfies the property claimed at its definition. -/\nlemma N\u2082_spec : (k' m) / (2 ^ (N\u2082 m)) \u2264 r' ^ b m :=\nbegin\n  suffices : (k' \u03ba' m : \u211d) / 2 ^ N\u2082 r r' BD \u03ba' m \u2264 r' ^ (b r r' BD \u03ba' m : \u211d),\n  exact_mod_cast this,\n  apply helper.N\u2082_spec \u2039fact (0 < r')\u203a.out ; norm_cast ;\n  apply fact.out\nend\n\n/-- `N\u2082 = N\u2082 \u03ba' r r' m` is defined in such a way that `r' ^ b < 2 * k' m / 2 ^ N\u2082`,\nwhere `b = b \u03ba' r r' m`. -/\nlemma N\u2082_spec_of_pos' (h : 0 < N\u2082 m) :\n  r' ^ b m < 2 * k' m / 2 ^ N\u2082 m :=\nbegin\n  suffices : (r' : \u211d) ^ (b r r' BD \u03ba' m : \u211d) < 2 * k' \u03ba' m / 2 ^ N\u2082 r r' BD \u03ba' m,\n  exact_mod_cast this,\n  apply helper.N\u2082_spec_of_pos' h,\n  { norm_cast,\n    exact \u2039fact (0 < r')\u203a.out },\n  apply nnreal.coe_nonneg\nend\n\nlemma k'_eq_one_of_N\u2082_spec_eq_zero (h : N\u2082 m = 0) : k' m = 1 :=\nbegin\n  refine le_antisymm _ (universal_constants.one_le_k' _ _).1,\n  obtain F := N\u2082_spec r r' BD \u03ba' m,\n  rw [h, pow_zero, div_one] at F,\n  refine F.trans (pow_le_one (b r r' BD \u03ba' m) (le_of_lt _) _);\n  { apply fact.out _,\n    assumption }\nend\n\n/-- `N m = 2 ^ N\u2082 m` is the smallest `N` that satisfies `(k' m) / N \u2264 r' ^ (b m)` -/\ndef N : \u2115 := 2 ^ N\u2082 m\n\ninstance N_pos : fact (0 < N m) := \u27e8pow_pos zero_lt_two _\u27e9\n\n/-- For all `m` we have `k' m \u2264 N m = 2 ^ N\u2082 m`. -/\ninstance k'_le_two_pow_N : fact (k' m \u2264 2 ^ N\u2082 m) :=\n{ out := begin\n  rw [\u2190 mul_one ((2 : \u211d\u22650) ^ _)],\n  obtain F := N\u2082_spec r r' BD \u03ba' 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) \u2264 2 * k' m * (r / r') ^ (b m)`. -/\nlemma r_pow_b_mul_N_le : r ^ (b m) * (N m) \u2264 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, \u2190 nnreal.le_div_iff_mul_le],\n  { by_cases N0 : N\u2082 r r' BD \u03ba' m = 0,\n    { rw [k'_eq_one_of_N\u2082_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\u2082_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 \u2264 \u03b5 m`. -/\nlemma r_pow_b_le_\u03b5 : r ^ b m * N m \u2264 \u03b5 m := (r_pow_b_mul_N_le _).trans (b_spec _)\n\n/-- For all `m` we have `k' m * (2 ^ N\u2082 m)\u207b\u00b9 \u2264 r' ^ b m`. -/\nlemma N\u2082_spec' : k' m * (2 ^ N\u2082 m)\u207b\u00b9 \u2264 r' ^ b m :=\nby { rw [inv_eq_one_div, mul_one_div], exact N\u2082_spec r r' BD \u03ba' m }\n\n/-- `H BD \u03ba' r r' m` is the universal bound on the norm of the `N\u2082`th Breen--Deligne homotopy\nin the first `m` degrees. Here `N\u2082 = N\u2082 \u03ba' r r' m`. -/\ndef H : \u2115 := H' m (N\u2082 m)\n\nlemma one_le_H : 1 \u2264 H m := le_max_left _ _\n\ninstance H_pos : fact (0 < H m) := \u27e8zero_lt_one.trans_le $ one_le_H _\u27e9\ninstance H_pos' : fact ((0:\u211d\u22650) < H m) := by { norm_cast, apply_instance }\n\nlemma bound_by_H {q : \u2115} (h : q \u2264 m) :\n  ((BD.data.homotopy_mul BD.homotopy (N\u2082 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    (\u03bb q, ((BD.data.homotopy_mul BD.homotopy (N\u2082 r r' BD \u03ba' 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\u2080 m (K\u2081 m) * H m`,\nwhere `K\u2080 m (K\u2081 m)` is one of the constants used in the proof of `normed_spectral`. -/\ndef K : \u211d\u22650 := 2 * normed_spectral.K\u2080 m (K\u2081 m) * H m\n\ninstance one_le_K : fact (1 \u2264 K m) := fact.mk $\ncalc 1 = 1 * 1 * 1 : by simp\n... \u2264 2 * normed_spectral.K\u2080 m (K\u2081 m) * H m :\nbegin\n  refine mul_le_mul' (mul_le_mul' one_le_two $ (normed_spectral.one_le_K\u2080 _ _).1) _,\n  norm_cast,\n  apply one_le_H\nend\n\n/-- For all positive `m`, we have `K (m - 1) \u2264 K\u2081 m`. -/\ninstance K_le_K\u2081 [fact (0 < m)] : fact (K (m - 1) \u2264 K\u2081 m) :=\n\u27e8begin\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\u2081, nat.succ_sub_succ_eq_sub, nat.sub_zero, le_max_iff],\n  right,\n  apply le_refl\nend\u27e9\n\nlemma K\u2081_spec : (m + 2 + (r + 1) / (r * (1 - r)) * (m + 2)^2 : \u211d\u22650) \u2264 K\u2081 m :=\nbegin\n  cases m,\n  { norm_num [K\u2081] },\n  { simp only [K\u2081, le_max_iff],\n    left,\n    apply le_refl }\nend\n\nsection open simplex_category\n\ndef c\u2080_aux (m : \u2115) (\u039b : PolyhedralLattice) : \u211d\u22650 :=\nN m * lem98.d \u039b (N m) / (k\u2081_sqrt m - 1) / r' / (range $ m+1).inf' \u27e80, by simp\u27e9 \u03ba\n\n-- define this such that the lemmas below hold\nnoncomputable def c\u2080 : \u2115 \u2192 PolyhedralLattice \u2192 \u211d\u22650\n| 0 \u039b := c\u2080_aux 0 \u039b\n| (m+1) \u039b := max (c\u2080_aux (m+1) \u039b)\n    (max (c\u2080 m \u039b)\n    (max (c\u2080 m ((\u039b.cosimplicial (N (m+1))).obj (mk 0)))\n      ((range (m+1)).sup (\u03bb i, c\u2080 m ((\u039b.cosimplicial (N (m+1))).obj (mk (i + 1)))))))\n\nlemma c\u2080_mono : fact (c\u2080 (m - 1) \u039b \u2264 c\u2080 m \u039b) :=\nbegin\n  fsplit,\n  cases m,\n  { apply le_refl, },\n  { dsimp [c\u2080],\n    apply le_trans _ (le_max_right _ _),\n    apply le_trans _ (le_max_left _ _),\n    simp, }\nend\n\nlemma c\u2080_pred_le (hm : 0 < m) : fact (c\u2080 (m - 1) ((\u039b.cosimplicial (N m)).obj (mk 0)) \u2264  c\u2080 m \u039b) :=\nbegin\n  fsplit,\n  cases m,\n  { cases hm, },\n  { dsimp [c\u2080],\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\u2080_pred_le_of_le (i : \u2115) (hi : i + 2 \u2264 m + 1) :\n  fact (c\u2080 (m - 1) ((\u039b.cosimplicial (N m)).obj (mk (i + 1))) \u2264 c\u2080 m \u039b) :=\nbegin\n  fsplit,\n  cases m,\n  { simpa using nat.succ_le_succ_iff.mp hi, },\n  { dsimp [c\u2080],\n    replace hi : i \u2208 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 \u211d\u22650 :=\nbegin\n  apply semilattice_inf.ext, intros, refl,\nend\n\nlemma c\u2080_spec [BD.data.very_suitable r r' \u03ba] (j : \u2115) (hj : j \u2264 m) :\n  lem98.d \u039b (N m) \u2264 (k\u2081_sqrt m - 1) * (r' * (\u03ba j * c\u2080 m \u039b)) / (N m) :=\nbegin\n  have w := BD.data.pos \u03ba,\n  rw [nnreal.le_div_iff', \u2190nnreal.div_le_iff', \u2190nnreal.div_le_iff', \u2190nnreal.div_le_iff'],\n  rotate,\n  { exact (w _).ne' },\n  { apply ne_of_gt, exact fact.out _ },\n  { rw [\u2190 pos_iff_ne_zero, \u2190add_lt_add_iff_right (1 : \u211d\u22650), 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\u2080_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 \u2022 s) \u2022 a = r \u2022 (s \u2022 a)`.\n\nAn important definition is `to_alg_hom R S A`, the canonical `R`-algebra homomorphism `S \u2192\u2090[R] A`.\n\n-/\n\n\nopen Pointwise\n\nuniverse u v w u\u2081 v\u2081\n\nvariable (R : Type u) (S : Type v) (A : Type w) (B : Type u\u2081) (M : Type v\u2081)\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\u2093'. -/\n/-- The `R`-algebra morphism `A \u2192 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 \u2192\u2090[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\u2093'. -/\n@[simp]\ntheorem lsmul_coe (a : A) : (lsmul R M a : M \u2192 M) = (\u00b7 \u2022 \u00b7) 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\u2093'. -/\ntheorem algebraMap_smul (r : R) (x : M) : algebraMap R A r \u2022 x = r \u2022 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\u2093'. -/\ntheorem of_algebraMap_eq [Algebra R A]\n    (h : \u2200 x, algebraMap R A x = algebraMap S A (algebraMap R S x)) : IsScalarTower R S A :=\n  \u27e8fun x y z => by simp_rw [Algebra.smul_def, RingHom.map_mul, mul_assoc, h]\u27e9\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\u2093'. -/\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      \u2200 (r : S) (x : A),\n        (haveI := h1\n          r \u2022 x) =\n          r \u2022 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 \u2192\u2090[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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_toAlgHom : \u2191(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 \u2192 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 \u2192\u2090[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, \u2190 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\u2093.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\u2093'. -/\n@[simp]\ntheorem IsScalarTower.AlgHom.comp_algebraMap_of_tower (f : A \u2192\u2090[S] B) :\n    (f : A \u2192+* 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\u2093'. -/\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 \u2192\u2090[R] B) :\n    @IsScalarTower R A B _ f.toRingHom.toAlgebra.toSMul _ :=\n  letI := (f : A \u2192+* 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 \u27f6 S induces S-Alg \u2964 R-Alg -/\ndef restrictScalars (f : A \u2192\u2090[S] B) : A \u2192\u2090[R] B :=\n  { (f : A \u2192+* 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 \u2192\u2090[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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_restrictScalars (f : A \u2192\u2090[S] B) : (f.restrictScalars R : A \u2192+* 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 \u2192\u2090[S] B) : (restrictScalars R f : A \u2192 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 \u2192\u2090[S] B) \u2192 A \u2192\u2090[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 \u27f6 S induces S-Alg \u2964 R-Alg -/\ndef restrictScalars (f : A \u2243\u2090[S] B) : A \u2243\u2090[R] B :=\n  { (f : A \u2243+* 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\u2093'. -/\ntheorem restrictScalars_apply (f : A \u2243\u2090[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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_restrictScalars (f : A \u2243\u2090[S] B) : (f.restrictScalars R : A \u2243+* 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'\u2093'. -/\n@[simp]\ntheorem coe_restrict_scalars' (f : A \u2243\u2090[S] B) : (restrictScalars R f : A \u2192 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 \u2243\u2090[S] B) \u2192 A \u2243\u2090[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\u2093'. -/\n/-- If `A` is an `R`-algebra such that the induced morphism `R \u2192+* 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 \u27e8r, rfl\u27e9 := 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\u2093.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\u2093.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\u2093'. -/\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 \u2208 span R s) {x : A}\n    (hx : x \u2208 t) : k \u2022 x \u2208 span R (s \u2022 t) :=\n  span_induction hks (fun c hc => subset_span <| Set.mem_smul.2 \u27e8c, x, hc, hx, rfl\u27e9)\n    (by\n      rw [zero_smul]\n      exact zero_mem _)\n    (fun c\u2081 c\u2082 ih\u2081 ih\u2082 => by\n      rw [add_smul]\n      exact add_mem ih\u2081 ih\u2082)\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\u2093'. -/\ntheorem smul_mem_span_smul {s : Set S} (hs : span R s = \u22a4) {t : Set A} {k : S} {x : A}\n    (hx : x \u2208 span R t) : k \u2022 x \u2208 span R (s \u2022 t) :=\n  span_induction hx (fun x hx => smul_mem_span_smul_of_mem (hs.symm \u25b8 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 \u25b8 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'\u2093'. -/\ntheorem smul_mem_span_smul' {s : Set S} (hs : span R s = \u22a4) {t : Set A} {k : S} {x : A}\n    (hx : x \u2208 span R (s \u2022 t)) : k \u2022 x \u2208 span R (s \u2022 t) :=\n  span_induction hx\n    (fun x hx => by\n      let \u27e8p, q, hp, hq, hpq\u27e9 := Set.mem_smul.1 hx\n      rw [\u2190 hpq, smul_smul]\n      exact smul_mem_span_smul_of_mem (hs.symm \u25b8 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 \u25b8 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\u2093'. -/\ntheorem span_smul_of_span_eq_top {s : Set S} (hs : span R s = \u22a4) (t : Set A) :\n    span R (s \u2022 t) = (span S t).restrictScalars R :=\n  le_antisymm\n    (span_le.2 fun x hx =>\n      let \u27e8p, q, hps, hqt, hpqx\u27e9 := Set.mem_smul.1 hx\n      hpqx \u25b8 (span S t).smul_mem p (subset_span hqt))\n    fun p hp =>\n    span_induction hp (fun x hx => one_smul S x \u25b8 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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 \u2208 Submodule.span R a) : algebraMap S T x \u2208 Submodule.span R (algebraMap S T '' a) :=\n  by\n  rw [span_algebra_map_image_of_tower, mem_map]\n  exact \u27e8x, hx, rfl\u27e9\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\u2093'. -/\ntheorem lsmul_injective [NoZeroSMulDivisors A M] {x : A} (hx : x \u2260 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 \u2192 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 \u2192 Cat \u2192 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} \u2192 (X : Obj C) \u2192 Prop\n| _, Obj.var _ _     => False\n| _, Obj.varApp _ X  => ObjContainsRAdj L X\n| _, Obj.rAdjApp F X => FuncContainsRAdj L F \u2228 ObjContainsRAdj L X\n\ndef FuncContainsRAdj {C' D' : Cat} (L : Func C' D') : {C D : Cat} \u2192 (F : Func C D) \u2192 Prop\n| _, _, Func.id _         => False\n| _, _, Func.compVar G v  => FuncContainsRAdj L G\n| _, _, Func.compRAdj G H => FuncContainsRAdj L G \u2228 HEq L H\n\nend\n\nnoncomputable def Func.compAux {D E : Cat} (G : Func D E) : (C : Cat) \u2192 (F : Func C D) \u2192 Func C E :=\n@Func.recOn (\u03bb _ _ => Unit) (\u03bb D E G => (C : Cat) \u2192 (F : Func C D) \u2192 Func C E)\n  D E G\n  (\u03bb _ _ => ())\n  (\u03bb _ _ _ => ())\n  (\u03bb _ _ _ _ => ())\n  (\u03bb _ _ F => F)\n  (\u03bb D v ih C F => compVar (ih _ F) v)\n  (\u03bb 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) \u2192 Obj D :=\n@Func.recOn (\u03bb _ _ => Unit) (\u03bb C D _ => Obj C \u2192 Obj D)\n  C D F\n  (\u03bb _ _ => ())\n  (\u03bb _ _ _ => ())\n  (\u03bb _ _ _ _ => ())\n  (\u03bb _ X => X)\n  (\u03bb F v ih X => Obj.varApp v (ih X))\n  (\u03bb 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} \u2192 (X Y : Obj C) \u2192 \u03a3 D : Cat, Obj D \u00d7 Obj D\n| C, X, rAdjApp F Y => cases (F.app X) Y\n| C, X,           Y => \u27e8C, X, Y\u27e9\n\n\ntheorem FuncAppContainsRAdj {C' D' : Cat} (G : Func C' D') :\n  {C D : Cat} \u2192 (F : Func C D) \u2192 (X : Obj C) \u2192\n  ObjContainsRAdj G (F.app X) \u2194 FuncContainsRAdj G F \u2228 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} \u2192 {X Y : Obj E} \u2192 {F : Func C D} \u2192\n  ObjContainsRAdj F (X.cases Y).2.1 \u2192 ObjContainsRAdj F X \u2228 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} \u2192 {X Y : Obj E} \u2192 {F : Func C D} \u2192\n  ObjContainsRAdj F (X.cases Y).2.2 \u2192 ObjContainsRAdj F X \u2228 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 (\u0393 : Context)\n\nmutual\n\ninductive HomAux : {C : Cat} \u2192 (X Y : Obj C) \u2192 Type where\n| var {C : Cat} (X Y : Obj C) (v : \u0393.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 \u2192 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} \u2192 (X Y : Obj C) \u2192 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 : \u0393.HomVar A B) :\n--   {C : Cat} \u2192 {X Y : Obj C} \u2192 HomAux \u0393 X Y \u2192 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 : \u0393.HomVar A B) :\n--   {C : Cat} \u2192 {X Y : Obj C} \u2192 Hom \u0393 X Y \u2192 Prop\n-- | _, _, _, Hom.id _ => False\n-- | _, _, _, Hom.comp' f g => HomAuxContainsVar v f \u2228 HomContainsVar v g\n\n-- end\n\nmutual\n\ninductive HomAuxContainsVar {C' : Cat} {A B : Obj C'} (v : \u0393.HomVar A B) :\n  {C : Cat} \u2192 {X Y : Obj C} \u2192 HomAux \u0393 X Y \u2192 Prop where\n| self : HomAuxContainsVar v (HomAux.var A B v)\n| mapRAdj : HomAuxContainsVar v f \u2192 HomAuxContainsVar v (HomAux.mapRAdj F f)\n| mapVar : HomAuxContainsVar v f \u2192 HomAuxContainsVar v (HomAux.mapVar D F f)\n| restrict : HomContainsVar v f \u2192 HomAuxContainsVar v (HomAux.restrict _ f)\n\ninductive HomContainsVar {C' : Cat} {A B : Obj C'} (v : \u0393.HomVar A B) :\n  {C : Cat} \u2192 {X Y : Obj C} \u2192 Hom \u0393 X Y \u2192 Prop where\n| compLeft : HomAuxContainsVar v f \u2192 HomContainsVar v (Hom.comp' f g)\n| compRight : HomContainsVar v g \u2192 HomContainsVar v (Hom.comp' f g)\n\nend\n\nvariable {\u0393}\n\nnamespace Hom\n\nvariable {C D : Cat}\n\nsection defs\n\ndef ofHomAux {X Y : Obj C} (f : HomAux \u0393 X Y) : Hom \u0393 X Y :=\nHom.comp' f (Hom.id _)\n\nnoncomputable def var {X Y : Obj C} (v : \u0393.HomVar X Y) : Hom \u0393 (X.cases Y).2.1 (X.cases Y).2.2 :=\nofHomAux (HomAux.var _ _ v)\n\nnoncomputable def comp : {C : Cat} \u2192 {X Y Z : Obj C} \u2192\n  Hom \u0393 X Y \u2192 Hom \u0393 Y Z \u2192 Hom \u0393 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} \u2192 (F : Func C D) \u2192 {X Y : Obj C} \u2192\n  (f : HomAux \u0393 X Y) \u2192 HomAux \u0393 (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} \u2192\n  (f : Hom \u0393 X Y) \u2192 Hom \u0393 (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 : \u0393.hasRAdj F)\n  {X : Obj C} {Y : Obj D}\n  (f : Hom \u0393 (F.app X) Y) : Hom \u0393 X (Obj.rAdjApp F Y) :=\nofHomAux (HomAux.restrict F f)\n\nnoncomputable def counit {C D : Cat} (F : Func C D) (hF : \u0393.hasRAdj F) (X : Obj D) :\n  Hom \u0393 (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} \u2192 (f : Hom \u0393 X Y) \u2192 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 \u0393 X Y) : (Hom.id _).comp f = f :=\nby rw [Hom.comp]\n\ntheorem compAssoc : {W X Y Z : Obj C} \u2192\n  (f : Hom \u0393 W X) \u2192 (g : Hom \u0393 X Y) \u2192 (h : Hom \u0393 Y Z) \u2192\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 \u0393 C X) = Hom.id (F.app X) :=\nby rw [Hom.map]\n\ntheorem mapComp (F : Func C D) : {X Y Z : Obj C} \u2192 (f : Hom \u0393 X Y) \u2192 (g : Hom \u0393 Y Z) \u2192\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 \u2192 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 (\u0393\u2081 \u0393\u2082 : Context)\n  (h : \u2200 {C D : Cat} (F : Func C D), \u0393\u2081.hasRAdj F \u2192 \u0393\u2082.hasRAdj F)\n  (i : {C : Cat} \u2192 {X Y : Obj C} \u2192 \u0393\u2081.HomVar X Y \u2192 \u0393\u2082.HomVar X Y) :\n  {C : Cat} \u2192 {X Y : Obj C} \u2192 HomAux \u0393\u2081 X Y \u2192 HomAux \u0393\u2082 X Y\n| _, _, _, HomAux.mapVar _ v f => HomAux.mapVar _ v (changeVarsAux \u0393\u2081 \u0393\u2082 h i f)\n| _, _, _, HomAux.mapRAdj F f => HomAux.mapRAdj F (changeVarsAux \u0393\u2081 \u0393\u2082 h i f)\n| _, _, _, HomAux.var _ _ f => HomAux.var _ _ (i f)\n| _, _, _, HomAux.restrict F f => HomAux.restrict F (changeVars \u0393\u2081 \u0393\u2082 h i f)\n| _, _, _, HomAux.counit F X => HomAux.counit F X\n\nnoncomputable def changeVars (\u0393\u2081 \u0393\u2082 : Context)\n  (h : \u2200 {C D : Cat} (F : Func C D), \u0393\u2081.hasRAdj F \u2192 \u0393\u2082.hasRAdj F)\n  (i : {C : Cat} \u2192 {X Y : Obj C} \u2192 \u0393\u2081.HomVar X Y \u2192 \u0393\u2082.HomVar X Y) :\n  {C : Cat} \u2192 {X Y : Obj C} \u2192 Hom \u0393\u2081 X Y \u2192 Hom \u0393\u2082 X Y\n| _, _, _, Hom.id _ => Hom.id _\n| _, _, _, Hom.comp' f g => Hom.comp' (changeVarsAux \u0393\u2081 \u0393\u2082 h i f) (changeVars \u0393\u2081 \u0393\u2082 h i g)\n\nend\n\nmutual\n\nnoncomputable def changeVarsAux2 (\u0393\u2081 \u0393\u2082 : Context) :\n  {C : Cat} \u2192 {X Y : Obj C} \u2192 (f : HomAux \u0393\u2081 X Y) \u2192\n  (h : \u2200 {C D : Cat} (F : Func C D), \u0393\u2081.hasRAdj F \u2192 \u0393\u2082.hasRAdj F) \u2192\n  (i : {C : Cat} \u2192 {X Y : Obj C} \u2192 (v : \u0393\u2081.HomVar X Y) \u2192\n    HomAuxContainsVar \u0393\u2081 v f \u2192 \u0393\u2082.HomVar X Y)  \u2192 HomAux \u0393\u2082 X Y\n| _, _, _, HomAux.mapVar _ v f, h, i =>\n    HomAux.mapVar _ v (changeVarsAux2 \u0393\u2081 \u0393\u2082 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 \u0393\u2081 \u0393\u2082 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 \u0393\u2081 \u0393\u2082 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 (\u0393\u2081 \u0393\u2082 : Context) :\n  {C : Cat} \u2192 {X Y : Obj C} \u2192 (f : Hom \u0393\u2081 X Y) \u2192\n  (h : \u2200 {C D : Cat} (F : Func C D), \u0393\u2081.hasRAdj F \u2192 \u0393\u2082.hasRAdj F) \u2192\n  (i : {C : Cat} \u2192 {X Y : Obj C} \u2192 (v : \u0393\u2081.HomVar X Y) \u2192\n    HomContainsVar \u0393\u2081 v f \u2192 \u0393\u2082.HomVar X Y) \u2192 Hom \u0393\u2082 X Y\n| _, _, _, Hom.id _, _, _ => Hom.id _\n| _, _, _, Hom.comp' f g, h, i =>\n  Hom.comp' (changeVarsAux2 \u0393\u2081 \u0393\u2082 f h\n    (by\n      intros\n      apply i\n      constructor\n      assumption))\n    (changeVars2 \u0393\u2081 \u0393\u2082 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 (\u0393\u2081 \u0393\u2082 : Context)\n  (h : \u2200 {C D : Cat} (F : Func C D), \u0393\u2081.hasRAdj F \u2192 \u0393\u2082.hasRAdj F)\n  (i : {C : Cat} \u2192 {X Y : Obj C} \u2192 \u0393\u2081.HomVar X Y \u2192 \u0393\u2082.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\u00edculo \"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\u207b\u00b9) * (u * y)\u207b\u00b9) * x))\u207b\u00b9) = u\n\nimport tactic\n\nclass mccune_group (\u03b1 : Type*) extends has_mul \u03b1, has_inv \u03b1, inhabited \u03b1 :=\n(mccune (x y z u : \u03b1) : x * (y * (((z * z\u207b\u00b9) * (u * y)\u207b\u00b9) * x))\u207b\u00b9 = u)\n\nnamespace mccune_group\nvariables {\u03b1 : Type*} [mccune_group \u03b1] (x y z u w v : \u03b1)\n\nlemma l5 : x * (y * (z * z\u207b\u00b9 * (u * y)\u207b\u00b9 * x))\u207b\u00b9 = u := mccune _ _ _ _\n\nlemma l7 : x * (y * y\u207b\u00b9 * (z * u)\u207b\u00b9 * (v * v\u207b\u00b9) * (z * x))\u207b\u00b9 = u :=\nby simpa [l5 (v * v\u207b\u00b9)] using l5 x (y * y\u207b\u00b9 * (z * u)\u207b\u00b9 * (v * v\u207b\u00b9)) v u\n\nlemma l9 : x * (y * (z * z\u207b\u00b9) * (u * x))\u207b\u00b9 = v * v\u207b\u00b9 * (y * u)\u207b\u00b9 * (w * w\u207b\u00b9) :=\nby simpa [l5 (w * w\u207b\u00b9)] using l7 x w u (v * v\u207b\u00b9 * (y * u)\u207b\u00b9 * (w * w\u207b\u00b9)) z\n\nlemma l10 : y * y\u207b\u00b9 * (z * z\u207b\u00b9 * (u * x)\u207b\u00b9 * u)\u207b\u00b9 * (v * v\u207b\u00b9) = x :=\nby simpa [l9 _ _ _ u v y] using l7 x z u x z\n\nlemma l12 : x * x\u207b\u00b9 * y\u207b\u00b9\u207b\u00b9 * (z * z\u207b\u00b9) = y :=\nby simpa [l10] using l10 y x x (y * y\u207b\u00b9 * (y * y\u207b\u00b9)\u207b\u00b9) z\n\nlemma l14 : (x * x\u207b\u00b9) * (y * z)\u207b\u00b9 = u * u\u207b\u00b9 * (y * z)\u207b\u00b9 := -- [10 -> 5]\nbegin\n  convert l5 _ _ _ _,\n  rw l10,\n  exact x,\nend\n\nlemma l15 : (x * x\u207b\u00b9) * y\u207b\u00b9 = (z * z\u207b\u00b9) * y\u207b\u00b9 :=\nby simpa [l12] using l14 x ((x * x\u207b\u00b9) * y\u207b\u00b9\u207b\u00b9) (z * z\u207b\u00b9) z\n\nlemma l17 : u * u\u207b\u00b9 = v * v\u207b\u00b9 := -- [15 \u2192 5 : 5]\nbegin\n  rw \u2190l5 u u\u207b\u00b9 u (v * v\u207b\u00b9),\n  rw l15 v _,\n  rw l5,\nend\n\ninstance : has_one \u03b1 := \u27e8arbitrary \u03b1 * (arbitrary \u03b1)\u207b\u00b9\u27e9\n\n@[simp] lemma l17' : u * u\u207b\u00b9 = 1 := l17 _ _\n\nlemma l10' : (1 * ((1 * (u * x)\u207b\u00b9) * u)\u207b\u00b9) * 1 = x := l10 _ _ _ _ _\n\nlemma l20' : (1 * (1*z)\u207b\u00b9)*1 = z\u207b\u00b9 :=\nbegin\n  convert l10' _ _,\n  rw l17',\n  rw l17',\nend\n\nlemma l5' : x * (y * ((1 * (u * y)\u207b\u00b9) * x))\u207b\u00b9 = u := l5 _ _ _ _\n\nlemma l22' : x * (y\u207b\u00b9 * (1 * x))\u207b\u00b9 = y := -- [17 \u2192 5]\nby { convert l5' _ _ y, simp }\n\nlemma l7' : x * (((1 * (z * u)\u207b\u00b9) * 1) * (z * x))\u207b\u00b9 = u := l7 _ _ _ _ _\n\nlemma l25' : x * (1\u207b\u00b9\u207b\u00b9 * (w * x))\u207b\u00b9 = w\u207b\u00b9 := -- [19 \u2192 7:20]\nbegin\n  convert l7' _ _ _,\n  rw l17',\n  convert (l20' _).symm,\n  simp,\nend\n\nlemma l32' : 1\u207b\u00b9 * (y\u207b\u00b9 * 1)\u207b\u00b9 = y := -- [17 \u2192 22]\nbegin\n  convert l22' (1 : \u03b1)\u207b\u00b9 y,\n  simp\nend\n\nlemma l34' : x\u207b\u00b9 * (1\u207b\u00b9\u207b\u00b9 * 1)\u207b\u00b9 = x\u207b\u00b9 := by simpa using l25' x\u207b\u00b9 x\n\nlemma l36' : (1 * (x * 1\u207b\u00b9\u207b\u00b9)\u207b\u00b9)\u207b\u00b9 = x :=\nbegin\n  convert l5' _ _ _,\n  rw l25',\n  exact x\nend\n\nlemma l44' : x * (1\u207b\u00b9\u207b\u00b9 * 1)\u207b\u00b9 = x := by simpa [l36'] using l34' (1 * (x * 1\u207b\u00b9\u207b\u00b9)\u207b\u00b9)\nlemma l48' : (1 : \u03b1)\u207b\u00b9\u207b\u00b9 * 1 = 1 := by simpa using (l44' ((1 : \u03b1)\u207b\u00b9\u207b\u00b9 * 1)).symm\nlemma l52' : x * 1\u207b\u00b9 = x := by simpa [l48'] using l44' x\nlemma l57' : (1\u207b\u00b9 * u)\u207b\u00b9\u207b\u00b9 = u := by simpa [l52', l20'] using l10' u 1\u207b\u00b9\n\nlemma l62' : (x\u207b\u00b9 * 1)\u207b\u00b9 = x\u207b\u00b9\u207b\u00b9 :=\nby simpa [l32'] using (l57' (x\u207b\u00b9 * 1)\u207b\u00b9).symm\n\nlemma l76' : (x * 1)\u207b\u00b9 = x\u207b\u00b9 := by simpa [l57'] using l62' (1\u207b\u00b9 * x)\u207b\u00b9\n\nlemma l88' : 1\u207b\u00b9 * x\u207b\u00b9\u207b\u00b9 = 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 : \u03b1)\u207b\u00b9\u207b\u00b9 = 1 :=\nby simpa using l48'\n\n@[simp] lemma one_inv : (1 : \u03b1)\u207b\u00b9 = 1 :=\nby simpa using l88' (1 : \u03b1)\n\nlemma l92' : (1 * y\u207b\u00b9)\u207b\u00b9 = y :=\nby simpa using l36' y\n\nlemma l126' : (y * z) * z\u207b\u00b9 = y :=\nbegin\n  have := l5' ((1 : \u03b1) * (y * z)\u207b\u00b9)\u207b\u00b9 z y,\n  rw l17' at this,\n  simpa [l92'] using this,\nend\n\nlemma l201 : x * y\u207b\u00b9\u207b\u00b9 = x * y :=\nby simpa [l126' x y] using l126' (x * y) y\u207b\u00b9\n\n@[simp] lemma l207' : 1 * z = z :=\nby simpa [l201] using l126' z z\u207b\u00b9\n\n@[simp] lemma l227 : y\u207b\u00b9\u207b\u00b9 = y :=\nby simpa using l201 1 y\n\n@[simp] lemma inv_mul : x\u207b\u00b9 * x = 1 :=\nby simpa using l17' x\u207b\u00b9\n\nlemma l229 : (z * x)\u207b\u00b9 = x\u207b\u00b9 * z\u207b\u00b9 := -- 126->25:227,207\nby simpa [l126'] using (l25' x\u207b\u00b9 (z * x)).symm\n\nlemma thingy : x * (x\u207b\u00b9 * z) = z := -- [126->5:207,229,229,227,227]\nbegin\n  have := l5' x z\u207b\u00b9 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\u207b\u00b9 * u) * y) = u * y := -- [126->5:207,229,229,227,227]\nby simpa [l229, l126'] using l5' x y\u207b\u00b9 (u * y)\n\nlemma l260 : (x * y) * z = x * (y * z) := -- [215->215:229,229,229,227,227,239]\nbegin\n  rw \u2190l239 x\u207b\u00b9 z y,\n  rw thingy,\n  simp\nend\n\ninstance : group \u03b1 :=\n{ mul_assoc := l260,\n  one_mul := by simp,\n  mul_one := by simp,\n  mul_left_inv := \u03bb x, inv_mul _,\n  ..(by apply_instance : has_one \u03b1),\n  ..(by apply_instance : has_mul \u03b1),\n  ..(by apply_instance : has_inv \u03b1) }\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 \u211d E] (\u03a9 : set E) \n  (F : Type*) [normed_group F] [normed_space \u211d F] (n : with_top \u2115) : Type* :=\nCc^n\u27ee\u03a9, E, \u211d; \u211d\u27ef \u2192L[\u211d] F\n\nlocalized \"notation `\ud835\udcd3'` := distribution\" in distribution\n\nnamespace distribution\n\nvariables {E : Type*} [normed_group E] [normed_space \u211d E] (\u03a9 : set E) \n  (F : Type*) [normed_group F] [normed_space \u211d F] (n : with_top \u2115)\n\nnoncomputable def dirac (x : E) : \ud835\udcd3' \u03a9 \u211d n := \n  (bounded_continuous_function.eval_clm \u211d x) \u2218L \n  (bounded_cont_diff_map.to_bounded_continuous_functionL \u211d E \u211d n) \u2218L\n  (test_function.to_bounded_cont_diff_mapL)\n\n@[simp] lemma dirac_apply (x : E) (f : Cc^n\u27ee\u03a9, E, \u211d; \u211d\u27ef) : dirac \u03a9 n x f = f x := rfl\n\nnoncomputable def of_measure [measurable_space E] [opens_measurable_space E] \n  (\u03bc : measure E) [is_finite_measure_on_compacts \u03bc] : \n  \ud835\udcd3' \u03a9 \u211d n := \n(L1.integral_clm) \u2218L (test_function.to_Lp n 1 \u03bc)\n\n@[simp] lemma of_measure_apply [measurable_space E] [opens_measurable_space E] \n  (\u03bc : measure E) [is_finite_measure_on_compacts \u03bc] (f : Cc^n\u27ee\u03a9, E, \u211d; \u211d\u27ef) : \n  of_measure \u03a9 n \u03bc f = \u222b x : E, f x \u2202\u03bc := \nby rw [of_measure, integral_eq f (f.integrable \u03bc), L1.integral_eq]; refl\n\nnoncomputable def dirac' [measurable_space E] [opens_measurable_space E] (x : E) : \ud835\udcd3' \u03a9 \u211d n := \n  of_measure \u03a9 n (measure.dirac x)\n\nlemma dirac_eq_dirac' [measurable_space E] [opens_measurable_space E] (x : E) : \n  dirac \u03a9 n x = dirac' \u03a9 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 (\u03a9 : set \u211d) (F : Type*) [normed_group F] [normed_space \u211d F]\n\n--def dderiv\u2097 : \ud835\udcd3' \u03a9 F \u22a4 \u2192\u2097[\u211d] \ud835\udcd3' \u03a9 F \u22a4 :=\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:\u211d) (e2:\u211d) (e3:\u211d) (e4:\u211d): \u211d := x^4+e2*x^2+e3*x+e4\ndef fun_b_gen (x:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d): \u211d \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) : \u211d \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\u207b\u00b9)  -- this comes from the assumption c*b'/x, but again could be better implemented.\ndef deriv_fun_a_gen (x:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d1:\u211d) : \u211d \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:\u211d) (e2:\u211d) (e3:\u211d): \u211d := 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 : \u211d):= (100*e_4 + 71*e_2^2=0) \u2227 (70*e_3^2 + 972*e_2*e_4+45*e_2^3=0) \u2227 d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 \u2227 d_1 = -(1 / 210 * e_3 * (71 * e_2 ^ 2 + 100 * e_4)) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = -(4 / 3 * e_3) \u2227 d_6 = -(2 * e_2) \u2227 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 : \u211d) := -((d_1*e_4)/64) = 0 \u2227 -((d_1*e_3)/128) = 0 \u2227 1/64*(d_2*e_3 + 3*d_3*e_4) = 0 \u2227 1/128*(-128*d_0 + 4*d_2*e_2 + 9*d_3*e_3 + 16*d_4*e_4) = 0 \u2227\n1/64*(-63*d_1 + 6*d_3*e_2 + 10*d_4*e_3 + 15*d_5*e_4) = 0 \u2227 1/128*(-120*d_2 + 24*d_4*e_2 + 35*d_5*e_3 + 48*d_6*e_4) = 0 \u2227 1/64*(-55*d_3 + 20*d_5*e_2 + 27*d_6*e_3 + 35*d_7*e_4) = 0 \u2227\n1/128*(-96*d_4 + 60*d_6*e_2 + 77*d_7*e_3 - 96*e_4) = 0 \u2227 1/64*(-39*d_5 + 42*d_7*e_2 - 52*e_3) = 0 \u2227 -(7/16)*(d_6 + 2*e_2) = 0 \u2227 -((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 : \u211d) := ((15/64)* d_7)=0 \u2227 (7 / 16 * d_6 + 7 / 8 * e_2)=0 \u2227 ((-1)/64* (-39 * d_5 + 42 * d_7 * e_2 - 52 * e_3))=0  \u2227 ((-1)/128 * (-96* d_4 + 60 * d_6 * e_2 + 77 * d_7 * e_3 - 96 * e_4))=0 \u2227 ((-1)/64 * (-55 * d_3 + 20 * d_5 * e_2 + 27 * d_6 * e_3 + 35 * d_7 * e_4))=0 \u2227 ((-1)/128 * (-120 * d_2 + 24 * d_4 * e_2 + 35 * d_5 * e_3 + 48 * d_6 * e_4))=0 \u2227 ((-1)/64*(-63 * d_1 + 6 * d_3 * e_2 + 10 * d_4 * e_3 + 15 * d_5 * e_4))=0 \u2227 ((-1)/128 * (-128 * d_0 + 4 * d_2 * e_2 + 9 * d_3 * e_3 + 16 * d_4 * e_4))=0 \u2227 ((-1)/64 * (d_2 * e_3 + 3 * d_3 * e_4))=0 \u2227 ((d_1 * e_3)/128)=0 \u2227 ((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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \nsystem_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7 \u2192 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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \nsystem_eleven_neg e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7 \u2192 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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \nsystem_eleven e2 e3 e4 d0 d1 d2 d3 d4 d5 d6 d7 \u2194 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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d): \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\u22600 to be with out sorrys, but due to time pressure, this has not been implemented.    -/\nlemma unfolding_polynomial_second_term (x:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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 \u2190 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 \u2190 mul_assoc,}},\n  conv_lhs {norm_num,}\nend \n\nlemma unfolding_polynomial_third_term (x:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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\u207b\u00b9)) * (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\u207b\u00b9*x^5 ) )),\n    ring_nf,\n  have h2extra:  4*d1*x\u207b\u00b9*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\u207b\u00b9)) * (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\u207b\u00b9)) * (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\u207b\u00b9 *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\u207b\u00b9)) * (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\u207b\u00b9) )),\n    ring_nf,\n  rw h5,\n  have h3extra: d1 * e3 * x ^ 2 * x\u207b\u00b9 = d1 * e3 * x,\n    sorry,\n  rw h3extra,\n  have h4extra: d1 * 2 * e2 * x\u207b\u00b9 * x ^ 3 = d1 * 2 * e2 *  x ^ 2,\n    sorry,\n  rw h4extra,\n  rw \u2190 mul_add,\n  rw \u2190 mul_add,\n  rw \u2190 mul_add,\n  rw \u2190 mul_add,\n  repeat {conv_lhs {rw \u2190 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 \u2190 mul_assoc,}},\n  conv_lhs {norm_num,},\n  repeat {conv_lhs {rw \u2190 mul_assoc,}},\n  repeat {conv_lhs {rw \u2190 neg_mul,}},\nend\n\nlemma eq_11 (x:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \nd7 + -(35 / 64 * d7) + -(7 / 32 * d7)=(15/64)* d7:=\nbegin\n  field_simp,\n  ring_nf,\nend\n\nlemma eq_10 (x:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \n(1 / 64 * d1 * e3 + -(1 / 128 * d1 * e3))=((d1 * e3)/128):=\nbegin\n  simp,\n  ring_nf,\nend\n\nlemma eq_1 (x:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d): \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 \u2190 pow_one x,\n  conv_lhs {rw \u2190 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 \u2190 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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d) (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 \u2192 ((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:\u211d) (d7:\u211d) (d6:\u211d) (d5:\u211d) (d4:\u211d) (d3:\u211d) (d2:\u211d) (d1:\u211d) (d0:\u211d)\n(e2:\u211d) (e3:\u211d) (e4:\u211d) (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 \u2192system_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 : \u211d) (hnotzero : e_3 \u2260 0) : d_6 + 2 * e_2 = 0 \u2194 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 : \u211d) (hnotzero : e_3 \u2260 0) : -(39 * d_5) + 42 * d_7 * e_2 - 52 * e_3 = 0 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194 d_5 = -52 / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 :=\nbegin\n  simp,\n  intros hd6 hd7,\n  simp[hd7],\n  rw [sub_eq_zero, \u2190 neg_mul, mul_comm, \u2190 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 : \u211d) (hnotzero : e_3 \u2260 0) : -(96 * d_4) + 60 * d_6 * e_2 + 77 * d_7 * e_3 - 96 * e_4 = 0 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194\nd_4 = -((5 * e_2^2) / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 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, \u2190 neg_mul, mul_comm, \u2190 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 : \u211d) (hnotzero : e_3 \u2260 0) : -(55 * d_3) + 20 * d_5 * e_2 + 27 * d_6 * e_3 + 35 * d_7 * e_4 = 0 \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194\nd_3 = -((22 * e_2 * e_3) / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 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, \u2190 neg_mul, mul_comm, \u2190 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 : \u211d) (hnotzero : e_3 \u2260 0) : -(120 * d_2) + 24 * d_4 * e_2 + 35 * d_5 * e_3 + 48 * d_6 * e_4 = 0 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194\nd_2 = -e_2 ^ 3 / 4 - (7 * e_3 ^ 2) / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 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, \u2190 neg_mul, mul_comm, \u2190 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 : \u211d) (hnotzero : e_3 \u2260 0) : -(63 * d_1) + 6 * d_3 * e_2 + 10 * d_4 * e_3 + 15 * d_5 * e_4 = 0 \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194\nd_1 = (-(1 / 210)) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 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, \u2190 neg_mul, mul_comm, \u2190 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 : \u211d) (hnotzero : e_3 \u2260 0) : -(128 * d_0) + 4 * d_2 * e_2 + 9 * d_3 * e_3 + 16 * d_4 * e_4 = 0 \u2227 d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194\nd_0 = -(e_2 ^ 4 / 128) - (83 * e_2 * e_3 ^ 2) / 720 - (3 * e_2 ^ 2 * e_4) / 16 - e_4 ^ 2 / 8 \u2227 d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 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, \u2190 neg_mul, mul_comm, \u2190 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 : \u211d) (hnotzero : e_3 \u2260 0) : d_2 * e_3 + 3 * d_3 * e_4 = 0 \u2227 d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 \u2227 d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194\n(-(1 / 180)) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 \u2227 d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 \u2227 d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 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 \u2190 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 : \u211d) (hnotzero : e_3 \u2260 0) : d_1 = 0 \u2227 -(1 / 180) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 \u2227 d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 \u2227 d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194\n-(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) = 0 \u2227 -(1 / 180) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 \u2227 d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 \u2227 d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 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 : \u211d) (hnotzero3 : e_3 \u2260 0) (hnotzero4 : e_4 \u2260 0) : (d_1 = 0 \u2228 e_4 = 0) \u2227 -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) = 0 \u2227 -(1 / 180) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 \u2227 d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 \u2227 d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 d_7 = 0 \u2194\n-(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) = 0 \u2227 -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) = 0 \u2227 -(1 / 180) * e_3 * (45 * e_2 ^ 3 + 70 * e_3 ^ 2 + 972 * e_2 * e_4) = 0 \u2227 d_0 = -(e_2 ^ 4 / 128) - 83 * e_2 * e_3 ^ 2 / 720 - 3 * e_2 ^ 2 * e_4 / 16 - e_4 ^ 2 / 8 \u2227 d_1 = -(1 / 210) * e_3 * (71 * e_2 ^ 2 + 100 * e_4) \u2227 d_2 = -e_2 ^ 3 / 4 - 7 * e_3 ^ 2 / 18 - e_2 * e_4 \u2227 d_3 = -(22 * e_2 * e_3 / 15) \u2227 d_4 = -(5 * e_2 ^ 2 / 4) - e_4 \u2227 d_5 = (-52) / 39 * e_3 \u2227 d_6 = -(2 * e_2) \u2227 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 : \u211d) (hnotzero3 : e_3 \u2260 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 \u2260 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 : \u211d) (hnotzero3 : e_3 \u2260 0) (hnotzero4 : e_4 \u2260 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 \u2194 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 \u27f6 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   \u2243\u2097[R] f.ker.quotient  : (submodule.quot_equiv_of_eq_bot _ (ker_eq_bot_of_mono _)).symm\n        ... \u2243\u2097[R] f.range         : linear_map.quot_ker_equiv_range f\n        ... \u2243\u2097[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            \u2243\u2097[R] f.ker.quotient : submodule.quot_equiv_of_eq _ _ (submodule.range_subtype _)\n        ... \u2243\u2097[R] f.range        : linear_map.quot_ker_equiv_range f\n        ... \u2243\u2097[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 := \u27e8by apply_instance\u27e9,\n  has_kernels := by apply_instance,\n  has_cokernels := has_cokernels_Module,\n  normal_mono := \u03bb X Y, normal_mono,\n  normal_epi := \u03bb X Y, normal_epi }\n\nvariables {O : Module.{v} R} (g : N \u27f6 O)\n\nopen linear_map\nlocal attribute [instance] preadditive.has_equalizers_of_has_kernels\n\ntheorem exact_iff : exact f g \u2194 f.range = g.ker :=\nbegin\n  rw abelian.exact_iff' f g (kernel_is_limit _) (cokernel_is_colimit _),\n  exact \u27e8\u03bb h, le_antisymm (range_le_ker_iff.2 h.1) (ker_le_range_iff.2 h.2),\n    \u03bb h, \u27e8range_le_ker_iff.1 $ le_of_eq h, ker_le_range_iff.1 $ le_of_eq h.symm\u27e9\u27e9\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 \u2192 (Q \u2192 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 {\u03b9 : Type} [decidable_eq \u03b9] (r : free_group \u03b9) (T : set \u03b9) [decidable_pred T]\n\nopen free_group\n\ndef phi : closure_var T \u2192* mul_aut (free_group (free_group \u03b9)) :=\n{ to_fun := \u03bb g : closure_var T, free_group.equiv (mul_left (g : free_group \u03b9)),\n  map_one' := by simp [equiv.perm.one_def]; refl,\n  map_mul' := \u03bb x y, by simp [equiv.perm.mul_def]; refl }\n\ndef phi' : free_group \u03b9 \u2192* mul_aut (free_group (free_group \u03b9)) :=\n{ to_fun := \u03bb 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\u221e) (w w' : free_group \u03b9) :\n  phi' w (of' w' n) = of' (w * w') n := by simp [phi']\n\ninclude r\n\ndef unnormalize : free_group (free_group \u03b9) \u22ca[phi T] closure_var T \u2192* free_group \u03b9 :=\nsemidirect_product.lift\n  (free_group.lift' (\u03bb g : free_group \u03b9,\n    (mul_aut.conj g : free_group \u03b9 \u2243* free_group \u03b9).to_monoid_hom.comp\n      (gpowers_hom (free_group \u03b9) r)))\n  (subgroup.subtype (closure_var T))\n  (\u03bb g, hom_ext (\u03bb i, by simp [_root_.phi, of_eq_of']))\n\nopen semidirect_product\n\ndef unnormalize' : free_group (free_group \u03b9) \u22ca[phi'] free_group \u03b9 \u2192* free_group \u03b9 :=\nsemidirect_product.lift\n  (free_group.lift' (\u03bb g : free_group \u03b9,\n    (mul_aut.conj g : free_group \u03b9 \u2243* free_group \u03b9).to_monoid_hom.comp\n      (gpowers_hom (free_group \u03b9) r)))\n  (monoid_hom.id _)\n  (\u03bb g, hom_ext (\u03bb i, by simp [_root_.phi', of_eq_of']))\n\n@[simp] lemma unnormalize'_inr (w : free_group \u03b9) : unnormalize' r (inr w) = w :=\nsemidirect_product.lift_inr _ _ _ _\n\nlemma unnormalize'_inl (w : free_group (free_group \u03b9)) :\n  unnormalize' r (inl w) = free_group.lift' (\u03bb g : free_group \u03b9,\n    (mul_aut.conj g : free_group \u03b9 \u2243* free_group \u03b9).to_monoid_hom.comp\n      (gpowers_hom (free_group \u03b9) r)) w :=\nsemidirect_product.lift_inl _ _ _ _\n\nomit r\n\ndef remove_subscript (t : \u03b9) : free_group (\u03b9 \u00d7 C\u221e) \u2192* free_group \u03b9 :=\nfree_group.lift' (\u03bb g, (mul_aut.conj (of' t g.2)).to_monoid_hom.comp (of' g.1))\n\ndef mul_subscript (n : C\u221e) : free_group (\u03b9 \u00d7 C\u221e) \u2243* free_group (\u03b9 \u00d7 C\u221e) :=\nfree_group.equiv (equiv.prod_congr (equiv.refl _) (mul_left n))\n\n@[simp] lemma remove_subscript_comp_mul_subscript (t : \u03b9) (n : C\u221e) :\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 : \u03b9) (n : C\u221e) (x) : remove_subscript t\n  (mul_subscript n x) =  of' t n * remove_subscript t x * of' t n\u207b\u00b9 :=\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 : \u03b9) (l : \u03b9 \u00d7 C\u221e) (n : C\u221e) : 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 : \u03b9) :\n  free_group (free_group (\u03b9 \u00d7 C\u221e)) \u22ca[phi'] free_group (\u03b9 \u00d7 C\u221e) \u2192*\n  free_group (free_group \u03b9) \u22ca[phi'] free_group \u03b9 :=\nsemidirect_product.lift (inl.comp\n  (free_group.lift' (\u03bb 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 \u03b9): Type :=\n(to_fun : free_group \u03b9 \u2192 option (free_group (free_group \u03b9) \u22ca[phi'] free_group \u03b9))\n(inv : \u2200 (x : free_group \u03b9), x \u2208 (set.univ : set (free_group \u03b9)) \u2192\n  \u2203 (y : free_group (free_group \u03b9) \u22ca[phi'] free_group \u03b9), y \u2208 to_fun x \u2192 unnormalize' r y = x)\n\ninstance : has_coe_to_fun (solver r T) :=\n{ F := \u03bb _, free_group \u03b9 \u2192 option (free_group (free_group \u03b9) \u22ca[phi'] free_group \u03b9),\n  coe := solver.to_fun }\n\nlemma unnormalize_eq_of_mem {n : solver r T}\n  {x : free_group \u03b9} {y : free_group (free_group \u03b9) \u22ca[phi'] free_group \u03b9}\n  (h : y \u2208 n x) : unnormalize' r y = x := sorry\n\nlemma unnormalize_inl_eq_of_mem {n : solver r T}\n  {x : free_group \u03b9} {y : free_group (free_group \u03b9) \u22ca[phi'] free_group \u03b9}\n  (h : y \u2208 n x) : unnormalize' r (inl y.left) = x * y.right\u207b\u00b9 :=\nby rw [eq_mul_inv_iff_mul_eq, \u2190 unnormalize'_inr r y.right, \u2190 monoid_hom.map_mul,\n    inl_left_mul_inr_right, unnormalize_eq_of_mem r T h]\n\nvariable {\u03b9}\n\nomit r\n\nnoncomputable def normalize_cons\n  (t : \u03b9) (r' : free_group (\u03b9 \u00d7 C\u221e))\n  {A B : set (\u03b9 \u00d7 C\u221e)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B) :\n  \u03a0 (old1 : free_group (\u03b9 \u00d7 C\u221e))\n  (old2 : free_group (free_group (\u03b9 \u00d7 C\u221e)) \u22ca[phi'] free_group (\u03b9 \u00d7 C\u221e)),\n  free_group (free_group (\u03b9 \u00d7 C\u221e)) \u22ca[phi'] free_group (\u03b9 \u00d7 C\u221e)\n| old1 \u27e8w, \u27e8[], _\u27e9\u27e9     := \u27e8phi' old1 w, old1\u27e9\n| old1 \u27e8w, \u27e8i :: l, _\u27e9\u27e9 :=\n  if i.1.1 = t\n  then if i.2 \u2264 1\n    then option.elim (hA old1)\n      (normalize_cons \u27e8old1.1 ++ [i], sorry\u27e9 \u27e8(phi' (of' i.1 i.2))\u207b\u00b9 w, \u27e8l, sorry\u27e9\u27e9)\n      (\u03bb a, inr (of (t, 1))\u207b\u00b9 *\n        normalize_cons (mul_subscript ii (right_hom a))\n          \u27e8phi' (of (t, 1)) (phi' a.right\u207b\u00b9 a.left * w), of' i.1 (ii * i.2) * \u27e8l, sorry\u27e9\u27e9)\n    else option.elim (hB old1)\n      (normalize_cons \u27e8old1.1 ++ [i], sorry\u27e9 \u27e8(phi' (of' i.1 i.2))\u207b\u00b9 w, \u27e8l, sorry\u27e9\u27e9)\n      (\u03bb a, inr (of (t, 1)) *\n        normalize_cons (mul_subscript (ii\u207b\u00b9) (right_hom a))\n          \u27e8phi' (of (t, 1))\u207b\u00b9  (phi' a.right\u207b\u00b9 a.left * w), of' i.1 (ii\u207b\u00b9 * i.2) *\u27e8l, sorry\u27e9\u27e9)\n  else normalize_cons \u27e8old1.1 ++ [i], sorry\u27e9 \u27e8(phi' (of' i.1 i.2))\u207b\u00b9 w, \u27e8l, sorry\u27e9\u27e9\nusing_well_founded { rel_tac := \u03bb _ _, `[exact \u27e8\u03bb _ _, true, sorry\u27e9], dec_tac := `[trivial] }\n\n@[simp] lemma remove_subscript_unnormalize_normalize_cons\n  (t : \u03b9) (r' : free_group (\u03b9 \u00d7 C\u221e))\n  {A B : set (\u03b9 \u00d7 C\u221e)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A)\n  (hB : solver r' B) :\n  \u03a0 (old1 : free_group (\u03b9 \u00d7 C\u221e))\n  (old2 : free_group (free_group (\u03b9 \u00d7 C\u221e)) \u22ca[phi'] free_group (\u03b9 \u00d7 C\u221e)),\n  remove_subscript t (unnormalize' r' (normalize_cons t r' hA hB old1 old2)) =\n    remove_subscript t (old1 * unnormalize' r' old2)\n| old1 \u27e8w, \u27e8[], _\u27e9\u27e9     := by rw normalize_cons; simp [inl_aut]\n| old1 \u27e8w, \u27e8i :: l, _\u27e9\u27e9 := 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 := \u03bb _ _, `[exact \u27e8\u03bb _ _, true, sorry\u27e9], dec_tac := `[trivial] }\n\nnoncomputable def normalize_with_subscript_aux\n  (t : \u03b9) (r' : free_group (\u03b9 \u00d7 C\u221e))\n  {A B : set (\u03b9 \u00d7 C\u221e)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B) :\n  \u03a0 (w : list (\u03a3 i : \u03b9, C\u221e)) (hw : reduced w),\n  free_group (free_group (\u03b9 \u00d7 C\u221e)) \u22ca[phi'] free_group (\u03b9 \u00d7 C\u221e)\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 : \u03b9) (r' : free_group (\u03b9 \u00d7 C\u221e))\n  {A B : set (\u03b9 \u00d7 C\u221e)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B)\n  (w : free_group \u03b9) :\n  free_group (free_group (\u03b9 \u00d7 C\u221e)) \u22ca[phi'] free_group (\u03b9 \u00d7 C\u221e) :=\nnormalize_with_subscript_aux t r' hA hB w.1 w.2\n\nlemma remove_subscript_unnormalize_normalize_with_subscript_aux\n  (t : \u03b9) (r' : free_group (\u03b9 \u00d7 C\u221e))\n  {A B : set (\u03b9 \u00d7 C\u221e)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B) :\n  \u03a0 (w : list (\u03a3 i : \u03b9, C\u221e)) (hw : reduced w),\n  remove_subscript t (unnormalize' r' (normalize_with_subscript_aux t r' hA hB w hw)) = \u27e8w, hw\u27e9\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 : \u03b9) (r' : free_group (\u03b9 \u00d7 C\u221e)) {A B : set (\u03b9 \u00d7 C\u221e)}\n  [decidable_pred A] [decidable_pred B]\n  (hA : solver r' A) (hB : solver r' B) (w : free_group \u03b9) :\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 : \u03b9) (a b : C\u221e) : set (\u03b9 \u00d7 C\u221e) :=\n{ p | p.1 = x \u2192 a \u2264 p.2 \u2227 p.2 \u2264 b }\n\ninstance (x : \u03b9) (a b : C\u221e) : decidable_pred (Icc_prod x a b) :=\nby dunfold Icc_prod; apply_instance\n\n/- need to cyclically reduce r' -/\ndef normalize (t x : \u03b9) (r' : free_group (\u03b9 \u00d7 C\u221e))\n  (hx : x \u2209 T) (ht : exp_sum t r = 1) (a b : C\u221e)\n  (ha : a \u2208 finset.min ((vars r').image prod.snd))\n  (hb : b \u2208 finset.max ((vars r').image prod.snd))\n  (hr' : r' = ((free_group.to_SD t) r).left)\n  (hr'\u2081 : solver r' (Icc_prod x a (b * ii\u207b\u00b9)))\n  (hr'\u2082 : solver r' (Icc_prod x (a * ii) b)) (w : free_group \u03b9) :\n  option (free_group (free_group \u03b9) \u22ca[phi'] free_group \u03b9) :=\nlet w' := remove_subscript_SD t (normalize_with_subscript t r' hr'\u2081 hr'\u2082 w) in\nif w'.right \u2208 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 `\ud835\udca6` := homotopy_category A (complex_shape.up \u2124)\n\nnamespace bounded_homotopy_category\nvariables {X Y Z : cochain_complex A \u2124} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n\n\nsection\nopen homotopy_category\n\n-- move me\n@[reassoc]\nlemma Ext_map_Ext_iso [enough_projectives A]\n  (i : \u2124) (P\u2081 P\u2082 X\u2081 X\u2082 Y : bounded_homotopy_category A)\n  [is_K_projective P\u2081.val] [is_K_projective P\u2082.val]\n  (f\u2081 : P\u2081 \u27f6 X\u2081) [is_quasi_iso f\u2081] (f\u2082 : P\u2082 \u27f6 X\u2082) [is_quasi_iso f\u2082]\n  (\u03c6 : X\u2081 \u27f6 X\u2082) (\u03c6' : P\u2081 \u27f6 P\u2082) (h : \u03c6' \u226b f\u2082 = f\u2081 \u226b \u03c6) :\n  ((Ext i).flip.obj Y).map \u03c6.op \u226b (Ext_iso i P\u2081 X\u2081 Y f\u2081).hom =\n    (Ext_iso i P\u2082 X\u2082 Y f\u2082).hom \u226b (preadditive_yoneda.obj (Y\u27e6i\u27e7)).map \u03c6'.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 [\u2190 category_theory.functor.map_comp, \u2190 op_comp,\n      \u2190 category_theory.functor.map_comp, \u2190 op_comp],\n  congr' 2,\n  dsimp only [replacement_iso_hom, opposite.unop_op],\n  refine lift_ext X\u2082.\u03c0 _ _ _,\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 : \u2124) (X\u2081 X\u2082 Y : bounded_homotopy_category A) (\u03c6 : X\u2081 \u27f6 X\u2082) :\n  ((Ext i).flip.obj Y).map \u03c6.op \u226b (Ext_iso i _ X\u2081 Y X\u2081.\u03c0).hom =\n    (Ext_iso i _ X\u2082 Y X\u2082.\u03c0).hom \u226b (preadditive_yoneda.obj (Y\u27e6i\u27e7)).map (lift (X\u2081.\u03c0 \u226b \u03c6) X\u2082.\u03c0).op :=\nExt_map_Ext_iso _ _ _ _ _ _ _ _ _ _ $ by rw [lift_lifts]\n\nlemma Ext_iso_naturality_snd_component\n  [enough_projectives A]\n  (i : \u2124) (P X Y\u2081 Y\u2082 : bounded_homotopy_category A)\n  [is_K_projective P.val]\n  (f : P \u27f6 X) [is_quasi_iso f] (g : Y\u2081 \u27f6 Y\u2082) :\n  ((Ext i).obj _).map g \u226b (Ext_iso i P X _ f).hom =\n  (Ext_iso i P X _ f).hom \u226b (preadditive_yoneda.flip.obj (opposite.op P)).map (g\u27e6i\u27e7') :=\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 : \u2124) (X : cochain_complex A \u2124) (Y : bounded_homotopy_category A)\n  [((homotopy_category.quotient A (complex_shape.up \u2124)).obj X).is_bounded_above] :\n  (((Ext (n+1)).flip.obj Y)).obj (opposite.op $ (of' X)\u27e6(1:\u2124)\u27e7) \u2245\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).\u03c0,\n  let e' := Ext_iso (n+1) ((of' X).replace\u27e61\u27e7) ((of' X)\u27e61\u27e7) Y ((of' X).\u03c0\u27e6(1:\u2124)\u27e7'),\n  refine (e' \u226a\u226b _ \u226a\u226b 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 : \u2124)\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 \u226b (((Ext (n+1)).flip.obj W).right_op.map ((of_hom f)\u27e6(1 : \u2124)\u27e7')).unop\n    \u226b (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:\u2124)).obj (of' X).replace)\n    ((shift_functor (bounded_homotopy_category A) (1:\u2124)).obj (of' Y).replace)\n    _ _ _\n    ((shift_functor (bounded_homotopy_category A) 1).map (of' X).\u03c0)\n    ((shift_functor (bounded_homotopy_category A) 1).map (of' Y).\u03c0)\n    _ ((lift ((of' X).\u03c0 \u226b of_hom f) (of' Y).\u03c0)\u27e61\u27e7'),\n    iso.inv_hom_id_assoc],\n  swap,\n  { simp only [comp_neg, neg_comp, neg_inj, \u2190 category_theory.functor.map_comp, lift_lifts], },\n  simp only [\u2190 category.assoc, iso.comp_inv_eq],\n  rw [Ext_map_Ext_iso', category.assoc, category.assoc], congr' 1,\n  rw [\u2190 category.assoc, \u2190 iso.eq_comp_inv],\n  apply AddCommGroup.ext, intros \u03c6,\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 [\u2190 category.assoc, quiver.hom.unop_op, \u2190 category_theory.functor.map_comp],\nend\n\n--attribute [simps] shift_iso_aux\nlemma shift_iso_conj'\n  (n : \u2124)\n  [enough_projectives A]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X)]\n  (W\u2081 W\u2082 : bounded_homotopy_category A) (f : W\u2081 \u27f6 W\u2082) :\n  (shift_iso n X W\u2081).inv \u226b ((Ext (n+1)).obj _).map f \u226b (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 \u2190 iso.eq_inv_comp,\n  simp_rw \u2190 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, \u03bc_hom_inv_app_assoc, functor.map_comp,\n    \u03b5_inv_app_obj, discrete.right_unitor_def, eq_to_iso.hom, eq_to_hom_map,\n    eq_to_hom_app, \u03bc_naturality_assoc, \u03bc_inv_hom_app_assoc],\n  erw \u2190 nat_trans.naturality_assoc,\n  erw \u2190 nat_trans.naturality_assoc,\n  dsimp, let s := _, change _ \u226b _ \u226b s = _, rw \u2190 category.assoc, convert category.comp_id _,\n  dsimp [s], simp,\nend\n\n@[reassoc] lemma shift_iso_Ext_map\n  (n : \u2124)\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)\u27e6(1 : \u2124)\u27e7')).unop \u226b (shift_iso _ _ _).hom =\n  (shift_iso _ _ _).hom \u226b ((Ext n).flip.obj W).map (of_hom f).op :=\nby rw [\u2190 iso.inv_comp_eq, shift_iso_conj]\n\n@[reassoc] lemma Ext_map_shift_iso_inv\n  (n : \u2124)\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 \u226b (((Ext (n+1)).flip.obj W).right_op.map ((of_hom f)\u27e6(1 : \u2124)\u27e7')).unop =\n  ((Ext n).flip.obj W).map (of_hom f).op \u226b (shift_iso _ _ _).inv :=\nby rw [iso.eq_comp_inv, category.assoc, shift_iso_conj]\n\ndef Ext_\u03b4\n  (n : \u2124)\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 : \u2200 i, short_exact (f.f i) (g.f i)) :\n  ((Ext n).flip.obj W).obj (opposite.op $ of' X) \u27f6\n  ((Ext (n+1)).flip.obj W).obj (opposite.op $ of' Z) :=\n(shift_iso n X W).inv \u226b (connecting_hom' f g (n+1) W w).unop\n\n.\n\ndef map_cone {A\u2081 A\u2082 B\u2081 B\u2082 : cochain_complex A \u2124}\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj A\u2081)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj B\u2081)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj A\u2082)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj B\u2082)]\n  (f\u2081 : A\u2081 \u27f6 B\u2081) (f\u2082 : A\u2082 \u27f6 B\u2082) (a : A\u2081 \u27f6 A\u2082) (b : B\u2081 \u27f6 B\u2082) (sq : f\u2081 \u226b b = a \u226b f\u2082) :\n  cone f\u2081 \u27f6 cone f\u2082 :=\n(homotopy_category.quotient _ _).map $\n{ f := \u03bb i, biprod.lift (biprod.fst \u226b a.f _) (biprod.snd \u226b b.f _),\n  comm' := begin\n    rintros i j \u27e8\u27e8rfl\u27e9\u27e9,\n    ext,\n    { dsimp [homological_complex.cone.d], simp },\n    { dsimp [homological_complex.cone.d], simp,\n      simp only [\u2190 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_\u03b4_natural\n  (i : \u2124)\n  [enough_projectives A]\n  (W : bounded_homotopy_category A)\n  {X\u2081 Y\u2081 Z\u2081 : cochain_complex A \u2124} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : Y\u2081 \u27f6 Z\u2081)\n  {X\u2082 Y\u2082 Z\u2082 : cochain_complex A \u2124} (g\u2081 : X\u2082 \u27f6 Y\u2082) (g\u2082 : Y\u2082 \u27f6 Z\u2082)\n  (\u03b1\u2081 : X\u2081 \u27f6 X\u2082) (\u03b1\u2082 : Y\u2081 \u27f6 Y\u2082) (\u03b1\u2083 : Z\u2081 \u27f6 Z\u2082)\n  (sq\u2081 : f\u2081 \u226b \u03b1\u2082 = \u03b1\u2081 \u226b g\u2081) (sq\u2082 : f\u2082 \u226b \u03b1\u2083 = \u03b1\u2082 \u226b g\u2082)\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X\u2081)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y\u2081)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Z\u2081)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj X\u2082)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Y\u2082)]\n  [homotopy_category.is_bounded_above ((homotopy_category.quotient _ _).obj Z\u2082)]\n  (w\u2081 : \u2200 i, short_exact (f\u2081.f i) (f\u2082.f i))\n  (w\u2082 : \u2200 i, short_exact (g\u2081.f i) (g\u2082.f i)) :\n  ((Ext i).flip.obj W).map (of_hom \u03b1\u2081).op \u226b Ext_\u03b4 f\u2081 f\u2082 i W w\u2081 =\n    Ext_\u03b4 g\u2081 g\u2082 i W w\u2082 \u226b ((Ext (i + 1)).flip.obj W).map (of_hom \u03b1\u2083).op :=\nbegin\n  -- TODO: This proof is SLOW.\n  delta Ext_\u03b4,\n  let F := homotopy_category.quotient A (complex_shape.up \u2124),\n  simp only [category.assoc],\n  dsimp only [connecting_hom', unop_comp],\n  simp only [unop_inv, category.assoc],\n  simp only [\u2190 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 _ = _ \u226b _ \u226b t,\n  have ht : t = ((Ext (i+1)).map (quiver.hom.op _)).app W,\n  rotate 2,\n  { apply map_cone,\n    exact sq\u2081 },\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 [\u2190 category.assoc],\n    congr' 1,\n    apply lift_ext (of' Z\u2082).\u03c0, swap, apply_instance,\n    simp only [category.assoc, lift_lifts, lift_lifts_assoc],\n    congr' 1, dsimp [map_cone, cone.\u03c0, homotopy_category.cone.\u03c0],\n    erw [\u2190 F.map_comp, \u2190 F.map_comp], congr' 1,\n    dsimp [homological_complex.cone.\u03c0],\n    ext,\n    { simp },\n    { simp,\n      simp only [\u2190 homological_complex.comp_f, sq\u2082] } },\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 [\u2190 category.assoc], congr' 1,\n  simp only [functor.map_comp, \u2190 category.assoc], congr' 1,\n  simp only [category.assoc],\n  apply lift_ext (((of' X\u2082).\u03c0)\u27e6(1 : \u2124)\u27e7'),\n  swap, apply_instance,\n  simp only [category.assoc, \u2190 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 [\u2190 F.map_comp, \u2190 F.map_comp], congr' 1,\n  dsimp [homological_complex.cone.out],\n  ext,\n  { simp, },\n  { simp, }\nend\n\n.\n\nlemma Ext_\u03b4_natural'\n  (i : \u2124)\n  [enough_projectives A]\n  (W\u2081 W\u2082 : bounded_homotopy_category A)\n  (e : W\u2081 \u27f6 W\u2082)\n  {X Y Z : cochain_complex A \u2124} (f : X \u27f6 Y) (g : Y \u27f6 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 : \u2200 i, short_exact (f.f i) (g.f i)) :\n  ((Ext i).obj _).map e \u226b Ext_\u03b4 f g i W\u2082 w =\n  Ext_\u03b4 f g i W\u2081 w \u226b ((Ext (i+1)).obj _).map e :=\nbegin\n  delta Ext_\u03b4,\n  dsimp [connecting_hom'],\n  simp only [quiver.hom.unop_op, unop_inv],\n  simp_rw \u2190 category.assoc,\n  rw is_iso.comp_inv_eq,\n  simp_rw category.assoc,\n  let t := _, change _ = _ \u226b _ \u226b 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 \u2190 nat_trans.naturality,\n  simp only [\u2190 category.assoc],\n  congr' 1,\n  rw [iso.comp_inv_eq, \u2190 shift_iso_conj', iso.hom_inv_id_assoc],\nend\n\nlemma Ext_five_term_exact_seq'\n  (n : \u2124)\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 : \u2200 i, short_exact (f.f i) (g.f i)) :\n  let E := \u03bb 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_\u03b4 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_\u03b4, functor.right_op_map, quiver.hom.unop_op, \u2190 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_\u03b4, 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 \u27f6 Y) (g : Y \u27f6 Z)\nopen homological_complex\n\ndef cone (f : X \u27f6 Y) : bounded_derived_category A :=\n(localization_functor _).obj $\n{ val := homotopy_category.cone f.val.out,\n  bdd := begin\n    obtain \u27e8a,ha\u27e9 := homotopy_category.is_bounded_above.cond X.val.val,\n    obtain \u27e8b,hb\u27e9 := 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 \u2124) 0).obj X} :=\nbegin\n  refine \u27e8\u27e81, _\u27e9\u27e9,\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 \u2124)).obj\n    ((homological_complex.single A (complex_shape.up \u2124) 0).obj X)).is_bounded_above :=\nsingle_is_bounded_above X\n\ndef Ext'_\u03b4 [enough_projectives A]\n  {X Y Z : A} (W : A) {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (h : short_exact f g) (n : \u2124) :\n  ((Ext' n).flip.obj W).obj (opposite.op $ X) \u27f6\n  ((Ext' (n+1)).flip.obj W).obj (opposite.op $ Z) :=\nbegin\n  refine @bounded_homotopy_category.Ext_\u03b4 _ _ _ _ _ _\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 \u27e8exact_of_zero _ _\u27e9, }\nend\n\nlemma Ext'_\u03b4_natural [enough_projectives A]\n  {X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : A}\n  (f\u2081 : X\u2081 \u27f6 X\u2082) (f\u2082 : X\u2082 \u27f6 X\u2083)\n  (g\u2081 : Y\u2081 \u27f6 Y\u2082) (g\u2082 : Y\u2082 \u27f6 Y\u2083)\n  (\u03b1\u2081 : X\u2081 \u27f6 Y\u2081) (\u03b1\u2082 : X\u2082 \u27f6 Y\u2082) (\u03b1\u2083 : X\u2083 \u27f6 Y\u2083)\n  (sq\u2081 : f\u2081 \u226b \u03b1\u2082 = \u03b1\u2081 \u226b g\u2081) (sq\u2082 : f\u2082 \u226b \u03b1\u2083 = \u03b1\u2082 \u226b g\u2082)\n  (Z : A) (hf : short_exact f\u2081 f\u2082) (hg : short_exact g\u2081 g\u2082) (i : \u2124) :\n  ((Ext' i).flip.obj Z).map \u03b1\u2081.op \u226b Ext'_\u03b4 Z hf i =\n    Ext'_\u03b4 Z hg i \u226b ((Ext' (i+1)).flip.obj Z).map \u03b1\u2083.op :=\nbegin\n  delta Ext' Ext'_\u03b4,\n  apply bounded_homotopy_category.Ext_\u03b4_natural _ _ _ _ _ _ _\n    ((homological_complex.single A (complex_shape.up \u2124) 0).map \u03b1\u2082),\n  all_goals { simp only [\u2190 category_theory.functor.map_comp, sq\u2081, sq\u2082, 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 \u27f6 Y} {g : Y \u27f6 Z}\n  (h : short_exact f g) (n : \u2124) :\n  let E := \u03bb 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'_\u03b4 W h n\n    , (E (n+1)).map g.op ] :=\nbegin\n  let f' := (homological_complex.single _ (complex_shape.up \u2124) (0:\u2124)).map f,\n  let g' := (homological_complex.single _ (complex_shape.up \u2124) (0:\u2124)).map g,\n  let W' := (bounded_homotopy_category.single _ 0).obj W,\n  have Hfg : \u2200 (i : \u2124), 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 \u27e8exact_of_zero _ _\u27e9, } },\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 {\u03b1 : Type u} {n : \u2115} (f : fin n \u2192 \u03b1) (m : \u2115) (h : m \u2264 n) (l : List \u03b1) :\n    length (of_fn_aux f m h l) = length l + m :=\n  sorry\n\n@[simp] theorem length_of_fn {\u03b1 : Type u} {n : \u2115} (f : fin n \u2192 \u03b1) : 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 {\u03b1 : Type u} {n : \u2115} (f : fin n \u2192 \u03b1) (i : \u2115) (m : \u2115) (h : m \u2264 n)\n    (l : List \u03b1) :\n    (\u2200 (i : \u2115), nth l i = of_fn_nth_val f (i + m)) \u2192\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 {\u03b1 : Type u} {n : \u2115} (f : fin n \u2192 \u03b1) (i : \u2115) :\n    nth (of_fn f) i = of_fn_nth_val f i :=\n  sorry\n\ntheorem nth_le_of_fn {\u03b1 : Type u} {n : \u2115} (f : fin n \u2192 \u03b1) (i : fin n) :\n    nth_le (of_fn f) (\u2191i) (Eq.symm (length_of_fn f) \u25b8 subtype.property i) = f i :=\n  sorry\n\n@[simp] theorem nth_le_of_fn' {\u03b1 : Type u} {n : \u2115} (f : fin n \u2192 \u03b1) {i : \u2115}\n    (h : i < length (of_fn f)) :\n    nth_le (of_fn f) i h = f { val := i, property := length_of_fn f \u25b8 h } :=\n  nth_le_of_fn f { val := i, property := length_of_fn f \u25b8 h }\n\n@[simp] theorem map_of_fn {\u03b1 : Type u} {\u03b2 : Type u_1} {n : \u2115} (f : fin n \u2192 \u03b1) (g : \u03b1 \u2192 \u03b2) :\n    map g (of_fn f) = of_fn (g \u2218 f) :=\n  sorry\n\ntheorem array_eq_of_fn {\u03b1 : Type u} {n : \u2115} (a : array n \u03b1) :\n    array.to_list a = of_fn (array.read a) :=\n  sorry\n\n@[simp] theorem of_fn_zero {\u03b1 : Type u} (f : fin 0 \u2192 \u03b1) : of_fn f = [] := rfl\n\n@[simp] theorem of_fn_succ {\u03b1 : Type u} {n : \u2115} (f : fin (Nat.succ n) \u2192 \u03b1) :\n    of_fn f = f 0 :: of_fn fun (i : fin n) => f (fin.succ i) :=\n  sorry\n\ntheorem of_fn_nth_le {\u03b1 : Type u} (l : List \u03b1) :\n    (of_fn fun (i : fin (length l)) => nth_le l (\u2191i) (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 {\u03b1 : Type u} {n : \u2115} (f : fin n \u2192 \u03b1) (a : \u03b1) : a \u2208 of_fn f \u2194 a \u2208 set.range f :=\n  sorry\n\n@[simp] theorem forall_mem_of_fn_iff {\u03b1 : Type u} {n : \u2115} {f : fin n \u2192 \u03b1} {P : \u03b1 \u2192 Prop} :\n    (\u2200 (i : \u03b1), i \u2208 of_fn f \u2192 P i) \u2194 \u2200 (j : fin n), P (f j) :=\n  sorry\n\n@[simp] theorem of_fn_const {\u03b1 : Type u} (n : \u2115) (c : \u03b1) :\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 \" \u2245 \"  => HEq\ntheorem ex1 {\u03b1 : Sort u} {a b : \u03b1} (h : a \u2245 b) : a = b :=\n  match h with\n  | HEq.refl _ => rfl\n\ntheorem ex2 {\u03b1 : Sort u2} {a : \u03b1} {motive : {\u03b2 : Sort u2} \u2192 \u03b2 \u2192 Sort u1} (m : motive a) {\u03b2 : Sort u2} {b : \u03b2} (h : a \u2245 b) : motive b :=\n  match h, m with\n  | HEq.refl _, m => m\n\ntheorem ex3 {\u03b1 : Sort u} {a : \u03b1} {p : \u03b1 \u2192 Sort v} {b : \u03b1} (h\u2081 : a \u2245 b) (h\u2082 : p a) : p b :=\n  match h\u2081, h\u2082 with\n  | HEq.refl _, h\u2082 => h\u2082\n\ntheorem ex4 {\u03b1 \u03b2 : Sort u} {a : \u03b1} {b : \u03b2} (h : a \u2245 b) : b \u2245 a :=\n  match h with\n  | HEq.refl _ => HEq.refl _\n\ntheorem ex5 {\u03b1 : Sort u} {a a' : \u03b1} (h : a = a') : a \u2245 a' :=\n  match h with\n  | rfl => HEq.refl _\n\ntheorem ex6 {\u03b1 \u03b2 : Sort u} (h : \u03b1 = \u03b2) (a : \u03b1) : cast h a \u2245 a :=\n  match h with\n  | rfl => HEq.refl _\n\ntheorem ex7 {\u03b1 \u03b2 \u03c3 : Sort u} {a : \u03b1} {b : \u03b2} {c : \u03c3} (h\u2081 : a \u2245 b) (h\u2082 : b \u2245 c) : a \u2245 c :=\n  match h\u2081, h\u2082 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 \u2243 B) \u2243 (A = B).\n\n  Proof that Type is not a\u00a0set.\n  * HoTT 3.1, example 3.1.9\n-/\n\nnamespace GroundZero\n\nuniverse u v u' v'\n\naxiom J {C : \u03a0 (A B : Type u), A \u2243 B \u2192 Type v}\n  (h : \u03a0 (A : Type u), C A A (ideqv A))\n  {A B : Type u} (e : A \u2243 B) : C A B e\n\nattribute [eliminator] J\n\naxiom J\u03b2rule {C : \u03a0 (A B : Type u), A \u2243 B \u2192 Type v}\n  {h : \u03a0 (A : Type u), C A A (ideqv A)} {A : Type u} :\n  J h (ideqv A) = h A\n\nnoncomputable hott def Jrule (C : \u03a0 (A B : Type u), A \u2243 B \u2192 Type v)\n  (h : \u03a0 (A : Type u), C A A (ideqv A)) {A B : Type u} (e : A \u2243 B) : C A B e :=\nJ h e\n\nnoncomputable hott def ua {A B : Type u} : A \u2243 B \u2192 A = B :=\nJrule (\u03bb A B _, A = B) idp\n\nnamespace ua\n\nnoncomputable hott def reflOnUa (A : Type u) : ua (ideqv A) = idp A :=\nby apply J\u03b2rule\n\nnoncomputable hott def transportRule {A B : Type u} (e : A \u2243 B) (x : A) :\n  transportconst (ua e) x = e x :=\nbegin\n  induction e; transitivity;\n  apply Id.map (transport id \u00b7 x);\n  apply reflOnUa; reflexivity\nend\n\nnoncomputable hott def transportInvRule {A B : Type u} (e : A \u2243 B) (x : B) :\n  transportconst (ua e)\u207b\u00b9 x = e.left x :=\nbegin\n  induction e; transitivity;\n  apply Id.map (transport id \u00b7\u207b\u00b9 x);\n  apply reflOnUa; reflexivity\nend\n\nnoncomputable hott def compRule {A B : Type u} (e : A \u2243 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\u03b2rule {A B : Type u} (e : A \u2243 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\u03b2rule end\n\nnoncomputable hott def univalence (A B : Type u) : (A \u2243 B) \u2243 (A = B) :=\n\u27e8ua, (\u27e8idtoeqv, ua\u03b2rule\u27e9, \u27e8idtoeqv, propUniq\u27e9)\u27e9\n\nnoncomputable hott def propext {A B : Type u}\n  (F : prop A) (G : prop B) : (A \u2194 B) \u2192 A = B :=\n\u03bb h, ua (propEquivLemma F G h.left h.right)\n\nnoncomputable hott def uaTrans {A B \u03b3 : Type u} (p : A \u2243 B) (q : B \u2243 \u03b3) :\n  ua (Equiv.trans p q) = ua p \u2b1d ua q :=\nbegin\n  induction p; induction q; change ua (ideqv _) = _; symmetry;\n  change _ = idp _ \u2b1d _; apply Id.map (\u00b7 \u2b1d ua _); apply reflOnUa\nend\n\nhott def isZero : \u2115 \u2192 \ud835\udfd0\n| Nat.zero   => true\n| Nat.succ _ => false\n\nexample (h : 0 = 1) : \ud835\udfce :=\nffNeqTt (Id.map isZero h)\u207b\u00b9\n\nhott def succNeqZero {n : \u2115} : \u00ac(Nat.succ n = 0) :=\n\u03bb h, ffNeqTt (Id.map isZero h)\n\nhott def negNeg : \u03a0 x, not (not x) = x\n| true  => idp true\n| false => idp false\n\nhott def negBoolEquiv : \ud835\udfd0 \u2243 \ud835\udfd0 :=\n\u27e8not, (\u27e8not, negNeg\u27e9, \u27e8not, negNeg\u27e9)\u27e9\n\nnoncomputable hott def universeNotASet : \u00ac(hset Type) :=\nbegin\n  let p : \ud835\udfd0 = \ud835\udfd0 := ua negBoolEquiv; let h := transportconst p true;\n  let g : h = false := transportRule negBoolEquiv true;\n  intro \u03b5; let f : h = true := Id.map (transportconst \u00b7 true) (\u03b5 _ _ p (idp \ud835\udfd0));\n  apply ffNeqTt; exact g\u207b\u00b9 \u2b1d 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))\u207b\u00b9 (f _ _)\n| Coproduct.inl x, Coproduct.inr y =>\n  transport prop (ua (@Coproduct.inl.inlInr A B x y))\u207b\u00b9 emptyIsProp\n| Coproduct.inr x, Coproduct.inl y =>\n  transport prop (ua (@Coproduct.inr.inrInl A B x y))\u207b\u00b9 emptyIsProp\n| Coproduct.inr x, Coproduct.inr y =>\n  transport prop (ua (@Coproduct.inr.inj' A B x y))\u207b\u00b9 (g _ _)\n\n-- exercise 2.17 (i) in HoTT book\nnoncomputable hott def productEquiv\u2081 {A A' B B' : Type u}\n  (e\u2081 : A \u2243 A') (e\u2082 : B \u2243 B') : (A \u00d7 B) \u2243 (A' \u00d7 B') :=\nbegin\n  have p := ua e\u2081; have q := ua e\u2082;\n  induction p; induction q; apply ideqv\nend\n\nnoncomputable hott def productEquiv\u2082 {A A' B B' : Type u}\n  (e\u2081 : A \u2243 A') (e\u2082 : B \u2243 B') : (A \u00d7 B) \u2243 (A' \u00d7 B') :=\nbegin induction e\u2081; induction e\u2082; 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\u2083 (e\u2081 : A \u2243 A') (e\u2082 : B \u2243 B') : (A \u00d7 B) \u2243 (A' \u00d7 B') :=\n  prodEquiv e\u2081 e\u2082\nend\n\nsection\n  variable {C : \ud835\udfd0 \u2192 Type u}\n\n  hott def familyOnBool.sec (w : C false \u00d7 C true) : \u03a0 b, C b\n  | false => w.1\n  | true  => w.2\n\n  hott def familyOnBool.ret (\u03c6 : \u03a0 b, C b) : C false \u00d7 C true :=\n  (\u03c6 false, \u03c6 true)\n\n  hott def familyOnBool : (C false \u00d7 C true) \u2243 \u03a0 b, C b :=\n  begin\n    existsi familyOnBool.sec; apply Qinv.toBiinv;\n    existsi familyOnBool.ret; apply Prod.mk;\n    { intro \u03c6; 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 \u2964 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 \u2964 D) :=\n{ hom_group := \u03bb F G,\n  { add := \u03bb \u03b1 \u03b2,\n    { app := \u03bb X, \u03b1.app X + \u03b2.app X,\n      naturality' := by { intros, rw [comp_add, add_comp, \u03b1.naturality, \u03b2.naturality] } },\n    zero := { app := \u03bb X, 0, naturality' := by { intros, rw [zero_comp, comp_zero] } },\n    neg := \u03bb \u03b1,\n    { app := \u03bb X, -\u03b1.app X,\n      naturality' := by { intros, rw [comp_neg, neg_comp, \u03b1.naturality] } },\n    sub := \u03bb \u03b1 \u03b2,\n    { app := \u03bb X, \u03b1.app X - \u03b2.app X,\n      naturality' := by { intros, rw [comp_sub, sub_comp, \u03b1.naturality, \u03b2.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 \u2964 D}\n\n/-- Application of a natural transformation at a fixed object,\nas group homomorphism -/\n@[simps] def app_hom (X : C) : (F \u27f6 G) \u2192+ (F.obj X \u27f6 G.obj X) :=\n{ to_fun := \u03bb \u03b1, \u03b1.app X,\n  map_zero' := rfl,\n  map_add' := \u03bb _ _, rfl }\n\n@[simp] lemma app_zero (X : C) : (0 : F \u27f6 G).app X = 0 := rfl\n\n@[simp] lemma app_add (X : C) (\u03b1 \u03b2 : F \u27f6 G) : (\u03b1 + \u03b2).app X = \u03b1.app X + \u03b2.app X := rfl\n\n@[simp] lemma app_sub (X : C) (\u03b1 \u03b2 : F \u27f6 G) : (\u03b1 - \u03b2).app X = \u03b1.app X - \u03b2.app X := rfl\n\n@[simp] lemma app_neg (X : C) (\u03b1 : F \u27f6 G) : (-\u03b1).app X = -\u03b1.app X := rfl\n\n@[simp] lemma app_nsmul (X : C) (\u03b1 : F \u27f6 G) (n : \u2115) : (n \u2022 \u03b1).app X = n \u2022 \u03b1.app X :=\n(app_hom X).map_nsmul \u03b1 n\n\n@[simp] lemma app_zsmul (X : C) (\u03b1 : F \u27f6 G) (n : \u2124) : (n \u2022 \u03b1).app X = n \u2022 \u03b1.app X :=\n(app_hom X : (F \u27f6 G) \u2192+ (F.obj X \u27f6 G.obj X)).map_zsmul \u03b1 n\n\n@[simp] lemma app_sum {\u03b9 : Type*} (s : finset \u03b9) (X : C) (\u03b1 : \u03b9 \u2192 (F \u27f6 G)) :\n  (\u2211 i in s, \u03b1 i).app X = \u2211 i in s, ((\u03b1 i).app X) :=\nby { rw [\u2190 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) => \u2200 (z : R), z * x = 0 \u2192 z = 0) sorry sorry\n\ntheorem mul_mem_non_zero_divisors {R : Type u_1} [comm_ring R] {a : R} {b : R} : a * b \u2208 non_zero_divisors R \u2194 a \u2208 non_zero_divisors R \u2227 b \u2208 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 \u2260 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 \u2260 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 \u2208 non_zero_divisors A \u2194 x \u2260 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 \u2192+* B} (hg : function.injective \u21d1g) {x : \u21a5(non_zero_divisors R)} : coe_fn g \u2191x \u2260 0 :=\n  fun (h0 : coe_fn g \u2191x = 0) =>\n    one_ne_zero (subtype.property x 1 (Eq.symm (one_mul (subtype.val x)) \u25b8 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 \u2192+* B} (hg : function.injective \u21d1g) {x : \u21a5(non_zero_divisors A)} : coe_fn g \u2191x \u2208 non_zero_divisors B :=\n  fun (z : B) (hz : z * coe_fn g \u2191x = 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 : \u00ac\u21910 \u2208 M) : M \u2264 non_zero_divisors A :=\n  fun (x : A) (hx : x \u2208 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 \u25b8 hx) hM\n\ntheorem powers_le_non_zero_divisors_of_domain {A : Type u_2} [integral_domain A] {a : A} (ha : a \u2260 0) : submonoid.powers a \u2264 non_zero_divisors A :=\n  le_non_zero_divisors_of_domain\n    fun (h : \u21910 \u2208 submonoid.powers a) => absurd (Exists.rec_on h fun (_x : \u2115) (hn : a ^ _x = \u21910) => 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 \u2192+* B} (hf : function.injective \u21d1f) {M : submonoid A} (hM : M \u2264 non_zero_divisors A) : submonoid.map (\u2191f) M \u2264 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 \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P`, where `M` and `N`\nare modules over `R` and `S` respectively, `P` is a module over both `R\u2082` and `S\u2082` with\ncommuting actions, and `\u03c1\u2081\u2082 : R \u2192+* R\u2082` and `\u03c3\u2081\u2082 : S \u2192+* S\u2082`.\n\n## Main declarations\n\n* `linear_map.mk\u2082`: 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 \u00d7 N \u2192 P` into `N \u00d7 M \u2192 P`\n* `linear_map.lcomp` and `linear_map.llcomp`: composition of linear maps as a bilinear map\n* `linear_map.compl\u2082`: composition of a bilinear map `M \u00d7 N \u2192 P` with a linear map `Q \u2192 M`\n* `linear_map.compr\u2082`: composition of a bilinear map `M \u00d7 N \u2192 P` with a linear map `Q \u2192 N`\n* `linear_map.lsmul`: scalar multiplication as a bilinear map `R \u00d7 M \u2192 M`\n\n## Tags\n\nbilinear\n-/\n\n\nnamespace LinearMap\n\nsection Semiring\n\n-- the `\u2097` 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\u2082 : Type _} [Semiring R\u2082] {S\u2082 : Type _} [Semiring S\u2082]\n\nvariable {M : Type _} {N : Type _} {P : Type _}\n\nvariable {M\u2082 : Type _} {N\u2082 : Type _} {P\u2082 : Type _}\n\nvariable {N\u2097 : Type _} {P\u2097 : Type _}\n\nvariable {M' : Type _} {N' : Type _} {P' : Type _}\n\nvariable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P]\n\nvariable [AddCommMonoid M\u2082] [AddCommMonoid N\u2082] [AddCommMonoid P\u2082]\n\nvariable [AddCommMonoid N\u2097] [AddCommMonoid P\u2097]\n\nvariable [AddCommGroup M'] [AddCommGroup N'] [AddCommGroup P']\n\nvariable [Module R M] [Module S N] [Module R\u2082 P] [Module S\u2082 P]\n\nvariable [Module R M\u2082] [Module S N\u2082] [Module R P\u2082] [Module S\u2082 P\u2082]\n\nvariable [Module R P\u2097] [Module S P\u2097]\n\nvariable [Module R M'] [Module S N'] [Module R\u2082 P'] [Module S\u2082 P']\n\nvariable [SMulCommClass S\u2082 R\u2082 P] [SMulCommClass S R P\u2097] [SMulCommClass S\u2082 R\u2082 P']\n\nvariable [SMulCommClass S\u2082 R P\u2082]\n\nvariable {\u03c1\u2081\u2082 : R \u2192+* R\u2082} {\u03c3\u2081\u2082 : S \u2192+* S\u2082}\n\nvariable (\u03c1\u2081\u2082 \u03c3\u2081\u2082)\n\n/- warning: linear_map.mk\u2082'\u209b\u2097 -> LinearMap.mk\u2082'\u209b\u2097 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] (\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) (\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) (f : M -> N -> P), (forall (m\u2081 : M) (m\u2082 : 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\u2081 m\u2082) 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\u2081 n) (f m\u2082 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\u2082 P (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18)))) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) (fun (_x : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) => R -> R\u2082) (RingHom.hasCoeToFun.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) \u03c1\u2081\u2082 c) (f m n))) -> (forall (m : M) (n\u2081 : N) (n\u2082 : 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\u2081 n\u2082)) (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\u2081) (f m n\u2082))) -> (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\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (coeFn.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) (fun (_x : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) => S -> S\u2082) (RingHom.hasCoeToFun.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) \u03c3\u2081\u2082 c) (f m n))) -> (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u4, u7} S\u2082 P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u4, u7} S\u2082 P (MonoidWithZero.toZero.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u3, u7} R\u2082 P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u3, u7} R\u2082 P (MonoidWithZero.toZero.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] (\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) (\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) (f : M -> N -> P), (forall (m\u2081 : M) (m\u2082 : 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\u2081 m\u2082) 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\u2081 n) (f m\u2082 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\u2082) c) P P (instHSMul.{u3, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) c) P (SMulZeroClass.toSMul.{u3, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) 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\u2082) c) P (MonoidWithZero.toZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) c) (Semiring.toMonoidWithZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) 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\u2082) c) P (Semiring.toMonoidWithZero.{u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) 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\u2082) c) P _inst_3 _inst_7 _inst_18))))) (FunLike.coe.{max (succ u1) (succ u3), succ u1, succ u3} (RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) _x) (MulHomClass.toFunLike.{max u1 u3, u1, u3} (RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) R R\u2082 (NonUnitalNonAssocSemiring.toMul.{u1} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u3} R\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R\u2082 (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) R R\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} R\u2082 (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u1 u3, u1, u3} (RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3) (RingHom.instRingHomClassRingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3))))) \u03c1\u2081\u2082 c) (f m n))) -> (forall (m : M) (n\u2081 : N) (n\u2082 : 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\u2081 n\u2082)) (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\u2081) (f m n\u2082))) -> (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\u2082) c) P P (instHSMul.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) c) P (SMulZeroClass.toSMul.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) 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\u2082) c) P (MonoidWithZero.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) c) (Semiring.toMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) 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\u2082) c) P (Semiring.toMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) 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\u2082) c) P _inst_4 _inst_7 _inst_19))))) (FunLike.coe.{max (succ u2) (succ u4), succ u2, succ u4} (RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) _x) (MulHomClass.toFunLike.{max u2 u4, u2, u4} (RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) S S\u2082 (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u4} S\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S\u2082 (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u4, u2, u4} (RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) S S\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} S\u2082 (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u4, u2, u4} (RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4) (RingHom.instRingHomClassRingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4))))) \u03c3\u2081\u2082 c) (f m n))) -> (LinearMap.{u1, u3, u5, max u7 u6} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30))\nCase conversion may be inaccurate. Consider using '#align linear_map.mk\u2082'\u209b\u2097 LinearMap.mk\u2082'\u209b\u2097\u2093'. -/\n/-- Create a bilinear map from a function that is semilinear in each component.\nSee `mk\u2082'` and `mk\u2082` for the linear case. -/\ndef mk\u2082'\u209b\u2097 (f : M \u2192 N \u2192 P) (H1 : \u2200 m\u2081 m\u2082 n, f (m\u2081 + m\u2082) n = f m\u2081 n + f m\u2082 n)\n    (H2 : \u2200 (c : R) (m n), f (c \u2022 m) n = \u03c1\u2081\u2082 c \u2022 f m n)\n    (H3 : \u2200 m n\u2081 n\u2082, f m (n\u2081 + n\u2082) = f m n\u2081 + f m n\u2082)\n    (H4 : \u2200 (c : S) (m n), f m (c \u2022 n) = \u03c3\u2081\u2082 c \u2022 f m n) : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] 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\u2081 m\u2082 := LinearMap.ext <| H1 m\u2081 m\u2082\n  map_smul' c m := LinearMap.ext <| H2 c m\n#align linear_map.mk\u2082'\u209b\u2097 LinearMap.mk\u2082'\u209b\u2097\n\nvariable {\u03c1\u2081\u2082 \u03c3\u2081\u2082}\n\n/- warning: linear_map.mk\u2082'\u209b\u2097_apply -> LinearMap.mk\u2082'\u209b\u2097_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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : M -> N -> P) {H1 : forall (m\u2081 : M) (m\u2082 : 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\u2081 m\u2082) 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\u2081 n) (f m\u2082 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\u2082 P (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18)))) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) (fun (_x : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) => R -> R\u2082) (RingHom.hasCoeToFun.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) \u03c1\u2081\u2082 c) (f m n))} {H3 : forall (m : M) (n\u2081 : N) (n\u2082 : 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\u2081 n\u2082)) (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\u2081) (f m n\u2082))} {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\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (coeFn.{max (succ u2) (succ u4), max (succ u2) (succ u4)} (RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) (fun (_x : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) => S -> S\u2082) (RingHom.hasCoeToFun.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)) \u03c3\u2081\u2082 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) (LinearMap.mk\u2082'\u209b\u2097.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 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\u2082 : Type.{u4}} [_inst_3 : Semiring.{u4} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u4, u7} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u7} S\u2082 P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u7} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u7} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u1, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u4, u7} R\u2082 P (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u4, u7} R\u2082 P (MonoidWithZero.toZero.{u4} R\u2082 (Semiring.toMonoidWithZero.{u4} R\u2082 _inst_3)) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u4, u7} R\u2082 P (Semiring.toMonoidWithZero.{u4} R\u2082 _inst_3) (AddMonoid.toZero.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7)) (Module.toMulActionWithZero.{u4, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u5, u4} R R\u2082 (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : M -> N -> P) {H1 : forall (m\u2081 : M) (m\u2082 : 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\u2081 m\u2082) 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\u2081 n) (f m\u2082 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\u2082) c) P P (instHSMul.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) c) P (SMulZeroClass.toSMul.{u4, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) 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\u2082) c) P (MonoidWithZero.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) c) (Semiring.toMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) 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\u2082) c) P (Semiring.toMonoidWithZero.{u4} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) 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\u2082) c) P _inst_3 _inst_7 _inst_18))))) (FunLike.coe.{max (succ u5) (succ u4), succ u5, succ u4} (RingHom.{u5, u4} R R\u2082 (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) _x) (MulHomClass.toFunLike.{max u5 u4, u5, u4} (RingHom.{u5, u4} R R\u2082 (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3)) R R\u2082 (NonUnitalNonAssocSemiring.toMul.{u5} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} R (Semiring.toNonAssocSemiring.{u5} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u4} R\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} R\u2082 (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u5 u4, u5, u4} (RingHom.{u5, u4} R R\u2082 (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3)) R R\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u5} R (Semiring.toNonAssocSemiring.{u5} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u4} R\u2082 (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u5 u4, u5, u4} (RingHom.{u5, u4} R R\u2082 (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3)) R R\u2082 (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3) (RingHom.instRingHomClassRingHom.{u5, u4} R R\u2082 (Semiring.toNonAssocSemiring.{u5} R _inst_1) (Semiring.toNonAssocSemiring.{u4} R\u2082 _inst_3))))) \u03c1\u2081\u2082 c) (f m n))} {H3 : forall (m : M) (n\u2081 : N) (n\u2082 : 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\u2081 n\u2082)) (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\u2081) (f m n\u2082))} {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\u2082) c) P P (instHSMul.{u1, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) c) P (SMulZeroClass.toSMul.{u1, u7} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) 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\u2082) c) P (MonoidWithZero.toZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) c) (Semiring.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) 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\u2082) c) P (Semiring.toMonoidWithZero.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) 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\u2082) c) P _inst_4 _inst_7 _inst_19))))) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)) S (fun (_x : S) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : S) => S\u2082) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)) S S\u2082 (NonUnitalNonAssocSemiring.toMul.{u2} S (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2))) (NonUnitalNonAssocSemiring.toMul.{u1} S\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S\u2082 (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)) S S\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} S (Semiring.toNonAssocSemiring.{u2} S _inst_2)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} S\u2082 (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)) S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4) (RingHom.instRingHomClassRingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4))))) \u03c3\u2081\u2082 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u4, u3, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u5, u4, u6, max u3 u7} R R\u2082 M (LinearMap.{u2, u1, u3, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u4, u3, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) (LinearMap.mk\u2082'\u209b\u2097.{u5, u2, u4, u1, u6, u3, u7} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 f H1 H2 H3 H4) m) n) (f m n)\nCase conversion may be inaccurate. Consider using '#align linear_map.mk\u2082'\u209b\u2097_apply LinearMap.mk\u2082'\u209b\u2097_apply\u2093'. -/\n@[simp]\ntheorem mk\u2082'\u209b\u2097_apply (f : M \u2192 N \u2192 P) {H1 H2 H3 H4} (m : M) (n : N) :\n    (mk\u2082'\u209b\u2097 \u03c1\u2081\u2082 \u03c3\u2081\u2082 f H1 H2 H3 H4 : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) m n = f m n :=\n  rfl\n#align linear_map.mk\u2082'\u209b\u2097_apply LinearMap.mk\u2082'\u209b\u2097_apply\n\nvariable (R S)\n\n/- warning: linear_map.mk\u2082' -> LinearMap.mk\u2082' 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\u2097 : Type.{u5}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_6 : AddCommMonoid.{u4} N] [_inst_12 : AddCommMonoid.{u5} P\u2097] [_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\u2097 _inst_1 _inst_12] [_inst_25 : Module.{u2, u5} S P\u2097 _inst_2 _inst_12] [_inst_31 : SMulCommClass.{u2, u1, u5} S R P\u2097 (SMulZeroClass.toHasSmul.{u2, u5} S P\u2097 (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (SMulWithZero.toSmulZeroClass.{u2, u5} S P\u2097 (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (MulActionWithZero.toSMulWithZero.{u2, u5} S P\u2097 (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (Module.toMulActionWithZero.{u2, u5} S P\u2097 _inst_2 _inst_12 _inst_25)))) (SMulZeroClass.toHasSmul.{u1, u5} R P\u2097 (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (SMulWithZero.toSmulZeroClass.{u1, u5} R P\u2097 (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (MulActionWithZero.toSMulWithZero.{u1, u5} R P\u2097 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (Module.toMulActionWithZero.{u1, u5} R P\u2097 _inst_1 _inst_12 _inst_24))))] (f : M -> N -> P\u2097), (forall (m\u2081 : M) (m\u2082 : M) (n : N), Eq.{succ u5} P\u2097 (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\u2081 m\u2082) n) (HAdd.hAdd.{u5, u5, u5} P\u2097 P\u2097 P\u2097 (instHAdd.{u5} P\u2097 (AddZeroClass.toHasAdd.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)))) (f m\u2081 n) (f m\u2082 n))) -> (forall (c : R) (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 (SMulZeroClass.toHasSmul.{u1, u5} R P\u2097 (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (SMulWithZero.toSmulZeroClass.{u1, u5} R P\u2097 (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (MulActionWithZero.toSMulWithZero.{u1, u5} R P\u2097 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (Module.toMulActionWithZero.{u1, u5} R P\u2097 _inst_1 _inst_12 _inst_24)))) c (f m n))) -> (forall (m : M) (n\u2081 : N) (n\u2082 : N), Eq.{succ u5} P\u2097 (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\u2081 n\u2082)) (HAdd.hAdd.{u5, u5, u5} P\u2097 P\u2097 P\u2097 (instHAdd.{u5} P\u2097 (AddZeroClass.toHasAdd.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)))) (f m n\u2081) (f m n\u2082))) -> (forall (c : S) (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 (SMulZeroClass.toHasSmul.{u2, u5} S P\u2097 (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (SMulWithZero.toSmulZeroClass.{u2, u5} S P\u2097 (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (MulActionWithZero.toSMulWithZero.{u2, u5} S P\u2097 (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (Module.toMulActionWithZero.{u2, u5} S P\u2097 _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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N P\u2097 _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\u2097 _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\u2097 : Type.{u5}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_6 : AddCommMonoid.{u4} N] [_inst_12 : AddCommMonoid.{u5} P\u2097] [_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\u2097 _inst_1 _inst_12] [_inst_25 : Module.{u2, u5} S P\u2097 _inst_2 _inst_12] [_inst_31 : SMulCommClass.{u2, u1, u5} S R P\u2097 (SMulZeroClass.toSMul.{u2, u5} S P\u2097 (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (SMulWithZero.toSMulZeroClass.{u2, u5} S P\u2097 (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (MulActionWithZero.toSMulWithZero.{u2, u5} S P\u2097 (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (Module.toMulActionWithZero.{u2, u5} S P\u2097 _inst_2 _inst_12 _inst_25)))) (SMulZeroClass.toSMul.{u1, u5} R P\u2097 (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (SMulWithZero.toSMulZeroClass.{u1, u5} R P\u2097 (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (MulActionWithZero.toSMulWithZero.{u1, u5} R P\u2097 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (Module.toMulActionWithZero.{u1, u5} R P\u2097 _inst_1 _inst_12 _inst_24))))] (f : M -> N -> P\u2097), (forall (m\u2081 : M) (m\u2082 : M) (n : N), Eq.{succ u5} P\u2097 (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\u2081 m\u2082) n) (HAdd.hAdd.{u5, u5, u5} P\u2097 P\u2097 P\u2097 (instHAdd.{u5} P\u2097 (AddZeroClass.toAdd.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)))) (f m\u2081 n) (f m\u2082 n))) -> (forall (c : R) (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 P\u2097 (instHSMul.{u1, u5} R P\u2097 (SMulZeroClass.toSMul.{u1, u5} R P\u2097 (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (SMulWithZero.toSMulZeroClass.{u1, u5} R P\u2097 (MonoidWithZero.toZero.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (MulActionWithZero.toSMulWithZero.{u1, u5} R P\u2097 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (Module.toMulActionWithZero.{u1, u5} R P\u2097 _inst_1 _inst_12 _inst_24))))) c (f m n))) -> (forall (m : M) (n\u2081 : N) (n\u2082 : N), Eq.{succ u5} P\u2097 (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\u2081 n\u2082)) (HAdd.hAdd.{u5, u5, u5} P\u2097 P\u2097 P\u2097 (instHAdd.{u5} P\u2097 (AddZeroClass.toAdd.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)))) (f m n\u2081) (f m n\u2082))) -> (forall (c : S) (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 P\u2097 (instHSMul.{u2, u5} S P\u2097 (SMulZeroClass.toSMul.{u2, u5} S P\u2097 (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (SMulWithZero.toSMulZeroClass.{u2, u5} S P\u2097 (MonoidWithZero.toZero.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (MulActionWithZero.toSMulWithZero.{u2, u5} S P\u2097 (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (Module.toMulActionWithZero.{u2, u5} S P\u2097 _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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N P\u2097 _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\u2097 _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\u2082' LinearMap.mk\u2082'\u2093'. -/\n/-- Create a bilinear map from a function that is linear in each component.\nSee `mk\u2082` for the special case where both arguments come from modules over the same ring. -/\ndef mk\u2082' (f : M \u2192 N \u2192 P\u2097) (H1 : \u2200 m\u2081 m\u2082 n, f (m\u2081 + m\u2082) n = f m\u2081 n + f m\u2082 n)\n    (H2 : \u2200 (c : R) (m n), f (c \u2022 m) n = c \u2022 f m n)\n    (H3 : \u2200 m n\u2081 n\u2082, f m (n\u2081 + n\u2082) = f m n\u2081 + f m n\u2082)\n    (H4 : \u2200 (c : S) (m n), f m (c \u2022 n) = c \u2022 f m n) : M \u2192\u2097[R] N \u2192\u2097[S] P\u2097 :=\n  mk\u2082'\u209b\u2097 (RingHom.id R) (RingHom.id S) f H1 H2 H3 H4\n#align linear_map.mk\u2082' LinearMap.mk\u2082'\n\nvariable {R S}\n\n/- warning: linear_map.mk\u2082'_apply -> LinearMap.mk\u2082'_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\u2097 : Type.{u5}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_6 : AddCommMonoid.{u4} N] [_inst_12 : AddCommMonoid.{u5} P\u2097] [_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\u2097 _inst_1 _inst_12] [_inst_25 : Module.{u2, u5} S P\u2097 _inst_2 _inst_12] [_inst_31 : SMulCommClass.{u2, u1, u5} S R P\u2097 (SMulZeroClass.toHasSmul.{u2, u5} S P\u2097 (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (SMulWithZero.toSmulZeroClass.{u2, u5} S P\u2097 (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (MulActionWithZero.toSMulWithZero.{u2, u5} S P\u2097 (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (Module.toMulActionWithZero.{u2, u5} S P\u2097 _inst_2 _inst_12 _inst_25)))) (SMulZeroClass.toHasSmul.{u1, u5} R P\u2097 (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (SMulWithZero.toSmulZeroClass.{u1, u5} R P\u2097 (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (MulActionWithZero.toSMulWithZero.{u1, u5} R P\u2097 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (Module.toMulActionWithZero.{u1, u5} R P\u2097 _inst_1 _inst_12 _inst_24))))] (f : M -> N -> P\u2097) {H1 : forall (m\u2081 : M) (m\u2082 : M) (n : N), Eq.{succ u5} P\u2097 (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\u2081 m\u2082) n) (HAdd.hAdd.{u5, u5, u5} P\u2097 P\u2097 P\u2097 (instHAdd.{u5} P\u2097 (AddZeroClass.toHasAdd.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)))) (f m\u2081 n) (f m\u2082 n))} {H2 : forall (c : R) (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 (SMulZeroClass.toHasSmul.{u1, u5} R P\u2097 (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (SMulWithZero.toSmulZeroClass.{u1, u5} R P\u2097 (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (MulActionWithZero.toSMulWithZero.{u1, u5} R P\u2097 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (Module.toMulActionWithZero.{u1, u5} R P\u2097 _inst_1 _inst_12 _inst_24)))) c (f m n))} {H3 : forall (m : M) (n\u2081 : N) (n\u2082 : N), Eq.{succ u5} P\u2097 (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\u2081 n\u2082)) (HAdd.hAdd.{u5, u5, u5} P\u2097 P\u2097 P\u2097 (instHAdd.{u5} P\u2097 (AddZeroClass.toHasAdd.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)))) (f m n\u2081) (f m n\u2082))} {H4 : forall (c : S) (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 (SMulZeroClass.toHasSmul.{u2, u5} S P\u2097 (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (SMulWithZero.toSmulZeroClass.{u2, u5} S P\u2097 (MulZeroClass.toHasZero.{u2} S (MulZeroOneClass.toMulZeroClass.{u2} S (MonoidWithZero.toMulZeroOneClass.{u2} S (Semiring.toMonoidWithZero.{u2} S _inst_2)))) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (MulActionWithZero.toSMulWithZero.{u2, u5} S P\u2097 (Semiring.toMonoidWithZero.{u2} S _inst_2) (AddZeroClass.toHasZero.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12))) (Module.toMulActionWithZero.{u2, u5} S P\u2097 _inst_2 _inst_12 _inst_25)))) c (f m n))} (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 _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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) => N -> P\u2097) (LinearMap.hasCoeToFun.{u2, u2, u4, u5} S S N P\u2097 _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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N P\u2097 _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\u2097 _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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N P\u2097 _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\u2097 _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\u2097 _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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) _inst_1 _inst_1 _inst_5 (LinearMap.addCommMonoid.{u2, u2, u4, u5} S S N P\u2097 _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\u2097 _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\u2082'.{u1, u2, u3, u4, u5} R _inst_1 S _inst_2 M N P\u2097 _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\u2097 : Type.{u5}} [_inst_5 : AddCommMonoid.{u4} M] [_inst_6 : AddCommMonoid.{u2} N] [_inst_12 : AddCommMonoid.{u5} P\u2097] [_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\u2097 _inst_1 _inst_12] [_inst_25 : Module.{u1, u5} S P\u2097 _inst_2 _inst_12] [_inst_31 : SMulCommClass.{u1, u3, u5} S R P\u2097 (SMulZeroClass.toSMul.{u1, u5} S P\u2097 (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (SMulWithZero.toSMulZeroClass.{u1, u5} S P\u2097 (MonoidWithZero.toZero.{u1} S (Semiring.toMonoidWithZero.{u1} S _inst_2)) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (MulActionWithZero.toSMulWithZero.{u1, u5} S P\u2097 (Semiring.toMonoidWithZero.{u1} S _inst_2) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (Module.toMulActionWithZero.{u1, u5} S P\u2097 _inst_2 _inst_12 _inst_25)))) (SMulZeroClass.toSMul.{u3, u5} R P\u2097 (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (SMulWithZero.toSMulZeroClass.{u3, u5} R P\u2097 (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R _inst_1)) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (MulActionWithZero.toSMulWithZero.{u3, u5} R P\u2097 (Semiring.toMonoidWithZero.{u3} R _inst_1) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (Module.toMulActionWithZero.{u3, u5} R P\u2097 _inst_1 _inst_12 _inst_24))))] (f : M -> N -> P\u2097) {H1 : forall (m\u2081 : M) (m\u2082 : M) (n : N), Eq.{succ u5} P\u2097 (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\u2081 m\u2082) n) (HAdd.hAdd.{u5, u5, u5} P\u2097 P\u2097 P\u2097 (instHAdd.{u5} P\u2097 (AddZeroClass.toAdd.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)))) (f m\u2081 n) (f m\u2082 n))} {H2 : forall (c : R) (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 P\u2097 (instHSMul.{u3, u5} R P\u2097 (SMulZeroClass.toSMul.{u3, u5} R P\u2097 (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (SMulWithZero.toSMulZeroClass.{u3, u5} R P\u2097 (MonoidWithZero.toZero.{u3} R (Semiring.toMonoidWithZero.{u3} R _inst_1)) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (MulActionWithZero.toSMulWithZero.{u3, u5} R P\u2097 (Semiring.toMonoidWithZero.{u3} R _inst_1) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (Module.toMulActionWithZero.{u3, u5} R P\u2097 _inst_1 _inst_12 _inst_24))))) c (f m n))} {H3 : forall (m : M) (n\u2081 : N) (n\u2082 : N), Eq.{succ u5} P\u2097 (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\u2081 n\u2082)) (HAdd.hAdd.{u5, u5, u5} P\u2097 P\u2097 P\u2097 (instHAdd.{u5} P\u2097 (AddZeroClass.toAdd.{u5} P\u2097 (AddMonoid.toAddZeroClass.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)))) (f m n\u2081) (f m n\u2082))} {H4 : forall (c : S) (m : M) (n : N), Eq.{succ u5} P\u2097 (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\u2097 P\u2097 (instHSMul.{u1, u5} S P\u2097 (SMulZeroClass.toSMul.{u1, u5} S P\u2097 (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (SMulWithZero.toSMulZeroClass.{u1, u5} S P\u2097 (MonoidWithZero.toZero.{u1} S (Semiring.toMonoidWithZero.{u1} S _inst_2)) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (MulActionWithZero.toSMulWithZero.{u1, u5} S P\u2097 (Semiring.toMonoidWithZero.{u1} S _inst_2) (AddMonoid.toZero.{u5} P\u2097 (AddCommMonoid.toAddMonoid.{u5} P\u2097 _inst_12)) (Module.toMulActionWithZero.{u1, u5} S P\u2097 _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\u2097) 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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) m) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u1, u1, u2, u5} S S N P\u2097 _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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u2, u5} S S N P\u2097 _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\u2097 _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\u2097 _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\u2097 _inst_6 _inst_12 _inst_17 _inst_25) _inst_1 _inst_1 _inst_5 (LinearMap.addCommMonoid.{u1, u1, u2, u5} S S N P\u2097 _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\u2097 _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\u2082'.{u3, u1, u4, u2, u5} R _inst_1 S _inst_2 M N P\u2097 _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\u2082'_apply LinearMap.mk\u2082'_apply\u2093'. -/\n@[simp]\ntheorem mk\u2082'_apply (f : M \u2192 N \u2192 P\u2097) {H1 H2 H3 H4} (m : M) (n : N) :\n    (mk\u2082' R S f H1 H2 H3 H4 : M \u2192\u2097[R] N \u2192\u2097[S] P\u2097) m n = f m n :=\n  rfl\n#align linear_map.mk\u2082'_apply LinearMap.mk\u2082'_apply\n\n/- warning: linear_map.ext\u2082 -> LinearMap.ext\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} {f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f m) n) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) g m) n)) -> (Eq.{max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} {f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) g m) n)) -> (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) f g)\nCase conversion may be inaccurate. Consider using '#align linear_map.ext\u2082 LinearMap.ext\u2082\u2093'. -/\ntheorem ext\u2082 {f g : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P} (H : \u2200 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\u2082 LinearMap.ext\u2082\n\n/- warning: linear_map.congr_fun\u2082 -> LinearMap.congr_fun\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} {f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)}, (Eq.{max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f x) y) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} {f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)}, (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) g x) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.congr_fun\u2082 LinearMap.congr_fun\u2082\u2093'. -/\ntheorem congr_fun\u2082 {f g : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] 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\u2082 LinearMap.congr_fun\u2082\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 \u00d7 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 \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) : N \u2192\u209b\u2097[\u03c3\u2081\u2082] M \u2192\u209b\u2097[\u03c1\u2081\u2082] P :=\n  mk\u2082'\u209b\u2097 \u03c3\u2081\u2082 \u03c1\u2081\u2082 (fun n m => f m n) (fun n\u2081 n\u2082 m => (f m).map_add _ _)\n    (fun c n m => (f m).map_smul\u209b\u2097 _ _) (fun n m\u2081 m\u2082 => by rw [f.map_add] <;> rfl) fun c n m => by\n    rw [f.map_smul\u209b\u2097] <;> 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) (fun (_x : LinearMap.{u1, u3, u5, u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) => M -> P) (LinearMap.hasCoeToFun.{u1, u3, u5, u7} R R\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u2, u4, u6, max u5 u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N (LinearMap.{u1, u3, u5, u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u5, u7} R R\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) _inst_17 (LinearMap.module.{u1, u3, u4, u5, u7} R R\u2082 S\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082 _inst_4 _inst_19 (LinearMap.flip._proof_1.{u3, u4, u7} R\u2082 _inst_3 S\u2082 _inst_4 P _inst_7 _inst_18 _inst_19 _inst_30))) (fun (_x : LinearMap.{u2, u4, u6, max u5 u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N (LinearMap.{u1, u3, u5, u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u5, u7} R R\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) _inst_17 (LinearMap.module.{u1, u3, u4, u5, u7} R R\u2082 S\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082 _inst_4 _inst_19 (LinearMap.flip._proof_1.{u3, u4, u7} R\u2082 _inst_3 S\u2082 _inst_4 P _inst_7 _inst_18 _inst_19 _inst_30))) => N -> (LinearMap.{u1, u3, u5, u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18)) (LinearMap.hasCoeToFun.{u2, u4, u6, max u5 u7} S S\u2082 N (LinearMap.{u1, u3, u5, u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_2 _inst_4 _inst_6 (LinearMap.addCommMonoid.{u1, u3, u5, u7} R R\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) _inst_17 (LinearMap.module.{u1, u3, u4, u5, u7} R R\u2082 S\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082 _inst_4 _inst_19 (LinearMap.flip._proof_1.{u3, u4, u7} R\u2082 _inst_3 S\u2082 _inst_4 P _inst_7 _inst_18 _inst_19 _inst_30)) \u03c3\u2081\u2082) (LinearMap.flip.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 f) n) m) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 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\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) (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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N (LinearMap.{u7, u6, u5, u4} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u7, u6, u5, u4} R R\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) _inst_17 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u6, u1, u5, u4} R R\u2082 S\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082 _inst_4 _inst_19 (SMulCommClass.symm.{u4, u6, u1} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, max u5 u4} S S\u2082 N (LinearMap.{u7, u6, u5, u4} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_2 _inst_4 _inst_6 (LinearMap.addCommMonoid.{u7, u6, u5, u4} R R\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) _inst_17 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u6, u1, u5, u4} R R\u2082 S\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082 _inst_4 _inst_19 (SMulCommClass.symm.{u4, u6, u1} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18)))) _inst_30)) \u03c3\u2081\u2082) (LinearMap.flip.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f m) n)\nCase conversion may be inaccurate. Consider using '#align linear_map.flip_apply LinearMap.flip_apply\u2093'. -/\n@[simp]\ntheorem flip_apply (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} [_inst_34 : SMulCommClass.{u3, u4, u7} R\u2082 S\u2082 P (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18)))) (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19))))] (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)), Eq.{max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 (LinearMap.flip._proof_1.{u4, u3, u7} S\u2082 _inst_4 R\u2082 _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\u2082 _inst_4 R\u2082 _inst_3 N M P _inst_6 _inst_5 _inst_7 _inst_17 _inst_16 _inst_19 _inst_18 _inst_34 \u03c3\u2081\u2082 \u03c1\u2081\u2082 (LinearMap.flip.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (_inst_34 : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)), Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 (SMulCommClass.symm.{u4, u1, u6} R\u2082 S\u2082 P (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18)))) (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulCommClass.symm.{u4, u6, u1} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 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\u2082 _inst_4 R\u2082 _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\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18)))) _inst_30) \u03c3\u2081\u2082 \u03c1\u2081\u2082 (LinearMap.flip.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 _inst_34)) _inst_34\nCase conversion may be inaccurate. Consider using '#align linear_map.flip_flip LinearMap.flip_flip\u2093'. -/\n@[simp]\ntheorem flip_flip [SMulCommClass R\u2082 S\u2082 P] (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) : f.flip.flip = f :=\n  LinearMap.ext\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} {f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)}, (Eq.{max (succ u6) (succ (max u5 u7))} (LinearMap.{u2, u4, u6, max u5 u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N (LinearMap.{u1, u3, u5, u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u5, u7} R R\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) _inst_17 (LinearMap.module.{u1, u3, u4, u5, u7} R R\u2082 S\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082 _inst_4 _inst_19 (LinearMap.flip._proof_1.{u3, u4, u7} R\u2082 _inst_3 S\u2082 _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\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 f) (LinearMap.flip.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 g)) -> (Eq.{max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} {f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)} {g : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)}, (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u2, u1, u3, max u4 u5} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N (LinearMap.{u7, u6, u5, u4} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M P _inst_5 _inst_7 _inst_16 _inst_18) _inst_6 (LinearMap.addCommMonoid.{u7, u6, u5, u4} R R\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082) _inst_17 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u6, u1, u5, u4} R R\u2082 S\u2082 M P _inst_1 _inst_3 _inst_5 _inst_7 _inst_16 _inst_18 \u03c1\u2081\u2082 _inst_4 _inst_19 (SMulCommClass.symm.{u4, u6, u1} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 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\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 f) (LinearMap.flip.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 g)) -> (Eq.{max (max (succ u5) (succ u3)) (succ u4)} (LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) f g)\nCase conversion may be inaccurate. Consider using '#align linear_map.flip_inj LinearMap.flip_inj\u2093'. -/\ntheorem flip_inj {f g : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P} (H : flip f = flip g) : f = g :=\n  ext\u2082 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\u2082 -> LinearMap.map_zero\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 LinearMap.map_zero\u2082\u2093'. -/\ntheorem map_zero\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (y) : f 0 y = 0 :=\n  (flip f y).map_zero\n#align linear_map.map_zero\u2082 LinearMap.map_zero\u2082\n\n/- warning: linear_map.map_neg\u2082 -> LinearMap.map_neg\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P' _inst_3 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)] [_inst_29 : Module.{u4, u7} S\u2082 P' _inst_4 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)] [_inst_32 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P' (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P' (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P' (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _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\u2082 P' (Semiring.toMonoidWithZero.{u4} S\u2082 _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\u2082 P' _inst_4 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_29)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P' (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P' (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _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\u2082 P' (Semiring.toMonoidWithZero.{u3} R\u2082 _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\u2082 P' _inst_3 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_28))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P' _inst_3 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15)] [_inst_29 : Module.{u1, u4} S\u2082 P' _inst_4 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15)] [_inst_32 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P' (SMulZeroClass.toSMul.{u1, u4} S\u2082 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\u2082 P' (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _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\u2082 P' (Semiring.toMonoidWithZero.{u1} S\u2082 _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\u2082 P' _inst_4 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_29)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 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\u2082 P' (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _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\u2082 P' (Semiring.toMonoidWithZero.{u6} R\u2082 _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\u2082 P' _inst_3 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_28))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) f x) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_neg\u2082 LinearMap.map_neg\u2082\u2093'. -/\ntheorem map_neg\u2082 (f : M' \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P') (x y) : f (-x) y = -f x y :=\n  (flip f y).map_neg _\n#align linear_map.map_neg\u2082 LinearMap.map_neg\u2082\n\n/- warning: linear_map.map_sub\u2082 -> LinearMap.map_sub\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P' _inst_3 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)] [_inst_29 : Module.{u4, u7} S\u2082 P' _inst_4 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)] [_inst_32 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P' (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P' (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P' (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _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\u2082 P' (Semiring.toMonoidWithZero.{u4} S\u2082 _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\u2082 P' _inst_4 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_29)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P' (AddZeroClass.toHasZero.{u7} P' (AddMonoid.toAddZeroClass.{u7} P' (AddCommMonoid.toAddMonoid.{u7} P' (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15)))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P' (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _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\u2082 P' (Semiring.toMonoidWithZero.{u3} R\u2082 _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\u2082 P' _inst_3 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_28))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) f x) z) (coeFn.{max (succ u5) (succ u7), max (succ u5) (succ u7)} (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) (fun (_x : LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29) => N -> P') (LinearMap.hasCoeToFun.{u2, u4, u5, u7} S S\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (coeFn.{max (succ u6) (succ (max u5 u7)), max (succ u6) (succ (max u5 u7))} (LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) (fun (_x : LinearMap.{u1, u3, u6, max u5 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32)) => M' -> (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P' _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29)) (LinearMap.hasCoeToFun.{u1, u3, u6, max u5 u7} R R\u2082 M' (LinearMap.{u2, u4, u5, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.module.{u2, u4, u3, u5, u7} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u7} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P' _inst_3 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15)] [_inst_29 : Module.{u1, u4} S\u2082 P' _inst_4 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15)] [_inst_32 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P' (SMulZeroClass.toSMul.{u1, u4} S\u2082 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\u2082 P' (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _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\u2082 P' (Semiring.toMonoidWithZero.{u1} S\u2082 _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\u2082 P' _inst_4 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_29)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 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\u2082 P' (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _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\u2082 P' (Semiring.toMonoidWithZero.{u6} R\u2082 _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\u2082 P' _inst_3 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_28))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 M' (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082) _inst_26 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P' _inst_2 _inst_4 _inst_6 (AddCommGroup.toAddCommMonoid.{u4} P' _inst_15) _inst_17 _inst_29 \u03c3\u2081\u2082 _inst_3 _inst_28 _inst_32) \u03c1\u2081\u2082) f y) z))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_sub\u2082 LinearMap.map_sub\u2082\u2093'. -/\ntheorem map_sub\u2082 (f : M' \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] 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\u2082 LinearMap.map_sub\u2082\n\n/- warning: linear_map.map_add\u2082 -> LinearMap.map_add\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (x\u2081 : M) (x\u2082 : 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2081 x\u2082)) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f x\u2081) y) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f x\u2082) 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (x\u2081 : M) (x\u2082 : 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2081 x\u2082)) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2081 x\u2082)) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) x\u2081) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f x\u2081) 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) x\u2082) N (fun (_x : N) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f x\u2082) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_add\u2082 LinearMap.map_add\u2082\u2093'. -/\ntheorem map_add\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (x\u2081 x\u2082 y) : f (x\u2081 + x\u2082) y = f x\u2081 y + f x\u2082 y :=\n  (flip f y).map_add _ _\n#align linear_map.map_add\u2082 LinearMap.map_add\u2082\n\n/- warning: linear_map.map_smul\u2082 -> LinearMap.map_smul\u2082 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\u2082 : Type.{u3}} [_inst_4 : Semiring.{u3} S\u2082] {M\u2082 : Type.{u4}} {N\u2082 : Type.{u5}} {P\u2082 : Type.{u6}} [_inst_8 : AddCommMonoid.{u4} M\u2082] [_inst_9 : AddCommMonoid.{u5} N\u2082] [_inst_10 : AddCommMonoid.{u6} P\u2082] [_inst_20 : Module.{u1, u4} R M\u2082 _inst_1 _inst_8] [_inst_21 : Module.{u2, u5} S N\u2082 _inst_2 _inst_9] [_inst_22 : Module.{u1, u6} R P\u2082 _inst_1 _inst_10] [_inst_23 : Module.{u3, u6} S\u2082 P\u2082 _inst_4 _inst_10] [_inst_33 : SMulCommClass.{u3, u1, u6} S\u2082 R P\u2082 (SMulZeroClass.toHasSmul.{u3, u6} S\u2082 P\u2082 (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (SMulWithZero.toSmulZeroClass.{u3, u6} S\u2082 P\u2082 (MulZeroClass.toHasZero.{u3} S\u2082 (MulZeroOneClass.toMulZeroClass.{u3} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} S\u2082 (Semiring.toMonoidWithZero.{u3} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (MulActionWithZero.toSMulWithZero.{u3, u6} S\u2082 P\u2082 (Semiring.toMonoidWithZero.{u3} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (Module.toMulActionWithZero.{u3, u6} S\u2082 P\u2082 _inst_4 _inst_10 _inst_23)))) (SMulZeroClass.toHasSmul.{u1, u6} R P\u2082 (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (SMulWithZero.toSmulZeroClass.{u1, u6} R P\u2082 (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (MulActionWithZero.toSMulWithZero.{u1, u6} R P\u2082 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (Module.toMulActionWithZero.{u1, u6} R P\u2082 _inst_1 _inst_10 _inst_22))))] {\u03c3\u2081\u2082 : RingHom.{u2, u3} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u3} S\u2082 _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\u2082 (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _inst_1 _inst_22 _inst_33)) (r : R) (x : M\u2082) (y : N\u2082), Eq.{succ u6} P\u2082 (coeFn.{max (succ u5) (succ u6), max (succ u5) (succ u6)} (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) (fun (_x : LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) => N\u2082 -> P\u2082) (LinearMap.hasCoeToFun.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) (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\u2082 (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _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\u2082 (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _inst_1 _inst_22 _inst_33)) => M\u2082 -> (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23)) (LinearMap.hasCoeToFun.{u1, u1, u4, max u5 u6} R R M\u2082 (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_1 _inst_1 _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _inst_1 _inst_22 _inst_33) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R _inst_1))) f (SMul.smul.{u1, u4} R M\u2082 (SMulZeroClass.toHasSmul.{u1, u4} R M\u2082 (AddZeroClass.toHasZero.{u4} M\u2082 (AddMonoid.toAddZeroClass.{u4} M\u2082 (AddCommMonoid.toAddMonoid.{u4} M\u2082 _inst_8))) (SMulWithZero.toSmulZeroClass.{u1, u4} R M\u2082 (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u4} M\u2082 (AddMonoid.toAddZeroClass.{u4} M\u2082 (AddCommMonoid.toAddMonoid.{u4} M\u2082 _inst_8))) (MulActionWithZero.toSMulWithZero.{u1, u4} R M\u2082 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u4} M\u2082 (AddMonoid.toAddZeroClass.{u4} M\u2082 (AddCommMonoid.toAddMonoid.{u4} M\u2082 _inst_8))) (Module.toMulActionWithZero.{u1, u4} R M\u2082 _inst_1 _inst_8 _inst_20)))) r x)) y) (SMul.smul.{u1, u6} R P\u2082 (SMulZeroClass.toHasSmul.{u1, u6} R P\u2082 (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (SMulWithZero.toSmulZeroClass.{u1, u6} R P\u2082 (MulZeroClass.toHasZero.{u1} R (MulZeroOneClass.toMulZeroClass.{u1} R (MonoidWithZero.toMulZeroOneClass.{u1} R (Semiring.toMonoidWithZero.{u1} R _inst_1)))) (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (MulActionWithZero.toSMulWithZero.{u1, u6} R P\u2082 (Semiring.toMonoidWithZero.{u1} R _inst_1) (AddZeroClass.toHasZero.{u6} P\u2082 (AddMonoid.toAddZeroClass.{u6} P\u2082 (AddCommMonoid.toAddMonoid.{u6} P\u2082 _inst_10))) (Module.toMulActionWithZero.{u1, u6} R P\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) (fun (_x : LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) => N\u2082 -> P\u2082) (LinearMap.hasCoeToFun.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) (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\u2082 (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _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\u2082 (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _inst_1 _inst_22 _inst_33)) => M\u2082 -> (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23)) (LinearMap.hasCoeToFun.{u1, u1, u4, max u5 u6} R R M\u2082 (LinearMap.{u2, u3, u5, u6} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_1 _inst_1 _inst_8 (LinearMap.addCommMonoid.{u2, u3, u5, u6} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.module.{u2, u3, u1, u5, u6} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _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\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {M\u2082 : Type.{u5}} {N\u2082 : Type.{u3}} {P\u2082 : Type.{u4}} [_inst_8 : AddCommMonoid.{u5} M\u2082] [_inst_9 : AddCommMonoid.{u3} N\u2082] [_inst_10 : AddCommMonoid.{u4} P\u2082] [_inst_20 : Module.{u6, u5} R M\u2082 _inst_1 _inst_8] [_inst_21 : Module.{u2, u3} S N\u2082 _inst_2 _inst_9] [_inst_22 : Module.{u6, u4} R P\u2082 _inst_1 _inst_10] [_inst_23 : Module.{u1, u4} S\u2082 P\u2082 _inst_4 _inst_10] [_inst_33 : SMulCommClass.{u1, u6, u4} S\u2082 R P\u2082 (SMulZeroClass.toSMul.{u1, u4} S\u2082 P\u2082 (AddMonoid.toZero.{u4} P\u2082 (AddCommMonoid.toAddMonoid.{u4} P\u2082 _inst_10)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P\u2082 (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P\u2082 (AddCommMonoid.toAddMonoid.{u4} P\u2082 _inst_10)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P\u2082 (AddCommMonoid.toAddMonoid.{u4} P\u2082 _inst_10)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P\u2082 _inst_4 _inst_10 _inst_23)))) (SMulZeroClass.toSMul.{u6, u4} R P\u2082 (AddMonoid.toZero.{u4} P\u2082 (AddCommMonoid.toAddMonoid.{u4} P\u2082 _inst_10)) (SMulWithZero.toSMulZeroClass.{u6, u4} R P\u2082 (MonoidWithZero.toZero.{u6} R (Semiring.toMonoidWithZero.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2082 (AddCommMonoid.toAddMonoid.{u4} P\u2082 _inst_10)) (MulActionWithZero.toSMulWithZero.{u6, u4} R P\u2082 (Semiring.toMonoidWithZero.{u6} R _inst_1) (AddMonoid.toZero.{u4} P\u2082 (AddCommMonoid.toAddMonoid.{u4} P\u2082 _inst_10)) (Module.toMulActionWithZero.{u6, u4} R P\u2082 _inst_1 _inst_10 _inst_22))))] {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _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\u2082 (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _inst_1 _inst_22 _inst_33)) (r : R) (x : M\u2082) (y : N\u2082), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (FunLike.coe.{max (succ u3) (succ u4), succ u3, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M\u2082) => LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) (HSMul.hSMul.{u6, u5, u5} R M\u2082 M\u2082 (instHSMul.{u6, u5} R M\u2082 (SMulZeroClass.toSMul.{u6, u5} R M\u2082 (AddMonoid.toZero.{u5} M\u2082 (AddCommMonoid.toAddMonoid.{u5} M\u2082 _inst_8)) (SMulWithZero.toSMulZeroClass.{u6, u5} R M\u2082 (MonoidWithZero.toZero.{u6} R (Semiring.toMonoidWithZero.{u6} R _inst_1)) (AddMonoid.toZero.{u5} M\u2082 (AddCommMonoid.toAddMonoid.{u5} M\u2082 _inst_8)) (MulActionWithZero.toSMulWithZero.{u6, u5} R M\u2082 (Semiring.toMonoidWithZero.{u6} R _inst_1) (AddMonoid.toZero.{u5} M\u2082 (AddCommMonoid.toAddMonoid.{u5} M\u2082 _inst_8)) (Module.toMulActionWithZero.{u6, u5} R M\u2082 _inst_1 _inst_8 _inst_20))))) r x)) N\u2082 (fun (_x : N\u2082) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) (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\u2082 (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _inst_1 _inst_22 _inst_33)) M\u2082 (fun (_x : M\u2082) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M\u2082) => LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u5, max u3 u4} R R M\u2082 (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_1 _inst_1 _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _inst_1 _inst_22 _inst_33) (RingHom.id.{u6} R (Semiring.toNonAssocSemiring.{u6} R _inst_1))) f (HSMul.hSMul.{u6, u5, u5} R M\u2082 M\u2082 (instHSMul.{u6, u5} R M\u2082 (SMulZeroClass.toSMul.{u6, u5} R M\u2082 (AddMonoid.toZero.{u5} M\u2082 (AddCommMonoid.toAddMonoid.{u5} M\u2082 _inst_8)) (SMulWithZero.toSMulZeroClass.{u6, u5} R M\u2082 (MonoidWithZero.toZero.{u6} R (Semiring.toMonoidWithZero.{u6} R _inst_1)) (AddMonoid.toZero.{u5} M\u2082 (AddCommMonoid.toAddMonoid.{u5} M\u2082 _inst_8)) (MulActionWithZero.toSMulWithZero.{u6, u5} R M\u2082 (Semiring.toMonoidWithZero.{u6} R _inst_1) (AddMonoid.toZero.{u5} M\u2082 (AddCommMonoid.toAddMonoid.{u5} M\u2082 _inst_8)) (Module.toMulActionWithZero.{u6, u5} R M\u2082 _inst_1 _inst_8 _inst_20))))) r x)) y) (HSMul.hSMul.{u6, u4, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (instHSMul.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (SMulZeroClass.toSMul.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) _inst_10)) (SMulWithZero.toSMulZeroClass.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (MonoidWithZero.toZero.{u6} R (Semiring.toMonoidWithZero.{u6} R _inst_1)) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) _inst_10)) (MulActionWithZero.toSMulWithZero.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (Semiring.toMonoidWithZero.{u6} R _inst_1) (AddMonoid.toZero.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) (AddCommMonoid.toAddMonoid.{u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) y) _inst_10)) (Module.toMulActionWithZero.{u6, u4} R ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) 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\u2082) => LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) x) N\u2082 (fun (_x : N\u2082) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2082) => P\u2082) _x) (LinearMap.instFunLikeLinearMap.{u2, u1, u3, u4} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) (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\u2082 (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _inst_1 _inst_22 _inst_33)) M\u2082 (fun (_x : M\u2082) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M\u2082) => LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u5, max u3 u4} R R M\u2082 (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N\u2082 P\u2082 _inst_9 _inst_10 _inst_21 _inst_23) _inst_1 _inst_1 _inst_8 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082) _inst_20 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R N\u2082 P\u2082 _inst_2 _inst_4 _inst_9 _inst_10 _inst_21 _inst_23 \u03c3\u2081\u2082 _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\u2082 LinearMap.map_smul\u2082\u2093'. -/\ntheorem map_smul\u2082 (f : M\u2082 \u2192\u2097[R] N\u2082 \u2192\u209b\u2097[\u03c3\u2081\u2082] P\u2082) (r : R) (x y) : f (r \u2022 x) y = r \u2022 f x y :=\n  (flip f y).map_smul _ _\n#align linear_map.map_smul\u2082 LinearMap.map_smul\u2082\n\n/- warning: linear_map.map_smul\u209b\u2097\u2082 -> LinearMap.map_smul\u209b\u2097\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 P (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18)))) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) (fun (_x : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) => R -> R\u2082) (RingHom.hasCoeToFun.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)) \u03c1\u2081\u2082 r) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082) 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\u2082) 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\u2082) 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\u2082) 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\u2082) r) (Semiring.toMonoidWithZero.{u6} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) 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\u2082) 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\u2082) 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\u2082) 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\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)) R (fun (_x : R) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : R) => R\u2082) _x) (MulHomClass.toFunLike.{max u7 u6, u7, u6} (RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)) R R\u2082 (NonUnitalNonAssocSemiring.toMul.{u7} R (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u7} R (Semiring.toNonAssocSemiring.{u7} R _inst_1))) (NonUnitalNonAssocSemiring.toMul.{u6} R\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u6} R\u2082 (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3))) (NonUnitalRingHomClass.toMulHomClass.{max u7 u6, u7, u6} (RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)) R R\u2082 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u7} R (Semiring.toNonAssocSemiring.{u7} R _inst_1)) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u6} R\u2082 (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)) (RingHomClass.toNonUnitalRingHomClass.{max u7 u6, u7, u6} (RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)) R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3) (RingHom.instRingHomClassRingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3))))) \u03c1\u2081\u2082 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f x) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_smul\u209b\u2097\u2082 LinearMap.map_smul\u209b\u2097\u2082\u2093'. -/\ntheorem map_smul\u209b\u2097\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (r : R) (x y) : f (r \u2022 x) y = \u03c1\u2081\u2082 r \u2022 f x y :=\n  (flip f y).map_smul\u209b\u2097 _ _\n#align linear_map.map_smul\u209b\u2097\u2082 LinearMap.map_smul\u209b\u2097\u2082\n\n/- warning: linear_map.map_sum\u2082 -> LinearMap.map_sum\u2082 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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} {\u03b9 : Type.{u8}} (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (t : Finset.{u8} \u03b9) (x : \u03b9 -> 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f (Finset.sum.{u5, u8} M \u03b9 _inst_5 t (fun (i : \u03b9) => x i))) y) (Finset.sum.{u7, u8} P \u03b9 _inst_7 t (fun (i : \u03b9) => coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} {\u03b9 : Type.{u8}} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (t : Finset.{u8} \u03b9) (x : \u03b9 -> 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (Finset.sum.{u5, u8} M \u03b9 _inst_5 t (fun (i : \u03b9) => 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f (Finset.sum.{u5, u8} M \u03b9 _inst_5 t (fun (i : \u03b9) => x i))) y) (Finset.sum.{u4, u8} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N) => P) y) \u03b9 _inst_7 t (fun (i : \u03b9) => 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) f (x i)) y))\nCase conversion may be inaccurate. Consider using '#align linear_map.map_sum\u2082 LinearMap.map_sum\u2082\u2093'. -/\ntheorem map_sum\u2082 {\u03b9 : Type _} (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (t : Finset \u03b9) (x : \u03b9 \u2192 M) (y) :\n    f (\u2211 i in t, x i) y = \u2211 i in t, f (x i) y :=\n  (flip f y).map_sum\n#align linear_map.map_sum\u2082 LinearMap.map_sum\u2082\n\n#print LinearMap.domRestrict\u2082 /-\n/-- Restricting a bilinear map in the second entry -/\ndef domRestrict\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (q : Submodule S N) : M \u2192\u209b\u2097[\u03c1\u2081\u2082] q \u2192\u209b\u2097[\u03c3\u2081\u2082] P\n    where\n  toFun m := (f m).domRestrict q\n  map_add' m\u2081 m\u2082 := 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\u209b\u2097, dom_restrict_apply, smul_apply]\n#align linear_map.dom_restrict\u2082 LinearMap.domRestrict\u2082\n-/\n\n/- warning: linear_map.dom_restrict\u2082_apply -> LinearMap.domRestrict\u2082_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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) (LinearMap.domRestrict\u2082.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 f q) x) y) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2093.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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) (LinearMap.domRestrict\u2082.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2082_apply LinearMap.domRestrict\u2082_apply\u2093'. -/\ntheorem domRestrict\u2082_apply (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (q : Submodule S N) (x : M) (y : q) :\n    f.domRestrict\u2082 q x y = f x y :=\n  rfl\n#align linear_map.dom_restrict\u2082_apply LinearMap.domRestrict\u2082_apply\n\n#print LinearMap.domRestrict\u2081\u2082 /-\n/-- Restricting a bilinear map in both components -/\ndef domRestrict\u2081\u2082 (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (p : Submodule R M) (q : Submodule S N) :\n    p \u2192\u209b\u2097[\u03c1\u2081\u2082] q \u2192\u209b\u2097[\u03c3\u2081\u2082] P :=\n  (f.domRestrict p).domRestrict\u2082 q\n#align linear_map.dom_restrict\u2081\u2082 LinearMap.domRestrict\u2081\u2082\n-/\n\n/- warning: linear_map.dom_restrict\u2081\u2082_apply -> LinearMap.domRestrict\u2081\u2082_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\u2082 : Type.{u3}} [_inst_3 : Semiring.{u3} R\u2082] {S\u2082 : Type.{u4}} [_inst_4 : Semiring.{u4} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u4, u7} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u4, u3, u7} S\u2082 R\u2082 P (SMulZeroClass.toHasSmul.{u4, u7} S\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u4, u7} S\u2082 P (MulZeroClass.toHasZero.{u4} S\u2082 (MulZeroOneClass.toMulZeroClass.{u4} S\u2082 (MonoidWithZero.toMulZeroOneClass.{u4} S\u2082 (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u4, u7} S\u2082 P (Semiring.toMonoidWithZero.{u4} S\u2082 _inst_4) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u4, u7} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toHasSmul.{u3, u7} R\u2082 P (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (SMulWithZero.toSmulZeroClass.{u3, u7} R\u2082 P (MulZeroClass.toHasZero.{u3} R\u2082 (MulZeroOneClass.toMulZeroClass.{u3} R\u2082 (MonoidWithZero.toMulZeroOneClass.{u3} R\u2082 (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3)))) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (MulActionWithZero.toSMulWithZero.{u3, u7} R\u2082 P (Semiring.toMonoidWithZero.{u3} R\u2082 _inst_3) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u1, u3} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R _inst_1) (Semiring.toNonAssocSemiring.{u3} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u4} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u4} S\u2082 _inst_4)} (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 (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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (Submodule.module.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 (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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (Submodule.module.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (Submodule.module.{u1, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) (LinearMap.domRestrict\u2081\u2082.{u1, u2, u3, u4, u5, u6, u7} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 f p q) x) y) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) (fun (_x : LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) => N -> P) (LinearMap.hasCoeToFun.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30)) => M -> (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2082 M (LinearMap.{u2, u4, u6, u7} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u4, u6, u7} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.module.{u2, u4, u3, u6, u7} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2093.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\u2093.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\u2082 : Type.{u6}} [_inst_3 : Semiring.{u6} R\u2082] {S\u2082 : Type.{u1}} [_inst_4 : Semiring.{u1} S\u2082] {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\u2082 P _inst_3 _inst_7] [_inst_19 : Module.{u1, u4} S\u2082 P _inst_4 _inst_7] [_inst_30 : SMulCommClass.{u1, u6, u4} S\u2082 R\u2082 P (SMulZeroClass.toSMul.{u1, u4} S\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u1, u4} S\u2082 P (MonoidWithZero.toZero.{u1} S\u2082 (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u1, u4} S\u2082 P (Semiring.toMonoidWithZero.{u1} S\u2082 _inst_4) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u1, u4} S\u2082 P _inst_4 _inst_7 _inst_19)))) (SMulZeroClass.toSMul.{u6, u4} R\u2082 P (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (SMulWithZero.toSMulZeroClass.{u6, u4} R\u2082 P (MonoidWithZero.toZero.{u6} R\u2082 (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (MulActionWithZero.toSMulWithZero.{u6, u4} R\u2082 P (Semiring.toMonoidWithZero.{u6} R\u2082 _inst_3) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u6, u4} R\u2082 P _inst_3 _inst_7 _inst_18))))] {\u03c1\u2081\u2082 : RingHom.{u7, u6} R R\u2082 (Semiring.toNonAssocSemiring.{u7} R _inst_1) (Semiring.toNonAssocSemiring.{u6} R\u2082 _inst_3)} {\u03c3\u2081\u2082 : RingHom.{u2, u1} S S\u2082 (Semiring.toNonAssocSemiring.{u2} S _inst_2) (Semiring.toNonAssocSemiring.{u1} S\u2082 _inst_4)} (f : LinearMap.{u7, u6, u5, max u4 u3} R R\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 (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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (Submodule.module.{u7, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 (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\u2082 (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 \u03c3\u2081\u2082) (Submodule.module.{u7, u5} R M _inst_1 _inst_5 _inst_16 p) (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 (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 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) (LinearMap.domRestrict\u2081\u2082.{u7, u2, u6, u1, u5, u3, u4} R _inst_1 S _inst_2 R\u2082 _inst_3 S\u2082 _inst_4 M N P _inst_5 _inst_6 _inst_7 _inst_16 _inst_17 _inst_18 _inst_19 _inst_30 \u03c1\u2081\u2082 \u03c3\u2081\u2082 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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 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\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) (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\u2082 _inst_1 _inst_3 \u03c1\u2081\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _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\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _x) (LinearMap.instFunLikeLinearMap.{u7, u6, u5, max u3 u4} R R\u2082 M (LinearMap.{u2, u1, u3, u4} S S\u2082 _inst_2 _inst_4 \u03c3\u2081\u2082 N P _inst_6 _inst_7 _inst_17 _inst_19) _inst_1 _inst_3 _inst_5 (LinearMap.addCommMonoid.{u2, u1, u3, u4} S S\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082) _inst_16 (LinearMap.instModuleLinearMapAddCommMonoid.{u2, u1, u6, u3, u4} S S\u2082 R\u2082 N P _inst_2 _inst_4 _inst_6 _inst_7 _inst_17 _inst_19 \u03c3\u2081\u2082 _inst_3 _inst_18 _inst_30) \u03c1\u2081\u2082) 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\u2081\u2082_apply LinearMap.domRestrict\u2081\u2082_apply\u2093'. -/\ntheorem domRestrict\u2081\u2082_apply (f : M \u2192\u209b\u2097[\u03c1\u2081\u2082] N \u2192\u209b\u2097[\u03c3\u2081\u2082] P) (p : Submodule R M) (q : Submodule S N)\n    (x : p) (y : q) : f.domRestrict\u2081\u2082 p q x y = f x y :=\n  rfl\n#align linear_map.dom_restrict\u2081\u2082_apply LinearMap.domRestrict\u2081\u2082_apply\n\nend Semiring\n\nsection CommSemiring\n\nvariable {R : Type _} [CommSemiring R] {R\u2082 : Type _} [CommSemiring R\u2082]\n\nvariable {R\u2083 : Type _} [CommSemiring R\u2083] {R\u2084 : Type _} [CommSemiring R\u2084]\n\nvariable {M : Type _} {N : Type _} {P : Type _} {Q : Type _}\n\nvariable {M\u2097 : Type _} {N\u2097 : Type _} {P\u2097 : Type _} {Q\u2097 Q\u2097' : Type _}\n\nvariable [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q]\n\nvariable [AddCommMonoid M\u2097] [AddCommMonoid N\u2097] [AddCommMonoid P\u2097]\n\nvariable [AddCommMonoid Q\u2097] [AddCommMonoid Q\u2097']\n\nvariable [Module R M] [Module R\u2082 N] [Module R\u2083 P] [Module R\u2084 Q]\n\nvariable [Module R M\u2097] [Module R N\u2097] [Module R P\u2097] [Module R Q\u2097] [Module R Q\u2097']\n\nvariable {\u03c3\u2081\u2082 : R \u2192+* R\u2082} {\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083} {\u03c3\u2081\u2083 : R \u2192+* R\u2083}\n\nvariable {\u03c3\u2084\u2082 : R\u2084 \u2192+* R\u2082} {\u03c3\u2084\u2083 : R\u2084 \u2192+* R\u2083}\n\nvariable [RingHomCompTriple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083] [RingHomCompTriple \u03c3\u2084\u2082 \u03c3\u2082\u2083 \u03c3\u2084\u2083]\n\nvariable (R)\n\n/- warning: linear_map.mk\u2082 -> LinearMap.mk\u2082 is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : M -> N\u2097 -> P\u2097), (forall (m\u2081 : M) (m\u2082 : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2081 m\u2082) n) (HAdd.hAdd.{u4, u4, u4} P\u2097 P\u2097 P\u2097 (instHAdd.{u4} P\u2097 (AddZeroClass.toHasAdd.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)))) (f m\u2081 n) (f m\u2082 n))) -> (forall (c : R) (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2097 (SMulZeroClass.toHasSmul.{u1, u4} R P\u2097 (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (SMulWithZero.toSmulZeroClass.{u1, u4} R P\u2097 (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\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (MulActionWithZero.toSMulWithZero.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) c (f m n))) -> (forall (m : M) (n\u2081 : N\u2097) (n\u2082 : N\u2097), Eq.{succ u4} P\u2097 (f m (HAdd.hAdd.{u3, u3, u3} N\u2097 N\u2097 N\u2097 (instHAdd.{u3} N\u2097 (AddZeroClass.toHasAdd.{u3} N\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)))) n\u2081 n\u2082)) (HAdd.hAdd.{u4, u4, u4} P\u2097 P\u2097 P\u2097 (instHAdd.{u4} P\u2097 (AddZeroClass.toHasAdd.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)))) (f m n\u2081) (f m n\u2082))) -> (forall (c : R) (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (f m (SMul.smul.{u1, u3} R N\u2097 (SMulZeroClass.toHasSmul.{u1, u3} R N\u2097 (AddZeroClass.toHasZero.{u3} N\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10))) (SMulWithZero.toSmulZeroClass.{u1, u3} R N\u2097 (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\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10))) (MulActionWithZero.toSMulWithZero.{u1, u3} R N\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} N\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10))) (Module.toMulActionWithZero.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_19)))) c n)) (SMul.smul.{u1, u4} R P\u2097 (SMulZeroClass.toHasSmul.{u1, u4} R P\u2097 (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (SMulWithZero.toSmulZeroClass.{u1, u4} R P\u2097 (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\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (MulActionWithZero.toSMulWithZero.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2082._proof_1.{u1, u4} R _inst_1 P\u2097 _inst_11 _inst_20)))\nbut is expected to have type\n  forall (R : Type.{u1}) [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : M -> N\u2097 -> P\u2097), (forall (m\u2081 : M) (m\u2082 : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2081 m\u2082) n) (HAdd.hAdd.{u4, u4, u4} P\u2097 P\u2097 P\u2097 (instHAdd.{u4} P\u2097 (AddZeroClass.toAdd.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)))) (f m\u2081 n) (f m\u2082 n))) -> (forall (c : R) (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2097 P\u2097 (instHSMul.{u1, u4} R P\u2097 (SMulZeroClass.toSMul.{u1, u4} R P\u2097 (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (SMulWithZero.toSMulZeroClass.{u1, u4} R P\u2097 (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (MulActionWithZero.toSMulWithZero.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) c (f m n))) -> (forall (m : M) (n\u2081 : N\u2097) (n\u2082 : N\u2097), Eq.{succ u4} P\u2097 (f m (HAdd.hAdd.{u3, u3, u3} N\u2097 N\u2097 N\u2097 (instHAdd.{u3} N\u2097 (AddZeroClass.toAdd.{u3} N\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)))) n\u2081 n\u2082)) (HAdd.hAdd.{u4, u4, u4} P\u2097 P\u2097 P\u2097 (instHAdd.{u4} P\u2097 (AddZeroClass.toAdd.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)))) (f m n\u2081) (f m n\u2082))) -> (forall (c : R) (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (f m (HSMul.hSMul.{u1, u3, u3} R N\u2097 N\u2097 (instHSMul.{u1, u3} R N\u2097 (SMulZeroClass.toSMul.{u1, u3} R N\u2097 (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (SMulWithZero.toSMulZeroClass.{u1, u3} R N\u2097 (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (MulActionWithZero.toSMulWithZero.{u1, u3} R N\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_19))))) c n)) (HSMul.hSMul.{u1, u4, u4} R P\u2097 P\u2097 (instHSMul.{u1, u4} R P\u2097 (SMulZeroClass.toSMul.{u1, u4} R P\u2097 (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (SMulWithZero.toSMulZeroClass.{u1, u4} R P\u2097 (CommMonoidWithZero.toZero.{u1} R (CommSemiring.toCommMonoidWithZero.{u1} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (MulActionWithZero.toSMulWithZero.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))))\nCase conversion may be inaccurate. Consider using '#align linear_map.mk\u2082 LinearMap.mk\u2082\u2093'. -/\n/-- Create a bilinear map from a function that is linear in each component.\n\nThis is a shorthand for `mk\u2082'` for the common case when `R = S`. -/\ndef mk\u2082 (f : M \u2192 N\u2097 \u2192 P\u2097) (H1 : \u2200 m\u2081 m\u2082 n, f (m\u2081 + m\u2082) n = f m\u2081 n + f m\u2082 n)\n    (H2 : \u2200 (c : R) (m n), f (c \u2022 m) n = c \u2022 f m n)\n    (H3 : \u2200 m n\u2081 n\u2082, f m (n\u2081 + n\u2082) = f m n\u2081 + f m n\u2082)\n    (H4 : \u2200 (c : R) (m n), f m (c \u2022 n) = c \u2022 f m n) : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097 :=\n  mk\u2082' R R f H1 H2 H3 H4\n#align linear_map.mk\u2082 LinearMap.mk\u2082\n\n/- warning: linear_map.mk\u2082_apply -> LinearMap.mk\u2082_apply is a dubious translation:\nlean 3 declaration is\n  forall (R : Type.{u1}) [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] (f : M -> N\u2097 -> P\u2097) {H1 : forall (m\u2081 : M) (m\u2082 : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2081 m\u2082) n) (HAdd.hAdd.{u4, u4, u4} P\u2097 P\u2097 P\u2097 (instHAdd.{u4} P\u2097 (AddZeroClass.toHasAdd.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)))) (f m\u2081 n) (f m\u2082 n))} {H2 : forall (c : R) (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2097 (SMulZeroClass.toHasSmul.{u1, u4} R P\u2097 (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (SMulWithZero.toSmulZeroClass.{u1, u4} R P\u2097 (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\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (MulActionWithZero.toSMulWithZero.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) c (f m n))} {H3 : forall (m : M) (n\u2081 : N\u2097) (n\u2082 : N\u2097), Eq.{succ u4} P\u2097 (f m (HAdd.hAdd.{u3, u3, u3} N\u2097 N\u2097 N\u2097 (instHAdd.{u3} N\u2097 (AddZeroClass.toHasAdd.{u3} N\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)))) n\u2081 n\u2082)) (HAdd.hAdd.{u4, u4, u4} P\u2097 P\u2097 P\u2097 (instHAdd.{u4} P\u2097 (AddZeroClass.toHasAdd.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)))) (f m n\u2081) (f m n\u2082))} {H4 : forall (c : R) (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (f m (SMul.smul.{u1, u3} R N\u2097 (SMulZeroClass.toHasSmul.{u1, u3} R N\u2097 (AddZeroClass.toHasZero.{u3} N\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10))) (SMulWithZero.toSmulZeroClass.{u1, u3} R N\u2097 (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\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10))) (MulActionWithZero.toSMulWithZero.{u1, u3} R N\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u3} N\u2097 (AddMonoid.toAddZeroClass.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10))) (Module.toMulActionWithZero.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10 _inst_19)))) c n)) (SMul.smul.{u1, u4} R P\u2097 (SMulZeroClass.toHasSmul.{u1, u4} R P\u2097 (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (SMulWithZero.toSmulZeroClass.{u1, u4} R P\u2097 (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\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (MulActionWithZero.toSMulWithZero.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20)))) c (f m n))} (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) => N\u2097 -> P\u2097) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2082._proof_1.{u1, u4} R _inst_1 P\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2082._proof_1.{u1, u4} R _inst_1 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 (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\u2097 P\u2097 (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\u2082._proof_1.{u1, u4} R _inst_1 P\u2097 _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.mk\u2082.{u1, u2, u3, u4} R _inst_1 M N\u2097 P\u2097 _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\u2097 : Type.{u1}} {P\u2097 : Type.{u4}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_10 : AddCommMonoid.{u1} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_14 : Module.{u2, u3} R M (CommSemiring.toSemiring.{u2} R _inst_1) _inst_5] [_inst_19 : Module.{u2, u1} R N\u2097 (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10] [_inst_20 : Module.{u2, u4} R P\u2097 (CommSemiring.toSemiring.{u2} R _inst_1) _inst_11] (f : M -> N\u2097 -> P\u2097) {H1 : forall (m\u2081 : M) (m\u2082 : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2081 m\u2082) n) (HAdd.hAdd.{u4, u4, u4} P\u2097 P\u2097 P\u2097 (instHAdd.{u4} P\u2097 (AddZeroClass.toAdd.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)))) (f m\u2081 n) (f m\u2082 n))} {H2 : forall (c : R) (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (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\u2097 P\u2097 (instHSMul.{u2, u4} R P\u2097 (SMulZeroClass.toSMul.{u2, u4} R P\u2097 (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (SMulWithZero.toSMulZeroClass.{u2, u4} R P\u2097 (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (MulActionWithZero.toSMulWithZero.{u2, u4} R P\u2097 (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u2, u4} R P\u2097 (CommSemiring.toSemiring.{u2} R _inst_1) _inst_11 _inst_20))))) c (f m n))} {H3 : forall (m : M) (n\u2081 : N\u2097) (n\u2082 : N\u2097), Eq.{succ u4} P\u2097 (f m (HAdd.hAdd.{u1, u1, u1} N\u2097 N\u2097 N\u2097 (instHAdd.{u1} N\u2097 (AddZeroClass.toAdd.{u1} N\u2097 (AddMonoid.toAddZeroClass.{u1} N\u2097 (AddCommMonoid.toAddMonoid.{u1} N\u2097 _inst_10)))) n\u2081 n\u2082)) (HAdd.hAdd.{u4, u4, u4} P\u2097 P\u2097 P\u2097 (instHAdd.{u4} P\u2097 (AddZeroClass.toAdd.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)))) (f m n\u2081) (f m n\u2082))} {H4 : forall (c : R) (m : M) (n : N\u2097), Eq.{succ u4} P\u2097 (f m (HSMul.hSMul.{u2, u1, u1} R N\u2097 N\u2097 (instHSMul.{u2, u1} R N\u2097 (SMulZeroClass.toSMul.{u2, u1} R N\u2097 (AddMonoid.toZero.{u1} N\u2097 (AddCommMonoid.toAddMonoid.{u1} N\u2097 _inst_10)) (SMulWithZero.toSMulZeroClass.{u2, u1} R N\u2097 (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u1} N\u2097 (AddCommMonoid.toAddMonoid.{u1} N\u2097 _inst_10)) (MulActionWithZero.toSMulWithZero.{u2, u1} R N\u2097 (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u1} N\u2097 (AddCommMonoid.toAddMonoid.{u1} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u2, u1} R N\u2097 (CommSemiring.toSemiring.{u2} R _inst_1) _inst_10 _inst_19))))) c n)) (HSMul.hSMul.{u2, u4, u4} R P\u2097 P\u2097 (instHSMul.{u2, u4} R P\u2097 (SMulZeroClass.toSMul.{u2, u4} R P\u2097 (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (SMulWithZero.toSMulZeroClass.{u2, u4} R P\u2097 (CommMonoidWithZero.toZero.{u2} R (CommSemiring.toCommMonoidWithZero.{u2} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (MulActionWithZero.toSMulWithZero.{u2, u4} R P\u2097 (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u2, u4} R P\u2097 (CommSemiring.toSemiring.{u2} R _inst_1) _inst_11 _inst_20))))) c (f m n))} (m : M) (n : N\u2097), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2097) => P\u2097) 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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) m) N\u2097 (fun (_x : N\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2097) => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, u1, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u2, u2, u1, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u2} R _inst_1) (MulActionWithZero.toMulAction.{u2, u4} R P\u2097 (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u2, u4} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u2} R _inst_1) (MulActionWithZero.toMulAction.{u2, u4} R P\u2097 (Semiring.toMonoidWithZero.{u2} R (CommSemiring.toSemiring.{u2} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u2, u4} R P\u2097 (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\u2082.{u2, u3, u1, u4} R _inst_1 M N\u2097 P\u2097 _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\u2082_apply LinearMap.mk\u2082_apply\u2093'. -/\n@[simp]\ntheorem mk\u2082_apply (f : M \u2192 N\u2097 \u2192 P\u2097) {H1 H2 H3 H4} (m : M) (n : N\u2097) :\n    (mk\u2082 R f H1 H2 H3 H4 : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) m n = f m n :=\n  rfl\n#align linear_map.mk\u2082_apply LinearMap.mk\u2082_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 \u2192 N \u2192 P`,\nchange the order of variables and get a linear map from `N` to linear maps from `M` to `P`. -/\ndef lflip : (M \u2192\u209b\u2097[\u03c3\u2081\u2083] N \u2192\u209b\u2097[\u03c3\u2082\u2083] P) \u2192\u2097[R\u2083] N \u2192\u209b\u2097[\u03c3\u2082\u2083] M \u2192\u209b\u2097[\u03c3\u2081\u2083] 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 \u2192\u209b\u2097[\u03c3\u2081\u2083] N \u2192\u209b\u2097[\u03c3\u2082\u2083] 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\u2082 : Type.{u2}} [_inst_2 : CommSemiring.{u2} R\u2082] {R\u2083 : Type.{u3}} [_inst_3 : CommSemiring.{u3} R\u2083] {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\u2082 N (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) _inst_6] [_inst_16 : Module.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7] {\u03c3\u2082\u2083 : RingHom.{u2, u3} R\u2082 R\u2083 (Semiring.toNonAssocSemiring.{u2} R\u2082 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} {\u03c3\u2081\u2083 : RingHom.{u1, u3} R R\u2083 (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} (f : LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _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\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (fun (_x : LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) => M -> P) (LinearMap.hasCoeToFun.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (coeFn.{max (succ u5) (succ (max u4 u6)), max (succ u5) (succ (max u4 u6))} (LinearMap.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (fun (_x : LinearMap.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) => N -> (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16)) (LinearMap.hasCoeToFun.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2082\u2083) (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\u2083 R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (RingHom.id.{u3} R\u2083 (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (LinearMap.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (LinearMap.addCommMonoid.{u1, u3, u4, max u5 u6} R R\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2081\u2083) (LinearMap.addCommMonoid.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2082\u2083) (LinearMap.module.{u1, u3, u3, u4, max u5 u6} R R\u2083 R\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_3.{u2, u3, u5, u6} R\u2082 _inst_2 R\u2083 _inst_3 N P _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083)) (LinearMap.module.{u2, u3, u3, u5, max u4 u6} R\u2082 R\u2083 R\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_4.{u1, u3, u4, u6} R _inst_1 R\u2083 _inst_3 M P _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083))) (fun (_x : LinearMap.{u3, u3, max u4 u5 u6, max u5 u4 u6} R\u2083 R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (RingHom.id.{u3} R\u2083 (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (LinearMap.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (LinearMap.addCommMonoid.{u1, u3, u4, max u5 u6} R R\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2081\u2083) (LinearMap.addCommMonoid.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2082\u2083) (LinearMap.module.{u1, u3, u3, u4, max u5 u6} R R\u2083 R\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_3.{u2, u3, u5, u6} R\u2082 _inst_2 R\u2083 _inst_3 N P _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083)) (LinearMap.module.{u2, u3, u3, u5, max u4 u6} R\u2082 R\u2083 R\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_4.{u1, u3, u4, u6} R _inst_1 R\u2083 _inst_3 M P _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083))) => (LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) -> (LinearMap.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)))) (LinearMap.hasCoeToFun.{u3, u3, max u4 u5 u6, max u5 u4 u6} R\u2083 R\u2083 (LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (LinearMap.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.addCommMonoid.{u1, u3, u4, max u5 u6} R R\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2081\u2083) (LinearMap.addCommMonoid.{u2, u3, u5, max u4 u6} R\u2082 R\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2082\u2083) (LinearMap.module.{u1, u3, u3, u4, max u5 u6} R R\u2083 R\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_3.{u2, u3, u5, u6} R\u2082 _inst_2 R\u2083 _inst_3 N P _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083)) (LinearMap.module.{u2, u3, u3, u5, max u4 u6} R\u2082 R\u2083 R\u2083 N (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lflip._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.lflip._proof_4.{u1, u3, u4, u6} R _inst_1 R\u2083 _inst_3 M P _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083)) (RingHom.id.{u3} R\u2083 (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)))) (LinearMap.lflip.{u1, u2, u3, u4, u5, u6} R _inst_1 R\u2082 _inst_2 R\u2083 _inst_3 M N P _inst_5 _inst_6 _inst_7 _inst_14 _inst_15 _inst_16 \u03c3\u2082\u2083 \u03c3\u2081\u2083) f) n) m) (coeFn.{max (succ u5) (succ u6), max (succ u5) (succ u6)} (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (fun (_x : LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) => N -> P) (LinearMap.hasCoeToFun.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (coeFn.{max (succ u4) (succ (max u5 u6)), max (succ u4) (succ (max u5 u6))} (LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (fun (_x : LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) => M -> (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16)) (LinearMap.hasCoeToFun.{u1, u3, u4, max u5 u6} R R\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083) f m) n)\nbut is expected to have type\n  forall {R : Type.{u4}} [_inst_1 : CommSemiring.{u4} R] {R\u2082 : Type.{u1}} [_inst_2 : CommSemiring.{u1} R\u2082] {R\u2083 : Type.{u3}} [_inst_3 : CommSemiring.{u3} R\u2083] {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\u2082 N (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) _inst_6] [_inst_16 : Module.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7] {\u03c3\u2082\u2083 : RingHom.{u1, u3} R\u2082 R\u2083 (Semiring.toNonAssocSemiring.{u1} R\u2082 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} {\u03c3\u2081\u2083 : RingHom.{u4, u3} R R\u2083 (Semiring.toNonAssocSemiring.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} (f : LinearMap.{u4, u3, u5, max u6 u2} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _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\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 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\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (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\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) => LinearMap.{u1, u3, u2, max u6 u5} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _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\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u1, u3, u2, max u5 u6} R\u2082 R\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2082\u2083) (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\u2083 R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (RingHom.id.{u3} R\u2083 (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (LinearMap.{u4, u3, u5, max u6 u2} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (LinearMap.{u1, u3, u2, max u6 u5} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (LinearMap.addCommMonoid.{u4, u3, u5, max u2 u6} R R\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083) (LinearMap.addCommMonoid.{u1, u3, u2, max u5 u6} R\u2082 R\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2082\u2083) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, max u2 u6} R R\u2083 R\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u1, u3, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (MonoidWithZero.toMonoid.{u3} R\u2083 (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (Module.toDistribMulAction.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))) (MonoidWithZero.toMonoid.{u3} R\u2083 (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (Module.toDistribMulAction.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, max u5 u6} R\u2082 R\u2083 R\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u3, u3, u3, u5, u6} R R\u2083 R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (MonoidWithZero.toMonoid.{u3} R\u2083 (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (Module.toDistribMulAction.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))) (MonoidWithZero.toMonoid.{u3} R\u2083 (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (Module.toDistribMulAction.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))))) (LinearMap.{u4, u3, u5, max u6 u2} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (fun (_x : LinearMap.{u4, u3, u5, max u6 u2} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u4, u3, u5, max u6 u2} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) => LinearMap.{u1, u3, u2, max u6 u5} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) _x) (LinearMap.instFunLikeLinearMap.{u3, u3, max (max u6 u2) u5, max (max u6 u2) u5} R\u2083 R\u2083 (LinearMap.{u4, u3, u5, max u6 u2} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (LinearMap.{u1, u3, u2, max u6 u5} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.addCommMonoid.{u4, u3, u5, max u2 u6} R R\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083) (LinearMap.addCommMonoid.{u1, u3, u2, max u5 u6} R\u2082 R\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2082\u2083) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, max u2 u6} R R\u2083 R\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u1, u3, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (MonoidWithZero.toMonoid.{u3} R\u2083 (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (Module.toDistribMulAction.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))) (MonoidWithZero.toMonoid.{u3} R\u2083 (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (Module.toDistribMulAction.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, max u5 u6} R\u2082 R\u2083 R\u2083 N (LinearMap.{u4, u3, u5, u6} R R\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 (LinearMap.addCommMonoid.{u4, u3, u5, u6} R R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) _inst_15 (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u3, u3, u5, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u3, u3, u3, u5, u6} R R\u2083 R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (MonoidWithZero.toMonoid.{u3} R\u2083 (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (Module.toDistribMulAction.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))) (MonoidWithZero.toMonoid.{u3} R\u2083 (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (Module.toDistribMulAction.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))) (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (RingHom.id.{u3} R\u2083 (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)))) (LinearMap.lflip.{u4, u1, u3, u5, u2, u6} R _inst_1 R\u2082 _inst_2 R\u2083 _inst_3 M N P _inst_5 _inst_6 _inst_7 _inst_14 _inst_15 _inst_16 \u03c3\u2082\u2083 \u03c3\u2081\u2083) 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\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 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\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (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\u2083 (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _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\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u4, u3, u5, max u2 u6} R R\u2083 M (LinearMap.{u1, u3, u2, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u4} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u1, u3, u2, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u3, u3, u2, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7)) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083) f m) n)\nCase conversion may be inaccurate. Consider using '#align linear_map.lflip_apply LinearMap.lflip_apply\u2093'. -/\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\u2097)\n\n#print LinearMap.lcomp /-\n/-- Composing a linear map `M \u2192 N` and a linear map `N \u2192 P` to form a linear map `M \u2192 P`. -/\ndef lcomp (f : M \u2192\u2097[R] N\u2097) : (N\u2097 \u2192\u2097[R] P\u2097) \u2192\u2097[R] M \u2192\u2097[R] P\u2097 :=\n  flip <| LinearMap.comp (flip id) f\n#align linear_map.lcomp LinearMap.lcomp\n-/\n\nvariable {R P\u2097}\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\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (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\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) (x : M), Eq.{succ u4} P\u2097 (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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) => M -> P\u2097) (LinearMap.hasCoeToFun.{u1, u1, u2, u4} R R M P\u2097 (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\u2097 P\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) => N\u2097 -> P\u2097) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 _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\u2097 _inst_5 _inst_10 _inst_14 _inst_19) => M -> N\u2097) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 : Type.{u2}} {P\u2097 : Type.{u1}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_10 : AddCommMonoid.{u2} N\u2097] [_inst_11 : AddCommMonoid.{u1} P\u2097] [_inst_14 : Module.{u4, u3} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_19 : Module.{u4, u2} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u1} R P\u2097 (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\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) (x : M), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P\u2097) 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\u2097 P\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) g) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u3, u1} R R M P\u2097 (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\u2097 P\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u2, u1} R R N\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} P\u2097 (AddCommMonoid.toAddMonoid.{u1} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u1} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u1} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} P\u2097 (AddCommMonoid.toAddMonoid.{u1} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u1} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} P\u2097 (AddCommMonoid.toAddMonoid.{u1} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u1} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u1} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} P\u2097 (AddCommMonoid.toAddMonoid.{u1} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u1} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) N\u2097 (fun (_x : N\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2097) => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u2, u1} R R N\u2097 P\u2097 (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\u2097 _inst_5 _inst_10 _inst_14 _inst_19) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => N\u2097) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u3, u2} R R M N\u2097 (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\u2093'. -/\n@[simp]\ntheorem lcomp_apply (f : M \u2192\u2097[R] N\u2097) (g : N\u2097 \u2192\u2097[R] P\u2097) (x : M) : lcomp R P\u2097 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\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 (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\u2097 : Type.{u2}} {P\u2097 : Type.{u1}} [_inst_5 : AddCommMonoid.{u3} M] [_inst_10 : AddCommMonoid.{u2} N\u2097] [_inst_11 : AddCommMonoid.{u1} P\u2097] [_inst_14 : Module.{u4, u3} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_19 : Module.{u4, u2} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u1} R P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u2, u1} R R N\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} P\u2097 (AddCommMonoid.toAddMonoid.{u1} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u1} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u1} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} P\u2097 (AddCommMonoid.toAddMonoid.{u1} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u1} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} P\u2097 (AddCommMonoid.toAddMonoid.{u1} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u1} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u3, u1} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u1} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u1} P\u2097 (AddCommMonoid.toAddMonoid.{u1} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u1} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 (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'\u2093'. -/\ntheorem lcomp_apply' (f : M \u2192\u2097[R] N\u2097) (g : N\u2097 \u2192\u2097[R] P\u2097) : lcomp R P\u2097 f g = g \u2218\u2097 f :=\n  rfl\n#align linear_map.lcomp_apply' LinearMap.lcomp_apply'\n\nvariable (P \u03c3\u2082\u2083)\n\n#print LinearMap.lcomp\u209b\u2097 /-\n/-- Composing a semilinear map `M \u2192 N` and a semilinear map `N \u2192 P` to form a semilinear map\n`M \u2192 P` is itself a linear map. -/\ndef lcomp\u209b\u2097 (f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] N) : (N \u2192\u209b\u2097[\u03c3\u2082\u2083] P) \u2192\u2097[R\u2083] M \u2192\u209b\u2097[\u03c3\u2081\u2083] P :=\n  flip <| LinearMap.comp (flip id) f\n#align linear_map.lcomp\u209b\u2097 LinearMap.lcomp\u209b\u2097\n-/\n\nvariable {P \u03c3\u2082\u2083}\n\ninclude \u03c3\u2081\u2083\n\n/- warning: linear_map.lcomp\u209b\u2097_apply -> LinearMap.lcomp\u209b\u2097_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R\u2082 : Type.{u2}} [_inst_2 : CommSemiring.{u2} R\u2082] {R\u2083 : Type.{u3}} [_inst_3 : CommSemiring.{u3} R\u2083] {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\u2082 N (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) _inst_6] [_inst_16 : Module.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7] {\u03c3\u2081\u2082 : RingHom.{u1, u2} R R\u2082 (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R\u2082 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2))} {\u03c3\u2082\u2083 : RingHom.{u2, u3} R\u2082 R\u2083 (Semiring.toNonAssocSemiring.{u2} R\u2082 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} {\u03c3\u2081\u2083 : RingHom.{u1, u3} R R\u2083 (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} [_inst_23 : RingHomCompTriple.{u1, u2, u3} R R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083] (f : LinearMap.{u1, u2, u4, u5} R R\u2082 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) \u03c3\u2081\u2082 M N _inst_5 _inst_6 _inst_14 _inst_15) (g : LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 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\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (fun (_x : LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) => M -> P) (LinearMap.hasCoeToFun.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (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\u2083 R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (RingHom.id.{u3} R\u2083 (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lcomp\u209b\u2097._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lcomp\u209b\u2097._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (fun (_x : LinearMap.{u3, u3, max u5 u6, max u4 u6} R\u2083 R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (RingHom.id.{u3} R\u2083 (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))) (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lcomp\u209b\u2097._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lcomp\u209b\u2097._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) => (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) -> (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16)) (LinearMap.hasCoeToFun.{u3, u3, max u5 u6, max u4 u6} R\u2083 R\u2083 (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u1, u3, u4, u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (LinearMap.addCommMonoid.{u1, u3, u4, u6} R R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lcomp\u209b\u2097._proof_1.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (LinearMap.module.{u1, u3, u3, u4, u6} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.lcomp\u209b\u2097._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16)) (RingHom.id.{u3} R\u2083 (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)))) (LinearMap.lcomp\u209b\u2097.{u1, u2, u3, u4, u5, u6} R _inst_1 R\u2082 _inst_2 R\u2083 _inst_3 M N P _inst_5 _inst_6 _inst_7 _inst_14 _inst_15 _inst_16 \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083 _inst_23 f) g) x) (coeFn.{max (succ u5) (succ u6), max (succ u5) (succ u6)} (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (fun (_x : LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) => N -> P) (LinearMap.hasCoeToFun.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) g (coeFn.{max (succ u4) (succ u5), max (succ u4) (succ u5)} (LinearMap.{u1, u2, u4, u5} R R\u2082 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) \u03c3\u2081\u2082 M N _inst_5 _inst_6 _inst_14 _inst_15) (fun (_x : LinearMap.{u1, u2, u4, u5} R R\u2082 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) \u03c3\u2081\u2082 M N _inst_5 _inst_6 _inst_14 _inst_15) => M -> N) (LinearMap.hasCoeToFun.{u1, u2, u4, u5} R R\u2082 M N (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) _inst_5 _inst_6 _inst_14 _inst_15 \u03c3\u2081\u2082) f x))\nbut is expected to have type\n  forall {R : Type.{u6}} [_inst_1 : CommSemiring.{u6} R] {R\u2082 : Type.{u5}} [_inst_2 : CommSemiring.{u5} R\u2082] {R\u2083 : Type.{u2}} [_inst_3 : CommSemiring.{u2} R\u2083] {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\u2082 N (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) _inst_6] [_inst_16 : Module.{u2, u1} R\u2083 P (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_7] {\u03c3\u2081\u2082 : RingHom.{u6, u5} R R\u2082 (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (Semiring.toNonAssocSemiring.{u5} R\u2082 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2))} {\u03c3\u2082\u2083 : RingHom.{u5, u2} R\u2082 R\u2083 (Semiring.toNonAssocSemiring.{u5} R\u2082 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2)) (Semiring.toNonAssocSemiring.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3))} {\u03c3\u2081\u2083 : RingHom.{u6, u2} R R\u2083 (Semiring.toNonAssocSemiring.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3))} [_inst_23 : RingHomCompTriple.{u6, u5, u2} R R\u2082 R\u2083 (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083] (f : LinearMap.{u6, u5, u4, u3} R R\u2082 (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) \u03c3\u2081\u2082 M N _inst_5 _inst_6 _inst_14 _inst_15) (g : LinearMap.{u5, u2, u3, u1} R\u2082 R\u2083 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 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\u2082 R\u2083 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) => LinearMap.{u6, u2, u4, u1} R R\u2083 (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2081\u2083 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\u2083 M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (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\u2083 R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) (RingHom.id.{u2} R\u2083 (Semiring.toNonAssocSemiring.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3))) (LinearMap.{u5, u2, u3, u1} R\u2082 R\u2083 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u6, u2, u4, u1} R R\u2083 (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (LinearMap.addCommMonoid.{u5, u2, u3, u1} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (LinearMap.addCommMonoid.{u6, u2, u4, u1} R R\u2083 M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u2, u2, u3, u1} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u2, u1} R\u2083 P (CommSemiring.toCommMonoid.{u2} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u2, u1} R\u2083 P (Semiring.toMonoidWithZero.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3)) (AddMonoid.toZero.{u1} P (AddCommMonoid.toAddMonoid.{u1} P _inst_7)) (Module.toMulActionWithZero.{u2, u1} R\u2083 P (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_7 _inst_16)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u2, u2, u4, u1} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u2, u1} R\u2083 P (CommSemiring.toCommMonoid.{u2} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u2, u1} R\u2083 P (Semiring.toMonoidWithZero.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3)) (AddMonoid.toZero.{u1} P (AddCommMonoid.toAddMonoid.{u1} P _inst_7)) (Module.toMulActionWithZero.{u2, u1} R\u2083 P (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_7 _inst_16))))) (LinearMap.{u5, u2, u3, u1} R\u2082 R\u2083 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (fun (_x : LinearMap.{u5, u2, u3, u1} R\u2082 R\u2083 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : LinearMap.{u5, u2, u3, u1} R\u2082 R\u2083 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) => LinearMap.{u6, u2, u4, u1} R R\u2083 (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u2, u2, max u3 u1, max u4 u1} R\u2083 R\u2083 (LinearMap.{u5, u2, u3, u1} R\u2082 R\u2083 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (LinearMap.{u6, u2, u4, u1} R R\u2083 (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2081\u2083 M P _inst_5 _inst_7 _inst_14 _inst_16) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) (LinearMap.addCommMonoid.{u5, u2, u3, u1} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (LinearMap.addCommMonoid.{u6, u2, u4, u1} R R\u2083 M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083) (LinearMap.instModuleLinearMapAddCommMonoid.{u5, u2, u2, u3, u1} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u2, u1} R\u2083 P (CommSemiring.toCommMonoid.{u2} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u2, u1} R\u2083 P (Semiring.toMonoidWithZero.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3)) (AddMonoid.toZero.{u1} P (AddCommMonoid.toAddMonoid.{u1} P _inst_7)) (Module.toMulActionWithZero.{u2, u1} R\u2083 P (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_7 _inst_16)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u6, u2, u2, u4, u1} R R\u2083 R\u2083 M P (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_5 _inst_7 _inst_14 _inst_16 \u03c3\u2081\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u2, u1} R\u2083 P (CommSemiring.toCommMonoid.{u2} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u2, u1} R\u2083 P (Semiring.toMonoidWithZero.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3)) (AddMonoid.toZero.{u1} P (AddCommMonoid.toAddMonoid.{u1} P _inst_7)) (Module.toMulActionWithZero.{u2, u1} R\u2083 P (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_7 _inst_16)))) (RingHom.id.{u2} R\u2083 (Semiring.toNonAssocSemiring.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3)))) (LinearMap.lcomp\u209b\u2097.{u6, u5, u2, u4, u3, u1} R _inst_1 R\u2082 _inst_2 R\u2083 _inst_3 M N P _inst_5 _inst_6 _inst_7 _inst_14 _inst_15 _inst_16 \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083 _inst_23 f) g) x) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (LinearMap.{u5, u2, u3, u1} R\u2082 R\u2083 (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 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\u2082 R\u2083 N P (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) g (FunLike.coe.{max (succ u4) (succ u3), succ u4, succ u3} (LinearMap.{u6, u5, u4, u3} R R\u2082 (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) \u03c3\u2081\u2082 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\u2082 M N (CommSemiring.toSemiring.{u6} R _inst_1) (CommSemiring.toSemiring.{u5} R\u2082 _inst_2) _inst_5 _inst_6 _inst_14 _inst_15 \u03c3\u2081\u2082) f x))\nCase conversion may be inaccurate. Consider using '#align linear_map.lcomp\u209b\u2097_apply LinearMap.lcomp\u209b\u2097_apply\u2093'. -/\n@[simp]\ntheorem lcomp\u209b\u2097_apply (f : M \u2192\u209b\u2097[\u03c3\u2081\u2082] N) (g : N \u2192\u209b\u2097[\u03c3\u2082\u2083] P) (x : M) :\n    lcomp\u209b\u2097 P \u03c3\u2082\u2083 f g x = g (f x) :=\n  rfl\n#align linear_map.lcomp\u209b\u2097_apply LinearMap.lcomp\u209b\u2097_apply\n\nomit \u03c3\u2081\u2083\n\nvariable (R M N\u2097 P\u2097)\n\n#print LinearMap.llcomp /-\n/-- Composing a linear map `M \u2192 N` and a linear map `N \u2192 P` to form a linear map `M \u2192 P`. -/\ndef llcomp : (N\u2097 \u2192\u2097[R] P\u2097) \u2192\u2097[R] (M \u2192\u2097[R] N\u2097) \u2192\u2097[R] M \u2192\u2097[R] P\u2097 :=\n  flip\n    { toFun := lcomp R P\u2097\n      map_add' := fun f f' => ext\u2082 fun g x => g.map_add _ _\n      map_smul' := fun (c : R) f => ext\u2082 fun g x => g.map_smul _ _ }\n#align linear_map.llcomp LinearMap.llcomp\n-/\n\nvariable {R M N\u2097 P\u2097}\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\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (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\u2097 P\u2097 _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\u2097 _inst_5 _inst_10 _inst_14 _inst_19) (x : M), Eq.{succ u4} P\u2097 (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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) => M -> P\u2097) (LinearMap.hasCoeToFun.{u1, u1, u2, u4} R R M P\u2097 (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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _inst_11 _inst_20))) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _inst_11 _inst_20))) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) => N\u2097 -> P\u2097) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 _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\u2097 _inst_5 _inst_10 _inst_14 _inst_19) => M -> N\u2097) (LinearMap.hasCoeToFun.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 : Type.{u3}} {P\u2097 : Type.{u2}} [_inst_5 : AddCommMonoid.{u1} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u2} P\u2097] [_inst_14 : Module.{u4, u1} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_19 : Module.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 _inst_5 _inst_10 _inst_14 _inst_19) (x : M), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P\u2097) 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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) g) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u1, u2} R R M P\u2097 (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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (LinearMap.addCommMonoid.{u4, u4, u3, u2} R R N\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u4, u4, u4, u1, u2} R R R R M P\u2097 (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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u4, u4, u4, u1, u2} R R R R M P\u2097 (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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) N\u2097 (fun (_x : N\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2097) => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u3, u2} R R N\u2097 P\u2097 (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\u2097 _inst_5 _inst_10 _inst_14 _inst_19) M (fun (_x : M) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M) => N\u2097) _x) (LinearMap.instFunLikeLinearMap.{u4, u4, u1, u3} R R M N\u2097 (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\u2093'. -/\n@[simp]\ntheorem llcomp_apply (f : N\u2097 \u2192\u2097[R] P\u2097) (g : M \u2192\u2097[R] N\u2097) (x : M) :\n    llcomp R M N\u2097 P\u2097 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\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (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\u2097 P\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _inst_11 _inst_20))) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _inst_11 _inst_20))) (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u1, u1, u2, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 _inst_10 _inst_19)) (LinearMap.module.{u1, u1, u1, u2, u4} R R R M P\u2097 (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\u2097 _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\u2097 (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\u2097 _inst_11 _inst_20)) (LinearMap.llcomp._proof_4.{u1, u4, u2} R _inst_1 M P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 (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\u2097 : Type.{u3}} {P\u2097 : Type.{u2}} [_inst_5 : AddCommMonoid.{u1} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u2} P\u2097] [_inst_14 : Module.{u4, u1} R M (CommSemiring.toSemiring.{u4} R _inst_1) _inst_5] [_inst_19 : Module.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (LinearMap.addCommMonoid.{u4, u4, u3, u2} R R N\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u4, u4, u4, u1, u2} R R R R M P\u2097 (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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 _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\u2097 _inst_5 _inst_11 _inst_14 _inst_20) (LinearMap.addCommMonoid.{u4, u4, u1, u3} R R M N\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 _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\u2097 _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\u2097 (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\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u3} R N\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u3} N\u2097 (AddCommMonoid.toAddMonoid.{u3} N\u2097 _inst_10)) (Module.toMulActionWithZero.{u4, u3} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)))) (LinearMap.instModuleLinearMapAddCommMonoid.{u4, u4, u4, u1, u2} R R R M P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20)))) (LinearMap.instSMulCommClassLinearMapInstSMulLinearMapInstSMulLinearMap.{u4, u4, u4, u4, u1, u2} R R R R M P\u2097 (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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))) (smulCommClass_self.{u4, u2} R P\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 (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'\u2093'. -/\ntheorem llcomp_apply' (f : N\u2097 \u2192\u2097[R] P\u2097) (g : M \u2192\u2097[R] N\u2097) : llcomp R M N\u2097 P\u2097 f g = f \u2218\u2097 g :=\n  rfl\n#align linear_map.llcomp_apply' LinearMap.llcomp_apply'\n\nend\n\n#print LinearMap.compl\u2082 /-\n/-- Composing a linear map `Q \u2192 N` and a bilinear map `M \u2192 N \u2192 P` to\nform a bilinear map `M \u2192 Q \u2192 P`. -/\ndef compl\u2082 (g : Q \u2192\u209b\u2097[\u03c3\u2084\u2082] N) : M \u2192\u209b\u2097[\u03c3\u2081\u2083] Q \u2192\u209b\u2097[\u03c3\u2084\u2083] P :=\n  (lcomp\u209b\u2097 _ _ g).comp f\n#align linear_map.compl\u2082 LinearMap.compl\u2082\n-/\n\ninclude \u03c3\u2084\u2083\n\n/- warning: linear_map.compl\u2082_apply -> LinearMap.compl\u2082_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R\u2082 : Type.{u2}} [_inst_2 : CommSemiring.{u2} R\u2082] {R\u2083 : Type.{u3}} [_inst_3 : CommSemiring.{u3} R\u2083] {R\u2084 : Type.{u4}} [_inst_4 : CommSemiring.{u4} R\u2084] {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\u2082 N (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) _inst_6] [_inst_16 : Module.{u3, u7} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7] [_inst_17 : Module.{u4, u8} R\u2084 Q (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) _inst_8] {\u03c3\u2082\u2083 : RingHom.{u2, u3} R\u2082 R\u2083 (Semiring.toNonAssocSemiring.{u2} R\u2082 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} {\u03c3\u2081\u2083 : RingHom.{u1, u3} R R\u2083 (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} {\u03c3\u2084\u2082 : RingHom.{u4, u2} R\u2084 R\u2082 (Semiring.toNonAssocSemiring.{u4} R\u2084 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4)) (Semiring.toNonAssocSemiring.{u2} R\u2082 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2))} {\u03c3\u2084\u2083 : RingHom.{u4, u3} R\u2084 R\u2083 (Semiring.toNonAssocSemiring.{u4} R\u2084 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} [_inst_24 : RingHomCompTriple.{u4, u2, u3} R\u2084 R\u2082 R\u2083 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2082 \u03c3\u2082\u2083 \u03c3\u2084\u2083] (f : LinearMap.{u1, u3, u5, max u6 u7} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u6, u7} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u6, u7} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u6, u7} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u7} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u7} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (g : LinearMap.{u4, u2, u8, u6} R\u2084 R\u2082 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) \u03c3\u2084\u2082 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\u2084 R\u2083 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16) (fun (_x : LinearMap.{u4, u3, u8, u7} R\u2084 R\u2083 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16) => Q -> P) (LinearMap.hasCoeToFun.{u4, u3, u8, u7} R\u2084 R\u2083 Q P (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083) (coeFn.{max (succ u5) (succ (max u8 u7)), max (succ u5) (succ (max u8 u7))} (LinearMap.{u1, u3, u5, max u8 u7} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u4, u3, u8, u7} R\u2084 R\u2083 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u4, u3, u8, u7} R\u2084 R\u2083 Q P (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083) _inst_14 (LinearMap.module.{u4, u3, u3, u8, u7} R\u2084 R\u2083 R\u2083 Q P (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.compl\u2082._proof_2.{u3, u7} R\u2083 _inst_3 P _inst_7 _inst_16))) (fun (_x : LinearMap.{u1, u3, u5, max u8 u7} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u4, u3, u8, u7} R\u2084 R\u2083 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u4, u3, u8, u7} R\u2084 R\u2083 Q P (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083) _inst_14 (LinearMap.module.{u4, u3, u3, u8, u7} R\u2084 R\u2083 R\u2083 Q P (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.compl\u2082._proof_2.{u3, u7} R\u2083 _inst_3 P _inst_7 _inst_16))) => M -> (LinearMap.{u4, u3, u8, u7} R\u2084 R\u2083 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u8 u7} R R\u2083 M (LinearMap.{u4, u3, u8, u7} R\u2084 R\u2083 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u4, u3, u8, u7} R\u2084 R\u2083 Q P (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083) _inst_14 (LinearMap.module.{u4, u3, u3, u8, u7} R\u2084 R\u2083 R\u2083 Q P (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.compl\u2082._proof_2.{u3, u7} R\u2083 _inst_3 P _inst_7 _inst_16)) \u03c3\u2081\u2083) (LinearMap.compl\u2082.{u1, u2, u3, u4, u5, u6, u7, u8} R _inst_1 R\u2082 _inst_2 R\u2083 _inst_3 R\u2084 _inst_4 M N P Q _inst_5 _inst_6 _inst_7 _inst_8 _inst_14 _inst_15 _inst_16 _inst_17 \u03c3\u2082\u2083 \u03c3\u2081\u2083 \u03c3\u2084\u2082 \u03c3\u2084\u2083 _inst_24 f g) m) q) (coeFn.{max (succ u6) (succ u7), max (succ u6) (succ u7)} (LinearMap.{u2, u3, u6, u7} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (fun (_x : LinearMap.{u2, u3, u6, u7} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) => N -> P) (LinearMap.hasCoeToFun.{u2, u3, u6, u7} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (coeFn.{max (succ u5) (succ (max u6 u7)), max (succ u5) (succ (max u6 u7))} (LinearMap.{u1, u3, u5, max u6 u7} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u6, u7} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u6, u7} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u6, u7} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u7} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u7} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (fun (_x : LinearMap.{u1, u3, u5, max u6 u7} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u6, u7} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u6, u7} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u6, u7} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u7} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u7} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) => M -> (LinearMap.{u2, u3, u6, u7} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16)) (LinearMap.hasCoeToFun.{u1, u3, u5, max u6 u7} R R\u2083 M (LinearMap.{u2, u3, u6, u7} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u6, u7} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u6, u7} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u7} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u7} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u7} P (AddMonoid.toAddZeroClass.{u7} P (AddCommMonoid.toAddMonoid.{u7} P _inst_7))) (Module.toMulActionWithZero.{u3, u7} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083) f m) (coeFn.{max (succ u8) (succ u6), max (succ u8) (succ u6)} (LinearMap.{u4, u2, u8, u6} R\u2084 R\u2082 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) \u03c3\u2084\u2082 Q N _inst_8 _inst_6 _inst_17 _inst_15) (fun (_x : LinearMap.{u4, u2, u8, u6} R\u2084 R\u2082 (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) \u03c3\u2084\u2082 Q N _inst_8 _inst_6 _inst_17 _inst_15) => Q -> N) (LinearMap.hasCoeToFun.{u4, u2, u8, u6} R\u2084 R\u2082 Q N (CommSemiring.toSemiring.{u4} R\u2084 _inst_4) (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) _inst_8 _inst_6 _inst_17 _inst_15 \u03c3\u2084\u2082) g q))\nbut is expected to have type\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R\u2082 : Type.{u7}} [_inst_2 : CommSemiring.{u7} R\u2082] {R\u2083 : Type.{u3}} [_inst_3 : CommSemiring.{u3} R\u2083] {R\u2084 : Type.{u8}} [_inst_4 : CommSemiring.{u8} R\u2084] {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\u2082 N (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) _inst_6] [_inst_16 : Module.{u3, u4} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7] [_inst_17 : Module.{u8, u6} R\u2084 Q (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) _inst_8] {\u03c3\u2082\u2083 : RingHom.{u7, u3} R\u2082 R\u2083 (Semiring.toNonAssocSemiring.{u7} R\u2082 (CommSemiring.toSemiring.{u7} R\u2082 _inst_2)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} {\u03c3\u2081\u2083 : RingHom.{u1, u3} R R\u2083 (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} {\u03c3\u2084\u2082 : RingHom.{u8, u7} R\u2084 R\u2082 (Semiring.toNonAssocSemiring.{u8} R\u2084 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4)) (Semiring.toNonAssocSemiring.{u7} R\u2082 (CommSemiring.toSemiring.{u7} R\u2082 _inst_2))} {\u03c3\u2084\u2083 : RingHom.{u8, u3} R\u2084 R\u2083 (Semiring.toNonAssocSemiring.{u8} R\u2084 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} [_inst_24 : RingHomCompTriple.{u8, u7, u3} R\u2084 R\u2082 R\u2083 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2082 \u03c3\u2082\u2083 \u03c3\u2084\u2083] (f : LinearMap.{u1, u3, u2, max u4 u5} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u7, u3, u5, u4} R\u2082 R\u2083 (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u7, u3, u5, u4} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u3, u3, u5, u4} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))) (g : LinearMap.{u8, u7, u6, u5} R\u2084 R\u2082 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) \u03c3\u2084\u2082 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\u2084 R\u2083 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 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\u2084 R\u2083 Q P (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083) (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\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u8, u3, u6, u4} R\u2084 R\u2083 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u8, u3, u6, u4} R\u2084 R\u2083 Q P (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u8, u3, u3, u6, u4} R\u2084 R\u2083 R\u2083 Q P (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _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\u2084 R\u2083 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u1, u3, u2, max u4 u6} R R\u2083 M (LinearMap.{u8, u3, u6, u4} R\u2084 R\u2083 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2084\u2083 Q P _inst_8 _inst_7 _inst_17 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u8, u3, u6, u4} R\u2084 R\u2083 Q P (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u8, u3, u3, u6, u4} R\u2084 R\u2083 R\u2083 Q P (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_8 _inst_7 _inst_17 _inst_16 \u03c3\u2084\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083) (LinearMap.compl\u2082.{u1, u7, u3, u8, u2, u5, u4, u6} R _inst_1 R\u2082 _inst_2 R\u2083 _inst_3 R\u2084 _inst_4 M N P Q _inst_5 _inst_6 _inst_7 _inst_8 _inst_14 _inst_15 _inst_16 _inst_17 \u03c3\u2082\u2083 \u03c3\u2081\u2083 \u03c3\u2084\u2082 \u03c3\u2084\u2083 _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\u2082 R\u2083 (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 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\u2082 R\u2083 N P (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) (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\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u7, u3, u5, u4} R\u2082 R\u2083 (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u7, u3, u5, u4} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u3, u3, u5, u4} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _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\u2082 R\u2083 (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _x) (LinearMap.instFunLikeLinearMap.{u1, u3, u2, max u5 u4} R R\u2083 M (LinearMap.{u7, u3, u5, u4} R\u2082 R\u2083 (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_5 (LinearMap.addCommMonoid.{u7, u3, u5, u4} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u7, u3, u3, u5, u4} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u4} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u4} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u3, u4} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16)))) \u03c3\u2081\u2083) f m) (FunLike.coe.{max (succ u5) (succ u6), succ u6, succ u5} (LinearMap.{u8, u7, u6, u5} R\u2084 R\u2082 (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) \u03c3\u2084\u2082 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\u2084 R\u2082 Q N (CommSemiring.toSemiring.{u8} R\u2084 _inst_4) (CommSemiring.toSemiring.{u7} R\u2082 _inst_2) _inst_8 _inst_6 _inst_17 _inst_15 \u03c3\u2084\u2082) g q))\nCase conversion may be inaccurate. Consider using '#align linear_map.compl\u2082_apply LinearMap.compl\u2082_apply\u2093'. -/\n@[simp]\ntheorem compl\u2082_apply (g : Q \u2192\u209b\u2097[\u03c3\u2084\u2082] N) (m : M) (q : Q) : f.compl\u2082 g m q = f m (g q) :=\n  rfl\n#align linear_map.compl\u2082_apply LinearMap.compl\u2082_apply\n\nomit \u03c3\u2084\u2083\n\n/- warning: linear_map.compl\u2082_id -> LinearMap.compl\u2082_id is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {R\u2082 : Type.{u2}} [_inst_2 : CommSemiring.{u2} R\u2082] {R\u2083 : Type.{u3}} [_inst_3 : CommSemiring.{u3} R\u2083] {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\u2082 N (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) _inst_6] [_inst_16 : Module.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7] {\u03c3\u2082\u2083 : RingHom.{u2, u3} R\u2082 R\u2083 (Semiring.toNonAssocSemiring.{u2} R\u2082 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} {\u03c3\u2081\u2083 : RingHom.{u1, u3} R R\u2083 (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (Semiring.toNonAssocSemiring.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3))} (f : LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u3, u6} R\u2083 P (CommSemiring.toCommMonoid.{u3} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u3, u6} R\u2083 P (Semiring.toMonoidWithZero.{u3} R\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3)) (AddZeroClass.toHasZero.{u6} P (AddMonoid.toAddZeroClass.{u6} P (AddCommMonoid.toAddMonoid.{u6} P _inst_7))) (Module.toMulActionWithZero.{u3, u6} R\u2083 P (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_7 _inst_16))))), Eq.{max (succ u4) (succ (max u5 u6))} (LinearMap.{u1, u3, u4, max u5 u6} R R\u2083 (CommSemiring.toSemiring.{u1} R _inst_1) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u2, u3, u5, u6} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u2, u3, u5, u6} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.module.{u2, u3, u3, u5, u6} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) _inst_16 (LinearMap.compl\u2082._proof_2.{u3, u6} R\u2083 _inst_3 P _inst_7 _inst_16))) (LinearMap.compl\u2082.{u1, u2, u3, u2, u4, u5, u6, u5} R _inst_1 R\u2082 _inst_2 R\u2083 _inst_3 R\u2082 _inst_2 M N P N _inst_5 _inst_6 _inst_7 _inst_6 _inst_14 _inst_15 _inst_16 _inst_15 \u03c3\u2082\u2083 \u03c3\u2081\u2083 (RingHom.id.{u2} R\u2082 (Semiring.toNonAssocSemiring.{u2} R\u2082 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2))) \u03c3\u2082\u2083 (RingHomCompTriple.ids.{u2, u3} R\u2082 R\u2083 (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) (CommSemiring.toSemiring.{u3} R\u2083 _inst_3) \u03c3\u2082\u2083) f (LinearMap.id.{u2, u5} R\u2082 N (CommSemiring.toSemiring.{u2} R\u2082 _inst_2) _inst_6 _inst_15)) f\nbut is expected to have type\n  forall {R : Type.{u3}} [_inst_1 : CommSemiring.{u3} R] {R\u2082 : Type.{u1}} [_inst_2 : CommSemiring.{u1} R\u2082] {R\u2083 : Type.{u2}} [_inst_3 : CommSemiring.{u2} R\u2083] {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\u2082 N (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) _inst_6] [_inst_16 : Module.{u2, u4} R\u2083 P (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_7] {\u03c3\u2082\u2083 : RingHom.{u1, u2} R\u2082 R\u2083 (Semiring.toNonAssocSemiring.{u1} R\u2082 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2)) (Semiring.toNonAssocSemiring.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3))} {\u03c3\u2081\u2083 : RingHom.{u3, u2} R R\u2083 (Semiring.toNonAssocSemiring.{u3} R (CommSemiring.toSemiring.{u3} R _inst_1)) (Semiring.toNonAssocSemiring.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3))} (f : LinearMap.{u3, u2, u6, max u4 u5} R R\u2083 (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u2, u5, u4} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u2, u5, u4} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u2, u2, u5, u4} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u2, u4} R\u2083 P (CommSemiring.toCommMonoid.{u2} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u2, u4} R\u2083 P (Semiring.toMonoidWithZero.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u2, u4} R\u2083 P (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_7 _inst_16))))), Eq.{max (max (succ u6) (succ u5)) (succ u4)} (LinearMap.{u3, u2, u6, max u4 u5} R R\u2083 (CommSemiring.toSemiring.{u3} R _inst_1) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2081\u2083 M (LinearMap.{u1, u2, u5, u4} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083 N P _inst_6 _inst_7 _inst_15 _inst_16) _inst_5 (LinearMap.addCommMonoid.{u1, u2, u5, u4} R\u2082 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083) _inst_14 (LinearMap.instModuleLinearMapAddCommMonoid.{u1, u2, u2, u5, u4} R\u2082 R\u2083 R\u2083 N P (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_6 _inst_7 _inst_15 _inst_16 \u03c3\u2082\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_16 (smulCommClass_self.{u2, u4} R\u2083 P (CommSemiring.toCommMonoid.{u2} R\u2083 _inst_3) (MulActionWithZero.toMulAction.{u2, u4} R\u2083 P (Semiring.toMonoidWithZero.{u2} R\u2083 (CommSemiring.toSemiring.{u2} R\u2083 _inst_3)) (AddMonoid.toZero.{u4} P (AddCommMonoid.toAddMonoid.{u4} P _inst_7)) (Module.toMulActionWithZero.{u2, u4} R\u2083 P (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) _inst_7 _inst_16))))) (LinearMap.compl\u2082.{u3, u1, u2, u1, u6, u5, u4, u5} R _inst_1 R\u2082 _inst_2 R\u2083 _inst_3 R\u2082 _inst_2 M N P N _inst_5 _inst_6 _inst_7 _inst_6 _inst_14 _inst_15 _inst_16 _inst_15 \u03c3\u2082\u2083 \u03c3\u2081\u2083 (RingHom.id.{u1} R\u2082 (Semiring.toNonAssocSemiring.{u1} R\u2082 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2))) \u03c3\u2082\u2083 (RingHomCompTriple.ids.{u1, u2} R\u2082 R\u2083 (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) (CommSemiring.toSemiring.{u2} R\u2083 _inst_3) \u03c3\u2082\u2083) f (LinearMap.id.{u1, u5} R\u2082 N (CommSemiring.toSemiring.{u1} R\u2082 _inst_2) _inst_6 _inst_15)) f\nCase conversion may be inaccurate. Consider using '#align linear_map.compl\u2082_id LinearMap.compl\u2082_id\u2093'. -/\n@[simp]\ntheorem compl\u2082_id : f.compl\u2082 LinearMap.id = f :=\n  by\n  ext\n  rw [compl\u2082_apply, id_coe, id.def]\n#align linear_map.compl\u2082_id LinearMap.compl\u2082_id\n\n#print LinearMap.compl\u2081\u2082 /-\n/-- Composing linear maps `Q \u2192 M` and `Q' \u2192 N` with a bilinear map `M \u2192 N \u2192 P` to\nform a bilinear map `Q \u2192 Q' \u2192 P`. -/\ndef compl\u2081\u2082 (f : M\u2097 \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) (g : Q\u2097 \u2192\u2097[R] M\u2097) (g' : Q\u2097' \u2192\u2097[R] N\u2097) :\n    Q\u2097 \u2192\u2097[R] Q\u2097' \u2192\u2097[R] P\u2097 :=\n  (f.comp g).compl\u2082 g'\n#align linear_map.compl\u2081\u2082 LinearMap.compl\u2081\u2082\n-/\n\n/- warning: linear_map.compl\u2081\u2082_apply -> LinearMap.compl\u2081\u2082_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M\u2097 : Type.{u2}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} {Q\u2097 : Type.{u5}} {Q\u2097' : Type.{u6}} [_inst_9 : AddCommMonoid.{u2} M\u2097] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_12 : AddCommMonoid.{u5} Q\u2097] [_inst_13 : AddCommMonoid.{u6} Q\u2097'] [_inst_18 : Module.{u1, u2} R M\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] [_inst_21 : Module.{u1, u5} R Q\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_12] [_inst_22 : Module.{u1, u6} R Q\u2097' (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 M\u2097 _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\u2097' N\u2097 _inst_13 _inst_10 _inst_22 _inst_19) (x : Q\u2097) (y : Q\u2097'), Eq.{succ u4} P\u2097 (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\u2097' P\u2097 _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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20) => Q\u2097' -> P\u2097) (LinearMap.hasCoeToFun.{u1, u1, u6, u4} R R Q\u2097' P\u2097 (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\u2097 (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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u1, u1, u6, u4} R R Q\u2097' P\u2097 (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\u2097' P\u2097 (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\u2081\u2082._proof_2.{u1, u4} R _inst_1 P\u2097 _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\u2097 (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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u1, u1, u6, u4} R R Q\u2097' P\u2097 (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\u2097' P\u2097 (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\u2081\u2082._proof_2.{u1, u4} R _inst_1 P\u2097 _inst_11 _inst_20))) => Q\u2097 -> (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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, u5, max u6 u4} R R Q\u2097 (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\u2097' P\u2097 _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\u2097' P\u2097 (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\u2097' P\u2097 (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\u2081\u2082._proof_2.{u1, u4} R _inst_1 P\u2097 _inst_11 _inst_20)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.compl\u2081\u2082.{u1, u2, u3, u4, u5, u6} R _inst_1 M\u2097 N\u2097 P\u2097 Q\u2097 Q\u2097' _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\u2097 P\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) => N\u2097 -> P\u2097) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) => M\u2097 -> (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20)) (LinearMap.hasCoeToFun.{u1, u1, u2, max u3 u4} R R M\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 M\u2097 _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\u2097 M\u2097 _inst_12 _inst_9 _inst_21 _inst_18) => Q\u2097 -> M\u2097) (LinearMap.hasCoeToFun.{u1, u1, u5, u2} R R Q\u2097 M\u2097 (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\u2097' N\u2097 _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\u2097' N\u2097 _inst_13 _inst_10 _inst_22 _inst_19) => Q\u2097' -> N\u2097) (LinearMap.hasCoeToFun.{u1, u1, u6, u3} R R Q\u2097' N\u2097 (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\u2097 : Type.{u5}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} {Q\u2097 : Type.{u2}} {Q\u2097' : Type.{u1}} [_inst_9 : AddCommMonoid.{u5} M\u2097] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_12 : AddCommMonoid.{u2} Q\u2097] [_inst_13 : AddCommMonoid.{u1} Q\u2097'] [_inst_18 : Module.{u6, u5} R M\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_9] [_inst_19 : Module.{u6, u3} R N\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10] [_inst_20 : Module.{u6, u4} R P\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11] [_inst_21 : Module.{u6, u2} R Q\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_12] [_inst_22 : Module.{u6, u1} R Q\u2097' (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (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\u2097 M\u2097 _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\u2097' N\u2097 _inst_13 _inst_10 _inst_22 _inst_19) (x : Q\u2097) (y : Q\u2097'), Eq.{succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097') => P\u2097) y) (FunLike.coe.{max (succ u4) (succ u1), succ u1, succ u4} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097) => 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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20) x) Q\u2097' (fun (_x : Q\u2097') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097') => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u1, u4} R R Q\u2097' P\u2097 (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\u2097 (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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u6, u6, u1, u4} R R Q\u2097' P\u2097 (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\u2097' P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) Q\u2097 (fun (_x : Q\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097) => 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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u2, max u4 u1} R R Q\u2097 (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\u2097' P\u2097 _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\u2097' P\u2097 (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\u2097' P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (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\u2081\u2082.{u6, u5, u3, u4, u2, u1} R _inst_1 M\u2097 N\u2097 P\u2097 Q\u2097 Q\u2097' _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\u2097) => 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\u2097 P\u2097 _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\u2097 M\u2097 _inst_12 _inst_9 _inst_21 _inst_18) Q\u2097 (fun (a : Q\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097) => M\u2097) a) (LinearMap.instFunLikeLinearMap.{u6, u6, u2, u5} R R Q\u2097 M\u2097 (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\u2097 (fun (_x : N\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2097) => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u3, u4} R R N\u2097 P\u2097 (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) M\u2097 (fun (_x : M\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : M\u2097) => 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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u5, max u3 u4} R R M\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (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\u2097 M\u2097 _inst_12 _inst_9 _inst_21 _inst_18) Q\u2097 (fun (_x : Q\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097) => M\u2097) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u2, u5} R R Q\u2097 M\u2097 (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\u2097' N\u2097 _inst_13 _inst_10 _inst_22 _inst_19) Q\u2097' (fun (_x : Q\u2097') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097') => N\u2097) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u1, u3} R R Q\u2097' N\u2097 (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\u2081\u2082_apply LinearMap.compl\u2081\u2082_apply\u2093'. -/\n@[simp]\ntheorem compl\u2081\u2082_apply (f : M\u2097 \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) (g : Q\u2097 \u2192\u2097[R] M\u2097) (g' : Q\u2097' \u2192\u2097[R] N\u2097) (x : Q\u2097)\n    (y : Q\u2097') : f.compl\u2081\u2082 g g' x y = f (g x) (g' y) :=\n  rfl\n#align linear_map.compl\u2081\u2082_apply LinearMap.compl\u2081\u2082_apply\n\n/- warning: linear_map.compl\u2081\u2082_id_id -> LinearMap.compl\u2081\u2082_id_id is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M\u2097 : Type.{u2}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} [_inst_9 : AddCommMonoid.{u2} M\u2097] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_18 : Module.{u1, u2} R M\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2081\u2082._proof_2.{u1, u4} R _inst_1 P\u2097 _inst_11 _inst_20))) (LinearMap.compl\u2081\u2082.{u1, u2, u3, u4, u2, u3} R _inst_1 M\u2097 N\u2097 P\u2097 M\u2097 N\u2097 _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\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9 _inst_18) (LinearMap.id.{u1, u3} R N\u2097 (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\u2097 : Type.{u3}} {N\u2097 : Type.{u1}} {P\u2097 : Type.{u2}} [_inst_9 : AddCommMonoid.{u3} M\u2097] [_inst_10 : AddCommMonoid.{u1} N\u2097] [_inst_11 : AddCommMonoid.{u2} P\u2097] [_inst_18 : Module.{u4, u3} R M\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_9] [_inst_19 : Module.{u4, u1} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10] [_inst_20 : Module.{u4, u2} R P\u2097 (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u4, u4, u1, u2} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u4} R _inst_1) (MulActionWithZero.toMulAction.{u4, u2} R P\u2097 (Semiring.toMonoidWithZero.{u4} R (CommSemiring.toSemiring.{u4} R _inst_1)) (AddMonoid.toZero.{u2} P\u2097 (AddCommMonoid.toAddMonoid.{u2} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u4, u2} R P\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_11 _inst_20))))) (LinearMap.compl\u2081\u2082.{u4, u3, u1, u2, u3, u1} R _inst_1 M\u2097 N\u2097 P\u2097 M\u2097 N\u2097 _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\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_9 _inst_18) (LinearMap.id.{u4, u1} R N\u2097 (CommSemiring.toSemiring.{u4} R _inst_1) _inst_10 _inst_19)) f\nCase conversion may be inaccurate. Consider using '#align linear_map.compl\u2081\u2082_id_id LinearMap.compl\u2081\u2082_id_id\u2093'. -/\n@[simp]\ntheorem compl\u2081\u2082_id_id (f : M\u2097 \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) : f.compl\u2081\u2082 LinearMap.id LinearMap.id = f :=\n  by\n  ext\n  simp_rw [compl\u2081\u2082_apply, id_coe, id.def]\n#align linear_map.compl\u2081\u2082_id_id LinearMap.compl\u2081\u2082_id_id\n\n/- warning: linear_map.compl\u2081\u2082_inj -> LinearMap.compl\u2081\u2082_inj is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M\u2097 : Type.{u2}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} {Q\u2097 : Type.{u5}} {Q\u2097' : Type.{u6}} [_inst_9 : AddCommMonoid.{u2} M\u2097] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_12 : AddCommMonoid.{u5} Q\u2097] [_inst_13 : AddCommMonoid.{u6} Q\u2097'] [_inst_18 : Module.{u1, u2} R M\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_9] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] [_inst_21 : Module.{u1, u5} R Q\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_12] [_inst_22 : Module.{u1, u6} R Q\u2097' (CommSemiring.toSemiring.{u1} R _inst_1) _inst_13] {f\u2081 : 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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))} {f\u2082 : 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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 M\u2097 _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\u2097' N\u2097 _inst_13 _inst_10 _inst_22 _inst_19}, (Function.Surjective.{succ u5, succ u2} Q\u2097 M\u2097 (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\u2097 M\u2097 _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\u2097 M\u2097 _inst_12 _inst_9 _inst_21 _inst_18) => Q\u2097 -> M\u2097) (LinearMap.hasCoeToFun.{u1, u1, u5, u2} R R Q\u2097 M\u2097 (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\u2097' N\u2097 (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\u2097' N\u2097 _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\u2097' N\u2097 _inst_13 _inst_10 _inst_22 _inst_19) => Q\u2097' -> N\u2097) (LinearMap.hasCoeToFun.{u1, u1, u6, u3} R R Q\u2097' N\u2097 (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\u2097 (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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u1, u1, u6, u4} R R Q\u2097' P\u2097 (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\u2097' P\u2097 (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\u2081\u2082._proof_2.{u1, u4} R _inst_1 P\u2097 _inst_11 _inst_20))) (LinearMap.compl\u2081\u2082.{u1, u2, u3, u4, u5, u6} R _inst_1 M\u2097 N\u2097 P\u2097 Q\u2097 Q\u2097' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f\u2081 g g') (LinearMap.compl\u2081\u2082.{u1, u2, u3, u4, u5, u6} R _inst_1 M\u2097 N\u2097 P\u2097 Q\u2097 Q\u2097' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f\u2082 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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11 _inst_20))))) f\u2081 f\u2082))\nbut is expected to have type\n  forall {R : Type.{u6}} [_inst_1 : CommSemiring.{u6} R] {M\u2097 : Type.{u5}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} {Q\u2097 : Type.{u2}} {Q\u2097' : Type.{u1}} [_inst_9 : AddCommMonoid.{u5} M\u2097] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_12 : AddCommMonoid.{u2} Q\u2097] [_inst_13 : AddCommMonoid.{u1} Q\u2097'] [_inst_18 : Module.{u6, u5} R M\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_9] [_inst_19 : Module.{u6, u3} R N\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_10] [_inst_20 : Module.{u6, u4} R P\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11] [_inst_21 : Module.{u6, u2} R Q\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_12] [_inst_22 : Module.{u6, u1} R Q\u2097' (CommSemiring.toSemiring.{u6} R _inst_1) _inst_13] {f\u2081 : 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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))} {f\u2082 : 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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (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\u2097 M\u2097 _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\u2097' N\u2097 _inst_13 _inst_10 _inst_22 _inst_19}, (Function.Surjective.{succ u2, succ u5} Q\u2097 M\u2097 (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\u2097 M\u2097 _inst_12 _inst_9 _inst_21 _inst_18) Q\u2097 (fun (_x : Q\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097) => M\u2097) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u2, u5} R R Q\u2097 M\u2097 (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\u2097' N\u2097 (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\u2097' N\u2097 _inst_13 _inst_10 _inst_22 _inst_19) Q\u2097' (fun (_x : Q\u2097') => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : Q\u2097') => N\u2097) _x) (LinearMap.instFunLikeLinearMap.{u6, u6, u1, u3} R R Q\u2097' N\u2097 (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\u2097 (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\u2097' P\u2097 _inst_13 _inst_11 _inst_22 _inst_20) _inst_12 (LinearMap.addCommMonoid.{u6, u6, u1, u4} R R Q\u2097' P\u2097 (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\u2097' P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) (LinearMap.compl\u2081\u2082.{u6, u5, u3, u4, u2, u1} R _inst_1 M\u2097 N\u2097 P\u2097 Q\u2097 Q\u2097' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f\u2081 g g') (LinearMap.compl\u2081\u2082.{u6, u5, u3, u4, u2, u1} R _inst_1 M\u2097 N\u2097 P\u2097 Q\u2097 Q\u2097' _inst_9 _inst_10 _inst_11 _inst_12 _inst_13 _inst_18 _inst_19 _inst_20 _inst_21 _inst_22 f\u2082 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\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_9 (LinearMap.addCommMonoid.{u6, u6, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u6} R _inst_1) (MulActionWithZero.toMulAction.{u6, u4} R P\u2097 (Semiring.toMonoidWithZero.{u6} R (CommSemiring.toSemiring.{u6} R _inst_1)) (AddMonoid.toZero.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u6, u4} R P\u2097 (CommSemiring.toSemiring.{u6} R _inst_1) _inst_11 _inst_20))))) f\u2081 f\u2082))\nCase conversion may be inaccurate. Consider using '#align linear_map.compl\u2081\u2082_inj LinearMap.compl\u2081\u2082_inj\u2093'. -/\ntheorem compl\u2081\u2082_inj {f\u2081 f\u2082 : M\u2097 \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097} {g : Q\u2097 \u2192\u2097[R] M\u2097} {g' : Q\u2097' \u2192\u2097[R] N\u2097}\n    (h\u2097 : Function.Surjective g) (h\u1d63 : Function.Surjective g') :\n    f\u2081.compl\u2081\u2082 g g' = f\u2082.compl\u2081\u2082 g g' \u2194 f\u2081 = f\u2082 :=\n  by\n  constructor <;> intro h\n  \u00b7 -- B\u2081.comp l r = B\u2082.comp l r \u2192 B\u2081 = B\u2082\n    ext (x y)\n    cases' h\u2097 x with x' hx\n    subst hx\n    cases' h\u1d63 y with y' hy\n    subst hy\n    convert LinearMap.congr_fun\u2082 h x' y'\n  \u00b7-- B\u2081 = B\u2082 \u2192 B\u2081.comp l r = B\u2082.comp l r\n    subst h\n#align linear_map.compl\u2081\u2082_inj LinearMap.compl\u2081\u2082_inj\n\n#print LinearMap.compr\u2082 /-\n/-- Composing a linear map `P \u2192 Q` and a bilinear map `M \u2192 N \u2192 P` to\nform a bilinear map `M \u2192 N \u2192 Q`. -/\ndef compr\u2082 (f : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) (g : P\u2097 \u2192\u2097[R] Q\u2097) : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] Q\u2097 :=\n  llcomp R N\u2097 P\u2097 Q\u2097 g \u2218\u2097 f\n#align linear_map.compr\u2082 LinearMap.compr\u2082\n-/\n\n/- warning: linear_map.compr\u2082_apply -> LinearMap.compr\u2082_apply is a dubious translation:\nlean 3 declaration is\n  forall {R : Type.{u1}} [_inst_1 : CommSemiring.{u1} R] {M : Type.{u2}} {N\u2097 : Type.{u3}} {P\u2097 : Type.{u4}} {Q\u2097 : Type.{u5}} [_inst_5 : AddCommMonoid.{u2} M] [_inst_10 : AddCommMonoid.{u3} N\u2097] [_inst_11 : AddCommMonoid.{u4} P\u2097] [_inst_12 : AddCommMonoid.{u5} Q\u2097] [_inst_14 : Module.{u1, u2} R M (CommSemiring.toSemiring.{u1} R _inst_1) _inst_5] [_inst_19 : Module.{u1, u3} R N\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_10] [_inst_20 : Module.{u1, u4} R P\u2097 (CommSemiring.toSemiring.{u1} R _inst_1) _inst_11] [_inst_21 : Module.{u1, u5} R Q\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 Q\u2097 _inst_11 _inst_12 _inst_20 _inst_21) (m : M) (n : N\u2097), Eq.{succ u5} Q\u2097 (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\u2097 Q\u2097 _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\u2097 Q\u2097 _inst_10 _inst_12 _inst_19 _inst_21) => N\u2097 -> Q\u2097) (LinearMap.hasCoeToFun.{u1, u1, u3, u5} R R N\u2097 Q\u2097 (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\u2097 Q\u2097 _inst_10 _inst_12 _inst_19 _inst_21) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u5} R R N\u2097 Q\u2097 (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\u2097 Q\u2097 (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\u2082._proof_2.{u1, u5} R _inst_1 Q\u2097 _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\u2097 Q\u2097 _inst_10 _inst_12 _inst_19 _inst_21) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u5} R R N\u2097 Q\u2097 (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\u2097 Q\u2097 (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\u2082._proof_2.{u1, u5} R _inst_1 Q\u2097 _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\u2097 Q\u2097 _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\u2097 Q\u2097 _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\u2097 Q\u2097 (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\u2097 Q\u2097 (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\u2082._proof_2.{u1, u5} R _inst_1 Q\u2097 _inst_12 _inst_21)) (RingHom.id.{u1} R (Semiring.toNonAssocSemiring.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)))) (LinearMap.compr\u2082.{u1, u2, u3, u4, u5} R _inst_1 M N\u2097 P\u2097 Q\u2097 _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\u2097 Q\u2097 _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\u2097 Q\u2097 _inst_11 _inst_12 _inst_20 _inst_21) => P\u2097 -> Q\u2097) (LinearMap.hasCoeToFun.{u1, u1, u4, u5} R R P\u2097 Q\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) => N\u2097 -> P\u2097) (LinearMap.hasCoeToFun.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u1, u1, u3, u4} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u1} R _inst_1) (MulActionWithZero.toMulAction.{u1, u4} R P\u2097 (Semiring.toMonoidWithZero.{u1} R (CommSemiring.toSemiring.{u1} R _inst_1)) (AddZeroClass.toHasZero.{u4} P\u2097 (AddMonoid.toAddZeroClass.{u4} P\u2097 (AddCommMonoid.toAddMonoid.{u4} P\u2097 _inst_11))) (Module.toMulActionWithZero.{u1, u4} R P\u2097 (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\u2097 : Type.{u2}} {P\u2097 : Type.{u3}} {Q\u2097 : Type.{u1}} [_inst_5 : AddCommMonoid.{u4} M] [_inst_10 : AddCommMonoid.{u2} N\u2097] [_inst_11 : AddCommMonoid.{u3} P\u2097] [_inst_12 : AddCommMonoid.{u1} Q\u2097] [_inst_14 : Module.{u5, u4} R M (CommSemiring.toSemiring.{u5} R _inst_1) _inst_5] [_inst_19 : Module.{u5, u2} R N\u2097 (CommSemiring.toSemiring.{u5} R _inst_1) _inst_10] [_inst_20 : Module.{u5, u3} R P\u2097 (CommSemiring.toSemiring.{u5} R _inst_1) _inst_11] [_inst_21 : Module.{u5, u1} R Q\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u5, u5, u2, u3} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u3} R P\u2097 (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u3} P\u2097 (AddCommMonoid.toAddMonoid.{u3} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u5, u3} R P\u2097 (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\u2097 Q\u2097 _inst_11 _inst_12 _inst_20 _inst_21) (m : M) (n : N\u2097), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2097) => Q\u2097) 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\u2097 Q\u2097 _inst_10 _inst_12 _inst_19 _inst_21) m) N\u2097 (fun (_x : N\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2097) => Q\u2097) _x) (LinearMap.instFunLikeLinearMap.{u5, u5, u2, u1} R R N\u2097 Q\u2097 (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\u2097 Q\u2097 _inst_10 _inst_12 _inst_19 _inst_21) _inst_5 (LinearMap.addCommMonoid.{u5, u5, u2, u1} R R N\u2097 Q\u2097 (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\u2097 Q\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u1} R Q\u2097 (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u1} Q\u2097 (AddCommMonoid.toAddMonoid.{u1} Q\u2097 _inst_12)) (Module.toMulActionWithZero.{u5, u1} R Q\u2097 (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\u2097 Q\u2097 _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\u2097 Q\u2097 _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\u2097 Q\u2097 (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\u2097 Q\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u1} R Q\u2097 (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u1} Q\u2097 (AddCommMonoid.toAddMonoid.{u1} Q\u2097 _inst_12)) (Module.toMulActionWithZero.{u5, u1} R Q\u2097 (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\u2082.{u5, u4, u2, u3, u1} R _inst_1 M N\u2097 P\u2097 Q\u2097 _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\u2097 Q\u2097 _inst_11 _inst_12 _inst_20 _inst_21) P\u2097 (fun (_x : P\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : P\u2097) => Q\u2097) _x) (LinearMap.instFunLikeLinearMap.{u5, u5, u3, u1} R R P\u2097 Q\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) m) N\u2097 (fun (_x : N\u2097) => (fun (x._@.Mathlib.Algebra.Module.LinearMap._hyg.6190 : N\u2097) => P\u2097) _x) (LinearMap.instFunLikeLinearMap.{u5, u5, u2, u3} R R N\u2097 P\u2097 (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\u2097 P\u2097 _inst_10 _inst_11 _inst_19 _inst_20) _inst_5 (LinearMap.addCommMonoid.{u5, u5, u2, u3} R R N\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u3} R P\u2097 (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u3} P\u2097 (AddCommMonoid.toAddMonoid.{u3} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u5, u3} R P\u2097 (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\u2097 P\u2097 _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\u2097 P\u2097 _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\u2097 P\u2097 (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\u2097 P\u2097 (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\u2097 (CommSemiring.toCommMonoid.{u5} R _inst_1) (MulActionWithZero.toMulAction.{u5, u3} R P\u2097 (Semiring.toMonoidWithZero.{u5} R (CommSemiring.toSemiring.{u5} R _inst_1)) (AddMonoid.toZero.{u3} P\u2097 (AddCommMonoid.toAddMonoid.{u3} P\u2097 _inst_11)) (Module.toMulActionWithZero.{u5, u3} R P\u2097 (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\u2082_apply LinearMap.compr\u2082_apply\u2093'. -/\n@[simp]\ntheorem compr\u2082_apply (f : M \u2192\u2097[R] N\u2097 \u2192\u2097[R] P\u2097) (g : P\u2097 \u2192\u2097[R] Q\u2097) (m : M) (n : N\u2097) :\n    f.compr\u2082 g m n = g (f m n) :=\n  rfl\n#align linear_map.compr\u2082_apply LinearMap.compr\u2082_apply\n\nvariable (R M)\n\n#print LinearMap.lsmul /-\n/-- Scalar multiplication as a bilinear map `R \u2192 M \u2192 M`. -/\ndef lsmul : R \u2192\u2097[R] M \u2192\u2097[R] M :=\n  mk\u2082 R (\u00b7 \u2022 \u00b7) 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\u2093'. -/\n@[simp]\ntheorem lsmul_apply (r : R) (m : M) : lsmul R M r m = r \u2022 m :=\n  rfl\n#align linear_map.lsmul_apply LinearMap.lsmul_apply\n\nend CommSemiring\n\nsection CommRing\n\nvariable {R R\u2082 S S\u2082 M N P : Type _}\n\nvariable {M\u2097 N\u2097 P\u2097 : Type _}\n\nvariable [CommRing R] [CommRing S] [CommRing R\u2082] [CommRing S\u2082]\n\nsection AddCommGroup\n\nvariable [AddCommGroup M] [AddCommGroup N] [AddCommGroup P]\n\nvariable [Module R M] [Module S N] [Module R\u2082 P] [Module S\u2082 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\u2093'. -/\ntheorem lsmul_injective [NoZeroSMulDivisors R M] {x : R} (hx : x \u2260 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\u2093'. -/\ntheorem ker_lsmul [NoZeroSMulDivisors R M] {a : R} (ha : a \u2260 0) : (LinearMap.lsmul R M a).ker = \u22a5 :=\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 \u00d7 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' : \u2200 {w x y z}, r w x \u2192 r y z \u2192 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' : \u2200 {w x y z}, r w x \u2192 r y z \u2192 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 \u2192 M \u2192 Prop) : M \u2192 M \u2192 Prop\n| of : \u03a0 x y, r x y \u2192 add_con_gen.rel x y\n| refl : \u03a0 x, add_con_gen.rel x x\n| symm : \u03a0 x y, add_con_gen.rel x y \u2192 add_con_gen.rel y x\n| trans : \u03a0 x y z, add_con_gen.rel x y \u2192 add_con_gen.rel y z \u2192 add_con_gen.rel x z\n| add : \u03a0 w x y z, add_con_gen.rel w x \u2192 add_con_gen.rel y z \u2192 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 \u2192 M \u2192 Prop) : M \u2192 M \u2192 Prop\n| of : \u03a0 x y, r x y \u2192 con_gen.rel x y\n| refl : \u03a0 x, con_gen.rel x x\n| symm : \u03a0 x y, con_gen.rel x y \u2192 con_gen.rel y x\n| trans : \u03a0 x y z, con_gen.rel x y \u2192 con_gen.rel y z \u2192 con_gen.rel x z\n| mul : \u03a0 w x y z, con_gen.rel w x \u2192 con_gen.rel y z \u2192 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 \u2192 M \u2192 Prop) : con M :=\n\u27e8\u27e8con_gen.rel r, \u27e8con_gen.rel.refl, con_gen.rel.symm, con_gen.rel.trans\u27e9\u27e9, con_gen.rel.mul\u27e9\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\u27e8con_gen empty_relation\u27e9\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) (\u03bb _, M \u2192 M \u2192 Prop) := \u27e8\u03bb c, \u03bb x y, @setoid.r _ c.to_setoid x y\u27e9\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 : \u2200 {x y}, c x y \u2192 c y x := \u03bb _ _ h, c.to_setoid.symm' h\n\n/-- Congruence relations are transitive. -/\n@[to_additive \"Additive congruence relations are transitive.\"]\nprotected lemma trans : \u2200 {x y z}, c x y \u2192 c y z \u2192 c x z :=\n\u03bb _ _ _ h, c.to_setoid.trans' h\n\n/-- Multiplicative congruence relations preserve multiplication. -/\n@[to_additive \"Additive congruence relations preserve addition.\"]\nprotected lemma mul : \u2200 {w x y z}, c w x \u2192 c y z \u2192 c (w * y) (x * z) :=\n\u03bb _ _ _ _ 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 \u2194 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) \u2208 M \u00d7 M` iff `x` is related to `y` by `c`. -/\n@[to_additive \"Given a type `M` with an addition, `x, y \u2208 M`, and an additive congruence relation\n`c` on `M`, `(x, y) \u2208 M \u00d7 M` iff `x` is related to `y` by `c`.\"]\ninstance : has_mem (M \u00d7 M) (con M) := \u27e8\u03bb x c, c x.1 x.2\u27e9\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 \u27e8\u27e8\u27e9\u27e9, rcases d with \u27e8\u27e8\u27e9\u27e9, 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 : \u2200 x y, c x y \u2194 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} : (\u2200 x y, c x y \u2194 d x y) \u2194 c = d :=\n\u27e8ext, \u03bb h _ _, h \u25b8 iff.rfl\u27e9\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 \u2194 c = d :=\n\u27e8ext', \u03bb h, h \u25b8 rfl\u27e9\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 \u2192 P) (h : \u2200 x y, f (x * y) = f x * f y) : con M :=\n{ to_setoid := setoid.ker f,\n  mul' := \u03bb _ _ _ _ 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\u2081, x\u2082), (y\u2081, y\u2082) \u2208 M \u00d7 N` are related by `c.prod d` iff `x\u2081` is related to `y\u2081`\n    by `c` and `x\u2082` is related to `y\u2082` 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\u2081, x\u2082), (y\u2081, y\u2082) \u2208 M \u00d7 N` are related by `c.prod d` iff `x\u2081`\nis related to `y\u2081` by `c` and `x\u2082` is related to `y\u2082` by `d`.\"]\nprotected def prod (c : con M) (d : con N) : con (M \u00d7 N) :=\n{ mul' := \u03bb _ _ _ _ h1 h2, \u27e8c.mul h1.1 h2.1, d.mul h1.2 h2.2\u27e9, ..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 {\u03b9 : Type*} {f : \u03b9 \u2192 Type*} [\u03a0 i, has_mul (f i)]\n  (C : \u03a0 i, con (f i)) : con (\u03a0 i, f i) :=\n{ mul' := \u03bb _ _ _ _ h1 h2 i, (C i).mul (h1 i) (h2 i), ..@pi_setoid _ _ $ \u03bb 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 := \u27e8@quotient.mk _ c.to_setoid\u27e9\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 : \u2200 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 {\u03b2} {c : con M} (q : c.quotient) (f : M \u2192 \u03b2)\n  (h : \u2200 a b, c a b \u2192 f a = f b) : \u03b2 := 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\u2082 {\u03b2} {c : con M} (q r : c.quotient) (f : M \u2192 M \u2192 \u03b2)\n  (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082, c a\u2081 b\u2081 \u2192 c a\u2082 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) : \u03b2 := quotient.lift_on\u2082' q r f h\n\n/-- A version of `quotient.hrec_on\u2082'` for quotients by `con`. -/\n@[to_additive \"A version of `quotient.hrec_on\u2082'` for quotients by `add_con`.\"]\nprotected def hrec_on\u2082 {cM : con M} {cN : con N} {\u03c6 : cM.quotient \u2192 cN.quotient \u2192 Sort*}\n  (a : cM.quotient) (b : cN.quotient)\n  (f : \u03a0 (x : M) (y : N), \u03c6 x y) (h : \u2200 x y x' y', cM x x' \u2192 cN y y' \u2192 f x y == f x' y') :\n  \u03c6 a b :=\nquotient.hrec_on\u2082' a b f h\n\n@[simp, to_additive] lemma hrec_on\u2082_coe {cM : con M} {cN : con N}\n  {\u03c6 : cM.quotient \u2192 cN.quotient \u2192 Sort*} (a : M) (b : N)\n  (f : \u03a0 (x : M) (y : N), \u03c6 x y) (h : \u2200 x y x' y', cM x x' \u2192 cN y y' \u2192 f x y == f x' y') :\n  con.hrec_on\u2082 \u2191a \u2191b 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 \u2192 Prop} (q : c.quotient) (H : \u2200 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\u2082 {d : con N} {C : c.quotient \u2192 d.quotient \u2192 Prop}\n  (p : c.quotient) (q : d.quotient) (H : \u2200 (x : M) (y : N), C x y) : C p q :=\nquotient.induction_on\u2082' 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 \u2194 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\u27e8\u03bb x y, quotient.lift_on\u2082' x y (\u03bb w z, ((w * z : M) : c.quotient))\n     $ \u03bb _ _ _ _ h1 h2, c.eq.2 $ c.mul h1 h2\u27e9\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 \u2192 c.quotient) (\u03bb x y, rfl) = c :=\next $ \u03bb 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) : (\u2191(x * y) : c.quotient) = \u2191x * \u2191y := 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 {\u03b2} (c : con M) (f : M \u2192 \u03b2)\n  (h : \u2200 a b, c a b \u2192 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 \u2243* d.quotient :=\n{ map_mul' := \u03bb 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 \u2264 d` iff `\u2200 x y \u2208 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 \u2264 d` iff\n`\u2200 x y \u2208 M`, `x` is related to `y` by `d` if `x` is related to `y` by `c`.\"]\ninstance : has_le (con M) := \u27e8\u03bb c d, \u2200 \u2983x y\u2984, c x y \u2192 d x y\u27e9\n\n/-- Definition of `\u2264` for congruence relations. -/\n@[to_additive \"Definition of `\u2264` for additive congruence relations.\"]\ntheorem le_def {c d : con M} : c \u2264 d \u2194 \u2200 {x y}, c x y \u2192 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\u27e8\u03bb S, \u27e8\u27e8\u03bb x y, \u2200 c : con M, c \u2208 S \u2192 c x y,\n\u27e8\u03bb x c hc, c.refl x, \u03bb _ _ h c hc, c.symm $ h c hc,\n \u03bb _ _ _ h1 h2 c hc, c.trans (h1 c hc) $ h2 c hc\u27e9\u27e9,\n \u03bb _ _ _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc\u27e9\u27e9\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' $ \u03bb x y, \u27e8\u03bb h r \u27e8c, hS, hr\u27e9, by rw \u2190hr; exact h c hS,\n  \u03bb h c hS, h c.to_setoid \u27e8c, hS, rfl\u27e9\u27e9\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)) : \u21d1(Inf S) = Inf (@set.image (con M) (M \u2192 M \u2192 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 := (\u2264),\n  lt := \u03bb c d, c \u2264 d \u2227 \u00acd \u2264 c,\n  le_refl := \u03bb c _ _, id,\n  le_trans := \u03bb c1 c2 c3 h1 h2 x y h, h2 $ h1 h,\n  lt_iff_le_not_le := \u03bb _ _, iff.rfl,\n  le_antisymm := \u03bb c d hc hd, ext $ \u03bb x y, \u27e8\u03bb h, hc h, \u03bb h, hd h\u27e9 }\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 := \u03bb c d, \u27e8(c.to_setoid \u2293 d.to_setoid), \u03bb _ _ _ _ h1 h2, \u27e8c.mul h1.1 h2.1, d.mul h1.2 h2.2\u27e9\u27e9,\n  inf_le_left := \u03bb _ _ _ _ h, h.1,\n  inf_le_right := \u03bb _ _ _ _ h, h.2,\n  le_inf := \u03bb _ _ _ hb hc _ _ h, \u27e8hb h, hc h\u27e9,\n  top := { mul' := by tauto, ..setoid.complete_lattice.top},\n  le_top := \u03bb _ _ _ h, trivial,\n  bot := { mul' := \u03bb _ _ _ _ h1 h2, h1 \u25b8 h2 \u25b8 rfl, ..setoid.complete_lattice.bot},\n  bot_le := \u03bb c x y h, h \u25b8 c.refl x,\n  .. complete_lattice_of_Inf (con M) $ assume s,\n    \u27e8\u03bb r hr x y h, (h : \u2200 r \u2208 s, (r : con M) x y) r hr, \u03bb r hr x y h r' hr', hr hr' h\u27e9 }\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 \u2293 d).r = c.r \u2293 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 \u2293 d) x y \u2194 c x y \u2227 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 \u2192 M \u2192 Prop) :\n  con_gen r = Inf {s : con M | \u2200 x y, r x y \u2192 s x y} :=\nle_antisymm\n  (\u03bb x y H, con_gen.rel.rec_on H (\u03bb _ _ h _ hs, hs _ _ h) (con.refl _) (\u03bb _ _ _, con.symm _)\n    (\u03bb _ _ _ _ _, con.trans _)\n    $ \u03bb w x y z _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc)\n  (Inf_le (\u03bb _ _, 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 \u2192 M \u2192 Prop} {c : con M} (h : \u2200 x y, r x y \u2192 @setoid.r _ c.to_setoid x y) :\n  con_gen r \u2264 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 \u2192 M \u2192 Prop} (h : \u2200 x y, r x y \u2192 s x y) :\n  con_gen r \u2264 con_gen s :=\ncon_gen_le $ \u03bb 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 (\u03bb _ _, 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 \u2192 M \u2192 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 \u2294 d = con_gen (\u03bb x y, c x y \u2228 d x y) :=\nbegin\n  rw con_gen_eq,\n  apply congr_arg Inf,\n  simp only [le_def, or_imp_distrib, \u2190 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 \u2294 d = con_gen (c.r \u2294 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 \u2208 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 \u2208 S`\nsuch that `x` is related to `y` by `c`'.\"]\nlemma Sup_eq_con_gen (S : set (con M)) :\n  Sup S = con_gen (\u03bb x y, \u2203 c : con M, c \u2208 S \u2227 c x y) :=\nbegin\n  rw con_gen_eq,\n  apply congr_arg Inf,\n  ext,\n  exact \u27e8\u03bb h _ _ \u27e8r, hr\u27e9, h hr.1 hr.2,\n         \u03bb h r hS _ _ hr, h _ _ \u27e8r, hS, hr\u27e9\u27e9,\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 \u2192 M \u2192 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 \u2192 M \u2192 Prop) (con M) _ _ con_gen coe_fn :=\n{ choice := \u03bb r h, con_gen r,\n  gc := \u03bb r c, \u27e8\u03bb H _ _ h, H $ con_gen.rel.of _ _ h, \u03bb H, con_gen_of_con c \u25b8 con_gen_mono H\u27e9,\n  le_l_u := \u03bb x, (con_gen_of_con x).symm \u25b8 le_refl x,\n  choice_eq := \u03bb _ _, 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 \u2248 y` iff the elements of `f\u207b\u00b9(x)` are related to the elements of `f\u207b\u00b9(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 \u2248 y` iff the elements of `f\u207b\u00b9(x)` are related to the\nelements of `f\u207b\u00b9(y)` by an additive congruence relation `c`.'\"]\ndef map_gen (f : M \u2192 N) : con N :=\ncon_gen $ \u03bb x y, \u2203 a b, f a = x \u2227 f b = y \u2227 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 \u2248 y` iff the\n    elements of `f\u207b\u00b9(x)` are related to the elements of `f\u207b\u00b9(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 \u2248 y` iff the elements of `f\u207b\u00b9(x)` are related to the elements of `f\u207b\u00b9(y)` by `c`.'\"]\ndef map_of_surjective (f : M \u2192 N) (H : \u2200 x y, f (x * y) = f x * f y) (h : mul_ker f H \u2264 c)\n  (hf : surjective f) : con N :=\n{ mul' := \u03bb w x y z \u27e8a, b, hw, hx, h1\u27e9 \u27e8p, q, hy, hz, h2\u27e9,\n    \u27e8a * p, b * q, by rw [H, hw, hy], by rw [H, hx, hz], c.mul h1 h2\u27e9,\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 \u2192 N} (H : \u2200 x y, f (x * y) = f x * f y)\n  (h : mul_ker f H \u2264 c) (hf : surjective f) :\n  c.map_gen f = c.map_of_surjective f H h hf :=\nby rw \u2190con_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 \u2192 N` induces a congruence relation on `f`'s domain\n    defined by '`x \u2248 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 \u2192 N` induces an additive congruence relation on `f`'s domain\ndefined by '`x \u2248 y` iff `f(x)` is related to `f(y)` by `c`.' \"]\ndef comap (f : M \u2192 N) (H : \u2200 x y, f (x * y) = f x * f y) (c : con N) : con M :=\n{ mul' := \u03bb 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 \u2192 N} (H : \u2200 x y, f (x * y) = f x * f y)\n  {c : con N} {x y : M} :\n  comap f H c x y \u2194 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 \u2264 d} \u2243o (con c.quotient) :=\n{ to_fun := \u03bb 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 := \u03bb d, \u27e8comap (coe : M \u2192 c.quotient) (\u03bb x y, rfl) d, \u03bb _ _ h,\n    show d _ _, by rw c.eq.2 h; exact d.refl _ \u27e9,\n  left_inv := \u03bb d, subtype.ext_iff_val.2 $ ext $ \u03bb _ _,\n    \u27e8\u03bb h, let \u27e8a, b, hx, hy, H\u27e9 := 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     \u03bb h, \u27e8_, _, rfl, rfl, h\u27e9\u27e9,\n  right_inv := \u03bb d, let Hm : mul_ker (coe : M \u2192 c.quotient) (\u03bb x y, rfl) \u2264\n        comap (coe : M \u2192 c.quotient) (\u03bb x y, rfl) d :=\n      \u03bb x y h, show d _ _, by rw mul_ker_mk_eq at h; exact c.eq.2 h \u25b8 d.refl _ in\n    ext $ \u03bb x y, \u27e8\u03bb h, let \u27e8a, b, hx, hy, H\u27e9 := h in hx \u25b8 hy \u25b8 H,\n      con.induction_on\u2082 x y $ \u03bb w z h, \u27e8w, z, rfl, rfl, h\u27e9\u27e9,\n  map_rel_iff' := \u03bb s t, \u27e8\u03bb h _ _ hs, let \u27e8a, b, hx, hy, ht\u27e9 := h \u27e8_, _, rfl, rfl, hs\u27e9 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      \u03bb h _ _ hs, let \u27e8a, b, hx, hy, Hs\u27e9 := hs in \u27e8a, b, hx, hy, h Hs\u27e9\u27e9 }\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 := \u03bb x, quotient.induction_on' x $ \u03bb _, congr_arg coe $ mul_one _,\n  one_mul := \u03bb x, quotient.induction_on' x $ \u03bb _, 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 \u00d7 M` defined by a congruence relation on a monoid `M`. -/\n@[to_additive \"The `add_submonoid` of `M \u00d7 M` defined by an additive congruence\nrelation on an `add_monoid` `M`.\"]\nprotected def submonoid : submonoid (M \u00d7 M) :=\n{ carrier := { x | c x.1 x.2 },\n  one_mem' := c.iseqv.1 1,\n  mul_mem' := \u03bb _ _, c.mul }\n\nvariables {M c}\n\n/-- The congruence relation on a monoid `M` from a submonoid of `M \u00d7 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 \u00d7 M` for which membership is an equivalence relation.\"]\ndef of_submonoid (N : submonoid (M \u00d7 M)) (H : equivalence (\u03bb x y, (x, y) \u2208 N)) : con M :=\n{ r := \u03bb x y, (x, y) \u2208 N,\n  iseqv := H,\n  mul' := \u03bb _ _ _ _, N.mul_mem }\n\n/-- Coercion from a congruence relation `c` on a monoid `M` to the submonoid of `M \u00d7 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 \u00d7 M` whose elements are `(x, y)` such that `x`\nis related to `y` by `c`.\"]\ninstance to_submonoid : has_coe (con M) (submonoid (M \u00d7 M)) := \u27e8\u03bb c, c.submonoid M\u27e9\n\n@[to_additive] lemma mem_coe {c : con M} {x y} :\n  (x, y) \u2208 (\u2191c : submonoid (M \u00d7 M)) \u2194 (x, y) \u2208 c := iff.rfl\n\n@[to_additive]\ntheorem to_submonoid_inj (c d : con M) (H : (c : submonoid (M \u00d7 M)) = d) : c = d :=\next $ \u03bb x y, show (x, y) \u2208 (c : submonoid (M \u00d7 M)) \u2194 (x, y) \u2208 \u2191d, by rw H\n\n@[to_additive]\nlemma le_iff {c d : con M} : c \u2264 d \u2194 (c : submonoid (M \u00d7 M)) \u2264 d :=\n\u27e8\u03bb h x H, h H, \u03bb h x y hc, h $ show (x, y) \u2208 c, from hc\u27e9\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 \u2192* 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 \u2192* P) {x y} : ker f x y \u2194 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 := \u27e8((1 : M) : c.quotient)\u27e9\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 \u2192* c.quotient := \u27e8coe, rfl, \u03bb _ _, rfl\u27e9\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 $ \u03bb _ _, 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 \u2192 c.quotient) = coe := rfl\n\n/-- The elements related to `x \u2208 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 \u2208 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 \u2192* P} (x) : (ker f) x = f \u207b\u00b9' {f x} :=\nset.ext $ \u03bb x,\n  \u27e8\u03bb h, set.mem_preimage.2 $ set.mem_singleton_iff.2 h.symm,\n   \u03bb h, (set.mem_singleton_iff.1 $ set.mem_preimage.1 h).symm\u27e9\n\n/-- Given a monoid homomorphism `f : N \u2192 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 \u2192 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 \u2192* M} : comap f f.map_mul c = ker (c.mk'.comp f) :=\next $ \u03bb x y, show c _ _ \u2194 c.mk' _ = c.mk' _, by rw \u2190c.eq; refl\n\nvariables (c) (f : M \u2192* 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 \u2264 ker f) : c.quotient \u2192* P :=\n{ to_fun := \u03bb x, con.lift_on x f $ \u03bb _ _ h, H h,\n  map_one' := by rw \u2190f.map_one; refl,\n  map_mul' := \u03bb x y, con.induction_on\u2082 x y $ \u03bb m n, f.map_mul m n \u25b8 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 \u2264 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 \u2264 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 \u2264 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 \u2192* P) :\n  c.lift (f.comp c.mk') (\u03bb x y h, show f \u2191x = f \u2191y, 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 \u2192* P) (h : \u2200 a : M, f a = g a) : f = g :=\nbegin\n  rw [\u2190lift_apply_mk' f, \u2190lift_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 \u2264 ker f) (g : c.quotient \u2192* P)\n  (Hg : g.comp c.mk' = f) : g = c.lift f H :=\nlift_funext g (c.lift f H) $ \u03bb 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 \u2264 ker f) : (c.lift f H).mrange = f.mrange :=\nsubmonoid.ext $ \u03bb x, \u27e8by rintros \u27e8\u27e8y\u27e9, hy\u27e9; exact \u27e8y, hy\u27e9, \u03bb \u27e8y, hy\u27e9, \u27e8\u2191y, hy\u27e9\u27e9\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 \u2264 ker f) (hf : surjective f) :\n  surjective (c.lift f h) :=\n\u03bb y, exists.elim (hf y) $ \u03bb w hw, \u27e8w, (lift_mk' h w).symm \u25b8 hw\u27e9\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 \u2264 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 \u2192* P :=\n(ker f).lift f $ \u03bb _ _, 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 $ \u03bb _ _, 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 \u2192* P) : injective (ker_lift f) :=\n\u03bb x y, quotient.induction_on\u2082' x y $ \u03bb _ _, (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 \u2264 d) : c.quotient \u2192* d.quotient :=\nc.lift d.mk' $ \u03bb x y hc, show (ker d.mk') x y, from\n  (mk'_ker d).symm \u25b8 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 \u2264 d) (x) :\n  c.map d h x = c.lift d.mk' (\u03bb 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 \u2192* P) : (ker f).quotient \u2243* 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        \u27e8\u03bb x y h, ker_lift_injective f $ by rcases x; rcases y; injections,\n         \u03bb \u27e8w, z, hz\u27e9, \u27e8z, by rcases hz; rcases _x; refl\u27e9\u27e9 }\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 \u2192* P) (g : P \u2192 M)\n  (hf : function.right_inverse g f) :\n  (ker f).quotient \u2243* P :=\n{ to_fun := ker_lift f,\n  inv_fun := coe \u2218 g,\n  left_inv := \u03bb 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 \u2192* P) (hf : surjective f) :\n  (ker f).quotient \u2243* 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 \u2192* M) :\n  (comap f f.map_mul c).quotient \u2243* (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 \u2264 d) :\n  (ker (c.map d h)).quotient \u2243* d.quotient :=\n{ map_mul' := \u03bb x y, con.induction_on\u2082 x y $ \u03bb w z, con.induction_on\u2082 w z $ \u03bb a b,\n    show _ = d.mk' a * d.mk' b, by rw \u2190d.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  \u2200 (n : \u2115) {w x}, c w x \u2192 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 \u2115 c.quotient :=\n{ smul := \u03bb n x, quotient.lift_on' x (\u03bb w, ((n \u2022 w : M) : c.quotient))\n     $ \u03bb 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 \u2115 :=\n{ pow := \u03bb x n, quotient.lift_on' x (\u03bb w, ((w ^ n : M) : c.quotient))\n     $ \u03bb 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' (\u03bb _ _, 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' (\u03bb _ _, 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 (\u03bb _ _, rfl) (\u03bb _ _, 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 (\u03bb _ _, rfl) (\u03bb _ _, 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 : \u2200 {w x}, c w x \u2192 c w\u207b\u00b9 x\u207b\u00b9 :=\n\u03bb x y h, by simpa using c.symm (c.mul (c.mul (c.refl x\u207b\u00b9) h) (c.refl y\u207b\u00b9))\n\n/-- Multiplicative congruence relations preserve division. -/\n@[to_additive \"Additive congruence relations preserve subtraction.\"]\nprotected lemma div : \u2200 {w x y z}, c w x \u2192 c y z \u2192 c (w / y) (x / z) :=\n\u03bb 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 : \u2200 (n : \u2124) {w x}, c w x \u2192 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\u27e8\u03bb x, quotient.lift_on' x (\u03bb w, ((w\u207b\u00b9 : M) : c.quotient))\n     $ \u03bb x y h, c.eq.2 $ c.inv h\u27e9\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\u27e8\u03bb x y, quotient.lift_on\u2082' x y (\u03bb w z, ((w / z : M) : c.quotient))\n     $ \u03bb _ _ _ _ h1 h2, c.eq.2 $ c.div h1 h2\u27e9\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 \u2124 c.quotient :=\n\u27e8\u03bb z x, quotient.lift_on' x (\u03bb w, ((z \u2022 w : M) : c.quotient))\n     $ \u03bb x y h, c.eq.2 $ c.zsmul z h\u27e9\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 \u2124 :=\n\u27e8\u03bb x z, quotient.lift_on' x (\u03bb w, ((w ^ z : M) : c.quotient))\n     $ \u03bb x y h, c.eq.2 $ c.zpow z h\u27e9\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  (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\nend groups\n\nsection units\n\nvariables {\u03b1 : Type*} [monoid M] {c : con M}\n\n/-- In order to define a function `(con.quotient c)\u02e3 \u2192 \u03b1` 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 `\u03b1` 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 : \u03a0 (x y : M), c (x * y) 1 \u2192 c (y * x) 1 \u2192 \u03b1)\n  (Hf : \u2200 x y hxy hyx x' y' hxy' hyx', c x x' \u2192 c y y' \u2192 f x y hxy hyx = f x' y' hxy' hyx') :\n  \u03b1 :=\nbegin\n  refine @con.hrec_on\u2082 M M _ _ c c (\u03bb x y, x * y = 1 \u2192 y * x = 1 \u2192 \u03b1)\n    (u : c.quotient) (\u2191u\u207b\u00b9 : c.quotient)\n    (\u03bb (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)) (\u03bb 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)\u02e3 \u2192 \u03b1` 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 `\u03b1` 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 : \u03a0 (x y : M), c (x * y) 1 \u2192 c (y * x) 1 \u2192 \u03b1)\n  (Hf : \u2200 x y hxy hyx x' y' hxy' hyx', c x x' \u2192 c y y' \u2192 f x y hxy hyx = f x' y' hxy' hyx')\n  (x y : M) (hxy hyx) :\n  lift_on_units \u27e8(x : c.quotient), y, hxy, hyx\u27e9 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 \u2192 Prop} (u : units c.quotient)\n  (H : \u2200 (x y : M) (hxy : c (x * y) 1) (hyx : c (y * x) 1), p \u27e8x, y, c.eq.2 hxy, c.eq.2 hyx\u27e9) :\n  p u :=\nbegin\n  rcases u with \u27e8\u27e8x\u27e9, \u27e8y\u27e9, h\u2081, h\u2082\u27e9,\n  exact H x y (c.eq.1 h\u2081) (c.eq.1 h\u2082)\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u00d7 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 \u2264 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 \u00d7 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 \u2243o add_submonoid (additive M) :=\n{ to_fun := \u03bb S,\n  { carrier := additive.to_mul \u207b\u00b9' S,\n    zero_mem' := S.one_mem',\n    add_mem' := S.mul_mem' },\n  inv_fun := \u03bb S,\n  { carrier := additive.of_mul \u207b\u00b9' S,\n    one_mem' := S.zero_mem',\n    mul_mem' := S.add_mem' },\n  left_inv := \u03bb x, by cases x; refl,\n  right_inv := \u03bb x, by cases x; refl,\n  map_rel_iff' := \u03bb 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) \u2243o 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 \u207b\u00b9' 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 \u207b\u00b9' 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 \u2243o submonoid (multiplicative A) :=\n{ to_fun := \u03bb S,\n  { carrier := multiplicative.to_add \u207b\u00b9' S,\n    one_mem' := S.zero_mem',\n    mul_mem' := S.add_mem' },\n  inv_fun := \u03bb S,\n  { carrier := multiplicative.of_add \u207b\u00b9' S,\n    zero_mem' := S.one_mem',\n    add_mem' := S.mul_mem' },\n  left_inv := \u03bb x, by cases x; refl,\n  right_inv := \u03bb x, by cases x; refl,\n  map_rel_iff' := \u03bb 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) \u2243o 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 \u207b\u00b9' 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 \u207b\u00b9' 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 \u2192* N) (S : submonoid N) : submonoid M :=\n{ carrier := (f \u207b\u00b9' S),\n  one_mem' := show f 1 \u2208 S, by rw f.map_one; exact S.one_mem,\n  mul_mem' := \u03bb a b ha hb,\n    show f (a * b) \u2208 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 \u2192* N) : (S.comap f : set M) = f \u207b\u00b9' S := rfl\n\n@[simp, to_additive]\nlemma mem_comap {S : submonoid N} {f : M \u2192* N} {x : M} : x \u2208 S.comap f \u2194 f x \u2208 S := iff.rfl\n\n@[to_additive]\nlemma comap_comap (S : submonoid P) (g : N \u2192* P) (f : M \u2192* 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 \u2192* N) (S : submonoid M) : submonoid N :=\n{ carrier := (f '' S),\n  one_mem' := \u27e81, S.one_mem, f.map_one\u27e9,\n  mul_mem' := begin rintros _ _ \u27e8x, hx, rfl\u27e9 \u27e8y, hy, rfl\u27e9, exact \u27e8x * y, S.mul_mem hx hy,\n    by rw f.map_mul; refl\u27e9 end }\n\n@[simp, to_additive]\nlemma coe_map (f : M \u2192* N) (S : submonoid M) :\n  (S.map f : set N) = f '' S := rfl\n\n@[simp, to_additive]\nlemma mem_map {f : M \u2192* N} {S : submonoid M} {y : N} :\n  y \u2208 S.map f \u2194 \u2203 x \u2208 S, f x = y :=\nmem_image_iff_bex\n\n@[to_additive]\nlemma mem_map_of_mem (f : M \u2192* N) (x : S) : f x \u2208 S.map f :=\nmem_image_of_mem f x.2\n\n@[to_additive]\nlemma map_map (g : N \u2192* P) (f : M \u2192* 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 \u2192* N} {S : submonoid M} {T : submonoid N} :\n  S.map f \u2264 T \u2194 S \u2264 T.comap f :=\nimage_subset_iff\n\n@[to_additive]\nlemma gc_map_comap (f : M \u2192* N) : galois_connection (map f) (comap f) :=\n\u03bb S T, map_le_iff_le_comap\n\n@[to_additive]\nlemma map_le_of_le_comap {T : submonoid N} {f : M \u2192* N} : S \u2264 T.comap f \u2192 S.map f \u2264 T :=\n(gc_map_comap f).l_le\n\n@[to_additive]\nlemma le_comap_of_map_le {T : submonoid N} {f : M \u2192* N} : S.map f \u2264 T \u2192 S \u2264 T.comap f :=\n(gc_map_comap f).le_u\n\n@[to_additive]\nlemma le_comap_map {f : M \u2192* N} : S \u2264 (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 \u2192* N} : (S.comap f).map f \u2264 S :=\n(gc_map_comap f).l_u_le _\n\n@[to_additive]\nlemma monotone_map {f : M \u2192* N} : monotone (map f) :=\n(gc_map_comap f).monotone_l\n\n@[to_additive]\nlemma monotone_comap {f : M \u2192* N} : monotone (comap f) :=\n(gc_map_comap f).monotone_u\n\n@[simp, to_additive]\nlemma map_comap_map {f : M \u2192* 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 \u2192* 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 \u2192* N) : (S \u2294 T).map f = S.map f \u2294 T.map f :=\n(gc_map_comap f).l_sup\n\n@[to_additive]\nlemma map_supr {\u03b9 : Sort*} (f : M \u2192* N) (s : \u03b9 \u2192 submonoid M) :\n  (supr s).map f = \u2a06 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 \u2192* N) : (S \u2293 T).comap f = S.comap f \u2293 T.comap f :=\n(gc_map_comap f).u_inf\n\n@[to_additive]\nlemma comap_infi {\u03b9 : Sort*} (f : M \u2192* N) (s : \u03b9 \u2192 submonoid N) :\n  (infi s).comap f = \u2a05 i, (s i).comap f :=\n(gc_map_comap f).u_infi\n\n@[simp, to_additive] lemma map_bot (f : M \u2192* N) : (\u22a5 : submonoid M).map f = \u22a5 :=\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 (\u03bb x, \u27e8\u03bb \u27e8_, h, rfl\u27e9, h, \u03bb h, \u27e8_, h, rfl\u27e9\u27e9)\n\nsection galois_coinsertion\n\nvariables {\u03b9 : Type*} {f : M \u2192* 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  (\u03bb 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 \u2293 T.map f).comap f = S \u2293 T :=\n(gci_map_comap hf).u_inf_l _ _\n\nlemma comap_infi_map_of_injective (S : \u03b9 \u2192 submonoid M) : (\u2a05 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 \u2294 T.map f).comap f = S \u2294 T :=\n(gci_map_comap hf).u_sup_l _ _\n\nlemma comap_supr_map_of_injective (S : \u03b9 \u2192 submonoid M) : (\u2a06 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 \u2264 T.map f \u2194 S \u2264 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 {\u03b9 : Type*} {f : M \u2192* 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  (\u03bb S x h, let \u27e8y, hy\u27e9 := hf x in mem_map.2 \u27e8y, by simp [hy, h]\u27e9)\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 \u2293 T.comap f).map f = S \u2293 T :=\n(gi_map_comap hf).l_inf_u _ _\n\nlemma map_infi_comap_of_surjective (S : \u03b9 \u2192 submonoid N) : (\u2a05 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 \u2294 T.comap f).map f = S \u2294 T :=\n(gi_map_comap hf).l_sup_u _ _\n\nlemma map_supr_comap_of_surjective (S : \u03b9 \u2192 submonoid N) : (\u2a06 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 \u2264 T.comap f \u2194 S \u2264 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 := \u27e8\u03bb a b, \u27e8a.1 * b.1, S.mul_mem a.2 b.2\u27e9\u27e9\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 := \u27e8\u27e8_, S.one_mem\u27e9\u27e9\n\n@[simp, to_additive] lemma coe_mul (x y : S) : (\u2191(x * y) : M) = \u2191x * \u2191y := 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 \u2192* M := \u27e8coe, rfl, \u03bb _ _, rfl\u27e9\n\n@[simp, to_additive] theorem coe_subtype : \u21d1S.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 \u2192 Prop}\n  (Hs : \u2200 x (h : x \u2208 s), p \u27e8x, subset_closure h\u27e9)\n  (H1 : p 1)\n  (Hmul : \u2200 x y, p x \u2192 p y \u2192 p (x * y))\n  (x : closure s) :\n  p x :=\nsubtype.rec_on x $ \u03bb x hx, begin\n  refine exists.elim _ (\u03bb (hx : x \u2208 closure s) (hc : p \u27e8x, hx\u27e9), hc),\n  exact closure_induction hx\n    (\u03bb x hx, \u27e8subset_closure hx, Hs x hx\u27e9)\n    \u27e8one_mem _, H1\u27e9\n    (\u03bb x y hx hy, exists.elim hx $ \u03bb hx' hx, exists.elim hy $ \u03bb hy' hy,\n      \u27e8mul_mem _ hx' hy', Hmul _ _ hx hy\u27e9),\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 \u00d7 t` as a submonoid\nof `M \u00d7 N`. -/\n@[to_additive prod \"Given `add_submonoid`s `s`, `t` of `add_monoid`s `A`, `B` respectively, `s \u00d7 t`\nas an `add_submonoid` of `A \u00d7 B`.\"]\ndef prod (s : submonoid M) (t : submonoid N) : submonoid (M \u00d7 N) :=\n{ carrier := (s : set M).prod t,\n  one_mem' := \u27e8s.one_mem, t.one_mem\u27e9,\n  mul_mem' := \u03bb p q hp hq, \u27e8s.mul_mem hp.1 hq.1, t.mul_mem hp.2 hq.2\u27e9 }\n\n@[to_additive coe_prod]\nlemma coe_prod (s : submonoid M) (t : submonoid N) :\n (s.prod t : set (M \u00d7 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 \u00d7 N} :\n  p \u2208 s.prod t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t := iff.rfl\n\n@[to_additive prod_mono]\nlemma prod_mono {s\u2081 s\u2082 : submonoid M} {t\u2081 t\u2082 : submonoid N} (hs : s\u2081 \u2264 s\u2082) (ht : t\u2081 \u2264 t\u2082) :\n  s\u2081.prod t\u2081 \u2264 s\u2082.prod t\u2082 :=\nset.prod_mono hs ht\n\n@[to_additive prod_top]\nlemma prod_top (s : submonoid M) :\n  s.prod (\u22a4 : submonoid N) = s.comap (monoid_hom.fst M N) :=\next $ \u03bb x, by simp [mem_prod, monoid_hom.coe_fst]\n\n@[to_additive top_prod]\nlemma top_prod (s : submonoid N) :\n  (\u22a4 : submonoid M).prod s = s.comap (monoid_hom.snd M N) :=\next $ \u03bb x, by simp [mem_prod, monoid_hom.coe_snd]\n\n@[simp, to_additive top_prod_top]\nlemma top_prod_top : (\u22a4 : submonoid M).prod (\u22a4 : submonoid N) = \u22a4 :=\n(top_prod _).trans $ comap_top _\n\n@[to_additive] lemma bot_prod_bot : (\u22a5 : submonoid M).prod (\u22a5 : submonoid N) = \u22a5 :=\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 \u2243* s \u00d7 t :=\n{ map_mul' := \u03bb x y, rfl, .. equiv.set.prod \u2191s \u2191t }\n\nopen monoid_hom\n\n@[to_additive]\nlemma map_inl (s : submonoid M) : s.map (inl M N) = s.prod \u22a5 :=\next $ \u03bb p, \u27e8\u03bb \u27e8x, hx, hp\u27e9, hp \u25b8 \u27e8hx, set.mem_singleton 1\u27e9,\n  \u03bb \u27e8hps, hp1\u27e9, \u27e8p.1, hps, prod.ext rfl $ (set.eq_of_mem_singleton hp1).symm\u27e9\u27e9\n\n@[to_additive]\nlemma map_inr (s : submonoid N) : s.map (inr M N) = prod \u22a5 s :=\next $ \u03bb p, \u27e8\u03bb \u27e8x, hx, hp\u27e9, hp \u25b8 \u27e8set.mem_singleton 1, hx\u27e9,\n  \u03bb \u27e8hp1, hps\u27e9, \u27e8p.2, hps, prod.ext (set.eq_of_mem_singleton hp1).symm rfl\u27e9\u27e9\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 \u22a5) \u2294 (prod \u22a5 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 \u25b8 mul_mem _\n  ((le_sup_left : s.prod \u22a5 \u2264 s.prod \u22a5 \u2294 prod \u22a5 t) \u27e8hp.1, set.mem_singleton 1\u27e9)\n  ((le_sup_right : prod \u22a5 t \u2264 s.prod \u22a5 \u2294 prod \u22a5 t) \u27e8set.mem_singleton 1, hp.2\u27e9)\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 `\u21a5(set.range f)` and `\u21a5f.range` are\ninterchangeable without proof obligations.\n\nA convenient candidate definition for range which is mathematically correct is `map \u22a4 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 \u2208 \u22a4`\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 `(\u22a4 : 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 \u25b8 S.one_mem',\n  mul_mem' := hs.symm \u25b8 S.mul_mem' }\n```\nand then finally define:\n```lean\ndef mrange (f : M \u2192* N) : submonoid N :=\n((\u22a4 : 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 \u2192* N) : submonoid N :=\n((\u22a4 : submonoid M).map f).copy (set.range f) set.image_univ.symm\n\n@[simp, to_additive]\nlemma coe_mrange (f : M \u2192* N) :\n  (f.mrange : set N) = set.range f :=\nrfl\n\n@[simp, to_additive] lemma mem_mrange {f : M \u2192* N} {y : N} :\n  y \u2208 f.mrange \u2194 \u2203 x, f x = y :=\niff.rfl\n\n@[to_additive] lemma mrange_eq_map (f : M \u2192* N) : f.mrange = (\u22a4 : submonoid M).map f :=\nby ext; simp\n\n@[to_additive]\nlemma map_mrange (g : N \u2192* P) (f : M \u2192* N) : f.mrange.map g = (g.comp f).mrange :=\nby simpa only [mrange_eq_map] using (\u22a4 : submonoid M).map_map g f\n\n@[to_additive]\nlemma mrange_top_iff_surjective {N} [mul_one_class N] {f : M \u2192* N} :\n  f.mrange = (\u22a4 : submonoid N) \u2194 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 \u2192* N) (hf : function.surjective f) :\n  f.mrange = (\u22a4 : submonoid N) :=\nmrange_top_iff_surjective.2 hf\n\n@[to_additive]\nlemma mclosure_preimage_le (f : M \u2192* N) (s : set N) :\n  closure (f \u207b\u00b9' s) \u2264 (closure s).comap f :=\nclosure_le.2 $ \u03bb 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 \u2192* 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 \u2192* N) (S : submonoid M) : S \u2192* N :=\nf.comp S.subtype\n\n@[simp, to_additive]\nlemma mrestrict_apply {N : Type*} [mul_one_class N] (f : M \u2192* 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 \u2192* N) (S : submonoid N) (h : \u2200 x, f x \u2208 S) : M \u2192* S :=\n{ to_fun := \u03bb n, \u27e8f n, h n\u27e9,\n  map_one' := subtype.eq f.map_one,\n  map_mul' := \u03bb 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 \u2192* N) : M \u2192* f.mrange :=\nf.cod_mrestrict f.mrange $ \u03bb x, \u27e8x, rfl\u27e9\n\n@[simp, to_additive]\nlemma coe_mrange_restrict {N} [mul_one_class N] (f : M \u2192* 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 \u22a4 \u22a5 :=\nby simpa only [mrange_eq_map] using map_inl \u22a4\n\n@[to_additive]\nlemma mrange_inr : (inr M N).mrange = prod \u22a5 \u22a4 :=\nby simpa only [mrange_eq_map] using map_inr \u22a4\n\n@[to_additive]\nlemma mrange_inl' : (inl M N).mrange = comap (snd M N) \u22a5 := mrange_inl.trans (top_prod _)\n\n@[to_additive]\nlemma mrange_inr' : (inr M N).mrange = comap (fst M N) \u22a5 := mrange_inr.trans (prod_top _)\n\n@[simp, to_additive]\nlemma mrange_fst : (fst M N).mrange = \u22a4 :=\n(fst M N).mrange_top_of_surjective $ @prod.fst_surjective _ _ \u27e81\u27e9\n\n@[simp, to_additive]\nlemma mrange_snd : (snd M N).mrange = \u22a4 :=\n(snd M N).mrange_top_of_surjective $ @prod.snd_surjective _ _ \u27e81\u27e9\n@[simp, to_additive]\n\nlemma mrange_inl_sup_mrange_inr : (inl M N).mrange \u2294 (inr M N).mrange = \u22a4 :=\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 \u2264 T) : S \u2192* T :=\nS.subtype.cod_mrestrict _ (\u03bb 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 = \u22a4 \u2194 \u2200 x : M, x \u2208 S :=\neq_top_iff.trans \u27e8\u03bb h m, h $ mem_top m, \u03bb h m _, h m\u27e9\n\n@[to_additive] lemma eq_bot_iff_forall : S = \u22a5 \u2194 \u2200 x \u2208 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 \u27e8h x, by { rintros rfl, exact S.one_mem }\u27e9 },\nend\n\n@[to_additive] lemma nontrivial_iff_exists_ne_one (S : submonoid M) :\n  nontrivial S \u2194 \u2203 x \u2208 S, x \u2260 (1:M) :=\nbegin\n  split,\n  { introI h,\n    rcases exists_ne (1 : S) with \u27e8\u27e8h, h_in\u27e9, h_ne\u27e9,\n    use [h, h_in],\n    intro hyp,\n    apply  h_ne,\n    simpa [hyp] },\n  { rintros \u27e8x, x_in, hx\u27e9,\n    apply nontrivial_of_ne (\u27e8x, x_in\u27e9 : 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 = \u22a5 \u2228 nontrivial S :=\nbegin\n  classical,\n  by_cases h : \u2200 x \u2208 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 = \u22a5 \u2228 \u2203 x \u2208 S, x \u2260 (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 \u2243* T :=\n{ map_mul' :=  \u03bb _ _, 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 (\u03b1 : Type*) [boolean_algebra \u03b1] : BoolAlg := bundled.of \u03b1\n\n@[simp] lemma coe_of (\u03b1 : Type*) [boolean_algebra \u03b1] : \u21a5(of \u03b1) = \u03b1 := rfl\n\ninstance : inhabited BoolAlg := \u27e8of punit\u27e9\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) : \u21a5X.to_BoundedDistribLattice = \u21a5X := 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\u2082 BoolAlg BoundedDistribLattice :=\ninduced_category.has_forget\u2082 to_BoundedDistribLattice\n\n/-- Constructs an equivalence between boolean algebras from an order isomorphism\nbetween them. -/\n@[simps] def iso.mk {\u03b1 \u03b2 : BoolAlg.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2 :=\n{ hom := (e : bounded_lattice_hom \u03b1 \u03b2),\n  inv := (e.symm : bounded_lattice_hom \u03b2 \u03b1),\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 \u2964 BoolAlg :=\n{ obj := \u03bb X, of (order_dual X), map := \u03bb 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 \u224c BoolAlg :=\nequivalence.mk dual dual\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n\nend BoolAlg\n\nlemma BoolAlg_dual_comp_forget_to_BoundedDistribLattice :\n  BoolAlg.dual \u22d9 forget\u2082 BoolAlg BoundedDistribLattice =\n    forget\u2082 BoolAlg BoundedDistribLattice \u22d9 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 := \u2115 \u2192 \u211a\n\ndef bound (x\u2099 : sequence) (K : \u211a) : Prop := \u2200 i, (-K \u2264 x\u2099 i \u2227 x\u2099 i \u2264 K)\n\ndef bounded (x\u2099 : sequence) : Prop := \u2203 K, bound x\u2099 K\n\ndef sequence_6_1 : sequence := \u03bb n, 1 / (n + 1)\ndef sequence_6_2 : sequence := \u03bb n, 2 ^ (n + 1)\ndef sequence_6_3 (a : \u211a) : sequence := \u03bb n, a ^ (n + 1)\ndef sequence_6_4 : sequence := \u03bb n, \u2191((n + 1) % 2)\ndef sequence_6_6 : sequence := \u03bb n, ((-1) ^ n) / (n + 1)\ndef sequence_6_7 : sequence := nat.fix $ \u03bb n x, dmatch n with\n  | 0 := 1\n  | 1 := 1\n  | (m + 2) := x \u27e8m + 1, _\u27e9 + x \u27e8m, _\u27e9\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 : (\u22a4 : 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 : (\u22a4 : 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\u2203 (n : \u2115) (f : mv_polynomial (fin n) R \u2192\u2090[R] A),\n  surjective f \u2227 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 \u2194 (\u22a4 : submodule R M).fg := \u27e8\u03bb h, h.1, \u03bb h, \u27e8h\u27e9\u27e9\n\n@[priority 100] -- see Note [lower instance priority]\ninstance is_noetherian.finite [is_noetherian R M] : finite R M :=\n\u27e8is_noetherian.noetherian \u22a4\u27e9\n\nnamespace finite\nopen _root_.submodule set\n\nlemma iff_add_monoid_fg {M : Type*} [add_comm_monoid M] : module.finite \u2115 M \u2194 add_monoid.fg M :=\n\u27e8\u03bb h, add_monoid.fg_def.2 $ (fg_iff_add_submonoid_fg \u22a4).1 (finite_def.1 h),\n  \u03bb h, finite_def.2 $ (fg_iff_add_submonoid_fg \u22a4).2 (add_monoid.fg_def.1 h)\u27e9\n\nlemma iff_add_group_fg {G : Type*} [add_comm_group G] : module.finite \u2124 G \u2194 add_group.fg G :=\n\u27e8\u03bb h, add_group.fg_def.2 $ (fg_iff_add_subgroup_fg \u22a4).1 (finite_def.1 h),\n  \u03bb h, finite_def.2 $ (fg_iff_add_subgroup_fg \u22a4).2 (add_group.fg_def.1 h)\u27e9\n\nvariables {R M N}\n\nlemma exists_fin [finite R M] : \u2203 (n : \u2115) (s : fin n \u2192 M), span R (range s) = \u22a4 :=\nsubmodule.fg_iff_exists_fin_generating_family.mp out\n\nlemma of_surjective [hM : finite R M] (f : M \u2192\u2097[R] N) (hf : surjective f) :\n  finite R N :=\n\u27e8begin\n  rw [\u2190 linear_map.range_eq_top.2 hf, \u2190 submodule.map_top],\n  exact submodule.fg_map hM.1\nend\u27e9\n\nlemma of_injective [is_noetherian R N] (f : M \u2192\u2097[R] N)\n  (hf : function.injective f) : finite R M :=\n\u27e8fg_of_injective f hf\u27e9\n\nvariables (R)\n\ninstance self : finite R R :=\n\u27e8\u27e8{1}, by simpa only [finset.coe_singleton] using ideal.span_singleton_one\u27e9\u27e9\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 \u22a2,\n  obtain \u27e8S, hSfin, hSgen\u27e9 := hM,\n  refine \u27e8S, hSfin, eq_top_iff.2 _\u27e9,\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 \u00d7 N) :=\n\u27e8begin\n  rw \u2190 submodule.prod_top,\n  exact submodule.fg_prod hM.1 hN.1\nend\u27e9\n\nlemma equiv [hM : finite R M] (e : M \u2243\u2097[R] N) : finite R N :=\nof_surjective (e : M \u2192\u2097[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  \u2200 [finite R A] [finite A B], finite R B\n| \u27e8\u27e8s, hs\u27e9\u27e9 \u27e8\u27e8t, ht\u27e9\u27e9 := \u27e8submodule.fg_def.2\n  \u27e8set.image2 (\u2022) (\u2191s : set A) (\u2191t : set B),\n    set.finite.image2 _ s.finite_to_set t.finite_to_set,\n    by rw [set.image2_smul, submodule.span_smul hs (\u2191t : set B),\n      ht, submodule.restrict_scalars_top]\u27e9\u27e9\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\u27e8subalgebra.fg_of_submodule_fg hRA.1\u27e9\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 := \u27e8\u27e8{1}, subsingleton.elim _ _\u27e9\u27e9\n\nsection\nopen_locale classical\n\nprotected lemma mv_polynomial (\u03b9 : Type*) [fintype \u03b9] : finite_type R (mv_polynomial \u03b9 R) :=\n\u27e8\u27e8finset.univ.image mv_polynomial.X, begin\n  rw eq_top_iff, refine \u03bb p, mv_polynomial.induction_on' p\n    (\u03bb u x, finsupp.induction u (subalgebra.algebra_map_mem _ x)\n      (\u03bb i n f hif hn ih, _))\n    (\u03bb 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\u27e9\u27e9\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 \u27e8S, hS\u27e9 := hB.out,\n  refine \u27e8\u27e8S, eq_top_iff.2 (\u03bb b, _)\u27e9\u27e9,\n  have le : adjoin R (S : set B) \u2264 subalgebra.restrict_scalars R (adjoin A S),\n  { apply (algebra.adjoin_le _ : _ \u2264 (subalgebra.restrict_scalars R (adjoin A \u2191S))),\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 \u2192\u2090[R] B) (hf : surjective f) :\n  finite_type R B :=\n\u27e8begin\n  convert subalgebra.fg_map _ f hRA.1,\n  simpa only [map_top f, @eq_comm _ \u22a4, eq_top_iff, alg_hom.mem_range] using hf\nend\u27e9\n\nlemma equiv (hRA : finite_type R A) (e : A \u2243\u2090[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\u27e8fg_trans' hRA.1 hAB.1\u27e9\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) \u2194 \u2203 (s : finset A)\n  (f : (mv_polynomial {x // x \u2208 s} R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rintro \u27e8s, hs\u27e9,\n    use [s, mv_polynomial.aeval coe],\n    intro x,\n    have hrw : (\u2191s : set A) = (\u03bb (x : A), x \u2208 s.val) := rfl,\n    rw [\u2190 set.mem_range, \u2190 alg_hom.coe_range, \u2190 adjoin_eq_range, \u2190 hrw, hs],\n    exact set.mem_univ x },\n  { rintro \u27e8s, \u27e8f, hsur\u27e9\u27e9,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R {x // x \u2208 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) \u2194 \u2203 (\u03b9 : Type u_2) (_ : fintype \u03b9)\n  (f : (mv_polynomial \u03b9 R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial,\n    rintro \u27e8s, \u27e8f, hsur\u27e9\u27e9,\n    use [{x // x \u2208 s}, by apply_instance, f, hsur] },\n  { rintro \u27e8\u03b9, \u27e8hfintype, \u27e8f, hsur\u27e9\u27e9\u27e9,\n    letI : fintype \u03b9 := hfintype,\n    exact finite_type.of_surjective (finite_type.mv_polynomial R \u03b9) 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) \u2194 \u2203 (n : \u2115)\n  (f : (mv_polynomial (fin n) R) \u2192\u2090[R] A), (surjective f) :=\nbegin\n  split,\n  { rw iff_quotient_mv_polynomial',\n    rintro \u27e8\u03b9, hfintype, \u27e8f, hsur\u27e9\u27e9,\n    letI := hfintype,\n    obtain \u27e8equiv\u27e9 := @fintype.trunc_equiv_fin \u03b9 (classical.dec_eq \u03b9) hfintype,\n    replace equiv := mv_polynomial.rename_equiv R equiv,\n    exact \u27e8fintype.card \u03b9, alg_hom.comp f equiv.symm, function.surjective.comp hsur\n      (alg_equiv.symm equiv).surjective\u27e9 },\n  { rintro \u27e8n, \u27e8f, hsur\u27e9\u27e9,\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 \u2192 finite_type R A :=\nbegin\n  rintro \u27e8n, f, hf\u27e9,\n  apply (finite_type.iff_quotient_mv_polynomial'').2,\n  exact \u27e8n, f, hf.1\u27e9\nend\n\ninstance prod [hA : finite_type R A] [hB : finite_type R B] : finite_type R (A \u00d7 B) :=\n\u27e8begin\n  rw \u2190 subalgebra.prod_top,\n  exact subalgebra.fg_prod hA.1 hB.1\nend\u27e9\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 \u2194 finite_presentation R A :=\nbegin\n  refine \u27e8\u03bb h, _, algebra.finite_type.of_finite_presentation\u27e9,\n  obtain \u27e8n, f, hf\u27e9 := algebra.finite_type.iff_quotient_mv_polynomial''.1 h,\n  refine \u27e8n, f, hf, _\u27e9,\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 \u2243\u2090[R] B` and `A` is finitely presented, then so is `B`. -/\nlemma equiv (hfp : finite_presentation R A) (e : A \u2243\u2090[R] B) : finite_presentation R B :=\nbegin\n  obtain \u27e8n, f, hf\u27e9 := hfp,\n  use [n, alg_hom.comp \u2191e f],\n  split,\n  { exact function.surjective.comp e.surjective hf.1 },\n  suffices hker : (alg_hom.comp \u2191e f).to_ring_hom.ker = f.to_ring_hom.ker,\n  { rw hker, exact hf.2 },\n  { have hco : (alg_hom.comp \u2191e f).to_ring_hom = ring_hom.comp \u2191e.to_ring_equiv f.to_ring_hom,\n    { have h : (alg_hom.comp \u2191e f).to_ring_hom = e.to_alg_hom.to_ring_hom.comp f.to_ring_hom := rfl,\n      have h1 : \u2191(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, \u2190 ideal.comap_comap, \u2190 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 (\u03b9 : Type u_2) [fintype \u03b9] :\n  finite_presentation R (mv_polynomial \u03b9 R) :=\nbegin\n  obtain \u27e8equiv\u27e9 := @fintype.trunc_equiv_fin \u03b9 (classical.dec_eq \u03b9) _,\n  replace equiv := mv_polynomial.rename_equiv R equiv,\n  refine \u27e8_, alg_equiv.to_alg_hom equiv.symm, _\u27e9,\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 \u29f8 I) :=\nbegin\n  obtain \u27e8n, f, hf\u27e9 := hfp,\n  refine \u27e8n, (ideal.quotient.mk\u2090 R I).comp f, _, _\u27e9,\n  { exact (ideal.quotient.mk\u2090_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 \u2192\u2090[R] B` is surjective with finitely generated kernel and `A` is finitely presented,\nthen so is `B`. -/\nlemma of_surjective {f : A \u2192\u2090[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 \u2194\n  \u2203 n (I : ideal (mv_polynomial (fin n) R)) (e : (_ \u29f8 I) \u2243\u2090[R] A), I.fg :=\nbegin\n  split,\n  { rintros \u27e8n, f, hf\u27e9,\n    exact \u27e8n, f.to_ring_hom.ker, ideal.quotient_ker_alg_equiv_of_surjective hf.1, hf.2\u27e9 },\n  { rintros \u27e8n, I, e, hfg\u27e9,\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 \u2194 \u2203 (\u03b9 : Type u_2) (_ : fintype \u03b9)\n  (f : mv_polynomial \u03b9 R \u2192\u2090[R] A), surjective f \u2227 f.to_ring_hom.ker.fg :=\nbegin\n  split,\n  { rintro \u27e8n, f, hfs, hfk\u27e9,\n    set ulift_var := mv_polynomial.rename_equiv R equiv.ulift,\n    refine \u27e8ulift (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\u27e9,\n    convert submodule.fg_bot,\n    exact ring_hom.ker_coe_equiv ulift_var.to_ring_equiv, },\n  { rintro \u27e8\u03b9, hfintype, f, hf\u27e9,\n    haveI : fintype \u03b9 := hfintype,\n    obtain \u27e8equiv\u27e9 := @fintype.trunc_equiv_fin \u03b9 (classical.dec_eq \u03b9) _,\n    replace equiv := mv_polynomial.rename_equiv R equiv,\n    refine \u27e8fintype.card \u03b9, 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\u27e9,\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) (\u03b9 : Type*)\n  [fintype \u03b9] : finite_presentation R (mv_polynomial \u03b9 A) :=\nbegin\n  rw iff_quotient_mv_polynomial' at hfp \u22a2,\n  classical,\n  obtain \u27e8\u03b9', _, f, hf_surj, hf_ker\u27e9 := hfp,\n  resetI,\n  let g := (mv_polynomial.map_alg_hom f).comp (mv_polynomial.sum_alg_equiv R \u03b9 \u03b9').to_alg_hom,\n  refine \u27e8\u03b9 \u2295 \u03b9', 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 _)\u27e9,\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 \u27e8n, I, e, hfg\u27e9 := 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 \u2192+* B` is `finite` if `B` is finitely generated as `A`-module. -/\ndef finite (f : A \u2192+* B) : Prop :=\nby letI : algebra A B := f.to_algebra; exact module.finite A B\n\n/-- A ring morphism `A \u2192+* B` is of `finite_type` if `B` is finitely generated as `A`-algebra. -/\ndef finite_type (f : A \u2192+* B) : Prop := @algebra.finite_type A B _ _ f.to_algebra\n\n/-- A ring morphism `A \u2192+* B` is of `finite_presentation` if `B` is finitely presented as\n`A`-algebra. -/\ndef finite_presentation (f : A \u2192+* 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 \u2192+* 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 \u2192+* C} {f : A \u2192+* 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 \u2192+* B} (hf : f.finite) : finite_type f :=\n@module.finite.finite_type _ _ _ _ f.to_algebra hf\n\nlemma of_comp_finite {f : A \u2192+* B} {g : B \u2192+* 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 \u2192+* B} {g : B \u2192+* 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' := \u03bb a, rfl, .. g } hg\n\nlemma of_surjective (f : A \u2192+* B) (hf : surjective f) : f.finite_type :=\nby { rw \u2190 f.comp_id, exact (id A).comp_surjective hf }\n\nlemma comp {g : B \u2192+* C} {f : A \u2192+* 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 \u2192+* 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 \u2192+* B} {g : B \u2192+* 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 \u2192+* B} {g : B \u2192+* 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' := \u03bb a, rfl, .. g } hg hker hf\n\nlemma of_surjective (f : A \u2192+* B) (hf : surjective f) (hker : f.ker.fg) : f.finite_presentation :=\nby { rw \u2190 f.comp_id, exact (id A).comp_surjective hf hker}\n\nlemma of_finite_type [is_noetherian_ring A] {f : A \u2192+* B} : f.finite_type \u2194 f.finite_presentation :=\n@algebra.finite_presentation.of_finite_type A B _ _ f.to_algebra _\n\nlemma comp {g : B \u2192+* C} {f : A \u2192+* 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 := \u03bb 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 \u2192\u2090[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 \u2192\u2090[R] B) : Prop := f.to_ring_hom.finite\n\n/-- An algebra morphism `A \u2192\u2090[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 \u2192\u2090[R] B) : Prop := f.to_ring_hom.finite_type\n\n/-- An algebra morphism `A \u2192\u2090[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 \u2192\u2090[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 \u2192\u2090[R] C} {f : A \u2192\u2090[R] B} (hg : g.finite) (hf : f.finite) : (g.comp f).finite :=\nring_hom.finite.comp hg hf\n\nlemma of_surjective (f : A \u2192\u2090[R] B) (hf : surjective f) : f.finite :=\nring_hom.finite.of_surjective f hf\n\nlemma finite_type {f : A \u2192\u2090[R] B} (hf : f.finite) : finite_type f :=\nring_hom.finite.finite_type hf\n\nlemma of_comp_finite {f : A \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[R] C} {f : A \u2192\u2090[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 \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[R] B) (hf : surjective f) : f.finite_type :=\nring_hom.finite_type.of_surjective f hf\n\nlemma of_finite_presentation {f : A \u2192\u2090[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 \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[R] C} {f : A \u2192\u2090[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 \u2192\u2090[R] B} {g : B \u2192\u2090[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 \u2192\u2090[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 \u2192\u2090[R] B} :\n  f.finite_type \u2194 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 \u2208 adjoin R (of' R M '' f.support) :=\nbegin\n  suffices : span R (of' R M '' f.support) \u2264 (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 = \u22a4) :\n  algebra.adjoin R (\u22c3 f \u2208 S, (of' R M '' (f.support : set M))) = \u22a4 :=\nbegin\n  refine le_antisymm le_top _,\n  rw [\u2190 hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : of' R M '' f.support \u2286\n    \u22c3 (g : add_monoid_algebra R M) (H : g \u2208 S), of' R M '' g.support,\n  { intros s hs,\n    exact set.mem_bUnion_iff.2 \u27e8f, \u27e8hf, hs\u27e9\u27e9 },\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 = \u22a4) :\n  algebra.adjoin R (of' R M '' (\u22c3 f \u2208 S, (f.support : set M))) = \u22a4 :=\nbegin\n  suffices : of' R M '' (\u22c3 f \u2208 S, (f.support : set M)) = \u22c3 f \u2208 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  \u2203 G : finset M, algebra.adjoin R (of' R M '' G) = \u22a4 :=\nbegin\n  unfreezingI { obtain \u27e8S, hS\u27e9 := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (\u03bb f, f.support),\n  have : (finset.bUnion S (\u03bb f, f.support) : set M) = \u22c3 f \u2208 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 \u2208 S`. -/\nlemma of'_mem_span [nontrivial R] {m : M} {S : set M} :\n  of' R M m \u2208 span R (of' R M '' S) \u2194 m \u2208 S :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, submodule.subset_span $ set.mem_image_of_mem (of R M) h\u27e9,\n  rw [of', \u2190 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 \u2208 closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of' R M m \u2208 span R (submonoid.closure (of' R M '' S) : set (add_monoid_algebra R M))) :\n  m \u2208 closure S :=\nbegin\n  suffices : multiplicative.of_add m \u2208 submonoid.closure (multiplicative.to_add \u207b\u00b9' S),\n  { simpa [\u2190 to_submonoid_closure] },\n  rw [set.image_congr' (show \u2200 x, of' R M x = of R M x, from \u03bb x, of'_eq_of x),\n    \u2190 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 = \u22a4) : function.surjective (mv_polynomial.aeval\n  (\u03bb (s : S), of' R M \u2191s) : mv_polynomial S R \u2192 add_monoid_algebra R M) :=\nbegin\n  refine \u03bb f, induction_on f (\u03bb m, _) _ _,\n  { have : m \u2208 closure S := hS.symm \u25b8 mem_top _,\n    refine closure_induction this (\u03bb m hm, _) _ _,\n    { exact \u27e8mv_polynomial.X \u27e8m, hm\u27e9, mv_polynomial.aeval_X _ _\u27e9 },\n    { exact \u27e81, alg_hom.map_one _\u27e9 },\n    { rintro m\u2081 m\u2082 \u27e8P\u2081, hP\u2081\u27e9 \u27e8P\u2082, hP\u2082\u27e9,\n      exact \u27e8P\u2081 * P\u2082, by rw [alg_hom.map_mul, hP\u2081, hP\u2082, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]; refl\u27e9 } },\n  { rintro f g \u27e8P, rfl\u27e9 \u27e8Q, rfl\u27e9,\n    exact \u27e8P + Q, alg_hom.map_add _ _ _\u27e9 },\n  { rintro r f \u27e8P, rfl\u27e9,\n    exact \u27e8r \u2022 P, alg_hom.map_smul _ _ _\u27e9 }\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 \u27e8S, hS\u27e9 := h.out,\n  exact (finite_type.mv_polynomial R (S : set M)).of_surjective (mv_polynomial.aeval\n    (\u03bb (s : (S : set M)), of' R M \u2191s)) (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) \u2194 add_monoid.fg M :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, @add_monoid_algebra.finite_type_of_fg _ _ _ _ h\u27e9,\n  obtain \u27e8S, hS\u27e9 := @exists_finset_adjoin_eq_top R M _ _ h,\n  refine add_monoid.fg_def.2 \u27e8S, (eq_top_iff' _).2 (\u03bb m, _)\u27e9,\n  have hm : of' R M m \u2208 (adjoin R (of' R M '' \u2191S)).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) \u2194 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 \u2208 adjoin R (of R M '' f.support) :=\nbegin\n  suffices : span R (of R M '' f.support) \u2264 (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 = \u22a4) :\n  algebra.adjoin R (\u22c3 f \u2208 S, (of R M '' (f.support : set M))) = \u22a4 :=\nbegin\n  refine le_antisymm le_top _,\n  rw [\u2190 hS, adjoin_le_iff],\n  intros f hf,\n  have hincl : (of R M) '' f.support \u2286\n    \u22c3 (g : monoid_algebra R M) (H : g \u2208 S), of R M '' g.support,\n  { intros s hs,\n    exact set.mem_bUnion_iff.2 \u27e8f, \u27e8hf, hs\u27e9\u27e9 },\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 = \u22a4) :\n  algebra.adjoin R (of R M '' (\u22c3 f \u2208 S, (f.support : set M))) = \u22a4 :=\nbegin\n  suffices : of R M '' (\u22c3 f \u2208 S, (f.support : set M)) = \u22c3 f \u2208 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  \u2203 G : finset M, algebra.adjoin R (of R M '' G) = \u22a4 :=\nbegin\n  unfreezingI { obtain \u27e8S, hS\u27e9 := h },\n  letI : decidable_eq M := classical.dec_eq M,\n  use finset.bUnion S (\u03bb f, f.support),\n  have : (finset.bUnion S (\u03bb f, f.support) : set M) = \u22c3 f \u2208 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 \u2208 S`. -/\nlemma of_mem_span_of_iff [nontrivial R] {m : M} {S : set M} :\n  of R M m \u2208 span R (of R M '' S) \u2194 m \u2208 S :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, submodule.subset_span $ set.mem_image_of_mem (of R M) h\u27e9,\n  rw [of, monoid_hom.coe_mk, \u2190 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 \u2208 closure S`. -/\nlemma mem_closure_of_mem_span_closure [nontrivial R] {m : M} {S : set M}\n  (h : of R M m \u2208 span R (submonoid.closure (of R M '' S) : set (monoid_algebra R M))) :\n  m \u2208 closure S :=\nbegin\n  rw \u2190 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 = \u22a4) : function.surjective (mv_polynomial.aeval\n  (\u03bb (s : S), of R M \u2191s) : mv_polynomial S R \u2192 monoid_algebra R M) :=\nbegin\n  refine \u03bb f, induction_on f (\u03bb m, _) _ _,\n  { have : m \u2208 closure S := hS.symm \u25b8 mem_top _,\n    refine closure_induction this (\u03bb m hm, _) _ _,\n    { exact \u27e8mv_polynomial.X \u27e8m, hm\u27e9, mv_polynomial.aeval_X _ _\u27e9 },\n    { exact \u27e81, alg_hom.map_one _\u27e9 },\n    { rintro m\u2081 m\u2082 \u27e8P\u2081, hP\u2081\u27e9 \u27e8P\u2082, hP\u2082\u27e9,\n      exact \u27e8P\u2081 * P\u2082, by rw [alg_hom.map_mul, hP\u2081, hP\u2082, of_apply, of_apply, of_apply,\n        single_mul_single, one_mul]\u27e9 } },\n  { rintro f g \u27e8P, rfl\u27e9 \u27e8Q, rfl\u27e9,\n    exact \u27e8P + Q, alg_hom.map_add _ _ _\u27e9 },\n  { rintro r f \u27e8P, rfl\u27e9,\n    exact \u27e8r \u2022 P, alg_hom.map_smul _ _ _\u27e9 }\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) \u2194 monoid.fg M :=\n\u27e8\u03bb h, monoid.fg_iff_add_fg.2 $ add_monoid_algebra.finite_type_iff_fg.1 $ h.equiv $\n  to_additive_alg_equiv R M, \u03bb h, @monoid_algebra.finite_type_of_fg _ _ _ _ h\u27e9\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) \u2194 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\u1d50\u1d52\u1d56 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 \u21a6 c +\u1d65 x` is an isometry. -/\nclass IsometricVAdd [PseudoEMetricSpace X] [VAdd M X] : Prop where\n  isometry_vadd : \u2200 c : M, Isometry ((\u00b7 +\u1d65 \u00b7) c : X \u2192 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 \u21a6 c \u2022 x` is an isometry. -/\n@[to_additive]\nclass IsometricSMul [PseudoEMetricSpace X] [SMul M X] : Prop where\n  isometry_smul : \u2200 c : M, Isometry ((\u00b7 \u2022 \u00b7) c : X \u2192 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  \u27e8fun c => (isometry_smul X c).Continuous\u27e9\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\u1d50\u1d52\u1d56 X] [IsCentralScalar M X] [IsometricSMul M X] : IsometricSMul M\u1d50\u1d52\u1d56 X :=\n  \u27e8fun c x y => by simpa only [\u2190 op_smul_eq_smul] using isometry_smul X c.unop x y\u27e9\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 \u2022 x) (c \u2022 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 ((\u00b7 * \u00b7) 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\u1d50\u1d52\u1d56 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\u1d50\u1d52\u1d56 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\u2093'. -/\n@[simp, to_additive]\ntheorem edist_div_right [DivInvMonoid M] [PseudoEMetricSpace M] [IsometricSMul M\u1d50\u1d52\u1d56 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\u2093'. -/\n@[simp, to_additive]\ntheorem edist_inv_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul G\u1d50\u1d52\u1d56 G] (a b : G) :\n    edist a\u207b\u00b9 b\u207b\u00b9 = edist a b := by\n  rw [\u2190 edist_mul_left a, \u2190 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\u2093'. -/\n@[to_additive]\ntheorem isometry_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul G\u1d50\u1d52\u1d56 G] :\n    Isometry (Inv.inv : G \u2192 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\u2093'. -/\n@[to_additive]\ntheorem edist_inv [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul G\u1d50\u1d52\u1d56 G] (x y : G) :\n    edist x\u207b\u00b9 y = edist x y\u207b\u00b9 := by rw [\u2190 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\u2093'. -/\n@[simp, to_additive]\ntheorem edist_div_left [PseudoEMetricSpace G] [IsometricSMul G G] [IsometricSMul G\u1d50\u1d52\u1d56 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 \u2243\u1d62 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\u2093'. -/\n@[simp, to_additive]\ntheorem constSMul_symm (c : G) : (constSMul c : X \u2243\u1d62 X).symm = constSMul c\u207b\u00b9 :=\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\u2093'. -/\n/-- Multiplication `y \u21a6 x * y` as an `isometry_equiv`. -/\n@[to_additive \"Addition `y \u21a6 x + y` as an `isometry_equiv`.\", simps apply toEquiv]\ndef mulLeft [IsometricSMul G G] (c : G) : G \u2243\u1d62 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\u2093'. -/\n@[simp, to_additive]\ntheorem mulLeft_symm [IsometricSMul G G] (x : G) : (mulLeft x).symm = IsometryEquiv.mulLeft x\u207b\u00b9 :=\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\u2093'. -/\n--ext $ \u03bb y, rfl\n/-- Multiplication `y \u21a6 y * x` as an `isometry_equiv`. -/\n@[to_additive \"Addition `y \u21a6 y + x` as an `isometry_equiv`.\", simps apply toEquiv]\ndef mulRight [IsometricSMul G\u1d50\u1d52\u1d56 G] (c : G) : G \u2243\u1d62 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\u2093'. -/\n@[simp, to_additive]\ntheorem mulRight_symm [IsometricSMul G\u1d50\u1d52\u1d56 G] (x : G) : (mulRight x).symm = mulRight x\u207b\u00b9 :=\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\u2093'. -/\n/-- Division `y \u21a6 y / x` as an `isometry_equiv`. -/\n@[to_additive \"Subtraction `y \u21a6 y - x` as an `isometry_equiv`.\", simps apply toEquiv]\ndef divRight [IsometricSMul G\u1d50\u1d52\u1d56 G] (c : G) : G \u2243\u1d62 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\u2093'. -/\n@[simp, to_additive]\ntheorem divRight_symm [IsometricSMul G\u1d50\u1d52\u1d56 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\u1d50\u1d52\u1d56 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\u2093'. -/\n/-- Division `y \u21a6 x / y` as an `isometry_equiv`. -/\n@[to_additive \"Subtraction `y \u21a6 x - y` as an `isometry_equiv`.\", simps apply symm_apply toEquiv]\ndef divLeft (c : G) : G \u2243\u1d62 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\u2093'. -/\n/-- Inversion `x \u21a6 x\u207b\u00b9` as an `isometry_equiv`. -/\n@[to_additive \"Negation `x \u21a6 -x` as an `isometry_equiv`.\", simps apply toEquiv]\ndef inv : G \u2243\u1d62 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\u2093'. -/\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 : \u211d\u22650\u221e) : c \u2022 ball x r = ball (c \u2022 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_smul_ball (c : G) (x : X) (r : \u211d\u22650\u221e) : (\u00b7 \u2022 \u00b7) c \u207b\u00b9' ball x r = ball (c\u207b\u00b9 \u2022 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 : \u211d\u22650\u221e) : c \u2022 closedBall x r = closedBall (c \u2022 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_smul_closedBall (c : G) (x : X) (r : \u211d\u22650\u221e) :\n    (\u00b7 \u2022 \u00b7) c \u207b\u00b9' closedBall x r = closedBall (c\u207b\u00b9 \u2022 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_mul_left_ball [IsometricSMul G G] (a b : G) (r : \u211d\u22650\u221e) :\n    (\u00b7 * \u00b7) a \u207b\u00b9' ball b r = ball (a\u207b\u00b9 * 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_mul_right_ball [IsometricSMul G\u1d50\u1d52\u1d56 G] (a b : G) (r : \u211d\u22650\u221e) :\n    (fun x => x * a) \u207b\u00b9' 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_mul_left_closedBall [IsometricSMul G G] (a b : G) (r : \u211d\u22650\u221e) :\n    (\u00b7 * \u00b7) a \u207b\u00b9' closedBall b r = closedBall (a\u207b\u00b9 * 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_mul_right_closedBall [IsometricSMul G\u1d50\u1d52\u1d56 G] (a b : G) (r : \u211d\u22650\u221e) :\n    (fun x => x * a) \u207b\u00b9' 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 \u2022 x) (c \u2022 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 \u2022 x) (c \u2022 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\u1d50\u1d52\u1d56 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\u1d50\u1d52\u1d56 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\u2093'. -/\n@[simp, to_additive]\ntheorem dist_div_right [DivInvMonoid M] [PseudoMetricSpace M] [IsometricSMul M\u1d50\u1d52\u1d56 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\u2093'. -/\n@[simp, to_additive]\ntheorem nndist_div_right [DivInvMonoid M] [PseudoMetricSpace M] [IsometricSMul M\u1d50\u1d52\u1d56 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\u2093'. -/\n@[simp, to_additive]\ntheorem dist_inv_inv [Group G] [PseudoMetricSpace G] [IsometricSMul G G] [IsometricSMul G\u1d50\u1d52\u1d56 G]\n    (a b : G) : dist a\u207b\u00b9 b\u207b\u00b9 = 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\u2093'. -/\n@[simp, to_additive]\ntheorem nndist_inv_inv [Group G] [PseudoMetricSpace G] [IsometricSMul G G] [IsometricSMul G\u1d50\u1d52\u1d56 G]\n    (a b : G) : nndist a\u207b\u00b9 b\u207b\u00b9 = 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\u2093'. -/\n@[simp, to_additive]\ntheorem dist_div_left [Group G] [PseudoMetricSpace G] [IsometricSMul G G] [IsometricSMul G\u1d50\u1d52\u1d56 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\u2093'. -/\n@[simp, to_additive]\ntheorem nndist_div_left [Group G] [PseudoMetricSpace G] [IsometricSMul G G] [IsometricSMul G\u1d50\u1d52\u1d56 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 : \u211d) : c \u2022 ball x r = ball (c \u2022 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_smul_ball (c : G) (x : X) (r : \u211d) : (\u00b7 \u2022 \u00b7) c \u207b\u00b9' ball x r = ball (c\u207b\u00b9 \u2022 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 : \u211d) : c \u2022 closedBall x r = closedBall (c \u2022 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_smul_closedBall (c : G) (x : X) (r : \u211d) :\n    (\u00b7 \u2022 \u00b7) c \u207b\u00b9' closedBall x r = closedBall (c\u207b\u00b9 \u2022 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 : \u211d) : c \u2022 sphere x r = sphere (c \u2022 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_smul_sphere (c : G) (x : X) (r : \u211d) :\n    (\u00b7 \u2022 \u00b7) c \u207b\u00b9' sphere x r = sphere (c\u207b\u00b9 \u2022 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_mul_left_ball [IsometricSMul G G] (a b : G) (r : \u211d) :\n    (\u00b7 * \u00b7) a \u207b\u00b9' ball b r = ball (a\u207b\u00b9 * 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_mul_right_ball [IsometricSMul G\u1d50\u1d52\u1d56 G] (a b : G) (r : \u211d) :\n    (fun x => x * a) \u207b\u00b9' 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_mul_left_closedBall [IsometricSMul G G] (a b : G) (r : \u211d) :\n    (\u00b7 * \u00b7) a \u207b\u00b9' closedBall b r = closedBall (a\u207b\u00b9 * 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\u2093'. -/\n@[simp, to_additive]\ntheorem preimage_mul_right_closedBall [IsometricSMul G\u1d50\u1d52\u1d56 G] (a b : G) (r : \u211d) :\n    (fun x => x * a) \u207b\u00b9' 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 \u00d7 Y) :=\n  \u27e8fun c => (isometry_smul X c).Prod_map (isometry_smul Y c)\u27e9\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 \u00d7 N) (M \u00d7 N) :=\n  \u27e8fun c => (isometry_smul M c.1).Prod_map (isometry_smul N c.2)\u27e9\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\u1d50\u1d52\u1d56 M] [Mul N]\n    [PseudoEMetricSpace N] [IsometricSMul N\u1d50\u1d52\u1d56 N] : IsometricSMul (M \u00d7 N)\u1d50\u1d52\u1d56 (M \u00d7 N) :=\n  \u27e8fun c => (isometry_mul_right c.unop.1).Prod_map (isometry_mul_right c.unop.2)\u27e9\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\u02e3 X :=\n  \u27e8fun c => by convert isometry_smul X (c : M)\u27e9\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\u1d50\u1d52\u1d56 :=\n  \u27e8fun c x y => by simpa only using edist_smul_left c x.unop y.unop\u27e9\n\n#print ULift.isometricSMul /-\n@[to_additive]\ninstance ULift.isometricSMul : IsometricSMul (ULift M) X :=\n  \u27e8fun c => by simpa only using isometry_smul X c.down\u27e9\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  \u27e8fun c x y => by simpa only using edist_smul_left c x.1 y.1\u27e9\n#align ulift.has_isometric_smul' ULift.isometricSMul'\n#align ulift.has_isometric_vadd' ULift.isometricVAdd'\n-/\n\n@[to_additive]\ninstance {\u03b9} {X : \u03b9 \u2192 Type _} [Fintype \u03b9] [\u2200 i, SMul M (X i)] [\u2200 i, PseudoEMetricSpace (X i)]\n    [\u2200 i, IsometricSMul M (X i)] : IsometricSMul M (\u2200 i, X i) :=\n  \u27e8fun c => isometry_dcomp (fun i => (\u00b7 \u2022 \u00b7) c) fun i => isometry_smul (X i) c\u27e9\n\n#print Pi.isometricSMul' /-\n@[to_additive]\ninstance Pi.isometricSMul' {\u03b9} {M X : \u03b9 \u2192 Type _} [Fintype \u03b9] [\u2200 i, SMul (M i) (X i)]\n    [\u2200 i, PseudoEMetricSpace (X i)] [\u2200 i, IsometricSMul (M i) (X i)] :\n    IsometricSMul (\u2200 i, M i) (\u2200 i, X i) :=\n  \u27e8fun c => isometry_dcomp (fun i => (\u00b7 \u2022 \u00b7) (c i)) fun i => isometry_smul _ _\u27e9\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'' {\u03b9} {M : \u03b9 \u2192 Type _} [Fintype \u03b9] [\u2200 i, Mul (M i)]\n    [\u2200 i, PseudoEMetricSpace (M i)] [\u2200 i, IsometricSMul (M i)\u1d50\u1d52\u1d56 (M i)] :\n    IsometricSMul (\u2200 i, M i)\u1d50\u1d52\u1d56 (\u2200 i, M i) :=\n  \u27e8fun c => isometry_dcomp (fun i (x : M i) => x * c.unop i) fun i => isometry_mul_right _\u27e9\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  \u27e8fun c => isometry_smul X c.toMul\u27e9\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'\u2093'. -/\ninstance Additive.isometricVAdd' [Mul M] [PseudoEMetricSpace M] [IsometricSMul M M] :\n    IsometricVAdd (Additive M) (Additive M) :=\n  \u27e8fun c x y => edist_smul_left c.toMul x.toMul y.toMul\u27e9\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''\u2093'. -/\ninstance Additive.isometricVAdd'' [Mul M] [PseudoEMetricSpace M] [IsometricSMul M\u1d50\u1d52\u1d56 M] :\n    IsometricVAdd (Additive M)\u1d43\u1d52\u1d56 (Additive M) :=\n  \u27e8fun c x y => edist_smul_left (MulOpposite.op c.unop.toMul) x.toMul y.toMul\u27e9\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  \u27e8fun c => isometry_vadd X c.toAdd\u27e9\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'\u2093'. -/\ninstance Multiplicative.isometricSMul' [Add M] [PseudoEMetricSpace M] [IsometricVAdd M M] :\n    IsometricSMul (Multiplicative M) (Multiplicative M) :=\n  \u27e8fun c x y => edist_vadd_left c.toAdd x.toAdd y.toAdd\u27e9\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''\u2093'. -/\ninstance Multiplicative.isometricVAdd'' [Add M] [PseudoEMetricSpace M] [IsometricVAdd M\u1d43\u1d52\u1d56 M] :\n    IsometricSMul (Multiplicative M)\u1d50\u1d52\u1d56 (Multiplicative M) :=\n  \u27e8fun c x y => edist_vadd_left (AddOpposite.op c.unop.toAdd) x.toAdd y.toAdd\u27e9\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (op : \u03b2 \u2192 \u03b2 \u2192 \u03b2) [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] (b : \u03b2) (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) : \u03b2 :=\n  multiset.fold op b (multiset.map f (val s))\n\n@[simp] theorem fold_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} : fold op b f \u2205 = b :=\n  rfl\n\n@[simp] theorem fold_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} {a : \u03b1} [DecidableEq \u03b1] (h : \u00aca \u2208 s) : fold op b f (insert a s) = op (f a) (fold op b f s) := sorry\n\n@[simp] theorem fold_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {a : \u03b1} : fold op b f (singleton a) = op (f a) b :=\n  rfl\n\n@[simp] theorem fold_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {g : \u03b3 \u21aa \u03b1} {s : finset \u03b3} : fold op b f (map g s) = fold op b (f \u2218 \u21d1g) s := sorry\n\n@[simp] theorem fold_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} [DecidableEq \u03b1] {g : \u03b3 \u2192 \u03b1} {s : finset \u03b3} (H : \u2200 (x : \u03b3), x \u2208 s \u2192 \u2200 (y : \u03b3), y \u2208 s \u2192 g x = g y \u2192 x = y) : fold op b f (image g s) = fold op b (f \u2218 g) s := sorry\n\ntheorem fold_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} {g : \u03b1 \u2192 \u03b2} (H : \u2200 (x : \u03b1), x \u2208 s \u2192 f x = g x) : fold op b f s = fold op b g s := sorry\n\ntheorem fold_op_distrib {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b2} {b\u2081 : \u03b2} {b\u2082 : \u03b2} : fold op (op b\u2081 b\u2082) (fun (x : \u03b1) => op (f x) (g x)) s = op (fold op b\u2081 f s) (fold op b\u2082 g s) := sorry\n\ntheorem fold_hom {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} {op' : \u03b3 \u2192 \u03b3 \u2192 \u03b3} [is_commutative \u03b3 op'] [is_associative \u03b3 op'] {m : \u03b2 \u2192 \u03b3} (hm : \u2200 (x y : \u03b2), m (op x y) = op' (m x) (m y)) : fold op' (m b) (fun (x : \u03b1) => m (f x)) s = m (fold op b f s) := sorry\n\ntheorem fold_union_inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {b\u2081 : \u03b2} {b\u2082 : \u03b2} : op (fold op b\u2081 f (s\u2081 \u222a s\u2082)) (fold op b\u2082 f (s\u2081 \u2229 s\u2082)) = op (fold op b\u2082 f s\u2081) (fold op b\u2081 f s\u2082) := sorry\n\n@[simp] theorem fold_insert_idem {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} {a : \u03b1} [DecidableEq \u03b1] [hi : is_idempotent \u03b2 op] : fold op b f (insert a s) = op (f a) (fold op b f s) := sorry\n\ntheorem fold_op_rel_iff_and {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} {r : \u03b2 \u2192 \u03b2 \u2192 Prop} (hr : \u2200 {x y z : \u03b2}, r x (op y z) \u2194 r x y \u2227 r x z) {c : \u03b2} : r c (fold op b f s) \u2194 r c b \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 r c (f x) := sorry\n\ntheorem fold_op_rel_iff_or {\u03b1 : Type u_1} {\u03b2 : Type u_2} {op : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [hc : is_commutative \u03b2 op] [ha : is_associative \u03b2 op] {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} {r : \u03b2 \u2192 \u03b2 \u2192 Prop} (hr : \u2200 {x y z : \u03b2}, r x (op y z) \u2194 r x y \u2228 r x z) {c : \u03b2} : r c (fold op b f s) \u2194 r c b \u2228 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), r c (f x) := sorry\n\n@[simp] theorem fold_union_empty_singleton {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : fold has_union.union \u2205 singleton s = s := sorry\n\n@[simp] theorem fold_sup_bot_singleton {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : fold has_sup.sup \u22a5 singleton s = s :=\n  fold_union_empty_singleton s\n\ntheorem le_fold_min {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} [linear_order \u03b2] (c : \u03b2) : c \u2264 fold min b f s \u2194 c \u2264 b \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 c \u2264 f x :=\n  fold_op_rel_iff_and fun (x y z : \u03b2) => le_min_iff\n\ntheorem fold_min_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} [linear_order \u03b2] (c : \u03b2) : fold min b f s \u2264 c \u2194 b \u2264 c \u2228 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), f x \u2264 c :=\n  id (fold_op_rel_iff_or fun (x y z : \u03b2) => id min_le_iff)\n\ntheorem lt_fold_min {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} [linear_order \u03b2] (c : \u03b2) : c < fold min b f s \u2194 c < b \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 c < f x :=\n  fold_op_rel_iff_and fun (x y z : \u03b2) => lt_min_iff\n\ntheorem fold_min_lt {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} [linear_order \u03b2] (c : \u03b2) : fold min b f s < c \u2194 b < c \u2228 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), f x < c :=\n  id (fold_op_rel_iff_or fun (x y z : \u03b2) => id min_lt_iff)\n\ntheorem fold_max_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} [linear_order \u03b2] (c : \u03b2) : fold max b f s \u2264 c \u2194 b \u2264 c \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2264 c :=\n  id (fold_op_rel_iff_and fun (x y z : \u03b2) => id max_le_iff)\n\ntheorem le_fold_max {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} [linear_order \u03b2] (c : \u03b2) : c \u2264 fold max b f s \u2194 c \u2264 b \u2228 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), c \u2264 f x :=\n  fold_op_rel_iff_or fun (x y z : \u03b2) => le_max_iff\n\ntheorem fold_max_lt {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} [linear_order \u03b2] (c : \u03b2) : fold max b f s < c \u2194 b < c \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 f x < c :=\n  id (fold_op_rel_iff_and fun (x y z : \u03b2) => id max_lt_iff)\n\ntheorem lt_fold_max {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} {s : finset \u03b1} [linear_order \u03b2] (c : \u03b2) : c < fold max b f s \u2194 c < b \u2228 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), c < f x :=\n  fold_op_rel_iff_or fun (x y z : \u03b2) => 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\u2081 and SemiNormedGroup\n\nWe show that `SemiNormedGroup\u2081` has cokernels\n(for which of course the `cokernel.\u03c0 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.\u03c0 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.\u03c0 f` arbitrarily large in norm), obtaining another categorical cokernel.\n\n-/\n\nopen category_theory category_theory.limits\n\nuniverse u\n\nnamespace SemiNormedGroup\u2081\n\nnoncomputable theory\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup\u2081`. -/\ndef cokernel_cocone {X Y : SemiNormedGroup\u2081.{u}} (f : X \u27f6 Y) : cofork f 0 :=\ncofork.of_\u03c0\n  (@SemiNormedGroup\u2081.mk_hom\n    _ (SemiNormedGroup.of (Y \u29f8 (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\u2081.mk_hom_apply, SemiNormedGroup\u2081.zero_apply, \u2190normed_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\u2081`. -/\ndef cokernel_lift {X Y : SemiNormedGroup\u2081.{u}} (f : X \u27f6 Y) (s : cokernel_cofork f) :\n  (cokernel_cocone f).X \u27f6 s.X :=\nbegin\n  fsplit,\n  -- The lift itself:\n  { apply normed_add_group_hom.lift _ s.\u03c0.1,\n    rintro _ \u27e8b, rfl\u27e9,\n    change (f \u226b s.\u03c0) b = 0,\n    simp, },\n  -- The lift has norm at most one:\n  exact normed_add_group_hom.lift_norm_noninc _ _ _ s.\u03c0.2,\nend\n\ninstance : has_cokernels SemiNormedGroup\u2081.{u} :=\n{ has_colimit := \u03bb X Y f, has_colimit.mk\n  { cocone := cokernel_cocone f,\n    is_colimit := is_colimit_aux _\n      (cokernel_lift f)\n      (\u03bb s, begin\n        ext,\n        apply normed_add_group_hom.lift_mk f.1.range,\n        rintro _ \u27e8b, rfl\u27e9,\n        change (f \u226b s.\u03c0) b = 0,\n        simp,\n      end)\n      (\u03bb 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\u2081 := by apply_instance\n\nend SemiNormedGroup\u2081\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 \u27f6 W) : fork f g :=\n@fork.of_\u03b9 _ _ _ _ _ _ (of (f - g).ker) (normed_add_group_hom.incl (f - g).ker) $\nbegin\n  ext v,\n  have : v.1 \u2208 (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 \u27f6 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      (\u03bb c, normed_add_group_hom.ker.lift (fork.\u03b9 c) _ $\n      show normed_add_group_hom.comp_hom (f - g) c.\u03b9 = 0,\n      by { rw [add_monoid_hom.map_sub, add_monoid_hom.sub_apply, sub_eq_zero], exact c.condition })\n      (\u03bb c, normed_add_group_hom.ker.incl_comp_lift _ _ _)\n      (\u03bb c g h, by { ext x, dsimp, rw \u2190 h, refl }) } }\n\ninstance : limits.has_equalizers.{u (u+1)} SemiNormedGroup :=\n@has_equalizers_of_has_limit_parallel_pair SemiNormedGroup _ $ \u03bb 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\u2081` 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 \u27f6 Y) : cofork f 0 :=\n@cofork.of_\u03c0 _ _ _ _ _ _\n  (SemiNormedGroup.of (Y \u29f8 (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      \u2190normed_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 \u27f6 Y) (s : cokernel_cofork f) :\n  (cokernel_cocone f).X \u27f6 s.X := normed_add_group_hom.lift _ s.\u03c0\nbegin\n  rintro _ \u27e8b, rfl\u27e9,\n  change (f \u226b s.\u03c0) b = 0,\n  simp,\nend\n\n/-- Auxiliary definition for `has_cokernels SemiNormedGroup`. -/\ndef is_colimit_cokernel_cocone {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  is_colimit (cokernel_cocone f) :=\nis_colimit_aux _ (cokernel_lift f)\n(\u03bb s, begin\n  ext,\n  apply normed_add_group_hom.lift_mk f.range,\n  rintro _ \u27e8b, rfl\u27e9,\n  change (f \u226b s.\u03c0) b = 0,\n  simp,\nend)\n(\u03bb s m w, normed_add_group_hom.lift_unique f.range _ _ _ w)\n\ninstance : has_cokernels SemiNormedGroup.{u} :=\n{ has_colimit := \u03bb 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 \u27f6 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 \u27f6 Y} {g : Y \u27f6 Z}\n  (w : f \u226b g = 0) : explicit_cokernel f \u27f6 Z :=\n(is_colimit_cokernel_cocone f).desc (cofork.of_\u03c0 g (by simp [w]))\n\n/-- The projection from `Y` to the explicit cokernel of `X \u27f6 Y`. -/\ndef explicit_cokernel_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) : Y \u27f6 explicit_cokernel f :=\n(cokernel_cocone f).\u03b9.app walking_parallel_pair.one\n\nlemma explicit_cokernel_\u03c0_surjective {X Y : SemiNormedGroup.{u}} {f : X \u27f6 Y} :\n  function.surjective (explicit_cokernel_\u03c0 f) :=\nsurjective_quot_mk _\n\n@[simp, reassoc]\nlemma comp_explicit_cokernel_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  f \u226b explicit_cokernel_\u03c0 f = 0 :=\nbegin\n  convert (cokernel_cocone f).w walking_parallel_pair_hom.left,\n  simp,\nend\n\n@[simp]\nlemma explicit_cokernel_\u03c0_apply_dom_eq_zero {X Y : SemiNormedGroup.{u}} {f : X \u27f6 Y} (x : X) :\n  (explicit_cokernel_\u03c0 f) (f x) = 0 :=\nshow (f \u226b (explicit_cokernel_\u03c0 f)) x = 0, by { rw [comp_explicit_cokernel_\u03c0], refl }\n\n@[simp, reassoc]\nlemma explicit_cokernel_\u03c0_desc {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (w : f \u226b g = 0) : explicit_cokernel_\u03c0 f \u226b explicit_cokernel_desc w = g :=\n(is_colimit_cokernel_cocone f).fac _ _\n\n@[simp]\nlemma explicit_cokernel_\u03c0_desc_apply {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  {cond : f \u226b g = 0} (x : Y) : explicit_cokernel_desc cond (explicit_cokernel_\u03c0 f x) = g x :=\nshow (explicit_cokernel_\u03c0 f \u226b explicit_cokernel_desc cond) x = g x, by rw explicit_cokernel_\u03c0_desc\n\nlemma explicit_cokernel_desc_unique {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (w : f \u226b g = 0) (e : explicit_cokernel f \u27f6 Z) (he : explicit_cokernel_\u03c0 f \u226b e = g) :\n  e = explicit_cokernel_desc w :=\nbegin\n  apply (is_colimit_cokernel_cocone f).uniq (cofork.of_\u03c0 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 \u27f6 Y} {g : Y \u27f6 Z}\n  {h : Z \u27f6 W} {cond : f \u226b g = 0} :\n  explicit_cokernel_desc cond \u226b h = explicit_cokernel_desc (show f \u226b (g \u226b h) = 0,\n  by rw [\u2190 category_theory.category.assoc, cond, limits.zero_comp]) :=\nbegin\n  refine explicit_cokernel_desc_unique _ _ _,\n  rw [\u2190 category_theory.category.assoc, explicit_cokernel_\u03c0_desc]\nend\n\n@[simp]\nlemma explicit_cokernel_desc_zero {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} :\n  explicit_cokernel_desc (show f \u226b (0 : Y \u27f6 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 \u27f6 Y}\n  (e\u2081 e\u2082 : explicit_cokernel f \u27f6 Z)\n  (h : explicit_cokernel_\u03c0 f \u226b e\u2081 = explicit_cokernel_\u03c0 f \u226b e\u2082) : e\u2081 = e\u2082 :=\nbegin\n  let g : Y \u27f6 Z := explicit_cokernel_\u03c0 f \u226b e\u2082,\n  have w : f \u226b g = 0, by simp,\n  have : e\u2082 = 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_\u03c0.epi {X Y : SemiNormedGroup.{u}} {f : X \u27f6 Y} :\n  epi (explicit_cokernel_\u03c0 f) :=\nbegin\n  constructor,\n  intros Z g h H,\n  ext x,\n  obtain \u27e8x, hx\u27e9 := explicit_cokernel_\u03c0_surjective (explicit_cokernel_\u03c0 f x),\n  change (explicit_cokernel_\u03c0 f \u226b g) _ = _,\n  rw [H]\nend\n\nlemma is_quotient_explicit_cokernel_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\nnormed_add_group_hom.is_quotient (explicit_cokernel_\u03c0 f) :=\nnormed_add_group_hom.is_quotient_quotient _\n\nlemma norm_noninc_explicit_cokernel_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  (explicit_cokernel_\u03c0 f).norm_noninc :=\n(is_quotient_explicit_cokernel_\u03c0 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 \u27f6 Y} {g : Y \u27f6 Z} (w : f \u226b g = 0) (c : \u211d\u22650) (h : \u2016 g \u2016 \u2264 c) :\n  \u2016 explicit_cokernel_desc w \u2016 \u2264 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 \u27f6 Y} {g : Y \u27f6 Z}\n  {h : Z \u27f6 W} (cond : f \u226b g = 0) (cond2 : g \u226b h = 0) :\n  explicit_cokernel_desc cond \u226b h = 0 :=\nbegin\n  rw [\u2190 cancel_epi (explicit_cokernel_\u03c0 f), \u2190 category.assoc, explicit_cokernel_\u03c0_desc],\n  simp [cond2]\nend\n\nlemma explicit_cokernel_desc_norm_le {X Y Z : SemiNormedGroup.{u}}\n  {f : X \u27f6 Y} {g : Y \u27f6 Z} (w : f \u226b g = 0) : \u2016 explicit_cokernel_desc w \u2016 \u2264 \u2016 g \u2016 :=\nexplicit_cokernel_desc_norm_le_of_norm_le w \u2016 g \u2016\u208a le_rfl\n\n/-- The explicit cokernel is isomorphic to the usual cokernel. -/\ndef explicit_cokernel_iso {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  explicit_cokernel f \u2245 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_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  explicit_cokernel_\u03c0 f \u226b (explicit_cokernel_iso f).hom = cokernel.\u03c0 _ :=\nby simp [explicit_cokernel_\u03c0, explicit_cokernel_iso, is_colimit.cocone_point_unique_up_to_iso]\n\n@[simp]\nlemma explicit_cokernel_iso_inv_\u03c0 {X Y : SemiNormedGroup.{u}} (f : X \u27f6 Y) :\n  cokernel.\u03c0 f \u226b (explicit_cokernel_iso f).inv = explicit_cokernel_\u03c0 f :=\nby simp [explicit_cokernel_\u03c0, explicit_cokernel_iso]\n\n@[simp]\nlemma explicit_cokernel_iso_hom_desc {X Y Z : SemiNormedGroup.{u}} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (w : f \u226b g = 0) :\n  (explicit_cokernel_iso f).hom \u226b cokernel.desc f g w = explicit_cokernel_desc w :=\nbegin\n  ext1,\n  simp [explicit_cokernel_desc, explicit_cokernel_\u03c0, 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 \u27f6 B}\n  {fbd : B \u27f6 D} {fac : A \u27f6 C} {fcd : C \u27f6 D} (h : fab \u226b fbd = fac \u226b fcd) :\n  explicit_cokernel fab \u27f6 explicit_cokernel fcd :=\n@explicit_cokernel_desc _ _ _ fab (fbd \u226b explicit_cokernel_\u03c0 _) $ 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 \u27f6 B} {fbd : B \u27f6 D} {fac : A \u27f6 C} {fcd : C \u27f6 D}\n  {h : fab \u226b fbd = fac \u226b fcd} {fbb' : B \u27f6 B'} {fdd' : D \u27f6 D'}\n  {condb : fab \u226b fbb' = 0} {condd : fcd \u226b fdd' = 0} {g : B' \u27f6 D'}\n  (h' : fbb' \u226b g = fbd \u226b fdd'):\n  explicit_cokernel_desc condb \u226b g = explicit_cokernel.map h \u226b explicit_cokernel_desc condd :=\nbegin\n  delta explicit_cokernel.map,\n  simp [\u2190 cancel_epi (explicit_cokernel_\u03c0 fab), category.assoc, explicit_cokernel_\u03c0_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\u02e3` to act on `M`, when `M` is a `monoid`\n* `conj_act G\u2080` to act on `G\u2080`, when `G\u2080` 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 \u2022 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 \u2022 h` describes an action of `mul_aut G` on `G`, and not an action of `G`.\n\n-/\n\nvariables (\u03b1 M G G\u2080 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\u2080 R K}\n\ninstance : \u03a0 [group G], group (conj_act G) := id\ninstance : \u03a0 [div_inv_monoid G], div_inv_monoid (conj_act G) := id\ninstance : \u03a0 [group_with_zero G], group_with_zero (conj_act G) := id\ninstance : \u03a0 [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) := \u27e81\u27e9\n\n/-- Reinterpret `g : conj_act G` as an element of `G`. -/\ndef of_conj_act : conj_act G \u2243* G := \u27e8id, id, \u03bb _, rfl, \u03bb _, rfl, \u03bb _ _, rfl\u27e9\n\n/-- Reinterpret `g : G` as an element of `conj_act G`. -/\ndef to_conj_act : G \u2243* 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 \u2192 Sort*} (h : \u03a0 g, C (to_conj_act g)) : \u03a0 g, C g := h\n\n@[simp] lemma \u00abforall\u00bb (p : conj_act G \u2192 Prop) :\n  (\u2200 (x : conj_act G), p x) \u2194 \u2200 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\u207b\u00b9) = (of_conj_act x)\u207b\u00b9 := rfl\n@[simp] lemma to_conj_act_inv (x : G) : to_conj_act (x\u207b\u00b9) = (to_conj_act x)\u207b\u00b9 := 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 := \u03bb g h, of_conj_act g * h * (of_conj_act g)\u207b\u00b9 }\n\nlemma smul_def (g : conj_act G) (h : G) : g \u2022 h = of_conj_act g * h * (of_conj_act g)\u207b\u00b9 := 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\u02e3) M :=\n{ smul := \u03bb g h, of_conj_act g * h * \u2191(of_conj_act g)\u207b\u00b9 }\n\nlemma units_smul_def (g : conj_act M\u02e3) (h : M) : g \u2022 h = of_conj_act g * h * \u2191(of_conj_act g)\u207b\u00b9 :=\nrfl\n\ninstance units_mul_distrib_mul_action : mul_distrib_mul_action (conj_act M\u02e3) M :=\n{ smul := (\u2022),\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 \u03b1 M] [smul_comm_class \u03b1 M M] [is_scalar_tower \u03b1 M M] :\n  smul_comm_class \u03b1 (conj_act M\u02e3) M :=\n{ smul_comm := \u03bb 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 \u03b1 M] [smul_comm_class M \u03b1 M] [is_scalar_tower \u03b1 M M] :\n  smul_comm_class (conj_act M\u02e3) \u03b1 M :=\nby { haveI : smul_comm_class \u03b1 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\u02e3) R :=\n{ smul := (\u2022),\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\u2080]\n\n@[simp] lemma of_conj_act_zero : of_conj_act (0 : conj_act G\u2080) = 0 := rfl\n@[simp] \n\ninstance mul_action\u2080 : mul_action (conj_act G\u2080) G\u2080 :=\n{ smul := (\u2022),\n  one_smul := by simp [smul_def],\n  mul_smul := by simp [smul_def, mul_assoc, mul_inv_rev] }\n\ninstance smul_comm_class\u2080 [has_smul \u03b1 G\u2080] [smul_comm_class \u03b1 G\u2080 G\u2080] [is_scalar_tower \u03b1 G\u2080 G\u2080] :\n  smul_comm_class \u03b1 (conj_act G\u2080) G\u2080 :=\n{ smul_comm := \u03bb a ug g, by rw [smul_def, smul_def, mul_smul_comm, smul_mul_assoc] }\n\ninstance smul_comm_class\u2080' [has_smul \u03b1 G\u2080] [smul_comm_class G\u2080 \u03b1 G\u2080] [is_scalar_tower \u03b1 G\u2080 G\u2080] :\n  smul_comm_class (conj_act G\u2080) \u03b1 G\u2080 :=\nby { haveI := smul_comm_class.symm G\u2080 \u03b1 G\u2080, exact smul_comm_class.symm _ _ _ }\n\nend group_with_zero\n\nsection division_ring\nvariables [division_ring K]\n\ninstance distrib_mul_action\u2080 : distrib_mul_action (conj_act K) K :=\n{ smul := (\u2022),\n  smul_zero := by simp [smul_def],\n  smul_add := by simp [smul_def, mul_add, add_mul],\n  ..conj_act.mul_action\u2080 }\n\nend division_ring\n\nvariables [group G]\n\ninstance : mul_distrib_mul_action (conj_act G) G :=\n{ smul := (\u2022),\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 \u03b1 G] [smul_comm_class \u03b1 G G] [is_scalar_tower \u03b1 G G] :\n  smul_comm_class \u03b1 (conj_act G) G :=\n{ smul_comm := \u03bb a ug g, by rw [smul_def, smul_def, mul_smul_comm, smul_mul_assoc] }\n\ninstance smul_comm_class' [has_smul \u03b1 G] [smul_comm_class G \u03b1 G] [is_scalar_tower \u03b1 G G] :\n  smul_comm_class (conj_act G) \u03b1 G :=\nby { haveI := smul_comm_class.symm G \u03b1 G, exact smul_comm_class.symm _ _ _ }\n\nlemma smul_eq_mul_aut_conj (g : conj_act G) (h : G) : g \u2022 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 (\u03bb x, mul_inv_eq_iff_eq_mul.mp)))\n  (\u03bb 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\u27e8\u03bb g h, \u27e8g \u2022 h, hH.conj_mem h.1 h.2 (of_conj_act g)\u27e9\u27e9\n\nlemma subgroup.coe_conj_smul {H : subgroup G} [hH : H.normal] (g : conj_act G) (h : H) :\n  \u2191(g \u2022 h) = g \u2022 (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 \u2192* 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  \u2191(mul_aut.conj_normal g h) = g * h * g\u207b\u00b9 := rfl\n\n@[simp] lemma _root_.mul_aut.conj_normal_symm_apply {H : subgroup G} [H.normal] (g : G) (h : H) :\n  \u2191((mul_aut.conj_normal g).symm h) = g\u207b\u00b9 * h * g :=\nby { change _ * (_)\u207b\u00b9\u207b\u00b9 = _, 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  \u2191((mul_aut.conj_normal g)\u207b\u00b9 h) = g\u207b\u00b9 * 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 \u2191h = mul_aut.conj h :=\nmul_equiv.ext (\u03bb 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\u27e8\u03bb a ha b, by\n{ obtain \u27e8a, ha, rfl\u27e9 := ha,\n  exact K.apply_coe_mem_map H.subtype\n    \u27e8_, ((set_like.ext_iff.mp (h.fixed (mul_aut.conj_normal b)) a).mpr ha)\u27e9 }\u27e9\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 \u00a9 2019 Fran\u00e7ois 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 {\u03c4 : Type} {\u03c3 : Type*} (sig : signature \u03c4 \u03c3)\n\nabbreviation substitution (dom\u2081 dom\u2082 : list \u03c4) := \u03a0 (i : index dom\u2081), term sig dom\u2082 i.val\n\nnamespace substitution\nvariables {sig} {dom\u2081 dom\u2082 dom\u2083 : list \u03c4} (sub : substitution sig dom\u2081 dom\u2082)\n\nabbreviation to_valuation : algebra.valuation (term_algebra sig dom\u2082) dom\u2081 := sub\n\nabbreviation apply {cod} (t : term sig dom\u2081 cod) : term sig dom\u2082 cod :=\nalgebra.eval (term_algebra sig dom\u2082) t sub\n\ntheorem apply_def {cod} (t : term sig dom\u2081 cod) : sub.apply t = (term_algebra sig dom\u2082).eval t sub := rfl\n\ntheorem apply_proj {i : index dom\u2081} : sub.apply (term.proj i) = sub i := rfl\n\ntheorem apply_func {f} (ts : \u03a0 (i : sig.index f), term sig dom\u2081 i.val) :\nsub.apply (term.func f ts) = term.func f (\u03bb i, sub.apply (ts i)) := rfl\n\ntheorem eval (alg : algebra sig) : \u2200 {cod} (t : term sig dom\u2081 cod) (val : \u03a0 (i : index dom\u2082), alg.sort i.val),\nalg.eval (sub.apply t) val = alg.eval t (\u03bb i, alg.eval (sub i) val)\n| _ (term.proj i) val := rfl\n| _ (term.func f ts) val :=\n  have IH : (\u03bb i, alg.eval (sub.apply (ts i)) val) = (\u03bb i, alg.eval (ts i) (\u03bb i, alg.eval (sub i) val)),\n  from funext $ \u03bb i, eval (ts i) val,\n  calc alg.eval (sub.apply (term.func f ts)) val\n  = alg.func f (\u03bb i, alg.eval (sub.apply (ts i)) val) : rfl ...\n  = alg.func f (\u03bb i, alg.eval (ts i) (\u03bb i, alg.eval (sub i) val)) : by rw IH ...\n  = alg.eval (term.func f ts) (\u03bb (i : index dom\u2081), alg.eval (sub i) val) : by reflexivity\n\nabbreviation id {dom : list \u03c4} : substitution sig dom dom := term.proj\n\n@[simp] theorem id_apply {dom : list \u03c4} : \u2200 {cod} (t : term sig dom cod), substitution.id.apply t = t\n| _ (term.proj _) := rfl\n| _ (term.func f ts) := \n  have (\u03bb i, apply id (ts i)) = ts,\n  from funext $ \u03bb i, id_apply (ts i),\n  calc apply id (term.func f ts)\n  = term.func f (\u03bb i, apply id (ts i)) : rfl ...\n  = term.func f ts : by rw this\n\nabbreviation comp : substitution sig dom\u2082 dom\u2083 \u2192 substitution sig dom\u2081 dom\u2082 \u2192 substitution sig dom\u2081 dom\u2083 :=\n\u03bb sub\u2082\u2083 sub\u2081\u2082 i, sub\u2082\u2083.apply (sub\u2081\u2082 i)\n\n@[simp] theorem comp_apply (sub\u2082\u2083 : substitution sig dom\u2082 dom\u2083) (sub\u2081\u2082 : substitution sig dom\u2081 dom\u2082) :\n\u2200 {cod} (t : term sig dom\u2081 cod), (comp sub\u2082\u2083 sub\u2081\u2082).apply t = sub\u2082\u2083.apply (sub\u2081\u2082.apply t)\n| _ (term.proj _) := rfl\n| _ (term.func f ts) :=\n  have (\u03bb i, (comp sub\u2082\u2083 sub\u2081\u2082).apply (ts i)) = (\u03bb i, sub\u2082\u2083.apply (sub\u2081\u2082.apply (ts i))),\n  from funext $ \u03bb i, comp_apply (ts i),\n  calc (comp sub\u2082\u2083 sub\u2081\u2082).apply (term.func f ts)\n  = term.func f (\u03bb i, (comp sub\u2082\u2083 sub\u2081\u2082).apply (ts i)) : rfl ...\n  = term.func f (\u03bb i, sub\u2082\u2083.apply (sub\u2081\u2082.apply (ts i))) : by rw this ...\n  = sub\u2082\u2083.apply (term.func f (\u03bb i, sub\u2081\u2082.apply (ts i))) : by rw apply_func sub\u2082\u2083 ...\n  = sub\u2082\u2083.apply (apply sub\u2081\u2082 (term.func f ts)) : by rw apply_func sub\u2081\u2082\n\nend substitution\n\nsection subst \nvariables {sig} {dom\u2081 dom\u2082 : list \u03c4} (sub : substitution sig dom\u2081 dom\u2082)\n\nabbreviation term.subst {{cod}} : term sig dom\u2081 cod \u2192 term sig dom\u2082 cod := sub.apply\n\nabbreviation equation.subst {{cod}} : equation sig dom\u2081 cod \u2192 equation sig dom\u2082 cod :=\n\u03bb e, \u27e8sub.apply e.lhs, sub.apply e.rhs\u27e9\n\ntheorem equation.subst_lhs {cod} (e : equation sig dom\u2081 cod) : (e.subst sub).lhs = e.lhs.subst sub := rfl\n\ntheorem equation.subst_rhs {cod} (e : equation sig dom\u2081 cod) : (e.subst sub).rhs = e.rhs.subst sub := rfl\n\ntheorem subst_subst {dom\u2081 dom\u2082 dom\u2083 : list \u03c4} (sub\u2082\u2083 : substitution sig dom\u2082 dom\u2083) (sub\u2081\u2082 : substitution sig dom\u2081 dom\u2082) {cod} (t : term sig dom\u2081 cod) :\nt.subst (\u03bb i, (sub\u2081\u2082 i).subst sub\u2082\u2083) = (t.subst sub\u2081\u2082).subst sub\u2082\u2083 := substitution.comp_apply sub\u2082\u2083 sub\u2081\u2082 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 *, +, -, ^, \u2264\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 \u2192 option \u211a\n| `(%%e\u2081 / %%e\u2082) := do m \u2190 e\u2081.to_nat, n \u2190 e\u2082.to_nat, some (rat.mk m n)\n| e              := do n \u2190 e.to_nat, return (rat.of_int n)\n\nprotected meta def to_rat : expr \u2192 option \u211a\n| `(has_neg.neg %%e) := do q \u2190 e.to_pos_rat, some (-q)\n| e                  := e.to_pos_rat\n\nprotected meta def of_rat (\u03b1 : expr) : \u211a \u2192 tactic expr\n| \u27e8(n:\u2115), d, h, c\u27e9   := do\n  e\u2081 \u2190 expr.of_nat \u03b1 n,\n  if d = 1 then return e\u2081 else\n  do e\u2082 \u2190 expr.of_nat \u03b1 d,\n  tactic.mk_app ``has_div.div [e\u2081, e\u2082]\n| \u27e8-[1+n], d, h, c\u27e9 := do\n  e\u2081 \u2190 expr.of_nat \u03b1 (n+1),\n  e \u2190 (if d = 1 then return e\u2081 else do\n    e\u2082 \u2190 expr.of_nat \u03b1 d,\n    tactic.mk_app ``has_div.div [e\u2081, e\u2082]),\n  tactic.mk_app ``has_neg.neg [e]\n\nend expr\n\nnamespace tactic\n\nmeta def refl_conv (e : expr) : tactic (expr \u00d7 expr) :=\ndo p \u2190 mk_eq_refl e, return (e, p)\n\nmeta def trans_conv (t\u2081 t\u2082 : expr \u2192 tactic (expr \u00d7 expr)) (e : expr) :\n  tactic (expr \u00d7 expr) :=\n(do (e\u2081, p\u2081) \u2190 t\u2081 e,\n  (do (e\u2082, p\u2082) \u2190 t\u2082 e\u2081,\n    p \u2190 mk_eq_trans p\u2081 p\u2082, return (e\u2082, p)) <|>\n  return (e\u2081, p\u2081)) <|> t\u2082 e\n\nend tactic\n\nopen tactic\n\nnamespace norm_num\nvariable {\u03b1 : Type u}\n\nlemma subst_into_neg {\u03b1} [has_neg \u03b1] (a ta t : \u03b1) (pra : a = ta) (prt : -ta = t) : -a = t :=\nby simp [pra, prt]\n\ntheorem bit0_zero [add_group \u03b1] : bit0 (0 : \u03b1) = 0 := add_zero _\n\ntheorem bit1_zero [add_group \u03b1] [has_one \u03b1] : bit1 (0 : \u03b1) = 1 :=\nby rw [bit1, bit0_zero, zero_add]\n\nlemma pow_bit0_helper [monoid \u03b1] (a t : \u03b1) (b : \u2115) (h : a ^ b = t) :\n  a ^ bit0 b = t * t :=\nby simp [pow_bit0, h]\n\nlemma pow_bit1_helper [monoid \u03b1] (a t : \u03b1) (b : \u2115) (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 \u03b1]\n  (a b c : \u03b1) (h : a + b = c) (h\u2082 : 0 < b) : a < c :=\nh \u25b8 (lt_add_iff_pos_right _).2 h\u2082\n\nlemma nat_div_helper (a b q r : \u2115) (h : r + q * b = a) (h\u2082 : r < b) : a / b = q :=\nby rw [\u2190 h, nat.add_mul_div_right _ _ (lt_of_le_of_lt (nat.zero_le _) h\u2082),\n       nat.div_eq_of_lt h\u2082, zero_add]\n\nlemma int_div_helper (a b q r : \u2124) (h : r + q * b = a) (h\u2081 : 0 \u2264 r) (h\u2082 : r < b) : a / b = q :=\nby rw [\u2190 h, int.add_mul_div_right _ _ (ne_of_gt (lt_of_le_of_lt h\u2081 h\u2082)),\n       int.div_eq_zero_of_lt h\u2081 h\u2082, zero_add]\n\nlemma nat_mod_helper (a b q r : \u2115) (h : r + q * b = a) (h\u2082 : r < b) : a % b = r :=\nby rw [\u2190 h, nat.add_mul_mod_self_right, nat.mod_eq_of_lt h\u2082]\n\nlemma int_mod_helper (a b q r : \u2124) (h : r + q * b = a) (h\u2081 : 0 \u2264 r) (h\u2082 : r < b) : a % b = r :=\nby rw [\u2190 h, int.add_mul_mod_self, int.mod_eq_of_lt h\u2081 h\u2082]\n\nmeta def eval_pow (simp : expr \u2192 tactic (expr \u00d7 expr)) : expr \u2192 tactic (expr \u00d7 expr)\n| `(@has_pow.pow %%\u03b1 _ %%m %%e\u2081 %%e\u2082) :=\n  match m with\n  | `(nat.has_pow) :=\n    mk_app ``nat.pow [e\u2081, e\u2082] >>= eval_pow\n  | `(@monoid.has_pow %%\u03b1 %%m) :=\n    mk_app ``monoid.pow [e\u2081, e\u2082] >>= eval_pow\n  | _ := failed\n  end\n| `(monoid.pow %%e\u2081 0) := do\n  p \u2190 mk_app ``pow_zero [e\u2081],\n  a \u2190 infer_type e\u2081,\n  o \u2190 mk_app ``has_one.one [a],\n  return (o, p)\n| `(monoid.pow %%e\u2081 1) := do\n  p \u2190 mk_app ``pow_one [e\u2081],\n  return (e\u2081, p)\n| `(monoid.pow %%e\u2081 (bit0 %%e\u2082)) := do\n  e \u2190 mk_app ``monoid.pow [e\u2081, e\u2082],\n  (e', p) \u2190 simp e,\n  p' \u2190 mk_app ``norm_num.pow_bit0_helper [e\u2081, e', e\u2082, p],\n  e'' \u2190 to_expr ``(%%e' * %%e'),\n  return (e'', p')\n| `(monoid.pow %%e\u2081 (bit1 %%e\u2082)) := do\n  e \u2190 mk_app ``monoid.pow [e\u2081, e\u2082],\n  (e', p) \u2190 simp e,\n  p' \u2190 mk_app ``norm_num.pow_bit1_helper [e\u2081, e', e\u2082, p],\n  e'' \u2190 to_expr ``(%%e' * %%e' * %%e\u2081),\n  return (e'', p')\n| `(nat.pow %%e\u2081 %%e\u2082) := do\n  p\u2081 \u2190 mk_app ``nat.pow_eq_pow [e\u2081, e\u2082],\n  e \u2190 mk_app ``monoid.pow [e\u2081, e\u2082],\n  (e', p\u2082) \u2190 simp e,\n  p \u2190 mk_eq_trans p\u2081 p\u2082,\n  return (e', p)\n| _ := failed\n\nmeta def prove_pos : instance_cache \u2192 expr \u2192 tactic (instance_cache \u00d7 expr)\n| c `(has_one.one _) := do (c, p) \u2190 c.mk_app ``zero_lt_one [], return (c, p)\n| c `(bit0 %%e)      := do (c, p) \u2190 prove_pos c e, (c, p) \u2190 c.mk_app ``bit0_pos [e, p], return (c, p)\n| c `(bit1 %%e)      := do (c, p) \u2190 prove_pos c e, (c, p) \u2190 c.mk_app ``bit1_pos' [e, p], return (c, p)\n| c `(%%e\u2081 / %%e\u2082)   := do\n  (c, p\u2081) \u2190 prove_pos c e\u2081, (c, p\u2082) \u2190 prove_pos c e\u2082,\n  (c, p) \u2190 c.mk_app ``div_pos_of_pos_of_pos [e\u2081, e\u2082, p\u2081, p\u2082],\n  return (c, p)\n| c e                       := failed\n\nmeta def prove_lt (simp : expr \u2192 tactic (expr \u00d7 expr)) : instance_cache \u2192 expr \u2192 expr \u2192 tactic (instance_cache \u00d7 expr)\n| c `(- %%e\u2081) `(- %%e\u2082) := do\n  (c, p) \u2190 prove_lt c e\u2081 e\u2082,\n  (c, p) \u2190 c.mk_app ``neg_lt_neg [e\u2081, e\u2082, p],\n  return (c, p)\n| c `(- %%e\u2081) `(has_zero.zero _) := do\n  (c, p) \u2190 prove_pos c e\u2081,\n  (c, p) \u2190 c.mk_app ``neg_neg_of_pos [e\u2081, p],\n  return (c, p)\n| c `(- %%e\u2081) e\u2082 := do\n  (c, p\u2081) \u2190 prove_pos c e\u2081,\n  (c, me\u2081) \u2190 c.mk_app ``has_neg.neg [e\u2081],\n  (c, p\u2081) \u2190 c.mk_app ``neg_neg_of_pos [e\u2081, p\u2081],\n  (c, p\u2082) \u2190 prove_pos c e\u2082,\n  (c, z) \u2190 c.mk_app ``has_zero.zero [],\n  (c, p) \u2190 c.mk_app ``lt_trans [me\u2081, z, e\u2082, p\u2081, p\u2082],\n  return (c, p)\n| c `(has_zero.zero _) e\u2082 := prove_pos c e\u2082\n| c e\u2081 e\u2082 := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  d \u2190 expr.of_rat c.\u03b1 (n\u2082 - n\u2081),\n  (c, e\u2083) \u2190 c.mk_app ``has_add.add [e\u2081, d],\n  (e\u2082', p) \u2190 norm_num e\u2083,\n  guard (e\u2082' =\u2090 e\u2082),\n  (c, p') \u2190 prove_pos c d,\n  (c, p) \u2190 c.mk_app ``norm_num.lt_add_of_pos_helper [e\u2081, d, e\u2082, p, p'],\n  return (c, p)\n\nprivate meta def true_intro (p : expr) : tactic (expr \u00d7 expr) :=\nprod.mk <$> mk_const `true <*> mk_app ``eq_true_intro [p]\n\nprivate meta def false_intro (p : expr) : tactic (expr \u00d7 expr) :=\nprod.mk <$> mk_const `false <*> mk_app ``eq_false_intro [p]\n\nmeta def eval_ineq (simp : expr \u2192 tactic (expr \u00d7 expr)) : expr \u2192 tactic (expr \u00d7 expr)\n| `(%%e\u2081 < %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 < n\u2082 then\n    do (_, p) \u2190 prove_lt simp c e\u2081 e\u2082, true_intro p\n  else do\n    (c, p) \u2190 if n\u2081 = n\u2082 then c.mk_app ``lt_irrefl [e\u2081] else\n      (do (c, p') \u2190 prove_lt simp c e\u2082 e\u2081,\n          c.mk_app ``not_lt_of_gt [e\u2081, e\u2082, p']),\n    false_intro p\n| `(%%e\u2081 \u2264 %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 \u2264 n\u2082 then do\n    (c, p) \u2190 if n\u2081 = n\u2082 then c.mk_app ``le_refl [e\u2081] else\n      (do (c, p') \u2190 prove_lt simp c e\u2081 e\u2082,\n          c.mk_app ``le_of_lt [e\u2081, e\u2082, p']),\n    true_intro p\n  else do\n    (c, p) \u2190 prove_lt simp c e\u2082 e\u2081,\n    (c, p) \u2190 c.mk_app ``not_le_of_gt [e\u2081, e\u2082, p],\n    false_intro p\n| `(%%e\u2081 = %%e\u2082) := do\n  n\u2081 \u2190 e\u2081.to_rat, n\u2082 \u2190 e\u2082.to_rat,\n  c \u2190 infer_type e\u2081 >>= mk_instance_cache,\n  if n\u2081 < n\u2082 then do\n    (c, p) \u2190 prove_lt simp c e\u2081 e\u2082,\n    (c, p) \u2190 c.mk_app ``ne_of_lt [e\u2081, e\u2082, p],\n    false_intro p\n  else if n\u2082 < n\u2081 then do\n    (c, p) \u2190 prove_lt simp c e\u2082 e\u2081,\n    (c, p) \u2190 c.mk_app ``ne_of_gt [e\u2081, e\u2082, p],\n    false_intro p\n  else mk_eq_refl e\u2081 >>= true_intro\n| `(%%e\u2081 > %%e\u2082) := mk_app ``has_lt.lt [e\u2082, e\u2081] >>= simp\n| `(%%e\u2081 \u2265 %%e\u2082) := mk_app ``has_le.le [e\u2082, e\u2081] >>= simp\n| `(%%e\u2081 \u2260 %%e\u2082) := do e \u2190 mk_app ``eq [e\u2081, e\u2082], mk_app ``not [e] >>= simp\n| _ := failed\n\nmeta def eval_div_ext (simp : expr \u2192 tactic (expr \u00d7 expr)) : expr \u2192 tactic (expr \u00d7 expr)\n| `(has_inv.inv %%e) := do\n  c \u2190 infer_type e >>= mk_instance_cache,\n  (c, p\u2081) \u2190 c.mk_app ``inv_eq_one_div [e],\n  (c, o) \u2190 c.mk_app ``has_one.one [],\n  (c, e') \u2190 c.mk_app ``has_div.div [o, e],\n  (do (e'', p\u2082) \u2190 simp e',\n    p \u2190 mk_eq_trans p\u2081 p\u2082,\n    return (e'', p)) <|> return (e', p\u2081)\n| `(%%e\u2081 / %%e\u2082) := do\n  \u03b1 \u2190 infer_type e\u2081,\n  c \u2190 mk_instance_cache \u03b1,\n  match \u03b1 with\n  | `(nat) := do\n    n\u2081 \u2190 e\u2081.to_nat, n\u2082 \u2190 e\u2082.to_nat,\n    q \u2190 expr.of_nat \u03b1 (n\u2081 / n\u2082),\n    r \u2190 expr.of_nat \u03b1 (n\u2081 % n\u2082),\n    (c, e\u2083) \u2190 c.mk_app ``has_mul.mul [q, e\u2082],\n    (c, e\u2083) \u2190 c.mk_app ``has_add.add [r, e\u2083],\n    (e\u2081', p) \u2190 norm_num e\u2083,\n    guard (e\u2081' =\u2090 e\u2081),\n    (c, p') \u2190 prove_lt simp c r e\u2082,\n    p \u2190 mk_app ``norm_num.nat_div_helper [e\u2081, e\u2082, q, r, p, p'],\n    return (q, p)\n  | `(int) := match e\u2082 with\n    | `(- %%e\u2082') := do\n      (c, p\u2081) \u2190 c.mk_app ``int.div_neg [e\u2081, e\u2082'],\n      (c, e) \u2190 c.mk_app ``has_div.div [e\u2081, e\u2082'],\n      (c, e) \u2190 c.mk_app ``has_neg.neg [e],\n      (e', p\u2082) \u2190 simp e,\n      p \u2190 mk_eq_trans p\u2081 p\u2082,\n      return (e', p)\n    | _ := do\n      n\u2081 \u2190 e\u2081.to_int,\n      n\u2082 \u2190 e\u2082.to_int,\n      q \u2190 expr.of_rat \u03b1 $ rat.of_int (n\u2081 / n\u2082),\n      r \u2190 expr.of_rat \u03b1 $ rat.of_int (n\u2081 % n\u2082),\n      (c, e\u2083) \u2190 c.mk_app ``has_mul.mul [q, e\u2082],\n      (c, e\u2083) \u2190 c.mk_app ``has_add.add [r, e\u2083],\n      (e\u2081', p) \u2190 norm_num e\u2083,\n      guard (e\u2081' =\u2090 e\u2081),\n      (c, r0) \u2190 c.mk_app ``has_zero.zero [],\n      (c, r0) \u2190 c.mk_app ``has_le.le [r0, r],\n      (_, p\u2081) \u2190 simp r0,\n      p\u2081 \u2190 mk_app ``of_eq_true [p\u2081],\n      (c, p\u2082) \u2190 prove_lt simp c r e\u2082,\n      p \u2190 mk_app ``norm_num.int_div_helper [e\u2081, e\u2082, q, r, p, p\u2081, p\u2082],\n      return (q, p)\n    end\n  | _ := failed\n  end\n| `(%%e\u2081 % %%e\u2082) := do\n  \u03b1 \u2190 infer_type e\u2081,\n  c \u2190 mk_instance_cache \u03b1,\n  match \u03b1 with\n  | `(nat) := do\n    n\u2081 \u2190 e\u2081.to_nat, n\u2082 \u2190 e\u2082.to_nat,\n    q \u2190 expr.of_nat \u03b1 (n\u2081 / n\u2082),\n    r \u2190 expr.of_nat \u03b1 (n\u2081 % n\u2082),\n    (c, e\u2083) \u2190 c.mk_app ``has_mul.mul [q, e\u2082],\n    (c, e\u2083) \u2190 c.mk_app ``has_add.add [r, e\u2083],\n    (e\u2081', p) \u2190 norm_num e\u2083,\n    guard (e\u2081' =\u2090 e\u2081),\n    (c, p') \u2190 prove_lt simp c r e\u2082,\n    p \u2190 mk_app ``norm_num.nat_mod_helper [e\u2081, e\u2082, q, r, p, p'],\n    return (r, p)\n  | `(int) := match e\u2082 with\n    | `(- %%e\u2082') := do\n      let p\u2081 := (expr.const ``int.mod_neg []).mk_app [e\u2081, e\u2082'],\n      (c, e) \u2190 c.mk_app ``has_mod.mod [e\u2081, e\u2082'],\n      (e', p\u2082) \u2190 simp e,\n      p \u2190 mk_eq_trans p\u2081 p\u2082,\n      return (e', p)\n    | _ := do\n      n\u2081 \u2190 e\u2081.to_int,\n      n\u2082 \u2190 e\u2082.to_int,\n      q \u2190 expr.of_rat \u03b1 $ rat.of_int (n\u2081 / n\u2082),\n      r \u2190 expr.of_rat \u03b1 $ rat.of_int (n\u2081 % n\u2082),\n      (c, e\u2083) \u2190 c.mk_app ``has_mul.mul [q, e\u2082],\n      (c, e\u2083) \u2190 c.mk_app ``has_add.add [r, e\u2083],\n      (e\u2081', p) \u2190 norm_num e\u2083,\n      guard (e\u2081' =\u2090 e\u2081),\n      (c, r0) \u2190 c.mk_app ``has_zero.zero [],\n      (c, r0) \u2190 c.mk_app ``has_le.le [r0, r],\n      (_, p\u2081) \u2190 simp r0,\n      p\u2081 \u2190 mk_app ``of_eq_true [p\u2081],\n      (c, p\u2082) \u2190 prove_lt simp c r e\u2082,\n      p \u2190 mk_app ``norm_num.int_mod_helper [e\u2081, e\u2082, q, r, p, p\u2081, p\u2082],\n      return (r, p)\n    end\n  | _ := failed\n  end\n| `(%%e\u2081 \u2223 %%e\u2082) := do\n  \u03b1 \u2190 infer_type e\u2081,\n  c \u2190 mk_instance_cache \u03b1,\n  n \u2190 match \u03b1 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\u2081 \u2190 mk_app ``propext [@expr.const tt n [] e\u2081 e\u2082],\n  (e', p\u2082) \u2190 simp `(%%e\u2082 % %%e\u2081 = 0),\n  p' \u2190 mk_eq_trans p\u2081 p\u2082,\n  return (e', p')\n| _ := failed\n\nlemma not_prime_helper (a b n : \u2115)\n  (h : a * b = n) (h\u2081 : 1 < a) (h\u2082 : 1 < b) : \u00ac nat.prime n :=\nby rw \u2190 h; exact nat.not_prime_mul h\u2081 h\u2082\n\nlemma is_prime_helper (n : \u2115)\n  (h\u2081 : 1 < n) (h\u2082 : nat.min_fac n = n) : nat.prime n :=\nnat.prime_def_min_fac.2 \u27e8h\u2081, h\u2082\u27e9\n\nlemma min_fac_bit0 (n : \u2115) : nat.min_fac (bit0 n) = 2 :=\nby simp [nat.min_fac_eq, show 2 \u2223 bit0 n, by simp [bit0_eq_two_mul n]]\n\ndef min_fac_helper (n k : \u2115) : Prop :=\n0 < k \u2227 bit1 k \u2264 nat.min_fac (bit1 n)\n\ntheorem min_fac_helper.n_pos {n k : \u2115} (h : min_fac_helper n k) : 0 < n :=\nnat.pos_iff_ne_zero.2 $ \u03bb 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 : \u2115} : nat.min_fac (bit1 n) \u2260 bit0 k :=\nby rw bit0_eq_two_mul; exact \u03bb e, absurd\n  ((nat.dvd_add_iff_right (by simp [bit0_eq_two_mul n])).2\n    (dvd_trans \u27e8_, e\u27e9 (nat.min_fac_dvd _)))\n  dec_trivial\n\nlemma min_fac_helper_0 (n : \u2115) (h : 0 < n) : min_fac_helper n 1 :=\nbegin\n  refine \u27e8zero_lt_one, lt_of_le_of_ne _ min_fac_ne_bit0.symm\u27e9,\n  refine @lt_of_le_of_ne \u2115 _ _ _ (nat.min_fac_pos _) _,\n  intro e,\n  have := nat.min_fac_prime _,\n  { rw \u2190 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' : \u2115} (e : k + 1 = k')\n  (np : nat.min_fac (bit1 n) \u2260 bit1 k)\n  (h : min_fac_helper n k) : min_fac_helper n k' :=\nbegin\n  rw \u2190 e,\n  refine \u27e8nat.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) < _)\u27e9,\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' : \u2115) (e : k + 1 = k')\n  (np : \u00ac 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\u2081, rw \u2190 e\u2081 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' : \u2115) (e : k + 1 = k')\n  (nd : bit1 k \u2223 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\u2081, rw [eq_false, \u2190 e\u2081] at nd,\n  exact nd (nat.min_fac_dvd _)\nend\n\nlemma min_fac_helper_4 (n k : \u2115) (hd : bit1 k \u2223 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' : \u2115) (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    \u27e8nat.bit1_lt h.n_pos, _\u27e9)).2,\n  rw \u2190 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 \u2192 tactic (expr \u00d7 expr)) (e : expr) (n d\u2081 : \u2115) : tactic expr :=\ndo let e\u2081 := reflect d\u2081,\n  c \u2190 mk_instance_cache `(nat),\n  (c, p\u2081) \u2190 prove_lt simp c `(1) e\u2081,\n  let d\u2082 := n / d\u2081, let e\u2082 := reflect d\u2082,\n  (e', p) \u2190 mk_app ``has_mul.mul [e\u2081, e\u2082] >>= norm_num,\n  guard (e' =\u2090 e),\n  (c, p\u2082) \u2190 prove_lt simp c `(1) e\u2082,\n  return $ (expr.const ``not_prime_helper []).mk_app [e\u2081, e\u2082, e, p, p\u2081, p\u2082]\n\nmeta def prove_min_fac (simp : expr \u2192 tactic (expr \u00d7 expr))\n  (e\u2081 : expr) (n1 : \u2115) : expr \u2192 expr \u2192 tactic (expr \u00d7 expr)\n| e\u2082 p := do\n  k \u2190 e\u2082.to_nat,\n  let k1 := bit1 k,\n  e\u20811 \u2190 mk_app ``bit1 [e\u2081],\n  e\u20821 \u2190 mk_app ``bit1 [e\u2082],\n  if n1 < k1*k1 then do\n    c \u2190 mk_instance_cache `(nat),\n    (c, e') \u2190 c.mk_app ``has_mul.mul [e\u20821, e\u20821],\n    (e', p\u2081) \u2190 norm_num e',\n    (c, p\u2082) \u2190 prove_lt simp c e\u20811 e',\n    p' \u2190 mk_app ``min_fac_helper_5 [e\u2081, e\u2082, e', p\u2081, p\u2082, p],\n    return (e\u20811, p')\n  else let d := k1.min_fac in\n  if to_bool (d < k1) then do\n    (e', p\u2081) \u2190 norm_num `(%%e\u2082 + 1),\n    p\u2082 \u2190 prove_non_prime simp e\u20821 k1 d,\n    mk_app ``min_fac_helper_2 [e\u2081, e\u2082, e', p\u2081, p\u2082, p] >>= prove_min_fac e'\n  else do\n    (_, p\u2082) \u2190 simp `((%%e\u20821 : \u2115) \u2223 %%e\u20811),\n    if k1 \u2223 n1 then do\n      p' \u2190 mk_app ``min_fac_helper_4 [e\u2081, e\u2082, p\u2082, p],\n      return (e\u20821, p')\n    else do\n      (e', p\u2081) \u2190 norm_num `(%%e\u2082 + 1),\n      mk_app ``min_fac_helper_3 [e\u2081, e\u2082, e', p\u2081, p\u2082, p] >>= prove_min_fac e'\n\nmeta def eval_prime (simp : expr \u2192 tactic (expr \u00d7 expr)) : expr \u2192 tactic (expr \u00d7 expr)\n| `(nat.prime %%e) := do\n  n \u2190 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\u2081 := n.min_fac in\n    if d\u2081 < n then prove_non_prime simp e n d\u2081 >>= false_intro\n    else do\n      let e\u2081 := reflect d\u2081,\n      c \u2190 mk_instance_cache `(nat),\n      (c, p\u2081) \u2190 prove_lt simp c `(1) e\u2081,\n      (e\u2081, p) \u2190 simp `(nat.min_fac %%e),\n      true_intro $ (expr.const ``is_prime_helper []).mk_app [e, p\u2081, p]\n  end\n| `(nat.min_fac 0) := refl_conv (reflect (0:\u2115))\n| `(nat.min_fac 1) := refl_conv (reflect (1:\u2115))\n| `(nat.min_fac (bit0 %%e)) := prod.mk `(2) <$> mk_app ``min_fac_bit0 [e]\n| `(nat.min_fac (bit1 %%e)) := do\n  n \u2190 e.to_nat,\n  c \u2190 mk_instance_cache `(nat),\n  (c, p) \u2190 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 \u2192 tactic (expr \u00d7 expr)) (e : expr) :\n  tactic (expr \u00d7 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 \u2192 tactic (expr \u00d7 expr) | e :=\ndo (_, e', pr) \u2190\n    ext_simplify_core () {} simp_lemmas.mk (\u03bb _, failed) (\u03bb _ _ _ _ _, failed)\n      (\u03bb _ _ _ _ e,\n        do (new_e, pr) \u2190 derive1 derive e,\n           guard (\u00ac new_e =\u2090 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 \u2190 loc.get_locals,\n   tt \u2190 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 (\u00ac ns.empty) $ try tactic.contradiction\n\n/-- Normalize numerical expressions. Supports the operations\n  `+` `-` `*` `/` `^` `<` `\u2264` over ordered fields (or other\n  appropriate classes), as well as `-` `/` `%` over `\u2124` and `\u2115`. -/\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\u2081 \u2190 to_expr x,\n  (x\u2082,_) \u2190 derive x\u2081,\n  tactic.exact x\u2082\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 \u2964 Type`, an object of `F.elements` is a pair `(X : C, x : F.obj X)`.\nA morphism `(X, x) \u27f6 (Y, y)` is a morphism `f : X \u27f6 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 \u2964 Type`\nis a pair `(X : C, x : F.obj X)`.\n-/\n@[nolint has_nonempty_instance]\ndef functor.elements (F : C \u2964 Type w) := (\u03a3 c : C, F.obj c)\n\n/-- The category structure on `F.elements`, for `F : C \u2964 Type`.\n    A morphism `(X, x) \u27f6 (Y, y)` is a morphism `f : X \u27f6 Y` in `C`, so `F.map f` takes `x` to `y`.\n -/\ninstance category_of_elements (F : C \u2964 Type w) : category.{v} F.elements :=\n{ hom := \u03bb p q, { f : p.1 \u27f6 q.1 // (F.map f) p.2 = q.2 },\n  id := \u03bb p, \u27e8\ud835\udfd9 p.1, by obviously\u27e9,\n  comp := \u03bb p q r f g, \u27e8f.val \u226b g.val, by obviously\u27e9 }\n\nnamespace category_of_elements\n\n@[ext]\nlemma ext (F : C \u2964 Type w) {x y : F.elements} (f g : x \u27f6 y) (w : f.val = g.val) : f = g :=\nsubtype.ext_val w\n\n@[simp] lemma comp_val {F : C \u2964 Type w} {p q r : F.elements} {f : p \u27f6 q} {g : q \u27f6 r} :\n  (f \u226b g).val = f.val \u226b g.val := rfl\n\n@[simp] lemma id_val {F : C \u2964 Type w} {p : F.elements} : (\ud835\udfd9 p : p \u27f6 p).val = \ud835\udfd9 p.1 := rfl\n\nend category_of_elements\n\nnoncomputable\ninstance groupoid_of_elements {G : Type u} [groupoid.{v} G] (F : G \u2964 Type w) :\n  groupoid F.elements :=\n{ inv := \u03bb p q f, \u27e8inv 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 \u226b F.map (inv f.val)) p.2 : rfl\n                           ... = p.2 : by {rw \u2190 F.map_comp, simp} \u27e9,\n  inv_comp' := \u03bb _ _ _, by { ext, simp },\n  comp_inv' := \u03bb _ _ _, by { ext, simp } }\n\nnamespace category_of_elements\nvariable (F : C \u2964 Type w)\n\n/-- The functor out of the category of elements which forgets the element. -/\n@[simps]\ndef \u03c0 : F.elements \u2964 C :=\n{ obj := \u03bb X, X.1,\n  map := \u03bb 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\u2081 F\u2082 : C \u2964 Type w} (\u03b1 : F\u2081 \u27f6 F\u2082) : F\u2081.elements \u2964 F\u2082.elements :=\n{ obj := \u03bb t, \u27e8t.1, \u03b1.app t.1 t.2\u27e9,\n  map := \u03bb t\u2081 t\u2082 k, \u27e8k.1, by simpa [\u2190k.2] using (functor_to_types.naturality _ _ \u03b1 k.1 t\u2081.2).symm\u27e9 }\n\n@[simp] lemma map_\u03c0 {F\u2081 F\u2082 : C \u2964 Type w} (\u03b1 : F\u2081 \u27f6 F\u2082) : map \u03b1 \u22d9 \u03c0 F\u2082 = \u03c0 F\u2081 := rfl\n\n/-- The forward direction of the equivalence `F.elements \u2245 (*, F)`. -/\ndef to_structured_arrow : F.elements \u2964 structured_arrow punit F :=\n{ obj := \u03bb X, structured_arrow.mk (\u03bb _, X.2),\n  map := \u03bb 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 := \u27e8\u27e8\u27e9\u27e9, right := X.1, hom := \u03bb _, X.2 } := rfl\n@[simp] lemma to_comma_map_right {X Y} (f : X \u27f6 Y) :\n  ((to_structured_arrow F).map f).right = f.val := rfl\n\n/-- The reverse direction of the equivalence `F.elements \u2245 (*, F)`. -/\ndef from_structured_arrow : structured_arrow punit F \u2964 F.elements :=\n{ obj := \u03bb X, \u27e8X.right, X.hom (punit.star)\u27e9,\n  map := \u03bb X Y f, \u27e8f.right, congr_fun f.w'.symm punit.star\u27e9 }\n\n@[simp] lemma from_structured_arrow_obj (X) :\n  (from_structured_arrow F).obj X = \u27e8X.right, X.hom (punit.star)\u27e9 := rfl\n@[simp] lemma from_structured_arrow_map {X Y} (f : X \u27f6 Y) :\n  (from_structured_arrow F).map f = \u27e8f.right, congr_fun f.w'.symm punit.star\u27e9 := 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 \u224c structured_arrow punit F :=\nequivalence.mk (to_structured_arrow F) (from_structured_arrow F)\n  (nat_iso.of_components (\u03bb X, eq_to_iso (by tidy)) (by tidy))\n  (nat_iso.of_components\n    (\u03bb 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\u1d52\u1d56 \u2245 (yoneda, F)`,\ngiven by `category_theory.yoneda_sections`.\n-/\n@[simps]\ndef to_costructured_arrow (F : C\u1d52\u1d56 \u2964 Type v) : (F.elements)\u1d52\u1d56 \u2964 costructured_arrow yoneda F :=\n{ obj := \u03bb X, costructured_arrow.mk\n    ((yoneda_sections (unop (unop X).fst) F).inv (ulift.up (unop X).2)),\n  map := \u03bb 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\u1d52\u1d56 \u2245 (yoneda, F)`,\ngiven by `category_theory.yoneda_equiv`.\n-/\n@[simps]\ndef from_costructured_arrow (F : C\u1d52\u1d56 \u2964 Type v) : (costructured_arrow yoneda F)\u1d52\u1d56 \u2964 F.elements :=\n{ obj := \u03bb X, \u27e8op (unop X).1, yoneda_equiv.1 (unop X).3\u27e9,\n  map := \u03bb X Y f, \u27e8f.unop.1.op,\n  begin\n    convert (congr_fun ((unop X).hom.naturality f.unop.left.op) (\ud835\udfd9 _)).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 \u226b (unop X).hom = (unop Y).hom,\n    { convert f.unop.3, erw category.comp_id },\n    erw \u2190 this,\n    simp only [yoneda_map_app, functor_to_types.comp],\n    erw category.id_comp\n  end \u27e9}\n\n@[simp]\nlemma from_costructured_arrow_obj_mk (F : C\u1d52\u1d56 \u2964 Type v) {X : C} (f : yoneda.obj X \u27f6 F) :\n  (from_costructured_arrow F).obj (op (costructured_arrow.mk f)) = \u27e8op X, yoneda_equiv.1 f\u27e9 := rfl\n\n/-- The unit of the equivalence `F.elements\u1d52\u1d56 \u2245 (yoneda, F)` is indeed iso. -/\nlemma from_to_costructured_arrow_eq (F : C\u1d52\u1d56 \u2964 Type v) :\n (to_costructured_arrow F).right_op \u22d9 from_costructured_arrow F = \ud835\udfed _ :=\nbegin\n  apply functor.ext,\n  intros X Y f,\n  have : \u2200 {a b : F.elements} (H : a = b),\n    \u2191(eq_to_hom H) = eq_to_hom (show a.fst = b.fst, by { cases H, refl }) :=\n    \u03bb _ _ H, by { cases H, refl },\n  ext, simp[this],\n  tidy\nend\n\n/-- The counit of the equivalence `F.elements\u1d52\u1d56 \u2245 (yoneda, F)` is indeed iso. -/\nlemma to_from_costructured_arrow_eq (F : C\u1d52\u1d56 \u2964 Type v) :\n  (from_costructured_arrow F).right_op \u22d9 to_costructured_arrow F = \ud835\udfed _ :=\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 (\ud835\udfd9 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 \u27e8X_left, \u27e8\u27e8\u27e9\u27e9\u27e9, rcases Y with \u27e8Y_left, \u27e8\u27e8\u27e9\u27e9\u27e9, 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 (\ud835\udfd9 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 (\ud835\udfd9 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\u1d52\u1d56 \u2245 (yoneda, F)` given by yoneda lemma. -/\n@[simps] def costructured_arrow_yoneda_equivalence (F : C\u1d52\u1d56 \u2964 Type v) :\n  (F.elements)\u1d52\u1d56 \u224c 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)\u1d52\u1d56 \u2245 (yoneda, -)` of is actually a natural isomorphism of functors.\n-/\nlemma costructured_arrow_yoneda_equivalence_naturality {F\u2081 F\u2082 : C\u1d52\u1d56 \u2964 Type v}\n  (\u03b1 : F\u2081 \u27f6 F\u2082) : (map \u03b1).op \u22d9 to_costructured_arrow F\u2082 =\n    to_costructured_arrow F\u2081 \u22d9 costructured_arrow.map \u03b1 :=\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 (\u03b1.naturality f.op).symm (unop X).snd },\n  { intros X Y f, ext,\n    have : \u2200 {F : C\u1d52\u1d56 \u2964 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      \u03bb _ _ _ 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 (\u03bb 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 : \u2200 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 : \u2200 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 \u2192 nat\n| 0 := 0\n| (n+1):= foo s t + bar n\n\ndef bar' (s t : nat) : nat \u2192 nat\n| 0 := 0\n| (n+1):= foo' s t + bar' n\n\ndef baz := \"hello\"\n\ndef bla (s : string) : nat \u2192 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 \u2190 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 `\u2228` (\"or\") connective. For example, if you have\nthe assumption\n\n```\nh : P \u2228 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\u22a2 P\n```\nand\n\n```\nP : Prop\nhq : Q\n\u22a2 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 \u2228 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 \u03b1`\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 \u03b1 \u2243 option \u03b2` constructed from `e : \u03b1 \u2243 \u03b2` by sending `none` to\n  `none`, and applying a `e` elsewhere.\n* `equiv.remove_none`: the `\u03b1 \u2243 \u03b2` constructed from `option \u03b1 \u2243 option \u03b2` by removing `none` from\n  both sides.\n-/\n\nnamespace equiv\n\nopen option\n\nvariables {\u03b1 \u03b2 \u03b3 : 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 : \u03b1 \u2243 \u03b2) : option \u03b1 \u2243 option \u03b2 :=\n{ to_fun := option.map e,\n  inv_fun := option.map e.symm,\n  left_inv := \u03bb x, (option.map_map _ _ _).trans $\n    e.symm_comp_self.symm \u25b8 congr_fun option.map_id x,\n  right_inv := \u03bb x, (option.map_map _ _ _).trans $\n    e.self_comp_symm.symm \u25b8 congr_fun option.map_id x }\n\n@[simp] lemma option_congr_refl : option_congr (equiv.refl \u03b1) = equiv.refl _ :=\next $ congr_fun option.map_id\n\n@[simp] lemma option_congr_symm (e : \u03b1 \u2243 \u03b2) : (option_congr e).symm = option_congr e.symm := rfl\n\n@[simp] lemma option_congr_trans (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b2 \u2243 \u03b3) :\n  (option_congr e\u2081).trans (option_congr e\u2082) = option_congr (e\u2081.trans e\u2082) :=\next $ option.map_map _ _\n\n/-- When `\u03b1` and `\u03b2` 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 {\u03b1 \u03b2 : Type*} (e : \u03b1 \u2243 \u03b2) :\n  option_congr e = equiv_functor.map_equiv option e := rfl\n\nend option_congr\n\nsection remove_none\nvariables (e : option \u03b1 \u2243 option \u03b2)\n\nprivate def remove_none_aux (x : \u03b1) : \u03b2 :=\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 \u2190option.ne_none_iff_is_some,\n    intro hn,\n    rw [option.not_is_some_iff_eq_none, \u2190hn] at h,\n    simpa only using e.injective h,\n  end\n\nprivate lemma remove_none_aux_some {x : \u03b1} (h : \u2203 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 : \u03b1} (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 : \u03b1) : 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 _ \u27e8_, h2\u27e9 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 _ \u27e8_, h1\u27e9,\n    rw remove_none_aux_some _ \u27e8_, h2\u27e9,\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 : \u03b1 \u2243 \u03b2 :=\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 : \u03b1} (h : \u2203 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 \u2194 e none = none :=\n\u27e8\u03bb h, by simpa using (congr_arg e h).symm, \u03bb h, by simpa using (congr_arg e.symm h).symm\u27e9\n\nlemma some_remove_none_iff {x : \u03b1} :\n  some (remove_none e x) = e none \u2194 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 _ \u27e8a, h\u27e9,\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 : \u03b1 \u2243 \u03b2) : remove_none e.option_congr = e :=\nequiv.ext $ \u03bb x, option.some_injective _ $ remove_none_some _ \u27e8e x, by simp [equiv_functor.map]\u27e9\n\nend remove_none\n\nlemma option_congr_injective : function.injective (option_congr : \u03b1 \u2243 \u03b2 \u2192 option \u03b1 \u2243 option \u03b2) :=\nfunction.left_inverse.injective remove_none_option_congr\n\n/-- Equivalences between `option \u03b1` and `\u03b2` that send `none` to `x` are equivalent to\nequivalences between `\u03b1` and `{y : \u03b2 // y \u2260 x}`. -/\ndef option_subtype [decidable_eq \u03b2] (x : \u03b2) :\n  {e : option \u03b1 \u2243 \u03b2 // e none = x} \u2243 (\u03b1 \u2243 {y : \u03b2 // y \u2260 x}) :=\n{ to_fun := \u03bb e,\n    { to_fun := \u03bb a, \u27e8e a, ((equiv_like.injective _).ne_iff' e.property).2 (some_ne_none _)\u27e9,\n      inv_fun := \u03bb 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 := \u03bb a, begin\n          rw [\u2190some_inj, some_get, \u2190coe_def],\n          exact symm_apply_apply (e : option \u03b1 \u2243 \u03b2) a\n        end,\n      right_inv := \u03bb b, begin\n          ext,\n          simp,\n          exact apply_symm_apply _ _\n        end },\n  inv_fun := \u03bb e,\n    \u27e8{ to_fun := \u03bb a, cases_on' a x (coe \u2218 e),\n       inv_fun := \u03bb b, if h : b = x then none else e.symm \u27e8b, h\u27e9,\n       left_inv := \u03bb 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 := \u03bb b, begin\n           by_cases h : b = x;\n             simp [h]\n         end},\n     rfl\u27e9,\n  left_inv := \u03bb e, begin\n      ext a,\n      cases a,\n      { simpa using e.property.symm },\n      { simpa }\n    end,\n  right_inv := \u03bb e, begin\n      ext a,\n      refl\n    end }\n\n@[simp] lemma option_subtype_apply_apply [decidable_eq \u03b2] (x : \u03b2)\n  (e : {e : option \u03b1 \u2243 \u03b2 // e none = x}) (a : \u03b1) (h) :\n  option_subtype x e a = \u27e8(e : option \u03b1 \u2243 \u03b2) a, h\u27e9 :=\nrfl\n\n@[simp] lemma coe_option_subtype_apply_apply [decidable_eq \u03b2] (x : \u03b2)\n  (e : {e : option \u03b1 \u2243 \u03b2 // e none = x}) (a : \u03b1) :\n  \u2191(option_subtype x e a) = (e : option \u03b1 \u2243 \u03b2) a :=\nrfl\n\n@[simp] lemma option_subtype_apply_symm_apply [decidable_eq \u03b2] (x : \u03b2)\n  (e : {e : option \u03b1 \u2243 \u03b2 // e none = x}) (b : {y : \u03b2 // y \u2260 x}) :\n  \u2191((option_subtype x e).symm b) = (e : option \u03b1 \u2243 \u03b2).symm b :=\nbegin\n  dsimp only [option_subtype],\n  simp\nend\n\n@[simp] lemma option_subtype_symm_apply_apply_coe [decidable_eq \u03b2] (x : \u03b2)\n  (e : \u03b1 \u2243 {y : \u03b2 // y \u2260 x}) (a : \u03b1) : (option_subtype x).symm e a = e a :=\nrfl\n\n@[simp] lemma option_subtype_symm_apply_apply_some [decidable_eq \u03b2] (x : \u03b2)\n  (e : \u03b1 \u2243 {y : \u03b2 // y \u2260 x}) (a : \u03b1) : (option_subtype x).symm e (some a) = e a :=\nrfl\n\n@[simp] lemma option_subtype_symm_apply_apply_none [decidable_eq \u03b2] (x : \u03b2)\n  (e : \u03b1 \u2243 {y : \u03b2 // y \u2260 x}) : (option_subtype x).symm e none = x :=\nrfl\n\n@[simp] lemma option_subtype_symm_apply_symm_apply [decidable_eq \u03b2] (x : \u03b2)\n  (e : \u03b1 \u2243 {y : \u03b2 // y \u2260 x}) (b : {y : \u03b2 // y \u2260 x}) :\n  ((option_subtype x).symm e : option \u03b1 \u2243 \u03b2).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 \u03bb 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 [\u2190baz, 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 \u2192 \u2124[T\u207b\u00b9] \u2192 \u2133(S, \u2124((T))_r') \u2192 \u2133-bar(S)_r' \u2192 0\n```\n-/\n\n-- move me\nlemma int.coe_nat_injective : function.injective (coe : \u2115 \u2192 \u2124) :=\n\u03bb m n h, int.coe_nat_inj h\n\nlemma int.nat_abs_of_nonpos {a : \u2124} : a \u2264 0 \u2192 \u2191(a.nat_abs) = -a :=\nbegin\n  intro h,\n  rw \u2190 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' : \u211d\u22650) [fact (0 < r')] (S : Fintype)\n\nnamespace invpoly\n\ndef to_laurent_measures_fun (F : invpoly r' S) : S \u2192 \u2124 \u2192 \u2124\n| s 0       := (F s).coeff 0\n| s (n+1:\u2115) := 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 : \u2115) :\nto_laurent_measures_fun r' S F s (n+1 : \u2115) = 0 :=\nrfl\n\nlemma to_laurent_measures_fun_pos' (F : invpoly r' S) (s : S) (n : \u2115) :\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 : \u2124} (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 : \u2115) :\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 : \u2115) :\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 : \u2115) :\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\u209b : \u2124[T\u207b\u00b9]` to\nthe corresponding power series `F\u209b : \u2124[[T]][T\u207b\u00b9]`. -/\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' := \u03bb s, begin\n    rw \u2190 nnreal.summable_coe,\n    rw \u2190 @summable_subtype_and_compl \u211d \u2124 _ _ _ _ _ {n : \u2124 | n \u2264 0},\n    split,\n    { have := F.nnreal_summable s,\n      rw \u2190 nnreal.summable_coe at this,\n      convert (equiv.summable_iff (equiv.nonpos_ge_zero \u2124)).mpr _,\n      rotate,\n      { exact \u03bb a, ((\u2225(F s).coeff (int.to_nat a)\u2225\u208a * r' ^ (-(a.1))) : \u211d) },\n      rotate,\n      { apply funext,\n        rintros \u27e8x, hx\u27e9,\n        rcases x with \u27e8_ | x\u27e9 | 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 : \u2115 \u2243 {z : \u2124 // 0 \u2264 z})).mp _,\n        simpa },\n      /- setup equiv with `\u2115` using `k \u2192 -k` and use `F.nnreal_summable s` -/ },\n    { convert summable_zero, ext \u27e8((_|n)|n), hn\u27e9,\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\u209b : \u2124[[T]][T\u207b\u00b9]` to `F\u209b : \u2124[T\u207b\u00b9]` obtained\nby throwing away all the positive terms. -/\ndef of_laurent_measures [fact (r' < 1)] (F : laurent_measures r' S) : invpoly r' S :=\n\u03bb s, \u2211 n in finset.range ((1 : \u2124) -(laurent_measures.exists_bdd_filtration\n  (show (0 : \u211d) < 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 : \u2115 \u2192 R) (d n : \u2115) :\n(\u2211 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 : \u2200 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 (\u03bb 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-- \u2124[X] version without C\nlemma polynomial.sum_range_int_mul_X_pow_coeff (f : \u2115 \u2192 \u2124) (d n : \u2115) :\n(\u2211 i in range d, (f i : polynomial \u2124) * 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  \u2225of_laurent_measures r' S F\u2225\u208a \u2264 \u2225F\u2225\u208a :=\nbegin\n  unfold has_nnnorm.nnnorm,\n  apply finset.sum_le_sum, rintro s -,\n  change tsum _ \u2264 tsum _,\n  delta of_laurent_measures,\n  simp_rw polynomial.sum_range_int_mul_X_pow_coeff,\n  apply tsum_le_tsum_of_inj (\u03bb (n : \u2115), -(n : \u2124)),\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 \u2190 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 : \u211d) < 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 : \u2200 (s : S) (n : \u2124), n < d \u2192 (to_laurent_measures r' S F) s n = 0 :=\n    (laurent_measures.exists_bdd_filtration\n    (show (0 : \u211d) < 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 : (\u2211 (n : \u2115) in range (1 - d).to_nat,\n    C (to_laurent_measures r' S F s (-\u2191n)) * X ^ n).coeff n =\n  (F s).coeff n,\n    simpa,\n  rw polynomial.sum_range_const_mul_X_pow_coeff,\n  rw \u2190 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 (\u03bb F, F s 0) at h, exact h },\n  { apply_fun (\u03bb F, F s (-n.succ)) at h, exact h }\nend\n\ndef to_laurent_measures_addhom : invpoly r' S \u2192+ 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  \u2225(to_laurent_measures_addhom r' S) p\u2225\u208a = \u2225p\u2225\u208a :=\nbegin\n  unfold nnnorm,\n  congr',\n  ext s,\n  norm_cast,\n  refine tsum_eq_tsum_of_ne_zero_bij (\u03bb n, -((n.1 : \u2115) : \u2124)) _ _ _,\n  { rintros \u27e8x, _\u27e9 \u27e8y, _\u27e9 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 \u27e8\u27e80, hn\u27e9, rfl\u27e9 },\n    { exfalso,\n      simpa [to_laurent_measures_addhom, to_laurent_measures_fun_pos'] using hn },\n    { exact \u27e8\u27e8n+1, hn\u27e9, rfl\u27e9 } },\n  { rintro \u27e8n, hn\u27e9,\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' := \u03bb c, continuous_bot,\n  map_Tinv' := begin\n    intro F,\n    ext s z,\n    change to_laurent_measures_fun r' S (\u03bb (s : \u21a5S), 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 : \u2124) + 1 = (n + 1 : \u2115)),\n        to_laurent_measures_fun_pos'] },\n    { rw [to_laurent_measures_fun_zero, (by norm_cast : (0 : \u2124) + 1 = (0 + 1 : \u2115)),\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 : \u2124) = -(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 \u2190 eq_sub_iff_add_eq at hn,\n      rw [hn, to_laurent_measures_fun_nonpos, (by {simp, ring} : -(n : \u2124) - 1 = -(n + 1 : \u2115)),\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' \u27f6 Fintype_LaurentMeasures r' :=\n{ app := \u03bb S, to_laurent_measures_hom r' S,\n  naturality' := \u03bb 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 (\u03bb (t_1 : S.\u03b1), f t_1 = t) finset.univ).sum (\u03bb (x : S.\u03b1),\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\u209b : \u2124 \u2192 \u2124` to its\ntruncation `F\u209b : {n \u2265 1} \u2192 \u2124` (often thought of as a power series `F\u209b \u2208 T\u2124[[T]]`.) -/\n@[simps] def to_Lbar (F : laurent_measures r' S) : Lbar r' S :=\n{ to_fun := \u03bb s n, if n = 0 then 0 else F s n,\n  coeff_zero' := \u03bb s, if_pos rfl,\n  summable' := \u03bb 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\u209b : {n\u22651} \u2192 \u2124` to the associated function `F\u209b : \u2124 \u2192 \u2124` which\nvanishes on non-positive integers. -/\ndef to_Lbar_section (G : Lbar r' S) : laurent_measures r' S :=\n\u27e8\u03bb s n, G s n.to_nat,\nbegin\n  intro s,\n  refine (nnreal.summable_iff_on_nat_less 0 (\u03bb 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 [\u2190 nnreal.coe_nat_abs] using G.summable' s }\nend\u27e9\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 {\u03b1 : Type*} [add_comm_monoid \u03b1] [topological_space \u03b1]\n  [t2_space \u03b1]\n  (f : \u2124 \u2192 \u03b1) : \u2211' (n : \u2115), f n = \u2211' (z : \u2124), if z < 0 then 0 else f z :=\nlet e : \u21a5(function.support (\u03bb (x : \u2115), f \u2191x)) \u2243\n  \u21a5(function.support (\u03bb (y : \u2124), ite (y < 0) 0 (f y))) :=\n{ to_fun := \u03bb x, \u27e8x, x.2\u27e9,\n  inv_fun := \u03bb y, \u27e8y.1.nat_abs, \u03bb 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\u27e9,\n  left_inv := begin\n    rintro \u27e8x, hx\u27e9,\n    refl,\n  end,\n  right_inv := begin\n    rintro \u27e8y, hy\u27e9,\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 \u27e8x, hx\u27e9,\n  have hx2 : \u00ac ((x : \u2124) < 0) := \u03bb 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 : \u211d\u22650)\n  (hG : G \u2208 pseudo_normed_group.filtration (Lbar r' S) c) :\n  to_Lbar_section r' S G \u2208 pseudo_normed_group.filtration (laurent_measures r' S) c :=\nbegin\n  change _ \u2264 _,\n  convert (hG : _ \u2264 _) 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 (\u03bb n, \u2225G s n.to_nat\u2225\u208a * 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\u03bb G, \u27e8to_Lbar_section r' S G, to_Lbar_section_to_Lbar r' S G\u27e9\n\nlemma nnnorm_to_Lbar (F : laurent_measures r' S) : \u2225to_Lbar r' S F\u2225\u208a \u2264 \u2225F\u2225\u208a :=\nbegin\n  rw [nnnorm_def, Lbar.nnnorm_def],\n  refine finset.sum_le_sum (\u03bb 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 `\u2124[[T]][1/T]`\nto its positive terms in `T\u2124[[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' := \u03bb 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' := \u03bb c F (hF : \u2225F\u2225\u208a \u2264 c), (nnnorm_to_Lbar r' S F).trans hF,\n  continuous' := \u03bb c, begin\n    let f : _ := _, show continuous f,\n    rw Lbar_le.continuous_iff,\n    intros N,\n    let e : \u2115 \u21aa \u2124 := \u27e8coe, int.coe_nat_injective\u27e9,\n    let T : finset \u2124 := (finset.range (N + 1)).map e,\n    let g : laurent_measures_bdd r' S T c \u2192 Lbar_bdd r' \u27e8S\u27e9 c N := \u03bb F,\n    { to_fun := \u03bb s n, if n = 0 then 0 else F s \u27e8n, _\u27e9,\n      coeff_zero' := \u03bb s, if_pos rfl,\n      sum_le' := _ },\n    have : Lbar_le.truncate N \u2218 f = g \u2218 truncate T,\n    { dsimp [f], ext F s \u27e8(_|n), hn\u27e9, { 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, \u2190 fin.sum_univ_eq_sum_range],\n      refine finset.sum_le_sum (\u03bb 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' := \u03bb 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' \u27f6 Fintype_Lbar r' :=\n{ app := \u03bb S, to_Lbar_hom r' S,\n  naturality' := \u03bb S\u2081 S\u2082 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\u2081\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\u2081_to_CHFPNG\u2081\u2091\u2097 r'))).app S)\n    ((condensify_map\n      (whisker_right (laurent_measures.to_Lbar_nat_trans r') (PFPNGT\u2081_to_CHFPNG\u2081\u2091\u2097 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 \u27e8hF1, hF2\u27e9,\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 \u2208 pseudo_normed_group.filtration (laurent_measures r' S) c at hF2,\n    show F \u2208 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 : \u211d) < r', by norm_cast; exact fact.elim infer_instance)\n      (by norm_cast; exact fact.elim infer_instance)\n      F,\n    refine \u27e8invpoly.of_laurent_measures r' S F, _, _\u27e9,\n    { change \u2225_\u2225\u208a \u2264 c,\n      change \u2225_\u2225\u208a \u2264 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 : \u2115) = _,\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, \u2190 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 \u27e8laurent_measures.to_Lbar_section r' S F, _, _\u27e9,\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 Hw5\nimport Lean.Elab.Print\nimport Lean.Elab.Command\n\ntheorem desiredType (A B : Prop) : (A \u2192 B) \u2192 (\u00ac B \u2192 \u00ac A) := sorry \n\nopen Lean\nopen Lean.Meta\nopen Lean.Elab.Command\n\ndef collectAxiomsOf (constName : Name) : MetaM (List String) := do\n  let env \u2190 getEnv\n  let (_, s) := ((CollectAxioms.collect constName).run env).run {}\n  let a := s.axioms.toList.map toString\n  return a\n\n#eval isDefEq (Expr.const ``desiredType []) (Expr.const ``problem1 [])\n#eval collectAxiomsOf ``problem1\n", "meta": {"author": "UofSC-Fall-2022-Math-300-H01", "repo": "homework5", "sha": "9775e690c2ffbaf37992f8441e2772e837306f15", "save_path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-homework5", "path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-homework5/homework5-9775e690c2ffbaf37992f8441e2772e837306f15/_Tests/Problem1.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7401743620390163, "lm_q2_score": 0.6261241702517975, "lm_q1q2_score": 0.4634410582733326}}
{"text": "import data.nat.basic\n\nuniverse u\n\ndef string.drop_chars (c : char) (s : string) : string := \n\u27e8s.data.drop_while (\u03bb x, x = c)\u27e9 \n\ndef string.reverse (s : string) : string := \u27e8s.data.reverse\u27e9 \n\ndef update (\u03b1 : Type u) (k : nat) (a : \u03b1) (f : nat \u2192 \u03b1) : nat \u2192 \u03b1 := \n\u03bb x : nat, if x = k then a else f x\n\nlemma forall_lt_zero (p : nat \u2192 Prop) : \u2200 x < 0, p x := \n\u03bb x h, by cases h\n\naxiom any {P : Prop} : P\n\nlemma forall_lt_succ (p : nat \u2192 Prop) (k : nat) : \n  p k \u2192 (\u2200 x < k, p x) \u2192 (\u2200 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 \u2192 Prop) (k : nat) : \n  (\u2200 x < k.succ, p x) \u2194 (p k \u2227 (\u2200 x < k, p x)) := \niff.intro \n  (\u03bb h, \u27e8 h k (nat.lt_succ_self k), \n          \u03bb x h2, h x (lt.trans h2 (nat.lt_succ_self k))\u27e9) \n  (\u03bb h, forall_lt_succ p k h.left h.right)\n\ninstance forall_lt.decidable (p : nat \u2192 Prop) [decidable_pred p] : \n  \u2200 k : nat, decidable (\u2200 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 (\u03b1x : expr) : tactic expr := \nto_expr ``(@inhabited.default %%\u03b1x _)\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 \u2964 C`,\nand show that when `C` itself is monoidal, it embeds via a monoidal functor into `C \u2964 C`.\n\n## TODO\n\nCan we use this to show coherence results, e.g. a cheap proof that `\u03bb_ (\ud835\udfd9_ C) = \u03c1_ (\ud835\udfd9_ 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 \u2964 C) :=\n{ tensor_obj   := \u03bb F G, F \u22d9 G,\n  tensor_hom   := \u03bb F G F' G' \u03b1 \u03b2, \u03b1 \u25eb \u03b2,\n  tensor_unit  := \ud835\udfed C,\n  associator   := \u03bb F G H, functor.associator F G H,\n  left_unitor  := \u03bb F, functor.left_unitor F,\n  right_unitor := \u03bb 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 \u2964 C) :=\n{ \u03b5 := (right_unitor_nat_iso C).inv,\n  \u03bc := \u03bb X Y,\n  { app := \u03bb Z, (\u03b1_ Z X Y).hom,\n    naturality' := \u03bb Z Z' f, by { dsimp, rw associator_naturality, simp, } },\n  \u03bc_natural' := \u03bb X Y X' Y' f g, by { ext Z, dsimp,\n    simp only [\u2190id_tensor_comp_tensor_id g f, id_tensor_comp, \u2190tensor_id, category.assoc,\n      associator_naturality, associator_naturality_assoc], },\n  associativity' := \u03bb X Y Z, by { ext W, dsimp, simp [pentagon], },\n  left_unitality' := \u03bb X, by { ext Y, dsimp, rw [category.id_comp, triangle, \u2190tensor_comp], simp, },\n  right_unitality' := \u03bb 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      \u2190id_tensor_comp, iso.inv_hom_id, tensor_id],\n  end,\n  \u03b5_is_iso := by apply_instance,\n  \u03bc_is_iso := \u03bb X Y,\n    -- We could avoid needing to do this explicitly by\n    -- constructing a partially applied analogue of `associator_nat_iso`.\n  \u27e8\u27e8{ app := \u03bb Z, (\u03b1_ Z X Y).inv,\n      naturality' := \u03bb Z Z' f, by { dsimp, rw \u2190associator_inv_naturality, simp, } },\n    by tidy\u27e9\u27e9,\n  ..tensoring_right C }.\n\nvariable {C}\nvariables {M : Type*} [category M] [monoidal_category M] (F : monoidal_functor M (C \u2964 C))\n\n@[simp, reassoc]\nlemma \u03bc_hom_inv_app (i j : M) (X : C) :\n  (F.\u03bc i j).app X \u226b (F.\u03bc_iso i j).inv.app X = \ud835\udfd9 _ := (F.\u03bc_iso i j).hom_inv_id_app X\n\n@[simp, reassoc]\nlemma \u03bc_inv_hom_app (i j : M) (X : C) :\n   (F.\u03bc_iso i j).inv.app X \u226b (F.\u03bc i j).app X = \ud835\udfd9 _ := (F.\u03bc_iso i j).inv_hom_id_app X\n\n@[simp, reassoc]\nlemma \u03b5_hom_inv_app (X : C) :\n  F.\u03b5.app X \u226b F.\u03b5_iso.inv.app X = \ud835\udfd9 _ := F.\u03b5_iso.hom_inv_id_app X\n\n@[simp, reassoc]\nlemma \u03b5_inv_hom_app (X : C) :\n  F.\u03b5_iso.inv.app X \u226b F.\u03b5.app X = \ud835\udfd9 _ := F.\u03b5_iso.inv_hom_id_app X\n\n@[simp, reassoc]\nlemma \u03b5_naturality {X Y : C} (f : X \u27f6 Y) :\n  F.\u03b5.app X \u226b (F.obj (\ud835\udfd9_M)).map f = f \u226b F.\u03b5.app Y := (F.\u03b5.naturality f).symm\n\n@[simp, reassoc]\nlemma \u03b5_inv_naturality {X Y : C} (f : X \u27f6 Y) :\n  (F.obj (\ud835\udfd9_M)).map f \u226b F.\u03b5_iso.inv.app Y = F.\u03b5_iso.inv.app X \u226b f :=\nF.\u03b5_iso.inv.naturality f\n\n@[simp, reassoc]\nlemma \u03bc_naturality {m n : M} {X Y : C} (f : X \u27f6 Y) :\n  (F.obj n).map ((F.obj m).map f) \u226b (F.\u03bc m n).app Y = (F.\u03bc m n).app X \u226b (F.obj _).map f :=\n(F.to_lax_monoidal_functor.\u03bc m n).naturality f\n\n-- This is a simp lemma in the reverse direction via `nat_trans.naturality`.\n@[reassoc]\nlemma \u03bc_inv_naturality {m n : M} {X Y : C} (f : X \u27f6 Y) :\n  (F.\u03bc_iso m n).inv.app X \u226b (F.obj n).map ((F.obj m).map f) =\n    (F.obj _).map f \u226b (F.\u03bc_iso m n).inv.app Y :=\n((F.\u03bc_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 \u03bc_naturality\u2082 {m n m' n' : M} (f : m \u27f6 m') (g : n \u27f6 n') (X : C) :\n  (F.map g).app ((F.obj m).obj X) \u226b (F.obj n').map ((F.map f).app X) \u226b (F.\u03bc m' n').app X =\n    (F.\u03bc m n).app X \u226b (F.map (f \u2297 g)).app X :=\nbegin\n  have := congr_app (F.to_lax_monoidal_functor.\u03bc_natural f g) X,\n  dsimp at this,\n  simpa using this,\nend\n\n@[simp, reassoc]\nlemma \u03bc_naturality\u2097 {m n m' : M} (f : m \u27f6 m') (X : C) :\n  (F.obj n).map ((F.map f).app X) \u226b (F.\u03bc m' n).app X =\n    (F.\u03bc m n).app X \u226b (F.map (f \u2297 \ud835\udfd9 n)).app X :=\nbegin\n  rw \u2190 \u03bc_naturality\u2082 F f (\ud835\udfd9 n) X,\n  simp,\nend\n\n@[simp, reassoc]\nlemma \u03bc_naturality\u1d63 {m n n' : M} (g : n \u27f6 n') (X : C) :\n  (F.map g).app ((F.obj m).obj X) \u226b (F.\u03bc m n').app X =\n    (F.\u03bc m n).app X \u226b (F.map (\ud835\udfd9 m \u2297 g)).app X :=\nbegin\n  rw \u2190 \u03bc_naturality\u2082 F (\ud835\udfd9 m) g X,\n  simp,\nend\n\n@[simp, reassoc]\nlemma \u03bc_inv_naturality\u2097 {m n m' : M} (f : m \u27f6 m') (X : C) :\n  (F.\u03bc_iso m n).inv.app X \u226b (F.obj n).map ((F.map f).app X) =\n    (F.map (f \u2297 \ud835\udfd9 n)).app X \u226b (F.\u03bc_iso m' n).inv.app X :=\nbegin\n  rw [\u2190 is_iso.comp_inv_eq, category.assoc, \u2190 is_iso.eq_inv_comp],\n  simp,\nend\n\n@[simp, reassoc]\nlemma \u03bc_inv_naturality\u1d63 {m n n' : M} (g : n \u27f6 n') (X : C) :\n  (F.\u03bc_iso m n).inv.app X \u226b (F.map g).app ((F.obj m).obj X) =\n    (F.map (\ud835\udfd9 m \u2297 g)).app X \u226b (F.\u03bc_iso m n').inv.app X :=\nbegin\n  rw [\u2190 is_iso.comp_inv_eq, category.assoc, \u2190 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.\u03b5.app X) \u226b (F.\u03bc (\ud835\udfd9_M) n).app X\n    \u226b (F.map (\u03bb_ n).hom).app X = \ud835\udfd9 _ :=\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_\u03b5_app (n : M) (X : C) :\n  (F.obj n).map (F.\u03b5.app X) =\n    (F.map (\u03bb_ n).inv).app X \u226b (F.\u03bc_iso (\ud835\udfd9_M) n).inv.app X :=\nbegin\n  refine eq.trans _ (category.id_comp _),\n  rw [\u2190 category.assoc, \u2190 is_iso.comp_inv_eq, \u2190 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.\u03b5.app ((F.obj n).obj X) \u226b (F.\u03bc n (\ud835\udfd9_M)).app X \u226b (F.map (\u03c1_ n).hom).app X = \ud835\udfd9 _ :=\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 \u03b5_app_obj (n : M) (X : C) :\n  F.\u03b5.app ((F.obj n).obj X) =\n    (F.map (\u03c1_ n).inv).app X \u226b (F.\u03bc_iso n (\ud835\udfd9_M)).inv.app X :=\nbegin\n  refine eq.trans _ (category.id_comp _),\n  rw [\u2190 category.assoc, \u2190 is_iso.comp_inv_eq, \u2190 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 \u03b5_inv_app_obj (n : M) (X : C) :\n  F.\u03b5_iso.inv.app ((F.obj n).obj X) =\n    (F.\u03bc n (\ud835\udfd9_M)).app X \u226b (F.map (\u03c1_ n).hom).app X :=\nbegin\n  rw [\u2190 cancel_mono (F.\u03b5.app ((F.obj n).obj X)), \u03b5_inv_hom_app],\n  simpa\nend\n\n@[reassoc]\nlemma associativity_app (m\u2081 m\u2082 m\u2083: M) (X : C) :\n  (F.obj m\u2083).map ((F.\u03bc m\u2081 m\u2082).app X) \u226b (F.\u03bc (m\u2081 \u2297 m\u2082) m\u2083).app X \u226b\n    (F.map (\u03b1_ m\u2081 m\u2082 m\u2083).hom).app X =\n  (F.\u03bc m\u2082 m\u2083).app ((F.obj m\u2081).obj X) \u226b (F.\u03bc m\u2081 (m\u2082 \u2297 m\u2083)).app X :=\nbegin\n  have := congr_app (F.to_lax_monoidal_functor.associativity m\u2081 m\u2082 m\u2083) X,\n  dsimp at this,\n  simpa using this,\nend\n\n@[reassoc, simp]\nlemma obj_\u03bc_app (m\u2081 m\u2082 m\u2083 : M) (X : C) :\n  (F.obj m\u2083).map ((F.\u03bc m\u2081 m\u2082).app X) =\n  (F.\u03bc m\u2082 m\u2083).app ((F.obj m\u2081).obj X) \u226b (F.\u03bc m\u2081 (m\u2082 \u2297 m\u2083)).app X \u226b\n    (F.map (\u03b1_ m\u2081 m\u2082 m\u2083).inv).app X \u226b (F.\u03bc_iso (m\u2081 \u2297 m\u2082) m\u2083).inv.app X :=\nbegin\n  rw [\u2190 associativity_app_assoc],\n  dsimp,\n  simp,\n  dsimp,\n  simp,\nend\n\n@[reassoc, simp]\nlemma obj_\u03bc_inv_app (m\u2081 m\u2082 m\u2083 : M) (X : C) :\n  (F.obj m\u2083).map ((F.\u03bc_iso m\u2081 m\u2082).inv.app X) =\n  (F.\u03bc (m\u2081 \u2297 m\u2082) m\u2083).app X \u226b (F.map (\u03b1_ m\u2081 m\u2082 m\u2083).hom).app X \u226b\n  (F.\u03bc_iso m\u2081 (m\u2082 \u2297 m\u2083)).inv.app X \u226b\n  (F.\u03bc_iso m\u2082 m\u2083).inv.app ((F.obj m\u2081).obj X) :=\nbegin\n  rw \u2190 is_iso.inv_eq_inv,\n  convert obj_\u03bc_app F m\u2081 m\u2082 m\u2083 X using 1,\n  { ext, rw \u2190 functor.map_comp, simp },\n  { simp only [monoidal_functor.\u03bc_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_\u03bc_app {m : M} {X Y : C} (f : X \u27f6 (F.obj m).obj Y) :\n  (F.obj (\ud835\udfd9_M)).map f \u226b (F.\u03bc m (\ud835\udfd9_M)).app _ =\n    F.\u03b5_iso.inv.app _ \u226b f \u226b (F.map (\u03c1_ m).inv).app _ :=\nbegin\n  rw [\u2190 is_iso.inv_comp_eq, \u2190 is_iso.comp_inv_eq],\n  simp,\nend\n\n@[simp]\nlemma obj_\u03bc_zero_app (m\u2081 m\u2082 : M) (X : C) :\n  (F.obj m\u2082).map ((F.\u03bc m\u2081 (\ud835\udfd9_M)).app X) =\n  (F.\u03bc (\ud835\udfd9_M) m\u2082).app ((F.obj m\u2081).obj X) \u226b (F.map (\u03bb_ m\u2082).hom).app ((F.obj m\u2081).obj X) \u226b\n    (F.obj m\u2082).map ((F.map (\u03c1_ m\u2081).inv).app X) :=\nbegin\n  rw [\u2190 obj_\u03b5_inv_app_assoc, \u2190 functor.map_comp],\n  congr, simp,\nend\n\n/-- If `m \u2297 n \u2245 \ud835\udfd9_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 \u2297 n \u2245 \ud835\udfd9_M) : F.obj m \u22d9 F.obj n \u2245 \ud835\udfed C :=\nF.\u03bc_iso m n \u226a\u226b F.to_functor.map_iso h \u226a\u226b F.\u03b5_iso.symm\n\n/-- If `m \u2297 n \u2245 \ud835\udfd9_M` and `n \u2297 m \u2245 \ud835\udfd9_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\u2081 : m \u2297 n \u2245 \ud835\udfd9_M) (h\u2082 : n \u2297 m \u2245 \ud835\udfd9_M)\n  (H : (h\u2081.hom \u2297 \ud835\udfd9 m) \u226b (\u03bb_ m).hom = (\u03b1_ m n m).hom \u226b (\ud835\udfd9 m \u2297 h\u2082.hom) \u226b (\u03c1_ m).hom) : C \u224c C :=\n{ functor := F.obj m,\n  inverse := F.obj n,\n  unit_iso := (unit_of_tensor_iso_unit F m n h\u2081).symm,\n  counit_iso := unit_of_tensor_iso_unit F n m h\u2082,\n  functor_unit_iso_comp' :=\n  begin\n    intro X,\n    dsimp,\n    simp only [\u03bc_naturality\u1d63_assoc, \u03bc_naturality\u2097_assoc, \u03b5_inv_app_obj, category.assoc,\n      obj_\u03bc_inv_app, functor.map_comp, \u03bc_inv_hom_app_assoc, obj_\u03b5_app,\n      unit_of_tensor_iso_unit_inv_app],\n    simp [\u2190 nat_trans.comp_app, \u2190 F.to_functor.map_comp, \u2190 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} (\ud835\udfed T) (\ud835\udfed T)\n\n-- Satisfying the inhabited linter\ninstance arrow.inhabited [inhabited T] : inhabited (arrow T) :=\n{ default := show comma (\ud835\udfed T) (\ud835\udfed T), from default }\n\nend\n\nnamespace arrow\n\n@[simp] lemma id_left (f : arrow T) : comma_morphism.left (\ud835\udfd9 f) = \ud835\udfd9 (f.left) := rfl\n@[simp] lemma id_right (f : arrow T) : comma_morphism.right (\ud835\udfd9 f) = \ud835\udfd9 (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 \u27f6 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 \u27f6 B) \u2192 arrow T) :=\n\u03bb f g h, by { cases h, refl }\n\ntheorem mk_inj (A B : T) {f g : A \u27f6 B} : arrow.mk f = arrow.mk g \u2194 f = g :=\n(mk_injective A B).eq_iff\ninstance {X Y : T} : has_coe (X \u27f6 Y) (arrow T) := \u27e8mk\u27e9\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 \u27f6 g.left} {v : f.right \u27f6 g.right}\n  (w : u \u226b g.hom = f.hom \u226b v) : f \u27f6 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 \u27f6 Y} {P Q : T} {g : P \u27f6 Q} {u : X \u27f6 P} {v : Y \u27f6 Q}\n  (w : u \u226b g = f \u226b v) : arrow.mk f \u27f6 arrow.mk g :=\n{ left := u,\n  right := v,\n  w' := w }\n\n@[simp, reassoc] lemma w {f g : arrow T} (sq : f \u27f6 g) : sq.left \u226b g.hom = f.hom \u226b 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 \u27f6 Y} (sq : f \u27f6 mk g) :\n  sq.left \u226b g = f.hom \u226b sq.right :=\nsq.w\n\nlemma is_iso_of_iso_left_of_is_iso_right\n  {f g : arrow T} (ff : f \u27f6 g) [is_iso ff.left] [is_iso ff.right] : is_iso ff :=\n{ out := \u27e8\u27e8inv ff.left, inv ff.right\u27e9,\n          by { ext; dsimp; simp only [is_iso.hom_inv_id] },\n          by { ext; dsimp; simp only [is_iso.inv_hom_id] }\u27e9 }\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 \u2245 g.left) (r : f.right \u2245 g.right) (h : l.hom \u226b g.hom = f.hom \u226b r.hom) :\n  f \u2245 g :=\ncomma.iso_mk l r h\n\nsection\n\nvariables {f g : arrow T} (sq : f \u27f6 g)\n\ninstance is_iso_left [is_iso sq] : is_iso sq.left :=\n{ out := \u27e8(inv sq).left, by simp only [\u2190 comma.comp_left, is_iso.hom_inv_id, is_iso.inv_hom_id,\n    arrow.id_left, eq_self_iff_true, and_self]\u27e9 }\n\ninstance is_iso_right [is_iso sq] : is_iso sq.right :=\n{ out := \u27e8(inv sq).right, by simp only [\u2190 comma.comp_right, is_iso.hom_inv_id, is_iso.inv_hom_id,\n    arrow.id_right, eq_self_iff_true, and_self]\u27e9 }\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 [\u2190 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 [\u2190 comma.comp_right, is_iso.hom_inv_id, id_right]\n\n@[simp] lemma left_hom_inv_right [is_iso sq] : sq.left \u226b g.hom \u226b inv sq.right = f.hom :=\nby simp only [\u2190 category.assoc, is_iso.comp_inv_eq, w]\n\n-- simp proves this\nlemma inv_left_hom_right [is_iso sq] : inv sq.left \u226b f.hom \u226b 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 := \u03bb Z \u03c6 \u03c8 h, begin\n    let aux : (Z \u27f6 f.left) \u2192 (arrow.mk (\ud835\udfd9 Z) \u27f6 f) := \u03bb \u03c6, { left := \u03c6, right := \u03c6 \u226b f.hom },\n    show (aux \u03c6).left = (aux \u03c8).left,\n    congr' 1,\n    rw \u2190 cancel_mono sq,\n    ext,\n    { exact h },\n    { simp only [comma.comp_right, category.assoc, \u2190 arrow.w],\n      simp only [\u2190 category.assoc, h], },\n  end }\n\ninstance epi_right [epi sq] : epi sq.right :=\n{ left_cancellation := \u03bb Z \u03c6 \u03c8 h, begin\n    let aux : (g.right \u27f6 Z) \u2192 (g \u27f6 arrow.mk (\ud835\udfd9 Z)) := \u03bb \u03c6, { right := \u03c6, left := g.hom \u226b \u03c6 },\n    show (aux \u03c6).right = (aux \u03c8).right,\n    congr' 1,\n    rw \u2190 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 \u2245 Y) (sq : i \u27f6 arrow.mk p.hom) :\n  i.hom \u226b sq.right \u226b 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 \u2245 Y) (p : arrow T) (sq : arrow.mk i.hom \u27f6 p) :\n  i.inv \u226b sq.left \u226b 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 \u27f6 g) :=\n(lift : f.right \u27f6 g.left)\n(fac_left' : f.hom \u226b lift = sq.left . obviously)\n(fac_right' : lift \u226b 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 (\ud835\udfd9 (arrow.mk (\ud835\udfd9 X)))) :=\n\u27e8\u27e8\ud835\udfd9 _, category.id_comp _, category.comp_id _\u27e9\u27e9\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 \u27f6 g) : Prop :=\nmk' :: (exists_lift : nonempty (lift_struct sq))\n\nlemma has_lift.mk {f g : arrow T} {sq : f \u27f6 g} (s : lift_struct sq) : has_lift sq :=\n\u27e8nonempty.intro s\u27e9\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 \u27f6 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 \u27f6 g) [has_lift sq] : f.right \u27f6 g.left :=\n(has_lift.struct sq).lift\n\nlemma lift.fac_left {f g : arrow T} (sq : f \u27f6 g) [has_lift sq] : f.hom \u226b lift sq = sq.left :=\nby simp\n\nlemma lift.fac_right {f g : arrow T} (sq : f \u27f6 g) [has_lift sq] : lift sq \u226b 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 \u27f6 Y} (sq : f \u27f6 mk g) [has_lift sq] :\n  lift sq \u226b g = sq.right :=\nby simp only [\u2190mk_hom g, lift.fac_right]\n\n@[simp, reassoc]\nlemma lift.fac_left_of_from_mk {X Y : T} {f : X \u27f6 Y} {g : arrow T} (sq : mk f \u27f6 g) [has_lift sq] :\n  f \u226b lift sq = sq.left :=\nby simp only [\u2190mk_hom f, lift.fac_left]\n\n@[simp, reassoc]\nlemma lift_mk'_left {X Y P Q : T} {f : X \u27f6 Y} {g : P \u27f6 Q} {u : X \u27f6 P} {v : Y \u27f6 Q}\n  (h : u \u226b g = f \u226b v) [has_lift $ arrow.hom_mk' h] : f \u226b lift (arrow.hom_mk' h) = u :=\nby simp only [\u2190arrow.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 \u27f6 Y} {g : P \u27f6 Q} {u : X \u27f6 P} {v : Y \u27f6 Q}\n  (h : u \u226b g = f \u226b v) [has_lift $ arrow.hom_mk' h] : lift (arrow.hom_mk' h) \u226b g = v :=\nby simp only [\u2190arrow.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 \u27f6 g) [epi f.hom] :\n  subsingleton (lift_struct sq) :=\nsubsingleton.intro $ \u03bb 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 \u27f6 g) [mono g.hom] :\n  subsingleton (lift_struct sq) :=\nsubsingleton.intro $ \u03bb 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 \u226b g`, produce a square between\n`i` and `g`, whose top leg uses `f`:\nA  \u2192 X\n     \u2193f\n\u2193i   Y             --> A \u2192 Y\n     \u2193g                \u2193i  \u2193g\nB  \u2192 Z                 B \u2192 Z\n -/\n@[simps] def square_to_snd {X Y Z: C} {i : arrow C} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n  (sq : i \u27f6 arrow.mk (f \u226b g)) :\n  i \u27f6 arrow.mk g :=\n{ left := sq.left \u226b f,\n  right := sq.right }\n\n/-- The functor sending an arrow to its source. -/\n@[simps] def left_func : arrow C \u2964 C := comma.fst _ _\n\n/-- The functor sending an arrow to its target. -/\n@[simps] def right_func : arrow C \u2964 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 \u2964 C) \u27f6 right_func :=\n{ app := \u03bb f, f.hom }\n\nend arrow\n\nnamespace functor\n\nuniverses v\u2081 v\u2082 u\u2081 u\u2082\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `C \u2964 D` induces a functor between the corresponding arrow categories. -/\n@[simps]\ndef map_arrow (F : C \u2964 D) : arrow C \u2964 arrow D :=\n{ obj := \u03bb a,\n  { left := F.obj a.left,\n    right := F.obj a.right,\n    hom := F.map a.hom, },\n  map := \u03bb 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 [\u2190F.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\u00e9my Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: R\u00e9my 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 (\u03c3-algebras)\n\n* A family of sets of sets `\u03c0 : \u03b9 \u2192 set (set \u03b1)` is independent with respect to a measure `\u03bc` if for\n  any finite set of indices `s = {i_1, ..., i_n}`, for any sets `f i_1 \u2208 \u03c0 i_1, ..., f i_n \u2208 \u03c0 i_n`,\n  `\u03bc (\u22c2 i in s, f i) = \u220f i in s, \u03bc (f i) `. It will be used for families of \u03c0-systems.\n* A family of measurable space structures (i.e. of \u03c3-algebras) is independent with respect to a\n  measure `\u03bc` (typically defined on a finer \u03c3-algebra) if the family of sets of measurable sets they\n  define is independent. I.e., `m : \u03b9 \u2192 measurable_space \u03b1` is independent with respect to a\n  measure `\u03bc` if for any finite set of indices `s = {i_1, ..., i_n}`, for any sets\n  `f i_1 \u2208 m i_1, ..., f i_n \u2208 m i_n`, then `\u03bc (\u22c2 i in s, f i) = \u220f i in s, \u03bc (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 `\u2205, s, s\u1d9c, 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 \u03c0-systems are independent as sets of sets, then the\nmeasurable space structures they generate are independent.\n* `indep_of_indep_sets`: variant with two \u03c0-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 : \u03b9 \u2192 set (set \u03b1)`.\nThree other independence notions are defined using `Indep_sets`:\n* `Indep`: independence of a family of measurable space structures `m : \u03b9 \u2192 measurable_space \u03b1`,\n* `Indep_set`: independence of a family of sets `s : \u03b9 \u2192 set \u03b1`,\n* `Indep_fun`: independence of a family of functions. For measurable spaces\n  `m : \u03a0 (i : \u03b9), measurable_space (\u03b2 i)`, we consider functions `f : \u03a0 (i : \u03b9), \u03b1 \u2192 \u03b2 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 {\u03b1} {m\u2081 m\u2082 : measurable_space \u03b1} [measurable_space \u03b1] {\u03bc : measure \u03b1} ...` .\nThis is intentional, to be able to control the order of the `measurable_space` variables. Indeed\nwhen defining `\u03bc` in the example above, the measurable space used is the last one defined, here\n`[measurable_space \u03b1]`, and not `m\u2081` or `m\u2082`.\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 `\u03c0 : \u03b9 \u2192 set (set \u03b1)` is independent with respect to a measure `\u03bc` if\nfor any finite set of indices `s = {i_1, ..., i_n}`, for any sets\n`f i_1 \u2208 \u03c0 i_1, ..., f i_n \u2208 \u03c0 i_n`, then `\u03bc (\u22c2 i in s, f i) = \u220f i in s, \u03bc (f i) `.\nIt will be used for families of pi_systems. -/\ndef Indep_sets {\u03b1 : Type u_1} {\u03b9 : Type u_2} [measurable_space \u03b1] (\u03c0 : \u03b9 \u2192 set (set \u03b1)) (\u03bc : autoParam (measure_theory.measure \u03b1)\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  \u2200 (s : finset \u03b9) {f : \u03b9 \u2192 set \u03b1} (H : \u2200 (i : \u03b9), i \u2208 s \u2192 f i \u2208 \u03c0 i),\n    coe_fn \u03bc (set.Inter fun (i : \u03b9) => set.Inter fun (H : i \u2208 s) => f i) = finset.prod s fun (i : \u03b9) => coe_fn \u03bc (f i)\n\n/-- Two sets of sets `s\u2081, s\u2082` are independent with respect to a measure `\u03bc` if for any sets\n`t\u2081 \u2208 p\u2081, t\u2082 \u2208 s\u2082`, then `\u03bc (t\u2081 \u2229 t\u2082) = \u03bc (t\u2081) * \u03bc (t\u2082)` -/\ndef indep_sets {\u03b1 : Type u_1} [measurable_space \u03b1] (s1 : set (set \u03b1)) (s2 : set (set \u03b1)) (\u03bc : autoParam (measure_theory.measure \u03b1)\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  \u2200 (t1 t2 : set \u03b1), t1 \u2208 s1 \u2192 t2 \u2208 s2 \u2192 coe_fn \u03bc (t1 \u2229 t2) = coe_fn \u03bc t1 * coe_fn \u03bc t2\n\n/-- A family of measurable space structures (i.e. of \u03c3-algebras) is independent with respect to a\nmeasure `\u03bc` (typically defined on a finer \u03c3-algebra) if the family of sets of measurable sets they\ndefine is independent. `m : \u03b9 \u2192 measurable_space \u03b1` is independent with respect to measure `\u03bc` if\nfor any finite set of indices `s = {i_1, ..., i_n}`, for any sets\n`f i_1 \u2208 m i_1, ..., f i_n \u2208 m i_n`, then `\u03bc (\u22c2 i in s, f i) = \u220f i in s, \u03bc (f i) `. -/\ndef Indep {\u03b1 : Type u_1} {\u03b9 : Type u_2} (m : \u03b9 \u2192 measurable_space \u03b1) [measurable_space \u03b1] (\u03bc : autoParam (measure_theory.measure \u03b1)\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 : \u03b9) => measurable_space.is_measurable' (m x)\n\n/-- Two measurable space structures (or \u03c3-algebras) `m\u2081, m\u2082` are independent with respect to a\nmeasure `\u03bc` (defined on a third \u03c3-algebra) if for any sets `t\u2081 \u2208 m\u2081, t\u2082 \u2208 m\u2082`,\n`\u03bc (t\u2081 \u2229 t\u2082) = \u03bc (t\u2081) * \u03bc (t\u2082)` -/\ndef indep {\u03b1 : Type u_1} (m\u2081 : measurable_space \u03b1) (m\u2082 : measurable_space \u03b1) [measurable_space \u03b1] (\u03bc : autoParam (measure_theory.measure \u03b1)\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\u2081) (measurable_space.is_measurable' m\u2082)\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 `\u2205, s, s\u1d9c, univ`. -/\ndef Indep_set {\u03b1 : Type u_1} {\u03b9 : Type u_2} [measurable_space \u03b1] (s : \u03b9 \u2192 set \u03b1) (\u03bc : autoParam (measure_theory.measure \u03b1)\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 : \u03b9) => 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 `\u2205, s, s\u1d9c, univ`. -/\ndef indep_set {\u03b1 : Type u_1} [measurable_space \u03b1] {s : set \u03b1} {t : set \u03b1} (\u03bc : autoParam (measure_theory.measure \u03b1)\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 `\u03b1` 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 `\u03b1` 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 {\u03b1 : Type u_1} {\u03b9 : Type u_2} [measurable_space \u03b1] {\u03b2 : \u03b9 \u2192 Type u_3} (m : (x : \u03b9) \u2192 measurable_space (\u03b2 x)) (f : (x : \u03b9) \u2192 \u03b1 \u2192 \u03b2 x) (\u03bc : autoParam (measure_theory.measure \u03b1)\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 : \u03b9) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [measurable_space \u03b1] (m\u03b2 : measurable_space \u03b2) (m\u03b3 : measurable_space \u03b3) {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} (\u03bc : autoParam (measure_theory.measure \u03b1)\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\u03b2) (measurable_space.comap g m\u03b3)\n\ntheorem indep_sets.symm {\u03b1 : Type u_1} {s\u2081 : set (set \u03b1)} {s\u2082 : set (set \u03b1)} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} (h : indep_sets s\u2081 s\u2082) : indep_sets s\u2082 s\u2081 := sorry\n\ntheorem indep.symm {\u03b1 : Type u_1} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} (h : indep m\u2081 m\u2082) : indep m\u2082 m\u2081 :=\n  indep_sets.symm h\n\ntheorem indep_sets_of_indep_sets_of_le_left {\u03b1 : Type u_1} {s\u2081 : set (set \u03b1)} {s\u2082 : set (set \u03b1)} {s\u2083 : set (set \u03b1)} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} (h_indep : indep_sets s\u2081 s\u2082) (h31 : s\u2083 \u2286 s\u2081) : indep_sets s\u2083 s\u2082 :=\n  fun (t1 t2 : set \u03b1) (ht1 : t1 \u2208 s\u2083) (ht2 : t2 \u2208 s\u2082) => h_indep t1 t2 (set.mem_of_subset_of_mem h31 ht1) ht2\n\ntheorem indep_sets_of_indep_sets_of_le_right {\u03b1 : Type u_1} {s\u2081 : set (set \u03b1)} {s\u2082 : set (set \u03b1)} {s\u2083 : set (set \u03b1)} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} (h_indep : indep_sets s\u2081 s\u2082) (h32 : s\u2083 \u2286 s\u2082) : indep_sets s\u2081 s\u2083 :=\n  fun (t1 t2 : set \u03b1) (ht1 : t1 \u2208 s\u2081) (ht2 : t2 \u2208 s\u2083) => h_indep t1 t2 ht1 (set.mem_of_subset_of_mem h32 ht2)\n\ntheorem indep_of_indep_of_le_left {\u03b1 : Type u_1} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} {m\u2083 : measurable_space \u03b1} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} (h_indep : indep m\u2081 m\u2082) (h31 : m\u2083 \u2264 m\u2081) : indep m\u2083 m\u2082 :=\n  fun (t1 t2 : set \u03b1) (ht1 : t1 \u2208 measurable_space.is_measurable' m\u2083) (ht2 : t2 \u2208 measurable_space.is_measurable' m\u2082) =>\n    h_indep t1 t2 (h31 t1 ht1) ht2\n\ntheorem indep_of_indep_of_le_right {\u03b1 : Type u_1} {m\u2081 : measurable_space \u03b1} {m\u2082 : measurable_space \u03b1} {m\u2083 : measurable_space \u03b1} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} (h_indep : indep m\u2081 m\u2082) (h32 : m\u2083 \u2264 m\u2082) : indep m\u2081 m\u2083 :=\n  fun (t1 t2 : set \u03b1) (ht1 : t1 \u2208 measurable_space.is_measurable' m\u2081) (ht2 : t2 \u2208 measurable_space.is_measurable' m\u2083) =>\n    h_indep t1 t2 ht1 (h32 t2 ht2)\n\ntheorem indep_sets.union {\u03b1 : Type u_1} [measurable_space \u03b1] {s\u2081 : set (set \u03b1)} {s\u2082 : set (set \u03b1)} {s' : set (set \u03b1)} {\u03bc : measure_theory.measure \u03b1} (h\u2081 : indep_sets s\u2081 s') (h\u2082 : indep_sets s\u2082 s') : indep_sets (s\u2081 \u222a s\u2082) s' := sorry\n\n@[simp] theorem indep_sets.union_iff {\u03b1 : Type u_1} [measurable_space \u03b1] {s\u2081 : set (set \u03b1)} {s\u2082 : set (set \u03b1)} {s' : set (set \u03b1)} {\u03bc : measure_theory.measure \u03b1} : indep_sets (s\u2081 \u222a s\u2082) s' \u2194 indep_sets s\u2081 s' \u2227 indep_sets s\u2082 s' := sorry\n\ntheorem indep_sets.Union {\u03b1 : Type u_1} {\u03b9 : Sort u_2} [measurable_space \u03b1] {s : \u03b9 \u2192 set (set \u03b1)} {s' : set (set \u03b1)} {\u03bc : measure_theory.measure \u03b1} (hyp : \u2200 (n : \u03b9), indep_sets (s n) s') : indep_sets (set.Union fun (n : \u03b9) => s n) s' := sorry\n\ntheorem indep_sets.inter {\u03b1 : Type u_1} [measurable_space \u03b1] {s\u2081 : set (set \u03b1)} {s' : set (set \u03b1)} (s\u2082 : set (set \u03b1)) {\u03bc : measure_theory.measure \u03b1} (h\u2081 : indep_sets s\u2081 s') : indep_sets (s\u2081 \u2229 s\u2082) s' :=\n  fun (t1 t2 : set \u03b1) (ht1 : t1 \u2208 s\u2081 \u2229 s\u2082) (ht2 : t2 \u2208 s') =>\n    h\u2081 t1 t2 (and.left (iff.mp (set.mem_inter_iff t1 s\u2081 s\u2082) ht1)) ht2\n\ntheorem indep_sets.Inter {\u03b1 : Type u_1} {\u03b9 : Sort u_2} [measurable_space \u03b1] {s : \u03b9 \u2192 set (set \u03b1)} {s' : set (set \u03b1)} {\u03bc : measure_theory.measure \u03b1} (h : \u2203 (n : \u03b9), indep_sets (s n) s') : indep_sets (set.Inter fun (n : \u03b9) => s n) s' :=\n  id\n    fun (t1 t2 : set \u03b1) (ht1 : t1 \u2208 set.Inter fun (n : \u03b9) => s n) (ht2 : t2 \u2208 s') =>\n      Exists.dcases_on h fun (n : \u03b9) (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 {\u03b1 : Type u_1} {\u03b9 : Type u_2} {s : \u03b9 \u2192 set (set \u03b1)} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} (h_indep : Indep_sets s) {i : \u03b9} {j : \u03b9} (hij : i \u2260 j) : indep_sets (s i) (s j) := sorry\n\ntheorem Indep.indep {\u03b1 : Type u_1} {\u03b9 : Type u_2} {m : \u03b9 \u2192 measurable_space \u03b1} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} (h_indep : Indep m) {i : \u03b9} {j : \u03b9} (hij : i \u2260 j) : indep (m i) (m j) :=\n  id (Indep_sets.indep_sets h_indep hij)\n\n/-!\n## \u03c0-system lemma\n\nIndependence of measurable spaces is equivalent to independence of generating \u03c0-systems.\n-/\n\n/-! ### Independence of measurable space structures implies independence of generating \u03c0-systems -/\n\ntheorem Indep.Indep_sets {\u03b1 : Type u_1} {\u03b9 : Type u_2} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} {m : \u03b9 \u2192 measurable_space \u03b1} {s : \u03b9 \u2192 set (set \u03b1)} (hms : \u2200 (n : \u03b9), m n = measurable_space.generate_from (s n)) (h_indep : Indep m) : Indep_sets s := sorry\n\ntheorem indep.indep_sets {\u03b1 : Type u_1} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} {s1 : set (set \u03b1)} {s2 : set (set \u03b1)} (h_indep : indep (measurable_space.generate_from s1) (measurable_space.generate_from s2)) : indep_sets s1 s2 :=\n  fun (t1 t2 : set \u03b1) (ht1 : t1 \u2208 s1) (ht2 : t2 \u2208 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 \u03c0-systems implies independence of measurable space structures -/\n\ntheorem indep_sets.indep {\u03b1 : Type u_1} {m1 : measurable_space \u03b1} {m2 : measurable_space \u03b1} {m : measurable_space \u03b1} {\u03bc : measure_theory.measure \u03b1} [measure_theory.probability_measure \u03bc] {p1 : set (set \u03b1)} {p2 : set (set \u03b1)} (h1 : m1 \u2264 m) (h2 : m2 \u2264 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\u2081` for a T\u2081 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 \u2192 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 `\u221e` := infty\" in alexandroff\n\nnamespace alexandroff\n\ninstance : has_coe_t X (alexandroff X) := \u27e8of\u27e9\n\ninstance : inhabited(alexandroff X) := \u27e8\u221e\u27e9\n\n@[norm_cast] \nlemma coe_eq_coe {x y : X} : (x : alexandroff X) = y \u2194 x = y :=\nof_injective.eq_iff\n\n@[simp] lemma coe_ne_infty (x : X) : (x : alexandroff X) \u2260 \u221e  .\n@[simp] lemma infty_ne_coe (x : X) : \u221e \u2260 (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 `\u221e` and `\u2191x`. -/\n@[elab_as_eliminator]\ndef rec_infty_coe (C : alexandroff X \u2192 Sort*) (h\u2081 : C infty) (h\u2082 : \u03a0 (x : X), C x) :\n  \u03a0 (z : alexandroff X), C z :=\noption.rec h\u2081 h\u2082\n\nlemma ne_infty_iff_exists {x : alexandroff X} : \n  x \u2260 \u221e \u2194 \u2203 (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) \u2208 (range_of X) :=\nby simp [range_of]\n\nlemma union_infty_eq_univ : (range_of X \u222a {\u221e}) = univ :=\nbegin\n  refine le_antisymm (subset_univ _) (\u03bb x hx, _),\n  induction x using alexandroff.rec_infty_coe; simp\nend\n\n@[simp] lemma infty_not_mem_range_of : \u221e \u2209 range_of X :=\nby simp [range_of]\n\n@[simp] lemma not_mem_range_of_iff (x : alexandroff X) :\n  x \u2209 range_of X \u2194 x = \u221e :=\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} : \u221e \u2209 of '' s :=\nnot_mem_subset (image_subset _ $ subset_univ _) infty_not_mem_range_of\n\nlemma inter_infty_eq_empty : (range_of X) \u2229 {\u221e} = \u2205 :=\nby { ext x, induction x using alexandroff.rec_infty_coe; simp }\n\nlemma of_preimage_infty : (of\u207b\u00b9' {\u221e} : set X) = \u2205 :=\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 := \u03bb s, if \u221e \u2208 s then is_compact (of\u207b\u00b9' s)\u1d9c \u2227 is_open (of\u207b\u00b9' s)\n    else is_open (of\u207b\u00b9' s),\n  is_open_univ := by simp,\n  is_open_inter :=\n  \u03bb 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  \u03bb S ht, begin\n    suffices : is_open (of\u207b\u00b9' \u22c3\u2080S),\n    { split_ifs with h,\n      { obtain \u27e8(a : set (alexandroff X)), ha, ha'\u27e9 := mem_sUnion.mp h,\n        specialize ht a ha,\n        rw if_pos ha' at ht,\n        refine \u27e8compact_of_is_closed_subset ht.left this.is_closed_compl _, this\u27e9,\n        rw [compl_subset_compl, preimage_subset_iff],\n        intros y hy,\n        refine \u27e8a, ha, hy\u27e9 },\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 \u27e8of \u207b\u00b9' s, subset_subset_Union _ (subset_subset_Union hs (subset.refl _)), _,\n        mem_preimage.mpr hy\u27e9,\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 \u2194 if \u221e \u2208 s then is_compact (of\u207b\u00b9' s)\u1d9c \u2227 is_open (of\u207b\u00b9' s)\n  else is_open (of\u207b\u00b9' s) :=\niff.rfl\n\nlemma is_open_iff_of_mem' (h : \u221e \u2208 s) :\n  is_open s \u2194 is_compact (of\u207b\u00b9' s)\u1d9c \u2227 is_open (of\u207b\u00b9' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_iff_of_mem (h : \u221e \u2208 s) :\n  is_open s \u2194 is_compact (of\u207b\u00b9' s)\u1d9c \u2227 is_closed (of\u207b\u00b9' s)\u1d9c :=\nby simp [is_open_alexandroff_iff_aux, h, is_closed_compl_iff]\n\nlemma is_open_iff_of_not_mem (h : \u221e \u2209 s) :\n  is_open s \u2194 is_open (of\u207b\u00b9' s) :=\nby simp [is_open_alexandroff_iff_aux, h]\n\nlemma is_open_of_is_open (h : is_open s) :\n  is_open (of\u207b\u00b9' s) :=\nbegin\n  by_cases H : \u221e \u2208 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 (\u03bb 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 \u2227 is_closed s) :\n  topological_space.opens (alexandroff X) :=\n\u27e8(of '' s)\u1d9c, 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 }\u27e9\n\nlemma infty_mem_opens_of_compl {s : set X} (h : is_compact s \u2227 is_closed s) :\n  \u221e \u2208 (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\u03bb s hs, begin\n  rw [\u2190 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 (\u03bb \u03b9 Z h H, _),\n    simp only [univ_subset_iff] at H \u22a2,\n    rcases Union_eq_univ_iff.mp H \u221e with \u27e8K, hK\u27e9,\n    have minor\u2081 : is_compact (of\u207b\u00b9' Z K)\u1d9c,\n    { specialize h K, rw is_open_iff_of_mem hK at h, exact h.1 },\n    let p : \u03b9 \u2192 set X := \u03bb i, of\u207b\u00b9' Z i,\n    have minor\u2082 : \u2200 i, is_open (p i) := \u03bb i, is_open_of_is_open (h i),\n    have minor\u2083 : (of\u207b\u00b9' Z K)\u1d9c \u2286 \u22c3 i, p i :=\n      by simp only [p, \u2190 preimage_Union, H, preimage_univ, subset_univ],\n    rcases is_compact_iff_finite_subcover.mp minor\u2081 p minor\u2082 minor\u2083 with \u27e8\u03b9', H'\u27e9,\n    refine \u27e8insert K \u03b9', _\u27e9,\n    rw \u2190 preimage_compl at H',\n    simp only [Union_eq_univ_iff],\n    intros x,\n    by_cases hx : x \u2208 Z K,\n    { exact \u27e8K, mem_Union.mpr \u27e8finset.mem_insert_self _ _, hx\u27e9\u27e9 },\n    { have triv\u2081 : x \u2260 \u221e := (ne_of_mem_of_not_mem hK hx).symm,\n      rcases ne_infty_iff_exists.mp triv\u2081 with \u27e8y, hy\u27e9,\n      have triv\u2082 : (y : alexandroff X) \u2208 {x} := mem_singleton_of_eq hy.symm,\n      rw [\u2190 mem_compl_iff, \u2190 singleton_subset_iff] at hx,\n      have : of\u207b\u00b9' {x} \u2286 of\u207b\u00b9' (Z K)\u1d9c := \u03bb y hy, hx hy,\n      have key : y \u2208 \u22c3 (i : \u03b9) (H : i \u2208 \u03b9'), p i := this.trans H' (mem_preimage.mpr triv\u2082),\n      rcases mem_bUnion_iff'.mp key with \u27e8i, hi, hyi\u27e9,\n      refine \u27e8i, mem_Union.mpr \u27e8finset.subset_insert _ \u03b9' hi, _\u27e9\u27e9,\n      simpa [hy] using hyi }\n  end }\n\nlemma dense_range_of (h : \u00ac is_compact (univ : set X)) : dense (@range_of X _) :=\nbegin\n  refine dense_iff_inter_open.mpr (\u03bb s hs Hs, _),\n  by_cases H : \u221e \u2208 s,\n  { rw is_open_iff_of_mem H at hs,\n    have minor\u2081 : s \u2260 {\u221e},\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\u2082 : of\u207b\u00b9' s \u2260 \u2205,\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 : \u2200 z \u2208 s, z = \u221e := \u03bb z hz,\n        by_contra (\u03bb w', let \u27e8x, hx\u27e9 := ne_infty_iff_exists.mp w' in\n          by rw hx at hz; exact (w x) hz),\n      exact minor\u2081 (eq_singleton_iff_unique_mem.mpr \u27e8H, this\u27e9) },\n    rcases ne_empty_iff_nonempty.mp minor\u2082 with \u27e8x, hx\u27e9,\n    exact \u27e8of x, hx, x, mem_univ _, rfl\u27e9 },\n  { rcases Hs with \u27e8z, hz\u27e9,\n    rcases ne_infty_iff_exists.mp (ne_of_mem_of_not_mem hz H) with \u27e8x, hx\u27e9,\n    rw hx at hz,\n    exact \u27e8of x, hz, x, mem_univ _, rfl\u27e9 }\nend\n\nlemma connected_space_alexandroff [preconnected_space X] (h : \u00ac is_compact (univ : set X)) :\n  connected_space (alexandroff X) :=\n{ is_preconnected_univ :=\n  begin\n    rw \u2190 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 := \u27e8\u221e\u27e9 }\n\ninstance [t1_space X] : t1_space (alexandroff X) :=\n{ t1 :=\n  \u03bb z, begin\n    induction z using alexandroff.rec_infty_coe,\n    { rw [\u2190 is_open_compl_iff, compl_eq_univ_diff, \u2190 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 : \u221e \u2208 ({z}\u1d9c : set (alexandroff X)) :=\n        mem_compl (\u03bb w, (infty_ne_coe z) (mem_singleton_iff.mp w)),\n      rw [\u2190 is_open_compl_iff, is_open_iff_of_mem this],\n      rw [preimage_compl, compl_compl, \u2190 of_eq_coe, \n          \u2190 image_singleton, of_injective.preimage_image _],\n      exact \u27e8is_compact_singleton, is_closed_singleton\u27e9 }\n  end }\n\ninstance [locally_compact_space X] [t2_space X] : t2_space (alexandroff X) :=\n{ t2 :=\n  \u03bb x y hxy, begin\n    have key : \u2200 (z : alexandroff X), z \u2260 \u221e \u2192\n      \u2203 (u v : set (alexandroff X)), is_open u \u2227 is_open v \u2227 \u221e \u2208 u \u2227 z \u2208 v \u2227 u \u2229 v = \u2205 :=\n    \u03bb z h, begin\n      rcases ne_infty_iff_exists.mp h with \u27e8y', hy'\u27e9,\n      rcases exists_open_with_compact_closure y' with \u27e8u, hu, huy', Hu\u27e9,\n      have minor\u2081 : _ \u2227 is_closed (closure u) := \u27e8Hu, is_closed_closure\u27e9,\n      refine \u27e8opens_of_compl minor\u2081, of '' u, _\u27e9,\n      refine \u27e8(opens_of_compl minor\u2081).2, is_open_map_of _ hu,\n        infty_mem_opens_of_compl minor\u2081, \u27e8y', huy', hy'.symm\u27e9, _\u27e9,\n      simp only [opens_of_compl, topological_space.opens.coe_mk],\n      have minor\u2082 : (of '' closure u)\u1d9c \u2229 of '' u \u2286 (of '' u)\u1d9c \u2229 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\u2082,\n      exact eq_empty_of_subset_empty minor\u2082\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 \u27e8u, v, hu, hv, hxu, hyv, huv\u27e9,\n      exact \u27e8v, u, hv, hu, hyv, hxu, (inter_comm u v) \u25b8 huv\u27e9 },\n    { have hxy' : x \u2260 y := \u03bb w, hxy (coe_eq_coe.mpr w),\n      rcases t2_separation hxy' with \u27e8u, v, hu, hv, hxu, hyv, huv\u27e9,\n      refine \u27e8of '' u, of '' v, is_open_map_of _ hu, is_open_map_of _ hv,\n        \u27e8x, hxu, rfl\u27e9, \u27e8y, hyv, rfl\u27e9, _\u27e9,\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 + \u221e = \u221e :=\nwith_top.add_top\n\n@[simp] lemma infty_add [has_add X] {x : (alexandroff X)} : \u221e + x = \u221e :=\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 \u27f6 Y) (e : C \u224c 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 \u2227 q \u2227 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} (\ud835\udfed T) (\ud835\udfed 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 (\ud835\udfed T) (\ud835\udfed 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 (\ud835\udfd9 f) = \ud835\udfd9 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 (\ud835\udfd9 f) = \ud835\udfd9 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 \u27f6 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 \u27f6 B) \u2192 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 \u27f6 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 \u27f6 g.left} {v : f.right \u27f6 g.right}\n    (w : u \u226b g.hom = f.hom \u226b v) : f \u27f6 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 \u27f6 Y} {P Q : T} {g : P \u27f6 Q} {u : X \u27f6 P} {v : Y \u27f6 Q} (w : u \u226b g = f \u226b v) :\n    Arrow.mk f \u27f6 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 \u27f6 g) : sq.left \u226b g.hom = f.hom \u226b 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 \u27f6 Y} (sq : f \u27f6 mk g) :\n    sq.left \u226b g = f.hom \u226b 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 \u27f6 g) [IsIso ff.left]\n    [IsIso ff.right] : IsIso ff where\n  out := by\n    let inverse : g \u27f6 f := \u27e8inv ff.left, inv ff.right, (by simp)\u27e9\n    apply Exists.intro inverse\n    constructor\n    \u00b7 apply CommaMorphism.ext\n      \u00b7 rw [Comma.comp_left, IsIso.hom_inv_id, \u2190Comma.id_left]\n      \u00b7 rw [Comma.comp_right, IsIso.hom_inv_id, \u2190Comma.id_right]\n    \u00b7 apply CommaMorphism.ext\n      \u00b7 rw [Comma.comp_left, IsIso.inv_hom_id, \u2190Comma.id_left]\n      \u00b7 rw [Comma.comp_right, IsIso.inv_hom_id, \u2190Comma.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 \u2245 g.left) (r : f.right \u2245 g.right)\n    (h : l.hom \u226b g.hom = f.hom \u226b r.hom) : f \u2245 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 \u27f6 X) (g : Y \u27f6 Z) (e\u2081 : W \u2245 Y) (e\u2082 : X \u2245 Z)\n    (h : e\u2081.hom \u226b g = f \u226b e\u2082.hom) : Arrow.mk f \u2245 Arrow.mk g :=\n  Arrow.isoMk e\u2081 e\u2082 h\n#align category_theory.arrow.iso_mk' CategoryTheory.Arrow.isoMk'\n\ntheorem hom.congr_left {f g : Arrow T} {\u03c6\u2081 \u03c6\u2082 : f \u27f6 g} (h : \u03c6\u2081 = \u03c6\u2082) : \u03c6\u2081.left = \u03c6\u2082.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} {\u03c6\u2081 \u03c6\u2082 : f \u27f6 g} (h : \u03c6\u2081 = \u03c6\u2082) : \u03c6\u2081.right = \u03c6\u2082.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 \u2245 g) : g.hom = e.inv.left \u226b f.hom \u226b e.hom.right := by\n  have eq := Arrow.hom.congr_right e.inv_hom_id\n  dsimp at eq\n  erw [Arrow.w_assoc, \u2190Comma.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 \u27f6 X} {g : Y \u27f6 Z} (e : Arrow.mk f \u2245 Arrow.mk g) :\n    g = e.inv.left \u226b f \u226b 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 \u27f6 g)\n\ninstance isIso_left [IsIso sq] : IsIso sq.left where\n  out := by\n    apply Exists.intro (inv sq).left\n    simp only [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 \u226b g.hom \u226b inv sq.right = f.hom := by\n  simp only [\u2190 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 \u226b f.hom \u226b 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} \u03c6 \u03c8 h := by\n    let aux : (Z \u27f6 f.left) \u2192 (Arrow.mk (\ud835\udfd9 Z) \u27f6 f) := fun \u03c6 =>\n      { left := \u03c6\n        right := \u03c6 \u226b f.hom }\n    have : \u2200 g, (aux g).right = g \u226b f.hom := fun g => by dsimp\n    show (aux \u03c6).left = (aux \u03c8).left\n    congr 1\n    rw [\u2190 cancel_mono sq]\n    apply CommaMorphism.ext\n    \u00b7 exact h\n    \u00b7 rw [Comma.comp_right, Comma.comp_right, this, this, Category.assoc, Category.assoc]\n      rw [\u2190Arrow.w]\n      simp only [\u2190 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} \u03c6 \u03c8 h := by\n    let aux : (g.right \u27f6 Z) \u2192 (g \u27f6 Arrow.mk (\ud835\udfd9 Z)) := fun \u03c6 =>\n      { right := \u03c6\n        left := g.hom \u226b \u03c6 }\n    show (aux \u03c6).right = (aux \u03c8).right\n    congr 1\n    rw [\u2190 cancel_epi sq]\n    apply CommaMorphism.ext\n    \u00b7 rw [Comma.comp_left, Comma.comp_left, Arrow.w_assoc, Arrow.w_assoc, h]\n    \u00b7 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 \u2245 Y) (sq : i \u27f6 Arrow.mk p.hom) :\n    i.hom \u226b sq.right \u226b 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 \u2245 Y) (p : Arrow T) (sq : Arrow.mk i.hom \u27f6 p) :\n    i.inv \u226b sq.left \u226b 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 \u226b g`, produce a square between\n`i` and `g`, whose top leg uses `f`:\nA  \u2192 X\n     \u2193f\n\u2193i   Y             --> A \u2192 Y\n     \u2193g                \u2193i  \u2193g\nB  \u2192 Z                 B \u2192 Z\n -/\n@[simps]\ndef squareToSnd {X Y Z : C} {i : Arrow C} {f : X \u27f6 Y} {g : Y \u27f6 Z} (sq : i \u27f6 Arrow.mk (f \u226b g)) :\n    i \u27f6 Arrow.mk g where\n  left := sq.left \u226b 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 \u2964 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 \u2964 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 \u2964 C) \u27f6 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\u2081 v\u2082 u\u2081 u\u2082\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} D]\n\n/-- A functor `C \u2964 D` induces a functor between the corresponding arrow categories. -/\n@[simps]\ndef mapArrow (F : C \u2964 D) : Arrow C \u2964 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 [\u2190 F.map_comp, w] }\n  map_id := by aesop_cat\n  map_comp := fun f g => by\n    apply CommaMorphism.ext\n    \u00b7 dsimp; rw [Comma.comp_left,F.map_comp]; rw [Comma.comp_left]\n    \u00b7 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 \u2964 D` are\nisomorphic arrows in `D`. -/\ndef Arrow.isoOfNatIso {C D : Type _} [Category C] [Category D] {F G : C \u2964 D} (e : F \u2245 G)\n    (f : Arrow C) : F.mapArrow.obj f \u2245 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 \u2192 P (e \u226b f)` and\n  `P f \u2192 P (f \u226b e)`, where `e` is an isomorphism.\n* `ring_hom.stable_under_composition`: `P` is stable under composition if `P f \u2192 P g \u2192 P (f \u226b g)`.\n* `ring_hom.stable_under_base_change`: `P` is stable under base change if `P (S \u27f6 Y)`\n  implies `P (X \u27f6 X \u2297[S] Y)`.\n\n-/\n\nuniverse u\n\nopen category_theory opposite category_theory.limits\n\nnamespace ring_hom\n\nvariable (P : \u2200 {R S : Type u} [comm_ring R] [comm_ring S] (f : by exactI R \u2192+* 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(\u2200 {R S T : Type u} [comm_ring R] [comm_ring S] [comm_ring T], by exactI\n    \u2200 (f : R \u2192+* S) (e : S \u2243+* T) (hf : P f), P (e.to_ring_hom.comp f)) \u2227\n  (\u2200 {R S T : Type u} [comm_ring R] [comm_ring S] [comm_ring T], by exactI\n    \u2200 (f : S \u2192+* T) (e : R \u2243+* 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 \u27f6 S) (g : S \u27f6 T)\n  [is_iso f] : P (f \u226b g) \u2194 P g :=\n\u27e8\u03bb H, by { convert hP.2 (f \u226b 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\u27e9\n\nlemma respects_iso.cancel_right_is_iso (hP : respects_iso @P) {R S T : CommRing}\n  (f : R \u27f6 S) (g : S \u27f6 T)\n  [is_iso g] : P (f \u226b g) \u2194 P f :=\n\u27e8\u03bb H, by { convert hP.1 (f \u226b g) (as_iso g).symm.CommRing_iso_to_ring_equiv H,\n  change f = f \u226b g \u226b (inv g), simp }, hP.1 f (as_iso g).CommRing_iso_to_ring_equiv\u27e9\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 \u2192+* S) (r : R) [is_localization.away r R'] [is_localization.away (f r) S'] :\n  P (localization.away_map f r) \u2194 P (is_localization.away.map R' S' f r) :=\nbegin\n  let e\u2081 : R' \u2243+* localization.away r :=\n    (is_localization.alg_equiv (submonoid.powers r) _ _).to_ring_equiv,\n  let e\u2082 : localization.away (f r) \u2243+* S' :=\n    (is_localization.alg_equiv (submonoid.powers (f r)) _ _).to_ring_equiv,\n  refine (hP.cancel_left_is_iso e\u2081.to_CommRing_iso.hom (CommRing.of_hom _)).symm.trans _,\n  refine (hP.cancel_right_is_iso (CommRing.of_hom _) e\u2082.to_CommRing_iso.hom).symm.trans _,\n  rw \u2190 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\u2081 e\u2082,\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  \u2200 \u2983R S T\u2984 [comm_ring R] [comm_ring S] [comm_ring T],\n    by exactI \u2200 (f : R \u2192+* S) (g : S \u2192+* 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' : \u2200 {R S : Type*} [comm_ring R] [comm_ring S] (e : by exactI R \u2243+* 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 \u2192+* A)` implies\n`P(B \u2192+* A \u2297[S] B)`. -/\ndef stable_under_base_change : Prop :=\n  \u2200 (R S R' S') [comm_ring R] [comm_ring S] [comm_ring R'] [comm_ring S'],\n    by exactI \u2200 [algebra R S] [algebra R R'] [algebra R S'] [algebra S S'] [algebra R' S'],\n    by exactI \u2200 [is_scalar_tower R S S'] [is_scalar_tower R R' S'],\n    by exactI \u2200 [algebra.is_pushout R S R' S'], P (algebra_map R S) \u2192 P (algebra_map R' S')\n\nlemma stable_under_base_change.mk\n  (h\u2081 : respects_iso @P)\n  (h\u2082 : \u2200 \u2983R S T\u2984 [comm_ring R] [comm_ring S] [comm_ring T],\n    by exactI \u2200 [algebra R S] [algebra R T], by exactI (P (algebra_map R T) \u2192\n      P (algebra.tensor_product.include_left.to_ring_hom : S \u2192+* 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 : \u2200 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\u2081.1 _ _ (h\u2082 H : P (_ : R' \u2192+* _)),\n  swap,\n  { refine { map_mul' := \u03bb 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 \u2297\u209c[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 \u27f6 S) (g : R \u27f6 T) (H : P g) : P (pushout.inl : S \u27f6 pushout f g) :=\nbegin\n  rw [\u2190 (show _ = pushout.inl, from colimit.iso_colimit_cocone_\u03b9_inv\n    \u27e8_, CommRing.pushout_cocone_is_colimit f g\u27e9 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.\u03b9_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 {\u03b1 \u03b2 \u03b3 : Type _}\n\n/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_mem[has_mem] (list[list] \u03b1) -/\n/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_singleton[has_singleton] (list[list] \u03b1) -/\n/- ./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_insert[has_insert] (list[list] \u03b1) -/\n#print Language /-\n/-- A language is a set of strings over an alphabet. -/\ndef Language (\u03b1) :=\n  Set (List \u03b1)deriving\n  \u00ab./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_mem[has_mem] (list[list] \u03b1)\u00bb,\n  \u00ab./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_singleton[has_singleton] (list[list] \u03b1)\u00bb,\n  \u00ab./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler has_insert[has_insert] (list[list] \u03b1)\u00bb,\n  CompleteBooleanAlgebra\n#align language Language\n-/\n\nnamespace Language\n\nvariable {l m : Language \u03b1} {a b x : List \u03b1}\n\nattribute [local reducible] Language\n\n/-- Zero language has no elements. -/\ninstance : Zero (Language \u03b1) :=\n  \u27e8(\u2205 : Set _)\u27e9\n\n/-- `1 : language \u03b1` contains only one element `[]`. -/\ninstance : One (Language \u03b1) :=\n  \u27e8{[]}\u27e9\n\ninstance : Inhabited (Language \u03b1) :=\n  \u27e80\u27e9\n\n/-- The sum of two languages is their union. -/\ninstance : Add (Language \u03b1) :=\n  \u27e8(\u00b7 \u222a \u00b7)\u27e9\n\n/-- The product of two languages `l` and `m` is the language made of the strings `x ++ y` where\n`x \u2208 l` and `y \u2208 m`. -/\ninstance : Mul (Language \u03b1) :=\n  \u27e8image2 (\u00b7 ++ \u00b7)\u27e9\n\n#print Language.zero_def /-\ntheorem zero_def : (0 : Language \u03b1) = (\u2205 : Set _) :=\n  rfl\n#align language.zero_def Language.zero_def\n-/\n\n#print Language.one_def /-\ntheorem one_def : (1 : Language \u03b1) = {[]} :=\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 {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1) (m : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.hasAdd.{u1} \u03b1)) l m) (Union.union.{u1} (Language.{u1} \u03b1) (Set.hasUnion.{u1} (List.{u1} \u03b1)) l m)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1) (m : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) l m) (Union.union.{u1} (Set.{u1} (List.{u1} \u03b1)) (Set.instUnionSet.{u1} (List.{u1} \u03b1)) l m)\nCase conversion may be inaccurate. Consider using '#align language.add_def Language.add_def\u2093'. -/\ntheorem add_def (l m : Language \u03b1) : l + m = l \u222a m :=\n  rfl\n#align language.add_def Language.add_def\n\n#print Language.mul_def /-\ntheorem mul_def (l m : Language \u03b1) : l * m = image2 (\u00b7 ++ \u00b7) 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 \u03b1) :=\n  \u27e8fun l => { x | \u2203 L : List (List \u03b1), x = L.join \u2227 \u2200 y \u2208 L, y \u2208 l }\u27e9\n\n#print Language.kstar_def /-\ntheorem kstar_def (l : Language \u03b1) :\n    l\u2217 = { x | \u2203 L : List (List \u03b1), x = L.join \u2227 \u2200 y \u2208 L, y \u2208 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 \u03b1) : x \u2209 (0 : Language \u03b1) :=\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 \u03b1) : x \u2208 (1 : Language \u03b1) \u2194 x = [] := by rfl\n#align language.mem_one Language.mem_one\n-/\n\n#print Language.nil_mem_one /-\ntheorem nil_mem_one : [] \u2208 (1 : Language \u03b1) :=\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 {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1) (m : Language.{u1} \u03b1) (x : List.{u1} \u03b1), Iff (Membership.Mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (Language.hasMem.{u1} \u03b1) x (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.hasAdd.{u1} \u03b1)) l m)) (Or (Membership.Mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (Language.hasMem.{u1} \u03b1) x l) (Membership.Mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (Language.hasMem.{u1} \u03b1) x m))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1) (m : Language.{u1} \u03b1) (x : List.{u1} \u03b1), Iff (Membership.mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (instMembershipListLanguage.{u1} \u03b1) x (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) l m)) (Or (Membership.mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (instMembershipListLanguage.{u1} \u03b1) x l) (Membership.mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (instMembershipListLanguage.{u1} \u03b1) x m))\nCase conversion may be inaccurate. Consider using '#align language.mem_add Language.mem_add\u2093'. -/\ntheorem mem_add (l m : Language \u03b1) (x : List \u03b1) : x \u2208 l + m \u2194 x \u2208 l \u2228 x \u2208 m :=\n  Iff.rfl\n#align language.mem_add Language.mem_add\n\n#print Language.mem_mul /-\ntheorem mem_mul : x \u2208 l * m \u2194 \u2203 a b, a \u2208 l \u2227 b \u2208 m \u2227 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 \u2208 l \u2192 b \u2208 m \u2192 a ++ b \u2208 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 \u2208 l\u2217 \u2194 \u2203 L : List (List \u03b1), x = L.join \u2227 \u2200 y \u2208 L, y \u2208 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 \u03b1)} (h : \u2200 y \u2208 L, y \u2208 l) : L.join \u2208 l\u2217 :=\n  \u27e8L, rfl, h\u27e9\n#align language.join_mem_kstar Language.join_mem_kstar\n-/\n\n#print Language.nil_mem_kstar /-\ntheorem nil_mem_kstar (l : Language \u03b1) : [] \u2208 l\u2217 :=\n  \u27e8[], rfl, fun _ => False.elim\u27e9\n#align language.nil_mem_kstar Language.nil_mem_kstar\n-/\n\ninstance : Semiring (Language \u03b1) where\n  add := (\u00b7 + \u00b7)\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 := (\u00b7 * \u00b7)\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 {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.hasAdd.{u1} \u03b1)) l l) l\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) l l) l\nCase conversion may be inaccurate. Consider using '#align language.add_self Language.add_self\u2093'. -/\n@[simp]\ntheorem add_self (l : Language \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}}, (\u03b1 -> \u03b2) -> (RingHom.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}}, (\u03b1 -> \u03b2) -> (RingHom.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.instSemiringLanguage.{u2} \u03b2)))\nCase conversion may be inaccurate. Consider using '#align language.map Language.map\u2093'. -/\n/-- Maps the alphabet of a language. -/\ndef map (f : \u03b1 \u2192 \u03b2) : Language \u03b1 \u2192+* Language \u03b2\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 {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (coeFn.{succ u1, succ u1} (RingHom.{u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1))) (fun (_x : RingHom.{u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1))) => (Language.{u1} \u03b1) -> (Language.{u1} \u03b1)) (RingHom.hasCoeToFun.{u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1))) (Language.map.{u1, u1} \u03b1 \u03b1 (id.{succ u1} \u03b1)) l) l\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u1} \u03b1) => Language.{u1} \u03b1) l) (FunLike.coe.{succ u1, succ u1, succ u1} (RingHom.{u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1))) (Language.{u1} \u03b1) (fun (_x : Language.{u1} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u1} \u03b1) => Language.{u1} \u03b1) _x) (MulHomClass.toFunLike.{u1, u1, u1} (RingHom.{u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1))) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} \u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} \u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)))) (NonUnitalRingHomClass.toMulHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1))) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1))) (RingHomClass.toNonUnitalRingHomClass.{u1, u1, u1} (RingHom.{u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1))) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)) (RingHom.instRingHomClassRingHom.{u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1)))))) (Language.map.{u1, u1} \u03b1 \u03b1 (id.{succ u1} \u03b1)) l) l\nCase conversion may be inaccurate. Consider using '#align language.map_id Language.map_id\u2093'. -/\n@[simp]\ntheorem map_id (l : Language \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} (g : \u03b2 -> \u03b3) (f : \u03b1 -> \u03b2) (l : Language.{u1} \u03b1), Eq.{succ u3} (Language.{u3} \u03b3) (coeFn.{max (succ u2) (succ u3), max (succ u2) (succ u3)} (RingHom.{u2, u3} (Language.{u2} \u03b2) (Language.{u3} \u03b3) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b3) (Language.semiring.{u3} \u03b3))) (fun (_x : RingHom.{u2, u3} (Language.{u2} \u03b2) (Language.{u3} \u03b3) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b3) (Language.semiring.{u3} \u03b3))) => (Language.{u2} \u03b2) -> (Language.{u3} \u03b3)) (RingHom.hasCoeToFun.{u2, u3} (Language.{u2} \u03b2) (Language.{u3} \u03b3) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b3) (Language.semiring.{u3} \u03b3))) (Language.map.{u2, u3} \u03b2 \u03b3 g) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) (fun (_x : RingHom.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) => (Language.{u1} \u03b1) -> (Language.{u2} \u03b2)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) (Language.map.{u1, u2} \u03b1 \u03b2 f) l)) (coeFn.{max (succ u1) (succ u3), max (succ u1) (succ u3)} (RingHom.{u1, u3} (Language.{u1} \u03b1) (Language.{u3} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b3) (Language.semiring.{u3} \u03b3))) (fun (_x : RingHom.{u1, u3} (Language.{u1} \u03b1) (Language.{u3} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b3) (Language.semiring.{u3} \u03b3))) => (Language.{u1} \u03b1) -> (Language.{u3} \u03b3)) (RingHom.hasCoeToFun.{u1, u3} (Language.{u1} \u03b1) (Language.{u3} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b3) (Language.semiring.{u3} \u03b3))) (Language.map.{u1, u3} \u03b1 \u03b3 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 g f)) l)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} (g : \u03b2 -> \u03b3) (f : \u03b1 -> \u03b2) (l : Language.{u3} \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u1} \u03b2) => Language.{u2} \u03b3) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (RingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u3} \u03b1) (fun (a : Language.{u3} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u3} \u03b1) => Language.{u1} \u03b2) a) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u3} \u03b1) (Language.{u1} \u03b2) (NonUnitalNonAssocSemiring.toMul.{u3} (Language.{u3} \u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))) (NonUnitalRingHomClass.toMulHomClass.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u3} \u03b1) (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (RingHomClass.toNonUnitalRingHomClass.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (RingHom.instRingHomClassRingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))))) (Language.map.{u3, u1} \u03b1 \u03b2 f) l)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (RingHom.{u1, u2} (Language.{u1} \u03b2) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (Language.{u1} \u03b2) (fun (_x : Language.{u1} \u03b2) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u1} \u03b2) => Language.{u2} \u03b3) _x) (MulHomClass.toFunLike.{max u1 u2, u1, u2} (RingHom.{u1, u2} (Language.{u1} \u03b2) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (Language.{u1} \u03b2) (Language.{u2} \u03b3) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} \u03b3) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3)))) (NonUnitalRingHomClass.toMulHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} (Language.{u1} \u03b2) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (Language.{u1} \u03b2) (Language.{u2} \u03b3) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (RingHomClass.toNonUnitalRingHomClass.{max u1 u2, u1, u2} (RingHom.{u1, u2} (Language.{u1} \u03b2) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (Language.{u1} \u03b2) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3)) (RingHom.instRingHomClassRingHom.{u1, u2} (Language.{u1} \u03b2) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3)))))) (Language.map.{u1, u2} \u03b2 \u03b3 g) (FunLike.coe.{max (succ u3) (succ u1), succ u3, succ u1} (RingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u3} \u03b1) (fun (_x : Language.{u3} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u3} \u03b1) => Language.{u1} \u03b2) _x) (MulHomClass.toFunLike.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u3} \u03b1) (Language.{u1} \u03b2) (NonUnitalNonAssocSemiring.toMul.{u3} (Language.{u3} \u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))) (NonUnitalRingHomClass.toMulHomClass.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u3} \u03b1) (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (RingHomClass.toNonUnitalRingHomClass.{max u3 u1, u3, u1} (RingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (RingHom.instRingHomClassRingHom.{u3, u1} (Language.{u3} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))))) (Language.map.{u3, u1} \u03b1 \u03b2 f) l)) (FunLike.coe.{max (succ u3) (succ u2), succ u3, succ u2} (RingHom.{u3, u2} (Language.{u3} \u03b1) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (Language.{u3} \u03b1) (fun (_x : Language.{u3} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u3} \u03b1) => Language.{u2} \u03b3) _x) (MulHomClass.toFunLike.{max u3 u2, u3, u2} (RingHom.{u3, u2} (Language.{u3} \u03b1) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (Language.{u3} \u03b1) (Language.{u2} \u03b3) (NonUnitalNonAssocSemiring.toMul.{u3} (Language.{u3} \u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)))) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} \u03b3) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3)))) (NonUnitalRingHomClass.toMulHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} (Language.{u3} \u03b1) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (Language.{u3} \u03b1) (Language.{u2} \u03b3) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (RingHomClass.toNonUnitalRingHomClass.{max u3 u2, u3, u2} (RingHom.{u3, u2} (Language.{u3} \u03b1) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3))) (Language.{u3} \u03b1) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3)) (RingHom.instRingHomClassRingHom.{u3, u2} (Language.{u3} \u03b1) (Language.{u2} \u03b3) (Semiring.toNonAssocSemiring.{u3} (Language.{u3} \u03b1) (Language.instSemiringLanguage.{u3} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b3) (Language.instSemiringLanguage.{u2} \u03b3)))))) (Language.map.{u3, u2} \u03b1 \u03b3 (Function.comp.{succ u3, succ u1, succ u2} \u03b1 \u03b2 \u03b3 g f)) l)\nCase conversion may be inaccurate. Consider using '#align language.map_map Language.map_map\u2093'. -/\n@[simp]\ntheorem map_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) (l : Language \u03b1) : map g (map f l) = map (g \u2218 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 \u03b1) :\n    l\u2217 = { x | \u2203 S : List (List \u03b1), x = S.join \u2227 \u2200 y \u2208 S, y \u2208 l \u2227 y \u2260 [] } :=\n  by\n  ext x\n  constructor\n  \u00b7 rintro \u27e8S, rfl, h\u27e9\n    refine' \u27e8S.filter fun l => \u00acList.isEmpty l, by simp, fun y hy => _\u27e9\n    rw [mem_filter, empty_iff_eq_nil] at hy\n    exact \u27e8h y hy.1, hy.2\u27e9\n  \u00b7 rintro \u27e8S, hx, h\u27e9\n    exact \u27e8S, hx, fun y hy => (h y hy).1\u27e9\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 {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1) (m : Language.{u1} \u03b1), Iff (LE.le.{u1} (Language.{u1} \u03b1) (Set.hasLe.{u1} (List.{u1} \u03b1)) l m) (Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.hasAdd.{u1} \u03b1)) l m) m)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1) (m : Language.{u1} \u03b1), Iff (LE.le.{u1} (Language.{u1} \u03b1) (Preorder.toLE.{u1} (Language.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Language.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Language.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Language.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Language.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)))))))) l m) (Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) l m) m)\nCase conversion may be inaccurate. Consider using '#align language.le_iff Language.le_iff\u2093'. -/\ntheorem le_iff (l m : Language \u03b1) : l \u2264 m \u2194 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\u2081 l\u2082 m\u2081 m\u2082 : Language \u03b1} : l\u2081 \u2264 m\u2081 \u2192 l\u2082 \u2264 m\u2082 \u2192 l\u2081 * l\u2082 \u2264 m\u2081 * m\u2082 :=\n  by\n  intro h\u2081 h\u2082 x hx\n  simp only [mul_def, exists_and_left, mem_image2, image_prod] at hx\u22a2\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 {\u03b1 : Type.{u1}} {l\u2081 : Language.{u1} \u03b1} {l\u2082 : Language.{u1} \u03b1} {m\u2081 : Language.{u1} \u03b1} {m\u2082 : Language.{u1} \u03b1}, (LE.le.{u1} (Language.{u1} \u03b1) (Set.hasLe.{u1} (List.{u1} \u03b1)) l\u2081 m\u2081) -> (LE.le.{u1} (Language.{u1} \u03b1) (Set.hasLe.{u1} (List.{u1} \u03b1)) l\u2082 m\u2082) -> (LE.le.{u1} (Language.{u1} \u03b1) (Set.hasLe.{u1} (List.{u1} \u03b1)) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.hasAdd.{u1} \u03b1)) l\u2081 l\u2082) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.hasAdd.{u1} \u03b1)) m\u2081 m\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {l\u2081 : Language.{u1} \u03b1} {l\u2082 : Language.{u1} \u03b1} {m\u2081 : Language.{u1} \u03b1} {m\u2082 : Language.{u1} \u03b1}, (LE.le.{u1} (Language.{u1} \u03b1) (Preorder.toLE.{u1} (Language.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Language.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Language.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Language.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Language.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)))))))) l\u2081 m\u2081) -> (LE.le.{u1} (Language.{u1} \u03b1) (Preorder.toLE.{u1} (Language.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Language.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Language.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Language.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Language.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)))))))) l\u2082 m\u2082) -> (LE.le.{u1} (Language.{u1} \u03b1) (Preorder.toLE.{u1} (Language.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Language.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Language.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Language.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Language.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)))))))) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) l\u2081 l\u2082) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) m\u2081 m\u2082))\nCase conversion may be inaccurate. Consider using '#align language.le_add_congr Language.le_add_congr\u2093'. -/\ntheorem le_add_congr {l\u2081 l\u2082 m\u2081 m\u2082 : Language \u03b1} : l\u2081 \u2264 m\u2081 \u2192 l\u2082 \u2264 m\u2082 \u2192 l\u2081 + l\u2082 \u2264 m\u2081 + m\u2082 :=\n  sup_le_sup\n#align language.le_add_congr Language.le_add_congr\n\n/- warning: language.mem_supr -> Language.mem_sup\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} {l : \u03b9 -> (Language.{u2} \u03b1)} {x : List.{u2} \u03b1}, Iff (Membership.Mem.{u2, u2} (List.{u2} \u03b1) (Language.{u2} \u03b1) (Language.hasMem.{u2} \u03b1) x (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => l i))) (Exists.{u1} \u03b9 (fun (i : \u03b9) => Membership.Mem.{u2, u2} (List.{u2} \u03b1) (Language.{u2} \u03b1) (Language.hasMem.{u2} \u03b1) x (l i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} {l : \u03b9 -> (Language.{u1} \u03b1)} {x : List.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (instMembershipListLanguage.{u1} \u03b1) x (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => l i))) (Exists.{u2} \u03b9 (fun (i : \u03b9) => Membership.mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (instMembershipListLanguage.{u1} \u03b1) x (l i)))\nCase conversion may be inaccurate. Consider using '#align language.mem_supr Language.mem_sup\u1d62\u2093'. -/\ntheorem mem_sup\u1d62 {\u03b9 : Sort v} {l : \u03b9 \u2192 Language \u03b1} {x : List \u03b1} : (x \u2208 \u2a06 i, l i) \u2194 \u2203 i, x \u2208 l i :=\n  mem_union\u1d62\n#align language.mem_supr Language.mem_sup\u1d62\n\n/- warning: language.supr_mul -> Language.sup\u1d62_mul is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} (l : \u03b9 -> (Language.{u2} \u03b1)) (m : Language.{u2} \u03b1), Eq.{succ u2} (Language.{u2} \u03b1) (HMul.hMul.{u2, u2, u2} (Language.{u2} \u03b1) (Language.{u2} \u03b1) (Language.{u2} \u03b1) (instHMul.{u2} (Language.{u2} \u03b1) (Language.hasMul.{u2} \u03b1)) (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => l i)) m) (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => HMul.hMul.{u2, u2, u2} (Language.{u2} \u03b1) (Language.{u2} \u03b1) (Language.{u2} \u03b1) (instHMul.{u2} (Language.{u2} \u03b1) (Language.hasMul.{u2} \u03b1)) (l i) m))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} (l : \u03b9 -> (Language.{u1} \u03b1)) (m : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHMul.{u1} (Language.{u1} \u03b1) (Language.instMulLanguage.{u1} \u03b1)) (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => l i)) m) (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => HMul.hMul.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHMul.{u1} (Language.{u1} \u03b1) (Language.instMulLanguage.{u1} \u03b1)) (l i) m))\nCase conversion may be inaccurate. Consider using '#align language.supr_mul Language.sup\u1d62_mul\u2093'. -/\ntheorem sup\u1d62_mul {\u03b9 : Sort v} (l : \u03b9 \u2192 Language \u03b1) (m : Language \u03b1) :\n    (\u2a06 i, l i) * m = \u2a06 i, l i * m :=\n  image2_union\u1d62_left _ _ _\n#align language.supr_mul Language.sup\u1d62_mul\n\n/- warning: language.mul_supr -> Language.mul_sup\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} (l : \u03b9 -> (Language.{u2} \u03b1)) (m : Language.{u2} \u03b1), Eq.{succ u2} (Language.{u2} \u03b1) (HMul.hMul.{u2, u2, u2} (Language.{u2} \u03b1) (Language.{u2} \u03b1) (Language.{u2} \u03b1) (instHMul.{u2} (Language.{u2} \u03b1) (Language.hasMul.{u2} \u03b1)) m (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => l i))) (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => HMul.hMul.{u2, u2, u2} (Language.{u2} \u03b1) (Language.{u2} \u03b1) (Language.{u2} \u03b1) (instHMul.{u2} (Language.{u2} \u03b1) (Language.hasMul.{u2} \u03b1)) m (l i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} (l : \u03b9 -> (Language.{u1} \u03b1)) (m : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HMul.hMul.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHMul.{u1} (Language.{u1} \u03b1) (Language.instMulLanguage.{u1} \u03b1)) m (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => l i))) (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => HMul.hMul.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHMul.{u1} (Language.{u1} \u03b1) (Language.instMulLanguage.{u1} \u03b1)) m (l i)))\nCase conversion may be inaccurate. Consider using '#align language.mul_supr Language.mul_sup\u1d62\u2093'. -/\ntheorem mul_sup\u1d62 {\u03b9 : Sort v} (l : \u03b9 \u2192 Language \u03b1) (m : Language \u03b1) :\n    (m * \u2a06 i, l i) = \u2a06 i, m * l i :=\n  image2_union\u1d62_right _ _ _\n#align language.mul_supr Language.mul_sup\u1d62\n\n/- warning: language.supr_add -> Language.sup\u1d62_add is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : Nonempty.{u1} \u03b9] (l : \u03b9 -> (Language.{u2} \u03b1)) (m : Language.{u2} \u03b1), Eq.{succ u2} (Language.{u2} \u03b1) (HAdd.hAdd.{u2, u2, u2} (Language.{u2} \u03b1) (Language.{u2} \u03b1) (Language.{u2} \u03b1) (instHAdd.{u2} (Language.{u2} \u03b1) (Language.hasAdd.{u2} \u03b1)) (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => l i)) m) (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => HAdd.hAdd.{u2, u2, u2} (Language.{u2} \u03b1) (Language.{u2} \u03b1) (Language.{u2} \u03b1) (instHAdd.{u2} (Language.{u2} \u03b1) (Language.hasAdd.{u2} \u03b1)) (l i) m))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : Nonempty.{u2} \u03b9] (l : \u03b9 -> (Language.{u1} \u03b1)) (m : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => l i)) m) (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) (l i) m))\nCase conversion may be inaccurate. Consider using '#align language.supr_add Language.sup\u1d62_add\u2093'. -/\ntheorem sup\u1d62_add {\u03b9 : Sort v} [Nonempty \u03b9] (l : \u03b9 \u2192 Language \u03b1) (m : Language \u03b1) :\n    (\u2a06 i, l i) + m = \u2a06 i, l i + m :=\n  sup\u1d62_sup\n#align language.supr_add Language.sup\u1d62_add\n\n/- warning: language.add_supr -> Language.add_sup\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : Nonempty.{u1} \u03b9] (l : \u03b9 -> (Language.{u2} \u03b1)) (m : Language.{u2} \u03b1), Eq.{succ u2} (Language.{u2} \u03b1) (HAdd.hAdd.{u2, u2, u2} (Language.{u2} \u03b1) (Language.{u2} \u03b1) (Language.{u2} \u03b1) (instHAdd.{u2} (Language.{u2} \u03b1) (Language.hasAdd.{u2} \u03b1)) m (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => l i))) (sup\u1d62.{u2, u1} (Language.{u2} \u03b1) (Set.hasSup.{u2} (List.{u2} \u03b1)) \u03b9 (fun (i : \u03b9) => HAdd.hAdd.{u2, u2, u2} (Language.{u2} \u03b1) (Language.{u2} \u03b1) (Language.{u2} \u03b1) (instHAdd.{u2} (Language.{u2} \u03b1) (Language.hasAdd.{u2} \u03b1)) m (l i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : Nonempty.{u2} \u03b9] (l : \u03b9 -> (Language.{u1} \u03b1)) (m : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) m (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => l i))) (sup\u1d62.{u1, u2} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) \u03b9 (fun (i : \u03b9) => HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) m (l i)))\nCase conversion may be inaccurate. Consider using '#align language.add_supr Language.add_sup\u1d62\u2093'. -/\ntheorem add_sup\u1d62 {\u03b9 : Sort v} [Nonempty \u03b9] (l : \u03b9 \u2192 Language \u03b1) (m : Language \u03b1) :\n    (m + \u2a06 i, l i) = \u2a06 i, m + l i :=\n  sup_sup\u1d62\n#align language.add_supr Language.add_sup\u1d62\n\n/- warning: language.mem_pow -> Language.mem_pow is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {l : Language.{u1} \u03b1} {x : List.{u1} \u03b1} {n : Nat}, Iff (Membership.Mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (Language.hasMem.{u1} \u03b1) x (HPow.hPow.{u1, 0, u1} (Language.{u1} \u03b1) Nat (Language.{u1} \u03b1) (instHPow.{u1, 0} (Language.{u1} \u03b1) Nat (Monoid.Pow.{u1} (Language.{u1} \u03b1) (MonoidWithZero.toMonoid.{u1} (Language.{u1} \u03b1) (Semiring.toMonoidWithZero.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1))))) l n)) (Exists.{succ u1} (List.{u1} (List.{u1} \u03b1)) (fun (S : List.{u1} (List.{u1} \u03b1)) => And (Eq.{succ u1} (List.{u1} \u03b1) x (List.join.{u1} \u03b1 S)) (And (Eq.{1} Nat (List.length.{u1} (List.{u1} \u03b1) S) n) (forall (y : List.{u1} \u03b1), (Membership.Mem.{u1, u1} (List.{u1} \u03b1) (List.{u1} (List.{u1} \u03b1)) (List.hasMem.{u1} (List.{u1} \u03b1)) y S) -> (Membership.Mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (Language.hasMem.{u1} \u03b1) y l)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {l : Language.{u1} \u03b1} {x : List.{u1} \u03b1} {n : Nat}, Iff (Membership.mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (instMembershipListLanguage.{u1} \u03b1) x (HPow.hPow.{u1, 0, u1} (Language.{u1} \u03b1) Nat (Language.{u1} \u03b1) (instHPow.{u1, 0} (Language.{u1} \u03b1) Nat (Monoid.Pow.{u1} (Language.{u1} \u03b1) (MonoidWithZero.toMonoid.{u1} (Language.{u1} \u03b1) (Semiring.toMonoidWithZero.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1))))) l n)) (Exists.{succ u1} (List.{u1} (List.{u1} \u03b1)) (fun (S : List.{u1} (List.{u1} \u03b1)) => And (Eq.{succ u1} (List.{u1} \u03b1) x (List.join.{u1} \u03b1 S)) (And (Eq.{1} Nat (List.length.{u1} (List.{u1} \u03b1) S) n) (forall (y : List.{u1} \u03b1), (Membership.mem.{u1, u1} (List.{u1} \u03b1) (List.{u1} (List.{u1} \u03b1)) (List.instMembershipList.{u1} (List.{u1} \u03b1)) y S) -> (Membership.mem.{u1, u1} (List.{u1} \u03b1) (Language.{u1} \u03b1) (instMembershipListLanguage.{u1} \u03b1) y l)))))\nCase conversion may be inaccurate. Consider using '#align language.mem_pow Language.mem_pow\u2093'. -/\ntheorem mem_pow {l : Language \u03b1} {x : List \u03b1} {n : \u2115} :\n    x \u2208 l ^ n \u2194 \u2203 S : List (List \u03b1), x = S.join \u2227 S.length = n \u2227 \u2200 y \u2208 S, y \u2208 l :=\n  by\n  induction' n with n ihn generalizing x\n  \u00b7 simp only [mem_one, pow_zero, length_eq_zero]\n    constructor\n    \u00b7 rintro rfl\n      exact \u27e8[], rfl, rfl, fun y h => h.elim\u27e9\n    \u00b7 rintro \u27e8_, rfl, rfl, _\u27e9\n      rfl\n  \u00b7 simp only [pow_succ, mem_mul, ihn]\n    constructor\n    \u00b7 rintro \u27e8a, b, ha, \u27e8S, rfl, rfl, hS\u27e9, rfl\u27e9\n      exact \u27e8a :: S, rfl, rfl, forall_mem_cons.2 \u27e8ha, hS\u27e9\u27e9\n    \u00b7 rintro \u27e8_ | \u27e8a, S\u27e9, rfl, hn, hS\u27e9 <;> cases hn\n      rw [forall_mem_cons] at hS\n      exact \u27e8a, _, hS.1, \u27e8S, rfl, rfl, hS.2\u27e9, rfl\u27e9\n#align language.mem_pow Language.mem_pow\n\n/- warning: language.kstar_eq_supr_pow -> Language.kstar_eq_sup\u1d62_pow is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.hasKstar.{u1} \u03b1) l) (sup\u1d62.{u1, 1} (Language.{u1} \u03b1) (Set.hasSup.{u1} (List.{u1} \u03b1)) Nat (fun (i : Nat) => HPow.hPow.{u1, 0, u1} (Language.{u1} \u03b1) Nat (Language.{u1} \u03b1) (instHPow.{u1, 0} (Language.{u1} \u03b1) Nat (Monoid.Pow.{u1} (Language.{u1} \u03b1) (MonoidWithZero.toMonoid.{u1} (Language.{u1} \u03b1) (Semiring.toMonoidWithZero.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1))))) l i))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.instKStarLanguage.{u1} \u03b1) l) (sup\u1d62.{u1, 1} (Language.{u1} \u03b1) (CompleteBooleanAlgebra.toSupSet.{u1} (Language.{u1} \u03b1) (instCompleteBooleanAlgebraLanguage.{u1} \u03b1)) Nat (fun (i : Nat) => HPow.hPow.{u1, 0, u1} (Language.{u1} \u03b1) Nat (Language.{u1} \u03b1) (instHPow.{u1, 0} (Language.{u1} \u03b1) Nat (Monoid.Pow.{u1} (Language.{u1} \u03b1) (MonoidWithZero.toMonoid.{u1} (Language.{u1} \u03b1) (Semiring.toMonoidWithZero.{u1} (Language.{u1} \u03b1) (Language.instSemiringLanguage.{u1} \u03b1))))) l i))\nCase conversion may be inaccurate. Consider using '#align language.kstar_eq_supr_pow Language.kstar_eq_sup\u1d62_pow\u2093'. -/\ntheorem kstar_eq_sup\u1d62_pow (l : Language \u03b1) : l\u2217 = \u2a06 i : \u2115, l ^ i :=\n  by\n  ext x\n  simp only [mem_kstar, mem_supr, mem_pow]\n  constructor\n  \u00b7 rintro \u27e8S, rfl, hS\u27e9\n    exact \u27e8_, S, rfl, rfl, hS\u27e9\n  \u00b7 rintro \u27e8_, S, rfl, rfl, hS\u27e9\n    exact \u27e8S, rfl, hS\u27e9\n#align language.kstar_eq_supr_pow Language.kstar_eq_sup\u1d62_pow\n\n/- warning: language.map_kstar -> Language.map_kstar is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (f : \u03b1 -> \u03b2) (l : Language.{u1} \u03b1), Eq.{succ u2} (Language.{u2} \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) (fun (_x : RingHom.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) => (Language.{u1} \u03b1) -> (Language.{u2} \u03b2)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) (Language.map.{u1, u2} \u03b1 \u03b2 f) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.hasKstar.{u1} \u03b1) l)) (KStar.kstar.{u2} (Language.{u2} \u03b2) (Language.hasKstar.{u2} \u03b2) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) (fun (_x : RingHom.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) => (Language.{u1} \u03b1) -> (Language.{u2} \u03b2)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} \u03b1) (Language.{u2} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b1) (Language.semiring.{u1} \u03b1)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b2) (Language.semiring.{u2} \u03b2))) (Language.map.{u1, u2} \u03b1 \u03b2 f) l))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (f : \u03b1 -> \u03b2) (l : Language.{u2} \u03b1), Eq.{succ u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} \u03b1) => Language.{u1} \u03b2) (KStar.kstar.{u2} (Language.{u2} \u03b1) (Language.instKStarLanguage.{u2} \u03b1) l)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u2} \u03b1) (fun (_x : Language.{u2} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} \u03b1) => Language.{u1} \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u2} \u03b1) (Language.{u1} \u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} \u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u2} \u03b1) (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (RingHom.instRingHomClassRingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))))) (Language.map.{u2, u1} \u03b1 \u03b2 f) (KStar.kstar.{u2} (Language.{u2} \u03b1) (Language.instKStarLanguage.{u2} \u03b1) l)) (KStar.kstar.{u1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} \u03b1) => Language.{u1} \u03b2) l) (Language.instKStarLanguage.{u1} \u03b2) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u2} \u03b1) (fun (_x : Language.{u2} \u03b1) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} \u03b1) => Language.{u1} \u03b2) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u2} \u03b1) (Language.{u1} \u03b2) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} \u03b1) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u2} \u03b1) (Language.{u1} \u03b2) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2))) (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)) (RingHom.instRingHomClassRingHom.{u2, u1} (Language.{u2} \u03b1) (Language.{u1} \u03b2) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} \u03b1) (Language.instSemiringLanguage.{u2} \u03b1)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} \u03b2) (Language.instSemiringLanguage.{u1} \u03b2)))))) (Language.map.{u2, u1} \u03b1 \u03b2 f) l))\nCase conversion may be inaccurate. Consider using '#align language.map_kstar Language.map_kstar\u2093'. -/\n@[simp]\ntheorem map_kstar (f : \u03b1 \u2192 \u03b2) (l : Language \u03b1) : map f l\u2217 = (map f l)\u2217 :=\n  by\n  rw [kstar_eq_supr_pow, kstar_eq_supr_pow]\n  simp_rw [\u2190 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 \u03b1) : l\u2217 * l = l * l\u2217 := by\n  simp only [kstar_eq_supr_pow, mul_supr, supr_mul, \u2190 pow_succ, \u2190 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 {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.hasAdd.{u1} \u03b1)) (OfNat.ofNat.{u1} (Language.{u1} \u03b1) 1 (OfNat.mk.{u1} (Language.{u1} \u03b1) 1 (One.one.{u1} (Language.{u1} \u03b1) (Language.hasOne.{u1} \u03b1)))) (HMul.hMul.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHMul.{u1} (Language.{u1} \u03b1) (Language.hasMul.{u1} \u03b1)) l (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.hasKstar.{u1} \u03b1) l))) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.hasKstar.{u1} \u03b1) l)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) (OfNat.ofNat.{u1} (Language.{u1} \u03b1) 1 (One.toOfNat1.{u1} (Language.{u1} \u03b1) (Language.instOneLanguage.{u1} \u03b1))) (HMul.hMul.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHMul.{u1} (Language.{u1} \u03b1) (Language.instMulLanguage.{u1} \u03b1)) l (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.instKStarLanguage.{u1} \u03b1) l))) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.instKStarLanguage.{u1} \u03b1) 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\u2093'. -/\n@[simp]\ntheorem one_add_self_mul_kstar_eq_kstar (l : Language \u03b1) : 1 + l * l\u2217 = l\u2217 :=\n  by\n  simp only [kstar_eq_supr_pow, mul_supr, \u2190 pow_succ, \u2190 pow_zero l]\n  exact sup_sup\u1d62_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 {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.hasAdd.{u1} \u03b1)) (OfNat.ofNat.{u1} (Language.{u1} \u03b1) 1 (OfNat.mk.{u1} (Language.{u1} \u03b1) 1 (One.one.{u1} (Language.{u1} \u03b1) (Language.hasOne.{u1} \u03b1)))) (HMul.hMul.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHMul.{u1} (Language.{u1} \u03b1) (Language.hasMul.{u1} \u03b1)) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.hasKstar.{u1} \u03b1) l) l)) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.hasKstar.{u1} \u03b1) l)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (l : Language.{u1} \u03b1), Eq.{succ u1} (Language.{u1} \u03b1) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHAdd.{u1} (Language.{u1} \u03b1) (Language.instAddLanguage.{u1} \u03b1)) (OfNat.ofNat.{u1} (Language.{u1} \u03b1) 1 (One.toOfNat1.{u1} (Language.{u1} \u03b1) (Language.instOneLanguage.{u1} \u03b1))) (HMul.hMul.{u1, u1, u1} (Language.{u1} \u03b1) (Language.{u1} \u03b1) (Language.{u1} \u03b1) (instHMul.{u1} (Language.{u1} \u03b1) (Language.instMulLanguage.{u1} \u03b1)) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.instKStarLanguage.{u1} \u03b1) l) l)) (KStar.kstar.{u1} (Language.{u1} \u03b1) (Language.instKStarLanguage.{u1} \u03b1) 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\u2093'. -/\n@[simp]\ntheorem one_add_kstar_mul_self_eq_kstar (l : Language \u03b1) : 1 + l\u2217 * l = l\u2217 := 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 \u03b1) :=\n  { Language.semiring, Set.completeBooleanAlgebra,\n    Language.hasKstar with\n    one_le_kstar := fun a l hl => \u27e8[], hl, by simp\u27e9\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\u1d62_le fun n => _\n      induction' n with n ih\n      \u00b7 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\u1d62_le fun n => _\n      induction' n with n ih\n      \u00b7 simp\n      rw [pow_succ, \u2190 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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, `\u03b9`, `\u03ba`, `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 {\u03b9 : Type*} [decidable_eq \u03b9] [fintype \u03b9]\nvariables (e : basis \u03b9 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 \u2192 R) \u2243\u2097[R] (n \u2192 R)) : m \u2243 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) :\n  m \u2243 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 \u2b1d N) = det (N \u2b1d 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 \u2b1d M) = det (M \u2b1d 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) :\n  det (M \u2b1d N) = det (N \u2b1d 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 [\u2190 det_minor_equiv_self e, minor_mul_equiv _ _ _ (equiv.refl n) _, det_comm,\n  \u2190 minor_mul_equiv, equiv.coe_refl, minor_id_id]\n\n/-- If `M'` is a two-sided inverse for `M` (indexed differently), `det (M \u2b1d N \u2b1d 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 \u2b1d M' = 1) (hM'M : M' \u2b1d M = 1) :\n  det (M \u2b1d N \u2b1d M') = det N :=\nby rw [\u2190 det_comm' hM'M hMM', \u2190 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 {\u03ba : Type*} [fintype \u03ba]\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 \u03ba]\n  (b : basis \u03b9 A M) (c : basis \u03ba A M) (f : M \u2192\u2097[A] M) :\n  det (linear_map.to_matrix b b f) = det (linear_map.to_matrix c c f) :=\nby rw [\u2190 linear_map_to_matrix_mul_basis_to_matrix c b c,\n       \u2190 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 \u03b9 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 \u03b9 A M) \u2192 (M \u2192\u2097[A] M) \u2192* A :=\ntrunc.lift\n  (\u03bb b : basis \u03b9 A M,\n    (det_monoid_hom).comp (to_matrix_alg_equiv b : (M \u2192\u2097[A] M) \u2192* matrix \u03b9 \u03b9 A))\n  (\u03bb 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 \u03b9 A M) (f : M \u2192\u2097[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' {\u03b9' : Type*} [fintype \u03b9'] [decidable_eq \u03b9']\n  (tb : trunc $ basis \u03b9 A M) (b' : basis \u03b9' A M) (f : M \u2192\u2097[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 \u03b9 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 \u03b9 A M) (f g : M \u2192\u2097[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 \u2192\u2097[A] M) \u2192* A :=\nif H : \u2203 (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] : \u21d1(linear_map.det : (M \u2192\u2097[A] M) \u2192* A) =\n  if H : \u2203 (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 \u2192\u2097[A] M) :\n  f.det = matrix.det (linear_map.to_matrix b b f) :=\nhave \u2203 (s : finset M), nonempty (basis s A M),\nfrom \u27e8s, \u27e8b\u27e9\u27e9,\nby rw [linear_map.coe_det, dif_pos, det_aux_def' _ b]; assumption\n\n@[simp] lemma det_to_matrix\n  (b : basis \u03b9 A M) (f : M \u2192\u2097[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' {\u03b9 : Type*} [fintype \u03b9] [decidable_eq \u03b9]\n  (f : (\u03b9 \u2192 A) \u2192\u2097[A] (\u03b9 \u2192 A)) :\n  det f.to_matrix' = f.det :=\nby simp [\u2190 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 \u2192 Prop} (f : M \u2192\u2097[A] M)\n  (hb : \u2200 (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 \u2192\u2097[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 \u2192\u2097[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 {\ud835\udd5c : Type*} [field \ud835\udd5c] {M : Type*} [add_comm_group M] [module \ud835\udd5c M]\n  (c : \ud835\udd5c) (f : M \u2192\u2097[\ud835\udd5c] M) :\n  linear_map.det (c \u2022 f) = c ^ (finite_dimensional.finrank \ud835\udd5c M) * linear_map.det f :=\nbegin\n  by_cases H : \u2203 (s : finset M), nonempty (basis s \ud835\udd5c M),\n  { haveI : finite_dimensional \ud835\udd5c M,\n    { rcases H with \u27e8s, \u27e8hs\u27e9\u27e9, exact finite_dimensional.of_finset_basis hs },\n    simp only [\u2190 det_to_matrix (finite_dimensional.fin_basis \ud835\udd5c M), linear_equiv.map_smul,\n              fintype.card_fin, det_smul] },\n  { classical,\n    have : finite_dimensional.finrank \ud835\udd5c M = 0 := finrank_eq_zero_of_not_exists_basis H,\n    simp [coe_det, H, this] }\nend\n\nlemma det_zero' {\u03b9 : Type*} [fintype \u03b9] [nonempty \u03b9] (b : basis \u03b9 A M) :\n  linear_map.det (0 : M \u2192\u2097[A] M) = 0 :=\nby { haveI := classical.dec_eq \u03b9,\n     rw [\u2190 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 {\ud835\udd5c : Type*} [field \ud835\udd5c] {M : Type*} [add_comm_group M] [module \ud835\udd5c M] :\n  linear_map.det (0 : M \u2192\u2097[\ud835\udd5c] M) = (0 : \ud835\udd5c) ^ (finite_dimensional.finrank \ud835\udd5c M) :=\nby simp only [\u2190 zero_smul \ud835\udd5c (1 : M \u2192\u2097[\ud835\udd5c] 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 \u2192\u2097[A] M) (e : M \u2243\u2097[A] N) :\n  linear_map.det ((e : M \u2192\u2097[A] N) \u2218\u2097 (f \u2218\u2097 (e.symm : N \u2192\u2097[A] M))) = linear_map.det f :=\nbegin\n  classical,\n  by_cases H : \u2203 (s : finset M), nonempty (basis s A M),\n  { rcases H with \u27e8s, \u27e8b\u27e9\u27e9,\n    rw [\u2190 det_to_matrix b f, \u2190 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, \u2190 matrix.mul_assoc, matrix.det_conj],\n    { rw [\u2190 to_matrix_comp, linear_equiv.comp_coe, e.symm_trans_self,\n          linear_equiv.refl_to_linear_map, to_matrix_id] },\n    { rw [\u2190 to_matrix_comp, linear_equiv.comp_coe, e.self_trans_symm,\n          linear_equiv.refl_to_linear_map, to_matrix_id] } },\n  { have H' : \u00ac (\u2203 (t : finset N), nonempty (basis t A N)),\n    { contrapose! H,\n      rcases H with \u27e8s, \u27e8b\u27e9\u27e9,\n      exact \u27e8_, \u27e8(b.map e.symm).reindex_finset_range\u27e9\u27e9 },\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 \u2243\u2097[R] M') (v : basis \u03b9 R M) (v' : basis \u03b9 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 \u2243\u2097[A] M) : is_unit (linear_map.det (f : M \u2192\u2097[A] M)) :=\nby haveI := classical.dec_eq M; exact\n(f : M \u2192\u2097[A] M).det_cases (\u03bb 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 \u2192\u2097[R] M'} {v : basis \u03b9 R M} {v' : basis \u03b9 R M'}\n  (h : is_unit (linear_map.to_matrix v v' f).det) : M \u2243\u2097[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)\u207b\u00b9,\n  left_inv := \u03bb x,\n    calc to_lin v' v (to_matrix v v' f)\u207b\u00b9 (f x)\n        = to_lin v v ((to_matrix v v' f)\u207b\u00b9 \u2b1d 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 := \u03bb x,\n    calc f (to_lin v' v (to_matrix v v' f)\u207b\u00b9 x)\n        = to_lin v' v' (to_matrix v v' f \u2b1d (to_matrix v v' f)\u207b\u00b9) 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  {\ud835\udd5c : Type*} [field \ud835\udd5c] {M : Type*} [add_comm_group M] [module \ud835\udd5c M]\n  [finite_dimensional \ud835\udd5c M] (f : M \u2192\u2097[\ud835\udd5c] M) (hf : linear_map.det f \u2260 0) :\n  M \u2243\u2097[\ud835\udd5c] M :=\nhave is_unit (linear_map.to_matrix (finite_dimensional.fin_basis \ud835\udd5c M)\n  (finite_dimensional.fin_basis \ud835\udd5c 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 \u03b9 :=\n{ to_fun := \u03bb 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 [\u2190function.update_eq_self i v, h, \u2190det_transpose, e.to_matrix_update,\n        \u2190update_row_transpose, \u2190e.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 : \u03b9 \u2192 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 \u2260 0 :=\n\u03bb h, by simpa [h] using e.det_self\n\nlemma is_basis_iff_det {v : \u03b9 \u2192 M} :\n  linear_independent R v \u2227 span R (set.range v) = \u22a4 \u2194 is_unit (e.det v) :=\nbegin\n  split,\n  { rintro \u27e8hli, hspan\u27e9,\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 : \u21d1 v' = v,\n    { ext i, rw [v'_def, basis.map_apply, linear_equiv.of_is_unit_det_apply, e.constr_basis] },\n    rw \u2190 this,\n    exact \u27e8v'.linear_independent, v'.span_eq\u27e9 },\nend\n\nlemma basis.is_unit_det (e' : basis \u03b9 R M) : is_unit (e.det e') :=\n(is_basis_iff_det e).mp \u27e8e'.linear_independent, e'.span_eq\u27e9\n\n/-- Any alternating map to `R` where `\u03b9` 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 \u03b9) : f = f e \u2022 e.det :=\nbegin\n  refine basis.ext_alternating e (\u03bb i h, _),\n  let \u03c3 : equiv.perm \u03b9 := equiv.of_bijective i (fintype.injective_iff_bijective.1 h),\n  change f (e \u2218 \u03c3) = (f e \u2022 e.det) (e \u2218 \u03c3),\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 \u03b9 A M) (f : M \u2192\u2097[A] M) (v : \u03b9 \u2192 M) :\n  e.det (f \u2218 v) = f.det * e.det v :=\nby { rw [basis.det_apply, basis.det_apply, \u2190 f.det_to_matrix e, \u2190 matrix.det_mul,\n         e.to_matrix_eq_to_matrix_constr (f \u2218 v), e.to_matrix_eq_to_matrix_constr v,\n         \u2190 to_matrix_comp, e.constr_comp] }\n\nlemma basis.det_reindex {\u03b9' : Type*} [fintype \u03b9'] [decidable_eq \u03b9']\n  (b : basis \u03b9 R M) (v : \u03b9' \u2192 M) (e : \u03b9 \u2243 \u03b9') :\n  (b.reindex e).det v = b.det (v \u2218 e) :=\nby rw [basis.det_apply, basis.to_matrix_reindex', det_reindex_alg_equiv, basis.det_apply]\n\nlemma basis.det_reindex_symm {\u03b9' : Type*} [fintype \u03b9'] [decidable_eq \u03b9']\n  (b : basis \u03b9 R M) (v : \u03b9 \u2192 M) (e : \u03b9' \u2243 \u03b9) :\n  (b.reindex e.symm).det (v \u2218 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 \u03b9 R M) (f : M \u2243\u2097[R] M') (v : \u03b9 \u2192 M') :\n  (b.map f).det v = b.det (f.symm \u2218 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 \u03b9).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 : \u03b9 \u2192 M}\n  (hli : linear_independent R v) (hsp : span R (range v) = \u22a4) (i : \u03b9) :\n  (e.det v) \u2022 (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 \u2192 C \u2192 Type )\n( id : (X : C) \u2192 hom X X )\n( comp : {X Y Z : C} \u2192 hom X Y \u2192 hom Y Z \u2192 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 \" \ud835\udfd9 \" => category.id\ninfixr: 80 \" \u226b \" => category.comp\ninfixr: 10 \" \u27f6 \" => category.hom\n\nvariable (C : Type) [category C]\n\ninductive prod_coprod : Type\n| of_cat' : C \u2192 prod_coprod\n| prod : prod_coprod \u2192 prod_coprod \u2192 prod_coprod\n| coprod : prod_coprod \u2192 prod_coprod \u2192 prod_coprod\n\nvariable {C}\n\nnamespace prod_coprod\n\n@[simp] def size : prod_coprod C \u2192 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) \u2192 Type\n| of_cat {X Y : C} : (X \u27f6 Y) \u2192 syn (of_cat' X) (of_cat' Y)\n| prod_mk {X Y Z : prod_coprod C} : syn X Y \u2192 syn X Z \u2192 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 \u2192 syn Y Z \u2192 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 \u2192 syn Y Z \u2192 syn X Z\n\nnamespace syn\n\ninductive rel : {X Y : prod_coprod C} \u2192 syn X Y \u2192 syn X Y \u2192 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 \u2192 rel g f\n| trans {X Y : prod_coprod C} {f g h : syn X Y} : rel f g \u2192 rel g h \u2192 rel f h\n| comp_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syn X Y} {g\u2081 g\u2082 : syn Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.comp g\u2081) (f\u2082.comp g\u2082)\n| prod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syn X Y} {g\u2081 g\u2082 : syn X Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.prod_mk g\u2081) (f\u2082.prod_mk g\u2082)\n| coprod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syn X Z} {g\u2081 g\u2082 : syn Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.coprod_mk g\u2081) (f\u2082.coprod_mk g\u2082)\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 (\ud835\udfd9 X)) (syn.id (of_cat' X))\n| of_cat_comp {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  rel (syn.of_cat (f \u226b 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 \" \u2665 \" => 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\u2081 : rel (f.comp syn.fst) (g.comp syn.fst))\n  (h\u2082 : 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\u2081 h\u2082) (rel.prod_eta g))\n\ntheorem rel_coprod {X Y Z : prod_coprod C} {f g : syn (X.coprod Y) Z}\n  (h\u2081 : rel (syn.inl.comp f) (syn.inl.comp g))\n  (h\u2082 : 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\u2081 h\u2082) (rel.coprod_eta g))\n\nend syn\n\ninductive norm_hom : (X Y : prod_coprod C) \u2192 Type\n| of_cat {X Y : C} (f : X \u27f6 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} \u2192 norm_hom X Y \u2192 norm_hom X Y \u2192 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 \u2192 rel f g\n| trans {X Y : prod_coprod C} {f g h : norm_hom X Y} : rel f g \u2192 rel g h \u2192 rel f h\n| coprod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Z} {g\u2081 g\u2082 : norm_hom Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (coprod_mk f\u2081 g\u2081) (coprod_mk f\u2082 g\u2082)\n| prod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Y} {g\u2081 g\u2082 : norm_hom X Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (prod_mk f\u2081 g\u2081) (prod_mk f\u2082 g\u2082)\n| comp_inl_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Y} :\n  rel f\u2081 f\u2082 \u2192 rel (comp_inl f\u2081 : norm_hom X (coprod Y Z)) (comp_inl f\u2082)\n| comp_inr_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Z} :\n  rel f\u2081 f\u2082 \u2192 rel (comp_inr f\u2081 : norm_hom X (coprod Y Z)) (comp_inr f\u2082)\n| fst_comp_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Z} :\n  rel f\u2081 f\u2082 \u2192 rel (fst_comp f\u2081 : norm_hom (prod X Y) Z) (fst_comp f\u2082)\n| snd_comp_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel (snd_comp f\u2081 : norm_hom (prod X Y) Z) (snd_comp f\u2082)\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} \u2192 (f : norm_hom X (coprod Y Z)) \u2192\n  Option ((norm_hom X Y) \u2295 (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} \u2192 {f : norm_hom X (coprod Y Z)} \u2192\n  {g : norm_hom X Y} \u2192 to_inj f = some (Sum.inl g) \u2192 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 : \u2203 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 \u27e8i, rfl\u27e9\n    | some (Sum.inr _) => simp\n    | none => simp }\n  match hi with\n  | \u27e8i, hi\u27e9 => by\n  simp [hi, to_inj] at h\n  rw [\u2190 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 : \u2203 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 \u27e8i, rfl\u27e9\n    | some (Sum.inr _) => simp\n    | none => simp }\n  match hi with\n  | \u27e8i, hi\u27e9 => by\n  simp [hi, to_inj] at h\n  rw [\u2190 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 : \u2203 f' g', to_inj f = some (Sum.inl f') \u2227 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 \u27e8f', g', rfl, rfl\u27e9\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  | \u27e8f', g', hf, hg\u27e9 => by\n  simp [hf, hg, to_inj] at h\n  rw [\u2190 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} \u2192 {f : norm_hom X (coprod Y Z)} \u2192\n  {g : norm_hom X Z} \u2192 to_inj f = some (Sum.inr g) \u2192 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 : \u2203 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 \u27e8i, rfl\u27e9\n    | some (Sum.inl _) => simp\n    | none => simp }\n  match hi with\n  | \u27e8i, hi\u27e9 => by\n  simp [hi, to_inj] at h\n  rw [\u2190 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 : \u2203 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 \u27e8i, rfl\u27e9\n    | some (Sum.inl _) => simp\n    | none => simp }\n  match hi with\n  | \u27e8i, hi\u27e9 => by\n  simp [hi, to_inj] at h\n  rw [\u2190 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 : \u2203 f' g', to_inj f = some (Sum.inr f') \u2227 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 \u27e8f', g', rfl, rfl\u27e9\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  | \u27e8f', g', hf, hg\u27e9 => by\n  simp [hf, hg, to_inj] at h\n  rw [\u2190 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} : \u00acrel 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  \u2203 (p : polynomial R), p \u2260 0 \u2227 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  \u2200 (x : A), x \u2208 S \u2192 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  \u2200 (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 \u2194 algebra.is_algebraic R \u21a5S :=\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 \u2194 subalgebra.is_algebraic \u22a4 :=\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 \u2194 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 \u2194 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 \u22a4\n        (is_noetherian_of_submodule_of_noetherian K L (\u2191\u22a4) 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 : \u2200 (x : R), coe_fn (algebra_map R S) x = 0 \u2192 x = 0) :\n    \u2203 (x : \u21a5(integral_closure R S)), \u2203 (y : \u21a5(integral_closure R S)), \u2203 (H : y \u2260 0), z * \u2191y = \u2191x :=\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) \u2260 0) :\n    x\u207b\u00b9 =\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 \u2260 0) :\n    x\u207b\u00b9 =\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 : \u21a5A} {p : polynomial K}\n    (aeval_eq : coe_fn (polynomial.aeval x) p = 0) (coeff_zero_ne : polynomial.coeff p 0 \u2260 0) :\n    \u2191x\u207b\u00b9 \u2208 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 : \u21a5A} (hx : is_algebraic K \u2191x) : \u2191x\u207b\u00b9 \u2208 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 \u21a5A :=\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\u2081 u\u2082 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\u2081} [category C] {D : Type u\u2082} [category D]\n    (G : C \u2964 D) {P : C} {X : C} {Y : C} (f : P \u27f6 X) (g : P \u27f6 Y) :\n    is_limit (functor.map_cone G (binary_fan.mk f g)) \u2243\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 \u22d9 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 \u22d9 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\u2081} [category C] {D : Type u\u2082} [category D]\n    (G : C \u2964 D) {P : C} {X : C} {Y : C} (f : P \u27f6 X) (g : P \u27f6 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\u2081} [category C] {D : Type u\u2082} [category D]\n    (G : C \u2964 D) {P : C} {X : C} {Y : C} (f : P \u27f6 X) (g : P \u27f6 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\u2081} [category C] {D : Type u\u2082}\n    [category D] (G : C \u2964 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\u2081} [category C] {D : Type u\u2082} [category D]\n    (G : C \u2964 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\u2081} [category C] {D : Type u\u2082} [category D] (G : C \u2964 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 \u2a2f Y) \u2245 functor.obj G X \u2a2f 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\u2081} [category C] {D : Type u\u2082} [category D]\n    (G : C \u2964 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\u2081} [category C] {D : Type u\u2082}\n    [category D] (G : C \u2964 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 \u2192 A \u2192 Type v) : A \u2192 A \u2192 Type (max u v)\n| nil {} : \u03a0{a : A}, paths a a\n| cons   : \u03a0{a\u2081 a\u2082 a\u2083 : A} (r : R a\u2082 a\u2083), paths a\u2081 a\u2082 \u2192 paths a\u2081 a\u2083\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 \u2192 A \u2192 Type _} {a a' a\u2081 a\u2082 a\u2083 a\u2084 : A}\n\n  @[hott] def concat (r : R a\u2081 a\u2082) (l : paths R a\u2082 a\u2083) : paths R a\u2081 a\u2083 :=\n  begin\n    hinduction l with a a\u2082 a\u2083 a\u2084 r' l IH,\n    { exact [r]},\n    { exact r' :: IH r}\n  end\n\n  @[hott] theorem concat_nil (r : R a\u2081 a\u2082) : concat r (@nil A R a\u2082) = [r] := idp\n\n  @[hott] theorem concat_cons (r : R a\u2081 a\u2082) (r' : R a\u2083 a\u2084) (l : paths R a\u2082 a\u2083)\n    : concat r (r'::l)  = r'::(concat r l) := idp\n\n  @[hott] def append (l\u2082 : paths R a\u2082 a\u2083) (l\u2081 : paths R a\u2081 a\u2082) :\n    paths R a\u2081 a\u2083 :=\n  begin\n    hinduction l\u2082 with a\u2082 a\u2082 a\u2083 a\u2084 r l\u2082 IH,\n    { exact l\u2081 },\n    { exact cons r (IH l\u2081) }\n  end\n\n  local infix ` ++ ` := append\n\n  @[hott] def nil_append (l : paths R a\u2081 a\u2082) : nil ++ l = l := idp\n  @[hott] def cons_append (r : R a\u2083 a\u2084) (l\u2082 : paths R a\u2082 a\u2083) (l\u2081 : paths R a\u2081 a\u2082) :\n    (r :: l\u2082) ++ l\u2081 = r :: (l\u2082 ++ l\u2081) := idp\n\n  @[hott] def singleton_append (r : R a\u2082 a\u2083) (l : paths R a\u2081 a\u2082) : [r] ++ l = r :: l := idp\n  @[hott] def append_singleton (l : paths R a\u2082 a\u2083) (r : R a\u2081 a\u2082) : l ++ [r] = concat r l :=\n  begin\n    hinduction l with a\u2081 a\u2081 a\u2082 a\u2083 r l IH,\n    { refl },\n    { exact ap (cons r) (IH _) }\n  end\n\n  @[hott] def append_nil (l : paths R a\u2081 a\u2082) : l ++ nil = l :=\n  begin\n    hinduction l with a\u2081 a\u2081 a\u2082 a\u2083 r l IH,\n    { refl },\n    { exact ap (cons r) IH }\n  end\n\n  @[hott] def append_assoc (l\u2083 : paths R a\u2083 a\u2084) (l\u2082 : paths R a\u2082 a\u2083)\n    (l\u2081 : paths R a\u2081 a\u2082) : (l\u2083 ++ l\u2082) ++ l\u2081 = l\u2083 ++ (l\u2082 ++ l\u2081) :=\n  begin\n    hinduction l\u2083 with a\u2083 a\u2083 a\u2084 a\u2085 r l\u2083 IH,\n    { refl },\n    { refine ap (cons r) (IH _) }\n  end\n\n  @[hott] theorem append_concat (l\u2082 : paths R a\u2083 a\u2084) (l\u2081 : paths R a\u2082 a\u2083) (r : R a\u2081 a\u2082) :\n    l\u2082 ++ concat r l\u2081 = concat r (l\u2082 ++ l\u2081) :=\n  begin\n    hinduction l\u2082 with a\u2082 a\u2082 a\u2083 a\u2084 r' l\u2082 IH,\n    { refl },\n    { exact ap (cons r') (IH _) }\n  end\n\n  @[hott] def concat_append (l\u2082 : paths R a\u2083 a\u2084) (r : R a\u2082 a\u2083) (l\u2081 : paths R a\u2081 a\u2082) :\n    concat r l\u2082 ++ l\u2081 = l\u2082 ++ r :: l\u2081 :=\n  begin\n    hinduction l\u2082 with a\u2082 a\u2082 a\u2083 a\u2084 r' l\u2082 IH,\n    { refl },\n    { exact ap (cons r') (IH _) }\n  end\n\n  @[hott] def paths.rec_tail {C : \u03a0\u2983a a' : A\u2984, paths R a a' \u2192 Type _}\n  (H0 : \u03a0 {a : A}, @C a a nil)\n  (H1 : \u03a0 {a\u2081 a\u2082 a\u2083 : A} (r : R a\u2081 a\u2082) (l : paths R a\u2082 a\u2083), C l \u2192 C (concat r l)) :\n  \u03a0{a a' : A} (l : paths R a a'), C l :=\n  begin\n    have : \u03a0{a\u2081 a\u2082 a\u2083 : A} (l\u2082 : paths R a\u2082 a\u2083) (l\u2081 : paths R a\u2081 a\u2082) (c : C l\u2082),\n      C (l\u2082 ++ l\u2081),\n    begin\n      intros, revert a\u2083 l\u2082 c, hinduction l\u2081 with a\u2081 a\u2081 a\u2082 a\u2084 r l\u2081 IH; intros a\u2083 l\u2082 c,\n      { rwr append_nil, exact c },\n      { rwr [\u2190concat_append], apply IH, apply H1, exact c }\n    end,\n    intros, rwr [\u2190nil_append l], apply this, apply H0\n  end\n\n  @[hott] def cons_eq_concat (r : R a\u2082 a\u2083) (l : paths R a\u2081 a\u2082) :\n    \u03a3a (r' : R a\u2081 a) (l' : paths R a a\u2083), r :: l = concat r' l' :=\n  begin\n    revert a\u2083 r, hinduction l with a\u2081 a\u2081 a\u2082 a\u2083 r l IH; intros a\u2083' r',\n    { exact \u27e8a\u2083', r', nil, idp\u27e9 },\n    { cases (IH r) with a\u2084 w, cases w with r\u2082 w, cases w with l p, clear IH,\n      exact \u27e8a\u2084, r\u2082, r' :: l, ap (cons r') p\u27e9 }\n  end\n\n  @[hott] def length (l : paths R a\u2081 a\u2082) : \u2115 :=\n  begin\n    hinduction l with a\u2081 a\u2081 a\u2082 a\u2083 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 : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) (l : paths R a\u2081 a\u2082) :\n    paths R a\u2082 a\u2081 :=\n  begin\n    hinduction l with a\u2081 a\u2081 a\u2082 a\u2083 r l IH,\n    { exact nil},\n    { exact concat (rev r) IH}\n  end\n\n  @[hott] theorem reverse_nil (rev : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) : reverse rev (@nil A R a\u2081) = [] := idp\n\n  @[hott] theorem reverse_cons (rev : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) (r : R a\u2082 a\u2083) (l : paths R a\u2081 a\u2082) :\n    reverse rev (r::l) = concat (rev r) (reverse rev l) := idp\n\n  @[hott] theorem reverse_singleton (rev : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) (r : R a\u2081 a\u2082) :\n    reverse rev [r] = [rev r] := idp\n\n  @[hott] theorem reverse_pair (rev : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) (r\u2082 : R a\u2082 a\u2083) (r\u2081 : R a\u2081 a\u2082) :\n    reverse rev [r\u2082, r\u2081] = [rev r\u2081, rev r\u2082] := idp\n\n  @[hott] theorem reverse_concat (rev : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) (r : R a\u2081 a\u2082) (l : paths R a\u2082 a\u2083) :\n    reverse rev (concat r l) = rev r :: (reverse rev l) :=\n  begin\n    hinduction l with a\u2081 a\u2081 a\u2082 a\u2083 r l IH,\n    { refl },\n    { rwr [concat_cons, reverse_cons, IH]}\n  end\n\n  @[hott] theorem reverse_append (rev : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) (l\u2082 : paths R a\u2082 a\u2083)\n    (l\u2081 : paths R a\u2081 a\u2082) : reverse rev (l\u2082 ++ l\u2081) = reverse rev l\u2081 ++ reverse rev l\u2082 :=\n  begin\n    hinduction l\u2082 with a\u2082 a\u2082 a\u2083 a\u2084 r l\u2082 IH,\n    { exact (append_nil _)\u207b\u00b9 },\n    { rwr [cons_append, reverse_cons, reverse_cons, append_concat, IH] }\n  end\n\n  @[hott] def realize (P : A \u2192 A \u2192 Type _) (f : \u03a0\u2983a a'\u2984, R a a' \u2192 P a a') (\u03c1 : \u03a0a, P a a)\n    (c : \u03a0\u2983a\u2081 a\u2082 a\u2083\u2984, P a\u2081 a\u2082 \u2192 P a\u2082 a\u2083 \u2192 P a\u2081 a\u2083)\n    \u2983a a' : A\u2984 (l : paths R a a') : P a a' :=\n  begin\n    hinduction l with a a\u2081 a\u2082 a\u2083 r l IH,\n    { exact \u03c1 a },\n    { exact c IH (f r) }\n  end\n\n  @[hott, hsimp] def realize_nil (P : A \u2192 A \u2192 Type _) (f : \u03a0\u2983a a'\u2984, R a a' \u2192 P a a') \n    (\u03c1 : \u03a0a, P a a) (c : \u03a0\u2983a\u2081 a\u2082 a\u2083\u2984, P a\u2081 a\u2082 \u2192 P a\u2082 a\u2083 \u2192 P a\u2081 a\u2083) (a : A) :\n    realize P f \u03c1 c nil = \u03c1 a :=\n  by refl\n\n  @[hott, hsimp] def realize_cons (P : A \u2192 A \u2192 Type _) (f : \u03a0\u2983a a'\u2984, R a a' \u2192 P a a') (\u03c1 : \u03a0a, P a a)\n    (c : \u03a0\u2983a\u2081 a\u2082 a\u2083\u2984, P a\u2081 a\u2082 \u2192 P a\u2082 a\u2083 \u2192 P a\u2081 a\u2083)\n    \u2983a\u2081 a\u2082 a\u2083 : A\u2984 (r : R a\u2082 a\u2083) (l : paths R a\u2081 a\u2082) :\n    realize P f \u03c1 c (r :: l) = c (realize P f \u03c1 c l) (f r) :=\n  by refl\n\n  @[hott] theorem realize_singleton {P : A \u2192 A \u2192 Type _} {f : \u03a0\u2983a a'\u2984, R a a' \u2192 P a a'} {\u03c1 : \u03a0a, P a a}\n    {c : \u03a0\u2983a\u2081 a\u2082 a\u2083\u2984, P a\u2081 a\u2082 \u2192 P a\u2082 a\u2083 \u2192 P a\u2081 a\u2083}\n    (id_left : \u03a0\u2983a\u2081 a\u2082\u2984 (p : P a\u2081 a\u2082), c (\u03c1 a\u2081) p = p)\n    \u2983a\u2081 a\u2082 : A\u2984 (r : R a\u2081 a\u2082) :\n    realize P f \u03c1 c [r] = f r :=\n  id_left (f r)\n\n  @[hott] theorem realize_pair {P : A \u2192 A \u2192 Type _} {f : \u03a0\u2983a a'\u2984, R a a' \u2192 P a a'} {\u03c1 : \u03a0a, P a a}\n    {c : \u03a0\u2983a\u2081 a\u2082 a\u2083\u2984, P a\u2081 a\u2082 \u2192 P a\u2082 a\u2083 \u2192 P a\u2081 a\u2083}\n    (id_left : \u03a0\u2983a\u2081 a\u2082\u2984 (p : P a\u2081 a\u2082), c (\u03c1 a\u2081) p = p)\n    \u2983a\u2081 a\u2082 a\u2083 : A\u2984 (r\u2082 : R a\u2082 a\u2083) (r\u2081 : R a\u2081 a\u2082) :\n    realize P f \u03c1 c [r\u2082, r\u2081] = c (f r\u2081) (f r\u2082) :=\n  ap (\u03bbx, c x (f r\u2082)) (realize_singleton id_left r\u2081)\n\n  @[hott] def realize_append {P : A \u2192 A \u2192 Type _} {f : \u03a0\u2983a a'\u2984, R a a' \u2192 P a a'} {\u03c1 : \u03a0a, P a a}\n    {c : \u03a0\u2983a\u2081 a\u2082 a\u2083\u2984, P a\u2081 a\u2082 \u2192 P a\u2082 a\u2083 \u2192 P a\u2081 a\u2083}\n    (assoc : \u03a0\u2983a\u2081 a\u2082 a\u2083 a\u2084\u2984 (p : P a\u2081 a\u2082) (q : P a\u2082 a\u2083) (r : P a\u2083 a\u2084), c (c p q) r = c p (c q r))\n    (id_right : \u03a0\u2983a\u2081 a\u2082\u2984 (p : P a\u2081 a\u2082), c p (\u03c1 a\u2082) = p)\n    \u2983a\u2081 a\u2082 a\u2083 : A\u2984 (l\u2082 : paths R a\u2082 a\u2083) (l\u2081 : paths R a\u2081 a\u2082) :\n    realize P f \u03c1 c (l\u2082 ++ l\u2081) = c (realize P f \u03c1 c l\u2081) (realize P f \u03c1 c l\u2082) :=\n  begin\n    hinduction l\u2082 with a\u2082 a\u2082 a\u2083 a\u2084 r l\u2082 IH,\n    { exact (id_right _)\u207b\u00b9 },\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 \u2192 A \u2192 Type v}\n    (Q : \u03a0\u2983a a' : A\u2984, paths R a a' \u2192 paths R a a' \u2192 Type w)\n    : \u03a0\u2983a a' : A\u2984, paths R a a' \u2192 paths R a a' \u2192 Type (max u v w)\n  | rrefl  : \u03a0{a a' : A} (l : paths R a a'), paths_rel l l\n  | rel    : \u03a0{a\u2081 a\u2082 a\u2083 : A} {l\u2082 l\u2083 : paths R a\u2082 a\u2083} (l : paths R a\u2081 a\u2082) (q : Q l\u2082 l\u2083),\n      paths_rel (l\u2082 ++ l) (l\u2083 ++ l)\n  | rcons  : \u03a0{a\u2081 a\u2082 a\u2083 : A} {l\u2081 l\u2082 : paths R a\u2081 a\u2082} (r : R a\u2082 a\u2083),\n      paths_rel l\u2081 l\u2082 \u2192 paths_rel (cons r l\u2081) (cons r l\u2082)\n  | rtrans : \u03a0{a\u2081 a\u2082 : A} {l\u2081 l\u2082 l\u2083 : paths R a\u2081 a\u2082},\n      paths_rel l\u2081 l\u2082 \u2192 paths_rel l\u2082 l\u2083 \u2192 paths_rel l\u2081 l\u2083\n\n  open paths_rel\n  attribute [refl] rrefl\n  attribute [trans] rtrans\n  variables {Q : \u03a0\u2983a a' : A\u2984, paths R a a' \u2192 paths R a a' \u2192 Type _}\n\n  @[hott] def paths_rel_of_Q {l\u2081 l\u2082 : paths R a\u2081 a\u2082} (q : Q l\u2081 l\u2082) :\n    paths_rel Q l\u2081 l\u2082 :=\n  begin\n    rwr [\u2190append_nil l\u2081, \u2190append_nil l\u2082], exact rel nil q,\n  end\n\n  @[hott] theorem rel_respect_append_left (l : paths R a\u2082 a\u2083) {l\u2083 l\u2084 : paths R a\u2081 a\u2082}\n    (H : paths_rel Q l\u2083 l\u2084) : paths_rel Q (l ++ l\u2083) (l ++ l\u2084) :=\n  begin\n    hinduction l with a\u2081 a\u2081 a\u2082 a\u2083 r l IH,\n    { exact H },\n    { exact rcons r (IH H) }\n  end\n\n  @[hott] theorem rel_respect_append_right {l\u2081 l\u2082 : paths R a\u2082 a\u2083} (l : paths R a\u2081 a\u2082)\n    (H\u2081 : paths_rel Q l\u2081 l\u2082) : paths_rel Q (l\u2081 ++ l) (l\u2082 ++ l) :=\n  begin\n    hinduction H\u2081 with a\u2081 a\u2082 l\u2081\n                      a\u2082 a\u2083 a\u2084 l\u2082 l\u2082' l\u2081 q\n                      a\u2082 a\u2083 a\u2084 l\u2081 l\u2082 r H\u2081 IH\n                      a\u2082 a\u2083 l\u2081 l\u2082 l\u2082' H\u2081 H\u2081' 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\u2081 l\u2082 : paths R a\u2082 a\u2083} {l\u2083 l\u2084 : paths R a\u2081 a\u2082}\n    (H\u2081 : paths_rel Q l\u2081 l\u2082) (H\u2082 : paths_rel Q l\u2083 l\u2084) :\n    paths_rel Q (l\u2081 ++ l\u2083) (l\u2082 ++ l\u2084) :=\n  begin\n    hinduction H\u2081 with a\u2081 a\u2082 l\n                       a\u2082 a\u2083 a\u2084 l\u2082 l\u2082' l q\n                       a\u2082 a\u2083 a\u2084 l\u2081 l\u2082 r H\u2081 IH\n                       a\u2082 a\u2083 l\u2081 l\u2082 l\u2082' H\u2081 H\u2081' IH IH',\n    { exact rel_respect_append_left _ H\u2082},\n    { rwr [append_assoc, append_assoc], transitivity _, exact rel _ q,\n      apply rel_respect_append_left, apply rel_respect_append_left, exact H\u2082},\n    { exact rcons r (IH H\u2082) },\n    { refine rtrans (IH H\u2082) _, apply rel_respect_append_right, exact H\u2081'}\n  end\n\n  /- assuming some extra properties the relation respects reversing -/\n\n  @[hott] theorem rel_respect_reverse (rev : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) {l\u2081 l\u2082 : paths R a\u2081 a\u2082}\n    (H : paths_rel Q l\u2081 l\u2082)\n    (rev_rel : \u03a0\u2983a a' : A\u2984 {l l' : paths R a a'},\n      Q l l' \u2192 paths_rel Q (reverse rev l) (reverse rev l')) :\n    paths_rel Q (reverse rev l\u2081) (reverse rev l\u2082) :=\n  begin\n    hinduction H with a\u2081 a\u2082 l\n                      a\u2082 a\u2083 a\u2084 l\u2082 l\u2082' l q\n                      a\u2082 a\u2083 a\u2084 l\u2081 l\u2082 r H\u2081 IH\n                      a\u2082 a\u2083 l\u2081 l\u2082 l\u2082' H\u2081 H\u2081' 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,\u2190append_singleton, \u2190append_singleton], \n      apply rel_respect_append_right, exact IH },\n    { exact rtrans IH IH' }\n  end\n\n  @[hott] theorem rel_left_inv (rev : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) (l : paths R a\u2081 a\u2082)\n    (li : \u03a0\u2983a a' : A\u2984 (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\u2081 a\u2081 a\u2082 a\u2083 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 : \u03a0\u2983a a'\u2984, R a a' \u2192 R a' a) (l : paths R a\u2081 a\u2082)\n    (ri : \u03a0\u2983a a' : A\u2984 (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 \u2192 A \u2192 Type _} {f : \u03a0\u2983a a'\u2984, R a a' \u2192 P a a'} {\u03c1 : \u03a0a, P a a}\n    {c : \u03a0\u2983a\u2081 a\u2082 a\u2083\u2984, P a\u2081 a\u2082 \u2192 P a\u2082 a\u2083 \u2192 P a\u2081 a\u2083}\n    (assoc : \u03a0\u2983a\u2081 a\u2082 a\u2083 a\u2084\u2984 (p : P a\u2081 a\u2082) (q : P a\u2082 a\u2083) (r : P a\u2083 a\u2084), c (c p q) r = c p (c q r))\n    (id_right : \u03a0\u2983a\u2081 a\u2082\u2984 (p : P a\u2081 a\u2082), c p (\u03c1 a\u2082) = p)\n    (resp_rel : \u03a0\u2983a\u2081 a\u2082\u2984 {l\u2081 l\u2082 : paths R a\u2081 a\u2082}, Q l\u2081 l\u2082 \u2192\n      realize P f \u03c1 c l\u2081 = realize P f \u03c1 c l\u2082)\n    \u2983a a' : A\u2984 {l l' : paths R a a'} (H : paths_rel Q l l') :\n    realize P f \u03c1 c l = realize P f \u03c1 c l' :=\n  begin\n    hinduction H with a\u2081 a\u2082 l\n                      a\u2082 a\u2083 a\u2084 l\u2082 l\u2082' l q\n                      a\u2082 a\u2083 a\u2084 l\u2081 l\u2082 r H\u2081 IH\n                      a\u2082 a\u2083 l\u2081 l\u2082 l\u2082' H\u2081 H\u2081' 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 (\u03bbx, c x (f r)) IH },\n    { exact IH \u2b1d 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 \u2192 A \u2192 Type v) : A \u2192 A \u2192 Type (max u v)\n| of_rel : \u03a0{a a'} (r : R a a'), pwords a a'\n| of_path : \u03a0{a a'} (pp : a = a'), pwords a a'\n| symm : \u03a0{a a'} (r : pwords a a'), pwords a' a\n| trans : \u03a0{a a' a''} (r : pwords a a') (r' : pwords a' a''), pwords a a''\n\nnamespace graph\n  export pwords\n  infix ` \u2b1dr `:75 := pwords.trans\n  postfix `\u207b\u00b9\u02b3`:(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 \u2192 A \u2192 Type _} {a : A} := of_path R (idpath a)\nend graph\n\nnamespace graph\n\nsection\nparameters {A : Type _}\n            {R : A \u2192 A \u2192 Type _}\nprivate abbreviation T := pwords R\n\nvariables \u2983a a' a'' : A\u2984 {s : R a a'} {r : T a a} {B : Type _} {C : Type _}\n\n@[hott] protected def pwords.elim {f : A \u2192 B}\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 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\u2081 IH\u2082,\n    exact e r,\n    exact ap f pp,\n    exact IH\u207b\u00b9,\n    exact IH\u2081 \u2b1d IH\u2082\nend\n\n@[hott, hsimp] protected def pwords.elim_symm {f : A \u2192 B}\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a') (t : T a a') : \n    pwords.elim e t\u207b\u00b9\u02b3 = (pwords.elim e t)\u207b\u00b9 :=\nby refl\n\n@[hott, hsimp] protected def pwords.elim_trans {f : A \u2192 B}\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a') (t : T a a') (t' : T a' a'') : \n    pwords.elim e (t \u2b1dr t') = pwords.elim e t \u2b1d pwords.elim e t' :=\nby refl\n\n@[hott] def ap_pwords_elim_h {B C : Type _} {f : A \u2192 B} {g : B \u2192 C}\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  {e' : \u03a0\u2983a a' : A\u2984, R a a' \u2192 g (f a) = g (f a')}\n  (p : \u03a0\u2983a a' : A\u2984 (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\u2081 IH\u2082,\n    apply p,\n    induction pp, refl,\n    exact ap_inv g (pwords.elim e r) \u2b1d inverse2 IH,\n    exact ap_con g (pwords.elim e r) (pwords.elim e r') \u2b1d (IH\u2081 \u25fe IH\u2082)\nend\n\n@[hott, hsimp] def ap_pwords_elim_h_symm {B C : Type _} {f : A \u2192 B} {g : B \u2192 C}\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  {e' : \u03a0\u2983a a' : A\u2984, R a a' \u2192 g (f a) = g (f a')}\n  (p : \u03a0\u2983a a' : A\u2984 (s : R a a'), ap g (e s) = e' s) (t : T a a') : \n  ap_pwords_elim_h e p t\u207b\u00b9\u02b3 = ap_inv g (pwords.elim e t) \u2b1d (ap_pwords_elim_h e p t)\u207b\u00b2 :=\nby refl\n\n@[hott, hsimp] def ap_pwords_elim_h_trans {B C : Type _} {f : A \u2192 B} {g : B \u2192 C}\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  {e' : \u03a0\u2983a a' : A\u2984, R a a' \u2192 g (f a) = g (f a')}\n  (p : \u03a0\u2983a a' : A\u2984 (s : R a a'), ap g (e s) = e' s) (t\u2081 : T a a') (t\u2082 : T a' a'') : \n  ap_pwords_elim_h e p (t\u2081 \u2b1dr t\u2082) = ap_con g (pwords.elim e t\u2081) (pwords.elim e t\u2082) \u2b1d \n    ap_pwords_elim_h e p t\u2081 \u25fe ap_pwords_elim_h e p t\u2082 :=\nby refl\n\n@[hott] def ap_pwords_elim {B C : Type _} {f : A \u2192 B} (g : B \u2192 C)\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a') (t : T a a')\n  : ap g (pwords.elim e t) = pwords.elim (\u03bba a' r, ap g (e r)) t :=\nap_pwords_elim_h e (\u03bba a' s, idp) t\n\n@[hott, hsimp] def ap_pwords_elim_symm {B C : Type _} {f : A \u2192 B} (g : B \u2192 C)\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a') (t : T a a')\n  : ap_pwords_elim g e t\u207b\u00b9\u02b3 = ap_inv g (pwords.elim e t) \u2b1d (ap_pwords_elim g e t)\u207b\u00b2 :=\nby refl\n\n@[hott, hsimp] def ap_pwords_elim_trans {B C : Type _} {f : A \u2192 B} (g : B \u2192 C)\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a') (t : T a a') (t' : T a' a'')\n  : ap_pwords_elim g e (t \u2b1dr t') = ap_con g (pwords.elim e t) (pwords.elim e t') \u2b1d\n    (ap_pwords_elim g e t \u25fe ap_pwords_elim g e t') :=\nby refl\n\n@[hott] def pwords_elim_eq {f : A \u2192 B}\n  {e e' : \u03a0\u2983a a' : A\u2984, R a a' \u2192 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\u2081 IH\u2082,\n    apply p,\n    refl,\n    exact IH\u207b\u00b2,\n    exact IH\u2081 \u25fe IH\u2082\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 \u2192 B} {g : B \u2192 C}\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  {e' : \u03a0\u2983a a' : A\u2984, R a a' \u2192 g (f a) = g (f a')}\n  (p : \u03a0\u2983a a' : A\u2984 (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 \u2b1d ap (\u03bbx, 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 _)) \u2b1d _,\n  refl\nend\n\n@[hott] def ap_ap_pwords_elim_h {B C D : Type _} {f : A \u2192 B}\n  {g : B \u2192 C} (h : C \u2192 D)\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  {e' : \u03a0\u2983a a' : A\u2984, R a a' \u2192 g (f a) = g (f a')}\n  (p : \u03a0\u2983a a' : A\u2984 (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 (\u03bba a' s, ap_compose h g (e s)) t)\n            (ap_compose h g (pwords.elim e t))\u207b\u00b9\n            (ap_pwords_elim_h e' (\u03bba a' s, (ap (ap h) (p s))\u207b\u00b9) t) :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH\u2081 IH\u2082,\n  { dsimp,\n    apply square_of_eq, exact con.right_inv _ \u2b1d (con.left_inv _)\u207b\u00b9 },\n  { induction pp, apply ids},\n  { dsimp, rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_inv _ _ _))\u207b\u00b9\u1d5b \u2b1dh _,\n    rwr [con_inv, eq.inv_inv, \u2190inv2_inv],\n    exact ap_inv2 _ \u2b1dv square_inv2 IH },\n  { dsimp, rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_con _ _ _ _))\u207b\u00b9\u1d5b \u2b1dh _,\n    rwr [con_inv, eq.inv_inv, con2_inv],\n    refine ap_con2 _ _ \u2b1dv square_con2 IH\u2081 IH\u2082 },\nend\n\n@[hott] def ap_ap_pwords_elim {B C D : Type _} {f : A \u2192 B}\n  (g : B \u2192 C) (h : C \u2192 D)\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 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 (\u03bba a' s, ap_compose h g (e s)) t)\n            (ap_compose h g (pwords.elim e t))\u207b\u00b9\n            (ap_pwords_elim h (\u03bba 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 \u2192 B}\n  {g : B \u2192 C} (h : C \u2192 D)\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  {e' : \u03a0\u2983a a' : A\u2984, R a a' \u2192 h (g (f a)) = h (g (f a'))}\n  (p : \u03a0\u2983a a' : A\u2984 (s : R a a'), ap (h \u2218 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))\u207b\u00b9 \n           (ap_pwords_elim_h (\u03bba a' s, ap g (e s)) (\u03bba a' s, (ap_compose h g (e s))\u207b\u00b9 \u2b1d p s) t) :=\nbegin\n  induction t with a a' r a a' pp a a' r IH a a' a'' r r' IH\u2081 IH\u2082,\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 _ _ _))\u207b\u00b9\u1d5b \u2b1dh _,\n    rwr [con_inv, eq.inv_inv, \u2190inv2_inv],\n    exact ap_inv2 _ \u2b1dv square_inv2 IH },\n  { dsimp [ap02], rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_con _ _ _ _))\u207b\u00b9\u1d5b \u2b1dh _,\n    rwr [con_inv, eq.inv_inv, con2_inv],\n    refine ap_con2 _ _ \u2b1dv square_con2 IH\u2081 IH\u2082 },\nend\n\n@[hott] def ap_pwords_elim_h_zigzag {B C D : Type _} {f : A \u2192 B}\n  {g : B \u2192 C} (h : C \u2192 D)\n  (e : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  {e' : \u03a0\u2983a a' : A\u2984, R a a' \u2192 h (g (f a)) = h (g (f a'))}\n  (p : \u03a0\u2983a a' : A\u2984 (s : R a a'), ap (h \u2218 g) (e s) = e' s) (t : T a a')\n  : ap_pwords_elim   h (\u03bba a' s, ap g (e s)) t \u2b1d\n    (ap_pwords_elim_h e (\u03bba a' s, ap_compose h g (e s)) t)\u207b\u00b9 \u2b1d\n    ap_pwords_elim_h e p t =\n    ap_pwords_elim_h (\u03bba a' s, ap g (e s)) (\u03bba a' s, (ap_compose h g (e s))\u207b\u00b9 \u2b1d p s) t :=\nbegin\n  refine whisker_right _ (eq_of_square (ap_ap_pwords_elim g h e t)\u207b\u00b9\u02b0)\u207b\u00b9 \u2b1d _,\n  refine con.assoc _ _ _ \u2b1d _, 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\u2081 IH\u2082,\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 _ _ _))\u207b\u00b9\u1d5b \u2b1dh _,\n    rwr [con_inv, eq.inv_inv, \u2190inv2_inv],\n    exact ap_inv2 _ \u2b1dv square_inv2 IH },\n  { dsimp, rwr [ap_con (ap h)],\n    refine (transpose (ap_compose_con _ _ _ _))\u207b\u00b9\u1d5b \u2b1dh _,\n    rwr [con_inv, eq.inv_inv, con2_inv],\n    refine ap_con2 _ _ \u2b1dv square_con2 IH\u2081 IH\u2082 },\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\u207b\u00b9\u02b3,\n    intros a a' a'' t t', exact t \u2b1dr t',\nend\n\n/- dependent elimination -/\n\nvariables {P : B \u2192 Type _} {Q : C \u2192 Type _} {f : A \u2192 B} {g : B \u2192 C} {f' : \u03a0(a : A), P (f a)}\n@[hott] protected def pwords.elimo (p : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  (po : \u03a0\u2983a a' : A\u2984 (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\u2081 IH\u2082,\n    exact po r,\n    induction pp, constructor,\n    exact IH\u207b\u00b9\u1d52,\n    exact IH\u2081 \u2b1do IH\u2082\nend\n\n@[hott, hsimp] def elimo_symm (p : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  (po : \u03a0\u2983a a' : A\u2984 (s : R a a'), f' a =[p s] f' a') (t : T a a')\n  : pwords.elimo p po t\u207b\u00b9\u02b3 = (pwords.elimo p po t)\u207b\u00b9\u1d52 :=\nby refl\n\n@[hott, hsimp] def elimo_trans (p : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  (po : \u03a0\u2983a a' : A\u2984 (s : R a a'), f' a =[p s] f' a') (t : T a a') (t' : T a' a'')\n  : pwords.elimo p po (t \u2b1dr t') = pwords.elimo p po t \u2b1do pwords.elimo p po t' :=\nby refl\n\n@[hott] def ap_pwords_elimo_h  {g' : \u03a0b, Q (g b)}\n  (p : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  (po : \u03a0\u2983a a' : A\u2984 (s : R a a'), g' (f a) =[p s; Q \u2218 g] g' (f a'))\n  (q : \u03a0\u2983a a' : A\u2984 (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\u2081 IH\u2082,\n    apply q,\n    induction pp, refl,\n    exact apd_inv g' (pwords.elim p r) \u2b1d IH\u207b\u00b2\u1d52,\n    exact apd_con g' (pwords.elim p r) (pwords.elim p r') \u2b1d (IH\u2081 \u25feo IH\u2082)\nend\n\n@[hott] theorem pwords_elimo_ap {g' : \u03a0(a : A), Q (g (f a))}\n  (p : \u03a0\u2983a a' : A\u2984, R a a' \u2192 f a = f a')\n  (po : \u03a0\u2983a a' : A\u2984 (s : R a a'), g' a =[ap g (p s)] g' a')\n  (t : T a a') : pwords.elimo p (\u03bba 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)\u207b\u00b9\n      (pwords.elimo (\u03bba 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\u2081 IH\u2082,\n  { refl },\n  { induction pp; refl },\n  { rwr [elimo_symm, ap_pwords_elim_symm, IH, con_inv, change_path_con, \u2190inv2_inv], dsimp,\n    rwr [change_path_invo, pathover_of_pathover_ap_invo] },\n  { rwr [elimo_trans, elimo_trans, ap_pwords_elim_trans, IH\u2081, IH\u2082, 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 \u2192 formula\n| [] := []\n| (x :: f) :=\n  (if l \u2208 x then [] else [list.remove_all x [l_not l]]) ++ assign_lit f\n\ndef assign_all (f : formula) (lits : list literal) :=\nlist.foldl (\u03bb f l, assign_lit l f) f lits\n\nlemma assign_removes : \u2200 (f : formula) (l : literal),\n  l \u2209 (assign_lit l f).join \u2227 l_not l \u2209 (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 \u2208 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 \u2208 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 : \u2200 (f : formula) (l : literal),\n  (assign_lit l f).join \u2286 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 \u2208 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] \u2286 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 {\u03b1 : Type} (a b : list  \u03b1) (c : \u03b1) : c \u2209 a ++ b \u2194 c \u2209 a \u2227 c \u2209 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 : \u2200 (f : formula) (l : literal) (c : clause),\n  c \u2208 f \u2192 c \u2209 assign_lit l f \u2192 l_not l \u2208 c \u2228 l \u2208 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 \u2208 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 \u2190h_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 {\u03b1 : Type} [decidable_eq \u03b1]\n  (l : list \u03b1) (r : \u03b1) : (l.remove_all [r]).length + (if r \u2208 l then 1 else 0) \u2264 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 \u2208 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 {\u03b1 : Type} [decidable_eq \u03b1]\n  (l : list \u03b1) (r : \u03b1) : (l.remove_all [r]).length \u2264 l.length :=\nbegin\n  have h := remove_all_length_impl l r,\n  cases' classical.em (r \u2208 l);\n  simp [h_1] at h;\n  linarith,\nend\n\nlemma remove_all_less_length {\u03b1 : Type} [decidable_eq \u03b1]\n  (l : list \u03b1) (r : \u03b1) (h : r \u2208 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 \u2209 f.join \u2227 l_not l \u2209 f.join \u2192 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\u2200 (f : formula) (l : literal),\nl \u2208 f.join \u2228 l_not l \u2208 f.join \u2192\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 \u2208 f.join \u2228 l_not l \u2208 f.join),\n    {\n      rw assign_lit,\n      simp,\n      have leq : (list.map list.length (ite (l \u2208 hd) list.nil\n                  [list.remove_all hd [l_not l]])).sum \u2264 hd.length :=\n      begin\n        cases' classical.em (l \u2208 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 \u2208 hd \u2228 l_not l \u2208 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 \u2208 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) \u2264 formula_size f :=\nbegin\n  cases' classical.em (l \u2209 f.join \u2227 l_not l \u2209 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 \u2208 f.join \u2228 l_not l \u2208 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 {\u03b1 : Type} : \u2200 (a b : list \u03b1) (c : \u03b1),\n  c \u2209 b \u2192 c \u2208 a ++ b \u2192 c \u2208 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 \u2208 f \u2192 c \u2209 assign_lit l f \u2192 l \u2209 c \u2192 l_not l \u2208 c \u2192\n  c.remove_all [l_not l] \u2208 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 \u2208 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 \u2208 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 \u2208 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  \u2209 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 \u2190h_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\u2200 (f : formula) (l : literal), sat (assign_lit l f) \u2192 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 \u2208 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 \u2208 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 \u2260 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 \u2208 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 \u2208 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 \u2208 c),\n    {\n      apply exists.intro l,\n      simp [h_2],\n      have l_in : l \u2208 (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 \u2208 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 \u2286 c := by apply list.filter_subset,\n      have neq_l : w_1 \u2260 l := begin\n        intro h,\n        rw h at right,\n        have in_c : l \u2208 c := begin\n          apply removed_sub,\n          exact right,\n        end,\n        contradiction,\n      end,\n      have neq_n_l : w_1 \u2260 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 \u2209 f \u2192 c \u2208 assign_lit l f \u2192\n(\u2203 (c' : clause), c'.remove_all [l_not l] = c \u2227 c' \u2208 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 \u2208 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(\u2203 (a : assignment), formula_sat a f \u2227 l \u2208 a) \u2192\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 \u2208 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 \u2190left_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) \u2264 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) \u2264 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\u00f6lzl, 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 \u00d7 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 \u2264 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 \u00d7 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 \u03c3 : 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 \u2243o add_subsemigroup (additive M) :=\n{ to_fun := \u03bb S,\n  { carrier := additive.to_mul \u207b\u00b9' S,\n    add_mem' := S.mul_mem' },\n  inv_fun := \u03bb S,\n  { carrier := additive.of_mul \u207b\u00b9' S,\n    mul_mem' := S.add_mem' },\n  left_inv := \u03bb x, by cases x; refl,\n  right_inv := \u03bb x, by cases x; refl,\n  map_rel_iff' := \u03bb 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) \u2243o 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 \u207b\u00b9' 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 \u207b\u00b9' 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 \u2243o subsemigroup (multiplicative A) :=\n{ to_fun := \u03bb S,\n  { carrier := multiplicative.to_add \u207b\u00b9' S,\n    mul_mem' := S.add_mem' },\n  inv_fun := \u03bb S,\n  { carrier := multiplicative.of_add \u207b\u00b9' S,\n    add_mem' := S.mul_mem' },\n  left_inv := \u03bb x, by cases x; refl,\n  right_inv := \u03bb x, by cases x; refl,\n  map_rel_iff' := \u03bb 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) \u2243o 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 \u207b\u00b9' 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 \u207b\u00b9' 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 \u2192\u2099* N) (S : subsemigroup N) : subsemigroup M :=\n{ carrier := (f \u207b\u00b9' S),\n  mul_mem' := \u03bb a b ha hb,\n    show f (a * b) \u2208 S, by rw map_mul; exact mul_mem ha hb }\n\n@[simp, to_additive]\nlemma coe_comap (S : subsemigroup N) (f : M \u2192\u2099* N) : (S.comap f : set M) = f \u207b\u00b9' S := rfl\n\n@[simp, to_additive]\nlemma mem_comap {S : subsemigroup N} {f : M \u2192\u2099* N} {x : M} : x \u2208 S.comap f \u2194 f x \u2208 S := iff.rfl\n\n@[to_additive]\nlemma comap_comap (S : subsemigroup P) (g : N \u2192\u2099* P) (f : M \u2192\u2099* 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 \u2192\u2099* N) (S : subsemigroup M) : subsemigroup N :=\n{ carrier := (f '' S),\n  mul_mem' := begin rintros _ _ \u27e8x, hx, rfl\u27e9 \u27e8y, hy, rfl\u27e9,\n    exact \u27e8x * y, @mul_mem (subsemigroup M) M _ _ _ _ _ _ hx hy, by rw map_mul; refl\u27e9 end }\n\n@[simp, to_additive]\nlemma coe_map (f : M \u2192\u2099* N) (S : subsemigroup M) :\n  (S.map f : set N) = f '' S := rfl\n\n@[simp, to_additive]\nlemma mem_map {f : M \u2192\u2099* N} {S : subsemigroup M} {y : N} :\n  y \u2208 S.map f \u2194 \u2203 x \u2208 S, f x = y :=\nmem_image_iff_bex\n\n@[to_additive]\nlemma mem_map_of_mem (f : M \u2192\u2099* N) {S : subsemigroup M} {x : M} (hx : x \u2208 S) : f x \u2208 S.map f :=\nmem_image_of_mem f hx\n\n@[to_additive]\nlemma apply_coe_mem_map (f : M \u2192\u2099* N) (S : subsemigroup M) (x : S) : f x \u2208 S.map f :=\nmem_map_of_mem f x.prop\n\n@[to_additive]\nlemma map_map (g : N \u2192\u2099* P) (f : M \u2192\u2099* 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 \u2192\u2099* N} (hf : function.injective f) {S : subsemigroup M} {x : M} :\n  f x \u2208 S.map f \u2194 x \u2208 S :=\nhf.mem_set_image\n\n@[to_additive]\nlemma map_le_iff_le_comap {f : M \u2192\u2099* N} {S : subsemigroup M} {T : subsemigroup N} :\n  S.map f \u2264 T \u2194 S \u2264 T.comap f :=\nimage_subset_iff\n\n@[to_additive]\nlemma gc_map_comap (f : M \u2192\u2099* N) : galois_connection (map f) (comap f) :=\n\u03bb S T, map_le_iff_le_comap\n\n@[to_additive]\nlemma map_le_of_le_comap {T : subsemigroup N} {f : M \u2192\u2099* N} : S \u2264 T.comap f \u2192 S.map f \u2264 T :=\n(gc_map_comap f).l_le\n\n@[to_additive]\nlemma le_comap_of_map_le {T : subsemigroup N} {f : M \u2192\u2099* N} : S.map f \u2264 T \u2192 S \u2264 T.comap f :=\n(gc_map_comap f).le_u\n\n@[to_additive]\nlemma le_comap_map {f : M \u2192\u2099* N} : S \u2264 (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 \u2192\u2099* N} : (S.comap f).map f \u2264 S :=\n(gc_map_comap f).l_u_le _\n\n@[to_additive]\nlemma monotone_map {f : M \u2192\u2099* N} : monotone (map f) :=\n(gc_map_comap f).monotone_l\n\n@[to_additive]\nlemma monotone_comap {f : M \u2192\u2099* N} : monotone (comap f) :=\n(gc_map_comap f).monotone_u\n\n@[simp, to_additive]\nlemma map_comap_map {f : M \u2192\u2099* 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 \u2192\u2099* 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 \u2192\u2099* N) : (S \u2294 T).map f = S.map f \u2294 T.map f :=\n(gc_map_comap f).l_sup\n\n@[to_additive]\nlemma map_supr {\u03b9 : Sort*} (f : M \u2192\u2099* N) (s : \u03b9 \u2192 subsemigroup M) :\n  (supr s).map f = \u2a06 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 \u2192\u2099* N) : (S \u2293 T).comap f = S.comap f \u2293 T.comap f :=\n(gc_map_comap f).u_inf\n\n@[to_additive]\nlemma comap_infi {\u03b9 : Sort*} (f : M \u2192\u2099* N) (s : \u03b9 \u2192 subsemigroup N) :\n  (infi s).comap f = \u2a05 i, (s i).comap f :=\n(gc_map_comap f).u_infi\n\n@[simp, to_additive] lemma map_bot (f : M \u2192\u2099* N) : (\u22a5 : subsemigroup M).map f = \u22a5 :=\n(gc_map_comap f).l_bot\n\n@[simp, to_additive] lemma comap_top (f : M \u2192\u2099* N) : (\u22a4 : subsemigroup N).comap f = \u22a4 :=\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 (\u03bb x, \u27e8\u03bb \u27e8_, h, rfl\u27e9, h, \u03bb h, \u27e8_, h, rfl\u27e9\u27e9)\n\nsection galois_coinsertion\n\nvariables {\u03b9 : Type*} {f : M \u2192\u2099* 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  (\u03bb 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 \u2293 T.map f).comap f = S \u2293 T :=\n(gci_map_comap hf).u_inf_l _ _\n\n@[to_additive]\nlemma comap_infi_map_of_injective (S : \u03b9 \u2192 subsemigroup M) : (\u2a05 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 \u2294 T.map f).comap f = S \u2294 T :=\n(gci_map_comap hf).u_sup_l _ _\n\n@[to_additive]\nlemma comap_supr_map_of_injective (S : \u03b9 \u2192 subsemigroup M) : (\u2a06 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 \u2264 T.map f \u2194 S \u2264 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 {\u03b9 : Type*} {f : M \u2192\u2099* 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  (\u03bb S x h, let \u27e8y, hy\u27e9 := hf x in mem_map.2 \u27e8y, by simp [hy, h]\u27e9)\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 \u2293 T.comap f).map f = S \u2293 T :=\n(gi_map_comap hf).l_inf_u _ _\n\n@[to_additive]\nlemma map_infi_comap_of_surjective (S : \u03b9 \u2192 subsemigroup N) : (\u2a05 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 \u2294 T.comap f).map f = S \u2294 T :=\n(gi_map_comap hf).l_sup_u _ _\n\n@[to_additive]\nlemma map_supr_comap_of_surjective (S : \u03b9 \u2192 subsemigroup N) : (\u2a06 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 \u2264 T.comap f \u2194 S \u2264 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' := \u27e8\u03bb a b, \u27e8a.1 * b.1, mul_mem a.2 b.2\u27e9\u27e9\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') : (\u2191(x * y) : M) = \u2191x * \u2191y := 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 \u2208 S') (hy : y \u2208 S') :\n  (\u27e8x, hx\u27e9 : S') * \u27e8y, hy\u27e9 = \u27e8x * y, mul_mem hx hy\u27e9 := rfl\n\n@[to_additive] lemma mul_def (x y : S') : x * y = \u27e8x * y, mul_mem x.2 y.2\u27e9 := 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 (\u03bb _ _, 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 (\u03bb _ _, 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' \u2192\u2099* M := \u27e8coe, \u03bb _ _, rfl\u27e9\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 : (\u22a4 : subsemigroup M) \u2243* M :=\n{ to_fun    := \u03bb x, x,\n  inv_fun   := \u03bb x, \u27e8x, mem_top x\u27e9,\n  left_inv  := \u03bb x, x.eta _,\n  right_inv := \u03bb _, rfl,\n  map_mul'  := \u03bb _ _, rfl }\n\n@[simp, to_additive] lemma top_equiv_to_mul_hom :\n  (top_equiv : _ \u2243* M).to_mul_hom = mul_mem_class.subtype (\u22a4 : 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 \u2192\u2099* N) (hf : function.injective f) : S \u2243* S.map f :=\n{ map_mul' := \u03bb _ _, 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 \u2192\u2099* 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 \u2192 M) \u207b\u00b9' s) = \u22a4 :=\neq_top_iff.2 $ \u03bb x, subtype.rec_on x $ \u03bb x hx _, begin\n  refine closure_induction' _ (\u03bb g hg, _) (\u03bb g\u2081 g\u2082 hg\u2081 hg\u2082, _) 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 \u00d7 t` as a subsemigroup\nof `M \u00d7 N`. -/\n@[to_additive prod \"Given `add_subsemigroup`s `s`, `t` of `add_semigroup`s `A`, `B` respectively,\n`s \u00d7 t` as an `add_subsemigroup` of `A \u00d7 B`.\"]\ndef prod (s : subsemigroup M) (t : subsemigroup N) : subsemigroup (M \u00d7 N) :=\n{ carrier := (s : set M) \u00d7\u02e2 (t : set N),\n  mul_mem' := \u03bb p q hp hq, \u27e8s.mul_mem hp.1 hq.1, t.mul_mem hp.2 hq.2\u27e9 }\n\n@[to_additive coe_prod]\nlemma coe_prod (s : subsemigroup M) (t : subsemigroup N) :\n (s.prod t : set (M \u00d7 N)) = (s : set M) \u00d7\u02e2 (t : set N) :=\nrfl\n\n@[to_additive mem_prod]\nlemma mem_prod {s : subsemigroup M} {t : subsemigroup N} {p : M \u00d7 N} :\n  p \u2208 s.prod t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t := iff.rfl\n\n@[to_additive prod_mono]\nlemma prod_mono {s\u2081 s\u2082 : subsemigroup M} {t\u2081 t\u2082 : subsemigroup N} (hs : s\u2081 \u2264 s\u2082) (ht : t\u2081 \u2264 t\u2082) :\n  s\u2081.prod t\u2081 \u2264 s\u2082.prod t\u2082 :=\nset.prod_mono hs ht\n\n@[to_additive prod_top]\nlemma prod_top (s : subsemigroup M) :\n  s.prod (\u22a4 : subsemigroup N) = s.comap (mul_hom.fst M N) :=\next $ \u03bb x, by simp [mem_prod, mul_hom.coe_fst]\n\n@[to_additive top_prod]\nlemma top_prod (s : subsemigroup N) :\n  (\u22a4 : subsemigroup M).prod s = s.comap (mul_hom.snd M N) :=\next $ \u03bb x, by simp [mem_prod, mul_hom.coe_snd]\n\n@[simp, to_additive top_prod_top]\nlemma top_prod_top : (\u22a4 : subsemigroup M).prod (\u22a4 : subsemigroup N) = \u22a4 :=\n(top_prod _).trans $ comap_top _\n\n@[to_additive] lemma bot_prod_bot : (\u22a5 : subsemigroup M).prod (\u22a5 : subsemigroup N) = \u22a5 :=\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 \u2243* s \u00d7 t :=\n{ map_mul' := \u03bb x y, rfl, .. equiv.set.prod \u2191s \u2191t }\n\nopen mul_hom\n\n@[to_additive]\nlemma mem_map_equiv {f : M \u2243* N} {K : subsemigroup M} {x : N} :\n  x \u2208 K.map f.to_mul_hom \u2194 f.symm x \u2208 K :=\n@set.mem_image_equiv _ _ \u2191K f.to_equiv x\n\n@[to_additive]\nlemma map_equiv_eq_comap_symm (f : M \u2243* 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 \u2243* 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 \u2243* N) : (\u22a4 : subsemigroup M).map f.to_mul_hom = \u22a4 :=\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 \u00d7 N)} :\n  u \u2264 s.prod t \u2194 u.map (fst M N) \u2264 s \u2227 u.map (snd M N) \u2264 t :=\nbegin\n  split,\n  { intros h,\n    split,\n    { rintros x \u27e8\u27e8y1,y2\u27e9, \u27e8hy1,rfl\u27e9\u27e9, exact (h hy1).1 },\n    { rintros x \u27e8\u27e8y1,y2\u27e9, \u27e8hy1,rfl\u27e9\u27e9, exact (h hy1).2 }, },\n  { rintros \u27e8hH, hK\u27e9 \u27e8x1, x2\u27e9 h, exact \u27e8hH \u27e8_ , h, rfl\u27e9, hK \u27e8 _, h, rfl\u27e9\u27e9, }\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 \u2192\u2099* N) : subsemigroup N :=\n((\u22a4 : subsemigroup M).map f).copy (set.range f) set.image_univ.symm\n\n@[simp, to_additive]\nlemma coe_srange (f : M \u2192\u2099* N) :\n  (f.srange : set N) = set.range f :=\nrfl\n\n@[simp, to_additive] lemma mem_srange {f : M \u2192\u2099* N} {y : N} :\n  y \u2208 f.srange \u2194 \u2203 x, f x = y :=\niff.rfl\n\n@[to_additive] lemma srange_eq_map (f : M \u2192\u2099* N) : f.srange = (\u22a4 : subsemigroup M).map f :=\ncopy_eq _\n\n@[to_additive]\nlemma map_srange (g : N \u2192\u2099* P) (f : M \u2192\u2099* N) : f.srange.map g = (g.comp f).srange :=\nby simpa only [srange_eq_map] using (\u22a4 : subsemigroup M).map_map g f\n\n@[to_additive]\nlemma srange_top_iff_surjective {N} [has_mul N] {f : M \u2192\u2099* N} :\n  f.srange = (\u22a4 : subsemigroup N) \u2194 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 \u2192\u2099* N) (hf : function.surjective f) :\n  f.srange = (\u22a4 : subsemigroup N) :=\nsrange_top_iff_surjective.2 hf\n\n@[to_additive]\nlemma mclosure_preimage_le (f : M \u2192\u2099* N) (s : set N) :\n  closure (f \u207b\u00b9' s) \u2264 (closure s).comap f :=\nclosure_le.2 $ \u03bb 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 \u2192\u2099* 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 \u03c3 M] [mul_mem_class \u03c3 M] (f : M \u2192\u2099* N) (S : \u03c3) :\n  S \u2192\u2099* N :=\nf.comp (mul_mem_class.subtype S)\n\n@[simp, to_additive]\nlemma restrict_apply {N : Type*} [has_mul N] [set_like \u03c3 M] [mul_mem_class \u03c3 M] (f : M \u2192\u2099* N)\n  {S : \u03c3} (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 \u03c3 N] [mul_mem_class \u03c3 N] (f : M \u2192\u2099* N) (S : \u03c3) (h : \u2200 x, f x \u2208 S) :\n  M \u2192\u2099* S :=\n{ to_fun := \u03bb n, \u27e8f n, h n\u27e9,\n  map_mul' := \u03bb 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 \u2192\u2099* N) : M \u2192\u2099* f.srange :=\nf.cod_restrict f.srange $ \u03bb x, \u27e8x, rfl\u27e9\n\n@[simp, to_additive]\nlemma coe_srange_restrict {N} [has_mul N] (f : M \u2192\u2099* N) (x : M) :\n  (f.srange_restrict x : N) = f x :=\nrfl\n\n@[to_additive]\nlemma srange_restrict_surjective (f : M \u2192\u2099* N) : function.surjective f.srange_restrict :=\n\u03bb \u27e8_, \u27e8x, rfl\u27e9\u27e9, \u27e8x, rfl\u27e9\n\n@[to_additive]\nlemma prod_map_comap_prod' {M' : Type*} {N' : Type*} [has_mul M'] [has_mul N']\n  (f : M \u2192\u2099* N) (g : M' \u2192\u2099* 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 \u2192\u2099* N) (N' : subsemigroup N) :\n  N'.comap f \u2192\u2099* N' :=\n{ to_fun := \u03bb x, \u27e8f x, x.prop\u27e9,\n  map_mul' := \u03bb 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 \u2192\u2099* N) (M' : subsemigroup M) :\n  M' \u2192\u2099* M'.map f :=\n{ to_fun := \u03bb x, \u27e8f x, \u27e8x, x.prop, rfl\u27e9\u27e9,\n  map_mul' := \u03bb x y, subtype.eq $ @map_mul M N _ _ _ _ f x y }\n\n@[to_additive]\nlemma subsemigroup_map_surjective (f : M \u2192\u2099* N) (M' : subsemigroup M) :\n  function.surjective (f.subsemigroup_map M') :=\nby { rintro \u27e8_, x, hx, rfl\u27e9, exact \u27e8\u27e8x, hx\u27e9, rfl\u27e9 }\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 = \u22a4 :=\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 = \u22a4 :=\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 = \u22a4 \u2194 s = \u22a4 \u2227 t = \u22a4 :=\nby simp only [eq_top_iff, le_prod_iff, \u2190 (gc_map_comap _).le_iff_le, \u2190 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 \u2264 T) : S \u2192\u2099* T :=\n(mul_mem_class.subtype S).cod_restrict _ (\u03bb 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 = \u22a4 \u2194 \u2200 x : M, x \u2208 S :=\neq_top_iff.trans \u27e8\u03bb h m, h $ mem_top m, \u03bb h m _, h m\u27e9\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 \u2243* T :=\n{ map_mul' :=  \u03bb _ _, 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 \u2192\u2099* N` with a left-inverse `g : N \u2192 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 \u2192+ N` with a left-inverse `g : N \u2192 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 \u2192\u2099* N) {g : N \u2192 M} (h : function.left_inverse g f) : M \u2243* f.srange :=\n{ to_fun := f.srange_restrict,\n  inv_fun := g \u2218 (mul_mem_class.subtype f.srange),\n  left_inv := h,\n  right_inv := \u03bb x, subtype.ext $\n    let \u27e8x', hx'\u27e9 := mul_hom.mem_srange.mp x.prop in\n    show f (g x) = x, by rw [\u2190hx', h x'],\n  .. f.srange_restrict }\n\n/-- A `mul_equiv` `\u03c6` between two semigroups `M` and `N` induces a `mul_equiv` between\na subsemigroup `S \u2264 M` and the subsemigroup `\u03c6(S) \u2264 N`.\nSee `mul_hom.subsemigroup_map` for a variant for `mul_hom`s. -/\n@[to_additive \"An `add_equiv` `\u03c6` between two additive semigroups `M` and `N` induces an `add_equiv`\nbetween a subsemigroup `S \u2264 M` and the subsemigroup `\u03c6(S) \u2264 N`. See `add_hom.add_subsemigroup_map`\nfor a variant for `add_hom`s.\", simps]\ndef subsemigroup_map (e : M \u2243* N) (S : subsemigroup M) : S \u2243* S.map e.to_mul_hom :=\n{ to_fun := \u03bb x, \u27e8e x, _\u27e9,\n  inv_fun := \u03bb x, \u27e8e.symm x, _\u27e9, -- we restate this for `simps` to avoid `\u21d1e.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 (\u03c4 : Type u) (msr : \u03c4 \u2192 M) [Monoid M]\n| Digit1 : (a : \u03c4) \u2192\n            Cached (msr a) \u2192 Digit \u03c4 msr\n| Digit2 : (a : \u03c4) \u2192 (b : \u03c4) \u2192\n            Cached (msr a ++ msr b) \u2192 Digit \u03c4 msr\n| Digit3 : (a : \u03c4) \u2192 (b : \u03c4) \u2192 (c : \u03c4) \u2192\n            Cached (msr a ++ msr b ++ msr c) \u2192 Digit \u03c4 msr\n| Digit4 : (a : \u03c4) \u2192 (b : \u03c4) \u2192 (c : \u03c4) \u2192 (d : \u03c4) \u2192\n            Cached (msr a ++ msr b ++ msr c ++ msr d) \u2192 Digit \u03c4 msr\n\nnamespace Digit\nvariable {msr : \u03c4 \u2192 M} [Monoid M] (d : Digit \u03c4 msr)\n\n@[inline]\ndef tryAddLeft (a : \u03c4) (av : Cached (msr a)) (sc : Digit \u03c4 msr \u2192 \u03b1) (fc : \u03c4 \u2192 \u03c4 \u2192 \u03c4 \u2192 \u03c4 \u2192 \u03b1) : \u03b1 :=\n  match d with\n  | Digit1 b       v => sc (Digit2 a b \u27e8av.1 ++ v.1,by simp [av.2]\u27e9)\n  | Digit2 b c     v => sc (Digit3 a b c \u27e8av.1 ++ v.1,by simp [av.2]\u27e9)\n  | Digit3 b c d   v => sc (Digit4 a b c d \u27e8av.1 ++ v.1,by simp [av.2]\u27e9)\n  | Digit4 b c d e _ => fc b c d e\n\n@[inline]\ndef tryFront (sc : \u03c4 \u2192 Digit \u03c4 msr \u2192 \u03b1) (fc : (a : \u03c4) \u2192 Cached (msr a) \u2192 \u03b1) : \u03b1 :=\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 : \u03c4) (zv : Cached (msr z)) (sc : Digit \u03c4 msr \u2192 \u03b1) (fc : \u03c4 \u2192 \u03c4 \u2192 \u03c4 \u2192 \u03c4 \u2192 \u03b1) : \u03b1 :=\n  match h':d with\n  | Digit1 y       v => sc (Digit2 y z \u27e8v.1 ++ zv.1,by simp [zv.2]\u27e9)\n  | Digit2 x y     v => sc (Digit3 x y z \u27e8v.1 ++ zv.1,by simp [zv.2]\u27e9)\n  | Digit3 w x y   v => sc (Digit4 w x y z \u27e8v.1 ++ zv.1,by simp [zv.2]\u27e9)\n  | Digit4 v w x y _ => fc v w x y\n\n@[inline]\ndef tryBack (sc : \u03c4 \u2192 Digit \u03c4 msr \u2192 \u03b1) (fc : (a : \u03c4) \u2192 Cached (msr a) \u2192 \u03b1) : \u03b1 :=\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 \u03c4 msr \u2192 List \u03c4\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 (\u03c4 : Type u) (msr : \u03c4 \u2192 M) [Monoid M]\n| Node2 : (a : \u03c4) \u2192 (b : \u03c4) \u2192\n          Cached (msr a ++ msr b) \u2192 Node \u03c4 msr\n| Node3 : (a : \u03c4) \u2192 (b : \u03c4) \u2192 (c : \u03c4) \u2192\n          Cached (msr a ++ msr b ++ msr c) \u2192 Node \u03c4 msr\n\nnamespace Node\n\ndef toDigit {msr : \u03c4 \u2192 M} [Monoid M] : Node \u03c4 msr \u2192 Digit \u03c4 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 : \u03c4 \u2192 M} [Monoid M] : Node \u03c4 msr \u2192 List \u03c4\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] : (\u03c4 : Type u) \u2192 (msr : \u03c4 \u2192 M) \u2192 Type (u+3000)\n| Empty : FingerTree \u03c4 msr\n| Single : (t : \u03c4) \u2192 FingerTree \u03c4 msr \n| Deep : Digit \u03c4 msr \u2192 FingerTree (Node \u03c4) msr \u2192 Digit \u03c4 msr \u2192 FingerTree \u03c4 msr\n\nnamespace FingerTree\n\ndef toList : FingerTree \u03c4 \u2192 List \u03c4\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 \u03c4) (a : \u03c4) : FingerTree \u03c4 :=\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      (\u03bb pr' => Deep pr' tr sf)\n      (\u03bb b c d e => Deep (Digit2 a b) (tr.cons (Node3 c d e)) sf)\n\n@[inline]\ndef front? (f : FingerTree \u03c4) : Option (\u03c4 \u00d7 FingerTree \u03c4) :=\n  match f with\n  | Empty         => none\n  | Single a      => some (a, Empty)\n  | Deep pr tr sf => some (\n    tryFront pr\n      (\u03bb a pr' => (a, Deep pr' tr sf))\n      (\u03bb 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            (\u03bb b sf' => Deep (Digit1 b) Empty sf')\n            (\u03bb b => /- sf = Digit1 b -/\n              Single b))))\n\ntheorem toList_cons (f : FingerTree \u03c4) (a : \u03c4)\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 \u03c4)\n  : f.front?.map (\u03bb (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 \u03c4) (z : \u03c4) : FingerTree \u03c4 :=\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      (\u03bb sf' => Deep pr tr sf')\n      (\u03bb a b c d => Deep pr (tr.snoc (Node3 a b c)) (Digit2 d z))\n\ndef back? (f : FingerTree \u03c4) : Option (FingerTree \u03c4 \u00d7 \u03c4) :=\n  match f with\n  | Empty         => none\n  | Single z      => some (Empty, z)\n  | Deep pr tr sf => some (\n    tryBack pr\n      (\u03bb z sf' => (Deep pr tr sf', z))\n      (\u03bb 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            (\u03bb y pr' => Deep pr' Empty (Digit1 y))\n            (\u03bb y => /- pr = Digit1 y -/\n              Single y),\n        z)))\n\ntheorem toList_snoc (f : FingerTree \u03c4) (a : \u03c4)\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 \u03c4)\n  : f.back?.map (\u03bb (f',a) => (f'.toList,a)) = f.toList.back?\n  := by sorry\n\n\ndef append (f1 f2 : FingerTree \u03c4) : FingerTree \u03c4 :=\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 : \u03b9 \u2192 finset \u03b1` have `\u03b9` be a `fintype`.\nThe `combinatorics.hall.basic` module applies a compactness argument to this version\nto remove the `fintype` constraint on `\u03b9`.\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 {\u03b9 : Type u} {\u03b1 : Type v} [fintype \u03b9]\n\ntheorem hall_hard_inductive_zero (t : \u03b9 \u2192 finset \u03b1) (hn : fintype.card \u03b9 = 0) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  rw fintype.card_eq_zero_iff at hn,\n  exactI \u27e8is_empty_elim, is_empty_elim, is_empty_elim\u27e9,\nend\n\nvariables {t : \u03b9 \u2192 finset \u03b1} [decidable_eq \u03b1]\n\nlemma hall_cond_of_erase {x : \u03b9} (a : \u03b1)\n  (ha : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card)\n  (s' : finset {x' : \u03b9 | x' \u2260 x}) :\n  s'.card \u2264 (s'.bUnion (\u03bb x', (t x').erase a)).card :=\nbegin\n  haveI := classical.dec_eq \u03b9,\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 (\u03bb x, t x)).card,\n    { specialize ha he (\u03bb h, by { have h' := mem_univ x, rw \u2190h 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 \u2190erase_bUnion,\n    by_cases hb : a \u2208 s'.bUnion (\u03bb 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`\u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card`\nand that the statement of **Hall's Marriage Theorem** is true for all\n`\u03b9'` of cardinality \u2264 `n`, then it is true for `\u03b9` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_A {n : \u2115} (hn : fintype.card \u03b9 = n + 1)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (ih : \u2200 {\u03b9' : Type u} [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n        by exactI fintype.card \u03b9' \u2264 n \u2192\n                  (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                  \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x)\n  (ha : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 s.card < (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  haveI : nonempty \u03b9 := fintype.card_pos_iff.mp (hn.symm \u25b8 nat.succ_pos _),\n  haveI := classical.dec_eq \u03b9,\n  /- Choose an arbitrary element `x : \u03b9` and `y : t x`. -/\n  let x := classical.arbitrary \u03b9,\n  have tx_ne : (t x).nonempty,\n  { rw \u2190finset.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 \u27e8y, hy\u27e9,\n  /- Restrict to everything except `x` and `y`. -/\n  let \u03b9' := {x' : \u03b9 | x' \u2260 x},\n  let t' : \u03b9' \u2192 finset \u03b1 := \u03bb x', (t x').erase y,\n  have card_\u03b9' : fintype.card \u03b9' = n,\n  { convert congr_arg (\u03bb m, m - 1) hn,\n    convert set.card_ne_eq _, },\n  rcases ih t' card_\u03b9'.le (hall_cond_of_erase y ha) with \u27e8f', hfinj, hfr\u27e9,\n  /- Extend the resulting function. -/\n  refine \u27e8\u03bb z, if h : z = x then y else f' \u27e8z, h\u27e9, _, _\u27e9,\n  { rintro z\u2081 z\u2082,\n    have key : \u2200 {x}, y \u2260 f' x,\n    { intros x h,\n      specialize hfr x,\n      rw \u2190h at hfr,\n      simpa using hfr, },\n    by_cases h\u2081 : z\u2081 = x; by_cases h\u2082 : z\u2082 = x; simp [h\u2081, h\u2082, hfinj.eq_iff, key, key.symm], },\n  { intro z,\n    split_ifs with hz,\n    { rwa hz },\n    { specialize hfr \u27e8z, hz\u27e9,\n      rw mem_erase at hfr,\n      exact hfr.2, }, },\nend\n\nlemma hall_cond_of_restrict {\u03b9 : Type u} {t : \u03b9 \u2192 finset \u03b1} {s : finset \u03b9}\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (s' : finset (s : set \u03b9)) :\n  s'.card \u2264 (s'.bUnion (\u03bb a', t a')).card :=\nbegin\n  haveI := classical.dec_eq \u03b9,\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 {\u03b9 : Type u} {t : \u03b9 \u2192 finset \u03b1} {s : finset \u03b9}\n  (hus : s.card = (s.bUnion t).card)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (s' : finset (s\u1d9c : set \u03b9)) :\n  s'.card \u2264 (s'.bUnion (\u03bb x', t x' \\ s.bUnion t)).card :=\nbegin\n  haveI := classical.dec_eq \u03b9,\n  have : s'.card = (s \u222a 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 \u2190 card_sdiff,\n  { have : (s \u222a s'.image subtype.val).bUnion t \\ s.bUnion t \u2286 s'.bUnion (\u03bb 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 | \u27e8x', hx', rfl\u27e9) rat hs,\n      { exact (hs x hx rat).elim },\n      { exact \u27e8\u27e8x', hx', rat\u27e9, hs\u27e9, } },\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`\u2203 (s : finset \u03b9), s \u2260 univ \u2192 s.card = (s.bUnion t).card`\nand that the statement of Hall's Marriage Theorem is true for all\n`\u03b9'` of cardinality \u2264 `n`, then it is true for `\u03b9` of cardinality `n + 1`.\n-/\nlemma hall_hard_inductive_step_B {n : \u2115} (hn : fintype.card \u03b9 = n + 1)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (ih : \u2200 {\u03b9' : Type u} [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n        by exactI fintype.card \u03b9' \u2264 n \u2192\n                  (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                  \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x)\n  (s : finset \u03b9)\n  (hs : s.nonempty)\n  (hns : s \u2260 univ)\n  (hus : s.card = (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  haveI := classical.dec_eq \u03b9,\n  /- Restrict to `s` -/\n  let t' : s \u2192 finset \u03b1 := \u03bb x', t x',\n  rw nat.add_one at hn,\n  have card_\u03b9'_le : fintype.card s \u2264 n,\n  { apply nat.le_of_lt_succ,\n    rw \u2190hn,\n    convert (card_lt_iff_ne_univ _).mpr hns,\n    convert fintype.card_coe _ },\n  rcases ih t' card_\u03b9'_le (hall_cond_of_restrict ht) with \u27e8f', hf', hsf'\u27e9,\n  /- Restrict to `s\u1d9c` in the domain and `(s.bUnion t)\u1d9c` in the codomain. -/\n  set \u03b9'' := (s : set \u03b9)\u1d9c with \u03b9''_def,\n  let t'' : \u03b9'' \u2192 finset \u03b1 := \u03bb a'', t a'' \\ s.bUnion t,\n  have card_\u03b9''_le : fintype.card \u03b9'' \u2264 n,\n  { apply nat.le_of_lt_succ,\n    rw \u2190hn,\n    convert (card_compl_lt_iff_nonempty _).mpr hs,\n    convert fintype.card_coe (s\u1d9c),\n    exact (finset.coe_compl s).symm },\n  rcases ih t'' card_\u03b9''_le (hall_cond_of_compl hus ht) with \u27e8f'', hf'', hsf''\u27e9,\n  /- Put them together -/\n  have f'_mem_bUnion : \u2200 {x'} (hx' : x' \u2208 s), f' \u27e8x', hx'\u27e9 \u2208 s.bUnion t,\n  { intros x' hx',\n    rw mem_bUnion,\n    exact \u27e8x', hx', hsf' _\u27e9, },\n  have f''_not_mem_bUnion : \u2200 {x''} (hx'' : \u00ac x'' \u2208 s), \u00ac f'' \u27e8x'', hx''\u27e9 \u2208 s.bUnion t,\n  { intros x'' hx'',\n    have h := hsf'' \u27e8x'', hx''\u27e9,\n    rw mem_sdiff at h,\n    exact h.2, },\n  have im_disj : \u2200 {x' x'' : \u03b9} {hx' : x' \u2208 s} {hx'' : \u00acx'' \u2208 s}, f' \u27e8x', hx'\u27e9 \u2260 f'' \u27e8x'', hx''\u27e9,\n  { intros _ _ hx' hx'' h,\n    apply f''_not_mem_bUnion hx'',\n    rw \u2190h,\n    apply f'_mem_bUnion, },\n  refine \u27e8\u03bb x, if h : x \u2208 s then f' \u27e8x, h\u27e9 else f'' \u27e8x, h\u27e9, _, _\u27e9,\n  { exact hf'.dite _ hf'' @im_disj },\n  { intro x,\n    split_ifs,\n    { exact hsf' \u27e8x, h\u27e9 },\n    { exact sdiff_subset _ _ (hsf'' \u27e8x, h\u27e9) } }\nend\n\n/--\nIf `\u03b9` has cardinality `n + 1` and the statement of Hall's Marriage Theorem\nis true for all `\u03b9'` of cardinality \u2264 `n`, then it is true for `\u03b9`.\n-/\ntheorem hall_hard_inductive_step {n : \u2115} (hn : fintype.card \u03b9 = n + 1)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card)\n  (ih : \u2200 {\u03b9' : Type u} [fintype \u03b9'] (t' : \u03b9' \u2192 finset \u03b1),\n        by exactI fintype.card \u03b9' \u2264 n \u2192\n                  (\u2200 (s' : finset \u03b9'), s'.card \u2264 (s'.bUnion t').card) \u2192\n                  \u2203 (f : \u03b9' \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t' x) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  by_cases h : \u2200 (s : finset \u03b9), s.nonempty \u2192 s \u2260 univ \u2192 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 \u27e8s, sne, snu, sle\u27e9,\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 : \u2115} (hn : fintype.card \u03b9 = n)\n  (ht : \u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card) :\n  \u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x :=\nbegin\n  tactic.unfreeze_local_instances,\n  revert \u03b9,\n  refine nat.strong_induction_on n (\u03bb 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 \u03b9' _ _ h\u03b9',\n    exact ih (fintype.card \u03b9') (nat.lt_succ_of_le h\u03b9') 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 : \u03b9 \u2192 finset \u03b1` with `\u03b9` 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 \u03b9` constraint is removed.\n-/\ntheorem finset.all_card_le_bUnion_card_iff_exists_injective'\n  {\u03b9 \u03b1 : Type*} [fintype \u03b9] [decidable_eq \u03b1] (t : \u03b9 \u2192 finset \u03b1) :\n  (\u2200 (s : finset \u03b9), s.card \u2264 (s.bUnion t).card) \u2194\n    (\u2203 (f : \u03b9 \u2192 \u03b1), function.injective f \u2227 \u2200 x, f x \u2208 t x) :=\nbegin\n  split,\n  { exact hall_marriage_theorem.hall_hard_inductive rfl },\n  { rintro \u27e8f, hf\u2081, hf\u2082\u27e9 s,\n    rw \u2190card_image_of_injective s hf\u2081,\n    apply card_le_of_subset,\n    intro _,\n    rw [mem_image, mem_bUnion],\n    rintros \u27e8x, hx, rfl\u27e9,\n    exact \u27e8x, hx, hf\u2082 x\u27e9, },\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--   \u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n--   (end_after : \u2115) (i : \u2115) (hi : h.i = end_after + i), ssyt \u03bc\n-- | \u03bc T h end_after 0 hi := h.irbs\n-- | \u03bc 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  \u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i),\n  \u03a3 (T : ssyt \u03bc), T.irbs_cert\n| \u03bc T h end_before 0 hi := \u27e8T, h\u27e9\n| \u03bc 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  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before : \u2115} (hi : h.i = end_before + 0) :\n  h.irb_inductive hi = \u27e8T, h\u27e9 := rfl\nlemma ssyt.irbs_cert.irb_inductive_def_pos\n  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before n : \u2115} (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  \u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i),\n  (h.irb_inductive hi).2.i = end_before\n| \u03bc T h end_before 0 hi := hi\n| \u03bc 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  \u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  (end_before : \u2115) (i : \u2115) (hi : h.i = end_before + i) (val : \u2115),\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| \u03bc T h end_before 0 hi val := rfl\n| \u03bc 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\u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  (i' j' : \u2115) (hi' : i' > h.i),\n  (h.irb_inductive hi).1 i' j' = T i' j'\n| \u03bc T h end_before 0 hi i' j' hi' := rfl\n| \u03bc 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\u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  (i' j' : \u2115) (hi' : i' \u2264 end_before),\n  (h.irb_inductive hi).1 i' j' = T i' j'\n| \u03bc T h end_before 0 hi i' j' hi' := rfl\n| \u03bc 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  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  (i' j' : \u2115) (hi' : i' \u2264 end_before \u2228 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\u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  {\u03bd : young_diagram} {T' : ssyt \u03bd} (h' : T'.irbs_cert)\n  (hi' : h'.i = h.i) (hval : h'.val = h.val)\n  (eq_cell : \u2200 i j (hi'' : end_before < i \u2227 i \u2264 h.i), (i, j) \u2208 \u03bc \u2194 (i, j) \u2208 \u03bd)\n  (eq_row_mid : \u2200 i j (hi'' : end_before < i \u2227 i \u2264 h.i), T i j = T' i j)\n  (i j : \u2115) (hi'' : end_before < i \u2227 i \u2264 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| \u03bc T h end_before 0 hi\n  \u03bd T' h' \n  hi' hval eq_cell eq_row_mid\n  i j hi'' := eq_row_mid _ _ \u27e8hi''.1, hi''.2\u27e9\n| \u03bc T h end_before (nat.succ n) hi\n  \u03bd 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 _ _ \u27e8hi''', by refl\u27e9],\n      intro j, rw [hi', eq_row_mid _ _ \u27e8hi''', by refl\u27e9],\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 _ _ \u27e8hi''', by refl\u27e9] },\n      { intros i' j' hij', \n        rw eq_cell _ _ \u27e8hij'.1, hij'.2.trans (nat.pred_le _)\u27e9 },\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 _ _ \u27e8hij'.1, le_of_lt key\u27e9,\n        rw hi', exact key },\n      { exact \u27e8hi''.1, nat.le_pred_of_lt h_1\u27e9 }\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  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert) : ssyt \u03bc \u00d7 \u2115 :=\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  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert) (val : \u2115) :\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  {\u03bc : young_diagram} (T : ssyt \u03bc) (c : \u03bc.inner_corner) : ssyt c.del \u00d7 \u2115 :=\ndite (c.i = 0) \n  (\u03bb _, (T.del c, T c.i c.j))\n  (\u03bb 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' \u2218 rbwf = id (start and end in row i)\n-- rbwf \u2218 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  {\u03bc : young_diagram} (T : ssyt \u03bc) (h h1 : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  (h_h1_i : h1.i \u2264 end_before \u2228 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\u2200 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' _ _ (\u03bb _, 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' \u2264 end_before \u2228 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' \u25b8 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      (\u03bb _ _ _, 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-- \u03a0 {\u03bc : young_diagram} (T : ssyt \u03bc) (h : T.irbs_cert)\n--   {end_before i : \u2115} (hi : h.i = end_before + i)\n--   (h' : (h.irb_inductive hi).1.irbs_cert)\n--   (hi' : h'.i = h.i) (hval' : h'.val \u2264 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-- | \u03bc 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  \u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i),\n  \u03a3' (T : ssyt \u03bc) (h : T.irbs_cert), h.i = end_before\n| \u03bc T h end_before 0 hi := \u27e8T, h, hi\u27e9\n| \u03bc 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\u27e8_,\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 }\u27e9\n\nlemma ssyt.irbs_cert.irb_inductive'_row_zero\n  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before : \u2115} (hi : h.i = end_before + 0) :\n  h.irb_inductive' hi = \u27e8T, h, hi\u27e9 := rfl\n\nlemma ssyt.irbs_cert.irb_inductive'_row_succ\n  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before n : \u2115} (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  \u27e8_, \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   }\u27e9 := rfl\n\nlemma ssyt.irbs_cert.irb_inductive'_out_row\n  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (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--   {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n--   {end_before : \u2115} (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--   {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n--   {end_before n : \u2115} (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--   \u27e8_, \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--    }\u27e9 := rfl\n\nlemma ssyt.irbs_cert.irb_inductive'_wt :\n  \u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  (end_before : \u2115) (i : \u2115) (hi : h.i = end_before + i) (val : \u2115),\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| \u03bc T h end_before 0 hi val := rfl\n| \u03bc 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\u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  (i' j' : \u2115) (hi' : i' > h.i),\n  (h.irb_inductive' hi).1 i' j' = T i' j'\n| \u03bc T h end_before 0 hi i' j' hi' := rfl\n| \u03bc 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, \u2190 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\u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  (i' j' : \u2115) (hi' : i' \u2264 end_before),\n  (h.irb_inductive' hi).1 i' j' = T i' j'\n| \u03bc T h end_before 0 hi i' j' hi' := rfl\n| \u03bc 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  {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  (i' j' : \u2115) (hi' : i' \u2264 end_before \u2228 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\u03a0 {\u03bc : young_diagram} {T : ssyt \u03bc} (h : T.irbs_cert)\n  {end_before i : \u2115} (hi : h.i = end_before + i)\n  {\u03bd : young_diagram} {T' : ssyt \u03bd} (h' : T'.irbs_cert)\n  (hi' : h'.i = h.i) (hval : h'.val = h.val) (hj : h'.j = h.j)\n  (eq_cell : \u2200 i j (hi'' : end_before < i \u2227 i \u2264 h.i), (i, j) \u2208 \u03bc \u2194 (i, j) \u2208 \u03bd)\n  (eq_row_mid : \u2200 i j (hi'' : end_before < i \u2227 i \u2264 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--\u2227 (h.irb_inductive' hi).2.1.j = (h'.irb_inductive' (hi'.trans hi)).2.1.j\n\u2227 \u2200 (i j : \u2115) (hi'' : end_before < i \u2227 i \u2264 h.i),\n(h.irb_inductive' hi).1 i j = (h'.irb_inductive' (hi'.trans hi)).1 i j \n| \u03bc T h end_before 0 hi\n  \u03bd 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 \u27e8hval.symm,\n          --  hj.symm,\n           eq_row_mid\u27e9,\n  end\n| \u03bc T h end_before (nat.succ n) hi\n  \u03bd 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' \u27e8h1, h2\u27e9, rw eq_cell _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\n    { rintros i' j' \u27e8h1, h2\u27e9, rw eq_row_mid _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\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 _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\n    -- intro j, rw eq_cell, rw [h.irb_inductive'_out_row, hi_succ], \n    -- exact \u27e8lt_add_one _, nat.le_add_right _ _\u27e9,\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' \u27e8h1, h2\u27e9, rw eq_cell _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\n    -- { rintros i' j' \u27e8h1, h2\u27e9, rw eq_row_mid _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\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 \u2190 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 \u27e8lt_add_one _, nat.le_add_right _ _\u27e9, 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 \u27e8h_1, hi''.2\u27e9,\n    { rintros i' j' \u27e8h1, h2\u27e9, rw eq_cell _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\n    { rintros i' j' \u27e8h1, h2\u27e9, rw eq_row_mid _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\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, \u2190 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' \u27e8h1, h2\u27e9, rw eq_cell _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\n  -- { rintros i' j' \u27e8h1, h2\u27e9, rw eq_row_mid _ _ \u27e8(lt_add_one _).trans h1, h2\u27e9 },\n  -- exact \u27e8h_1, hi''.2\u27e9,\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 _ _ \u27e8hi''', by refl\u27e9] },\n  --     { intros i' j' hij', \n  --       rw eq_cell _ _ \u27e8hij'.1, hij'.2.trans (nat.pred_le _)\u27e9 },\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 _ _ \u27e8hij'.1, le_of_lt key\u27e9,\n  --       rw hi', exact key },\n  --     { exact \u27e8hi''.1, nat.le_pred_of_lt h_1\u27e9 }\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": "/-\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, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.default\nimport Mathlib.data.nat.basic\nimport Mathlib.PostPort\n\nnamespace Mathlib\n\n/-!\n# The factorial function\n\n-/\n\nnamespace nat\n\n\n/-- `nat.factorial n` is the factorial of `n`. -/\n@[simp] def factorial : \u2115 \u2192 \u2115 :=\n  sorry\n\n@[simp] theorem factorial_zero : factorial 0 = factorial 1 :=\n  rfl\n\n@[simp] theorem factorial_succ (n : \u2115) : factorial (Nat.succ n) = Nat.succ n * factorial n :=\n  rfl\n\n@[simp] theorem factorial_one : factorial 1 = 1 :=\n  rfl\n\ntheorem mul_factorial_pred {n : \u2115} (hn : 0 < n) : n * factorial (n - 1) = factorial n :=\n  nat.sub_add_cancel hn \u25b8 rfl\n\ntheorem factorial_pos (n : \u2115) : 0 < factorial n := sorry\n\ntheorem factorial_ne_zero (n : \u2115) : factorial n \u2260 0 :=\n  ne_of_gt (factorial_pos n)\n\ntheorem factorial_dvd_factorial {m : \u2115} {n : \u2115} (h : m \u2264 n) : factorial m \u2223 factorial n := sorry\n\ntheorem dvd_factorial {m : \u2115} {n : \u2115} : 0 < m \u2192 m \u2264 n \u2192 m \u2223 factorial n := sorry\n\ntheorem factorial_le {m : \u2115} {n : \u2115} (h : m \u2264 n) : factorial m \u2264 factorial n :=\n  le_of_dvd (factorial_pos n) (factorial_dvd_factorial h)\n\ntheorem factorial_mul_pow_le_factorial {m : \u2115} {n : \u2115} : factorial m * Nat.succ m ^ n \u2264 factorial (m + n) := sorry\n\ntheorem monotone_factorial : monotone factorial :=\n  fun (n m : \u2115) => factorial_le\n\ntheorem factorial_lt {m : \u2115} {n : \u2115} (h0 : 0 < n) : factorial n < factorial m \u2194 n < m := sorry\n\ntheorem one_lt_factorial {n : \u2115} : 1 < factorial n \u2194 1 < n := sorry\n\ntheorem factorial_eq_one {n : \u2115} : factorial n = 1 \u2194 n \u2264 1 := sorry\n\ntheorem factorial_inj {m : \u2115} {n : \u2115} (h0 : 1 < factorial n) : factorial n = factorial m \u2194 n = m := sorry\n\ntheorem self_le_factorial (n : \u2115) : n \u2264 factorial 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/factorial.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7662936430859597, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.4627891250414487}}
{"text": "import Logic.Predicate.Term\nimport Mathlib.Data.W.Basic\n\nuniverse u v\n\nvariable {L : Language.{u}} [\u2200 k, Encodable (L.func k)] {\u03bc : Type v} [Encodable \u03bc]\n\nnamespace SubTerm\nopen Encodable\nvariable {n : \u2115}\n\n-- \u672c\u6765 \" + 1\"\u306f\u5fc5\u8981\u306a\u3044\u304cofNat\u306e\u505c\u6b62\u6027\u306e\u8a3c\u660e\u304c\u3088\u308a\u7c21\u6613\u306b\u306a\u308b\u305f\u3081\u3064\u3051\u3066\u3044\u308b\ndef toNat : SubTerm L \u03bc n \u2192 \u2115 \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 : \u2115 \u2192 Option (SubTerm L \u03bc n)\n| 0  => none\n| e + 1 =>\n  match e.bodd with\n  | false => \n    match e.div2.bodd with\n    | false => (decode\u2082 (Fin n) e.div2.div2).map bvar\n    | true  => (decode\u2082 \u03bc 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\u2082 (L.func k) x.unpair.2.unpair.1\n      let w : Fin k \u2192 \u2115 := Nat.unvector x.unpair.2.unpair.2\n      have : \u2200 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 \u2192 SubTerm L \u03bc 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 : \u2200 t : SubTerm L \u03bc 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 \u03bc n) where\n  encode := toNat\n  decode := ofNat\n  encodek := ofNat_toNat\n\nvariable [\u2200 k, DecidableEq (L.func k)]\n\ndef enumLtList : \u2115 \u2192 List (SyntacticTerm L)\n| 0     => []\n| s + 1 => (Encodable.decode\u2082 (SyntacticTerm L) s).toList ++ enumLtList s\n\nlemma mem_enumLtList_of_lt {i} {t : SyntacticTerm L} (h : encode t < i) : t \u2208 enumLtList i := by\n  induction' i with i ih <;> simp[enumLtList]\n  \u00b7 contradiction\n  \u00b7 have : encode t < i \u2228 encode t = i := lt_or_eq_of_le (Nat.lt_succ.mp h)\n    rcases this with (h | rfl) <;> simp[*]\n\ndef enumLt (s : \u2115) : Finset (SyntacticTerm L) := (enumLtList s).toFinset\n\n@[simp] lemma enumLt_zero : (enumLt 0 : Finset (SyntacticTerm L)) = \u2205 := rfl \n\nlemma mem_enumLt_of_lt {i} {t : SyntacticTerm L} (h : encode t < i) : t \u2208 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 \u2192 Prop) : Prop :=\n  \u2200 (s : sys_state pid_t pstate_t msg_t), s.reachable \u2192 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 \u2192 Prop) : Prop :=\n  (\u2200 (u v : sys_state pid_t pstate_t msg_t), p u \u2192 u.possible_next v \u2192 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 \u2192 Prop) : Prop :=\n  (\u2200 (s : sys_state pid_t pstate_t msg_t), s.is_initial \u2192 p s) \u2227\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 \u2192 Prop} :\n  inductive_invariant p \u2192 invariant p :=\nbegin\nrintro \u27e8initial, inductive_step\u27e9,\nsuffices key : \u2200 (n : \u2115) (s : sys_state pid_t pstate_t msg_t), s.reachable_in n \u2192 p s,\nby {\n  intro s,\n  rintros \u27e8n, reachable_in_n_steps\u27e9,\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 \u27e8u, reach_u_in_k, s_is_u_next\u27e9,\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 \u2192 Prop} :\n  (\u2200 (s : sys_state pid_t pstate_t msg_t), stronger s \u2192 weaker s) \u2192\n     invariant stronger \u2192 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 \u2194 inductive_invariant inv,\n-- specifically the \u2192 direction.\nlemma inv_iff_ind_inv (inv : sys_state pid_t pstate_t msg_t \u2192 Prop) :\n  invariant inv \u2194 inductive_invariant (\u03bb s, s.reachable \u2227 inv s) :=\nbegin\nsplit,\n{ intro hyp,\n  split,\n  { intros s hs,\n    have s_r : s.reachable := \u27e80, hs\u27e9,\n    exact \u27e8s_r, hyp s s_r\u27e9 },\n  intros u v,\n  rintros \u27e8\u27e8steps_r, u_r\u27e9, inv_u\u27e9,\n  intro u_pn_v,\n  have v_r : v.reachable := \u27e8steps_r.succ, or.inl \u27e8u, u_r, u_pn_v\u27e9\u27e9,\n  exact \u27e8v_r, hyp v v_r\u27e9 },\nintro hyp,\nsuffices key : \u2200 (s : sys_state pid_t pstate_t msg_t), s.reachable \u2227 inv s \u2192 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 \u2192 Prop) :\n  invariant p \u2194\n    (\u2200 (s : sys_state pid_t pstate_t msg_t), s.is_initial \u2192 p s) \u2227\n    (\u2200 (u v : sys_state pid_t pstate_t msg_t), u.reachable \u2192 p u \u2192 u.possible_next v \u2192 v.reachable \u2192 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 \u27e8u_r, p_u\u27e9 u_pn_v).right },\nrintros \u27e8h_init, h_step\u27e9,\nsplit,\n{ intros s hs,\n  exact \u27e8\u27e80, hs\u27e9, h_init s hs\u27e9 },\nintros u v,\nrintros \u27e8u_r, p_u\u27e9,\nintro u_pn_v,\nhave key : v.reachable,\n  by { cases u_r with steps_r u_r, exact \u27e8steps_r.succ, or.inl \u27e8u, u_r, u_pn_v\u27e9\u27e9 },\nexact \u27e8key, by { exact h_step u v u_r p_u u_pn_v key }\u27e9,\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 : \u2115} : fin n \u2192 fin (Nat.succ n) :=\n  sorry\n\ndef of_nat {n : \u2115} (a : \u2115) : fin (Nat.succ n) :=\n  { val := a % Nat.succ n, property := sorry }\n\nprotected def add {n : \u2115} : fin n \u2192 fin n \u2192 fin n :=\n  sorry\n\nprotected def mul {n : \u2115} : fin n \u2192 fin n \u2192 fin n :=\n  sorry\n\nprotected def sub {n : \u2115} : fin n \u2192 fin n \u2192 fin n :=\n  sorry\n\nprotected def mod {n : \u2115} : fin n \u2192 fin n \u2192 fin n :=\n  sorry\n\nprotected def div {n : \u2115} : fin n \u2192 fin n \u2192 fin n :=\n  sorry\n\nprotected instance has_zero {n : \u2115} : HasZero (fin (Nat.succ n)) :=\n  { zero := { val := 0, property := nat.succ_pos n } }\n\nprotected instance has_one {n : \u2115} : HasOne (fin (Nat.succ n)) :=\n  { one := of_nat 1 }\n\nprotected instance has_add {n : \u2115} : Add (fin n) :=\n  { add := fin.add }\n\nprotected instance has_sub {n : \u2115} : Sub (fin n) :=\n  { sub := fin.sub }\n\nprotected instance has_mul {n : \u2115} : Mul (fin n) :=\n  { mul := fin.mul }\n\nprotected instance has_mod {n : \u2115} : Mod (fin n) :=\n  { mod := fin.mod }\n\nprotected instance has_div {n : \u2115} : Div (fin n) :=\n  { div := fin.div }\n\ntheorem of_nat_zero {n : \u2115} : of_nat 0 = 0 :=\n  rfl\n\ntheorem add_def {n : \u2115} (a : fin n) (b : fin n) : subtype.val (a + b) = (subtype.val a + subtype.val b) % n := sorry\n\ntheorem mul_def {n : \u2115} (a : fin n) (b : fin n) : subtype.val (a * b) = subtype.val a * subtype.val b % n := sorry\n\ntheorem sub_def {n : \u2115} (a : fin n) (b : fin n) : subtype.val (a - b) = subtype.val a - subtype.val b := sorry\n\ntheorem mod_def {n : \u2115} (a : fin n) (b : fin n) : subtype.val (a % b) = subtype.val a % subtype.val b := sorry\n\ntheorem div_def {n : \u2115} (a : fin n) (b : fin n) : subtype.val (a / b) = subtype.val a / subtype.val b := sorry\n\ntheorem lt_def {n : \u2115} (a : fin n) (b : fin n) : a < b = (subtype.val a < subtype.val b) := sorry\n\ntheorem le_def {n : \u2115} (a : fin n) (b : fin n) : a \u2264 b = (subtype.val a \u2264 subtype.val b) := sorry\n\ntheorem val_zero {n : \u2115} : subtype.val 0 = 0 :=\n  rfl\n\ndef pred {n : \u2115} (i : fin (Nat.succ n)) : i \u2260 0 \u2192 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 : \u2115} (P : mvpfunctor.{u} (n+1))\n\ninductive M_path : P.last.M \u2192 fin' n \u2192 Type u\n| root (x : P.last.M) (a : P.A) (f : P.last.B a \u2192 P.last.M) (h : pfunctor.M_dest x = \u27e8a, f\u27e9)\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 \u2192 P.last.M) (h : pfunctor.M_dest x = \u27e8a, f\u27e9)\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 (\u03b1 : typevec n) : Type* := P.Mp.apply \u03b1\n\ninstance mvfunctor_M : mvfunctor P.M := by delta M; apply_instance\n\ndef M_corec_shape {\u03b2 : Type u}\n    (g\u2080 : \u03b2 \u2192 P.A)\n    (g\u2082 : \u03a0 b : \u03b2, P.last.B (g\u2080 b) \u2192 \u03b2) :\n  \u03b2 \u2192 P.last.M :=\npfunctor.M_corec (\u03bb b, \u27e8g\u2080 b, g\u2082 b\u27e9)\n\ndef cast_dropB {a a' : P.A} (h : a = a') : P.drop.B a \u27f9 P.drop.B a' :=\n\u03bb i b, eq.rec_on h b\n\ndef cast_lastB {a a' : P.A} (h : a = a') : P.last.B a \u2192 P.last.B a' :=\n\u03bb b, eq.rec_on h b\n\ndef M_corec_contents {\u03b1 : typevec.{u} n} {\u03b2 : Type u}\n    (g\u2080 : \u03b2 \u2192 P.A)\n    (g\u2081 : \u03a0 b : \u03b2, P.drop.B (g\u2080 b) \u27f9 \u03b1)\n    (g\u2082 : \u03a0 b : \u03b2, P.last.B (g\u2080 b) \u2192 \u03b2) :\n  \u03a0 x b, x = P.M_corec_shape g\u2080 g\u2082 b \u2192 P.M_path x \u27f9 \u03b1\n| ._ b h ._ (M_path.root x a f h' i c)    :=\n  have a = g\u2080 b,\n    by { rw [h, M_corec_shape, pfunctor.M_dest_corec] at h', cases h', refl },\n  g\u2081 b i (P.cast_dropB this i c)\n| ._ b h ._ (M_path.child x a f h' j i c) :=\n  have h\u2080 : a = g\u2080 b,\n    by { rw [h, M_corec_shape, pfunctor.M_dest_corec] at h', cases h', refl },\n  have h\u2081 : f j = M_corec_shape P g\u2080 g\u2082 (g\u2082 b (cast_lastB P h\u2080 j)),\n    by { rw [h, M_corec_shape, pfunctor.M_dest_corec] at h', cases h', refl },\n  M_corec_contents (f j) (g\u2082 b (P.cast_lastB h\u2080 j)) h\u2081 i c\n\ndef M_corec' {\u03b1 : typevec n} {\u03b2 : Type u}\n    (g\u2080 : \u03b2 \u2192 P.A)\n    (g\u2081 : \u03a0 b : \u03b2, P.drop.B (g\u2080 b) \u27f9 \u03b1)\n    (g\u2082 : \u03a0 b : \u03b2, P.last.B (g\u2080 b) \u2192 \u03b2) :\n  \u03b2 \u2192 P.M \u03b1 :=\n\u03bb b, \u27e8M_corec_shape P g\u2080 g\u2082 b, M_corec_contents P g\u2080 g\u2081 g\u2082 _ _ rfl\u27e9\n\ndef M_corec {\u03b1 : typevec n} {\u03b2 : Type u} (g : \u03b2 \u2192 P.apply (\u03b1.append1 \u03b2)) :\n  \u03b2 \u2192 P.M \u03b1 :=\nM_corec' P\n  (\u03bb b, (g b).fst)\n  (\u03bb b, drop_fun (g b).snd)\n  (\u03bb b, last_fun (g b).snd)\n\ndef M_path_dest_left {\u03b1 : typevec n} {x : P.last.M}\n    {a : P.A} {f : P.last.B a \u2192 P.last.M} (h : pfunctor.M_dest x = \u27e8a, f\u27e9)\n    (f' : P.M_path x \u27f9 \u03b1) :\n  P.drop.B a \u27f9 \u03b1 :=\n\u03bb i c, f' i (M_path.root x a f h i c)\n\ndef M_path_dest_right {\u03b1 : typevec n} {x : P.last.M}\n    {a : P.A} {f : P.last.B a \u2192 P.last.M} (h : pfunctor.M_dest x = \u27e8a, f\u27e9)\n    (f' : P.M_path x \u27f9 \u03b1) :\n  \u03a0 j : P.last.B a, P.M_path (f j) \u27f9 \u03b1 :=\n\u03bb j i c, f' i (M_path.child x a f h j i c)\n\ndef M_dest' {\u03b1 : typevec n} {x : P.last.M}\n    {a : P.A} {f : P.last.B a \u2192 P.last.M} (h : pfunctor.M_dest x = \u27e8a, f\u27e9)\n    (f' : P.M_path x \u27f9 \u03b1) :\n  P.apply (\u03b1.append1 (P.M \u03b1)) :=\n\u27e8a, split_fun (P.M_path_dest_left h f') (\u03bb x, \u27e8f x, P.M_path_dest_right h f' x\u27e9)\u27e9\n\ndef M_dest {\u03b1 : typevec n} (x : P.M \u03b1) : P.apply (\u03b1.append1 (P.M \u03b1)) :=\nP.M_dest' (sigma.eta $ pfunctor.M_dest x.fst).symm x.snd\n\ndef M_mk  {\u03b1 : typevec n} : P.apply (\u03b1.append1 (P.M \u03b1)) \u2192 P.M \u03b1 :=\nM_corec _ (\u03bb i, append_fun id (M_dest P) <$$> i)\n\ntheorem M_dest'_eq_dest' {\u03b1 : typevec n} {x : P.last.M}\n    {a\u2081 : P.A} {f\u2081 : P.last.B a\u2081 \u2192 P.last.M} (h\u2081 : pfunctor.M_dest x = \u27e8a\u2081, f\u2081\u27e9)\n    {a\u2082 : P.A} {f\u2082 : P.last.B a\u2082 \u2192 P.last.M} (h\u2082 : pfunctor.M_dest x = \u27e8a\u2082, f\u2082\u27e9)\n    (f' : P.M_path x \u27f9 \u03b1) : M_dest' P h\u2081 f' = M_dest' P h\u2082 f' :=\nby cases h\u2081.symm.trans h\u2082; refl\n\ntheorem M_dest_eq_dest' {\u03b1 : typevec n} {x : P.last.M}\n    {a : P.A} {f : P.last.B a \u2192 P.last.M} (h : pfunctor.M_dest x = \u27e8a, f\u27e9)\n    (f' : P.M_path x \u27f9 \u03b1) : M_dest P \u27e8x, f'\u27e9 = M_dest' P h f' :=\nM_dest'_eq_dest' _ _ _ _\n\ntheorem M_dest_corec' {\u03b1 : typevec.{u} n} {\u03b2 : Type u}\n    (g\u2080 : \u03b2 \u2192 P.A)\n    (g\u2081 : \u03a0 b : \u03b2, P.drop.B (g\u2080 b) \u27f9 \u03b1)\n    (g\u2082 : \u03a0 b : \u03b2, P.last.B (g\u2080 b) \u2192 \u03b2)\n    (x : \u03b2) :\n  P.M_dest (P.M_corec' g\u2080 g\u2081 g\u2082 x) =\n    \u27e8g\u2080 x, split_fun (g\u2081 x) (P.M_corec' g\u2080 g\u2081 g\u2082 \u2218 (g\u2082 x))\u27e9 :=\nrfl\n\ntheorem M_dest_corec {\u03b1 : typevec n} {\u03b2 : Type u} (g : \u03b2 \u2192 P.apply (\u03b1.append1 \u03b2)) (x : \u03b2) :\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 [\u2190split_drop_fun_last_fun f, append_fun_comp_split_fun] },\n  refl\nend\n\nlemma M_bisim_lemma {\u03b1 : typevec n}\n  {a\u2081 : (Mp P).A} {f\u2081 : (Mp P).B a\u2081 \u27f9 \u03b1}\n  {a' : P.A} {f' : (P.B a').drop \u27f9 \u03b1} {f\u2081' : (P.B a').last \u2192 M P \u03b1}\n  (e\u2081 : M_dest P \u27e8a\u2081, f\u2081\u27e9 = \u27e8a', split_fun f' f\u2081'\u27e9) :\n  \u2203 g\u2081' (e\u2081' : pfunctor.M_dest a\u2081 = \u27e8a', g\u2081'\u27e9),\n    f' = M_path_dest_left P e\u2081' f\u2081 \u2227\n    f\u2081' = \u03bb (x : (last P).B a'),\n      \u27e8g\u2081' x, M_path_dest_right P e\u2081' f\u2081 x\u27e9 :=\nbegin\n  generalize_hyp ef : @split_fun n _ (append1 \u03b1 (M P \u03b1)) f' f\u2081' = ff at e\u2081,\n  cases e\u2081' : pfunctor.M_dest a\u2081 with a\u2081' g\u2081',\n  rw M_dest_eq_dest' _ e\u2081' at e\u2081,\n  cases e\u2081, exact \u27e8_, e\u2081', split_fun_inj ef\u27e9,\nend\n\ntheorem M_bisim {\u03b1 : typevec n} (R : P.M \u03b1 \u2192 P.M \u03b1 \u2192 Prop)\n  (h : \u2200 x y, R x y \u2192 \u2203 a f f\u2081 f\u2082,\n    P.M_dest x = \u27e8a, split_fun f f\u2081\u27e9 \u2227\n    P.M_dest y = \u27e8a, split_fun f f\u2082\u27e9 \u2227\n    \u2200 i, R (f\u2081 i) (f\u2082 i))\n  (x y) (r : R x y) : x = y :=\nbegin\n  cases x with a\u2081 f\u2081,\n  cases y with a\u2082 f\u2082,\n  dsimp [Mp] at *,\n  have : a\u2081 = a\u2082, {\n    refine pfunctor.M_bisim\n      (\u03bb a\u2081 a\u2082, \u2203 x y, R x y \u2227 x.1 = a\u2081 \u2227 y.1 = a\u2082) _ _ _\n      \u27e8\u27e8a\u2081, f\u2081\u27e9, \u27e8a\u2082, f\u2082\u27e9, r, rfl, rfl\u27e9,\n    rintro _ _ \u27e8\u27e8a\u2081, f\u2081\u27e9, \u27e8a\u2082, f\u2082\u27e9, r, rfl, rfl\u27e9,\n    rcases h _ _ r with \u27e8a', f', f\u2081', f\u2082', e\u2081, e\u2082, h'\u27e9,\n    rcases M_bisim_lemma P e\u2081 with \u27e8g\u2081', e\u2081', rfl, rfl\u27e9,\n    rcases M_bisim_lemma P e\u2082 with \u27e8g\u2082', e\u2082', _, rfl\u27e9,\n    rw [e\u2081', e\u2082'],\n    exact \u27e8_, _, _, rfl, rfl, \u03bb b, \u27e8_, _, h' b, rfl, rfl\u27e9\u27e9 },\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\u2081 f\u2082;\n  try {\n    rcases h _ _ r with \u27e8a', f', f\u2081', f\u2082', e\u2081, e\u2082, h''\u27e9,\n    rcases M_bisim_lemma P e\u2081 with \u27e8g\u2081', e\u2081', rfl, rfl\u27e9,\n    rcases M_bisim_lemma P e\u2082 with \u27e8g\u2082', e\u2082', e\u2083, rfl\u27e9,\n    cases h'.symm.trans e\u2081',\n    cases h'.symm.trans e\u2082' },\n  { exact (congr_fun (congr_fun e\u2083 i) c : _) },\n  { exact IH _ _ (h'' _) }\nend\n\ntheorem M_dest_map {\u03b1 \u03b2 : typevec n} (g : \u03b1 \u27f9 \u03b2) (x : P.M \u03b1) :\n  P.M_dest (g <$$> x) = append_fun g (\u03bb 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) \u2192 PFin2 (n + k)` by applying `f : PFin2 m \u2192 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 \u2192 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 \u2192 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) \u2192 Sort u} (H1 : C fz) (H2 : \u2200 n, C (fs n)) : \u2200 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 \u2192 Sort u} : \u2200 i : PFin2 0, C i :=\n  by intro i; cases i\n\n/-- Converts a `PFin2` into a natural. -/\ndef toNat : \u2200 {n}, PFin2 n \u2192 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 \u2192 Fin n\n  := fun i => \u27e8i.toNat, toNat_in_range i\u27e9\n\n\n/-- Converts a natural into a `PFin2` if it is in range -/\ndef optOfNat : \u2200 {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 : \u2200 {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 \u2192 PFin2 n\n  := fun \u27e8i, h\u27e9 => ofNatLt i h\n\n\n/-- `i + k : PFin2 (n + k)` when `i : PFin2 n` and `k : Nat` -/\ndef add {n} (i : PFin2 n) : \u2200 k, PFin2 (n + k)\n  | 0 => i\n  | succ k => fs (add i k)\n\n/-- `left k` is the embedding `PFin2 n \u2192 PFin2 (k + n)` -/\ndef left k : \u2200 {n}, PFin2 n \u2192 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 : \u2200 {n}, PFin2 n \u2192 PFin2 n \u2192 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) \u2192 PFin2 (n + k)` applies the function\n  `f : PFin2 m \u2192 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 \u2192 PFin2 n) : \u2200 k, PFin2 (m + k) \u2192 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  \u27e8succ_pos _\u27e9\n\ninstance IsLt.succ m n [l : IsLt m n] : IsLt (succ m) (succ n) :=\n  \u27e8succ_lt_succ l.h\u27e9\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' : \u2200 {n} m [IsLt m n], PFin2 n\n  | 0, m, \u27e8h\u27e9 => absurd h (Nat.not_lt_zero _)\n  | succ n, 0, \u27e8h\u27e9 => fz\n  | succ n, succ m, \u27e8h\u27e9 => fs (@ofNat' n m \u27e8lt_of_succ_lt_succ h\u27e9)\n\n-- mathport name: \u00abexpr& \u00bb\nlocal prefix:arg \"&\" => ofNat'\n\ninstance : Inhabited (PFin2 1) :=\n  \u27e8fz\u27e9\n\n/-- There is only one function with empty domain `PFin2 0` -/\ndef eq_fn0 {\u03b1} (f g : PFin2 0 \u2192 \u03b1) : 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 {\u03b1} (f g : PFin2 0 \u2192 \u03b1) : 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 : \u2200{n}, PFin2 (succ n) \u2192 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 \u2192 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) \u2192 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} \u2192 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} \u2192 PFin2.{u} n \u2192 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 \u2192 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 \u2192 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 \u2192 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 \u2192 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) := \u27e8fz\u27e9\ninstance (n : Nat) : OfNat (PFin2 (n+2)) (nat_lit 1) := \u27e8fs 0\u27e9\ninstance (n : Nat) : OfNat (PFin2 (n+3)) (nat_lit 2) := \u27e8fs 1\u27e9\n\n\n/-\n  ## LT / LE\n-/\ninstance instOrd (n : Nat) : Ord (PFin2 n) where\n  compare := (compare \u00b7.toNat \u00b7.toNat)\n\ninstance instLT {n : Nat} : LT (PFin2 n) := \u27e8(Nat.lt \u00b7.toNat \u00b7.toNat)\u27e9\ninstance instLE {n : Nat} : LE (PFin2 n) := \u27e8(Nat.le \u00b7.toNat \u00b7.toNat)\u27e9\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 \u2264 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\u2081 h\u2082 := by simp[LE.le] at h\u2081 h\u2082;\n                              suffices toNat x = toNat y\n                              from by clear h\u2081 h\u2082;\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\u2081 h\u2082\n  le_total _ _          := by apply Nat.le_total\n  decidable_le          := decidable_le\n\ndef le_refl {n : Nat} : \n  \u2200 (x : PFin2 n), x \u2264 x := \n  instLinOrd.le_refl\n\ndef le_trans {n : Nat} : \n  \u2200 (x y z : PFin2 n), x \u2264 y \u2192 y \u2264 z \u2192 x \u2264 z \n:= instLinOrd.le_trans\n\ndef lt_iff_le_not_le : \n  \u2200 (x y : PFin2 n), x < y \u2194 x \u2264 y \u2227 \u00acy \u2264 x \n:= instLinOrd.lt_iff_le_not_le\n\ndef le_antisymm : \n  \u2200 (x y : PFin2 n), x \u2264 y \u2192 y \u2264 x \u2192 x = y\n:= instLinOrd.le_antisymm\n\ndef le_total :\n  \u2200 (x y : PFin2 n), x \u2264 y \u2228 y \u2264 x\n:= instLinOrd.le_total\n\ndef lt_trichotomy {n : Nat}  : \n  \u2200(a b : PFin2 n), a < b \u2228 a = b \u2228 b < a\n:= _root_.lt_trichotomy\n\ndef zero_le {n : Nat} (i : PFin2 (n+1)) :\n  .fz \u2264 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 \u2264 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 \u2192 \u2203k, 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 \u2264 last   := by apply last_is_maximal;\n    have : \u00ac last < j := by simp[this];\n    contradiction\n\n\n\n  def ofFin2 : Fin2 n \u2192 PFin2 n\n    | .fz   => .fz\n    | .fs i => .fs <| ofFin2 i\n\n  def toFin2 : PFin2 n \u2192 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) := \u27e8ofFin2\u27e9\n  instance : Coe (PFin2 n) (Fin2 n) := \u27e8toFin2\u27e9\n\n  instance : Coe (PFin2 n) (Fin n) := \u27e8toFin\u27e9\n  instance : Coe (Fin n) (PFin2 n) := \u27e8ofFin\u27e9\n\n  instance : Coe (Fin n) (Fin2 n) := \u27e8fun i => toFin2 <| ofFin.{0} i\u27e9\n  instance : Coe (Fin2 n) (Fin n) := \u27e8fun i => toFin <| ofFin2.{0} i\u27e9\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) := \u27e8fz\u27e9\ninstance (n : Nat) : OfNat (Fin2 (n+2)) (nat_lit 1) := \u27e8fs 0\u27e9\ninstance (n : Nat) : OfNat (Fin2 (n+3)) (nat_lit 2) := \u27e8fs 1\u27e9\n\n  def inv : Fin2 n \u2192 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 `\u22a2 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 : \u00ac P` as a hypothesis and we apply `exfalso`\nwe can then `apply h` to transform the goal into `\u22a2 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 `\u22a2 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 `\u00ac (P \u2208 line_through P Q)`, where \nthe symbol **\u00ac** means \"not\". Moreover, it can also be rewritten as `P \u2208 line_through P Q \u2192 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 `\u22a2 false`. Then, look\nfor a tactic that can turn the goal into `\u22a2 P \u2208 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 `\u22a2 Q` to `\u22a2 P` when we have a hypothesis of the form `h : P \u2192 Q`. In this case, `h : P \u2209 line_through P Q`\ncan be interpreted as `P \u2208 line_through P Q \u2192 false`. Then, because the goal is `\u22a2 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 {\u03a9 : Type} [IncidencePlane \u03a9] --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 : \u03a9) (h: P \u2209 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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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] \u27f6 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.\u03c3 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`\u03b8 : [n] \u27f6 \u0394'` is a non injective map in `simplex_category`, then\n`X.map \u03b8.op \u226b P_infty.f n = 0`. It follows from the more precise\nstatement vanishing statement `\u03c3_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_\u03c3 {Y : C} {X : simplicial_object C} {n b q : \u2115} {\u03c6 : Y \u27f6 X _[n+1]}\n  (v : higher_faces_vanish q \u03c6) (hnbq : n + 1 = b + q) :\n    higher_faces_vanish q (\u03c6 \u226b X.\u03c3 \u27e8b,\n    by simpa only [hnbq, nat.lt_succ_iff, le_add_iff_nonneg_right] using zero_le q\u27e9) :=\n\u03bb j hj, begin\n  rw [assoc, simplicial_object.\u03b4_comp_\u03c3_of_gt', fin.pred_succ,\n    v.comp_\u03b4_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 \u03c3_comp_P_eq_zero (X : simplicial_object C)\n  {n q : \u2115} (i : fin (n + 1)) (hi : n + 1 \u2264 i + q) : (X.\u03c3 i) \u226b (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 \u2264 (i : \u2115) + q,\n    { unfold P,\n      simp only [homological_complex.comp_f, \u2190 assoc],\n      rw [hq i h, zero_comp], },\n    { have hi' : n = (i : \u2115) + q,\n      { cases le_iff_exists_add.mp hi with j hj,\n        rw [\u2190 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 [\u2190 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\u03c3, 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\u03c3'_eq' (zero_add 0).symm, h\u03c3'_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.\u03b4_comp_\u03c3_self, simplicial_object.\u03b4_comp_\u03c3_self_assoc,\n          simplicial_object.\u03b4_comp_\u03c3_succ, comp_id, simplicial_object.\u03b4_comp_\u03c3_of_le X\n            (show (0 : fin(2)) \u2264 fin.cast_succ 0, by rw fin.cast_succ_zero),\n          simplicial_object.\u03b4_comp_\u03c3_self_assoc, simplicial_object.\u03b4_comp_\u03c3_succ_assoc],\n        abel, },\n      { rw [\u2190 id_comp (X.\u03c3 i), \u2190 (P_add_Q_f q n.succ : _ = \ud835\udfd9 (X.obj _)), add_comp, add_comp],\n        have v : higher_faces_vanish q ((P q).f n.succ \u226b X.\u03c3 i) :=\n          (higher_faces_vanish.of_P q n).comp_\u03c3 hi',\n        unfold P,\n        erw [\u2190 assoc, v.comp_P_eq_self, homological_complex.add_f_apply,\n          preadditive.comp_add, comp_id, v.comp_H\u03c3_eq hi', assoc,\n          simplicial_object.\u03b4_comp_\u03c3_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 \u27e8k, hk\u27e9 := 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 \u27e8i, by linarith\u27e9 :=\n            by { ext, simp only [fin.cast_succ_mk, fin.eta], },\n          have eq := hq j.rev.succ begin\n            simp only [\u2190 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.\u03c3_comp_\u03c3_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 \u03c3_comp_P_infty (X : simplicial_object C) {n : \u2115} (i : fin (n+1)) :\n  (X.\u03c3 i) \u226b P_infty.f (n+1) = 0 :=\nbegin\n  rw [P_infty_f, \u03c3_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 : \u2115) {\u0394' : simplex_category} (\u03b8 : [n] \u27f6 \u0394') (h\u03b8 : \u00acmono \u03b8) :\n  X.map \u03b8.op \u226b P_infty.f n = 0 :=\nbegin\n  rw simplex_category.mono_iff_injective at h\u03b8,\n  cases n,\n  { exfalso,\n    apply h\u03b8,\n    intros x y h,\n    fin_cases x,\n    fin_cases y, },\n  { obtain \u27e8i, \u03b1, h\u27e9 := simplex_category.eq_\u03c3_comp_of_not_injective \u03b8 h\u03b8,\n    rw [h, op_comp, X.map_comp, assoc, (show X.map (simplex_category.\u03c3 i).op = X.\u03c3 i, by refl),\n      \u03c3_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 `\u27ea P \u27eb` \n-- is also a valid proposition without quantifier instantiation `\u2983 P \u2984`:\ntheorem vc_valid_without_instantiations (P: prop):\n  \u27ea P \u27eb \u2192 \u2983 P \u2984\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 \u22a2 e: Q) \u2192 ((env.empty, e) \u27f6* s) \u2192 (is_value s \u2228 \u2203s', s \u27f6 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 \u03b2)`, treated as a key-value store.\n\nIf `\u03b1 : Type*` and `\u03b2 : \u03b1 \u2192 Type*`, then we regard `s : sigma \u03b2` as having key `s.1 : \u03b1` and value\n`s.2 : \u03b2 s.1`. Hence, `list (sigma \u03b2)` 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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v} {l l\u2081 l\u2082 : List (Sigma \u03b2)}\n\n/-! ### `keys` -/\n\n\n#print List.keys /-\n/-- List of keys from a list of key-value pairs -/\ndef keys : List (Sigma \u03b2) \u2192 List \u03b1 :=\n  map Sigma.fst\n#align list.keys List.keys\n-/\n\n#print List.keys_nil /-\n@[simp]\ntheorem keys_nil : @keys \u03b1 \u03b2 [] = [] :=\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 \u03b2)} : (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 \u03b2} {l : List (Sigma \u03b2)} : s \u2208 l \u2192 s.1 \u2208 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 \u03b2)} (h : a \u2208 l.keys) :\n    \u2203 b : \u03b2 a, Sigma.mk a b \u2208 l :=\n  let \u27e8\u27e8a', b'\u27e9, m, e\u27e9 := 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 \u03b2)} : a \u2208 l.keys \u2194 \u2203 b : \u03b2 a, Sigma.mk a b \u2208 l :=\n  \u27e8exists_of_mem_keys, fun \u27e8b, h\u27e9 => mem_keys_of_mem h\u27e9\n#align list.mem_keys List.mem_keys\n-/\n\n#print List.not_mem_keys /-\ntheorem not_mem_keys {a} {l : List (Sigma \u03b2)} : a \u2209 l.keys \u2194 \u2200 b : \u03b2 a, Sigma.mk a b \u2209 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 \u03b2)} : a \u2209 l.keys \u2194 \u2200 s : Sigma \u03b2, s \u2208 l \u2192 a \u2260 s.1 :=\n  Iff.intro (fun h\u2081 s h\u2082 e => absurd (mem_keys_of_mem h\u2082) (by rwa [e] at h\u2081)) fun f h\u2081 =>\n    let \u27e8b, h\u2082\u27e9 := exists_of_mem_keys h\u2081\n    f _ h\u2082 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 \u03b2)) : 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 \u2194 Pairwise (fun s s' : Sigma \u03b2 => s.1 \u2260 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 \u03b2 => s.1 \u2260 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 \u03b1 \u03b2 [] :=\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 \u03b2} {l : List (Sigma \u03b2)} :\n    NodupKeys (s :: l) \u2194 s.1 \u2209 l.keys \u2227 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 \u03b2} {l : List (Sigma \u03b2)} (h : NodupKeys (s :: l)) :\n    s.1 \u2209 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 \u03b2} {l : List (Sigma \u03b2)} (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 \u03b2)} (nd : NodupKeys l) {s s' : Sigma \u03b2} (h : s \u2208 l)\n    (h' : s' \u2208 l) : s.1 = s'.1 \u2192 s = s' :=\n  @Pairwise.forall_of_forall _ (fun s s' : Sigma \u03b2 => s.1 = s'.1 \u2192 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 : \u03b1} {b b' : \u03b2 a} {l : List (Sigma \u03b2)} (nd : NodupKeys l)\n    (h : Sigma.mk a b \u2208 l) (h' : Sigma.mk a b' \u2208 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 \u03b2) : NodupKeys [s] :=\n  nodup_singleton _\n#align list.nodupkeys_singleton List.nodupKeys_singleton\n-/\n\n#print List.NodupKeys.sublist /-\ntheorem NodupKeys.sublist {l\u2081 l\u2082 : List (Sigma \u03b2)} (h : l\u2081 <+ l\u2082) : NodupKeys l\u2082 \u2192 NodupKeys l\u2081 :=\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 \u03b2)} : NodupKeys l \u2192 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\u2081 l\u2082 : List (Sigma \u03b2)} (h : l\u2081 ~ l\u2082) : NodupKeys l\u2081 \u2194 NodupKeys l\u2082 :=\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 \u03b2))} :\n    NodupKeys (join L) \u2194 (\u2200 l \u2208 L, NodupKeys l) \u2227 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\u2081 l\u2082)\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 \u03b1) : (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\u2080 l\u2081 : List (Sigma \u03b2)} (nd\u2080 : l\u2080.Nodup) (nd\u2081 : l\u2081.Nodup)\n    (h : \u2200 x, x \u2208 l\u2080 \u2194 x \u2208 l\u2081) : l\u2080 ~ l\u2081 :=\n  by\n  induction' l\u2080 with x xs generalizing l\u2081 <;> cases' l\u2081 with y ys\n  \u00b7 constructor\n  iterate 2 \n    first |specialize h x|specialize h y; simp at h\n    cases h\n  simp at nd\u2080 nd\u2081\n  classical\n    obtain rfl | h' := eq_or_ne x y\n    \u00b7 constructor\n      refine' l\u2080_ih nd\u2080.2 nd\u2081.2 fun a => _\n      specialize h a\n      simp at h\n      obtain rfl | h' := eq_or_ne a x\n      \u00b7 exact iff_of_false nd\u2080.1 nd\u2081.1\n      \u00b7 simpa [h'] using h\n    \u00b7 trans x :: y :: ys.erase x\n      \u00b7 constructor\n        refine' l\u2080_ih nd\u2080.2 ((nd\u2081.2.erase\u2093 _).cons fun h => nd\u2081.1 <| mem_of_mem_erase h) fun a => _\n        \u00b7 specialize h a\n          simp at h\n          obtain rfl | h' := eq_or_ne a x\n          \u00b7 exact iff_of_false nd\u2080.1 fun h => h.elim h' nd\u2081.2.not_mem_erase\n          \u00b7 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      \u00b7 constructor\n      \u00b7 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 \u03b1]\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 : \u03b1) : List (Sigma \u03b2) \u2192 Option (\u03b2 a)\n  | [] => none\n  | \u27e8a', b\u27e9 :: 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 : \u03b1) : dlookup a [] = @none (\u03b2 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 : \u03b1) (b : \u03b2 a) : dlookup a (\u27e8a, b\u27e9 :: 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} : \u2200 s : Sigma \u03b2, a \u2260 s.1 \u2192 dlookup a (s :: l) = dlookup a l\n  | \u27e8a', b\u27e9, 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 : \u03b1} : \u2200 {l : List (Sigma \u03b2)}, (dlookup a l).isSome \u2194 a \u2208 l.keys\n  | [] => by simp\n  | \u27e8a', b\u27e9 :: l => by\n    by_cases h : a = a'\n    \u00b7 subst a'\n      simp\n    \u00b7 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 : \u03b1} {l : List (Sigma \u03b2)} : dlookup a l = none \u2194 a \u2209 l.keys := by\n  simp [\u2190 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 : \u03b1} {b : \u03b2 a} :\n    \u2200 {l : List (Sigma \u03b2)}, b \u2208 dlookup a l \u2192 Sigma.mk a b \u2208 l\n  | \u27e8a', b'\u27e9 :: l, H => by\n    by_cases h : a = a'\n    \u00b7 subst a'\n      simp at H\n      simp [H]\n    \u00b7 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 : \u03b2 a} {l : List (Sigma \u03b2)} (nd : l.NodupKeys) (h : Sigma.mk a b \u2208 l) :\n    b \u2208 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 : \u03b1) :\n    \u2200 l : List (Sigma \u03b2), (dlookup a l).map (Sigma.mk a) = find? (fun s => a = s.1) l\n  | [] => rfl\n  | \u27e8a', b'\u27e9 :: l => by\n    by_cases h : a = a'\n    \u00b7 subst a'\n      simp\n    \u00b7 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 : \u03b1} {b : \u03b2 a} {l : List (Sigma \u03b2)} (nd : l.NodupKeys) :\n    b \u2208 dlookup a l \u2194 Sigma.mk a b \u2208 l :=\n  \u27e8of_mem_dlookup, mem_dlookup nd\u27e9\n#align list.mem_lookup_iff List.mem_dlookup_iff\n-/\n\n#print List.perm_dlookup /-\ntheorem perm_dlookup (a : \u03b1) {l\u2081 l\u2082 : List (Sigma \u03b2)} (nd\u2081 : l\u2081.NodupKeys) (nd\u2082 : l\u2082.NodupKeys)\n    (p : l\u2081 ~ l\u2082) : dlookup a l\u2081 = dlookup a l\u2082 := by\n  ext b <;> simp [mem_lookup_iff, nd\u2081, nd\u2082] <;> exact p.mem_iff\n#align list.perm_lookup List.perm_dlookup\n-/\n\n#print List.lookup_ext /-\ntheorem lookup_ext {l\u2080 l\u2081 : List (Sigma \u03b2)} (nd\u2080 : l\u2080.NodupKeys) (nd\u2081 : l\u2081.NodupKeys)\n    (h : \u2200 x y, y \u2208 l\u2080.dlookup x \u2194 y \u2208 l\u2081.dlookup x) : l\u2080 ~ l\u2081 :=\n  mem_ext nd\u2080.Nodup nd\u2081.Nodup fun \u27e8a, b\u27e9 => by\n    rw [\u2190 mem_lookup_iff, \u2190 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 : \u03b1) : List (Sigma \u03b2) \u2192 List (\u03b2 a)\n  | [] => []\n  | \u27e8a', b\u27e9 :: 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 : \u03b1) : lookupAll a [] = @nil (\u03b2 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 : \u03b1) (b : \u03b2 a) : lookupAll a (\u27e8a, b\u27e9 :: 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} : \u2200 s : Sigma \u03b2, a \u2260 s.1 \u2192 lookupAll a (s :: l) = lookupAll a l\n  | \u27e8a', b\u27e9, 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 : \u03b1} :\n    \u2200 {l : List (Sigma \u03b2)}, lookupAll a l = [] \u2194 \u2200 b : \u03b2 a, Sigma.mk a b \u2209 l\n  | [] => by simp\n  | \u27e8a', b\u27e9 :: l => by\n    by_cases h : a = a'\n    \u00b7 subst a'\n      simp\n    \u00b7 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 : \u03b1) : \u2200 l : List (Sigma \u03b2), head? (lookupAll a l) = dlookup a l\n  | [] => by simp\n  | \u27e8a', b\u27e9 :: l => by\n    by_cases h : a = a' <;>\n      [\u00b7\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 : \u03b1} {b : \u03b2 a} :\n    \u2200 {l : List (Sigma \u03b2)}, b \u2208 lookupAll a l \u2194 Sigma.mk a b \u2208 l\n  | [] => by simp\n  | \u27e8a', b'\u27e9 :: l => by\n    by_cases h : a = a' <;>\n      [\u00b7\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 : \u03b1) : \u2200 l : List (Sigma \u03b2), (lookupAll a l).map (Sigma.mk a) <+ l\n  | [] => by simp\n  | \u27e8a', b'\u27e9 :: l => by\n    by_cases h : a = a'\n    \u00b7 subst h\n      simp\n      exact (lookup_all_sublist l).cons\u2082 _ _ _\n    \u00b7 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 : \u03b1) {l : List (Sigma \u03b2)} (h : l.NodupKeys) :\n    length (lookupAll a l) \u2264 1 := by\n  have := nodup.sublist ((lookup_all_sublist a l).map _) h <;> rw [map_map] at this <;>\n    rwa [\u2190 nodup_replicate, \u2190 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 : \u03b1) {l : List (Sigma \u03b2)} (h : l.NodupKeys) :\n    lookupAll a l = (dlookup a l).toList :=\n  by\n  rw [\u2190 head_lookup_all]\n  have := lookup_all_length_le_one a h; revert this\n  rcases lookup_all a l with (_ | \u27e8b, _ | \u27e8c, l\u27e9\u27e9) <;> 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 : \u03b1) {l : List (Sigma \u03b2)} (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 : \u03b1) {l\u2081 l\u2082 : List (Sigma \u03b2)} (nd\u2081 : l\u2081.NodupKeys) (nd\u2082 : l\u2082.NodupKeys)\n    (p : l\u2081 ~ l\u2082) : lookupAll a l\u2081 = lookupAll a l\u2082 := by\n  simp [lookup_all_eq_lookup, nd\u2081, nd\u2082, perm_lookup a nd\u2081 nd\u2082 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 : \u03b1) (b : \u03b2 a) : List (Sigma \u03b2) \u2192 List (Sigma \u03b2) :=\n  lookmap fun s => if a = s.1 then some \u27e8a, b\u27e9 else none\n#align list.kreplace List.kreplace\n-/\n\n#print List.kreplace_of_forall_not /-\ntheorem kreplace_of_forall_not (a : \u03b1) (b : \u03b2 a) {l : List (Sigma \u03b2)}\n    (H : \u2200 b : \u03b2 a, Sigma.mk a b \u2209 l) : kreplace a b l = l :=\n  lookmap_of_forall_not _ <| by\n    rintro \u27e8a', b'\u27e9 h; dsimp; split_ifs\n    \u00b7 subst a'\n      exact H _ h; \u00b7 rfl\n#align list.kreplace_of_forall_not List.kreplace_of_forall_not\n-/\n\n#print List.kreplace_self /-\ntheorem kreplace_self {a : \u03b1} {b : \u03b2 a} {l : List (Sigma \u03b2)} (nd : NodupKeys l)\n    (h : Sigma.mk a b \u2208 l) : kreplace a b l = l :=\n  by\n  refine' (lookmap_congr _).trans (lookmap_id' (Option.guard fun s => a = s.1) _ _)\n  \u00b7 rintro \u27e8a', b'\u27e9 h'\n    dsimp [Option.guard]\n    split_ifs\n    \u00b7 subst a'\n      exact \u27e8rfl, hEq_of_eq <| nd.eq_of_mk_mem h h'\u27e9\n    \u00b7 rfl\n  \u00b7 rintro \u27e8a\u2081, b\u2081\u27e9 \u27e8a\u2082, b\u2082\u27e9\n    dsimp [Option.guard]\n    split_ifs\n    \u00b7 exact id\n    \u00b7 rintro \u27e8\u27e9\n#align list.kreplace_self List.kreplace_self\n-/\n\n#print List.keys_kreplace /-\ntheorem keys_kreplace (a : \u03b1) (b : \u03b2 a) : \u2200 l : List (Sigma \u03b2), (kreplace a b l).keys = l.keys :=\n  lookmap_map_eq _ _ <| by\n    rintro \u27e8a\u2081, b\u2082\u27e9 \u27e8a\u2082, b\u2082\u27e9 <;> 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 : \u03b1) (b : \u03b2 a) {l : List (Sigma \u03b2)} :\n    (kreplace a b l).NodupKeys \u2194 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 : \u03b1} {b : \u03b2 a} {l\u2081 l\u2082 : List (Sigma \u03b2)} (nd : l\u2081.NodupKeys) :\n    l\u2081 ~ l\u2082 \u2192 kreplace a b l\u2081 ~ kreplace a b l\u2082 :=\n  perm_lookmap _ <| by\n    refine' nd.pairwise_ne.imp _\n    intro x y h z h\u2081 w h\u2082\n    split_ifs  at h\u2081 h\u2082 <;> cases h\u2081 <;> cases h\u2082\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 : \u03b1) : List (Sigma \u03b2) \u2192 List (Sigma \u03b2) :=\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 _ \u03b2 _ 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 \u03b2} {l : List (Sigma \u03b2)} (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 \u03b2} {l : List (Sigma \u03b2)} (h : a \u2260 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 \u03b2)} (h : a \u2209 l.keys) : kerase a l = l := by\n  induction' l with _ _ ih <;> [rfl,\n    \u00b7 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 : \u03b1) (l : List (Sigma \u03b2)) : 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 \u03b2)) : (kerase a l).keys \u2286 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\u2081 a\u2082} {l : List (Sigma \u03b2)} :\n    a\u2081 \u2208 (kerase a\u2082 l).keys \u2192 a\u2081 \u2208 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 : \u03b1} {l : List (Sigma \u03b2)} (h : a \u2208 l.keys) :\n    \u2203 (b : \u03b2 a)(l\u2081 l\u2082 : List (Sigma \u03b2)),\n      a \u2209 l\u2081.keys \u2227 l = l\u2081 ++ \u27e8a, b\u27e9 :: l\u2082 \u2227 kerase a l = l\u2081 ++ l\u2082 :=\n  by\n  induction l\n  case nil => cases h\n  case cons hd tl ih =>\n    by_cases e : a = hd.1\n    \u00b7 subst e\n      exact \u27e8hd.2, [], tl, by simp, by cases hd <;> rfl, by simp\u27e9\n    \u00b7 simp at h\n      cases h\n      case inl h => exact absurd h e\n      case inr h =>\n        rcases ih h with \u27e8b, tl\u2081, tl\u2082, h\u2081, h\u2082, h\u2083\u27e9\n        exact\n          \u27e8b, hd :: tl\u2081, tl\u2082, not_mem_cons_of_ne_of_not_mem e h\u2081, by rw [h\u2082] <;> rfl, by\n            simp [e, h\u2083]\u27e9\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\u2081 a\u2082} {l : List (Sigma \u03b2)} (h : a\u2081 \u2260 a\u2082) :\n    a\u2081 \u2208 (kerase a\u2082 l).keys \u2194 a\u2081 \u2208 l.keys :=\n  Iff.intro mem_keys_of_mem_keys_kerase fun p =>\n    if q : a\u2082 \u2208 l.keys then\n      match l, kerase a\u2082 l, exists_of_kerase q, p with\n      | _, _, \u27e8_, _, _, _, rfl, rfl\u27e9, 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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {a : \u03b1} {l : List.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2)}, Eq.{succ u1} (List.{u1} \u03b1) (List.keys.{u1, u2} \u03b1 \u03b2 (List.kerase.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a l)) (List.erase\u2093.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (List.keys.{u1, u2} \u03b1 \u03b2 l) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {a : \u03b1} {l : List.{max u2 u1} (Sigma.{u1, u2} \u03b1 \u03b2)}, Eq.{succ u1} (List.{u1} \u03b1) (List.keys.{u1, u2} \u03b1 \u03b2 (List.kerase.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a l)) (List.erase.{u1} \u03b1 (instBEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (List.keys.{u1, u2} \u03b1 \u03b2 l) a)\nCase conversion may be inaccurate. Consider using '#align list.keys_kerase List.keys_kerase\u2093'. -/\ntheorem keys_kerase {a} {l : List (Sigma \u03b2)} : (kerase a l).keys = l.keys.erase\u2093 a := by\n  rw [keys, kerase, \u2190 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 \u03b2)} :\n    (kerase a' l).kerase a = (kerase a l).kerase a' :=\n  by\n  by_cases a = a'\n  \u00b7 subst a'\n  induction' l with x xs; \u00b7 rfl\n  \u00b7 by_cases a' = x.1\n    \u00b7 subst a'\n      simp [kerase_cons_ne h, kerase_cons_eq rfl]\n    by_cases h' : a = x.1\n    \u00b7 subst a\n      simp [kerase_cons_eq rfl, kerase_cons_ne (Ne.symm h)]\n    \u00b7 simp [kerase_cons_ne, *]\n#align list.kerase_kerase List.kerase_kerase\n-/\n\n#print List.NodupKeys.kerase /-\ntheorem NodupKeys.kerase (a : \u03b1) : NodupKeys l \u2192 (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 : \u03b1} {l\u2081 l\u2082 : List (Sigma \u03b2)} (nd : l\u2081.NodupKeys) :\n    l\u2081 ~ l\u2082 \u2192 kerase a l\u2081 ~ kerase a l\u2082 :=\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 \u03b2)} (nd : l.NodupKeys) : a \u2209 (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    \u00b7 subst h\n      simp [nd.1]\n    \u00b7 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 \u03b2)} (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 \u03b2)} (h : a \u2260 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\u2081 : a = ah <;> by_cases h\u2082 : a' = ah\n    \u00b7 substs h\u2081 h\u2082\n      cases Ne.irrefl h\n    \u00b7 subst h\u2081\n      simp [h\u2082]\n    \u00b7 subst h\u2082\n      simp [h]\n    \u00b7 simp [h\u2081, h\u2082, 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    \u2200 {l\u2081 l\u2082 : List (Sigma \u03b2)}, a \u2208 l\u2081.keys \u2192 kerase a (l\u2081 ++ l\u2082) = kerase a l\u2081 ++ l\u2082\n  | [], _, h => by cases h\n  | s :: l\u2081, l\u2082, h\u2081 =>\n    if h\u2082 : a = s.1 then by simp [h\u2082]\n    else by simp at h\u2081 <;> cases h\u2081 <;> [exact absurd h\u2081 h\u2082, simp [h\u2082, kerase_append_left h\u2081]]\n#align list.kerase_append_left List.kerase_append_left\n-/\n\n#print List.kerase_append_right /-\ntheorem kerase_append_right {a} :\n    \u2200 {l\u2081 l\u2082 : List (Sigma \u03b2)}, a \u2209 l\u2081.keys \u2192 kerase a (l\u2081 ++ l\u2082) = l\u2081 ++ kerase a l\u2082\n  | [], _, h => rfl\n  | _ :: l\u2081, l\u2082, 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\u2081 a\u2082) (l : List (Sigma \u03b2)) :\n    kerase a\u2082 (kerase a\u2081 l) = kerase a\u2081 (kerase a\u2082 l) :=\n  if h : a\u2081 = a\u2082 then by simp [h]\n  else\n    if ha\u2081 : a\u2081 \u2208 l.keys then\n      if ha\u2082 : a\u2082 \u2208 l.keys then\n        match l, kerase a\u2081 l, exists_of_kerase ha\u2081, ha\u2082 with\n        | _, _, \u27e8b\u2081, l\u2081, l\u2082, a\u2081_nin_l\u2081, rfl, rfl\u27e9, a\u2082_in_l\u2081_app_l\u2082 =>\n          if h' : a\u2082 \u2208 l\u2081.keys then by\n            simp [kerase_append_left h',\n              kerase_append_right (mt (mem_keys_kerase_of_ne h).mp a\u2081_nin_l\u2081)]\n          else by\n            simp [kerase_append_right h', kerase_append_right a\u2081_nin_l\u2081,\n              @kerase_cons_ne _ _ _ a\u2082 \u27e8a\u2081, b\u2081\u27e9 _ (Ne.symm h)]\n      else by simp [ha\u2082, mt mem_keys_of_mem_keys_kerase ha\u2082]\n    else by simp [ha\u2081, mt mem_keys_of_mem_keys_kerase ha\u2081]\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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_2 : DecidableEq.{succ u1} \u03b1] [_inst_3 : SizeOf.{max (succ u1) (succ u2)} (Sigma.{u1, u2} \u03b1 \u03b2)] (x : \u03b1) (xs : List.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2)), LE.le.{0} Nat Nat.hasLe (SizeOf.sizeOf.{succ (max u1 u2)} (List.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2)) (List.hasSizeof.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2) _inst_3) (List.kerase.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) x xs)) (SizeOf.sizeOf.{succ (max u1 u2)} (List.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2)) (List.hasSizeof.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2) _inst_3) xs)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : \u03b1 -> Type.{u1}} [_inst_2 : DecidableEq.{succ u2} \u03b1] [_inst_3 : SizeOf.{max (succ u1) (succ u2)} (Sigma.{u2, u1} \u03b1 \u03b2)] (x : \u03b1) (xs : List.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2)), LE.le.{0} Nat instLENat (SizeOf.sizeOf.{max (succ u1) (succ u2)} (List.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2)) (List._sizeOf_inst.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2) _inst_3) (List.kerase.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) x xs)) (SizeOf.sizeOf.{max (succ u1) (succ u2)} (List.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2)) (List._sizeOf_inst.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2) _inst_3) xs)\nCase conversion may be inaccurate. Consider using '#align list.sizeof_kerase List.sizeOf_kerase\u2093'. -/\ntheorem sizeOf_kerase {\u03b1} {\u03b2 : \u03b1 \u2192 Type _} [DecidableEq \u03b1] [SizeOf (Sigma \u03b2)] (x : \u03b1)\n    (xs : List (Sigma \u03b2)) : SizeOf.sizeOf (List.kerase x xs) \u2264 SizeOf.sizeOf xs :=\n  by\n  unfold_wf\n  induction' xs with y ys\n  \u00b7 simp\n  \u00b7 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 `\u27e8a, b\u27e9` and erase the first pair with the key `a`. -/\ndef kinsert (a : \u03b1) (b : \u03b2 a) (l : List (Sigma \u03b2)) : List (Sigma \u03b2) :=\n  \u27e8a, b\u27e9 :: kerase a l\n#align list.kinsert List.kinsert\n-/\n\n#print List.kinsert_def /-\n@[simp]\ntheorem kinsert_def {a} {b : \u03b2 a} {l : List (Sigma \u03b2)} : kinsert a b l = \u27e8a, b\u27e9 :: 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' : \u03b2 a'} {l : List (Sigma \u03b2)} :\n    a \u2208 (kinsert a' b' l).keys \u2194 a = a' \u2228 a \u2208 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 : \u03b2 a) {l : List (Sigma \u03b2)} (nd : l.NodupKeys) :\n    (kinsert a b l).NodupKeys :=\n  nodupKeys_cons.mpr \u27e8not_mem_keys_kerase a nd, nd.kerase a\u27e9\n#align list.kinsert_nodupkeys List.kinsert_nodupKeys\n-/\n\n#print List.Perm.kinsert /-\ntheorem Perm.kinsert {a} {b : \u03b2 a} {l\u2081 l\u2082 : List (Sigma \u03b2)} (nd\u2081 : l\u2081.NodupKeys) (p : l\u2081 ~ l\u2082) :\n    kinsert a b l\u2081 ~ kinsert a b l\u2082 :=\n  (p.kerase nd\u2081).cons _\n#align list.perm.kinsert List.Perm.kinsert\n-/\n\n#print List.dlookup_kinsert /-\ntheorem dlookup_kinsert {a} {b : \u03b2 a} (l : List (Sigma \u03b2)) : 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' : \u03b2 a'} {l : List (Sigma \u03b2)} (h : a \u2260 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 : \u03b1) : List (Sigma \u03b2) \u2192 Option (\u03b2 a) \u00d7 List (Sigma \u03b2)\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 : \u03b1) :\n    \u2200 l : List (Sigma \u03b2), kextract a l = (dlookup a l, kerase a l)\n  | [] => rfl\n  | \u27e8a', b\u27e9 :: l => by\n    simp [kextract]; dsimp; split_ifs\n    \u00b7 subst a'\n      simp [kerase]\n    \u00b7 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 \u03b2)`. -/\ndef dedupKeys : List (Sigma \u03b2) \u2192 List (Sigma \u03b2) :=\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 \u03b2} (l : List (Sigma \u03b2)) :\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 \u03b2)) : NodupKeys (dedupKeys l) :=\n  by\n  dsimp [dedupkeys]\n  generalize hl : nil = l'\n  have : nodupkeys l' := by\n    rw [\u2190 hl]\n    apply nodup_nil\n  clear hl\n  induction' l with x xs\n  \u00b7 apply this\n  \u00b7 cases x\n    simp [dedupkeys]\n    constructor\n    \u00b7 simp [keys_kerase]\n      apply l_ih.not_mem_erase\n    \u00b7 exact l_ih.kerase _\n#align list.nodupkeys_dedupkeys List.nodupKeys_dedupKeys\n-/\n\n#print List.dlookup_dedupKeys /-\ntheorem dlookup_dedupKeys (a : \u03b1) (l : List (Sigma \u03b2)) : 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  \u00b7 subst a'\n    rw [dedupkeys_cons, lookup_kinsert, lookup_cons_eq]\n  \u00b7 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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_2 : DecidableEq.{succ u1} \u03b1] [_inst_3 : SizeOf.{max (succ u1) (succ u2)} (Sigma.{u1, u2} \u03b1 \u03b2)] (xs : List.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2)), LE.le.{0} Nat Nat.hasLe (SizeOf.sizeOf.{succ (max u1 u2)} (List.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2)) (List.hasSizeof.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2) _inst_3) (List.dedupKeys.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) xs)) (SizeOf.sizeOf.{succ (max u1 u2)} (List.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2)) (List.hasSizeof.{max u1 u2} (Sigma.{u1, u2} \u03b1 \u03b2) _inst_3) xs)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : \u03b1 -> Type.{u1}} [_inst_2 : DecidableEq.{succ u2} \u03b1] [_inst_3 : SizeOf.{max (succ u1) (succ u2)} (Sigma.{u2, u1} \u03b1 \u03b2)] (xs : List.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2)), LE.le.{0} Nat instLENat (SizeOf.sizeOf.{max (succ u1) (succ u2)} (List.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2)) (List._sizeOf_inst.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2) _inst_3) (List.dedupKeys.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_2 a b) xs)) (SizeOf.sizeOf.{max (succ u1) (succ u2)} (List.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2)) (List._sizeOf_inst.{max u1 u2} (Sigma.{u2, u1} \u03b1 \u03b2) _inst_3) xs)\nCase conversion may be inaccurate. Consider using '#align list.sizeof_dedupkeys List.sizeOf_dedupKeys\u2093'. -/\ntheorem sizeOf_dedupKeys {\u03b1} {\u03b2 : \u03b1 \u2192 Type _} [DecidableEq \u03b1] [SizeOf (Sigma \u03b2)]\n    (xs : List (Sigma \u03b2)) : SizeOf.sizeOf (List.dedupKeys xs) \u2264 SizeOf.sizeOf xs :=\n  by\n  unfold_wf\n  induction' xs with x xs\n  \u00b7 simp [List.dedupKeys]\n  \u00b7 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\u2081 l\u2082` is the append to l\u2081 of l\u2082 after, for each key in l\u2081, the\nfirst matching pair in l\u2082 is erased. -/\ndef kunion : List (Sigma \u03b2) \u2192 List (Sigma \u03b2) \u2192 List (Sigma \u03b2)\n  | [], l\u2082 => l\u2082\n  | s :: l\u2081, l\u2082 => s :: kunion l\u2081 (kerase s.1 l\u2082)\n#align list.kunion List.kunion\n-/\n\n#print List.nil_kunion /-\n@[simp]\ntheorem nil_kunion {l : List (Sigma \u03b2)} : 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 : \u2200 {l : List (Sigma \u03b2)}, 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\u2081 l\u2082 : List (Sigma \u03b2)} :\n    kunion (s :: l\u2081) l\u2082 = s :: kunion l\u2081 (kerase s.1 l\u2082) :=\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\u2081 l\u2082 : List (Sigma \u03b2)} :\n    a \u2208 (kunion l\u2081 l\u2082).keys \u2194 a \u2208 l\u2081.keys \u2228 a \u2208 l\u2082.keys :=\n  by\n  induction l\u2081 generalizing l\u2082\n  case nil => simp\n  case cons s l\u2081 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    \u2200 {l\u2081 l\u2082 : List (Sigma \u03b2)}, kunion (kerase a l\u2081) (kerase a l\u2082) = kerase a (kunion l\u2081 l\u2082)\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\u2081 : l\u2081.NodupKeys) (nd\u2082 : l\u2082.NodupKeys) : (kunion l\u2081 l\u2082).NodupKeys :=\n  by\n  induction l\u2081 generalizing l\u2082\n  case nil => simp only [nil_kunion, nd\u2082]\n  case cons s l\u2081 ih =>\n    simp at nd\u2081\n    simp [not_or, nd\u2081.1, nd\u2082, ih nd\u2081.2 (nd\u2082.kerase s.1)]\n#align list.nodupkeys.kunion List.NodupKeys.kunion\n-/\n\n#print List.Perm.kunion_right /-\ntheorem Perm.kunion_right {l\u2081 l\u2082 : List (Sigma \u03b2)} (p : l\u2081 ~ l\u2082) (l) : kunion l\u2081 l ~ kunion l\u2082 l :=\n  by\n  induction p generalizing l\n  case nil => rfl\n  case cons hd tl\u2081 tl\u2082 p ih => simp [ih (kerase hd.1 l), perm.cons]\n  case swap s\u2081 s\u2082 l => simp [kerase_comm, perm.swap]\n  case trans l\u2081 l\u2082 l\u2083 p\u2081\u2082 p\u2082\u2083 ih\u2081\u2082 ih\u2082\u2083 => exact perm.trans (ih\u2081\u2082 l) (ih\u2082\u2083 l)\n#align list.perm.kunion_right List.Perm.kunion_right\n-/\n\n#print List.Perm.kunion_left /-\ntheorem Perm.kunion_left :\n    \u2200 (l) {l\u2081 l\u2082 : List (Sigma \u03b2)}, l\u2081.NodupKeys \u2192 l\u2081 ~ l\u2082 \u2192 kunion l l\u2081 ~ kunion l l\u2082\n  | [], _, _, _, p => p\n  | s :: l, l\u2081, l\u2082, nd\u2081, p => by simp [((p.kerase nd\u2081).kunion_left l <| nd\u2081.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\u2081 l\u2082 l\u2083 l\u2084 : List (Sigma \u03b2)} (nd\u2083 : l\u2083.NodupKeys) (p\u2081\u2082 : l\u2081 ~ l\u2082)\n    (p\u2083\u2084 : l\u2083 ~ l\u2084) : kunion l\u2081 l\u2083 ~ kunion l\u2082 l\u2084 :=\n  (p\u2081\u2082.kunion_right l\u2083).trans (p\u2083\u2084.kunion_left l\u2082 nd\u2083)\n#align list.perm.kunion List.Perm.kunion\n-/\n\n#print List.dlookup_kunion_left /-\n@[simp]\ntheorem dlookup_kunion_left {a} {l\u2081 l\u2082 : List (Sigma \u03b2)} (h : a \u2208 l\u2081.keys) :\n    dlookup a (kunion l\u2081 l\u2082) = dlookup a l\u2081 :=\n  by\n  induction' l\u2081 with s _ ih generalizing l\u2082 <;> simp at h <;> cases h <;> cases' s with a'\n  \u00b7 subst h\n    simp\n  \u00b7 rw [kunion_cons]\n    by_cases h' : a = a'\n    \u00b7 subst h'\n      simp\n    \u00b7 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\u2081 l\u2082 : List (Sigma \u03b2)} (h : a \u2209 l\u2081.keys) :\n    dlookup a (kunion l\u2081 l\u2082) = dlookup a l\u2082 :=\n  by\n  induction l\u2081 generalizing l\u2082\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 : \u03b2 a} {l\u2081 l\u2082 : List (Sigma \u03b2)} :\n    b \u2208 dlookup a (kunion l\u2081 l\u2082) \u2194 b \u2208 dlookup a l\u2081 \u2228 a \u2209 l\u2081.keys \u2227 b \u2208 dlookup a l\u2082 :=\n  by\n  induction l\u2081 generalizing l\u2082\n  case nil => simp\n  case cons s _ ih =>\n    cases' s with a'\n    by_cases h\u2081 : a = a'\n    \u00b7 subst h\u2081\n      simp\n    \u00b7 let h\u2082 := @ih (kerase a' l\u2082)\n      simp [h\u2081] at h\u2082\n      simp [h\u2081, h\u2082]\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 : \u03b2 a} {l\u2081 l\u2082 l\u2083 : List (Sigma \u03b2)}\n    (h\u2081 : b \u2208 dlookup a (kunion l\u2081 l\u2083)) (h\u2082 : a \u2209 keys l\u2082) :\n    b \u2208 dlookup a (kunion (kunion l\u2081 l\u2082) l\u2083) :=\n  match mem_dlookup_kunion.mp h\u2081 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 \u27e8mt mem_keys_kunion.mp (not_or.mpr \u27e8h.1, h\u2082\u27e9), h.2\u27e9\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\u2082\u2085\u20871 (l: list \u2115) : option \u2115 :=\nmatch list.nth l 1 with \n| option.none    := option.none \n| option.some n\u2082 := match list.nth l 4 with \n                    | option.none    := option.none\n                    | option.some n\u2085 := match list.nth l 6 with \n                                        | option.none    := option.none \n                                        | option.some n\u2087 := option.some (n\u2082 + n\u2085 + n\u2087)\n                                        end\n                    end\nend\n\n/-\n  If we had a function that allow us to update the internal value of a option \u03b1 via\n  a fn on the left we could rewrite this in a more imperative manner. \n-/\n\ndef connect {\u03b1 \u03b2 : Type} : option \u03b1 \u2192 (\u03b1 \u2192 option \u03b2) \u2192 option \u03b2 \n| option.none _    := option.none \n| (option.some a) f := f a\n\n\ndef sum\u2082\u2085\u20872 (l: list \u2115) : option \u2115 := connect (list.nth l 1) \n                                      (\u03bb n\u2082, connect (list.nth l 4) \n                                      (\u03bb n\u2085, connect (list.nth l 6)\n                                      (\u03bb n\u2087, option.some (n\u2082 + n\u2085 +n\u2087))))\n\n/-\n  connect is rewritten as >>= and pronounced \"bind\". \n  the function n \u21a6 some n is rewritten as \"pure\"\n-/\n\ndef sum\u2082\u2085\u20873 (l: list \u2115) : option \u2115 := \n  (list.nth l 1) >>= (\u03bb n\u2082, \n  (list.nth l 4) >>= (\u03bb n\u2085, \n  (list.nth l 6) >>= (\u03bb n\u2087, \n  pure (n\u2082 + n\u2085 + n\u2087))))\n\n/-\n  this looks a lot like the imperative program\n  let n\u2082 = l[1];\n  let n\u2085 = l[4];\n  let n\u2086 = l[5];\n  return n\u2082 + n\u2085 + n\u2087\n\n  Functional programming languages the following notation\n  do x \u2190 ma, t    is equiv to    ma >>= (\u03bb x, t) \n-/\n\ndef sum\u2082\u2085\u20874 (l: list \u2115) : option \u2115 := do n\u2082 \u2190 list.nth l 1,\n                                      (do n\u2085 \u2190 list.nth l 4,\n                                      (do n\u2087 \u2190 list.nth l 6,\n                                          pure (n\u2082 + n\u2085 + n\u2087)))\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 >>= (\u03bb x, (f x) >>= g)\n\n  so do x \u2190 (pure a), pure (f x) = pure a >>= (\u03bb x, pure (f x)) = pure (f a)\n  so we can think of the last term as the return value. (m >>= f) >>= g = m >>= (\u03bb x, (f x) >>= g)\n  means we don't really care how the do's are bracketed in sum\u2082\u2085\u2087 so we can just drop them. \n-/\n\ndef sum\u2082\u2085\u20875 (l: list \u2115) : option \u2115 :=\n  do n\u2082 \u2190 list.nth l 1,\n     n\u2085 \u2190 list.nth l 5,\n     n\u2087 \u2190 list.nth l 7,\n     pure (n\u2082 + n\u2085 + n\u2087)\n\n\n/-\n  any fn m : Type u \u2192 Type u with similar operations >>= and pure satifying (*)\n  is called a monad. Using >>= and pure we can defn m\u2081 >> m\u2082 = m\u2081 >>= (\u03bb a, m\u2082).\n  do s, t is sugar for s >> t. <|> : m a \u2192 m a \u2192 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 \u2192 level\n  | max   : level \u2192 level \u2192 level\n  | imax  : level \u2192 level \u2192 level\n  | param : name \u2192 level\n  | mvar  : name \u2192 level\n\n  inductive expr\n  | var    : nat \u2192 expr\n  | lconst : name \u2192 name \u2192 expr\n  | mvar   : name \u2192 expr \u2192 expr\n  | sort   : level \u2192 expr\n  | const  : name \u2192 list level \u2192 expr\n  | app    : expr \u2192 expr \u2192 expr\n  | lam    : name \u2192 binfo \u2192 expr \u2192 expr \u2192 expr\n  | pi     : name \u2192 binfo \u2192 expr \u2192 expr \u2192 expr\n  | elet   : name \u2192 expr \u2192 expr \u2192 expr \u2192 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`\u00a0in `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##\u00a0Main declarations\n\nBesides `open_nhds`, the main constructions here are:\n\n* `inclusion (x : X)`: the obvious functor `open_nhds x \u2964 opens X`\n* `functor_nhds`: An open map `f : X \u27f6 Y` induces a functor `open_nhds x \u2964 open_nhds (f x)`\n* `adjunction_nhds`: An open map `f : X \u27f6 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 \u27f6 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 (\u03bb (U : opens X), x \u2208 U)\n\nnamespace open_nhds\n\ninstance (x : X) : partial_order (open_nhds x) :=\n{ le := \u03bb U V, U.1 \u2264 V.1,\n  le_refl := \u03bb _, le_rfl,\n  le_trans := \u03bb _ _ _, le_trans,\n  le_antisymm := \u03bb _ _ i j, full_subcategory.ext _ _ $ le_antisymm i j }\n\ninstance (x : X) : lattice (open_nhds x) :=\n{ inf := \u03bb U V, \u27e8U.1 \u2293 V.1, \u27e8U.2, V.2\u27e9\u27e9,\n  le_inf := \u03bb U V W, @le_inf _ _ U.1.1 V.1.1 W.1.1,\n  inf_le_left := \u03bb U V, @inf_le_left _ _ U.1.1 V.1.1,\n  inf_le_right := \u03bb U V, @inf_le_right _ _ U.1.1 V.1.1,\n  sup := \u03bb U V, \u27e8U.1 \u2294 V.1, V.1.1.mem_union_left U.2\u27e9,\n  sup_le := \u03bb U V W, @sup_le _ _ U.1.1 V.1.1 W.1.1,\n  le_sup_left := \u03bb U V, @le_sup_left _ _ U.1.1 V.1.1,\n  le_sup_right := \u03bb 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 := \u27e8\u22a4, trivial\u27e9,\n  le_top := \u03bb _, le_top }\n\ninstance (x : X) : inhabited (open_nhds x) := \u27e8\u22a4\u27e9\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 \u27f6 V) (\u03bb _, U.1 \u2192 V.1) :=\n\u27e8\u03bb f x, \u27e8x, f.le x.2\u27e9\u27e9\n\n/--\nThe inclusion `U \u2293 V \u27f6 U` as a morphism in the category of open sets.\n-/\ndef inf_le_left {x : X} (U V : open_nhds x) : U \u2293 V \u27f6 U :=\nhom_of_le inf_le_left\n\n/--\nThe inclusion `U \u2293 V \u27f6 V` as a morphism in the category of open sets.\n-/\ndef inf_le_right {x : X} (U V : open_nhds x) : U \u2293 V \u27f6 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 \u2964 opens X :=\nfull_subcategory_inclusion _\n\n@[simp] lemma inclusion_obj (x : X) (U) (p) : (inclusion x).obj \u27e8U,p\u27e9 = 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) \u2964 open_nhds x :=\n{ obj := \u03bb U, \u27e8(opens.map f).obj U.1, U.2\u27e9,\n  map := \u03bb U V i, (opens.map f).map i }\n\n@[simp] lemma map_obj (x : X) (U) (q) : (map f x).obj \u27e8U, q\u27e9 = \u27e8(opens.map f).obj U, by tidy\u27e9 :=\nrfl\n@[simp] lemma map_id_obj (x : X) (U) : (map (\ud835\udfd9 X) x).obj U = U :=\nby tidy\n@[simp] lemma map_id_obj' (x : X) (U) (p) (q) : (map (\ud835\udfd9 X) x).obj \u27e8\u27e8U, p\u27e9, q\u27e9 = \u27e8\u27e8U, p\u27e9, q\u27e9 :=\nrfl\n\n@[simp] lemma map_id_obj_unop (x : X) (U : (open_nhds x)\u1d52\u1d56) : (map (\ud835\udfd9 X) x).obj (unop U) = unop U :=\nby simp\n@[simp] lemma op_map_id_obj (x : X) (U : (open_nhds x)\u1d52\u1d56) : (map (\ud835\udfd9 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) \u22d9 opens.map f \u2245 map f x \u22d9 inclusion x :=\nnat_iso.of_components\n  (\u03bb U, begin split, exact \ud835\udfd9 _, exact \ud835\udfd9 _ end)\n  (by tidy)\n\n@[simp] lemma inclusion_map_iso_hom (x : X) : (inclusion_map_iso f x).hom = \ud835\udfd9 _ := rfl\n@[simp] lemma inclusion_map_iso_inv (x : X) : (inclusion_map_iso f x).inv = \ud835\udfd9 _ := 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 \u27f6 Y` induces a functor `open_nhds x \u2964 open_nhds (f x)`.\n-/\n@[simps]\ndef functor_nhds (h : is_open_map f) (x : X) :\n  open_nhds x \u2964 open_nhds (f x) :=\n{ obj := \u03bb U, \u27e8h.functor.obj U.1, \u27e8x, U.2, rfl\u27e9\u27e9,\n  map := \u03bb U V i, h.functor.map i }\n\n/--\nAn open map `f : X \u27f6 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 \u22a3 open_nhds.map f x :=\nadjunction.mk_of_unit_counit\n{ unit := { app := \u03bb U, hom_of_le $ \u03bb x hxU, \u27e8x, hxU, rfl\u27e9 },\n  counit := { app := \u03bb V, hom_of_le $ \u03bb y \u27e8x, hfxV, hxy\u27e9, hxy \u25b8 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 {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w}\n\nnamespace List\n\n@[simp] theorem length_nil : length ([] : List \u03b1) = 0 :=\n  rfl\n\ndef reverseAux : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\n  | [],   r => r\n  | a::l, r => reverseAux l (a::r)\n\ndef reverse (as : List \u03b1) :List \u03b1 :=\n  reverseAux as []\n\nprotected def append (as bs : List \u03b1) : List \u03b1 :=\n  reverseAux as.reverse bs\n\ninstance : Append (List \u03b1) := \u27e8List.append\u27e9\n\ntheorem reverseAux_reverseAux_nil (as bs : List \u03b1) : 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 \u03b1) : [] ++ as = as := rfl\n\n@[simp] theorem append_nil (as : List \u03b1) : as ++ [] = as := by\n  show reverseAux (reverseAux as []) [] = as\n  simp [reverseAux_reverseAux_nil, reverseAux]\n\ntheorem reverseAux_reverseAux (as bs cs : List \u03b1) : 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 : \u03b1) (as bs : List \u03b1) : (a::as) ++ bs = a::(as ++ bs) :=\n  reverseAux_reverseAux as [a] bs\n\ntheorem append_assoc (as bs cs : List \u03b1) : (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 \u03b1) := \u27e8List.nil\u27e9\n\nprotected def erase {\u03b1} [BEq \u03b1] : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1\n  | [],    b => []\n  | a::as, b => match a == b with\n    | true  => as\n    | false => a :: List.erase as b\n\ndef eraseIdx : List \u03b1 \u2192 Nat \u2192 List \u03b1\n  | [],    _   => []\n  | a::as, 0   => as\n  | a::as, n+1 => a :: eraseIdx as n\n\ndef isEmpty : List \u03b1 \u2192 Bool\n  | []     => true\n  | _ :: _ => false\n\n@[specialize] def map (f : \u03b1 \u2192 \u03b2) : List \u03b1 \u2192 List \u03b2\n  | []    => []\n  | a::as => f a :: map f as\n\n@[specialize] def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3\n  | [],    _     => []\n  | _,     []    => []\n  | a::as, b::bs => f a b :: map\u2082 f as bs\n\ndef join : List (List \u03b1) \u2192 List \u03b1\n  | []      => []\n  | a :: as => a ++ join as\n\n@[specialize] def filterMap (f : \u03b1 \u2192 Option \u03b2) : List \u03b1 \u2192 List \u03b2\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 : \u03b1 \u2192 Bool) : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\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 : \u03b1 \u2192 Bool) (as : List \u03b1) : List \u03b1 :=\n  filterAux p as []\n\n@[specialize] def partitionAux (p : \u03b1 \u2192 Bool) : List \u03b1 \u2192 List \u03b1 \u00d7 List \u03b1 \u2192 List \u03b1 \u00d7 List \u03b1\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 : \u03b1 \u2192 Bool) (as : List \u03b1) : List \u03b1 \u00d7 List \u03b1 :=\n  partitionAux p as ([], [])\n\ndef dropWhile (p : \u03b1 \u2192 Bool) : List \u03b1 \u2192 List \u03b1\n  | []   => []\n  | a::l => match p a with\n    | true  => dropWhile p l\n    | false =>  a::l\n\ndef find? (p : \u03b1 \u2192 Bool) : List \u03b1 \u2192 Option \u03b1\n  | []    => none\n  | a::as => match p a with\n    | true  => some a\n    | false => find? p as\n\ndef findSome? (f : \u03b1 \u2192 Option \u03b2) : List \u03b1 \u2192 Option \u03b2\n  | []    => none\n  | a::as => match f a with\n    | some b => some b\n    | none   => findSome? f as\n\ndef replace [BEq \u03b1] : List \u03b1 \u2192 \u03b1 \u2192 \u03b1 \u2192 List \u03b1\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 \u03b1] (a : \u03b1) : List \u03b1 \u2192 Bool\n  | []    => false\n  | b::bs => match a == b with\n    | true  => true\n    | false => elem a bs\n\ndef notElem [BEq \u03b1] (a : \u03b1) (as : List \u03b1) : Bool :=\n  !(as.elem a)\n\nabbrev contains [BEq \u03b1] (as : List \u03b1) (a : \u03b1) : Bool :=\n  elem a as\n\ndef eraseDupsAux {\u03b1} [BEq \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\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 {\u03b1} [BEq \u03b1] (as : List \u03b1) : List \u03b1 :=\n  eraseDupsAux as []\n\ndef eraseRepsAux {\u03b1} [BEq \u03b1] : \u03b1 \u2192 List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1\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 {\u03b1} [BEq \u03b1] : List \u03b1 \u2192 List \u03b1\n  | []    => []\n  | a::as => eraseRepsAux a as []\n\n@[specialize] def spanAux (p : \u03b1 \u2192 Bool) : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b1 \u00d7 List \u03b1\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 : \u03b1 \u2192 Bool) (as : List \u03b1) : List \u03b1 \u00d7 List \u03b1 :=\n  spanAux p as []\n\n@[specialize] def groupByAux (eq : \u03b1 \u2192 \u03b1 \u2192 Bool) : List \u03b1 \u2192 List (List \u03b1) \u2192 List (List \u03b1)\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 : \u03b1 \u2192 \u03b1 \u2192 Bool) : List \u03b1 \u2192 List (List \u03b1)\n  | []    => []\n  | a::as => groupByAux p as [[a]]\n\ndef lookup [BEq \u03b1] : \u03b1 \u2192 List (\u03b1 \u00d7 \u03b2) \u2192 Option \u03b2\n  | _, []        => none\n  | a, (k,b)::es => match a == k with\n    | true  => some b\n    | false => lookup a es\n\ndef removeAll [BEq \u03b1] (xs ys : List \u03b1) : List \u03b1 :=\n  xs.filter (fun x => ys.notElem x)\n\ndef drop : Nat \u2192 List \u03b1 \u2192 List \u03b1\n  | 0,   a     => a\n  | n+1, []    => []\n  | n+1, a::as => drop n as\n\ndef take : Nat \u2192 List \u03b1 \u2192 List \u03b1\n  | 0,   a     => []\n  | n+1, []    => []\n  | n+1, a::as => a :: take n as\n\n@[specialize] def foldr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (init : \u03b2) : List \u03b1 \u2192 \u03b2\n  | []     => init\n  | a :: l => f a (foldr f init l)\n\n@[inline] def any (l : List \u03b1) (p : \u03b1 \u2192 Bool) : Bool :=\n  foldr (fun a r => p a || r) false l\n\n@[inline] def all (l : List \u03b1) (p : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3\n  | x::xs, y::ys => f x y :: zipWith f xs ys\n  | _,     _     => []\n\ndef zip : List \u03b1 \u2192 List \u03b2 \u2192 List (Prod \u03b1 \u03b2) :=\n  zipWith Prod.mk\n\ndef unzip : List (\u03b1 \u00d7 \u03b2) \u2192 List \u03b1 \u00d7 List \u03b2\n  | []          => ([], [])\n  | (a, b) :: t => match unzip t with | (al, bl) => (a::al, b::bl)\n\ndef rangeAux : Nat \u2192 List Nat \u2192 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 \u2192 List Nat\n  | 0       => []\n  | m@(n+1) => m :: iota n\n\ndef enumFrom : Nat \u2192 List \u03b1 \u2192 List (Nat \u00d7 \u03b1)\n  | n, [] => nil\n  | n, x :: xs   => (n, x) :: enumFrom (n + 1) xs\n\ndef enum : List \u03b1 \u2192 List (Nat \u00d7 \u03b1) := enumFrom 0\n\ndef init : List \u03b1 \u2192 List \u03b1\n  | []   => []\n  | [a]  => []\n  | a::l => a::init l\n\ndef intersperse (sep : \u03b1) : List \u03b1 \u2192 List \u03b1\n  | []    => []\n  | [x]   => [x]\n  | x::xs => x :: sep :: intersperse sep xs\n\ndef intercalate (sep : List \u03b1) (xs : List (List \u03b1)) : List \u03b1 :=\n  join (intersperse sep xs)\n\n@[inline] protected def bind {\u03b1 : Type u} {\u03b2 : Type v} (a : List \u03b1) (b : \u03b1 \u2192 List \u03b2) : List \u03b2 := join (map b a)\n\n@[inline] protected def pure {\u03b1 : Type u} (a : \u03b1) : List \u03b1 := [a]\n\ninductive lt [LT \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 Prop where\n  | nil  (b : \u03b1) (bs : List \u03b1) : lt [] (b::bs)\n  | head {a : \u03b1} (as : List \u03b1) {b : \u03b1} (bs : List \u03b1) : a < b \u2192 lt (a::as) (b::bs)\n  | tail {a : \u03b1} {as : List \u03b1} {b : \u03b1} {bs : List \u03b1} : \u00ac a < b \u2192 \u00ac b < a \u2192 lt as bs \u2192 lt (a::as) (b::bs)\n\ninstance [LT \u03b1] : LT (List \u03b1) := \u27e8List.lt\u27e9\n\ninstance hasDecidableLt [LT \u03b1] [h : DecidableRel (\u03b1:=\u03b1) (\u00b7<\u00b7)] : (l\u2081 l\u2082 : List \u03b1) \u2192 Decidable (l\u2081 < l\u2082)\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\u2081  => isTrue (List.lt.head _ _ h\u2081)\n    | isFalse h\u2081 =>\n      match h b a with\n      | isTrue h\u2082  => isFalse (fun h => match h with\n         | List.lt.head _ _ h\u2081' => absurd h\u2081' h\u2081\n         | List.lt.tail _ h\u2082' _ => absurd h\u2082 h\u2082')\n      | isFalse h\u2082 =>\n        match hasDecidableLt as bs with\n        | isTrue h\u2083  => isTrue (List.lt.tail h\u2081 h\u2082 h\u2083)\n        | isFalse h\u2083 => isFalse (fun h => match h with\n           | List.lt.head _ _ h\u2081' => absurd h\u2081' h\u2081\n           | List.lt.tail _ _ h\u2083' => absurd h\u2083' h\u2083)\n\n@[reducible] protected def le [LT \u03b1] (a b : List \u03b1) : Prop := \u00ac b < a\n\ninstance [LT \u03b1] : LE (List \u03b1) := \u27e8List.le\u27e9\n\ninstance [LT \u03b1] [h : DecidableRel ((\u00b7 < \u00b7) : \u03b1 \u2192 \u03b1 \u2192 Prop)] : (l\u2081 l\u2082 : List \u03b1) \u2192 Decidable (l\u2081 \u2264 l\u2082) :=\n  fun a b => inferInstanceAs (Decidable (Not _))\n\n/--  `isPrefixOf l\u2081 l\u2082` returns `true` Iff `l\u2081` is a prefix of `l\u2082`. -/\ndef isPrefixOf [BEq \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 Bool\n  | [],    _     => true\n  | _,     []    => false\n  | a::as, b::bs => a == b && isPrefixOf as bs\n\n/--  `isSuffixOf l\u2081 l\u2082` returns `true` Iff `l\u2081` is a suffix of `l\u2082`. -/\ndef isSuffixOf [BEq \u03b1] (l\u2081 l\u2082 : List \u03b1) : Bool :=\n  isPrefixOf l\u2081.reverse l\u2082.reverse\n\n@[specialize] def isEqv : List \u03b1 \u2192 List \u03b1 \u2192 (\u03b1 \u2192 \u03b1 \u2192 Bool) \u2192 Bool\n  | [],    [],    _   => true\n  | a::as, b::bs, eqv => eqv a b && isEqv as bs eqv\n  | _,     _,     eqv => false\n\nprotected def beq [BEq \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 Bool\n  | [],    []    => true\n  | a::as, b::bs => a == b && List.beq as bs\n  | _,     _     => false\n\ninstance [BEq \u03b1] : BEq (List \u03b1) := \u27e8List.beq\u27e9\n\ndef replicate {\u03b1 : Type u} (n : Nat) (a : \u03b1) : List \u03b1 :=\n  let rec loop : Nat \u2192 List \u03b1 \u2192 List \u03b1\n    | 0, as => as\n    | n+1, as => loop n (a::as)\n  loop n []\n\ndef dropLast {\u03b1} : List \u03b1 \u2192 List \u03b1\n  | []    => []\n  | [a]   => []\n  | a::as => a :: dropLast as\n\n@[simp] theorem length_replicate (n : Nat) (a : \u03b1) : (replicate n a).length = n :=\n  let rec aux (n : Nat) (as : List \u03b1) : (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 \u03b1) (a : \u03b1) : (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 \u03b1) (i : Nat) (a : \u03b1) : (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 \u03b1) : 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 \u2964 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\u2081 v\u2082 v\u2083 v\u2084 u\u2081 u\u2082 u\u2083 u\u2084\n\nvariables {J : Type u\u2081} [category.{v\u2081} J] {K : Type u\u2082} [category.{v\u2082} K]\nvariables {C : Type u\u2083} [category.{v\u2083} C]\n\nvariables {F : J \u2964 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  : \u03a0 (s : cone F), s.X \u27f6 t.X)\n(fac'  : \u2200 (s : cone F) (j : J), lift s \u226b t.\u03c0.app j = s.\u03c0.app j . obviously)\n(uniq' : \u2200 (s : cone F) (m : s.X \u27f6 t.X) (w : \u2200 j : J, m \u226b t.\u03c0.app j = s.\u03c0.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\u27e8by intros P Q; cases P; cases Q; congr; ext; solve_by_elim\u27e9\n\n/-- Given a natural transformation `\u03b1 : F \u27f6 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 \u2964 C} (s : cone F) {t : cone G} (P : is_limit t)\n  (\u03b1 : F \u27f6 G) : s.X \u27f6 t.X :=\nP.lift ((cones.postcompose \u03b1).obj s)\n\n@[simp, reassoc] lemma map_\u03c0 {F G : J \u2964 C} (c : cone F) {d : cone G} (hd : is_limit d)\n  (\u03b1 : F \u27f6 G) (j : J) : hd.map c \u03b1 \u226b d.\u03c0.app j = c.\u03c0.app j \u226b \u03b1.app j :=\nfac _ _ _\n\nlemma lift_self {c : cone F} (t : is_limit c) : t.lift c = \ud835\udfd9 c.X :=\n(t.uniq _ _ (\u03bb 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 \u27f6 t :=\n{ hom := h.lift s }\n\nlemma uniq_cone_morphism {s t : cone F} (h : is_limit t) {f f' : s \u27f6 t} :\n  f = f' :=\nhave \u2200 {g : s \u27f6 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 \u2203! operator. -/\nlemma exists_unique {t : cone F} (h : is_limit t) (s : cone F) :\n  \u2203! (l : s.X \u27f6 t.X), \u2200 j, l \u226b t.\u03c0.app j = s.\u03c0.app j :=\n\u27e8h.lift s, h.fac s, h.uniq s\u27e9\n\n/-- Noncomputably make a colimit cocone from the existence of unique factorizations. -/\ndef of_exists_unique {t : cone F}\n  (ht : \u2200 s : cone F, \u2203! l : s.X \u27f6 t.X, \u2200 j, l \u226b t.\u03c0.app j = s.\u03c0.app j) : is_limit t :=\nby { choose s hs hs' using ht, exact \u27e8s, hs, hs'\u27e9 }\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 : \u03a0 (s : cone F), s \u27f6 t)\n  (uniq' : \u2200 (s : cone F) (m : s \u27f6 t), m = lift s) : is_limit t :=\n{ lift := \u03bb s, (lift s).hom,\n  uniq' := \u03bb 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 \u2245 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 \u27f6 t) : is_iso f :=\n\u27e8\u27e8P.lift_cone_morphism t, \u27e8P.uniq_cone_morphism, Q.uniq_cone_morphism\u27e9\u27e9\u27e9\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 \u2245 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 \u226b t.\u03c0.app j = s.\u03c0.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 \u226b s.\u03c0.app j = t.\u03c0.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 \u226b (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 \u226b (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 \u2245 t) : is_limit t :=\nis_limit.mk_cone_morphism\n  (\u03bb s, P.lift_cone_morphism s \u226b i.hom)\n  (\u03bb s m, by rw \u2190i.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 \u2245 t) (s) :\n  (P.of_iso_limit i).lift s = P.lift s \u226b 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 \u2245 t) : is_limit r \u2243 is_limit t :=\n{ to_fun := \u03bb h, h.of_iso_limit i,\n  inv_fun := \u03bb 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 \u2245 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 \u2245 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 \u27f6 t.X) :\n  m = h.lift { X := W, \u03c0 := { app := \u03bb b, m \u226b t.\u03c0.app b } } :=\nh.uniq { X := W, \u03c0 := { app := \u03bb b, m \u226b t.\u03c0.app b } } m (\u03bb 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 \u27f6 t.X}\n  (w : \u2200 j, f \u226b t.\u03c0.app j = f' \u226b t.\u03c0.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\u2084} [category.{v\u2084} D] {G : K \u2964 D}\n  (h : cone G \u2964 cone F) [is_right_adjoint h] {c : cone G} (t : is_limit c) :\n  is_limit (h.obj c) :=\nmk_cone_morphism\n  (\u03bb s, (adjunction.of_right_adjoint h).hom_equiv s c (t.lift_cone_morphism _))\n  (\u03bb 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\u2084} [category.{v\u2084} D] {G : K \u2964 D}\n  (h : cone G \u224c cone F) {c : cone G} :\n  is_limit (h.functor.obj c) \u2243 is_limit c :=\n{ to_fun := \u03bb 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\u2084} [category.{v\u2084} D] {G : K \u2964 D}\n  (h : cone G \u224c 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 \u226b\n      (h.functor.inv.map (P.lift_cone_morphism (h.functor.obj s))).hom) \u226b\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 \u2964 C} (\u03b1 : F \u2245 G) (c : cone F) :\n  is_limit ((cones.postcompose \u03b1.hom).obj c) \u2243 is_limit c :=\nof_cone_equiv (cones.postcompose_equivalence \u03b1)\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 \u2964 C} (\u03b1 : F \u2245 G) (c : cone G) :\n  is_limit ((cones.postcompose \u03b1.inv).obj c) \u2243 is_limit c :=\npostcompose_hom_equiv \u03b1.symm c\n\n/--\nConstructing an equivalence `is_limit c \u2243 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 \u2964 C} (\u03b1 : F \u2245 G) (c : cone F) (d : cone G)\n  (w : (cones.postcompose \u03b1.hom).obj c \u2245 d) :\n  is_limit c \u2243 is_limit d :=\n(postcompose_hom_equiv \u03b1 _).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 \u2964 C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F \u2245 G) : s.X \u2245 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 \u2964 C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F \u2245 G) (j : J) :\n  (cone_points_iso_of_nat_iso P Q w).hom \u226b t.\u03c0.app j = s.\u03c0.app j \u226b w.hom.app j :=\nby simp\n\n@[reassoc]\nlemma cone_points_iso_of_nat_iso_inv_comp {F G : J \u2964 C} {s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F \u2245 G) (j : J) :\n  (cone_points_iso_of_nat_iso P Q w).inv \u226b s.\u03c0.app j = t.\u03c0.app j \u226b w.inv.app j :=\nby simp\n\n@[reassoc]\nlemma lift_comp_cone_points_iso_of_nat_iso_hom {F G : J \u2964 C} {r s : cone F} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (w : F \u2245 G) :\n  P.lift r \u226b (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 \u2964 C} {r s : cone G} {t : cone F}\n  (P : is_limit t) (Q : is_limit s) (w : F \u2245 G) :\n  Q.lift r \u226b (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 \u224c 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 \u224c 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 \u224c J) :\n  is_limit s \u2243 is_limit (s.whisker e.functor) :=\n\u27e8\u03bb h, h.whisker_equivalence e, of_whisker_equivalence e, by tidy, by tidy\u27e9\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 \u224c K`,\n* the triangle of functors commutes up to a natural isomorphism: `e.functor \u22d9 G \u2245 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 \u2964 C} {s : cone F} {G : K \u2964 C} {t : cone G}\n  (P : is_limit s) (Q : is_limit t) (e : J \u224c K) (w : e.functor \u22d9 G \u2245 F) : s.X \u2245 t.X :=\nlet w' : e.inverse \u22d9 F \u2245 G := (iso_whisker_left e.inverse w).symm \u226a\u226b 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_\u03c0, limits.cones.postcompose_obj_\u03c0, 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, \u2190functor.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 \u27f6 X` is the same as\n  a cone on `F` with vertex `W`. -/\ndef hom_iso (h : is_limit t) (W : C) : ulift.{u\u2081} (W \u27f6 t.X : Type v\u2083) \u2245 (const J).obj W \u27f6 F :=\n{ hom := \u03bb f, (t.extend f.down).\u03c0,\n  inv := \u03bb \u03c0, \u27e8h.lift { X := W, \u03c0 := \u03c0 }\u27e9,\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\u2081} (W \u27f6 t.X)) :\n  (is_limit.hom_iso h W).hom f = (t.extend f.down).\u03c0 := 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 \u22d9 ulift_functor.{u\u2081} \u2245 F.cones :=\nnat_iso.of_components (\u03bb 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\u2081} ((W \u27f6 t.X) : Type v\u2083) \u2245\n    { p : \u03a0 j, W \u27f6 F.obj j // \u2200 {j j'} (f : j \u27f6 j'), p j \u226b F.map f = p j' } :=\nh.hom_iso W \u226a\u226b\n{ hom := \u03bb \u03c0,\n  \u27e8\u03bb j, \u03c0.app j, \u03bb j j' f,\n   by convert \u2190(\u03c0.naturality f).symm; apply id_comp\u27e9,\n  inv := \u03bb p,\n  { app := \u03bb j, p.1 j,\n    naturality' := \u03bb j j' f, begin dsimp, rw [id_comp], exact (p.2 f).symm end } }\n\n/-- If G : C \u2192 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\u2084} [category.{v\u2084} D] (G : C \u2964 D) [faithful G]\n  (ht : is_limit (G.map_cone t)) (lift : \u03a0 (s : cone F), s.X \u27f6 t.X)\n  (h : \u2200 s, G.map (lift s) = ht.lift (G.map_cone s)) : is_limit t :=\n{ lift := lift,\n  fac' := \u03bb s j, by apply G.map_injective; rw [G.map_comp, h]; apply ht.fac,\n  uniq' := \u03bb s m w, begin\n    apply G.map_injective, rw h,\n    refine ht.uniq (G.map_cone s) _ (\u03bb j, _),\n    convert \u2190congr_arg (\u03bb 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\u2084} [category.{v\u2084} D]\n  {K : J \u2964 C} {F G : C \u2964 D} (h : F \u2245 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 \u2245 \u03a0 s, unique (s \u27f6 t) :=\n{ hom := \u03bb h s,\n  { default := h.lift_cone_morphism s,\n    uniq := \u03bb _, h.uniq_cone_morphism },\n  inv := \u03bb h,\n  { lift := \u03bb s, (h s).default.hom,\n    uniq' := \u03bb s f w, congr_arg cone_morphism.hom ((h s).uniq \u27e8f, w\u27e9) } }\n\nnamespace of_nat_iso\nvariables {X : C} (h : yoneda.obj X \u22d9 ulift_functor.{u\u2081} \u2245 F.cones)\n\n/-- If `F.cones` is represented by `X`, each morphism `f : Y \u27f6 X` gives a cone with cone point\n`Y`. -/\ndef cone_of_hom {Y : C} (f : Y \u27f6 X) : cone F :=\n{ X := Y, \u03c0 := h.hom.app (op Y) \u27e8f\u27e9 }\n\n/-- If `F.cones` is represented by `X`, each cone `s` gives a morphism `s.X \u27f6 X`. -/\ndef hom_of_cone (s : cone F) : s.X \u27f6 X := (h.inv.app (op s.X) s.\u03c0).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_\u03c0,\n  exact ulift.up_down _\nend\n\n@[simp] lemma hom_of_cone_of_hom {Y : C} (f : Y \u27f6 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)) \u27e8f\u27e9 : _)\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 (\ud835\udfd9 X)\n\n/-- If `F.cones` is represented by `X`, the cone corresponding to a morphism `f : Y \u27f6 X` is\nthe limit cone extended by `f`. -/\nlemma cone_of_hom_fac {Y : C} (f : Y \u27f6 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) \u27e8\ud835\udfd9 X\u27e9,\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 \u2190cone_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 \u22d9 ulift_functor.{u\u2081} \u2245 F.cones) :\n  is_limit (limit_cone h) :=\n{ lift := \u03bb s, hom_of_cone h s,\n  fac' := \u03bb s j,\n  begin\n    have h := cone_fac h s,\n    cases s,\n    injection h with h\u2081 h\u2082,\n    simp only [heq_iff_eq] at h\u2082,\n    conv_rhs { rw \u2190 h\u2082 }, refl,\n  end,\n  uniq' := \u03bb s m w,\n  begin\n    rw \u2190hom_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  : \u03a0 (s : cocone F), t.X \u27f6 s.X)\n(fac'  : \u2200 (s : cocone F) (j : J), t.\u03b9.app j \u226b desc s = s.\u03b9.app j . obviously)\n(uniq' : \u2200 (s : cocone F) (m : t.X \u27f6 s.X) (w : \u2200 j : J, t.\u03b9.app j \u226b m = s.\u03b9.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\u27e8by intros P Q; cases P; cases Q; congr; ext; solve_by_elim\u27e9\n\n/-- Given a natural transformation `\u03b1 : F \u27f6 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 \u2964 C} {s : cocone F} (P : is_colimit s) (t : cocone G)\n  (\u03b1 : F \u27f6 G) : s.X \u27f6 t.X :=\nP.desc ((cocones.precompose \u03b1).obj t)\n\n@[simp, reassoc]\nlemma \u03b9_map {F G : J \u2964 C} {c : cocone F} (hc : is_colimit c) (d : cocone G) (\u03b1 : F \u27f6 G)\n  (j : J) : c.\u03b9.app j \u226b is_colimit.map hc d \u03b1 = \u03b1.app j \u226b d.\u03b9.app j :=\nfac _ _ _\n\n@[simp]\nlemma desc_self {t : cocone F} (h : is_colimit t) : h.desc t = \ud835\udfd9 t.X :=\n(h.uniq _ _ (\u03bb 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 \u27f6 s :=\n{ hom := h.desc s }\n\nlemma uniq_cocone_morphism {s t : cocone F} (h : is_colimit t) {f f' : t \u27f6 s} :\n  f = f' :=\nhave \u2200 {g : t \u27f6 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 \u2203! operator. -/\nlemma exists_unique {t : cocone F} (h : is_colimit t) (s : cocone F) :\n  \u2203! (d : t.X \u27f6 s.X), \u2200 j, t.\u03b9.app j \u226b d = s.\u03b9.app j :=\n\u27e8h.desc s, h.fac s, h.uniq s\u27e9\n\n/-- Noncomputably make a colimit cocone from the existence of unique factorizations. -/\ndef of_exists_unique {t : cocone F}\n  (ht : \u2200 s : cocone F, \u2203! d : t.X \u27f6 s.X, \u2200 j, t.\u03b9.app j \u226b d = s.\u03b9.app j) : is_colimit t :=\nby { choose s hs hs' using ht, exact \u27e8s, hs, hs'\u27e9 }\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 : \u03a0 (s : cocone F), t \u27f6 s)\n  (uniq' : \u2200 (s : cocone F) (m : t \u27f6 s), m = desc s) : is_colimit t :=\n{ desc := \u03bb s, (desc s).hom,\n  uniq' := \u03bb 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 \u2245 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 \u27f6 t) : is_iso f :=\n\u27e8\u27e8Q.desc_cocone_morphism s, \u27e8P.uniq_cocone_morphism, Q.uniq_cocone_morphism\u27e9\u27e9\u27e9\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 \u2245 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.\u03b9.app j \u226b (cocone_point_unique_up_to_iso P Q).hom = t.\u03b9.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.\u03b9.app j \u226b (cocone_point_unique_up_to_iso P Q).inv = s.\u03b9.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 \u226b 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 \u226b 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 \u2245 t) : is_colimit t :=\nis_colimit.mk_cocone_morphism\n  (\u03bb s, i.inv \u226b P.desc_cocone_morphism s)\n  (\u03bb 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 \u2245 t) (s) :\n  (P.of_iso_colimit i).desc s = i.inv.hom \u226b 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 \u2245 t) : is_colimit r \u2243 is_colimit t :=\n{ to_fun := \u03bb h, h.of_iso_colimit i,\n  inv_fun := \u03bb 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 \u2245 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 \u2245 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 \u27f6 W) :\n  m = h.desc { X := W, \u03b9 := { app := \u03bb b, t.\u03b9.app b \u226b m,\n    naturality' := by intros; erw [\u2190assoc, t.\u03b9.naturality, comp_id, comp_id] } } :=\nh.uniq { X := W, \u03b9 := { app := \u03bb b, t.\u03b9.app b \u226b m, naturality' := _ } } m (\u03bb 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 \u27f6 W}\n  (w : \u2200 j, t.\u03b9.app j \u226b f = t.\u03b9.app j \u226b 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\u2084} [category.{v\u2084} D] {G : K \u2964 D}\n  (h : cocone G \u2964 cocone F) [is_left_adjoint h] {c : cocone G} (t : is_colimit c) :\n  is_colimit (h.obj c) :=\nmk_cocone_morphism\n  (\u03bb s, ((adjunction.of_left_adjoint h).hom_equiv c s).symm (t.desc_cocone_morphism _))\n  (\u03bb 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\u2084} [category.{v\u2084} D] {G : K \u2964 D}\n  (h : cocone G \u224c cocone F) {c : cocone G} :\n  is_colimit (h.functor.obj c) \u2243 is_colimit c :=\n{ to_fun := \u03bb 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\u2084} [category.{v\u2084} D] {G : K \u2964 D}\n  (h : cocone G \u224c 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 \u226b\n    (h.inverse.map (P.desc_cocone_morphism (h.functor.obj s))).hom \u226b\n    (h.unit_inv.app s).hom :=\nrfl\n\n@[simp] lemma of_cocone_equiv_symm_apply_desc {D : Type u\u2084} [category.{v\u2084} D] {G : K \u2964 D}\n  (h : cocone G \u224c 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 \u226b (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 \u2964 C} (\u03b1 : F \u2245 G) (c : cocone G) :\n  is_colimit ((cocones.precompose \u03b1.hom).obj c) \u2243 is_colimit c :=\nof_cocone_equiv (cocones.precompose_equivalence \u03b1)\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 \u2964 C} (\u03b1 : F \u2245 G) (c : cocone F) :\n  is_colimit ((cocones.precompose \u03b1.inv).obj c) \u2243 is_colimit c :=\nprecompose_hom_equiv \u03b1.symm c\n\n/--\nConstructing an equivalence `is_colimit c \u2243 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 \u2964 C} (\u03b1 : F \u2245 G) (c : cocone F) (d : cocone G)\n  (w : (cocones.precompose \u03b1.inv).obj c \u2245 d) :\n  is_colimit c \u2243 is_colimit d :=\n(precompose_inv_equiv \u03b1 _).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 \u2964 C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F \u2245 G) : s.X \u2245 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 \u2964 C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F \u2245 G) (j : J) :\n  s.\u03b9.app j \u226b (cocone_points_iso_of_nat_iso P Q w).hom = w.hom.app j \u226b t.\u03b9.app j :=\nby simp\n\n@[reassoc]\nlemma comp_cocone_points_iso_of_nat_iso_inv {F G : J \u2964 C} {s : cocone F} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F \u2245 G) (j : J) :\n  t.\u03b9.app j \u226b (cocone_points_iso_of_nat_iso P Q w).inv = w.inv.app j \u226b s.\u03b9.app j :=\nby simp\n\n@[reassoc]\nlemma cocone_points_iso_of_nat_iso_hom_desc {F G : J \u2964 C} {s : cocone F} {r t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (w : F \u2245 G) :\n  (cocone_points_iso_of_nat_iso P Q w).hom \u226b 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 \u2964 C} {s : cocone G} {r t : cocone F}\n  (P : is_colimit t) (Q : is_colimit s) (w : F \u2245 G) :\n  (cocone_points_iso_of_nat_iso P Q w).inv \u226b 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 \u224c 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 \u224c 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 \u224c J) :\n  is_colimit s \u2243 is_colimit (s.whisker e.functor) :=\n\u27e8\u03bb h, h.whisker_equivalence e, of_whisker_equivalence e, by tidy, by tidy\u27e9\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 \u224c K`,\n* the triangle of functors commutes up to a natural isomorphism: `e.functor \u22d9 G \u2245 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 \u2964 C} {s : cocone F} {G : K \u2964 C} {t : cocone G}\n  (P : is_colimit s) (Q : is_colimit t) (e : J \u224c K) (w : e.functor \u22d9 G \u2245 F) : s.X \u2245 t.X :=\nlet w' : e.inverse \u22d9 F \u2245 G := (iso_whisker_left e.inverse w).symm \u226a\u226b 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_\u03b9, fac, inv_fun_id_assoc_inv_app, whisker_left_app, assoc,\n      comp_id, limits.cocones.precompose_obj_\u03b9, fac_assoc, nat_trans.comp_app],\n    rw [counit_inv_app_functor, \u2190functor.comp_map, \u2190w.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 \u27f6 W` is the same as\n  a cocone on `F` with vertex `W`. -/\ndef hom_iso (h : is_colimit t) (W : C) : ulift.{u\u2081} (t.X \u27f6 W : Type v\u2083) \u2245 (F \u27f6 (const J).obj W) :=\n{ hom := \u03bb f, (t.extend f.down).\u03b9,\n  inv := \u03bb \u03b9, \u27e8h.desc { X := W, \u03b9 := \u03b9 }\u27e9,\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 \u27f6 W)) :\n  (is_colimit.hom_iso h W).hom f = (t.extend f.down).\u03b9 := 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) \u22d9 ulift_functor.{u\u2081} \u2245 F.cocones :=\nnat_iso.of_components (is_colimit.hom_iso h) (by intros; ext; dsimp; rw \u2190assoc; 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\u2081} ((t.X \u27f6 W) : Type v\u2083) \u2245\n    { p : \u03a0 j, F.obj j \u27f6 W // \u2200 {j j' : J} (f : j \u27f6 j'), F.map f \u226b p j' = p j } :=\nh.hom_iso W \u226a\u226b\n{ hom := \u03bb \u03b9,\n  \u27e8\u03bb j, \u03b9.app j, \u03bb j j' f,\n   by convert \u2190(\u03b9.naturality f); apply comp_id\u27e9,\n  inv := \u03bb p,\n  { app := \u03bb j, p.1 j,\n    naturality' := \u03bb j j' f, begin dsimp, rw [comp_id], exact (p.2 f) end } }\n\n/-- If G : C \u2192 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\u2084} [category.{v\u2084} D] (G : C \u2964 D) [faithful G]\n  (ht : is_colimit (G.map_cocone t)) (desc : \u03a0 (s : cocone F), t.X \u27f6 s.X)\n  (h : \u2200 s, G.map (desc s) = ht.desc (G.map_cocone s)) : is_colimit t :=\n{ desc := desc,\n  fac' := \u03bb s j, by apply G.map_injective; rw [G.map_comp, h]; apply ht.fac,\n  uniq' := \u03bb s m w, begin\n    apply G.map_injective, rw h,\n    refine ht.uniq (G.map_cocone s) _ (\u03bb j, _),\n    convert \u2190congr_arg (\u03bb 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\u2084} [category.{v\u2084} D] {K : J \u2964 C} {F G : C \u2964 D} (h : F \u2245 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 \u2245 \u03a0 s, unique (t \u27f6 s) :=\n{ hom := \u03bb h s,\n  { default := h.desc_cocone_morphism s,\n    uniq := \u03bb _, h.uniq_cocone_morphism },\n  inv := \u03bb h,\n  { desc := \u03bb s, (h s).default.hom,\n    uniq' := \u03bb s f w, congr_arg cocone_morphism.hom ((h s).uniq \u27e8f, w\u27e9) } }\n\nnamespace of_nat_iso\nvariables {X : C} (h : coyoneda.obj (op X) \u22d9 ulift_functor.{u\u2081} \u2245 F.cocones)\n\n/-- If `F.cocones` is corepresented by `X`, each morphism `f : X \u27f6 Y` gives a cocone with cone\npoint `Y`. -/\ndef cocone_of_hom {Y : C} (f : X \u27f6 Y) : cocone F :=\n{ X := Y, \u03b9 := h.hom.app Y \u27e8f\u27e9 }\n\n/-- If `F.cocones` is corepresented by `X`, each cocone `s` gives a morphism `X \u27f6 s.X`. -/\ndef hom_of_cocone (s : cocone F) : X \u27f6 s.X := (h.inv.app s.X s.\u03b9).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_\u03b9,\n  exact ulift.up_down _\nend\n\n@[simp] lemma hom_of_cocone_of_hom {Y : C} (f : X \u27f6 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) \u27e8f\u27e9 : _)\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 (\ud835\udfd9 X)\n\n/-- If `F.cocones` is corepresented by `X`, the cocone corresponding to a morphism `f : Y \u27f6 X` is\nthe colimit cocone extended by `f`. -/\nlemma cocone_of_hom_fac {Y : C} (f : X \u27f6 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) \u27e8\ud835\udfd9 X\u27e9,\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 \u2190cocone_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) \u22d9 ulift_functor.{u\u2081} \u2245 F.cocones) :\n  is_colimit (colimit_cocone h) :=\n{ desc := \u03bb s, hom_of_cocone h s,\n  fac' := \u03bb s j,\n  begin\n    have h := cocone_fac h s,\n    cases s,\n    injection h with h\u2081 h\u2082,\n    simp only [heq_iff_eq] at h\u2082,\n    conv_rhs { rw \u2190 h\u2082 }, refl,\n  end,\n  uniq' := \u03bb s m w,\n  begin\n    rw \u2190hom_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 : \u211d\u22650}\n\n/--  This is the same `r` as before. -/\n-- def r : \u211d\u22650 := 2\u207b\u00b9 ^ (p:\u211d)\n\n-- lemma r_pos : 0 < r :=\n-- suffices 0 < (2 : \u211d\u22650)\u207b\u00b9 ^ (p : \u211d), 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 : \u211d\u22650} [fact (0 < r)] [fact (r < 1)]\n\nlocal notation `\u2112` := laurent_measures r\n\nvariables {S : Fintype}\n\n-- /--  Let `F : \u2112 S` be a Laurent measure.  `laurent_measures.d` chooses a bound `d \u2208 \u2124` 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 : \u2112 S) : \u2124 :=\n-- (exists_bdd_filtration (fact.out _ : 0 < r) (fact.out _ : r < 1) F).some\n\n-- lemma lt_d_eq_zero (F : \u2112 S) (s : S) (n : \u2124) :\n--   n < F.d \u2192 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 : \u211d\u22650) (S : Fintype) :=\n(to_fun    : S \u2192 \u2124 \u2192 \u2124)\n(d         : \u2124)\n(summable' : \u2200 s, summable (\u03bb n : \u2115, \u2225to_fun s n\u2225\u208a * r ^ n))\n(zero_lt_d : \u2200 s n, n < d \u2192 to_fun s n = 0)\n\n/--  A \"usual\" Laurent Measure `F : \u2112 S` gives rise to a Simple Laurent Measure of type `slm S`. -/\ndef _root_.laurent_measures.to_slm (F : \u2112 S) : slm r S :=\n{ to_fun    := F.to_fun,\n  d         := F.d,\n  zero_lt_d := \u03bb n s, lt_d_eq_zero F _ _,\n  summable' := begin\n    refine \u03bb s, summable_coe.mp _,\n    convert ((@int_summable_iff _ _ _ _ _ (\u03bb (n : \u2124), \u2225F.to_fun s n\u2225 * 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 `\u2112 S`. -/\n--  The \"main\" input is `int_summable_iff`, proving that a series over `\u2124` is summable if and only\n--  if both its restrictions to `\u2115` and to \"`-\u2115`\" are summable.\ndef slm.to_laurent_measures {r : \u211d\u22650} (F : slm r S) : laurent_measures r S :=\n{ to_fun := F.to_fun,\n  summable' := begin\n    refine \u03bb s, summable_coe.mp _,\n    convert ((@int_summable_iff _ _ _ _ _ (\u03bb (n : \u2124), \u2225F.to_fun s n\u2225 * r ^ n)).mpr _),\n    { simp },\n    { refine \u27e8_, summable_of_eventually_zero (\u03bb (n : \u2124), \u2225F.to_fun s n\u2225 * \u2191r ^ n) F.d (\u03bb n nd, _)\u27e9,\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 : \u211d\u22650} (F : slm r S) : F.to_fun = F.to_laurent_measures.to_fun := rfl\n\nlemma lm_slm_to_fun_eq (F : \u2112 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel, 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 {\u03b1 \u03b2 : Type _} [LinearOrder \u03b1] [ConditionallyCompleteLinearOrder \u03b2] {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1}\n  {a b : \u03b1}\n\n/- warning: monotone_on.exists_monotone_extension -> MonotoneOn.exists_monotone_extension is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : ConditionallyCompleteLinearOrder.{u2} \u03b2] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (MonotoneOn.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_2))))) f s) -> (BddBelow.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_2))))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)) -> (BddAbove.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_2))))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)) -> (Exists.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (fun (g : \u03b1 -> \u03b2) => And (Monotone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_2))))) g) (Set.EqOn.{u1, u2} \u03b1 \u03b2 f g s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : ConditionallyCompleteLinearOrder.{u1} \u03b2] {f : \u03b1 -> \u03b2} {s : Set.{u2} \u03b1}, (MonotoneOn.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_2))))) f s) -> (BddBelow.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_2))))) (Set.image.{u2, u1} \u03b1 \u03b2 f s)) -> (BddAbove.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_2))))) (Set.image.{u2, u1} \u03b1 \u03b2 f s)) -> (Exists.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (fun (g : \u03b1 -> \u03b2) => And (Monotone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_2))))) g) (Set.EqOn.{u2, u1} \u03b1 \u03b2 f g s)))\nCase conversion may be inaccurate. Consider using '#align monotone_on.exists_monotone_extension MonotoneOn.exists_monotone_extension\u2093'. -/\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)) : \u2203 g : \u03b1 \u2192 \u03b2, Monotone g \u2227 EqOn f g s := by\n  classical\n    /- The extension is defined by `f x = f a` for `x \u2264 a`, and `f x` is the supremum of the values\n      of `f`  to the left of `x` for `x \u2265 a`. -/\n    rcases hl with \u27e8a, ha\u27e9\n    have hu' : \u2200 x, BddAbove (f '' (Iic x \u2229 s)) := fun x =>\n      hu.mono (image_subset _ (inter_subset_right _ _))\n    set g : \u03b1 \u2192 \u03b2 := fun x => if Disjoint (Iic x) s then a else Sup (f '' (Iic x \u2229 s))\n    have hgs : eq_on f g s := by\n      intro x hx\n      simp only [g]\n      have : IsGreatest (Iic x \u2229 s) x := \u27e8\u27e8right_mem_Iic, hx\u27e9, fun y hy => hy.1\u27e9\n      rw [if_neg this.nonempty.not_disjoint,\n        ((h.mono <| inter_subset_right _ _).map_isGreatest this).csup\u209b_eq]\n    refine' \u27e8g, fun x y hxy => _, hgs\u27e9\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    \u00b7 rcases not_disjoint_iff_nonempty_inter.1 hy with \u27e8z, hz\u27e9\n      exact le_csup\u209b_of_le (hu' _) (mem_image_of_mem _ hz) (ha <| mem_image_of_mem _ hz.2)\n    \u00b7 exact (hx <| hy.mono_left <| Iic_subset_Iic.2 hxy).elim\n    \u00b7 rw [not_disjoint_iff_nonempty_inter] at hx hy\n      refine' csup\u209b_le_csup\u209b (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : ConditionallyCompleteLinearOrder.{u2} \u03b2] {f : \u03b1 -> \u03b2} {s : Set.{u1} \u03b1}, (AntitoneOn.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_2))))) f s) -> (BddBelow.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_2))))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)) -> (BddAbove.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_2))))) (Set.image.{u1, u2} \u03b1 \u03b2 f s)) -> (Exists.{max (succ u1) (succ u2)} (\u03b1 -> \u03b2) (fun (g : \u03b1 -> \u03b2) => And (Antitone.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) (PartialOrder.toPreorder.{u2} \u03b2 (SemilatticeInf.toPartialOrder.{u2} \u03b2 (Lattice.toSemilatticeInf.{u2} \u03b2 (ConditionallyCompleteLattice.toLattice.{u2} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u2} \u03b2 _inst_2))))) g) (Set.EqOn.{u1, u2} \u03b1 \u03b2 f g s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : ConditionallyCompleteLinearOrder.{u1} \u03b2] {f : \u03b1 -> \u03b2} {s : Set.{u2} \u03b1}, (AntitoneOn.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_2))))) f s) -> (BddBelow.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_2))))) (Set.image.{u2, u1} \u03b1 \u03b2 f s)) -> (BddAbove.{u1} \u03b2 (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_2))))) (Set.image.{u2, u1} \u03b1 \u03b2 f s)) -> (Exists.{max (succ u2) (succ u1)} (\u03b1 -> \u03b2) (fun (g : \u03b1 -> \u03b2) => And (Antitone.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) (PartialOrder.toPreorder.{u1} \u03b2 (SemilatticeInf.toPartialOrder.{u1} \u03b2 (Lattice.toSemilatticeInf.{u1} \u03b2 (ConditionallyCompleteLattice.toLattice.{u1} \u03b2 (ConditionallyCompleteLinearOrder.toConditionallyCompleteLattice.{u1} \u03b2 _inst_2))))) g) (Set.EqOn.{u2, u1} \u03b1 \u03b2 f g s)))\nCase conversion may be inaccurate. Consider using '#align antitone_on.exists_antitone_extension AntitoneOn.exists_antitone_extension\u2093'. -/\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)) : \u2203 g : \u03b1 \u2192 \u03b2, Antitone g \u2227 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 \u2192 \u2115 \u2192. \u2115\n| code.fst := \u03bb v, pure (nat.log 2 v + 1)\n| code.snd := \u03bb v, pure (nat.log 2 v + 1)\n| (code.bit _) := \u03bb v, pure (nat.log 2 v + 1)\n| (code.pair c\u2081 c\u2082) := \u03bb v, (+3) <$> (time c\u2081 v) + (time c\u2082 v)\n| (code.comp c\u2081 c\u2082) := \u03bb v, (+1) <$> (time c\u2082 v) + (c\u2082.eval v >>= time c\u2081)\n| (code.case c\u2081 c\u2082 c\u2083) := \u03bb v, (+1) <$> (match to_bits v with\n  | [] := time c\u2083 0\n  | (ff :: xs) := time c\u2081 (of_bits xs)\n  | (tt :: xs) := time c\u2082 (of_bits xs)\nend)\n| (code.fix f) := \u03bb v\u2080, (+1) <$> (@pfun.fix (\u2115 \u00d7 \u2115) \u2115 $ \n  \u03bb vt, (time f vt.1) >>= \u03bb t',\n    (f.eval vt.1).map (\u03bb v' : \u2115,\n      if v'.unpair'.1 = 0 then sum.inl (vt.2+t')\n      else sum.inr (v'.unpair'.2, vt.2+t'))\n  ) (v\u2080, 0)\n\nlemma add_def (x y : part \u2115) : x + y = x >>= \u03bb x', y >>= (\u03bb y', pure (x' + y')) :=\nby { simp only [(+), (<*>)], simp, refl, }\n\nprivate lemma time_frespects_once_eval_aux (f : code)\n  (ih : \u2200 (n : \u2115), (time f n).dom \u2194 (f.eval n).dom) :\n  pfun.frespects_once\n  (\u03bb (vt : \u2115 \u00d7 \u2115), (time f vt.1) >>= \u03bb t',\n    (f.eval vt.1).map (\u03bb v' : \u2115,\n      if v'.unpair'.1 = 0 then sum.inl (vt.2+t')\n      else sum.inr (v'.unpair'.2, vt.2+t')))\n  (\u03bb (v : \u2115), (f.eval v).map $ \u03bb 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 \u27e8he, _\u27e9,\n    split_ifs at h, { contradiction, },\n    rw \u2190 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\u2081 n\u2082 hn\u2082 b hb h,\n  refine \u27e8b.unpair'.snd, b, hb, _\u27e9,\n  split_ifs at h \u22a2, { refl, }, { contradiction, },\nend\n\nlemma time_dom_iff_eval_dom (c : code) (n : \u2115) : (time c n).dom \u2194 (c.eval n).dom :=\nbegin\n  induction c generalizing n,\n  iterate 3 { simp [time], refl, },\n  case code.pair : c\u2081 c\u2082 c\u2081ih c\u2082ih { simp [time, add_def, c\u2081ih, c\u2082ih], },\n  case code.comp : c\u2081 c\u2082 c\u2081ih c\u2082ih { simp [time, add_def, c\u2081ih, c\u2082ih], tauto, },\n  case code.case : c\u2081 c\u2082 c\u2083 c\u2081ih c\u2082ih c\u2083ih { simp only [time, code.eval],\n    rcases (to_bits n) with _|_|_; simp [c\u2081ih, c\u2082ih, c\u2083ih, 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 : \u2115) : (\u2203 t, t \u2208 time c n) \u2194 \u2203 m, m \u2208 c.eval n :=\nby { rw [\u2190 part.dom_iff_mem, \u2190 part.dom_iff_mem], apply time_dom_iff_eval_dom, }\n\nlemma time_frespects_once_eval (f : code) :\n  pfun.frespects_once\n  (\u03bb (vt : \u2115 \u00d7 \u2115), (time f vt.1) >>= \u03bb t',\n    (f.eval vt.1).map (\u03bb v' : \u2115,\n      if v'.unpair'.1 = 0 then sum.inl (vt.2+t')\n      else sum.inr (v'.unpair'.2, vt.2+t')))\n  (\u03bb (v : \u2115), (f.eval v).map $ \u03bb 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 : \u2115 \u2192 \u2115) : Prop :=\n\u2200 (n m : \u2115), n \u2264 m \u2192 \u2203 t \u2208 time c n, t \u2264 bound (nat.log 2 m)\n\ndef time_bound_of_monotonic_iff (c : code) {bound : \u2115 \u2192 \u2115} (mono : monotone bound) :\n  time_bound c bound \u2194 \u2200 n, \u2203 t \u2208 time c n, t \u2264 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 \u27e8t, ht, H\u27e9 := 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\u2081 : \u2115 \u2192 \u2115} (hb : time_bound c b\u2081) (b\u2082 : \u2115 \u2192 \u2115) (b\u2081_le_b\u2082 : \u2200 n, b\u2081 n \u2264 b\u2082 n) : time_bound c b\u2082 :=\n\u03bb n N h, let \u27e8t, ht, hb\u27e9 := hb n N h in \u27e8t, ht, hb.trans (b\u2081_le_b\u2082 _)\u27e9\n\n/- Why isn't this already a lemma? -/\nlemma sq_mono : monotone (\u03bb n : \u2115, n^2) := by { intros x y hxy, nlinarith, }\n\nlemma pair_bound {v\u2081 v\u2082 b\u2081 b\u2082 : \u2115} (hv\u2081 : nat.log 2 v\u2081 \u2264 b\u2081^2) (hv\u2082 : nat.log 2 v\u2082 \u2264 b\u2082^2) :\n  nat.log 2 (nat.mkpair' v\u2081 v\u2082) \u2264 (b\u2081 + b\u2082 + 3)^2 :=\nbegin\n  have :=\n    calc 2 * nat.log 2 (nat.log 2 v\u2081 + 1)\n      \u2264 2 * nat.log 2 (b\u2081^2 + 1) : by { mono*,  { apply nat.log_monotone, mono, }, all_goals { exact zero_le _, }, }\n  ... \u2264 2 * nat.log 2 ((b\u2081 + 1)^2) : by { mono*, { apply nat.log_monotone, ring_nf SOP, simp, }, all_goals { exact zero_le _, }, }\n  ... \u2264 2 * (2 * (nat.log 2 (b\u2081 + 1) + 1)) : by { mono, { apply nat.log_pow_k_le, }, all_goals { exact zero_le _, }, }\n  ... = 4 * nat.log 2 (b\u2081 + 1) + 4 : by ring\n  ... \u2264 4 * b\u2081 + 4 : by { mono*, { exact nat.log_succ_le _ _, }, all_goals { exact zero_le _, }, },\n  \n  exact calc nat.log 2 (nat.mkpair' v\u2081 v\u2082)\n      \u2264 nat.log 2 v\u2081 + nat.log 2 v\u2082 + 2 * nat.log 2 (nat.log 2 v\u2081 + 1) + 5 : nat.mkpair'_le v\u2081 v\u2082\n  ... \u2264 b\u2081^2 + b\u2082^2 + (4 * b\u2081 + 4) + 5 : by mono*\n  ... \u2264 (b\u2081 + b\u2082 + 3)^2 : by { ring_nf, nlinarith, }\nend\n\nlemma eval_le_time {c : code} {n m t : \u2115} (hm : m \u2208 c.eval n) (ht : t \u2208 time c n) : nat.log 2 m \u2264 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\u2081 c\u2082 c\u2081ih c\u2082ih\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 \u27e8t\u2081, ht\u2081, t\u2082, ht\u2082, ht\u27e9 := ht, subst ht,\n    obtain \u27e8v\u2081, hv\u2081, v\u2082, hv\u2082, hm\u27e9 := hm, subst hm,\n    rw [add_assoc t\u2081 3 t\u2082, add_comm 3 t\u2082, \u2190 add_assoc t\u2081 t\u2082 3],\n    exact pair_bound (c\u2081ih hv\u2081 ht\u2081) (c\u2082ih hv\u2082 ht\u2082), },\n  case code.comp : c\u2081 c\u2082 c\u2081ih c\u2082ih\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 \u27e8t\u2082, ht\u2082, t\u2081, \u27e8v, hv, ht\u2081\u27e9, ht\u27e9 := ht,\n    obtain \u27e8v', hv', hm\u27e9 := hm, have := part.mem_unique hv hv', subst this,\n    refine (c\u2081ih hm ht\u2081).trans _, apply sq_mono, simp only [part.mem_some_iff] at ht, rw ht,\n    simp, },\n  case code.case : c\u2081 c\u2082 c\u2083 c\u2081ih c\u2082ih c\u2083ih\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 \u27e8t\u2083, ht\u2083, ht\u27e9, refine (c\u2083ih h ht\u2083).trans _,  apply sq_mono, rw \u2190 ht, simp, },\n    { rintros h \u27e8t\u2081, ht\u2081, ht\u27e9, refine (c\u2081ih h ht\u2081).trans _, apply sq_mono, rw \u2190 ht, simp, },\n    { rintros h \u27e8t\u2082, ht\u2082, ht\u27e9, refine (c\u2082ih h ht\u2082).trans _, apply sq_mono, rw \u2190 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 \u27e8t, ht, ht_succ\u27e9 := ht,\n    obtain \u27e8\u27e8mL, tL\u27e9, htime, heval\u27e9 := 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 \u27e8m', hm', hmm'\u27e9 := heval, obtain \u27e8tf, htf, m'', hm'', htL\u27e9 := 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 \u2264 nat.log 2 m' : by { apply nat.log_monotone, rw \u2190 hmm', exact nat.unpair'_snd_le _, }\n                      ...  \u2264 tf^2 : ih hm' htf\n                      ...  \u2264 t_succ^2 : by { rw [\u2190 ht_succ, \u2190 htL], mono, apply le_add_right, simp, }, },\nend\n\nlemma one_le_time {c : code} {n t : \u2115} (ht : t \u2208 time c n) : 1 \u2264 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 \u27e8_, _, _, _, ht\u27e9 := ht, rw \u2190 ht, nlinarith only, },\n  { obtain \u27e8_, _, _, _, ht\u27e9 := ht, rw \u2190 ht, nlinarith only, },\n  { obtain \u27e8_, _, ht\u27e9 := ht, rw \u2190 ht, nlinarith only, },\n  { obtain \u27e8_, _, ht\u27e9 := ht, rw \u2190 ht, nlinarith only, },\nend\n\nlemma time_bound_fst : time_bound code.fst (\u03bb 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 (\u03bb 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) (\u03bb t, t+1) :=\nby { rw time_bound_of_monotonic_iff, { simp [time], }, { intros x y h, simpa }, }\n\nlemma time_bound_pair {c\u2081 c\u2082 : code} {b\u2081 b\u2082 : \u2115 \u2192 \u2115} (hb\u2081 : time_bound c\u2081 b\u2081) (hb\u2082 : time_bound c\u2082 b\u2082) :\n  time_bound (code.pair c\u2081 c\u2082) (\u03bb t, (b\u2081 t) + (b\u2082 t) + 3) :=\nbegin\n  intros n N h,\n  obtain \u27e8t\u2081, ht\u2081, hb\u2081\u27e9 := hb\u2081 n N h, obtain \u27e8t\u2082, ht\u2082, hb\u2082\u27e9 := hb\u2082 n N h,\n  use (t\u2081 + t\u2082 + 3), split,\n  { rw \u2190 part.eq_some_iff at ht\u2081 ht\u2082, simp [time, ht\u2081, ht\u2082, add_def], ring, },\n  { mono*, },\nend\n\nlemma time_bound_comp {c\u2081 c\u2082 : code} {b\u2081 b\u2082 : \u2115 \u2192 \u2115} (hb\u2081 : time_bound c\u2081 b\u2081) (hb\u2082 : time_bound c\u2082 b\u2082) :\n  time_bound (code.comp c\u2081 c\u2082) (\u03bb t, (b\u2082 t) + (b\u2081 ((b\u2082 t)^2 + 1)) + 1) :=\nbegin\n  intros n N h,\n  obtain \u27e8t\u2082, ht\u2082, hb\u2082\u27e9 := hb\u2082 n N h,\n  obtain \u27e8m, hm\u27e9 := (exists_mem_time_iff_exists_mem_dom c\u2082 n).mp \u27e8_, ht\u2082\u27e9,\n  obtain \u27e8t\u2081, ht\u2081, hb\u2081\u27e9 := hb\u2081 m (2^((b\u2082 $ nat.log 2 N)^2 + 1)) _,\n  { use t\u2081 + t\u2082 + 1, split,\n    { rw \u2190 part.eq_some_iff at ht\u2081 ht\u2082 hm, simp [time, ht\u2081, ht\u2082, add_def, hm], ring, },\n    rw add_comm t\u2081 t\u2082, mono*, rwa nat.log_pow (show 1 < 2, by norm_num) at hb\u2081, },\n  apply le_of_lt, apply nat.lt_pow_succ_of_log_le, { norm_num },\n  exact calc nat.log 2 m \u2264 t\u2082^2 : eval_le_time hm ht\u2082\n                     ... \u2264 (b\u2082 $ nat.log 2 N)^2 : by mono,\nend\n\nlemma time_bound_case {c\u2081 c\u2082 c\u2083 : code} {b\u2081 b\u2082 b\u2083 : \u2115 \u2192 \u2115} (hb\u2081 : time_bound c\u2081 b\u2081) (hb\u2082 : time_bound c\u2082 b\u2082) (hb\u2083 : time_bound c\u2083 b\u2083) :\n  time_bound (code.case c\u2081 c\u2082 c\u2083) (\u03bb t, (max (max (b\u2081 t) (b\u2082 t)) (b\u2083 0)) + 1) :=\nbegin\n  intros n N h, \n  rcases e : (to_bits n) with _ |_|_,\n  { obtain \u27e8t, ht, hb\u27e9 := hb\u2083 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 \u27e8t, ht, hb\u27e9 := hb\u2081 (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) : \u2115),\n    { apply le_of_lt, apply num.of_bits_strict_mono, rw e, simp, },\n    simpa, },\n  { obtain \u27e8t, ht, hb\u27e9 := hb\u2082 (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) : \u2115),\n    { apply le_of_lt, apply num.of_bits_strict_mono, rw e, simp, },\n    simpa, },\nend\n\nlemma time_bound_case' {c\u2081 c\u2082 c\u2083 : code} {b\u2081 b\u2082 b\u2083 : \u2115 \u2192 \u2115} (hb\u2081 : time_bound c\u2081 b\u2081) (hb\u2082 : time_bound c\u2082 b\u2082) (hb\u2083 : time_bound c\u2083 b\u2083) :\n  time_bound (code.case c\u2081 c\u2082 c\u2083) (\u03bb t, (b\u2081 t) + (b\u2082 t) + (b\u2083 0) + 1) :=\nbegin\n  apply time_bound_of_time_bound_le (time_bound_case hb\u2081 hb\u2082 hb\u2083),\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* `\u03b8`, which is the specialization of evaluation-at-\u03be map `\u03d1` from `laurent_measures.theta`\n  at `\u03be=2\u207b\u00b9`.\n* `\u03d5` which corresponds to multiplying a Laurent series in `\u2112 S = (laurent_measures r S)`\n  for `r = 2^(1/p)` by `T\u207b\u00b9-2`.\n* `\u03c8` corresponds to dividing a Laurent series by `(T\u207b\u00b9-2)`. It is defined only on series\n  vanishing at `2\u207b\u00b9`, so that it again takes values in `\u2112 S`\n* The maps `\u0398`, `\u03a6` and `\u03a8` are the \"measurifications\" of `\u03b8`, `\u03d5` and `\u03c8`,\n  so they are morphisms in the right category (**[FAE]** Not here any more!)\n\nThe main results are\n* `injective_\u03d5` stating that `\u03d5` is injective;\n* `\u03b8_\u03d5_complex` stating that `\u03d5 \u2218 \u03b8 = 0`; and\n* `\u03b8_\u03d5_exact` stating that the kernel of `\u03b8` coincides with the image of `\u03d5`.\nTogether with `\u03d1_surjective` from `laurent_measures.theta` (specialized at `\u03be=2\u207b\u00b9`, so that `\u03d1` is\n`\u03b8`) 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 : \u211d\u22650}\n\nlocal notation `\u2112` := laurent_measures r\nvariables [fact (0 < r)]\nvariable {S : Fintype}\n\ndef \u03d5 : \u2112 S \u2192 \u2112 S :=\n\u03bb F, shift (1) F - 2 \u2022 F\n\nlemma \u03d5_apply (F : \u2112 S) (s : S) (n : \u2124) : \u03d5 F s n = F s (n+1) - 2 * F s n :=\nby simp only [\u03d5, sub_apply, nsmul_apply, shift_to_fun_to_fun, nsmul_eq_mul]; refl\n\nlemma \u03d5_natural (S T : Fintype) (f : S \u27f6 T) : --[fact (0 < p)] [fact ( p \u2264 1)] :\n  \u03d5 \u2218 laurent_measures.map_hom f = laurent_measures.map_hom f \u2218 \u03d5 :=\nbegin\n  ext F t n,\n  simp only [\u03d5, 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 @\u03d5\n\n-- lemma tsum_reindex (F : \u2112 S) (N : \u2124) (s : S) : \u2211' (l : \u2115), (F s (N + l) : \u211d) * (2 ^ l)\u207b\u00b9 =\n--  2 ^ N * \u2211' (m : {m : \u2124 // N \u2264 m}), (F s m : \u211d) * (2 ^ m.1)\u207b\u00b9 :=\n-- begin\n--   have h_shift := int_tsum_shift (\u03bb n, (F s n : \u211d) * (2 ^ (-n))) N,\n--   simp only at h_shift,\n--   simp_rw [subtype.val_eq_coe, \u2190 zpow_neg],\n--   rw [\u2190 h_shift, \u2190 _root_.tsum_mul_left, tsum_congr],\n--   intro n,\n--   rw [mul_comm (_ ^ N), mul_assoc, \u2190 (zpow_add\u2080 (@two_ne_zero \u211d _ _)), 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_\u03d5 (F : \u2112 S) (H : \u03d5 F = 0) : F = 0 :=\nbegin\n  dsimp only [\u03d5] at H, rw [sub_eq_zero] at H,\n  replace H : \u2200 n : \u2124, \u2200 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\u2080,\n    simp [\u2190 H (k + 1) s, add_sub_cancel, hk\u2080, mul_zero] },\n  { intros k h hk\u2080,\n    simpa only [hk\u2080, mul_eq_zero, bit0_eq_zero, one_ne_zero, false_or, zero_apply] using H k s }\nend\n\nlemma injective_\u03d5' : function.injective (\u03d5 : \u2112 S \u2192 \u2112 S) :=\nbegin\n  let PHI : comphaus_filtered_pseudo_normed_group_hom (\u2112 S) (\u2112 S) :=\n    shift (1) - 2 \u2022 comphaus_filtered_pseudo_normed_group_hom.id,\n  apply (injective_iff_map_eq_zero (PHI.to_add_monoid_hom)).mpr,\n  exact injective_\u03d5\nend\n\nend phi\n\nsection mem_exact\n\nparameter {p : \u211d\u22650}\n\n/-- `r`, or `r(p)`, is `2\u207b\u1d56`. -/\ndef r : \u211d\u22650 := 2\u207b\u00b9 ^ (p : \u211d)\n\nlemma r_pos : 0 < r :=\nsuffices 0 < (2 : \u211d\u22650)\u207b\u00b9 ^ (p : \u211d), by simpa [r],\nrpow_pos (nnreal.inv_pos.mpr zero_lt_two)\n\ninstance r_pos' : fact (0 < r) := \u27e8r_pos\u27e9\n\nlemma r_coe : (2\u207b\u00b9 : \u211d) ^ (p : \u211d) = r :=\nbegin\n  have : (2\u207b\u00b9 : \u211d) = ((2\u207b\u00b9 : \u211d\u22650) : \u211d),\n  simp only [one_div, nonneg.coe_inv, nnreal.coe_bit0, nonneg.coe_one],\n  rw [this, \u2190 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) := \u27e8r_lt_one\u27e9\n\nvariable {S : Fintype}\n\nlocal notation `\u2112` := laurent_measures r\nlocal notation `\u2133` := real_measures p\n\ntheorem nnreal.rpow_int_cast (x : nnreal) (n : \u2124) : x ^ (n : \u211d) = x ^ n :=\nbegin\n  apply subtype.ext,\n  simp,\nend\n\ndef \u03b8 : \u2112 S \u2192 \u2133 S := \u03d1 2\u207b\u00b9 r p S\n\nlemma \u03b8_natural [fact (0 < p)] [fact (p \u2264 1)] (S T : Fintype) (f : S \u27f6 T) (F : \u2112 S) (t : T) :\n  \u03b8 (map f F) t = real_measures.map f (\u03b8 F) t :=\nbegin\n  simp only [\u03b8, \u03d1, one_div, map_apply, int.cast_sum, inv_zpow', zpow_neg, real_measures.map_apply],\n  rw \u2190 tsum_sum,\n  { congr', ext n, exact sum_mul, },\n  intros,\n  rw mem_filter at H,\n  rcases H with \u27e8-, rfl\u27e9,\n  have := F.summable i,\n  refine summable.add_compl (_ : summable (_ \u2218 (coe : {n : \u2124 | 0 \u2264 n} \u2192 \u2124))) _,\n  { have moo := summable.comp_injective this\n      (subtype.coe_injective : function.injective (coe : {n : \u2124 | 0 \u2264 n} \u2192 \u2124)),\n    refine summable_of_norm_bounded _ (moo) _, clear moo this,\n    rintro \u27e8n, (hn : 0 \u2264 n)\u27e9,\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 : \u211d) ^ n)\u207b\u00b9 = ((2 ^ n)\u207b\u00b9 : nnreal)),\n    norm_cast,\n    rw [\u2190 nnreal.rpow_int_cast, \u2190 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 \u27e8d, hd\u27e9 := 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 \u27e8z, (hz : \u00ac (0 \u2264 z))\u27e9 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\u207b\u00b9 < r :=\ncalc (2\u207b\u00b9:\u211d\u22650)\n    = 2\u207b\u00b9 ^ (1:\u211d) : (rpow_one (2\u207b\u00b9:\u211d\u22650)).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\u207b\u00b9 : \u211d) < 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\u207b\u00b9 < 2 :=\nbegin\n  rw \u2190 inv_inv (2 : \u211d\u22650),\n  exact nnreal.inv_lt_inv (by norm_num) half_lt_r,\nend\n\nlemma laurent_measures.summable_half (F : \u2112 S) (s : S) :\n  summable (\u03bb n, ((F s n) : \u211d) * 2\u207b\u00b9 ^ n) :=\naux_thm69.summable_smaller_radius F.d (F.summable s) (\u03bb n hn, lt_d_eq_zero _ _ _ hn) half_lt_r\n\nlemma \u03b8_\u03d5_complex (F : \u2112 S) : (\u03b8 \u2218 \u03d5) F = 0 :=\nbegin\n  have t0 : (2 : \u211d)\u207b\u00b9 \u2260 0 := inv_ne_zero two_ne_zero,\n  funext s,\n  convert_to \u2211' (n : \u2124), ((F s (n + 1) - 2 * F s n) : \u211d) * 2\u207b\u00b9 ^ n = 0,\n  { apply tsum_congr,\n    intro b,\n    field_simp [\u03d5] },\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 (\u03bb i, (i.val : \u2124) - 1) _ _ _,\n    { rintros \u27e8x, _\u27e9 \u27e8y, _\u27e9 h, dsimp at *, linarith },\n    { rintros x hx,\n      refine \u27e8\u27e8x + 1, _\u27e9, _\u27e9,\n      { rw function.mem_support at \u22a2 hx,\n        convert hx using 1,\n        simp [zpow_add\u2080],\n        ring },\n      { simp } },\n    { rintro \u27e8i, hi\u27e9,\n      simp [zpow_sub\u2080],\n      ring } },\n  { rw \u2190 (equiv.add_group_add (-1 : \u2124)).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\u2080], ring },\n  { simp_rw [mul_assoc],\n    convert (F.summable_half s).mul_left 2 },\nend\n.\n\n/-!\n\n### Definition of \u03c8\n\nThis involves dividing by T\u207b\u00b9 - 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 \u211d\u22650-valued\nsum of sums\"\n\n-/\n\nlemma nnreal.summable_mul_left_iff {X : Type*} {f : X \u2192 \u211d\u22650} {a : \u211d\u22650} (ha : a \u2260 0) :\nsummable f \u2194 summable (\u03bb (x : X), a * f x) :=\nbegin\n  rw [\u2190 nnreal.summable_coe, \u2190 nnreal.summable_coe],\n  rw summable_mul_left_iff (by exact_mod_cast ha : (a : \u211d) \u2260 0),\n  apply summable_congr,\n  intro b,\n  norm_cast,\nend\n\nlemma psi_def_summable {S : Fintype} (n : \u2115)\n  (F : \u2112 S)\n  (s : S) :\n  summable\n    (\u03bb (k : \u2115),\n       r ^ (F.d + \u2191n) *\n         (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a)) :=\nbegin\n  have := F.summable_half s,\n  apply summable.mul_left,\n  have h : (2\u207b\u00b9 : \u211d\u22650) \u2260 0 := by norm_num,\n  rw nnreal.summable_mul_left_iff (show ((2\u207b\u00b9 : \u211d\u22650) ^ (F.d + n) \u2260 0), from zpow_ne_zero _ h),\n  simp only [\u2190 mul_assoc, \u2190 zpow_add\u2080 h],\n  have this2 := lt_d_eq_zero F s,\n  rw \u2190 summable_norm_iff at this,\n  simp_rw \u2190 _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 : \u2112 S)\n  (s : \u21a5S) :\n  \u2200 (k : \u2115),\n    summable\n      (\u03bb (n : \u2115),\n         r ^ (F.d + \u2191n) *\n           ((2\u207b\u00b9 : \u211d\u22650) ^ (k : \u2124) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a)) :=\nbegin\n  intro k,\n  have hhalf : (2\u207b\u00b9 : \u211d\u22650) \u2260 0, by norm_num,\n  have hhalf' : (2\u207b\u00b9 : \u211d\u22650) \u2260 0, by norm_num,\n  have hr : r \u2260 0 := r_pos.ne.symm,\n  rw nnreal.summable_mul_left_iff\n    (show (2\u207b\u00b9 : \u211d\u22650) ^ (-(k : \u2124)) * r ^ (k : \u2124) \u2260 0, from mul_ne_zero (zpow_ne_zero _ hhalf') (zpow_ne_zero _ hr)),\n  have : \u2200 x : \u2115, 2\u207b\u00b9 ^ -(k : \u2124) * r ^ (k : \u2124) * (r ^ (F.d + \u2191x) * (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191x + \u2191k)\u2225\u208a))\n    = r ^ (F.d + x + k) * \u2225F s (F.d + \u2191x + \u2191k)\u2225\u208a,\n  { intro x,\n    rw (show (2\u207b\u00b9 : \u211d\u22650) ^ -(k : \u2124) * r ^ (k : \u2124) * (r ^ (F.d + \u2191x) * (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191x + \u2191k)\u2225\u208a))\n      = (2\u207b\u00b9 : \u211d\u22650) ^ -(k : \u2124) * 2\u207b\u00b9 ^ (k : \u2124) * r ^ (k : \u2124) * r ^ (F.d + \u2191x) *  \u2225F s (F.d + \u2191x + \u2191k)\u2225\u208a, by ring),\n    simp only [zpow_add\u2080 hr, \u2190 zpow_add\u2080 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 : \u2112 S)\n  (s : \u21a5S) :\n  summable\n    (\u03bb (k : \u2115),\n       \u2211' (n : \u2115),\n         r ^ (F.d + \u2191n) *\n           (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a)) :=\nbegin\n  -- take 2\u207b\u00b9^k out the tsum,\n  -- put r^k into the tsum,\n  -- bounded by sum of GP,\n  have bdd : \u2200 k : \u2115, \u2211' (n : \u2115),\n         r ^ (F.d + \u2191n + k) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a \u2264\n           \u2211' (t : \u2124),\n         r ^ t * \u2225F s t\u2225\u208a,\n  { intro k,\n    simp_rw add_right_comm,\n    have hinj : function.injective (\u03bb (m : \u2115), 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 \u2190 @nnreal.summable_iff_on_nat_less_shift (\u03bb (z : \u2124), r ^ z * \u2225F s z\u2225\u208a) 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 : \u2200 k : \u2115, \u2211' (n : \u2115), r ^ (F.d + \u2191n) * (2\u207b\u00b9 ^ (k : \u2124) * \u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a) =\n   (\u2211' (n : \u2115), r ^ (F.d + \u2191n + k) * (\u2225F s (F.d + \u2191n + \u2191k)\u2225\u208a)) * (2\u207b\u00b9 * r\u207b\u00b9) ^ (k : \u2124),\n  { intro k,\n    rw \u2190 nnreal.tsum_mul_right,\n    apply tsum_congr,\n    intro n,\n    simp only [zpow_add\u2080 r_pos.ne.symm, zpow_coe_nat, one_div, inv_pow, div_zpow],\n    have foo : (2 * r) ^ k \u2260 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 (\u03bb k : \u2115, (\u2211' (t : \u2124), r ^ t * \u2225F s t\u2225\u208a) * (2\u207b\u00b9 * r\u207b\u00b9) ^ 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 : \u2112 S) (s : \u21a5S) : summable\n  (\u03bb (m : \u2115),\n     \u2225(2 : \u211d) ^ (F.d + \u2191m)\u2225\u208a *\n       ((\u2211' (k : \u2115), \u2225F s (F.d + \u2191m + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (F.d + \u2191m + \u2191k)) * r ^ (F.d + \u2191m))) :=\nbegin\n  -- tidy up\n  simp_rw [nnnorm_zpow, real.nnnorm_two],\n  have : \u2200 m : \u2115, (2 : \u211d\u22650) ^ (F.d + \u2191m) *\n  ((\u2211' (k : \u2115), \u2225F s (F.d + \u2191m + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (F.d + \u2191m + \u2191k)) * r ^ (F.d + \u2191m)) =\n  \u2211' (k : \u2115), (2 : \u211d\u22650) ^ (F.d + \u2191m) * \u2225F s (F.d + \u2191m + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (F.d + \u2191m + \u2191k) * r ^ (F.d + \u2191m),\n  { intro m,\n    rw [\u2190 nnreal.tsum_mul_right, \u2190 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\u207b\u00b9^x)\n  suffices : summable\n  (\u03bb (m : \u2115), \u2211' (k : \u2115),\n       \u2225F s (F.d + \u2191m + \u2191k)\u2225\u208a *\n       2\u207b\u00b9 ^ (k : \u2124) * r ^ (F.d + \u2191m)),\n  { refine (summable_congr _).2 this,\n    intro m,\n    apply tsum_congr,\n    intro b,\n    rw [inv_zpow , inv_zpow],\n    rw [\u2190 zpow_neg, \u2190zpow_neg],\n    have h2 : (2 : \u211d\u22650) \u2260 0 := two_ne_zero,\n    simp only [zpow_add\u2080, 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 : \u2112 S) (s : \u21a5S) : summable\n  (\u03bb (n : \u2124),\n     \u2225-(2 : \u211d) ^ (n - 1)\u2225\u208a *\n       ite (F.d \u2264 n) ((\u2211' (k : \u2115), \u2225F s (n + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (n + \u2191k)) * r ^ n) 0) :=\nbegin\n  -- get rid of factor of -2\u207b\u00b9\n  simp_rw [_root_.nnnorm_neg, zpow_sub\u2080 (two_ne_zero : (2 : \u211d) \u2260 0), nnnorm_div, zpow_one,\n    div_eq_mul_inv _ \u2225(2 : \u211d)\u2225\u208a, mul_comm _ \u2225(2 : \u211d)\u2225\u208a\u207b\u00b9, mul_assoc],\n  apply summable.mul_left,\n  have hinj : function.injective (\u03bb (m : \u2115), F.d + m),\n  { rintros a b (h2 : F.d + a = F.d + b),\n    simpa using h2 },\n  -- change outer sum to m : \u2115 with n : \u2124 = F.d + m\n  suffices : summable (\u03bb (m : \u2115),\n     \u2225(2 : \u211d) ^ (F.d + m)\u2225\u208a *\n       ((\u2211' (k : \u2115), \u2225F s (F.d + m + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (F.d + m + \u2191k)) * 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 : \u2112 S) (s : \u21a5S) : summable\n  (\u03bb (n : \u2124),\n     ite (F.d \u2264 n) \u2225-(2 : \u211d) ^ (n - 1) * \u2211' (k : \u2115), \u2191(F s (n + \u2191k)) * 2\u207b\u00b9 ^ (n + \u2191k) * r ^ n\u2225\u208a 0) :=\nbegin\n  simp_rw [nnnorm_mul],\n  -- next : put norm inside inner tsum (a one way implication)\n  suffices : summable\n  (\u03bb (n : \u2124), \u2225-(2 : \u211d) ^ (n - 1)\u2225\u208a *\n     ite (F.d \u2264 n)\n     ((\u2211' (k : \u2115), \u2225F s (n + \u2191k)\u2225\u208a * 2\u207b\u00b9 ^ (n + \u2191k)) * 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 \u2190 summable_norm_iff at this,\n          simp_rw \u2190 _root_.coe_nnnorm at this,\n          rw nnreal.summable_coe at this,\n          have hinj : function.injective (\u03bb (b : \u2115), 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 [\u2190 zpow_neg] },\n        { rw \u2190 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 : \u2112 S) (s : \u21a5S) :\n  summable (\u03bb (n : \u2124), \u2225ite (F.d \u2264 n) (-(2 : \u211d) ^ (n - 1) *\n    \u2211' (k : \u2115), \u2191(F s (n + \u2191k)) * 2\u207b\u00b9 ^ (n + \u2191k)) 0\u2225\u208a * r ^ n) :=\nbegin\n  suffices :  summable (\u03bb (n : \u2124), ite (F.d \u2264 n) \u2225-(2 : \u211d) ^ (n - 1) *\n    \u2211' (k : \u2115), \u2191(F s (n + \u2191k)) * 2\u207b\u00b9 ^ (n + \u2191k) * r ^ n\u2225\u208a 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 [ \u2190 mul_assoc, nnnorm_mul _ ((r : \u211d) ^ n)],\n      simp },\n    { simp } },\n  exact psi_def_aux_2 _ _,\nend\n\ndef \u03c8 (F : \u2112 S) (hF : \u03b8 F = 0) : \u2112 S :=\n{ to_fun := \u03bb s n, if F.d \u2264 n then\n    \u2211 l in range (n - F.d).nat_abs.succ, F s (n - 1 - l) * (2 ^ l)\n    else 0,\n  summable' := \u03bb s, begin\n    -- make everything real\n    change summable (\u03bb (n : \u2124),\n     \u2225((ite (F.d \u2264 n)\n       (\u2211 (l : \u2115) in range (n - F.d).nat_abs.succ, F s (n - 1 - \u2191l) * 2 ^ l) 0 : \u2124) : \u211d)\u2225\u208a\n     * r ^ n),\n    push_cast,\n    -- hypothesis that infinite sum converges at r>2\u207b\u00b9\n    -- get hypothesis that infinite sum is 0 at 2\u207b\u00b9\n    simp only [\u03b8, \u03d1] at hF,\n    replace hF := congr_fun hF s, dsimp at hF,\n    -- change sum from \u2124 to \u2115\n    --rw nnreal.summable_iff_on_nat_less F.d, swap,\n    --{ intros n hn, simp [if_neg hn.not_le] },\n    have h1 : \u2200 (n : \u2124),\n      ite (F.d \u2264 n) (\u2211 (l : \u2115) in range (n - F.d).nat_abs.succ, (F s (n - 1 - \u2191l) : \u211d) * 2 ^ l) 0 =\n      ite (F.d \u2264 n) (-(2 : \u211d)^(n-1)*\u2211' (k : \u2115), F s (n + k) * 2\u207b\u00b9 ^ (n + k)) 0,\n    { intro n,\n      split_ifs with hn, swap, refl,\n      rw [\u2190 inv_mul_eq_iff_eq_mul\u2080, \u2190 neg_inv, neg_mul, mul_sum, neg_eq_iff_add_eq_zero, \u2190 hF],\n        swap, exact neg_ne_zero.2 (zpow_ne_zero _ two_ne_zero),\n      convert @tsum_add_tsum_compl \u211d \u2124 _ _ _ _ _ {x : \u2124 | x < n}\n        (summable.subtype (F.summable_half s) _) (summable.subtype (F.summable_half s) _) using 2,\n      { simp_rw [\u2190 inv_zpow, mul_comm ((2\u207b\u00b9 : \u211d)^(n-1)), mul_assoc],\n        simp_rw (show \u2200 (x : \u2115), (2 : \u211d)^x = 2\u207b\u00b9^(-(x : \u2124)), by {intros, simp}),\n        simp_rw [\u2190 zpow_add\u2080 (by norm_num : (2\u207b\u00b9 : \u211d) \u2260 0), add_comm, \u2190 sub_eq_add_neg],\n        rw \u2190 tsum_eq_sum,\n        convert @equiv.tsum_eq \u211d _ _ _ _ _\n          (\u27e8\u03bb m, \u27e8n - 1 - m, lt_of_le_of_lt (sub_le_self _ (int.coe_zero_le m)) (sub_one_lt n)\u27e9,\n           (\u03bb z, (n - 1 - z.1).nat_abs), \u03bb m, by simp, \u03bb \u27e8z, hz\u27e9, subtype.ext begin\n--             squeeze_simp,\n             change n - 1 - (n - 1 - z).nat_abs = z,\n             rw \u2190 int.eq_nat_abs_of_zero_le (sub_nonneg_of_le (int.le_sub_one_of_lt hz)),\n             ring, end\u27e9 : \u2115 \u2243 {z : \u2124 // 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, \u2190 int.coe_nat_lt, int.coe_nat_add,\n            \u2190 int.eq_nat_abs_of_zero_le]; linarith } },\n      { convert @equiv.tsum_eq \u211d _ _ _ _ _\n          (\u27e8\u03bb x, \u27e8n + x, (int.le.intro rfl).not_lt\u27e9, (\u03bb z, (z.1 - n).nat_abs),\n            \u03bb x, by simp, \u03bb \u27e8x, hx\u27e9, subtype.ext begin\n              change n + _ = x,\n              rw \u2190 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\u27e9 : \u2115 \u2243 {z : \u2124 // \u00ac z < n}) _,\n        ext, refl },\n    },\n    suffices : summable (\u03bb (n : \u2124),\n     \u2225ite (F.d \u2264 n) (-(2 : \u211d)^(n-1)*\u2211' (k : \u2115), \u2191(F s (n + k)) * 2\u207b\u00b9 ^ (n + k)) 0\u2225\u208a *\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 \u03b8_\u03d5_split_exact (F : \u2112 S) (hF : \u03b8 F = 0) : \u03d5 (\u03c8 F hF) = F :=\nbegin\n  ext s n,\n  simp only [\u03d5, \u03c8, 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 : \u2124) + 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 \u27e8m, hm\u27e9 := (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 \u03b8_\u03d5_exact (F : \u2112 S) (hF : \u03b8 F = 0) : \u2203 G, \u03d5 G = F :=\n\u27e8\u03c8 F hF, \u03b8_\u03d5_split_exact F hF\u27e9\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 \u2192 type \u2192 Prop )\n\nnamespace edge\n\ndef op (E : edge) : edge :=\n{ op_type := E.type,\n  type := E.op_type,\n  R := \u03bb x y, E.R y x }\n\nstructure hom (X Y : edge) : Type :=\n( op_hom : Y.op_type \u2192 X.op_type )\n( hom : X.type \u2192 Y.type )\n( adj : \u2200 (x : X.type) (y : Y.op_type), X.R (op_hom y) x \u2194 Y.R y (hom x) )\n\ndef functional (E : edge) : Prop :=\n\u2203 f : E.op_type \u2192 E.type, \u2200 x y, E.R x y \u2194 f x = y\n\ndef id (X : edge) : hom X X :=\n{ op_hom := id,\n  hom := id,\n  adj := \u03bb _ _, 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 \u2218 f.op_hom,\n  hom := f.hom \u2218 g.hom,\n  adj := \u03bb x y, by simp [f.adj, g.adj] }\n\ndef pullback (E : edge) : Type := { x : E.op_type \u00d7 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 \u2192 Y) : edge :=\n{ op_type := X,\n  type := Y,\n  R := \u03bb x y, f x = y }\n\ndef id_to_of_fun {X Y : Type} (f : X \u2192 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-- \u03a0 (f : \u03a0 x : X, {l : list X // x \u2208 l}) (x : X), {l : list (list X) // (f x).1 \u2208 l}\n\n-- inductive list.rel_lift {A B : Type} (R : A \u2192 B \u2192 Prop) : list A \u2192 list B \u2192 Prop\n-- | nil : list.rel_lift [] []\n-- | cons : \u2200 a b l\u2081 l\u2082, list.rel_lift l\u2081 l\u2082 \u2192 R a b \u2192 list.rel_lift (a :: l\u2081) (b::l\u2082)\n\n-- def thing' (E : edge) : Type := \n-- \u03a0 (f : \u03a0 x : E.type, { l : list E.op_type // \u2203 (y : E.op_type) (h : E.R y x), y \u2208 l }) (x : E.op_type),\n--   {l : list (list E.type) // \u2203 (y : E.type) (h : E.R x y) \n--     (l' : list E.type) (h : list.rel_lift E.R (f y).1 l'), l' \u2208 l  }\n\n-- def thing'_map {X Y : edge} (f : hom X Y) (t : thing' X) : thing' Y :=\n-- \u03bb g y, begin\n--   dsimp only [thing', thing] at t,\n--   let g' : \u03a0 (x : X.type), { l : list X.op_type // \u2203 (y : X.op_type) (h : X.R y x ), y \u2208 l },\n--     from \u03bb x, \u27e8(g (f.hom x)).1.map f.op_hom, begin\n--       rcases (g (f.hom x)).2 with \u27e8y, hy\u2081, hy\u2082\u27e9,\n--       existsi f.op_hom y,\n--       rw [f.adj],\n--       use hy\u2081,\n--       rw [list.mem_map],\n--       use y,\n--       simpa using hy\u2082,\n--     end\u27e9,\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 \u27e8x, hxy, l', hl', hll\u27e9,\n--   use f.hom x,\n--   rw \u2190 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 : (\u2191(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 \u2190 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 \u2192 A) = _root_.id := \n-- by funext; simp\n\n-- lemma list.map_comp {A B C : Type} (f : A \u2192 B) (g : B \u2192 C) : \n--   list.map (g \u2218 f) = list.map g \u2218 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 \u2218 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\u2081 E\u2082 : edge} (f : hom E\u2081 E\u2082) : id2 E\u2081 \u2192 id2 E\u2082 := f.hom\n\nlemma id2_map_id (E : edge) : id2_map (id E) = _root_.id := rfl\n\nlemma id2_map_comp (E\u2081 E\u2082 E\u2083 : edge) (f : hom E\u2081 E\u2082) (g : hom E\u2082 E\u2083) : \n  id2_map (comp g f) = id2_map g \u2218 id2_map f := rfl\n\ndef set2 (E : edge) : Type := E.op_type \u2192 Prop\n\ndef set2_map {E\u2081 E\u2082 : edge} (f : hom E\u2081 E\u2082) : set2 E\u2081 \u2192 set2 E\u2082 := (\u2218 f.op_hom)\n\nlemma set2_map_id (E : edge) : set2_map (id E) = _root_.id := rfl\n\nlemma set2_map_comp (E\u2081 E\u2082 E\u2083 : edge) (f : hom E\u2081 E\u2082) (g : hom E\u2082 E\u2083) : \n  set2_map (comp g f) = set2_map g \u2218 set2_map f := rfl\n\nstructure group2 (E : edge) : Type :=\n( one : E.type )\n( inv : E.op_type \u2192 E.type )\n( mul : E.op_type \u2192 E.op_type \u2192 E.type )\n( one_mul : \u2200 (x : E.op_type) (one' : E.op_type) (h1 : E.R one' one), mul one' x = one  )\n(inv_mul : \u2200 (x : E.op_type), \u2200 (inv_y : E.op_type) (hi : E.R inv_y (inv x)), mul inv_y x = one )\n( mul_assoc : \u2200 (x y z : E.op_type),\n    \u2200 (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 := \u03bb x, f.hom (G.inv (f.op_hom x)),\n  mul := \u03bb x y, f.hom (G.mul (f.op_hom x) (f.op_hom y)),\n  one_mul := \u03bb x one' h1,\n    by rw G.one_mul (f.op_hom x) (f.op_hom one') ((f.adj _ _).2 h1),\n  inv_mul := \u03bb x y hxy, \n    by rw (G.inv_mul (f.op_hom x) (f.op_hom y)) ((f.adj _ _).2 hxy),\n  mul_assoc := \u03bb 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 \u2218 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 \u00a9 2020 Nicol\u00f2 Cavalleri. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Nicol\u00f2 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 (\u03b1 : Type u_1) (\u03b2 : Type u_2) [topological_space \u03b1] [topological_space \u03b2]\n    where\n  to_fun : \u03b1 \u2192 \u03b2\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1]\n    [topological_space \u03b2] : has_coe_to_fun (continuous_map \u03b1 \u03b2) :=\n  has_coe_to_fun.mk (fun (x : continuous_map \u03b1 \u03b2) => \u03b1 \u2192 \u03b2) continuous_map.to_fun\n\nprotected theorem continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1]\n    [topological_space \u03b2] (f : continuous_map \u03b1 \u03b2) : continuous \u21d1f :=\n  continuous_map.continuous_to_fun f\n\ntheorem coe_continuous {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2]\n    {f : continuous_map \u03b1 \u03b2} : continuous \u21d1f :=\n  continuous_map.continuous_to_fun f\n\ntheorem ext {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2]\n    {f : continuous_map \u03b1 \u03b2} {g : continuous_map \u03b1 \u03b2} (H : \u2200 (x : \u03b1), coe_fn f x = coe_fn g x) :\n    f = g :=\n  sorry\n\nprotected instance inhabited {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1]\n    [topological_space \u03b2] [Inhabited \u03b2] : Inhabited (continuous_map \u03b1 \u03b2) :=\n  { default := mk fun (_x : \u03b1) => Inhabited.default }\n\ntheorem coe_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2]\n    {f : continuous_map \u03b1 \u03b2} {g : continuous_map \u03b1 \u03b2} (h : \u21d1f = \u21d1g) : f = g :=\n  sorry\n\n/-- The identity as a continuous map. -/\ndef id {\u03b1 : Type u_1} [topological_space \u03b1] : continuous_map \u03b1 \u03b1 := mk id\n\n/-- The composition of continuous maps, as a continuous map. -/\ndef comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [topological_space \u03b1] [topological_space \u03b2]\n    [topological_space \u03b3] (f : continuous_map \u03b2 \u03b3) (g : continuous_map \u03b1 \u03b2) : continuous_map \u03b1 \u03b3 :=\n  mk (\u21d1f \u2218 \u21d1g)\n\n/-- Constant map as a continuous map -/\ndef const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [topological_space \u03b1] [topological_space \u03b2] (b : \u03b2) :\n    continuous_map \u03b1 \u03b2 :=\n  mk fun (x : \u03b1) => 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)\u1d52\u1d56 \u2964 C`,\nand inherit the category structure with natural transformations as morphisms.\n\nWe define\n* `pushforward_obj {X Y : Top.{v}} (f : X \u27f6 Y) (\u2131 : X.presheaf C) : Y.presheaf C`\nwith notation `f _* \u2131`\nand for `\u2131 : X.presheaf C` provide the natural isomorphisms\n* `pushforward.id : (\ud835\udfd9 X) _* \u2131 \u2245 \u2131`\n* `pushforward.comp : (f \u226b g) _* \u2131 \u2245 g _* (f _* \u2131)`\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)\u1d52\u1d56 \u2964 C\n\nvariables {C}\n\nnamespace presheaf\n\n/-- Pushforward a presheaf on `X` along a continuous map `f : X \u27f6 Y`, obtaining a presheaf\non `Y`. -/\ndef pushforward_obj {X Y : Top.{v}} (f : X \u27f6 Y) (\u2131 : X.presheaf C) : Y.presheaf C :=\n(opens.map f).op \u22d9 \u2131\n\ninfix ` _* `: 80 := pushforward_obj\n\n@[simp] lemma pushforward_obj_obj {X Y : Top.{v}} (f : X \u27f6 Y) (\u2131 : X.presheaf C) (U : (opens Y)\u1d52\u1d56) :\n  (f _* \u2131).obj U = \u2131.obj ((opens.map f).op.obj U) := rfl\n\n@[simp] lemma pushforward_obj_map {X Y : Top.{v}} (f : X \u27f6 Y) (\u2131 : X.presheaf C)\n  {U V : (opens Y)\u1d52\u1d56} (i : U \u27f6 V) :\n  (f _* \u2131).map i = \u2131.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 \u27f6 Y} (h : f = g) (\u2131 : X.presheaf C) :\n  f _* \u2131 \u2245 g _* \u2131 :=\niso_whisker_right (nat_iso.op (opens.map_iso f g h).symm) \u2131\n\nlemma pushforward_eq' {X Y : Top.{v}} {f g : X \u27f6 Y} (h : f = g) (\u2131 : X.presheaf C) :\n  f _* \u2131 = g _* \u2131 :=\nby rw h\n\n@[simp] lemma pushforward_eq_hom_app\n  {X Y : Top.{v}} {f g : X \u27f6 Y} (h : f = g) (\u2131 : X.presheaf C) (U) :\n  (pushforward_eq h \u2131).hom.app U =\n    \u2131.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 \u27f6 Y) (\u2131 : X.presheaf C) (U) :\n  (pushforward_eq (rfl : f = f) \u2131).hom.app (op U) = \ud835\udfd9 _ :=\nbegin\n  dsimp [pushforward_eq],\n  simp,\nend\n\nlemma pushforward_eq_eq {X Y : Top.{v}} {f g : X \u27f6 Y} (h\u2081 h\u2082 : f = g) (\u2131 : X.presheaf C) :\n  \u2131.pushforward_eq h\u2081 = \u2131.pushforward_eq h\u2082 :=\nrfl\n\nnamespace pushforward\nvariables {X : Top.{v}} (\u2131 : 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 : (\ud835\udfd9 X) _* \u2131 \u2245 \u2131 :=\n(iso_whisker_right (nat_iso.op (opens.map_id X).symm) \u2131) \u226a\u226b functor.left_unitor _\n\nlemma id_eq : (\ud835\udfd9 X) _* \u2131 = \u2131 :=\nby { unfold pushforward_obj, rw opens.map_id_eq, erw functor.id_comp }\n\n@[simp] lemma id_hom_app' (U) (p) :\n  (id \u2131).hom.app (op \u27e8U, p\u27e9) = \u2131.map (\ud835\udfd9 (op \u27e8U, p\u27e9)) :=\nby { dsimp [id], simp, }\n\nlocal attribute [tidy] tactic.op_induction'\n\n@[simp, priority 990] lemma id_hom_app (U) :\n  (id \u2131).hom.app U = \u2131.map (eq_to_hom (opens.op_map_id_obj U)) := by tidy\n\n@[simp] lemma id_inv_app' (U) (p) : (id \u2131).inv.app (op \u27e8U, p\u27e9) = \u2131.map (\ud835\udfd9 (op \u27e8U, p\u27e9)) :=\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 \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g) _* \u2131 \u2245 g _* (f _* \u2131) :=\niso_whisker_right (nat_iso.op (opens.map_comp f g).symm) \u2131\n\n\n\n@[simp] lemma comp_hom_app {Y Z : Top.{v}} (f : X \u27f6 Y) (g : Y \u27f6 Z) (U) :\n  (comp \u2131 f g).hom.app U = \ud835\udfd9 _ :=\nby { dsimp [comp], tidy, }\n\n@[simp] lemma comp_inv_app {Y Z : Top.{v}} (f : X \u27f6 Y) (g : Y \u27f6 Z) (U) :\n  (comp \u2131 f g).inv.app U = \ud835\udfd9 _ :=\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 \u27f6 Y) {\u2131 \ud835\udca2 : X.presheaf C} (\u03b1 : \u2131 \u27f6 \ud835\udca2) :\n  f _* \u2131 \u27f6 f _* \ud835\udca2 :=\n{ app := \u03bb U, \u03b1.app _,\n  naturality' := \u03bb U V i, by { erw \u03b1.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 \u27f6 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 \u27f6 Y) (\u2131 : Y.presheaf C) : X.presheaf C :=\n(Lan (opens.map f).op).obj \u2131\n\n/-- Pulling back along continuous maps is functorial. -/\ndef pullback_map {X Y : Top.{v}} (f : X \u27f6 Y) {\u2131 \ud835\udca2 : Y.presheaf C} (\u03b1 : \u2131 \u27f6 \ud835\udca2) :\n  pullback_obj f \u2131 \u27f6 pullback_obj f \ud835\udca2 :=\n(Lan (opens.map f).op).map \u03b1\n\n/-- If `f '' U` is open, then `f\u207b\u00b9\u2131 U \u2245 \u2131 (f '' U)`.  -/\n@[simps]\ndef pullback_obj_obj_of_image_open {X Y : Top.{v}} (f : X \u27f6 Y) (\u2131 : Y.presheaf C) (U : opens X)\n  (H : is_open (f '' U)) : (pullback_obj f \u2131).obj (op U) \u2245 \u2131.obj (op \u27e8_, H\u27e9) :=\nbegin\n  let x : costructured_arrow (opens.map f).op (op U) :=\n  { left := op \u27e8f '' U, H\u27e9,\n    hom := ((@hom_of_le _ _ _ ((opens.map f).obj \u27e8_, H\u27e9) (set.image_preimage.le_u_l _)).op :\n    op ((opens.map f).obj (\u27e8\u21d1f '' \u2191U, H\u27e9)) \u27f6 op U) },\n  have hx : is_terminal x :=\n  { lift := \u03bb s,\n    begin\n      fapply costructured_arrow.hom_mk,\n      change op (unop _) \u27f6 op (\u27e8_, H\u27e9 : 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 \u2191(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}} (\u2131 : Y.presheaf C)\n\n/-- The pullback along the identity is isomorphic to the original presheaf. -/\ndef id : pullback_obj (\ud835\udfd9 _) \u2131 \u2245 \u2131 :=\nnat_iso.of_components\n  (\u03bb U, pullback_obj_obj_of_image_open (\ud835\udfd9 _) \u2131 (unop U) (by simpa using U.unop.2) \u226a\u226b\n    \u2131.map_iso (eq_to_iso (by simp)))\n  (\u03bb 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.\u03b9_desc_assoc,\n      erw colimit.\u03b9_desc_assoc,\n      dsimp, simp only [\u2190\u2131.map_comp], congr\n  end)\n\nlemma id_inv_app (U : opens Y) :\n  (id \u2131).inv.app (op U) = colimit.\u03b9 (Lan.diagram (opens.map (\ud835\udfd9 Y)).op \u2131 (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 \u2190 \u2131.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 \u27f6 Y) : X.presheaf C \u2964 Y.presheaf C :=\n{ obj := pushforward_obj f,\n  map := @pushforward_map _ _ X Y f }\n\nlemma id_pushforward {X : Top.{v}} : pushforward C (\ud835\udfd9 X) = \ud835\udfed (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 \u2245 Y) :\n  X.presheaf C \u224c Y.presheaf C :=\nequivalence.congr_left (opens.map_map_iso H).symm.op\n\nvariable {C}\n\n/--\nIf `H : X \u2245 Y` is a homeomorphism,\nthen given an `H _* \u2131 \u27f6 \ud835\udca2`, we may obtain an `\u2131 \u27f6 H \u207b\u00b9 _* \ud835\udca2`.\n-/\ndef to_pushforward_of_iso {X Y : Top} (H : X \u2245 Y) {\u2131 : X.presheaf C} {\ud835\udca2 : Y.presheaf C}\n  (\u03b1 : H.hom _* \u2131 \u27f6 \ud835\udca2) : \u2131 \u27f6 H.inv _* \ud835\udca2 :=\n(presheaf_equiv_of_iso _ H).to_adjunction.hom_equiv \u2131 \ud835\udca2 \u03b1\n\n@[simp]\nlemma to_pushforward_of_iso_app {X Y : Top} (H\u2081 : X \u2245 Y) {\u2131 : X.presheaf C} {\ud835\udca2 : Y.presheaf C}\n  (H\u2082 : H\u2081.hom _* \u2131 \u27f6 \ud835\udca2) (U : (opens X)\u1d52\u1d56) :\n(to_pushforward_of_iso H\u2081 H\u2082).app U =\n  \u2131.map (eq_to_hom (by simp [opens.map, set.preimage_preimage])) \u226b\n  H\u2082.app (op ((opens.map H\u2081.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 \u2245 Y` is a homeomorphism,\nthen given an `H _* \u2131 \u27f6 \ud835\udca2`, we may obtain an `\u2131 \u27f6 H \u207b\u00b9 _* \ud835\udca2`.\n-/\ndef pushforward_to_of_iso {X Y : Top} (H\u2081 : X \u2245 Y) {\u2131 : Y.presheaf C} {\ud835\udca2 : X.presheaf C}\n  (H\u2082 : \u2131 \u27f6 H\u2081.hom _* \ud835\udca2) : H\u2081.inv _* \u2131 \u27f6 \ud835\udca2 :=\n((presheaf_equiv_of_iso _ H\u2081.symm).to_adjunction.hom_equiv \u2131 \ud835\udca2).symm H\u2082\n\n@[simp]\nlemma pushforward_to_of_iso_app {X Y : Top} (H\u2081 : X \u2245 Y) {\u2131 : Y.presheaf C} {\ud835\udca2 : X.presheaf C}\n  (H\u2082 : \u2131 \u27f6 H\u2081.hom _* \ud835\udca2) (U : (opens X)\u1d52\u1d56) :\n(pushforward_to_of_iso H\u2081 H\u2082).app U =\n  H\u2082.app (op ((opens.map H\u2081.inv).obj (unop U))) \u226b\n  \ud835\udca2.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 \u27f6 Y`, obtaining a presheaf\non `X`. -/\n@[simps map_app]\ndef pullback {X Y : Top.{v}} (f : X \u27f6 Y) : Y.presheaf C \u2964 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 \u27f6 Y) (\u2131 : Y.presheaf C) : (pullback C f).obj \u2131 = pullback_obj f \u2131 := 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 \u27f6 Y) :\n  pullback C f \u22a3 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 \u2245 Y) :\n  pullback C H.hom \u2245 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 \u2245 Y) :\n  pullback C H.inv \u2245 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 `\u03d5 i : N i \u2192* M` for each `i : \u03b9` where elements in the\nimages of different morphisms commute, we obtain a canonical morphism\n`monoid_hom.noncomm_pi_coprod : (\u03a0 i, N i) \u2192* M` that coincides with `\u03d5`\n\n## Main definitions\n\n* `monoid_hom.noncomm_pi_coprod : (\u03a0 i, N i) \u2192* M` is the main homomorphism\n* `subgroup.noncomm_pi_coprod : (\u03a0 i, H i) \u2192* 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 `\u03d5 i` when restricted to `N i`\n* `monoid_hom.noncomm_pi_coprod_mrange`: The range of `monoid_hom.noncomm_pi_coprod` is\n  `\u2a06 (i : \u03b9), (\u03d5 i).mrange`\n* `monoid_hom.noncomm_pi_coprod_range`: The range of `monoid_hom.noncomm_pi_coprod` is\n  `\u2a06 (i : \u03b9), (\u03d5 i).range`\n* `subgroup.noncomm_pi_coprod_range`: The range of `subgroup.noncomm_pi_coprod` is `\u2a06 (i : \u03b9), H i`.\n* `monoid_hom.injective_noncomm_pi_coprod_of_independent`: in the case of groups, `pi_hom.hom` is\n   injective if the `\u03d5` are injective and the ranges of the `\u03d5` are independent.\n* `monoid_hom.independent_range_of_coprime_order`: If the `N i` have coprime orders, then the ranges\n   of the `\u03d5` 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] {\u03b9 : Type.{u2}} (s : Finset.{u2} \u03b9) (f : \u03b9 -> G) (comm : Set.Pairwise.{u2} \u03b9 ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} \u03b9) (Set.{u2} \u03b9) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} \u03b9) (Set.{u2} \u03b9) (CoeTC\u2093.coe.{succ u2, succ u2} (Finset.{u2} \u03b9) (Set.{u2} \u03b9) (Finset.Set.hasCoeT.{u2} \u03b9))) s) (fun (a : \u03b9) (b : \u03b9) => 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 : \u03b9 -> (Subgroup.{u1} G _inst_1)), (CompleteLattice.Independent.{succ u2, u1} \u03b9 (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) K) -> (forall (x : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.hasMem.{u2} \u03b9) 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} \u03b9 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 : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.hasMem.{u2} \u03b9) 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] {\u03b9 : Type.{u2}} (s : Finset.{u2} \u03b9) (f : \u03b9 -> G) (comm : Set.Pairwise.{u2} \u03b9 (Finset.toSet.{u2} \u03b9 s) (fun (a : \u03b9) (b : \u03b9) => 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 : \u03b9 -> (Subgroup.{u1} G _inst_1)), (CompleteLattice.Independent.{succ u2, u1} \u03b9 (Subgroup.{u1} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u1} G _inst_1) K) -> (forall (x : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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} \u03b9 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 : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.instMembershipFinset.{u2} \u03b9) 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\u2093'. -/\n/-- `finset.noncomm_prod` is \u201cinjective\u201d 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 \u201cinjective\u201d 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 {\u03b9 : Type _} (s : Finset \u03b9) (f : \u03b9 \u2192 G) (comm)\n    (K : \u03b9 \u2192 Subgroup G) (hind : CompleteLattice.Independent K) (hmem : \u2200 x \u2208 s, f x \u2208 K x)\n    (heq1 : s.noncommProd f comm = 1) : \u2200 i \u2208 s, f i = 1 := by\n  classical\n    revert heq1\n    induction' s using Finset.induction_on with i s hnmem ih\n    \u00b7 simp\n    \u00b7 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 \u2208 \u2a06 i \u2208 (s : Set \u03b9), K i :=\n        by\n        refine' Subgroup.noncommProd_mem _ _ _\n        intro x hx\n        have : K x \u2264 \u2a06 i \u2208 (s : Set \u03b9), K i := le_sup\u1d62\u2082 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 \u2209 (s : Set \u03b9) := by simpa\n      obtain \u27e8heq1i : f i = 1, heq1S : s.noncomm_prod f _ = 1\u27e9 :=\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 \u27e8rfl | _\u27e9\n      \u00b7 exact heq1i\n      \u00b7 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 {\u03b9 : Type _} [hdec : DecidableEq \u03b9] [Fintype \u03b9]\n\nvariable {N : \u03b9 \u2192 Type _} [\u2200 i, Monoid (N i)]\n\n-- And morphisms \u03d5 into G\nvariable (\u03d5 : \u2200 i : \u03b9, N i \u2192* M)\n\n-- We assume that the elements of different morphism commute\nvariable (hcomm : Pairwise fun i j => \u2200 x y, Commute (\u03d5 i x) (\u03d5 j y))\n\ninclude hcomm\n\n-- We use `f` and `g` to denote elements of `\u03a0 (i : \u03b9), N i`\nvariable (f g : \u2200 i : \u03b9, 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] {\u03b9 : Type.{u2}} [_inst_2 : Fintype.{u2} \u03b9] {N : \u03b9 -> Type.{u3}} [_inst_3 : forall (i : \u03b9), Monoid.{u3} (N i)] (\u03d5 : forall (i : \u03b9), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)), (Pairwise.{u2} \u03b9 (fun (i : \u03b9) (j : \u03b9) => 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)) (\u03d5 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)) (\u03d5 j) y))) -> (MonoidHom.{max u2 u3, u1} (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => 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] {\u03b9 : Type.{u2}} [_inst_2 : Fintype.{u2} \u03b9] {N : \u03b9 -> Type.{u3}} [_inst_3 : forall (i : \u03b9), Monoid.{u3} (N i)] (\u03d5 : forall (i : \u03b9), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)), (Pairwise.{u2} \u03b9 (fun (i : \u03b9) (j : \u03b9) => 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)))) (\u03d5 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)))) (\u03d5 j) y))) -> (MonoidHom.{max u2 u3, u1} (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => 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\u2093'. -/\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 : (\u2200 i : \u03b9, N i) \u2192* M\n    where\n  toFun f := Finset.univ.noncommProd (fun i => \u03d5 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 => \u03d5 i (f i)) (fun i => \u03d5 i (g i)) _ _ _\n      \u00b7 ext i\n        exact map_mul (\u03d5 i) (f i) (g i)\n      \u00b7 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] {\u03b9 : Type.{u2}} [hdec : DecidableEq.{succ u2} \u03b9] [_inst_2 : Fintype.{u2} \u03b9] {N : \u03b9 -> Type.{u3}} [_inst_3 : forall (i : \u03b9), Monoid.{u3} (N i)] (\u03d5 : forall (i : \u03b9), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) {hcomm : Pairwise.{u2} \u03b9 (fun (i : \u03b9) (j : \u03b9) => 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)) (\u03d5 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)) (\u03d5 j) y))} (i : \u03b9) (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 : \u03b9), (fun (i : \u03b9) => N i) i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => N i) i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} ((fun (i : \u03b9) => N i) i) ((fun (i : \u03b9) => _inst_3 i) i))) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (_x : MonoidHom.{max u2 u3, u1} (forall (i : \u03b9), (fun (i : \u03b9) => N i) i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => N i) i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} ((fun (i : \u03b9) => N i) i) ((fun (i : \u03b9) => _inst_3 i) i))) (Monoid.toMulOneClass.{u1} M _inst_1)) => (forall (i : \u03b9), (fun (i : \u03b9) => N i) i) -> M) (MonoidHom.hasCoeToFun.{max u2 u3, u1} (forall (i : \u03b9), (fun (i : \u03b9) => N i) i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => N i) i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} ((fun (i : \u03b9) => N i) i) ((fun (i : \u03b9) => _inst_3 i) i))) (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHom.noncommPiCoprod.{u1, u2, u3} M _inst_1 \u03b9 _inst_2 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => _inst_3 i) \u03d5 hcomm) (Pi.mulSingle.{u2, u3} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => N i) i) (fun (a : \u03b9) (b : \u03b9) => hdec a b) (fun (i : \u03b9) => MulOneClass.toHasOne.{u3} ((fun (i : \u03b9) => N i) i) (Monoid.toMulOneClass.{u3} ((fun (i : \u03b9) => 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)) (\u03d5 i) y)\nbut is expected to have type\n  forall {M : Type.{u3}} [_inst_1 : Monoid.{u3} M] {\u03b9 : Type.{u2}} [hdec : DecidableEq.{succ u2} \u03b9] [_inst_2 : Fintype.{u2} \u03b9] {N : \u03b9 -> Type.{u1}} [_inst_3 : forall (i : \u03b9), Monoid.{u1} (N i)] (\u03d5 : forall (i : \u03b9), MonoidHom.{u1, u3} (N i) M (Monoid.toMulOneClass.{u1} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) {hcomm : Pairwise.{u2} \u03b9 (fun (i : \u03b9) (j : \u03b9) => 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)))) (\u03d5 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)))) (\u03d5 j) y))} (i : \u03b9) (y : N i), Eq.{succ u3} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : \u03b9), N i) => M) (Pi.mulSingle.{u2, u1} \u03b9 (fun (i : \u03b9) => N i) (fun (a : \u03b9) (b : \u03b9) => hdec a b) (fun (i : \u03b9) => 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 : \u03b9), N i) M (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (forall (i : \u03b9), N i) (fun (_x : forall (i : \u03b9), N i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : \u03b9), N i) => M) _x) (MulHomClass.toFunLike.{max (max u3 u2) u1, max u2 u1, u3} (MonoidHom.{max u2 u1, u3} (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (forall (i : \u03b9), N i) M (MulOneClass.toMul.{max u2 u1} (forall (i : \u03b9), N i) (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => 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 : \u03b9), N i) M (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{max u2 u1, u3} (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u1} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u3} M _inst_1)))) (MonoidHom.noncommPiCoprod.{u3, u2, u1} M _inst_1 \u03b9 _inst_2 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => _inst_3 i) \u03d5 hcomm) (Pi.mulSingle.{u2, u1} \u03b9 (fun (i : \u03b9) => N i) (fun (a : \u03b9) (b : \u03b9) => hdec a b) (fun (i : \u03b9) => 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)))) (\u03d5 i) y)\nCase conversion may be inaccurate. Consider using '#align monoid_hom.noncomm_pi_coprod_mul_single MonoidHom.noncommPiCoprod_mulSingle\u2093'. -/\n@[simp, to_additive]\ntheorem noncommPiCoprod_mulSingle (i : \u03b9) (y : N i) :\n    noncommPiCoprod \u03d5 hcomm (Pi.mulSingle i y) = \u03d5 i y :=\n  by\n  change finset.univ.noncomm_prod (fun j => \u03d5 j (Pi.mulSingle i y j)) _ = \u03d5 i y\n  simp (config := { singlePass := true }) only [\u2190 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  \u00b7 rw [one_pow]\n    exact mul_one _\n  \u00b7 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] {\u03b9 : Type.{u2}} [hdec : DecidableEq.{succ u2} \u03b9] [_inst_2 : Fintype.{u2} \u03b9] {N : \u03b9 -> Type.{u3}} [_inst_3 : forall (i : \u03b9), 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 : \u03b9), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (\u03d5 : forall (i : \u03b9), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => Pairwise.{u2} \u03b9 (fun (i : \u03b9) (j : \u03b9) => 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)) (\u03d5 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)) (\u03d5 j) y)))) (MonoidHom.{max u2 u3, u1} (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => 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] {\u03b9 : Type.{u2}} [hdec : DecidableEq.{succ u2} \u03b9] [_inst_2 : Fintype.{u2} \u03b9] {N : \u03b9 -> Type.{u3}} [_inst_3 : forall (i : \u03b9), 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 : \u03b9), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) (fun (\u03d5 : forall (i : \u03b9), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) => Pairwise.{u2} \u03b9 (fun (i : \u03b9) (j : \u03b9) => 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)))) (\u03d5 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)))) (\u03d5 j) y)))) (MonoidHom.{max u2 u3, u1} (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => 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\u2093'. -/\n/-- The universal property of `noncomm_pi_coprod` -/\n@[to_additive \"The universal property of `noncomm_pi_coprod`\"]\ndef noncommPiCoprodEquiv :\n    { \u03d5 : \u2200 i, N i \u2192* M // Pairwise fun i j => \u2200 x y, Commute (\u03d5 i x) (\u03d5 j y) } \u2243 ((\u2200 i, N i) \u2192* M)\n    where\n  toFun \u03d5 := noncommPiCoprod \u03d5.1 \u03d5.2\n  invFun f :=\n    \u27e8fun i => f.comp (MonoidHom.single N i), fun i j hij x y =>\n      Commute.map (Pi.mulSingle_commute hij x y) f\u27e9\n  left_inv \u03d5 := 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] {\u03b9 : Type.{u2}} [_inst_2 : Fintype.{u2} \u03b9] {N : \u03b9 -> Type.{u3}} [_inst_3 : forall (i : \u03b9), Monoid.{u3} (N i)] (\u03d5 : forall (i : \u03b9), MonoidHom.{u3, u1} (N i) M (Monoid.toMulOneClass.{u3} (N i) (_inst_3 i)) (Monoid.toMulOneClass.{u1} M _inst_1)) {hcomm : Pairwise.{u2} \u03b9 (fun (i : \u03b9) (j : \u03b9) => 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)) (\u03d5 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)) (\u03d5 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 : \u03b9), N i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1) (MonoidHom.{max u2 u3, u1} (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHom.monoidHomClass.{max u2 u3, u1} (forall (i : \u03b9), N i) M (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} (N i) (_inst_3 i))) (Monoid.toMulOneClass.{u1} M _inst_1)) (MonoidHom.noncommPiCoprod.{u1, u2, u3} M _inst_1 \u03b9 _inst_2 (fun (i : \u03b9) => N i) (fun (i : \u03b9) => _inst_3 i) \u03d5 hcomm)) (sup\u1d62.{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)))) \u03b9 (fun (i : \u03b9) => 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)) (\u03d5 i)))\nbut is expected to have type\n  forall {M : Type.{u3}} [_inst_1 : Monoid.{u3} M] {\u03b9 : Type.{u2}} [_inst_2 : DecidableEq.{succ u2} \u03b9] [N : Fintype.{u2} \u03b9] {_inst_3 : \u03b9 -> Type.{u1}} [\u03d5 : forall (i : \u03b9), Monoid.{u1} (_inst_3 i)] (hcomm : forall (i : \u03b9), MonoidHom.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) {hcomm_1 : Pairwise.{u2} \u03b9 (fun (i : \u03b9) (j : \u03b9) => 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) (\u03d5 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) (\u03d5 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 i) M (MulOneClass.toMul.{u1} (_inst_3 i) (Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 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) (\u03d5 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 i)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 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) (\u03d5 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) (\u03d5 j)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 j) M (MulOneClass.toMul.{u1} (_inst_3 j) (Monoid.toMulOneClass.{u1} (_inst_3 j) (\u03d5 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) (\u03d5 j)) (Monoid.toMulOneClass.{u3} M _inst_1)) (_inst_3 j) M (Monoid.toMulOneClass.{u1} (_inst_3 j) (\u03d5 j)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.monoidHomClass.{u1, u3} (_inst_3 j) M (Monoid.toMulOneClass.{u1} (_inst_3 j) (\u03d5 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 : \u03b9), _inst_3 i) M (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 i))) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.{max u2 u1, u3} (forall (i : \u03b9), _inst_3 i) M (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHom.monoidHomClass.{max u2 u1, u3} (forall (i : \u03b9), _inst_3 i) M (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 i))) (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHom.noncommPiCoprod.{u3, u2, u1} M _inst_1 \u03b9 N (fun (i : \u03b9) => _inst_3 i) (fun (i : \u03b9) => \u03d5 i) hcomm hcomm_1)) (sup\u1d62.{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)))) \u03b9 (fun (i : \u03b9) => MonoidHom.mrange.{u1, u3, max u3 u1} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 i)) (Monoid.toMulOneClass.{u3} M _inst_1) (MonoidHom.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 i)) (Monoid.toMulOneClass.{u3} M _inst_1)) (MonoidHom.monoidHomClass.{u1, u3} (_inst_3 i) M (Monoid.toMulOneClass.{u1} (_inst_3 i) (\u03d5 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\u2093'. -/\n@[to_additive]\ntheorem noncommPiCoprod_mrange : (noncommPiCoprod \u03d5 hcomm).mrange = \u2a06 i : \u03b9, (\u03d5 i).mrange := by\n  classical\n    apply le_antisymm\n    \u00b7 rintro x \u27e8f, rfl\u27e9\n      refine' Submonoid.noncommProd_mem _ _ _ _ _\n      intro i hi\n      apply Submonoid.mem_sup\u209b_of_mem\n      \u00b7 use i\n      simp\n    \u00b7 refine' sup\u1d62_le _\n      rintro i x \u27e8y, rfl\u27e9\n      refine' \u27e8Pi.mulSingle i y, noncomm_pi_coprod_mul_single _ _ _\u27e9\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 {\u03b9 : Type _} [hdec : DecidableEq \u03b9] [hfin : Fintype \u03b9]\n\nvariable {H : \u03b9 \u2192 Type _} [\u2200 i, Group (H i)]\n\nvariable (\u03d5 : \u2200 i : \u03b9, H i \u2192* G)\n\nvariable {hcomm : \u2200 i j : \u03b9, i \u2260 j \u2192 \u2200 (x : H i) (y : H j), Commute (\u03d5 i x) (\u03d5 j y)}\n\ninclude hcomm\n\n-- We use `f` and `g` to denote elements of `\u03a0 (i : \u03b9), H i`\nvariable (f g : \u2200 i : \u03b9, 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] {\u03b9 : Type.{u2}} [hfin : Fintype.{u2} \u03b9] {H : \u03b9 -> Type.{u3}} [_inst_2 : forall (i : \u03b9), Group.{u3} (H i)] (\u03d5 : forall (i : \u03b9), 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 : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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)))) (\u03d5 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)))) (\u03d5 j) y))}, Eq.{succ u1} (Subgroup.{u1} G _inst_1) (MonoidHom.range.{max u2 u3, u1} (forall (i : \u03b9), H i) (Pi.group.{u2, u3} \u03b9 (fun (i : \u03b9) => H i) (fun (i : \u03b9) => _inst_2 i)) G _inst_1 (MonoidHom.noncommPiCoprod.{u1, u2, u3} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)) \u03b9 hfin (fun (i : \u03b9) => H i) (fun (i : \u03b9) => DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i))) \u03d5 hcomm)) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => MonoidHom.range.{u3, u1} (H i) (_inst_2 i) G _inst_1 (\u03d5 i)))\nbut is expected to have type\n  forall {G : Type.{u3}} [_inst_1 : Group.{u3} G] {\u03b9 : Type.{u2}} [hfin : DecidableEq.{succ u2} \u03b9] [H : Fintype.{u2} \u03b9] {_inst_2 : \u03b9 -> Type.{u1}} [\u03d5 : forall (i : \u03b9), Group.{u1} (_inst_2 i)] (hcomm : forall (i : \u03b9), 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) (\u03d5 i)))) (Monoid.toMulOneClass.{u3} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)))) {hcomm_1 : forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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 : \u03b9), _inst_2 i) (Pi.group.{u2, u1} \u03b9 (fun (i : \u03b9) => _inst_2 i) (fun (i : \u03b9) => \u03d5 i)) G _inst_1 (MonoidHom.noncommPiCoprod.{u3, u2, u1} G (DivInvMonoid.toMonoid.{u3} G (Group.toDivInvMonoid.{u3} G _inst_1)) \u03b9 H (fun (i : \u03b9) => _inst_2 i) (fun (i : \u03b9) => DivInvMonoid.toMonoid.{u1} (_inst_2 i) (Group.toDivInvMonoid.{u1} (_inst_2 i) (\u03d5 i))) hcomm hcomm_1)) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => MonoidHom.range.{u1, u3} (_inst_2 i) (\u03d5 i) G _inst_1 (hcomm i)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.noncomm_pi_coprod_range MonoidHom.noncommPiCoprod_range\u2093'. -/\n-- The subgroup version of `noncomm_pi_coprod_mrange`\n@[to_additive]\ntheorem noncommPiCoprod_range : (noncommPiCoprod \u03d5 hcomm).range = \u2a06 i : \u03b9, (\u03d5 i).range := by\n  classical\n    apply le_antisymm\n    \u00b7 rintro x \u27e8f, rfl\u27e9\n      refine' Subgroup.noncommProd_mem _ _ _\n      intro i hi\n      apply Subgroup.mem_sup\u209b_of_mem\n      \u00b7 use i\n      simp\n    \u00b7 refine' sup\u1d62_le _\n      rintro i x \u27e8y, rfl\u27e9\n      refine' \u27e8Pi.mulSingle i y, noncomm_pi_coprod_mul_single _ _ _\u27e9\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] {\u03b9 : Type.{u2}} [hfin : Fintype.{u2} \u03b9] {H : \u03b9 -> Type.{u3}} [_inst_2 : forall (i : \u03b9), Group.{u3} (H i)] (\u03d5 : forall (i : \u03b9), 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 : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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)))) (\u03d5 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)))) (\u03d5 j) y))}, (CompleteLattice.Independent.{succ u2, u1} \u03b9 (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) (fun (i : \u03b9) => MonoidHom.range.{u3, u1} (H i) (_inst_2 i) G _inst_1 (\u03d5 i))) -> (forall (i : \u03b9), 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)))) (\u03d5 i))) -> (Function.Injective.{max (succ u2) (succ u3), succ u1} (forall (i : \u03b9), (fun (i : \u03b9) => 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 : \u03b9), (fun (i : \u03b9) => H i) i) G (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => H i) i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} ((fun (i : \u03b9) => H i) i) ((fun (i : \u03b9) => 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 : \u03b9), (fun (i : \u03b9) => H i) i) G (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => H i) i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} ((fun (i : \u03b9) => H i) i) ((fun (i : \u03b9) => 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 : \u03b9), (fun (i : \u03b9) => H i) i) -> G) (MonoidHom.hasCoeToFun.{max u2 u3, u1} (forall (i : \u03b9), (fun (i : \u03b9) => H i) i) G (Pi.mulOneClass.{u2, u3} \u03b9 (fun (i : \u03b9) => (fun (i : \u03b9) => H i) i) (fun (i : \u03b9) => Monoid.toMulOneClass.{u3} ((fun (i : \u03b9) => H i) i) ((fun (i : \u03b9) => 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)) \u03b9 hfin (fun (i : \u03b9) => H i) (fun (i : \u03b9) => DivInvMonoid.toMonoid.{u3} (H i) (Group.toDivInvMonoid.{u3} (H i) (_inst_2 i))) \u03d5 hcomm)))\nbut is expected to have type\n  forall {G : Type.{u2}} [_inst_1 : Group.{u2} G] {\u03b9 : Type.{u3}} [hfin : Fintype.{u3} \u03b9] {H : \u03b9 -> Type.{u1}} [_inst_2 : forall (i : \u03b9), Group.{u1} (H i)] (\u03d5 : forall (i : \u03b9), 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 : \u03b9) (j : \u03b9), (Ne.{succ u3} \u03b9 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)))))) (\u03d5 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)))))) (\u03d5 j) y))}, (CompleteLattice.Independent.{succ u3, u2} \u03b9 (Subgroup.{u2} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u2} G _inst_1) (fun (i : \u03b9) => MonoidHom.range.{u1, u2} (H i) (_inst_2 i) G _inst_1 (\u03d5 i))) -> (forall (i : \u03b9), 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)))))) (\u03d5 i))) -> (Function.Injective.{max (succ u3) (succ u1), succ u2} (forall (i : \u03b9), 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 : \u03b9), H i) G (Pi.mulOneClass.{u3, u1} \u03b9 (fun (i : \u03b9) => H i) (fun (i : \u03b9) => 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 : \u03b9), H i) (fun (_x : forall (i : \u03b9), H i) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : forall (i : \u03b9), H i) => G) _x) (MulHomClass.toFunLike.{max (max u2 u3) u1, max u3 u1, u2} (MonoidHom.{max u3 u1, u2} (forall (i : \u03b9), H i) G (Pi.mulOneClass.{u3, u1} \u03b9 (fun (i : \u03b9) => H i) (fun (i : \u03b9) => 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 : \u03b9), H i) G (MulOneClass.toMul.{max u3 u1} (forall (i : \u03b9), H i) (Pi.mulOneClass.{u3, u1} \u03b9 (fun (i : \u03b9) => H i) (fun (i : \u03b9) => 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 : \u03b9), H i) G (Pi.mulOneClass.{u3, u1} \u03b9 (fun (i : \u03b9) => H i) (fun (i : \u03b9) => 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 : \u03b9), H i) G (Pi.mulOneClass.{u3, u1} \u03b9 (fun (i : \u03b9) => H i) (fun (i : \u03b9) => 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 : \u03b9), H i) G (Pi.mulOneClass.{u3, u1} \u03b9 (fun (i : \u03b9) => H i) (fun (i : \u03b9) => 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)) \u03b9 hfin (fun (i : \u03b9) => H i) (fun (i : \u03b9) => DivInvMonoid.toMonoid.{u1} (H i) (Group.toDivInvMonoid.{u1} (H i) (_inst_2 i))) \u03d5 hcomm)))\nCase conversion may be inaccurate. Consider using '#align monoid_hom.injective_noncomm_pi_coprod_of_independent MonoidHom.injective_noncommPiCoprod_of_independent\u2093'. -/\n@[to_additive]\ntheorem injective_noncommPiCoprod_of_independent\n    (hind : CompleteLattice.Independent fun i => (\u03d5 i).range)\n    (hinj : \u2200 i, Function.Injective (\u03d5 i)) : Function.Injective (noncommPiCoprod \u03d5 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 => \u03d5 i (f i)) _ = 1 at heq1\n    change f = 1\n    have : \u2200 i, i \u2208 Finset.univ \u2192 \u03d5 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] {\u03b9 : Type.{u2}} {H : \u03b9 -> Type.{u3}} [_inst_2 : forall (i : \u03b9), Group.{u3} (H i)] (\u03d5 : forall (i : \u03b9), 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 : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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)))) (\u03d5 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)))) (\u03d5 j) y))) -> (forall [_inst_3 : Finite.{succ u2} \u03b9] [_inst_4 : forall (i : \u03b9), Fintype.{u3} (H i)], (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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} \u03b9 (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) (fun (i : \u03b9) => MonoidHom.range.{u3, u1} (H i) (_inst_2 i) G _inst_1 (\u03d5 i))))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {\u03b9 : Type.{u3}} [H : DecidableEq.{succ u3} \u03b9] {_inst_2 : \u03b9 -> Type.{u2}} [\u03d5 : forall (i : \u03b9), Group.{u2} (_inst_2 i)] (hcomm : forall (i : \u03b9), 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) (\u03d5 i)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))), (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u3} \u03b9 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 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) (\u03d5 j)))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))))) (hcomm j) y))) -> (forall [_inst_4 : Finite.{succ u3} \u03b9] [hcoprime : forall (i : \u03b9), Fintype.{u2} (_inst_2 i)], (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u3} \u03b9 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} \u03b9 (Subgroup.{u1} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u1} G _inst_1) (fun (i : \u03b9) => MonoidHom.range.{u2, u1} (_inst_2 i) (\u03d5 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\u2093'. -/\n@[to_additive]\ntheorem independent_range_of_coprime_order [Finite \u03b9] [\u2200 i, Fintype (H i)]\n    (hcoprime : \u2200 i j, i \u2260 j \u2192 Nat.coprime (Fintype.card (H i)) (Fintype.card (H j))) :\n    CompleteLattice.Independent fun i => (\u03d5 i).range :=\n  by\n  cases nonempty_fintype \u03b9\n  classical\n    rintro i\n    rw [disjoint_iff_inf_le]\n    rintro f \u27e8hxi, hxp\u27e9\n    dsimp at hxi hxp\n    rw [sup\u1d62_subtype', \u2190 noncomm_pi_coprod_range] at hxp\n    rotate_left\n    \u00b7 intro _ _ hj\n      apply hcomm\n      exact hj \u2218 Subtype.ext\n    cases' hxp with g hgf\n    cases' hxi with g' hg'f\n    have hxi : orderOf f \u2223 Fintype.card (H i) :=\n      by\n      rw [\u2190 hg'f]\n      exact (orderOf_map_dvd _ _).trans orderOf_dvd_card_univ\n    have hxp : orderOf f \u2223 \u220f j : { j // j \u2260 i }, Fintype.card (H j) :=\n      by\n      rw [\u2190 hgf, \u2190 Fintype.card_pi]\n      exact (orderOf_map_dvd _ _).trans orderOf_dvd_card_univ\n    change f = 1\n    rw [\u2190 pow_one f, \u2190 orderOf_dvd_iff_pow_eq_one]\n    convert\u2190 Nat.dvd_gcd hxp hxi\n    rw [\u2190 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 {\u03b9 : Type _} [hdec : DecidableEq \u03b9] [hfin : Fintype \u03b9] {H : \u03b9 \u2192 Subgroup G}\n\n-- Elements of `\u03a0 (i : \u03b9), H i` are called `f` and `g` here\nvariable (f g : \u2200 i : \u03b9, H i)\n\nsection CommutingSubgroups\n\n-- We assume that the elements of different subgroups commute\nvariable (hcomm : \u2200 i j : \u03b9, i \u2260 j \u2192 \u2200 x y : G, x \u2208 H i \u2192 y \u2208 H j \u2192 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] {\u03b9 : Type.{u2}} {H : \u03b9 -> (Subgroup.{u1} G _inst_1)}, (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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 : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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] {\u03b9 : Type.{u2}} {H : \u03b9 -> (Subgroup.{u1} G _inst_1)}, (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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 : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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\u2093'. -/\n@[to_additive]\ntheorem commute_subtype_of_commute (i j : \u03b9) (hne : i \u2260 j) :\n    \u2200 (x : H i) (y : H j), Commute ((H i).Subtype x) ((H j).Subtype y) :=\n  by\n  rintro \u27e8x, hx\u27e9 \u27e8y, hy\u27e9\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] {\u03b9 : Type.{u2}} [hfin : Fintype.{u2} \u03b9] {H : \u03b9 -> (Subgroup.{u1} G _inst_1)}, (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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] {\u03b9 : Type.{u2}} [hfin : Fintype.{u2} \u03b9] {H : \u03b9 -> (Subgroup.{u1} G _inst_1)}, (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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\u2093'. -/\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 : (\u2200 i : \u03b9, H i) \u2192* 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] {\u03b9 : Type.{u2}} [hdec : DecidableEq.{succ u2} \u03b9] [hfin : Fintype.{u2} \u03b9] {H : \u03b9 -> (Subgroup.{u1} G _inst_1)} {hcomm : forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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 : \u03b9) (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 : \u03b9), 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 : \u03b9) => H i) i)) G (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => H i) i)) (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : \u03b9) => 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 : \u03b9), 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 : \u03b9) => H i) i)) G (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => H i) i)) (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : \u03b9) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (forall (i : \u03b9), 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 : \u03b9) => H i) i)) -> G) (MonoidHom.hasCoeToFun.{max u2 u1, u1} (forall (i : \u03b9), 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 : \u03b9) => H i) i)) G (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => H i) i)) (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : \u03b9) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subgroup.noncommPiCoprod.{u1, u2} G _inst_1 \u03b9 hfin (fun (i : \u03b9) => H i) hcomm) (Pi.mulSingle.{u2, u1} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => H i) i)) (fun (a : \u03b9) (b : \u03b9) => hdec a b) (fun (i : \u03b9) => Subgroup.one.{u1} G _inst_1 ((fun (i : \u03b9) => 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\u2093.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] {\u03b9 : Type.{u1}} [hdec : DecidableEq.{succ u1} \u03b9] [hfin : Fintype.{u1} \u03b9] {H : \u03b9 -> (Subgroup.{u2} G _inst_1)} {hcomm : forall (i : \u03b9) (j : \u03b9), (Ne.{succ u1} \u03b9 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 : \u03b9) (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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) (b : \u03b9) => hdec a b) (fun (i : \u03b9) => 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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 : \u03b9), 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 : \u03b9), 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 \u03b9 hfin (fun (i : \u03b9) => H i) hcomm) (Pi.mulSingle.{u1, u2} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) (b : \u03b9) => hdec a b) (fun (i : \u03b9) => 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\u2093'. -/\n@[simp, to_additive]\ntheorem noncommPiCoprod_mulSingle (i : \u03b9) (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] {\u03b9 : Type.{u2}} [hfin : Fintype.{u2} \u03b9] {H : \u03b9 -> (Subgroup.{u1} G _inst_1)} {hcomm : forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => Subgroup.toGroup.{u1} G _inst_1 (H i))) G _inst_1 (Subgroup.noncommPiCoprod.{u1, u2} G _inst_1 \u03b9 hfin (fun (i : \u03b9) => H i) hcomm)) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => H i))\nbut is expected to have type\n  forall {G : Type.{u2}} [_inst_1 : Group.{u2} G] {\u03b9 : Type.{u1}} [hfin : DecidableEq.{succ u1} \u03b9] [H : Fintype.{u1} \u03b9] {hcomm : \u03b9 -> (Subgroup.{u2} G _inst_1)} {hcomm_1 : forall (i : \u03b9) (j : \u03b9), (Ne.{succ u1} \u03b9 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => Subgroup.toGroup.{u2} G _inst_1 (hcomm i))) G _inst_1 (Subgroup.noncommPiCoprod.{u2, u1} G _inst_1 \u03b9 H (fun (i : \u03b9) => hcomm i) hcomm_1)) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => hcomm i))\nCase conversion may be inaccurate. Consider using '#align subgroup.noncomm_pi_coprod_range Subgroup.noncommPiCoprod_range\u2093'. -/\n@[to_additive]\ntheorem noncommPiCoprod_range : (noncommPiCoprod hcomm).range = \u2a06 i : \u03b9, 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] {\u03b9 : Type.{u2}} [hfin : Fintype.{u2} \u03b9] {H : \u03b9 -> (Subgroup.{u1} G _inst_1)} {hcomm : forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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} \u03b9 (Subgroup.{u1} G _inst_1) (Subgroup.completeLattice.{u1} G _inst_1) H) -> (Function.Injective.{max (succ u2) (succ u1), succ u1} (forall (i : \u03b9), 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 : \u03b9) => 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 : \u03b9), 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 : \u03b9) => H i) i)) G (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => H i) i)) (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : \u03b9) => 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 : \u03b9), 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 : \u03b9) => H i) i)) G (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => H i) i)) (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : \u03b9) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) => (forall (i : \u03b9), 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 : \u03b9) => H i) i)) -> G) (MonoidHom.hasCoeToFun.{max u2 u1, u1} (forall (i : \u03b9), 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 : \u03b9) => H i) i)) G (Pi.mulOneClass.{u2, u1} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => H i) i)) (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => 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 : \u03b9) => H i) i)) (Subgroup.toGroup.{u1} G _inst_1 ((fun (i : \u03b9) => H i) i)))))) (Monoid.toMulOneClass.{u1} G (DivInvMonoid.toMonoid.{u1} G (Group.toDivInvMonoid.{u1} G _inst_1)))) (Subgroup.noncommPiCoprod.{u1, u2} G _inst_1 \u03b9 hfin (fun (i : \u03b9) => H i) hcomm)))\nbut is expected to have type\n  forall {G : Type.{u1}} [_inst_1 : Group.{u1} G] {\u03b9 : Type.{u2}} [hfin : Fintype.{u2} \u03b9] {H : \u03b9 -> (Subgroup.{u1} G _inst_1)} {hcomm : forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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} \u03b9 (Subgroup.{u1} G _inst_1) (Subgroup.instCompleteLatticeSubgroup.{u1} G _inst_1) H) -> (Function.Injective.{max (succ u1) (succ u2), succ u1} (forall (i : \u03b9), 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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 : \u03b9), 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 : \u03b9), 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 : \u03b9), 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} \u03b9 (fun (i : \u03b9) => 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 : \u03b9) => 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 \u03b9 hfin (fun (i : \u03b9) => H i) hcomm)))\nCase conversion may be inaccurate. Consider using '#align subgroup.injective_noncomm_pi_coprod_of_independent Subgroup.injective_noncommPiCoprod_of_independent\u2093'. -/\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  \u00b7 simpa using hind\n  \u00b7 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] {\u03b9 : Type.{u2}} {H : \u03b9 -> (Subgroup.{u1} G _inst_1)}, (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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} \u03b9] [_inst_3 : forall (i : \u03b9), 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 : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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} \u03b9 (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] {\u03b9 : Type.{u2}} [H : DecidableEq.{succ u2} \u03b9] {hcomm : \u03b9 -> (Subgroup.{u1} G _inst_1)}, (forall (i : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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} \u03b9] [hcoprime : forall (i : \u03b9), 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 : \u03b9) (j : \u03b9), (Ne.{succ u2} \u03b9 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} \u03b9 (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\u2093'. -/\n@[to_additive]\ntheorem independent_of_coprime_order [Finite \u03b9] [\u2200 i, Fintype (H i)]\n    (hcoprime : \u2200 i j, i \u2260 j \u2192 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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n\nlemma coe_def : (coe : \u03b1 \u2192 option \u03b1) = some := rfl\n\nlemma some_ne_none (x : \u03b1) : some x \u2260 none := \u03bb h, option.no_confusion h\n\nprotected lemma \u00abforall\u00bb {p : option \u03b1 \u2192 Prop} : (\u2200 x, p x) \u2194 p none \u2227 \u2200 x, p (some x) :=\n\u27e8\u03bb h, \u27e8h _, \u03bb x, h _\u27e9, \u03bb h x, option.cases_on x h.1 h.2\u27e9\n\nprotected lemma \u00abexists\u00bb {p : option \u03b1 \u2192 Prop} : (\u2203 x, p x) \u2194 p none \u2228 \u2203 x, p (some x) :=\n\u27e8\u03bb \u27e8x, hx\u27e9, (option.cases_on x or.inl $ \u03bb x hx, or.inr \u27e8x, hx\u27e9) hx,\n  \u03bb h, h.elim (\u03bb h, \u27e8_, h\u27e9) (\u03bb \u27e8x, hx\u27e9, \u27e8_, hx\u27e9)\u27e9\n\n@[simp] theorem get_mem : \u2200 {o : option \u03b1} (h : is_some o), option.get h \u2208 o\n| (some a) _ := rfl\n\ntheorem get_of_mem {a : \u03b1} : \u2200 {o : option \u03b1} (h : is_some o), a \u2208 o \u2192 option.get h = a\n| _ _ rfl := rfl\n\n@[simp] lemma not_mem_none (a : \u03b1) : a \u2209 (none : option \u03b1) :=\n\u03bb h, option.no_confusion h\n\n@[simp] lemma some_get : \u2200 {x : option \u03b1} (h : is_some x), some (option.get h) = x\n| (some x) hx := rfl\n\n@[simp] lemma get_some (x : \u03b1) (h : is_some (some x)) : option.get h = x := rfl\n\n@[simp] lemma get_or_else_some (x y : \u03b1) : option.get_or_else (some x) y = x := rfl\n\n@[simp] lemma get_or_else_coe (x y : \u03b1) : option.get_or_else \u2191x y = x := rfl\n\nlemma get_or_else_of_ne_none {x : option \u03b1} (hx : x \u2260 none) (y : \u03b1) : some (x.get_or_else y) = x :=\nby cases x; [contradiction, rw get_or_else_some]\n\ntheorem mem_unique {o : option \u03b1} {a b : \u03b1} (ha : a \u2208 o) (hb : b \u2208 o) : a = b :=\noption.some.inj $ ha.symm.trans hb\n\ntheorem mem.left_unique : relator.left_unique ((\u2208) : \u03b1 \u2192 option \u03b1 \u2192 Prop) :=\n\u27e8\u03bb a o b, mem_unique\u27e9\n\ntheorem some_injective (\u03b1 : Type*) : function.injective (@some \u03b1) :=\n\u03bb _ _, some_inj.mp\n\n/-- `option.map f` is injective if `f` is injective. -/\ntheorem map_injective {f : \u03b1 \u2192 \u03b2} (Hf : function.injective f) : function.injective (option.map f)\n| none      none      H := rfl\n| (some a\u2081) (some a\u2082) H := by rw Hf (option.some.inj H)\n\n@[ext] theorem ext : \u2200 {o\u2081 o\u2082 : option \u03b1}, (\u2200 a, a \u2208 o\u2081 \u2194 a \u2208 o\u2082) \u2192 o\u2081 = o\u2082\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 \u03b1} :\n  o = none \u2194 (\u2200 a, a \u2209 o) :=\n\u27e8\u03bb e a h, by rw e at h; cases h, \u03bb h, ext $ by simpa\u27e9\n\n@[simp] theorem none_bind {\u03b1 \u03b2} (f : \u03b1 \u2192 option \u03b2) : none >>= f = none := rfl\n\n@[simp] theorem some_bind {\u03b1 \u03b2} (a : \u03b1) (f : \u03b1 \u2192 option \u03b2) : some a >>= f = f a := rfl\n\n@[simp] theorem none_bind' (f : \u03b1 \u2192 option \u03b2) : none.bind f = none := rfl\n\n@[simp] theorem some_bind' (a : \u03b1) (f : \u03b1 \u2192 option \u03b2) : (some a).bind f = f a := rfl\n\n@[simp] theorem bind_some : \u2200 x : option \u03b1, x >>= some = x :=\n@bind_pure \u03b1 option _ _\n\n@[simp] theorem bind_eq_some {\u03b1 \u03b2} {x : option \u03b1} {f : \u03b1 \u2192 option \u03b2} {b : \u03b2} :\n  x >>= f = some b \u2194 \u2203 a, x = some a \u2227 f a = some b :=\nby cases x; simp\n\n@[simp] theorem bind_eq_some' {x : option \u03b1} {f : \u03b1 \u2192 option \u03b2} {b : \u03b2} :\n  x.bind f = some b \u2194 \u2203 a, x = some a \u2227 f a = some b :=\nby cases x; simp\n\n@[simp] theorem bind_eq_none' {o : option \u03b1} {f : \u03b1 \u2192 option \u03b2} :\n  o.bind f = none \u2194 (\u2200 b a, a \u2208 o \u2192 b \u2209 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 {\u03b1 \u03b2} {o : option \u03b1} {f : \u03b1 \u2192 option \u03b2} :\n  o >>= f = none \u2194 (\u2200 b a, a \u2208 o \u2192 b \u2209 f a) :=\nbind_eq_none'\n\nlemma bind_comm {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b2 \u2192 option \u03b3} (a : option \u03b1) (b : option \u03b2) :\n  a.bind (\u03bbx, b.bind (f x)) = b.bind (\u03bby, a.bind (\u03bbx, f x y)) :=\nby cases a; cases b; refl\n\nlemma bind_assoc (x : option \u03b1) (f : \u03b1 \u2192 option \u03b2) (g : \u03b2 \u2192 option \u03b3) :\n  (x.bind f).bind g = x.bind (\u03bb y, (f y).bind g) := by cases x; refl\n\nlemma join_eq_some {x : option (option \u03b1)} {a : \u03b1} : x.join = some a \u2194 x = some (some a) := by simp\n\nlemma join_ne_none {x : option (option \u03b1)} : x.join \u2260 none \u2194 \u2203 z, x = some (some z) := by simp\n\nlemma join_ne_none' {x : option (option \u03b1)} : \u00ac(x.join = none) \u2194 \u2203 z, x = some (some z) := by simp\n\nlemma join_eq_none {o : option (option \u03b1)} : o.join = none \u2194 o = none \u2228 o = some none :=\nby rcases o with _|_|_; simp\n\nlemma bind_id_eq_join {x : option (option \u03b1)} : x >>= id = x.join := by simp\n\nlemma join_eq_join : mjoin = @join \u03b1 :=\nfunext (\u03bb x, by rw [mjoin, bind_id_eq_join])\n\nlemma bind_eq_bind {\u03b1 \u03b2 : Type*} {f : \u03b1 \u2192 option \u03b2} {x : option \u03b1} :\n  x >>= f = x.bind f := rfl\n\n@[simp] lemma map_eq_map {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} :\n  (<$>) f = option.map f := rfl\n\ntheorem map_none {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} : f <$> none = none := rfl\n\ntheorem map_some {\u03b1 \u03b2} {a : \u03b1} {f : \u03b1 \u2192 \u03b2} : f <$> some a = some (f a) := rfl\n\n@[simp] theorem map_none' {f : \u03b1 \u2192 \u03b2} : option.map f none = none := rfl\n\n@[simp] theorem map_some' {a : \u03b1} {f : \u03b1 \u2192 \u03b2} : option.map f (some a) = some (f a) := rfl\n\ntheorem map_eq_some {\u03b1 \u03b2} {x : option \u03b1} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} :\n  f <$> x = some b \u2194 \u2203 a, x = some a \u2227 f a = b :=\nby cases x; simp\n\n@[simp] theorem map_eq_some' {x : option \u03b1} {f : \u03b1 \u2192 \u03b2} {b : \u03b2} :\n  x.map f = some b \u2194 \u2203 a, x = some a \u2227 f a = b :=\nby cases x; simp\n\nlemma map_eq_none {\u03b1 \u03b2} {x : option \u03b1} {f : \u03b1 \u2192 \u03b2} :\n  f <$> x = none \u2194 x = none :=\nby { cases x; simp only [map_none, map_some, eq_self_iff_true] }\n\n@[simp] lemma map_eq_none' {x : option \u03b1} {f : \u03b1 \u2192 \u03b2} :\n  x.map f = none \u2194 x = none :=\nby { cases x; simp only [map_none', map_some', eq_self_iff_true] }\n\nlemma map_congr {f g : \u03b1 \u2192 \u03b2} {x : option \u03b1} (h : \u2200 a \u2208 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 \u03b1) = id := map_id\n\n@[simp] lemma map_map (h : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) (x : option \u03b1) :\n  option.map h (option.map g x) = option.map (h \u2218 g) x :=\nby { cases x; simp only [map_none', map_some'] }\n\nlemma comp_map (h : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) (x : option \u03b1) :\n  option.map (h \u2218 g) x = option.map h (option.map g x) := (map_map _ _ _).symm\n\n@[simp] lemma map_comp_map (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) :\n  option.map g \u2218 option.map f = option.map (g \u2218 f) :=\nby { ext x, rw comp_map }\n\nlemma mem_map_of_mem {\u03b1 \u03b2 : Type*} {a : \u03b1} {x : option \u03b1} (g : \u03b1 \u2192 \u03b2) (h : a \u2208 x) : g a \u2208 x.map g :=\nmem_def.mpr ((mem_def.mp h).symm \u25b8 map_some')\n\nlemma bind_map_comm {\u03b1 \u03b2} {x : option (option \u03b1) } {f : \u03b1 \u2192 \u03b2} :\n  x >>= option.map f = x.map (option.map f) >>= id :=\nby { cases x; simp }\n\nlemma join_map_eq_map_join {f : \u03b1 \u2192 \u03b2} {x : option (option \u03b1)} :\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 \u03b1))} :\n  x.join.join = (x.map join).join :=\nby { rcases x with _ | _ | _ | x; simp }\n\nlemma mem_of_mem_join {a : \u03b1} {x : option (option \u03b1)} (h : a \u2208 x.join) : some a \u2208 x :=\nmem_def.mpr ((mem_def.mp h).symm \u25b8 join_eq_some.mp h)\n\nsection pmap\n\nvariables {p : \u03b1 \u2192 Prop} (f : \u03a0 (a : \u03b1), p a \u2192 \u03b2) (x : option \u03b1)\n\n@[simp] lemma pbind_eq_bind (f : \u03b1 \u2192 option \u03b2) (x : option \u03b1) :\n  x.pbind (\u03bb a _, f a) = x.bind f :=\nby { cases x; simp only [pbind, none_bind', some_bind'] }\n\nlemma map_bind {\u03b1 \u03b2 \u03b3} (f : \u03b2 \u2192 \u03b3) (x : option \u03b1) (g : \u03b1 \u2192 option \u03b2) :\n  option.map f (x >>= g) = (x >>= \u03bb a, option.map f (g a)) :=\nby simp_rw [\u2190map_eq_map, \u2190bind_pure_comp_eq_map,is_lawful_monad.bind_assoc]\n\nlemma map_bind' (f : \u03b2 \u2192 \u03b3) (x : option \u03b1) (g : \u03b1 \u2192 option \u03b2) :\n  option.map f (x.bind g) = x.bind (\u03bb a, option.map f (g a)) :=\nby { cases x; simp }\n\nlemma map_pbind (f : \u03b2 \u2192 \u03b3) (x : option \u03b1) (g : \u03a0 a, a \u2208 x \u2192 option \u03b2) :\n  option.map f (x.pbind g) = (x.pbind (\u03bb a H, option.map f (g a H))) :=\nby { cases x; simp only [pbind, map_none'] }\n\nlemma pbind_map (f : \u03b1 \u2192 \u03b2) (x : option \u03b1) (g : \u03a0 (b : \u03b2), b \u2208 x.map f \u2192 option \u03b3) :\n  pbind (option.map f x) g = x.pbind (\u03bb a h, g (f a) (mem_map_of_mem _ h)) :=\nby { cases x; refl }\n\n@[simp] lemma pmap_none (f : \u03a0 (a : \u03b1), p a \u2192 \u03b2) {H} : pmap f (@none \u03b1) H = none := rfl\n\n@[simp] lemma pmap_some (f : \u03a0 (a : \u03b1), p a \u2192 \u03b2) {x : \u03b1} (h : p x) :\n  pmap f (some x) = \u03bb _, some (f x h) := rfl\n\nlemma mem_pmem {a : \u03b1} (h : \u2200 a \u2208 x, p a) (ha : a \u2208 x) :\n  f a (h a ha) \u2208 pmap f x h :=\nby { rw mem_def at ha \u22a2, subst ha, refl }\n\nlemma pmap_map (g : \u03b3 \u2192 \u03b1) (x : option \u03b3) (H) :\n  pmap f (x.map g) H = pmap (\u03bb a h, f (g a) h) x (\u03bb a h, H _ (mem_map_of_mem _ h)) :=\nby { cases x; simp only [map_none', map_some', pmap] }\n\nlemma map_pmap (g : \u03b2 \u2192 \u03b3) (f : \u03a0 a, p a \u2192 \u03b2) (x H) :\n  option.map g (pmap f x H) = pmap (\u03bb 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 : \u03b1 \u2192 Prop) (f : \u03b1 \u2192 \u03b2) (x H) :\n  @pmap _ _ p (\u03bb 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 {\u03b1 \u03b2 \u03b3} {p : \u03b1 \u2192 Prop} (f : \u03a0 a, p a \u2192 \u03b2) (x : option \u03b1) (g : \u03b2 \u2192 option \u03b3) (H) :\n  (pmap f x H) >>= g = x.pbind (\u03bb 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 : \u03a0 (a : \u03b1), a \u2208 x \u2192 option \u03b2}\n  (h' : \u2200 a \u2208 x, f a H = none \u2192 x = none) :\n  x.pbind f = none \u2194 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 : \u03a0 (a : \u03b1), a \u2208 x \u2192 option \u03b2} {y : \u03b2} :\n  x.pbind f = some y \u2194 \u2203 (z \u2208 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 \u27e8z, H, hz\u27e9,\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 \u2194 x = none :=\nby { cases x; simp }\n\n@[simp] lemma pmap_eq_some_iff {hf} {y : \u03b2} :\n  pmap f x hf = some y \u2194 \u2203 (a : \u03b1) (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 \u27e8x, rfl, h\u27e9 },\n    { rintro \u27e8a, H, rfl\u27e9,\n      simp only [mem_def] at H,\n      simp only [H, pmap] } }\nend\n\n@[simp] lemma join_pmap_eq_pmap_join {f : \u03a0 a, p a \u2192 \u03b2} {x : option (option \u03b1)} (H) :\n  (pmap (pmap f) x H).join = pmap f x.join (\u03bb 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 {\u03b1 \u03b2} {a : \u03b1} {f : \u03b1 \u2192 \u03b2} : some f <*> some a = some (f a) := rfl\n\n@[simp] theorem some_orelse' (a : \u03b1) (x : option \u03b1) : (some a).orelse x = some a := rfl\n\n@[simp] theorem some_orelse (a : \u03b1) (x : option \u03b1) : (some a <|> x) = some a := rfl\n\n@[simp] theorem none_orelse' (x : option \u03b1) : none.orelse x = x :=\nby cases x; refl\n\n@[simp] theorem none_orelse (x : option \u03b1) : (none <|> x) = x := none_orelse' x\n\n@[simp] theorem orelse_none' (x : option \u03b1) : x.orelse none = x :=\nby cases x; refl\n\n@[simp] theorem orelse_none (x : option \u03b1) : (x <|> none) = x := orelse_none' x\n\n@[simp] theorem is_some_none : @is_some \u03b1 none = ff := rfl\n\n@[simp] theorem is_some_some {a : \u03b1} : is_some (some a) = tt := rfl\n\ntheorem is_some_iff_exists {x : option \u03b1} : is_some x \u2194 \u2203 a, x = some a :=\nby cases x; simp [is_some]; exact \u27e8_, rfl\u27e9\n\n@[simp] theorem is_none_none : @is_none \u03b1 none = tt := rfl\n\n@[simp] theorem is_none_some {a : \u03b1} : is_none (some a) = ff := rfl\n\n@[simp] theorem not_is_some {a : option \u03b1} : is_some a = ff \u2194 a.is_none = tt :=\nby cases a; simp\n\nlemma eq_some_iff_get_eq {o : option \u03b1} {a : \u03b1} :\n  o = some a \u2194 \u2203 h : o.is_some, option.get h = a :=\nby cases o; simp\n\nlemma not_is_some_iff_eq_none {o : option \u03b1} :  \u00aco.is_some \u2194 o = none :=\nby cases o; simp\n\nlemma ne_none_iff_is_some {o : option \u03b1} : o \u2260 none \u2194 o.is_some :=\nby cases o; simp\n\nlemma ne_none_iff_exists {o : option \u03b1} : o \u2260 none \u2194 \u2203 (x : \u03b1), some x = o :=\nby {cases o; simp}\n\nlemma ne_none_iff_exists' {o : option \u03b1} : o \u2260 none \u2194 \u2203 (x : \u03b1), o = some x :=\nne_none_iff_exists.trans $ exists_congr $ \u03bb _, eq_comm\n\nlemma bex_ne_none {p : option \u03b1 \u2192 Prop} :\n  (\u2203 x \u2260 none, p x) \u2194 \u2203 x, p (some x) :=\n\u27e8\u03bb \u27e8x, hx, hp\u27e9, \u27e8get $ ne_none_iff_is_some.1 hx, by rwa [some_get]\u27e9,\n  \u03bb \u27e8x, hx\u27e9, \u27e8some x, some_ne_none x, hx\u27e9\u27e9\n\nlemma ball_ne_none {p : option \u03b1 \u2192 Prop} :\n  (\u2200 x \u2260 none, p x) \u2194 \u2200 x, p (some x) :=\n\u27e8\u03bb h x, h (some x) (some_ne_none x),\n  \u03bb h x hx, by simpa only [some_get] using h (get $ ne_none_iff_is_some.1 hx)\u27e9\n\ntheorem iget_mem [inhabited \u03b1] : \u2200 {o : option \u03b1}, is_some o \u2192 o.iget \u2208 o\n| (some a) _ := rfl\n\ntheorem iget_of_mem [inhabited \u03b1] {a : \u03b1} : \u2200 {o : option \u03b1}, a \u2208 o \u2192 o.iget = a\n| _ rfl := rfl\n\n@[simp] theorem guard_eq_some {p : \u03b1 \u2192 Prop} [decidable_pred p] {a b : \u03b1} :\n  guard p a = some b \u2194 a = b \u2227 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  \u2200 u, _root_.guard p = some u \u2194 p\n| () := by by_cases p; simp [guard, h, pure]; intro; contradiction\n\ntheorem lift_or_get_choice {f : \u03b1 \u2192 \u03b1 \u2192 \u03b1} (h : \u2200 a b, f a b = a \u2228 f a b = b) :\n  \u2200 o\u2081 o\u2082, lift_or_get f o\u2081 o\u2082 = o\u2081 \u2228 lift_or_get f o\u2081 o\u2082 = o\u2082\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 \u03b1} : lift_or_get f none b = b :=\nby cases b; refl\n\n@[simp] lemma lift_or_get_none_right {f} {a : option \u03b1} : lift_or_get f a none = a :=\nby cases a; refl\n\n@[simp] lemma lift_or_get_some_some {f} {a b : \u03b1} :\n  lift_or_get f (some a) (some b) = f a b := rfl\n\n/-- given an element of `a : option \u03b1`, a default element `b : \u03b2` and a function `\u03b1 \u2192 \u03b2`, apply this\nfunction to `a` if it comes from `\u03b1`, and return `b` otherwise. -/\ndef cases_on' : option \u03b1 \u2192 \u03b2 \u2192 (\u03b1 \u2192 \u03b2) \u2192 \u03b2\n| none     n s := n\n| (some a) n s := s a\n\n@[simp] lemma cases_on'_none (x : \u03b2) (f : \u03b1 \u2192 \u03b2) : cases_on' none x f = x := rfl\n\n@[simp] lemma cases_on'_some (x : \u03b2) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : cases_on' (some a) x f = f a := rfl\n\n@[simp] lemma cases_on'_coe (x : \u03b2) (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : cases_on' (a : option \u03b1) x f = f a := rfl\n\n@[simp] lemma cases_on'_none_coe (f : option \u03b1 \u2192 \u03b2) (o : option \u03b1) :\n  cases_on' o (f none) (f \u2218 coe) = f o :=\nby cases o; refl\n\nsection\nopen_locale classical\n\n/-- An arbitrary `some a` with `a : \u03b1` if `\u03b1` is nonempty, and otherwise `none`. -/\nnoncomputable def choice (\u03b1 : Type*) : option \u03b1 :=\nif h : nonempty \u03b1 then\n  some h.some\nelse\n  none\n\nlemma choice_eq {\u03b1 : Type*} [subsingleton \u03b1] (a : \u03b1) : choice \u03b1 = some a :=\nbegin\n  dsimp [choice],\n  rw dif_pos (\u27e8a\u27e9 : nonempty \u03b1),\n  congr,\nend\n\nlemma choice_eq_none {\u03b1 : Type*} (h : \u03b1 \u2192 false) : choice \u03b1 = none :=\nbegin\n  dsimp [choice],\n  rw dif_neg (not_nonempty_iff_imp_false.mpr h),\nend\n\nlemma choice_is_some_iff_nonempty {\u03b1 : Type*} : (choice \u03b1).is_some \u2194 nonempty \u03b1 :=\nbegin\n  fsplit,\n  { intro h, exact \u27e8option.get h\u27e9, },\n  { rintro \u27e8a\u27e9,\n    dsimp [choice],\n    rw dif_pos,\n    fsplit,\n    exact \u27e8a\u27e9, },\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 \u2192 Pos \u2192 Pos\n  | .succ x, .succ y => .succ (x + y).succ\n\ninstance : Add Pos := \u27e8Pos.add\u27e9\n\ninstance (x : Nat) : OfNat Pos x.succ := \u27e8.succ x\u27e9\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 \u27e8n\u27e9\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\u2081 = PosView.succ p\u2082) : sizeOf p\u2082 < sizeOf p\u2081 := by\n  match p\u2081, p\u2082 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 \u226b g = 0`\n\nWe define the map, as the lift of `image.\u03b9 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 \u226b 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 \u27f6 B) (g : B \u27f6 C)\n    (w : f \u226b g = 0) : limits.image f \u27f6 limits.kernel g :=\n  limits.kernel.lift g (limits.image.\u03b9 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 \u27f6 C) [limits.has_zero_object V] {w : 0 \u226b 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 \u27f6 B)\n    {w : f \u226b 0 = 0} : image_to_kernel_map f 0 w = limits.image.\u03b9 f \u226b inv (limits.kernel.\u03b9 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 \u27f6 B) (g : B \u27f6 C)\n    {D : V} (h : C \u27f6 D) (w : f \u226b g = 0) :\n    image_to_kernel_map f (g \u226b h)\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : A \u27f6 D) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 D) (e_2 : \u1fb0 = \u1fb0_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (f \u226b g \u226b 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 \u226b\n          limits.kernel.lift (g \u226b h) (limits.kernel.\u03b9 g)\n            (eq.mpr\n              (id\n                (Eq.trans\n                  ((fun (a a_1 : limits.kernel g \u27f6 D) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : limits.kernel g \u27f6 D)\n                      (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n                    (limits.kernel.\u03b9 g \u226b g \u226b 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 \u27f6 B) (g : B \u27f6 C)\n    {Z : V} (h : Z \u27f6 A) (w : f \u226b g = 0) :\n    image_to_kernel_map (h \u226b f) g\n          (eq.mpr\n            (id\n              (Eq.trans\n                ((fun (a a_1 : Z \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : Z \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  ((h \u226b f) \u226b g) 0\n                  (Eq.trans\n                    (Eq.trans (category.assoc h f g)\n                      ((fun (\u1fb0 \u1fb0_1 : Z \u27f6 A) (e_1 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : A \u27f6 C) (e_2 : \u1fb0_2 = \u1fb0_3) =>\n                          congr (congr_arg category_struct.comp e_1) e_2)\n                        h h (Eq.refl h) (f \u226b 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 \u226b 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 \u27f6 B) (g : B \u27f6 C)\n    {D : V} (h : C \u27f6 D) [is_iso h] (w : f \u226b g \u226b h = 0) :\n    image_to_kernel_map f (g \u226b 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 \u27f6 D) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 D) (e_2 : \u1fb0 = \u1fb0_1) =>\n                      congr (congr_arg Eq e_1) e_2)\n                    ((f \u226b g) \u226b h) (f \u226b g \u226b h) (category.assoc f g h) (0 \u226b h) 0 limits.zero_comp))\n                (eq.mp (Eq.refl (f \u226b g \u226b h = 0)) w))) \u226b\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 \u27f6 B) (g : B \u27f6 C)\n    {Z : V} (h : Z \u27f6 A) [is_iso h] (w : (h \u226b f) \u226b g = 0) :\n    image_to_kernel_map (h \u226b f) g w =\n        limits.image.pre_comp h f \u226b\n          image_to_kernel_map f g\n            (iff.mp (cancel_epi h)\n              (eq.mpr\n                (id\n                  ((fun (a a_1 : Z \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : Z \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) =>\n                      congr (congr_arg Eq e_1) e_2)\n                    (h \u226b f \u226b g) (h \u226b f \u226b g) (Eq.refl (h \u226b f \u226b g)) (h \u226b 0) 0 limits.comp_zero))\n                (eq.mp\n                  ((fun (a a_1 : Z \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : Z \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) =>\n                      congr (congr_arg Eq e_1) e_2)\n                    ((h \u226b f) \u226b g) (h \u226b f \u226b 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 \u27f6 B) (g : B \u27f6 C) {Z : V} {i : B \u2245 Z} (w : (f \u226b iso.hom i) \u226b iso.inv i \u226b g = 0) :\n    image_to_kernel_map (f \u226b iso.hom i) (iso.inv i \u226b g) w =\n        iso.inv (limits.image.post_comp_is_iso f (iso.hom i)) \u226b\n          image_to_kernel_map f g\n              (eq.mpr (id (Eq.refl (f \u226b g = 0)))\n                (eq.mp\n                  ((fun (a a_1 : A \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) =>\n                      congr (congr_arg Eq e_1) e_2)\n                    ((f \u226b iso.hom i) \u226b iso.inv i \u226b g) (f \u226b g)\n                    (Eq.trans (category.assoc f (iso.hom i) (iso.inv i \u226b g))\n                      ((fun (\u1fb0 \u1fb0_1 : A \u27f6 B) (e_1 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : B \u27f6 C) (e_2 : \u1fb0_2 = \u1fb0_3) =>\n                          congr (congr_arg category_struct.comp e_1) e_2)\n                        f f (Eq.refl f) (iso.hom i \u226b iso.inv i \u226b g) g (iso.hom_inv_id_assoc i g)))\n                    0 0 (Eq.refl 0))\n                  w)) \u226b\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 \u27f6 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 \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (0 \u226b 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 \u27f6 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 \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) =>\n                    congr (congr_arg Eq e_1) e_2)\n                  (f \u226b 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes H\u00f6lzl\n\nLinear structures on function with finite support `\u03b9 \u2192\u2080 \u03b2`.\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} {\u03b9 : Type u_3} [ring R]\n    [add_comm_group M] [module R M] {\u03c6 : \u03b9 \u2192 Type u_4} {f : (\u03b9 : \u03b9) \u2192 \u03c6 \u03b9 \u2192 M}\n    (hf : \u2200 (i : \u03b9), linear_independent R (f i)) :\n    linear_independent R\n        fun (ix : sigma fun (i : \u03b9) => \u03c6 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} {\u03b9 : Type u_3} [ring R] [add_comm_group M]\n    [module R M] {\u03c6 : \u03b9 \u2192 Type u_4} (f : (\u03b9 : \u03b9) \u2192 \u03c6 \u03b9 \u2192 M) (hf : \u2200 (i : \u03b9), is_basis R (f i)) :\n    is_basis R\n        fun (ix : sigma fun (i : \u03b9) => \u03c6 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} {\u03b9 : Type u_3} [ring R] :\n    is_basis R fun (i : \u03b9) => single i 1 :=\n  sorry\n\n/-- If b : \u03b9 \u2192 M and c : \u03ba \u2192 N are bases then so is \u03bb i, b i.1 \u2297\u209c c i.2 : \u03b9 \u00d7 \u03ba \u2192 M \u2297 N. -/\ntheorem is_basis.tensor_product {R : Type u_1} {M : Type u_2} {N : Type u_3} {\u03b9 : Type u_4}\n    {\u03ba : Type u_5} [comm_ring R] [add_comm_group M] [module R M] [add_comm_group N] [module R N]\n    {b : \u03b9 \u2192 M} (hb : is_basis R b) {c : \u03ba \u2192 N} (hc : is_basis R c) :\n    is_basis R fun (i : \u03b9 \u00d7 \u03ba) => tensor_product.tmul R (b (prod.fst i)) (c (prod.snd i)) :=\n  sorry\n\ntheorem dim_eq {K : Type u} {V : Type v} {\u03b9 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] : vector_space.dim K (\u03b9 \u2192\u2080 V) = cardinal.mk \u03b9 * 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\u2081 : Type v} {V\u2082 : Type v} [field K] [add_comm_group V\u2081]\n    [vector_space K V\u2081] [add_comm_group V\u2082] [vector_space K V\u2082]\n    (h : vector_space.dim K V\u2081 = vector_space.dim K V\u2082) : linear_equiv K V\u2081 V\u2082 :=\n  Classical.choice sorry\n\n/-- An `n`-dimensional `K`-vector space is equivalent to `fin n \u2192 K`. -/\ndef fin_dim_vectorspace_equiv {K : Type u} {V : Type v} [field K] [add_comm_group V]\n    [vector_space K V] (n : \u2115) (hn : vector_space.dim K V = \u2191n) : linear_equiv K V (fin n \u2192 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 \u21a5p = 0) : p = \u22a5 :=\n  let e : linear_equiv K \u21a5p \u21a5\u22a5 :=\n    equiv_of_dim_eq_dim\n      (eq.mpr (id (Eq._oldrec (Eq.refl (vector_space.dim K \u21a5p = vector_space.dim K \u21a5\u22a5)) dim_bot))\n        h);\n  linear_equiv.eq_bot_of_equiv p e\n\ntheorem injective_of_surjective {K : Type u} {V\u2081 : Type v} {V\u2082 : Type v} [field K]\n    [add_comm_group V\u2081] [vector_space K V\u2081] [add_comm_group V\u2082] [vector_space K V\u2082]\n    (f : linear_map K V\u2081 V\u2082) (hV\u2081 : vector_space.dim K V\u2081 < cardinal.omega)\n    (heq : vector_space.dim K V\u2082 = vector_space.dim K V\u2081) (hf : linear_map.range f = \u22a4) :\n    linear_map.ker f = \u22a5 :=\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 \u03b1` is classically a nonempty `set \u03b1`,\n  and in the VM is represented by an element of `\u03b1`; 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 (\u03b1 : Type u_1) where\n  mk' :: (s : set \u03b1) (val : trunc \u21a5s)\n\nnamespace semiquot\n\n\nprotected instance has_mem {\u03b1 : Type u_1} : has_mem \u03b1 (semiquot \u03b1) :=\n  has_mem.mk fun (a : \u03b1) (q : semiquot \u03b1) => a \u2208 s q\n\n/-- Construct a `semiquot \u03b1` from `h : a \u2208 s` where `s : set \u03b1`. -/\ndef mk {\u03b1 : Type u_1} {a : \u03b1} {s : set \u03b1} (h : a \u2208 s) : semiquot \u03b1 :=\n  mk' s (trunc.mk { val := a, property := h })\n\ntheorem ext_s {\u03b1 : Type u_1} {q\u2081 : semiquot \u03b1} {q\u2082 : semiquot \u03b1} : q\u2081 = q\u2082 \u2194 s q\u2081 = s q\u2082 := sorry\n\ntheorem ext {\u03b1 : Type u_1} {q\u2081 : semiquot \u03b1} {q\u2082 : semiquot \u03b1} :\n    q\u2081 = q\u2082 \u2194 \u2200 (a : \u03b1), a \u2208 q\u2081 \u2194 a \u2208 q\u2082 :=\n  iff.trans ext_s set.ext_iff\n\ntheorem exists_mem {\u03b1 : Type u_1} (q : semiquot \u03b1) : \u2203 (a : \u03b1), a \u2208 q := sorry\n\ntheorem eq_mk_of_mem {\u03b1 : Type u_1} {q : semiquot \u03b1} {a : \u03b1} (h : a \u2208 q) : q = mk h :=\n  iff.mpr ext_s rfl\n\ntheorem nonempty {\u03b1 : Type u_1} (q : semiquot \u03b1) : set.nonempty (s q) := exists_mem q\n\n/-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/\nprotected def pure {\u03b1 : Type u_1} (a : \u03b1) : semiquot \u03b1 := mk (set.mem_singleton a)\n\n@[simp] theorem mem_pure' {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : a \u2208 semiquot.pure b \u2194 a = b :=\n  set.mem_singleton_iff\n\n/-- Replace `s` in a `semiquot` with a superset. -/\ndef blur' {\u03b1 : Type u_1} (q : semiquot \u03b1) {s : set \u03b1} (h : s q \u2286 s) : semiquot \u03b1 :=\n  mk' s\n    (trunc.lift (fun (a : \u21a5(s q)) => trunc.mk { val := subtype.val a, property := sorry }) sorry\n      (val q))\n\n/-- Replace `s` in a `q : semiquot \u03b1` with a union `s \u222a q.s` -/\ndef blur {\u03b1 : Type u_1} (s : set \u03b1) (q : semiquot \u03b1) : semiquot \u03b1 := blur' q sorry\n\ntheorem blur_eq_blur' {\u03b1 : Type u_1} (q : semiquot \u03b1) (s : set \u03b1) (h : s q \u2286 s) :\n    blur s q = blur' q h :=\n  sorry\n\n@[simp] theorem mem_blur' {\u03b1 : Type u_1} (q : semiquot \u03b1) {s : set \u03b1} (h : s q \u2286 s) {a : \u03b1} :\n    a \u2208 blur' q h \u2194 a \u2208 s :=\n  iff.rfl\n\n/-- Convert a `trunc \u03b1` to a `semiquot \u03b1`. -/\ndef of_trunc {\u03b1 : Type u_1} (q : trunc \u03b1) : semiquot \u03b1 :=\n  mk' set.univ (trunc.map (fun (a : \u03b1) => { val := a, property := trivial }) q)\n\n/-- Convert a `semiquot \u03b1` to a `trunc \u03b1`. -/\ndef to_trunc {\u03b1 : Type u_1} (q : semiquot \u03b1) : trunc \u03b1 := 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (q : semiquot \u03b1) (f : \u03b1 \u2192 \u03b2)\n    (h : \u2200 (a b : \u03b1), a \u2208 q \u2192 b \u2208 q \u2192 f a = f b) : \u03b2 :=\n  trunc.lift_on (val q) (fun (x : \u21a5(s q)) => f (subtype.val x)) sorry\n\ntheorem lift_on_of_mem {\u03b1 : Type u_1} {\u03b2 : Type u_2} (q : semiquot \u03b1) (f : \u03b1 \u2192 \u03b2)\n    (h : \u2200 (a b : \u03b1), a \u2208 q \u2192 b \u2208 q \u2192 f a = f b) (a : \u03b1) (aq : a \u2208 q) : lift_on q f h = f a :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (\u2200 (h : \u2200 (a b : \u03b1), a \u2208 q \u2192 b \u2208 q \u2192 f a = f b), lift_on q f h = f a))\n        (eq_mk_of_mem aq)))\n    (fun (h : \u2200 (a_1 b : \u03b1), a_1 \u2208 mk aq \u2192 b \u2208 mk aq \u2192 f a_1 = f b) =>\n      Eq.refl (lift_on (mk aq) f h))\n    h\n\ndef map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (q : semiquot \u03b1) : semiquot \u03b2 :=\n  mk' (f '' s q)\n    (trunc.map (fun (x : \u21a5(s q)) => { val := f (subtype.val x), property := sorry }) (val q))\n\n@[simp] theorem mem_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (q : semiquot \u03b1) (b : \u03b2) :\n    b \u2208 map f q \u2194 \u2203 (a : \u03b1), a \u2208 q \u2227 f a = b :=\n  set.mem_image (fun (a : \u03b1) => f a) (s q) b\n\ndef bind {\u03b1 : Type u_1} {\u03b2 : Type u_2} (q : semiquot \u03b1) (f : \u03b1 \u2192 semiquot \u03b2) : semiquot \u03b2 :=\n  mk' (set.Union fun (a : \u03b1) => set.Union fun (H : a \u2208 s q) => s (f a))\n    (trunc.bind (val q)\n      fun (a : \u21a5(s q)) =>\n        trunc.map\n          (fun (b : \u21a5(s (f (subtype.val a)))) => { val := subtype.val b, property := sorry })\n          (val (f (subtype.val a))))\n\n@[simp] theorem mem_bind {\u03b1 : Type u_1} {\u03b2 : Type u_2} (q : semiquot \u03b1) (f : \u03b1 \u2192 semiquot \u03b2)\n    (b : \u03b2) : b \u2208 bind q f \u2194 \u2203 (a : \u03b1), \u2203 (H : a \u2208 q), b \u2208 f a :=\n  set.mem_bUnion_iff\n\nprotected instance monad : Monad semiquot :=\n  { toApplicative :=\n      { toFunctor := { map := map, mapConst := fun (\u03b1 \u03b2 : Type u_1) => map \u2218 function.const \u03b2 },\n        toPure := { pure := semiquot.pure },\n        toSeq :=\n          { seq :=\n              fun (\u03b1 \u03b2 : Type u_1) (f : semiquot (\u03b1 \u2192 \u03b2)) (x : semiquot \u03b1) =>\n                bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x },\n        toSeqLeft :=\n          { seqLeft :=\n              fun (\u03b1 \u03b2 : Type u_1) (a : semiquot \u03b1) (b : semiquot \u03b2) =>\n                (fun (\u03b1 \u03b2 : Type u_1) (f : semiquot (\u03b1 \u2192 \u03b2)) (x : semiquot \u03b1) =>\n                    bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x)\n                  \u03b2 \u03b1 (map (function.const \u03b2) a) b },\n        toSeqRight :=\n          { seqRight :=\n              fun (\u03b1 \u03b2 : Type u_1) (a : semiquot \u03b1) (b : semiquot \u03b2) =>\n                (fun (\u03b1 \u03b2 : Type u_1) (f : semiquot (\u03b1 \u2192 \u03b2)) (x : semiquot \u03b1) =>\n                    bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x)\n                  \u03b2 \u03b2 (map (function.const \u03b1 id) a) b } },\n    toBind := { bind := bind } }\n\n@[simp] theorem map_def {\u03b1 : Type u_1} {\u03b2 : Type u_1} : Functor.map = map := rfl\n\n@[simp] theorem bind_def {\u03b1 : Type u_1} {\u03b2 : Type u_1} : bind = bind := rfl\n\n@[simp] theorem mem_pure {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : a \u2208 pure b \u2194 a = b :=\n  set.mem_singleton_iff\n\ntheorem mem_pure_self {\u03b1 : Type u_1} (a : \u03b1) : a \u2208 pure a := set.mem_singleton a\n\n@[simp] theorem pure_inj {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : pure a = pure b \u2194 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 {\u03b1 : Type u_1} : HasLessEq (semiquot \u03b1) :=\n  { LessEq := fun (s t : semiquot \u03b1) => s s \u2286 s t }\n\nprotected instance partial_order {\u03b1 : Type u_1} : partial_order (semiquot \u03b1) :=\n  partial_order.mk (fun (s t : semiquot \u03b1) => \u2200 {x : \u03b1}, x \u2208 s \u2192 x \u2208 t)\n    (preorder.lt._default fun (s t : semiquot \u03b1) => \u2200 {x : \u03b1}, x \u2208 s \u2192 x \u2208 t) sorry sorry sorry\n\nprotected instance semilattice_sup {\u03b1 : Type u_1} : semilattice_sup (semiquot \u03b1) :=\n  semilattice_sup.mk (fun (s : semiquot \u03b1) => blur (s s)) partial_order.le partial_order.lt sorry\n    sorry sorry sorry sorry sorry\n\n@[simp] theorem pure_le {\u03b1 : Type u_1} {a : \u03b1} {s : semiquot \u03b1} : pure a \u2264 s \u2194 a \u2208 s :=\n  set.singleton_subset_iff\n\ndef is_pure {\u03b1 : Type u_1} (q : semiquot \u03b1) := \u2200 (a b : \u03b1), a \u2208 q \u2192 b \u2208 q \u2192 a = b\n\ndef get {\u03b1 : Type u_1} (q : semiquot \u03b1) (h : is_pure q) : \u03b1 := lift_on q id h\n\ntheorem get_mem {\u03b1 : Type u_1} {q : semiquot \u03b1} (p : is_pure q) : get q p \u2208 q := sorry\n\ntheorem eq_pure {\u03b1 : Type u_1} {q : semiquot \u03b1} (p : is_pure q) : q = pure (get q p) := sorry\n\n@[simp] theorem pure_is_pure {\u03b1 : Type u_1} (a : \u03b1) : is_pure (pure a) :=\n  fun (a_1 b : \u03b1) (H : a_1 \u2208 pure a) (H_1 : b \u2208 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 {\u03b1 : Type u_1} {s : semiquot \u03b1} : is_pure s \u2194 \u2203 (a : \u03b1), s = pure a := sorry\n\ntheorem is_pure.mono {\u03b1 : Type u_1} {s : semiquot \u03b1} {t : semiquot \u03b1} (st : s \u2264 t) (h : is_pure t) :\n    is_pure s :=\n  fun (a b : \u03b1) (H : a \u2208 s) (H_1 : b \u2208 s) => idRhs (a = b) (h a b (st H) (st H_1))\n\ntheorem is_pure.min {\u03b1 : Type u_1} {s : semiquot \u03b1} {t : semiquot \u03b1} (h : is_pure t) :\n    s \u2264 t \u2194 s = t :=\n  sorry\n\ntheorem is_pure_of_subsingleton {\u03b1 : Type u_1} [subsingleton \u03b1] (q : semiquot \u03b1) : is_pure q :=\n  fun (a b : \u03b1) (H : a \u2208 q) (H : b \u2208 q) => idRhs (a = b) (subsingleton.elim a b)\n\n/-- `univ : semiquot \u03b1` represents an unspecified element of `univ : set \u03b1`. -/\ndef univ {\u03b1 : Type u_1} [Inhabited \u03b1] : semiquot \u03b1 := mk sorry\n\nprotected instance inhabited {\u03b1 : Type u_1} [Inhabited \u03b1] : Inhabited (semiquot \u03b1) :=\n  { default := univ }\n\n@[simp] theorem mem_univ {\u03b1 : Type u_1} [Inhabited \u03b1] (a : \u03b1) : a \u2208 univ := set.mem_univ\n\ntheorem univ_unique {\u03b1 : Type u_1} (I : Inhabited \u03b1) (J : Inhabited \u03b1) : univ = univ := sorry\n\n@[simp] theorem is_pure_univ {\u03b1 : Type u_1} [Inhabited \u03b1] : is_pure univ \u2194 subsingleton \u03b1 := sorry\n\nprotected instance order_top {\u03b1 : Type u_1} [Inhabited \u03b1] : order_top (semiquot \u03b1) :=\n  order_top.mk univ partial_order.le partial_order.lt sorry sorry sorry sorry\n\nprotected instance semilattice_sup_top {\u03b1 : Type u_1} [Inhabited \u03b1] :\n    semilattice_sup_top (semiquot \u03b1) :=\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\u2081` is defined so that `A.definable\u2081 L s` indicates that\n`(s : set M)` is definable with parameters in `A`.\n* `set.definable\u2082` is defined so that `A.definable\u2082 L s` indicates that\n`(s : set (M \u00d7 M))` is definable with parameters in `A`.\n* A `first_order.language.definable_set` is defined so that `L.definable_set A \u03b1` is the boolean\n  algebra of subsets of `\u03b1 \u2192 M` defined by formulas with parameters in `A`.\n\n## Main Results\n* `L.definable_set A \u03b1` 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 {\u03b1 : Type*} {\u03b2 : 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 (\u03b1 \u2192 M)) : Prop :=\n\u2203 (\u03c6 : L[[A]].formula \u03b1), s = set_of \u03c6.realize\n\nvariables {L} {A} {B : set M} {s : set (\u03b1 \u2192 M)}\n\nlemma definable.map_expansion {L' : first_order.language} [L'.Structure M] (h : A.definable L s)\n  (\u03c6 : L \u2192\u1d38 L') [\u03c6.is_expansion_on M] :\n  A.definable L' s :=\nbegin\n  obtain \u27e8\u03c8, rfl\u27e9 := h,\n  refine \u27e8(\u03c6.add_constants A).on_formula \u03c8, _\u27e9,\n  ext x,\n  simp only [mem_set_of_eq, Lhom.realize_on_formula],\nend\n\nlemma empty_definable_iff :\n  (\u2205 : set M).definable L s \u2194 \u2203 (\u03c6 : L.formula \u03b1), s = set_of \u03c6.realize :=\nbegin\n  rw [definable, equiv.exists_congr_left (Lequiv.add_empty_constants L (\u2205 : set M)).on_formula],\n  simp,\nend\n\nlemma definable_iff_empty_definable_with_params :\n  A.definable L s \u2194 (\u2205 : set M).definable (L[[A]]) s :=\nempty_definable_iff.symm\n\nlemma definable.mono (hAs : A.definable L s) (hAB : A \u2286 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 (\u2205 : set (\u03b1 \u2192 M)) :=\n\u27e8\u22a5, by {ext, simp} \u27e9\n\n@[simp]\nlemma definable_univ : A.definable L (univ : set (\u03b1 \u2192 M)) :=\n\u27e8\u22a4, by {ext, simp} \u27e9\n\n@[simp]\nlemma definable.inter {f g : set (\u03b1 \u2192 M)} (hf : A.definable L f) (hg : A.definable L g) :\n  A.definable L (f \u2229 g) :=\nbegin\n  rcases hf with \u27e8\u03c6, rfl\u27e9,\n  rcases hg with \u27e8\u03b8, rfl\u27e9,\n  refine \u27e8\u03c6 \u2293 \u03b8, _\u27e9,\n  ext,\n  simp,\nend\n\n@[simp]\nlemma definable.union {f g : set (\u03b1 \u2192 M)} (hf : A.definable L f) (hg : A.definable L g) :\n  A.definable L (f \u222a g) :=\nbegin\n  rcases hf with \u27e8\u03c6, h\u03c6\u27e9,\n  rcases hg with \u27e8\u03b8, h\u03b8\u27e9,\n  refine \u27e8\u03c6 \u2294 \u03b8, _\u27e9,\n  ext,\n  rw [h\u03c6, h\u03b8, mem_set_of_eq, formula.realize_sup, mem_union, mem_set_of_eq,\n    mem_set_of_eq],\nend\n\nlemma definable_finset_inf {\u03b9 : Type*} {f : \u03a0 (i : \u03b9), set (\u03b1 \u2192 M)}\n  (hf : \u2200 i, A.definable L (f i)) (s : finset \u03b9) :\n  A.definable L (s.inf f) :=\nbegin\n  classical,\n  refine finset.induction definable_univ (\u03bb i s is h, _) s,\n  rw finset.inf_insert,\n  exact (hf i).inter h,\nend\n\nlemma definable_finset_sup {\u03b9 : Type*} {f : \u03a0 (i : \u03b9), set (\u03b1 \u2192 M)}\n  (hf : \u2200 i, A.definable L (f i)) (s : finset \u03b9) :\n  A.definable L (s.sup f) :=\nbegin\n  classical,\n  refine finset.induction definable_empty (\u03bb i s is h, _) s,\n  rw finset.sup_insert,\n  exact (hf i).union h,\nend\n\nlemma definable_finset_bInter {\u03b9 : Type*} {f : \u03a0 (i : \u03b9), set (\u03b1 \u2192 M)}\n  (hf : \u2200 i, A.definable L (f i)) (s : finset \u03b9) :\n  A.definable L (\u22c2 i \u2208 s, f i) :=\nbegin\n  rw \u2190 finset.inf_set_eq_bInter,\n  exact definable_finset_inf hf s,\nend\n\nlemma definable_finset_bUnion {\u03b9 : Type*} {f : \u03a0 (i : \u03b9), set (\u03b1 \u2192 M)}\n  (hf : \u2200 i, A.definable L (f i)) (s : finset \u03b9) :\n  A.definable L (\u22c3 i \u2208 s, f i) :=\nbegin\n  rw \u2190 finset.sup_set_eq_bUnion,\n  exact definable_finset_sup hf s,\nend\n\n@[simp]\nlemma definable.compl {s : set (\u03b1 \u2192 M)} (hf : A.definable L s) :\n  A.definable L s\u1d9c :=\nbegin\n  rcases hf with \u27e8\u03c6, h\u03c6\u27e9,\n  refine \u27e8\u03c6.not, _\u27e9,\n  rw h\u03c6,\n  refl,\nend\n\n@[simp]\nlemma definable.sdiff {s t : set (\u03b1 \u2192 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 : \u03b1 \u2192 \u03b2) {s : set (\u03b1 \u2192 M)}\n  (h : A.definable L s) :\n  A.definable L ((\u03bb g : \u03b2 \u2192 M, g \u2218 f) \u207b\u00b9' s) :=\nbegin\n  obtain \u27e8\u03c6, rfl\u27e9 := h,\n  refine \u27e8(\u03c6.relabel f), _\u27e9,\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 (\u03b2 \u2192 M)}\n  (h : A.definable L s) (f : \u03b1 \u2243 \u03b2) :\n  A.definable L ((\u03bb g : \u03b2 \u2192 M, g \u2218 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 : \u2115) {s : set ((\u03b1 \u2295 fin m) \u2192 M)}\n  (h : A.definable L s) :\n  A.definable L ((\u03bb g : (\u03b1 \u2295 fin m) \u2192 M, g \u2218 sum.inl) '' s) :=\nbegin\n  obtain \u27e8\u03c6, rfl\u27e9 := h,\n  refine \u27e8(bounded_formula.relabel id \u03c6).exs, _\u27e9,\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 \u27e8y, hy, rfl\u27e9,\n    exact \u27e8y \u2218 sum.inr,\n      (congr (congr rfl (sum.elim_comp_inl_inr y).symm) (funext fin_zero_elim)).mp hy\u27e9 },\n  { rintro \u27e8y, hy\u27e9,\n    exact \u27e8sum.elim x y, (congr rfl (funext fin_zero_elim)).mp hy, sum.elim_comp_inl _ _\u27e9, },\nend\n\n/-- Shows that definability is closed under finite projections. -/\nlemma definable.image_comp_embedding {s : set (\u03b2 \u2192 M)} (h : A.definable L s)\n  (f : \u03b1 \u21aa \u03b2) [finite \u03b2] :\n  A.definable L ((\u03bb g : \u03b2 \u2192 M, g \u2218 f) '' s) :=\nbegin\n  classical,\n  casesI nonempty_fintype \u03b2,\n  refine (congr rfl (ext (\u03bb 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 (\u03bb y, and_congr_right (\u03bb ys, eq.congr_left (funext (\u03bb a, _)))),\n  simp,\nend\n\n/-- Shows that definability is closed under finite projections. -/\nlemma definable.image_comp {s : set (\u03b2 \u2192 M)} (h : A.definable L s)\n  (f : \u03b1 \u2192 \u03b2) [finite \u03b1] [finite \u03b2] :\n  A.definable L ((\u03bb g : \u03b2 \u2192 M, g \u2218 f) '' s) :=\nbegin\n  classical,\n  casesI nonempty_fintype \u03b1,\n  casesI nonempty_fintype \u03b2,\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 : \u03b1 \u2192 M |\n    \u2200 a, x a = x (range_splitting f (range_factorization f a))}),\n  { have h' : \u2200 a, A.definable L {x : \u03b1 \u2192 M | x a =\n      x (range_splitting f (range_factorization f a))},\n    { refine \u03bb a, \u27e8(var a).equal (var (range_splitting f (range_factorization f a))), ext _\u27e9,\n      simp, },\n    refine (congr rfl (ext _)).mp (definable_finset_bInter h' finset.univ),\n    simp },\n  refine (congr rfl (ext (\u03bb 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 \u27e8\u27e8y, ys, hy\u27e9, hx\u27e9,\n    refine \u27e8y, ys, _\u27e9,\n    ext a,\n    rw [hx a, \u2190 function.comp_apply x, \u2190 hy],\n    simp, },\n  { rintro \u27e8y, ys, rfl\u27e9,\n    refine \u27e8\u27e8y, ys, _\u27e9, \u03bb a, _\u27e9,\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\u2081 (s : set M) : Prop := A.definable L { x : fin 1 \u2192 M | x 0 \u2208 s }\n\n/-- A 2-dimensional version of `definable`, for `set (M \u00d7 M)`. -/\ndef definable\u2082 (s : set (M \u00d7 M)) : Prop := A.definable L { x : fin 2 \u2192 M | (x 0, x 1) \u2208 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) (\u03b1 : 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 (\u03b1 \u2192 M) // A.definable L s}\n\nnamespace definable_set\nvariables {L A \u03b1} {s t : L.definable_set A \u03b1} {x : \u03b1 \u2192 M}\n\ninstance : set_like (L.definable_set A \u03b1) (\u03b1 \u2192 M) :=\n{ coe := subtype.val,\n  coe_injective' := subtype.val_injective }\n\ninstance : has_top (L.definable_set A \u03b1) := \u27e8\u27e8\u22a4, definable_univ\u27e9\u27e9\ninstance : has_bot (L.definable_set A \u03b1) := \u27e8\u27e8\u22a5, definable_empty\u27e9\u27e9\ninstance : has_sup (L.definable_set A \u03b1) := \u27e8\u03bb s t, \u27e8s \u222a t, s.2.union t.2\u27e9\u27e9\ninstance : has_inf (L.definable_set A \u03b1) := \u27e8\u03bb s t, \u27e8s \u2229 t, s.2.inter t.2\u27e9\u27e9\ninstance : has_compl (L.definable_set A \u03b1) := \u27e8\u03bb s, \u27e8s\u1d9c, s.2.compl\u27e9\u27e9\ninstance : has_sdiff (L.definable_set A \u03b1) := \u27e8\u03bb s t, \u27e8s \\ t, s.2.sdiff t.2\u27e9\u27e9\n\ninstance : inhabited (L.definable_set A \u03b1) := \u27e8\u22a5\u27e9\n\nlemma le_iff : s \u2264 t \u2194 (s : set (\u03b1 \u2192 M)) \u2264 (t : set (\u03b1 \u2192 M)) := iff.rfl\n\n@[simp] lemma mem_top : x \u2208 (\u22a4 : L.definable_set A \u03b1) := mem_univ x\n@[simp] lemma not_mem_bot {x : \u03b1 \u2192 M} : \u00ac x \u2208 (\u22a5 : L.definable_set A \u03b1) := not_mem_empty x\n@[simp] \n\n@[simp, norm_cast] lemma coe_top : ((\u22a4 : L.definable_set A \u03b1) : set (\u03b1 \u2192 M)) = univ := rfl\n@[simp, norm_cast] lemma coe_bot : ((\u22a5 : L.definable_set A \u03b1) : set (\u03b1 \u2192 M)) = \u2205 := rfl\n@[simp, norm_cast] lemma coe_sup (s t : L.definable_set A \u03b1) : (\u2191(s \u2294 t) : set (\u03b1 \u2192 M)) = s \u222a t :=\nrfl\n@[simp, norm_cast] lemma coe_inf (s t : L.definable_set A \u03b1) : (\u2191(s \u2293 t) : set (\u03b1 \u2192 M)) = s \u2229 t :=\nrfl\n@[simp, norm_cast] lemma coe_compl (s : L.definable_set A \u03b1) : (\u2191(s\u1d9c) : set (\u03b1 \u2192 M)) = s\u1d9c := rfl\n@[simp, norm_cast] lemma coe_sdiff (s t : L.definable_set A \u03b1) : (\u2191(s \\ t) : set (\u03b1 \u2192 M)) = s \\ t :=\nrfl\n\ninstance : boolean_algebra (L.definable_set A \u03b1) :=\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 : \u00ac (p \u2194 \u00ac p) :=\nbegin\n  intro h,\n  cases h with h1 h2,\n  have hnp : \u00ac p := \u03bb 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 (\u03b1 : Type u) : Type u := order_top \u03b1\n\n-- @[instance]def has_top_forcing_notion (\u03b1 : Type u) [H : forcing_notion \u03b1] : has_top \u03b1 := sorry\n\ninstance partial_order_of_forcing_notion (\u03b1 : Type u) [H : forcing_notion \u03b1] : partial_order \u03b1 :=\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 {\u03b1 : Type u} [H\u2081 : partial_order \u03b1] [H\u2082 : has_top \u03b1] (H : \u2200 a : \u03b1, a \u2264 \u22a4) : order_top \u03b1 :=\n{ top := \u22a4,\n  le := (\u2264),\n  lt := (<),\n  le_refl := H\u2081.le_refl,\n  le_trans := H\u2081.le_trans,\n  lt_iff_le_not_le := H\u2081.lt_iff_le_not_le,\n  le_antisymm := H\u2081.le_antisymm,\n  le_top := H }\n\n@[instance]example {\u03b1 : Type u} : forcing_notion (set \u03b1) :=\norder_top.mk (\u03bb _, le_top)\n\n/- A pfilter is an order-theoretic filter on the partial order \u03b1  -/\nstructure pfilter (\u03b1 : Type u) [partial_order \u03b1] : Type u :=\n(X : set \u03b1)\n(nonempty : X \u2260 \u2205)\n(upward_closed : \u2200 (p q : \u03b1) (H_le : p \u2264 q) (H_mem : p \u2208 X), q \u2208 X)\n(downward_directed : \u2200 (p q \u2208 X), \u2203 r \u2208 X, r \u2264 p \u2227 r \u2264 q)\n\ninductive Name (P : Type u) [forcing_notion P] : Type (u+1)\n| mk (\u03b1 : Type u) (A : \u03b1 \u2192 Name) (B : \u03b1 \u2192 P) : Name\n\npostfix `-name`:100 := Name\n\ninstance : partial_order punit :=\n{ le := \u03bb _ _, true,\n  lt := \u03bb _ _, 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 := \u27e8punit.star\u27e9\n\ninstance : forcing_notion punit := order_top.mk (by finish)\n\ninstance forcing_notion_complete_boolean_algebra {\u03b1 : Type u} [complete_boolean_algebra \u03b1] : forcing_notion \u03b1 := 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} \u2243 (punit-name : Type (u+1)) :=\n{ to_fun := \u03bb u,\n  begin\n    induction u with \u03b1 A ih,\n    from \u27e8\u03b1, ih, \u03bb _, punit.star\u27e9\n  end,\n  inv_fun := \u03bb v,\n  begin\n    induction v with \u03b1 A B ih,\n    from \u27e8\u03b1, ih\u27e9\n  end,\n  left_inv :=\n    \u03bb x, by induction x; finish,\n  right_inv :=\n    \u03bb y, by induction y; finish }\n\n-- def Pcheck {P} [forcing_notion P] : pSet.{u} \u2192 (P-name : Type (u+1))\n-- | \u27e8\u03b1, A\u27e9 := \u27e8\u03b1, \u03bb a, Pcheck (A a), \u03bb _, \u22a4\u27e9\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 \u1e8b is any Q-name, define\n\u1e8b(G) recursively by \u1e8b(G) := { \u1e8f(G) : \u2203p \u2208 G (( \u1e8f, p) \u2208 \u1e8b)}\n\nx \u21a6 \u1e8b is a map (Name \u03b1).{u} \u2192 Type u, parametrized by a pfilter (G : pfilter \u03b1)\n\nHowever, what does it mean for a filter in this case to be generic?\n-/\ndef eval {P : Type u} [forcing_notion P] (\ud835\udca2 : pfilter P) : P-name \u2192 Type u\n| \u27e8\u03b1, A, B\u27e9 := \u03a3 p : {a : \u03b1 // B a \u2208 \ud835\udca2.X}, eval (A p.1)\n\ndef eval_image {P : Type u} [forcing_notion P] (\ud835\udca2 : pfilter P): Type (u + 1) :=\n{\u03b1 // \u2203 x, \u03b1 = eval \ud835\udca2 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] (\ud835\udca2 : pfilter P)  : pSet.{u} \u2192 (eval_image.{u} \ud835\udca2) := \u03bb x, \u27e8eval \ud835\udca2 (Pcheck x), \u27e8_, rfl\u27e9\u27e9\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 : \u211d} (ha : a \u2260 0) (hb : b \u2260 0) : | ( 1 /a - 1 / b) | = | (b - a) / (a * b) |\n-/\n\n/-\nLemma : stuff2 \n{a b : \u211d} (ha : a \u2260 0) (hb : b \u2260 0) :  | (b - a) / ( a * b) | = 1 / (|a| * |b|) * |a - b| \n-/\n\n/-\nLemma : stuff3\n{a b : \u211d} (ha : a \u2260 0) (hb : b \u2260 0) (pb : 0 < b) (c : a \u2265 b) : 1 / a \u2264 1 / b \n-/\n\n/-\nLemma : stuff4\n{a b c : \u211d} (ha : a \u2260 0) (hb : b \u2260 0) (hc : c \u2260 0) (hab : a \u2265 b) : 1 / (a * c) \u2264 1 / (b * c)\n-/\n\n/-\nLemma : stuff5\n{a b c : \u211d} (ha : 0 < a) (hb : 0 \u2264 b) (hc : 0 < c) (hbc : b < c)\n-/\n\n\n\nlocal notation `|`x`|` := abs x\n\nlemma lim_recip (b : \u2115 \u2192 \u211d) (k : \u211d) (hk : k \u2260 0) (hb : is_limit b k) (hbnz : \u2200 n : \u2115, b n \u2260 0) : \nis_limit (\u03bbn , 1 / b n) (1 / k) :=\nbegin \n\n  apply lim_le_iff_lim_lt.mpr,\n  \n  intro \u03b5,\n  intro h\u03b5, \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| * \u03b5), \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| * \u03b5), exact mul_pos H2 h\u03b5, \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 | \u2260 0, linarith, \n  have duh2 : c \u2260 0, linarith, \n\n  have L4 : 1 / |b n| \u2264 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| \u2264 |b n| * |k|, exact mul_le_mul_right1 duh5 L3, \n  have L505 : 0 < |b n|, linarith, \n  have L5051 : |k| \u2260 0, linarith, \n  have L51 : 0 < c * |k|, exact mul_pos y duh4, \n  have L5101 : 0 < (1 : \u211d), linarith, \n  have L511 : 0 < 1 / (c * |k|), exact div_pos (L5101) (L51), \n  have L512 : 0 \u2264 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|) \u2264 1 / (c * |k|), exact stuff4 duh duh2 L5051 L3,      \n  have L7 : (1 / (|b n| * |k|)) * |b n - k| \u2264 (1 / (c * |k|)) * |b n - k|, exact mul_le_mul_right1 duh3 L6,\n    \n  have duh6 : |b n - k| < (c * |k| * \u03b5), 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| * \u03b5), \n  exact stuff5 L511 duh3 H3 duh6,      \n     \n  have L65 : (c * |k|) \u2260 0, linarith, \n  have H7 : 1 / (c * |k|) * (c * |k| * \u03b5) = \u03b5, exact soul_sucking_deep_sadness h\u03b5 L65, \n  rw H7 at H6,\n\n  have H8 := bs_lemma L505 y duh4 duh3 h\u03b5 duh L5051 duh2 L3 _, \n  swap, have H9 : 1 / (c * |k|) * |b n - k| \u2264 \u03b5, 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)) \u2294 (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) := \u03bb 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 \u2192o I := \u27e8T_propagate p i_neg, T_monotone p i_neg\u27e9\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 \u2194 T p i ii = ii := \n  (iff.intro (\u03bb h, le_antisymm h T_increasing) (\u03bb 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 \u2194 \u2200 r \u2208 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 = (\u03bb b, if r.head = b then (r.eval_body i ii) else i b) \u2294 (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)) \u2294 (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 \u2194 p.model i :=\n  (iff.intro (\u03bb h, \u27e8 T_fp_rule_sat_iff.mp h \u27e9)\n             (\u03bb h, T_fp_rule_sat_iff.mpr h.p))\n\n\ndef Program.is_local_op (p : Program) (f : I -> I) := \u2200 {i : I}, p.localize (f i) = f (p.localize i)\n\n\ndef Program.is_local_biop (p : Program) (f : I -> I -> I) := \u2200 {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 \u2208 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} : (\u2200 a \u2208 atoms, a \u2208 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 \u2208 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 \u2208 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 \u2208 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 \u2208 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 \u2208 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) := \u03bb i, begin\n  have generalized : \u2200 {p' : Program}, p \u2286 p' -> (p'.localize) ((T p ii) i) = (T p ii) ((p'.localize) i) := \u03bb 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 \u2208 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) : \u03a0(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) \u2194 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 (\u00ablet\u00bb \u00abhave\u00bb simp refl)\nopen freealg\n\n------------------------- Conversion Tactic: [(finset \u03b1) or (set \u03b1) or boolean_lattice] to [boolean_ring] \n\nlemma finset.inter_is_inf (\u03b1 : Type) [decidable_eq \u03b1] (X Y : finset \u03b1) : X \u2229 Y = X \u2293 Y := rfl\nlemma finset.union_is_sup (\u03b1 : Type) [decidable_eq \u03b1] (X Y : finset \u03b1) : X \u222a Y = X \u2294 Y := rfl\nlemma finset.empt_is_bot (\u03b1 : Type) [decidable_eq \u03b1] : (finset.has_emptyc.emptyc : finset \u03b1) = \u22a5 := rfl\nlemma finset.subset_is_le (\u03b1 : Type) [decidable_eq \u03b1] (X Y : finset \u03b1) : (X \u2286 Y) = (X \u2264 Y) := rfl \n\nlemma set.union_is_sup (\u03b1 : Type) (X Y : set \u03b1) : X \u222a Y = X \u2294 Y := rfl\nlemma set.inter_is_inf (\u03b1 : Type) (X Y : set \u03b1) : X \u2229 Y = X \u2293 Y := rfl\nlemma set.empt_is_bot (\u03b1 : Type) : (set.has_emptyc.emptyc : set \u03b1) = \u22a5 := rfl \nlemma set.univ_is_top (\u03b1 : Type) : (set.univ : set \u03b1) = \u22a4 := rfl \nlemma set.subset_is_le (\u03b1 : Type) (X Y : set \u03b1) : (X \u2286 Y) = (X \u2264 Y) := rfl \n\nlemma ne_is_not_eq {\u03b1 : Type} [boolean_algebra \u03b1] {X Y : \u03b1} : (X \u2260 Y) = \u00ac(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' \u2192 B = B' \u2192 (A \u2227 B) = (A' \u2227 B') :=\nbegin\n  cc,\nend\n\nmeta def get_proof_normalization : expr \u2192 tactic (expr \u00d7 expr)\n| e := do\n  match e with \n  | `(%%L \u2227 %%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 \u2227 %%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 \u2227 %%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) \u2192 nat -> list (nat \u00d7 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    (\u00ablet\u00bb vname ``(vector _ %%(vars.length)) $ meta_build_vector (names.map to_pexpr)),\n    mmap \n      (\u03bb (pair : (nat \u00d7 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          (\u00abhave\u00bb 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 \u2192 tactic expr\n| []         := tactic.failed\n| (H :: Hs)  := do t \u2190 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 \u2192 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 \u2192 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 \u2260 %%R) <- (infer_type e),\n    assert_expr_is_boolalg L,\n    assert_expr_is_boolalg R,\n    return tt)\n  <|>\n  (do `(\u00ac %%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 \u22a2 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 ```(\u03bb a : \u03b1, x)`` -/\n-- | lam name binder type body := do return ()\n/- Pi type constructor. eg ```(\u03a0 a : \u03b1, x)`` and ```(\u03b1 \u2192 \u03b2)`` -/\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) \u2192 (A * B = A * C) \u2192 B = C :=\n  \u03bb 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 \u2227 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 \u03a0 (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 \u2228 %%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 \u2286 B \u2192 C \u2286 B\u1d9c \u2192 D \u2286 B\u1d9c \u2192 ((A \u2229 C = \u2205 ) \u2227 (A \u2229 D = \u2205)):=\nbegin\n  intros,\n  timed_simplify_sets,\nend\n\n--lemma fourtrans (T : Type) (A B C D : set T) : (A \u2286 B) \u2192 (B \u2286 C) \u2192 (C \u2286 D) \u2192 (A \u2286 D) :=\n--begin\n--  intros,\n--  timed_simplify_sets,\n--end\n\n--lemma dummylemma (T: Type) (X Y Z : set T) : (T = nat) \u2192 (X \u2286 Y) \u2192 (X \u2229 Z) \u2286 (Y \u2229 Z) :=\n--begin\n--  intros H1 H2,      \n--  simplify_sets,\n--end\n\n--lemma foo_alg2 (\u03b1 : Type) (A: boolean_algebra \u03b1) (X Y Z P Q W: \u03b1): \n--  (X \u2294 (Y \u2294 Z)) \u2294 ((W \u2293 P \u2293 Q)\u1d9c \u2294 (P \u2294 W \u2294 Q)) = \u22a4 :=\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* \u2192 Type* \u2192 Type*` along with a bimap which turns `F \u03b1 \u03b2` into\n`F \u03b1' \u03b2'` given two functions `\u03b1 \u2192 \u03b1'` and `\u03b2 \u2192 \u03b2'`. It further\n* respects the identity: `bimap id id = id`\n* composes in the obvious way: `(bimap f' g') \u2218 (bimap f g) = bimap (f' \u2218 f) (g' \u2218 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\u2080 u\u2081 u\u2082 v\u2080 v\u2081 v\u2082\n\nopen Function\n\n#print Bifunctor /-\n/-- Lawless bifunctor. This typeclass only holds the data for the bimap. -/\nclass Bifunctor (F : Type u\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082) where\n  bimap : \u2200 {\u03b1 \u03b1' \u03b2 \u03b2'}, (\u03b1 \u2192 \u03b1') \u2192 (\u03b2 \u2192 \u03b2') \u2192 F \u03b1 \u03b2 \u2192 F \u03b1' \u03b2'\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\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082) [Bifunctor F] where\n  id_bimap : \u2200 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), bimap id id x = x\n  bimap_bimap :\n    \u2200 {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 \u03b2\u2080 \u03b2\u2081 \u03b2\u2082} (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b1\u2081 \u2192 \u03b1\u2082) (g : \u03b2\u2080 \u2192 \u03b2\u2081) (g' : \u03b2\u2081 \u2192 \u03b2\u2082) (x : F \u03b1\u2080 \u03b2\u2080),\n      bimap f' g' (bimap f g x) = bimap (f' \u2218 f) (g' \u2218 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\u2080 \u2192 Type u\u2081 \u2192 Type u\u2082} [Bifunctor F]\n\nnamespace Bifunctor\n\n#print Bifunctor.fst /-\n/-- Left map of a bifunctor. -/\n@[reducible]\ndef fst {\u03b1 \u03b1' \u03b2} (f : \u03b1 \u2192 \u03b1') : F \u03b1 \u03b2 \u2192 F \u03b1' \u03b2 :=\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 {\u03b1 \u03b2 \u03b2'} (f : \u03b2 \u2192 \u03b2') : F \u03b1 \u03b2 \u2192 F \u03b1 \u03b2' :=\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 : \u2200 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), 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 : \u2200 {\u03b1 \u03b2} (x : F \u03b1 \u03b2), 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 {\u03b1\u2080 \u03b1\u2081 \u03b1\u2082 \u03b2} (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b1\u2081 \u2192 \u03b1\u2082) (x : F \u03b1\u2080 \u03b2) :\n    fst f' (fst f x) = fst (f' \u2218 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 {\u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081} (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b2\u2080 \u2192 \u03b2\u2081) (x : F \u03b1\u2080 \u03b2\u2080) :\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 {\u03b1\u2080 \u03b1\u2081 \u03b2\u2080 \u03b2\u2081} (f : \u03b1\u2080 \u2192 \u03b1\u2081) (f' : \u03b2\u2080 \u2192 \u03b2\u2081) (x : F \u03b1\u2080 \u03b2\u2080) :\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 {\u03b1 \u03b2\u2080 \u03b2\u2081 \u03b2\u2082} (g : \u03b2\u2080 \u2192 \u03b2\u2081) (g' : \u03b2\u2081 \u2192 \u03b2\u2082) (x : F \u03b1 \u03b2\u2080) :\n    snd g' (snd g x) = snd (g' \u2218 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 \u03b1 \u03b1' \u03b2 \u03b2 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 \u03b1 \u03b1' \u03b2 \u03b2' f f' x := (bimap f' f x : F \u03b2' \u03b1')\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 {\u03b1} : Functor (F \u03b1) where map _ _ := snd\n#align bifunctor.functor Bifunctor.functor\n-/\n\n#print Bifunctor.lawfulFunctor /-\ninstance (priority := 10) Bifunctor.lawfulFunctor [LawfulBifunctor F] {\u03b1} : LawfulFunctor (F \u03b1) :=\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 _ \u2192 Type u\u2080) (H : Type _ \u2192 Type u\u2081) [Functor G] [Functor H]\n\ninstance : Bifunctor (bicompl F G H)\n    where bimap \u03b1 \u03b1' \u03b2 \u03b2' f f' x := (bimap (map f) (map f') x : F (G \u03b1') (H \u03b2'))\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\u2082 \u2192 Type _) [Functor G]\n\ninstance : Bifunctor (bicompr G F)\n    where bimap \u03b1 \u03b1' \u03b2 \u03b2' f f' x := (map (bimap f f') x : G (F \u03b1' \u03b2'))\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 : \u2115) :=\n(A : Type.{u}) (B : A \u2192 typevec.{u} n)\n\nnamespace mvpfunctor\nopen mvfunctor (liftp liftr)\n\nvariables {n m : \u2115} (P : mvpfunctor.{u} n)\n\ndef apply (\u03b1 : typevec.{u} n) : Type u := \u03a3 a : P.A, P.B a \u27f9 \u03b1\n\ndef map {\u03b1 \u03b2 : typevec n} (f : \u03b1 \u27f9 \u03b2) : P.apply \u03b1 \u2192 P.apply \u03b2 :=\n\u03bb \u27e8a, g\u27e9, \u27e8a, typevec.comp f g\u27e9\n\ninstance : mvfunctor P.apply :=\n\u27e8@mvpfunctor.map n P\u27e9\n\ntheorem map_eq {\u03b1 \u03b2 : typevec n} (g : \u03b1 \u27f9 \u03b2) (a : P.A) (f : P.B a \u27f9 \u03b1) :\n  @mvfunctor.map _ P.apply _ _ _ g \u27e8a, f\u27e9 = \u27e8a, g \u229a f\u27e9 :=\nrfl\n\ntheorem id_map {\u03b1 : typevec n} : \u2200 x : P.apply \u03b1, typevec.id <$$> x = x\n| \u27e8a, g\u27e9 := rfl\n\ntheorem comp_map {\u03b1 \u03b2 \u03b3 : typevec n} (f : \u03b1 \u27f9 \u03b2) (g : \u03b2 \u27f9 \u03b3) :\n  \u2200 x : P.apply \u03b1, (g \u229a f) <$$> x = g <$$> (f <$$> x)\n| \u27e8a, h\u27e9 := rfl\n\ndef comp (P : mvpfunctor.{u} n) (Q : fin' n \u2192 mvpfunctor.{u} m) : mvpfunctor m :=\n{ A := \u03a3 a\u2082 : P.1, \u03a0 i, P.2 a\u2082 i \u2192 (Q i).1,\n  B := \u03bb a, \u03bb i, \u03a3 j (b : P.2 a.1 j), (Q j).2 (a.snd j b) i }\n\nvariables {P} {Q : fin' n \u2192 mvpfunctor.{u} m} {\u03b1 \u03b2 : typevec.{u} m}\n\ndef comp.mk (x : P.apply (\u03bb i, (Q i).apply \u03b1)) : (comp P Q).apply \u03b1 :=\n\u27e8 \u27e8 x.1, \u03bb i a, (x.2 _ a).1  \u27e9, \u03bb i a, (x.snd a.fst (a.snd).fst).snd i (a.snd).snd \u27e9\n\ndef comp.get (x : (comp P Q).apply \u03b1) : P.apply (\u03bb i, (Q i).apply \u03b1) :=\n\u27e8 x.1.1, \u03bb i a, \u27e8x.fst.snd i a, \u03bb (j : fin' m) (b : (Q i).B _ j), x.snd j \u27e8i, \u27e8a, b\u27e9\u27e9\u27e9 \u27e9\n\nlemma comp.get_map (f : \u03b1 \u27f9 \u03b2) (x : (comp P Q).apply \u03b1) :\n  comp.get (f <$$> x) = (\u03bb i (x : (Q i).apply \u03b1), f <$$> x) <$$> comp.get x :=\nby cases x; refl\n\n@[simp]\nlemma comp.get_mk (x : P.apply (\u03bb i, (Q i).apply \u03b1)) : 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 \u03b1) : 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 \u27e8a,b,c\u27e9; refl,\nend\n\n/-\nlifting predicates and relations\n-/\n\ntheorem liftp_iff {\u03b1 : typevec n} (p : \u03a0 \u2983i\u2984 , \u03b1 i \u2192 Prop) (x : P.apply \u03b1) :\n  liftp p x \u2194 \u2203 a f, x = \u27e8a, f\u27e9 \u2227 \u2200 i j, p (f i j) :=\nbegin\n  split,\n  { rintros \u27e8y, hy\u27e9, cases h : y with a f,\n    refine \u27e8a, \u03bb i j, (f i j).val, _, \u03bb i j, (f i j).property\u27e9,\n    rw [\u2190hy, h, map_eq], refl },\n  rintros \u27e8a, f, xeq, pf\u27e9,\n  use \u27e8a, \u03bb i j, \u27e8f i j, pf i j\u27e9\u27e9,\n  rw [xeq], reflexivity\nend\n\ntheorem liftr_iff {\u03b1 : typevec n} (r : \u03a0 \u2983i\u2984, \u03b1 i \u2192 \u03b1 i \u2192 Prop) (x y : P.apply \u03b1) :\n  liftr r x y \u2194 \u2203 a f\u2080 f\u2081, x = \u27e8a, f\u2080\u27e9 \u2227 y = \u27e8a, f\u2081\u27e9 \u2227 \u2200 i j, r (f\u2080 i j) (f\u2081 i j) :=\nbegin\n  split,\n  { rintros \u27e8u, xeq, yeq\u27e9, cases h : u with a f,\n    use [a, \u03bb i j, (f i j).val.fst, \u03bb i j, (f i j).val.snd],\n    split, { rw [\u2190xeq, h], refl },\n    split, { rw [\u2190yeq, h], refl },\n    intros i j, exact (f i j).property },\n  rintros \u27e8a, f\u2080, f\u2081, xeq, yeq, h\u27e9,\n  use \u27e8a, \u03bb i j, \u27e8(f\u2080 i j, f\u2081 i j), h i j\u27e9\u27e9,\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 : \u2115} (P : mvpfunctor.{u} (n+1))\n\ndef drop : mvpfunctor n :=\n{ A := P.A, B := \u03bb a, (P.B a).drop }\n\ndef last : pfunctor :=\n{ A := P.A, B := \u03bb a, (P.B a).last }\n\n@[reducible] def append_contents {\u03b1 : typevec n} {\u03b2 : Type*}\n    {a : P.A} (f' : P.drop.B a \u27f9 \u03b1) (f : P.last.B a \u2192 \u03b2) :\n  P.B a \u27f9 \u03b1.append1 \u03b2 :=\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 \u2297[R] N)\n/-- (implementation) tensor product of morphisms R-modules -/\ndef tensor_hom {M N M' N' : Module R} (f : M \u27f6 N) (g : M' \u27f6 N') :\n  tensor_obj M M' \u27f6 tensor_obj N N' :=\ntensor_product.map f g\n\nlemma tensor_id (M N : Module R) : tensor_hom (\ud835\udfd9 M) (\ud835\udfd9 N) = \ud835\udfd9 (Module.of R (M \u2297 N)) :=\nby { ext1, refl }\n\nlemma tensor_comp {X\u2081 Y\u2081 Z\u2081 X\u2082 Y\u2082 Z\u2082 : Module R}\n  (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (g\u2081 : Y\u2081 \u27f6 Z\u2081) (g\u2082 : Y\u2082 \u27f6 Z\u2082) :\n    tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082) = tensor_hom f\u2081 f\u2082 \u226b tensor_hom g\u2081 g\u2082 :=\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 \u2245 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\u2081 X\u2082 X\u2083 : Type*}\n  [add_comm_monoid X\u2081] [add_comm_monoid X\u2082] [add_comm_monoid X\u2083]\n  [module R X\u2081] [module R X\u2082] [module R X\u2083]\n  {Y\u2081 Y\u2082 Y\u2083 : Type*}\n  [add_comm_monoid Y\u2081] [add_comm_monoid Y\u2082] [add_comm_monoid Y\u2083]\n  [module R Y\u2081] [module R Y\u2082] [module R Y\u2083]\n  (f\u2081 : X\u2081 \u2192\u2097[R] Y\u2081) (f\u2082 : X\u2082 \u2192\u2097[R] Y\u2082) (f\u2083 : X\u2083 \u2192\u2097[R] Y\u2083) :\n  (\u2191(assoc R Y\u2081 Y\u2082 Y\u2083) \u2218\u2097 (map (map f\u2081 f\u2082) f\u2083)) = ((map f\u2081 (map f\u2082 f\u2083)) \u2218\u2097 \u2191(assoc R X\u2081 X\u2082 X\u2083)) :=\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 \u2192\u2097[R] W) (assoc R X Y Z).to_linear_map).comp (assoc R W (X \u2297[R] Y) Z).to_linear_map)\n    .comp (map \u2191(assoc R W X Y) (1 : Z \u2192\u2097[R] Z)) =\n  (assoc R W X (Y \u2297[R] Z)).to_linear_map.comp (assoc R (W \u2297[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\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : Module R}\n  (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083) :\n    tensor_hom (tensor_hom f\u2081 f\u2082) f\u2083 \u226b (associator Y\u2081 Y\u2082 Y\u2083).hom =\n    (associator X\u2081 X\u2082 X\u2083).hom \u226b tensor_hom f\u2081 (tensor_hom f\u2082 f\u2083) :=\nby convert associator_naturality_aux f\u2081 f\u2082 f\u2083 using 1\n\nlemma pentagon (W X Y Z : Module R) :\n  tensor_hom (associator W X Y).hom (\ud835\udfd9 Z) \u226b (associator W (tensor_obj X Y) Z).hom\n  \u226b tensor_hom (\ud835\udfd9 W) (associator X Y Z).hom =\n    (associator (tensor_obj W X) Y Z).hom \u226b (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 \u2297[R] M) \u2245 M :=\n(linear_equiv.to_Module_iso (tensor_product.lid R M) : of R (R \u2297 M) \u2245 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 \u2297[R] R) \u2245 M :=\n(linear_equiv.to_Module_iso (tensor_product.rid R M) : of R (M \u2297 R) \u2245 of R M).trans (of_self_iso M)\n\nlemma right_unitor_naturality {M N : Module R} (f : M \u27f6 N) :\n  tensor_hom f (\ud835\udfd9 (Module.of R R)) \u226b (right_unitor N).hom = (right_unitor M).hom \u226b 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 \u226b tensor_hom (\ud835\udfd9 M) (left_unitor N).hom =\n    tensor_hom (right_unitor M).hom (\ud835\udfd9 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'               := \u03bb M N, tensor_id M N,\n  tensor_comp'             := \u03bb M N K M' N' K' f g h, tensor_comp f g h,\n  associator_naturality'   := \u03bb M N K M' N' K' f g h, associator_naturality f g h,\n  left_unitor_naturality'  := \u03bb M N f, left_unitor_naturality f,\n  right_unitor_naturality' := \u03bb M N f, right_unitor_naturality f,\n  pentagon'                := \u03bb M N K L, pentagon M N K L,\n  triangle'                := \u03bb M N, triangle M N, }\n\n/-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative ring. -/\ninstance : comm_ring ((\ud835\udfd9_ (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 \u27f6 L) (g : M \u27f6 N) (k : K) (m : M) :\n  (f \u2297 g) (k \u2297\u209c m) = f k \u2297\u209c g m := rfl\n\n@[simp]\nlemma left_unitor_hom_apply {M : Module.{u} R} (r : R) (m : M) :\n  ((\u03bb_ M).hom : \ud835\udfd9_ (Module R) \u2297 M \u27f6 M) (r \u2297\u209c[R] m) = r \u2022 m :=\ntensor_product.lid_tmul m r\n\n@[simp]\nlemma left_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((\u03bb_ M).inv : M \u27f6 \ud835\udfd9_ (Module.{u} R) \u2297 M) m = 1 \u2297\u209c[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  ((\u03c1_ M).hom : M \u2297 \ud835\udfd9_ (Module R) \u27f6 M) (m \u2297\u209c r) = r \u2022 m :=\ntensor_product.rid_tmul m r\n\n@[simp]\nlemma right_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((\u03c1_ M).inv : M \u27f6 M \u2297 \ud835\udfd9_ (Module.{u} R)) m = m \u2297\u209c[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  ((\u03b1_ M N K).hom : (M \u2297 N) \u2297 K \u27f6 M \u2297 (N \u2297 K)) ((m \u2297\u209c n) \u2297\u209c k) = (m \u2297\u209c (n \u2297\u209c k)) := rfl\n\n@[simp]\nlemma associator_inv_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((\u03b1_ M N K).inv : M \u2297 (N \u2297 K) \u27f6 (M \u2297 N) \u2297 K) (m \u2297\u209c (n \u2297\u209c k)) = ((m \u2297\u209c n) \u2297\u209c k) := rfl\n\nend monoidal_category\n\n/-- (implementation) the braiding for R-modules -/\ndef braiding (M N : Module R) : tensor_obj M N \u2245 tensor_obj N M :=\nlinear_equiv.to_Module_iso (tensor_product.comm R M N)\n\n@[simp] lemma braiding_naturality {X\u2081 X\u2082 Y\u2081 Y\u2082 : Module.{u} R} (f : X\u2081 \u27f6 Y\u2081) (g : X\u2082 \u27f6 Y\u2082) :\n  (f \u2297 g) \u226b (Y\u2081.braiding Y\u2082).hom =\n    (X\u2081.braiding X\u2082).hom \u226b (g \u2297 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  (\u03b1_ X Y Z).hom \u226b (braiding X _).hom \u226b (\u03b1_ Y Z X).hom =\n  ((braiding X Y).hom \u2297 \ud835\udfd9 Z) \u226b (\u03b1_ Y X Z).hom \u226b (\ud835\udfd9 Y \u2297 (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  (\u03b1_ X Y Z).inv \u226b (braiding _ Z).hom \u226b (\u03b1_ Z X Y).inv =\n  (\ud835\udfd9 X \u2297 (Y.braiding Z).hom) \u226b (\u03b1_ X Z Y).inv \u226b ((X.braiding Z).hom \u2297 \ud835\udfd9 Y) :=\nbegin\n  apply (cancel_epi (\u03b1_ 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' := \u03bb X\u2081 X\u2082 Y\u2081 Y\u2082 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  ((\u03b2_ M N).hom : M \u2297 N \u27f6 N \u2297 M) (m \u2297\u209c n) = n \u2297\u209c m := rfl\n\n@[simp] lemma braiding_inv_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((\u03b2_ M N).inv : N \u2297 M \u27f6 M \u2297 N) (n \u2297\u209c m) = m \u2297\u209c n := rfl\n\nend monoidal_category\n\nopen opposite\n\ninstance : monoidal_preadditive (Module.{u} R) :=\nby refine \u27e8_, _, _, _\u27e9; dsimp only [auto_param]; intros;\n  refine tensor_product.ext (linear_map.ext $ \u03bb x, linear_map.ext $ \u03bb y, _);\n  simp only [linear_map.compr\u2082_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 \u27e8_, _\u27e9; dsimp only [auto_param]; intros;\n  refine tensor_product.ext (linear_map.ext $ \u03bb x, linear_map.ext $ \u03bb y, _);\n  simp only [linear_map.compr\u2082_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 \u27f6 P) \u2243\n    (N \u27f6 ((linear_coyoneda R (Module R)).obj (op M)).obj P) :=\n{ to_fun := \u03bb f, linear_map.compr\u2082 (tensor_product.mk R N M) ((\u03b2_ N M).hom \u226b f),\n  inv_fun := \u03bb f, (\u03b2_ M N).hom \u226b tensor_product.lift f,\n  left_inv := \u03bb f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr\u2082_apply,\n      function.comp_app, coe_comp, monoidal_category.braiding_hom_apply],\n  end,\n  right_inv := \u03bb f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr\u2082_apply,\n      symmetric_category.symmetry_assoc],\n  end, }\n\ninstance : monoidal_closed (Module.{u} R) :=\n{ closed' := \u03bb 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 := \u03bb N P, monoidal_closed_hom_equiv M N P, } } } }\n\nlemma ihom_map_apply {M N P : Module.{u} R} (f : N \u27f6 P) (g : Module.of R (M \u27f6 N)) :\n  (ihom M).map f g = g \u226b 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 \u2297 N \u27f6 P) (x : M) (y : N) :\n  @coe_fn _ _ linear_map.has_coe_to_fun ((monoidal_closed.curry f : N \u2192\u2097[R] (M \u2192\u2097[R] P)) y) x =\n    f (x \u2297\u209c[R] y) :=\nrfl\n\n@[simp]\nlemma monoidal_closed_uncurry {M N P : Module.{u} R}\n  (f : N \u27f6 (M \u27f6[Module.{u} R] P)) (x : M) (y : N) :\n  monoidal_closed.uncurry f (x \u2297\u209c[R] y) = (@coe_fn _ _ linear_map.has_coe_to_fun (f y)) x :=\nrfl\n\n/-- Describes the counit of the adjunction `M \u2297 - \u22a3 Hom(M, -)`. Given an `R`-module `N` this\nshould give a map `M \u2297 Hom(M, N) \u27f6 N`, so we flip the order of the arguments in the identity map\n`Hom(M, N) \u27f6 (M \u27f6 N)` and uncurry the resulting map `M \u27f6 Hom(M, N) \u27f6 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 \u2297 - \u22a3 Hom(M, -)`. Given an `R`-module `N` this should\ndefine a map `N \u27f6 Hom(M, M \u2297 N)`, which is given by flipping the arguments in the natural\n`R`-bilinear map `M \u27f6 N \u27f6 M \u2297 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 \u27f6 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 \u2964 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.\u03c0.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 \u22d9 forget C)\n  let hG := Types.limitConeIsLimit.{w, v} (F \u22d9 forget C)\n  let T : E.pt \u2245 G.pt := hE.conePointUniqueUpToIso hG\n  change Function.Injective (T.hom \u226b fun x j => G.\u03c0.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.\u03c0.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    (\u2200 j, D.\u03c0.app j x = D.\u03c0.app j y) \u2192 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 : \u2191(limit F)) :\n    (\u2200 j, limit.\u03c0 F j x = limit.\u03c0 F j y) \u2192 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} {\u03b9 : Type w} {X : \u03b9 \u2192 C} (f : \u2200 j : \u03b9, X j \u27f6 B)\n    [HasWidePullback B X f] [PreservesLimit (wideCospan B X f) (forget C)]\n    (x y : \u2191(widePullback B X f)) (h\u2080 : base f x = base f y) (h : \u2200 j, \u03c0 f j x = \u03c0 f j y) :\n    x = y := by\n  apply Concrete.limit_ext\n  rintro (_ | j)\n  \u00b7 exact h\u2080\n  \u00b7 apply h\n#align category_theory.limits.concrete.wide_pullback_ext CategoryTheory.Limits.Concrete.widePullback_ext\n\ntheorem Concrete.widePullback_ext' {B : C} {\u03b9 : Type w} [Nonempty \u03b9] {X : \u03b9 \u2192 C}\n    (f : \u2200 j : \u03b9, X j \u27f6 B) [HasWidePullback.{w} B X f]\n    [PreservesLimit (wideCospan B X f) (forget C)] (x y : \u2191(widePullback B X f))\n    (h : \u2200 j, \u03c0 f j x = \u03c0 f j y) : x = y := by\n  apply Concrete.widePullback_ext _ _ _ _ h\n  inhabit \u03b9\n  simp only [\u2190 \u03c0_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 : \u2191(multiequalizer I))\n    (h : \u2200 t : I.L, Multiequalizer.\u03b9 I t x = Multiequalizer.\u03b9 I t y) : x = y := by\n  apply Concrete.limit_ext\n  rintro (a | b)\n  \u00b7 apply h\n  \u00b7 rw [\u2190 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 \u22d9 forget C).sections \u2243\n      { x : \u2200 i : I.L, I.left i // \u2200 i : I.R, I.fst i (x _) = I.snd i (x _) }\n    where\n  toFun x :=\n    \u27e8fun 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 [\u2190 b] at a\n      exact a\u27e9\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        \u00b7 change (I.multicospan.map (\ud835\udfd9 _)) _ = _\n          simp\n        \u00b7 rfl\n        \u00b7 dsimp\n          erw [\u2190 x.2 b']\n        \u00b7 change (I.multicospan.map (\ud835\udfd9 _)) _ = _\n          simp }\n  left_inv := by\n    intro x; ext (a | b)\n    \u00b7 rfl\n    \u00b7 change _ = x.val _\n      rw [\u2190 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) \u2243\n      { x : \u2200 i : I.L, I.left i // \u2200 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 : \u2191(multiequalizer I)) (i : I.L) :\n    ((Concrete.multiequalizerEquiv I) x : \u2200 i : I.L, I.left i) i = Multiequalizer.\u03b9 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 \u27f6 N} [HasCokernel f] {g h : cokernel f \u27f6 K}\n    (w : \u2200 n : N, g (cokernel.\u03c0 f n) = h (cokernel.\u03c0 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 \u2964 C) [PreservesColimit F (forget C)]\n\n\n\ntheorem Concrete.isColimit_exists_rep {D : Cocone F} (hD : IsColimit D) (x : D.pt) :\n    \u2203 (j : J)(y : F.obj j), D.\u03b9.app j y = x := by\n  obtain \u27e8a, rfl\u27e9 := Concrete.from_union_surjective_of_isColimit F hD x\n  exact \u27e8a.1, a.2, rfl\u27e9\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 : \u2191(colimit F)) :\n    \u2203 (j : J)(y : F.obj j), colimit.\u03b9 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 : \u2203 (k : _)(f : i \u27f6 k)(g : j \u27f6 k), F.map f x = F.map g y) :\n    D.\u03b9.app i x = D.\u03b9.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 \u22d9 forget C)\n  let hG := Types.colimitCoconeIsColimit.{v, v} (F \u22d9 forget C)\n  let T : E \u2245 G := hE.uniqueUpToIso hG\n  let TX : E.pt \u2245 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 [\u2190 isIso_iff_bijective]\n    apply IsIso.of_iso).1\n  change (E.\u03b9.app i \u226b TX.hom) x = (E.\u03b9.app j \u226b TX.hom) y\n  erw [T.hom.w, T.hom.w]\n  obtain \u27e8k, f, g, h\u27e9 := h\n  have : G.\u03b9.app i x = (G.\u03b9.app k (F.map f x) : G.pt) := Quot.sound \u27e8f, rfl\u27e9\n  rw [this, h]\n  symm\n  exact Quot.sound \u27e8g, rfl\u27e9\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 : \u2203 (k : _)(f : i \u27f6 k)(g : j \u27f6 k), F.map f x = F.map g y) :\n    colimit.\u03b9 F i x = colimit.\u03b9 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.\u03b9.app _ x = D.\u03b9.app _ y) :\n    \u2203 (k : _)(f : i \u27f6 k)(g : j \u27f6 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 \u22d9 forget C)\n  let hG := Types.colimitCoconeIsColimit.{v, v} (F \u22d9 forget C)\n  let T : E \u2245 G := hE.uniqueUpToIso hG\n  let TX : E.pt \u2245 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.\u03b9.app i \u226b TX.hom) x = (E.\u03b9.app j \u226b TX.hom) y at h\n  erw [T.hom.w, T.hom.w] at h\n  replace h := Quot.exact _ h\n  suffices\n    \u2200 (a b : \u03a3j, F.obj j) (_ : EqvGen (Limits.Types.Quot.Rel.{v, v} (F \u22d9 forget C)) a b),\n      \u2203 (k : _)(f : a.1 \u27f6 k)(g : b.1 \u27f6 k), F.map f a.2 = F.map g b.2\n    by exact this \u27e8i, x\u27e9 \u27e8j, y\u27e9 h\n  intro a b h\n  induction h\n  case rel x y hh =>\n    obtain \u27e8e, he\u27e9 := hh\n    use y.1, e, \ud835\udfd9 _\n    simpa using he.symm\n  case refl x =>\n    exact \u27e8x.1, \ud835\udfd9 _, \ud835\udfd9 _, rfl\u27e9\n  case symm x y _ hh =>\n    obtain \u27e8k, f, g, hh\u27e9 := hh\n    exact \u27e8k, g, f, hh.symm\u27e9\n  case trans x y z _ _ hh1 hh2 =>\n    obtain \u27e8k1, f1, g1, h1\u27e9 := hh1\n    obtain \u27e8k2, f2, g2, h2\u27e9 := hh2\n    let k0 : J := IsFiltered.max k1 k2\n    let e1 : k1 \u27f6 k0 := IsFiltered.leftToMax _ _\n    let e2 : k2 \u27f6 k0 := IsFiltered.rightToMax _ _\n    let k : J := IsFiltered.coeq (g1 \u226b e1) (f2 \u226b e2)\n    let e : k0 \u27f6 k := IsFiltered.coeqHom _ _\n    use k, f1 \u226b e1 \u226b e, g2 \u226b e2 \u226b e\n    simp only [F.map_comp, comp_apply, h1, \u2190 h2]\n    simp only [\u2190 comp_apply, \u2190 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.\u03b9.app i x = D.\u03b9.app j y \u2194 \u2203 (k : _)(f : i \u27f6 k)(g : j \u27f6 k), F.map f x = F.map g y :=\n  \u27e8Concrete.isColimit_exists_of_rep_eq _ hD _ _, Concrete.isColimit_rep_eq_of_exists _ hD _ _\u27e9\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.\u03b9 F _ x = colimit.\u03b9 F _ y) :\n    \u2203 (k : _)(f : i \u27f6 k)(g : j \u27f6 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.\u03b9 F i x = colimit.\u03b9 F j y \u2194 \u2203 (k : _)(f : i \u27f6 k)(g : j \u27f6 k), F.map f x = F.map g y :=\n  \u27e8Concrete.colimit_exists_of_rep_eq _ _ _, Concrete.colimit_rep_eq_of_exists _ _ _\u27e9\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} {\u03b1 : Type _} {X : \u03b1 \u2192 C} (f : \u2200 j : \u03b1, B \u27f6 X j)\n    [HasWidePushout.{v} B X f] [PreservesColimit (wideSpan B X f) (forget C)]\n    (x : \u2191(widePushout B X f)) : (\u2203 y : B, head f y = x) \u2228 \u2203 (i : \u03b1)(y : X i), \u03b9 f i y = x := by\n  obtain \u27e8_ | j, y, rfl\u27e9 := Concrete.colimit_exists_rep _ x\n  \u00b7 left\n    use y\n  \u00b7 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} {\u03b1 : Type _} [Nonempty \u03b1] {X : \u03b1 \u2192 C}\n    (f : \u2200 j : \u03b1, B \u27f6 X j) [HasWidePushout.{v} B X f] [PreservesColimit (wideSpan B X f) (forget C)]\n    (x : \u2191(widePushout B X f)) : \u2203 (i : \u03b1)(y : X i), \u03b9 f i y = x := by\n  rcases Concrete.widePushout_exists_rep f x with (\u27e8y, rfl\u27e9 | \u27e8i, y, rfl\u27e9)\n  \u00b7 inhabit \u03b1\n    use default, f _ y\n    simp only [\u2190 arrow_\u03b9 _ default, comp_apply]\n  \u00b7 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 : \u2200  {f : geom3d_frame} {s : geom3d_space f } (x y : position3d s),\n    x.to_point = y.to_point \u2192 x = y :=\n    begin\n        intros f s x y e,\n        cases x,\n        cases y,\n        simp *,\n        have h\u2081 : ({to_point := x} : position3d s).to_point = x := rfl,\n        simp [h\u2081] at e,\n        exact e \n    end\n\nnoncomputable def position3d.coords {f : geom3d_frame} {s : geom3d_space f } (p :position3d s) :=\n    \u03bbi : 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 : \u2115} {id_vec : fin dim \u2192 \u2115} {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 : \u2115} {id_vec : fin dim \u2192 \u2115} {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    : \u03a0 {f' : geom3d_frame} (s' : geom3d_space f' ), position3d s' := \n        \u03bb f' s',\n        \u27e8(p.to_point.expressed_in s')\u27e9\n\n\nnoncomputable def position3d.coords_in {f : geom3d_frame} {s : geom3d_space f } (p :position3d s) \n    : \u03a0 {f' : geom3d_frame} (s' : geom3d_space f' ), fin 3 \u2192 scalar := \n        \u03bb f' s',\n        \u03bbi, ((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\u2081 k\u2082 k\u2083 : real_scalar) : \n    position3d s := \nposition3d.mk (mk_point s \u27e8[k\u2081,k\u2082,k\u2083],rfl\u27e9) \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    \u27e8mk_point_prod (mk_point_prod p1.to_point p2.to_point) p3.to_point\u27e9\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 : \u2200  {f : geom3d_frame} {s : geom3d_space f } (x y : displacement3d s),\n    x.to_vectr = y.to_vectr \u2192 x = y :=\n    begin\n        intros f s x y e,\n        cases x,\n        cases y,\n        simp *,\n        have h\u2081 : ({to_vectr := x} : displacement3d s).to_vectr = x := rfl,\n        simp [h\u2081] 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    : \u03a0 {f' : geom3d_frame} (s' : geom3d_space f' ), displacement3d s' := \n        \u03bb f' s',\n        \u27e8(p.to_vectr.expressed_in s')\u27e9\n\n\nnoncomputable def displacement3d.coords_in {f : geom3d_frame} {s : geom3d_space f } (p : displacement3d s) \n    : \u03a0 {f' : geom3d_frame} (s' : geom3d_space f' ), fin 3 \u2192 scalar := \n        \u03bb f' s',\n        \u03bbi, ((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    \u03bbi : 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\u2081 k\u2082 k\u2083 : real_scalar) : displacement3d s := displacement3d.mk (mk_vectr s \u27e8[k\u2081,k\u2082,k\u2083],rfl\u27e9) \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    \u27e8mk_vectr_prod (mk_vectr_prod p1.to_vectr p2.to_vectr) p3.to_vectr\u27e9\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 \u27e8(\u03bbi, if i = 0 then v0.to_vectr else if i = 1 then v1.to_vectr else v2.to_vectr),sorry,sorry\u27e9)\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 \u2022 v.to_vectr)\n@[simp]\nnoncomputable def neg_displacement3d (v : displacement3d s) : displacement3d s := \n    mk_displacement3d' s ((-1 : real_scalar) \u2022 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) := \u27e8 add_displacement3d_displacement3d \u27e9\nlemma add_assoc_displacement3d : \u2200 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) := \u27e8 add_displacement3d_displacement3d, add_assoc_displacement3d\u27e9 \n@[simp]\nnoncomputable def displacement3d_zero  := mk_displacement3d s 0 0 0\nnoncomputable instance : inhabited (displacement3d s) := \u27e8displacement3d_zero\u27e9\nnoncomputable instance has_zero_displacement3d : has_zero (displacement3d s) := \u27e8displacement3d_zero\u27e9\n\nlemma zero_add_displacement3d : \u2200 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\u2080 : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h\u2081 : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h\u2080, h\u2081] at x_property,\n    have h\u2082 : x'''.succ + 3 \u2264 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\u2083 := (add_le_add_iff_right 3).1 h\u2082,\n    simp only [nat.not_succ_le_zero] at h\u2083,\n    contradiction,\nend\n\nlemma add_zero_displacement3d : \u2200 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\u2080 : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h\u2081 : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h\u2080, h\u2081] at x_property,\n    have h\u2082 : x'''.succ + 3 \u2264 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\u2083 := (add_le_add_iff_right 3).1 h\u2082,\n    simp only [nat.not_succ_le_zero] at h\u2083,\n    contradiction,\nend\n\n@[simp]\nnoncomputable def nsmul_displacement3d : \u2115 \u2192 (displacement3d s) \u2192 (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) := \u27e8 \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\u27e9\n\nnoncomputable instance has_neg_displacement3d : has_neg (displacement3d s) := \u27e8neg_displacement3d\u27e9\nnoncomputable instance has_sub_displacement3d : has_sub (displacement3d s) := \u27e8 sub_displacement3d_displacement3d\u27e9 \nlemma sub_eq_add_neg_displacement3d : \u2200 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 : \u2200 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\u2080 : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h\u2081 : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h\u2080, h\u2081] at x_property,\n    have h\u2082 : x'''.succ + 3 \u2264 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\u2083 := (add_le_add_iff_right 3).1 h\u2082,\n    simp only [nat.not_succ_le_zero] at h\u2083,\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 : \u2200 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) := \u27e8\n    -- add_semigroup\n    add_displacement3d_displacement3d, \n    add_assoc_displacement3d,\n    add_comm_displacement3d,\n\u27e9\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) := \u27e8\nsmul_displacement3d,\n\u27e9\n\nlemma one_smul_displacement3d : \u2200 b : displacement3d s, (1 : real_scalar) \u2022 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 : \u2200 (x y : real_scalar) (b : displacement3d s), (x * y) \u2022 b = x \u2022 y \u2022 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) := \u27e8\none_smul_displacement3d,\nmul_smul_displacement3d,\n\u27e9 \n\nlemma smul_add_displacement3d : \u2200(r : real_scalar) (x y : displacement3d s), r \u2022 (x + y) = r \u2022 x + r \u2022 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 : \u2200(r : real_scalar), r \u2022 (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\u2080 : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h\u2081 : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h\u2080, h\u2081] at x_property,\n    have h\u2082 : x'''.succ + 3 \u2264 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\u2083 := (add_le_add_iff_right 3).1 h\u2082,\n    simp only [nat.not_succ_le_zero] at h\u2083,\n    contradiction,\nend\nnoncomputable instance distrib_mul_action_K_displacement3d : distrib_mul_action real_scalar (displacement3d s) := \u27e8\nsmul_add_displacement3d,\nsmul_zero_displacement3d,\n\u27e9 \n\n-- renaming vs template due to clash with name \"s\" for prevailing variable\nlemma add_smul_displacement3d : \u2200 (a b : real_scalar) (x : displacement3d s), (a + b) \u2022 x = a \u2022 x + b \u2022 x := \nbegin\n  intros,\n  ext,\n  exact right_distrib _ _ _,\nend\nlemma zero_smul_displacement3d : \u2200 (x : displacement3d s), (0 : real_scalar) \u2022 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\u2080 : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h\u2081 : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h\u2080, h\u2081] at x_1_property,\n    have h\u2082 : x'''.succ + 3 \u2264 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\u2083 := (add_le_add_iff_right 3).1 h\u2082,\n    simp only [nat.not_succ_le_zero] at h\u2083,\n    contradiction,\nend\nnoncomputable instance module_K_displacement3d : module real_scalar (displacement3d s) := \u27e8 add_smul_displacement3d, zero_smul_displacement3d \u27e9 \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) := \u27e8add_displacement3d_displacement3d\u27e9\nnoncomputable instance : has_zero (displacement3d s) := \u27e8displacement3d_zero\u27e9\nnoncomputable instance : has_neg (displacement3d s) := \u27e8neg_displacement3d\u27e9\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 -\u1d65 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 +\u1d65 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 +\u1d65 p.to_point)\n--@[simp]\n--def aff_displacement3d_group_action : displacement3d s \u2192 position3d s \u2192 position3d s := add_displacement3d_position3d real_scalar\nnoncomputable instance : has_vadd (displacement3d s) (position3d s) := \u27e8add_displacement3d_position3d\u27e9\n\nlemma zero_displacement3d_vadd'_a3 : \u2200 p : position3d s, (0 : displacement3d s) +\u1d65 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\u2080 : x'''.succ.succ.succ = x''' + 3 := rfl,\n    have h\u2081 : 1 + 1 + 1 = 0 + 3 := rfl,\n    rw [h\u2080, h\u2081] at x_property,\n    have h\u2082 : x'''.succ + 3 \u2264 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\u2083 := (add_le_add_iff_right 3).1 h\u2082,\n    simp only [nat.not_succ_le_zero] at h\u2083,\n    contradiction,\nend\nlemma displacement3d_add_assoc'_a3 : \u2200 (g3 g2 : displacement3d s) (p : position3d s), g3 +\u1d65 (g2 +\u1d65 p) = (g3 + g2) +\u1d65 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\u27e8 zero_displacement3d_vadd'_a3, \nbegin\n    let h0 := displacement3d_add_assoc'_a3,\n    intros,\n    exact (h0 g\u2081 g\u2082 p).symm\nend\u27e9 \n--@[simp]\n\nnoncomputable instance position3d_has_vsub : has_vsub (displacement3d s) (position3d s) := \u27e8 sub_position3d_position3d\u27e9 \n\ninstance : nonempty (position3d s) := \u27e8mk_position3d s 0 0 0\u27e9\nnoncomputable instance : inhabited (position3d s) := \u27e8mk_position3d s 0 0 0\u27e9\n\nlemma position3d_vsub_vadd_a3 : \u2200 (p3 p2 : (position3d s)), (p3 -\u1d65 p2) +\u1d65 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 : \u2200 (g : displacement3d s) (p : position3d s), g +\u1d65 p -\u1d65 p = g := \nbegin\n    intros, ext,\n    repeat {\n    have h0 : ((g +\u1d65 p -\u1d65 p) : displacement3d s).to_vectr = (g.to_vectr +\u1d65 p.to_point -\u1d65 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\u27e8 \n    begin\n        exact position3d_vsub_vadd_a3,\n    end,\n    begin\n        exact position3d_vadd_vsub_a3,\n    end,\n\u27e9\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) : \u03a0 {f2 : geom3d_frame} (s2 : geom3d_space f2), \n        geom3d_transform s3 s2 := --(position3d s2) \u2243\u1d43[scalar] (position3d s3) := \n    \u03bb f2 s2,\n        \u27e8s3.fm_tr s2\u27e9\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) := \u27e8sp3.mk_geom3d_transform_to sp2\u27e9\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 := \u27e8(ttr.1).symm\u27e9\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 \u2192 geom3d_transform sp1 sp3 := \u03bbttr_, \u27e8(ttr.1).trans ttr_.1\u27e9\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 \u2192 position3d s2 :=\n    \u03bbt : position3d s3,\n    \u27e8tr.to_fm_tr.to_equiv t.to_point\u27e9\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 \u2192 displacement3d s2 :=\n    \u03bbd,\n    let as_pt : point s3 := \u27e8\u03bbi, mk_pt real_scalar (d.coords i).coord\u27e9 in\n    let tr_pt := (tr.to_equiv as_pt) in\n    \u27e8\u27e8\u03bbi, mk_vec real_scalar (tr_pt.coords i).coord\u27e9\u27e9\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 : \u03a0 {dim : \u2115} {id_vec : fin dim \u2192 \u2115} {f : fm K dim id_vec}, spc K f \u2192 Type\n-/\n\nstructure orientation3d extends orientation s :=\nmk ::\n\nnoncomputable instance o3i : inhabited (orientation3d s) := \u27e8\n    \u27e8mk_orientation s (\u03bbi, mk_vectr s \u27e8[0,0,0],rfl\u27e9)\u27e9\n\u27e9\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 := \u27e8mk_orientation s (\u03bbi, 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 )\u27e9\n\n    : orientation3d s := \u27e8mk_orientation s (\u03bbi, if i.1 = 0 then ax1.to_vectr else if i.1 = 1 then ax2.to_vectr else ax3.to_vectr )\u27e9\n\n\nnoncomputable def mk_orientation3d (s1 s2 s3 s4 s5 s6 s7 s8 s9 : real_scalar)\n    : orientation3d s := \u27e8mk_orientation s (\u03bbi, 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 )\u27e9\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 := \u27e8mk_orientation s \n        (\u03bbi, 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 )\u27e9\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 := \u27e8mk_orientation s (\u03bbi, if i.1 = 0 then ax1.to_vectr else if i.1 = 1 then ax2.to_vectr else ax3.to_vectr )\u27e9\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 \u2192 orientation3d s2 :=\n    \u03bbo : orientation3d s3,\n    \u27e8mk_orientation s2 \n        (\u03bbi, if i.1 = 0 then (tr.to_fm_tr.transform_vectr (o.to_orientation.to_vectr_basis.basis_vectrs \u27e80,by linarith\u27e9)) \n        else if i.1 = 1 then (tr.to_fm_tr.transform_vectr (o.to_orientation.to_vectr_basis.basis_vectrs \u27e81,by linarith\u27e9))\n        else (tr.to_fm_tr.transform_vectr (o.to_orientation.to_vectr_basis.basis_vectrs \u27e82,by linarith\u27e9)) )\u27e9\n\n\n   -- \u27e8tr.to_fm_tr.transform_orientation o.to_orientation\u27e9\u27e9\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 := \u27e8mk_rotation s (\u03bbi, if i.1 = 0 then ax1.to_vectr else if i.1 = 1 then ax2.to_vectr else ax3.to_vectr )\u27e9\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 := \u27e8mk_rotation s (\u03bbi, 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 )\u27e9\n\nnoncomputable instance r3i : inhabited (rotation3d s) := \u27e8\n    mk_rotation3d s 1 1 1 1 1 1 1 1 1\n\u27e9\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 := \u27e8mk_orientation s (\u03bbi, if i.1 = 0 then ax1.to_vectr else if i.1 = 1 then ax2.to_vectr else ax3.to_vectr )\u27e9\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 := \u27e8orientation,position\u27e9\n \n noncomputable instance p3i : inhabited (pose3d s) := \u27e8\n    (\n    mk_pose3d _ \n    (mk_orientation3d _ 0 0 0 0 0 0 0 0 0)\n    (mk_position3d _ 0 0 0)\n    )\n\u27e9\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 \u2192 pose3d s2 :=\n    \u03bbp :_,\n    (\u27e8tr.transform_orientation p.orientation, tr.transform_position3d p.position\u27e9:pose3d s2)\n\n\nnotation tr\u2b1dt := 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 \u2192 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 \u2192 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 \u2964 T` and `R : B \u2964 T`, an object in\n`comma L R` is a morphism `hom : L.obj left \u27f6 R.obj right` for some objects `left : A` and\n`right : B`, and a morphism in `comma L R` between `hom : L.obj left \u27f6 R.obj right` and\n`hom' : L.obj left' \u27f6 R.obj right'` is a commutative square\n\n```\nL.obj left   \u27f6   L.obj left'\n      |               |\n  hom |               | hom'\n      \u2193               \u2193\nR.obj right  \u27f6   R.obj right',\n```\n\nwhere the top and bottom morphism come from morphisms `left \u27f6 left'` and `right \u27f6 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\u2081 v\u2082 v\u2083 v\u2084 v\u2085 u\u2081 u\u2082 u\u2083 u\u2084 u\u2085\nvariables {A : Type u\u2081} [category.{v\u2081} A]\nvariables {B : Type u\u2082} [category.{v\u2082} B]\nvariables {T : Type u\u2083} [category.{v\u2083} 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 \u27f6 R.obj right`.  -/\nstructure comma (L : A \u2964 T) (R : B \u2964 T) : Type (max u\u2081 u\u2082 v\u2083) :=\n(left : A . obviously)\n(right : B . obviously)\n(hom : L.obj left \u27f6 R.obj right)\n\n-- Satisfying the inhabited linter\ninstance comma.inhabited [inhabited T] : inhabited (comma (\ud835\udfed T) (\ud835\udfed T)) :=\n{ default :=\n  { left := default T,\n    right := default T,\n    hom := \ud835\udfd9 (default T) } }\n\nvariables {L : A \u2964 T} {R : B \u2964 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 \u27f6 Y.left . obviously)\n(right : X.right \u27f6 Y.right . obviously)\n(w' : L.map left \u226b Y.hom = X.hom \u226b 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 := \ud835\udfd9 _,\n    right := \ud835\udfd9 _ } }\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 := \u03bb X,\n  { left := \ud835\udfd9 X.left,\n    right := \ud835\udfd9 X.right },\n  comp := \u03bb X Y Z f g,\n  { left := f.left \u226b g.left,\n    right := f.right \u226b g.right } }\n\nnamespace comma\n\nsection\nvariables {X Y Z : comma L R} {f : X \u27f6 Y} {g : Y \u27f6 Z}\n\n@[simp] lemma id_left  : ((\ud835\udfd9 X) : comma_morphism X X).left = \ud835\udfd9 X.left := rfl\n@[simp] lemma id_right : ((\ud835\udfd9 X) : comma_morphism X X).right = \ud835\udfd9 X.right := rfl\n@[simp] lemma comp_left  : (f \u226b g).left  = f.left \u226b g.left   := rfl\n@[simp] lemma comp_right : (f \u226b g).right = f.right \u226b 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 \u2964 A :=\n{ obj := \u03bb X, X.left,\n  map := \u03bb _ _ 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 \u2964 B :=\n{ obj := \u03bb X, X.right,\n  map := \u03bb _ _ 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 \u22d9 L` and `snd \u22d9 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 \u22d9 L \u27f6 snd L R \u22d9 R :=\n{ app := \u03bb 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\u2081 L\u2082 L\u2083 : A \u2964 T} {R\u2081 R\u2082 R\u2083 : B \u2964 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\u2081 R\u2081} (l : X.left \u2245 Y.left) (r : X.right \u2245 Y.right)\n  (h : L\u2081.map l.hom \u226b Y.hom = X.hom \u226b R\u2081.map r.hom) : X \u2245 Y :=\n{ hom := { left := l.hom, right := r.hom },\n  inv :=\n  { left := l.inv,\n    right := r.inv,\n    w' := begin\n      rw [\u2190L\u2081.map_iso_inv l, iso.inv_comp_eq, L\u2081.map_iso_hom, reassoc_of h, \u2190 R\u2081.map_comp],\n      simp\n    end, } }\n\n/-- A natural transformation `L\u2081 \u27f6 L\u2082` induces a functor `comma L\u2082 R \u2964 comma L\u2081 R`. -/\n@[simps]\ndef map_left (l : L\u2081 \u27f6 L\u2082) : comma L\u2082 R \u2964 comma L\u2081 R :=\n{ obj := \u03bb X,\n  { left  := X.left,\n    right := X.right,\n    hom   := l.app X.left \u226b X.hom },\n  map := \u03bb X Y f,\n  { left  := f.left,\n    right := f.right } }\n\n/-- The functor `comma L R \u2964 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 (\ud835\udfd9 L) \u2245 \ud835\udfed _ :=\n{ hom :=\n  { app := \u03bb X, { left := \ud835\udfd9 _, right := \ud835\udfd9 _ } },\n  inv :=\n  { app := \u03bb X, { left := \ud835\udfd9 _, right := \ud835\udfd9 _ } } }\n\n/-- The functor `comma L\u2081 R \u2964 comma L\u2083 R` induced by the composition of two natural transformations\n    `l : L\u2081 \u27f6 L\u2082` and `l' : L\u2082 \u27f6 L\u2083` is naturally isomorphic to the composition of the two functors\n    induced by these natural transformations. -/\n@[simps]\ndef map_left_comp (l : L\u2081 \u27f6 L\u2082) (l' : L\u2082 \u27f6 L\u2083) :\n  (map_left R (l \u226b l')) \u2245 (map_left R l') \u22d9 (map_left R l) :=\n{ hom :=\n  { app := \u03bb X, { left := \ud835\udfd9 _, right := \ud835\udfd9 _ } },\n  inv :=\n  { app := \u03bb X, { left := \ud835\udfd9 _, right := \ud835\udfd9 _ } } }\n\n/-- A natural transformation `R\u2081 \u27f6 R\u2082` induces a functor `comma L R\u2081 \u2964 comma L R\u2082`. -/\n@[simps]\ndef map_right (r : R\u2081 \u27f6 R\u2082) : comma L R\u2081 \u2964 comma L R\u2082 :=\n{ obj := \u03bb X,\n  { left  := X.left,\n    right := X.right,\n    hom   := X.hom \u226b r.app X.right },\n  map := \u03bb X Y f,\n  { left  := f.left,\n    right := f.right } }\n\n/-- The functor `comma L R \u2964 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 (\ud835\udfd9 R) \u2245 \ud835\udfed _ :=\n{ hom :=\n  { app := \u03bb X, { left := \ud835\udfd9 _, right := \ud835\udfd9 _ } },\n  inv :=\n  { app := \u03bb X, { left := \ud835\udfd9 _, right := \ud835\udfd9 _ } } }\n\n/-- The functor `comma L R\u2081 \u2964 comma L R\u2083` induced by the composition of the natural transformations\n    `r : R\u2081 \u27f6 R\u2082` and `r' : R\u2082 \u27f6 R\u2083` is naturally isomorphic to the composition of the functors\n    induced by these natural transformations. -/\n@[simps]\ndef map_right_comp (r : R\u2081 \u27f6 R\u2082) (r' : R\u2082 \u27f6 R\u2083) :\n  (map_right L (r \u226b r')) \u2245 (map_right L r) \u22d9 (map_right L r') :=\n{ hom :=\n  { app := \u03bb X, { left := \ud835\udfd9 _, right := \ud835\udfd9 _ } },\n  inv :=\n  { app := \u03bb X, { left := \ud835\udfd9 _, right := \ud835\udfd9 _ } } }\n\nend\n\nsection\nvariables {C : Type u\u2084} [category.{v\u2084} C] {D : Type u\u2085} [category.{v\u2085} D]\n\n/-- The functor `(F \u22d9 L, R) \u2964 (L, R)` -/\n@[simps] def pre_left (F: C \u2964 A) (L : A \u2964 T) (R : B \u2964 T) : comma (F \u22d9 L) R \u2964 comma L R :=\n{ obj := \u03bb X, { left := F.obj X.left, right := X.right, hom := X.hom },\n  map := \u03bb X Y f, { left := F.map f.left, right := f.right, w' := by simpa using f.w } }\n\n/-- The functor `(F \u22d9 L, R) \u2964 (L, R)` -/\n@[simps] def pre_right (L : A \u2964 T) (F: C \u2964 B) (R : B \u2964 T) : comma L (F \u22d9 R) \u2964 comma L R :=\n{ obj := \u03bb X, { left := X.left, right := F.obj X.right, hom := X.hom },\n  map := \u03bb X Y f, { left := f.left, right := F.map f.right, w' := by simp } }\n\n/-- The functor `(L, R) \u2964 (L \u22d9 F, R \u22d9 F)` -/\n@[simps] def post (L : A \u2964 T) (R : B \u2964 T) (F: T \u2964 C) : comma L R \u2964 comma (L \u22d9 F) (R \u22d9 F) :=\n{ obj := \u03bb X, { left := X.left, right := X.right, hom := F.map X.hom },\n  map := \u03bb X Y f, { left := f.left, right := f.right, w' :=\n    by { simp only [functor.comp_map, \u2190F.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 `\u03b1` as a list of `\u03b1`.\n@[reducible,inline]\nprotected\ndefinition underlying {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (l : exhaustive_list (subtype p)) : list \u03b1 :=\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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} {l\u2081 l\u2082 : exhaustive_list (subtype p)} : l\u2081.underlying = l\u2082.underlying \u2192 l\u2081 = l\u2082 :=\n  \u03bb h, subtype.eq (list.inj_of_map_inj subtype.val_injective h)\n\nprotected\nlemma underlying_nodup {\u03b1 : Type _} {p : \u03b1 \u2192 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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (l : exhaustive_list (subtype p)) : \u2200 x, p x \u2192 x \u2208 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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (l : exhaustive_list (subtype p)) : \u2200 x, p x \u2194 x \u2208 l.underlying :=\n  begin\n    intros x,\n    split,\n    show p x \u2192 _,\n      from l.underlying_exhaustive x,\n    show _ \u2192 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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (l\u2081 l\u2082 : exhaustive_list (subtype p)) : list.perm l\u2081.underlying l\u2082.underlying :=\n  list.perm.map subtype.val (l\u2081.perm l\u2082)\n\n--- The empty list is exhaustive on empty subtypes.\n@[reducible]\nprotected\ndefinition of_empty {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (h : \u2200 a, \u00acp 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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (h : \u2200 a, \u00acp 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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (h : \u2200 a, \u00acp 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 {\u03b1 : Type _} [decidable_eq \u03b1] (a : \u03b1) : exhaustive_list {x // x=a} :=\n  subtype.mk [\u27e8a,rfl\u27e9] $\n    begin\n      split,\n      exact list.nodup.cons (list.not_mem_nil _) list.nodup.nil,\n      show \u2200 x, _, {\n        intros x,\n        have : x = \u27e8a,rfl\u27e9 := 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 {\u03b1 : Type _} [decidable_eq \u03b1] {a : \u03b1} : (exhaustive_list.singleton a).underlying = [a] :=\n  rfl\n\n--- The uniqueness of `exhaustive_list` on singleton subtypes.\nprotected\nlemma singleton_unique {\u03b1 : Type _} [decidable_eq \u03b1] {a : \u03b1} : \u2200 (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 {\u03b1 : Type _} {p q : \u03b1 \u2192 Prop} (h : \u2200 a, p a \u2194 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 {\u03b1 : Type _} {p q : \u03b1 \u2192 Prop} (h : \u2200 a, p a  \u2194 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 `\u03b1` has an `exhaustive_list`, then each decidable subtype of `\u03b1` does.\n@[reducible]\nprotected\ndefinition restrict {\u03b1 : Type _} (l : exhaustive_list \u03b1) (p : \u03b1 \u2192 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 \u27e8x.val,hx\u27e9, {\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 {\u03b1 : Type _} (l : exhaustive_list \u03b1) {p : \u03b1 \u2192 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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (l : exhaustive_list (subtype p)) (q : \u03b1 \u2192 Prop) [decidable_pred q] : exhaustive_list {x // p x \u2227 q x} :=\n  let l' := (l.restrict (q \u2218 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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (l : exhaustive_list (subtype p)) (q : \u03b1 \u2192 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 : \u2200 (x : {x : subtype p // q x.val}), x.val.val = (subtype.val \u2218 subtype.val) x,\n      by intros; refl,\n    rw [list.map_equiv this]; dsimp *,\n    rw [\u2190list.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 \u03b1` with a decidable predicator `p : \u03b1 \u2192 Prop`.\n@[reducible]\nprotected\ndefinition partition {\u03b1 : Type _} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : exhaustive_list \u03b1) : exhaustive_list (subtype p) \u00d7 exhaustive_list {x // \u00acp x} :=\n  (l.restrict p, l.restrict (not \u2218 p))\n\n--- Underlying lists of partitioned `exhaustive_list`.\n@[simp]\nprotected\nlemma partition_underlying {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} [decidable_pred p] {l : exhaustive_list \u03b1} : (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 {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (l : exhaustive_list (subtype p)) (q : \u03b1 \u2192 Prop) [decidable_pred q] : exhaustive_list {x // p x \u2227 q x} \u00d7 exhaustive_list {x // p x \u2227 \u00acq x} :=\n  (l.subrestrict q, l.subrestrict (not \u2218 q))\n\n--- Underlying lists of partitioned `exhaustive_list`.\n@[simp]\nprotected\nlemma subpartition_underlying {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} {l : exhaustive_list (subtype p)} {q : \u03b1 \u2192 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 {\u03b1 : Type _} [decidable_eq \u03b1] {p q : \u03b1 \u2192 Prop} (lp : exhaustive_list (subtype p)) (lq : exhaustive_list (subtype q)) : exhaustive_list {x // p x \u2228 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 \u2200 x, x \u2208 _, {\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 \u27e8x.val,hx\u27e9,\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 \u27e8x.val,hx\u27e9,\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 {\u03b1 : Type _} [decidable_eq \u03b1] {p q : \u03b1 \u2192 Prop} {lp : exhaustive_list (subtype p)} {lq : exhaustive_list (subtype q)} : (lp.union lq).underlying = lp.underlying \u222a 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 \u2228 q x}) _,\n    rw [list.union_of_map_inj (@subtype.val_injective \u03b1 _)],\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 {\u03b1 : Type _} [decidable_eq \u03b1] {p q : \u03b1 \u2192 Prop} {lp : exhaustive_list (subtype p)} {lq : exhaustive_list (subtype q)} : (\u2200 x, \u00ac(p x \u2227 q x)) \u2192 (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 \u27e8hpx,hqx\u27e9\n  end\n\nend exhaustive_list\n\nnamespace is_finite\n\n--- Empty subtype is finite\ndefinition of_empty {\u03b1 : Type _} {p : \u03b1 \u2192 Prop} (h : \u2200 x, \u00acp x) : is_finite {x // p x} :=\n  begin\n    constructor,\n    existsi 0,\n    existsi (\u03bb 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 {\u03b1 : Type _} [decidable_eq \u03b1] [is_finite \u03b1] {p : \u03b1 \u2192 Prop} [decidable_pred p] : is_finite (subtype p) :=\n  begin\n    cases has_exhaustive_list \u03b1 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 {\u03b1 : Type _} [decidable_eq \u03b1] {p q : \u03b1 \u2192 Prop} (hpq : \u2200 x, p x \u2194 q x) : is_finite (subtype p) \u2192 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 {\u03b1 : Type _} [decidable_eq \u03b1] {p : \u03b1 \u2192 Prop} : is_finite (subtype p) \u2192 \u03a0 (q : \u03b1 \u2192 Prop) [decidable_pred q], is_finite {x // p x \u2227 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 {\u03b1 : Type _} [decidable_eq \u03b1] {p q : \u03b1 \u2192 Prop} : is_finite (subtype p) \u2192 is_finite (subtype q) \u2192 is_finite {x // p x \u2228 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 {\u03b1 : Type _} [decidable_eq \u03b1] {p : \u03b1 \u2192 Prop} {q : subtype p \u2192 Prop} : is_finite (subtype q) \u2192 \u2200 (a : \u03b1), idecidable (\u2203 (h : p a), q \u27e8a,h\u27e9) :=\n  begin\n    intros hfin a,\n    constructor,\n    cases @is_finite.has_exhaustive_list _ hfin with l,\n    refine dite (a \u2208 l.underlying.map subtype.val) _ _,\n    show a \u2208 _ \u2192 _, {\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 \u25b8 x.property,\n      have : x = \u27e8a,hpa\u27e9,\n        from subtype.eq hxa.left.symm,\n      rw [this] at hqx,\n      exact \u27e8hpa,hqx\u27e9\n    },\n    show a \u2209 _ \u2192 _, {\n      intros ha; right,\n      intros h; cases h with hpa hqa,\n      let x : subtype p := \u27e8a,hpa\u27e9,\n      have : x \u2208 l.underlying,\n        from (l.underlying_mem_iff x).mp hqa,\n      have: x.val \u2208 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 {\u03b1 : Type _} [decidable_eq \u03b1] [is_finite \u03b1] {p : \u03b1 \u2192 Prop} {q : subtype p \u2192 Prop} [\u2200 (a : \u03b1), decidable (\u2203 (h : p a), q \u27e8a,h\u27e9)] : is_finite (subtype q) :=\n  begin\n    cases is_finite.has_exhaustive_list \u03b1 with l,\n    apply is_finite.of_exhaustive_list,\n    let l' := l.restrict (\u03bb a, \u2203 (h : p a), q \u27e8a,h\u27e9),\n    have : \u2200 a, (\u2203 h, q \u27e8a,h\u27e9) \u2194 (p a \u2227 \u2200 h, q \u27e8a,h\u27e9), {\n      intros a,\n      split,\n      show (\u2203 h, q \u27e8a,h\u27e9) \u2192 _, {\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 \u2227 \u2200 h, q \u27e8a,h\u27e9) \u2192 _, {\n        intros hpqa,\n        exact \u27e8hpqa.left, hpqa.right hpqa.left\u27e9\n      }\n    },\n    let l'' := l'.of_iff this,\n    let f : {a // p a \u2227 \u2200 h, q \u27e8a,h\u27e9} \u2192 subtype q :=\n      \u03bb x, subtype.mk \u27e8x.val, x.property.left\u27e9 $\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\u2218subtype.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 [\u2190subtype.eta z.val z.val.property] at hqa,\n        let x : {a // p a \u2227 \u2200 h, q \u27e8a,h\u27e9} :=\n          subtype.mk z.val.val\n            (and.intro z.val.property (\u03bb 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\u1601 : Y\u1601 \u27f6 X\u1601` for a morphism `f : X \u27f6 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* `\u03b7_` and `\u03b5_` denote the coevaluation and evaluation morphism of an exact pairing.\n* `X\u1601` and `\u1601X` 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 \u2297 Y` and `Y\u1601 \u2297 X\u1601` 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 `\u1601` gives an equivalence of categories `C \u2245 (C\u1d52\u1d56)\u1d39\u1d52\u1d56`.\n* Define pivotal categories (rigid categories equipped with a natural isomorphism `\u1601\u1601 \u2245 \ud835\udfd9 C`).\n\n## Notes\n\nAlthough we construct the adjunction `tensor_left Y \u22a3 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\n\nnoncomputable section\n\nnamespace CategoryTheory\n\nvariable {C : Type u\u2081} [Category.{v\u2081} 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 : \ud835\udfd9_ C \u27f6 X \u2297 Y\n  evaluation : Y \u2297 X \u27f6 \ud835\udfd9_ C\n  coevaluation_evaluation' :\n    (\ud835\udfd9 Y \u2297 coevaluation) \u226b (\u03b1_ _ _ _).inv \u226b (evaluation \u2297 \ud835\udfd9 Y) = (\u03c1_ Y).Hom \u226b (\u03bb_ Y).inv := by\n    obviously\n  evaluation_coevaluation' :\n    (coevaluation \u2297 \ud835\udfd9 X) \u226b (\u03b1_ _ _ _).Hom \u226b (\ud835\udfd9 X \u2297 evaluation) = (\u03bb_ X).Hom \u226b (\u03c1_ X).inv := by\n    obviously\n#align category_theory.exact_pairing CategoryTheory.ExactPairing\n\nopen ExactPairing\n\n-- mathport name: expr\u03b7_\nnotation \"\u03b7_\" => ExactPairing.coevaluation\n\n-- mathport name: expr\u03b5_\nnotation \"\u03b5_\" => 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 (\ud835\udfd9_ C) (\ud835\udfd9_ C)\n    where\n  coevaluation := (\u03c1_ _).inv\n  evaluation := (\u03c1_ _).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 \"\u1601\" => leftDual\n\n-- mathport name: right_dual\npostfix:1024 \"\u1601\" => rightDual\n\ninstance hasRightDualUnit : HasRightDual (\ud835\udfd9_ C) where rightDual := \ud835\udfd9_ C\n#align category_theory.has_right_dual_unit CategoryTheory.hasRightDualUnit\n\ninstance hasLeftDualUnit : HasLeftDual (\ud835\udfd9_ C) where leftDual := \ud835\udfd9_ C\n#align category_theory.has_left_dual_unit CategoryTheory.hasLeftDualUnit\n\ninstance hasRightDualLeftDual {X : C} [HasLeftDual X] : HasRightDual \u1601X where rightDual := X\n#align category_theory.has_right_dual_left_dual CategoryTheory.hasRightDualLeftDual\n\ninstance hasLeftDualRightDual {X : C} [HasRightDual X] : HasLeftDual X\u1601 where leftDual := X\n#align category_theory.has_left_dual_right_dual CategoryTheory.hasLeftDualRightDual\n\n@[simp]\ntheorem leftDual_rightDual {X : C} [HasRightDual X] : \u1601X\u1601 = X :=\n  rfl\n#align category_theory.left_dual_right_dual CategoryTheory.leftDual_rightDual\n\n@[simp]\ntheorem rightDual_leftDual {X : C} [HasLeftDual X] : (\u1601X)\u1601 = 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\u1601 : X\u1601 \u27f6 Y\u1601` of a morphism `f : X \u27f6 Y`. -/\ndef rightAdjointMate {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X \u27f6 Y) : Y\u1601 \u27f6 X\u1601 :=\n  (\u03c1_ _).inv \u226b (\ud835\udfd9 _ \u2297 \u03b7_ _ _) \u226b (\ud835\udfd9 _ \u2297 f \u2297 \ud835\udfd9 _) \u226b (\u03b1_ _ _ _).inv \u226b (\u03b5_ _ _ \u2297 \ud835\udfd9 _) \u226b (\u03bb_ _).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 `\u1601f : \u1601Y \u27f6 \u1601X` of a morphism `f : X \u27f6 Y`. -/\ndef leftAdjointMate {X Y : C} [HasLeftDual X] [HasLeftDual Y] (f : X \u27f6 Y) : \u1601Y \u27f6 \u1601X :=\n  (\u03bb_ _).inv \u226b (\u03b7_ (\u1601X) X \u2297 \ud835\udfd9 _) \u226b ((\ud835\udfd9 _ \u2297 f) \u2297 \ud835\udfd9 _) \u226b (\u03b1_ _ _ _).Hom \u226b (\ud835\udfd9 _ \u2297 \u03b5_ _ _) \u226b (\u03c1_ _).Hom\n#align category_theory.left_adjoint_mate CategoryTheory.leftAdjointMate\n\n-- mathport name: right_adjoint_mate\nnotation f \"\u1601\" => rightAdjointMate f\n\n-- mathport name: left_adjoint_mate\nnotation \"\u1601\" 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] : \ud835\udfd9 X\u1601 = \ud835\udfd9 (X\u1601) := 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] : (\u1601\ud835\udfd9 X) = \ud835\udfd9 (\u1601X) := 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 \u27f6 Y}\n    {g : X\u1601 \u27f6 Z} :\n    f\u1601 \u226b g =\n      (\u03c1_ (Y\u1601)).inv \u226b\n        (\ud835\udfd9 _ \u2297 \u03b7_ X (X\u1601)) \u226b (\ud835\udfd9 _ \u2297 f \u2297 g) \u226b (\u03b1_ (Y\u1601) Y Z).inv \u226b (\u03b5_ Y (Y\u1601) \u2297 \ud835\udfd9 _) \u226b (\u03bb_ 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, \u2190 tensor_id_comp_id_tensor g, category.assoc, category.assoc,\n    category.assoc, category.assoc, id_tensor_comp_tensor_id_assoc, \u2190 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 \u27f6 Y}\n    {g : (\u1601X) \u27f6 Z} :\n    (\u1601f) \u226b g =\n      (\u03bb_ _).inv \u226b\n        (\u03b7_ (\u1601X) X \u2297 \ud835\udfd9 _) \u226b ((g \u2297 f) \u2297 \ud835\udfd9 _) \u226b (\u03b1_ _ _ _).Hom \u226b (\ud835\udfd9 _ \u2297 \u03b5_ _ _) \u226b (\u03c1_ _).Hom :=\n  by\n  dsimp only [left_adjoint_mate]\n  rw [category.assoc, category.assoc, associator_naturality_assoc, associator_naturality_assoc, \u2190\n    id_tensor_comp_tensor_id _ g, category.assoc, category.assoc, category.assoc, category.assoc,\n    tensor_id_comp_id_tensor_assoc, \u2190 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 \u27f6 Y} {g : Y \u27f6 Z} : (f \u226b g)\u1601 = g\u1601 \u226b f\u1601 :=\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 [\u2190 category.id_comp g, tensor_comp]\n  rw [\u2190 category.assoc]\n  symm; iterate 2 trans; rw [\u2190 category.assoc]; apply eq_whisker\n  repeat' rw [\u2190 id_tensor_comp]; congr 1\n  rw [\u2190 id_tensor_comp_tensor_id (\u03bb_ (X\u1601)).Hom g, id_tensor_right_unitor_inv, category.assoc,\n    category.assoc, right_unitor_inv_naturality_assoc, \u2190 associator_naturality_assoc, tensor_id,\n    tensor_id_comp_id_tensor_assoc, \u2190 associator_naturality_assoc]\n  slice_rhs 2 3 =>\n    rw [\u2190 tensor_comp, tensor_id, category.comp_id, \u2190 category.id_comp (\u03b7_ Y (Y\u1601)), tensor_comp]\n  rw [\u2190 id_tensor_comp_tensor_id _ (\u03b7_ Y (Y\u1601)), \u2190 tensor_id]\n  repeat' rw [category.assoc]\n  rw [pentagon_hom_inv_assoc, \u2190 associator_naturality_assoc, associator_inv_naturality_assoc]\n  slice_rhs 5 7 => rw [\u2190 comp_tensor_id, \u2190 comp_tensor_id, evaluation_coevaluation, comp_tensor_id]\n  rw [associator_inv_naturality_assoc]\n  slice_rhs 4 5 => rw [\u2190 tensor_comp, left_unitor_naturality, tensor_comp]\n  repeat' rw [category.assoc]\n  rw [triangle_assoc_comp_right_inv_assoc, \u2190 left_unitor_tensor_assoc, left_unitor_naturality_assoc,\n    unitors_equal, \u2190 category.assoc, \u2190 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 \u27f6 Y}\n    {g : Y \u27f6 Z} : (\u1601f \u226b g) = (\u1601g) \u226b \u1601f :=\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 [\u2190 category.id_comp g, tensor_comp]\n  rw [\u2190 category.assoc]\n  symm; iterate 2 trans; rw [\u2190 category.assoc]; apply eq_whisker\n  repeat' rw [\u2190 comp_tensor_id]; congr 1\n  rw [\u2190 tensor_id_comp_id_tensor g (\u03c1_ (\u1601X)).Hom, left_unitor_inv_tensor_id, category.assoc,\n    category.assoc, left_unitor_inv_naturality_assoc, \u2190 associator_inv_naturality_assoc, tensor_id,\n    id_tensor_comp_tensor_id_assoc, \u2190 associator_inv_naturality_assoc]\n  slice_rhs 2 3 =>\n    rw [\u2190 tensor_comp, tensor_id, category.comp_id, \u2190 category.id_comp (\u03b7_ (\u1601Y) Y), tensor_comp]\n  rw [\u2190 tensor_id_comp_id_tensor (\u03b7_ (\u1601Y) Y), \u2190 tensor_id]\n  repeat' rw [category.assoc]\n  rw [pentagon_inv_hom_assoc, \u2190 associator_inv_naturality_assoc, associator_naturality_assoc]\n  slice_rhs 5 7 => rw [\u2190 id_tensor_comp, \u2190 id_tensor_comp, coevaluation_evaluation, id_tensor_comp]\n  rw [associator_naturality_assoc]\n  slice_rhs 4 5 => rw [\u2190 tensor_comp, right_unitor_naturality, tensor_comp]\n  repeat' rw [category.assoc]\n  rw [triangle_assoc_comp_left_inv_assoc, \u2190 right_unitor_tensor_assoc,\n    right_unitor_naturality_assoc, \u2190 unitors_equal, \u2190 category.assoc, \u2190 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' \u2297 X \u27f6 Z) \u2243 (X \u27f6 Y \u2297 Z)`\nby \"pulling the string on the left\" up or down.\n\nThis gives the adjunction `tensor_left_adjunction Y Y' : tensor_left Y' \u22a3 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' \u2297 X \u27f6 Z) \u2243 (X \u27f6 Y \u2297 Z)\n    where\n  toFun f := (\u03bb_ _).inv \u226b (\u03b7_ _ _ \u2297 \ud835\udfd9 _) \u226b (\u03b1_ _ _ _).Hom \u226b (\ud835\udfd9 _ \u2297 f)\n  invFun f := (\ud835\udfd9 Y' \u2297 f) \u226b (\u03b1_ _ _ _).inv \u226b (\u03b5_ _ _ \u2297 \ud835\udfd9 _) \u226b (\u03bb_ _).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, \u2190 tensor_id_comp_id_tensor]\n    slice_lhs 2 5 => simp only [\u2190 tensor_id, associator_inv_conjugation]\n    have c :\n      (\u03b1_ Y' (Y \u2297 Y') X).Hom \u226b\n          (\ud835\udfd9 Y' \u2297 (\u03b1_ Y Y' X).Hom) \u226b (\u03b1_ Y' Y (Y' \u2297 X)).inv \u226b (\u03b1_ (Y' \u2297 Y) Y' X).inv =\n        (\u03b1_ _ _ _).inv \u2297 \ud835\udfd9 _\n    pure_coherence\n    slice_lhs 4 7 => rw [c]\n    slice_lhs 3 5 => rw [\u2190 comp_tensor_id, \u2190 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 [\u2190 associator_naturality]\n    slice_lhs 2 3 => rw [tensor_id, tensor_id_comp_id_tensor, \u2190 id_tensor_comp_tensor_id]\n    slice_lhs 3 6 => simp only [\u2190 tensor_id, associator_inv_conjugation]\n    have c :\n      (\u03b1_ (Y \u2297 Y') Y Z).Hom \u226b\n          (\u03b1_ Y Y' (Y \u2297 Z)).Hom \u226b (\ud835\udfd9 Y \u2297 (\u03b1_ Y' Y Z).inv) \u226b (\u03b1_ Y (Y' \u2297 Y) Z).inv =\n        (\u03b1_ _ _ _).Hom \u2297 \ud835\udfd9 Z\n    pure_coherence\n    slice_lhs 5 8 => rw [c]\n    slice_lhs 4 6 => rw [\u2190 comp_tensor_id, \u2190 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 \u2297 Y \u27f6 Z) \u2243 (X \u27f6 Z \u2297 Y')`\nby \"pulling the string on the right\" up or down.\n-/\ndef tensorRightHomEquiv (X Y Y' Z : C) [ExactPairing Y Y'] : (X \u2297 Y \u27f6 Z) \u2243 (X \u27f6 Z \u2297 Y')\n    where\n  toFun f := (\u03c1_ _).inv \u226b (\ud835\udfd9 _ \u2297 \u03b7_ _ _) \u226b (\u03b1_ _ _ _).inv \u226b (f \u2297 \ud835\udfd9 _)\n  invFun f := (f \u2297 \ud835\udfd9 _) \u226b (\u03b1_ _ _ _).Hom \u226b (\ud835\udfd9 _ \u2297 \u03b5_ _ _) \u226b (\u03c1_ _).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, \u2190 id_tensor_comp_tensor_id]\n    slice_lhs 2 5 => simp only [\u2190 tensor_id, associator_conjugation]\n    have c :\n      (\u03b1_ X (Y \u2297 Y') Y).inv \u226b\n          ((\u03b1_ X Y Y').inv \u2297 \ud835\udfd9 Y) \u226b (\u03b1_ (X \u2297 Y) Y' Y).Hom \u226b (\u03b1_ X Y (Y' \u2297 Y)).Hom =\n        \ud835\udfd9 _ \u2297 (\u03b1_ _ _ _).Hom\n    pure_coherence\n    slice_lhs 4 7 => rw [c]\n    slice_lhs 3 5 => rw [\u2190 id_tensor_comp, \u2190 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 [\u2190 associator_inv_naturality]\n    slice_lhs 2 3 => rw [tensor_id, id_tensor_comp_tensor_id, \u2190 tensor_id_comp_id_tensor]\n    slice_lhs 3 6 => simp only [\u2190 tensor_id, associator_conjugation]\n    have c :\n      (\u03b1_ Z Y' (Y \u2297 Y')).inv \u226b\n          (\u03b1_ (Z \u2297 Y') Y Y').inv \u226b ((\u03b1_ Z Y' Y).Hom \u2297 \ud835\udfd9 Y') \u226b (\u03b1_ Z (Y' \u2297 Y) Y').Hom =\n        \ud835\udfd9 _ \u2297 (\u03b1_ _ _ _).inv\n    pure_coherence\n    slice_lhs 5 8 => rw [c]\n    slice_lhs 4 6 => rw [\u2190 id_tensor_comp, \u2190 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' \u2297 X \u27f6 Z)\n    (g : Z \u27f6 Z') :\n    (tensorLeftHomEquiv X Y Y' Z') (f \u226b g) = (tensorLeftHomEquiv X Y Y' Z) f \u226b (\ud835\udfd9 Y \u2297 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 \u27f6 X')\n    (g : X' \u27f6 Y \u2297 Z) :\n    (tensorLeftHomEquiv X Y Y' Z).symm (f \u226b g) =\n      (\ud835\udfd9 _ \u2297 f) \u226b (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 \u2297 Y \u27f6 Z)\n    (g : Z \u27f6 Z') :\n    (tensorRightHomEquiv X Y Y' Z') (f \u226b g) = (tensorRightHomEquiv X Y Y' Z) f \u226b (g \u2297 \ud835\udfd9 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 \u27f6 X')\n    (g : X' \u27f6 Z \u2297 Y') :\n    (tensorRightHomEquiv X Y Y' Z).symm (f \u226b g) =\n      (f \u2297 \ud835\udfd9 Y) \u226b (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' \u22a3 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 \u22a3 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 `\u1601Y`, then it is a closed object, with the internal hom functor `Y \u27f6[C] -`\ngiven by left tensoring by `\u1601Y`.\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 `\u1601Y \u2297 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 \u2192\u2097[k] X` rather than `\u1601Y \u2297 X` even though these are\nnaturally isomorphic).\n-/\ndef closedOfHasLeftDual (Y : C) [HasLeftDual Y] : Closed Y\n    where isAdj := \u27e8_, tensorLeftAdjunction (\u1601Y) Y\u27e9\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 \u27f6 Y \u2297 Z)\n    (g : X' \u27f6 Z') :\n    (tensorLeftHomEquiv (X \u2297 X') Y Y' (Z \u2297 Z')).symm ((f \u2297 g) \u226b (\u03b1_ _ _ _).Hom) =\n      (\u03b1_ _ _ _).inv \u226b ((tensorLeftHomEquiv X Y Y' Z).symm f \u2297 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 [\u2190 id_tensor_comp_tensor_id]\n  conv_rhs => rw [\u2190 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 \u27f6 Z \u2297 Y')\n    (g : X' \u27f6 Z') :\n    (tensorRightHomEquiv (X' \u2297 X) Y Y' (Z' \u2297 Z)).symm ((g \u2297 f) \u226b (\u03b1_ _ _ _).inv) =\n      (\u03b1_ _ _ _).Hom \u226b (g \u2297 (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 [\u2190 tensor_id_comp_id_tensor]\n  conv_rhs => rw [\u2190 tensor_id_comp_id_tensor, id_tensor_comp, id_tensor_comp]\n  simp only [\u2190 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' \u27f6 Z) : (tensorLeftHomEquiv _ _ _ _).symm (\u03b7_ _ _ \u226b (\ud835\udfd9 Y \u2297 f)) = (\u03c1_ _).Hom \u226b 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, \u2190 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 \u27f6 Y) :\n    (tensorLeftHomEquiv _ _ _ _).symm (\u03b7_ _ _ \u226b (f \u2297 \ud835\udfd9 (X\u1601))) = (\u03c1_ _).Hom \u226b f\u1601 :=\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 \u27f6 Y) :\n    (tensorRightHomEquiv _ (\u1601Y) _ _).symm (\u03b7_ (\u1601X) X \u226b (\ud835\udfd9 (\u1601X) \u2297 f)) = (\u03bb_ _).Hom \u226b \u1601f :=\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 \u27f6 Z) : (tensorRightHomEquiv _ Y _ _).symm (\u03b7_ Y Y' \u226b (f \u2297 \ud835\udfd9 Y')) = (\u03bb_ _).Hom \u226b 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, \u2190 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 \u27f6 \u1601Z) :\n    (tensorLeftHomEquiv _ _ _ _) ((\ud835\udfd9 Z \u2297 f) \u226b \u03b5_ _ _) = f \u226b (\u03c1_ _).inv :=\n  by\n  dsimp [tensor_left_hom_equiv]\n  rw [id_tensor_comp]\n  slice_lhs 3 4 => rw [\u2190 associator_naturality]\n  slice_lhs 2 3 => rw [tensor_id, tensor_id_comp_id_tensor, \u2190 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 \u27f6 Y) : (tensorLeftHomEquiv _ _ _ _) ((f \u2297 \ud835\udfd9 _) \u226b \u03b5_ _ _) = (\u1601f) \u226b (\u03c1_ _).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 \u27f6 Y) : (tensorRightHomEquiv _ _ _ _) ((\ud835\udfd9 (Y\u1601) \u2297 f) \u226b \u03b5_ _ _) = f\u1601 \u226b (\u03bb_ _).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 \u27f6 X\u1601) :\n    (tensorRightHomEquiv _ _ _ _) ((f \u2297 \ud835\udfd9 X) \u226b \u03b5_ X (X\u1601)) = f \u226b (\u03bb_ _).inv :=\n  by\n  dsimp [tensor_right_hom_equiv]\n  rw [comp_tensor_id]\n  slice_lhs 3 4 => rw [\u2190 associator_inv_naturality]\n  slice_lhs 2 3 => rw [tensor_id, id_tensor_comp_tensor_id, \u2190 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\u1601` or `\u1601f` through (co)evaluations.\ntheorem coevaluation_comp_rightAdjointMate {X Y : C} [HasRightDual X] [HasRightDual Y] (f : X \u27f6 Y) :\n    \u03b7_ Y (Y\u1601) \u226b (\ud835\udfd9 _ \u2297 f\u1601) = \u03b7_ _ _ \u226b (f \u2297 \ud835\udfd9 _) :=\n  by\n  apply_fun (tensor_left_hom_equiv _ Y (Y\u1601) _).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 \u27f6 Y) :\n    (\ud835\udfd9 X \u2297 \u1601f) \u226b \u03b5_ _ _ = (f \u2297 \ud835\udfd9 _) \u226b \u03b5_ _ _ :=\n  by\n  apply_fun tensor_left_hom_equiv _ (\u1601X) 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 \u27f6 Y) :\n    \u03b7_ (\u1601Y) Y \u226b ((\u1601f) \u2297 \ud835\udfd9 Y) = \u03b7_ (\u1601X) X \u226b (\ud835\udfd9 (\u1601X) \u2297 f) :=\n  by\n  apply_fun (tensor_right_hom_equiv _ (\u1601Y) 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 \u27f6 Y) :\n    (f\u1601 \u2297 \ud835\udfd9 X) \u226b \u03b5_ X (X\u1601) = (\ud835\udfd9 (Y\u1601) \u2297 f) \u226b \u03b5_ Y (Y\u1601) :=\n  by\n  apply_fun tensor_right_hom_equiv _ X (X\u1601) _\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 \u2245 X') : ExactPairing X Y\n    where\n  evaluation := (\ud835\udfd9 Y \u2297 i.Hom) \u226b \u03b5_ _ _\n  coevaluation := \u03b7_ _ _ \u226b (i.inv \u2297 \ud835\udfd9 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, \u2190 id_tensor_comp_tensor_id]\n    slice_lhs 4 5 => rw [tensor_id_comp_id_tensor, \u2190 id_tensor_comp_tensor_id]\n    slice_lhs 2 3 => rw [\u2190 associator_naturality]\n    slice_lhs 1 2 => rw [tensor_id, tensor_id_comp_id_tensor, \u2190 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 [\u2190 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 [\u2190 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 \u2245 Y') : ExactPairing X Y\n    where\n  evaluation := (i.Hom \u2297 \ud835\udfd9 X) \u226b \u03b5_ _ _\n  coevaluation := \u03b7_ _ _ \u226b (\ud835\udfd9 X \u2297 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 [\u2190 tensor_comp]\n      simp\n    simp\n  coevaluation_evaluation' := by\n    rw [id_tensor_comp, comp_tensor_id]\n    slice_lhs 3 4 => rw [\u2190 associator_inv_naturality]\n    slice_lhs 2 3 => rw [tensor_id, id_tensor_comp_tensor_id, \u2190 tensor_id_comp_id_tensor]\n    slice_lhs 1 2 => rw [id_tensor_comp_tensor_id, \u2190 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, \u2190 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 [\u2190 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 \u2245 X') (j : Y \u2245 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\u2081 Y\u2082 : C} (_ : ExactPairing X Y\u2081) (_ : ExactPairing X Y\u2082) : Y\u2081 \u2245 Y\u2082\n    where\n  Hom := @rightAdjointMate C _ _ X X \u27e8Y\u2082\u27e9 \u27e8Y\u2081\u27e9 (\ud835\udfd9 X)\n  inv := @rightAdjointMate C _ _ X X \u27e8Y\u2081\u27e9 \u27e8Y\u2082\u27e9 (\ud835\udfd9 X)\n  hom_inv_id' := by rw [\u2190 comp_right_adjoint_mate, category.comp_id, right_adjoint_mate_id]\n  inv_hom_id' := by rw [\u2190 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\u2081 X\u2082 Y : C} (p\u2081 : ExactPairing X\u2081 Y) (p\u2082 : ExactPairing X\u2082 Y) : X\u2081 \u2245 X\u2082\n    where\n  Hom := @leftAdjointMate C _ _ Y Y \u27e8X\u2082\u27e9 \u27e8X\u2081\u27e9 (\ud835\udfd9 Y)\n  inv := @leftAdjointMate C _ _ Y Y \u27e8X\u2081\u27e9 \u27e8X\u2082\u27e9 (\ud835\udfd9 Y)\n  hom_inv_id' := by rw [\u2190 comp_left_adjoint_mate, category.comp_id, left_adjoint_mate_id]\n  inv_hom_id' := by rw [\u2190 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 : \u2200 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 : \u2200 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 \u27f6[C] Y = \u1601X \u2297 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 `\u1601Y \u2297 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 \u2192\u2097[k] X` rather than `\u1601Y \u2297 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 : \u03a0 (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 \u2192 E \u2192 rbtree E \u2192  E \u2192 rbtree E \u2192 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 \u2192 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 \u2192 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 \u2192 Prop\n| (tree t) := t.is_ordered\n| (triple l x c y r) :=\n   l.is_ordered\n   \u2227 all_lt l x\n   \u2227 all_gt c x\n   \u2227 c.is_ordered \u2227 has_ordering.cmp x y = ordering.lt\n   \u2227 all_lt c y\n   \u2227 all_gt r y\n   \u2227 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 \u2192 E \u2192 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 \u2227 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 \u2192 E \u2192 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 \u2227 l.all_gt a\n\nend\nend insert_result\n\nsection insert_def\nparameters {E:Type _}\n\nopen insert_result\n\ndef balanceL : color \u2192 insert_result E \u2192 E \u2192 rbtree E \u2192 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 \u2192 rbtree E \u2192 E \u2192 insert_result E \u2192 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 \u2192 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\u2192 (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 \u2260 ordering.lt), exact dec_trivial,\n    have g2 : ordering.lt \u2264 ordering.eq, exact dec_trivial,\n    have g3 : ordering.eq \u2264 ordering.eq, exact dec_trivial,\n    have g4 : ordering.eq \u2260 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 \u2192 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: \u2200{t u : rbtree E},\n   is_ordered t\n   \u2192 is_ordered u\n   \u2192 t.to_list = u.to_list\n   \u2192 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\u2227 (\u2200 (a : E), has_ordering.cmp y a = ordering.lt\n            \u2192 t.all_lt a\n            \u2192 (insert_core y t).all_lt a)\n\u2227 (\u2200 (a:E), has_ordering.cmp a y = ordering.lt\n               \u2192 t.all_gt a\n               \u2192 (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 \u2192 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 \u2192 \u2115\n| (triple l _ _ _ _) := l.black_height\n| (tree t) := t.black_height\n\ndef well_formed : insert_result E \u2192 Prop\n| (triple l x c y r) :=\n  l.well_formed\n  \u2227 c.well_formed\n  \u2227 r.well_formed\n  \u2227 l.black_height = c.black_height\n  \u2227 c.black_height = r.black_height\n  \u2227 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 :\u2115) : (nat.succ m = nat.succ n) \u2194 (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 \u2192 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 \u2192 E \u2192 rbtree E \u2192 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 \u2192 E \u2192 insert_result E \u2192 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 \u2192 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 \u2192 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 \u2192 (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 \u2192 (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 \u2192 (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 \u2192 list node \u2192 Prop\n| _   [] := false\n\n| tgt (\u27e8ref, parents, _\u27e9 :: nodes) :=\n  if ref.1 = cost\n  then true\n  else (tgt \u2208 parents \u2227 is_downstream ref nodes) \u2228 is_downstream tgt nodes\n\ninstance decidable_is_downstream (cost : ID) : \u03a0 (tgt : reference) (nodes : list node), decidable (is_downstream cost tgt nodes)\n| _   [] := decidable.false\n\n| tgt (\u27e8ref, parents, _\u27e9 :: nodes) :=\n  show decidable (if ref.1 = cost then true else (tgt \u2208 parents \u2227 is_downstream cost ref nodes) \u2228 is_downstream cost tgt nodes), from\n  have H\u2081 : decidable (is_downstream cost ref nodes), from begin apply decidable_is_downstream end,\n  have H\u2082 : decidable (is_downstream cost tgt nodes), from begin apply decidable_is_downstream end,\n  by tactic.apply_instance\n\ndef all_parents_in_env : \u03a0 (inputs : env) (nodes : list node), Prop\n| _   [] := true\n\n| inputs (\u27e8ref, parents, _\u27e9 :: nodes) :=\n  (\u2200 (parent : reference), parent \u2208 parents \u2192 env.has_key parent inputs)\n  \u2227 (\u2200 (x : T ref.2), all_parents_in_env (env.insert ref x inputs) nodes)\n\ndef all_costs_scalars (costs : list ID) : \u03a0 (nodes : list node), Prop\n| [] := true\n| (\u27e8ref, _, _\u27e9 :: nodes) := (ref.1 \u2208 costs \u2192 ref.2 = []) \u2227 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 \u2208 costs \u2192 tgt.2 = [])\n\ndef grads_exist_at : list node \u2192 env \u2192 reference \u2192 Prop\n| [] _ _ := true\n\n| (\u27e8ref, parents, operator.det op\u27e9 :: 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  \u2227 (tgt \u2208 parents \u2192 op^.pre (env.get_ks parents m) \u2227 grads_exist_at nodes m' ref)\n\n| (\u27e8ref, parents, operator.rand op\u27e9 :: nodes) m tgt  :=\n  let m' := (\u03bb (y : T ref.2), env.insert ref y m) in\n  (tgt \u2208 parents \u2192 op^.pre (env.get_ks parents m)) \u2227 (\u2200 y, grads_exist_at nodes (m' y) tgt)\n\ndef pdfs_exist_at : list node \u2192 env \u2192 Prop\n| [] _ := true\n\n| (\u27e8ref, parents, operator.det op\u27e9 :: nodes) m := pdfs_exist_at nodes (env.insert ref (op^.f (env.get_ks parents m)) m )\n\n| (\u27e8ref, parents, operator.rand op\u27e9 :: nodes) m :=\n  let m' := (\u03bb (y : T ref.2), env.insert ref y m) in\n  (op^.pre (env.get_ks parents m)) \u2227 (\u2200 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 \u2192 env \u2192 reference \u2192 Prop\n| [] _ _ := true\n\n| (\u27e8ref, parents, operator.det op\u27e9 :: 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  \u2227 (tgt \u2208 parents \u2192 can_differentiate_under_integrals nodes (env.insert ref (op^.f (env.get_ks parents inputs)) inputs) ref)\n\n| (\u27e8ref, parents, operator.rand op\u27e9 :: nodes) inputs tgt  :=\n  let \u03b8 : T tgt.2 := env.get tgt inputs in\n  let g : T ref.2 \u2192 T tgt.2 \u2192 \u211d :=\n  (\u03bb (x : T ref.2) (\u03b8\u2080 : T tgt.2),\n      E (graph.to_dist (\u03bb (inputs : env), \u27e6sum_costs inputs costs\u27e7)\n                       (env.insert ref x (env.insert tgt \u03b8\u2080 inputs))\n                       nodes)\n        dvec.head) in\n  let next_inputs := (\u03bb (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 (\u03bb (\u03b8\u2080 : T (tgt.snd)) (x : T (ref.snd)), rand.op.pdf op (env.get_ks parents (env.insert tgt \u03b8\u2080 inputs)) x \u2b1d g x \u03b8\u2080) \u03b8\n\n    \u2227 (T.is_uniformly_integrable_around (\u03bb (\u03b8\u2080 : T (tgt.snd)) (x : T (ref.snd)), \u2207 (\u03bb (\u03b8\u2081 : T (tgt.snd)), rand.op.pdf op (env.get_ks parents (env.insert tgt \u03b8\u2081 inputs)) x \u2b1d g x \u03b8\u2081) \u03b8\u2080) \u03b8\n       \u2227 T.is_uniformly_integrable_around (\u03bb (\u03b8\u2080 : T (tgt.snd)) (x : T (ref.snd)), \u2207 (\u03bb (\u03b8\u2081 : T (tgt.snd)), rand.op.pdf op (env.get_ks parents (env.insert tgt \u03b8 inputs)) x \u2b1d g x \u03b8\u2081) \u03b8\u2080) \u03b8)\n\n    \u2227 (\u2200 (idx : \u2115), at_idx parents idx tgt \u2192\n    T.is_uniformly_integrable_around (\u03bb (\u03b8\u2080 : T (tgt.snd)) (x : T (ref.snd)), rand.op.pdf op (dvec.update_at \u03b8\u2080 (env.get_ks parents (env.insert tgt \u03b8 inputs)) idx) x \u2b1d g x \u03b8) \u03b8)\n   \u2227 (\u2200 (idx : \u2115),  at_idx parents idx tgt \u2192\n    T.is_uniformly_integrable_around (\u03bb (\u03b8\u2080 : T (tgt.snd)) (x : T (ref.snd)),\n                                         \u2207 (\u03bb (\u03b8\u2080 : T (tgt.snd)), rand.op.pdf op (dvec.update_at \u03b8\u2080 (env.get_ks parents (env.insert tgt \u03b8 inputs)) idx) x \u2b1d g x \u03b8) \u03b8\u2080) \u03b8))\n\u2227 (\u2200 y, can_differentiate_under_integrals nodes (next_inputs y) tgt)\n\ndef all_pdfs_std : \u03a0 (nodes : list node), Prop\n| [] := true\n| (\u27e8ref, parents, operator.det op\u27e9 :: nodes) := all_pdfs_std nodes\n| (\u27e8(ref, .(shape)), [], operator.rand (rand.op.mvn_std shape)\u27e9 :: nodes) := all_pdfs_std nodes\n| (\u27e8(ref, .(shape)), [(parent\u2081, .(shape)), (parent\u2082, .(shape))], operator.rand (rand.op.mvn shape)\u27e9 :: nodes) := false\n\nlemma all_pdfs_std_det : \u03a0 (ref : reference) (parents : list reference) (op : det.op parents^.p2 ref.2) (nodes : list node),\n  all_pdfs_std (\u27e8ref, parents, operator.det op\u27e9 :: 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) : \u03a0 (nodes : list node) (m : env) (tgt : reference), Prop\n| [] _ _ := true\n\n| (\u27e8ref, parents, operator.det op\u27e9 :: 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  \u2227 (tgt \u2208 parents \u2192 can_diff_under_ints_pdfs_std nodes (env.insert ref (op^.f (env.get_ks parents inputs)) inputs) ref)\n\n| (\u27e8ref, parents, operator.rand op\u27e9 :: nodes) inputs tgt  :=\n  let \u03b8 : T tgt.2 := env.get tgt inputs in\n  let g : T ref.2 \u2192 T tgt.2 \u2192 \u211d :=\n  (\u03bb (x : T ref.2) (\u03b8\u2080 : T tgt.2),\n      E (graph.to_dist (\u03bb (inputs : env), \u27e6sum_costs inputs costs\u27e7)\n                       (env.insert ref x (env.insert tgt \u03b8\u2080 inputs))\n                       nodes)\n        dvec.head) in\n  let next_inputs := (\u03bb (y : T ref.2), env.insert ref y inputs) in\n\n (T.is_uniformly_integrable_around (\u03bb (\u03b8\u2080 : T (tgt.snd)) (x : T (ref.snd)), T.mvn_pdf 0 1 x \u2b1d g x \u03b8\u2080) \u03b8\n    \u2227 T.is_uniformly_integrable_around (\u03bb (\u03b8\u2080 : T (tgt.snd)) (x : T (ref.snd)), \u2207 (\u03bb (\u03b8\u2081 : T (tgt.snd)), T.mvn_pdf 0 1 x \u2b1d g x \u03b8\u2081) \u03b8\u2080) \u03b8)\n\u2227 (\u2200 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 : \u2124} {s : set K} [is_subfield s] (h : a \u2208 s) : a ^ n \u2208 s :=\nbegin\n    by_cases hn : n \u2265 0,\n    {   lift n to \u2115 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 \u2115 using (show -n \u2265 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 \u2260 0) : algebra_map F M x \u2260 0 :=\nbegin\n    revert hx,\n    contrapose!,\n    intro h,\n    rw \u2190 (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) (\u03b1 : F) (hf : f.eval \u03b1 = 0) (hg : g.eval \u03b1 = 0) : (euclidean_domain.gcd f g).eval \u03b1 = 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) (\u03b1 : E) (h\u03b1 : (euclidean_domain.gcd f g).eval\u2082 (algebra_map F E) \u03b1 = 0) :\nf.eval\u2082 (algebra_map F E) \u03b1 = 0 :=\nbegin\n    cases euclidean_domain.gcd_dvd_left f g with p hp,\n    rw [hp,polynomial.eval\u2082_mul,h\u03b1,zero_mul],\nend\n\nlemma gcd_root_right (f g : polynomial F) (\u03b1 : E) (h\u03b1 : (euclidean_domain.gcd f g).eval\u2082 (algebra_map F E) \u03b1 = 0) :\ng.eval\u2082 (algebra_map F E) \u03b1 = 0 :=\nbegin\n    cases euclidean_domain.gcd_dvd_right f g with p hp,\n    rw [hp,polynomial.eval\u2082_mul,h\u03b1,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) = (\u22a4 : set E)) :\n    \u2203 \u03b1 : E, F[\u03b1] = (\u22a4 : set E) :=\nbegin\n    use 0,\n    ext,\n    split,\n    exact \u03bb _, trivial,\n    rw \u2190 F_eq_E,\n    rintros \u27e8x, rfl\u27e9,\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] : \u2203 \u03b1 : E, F[\u03b1] = (\u22a4 : set E) :=\nbegin\n    obtain \u27e8\u03b1, h\u03b1\u27e9 := is_cyclic.exists_generator (units E),\n    use \u03b1,\n    ext,\n    refine \u27e8\u03bb _, dec_trivial, \u03bb _, _\u27e9,\n    by_cases hx : x = 0,\n    {   rw hx,\n        exact is_add_submonoid.zero_mem, },\n    {   obtain \u27e8n, hn\u27e9 := set.mem_range.mp (h\u03b1 (units.mk0 x hx)),\n        rw (show x = (\u03b1 : E)^n, by norm_cast at *; simp *),\n        exact is_subfield.pow_mem (adjoin_simple_contains_element F \u2191\u03b1),\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    \u2203 \u03b1 : E, F[\u03b1] = (\u22a4 : 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] (\u03d5 : F \u2192+* E)\n\nlemma primitive_element_two_aux (\u03b1 \u03b2 : E) {f g : polynomial F} [F_inf : infinite F] (hf : f \u2260 0) (hg : g \u2260 0) (f_monic : polynomial.monic f) (g_monic : polynomial.monic g) :\n    \u2203 c : F, \u2200 (\u03b1' \u2208 (f.map \u03d5).roots) (\u03b2' \u2208 (g.map \u03d5).roots), \u03b2' \u2260 \u03b2 \u2192 \u03d5 c \u2260 -(\u03b1' - \u03b1)/(\u03b2' - \u03b2) :=\nbegin\n    let sf := (f.map \u03d5).roots,\n    let sg := (g.map \u03d5).roots,\n    let s := {c : E | \u2203 (\u03b1' \u2208 sf) (\u03b2' \u2208 sg), \u03b2' \u2260 \u03b2 \u2227 c = -(\u03b1' - \u03b1)/(\u03b2' - \u03b2)},\n    let s' := \u03d5\u207b\u00b9' s,\n    let r : E \u2192 E \u2192 E := \u03bb \u03b1' \u03b2', -(\u03b1' - \u03b1)/(\u03b2' - \u03b2),\n    have hr : \u2200 c \u2208 s, \u2203 \u03b1' \u03b2', ((\u03b1' \u2208 sf) \u2227 (\u03b2' \u2208 sg)) \u2227 r \u03b1' \u03b2' = 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 (\u03bb z : E \u00d7 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 \u03d5).inj_on (\u21d1\u03d5 \u207b\u00b9' s)),\n    obtain \u27e8c, hc\u27e9 := 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 \u27e8c, hc\u27e9,\nend\n\nlemma primitive_element_two_inf_key_aux {\u03b2 : F} {h : polynomial F} (h_ne_zero : h \u2260 0) (h_sep : h.separable)\n(h_root : h.eval \u03b2 = 0) (h_splits : polynomial.splits \u03d5 h) (h_roots : \u2200 x \u2208 (h.map \u03d5).roots, x = \u03d5 \u03b2) :\nh = (polynomial.C (polynomial.leading_coeff h)) * (polynomial.X - polynomial.C \u03b2) :=\nbegin\n    have h_map_separable : (h.map \u03d5).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 : \u2200 x \u2208 s, x = \u03d5 \u03b2 :=\n    begin\n        intros x hx,\n        have is_root : x \u2208 (h.map \u03d5).roots,\n        rw polynomial.mem_roots,\n        dsimp[polynomial.is_root],\n        rw polynomial.eval_map,\n        rw polynomial.eval\u2082_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 : \u2200 x \u2208 multiset.map (\u03bb (a : E), polynomial.X - polynomial.C a) s, x = polynomial.X - polynomial.C (\u03d5 \u03b2) :=\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 : \u00acis_unit (polynomial.X - polynomial.C (\u03d5 \u03b2)) :=\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 \u03d5 \u03d5.injective,\n    have hn : s.card \u2260 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 \u2190polynomial.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 (\u03b1 \u03b2 : E) [F_sep : is_separable F E]\n    (F_inf : infinite F) : \u2203 c : F, \u03b2 \u2208 F[\u03b1 + (algebra_map F E) c * \u03b2] :=\nbegin\n    rcases F_sep \u03b1 with \u27e8h\u03b1, hf\u27e9,\n    rcases F_sep \u03b2 with \u27e8h\u03b2, hg\u27e9,\n    let f := minimal_polynomial h\u03b1,\n    let g := minimal_polynomial h\u03b2,\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 \u03b9FE := algebra_map F E,\n    let \u03b9EE' := algebra_map E E',\n    let \u03b9FE' := \u03b9EE'.comp(\u03b9FE),\n    have key := primitive_element_two_aux \u03b9FE' (\u03b9EE' \u03b1) (\u03b9EE' \u03b2) (minimal_polynomial.ne_zero h\u03b1) (minimal_polynomial.ne_zero h\u03b2) (minimal_polynomial.monic h\u03b1) (minimal_polynomial.monic h\u03b2),\n    cases key with c hc,\n    use c,\n    let \u03b3 := \u03b1+(\u03b9FE c)*\u03b2,\n    let f' := f_E.comp(polynomial.C \u03b3-(polynomial.C (\u03b9FE 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[\u2190h] at mul,\n        apply polynomial.separable.of_mul_left,\n        rw \u2190mul,\n        exact polynomial.separable.map hg,\n    end,\n    have h_ne_zero : h \u2260 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\u03b2) h_eq_zero.2,\n    end,\n    have h_map_separable : (h.map \u03b9EE').separable :=\n    begin\n        apply polynomial.separable.map,\n        exact h_sep,\n    end,\n    have h_root : h.eval \u03b2 = 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,\u2190polynomial.aeval_def,minimal_polynomial.aeval],\n        rw [polynomial.eval_map,\u2190polynomial.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\u03b2)) (polynomial.splitting_field.splits g_E) (euclidean_domain.gcd_dvd_right f' g_E),\n    have h_roots : \u2200 x \u2208 (h.map \u03b9EE').roots, x = algebra_map E E' \u03b2 :=\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\u2082 (algebra_map E E') x = 0 := polynomial.gcd_root_left E f' g_E x hx,\n        simp only [polynomial.eval\u2082_comp,polynomial.eval\u2082_map,polynomial.eval\u2082_sub,polynomial.eval\u2082_mul,polynomial.eval\u2082_C,polynomial.eval\u2082_X] at f_root,\n        replace f_root : _ \u2208 (f.map \u03b9FE').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\u03b1),\n        specialize hc _ f_root,\n        have g_root : g_E.eval\u2082 (algebra_map E E') x = 0 := polynomial.gcd_root_right E f' g_E x hx,\n        simp only [polynomial.eval\u2082_map] at g_root,\n        replace g_root : _ \u2208 (g.map \u03b9FE').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\u03b2),\n        specialize hc _ g_root,\n        by_contradiction,\n        specialize hc a,\n        apply hc,\n        dsimp[\u03b9EE'],\n        rw[neg_sub,ring_hom.map_add,\u2190sub_add,\u2190sub_sub,sub_self,zero_sub,neg_add_eq_sub,ring_hom.map_mul,\u2190mul_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 \u03b9EE' h_ne_zero h_sep h_root h_splits h_roots,\n    let f_F\u03b3 := (f.map(algebra_map F F[\u03b3])).comp(polynomial.C (adjoin_simple.gen F \u03b3)-(polynomial.C \u2191c) * (polynomial.X)),\n    let g_F\u03b3 := g.map(algebra_map F F[\u03b3]),\n    have composition2 : (algebra_map F[\u03b3] E).comp(algebra_map F F[\u03b3]) = algebra_map F E := by ext;refl,\n    have f_map : f_F\u03b3.map(algebra_map F[\u03b3] E) = f' :=\n    begin\n        dsimp[f_F\u03b3,f',f_E],\n        rw \u2190composition2,\n        rw \u2190polynomial.map_map,\n        set p := f.map(algebra_map F F[\u03b3]),\n        dsimp[\u2190p],\n        rw polynomial.map_comp (algebra_map F[\u03b3] E) p (polynomial.C (adjoin_simple.gen F \u03b3)-(polynomial.C \u2191c) * (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\u03b3.map(algebra_map F[\u03b3] E) = g_E :=\n    begin\n        rw polynomial.map_map,\n        rw composition2,\n    end,\n    dsimp[h] at key,\n    rw [\u2190f_map,\u2190g_map] at key,\n    have swap : euclidean_domain.gcd (f_F\u03b3.map(algebra_map F[\u03b3] E)) (g_F\u03b3.map(algebra_map F[\u03b3] E)) = (euclidean_domain.gcd f_F\u03b3 g_F\u03b3).map(algebra_map F[\u03b3] E),\n    convert polynomial.gcd_map (algebra_map F[\u03b3] E),\n    rw swap at key,\n    set p := euclidean_domain.gcd f_F\u03b3 g_F\u03b3,\n    set k := (p.map(algebra_map F[\u03b3] E)).leading_coeff,\n    dsimp[\u2190k] at key,\n    rw mul_sub at key,\n    rw \u2190polynomial.C_mul at key,\n    have coeff0 : algebra_map F[\u03b3] E (p.coeff 0) = -(k*\u03b2) :=\n        by rw [\u2190polynomial.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[\u03b3] E (p.coeff 1) = k :=\n    begin\n        rw [\u2190polynomial.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\u22600 :=\n    begin\n        intro k_eq_zero,\n        rw [polynomial.leading_coeff_eq_zero,\u2190polynomial.map_zero (algebra_map F[\u03b3] E)] at k_eq_zero,\n        replace k_eq_zero := polynomial.map_injective (algebra_map F[\u03b3] E) (algebra_map F[\u03b3] 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\u03b2) k_eq_zero.2,\n    end,\n    have last_step : \u03b2 = algebra_map F[\u03b3] 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,\u2190mul_assoc,inv_mul_cancel k_ne_zero,one_mul],\n    change \u03b2 = \u2191(-p.coeff 0 / p.coeff 1) at last_step,\n    have h := subtype.mem (-p.coeff 0 / p.coeff 1),\n    rw \u2190last_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 (\u03b1 \u03b2 : E) (F_sep : is_separable F E)\n    (F_inf : infinite F) :  \u2203 \u03b3 : E, F[\u03b1, \u03b2] = F[\u03b3] :=\nbegin\n    obtain \u27e8c, \u03b2_in_F\u03b3\u27e9 := primitive_element_two_inf_key \u03b1 \u03b2 F_inf,\n    let c' := algebra_map F E c,\n    let \u03b3 := \u03b1 + c'*\u03b2,\n    have \u03b3_in_F\u03b3 : \u03b3 \u2208 F[\u03b3] := adjoin_simple_contains_element F \u03b3,\n    have c_in_F\u03b3 : c' \u2208 F[\u03b3] := adjoin.field_mem F {\u03b3} c,\n    have c\u03b2_in_F\u03b3 : c'*\u03b2 \u2208 F[\u03b3] := is_submonoid.mul_mem c_in_F\u03b3 \u03b2_in_F\u03b3,\n    have \u03b1_in_F\u03b3 : \u03b1 \u2208 F[\u03b3] := by rw (show \u03b1 = \u03b3 - c'*\u03b2, by simp *);\n        exact is_add_subgroup.sub_mem F[\u03b3] \u03b3 (c'*\u03b2) \u03b3_in_F\u03b3 c\u03b2_in_F\u03b3,\n    have \u03b1\u03b2_in_F\u03b3 : {\u03b1, \u03b2} \u2286 F[\u03b3] := \u03bb x hx, by cases hx; cases hx; assumption,\n    have F\u03b1\u03b2_sub_F\u03b3 : F[\u03b1, \u03b2] \u2286 F[\u03b3] := adjoin_subset' F {\u03b1, \u03b2} \u03b1\u03b2_in_F\u03b3,\n    have \u03b1_in_F\u03b1\u03b2 : \u03b1 \u2208 F[\u03b1, \u03b2] := adjoin.set_mem F {\u03b1, \u03b2} \u27e8\u03b1, set.mem_insert \u03b1 {\u03b2}\u27e9,\n    have \u03b2_in_F\u03b1\u03b2 : \u03b2 \u2208 F[\u03b1, \u03b2] := adjoin.set_mem F {\u03b1, \u03b2} \u27e8\u03b2, set.mem_insert_of_mem \u03b1 rfl\u27e9,\n    have c_in_F\u03b1\u03b2 : c' \u2208 (F[\u03b1, \u03b2] : set E) := adjoin.field_mem F {\u03b1, \u03b2} c,\n    have c\u03b2_in_F\u03b1\u03b2 : c'*\u03b2 \u2208 F[\u03b1, \u03b2] := is_submonoid.mul_mem c_in_F\u03b1\u03b2 \u03b2_in_F\u03b1\u03b2,\n    have \u03b3_in_F\u03b1\u03b2 : \u03b3 \u2208 F[\u03b1, \u03b2] := is_add_submonoid.add_mem \u03b1_in_F\u03b1\u03b2 c\u03b2_in_F\u03b1\u03b2,\n    have F\u03b3_sub_F\u03b1\u03b2 : F[\u03b3] \u2286 F[\u03b1, \u03b2] := adjoin_simple_subset' F \u03b3 \u03b3_in_F\u03b1\u03b2,\n    exact \u27e8\u03b3, set.subset.antisymm F\u03b1\u03b2_sub_F\u03b3 F\u03b3_sub_F\u03b1\u03b2\u27e9,\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 : \u2115) (hn : findim F E = n) : (\u2203 \u03b1 : E, F[\u03b1] = (\u22a4 : 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) = (\u22a4 : set E),\n    {   exact primitive_element_trivial F F_neq_E, },\n    {   have : \u2203 \u03b1 : E, \u03b1 \u2209 set.range (algebra_map F E) :=\n        begin\n            revert F_neq_E,\n            contrapose!,\n            exact \u03bb h, set.ext (\u03bb x, \u27e8\u03bb _, dec_trivial, \u03bb _, h x\u27e9),\n        end,\n        rcases this with \u27e8\u03b1, h\u03b1\u27e9,\n        by_cases h : F[\u03b1] = (\u22a4 : set E),\n        {   exact \u27e8\u03b1, h\u27e9,   },\n        {   have F\u03b1_findim : finite_dimensional F[\u03b1] E := adjoin_findim_of_findim F \u03b1,\n            have F\u03b1_le_n : findim F[\u03b1] E < n := by rw \u2190 hn; exact adjoin_dim_lt F h\u03b1,\n            have F\u03b1_inf : infinite F[\u03b1] := adjoin_inf_of_inf F {\u03b1} F_inf,\n            have F\u03b1_sep : is_separable F[\u03b1] E := adjoin_separable F {\u03b1},\n            obtain \u27e8\u03b2, h\u03b2\u27e9 := ih (findim F[\u03b1] E) F\u03b1_le_n F[\u03b1]\n                F\u03b1_sep F\u03b1_findim F\u03b1_inf rfl,\n            obtain \u27e8\u03b3, h\u03b3\u27e9 := primitive_element_two_inf \u03b1 \u03b2 F_sep F_inf,\n            rw [adjoin_simple_twice, h\u03b3] at h\u03b2,\n            exact \u27e8\u03b3, h\u03b2\u27e9,\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    (\u2203 \u03b1 : E, F[\u03b1] = (\u22a4 : set E)) :=\nbegin\n    by_cases F_finite : nonempty (fintype F),\n    exact nonempty.elim F_finite (\u03bb 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    (\u2203 \u03b1 : E, F[\u03b1] = (\u22a4 : 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 \u27e8\u03b1, h\u03b1\u27e9 := primitive_element_aux F' E F'_sep F'_findim,\n    exact \u27e8\u03b1, by simp only [*, adjoin_equals_adjoin_range]\u27e9,\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 \u03b1 \u2192 \u03b2 \u2192 (\u03b1 \u2192 \u03b2) \u2192 \u03b2\n  | (some x), y, f => f x\n  | none,     y, f => y\n\ninstance : Bind (Option) := \u27e8Option.bind\u27e9\n\ninstance : Mem \u03b1 (Option \u03b1) := \u27e8\u03bb a b => b = some a\u27e9\n\n@[simp] theorem mem_def {a : \u03b1} {b : Option \u03b1} : a \u2208 b \u2194 b = some a := sorry\n\nlemma ne_none_iff_exists {o : Option \u03b1} : \n  o \u2260 none \u2194 \u2203 (x : \u03b1), some x = o := \n  sorry\n\nlemma bind_eq_bind {f : \u03b1 \u2192 Option \u03b2} {x : Option \u03b1} :\n  x >>= f = x.bind f := \n  rfl\n\n@[simp] theorem bind_eq_some {x : Option \u03b1} {f : \u03b1 \u2192 Option \u03b2} {b : \u03b2} :\n  x >>= f = some b \u2194 \u2203 a, x = some a \u2227 f a = some b := \n  sorry\n\n@[simp] theorem bind_eq_none {o : Option \u03b1} {f : \u03b1 \u2192 Option \u03b2} :\n  o >>= f = none \u2194 (\u2200 b a, a \u2208 o \u2192 b \u2209 f a) := \n  sorry\n\n@[simp] theorem some_orelse (a : \u03b1) (x : Option \u03b1) : (some a <|> x) = some a := sorry\n\n@[simp] theorem orelse_none (x : Option \u03b1) : (x <|> none) = x := sorry\n\n@[simp] theorem none_bind {\u03b1 \u03b2} (f : \u03b1 \u2192 Option \u03b2) : 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) 2014 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Leonardo de Moura, Jeremy Avigad, Floris van Doorn\n-/\nimport Mathlib.PrePort\nimport Mathlib.Lean3Lib.init.logic\nimport Mathlib.Lean3Lib.init.wf\n\nuniverses u v \n\nnamespace Mathlib\n\ntheorem ex_of_psig {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} : (psigma fun (x : \u03b1) => p x) \u2192 \u2203 (x : \u03b1), p x :=\n  fun (\u1fb0 : psigma fun (x : \u03b1) => p x) =>\n    psigma.cases_on \u1fb0\n      fun (\u1fb0_fst : \u03b1) (\u1fb0_snd : p \u1fb0_fst) => idRhs (\u2203 (x : \u03b1), p x) (Exists.intro \u1fb0_fst \u1fb0_snd)\n\nprotected theorem sigma.eq {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v} {p\u2081 : sigma fun (a : \u03b1) => \u03b2 a}\n    {p\u2082 : sigma fun (a : \u03b1) => \u03b2 a} (h\u2081 : sigma.fst p\u2081 = sigma.fst p\u2082) :\n    eq.rec_on h\u2081 (sigma.snd p\u2081) = sigma.snd p\u2082 \u2192 p\u2081 = p\u2082 :=\n  sorry\n\nprotected theorem psigma.eq {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {p\u2081 : psigma \u03b2} {p\u2082 : psigma \u03b2}\n    (h\u2081 : psigma.fst p\u2081 = psigma.fst p\u2082) : eq.rec_on h\u2081 (psigma.snd p\u2081) = psigma.snd p\u2082 \u2192 p\u2081 = p\u2082 :=\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/Lean3Lib/init/data/sigma/basic_auto.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191460821871, "lm_q2_score": 0.6513548646660542, "lm_q1q2_score": 0.4618230699420043}}
{"text": "import Lean.Data.HashMap\nimport Lean.Data.HashSet\nnamespace MWE4\n\nstructure State where\n  declarations: Lean.HashMap String (Lean.HashSet String)\n\n-- all declaration values must be declaration keys\ndef State.wff: State \u2192 Bool := fun s => s.declarations.toList.all fun (_, xs) => xs.toList.all s.declarations.contains\n\ndef State.withDeclaration (s: State) (d: String) : State := \n  match s.declarations.contains d with\n  | true => s\n  | false => { s with declarations := s.declarations.insert d .empty }\n\ndef State.withSpecialization (s: State) (sub: String) (sup: String): State :=\n  let s := s.withDeclaration sup\n  { s with declarations := s.declarations.insert sub ((s.declarations.findD sub .empty).insert sup) }\n\ntheorem State.withDeclarationWff (s: State) (d: String) : s.wff \u2192 (s.withDeclaration d).wff := sorry\n\ntheorem State.withSpecializationWff (s: State) (sub: String) (sup: String): s.wff \u2192 (s.withSpecialization sub sup).wff := sorry\n\nend MWE4\n", "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/MWE4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7090191337850933, "lm_q2_score": 0.6513548714339145, "lm_q1q2_score": 0.46182306673077483}}
{"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 \u25b8 x.1.zero_mem\n\nsection\nvariables (R) (S : Type v) [comm_ring S]\n\n/-- The prime spectrum of `R \u00d7 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 \u00d7 S) \u2243 prime_spectrum R \u2295 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 \u22a4 :=\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 \u22a4 x.as_ideal :=\nby { cases x, refl }\n\nend\n\n@[ext] lemma ext {x y : prime_spectrum R} :\n  x = y \u2194 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 \u2286 x.as_ideal}\n\n@[simp] lemma mem_zero_locus (x : prime_spectrum R) (s : set R) :\n  x \u2208 zero_locus s \u2194 s \u2286 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\u2a05 (x : prime_spectrum R) (h : x \u2208 t), x.as_ideal\n\nlemma coe_vanishing_ideal (t : set (prime_spectrum R)) :\n  (vanishing_ideal t : set R) = {f : R | \u2200 x : prime_spectrum R, x \u2208 t \u2192 f \u2208 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 \u2208 vanishing_ideal t \u2194 \u2200 x : prime_spectrum R, x \u2208 t \u2192 f \u2208 x.as_ideal :=\nby rw [\u2190 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 \u2286 zero_locus I \u2194 I \u2264 vanishing_ideal t :=\n\u27e8\u03bb h f k, (mem_vanishing_ideal _ _).mpr (\u03bb x j, (mem_zero_locus _ _).mpr (h j) k), \u03bb h,\n  \u03bb x j, (mem_zero_locus _ _).mpr (le_trans h (\u03bb f h, ((mem_vanishing_ideal _ _).mp h) x j))\u27e9\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  (\u03bb I, zero_locus I) (\u03bb t, vanishing_ideal t) :=\n\u03bb 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  (\u03bb s, zero_locus s) (\u03bb 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 \u2286 zero_locus s \u2194 s \u2286 vanishing_ideal t :=\n(gc_set R) s t\n\nend gc\n\nlemma subset_vanishing_ideal_zero_locus (s : set R) :\n  s \u2286 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 \u2264 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 $ \u03bb f,\nbegin\n  rw [mem_vanishing_ideal, ideal.radical_eq_Inf, submodule.mem_Inf],\n  exact \u27e8(\u03bb h x hx, h \u27e8x, hx.2\u27e9 hx.1), (\u03bb h x hx, h x.1 \u27e8hx, x.2\u27e9)\u27e9\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 \u25b8 congr_fun (gc R).l_u_l_eq_l I\n\nlemma subset_zero_locus_vanishing_ideal (t : set (prime_spectrum R)) :\n  t \u2286 zero_locus (vanishing_ideal t) :=\n(gc R).l_u_le t\n\nlemma zero_locus_anti_mono {s t : set R} (h : s \u2286 t) : zero_locus t \u2286 zero_locus s :=\n(gc_set R).monotone_l h\n\nlemma zero_locus_anti_mono_ideal {s t : ideal R} (h : s \u2264 t) :\n  zero_locus (t : set R) \u2286 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 \u2286 t) :\n  vanishing_ideal t \u2264 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) \u2286 zero_locus (J : set R) \u2194 J \u2264 I.radical :=\n\u27e8\u03bb h, ideal.radical_le_radical_iff.mp (vanishing_ideal_zero_locus_eq_radical I \u25b8\n  vanishing_ideal_zero_locus_eq_radical J \u25b8 vanishing_ideal_anti_mono h),\n\u03bb h, zero_locus_radical I \u25b8 zero_locus_anti_mono_ideal h\u27e9\n\nlemma zero_locus_subset_zero_locus_singleton_iff (f g : R) :\n  zero_locus ({f} : set R) \u2286 zero_locus {g} \u2194 g \u2208 (ideal.span ({f} : set R)).radical :=\nby rw [\u2190 zero_locus_span {f}, \u2190 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 ((\u22a5 : 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 (\u2205 : set R) = set.univ :=\n(gc_set R).l_bot\n\n@[simp] lemma vanishing_ideal_univ :\n  vanishing_ideal (\u2205 : set (prime_spectrum R)) = \u22a4 :=\nby simpa using (gc R).u_top\n\nlemma zero_locus_empty_of_one_mem {s : set R} (h : (1:R) \u2208 s) :\n  zero_locus s = \u2205 :=\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 = \u22a4, { 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) = \u2205 :=\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) = \u2205 \u2194 I = \u22a4 :=\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 \u27e8M, hM, hIM\u27e9,\n    exact \u27e8\u27e8M, hM.is_prime\u27e9, hIM\u27e9 },\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) = \u2205 :=\nzero_locus_empty_of_one_mem (set.mem_univ 1)\n\nlemma zero_locus_sup (I J : ideal R) :\n  zero_locus ((I \u2294 J : ideal R) : set R) = zero_locus I \u2229 zero_locus J :=\n(gc R).l_sup\n\nlemma zero_locus_union (s s' : set R) :\n  zero_locus (s \u222a s') = zero_locus s \u2229 zero_locus s' :=\n(gc_set R).l_sup\n\nlemma vanishing_ideal_union (t t' : set (prime_spectrum R)) :\n  vanishing_ideal (t \u222a t') = vanishing_ideal t \u2293 vanishing_ideal t' :=\n(gc R).u_inf\n\nlemma zero_locus_supr {\u03b9 : Sort*} (I : \u03b9 \u2192 ideal R) :\n  zero_locus ((\u2a06 i, I i : ideal R) : set R) = (\u22c2 i, zero_locus (I i)) :=\n(gc R).l_supr\n\nlemma zero_locus_Union {\u03b9 : Sort*} (s : \u03b9 \u2192 set R) :\n  zero_locus (\u22c3 i, s i) = (\u22c2 i, zero_locus (s i)) :=\n(gc_set R).l_supr\n\nlemma zero_locus_bUnion (s : set (set R)) :\n  zero_locus (\u22c3 s' \u2208 s, s' : set R) = \u22c2 s' \u2208 s, zero_locus s' :=\nby simp only [zero_locus_Union]\n\nlemma vanishing_ideal_Union {\u03b9 : Sort*} (t : \u03b9 \u2192 set (prime_spectrum R)) :\n  vanishing_ideal (\u22c3 i, t i) = (\u2a05 i, vanishing_ideal (t i)) :=\n(gc R).u_infi\n\nlemma zero_locus_inf (I J : ideal R) :\n  zero_locus ((I \u2293 J : ideal R) : set R) = zero_locus I \u222a zero_locus J :=\nset.ext $ \u03bb x, by simpa using x.2.inf_le\n\nlemma union_zero_locus (s s' : set R) :\n  zero_locus s \u222a zero_locus s' = zero_locus ((ideal.span s) \u2293 (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 \u222a zero_locus J :=\nset.ext $ \u03bb 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} \u222a zero_locus {g} :=\nset.ext $ \u03bb x, by simpa using x.2.mul_mem_iff_mem_or_mem\n\n@[simp] lemma zero_locus_pow (I : ideal R) {n : \u2115} (hn : 0 < n) :\n  zero_locus ((I ^ n : ideal R) : set R) = zero_locus I :=\nzero_locus_radical (I ^ n) \u25b8 (I.radical_pow n hn).symm \u25b8 zero_locus_radical I\n\n@[simp] lemma zero_locus_singleton_pow (f : R) (n : \u2115) (hn : 0 < n) :\n  zero_locus ({f ^ n} : set R) = zero_locus {f} :=\nset.ext $ \u03bb 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 \u2294 vanishing_ideal t' \u2264 vanishing_ideal (t \u2229 t') :=\nbegin\n  intros r,\n  rw [submodule.mem_sup, mem_vanishing_ideal],\n  rintro \u27e8f, hf, g, hg, rfl\u27e9 x \u27e8hxt, hxt'\u27e9,\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 \u2208 (zero_locus {f} : set (prime_spectrum R))\u1d9c \u2194 f \u2209 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  (\u27e8set.univ, by simp\u27e9)\n  begin\n    intros Zs h,\n    rw set.sInter_eq_Inter,\n    let f : Zs \u2192 set R := \u03bb i, classical.some (h i.2),\n    have hf : \u2200 i : Zs, \u2191i = zero_locus (f i) := \u03bb i, (classical.some_spec (h i.2)).symm,\n    simp only [hf],\n    exact \u27e8_, zero_locus_Union _\u27e9\n  end\n  (by { rintro _ _ \u27e8s, rfl\u27e9 \u27e8t, rfl\u27e9, exact \u27e8_, (union_zero_locus s t).symm\u27e9 })\n\nlemma is_open_iff (U : set (prime_spectrum R)) :\n  is_open U \u2194 \u2203 s, U\u1d9c = zero_locus s :=\nby simp only [@eq_comm _ U\u1d9c]; refl\n\nlemma is_closed_iff_zero_locus (Z : set (prime_spectrum R)) :\n  is_closed Z \u2194 \u2203 s, Z = zero_locus s :=\nby rw [\u2190 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 \u27e8s, rfl\u27e9 }\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' \u27e8ht', ht\u27e9,\n    obtain \u27e8fs, rfl\u27e9 : \u2203 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 \u25b8 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 \u2192+* S) : prime_spectrum S \u2192 prime_spectrum R :=\n\u03bb y, \u27e8ideal.comap f y.as_ideal, by exact ideal.is_prime.comap _\u27e9\n\nvariables (f : R \u2192+* 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 $ \u03bb _, subtype.ext $ ideal.ext $ \u03bb _, iff.rfl\n\n@[simp] lemma comap_comp (f : R \u2192+* S) (g : S \u2192+* S') :\n  comap (g.comp f) = comap f \u2218 comap g :=\nfunext $ \u03bb _, subtype.ext $ ideal.ext $ \u03bb _, iff.rfl\n\n@[simp] lemma preimage_comap_zero_locus (s : set R) :\n  (comap f) \u207b\u00b9' (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 \u2192+* S) : continuous (comap f) :=\nbegin\n  rw continuous_iff_is_closed,\n  simp only [is_closed_iff_zero_locus],\n  rintro _ \u27e8s, rfl\u27e9,\n  exact \u27e8_, preimage_comap_zero_locus f s\u27e9\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 \u2209 x.as_ideal },\n  property := \u27e8{r}, set.ext $ \u03bb x, set.singleton_subset_iff.trans $ not_not.symm\u27e9 }\n\n@[simp] lemma mem_basic_open (f : R) (x : prime_spectrum R) :\n  x \u2208 basic_open f \u2194 f \u2209 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})\u1d9c :=\nset.ext $ \u03bb 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) = \u22a4 :=\ntopological_space.opens.ext $ by {simp, refl}\n\n@[simp] lemma basic_open_zero : basic_open (0 : R) = \u22a5 :=\ntopological_space.opens.ext $ by {simp, refl}\n\nlemma basic_open_le_basic_open_iff (f g : R) :\n  basic_open f \u2264 basic_open g \u2194 f \u2208 (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 \u2293 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) \u2264 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) \u2264 basic_open g :=\nby { rw basic_open_mul f g, exact inf_le_right }\n\n@[simp] lemma basic_open_pow (f : R) (n : \u2115) (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 (\u03bb (r : R), (basic_open r : set (prime_spectrum R)))) :=\nbegin\n  apply topological_space.is_topological_basis_of_open_of_nhds,\n  { rintros _ \u27e8r, rfl\u27e9,\n    exact is_open_basic_open },\n  { rintros p U hp \u27e8s, hs\u27e9,\n    rw [\u2190 compl_compl U, set.mem_compl_eq, \u2190 hs, mem_zero_locus, set.not_subset] at hp,\n    obtain \u27e8f, hfs, hfp\u27e9 := hp,\n    refine \u27e8basic_open f, \u27e8f, rfl\u27e9, hfp, _\u27e9,\n    rw [\u2190 set.compl_subset_compl, \u2190 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 $ \u03bb \u03b9 Z hZc hZ,\nbegin\n  let I : \u03b9 \u2192 ideal R := \u03bb i, vanishing_ideal (Z i),\n  have hI : \u2200 i, Z i = zero_locus (I i) := \u03bb 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, \u2190 set.diff_eq,\n      set.diff_eq_empty, funext hI, \u2190 zero_locus_supr] at hZ,\n  obtain \u27e8n, hn\u27e9 : f \u2208 (\u2a06 (i : \u03b9), I i).radical,\n  { rw \u2190 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 \u27e8s, hs\u27e9,\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, \u2190 set.diff_eq,\n           set.diff_eq_empty, hI, \u2190 zero_locus_supr],\n  rw \u2190 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 \u27e8n, hs\u27e9\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 \u2264 y` if and only if `y \u2208 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 \u2264 y.as_ideal \u2194 x \u2264 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 \u2194 x < y :=\nsubtype.coe_lt_coe\n\nlemma le_iff_mem_closure (x y : prime_spectrum R) :\n  x \u2264 y \u2194 y \u2208 closure ({x} : set (prime_spectrum R)) :=\nby rw [\u2190 as_ideal_le_as_ideal, \u2190 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 : \u00ac\u00acp) : p :=\n  by_contradiction\n    (assume h1 : \u00acp,\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 : Sort*} {\u03b2 : Sort*}\n\nnamespace setoid\n\nlemma ext {\u03b1 : Sort*} :\n  \u2200{s t : setoid \u03b1}, (\u2200a b, @setoid.r \u03b1 s a b \u2194 @setoid.r \u03b1 t a b) \u2192 s = t\n| \u27e8r, _\u27e9 \u27e8p, _\u27e9 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} {rb : \u03b2 \u2192 \u03b2 \u2192 Prop} {\u03c6 : quot ra \u2192 quot rb \u2192 Sort*}\nlocal notation `\u27e6`:max a `\u27e7` := quot.mk _ a\n\ninstance [inhabited \u03b1] : inhabited (quot ra) := \u27e8\u27e6default _\u27e7\u27e9\n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082 (qa : quot ra) (qb : quot rb) (f : \u03a0 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n  (ca : \u2200 {b a\u2081 a\u2082}, ra a\u2081 a\u2082 \u2192 f a\u2081 b == f a\u2082 b)\n  (cb : \u2200 {a b\u2081 b\u2082}, rb b\u2081 b\u2082 \u2192 f a b\u2081 == f a b\u2082) : \u03c6 qa qb :=\nquot.hrec_on qa (\u03bb a, quot.hrec_on qb (f a) (\u03bb b\u2081 b\u2082 pb, cb pb)) $ \u03bb a\u2081 a\u2082 pa,\n  quot.induction_on qb $ \u03bb b,\n    calc @quot.hrec_on _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2081) (@cb _)\n          == f a\u2081 b                                     : by simp [heq_self_iff_true]\n      ... == f a\u2082 b                                     : ca pa\n      ... == @quot.hrec_on _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2082) (@cb _) : by simp [heq_self_iff_true]\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` such that `ra x y` implies `rb (f x) (f y)`\nto a map `quot ra \u2192 quot rb`. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : (ra \u21d2 rb) f f) : quot ra \u2192 quot rb :=\nquot.lift (\u03bb x, \u27e6f x\u27e7) $ assume x y (h\u2081 : ra x y), quot.sound $ h h\u2081\n\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `quot ra \u2192 quot ra'`. -/\nprotected def map_right {ra' : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : \u2200a\u2081 a\u2082, ra a\u2081 a\u2082 \u2192 ra' a\u2081 a\u2082) :\n  quot ra \u2192 quot ra' :=\nquot.map id h\n\n/-- weaken the relation of a quotient -/\ndef factor {\u03b1 : Type*} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) :\n  quot r \u2192 quot s :=\nquot.lift (quot.mk s) (\u03bb x y rxy, quot.sound (h x y rxy))\n\nlemma factor_mk_eq {\u03b1 : Type*} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) :\n  factor r s h \u2218 quot.mk _ = quot.mk _ := rfl\n\nvariables {\u03b3 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n\n/-- **Alias** of `quot.lift_beta`. -/\nlemma lift_mk (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) (a : \u03b1) :\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 : \u03b1) (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) :\n  quot.lift_on (quot.mk r a) f h = f a := rfl\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2`. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift\u2082\n  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b)\n  (q\u2081 : quot r) (q\u2082 : quot s) : \u03b3 :=\nquot.lift (\u03bb a, quot.lift (f a) (hr a))\n(\u03bb a\u2081 a\u2082 ha, funext (\u03bb q, quot.induction_on q (\u03bb b, hs a\u2081 a\u2082 b ha)))\nq\u2081 q\u2082\n\n@[simp]\nlemma lift\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) (a : \u03b1) (b : \u03b2) :\n  quot.lift\u2082 f hr hs (quot.mk r a) (quot.mk s b) = f a b := rfl\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` and applies it. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift_on\u2082 (p : quot r) (q : quot s) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) : \u03b3 := quot.lift\u2082 f hr hs p q\n\n@[simp]\nlemma lift_on\u2082_mk (a : \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) :\n  quot.lift_on\u2082 (quot.mk r a) (quot.mk s b) f hr hs = f a b := rfl\n\nvariables {t : \u03b3 \u2192 \u03b3 \u2192 Prop}\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` wih values in a quotient of\n`\u03b3`. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b))\n  (q\u2081 : quot r) (q\u2082 : quot s) : quot t :=\nquot.lift\u2082 (\u03bb a b, quot.mk t $ f a b) (\u03bb a b\u2081 b\u2082 hb, quot.sound (hr a b\u2081 b\u2082 hb))\n(\u03bb a\u2081 a\u2082 b ha, quot.sound (hs a\u2081 a\u2082 b ha)) q\u2081 q\u2082\n\n@[simp]\nlemma map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b))\n  (a : \u03b1) (b : \u03b2) : quot.map\u2082 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\u2082\n  {\u03b4 : quot r \u2192 quot s \u2192 Prop} (q\u2081 : quot r) (q\u2082 : quot s)\n  (h : \u2200 a b, \u03b4 (quot.mk r a) (quot.mk s b)) : \u03b4 q\u2081 q\u2082 :=\nquot.ind (\u03bb a\u2081, quot.ind (\u03bb a\u2082, h a\u2081 a\u2082) q\u2082) q\u2081\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on\u2083\n  {\u03b4 : quot r \u2192 quot s \u2192 quot t \u2192 Prop} (q\u2081 : quot r) (q\u2082 : quot s) (q\u2083 : quot t)\n  (h : \u2200 a b c, \u03b4 (quot.mk r a) (quot.mk s b) (quot.mk t c)) : \u03b4 q\u2081 q\u2082 q\u2083 :=\nquot.ind (\u03bb a\u2081, quot.ind (\u03bb a\u2082, quot.ind (\u03bb a\u2083, h a\u2081 a\u2082 a\u2083) q\u2083) q\u2082) q\u2081\n\nend quot\n\nnamespace quotient\nvariables [sa : setoid \u03b1] [sb : setoid \u03b2]\nvariables {\u03c6 : quotient sa \u2192 quotient sb \u2192 Sort*}\n\ninstance [inhabited \u03b1] : inhabited (quotient sa) := \u27e8\u27e6default _\u27e7\u27e9\n\n/-- Induction on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082 (qa : quotient sa) (qb : quotient sb) (f : \u03a0 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) : \u03c6 qa qb :=\nquot.hrec_on\u2082 qa qb f\n  (\u03bb _ _ _ p, c _ _ _ _ p (setoid.refl _))\n  (\u03bb _ _ _ p, c _ _ _ _ (setoid.refl _) p)\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `quotient sa \u2192 quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : ((\u2248) \u21d2 (\u2248)) f f) : quotient sa \u2192 quotient sb :=\nquot.map f h\n\n@[simp] lemma map_mk (f : \u03b1 \u2192 \u03b2) (h : ((\u2248) \u21d2 (\u2248)) f f) (x : \u03b1) :\n  quotient.map f h (\u27e6x\u27e7 : quotient sa) = (\u27e6f x\u27e7 : quotient sb) :=\nrfl\n\nvariables {\u03b3 : Sort*} [sc : setoid \u03b3]\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` that sends equivalent elements to equivalent elements\nto a function `f : quotient sa \u2192 quotient sb \u2192 quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u2248) \u21d2 (\u2248) \u21d2 (\u2248)) f f) :\n  quotient sa \u2192 quotient sb \u2192 quotient sc :=\nquotient.lift\u2082 (\u03bb x y, \u27e6f x y\u27e7) (\u03bb x\u2081 y\u2081 x\u2082 y\u2082 h\u2081 h\u2082, quot.sound $ h h\u2081 h\u2082)\n\nend quotient\n\nlemma quot.eq {\u03b1 : Type*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {x y : \u03b1} :\n  quot.mk r x = quot.mk r y \u2194 eqv_gen r x y :=\n\u27e8quot.exact r, quot.eqv_gen_sound\u27e9\n\n@[simp] theorem quotient.eq [r : setoid \u03b1] {x y : \u03b1} : \u27e6x\u27e7 = \u27e6y\u27e7 \u2194 x \u2248 y :=\n\u27e8quotient.exact, quotient.sound\u27e9\n\ntheorem forall_quotient_iff {\u03b1 : Type*} [r : setoid \u03b1] {p : quotient r \u2192 Prop} :\n  (\u2200a:quotient r, p a) \u2194 (\u2200a:\u03b1, p \u27e6a\u27e7) :=\n\u27e8assume h x, h _, assume h a, a.induction_on h\u27e9\n\n@[simp] lemma quotient.lift_mk [s : setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b)\n  (x : \u03b1) :\n  quotient.lift f h (quotient.mk x) = f x := rfl\n\n@[simp] lemma quotient.lift_on_mk [s : setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b)\n  (x : \u03b1) :\n  quotient.lift_on (quotient.mk x) f h = f x := rfl\n\n@[simp] theorem quotient.lift_on\u2082_mk {\u03b1 : Sort*} {\u03b2 : Sort*} [setoid \u03b1] (f : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n  (h : \u2200 (a\u2081 a\u2082 b\u2081 b\u2082 : \u03b1), a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) (x y : \u03b1) :\n  quotient.lift_on\u2082 (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 : \u03b1 \u2192 \u03b1 \u2192 Prop) : function.surjective (quot.mk r) :=\nquot.exists_rep\n\n/-- `quotient.mk` is a surjective function. -/\nlemma surjective_quotient_mk (\u03b1 : Sort*) [s : setoid \u03b1] :\n  function.surjective (quotient.mk : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} (q : quot r) : \u03b1 :=\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 : \u03b1 \u2192 \u03b1 \u2192 Prop} : quot r \u2192 \u03b1 := unchecked_cast\n\n@[simp] theorem quot.out_eq {r : \u03b1 \u2192 \u03b1 \u2192 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 \u03b1] : quotient s \u2192 \u03b1 := quot.out\n\n@[simp] theorem quotient.out_eq [s : setoid \u03b1] (q : quotient s) : \u27e6q.out\u27e7 = q := q.out_eq\n\ntheorem quotient.mk_out [s : setoid \u03b1] (a : \u03b1) : \u27e6a\u27e7.out \u2248 a :=\nquotient.exact (quotient.out_eq _)\n\ninstance pi_setoid {\u03b9 : Sort*} {\u03b1 : \u03b9 \u2192 Sort*} [\u2200 i, setoid (\u03b1 i)] : setoid (\u03a0 i, \u03b1 i) :=\n{ r := \u03bb a b, \u2200 i, a i \u2248 b i,\n  iseqv := \u27e8\n    \u03bb a i, setoid.refl _,\n    \u03bb a b h i, setoid.symm (h _),\n    \u03bb a b c h\u2081 h\u2082 i, setoid.trans (h\u2081 _) (h\u2082 _)\u27e9 }\n\n/-- Given a function `f : \u03a0 i, quotient (S i)`, returns the class of functions `\u03a0 i, \u03b1 i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def quotient.choice {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [S : \u03a0 i, setoid (\u03b1 i)]\n  (f : \u03a0 i, quotient (S i)) : @quotient (\u03a0 i, \u03b1 i) (by apply_instance) :=\n\u27e6\u03bb i, (f i).out\u27e7\n\ntheorem quotient.choice_eq {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u03a0 i, setoid (\u03b1 i)]\n  (f : \u03a0 i, \u03b1 i) : quotient.choice (\u03bb i, \u27e6f i\u27e7) = \u27e6f\u27e7 :=\nquotient.sound $ \u03bb i, quotient.mk_out _\n\nlemma nonempty_quotient_iff (s : setoid \u03b1) : nonempty (quotient s) \u2194 nonempty \u03b1 :=\n\u27e8assume \u27e8a\u27e9, quotient.induction_on a nonempty.intro, assume \u27e8a\u27e9, \u27e8\u27e6a\u27e7\u27e9\u27e9\n\n/-- `trunc \u03b1` is the quotient of `\u03b1` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty \u03b1`, but unlike `nonempty \u03b1`, `trunc \u03b1` is data,\n  so the VM representation is the same as `\u03b1`, and so this can be used to\n  maintain computability. -/\ndef {u} trunc (\u03b1 : Sort u) : Sort u := @quot \u03b1 (\u03bb _ _, true)\n\ntheorem true_equivalence : @equivalence \u03b1 (\u03bb _ _, true) :=\n\u27e8\u03bb _, trivial, \u03bb _ _ _, trivial, \u03bb _ _ _ _ _, trivial\u27e9\n\nnamespace trunc\n\n/-- Constructor for `trunc \u03b1` -/\ndef mk (a : \u03b1) : trunc \u03b1 := quot.mk _ a\n\ninstance [inhabited \u03b1] : inhabited (trunc \u03b1) := \u27e8mk (default _)\u27e9\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : \u03b1 \u2192 \u03b2) (c : \u2200 a b : \u03b1, f a = f b) : trunc \u03b1 \u2192 \u03b2 :=\nquot.lift f (\u03bb a b _, c a b)\n\ntheorem ind {\u03b2 : trunc \u03b1 \u2192 Prop} : (\u2200 a : \u03b1, \u03b2 (mk a)) \u2192 \u2200 q : trunc \u03b1, \u03b2 q := quot.ind\n\nprotected theorem lift_mk (f : \u03b1 \u2192 \u03b2) (c) (a : \u03b1) : lift f c (mk a) = f a := rfl\n\n/-- Lift a constant function on `q : trunc \u03b1`. -/\n@[reducible, elab_as_eliminator]\nprotected def lift_on (q : trunc \u03b1) (f : \u03b1 \u2192 \u03b2)\n  (c : \u2200 a b : \u03b1, f a = f b) : \u03b2 := lift f c q\n\n@[elab_as_eliminator]\nprotected theorem induction_on {\u03b2 : trunc \u03b1 \u2192 Prop} (q : trunc \u03b1)\n  (h : \u2200 a, \u03b2 (mk a)) : \u03b2 q := ind h q\n\ntheorem exists_rep (q : trunc \u03b1) : \u2203 a : \u03b1, mk a = q := quot.exists_rep q\n\nattribute [elab_as_eliminator]\nprotected theorem induction_on\u2082 {C : trunc \u03b1 \u2192 trunc \u03b2 \u2192 Prop} (q\u2081 : trunc \u03b1) (q\u2082 : trunc \u03b2)\n  (h : \u2200 a b, C (mk a) (mk b)) : C q\u2081 q\u2082 :=\ntrunc.induction_on q\u2081 $ \u03bb a\u2081, trunc.induction_on q\u2082 (h a\u2081)\n\nprotected theorem eq (a b : trunc \u03b1) : a = b :=\ntrunc.induction_on\u2082 a b (\u03bb x y, quot.sound trivial)\n\ninstance : subsingleton (trunc \u03b1) := \u27e8trunc.eq\u27e9\n\n/-- The `bind` operator for the `trunc` monad. -/\ndef bind (q : trunc \u03b1) (f : \u03b1 \u2192 trunc \u03b2) : trunc \u03b2 :=\ntrunc.lift_on q f (\u03bb a b, trunc.eq _ _)\n\n/-- A function `f : \u03b1 \u2192 \u03b2` defines a function `map f : trunc \u03b1 \u2192 trunc \u03b2`. -/\ndef map (f : \u03b1 \u2192 \u03b2) (q : trunc \u03b1) : trunc \u03b2 := bind q (trunc.mk \u2218 f)\n\ninstance : monad trunc :=\n{ pure := @trunc.mk,\n  bind := @trunc.bind }\n\ninstance : is_lawful_monad trunc :=\n{ id_map := \u03bb \u03b1 q, trunc.eq _ _,\n  pure_bind := \u03bb \u03b1 \u03b2 q f, rfl,\n  bind_assoc := \u03bb \u03b1 \u03b2 \u03b3 x f g, trunc.eq _ _ }\n\nvariable {C : trunc \u03b1 \u2192 Sort*}\n\n/-- Recursion/induction principle for `trunc`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec\n   (f : \u03a0 a, C (mk a)) (h : \u2200 (a b : \u03b1), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n   (q : trunc \u03b1) : C q :=\nquot.rec f (\u03bb a b _, h a b) q\n\n/-- A version of `trunc.rec` taking `q : trunc \u03b1` as the first argument. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on (q : trunc \u03b1) (f : \u03a0 a, C (mk a))\n  (h : \u2200 (a b : \u03b1), (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   [\u2200 a, subsingleton (C (mk a))] (q : trunc \u03b1) (f : \u03a0 a, C (mk a)) : C q :=\ntrunc.rec f (\u03bb a b, subsingleton.elim _ (f b)) q\n\n/-- Noncomputably extract a representative of `trunc \u03b1` (using the axiom of choice). -/\nnoncomputable def out : trunc \u03b1 \u2192 \u03b1 := quot.out\n\n@[simp] theorem out_eq (q : trunc \u03b1) : mk q.out = q := trunc.eq _ _\n\nprotected theorem nonempty (q : trunc \u03b1) : nonempty \u03b1 :=\nnonempty_of_exists q.exists_rep\n\nend trunc\n\nnamespace quotient\nvariables {\u03b3 : Sort*} {\u03c6 : Sort*}\n  {s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2} {s\u2083 : setoid \u03b3}\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 \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk' (a : \u03b1) : quotient s\u2081 := quot.mk s\u2081.1 a\n\n/-- `quotient.mk'` is a surjective function. -/\nlemma surjective_quotient_mk' : function.surjective (quotient.mk' : \u03b1 \u2192 quotient s\u2081) :=\nquot.exists_rep\n\n/-- A version of `quotient.lift_on` taking `{s : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on' (q : quotient s\u2081) (f : \u03b1 \u2192 \u03c6)\n  (h : \u2200 a b, @setoid.r \u03b1 s\u2081 a b \u2192 f a = f b) : \u03c6 := quotient.lift_on q f h\n\n@[simp]\nprotected lemma lift_on'_mk' (f : \u03b1 \u2192 \u03c6) (h) (x : \u03b1) :\n  quotient.lift_on' (@quotient.mk' _ s\u2081 x) f h = f x := rfl\n\n/-- A version of `quotient.lift_on\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on\u2082' (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082, @setoid.r \u03b1 s\u2081 a\u2081 b\u2081 \u2192 @setoid.r \u03b2 s\u2082 a\u2082 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) : \u03b3 :=\nquotient.lift_on\u2082 q\u2081 q\u2082 f h\n\n@[simp]\nprotected lemma lift_on\u2082'_mk' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (a : \u03b1) (b : \u03b2) :\n  quotient.lift_on\u2082' (@quotient.mk' _ s\u2081 a) (@quotient.mk' _ s\u2082 b) f h = f a b := rfl\n\n/-- A version of `quotient.ind` taking `{s : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator]\nprotected lemma ind' {p : quotient s\u2081 \u2192 Prop}\n  (h : \u2200 a, p (quotient.mk' a)) (q : quotient s\u2081) : p q :=\nquotient.ind h q\n\n/-- A version of `quotient.ind\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma ind\u2082' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Prop}\n  (h : \u2200 a\u2081 a\u2082, p (quotient.mk' a\u2081) (quotient.mk' a\u2082))\n  (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) : p q\u2081 q\u2082 :=\nquotient.ind\u2082 h q\u2081 q\u2082\n\n/-- A version of `quotient.induction_on` taking `{s : setoid \u03b1}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_eliminator]\nprotected lemma induction_on' {p : quotient s\u2081 \u2192 Prop} (q : quotient s\u2081)\n  (h : \u2200 a, p (quotient.mk' a)) : p q := quotient.induction_on q h\n\n/-- A version of `quotient.induction_on\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on\u2082' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Prop} (q\u2081 : quotient s\u2081)\n  (q\u2082 : quotient s\u2082) (h : \u2200 a\u2081 a\u2082, p (quotient.mk' a\u2081) (quotient.mk' a\u2082)) : p q\u2081 q\u2082 :=\nquotient.induction_on\u2082 q\u2081 q\u2082 h\n\n/-- A version of `quotient.induction_on\u2083` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2} {s\u2083 : setoid \u03b3}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on\u2083' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 quotient s\u2083 \u2192 Prop}\n  (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (q\u2083 : quotient s\u2083)\n  (h : \u2200 a\u2081 a\u2082 a\u2083, p (quotient.mk' a\u2081) (quotient.mk' a\u2082) (quotient.mk' a\u2083)) : p q\u2081 q\u2082 q\u2083 :=\nquotient.induction_on\u2083 q\u2081 q\u2082 q\u2083 h\n\n/-- A version of `quotient.rec_on_subsingleton` taking `{s\u2081 : setoid \u03b1}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_eliminator]\nprotected def rec_on_subsingleton' {\u03c6 : quotient s\u2081 \u2192 Sort*}\n  [h : \u2200 a, subsingleton (\u03c6 \u27e6a\u27e7)] (q : quotient s\u2081) (f : \u03a0 a, \u03c6 (quotient.mk' a)) : \u03c6 q :=\nquotient.rec_on_subsingleton q f\n\n/-- A version of `quotient.rec_on_subsingleton\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b1}`\nas implicit arguments instead of instance arguments. -/\nattribute [reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton\u2082'\n   {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*} [h : \u2200 a b, subsingleton (\u03c6 \u27e6a\u27e7 \u27e6b\u27e7)]\n   (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (f : \u03a0 a\u2081 a\u2082, \u03c6 (quotient.mk' a\u2081) (quotient.mk' a\u2082)) :\n   \u03c6 q\u2081 q\u2082 :=\nquotient.rec_on_subsingleton\u2082 q\u2081 q\u2082 f\n\n/-- Recursion on a `quotient` argument `a`, result type depends on `\u27e6a\u27e7`. -/\nprotected def hrec_on' {\u03c6 : quotient s\u2081 \u2192 Sort*} (qa : quotient s\u2081) (f : \u03a0 a, \u03c6 (quotient.mk' a))\n  (c : \u2200 a\u2081 a\u2082, a\u2081 \u2248 a\u2082 \u2192 f a\u2081 == f a\u2082) : \u03c6 qa :=\nquot.hrec_on qa f c\n\n@[simp] \n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082' {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*} (qa : quotient s\u2081)\n  (qb : quotient s\u2082) (f : \u2200 a b, \u03c6 (quotient.mk' a) (quotient.mk' b))\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) : \u03c6 qa qb :=\nquotient.hrec_on\u2082 qa qb f c\n\n@[simp] lemma hrec_on\u2082'_mk' {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*}\n  (f : \u2200 a b, \u03c6 (quotient.mk' a) (quotient.mk' b))\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) (x : \u03b1) (qb : quotient s\u2082) :\n  (quotient.mk' x).hrec_on\u2082' qb f c = qb.hrec_on' (f x) (\u03bb b\u2081 b\u2082, c _ _ _ _ (setoid.refl _)) :=\nrfl\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `quotient sa \u2192 quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : \u03b1 \u2192 \u03b2) (h : ((\u2248) \u21d2 (\u2248)) f f) :\n  quotient s\u2081 \u2192 quotient s\u2082 :=\nquot.map f h\n\n@[simp] lemma map'_mk' (f : \u03b1 \u2192 \u03b2) (h) (x : \u03b1) :\n  (quotient.mk' x : quotient s\u2081).map' f h = (quotient.mk' (f x) : quotient s\u2082) :=\nrfl\n\n/-- A version of `quotient.map\u2082` using curly braces and unification. -/\nprotected def map\u2082' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u2248) \u21d2 (\u2248) \u21d2 (\u2248)) f f) :\n  quotient s\u2081 \u2192 quotient s\u2082 \u2192 quotient s\u2083 :=\nquotient.map\u2082 f h\n\n@[simp] lemma map\u2082'_mk' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (x : \u03b1) :\n  (quotient.mk' x : quotient s\u2081).map\u2082' f h =\n    (quotient.map' (f x) (h (setoid.refl x)) : quotient s\u2082 \u2192 quotient s\u2083) :=\nrfl\n\nlemma exact' {a b : \u03b1} :\n  (quotient.mk' a : quotient s\u2081) = quotient.mk' b \u2192 @setoid.r _ s\u2081 a b :=\nquotient.exact\n\nlemma sound' {a b : \u03b1} : @setoid.r _ s\u2081 a b \u2192 @quotient.mk' \u03b1 s\u2081 a = quotient.mk' b :=\nquotient.sound\n\n@[simp]\nprotected lemma eq' {a b : \u03b1} : @quotient.mk' \u03b1 s\u2081 a = quotient.mk' b \u2194 @setoid.r _ s\u2081 a b :=\nquotient.eq\n\n/-- A version of `quotient.out` taking `{s\u2081 : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : quotient s\u2081) : \u03b1 := quotient.out a\n\n@[simp] theorem out_eq' (q : quotient s\u2081) : quotient.mk' q.out' = q := q.out_eq\n\ntheorem mk_out' (a : \u03b1) : @setoid.r \u03b1 s\u2081 (quotient.mk' a : quotient s\u2081).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 \u2192 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 = \"\u1fb0\") 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 = \"\u1fb0\") 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 (\u03b1 : Type*) [boolean_algebra \u03b1] (X Y Z P Q W : \u03b1) :\n  (X \u2294 (Y \u2294 Z)) \u2294 ((W \u2293 P \u2293 Q)\u1d9c \u2294 (P \u2294 W \u2294 Q)) = \u22a4 :=\nbegin\n  set_solver,\nend\n\nexample (T : Type*) [fintype T] [decidable_eq T] (X Y Z P Q W : finset T)  :\n  (X \u2294 (Y \u2294 Z)) \u2294 ((W \u2293 P \u2293 Q)\u1d9c \u2294 (P \u2294 W \u2294 Q)) = \u22a4 :=\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 \u222a Y) \u2265 X :=\nbegin\n  set_solver,\nend\n\nexample (T : Type*) [decidable_eq T] (x z : T) (Y : set T) :\n  x \u2208 ({z} : set T) \u2192 x = z :=\nbegin\n  set_solver,\nend\n\nexample (\u03b1 : Type*) [boolean_algebra \u03b1]  (A B C D E F G : \u03b1) :\n  A \u2264 B \u2192\n  B \u2264 C \u2192\n  C \u2264 D \u2293 E \u2192\n  D \u2264 F\u1d9c \u2192\n  (A \u2293 F = \u22a5) :=\nbegin\n  set_ext,\n  tactic.timetac \"fast\" $ (`[repeat {finisher_step}]),\nend\n\nexample (\u03b1 : Type*) [boolean_algebra \u03b1]  (A B C D E F G : \u03b1) :\n  A \u2264 B \u2192\n  B \u2264 C \u2192\n  C \u2264 D \u2293 E \u2192\n  D \u2264 F\u1d9c \u2192\n  (A \u2293 F = \u22a5) :=\nbegin\n  tactic.timetac \"slow\" $ set_solver,\nend\n \nexample (\u03b1 : Type*) (C E : set \u03b1) (hCE : C \u2293 E = \u2205) :\n  C \u2294 (E \u2294 C)\u1d9c = E\u1d9c := \nby {set_solver, }\n\nexample (\u03b1 : Type*) (C E : set \u03b1) (h : C \u2293 E = \u22a5) : \n  C \u2293 (C \u2294 E)\u1d9c = \u2205 := \nby {set_solver, } \n\nexample (X\u2080 X\u2081 X\u2082 X\u2083 X\u2084 X\u2085 X\u2086 X\u2087 X\u2088 X\u2089 : set nat) :\n  (X\u2080 \u2294 X\u2081 \u2294 (X\u2082 \u2293 X\u2083) \u2294 X\u2084 \u2294 X\u2085 \u2294 (X\u2086 \u2293 X\u2087 \u2293 X\u2088) \u2294 X\u2089)\u1d9c\n    \u2264 (X\u2089\u1d9c \u2293 ((X\u2086\u1d9c \u2294 \u22a5) \u2294 X\u2088\u1d9c \u2294 X\u2087\u1d9c\u1d9c\u1d9c) \u2293 X\u2085\u1d9c \u2293 (X\u2080\u1d9c \\ X\u2081) \u2293 (X\u2083\u1d9c \u2294 X\u2082\u1d9c) \u2293 X\u2084\u1d9c) :=\nbegin\n  tactic.timetac \"big_ext\" $ set_ext,\n  tactic.timetac \"big_finish\" $ set_solver_finisher\nend\n\n/-\nexample (X\u2080 X\u2081 X\u2082 X\u2083 X\u2084 X\u2085 X\u2086 X\u2087 X\u2088 X\u2089 : \u03b1) :\n  (X\u2080 \u2294 X\u2081 \u2294 (X\u2082 \u2293 X\u2083) \u2294 X\u2084 \u2294 X\u2085 \u2294 (X\u2086 \u2293 X\u2087 \u2293 X\u2088) \u2294 X\u2089)\u1d9c\n    \u2264 (X\u2089\u1d9c \u2293 ((X\u2086\u1d9c \u2294 \u22a5) \u2294 X\u2088\u1d9c \u2294 X\u2087\u1d9c\u1d9c\u1d9c) \u2293 X\u2085\u1d9c \u2293 (X\u2080\u1d9c \\ X\u2081) \u2293 (X\u2083\u1d9c \u2294 X\u2082\u1d9c) \u2293 X\u2084\u1d9c) :=\nby tactic.timetac \"big\" $ boolean_algebra_tactic\n\nexample (A B C D E F G : \u03b1) :\n  A \u2264 B \u2192\n  B \u2264 C \u2192\n  C \u2264 D \u2293 E \u2192\n  A \u2264 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 : \u03b1) :\n  A \u2264 B \u2192\n  B \u2264 C \u2192\n  C \u2264 D \u2293 E \u2192\n  D \u2264 F\u1d9c \u2192\n  (A \u2293 F = \u22a5) :=\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 {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op] [ha : is_associative \u03b1 op] :\n    \u03b1 \u2192 multiset \u03b1 \u2192 \u03b1 :=\n  foldr op sorry\n\ntheorem fold_eq_foldr {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (s : multiset \u03b1) :\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 {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (l : List \u03b1) : fold op b \u2191l = list.foldr op b l :=\n  rfl\n\ntheorem coe_fold_l {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (l : List \u03b1) : fold op b \u2191l = list.foldl op b l :=\n  sorry\n\ntheorem fold_eq_foldl {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (s : multiset \u03b1) :\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 \u03b1) => coe_fold_l op b l\n\n@[simp] theorem fold_zero {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) : fold op b 0 = b :=\n  rfl\n\n@[simp] theorem fold_cons_left {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (a : \u03b1) (s : multiset \u03b1) :\n    fold op b (a ::\u2098 s) = op a (fold op b s) :=\n  foldr_cons op (fold._proof_1 op)\n\ntheorem fold_cons_right {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (a : \u03b1) (s : multiset \u03b1) :\n    fold op b (a ::\u2098 s) = op (fold op b s) a :=\n  sorry\n\ntheorem fold_cons'_right {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (a : \u03b1) (s : multiset \u03b1) :\n    fold op b (a ::\u2098 s) = fold op (op b a) s :=\n  sorry\n\ntheorem fold_cons'_left {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (a : \u03b1) (s : multiset \u03b1) :\n    fold op b (a ::\u2098 s) = fold op (op a b) s :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (fold op b (a ::\u2098 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 {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b\u2081 : \u03b1) (b\u2082 : \u03b1) (s\u2081 : multiset \u03b1) (s\u2082 : multiset \u03b1) :\n    fold op (op b\u2081 b\u2082) (s\u2081 + s\u2082) = op (fold op b\u2081 s\u2081) (fold op b\u2082 s\u2082) :=\n  sorry\n\ntheorem fold_singleton {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] (b : \u03b1) (a : \u03b1) : fold op b (a ::\u2098 0) = op a b :=\n  sorry\n\ntheorem fold_distrib {\u03b1 : Type u_1} {\u03b2 : Type u_2} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] {f : \u03b2 \u2192 \u03b1} {g : \u03b2 \u2192 \u03b1} (u\u2081 : \u03b1) (u\u2082 : \u03b1) (s : multiset \u03b2) :\n    fold op (op u\u2081 u\u2082) (map (fun (x : \u03b2) => op (f x) (g x)) s) =\n        op (fold op u\u2081 (map f s)) (fold op u\u2082 (map g s)) :=\n  sorry\n\ntheorem fold_hom {\u03b1 : Type u_1} {\u03b2 : Type u_2} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] {op' : \u03b2 \u2192 \u03b2 \u2192 \u03b2} [is_commutative \u03b2 op'] [is_associative \u03b2 op']\n    {m : \u03b1 \u2192 \u03b2} (hm : \u2200 (x y : \u03b1), m (op x y) = op' (m x) (m y)) (b : \u03b1) (s : multiset \u03b1) :\n    fold op' (m b) (map m s) = m (fold op b s) :=\n  sorry\n\ntheorem fold_union_inter {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] [DecidableEq \u03b1] (s\u2081 : multiset \u03b1) (s\u2082 : multiset \u03b1) (b\u2081 : \u03b1)\n    (b\u2082 : \u03b1) :\n    op (fold op b\u2081 (s\u2081 \u222a s\u2082)) (fold op b\u2082 (s\u2081 \u2229 s\u2082)) = op (fold op b\u2081 s\u2081) (fold op b\u2082 s\u2082) :=\n  sorry\n\n@[simp] theorem fold_erase_dup_idem {\u03b1 : Type u_1} (op : \u03b1 \u2192 \u03b1 \u2192 \u03b1) [hc : is_commutative \u03b1 op]\n    [ha : is_associative \u03b1 op] [DecidableEq \u03b1] [hi : is_idempotent \u03b1 op] (s : multiset \u03b1) (b : \u03b1) :\n    fold op b (erase_dup s) = fold op b s :=\n  sorry\n\ntheorem le_smul_erase_dup {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) :\n    \u2203 (n : \u2115), s \u2264 n \u2022\u2115 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 \u2964 D` for the type of all functors from `C` to `D`.\n    (I would like a better arrow here, unfortunately \u21d2 (`\\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\u2081 v\u2081 u\u2082 v\u2082 u\u2083 v\u2083\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\u2081) [category.{u\u2081 v\u2081} C] (D : Type u\u2082) [category.{u\u2082 v\u2082} D] : Type (max u\u2081 v\u2081 u\u2082 v\u2082) :=\n(obj       : C \u2192 D)\n(map'      : \u03a0 {X Y : C}, (X \u27f6 Y) \u2192 ((obj X) \u27f6 (obj Y)))\n(map_id'   : \u2200 (X : C), map' (\ud835\udfd9 X) = \ud835\udfd9 (obj X) . obviously)\n(map_comp' : \u2200 {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z), map' (f \u226b g) = (map' f) \u226b (map' g) . obviously)\n\ninfixr ` \u2964 `:70 := functor       -- type as \\func --\n\nnamespace functor\n\nsection\nvariables {C : Type u\u2081} [\ud835\udc9e : category.{u\u2081 v\u2081} C] {D : Type u\u2082} [\ud835\udc9f : category.{u\u2082 v\u2082} D]\ninclude \ud835\udc9e \ud835\udc9f\n\ninstance : has_coe_to_fun (C \u2964 D) :=\n{ F   := \u03bb F, C \u2192 D,\n  coe := \u03bb F, F.obj }\n\ndef map (F : C \u2964 D) {X Y : C} (f : X \u27f6 Y) : (F X) \u27f6 (F Y) := F.map' f\n\n@[simp] lemma map_id (F : C \u2964 D) (X : C) : F.map (\ud835\udfd9 X) = \ud835\udfd9 (F X) :=\nbegin unfold functor.map, erw F.map_id', refl end\n@[simp] lemma map_comp (F : C \u2964 D) {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  F.map (f \u226b g) = F.map f \u226b 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 \u2964 D} (X : C) : F.obj X = F X := rfl\n@[simp] lemma mk_obj (o : C \u2192 D) (m mi mc) (X : C) :\n  ({ functor . obj := o, map' := m, map_id' := mi, map_comp' := mc } : C \u2964 D) X = o X := rfl\n@[simp] lemma mk_map (o : C \u2192 D) (m mi mc) {X Y : C} (f : X \u27f6 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\u2081) [\ud835\udc9e : category.{u\u2081 v\u2081} C]\ninclude \ud835\udc9e\n\n/-- `functor.id C` is the identity functor on a category `C`. -/\nprotected def id : C \u2964 C :=\n{ obj      := \u03bb X, X,\n  map'     := \u03bb _ _ 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 \u27f6 Y) : (functor.id C).map f = f := rfl\nend\n\nsection\nvariables {C : Type u\u2081} [\ud835\udc9e : category.{u\u2081 v\u2081} C]\n          {D : Type u\u2082} [\ud835\udc9f : category.{u\u2082 v\u2082} D]\n          {E : Type u\u2083} [\u2130 : category.{u\u2083 v\u2083} E]\ninclude \ud835\udc9e \ud835\udc9f \u2130\n\n/--\n`F \u22d9 G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\ndef comp (F : C \u2964 D) (G : D \u2964 E) : C \u2964 E :=\n{ obj      := \u03bb X, G (F X),\n  map'      := \u03bb _ _ f, G.map (F.map f) }\n\ninfixr ` \u22d9 `:80 := comp\n\n@[simp] lemma comp_obj (F : C \u2964 D) (G : D \u2964 E) (X : C) : (F \u22d9 G) X = G (F X) := rfl\n@[simp] lemma comp_map (F : C \u2964 D) (G : D \u2964 E) (X Y : C) (f : X \u27f6 Y) :\n  (F \u22d9 G).map f = G.map (F.map f) := rfl\nend\n\nsection\nvariables (C : Type u\u2081) [\ud835\udc9e : category.{u\u2081 v\u2081} C]\ninclude \ud835\udc9e\n\n@[simp] def ulift_down : (ulift.{u\u2082} C) \u2964 C :=\n{ obj := \u03bb X, X.down,\n  map' := \u03bb X Y f, f }\n\n@[simp] def ulift_up : C \u2964 (ulift.{u\u2082} C) :=\n{ obj := \u03bb X, \u27e8 X \u27e9,\n  map' := \u03bb X Y f, f }\nend\n\nend functor\n\ndef bundled.map {c : Type u \u2192 Type v} {d : Type u \u2192 Type v} (f : \u03a0{a}, c a \u2192 d a) (s : bundled c) : bundled d :=\n{ \u03b1 := s.\u03b1, str := f s.str }\n\ndef concrete_functor\n  {C : Type u \u2192 Type v} {hC : \u2200{\u03b1 \u03b2}, C \u03b1 \u2192 C \u03b2 \u2192 (\u03b1 \u2192 \u03b2) \u2192 Prop} [concrete_category @hC]\n  {D : Type u \u2192 Type v} {hD : \u2200{\u03b1 \u03b2}, D \u03b1 \u2192 D \u03b2 \u2192 (\u03b1 \u2192 \u03b2) \u2192 Prop} [concrete_category @hD]\n  (m : \u2200{\u03b1}, C \u03b1 \u2192 D \u03b1) (h : \u2200{\u03b1 \u03b2} {ia : C \u03b1} {ib : C \u03b2} {f}, hC ia ib f \u2192 hD (m ia) (m ib) f) :\n  bundled C \u2964 bundled D :=\n{ obj := bundled.map @m,\n  map' := \u03bb X Y f, \u27e8 f, h f.2 \u27e9}\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\u00f6lzl, 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 : \u03b9 \u2192 M`\n  and any finite spanning set `w : set M`,\n  the cardinality of `\u03b9` 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\u2081` is a submodule of `V`, then\n  `module.rank (V/V\u2081) + module.rank V\u2081 = 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\u2081`, `V\u2082`, ... all live in the same universe.\n-/\n\nnoncomputable theory\n\nuniverses u v v' v'' u\u2081' w w'\n\nvariables {K : Type u} {V V\u2081 V\u2082 V\u2083 : Type v} {V' V'\u2081 : Type v'} {V'' : Type v''}\nvariables {\u03b9 : Type w} {\u03b9' : Type w'} {\u03b7 : Type u\u2081'} {\u03c6 : \u03b7 \u2192 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\u2a06 \u03b9 : {s : set V // linear_independent K (coe : s \u2192 V)}, #\u03b9.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\u2081 : Type v} [add_comm_group M\u2081] [module R M\u2081]\n\ntheorem linear_map.lift_dim_le_of_injective (f : M \u2192\u2097[R] M') (i : injective f) :\n  cardinal.lift.{v'} (module.rank R M) \u2264 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 \u27e8s, li\u27e9,\n  refine \u27e8\u27e8f '' s, _\u27e9, cardinal.lift_mk_le'.mpr \u27e8(equiv.set.image f s i).to_embedding\u27e9\u27e9,\n  exact (li.map' _ $ linear_map.ker_eq_bot.mpr i).image,\nend\n\ntheorem linear_map.dim_le_of_injective (f : M \u2192\u2097[R] M\u2081) (i : injective f) :\n  module.rank R M \u2264 module.rank R M\u2081 :=\ncardinal.lift_le.1 (f.lift_dim_le_of_injective i)\n\ntheorem dim_le {n : \u2115}\n  (H : \u2200 s : finset M, linear_independent R (\u03bb i : s, (i : M)) \u2192 s.card \u2264 n) :\n  module.rank R M \u2264 n :=\nbegin\n  rw module.rank,\n  apply csupr_le',\n  rintro \u27e8s, li\u27e9,\n  exact linear_independent_bounded_of_finset_linear_independent_bounded H _ li,\nend\n\nlemma lift_dim_range_le (f : M \u2192\u2097[R] M') :\n  cardinal.lift.{v} (module.rank R f.range) \u2264 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 \u27e8s, li\u27e9,\n  apply le_trans,\n  swap 2,\n  apply cardinal.lift_le.mpr,\n  refine (le_csupr (cardinal.bdd_above_range.{v v} _) \u27e8range_splitting f '' s, _\u27e9),\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 \u27e8equiv.set.range_splitting_image_equiv f s\u27e9).ge, },\nend\n\nlemma dim_range_le (f : M \u2192\u2097[R] M\u2081) : module.rank R f.range \u2264 module.rank R M :=\nby simpa using lift_dim_range_le f\n\nlemma lift_dim_map_le (f : M \u2192\u2097[R] M') (p : submodule R M) :\n  cardinal.lift.{v} (module.rank R (p.map f)) \u2264 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 \u2192\u2097[R] M\u2081) (p : submodule R M) : module.rank R (p.map f) \u2264 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 \u2264 t) :\n  module.rank R s \u2264 module.rank R t :=\n(of_le h).dim_le_of_injective $ assume \u27e8x, hx\u27e9 \u27e8y, hy\u27e9 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 \u2243\u2097[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 \u2243\u2097[R] M\u2081) :\n  module.rank R M = module.rank R M\u2081 :=\ncardinal.lift_inj.1 f.lift_dim_eq\n\nlemma dim_eq_of_injective (f : M \u2192\u2097[R] M\u2081) (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 \u2243\u2097[R] M\u2081) (p : submodule R M) :\n  module.rank R (p.map (f : M \u2192\u2097[R] M\u2081)) = 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 (\u22a4 : submodule R M) = module.rank R M :=\nbegin\n  have : (\u22a4 : submodule R M) \u2243\u2097[R] M := linear_equiv.of_top \u22a4 rfl,\n  rw this.dim_eq,\nend\n\nvariables {R M}\n\nlemma dim_range_of_surjective (f : M \u2192\u2097[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 \u2264 module.rank R M :=\nbegin\n  rw \u2190dim_top R M,\n  exact dim_le_of_submodule _ _ le_top,\nend\n\nlemma linear_map.dim_le_of_surjective (f : M \u2192\u2097[R] M\u2081) (h : surjective f) :\n  module.rank R M\u2081 \u2264 module.rank R M :=\nbegin\n  rw \u2190dim_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 \u29f8 p) \u2264 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  {\u03b9 : Type w} {v : \u03b9 \u2192 M} (hv : linear_independent R v) :\n  cardinal.lift.{max v m} (#\u03b9) \u2264 cardinal.lift.{max w m} (module.rank R M) :=\nbegin\n  apply le_trans,\n  { exact cardinal.lift_mk_le.mpr\n      \u27e8(equiv.of_injective _ hv.injective).to_embedding\u27e9, },\n  { simp only [cardinal.lift_le, module.rank],\n    apply le_trans,\n    swap,\n    exact le_csupr (cardinal.bdd_above_range.{v v} _) \u27e8range v, hv.coe_range\u27e9,\n    exact le_rfl, },\nend\n\nlemma cardinal_lift_le_dim_of_linear_independent'\n  {\u03b9 : Type w} {v : \u03b9 \u2192 M} (hv : linear_independent R v) :\n  cardinal.lift.{v} (#\u03b9) \u2264 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  {\u03b9 : Type v} {v : \u03b9 \u2192 M} (hv : linear_independent R v) :\n  #\u03b9 \u2264 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 (\u03bb x, x : s \u2192 M)) :\n  #s \u2264 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 \u27e8s, li\u27e9,\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 \u27e8a, ha\u27e9 := nonempty_iff_ne_empty.2 h,\n  simpa using linear_independent.ne_zero (\u27e8a, ha\u27e9 : s) li,\nend\n\n@[simp] lemma dim_bot : module.rank R (\u22a5 : submodule R M) = 0 :=\nbegin\n  have : (\u22a5 : submodule R M) \u2243\u2097[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 : \u03b9 \u2192 M} (hv : linear_independent R v) : finite \u03b9 :=\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 (\u03bb i contra, _),\n  apply hv.ne_zero i,\n  have : v i \u2208 R \u2219 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 \u2192 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 = \u22a4)\n  {\u03b9 : Type w} (b : basis \u03b9 R M) : fintype \u03b9 :=\nbegin\n  -- We'll work by contradiction, assuming `\u03b9` is infinite.\n  apply fintype_of_not_infinite _,\n  introI i,\n  -- Let `S` be the union of the supports of `x \u2208 w` expressed as linear combinations of `b`.\n  -- This is a finite set since `w` is finite.\n  let S : finset \u03b9 := finset.univ.sup (\u03bb x : w, (b.repr x).support),\n  let bS : set M := b '' S,\n  have h : \u2200 x \u2208 w, x \u2208 span R bS,\n  { intros x m,\n    rw [\u2190b.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 \u2264 S,\n    convert (finset.le_sup (by simp : (\u27e8x, m\u27e9 : w) \u2208 finset.univ)),\n    refl, },\n  -- Thus this finite subset of the basis elements spans the entire module.\n  have k : span R bS = \u22a4 := eq_top_iff.2 (le_trans s.ge (span_le.2 h)),\n\n  -- Now there is some `x : \u03b9` not in `S`, since `\u03b9` is infinite.\n  obtain \u27e8x, nm\u27e9 := infinite.exists_not_mem_finset S,\n  -- However it must be in the span of the finite subset,\n  have k' : b x \u2208 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 \u2208 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  {\u03b9 : Type w} (b : basis \u03b9 R M)\n  {\u03ba : Type w'} (v : \u03ba \u2192 M) (i : linear_independent R v) (m : i.maximal) :\n  (\u22c3 k, ((b.repr (v k)).support : set \u03b9)) = univ :=\nbegin\n  -- If that's not the case,\n  by_contradiction h,\n  simp only [\u2190ne.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 \u27e8b', w\u27e9 := 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 \u03ba \u2192 M := \u03bb o, o.elim (b b') v,\n  have r : range v \u2286 range v',\n  { rintro - \u27e8k, rfl\u27e9,\n    use some k,\n    refl, },\n  have r' : b b' \u2209 range v,\n  { rintro \u27e8k, p\u27e9,\n    simpa [w] using congr_arg (\u03bb m, (b.repr m) b') p, },\n  have r'' : range v \u2260 range v',\n  { intro e,\n    have p : b b' \u2208 range v', { use none, refl, },\n    rw \u2190e at p,\n    exact r' p, },\n  have inj' : injective v',\n  { rintros (_|k) (_|k) z,\n    { refl, },\n    { exfalso, exact r' \u27e8k, z.symm\u27e9, },\n    { exfalso, exact r' \u27e8k, z\u27e9, },\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' \u2192 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 \u03ba 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\u2080 : l none = 0,\n    { rw \u2190eq_neg_iff_add_eq_zero at z,\n      replace z := neg_eq_iff_eq_neg.mpr z,\n      apply_fun (\u03bb 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 \u2192\u2097[R] \u03b9 \u2192\u2080 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\u2081 : l.some = 0,\n    { rw [l\u2080, 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\u2080, finsupp.coe_zero, pi.zero_apply], },\n    { erw finsupp.congr_fun l\u2081 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  {\u03b9 : Type w} (b : basis \u03b9 R M) [infinite \u03b9]\n  {\u03ba : Type w'} (v : \u03ba \u2192 M) (i : linear_independent R v) (m : i.maximal) :\n  cardinal.lift.{w'} (#\u03b9) \u2264 cardinal.lift.{w} (#\u03ba) :=\nbegin\n  let \u03a6 := \u03bb k : \u03ba, (b.repr (v k)).support,\n  have w\u2081 : #\u03b9 \u2264 #(set.range \u03a6),\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\u2082 :\n    cardinal.lift.{w'} (#(set.range \u03a6)) \u2264 cardinal.lift.{w} (#\u03ba) :=\n    cardinal.mk_range_le_lift,\n  exact (cardinal.lift_le.mpr w\u2081).trans w\u2082,\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  {\u03b9 : Type w} (b : basis \u03b9 R M) [infinite \u03b9]\n  {\u03ba : Type w} (v : \u03ba \u2192 M) (i : linear_independent R v) (m : i.maximal) :\n  #\u03b9 \u2264 #\u03ba :=\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 : \u03b9 \u2192 submodule R M} (hV : complete_lattice.independent V) :\n  cardinal.lift.{v} (#{i : \u03b9 // V i \u2260 \u22a5}) \u2264 cardinal.lift.{w} (module.rank R M) :=\nbegin\n  set I := {i : \u03b9 // V i \u2260 \u22a5},\n  have hI : \u2200 i : I, \u2203 v \u2208 V i, v \u2260 (0:M),\n  { intros i,\n    rw \u2190 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 \u2194 \u2200 x : M, x = 0 :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { contrapose! h,\n    obtain \u27e8x, hx\u27e9 := h,\n    suffices : 1 \u2264 module.rank R M,\n    { intro h, exact this.not_lt (h.symm \u25b8 zero_lt_one) },\n    suffices : linear_independent R (\u03bb (y : ({x} : set M)), \u2191y),\n    { simpa using (cardinal_le_dim_of_linear_independent this), },\n    exact linear_independent_singleton hx },\n  { have : (\u22a4 : submodule R M) = \u22a5,\n    { ext x, simp [h x] },\n    rw [\u2190dim_top, this, dim_bot] }\nend\n\nlemma dim_zero_iff : module.rank R M = 0 \u2194 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 \u2194 \u2203 x : M, x \u2260 0 :=\nbegin\n  rw \u2190not_iff_not,\n  simpa using dim_zero_iff_forall_zero\nend\n\nlemma dim_pos_iff_nontrivial : 0 < module.rank R M \u2194 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 \u03b9 R M) (v' : basis \u03b9' R M) :\n  cardinal.lift.{w'} (#\u03b9) = cardinal.lift.{w} (#\u03b9') :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  casesI fintype_or_infinite \u03b9,\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 \u03b9).symm.trans v.repr.symm) \u226a\u226b\u2097\n      v'.repr) \u226a\u226b\u2097 (finsupp.linear_equiv_fun_on_finite R R \u03b9'), },\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\u2081 :=\n      infinite_basis_le_maximal_linear_independent' v _ v'.linear_independent v'.maximal,\n    rcases cardinal.lift_mk_le'.mp w\u2081 with \u27e8f\u27e9,\n    haveI : infinite \u03b9' := infinite.of_injective f f.2,\n    have w\u2082 :=\n      infinite_basis_le_maximal_linear_independent' v' _ v.linear_independent v.maximal,\n    exact le_antisymm w\u2081 w\u2082, }\nend\n\n/-- Given two bases indexed by `\u03b9` and `\u03b9'` of an `R`-module, where `R` satisfies the invariant\nbasis number property, an equiv `\u03b9 \u2243 \u03b9' `. -/\ndef basis.index_equiv (v : basis \u03b9 R M) (v' : basis \u03b9' R M) : \u03b9 \u2243 \u03b9' :=\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' {\u03b9' : Type w} (v : basis \u03b9 R M) (v' : basis \u03b9' R M) :\n  #\u03b9 = #\u03b9' :=\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 \u03b9 R M`,\nand any finite spanning set `w : set M`,\nthe cardinality of `\u03b9` is bounded by the cardinality of `w`.\n-/\nlemma basis.le_span'' {\u03b9 : Type*} [fintype \u03b9] (b : basis \u03b9 R M)\n  {w : set M} [fintype w] (s : span R w = \u22a4) :\n  fintype.card \u03b9 \u2264 fintype.card w :=\nbegin\n  -- We construct an surjective linear map `(w \u2192 R) \u2192\u2097[R] (\u03b9 \u2192 R)`,\n  -- by expressing a linear combination in `w` as a linear combination in `\u03b9`.\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 [\u2190linear_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' {\u03b9 : Type*} (b : basis \u03b9 R M)\n  {w : set M} [fintype w] (s : span R w = \u22a4) :\n  #\u03b9 \u2264 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 \u03b9,\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 \u03b9 R M)\n   (hJ : span R J = \u22a4) : #(range v) \u2264 #J :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  casesI fintype_or_infinite J,\n  { rw [\u2190cardinal.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 \u2192 set \u03b9 := \u03bb j, \u2191(v.repr j).support,\n    let S' : J \u2192 set M := \u03bb j, v '' S j,\n    have hs : range v \u2286 \u22c3 j, S' j,\n    { intros b hb,\n      rcases mem_range.1 hb with \u27e8i, hi\u27e9,\n      have : span R J \u2264 comap v.repr.to_linear_map (finsupp.supported R R (\u22c3 j, S j)) :=\n        span_le.2 (\u03bb j hj x hx, \u27e8_, \u27e8\u27e8j, hj\u27e9, rfl\u27e9, hx\u27e9),\n      rw hJ at this,\n      replace : v.repr (v i) \u2208 (finsupp.supported R R (\u22c3 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 \u27e8j, hj\u27e9,\n        exact mem_Union.2 \u27e8j, (mem_image _ _ _).2 \u27e8i, hj, rfl\u27e9\u27e9 },\n      { apply_instance } },\n    refine le_of_not_lt (\u03bb IJ, _),\n    suffices : #(\u22c3 j, S' j) < #(range v),\n    { exact not_le_of_lt this \u27e8set.embedding_of_subset _ _ hs\u27e9 },\n    refine lt_of_le_of_lt (le_trans cardinal.mk_Union_le_sum_mk\n      (cardinal.sum_le_sum _ (\u03bb _, \u2135\u2080) _)) _,\n    { exact \u03bb 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  {\u03b9 : Type*} [fintype \u03b9] (v : \u03b9 \u2192 M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v \u2264 span R w) :\n  fintype.card \u03b9 \u2264 fintype.card w :=\nbegin\n  -- We construct an injective linear map `(\u03b9 \u2192 R) \u2192\u2097[R] (w \u2192 R)`,\n  -- by thinking of `f : \u03b9 \u2192 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 \u03bb i, span.repr R w \u27e8v i, s (mem_range_self i)\u27e9, },\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 [\u2190sub_eq_zero, \u2190linear_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 : \u03b9 \u2192 M`\ncontained in the span of some finite `w : set M`,\nis itself finite.\n-/\ndef linear_independent_fintype_of_le_span_fintype\n  {\u03b9 : Type*} (v : \u03b9 \u2192 M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v \u2264 span R w) : fintype \u03b9 :=\nfintype_of_finset_card_le (fintype.card w) (\u03bb t, begin\n  let v' := \u03bb x : (t : set \u03b9), v x,\n  have i' : linear_independent R v' := i.comp _ subtype.val_injective,\n  have s' : range v' \u2264 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 : \u03b9 \u2192 M`\ncontained in the span of some finite `w : set M`,\nthe cardinality of `\u03b9` is bounded by the cardinality of `w`.\n-/\nlemma linear_independent_le_span' {\u03b9 : Type*} (v : \u03b9 \u2192 M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v \u2264 span R w) :\n  #\u03b9 \u2264 fintype.card w :=\nbegin\n  haveI : fintype \u03b9 := 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 : \u03b9 \u2192 M`\nand any finite spanning set `w : set M`,\nthe cardinality of `\u03b9` is bounded by the cardinality of `w`.\n-/\nlemma linear_independent_le_span {\u03b9 : Type*} (v : \u03b9 \u2192 M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : span R w = \u22a4) :\n  #\u03b9 \u2264 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  {\u03b9 : Type*} (b : basis \u03b9 R M) [infinite \u03b9]\n  {\u03ba : Type*} (v : \u03ba \u2192 M) (i : linear_independent R v) :\n  #\u03ba \u2264 #\u03b9 :=\nbegin\n  by_contradiction,\n  rw [not_le, \u2190 cardinal.mk_finset_of_infinite \u03b9] at h,\n  let \u03a6 := \u03bb k : \u03ba, (b.repr (v k)).support,\n  obtain \u27e8s, w : infinite \u21a5(\u03a6 \u207b\u00b9' {s})\u27e9 := cardinal.exists_infinite_fiber \u03a6 h (by apply_instance),\n  let v' := \u03bb k : \u03a6 \u207b\u00b9' {s}, v k,\n  have i' : linear_independent R v' := i.comp _ subtype.val_injective,\n  have w' : fintype (\u03a6 \u207b\u00b9' {s}),\n  { apply linear_independent_fintype_of_le_span_fintype v' i' (s.image b),\n    rintros m \u27e8\u27e8p,\u27e8rfl\u27e9\u27e9,rfl\u27e9,\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  {\u03b9 : Type*} (b : basis \u03b9 R M)\n  {\u03ba : Type*} (v : \u03ba \u2192 M) (i : linear_independent R v) :\n  #\u03ba \u2264 #\u03b9 :=\nbegin\n  -- We split into cases depending on whether `\u03b9` is infinite.\n  cases fintype_or_infinite \u03b9; resetI,\n  { -- When `\u03b9` is finite, we have `linear_independent_le_span`,\n    rw cardinal.mk_fintype \u03b9,\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 : \u2115) {m : \u2115} (v : fin m \u2192 fin n \u2192 R) :\n  linear_independent R v \u2192 m \u2264 n :=\n\u03bb 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  {\u03b9 : Type*} (b : basis \u03b9 R M) [infinite \u03b9]\n  {\u03ba : Type*} (v : \u03ba \u2192 M) (i : linear_independent R v) (m : i.maximal) :\n  #\u03ba = #\u03b9 :=\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'' {\u03b9 : Type v} (v : basis \u03b9 R M) :\n  #\u03b9 = 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 \u27e8set.range v, by { convert v.reindex_range.linear_independent, ext, simp }\u27e9,\n    exact (cardinal.mk_range_eq v v.injective).ge, },\n  { apply csupr_le',\n    rintro \u27e8s, li\u27e9,\n    apply linear_independent_le_basis v _ li, },\nend\n\ntheorem basis.mk_range_eq_dim (v : basis \u03b9 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 {\u03b9 : Type w} [fintype \u03b9] (h : basis \u03b9 R M) :\n  module.rank R M = fintype.card \u03b9 :=\nby {haveI := nontrivial_of_invariant_basis_number R,\n  rw [\u2190h.mk_range_eq_dim, cardinal.mk_fintype, set.card_range_of_injective h.injective] }\n\nlemma basis.card_le_card_of_linear_independent {\u03b9 : Type*} [fintype \u03b9]\n  (b : basis \u03b9 R M) {\u03b9' : Type*} [fintype \u03b9'] {v : \u03b9' \u2192 M} (hv : linear_independent R v) :\n  fintype.card \u03b9' \u2264 fintype.card \u03b9 :=\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 \u03b9] (b : basis \u03b9 R M)\n  [fintype \u03b9'] (b' : basis \u03b9' R N) : fintype.card \u03b9' \u2264 fintype.card \u03b9 :=\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 \u2264 O) [fintype \u03b9] (b : basis \u03b9 R O) [fintype \u03b9']\n  (b' : basis \u03b9' R N) : fintype.card \u03b9' \u2264 fintype.card \u03b9 :=\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 \u03b9 R M) :\n  cardinal.lift.{v} (#\u03b9) = cardinal.lift.{w} (module.rank R M) :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw [\u2190v.mk_range_eq_dim, cardinal.mk_range_eq_of_injective v.injective]\nend\n\ntheorem {m} basis.mk_eq_dim' (v : basis \u03b9 R M) :\n  cardinal.lift.{max v m} (#\u03b9) = 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 {\u03b9 : Type*}\n  (b : basis \u03b9 R M) (h : module.rank R M < \u2135\u2080) :\n  nonempty (fintype \u03b9) :=\nby rwa [\u2190 cardinal.lift_lt, \u2190 b.mk_eq_dim,\n        -- ensure `aleph_0` has the correct universe\n        cardinal.lift_aleph_0, \u2190 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 {\u03b9 : Type*}\n  (b : basis \u03b9 R M) (h : module.rank R M < \u2135\u2080) :\n  fintype \u03b9 :=\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 {\u03b9 : Type*} {s : set \u03b9}\n  (b : basis s R M) (h : module.rank R M < \u2135\u2080) :\n  s.finite :=\nfinite_def.2 (b.nonempty_fintype_index_of_dim_lt_aleph_0 h)\n\nlemma dim_span {v : \u03b9 \u2192 M} (hv : linear_independent R v) :\n  module.rank R \u21a5(span R (range v)) = #(range v) :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw [\u2190cardinal.lift_inj, \u2190 (basis.span hv).mk_eq_dim,\n    cardinal.mk_range_eq_of_injective (@linear_independent.injective \u03b9 R M v _ _ _ _ hv)]\nend\n\nlemma dim_span_set {s : set M} (hs : linear_independent R (\u03bb x, x : s \u2192 M)) :\n  module.rank R \u21a5(span R s) = #s :=\nby { rw [\u2190 @set_of_mem_eq _ s, \u2190 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 \u03b9] (b : basis \u03b9 R M)\n  (P : submodule R M \u2192 Sort*) (ih : \u2200 (N : submodule R M),\n    (\u2200 (N' \u2264 N) (x \u2208 N), (\u2200 (c : R) (y \u2208 N'), c \u2022 x + y = (0 : M) \u2192 c = 0) \u2192 P N') \u2192\n    P N)\n  (N : submodule R M) : P N :=\nsubmodule.induction_on_rank_aux b P ih (fintype.card \u03b9) N (\u03bb 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 \u2260 \u22a5) (c : basis m R I) :\n  fintype.card m = fintype.card n :=\nbegin\n  obtain \u27e8a, ha\u27e9 := submodule.nonzero_mem_of_bot_lt (bot_lt_iff_ne_bot.mpr hI),\n  have : linear_independent R (\u03bb i, b i \u2022 a),\n  { have hb := b.linear_independent,\n    rw fintype.linear_independent_iff at \u22a2 hb,\n    intros g hg,\n    apply hb g,\n    simp only [\u2190 smul_assoc, \u2190 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 [\u2190cardinal.lift_inj, \u2190 (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\u2081] [module K V\u2081]\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 < \u2135\u2080) :\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 \u2243\u2097[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\u2081) :\n  nonempty (V \u2243\u2097[K] V\u2081) :=\nnonempty_linear_equiv_of_lift_dim_eq $ congr_arg _ cond\n\nsection\n\nvariables (V V' V\u2081)\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 \u2243\u2097[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\u2081) : V \u2243\u2097[K] V\u2081 :=\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 \u2243\u2097[K] V') \u2194\n    cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V') :=\n\u27e8\u03bb \u27e8h\u27e9, linear_equiv.lift_dim_eq h, \u03bb h, nonempty_linear_equiv_of_lift_dim_eq h\u27e9\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 \u2243\u2097[K] V\u2081) \u2194 module.rank K V = module.rank K V\u2081 :=\n\u27e8\u03bb \u27e8h\u27e9, linear_equiv.dim_eq h, \u03bb h, nonempty_linear_equiv_of_dim_eq h\u27e9\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) \u2264 #s :=\nbegin\n  obtain \u27e8b, hb, hsab, hlib\u27e9 := exists_linear_independent K s,\n  convert cardinal.mk_le_mk_of_subset hb,\n  rw [\u2190 hsab, dim_span_set hlib]\nend\n\nlemma dim_span_of_finset (s : finset V) :\n  module.rank K (span K (\u2191s : set V)) < \u2135\u2080 :=\ncalc module.rank K (span K (\u2191s : set V)) \u2264 #(\u2191s : set V) : dim_span_le \u2191s\n                             ... = s.card : by rw [finset.coe_sort_coe, cardinal.mk_coe_finset]\n                             ... < \u2135\u2080 : cardinal.nat_lt_aleph_0 _\n\ntheorem dim_prod : module.rank K (V \u00d7 V\u2081) = module.rank K V + module.rank K V\u2081 :=\nbegin\n  let b := basis.of_vector_space K V,\n  let c := basis.of_vector_space K V\u2081,\n  rw [\u2190 cardinal.lift_inj,\n      \u2190 (basis.prod b c).mk_eq_dim,\n      cardinal.lift_add, \u2190 cardinal.mk_ulift,\n      \u2190 b.mk_eq_dim, \u2190 c.mk_eq_dim,\n      \u2190 cardinal.mk_ulift, \u2190 cardinal.mk_ulift,\n      cardinal.add_def (ulift _)],\n  exact cardinal.lift_inj.1 (cardinal.lift_mk_eq.2\n      \u27e8equiv.ulift.trans (equiv.sum_congr equiv.ulift equiv.ulift).symm \u27e9),\nend\n\nsection fintype\nvariables [\u2200i, add_comm_group (\u03c6 i)] [\u2200i, module K (\u03c6 i)]\n\nopen linear_map\n\nlemma dim_pi [finite \u03b7] : module.rank K (\u03a0i, \u03c6 i) = cardinal.sum (\u03bbi, module.rank K (\u03c6 i)) :=\nbegin\n  casesI nonempty_fintype \u03b7,\n  let b := assume i, basis.of_vector_space K (\u03c6 i),\n  let this : basis (\u03a3 j, _) K (\u03a0 j, \u03c6 j) := pi.basis b,\n  rw [\u2190 cardinal.lift_inj, \u2190 this.mk_eq_dim],\n  simp [\u2190 (b _).mk_range_eq_dim]\nend\n\nvariable [fintype \u03b7]\n\nlemma dim_fun {V \u03b7 : Type u} [fintype \u03b7] [add_comm_group V] [module K V] :\n  module.rank K (\u03b7 \u2192 V) = fintype.card \u03b7 * 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 (\u03b7 \u2192 V) = (fintype.card \u03b7 : cardinal.{max u\u2081' v}) *\n    cardinal.lift.{u\u2081'} (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 (\u03b7 \u2192 K) = fintype.card \u03b7 :=\nby rw [dim_fun_eq_lift_mul, dim_self, cardinal.lift_one, mul_one, cardinal.nat_cast_inj]\n\nlemma dim_fin_fun (n : \u2115) : module.rank K (fin n \u2192 K) = n :=\nby simp [dim_fun']\n\nend fintype\n\ntheorem dim_quotient_add_dim (p : submodule K V) :\n  module.rank K (V \u29f8 p) + module.rank K p = module.rank K V :=\nby classical; exact let \u27e8f\u27e9 := 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 \u2192\u2097[K] V\u2081) :\n  module.rank K f.range + module.rank K f.ker = module.rank K V :=\nbegin\n  haveI := \u03bb (p : submodule K V), classical.dec_eq (V \u29f8 p),\n  rw [\u2190 f.quot_ker_equiv_range.dim_eq, dim_quotient_add_dim]\nend\n\nlemma dim_eq_of_surjective (f : V \u2192\u2097[K] V\u2081) (h : surjective f) :\n  module.rank K V = module.rank K V\u2081 + module.rank K f.ker :=\nby rw [\u2190 dim_range_add_dim_ker f, \u2190 dim_range_of_surjective f h]\n\nsection\nvariables [add_comm_group V\u2082] [module K V\u2082]\nvariables [add_comm_group V\u2083] [module K V\u2083]\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\u2082 \u2192\u2097[K] V) (eb : V\u2083 \u2192\u2097[K] V) (cd : V\u2081 \u2192\u2097[K] V\u2082) (ce : V\u2081 \u2192\u2097[K] V\u2083)\n  (hde : \u22a4 \u2264 db.range \u2294 eb.range)\n  (hgd : ker cd = \u22a5)\n  (eq : db.comp cd = eb.comp ce)\n  (eq\u2082 : \u2200d e, db d = eb e \u2192 (\u2203c, cd c = d \u2227 ce c = e)) :\n  module.rank K V + module.rank K V\u2081 = module.rank K V\u2082 + module.rank K V\u2083 :=\nhave hf : surjective (coprod db eb),\nby rwa [\u2190range_eq_top, range_coprod, eq_top_iff],\nbegin\n  conv {to_rhs, rw [\u2190 dim_prod, dim_eq_of_surjective _ hf] },\n  congr' 1,\n  apply linear_equiv.dim_eq,\n  refine linear_equiv.of_bijective _ \u27e8_, _\u27e9,\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 [\u2190 ker_eq_bot, ker_cod_restrict, ker_prod, hgd, bot_inf_eq] },\n  { rw [\u2190 range_eq_top, eq_top_iff, range_cod_restrict, \u2190 map_le_iff_le_comap,\n      submodule.map_top, range_subtype],\n    rintros \u27e8d, e\u27e9,\n    have h := eq\u2082 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 \u22a2 h,\n    assume hde,\n    rcases h hde with \u27e8c, h\u2081, h\u2082\u27e9,\n    refine \u27e8c, h\u2081, _\u27e9,\n    rw [h\u2082, _root_.neg_neg] }\nend\n\nlemma dim_sup_add_dim_inf_eq (s t : submodule K V) :\n  module.rank K (s \u2294 t : submodule K V) + module.rank K (s \u2293 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 [\u2190 map_le_map_iff' (ker_subtype $ s \u2294 t), submodule.map_sup, submodule.map_top,\n      \u2190 linear_map.range_comp, \u2190 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 \u27e8x, hx\u27e9, refl end\n  begin\n    rintros \u27e8b\u2081, hb\u2081\u27e9 \u27e8b\u2082, hb\u2082\u27e9 eq,\n    obtain rfl : b\u2081 = b\u2082 := congr_arg subtype.val eq,\n    exact \u27e8\u27e8b\u2081, hb\u2081, hb\u2082\u27e9, rfl, rfl\u27e9\n  end\n\nlemma dim_add_le_dim_add_dim (s t : submodule K V) :\n  module.rank K (s \u2294 t : submodule K V) \u2264 module.rank K s + module.rank K t :=\nby { rw [\u2190 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  \u2203 b : V, b \u2208 s \u2227 b \u2260 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\u2081] [module K V\u2081]\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 \u2192\u2097[K] V') : cardinal := module.rank K f.range\n\nlemma rank_le_range (f : V \u2192\u2097[K] V\u2081) : rank f \u2264 module.rank K V\u2081 :=\ndim_submodule_le _\n\n@[simp] lemma rank_zero [nontrivial K] : rank (0 : V \u2192\u2097[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 \u2192\u2097[K] V') (f : V' \u2192\u2097[K] V'') : rank (f.comp g) \u2264 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'\u2081] [module K V'\u2081]\n\nlemma rank_comp_le2 (g : V \u2192\u2097[K] V') (f : V' \u2192\u2097[K] V'\u2081) : rank (f.comp g) \u2264 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\u2081] [module K V\u2081]\nvariables [add_comm_group V'] [module K V']\n\nlemma rank_le_domain (f : V \u2192\u2097[K] V\u2081) : rank f \u2264 module.rank K V :=\nby { rw [\u2190 dim_range_add_dim_ker f], exact self_le_add_right _ _ }\n\nlemma rank_add_le (f g : V \u2192\u2097[K] V') : rank (f + g) \u2264 rank f + rank g :=\ncalc rank (f + g) \u2264 module.rank K (f.range \u2294 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 \u2208 (f.range \u2294 g.range : submodule K V'), from\n        mem_sup.2 \u27e8_, \u27e8x, rfl\u27e9, _, \u27e8x, rfl\u27e9, rfl\u27e9)\n  end\n  ... \u2264 rank f + rank g : dim_add_le_dim_add_dim _ _\n\nlemma rank_finset_sum_le {\u03b7} (s : finset \u03b7) (f : \u03b7 \u2192 V \u2192\u2097[K] V') :\n  rank (\u2211 d in s, f d) \u2264 \u2211 d in s, rank (f d) :=\n@finset.sum_hom_rel _ _ _ _ _ (\u03bba b, rank a \u2264 b) f (\u03bb d, rank (f d)) s (le_of_eq rank_zero)\n      (\u03bb i g c h, le_trans (rank_add_le _ _) (add_le_add_left h _))\n\n/-- The `\u03b9` indexed basis on `V`, where `\u03b9` is an empty type and `V` is zero-dimensional.\n\nSee also `finite_dimensional.fin_basis`.\n-/\ndef basis.of_dim_eq_zero {\u03b9 : Type*} [is_empty \u03b9] (hV : module.rank K V = 0) :\n  basis \u03b9 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 {\u03b9 : Type*} [is_empty \u03b9]\n  (hV : module.rank K V = 0) (i : \u03b9) :\n  basis.of_dim_eq_zero hV i = 0 :=\nrfl\n\nlemma le_dim_iff_exists_linear_independent {c : cardinal} :\n  c \u2264 module.rank K V \u2194 \u2203 s : set V, #s = c \u2227 linear_independent K (coe : s \u2192 V) :=\nbegin\n  split,\n  { intro h,\n    let t := basis.of_vector_space K V,\n    rw [\u2190 t.mk_eq_dim'', cardinal.le_mk_iff_exists_subset] at h,\n    rcases h with \u27e8s, hst, hsc\u27e9,\n    exact \u27e8s, hsc, (of_vector_space_index.linear_independent K V).mono hst\u27e9 },\n  { rintro \u27e8s, rfl, si\u27e9,\n    exact cardinal_le_dim_of_linear_independent si }\nend\n\nlemma le_dim_iff_exists_linear_independent_finset {n : \u2115} :\n  \u2191n \u2264 module.rank K V \u2194\n    \u2203 s : finset V, s.card = n \u2227 linear_independent K (coe : (s : set V) \u2192 V) :=\nbegin\n  simp only [le_dim_iff_exists_linear_independent, cardinal.mk_set_eq_nat_iff_finset],\n  split,\n  { rintro \u27e8s, \u27e8t, rfl, rfl\u27e9, si\u27e9,\n    exact \u27e8t, rfl, si\u27e9 },\n  { rintro \u27e8s, rfl, si\u27e9,\n    exact \u27e8s, \u27e8s, rfl, rfl\u27e9, si\u27e9 }\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 \u2264 1 \u2194 \u2203 v\u2080 : V, \u2200 v, \u2203 r : K, r \u2022 v\u2080 = v :=\nbegin\n  let b := basis.of_vector_space K V,\n  split,\n  { intro hd,\n    rw [\u2190 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 | \u27e8\u27e8v\u2080, hv\u2080\u27e9\u27e9,\n    { use 0,\n      have h' : \u2200 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\u2080,\n      have h' : (K \u2219 v\u2080) = \u22a4, { simpa [hd.eq_singleton_of_mem hv\u2080] using b.span_eq },\n      intro v,\n      have hv : v \u2208 (\u22a4 : submodule K V) := mem_top,\n      rwa [\u2190h', mem_span_singleton] at hv } },\n  { rintros \u27e8v\u2080, hv\u2080\u27e9,\n    have h : (K \u2219 v\u2080) = \u22a4,\n    { ext, simp [mem_span_singleton, hv\u2080] },\n    rw [\u2190dim_top, \u2190h],\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 \u2264 1 \u2194 \u2203 v\u2080 \u2208 s, s \u2264 K \u2219 v\u2080 :=\nbegin\n  simp_rw [dim_le_one_iff, le_span_singleton_iff],\n  split,\n  { rintro \u27e8\u27e8v\u2080, hv\u2080\u27e9, h\u27e9,\n    use [v\u2080, hv\u2080],\n    intros v hv,\n    obtain \u27e8r, hr\u27e9 := h \u27e8v, hv\u27e9,\n    use r,\n    simp_rw [subtype.ext_iff, coe_smul, submodule.coe_mk] at hr,\n    exact hr },\n  { rintro \u27e8v\u2080, hv\u2080, h\u27e9,\n    use \u27e8v\u2080, hv\u2080\u27e9,\n    rintro \u27e8v, hv\u27e9,\n    obtain \u27e8r, hr\u27e9 := 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 \u2264 1 \u2194 \u2203 v\u2080, s \u2264 K \u2219 v\u2080 :=\nbegin\n  rw dim_submodule_le_one_iff,\n  split,\n  { rintros \u27e8v\u2080, hv\u2080, h\u27e9,\n    exact \u27e8v\u2080, h\u27e9 },\n  { rintros \u27e8v\u2080, h\u27e9,\n    by_cases hw : \u2203 w : V, w \u2208 s \u2227 w \u2260 0,\n    { rcases hw with \u27e8w, hw, hw0\u27e9,\n      use [w, hw],\n      rcases mem_span_singleton.1 (h hw) with \u27e8r', rfl\u27e9,\n      have h0 : r' \u2260 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 \u2190submodule.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 \u2264 1 \u2194 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 \u27e8\u27e8m, hm\u27e9, hm'\u27e9,\n    choose f hf using hm',\n    exact \u27e8m, \u27e8\u03bb v hv, \u27e8f \u27e8v, hv\u27e9, congr_arg coe (hf \u27e8v, hv\u27e9)\u27e9, hm\u27e9\u27e9 },\n  { rintro \u27e8a, \u27e8h, ha\u27e9\u27e9,\n    choose f hf using h,\n    exact \u27e8\u27e8a, ha\u27e9, \u03bb v, \u27e8f v.1 v.2, subtype.ext (hf v.1 v.2)\u27e9\u27e9 }\nend\n\nlemma module.rank_le_one_iff_top_is_principal :\n  module.rank K V \u2264 1 \u2194 (\u22a4 : submodule K V).is_principal :=\nby rw [\u2190 submodule.rank_le_one_iff_is_principal, dim_top]\n\nlemma le_rank_iff_exists_linear_independent {c : cardinal} {f : V \u2192\u2097[K] V'} :\n  c \u2264 rank f \u2194\n  \u2203 s : set V, cardinal.lift.{v'} (#s) = cardinal.lift.{v} c \u2227\n    linear_independent K (\u03bb x : s, f x) :=\nbegin\n  rcases f.range_restrict.exists_right_inverse_of_surjective f.range_range_restrict with \u27e8g, hg\u27e9,\n  have fg : left_inverse f.range_restrict g, from linear_map.congr_fun hg,\n  refine \u27e8\u03bb h, _, _\u27e9,\n  { rcases le_dim_iff_exists_linear_independent.1 h with \u27e8s, rfl, si\u27e9,\n    refine \u27e8g '' s, cardinal.mk_image_eq_lift _ _ fg.injective, _\u27e9,\n    replace fg : \u2200 x, f (g x) = x, by { intro x, convert congr_arg subtype.val (fg x) },\n    replace si : linear_independent K (\u03bb 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 \u27e8s, hsc, si\u27e9,\n    have : linear_independent K (\u03bb 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 [\u2190 cardinal.lift_inj, \u2190 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 : \u2115} {f : V \u2192\u2097[K] V'} :\n  \u2191n \u2264 rank f \u2194 \u2203 s : finset V, s.card = n \u2227 linear_independent K (\u03bb 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 \u27e8s, \u27e8t, rfl, rfl\u27e9, si\u27e9,\n    exact \u27e8t, rfl, si\u27e9 },\n  { rintro \u27e8s, rfl, si\u27e9,\n    exact \u27e8s, \u27e8s, rfl, rfl\u27e9, si\u27e9 }\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, \u2190 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. `\u222a, \u2229, \u2293, \u2294, ...`), 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 `\u03b1`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 {\u03b1 : Type _} : List \u03b1 \u2192 List Bool \u2192 List \u03b1\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 \u00d7 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 \u2208 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 \u00d7 expr) \u2192\n      List expr \u2192 List Bool \u2192 tactic (List expr \u00d7 List expr \u00d7 List expr \u00d7 List Bool)\n  | [], l_un, l_m => return ([], [], l_un, l_m)\n  | be :: l, l_un, l_m => do\n    let ex :: _ \u2190 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) \u2190 move_left_or_right l (l_un.erase\u2093 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 \u00d7 pexpr` to a list of pairs `bool \u00d7 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 \u00d7 pexpr)) (sl : List expr) :\n    tactic (List expr \u00d7 List Bool) := do\n  let lp_exp : List (Bool \u00d7 expr) \u2190\n    lp.mapM fun x => do\n        let e \u2190 to_expr x.2 true false\n        return (x.1, e)\n  let (l1, l2, l3, is_unused) \u2190 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 \u22652-argument function application,\nwith the binary operation `op`, failing if it cannot. -/\nunsafe def as_given_op (op : pexpr) : expr \u2192 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) \u2190 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))] `(\u2200 x y : \u2115, 2 = 0)\n--  (\u2115 \u2192 \u2115 \u2192 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  `(\u03bb (e : \u2115), \u2200 (x : \u2115), \u2203 (y : \u2115),\n      2 + x * (y + (e + 5)) + y = x + 2 + e \u2192 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   (\u03bb (e : \u2115), \u2200 (x : \u2115), \u2203 (y : \u2115),\n      x * (5 + y + e) + y + 2   = x + e + 2 \u2192 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 \u00d7 pexpr)) : expr \u2192 tactic (expr \u00d7 List Bool)\n  | F'@(expr.app F b) => do\n    let is_op \u2190 try_core (as_given_op op F')\n    match is_op with\n      | some op => do\n        let (sort_list, is_unused) \u2190 list_binary_operands op F' >>= final_sort lp\n        let sort_all \u2190\n          sort_list fun e => do\n              let (e, lu) \u2190 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 \u2190 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)] \u2190 [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] \u2190 [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] \u2190 [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      \u2190-- 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      \u2190-- 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] \u2190 [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      \u2190-- 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 \u00d7 pexpr)) (na : Option Name) :\n    tactic (Bool \u00d7 List Bool) := do\n  let (thyp, hyploc) \u2190\n    match na with\n      | none => do\n        let t \u2190 target\n        return (t, none)\n      | some na => do\n        let hl \u2190 get_local na\n        let th \u2190 infer_type hl\n        return (th, some hl)\n  let (reordered, is_unused) \u2190 reorder_oper op lp thyp\n  unify reordered thyp >> return (tt, is_unused) <|> do\n      let neq\n        \u2190-- 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 \u2190 to_expr op tt ff\n      let pre \u2190 pp reordered\n      let (_, prf) \u2190\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 `\u2190`. -/\nunsafe def move_op_arg (prec : Nat) : parser (Bool \u00d7 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 \u00d7 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 \u2190 locat.get_locals\n  let tg \u2190 target\n  let locas_with_tg := if locat.include_goal then locas ++ [tg] else locas\n  let ner \u2190\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 \u2190\n    match\n        (returnUnused args (unus_vars.transpose.map List.and)).map fun e : Bool \u00d7 pexpr => e.2 with\n      | [] => pure []\n      | [pe] => do\n        let nm \u2190 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 \u2190\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 \u2208 returnUnused names unch_tgts then [f!\"Goal did not change\"] else []) ++\n        if linames \u2260 [] then [f! \"'{linames.reverse}' did not change\"] else []\n  let [] \u2190 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, \u2190 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 `\u2190` 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 : \u2115} (h : c = d) : c + b + a = b + a + d :=\nbegin\n  move_add [\u2190 a, b],  -- Goal: `a + c + b = a + d + b`  -- both sides changed\n  congr,\n  exact h\nend\n\nexample {a b c d : \u2115} (h : c = d) : c + b * c + a * c = a * d + d + b * d :=\nbegin\n  move_add [_ * c, \u2190 _ * 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 \u2190 f` and `move_add [\u2190 f]` mean the same.\n\nFinally, `move_add` can also target one or more hypotheses.  If `hp\u2081, hp\u2082` are in the\nlocal context, then `move_add [f, \u2190 g] at hp\u2081 hp\u2082` performs the rearranging at `hp\u2081` and `hp\u2082`.\nAs usual, passing `\u22a2` 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 \u2190 _` 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 \u2190 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 ``((\u00b7 + \u00b7))\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 : \u2115) : max a b = max b a :=\nby move_oper [max] [\u2190 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] \u2190 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 {\u03b9 : Type v} [decidable_eq \u03b9]\n\nsection mk\n\nvariables {\u03b2 : \u03b9 \u2192 Type w} [\u03a0 (i : \u03b9), add_comm_monoid (\u03b2 i)]\n\nlemma direct_sum.mk_apply_of_mem {s : finset \u03b9} {f : \u03a0 (i : (\u2191s : set \u03b9)), \u03b2 i.val}\n  {n : \u03b9} (hn : n \u2208 s):\n  direct_sum.mk \u03b2 s f n = f \u27e8n, hn\u27e9 := \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 \u03b9} {f : \u03a0 (i : (\u2191s : set \u03b9)), \u03b2 i.val}\n  {n : \u03b9} (hn : n \u2209 s):\n  direct_sum.mk \u03b2 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 : \u03b9 \u2192 add_submonoid M) (x : direct_sum \u03b9 (\u03bb i, A i)) :\n  direct_sum.coe_add_monoid_hom A x = dfinsupp.sum x (\u03bb 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 : \u03b9 \u2192 submodule R M) \n  (x : direct_sum \u03b9 (\u03bb i, A i)) :\n  direct_sum.coe_linear_map A x = dfinsupp.sum x (\u03bb 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 : \u03b9 \u2192 add_submonoid M) \n  (x : direct_sum \u03b9 (\u03bb i, A i)) :\n  function.support  (\u03bb i, (x i : M)) \u2286 \u2191(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 : \u03b9 \u2192 submodule R M) \n  (x : direct_sum \u03b9 (\u03bb i, A i)) :\n  function.support  (\u03bb i, (x i : M)) \u2286 \u2191(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 : \u03b9 \u2192 add_submonoid M) \n  (x : direct_sum \u03b9 (\u03bb i, A i)) :\n  (function.support (\u03bb i, (x i : M))).finite := \nset.finite.subset (dfinsupp.support x : set \u03b9).to_finite (direct_sum.support_subset _ x)\n\nend internal\n\nend direct_sum\n\nsection\n\ntheorem linear_map.map_finsum {\u03b1 R S M N : Type*} [semiring R] [semiring S] (\u03c3 : R \u2192+* S)\n  [add_comm_monoid M] [add_comm_monoid N]  [module R M] [module S N] {f : \u03b1 \u2192 M} (g : M \u2192\u209b\u2097[\u03c3] N)\n  (hf : (function.support f).finite) :\n  g (finsum (\u03bb (i : \u03b1), f i)) = finsum (\u03bb (i : \u03b1), g (f i)) := \nbegin\n  rw \u2190 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 (\u03b9 \u2192 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 (\u03b9 : Type*) [decidable_eq \u03b9]\n\nvariables (M : \u03b9 \u2192 submodule R A) [add_monoid \u03b9] [set_like.graded_monoid M]\n\nvariables {R A \u03b9 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 \u03b9 (\u03bb i, \u21a5(M i)) \u2243\u2090[R] A :=\n{ commutes' := \u03bb 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 : \u03c3 \u2192 M`, where `M` is an additive and commutative monoid, we endow the\n  ring of multivariate polynomials `mv_polynomial \u03c3 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 {\u03c3 : Type*}\nvariable (w : \u03c3 \u2192 M)\n\nnamespace mv_polynomial\n\nlemma weighted_homogeneous_component_mem (w : \u03c3 \u2192 M) (\u03c6 : mv_polynomial \u03c3 R) \n  (m : M) :\n  weighted_homogeneous_component R w m \u03c6 \u2208 weighted_homogeneous_submodule R w m :=\nbegin\n  rw mem_weighted_homogeneous_submodule, \n  exact weighted_homogeneous_component_is_weighted_homogeneous m \u03c6, \nend\n\n/- \nlemma toto (p : Prop) [decidable p] (u v : M) : \n  (ite p u v = u) \u2194 (\u00ac p \u2192 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 (\u03c6 : mv_polynomial \u03c3 R) (i : M) \n  (hi : i \u2209 finset.image (weighted_degree' w) \u03c6.support) : \n  weighted_homogeneous_component R w i \u03c6 = 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' (\u03c6 : mv_polynomial \u03c3 R) (i : M) : \n  ite (i \u2208 finset.image (weighted_degree' w) \u03c6.support) \n    ((weighted_homogeneous_component R w i) \u03c6) 0 \n    = (weighted_homogeneous_component R w i) \u03c6 :=\nbegin\n  split_ifs with hi hi,\n  refl,\n  rw decompose'_aux w \u03c6 i hi, \nend -/\n\nvariable (R)\ndef decompose'_fun := \u03bb (\u03c6 : mv_polynomial \u03c3 R), direct_sum.mk \n  (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))\n  (finset.image (weighted_degree' w) \u03c6.support)\n  (\u03bb m, \u27e8weighted_homogeneous_component R w m \u03c6, weighted_homogeneous_component_mem w \u03c6 m\u27e9)\n\nlemma decompose'_fun_apply (\u03c6 : mv_polynomial \u03c3 R) (m : M):\n  (decompose'_fun R w \u03c6 m : mv_polynomial \u03c3 R) = \n  weighted_homogeneous_component R w m \u03c6 := \nbegin\n  rw decompose'_fun,\n  by_cases hm :  m \u2208 finset.image (weighted_degree' w) \u03c6.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 \u03c6 m hm],\nend\n\ninstance [decidable_eq \u03c3] [decidable_eq R] :\n  \u03a0 (i : M) (x : \u21a5(weighted_homogeneous_submodule R w i)), decidable (x \u2260 0) :=\nbegin\n  intros m x,\n  rw [ne.def, \u2190 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 \u03c3] [decidable_eq R]\n  (x : direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))) :\n  ((direct_sum.coe_linear_map (\u03bb (i : M), weighted_homogeneous_submodule R w i)) x) = \n  dfinsupp.sum x  (\u03bb 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 \u03c3] [decidable_eq R]\n  (x : direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))) :\n  ((direct_sum.coe_add_monoid_hom (\u03bb (i : M), weighted_homogeneous_submodule R w i)) x) = \n  dfinsupp.sum x  (\u03bb 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 \u03c3] [decidable_eq R]\n  (x : direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))) \n  /- [h_dec : \u03a0 (i : M) (x : \u21a5(weighted_homogeneous_submodule R w i)), decidable (x \u2260 0)]  -/: \n  ((direct_sum.coe_linear_map (\u03bb (i : M), weighted_homogeneous_submodule R w i)) x) = \n  finsum (\u03bb 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\u2026\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 \u03c3] [decidable_eq R]\n  (x : direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))) \n  /- [h_dec : \u03a0 (i : M) (x : \u21a5(weighted_homogeneous_submodule R w i)), decidable (x \u2260 0)]  -/: \n  ((direct_sum.coe_add_monoid_hom (\u03bb (i : M), weighted_homogeneous_submodule R w i)) x) = \n  finsum (\u03bb 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) \u2191x = 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 \u03c3] [decidable_eq R]\n  (x : direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))) (m : M) : \n  (weighted_homogeneous_component R w m) \n    ((direct_sum.coe_linear_map (\u03bb (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 \u2190 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 \u2190 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 \u03c3] [decidable_eq R] : \n  direct_sum.decomposition (weighted_homogeneous_submodule R w) := \n{ decompose'  := decompose'_fun R w,\n  left_inv    := \u03bb \u03c6,\n  begin\n    conv_rhs { rw [\u2190 sum_weighted_homogeneous_component w \u03c6], },\n    rw \u2190 direct_sum.sum_support_of (\u03bb m, \u21a5(weighted_homogeneous_submodule R w m))\n      (decompose'_fun R w \u03c6),\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 \u2190 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   := \u03bb x,\n  begin\n    apply dfinsupp.ext, intro m, \n    rw \u2190 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) = \u2191(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 \u03c3] [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\u2026\u00a0\nFor the moment, I am stuck. -/\n\nvariables (R : Type*) [semiring R] \nvariables (\u03b9 : Type*) [decidable_eq \u03b9]\n  {M : \u03b9 \u2192 Type* } [\u03a0 (i : \u03b9), add_comm_monoid (M i)] [\u03a0 (i : \u03b9), module R (M i)]\nvariables {N : Type*} [add_comm_monoid N] [module R N]\n\nlemma yala \n  (g : \u03a0 (i : \u03b9), N \u2192\u2097[R] M i) \n  (hg : \u2200 n, {i | g i n \u2260 0}.finite) \n  (h : \u03a0 (i : \u03b9), M i \u2192\u2097[R] N) (n : N) :\n  (direct_sum.to_module R \u03b9 N h) (direct_sum.mk M (hg n).to_finset (\u03bb i, g i n)) = finsum (\u03bb i, h i (g i n)) :=\nbegin\n  classical,\n  suffices : (function.support ((\u03bb (i : \u03b9), (h i) ((g i) n)) \u2218 plift.down)).finite, \n  let s := { i | g i n \u2260 0},\n  unfold finsum, \n  rw dif_pos this,\n\n  unfold direct_sum.mk,dsimp,\nend\n\nexample (f : \u2115 \u2192+ \u2115) (a : \u03b9 \u2192\u2080 \u2115) :\n  f (finsupp.sum a (\u03bb i m, m)) =\n  finsupp.sum (finsupp.map_range f (f.map_zero) a) (\u03bb 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 : \u2115 \u2192+ \u2115) (a : \u03b9 \u2192 \u2115) (ha : (function.support a).finite):\n  f (finsum a) = finsum (\u03bb 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 {\u03c3 : Type*}\nvariable (w : \u03c3 \u2192 M)\n#check weighted_degree'\ndef w_degree : (\u03c3 \u2192\u2080 \u2115) \u2192 M := \u03bb p, finsupp.sum p (\u03bb s n, n \u2022 (w s))\n\n/- def weighted_degrees' (w : \u03c3 \u2192 M) (s : finset (\u03c3 \u2192\u2080 \u2115)) : \nfinset M := finset.image (weighted_degree' w) s -/\n\nlemma weighted_homogeneous_component_mem (w : \u03c3 \u2192 M) (\u03c6 : mv_polynomial \u03c3 R) (m : M) :\n  weighted_homogeneous_component w m \u03c6 \u2208 weighted_homogeneous_submodule R w m :=\nbegin\n  rw mem_weighted_homogeneous_submodule, \n  exact weighted_homogeneous_component_is_weighted_homogeneous m \u03c6, \nend\n\nexample (s : finset \u2115) : s = \u2205 \u2194 s \u2286 \u2205 :=\nbegin\n  rw [\u2190 finset.bot_eq_empty, eq_bot_iff, le_iff_subset],\nend\n\nlemma decompose'_aux (\u03c6 : mv_polynomial \u03c3 R) (i : M) : \n  ite (i \u2208 finset.image (weighted_degree' w) \u03c6.support) ((weighted_homogeneous_component w i) \u03c6) 0 = (weighted_homogeneous_component w i) \u03c6 :=\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 \u03c3 R \u2192\u2097[R] direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i)) := {\nto_fun  := \u03bb \u03c6, direct_sum.mk \n  (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))\n  (finset.image (weighted_degree' w) \u03c6.support)\n  (\u03bb m, \u27e8weighted_homogeneous_component w m \u03c6, weighted_homogeneous_component_mem w \u03c6 m\u27e9),\nmap_add'  := \u03bb \u03c6 \u03c8,\nbegin\n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  dsimp,\n  rw \u2190 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 \u03c6, \n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  dsimp,\n  rw \u2190 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 \u03c3 R \u2192 direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i)) := \u03bb \u03c6, direct_sum.mk \n  (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))\n  (finset.image (weighted_degree' w) \u03c6.support)\n  (\u03bb m, \u27e8weighted_homogeneous_component w m \u03c6, weighted_homogeneous_component_mem w \u03c6 m\u27e9)\nfintype\nlemma decompose'_fun_coe_apply (\u03c6 : mv_polynomial \u03c3 R) (m : M) : (decompose'_fun R w \u03c6 m : mv_polynomial \u03c3 R) = weighted_homogeneous_component w m \u03c6 := \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 \u03c6 m, \nend\n\nlemma decompose'_add' : \u2200 (\u03c6 \u03c8 : mv_polynomial \u03c3 R), decompose'_fun R w (\u03c6 + \u03c8) = decompose'_fun R w \u03c6 + decompose'_fun R w \u03c8 :=\nbegin\n  intros \u03c6 \u03c8,\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 \u2190 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 (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))) i) : mv_polynomial \u03c3 R) \n  = ite (i = 0) (1 : mv_polynomial \u03c3 R) (0 : mv_polynomial \u03c3 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 \u2190 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' : \u2200 (\u03c6 \u03c8 : mv_polynomial \u03c3 R), decompose'_fun R w (\u03c6 * \u03c8) = decompose'_fun R w \u03c6 * decompose'_fun R w \u03c8 :=\nbegin\nsorry,\nend\n\n/-- The alg_hom map from polynomials to the direct sum of the homogeneous components -/\ndef decompose'a : mv_polynomial \u03c3 R \u2192\u2090[R] direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i)) := {\nto_fun  := \u03bb \u03c6, direct_sum.mk \n  (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))\n  (finset.image (weighted_degree' w) \u03c6.support)\n  (\u03bb m, \u27e8weighted_homogeneous_component w m \u03c6, weighted_homogeneous_component_mem w \u03c6 m\u27e9),\nmap_add'  := decompose'_add' R w, \n/- map_smul' := \nbegin\n  intros a \u03c6, \n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  dsimp,\n  rw \u2190 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 \u03c6 \u03c8,\n  rw dfinsupp.ext_iff,\n  simp only [direct_sum.mk],\n  intro i, \n  -- dsimp,\n  rw \u2190 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 [\u2190 direct_sum.sum_support_of _ p, \u2190 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 : \u2200 (x : direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))) (c : M), c \u2260 i \u2192 coeff m ((x c) : mv_polynomial \u03c3 R) = 0,\n      suffices this' : \u2200 (x : direct_sum M (\u03bb (i : M), \u21a5(weighted_homogeneous_submodule R w i))), \n      i \u2209 dfinsupp.support x \u2192 coeff m ((x i) : mv_polynomial \u03c3 R) = 0,\n      rw [finset.sum_eq_single i, finset.sum_eq_single i] at hpq, \n      exact hpq,\n      exact \u03bb b hb, this q b,\n      exact this' q,\n      exact \u03bb 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 \u2190 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 \u03c6,\n    use decompose'_fun R w \u03c6,\n    conv_lhs { rw \u2190 direct_sum.sum_support_of _ (decompose'_fun R w \u03c6) },\n    simp only [map_sum, direct_sum.coe_add_monoid_hom_of],\n    simp_rw decompose'_fun_coe_apply, \n\n    conv_rhs { rw \u2190 sum_weighted_homogeneous_component w \u03c6}, \n    rw finsum_eq_sum _ (weighted_homogeneous_component_finsupp \u03c6),\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 [\u2190 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\u00f6lzl, 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 : \u03b9 \u2192 M`\n  and any finite spanning set `w : set M`,\n  the cardinality of `\u03b9` 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\u2081` is a submodule of `V`, then\n  `module.rank (V/V\u2081) + module.rank V\u2081 = 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\u2081`, `V\u2082`, ... all live in the same universe.\n-/\n\nnoncomputable theory\n\nuniverses u v v' v'' u\u2081' w w'\n\nvariables {K : Type u} {V V\u2081 V\u2082 V\u2083 : Type v} {V' V'\u2081 : Type v'} {V'' : Type v''}\nvariables {\u03b9 : Type w} {\u03b9' : Type w'} {\u03b7 : Type u\u2081'} {\u03c6 : \u03b7 \u2192 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} (\u03bb \u03b9 : {s : set V // linear_independent K (coe : s \u2192 V)}, #\u03b9.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\u2081 : Type v} [add_comm_group M\u2081] [module R M\u2081]\n\ntheorem linear_map.lift_dim_le_of_injective (f : M \u2192\u2097[R] M') (i : injective f) :\n  cardinal.lift.{v'} (module.rank R M) \u2264 cardinal.lift.{ v} (module.rank R M') :=\nbegin\n  dsimp [module.rank],\n  fapply cardinal.lift_sup_le_lift_sup',\n  { rintro \u27e8s, li\u27e9,\n    use f '' s,\n    convert (li.map' f (linear_map.ker_eq_bot.mpr i)).comp\n      (equiv.set.image \u21d1f s i).symm (equiv.injective _),\n    ext \u27e8-, \u27e8x, \u27e8h, rfl\u27e9\u27e9\u27e9,\n    simp, },\n  { rintro \u27e8s, li\u27e9,\n    exact cardinal.lift_mk_le'.mpr \u27e8(equiv.set.image f s i).to_embedding\u27e9, }\nend\n\ntheorem linear_map.dim_le_of_injective (f : M \u2192\u2097[R] M\u2081) (i : injective f) :\n  module.rank R M \u2264 module.rank R M\u2081 :=\ncardinal.lift_le.1 (f.lift_dim_le_of_injective i)\n\ntheorem dim_le {n : \u2115}\n  (H : \u2200 s : finset M, linear_independent R (\u03bb i : s, (i : M)) \u2192 s.card \u2264 n) :\n  module.rank R M \u2264 n :=\nbegin\n  apply cardinal.sup_le.mpr,\n  rintro \u27e8s, li\u27e9,\n  exact linear_independent_bounded_of_finset_linear_independent_bounded H _ li,\nend\n\nlemma lift_dim_range_le (f : M \u2192\u2097[R] M') :\n  cardinal.lift.{v} (module.rank R f.range) \u2264 cardinal.lift.{v'} (module.rank R M) :=\nbegin\n  dsimp [module.rank],\n  apply cardinal.lift_sup_le,\n  rintro \u27e8s, li\u27e9,\n  apply le_trans,\n  swap 2,\n  apply cardinal.lift_le.mpr,\n  refine (cardinal.le_sup _ \u27e8range_splitting f '' s, _\u27e9),\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 \u27e8equiv.set.range_splitting_image_equiv f s\u27e9).ge, },\nend\n\nlemma dim_range_le (f : M \u2192\u2097[R] M\u2081) : module.rank R f.range \u2264 module.rank R M :=\nby simpa using lift_dim_range_le f\n\nlemma lift_dim_map_le (f : M \u2192\u2097[R] M') (p : submodule R M) :\n  cardinal.lift.{v} (module.rank R (p.map f)) \u2264 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 \u2192\u2097[R] M\u2081) (p : submodule R M) : module.rank R (p.map f) \u2264 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 \u2264 t) :\n  module.rank R s \u2264 module.rank R t :=\n(of_le h).dim_le_of_injective $ assume \u27e8x, hx\u27e9 \u27e8y, hy\u27e9 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 \u2243\u2097[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 \u2243\u2097[R] M\u2081) :\n  module.rank R M = module.rank R M\u2081 :=\ncardinal.lift_inj.1 f.lift_dim_eq\n\nlemma dim_eq_of_injective (f : M \u2192\u2097[R] M\u2081) (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 \u2243\u2097[R] M\u2081) (p : submodule R M) :\n  module.rank R (p.map (f : M \u2192\u2097[R] M\u2081)) = 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 (\u22a4 : submodule R M) = module.rank R M :=\nbegin\n  have : (\u22a4 : submodule R M) \u2243\u2097[R] M := linear_equiv.of_top \u22a4 rfl,\n  rw this.dim_eq,\nend\n\nvariables {R M}\n\nlemma dim_range_of_surjective (f : M \u2192\u2097[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 \u2264 module.rank R M :=\nbegin\n  rw \u2190dim_top R M,\n  exact dim_le_of_submodule _ _ le_top,\nend\n\nlemma linear_map.dim_le_of_surjective (f : M \u2192\u2097[R] M\u2081) (h : surjective f) :\n  module.rank R M\u2081 \u2264 module.rank R M :=\nbegin\n  rw \u2190dim_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 \u29f8 p) \u2264 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  {\u03b9 : Type w} {v : \u03b9 \u2192 M} (hv : linear_independent R v) :\n  cardinal.lift.{(max v m)} (#\u03b9) \u2264 cardinal.lift.{(max w m)} (module.rank R M) :=\nbegin\n  apply le_trans,\n  { exact cardinal.lift_mk_le.mpr\n      \u27e8(equiv.of_injective _ hv.injective).to_embedding\u27e9, },\n  { simp only [cardinal.lift_le],\n    apply le_trans,\n    swap,\n    exact cardinal.le_sup _ \u27e8range v, hv.coe_range\u27e9,\n    exact le_refl _, },\nend\n\nlemma cardinal_lift_le_dim_of_linear_independent'\n  {\u03b9 : Type w} {v : \u03b9 \u2192 M} (hv : linear_independent R v) :\n  cardinal.lift.{v} (#\u03b9) \u2264 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  {\u03b9 : Type v} {v : \u03b9 \u2192 M} (hv : linear_independent R v) :\n  #\u03b9 \u2264 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 (\u03bb x, x : s \u2192 M)) :\n  #s \u2264 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 \u27e8s, li\u27e9,\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 (\u27e8_, ne.some_mem\u27e9 : s) li,\nend\n\n@[simp] lemma dim_bot : module.rank R (\u22a5 : submodule R M) = 0 :=\nbegin\n  have : (\u22a5 : submodule R M) \u2243\u2097[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 = \u22a4)\n  {\u03b9 : Type w} (b : basis \u03b9 R M) : fintype \u03b9 :=\nbegin\n  -- We'll work by contradiction, assuming `\u03b9` is infinite.\n  apply fintype_of_not_infinite _,\n  introI i,\n  -- Let `S` be the union of the supports of `x \u2208 w` expressed as linear combinations of `b`.\n  -- This is a finite set since `w` is finite.\n  let S : finset \u03b9 := finset.univ.sup (\u03bb x : w, (b.repr x).support),\n  let bS : set M := b '' S,\n  have h : \u2200 x \u2208 w, x \u2208 span R bS,\n  { intros x m,\n    rw [\u2190b.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 \u2264 S,\n    convert (finset.le_sup (by simp : (\u27e8x, m\u27e9 : w) \u2208 finset.univ)),\n    refl, },\n  -- Thus this finite subset of the basis elements spans the entire module.\n  have k : span R bS = \u22a4 := eq_top_iff.2 (le_trans s.ge (span_le.2 h)),\n\n  -- Now there is some `x : \u03b9` not in `S`, since `\u03b9` is infinite.\n  obtain \u27e8x, nm\u27e9 := infinite.exists_not_mem_finset S,\n  -- However it must be in the span of the finite subset,\n  have k' : b x \u2208 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 \u2208 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  {\u03b9 : Type w} (b : basis \u03b9 R M)\n  {\u03ba : Type w'} (v : \u03ba \u2192 M) (i : linear_independent R v) (m : i.maximal) :\n  (\u22c3 k, ((b.repr (v k)).support : set \u03b9)) = univ :=\nbegin\n  -- If that's not the case,\n  by_contradiction h,\n  simp only [\u2190ne.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 \u27e8b', w\u27e9 := 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 \u03ba \u2192 M := \u03bb o, o.elim (b b') v,\n  have r : range v \u2286 range v',\n  { rintro - \u27e8k, rfl\u27e9,\n    use some k,\n    refl, },\n  have r' : b b' \u2209 range v,\n  { rintro \u27e8k, p\u27e9,\n    simpa [w] using congr_arg (\u03bb m, (b.repr m) b') p, },\n  have r'' : range v \u2260 range v',\n  { intro e,\n    have p : b b' \u2208 range v', { use none, refl, },\n    rw \u2190e at p,\n    exact r' p, },\n  have inj' : injective v',\n  { rintros (_|k) (_|k) z,\n    { refl, },\n    { exfalso, exact r' \u27e8k, z.symm\u27e9, },\n    { exfalso, exact r' \u27e8k, z\u27e9, },\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' \u2192 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 \u03ba 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\u2080 : l none = 0,\n    { rw \u2190eq_neg_iff_add_eq_zero at z,\n      replace z := eq_neg_of_eq_neg z,\n      apply_fun (\u03bb 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 \u2192\u2097[R] \u03b9 \u2192\u2080 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\u2081 : l.some = 0,\n    { rw [l\u2080, 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\u2080, finsupp.coe_zero, pi.zero_apply], },\n    { erw finsupp.congr_fun l\u2081 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  {\u03b9 : Type w} (b : basis \u03b9 R M) [infinite \u03b9]\n  {\u03ba : Type w'} (v : \u03ba \u2192 M) (i : linear_independent R v) (m : i.maximal) :\n  cardinal.lift.{w'} (#\u03b9) \u2264 cardinal.lift.{w} (#\u03ba) :=\nbegin\n  let \u03a6 := \u03bb k : \u03ba, (b.repr (v k)).support,\n  have w\u2081 : #\u03b9 \u2264 #(set.range \u03a6),\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\u2082 :\n    cardinal.lift.{w'} (#(set.range \u03a6)) \u2264 cardinal.lift.{w} (#\u03ba) :=\n    cardinal.mk_range_le_lift,\n  exact (cardinal.lift_le.mpr w\u2081).trans w\u2082,\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  {\u03b9 : Type w} (b : basis \u03b9 R M) [infinite \u03b9]\n  {\u03ba : Type w} (v : \u03ba \u2192 M) (i : linear_independent R v) (m : i.maximal) :\n  #\u03b9 \u2264 #\u03ba :=\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 : \u03b9 \u2192 submodule R M} (hV : complete_lattice.independent V) :\n  cardinal.lift.{v} (#{i : \u03b9 // V i \u2260 \u22a5}) \u2264 cardinal.lift.{w} (module.rank R M) :=\nbegin\n  set I := {i : \u03b9 // V i \u2260 \u22a5},\n  have hI : \u2200 i : I, \u2203 v \u2208 V i, v \u2260 (0:M),\n  { intros i,\n    rw \u2190 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 \u2194 \u2200 x : M, x = 0 :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { contrapose! h,\n    obtain \u27e8x, hx\u27e9 := h,\n    suffices : 1 \u2264 module.rank R M,\n    { intro h, exact lt_irrefl _ (lt_of_lt_of_le cardinal.zero_lt_one (h \u25b8 this)) },\n    suffices : linear_independent R (\u03bb (y : ({x} : set M)), \u2191y),\n    { simpa using (cardinal_le_dim_of_linear_independent this), },\n    exact linear_independent_singleton hx },\n  { have : (\u22a4 : submodule R M) = \u22a5,\n    { ext x, simp [h x] },\n    rw [\u2190dim_top, this, dim_bot] }\nend\n\nlemma dim_zero_iff : module.rank R M = 0 \u2194 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 \u2194 \u2203 x : M, x \u2260 0 :=\nbegin\n  rw \u2190not_iff_not,\n  simpa using dim_zero_iff_forall_zero\nend\n\nlemma dim_pos_iff_nontrivial : 0 < module.rank R M \u2194 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 \u03b9 R M) (v' : basis \u03b9' R M) :\n  cardinal.lift.{w'} (#\u03b9) = cardinal.lift.{w} (#\u03b9') :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  by_cases h : #\u03b9 < \u03c9,\n  { -- `v` is a finite basis, so by `basis_fintype_of_finite_spans` so is `v'`.\n    haveI : fintype \u03b9 := (cardinal.lt_omega_iff_fintype.mp h).some,\n    haveI : fintype (range v) := set.fintype_range \u21d1v,\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 \u03b9).symm.trans v.repr.symm) \u226a\u226b\u2097\n      v'.repr) \u226a\u226b\u2097 (finsupp.linear_equiv_fun_on_fintype R R \u03b9'), },\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 \u03b9 := cardinal.infinite_iff.mpr h,\n    have w\u2081 :=\n      infinite_basis_le_maximal_linear_independent' v _ v'.linear_independent v'.maximal,\n    haveI : infinite \u03b9' := cardinal.infinite_iff.mpr (begin\n      apply cardinal.lift_le.{w' w}.mp,\n      have p := (cardinal.lift_le.mpr h).trans w\u2081,\n      rw cardinal.lift_omega at \u22a2 p,\n      exact p,\n    end),\n    have w\u2082 :=\n      infinite_basis_le_maximal_linear_independent' v' _ v.linear_independent v.maximal,\n    exact le_antisymm w\u2081 w\u2082, }\nend\n\n/-- Given two basis indexed by `\u03b9` and `\u03b9'` of an `R`-module, where `R` satisfies the invariant\nbasis number property, an equiv `\u03b9 \u2243 \u03b9' `. -/\ndef basis.index_equiv (v : basis \u03b9 R M) (v' : basis \u03b9' R M) : \u03b9 \u2243 \u03b9' :=\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' {\u03b9' : Type w} (v : basis \u03b9 R M) (v' : basis \u03b9' R M) :\n  #\u03b9 = #\u03b9' :=\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 \u03b9 R M`,\nand any finite spanning set `w : set M`,\nthe cardinality of `\u03b9` is bounded by the cardinality of `w`.\n-/\nlemma basis.le_span'' {\u03b9 : Type*} [fintype \u03b9] (b : basis \u03b9 R M)\n  {w : set M} [fintype w] (s : span R w = \u22a4) :\n  fintype.card \u03b9 \u2264 fintype.card w :=\nbegin\n  -- We construct an surjective linear map `(w \u2192 R) \u2192\u2097[R] (\u03b9 \u2192 R)`,\n  -- by expressing a linear combination in `w` as a linear combination in `\u03b9`.\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 [\u2190linear_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' {\u03b9 : Type*} (b : basis \u03b9 R M)\n  {w : set M} [fintype w] (s : span R w = \u22a4) :\n  #\u03b9 \u2264 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 \u03b9,\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 \u03b9 R M)\n   (hJ : span R J = \u22a4) : #(range v) \u2264 #J :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  casesI fintype_or_infinite J,\n  { rw [\u2190cardinal.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 \u2192 set \u03b9 := \u03bb j, \u2191(v.repr j).support,\n    let S' : J \u2192 set M := \u03bb j, v '' S j,\n    have hs : range v \u2286 \u22c3 j, S' j,\n    { intros b hb,\n      rcases mem_range.1 hb with \u27e8i, hi\u27e9,\n      have : span R J \u2264 comap v.repr.to_linear_map (finsupp.supported R R (\u22c3 j, S j)) :=\n        span_le.2 (\u03bb j hj x hx, \u27e8_, \u27e8\u27e8j, hj\u27e9, rfl\u27e9, hx\u27e9),\n      rw hJ at this,\n      replace : v.repr (v i) \u2208 (finsupp.supported R R (\u22c3 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 \u27e8j, hj\u27e9,\n        exact mem_Union.2 \u27e8j, (mem_image _ _ _).2 \u27e8i, hj, rfl\u27e9\u27e9 },\n      { apply_instance } },\n    refine le_of_not_lt (\u03bb IJ, _),\n    suffices : #(\u22c3 j, S' j) < #(range v),\n    { exact not_le_of_lt this \u27e8set.embedding_of_subset _ _ hs\u27e9 },\n    refine lt_of_le_of_lt (le_trans cardinal.mk_Union_le_sum_mk\n      (cardinal.sum_le_sum _ (\u03bb _, \u03c9) _)) _,\n    { exact \u03bb 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  {\u03b9 : Type*} [fintype \u03b9] (v : \u03b9 \u2192 M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v \u2264 span R w) :\n  fintype.card \u03b9 \u2264 fintype.card w :=\nbegin\n  -- We construct an injective linear map `(\u03b9 \u2192 R) \u2192\u2097[R] (w \u2192 R)`,\n  -- by thinking of `f : \u03b9 \u2192 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 \u03bb i, span.repr R w \u27e8v i, s (mem_range_self i)\u27e9, },\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 [\u2190sub_eq_zero, \u2190linear_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 : \u03b9 \u2192 M`\ncontained in the span of some finite `w : set M`,\nis itself finite.\n-/\ndef linear_independent_fintype_of_le_span_fintype\n  {\u03b9 : Type*} (v : \u03b9 \u2192 M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v \u2264 span R w) : fintype \u03b9 :=\nfintype_of_finset_card_le (fintype.card w) (\u03bb t, begin\n  let v' := \u03bb x : (t : set \u03b9), v x,\n  have i' : linear_independent R v' := i.comp _ subtype.val_injective,\n  have s' : range v' \u2264 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 : \u03b9 \u2192 M`\ncontained in the span of some finite `w : set M`,\nthe cardinality of `\u03b9` is bounded by the cardinality of `w`.\n-/\nlemma linear_independent_le_span' {\u03b9 : Type*} (v : \u03b9 \u2192 M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : range v \u2264 span R w) :\n  #\u03b9 \u2264 fintype.card w :=\nbegin\n  haveI : fintype \u03b9 := 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 : \u03b9 \u2192 M`\nand any finite spanning set `w : set M`,\nthe cardinality of `\u03b9` is bounded by the cardinality of `w`.\n-/\nlemma linear_independent_le_span {\u03b9 : Type*} (v : \u03b9 \u2192 M) (i : linear_independent R v)\n  (w : set M) [fintype w] (s : span R w = \u22a4) :\n  #\u03b9 \u2264 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 : \u03b9 \u2192 M} (hi : linear_independent R v) : fintype \u03b9 :=\nbegin\n  have hfg : (\u22a4 : submodule R M).fg,\n  { exact is_noetherian_def.mp infer_instance \u22a4, },\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 \u2192 M)) : s.finite :=\n\u27e8fintype_of_is_noetherian_linear_independent hi\u27e9\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  {\u03b9 : Type*} (b : basis \u03b9 R M) [infinite \u03b9]\n  {\u03ba : Type*} (v : \u03ba \u2192 M) (i : linear_independent R v) :\n  #\u03ba \u2264 #\u03b9 :=\nbegin\n  by_contradiction,\n  rw [not_le, \u2190 cardinal.mk_finset_eq_mk \u03b9] at h,\n  let \u03a6 := \u03bb k : \u03ba, (b.repr (v k)).support,\n  obtain \u27e8s, w : infinite \u21a5(\u03a6 \u207b\u00b9' {s})\u27e9 := cardinal.exists_infinite_fiber \u03a6 h (by apply_instance),\n  let v' := \u03bb k : \u03a6 \u207b\u00b9' {s}, v k,\n  have i' : linear_independent R v' := i.comp _ subtype.val_injective,\n  have w' : fintype (\u03a6 \u207b\u00b9' {s}),\n  { apply linear_independent_fintype_of_le_span_fintype v' i' (s.image b),\n    rintros m \u27e8\u27e8p,\u27e8rfl\u27e9\u27e9,rfl\u27e9,\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  {\u03b9 : Type*} (b : basis \u03b9 R M)\n  {\u03ba : Type*} (v : \u03ba \u2192 M) (i : linear_independent R v) :\n  #\u03ba \u2264 #\u03b9 :=\nbegin\n  -- We split into cases depending on whether `\u03b9` is infinite.\n  cases fintype_or_infinite \u03b9; resetI,\n  { -- When `\u03b9` is finite, we have `linear_independent_le_span`,\n    rw cardinal.mk_fintype \u03b9,\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 : \u2115) {m : \u2115} (v : fin m \u2192 fin n \u2192 R) :\n  linear_independent R v \u2192 m \u2264 n :=\n\u03bb 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  {\u03b9 : Type*} (b : basis \u03b9 R M) [infinite \u03b9]\n  {\u03ba : Type*} (v : \u03ba \u2192 M) (i : linear_independent R v) (m : i.maximal) :\n  #\u03ba = #\u03b9 :=\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'' {\u03b9 : Type v} (v : basis \u03b9 R M) :\n  #\u03b9 = 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 \u27e8set.range v, by { convert v.reindex_range.linear_independent, ext, simp }\u27e9,\n    exact (cardinal.mk_range_eq v v.injective).ge, },\n  { apply cardinal.sup_le.mpr,\n    rintro \u27e8s, li\u27e9,\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 \u03b9 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 {\u03b9 : Type w} [fintype \u03b9] (h : basis \u03b9 R M) :\n  module.rank R M = fintype.card \u03b9 :=\nby {haveI := nontrivial_of_invariant_basis_number R,\n  rw [\u2190h.mk_range_eq_dim, cardinal.mk_fintype, set.card_range_of_injective h.injective] }\n\nlemma basis.card_le_card_of_linear_independent {\u03b9 : Type*} [fintype \u03b9]\n  (b : basis \u03b9 R M) {\u03b9' : Type*} [fintype \u03b9'] {v : \u03b9' \u2192 M} (hv : linear_independent R v) :\n  fintype.card \u03b9' \u2264 fintype.card \u03b9 :=\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 \u03b9] (b : basis \u03b9 R M)\n  [fintype \u03b9'] (b' : basis \u03b9' R N) : fintype.card \u03b9' \u2264 fintype.card \u03b9 :=\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 \u2264 O) [fintype \u03b9] (b : basis \u03b9 R O) [fintype \u03b9']\n  (b' : basis \u03b9' R N) : fintype.card \u03b9' \u2264 fintype.card \u03b9 :=\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 \u03b9 R M) :\n  cardinal.lift.{v} (#\u03b9) = cardinal.lift.{w} (module.rank R M) :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw [\u2190v.mk_range_eq_dim, cardinal.mk_range_eq_of_injective v.injective]\nend\n\ntheorem {m} basis.mk_eq_dim' (v : basis \u03b9 R M) :\n  cardinal.lift.{(max v m)} (#\u03b9) = 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 {\u03b9 : Type*}\n  (b : basis \u03b9 R M) (h : module.rank R M < \u03c9) :\n  nonempty (fintype \u03b9) :=\nby rwa [\u2190 cardinal.lift_lt, \u2190 b.mk_eq_dim,\n        -- ensure `omega` has the correct universe\n        cardinal.lift_omega, \u2190 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 {\u03b9 : Type*}\n  (b : basis \u03b9 R M) (h : module.rank R M < \u03c9) :\n  fintype \u03b9 :=\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 {\u03b9 : Type*} {s : set \u03b9}\n  (b : basis s R M) (h : module.rank R M < \u03c9) :\n  s.finite :=\nfinite_def.2 (b.nonempty_fintype_index_of_dim_lt_omega h)\n\nlemma dim_span {v : \u03b9 \u2192 M} (hv : linear_independent R v) :\n  module.rank R \u21a5(span R (range v)) = #(range v) :=\nbegin\n  haveI := nontrivial_of_invariant_basis_number R,\n  rw [\u2190cardinal.lift_inj, \u2190 (basis.span hv).mk_eq_dim,\n    cardinal.mk_range_eq_of_injective (@linear_independent.injective \u03b9 R M v _ _ _ _ hv)]\nend\n\nlemma dim_span_set {s : set M} (hs : linear_independent R (\u03bb x, x : s \u2192 M)) :\n  module.rank R \u21a5(span R s) = #s :=\nby { rw [\u2190 @set_of_mem_eq _ s, \u2190 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 \u03b9] (b : basis \u03b9 R M)\n  (P : submodule R M \u2192 Sort*) (ih : \u2200 (N : submodule R M),\n    (\u2200 (N' \u2264 N) (x \u2208 N), (\u2200 (c : R) (y \u2208 N'), c \u2022 x + y = (0 : M) \u2192 c = 0) \u2192 P N') \u2192\n    P N)\n  (N : submodule R M) : P N :=\nsubmodule.induction_on_rank_aux b P ih (fintype.card \u03b9) N (\u03bb 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 \u2260 \u22a5) (c : basis m R I) :\n  fintype.card m = fintype.card n :=\nbegin\n  obtain \u27e8a, ha\u27e9 := submodule.nonzero_mem_of_bot_lt (bot_lt_iff_ne_bot.mpr hI),\n  have : linear_independent R (\u03bb i, b i \u2022 a),\n  { have hb := b.linear_independent,\n    rw fintype.linear_independent_iff at \u22a2 hb,\n    intros g hg,\n    apply hb g,\n    simp only [\u2190 smul_assoc, \u2190 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 [\u2190cardinal.lift_inj, \u2190 (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\u2081] [module K V\u2081]\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 < \u03c9) :\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 \u2243\u2097[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\u2081) :\n  nonempty (V \u2243\u2097[K] V\u2081) :=\nnonempty_linear_equiv_of_lift_dim_eq $ congr_arg _ cond\n\nsection\n\nvariables (V V' V\u2081)\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 \u2243\u2097[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\u2081) : V \u2243\u2097[K] V\u2081 :=\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 \u2243\u2097[K] V') \u2194\n    cardinal.lift.{v'} (module.rank K V) = cardinal.lift.{v} (module.rank K V') :=\n\u27e8\u03bb \u27e8h\u27e9, linear_equiv.lift_dim_eq h, \u03bb h, nonempty_linear_equiv_of_lift_dim_eq h\u27e9\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 \u2243\u2097[K] V\u2081) \u2194 module.rank K V = module.rank K V\u2081 :=\n\u27e8\u03bb \u27e8h\u27e9, linear_equiv.dim_eq h, \u03bb h, nonempty_linear_equiv_of_dim_eq h\u27e9\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) \u2264 #s :=\nbegin\n  obtain \u27e8b, hb, hsab, hlib\u27e9 := exists_linear_independent K s,\n  convert cardinal.mk_le_mk_of_subset hb,\n  rw [\u2190 hsab, dim_span_set hlib]\nend\n\nlemma dim_span_of_finset (s : finset V) :\n  module.rank K (span K (\u2191s : set V)) < \u03c9 :=\ncalc module.rank K (span K (\u2191s : set V)) \u2264 #(\u2191s : set V) : dim_span_le \u2191s\n                             ... = s.card : by rw [finset.coe_sort_coe, cardinal.mk_finset]\n                             ... < \u03c9 : cardinal.nat_lt_omega _\n\ntheorem dim_prod : module.rank K (V \u00d7 V\u2081) = module.rank K V + module.rank K V\u2081 :=\nbegin\n  let b := basis.of_vector_space K V,\n  let c := basis.of_vector_space K V\u2081,\n  rw [\u2190 cardinal.lift_inj,\n      \u2190 (basis.prod b c).mk_eq_dim,\n      cardinal.lift_add, \u2190 cardinal.mk_ulift,\n      \u2190 b.mk_eq_dim, \u2190 c.mk_eq_dim,\n      \u2190 cardinal.mk_ulift, \u2190 cardinal.mk_ulift,\n      cardinal.add_def (ulift _)],\n  exact cardinal.lift_inj.1 (cardinal.lift_mk_eq.2\n      \u27e8equiv.ulift.trans (equiv.sum_congr equiv.ulift equiv.ulift).symm \u27e9),\nend\n\nsection fintype\nvariable [fintype \u03b7]\nvariables [\u2200i, add_comm_group (\u03c6 i)] [\u2200i, module K (\u03c6 i)]\n\nopen linear_map\n\nlemma dim_pi : module.rank K (\u03a0i, \u03c6 i) = cardinal.sum (\u03bbi, module.rank K (\u03c6 i)) :=\nbegin\n  let b := assume i, basis.of_vector_space K (\u03c6 i),\n  let this : basis (\u03a3 j, _) K (\u03a0 j, \u03c6 j) := pi.basis b,\n  rw [\u2190 cardinal.lift_inj, \u2190 this.mk_eq_dim],\n  simp [\u2190 (b _).mk_range_eq_dim]\nend\n\nlemma dim_fun {V \u03b7 : Type u} [fintype \u03b7] [add_comm_group V] [module K V] :\n  module.rank K (\u03b7 \u2192 V) = fintype.card \u03b7 * 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 (\u03b7 \u2192 V) = (fintype.card \u03b7 : cardinal.{max u\u2081' v}) *\n    cardinal.lift.{u\u2081'} (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 (\u03b7 \u2192 K) = fintype.card \u03b7 :=\nby rw [dim_fun_eq_lift_mul, dim_self, cardinal.lift_one, mul_one, cardinal.nat_cast_inj]\n\nlemma dim_fin_fun (n : \u2115) : module.rank K (fin n \u2192 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\u2081] [module K V\u2081]\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 \u29f8 p) + module.rank K p = module.rank K V :=\nby classical; exact let \u27e8f\u27e9 := 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 \u2192\u2097[K] V\u2081) :\n  module.rank K f.range + module.rank K f.ker = module.rank K V :=\nbegin\n  haveI := \u03bb (p : submodule K V), classical.dec_eq (V \u29f8 p),\n  rw [\u2190 f.quot_ker_equiv_range.dim_eq, dim_quotient_add_dim]\nend\n\nlemma dim_eq_of_surjective (f : V \u2192\u2097[K] V\u2081) (h : surjective f) :\n  module.rank K V = module.rank K V\u2081 + module.rank K f.ker :=\nby rw [\u2190 dim_range_add_dim_ker f, \u2190 dim_range_of_surjective f h]\n\nsection\nvariables [add_comm_group V\u2082] [module K V\u2082]\nvariables [add_comm_group V\u2083] [module K V\u2083]\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\u2082 \u2192\u2097[K] V) (eb : V\u2083 \u2192\u2097[K] V) (cd : V\u2081 \u2192\u2097[K] V\u2082) (ce : V\u2081 \u2192\u2097[K] V\u2083)\n  (hde : \u22a4 \u2264 db.range \u2294 eb.range)\n  (hgd : ker cd = \u22a5)\n  (eq : db.comp cd = eb.comp ce)\n  (eq\u2082 : \u2200d e, db d = eb e \u2192 (\u2203c, cd c = d \u2227 ce c = e)) :\n  module.rank K V + module.rank K V\u2081 = module.rank K V\u2082 + module.rank K V\u2083 :=\nhave hf : surjective (coprod db eb),\nbegin\n  refine (range_eq_top.1 $ top_unique $ _),\n  rwa [\u2190 map_top, \u2190 prod_top, map_coprod_prod, \u2190range_eq_map, \u2190range_eq_map]\nend,\nbegin\n  conv {to_rhs, rw [\u2190 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 [\u2190 ker_eq_bot, ker_cod_restrict, ker_prod, hgd, bot_inf_eq] },\n  { rw [\u2190 range_eq_top, eq_top_iff, range_cod_restrict, \u2190 map_le_iff_le_comap,\n      map_top, range_subtype],\n    rintros \u27e8d, e\u27e9,\n    have h := eq\u2082 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 \u22a2 h,\n    assume hde,\n    rcases h hde with \u27e8c, h\u2081, h\u2082\u27e9,\n    refine \u27e8c, h\u2081, _\u27e9,\n    rw [h\u2082, _root_.neg_neg] }\nend\n\nlemma dim_sup_add_dim_inf_eq (s t : submodule K V) :\n  module.rank K (s \u2294 t : submodule K V) + module.rank K (s \u2293 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 [\u2190 map_le_map_iff' (ker_subtype $ s \u2294 t), map_sup, map_top,\n      \u2190 linear_map.range_comp, \u2190 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 \u27e8x, hx\u27e9, refl end\n  begin\n    rintros \u27e8b\u2081, hb\u2081\u27e9 \u27e8b\u2082, hb\u2082\u27e9 eq,\n    have : b\u2081 = b\u2082 := congr_arg subtype.val eq,\n    subst this,\n    exact \u27e8\u27e8b\u2081, hb\u2081, hb\u2082\u27e9, rfl, rfl\u27e9\n  end\n\nlemma dim_add_le_dim_add_dim (s t : submodule K V) :\n  module.rank K (s \u2294 t : submodule K V) \u2264 module.rank K s + module.rank K t :=\nby { rw [\u2190 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  \u2203 b : V, b \u2208 s \u2227 b \u2260 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 \u2192\u2097[K] V') : cardinal := module.rank K f.range\n\nlemma rank_le_domain (f : V \u2192\u2097[K] V\u2081) : rank f \u2264 module.rank K V :=\nby { rw [\u2190 dim_range_add_dim_ker f], exact self_le_add_right _ _ }\n\nlemma rank_le_range (f : V \u2192\u2097[K] V\u2081) : rank f \u2264 module.rank K V\u2081 :=\ndim_submodule_le _\n\nlemma rank_add_le (f g : V \u2192\u2097[K] V') : rank (f + g) \u2264 rank f + rank g :=\ncalc rank (f + g) \u2264 module.rank K (f.range \u2294 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 \u2208 (f.range \u2294 g.range : submodule K V'), from\n        mem_sup.2 \u27e8_, \u27e8x, rfl\u27e9, _, \u27e8x, rfl\u27e9, rfl\u27e9)\n  end\n  ... \u2264 rank f + rank g : dim_add_le_dim_add_dim _ _\n\n@[simp] lemma rank_zero : rank (0 : V \u2192\u2097[K] V') = 0 :=\nby rw [rank, linear_map.range_zero, dim_bot]\n\nlemma rank_finset_sum_le {\u03b7} (s : finset \u03b7) (f : \u03b7 \u2192 V \u2192\u2097[K] V') :\n  rank (\u2211 d in s, f d) \u2264 \u2211 d in s, rank (f d) :=\n@finset.sum_hom_rel _ _ _ _ _ (\u03bba b, rank a \u2264 b) f (\u03bb d, rank (f d)) s (le_of_eq rank_zero)\n      (\u03bb 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 \u2192\u2097[K] V') (f : V' \u2192\u2097[K] V'') : rank (f.comp g) \u2264 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'\u2081] [module K V'\u2081]\n\nlemma rank_comp_le2 (g : V \u2192\u2097[K] V') (f : V' \u2192\u2097[K] V'\u2081) : rank (f.comp g) \u2264 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 `\u03b9` indexed basis on `V`, where `\u03b9` is an empty type and `V` is zero-dimensional.\n\nSee also `finite_dimensional.fin_basis`.\n-/\ndef basis.of_dim_eq_zero {\u03b9 : Type*} [is_empty \u03b9] (hV : module.rank K V = 0) :\n  basis \u03b9 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 {\u03b9 : Type*} [is_empty \u03b9]\n  (hV : module.rank K V = 0) (i : \u03b9) :\n  basis.of_dim_eq_zero hV i = 0 :=\nrfl\n\nlemma le_dim_iff_exists_linear_independent {c : cardinal} :\n  c \u2264 module.rank K V \u2194 \u2203 s : set V, #s = c \u2227 linear_independent K (coe : s \u2192 V) :=\nbegin\n  split,\n  { intro h,\n    let t := basis.of_vector_space K V,\n    rw [\u2190 t.mk_eq_dim'', cardinal.le_mk_iff_exists_subset] at h,\n    rcases h with \u27e8s, hst, hsc\u27e9,\n    exact \u27e8s, hsc, (of_vector_space_index.linear_independent K V).mono hst\u27e9 },\n  { rintro \u27e8s, rfl, si\u27e9,\n    exact cardinal_le_dim_of_linear_independent si }\nend\n\nlemma le_dim_iff_exists_linear_independent_finset {n : \u2115} :\n  \u2191n \u2264 module.rank K V \u2194\n    \u2203 s : finset V, s.card = n \u2227 linear_independent K (coe : (s : set V) \u2192 V) :=\nbegin\n  simp only [le_dim_iff_exists_linear_independent, cardinal.mk_eq_nat_iff_finset],\n  split,\n  { rintro \u27e8s, \u27e8t, rfl, rfl\u27e9, si\u27e9,\n    exact \u27e8t, rfl, si\u27e9 },\n  { rintro \u27e8s, rfl, si\u27e9,\n    exact \u27e8s, \u27e8s, rfl, rfl\u27e9, si\u27e9 }\nend\n\nlemma le_rank_iff_exists_linear_independent {c : cardinal} {f : V \u2192\u2097[K] V'} :\n  c \u2264 rank f \u2194\n  \u2203 s : set V, cardinal.lift.{v'} (#s) = cardinal.lift.{v} c \u2227\n    linear_independent K (\u03bb x : s, f x) :=\nbegin\n  rcases f.range_restrict.exists_right_inverse_of_surjective f.range_range_restrict with \u27e8g, hg\u27e9,\n  have fg : left_inverse f.range_restrict g, from linear_map.congr_fun hg,\n  refine \u27e8\u03bb h, _, _\u27e9,\n  { rcases le_dim_iff_exists_linear_independent.1 h with \u27e8s, rfl, si\u27e9,\n    refine \u27e8g '' s, cardinal.mk_image_eq_lift _ _ fg.injective, _\u27e9,\n    replace fg : \u2200 x, f (g x) = x, by { intro x, convert congr_arg subtype.val (fg x) },\n    replace si : linear_independent K (\u03bb 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 \u27e8s, hsc, si\u27e9,\n    have : linear_independent K (\u03bb 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 [\u2190 cardinal.lift_inj, \u2190 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 : \u2115} {f : V \u2192\u2097[K] V'} :\n  \u2191n \u2264 rank f \u2194 \u2203 s : finset V, s.card = n \u2227 linear_independent K (\u03bb 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 \u27e8s, \u27e8t, rfl, rfl\u27e9, si\u27e9,\n    exact \u27e8t, rfl, si\u27e9 },\n  { rintro \u27e8s, rfl, si\u27e9,\n    exact \u27e8s, \u27e8s, rfl, rfl\u27e9, si\u27e9 }\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 \u2264 1 \u2194 \u2203 v\u2080 : V, \u2200 v, \u2203 r : K, r \u2022 v\u2080 = v :=\nbegin\n  let b := basis.of_vector_space K V,\n  split,\n  { intro hd,\n    rw [\u2190 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 | \u27e8\u27e8v\u2080, hv\u2080\u27e9\u27e9,\n    { use 0,\n      have h' : \u2200 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\u2080,\n      have h' : (K \u2219 v\u2080) = \u22a4, { simpa [hd.eq_singleton_of_mem hv\u2080] using b.span_eq },\n      intro v,\n      have hv : v \u2208 (\u22a4 : submodule K V) := mem_top,\n      rwa [\u2190h', mem_span_singleton] at hv } },\n  { rintros \u27e8v\u2080, hv\u2080\u27e9,\n    have h : (K \u2219 v\u2080) = \u22a4,\n    { ext, simp [mem_span_singleton, hv\u2080] },\n    rw [\u2190dim_top, \u2190h],\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 \u2264 1 \u2194 \u2203 v\u2080 \u2208 s, s \u2264 K \u2219 v\u2080 :=\nbegin\n  simp_rw [dim_le_one_iff, le_span_singleton_iff],\n  split,\n  { rintro \u27e8\u27e8v\u2080, hv\u2080\u27e9, h\u27e9,\n    use [v\u2080, hv\u2080],\n    intros v hv,\n    obtain \u27e8r, hr\u27e9 := h \u27e8v, hv\u27e9,\n    use r,\n    simp_rw [subtype.ext_iff, coe_smul, submodule.coe_mk] at hr,\n    exact hr },\n  { rintro \u27e8v\u2080, hv\u2080, h\u27e9,\n    use \u27e8v\u2080, hv\u2080\u27e9,\n    rintro \u27e8v, hv\u27e9,\n    obtain \u27e8r, hr\u27e9 := 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 \u2264 1 \u2194 \u2203 v\u2080, s \u2264 K \u2219 v\u2080 :=\nbegin\n  rw dim_submodule_le_one_iff,\n  split,\n  { rintros \u27e8v\u2080, hv\u2080, h\u27e9,\n    exact \u27e8v\u2080, h\u27e9 },\n  { rintros \u27e8v\u2080, h\u27e9,\n    by_cases hw : \u2203 w : V, w \u2208 s \u2227 w \u2260 0,\n    { rcases hw with \u27e8w, hw, hw0\u27e9,\n      use [w, hw],\n      rcases mem_span_singleton.1 (h hw) with \u27e8r', rfl\u27e9,\n      have h0 : r' \u2260 0,\n      { rintro rfl,\n        simpa using hw0 },\n      rwa span_singleton_smul_eq _ h0 },\n    { push_neg at hw,\n      rw \u2190submodule.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) \u2228 (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) \u2190 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 \u2228 ... \u2228 L_{n-1} \u2228 L_n` by showing p = q -> L_{n-1} \u2228 L_n where L_{n-1} is p = True and L_n = q = False\n        let proofCase \u2190 Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let proofCase \u2190 Meta.mkAppM ``c1_soundness #[h]\n          Meta.mkLambdaFVars #[h] $ \u2190 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 \u2190 Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let idx := if j \u2265 i then j - 1 else j\n          Meta.mkLambdaFVars #[h] $ \u2190 orIntro (cLits.map Lit.toExpr) idx h\n        proofCases := proofCases.push proofCase\n    let r \u2190 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) \u2228 (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) \u2190 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 \u2228 ... \u2228 L_{n-1} \u2228 L_n` by showing p = q -> L_{n-1} \u2228 L_n where L_{n-1} is p = False and L_n = q = True\n        let proofCase \u2190 Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let proofCase \u2190 Meta.mkAppM ``c2_soundness #[h]\n          Meta.mkLambdaFVars #[h] $ \u2190 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 \u2190 Meta.withLocalDeclD `h lit.toExpr fun h => do\n          let idx := if j \u2265 i then j - 1 else j\n          Meta.mkLambdaFVars #[h] $ \u2190 orIntro (cLits.map Lit.toExpr) idx h\n        proofCases := proofCases.push proofCase\n    let r \u2190 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 \u00ac lit.rhs.isConstOf ``True && \u00ac 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 \u2190 getLoadedClauses\n        let ug \u2190 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\u00e9bastien Gou\u00ebzel, 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 {\u03b1 \u03b2 : Type _}\n\nnamespace List\n\nattribute [simp] join\n\n#print List.join_singleton /-\n@[simp]\ntheorem join_singleton (l : List \u03b1) : [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 : \u2200 {L : List (List \u03b1)}, join L = [] \u2194 \u2200 l \u2208 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\u2081 L\u2082 : List (List \u03b1)) : join (L\u2081 ++ L\u2082) = join L\u2081 ++ join L\u2082 := by\n  induction L\u2081 <;> [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 \u03b1)) (l : List \u03b1) : 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidablePred.{succ u1} (List.{u1} \u03b1) (fun (l : List.{u1} \u03b1) => Eq.{1} Bool (List.isEmpty.{u1} \u03b1 l) Bool.false)] {L : List.{u1} (List.{u1} \u03b1)}, Eq.{succ u1} (List.{u1} \u03b1) (List.join.{u1} \u03b1 (List.filter\u2093.{u1} (List.{u1} \u03b1) (fun (l : List.{u1} \u03b1) => Eq.{1} Bool (List.isEmpty.{u1} \u03b1 l) Bool.false) (fun (a : List.{u1} \u03b1) => _inst_1 a) L)) (List.join.{u1} \u03b1 L)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidablePred.{succ u1} (List.{u1} \u03b1) (fun (l : List.{u1} \u03b1) => Eq.{1} Bool (List.isEmpty.{u1} \u03b1 l) Bool.false)] {L : List.{u1} (List.{u1} \u03b1)}, Eq.{succ u1} (List.{u1} \u03b1) (List.join.{u1} \u03b1 (List.filter.{u1} (List.{u1} \u03b1) (fun (a : List.{u1} \u03b1) => Decidable.decide (Eq.{1} Bool (List.isEmpty.{u1} \u03b1 a) Bool.false) (_inst_1 a)) L)) (List.join.{u1} \u03b1 L)\nCase conversion may be inaccurate. Consider using '#align list.join_filter_empty_eq_ff List.join_filter_isEmpty_eq_false\u2093'. -/\n@[simp]\ntheorem join_filter_isEmpty_eq_false [DecidablePred fun l : List \u03b1 => l.Empty = false] :\n    \u2200 {L : List (List \u03b1)}, join (L.filter\u2093 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 {\u03b1 : Type.{u1}} [_inst_1 : DecidablePred.{succ u1} (List.{u1} \u03b1) (fun (l : List.{u1} \u03b1) => Ne.{succ u1} (List.{u1} \u03b1) l (List.nil.{u1} \u03b1))] {L : List.{u1} (List.{u1} \u03b1)}, Eq.{succ u1} (List.{u1} \u03b1) (List.join.{u1} \u03b1 (List.filter\u2093.{u1} (List.{u1} \u03b1) (fun (l : List.{u1} \u03b1) => Ne.{succ u1} (List.{u1} \u03b1) l (List.nil.{u1} \u03b1)) (fun (a : List.{u1} \u03b1) => _inst_1 a) L)) (List.join.{u1} \u03b1 L)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DecidablePred.{succ u1} (List.{u1} \u03b1) (fun (l : List.{u1} \u03b1) => Ne.{succ u1} (List.{u1} \u03b1) l (List.nil.{u1} \u03b1))] {L : List.{u1} (List.{u1} \u03b1)}, Eq.{succ u1} (List.{u1} \u03b1) (List.join.{u1} \u03b1 (List.filter.{u1} (List.{u1} \u03b1) (fun (a : List.{u1} \u03b1) => Decidable.decide (Ne.{succ u1} (List.{u1} \u03b1) a (List.nil.{u1} \u03b1)) (_inst_1 a)) L)) (List.join.{u1} \u03b1 L)\nCase conversion may be inaccurate. Consider using '#align list.join_filter_ne_nil List.join_filter_ne_nil\u2093'. -/\n@[simp]\ntheorem join_filter_ne_nil [DecidablePred fun l : List \u03b1 => l \u2260 []] {L : List (List \u03b1)} :\n    join (L.filter\u2093 fun l => l \u2260 []) = L.join := by\n  simp [join_filter_empty_eq_ff, \u2190 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 \u03b1))) : 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 \u03b1)) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} (l : List.{u1} \u03b1) (f : \u03b1 -> (List.{u2} \u03b2)), Eq.{1} Nat (List.length.{u2} \u03b2 (List.bind.{u1, u2} \u03b1 \u03b2 l f)) (List.sum.{0} Nat Nat.hasAdd Nat.hasZero (List.map.{u1, 0} \u03b1 Nat (Function.comp.{succ u1, succ u2, 1} \u03b1 (List.{u2} \u03b2) Nat (List.length.{u2} \u03b2) f) l))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} (l : List.{u2} \u03b1) (f : \u03b1 -> (List.{u1} \u03b2)), Eq.{1} Nat (List.length.{u1} \u03b2 (List.bind.{u2, u1} \u03b1 \u03b2 l f)) (List.sum.{0} Nat instAddNat (LinearOrderedCommMonoidWithZero.toZero.{0} Nat Nat.linearOrderedCommMonoidWithZero) (List.map.{u2, 0} \u03b1 Nat (Function.comp.{succ u2, succ u1, 1} \u03b1 (List.{u1} \u03b2) Nat (List.length.{u1} \u03b2) f) l))\nCase conversion may be inaccurate. Consider using '#align list.length_bind List.length_bind\u2093'. -/\n@[simp]\ntheorem length_bind (l : List \u03b1) (f : \u03b1 \u2192 List \u03b2) :\n    length (List.bind l f) = sum (map (length \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {l : List.{u1} \u03b1} {f : \u03b1 -> (List.{u2} \u03b2)}, Iff (Eq.{succ u2} (List.{u2} \u03b2) (List.bind.{u1, u2} \u03b1 \u03b2 l f) (List.nil.{u2} \u03b2)) (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (List.{u1} \u03b1) (List.hasMem.{u1} \u03b1) x l) -> (Eq.{succ u2} (List.{u2} \u03b2) (f x) (List.nil.{u2} \u03b2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {l : List.{u2} \u03b1} {f : \u03b1 -> (List.{u1} \u03b2)}, Iff (Eq.{succ u1} (List.{u1} \u03b2) (List.bind.{u2, u1} \u03b1 \u03b2 l f) (List.nil.{u1} \u03b2)) (forall (x : \u03b1), (Membership.mem.{u2, u2} \u03b1 (List.{u2} \u03b1) (List.instMembershipList.{u2} \u03b1) x l) -> (Eq.{succ u1} (List.{u1} \u03b2) (f x) (List.nil.{u1} \u03b2)))\nCase conversion may be inaccurate. Consider using '#align list.bind_eq_nil List.bind_eq_nil\u2093'. -/\n@[simp]\ntheorem bind_eq_nil {l : List \u03b1} {f : \u03b1 \u2192 List \u03b2} : List.bind l f = [] \u2194 \u2200 x \u2208 l, f x = [] :=\n  join_eq_nil.trans <| by\n    simp only [mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff\u2082]\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 \u03b1)) (i : \u2115) :\n    L.join.take ((L.map length).take i).Sum = (L.take i).join :=\n  by\n  induction L generalizing i; \u00b7 simp\n  cases i; \u00b7 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 \u03b1)) (i : \u2115) :\n    L.join.drop ((L.map length).take i).Sum = (L.drop i).join :=\n  by\n  induction L generalizing i; \u00b7 simp\n  cases i; \u00b7 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 \u03b1) {i : \u2115} (hi : i < L.length) :\n    (L.take (i + 1)).drop i = [nthLe L i hi] :=\n  by\n  induction L generalizing i\n  \u00b7 simp only [length] at hi\n    exact (Nat.not_succ_le_zero i hi).elim\n  cases i\n  \u00b7 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 `\u2264 i`. -/\ntheorem drop_take_succ_join_eq_nthLe (L : List (List \u03b1)) {i : \u2115} (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 \u03b1)) {i j : \u2115} (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 \u03b1)) {i j : \u2115} (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 \u03b1)) {i j : \u2115} (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 \u03b1)) :\n    L = L' \u2194 L.join = L'.join \u2227 map length L = map length L' :=\n  by\n  refine' \u27e8fun H => by simp [H], _\u27e9\n  rintro \u27e8join_eq, length_eq\u27e9\n  apply ext_le\n  \u00b7 have : length (map length L) = length (map length L') := by rw [length_eq]\n    simpa using this\n  \u00b7 intro n h\u2081 h\u2082\n    rw [\u2190 drop_take_succ_join_eq_nth_le, \u2190 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 \u03b1)} (h : L \u2260 []) :\n    (L.drop (L.length - 1)).join = L.getLast h :=\n  by\n  induction L using List.reverseRecOn\n  \u00b7 cases h rfl\n  \u00b7 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\u2081 ++ x) ++ (l\u2082 ++ x) ++ ... ++ (l\u2099 ++ x)` to\n`(x ++ l\u2081) ++ (x ++ l\u2082) ++ ... ++ (x ++ l\u2099) ++ x` where `L = [l\u2081, l\u2082, ..., l\u2099]`. -/\ntheorem append_join_map_append (L : List (List \u03b1)) (x : List \u03b1) :\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  \u00b7 rw [map_nil, join, append_nil, map_nil, join, nil_append]\n  \u00b7 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 \u03b1)) :\n    L.join.reverse = (List.map List.reverse L).reverse.join :=\n  by\n  induction L\n  \u00b7 rfl\n  \u00b7 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 \u03b1)) :\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\u2080 i\u2081 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 (\u03c0 : I \u2192 Sort u) (i : I) (x : \u03c0 i\u2080) : \u03c0 i :=\ninterval.ind x (equiv.subst seg x) (equiv.path_over_subst eq.rfl) i\n\ndef coe.back (\u03c0 : I \u2192 Sort u) (i : I) (x : \u03c0 i\u2081) : \u03c0 i :=\ninterval.ind (equiv.subst seg\u207b\u00b9 x) x (begin\n  apply equiv.path_over_subst, transitivity,\n  { symmetry, apply equiv.subst_comp }, transitivity,\n  { apply eq.map (\u03bb p, equiv.subst p x), apply eq.inv_comp },\n  reflexivity\nend) i\n\ndef coe (i k : I) (\u03c0 : I \u2192 Sort u) : \u03c0 i \u2192 \u03c0 k :=\ncoe.forward (\u03bb i, \u03c0 i \u2192 \u03c0 k) i (coe.forward \u03c0 k)\n\ndef coe_inv (i k : I) (\u03c0 : I \u2192 Sort u) : \u03c0 i \u2192 \u03c0 k :=\ncoe.back (\u03bb i, \u03c0 i \u2192 \u03c0 k) i (coe.back \u03c0 k)\n\nnotation `coe\u207b\u00b9` := coe_inv\n\n@[refl] def refl {\u03b1 : Sort u} (a : \u03b1) : a \u21dd a := <i> a\ndef rfl {\u03b1 : Sort u} {a : \u03b1} : a \u21dd a := <i> a\n\n@[symm] def symm {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) : b \u21dd a :=\n<i> p # \u2212i\npostfix `\u207b\u00b9` := symm\n\nabbreviation inv {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) := p\u207b\u00b9\n\nexample {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) : b \u21dd a :=\ncoe 1 0 (\u03bb i, b \u21dd p # i) rfl\n\ndef funext {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {f g : \u03a0 (x : \u03b1), \u03b2 x}\n  (p : \u03a0 (x : \u03b1), f x \u21dd g x) : f \u21dd g :=\n<i> \u03bb x, p x # i\n\ndef cong {\u03b1 : Sort u} {\u03b2 : Sort v} {a b : \u03b1}\n  (f : \u03b1 \u2192 \u03b2) (p : a \u21dd b) : f a \u21dd f b :=\n<i> f (p # i)\n\ndef ap {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {a b : \u03b1}\n  (f : \u03b1 \u2192 \u03b2 a) (p : a \u21dd b) : f a \u21dd f b :=\n<i> f (p # i)\n\ndef subst {\u03b1 : Sort u} {\u03c0 : \u03b1 \u2192 Sort v} {a b : \u03b1}\n  (p : a \u21dd b) (x : \u03c0 a) : \u03c0 b :=\ncoe 0 1 (\u03bb i, \u03c0 (p # i)) x\n\nabbreviation transport {\u03b1 : Sort u} (\u03c0 : \u03b1 \u2192 Sort v) {a b : \u03b1}\n  (p : a \u21dd b) : \u03c0 a \u2192 \u03c0 b := subst p\n\ndef trans {\u03b1 \u03b2 : Sort u} (p : \u03b1 \u21dd \u03b2) : \u03b1 \u2192 \u03b2 :=\ncoe 0 1 (\u03bb i, p # i)\nabbreviation coerce {\u03b1 \u03b2 : Sort u} : (\u03b1 \u21dd \u03b2) \u2192 (\u03b1 \u2192 \u03b2) := trans\n\ndef trans_neg {\u03b1 \u03b2 : Sort u} (p : \u03b1 \u21dd \u03b2) : \u03b2 \u2192 \u03b1 :=\ncoe 1 0 (\u03bb i, p # i)\n\ndef transK {\u03b1 \u03b2 : Sort u} (p : \u03b1 \u21dd \u03b2) (x : \u03b1) :\n  x \u21dd trans_neg p (trans p x) :=\n<i> coe i 0 (\u03bb i, p # i) (coe 0 i (\u03bb i, p # i) x)\n\ndef idtoeqv {\u03b1 \u03b2 : Sort u} (p : \u03b1 \u21dd \u03b2) : \u03b1 \u2243 \u03b2 :=\ntrans (<i> \u03b1 \u2243 p # i) (equiv.id \u03b1)\n\ndef test_eta {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) : p \u21dd p := rfl\ndef face\u2080 {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) : \u03b1 := p # 0\ndef face\u2081 {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) : \u03b1 := p # 1\n\ndef comp_test\u2080 {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) : p # 0 \u21dd a := rfl\ndef comp_test\u2081 {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) : p # 1 \u21dd b := rfl\n\n-- fail\n--def symm_test {\u03b1 : Type u} {a b : \u03b1} (p : a \u21dd b) : (p\u207b\u00b9)\u207b\u00b9 \u21dd p := rfl\n@[trans] def composition {\u03b1 : Sort u} {a b c : \u03b1}\n  (p : a \u21dd b) (q : b \u21dd c) : a \u21dd c := subst q p\n\ninfix \u2b1d := composition\n\n-- this will be replaced by a more general version in future\ndef kan {\u03b1 : Sort u} {a b c d : \u03b1}\n  (bottom : b \u21dd c) (left : b \u21dd a) (right : c \u21dd d) : a \u21dd d :=\nleft\u207b\u00b9 \u2b1d bottom \u2b1d right\n\ndef kan_op {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd a) (q : a \u21dd b) : b \u21dd b :=\nkan p q q\n\ndef interval_contr (i : I) : i\u2080 \u21dd i := coe 0 i (\u03bb i, i\u2080 \u21dd i) rfl\ndef seg_path : i\u2080 \u21dd i\u2081 := interval_contr i\u2081\n\n-- or too direct way\nexample : i\u2080 \u21dd i\u2081 := <i> i\n\ndef conn_and {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) :\n  LineP (\u03bb i, a \u21dd p # i) :=\n\u03bb i, <j> p # i \u2227 j\n\ndef conn_or {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) :\n  LineP (\u03bb i, p # i \u21dd b) :=\n\u03bb i, <j> p # i \u2228 j\n\ndef singl {\u03b1 : Sort u} (a : \u03b1) :=\n\u03a3' (x : \u03b1), a \u21dd x\n\ndef eta {\u03b1 : Sort u} (a : \u03b1) : singl a := \u27e8a, refl a\u27e9\n\ndef refl_contr {\u03b1 : Sort u} {a b : \u03b1} (p : a \u21dd b) :\n  LineP (\u03bb i, a \u21dd 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\u2019t pass typechecking.\n\ndef J {\u03b1 : Type u} {a : \u03b1} {\u03c0 : \u03a0 (b : \u03b1), a \u21dd b \u2192 Type u}\n  (h : \u03c0 a (refl a)) (b : \u03b1) (p : a \u21dd b) : \u03c0 b (<i> p # i) :=\ncoe (\u03bb i, \u03c0 (p # i) (conn_and p i)) h i\u2081\n\ndef J {\u03b1 : Type u} {a : \u03b1} {\u03c0 : \u03a0 (b : \u03b1), a \u21dd b \u2192 Type u}\n  (h : \u03c0 a (refl a)) (b : \u03b1) (p : a \u21dd b) : \u03c0 b (<i> p # i) :=\ntransport (<i> \u03c0 (p # i) (<j> p # i \u2227 j)) h\n-/\n\ndef J {\u03b1 : Sort u} {a : \u03b1} (\u03c0 : \u03a0 (b : \u03b1), a \u21dd b \u2192 Sort v)\n  (h : \u03c0 a (refl a)) {b : \u03b1} (p : a \u21dd b) : \u03c0 b p :=\ntrans (<i> \u03c0 (p # i) (refl_contr p i)) h\n\nend Path\n\ndef {u} PathP (\u03c3 : I \u2192 Sort u) (a : \u03c3 0) (b : \u03c3 1) :=\nPath (equiv.subst interval.seg a) b\n\ndef {u} PathP.lam (\u03c3 : I \u2192 Sort u) (f : \u03a0 i, \u03c3 i) : PathP \u03c3 (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 \u03b1] (p : a = b) (c : \u03b1) : a + c = b + c := p \u25b8 rfl\ntheorem c_add_pf [Add \u03b1] (p : b = c) (a : \u03b1) : a + b = a + c := p \u25b8 rfl\ntheorem add_pf [Add \u03b1] (p\u2081 : (a\u2081:\u03b1) = b\u2081) (p\u2082 : a\u2082 = b\u2082) : a\u2081 + a\u2082 = b\u2081 + b\u2082 := p\u2081 \u25b8 p\u2082 \u25b8 rfl\ntheorem pf_sub_c [Sub \u03b1] (p : a = b) (c : \u03b1) : a - c = b - c := p \u25b8 rfl\ntheorem c_sub_pf [Sub \u03b1] (p : b = c) (a : \u03b1) : a - b = a - c := p \u25b8 rfl\ntheorem sub_pf [Sub \u03b1] (p\u2081 : (a\u2081:\u03b1) = b\u2081) (p\u2082 : a\u2082 = b\u2082) : a\u2081 - a\u2082 = b\u2081 - b\u2082 := p\u2081 \u25b8 p\u2082 \u25b8 rfl\ntheorem neg_pf [Neg \u03b1] (p : (a:\u03b1) = b) : -a = -b := p \u25b8 rfl\ntheorem pf_mul_c [Mul \u03b1] (p : a = b) (c : \u03b1) : a * c = b * c := p \u25b8 rfl\ntheorem c_mul_pf [Mul \u03b1] (p : b = c) (a : \u03b1) : a * b = a * c := p \u25b8 rfl\ntheorem mul_pf [Mul \u03b1] (p\u2081 : (a\u2081:\u03b1) = b\u2081) (p\u2082 : a\u2082 = b\u2082) : a\u2081 * a\u2082 = b\u2081 * b\u2082 := p\u2081 \u25b8 p\u2082 \u25b8 rfl\ntheorem inv_pf [Inv \u03b1] (p : (a:\u03b1) = b) : a\u207b\u00b9 = b\u207b\u00b9 := p \u25b8 rfl\ntheorem pf_div_c [Div \u03b1] (p : a = b) (c : \u03b1) : a / c = b / c := p \u25b8 rfl\ntheorem c_div_pf [Div \u03b1] (p : b = c) (a : \u03b1) : a / b = a / c := p \u25b8 rfl\ntheorem div_pf [Div \u03b1] (p\u2081 : (a\u2081:\u03b1) = b\u2081) (p\u2082 : a\u2082 = b\u2082) : a\u2081 / a\u2082 = b\u2081 / b\u2082 := p\u2081 \u25b8 p\u2082 \u25b8 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 \u2190 match stx with\n  | `(($e)) => expandLinearCombo e\n  | `($e\u2081 + $e\u2082) => do\n    match \u2190 expandLinearCombo e\u2081, \u2190 expandLinearCombo e\u2082 with\n    | none, none => pure none\n    | some p\u2081, none => ``(pf_add_c $p\u2081 $e\u2082)\n    | none, some p\u2082 => ``(c_add_pf $p\u2082 $e\u2081)\n    | some p\u2081, some p\u2082 => ``(add_pf $p\u2081 $p\u2082)\n  | `($e\u2081 - $e\u2082) => do\n    match \u2190 expandLinearCombo e\u2081, \u2190 expandLinearCombo e\u2082 with\n    | none, none => pure none\n    | some p\u2081, none => ``(pf_sub_c $p\u2081 $e\u2082)\n    | none, some p\u2082 => ``(c_sub_pf $p\u2082 $e\u2081)\n    | some p\u2081, some p\u2082 => ``(sub_pf $p\u2081 $p\u2082)\n  | `(-$e) => do\n    match \u2190 expandLinearCombo e with\n    | none => pure none\n    | some p => ``(neg_pf $p)\n  | `(\u2190 $e) => do\n    match \u2190 expandLinearCombo e with\n    | none => pure none\n    | some p => ``(Eq.symm $p)\n  | `($e\u2081 * $e\u2082) => do\n    match \u2190 expandLinearCombo e\u2081, \u2190 expandLinearCombo e\u2082 with\n    | none, none => pure none\n    | some p\u2081, none => ``(pf_mul_c $p\u2081 $e\u2082)\n    | none, some p\u2082 => ``(c_mul_pf $p\u2082 $e\u2081)\n    | some p\u2081, some p\u2082 => ``(mul_pf $p\u2081 $p\u2082)\n  | `($e\u207b\u00b9) => do\n    match \u2190 expandLinearCombo e with\n    | none => pure none\n    | some p => ``(inv_pf $p)\n  | `($e\u2081 / $e\u2082) => do\n    match \u2190 expandLinearCombo e\u2081, \u2190 expandLinearCombo e\u2082 with\n    | none, none => pure none\n    | some p\u2081, none => ``(pf_div_c $p\u2081 $e\u2082)\n    | none, some p\u2082 => ``(c_div_pf $p\u2082 $e\u2081)\n    | some p\u2081, some p\u2082 => ``(div_pf $p\u2081 $p\u2082)\n  | e => do\n    let e \u2190 elabTerm e none\n    let eType \u2190 inferType e\n    let .true := (\u2190 withReducible do whnf eType).isEq | pure none\n    some <$> e.toSyntax\n  return result.map fun r => \u27e8r.raw.setInfo (SourceInfo.fromRef stx true)\u27e9\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\u2083 (p : (a:\u03b1) = b) (p\u2081 : a = a') (p\u2082 : b = b') : a' = b' := p\u2081 \u25b8 p\u2082 \u25b8 p\n\ntheorem eq_of_add [AddGroup \u03b1] (p : (a:\u03b1) = b) (H : (a' - b') - (a - b) = 0) : a' = b' := by\n  rw [\u2190 sub_eq_zero] at p \u22a2; 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 \u2190 match input with\n  | none => `(Eq.refl 0)\n  | some e => withSynthesize do\n    match \u2190 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 <|\u2190 withFreshMacroScope <| if twoGoals then\n    `(tactic| (\n      refine eq_trans\u2083 $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 `\u2190 h`, so for example if `h\u2081 : a = b`\n    then `2 * (\u2190 h)` is a proof of `2 * b = 2 * a`.\n\nExample Usage:\n```\nexample (x y : \u2124) (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 : \u2124) (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 : \u2124) (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 : \u211d) (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 : \u211a) (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 : \u2124) (h1 : x = -3) (h2 : y = 10) : 2*x = -6 := by\n  linear_combination (norm := skip) 2*h1\n  simp\n\naxiom qc : \u211a\naxiom hqc : qc = 2*qc\n\nexample (a b : \u211a) (h : \u2200 p q : \u211a, 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 \u2964 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 \u2964 over B) :\n  F \u22d9 forget B \u27f6 (category_theory.functor.const J).obj B :=\n{ app := \u03bb 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 \u2964 over B} (c : cone (F \u22d9 forget B)) :\n  cone F :=\n{ X := over.mk (c.\u03c0.app (classical.arbitrary J) \u226b (F.obj (classical.arbitrary J)).hom),\n  \u03c0 :=\n  { app := \u03bb j,\n      over.hom_mk (c.\u03c0.app j) (nat_trans_from_is_connected (c.\u03c0 \u226b nat_trans_in_over F) j _) } }\n\nlemma raised_cone_lowers_to_original [is_connected J] {B : C} {F : J \u2964 over B}\n  (c : cone (F \u22d9 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 \u2964 over B}\n  {c : cone (F \u22d9 forget B)} (t : is_limit c) :\n  is_limit (raise_cone c) :=\n{ lift := \u03bb s, over.hom_mk (t.lift ((forget B).map_cone s)) (by { dsimp, simp }),\n  uniq' := \u03bb s m K, by { ext1, apply t.hom_ext, intro j, simp [\u2190 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 := \u03bb K,\n    creates_limit_of_reflects_iso (\u03bb 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 := \u03bb 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\u2081 (p : a = b) (q : b = c) : a = c :=\n  @Id.casesOn A a (\u03bb x _, x = c \u2192 a = c) b p (@Id.casesOn A a (\u03bb x _, a = x) c \u00b7 (idp a)) q\n\n  infixl:99 \" \u2b1d\u2081 \" => trans\u2081\n\n  hott def trans\u2082 (p : a = b) (q : b = c) : a = c :=\n  @Id.casesOn A a (\u03bb x _, x = c \u2192 a = c) b p idfun q\n\n  infixl:99 \" \u2b1d\u2082 \" => trans\u2082\n\n  hott def trans\u2083 (p : a = b) (q : b = c) : a = c :=\n  @Id.casesOn A b (\u03bb x _, a = b \u2192 a = x) c q idfun p\n\n  infixl:99 \" \u2b1d\u2083 \" => trans\u2083\n\n  hott def eq\u2081\u2082 (p : a = b) (q : b = c) : p \u2b1d\u2081 q = p \u2b1d\u2082 q :=\n  begin induction p; induction q; reflexivity end\n\n  hott def eq\u2082\u2083 (p : a = b) (q : b = c) : p \u2b1d\u2082 q = p \u2b1d\u2083 q :=\n  begin induction p; induction q; reflexivity end\n\n  hott def eq\u2081\u2083 (p : a = b) (q : b = c) : p \u2b1d\u2081 q = p \u2b1d\u2083 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\u2081\u2082 p q \u2b1d eq\u2082\u2083 p q = eq\u2081\u2083 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\u2084 (p : a = b) (q : b = c) : a = c :=\n  @Id.casesOn A b (\u03bb x _, a = b \u2192 a = x) c q (@Id.casesOn A a (\u03bb x _, a = x) b \u00b7 (idp a)) p\n\n  infixl:99 \" \u2b1d\u2084 \" => trans\u2084\n\n  /-\n  example (p : a = b) (q : b = c) : p \u2b1d\u2081 q = p \u2b1d\u2084 q := idp _\n  example (p : a = b) (q : b = c) : p \u2b1d\u2082 q = p \u2b1d\u2084 q := idp _\n  example (p : a = b) (q : b = c) : p \u2b1d\u2083 q = p \u2b1d\u2084 q := idp _\n  -/\n\n  example (p : a = b) (q : b = c) : p \u2b1d\u2081 q = p \u2b1d\u2084 q :=\n  begin induction p; induction q; reflexivity end\nend\n\n-- exercise 2.4\n\nhott def nPath (A : Type u) : \u2115 \u2192 Type u\n| Nat.zero   => A\n| Nat.succ n => \u03a3 (a b : nPath A n), a = b\n\nhott def boundary {A : Type u} {n : \u2115} :\n  nPath A (n + 1) \u2192 (nPath A n) \u00d7 (nPath A n) :=\n\u03bb \u27e8a, b, _\u27e9, (a, b)\n\n-- exercise 2.5\n\nnamespace \u00ab2.5\u00bb\n  variable {A : Type u} {B : Type v} {x y : A} (p : x = y)\n\n  hott def transconst (b : B) : transport (\u03bb _, B) p b = b :=\n  begin induction p; reflexivity end\n\n  hott def f (\u03c6 : A \u2192 B) : \u03c6 x = \u03c6 y \u2192 transport (\u03bb _, B) p (\u03c6 x) = \u03c6 y :=\n  \u03bb q, transconst p (\u03c6 x) \u2b1d q\n\n  hott def g (\u03c6 : A \u2192 B) : transport (\u03bb _, B) p (\u03c6 x) = \u03c6 y \u2192 \u03c6 x = \u03c6 y :=\n  \u03bb q, (transconst p (\u03c6 x))\u207b\u00b9 \u2b1d q\n\n  example (\u03c6 : A \u2192 B) : f p \u03c6 \u2218 g p \u03c6 ~ id :=\n  begin induction p; reflexivity end\n\n  example (\u03c6 : A \u2192 B) : g p \u03c6 \u2218 f p \u03c6 ~ id :=\n  begin induction p; reflexivity end\nend \u00ab2.5\u00bb\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\u207b\u00b9 <;> intro q <;> induction p <;> induction q <;> reflexivity end\n\n-- exercise 2.7\n\nnamespace \u00ab2.7\u00bb\n  variable {A : Type u} {A' : Type u'} {B : A \u2192 Type v} {B' : A' \u2192 Type v'}\n           (g : A \u2192 A') (h : \u03a0 a, B a \u2192 B' (g a))\n\n  def \u03c6 (x : \u03a3 a, B a) : \u03a3 a', B' a' := \u27e8g x.1, h x.1 x.2\u27e9\n\n  hott def prodMap : \u03a0 (x y : \u03a3 a, B a) (p : x.1 = y.1) (q : x.2 =[p] y.2),\n      Id.map (\u03c6 g h) (Sigma.prod p q)\n    = @Sigma.prod A' B' (\u03c6 g h x) (\u03c6 g h y)\n        (@Id.map A A' x.1 y.1 g p) (depPathMap' g h q) :=\n  begin\n    intro \u27e8x, H\u27e9 \u27e8y, G\u27e9 (p : x = y); induction p;\n    intro (q : H = G); induction q; reflexivity\n  end\nend \u00ab2.7\u00bb\n\n-- exercise 2.8\n\nnamespace \u00ab2.8\u00bb\n  variable {A A' B B' : Type u} (g : A \u2192 A') (h : B \u2192 B')\n\n  def \u03c6 : A + B \u2192 A' + B' :=\n  Coproduct.elim (Coproduct.inl \u2218 g) (Coproduct.inr \u2218 h)\n\n  hott def \u03c1 : \u03a0 {x y : A + B}, Coproduct.code x y \u2192 Coproduct.code (\u03c6 g h x) (\u03c6 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) : \u03a0 p,\n      Id.map (\u03c6 g h) (Coproduct.pathSum x y p)\n    = Coproduct.pathSum (\u03c6 g h x) (\u03c6 g h y) (\u03c1 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 \u00ab2.8\u00bb\n\n-- exercise 2.9\n\nhott def Coproduct.depUnivProperty (A : Type u) (B : Type v) (X : A + B \u2192 Type w) :\n  (\u03a0 x, X x) \u2243 (\u03a0 a, X (Coproduct.inl a)) \u00d7 (\u03a0 b, X (Coproduct.inr b)) :=\nbegin\n  fapply Sigma.mk; { intro \u03c6; exact (\u03bb a, \u03c6 (Coproduct.inl a), \u03bb b, \u03c6 (Coproduct.inr b)) };\n  apply Qinv.toBiinv; fapply Sigma.mk;\n  { intros \u03c6 x; induction x using Sum.casesOn; apply \u03c6.1; apply \u03c6.2 };\n  apply Prod.mk; { intro (\u03c6, \u03c8); 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 \u2192 X) \u2243 (A \u2192 X) \u00d7 (B \u2192 X) :=\nCoproduct.depUnivProperty A B (\u03bb _, X)\n\n-- exercise 2.10\n\nhott def sigma.assoc (A : Type u) (B : A \u2192 Type v) (C : (\u03a3 x, B x) \u2192 Type w) :\n  (\u03a3 x, \u03a3 y, C \u27e8x, y\u27e9) \u2243 (\u03a3 p, C p) :=\nbegin\n  fapply Sigma.mk; { intro w; existsi \u27e8w.1, w.2.1\u27e9; 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 \u27e8\u27e8a, b\u27e9, c\u27e9; reflexivity };\n  { intro \u27e8a, \u27e8b, c\u27e9\u27e9; reflexivity }\nend\n\n-- exercise 2.11\n\nnamespace \u00ab2.11\u00bb\n  variable {P : Type k} {A : Type u} {B : Type v} {C : Type w}\n           (\u03b7 : pullbackSquare P A B C)\n\n  example : P \u2243 pullback C \u03b7.1.right \u03b7.1.bot :=\n  Theorems.pullbackCorner \u03b7\nend \u00ab2.11\u00bb\n\n-- exercise 2.12\n\nnamespace \u00ab2.12\u00bb\n  variable {A B C D E F : Type u}\n           {f : A \u2192 C} {g : C \u2192 E} {i : A \u2192 B} {j : C \u2192 D}\n           {k : E \u2192 F} {h : B \u2192 D} {s : D \u2192 F}\n           (\u03b1 : j \u2218 f = h \u2218 i) (\u03b2 : k \u2218 g = s \u2218 j)\n\n  def left  : hcommSquare A C B D := \u27e8j, h, f, i, \u03b1\u27e9\n  def right : hcommSquare C E D F := \u27e8k, s, g, j, \u03b2\u27e9\n\n  def outer : hcommSquare A E B F :=\n  \u27e8k, s \u2218 h, g \u2218 f, i, @Id.map (C \u2192 F) (A \u2192 F) _ _ (\u00b7 \u2218 f) \u03b2\n                     \u2b1d @Id.map _ (A \u2192 F) _ _ (s \u2218 \u00b7) \u03b1\u27e9\n\n  hott def pullbackLemma (H : (right \u03b2).isPullback) :\n    (left \u03b1).isPullback \u2194 (outer \u03b1 \u03b2).isPullback :=\n  sorry\nend \u00ab2.12\u00bb\n\n-- exercise 2.13\n\nexample : (\ud835\udfd0 \u2243 \ud835\udfd0) \u2243 \ud835\udfd0 := Theorems.Equiv.boolEquivEqvBool\n\n-- exercise 2.14\n\n-- Assume \u0393, p : x = y \u22a2 x \u2261 y, let \u0393 = A : U, a : A. Then \u0393, b : A, p : a = b \u22a2 p = idp a : U,\n-- because in this context we have p : a = b, so a \u2261 b, so p : a = a.\n-- \u201c@Id.rec A a (\u03bb b, p = idp a) (\u03bb x, idp a) a\u201d is then well-typed.\n-- This means that we have a proof of \u201c\u03a0 (p : a = a), p = idp a\u201d leading to contradiction.\n\n-- exercise 2.15\n\nhott def transportMap {A : Type u} {B : A \u2192 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 \u2192 Type v} {f g : \u03a0 x, B x} (H : f ~ g) {x y : A} (p : x = y) :\n  Id.map (transport B p) (H x) \u2b1d apd g p = apd f p \u2b1d 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 `\u27e8X, b\u27e9`, 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\nnoncomputable theory\n\nnamespace category_theory\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] [monoidal_category C]\n\n/--\nA half-braiding on `X : C` is a family of isomorphisms `X \u2297 U \u2245 U \u2297 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(\u03b2 : \u03a0 U, X \u2297 U \u2245 U \u2297 X)\n(monoidal' : \u2200 U U', (\u03b2 (U \u2297 U')).hom =\n  (\u03b1_ _ _ _).inv \u226b ((\u03b2 U).hom \u2297 \ud835\udfd9 U') \u226b (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 U \u2297 (\u03b2 U').hom) \u226b (\u03b1_ _ _ _).inv\n  . obviously)\n(naturality' : \u2200 {U U'} (f : U \u27f6 U'), (\ud835\udfd9 X \u2297 f) \u226b (\u03b2 U').hom = (\u03b2 U).hom \u226b (f \u2297 \ud835\udfd9 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 `\u27e8X, b\u27e9`, where `X : C`\nand `b` is a half-braiding on `X`.\n-/\n@[nolint has_nonempty_instance]\ndef center := \u03a3 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 \u27f6 Y.1)\n(comm' : \u2200 U, (f \u2297 \ud835\udfd9 U) \u226b (Y.2.\u03b2 U).hom = (X.2.\u03b2 U).hom \u226b (\ud835\udfd9 U \u2297 f) . obviously)\n\nrestate_axiom hom.comm'\nattribute [simp, reassoc] hom.comm\n\ninstance : category (center C) :=\n{ hom := hom,\n  id := \u03bb X, { f := \ud835\udfd9 X.1, },\n  comp := \u03bb X Y Z f g, { f := f.f \u226b g.f, }, }\n\n@[simp] lemma id_f (X : center C) : hom.f (\ud835\udfd9 X) = \ud835\udfd9 X.1 := rfl\n@[simp] lemma comp_f {X Y Z : center C} (f : X \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g).f = f.f \u226b g.f := rfl\n\n@[ext]\nlemma ext {X Y : center C} (f g : X \u27f6 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 \u27f6 Y) [is_iso f.f] : X \u2245 Y :=\n{ hom := f,\n  inv := \u27e8inv f.f, \u03bb U, by simp [\u2190cancel_epi (f.f \u2297 \ud835\udfd9 U), \u2190comp_tensor_id_assoc, \u2190id_tensor_comp]\u27e9 }\n\ninstance is_iso_of_f_is_iso {X Y : center C} (f : X \u27f6 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\u27e8X.1 \u2297 Y.1,\n  { \u03b2 := \u03bb U, \u03b1_ _ _ _ \u226a\u226b (iso.refl X.1 \u2297 Y.2.\u03b2 U) \u226a\u226b (\u03b1_ _ _ _).symm\n      \u226a\u226b (X.2.\u03b2 U \u2297 iso.refl Y.1) \u226a\u226b \u03b1_ _ _ _,\n    monoidal' := \u03bb 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.\u03b2 U).hom \u2297 \ud835\udfd9 Y.fst) \u2297 \ud835\udfd9 U'`\n      -- and `\ud835\udfd9 U \u2297 \ud835\udfd9 X.fst \u2297 (Y.snd.\u03b2 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 \u2190associator_naturality, },\n      slice_rhs 6 7 { rw [tensor_id, tensor_id, tensor_id_comp_id_tensor, \u2190id_tensor_comp_tensor_id,\n        \u2190tensor_id, \u2190tensor_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' := \u03bb U U' f,\n    begin\n      dsimp,\n      rw [category.assoc, category.assoc, category.assoc, category.assoc,\n        id_tensor_associator_naturality_assoc, \u2190id_tensor_comp_assoc, half_braiding.naturality,\n        id_tensor_comp_assoc, associator_inv_naturality_assoc, \u2190comp_tensor_id_assoc,\n        half_braiding.naturality, comp_tensor_id_assoc, associator_naturality, \u2190tensor_id],\n    end, }\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_hom {X\u2081 Y\u2081 X\u2082 Y\u2082 : center C} (f : X\u2081 \u27f6 Y\u2081) (g : X\u2082 \u27f6 Y\u2082) :\n  tensor_obj X\u2081 X\u2082 \u27f6 tensor_obj Y\u2081 Y\u2082 :=\n{ f := f.f \u2297 g.f,\n  comm' := \u03bb U, begin\n    dsimp,\n    rw [category.assoc, category.assoc, category.assoc, category.assoc,\n      associator_naturality_assoc, \u2190tensor_id_comp_id_tensor, category.assoc,\n      \u2190id_tensor_comp_assoc, g.comm, id_tensor_comp_assoc, tensor_id_comp_id_tensor_assoc,\n      \u2190id_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, \u2190tensor_id_comp_id_tensor g.f, category.assoc,\n      \u2190comp_tensor_id_assoc, f.comm, comp_tensor_id_assoc, id_tensor_associator_naturality,\n      associator_naturality_assoc, \u2190id_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\u27e8\ud835\udfd9_ C,\n  { \u03b2 := \u03bb U, (\u03bb_ U) \u226a\u226b (\u03c1_ U).symm,\n    monoidal' := \u03bb U U', by simp,\n    naturality' := \u03bb U U' f, begin\n      dsimp,\n      rw [left_unitor_naturality_assoc, right_unitor_inv_naturality, category.assoc],\n    end, }\u27e9\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 \u2245 tensor_obj X (tensor_obj Y Z) :=\niso_mk \u27e8(\u03b1_ X.1 Y.1 Z.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [comp_tensor_id, id_tensor_comp, \u2190tensor_id, associator_conjugation],\n  coherence,\nend\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef left_unitor (X : center C) : tensor_obj tensor_unit X \u2245 X :=\niso_mk \u27e8(\u03bb_ X.1).hom, \u03bb 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 [\u2190left_unitor_tensor, left_unitor_naturality, left_unitor_tensor'_assoc],\nend\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef right_unitor (X : center C) : tensor_obj X tensor_unit \u2245 X :=\niso_mk \u27e8(\u03c1_ X.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [tensor_id_comp_id_tensor_assoc, triangle_assoc, id_tensor_comp, category.assoc],\n  rw [\u2190tensor_id_comp_id_tensor_assoc (\u03c1_ U).inv, cancel_epi, \u2190right_unitor_tensor_inv_assoc,\n    \u2190right_unitor_inv_naturality_assoc],\n  simp,\nend\u27e9\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 := \u03bb X Y, tensor_obj X Y,\n  tensor_hom := \u03bb X\u2081 Y\u2081 X\u2082 Y\u2082 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 \u2297 Y).1 = X.1 \u2297 Y.1 := rfl\n\n@[simp] lemma tensor_\u03b2 (X Y : center C) (U : C) :\n  (X \u2297 Y).2.\u03b2 U =\n    \u03b1_ _ _ _ \u226a\u226b (iso.refl X.1 \u2297 Y.2.\u03b2 U) \u226a\u226b (\u03b1_ _ _ _).symm\n      \u226a\u226b (X.2.\u03b2 U \u2297 iso.refl Y.1) \u226a\u226b \u03b1_ _ _ _ :=\nrfl\n@[simp] \n\n@[simp] lemma tensor_unit_\u03b2 (U : C) : (\ud835\udfd9_ (center C)).2.\u03b2 U = (\u03bb_ U) \u226a\u226b (\u03c1_ U).symm := rfl\n\n@[simp] lemma associator_hom_f (X Y Z : center C) : hom.f (\u03b1_ X Y Z).hom = (\u03b1_ X.1 Y.1 Z.1).hom :=\nrfl\n\n@[simp] lemma associator_inv_f (X Y Z : center C) : hom.f (\u03b1_ X Y Z).inv = (\u03b1_ X.1 Y.1 Z.1).inv :=\nby { ext, rw [\u2190associator_hom_f, \u2190comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma left_unitor_hom_f (X : center C) : hom.f (\u03bb_ X).hom = (\u03bb_ X.1).hom :=\nrfl\n\n@[simp] lemma left_unitor_inv_f (X : center C) : hom.f (\u03bb_ X).inv = (\u03bb_ X.1).inv :=\nby { ext, rw [\u2190left_unitor_hom_f, \u2190comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma right_unitor_hom_f (X : center C) : hom.f (\u03c1_ X).hom = (\u03c1_ X.1).hom :=\nrfl\n\n@[simp] lemma right_unitor_inv_f (X : center C) : hom.f (\u03c1_ X).inv = (\u03c1_ X.1).inv :=\nby { ext, rw [\u2190right_unitor_hom_f, \u2190comp_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 := \u03bb X, X.1,\n  map := \u03bb X Y f, f.f,\n  \u03b5 := \ud835\udfd9 (\ud835\udfd9_ C),\n  \u03bc := \u03bb X Y, \ud835\udfd9 (X.1 \u2297 Y.1), }\n\ninstance : reflects_isomorphisms (forget C).to_functor :=\n{ reflects := \u03bb 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 \u2297 Y \u2245 Y \u2297 X :=\niso_mk \u27e8(X.2.\u03b2 Y.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [category.assoc],\n  rw [\u2190is_iso.inv_comp_eq, is_iso.iso.inv_hom, \u2190half_braiding.monoidal_assoc,\n    \u2190half_braiding.naturality_assoc, half_braiding.monoidal],\n  simp,\nend\u27e9\n\ninstance braided_category_center : braided_category (center C) :=\n{ braiding := braiding,\n  braiding_naturality' := \u03bb X Y X' Y' f g, begin\n    ext,\n    dsimp,\n    rw [\u2190tensor_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\u27e8X, { \u03b2 := \u03bb Y, \u03b2_ X Y,\n  monoidal' := \u03bb U U', begin\n    rw [iso.eq_inv_comp, \u2190category.assoc, \u2190category.assoc, iso.eq_comp_inv,\n      category.assoc, category.assoc],\n    exact hexagon_forward X U U',\n  end }\u27e9\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 := \u03bb X X' f,\n  { f := f,\n    comm' := \u03bb U, braiding_naturality _ _, },\n  \u03b5 :=\n  { f := \ud835\udfd9 _,\n    comm' := \u03bb U, begin\n      dsimp,\n      rw [tensor_id, category.id_comp, tensor_id, category.comp_id, \u2190braiding_right_unitor,\n        category.assoc, iso.hom_inv_id, category.comp_id],\n    end, },\n  \u03bc := \u03bb X Y,\n  { f := \ud835\udfd9 _,\n    comm' := \u03bb U, begin\n      dsimp,\n      rw [tensor_id, tensor_id, category.id_comp, category.comp_id,\n        \u2190iso.inv_comp_eq, \u2190category.assoc, \u2190category.assoc, \u2190iso.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 \u27f6 P`, `snd : X \u27f6 Q`, `inl : P \u27f6 X` and `inr : X \u27f6 Q`,\nsuch that `inl \u226b fst = \ud835\udfd9 P`, `inl \u226b snd = 0`, `inr \u226b fst = 0`, and `inr \u226b snd = \ud835\udfd9 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 \u226b inl + snd \u226b inr = \ud835\udfd9 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 `\u03c0 j : X \u27f6 F j` and `\u03b9 j : F j \u27f6 X` for each `j`,\nsuch that `\u03b9 j \u226b \u03c0 j'` is the identity when `j = j'` and zero otherwise.\n\nIn a preadditive category,\n* any `biproduct` satisfies `total : \u2211 j : J, biproduct.\u03c0 f j \u226b biproduct.\u03b9 f j = \ud835\udfd9 (\u2a01 f)`\n* any `product` is a `biproduct`\n* any `coproduct` is a `biproduct`\n\n## Notation\nAs `\u2295` is already taken for the sum of types, we introduce the notation `X \u229e Y` for\na binary biproduct. We introduce `\u2a01 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 `\u03c0 j : X \u27f6 F j` and `\u03b9 j : F j \u27f6 X` for each `j`,\n* such that `\u03b9 j \u226b \u03c0 j'` is the identity when `j = j'` and zero otherwise.\n-/\n@[nolint has_inhabited_instance]\nstructure bicone (F : J \u2192 C) :=\n(X : C)\n(\u03c0 : \u03a0 j, X \u27f6 F j)\n(\u03b9 : \u03a0 j, F j \u27f6 X)\n(\u03b9_\u03c0 : \u2200 j j', \u03b9 j \u226b \u03c0 j' = if h : j = j' then eq_to_hom (congr_arg F h) else 0)\n\n@[simp] lemma bicone_\u03b9_\u03c0_self {F : J \u2192 C} (B : bicone F) (j : J) : B.\u03b9 j \u226b B.\u03c0 j = \ud835\udfd9 (F j) :=\nby simpa using B.\u03b9_\u03c0 j j\n\n@[simp] lemma bicone_\u03b9_\u03c0_ne {F : J \u2192 C} (B : bicone F) {j j' : J} (h : j \u2260 j') :\n  B.\u03b9 j \u226b B.\u03c0 j' = 0 :=\nby simpa [h] using B.\u03b9_\u03c0 j j'\n\nvariables {F : J \u2192 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  \u03c0 := { app := \u03bb j, B.\u03c0 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  \u03b9 := { app := \u03bb j, B.\u03b9 j }, }\n\nend bicone\n\n/--\nA bicone over `F : J \u2192 C`, which is both a limit cone and a colimit cocone.\n-/\n@[nolint has_inhabited_instance]\nstructure limit_bicone (F : J \u2192 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 \u2192 C) : Prop :=\nmk' :: (exists_biproduct : nonempty (limit_bicone F))\n\nlemma has_biproduct.mk {F : J \u2192 C} (d : limit_bicone F) : has_biproduct F :=\n\u27e8nonempty.intro d\u27e9\n\n/-- Use the axiom of choice to extract explicit `biproduct_data F` from `has_biproduct F`. -/\ndef get_biproduct_data (F : J \u2192 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 \u2192 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 \u2192 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 \u2192 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 \u2192 C`.\n-/\nclass has_biproducts_of_shape : Prop :=\n(has_biproduct : \u03a0 F : J \u2192 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 : \u03a0 (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 := \u03bb J _ _, \u27e8\u03bb F, by exactI has_limit_of_iso discrete.nat_iso_functor.symm\u27e9 }\n\n@[priority 100]\ninstance has_finite_coproducts_of_has_finite_biproducts [has_finite_biproducts C] :\n  has_finite_coproducts C :=\n{ out := \u03bb J _ _, \u27e8\u03bb F, by exactI has_colimit_of_iso discrete.nat_iso_functor\u27e9 }\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 \u2192 C) [has_biproduct F] :\n  limits.pi_obj F \u2245 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 \u2192 C) [has_biproduct f] : C :=\n(biproduct.bicone f).X\n\nnotation `\u2a01 ` f:20 := biproduct f\n\n/-- The projection onto a summand of a biproduct. -/\nabbreviation biproduct.\u03c0 (f : J \u2192 C) [has_biproduct f] (b : J) : \u2a01 f \u27f6 f b :=\n(biproduct.bicone f).\u03c0 b\n\n@[simp]\nlemma biproduct.bicone_\u03c0 (f : J \u2192 C) [has_biproduct f] (b : J) :\n  (biproduct.bicone f).\u03c0 b = biproduct.\u03c0 f b := rfl\n\n/-- The inclusion into a summand of a biproduct. -/\nabbreviation biproduct.\u03b9 (f : J \u2192 C) [has_biproduct f] (b : J) : f b \u27f6 \u2a01 f :=\n(biproduct.bicone f).\u03b9 b\n\n@[simp]\nlemma biproduct.bicone_\u03b9 (f : J \u2192 C) [has_biproduct f] (b : J) :\n  (biproduct.bicone f).\u03b9 b = biproduct.\u03b9 f b := rfl\n\n@[reassoc]\nlemma biproduct.\u03b9_\u03c0 (f : J \u2192 C) [has_biproduct f] (j j' : J) :\n  biproduct.\u03b9 f j \u226b biproduct.\u03c0 f j' = if h : j = j' then eq_to_hom (congr_arg f h) else 0 :=\n(biproduct.bicone f).\u03b9_\u03c0 j j'\n\n@[simp,reassoc]\nlemma biproduct.\u03b9_\u03c0_self (f : J \u2192 C) [has_biproduct f] (j : J) :\n  biproduct.\u03b9 f j \u226b biproduct.\u03c0 f j = \ud835\udfd9 _ :=\nby simp [biproduct.\u03b9_\u03c0]\n\n@[simp,reassoc]\nlemma biproduct.\u03b9_\u03c0_ne (f : J \u2192 C) [has_biproduct f] {j j' : J} (h : j \u2260 j') :\n  biproduct.\u03b9 f j \u226b biproduct.\u03c0 f j' = 0 :=\nby simp [biproduct.\u03b9_\u03c0, h]\n\n/-- Given a collection of maps into the summands, we obtain a map into the biproduct. -/\nabbreviation biproduct.lift\n  {f : J \u2192 C} [has_biproduct f] {P : C} (p : \u03a0 b, P \u27f6 f b) : P \u27f6 \u2a01 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 \u2192 C} [has_biproduct f] {P : C} (p : \u03a0 b, f b \u27f6 P) : \u2a01 f \u27f6 P :=\n(biproduct.is_colimit f).desc (cofan.mk P p)\n\n@[simp, reassoc]\nlemma biproduct.lift_\u03c0 {f : J \u2192 C} [has_biproduct f] {P : C} (p : \u03a0 b, P \u27f6 f b) (j : J) :\n  biproduct.lift p \u226b biproduct.\u03c0 f j = p j :=\n(biproduct.is_limit f).fac _ _\n\n@[simp, reassoc]\nlemma biproduct.\u03b9_desc {f : J \u2192 C} [has_biproduct f] {P : C} (p : \u03a0 b, f b \u27f6 P) (j : J) :\n  biproduct.\u03b9 f j \u226b 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 \u2192 C} [has_finite_biproducts C]\n  (p : \u03a0 b, f b \u27f6 g b) : \u2a01 f \u27f6 \u2a01 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 \u2192 C} [has_finite_biproducts C]\n  (p : \u03a0 b, f b \u27f6 g b) : \u2a01 f \u27f6 \u2a01 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 \u2192 C} [has_biproduct f]\n  {Z : C} (g h : Z \u27f6 \u2a01 f)\n  (w : \u2200 j, g \u226b biproduct.\u03c0 f j = h \u226b biproduct.\u03c0 f j) : g = h :=\n(biproduct.is_limit f).hom_ext w\n\n@[ext] lemma biproduct.hom_ext' {f : J \u2192 C} [has_biproduct f]\n  {Z : C} (g h : \u2a01 f \u27f6 Z)\n  (w : \u2200 j, biproduct.\u03b9 f j \u226b g = biproduct.\u03b9 f j \u226b h) : g = h :=\n(biproduct.is_colimit f).hom_ext w\n\nlemma biproduct.map_eq_map' [fintype J] {f g : J \u2192 C} [has_finite_biproducts C]\n  (p : \u03a0 b, f b \u27f6 g b) : biproduct.map p = biproduct.map' p :=\nbegin\n  ext j j',\n  simp only [discrete.nat_trans_app, limits.is_colimit.\u03b9_map, limits.is_limit.map_\u03c0, category.assoc,\n    \u2190bicone.to_cone_\u03c0_app, \u2190biproduct.bicone_\u03c0, \u2190bicone.to_cocone_\u03b9_app, \u2190biproduct.bicone_\u03b9],\n  simp only [biproduct.bicone_\u03b9, biproduct.bicone_\u03c0, bicone.to_cocone_\u03b9_app, bicone.to_cone_\u03c0_app],\n  rw [biproduct.\u03b9_\u03c0_assoc, biproduct.\u03b9_\u03c0],\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_\u03c0 [fintype J] {f g : J \u2192 C} [has_finite_biproducts C]\n  (p : \u03a0 j, f j \u27f6 g j) (j : J) :\n  biproduct.map p \u226b biproduct.\u03c0 g j = biproduct.\u03c0 f j \u226b p j :=\nlimits.is_limit.map_\u03c0 _ _ _ _\n\n@[simp, reassoc]\nlemma biproduct.\u03b9_map [fintype J] {f g : J \u2192 C} [has_finite_biproducts C]\n  (p : \u03a0 j, f j \u27f6 g j) (j : J) :\n  biproduct.\u03b9 f j \u226b biproduct.map p = p j \u226b biproduct.\u03b9 g j :=\nbegin\n  rw biproduct.map_eq_map',\n  convert limits.is_colimit.\u03b9_map _ _ _ _; refl\nend\n\n@[simp, reassoc]\nlemma biproduct.map_desc [fintype J] {f g : J \u2192 C} [has_finite_biproducts C]\n  (p : \u03a0 j, f j \u27f6 g j) {P : C} (k : \u03a0 j, g j \u27f6 P) :\n  biproduct.map p \u226b biproduct.desc k = biproduct.desc (\u03bb j, p j \u226b k j) :=\nby { ext, simp, }\n\n@[simp, reassoc]\nlemma biproduct.lift_map [fintype J] {f g : J \u2192 C} [has_finite_biproducts C]\n  {P : C} (k : \u03a0 j, P \u27f6 f j) (p : \u03a0 j, f j \u27f6 g j)  :\n  biproduct.lift k \u226b biproduct.map p = biproduct.lift (\u03bb j, k j \u226b 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 \u2192 C} [has_finite_biproducts C]\n  (p : \u03a0 b, f b \u2245 g b) : \u2a01 f \u2245 \u2a01 g :=\n{ hom := biproduct.map (\u03bb b, (p b).hom),\n  inv := biproduct.map (\u03bb b, (p b).inv), }\n\nsection\nvariables [fintype J] {K : Type v} [fintype K] [decidable_eq K] {f : J \u2192 C} {g : K \u2192 C}\n  [has_finite_biproducts C]\n\n/--\nConvert a (dependently typed) matrix to a morphism of biproducts.\n-/\ndef biproduct.matrix (m : \u03a0 j k, f j \u27f6 g k) : \u2a01 f \u27f6 \u2a01 g :=\nbiproduct.desc (\u03bb j, biproduct.lift (\u03bb k, m j k))\n\n@[simp, reassoc]\nlemma biproduct.matrix_\u03c0 (m : \u03a0 j k, f j \u27f6 g k) (k : K) :\n  biproduct.matrix m \u226b biproduct.\u03c0 g k = biproduct.desc (\u03bb j, m j k) :=\nby { ext, simp [biproduct.matrix], }\n\n@[simp, reassoc]\nlemma biproduct.\u03b9_matrix (m : \u03a0 j k, f j \u27f6 g k) (j : J) :\n  biproduct.\u03b9 f j \u226b biproduct.matrix m = biproduct.lift (\u03bb 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 : \u2a01 f \u27f6 \u2a01 g) (j : J) (k : K) : f j \u27f6 g k :=\nbiproduct.\u03b9 f j \u226b m \u226b biproduct.\u03c0 g k\n\n@[simp] lemma biproduct.matrix_components (m : \u03a0 j k, f j \u27f6 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 : \u2a01 f \u27f6 \u2a01 g) :\n  biproduct.matrix (\u03bb 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 : (\u2a01 f \u27f6 \u2a01 g) \u2243 (\u03a0 j k, f j \u27f6 g k) :=\n{ to_fun := biproduct.components,\n  inv_fun := biproduct.matrix,\n  left_inv := biproduct.components_matrix,\n  right_inv := \u03bb m, by { ext, apply biproduct.matrix_components } }\n\nend\n\ninstance biproduct.\u03b9_mono (f : J \u2192 C) [has_biproduct f]\n  (b : J) : split_mono (biproduct.\u03b9 f b) :=\n{ retraction := biproduct.desc $\n    \u03bb b', if h : b' = b then eq_to_hom (congr_arg f h) else biproduct.\u03b9 f b' \u226b biproduct.\u03c0 f b }\n\ninstance biproduct.\u03c0_epi (f : J \u2192 C) [has_biproduct f]\n  (b : J) : split_epi (biproduct.\u03c0 f b) :=\n{ section_ := biproduct.lift $\n    \u03bb b', if h : b = b' then eq_to_hom (congr_arg f h) else biproduct.\u03b9 f b \u226b biproduct.\u03c0 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 \u226b fst = \ud835\udfd9 P`, `inl \u226b snd = 0`, `inr \u226b fst = 0`, and `inr \u226b snd = \ud835\udfd9 Q`\n-/\n@[nolint has_inhabited_instance]\nstructure binary_bicone (P Q : C) :=\n(X : C)\n(fst : X \u27f6 P)\n(snd : X \u27f6 Q)\n(inl : P \u27f6 X)\n(inr : Q \u27f6 X)\n(inl_fst' : inl \u226b fst = \ud835\udfd9 P . obviously)\n(inl_snd' : inl \u226b snd = 0 . obviously)\n(inr_fst' : inr \u226b fst = 0 . obviously)\n(inr_snd' : inr \u226b snd = \ud835\udfd9 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_\u03c0_app_left (c : binary_bicone P Q) :\n  c.to_cone.\u03c0.app (walking_pair.left) = c.fst := rfl\n@[simp]\nlemma to_cone_\u03c0_app_right (c : binary_bicone P Q) :\n  c.to_cone.\u03c0.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_\u03b9_app_left (c : binary_bicone P Q) :\n  c.to_cocone.\u03b9.app (walking_pair.left) = c.inl := rfl\n@[simp]\nlemma to_cocone_\u03b9_app_right (c : binary_bicone P Q) :\n  c.to_cocone.\u03b9.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.\u03c0 walking_pair.left,\n  snd := b.\u03c0 walking_pair.right,\n  inl := b.\u03b9 walking_pair.left,\n  inr := b.\u03b9 walking_pair.right,\n  inl_fst' := by { simp [bicone.\u03b9_\u03c0], refl, },\n  inr_fst' := by simp [bicone.\u03b9_\u03c0],\n  inl_snd' := by simp [bicone.\u03b9_\u03c0],\n  inr_snd' := by { simp [bicone.\u03b9_\u03c0], 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 := \u03bb s, c.lift s,\n   fac' := \u03bb s j, by { cases j; erw c.fac, },\n   uniq' := \u03bb s m w,\n   begin\n     apply c.uniq s,\n     rintro (\u27e8\u27e9|\u27e8\u27e9),\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 := \u03bb s, c.desc s,\n   fac' := \u03bb s j, by { cases j; erw c.fac, },\n   uniq' := \u03bb s m w,\n   begin\n     apply c.uniq s,\n     rintro (\u27e8\u27e9|\u27e8\u27e9),\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\u27e8nonempty.intro d\u27e9\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 : \u03a0 (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 := \u03bb 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 \u27e8_, binary_biproduct.is_limit P Q\u27e9\n\ninstance has_binary_biproduct.has_colimit_pair [has_binary_biproduct P Q] :\n  has_colimit (pair P Q) :=\nhas_colimit.mk \u27e8_, binary_biproduct.is_colimit P Q\u27e9\n\n@[priority 100]\ninstance has_binary_products_of_has_binary_biproducts [has_binary_biproducts C] :\n  has_binary_products C :=\n{ has_limit := \u03bb 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 := \u03bb 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 \u2245 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 ` \u229e `: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 \u229e Y \u27f6 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 \u229e Y \u27f6 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 \u27f6 X \u229e 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 \u27f6 X \u229e 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 \u27f6 X \u229e Y) \u226b (biprod.fst : X \u229e Y \u27f6 X) = \ud835\udfd9 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 \u27f6 X \u229e Y) \u226b (biprod.snd : X \u229e Y \u27f6 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 \u27f6 X \u229e Y) \u226b (biprod.fst : X \u229e Y \u27f6 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 \u27f6 X \u229e Y) \u226b (biprod.snd : X \u229e Y \u27f6 Y) = \ud835\udfd9 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 \u27f6 X) (g : W \u27f6 Y) :\n  W \u27f6 X \u229e 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 \u27f6 W) (g : Y \u27f6 W) :\n  X \u229e Y \u27f6 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 \u27f6 X) (g : W \u27f6 Y) :\n  biprod.lift f g \u226b 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 \u27f6 X) (g : W \u27f6 Y) :\n  biprod.lift f g \u226b 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 \u27f6 W) (g : Y \u27f6 W) :\n  biprod.inl \u226b 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 \u27f6 W) (g : Y \u27f6 W) :\n  biprod.inr \u226b 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 \u27f6 X)\n  (g : W \u27f6 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 \u27f6 X)\n  (g : W \u27f6 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 \u27f6 W) (g : Y \u27f6 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 \u27f6 W) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 Z) : W \u229e X \u27f6 Y \u229e 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 \u27f6 Y) (g : X \u27f6 Z) : W \u229e X \u27f6 Y \u229e 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 \u27f6 X \u229e Y)\n  (h\u2080 : f \u226b biprod.fst = g \u226b biprod.fst) (h\u2081 : f \u226b biprod.snd = g \u226b biprod.snd) : f = g :=\nbinary_fan.is_limit.hom_ext (binary_biproduct.is_limit X Y) h\u2080 h\u2081\n\n\n@[ext] lemma biprod.hom_ext' {X Y Z : C} [has_binary_biproduct X Y] (f g : X \u229e Y \u27f6 Z)\n  (h\u2080 : biprod.inl \u226b f = biprod.inl \u226b g) (h\u2081 : biprod.inr \u226b f = biprod.inr \u226b g) : f = g :=\nbinary_cofan.is_colimit.hom_ext (binary_biproduct.is_colimit X Y) h\u2080 h\u2081\n\nlemma biprod.map_eq_map' {W X Y Z : C} [has_binary_biproduct W X] [has_binary_biproduct Y Z]\n  (f : W \u27f6 Y) (g : X \u27f6 Z) : biprod.map f g = biprod.map' f g :=\nbegin\n  ext,\n  { simp only [map_pair_left, is_colimit.\u03b9_map, is_limit.map_\u03c0, biprod.inl_fst_assoc,\n    category.assoc, \u2190binary_bicone.to_cone_\u03c0_app_left, \u2190binary_biproduct.bicone_fst,\n    \u2190binary_bicone.to_cocone_\u03b9_app_left, \u2190binary_biproduct.bicone_inl],\n    simp },\n  { simp only [map_pair_left, is_colimit.\u03b9_map, is_limit.map_\u03c0, zero_comp,\n      biprod.inl_snd_assoc, category.assoc,\n      \u2190binary_bicone.to_cone_\u03c0_app_right, \u2190binary_biproduct.bicone_snd,\n      \u2190binary_bicone.to_cocone_\u03b9_app_left, \u2190binary_biproduct.bicone_inl],\n    simp },\n  { simp only [map_pair_right, biprod.inr_fst_assoc, is_colimit.\u03b9_map, is_limit.map_\u03c0,\n      zero_comp, category.assoc,\n      \u2190binary_bicone.to_cone_\u03c0_app_left, \u2190binary_biproduct.bicone_fst,\n      \u2190binary_bicone.to_cocone_\u03b9_app_right, \u2190binary_biproduct.bicone_inr],\n    simp },\n  { simp only [map_pair_right, is_colimit.\u03b9_map, is_limit.map_\u03c0, biprod.inr_snd_assoc,\n      category.assoc, \u2190binary_bicone.to_cone_\u03c0_app_right, \u2190binary_biproduct.bicone_snd,\n      \u2190binary_bicone.to_cocone_\u03b9_app_right, \u2190binary_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 \u27f6 X \u229e Y) :=\n{ retraction := biprod.desc (\ud835\udfd9 X) (biprod.inr \u226b biprod.fst) }\n\ninstance biprod.inr_mono {X Y : C} [has_binary_biproduct X Y] :\n  split_mono (biprod.inr : Y \u27f6 X \u229e Y) :=\n{ retraction := biprod.desc (biprod.inl \u226b biprod.snd) (\ud835\udfd9 Y)}\n\ninstance biprod.fst_epi {X Y : C} [has_binary_biproduct X Y] :\n  split_epi (biprod.fst : X \u229e Y \u27f6 X) :=\n{ section_ := biprod.lift (\ud835\udfd9 X) (biprod.inl \u226b biprod.snd) }\n\ninstance biprod.snd_epi {X Y : C} [has_binary_biproduct X Y] :\n  split_epi (biprod.snd : X \u229e Y \u27f6 Y) :=\n{ section_ := biprod.lift (biprod.inr \u226b biprod.fst) (\ud835\udfd9 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 \u27f6 Y) (g : X \u27f6 Z) :\n  biprod.map f g \u226b biprod.fst = biprod.fst \u226b f :=\nis_limit.map_\u03c0 _ _ _ 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 \u27f6 Y) (g : X \u27f6 Z) :\n  biprod.map f g \u226b biprod.snd = biprod.snd \u226b g :=\nis_limit.map_\u03c0 _ _ _ 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 \u27f6 Y) (g : X \u27f6 Z) :\n  biprod.inl \u226b biprod.map f g = f \u226b biprod.inl :=\nbegin\n  rw biprod.map_eq_map',\n  exact is_colimit.\u03b9_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 \u27f6 Y) (g : X \u27f6 Z) :\n  biprod.inr \u226b biprod.map f g = g \u226b biprod.inr :=\nbegin\n  rw biprod.map_eq_map',\n  exact is_colimit.\u03b9_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 \u2245 Y) (g : X \u2245 Z) : W \u229e X \u2245 Y \u229e 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 \u229e Q \u2245 Q \u229e 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 \u229e Q \u2245 Q \u229e 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 \u27f6 Y) (g : Z \u27f6 W) :\n  biprod.map f g \u226b (biprod.braiding _ _).hom = (biprod.braiding _ _).hom \u226b biprod.map g f :=\nby tidy\n\n@[reassoc] lemma biprod.braiding_map_braiding {W X Y Z : C} (f : W \u27f6 Y) (g : X \u27f6 Z) :\n  (biprod.braiding X W).hom \u226b biprod.map f g \u226b (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 \u226b biprod.lift biprod.snd biprod.fst = \ud835\udfd9 (P \u229e Q) :=\nby tidy\n\n/-- The braiding isomorphism is symmetric. -/\n@[reassoc] lemma biprod.symmetry (P Q : C) :\n  (biprod.braiding P Q).hom \u226b (biprod.braiding Q P).hom = \ud835\udfd9 _ :=\nby simp\n\nend\n\n-- TODO:\n-- If someone is interested, they could provide the constructions:\n--   has_binary_biproducts \u2194 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 \u2192 C` from\nany bicone `b` for `f` satisfying `total : \u2211 j : J, b.\u03c0 j \u226b b.\u03b9 j = \ud835\udfd9 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 \u2192 C} (b : bicone f) (total : \u2211 j : J, b.\u03c0 j \u226b b.\u03b9 j = \ud835\udfd9 b.X) :\n  has_biproduct f :=\nhas_biproduct.mk\n{ bicone := b,\n  is_limit :=\n  { lift := \u03bb s, \u2211 j, s.\u03c0.app j \u226b b.\u03b9 j,\n    uniq' := \u03bb s m h,\n    begin\n      erw [\u2190category.comp_id m, \u2190total, comp_sum],\n      apply finset.sum_congr rfl,\n      intros j m,\n      erw [reassoc_of (h j)],\n    end,\n    fac' := \u03bb s j,\n    begin\n      simp only [sum_comp, category.assoc, bicone.to_cone_\u03c0_app, b.\u03b9_\u03c0, comp_dite],\n      -- See note [dsimp, simp].\n      dsimp, simp,\n    end },\n  is_colimit :=\n  { desc := \u03bb s, \u2211 j, b.\u03c0 j \u226b s.\u03b9.app j,\n    uniq' := \u03bb s m h,\n    begin\n      erw [\u2190category.id_comp m, \u2190total, sum_comp],\n            apply finset.sum_congr rfl,\n      intros j m,\n      erw [category.assoc, h],\n    end,\n    fac' := \u03bb s j,\n    begin\n      simp only [comp_sum, \u2190category.assoc, bicone.to_cocone_\u03b9_app, b.\u03b9_\u03c0, dite_comp],\n      dsimp, simp,\n    end } }\n\n/-- In a preadditive category, if the product over `f : J \u2192 C` exists,\n    then the biproduct over `f` exists. -/\nlemma has_biproduct.of_has_product (f : J \u2192 C) [has_product f] :\n  has_biproduct f :=\nhas_biproduct_of_total\n{ X := pi_obj f,\n  \u03c0 := limits.pi.\u03c0 f,\n  \u03b9 := \u03bb j, pi.lift (\u03bb j', if h : j = j' then eq_to_hom (congr_arg f h) else 0),\n  \u03b9_\u03c0 := \u03bb j j', by simp, }\n(by { ext, simp [sum_comp, comp_dite] })\n\n/-- In a preadditive category, if the coproduct over `f : J \u2192 C` exists,\n    then the biproduct over `f` exists. -/\nlemma has_biproduct.of_has_coproduct (f : J \u2192 C) [has_coproduct f] :\n  has_biproduct f :=\nhas_biproduct_of_total\n{ X := sigma_obj f,\n  \u03c0 := \u03bb j, sigma.desc (\u03bb j', if h : j' = j then eq_to_hom (congr_arg f h) else 0),\n  \u03b9 := limits.sigma.\u03b9 f,\n  \u03b9_\u03c0 := \u03bb j j', by simp, }\nbegin\n  ext,\n  simp only [comp_sum, limits.colimit.\u03b9_desc_assoc, eq_self_iff_true,\n    limits.colimit.\u03b9_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\u27e8\u03bb J _ _, { has_biproduct := \u03bb F, by exactI has_biproduct.of_has_product _ }\u27e9\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\u27e8\u03bb J _ _, { has_biproduct := \u03bb F, by exactI has_biproduct.of_has_coproduct _ }\u27e9\n\nsection\nvariables {f : J \u2192 C} [has_biproduct f]\n\n/--\nIn any preadditive category, any biproduct satsifies\n`\u2211 j : J, biproduct.\u03c0 f j \u226b biproduct.\u03b9 f j = \ud835\udfd9 (\u2a01 f)`\n-/\n@[simp] lemma biproduct.total : \u2211 j : J, biproduct.\u03c0 f j \u226b biproduct.\u03b9 f j = \ud835\udfd9 (\u2a01 f) :=\nbegin\n  ext j j',\n  simp [comp_sum, sum_comp, biproduct.\u03b9_\u03c0, comp_dite, dite_comp],\nend\n\nlemma biproduct.lift_eq {T : C} {g : \u03a0 j, T \u27f6 f j} :\n  biproduct.lift g = \u2211 j, g j \u226b biproduct.\u03b9 f j :=\nbegin\n  ext j,\n  simp [sum_comp, biproduct.\u03b9_\u03c0, comp_dite],\nend\n\nlemma biproduct.desc_eq {T : C} {g : \u03a0 j, f j \u27f6 T} :\n  biproduct.desc g = \u2211 j, biproduct.\u03c0 f j \u226b g j :=\nbegin\n  ext j,\n  simp [comp_sum, biproduct.\u03b9_\u03c0_assoc, dite_comp],\nend\n\n@[simp, reassoc] lemma biproduct.lift_desc {T U : C} {g : \u03a0 j, T \u27f6 f j} {h : \u03a0 j, f j \u27f6 U} :\n  biproduct.lift g \u226b biproduct.desc h = \u2211 j : J, g j \u226b h j :=\nby simp [biproduct.lift_eq, biproduct.desc_eq, comp_sum, sum_comp, biproduct.\u03b9_\u03c0_assoc,\n  comp_dite, dite_comp]\n\nlemma biproduct.map_eq [has_finite_biproducts C] {f g : J \u2192 C} {h : \u03a0 j, f j \u27f6 g j} :\n  biproduct.map h = \u2211 j : J, biproduct.\u03c0 f j \u226b h j \u226b biproduct.\u03b9 g j :=\nbegin\n  ext,\n  simp [biproduct.\u03b9_\u03c0, biproduct.\u03b9_\u03c0_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 \u2192 C} {g : K \u2192 C} (m : \u03a0 j k, f j \u27f6 g k) {P} (x : \u03a0 k, g k \u27f6 P) :\n  biproduct.matrix m \u226b biproduct.desc x = biproduct.desc (\u03bb j, \u2211 k, m j k \u226b 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 \u2192 C} {g : K \u2192 C} {P} (x : \u03a0 j, P \u27f6 f j) (m : \u03a0 j k, f j \u27f6 g k)  :\n  biproduct.lift x \u226b biproduct.matrix m = biproduct.lift (\u03bb k, \u2211 j, x j \u226b 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 \u2192 C} {g : K \u2192 C} {h : K \u2192 C} (m : \u03a0 j k, f j \u27f6 g k) (n : \u03a0 k, g k \u27f6 h k) :\n  biproduct.matrix m \u226b biproduct.map n = biproduct.matrix (\u03bb j k, m j k \u226b 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 \u2192 C} {g : J \u2192 C} {h : K \u2192 C} (m : \u03a0 k, f k \u27f6 g k) (n : \u03a0 j k, g j \u27f6 h k) :\n  biproduct.map m \u226b biproduct.matrix n = biproduct.matrix (\u03bb j k, m j \u226b 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 \u226b b.inl + b.snd \u226b b.inr = \ud835\udfd9 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 \u226b b.inl + b.snd \u226b b.inr = \ud835\udfd9 b.X) :\n  has_binary_biproduct X Y :=\nhas_binary_biproduct.mk\n{ bicone := b,\n  is_limit :=\n  { lift := \u03bb s, binary_fan.fst s \u226b b.inl +\n      binary_fan.snd s \u226b b.inr,\n    uniq' := \u03bb s m h, by erw [\u2190category.comp_id m, \u2190total,\n      comp_add, reassoc_of (h walking_pair.left), reassoc_of (h walking_pair.right)],\n    fac' := \u03bb s j, by cases j; simp, },\n  is_colimit :=\n  { desc := \u03bb s, b.fst \u226b binary_cofan.inl s +\n      b.snd \u226b binary_cofan.inr s,\n    uniq' := \u03bb s m h, by erw [\u2190category.id_comp m, \u2190total,\n      add_comp, category.assoc, category.assoc, h walking_pair.left, h walking_pair.right],\n    fac' := \u03bb 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 \u2a2f Y,\n  fst := category_theory.limits.prod.fst,\n  snd := category_theory.limits.prod.snd,\n  inl := prod.lift (\ud835\udfd9 X) 0,\n  inr := prod.lift 0 (\ud835\udfd9 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 := \u03bb 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 \u2a3f Y,\n  fst := coprod.desc (\ud835\udfd9 X) 0,\n  snd := coprod.desc 0 (\ud835\udfd9 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 := \u03bb 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 \u226b biprod.inl + biprod.snd \u226b biprod.inr = \ud835\udfd9 (X \u229e Y)`.\n-/\n@[simp] lemma biprod.total : biprod.fst \u226b biprod.inl + biprod.snd \u226b biprod.inr = \ud835\udfd9 (X \u229e Y) :=\nbegin\n  ext; simp [add_comp],\nend\n\nlemma biprod.lift_eq {T : C} {f : T \u27f6 X} {g : T \u27f6 Y} :\n  biprod.lift f g = f \u226b biprod.inl + g \u226b biprod.inr :=\nbegin\n  ext; simp [add_comp],\nend\n\nlemma biprod.desc_eq {T : C} {f : X \u27f6 T} {g : Y \u27f6 T} :\n  biprod.desc f g = biprod.fst \u226b f + biprod.snd \u226b g :=\nbegin\n  ext; simp [add_comp],\nend\n\n@[simp, reassoc] lemma biprod.lift_desc {T U : C} {f : T \u27f6 X} {g : T \u27f6 Y} {h : X \u27f6 U} {i : Y \u27f6 U} :\n  biprod.lift f g \u226b biprod.desc h i = f \u226b h + g \u226b 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 \u27f6 Y} {g : X \u27f6 Z} :\n  biprod.map f g = biprod.fst \u226b f \u226b biprod.inl + biprod.snd \u226b g \u226b 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u2260 1`. In vector spaces, this is equivalent to positive dimension. -/\nclass nontrivial (\u03b1 : Type u_3) \nwhere\n  exists_pair_ne : \u2203 (x : \u03b1), \u2203 (y : \u03b1), x \u2260 y\n\ntheorem nontrivial_iff {\u03b1 : Type u_1} : nontrivial \u03b1 \u2194 \u2203 (x : \u03b1), \u2203 (y : \u03b1), x \u2260 y :=\n  { mp := fun (h : nontrivial \u03b1) => nontrivial.exists_pair_ne,\n    mpr := fun (h : \u2203 (x : \u03b1), \u2203 (y : \u03b1), x \u2260 y) => nontrivial.mk h }\n\ntheorem exists_pair_ne (\u03b1 : Type u_1) [nontrivial \u03b1] : \u2203 (x : \u03b1), \u2203 (y : \u03b1), x \u2260 y :=\n  nontrivial.exists_pair_ne\n\ntheorem exists_ne {\u03b1 : Type u_1} [nontrivial \u03b1] (x : \u03b1) : \u2203 (y : \u03b1), y \u2260 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 {\u03b1 : Type u_1} (x : \u03b1) (y : \u03b1) (h : x \u2260 y) : nontrivial \u03b1 :=\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 {\u03b1 : Type u_1} [preorder \u03b1] (x : \u03b1) (y : \u03b1) (h : x < y) : nontrivial \u03b1 :=\n  nontrivial.mk (Exists.intro x (Exists.intro y (ne_of_lt h)))\n\nprotected instance nontrivial.to_nonempty {\u03b1 : Type u_1} [nontrivial \u03b1] : Nonempty \u03b1 :=\n  sorry\n\n/-- An inhabited type is either nontrivial, or has a unique element. -/\ndef nontrivial_psum_unique (\u03b1 : Type u_1) [Inhabited \u03b1] : psum (nontrivial \u03b1) (unique \u03b1) :=\n  dite (nontrivial \u03b1) (fun (h : nontrivial \u03b1) => psum.inl h)\n    fun (h : \u00acnontrivial \u03b1) => psum.inr (unique.mk { default := Inhabited.default } sorry)\n\ntheorem subsingleton_iff {\u03b1 : Type u_1} : subsingleton \u03b1 \u2194 \u2200 (x y : \u03b1), x = y :=\n  { mp := fun (h : subsingleton \u03b1) => subsingleton.elim, mpr := fun (h : \u2200 (x y : \u03b1), x = y) => subsingleton.intro h }\n\ntheorem not_nontrivial_iff_subsingleton {\u03b1 : Type u_1} : \u00acnontrivial \u03b1 \u2194 subsingleton \u03b1 := sorry\n\ntheorem not_subsingleton (\u03b1 : Type u_1) [h : nontrivial \u03b1] : \u00acsubsingleton \u03b1 := sorry\n\n/-- A type is either a subsingleton or nontrivial. -/\ntheorem subsingleton_or_nontrivial (\u03b1 : Type u_1) : subsingleton \u03b1 \u2228 nontrivial \u03b1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (subsingleton \u03b1 \u2228 nontrivial \u03b1)) (Eq.symm (propext not_nontrivial_iff_subsingleton))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u00acnontrivial \u03b1 \u2228 nontrivial \u03b1)) (propext (or_comm (\u00acnontrivial \u03b1) (nontrivial \u03b1)))))\n      (classical.em (nontrivial \u03b1)))\n\ntheorem false_of_nontrivial_of_subsingleton (\u03b1 : Type u_1) [nontrivial \u03b1] [subsingleton \u03b1] : False := sorry\n\nprotected instance option.nontrivial {\u03b1 : Type u_1} [Nonempty \u03b1] : nontrivial (Option \u03b1) :=\n  nonempty.elim_to_inhabited\n    fun (inst : Inhabited \u03b1) =>\n      nontrivial.mk\n        (Exists.intro none\n          (Exists.intro (some Inhabited.default)\n            (id (id fun (\u1fb0 : none = some Inhabited.default) => option.no_confusion \u1fb0))))\n\n/-- Pushforward a `nontrivial` instance along an injective function. -/\nprotected theorem function.injective.nontrivial {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b1] {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) : nontrivial \u03b2 := sorry\n\n/-- Pullback a `nontrivial` instance along a surjective function. -/\nprotected theorem function.surjective.nontrivial {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b2] {f : \u03b1 \u2192 \u03b2} (hf : function.surjective f) : nontrivial \u03b1 := 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b1] {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) (y : \u03b2) : \u2203 (x : \u03b1), f x \u2260 y := sorry\n\nprotected instance nontrivial_prod_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} [Nonempty \u03b1] [nontrivial \u03b2] : nontrivial (\u03b1 \u00d7 \u03b2) :=\n  function.surjective.nontrivial prod.snd_surjective\n\nprotected instance nontrivial_prod_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} [nontrivial \u03b1] [Nonempty \u03b2] : nontrivial (\u03b1 \u00d7 \u03b2) :=\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 \u2192 Type u_4} (i' : I) [inst : \u2200 (i : I), Nonempty (f i)] [nontrivial (f i')] : nontrivial ((i : I) \u2192 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 \u2192 Type u_4} [Inhabited I] [inst : \u2200 (i : I), Nonempty (f i)] [nontrivial (f Inhabited.default)] : nontrivial ((i : I) \u2192 f i) :=\n  nontrivial_at Inhabited.default\n\nend pi\n\n\nprotected instance function.nontrivial {\u03b1 : Type u_1} {\u03b2 : Type u_2} [h : Nonempty \u03b1] [nontrivial \u03b2] : nontrivial (\u03b1 \u2192 \u03b2) :=\n  nonempty.elim h fun (a : \u03b1) => pi.nontrivial_at a\n\nprotected theorem subsingleton.le {\u03b1 : Type u_1} [preorder \u03b1] [subsingleton \u03b1] (x : \u03b1) (y : \u03b1) : x \u2264 y :=\n  le_of_eq (subsingleton.elim x y)\n\nnamespace tactic\n\n\n/--\nTries to generate a `nontrivial \u03b1` instance by performing case analysis on\n`subsingleton_or_nontrivial \u03b1`,\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 \u03b1` 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 \u03b1` hypothesis.\n\nThe tactic first looks for an instance using `apply_instance`.\n\nIf the goal is an (in)equality, the type `\u03b1` is inferred from the goal.\nOtherwise, the type needs to be specified in the tactic invocation, as `nontriviality \u03b1`.\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 \u03b1 \u2228 nontrivial \u03b1`, 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 \u03b1 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 : \u2115) \u2223 4 :=\nbegin\n  nontriviality R, -- there is now a `nontrivial R` hypothesis available.\n  dec_trivial\nend\n```\n\n```\ndef myeq {\u03b1 : Type} (a b : \u03b1) : Prop := a = b\n\nexample {\u03b1 : Type} (a b : \u03b1) (h : a = b) : myeq a b :=\nbegin\n  success_if_fail { nontriviality \u03b1 }, -- Fails\n  nontriviality \u03b1 using [myeq], -- There is now a `nontrivial \u03b1` 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\u2081, ..., l\u2099]` is a list whose `i`-th element comes from the `i`-th list.\n-/\n\n\nopen nat function\n\nnamespace list\nvariables {\u03b1 \u03b2 : Type*}\n\ntheorem mem_sections {L : list (list \u03b1)} {f} : f \u2208 sections L \u2194 forall\u2082 (\u2208) f L :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n  { induction L generalizing f, {cases mem_singleton.1 h, exact forall\u2082.nil},\n    simp only [sections, bind_eq_bind, mem_bind, mem_map] at h,\n    rcases h with \u27e8_, _, _, _, rfl\u27e9,\n    simp only [*, forall\u2082_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 \u27e8_, fs, _, al, rfl, rfl\u27e9 }\nend\n\ntheorem mem_sections_length {L : list (list \u03b1)} {f} (h : f \u2208 sections L) : length f = length L :=\nforall\u2082_length_eq (mem_sections.1 h)\n\nlemma rel_sections {r : \u03b1 \u2192 \u03b2 \u2192 Prop} :\n  (forall\u2082 (forall\u2082 r) \u21d2 forall\u2082 (forall\u2082 r)) sections sections\n| _ _ forall\u2082.nil := forall\u2082.cons forall\u2082.nil forall\u2082.nil\n| _ _ (forall\u2082.cons h\u2080 h\u2081) :=\n  rel_bind (rel_sections h\u2081) (assume _ _ hl, rel_map (assume _ _ ha, forall\u2082.cons ha hl) h\u2080)\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\u2081` and `x\u2082` 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\u2081` and `x\u2082` are not coprime. -/\n@[simp] def is_coprime {R : Type u} [comm_semiring R] (x : R) (y : R) :=\n  \u2203 (a : R), \u2203 (b : R), a * x + b * y = 1\n\ntheorem nat.is_coprime_iff_coprime {m : \u2115} {n : \u2115} : is_coprime \u2191m \u2191n \u2194 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 \u2194 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 \u2194 is_unit x := sorry\n\ntheorem is_coprime_zero_left {R : Type u} [comm_semiring R] {x : R} : is_coprime 0 x \u2194 is_unit x := sorry\n\ntheorem is_coprime_zero_right {R : Type u} [comm_semiring R] {x : R} : is_coprime x 0 \u2194 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 \u2223 y * z) : x \u2223 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 \u2223 y * z) : x \u2223 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 \u2192 R} {t : finset I} : (\u2200 (i : I), i \u2208 t \u2192 is_coprime (s i) x) \u2192 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 \u2192 R} {t : finset I} : (\u2200 (i : I), i \u2208 t \u2192 is_coprime x (s i)) \u2192 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 \u2223 z) (H2 : y \u2223 z) : x * y \u2223 z := sorry\n\ntheorem finset.prod_dvd_of_coprime {R : Type u} [comm_semiring R] {z : R} {I : Type v} {s : I \u2192 R} {t : finset I} (Hs : set.pairwise_on (\u2191t) (is_coprime on s)) (Hs1 : \u2200 (i : I), i \u2208 t \u2192 s i \u2223 z) : (finset.prod t fun (x : I) => s x) \u2223 z := sorry\n\ntheorem fintype.prod_dvd_of_coprime {R : Type u} [comm_semiring R] {z : R} {I : Type v} {s : I \u2192 R} [fintype I] (Hs : pairwise (is_coprime on s)) (Hs1 : \u2200 (i : I), s i \u2223 z) : (finset.prod finset.univ fun (x : I) => s x) \u2223 z :=\n  finset.prod_dvd_of_coprime (pairwise.pairwise_on Hs \u2191finset.univ) fun (i : I) (_x : i \u2208 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 \u2194 is_coprime x z \u2227 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) \u2194 is_coprime x y \u2227 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 \u2192 R} {t : finset I} : is_coprime (finset.prod t fun (i : I) => s i) x \u2194 \u2200 (i : I), i \u2208 t \u2192 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 \u2192 R} {t : finset I} : is_coprime x (finset.prod t fun (i : I) => s i) \u2194 \u2200 (i : I), i \u2208 t \u2192 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 \u2192 R} {t : finset I} (H1 : is_coprime (finset.prod t fun (i : I) => s i) x) (i : I) (hit : i \u2208 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 \u2192 R} {t : finset I} (H1 : is_coprime x (finset.prod t fun (i : I) => s i)) (i : I) (hit : i \u2208 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 : \u2115} (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 : \u2115) (_x : _x \u2208 finset.range m) => H))\n\ntheorem is_coprime.pow_right {R : Type u} [comm_semiring R] {x : R} {y : R} {n : \u2115} (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 : \u2115) (_x : _x \u2208 finset.range n) => H))\n\ntheorem is_coprime.pow {R : Type u} [comm_semiring R] {x : R} {y : R} {m : \u2115} {n : \u2115} (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 \u2223 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 \u2192+* 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 \u2194 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 \u2194 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) \u2194 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) \u2194 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 \u2194 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 \u2194 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) \u2194 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) \u2194 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 := \u03bb 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 := \u03bb U, Z,\n    map := \u03bb U V f, \ud835\udfd9 Z, } }\n\ninstance [inhabited C] : inhabited (PresheafedSpace C) := \u27e8const (Top.of pempty) default\u27e9\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}) \u27f6 (Y : Top.{v}))\n(c : Y.presheaf \u27f6 base _* X.presheaf)\n\n@[ext] lemma ext {X Y : PresheafedSpace C} (\u03b1 \u03b2 : hom X Y)\n  (w : \u03b1.base = \u03b2.base)\n  (h : \u03b1.c \u226b (whisker_right (eq_to_hom (by rw w)) _) = \u03b2.c) :\n  \u03b1 = \u03b2 :=\nbegin\n  cases \u03b1, cases \u03b2,\n  dsimp [presheaf.pushforward_obj] at *,\n  tidy, -- TODO including `injections` would make tidy work earlier.\nend\n\nlemma hext {X Y : PresheafedSpace C} (\u03b1 \u03b2 : hom X Y)\n  (w : \u03b1.base = \u03b2.base)\n  (h : \u03b1.c == \u03b2.c) :\n  \u03b1 = \u03b2 :=\nby { cases \u03b1, cases \u03b2, congr, exacts [w,h] }\n\n.\n\n/-- The identity morphism of a `PresheafedSpace`. -/\ndef id (X : PresheafedSpace C) : hom X X :=\n{ base := \ud835\udfd9 (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) := \u27e8id X\u27e9\n\n/-- Composition of morphisms of `PresheafedSpace`s. -/\ndef comp {X Y Z : PresheafedSpace C} (\u03b1 : hom X Y) (\u03b2 : hom Y Z) : hom X Z :=\n{ base := \u03b1.base \u226b \u03b2.base,\n  c := \u03b2.c \u226b (presheaf.pushforward _ \u03b2.base).map \u03b1.c }\n\nlemma comp_c {X Y Z : PresheafedSpace C} (\u03b1 : hom X Y) (\u03b2 : hom Y Z) :\n  (comp \u03b1 \u03b2).c = \u03b2.c \u226b (presheaf.pushforward _ \u03b2.base).map \u03b1.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 := \u03bb X Y Z f g, comp f g,\n  id_comp' := \u03bb 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' := \u03bb 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' := \u03bb 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  ((\ud835\udfd9 X) : X \u27f6 X).base = \ud835\udfd9 (X : Top.{v}) := rfl\n\nlemma id_c (X : PresheafedSpace C) :\n  ((\ud835\udfd9 X) : X \u27f6 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  ((\ud835\udfd9 X) : X \u27f6 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 \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).base = f.base \u226b g.base := rfl\n\ninstance (X Y : PresheafedSpace C) : has_coe_to_fun (X \u27f6 Y) (\u03bb _, X \u2192 Y) :=\n\u27e8\u03bb f, f.base\u27e9\n\nlemma coe_to_fun_eq {X Y : PresheafedSpace C} (f : X \u27f6 Y) : (f : X \u2192 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} (\u03b1 : X \u27f6 Y) (\u03b2 : Y \u27f6 Z) (U) :\n  (\u03b1 \u226b \u03b2).c.app U = (\u03b2.c).app U \u226b (\u03b1.c).app (op ((opens.map (\u03b2.base)).obj (unop U))) := rfl\n\nlemma congr_app {X Y : PresheafedSpace C} {\u03b1 \u03b2 : X \u27f6 Y} (h : \u03b1 = \u03b2) (U) :\n  \u03b1.c.app U = \u03b2.c.app U \u226b 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 \u2964 Top :=\n{ obj := \u03bb X, (X : Top.{v}),\n  map := \u03bb 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 \u2245 Y.1) (\u03b1 : H.hom _* X.2 \u2245 Y.2) : X \u2245 Y :=\n{ hom := { base := H.hom, c := \u03b1.inv },\n  inv := { base := H.inv,\n    c := presheaf.to_pushforward_of_iso H \u03b1.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 [\u2190 \u03b1.hom.naturality],\n    have := nat_trans.congr_app (\u03b1.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 \u2245 Y) : Y.2 \u2245 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 (\u03bb f, f \u226b 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 (\u03bb f, f \u226b X.presheaf.map (eq_to_hom h.symm)) this\n  end }\n\ninstance base_is_iso_of_iso (f : X \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 (X : Top.{v})} (h : open_embedding f) : PresheafedSpace C :=\n{ carrier := U,\n  presheaf := h.is_open_map.functor.op \u22d9 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 \u27f6 (X : Top.{v})} (h : open_embedding f) :\n  X.restrict h \u27f6 X :=\n{ base := f,\n  c := { app := \u03bb V, X.presheaf.map (h.is_open_map.adjunction.counit.app V.unop).op,\n    naturality' := \u03bb U V f, show _ = _ \u226b X.presheaf.map _,\n      by { rw [\u2190 map_comp, \u2190 map_comp], refl } } }\n\ninstance of_restrict_mono {U : Top} (X : PresheafedSpace C) (f : U \u27f6 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\u2081 g\u2082 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 : _ \u226b _ = _ \u226b _ \u226b _ :=\n       congr_arg (\u03bb f, (X.restrict hf).presheaf.map (eq_to_hom hV).op \u226b f) this,\n     erw [g\u2081.c.naturality, g\u2082.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 \u2190is_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 \u22a4)).c = eq_to_hom\n    (by { rw [restrict_top_presheaf, \u2190presheaf.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 \u27e8 \u03bb h, \u27e8\u27e8x,trivial\u27e9,h,rfl\u27e9, \u03bb \u27e8\u27e8_,_\u27e9,h,rfl\u27e9, h \u27e9 },\n  /- or `rw [opens.inclusion_top_functor, \u2190comp_obj, \u2190opens.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 \u27f6 X.restrict (opens.open_embedding \u22a4) :=\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 \u22a4) \u2245 X :=\n{ hom := X.of_restrict _,\n  inv := X.to_restrict_top,\n  hom_inv_id' := ext _ _ (concrete_category.hom_ext _ _ $ \u03bb \u27e8x, _\u27e9, 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 \u0393 : (PresheafedSpace C)\u1d52\u1d56 \u2964 C :=\n{ obj := \u03bb X, (unop X).presheaf.obj (op \u22a4),\n  map := \u03bb X Y f, f.unop.c.app (op \u22a4) }\n\nlemma \u0393_obj_op (X : PresheafedSpace C) : \u0393.obj (op X) = X.presheaf.obj (op \u22a4) := rfl\n\nlemma \u0393_map_op {X Y : PresheafedSpace C} (f : X \u27f6 Y) :\n  \u0393.map f.op = f.c.app (op \u22a4) := 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 \u2964 D` to the values of the presheaf in any `PresheafedSpace C`,\n    giving a functor `PresheafedSpace C \u2964 PresheafedSpace D` -/\ndef map_presheaf (F : C \u2964 D) : PresheafedSpace C \u2964 PresheafedSpace D :=\n{ obj := \u03bb X, { carrier := X.carrier, presheaf := X.presheaf \u22d9 F },\n  map := \u03bb X Y f, { base := f.base, c := whisker_right f.c F }, }\n\n@[simp] lemma map_presheaf_obj_X (F : C \u2964 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 \u2964 D) (X : PresheafedSpace C) :\n  (F.map_presheaf.obj X).presheaf = X.presheaf \u22d9 F := rfl\n@[simp] lemma map_presheaf_map_f (F : C \u2964 D) {X Y : PresheafedSpace C} (f : X \u27f6 Y) :\n  (F.map_presheaf.map f).base = f.base := rfl\n@[simp] lemma map_presheaf_map_c (F : C \u2964 D) {X Y : PresheafedSpace C} (f : X \u27f6 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 \u2964 D} (\u03b1 : F \u27f6 G) : G.map_presheaf \u27f6 F.map_presheaf :=\n{ app := \u03bb X,\n  { base := \ud835\udfd9 _,\n    c := whisker_left X.presheaf \u03b1 \u226b eq_to_hom (presheaf.pushforward.id_eq _).symm } }\n\n-- TODO Assemble the last two constructions into a functor\n--   `(C \u2964 D) \u2964 (PresheafedSpace C \u2964 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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl Dillies, Bhavik Mehta\n-/\nimport combinatorics.simplicial_complex.basic\n\nnamespace affine\nopen set\nvariables {m n : \u2115} {E : Type*} [normed_group E] [normed_space \u211d 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 \u2208 S.faces_finset hS \u2194 X \u2208 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 \u2208 S.faces | X \u2286 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 \u2208 S.faces | X \u2286 Y}\n\nlemma simplicial_complex.locally_finite_at_iff_not_locally_infinite_at :\n  \u00acS.locally_infinite_at X \u2194 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\u2200 {X : finset _}, X \u2208 S.faces \u2192 X.nonempty \u2192 S.locally_finite_at X\n\nexample {\u03b1 : Type*} {s : set \u03b1} {p q : \u03b1 \u2192 Prop} (h : \u2200 x, p x \u2192 q x) :\n  {x \u2208 s | p x} \u2286 {x \u2208 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 \u2286 Y) :\n  S.locally_finite_at Y :=\nbegin\n  apply hX.subset,\n  rintro Z \u27e8_, _\u27e9,\n  exact \u27e8\u2039Z \u2208 S.faces\u203a, finset.subset.trans hXY \u2039Y \u2286 Z\u203a\u27e9,\nend\n\nlemma locally_infinite_at_down_closed (hY : S.locally_infinite_at Y) (hXY : X \u2286 Y) :\n  S.locally_infinite_at X :=\n\u03bb t, hY (locally_finite_at_up_closed t hXY)\n\nlemma locally_finite_of_finite (hS : S.finite) :\n  S.locally_finite :=\n\u03bb X hX _, hS.subset (\u03bb 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 \u2194 \u2200 (x : E), finite {X | X \u2208 S.faces \u2227 x \u2208 convex_hull (X : set E)} :=\nbegin\n  split,\n  { unfold simplicial_complex.locally_finite,\n    contrapose!,\n    rintro \u27e8x, hx\u27e9,\n    by_cases hxspace : x \u2208 S.space,\n    { obtain \u27e8X, \u27e8hX, hXhull, hXbound\u27e9, hXunique\u27e9 := 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 \u2208 S.faces \u2227 x \u2208 convex_hull \u2191X} \u2286\n        {Y : finset E | Y \u2208 S.faces \u2227 X \u2286 Y},\n      { exact finite.subset hXlocallyfinite h },\n      rintro Y \u27e8hY, hYhull\u27e9,\n      use hY,\n      have hXYhull := S.disjoint hX hY \u27e8hXhull, hYhull\u27e9,\n      rw \u2190finset.coe_inter at hXYhull,\n      by_contra hXY,\n      apply hXbound,\n      have hYX : X \u2229 Y \u2282 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 \u27e8X \u2229 Y, hYX, hXYhull\u27e9 },\n    { exfalso,\n      apply hx,\n      suffices h : {X : finset E | X \u2208 S.faces \u2227 x \u2208 convex_hull \u2191X} = \u2205,\n      { rw h,\n        exact finite_empty },\n      apply eq_empty_of_subset_empty,\n      rintro X \u27e8hX, h\u27e9,\n      exact hxspace (mem_bUnion hX h) }},\n  { rintro hS X hX h,\n    obtain \u27e8x, hx\u27e9 := h,\n    suffices h : {Y : finset E | Y \u2208 S.faces \u2227 X \u2286 Y} \u2286\n      {Y : finset E | Y \u2208 S.faces \u2227 x \u2208 convex_hull \u2191Y},\n    { exact (hS x).subset h },\n    rintro Y \u27e8hY, hXY\u27e9,\n    exact \u27e8hY, subset_convex_hull Y (hXY hx)\u27e9 }\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\u2081 v\u2082 u\u2081 u\u2082 l u\u2083 v\u2083 \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\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2192 D) where\n  map : {X Y : C} \u2192 (X \u27f6 Y) \u2192 (F X \u27f6 F Y)\n  map_id' :\n    autoParam (C \u2192 map \ud835\udfd9 = \ud835\udfd9)\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 (\u2200 {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z), map (f \u226b g) = map f \u226b 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 \u2192 D` (just a function) has `[functorial F]`,\nwe can write `map F f : F X \u27f6 F Y` for the action of `F` on a morphism `f : X \u27f6 Y`.\n-/\ndef map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2192 D) [functorial F] {X : C}\n    {Y : C} (f : X \u27f6 Y) : F X \u27f6 F Y :=\n  functorial.map f\n\n@[simp] theorem map_as_map {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2192 D}\n    [functorial F] {X : C} {Y : C} {f : X \u27f6 Y} : functorial.map f = map F f :=\n  rfl\n\n@[simp] theorem functorial.map_id {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2192 D}\n    [functorial F] {X : C} : map F \ud835\udfd9 = \ud835\udfd9 :=\n  functorial.map_id' X\n\n@[simp] theorem functorial.map_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2192 D} [functorial F] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {g : Y \u27f6 Z} :\n    map F (f \u226b g) = map F f \u226b 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\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2192 D) [I : functorial F] :\n    C \u2964 D :=\n  mk F functorial.map\n\nend functor\n\n\nprotected instance functor.obj.functorial {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    (F : C \u2964 D) : functorial (functor.obj F) :=\n  functorial.mk (functor.map F)\n\n@[simp] theorem map_functorial_obj {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D)\n    {X : C} {Y : C} (f : X \u27f6 Y) : map (functor.obj F) f = functor.map F f :=\n  rfl\n\nprotected instance functorial_id {C : Type u\u2081} [category C] : functorial id :=\n  functorial.mk fun (X Y : C) (f : X \u27f6 Y) => f\n\n/--\n`G \u2218 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\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E]\n    (F : C \u2192 D) [functorial F] (G : D \u2192 E) [functorial G] : functorial (G \u2218 F) :=\n  functorial.mk (functor.map (functor.of F \u22d9 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 \u2192g F`.\n\n## Notations\n\n`\u2192fg` is a module-local variant on `\u2192g` 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'' \u2264 G'`, the inverse system `finsubgraph_hom_functor` restricts homomorphisms\n`G' \u2192fg 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 \u2192g F\n\nlocal infix ` \u2192fg ` : 50 := finsubgraph_hom\n\ninstance : order_bot G.finsubgraph :=\n{ bot := \u27e8\u22a5, finite_empty\u27e9,\n  bot_le := \u03bb _, bot_le }\n\ninstance : has_sup G.finsubgraph := \u27e8\u03bb G\u2081 G\u2082, \u27e8G\u2081 \u2294 G\u2082, G\u2081.2.union G\u2082.2\u27e9\u27e9\ninstance : has_inf G.finsubgraph := \u27e8\u03bb G\u2081 G\u2082, \u27e8G\u2081 \u2293 G\u2082, G\u2081.2.subset $ inter_subset_left _ _\u27e9\u27e9\n\ninstance : distrib_lattice G.finsubgraph :=\nsubtype.coe_injective.distrib_lattice _ (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [finite V] : has_top G.finsubgraph := \u27e8\u27e8\u22a4, finite_univ\u27e9\u27e9\ninstance [finite V] : has_Sup G.finsubgraph := \u27e8\u03bb s, \u27e8\u2a06 G \u2208 s, \u2191G, set.to_finite _\u27e9\u27e9\ninstance [finite V] : has_Inf G.finsubgraph := \u27e8\u03bb s, \u27e8\u2a05 G \u2208 s, \u2191G, set.to_finite _\u27e9\u27e9\n\ninstance [finite V] : complete_distrib_lattice G.finsubgraph :=\nsubtype.coe_injective.complete_distrib_lattice _ (\u03bb _ _, rfl) (\u03bb _ _, rfl) (\u03bb _, rfl) (\u03bb _, rfl) rfl\n  rfl\n\n/-- The finite subgraph of G generated by a single vertex. -/\ndef singleton_finsubgraph (v : V) : G.finsubgraph := \u27e8simple_graph.singleton_subgraph _ v, by simp\u27e9\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\u27e8simple_graph.subgraph_of_adj _ e, by simp\u27e9\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 \u2264 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 \u2264 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'' \u2264 G') (f : G' \u2192fg F) : G'' \u2192fg F :=\nbegin\n  refine \u27e8\u03bb \u27e8v, hv\u27e9, f.to_fun \u27e8v, h.1 hv\u27e9, _\u27e9,\n  rintros \u27e8u, hu\u27e9 \u27e8v, hv\u27e9 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)\u1d52\u1d56 \u2964 Type (max u v) :=\n{ obj := \u03bb G', G'.unop \u2192fg F,\n  map := \u03bb 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 : \u03a0 (G' : G.subgraph), G'.verts.finite \u2192 G'.coe \u2192g F) : nonempty (G \u2192g F) :=\nbegin\n  /- Obtain a `fintype` instance for `W`. -/\n  casesI nonempty_fintype W,\n  /- Establish the required interface instances. -/\n  haveI : \u2200 (G' : (G.finsubgraph)\u1d52\u1d56), nonempty ((finsubgraph_hom_functor G F).obj G') :=\n    \u03bb G', \u27e8h G'.unop G'.unop.property\u27e9,\n  haveI : \u03a0 (G' : (G.finsubgraph)\u1d52\u1d56), fintype ((finsubgraph_hom_functor G F).obj G') :=\n  begin\n    intro G',\n    haveI : fintype (\u21a5(G'.unop.val.verts)) := G'.unop.property.fintype,\n    haveI : fintype (\u21a5(G'.unop.val.verts) \u2192 W) := begin\n      classical,\n      exact pi.fintype\n    end,\n    exact fintype.of_injective (\u03bb f, f.to_fun) rel_hom.coe_fn_injective\n  end,\n  /- Use compactness to obtain a section. -/\n  obtain \u27e8u, hu\u27e9 := nonempty_sections_of_finite_inverse_system (finsubgraph_hom_functor G F),\n  refine \u27e8\u27e8\u03bb v, _, _\u27e9\u27e9,\n  { /- Map each vertex using the homomorphism provided for its singleton subgraph. -/\n    exact (u (opposite.op (singleton_finsubgraph v))).to_fun\n      \u27e8v, by {unfold singleton_finsubgraph, simp}\u27e9, },\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) \u27f6 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) \u27f6 opposite.op (singleton_finsubgraph v') :=\n      quiver.hom.op (category_theory.hom_of_le singleton_finsubgraph_le_adj_right),\n    rw [\u2190 (hu hv), \u2190 (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 : \u2115} (s_ne_zero : s \u2260 0) : finset \u211d :=\nbegin\n  let numerators : finset \u2115 := finset.range s,\n  let div_by_s_fn : \u2115 \u21aa \u211d :=\n    begin\n      let div_by_s_fn : \u2115 \u2192 \u211d := \u03bb numerator, \u2191numerator / \u2191s,\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 : \u211d) \u2260 0 := by exact_mod_cast s_ne_zero,\n          have mul_div_cancel_fact1 := mul_div_cancel' (num1 : \u211d) s_cast_ne_zero,\n          have mul_div_cancel_fact2 := mul_div_cancel' (num2 : \u211d) s_cast_ne_zero,\n          replace num1_div_by_s_eq_num2_div_by_s : (s : \u211d) * ((num1 : \u211d) / (s : \u211d)) = (s : \u211d) * ((num2 : \u211d) / (s : \u211d)) :=\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 : \u2115} (s_ne_zero : s \u2260 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 : \u2115} {s_ne_zero : s \u2260 0} {a : \u211d} (a_in_s_finset : a \u2208 s_finset s_ne_zero) : 0 \u2264 a \u2227 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 \u27e8a_num, a_num_lt_s, a_num_div_s_eq_a\u27e9,\n  have zero_le_s : 0 \u2264 s := nat.zero_le s,\n  have cast_zero_le_s : (0 : \u211d) \u2264 \u2191s := by {exact_mod_cast zero_le_s},\n  have cast_zero_lt_s : (0 : \u211d) < \u2191s :=\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 \u2264 a :=\n    begin\n      have zero_le_a_num : 0 \u2264 a_num := nat.zero_le a_num,\n      have cast_zero_le_a_num : (0 : \u211d) \u2264 \u2191a_num := by {exact_mod_cast zero_le_a_num},\n      rw \u2190 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 [\u2190 a_num_div_s_eq_a, div_lt_one cast_zero_lt_s], exact_mod_cast a_num_lt_s},\n  exact \u27e8zero_le_a, a_lt_one\u27e9,\nend\n\nlemma s_finset_distinct_mod_one {s : \u2115} {s_ne_zero : s \u2260 0} {a : \u211d} {b : \u211d} (a_ne_b : a \u2260 b) (a_in_s_finset : a \u2208 s_finset s_ne_zero)\n  (b_in_s_finset : b \u2208 s_finset s_ne_zero) : ne_mod_one a b :=\nbegin\n  rcases s_finset_range a_in_s_finset with \u27e8zero_le_a, a_lt_one\u27e9,\n  rcases s_finset_range b_in_s_finset with \u27e8zero_le_b, b_lt_one\u27e9,\n  rintro \u27e8a_floor, b_floor, y, zero_le_y, y_lt_one, a_eq_a_floor_add_y, b_eq_b_floor_add_y\u27e9,\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, \u2190 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 : (\u2191a_floor : \u211d) + 1 \u2264 \u2191b_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 : (\u2191b_floor : \u211d) + 1 \u2264 \u2191a_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 : \u2115} {s : \u2115} (s_ne_zero : s \u2260 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 : \u2200 p : point d, p \u2208 T \u2192 \u2200 j : fin d, j.val < i.val \u2192 \n    \u2203 s_val \u2208 s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val) : \n  \u2200 coords_left : \u2115, \u2200 coords : finset \u211d, \u2200 goal_finset : finset \u211d, goal_finset \u2286 s_finset s_ne_zero \u2192\n  (\u2200 coord \u2208 coords, \u2200 s_val \u2208 s_finset s_ne_zero, ne_mod_one coord s_val) \u2192\n  (\u2200 p \u2208 T, \u2200 goal_val \u2208 goal_finset, ne_mod_one (vector.nth p i) goal_val) \u2192\n  coords_left = coords.card \u2192 coords.card \u2264 goal_finset.card \u2192\n  \u2203 T_shifted : set (point d), \u2203 T_shifted_is_tiling : is_tiling T_shifted, tiling_faceshare_free T_shifted \u2227 is_periodic T_shifted_is_tiling \u2227\n  (\u2200 p : point d, p \u2208 T_shifted \u2192 \u2200 j : fin d, j.val < i.val \u2192 \u2203 s_val \u2208 s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val) \u2227\n  (\u2200 p : point d, p \u2208 T_shifted \u2192 (\u2200 coord \u2208 coords, ne_mod_one (vector.nth p i) coord) \n    \u2227 ((\u2203 goal_val \u2208 goal_finset, eq_mod_one (vector.nth p i) goal_val) \u2228 p \u2208 T)) \u2227\n  (\u2200 p : point d, p \u2208 T_shifted \u2192 \u2200 j : fin d, j.val > i.val \u2192 \u2203 p' \u2208 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 \u211d := finset.sort has_le.le coords,\n  let goal_list : list \u211d := 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 [\u2190 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 \u2264 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 [\u2190 goal_finset_card_eq_goal_list_length, goal_list_def, list.length, \u2190 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 \u2208 goal_finset :=\n    begin\n      rw \u2190 finset.mem_sort real.has_le.le,\n      change last_goal \u2208 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 \u211d := rest_coords.to_finset,\n  let rest_goal_finset : finset \u211d := rest_goal_list.to_finset,\n  have rest_goal_finset_subset_goal_finset : rest_goal_finset \u2286 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 \u2190 finset.mem_sort real.has_le.le,\n      change rest_goal_val \u2208 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 \u2286 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 \u2286 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 \u2190 finset.mem_sort real.has_le.le,\n      change coord \u2208 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    \u2200 (coord : \u211d), coord \u2208 rest_coords_finset \u2192 \u2200 (s_val : \u211d), s_val \u2208 s_finset s_ne_zero \u2192 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 \u2190 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    \u2200 (p : vector \u211d d), p \u2208 T \u2192 \u2200 (goal_val : \u211d), goal_val \u2208 rest_goal_finset \u2192 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 \u2264 rest_goal_finset.card := \n    begin\n      rw \u2190 rest_coords_card,\n      rw [\u2190 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 \u2264 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 \u2190 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, \u2190 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    \u27e8T_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\u27e9,\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    \u27e8T_shifted_is_tiling, T_shifted_prev_faceshare_free_implication\u27e9,\n  use [T_shifted, T_shifted_is_tiling],\n  have last_goal_not_in_T_shifted_prev : \n    (\u2200 (t : point d), t \u2208 T_shifted_prev \u2192 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        \u27e8t_ne_mod_one_rest_coords, \u27e8goal_val, goal_val_in_rest_goal_finset, t_eq_goal_val_mod_one\u27e9 | t_in_T\u27e9,\n      { have goal_val_ne_last_goal : goal_val \u2260 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 \u27e8last_goal_not_in_rest_goal_list, rest_goal_list_nodup\u27e9,\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 \u2208 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      \u27e8p_in_T_shifted_prev, p_ne_last_coord_mod_one\u27e9 | \u27e8p_prev, p_prev_in_T_shifted_prev, p_def, p_prev_eq_last_coord_mod_one\u27e9,\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 \u2260 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      \u27e8p_in_T_shifted_prev, p_ne_last_coord_mod_one\u27e9 | \u27e8p_prev, p_prev_in_T_shifted_prev, p_def, p_prev_eq_last_coord_mod_one\u27e9,\n    { rcases T_shifted_prev_property_at_i p p_in_T_shifted_prev with \u27e8p_ne_rest_coords_mod_one, T_shifted_second_property_at_i\u27e9,\n      split,\n      { intros coord coord_in_coords,\n        by_cases coord_in_rest_coords_finset : coord \u2208 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 \u2208 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 \u2208 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        \u27e8goal_val, goal_val_in_rest_goal_finset, p_eq_goal_val_mod_one\u27e9 | 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    \u27e8p_in_T_shifted_prev, p_ne_last_coord_mod_one\u27e9 | \u27e8p_prev, p_prev_in_T_shifted_prev, p_def, p_prev_eq_last_coord_mod_one\u27e9,\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 \u2260 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 : \u2115} {s : \u2115} (d_ne_zero : d \u2260 0) (s_ne_zero : s \u2260 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 : \u2200 p : point d, p \u2208 T \u2192 \u2200 j : fin d, j.val < i.val \u2192 \n    \u2203 s_val \u2208 s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val) :\n  \u2203 T_shifted : set (point d), \u2203 T_shifted_is_tiling : is_tiling T_shifted, tiling_faceshare_free T_shifted \u2227 \n  is_periodic T_shifted_is_tiling \u2227 is_s_discrete s T_shifted \u2227\n  \u2200 p : point d, p \u2208 T_shifted \u2192 \u2200 j : fin d, j.val \u2264 i.val \u2192 \u2203 s_val \u2208 s_finset s_ne_zero, eq_mod_one (vector.nth p j) s_val :=\nbegin\n  rcases T_is_s_discrete i with \u27e8coords, coords_card_le_s, \u27e8coords_distinct_mod_one, T_is_s_discrete'\u27e9\u27e9,\n  let goal_finset := {s_val \u2208 s_finset s_ne_zero | \u2200 coord \u2208 coords, ne_mod_one coord s_val},\n  let coords_inter_s_finset := {coord \u2208 coords | \u2203 s_val \u2208 s_finset s_ne_zero, eq_mod_one coord s_val},\n  have coords_inter_goal_subset_of_coords : coords_inter_s_finset \u2286 coords :=\n    by {dsimp[coords_inter_s_finset], simp only [finset.filter_subset]},\n  have goal_finset_subset_s_finset : goal_finset \u2286 s_finset s_ne_zero :=\n    by {dsimp[goal_finset], apply finset.filter_subset},\n  have coords_to_handle_disjoint_s_finset : \n    \u2200 (coord : \u211d), coord \u2208 coords \\ coords_inter_s_finset \u2192 \u2200 (s_val : \u211d), s_val \u2208 s_finset s_ne_zero \u2192 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    \u2200 (p : vector \u211d d), p \u2208 T \u2192 \u2200 (goal_val : \u211d), goal_val \u2208 goal_finset \u2192 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 \u27e8coord, coord_in_coords, p_eq_coord_mod_one\u27e9,\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 \u2264 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 := (\u03bb s_val : \u211d, \u2200 (coord : \u211d), coord \u2208 coords \u2192 ne_mod_one coord s_val),\n            have s_finset_filter_fn_decidable : decidable_pred s_finset_filter_fn := \n              (\u03bb s_val, classical.prop_decidable (s_finset_filter_fn s_val)),\n            let s_finset_filter_fn_neg := (\u03bb s_val : \u211d, \u2203 coord \u2208 coords, eq_mod_one coord s_val),\n            have not_s_finset_filter_fn_neg_eq_f_finset_filter_fn_neg : not \u2218 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 \u27e8coord, coord_in_coords, coord_eq_s_val_mod_one\u27e9,\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 \u27e8coord, coord_in_coords, coord_eq_s_val_mod_one\u27e9,\n                use [coord, coord_in_coords],\n              end,\n            \n            rw \u2190 @finset.filter_card_add_filter_neg_card_eq_card \u211d (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 \u211d 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 : \u211d \u2192 \u211d := \n              (\u03bb coord : \u211d,\n                begin\n                  by_cases h : \u2203 s_val \u2208 s_finset s_ne_zero, eq_mod_one coord s_val,\n                  exact classical.some h,\n                  exact (-1 : \u211d),\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 : \u2200 s : finset \u211d, \u2200 s' : finset \u211d, s = s' \u2192 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 \u2218 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 \u27e8s_val_in_s_finset, \u27e8coord, coord_in_coords, coord_eq_s_val_mod_one\u27e9\u27e9,\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 : \u2203 (s_val : \u211d) (H : s_val \u2208 s_finset s_ne_zero), eq_mod_one coord s_val := \n                  \u27e8s_val, s_val_in_s_finset, coord_eq_s_val_mod_one\u27e9,\n                convert_to classical.some if_cond_true = s_val, apply dif_pos,\n                rcases classical.some_spec if_cond_true with \u27e8classical_some_in_s_finset, coord_eq_classical_some_mod_one\u27e9,\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 \u2218 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 \u27e8coord, coord_in_coords_inter_s_finset, classical_some_eq_s_val\u27e9,\n              by_cases if_cond : \u2203 (s_val : \u211d), s_val \u2208 s_finset s_ne_zero \u2227 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 \u27e8classical_some_in_s_finset, coord_eq_classical_some_mod_one\u27e9,\n                rw \u2190 classical_some_eq_s_val,\n                have coord_in_coords : coord \u2208 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 \u27e8classical_some_in_s_finset, \u27e8coord, coord_in_coords, coord_eq_classical_some_mod_one\u27e9\u27e9,\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' : \u2203 s_val : \u211d, s_val \u2208 s_finset s_ne_zero \u2227 eq_mod_one coord s_val :=\n                begin\n                  rcases if_cond_true with \u27e8s_val, s_val_in_s_finset, coord_eq_s_val_mod_one\u27e9,\n                  use s_val,\n                  exact \u27e8s_val_in_s_finset, coord_eq_s_val_mod_one\u27e9,\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              \u27e8coord1_in_coords, \u27e8coord1_s_val, coord1_s_val_in_s_finset, coord1_eq_coord1_s_val_mod_one\u27e9\u27e9,\n            rcases coord2_in_coords_inter_s_finset with\n              \u27e8coord2_in_coords, \u27e8coord2_s_val, coord2_s_val_in_s_finset, coord2_eq_coord2_s_val_mod_one\u27e9\u27e9,\n            dsimp[f] at f_coord1_eq_f_coord2,\n            have exists_s_val_eq_coord1_mod_one : \u2203 (s_val : \u211d) (H : s_val \u2208 s_finset s_ne_zero), eq_mod_one coord1 s_val :=\n              \u27e8coord1_s_val, coord1_s_val_in_s_finset, coord1_eq_coord1_s_val_mod_one\u27e9,\n            have exists_s_val_eq_coord2_mod_one : \u2203 (s_val : \u211d) (H : s_val \u2208 s_finset s_ne_zero), eq_mod_one coord2 s_val :=\n              \u27e8coord2_s_val, coord2_s_val_in_s_finset, coord2_eq_coord2_s_val_mod_one\u27e9,\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              \u27e8classical_some1_in_s_finset, coord1_eq_classical_some1_mod_one\u27e9,\n            rcases classical.some_spec exists_s_val_eq_coord2_mod_one with\n              \u27e8classical_some2_in_s_finset, coord2_eq_classical_some2_mod_one\u27e9, \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    \u27e8T_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\u27e9,\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 \u27e8goal_val, goal_val_in_goal_finset, t_eq_goal_val_mod_one\u27e9,\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 \u27e8coord, coord_in_coords, t_eq_mod_one_coord\u27e9,\n      have coord_in_coords_to_handle : coord \u2208 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 \u27e8coords, coords_card_le_s, \u27e8coords_distinct_mod_one, t_in_T_imp_t_j_in_coords\u27e9\u27e9,\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 \u27e8t', t'_in_T, t_eq_t'_at_j\u27e9,\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 \u27e8goal_val, goal_val_in_goal_finset, p_eq_goal_val_mod_one\u27e9,\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 : \u2203 coord \u2208 coords, eq_mod_one (vector.nth p i) coord := T_is_s_discrete' p p_in_T,\n  rcases p_i_in_coords with \u27e8coord, coord_in_coords, p_i_eq_coords_mod_one\u27e9,\n  by_cases coord_in_goal_finset : coord \u2208 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 \u2208 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 : \u2115} {s : \u2115} (d_ne_zero : d \u2260 0) (s_ne_zero : s \u2260 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  \u2203 T_shifted : set (point d), \u2203 T_shifted_is_tiling : is_tiling T_shifted, tiling_faceshare_free T_shifted \u2227 is_periodic T_shifted_is_tiling \u2227\n  (\u2200 i : fin d, \u2200 p : point d, p \u2208 T_shifted \u2192 \u2203 s_val \u2208 s_finset s_ne_zero, eq_mod_one (vector.nth p i) s_val) :=\nbegin\n  let d_sub_one : fin d := \u27e8d - 1, nat.pred_lt d_ne_zero\u27e9,\n  have inductive_replacement_lemma_helper_fact : \u2200 i : fin d, i.val < d \u2192 \n    \u2203 T_shifted : set (point d), \u2203 T_shifted_is_tiling : is_tiling T_shifted, tiling_faceshare_free T_shifted \u2227 \n    is_periodic T_shifted_is_tiling \u2227 is_s_discrete s T_shifted \u2227\n    \u2200 p : point d, p \u2208 T_shifted \u2192 \u2200 j : fin d, j.val \u2264 i.val \u2192 \u2203 s_val \u2208 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 : \u2200 p : point d, p \u2208 T \u2192 \u2200 j : fin d, j.val < 0 \u2192 \n          \u2203 s_val \u2208 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 \u27e80, zero_lt_d\u27e9 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        \u27e8T_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\u27e9,\n      have coords_before_n_succ_handled : \n        \u2200 p : point d, p \u2208 T_shifted_prev \u2192 \u2200 j : fin d, j.val < n.succ \u2192 \u2203 s_val \u2208 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 \u27e8n.succ, n_succ_lt_d\u27e9 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    \u27e8T_shifted, T_shifted_is_tiling, T_shifted_faceshare_free, T_shifted_is_periodic, T_shifted_s_discrete, T_shifted_only_uses_goal_coordinates\u27e9,\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 \u2264 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 : \u2115} (d_ne_zero : d \u2260 0) (s_ne_zero : s \u2260 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    \u2200 (i : fin d) (p : point d), p \u2208 T_shifted \u2192 (\u2203 (s_val : \u211d) (H : s_val \u2208 s_finset s_ne_zero), eq_mod_one (vector.nth p i) s_val))\n  (core_points_finset : \n    finset {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)})\n  (core_points_finset_card : core_points_finset.card = 2 ^ d)\n  (core_points_finset_property : \n    \u2200 (p : point d) (h : \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)),\n      (\u27e8p, h\u27e9 : {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)}) \u2208 core_points_finset)\n  (p : {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)}) :\n  \u2203 fin_double_s_vector : vector (fin (2*s)) d, \u2200 i : fin d, \u2191(fin_double_s_vector.nth i).val = \u2191s * (((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 \u2191p).val,\n  have p_corner_def : p_corner = (point_to_corner T_shifted_is_tiling \u2191p).val := by refl,\n  have p_corner_property := (point_to_corner T_shifted_is_tiling \u2191p).property,\n  rw \u2190 p_corner_def at p_corner_property,\n  rw \u2190 p_corner_def,\n  rcases p_corner_property with \u27e8p_corner_in_T_shifted, p_in_p_corner, p_corner_unique\u27e9,\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 : \u2200 i : fin d, \u2203 n : \u2115, \u2191n = \u2191s * vector.nth p_corner i + \u2191s - 1 :=\n    begin\n      intro i,\n      rcases T_shifted_contains_only_s_points i p_corner p_corner_in_T_shifted with \u27e8s_val, s_val_in_s_finset, p_corner_eq_s_val_mod_one\u27e9,\n      rcases s_finset_range s_val_in_s_finset with \u27e8zero_le_s_val, s_val_lt_one\u27e9,\n      replace p_in_p_corner := p_in_p_corner i,\n      rcases p_in_p_corner with \u27e8p_corner_le_p, p_lt_p_corner_add_one\u27e9,\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 \u27e8p_corner_floor, zero, y, zero_le_y, y_lt_one, p_corner_def, s_val_def\u27e9,\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 \u2264 -1 := by omega,\n              have cast_zero_le_neg_one : \u2191zero \u2264 (-1 : \u211d) := by exact_mod_cast zero_le_neg_one,\n              linarith,\n            },\n            have zero_ge_one : zero \u2265 1 := by omega,\n            have cast_zero_ge_one : \u2191zero \u2265 (1 : \u211d) := by exact_mod_cast zero_ge_one,\n            linarith,\n          end,\n        have cast_zero_eq_zero : \u2191zero = (0 : \u211d) := by exact_mod_cast zero_eq_zero,\n        rw [cast_zero_eq_zero, zero_add] at s_val_def,\n        rw \u2190 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 \u2264 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 \u2264 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 : \u2191p_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 : \u2191p_corner_floor.to_nat = (\u2191p_corner_floor : \u211d) := \n            by exact_mod_cast p_corner_floor_to_nat_eq_self,\n          have one_le_s : 1 \u2264 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, \u2190 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 \u27e8zero_le_s_val, s_val_lt_one\u27e9,\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 \u27e8s_val_num, s_val_num_lt_s, s_val_num_div_s_eq_s_val\u27e9,\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 \u2264 s_val_num := by {clear_except s_val_num_gt_zero, omega},\n        have cast_s_ne_zero : \u2191s \u2260 (0 : \u211d) := 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 \u2264 -2 := by {clear_except p_corner_floor_lt_neg_one, omega},\n              have cast_p_corner_floor_le_neg_two : \u2191p_corner_floor \u2264 (-2 : \u211d) := by exact_mod_cast p_corner_floor_le_neg_two,\n              linarith,\n            },\n            have zero_le_p_corner_floor : 0 \u2264 p_corner_floor := by {clear_except p_corner_floor_gt_neg_one, omega},\n            have cast_zero_le_p_corner_floor : (0 : \u211d) \u2264 \u2191p_corner_floor := by exact_mod_cast zero_le_p_corner_floor,\n            have zero_ne_s_val : 0 \u2260 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 : \u2191p_corner_floor = (-1 : \u211d) := by exact_mod_cast p_corner_floor_eq_neg_one,\n        rw \u2190 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 \u2191s_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 \u27e8p_corner_floor, zero, y, zero_le_y, y_lt_one, p_corner_def, s_val_def\u27e9,\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 \u2264 -1 := by omega,\n            have cast_zero_le_neg_one : \u2191zero \u2264 (-1 : \u211d) := by exact_mod_cast zero_le_neg_one,\n            linarith,\n          },\n          have zero_ge_one : zero \u2265 1 := by omega,\n          have cast_zero_ge_one : \u2191zero \u2265 (1 : \u211d) := by exact_mod_cast zero_ge_one,\n          linarith,\n        end,\n      have cast_zero_eq_zero : \u2191zero = (0 : \u211d) := by exact_mod_cast zero_eq_zero,\n      rw [cast_zero_eq_zero, zero_add] at s_val_def,\n      rw \u2190 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 \u2264 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 \u2264 p_corner_floor := by linarith,\n        have p_corner_floor_to_nat_eq_self : \u2191p_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 : \u2191p_corner_floor.to_nat = (\u2191p_corner_floor : \u211d) := \n          by exact_mod_cast p_corner_floor_to_nat_eq_self,\n        have one_le_s : 1 \u2264 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, \u2190 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 \u27e8zero_le_s_val, s_val_lt_one\u27e9,\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 \u27e8s_val_num, s_val_num_lt_s, s_val_num_div_s_eq_s_val\u27e9,\n      use \u2191s_val_num + \u2191s - 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 \u2264 s_val_num := by {clear_except s_val_num_gt_zero, omega},\n      have one_le_s_add_s_val_num : 1 \u2264 \u2191s_val_num + \u2191s := by linarith,\n      have cast_s_ne_zero : \u2191s \u2260 (0 : \u211d) := 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 \u2264 -1 := by {clear_except p_corner_floor_lt_zero, omega},\n            have cast_p_corner_floor_le_neg_one : \u2191p_corner_floor \u2264 (-1 : \u211d) := by exact_mod_cast p_corner_floor_le_neg_one,\n            linarith,\n          },\n          have one_le_p_corner_floor : 1 \u2264 p_corner_floor := by {clear_except p_corner_floor_gt_zero, omega},\n          have cast_one_le_p_corner_floor : (1 : \u211d) \u2264 \u2191p_corner_floor := by exact_mod_cast one_le_p_corner_floor,\n          have zero_ne_s_val : 0 \u2260 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 : \u2191p_corner_floor = (0 : \u211d) := by exact_mod_cast p_corner_floor_eq_zero,\n      rw \u2190 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 \u2191s_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 : \u2200 i : fin d, classical.some (each_coord_is_nat i) < 2 * s :=\n    begin\n      intro i,\n      have cast_goal : \u2191(classical.some (each_coord_is_nat i)) < (2 : \u211d) * \u2191s :=\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 \u27e8p_corner_le_p, p_lt_p_corner_add_one\u27e9,\n          have p_le_one : vector.nth (\u2191p : point d) i \u2264 (1 : \u211d) :=\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 \u2264 1 := by linarith,\n          have zero_le_p : (0 : \u211d) \u2264 vector.nth (\u2191p : 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 \u2264 vector.nth p_corner i := by linarith,\n          have zero_le_cast_s : (0 : \u211d) \u2264 \u2191s := by exact_mod_cast (zero_le s),\n          have goal_sans_sub_one : \u2191s * vector.nth p_corner i + \u2191s \u2264 2 * \u2191s :=\n            begin\n              rw mul_comm (2 : \u211d) \u2191s,\n              convert_to \u2191s * vector.nth p_corner i + \u2191s * 1 \u2264 \u2191s * 2, rw mul_one,\n              rw \u2190 mul_add,\n              apply mul_le_mul, exact le_refl \u2191s, 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 (\u03bb i, \u27e8classical.some (each_coord_is_nat i), each_coord_lt_double_s i\u27e9),\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 : \u2115} (d_ne_zero : d \u2260 0) (s_ne_zero : s \u2260 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    \u2200 (i : fin d) (p : point d), p \u2208 T_shifted \u2192 (\u2203 (s_val : \u211d) (H : s_val \u2208 s_finset s_ne_zero), eq_mod_one (vector.nth p i) s_val))\n  (core_points_finset : \n    finset {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)})\n  (core_points_finset_card : core_points_finset.card = 2 ^ d)\n  (core_points_finset_property : \n    \u2200 (p : point d) (h : \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)),\n      (\u27e8p, h\u27e9 : {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)}) \u2208 core_points_finset) : \n  {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)} \u2192\n  {v : vector (fin (2*s)) d // \u2203 p : point d, is_core_point p \u2227 \u2203 p_corner \u2208 T_shifted, \n    p \u2208 cube p_corner \u2227 (\u2200 alt_corner : point d, alt_corner \u2208 T_shifted \u2192 p \u2208 cube alt_corner \u2192 alt_corner = p_corner) \u2227\n    (\u2200 i : fin d, \u2191s * (vector.nth p_corner i) + \u2191s - 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 \u2190 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 \u2190 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 \u2190 p_corner_def at p_corner_property,\n  rcases p_corner_property with \u27e8p_corner_in_T_shifted, p_in_p_corner, p_corner_unique\u27e9,\n  use [p.val, (\u03bb 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 : \u2115} (d_ne_zero : d \u2260 0) (s_ne_zero : s \u2260 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    \u2200 (i : fin d) (p : point d), p \u2208 T_shifted \u2192 (\u2203 (s_val : \u211d) (H : s_val \u2208 s_finset s_ne_zero), eq_mod_one (vector.nth p i) s_val))\n  (core_points_finset : \n    finset {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)})\n  (core_points_finset_card : core_points_finset.card = 2 ^ d)\n  (core_points_finset_property : \n    \u2200 (p : point d) (h : \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)),\n    (\u27e8p, h\u27e9 : {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)}) \n    \u2208 core_points_finset)\n  (goal_clique_with_info_map : \n    {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)} \u21aa\n    {v : vector (fin (2*s)) d // \u2203 (p : point d), is_core_point p \u2227 \u2203 (p_corner : point d) (H : p_corner \u2208 T_shifted), p \u2208 cube p_corner \u2227\n      (\u2200 (alt_corner : point d), alt_corner \u2208 T_shifted \u2192 p \u2208 cube alt_corner \u2192 alt_corner = p_corner) \u2227\n      \u2200 (i : fin d), \u2191s * vector.nth p_corner i + \u2191s - 1 = \u2191((v.nth i).val)})\n  (v1 v2 : vector (fin (2 * s)) d) (v1_ne_v2 : v1 \u2260 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 \u2208 T_shifted) (core_point1_in_core_point1_corner : core_point1 \u2208 cube core_point1_corner)\n  (core_point1_corner_unique : \n    \u2200 (alt_corner : point d), alt_corner \u2208 T_shifted \u2192 core_point1 \u2208 cube alt_corner \u2192 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 \u2208 T_shifted) (core_point2_in_core_point2_corner : core_point2 \u2208 cube core_point2_corner)\n  (core_point2_corner_unique : \u2200 (alt_corner : point d), alt_corner \u2208 T_shifted \u2192 core_point2 \u2208 cube alt_corner \u2192 alt_corner = core_point2_corner)\n  (v2_def : v2' = v2) (v1_def : v1' = v1)\n  (core_point1_corner_v1'_relationship : \u2200 (i : fin d), \u2191s * vector.nth core_point1_corner i + \u2191s - 1 = \u2191(\u2191(v1.nth i) : \u2115))\n  (core_point2_corner_v2'_relationship : \u2200 (i : fin d), \u2191s * vector.nth core_point2_corner i + \u2191s - 1 = \u2191(\u2191(v2.nth i) : \u2115))\n  (v1_not_adj_v2 : \n    (\u2200 (x : fin d), \u2191(v1.nth x) = \u2191(v2.nth x) + s \u2192 \u2200 (x_1 : fin d), \u00acv1.nth x_1 = v2.nth x_1 \u2192 x = x_1) \u2227 \n    \u2200 (x : fin d), \u2191(v2.nth x) = \u2191(v1.nth x) + s \u2192 \u2200 (x_1 : fin d), \u00acv2.nth x_1 = v1.nth x_1 \u2192 x = x_1)\n  (v1_not_adj_v2_hyp_false : \u00ac\u2203 (i : fin d), \u2191(v1.nth i) = \u2191(v2.nth i) + s \u2228 \u2191(v2.nth i) = \u2191(v1.nth i) + s) :\n  let goal_clique_with_info : finset\n        {v : vector (fin (2*s)) d // \u2203 (p : point d),\n           is_core_point p \u2227\n             \u2203 (p_corner : point d) (H : p_corner \u2208 T_shifted),\n               p \u2208 cube p_corner \u2227\n                 (\u2200 (alt_corner : point d),\n                      alt_corner \u2208 T_shifted \u2192\n                      p \u2208 cube alt_corner \u2192 alt_corner = p_corner) \u2227\n                   \u2200 (i : fin d),\n                     \u2191s * vector.nth p_corner i + \u2191s - 1 =\n                       \u2191((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    \u2200 i : fin d, core_point1_corner.nth i \u2260 core_point2_corner.nth i + 1 \u2227 core_point2_corner.nth i \u2260 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 : (\u2191(\u2191(v1.nth i) : \u2115) : \u211d) \u2260 (\u2191(\u2191(v2.nth i) : \u2115) : \u211d) + \u2191s := by exact_mod_cast v1_ne_v2_add_s,\n      have real_v2_ne_v1_add_s : (\u2191(\u2191(v2.nth i) : \u2115) : \u211d) \u2260 (\u2191(\u2191(v1.nth i) : \u2115) : \u211d) + \u2191s := by exact_mod_cast v2_ne_v1_add_s,\n      rw [\u2190 core_point1_corner_v1'_relationship, \u2190 core_point2_corner_v2'_relationship, add_sub_assoc, add_sub_assoc,\n        add_comm (\u2191s * vector.nth core_point1_corner i) (\u2191s - 1), \n        add_comm (\u2191s * vector.nth core_point2_corner i) (\u2191s - 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 : \u2191s * vector.nth core_point1_corner i + \u2191s = \u2191s * vector.nth core_point1_corner i + \u2191s * (1 : \u211d) := by rw mul_one,\n      have rw2 : \u2191s * vector.nth core_point2_corner i + \u2191s = \u2191s * vector.nth core_point2_corner i + \u2191s * (1 : \u211d) := 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 \u2190 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 \u27e8real_v1_ne_v2_add_s.1, real_v2_ne_v1_add_s.1\u27e9,\n    end,\n  let z : int_point d := vector.of_fn\n    (\u03bb i, if(core_point1_corner.nth i < core_point2_corner.nth i + 1 \u2227 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 (\u03bb 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 \u2260 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 \u2190 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    \u27e8core_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\u27e9,\n  let shared_point : point d := vector.of_fn \n    (\u03bb 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 \u27e8unique_corner, unique_corner_in_T_shifted, shared_point_in_unique_corner, unique_corner_unique\u27e9,\n  have shared_point_in_core_point1_add_double_z_corner : shared_point \u2208 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 \u2264 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 \u2264 vector.nth core_point2_corner i,\n      { rw if_pos h,\n        have int_core_point1_corner_eq_core_point1_corner : \u2191(int_point_to_corner T_shifted_is_tiling int_core_point1) = core_point1_corner :=\n          begin\n            rw \u2190 subtype.val_eq_coe,\n            rcases (int_point_to_corner T_shifted_is_tiling int_core_point1).property with\n              \u27e8int_core_point1_corner_in_T_shifted, int_core_point1_in_int_core_point1_corner, int_core_point1_corner_unique\u27e9,\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 \u2227 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 \u2265 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 \u2208 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 \u2264 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 \u2264 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 : \u2191(int_point_to_corner T_shifted_is_tiling int_core_point1) = core_point1_corner :=\n        begin\n          rw \u2190 subtype.val_eq_coe,\n          rcases (int_point_to_corner T_shifted_is_tiling int_core_point1).property with\n            \u27e8int_core_point1_corner_in_T_shifted, int_core_point1_in_int_core_point1_corner, int_core_point1_corner_unique\u27e9,\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 \u2227 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 \u2265 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 : (\u2191(\u2191(v1.nth i) : \u2115) : \u211d) = (\u2191(\u2191(v2.nth i) : \u2115) : \u211d) :=\n          begin\n            rw [\u2190 core_point1_corner_v1'_relationship i, \u2190 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 : (\u2191(v1.nth i) : \u2115) = (\u2191(v2.nth i) : \u2115) := 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 : \u2203 i : fin d, core_point1.nth i \u2260 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 \u2190 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 \u2227 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 \u2264 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 \u2260 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 \u2190 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 \u2227 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 \u2264 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 : \u2115} {s : \u2115} (d_ne_zero : d \u2260 0) (s_ne_zero : s \u2260 0) :\n  (\u2203 (T : set (point d)) (T_is_tiling : is_tiling T), tiling_faceshare_free T \u2227 is_periodic T_is_tiling \u2227 is_s_discrete s T) \u2192\n  has_clique (Keller_graph d s) (2 ^ d) :=\nbegin\n  rintro \u27e8T, T_is_tiling, T_faceshare_free, T_is_periodic, T_is_s_discrete\u27e9,\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    \u27e8T_shifted, T_shifted_is_tiling, T_shifted_faceshare_free, T_shifted_is_periodic, T_shifted_contains_only_s_points\u27e9,\n  have core_points_finset := build_core_points_finset \u27e8d, lt_add_one d\u27e9,\n  rcases core_points_finset with \u27e8core_points_finset, core_points_finset_card, core_points_finset_property\u27e9,\n  have goal_clique_with_info_map :\n    {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)} \u21aa\n    {v : vector (fin (2*s)) d // \u2203 p : point d, is_core_point p \u2227 \u2203 p_corner \u2208 T_shifted, \n      p \u2208 cube p_corner \u2227 (\u2200 alt_corner : point d, alt_corner \u2208 T_shifted \u2192 p \u2208 cube alt_corner \u2192 alt_corner = p_corner) \u2227\n      (\u2200 i : fin d, \u2191s * (vector.nth p_corner i) + \u2191s - 1 = (vector.nth v i).val)} :=\n    begin\n      let goal_clique_with_info_map_fn :\n        {p : point d // \u2200 (j : fin d), (j.val < d \u2192 vector.nth p j = 0 \u2228 vector.nth p j = 1) \u2227 (j.val \u2265 d \u2192 vector.nth p j = 0)} \u2192\n        {v : vector (fin (2*s)) d // \u2203 p : point d, is_core_point p \u2227 \u2203 p_corner \u2208 T_shifted, \n          p \u2208 cube p_corner \u2227 (\u2200 alt_corner : point d, alt_corner \u2208 T_shifted \u2192 p \u2208 cube alt_corner \u2192 alt_corner = p_corner) \u2227\n          (\u2200 i : fin d, \u2191s * (vector.nth p_corner i) + \u2191s - 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 \u2190 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 \u2190 mapped_p2_def at mapped_p2_property,\n          rw [\u2190 mapped_p1_def, \u2190 mapped_p2_def] at mapped_p1_eq_mapped_p2,\n          let p1_corner := (point_to_corner T_shifted_is_tiling \u2191p1).val,\n          have p1_corner_def : p1_corner = (point_to_corner T_shifted_is_tiling \u2191p1).val := by refl,\n          have p1_corner_property := (point_to_corner T_shifted_is_tiling \u2191p1).property,\n          rw \u2190 p1_corner_def at p1_corner_property,\n          rcases p1_corner_property with \u27e8p1_corner_in_T_shifted, p1_in_p1_corner, p1_corner_unique\u27e9,\n          let p2_corner := (point_to_corner T_shifted_is_tiling \u2191p2).val,\n          have p2_corner_def : p2_corner = (point_to_corner T_shifted_is_tiling \u2191p2).val := by refl,\n          have p2_corner_property := (point_to_corner T_shifted_is_tiling \u2191p2).property,\n          rw \u2190 p2_corner_def at p2_corner_property,\n          rcases p2_corner_property with \u27e8p2_corner_in_T_shifted, p2_in_p2_corner, p2_corner_unique\u27e9,\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, \u2190 p1_corner_def, \u2190 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 \u27e8p1_is_core_point, unneeded1\u27e9,\n          rcases p2.property i with \u27e8p2_is_core_point, unneeded2\u27e9,\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 // \u2203 p : point d, is_core_point p \u2227 \u2203 p_corner \u2208 T_shifted, \n      p \u2208 cube p_corner \u2227 (\u2200 alt_corner : point d, alt_corner \u2208 T_shifted \u2192 p \u2208 cube alt_corner \u2192 alt_corner = p_corner) \u2227\n      (\u2200 i : fin d, \u2191s * (vector.nth p_corner i) + \u2191s - 1 = (vector.nth v i).val)} \u21aa vector (fin (2*s)) d :=\n    begin\n      let remove_info_map_fn :\n        {v : vector (fin (2*s)) d // \u2203 p : point d, is_core_point p \u2227 \u2203 p_corner \u2208 T_shifted, \n          p \u2208 cube p_corner \u2227 (\u2200 alt_corner : point d, alt_corner \u2208 T_shifted \u2192 p \u2208 cube alt_corner \u2192 alt_corner = p_corner) \u2227\n          (\u2200 i : fin d, \u2191s * (vector.nth p_corner i) + \u2191s - 1 = (vector.nth v i).val)} \u2192 vector (fin (2*s)) d :=\n        \u03bb 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    \u27e8v1', \u27e8core_point1, core_point1_is_core_point, \u27e8core_point1_corner, core_point1_corner_in_T_shifted, \n    core_point1_in_core_point1_corner, core_point1_corner_unique, core_point1_corner_v1'_relationship\u27e9\u27e9, redundant, v1_def\u27e9,\n  clear redundant,\n  rcases v2_in_goal_clique with \n    \u27e8v2', \u27e8core_point2, core_point2_is_core_point, \u27e8core_point2_corner, core_point2_corner_in_T_shifted, \n    core_point2_in_core_point2_corner, core_point2_corner_unique, core_point2_corner_v2'_relationship\u27e9\u27e9, redundant, v2_def\u27e9,\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 : \u2203 i : fin d, \u2191(v1.nth i) = \u2191(v2.nth i) + s \u2228 \u2191(v2.nth i) = \u2191(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 \u27e8i, v1_eq_v2_add_s | v2_eq_v1_add_s\u27e9,\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            \u2191s * vector.nth core_point1_corner i + \u2191s - (1 : \u211d) = \u2191((v2.nth i).val) + \u2191s := \n            by exact_mod_cast core_point1_corner_v1'_relationship,\n          rw \u2190 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 (\u2191s * vector.nth core_point2_corner i + \u2191s - 1) \u2191s at core_point1_corner_v1'_relationship,\n          rw [sub_eq_add_neg, sub_eq_add_neg, add_assoc (\u2191s * vector.nth core_point2_corner i) \u2191s (-1), \u2190 add_assoc,\n            add_assoc (\u2191s * vector.nth core_point1_corner i) \u2191s (-1)] at core_point1_corner_v1'_relationship,\n          simp only [add_left_inj] at core_point1_corner_v1'_relationship,\n          have s_times_goal : \u2191s * vector.nth core_point1_corner i - \u2191s * vector.nth core_point2_corner i = \u2191s := by linarith,\n          rw \u2190 mul_sub_left_distrib at s_times_goal,\n          have s_times_goal_div_s : \u2191s * (vector.nth core_point1_corner i - vector.nth core_point2_corner i) / \u2191s = \u2191s / \u2191s :=\n            by rw s_times_goal,\n          have cast_s_ne_zero : \u2191s \u2260 (0 : \u211d) := 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 \u27e8j, i_ne_j_and_core_point1_eq_core_point2_at_j\u27e9,\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 \u2260 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, \u2190 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, \u2190 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          \u2191s * vector.nth core_point2_corner i + \u2191s - (1 : \u211d) = \u2191((v1.nth i).val) + \u2191s := \n          by exact_mod_cast core_point2_corner_v2'_relationship,\n        rw \u2190 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 (\u2191s * vector.nth core_point1_corner i + \u2191s - 1) \u2191s at core_point2_corner_v2'_relationship,\n        rw [sub_eq_add_neg, sub_eq_add_neg, add_assoc (\u2191s * vector.nth core_point1_corner i) \u2191s (-1), \u2190 add_assoc,\n          add_assoc (\u2191s * vector.nth core_point2_corner i) \u2191s (-1)] at core_point2_corner_v2'_relationship,\n        simp only [add_left_inj] at core_point2_corner_v2'_relationship,\n        have s_times_goal : \u2191s * vector.nth core_point2_corner i - \u2191s * vector.nth core_point1_corner i = \u2191s := by linarith,\n        rw \u2190 mul_sub_left_distrib at s_times_goal,\n        have s_times_goal_div_s : \u2191s * (vector.nth core_point2_corner i - vector.nth core_point1_corner i) / \u2191s = \u2191s / \u2191s :=\n          by rw s_times_goal,\n        have cast_s_ne_zero : \u2191s \u2260 (0 : \u211d) := 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 \u27e8j, i_ne_j_and_core_point1_eq_core_point2_at_j\u27e9,\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 \u2260 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 [\u2190 v2_eq_v1_at_j, \u2190 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 [\u2190 v2_eq_v1_at_j, \u2190 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 : \u2115} (d_gt_zero : d > 0) :\n  \u00achas_clique (Keller_graph d (2^(d-1))) (2^d) \u2192 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 \u27e8T, \u27e8T_is_tiling, T_is_periodic\u27e9, T_faceshare_free\u27e9,\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 \u2260 0 := by linarith,\n  have two_to_the_d_sub_one_ne_zero : 2^(d - 1) \u2260 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\u00e4rn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David W\u00e4rn\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 \u27f6 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 \u2192 V \u2192 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\u2081 v\u2082 u u\u2081 u\u2082\n\n/--\nA quiver `G` on a type `V` of vertices assigns to every pair `a b : V` of vertices\na type `a \u27f6 b` of arrows from `a` to `b`.\n\nFor graphs with no repeated edges, one can use `quiver.{0} V`, which ensures\n`a \u27f6 b : Prop`. For multigraphs, one can use `quiver.{v+1} V`, which ensures\n`a \u27f6 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 `\u27f6` notation instead.\n-/\nclass quiver (V : Type u) :=\n(hom : V \u2192 V \u2192 Sort v)\n\ninfixr ` \u27f6 `: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\u2081) [quiver.{v\u2081} V] (W : Type u\u2082) [quiver.{v\u2082} W] :=\n(obj [] : V \u2192 W)\n(map : \u03a0 {X Y : V}, (X \u27f6 Y) \u2192 (obj X \u27f6 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 := \u03bb X Y f, f, }\n\ninstance (V : Type*) [quiver V] : inhabited (prefunctor V V) := \u27e8id V\u27e9\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 := \u03bb X, G.obj (F.obj X),\n  map := \u03bb 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\u03a0 a b : V, set (a \u27f6 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 := \u03bb 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\u27e8\u03bb a b, H a b\u27e9\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) := \u27e8\u03bb a b, pempty\u27e9\n\n@[simp] lemma empty_arrow {V : Type u} (a b : empty V) : (a \u27f6 b) = pempty := rfl\n\ninstance {V} [quiver V] : has_bot (wide_subquiver V) := \u27e8\u03bb a b, \u2205\u27e9\ninstance {V} [quiver V] : has_top (wide_subquiver V) := \u27e8\u03bb a b, set.univ\u27e9\ninstance {V} [quiver V] : inhabited (wide_subquiver V) := \u27e8\u22a4\u27e9\n\n/-- `V\u1d52\u1d56` reverses the direction of all arrows of `V`. -/\ninstance opposite {V} [quiver V] : quiver V\u1d52\u1d56 :=\n\u27e8\u03bb a b, (unop b) \u27f6 (unop a)\u27e9\n\n/--\nThe opposite of an arrow in `V`.\n-/\ndef hom.op {V} [quiver V] {X Y : V} (f : X \u27f6 Y) : op Y \u27f6 op X := f\n/--\nGiven an arrow in `V\u1d52\u1d56`, we can take the \"unopposite\" back in `V`.\n-/\ndef hom.unop {V} [quiver V] {X Y : V\u1d52\u1d56} (f : X \u27f6 Y) : unop Y \u27f6 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\u27e8\u03bb a b : V, (a \u27f6 b) \u2295 (b \u27f6 a)\u27e9\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 \u27f6 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) \u2192 wide_subquiver V :=\n\u03bb H a b, { e | sum.inl e \u2208 H a b \u2228 sum.inr e \u2208 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 \u2243 set (total V) :=\n{ to_fun := \u03bb H, { e | e.hom \u2208 H e.left e.right },\n  inv_fun := \u03bb S a b, { e | total.mk a b e \u2208 S },\n  left_inv := \u03bb 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 \u2192 Sort (max (u+1) v)\n| nil  : path a\n| cons : \u03a0 {b c : V}, path b \u2192 (b \u27f6 c) \u2192 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 \u27f6 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} : \u03a0 {b : V}, path a b \u2192 \u2115\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 \u27f6 c) : (p.cons e).length = p.length + 1 := rfl\n\n/-- Composition of paths. -/\ndef comp {a b : V} : \u03a0 {c}, path a b \u2192 path b c \u2192 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 \u27f6 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} : \u2200 {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} : \u2200 {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\u2081} [quiver.{v\u2081} V] {W : Type u\u2082} [quiver.{v\u2082} W] (F : prefunctor V W)\n\n/-- The image of a path under a prefunctor. -/\ndef map_path {a : V} :\n  \u03a0 {b : V}, path a b \u2192 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 \u27f6 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  \u2200 {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 : \u03a0 (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*) := \u03a0 \u2983a b : V\u2984, (a \u27f6 b) \u2192 L\n\ninstance {V : Type u} [quiver V] (L) [inhabited L] : inhabited (labelling V L) :=\n\u27e8\u03bb a b e, default L\u27e9\n\n/-- To show that `[quiver V]` is an arborescence with root `r : V`, it suffices to\n  - provide a height function `V \u2192 \u2115` 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 \u2192 \u2115)\n  (height_lt : \u2200 \u2983a b\u2984, (a \u27f6 b) \u2192 height a < height b)\n  (unique_arrow : \u2200 \u2983a b c : V\u2984 (e : a \u27f6 c) (f : b \u27f6 c), a = b \u2227 e == f)\n  (root_or_arrow : \u2200 b, b = r \u2228 \u2203 a, nonempty (a \u27f6 b)) : arborescence V :=\n{ root := r,\n  unique_path := \u03bb b, \u27e8classical.inhabited_of_nonempty\n    begin\n      rcases (show \u2203 n, height b < n, from \u27e8_, lt_add_one _\u27e9) with \u27e8n, hn\u27e9,\n      induction n with n ih generalizing b,\n      { exact false.elim (nat.not_lt_zero _ hn) },\n      rcases root_or_arrow b with \u27e8\u27e8\u27e9\u27e9 | \u27e8a, \u27e8e\u27e9\u27e9,\n      { exact \u27e8path.nil\u27e9 },\n      { rcases ih a (lt_of_lt_of_le (height_lt e) (nat.lt_succ_iff.mp hn)) with \u27e8p\u27e9,\n        exact \u27e8p.cons e\u27e9 }\n    end,\n    begin\n      have height_le : \u2200 {a b}, path a b \u2192 height a \u2264 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 : \u2200 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 \u27e8\u27e8\u27e9, \u27e8\u27e9\u27e9, rw ih },\n    end \u27e9 }\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 : \u2200 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 \u2264 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\u03bb a b, { e | \u2203 p : path r a, shortest_path r b = p.cons e }\n\nnoncomputable instance geodesic_arborescence : arborescence (geodesic_subtree r) :=\narborescence_mk r (\u03bb a, (shortest_path r a).length)\n(by { rintros a b \u27e8e, p, h\u27e9,\n  rw [h, path.length_cons, nat.lt_succ_iff], apply shortest_path_spec })\n(by { rintros a b c \u27e8e, p, h\u27e9 \u27e8f, q, j\u27e9, cases h.symm.trans j, split; refl })\n(by { intro b, have : \u2203 p, shortest_path r b = p := \u27e8_, rfl\u27e9,\n  rcases this with \u27e8p, hp\u27e9, cases p with a _ p e,\n  { exact or.inl rfl }, { exact or.inr \u27e8a, \u27e8\u27e8e, p, hp\u27e9\u27e9\u27e9 } })\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' : \u03a0 {a b : V}, (a \u27f6 b) \u2192 (b \u27f6 a))\n\ninstance : has_reverse (symmetrify V) := \u27e8\u03bb a b e, e.swap\u27e9\n\nvariables {V} [has_reverse V]\n\n/-- Reverse the direction of an arrow. -/\ndef reverse {a b : V} : (a \u27f6 b) \u2192 (b \u27f6 a) := has_reverse.reverse'\n\n/-- Reverse the direction of a path. -/\ndef path.reverse {a : V} : \u03a0 {b}, path a b \u2192 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\u27e8\u03bb a b, nonempty (path (a : symmetrify V) (b : symmetrify V)),\n \u03bb a, \u27e8path.nil\u27e9,\n \u03bb a b \u27e8p\u27e9, \u27e8p.reverse\u27e9,\n \u03bb a b c \u27e8p\u27e9 \u27e8q\u27e9, \u27e8p.comp q\u27e9\u27e9\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 \u2192 weakly_connected_component V := quotient.mk'\n\ninstance : has_coe_t V (weakly_connected_component V) := \u27e8weakly_connected_component.mk\u27e9\ninstance [inhabited V] : inhabited (weakly_connected_component V) := \u27e8\u2191(default V)\u27e9\n\nprotected lemma eq (a b : V) :\n  (a : weakly_connected_component V) = b \u2194 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 {\u03b1 : Type u} [fintype \u03b1] (R : Type v) [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] : matrix \u03b1 \u03b1 R :=\n  sorry\n\n@[simp] theorem adj_matrix_apply {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] (v : \u03b1) (w : \u03b1) : adj_matrix R G v w = ite (adj G v w) 1 0 :=\n  rfl\n\n@[simp] theorem transpose_adj_matrix {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] : matrix.transpose (adj_matrix R G) = adj_matrix R G := sorry\n\n@[simp] theorem adj_matrix_dot_product {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] (v : \u03b1) (vec : \u03b1 \u2192 R) : matrix.dot_product (adj_matrix R G v) vec = finset.sum (neighbor_finset G v) fun (u : \u03b1) => vec u := sorry\n\n@[simp] theorem dot_product_adj_matrix {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] (v : \u03b1) (vec : \u03b1 \u2192 R) : matrix.dot_product vec (adj_matrix R G v) = finset.sum (neighbor_finset G v) fun (u : \u03b1) => vec u := sorry\n\n@[simp] theorem adj_matrix_mul_vec_apply {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] (v : \u03b1) (vec : \u03b1 \u2192 R) : matrix.mul_vec (adj_matrix R G) vec v = finset.sum (neighbor_finset G v) fun (u : \u03b1) => vec u := sorry\n\n@[simp] theorem adj_matrix_vec_mul_apply {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] (v : \u03b1) (vec : \u03b1 \u2192 R) : matrix.vec_mul vec (adj_matrix R G) v = finset.sum (neighbor_finset G v) fun (u : \u03b1) => vec u := sorry\n\n@[simp] theorem adj_matrix_mul_apply {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] (M : matrix \u03b1 \u03b1 R) (v : \u03b1) (w : \u03b1) : matrix.mul (adj_matrix R G) M v w = finset.sum (neighbor_finset G v) fun (u : \u03b1) => M u w := sorry\n\n@[simp] theorem mul_adj_matrix_apply {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] (M : matrix \u03b1 \u03b1 R) (v : \u03b1) (w : \u03b1) : matrix.mul M (adj_matrix R G) v w = finset.sum (neighbor_finset G w) fun (u : \u03b1) => M v u := sorry\n\ntheorem trace_adj_matrix {\u03b1 : Type u} [fintype \u03b1] (R : Type v) [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] : coe_fn (matrix.trace \u03b1 R R) (adj_matrix R G) = 0 := sorry\n\ntheorem adj_matrix_mul_self_apply_self {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] (G : simple_graph \u03b1) [DecidableRel (adj G)] (i : \u03b1) : matrix.mul (adj_matrix R G) (adj_matrix R G) i i = \u2191(degree G i) := sorry\n\n@[simp] theorem adj_matrix_mul_vec_const_apply {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] {G : simple_graph \u03b1} [DecidableRel (adj G)] {r : R} {v : \u03b1} : matrix.mul_vec (adj_matrix R G) (function.const \u03b1 r) v = \u2191(degree G v) * r := sorry\n\ntheorem adj_matrix_mul_vec_const_apply_of_regular {\u03b1 : Type u} [fintype \u03b1] {R : Type v} [semiring R] {G : simple_graph \u03b1} [DecidableRel (adj G)] {d : \u2115} {r : R} (hd : is_regular_of_degree G d) {v : \u03b1} : matrix.mul_vec (adj_matrix R G) (function.const \u03b1 r) v = \u2191d * 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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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\u00e9di Regularity Lemma\n\nThis file gathers the numerical facts required by the proof of Szemer\u00e9di's regularity lemma.\n\nThis entire file is internal to the proof of Szemer\u00e9di 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\u00e9di's regularity lemma.\n-/\n\n\nopen Finset Fintype Function Real\n\nopen BigOperators\n\nnamespace SzemerediRegularity\n\n/-- Auxiliary function for Szemer\u00e9di'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 : \u2115) : \u2115 :=\n  n * 4 ^ n\n#align szemeredi_regularity.step_bound SzemerediRegularity.stepBound\n\ntheorem le_stepBound : id \u2264 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 : \u2115} : 0 < stepBound n \u2194 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 \u2194 _ step_bound_pos\n#align szemeredi_regularity.step_bound_pos SzemerediRegularity.stepBound_pos\n\nend SzemerediRegularity\n\nopen SzemerediRegularity\n\nvariable {\u03b1 : Type _} [DecidableEq \u03b1] [Fintype \u03b1] {P : Finpartition (univ : Finset \u03b1)}\n  {u : Finset \u03b1} {\u03b5 : \u211d}\n\n-- mathport name: exprm\nlocal notation \"m\" => (card \u03b1 / stepBound P.parts.card : \u2115)\n\n-- mathport name: expra\nlocal notation \"a\" => (card \u03b1 / P.parts.card - m * 4 ^ P.parts.card : \u2115)\n\nnamespace Tactic\n\nopen Positivity\n\nprivate theorem eps_pos {\u03b5 : \u211d} {n : \u2115} (h : 100 \u2264 4 ^ n * \u03b5 ^ 5) : 0 < \u03b5 :=\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 \u03b1] (hP\u03b1 : P.parts.card * 16 ^ P.parts.card \u2264 card \u03b1) : 0 < m :=\n  Nat.div_pos ((Nat.mul_le_mul_left _ <| Nat.pow_le_pow_of_le_left (by norm_num) _).trans hP\u03b1) <|\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\u00e9di's regularity lemma. -/\n    unsafe\n  def\n    positivity_szemeredi_regularity\n    : expr \u2192 tactic strictness\n    |\n        q( $ ( n ) / stepBound ( Finpartition.parts $ ( P ) ) . card )\n        =>\n        do\n          let\n              p\n                \u2190\n                to_expr\n                    `\n                      `(\n                        ( Finpartition.parts $ ( P ) ) . card\n                            *\n                            16 ^ ( Finpartition.parts $ ( P ) ) . card\n                          \u2264\n                          $ ( n )\n                        )\n                  >>=\n                  find_assumption\n            positive <$> mk_app ` ` m_pos [ p ]\n      |\n        \u03b5\n        =>\n        do\n          let typ \u2190 infer_type \u03b5\n            unify typ q( \u211d )\n            let p \u2190 to_expr ` `( 100 \u2264 4 ^ _ * $ ( \u03b5 ) ^ 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 \u03b1] (hP\u03b1 : P.parts.card * 16 ^ P.parts.card \u2264 card \u03b1) : 0 < m := by\n  positivity\n#align szemeredi_regularity.m_pos SzemerediRegularity.m_pos\n\ntheorem coe_m_add_one_pos : 0 < (m : \u211d) + 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 \u03b1] (hP\u03b1 : P.parts.card * 16 ^ P.parts.card \u2264 card \u03b1) : (1 : \u211d) \u2264 m :=\n  Nat.one_le_cast.2 <| m_pos hP\u03b1\n#align szemeredi_regularity.one_le_m_coe SzemerediRegularity.one_le_m_coe\n\ntheorem eps_pow_five_pos (hP\u03b5 : 100 \u2264 4 ^ P.parts.card * \u03b5 ^ 5) : 0 < \u03b5 ^ 5 :=\n  pos_of_mul_pos_right ((by norm_num : (0 : \u211d) < 100).trans_le hP\u03b5) <| pow_nonneg (by norm_num) _\n#align szemeredi_regularity.eps_pow_five_pos SzemerediRegularity.eps_pow_five_pos\n\ntheorem eps_pos (hP\u03b5 : 100 \u2264 4 ^ P.parts.card * \u03b5 ^ 5) : 0 < \u03b5 :=\n  pow_bit1_pos_iff.1 <| eps_pow_five_pos hP\u03b5\n#align szemeredi_regularity.eps_pos SzemerediRegularity.eps_pos\n\ntheorem hundred_div_\u03b5_pow_five_le_m [Nonempty \u03b1] (hP\u03b1 : P.parts.card * 16 ^ P.parts.card \u2264 card \u03b1)\n    (hP\u03b5 : 100 \u2264 4 ^ P.parts.card * \u03b5 ^ 5) : 100 / \u03b5 ^ 5 \u2264 m :=\n  (div_le_of_nonneg_of_le_mul (eps_pow_five_pos hP\u03b5).le (by positivity) hP\u03b5).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, \u2190 mul_pow])\n#align szemeredi_regularity.hundred_div_\u03b5_pow_five_le_m SzemerediRegularity.hundred_div_\u03b5_pow_five_le_m\n\ntheorem hundred_le_m [Nonempty \u03b1] (hP\u03b1 : P.parts.card * 16 ^ P.parts.card \u2264 card \u03b1)\n    (hP\u03b5 : 100 \u2264 4 ^ P.parts.card * \u03b5 ^ 5) (h\u03b5 : \u03b5 \u2264 1) : 100 \u2264 m := by\n  exact_mod_cast\n    (hundred_div_\u03b5_pow_five_le_m hP\u03b1 hP\u03b5).trans'\n      (le_div_self (by norm_num) (by positivity) <| pow_le_one _ (by positivity) h\u03b5)\n#align szemeredi_regularity.hundred_le_m SzemerediRegularity.hundred_le_m\n\ntheorem a_add_one_le_four_pow_parts_card : a + 1 \u2264 4 ^ P.parts.card :=\n  by\n  have h : 1 \u2264 4 ^ P.parts.card := one_le_pow_of_one_le (by norm_num) _\n  rw [step_bound, \u2190 Nat.div_div_eq_div_mul, \u2190 Nat.le_sub_iff_right h, tsub_le_iff_left, \u2190\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\u2081 (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, \u2190 add_assoc, \u2190 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\u2081 SzemerediRegularity.card_aux\u2081\n\ntheorem card_aux\u2082 (hP : P.IsEquipartition) (hu : u \u2208 P.parts)\n    (hucard : \u00acu.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 \u2264 card \u03b1 / P.parts.card :=\n    by\n    rw [step_bound, \u2190 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, \u2190 add_assoc, \u2190 add_mul,\n    Nat.sub_add_cancel a_add_one_le_four_pow_parts_card, \u2190 add_assoc, mul_comm,\n    Nat.add_sub_of_le this, card_univ]\n#align szemeredi_regularity.card_aux\u2082 SzemerediRegularity.card_aux\u2082\n\ntheorem pow_mul_m_le_card_part (hP : P.IsEquipartition) (hu : u \u2208 P.parts) :\n    (4 : \u211d) ^ P.parts.card * m \u2264 u.card := by\n  norm_cast\n  rw [step_bound, \u2190 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 \u03b5) (l : \u2115)\n\n/-- Auxiliary function for Szemer\u00e9di's regularity lemma. The size of the partition by which we start\nblowing. -/\nnoncomputable def initialBound : \u2115 :=\n  max 7 <| max l <| \u230alog (100 / \u03b5 ^ 5) / log 4\u230b\u208a + 1\n#align szemeredi_regularity.initial_bound SzemerediRegularity.initialBound\n\ntheorem le_initialBound : l \u2264 initialBound \u03b5 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 \u2264 initialBound \u03b5 l :=\n  le_max_left _ _\n#align szemeredi_regularity.seven_le_initial_bound SzemerediRegularity.seven_le_initialBound\n\ntheorem initialBound_pos : 0 < initialBound \u03b5 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 {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5) (l : \u2115) :\n    100 < 4 ^ initialBound \u03b5 l * \u03b5 ^ 5 :=\n  by\n  rw [\u2190 rpow_nat_cast 4, \u2190 div_lt_iff (pow_pos h\u03b5 5), lt_rpow_iff_log_lt _ zero_lt_four, \u2190\n    div_lt_iff, initial_bound, Nat.cast_max, Nat.cast_max]\n  \u00b7 push_cast\n    exact lt_max_of_lt_right (lt_max_of_lt_right <| Nat.lt_floor_add_one _)\n  \u00b7 exact log_pos (by norm_num)\n  \u00b7 exact div_pos (by norm_num) (pow_pos h\u03b5 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\u00e9di's\nregularity lemma. -/\nnoncomputable def bound : \u2115 :=\n  (stepBound^[\u230a4 / \u03b5 ^ 5\u230b\u208a] <| initialBound \u03b5 l) *\n    16 ^ (stepBound^[\u230a4 / \u03b5 ^ 5\u230b\u208a] <| initialBound \u03b5 l)\n#align szemeredi_regularity.bound SzemerediRegularity.bound\n\ntheorem initialBound_le_bound : initialBound \u03b5 l \u2264 bound \u03b5 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 \u2264 bound \u03b5 l :=\n  (le_initialBound \u03b5 l).trans <| initialBound_le_bound \u03b5 l\n#align szemeredi_regularity.le_bound SzemerediRegularity.le_bound\n\ntheorem bound_pos : 0 < bound \u03b5 l :=\n  (initialBound_pos \u03b5 l).trans_le <| initialBound_le_bound \u03b5 l\n#align szemeredi_regularity.bound_pos SzemerediRegularity.bound_pos\n\nvariable {\u03b9 \ud835\udd5c : Type _} [LinearOrderedField \ud835\udd5c] (r : \u03b9 \u2192 \u03b9 \u2192 Prop) [DecidableRel r] {s t : Finset \u03b9}\n  {x : \ud835\udd5c}\n\ntheorem mul_sq_le_sum_sq (hst : s \u2286 t) (f : \u03b9 \u2192 \ud835\udd5c) (hs : x ^ 2 \u2264 ((\u2211 i in s, f i) / s.card) ^ 2)\n    (hs' : (s.card : \ud835\udd5c) \u2260 0) : (s.card : \ud835\udd5c) * x ^ 2 \u2264 \u2211 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 \u2286 t) (f : \u03b9 \u2192 \ud835\udd5c) (d : \ud835\udd5c) (hx : 0 \u2264 x)\n    (hs : x \u2264 |(\u2211 i in s, f i) / s.card - (\u2211 i in t, f i) / t.card|)\n    (ht : d \u2264 ((\u2211 i in t, f i) / t.card) ^ 2) :\n    d + s.card / t.card * x ^ 2 \u2264 (\u2211 i in t, f i ^ 2) / t.card :=\n  by\n  obtain hscard | hscard := (s.card.cast_nonneg : (0 : \ud835\udd5c) \u2264 s.card).eq_or_lt\n  \u00b7 simpa [\u2190 hscard] using ht.trans sum_div_card_sq_le_sum_sq_div_card\n  have htcard : (0 : \ud835\udd5c) < t.card := hscard.trans_le (Nat.cast_le.2 (card_le_of_subset hst))\n  have h\u2081 : x ^ 2 \u2264 ((\u2211 i in s, f i) / s.card - (\u2211 i in t, f i) / t.card) ^ 2 :=\n    sq_le_sq.2 (by rwa [abs_of_nonneg hx])\n  have h\u2082 : x ^ 2 \u2264 ((\u2211 i in s, f i - (\u2211 j in t, f j) / t.card) / s.card) ^ 2 :=\n    by\n    apply h\u2081.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 [\u2190 mul_div_right_comm, le_div_iff htcard, add_mul, div_mul_cancel _ htcard.ne']\n  have h\u2083 := mul_sq_le_sum_sq hst (fun i => f i - (\u2211 j in t, f j) / t.card) h\u2082 hscard.ne'\n  apply (add_le_add_left h\u2083 _).trans\n  simp [\u2190 mul_div_right_comm _ (t.card : \ud835\udd5c), sub_div' _ _ _ htcard.ne', \u2190 sum_div, \u2190 add_div,\n    mul_pow, div_le_iff (sq_pos_of_ne_zero _ htcard.ne'), sub_sq, sum_add_distrib, \u2190 sum_mul, \u2190\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 \u2192 tactic strictness\n  | q(SzemerediRegularity.initialBound $(\u03b5) $(l)) => positive <$> mk_app `` initial_bound_pos [\u03b5, l]\n  | q(SzemerediRegularity.bound $(\u03b5) $(l)) => positive <$> mk_app `` bound_pos [\u03b5, l]\n  | e =>\n    pp e >>=\n      fail \u2218\n        format.bracket \"The expression `\"\n          \"` isn't of the form `szemeredi_regularity.initial_bound \u03b5 l` nor `szemeredi_regularity.bound \u03b5 l`\"\n#align tactic.positivity_szemeredi_regularity_bound tactic.positivity_szemeredi_regularity_bound\n\nexample (\u03b5 : \u211d) (l : \u2115) : 0 < SzemerediRegularity.initialBound \u03b5 l := by positivity\n\nexample (\u03b5 : \u211d) (l : \u2115) : 0 < SzemerediRegularity.bound \u03b5 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 {\u03b1} :\n  List \u03b1 = List' ![\u03b1] :=\nby\n  rfl\n\nexample {\u0393} :\n  List (\u0393 0) = List' \u0393 :=\nby\n  rfl\n\n\n\n/-- If `a \u2208 as`, return `as` with (a single occurence of) `a` removed.\n    Otherwise, if `a \u2209 as`, return `none` -/\ndef List.is_rem (a : \u03b1) : List \u03b1 \u2192 List \u03b1 \u2192 Prop\n  | b::bs, c::cs  =>    (a = c  \u2227 bs = c::cs)\n                      \u2228 (b = c  \u2227 bs.is_rem a cs)\n  | _, _          => false\n\n\n/-- Equates lists up-to permutation -/\ndef List.perm : List \u03b1 \u2192 List \u03b1 \u2192 Prop\n  | [],    []  =>  true\n  | a::as, bs  =>  \u2203cs : List \u03b1, cs.is_rem a bs \u2227 as.perm cs\n  | _, _       =>  false\n\nabbrev List'.perm \u2983\u0393\u2984 : (@TypeFun.ofCurried 1 List) \u0393 \u2192 (TypeFun.ofCurried List) \u0393 \u2192 Prop\n  := List.perm\n\ndef MultiSet := MvQPF.Quot1 List'.perm\n\nnoncomputable instance : MvQPF MultiSet := MvQPF.relQuot List'.perm (\n  by \n    intros \u0393\u2081 \u0393\u2082 a b f h\u2081;\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\u2081;\n\n    case nil =>\n      simp[List'.perm, List.perm]\n\n    case cons a as b bs ih =>\n      rcases h\u2081 with \u27e8_|\u27e8c,cs\u27e9, h\u2081, h\u2082\u27e9\n      { contradiction }\n      dsimp[List.perm, List'.perm];\n\n      let cs' : List' \u0393\u2082.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\u2082` says that `\u03bb p : \u03b1 \u00d7 \u03b1, 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 `\u03b1` equipped with the Borel `\u03c3`-algebra, instances for `has_measurable_mul\u2082`\netc require `\u03b1` to have a second countable topology.\n\nWe define separate classes for `has_measurable_div`/`has_measurable_sub`\nbecause on some types (e.g., `\u2115`, `\u211d\u22650\u221e`) division and/or subtraction are not defined as `a * b\u207b\u00b9` /\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\u2082`.\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\u2082`. -/\nclass has_measurable_add (M : Type*) [measurable_space M] [has_add M] : Prop :=\n(measurable_const_add : \u2200 c : M, measurable ((+) c))\n(measurable_add_const : \u2200 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\u2082 (M : Type*) [measurable_space M] [has_add M] : Prop :=\n(measurable_add : measurable (\u03bb p : M \u00d7 M, p.1 + p.2))\n\nexport has_measurable_add\u2082 (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\u2082`. -/\n@[to_additive]\nclass has_measurable_mul (M : Type*) [measurable_space M] [has_mul M] : Prop :=\n(measurable_const_mul : \u2200 c : M, measurable ((*) c))\n(measurable_mul_const : \u2200 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\u2082]\nclass has_measurable_mul\u2082 (M : Type*) [measurable_space M] [has_mul M] : Prop :=\n(measurable_mul : measurable (\u03bb p : M \u00d7 M, p.1 * p.2))\n\nexport has_measurable_mul\u2082 (measurable_mul)\n  has_measurable_mul (measurable_const_mul measurable_mul_const)\n\nsection mul\n\nvariables {M \u03b1 : Type*} [measurable_space M] [has_mul M] {m : measurable_space \u03b1}\n  {f g : \u03b1 \u2192 M} {\u03bc : measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.const_mul [has_measurable_mul M] (hf : measurable f) (c : M) :\n  measurable (\u03bb 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 \u03bc) (c : M) :\n  ae_measurable (\u03bb x, c * f x) \u03bc :=\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 (\u03bb 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 \u03bc) (c : M) :\n  ae_measurable (\u03bb x, f x * c) \u03bc :=\n(measurable_mul_const c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.mul' [has_measurable_mul\u2082 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\u2082 M] (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb a, f a * g a) :=\nmeasurable_mul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.mul' [has_measurable_mul\u2082 M] (hf : ae_measurable f \u03bc)\n  (hg : ae_measurable g \u03bc) :\n  ae_measurable (f * g) \u03bc :=\nmeasurable_mul.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.mul [has_measurable_mul\u2082 M] (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  ae_measurable (\u03bb a, f a * g a) \u03bc :=\nmeasurable_mul.comp_ae_measurable (hf.prod_mk hg)\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_mul\u2082.to_has_measurable_mul [has_measurable_mul\u2082 M] :\n  has_measurable_mul M :=\n\u27e8\u03bb c, measurable_const.mul measurable_id, \u03bb c, measurable_id.mul measurable_const\u27e9\n\n@[to_additive]\ninstance pi.has_measurable_mul {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_mul (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_mul (\u03b1 i)] :\n  has_measurable_mul (\u03a0 i, \u03b1 i) :=\n\u27e8\u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).const_mul _,\n \u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).mul_const _\u27e9\n\n@[to_additive pi.has_measurable_add\u2082]\ninstance pi.has_measurable_mul\u2082 {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_mul (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_mul\u2082 (\u03b1 i)] :\n  has_measurable_mul\u2082 (\u03a0 i, \u03b1 i) :=\n\u27e8measurable_pi_iff.mpr $ \u03bb i, measurable_fst.eval.mul measurable_snd.eval\u27e9\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 `\u03b2 \u00d7 \u03b3 \u2192 \u03b2` given by `(x, y) \u21a6 x ^ y` is measurable. -/\nclass has_measurable_pow (\u03b2 \u03b3 : Type*) [measurable_space \u03b2] [measurable_space \u03b3] [has_pow \u03b2 \u03b3] :=\n(measurable_pow : measurable (\u03bb p : \u03b2 \u00d7 \u03b3, 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\u2082 M] : has_measurable_pow M \u2115 :=\n\u27e8measurable_from_prod_encodable $ \u03bb n, begin\n  induction n with n ih,\n  { simp only [pow_zero, \u2190pi.one_def, measurable_one] },\n  { simp only [pow_succ], exact measurable_id.mul ih }\nend\u27e9\n\nsection pow\n\nvariables {\u03b2 \u03b3 \u03b1 : Type*} [measurable_space \u03b2] [measurable_space \u03b3] [has_pow \u03b2 \u03b3]\n  [has_measurable_pow \u03b2 \u03b3] {m : measurable_space \u03b1} {\u03bc : measure \u03b1} {f : \u03b1 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3}\n\ninclude m\n\n@[measurability]\nlemma measurable.pow (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb x, f x ^ g x) :=\nmeasurable_pow.comp (hf.prod_mk hg)\n\n@[measurability]\nlemma ae_measurable.pow (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  ae_measurable (\u03bb x, f x ^ g x) \u03bc :=\nmeasurable_pow.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability]\nlemma measurable.pow_const (hf : measurable f) (c : \u03b3) :\n  measurable (\u03bb x, f x ^ c) :=\nhf.pow measurable_const\n\n@[measurability]\nlemma ae_measurable.pow_const (hf : ae_measurable f \u03bc) (c : \u03b3) :\n  ae_measurable (\u03bb x, f x ^ c) \u03bc :=\nhf.pow ae_measurable_const\n\n@[measurability]\nlemma measurable.const_pow (hg : measurable g) (c : \u03b2) :\n  measurable (\u03bb x, c ^ g x) :=\nmeasurable_const.pow hg\n\n@[measurability]\nlemma ae_measurable.const_pow (hg : ae_measurable g \u03bc) (c : \u03b2) :\n  ae_measurable (\u03bb x, c ^ g x) \u03bc :=\nae_measurable_const.pow hg\n\nomit m\n\nend pow\n\n/-- We say that a type `has_measurable_sub` if `(\u03bb x, c - x)` and `(\u03bb x, x - c)` are measurable\nfunctions. For a typeclass assuming measurability of `uncurry (-)` see `has_measurable_sub\u2082`. -/\nclass has_measurable_sub (G : Type*) [measurable_space G] [has_sub G] : Prop :=\n(measurable_const_sub : \u2200 c : G, measurable (\u03bb x, c - x))\n(measurable_sub_const : \u2200 c : G, measurable (\u03bb 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\u2082 (G : Type*) [measurable_space G] [has_sub G] : Prop :=\n(measurable_sub : measurable (\u03bb p : G \u00d7 G, p.1 - p.2))\n\nexport has_measurable_sub\u2082 (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\u2082`. -/\n@[to_additive] class has_measurable_div (G\u2080: Type*) [measurable_space G\u2080] [has_div G\u2080] : Prop :=\n(measurable_const_div : \u2200 c : G\u2080, measurable ((/) c))\n(measurable_div_const : \u2200 c : G\u2080, 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\u2082]\nclass has_measurable_div\u2082 (G\u2080: Type*) [measurable_space G\u2080] [has_div G\u2080] : Prop :=\n(measurable_div : measurable (\u03bb p : G\u2080\u00d7 G\u2080, p.1 / p.2))\n\nexport has_measurable_div\u2082 (measurable_div)\n\nsection div\n\nvariables {G \u03b1 : Type*} [measurable_space G] [has_div G] {m : measurable_space \u03b1} {f g : \u03b1 \u2192 G}\n  {\u03bc : measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.const_div [has_measurable_div G] (hf : measurable f) (c : G) :\n  measurable (\u03bb 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 \u03bc) (c : G) :\n  ae_measurable (\u03bb x, c / f x) \u03bc :=\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 (\u03bb 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 \u03bc) (c : G) :\n  ae_measurable (\u03bb x, f x / c) \u03bc :=\n(has_measurable_div.measurable_div_const c).comp_ae_measurable hf\n\n@[measurability, to_additive]\nlemma measurable.div' [has_measurable_div\u2082 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\u2082 G] (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb a, f a / g a) :=\nmeasurable_div.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.div' [has_measurable_div\u2082 G] (hf : ae_measurable f \u03bc)\n  (hg : ae_measurable g \u03bc) :\n  ae_measurable (f / g) \u03bc :=\nmeasurable_div.comp_ae_measurable (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.div [has_measurable_div\u2082 G] (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  ae_measurable (\u03bb a, f a / g a) \u03bc :=\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\u2082.to_has_measurable_div [has_measurable_div\u2082 G] :\n  has_measurable_div G :=\n\u27e8\u03bb c, measurable_const.div measurable_id, \u03bb c, measurable_id.div measurable_const\u27e9\n\n@[to_additive]\ninstance pi.has_measurable_div {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_div (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_div (\u03b1 i)] :\n  has_measurable_div (\u03a0 i, \u03b1 i) :=\n\u27e8\u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).const_div _,\n \u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).div_const _\u27e9\n\n@[to_additive pi.has_measurable_sub\u2082]\ninstance pi.has_measurable_div\u2082 {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_div (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_div\u2082 (\u03b1 i)] :\n  has_measurable_div\u2082 (\u03a0 i, \u03b1 i) :=\n\u27e8measurable_pi_iff.mpr $ \u03bb i, measurable_fst.eval.div measurable_snd.eval\u27e9\n\n@[measurability]\nlemma measurable_set_eq_fun {m : measurable_space \u03b1} {E} [measurable_space E] [add_group E]\n  [measurable_singleton_class E] [has_measurable_sub\u2082 E] {f g : \u03b1 \u2192 E}\n  (hf : measurable f) (hg : measurable g) :\n  measurable_set {x | f x = g x} :=\nbegin\n  suffices h_set_eq : {x : \u03b1 | 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 {\u03b1 E} {m m0 : measurable_space \u03b1} {\u03bc : measure \u03b1}\n  [measurable_space E] [add_group E] [measurable_singleton_class E] [has_measurable_sub\u2082 E]\n  (hm : m \u2264 m0) {f g : \u03b1 \u2192 E} (hf : measurable[m] f) (hg : measurable[m] g)\n  (hfg : f =\u1d50[\u03bc] g) :\n  f =\u1da0[@measure.ae \u03b1 m (\u03bc.trim hm)] g :=\nbegin\n  rwa [filter.eventually_eq, ae_iff, trim_measurable_set_eq hm _],\n  exact (@measurable_set.compl \u03b1 _ m (@measurable_set_eq_fun \u03b1 m E _ _ _ _ _ _ hf hg)),\nend\n\nend div\n\n/-- We say that a type `has_measurable_neg` if `x \u21a6 -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 \u2192 G))\n\n/-- We say that a type `has_measurable_inv` if `x \u21a6 x\u207b\u00b9` 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 \u2192 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 := \u03bb c,\n    by { convert (measurable_inv.const_mul c), ext1, apply div_eq_mul_inv },\n  measurable_div_const := \u03bb c,\n    by { convert (measurable_id.mul_const c\u207b\u00b9), ext1, apply div_eq_mul_inv } }\n\nsection inv\n\nvariables {G \u03b1 : Type*} [has_inv G] [measurable_space G] [has_measurable_inv G]\n  {m : measurable_space \u03b1} {f : \u03b1 \u2192 G} {\u03bc : measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.inv (hf : measurable f) : measurable (\u03bb x, (f x)\u207b\u00b9) := measurable_inv.comp hf\n\n@[measurability, to_additive]\nlemma ae_measurable.inv (hf : ae_measurable f \u03bc) : ae_measurable (\u03bb x, (f x)\u207b\u00b9) \u03bc :=\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 : \u03b1 \u2192 G} : measurable (\u03bb x, (f x)\u207b\u00b9) \u2194 measurable f :=\n\u27e8\u03bb h, by simpa only [inv_inv] using h.inv, \u03bb h, h.inv\u27e9\n\n@[simp, to_additive] lemma ae_measurable_inv_iff {G : Type*} [group G] [measurable_space G]\n  [has_measurable_inv G] {f : \u03b1 \u2192 G} :\n  ae_measurable (\u03bb x, (f x)\u207b\u00b9) \u03bc \u2194 ae_measurable f \u03bc :=\n\u27e8\u03bb h, by simpa only [inv_inv] using h.inv, \u03bb h, h.inv\u27e9\n\n@[simp] lemma measurable_inv_iff\u2080 {G\u2080 : Type*} [group_with_zero G\u2080]\n  [measurable_space G\u2080] [has_measurable_inv G\u2080] {f : \u03b1 \u2192 G\u2080} :\n  measurable (\u03bb x, (f x)\u207b\u00b9) \u2194 measurable f :=\n\u27e8\u03bb h, by simpa only [inv_inv] using h.inv, \u03bb h, h.inv\u27e9\n\n@[simp] lemma ae_measurable_inv_iff\u2080 {G\u2080 : Type*} [group_with_zero G\u2080]\n  [measurable_space G\u2080] [has_measurable_inv G\u2080] {f : \u03b1 \u2192 G\u2080} :\n  ae_measurable (\u03bb x, (f x)\u207b\u00b9) \u03bc \u2194 ae_measurable f \u03bc :=\n\u27e8\u03bb h, by simpa only [inv_inv] using h.inv, \u03bb h, h.inv\u27e9\n\nomit m\n\n@[to_additive]\ninstance pi.has_measurable_inv {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_inv (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_inv (\u03b1 i)] :\n  has_measurable_inv (\u03a0 i, \u03b1 i) :=\n\u27e8measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).inv\u27e9\n\n@[to_additive] lemma measurable_set.inv {s : set G} (hs : measurable_set s) : measurable_set s\u207b\u00b9 :=\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\u2082 G] [has_measurable_inv G] :\n  has_measurable_pow G \u2124 :=\n\u27e8measurable_from_prod_encodable $ \u03bb 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\u27e9\n\n@[priority 100, to_additive]\ninstance has_measurable_div\u2082_of_mul_inv (G : Type*) [measurable_space G]\n  [div_inv_monoid G] [has_measurable_mul\u2082 G] [has_measurable_inv G] :\n  has_measurable_div\u2082 G :=\n\u27e8by { simp only [div_eq_mul_inv], exact measurable_fst.mul measurable_snd.inv }\u27e9\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_vadd` if for each `c` the map `x \u21a6 c +\u1d65 x`\nis a measurable function and for each `x` the map `c \u21a6 c +\u1d65 x` is a measurable function. -/\nclass has_measurable_vadd (M \u03b1 : Type*) [has_vadd M \u03b1] [measurable_space M] [measurable_space \u03b1] :\n  Prop :=\n(measurable_const_vadd : \u2200 c : M, measurable ((+\u1d65) c : \u03b1 \u2192 \u03b1))\n(measurable_vadd_const : \u2200 x : \u03b1, measurable (\u03bb c : M, c +\u1d65 x))\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_smul` if for each `c` the map `x \u21a6 c \u2022 x`\nis a measurable function and for each `x` the map `c \u21a6 c \u2022 x` is a measurable function. -/\n@[to_additive]\nclass has_measurable_smul (M \u03b1 : Type*) [has_scalar M \u03b1] [measurable_space M] [measurable_space \u03b1] :\n  Prop :=\n(measurable_const_smul : \u2200 c : M, measurable ((\u2022) c : \u03b1 \u2192 \u03b1))\n(measurable_smul_const : \u2200 x : \u03b1, measurable (\u03bb c : M, c \u2022 x))\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_vadd\u2082` if the map\n`(c, x) \u21a6 c +\u1d65 x` is a measurable function. -/\nclass has_measurable_vadd\u2082 (M \u03b1 : Type*) [has_vadd M \u03b1] [measurable_space M]\n  [measurable_space \u03b1] : Prop :=\n(measurable_vadd : measurable (function.uncurry (+\u1d65) : M \u00d7 \u03b1 \u2192 \u03b1))\n\n/-- We say that the action of `M` on `\u03b1` `has_measurable_smul\u2082` if the map\n`(c, x) \u21a6 c \u2022 x` is a measurable function. -/\n@[to_additive has_measurable_vadd\u2082]\nclass has_measurable_smul\u2082 (M \u03b1 : Type*) [has_scalar M \u03b1] [measurable_space M]\n  [measurable_space \u03b1] : Prop :=\n(measurable_smul : measurable (function.uncurry (\u2022) : M \u00d7 \u03b1 \u2192 \u03b1))\n\nexport has_measurable_smul (measurable_const_smul measurable_smul_const)\n  has_measurable_smul\u2082 (measurable_smul)\nexport has_measurable_vadd (measurable_const_vadd measurable_vadd_const)\n  has_measurable_vadd\u2082 (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\u27e8measurable_id.const_mul, measurable_id.mul_const\u27e9\n\n@[to_additive]\ninstance has_measurable_smul\u2082_of_mul (M : Type*) [has_mul M] [measurable_space M]\n  [has_measurable_mul\u2082 M] :\n  has_measurable_smul\u2082 M M :=\n\u27e8measurable_mul\u27e9\n\n@[to_additive] instance submonoid.has_measurable_smul {M \u03b1} [measurable_space M]\n  [measurable_space \u03b1] [monoid M] [mul_action M \u03b1] [has_measurable_smul M \u03b1] (s : submonoid M) :\n  has_measurable_smul s \u03b1 :=\n\u27e8\u03bb c, by simpa only using measurable_const_smul (c : M),\n  \u03bb x, (measurable_smul_const x : measurable (\u03bb c : M, c \u2022 x)).comp measurable_subtype_coe\u27e9\n\n@[to_additive] instance subgroup.has_measurable_smul {G \u03b1} [measurable_space G]\n  [measurable_space \u03b1] [group G] [mul_action G \u03b1] [has_measurable_smul G \u03b1] (s : subgroup G) :\n  has_measurable_smul s \u03b1 :=\ns.to_submonoid.has_measurable_smul\n\nsection smul\n\nvariables {M \u03b2 \u03b1 : Type*} [measurable_space M] [measurable_space \u03b2] [has_scalar M \u03b2]\n  {m : measurable_space \u03b1} {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 \u03b2}\n\ninclude m\n\n@[measurability, to_additive]\nlemma measurable.smul [has_measurable_smul\u2082 M \u03b2] (hf : measurable f) (hg : measurable g) :\n  measurable (\u03bb x, f x \u2022 g x) :=\nmeasurable_smul.comp (hf.prod_mk hg)\n\n@[measurability, to_additive]\nlemma ae_measurable.smul [has_measurable_smul\u2082 M \u03b2]\n  {\u03bc : measure \u03b1} (hf : ae_measurable f \u03bc) (hg : ae_measurable g \u03bc) :\n  ae_measurable (\u03bb x, f x \u2022 g x) \u03bc :=\nhas_measurable_smul\u2082.measurable_smul.comp_ae_measurable (hf.prod_mk hg)\n\nomit m\n\n@[priority 100, to_additive]\ninstance has_measurable_smul\u2082.to_has_measurable_smul [has_measurable_smul\u2082 M \u03b2] :\n  has_measurable_smul M \u03b2 :=\n\u27e8\u03bb c, measurable_const.smul measurable_id, \u03bb y, measurable_id.smul measurable_const\u27e9\n\ninclude m\n\nvariables [has_measurable_smul M \u03b2] {\u03bc : measure \u03b1}\n\n@[measurability, to_additive]\nlemma measurable.smul_const (hf : measurable f) (y : \u03b2) :\n  measurable (\u03bb x, f x \u2022 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 \u03bc) (y : \u03b2) :\n  ae_measurable (\u03bb x, f x \u2022 y) \u03bc :=\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 (\u03bb x, c \u2022 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 \u2022 g) :=\nhg.const_smul' c\n\n@[measurability, to_additive]\nlemma ae_measurable.const_smul' (hg : ae_measurable g \u03bc) (c : M) :\n  ae_measurable (\u03bb x, c \u2022 g x) \u03bc :=\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 \u03bc) (c : M) :\n  ae_measurable (c \u2022 g) \u03bc :=\nhf.const_smul' c\n\nomit m\n\n@[to_additive]\ninstance pi.has_measurable_smul {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u2200 i, has_scalar M (\u03b1 i)]\n  [\u2200 i, measurable_space (\u03b1 i)] [\u2200 i, has_measurable_smul M (\u03b1 i)] :\n  has_measurable_smul M (\u03a0 i, \u03b1 i) :=\n\u27e8\u03bb g, measurable_pi_iff.mpr $ \u03bb i, (measurable_pi_apply i).const_smul _,\n \u03bb g, measurable_pi_iff.mpr $ \u03bb i, measurable_smul_const _\u27e9\n\n/-- `add_monoid.has_scalar_nat` is measurable. -/\ninstance add_monoid.has_measurable_smul_nat\u2082 (M : Type*) [add_monoid M] [measurable_space M]\n  [has_measurable_add\u2082 M] : has_measurable_smul\u2082 \u2115 M :=\n\u27e8begin\n  suffices : measurable (\u03bb p : M \u00d7 \u2115, p.2 \u2022 p.1),\n  { apply this.comp measurable_swap, },\n  refine measurable_from_prod_encodable (\u03bb n, _),\n  induction n with n ih,\n  { simp only [zero_smul, \u2190pi.zero_def, measurable_zero] },\n  { simp only [succ_nsmul], exact measurable_id.add ih }\nend\u27e9\n\n/-- `sub_neg_monoid.has_scalar_int` is measurable. -/\ninstance sub_neg_monoid.has_measurable_smul_int\u2082 (M : Type*) [sub_neg_monoid M] [measurable_space M]\n  [has_measurable_add\u2082 M] [has_measurable_neg M] : has_measurable_smul\u2082 \u2124 M :=\n\u27e8begin\n  suffices : measurable (\u03bb p : M \u00d7 \u2124, p.2 \u2022 p.1),\n  { apply this.comp measurable_swap, },\n  refine measurable_from_prod_encodable (\u03bb 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\u27e9\n\nend smul\n\nsection mul_action\n\nvariables {M \u03b2 \u03b1 : Type*} [measurable_space M] [measurable_space \u03b2] [monoid M] [mul_action M \u03b2]\n  [has_measurable_smul M \u03b2] [measurable_space \u03b1] {f : \u03b1 \u2192 \u03b2} {\u03bc : measure \u03b1}\n\nvariables {G : Type*} [group G] [measurable_space G] [mul_action G \u03b2]\n  [has_measurable_smul G \u03b2]\n\n@[to_additive]\nlemma measurable_const_smul_iff (c : G) :\n  measurable (\u03bb x, c \u2022 f x) \u2194 measurable f :=\n\u27e8\u03bb h, by simpa only [inv_smul_smul] using h.const_smul' c\u207b\u00b9, \u03bb h, h.const_smul c\u27e9\n\n@[to_additive]\nlemma ae_measurable_const_smul_iff (c : G) :\n  ae_measurable (\u03bb x, c \u2022 f x) \u03bc \u2194 ae_measurable f \u03bc :=\n\u27e8\u03bb h, by simpa only [inv_smul_smul] using h.const_smul' c\u207b\u00b9, \u03bb h, h.const_smul c\u27e9\n\n@[to_additive]\ninstance : measurable_space M\u02e3 := measurable_space.comap (coe : M\u02e3 \u2192 M) \u2039_\u203a\n\n@[to_additive]\ninstance units.has_measurable_smul : has_measurable_smul M\u02e3 \u03b2 :=\n{ measurable_const_smul := \u03bb c, (measurable_const_smul (c : M) : _),\n  measurable_smul_const := \u03bb x,\n    (measurable_smul_const x : measurable (\u03bb c : M, c \u2022 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 (\u03bb x, c \u2022 f x) \u2194 measurable f :=\nlet \u27e8u, hu\u27e9 := hc in hu \u25b8 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 (\u03bb x, c \u2022 f x) \u03bc \u2194 ae_measurable f \u03bc :=\nlet \u27e8u, hu\u27e9 := hc in hu \u25b8 ae_measurable_const_smul_iff u\n\nvariables {G\u2080 : Type*} [group_with_zero G\u2080] [measurable_space G\u2080] [mul_action G\u2080 \u03b2]\n  [has_measurable_smul G\u2080 \u03b2]\n\nlemma measurable_const_smul_iff\u2080 {c : G\u2080} (hc : c \u2260 0) :\n  measurable (\u03bb x, c \u2022 f x) \u2194 measurable f :=\n(is_unit.mk0 c hc).measurable_const_smul_iff\n\nlemma ae_measurable_const_smul_iff\u2080 {c : G\u2080} (hc : c \u2260 0) :\n  ae_measurable (\u03bb x, c \u2022 f x) \u03bc \u2194 ae_measurable f \u03bc :=\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 {\u03b1 : Type*} [h : measurable_space \u03b1] : measurable_space \u03b1\u1d50\u1d52\u1d56 := measurable_space.map op h\n\n@[to_additive]\nlemma measurable_mul_op {\u03b1 : Type*} [measurable_space \u03b1] : measurable (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) := \u03bb s, id\n\n@[to_additive]\nlemma measurable_mul_unop {\u03b1 : Type*} [measurable_space \u03b1] : measurable (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) := \u03bb s, id\n\n@[to_additive]\ninstance {M : Type*} [has_mul M] [measurable_space M] [has_measurable_mul M] :\n  has_measurable_mul M\u1d50\u1d52\u1d56 :=\n\u27e8\u03bb c, measurable_mul_op.comp (measurable_mul_unop.mul_const _),\n  \u03bb c, measurable_mul_op.comp (measurable_mul_unop.const_mul _)\u27e9\n\n@[to_additive]\ninstance {M : Type*} [has_mul M] [measurable_space M] [has_measurable_mul\u2082 M] :\n  has_measurable_mul\u2082 M\u1d50\u1d52\u1d56 :=\n\u27e8measurable_mul_op.comp ((measurable_mul_unop.comp measurable_snd).mul\n  (measurable_mul_unop.comp measurable_fst))\u27e9\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance has_measurable_smul.op {M \u03b1} [measurable_space M]\n  [measurable_space \u03b1] [has_scalar M \u03b1] [has_scalar M\u1d50\u1d52\u1d56 \u03b1] [is_central_scalar M \u03b1]\n  [has_measurable_smul M \u03b1] : has_measurable_smul M\u1d50\u1d52\u1d56 \u03b1 :=\n\u27e8 mul_opposite.rec $ \u03bb c, show measurable (\u03bb x, op c \u2022 x),\n                          by simpa only [op_smul_eq_smul] using measurable_const_smul c,\n  \u03bb x, show measurable (\u03bb c, op (unop c) \u2022 x),\n       by simpa only [op_smul_eq_smul] using (measurable_smul_const x).comp measurable_mul_unop\u27e9\n\n/-- If a scalar is central, then its right action is measurable when its left action is. -/\ninstance has_measurable_smul\u2082.op {M \u03b1} [measurable_space M]\n  [measurable_space \u03b1] [has_scalar M \u03b1] [has_scalar M\u1d50\u1d52\u1d56 \u03b1] [is_central_scalar M \u03b1]\n  [has_measurable_smul\u2082 M \u03b1] : has_measurable_smul\u2082 M\u1d50\u1d52\u1d56 \u03b1 :=\n\u27e8show measurable (\u03bb x : M\u1d50\u1d52\u1d56 \u00d7 \u03b1, op (unop x.1) \u2022 x.2), begin\n  simp_rw op_smul_eq_smul,\n  refine (measurable_mul_unop.comp measurable_fst).smul measurable_snd,\nend\u27e9\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\u1d50\u1d52\u1d56 M :=\n\u27e8\u03bb c, measurable_mul_const (unop c), \u03bb x, measurable_mul_unop.const_mul x\u27e9\n\n@[to_additive]\ninstance has_measurable_smul\u2082_opposite_of_mul {M : Type*} [has_mul M] [measurable_space M]\n  [has_measurable_mul\u2082 M] : has_measurable_smul\u2082 M\u1d50\u1d52\u1d56 M :=\n\u27e8measurable_snd.mul (measurable_mul_unop.comp measurable_fst)\u27e9\n\nend opposite\n\n/-!\n### Big operators: `\u220f` and `\u2211`\n-/\n\nsection monoid\nvariables {M \u03b1 : Type*} [monoid M] [measurable_space M] [has_measurable_mul\u2082 M]\n  {m : measurable_space \u03b1} {\u03bc : measure \u03b1}\n\ninclude m\n\n@[measurability, to_additive]\nlemma list.measurable_prod' (l : list (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 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 (\u03b1 \u2192 M))\n  (hl : \u2200 f \u2208 l, ae_measurable f \u03bc) : ae_measurable l.prod \u03bc :=\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 (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, measurable f) :\n  measurable (\u03bb x, (l.map (\u03bb f : \u03b1 \u2192 M, f x)).prod) :=\nby simpa only [\u2190 pi.list_prod_apply] using l.measurable_prod' hl\n\n@[measurability, to_additive]\nlemma list.ae_measurable_prod (l : list (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, ae_measurable f \u03bc) :\n  ae_measurable (\u03bb x, (l.map (\u03bb f : \u03b1 \u2192 M, f x)).prod) \u03bc :=\nby simpa only [\u2190 pi.list_prod_apply] using l.ae_measurable_prod' hl\n\nomit m\n\nend monoid\n\nsection comm_monoid\nvariables {M \u03b9 \u03b1 : Type*} [comm_monoid M] [measurable_space M] [has_measurable_mul\u2082 M]\n  {m : measurable_space \u03b1} {\u03bc : measure \u03b1} {f : \u03b9 \u2192 \u03b1 \u2192 M}\n\ninclude m\n\n@[measurability, to_additive]\nlemma multiset.measurable_prod' (l : multiset (\u03b1 \u2192 M)) (hl : \u2200 f \u2208 l, measurable f) :\n  measurable l.prod :=\nby { rcases l with \u27e8l\u27e9, simpa using l.measurable_prod' (by simpa using hl) }\n\n@[measurability, to_additive]\nlemma multiset.ae_measurable_prod' (l : multiset (\u03b1 \u2192 M))\n  (hl : \u2200 f \u2208 l, ae_measurable f \u03bc) : ae_measurable l.prod \u03bc :=\nby { rcases l with \u27e8l\u27e9, simpa using l.ae_measurable_prod' (by simpa using hl) }\n\n@[measurability, to_additive]\nlemma multiset.measurable_prod (s : multiset (\u03b1 \u2192 M)) (hs : \u2200 f \u2208 s, measurable f) :\n  measurable (\u03bb x, (s.map (\u03bb f : \u03b1 \u2192 M, f x)).prod) :=\nby simpa only [\u2190 pi.multiset_prod_apply] using s.measurable_prod' hs\n\n@[measurability, to_additive]\nlemma multiset.ae_measurable_prod (s : multiset (\u03b1 \u2192 M))\n  (hs : \u2200 f \u2208 s, ae_measurable f \u03bc) : ae_measurable (\u03bb x, (s.map (\u03bb f : \u03b1 \u2192 M, f x)).prod) \u03bc :=\nby simpa only [\u2190 pi.multiset_prod_apply] using s.ae_measurable_prod' hs\n\n@[measurability, to_additive]\nlemma finset.measurable_prod' (s : finset \u03b9) (hf : \u2200i \u2208 s, measurable (f i)) :\n  measurable (\u220f i in s, f i) :=\nfinset.prod_induction _ _ (\u03bb _ _, measurable.mul) (@measurable_one M _ _ _ _) hf\n\n@[measurability, to_additive]\nlemma finset.measurable_prod (s : finset \u03b9) (hf : \u2200i \u2208 s, measurable (f i)) :\n  measurable (\u03bb a, \u220f i in s, f i a) :=\nby simpa only [\u2190 finset.prod_apply] using s.measurable_prod' hf\n\n@[measurability, to_additive]\nlemma finset.ae_measurable_prod' (s : finset \u03b9) (hf : \u2200i \u2208 s, ae_measurable (f i) \u03bc) :\n  ae_measurable (\u220f i in s, f i) \u03bc :=\nmultiset.ae_measurable_prod' _ $\n  \u03bb g hg, let \u27e8i, hi, hg\u27e9 := multiset.mem_map.1 hg in (hg \u25b8 hf _ hi)\n\n@[measurability, to_additive]\nlemma finset.ae_measurable_prod (s : finset \u03b9) (hf : \u2200i \u2208 s, ae_measurable (f i) \u03bc) :\n  ae_measurable (\u03bb a, \u220f i in s, f i a) \u03bc :=\nby simpa only [\u2190 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 { \u03b1 : Type u}\n\n@[simp]\ntheorem nil_eq_cons (a : \u03b1) (l : list \u03b1) : nil = (a :: l) \u2194 false :=\nbegin\n  simp,\n  contradiction,\nend\n\n@[simp]\ntheorem cons_eq_nil (a : \u03b1) (l : list \u03b1) : (a :: l) = nil \u2194 false :=\nbegin\n  simp,\n  contradiction,\nend\n\n@[simp]\ntheorem cons_eq_cons (a : \u03b1) (x : list \u03b1)  (b : \u03b1) (y : list \u03b1) : (a :: x) = (b :: y) \u2194 a = b \u2227 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 \u03b1 \u03b2` a.k.a. `\u03b1 \u2243 \u03b2`: a bijective map `\u03b1 \u2192 \u03b2` 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 \u03b1`: the group of permutations `\u03b1 \u2243 \u03b1`. 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 \u03b1` is the identity map interpreted as `\u03b1 \u2243 \u03b1`;\n\n  - `equiv.sum_equiv_sigma_bool` is the canonical equivalence between the sum of two types `\u03b1 \u2295 \u03b2`\n    and the sigma-type `\u03a3 b : bool, cond b \u03b1 \u03b2`;\n\n  - `equiv.prod_sum_distrib : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243 (\u03b1 \u00d7 \u03b2) \u2295 (\u03b1 \u00d7 \u03b3)` 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 : \u03b2 \u2243 \u03b1` is the inverse of `e : \u03b1 \u2243 \u03b2`;\n\n  - `equiv.trans e\u2081 e\u2082 : \u03b1 \u2243 \u03b3` is the composition of `e\u2081 : \u03b1 \u2243 \u03b2` and `e\u2082 : \u03b2 \u2243 \u03b3` (note the order\n    of the arguments!);\n\n  - `equiv.prod_congr ea eb : \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082`: combine two equivalences `ea : \u03b1\u2081 \u2243 \u03b1\u2082` and\n    `eb : \u03b2\u2081 \u2243 \u03b2\u2082` 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 : \u03b1 \u2243 \u03b2` and `[inhabited \u03b2]` and returns `inhabited \u03b1`;\n  - `equiv.unique` takes `e : \u03b1 \u2243 \u03b2` and `[unique \u03b2]` and returns `unique \u03b1`;\n  - `equiv.decidable_eq` takes `e : \u03b1 \u2243 \u03b2` and `[decidable_eq \u03b2]` and returns `decidable_eq \u03b1`.\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/-- `\u03b1 \u2243 \u03b2` is the type of functions from `\u03b1 \u2192 \u03b2` with a two-sided inverse. -/\nstructure equiv (\u03b1 : Sort u_1) (\u03b2 : Sort u_2) where\n  to_fun : \u03b1 \u2192 \u03b2\n  inv_fun : \u03b2 \u2192 \u03b1\n  left_inv : function.left_inverse inv_fun to_fun\n  right_inv : function.right_inverse inv_fun to_fun\n\ninfixl:25 \" \u2243 \" => Mathlib.equiv\n\n/-- Convert an involutive function `f` to an equivalence with `to_fun = inv_fun = f`. -/\ndef function.involutive.to_equiv {\u03b1 : Sort u} (f : \u03b1 \u2192 \u03b1) (h : function.involutive f) : \u03b1 \u2243 \u03b1 :=\n  equiv.mk f f (function.involutive.left_inverse h) (function.involutive.right_inverse h)\n\nnamespace equiv\n\n\n/-- `perm \u03b1` is the type of bijections from `\u03b1` to itself. -/\ndef perm (\u03b1 : Sort u_1) := \u03b1 \u2243 \u03b1\n\nprotected instance has_coe_to_fun {\u03b1 : Sort u} {\u03b2 : Sort v} : has_coe_to_fun (\u03b1 \u2243 \u03b2) :=\n  has_coe_to_fun.mk (fun (x : \u03b1 \u2243 \u03b2) => \u03b1 \u2192 \u03b2) to_fun\n\n@[simp] theorem coe_fn_mk {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1)\n    (l : function.left_inverse g f) (r : function.right_inverse g f) : \u21d1(mk f g l r) = f :=\n  rfl\n\n/-- The map `coe_fn : (r \u2243 s) \u2192 (r \u2192 s)` is injective. -/\ntheorem injective_coe_fn {\u03b1 : Sort u} {\u03b2 : Sort v} :\n    function.injective fun (e : \u03b1 \u2243 \u03b2) (x : \u03b1) => coe_fn e x :=\n  sorry\n\n@[simp] protected theorem coe_inj {\u03b1 : Sort u} {\u03b2 : Sort v} {e\u2081 : \u03b1 \u2243 \u03b2} {e\u2082 : \u03b1 \u2243 \u03b2} :\n    \u21d1e\u2081 = \u21d1e\u2082 \u2194 e\u2081 = e\u2082 :=\n  function.injective.eq_iff injective_coe_fn\n\ntheorem ext {\u03b1 : Sort u} {\u03b2 : Sort v} {f : \u03b1 \u2243 \u03b2} {g : \u03b1 \u2243 \u03b2}\n    (H : \u2200 (x : \u03b1), coe_fn f x = coe_fn g x) : f = g :=\n  injective_coe_fn (funext H)\n\nprotected theorem congr_arg {\u03b1 : Sort u} {\u03b2 : Sort v} {f : \u03b1 \u2243 \u03b2} {x : \u03b1} {x' : \u03b1} :\n    x = x' \u2192 coe_fn f x = coe_fn f x' :=\n  sorry\n\nprotected theorem congr_fun {\u03b1 : Sort u} {\u03b2 : Sort v} {f : \u03b1 \u2243 \u03b2} {g : \u03b1 \u2243 \u03b2} (h : f = g) (x : \u03b1) :\n    coe_fn f x = coe_fn g x :=\n  h \u25b8 rfl\n\ntheorem ext_iff {\u03b1 : Sort u} {\u03b2 : Sort v} {f : \u03b1 \u2243 \u03b2} {g : \u03b1 \u2243 \u03b2} :\n    f = g \u2194 \u2200 (x : \u03b1), coe_fn f x = coe_fn g x :=\n  { mp := fun (h : f = g) (x : \u03b1) => h \u25b8 rfl, mpr := ext }\n\ntheorem perm.ext {\u03b1 : Sort u} {\u03c3 : perm \u03b1} {\u03c4 : perm \u03b1} (H : \u2200 (x : \u03b1), coe_fn \u03c3 x = coe_fn \u03c4 x) :\n    \u03c3 = \u03c4 :=\n  ext H\n\nprotected theorem perm.congr_arg {\u03b1 : Sort u} {f : perm \u03b1} {x : \u03b1} {x' : \u03b1} :\n    x = x' \u2192 coe_fn f x = coe_fn f x' :=\n  equiv.congr_arg\n\nprotected theorem perm.congr_fun {\u03b1 : Sort u} {f : perm \u03b1} {g : perm \u03b1} (h : f = g) (x : \u03b1) :\n    coe_fn f x = coe_fn g x :=\n  equiv.congr_fun h x\n\ntheorem perm.ext_iff {\u03b1 : Sort u} {\u03c3 : perm \u03b1} {\u03c4 : perm \u03b1} :\n    \u03c3 = \u03c4 \u2194 \u2200 (x : \u03b1), coe_fn \u03c3 x = coe_fn \u03c4 x :=\n  ext_iff\n\n/-- Any type is equivalent to itself. -/\nprotected def refl (\u03b1 : Sort u_1) : \u03b1 \u2243 \u03b1 := mk id id sorry sorry\n\nprotected instance inhabited' {\u03b1 : Sort u} : Inhabited (\u03b1 \u2243 \u03b1) := { default := equiv.refl \u03b1 }\n\n/-- Inverse of an equivalence `e : \u03b1 \u2243 \u03b2`. -/\nprotected def symm {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : \u03b2 \u2243 \u03b1 :=\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 {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : \u03b2 \u2192 \u03b1 := \u21d1(equiv.symm e)\n\n/-- Composition of equivalences `e\u2081 : \u03b1 \u2243 \u03b2` and `e\u2082 : \u03b2 \u2243 \u03b3`. -/\nprotected def trans {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b2 \u2243 \u03b3) : \u03b1 \u2243 \u03b3 :=\n  mk (\u21d1e\u2082 \u2218 \u21d1e\u2081) (\u21d1(equiv.symm e\u2081) \u2218 \u21d1(equiv.symm e\u2082)) sorry sorry\n\n@[simp] theorem to_fun_as_coe {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : to_fun e = \u21d1e := rfl\n\n@[simp] theorem inv_fun_as_coe {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) :\n    inv_fun e = \u21d1(equiv.symm e) :=\n  rfl\n\nprotected theorem injective {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : function.injective \u21d1e :=\n  function.left_inverse.injective (left_inv e)\n\nprotected theorem surjective {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : function.surjective \u21d1e :=\n  function.right_inverse.surjective (right_inv e)\n\nprotected theorem bijective {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2243 \u03b2) : function.bijective \u21d1f :=\n  { left := equiv.injective f, right := equiv.surjective f }\n\n@[simp] theorem range_eq_univ {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) : set.range \u21d1e = set.univ :=\n  set.eq_univ_of_forall (equiv.surjective e)\n\nprotected theorem subsingleton {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) [subsingleton \u03b2] :\n    subsingleton \u03b1 :=\n  function.injective.subsingleton (equiv.injective e)\n\nprotected theorem subsingleton.symm {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) [subsingleton \u03b1] :\n    subsingleton \u03b2 :=\n  function.injective.subsingleton (equiv.injective (equiv.symm e))\n\nprotected instance equiv_subsingleton_cod {\u03b1 : Sort u} {\u03b2 : Sort v} [subsingleton \u03b2] :\n    subsingleton (\u03b1 \u2243 \u03b2) :=\n  subsingleton.intro\n    fun (f g : \u03b1 \u2243 \u03b2) => ext fun (x : \u03b1) => subsingleton.elim (coe_fn f x) (coe_fn g x)\n\nprotected instance equiv_subsingleton_dom {\u03b1 : Sort u} {\u03b2 : Sort v} [subsingleton \u03b1] :\n    subsingleton (\u03b1 \u2243 \u03b2) :=\n  subsingleton.intro\n    fun (f g : \u03b1 \u2243 \u03b2) => ext fun (x : \u03b1) => subsingleton.elim (coe_fn f x) (coe_fn g x)\n\nprotected instance perm_subsingleton {\u03b1 : Sort u} [subsingleton \u03b1] : subsingleton (perm \u03b1) :=\n  equiv.equiv_subsingleton_cod\n\ntheorem perm.subsingleton_eq_refl {\u03b1 : Sort u} [subsingleton \u03b1] (e : perm \u03b1) : e = equiv.refl \u03b1 :=\n  subsingleton.elim e (equiv.refl \u03b1)\n\n/-- Transfer `decidable_eq` across an equivalence. -/\nprotected def decidable_eq {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) [DecidableEq \u03b2] : DecidableEq \u03b1 :=\n  function.injective.decidable_eq (equiv.injective e)\n\ntheorem nonempty_iff_nonempty {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : Nonempty \u03b1 \u2194 Nonempty \u03b2 :=\n  nonempty.congr \u21d1e \u21d1(equiv.symm e)\n\n/-- If `\u03b1 \u2243 \u03b2` and `\u03b2` is inhabited, then so is `\u03b1`. -/\nprotected def inhabited {\u03b1 : Sort u} {\u03b2 : Sort v} [Inhabited \u03b2] (e : \u03b1 \u2243 \u03b2) : Inhabited \u03b1 :=\n  { default := coe_fn (equiv.symm e) Inhabited.default }\n\n/-- If `\u03b1 \u2243 \u03b2` and `\u03b2` is a singleton type, then so is `\u03b1`. -/\nprotected def unique {\u03b1 : Sort u} {\u03b2 : Sort v} [unique \u03b2] (e : \u03b1 \u2243 \u03b2) : unique \u03b1 :=\n  function.surjective.unique sorry\n\n/-- Equivalence between equal types. -/\nprotected def cast {\u03b1 : Sort u_1} {\u03b2 : Sort u_1} (h : \u03b1 = \u03b2) : \u03b1 \u2243 \u03b2 :=\n  mk (cast h) (cast sorry) sorry sorry\n\n@[simp] theorem coe_fn_symm_mk {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1)\n    (l : function.left_inverse g f) (r : function.right_inverse g f) :\n    \u21d1(equiv.symm (mk f g l r)) = g :=\n  rfl\n\n@[simp] theorem coe_refl {\u03b1 : Sort u} : \u21d1(equiv.refl \u03b1) = id := rfl\n\n@[simp] theorem perm.coe_subsingleton {\u03b1 : Type u_1} [subsingleton \u03b1] (e : perm \u03b1) : \u21d1e = id :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u21d1e = id)) (perm.subsingleton_eq_refl e)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u21d1(equiv.refl \u03b1) = id)) coe_refl)) (Eq.refl id))\n\ntheorem refl_apply {\u03b1 : Sort u} (x : \u03b1) : coe_fn (equiv.refl \u03b1) x = x := rfl\n\n@[simp] theorem coe_trans {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (f : \u03b1 \u2243 \u03b2) (g : \u03b2 \u2243 \u03b3) :\n    \u21d1(equiv.trans f g) = \u21d1g \u2218 \u21d1f :=\n  rfl\n\ntheorem trans_apply {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (f : \u03b1 \u2243 \u03b2) (g : \u03b2 \u2243 \u03b3) (a : \u03b1) :\n    coe_fn (equiv.trans f g) a = coe_fn g (coe_fn f a) :=\n  rfl\n\n@[simp] theorem apply_symm_apply {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) (x : \u03b2) :\n    coe_fn e (coe_fn (equiv.symm e) x) = x :=\n  right_inv e x\n\n@[simp] theorem symm_apply_apply {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) (x : \u03b1) :\n    coe_fn (equiv.symm e) (coe_fn e x) = x :=\n  left_inv e x\n\n@[simp] theorem symm_comp_self {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : \u21d1(equiv.symm e) \u2218 \u21d1e = id :=\n  funext (symm_apply_apply e)\n\n@[simp] theorem self_comp_symm {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : \u21d1e \u2218 \u21d1(equiv.symm e) = id :=\n  funext (apply_symm_apply e)\n\n@[simp] theorem symm_trans_apply {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (f : \u03b1 \u2243 \u03b2) (g : \u03b2 \u2243 \u03b3)\n    (a : \u03b3) :\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 {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2243 \u03b2) (b : \u03b1) :\n    coe_fn (equiv.symm (equiv.symm f)) b = coe_fn f b :=\n  rfl\n\n@[simp] theorem apply_eq_iff_eq {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2243 \u03b2) {x : \u03b1} {y : \u03b1} :\n    coe_fn f x = coe_fn f y \u2194 x = y :=\n  function.injective.eq_iff (equiv.injective f)\n\ntheorem apply_eq_iff_eq_symm_apply {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (f : \u03b1 \u2243 \u03b2) {x : \u03b1} {y : \u03b2} :\n    coe_fn f x = y \u2194 x = coe_fn (equiv.symm f) y :=\n  sorry\n\n@[simp] theorem cast_apply {\u03b1 : Sort u_1} {\u03b2 : Sort u_1} (h : \u03b1 = \u03b2) (x : \u03b1) :\n    coe_fn (equiv.cast h) x = cast h x :=\n  rfl\n\ntheorem symm_apply_eq {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (e : \u03b1 \u2243 \u03b2) {x : \u03b2} {y : \u03b1} :\n    coe_fn (equiv.symm e) x = y \u2194 x = coe_fn e y :=\n  sorry\n\ntheorem eq_symm_apply {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (e : \u03b1 \u2243 \u03b2) {x : \u03b2} {y : \u03b1} :\n    y = coe_fn (equiv.symm e) x \u2194 coe_fn e y = x :=\n  iff.trans (iff.trans eq_comm (symm_apply_eq e)) eq_comm\n\n@[simp] theorem symm_symm {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : equiv.symm (equiv.symm e) = e :=\n  sorry\n\n@[simp] theorem trans_refl {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) :\n    equiv.trans e (equiv.refl \u03b2) = e :=\n  sorry\n\n@[simp] theorem refl_symm {\u03b1 : Sort u} : equiv.symm (equiv.refl \u03b1) = equiv.refl \u03b1 := rfl\n\n@[simp] theorem refl_trans {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) :\n    equiv.trans (equiv.refl \u03b1) e = e :=\n  sorry\n\n@[simp] theorem symm_trans {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) :\n    equiv.trans (equiv.symm e) e = equiv.refl \u03b2 :=\n  sorry\n\n@[simp] theorem trans_symm {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) :\n    equiv.trans e (equiv.symm e) = equiv.refl \u03b1 :=\n  sorry\n\ntheorem trans_assoc {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {\u03b4 : Sort u_1} (ab : \u03b1 \u2243 \u03b2) (bc : \u03b2 \u2243 \u03b3)\n    (cd : \u03b3 \u2243 \u03b4) : equiv.trans (equiv.trans ab bc) cd = equiv.trans ab (equiv.trans bc cd) :=\n  ext fun (a : \u03b1) => rfl\n\ntheorem left_inverse_symm {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2243 \u03b2) :\n    function.left_inverse \u21d1(equiv.symm f) \u21d1f :=\n  left_inv f\n\ntheorem right_inverse_symm {\u03b1 : Sort u} {\u03b2 : Sort v} (f : \u03b1 \u2243 \u03b2) :\n    function.right_inverse \u21d1(equiv.symm f) \u21d1f :=\n  right_inv f\n\n/-- If `\u03b1` is equivalent to `\u03b2` and `\u03b3` is equivalent to `\u03b4`, then the type of equivalences `\u03b1 \u2243 \u03b3`\nis equivalent to the type of equivalences `\u03b2 \u2243 \u03b4`. -/\ndef equiv_congr {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {\u03b4 : Sort u_1} (ab : \u03b1 \u2243 \u03b2) (cd : \u03b3 \u2243 \u03b4) :\n    \u03b1 \u2243 \u03b3 \u2243 (\u03b2 \u2243 \u03b4) :=\n  mk (fun (ac : \u03b1 \u2243 \u03b3) => equiv.trans (equiv.trans (equiv.symm ab) ac) cd)\n    (fun (bd : \u03b2 \u2243 \u03b4) => equiv.trans ab (equiv.trans bd (equiv.symm cd))) sorry sorry\n\n@[simp] theorem equiv_congr_refl {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} :\n    equiv_congr (equiv.refl \u03b1) (equiv.refl \u03b2) = equiv.refl (\u03b1 \u2243 \u03b2) :=\n  ext\n    fun (x : \u03b1 \u2243 \u03b2) =>\n      ext\n        fun (x_1 : \u03b1) => Eq.refl (coe_fn (coe_fn (equiv_congr (equiv.refl \u03b1) (equiv.refl \u03b2)) x) x_1)\n\n@[simp] theorem equiv_congr_symm {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {\u03b4 : Sort u_1} (ab : \u03b1 \u2243 \u03b2)\n    (cd : \u03b3 \u2243 \u03b4) : equiv.symm (equiv_congr ab cd) = equiv_congr (equiv.symm ab) (equiv.symm cd) :=\n  ext\n    fun (x : \u03b2 \u2243 \u03b4) =>\n      ext fun (x_1 : \u03b1) => Eq.refl (coe_fn (coe_fn (equiv.symm (equiv_congr ab cd)) x) x_1)\n\n@[simp] theorem equiv_congr_trans {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {\u03b4 : Sort u_1}\n    {\u03b5 : Sort u_2} {\u03b6 : Sort u_3} (ab : \u03b1 \u2243 \u03b2) (de : \u03b4 \u2243 \u03b5) (bc : \u03b2 \u2243 \u03b3) (ef : \u03b5 \u2243 \u03b6) :\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 : \u03b1 \u2243 \u03b4) =>\n      ext\n        fun (x_1 : \u03b3) =>\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 {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} {\u03b3 : Sort u_3} (bg : \u03b2 \u2243 \u03b3)\n    (e : \u03b1 \u2243 \u03b2) : coe_fn (equiv_congr (equiv.refl \u03b1) bg) e = equiv.trans e bg :=\n  rfl\n\n@[simp] theorem equiv_congr_refl_right {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (ab : \u03b1 \u2243 \u03b2) (e : \u03b1 \u2243 \u03b2) :\n    coe_fn (equiv_congr ab (equiv.refl \u03b2)) e = equiv.trans (equiv.symm ab) e :=\n  rfl\n\n@[simp] theorem equiv_congr_apply_apply {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {\u03b4 : Sort u_1}\n    (ab : \u03b1 \u2243 \u03b2) (cd : \u03b3 \u2243 \u03b4) (e : \u03b1 \u2243 \u03b3) (x : \u03b2) :\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 `\u03b1` is equivalent to `\u03b2`, then `perm \u03b1` is equivalent to `perm \u03b2`. -/\ndef perm_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) : perm \u03b1 \u2243 perm \u03b2 := equiv_congr e e\n\ntheorem perm_congr_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (p : perm \u03b1) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) :\n    equiv.symm (perm_congr e) = perm_congr (equiv.symm e) :=\n  rfl\n\n@[simp] theorem perm_congr_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (p : perm \u03b1) (x : \u03b2) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (p : perm \u03b2) (x : \u03b1) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (s : set \u03b1) :\n    \u21d1e '' s = \u21d1(equiv.symm e) \u207b\u00b9' s :=\n  set.ext fun (x : \u03b2) => set.mem_image_iff_of_inverse (left_inv e) (right_inv e)\n\nprotected theorem subset_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (s : set \u03b1) (t : set \u03b2) :\n    t \u2286 \u21d1e '' s \u2194 \u21d1(equiv.symm e) '' t \u2286 s :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (t \u2286 \u21d1e '' s \u2194 \u21d1(equiv.symm e) '' t \u2286 s))\n        (propext set.image_subset_iff)))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl (t \u2286 \u21d1e '' s \u2194 t \u2286 \u21d1(equiv.symm e) \u207b\u00b9' s))\n          (equiv.image_eq_preimage e s)))\n      (iff.refl (t \u2286 \u21d1(equiv.symm e) \u207b\u00b9' s)))\n\n@[simp] theorem symm_image_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2243 \u03b2) (s : set \u03b1) :\n    \u21d1(equiv.symm f) '' (\u21d1f '' s) = s :=\n  sorry\n\n@[simp] theorem image_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (s : set \u03b2) :\n    \u21d1e '' (\u21d1e \u207b\u00b9' s) = s :=\n  function.surjective.image_preimage (equiv.surjective e) s\n\n@[simp] theorem preimage_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (s : set \u03b1) :\n    \u21d1e \u207b\u00b9' (\u21d1e '' s) = s :=\n  set.preimage_image_eq s (equiv.injective e)\n\nprotected theorem image_compl {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2243 \u03b2) (s : set \u03b1) :\n    \u21d1f '' (s\u1d9c) = (\u21d1f '' s\u1d9c) :=\n  set.image_compl_eq (equiv.bijective f)\n\n/-- If `\u03b1` is an empty type, then it is equivalent to the `empty` type. -/\ndef equiv_empty {\u03b1 : Sort u} (h : \u03b1 \u2192 False) : \u03b1 \u2243 empty :=\n  mk (fun (x : \u03b1) => false.elim (h x)) (fun (e : empty) => empty.rec (fun (e : empty) => \u03b1) e) sorry\n    sorry\n\n/-- `false` is equivalent to `empty`. -/\ndef false_equiv_empty : False \u2243 empty := equiv_empty id\n\n/-- If `\u03b1` is an empty type, then it is equivalent to the `pempty` type in any universe. -/\ndef equiv_pempty {\u03b1 : Sort v'} (h : \u03b1 \u2192 False) : \u03b1 \u2243 pempty :=\n  mk (fun (x : \u03b1) => false.elim (h x)) (fun (e : pempty) => pempty.rec (fun (e : pempty) => \u03b1) e)\n    sorry sorry\n\n/-- `false` is equivalent to `pempty`. -/\ndef false_equiv_pempty : False \u2243 pempty := equiv_pempty id\n\n/-- `empty` is equivalent to `pempty`. -/\ndef empty_equiv_pempty : empty \u2243 pempty := equiv_pempty sorry\n\n/-- `pempty` types from any two universes are equivalent. -/\ndef pempty_equiv_pempty : pempty \u2243 pempty := equiv_pempty pempty.elim\n\n/-- If `\u03b1` is not `nonempty`, then it is equivalent to `empty`. -/\ndef empty_of_not_nonempty {\u03b1 : Sort u_1} (h : \u00acNonempty \u03b1) : \u03b1 \u2243 empty := equiv_empty sorry\n\n/-- If `\u03b1` is not `nonempty`, then it is equivalent to `pempty`. -/\ndef pempty_of_not_nonempty {\u03b1 : Sort u_1} (h : \u00acNonempty \u03b1) : \u03b1 \u2243 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 \u2243 PUnit :=\n  mk (fun (x : p) => Unit.unit) sorry sorry sorry\n\n/-- `true` is equivalent to `punit`. -/\ndef true_equiv_punit : True \u2243 PUnit := prop_equiv_punit trivial\n\n/-- `ulift \u03b1` is equivalent to `\u03b1`. -/\n@[simp] theorem ulift_symm_apply {\u03b1 : Type v} : \u21d1(equiv.symm equiv.ulift) = ulift.up :=\n  Eq.refl \u21d1(equiv.symm equiv.ulift)\n\n/-- `plift \u03b1` is equivalent to `\u03b1`. -/\nprotected def plift {\u03b1 : Sort u} : plift \u03b1 \u2243 \u03b1 := 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 \u2194 Q) : P \u2243 Q := mk (iff.mp h) (iff.mpr h) sorry sorry\n\n/-- If `\u03b1\u2081` is equivalent to `\u03b1\u2082` and `\u03b2\u2081` is equivalent to `\u03b2\u2082`, then the type of maps `\u03b1\u2081 \u2192 \u03b2\u2081`\nis equivalent to the type of maps `\u03b1\u2082 \u2192 \u03b2\u2082`. -/\ndef arrow_congr {\u03b1\u2081 : Sort u_1} {\u03b2\u2081 : Sort u_2} {\u03b1\u2082 : Sort u_3} {\u03b2\u2082 : Sort u_4} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082)\n    (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) : (\u03b1\u2081 \u2192 \u03b2\u2081) \u2243 (\u03b1\u2082 \u2192 \u03b2\u2082) :=\n  mk (fun (f : \u03b1\u2081 \u2192 \u03b2\u2081) => \u21d1e\u2082 \u2218 f \u2218 \u21d1(equiv.symm e\u2081))\n    (fun (f : \u03b1\u2082 \u2192 \u03b2\u2082) => \u21d1(equiv.symm e\u2082) \u2218 f \u2218 \u21d1e\u2081) sorry sorry\n\ntheorem arrow_congr_comp {\u03b1\u2081 : Sort u_1} {\u03b2\u2081 : Sort u_2} {\u03b3\u2081 : Sort u_3} {\u03b1\u2082 : Sort u_4}\n    {\u03b2\u2082 : Sort u_5} {\u03b3\u2082 : Sort u_6} (ea : \u03b1\u2081 \u2243 \u03b1\u2082) (eb : \u03b2\u2081 \u2243 \u03b2\u2082) (ec : \u03b3\u2081 \u2243 \u03b3\u2082) (f : \u03b1\u2081 \u2192 \u03b2\u2081)\n    (g : \u03b2\u2081 \u2192 \u03b3\u2081) :\n    coe_fn (arrow_congr ea ec) (g \u2218 f) =\n        coe_fn (arrow_congr eb ec) g \u2218 coe_fn (arrow_congr ea eb) f :=\n  sorry\n\n@[simp] theorem arrow_congr_refl {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} :\n    arrow_congr (equiv.refl \u03b1) (equiv.refl \u03b2) = equiv.refl (\u03b1 \u2192 \u03b2) :=\n  rfl\n\n@[simp] theorem arrow_congr_trans {\u03b1\u2081 : Sort u_1} {\u03b2\u2081 : Sort u_2} {\u03b1\u2082 : Sort u_3} {\u03b2\u2082 : Sort u_4}\n    {\u03b1\u2083 : Sort u_5} {\u03b2\u2083 : Sort u_6} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2081' : \u03b2\u2081 \u2243 \u03b2\u2082) (e\u2082 : \u03b1\u2082 \u2243 \u03b1\u2083) (e\u2082' : \u03b2\u2082 \u2243 \u03b2\u2083) :\n    arrow_congr (equiv.trans e\u2081 e\u2082) (equiv.trans e\u2081' e\u2082') =\n        equiv.trans (arrow_congr e\u2081 e\u2081') (arrow_congr e\u2082 e\u2082') :=\n  rfl\n\n@[simp] theorem arrow_congr_symm {\u03b1\u2081 : Sort u_1} {\u03b2\u2081 : Sort u_2} {\u03b1\u2082 : Sort u_3} {\u03b2\u2082 : Sort u_4}\n    (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    equiv.symm (arrow_congr e\u2081 e\u2082) = arrow_congr (equiv.symm e\u2081) (equiv.symm e\u2082) :=\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' {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b1\u2082 : Type u_3} {\u03b2\u2082 : Type u_4} (h\u03b1 : \u03b1\u2081 \u2243 \u03b1\u2082)\n    (h\u03b2 : \u03b2\u2081 \u2243 \u03b2\u2082) : (\u03b1\u2081 \u2192 \u03b2\u2081) \u2243 (\u03b1\u2082 \u2192 \u03b2\u2082) :=\n  arrow_congr h\u03b1 h\u03b2\n\n@[simp] theorem arrow_congr'_refl {\u03b1 : Type u_1} {\u03b2 : Type u_2} :\n    arrow_congr' (equiv.refl \u03b1) (equiv.refl \u03b2) = equiv.refl (\u03b1 \u2192 \u03b2) :=\n  rfl\n\n@[simp] theorem arrow_congr'_trans {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b1\u2082 : Type u_3} {\u03b2\u2082 : Type u_4}\n    {\u03b1\u2083 : Type u_5} {\u03b2\u2083 : Type u_6} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2081' : \u03b2\u2081 \u2243 \u03b2\u2082) (e\u2082 : \u03b1\u2082 \u2243 \u03b1\u2083) (e\u2082' : \u03b2\u2082 \u2243 \u03b2\u2083) :\n    arrow_congr' (equiv.trans e\u2081 e\u2082) (equiv.trans e\u2081' e\u2082') =\n        equiv.trans (arrow_congr' e\u2081 e\u2081') (arrow_congr' e\u2082 e\u2082') :=\n  rfl\n\n@[simp] theorem arrow_congr'_symm {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b1\u2082 : Type u_3} {\u03b2\u2082 : Type u_4}\n    (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    equiv.symm (arrow_congr' e\u2081 e\u2082) = arrow_congr' (equiv.symm e\u2081) (equiv.symm e\u2082) :=\n  rfl\n\n/-- Conjugate a map `f : \u03b1 \u2192 \u03b1` by an equivalence `\u03b1 \u2243 \u03b2`. -/\ndef conj {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : (\u03b1 \u2192 \u03b1) \u2243 (\u03b2 \u2192 \u03b2) := arrow_congr e e\n\n@[simp] theorem conj_refl {\u03b1 : Sort u} : conj (equiv.refl \u03b1) = equiv.refl (\u03b1 \u2192 \u03b1) := rfl\n\n@[simp] theorem conj_symm {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) :\n    equiv.symm (conj e) = conj (equiv.symm e) :=\n  rfl\n\n@[simp] theorem conj_trans {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} (e\u2081 : \u03b1 \u2243 \u03b2) (e\u2082 : \u03b2 \u2243 \u03b3) :\n    conj (equiv.trans e\u2081 e\u2082) = equiv.trans (conj e\u2081) (conj e\u2082) :=\n  rfl\n\n-- This should not be a simp lemma as long as `(\u2218)` is reducible:\n\n-- when `(\u2218)` is reducible, Lean can unify `f\u2081 \u2218 f\u2082` with any `g` using\n\n-- `f\u2081 := g` and `f\u2082 := \u03bb x, x`.  This causes nontermination.\n\ntheorem conj_comp {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) (f\u2081 : \u03b1 \u2192 \u03b1) (f\u2082 : \u03b1 \u2192 \u03b1) :\n    coe_fn (conj e) (f\u2081 \u2218 f\u2082) = coe_fn (conj e) f\u2081 \u2218 coe_fn (conj e) f\u2082 :=\n  arrow_congr_comp e e e f\u2082 f\u2081\n\ntheorem semiconj_conj {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} (e : \u03b1\u2081 \u2243 \u03b2\u2081) (f : \u03b1\u2081 \u2192 \u03b1\u2081) :\n    function.semiconj (\u21d1e) f (coe_fn (conj e) f) :=\n  sorry\n\ntheorem semiconj\u2082_conj {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} (e : \u03b1\u2081 \u2243 \u03b2\u2081) (f : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 \u03b1\u2081) :\n    function.semiconj\u2082 (\u21d1e) f (coe_fn (arrow_congr e (conj e)) f) :=\n  sorry\n\nprotected instance arrow_congr.is_associative {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} (e : \u03b1\u2081 \u2243 \u03b2\u2081)\n    (f : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 \u03b1\u2081) [is_associative \u03b1\u2081 f] :\n    is_associative \u03b2\u2081 (coe_fn (arrow_congr e (arrow_congr e e)) f) :=\n  function.semiconj\u2082.is_associative_right (semiconj\u2082_conj e f) (equiv.surjective e)\n\nprotected instance arrow_congr.is_idempotent {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} (e : \u03b1\u2081 \u2243 \u03b2\u2081)\n    (f : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 \u03b1\u2081) [is_idempotent \u03b1\u2081 f] :\n    is_idempotent \u03b2\u2081 (coe_fn (arrow_congr e (arrow_congr e e)) f) :=\n  function.semiconj\u2082.is_idempotent_right (semiconj\u2082_conj e f) (equiv.surjective e)\n\nprotected instance arrow_congr.is_left_cancel {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} (e : \u03b1\u2081 \u2243 \u03b2\u2081)\n    (f : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 \u03b1\u2081) [is_left_cancel \u03b1\u2081 f] :\n    is_left_cancel \u03b2\u2081 (coe_fn (arrow_congr e (arrow_congr e e)) f) :=\n  sorry\n\nprotected instance arrow_congr.is_right_cancel {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} (e : \u03b1\u2081 \u2243 \u03b2\u2081)\n    (f : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 \u03b1\u2081) [is_right_cancel \u03b1\u2081 f] :\n    is_right_cancel \u03b2\u2081 (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 \u2243 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 (\u03b1 : Sort u_1) : (\u03b1 \u2192 PUnit) \u2243 PUnit :=\n  mk (fun (f : \u03b1 \u2192 PUnit) => PUnit.unit) (fun (u : PUnit) (f : \u03b1) => PUnit.unit) sorry sorry\n\n/-- The sort of maps from `punit` is equivalent to the codomain. -/\ndef punit_arrow_equiv (\u03b1 : Sort u_1) : (PUnit \u2192 \u03b1) \u2243 \u03b1 :=\n  mk (fun (f : PUnit \u2192 \u03b1) => f PUnit.unit) (fun (a : \u03b1) (u : PUnit) => a) sorry sorry\n\n/-- The sort of maps from `true` is equivalent to the codomain. -/\ndef true_arrow_equiv (\u03b1 : Sort u_1) : (True \u2192 \u03b1) \u2243 \u03b1 :=\n  mk (fun (f : True \u2192 \u03b1) => f trivial) (fun (a : \u03b1) (u : True) => a) sorry sorry\n\n/-- The sort of maps from `empty` is equivalent to `punit`. -/\ndef empty_arrow_equiv_punit (\u03b1 : Sort u_1) : (empty \u2192 \u03b1) \u2243 PUnit :=\n  mk (fun (f : empty \u2192 \u03b1) => PUnit.unit)\n    (fun (u : PUnit) (e : empty) => empty.rec (fun (e : empty) => \u03b1) e) sorry sorry\n\n/-- The sort of maps from `pempty` is equivalent to `punit`. -/\ndef pempty_arrow_equiv_punit (\u03b1 : Sort u_1) : (pempty \u2192 \u03b1) \u2243 PUnit :=\n  mk (fun (f : pempty \u2192 \u03b1) => PUnit.unit)\n    (fun (u : PUnit) (e : pempty) => pempty.rec (fun (e : pempty) => \u03b1) e) sorry sorry\n\n/-- The sort of maps from `false` is equivalent to `punit`. -/\ndef false_arrow_equiv_punit (\u03b1 : Sort u_1) : (False \u2192 \u03b1) \u2243 PUnit :=\n  equiv.trans (arrow_congr false_equiv_empty (equiv.refl \u03b1)) (empty_arrow_equiv_punit \u03b1)\n\n/-- Product of two equivalences. If `\u03b1\u2081 \u2243 \u03b1\u2082` and `\u03b2\u2081 \u2243 \u03b2\u2082`, then `\u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2082 \u00d7 \u03b2\u2082`. -/\n@[simp] theorem prod_congr_apply {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b1\u2082 : Type u_3} {\u03b2\u2082 : Type u_4}\n    (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) (x : \u03b1\u2081 \u00d7 \u03b2\u2081) :\n    coe_fn (prod_congr e\u2081 e\u2082) x = prod.map (\u21d1e\u2081) (\u21d1e\u2082) x :=\n  Eq.refl (coe_fn (prod_congr e\u2081 e\u2082) x)\n\n@[simp] theorem prod_congr_symm {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b1\u2082 : Type u_3} {\u03b2\u2082 : Type u_4}\n    (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    equiv.symm (prod_congr e\u2081 e\u2082) = prod_congr (equiv.symm e\u2081) (equiv.symm e\u2082) :=\n  rfl\n\n/-- Type product is commutative up to an equivalence: `\u03b1 \u00d7 \u03b2 \u2243 \u03b2 \u00d7 \u03b1`. -/\n@[simp] theorem prod_comm_apply (\u03b1 : Type u_1) (\u03b2 : Type u_2) :\n    \u2200 (\u1fb0 : \u03b1 \u00d7 \u03b2), coe_fn (prod_comm \u03b1 \u03b2) \u1fb0 = prod.swap \u1fb0 :=\n  fun (\u1fb0 : \u03b1 \u00d7 \u03b2) => Eq.refl (coe_fn (prod_comm \u03b1 \u03b2) \u1fb0)\n\n@[simp] theorem prod_comm_symm (\u03b1 : Type u_1) (\u03b2 : Type u_2) :\n    equiv.symm (prod_comm \u03b1 \u03b2) = prod_comm \u03b2 \u03b1 :=\n  rfl\n\n/-- Type product is associative up to an equivalence. -/\n@[simp] theorem prod_assoc_apply (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) (p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b3) :\n    coe_fn (prod_assoc \u03b1 \u03b2 \u03b3) p = (prod.fst (prod.fst p), prod.snd (prod.fst p), prod.snd p) :=\n  Eq.refl (coe_fn (prod_assoc \u03b1 \u03b2 \u03b3) p)\n\ntheorem prod_assoc_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {s : set \u03b1} {t : set \u03b2}\n    {u : set \u03b3} : \u21d1(prod_assoc \u03b1 \u03b2 \u03b3) \u207b\u00b9' 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 (\u03b1 : Type u_1) (p : \u03b1 \u00d7 PUnit) :\n    coe_fn (prod_punit \u03b1) p = prod.fst p :=\n  Eq.refl (coe_fn (prod_punit \u03b1) p)\n\n/-- `punit` is a left identity for type product up to an equivalence. -/\n@[simp] theorem punit_prod_apply (\u03b1 : Type u_1) :\n    \u2200 (\u1fb0 : PUnit \u00d7 \u03b1), coe_fn (punit_prod \u03b1) \u1fb0 = prod.snd \u1fb0 :=\n  fun (\u1fb0 : PUnit \u00d7 \u03b1) => Eq.refl (prod.snd \u1fb0)\n\n/-- `empty` type is a right absorbing element for type product up to an equivalence. -/\ndef prod_empty (\u03b1 : Type u_1) : \u03b1 \u00d7 empty \u2243 empty := equiv_empty sorry\n\n/-- `empty` type is a left absorbing element for type product up to an equivalence. -/\ndef empty_prod (\u03b1 : Type u_1) : empty \u00d7 \u03b1 \u2243 empty := equiv_empty sorry\n\n/-- `pempty` type is a right absorbing element for type product up to an equivalence. -/\ndef prod_pempty (\u03b1 : Type u_1) : \u03b1 \u00d7 pempty \u2243 pempty := equiv_pempty sorry\n\n/-- `pempty` type is a left absorbing element for type product up to an equivalence. -/\ndef pempty_prod (\u03b1 : Type u_1) : pempty \u00d7 \u03b1 \u2243 pempty := equiv_pempty sorry\n\n/-- `psum` is equivalent to `sum`. -/\ndef psum_equiv_sum (\u03b1 : Type u_1) (\u03b2 : Type u_2) : psum \u03b1 \u03b2 \u2243 \u03b1 \u2295 \u03b2 :=\n  mk (fun (s : psum \u03b1 \u03b2) => psum.cases_on s sum.inl sum.inr)\n    (fun (s : \u03b1 \u2295 \u03b2) => sum.cases_on s psum.inl psum.inr) sorry sorry\n\n/-- If `\u03b1 \u2243 \u03b1'` and `\u03b2 \u2243 \u03b2'`, then `\u03b1 \u2295 \u03b2 \u2243 \u03b1' \u2295 \u03b2'`. -/\ndef sum_congr {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b1\u2082 : Type u_3} {\u03b2\u2082 : Type u_4} (ea : \u03b1\u2081 \u2243 \u03b1\u2082)\n    (eb : \u03b2\u2081 \u2243 \u03b2\u2082) : \u03b1\u2081 \u2295 \u03b2\u2081 \u2243 \u03b1\u2082 \u2295 \u03b2\u2082 :=\n  mk (sum.map \u21d1ea \u21d1eb) (sum.map \u21d1(equiv.symm ea) \u21d1(equiv.symm eb)) sorry sorry\n\n@[simp] theorem sum_congr_trans {\u03b1\u2081 : Type u_1} {\u03b1\u2082 : Type u_2} {\u03b2\u2081 : Type u_3} {\u03b2\u2082 : Type u_4}\n    {\u03b3\u2081 : Type u_5} {\u03b3\u2082 : Type u_6} (e : \u03b1\u2081 \u2243 \u03b2\u2081) (f : \u03b1\u2082 \u2243 \u03b2\u2082) (g : \u03b2\u2081 \u2243 \u03b3\u2081) (h : \u03b2\u2082 \u2243 \u03b3\u2082) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4}\n    (e : \u03b1 \u2243 \u03b2) (f : \u03b3 \u2243 \u03b4) :\n    equiv.symm (sum_congr e f) = sum_congr (equiv.symm e) (equiv.symm f) :=\n  rfl\n\n@[simp] theorem sum_congr_refl {\u03b1 : Type u_1} {\u03b2 : Type u_2} :\n    sum_congr (equiv.refl \u03b1) (equiv.refl \u03b2) = equiv.refl (\u03b1 \u2295 \u03b2) :=\n  sorry\n\nnamespace perm\n\n\n/-- Combine a permutation of `\u03b1` and of `\u03b2` into a permutation of `\u03b1 \u2295 \u03b2`. -/\ndef sum_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} (ea : perm \u03b1) (eb : perm \u03b2) : perm (\u03b1 \u2295 \u03b2) :=\n  sum_congr ea eb\n\n@[simp] theorem sum_congr_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} (ea : perm \u03b1) (eb : perm \u03b2)\n    (x : \u03b1 \u2295 \u03b2) : coe_fn (sum_congr ea eb) x = sum.map (\u21d1ea) (\u21d1eb) x :=\n  sum_congr_apply ea eb x\n\n@[simp] theorem sum_congr_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : perm \u03b1) (f : perm \u03b2) (g : perm \u03b1)\n    (h : perm \u03b2) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : perm \u03b1) (f : perm \u03b2) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} :\n    sum_congr (equiv.refl \u03b1) (equiv.refl \u03b2) = equiv.refl (\u03b1 \u2295 \u03b2) :=\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 \u2243 PUnit \u2295 PUnit :=\n  mk (fun (b : Bool) => cond b (sum.inr PUnit.unit) (sum.inl PUnit.unit))\n    (fun (s : PUnit \u2295 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 \u2243 Bool :=\n  mk (fun (p : Prop) => to_bool p) (fun (b : Bool) => \u21a5b) sorry sorry\n\n/-- Sum of types is commutative up to an equivalence. -/\n@[simp] theorem sum_comm_apply (\u03b1 : Type u_1) (\u03b2 : Type u_2) :\n    \u2200 (\u1fb0 : \u03b1 \u2295 \u03b2), coe_fn (sum_comm \u03b1 \u03b2) \u1fb0 = sum.swap \u1fb0 :=\n  fun (\u1fb0 : \u03b1 \u2295 \u03b2) => Eq.refl (coe_fn (sum_comm \u03b1 \u03b2) \u1fb0)\n\n@[simp] theorem sum_comm_symm (\u03b1 : Type u_1) (\u03b2 : Type u_2) :\n    equiv.symm (sum_comm \u03b1 \u03b2) = sum_comm \u03b2 \u03b1 :=\n  rfl\n\n/-- Sum of types is associative up to an equivalence. -/\ndef sum_assoc (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) : (\u03b1 \u2295 \u03b2) \u2295 \u03b3 \u2243 \u03b1 \u2295 \u03b2 \u2295 \u03b3 :=\n  mk (sum.elim (sum.elim sum.inl (sum.inr \u2218 sum.inl)) (sum.inr \u2218 sum.inr))\n    (sum.elim (sum.inl \u2218 sum.inl) (sum.elim (sum.inl \u2218 sum.inr) sum.inr)) sorry sorry\n\n@[simp] theorem sum_assoc_apply_in1 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (a : \u03b1) :\n    coe_fn (sum_assoc \u03b1 \u03b2 \u03b3) (sum.inl (sum.inl a)) = sum.inl a :=\n  rfl\n\n@[simp] theorem sum_assoc_apply_in2 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (b : \u03b2) :\n    coe_fn (sum_assoc \u03b1 \u03b2 \u03b3) (sum.inl (sum.inr b)) = sum.inr (sum.inl b) :=\n  rfl\n\n@[simp] theorem sum_assoc_apply_in3 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (c : \u03b3) :\n    coe_fn (sum_assoc \u03b1 \u03b2 \u03b3) (sum.inr c) = sum.inr (sum.inr c) :=\n  rfl\n\n/-- Sum with `empty` is equivalent to the original type. -/\ndef sum_empty (\u03b1 : Type u_1) : \u03b1 \u2295 empty \u2243 \u03b1 :=\n  mk (sum.elim id (empty.rec fun (n : empty) => \u03b1)) sum.inl sorry sorry\n\n@[simp] theorem sum_empty_apply_inl {\u03b1 : Type u_1} (a : \u03b1) : coe_fn (sum_empty \u03b1) (sum.inl a) = a :=\n  rfl\n\n/-- The sum of `empty` with any `Sort*` is equivalent to the right summand. -/\ndef empty_sum (\u03b1 : Type u_1) : empty \u2295 \u03b1 \u2243 \u03b1 := equiv.trans (sum_comm empty \u03b1) (sum_empty \u03b1)\n\n@[simp] theorem empty_sum_apply_inr {\u03b1 : Type u_1} (a : \u03b1) : coe_fn (empty_sum \u03b1) (sum.inr a) = a :=\n  rfl\n\n/-- Sum with `pempty` is equivalent to the original type. -/\ndef sum_pempty (\u03b1 : Type u_1) : \u03b1 \u2295 pempty \u2243 \u03b1 :=\n  mk (sum.elim id (pempty.rec fun (n : pempty) => \u03b1)) sum.inl sorry sorry\n\n@[simp] theorem sum_pempty_apply_inl {\u03b1 : Type u_1} (a : \u03b1) :\n    coe_fn (sum_pempty \u03b1) (sum.inl a) = a :=\n  rfl\n\n/-- The sum of `pempty` with any `Sort*` is equivalent to the right summand. -/\ndef pempty_sum (\u03b1 : Type u_1) : pempty \u2295 \u03b1 \u2243 \u03b1 := equiv.trans (sum_comm pempty \u03b1) (sum_pempty \u03b1)\n\n@[simp] theorem pempty_sum_apply_inr {\u03b1 : Type u_1} (a : \u03b1) :\n    coe_fn (pempty_sum \u03b1) (sum.inr a) = a :=\n  rfl\n\n/-- `option \u03b1` is equivalent to `\u03b1 \u2295 punit` -/\ndef option_equiv_sum_punit (\u03b1 : Type u_1) : Option \u03b1 \u2243 \u03b1 \u2295 PUnit :=\n  mk (fun (o : Option \u03b1) => sorry) (fun (s : \u03b1 \u2295 PUnit) => sorry) sorry sorry\n\n@[simp] theorem option_equiv_sum_punit_none {\u03b1 : Type u_1} :\n    coe_fn (option_equiv_sum_punit \u03b1) none = sum.inr PUnit.unit :=\n  rfl\n\n@[simp] theorem option_equiv_sum_punit_some {\u03b1 : Type u_1} (a : \u03b1) :\n    coe_fn (option_equiv_sum_punit \u03b1) (some a) = sum.inl a :=\n  rfl\n\n@[simp] theorem option_equiv_sum_punit_coe {\u03b1 : Type u_1} (a : \u03b1) :\n    coe_fn (option_equiv_sum_punit \u03b1) \u2191a = sum.inl a :=\n  rfl\n\n@[simp] theorem option_equiv_sum_punit_symm_inl {\u03b1 : Type u_1} (a : \u03b1) :\n    coe_fn (equiv.symm (option_equiv_sum_punit \u03b1)) (sum.inl a) = \u2191a :=\n  rfl\n\n@[simp] theorem option_equiv_sum_punit_symm_inr {\u03b1 : Type u_1} (a : PUnit) :\n    coe_fn (equiv.symm (option_equiv_sum_punit \u03b1)) (sum.inr a) = none :=\n  rfl\n\n/-- The set of `x : option \u03b1` such that `is_some x` is equivalent to `\u03b1`. -/\ndef option_is_some_equiv (\u03b1 : Type u_1) : (Subtype fun (x : Option \u03b1) => \u21a5(option.is_some x)) \u2243 \u03b1 :=\n  mk (fun (o : Subtype fun (x : Option \u03b1) => \u21a5(option.is_some x)) => option.get sorry)\n    (fun (x : \u03b1) => { val := some x, property := sorry }) sorry sorry\n\n/-- `\u03b1 \u2295 \u03b2` is equivalent to a `sigma`-type over `bool`. Note that this definition assumes `\u03b1` and\n`\u03b2` 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 (\u03b1 : Type u) (\u03b2 : Type u) : \u03b1 \u2295 \u03b2 \u2243 sigma fun (b : Bool) => cond b \u03b1 \u03b2 :=\n  mk\n    (fun (s : \u03b1 \u2295 \u03b2) => sum.elim (fun (x : \u03b1) => sigma.mk tt x) (fun (x : \u03b2) => sigma.mk false x) s)\n    (fun (s : sigma fun (b : Bool) => cond b \u03b1 \u03b2) => sorry) sorry sorry\n\n/-- `sigma_preimage_equiv f` for `f : \u03b1 \u2192 \u03b2` is the natural equivalence between\nthe type of all fibres of `f` and the total space `\u03b1`. -/\n@[simp] theorem sigma_preimage_equiv_symm_apply_fst {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2)\n    (x : \u03b1) : 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 `\u03b1 \u00d7 \u03b2` is equivalent to the sigma-type `\u03a3 x, {y | (x, y) \u2208 s}`. -/\ndef set_prod_equiv_sigma {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : set (\u03b1 \u00d7 \u03b2)) :\n    \u21a5s \u2243 sigma fun (x : \u03b1) => \u21a5(set_of fun (y : \u03b2) => (x, y) \u2208 s) :=\n  mk\n    (fun (x : \u21a5s) =>\n      sigma.mk (prod.fst (subtype.val x)) { val := prod.snd (subtype.val x), property := sorry })\n    (fun (x : sigma fun (x : \u03b1) => \u21a5(set_of fun (y : \u03b2) => (x, y) \u2208 s)) =>\n      { val := (sigma.fst x, subtype.val (sigma.snd x)), property := sorry })\n    sorry sorry\n\n/-- For any predicate `p` on `\u03b1`,\nthe sum of the two subtypes `{a // p a}` and its complement `{a // \u00ac p a}`\nis naturally equivalent to `\u03b1`. -/\ndef sum_compl {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] :\n    ((Subtype fun (a : \u03b1) => p a) \u2295 Subtype fun (a : \u03b1) => \u00acp a) \u2243 \u03b1 :=\n  mk (sum.elim coe coe)\n    (fun (a : \u03b1) =>\n      dite (p a) (fun (h : p a) => sum.inl { val := a, property := h })\n        fun (h : \u00acp a) => sum.inr { val := a, property := h })\n    sorry sorry\n\n@[simp] theorem sum_compl_apply_inl {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p]\n    (x : Subtype fun (a : \u03b1) => p a) : coe_fn (sum_compl p) (sum.inl x) = \u2191x :=\n  rfl\n\n@[simp] theorem sum_compl_apply_inr {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p]\n    (x : Subtype fun (a : \u03b1) => \u00acp a) : coe_fn (sum_compl p) (sum.inr x) = \u2191x :=\n  rfl\n\n@[simp] theorem sum_compl_apply_symm_of_pos {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (a : \u03b1)\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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (a : \u03b1)\n    (h : \u00acp 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\u2080 : {a // p a} \u2192 \u03b2` defined on a subtype of `\u03b1`,\nthe subtype of functions `x : \u03b1 \u2192 \u03b2` that agree with `x\u2080` on the subtype `{a // p a}`\nis naturally equivalent to the type of functions `{a // \u00ac p a} \u2192 \u03b2`. -/\n@[simp] theorem subtype_preimage_apply {\u03b1 : Sort u} {\u03b2 : Sort v} (p : \u03b1 \u2192 Prop) [decidable_pred p]\n    (x\u2080 : (Subtype fun (a : \u03b1) => p a) \u2192 \u03b2) (x : Subtype fun (x : \u03b1 \u2192 \u03b2) => x \u2218 coe = x\u2080)\n    (a : Subtype fun (a : \u03b1) => \u00acp a) : coe_fn (subtype_preimage p x\u2080) x a = coe x \u2191a :=\n  Eq.refl (coe_fn (subtype_preimage p x\u2080) x a)\n\ntheorem subtype_preimage_symm_apply_coe_pos {\u03b1 : Sort u} {\u03b2 : Sort v} (p : \u03b1 \u2192 Prop)\n    [decidable_pred p] (x\u2080 : (Subtype fun (a : \u03b1) => p a) \u2192 \u03b2)\n    (x : (Subtype fun (a : \u03b1) => \u00acp a) \u2192 \u03b2) (a : \u03b1) (h : p a) :\n    coe (coe_fn (equiv.symm (subtype_preimage p x\u2080)) x) a = x\u2080 { val := a, property := h } :=\n  dif_pos h\n\ntheorem subtype_preimage_symm_apply_coe_neg {\u03b1 : Sort u} {\u03b2 : Sort v} (p : \u03b1 \u2192 Prop)\n    [decidable_pred p] (x\u2080 : (Subtype fun (a : \u03b1) => p a) \u2192 \u03b2)\n    (x : (Subtype fun (a : \u03b1) => \u00acp a) \u2192 \u03b2) (a : \u03b1) (h : \u00acp a) :\n    coe (coe_fn (equiv.symm (subtype_preimage p x\u2080)) x) a = x { val := a, property := h } :=\n  dif_neg h\n\n/-- If `\u03b1` has a unique term, then the type of function `\u03b1 \u2192 \u03b2` is equivalent to `\u03b2`. -/\n@[simp] theorem fun_unique_apply (\u03b1 : Sort u) (\u03b2 : Sort v) [unique \u03b1] (f : \u03b1 \u2192 \u03b2) :\n    coe_fn (fun_unique \u03b1 \u03b2) f = f Inhabited.default :=\n  Eq.refl (coe_fn (fun_unique \u03b1 \u03b2) f)\n\n/-- A family of equivalences `\u03a0 a, \u03b2\u2081 a \u2243 \u03b2\u2082 a` generates an equivalence between `\u03a0 a, \u03b2\u2081 a` and\n`\u03a0 a, \u03b2\u2082 a`. -/\ndef Pi_congr_right {\u03b1 : Sort u_1} {\u03b2\u2081 : \u03b1 \u2192 Sort u_2} {\u03b2\u2082 : \u03b1 \u2192 Sort u_3}\n    (F : (a : \u03b1) \u2192 \u03b2\u2081 a \u2243 \u03b2\u2082 a) : ((a : \u03b1) \u2192 \u03b2\u2081 a) \u2243 ((a : \u03b1) \u2192 \u03b2\u2082 a) :=\n  mk (fun (H : (a : \u03b1) \u2192 \u03b2\u2081 a) (a : \u03b1) => coe_fn (F a) (H a))\n    (fun (H : (a : \u03b1) \u2192 \u03b2\u2082 a) (a : \u03b1) => coe_fn (equiv.symm (F a)) (H a)) sorry sorry\n\n/-- Dependent `curry` equivalence: the type of dependent functions on `\u03a3 i, \u03b2 i` is equivalent\nto the type of dependent functions of two arguments (i.e., functions to the space of functions). -/\ndef Pi_curry {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (\u03b3 : (a : \u03b1) \u2192 \u03b2 a \u2192 Sort u_3) :\n    ((x : sigma fun (i : \u03b1) => \u03b2 i) \u2192 \u03b3 (sigma.fst x) (sigma.snd x)) \u2243\n        ((a : \u03b1) \u2192 (b : \u03b2 a) \u2192 \u03b3 a b) :=\n  mk\n    (fun (f : (x : sigma fun (i : \u03b1) => \u03b2 i) \u2192 \u03b3 (sigma.fst x) (sigma.snd x)) (x : \u03b1) (y : \u03b2 x) =>\n      f (sigma.mk x y))\n    (fun (f : (a : \u03b1) \u2192 (b : \u03b2 a) \u2192 \u03b3 a b) (x : sigma fun (i : \u03b1) => \u03b2 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 {\u03b1 : Type u_1} (\u03b2 : \u03b1 \u2192 Type u_2) :\n    (psigma fun (i : \u03b1) => \u03b2 i) \u2243 sigma fun (i : \u03b1) => \u03b2 i :=\n  mk (fun (a : psigma fun (i : \u03b1) => \u03b2 i) => sigma.mk (psigma.fst a) (psigma.snd a))\n    (fun (a : sigma fun (i : \u03b1) => \u03b2 i) => psigma.mk (sigma.fst a) (sigma.snd a)) sorry sorry\n\n/-- A family of equivalences `\u03a0 a, \u03b2\u2081 a \u2243 \u03b2\u2082 a` generates an equivalence between `\u03a3 a, \u03b2\u2081 a` and\n`\u03a3 a, \u03b2\u2082 a`. -/\n@[simp] theorem sigma_congr_right_apply {\u03b1 : Type u_1} {\u03b2\u2081 : \u03b1 \u2192 Type u_2} {\u03b2\u2082 : \u03b1 \u2192 Type u_3}\n    (F : (a : \u03b1) \u2192 \u03b2\u2081 a \u2243 \u03b2\u2082 a) (a : sigma fun (a : \u03b1) => \u03b2\u2081 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 {\u03b1 : Type u_1} {\u03b2\u2081 : \u03b1 \u2192 Type u_2} {\u03b2\u2082 : \u03b1 \u2192 Type u_3}\n    {\u03b2\u2083 : \u03b1 \u2192 Type u_4} (F : (a : \u03b1) \u2192 \u03b2\u2081 a \u2243 \u03b2\u2082 a) (G : (a : \u03b1) \u2192 \u03b2\u2082 a \u2243 \u03b2\u2083 a) :\n    equiv.trans (sigma_congr_right F) (sigma_congr_right G) =\n        sigma_congr_right fun (a : \u03b1) => equiv.trans (F a) (G a) :=\n  sorry\n\n@[simp] theorem sigma_congr_right_symm {\u03b1 : Type u_1} {\u03b2\u2081 : \u03b1 \u2192 Type u_2} {\u03b2\u2082 : \u03b1 \u2192 Type u_3}\n    (F : (a : \u03b1) \u2192 \u03b2\u2081 a \u2243 \u03b2\u2082 a) :\n    equiv.symm (sigma_congr_right F) = sigma_congr_right fun (a : \u03b1) => equiv.symm (F a) :=\n  sorry\n\n@[simp] theorem sigma_congr_right_refl {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} :\n    (sigma_congr_right fun (a : \u03b1) => equiv.refl (\u03b2 a)) = equiv.refl (sigma fun (a : \u03b1) => \u03b2 a) :=\n  sorry\n\nnamespace perm\n\n\n/-- A family of permutations `\u03a0 a, perm (\u03b2 a)` generates a permuation `perm (\u03a3 a, \u03b2\u2081 a)`. -/\ndef sigma_congr_right {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (F : (a : \u03b1) \u2192 perm (\u03b2 a)) :\n    perm (sigma fun (a : \u03b1) => \u03b2 a) :=\n  sigma_congr_right F\n\n@[simp] theorem sigma_congr_right_trans {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} (F : (a : \u03b1) \u2192 perm (\u03b2 a))\n    (G : (a : \u03b1) \u2192 perm (\u03b2 a)) :\n    equiv.trans (sigma_congr_right F) (sigma_congr_right G) =\n        sigma_congr_right fun (a : \u03b1) => equiv.trans (F a) (G a) :=\n  sigma_congr_right_trans F G\n\n@[simp] theorem sigma_congr_right_symm {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2}\n    (F : (a : \u03b1) \u2192 perm (\u03b2 a)) :\n    equiv.symm (sigma_congr_right F) = sigma_congr_right fun (a : \u03b1) => equiv.symm (F a) :=\n  sigma_congr_right_symm F\n\n@[simp] theorem sigma_congr_right_refl {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} :\n    (sigma_congr_right fun (a : \u03b1) => equiv.refl (\u03b2 a)) = equiv.refl (sigma fun (a : \u03b1) => \u03b2 a) :=\n  sigma_congr_right_refl\n\nend perm\n\n\n/-- An equivalence `f : \u03b1\u2081 \u2243 \u03b1\u2082` generates an equivalence between `\u03a3 a, \u03b2 (f a)` and `\u03a3 a, \u03b2 a`. -/\ndef sigma_congr_left {\u03b1\u2081 : Type u_1} {\u03b1\u2082 : Type u_2} {\u03b2 : \u03b1\u2082 \u2192 Type u_3} (e : \u03b1\u2081 \u2243 \u03b1\u2082) :\n    (sigma fun (a : \u03b1\u2081) => \u03b2 (coe_fn e a)) \u2243 sigma fun (a : \u03b1\u2082) => \u03b2 a :=\n  mk\n    (fun (a : sigma fun (a : \u03b1\u2081) => \u03b2 (coe_fn e a)) =>\n      sigma.mk (coe_fn e (sigma.fst a)) (sigma.snd a))\n    (fun (a : sigma fun (a : \u03b1\u2082) => \u03b2 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' {\u03b1\u2081 : Type u_1} {\u03b1\u2082 : Type u_2} {\u03b2 : \u03b1\u2081 \u2192 Type u_3} (f : \u03b1\u2081 \u2243 \u03b1\u2082) :\n    (sigma fun (a : \u03b1\u2081) => \u03b2 a) \u2243 sigma fun (a : \u03b1\u2082) => \u03b2 (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 {\u03b1\u2081 : Type u_1} {\u03b1\u2082 : Type u_2} {\u03b2\u2081 : \u03b1\u2081 \u2192 Type u_3} {\u03b2\u2082 : \u03b1\u2082 \u2192 Type u_4}\n    (f : \u03b1\u2081 \u2243 \u03b1\u2082) (F : (a : \u03b1\u2081) \u2192 \u03b2\u2081 a \u2243 \u03b2\u2082 (coe_fn f a)) : sigma \u03b2\u2081 \u2243 sigma \u03b2\u2082 :=\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 (\u03b1 : Type u_1) (\u03b2 : Type u_2) (a : \u03b1 \u00d7 \u03b2) :\n    coe_fn (equiv.symm (sigma_equiv_prod \u03b1 \u03b2)) a = sigma.mk (prod.fst a) (prod.snd a) :=\n  Eq.refl (coe_fn (equiv.symm (sigma_equiv_prod \u03b1 \u03b2)) 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b2\u2081 : \u03b1 \u2192 Type u_3}\n    (F : (a : \u03b1) \u2192 \u03b2\u2081 a \u2243 \u03b2) : sigma \u03b2\u2081 \u2243 \u03b1 \u00d7 \u03b2 :=\n  equiv.trans (sigma_congr_right F) (sigma_equiv_prod \u03b1 \u03b2)\n\n/-- A family of equivalences `\u03a0 (a : \u03b1\u2081), \u03b2\u2081 \u2243 \u03b2\u2082` generates an equivalence\nbetween `\u03b2\u2081 \u00d7 \u03b1\u2081` and `\u03b2\u2082 \u00d7 \u03b1\u2081`. -/\ndef prod_congr_left {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3} (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) :\n    \u03b2\u2081 \u00d7 \u03b1\u2081 \u2243 \u03b2\u2082 \u00d7 \u03b1\u2081 :=\n  mk (fun (ab : \u03b2\u2081 \u00d7 \u03b1\u2081) => (coe_fn (e (prod.snd ab)) (prod.fst ab), prod.snd ab))\n    (fun (ab : \u03b2\u2082 \u00d7 \u03b1\u2081) => (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 {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3}\n    (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) (b : \u03b2\u2081) (a : \u03b1\u2081) :\n    coe_fn (prod_congr_left e) (b, a) = (coe_fn (e a) b, a) :=\n  rfl\n\ntheorem prod_congr_refl_right {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3} (e : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    prod_congr e (equiv.refl \u03b1\u2081) = prod_congr_left fun (_x : \u03b1\u2081) => e :=\n  sorry\n\n/-- A family of equivalences `\u03a0 (a : \u03b1\u2081), \u03b2\u2081 \u2243 \u03b2\u2082` generates an equivalence\nbetween `\u03b1\u2081 \u00d7 \u03b2\u2081` and `\u03b1\u2081 \u00d7 \u03b2\u2082`. -/\ndef prod_congr_right {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3} (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) :\n    \u03b1\u2081 \u00d7 \u03b2\u2081 \u2243 \u03b1\u2081 \u00d7 \u03b2\u2082 :=\n  mk (fun (ab : \u03b1\u2081 \u00d7 \u03b2\u2081) => (prod.fst ab, coe_fn (e (prod.fst ab)) (prod.snd ab)))\n    (fun (ab : \u03b1\u2081 \u00d7 \u03b2\u2082) => (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 {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3}\n    (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) (a : \u03b1\u2081) (b : \u03b2\u2081) :\n    coe_fn (prod_congr_right e) (a, b) = (a, coe_fn (e a) b) :=\n  rfl\n\ntheorem prod_congr_refl_left {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3} (e : \u03b2\u2081 \u2243 \u03b2\u2082) :\n    prod_congr (equiv.refl \u03b1\u2081) e = prod_congr_right fun (_x : \u03b1\u2081) => e :=\n  sorry\n\n@[simp] theorem prod_congr_left_trans_prod_comm {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3}\n    (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) :\n    equiv.trans (prod_congr_left e) (prod_comm \u03b2\u2082 \u03b1\u2081) =\n        equiv.trans (prod_comm \u03b2\u2081 \u03b1\u2081) (prod_congr_right e) :=\n  sorry\n\n@[simp] theorem prod_congr_right_trans_prod_comm {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3}\n    (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) :\n    equiv.trans (prod_congr_right e) (prod_comm \u03b1\u2081 \u03b2\u2082) =\n        equiv.trans (prod_comm \u03b1\u2081 \u03b2\u2081) (prod_congr_left e) :=\n  sorry\n\ntheorem sigma_congr_right_sigma_equiv_prod {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3}\n    (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) :\n    equiv.trans (sigma_congr_right e) (sigma_equiv_prod \u03b1\u2081 \u03b2\u2082) =\n        equiv.trans (sigma_equiv_prod \u03b1\u2081 \u03b2\u2081) (prod_congr_right e) :=\n  sorry\n\ntheorem sigma_equiv_prod_sigma_congr_right {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b2\u2082 : Type u_3}\n    (e : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) :\n    equiv.trans (equiv.symm (sigma_equiv_prod \u03b1\u2081 \u03b2\u2081)) (sigma_congr_right e) =\n        equiv.trans (prod_congr_right e) (equiv.symm (sigma_equiv_prod \u03b1\u2081 \u03b2\u2082)) :=\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 {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} {\u03b1\u2082 : Type u_3}\n    {\u03b2\u2082 : Type u_4} (e\u2081 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u2082 : \u03b1\u2081 \u2192 \u03b2\u2081 \u2243 \u03b2\u2082) :\n    \u21d1(equiv.symm (prod_shear e\u2081 e\u2082)) =\n        fun (y : \u03b1\u2082 \u00d7 \u03b2\u2082) =>\n          (coe_fn (equiv.symm e\u2081) (prod.fst y),\n          coe_fn (equiv.symm (e\u2082 (coe_fn (equiv.symm e\u2081) (prod.fst y)))) (prod.snd y)) :=\n  Eq.refl \u21d1(equiv.symm (prod_shear e\u2081 e\u2082))\n\nnamespace perm\n\n\n/-- `prod_extend_right a e` extends `e : perm \u03b2` to `perm (\u03b1 \u00d7 \u03b2)` by sending `(a, b)` to\n`(a, e b)` and keeping the other `(a', b)` fixed. -/\ndef prod_extend_right {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} [DecidableEq \u03b1\u2081] (a : \u03b1\u2081) (e : perm \u03b2\u2081) :\n    perm (\u03b1\u2081 \u00d7 \u03b2\u2081) :=\n  mk (fun (ab : \u03b1\u2081 \u00d7 \u03b2\u2081) => ite (prod.fst ab = a) (a, coe_fn e (prod.snd ab)) ab)\n    (fun (ab : \u03b1\u2081 \u00d7 \u03b2\u2081) => 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 {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} [DecidableEq \u03b1\u2081] (a : \u03b1\u2081)\n    (e : perm \u03b2\u2081) (b : \u03b2\u2081) : 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 {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} [DecidableEq \u03b1\u2081] (e : perm \u03b2\u2081)\n    {a : \u03b1\u2081} {a' : \u03b1\u2081} (h : a' \u2260 a) (b : \u03b2\u2081) : coe_fn (prod_extend_right a e) (a', b) = (a', b) :=\n  if_neg h\n\ntheorem eq_of_prod_extend_right_ne {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} [DecidableEq \u03b1\u2081] {e : perm \u03b2\u2081}\n    {a : \u03b1\u2081} {a' : \u03b1\u2081} {b : \u03b2\u2081} (h : coe_fn (prod_extend_right a e) (a', b) \u2260 (a', b)) : a' = a :=\n  sorry\n\n@[simp] theorem fst_prod_extend_right {\u03b1\u2081 : Type u_1} {\u03b2\u2081 : Type u_2} [DecidableEq \u03b1\u2081] (a : \u03b1\u2081)\n    (e : perm \u03b2\u2081) (ab : \u03b1\u2081 \u00d7 \u03b2\u2081) : 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 `\u03b1 \u00d7 \u03b2` is equivalent to the type of pairs of functions\n`\u03b3 \u2192 \u03b1` and `\u03b3 \u2192 \u03b2`. -/\ndef arrow_prod_equiv_prod_arrow (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) :\n    (\u03b3 \u2192 \u03b1 \u00d7 \u03b2) \u2243 (\u03b3 \u2192 \u03b1) \u00d7 (\u03b3 \u2192 \u03b2) :=\n  mk (fun (f : \u03b3 \u2192 \u03b1 \u00d7 \u03b2) => (fun (c : \u03b3) => prod.fst (f c), fun (c : \u03b3) => prod.snd (f c)))\n    (fun (p : (\u03b3 \u2192 \u03b1) \u00d7 (\u03b3 \u2192 \u03b2)) (c : \u03b3) => (prod.fst p c, prod.snd p c)) sorry sorry\n\n/-- Functions `\u03b1 \u2192 \u03b2 \u2192 \u03b3` are equivalent to functions on `\u03b1 \u00d7 \u03b2`. -/\ndef arrow_arrow_equiv_prod_arrow (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) :\n    (\u03b1 \u2192 \u03b2 \u2192 \u03b3) \u2243 (\u03b1 \u00d7 \u03b2 \u2192 \u03b3) :=\n  mk function.uncurry function.curry function.curry_uncurry function.uncurry_curry\n\n/-- The type of functions on a sum type `\u03b1 \u2295 \u03b2` is equivalent to the type of pairs of functions\non `\u03b1` and on `\u03b2`. -/\ndef sum_arrow_equiv_prod_arrow (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) :\n    (\u03b1 \u2295 \u03b2 \u2192 \u03b3) \u2243 (\u03b1 \u2192 \u03b3) \u00d7 (\u03b2 \u2192 \u03b3) :=\n  mk (fun (f : \u03b1 \u2295 \u03b2 \u2192 \u03b3) => (f \u2218 sum.inl, f \u2218 sum.inr))\n    (fun (p : (\u03b1 \u2192 \u03b3) \u00d7 (\u03b2 \u2192 \u03b3)) => 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 (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) : (\u03b1 \u2295 \u03b2) \u00d7 \u03b3 \u2243 \u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3 :=\n  mk (fun (p : (\u03b1 \u2295 \u03b2) \u00d7 \u03b3) => sorry) (fun (s : \u03b1 \u00d7 \u03b3 \u2295 \u03b2 \u00d7 \u03b3) => sorry) sorry sorry\n\n@[simp] theorem sum_prod_distrib_apply_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (a : \u03b1)\n    (c : \u03b3) : coe_fn (sum_prod_distrib \u03b1 \u03b2 \u03b3) (sum.inl a, c) = sum.inl (a, c) :=\n  rfl\n\n@[simp] theorem sum_prod_distrib_apply_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (b : \u03b2)\n    (c : \u03b3) : coe_fn (sum_prod_distrib \u03b1 \u03b2 \u03b3) (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 (\u03b1 : Type u_1) (\u03b2 : Type u_2) (\u03b3 : Type u_3) : \u03b1 \u00d7 (\u03b2 \u2295 \u03b3) \u2243 \u03b1 \u00d7 \u03b2 \u2295 \u03b1 \u00d7 \u03b3 :=\n  equiv.trans (equiv.trans (prod_comm \u03b1 (\u03b2 \u2295 \u03b3)) (sum_prod_distrib \u03b2 \u03b3 \u03b1))\n    (sum_congr (prod_comm \u03b2 \u03b1) (prod_comm \u03b3 \u03b1))\n\n@[simp] theorem prod_sum_distrib_apply_left {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (a : \u03b1)\n    (b : \u03b2) : coe_fn (prod_sum_distrib \u03b1 \u03b2 \u03b3) (a, sum.inl b) = sum.inl (a, b) :=\n  rfl\n\n@[simp] theorem prod_sum_distrib_apply_right {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (a : \u03b1)\n    (c : \u03b3) : coe_fn (prod_sum_distrib \u03b1 \u03b2 \u03b3) (a, sum.inr c) = sum.inr (a, c) :=\n  rfl\n\n/-- The product of an indexed sum of types (formally, a `sigma`-type `\u03a3 i, \u03b1 i`) by a type `\u03b2` is\nequivalent to the sum of products `\u03a3 i, (\u03b1 i \u00d7 \u03b2)`. -/\ndef sigma_prod_distrib {\u03b9 : Type u_1} (\u03b1 : \u03b9 \u2192 Type u_2) (\u03b2 : Type u_3) :\n    (sigma fun (i : \u03b9) => \u03b1 i) \u00d7 \u03b2 \u2243 sigma fun (i : \u03b9) => \u03b1 i \u00d7 \u03b2 :=\n  mk\n    (fun (p : (sigma fun (i : \u03b9) => \u03b1 i) \u00d7 \u03b2) =>\n      sigma.mk (sigma.fst (prod.fst p)) (sigma.snd (prod.fst p), prod.snd p))\n    (fun (p : sigma fun (i : \u03b9) => \u03b1 i \u00d7 \u03b2) =>\n      (sigma.mk (sigma.fst p) (prod.fst (sigma.snd p)), prod.snd (sigma.snd p)))\n    sorry sorry\n\n/-- The product `bool \u00d7 \u03b1` is equivalent to `\u03b1 \u2295 \u03b1`. -/\ndef bool_prod_equiv_sum (\u03b1 : Type u) : Bool \u00d7 \u03b1 \u2243 \u03b1 \u2295 \u03b1 :=\n  equiv.trans\n    (equiv.trans (prod_congr bool_equiv_punit_sum_punit (equiv.refl \u03b1))\n      (sum_prod_distrib Unit Unit \u03b1))\n    (sum_congr (punit_prod \u03b1) (punit_prod \u03b1))\n\n/-- The function type `bool \u2192 \u03b1` is equivalent to `\u03b1 \u00d7 \u03b1`. -/\ndef bool_to_equiv_prod (\u03b1 : Type u) : (Bool \u2192 \u03b1) \u2243 \u03b1 \u00d7 \u03b1 :=\n  equiv.trans\n    (equiv.trans (arrow_congr bool_equiv_punit_sum_punit (equiv.refl \u03b1))\n      (sum_arrow_equiv_prod_arrow Unit Unit \u03b1))\n    (prod_congr (punit_arrow_equiv \u03b1) (punit_arrow_equiv \u03b1))\n\n@[simp] theorem bool_to_equiv_prod_apply {\u03b1 : Type u} (f : Bool \u2192 \u03b1) :\n    coe_fn (bool_to_equiv_prod \u03b1) f = (f false, f tt) :=\n  rfl\n\n@[simp] theorem bool_to_equiv_prod_symm_apply_ff {\u03b1 : Type u} (p : \u03b1 \u00d7 \u03b1) :\n    coe_fn (equiv.symm (bool_to_equiv_prod \u03b1)) p false = prod.fst p :=\n  rfl\n\n@[simp] theorem bool_to_equiv_prod_symm_apply_tt {\u03b1 : Type u} (p : \u03b1 \u00d7 \u03b1) :\n    coe_fn (equiv.symm (bool_to_equiv_prod \u03b1)) p tt = prod.snd p :=\n  rfl\n\n/-- The set of natural numbers is equivalent to `\u2115 \u2295 punit`. -/\ndef nat_equiv_nat_sum_punit : \u2115 \u2243 \u2115 \u2295 PUnit :=\n  mk (fun (n : \u2115) => sorry) (fun (s : \u2115 \u2295 PUnit) => sorry) sorry sorry\n\n/-- `\u2115 \u2295 punit` is equivalent to `\u2115`. -/\ndef nat_sum_punit_equiv_nat : \u2115 \u2295 PUnit \u2243 \u2115 := equiv.symm nat_equiv_nat_sum_punit\n\n/-- The type of integer numbers is equivalent to `\u2115 \u2295 \u2115`. -/\ndef int_equiv_nat_sum_nat : \u2124 \u2243 \u2115 \u2295 \u2115 :=\n  mk (fun (z : \u2124) => int.cases_on z (fun (z : \u2115) => sum.inl z) fun (z : \u2115) => sum.inr z)\n    (fun (z : \u2115 \u2295 \u2115) => sum.cases_on z (fun (z : \u2115) => Int.ofNat z) fun (z : \u2115) => Int.negSucc z)\n    sorry sorry\n\n/-- An equivalence between `\u03b1` and `\u03b2` generates an equivalence between `list \u03b1` and `list \u03b2`. -/\ndef list_equiv_of_equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) : List \u03b1 \u2243 List \u03b2 :=\n  mk (list.map \u21d1e) (list.map \u21d1(equiv.symm e)) sorry sorry\n\n/-- `fin n` is equivalent to `{m // m < n}`. -/\ndef fin_equiv_subtype (n : \u2115) : fin n \u2243 Subtype fun (m : \u2115) => m < n :=\n  mk (fun (x : fin n) => { val := subtype.val x, property := sorry })\n    (fun (x : Subtype fun (m : \u2115) => m < n) => { val := subtype.val x, property := sorry }) sorry\n    sorry\n\n/-- If `\u03b1` is equivalent to `\u03b2`, then `unique \u03b1` is equivalent to `\u03b2`. -/\ndef unique_congr {\u03b1 : Sort u} {\u03b2 : Sort v} (e : \u03b1 \u2243 \u03b2) : unique \u03b1 \u2243 unique \u03b2 :=\n  mk (fun (h : unique \u03b1) => equiv.unique (equiv.symm e)) (fun (h : unique \u03b2) => equiv.unique e)\n    sorry sorry\n\n/-- If `\u03b1` is equivalent to `\u03b2` and the predicates `p : \u03b1 \u2192 Prop` and `q : \u03b2 \u2192 Prop` are equivalent\nat corresponding points, then `{a // p a}` is equivalent to `{b // q b}`. -/\ndef subtype_congr {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2)\n    (h : \u2200 (a : \u03b1), p a \u2194 q (coe_fn e a)) :\n    (Subtype fun (a : \u03b1) => p a) \u2243 Subtype fun (b : \u03b2) => q b :=\n  mk (fun (x : Subtype fun (a : \u03b1) => p a) => { val := coe_fn e \u2191x, property := sorry })\n    (fun (y : Subtype fun (b : \u03b2) => q b) => { val := coe_fn (equiv.symm e) \u2191y, property := sorry })\n    sorry sorry\n\n@[simp] theorem subtype_congr_apply {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop}\n    (e : \u03b1 \u2243 \u03b2) (h : \u2200 (a : \u03b1), p a \u2194 q (coe_fn e a)) (x : Subtype fun (x : \u03b1) => p x) :\n    coe_fn (subtype_congr e h) x =\n        { val := coe_fn e \u2191x, property := iff.mp (h \u2191x) (subtype.property x) } :=\n  rfl\n\n@[simp] theorem subtype_congr_symm_apply {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop}\n    (e : \u03b1 \u2243 \u03b2) (h : \u2200 (a : \u03b1), p a \u2194 q (coe_fn e a)) (y : Subtype fun (y : \u03b2) => q y) :\n    coe_fn (equiv.symm (subtype_congr e h)) y =\n        { val := coe_fn (equiv.symm e) \u2191y,\n          property :=\n            iff.mpr (h (coe_fn (equiv.symm e) \u2191y))\n              (Eq.symm (apply_symm_apply e \u2191y) \u25b8 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 {\u03b1 : Sort u} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} (e : \u2200 (x : \u03b1), p x \u2194 q x) :\n    (Subtype fun (x : \u03b1) => p x) \u2243 Subtype fun (x : \u03b1) => q x :=\n  subtype_congr (equiv.refl \u03b1) e\n\n/-- If `\u03b1 \u2243 \u03b2`, then for any predicate `p : \u03b2 \u2192 Prop` the subtype `{a // p (e a)}` is equivalent\nto the subtype `{b // p b}`. -/\ndef subtype_equiv_of_subtype {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) :\n    (Subtype fun (a : \u03b1) => p (coe_fn e a)) \u2243 Subtype fun (b : \u03b2) => p b :=\n  subtype_congr e sorry\n\n/-- If `\u03b1 \u2243 \u03b2`, then for any predicate `p : \u03b1 \u2192 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' {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) :\n    (Subtype fun (a : \u03b1) => p a) \u2243 Subtype fun (b : \u03b2) => 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 {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} (h : p = q) :\n    Subtype p \u2243 Subtype q :=\n  subtype_congr (equiv.refl \u03b1) sorry\n\n/-- The subtypes corresponding to equal sets are equivalent. -/\ndef set_congr {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1} (h : s = t) : \u21a5s \u2243 \u21a5t := 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 \u201cinner\u201d predicate to depend on `h : p a`. -/\ndef subtype_subtype_equiv_subtype_exists {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) (q : Subtype p \u2192 Prop) :\n    Subtype q \u2243 Subtype fun (a : \u03b1) => \u2203 (h : p a), q { val := a, property := h } :=\n  mk (fun (_x : Subtype q) => sorry)\n    (fun (_x : Subtype fun (a : \u03b1) => \u2203 (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 {\u03b1 : Type u} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) :\n    (Subtype fun (x : Subtype p) => q (subtype.val x)) \u2243 Subtype fun (x : \u03b1) => p x \u2227 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 {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop}\n    (h : \u2200 {x : \u03b1}, q x \u2192 p x) : (Subtype fun (x : Subtype p) => q (subtype.val x)) \u2243 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 {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} (h : \u2200 (x : \u03b1), p x) : Subtype p \u2243 \u03b1 :=\n  mk (fun (x : Subtype p) => \u2191x) (fun (x : \u03b1) => { 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 {\u03b1 : Type u} (p : \u03b1 \u2192 Type v) (q : \u03b1 \u2192 Prop) :\n    (Subtype fun (y : sigma p) => q (sigma.fst y)) \u2243\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 {\u03b1 : Type u} (p : \u03b1 \u2192 Type v) (q : \u03b1 \u2192 Prop)\n    (h : \u2200 (x : \u03b1), p x \u2192 q x) : (sigma fun (x : Subtype q) => p \u2191x) \u2243 sigma fun (x : \u03b1) => p x :=\n  equiv.trans (equiv.symm (subtype_sigma_equiv p q)) (subtype_univ_equiv sorry)\n\n/-- If a predicate `p : \u03b2 \u2192 Prop` is true on the range of a map `f : \u03b1 \u2192 \u03b2`, then\n`\u03a3 y : {y // p y}, {x // f x = y}` is equivalent to `\u03b1`. -/\ndef sigma_subtype_preimage_equiv {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (p : \u03b2 \u2192 Prop)\n    (h : \u2200 (x : \u03b1), p (f x)) : (sigma fun (y : Subtype p) => Subtype fun (x : \u03b1) => f x = \u2191y) \u2243 \u03b1 :=\n  equiv.trans\n    (sigma_subtype_equiv_of_subset (fun (y : \u03b2) => Subtype fun (x : \u03b1) => f x = y) p sorry)\n    (sigma_preimage_equiv f)\n\n/-- If for each `x` we have `p x \u2194 q (f x)`, then `\u03a3 y : {y // q y}, f \u207b\u00b9' {y}` is equivalent\nto `{x // p x}`. -/\ndef sigma_subtype_preimage_equiv_subtype {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) {p : \u03b1 \u2192 Prop}\n    {q : \u03b2 \u2192 Prop} (h : \u2200 (x : \u03b1), p x \u2194 q (f x)) :\n    (sigma fun (y : Subtype q) => Subtype fun (x : \u03b1) => f x = \u2191y) \u2243 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 \u2191x, property := sorry } = y)\n            (subtype_congr_right sorry)))\n    (sigma_preimage_equiv fun (x : Subtype p) => { val := f \u2191x, property := sorry })\n\n/-- The `pi`-type `\u03a0 i, \u03c0 i` is equivalent to the type of sections `f : \u03b9 \u2192 \u03a3 i, \u03c0 i` of the\n`sigma` type such that for all `i` we have `(f i).fst = i`. -/\ndef pi_equiv_subtype_sigma (\u03b9 : Type u_1) (\u03c0 : \u03b9 \u2192 Type u_2) :\n    ((i : \u03b9) \u2192 \u03c0 i) \u2243\n        \u21a5(set_of fun (f : \u03b9 \u2192 sigma fun (i : \u03b9) => \u03c0 i) => \u2200 (i : \u03b9), sigma.fst (f i) = i) :=\n  mk (fun (f : (i : \u03b9) \u2192 \u03c0 i) => { val := fun (i : \u03b9) => sigma.mk i (f i), property := sorry })\n    (fun (f : \u21a5(set_of fun (f : \u03b9 \u2192 sigma fun (i : \u03b9) => \u03c0 i) => \u2200 (i : \u03b9), sigma.fst (f i) = i))\n      (i : \u03b9) => eq.mpr sorry (sigma.snd (subtype.val f i)))\n    sorry sorry\n\n/-- The set of functions `f : \u03a0 a, \u03b2 a` such that for all `a` we have `p a (f a)` is equivalent\nto the set of functions `\u03a0 a, {b : \u03b2 a // p a b}`. -/\ndef subtype_pi_equiv_pi {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {p : (a : \u03b1) \u2192 \u03b2 a \u2192 Prop} :\n    (Subtype fun (f : (a : \u03b1) \u2192 \u03b2 a) => \u2200 (a : \u03b1), p a (f a)) \u2243\n        ((a : \u03b1) \u2192 Subtype fun (b : \u03b2 a) => p a b) :=\n  mk\n    (fun (f : Subtype fun (f : (a : \u03b1) \u2192 \u03b2 a) => \u2200 (a : \u03b1), p a (f a)) (a : \u03b1) =>\n      { val := subtype.val f a, property := sorry })\n    (fun (f : (a : \u03b1) \u2192 Subtype fun (b : \u03b2 a) => p a b) =>\n      { val := fun (a : \u03b1) => 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 {\u03b1 : Type u} {\u03b2 : Type v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} :\n    (Subtype fun (c : \u03b1 \u00d7 \u03b2) => p (prod.fst c) \u2227 q (prod.snd c)) \u2243\n        (Subtype fun (a : \u03b1) => p a) \u00d7 Subtype fun (b : \u03b2) => q b :=\n  mk\n    (fun (x : Subtype fun (c : \u03b1 \u00d7 \u03b2) => p (prod.fst c) \u2227 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 : \u03b1) => p a) \u00d7 Subtype fun (b : \u03b2) => 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 \u2192 Y` with prescribed values for all `x' \u2260 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' \u2260 x) \u2192 Y) : (Subtype fun (g : X \u2192 Y) => g \u2218 coe = f) \u2243 Y :=\n  equiv.trans (subtype_preimage (fun (x' : X) => x' \u2260 x) f)\n    (fun_unique (Subtype fun (a : X) => \u00aca \u2260 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' \u2260 x) \u2192 Y) :\n    \u21d1(subtype_equiv_codomain f) = fun (g : Subtype fun (g : X \u2192 Y) => g \u2218 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' \u2260 x) \u2192 Y) (g : Subtype fun (g : X \u2192 Y) => g \u2218 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' \u2260 x) \u2192 Y) :\n    \u21d1(equiv.symm (subtype_equiv_codomain f)) =\n        fun (y : Y) =>\n          { val :=\n              fun (x' : X) =>\n                dite (x' \u2260 x) (fun (h : x' \u2260 x) => f { val := x', property := h })\n                  fun (h : \u00acx' \u2260 x) => y,\n            property :=\n              funext\n                fun (x' : Subtype fun (x' : X) => x' \u2260 x) =>\n                  id\n                    (eq.mpr\n                      (id\n                        (Eq._oldrec\n                          (Eq.refl\n                            ((dite (\u00ac\u2191x' = x)\n                                (fun (h : \u00ac\u2191x' = x) => f { val := \u2191x', property := h })\n                                fun (h : \u00ac\u00ac\u2191x' = x) => y) =\n                              f x'))\n                          (dif_pos (subtype.property x'))))\n                      (eq.mpr\n                        (id\n                          (Eq._oldrec\n                            (Eq.refl (f { val := \u2191x', 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' \u2260 x) \u2192 Y) (y : Y) (x' : X) :\n    coe (coe_fn (equiv.symm (subtype_equiv_codomain f)) y) x' =\n        dite (x' \u2260 x) (fun (h : x' \u2260 x) => f { val := x', property := h }) fun (h : \u00acx' \u2260 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' \u2260 x) \u2192 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' \u2260 x) \u2192 Y) (y : Y) (x' : X) (h : x' \u2260 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 \u03b1` is equivalent to `\u03b1`. -/\n@[simp] theorem univ_symm_apply (\u03b1 : Type u_1) (a : \u03b1) :\n    coe_fn (equiv.symm (set.univ \u03b1)) a = { val := a, property := trivial } :=\n  Eq.refl (coe_fn (equiv.symm (set.univ \u03b1)) a)\n\n/-- An empty set is equivalent to the `empty` type. -/\nprotected def empty (\u03b1 : Type u_1) : \u21a5\u2205 \u2243 empty := equiv_empty sorry\n\n/-- An empty set is equivalent to a `pempty` type. -/\nprotected def pempty (\u03b1 : Type u_1) : \u21a5\u2205 \u2243 pempty := equiv_pempty sorry\n\n/-- If sets `s` and `t` are separated by a decidable predicate, then `s \u222a t` is equivalent to\n`s \u2295 t`. -/\nprotected def union' {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1} (p : \u03b1 \u2192 Prop) [decidable_pred p]\n    (hs : \u2200 (x : \u03b1), x \u2208 s \u2192 p x) (ht : \u2200 (x : \u03b1), x \u2208 t \u2192 \u00acp x) : \u21a5(s \u222a t) \u2243 \u21a5s \u2295 \u21a5t :=\n  mk\n    (fun (x : \u21a5(s \u222a t)) =>\n      dite (p \u2191x) (fun (hp : p \u2191x) => sum.inl { val := subtype.val x, property := sorry })\n        fun (hp : \u00acp \u2191x) => sum.inr { val := subtype.val x, property := sorry })\n    (fun (o : \u21a5s \u2295 \u21a5t) => sorry) sorry sorry\n\n/-- If sets `s` and `t` are disjoint, then `s \u222a t` is equivalent to `s \u2295 t`. -/\nprotected def union {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1} [decidable_pred fun (x : \u03b1) => x \u2208 s]\n    (H : s \u2229 t \u2286 \u2205) : \u21a5(s \u222a t) \u2243 \u21a5s \u2295 \u21a5t :=\n  set.union' (fun (x : \u03b1) => x \u2208 s) sorry sorry\n\ntheorem union_apply_left {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1}\n    [decidable_pred fun (x : \u03b1) => x \u2208 s] (H : s \u2229 t \u2286 \u2205) {a : \u21a5(s \u222a t)} (ha : \u2191a \u2208 s) :\n    coe_fn (set.union H) a = sum.inl { val := \u2191a, property := ha } :=\n  dif_pos ha\n\ntheorem union_apply_right {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1}\n    [decidable_pred fun (x : \u03b1) => x \u2208 s] (H : s \u2229 t \u2286 \u2205) {a : \u21a5(s \u222a t)} (ha : \u2191a \u2208 t) :\n    coe_fn (set.union H) a = sum.inr { val := \u2191a, property := ha } :=\n  dif_neg fun (h : \u2191a \u2208 s) => H { left := h, right := ha }\n\n@[simp] theorem union_symm_apply_left {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1}\n    [decidable_pred fun (x : \u03b1) => x \u2208 s] (H : s \u2229 t \u2286 \u2205) (a : \u21a5s) :\n    coe_fn (equiv.symm (set.union H)) (sum.inl a) =\n        { val := \u2191a, property := set.subset_union_left s t (subtype.property a) } :=\n  rfl\n\n@[simp] theorem union_symm_apply_right {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1}\n    [decidable_pred fun (x : \u03b1) => x \u2208 s] (H : s \u2229 t \u2286 \u2205) (a : \u21a5t) :\n    coe_fn (equiv.symm (set.union H)) (sum.inr a) =\n        { val := \u2191a, 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 {\u03b1 : Type u_1} (a : \u03b1) : \u21a5(singleton a) \u2243 PUnit :=\n  mk (fun (_x : \u21a5(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 {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} (h : s = t) (x : \u21a5t) :\n    coe_fn (equiv.symm (set.of_eq h)) x = { val := \u2191x, property := of_eq._proof_2 h x } :=\n  Eq.refl (coe_fn (equiv.symm (set.of_eq h)) x)\n\n/-- If `a \u2209 s`, then `insert a s` is equivalent to `s \u2295 punit`. -/\nprotected def insert {\u03b1 : Type u} {s : set \u03b1} [decidable_pred s] {a : \u03b1} (H : \u00aca \u2208 s) :\n    \u21a5(insert a s) \u2243 \u21a5s \u2295 PUnit :=\n  equiv.trans (equiv.trans (set.of_eq sorry) (set.union sorry))\n    (sum_congr (equiv.refl \u21a5s) (set.singleton a))\n\n@[simp] theorem insert_symm_apply_inl {\u03b1 : Type u} {s : set \u03b1} [decidable_pred s] {a : \u03b1}\n    (H : \u00aca \u2208 s) (b : \u21a5s) :\n    coe_fn (equiv.symm (set.insert H)) (sum.inl b) =\n        { val := \u2191b, property := Or.inr (subtype.property b) } :=\n  rfl\n\n@[simp] theorem insert_symm_apply_inr {\u03b1 : Type u} {s : set \u03b1} [decidable_pred s] {a : \u03b1}\n    (H : \u00aca \u2208 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 {\u03b1 : Type u} {s : set \u03b1} [decidable_pred s] {a : \u03b1} (H : \u00aca \u2208 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 {\u03b1 : Type u} {s : set \u03b1} [decidable_pred s] {a : \u03b1} (H : \u00aca \u2208 s)\n    (b : \u21a5s) :\n    coe_fn (set.insert H) { val := \u2191b, 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 \u03b1` is a set with decidable membership, then `s \u2295 s\u1d9c` is equivalent to `\u03b1`. -/\nprotected def sum_compl {\u03b1 : Type u_1} (s : set \u03b1) [decidable_pred s] : \u21a5s \u2295 \u21a5(s\u1d9c) \u2243 \u03b1 :=\n  equiv.trans (equiv.trans (equiv.symm (set.union sorry)) (set.of_eq sorry)) (set.univ \u03b1)\n\n@[simp] theorem sum_compl_apply_inl {\u03b1 : Type u} (s : set \u03b1) [decidable_pred s] (x : \u21a5s) :\n    coe_fn (set.sum_compl s) (sum.inl x) = \u2191x :=\n  rfl\n\n@[simp] theorem sum_compl_apply_inr {\u03b1 : Type u} (s : set \u03b1) [decidable_pred s] (x : \u21a5(s\u1d9c)) :\n    coe_fn (set.sum_compl s) (sum.inr x) = \u2191x :=\n  rfl\n\ntheorem sum_compl_symm_apply_of_mem {\u03b1 : Type u} {s : set \u03b1} [decidable_pred s] {x : \u03b1}\n    (hx : x \u2208 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 {\u03b1 : Type u} {s : set \u03b1} [decidable_pred s] {x : \u03b1}\n    (hx : \u00acx \u2208 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 {\u03b1 : Type u_1} {s : set \u03b1} [decidable_pred s] {x : \u21a5s} :\n    coe_fn (equiv.symm (set.sum_compl s)) \u2191x = sum.inl x :=\n  subtype.cases_on x fun (x : \u03b1) (hx : x \u2208 s) => sum_compl_symm_apply_of_mem hx\n\n@[simp] theorem sum_compl_symm_apply_compl {\u03b1 : Type u_1} {s : set \u03b1} [decidable_pred s]\n    {x : \u21a5(s\u1d9c)} : coe_fn (equiv.symm (set.sum_compl s)) \u2191x = sum.inr x :=\n  subtype.cases_on x fun (x : \u03b1) (hx : x \u2208 (s\u1d9c)) => sum_compl_symm_apply_of_not_mem hx\n\n/-- `sum_diff_subset s t` is the natural equivalence between\n`s \u2295 (t \\ s)` and `t`, where `s` and `t` are two sets. -/\nprotected def sum_diff_subset {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1} (h : s \u2286 t)\n    [decidable_pred s] : \u21a5s \u2295 \u21a5(t \\ s) \u2243 \u21a5t :=\n  equiv.trans (equiv.symm (set.union sorry)) (set.of_eq sorry)\n\n@[simp] theorem sum_diff_subset_apply_inl {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1} (h : s \u2286 t)\n    [decidable_pred s] (x : \u21a5s) : 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 {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1} (h : s \u2286 t)\n    [decidable_pred s] (x : \u21a5(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 {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1} (h : s \u2286 t)\n    [decidable_pred s] {x : \u21a5t} (hx : subtype.val x \u2208 s) :\n    coe_fn (equiv.symm (set.sum_diff_subset h)) x = sum.inl { val := \u2191x, property := hx } :=\n  sorry\n\ntheorem sum_diff_subset_symm_apply_of_not_mem {\u03b1 : Type u_1} {s : set \u03b1} {t : set \u03b1} (h : s \u2286 t)\n    [decidable_pred s] {x : \u21a5t} (hx : \u00acsubtype.val x \u2208 s) :\n    coe_fn (equiv.symm (set.sum_diff_subset h)) x =\n        sum.inr { val := \u2191x, property := { left := subtype.property x, right := hx } } :=\n  sorry\n\n/-- If `s` is a set with decidable membership, then the sum of `s \u222a t` and `s \u2229 t` is equivalent\nto `s \u2295 t`. -/\nprotected def union_sum_inter {\u03b1 : Type u} (s : set \u03b1) (t : set \u03b1) [decidable_pred s] :\n    \u21a5(s \u222a t) \u2295 \u21a5(s \u2229 t) \u2243 \u21a5s \u2295 \u21a5t :=\n  equiv.trans\n    (equiv.trans\n      (equiv.trans\n        (equiv.trans (eq.mpr sorry (equiv.refl (\u21a5(s \u222a t) \u2295 \u21a5(s \u2229 t))))\n          (sum_congr (set.union sorry) (equiv.refl \u21a5(s \u2229 t))))\n        (sum_assoc \u21a5s \u21a5(t \\ s) \u21a5(s \u2229 t)))\n      (sum_congr (equiv.refl \u21a5s) (equiv.symm (set.union' (fun (_x : \u03b1) => \u00ac_x \u2208 s) sorry sorry))))\n    (eq.mpr sorry (equiv.refl (\u21a5s \u2295 \u21a5t)))\n\n/-- Given an equivalence `e\u2080` between sets `s : set \u03b1` and `t : set \u03b2`, the set of equivalences\n`e : \u03b1 \u2243 \u03b2` such that `e \u2191x = \u2191(e\u2080 x)` for each `x : s` is equivalent to the set of equivalences\nbetween `s\u1d9c` and `t\u1d9c`. -/\nprotected def compl {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : set \u03b2} [decidable_pred s]\n    [decidable_pred t] (e\u2080 : \u21a5s \u2243 \u21a5t) :\n    (Subtype fun (e : \u03b1 \u2243 \u03b2) => \u2200 (x : \u21a5s), coe_fn e \u2191x = \u2191(coe_fn e\u2080 x)) \u2243 (\u21a5(s\u1d9c) \u2243 \u21a5(t\u1d9c)) :=\n  mk\n    (fun (e : Subtype fun (e : \u03b1 \u2243 \u03b2) => \u2200 (x : \u21a5s), coe_fn e \u2191x = \u2191(coe_fn e\u2080 x)) =>\n      subtype_congr \u2191e sorry)\n    (fun (e\u2081 : \u21a5(s\u1d9c) \u2243 \u21a5(t\u1d9c)) =>\n      { val :=\n          equiv.trans (equiv.trans (equiv.symm (set.sum_compl s)) (sum_congr e\u2080 e\u2081))\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : set \u03b1) (t : set \u03b2) :\n    \u21a5(set.prod s t) \u2243 \u21a5s \u00d7 \u21a5t :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (s : set \u03b1)\n    (H : set.inj_on f s) : \u21a5s \u2243 \u21a5(f '' s) :=\n  mk (fun (p : \u21a5s) => { val := f \u2191p, property := sorry })\n    (fun (p : \u21a5(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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (s : set \u03b1)\n    (H : function.injective f) (p : \u21a5s) :\n    coe_fn (set.image f s H) p = { val := f \u2191p, property := image_of_inj_on._proof_1 f s p } :=\n  Eq.refl { val := f \u2191p, property := image_of_inj_on._proof_1 f s p }\n\ntheorem image_symm_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} (hf : function.injective f)\n    (u : set \u03b1) (s : set \u03b1) :\n    (fun (x : \u21a5(f '' s)) => \u2191(coe_fn (equiv.symm (set.image f s hf)) x)) \u207b\u00b9' u = coe \u207b\u00b9' (f '' u) :=\n  sorry\n\n/-- If `f : \u03b1 \u2192 \u03b2` is an injective function, then `\u03b1` is equivalent to the range of `f`. -/\n@[simp] theorem range_apply {\u03b1 : Sort u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (H : function.injective f)\n    (x : \u03b1) : 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 {\u03b1 : Sort u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (H : function.injective f)\n    (b : \u21a5(set.range f)) : f (coe_fn (equiv.symm (set.range f H)) b) = \u2191b :=\n  sorry\n\n/-- If `\u03b1` is equivalent to `\u03b2`, then `set \u03b1` is equivalent to `set \u03b2`. -/\nprotected def congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) : set \u03b1 \u2243 set \u03b2 :=\n  mk (fun (s : set \u03b1) => \u21d1e '' s) (fun (t : set \u03b2) => \u21d1(equiv.symm e) '' t) (symm_image_image e)\n    sorry\n\n/-- The set `{x \u2208 s | t x}` is equivalent to the set of `x : s` such that `t x`. -/\nprotected def sep {\u03b1 : Type u} (s : set \u03b1) (t : \u03b1 \u2192 Prop) :\n    \u21a5(has_sep.sep (fun (x : \u03b1) => t x) s) \u2243 \u21a5(set_of fun (x : \u21a5s) => t \u2191x) :=\n  equiv.symm (subtype_subtype_equiv_subtype_inter s t)\n\n/-- The set `\ud835\udcab S := {x | x \u2286 S}` is equivalent to the type `set S`. -/\nprotected def powerset {\u03b1 : Type u_1} (S : set \u03b1) : \u21a5(\ud835\udcab S) \u2243 set \u21a5S :=\n  mk (fun (x : \u21a5(\ud835\udcab S)) => coe \u207b\u00b9' \u2191x) (fun (x : set \u21a5S) => { 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 {\u03b1 : Sort u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (hf : function.bijective f) : \u03b1 \u2243 \u03b2 :=\n  equiv.trans (set.range f sorry) (equiv.trans (set_congr sorry) (set.univ \u03b2))\n\ntheorem of_bijective_apply_symm_apply {\u03b1 : Sort u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2)\n    (hf : function.bijective f) (x : \u03b2) : 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 {\u03b1 : Sort u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2)\n    (hf : function.bijective f) (x : \u03b1) : 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 {\u03b1 : Sort u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2)\n    (hf : function.injective f) :\n    \u2200 (\u1fb0 : \u03b1), coe_fn (of_injective f hf) \u1fb0 = { val := f \u1fb0, property := set.mem_range_self \u1fb0 } :=\n  fun (\u1fb0 : \u03b1) => Eq.refl { val := f \u1fb0, property := set.mem_range_self \u1fb0 }\n\n/-- Subtype of the quotient is equivalent to the quotient of the subtype. Let `\u03b1` be a setoid with\nequivalence relation `~`. Let `p\u2082` be a predicate on the quotient type `\u03b1/~`, and `p\u2081` be the lift\nof this predicate to `\u03b1`: `p\u2081 a \u2194 p\u2082 \u27e6a\u27e7`. Let `~\u2082` be the restriction of `~` to `{x // p\u2081 x}`.\nThen `{x // p\u2082 x}` is equivalent to the quotient of `{x // p\u2081 x}` by `~\u2082`. -/\ndef subtype_quotient_equiv_quotient_subtype {\u03b1 : Sort u} (p\u2081 : \u03b1 \u2192 Prop) [s\u2081 : setoid \u03b1]\n    [s\u2082 : setoid (Subtype p\u2081)] (p\u2082 : quotient s\u2081 \u2192 Prop)\n    (hp\u2082 : \u2200 (a : \u03b1), p\u2081 a \u2194 p\u2082 (quotient.mk a))\n    (h : \u2200 (x y : Subtype p\u2081), setoid.r x y \u2194 \u2191x \u2248 \u2191y) :\n    (Subtype fun (x : quotient s\u2081) => p\u2082 x) \u2243 quotient s\u2082 :=\n  mk\n    (fun (a : Subtype fun (x : quotient s\u2081) => p\u2082 x) =>\n      quotient.hrec_on (subtype.val a)\n        (fun (a : \u03b1) (h : p\u2082 (quotient.mk a)) => quotient.mk { val := a, property := sorry }) sorry\n        sorry)\n    (fun (a : quotient s\u2082) =>\n      quotient.lift_on a\n        (fun (a : Subtype p\u2081) => { val := quotient.mk (subtype.val a), property := sorry }) sorry)\n    sorry sorry\n\n/-- A helper function for `equiv.swap`. -/\ndef swap_core {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) (r : \u03b1) : \u03b1 :=\n  ite (r = a) b (ite (r = b) a r)\n\ntheorem swap_core_self {\u03b1 : Sort u} [DecidableEq \u03b1] (r : \u03b1) (a : \u03b1) : swap_core a a r = r := sorry\n\ntheorem swap_core_swap_core {\u03b1 : Sort u} [DecidableEq \u03b1] (r : \u03b1) (a : \u03b1) (b : \u03b1) :\n    swap_core a b (swap_core a b r) = r :=\n  sorry\n\ntheorem swap_core_comm {\u03b1 : Sort u} [DecidableEq \u03b1] (r : \u03b1) (a : \u03b1) (b : \u03b1) :\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 {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) : perm \u03b1 :=\n  mk (swap_core a b) (swap_core a b) sorry sorry\n\n@[simp] theorem swap_self {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) : swap a a = equiv.refl \u03b1 :=\n  ext fun (r : \u03b1) => swap_core_self r a\n\ntheorem swap_comm {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) : swap a b = swap b a :=\n  ext fun (r : \u03b1) => swap_core_comm r a b\n\ntheorem swap_apply_def {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) (x : \u03b1) :\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 {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) :\n    coe_fn (swap a b) a = b :=\n  if_pos rfl\n\n@[simp] theorem swap_apply_right {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) :\n    coe_fn (swap a b) b = a :=\n  sorry\n\ntheorem swap_apply_of_ne_of_ne {\u03b1 : Sort u} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {x : \u03b1} :\n    x \u2260 a \u2192 x \u2260 b \u2192 coe_fn (swap a b) x = x :=\n  sorry\n\n@[simp] theorem swap_swap {\u03b1 : Sort u} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) :\n    equiv.trans (swap a b) (swap a b) = equiv.refl \u03b1 :=\n  ext fun (x : \u03b1) => swap_core_swap_core x a b\n\ntheorem swap_comp_apply {\u03b1 : Sort u} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {x : \u03b1} (\u03c0 : perm \u03b1) :\n    coe_fn (equiv.trans \u03c0 (swap a b)) x =\n        ite (coe_fn \u03c0 x = a) b (ite (coe_fn \u03c0 x = b) a (coe_fn \u03c0 x)) :=\n  sorry\n\ntheorem swap_eq_update {\u03b1 : Sort u} [DecidableEq \u03b1] (i : \u03b1) (j : \u03b1) :\n    \u21d1(swap i j) = function.update (function.update id j i) i j :=\n  sorry\n\ntheorem comp_swap_eq_update {\u03b1 : Sort u} {\u03b2 : Sort v} [DecidableEq \u03b1] (i : \u03b1) (j : \u03b1) (f : \u03b1 \u2192 \u03b2) :\n    f \u2218 \u21d1(swap i j) = function.update (function.update f j (f i)) i (f j) :=\n  sorry\n\n@[simp] theorem symm_trans_swap_trans {\u03b1 : Sort u} {\u03b2 : Sort v} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    (a : \u03b1) (b : \u03b1) (e : \u03b1 \u2243 \u03b2) :\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 {\u03b1 : Sort u} {\u03b2 : Sort v} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    (a : \u03b2) (b : \u03b2) (e : \u03b1 \u2243 \u03b2) :\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 {\u03b1 : Sort u} [DecidableEq \u03b1] (i : \u03b1) (j : \u03b1) (a : \u03b1) :\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 {\u03b1 : Sort u} {\u03b2 : Sort v} [DecidableEq \u03b1] {v : \u03b1 \u2192 \u03b2} {i : \u03b1} {j : \u03b1}\n    (hv : v i = v j) (k : \u03b1) : v (coe_fn (swap i j) k) = v k :=\n  sorry\n\nnamespace perm\n\n\n@[simp] theorem sum_congr_swap_refl {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    (i : \u03b1) (j : \u03b1) : sum_congr (swap i j) (equiv.refl \u03b2) = swap (sum.inl i) (sum.inl j) :=\n  sorry\n\n@[simp] theorem sum_congr_refl_swap {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    (i : \u03b2) (j : \u03b2) : sum_congr (equiv.refl \u03b1) (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 {\u03b1 : Sort u} {\u03b2 : Sort v} [DecidableEq \u03b1] (f : \u03b1 \u2243 \u03b2) (a : \u03b1) (b : \u03b2) : \u03b1 \u2243 \u03b2 :=\n  equiv.trans (swap a (coe_fn (equiv.symm f) b)) f\n\n@[simp] theorem set_value_eq {\u03b1 : Sort u} {\u03b2 : Sort v} [DecidableEq \u03b1] (f : \u03b1 \u2243 \u03b2) (a : \u03b1) (b : \u03b2) :\n    coe_fn (set_value f a b) a = b :=\n  sorry\n\nprotected theorem exists_unique_congr {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2243 \u03b2) (h : \u2200 {x : \u03b1}, p x \u2194 q (coe_fn f x)) :\n    (exists_unique fun (x : \u03b1) => p x) \u2194 exists_unique fun (y : \u03b2) => q y :=\n  sorry\n\nprotected theorem exists_unique_congr_left' {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} (f : \u03b1 \u2243 \u03b2) :\n    (exists_unique fun (x : \u03b1) => p x) \u2194 exists_unique fun (y : \u03b2) => p (coe_fn (equiv.symm f) y) :=\n  sorry\n\nprotected theorem exists_unique_congr_left {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b2 \u2192 Prop} (f : \u03b1 \u2243 \u03b2) :\n    (exists_unique fun (x : \u03b1) => p (coe_fn f x)) \u2194 exists_unique fun (y : \u03b2) => p y :=\n  iff.symm (equiv.exists_unique_congr_left' (equiv.symm f))\n\nprotected theorem forall_congr {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (f : \u03b1 \u2243 \u03b2)\n    (h : \u2200 {x : \u03b1}, p x \u2194 q (coe_fn f x)) : (\u2200 (x : \u03b1), p x) \u2194 \u2200 (y : \u03b2), q y :=\n  sorry\n\nprotected theorem forall_congr' {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} (f : \u03b1 \u2243 \u03b2)\n    (h : \u2200 {x : \u03b2}, p (coe_fn (equiv.symm f) x) \u2194 q x) : (\u2200 (x : \u03b1), p x) \u2194 \u2200 (y : \u03b2), q y :=\n  iff.symm (equiv.forall_congr (equiv.symm f) fun (x : \u03b2) => 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\u2082_congr {\u03b1\u2081 : Sort ua1} {\u03b1\u2082 : Sort ua2} {\u03b2\u2081 : Sort ub1} {\u03b2\u2082 : Sort ub2}\n    {p : \u03b1\u2081 \u2192 \u03b2\u2081 \u2192 Prop} {q : \u03b1\u2082 \u2192 \u03b2\u2082 \u2192 Prop} (e\u03b1 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u03b2 : \u03b2\u2081 \u2243 \u03b2\u2082)\n    (h : \u2200 {x : \u03b1\u2081} {y : \u03b2\u2081}, p x y \u2194 q (coe_fn e\u03b1 x) (coe_fn e\u03b2 y)) :\n    (\u2200 (x : \u03b1\u2081) (y : \u03b2\u2081), p x y) \u2194 \u2200 (x : \u03b1\u2082) (y : \u03b2\u2082), q x y :=\n  equiv.forall_congr e\u03b1 fun (x : \u03b1\u2081) => equiv.forall_congr e\u03b2 fun (x_1 : \u03b2\u2081) => h\n\nprotected theorem forall\u2082_congr' {\u03b1\u2081 : Sort ua1} {\u03b1\u2082 : Sort ua2} {\u03b2\u2081 : Sort ub1} {\u03b2\u2082 : Sort ub2}\n    {p : \u03b1\u2081 \u2192 \u03b2\u2081 \u2192 Prop} {q : \u03b1\u2082 \u2192 \u03b2\u2082 \u2192 Prop} (e\u03b1 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u03b2 : \u03b2\u2081 \u2243 \u03b2\u2082)\n    (h : \u2200 {x : \u03b1\u2082} {y : \u03b2\u2082}, p (coe_fn (equiv.symm e\u03b1) x) (coe_fn (equiv.symm e\u03b2) y) \u2194 q x y) :\n    (\u2200 (x : \u03b1\u2081) (y : \u03b2\u2081), p x y) \u2194 \u2200 (x : \u03b1\u2082) (y : \u03b2\u2082), q x y :=\n  iff.symm (equiv.forall\u2082_congr (equiv.symm e\u03b1) (equiv.symm e\u03b2) fun (x : \u03b1\u2082) (y : \u03b2\u2082) => iff.symm h)\n\nprotected theorem forall\u2083_congr {\u03b1\u2081 : Sort ua1} {\u03b1\u2082 : Sort ua2} {\u03b2\u2081 : Sort ub1} {\u03b2\u2082 : Sort ub2}\n    {\u03b3\u2081 : Sort ug1} {\u03b3\u2082 : Sort ug2} {p : \u03b1\u2081 \u2192 \u03b2\u2081 \u2192 \u03b3\u2081 \u2192 Prop} {q : \u03b1\u2082 \u2192 \u03b2\u2082 \u2192 \u03b3\u2082 \u2192 Prop}\n    (e\u03b1 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u03b2 : \u03b2\u2081 \u2243 \u03b2\u2082) (e\u03b3 : \u03b3\u2081 \u2243 \u03b3\u2082)\n    (h : \u2200 {x : \u03b1\u2081} {y : \u03b2\u2081} {z : \u03b3\u2081}, p x y z \u2194 q (coe_fn e\u03b1 x) (coe_fn e\u03b2 y) (coe_fn e\u03b3 z)) :\n    (\u2200 (x : \u03b1\u2081) (y : \u03b2\u2081) (z : \u03b3\u2081), p x y z) \u2194 \u2200 (x : \u03b1\u2082) (y : \u03b2\u2082) (z : \u03b3\u2082), q x y z :=\n  equiv.forall\u2082_congr e\u03b1 e\u03b2 fun (x : \u03b1\u2081) (y : \u03b2\u2081) => equiv.forall_congr e\u03b3 fun (x_1 : \u03b3\u2081) => h\n\nprotected theorem forall\u2083_congr' {\u03b1\u2081 : Sort ua1} {\u03b1\u2082 : Sort ua2} {\u03b2\u2081 : Sort ub1} {\u03b2\u2082 : Sort ub2}\n    {\u03b3\u2081 : Sort ug1} {\u03b3\u2082 : Sort ug2} {p : \u03b1\u2081 \u2192 \u03b2\u2081 \u2192 \u03b3\u2081 \u2192 Prop} {q : \u03b1\u2082 \u2192 \u03b2\u2082 \u2192 \u03b3\u2082 \u2192 Prop}\n    (e\u03b1 : \u03b1\u2081 \u2243 \u03b1\u2082) (e\u03b2 : \u03b2\u2081 \u2243 \u03b2\u2082) (e\u03b3 : \u03b3\u2081 \u2243 \u03b3\u2082)\n    (h :\n      \u2200 {x : \u03b1\u2082} {y : \u03b2\u2082} {z : \u03b3\u2082},\n        p (coe_fn (equiv.symm e\u03b1) x) (coe_fn (equiv.symm e\u03b2) y) (coe_fn (equiv.symm e\u03b3) z) \u2194\n          q x y z) :\n    (\u2200 (x : \u03b1\u2081) (y : \u03b2\u2081) (z : \u03b3\u2081), p x y z) \u2194 \u2200 (x : \u03b1\u2082) (y : \u03b2\u2082) (z : \u03b3\u2082), q x y z :=\n  iff.symm\n    (equiv.forall\u2083_congr (equiv.symm e\u03b1) (equiv.symm e\u03b2) (equiv.symm e\u03b3)\n      fun (x : \u03b1\u2082) (y : \u03b2\u2082) (z : \u03b3\u2082) => iff.symm h)\n\nprotected theorem forall_congr_left' {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b1 \u2192 Prop} (f : \u03b1 \u2243 \u03b2) :\n    (\u2200 (x : \u03b1), p x) \u2194 \u2200 (y : \u03b2), p (coe_fn (equiv.symm f) y) :=\n  sorry\n\nprotected theorem forall_congr_left {\u03b1 : Sort u} {\u03b2 : Sort v} {p : \u03b2 \u2192 Prop} (f : \u03b1 \u2243 \u03b2) :\n    (\u2200 (x : \u03b1), p (coe_fn f x)) \u2194 \u2200 (y : \u03b2), 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 {\u03b1 : Sort u} {\u03b2 : Sort v} (P : \u03b1 \u2192 Sort w) (e : \u03b1 \u2243 \u03b2)\n    (f : (b : \u03b2) \u2192 P (coe_fn (equiv.symm e) b)) (x : \u03b1) :\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 {\u03b1 : Sort u} {\u03b2 : Sort v} (P : \u03b2 \u2192 Sort w) (e : \u03b1 \u2243 \u03b2) :\n    ((a : \u03b1) \u2192 P (coe_fn e a)) \u2243 ((b : \u03b2) \u2192 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 {\u03b1 : Sort u} {\u03b2 : Sort v} {W : \u03b1 \u2192 Sort w} {Z : \u03b2 \u2192 Sort z} (h\u2081 : \u03b1 \u2243 \u03b2)\n    (h\u2082 : (a : \u03b1) \u2192 W a \u2243 Z (coe_fn h\u2081 a)) : ((a : \u03b1) \u2192 W a) \u2243 ((b : \u03b2) \u2192 Z b) :=\n  equiv.trans (Pi_congr_right h\u2082) (Pi_congr_left Z h\u2081)\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' {\u03b1 : Sort u} {\u03b2 : Sort v} {W : \u03b1 \u2192 Sort w} {Z : \u03b2 \u2192 Sort z} (h\u2081 : \u03b1 \u2243 \u03b2)\n    (h\u2082 : (b : \u03b2) \u2192 W (coe_fn (equiv.symm h\u2081) b) \u2243 Z b) : ((a : \u03b1) \u2192 W a) \u2243 ((b : \u03b2) \u2192 Z b) :=\n  equiv.symm (Pi_congr (equiv.symm h\u2081) fun (b : \u03b2) => equiv.symm (h\u2082 b))\n\nend equiv\n\n\ntheorem function.injective.swap_apply {\u03b1 : Sort u} {\u03b2 : Sort v} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) (x : \u03b1) (y : \u03b1) (z : \u03b1) :\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 {\u03b1 : Sort u} {\u03b2 : Sort v} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (hf : function.injective f) (x : \u03b1) (y : \u03b1) :\n    \u21d1(equiv.swap (f x) (f y)) \u2218 f = f \u2218 \u21d1(equiv.swap x y) :=\n  funext fun (z : \u03b1) => function.injective.swap_apply hf x y z\n\nprotected instance ulift.subsingleton {\u03b1 : Type u_1} [subsingleton \u03b1] : subsingleton (ulift \u03b1) :=\n  equiv.subsingleton equiv.ulift\n\nprotected instance plift.subsingleton {\u03b1 : Sort u_1} [subsingleton \u03b1] : subsingleton (plift \u03b1) :=\n  equiv.subsingleton equiv.plift\n\nprotected instance ulift.decidable_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] : DecidableEq (ulift \u03b1) :=\n  equiv.decidable_eq equiv.ulift\n\nprotected instance plift.decidable_eq {\u03b1 : Sort u_1} [DecidableEq \u03b1] : DecidableEq (plift \u03b1) :=\n  equiv.decidable_eq equiv.plift\n\n/-- If both `\u03b1` and `\u03b2` are singletons, then `\u03b1 \u2243 \u03b2`. -/\ndef equiv_of_unique_of_unique {\u03b1 : Sort u} {\u03b2 : Sort v} [unique \u03b1] [unique \u03b2] : \u03b1 \u2243 \u03b2 :=\n  equiv.mk (fun (_x : \u03b1) => Inhabited.default) (fun (_x : \u03b2) => Inhabited.default) sorry sorry\n\n/-- If `\u03b1` is a singleton, then it is equivalent to any `punit`. -/\ndef equiv_punit_of_unique {\u03b1 : Sort u} [unique \u03b1] : \u03b1 \u2243 PUnit := equiv_of_unique_of_unique\n\n/-- If `\u03b1` is a subsingleton, then it is equivalent to `\u03b1 \u00d7 \u03b1`. -/\ndef subsingleton_prod_self_equiv {\u03b1 : Type u_1} [subsingleton \u03b1] : \u03b1 \u00d7 \u03b1 \u2243 \u03b1 :=\n  equiv.mk (fun (p : \u03b1 \u00d7 \u03b1) => prod.fst p) (fun (a : \u03b1) => (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 {\u03b1 : Sort u} {\u03b2 : Sort v} [subsingleton \u03b1]\n    [subsingleton \u03b2] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) : \u03b1 \u2243 \u03b2 :=\n  equiv.mk f g sorry sorry\n\n/-- `unique (unique \u03b1)` is equivalent to `unique \u03b1`. -/\ndef unique_unique_equiv {\u03b1 : Sort u} : unique (unique \u03b1) \u2243 unique \u03b1 :=\n  equiv_of_subsingleton_of_subsingleton (fun (h : unique (unique \u03b1)) => Inhabited.default)\n    fun (h : unique \u03b1) => unique.mk { default := h } sorry\n\nnamespace quot\n\n\n/-- An equivalence `e : \u03b1 \u2243 \u03b2` generates an equivalence between quotient spaces,\nif `ra a\u2081 a\u2082 \u2194 rb (e a\u2081) (e a\u2082). -/\nprotected def congr {\u03b1 : Sort u} {\u03b2 : Sort v} {ra : \u03b1 \u2192 \u03b1 \u2192 Prop} {rb : \u03b2 \u2192 \u03b2 \u2192 Prop} (e : \u03b1 \u2243 \u03b2)\n    (eq : \u2200 (a\u2081 a\u2082 : \u03b1), ra a\u2081 a\u2082 \u2194 rb (coe_fn e a\u2081) (coe_fn e a\u2082)) : Quot ra \u2243 Quot rb :=\n  equiv.mk (quot.map \u21d1e sorry) (quot.map \u21d1(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 {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {r' : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (eq : \u2200 (a\u2081 a\u2082 : \u03b1), r a\u2081 a\u2082 \u2194 r' a\u2081 a\u2082) : Quot r \u2243 Quot r' :=\n  quot.congr (equiv.refl \u03b1) eq\n\n/-- An equivalence `e : \u03b1 \u2243 \u03b2` generates an equivalence between the quotient space of `\u03b1`\nby a relation `ra` and the quotient space of `\u03b2` by the image of this relation under `e`. -/\nprotected def congr_left {\u03b1 : Sort u} {\u03b2 : Sort v} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (e : \u03b1 \u2243 \u03b2) :\n    Quot r \u2243 Quot fun (b b' : \u03b2) => 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 : \u03b1 \u2243 \u03b2` generates an equivalence between quotient spaces,\nif `ra a\u2081 a\u2082 \u2194 rb (e a\u2081) (e a\u2082). -/\nprotected def congr {\u03b1 : Sort u} {\u03b2 : Sort v} {ra : setoid \u03b1} {rb : setoid \u03b2} (e : \u03b1 \u2243 \u03b2)\n    (eq : \u2200 (a\u2081 a\u2082 : \u03b1), setoid.r a\u2081 a\u2082 \u2194 setoid.r (coe_fn e a\u2081) (coe_fn e a\u2082)) :\n    quotient ra \u2243 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 {\u03b1 : Sort u} {r : setoid \u03b1} {r' : setoid \u03b1}\n    (eq : \u2200 (a\u2081 a\u2082 : \u03b1), setoid.r a\u2081 a\u2082 \u2194 setoid.r a\u2081 a\u2082) : quotient r \u2243 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 `\u21a5s` and ``\u21a5t`. -/\ndef set.bij_on.equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : set \u03b1} {t : set \u03b2} (f : \u03b1 \u2192 \u03b2)\n    (h : set.bij_on f s t) : \u21a5s \u2243 \u21a5t :=\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 {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} {\u03b1' : Sort u_3} [DecidableEq \u03b1']\n    [DecidableEq \u03b1] (f : \u03b1 \u2192 \u03b2) (g : \u03b1' \u2243 \u03b1) (a : \u03b1) (v : \u03b2) :\n    update f a v \u2218 \u21d1g = update (f \u2218 \u21d1g) (coe_fn (equiv.symm g) a) v :=\n  sorry\n\ntheorem update_apply_equiv_apply {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} {\u03b1' : Sort u_3} [DecidableEq \u03b1']\n    [DecidableEq \u03b1] (f : \u03b1 \u2192 \u03b2) (g : \u03b1' \u2243 \u03b1) (a : \u03b1) (v : \u03b2) (a' : \u03b1') :\n    update f a v (coe_fn g a') = update (f \u2218 \u21d1g) (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 {\u03b1 : Type u_1} {\u03b2 : Sort u_2} {\u03b3 : Sort u_3} {s : set \u03b1} (e : \u03b2 \u2243 \u21a5s)\n    (v : \u03b2 \u2192 \u03b3) (w : \u03b1 \u2192 \u03b3) (j : \u03b2) (x : \u03b3) [DecidableEq \u03b2] [DecidableEq \u03b1]\n    [(j : \u03b1) \u2192 Decidable (j \u2208 s)] :\n    (fun (i : \u03b1) =>\n          dite (i \u2208 s)\n            (fun (h : i \u2208 s) =>\n              function.update v j x (coe_fn (equiv.symm e) { val := i, property := h }))\n            fun (h : \u00aci \u2208 s) => w i) =\n        function.update\n          (fun (i : \u03b1) =>\n            dite (i \u2208 s) (fun (h : i \u2208 s) => v (coe_fn (equiv.symm e) { val := i, property := h }))\n              fun (h : \u00aci \u2208 s) => w i)\n          (\u2191(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\u00e9e 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\u00e9s/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 ` \u229a `:80 g:80 := category_struct.comp g f\n\n\n/-- The stucture of coalgebra of signature F -/\nstructure Coalgebra (F : Type u \u2964 Type u) : Type (u+1) :=\n    (carrier : Type u) (\u03b1 : carrier \u27f6 F.obj carrier)\n\nvariables {F : Type u \u2964 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    \u27e8Type u,  \u03bb \ud835\udd38, \ud835\udd38.carrier\u27e9 \n\nvariables {\ud835\udd38 \u0392 \u2102: Coalgebra F}\n \n/--\n    A Set-Category morphism(\u03c6 : A -> B) is coalgebra morphism iff\n    \u03b1_B \u2218 \u03c6 =  F \u03c6 \u2218 \u03b1_A\n-/\n@[simp , tidy] def is_coalgebra_homomorphism\n        (\u03d5 : \ud835\udd38 \u2192  \u0392) : Prop :=\n        \u0392.\u03b1 \u2218 \u03d5 =  (F.map \u03d5) \u2218 \ud835\udd38.\u03b1\n\n/--\n    The subtype of coalgebra-homomorphism\n-/\ndef homomorphism (\ud835\udd38 \u0392 : Coalgebra F) : set (\ud835\udd38 \u2192 \u0392):=\n    \u03bb \u03d5 , is_coalgebra_homomorphism \u03d5 \n\n \n/-- Allows us to use a homomorphism as a map-/\ninstance homomorphism_to_map (\ud835\udd38 \u0392 : Coalgebra F) : \n    has_coe_to_fun (homomorphism \ud835\udd38 \u0392) := \n    { F := \u03bb _, \ud835\udd38 \u2192 \u0392, coe := \u03bb m, m.val}\n    \n/--\n    A proof that id is a coalgebra-homomorphism\n-/\nlemma id_is_hom (\ud835\udd38 : Coalgebra F):\n     is_coalgebra_homomorphism (@id \ud835\udd38) := \n     show \ud835\udd38.\u03b1 \u2218 id =  (F.map id) \u2218 \ud835\udd38.\u03b1, from\n        calc \ud835\udd38.\u03b1 \u2218 id = (\ud835\udfd9 (F.obj \ud835\udd38)) \u2218 \ud835\udd38.\u03b1     : rfl\n                ...   = (F.map (\ud835\udfd9 \ud835\udd38)) \u2218 \ud835\udd38.\u03b1     : by rw \u2190 functor.map_id' F \ud835\udd38\n               \n/--\n    A proof that composition of two homomorphism is a coalgebra-homomorphism\n-/\nlemma comp_is_hom (\u03c6 : homomorphism \ud835\udd38 \u0392) (\u03c8 : homomorphism \u0392 \u2102)\n    : is_coalgebra_homomorphism (\u03c8 \u2218 \u03c6) :=\n        have ab : \u0392.\u03b1 \u2218 \u03c6 =  F.map \u03c6 \u2218 \ud835\udd38.\u03b1 := \u03c6.property,\n        have bc : \u2102.\u03b1 \u2218 \u03c8 =  F.map \u03c8 \u2218 \u0392.\u03b1 := \u03c8.property,\n\n        calc\n        (\u2102.\u03b1 \u2218 \u03c8) \u2218 \u03c6 = (F.map \u03c8) \u2218 \u0392.\u03b1  \u2218 \u03c6    : by rw bc\n        ... = (F.map \u03c8) \u2218 (F.map \u03c6) \u2218 \ud835\udd38.\u03b1      : by rw ab\n        ... = ((F.map \u03c8) \u229a (F.map \u03c6)) \u2218 \ud835\udd38.\u03b1   : rfl\n        ... = (F.map (\u03c8 \u229a \u03c6)) \u2218 \ud835\udd38.\u03b1           : by rw \u2190 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  := \u03bb \ud835\udd38 \u0392, homomorphism \ud835\udd38 \u0392,\n    id   := \u03bb \ud835\udd38 , \u27e8@id \ud835\udd38, id_is_hom \ud835\udd38\u27e9 ,\n    comp := \u03bb \ud835\udd38 \u0392 \u2102 \u03c6 \u03c8, \u27e8\u03c8 \u2218 \u03c6, comp_is_hom \u03c6 \u03c8\u27e9\n}\n\n\ninstance set_F_to_set : has_coe (\ud835\udd38 \u27f6 \u0392) (\ud835\udd38.carrier \u27f6 \u0392.carrier)\n    := \u27e8\u03bb \u03d5 :\ud835\udd38 \u27f6 \u0392, \u03d5\u27e9 \n\nopen function\n\nlemma empty_hom_dom (\u03d5 : \ud835\udd38.carrier \u27f6 \u0392.carrier) \n    (em_\ud835\udd38 : \u00ac nonempty \ud835\udd38):\n    is_coalgebra_homomorphism \u03d5 := \n    begin\n        dsimp at *,\n        ext1,\n        have ex : \u2203 a : \ud835\udd38 , true := exists.intro x trivial,\n        exact absurd (nonempty_of_exists ex) em_\ud835\udd38\n    end\n\nlemma empty_hom_codom (\u03d5 : \ud835\udd38.carrier \u27f6 \u0392.carrier) \n    (em_\u0392 : \u00ac nonempty \u0392):\n    is_coalgebra_homomorphism \u03d5 := \n    begin\n        dsimp at *,\n        ext1,\n        have ex : \u2203 b : \u0392 , true := exists.intro (\u03d5 x) trivial,\n        exact absurd (nonempty_of_exists ex) em_\u0392\n    end\n\nnoncomputable \ndef empty_map (S : Type u) (emp : \u00ac nonempty S) (X : Type u): \n    S \u2192 X := \n    graph_to_map (\u03bb s fs, false) -- \u2200 a : A , \u2203! b : B, G a b\n    (\u03bb s, absurd (\u27e8s\u27e9 : nonempty S) emp)\n\nlemma not_nonempty_empty : \u00ac nonempty (\u2205: set \ud835\udd38) := \nassume \u27e8s\u27e9, by tidy\n\nnoncomputable\ndef empty_coalgebra : Coalgebra F :=\n    {\n        carrier := (\u2205 : set \ud835\udd38),\n        \u03b1       := empty_map (\u2205 : set \ud835\udd38) not_nonempty_empty (F.obj (\u2205 : set \ud835\udd38))\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    (\u03c6 : homomorphism \ud835\udd38 \u0392)\n    (bij : bijective \u03c6) :  \n        let inv : \u0392 \u2192 \ud835\udd38 := some (bijective_iff_has_inverse.1 bij) in\n        is_coalgebra_homomorphism inv := \n        begin \n            intro inv,\n            let hom :\u0392.\u03b1 \u2218 \u03c6 =  F.map \u03c6 \u2218 \ud835\udd38.\u03b1 := \u03c6.property,\n            have has_lr_inv :left_inverse inv \u03c6 \u2227 right_inverse inv \u03c6\n                := some_spec (bijective_iff_has_inverse.1 bij),\n\n            calc \n            \ud835\udd38.\u03b1 \u2218 inv = id \u2218 \ud835\udd38.\u03b1 \u2218 inv                     : rfl\n            ... = (\ud835\udfd9 (F.obj \ud835\udd38)) \u2218 \ud835\udd38.\u03b1 \u2218 inv                : rfl \n            ... = (F.map (\ud835\udfd9 \ud835\udd38)) \u2218 \ud835\udd38.\u03b1 \u2218 inv                : by rw \u2190 functor.map_id' \n            ... = (F.map id) \u2218 \ud835\udd38.\u03b1 \u2218 inv                   : rfl\n            ... = (F.map (inv \u2218 \u03c6)) \u2218 \ud835\udd38.\u03b1 \u2218 inv            : by rw id_of_left_inverse has_lr_inv.1\n            ... = (F.map (inv \u229a \u03c6)) \u2218 \ud835\udd38.\u03b1 \u2218 inv           : rfl\n            ... = ((F.map inv) \u229a (F.map \u03c6)) \u2218 \ud835\udd38.\u03b1 \u2218 inv   : by rw \u2190 functor.map_comp \n            ... = (F.map inv) \u2218 ((F.map \u03c6) \u2218 \ud835\udd38.\u03b1) \u2218 inv    : rfl\n            ... = (F.map inv) \u2218 (\u0392.\u03b1 \u2218 \u03c6) \u2218 inv            : by rw hom\n            ... = (F.map inv) \u2218 \u0392.\u03b1 \u2218 (\u03c6 \u2218 inv)            : rfl \n            ... = ((F.map inv) \u2218 \u0392.\u03b1 \u2218 id)                 : by rw id_of_right_inverse has_lr_inv.2\n            ... = (F.map inv) \u2218 \u0392.\u03b1                        : rfl\n        end \n/--\n    Let \ud835\udd38, \u0392, and \u2102 be coalgebras and \n    f : A \u2192 B, g : B \u2192 C set maps, \n    so that \u03d5 := g \u2218 f : A \u2192 C is a homomorphism.\n\n    If f is a surjective homomorphism, then g is a homomorphism.\n-/\nlemma surj_to_hom  \n            (f : \ud835\udd38.carrier \u27f6 \u0392.carrier) \n            (g : \u0392.carrier \u27f6 \u2102.carrier) \n            (hom_gf : is_coalgebra_homomorphism (g \u2218 f))\n            (hom_f : is_coalgebra_homomorphism f)\n            (ep : epi f) \n                : is_coalgebra_homomorphism g :=\n    \n        have  h1 : (\u2102.\u03b1 \u2218 g) \u229a f = (F.map g \u2218 \u0392.\u03b1) \u229a f :=\n        calc\n        (\u2102.\u03b1 \u2218 g) \u229a f = F.map (g \u229a f) \u2218 \ud835\udd38.\u03b1   : hom_gf\n        ... = (F.map g \u229a F.map f) \u2218 \ud835\udd38.\u03b1        : by rw functor.map_comp\n        ... = F.map g \u2218 F.map f \u2218 \ud835\udd38.\u03b1           : by tidy\n        ... = F.map g \u2218 \u0392.\u03b1 \u2218 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 : \ud835\udd38.carrier \u2192 \u0392.carrier) \n               (g : \u0392.carrier \u2192 \u2102.carrier) \n            (hom_gf : is_coalgebra_homomorphism (g \u2218 f))\n            (hom_g : is_coalgebra_homomorphism g)\n            (inj : injective g) \n                : is_coalgebra_homomorphism f := \n    begin\n        cases classical.em (nonempty \u0392) with n_em_\u0392 emp_\u0392,\n        have  h1 : (F.map g) \u229a (F.map f) \u229a \ud835\udd38.\u03b1 = F.map g \u229a (\u0392.\u03b1 \u229a f) :=\n        calc\n        ((F.map g) \u229a (F.map f)) \u2218 \ud835\udd38.\u03b1  \n                = (F.map (g \u229a f)) \u2218 \ud835\udd38.\u03b1  : by rw functor.map_comp\n        ...     = F.map (g \u2218 f) \u2218 \ud835\udd38.\u03b1     : rfl\n        ...     = \u2102.\u03b1 \u2218 g \u2218 f             : by rw [eq.symm hom_gf]\n        ...     = (F.map g \u2218 \u0392.\u03b1) \u2218 f     : by rw [eq.symm hom_g],\n        \n        haveI inh_\u0392 : inhabited \u0392 := \u27e8choice n_em_\u0392\u27e9, \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_\u0392\n    end\n\n/--\n    Let \u03d5 : \ud835\udd38 \u2192 \u0392, \u03c8 : \ud835\udd38 \u2192 \u2102 be homomorphisms, \n    and \u03d5 is surjective.\n\n    Then there exists a unique homomorphism \u03c7 : \u0392 \u27f6 \u2102, \n    such that \u03c7 \u2218 \u03d5 = \u03c8 \n    iff kern \u03d5 \u2286 kern \u03c8\n-/\nlemma coalgebra_diagram (\u03d5 : homomorphism \ud835\udd38 \u0392) \n                        (\u03c8 : homomorphism \ud835\udd38 \u2102)\n                        (sur : surjective \u03d5)\n            :   (\u2203! \u03c7 : homomorphism \u0392 \u2102 , \u03c7 \u2218 \u03d5 = \u03c8) \u2194 \n                (sub_kern \u03d5 \u03c8)\n                :=\n    iff.intro\n    -- The \"exists such \u03c7\" \u2192 \"kern \u03d5 \u2286 kern \u03c8\" direction:\n    begin\n        intro ex,\n        cases ex with \u03c7 h1,\n\n        exact h1.left \u25b8 (kern_comp \u03d5 \u03c7) \n    end \n    -- The \"kern \u03d5 \u2286 kern \u03c8\" \u2192 \"exists a unique \u03c7\" 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 : \u2203 \u03c7 : \u0392 \u2192 \u2102, \n            (\u03c7 \u2218 \u03d5 = \u03c8  \u2227 \u2200 \u03c7\u2081, \u03c7\u2081 \u2218 \u03d5 = \u03c8 \u2192 \u03c7\u2081 = \u03c7)\n            := (diagram_surjective \u03d5 \u03c8 sur).2 k,\n\n        cases ex_uni with \u03c7 spec,\n        -- \u03c7 : \u0392 \u2192 \u2102\n        -- spec : \u03c7 \u2218 \u03d5 = \u03c8  \u2227 \u2200 \u03c7\u2081, \u03c7\u2081 \u2218 \u03d5 = \u03c8 \u2192 \u03c7\u2081 = \u03c7\n\n        have hom_\u03c7_\u03d5 : is_coalgebra_homomorphism (\u03c7 \u2218 \u03d5) :=\n            (eq.symm spec.left) \u25b8 \u03c8.property,\n\n        have hom_\u03c7 : is_coalgebra_homomorphism \u03c7 :=\n            surj_to_hom \u03d5 \u03c7 hom_\u03c7_\u03d5 \u03d5.property \n                    ((epi_iff_surjective \u03d5).2 sur),\n\n        have unique : \u2200 (\u03c7\u2081 : homomorphism \u0392 \u2102), \n                    \u03c7\u2081 \u2218 \u03d5 = \u03c8\n                    \u2192 \u03c7\u2081 = \u27e8\u03c7 , hom_\u03c7\u27e9 := by tidy,\n\n        exact exists_unique.intro \u27e8\u03c7 , hom_\u03c7\u27e9 \n                                  spec.left unique\n    end\n\n\n/--\nLet Q be a nonempty set,\n    \u03d5 : \ud835\udd38 \u27f6 \u0392 be a homomorphisms, \n    f : A \u2192 Q and g : Q \u2192 B be maps with \u03d5 = g \u2218 f and\n    f surjective and g injective\n\n    Then there exists a unique \u03b1_Q : Q \u2192 F(Q) coalgebra structure\n    such that both f and g are homomorphisms.\n-/\ntheorem Factorization {Q : Type u}\n    (\u03d5 : homomorphism \ud835\udd38 \u0392) \n    (f : \ud835\udd38.carrier \u27f6 Q)\n    (g : Q \u27f6 \u0392.carrier)\n    (h : \u03d5.val = g \u2218 f)\n    (ep : epi f)\n    (inj : injective g):\n        \u2203! \u03b1_Q : Q \u27f6 F.obj Q , \n            @is_coalgebra_homomorphism F \ud835\udd38 \u27e8Q , \u03b1_Q\u27e9 f \u2227 \n            @is_coalgebra_homomorphism F \u27e8Q , \u03b1_Q\u27e9 \u0392 g\n    := \nbegin\n    cases classical.em (nonempty \ud835\udd38) with n_em_\ud835\udd38 emp_\ud835\udd38,\n    haveI inh_\ud835\udd38 : inhabited \ud835\udd38 := \u27e8choice n_em_\ud835\udd38\u27e9 ,\n    haveI inh_\u211a : inhabited Q := \u27e8f (default \ud835\udd38)\u27e9, \n    let hom_\u03d5 := \u03d5.property,\n    /-\n        Using the E-M-Square \n        A      \u27f6(f)\u27f6     Q   \u27f6(\u0392.\u03b1 \u2218 g)\u27f6 F(B), \n        A \u27f6(F f \u2218 \u03b1_\ud835\udd38)\u27f6 F(Q)   \u27f6(F g)\u27f6   F(B)\n    -/\n    /-\n        showing that the triangles commute\n    -/ \n\n    have commute\n        : (\u0392.\u03b1 \u2218 g) \u2218 f = (F.map g) \u2218 ((F.map f) \u2218 \ud835\udd38.\u03b1) := \n        calc \u0392.\u03b1 \u2218 g \u2218 f = \u0392.\u03b1 \u2218 \u03d5.val                      : by simp [h]\n                 ...     = (F.map \u03d5.val) \u2218 \ud835\udd38.\u03b1             : hom_\u03d5\n                 ...     = (F.map (g \u2218 f)) \u2218 \ud835\udd38.\u03b1           : by rw [h]\n                 ...     = (F.map (g \u229a f)) \u2218 \ud835\udd38.\u03b1           : rfl\n                 ...     = ((F.map g) \u229a (F.map f)) \u2218 \ud835\udd38.\u03b1   : by rw functor.map_comp\n                 ...     = (F.map g) \u2218 (F.map f) \u2218 \ud835\udd38.\u03b1     : 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                (\u0392.\u03b1 \u2218 g) ((F.map f) \u2218 \ud835\udd38.\u03b1) (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 \u211a : Coalgebra F := \u27e8Q , d\u27e9,\n    \n    have homomorphism_f : @is_coalgebra_homomorphism F \ud835\udd38 \u211a f := \n        eq.symm spec.left.left,\n\n    have homomorphism_g : @is_coalgebra_homomorphism F \u211a \u0392 g := \n        spec.left.right,\n\n    have unique : \u2200 (\u03b1_Q : Q \u27f6 F.obj Q), \n        @is_coalgebra_homomorphism F \ud835\udd38 \u27e8Q , \u03b1_Q\u27e9 f \u2227 \n        @is_coalgebra_homomorphism F \u27e8Q , \u03b1_Q\u27e9 \u0392 g \u2192 \n        \u03b1_Q = d := \n        assume \u03b1_Q \u27e8hom_f , hom_g\u27e9, \n        uni_d \u03b1_Q \u27e8eq.symm hom_f , hom_g\u27e9,\n\n    exact\n    exists_unique.intro\n        d \n        \u27e8homomorphism_f , homomorphism_g\u27e9\n        unique,\n\n    have A_Q : nonempty Q \u2192 nonempty \ud835\udd38 :=\n       \u03bb n_Q, \u27e8some ((epi_iff_surjective f).1 ep (choice n_Q))\u27e9, \n    have em_Q : nonempty Q \u2192 false := \n        \u03bb n_Q, emp_\ud835\udd38 (A_Q n_Q),\n    have n_Q : \u00ac (nonempty Q) := em_Q,\n    let \u03b1_Q : Q \u2192 F.obj Q := empty_map Q n_Q (F.obj Q),\n    have hom_f : @is_coalgebra_homomorphism F \ud835\udd38 \u27e8Q , \u03b1_Q\u27e9 f\n        := empty_hom_dom f emp_\ud835\udd38,\n    exact exists_unique.intro \u03b1_Q \n        \u27e8hom_f , by tidy\u27e9 (by tidy)    \n\nend\n\n\ntheorem factorization {Q : Type u}\n    (\u03d5 : homomorphism \ud835\udd38 \u0392) \n    (f : \ud835\udd38.carrier \u27f6 Q) (g : Q \u27f6 \u0392.carrier)\n    (h : \u03d5.val = g \u2218 f)\n    (sur : surjective f)\n    (inj : injective g) :\n        (\u2203! \u03b1_Q : Q \u27f6 F.obj Q , \n            @is_coalgebra_homomorphism F \ud835\udd38 \u27e8Q , \u03b1_Q\u27e9 f)\n    := \nbegin\n    cases classical.em (nonempty \ud835\udd38) with n_em_\ud835\udd38 emp_\ud835\udd38,\n    haveI inh : inhabited \ud835\udd38 := \u27e8choice n_em_\ud835\udd38\u27e9 ,\n    let hom_\u03d5 := \u03d5.property,\n    /-\n        Using the E-M-Square \n        A      \u27f6(f)\u27f6     Q   \u27f6(\u0392.\u03b1 \u2218 g)\u27f6 F(B), \n        A \u27f6(F f \u2218 \u03b1_\ud835\udd38)\u27f6 F(Q)   \u27f6(F g)\u27f6   F(B)\n    -/\n    /-\n        showing that the triangles commute\n    -/ \n    have commute\n        : (\u0392.\u03b1 \u2218 g) \u2218 f = (F.map g) \u2218 ((F.map f) \u2218 \ud835\udd38.\u03b1) := \n        calc \u0392.\u03b1 \u2218 g \u2218 f = \u0392.\u03b1 \u2218 \u03d5.val                      : by simp [h]\n                 ...     = (F.map \u03d5.val) \u2218 \ud835\udd38.\u03b1             : hom_\u03d5\n                 ...     = (F.map (g \u2218 f)) \u2218 \ud835\udd38.\u03b1           : by rw [h]\n                 ...     = (F.map (g \u229a f)) \u2218 \ud835\udd38.\u03b1           : rfl\n                 ...     = ((F.map g) \u229a (F.map f)) \u2218 \ud835\udd38.\u03b1   : by rw functor.map_comp\n                 ...     = (F.map g) \u2218 (F.map f) \u2218 \ud835\udd38.\u03b1     : by simp,\n    \n    haveI inh_Q : inhabited Q := \u27e8f (default \ud835\udd38)\u27e9 ,\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 (\u0392.\u03b1 \u2218 g) ((F.map f) \u2218 \ud835\udd38.\u03b1) \n            (F.map g) mono_Fg commute,\n\n    cases em_square with d spec,\n    \n    have homomorphism_f : d \u229a f = (F.map f) \u229a \ud835\udd38.\u03b1 := \n        eq.symm spec.left.left,\n\n    have com_tri_epi := commutative_triangles_epi \n        f (\u0392.\u03b1 \u2218 g) ((F.map f) \u2218 \ud835\udd38.\u03b1) (F.map g) commute d (eq.symm homomorphism_f),\n    \n    have uni_f : \u2200 (\u03b1_Q : Q \u27f6 F.obj Q), \n        @is_coalgebra_homomorphism F \ud835\udd38 \u27e8Q , \u03b1_Q\u27e9 f \u2192 \n        \u03b1_Q = d := \n        assume \u03b1_Q hom_f, \n        have com : \u03b1_Q \u229a f = F.map f \u2218 \ud835\udd38.\u03b1 := hom_f,\n        com_tri_epi.1 \u03b1_Q (eq.symm com),\n\n    exact exists_unique.intro d \n        homomorphism_f uni_f,\n\n    have A_Q : nonempty Q \u2192 nonempty \ud835\udd38 :=\n       \u03bb n_Q, \u27e8some (sur (choice n_Q))\u27e9, \n    have em_Q : nonempty Q \u2192 false := \n        \u03bb n_Q, emp_\ud835\udd38 (A_Q n_Q),\n    have n_Q : \u00ac (nonempty Q) := em_Q,\n    let \u03b1_Q : Q \u2192 F.obj Q := empty_map Q n_Q (F.obj Q),\n    have hom_f : @is_coalgebra_homomorphism F \ud835\udd38 \u27e8Q , \u03b1_Q\u27e9 f\n        := empty_hom_dom f emp_\ud835\udd38,\n    exact exists_unique.intro \u03b1_Q hom_f (by tidy)\nend\n\ntheorem factorization_hom {Q : Type u}\n    (\u03d5 : homomorphism \ud835\udd38 \u0392) \n    (f : \ud835\udd38.carrier \u27f6 Q) (g : Q \u27f6 \u0392.carrier)\n    (h : \u03d5.val = g \u2218 f)\n    (sur : surjective f)\n    (inj : injective g)\n    [inhabited \ud835\udd38] :\n    let \u03b1_Q := some (factorization \u03d5 f g h sur inj) in\n        @is_coalgebra_homomorphism F \u27e8Q , \u03b1_Q\u27e9 \u0392 g := \n    begin \n        intros \u03b1_Q,\n        \n        have hom_\u03d5 := \u03d5.property,\n        \n        have commute : (\u0392.\u03b1 \u2218 g) \u2218 f = (F.map g) \u2218 ((F.map f) \u2218 \ud835\udd38.\u03b1) := \n            calc \u0392.\u03b1 \u2218 g \u2218 f \n                        = \u0392.\u03b1 \u2218 \u03d5.val                      : by simp [h]\n                    ... = (F.map \u03d5.val) \u2218 \ud835\udd38.\u03b1             : hom_\u03d5\n                    ... = (F.map (g \u2218 f)) \u2218 \ud835\udd38.\u03b1           : by rw [h]\n                    ... = (F.map (g \u229a f)) \u2218 \ud835\udd38.\u03b1           : rfl\n                    ... = ((F.map g) \u229a (F.map f)) \u2218 \ud835\udd38.\u03b1   : by rw functor.map_comp\n                    ... = (F.map g) \u2218 (F.map f) \u2218 \ud835\udd38.\u03b1     : by simp,\n        haveI inh_Q : inhabited Q := \u27e8f (default \ud835\udd38)\u27e9 ,\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 \u03d5 f g h sur inj),\n\n        have com_tri_epi : _ := commutative_triangles_epi \n            f (\u0392.\u03b1 \u2218 g) ((F.map f) \u2218 \ud835\udd38.\u03b1) (F.map g) commute \u03b1_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 `\u2124_[p]`\n\nWe construct a ring isomorphism between `witt_vector p (zmod p)` and `\u2124_[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 `\ud835\udd4e (zmod p) \u2192 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) (R : Type u_1) [comm_ring R] [char_p R p] (i : \u2115) (hin : i \u2264 n) (hpi : \u2191p ^ i = 0) : i = n := sorry\n\ntheorem card_zmod (p : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) : zmod (p ^ n) \u2243+* 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {m : \u2115} (hm : n \u2264 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {m : \u2115} (hm : n \u2264 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {m : \u2115} (hm : n \u2264 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 : \u2115) [hp : fact (nat.prime p)] (n : \u2115) {m : \u2115} (hm : n \u2264 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 : \u2115) [hp : fact (nat.prime p)] (k : \u2115) : witt_vector p (zmod p) \u2192+* 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 : \u2115) [hp : fact (nat.prime p)] (m : \u2115) (n : \u2115) (h : m \u2264 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 : \ud835\udd4e (zmod p) \u2192+* zmod (p ^ k)` to a ring hom to `\u2124_[p]`\nusing `padic_int.lift`, the universal property of `\u2124_[p]`.\n-/\ndef to_padic_int (p : \u2115) [hp : fact (nat.prime p)] : witt_vector p (zmod p) \u2192+* padic_int p :=\n  padic_int.lift (to_zmod_pow_compat p)\n\ntheorem zmod_equiv_trunc_compat (p : \u2115) [hp : fact (nat.prime p)] (k\u2081 : \u2115) (k\u2082 : \u2115) (hk : k\u2081 \u2264 k\u2082) : 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\u2082)) (padic_int.to_zmod_pow k\u2082)) =\n  ring_hom.comp (ring_equiv.to_ring_hom (truncated_witt_vector.zmod_equiv_trunc p k\u2081)) (padic_int.to_zmod_pow k\u2081) := 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 `\u2124_[p] \u2192+* \ud835\udd4e (zmod p)`.\n-/\ndef from_padic_int (p : \u2115) [hp : fact (nat.prime p)] : padic_int p \u2192+* witt_vector p (zmod p) :=\n  lift\n    (fun (k : \u2115) =>\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 : \u2115) [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 : \u2115) [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 : \u2115) [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 : \u2115) [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 : \u2115) [hp : fact (nat.prime p)] : witt_vector p (zmod p) \u2243+* padic_int p :=\n  ring_equiv.mk (\u21d1(to_padic_int p)) (\u21d1(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 ` \u229a ` :80 g:80 := category_struct.comp g f\n\nvariables {F : Type u \u2964 Type u} \n        {A B C : Type u}\n\n\nlemma diagram_injective (f: B \u27f6 A)\n                        (g: C \u27f6 A)\n                        (inj : injective f)\n                        : (\u2203! h : C \u27f6 B , f \u2218 h = g) \u2194 \n                          (range g \u2286 range f) \n    := \n        iff.intro \n        begin\n            tidy\n        end\n        begin\n            assume im,\n            let G : C \u2192 B \u2192 Prop := \u03bb c b , g c = f b, \n            have G1 :  \u2200 c : C , \u2203 b : B, G c b \n                    :=\n                        have G10 : \n                            \u2200 a : A , a \u2208 range g \u2192 \n                                    a \u2208 range f := im,\n                        have G11 : \n                            \u2200 c : C , g c \u2208 range f := \n                                \u03bb c , \n                                have G110 : g c \u2208 range g := by tidy,\n                                G10 (g c) G110,\n                        have G12 : \u2200 c : C , \u2203 b : B , g c = f b := \n                            \u03bb c : C,  \n                            have G110 : g c \u2208 range f := G11 c,\n                            by tidy,\n                        G12,\n            have G2 :  \u2200 c : C , \u2203! b : B, G c b\n                    :=\n                        \u03bb 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 : \u2200 b\u2081 : B, G c b\u2081 \u2192 \n                                    b\u2081 = (some (G1 c)) := \n                                    \u03bb b\u2081 : B, assume cbG : G c b\u2081,\n                                    show b\u2081 = (some (G1 c)), from\n                                    have G220 : f b\u2081 = g c := by tidy,\n                                    have G221 : f (some (G1 c)) = f b\u2081 := by rw [G21 , G220],\n                                    eq.symm (inj G221),\n                        by tidy,\n            let h : C \u27f6 B := graph_to_map G G2,\n            have G3 : \u2200 c , (f \u2218 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 \u2218 h = g := funext G3,\n            have G5 : \u2200 h\u2081 : C \u27f6 B , f \u2218 h\u2081 = g \u2192 h\u2081 = h := \n                    assume h\u2081 fh,\n                    have G51 : f \u2218 h\u2081 = f \u2218 h := by rw [fh , G4],\n                    have G511 : f \u229a h\u2081 = f \u229a 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\u2081 h G511,\n            exact exists_unique.intro h G4 G5\n        end\n\n\n\nlemma diagram_surjective\n            (f : A \u27f6 B) \n            (g : A \u27f6 C)\n            (sur: surjective f) \n            :   (\u2203! h : B \u27f6 C , h \u2218 f = g) \u2194\n                (sub_kern f g) \n    :=\n        iff.intro\n        begin\n            assume ex : \u2203 h , (h \u2218 f = g \u2227 \n                            \u2200 h\u2081, h\u2081 \u2218 f = g \u2192 h\u2081 = h),\n            show \u2200 a\u2081 a\u2082 , kern f a\u2081  a\u2082 \u2192 kern g a\u2081 a\u2082,\n            cases ex with h spec,\n            exact spec.1 \u25b8 kern_comp f h\n        end\n        begin \n            assume k : \u2200 a\u2081 a\u2082 , f a\u2081 = f a\u2082 \u2192 g a\u2081 = g a\u2082,\n            let h : B \u2192 C := \u03bb b : B, g (surj_inv sur b),\n            have s2 : \u2200 a , f (surj_inv sur (f a)) = f a := \n                assume a , surj_inv_eq sur (f a),\n            have s3 : \u2200 a , g (surj_inv sur (f a)) = g a :=\n                assume a , k (surj_inv sur (f a)) a (s2 a),\n            have s4 : \u2200 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 \u2218 f = g := funext s4,\n            have s6 : \u2200 h\u2082 :B \u2192 C , h\u2082 \u2218 f = g \u2192 h\u2082 = h := \n                begin \n                    assume h\u2082 h2,\n                    have s61 : h\u2082 \u2218 f = h \u2218 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\u2082 = h := left_cancel h\u2082 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\u2081 v\u2082 u\u2081 u\u2082 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\u2081} {D : Type u\u2082} [category C] [category D] (R : D \u2964 C) \nextends full R, faithful R, is_right_adjoint R\nwhere\n\n/--\nFor a reflective functor `i` (with left adjoint `L`), with unit `\u03b7`, we have `\u03b7_iL = iL \u03b7`.\n-/\n-- TODO: This holds more generally for idempotent adjunctions, not just reflective adjunctions.\n\ntheorem unit_obj_eq_map_unit {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {i : D \u2964 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 \u2964 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\u2081} {D : Type u\u2082} [category C] [category D] {i : D \u2964 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 `\u03b7_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 `\u03b7_A`.\n\n(For any `B` in the reflective subcategory, we automatically have that `\u03b5_B` is an iso.)\n-/\ndef functor.ess_image.unit_is_iso {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {i : D \u2964 C} [reflective i] {A : C} (h : A \u2208 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 `\u03b7_A` is an isomorphism, then `A` is in the essential image of `i`. -/\ntheorem mem_ess_image_of_unit_is_iso {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {i : D \u2964 C} [is_right_adjoint i] (A : C) [is_iso (nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) A)] : A \u2208 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 `\u03b7_A` is a split monomorphism, then `A` is in the reflective subcategory. -/\ntheorem mem_ess_image_of_unit_split_mono {C : Type u\u2081} {D : Type u\u2082} [category C] [category D] {i : D \u2964 C} [reflective i] {A : C} [split_mono (nat_trans.app (adjunction.unit (adjunction.of_right_adjoint i)) A)] : A \u2208 functor.ess_image i :=\n  let \u03b7 : \ud835\udfed \u27f6 left_adjoint i \u22d9 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 {\u03b1 \u03b2 \u03b3 : Type}\nvariable {X Y Z W : Type} [SemiHilbert X] [SemiHilbert Y] [SemiHilbert Z] [SemiHilbert W]\nvariable {Y\u2081 Y\u2082 : Type} [SemiHilbert Y\u2081] [SemiHilbert Y\u2082]\nvariable {\u03b9 \u03ba : Type} [Enumtype \u03b9] [Enumtype \u03ba]\n\n\n@[diff]\ntheorem adjoint_sum_eval\n  (f : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) [\u2200 i j, HasAdjointT (f i j)]\n  : (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f i j) (x j))\u2020\n    =\n    \u03bb y => \u03bb j => \u2211 i, (f i j)\u2020 (y i)\n  := by sorry -- symdiff; sorry_proof\n\n@[diff]\ntheorem adjDiff_sum_eval\n  (f : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) [hf : \u2200 i j, HasAdjDiffT (f i j)]\n  : \u2202\u2020 (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f i j) (x j))\n    =\n    \u03bb x dy => \u03bb j => \u2211 i, \u2202\u2020 (f i j) (x j) (dy i) := \nby \n  unfold adjointDifferential\n  have  := \u03bb i j => (hf i j).1\n  have  := \u03bb i j => (hf i j).2\n  sorry -- symdiff; symdiff\n  -- done\n\n@[diff]\ntheorem revDiff_sum_eval\n  (f : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) [hf : \u2200 i j, HasAdjDiffT (f i j)]\n  : \u211b (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f i j) (x j))\n    =\n    \u03bb x => (\u03bb i => \u2211 j, (f i j) (x j), \n            \u03bb dy => \u03bb j => \u2211 i, \u2202\u2020 (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? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 X \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1)\nwhere\n  f? =?= \u03bb i j x => f i j x (g i j)\n  |-\n  (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j))\u2020 \n  =?= \n  (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, f i j (x j) (g i j))\u2020\n\nunif_hint adjoint_sum_eval.unif_hint_2\n  (f? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 W \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1) (h : \u03b9 \u2192 \u03ba \u2192 X \u2192 W)\nwhere\n  f? =?= \u03bb i j x => f i j (h i j x) (g i j)\n  |-\n  (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j))\u2020 \n  =?= \n  (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, f i j (h i j (x j)) (g i j))\u2020\n\n\nunif_hint adjoint_sum_eval.unif_hint_3\n  (f? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 W \u2192 Z \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1) (h : \u03b9 \u2192 \u03ba \u2192 X \u2192 W) (h' : \u03b9 \u2192 \u03ba \u2192 X \u2192 Z)\nwhere\n  f? =?= \u03bb i j x => f i j (h i j x) (h' i j x) (g i j)\n  |-\n  (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j))\u2020\n  =?= \n  (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, f i j (h i j (x j)) (h' i j (x j)) (g i j))\u2020\n\n\nunif_hint adjDiff_sum_eval.unif_hint_1\n  (f? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 X \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1)\nwhere\n  f? =?= \u03bb i j x => f i j x (g i j)\n  |-\n  \u2202\u2020 (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j)) \n  =?= \n  \u2202\u2020 (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, f i j (x j) (g i j))\n\nunif_hint adjDiff_sum_eval.unif_hint_2\n  (f? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 W \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1) (h : \u03b9 \u2192 \u03ba \u2192 X \u2192 W)\nwhere\n  f? =?= \u03bb i j x => f i j (h i j x) (g i j)\n  |-\n  \u2202\u2020 (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j))\n  =?= \n  \u2202\u2020 (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, f i j (h i j (x j)) (g i j))\n\nunif_hint adjDiff_sum_eval.unif_hint_3\n  (f? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 W \u2192 Z \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1) (h : \u03b9 \u2192 \u03ba \u2192 X \u2192 W) (h' : \u03b9 \u2192 \u03ba \u2192 X \u2192 Z)\nwhere\n  f? =?= \u03bb i j x => f i j (h i j x) (h' i j x) (g i j)\n  |-\n  \u2202\u2020 (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j))\n  =?= \n  \u2202\u2020 (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 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? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 X \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1)\nwhere\n  f? =?= \u03bb i j x => f i j x (g i j)\n  |-\n  \u211b (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j)) \n  =?= \n  \u211b (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, f i j (x j) (g i j))\n\nunif_hint revDiff_sum_eval.unif_hint_2\n  (f? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 W \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1) (h : \u03b9 \u2192 \u03ba \u2192 X \u2192 W)\nwhere\n  f? =?= \u03bb i j x => f i j (h i j x) (g i j)\n  |-\n  \u211b (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j))\n  =?= \n  \u211b (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, f i j (h i j (x j)) (g i j))\n\n\nunif_hint revDiff_sum_eval.unif_hint_3\n  (f? : \u03b9 \u2192 \u03ba \u2192 X \u2192 Y) \n  (f : \u03b9 \u2192 \u03ba \u2192 W \u2192 Z \u2192 \u03b1 \u2192 Y) (g : \u03b9 \u2192 \u03ba \u2192 \u03b1) (h : \u03b9 \u2192 \u03ba \u2192 X \u2192 W) (h' : \u03b9 \u2192 \u03ba \u2192 X \u2192 Z)\nwhere\n  f? =?= \u03bb i j x => f i j (h i j x) (h' i j x) (g i j)\n  |-\n  \u211b (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 j, (f? i j) (x j))\n  =?= \n  \u211b (\u03bb (x : \u03ba \u2192 X) => \u03bb i => \u2211 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 {\u03b1 \u03c9} [has_one \u03c9] [has_mul \u03c9] (f : \u03b1 \u2192 \u03c9) : t \u03b1 \u2192 \u03c9 := ...\n\nlemma fold_map_hom (\u03b1 \u03b2)\n  [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2)\n  (g : \u03b3 \u2192 \u03b1) (x : t \u03b3) :\n  f (fold_map g x) = fold_map (f \u2218 g) x :=\n...\n```\n\n`fold_map` uses a monoid \u03c9 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 \u2192 Type u} [monad m]\nvariables {\u03b1 \u03b2 : Type u}\n/--\nFor a list, foldl f x [y\u2080,y\u2081] reduces as follows:\n\n```\ncalc  foldl f x [y\u2080,y\u2081]\n    = foldl f (f x y\u2080) [y\u2081]      : rfl\n... = foldl f (f (f x y\u2080) y\u2081) [] : rfl\n... = f (f x y\u2080) y\u2081              : rfl\n```\nwith\n```\nf : \u03b1 \u2192 \u03b2 \u2192 \u03b1\nx : \u03b1\n[y\u2080,y\u2081] : list \u03b2\n```\n\nWe can view the above as a composition of functions:\n```\n... = f (f x y\u2080) y\u2081              : rfl\n... = flip f y\u2081 (flip f y\u2080 x)    : rfl\n... = (flip f y\u2081 \u2218 flip f y\u2080) x  : rfl\n```\n\nWe can use traverse and const to construct this composition:\n```\ncalc   const.run (traverse (\u03bb y, const.mk' (flip f y)) [y\u2080,y\u2081]) x\n     = const.run ((::) <$> const.mk' (flip f y\u2080) <*> traverse (\u03bb y, const.mk' (flip f y)) [y\u2081]) x\n...  = const.run ((::) <$> const.mk' (flip f y\u2080) <*>\n         ( (::) <$> const.mk' (flip f y\u2081) <*> traverse (\u03bb y, const.mk' (flip f y)) [] )) x\n...  = const.run ((::) <$> const.mk' (flip f y\u2080) <*>\n         ( (::) <$> const.mk' (flip f y\u2081) <*> pure [] )) x\n...  = const.run ( ((::) <$> const.mk' (flip f y\u2081) <*> pure []) \u2218\n         ((::) <$> const.mk' (flip f y\u2080)) ) x\n...  = const.run ( const.mk' (flip f y\u2081) \u2218 const.mk' (flip f y\u2080) ) x\n...  = const.run ( flip f y\u2081 \u2218 flip f y\u2080 ) x\n...  = f (f x y\u2080) y\u2081\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 (\u03b1 : Type u) : Type u := (End \u03b1)\u1d50\u1d52\u1d56\ndef foldl.mk (f : \u03b1 \u2192 \u03b1) : foldl \u03b1 := op f\ndef foldl.get (x : foldl \u03b1) : \u03b1 \u2192 \u03b1 := unop x\n@[simps] def foldl.of_free_monoid (f : \u03b2 \u2192 \u03b1 \u2192 \u03b2) : free_monoid \u03b1 \u2192* monoid.foldl \u03b2 :=\n{ to_fun := \u03bb 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 (\u03b1 : Type u) : Type u := End \u03b1\ndef foldr.mk (f : \u03b1 \u2192 \u03b1) : foldr \u03b1 := f\ndef foldr.get (x : foldr \u03b1) : \u03b1 \u2192 \u03b1 := x\n@[simps] def foldr.of_free_monoid (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) : free_monoid \u03b1 \u2192* monoid.foldr \u03b2 :=\n{ to_fun := \u03bb 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 \u2192 Type u) [monad m] (\u03b1 : Type u) : Type u :=\nmul_opposite $ End $ Kleisli.mk m \u03b1\ndef mfoldl.mk (f : \u03b1 \u2192 m \u03b1) : mfoldl m \u03b1 := op f\ndef mfoldl.get (x : mfoldl m \u03b1) : \u03b1 \u2192 m \u03b1 := unop x\n@[simps] def mfoldl.of_free_monoid [is_lawful_monad m] (f : \u03b2 \u2192 \u03b1 \u2192 m \u03b2) :\n  free_monoid \u03b1 \u2192* monoid.mfoldl m \u03b2 :=\n{ to_fun := \u03bb 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 \u2192 Type u) [monad m] (\u03b1 : Type u) : Type u :=\nEnd $ Kleisli.mk m \u03b1\ndef mfoldr.mk (f : \u03b1 \u2192 m \u03b1) : mfoldr m \u03b1 := f\ndef mfoldr.get (x : mfoldr m \u03b1) : \u03b1 \u2192 m \u03b1 := x\n@[simps] def mfoldr.of_free_monoid [is_lawful_monad m] (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) :\n  free_monoid \u03b1 \u2192* monoid.mfoldr m \u03b2 :=\n{ to_fun := \u03bb 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 {\u03b1 \u03b2 : Type u} {t : Type u \u2192 Type u} [traversable t]\n\ndef fold_map {\u03b1 \u03c9} [has_one \u03c9] [has_mul \u03c9] (f : \u03b1 \u2192 \u03c9) : t \u03b1 \u2192 \u03c9 :=\ntraverse (const.mk' \u2218 f)\n\ndef foldl (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (x : \u03b1) (xs : t \u03b2) : \u03b1 :=\n(fold_map (foldl.mk \u2218 flip f) xs).get x\n\ndef foldr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (x : \u03b2) (xs : t \u03b1) : \u03b2 :=\n(fold_map (foldr.mk \u2218 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 \u03b1) : 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\u00b2)` run time. -/\ndef to_list : t \u03b1 \u2192 list \u03b1 :=\nlist.reverse \u2218 foldl (flip list.cons) []\n\ndef length (xs : t \u03b1) : \u2115 :=\ndown $ foldl (\u03bb l _, up $ l.down + 1) (up 0) xs\n\nvariables {m : Type u \u2192 Type u} [monad m]\n\ndef mfoldl (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b1) (x : \u03b1) (xs : t \u03b2) : m \u03b1 :=\n(fold_map (mfoldl.mk \u2218 flip f) xs).get x\n\ndef mfoldr (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) (x : \u03b2) (xs : t \u03b1) : m \u03b2 :=\n(fold_map (mfoldr.mk \u2218 f) xs).get x\n\nend defs\n\nsection applicative_transformation\nvariables {\u03b1 \u03b2 \u03b3 : Type u}\n\nopen function (hiding const)\n\ndef map_fold [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2) :\n  applicative_transformation (const \u03b1) (const \u03b2) :=\n{ app := \u03bb 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 : \u03b1 \u2192 free_monoid \u03b1 := list.ret\n\ndef free.map (f : \u03b1 \u2192 \u03b2) : free_monoid \u03b1 \u2192* free_monoid \u03b2 :=\n{ to_fun := list.map f,\n  map_mul' := \u03bb 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 : \u03b1 \u2192 \u03b2) (xs : list \u03b1) :\n  f <$> xs = free.map f xs := rfl\n\nlemma foldl.unop_of_free_monoid  (f : \u03b2 \u2192 \u03b1 \u2192 \u03b2) (xs : free_monoid \u03b1) (a : \u03b2) :\n  unop (foldl.of_free_monoid f xs) a = list.foldl f a xs := rfl\n\nvariables (m : Type u \u2192 Type u) [monad m] [is_lawful_monad m]\n\nvariables {t : Type u \u2192 Type u} [traversable t] [is_lawful_traversable t]\nopen is_lawful_traversable\n\nlemma fold_map_hom\n  [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2)\n  (g : \u03b3 \u2192 \u03b1) (x : t \u03b3) :\n  f (fold_map g x) = fold_map (f \u2218 g) x :=\ncalc  f (fold_map g x)\n    = f (traverse (const.mk' \u2218 g) x)                                     : rfl\n... = (map_fold f).app _ (traverse (const.mk' \u2218 g) x)   : rfl\n... = traverse ((map_fold f).app _ \u2218 (const.mk' \u2218 g)) x :\n        naturality (map_fold f) _ _\n... = fold_map (f \u2218 g) x : rfl\n\nlemma fold_map_hom_free\n  [monoid \u03b2] (f : free_monoid \u03b1 \u2192* \u03b2) (x : t \u03b1) :\n  f (fold_map free.mk x) = fold_map (f \u2218 free.mk) x :=\nfold_map_hom f _ x\n\nvariable {m}\n\nlemma fold_mfoldl_cons (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b1) (x : \u03b2) (y : \u03b1) :\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 : \u03b2 \u2192 \u03b1 \u2192 m \u03b1) (x : \u03b2) (y : \u03b1) :\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 {\u03b1 \u03b2 \u03b3 : Type u}\nvariables {t : Type u \u2192 Type u} [traversable t] [is_lawful_traversable t]\n\n@[simp]\nlemma foldl.of_free_monoid_comp_free_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) :\n  foldl.of_free_monoid f \u2218 free.mk = foldl.mk \u2218 flip f := rfl\n\n@[simp]\nlemma foldr.of_free_monoid_comp_free_mk (f : \u03b2 \u2192 \u03b1 \u2192 \u03b1) :\n  foldr.of_free_monoid f \u2218 free.mk = foldr.mk \u2218 f := rfl\n\n@[simp]\nlemma mfoldl.of_free_monoid_comp_free_mk {m} [monad m] [is_lawful_monad m] (f : \u03b1 \u2192 \u03b2 \u2192 m \u03b1) :\n  mfoldl.of_free_monoid f \u2218 free.mk = mfoldl.mk \u2218 flip f :=\nby ext; simp [(\u2218), 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 : \u03b2 \u2192 \u03b1 \u2192 m \u03b1) :\n  mfoldr.of_free_monoid f \u2218 free.mk = mfoldr.mk \u2218 f :=\nby { ext, simp [(\u2218), mfoldr.of_free_monoid, mfoldr.mk, flip, fold_mfoldr_cons] }\n\nlemma to_list_spec (xs : t \u03b1) :\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 \u03b1)),\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 \u03b3]  (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (xs : t \u03b1) :\n  fold_map g (f <$> xs) = fold_map (g \u2218 f) xs :=\nby simp only [fold_map,traverse_map]\n\nlemma foldl_to_list (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) (xs : t \u03b2) (x : \u03b1) :\n  foldl f x xs = list.foldl f x (to_list xs) :=\nbegin\n  rw \u2190 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (xs : t \u03b1) (x : \u03b2) :\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 : \u03b1 \u2192 \u03b2) (xs : t \u03b1) :\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 : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b3 \u2192 \u03b1) (a : \u03b1) (l : t \u03b2) :\n  foldl f a (g <$> l) = foldl (\u03bb x y, f x (g y)) a l :=\nby simp only [foldl, fold_map_map, (\u2218), flip]\n\n@[simp] theorem foldr_map (g : \u03b2 \u2192 \u03b3) (f : \u03b3 \u2192 \u03b1 \u2192 \u03b1) (a : \u03b1) (l : t \u03b2) :\n  foldr f a (g <$> l) = foldr (f \u2218 g) a l :=\nby simp only [foldr, fold_map_map, (\u2218), flip]\n\n@[simp] theorem to_list_eq_self {xs : list \u03b1} : 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 \u03b1} : 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 := \u03bb (n : \u2115) (a : \u03b1), 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 [\u2190 ih],\n      exact tl.foldl_hom (\u03bbx, x+1) f f 0 (\u03bb n x, rfl) } }\nend\n\nvariables {m : Type u \u2192 Type u} [monad m] [is_lawful_monad m]\n\nlemma mfoldl_to_list {f : \u03b1 \u2192 \u03b2 \u2192 m \u03b1} {x : \u03b1} {xs : t \u03b2} :\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 : \u03b1 \u2192 \u03b2 \u2192 m \u03b2) (x : \u03b2) (xs : t \u03b1) :\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 : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b3 \u2192 m \u03b1) (a : \u03b1) (l : t \u03b2) :\n  mfoldl f a (g <$> l) = mfoldl (\u03bb x y, f x (g y)) a l :=\nby simp only [mfoldl, fold_map_map, (\u2218), flip]\n\n@[simp] theorem mfoldr_map (g : \u03b2 \u2192 \u03b3) (f : \u03b3 \u2192 \u03b1 \u2192 m \u03b1) (a : \u03b1) (l : t \u03b2) :\n  mfoldr f a (g <$> l) = mfoldr (f \u2218 g) a l :=\nby simp only [mfoldr, fold_map_map, (\u2218), 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\u2081 w\u2082\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' : \u2200 {x y}, x \u2208 carrier \u2192 y \u2208 carrier \u2192 \u2045x, y\u2046 \u2208 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\u27e8{ lie_mem' := \u03bb 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) }\u27e9\n\ninstance : inhabited (lie_subalgebra R L) := \u27e80\u27e9\ninstance : has_coe (lie_subalgebra R L) (submodule R L) := \u27e8lie_subalgebra.to_submodule\u27e9\ninstance : has_mem L (lie_subalgebra R L) := \u27e8\u03bb x L', x \u2208 (L' : set L)\u27e9\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      := \u03bb x y, \u27e8\u2045x.val, y.val\u2046, L'.lie_mem' x.property y.property\u27e9,\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) \u2208 L' := (L' : submodule R L).zero_mem\n\nlemma smul_mem (t : R) {x : L} (h : x \u2208 L') : t \u2022 x \u2208 L' := (L' : submodule R L).smul_mem t h\n\nlemma add_mem {x y : L} (hx : x \u2208 L') (hy : y \u2208 L') : (x + y : L) \u2208 L' :=\n(L' : submodule R L).add_mem hx hy\n\nlemma sub_mem {x y : L} (hx : x \u2208 L') (hy : y \u2208 L') : (x - y : L) \u2208 L' :=\n(L' : submodule R L).sub_mem hx hy\n\nlemma lie_mem {x y : L} (hx : x \u2208 L') (hy : y \u2208 L') : (\u2045x, y\u2046 : L) \u2208 L' := L'.lie_mem' hx hy\n\n@[simp] lemma mem_carrier {x : L} : x \u2208 L'.carrier \u2194 x \u2208 (L' : set L) := iff.rfl\n\n@[simp] lemma mem_coe_submodule {x : L} : x \u2208 (L' : submodule R L) \u2194 x \u2208 L' := iff.rfl\n\nlemma mem_coe {x : L} : x \u2208 (L' : set L) \u2194 x \u2208 L' := iff.rfl\n\n@[simp, norm_cast] lemma coe_bracket (x y : L') : (\u2191\u2045x, y\u2046 : L) = \u2045(\u2191x : L), \u2191y\u2046 := rfl\n\nlemma ext_iff (x y : L') : x = y \u2194 (x : L) = y := subtype.ext_iff\n\nlemma coe_zero_iff_zero (x : L') : (x : L) = 0 \u2194 x = 0 := (ext_iff L' x 0).symm\n\n@[ext] lemma ext (L\u2081' L\u2082' : lie_subalgebra R L) (h : \u2200 x, x \u2208 L\u2081' \u2194 x \u2208 L\u2082') :\n  L\u2081' = L\u2082' :=\nby { cases L\u2081', cases L\u2082', simp only [], ext x, exact h x, }\n\nlemma ext_iff' (L\u2081' L\u2082' : lie_subalgebra R L) : L\u2081' = L\u2082' \u2194 \u2200 x, x \u2208 L\u2081' \u2194 x \u2208 L\u2082' :=\n\u27e8\u03bb h x, by rw h, ext L\u2081' L\u2082'\u27e9\n\n@[simp] lemma mk_coe (S : set L) (h\u2081 h\u2082 h\u2083 h\u2084) :\n  ((\u27e8S, h\u2081, h\u2082, h\u2083, h\u2084\u27e9 : 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 \u2192 set L) :=\n\u03bb L\u2081' L\u2082' h, by cases L\u2081'; cases L\u2082'; congr'\n\n@[norm_cast] theorem coe_set_eq (L\u2081' L\u2082' : lie_subalgebra R L) :\n  (L\u2081' : set L) = L\u2082' \u2194 L\u2081' = L\u2082' := coe_injective.eq_iff\n\nlemma to_submodule_injective :\n  function.injective (coe : lie_subalgebra R L \u2192 submodule R L) :=\n\u03bb L\u2081' L\u2082' h, by { rw set_like.ext'_iff at h, rw \u2190 coe_set_eq, exact h, }\n\n@[simp] lemma coe_to_submodule_eq_iff (L\u2081' L\u2082' : lie_subalgebra R L) :\n  (L\u2081' : submodule R L) = (L\u2082' : submodule R L) \u2194 L\u2081' = L\u2082' :=\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' \u2286 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     := \u03bb x m, \u2045(x : L), m\u2046,\n  add_lie     := \u03bb x y m, add_lie x y m,\n  lie_add     := \u03bb x y m, lie_add x y m,\n  leibniz_lie := \u03bb x y m, leibniz_lie x y m, }\n\n@[simp] lemma coe_bracket_of_module (x : L') (m : M) : \u2045x, m\u2046 = \u2045(x : L), m\u2046 := rfl\n\n/-- Given a Lie algebra `L` containing a Lie subalgebra `L' \u2286 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 := \u03bb t x m, by simp only [coe_bracket_of_module, smul_lie, submodule.coe_smul_of_tower],\n  lie_smul := \u03bb 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\u2082 : Type w} [lie_ring L\u2082] [lie_algebra R L\u2082]\nvariables (f : L \u2192\u2097\u2045R\u2046 L\u2082)\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' \u2192\u2097\u2045R\u2046 L :=\n{ map_lie' := \u03bb 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\u2082 :=\n{ lie_mem' := \u03bb x y,\n    show x \u2208 f.to_linear_map.range \u2192 y \u2208 f.to_linear_map.range \u2192 \u2045x, y\u2046 \u2208 f.to_linear_map.range,\n    by { repeat { rw linear_map.mem_range }, rintros \u27e8x', hx\u27e9 \u27e8y', hy\u27e9, refine \u27e8\u2045x', y'\u2046, _\u27e9,\n         rw [\u2190hx, \u2190hy], change f \u2045x', y'\u2046 = \u2045f x', f y'\u2046, rw map_lie, },\n  ..(f : L \u2192\u2097[R] L\u2082).range }\n\n@[simp] lemma range_coe : (f.range : set L\u2082) = set.range f :=\nlinear_map.range_coe \u2191f\n\n@[simp] lemma mem_range (x : L\u2082) : x \u2208 f.range \u2194 \u2203 (y : L), f y = x := linear_map.mem_range\n\nlemma mem_range_self (x : L) : f x \u2208 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 \u2192\u2097\u2045R\u2046 f.range :=\n{ map_lie' := \u03bb x y, by { apply subtype.ext, exact f.map_lie x y, },\n  ..(f : L \u2192\u2097[R] L\u2082).range_restrict, }\n\n@[simp] lemma range_restrict_apply (x : L) : f.range_restrict x = \u27e8f x, f.mem_range_self x\u27e9 := rfl\n\nlemma surjective_range_restrict : function.surjective (f.range_restrict) :=\nbegin\n  rintros \u27e8y, hy\u27e9,\n  erw mem_range at hy, obtain \u27e8x, rfl\u27e9 := 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  (\u2203 (K : lie_subalgebra R L), \u2191K = p) \u2194 \u2200 (x y : L), x \u2208 p \u2192 y \u2208 p \u2192 \u2045x, y\u2046 \u2208 p :=\nbegin\n  split,\n  { rintros \u27e8K, rfl\u27e9, 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\u2082 : lie_subalgebra R L\u2082)\n\n@[simp] lemma incl_range : K.incl.range = K :=\nby { rw \u2190 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\u2082 :=\n{ lie_mem' := \u03bb x y hx hy, by {\n    erw submodule.mem_map at hx, rcases hx with \u27e8x', hx', hx\u27e9, rw \u2190hx,\n    erw submodule.mem_map at hy, rcases hy with \u27e8y', hy', hy\u27e9, rw \u2190hy,\n    erw submodule.mem_map,\n    exact \u27e8\u2045x', y'\u2046, K.lie_mem hx' hy', f.map_lie x' y'\u27e9, },\n..((K : submodule R L).map (f : L \u2192\u2097[R] L\u2082)) }\n\n@[simp] lemma mem_map (x : L\u2082) : x \u2208 K.map f \u2194 \u2203 (y : L), y \u2208 K \u2227 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 \u2243\u2097\u2045R\u2046 L\u2082) (x : L\u2082) :\n  x \u2208 K.map (e : L \u2192\u2097\u2045R\u2046 L\u2082) \u2194 x \u2208 (K : submodule R L).map (e : L \u2192\u2097[R] L\u2082) :=\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' := \u03bb x y hx hy, by\n    { suffices : \u2045f x, f y\u2046 \u2208 K\u2082, by { simp [this], }, exact K\u2082.lie_mem hx hy, },\n  ..((K\u2082 : submodule R L\u2082).comap (f : L \u2192\u2097[R] L\u2082)), }\n\nsection lattice_structure\n\nopen set\n\ninstance : partial_order (lie_subalgebra R L) :=\n{ le := \u03bb N N', \u2200 \u2983x\u2984, x \u2208 N \u2192 x \u2208 N', -- Overriding `le` like this gives a better defeq.\n  ..partial_order.lift (coe : lie_subalgebra R L \u2192 set L) coe_injective }\n\nlemma le_def : K \u2264 K' \u2194 (K : set L) \u2286 K' := iff.rfl\n\n@[simp, norm_cast] lemma coe_submodule_le_coe_submodule : (K : submodule R L) \u2264 K' \u2194 K \u2264 K' :=\niff.rfl\n\ninstance : has_bot (lie_subalgebra R L) := \u27e80\u27e9\n\n@[simp] lemma bot_coe : ((\u22a5 : lie_subalgebra R L) : set L) = {0} := rfl\n\n@[simp] lemma bot_coe_submodule : ((\u22a5 : lie_subalgebra R L) : submodule R L) = \u22a5 := rfl\n\n@[simp] lemma mem_bot (x : L) : x \u2208 (\u22a5 : lie_subalgebra R L) \u2194 x = 0 := mem_singleton_iff\n\ninstance : has_top (lie_subalgebra R L) :=\n\u27e8{ lie_mem' := \u03bb x y hx hy, mem_univ \u2045x, y\u2046,\n   ..(\u22a4 : submodule R L) }\u27e9\n\n@[simp] lemma top_coe : ((\u22a4 : lie_subalgebra R L) : set L) = univ := rfl\n\n@[simp] lemma top_coe_submodule : ((\u22a4 : lie_subalgebra R L) : submodule R L) = \u22a4 := rfl\n\n@[simp] lemma mem_top (x : L) : x \u2208 (\u22a4 : lie_subalgebra R L) := mem_univ x\n\nlemma _root_.lie_hom.range_eq_map : f.range = map f \u22a4 :=\nby { ext, simp }\n\ninstance : has_inf (lie_subalgebra R L) :=\n\u27e8\u03bb K K', { lie_mem' := \u03bb x y hx hy, mem_inter (K.lie_mem hx.1 hy.1) (K'.lie_mem hx.2 hy.2),\n            ..(K \u2293 K' : submodule R L) }\u27e9\n\ninstance : has_Inf (lie_subalgebra R L) :=\n\u27e8\u03bb S, { lie_mem' := \u03bb 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\u2082, 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 \u2208 S} }\u27e9\n\n@[simp] theorem inf_coe : (\u2191(K \u2293 K') : set L) = K \u2229 K' := rfl\n\n@[simp] lemma Inf_coe_to_submodule (S : set (lie_subalgebra R L)) :\n  (\u2191(Inf S) : submodule R L) = Inf {(s : submodule R L) | s \u2208 S} := rfl\n\n@[simp] lemma Inf_coe (S : set (lie_subalgebra R L)) : (\u2191(Inf S) : set L) = \u22c2 s \u2208 S, (s : set L) :=\nbegin\n  rw [\u2190 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\u2082, exists_imp_distrib],\nend\n\nlemma Inf_glb (S : set (lie_subalgebra R L)) : is_glb S (Inf S) :=\nbegin\n  have h : \u2200 (K K' : lie_subalgebra R L), (K : set L) \u2264 K' \u2194 K \u2264 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          := \u22a5,\n  bot_le       := \u03bb N _ h, by { rw mem_bot at h, rw h, exact N.zero_mem', },\n  top          := \u22a4,\n  le_top       := \u03bb _ _ _, trivial,\n  inf          := (\u2293),\n  le_inf       := \u03bb N\u2081 N\u2082 N\u2083 h\u2081\u2082 h\u2081\u2083 m hm, \u27e8h\u2081\u2082 hm, h\u2081\u2083 hm\u27e9,\n  inf_le_left  := \u03bb _ _ _, and.left,\n  inf_le_right := \u03bb _ _ _, and.right,\n  ..complete_lattice_of_Inf _ Inf_glb }\n\ninstance : add_comm_monoid (lie_subalgebra R L) :=\n{ add       := (\u2294),\n  add_assoc := \u03bb _ _ _, sup_assoc,\n  zero      := \u22a5,\n  zero_add  := \u03bb _, bot_sup_eq,\n  add_zero  := \u03bb _, sup_bot_eq,\n  add_comm  := \u03bb _ _, sup_comm, }\n\n@[simp] lemma add_eq_sup : K + K' = K \u2294 K' := rfl\n\n@[norm_cast, simp] lemma inf_coe_to_submodule :\n  (\u2191(K \u2293 K') : submodule R L) = (K : submodule R L) \u2293 (K' : submodule R L) := rfl\n\n@[simp] lemma mem_inf (x : L) : x \u2208 K \u2293 K' \u2194 x \u2208 K \u2227 x \u2208 K' :=\nby rw [\u2190 mem_coe_submodule, \u2190 mem_coe_submodule, \u2190 mem_coe_submodule, inf_coe_to_submodule,\n  submodule.mem_inf]\n\nlemma eq_bot_iff : K = \u22a5 \u2194 \u2200 (x : L), x \u2208 K \u2192 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 \u21a5(\u22a5 : lie_subalgebra R L)) :=\nbegin\n  apply subsingleton_of_bot_eq_top,\n  ext \u27e8x, hx\u27e9, change x \u2208 \u22a5 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 \u2192 lie_subalgebra R L \u2192 Prop) :=\nbegin\n  let f : ((>) : lie_subalgebra R L \u2192 lie_subalgebra R L \u2192 Prop) \u2192r\n          ((>) : submodule R L \u2192 submodule R L \u2192 Prop) :=\n  { to_fun       := coe,\n    map_rel' := \u03bb N N' h, h, },\n  apply f.well_founded, rw \u2190 is_noetherian_iff_well_founded, apply_instance,\nend\n\nvariables {R L K K' f}\n\nsection nested_subalgebras\n\nvariables (h : K \u2264 K')\n\n/-- Given two nested Lie subalgebras `K \u2286 K'`, the inclusion `K \u21aa K'` is a morphism of Lie\nalgebras. -/\ndef hom_of_le : K \u2192\u2097\u2045R\u2046 K' :=\n{ map_lie' := \u03bb 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 = \u27e8x.1, h x.2\u27e9 := rfl\n\nlemma hom_of_le_injective : function.injective (hom_of_le h) :=\n\u03bb 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 \u2286 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 \u2208 of_le h \u2194 (x : L) \u2208 K :=\nbegin\n  simp only [of_le, hom_of_le_apply, lie_hom.mem_range],\n  split,\n  { rintros \u27e8y, rfl\u27e9, exact y.property, },\n  { intros h, use \u27e8(x : L), h\u27e9, 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\u2082} :\n  map f K \u2264 K' \u2194 K \u2264 comap f K' := set.image_subset_iff\n\nlemma gc_map_comap : galois_connection (map f) (comap f) := \u03bb 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 \u2286 L`. -/\ndef lie_span : lie_subalgebra R L := Inf {N | s \u2286 N}\n\nvariables {R L s}\n\nlemma mem_lie_span {x : L} : x \u2208 lie_span R L s \u2194 \u2200 K : lie_subalgebra R L, s \u2286 K \u2192 x \u2208 K :=\nby { change x \u2208 (lie_span R L s : set L) \u2194 _, erw Inf_coe, exact set.mem_bInter_iff, }\n\nlemma subset_lie_span : s \u2286 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 \u2264 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 \u2264 K \u2194 s \u2286 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 \u2286 t) : lie_span R L s \u2264 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 \u2194 \u2203 (K : lie_subalgebra R L), \u2191K = p :=\nbegin\n  rw p.exists_lie_subalgebra_coe_eq_iff, split; intros h,\n  { intros x m hm, rw [\u2190 h, mem_coe_submodule], exact lie_mem _ (subset_lie_span hm), },\n  { rw [\u2190 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\u2081 : Type v} {L\u2082 : Type w}\nvariables [comm_ring R] [lie_ring L\u2081] [lie_ring L\u2082] [lie_algebra R L\u2081] [lie_algebra R L\u2082]\n\n/-- An injective Lie algebra morphism is an equivalence onto its range. -/\nnoncomputable def of_injective (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h : function.injective f) :\n  L\u2081 \u2243\u2097\u2045R\u2046 f.range :=\nhave h' : (f : L\u2081 \u2192\u2097[R] L\u2082).ker = \u22a5 := linear_map.ker_eq_bot_of_injective h,\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, simpa, },\n..(linear_equiv.of_injective \u2191f h')}\n\n@[simp] lemma of_injective_apply (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h : function.injective f) (x : L\u2081) :\n  \u2191(of_injective f h x) = f x := rfl\n\nvariables (L\u2081' L\u2081'' : lie_subalgebra R L\u2081) (L\u2082' : lie_subalgebra R L\u2082)\n\n/-- Lie subalgebras that are equal as sets are equivalent as Lie algebras. -/\ndef of_eq (h : (L\u2081' : set L\u2081) = L\u2081'') : L\u2081' \u2243\u2097\u2045R\u2046 L\u2081'' :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, simp, },\n  ..(linear_equiv.of_eq \u2191L\u2081' \u2191L\u2081''\n      (by {ext x, change x \u2208 (L\u2081' : set L\u2081) \u2194 x \u2208 (L\u2081'' : set L\u2081), rw h, } )) }\n\n@[simp] lemma of_eq_apply (L L' : lie_subalgebra R L\u2081) (h : (L : set L\u2081) = L') (x : L) :\n  (\u2191(of_eq L L' h x) : L\u2081) = x := rfl\n\nvariables (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082)\n\n/-- An equivalence of Lie algebras restricts to an equivalence from any Lie subalgebra onto its\nimage. -/\ndef of_subalgebra : L\u2081'' \u2243\u2097\u2045R\u2046 (L\u2081''.map e : lie_subalgebra R L\u2082) :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, exact lie_hom.map_lie (\u2191e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) \u2191x \u2191y, }\n  ..(linear_equiv.of_submodule (e : L\u2081 \u2243\u2097[R] L\u2082) \u2191L\u2081'') }\n\n@[simp] lemma of_subalgebra_apply (x : L\u2081'') : \u2191(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\u2081'.map \u2191e = L\u2082') : L\u2081' \u2243\u2097\u2045R\u2046 L\u2082' :=\n{ map_lie' := \u03bb x y, by { apply set_coe.ext, exact lie_hom.map_lie (\u2191e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) \u2191x \u2191y, },\n  ..(linear_equiv.of_submodules (e : L\u2081 \u2243\u2097[R] L\u2082) \u2191L\u2081' \u2191L\u2082' (by { rw \u2190h, refl, })) }\n\n@[simp] lemma of_subalgebras_apply (h : L\u2081'.map \u2191e = L\u2082') (x : L\u2081') :\n  \u2191(e.of_subalgebras _ _ h x) = e x := rfl\n\n@[simp] lemma of_subalgebras_symm_apply (h : L\u2081'.map \u2191e = L\u2082') (x : L\u2082') :\n  \u2191((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\u00ebl 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 `\u03a3 i, \u03b1 i`.\n\n## Main declarations\n\n* `finset.sigma`: Given a finset `s` in `\u03b9` and finsets `t i` in each `\u03b1 i`, `s.sigma t` is the\n  finset of the dependent sum `\u03a3 i, \u03b1 i`\n* `finset.sigma_lift`: Lifts maps `\u03b1 i \u2192 \u03b2 i \u2192 finset (\u03b3 i)` to a map\n  `\u03a3 i, \u03b1 i \u2192 \u03a3 i, \u03b2 i \u2192 finset (\u03a3 i, \u03b3 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 {\u03b9 : Type*}\n\nnamespace finset\nsection sigma\nvariables {\u03b1 : \u03b9 \u2192 Type*} {\u03b2 : Type*} (s s\u2081 s\u2082 : finset \u03b9) (t t\u2081 t\u2082 : \u03a0 i, finset (\u03b1 i))\n\n/-- `s.sigma t` is the finset of dependent pairs `\u27e8i, a\u27e9` such that `i \u2208 s` and `a \u2208 t i`. -/\nprotected def sigma : finset (\u03a3 i, \u03b1 i) := \u27e8_, s.nodup.sigma $ \u03bb i, (t i).nodup\u27e9\n\nvariables {s s\u2081 s\u2082 t t\u2081 t\u2082}\n\n@[simp] lemma mem_sigma {a : \u03a3 i, \u03b1 i} : a \u2208 s.sigma t \u2194 a.1 \u2208 s \u2227 a.2 \u2208 t a.1 := mem_sigma\n\n@[simp, norm_cast] lemma coe_sigma (s : finset \u03b9) (t : \u03a0 i, finset (\u03b1 i)) :\n  (s.sigma t : set (\u03a3 i, \u03b1 i)) = (s : set \u03b9).sigma (\u03bb i, t i) :=\nset.ext $ \u03bb _, mem_sigma\n\n@[simp] lemma sigma_nonempty : (s.sigma t).nonempty \u2194 \u2203 i \u2208 s, (t i).nonempty :=\nby simp [finset.nonempty]\n\n@[simp] lemma sigma_eq_empty : s.sigma t = \u2205 \u2194 \u2200 i \u2208 s, t i = \u2205 :=\nby simp only [\u2190 not_nonempty_iff_eq_empty, sigma_nonempty, not_exists]\n\n@[mono] lemma sigma_mono (hs : s\u2081 \u2286 s\u2082) (ht : \u2200 i, t\u2081 i \u2286 t\u2082 i) : s\u2081.sigma t\u2081 \u2286 s\u2082.sigma t\u2082 :=\n\u03bb \u27e8i, a\u27e9 h, let \u27e8hi, ha\u27e9 := mem_sigma.1 h in mem_sigma.2 \u27e8hs hi, ht i ha\u27e9\n\nlemma sigma_eq_bUnion [decidable_eq (\u03a3 i, \u03b1 i)] (s : finset \u03b9) (t : \u03a0 i, finset (\u03b1 i)) :\n  s.sigma t = s.bUnion (\u03bb i, (t i).map $ embedding.sigma_mk i) :=\nby { ext \u27e8x, y\u27e9, simp [and.left_comm] }\n\nvariables (s t) (f : (\u03a3 i, \u03b1 i) \u2192 \u03b2)\n\nlemma sup_sigma [semilattice_sup \u03b2] [order_bot \u03b2] :\n  (s.sigma t).sup f = s.sup (\u03bb i, (t i).sup $ \u03bb b, f \u27e8i, b\u27e9) :=\nbegin\n  refine (sup_le _).antisymm (sup_le $ \u03bb i hi, sup_le $ \u03bb b hb, le_sup $ mem_sigma.2 \u27e8hi, hb\u27e9),\n  rintro \u27e8i, b\u27e9 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 \u03b2] [order_top \u03b2] :\n  (s.sigma t).inf f = s.inf (\u03bb i, (t i).inf $ \u03bb b, f \u27e8i, b\u27e9) :=\n@sup_sigma _ _ (order_dual \u03b2) _ _ _ _ _\n\nend sigma\n\nsection sigma_lift\nvariables {\u03b1 \u03b2 \u03b3 : \u03b9 \u2192 Type*} [decidable_eq \u03b9]\n\n/-- Lifts maps `\u03b1 i \u2192 \u03b2 i \u2192 finset (\u03b3 i)` to a map `\u03a3 i, \u03b1 i \u2192 \u03a3 i, \u03b2 i \u2192 finset (\u03a3 i, \u03b3 i)`. -/\ndef sigma_lift (f : \u03a0 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 finset (\u03b3 i)) (a : sigma \u03b1) (b : sigma \u03b2) :\n  finset (sigma \u03b3) :=\ndite (a.1 = b.1) (\u03bb h, (f (h.rec a.2) b.2).map $ embedding.sigma_mk _) (\u03bb _, \u2205)\n\nlemma mem_sigma_lift (f : \u03a0 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 finset (\u03b3 i))\n  (a : sigma \u03b1) (b : sigma \u03b2) (x : sigma \u03b3) :\n  x \u2208 sigma_lift f a b \u2194 \u2203 (ha : a.1 = x.1) (hb : b.1 = x.1), x.2 \u2208 f (ha.rec a.2) (hb.rec b.2) :=\nbegin\n  obtain \u27e8\u27e8i, a\u27e9, j, b\u27e9 := \u27e8a, b\u27e9,\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 \u27e8x, hx, rfl\u27e9,\n      exact \u27e8rfl, rfl, hx\u27e9 },\n    { rintro \u27e8\u27e8\u27e9, \u27e8\u27e9, hx\u27e9,\n      rw [sigma_lift, dif_pos rfl, mem_map],\n      exact \u27e8_, hx, by simp [sigma.ext_iff]\u27e9 } },\n  { rw [sigma_lift, dif_neg h],\n    refine iff_of_false (not_mem_empty _) _,\n    rintro \u27e8\u27e8\u27e9, \u27e8\u27e9, _\u27e9,\n    exact h rfl }\nend\n\nlemma mk_mem_sigma_lift (f : \u03a0 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 finset (\u03b3 i)) (i : \u03b9) (a : \u03b1 i) (b : \u03b2 i)\n  (x : \u03b3 i) :\n  (\u27e8i, x\u27e9 : sigma \u03b3) \u2208 sigma_lift f \u27e8i, a\u27e9 \u27e8i, b\u27e9 \u2194 x \u2208 f a b :=\nbegin\n  rw [sigma_lift, dif_pos rfl, mem_map],\n  refine \u27e8_, \u03bb hx, \u27e8_, hx, rfl\u27e9\u27e9,\n  rintro \u27e8x, hx, _, rfl\u27e9,\n  exact hx,\nend\n\nlemma not_mem_sigma_lift_of_ne_left (f : \u03a0 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 finset (\u03b3 i))\n  (a : sigma \u03b1) (b : sigma \u03b2) (x : sigma \u03b3) (h : a.1 \u2260 x.1) :\n  x \u2209 sigma_lift f a b :=\nby { rw mem_sigma_lift, exact \u03bb H, h H.fst }\n\nlemma not_mem_sigma_lift_of_ne_right (f : \u03a0 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 finset (\u03b3 i))\n  {a : sigma \u03b1} (b : sigma \u03b2) {x : sigma \u03b3} (h : b.1 \u2260 x.1) :\n  x \u2209 sigma_lift f a b :=\nby { rw mem_sigma_lift, exact \u03bb H, h H.snd.fst }\n\nvariables {f g : \u03a0 \u2983i\u2984, \u03b1 i \u2192 \u03b2 i \u2192 finset (\u03b3 i)} {a : \u03a3 i, \u03b1 i} {b : \u03a3 i, \u03b2 i}\n\nlemma sigma_lift_nonempty :\n  (sigma_lift f a b).nonempty \u2194 \u2203 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 \u2190nonempty_iff_ne_empty,\n  exact map_nonempty.symm,\nend\n\nlemma sigma_lift_eq_empty : (sigma_lift f a b) = \u2205 \u2194 \u2200 h : a.1 = b.1, (f (h.rec a.2) b.2) = \u2205 :=\nbegin\n  convert dite_eq_right_iff,\n  exact forall_congr_eq (\u03bb h, propext map_eq_empty.symm),\nend\n\nlemma sigma_lift_mono (h : \u2200 \u2983i\u2984 \u2983a : \u03b1 i\u2984 \u2983b : \u03b2 i\u2984, f a b \u2286 g a b) (a : \u03a3 i, \u03b1 i) (b : \u03a3 i, \u03b2 i) :\n  sigma_lift f a b \u2286 sigma_lift g a b :=\nbegin\n  rintro x hx,\n  rw mem_sigma_lift at \u22a2 hx,\n  obtain \u27e8ha, hb, hx\u27e9 := hx,\n  exact \u27e8ha, hb, h hx\u27e9,\nend\n\nvariables (f a b)\n\nlemma card_sigma_lift :\n  (sigma_lift f a b).card = dite (a.1 = b.1) (\u03bb h, (f (h.rec a.2) b.2).card) (\u03bb _, 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  \u27e8@MulHom.toFun, @MulHom.id, @MulHom.comp, @MulHom.coe_inj\u27e9\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 \u2192\u2099* Y) : of X \u27f6 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 \u2192\u2099* 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  \u27e8Magma.of PEmpty\u27e9\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  \u27e8\u27e9\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 \u2192\u2099* Y) : of X \u27f6 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 \u2192\u2099* 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  \u27e8SemigroupCat.of PEmpty\u27e9\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\u2082 SemigroupCat Magma :=\n  BundledHom.forget\u2082 _ _\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 \u2243* Y) : Magma.of X \u2245 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 \u2243* Y) : SemigroupCat.of X \u2245 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 \u2245 Y) : X \u2243* 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 \u2245 Y) : X \u2243* 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 \u2243* Y \u2245 Magma.of X \u2245 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 \u2243* Y \u2245 SemigroupCat.of X \u2245 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 \u2243* Y := { f, i.to_equiv with }\n    exact \u27e8(is_iso.of_iso e.to_Magma_iso).1\u27e9\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 \u2243* Y := { f, i.to_equiv with }\n    exact \u27e8(is_iso.of_iso e.to_Semigroup_iso).1\u27e9\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\u2082` functors between our concrete categories\nreflect isomorphisms.\n-/\n\n\nexample : ReflectsIsomorphisms (forget\u2082 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\u00f6lzl\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 `\u21be 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 \u2964 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     := \u03bb a b, (a \u2192 b),\n  id      := \u03bb a, id,\n  comp    := \u03bb _ _ _ f g, g \u2218 f }\n\nlemma types_hom {\u03b1 \u03b2 : Type u} : (\u03b1 \u27f6 \u03b2) = (\u03b1 \u2192 \u03b2) := rfl\nlemma types_id (X : Type u) : \ud835\udfd9 X = id := rfl\nlemma types_comp {X Y Z : Type u} (f : X \u27f6 Y) (g : Y \u27f6 Z) : f \u226b g = g \u2218 f := rfl\n\n@[simp]\nlemma types_id_apply (X : Type u) (x : X) : ((\ud835\udfd9 X) : X \u2192 X) x = x := rfl\n@[simp]\nlemma types_comp_apply {X Y Z : Type u} (f : X \u27f6 Y) (g : Y \u27f6 Z) (x : X) : (f \u226b g) x = g (f x) := rfl\n\n@[simp]\nlemma hom_inv_id_apply {X Y : Type u} (f : X \u2245 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 \u2245 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 {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) : \u03b1 \u27f6 \u03b2 := f\n-- If you don't mind some notation you can use fewer keystrokes:\nlocalized \"notation  `\u21be` 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 (\u03b1 \u03b2 \u03b3 : Type u) (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3)\n\nexample : \u03b1 \u2192 \u03b3 := \u21bef \u226b \u21beg\nexample [is_iso \u21bef] : mono \u21bef := by apply_instance\nexample [is_iso \u21bef] : \u21bef \u226b inv \u21bef = \ud835\udfd9 \u03b1 := by simp\nend\n\nnamespace functor\nvariables {J : Type u} [category.{v} J]\n\n/--\nThe sections of a functor `J \u2964 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 \u27f6 j'`.\n\nWe later use these to define limits in `Type` and in many concrete categories.\n-/\ndef sections (F : J \u2964 Type w) : set (\u03a0 j, F.obj j) :=\n{ u | \u2200 {j j'} (f : j \u27f6 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 \u2964 Type w) {X Y Z : C}\nvariables (\u03c3 : F \u27f6 G) (\u03c4 : G \u27f6 H)\n\n@[simp] lemma map_comp_apply (f : X \u27f6 Y) (g : Y \u27f6 Z) (a : F.obj X) :\n  (F.map (f \u226b 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 (\ud835\udfd9 X)) a = a :=\nby simp [types_id]\n\nlemma naturality (f : X \u27f6 Y) (x : F.obj X) : \u03c3.app Y ((F.map f) x) = (G.map f) (\u03c3.app X x) :=\ncongr_fun (\u03c3.naturality f) x\n\n@[simp] lemma comp (x : F.obj X) : (\u03c3 \u226b \u03c4).app X x = \u03c4.app X (\u03c3.app X x) := rfl\n\nvariables {D : Type u'} [\ud835\udc9f : category.{u'} D] (I J : D \u2964 C) (\u03c1 : I \u27f6 J) {W : D}\n\n@[simp] lemma hcomp (x : (I \u22d9 F).obj W) :\n  (\u03c1 \u25eb \u03c3).app W x = (G.map (\u03c1.app W)) (\u03c3.app (I.obj W) x) :=\nrfl\n\n@[simp] \n\n@[simp] lemma hom_inv_id_app_apply (\u03b1 : F \u2245 G) (X) (x) : \u03b1.inv.app X (\u03b1.hom.app X x) = x :=\ncongr_fun (\u03b1.hom_inv_id_app X) x\n@[simp] lemma inv_hom_id_app_apply (\u03b1 : F \u2245 G) (X) (x) : \u03b1.hom.app X (\u03b1.inv.app X x) = x :=\ncongr_fun (\u03b1.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 \u2245 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 \u2964 Type 5`.\n-/\ndef ulift_functor : Type u \u2964 Type (max u v) :=\n{ obj := \u03bb X, ulift.{v} X,\n  map := \u03bb X Y f, \u03bb x : ulift.{v} X, ulift.up (f x.down) }\n\n@[simp] lemma ulift_functor_map {X Y : Type u} (f : X \u27f6 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 := \u03bb X Y f x, (f (ulift.up x)).down }\ninstance ulift_functor_faithful : faithful ulift_functor :=\n{ map_injective' := \u03bb X Y f g p, funext $ \u03bb 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 \u27f6 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 \u27f6 X := \u03bb _, x\n\nlemma hom_of_element_eq_iff {X : Type u} (x y : X) :\n  hom_of_element x = hom_of_element y \u2194 x = y :=\n\u27e8\u03bb H, congr_fun H punit.star, by cc\u27e9\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 \u27f6 Y) : mono f \u2194 function.injective f :=\nbegin\n  split,\n  { intros H x x' h,\n    resetI,\n    rw \u2190hom_of_element_eq_iff at \u22a2 h,\n    exact (cancel_mono f).mp h },\n  { refine \u03bb H, \u27e8\u03bb Z g h H\u2082, _\u27e9,\n    ext z,\n    replace H\u2082 := congr_fun H\u2082 z,\n    exact H H\u2082 }\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 \u27f6 Y) : epi f \u2194 function.surjective f :=\nbegin\n  split,\n  { intros H,\n    let g : Y \u27f6 ulift Prop := \u03bb y, \u27e8true\u27e9,\n    let h : Y \u27f6 ulift Prop := \u03bb y, \u27e8\u2203 x, f x = y\u27e9,\n    suffices : f \u226b g = f \u226b h,\n    { resetI,\n      rw cancel_epi at this,\n      intro y,\n      replace this := congr_fun this y,\n      replace this : true = \u2203 x, f x = y := congr_arg ulift.down this,\n      rw \u2190this,\n      trivial },\n    ext x,\n    change true \u2194 \u2203 x', f x' = f x,\n    rw true_iff,\n    exact \u27e8x, rfl\u27e9 },\n  { intro H,\n    constructor,\n    intros Z g h H\u2082,\n    apply funext,\n    rw \u2190forall_iff_forall_surj H,\n    intro x,\n    exact (congr_fun H\u2082 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 \u2192 Type v) [_root_.functor m] [is_lawful_functor m] :\n  Type u \u2964 Type v :=\n{ obj       := m,\n  map       := \u03bb\u03b1 \u03b2, _root_.functor.map,\n  map_id'   := assume \u03b1, _root_.functor.map_id,\n  map_comp' := assume \u03b1 \u03b2 \u03b3 f g, funext $ assume a, is_lawful_functor.comp_map f g _ }\n\nvariables (m : Type u \u2192 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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) :\n  (of_type_functor m).map f = (_root_.functor.map f : m \u03b1 \u2192 m \u03b2) := 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 \u2243 Y) : X \u2245 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 \u2243 Y} : e.to_iso.hom = e := rfl\n@[simp] lemma to_iso_inv {e : X \u2243 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 \u2245 Y) : X \u2243 Y :=\n{ to_fun := i.hom,\n  inv_fun := i.inv,\n  left_inv := \u03bb x, congr_fun i.hom_inv_id x,\n  right_inv := \u03bb y, congr_fun i.inv_hom_id y }\n\n@[simp] lemma to_equiv_fun (i : X \u2245 Y) : (i.to_equiv : X \u2192 Y) = i.hom := rfl\n@[simp] lemma to_equiv_symm_fun (i : X \u2245 Y) : (i.to_equiv.symm : Y \u2192 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 \u2245 Y) (g : Y \u2245 Z) :\n  (f \u226a\u226b 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 \u27f6 Y) : is_iso f \u2194 function.bijective f :=\niff.intro\n  (\u03bb i, (by exactI as_iso f : X \u2245 Y).to_equiv.bijective)\n  (\u03bb 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 \u2243 Y) \u2245 (X \u2245 Y) :=\n{ hom := \u03bb e, e.to_iso,\n  inv := \u03bb 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 \u2243 Y) \u2243 (X \u2245 Y) :=\n(equiv_iso_iso).to_equiv\n\n@[simp] lemma equiv_equiv_iso_hom {X Y : Type u} (e : X \u2243 Y) :\n  equiv_equiv_iso e = e.to_iso := rfl\n\n@[simp] lemma equiv_equiv_iso_inv {X Y : Type u} (e : X \u2245 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\u00e9my Degenne. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: R\u00e9my 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 \u03bc` 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 \u03bc` for `1 \u2264 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 {\u03b1 E : Type*} {m : measurable_space \u03b1} {\u03bc : measure \u03b1} {p : \u211d\u22650\u221e}\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 \u03bc) : f \u2264\u1d50[\u03bc] g \u2194 f \u2264 g :=\nby rw [\u2190 subtype.coe_le_coe, \u2190 ae_eq_fun.coe_fn_le, \u2190 coe_fn_coe_base, \u2190 coe_fn_coe_base]\n\nlemma coe_fn_nonneg (f : Lp E p \u03bc) : 0 \u2264\u1d50[\u03bc] f \u2194 0 \u2264 f :=\nbegin\n  rw \u2190 coe_fn_le,\n  have h0 := Lp.coe_fn_zero E p \u03bc,\n  split; intro h; filter_upwards [h, h0] with _ _ h2,\n  { rwa h2, },\n  { rwa \u2190 h2, },\nend\n\ninstance : covariant_class (Lp E p \u03bc) (Lp E p \u03bc) (+) (\u2264) :=\nbegin\n  refine \u27e8\u03bb f g\u2081 g\u2082 hg\u2081\u2082, _\u27e9,\n  rw \u2190 coe_fn_le at hg\u2081\u2082 \u22a2,\n  filter_upwards [coe_fn_add f g\u2081, coe_fn_add f g\u2082, hg\u2081\u2082] 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 \u03bc) :=\n{ add_le_add_left := \u03bb 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": "\n\ninfix:65 \" +' \" => Add.add\ninfix:70 \" *' \" => Mul.mul\ninfixr:30 \" OR \" => Or\nprefix:40 \"NOT \" => Not\n\ntheorem ex (a b c d : Nat) (p : Prop) : (NOT p OR a = b*'c +' c*'a OR a = b *' c) = (\u00ac p \u2228 a = b*c + c*a \u2228 a = b * c) :=\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/mixfix.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8031738057795402, "lm_q2_score": 0.5736784074525096, "lm_q1q2_score": 0.4607634698071779}}
{"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 (\u2124/dp^n \u2124)\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 : \u2115} [fact (nat.prime p)] {d : \u2115} [fact (0 < d)] {R : Type*} [normed_comm_ring R] (m : \u2115)\n(hd : d.gcd p = 1) (\u03c7 : dirichlet_character R (d*(p^m))) {c : \u2115} (hc : c.gcd p = 1)\n(hc' : c.gcd d = 1) (na : \u2200 (n : \u2115) (f : \u2115 \u2192 R),\n  \u2225 \u2211 (i : \u2115) in finset.range n, f i\u2225 \u2264 \u2a06 (i : zmod n), \u2225f i.val\u2225)\n(w : continuous_monoid_hom (units (zmod d) \u00d7 units \u2124_[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 \u211a_[p] R] [algebra \u211a R] [is_scalar_tower \u211a \u211a_[p] R] [fact (0 < m)]\n  {k : \u2115} (hk : 1 < k) : (\u03bb (n : \u2115), (1 / ((d * p ^ n : \u2115) : \u211a_[p])) \u2022\n  \u2211 (i : \u2115) in finset.range (d * p ^ n), (asso_dirichlet_character (\u03c7.mul\n  (teichmuller_character_mod_p' p R^k))) \u2191i * \u2191i ^ k - general_bernoulli_number\n  (\u03c7.mul (teichmuller_character_mod_p' p R ^ k)) k) =\u1da0[filter.at_top]\n  \u03bb (x : \u2115), -((1 / (d * p ^ x : \u2115) : \u211a_[p]) \u2022 \u2211 (x_1 : \u2115) in finset.range (d * p ^ x).pred,\n  (asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R ^ k))) \u2191(x_1.succ) *\n  ((algebra_map \u211a R) (bernoulli 1 * \u2191k) * \u2191(d * p ^ x) * \u2191(1 + x_1) ^ (k - 1)) +\n  (1 / (d * p ^ x : \u2115) : \u211a_[p]) \u2022 \u2211 (x_1 : \u2115) in finset.range (d * p ^ x).pred,\n  (asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R ^ k))) \u2191(x_1.succ) *\n  (\u2191(d * p ^ x) * \u2211 (x_2 : \u2115) in finset.range (k - 1),\n  (algebra_map \u211a R) (bernoulli ((k - 1).succ - x_2) * \u2191((k - 1).succ.choose x_2) *\n  (\u2191(1 + x_1) ^ x_2 / \u2191(d * p ^ x) ^ x_2) * \u2191(d * p ^ x) ^ (k - 1))) +\n  (1 / (d * p ^ x : \u2115) : \u211a_[p]) \u2022\n  ((asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R ^ k)).asso_primitive_character)\n  \u2191(d * p ^ x) * ((algebra_map \u211a R) (\u2191(d * p ^ x) ^ k) *\n  (algebra_map \u211a R) (polynomial.eval (\u2191(d * p ^ x) / \u2191(d * p ^ x)) (polynomial.bernoulli k))))) :=\nbegin\n  rw [eventually_eq, eventually_at_top],\n  refine \u27e8m, \u03bb x hx, _\u27e9,\n  have h1 : lcm (d * p^m) p \u2223 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 : \u2115) : \u211a) \u2260 0 := nat.cast_ne_zero.2 (nat.ne_zero_of_lt' 0),\n  have coe_sub : (k : \u2124) - 1 = ((k - 1 : \u2115) : \u2124),\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 : \u2200 x : \u2115, asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R ^ k)).asso_primitive_character x =\n    asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R ^ k)) x :=\n  asso_dirichlet_character.asso_primitive_character _ (is_primitive.mul _ _),\n  have f1 : (\u03c7.mul (teichmuller_character_mod_p' p R ^ k)).asso_primitive_character.conductor =\n    (\u03c7.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, \u2190 one_mul\n    ((algebra_map \u211a R) (((d * p ^ x : \u2115) : \u211a) ^ (k - 1))), \u2190 (algebra_map \u211a R).map_one,\n    \u2190one_div_mul_cancel ne_zero, (algebra_map \u211a R).map_mul, mul_assoc _ _ ((algebra_map \u211a R)\n    (((d * p ^ x : \u2115) : \u211a) ^ (k - 1))), \u2190(algebra_map \u211a R).map_mul, \u2190pow_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 \u211a R) (((d * p ^ x : \u2115) : \u211a) ^ k)) _, mul_assoc,\n      mul_comm _ ((algebra_map \u211a R) (((d * p ^ x : \u2115) : \u211a) ^ 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, \u2190nat.sub_add_cancel (nat.succ_le_iff.2 poss),\n      \u2190finset.sum_Ico_add, finset.sum_Ico_succ_top (nat.zero_le _) _, \u2190finset.range_eq_Ico,\n      \u2190nat.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, \u2190smul_sub, \u2190sub_sub, \u2190sub_sub, sub_self,\n    zero_sub, \u2190neg_add', smul_neg, nat.pred_add_one_eq_self poss, \u2190smul_add, \u2190smul_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 \u211a_[p] R] [fact (0 < m)]\nopen clopen_from\n\n-- `helper_289` replaced with `helper_18`\nlemma helper_18 {n : \u2115} (hn : 1 < n) (a : (zmod d)\u02e3 \u00d7 (zmod (p^n))\u02e3) :\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 (\u2191(((units.chinese_remainder (nat.coprime.pow_right n hd)).symm) a))) :=\nbegin\n  ext,\n  rw loc_const_ind_fn, rw \u2190 locally_constant.to_fun_eq_coe,\n  simp only,\n  by_cases h' : is_unit x.fst \u2227 is_unit x.snd, --rw ind_fn.ind_fn_def, --simp only, split_ifs,\n  { by_cases hx : x \u2208 clopen_from \u2191(((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 \u2190 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 \u2190 hx.2, rw units.chinese_remainder_symm_apply_fst,\n      rw units.chinese_remainder_symm_apply_snd, refine \u27e8rfl, rfl\u27e9,\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 \u2190hx.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 \u27e8h'.1, h'.2.symm\u27e9, }, },\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 \u2190hx.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 \u211a_[p] R]\n  [fact (0 < m)] {k : \u2115} [algebra \u211a R] [is_scalar_tower \u211a \u211a_[p] R] [norm_one_class R] (hk : 1 < k)\n  (h\u03c7 : \u03c7.is_even) (hp : 2 < p)\n  (na : \u2200 (n : \u2115) (f : \u2115 \u2192 R), \u2225 \u2211 (i : \u2115) in finset.range n, f i\u2225 \u2264 \u2a06 (i : zmod n), \u2225f i.val\u2225) :\n  filter.tendsto (\u03bb n, (1/((d * p^n : \u2115) : \u211a_[p])) \u2022 \u2211 i in finset.range (d * p^n),\n  ((asso_dirichlet_character (\u03c7.mul (teichmuller_character_mod_p' p R ^ k))) i * i^k) )\n  (@filter.at_top \u2115 _) (nhds (general_bernoulli_number\n  (\u03c7.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 \u2190neg_zero, rw \u2190add_zero (0 : R),\n    conv { congr, congr, congr, rw \u2190add_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 \u211a R) (bernoulli 1 * \u2191k) * \u2191(d * p ^ x)) _, \u2190mul_assoc], },\n      rw [\u2190finset.sum_mul, mul_comm _ ((algebra_map \u211a R) (bernoulli 1 * \u2191k) * \u2191(d * p ^ x)),\n       \u2190smul_mul_assoc, mul_comm ((algebra_map \u211a R) (bernoulli 1 * \u2191k)) \u2191(d * p ^ x),\n       \u2190smul_mul_assoc, \u2190div_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, \u2190smul_eq_mul,\n       algebra_map_smul, helper_14 p R], skip, skip,\n       rw \u2190@smul_zero \u211a_[p] R _ _ _ ((algebra_map \u211a \u211a_[p]) (bernoulli 1 * \u2191k)), },\n    refine tendsto.const_smul _ _,\n    convert (tendsto_congr' _).2 (sum_even_character_tendsto_zero hk h\u03c7 hp na),\n    rw [eventually_eq, eventually_at_top],\n    refine \u27e8m, \u03bb x hx, _\u27e9,\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' (\u03bb x : \u2115, (asso_dirichlet_character (\u03c7.mul\n      (teichmuller_character_mod_p' p R ^ k))) \u2191x * \u2191x ^ (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 \u03b5 h\u03b5,\n    obtain \u27e8N, h\u27e9 := metric.tendsto_at_top.1 (tendsto.const_mul ((\u2a06 (x_1 : zmod (k.sub 0).pred),\n      \u2225(algebra_map \u211a R) (bernoulli ((k.sub 0).pred.succ - x_1.val) *\n      \u2191((k.sub 0).pred.succ.choose x_1.val))\u2225) *\n      (\u03c7.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))) (\u03b5/2) (half_pos h\u03b5),\n    simp_rw [sub_zero, mul_zero _, dist_zero_right _, real.norm_eq_abs] at h,\n    refine \u27e8N, \u03bb  x hx, _\u27e9,\n    rw dist_eq_norm, rw sub_zero,\n    conv { congr, congr, conv { congr, skip,\n      conv { apply_congr, skip, rw [\u2190mul_assoc, mul_comm ((asso_dirichlet_character (\u03c7.mul\n        (teichmuller_character_mod_p' p R ^ k))) \u2191(x_1.succ)) _, mul_assoc, add_comm 1 x_1], },\n      rw \u2190finset.mul_sum, },\n      rw [\u2190smul_mul_assoc, \u2190div_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 _) (\u03bb b hb, _))\n      (half_lt_self h\u03b5)),\n    cases hb with y hy,\n    rw \u2190hy,\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 : \u2200 x : \u2115, ((d * p^x : \u2115) : \u211a) \u2260 0 := \u03bb 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 (\u03c7.mul\n      (teichmuller_character_mod_p' p R ^ k)).asso_primitive_character) \u2191(d * p ^ x))\n      ((algebra_map \u211a R) (\u2191(d * p ^ x) ^ k) * (algebra_map \u211a R)\n      (polynomial.eval 1 (polynomial.bernoulli k))), mul_assoc, \u2190 smul_mul_assoc,\n      \u2190 nat.succ_pred_eq_of_pos (pos_of_gt hk), pow_succ, (algebra_map \u211a R).map_mul,\n      \u2190 smul_mul_assoc, \u2190 inv_eq_one_div, map_nat_cast,--], },\n      inv_smul_self' p R (@nat.ne_zero_of_lt' 0 (d * p^x) _), one_mul, \u2190 mul_assoc, mul_comm _\n      ((algebra_map \u211a R) (polynomial.eval 1 (polynomial.bernoulli k.pred.succ))), mul_assoc], skip,\n      skip, congr, rw \u2190mul_zero ((algebra_map \u211a 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 \u03b5 h\u03b5,\n      obtain \u27e8N, hN\u27e9 := metric.tendsto_at_top.1 (norm_pow_lim_eq_zero p d R 1 (nat.pred_lt_pred\n        nat.one_ne_zero hk)) (\u03b5/((\u03c7.mul\n        (teichmuller_character_mod_p' p R ^ k.pred.succ)).asso_primitive_character.bound))\n        (div_pos h\u03b5 (bound_pos _)),\n      refine \u27e8N, \u03bb x hx, _\u27e9,\n      rw dist_eq_norm, rw sub_zero, rw mul_comm,\n      apply lt_of_le_of_lt (norm_mul_le _ _) _,\n      rw \u2190 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\u207b\u00b9 then so is Hom(\u039b, M)\n\nHere \u039b is a polyhedral lattice, and the T\u207b\u00b9 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 : \u2124) \u2208 filtration \u2124 1 :=\nby simp only [nnnorm_one, mem_filtration_iff]\n\nsection\n\nvariables {\u039b : Type*} [polyhedral_lattice \u039b]\nvariables {M : Type*} [pseudo_normed_group M]\n\nlemma generates_norm.add_monoid_hom_mem_filtration_iff {\u03b9 : Type} [fintype \u03b9]\n  {l : \u03b9 \u2192 \u039b} (hl : generates_norm l) (x : \u039b \u2192+ M) (c : \u211d\u22650) :\n  x \u2208 filtration (\u039b \u2192+ M) c \u2194 \u2200 i, x (l i) \u2208 filtration M (c * \u2225l i\u2225\u208a) :=\nbegin\n  refine \u27e8\u03bb H i, H (le_refl \u2225l i\u2225\u208a), _\u27e9,\n  intros H c' l' hl',\n  obtain \u27e8c\u1d62, h1, h2\u27e9 := hl.generates_nnnorm l',\n  rw [h1, x.map_sum],\n  refine filtration_mono _ (sum_mem_filtration _ (\u03bb i, c * c\u1d62 i * \u2225l i\u2225\u208a) _ _),\n  { calc \u2211 i, c * c\u1d62 i * \u2225l i\u2225\u208a\n        = c * \u2211 i, c\u1d62 i * \u2225l i\u2225\u208a : by simp only [mul_assoc, \u2190 finset.mul_sum]\n    ... = c * \u2225l'\u2225\u208a : by rw h2\n    ... \u2264 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\u1d62 i) _ _ (H i),\nend\n\nend\n\nnamespace polyhedral_lattice\n\nvariables (\u039b : Type*) (r' : \u211d\u22650) (M : Type*) [polyhedral_lattice \u039b]\nvariables [profinitely_filtered_pseudo_normed_group_with_Tinv r' M]\n\ninclude r'\n\nnamespace add_monoid_hom\n\nvariables {\u039b r' M} (c : \u211d\u22650)\n\ndef incl (c : \u211d\u22650) : filtration (\u039b \u2192+ M) c \u2192 \u03a0 l : \u039b, filtration M (c * \u2225l\u2225\u208a) :=\n\u03bb f l, \u27e8f l, f.2 $ mem_filtration_nnnorm _\u27e9\n\n@[simp] lemma coe_incl_apply (f : filtration (\u039b \u2192+ M) c) (l : \u039b) :\n  (incl c f l : M) = f l :=\nrfl\n\nvariables (\u039b r' M)\n\nlemma incl_injective : function.injective (@incl \u039b 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 (\u039b \u2192+ M) c) :=\ntopological_space.induced (incl c) infer_instance\n\nlemma incl_embedding : embedding (@incl \u039b r' M _ _ c) :=\n{ induced := rfl,\n  inj := incl_injective \u039b r' M c }\n\nlemma incl_inducing : inducing (@incl \u039b r' M _ _ c) := \u27e8rfl\u27e9\n\nlemma incl_continuous : continuous (@incl \u039b r' M _ _ c) :=\n(incl_inducing _ _ _ _).continuous\n\ninstance : t2_space (filtration (\u039b \u2192+ M) c) :=\n(incl_embedding \u039b r' M c).t2_space\n\ninstance : totally_disconnected_space (filtration (\u039b \u2192+ M) c) :=\n{ is_totally_disconnected_univ := (incl_embedding \u039b r' M c).is_totally_disconnected $\n    is_totally_disconnected_of_totally_disconnected_space _ }\n\nlemma incl_range_eq :\n  (set.range (@incl \u039b r' M _ _ c)) =\n    \u22c2 l\u2081 l\u2082, {f | (cast_le (f (l\u2081 + l\u2082)) : filtration M (c * (\u2225l\u2081\u2225\u208a + \u2225l\u2082\u2225\u208a))) =\n    cast_le (add' (f l\u2081, f l\u2082))} :=\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 \u27e8\u27e8f, hf\u27e9, rfl\u27e9 l\u2081 l\u2082,\n    exact f.map_add _ _ },\n  { intro h,\n    refine \u27e8\u27e8add_monoid_hom.mk' (\u03bb l, f l) h, _\u27e9, _\u27e9,\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 \u039b r' M _ _ c))) :=\nbegin\n  rw incl_range_eq,\n  apply is_closed_Inter,\n  intro l\u2081,\n  apply is_closed_Inter,\n  intro l\u2082,\n  apply is_closed_eq,\n  { exact (continuous_cast_le _ _).comp (continuous_apply (l\u2081 + l\u2082)) },\n  { exact (continuous_cast_le _ _).comp ((continuous_add' _ _).comp\n          ((continuous_apply l\u2081).prod_mk (continuous_apply l\u2082))) },\nend\n\ninstance : compact_space (filtration (\u039b \u2192+ M) c) :=\n{ compact_univ :=\n  begin\n    rw \u2190 (incl_inducing \u039b 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  (\u03d5 : X \u2192 (filtration (\u039b \u2192+ M) c)) :\n  continuous \u03d5 \u2194 \u2200 l : \u039b, continuous (\u03bb x, incl c (\u03d5 x) l) :=\nbegin\n  rw (incl_inducing \u039b 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 (\u039b \u2192+ M) :=\n{ continuous_add' :=\n  begin\n    intros c\u2081 c\u2082,\n    rw continuous_iff,\n    intro l,\n    have step1 :=\n      ((continuous_apply l).comp (incl_continuous \u039b r' M c\u2081)).prod_map\n      ((continuous_apply l).comp (incl_continuous \u039b r' M c\u2082)),\n    have step2 := (continuous_add' (c\u2081 * \u2225l\u2225\u208a) (c\u2082 * \u2225l\u2225\u208a)),\n    have := step2.comp step1,\n    refine (@continuous_cast_le _ _ _ _ (id _)).comp this,\n    rw add_mul, exact \u27e8le_rfl\u27e9\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 \u039b r' M c)),\n  end,\n  continuous_cast_le :=\n  begin\n    introsI c\u2081 c\u2082 h,\n    rw continuous_iff,\n    intro l,\n    exact (continuous_cast_le _ _).comp ((continuous_apply l).comp (incl_continuous \u039b r' M c\u2081))\n  end,\n  .. add_monoid_hom.pseudo_normed_group }\n\nend add_monoid_hom\n\nvariables {\u039b r' M}\n\nopen profinitely_filtered_pseudo_normed_group_with_Tinv\n\ndef Tinv' : (\u039b \u2192+ M) \u2192+ (\u039b \u2192+ M) :=\nadd_monoid_hom.comp_hom\n  (@Tinv r' M _).to_add_monoid_hom\n\n@[simp] lemma Tinv'_apply (f : \u039b \u2192+ M) (l : \u039b) :\n  Tinv' f l = Tinv (f l) := rfl\n\nlemma Tinv'_mem_filtration (c : \u211d\u22650) (f : \u039b \u2192+ M) (hf : f \u2208 filtration (\u039b \u2192+ M) c) :\n  Tinv' f \u2208 filtration (\u039b \u2192+ M) (r'\u207b\u00b9 * 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 (\u039b 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 (\u039b \u2192+ M) (\u039b \u2192+ M) :=\ncomphaus_filtered_pseudo_normed_group_hom.mk' Tinv'\nbegin\n  refine \u27e8r'\u207b\u00b9, \u03bb c, \u27e8Tinv'_mem_filtration c, _\u27e9\u27e9,\n  rw add_monoid_hom.continuous_iff,\n  intro l,\n  haveI : \u2200 a, fact (a \u2264 r' * (r'\u207b\u00b9 * a)) :=\n    \u03bb a, \u27e8by simp [mul_inv_cancel_left\u2080 (ne_of_gt (fact.out _ : 0 < r'))]\u27e9,\n  refine (@continuous_cast_le _ _ _ _ (id _)).comp\n    ((@Tinv\u2080_continuous r' M _ (c * \u2225l\u2225\u208a) (r'\u207b\u00b9 * (c * \u2225l\u2225\u208a)) _).comp\n    ((continuous_apply l).comp (add_monoid_hom.incl_continuous \u039b r' M c))),\n  rw mul_assoc, exact \u27e8le_rfl\u27e9\nend\n\ninstance : profinitely_filtered_pseudo_normed_group_with_Tinv r' (\u039b \u2192+ M) :=\n{ Tinv := Tinv \u039b r' M,\n  Tinv_mem_filtration := Tinv'_mem_filtration,\n  .. add_monoid_hom.profinitely_filtered_pseudo_normed_group \u039b r' M }\n\n@[simp] lemma Tinv_apply (x : \u039b \u2192+ M) (l : \u039b) :\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 (\u03b1 : Type u) \nvariables {L L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)}\n\nopen relation \n\nnamespace dyck\n\nvariable {\u03b1}\n\ninductive red.step : list (\u03b1 \u00d7 bool) \u2192 list (\u03b1 \u00d7 bool) \u2192 Prop\n| mul_inv {L L\u2081 : list (\u03b1 \u00d7 bool)} {x} : red.step (L ++ (x,tt) :: (x,ff) :: L\u2081) (L ++ L\u2081)\nattribute [simp] mul_inv \n\ndef red {\u03b1}  := relation.refl_trans_gen (@red.step \u03b1) \n\n@[refl] lemma red.refl : red L L := relation.refl_trans_gen.refl\n@[trans] lemma red.trans : red L\u2081 L\u2082 \u2192 red L\u2082 L\u2083 \u2192 red L\u2081 L\u2083 := relation.refl_trans_gen.trans\n\nnamespace red\n\ntheorem step.length : \u2200 {L\u2081 L\u2082 : list (\u03b1 \u00d7 bool)}, step L\u2081 L\u2082 \u2192 L\u2082.length + 2 = L\u2081.length\n| _ _ (@red.step.mul_inv _ L\u2081 L\u2082 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 : \u2200 {L\u2081 L\u2082 L\u2083 : list (\u03b1 \u00d7 bool)}, step L\u2082 L\u2083 \u2192 step (L\u2081 ++ L\u2082) (L\u2081 ++ L\u2083)\n| _ _ _ red.step.mul_inv := by rw [\u2190 list.append_assoc, \u2190 list.append_assoc]; constructor\n\ntheorem step.append_right : \u2200 {L\u2081 L\u2082 L\u2083 : list (\u03b1 \u00d7 bool)}, step L\u2081 L\u2082 \u2192 step (L\u2081 ++ L\u2083) (L\u2082 ++ L\u2083)\n| _ _ _ red.step.mul_inv := by simp only [list.append_assoc, list.cons_append]; constructor\n\ntheorem step.cons {x} (H : red.step L\u2081 L\u2082) : red.step (x :: L\u2081) (x :: L\u2082) :=\n@step.append_left _ [x] _ _ H\n\nlemma not_step_nil : \u00ac step [] L :=\nbegin\n  generalize h' : [] = L',\n  assume h,\n  cases h with L\u2081 L\u2082,\n  simp [list.append_eq_has_append, list.nil_eq_append_iff] at h',\n  contradiction,\nend\n\nprivate lemma not_step_inv {a : \u03b1} : \u00ac step [(a, ff)] L :=\nbegin\n  assume h,\n  generalize h' : [(a,ff)] = L',\n  rw h' at h,\n  cases h with L\u2081 L\u2082,\n  simp [list.append_eq_has_append, list.nil_eq_append_iff] at h',\n  cases L\u2081, \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 : \u03b1} :\n  step ((a, tt) :: L\u2081) L\u2082 \u2194 (\u2203 L, step L\u2081 L \u2227 L\u2082 = (a, tt) :: L) \u2228 (L\u2081 = (a, ff) :: L\u2082) :=\nbegin\n  split,\n  { generalize hL : ((a, tt) :: L\u2081 : list _) = L,\n    assume h,\n    rcases h with \u27e8_ | \u27e8p, s'\u27e9, e, a'\u27e9,\n    { simp at hL, simp [*] },\n    { simp at hL,\n      rcases hL with \u27e8rfl, rfl\u27e9,\n      refine or.inl \u27e8s' ++ e, step.mul_inv, _\u27e9,\n      simp only [list.append, eq_self_iff_true, true_and],\n      tauto } },\n  { assume h,\n    rcases h with \u27e8L, h, rfl\u27e9 | rfl,\n    { exact step.cons h },\n    { simp only [step.cons_mul_inv] } }\nend\n\nlemma step.cons_left_of_inv_iff {a : \u03b1} :\n  step ((a, ff) :: L\u2081) L\u2082 \u2194 (\u2203 L, step L\u2081 L \u2227 L\u2082 = (a, ff) :: L) :=\nbegin\n  split, \n  { generalize hL : ((a, ff) :: L\u2081 : list _) = L,\n    assume h,\n    rcases h with \u27e8_ | \u27e8p, s'\u27e9, e, a'\u27e9,\n    { simp only [list.append, prod.mk.inj_iff, and_false, false_and, step.cons_mul_inv] at *,\n      exact false.rec (\u2203 (L : list (\u03b1 \u00d7 bool)), step L\u2081 L \u2227 e = (a, ff) :: L) hL },\n    { simp only [list.append, eq_self_iff_true, true_and] at *,\n      rcases hL with \u27e8rfl, rfl\u27e9,\n      simp only [eq_self_iff_true, true_and, exists_eq_right'] at *,\n      fconstructor } }, \n    { intro h,\n      rcases h with \u27e8L, h, h'\u27e9,\n      rw h'; exact step.cons h }\nend\n\nlemma not_step_singleton : \u2200 {p : \u03b1 \u00d7 bool}, \u00ac 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\u2081 L\u2082 \u2192 red L\u2081 L\u2082 :=\nrelation.refl_trans_gen.single\n\nlemma step.cons_of_inv_cons_iff : \u2200 {a : \u03b1}, step ((a, ff) :: L\u2081) ((a, ff) :: L\u2082) \u2194 step L\u2081 L\u2082 :=\nbegin\n  intro a,\n  split, \n  { intro h,\n    rw step.cons_left_of_inv_iff at h,\n    rcases h with \u27e8L, _, _\u27e9,\n    simp only [eq_self_iff_true, true_and] at h_h_right,\n    rw \u2190 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\u2081 L\u2082 \u2192 red (p :: L\u2081) (p :: L\u2082) :=\nrelation.refl_trans_gen.lift (list.cons p) (assume a b, step.cons)\n\nprivate theorem step.diamond_aux : \u2200 {L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)} {x1 x2 },\n  L\u2081 ++ (x1, tt) :: (x1, ff) :: L\u2082 = L\u2083 ++ (x2, tt) :: (x2, ff) :: L\u2084 \u2192\n  L\u2081 ++ L\u2082 = L\u2083 ++ L\u2084 \u2228 \u2203 L\u2085, red.step (L\u2081 ++ L\u2082) L\u2085 \u2227 red.step (L\u2083 ++ L\u2084) L\u2085\n:=\nbegin\n  intros L\u2081 L\u2082 L\u2083 L\u2084 x1 x2 h,\n  rw list.append_eq_append_iff at *,\n  induction h,\n  rcases h with \u27e8a', hl, hr\u27e9,\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 \u2190 hrl,\n  exact hl,\n\n  simp,\n  exact hrr.2.symm,\n\n  rcases hr with \u27e8a'', hrl, hrr\u27e9,\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  (((\u2203 (a' : list (\u03b1 \u00d7 bool)), L\u2083 = L\u2081 ++ a' \u2227 L\u2082 = a' ++ L\u2084) \u2228\n        \u2203 (c' : list (\u03b1 \u00d7 bool)), L\u2081 = L\u2083 ++ c' \u2227 L\u2084 = c' ++ L\u2082) \u2228\n     \u2203 (L\u2085 : list (\u03b1 \u00d7 bool)), step (L\u2081 ++ L\u2082) L\u2085 \u2227 step (L\u2083 ++ L\u2084) L\u2085)\n  hrrr,\n\n  rcases hrr with \u27e8b', hrrl, hrrr\u27e9,\n  rw hrrl at hrl,\n  rw hrl at hl,\n  right,\n  subst_vars,\n  use (L\u2081 ++ b' ++L\u2084),\n  split,\n  rw \u2190 list.append_assoc,\n  generalize eq\u2081 : (L\u2081 ++ b' = LL),\n  exact step.mul_inv,\n  generalize eq\u2081 : (b' ++ L\u2084= LL),\n  simp,\n  rw eq\u2081,\n  exact step.mul_inv,\n\n  rcases h with \u27e8c, hl, hr\u27e9,\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 \u27e8a', hrl, hrr\u27e9,\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  (((\u2203 (a' : list (\u03b1 \u00d7 bool)), L\u2083 = L\u2081 ++ a' \u2227 L\u2082 = a' ++ L\u2084) \u2228\n        \u2203 (c' : list (\u03b1 \u00d7 bool)), L\u2081 = L\u2083 ++ c' \u2227 L\u2084 = c' ++ L\u2082) \u2228\n     \u2203 (L\u2085 : list (\u03b1 \u00d7 bool)), step (L\u2081 ++ L\u2082) L\u2085 \u2227 step (L\u2083 ++ L\u2084) L\u2085)\n  hrrr,\n\n  rcases hrr with \u27e8b', hrrl, hrrr\u27e9,\n  rw hrrl at hrl,\n  rw hrl at hl,\n  right,\n  subst_vars,\n  use (L\u2083 ++ b' ++ L\u2082),\n  split,\n  simp,\n  generalize eq\u2081 : (b' ++ L\u2082 = LL),\n  exact step.mul_inv,\n\n  rw \u2190 list.append_assoc,\n  generalize eq\u2081 : (L\u2083 ++ b' = LL),\n  exact step.mul_inv,\nend\n\ntheorem step.diamond : \u2200 {L\u2081 L\u2082 L\u2083 L\u2084 : list (\u03b1 \u00d7 bool)},\n  red.step L\u2081 L\u2083 \u2192 red.step L\u2082 L\u2084 \u2192 L\u2081 = L\u2082 \u2192\n  L\u2083 = L\u2084 \u2228 \u2203 L\u2085, red.step L\u2083 L\u2085 \u2227 red.step L\u2084 L\u2085\n| _ _ _ _ red.step.mul_inv red.step.mul_inv H := step.diamond_aux H\n\ntheorem church_rosser : red L\u2081 L\u2082 \u2192 red L\u2081 L\u2083 \u2192 relation.join red L\u2082 L\u2083 :=\nrelation.church_rosser (assume a b c hab hac,\nmatch b, c, red.step.diamond hab hac rfl with\n| b, _, or.inl rfl           := \u27e8b, by refl, by refl\u27e9\n| b, c, or.inr \u27e8d, hbd, hcd\u27e9 := \u27e8d, relation.refl_gen.single hbd, hcd.to_red\u27e9\nend)\n\ntheorem nil_iff : red [] L \u2194 L = [] :=\nrefl_trans_gen_iff_eq (assume l, red.not_step_nil)\n\ntheorem singleton_iff {x} : red [x] L\u2081 \u2194 L\u2081 = [x] :=\nrefl_trans_gen_iff_eq (assume l, not_step_singleton)\n\nprivate lemma cons_nil_iff_singleton_aux {x} : \nred L [] \u2192 (\u2203 L', L = (x, tt) :: L') \u2192 red L.tail [(x, ff)] :=\nbegin\n  intros h,\n  apply h.head_induction_on,\n  intro h',\n  rcases h' with \u27e8L', _\u27e9,\n  simp at *,\n  contradiction,\n  rintros a c h\u2082 h\u2083 h\u2084 \u27e8 L', h\u2085\u27e9,\n  induction h\u2082 with L\u2081 L\u2082 x1,\n  have := eq.symm h\u2085,\n  clear h\u2085,\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 \u2190 red at *,\n  exact cons_cons h\u2083,\n\n  rcases this with \u27e8a', hl, hr\u27e9,\n  subst_vars,\n  specialize h\u2084 _,\n  use (a' ++ L\u2082),\n  simp at *,\n  have : ((x, tt) :: a' ++ L\u2082).tail = a' ++ L\u2082 := by simp,\n  rw this at *,\n  clear this,\n  have : ((x, tt) :: a' ++ (x1, tt) :: (x1, ff) :: L\u2082).tail = a' ++ (x1, tt) :: (x1, ff) :: L\u2082 := by simp,\n  rw this at *,\n  clear this,\n  have h\u2081 : red (a' ++ (x1, tt) :: (x1, ff) :: L\u2082) (a' ++ L\u2082), {\n    refine step.to_red _,\n    exact step.mul_inv,\n  },\n  exact trans h\u2081 h\u2084,\nend\n\ntheorem cons_nil_iff_singleton {x} : red ((x, tt) :: L) [] \u2194 red L [(x, ff)] :=\nbegin\n  split,\n  intro h,\n  have := @cons_nil_iff_singleton_aux \u03b1 ((x, tt) :: L) x h _,\n  simp at *,\n  exact this,\n  use L,\n  intro h,\n  have h\u2081 : red ((x, tt) :: L) ((x, tt) :: [(x, ff)]) := cons_cons h,\n  have h\u2082 : red [(x, tt), (x, ff)] [], {\n    refine step.to_red _,\n    exact step.cons_mul_inv,\n  },\n  exact trans h\u2081 h\u2082,\nend  \n\n/-\nprivate lemma append_nil_iff_singleton_aux {x} : \nred L [] \u2192 (\u2203 L', L = L' ++ [(x, ff)]) \u2192 red (L.reverse.tail.reverse) [(x, tt)] :=\nbegin\n  intro h,\n  apply h.head_induction_on,\n  sorry,\n  intros a c h\u2081 h\u2082 h\u2083 h\u2084,\n  induction h\u2081 with L\u2081 L\u2082 x1,\n  rcases h\u2084 with \u27e8L', h\u27e9,\n  rw list.append_eq_append_iff at *,\n  induction h,\n  rcases h_1 with \u27e8a', hl, hr\u27e9,\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 \u27e8b, hrl, hrr\u27e9,\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 \u03b1)) :=\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           := \u27e8b, by refl, by refl\u27e9\n| b, c, or.inr \u27e8d, hbd, hcd\u27e9 := \u27e8d, refl_gen.single hbd, refl_trans_gen.single hcd\u27e9\nend)\n\ntheorem join_red_of_step (h : red.step L\u2081 L\u2082) : join red L\u2081 L\u2082 :=\njoin_of_single reflexive_refl_trans_gen h.to_red\n\ntheorem eqv_gen_step_iff_join_red : eqv_gen red.step L\u2081 L\u2082 \u2194 join red L\u2081 L\u2082 :=\niff.intro\n  (assume h,\n    have eqv_gen (join red) L\u2081 L\u2082 := 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\u2081 L\u2082 \u2192 free_group.red.step L\u2081 L\u2082 :=\nbegin\n  intro h,\n  induction h,\n  exact free_group.red.step.bnot,\nend\n\nlemma to_free_group_red : red L\u2081 L\u2082 \u2192 free_group.red L\u2081 L\u2082 :=\nbegin\n  rw red,\n  rw free_group.red,\n  refine refl_trans_gen.lift (\u03bb {L\u2081 : list (\u03b1 \u00d7 bool)}, L\u2081) _,\n  intros a b,\n  exact to_free_group_step,\nend\n\ntheorem step.sublist (H : red.step L\u2081 L\u2082) : L\u2082 <+ L\u2081 :=\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\u2081 L\u2082 \u2192 L\u2082 <+ L\u2081 :=\nrefl_trans_gen_of_transitive_reflexive\n  (\u03bbl, list.sublist.refl l) (\u03bba b c hab hbc, list.sublist.trans hbc hab) (\u03bba b, red.step.sublist)\n\nend red\n\nend dyck\n\n-- Definition of the dyck syntactic monoid\ndef dyck (\u03b1 : Type u) : Type u :=\nquot $ @dyck.red.step \u03b1\n\nnamespace dyck\n\nvariable {\u03b1}\n\ndef mk (L) : dyck \u03b1 := 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 (\u03b2 : Type v) (f : list (\u03b1 \u00d7 bool) \u2192 \u03b2)\n  (H : \u2200 L\u2081 L\u2082, red.step L\u2081 L\u2082 \u2192 f L\u2081 = f L\u2082) :\nquot.lift f H (mk L) = f L := rfl\n\n@[simp] lemma quot_lift_on_mk (\u03b2 : Type v) (f : list (\u03b1 \u00d7 bool) \u2192 \u03b2)\n  (H : \u2200 L\u2081 L\u2082, red.step L\u2081 L\u2082 \u2192 f L\u2081 = f L\u2082) :\nquot.lift_on (mk L) f H = f L := rfl\n\n@[simp] lemma quot_map_mk (\u03b2 : Type v) (f : list (\u03b1 \u00d7 bool) \u2192 list (\u03b2 \u00d7 bool))\n  (H : (red.step \u21d2 red.step) f f) :\nquot.map f H (mk L) = mk (f L) := rfl\n\ninstance : has_one (dyck \u03b1) := \u27e8mk []\u27e9\nlemma one_eq_mk : (1 : dyck \u03b1) = mk [] := rfl\n\ninstance : inhabited (dyck \u03b1) := \u27e81\u27e9\n\ninstance : has_mul (dyck \u03b1) :=\n\u27e8\u03bb x y, quot.lift_on x\n    (\u03bb L\u2081, quot.lift_on y (\u03bb L\u2082, mk $ L\u2081 ++ L\u2082) (\u03bb L\u2082 L\u2083 H, quot.sound $ red.step.append_left H))\n    (\u03bb L\u2081 L\u2082 H, quot.induction_on y $ \u03bb L\u2083, quot.sound $ red.step.append_right H)\u27e9\n@[simp] lemma mul_mk : mk L\u2081 * mk L\u2082 = mk (L\u2081 ++ L\u2082) := rfl\n\ninstance : monoid (dyck \u03b1) :=\n{ mul := (*),\n  one := 1,\n  mul_assoc := by rintros \u27e8L\u2081\u27e9 \u27e8L\u2082\u27e9 \u27e8L\u2083\u27e9; simp,\n  one_mul := by rintros \u27e8L\u27e9; refl,\n  mul_one := by rintros \u27e8L\u27e9; simp [one_eq_mk],\n}\n\ndef of (x : \u03b1) : dyck \u03b1 :=\nmk [(x, tt)]\n\ntheorem red.exact : mk L\u2081 = mk L\u2082 \u2194 join red L\u2081 L\u2082 :=\ncalc (mk L\u2081 = mk L\u2082) \u2194 eqv_gen red.step L\u2081 L\u2082 : iff.intro (quot.exact _) quot.eqv_gen_sound\n  ... \u2194 join red L\u2081 L\u2082 : red.eqv_gen_step_iff_join_red\n\ntheorem of_injective : function.injective (@of \u03b1) :=\n\u03bb _ _ H, let \u27e8L\u2081, hx, hy\u27e9 := red.exact.1 H in\n  by simp [red.singleton_iff] at hx hy; cc\n\nlemma mk_one_iff {L : list (\u03b1 \u00d7 bool)}: mk L = 1 \u2194 red L [] :=\nbegin\nsplit,\n  { intro h,\n    rw [one_eq_mk, red.exact] at h,\n    rcases h with \u27e8c, hl, hr\u27e9,\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 \u27e8h, red.refl\u27e9 }\nend \n\nlemma mk_mul_inv : \u2200 {x : \u03b1}, 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\u2081 : list (\u03b1 \u00d7 bool)} {x} : \nmk (L ++ (x, tt) :: (x, ff) :: L\u2081) = mk (L ++ L\u2081) :=\nbegin\n  have : L ++ (x, tt) :: (x, ff) :: L\u2081 = L ++ [(x, tt), (x, ff)] ++ L\u2081 := by simp,\n  rw [this, \u2190 mul_mk, \u2190 mul_mk, mk_mul_inv, mul_one, mul_mk],\nend \n\n\nlemma mk_free_group : mk L\u2081 = mk L\u2082 \u2192 free_group.mk L\u2081 = free_group.mk L\u2082 :=\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 \u27e8red.to_free_group_red h.1, red.to_free_group_red h.2\u27e9,\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 {\u03b1 : Type*} [monoid \u03b1] (p n : \u2115) (a : \u03b1) :\n  (frobenius \u03b1 p)^[n] a = a^p^n :=\nbegin\n  induction n with n ih, {simp},\n  rw [nat.iterate_succ', ih, frobenius_def, \u2190 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 : \u2115) [nat.prime p] [char_p R p]\n\nprivate def f\u2080 : \u2115 \u00d7 R \u2192 nnreal :=\n\u03bb (x : \u2115 \u00d7 R), (v x.2)^(p^(-x.1 : \u2124) : \u211d)\n\nprivate def hf\u2080 : \u2200 (x\u2081 x\u2082 : \u2115 \u00d7 R) (h : perfect_closure.r R p x\u2081 x\u2082),\n  f\u2080 v p x\u2081 = f\u2080 v p x\u2082\n| x\u2081 x\u2082 (perfect_closure.r.intro _ n x) :=\nshow v x ^ (p ^ (-n : \u2124) : \u211d) = v (x ^ p) ^ (p ^ (-(\u2191n + 1) : \u2124) : \u211d),\nfrom have hp : (p : \u211d) \u2260 0 := by exact_mod_cast nat.prime.ne_zero \u2039_\u203a,\nby rw [valuation.map_pow, \u2190 rpow_nat_cast, \u2190 rpow_mul, neg_add_rev,\n    fpow_add hp, \u2190 mul_assoc, fpow_inv, mul_inv_cancel hp, one_mul]\n\ndef f : perfect_closure R p \u2192 nnreal :=\nquot.lift (f\u2080 v p) (hf\u2080 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\u2080 v p) (hf\u2080 v p) (0 : perfect_closure R p) : rfl\n  ... = (v (0:R))^(p^(-0:\u2124) : \u211d) : quot.lift_beta (f\u2080 v p) (hf\u2080 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\u2080 v p) (hf\u2080 v p) (1 : perfect_closure R p) : rfl\n  ... = (v (1:R))^(p^(-0:\u2124) : \u211d) : quot.lift_beta (f\u2080 v p) (hf\u2080 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 $ \u03bb \u27e8m,x\u27e9, quot.induction_on s $ \u03bb \u27e8n,y\u27e9,\nshow f\u2080 v p (m + n, _) = f\u2080 v p (m,x) * f\u2080 v p (n,y), from\nhave hp : p \u2260 0 := nat.prime.ne_zero \u2039_\u203a,\nhave hpQ : (p : \u211d) \u2260 0 := by exact_mod_cast hp,\nbegin\n  clear _fun_match _fun_match _x _x,\n  dsimp only [f\u2080],\n  simp only [iterate_frobenius_apply, v.map_mul, v.map_pow, mul_rpow],\n  congr' 1,\n  all_goals {\n    rw [\u2190 rpow_nat_cast, \u2190 rpow_mul, nat.cast_pow, \u2190fpow_of_nat, \u2190 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) \u2264 max (f v p r) (f v p s) :=\nquot.induction_on r $ \u03bb \u27e8m,x\u27e9, quot.induction_on s $ \u03bb \u27e8n,y\u27e9,\nshow f\u2080 v p (m + n, _) \u2264 max (f\u2080 v p (m,x)) (f\u2080 v p (n,y)), from\nhave hp : p \u2260 0 := nat.prime.ne_zero \u2039_\u203a,\nhave hpQ : (p : \u211d) \u2260 0 := by exact_mod_cast hp,\nbegin\n  clear _fun_match _fun_match _x _x,\n  dsimp only [f\u2080],\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 \u22a2,\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 [\u2190 rpow_nat_cast, \u2190 rpow_mul, nat.cast_pow, \u2190fpow_of_nat, \u2190 fpow_add hpQ],\n    { congr, rw [int.coe_nat_add, neg_add], abel }, }\nend\n\nend perfection\n\nsection\nvariables (p : \u2115) [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\u00e4rn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David W\u00e4rn\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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) \nwhere\n  as : C\n\nprotected instance quotient.inhabited {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {s : C} {t : C} : (s \u27f6 t) \u2192 (s \u27f6 t) \u2192 Prop\nwhere\n| intro : \u2200 {a b : C} (f : s \u27f6 a) (m\u2081 m\u2082 : a \u27f6 b) (g : b \u27f6 t), r m\u2081 m\u2082 \u2192 comp_closure r (f \u226b m\u2081 \u226b g) (f \u226b m\u2082 \u226b g)\n\ntheorem comp_left {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : C} {b : C} {c : C} (f : a \u27f6 b) (g\u2081 : b \u27f6 c) (g\u2082 : b \u27f6 c) (h : comp_closure r g\u2081 g\u2082) : comp_closure r (f \u226b g\u2081) (f \u226b g\u2082) := sorry\n\ntheorem comp_right {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : C} {b : C} {c : C} (g : b \u27f6 c) (f\u2081 : a \u27f6 b) (f\u2082 : a \u27f6 b) (h : comp_closure r f\u2081 f\u2082) : comp_closure r (f\u2081 \u226b g) (f\u2082 \u226b g) := sorry\n\n/-- Hom-sets of the quotient category. -/\ndef hom {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) (a : quotient r) : Inhabited (hom r a a) :=\n  { default := Quot.mk (comp_closure r) \ud835\udfd9 }\n\n/-- Composition in the quotient category. -/\ndef comp {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : quotient r} {b : quotient r} {c : quotient r} : hom r a b \u2192 hom r b c \u2192 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 \u27f6 as b) => quot.lift_on hg (fun (g : as b \u27f6 as c) => Quot.mk (comp_closure r) (f \u226b g)) sorry) sorry\n\n@[simp] theorem comp_mk {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : quotient r} {b : quotient r} {c : quotient r} (f : as a \u27f6 as b) (g : as b \u27f6 as c) : comp r (Quot.mk (comp_closure r) f) (Quot.mk (comp_closure r) g) = Quot.mk (comp_closure r) (f \u226b g) :=\n  rfl\n\nprotected instance category {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) (_x : C) : \u2200 (_x_1 : C) (f : _x \u27f6 _x_1), functor.map (functor r) f = Quot.mk (comp_closure r) f :=\n  fun (_x_1 : C) (f : _x \u27f6 _x_1) => Eq.refl (functor.map (functor r) f)\n\nprotected theorem induction {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {P : {a b : quotient r} \u2192 (a \u27f6 b) \u2192 Prop} (h : \u2200 {x y : C} (f : x \u27f6 y), P (functor.map (functor r) f)) {a : quotient r} {b : quotient r} (f : a \u27f6 b) : P f := sorry\n\nprotected theorem sound {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {a : C} {b : C} {f\u2081 : a \u27f6 b} {f\u2082 : a \u27f6 b} (h : r f\u2081 f\u2082) : functor.map (functor r) f\u2081 = functor.map (functor r) f\u2082 := sorry\n\n/-- The induced functor on the quotient category. -/\ndef lift {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {D : Type u_1} [category D] (F : C \u2964 D) (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 functor.map F f\u2081 = functor.map F f\u2082) : quotient r \u2964 D :=\n  functor.mk (fun (a : quotient r) => functor.obj F (as a))\n    fun (a b : quotient r) (hf : a \u27f6 b) => quot.lift_on hf (fun (f : as a \u27f6 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} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {D : Type u_1} [category D] (F : C \u2964 D) (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 functor.map F f\u2081 = functor.map F f\u2082) : functor r \u22d9 lift r F H \u2245 F :=\n  nat_iso.of_components (fun (X : C) => iso.refl (functor.obj (functor r \u22d9 lift r F H) X)) sorry\n\n@[simp] theorem lift.is_lift_hom {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {D : Type u_1} [category D] (F : C \u2964 D) (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 functor.map F f\u2081 = functor.map F f\u2082) (X : C) : nat_trans.app (iso.hom (lift.is_lift r F H)) X = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem lift.is_lift_inv {C : Type u} [category C] (r : {a b : C} \u2192 (a \u27f6 b) \u2192 (a \u27f6 b) \u2192 Prop) {D : Type u_1} [category D] (F : C \u2964 D) (H : \u2200 (x y : C) (f\u2081 f\u2082 : x \u27f6 y), r f\u2081 f\u2082 \u2192 functor.map F f\u2081 = functor.map F f\u2082) (X : C) : nat_trans.app (iso.inv (lift.is_lift r F H)) X = \ud835\udfd9 :=\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 {\u03b1 : Type u}\nvariable [semiring \u03b1]\n\ndef associated (x y : \u03b1) : Prop:=\n\u2203u : units \u03b1, x = u * y\n\nlocal notation a `~\u1d64` b : 50 := associated a b\n\ndef is_unit (a : \u03b1) : Prop := \u2203b : units \u03b1, a = b\n\n/- is used once in UFD, but I don't understand what it does\n-/\nlemma is_unit_unit  (u : units \u03b1) : @is_unit \u03b1 _ u :=\n\u27e8u, rfl\u27e9\n\n\n@[simp] lemma is_unit_one : is_unit (1 : \u03b1 ) := \u27e81, rfl\u27e9\n\n--Should I do all these lemmas using the zero_ne_one class?\n@[simp] lemma not_is_unit_zero (h : (0 : \u03b1) \u2260 1) : \u00ac is_unit (0 : \u03b1) := --Do we need semiring?\nbegin\n  intro h,\n  rcases h with \u27e8u, hu\u27e9,\n  have h2: u.val*u.inv = 1,\n    from u.val_inv,\n  simp [units.val_coe] at *,\n  rw [\u2190hu, _root_.zero_mul] at h2,\n  contradiction,\nend\n\nlemma ne_zero_of_is_unit {a : \u03b1} (h : (0 : \u03b1) \u2260 1) : is_unit a \u2192 a \u2260 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 : \u03b1} (h1 : is_unit a) (h2 : is_unit b) : is_unit (a * b) :=\nlet \u27e8a\u1d64, ha\u27e9 := h1 in\nlet \u27e8b\u1d64, hb\u27e9 := h2 in \u27e8a\u1d64*b\u1d64, by simp [units.mul_coe, *]\u27e9\n\nlemma zero_associated_zero   : (0 : \u03b1) ~\u1d64 0 := \u27e81, by simp\u27e9\n\nlemma unit_associated_one {u : units \u03b1}: (u : \u03b1) ~\u1d64 1 := \u27e8u, by simp\u27e9\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 \u00d7 Array (DiscrTree.Key true)) (DiscrTree Name true) \u2190\n  registerSimpleScopedEnvExtension {\n    addEntry := fun dt (n, ks) \u21a6 dt.insertCore ks n\n    initial := {}\n  }\n\ninitialize registerBuiltinAttribute {\n  name := `refl\n  descr := \"reflexivity relation\"\n  add := fun decl _ kind \u21a6 MetaM.run' do\n    let declTy := (\u2190 getConstInfo decl).type\n    let (_, _, targetTy) \u2190 withReducible <| forallMetaTelescopeReducing declTy\n    let fail := throwError\n      \"@[refl] attribute only applies to lemmas proving x \u223c x, got {declTy}\"\n    let .app (.app rel lhs) rhs := targetTy | fail\n    unless \u2190 withNewMCtxDepth <| isDefEq lhs rhs do fail\n    let key \u2190 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 \u2190 getMainTarget\n  let .app (.app rel _) _ := tgt\n    | throwError \"reflexivity lemmas only apply to binary relations, not {indentExpr tgt}\"\n  let s \u2190 saveState\n  for lem in \u2190 (reflExt.getState (\u2190 getEnv)).getMatch rel do\n    try\n      liftMetaTactic (\u00b7.apply (\u2190 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 (\u03b1 \u03b2 : Type u)\n\nexample (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : (\u03bb x, f x) a = f a := rfl\nexample (a : \u03b1) (b : \u03b1) : (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 \u2227 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 {\u03b1 : Sort _} {a : \u03b1} := a\n#align hidden hidden\n\ninstance (priority := 10) decidableEq_of_subsingleton [Subsingleton \u03b1] : DecidableEq \u03b1 :=\n  fun a b \u21a6 isTrue (Subsingleton.elim a b)\n#align decidable_eq_of_subsingleton decidableEq_of_subsingleton\n\ninstance (\u03b1 : Sort _) [Subsingleton \u03b1] (p : \u03b1 \u2192 Prop) : Subsingleton (Subtype p) :=\n  \u27e8fun \u27e8x, _\u27e9 \u27e8y, _\u27e9 \u21a6 by cases Subsingleton.elim x y; rfl\u27e9\n\n#align pempty PEmpty\n\ntheorem congr_heq {\u03b1 \u03b2 \u03b3 : Sort _} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3} {x : \u03b1} {y : \u03b2}\n    (h\u2081 : HEq f g) (h\u2082 : HEq x y) : f x = g y := by\n  cases h\u2082; cases h\u2081; rfl\n#align congr_heq congr_heq\n\ntheorem congr_arg_heq {\u03b1} {\u03b2 : \u03b1 \u2192 Sort _} (f : \u2200 a, \u03b2 a) :\n    \u2200 {a\u2081 a\u2082 : \u03b1}, a\u2081 = a\u2082 \u2192 HEq (f a\u2081) (f a\u2082)\n  | _, _, rfl => HEq.rfl\n#align congr_arg_heq congr_arg_heq\n\ntheorem ULift.down_injective {\u03b1 : Sort _} : Function.Injective (@ULift.down \u03b1)\n  | \u27e8a\u27e9, \u27e8b\u27e9, _ => by congr\n#align ulift.down_injective ULift.down_injective\n\n@[simp] theorem ULift.down_inj {\u03b1 : Sort _} {a b : ULift \u03b1} : a.down = b.down \u2194 a = b :=\n  \u27e8fun h \u21a6 ULift.down_injective h, fun h \u21a6 by rw [h]\u27e9\n#align ulift.down_inj ULift.down_inj\n\ntheorem PLift.down_injective {\u03b1 : Sort _} : Function.Injective (@PLift.down \u03b1)\n  | \u27e8a\u27e9, \u27e8b\u27e9, _ => by congr\n#align plift.down_injective PLift.down_injective\n\n@[simp] theorem PLift.down_inj {\u03b1 : Sort _} {a b : PLift \u03b1} : a.down = b.down \u2194 a = b :=\n  \u27e8fun h \u21a6 PLift.down_injective h, fun h \u21a6 by rw [h]\u27e9\n#align plift.down_inj PLift.down_inj\n\n@[simp] theorem eq_iff_eq_cancel_left {b c : \u03b1} : (\u2200 {a}, a = b \u2194 a = c) \u2194 b = c :=\n  \u27e8fun h \u21a6 by rw [\u2190 h], fun h a \u21a6 by rw [h]\u27e9\n#align eq_iff_eq_cancel_left eq_iff_eq_cancel_left\n\n@[simp] theorem eq_iff_eq_cancel_right {a b : \u03b1} : (\u2200 {c}, a = c \u2194 b = c) \u2194 a = b :=\n  \u27e8fun h \u21a6 by rw [h], fun h a \u21a6 by rw [h]\u27e9\n#align eq_iff_eq_cancel_right eq_iff_eq_cancel_right\n\nlemma ne_and_eq_iff_right {\u03b1 : Sort _} {a b c : \u03b1} (h : b \u2260 c) : a \u2260 b \u2227 a = c \u2194 a = c :=\n  and_iff_right_of_imp (fun h2 => h2.symm \u25b8 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 \u2194 p := \u27e8fun h \u21a6 h.1, fun h \u21a6 \u27e8h\u27e9\u27e9\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\u2082 {\u03ba\u2081 : \u03b9\u2081 \u2192 Sort _} {\u03ba\u2082 : \u03b9\u2082 \u2192 Sort _}\n    {\u03c6 : \u2200 i\u2081, \u03ba\u2081 i\u2081 \u2192 \u2200 i\u2082, \u03ba\u2082 i\u2082 \u2192 Sort _} (f : \u2200 i\u2081 j\u2081 i\u2082 j\u2082, \u03c6 i\u2081 j\u2081 i\u2082 j\u2082)\n    (i\u2082 j\u2082 i\u2081 j\u2081) : \u03c6 i\u2081 j\u2081 i\u2082 j\u2082 := f i\u2081 j\u2081 i\u2082 j\u2082\n#align function.swap\u2082 Function.swap\u2082\n\n-- Porting note: these don't work as intended any more\n-- /-- If `x : \u03b1 . tac_name` then `x.out : \u03b1`. 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 {\u03b1 : Sort _} {n : Name} (x : autoParam' \u03b1 n) : \u03b1 := x\n\n-- /-- If `x : \u03b1 := d` then `x.out : \u03b1`. 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 {\u03b1 : Sort _} {d : \u03b1} (x : \u03b1 := d) : \u03b1 := 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 := \u27e8Iff.refl\u27e9\n\ninstance : IsTrans Prop Iff := \u27e8fun _ _ _ \u21a6 Iff.trans\u27e9\n\nalias imp_congr \u2190 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\u2093 -- reorder implicits\n#align imp_iff_not imp_iff_not\u2093 -- reorder implicits\n\n@[simp] theorem imp_iff_right_iff : (a \u2192 b \u2194 b) \u2194 a \u2228 b := Decidable.imp_iff_right_iff\n#align imp_iff_right_iff imp_iff_right_iff\n\n@[simp] theorem and_or_imp : a \u2227 b \u2228 (a \u2192 c) \u2194 a \u2192 b \u2228 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 \u2192 b) \u2192 \u00acb \u2192 \u00aca := mt\n#align function.mt Function.mt\n\n/-! ### Declarations about `not` -/\n\nalias Decidable.em \u2190 dec_em\n#align dec_em dec_em\n\ntheorem dec_em' (p : Prop) [Decidable p] : \u00acp \u2228 p := (dec_em p).symm\n#align dec_em' dec_em'\n\nalias Classical.em \u2190 em\n#align em em\n\ntheorem em' (p : Prop) : \u00acp \u2228 p := (em p).symm\n#align em' em'\n\ntheorem or_not {p : Prop} : p \u2228 \u00acp := em _\n#align or_not or_not\n\ntheorem Decidable.eq_or_ne (x y : \u03b1) [Decidable (x = y)] : x = y \u2228 x \u2260 y := dec_em <| x = y\n#align decidable.eq_or_ne Decidable.eq_or_ne\n\ntheorem Decidable.ne_or_eq (x y : \u03b1) [Decidable (x = y)] : x \u2260 y \u2228 x = y := dec_em' <| x = y\n#align decidable.ne_or_eq Decidable.ne_or_eq\n\ntheorem eq_or_ne (x y : \u03b1) : x = y \u2228 x \u2260 y := em <| x = y\n#align eq_or_ne eq_or_ne\n\ntheorem ne_or_eq (x y : \u03b1) : x \u2260 y \u2228 x = y := em' <| x = y\n#align ne_or_eq ne_or_eq\n\ntheorem by_contradiction : (\u00acp \u2192 False) \u2192 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 \u2192 q) (hnpq : \u00acp \u2192 q) : q :=\nif hp : p then hpq hp else hnpq hp\n#align classical.by_cases by_cases\n\nalias by_contradiction \u2190 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 : \u00ac\u00aca \u2192 a := by_contra\n#align of_not_not of_not_not\n\ntheorem not_ne_iff : \u00aca \u2260 b \u2194 a = b := not_not\n#align not_ne_iff not_ne_iff\n\ntheorem of_not_imp {a b : Prop} : \u00ac(a \u2192 b) \u2192 a := Decidable.of_not_imp\n#align of_not_imp of_not_imp\n\nalias Decidable.not_imp_symm \u2190 Not.decidable_imp_symm\n#align not.decidable_imp_symm Not.decidable_imp_symm\n\ntheorem Not.imp_symm : (\u00aca \u2192 b) \u2192 \u00acb \u2192 a := Not.decidable_imp_symm\n#align not.imp_symm Not.imp_symm\n\ntheorem not_imp_comm : \u00aca \u2192 b \u2194 \u00acb \u2192 a := Decidable.not_imp_comm\n#align not_imp_comm not_imp_comm\n\n@[simp] theorem not_imp_self : \u00aca \u2192 a \u2194 a := Decidable.not_imp_self\n#align not_imp_self not_imp_self\n\ntheorem Imp.swap : a \u2192 b \u2192 c \u2194 b \u2192 a \u2192 c := \u27e8Function.swap, Function.swap\u27e9\n#align imp.swap Imp.swap\n\nalias not_congr \u2190 Iff.not\ntheorem Iff.not_left (h : a \u2194 \u00acb) : \u00aca \u2194 b := h.not.trans not_not\ntheorem Iff.not_right (h : \u00aca \u2194 b) : a \u2194 \u00acb := 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' := \u27e8xor_comm\u27e9\n\n@[simp] theorem xor_self (a : Prop) : Xor' a a = False := by simp [Xor']\n@[simp] theorem xor_not_left : Xor' (\u00aca) b \u2194 (a \u2194 b) := by by_cases a <;> simp [*]\n@[simp] theorem xor_not_right : Xor' a (\u00acb) \u2194 (a \u2194 b) := by by_cases a <;> simp [*]\ntheorem xor_not_not : Xor' (\u00aca) (\u00acb) \u2194 Xor' a b := by simp [Xor', or_comm, and_comm]\nprotected theorem Xor'.or (h : Xor' a b) : a \u2228 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 \u2190 Iff.and\n#align and_congr_left and_congr_left\u2093 -- reorder implicits\n#align and_congr_right' and_congr_right'\u2093 -- 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 \u2194 And.rotate _\n#align and.congr_right_iff and_congr_right_iff\n#align and.congr_left_iff and_congr_left_iff\u2093 -- reorder implicits\n#align and.rotate And.rotate\n#align iff.and Iff.and\n\ntheorem and_symm_right (a b : \u03b1) (p : Prop) : p \u2227 a = b \u2194 p \u2227 b = a := by simp [eq_comm]\ntheorem and_symm_left (a b : \u03b1) (p : Prop) : a = b \u2227 p \u2194 b = a \u2227 p := by simp [eq_comm]\n\n/-! ### Declarations about `or` -/\n\nalias or_congr \u2190 Iff.or\n#align or_congr_left' or_congr_left\n#align or_congr_right' or_congr_right\u2093 -- reorder implicits\n#align or.right_comm or_right_comm\nalias or_rotate \u2194 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\u2081 : a \u2228 b) (h\u2082 : a \u2192 c) (h\u2083 : b \u2192 d) : c \u2228 d := Or.imp h\u2082 h\u2083 h\u2081\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\u2081 : a \u2228 c) (h : a \u2192 b) : b \u2228 c := Or.imp_left h h\u2081\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\u2081 : c \u2228 a) (h : a \u2192 b) : c \u2228 b := Or.imp_right h h\u2081\n#align or_of_or_of_imp_right or_of_or_of_imp_right\n\ntheorem Or.elim3 {d : Prop} (h : a \u2228 b \u2228 c) (ha : a \u2192 d) (hb : b \u2192 d) (hc : c \u2192 d) : d :=\n  Or.elim h ha fun h\u2082 \u21a6 Or.elim h\u2082 hb hc\n#align or.elim3 Or.elim3\n\ntheorem Or.imp3 (had : a \u2192 d) (hbe : b \u2192 e) (hcf : c \u2192 f) : a \u2228 b \u2228 c \u2192 d \u2228 e \u2228 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 \u2228 b \u2194 \u00aca \u2192 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 \u2228 b \u2194 \u00acb \u2192 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 \u2192 b) \u2192 \u00aca \u2228 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 \u2192 b) : b \u2228 \u00aca :=\n  dite _ (Or.inl \u2218 h) Or.inr\n#align decidable.or_not_of_imp Decidable.or_not_of_imp\n\ntheorem or_not_of_imp : (a \u2192 b) \u2192 b \u2228 \u00aca := Decidable.or_not_of_imp\n#align or_not_of_imp or_not_of_imp\n\ntheorem imp_iff_not_or : a \u2192 b \u2194 \u00aca \u2228 b := Decidable.imp_iff_not_or\n#align imp_iff_not_or imp_iff_not_or\n\ntheorem imp_iff_or_not : b \u2192 a \u2194 a \u2228 \u00acb := Decidable.imp_iff_or_not\n#align imp_iff_or_not imp_iff_or_not\n\ntheorem not_imp_not : \u00aca \u2192 \u00acb \u2194 b \u2192 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 : (\u00aca \u2192 \u00acb) \u2192 b \u2192 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\u2093 -- reorder implicits\n#align decidable.imp_iff_or_not Decidable.imp_iff_or_not\u2093 -- reorder implicits\n\ntheorem or_congr_left' (h : \u00acc \u2192 (a \u2194 b)) : a \u2228 c \u2194 b \u2228 c := Decidable.or_congr_left' h\n#align or_congr_left or_congr_left'\n\ntheorem or_congr_right' (h : \u00aca \u2192 (b \u2194 c)) : a \u2228 b \u2194 a \u2228 c := Decidable.or_congr_right' h\n#align or_congr_right or_congr_right'\u2093 -- reorder implicits\n\n#align or_iff_left or_iff_left\u2093 -- 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 \u2190 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 \u2192 b \u2228 c \u2194 (a \u2192 b) \u2228 (a \u2192 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 \u2192 b \u2228 c \u2194 (a \u2192 b) \u2228 (a \u2192 c) := Decidable.imp_or'\n#align imp_or_distrib' imp_or'\u2093 -- universes\n\ntheorem not_imp : \u00ac(a \u2192 b) \u2194 a \u2227 \u00acb := Decidable.not_imp\n#align not_imp not_imp\n\ntheorem peirce (a b : Prop) : ((a \u2192 b) \u2192 a) \u2192 a := Decidable.peirce _ _\n#align peirce peirce\n\ntheorem not_iff_not : (\u00aca \u2194 \u00acb) \u2194 (a \u2194 b) := Decidable.not_iff_not\n#align not_iff_not not_iff_not\n\ntheorem not_iff_comm : (\u00aca \u2194 b) \u2194 (\u00acb \u2194 a) := Decidable.not_iff_comm\n#align not_iff_comm not_iff_comm\n\ntheorem not_iff : \u00ac(a \u2194 b) \u2194 (\u00aca \u2194 b) := Decidable.not_iff\n#align not_iff not_iff\n\ntheorem iff_not_comm : (a \u2194 \u00acb) \u2194 (b \u2194 \u00aca) := Decidable.iff_not_comm\n#align iff_not_comm iff_not_comm\n\ntheorem iff_iff_and_or_not_and_not : (a \u2194 b) \u2194 a \u2227 b \u2228 \u00aca \u2227 \u00acb :=\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 \u2194 b) \u2194 (\u00aca \u2228 b) \u2227 (a \u2228 \u00acb) :=\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 : \u00ac(a \u2227 \u00acb) \u2194 a \u2192 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 : \u00ac(a \u2227 b) \u2194 \u00aca \u2228 \u00acb := 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 \u2228 b \u2194 \u00ac(\u00aca \u2227 \u00acb) := 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 \u2227 b \u2194 \u00ac(\u00aca \u2228 \u00acb) := 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) : \u00acXor' P Q \u2194 (P \u2194 Q) := by\n  simp only [not_and, Xor', not_or, not_not, \u2190 iff_iff_implies_and_implies]\n#align not_xor not_xor\n\ntheorem xor_iff_not_iff (P Q : Prop) : Xor' P Q \u2194 \u00ac (P \u2194 Q) := (not_xor P Q).not_right\ntheorem xor_iff_iff_not : Xor' a b \u2194 (a \u2194 \u00acb) := by simp only [\u2190 @xor_not_right a, not_not]\ntheorem xor_iff_not_iff' : Xor' a b \u2194 (\u00aca \u2194 b) := by simp only [\u2190 @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 \u2190 Membership.mem.ne_of_not_mem\nalias ne_of_mem_of_not_mem' \u2190 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 {\u03b1} {s : \u03b1 \u2192 Prop} {p : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n    (\u2200 a, s a \u2192 \u2200 b, s b \u2192 p a b) \u2194 \u2200 a b, s a \u2192 s b \u2192 p a b :=\n  \u27e8fun h a b ha hb \u21a6 h a ha b hb, fun h a ha b hb \u21a6 h a b ha hb\u27e9\n#align ball_cond_comm ball_cond_comm\n\ntheorem ball_mem_comm {\u03b1 \u03b2} [Membership \u03b1 \u03b2] {s : \u03b2} {p : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n    (\u2200 a (_ : a \u2208 s) b (_ : b \u2208 s), p a b) \u2194 \u2200 a b, a \u2208 s \u2192 b \u2208 s \u2192 p a b :=\n  ball_cond_comm\n#align ball_mem_comm ball_mem_comm\n\ntheorem ne_of_apply_ne {\u03b1 \u03b2 : Sort _} (f : \u03b1 \u2192 \u03b2) {x y : \u03b1} (h : f x \u2260 f y) : x \u2260 y :=\n  fun w : x = y \u21a6 h (congr_arg f w)\n#align ne_of_apply_ne ne_of_apply_ne\n\ntheorem eq_equivalence : Equivalence (@Eq \u03b1) :=\n  \u27e8Eq.refl, @Eq.symm _, @Eq.trans _\u27e9\n#align eq_equivalence eq_equivalence\n\n@[simp] theorem eq_mp_eq_cast (h : \u03b1 = \u03b2) : 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 : \u03b1 = \u03b2) : Eq.mpr h = cast h.symm := rfl\n#align eq_mpr_eq_cast eq_mpr_eq_cast\n\n@[simp] theorem cast_cast : \u2200 (ha : \u03b1 = \u03b2) (hb : \u03b2 = \u03b3) (a : \u03b1),\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 : \u03b1 \u2192 \u03b2) {a b : \u03b1} (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 : \u03b1 \u2192 \u03b2} (h : f = g) (a : \u03b1) :\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 : \u03b1 \u2192 \u03b2) (a : \u03b1) : 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 : \u03b1 \u2192 \u03b2) (a : \u03b1) : 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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) {a a' : \u03b1} (p : a = a') (b : \u03b2) :\n    congr_fun (congr_arg f p) b = congr_arg (fun a \u21a6 f a b) p := rfl\n#align congr_fun_congr_arg congr_fun_congr_arg\n\ntheorem heq_of_cast_eq : \u2200 (e : \u03b1 = \u03b2) (_ : 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' \u2194 HEq a a' :=\n  \u27e8heq_of_cast_eq _, fun h \u21a6 by cases h; rfl\u27e9\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' {\u03b1 : Sort u_1} {a' : \u03b1} {motive : (a : \u03b1) \u2192 a' = a \u2192 Sort u}\n    (p : motive a' (rfl : a' = a')) {a : \u03b1} (t : a' = a) :\n    HEq (@Eq.rec \u03b1 a' motive p a t) p :=\n  by subst t; rfl\n\ntheorem rec_heq_of_heq {C : \u03b1 \u2192 Sort _} {x : C a} {y : \u03b2} (e : a = b) (h : HEq x y) :\n    HEq (e \u25b8 x) y := by subst e; exact h\n#align rec_heq_of_heq rec_heq_of_heq\n\ntheorem rec_heq_iff_heq {C : \u03b1 \u2192 Sort _} {x : C a} {y : \u03b2} {e : a = b} :\n    HEq (e \u25b8 x) y \u2194 HEq x y := by subst e; rfl\n#align rec_heq_iff_heq rec_heq_iff_heq\n\ntheorem heq_rec_iff_heq {C : \u03b1 \u2192 Sort _} {x : \u03b2} {y : C a} {e : a = b} :\n    HEq x (e \u25b8 y) \u2194 HEq x y := by subst e; rfl\n#align heq_rec_iff_heq heq_rec_iff_heq\n\nprotected theorem Eq.congr (h\u2081 : x\u2081 = y\u2081) (h\u2082 : x\u2082 = y\u2082) : x\u2081 = x\u2082 \u2194 y\u2081 = y\u2082 := by\n  subst h\u2081; subst h\u2082; rfl\n#align eq.congr Eq.congr\n\ntheorem Eq.congr_left {x y z : \u03b1} (h : x = y) : x = z \u2194 y = z := by rw [h]\n#align eq.congr_left Eq.congr_left\n\ntheorem Eq.congr_right {x y z : \u03b1} (h : x = y) : z = x \u2194 z = y := by rw [h]\n#align eq.congr_right Eq.congr_right\n\nalias congrArg\u2082 \u2190 congr_arg\u2082\n#align congr_arg2 congr_arg\u2082\n\nvariable {\u03b2 : \u03b1 \u2192 Sort _} {\u03b3 : \u2200 a, \u03b2 a \u2192 Sort _} {\u03b4 : \u2200 a b, \u03b3 a b \u2192 Sort _}\n\ntheorem congr_fun\u2082 {f g : \u2200 a b, \u03b3 a b} (h : f = g) (a : \u03b1) (b : \u03b2 a) : f a b = g a b :=\n  congr_fun (congr_fun h _) _\n#align congr_fun\u2082 congr_fun\u2082\n\ntheorem congr_fun\u2083 {f g : \u2200 a b c, \u03b4 a b c} (h : f = g) (a : \u03b1) (b : \u03b2 a) (c : \u03b3 a b) :\n    f a b c = g a b c :=\n  congr_fun\u2082 (congr_fun h _) _ _\n#align congr_fun\u2083 congr_fun\u2083\n\ntheorem funext\u2082 {f g : \u2200 a b, \u03b3 a b} (h : \u2200 a b, f a b = g a b) : f = g :=\n  funext fun _ \u21a6 funext <| h _\n#align funext\u2082 funext\u2082\n\ntheorem funext\u2083 {f g : \u2200 a b c, \u03b4 a b c} (h : \u2200 a b c, f a b c = g a b c) : f = g :=\n  funext fun _ \u21a6 funext\u2082 <| h _\n#align funext\u2083 funext\u2083\n\nend Equality\n\n/-! ### Declarations about quantifiers -/\n\n\nsection Quantifiers\nsection Dependent\n\nvariable {\u03b2 : \u03b1 \u2192 Sort _} {\u03b3 : \u2200 a, \u03b2 a \u2192 Sort _} {\u03b4 : \u2200 a b, \u03b3 a b \u2192 Sort _}\n  {\u03b5 : \u2200 a b c, \u03b4 a b c \u2192 Sort _}\n\ntheorem pi_congr {\u03b2' : \u03b1 \u2192 Sort _} (h : \u2200 a, \u03b2 a = \u03b2' a) : (\u2200 a, \u03b2 a) = \u2200 a, \u03b2' a :=\n  (funext h : \u03b2 = \u03b2') \u25b8 rfl\n#align pi_congr pi_congr\n\n-- Porting note: some higher order lemmas such as `forall\u2082_congr` and `exists\u2082_congr`\n-- were moved to `Std4`\n\ntheorem forall\u2082_imp {p q : \u2200 a, \u03b2 a \u2192 Prop} (h : \u2200 a b, p a b \u2192 q a b) :\n    (\u2200 a b, p a b) \u2192 \u2200 a b, q a b :=\n  forall_imp fun i \u21a6 forall_imp <| h i\n#align forall\u2082_imp forall\u2082_imp\n\ntheorem forall\u2083_imp {p q : \u2200 a b, \u03b3 a b \u2192 Prop} (h : \u2200 a b c, p a b c \u2192 q a b c) :\n    (\u2200 a b c, p a b c) \u2192 \u2200 a b c, q a b c :=\n  forall_imp fun a \u21a6 forall\u2082_imp <| h a\n#align forall\u2083_imp forall\u2083_imp\n\ntheorem Exists\u2082.imp {p q : \u2200 a, \u03b2 a \u2192 Prop} (h : \u2200 a b, p a b \u2192 q a b) :\n    (\u2203 a b, p a b) \u2192 \u2203 a b, q a b :=\n  Exists.imp fun a \u21a6 Exists.imp <| h a\n#align Exists\u2082.imp Exists\u2082.imp\n\ntheorem Exists\u2083.imp {p q : \u2200 a b, \u03b3 a b \u2192 Prop} (h : \u2200 a b c, p a b c \u2192 q a b c) :\n    (\u2203 a b c, p a b c) \u2192 \u2203 a b c, q a b c :=\n  Exists.imp fun a \u21a6 Exists\u2082.imp <| h a\n#align Exists\u2083.imp Exists\u2083.imp\n\nend Dependent\n\nvariable {\u03ba : \u03b9 \u2192 Sort _} {p q : \u03b1 \u2192 Prop}\n\n#align exists_imp_exists' Exists.imp'\n\ntheorem forall_swap {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2200 x y, p x y) \u2194 \u2200 y x, p x y := \u27e8swap, swap\u27e9\n#align forall_swap forall_swap\n\ntheorem forall\u2082_swap {\u03ba\u2081 : \u03b9\u2081 \u2192 Sort _} {\u03ba\u2082 : \u03b9\u2082 \u2192 Sort _} {p : \u2200 i\u2081, \u03ba\u2081 i\u2081 \u2192 \u2200 i\u2082, \u03ba\u2082 i\u2082 \u2192 Prop} :\n    (\u2200 i\u2081 j\u2081 i\u2082 j\u2082, p i\u2081 j\u2081 i\u2082 j\u2082) \u2194 \u2200 i\u2082 j\u2082 i\u2081 j\u2081, p i\u2081 j\u2081 i\u2082 j\u2082 := \u27e8swap\u2082, swap\u2082\u27e9\n#align forall\u2082_swap forall\u2082_swap\n\n/-- We intentionally restrict the type of `\u03b1` in this lemma so that this is a safer to use in simp\nthan `forall_swap`. -/\ntheorem imp_forall_iff {\u03b1 : Type _} {p : Prop} {q : \u03b1 \u2192 Prop} : (p \u2192 \u2200 x, q x) \u2194 \u2200 x, p \u2192 q x :=\n  forall_swap\n#align imp_forall_iff imp_forall_iff\n\ntheorem exists_swap {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2203 x y, p x y) \u2194 \u2203 y x, p x y :=\n  \u27e8fun \u27e8x, y, h\u27e9 \u21a6 \u27e8y, x, h\u27e9, fun \u27e8y, x, h\u27e9 \u21a6 \u27e8x, y, h\u27e9\u27e9\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 \u2194 _ 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 : \u03b1 \u2192 Prop} [Decidable (\u2203 x, \u00acp x)]\n    [\u2200 x, Decidable (p x)] : (\u00ac\u2200 x, p x) \u2194 \u2203 x, \u00acp x :=\n  \u27e8Not.decidable_imp_symm fun nx x \u21a6 nx.decidable_imp_symm fun h \u21a6 \u27e8x, h\u27e9,\n   not_forall_of_exists_not\u27e9\n#align decidable.not_forall Decidable.not_forall\n\n@[simp]\ntheorem not_forall {p : \u03b1 \u2192 Prop} : (\u00ac\u2200 x, p x) \u2194 \u2203 x, \u00acp x :=\n  Decidable.not_forall\n#align not_forall not_forall\n\n-- See Note [decidable namespace]\nprotected theorem Decidable.not_forall_not [Decidable (\u2203 x, p x)] : (\u00ac\u2200 x, \u00acp x) \u2194 \u2203 x, p x :=\n  (@Decidable.not_iff_comm _ _ _ (decidable_of_iff (\u00ac\u2203 x, p x) not_exists)).1 not_exists\n#align decidable.not_forall_not Decidable.not_forall_not\n\ntheorem not_forall_not : (\u00ac\u2200 x, \u00acp x) \u2194 \u2203 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 [\u2200 x, Decidable (p x)] : (\u00ac\u2203 x, \u00acp x) \u2194 \u2200 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 : (\u00ac\u2203 x, \u00acp x) \u2194 \u2200 x, p x := Decidable.not_exists_not\n#align not_exists_not not_exists_not\n\ntheorem forall_imp_iff_exists_imp [ha : Nonempty \u03b1] : (\u2200 x, p x) \u2192 b \u2194 \u2203 x, p x \u2192 b := by\n  let \u27e8a\u27e9 := ha\n  refine \u27e8fun h \u21a6 not_forall_not.1 fun h' \u21a6 ?_, fun \u27e8x, hx\u27e9 h \u21a6 hx (h x)\u27e9\n  exact if hb : b then h' a fun _ \u21a6 hb else hb <| h fun x \u21a6 (not_imp.1 (h' x)).1\n#align forall_imp_iff_exists_imp forall_imp_iff_exists_imp\n\ntheorem forall_true_iff : (\u03b1 \u2192 True) \u2194 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 : \u2200 a, p a \u2194 True) : (\u2200 a, p a) \u2194 True :=\n  iff_true_intro fun _ \u21a6 of_iff_true (h _)\n#align forall_true_iff' forall_true_iff'\n\n-- This is not marked `@[simp]` because `implies_true : (\u03b1 \u2192 True) = True` works\ntheorem forall\u2082_true_iff {\u03b2 : \u03b1 \u2192 Sort _} : (\u2200 a, \u03b2 a \u2192 True) \u2194 True := by simp\n#align forall_2_true_iff forall\u2082_true_iff\n\n-- This is not marked `@[simp]` because `implies_true : (\u03b1 \u2192 True) = True` works\ntheorem forall\u2083_true_iff {\u03b2 : \u03b1 \u2192 Sort _} {\u03b3 : \u2200 a, \u03b2 a \u2192 Sort _} :\n    (\u2200 (a) (b : \u03b2 a), \u03b3 a b \u2192 True) \u2194 True := by simp\n#align forall_3_true_iff forall\u2083_true_iff\n\n@[simp] theorem exists_unique_iff_exists [Subsingleton \u03b1] {p : \u03b1 \u2192 Prop} :\n    (\u2203! x, p x) \u2194 \u2203 x, p x :=\n  \u27e8fun h \u21a6 h.exists, Exists.imp fun x hx \u21a6 \u27e8hx, fun y _ \u21a6 Subsingleton.elim y x\u27e9\u27e9\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 (\u03b1) [i : Nonempty \u03b1] : (\u2203 _ : \u03b1, b) \u2194 b :=\n  \u27e8fun \u27e8_, h\u27e9 \u21a6 h, i.elim Exists.intro\u27e9\n#align exists_const exists_const\n\ntheorem exists_unique_const (\u03b1) [i : Nonempty \u03b1] [Subsingleton \u03b1] :\n    (\u2203! _ : \u03b1, b) \u2194 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 \u03b1] (a : \u03b1) {p : \u03b1 \u2192 Prop} :\n    (p a \u2227 \u2200 b, b \u2260 a \u2192 p b) \u2194 \u2200 b, p b := by\n  simp only [\u2190 @forall_eq _ p a, \u2190 forall_and, \u2190 or_imp, Decidable.em, forall_const]\n#align decidable.and_forall_ne Decidable.and_forall_ne\n\ntheorem and_forall_ne (a : \u03b1) : (p a \u2227 \u2200 b, b \u2260 a \u2192 p b) \u2194 \u2200 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 : \u03b1} (z : \u03b1) (h : x \u2260 y) : x \u2260 z \u2228 y \u2260 z :=\n  not_and_or.1 <| mt (and_imp.2 (\u00b7 \u25b8 \u00b7)) h.symm\n#align ne.ne_or_ne Ne.ne_or_ne\n\n@[simp] theorem exists_unique_eq {a' : \u03b1} : \u2203! 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' : \u03b1} : \u2203! 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 : \u03b1 \u2192 \u03b2) (a' : \u03b1) : \u2203 a, f a' = f a := \u27e8a', rfl\u27e9\n#align exists_apply_eq_apply' exists_apply_eq_apply'\n\n-- porting note: an alternative workaround theorem:\ntheorem exists_apply_eq (a : \u03b1) (b : \u03b2) : \u2203 f : \u03b1 \u2192 \u03b2, f a = b := \u27e8fun _ \u21a6 b, rfl\u27e9\n\n@[simp] theorem exists_exists_and_eq_and {f : \u03b1 \u2192 \u03b2} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} :\n    (\u2203 b, (\u2203 a, p a \u2227 f a = b) \u2227 q b) \u2194 \u2203 a, p a \u2227 q (f a) :=\n  \u27e8fun \u27e8_, \u27e8a, ha, hab\u27e9, hb\u27e9 \u21a6 \u27e8a, ha, hab.symm \u25b8 hb\u27e9, fun \u27e8a, hp, hq\u27e9 \u21a6 \u27e8f a, \u27e8a, hp, rfl\u27e9, hq\u27e9\u27e9\n#align exists_exists_and_eq_and exists_exists_and_eq_and\n\n@[simp] theorem exists_exists_eq_and {f : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} :\n    (\u2203 b, (\u2203 a, f a = b) \u2227 p b) \u2194 \u2203 a, p (f a) :=\n  \u27e8fun \u27e8_, \u27e8a, ha\u27e9, hb\u27e9 \u21a6 \u27e8a, ha.symm \u25b8 hb\u27e9, fun \u27e8a, ha\u27e9 \u21a6 \u27e8f a, \u27e8a, rfl\u27e9, ha\u27e9\u27e9\n#align exists_exists_eq_and exists_exists_eq_and\n\n@[simp] theorem exists_or_eq_left (y : \u03b1) (p : \u03b1 \u2192 Prop) : \u2203 x : \u03b1, x = y \u2228 p x := \u27e8y, .inl rfl\u27e9\n#align exists_or_eq_left exists_or_eq_left\n\n@[simp] theorem exists_or_eq_right (y : \u03b1) (p : \u03b1 \u2192 Prop) : \u2203 x : \u03b1, p x \u2228 x = y := \u27e8y, .inr rfl\u27e9\n#align exists_or_eq_right exists_or_eq_right\n\n@[simp] theorem exists_or_eq_left' (y : \u03b1) (p : \u03b1 \u2192 Prop) : \u2203 x : \u03b1, y = x \u2228 p x := \u27e8y, .inl rfl\u27e9\n#align exists_or_eq_left' exists_or_eq_left'\n\n@[simp] theorem exists_or_eq_right' (y : \u03b1) (p : \u03b1 \u2192 Prop) : \u2203 x : \u03b1, p x \u2228 y = x := \u27e8y, .inr rfl\u27e9\n#align exists_or_eq_right' exists_or_eq_right'\n\ntheorem forall_apply_eq_imp_iff {f : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} :\n    (\u2200 a b, f a = b \u2192 p b) \u2194 \u2200 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 : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} :\n    (\u2200 b a, f a = b \u2192 p b) \u2194 \u2200 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 : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} :\n    (\u2200 a b, b = f a \u2192 p b) \u2194 \u2200 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 : \u03b1 \u2192 \u03b2} {p : \u03b2 \u2192 Prop} :\n    (\u2200 b a, b = f a \u2192 p b) \u2194 \u2200 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\u2082 {f : \u03b1 \u2192 \u03b2} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} :\n    (\u2200 b a, p a \u2192 f a = b \u2192 q b) \u2194 \u2200 a, p a \u2192 q (f a) :=\n  \u27e8fun h a ha \u21a6 h (f a) a ha rfl, fun h _ a ha hb \u21a6 hb \u25b8 h a ha\u27e9\n#align forall_apply_eq_imp_iff\u2082 forall_apply_eq_imp_iff\u2082\n\n@[simp] theorem exists_eq_right' {a' : \u03b1} : (\u2203 a, p a \u2227 a' = a) \u2194 p a' := by simp [@eq_comm _ a']\n#align exists_eq_right' exists_eq_right'\n\ntheorem exists_comm {p : \u03b1 \u2192 \u03b2 \u2192 Prop} : (\u2203 a b, p a b) \u2194 \u2203 b a, p a b :=\n  \u27e8fun \u27e8a, b, h\u27e9 \u21a6 \u27e8b, a, h\u27e9, fun \u27e8b, a, h\u27e9 \u21a6 \u27e8a, b, h\u27e9\u27e9\n#align exists_comm exists_comm\n\ntheorem exists\u2082_comm {\u03ba\u2081 : \u03b9\u2081 \u2192 Sort _} {\u03ba\u2082 : \u03b9\u2082 \u2192 Sort _} {p : \u2200 i\u2081, \u03ba\u2081 i\u2081 \u2192 \u2200 i\u2082, \u03ba\u2082 i\u2082 \u2192 Prop} :\n    (\u2203 i\u2081 j\u2081 i\u2082 j\u2082, p i\u2081 j\u2081 i\u2082 j\u2082) \u2194 \u2203 i\u2082 j\u2082 i\u2081 j\u2081, p i\u2081 j\u2081 i\u2082 j\u2082 := by\n  simp only [@exists_comm (\u03ba\u2081 _), @exists_comm \u03b9\u2081]\n#align exists\u2082_comm exists\u2082_comm\n\ntheorem And.exists {p q : Prop} {f : p \u2227 q \u2192 Prop} : (\u2203 h, f h) \u2194 \u2203 hp hq, f \u27e8hp, hq\u27e9 :=\n  \u27e8fun \u27e8h, H\u27e9 \u21a6 \u27e8h.1, h.2, H\u27e9, fun \u27e8hp, hq, H\u27e9 \u21a6 \u27e8\u27e8hp, hq\u27e9, H\u27e9\u27e9\n#align and.exists And.exists\n\ntheorem forall_or_of_or_forall (h : b \u2228 \u2200 x, p x) (x) : b \u2228 p x := h.imp_right fun h\u2082 \u21a6 h\u2082 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 : \u03b1 \u2192 Prop} [Decidable q] :\n    (\u2200 x, q \u2228 p x) \u2194 q \u2228 \u2200 x, p x :=\n  \u27e8fun h \u21a6 if hq : q then Or.inl hq else\n    Or.inr fun x \u21a6 (h x).resolve_left hq, forall_or_of_or_forall\u27e9\n#align decidable.forall_or_distrib_left Decidable.forall_or_left\n\ntheorem forall_or_left {q} {p : \u03b1 \u2192 Prop} : (\u2200 x, q \u2228 p x) \u2194 q \u2228 \u2200 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 : \u03b1 \u2192 Prop} [Decidable q] :\n    (\u2200 x, p x \u2228 q) \u2194 (\u2200 x, p x) \u2228 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 : \u03b1 \u2192 Prop} : (\u2200 x, p x \u2228 q) \u2194 (\u2200 x, p x) \u2228 q :=\n  Decidable.forall_or_right\n#align forall_or_distrib_right forall_or_right\n\ntheorem exists_unique_prop {p q : Prop} : (\u2203! _ : p, q) \u2194 p \u2227 q := by simp\n#align exists_unique_prop exists_unique_prop\n\n@[simp] theorem exists_unique_false : \u00ac\u2203! _ : \u03b1, False := fun \u27e8_, h, _\u27e9 \u21a6 h\n#align exists_unique_false exists_unique_false\n\ntheorem Exists.fst {b : Prop} {p : b \u2192 Prop} : Exists p \u2192 b\n  | \u27e8h, _\u27e9 => h\n#align Exists.fst Exists.fst\n\ntheorem Exists.snd {b : Prop} {p : b \u2192 Prop} : \u2200 h : Exists p, p h.fst\n  | \u27e8_, h\u27e9 => h\n#align Exists.snd Exists.snd\n\ntheorem exists_prop_of_true {p : Prop} {q : p \u2192 Prop} (h : p) : (\u2203 h' : p, q h') \u2194 q h :=\n  @exists_const (q h) p \u27e8h\u27e9\n#align exists_prop_of_true exists_prop_of_true\n\ntheorem exists_iff_of_forall {p : Prop} {q : p \u2192 Prop} (h : \u2200 h, q h) : (\u2203 h, q h) \u2194 p :=\n  \u27e8Exists.fst, fun H \u21a6 \u27e8H, h H\u27e9\u27e9\n#align exists_iff_of_forall exists_iff_of_forall\n\ntheorem exists_unique_prop_of_true {p : Prop} {q : p \u2192 Prop} (h : p) : (\u2203! h' : p, q h') \u2194 q h :=\n  @exists_unique_const (q h) p \u27e8h\u27e9 _\n#align exists_unique_prop_of_true exists_unique_prop_of_true\n\ntheorem forall_prop_of_false {p : Prop} {q : p \u2192 Prop} (hn : \u00acp) : (\u2200 h' : p, q h') \u2194 True :=\n  iff_true_intro fun h \u21a6 hn.elim h\n#align forall_prop_of_false forall_prop_of_false\n\ntheorem exists_prop_of_false {p : Prop} {q : p \u2192 Prop} : \u00acp \u2192 \u00ac\u2203 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 \u2192 Prop} (hq : \u2200 h, q h \u2194 q' h) (hp : p \u2194 p') :\n    Exists q \u2194 \u2203 h : p', q' (hp.2 h) :=\n  \u27e8fun \u27e8_, _\u27e9 \u21a6 \u27e8hp.1 \u2039_\u203a, (hq _).1 \u2039_\u203a\u27e9, fun \u27e8_, _\u27e9 \u21a6 \u27e8_, (hq _).2 \u2039_\u203a\u27e9\u27e9\n#align exists_prop_congr exists_prop_congr\n\n@[congr]\ntheorem exists_prop_congr' {p p' : Prop} {q q' : p \u2192 Prop} (hq : \u2200 h, q h \u2194 q' h) (hp : p \u2194 p') :\n    Exists q = \u2203 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 \u2192 Prop) : (\u2203 x, p x) \u2194 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 \u2192 Prop} (hq : \u2200 h, q h \u2194 q' h) (hp : p \u2194 p') :\n    (\u2200 h, q h) \u2194 \u2200 h : p', q' (hp.2 h) :=\n  \u27e8fun h1 h2 \u21a6 (hq _).1 (h1 (hp.2 h2)), fun h1 h2 \u21a6 (hq _).2 (h1 (hp.1 h2))\u27e9\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 \u2192 Prop} (hq : \u2200 h, q h \u2194 q' h) (hp : p \u2194 p') :\n    (\u2200 h, q h) = \u2200 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 \u2192 Prop) : (\u2200 x, p x) \u2194 p True.intro :=\n  forall_prop_of_true _\n#align forall_true_left forall_true_left\n\ntheorem ExistsUnique.elim\u2082 {\u03b1 : Sort _} {p : \u03b1 \u2192 Sort _} [\u2200 x, Subsingleton (p x)]\n    {q : \u2200 (x) (_ : p x), Prop} {b : Prop} (h\u2082 : \u2203! (x : _) (h : p x), q x h)\n    (h\u2081 : \u2200 (x) (h : p x), q x h \u2192 (\u2200 (y) (hy : p y), q y hy \u2192 y = x) \u2192 b) : b := by\n  simp only [exists_unique_iff_exists] at h\u2082\n  apply h\u2082.elim\n  exact fun x \u27e8hxp, hxq\u27e9 H \u21a6 h\u2081 x hxp hxq fun y hyp hyq \u21a6 H y \u27e8hyp, hyq\u27e9\n#align exists_unique.elim2 ExistsUnique.elim\u2082\n\ntheorem ExistsUnique.intro\u2082 {\u03b1 : Sort _} {p : \u03b1 \u2192 Sort _} [\u2200 x, Subsingleton (p x)]\n    {q : \u2200 (x : \u03b1) (_ : p x), Prop} (w : \u03b1) (hp : p w) (hq : q w hp)\n    (H : \u2200 (y) (hy : p y), q y hy \u2192 y = w) : \u2203! (x : _) (hx : p x), q x hx := by\n  simp only [exists_unique_iff_exists]\n  exact ExistsUnique.intro w \u27e8hp, hq\u27e9 fun y \u27e8hyp, hyq\u27e9 \u21a6 H y hyp hyq\n#align exists_unique.intro2 ExistsUnique.intro\u2082\n\ntheorem ExistsUnique.exists\u2082 {\u03b1 : Sort _} {p : \u03b1 \u2192 Sort _} {q : \u2200 (x : \u03b1) (_ : p x), Prop}\n    (h : \u2203! (x : _) (hx : p x), q x hx) : \u2203 (x : _) (hx : p x), q x hx :=\n  h.exists.imp fun _ hx \u21a6 hx.exists\n#align exists_unique.exists2 ExistsUnique.exists\u2082\n\ntheorem ExistsUnique.unique\u2082 {\u03b1 : Sort _} {p : \u03b1 \u2192 Sort _} [\u2200 x, Subsingleton (p x)]\n    {q : \u2200 (x : \u03b1) (_ : p x), Prop} (h : \u2203! (x : _) (hx : p x), q x hx) {y\u2081 y\u2082 : \u03b1}\n    (hpy\u2081 : p y\u2081) (hqy\u2081 : q y\u2081 hpy\u2081) (hpy\u2082 : p y\u2082) (hqy\u2082 : q y\u2082 hpy\u2082) : y\u2081 = y\u2082 := by\n  simp only [exists_unique_iff_exists] at h\n  exact h.unique \u27e8hpy\u2081, hqy\u2081\u27e9 \u27e8hpy\u2082, hqy\u2082\u27e9\n#align exists_unique.unique2 ExistsUnique.unique\u2082\n\nend Quantifiers\n\n/-! ### Classical lemmas -/\n\nnamespace Classical\nvariable {p : \u03b1 \u2192 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 : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) : DecidableRel p := by infer_instance\n#align classical.dec_rel Classical.decRel\n\n/-- Any type `\u03b1` has decidable equality classically. -/\nnoncomputable def decEq (\u03b1 : Sort u) : DecidableEq \u03b1 := 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 : \u2200 a, p a \u2192 C) : C :=\n  if h : \u2203 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\u2082 {\u03b1 : Sort _} {p : \u03b1 \u2192 Prop} {h : \u2203 a, p a} (q : \u03b1 \u2192 Prop)\n    (hpq : \u2200 a, p a \u2192 q a) : q (choose h) := hpq _ <| choose_spec _\n#align classical.some_spec2 Classical.some_spec\u2082\n\n/-- A version of `Classical.indefiniteDescription` which is definitionally equal to a pair -/\nnoncomputable def subtype_of_exists {\u03b1 : Type _} {P : \u03b1 \u2192 Prop} (h : \u2203 x, P x) : { x // P x } :=\n  \u27e8Classical.choose h, Classical.choose_spec h\u27e9\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' {\u03b1 : Sort _} (H : \u00ac(\u03b1 \u2192 False)) : \u03b1 :=\n  Classical.choice <| (peirce _ False) fun h \u21a6 (H fun a \u21a6 h \u27e8a\u27e9).elim\n#align classical.by_contradiction' Classical.byContradiction'\n\n/-- `classical.byContradiction'` is equivalent to lean's axiom `classical.choice`. -/\ndef choice_of_byContradiction' {\u03b1 : Sort _} (contra : \u00ac(\u03b1 \u2192 False) \u2192 \u03b1) : Nonempty \u03b1 \u2192 \u03b1 :=\n  fun H \u21a6 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 : \u03b1 \u2192 Prop} (h : \u2203 a, p a) {C} (H : \u2200 a, p a \u2192 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 : \u03b1 \u2192 Prop} {P Q : \u2200 x, p x \u2192 Prop} {b : Prop}\n\ntheorem bex_def : (\u2203 (x : _) (_ : p x), q x) \u2194 \u2203 x, p x \u2227 q x :=\n  \u27e8fun \u27e8x, px, qx\u27e9 \u21a6 \u27e8x, px, qx\u27e9, fun \u27e8x, px, qx\u27e9 \u21a6 \u27e8x, px, qx\u27e9\u27e9\n#align bex_def bex_def\n\ntheorem BEx.elim {b : Prop} : (\u2203 x h, P x h) \u2192 (\u2200 a h, P a h \u2192 b) \u2192 b\n  | \u27e8a, h\u2081, h\u2082\u27e9, h' => h' a h\u2081 h\u2082\n#align bex.elim BEx.elim\n\ntheorem BEx.intro (a : \u03b1) (h\u2081 : p a) (h\u2082 : P a h\u2081) : \u2203 (x : _) (h : p x), P x h :=\n  \u27e8a, h\u2081, h\u2082\u27e9\n#align bex.intro BEx.intro\n\ntheorem ball_congr (H : \u2200 x h, P x h \u2194 Q x h) : (\u2200 x h, P x h) \u2194 \u2200 x h, Q x h :=\n  forall_congr' fun x \u21a6 forall_congr' (H x)\n#align ball_congr ball_congr\n\ntheorem bex_congr (H : \u2200 x h, P x h \u2194 Q x h) : (\u2203 x h, P x h) \u2194 \u2203 x h, Q x h :=\n  exists_congr fun x \u21a6 exists_congr (H x)\n#align bex_congr bex_congr\n\ntheorem bex_eq_left {a : \u03b1} : (\u2203 (x : _) (_ : x = a), p x) \u2194 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 : \u2200 x h, P x h \u2192 Q x h) (h\u2081 : \u2200 x h, P x h) (x h) : Q x h :=\n  H _ _ <| h\u2081 _ _\n#align ball.imp_right BAll.imp_right\n\ntheorem BEx.imp_right (H : \u2200 x h, P x h \u2192 Q x h) : (\u2203 x h, P x h) \u2192 \u2203 x h, Q x h\n  | \u27e8_, _, h'\u27e9 => \u27e8_, _, H _ _ h'\u27e9\n#align bex.imp_right BEx.imp_right\n\ntheorem BAll.imp_left (H : \u2200 x, p x \u2192 q x) (h\u2081 : \u2200 x, q x \u2192 r x) (x) (h : p x) : r x :=\n  h\u2081 _ <| H _ h\n#align ball.imp_left BAll.imp_left\n\ntheorem BEx.imp_left (H : \u2200 x, p x \u2192 q x) : (\u2203 (x : _) (_ : p x), r x) \u2192 \u2203 (x : _) (_ : q x), r x\n  | \u27e8x, hp, hr\u27e9 => \u27e8x, H _ hp, hr\u27e9\n#align bex.imp_left BEx.imp_left\n\ntheorem ball_of_forall (h : \u2200 x, p x) (x) : p x := h x\n#align ball_of_forall ball_of_forall\n\ntheorem forall_of_ball (H : \u2200 x, p x) (h : \u2200 x, p x \u2192 q x) (x) : q x := h x <| H x\n#align forall_of_ball forall_of_ball\n\ntheorem bex_of_exists (H : \u2200 x, p x) : (\u2203 x, q x) \u2192 \u2203 (x : _) (_ : p x), q x\n  | \u27e8x, hq\u27e9 => \u27e8x, H x, hq\u27e9\n#align bex_of_exists bex_of_exists\n\ntheorem exists_of_bex : (\u2203 (x : _) (_ : p x), q x) \u2192 \u2203 x, q x\n  | \u27e8x, _, hq\u27e9 => \u27e8x, hq\u27e9\n#align exists_of_bex exists_of_bex\n\ntheorem bex_imp : (\u2203 x h, P x h) \u2192 b \u2194 \u2200 x h, P x h \u2192 b := by simp\n#align bex_imp_distrib bex_imp\n\ntheorem not_bex : (\u00ac\u2203 x h, P x h) \u2194 \u2200 x h, \u00acP x h := bex_imp\n#align not_bex not_bex\n\ntheorem not_ball_of_bex_not : (\u2203 x h, \u00acP x h) \u2192 \u00ac\u2200 x h, P x h\n  | \u27e8x, h, hp\u27e9, 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 (\u2203 x h, \u00acP x h)] [\u2200 x h, Decidable (P x h)] :\n    (\u00ac\u2200 x h, P x h) \u2194 \u2203 x h, \u00acP x h :=\n  \u27e8Not.decidable_imp_symm fun nx x h \u21a6 nx.decidable_imp_symm\n    fun h' \u21a6 \u27e8x, h, h'\u27e9, not_ball_of_bex_not\u27e9\n#align decidable.not_ball Decidable.not_ball\n\ntheorem not_ball : (\u00ac\u2200 x h, P x h) \u2194 \u2203 x h, \u00acP x h := Decidable.not_ball\n#align not_ball not_ball\n\ntheorem ball_true_iff (p : \u03b1 \u2192 Prop) : (\u2200 x, p x \u2192 True) \u2194 True :=\n  iff_true_intro fun _ _ \u21a6 trivial\n#align ball_true_iff ball_true_iff\n\ntheorem ball_and : (\u2200 x h, P x h \u2227 Q x h) \u2194 (\u2200 x h, P x h) \u2227 \u2200 x h, Q x h :=\n  Iff.trans (forall_congr' fun _ \u21a6 forall_and) forall_and\n#align ball_and_distrib ball_and\n\ntheorem bex_or : (\u2203 x h, P x h \u2228 Q x h) \u2194 (\u2203 x h, P x h) \u2228 \u2203 x h, Q x h :=\n  Iff.trans (exists_congr fun _ \u21a6 exists_or) exists_or\n#align bex_or_distrib bex_or\n\ntheorem ball_or_left : (\u2200 x, p x \u2228 q x \u2192 r x) \u2194 (\u2200 x, p x \u2192 r x) \u2227 \u2200 x, q x \u2192 r x :=\n  Iff.trans (forall_congr' fun _ \u21a6 or_imp) forall_and\n#align ball_or_left_distrib ball_or_left\n\ntheorem bex_or_left :\n    (\u2203 (x : _) (_ : p x \u2228 q x), r x) \u2194 (\u2203 (x : _) (_ : p x), r x) \u2228 \u2203 (x : _) (_ : q x), r x := by\n  simp only [exists_prop]\n  exact Iff.trans (exists_congr fun x \u21a6 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 {\u03c3 : \u03b1 \u2192 Sort _} (f : \u03b1 \u2192 \u03b2) {P Q : Prop} [Decidable P] [Decidable Q]\n  {a b c : \u03b1} {A : P \u2192 \u03b1} {B : \u00acP \u2192 \u03b1}\n\ntheorem dite_eq_iff : dite P A B = c \u2194 (\u2203 h, A h = c) \u2228 \u2203 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 \u2194 P \u2227 a = c \u2228 \u00acP \u2227 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 \u2194 P \u2227 a = b \u2228 \u00acP \u2227 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 \u2194 (\u2200 h, A h = c) \u2227 \u2200 h, B h = c :=\n  \u27e8fun he \u21a6 \u27e8fun h \u21a6 (dif_pos h).symm.trans he, fun h \u21a6 (dif_neg h).symm.trans he\u27e9, fun he \u21a6\n    (em P).elim (fun h \u21a6 (dif_pos h).trans <| he.1 h) fun h \u21a6 (dif_neg h).trans <| he.2 h\u27e9\n#align dite_eq_iff' dite_eq_iff'\n\ntheorem ite_eq_iff' : ite P a b = c \u2194 (P \u2192 a = c) \u2227 (\u00acP \u2192 b = c) := dite_eq_iff'\n#align ite_eq_iff' ite_eq_iff'\n\n@[simp] theorem dite_eq_left_iff : dite P (fun _ \u21a6 a) B = a \u2194 \u2200 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 _ \u21a6 b) = b \u2194 \u2200 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 \u2194 \u00acP \u2192 b = a := dite_eq_left_iff\n@[simp] theorem ite_eq_right_iff : ite P a b = b \u2194 P \u2192 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 _ \u21a6 a) B \u2260 a \u2194 \u2203 h, a \u2260 B h := by\n  rw [Ne.def, dite_eq_left_iff, not_forall]\n  exact exists_congr fun h \u21a6 by rw [ne_comm]\n#align dite_ne_left_iff dite_ne_left_iff\n\ntheorem dite_ne_right_iff : (dite P A fun _ \u21a6 b) \u2260 b \u2194 \u2203 h, A h \u2260 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 \u2260 a \u2194 \u00acP \u2227 a \u2260 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 \u2260 b \u2194 P \u2227 a \u2260 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 : \u2200 h, a \u2260 B h) : dite P (fun _ \u21a6 a) B = a \u2194 P :=\n  dite_eq_left_iff.trans \u27e8fun H \u21a6 of_not_not fun h' \u21a6 h h' (H h').symm, fun h H \u21a6 (H h).elim\u27e9\n#align ne.dite_eq_left_iff Ne.dite_eq_left_iff\n\nprotected theorem Ne.dite_eq_right_iff (h : \u2200 h, A h \u2260 b) : (dite P A fun _ \u21a6 b) = b \u2194 \u00acP :=\n  dite_eq_right_iff.trans \u27e8fun H h' \u21a6 h h' (H h'), fun h' H \u21a6 (h' H).elim\u27e9\n#align ne.dite_eq_right_iff Ne.dite_eq_right_iff\n\nprotected theorem Ne.ite_eq_left_iff (h : a \u2260 b) : ite P a b = a \u2194 P :=\n  Ne.dite_eq_left_iff fun _ \u21a6 h\n#align ne.ite_eq_left_iff Ne.ite_eq_left_iff\n\nprotected theorem Ne.ite_eq_right_iff (h : a \u2260 b) : ite P a b = b \u2194 \u00acP :=\n  Ne.dite_eq_right_iff fun _ \u21a6 h\n#align ne.ite_eq_right_iff Ne.ite_eq_right_iff\n\nprotected theorem Ne.dite_ne_left_iff (h : \u2200 h, a \u2260 B h) : dite P (fun _ \u21a6 a) B \u2260 a \u2194 \u00acP :=\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 : \u2200 h, A h \u2260 b) : (dite P A fun _ \u21a6 b) \u2260 b \u2194 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 \u2260 b) : ite P a b \u2260 a \u2194 \u00acP :=\n  Ne.dite_ne_left_iff fun _ \u21a6 h\n#align ne.ite_ne_left_iff Ne.ite_ne_left_iff\n\nprotected theorem Ne.ite_ne_right_iff (h : a \u2260 b) : ite P a b \u2260 b \u2194 P :=\n  Ne.dite_ne_right_iff fun _ \u21a6 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 _ \u21a6 a) fun _ \u21a6 b) = ite P a b := rfl\n#align dite_eq_ite dite_eq_ite\n\ntheorem dite_eq_or_eq : (\u2203 h, dite P A B = A h) \u2228 \u2203 h, dite P A B = B h :=\n  if h : _ then .inl \u27e8h, dif_pos h\u27e9 else .inr \u27e8h, dif_neg h\u27e9\n#align dite_eq_or_eq dite_eq_or_eq\n\ntheorem ite_eq_or_eq : ite P a b = a \u2228 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\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (P : Prop) [Decidable P] (a : P \u2192 \u03b1) (b : \u00acP \u2192 \u03b1)\n    (c : P \u2192 \u03b2) (d : \u00acP \u2192 \u03b2) :\n    f (dite P a b) (dite P c d) = dite P (fun h \u21a6 f (a h) (c h)) fun h \u21a6 f (b h) (d h) := by\n  by_cases h : P <;> simp [h]\n#align apply_dite2 apply_dite\u2082\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\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (P : Prop) [Decidable P] (a b : \u03b1) (c d : \u03b2) :\n    f (ite P a b) (ite P c d) = ite P (f a c) (f b d) :=\n  apply_dite\u2082 f P (fun _ \u21a6 a) (fun _ \u21a6 b) (fun _ \u21a6 c) fun _ \u21a6 d\n#align apply_ite2 apply_ite\u2082\n\n/-- A 'dite' producing a `Pi` type `\u03a0 a, \u03c3 a`, applied to a value `a : \u03b1` is a `dite` that applies\neither branch to `a`. -/\ntheorem dite_apply (f : P \u2192 \u2200 a, \u03c3 a) (g : \u00acP \u2192 \u2200 a, \u03c3 a) (a : \u03b1) :\n    (dite P f g) a = dite P (fun h \u21a6 f h a) fun h \u21a6 g h a := by by_cases h:P <;> simp [h]\n#align dite_apply dite_apply\n\n/-- A 'ite' producing a `Pi` type `\u03a0 a, \u03c3 a`, applied to a value `a : \u03b1` is a `ite` that applies\neither branch to `a`. -/\ntheorem ite_apply (f g : \u2200 a, \u03c3 a) (a : \u03b1) : (ite P f g) a = ite P (f a) (g a) :=\n  dite_apply P (fun _ \u21a6 f) (fun _ \u21a6 g) a\n#align ite_apply ite_apply\n\ntheorem ite_and : ite (P \u2227 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 \u2192 \u03b1} {C : \u00acP \u2192 \u00acQ \u2192 \u03b1} (h : P \u2192 \u00acQ) :\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 \u27e8\n    fun p \u21a6 by rw [dif_neg (h p), dif_pos p],\n    fun np \u21a6 by congr; funext _; rw [dif_neg np]\u27e9\n#align dite_dite_comm dite_dite_comm\n\ntheorem ite_ite_comm (h : P \u2192 \u00acQ) :\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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u27f6 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 \u226b 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 \u27f6 Y) [is_fibrant X] (hY : is_terminal Y) : fibration f :=\nbegin\n  have fac : f = terminal.from X \u226b (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 \u27f6 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 \u226b 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 \u27f6 Y) [fibration f] (hY : is_terminal Y) : is_fibrant X :=\nbegin\n  change fibration (terminal.from X),\n  rw [show terminal.from X = f \u226b 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\u1d52\u1d56} (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\u1d52\u1d56} (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 \u27f6 A \u2a3f B) :=\n\u27e8cof_is_stable_under_cobase_change.coprod_inl A B hB.property\u27e9\n\ninstance cofibration_coprod_inr [hA : is_cofibrant A] : cofibration (coprod.inr : B \u27f6 A \u2a3f B) :=\n\u27e8cof_is_stable_under_cobase_change.coprod_inr A B hA.property\u27e9\n\ninstance fibration_prod_fst [hY : is_fibrant Y] : fibration (limits.prod.fst : X \u2a2f Y \u27f6 X) :=\n\u27e8fib_is_stable_under_base_change.prod_fst X Y hY.property\u27e9\n\ninstance fibration_prod_snd [hX : is_fibrant X] : fibration (limits.prod.snd : X \u2a2f Y \u27f6 Y) :=\n\u27e8fib_is_stable_under_base_change.prod_snd X Y hX.property\u27e9\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 \u27f6 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) \u226b terminal.from _ :=\n    subsingleton.elim _ _,\n  rw eq,\n  apply_instance,\nend\n\ninstance is_fibrant_CM5b_obj {X Y : C} (f : X \u27f6 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) \u226b terminal.from _ :=\n    subsingleton.elim _ _,\n  rw eq,\n  apply_instance,\nend\n\ninstance is_cofibrant_CM5a_obj {X Y : C} (f : X \u27f6 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 _ \u226b (CM5a.i f) :=\n    subsingleton.elim _ _,\n  rw eq,\n  apply_instance,\nend\n\ninstance is_cofibrant_CM5b_obj {X Y : C} (f : X \u27f6 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 _ \u226b (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 `\u03c9Sup`). In this sense, it is strictly weaker than join complete\nsemi-lattices as only \u03c9-sized totally ordered sets have a supremum.\n\nThe concept of an omega-complete partial order (\u03c9CPO) 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 \u2192\ud835\udc84)\n   * an instance of `omega_complete_partial_order (\u03b1 \u2192\ud835\udc84 \u03b2)`\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 (\u03b1 : Type*) (\u03b2 : Type*) {\u03b3 : Type*} {\u03c6 : Type*}\nvariables [preorder \u03b1] [preorder \u03b2] [preorder \u03b3] [preorder \u03c6]\n\nvariables {\u03b2 \u03b3}\n\nvariables {\u03b1} {\u03b1' : Type*} {\u03b2' : Type*} [preorder \u03b1'] [preorder \u03b2']\n\n/-- `part.bind` as a monotone function -/\n@[simps]\ndef bind {\u03b2 \u03b3} (f : \u03b1 \u2192o part \u03b2) (g : \u03b1 \u2192o \u03b2 \u2192 part \u03b3) : \u03b1 \u2192o part \u03b3 :=\n{ to_fun := \u03bb 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 \u27e8b, f.monotone h _ hb, g.monotone h _ _ ha\u27e9,\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 (\u03b1 : Type u) [preorder \u03b1] :=\n\u2115 \u2192o \u03b1\n\nnamespace chain\n\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type*}\nvariables [preorder \u03b1] [preorder \u03b2] [preorder \u03b3]\n\ninstance : has_coe_to_fun (chain \u03b1) (\u03bb _, \u2115 \u2192 \u03b1) := order_hom.has_coe_to_fun\n\ninstance [inhabited \u03b1] : inhabited (chain \u03b1) :=\n\u27e8\u27e8default, \u03bb _ _ _, le_rfl\u27e9\u27e9\n\ninstance : has_mem \u03b1 (chain \u03b1) :=\n\u27e8\u03bb a (c : \u2115 \u2192o \u03b1), \u2203 i, a = c i\u27e9\n\nvariables (c c' : chain \u03b1)\nvariables (f : \u03b1 \u2192o \u03b2)\nvariables (g : \u03b2 \u2192o \u03b3)\n\ninstance : has_le (chain \u03b1) :=\n{ le := \u03bb x y, \u2200 i, \u2203 j, x i \u2264 y j }\n\n/-- `map` function for `chain` -/\n@[simps {fully_applied := ff}] def map : chain \u03b2 :=\nf.comp c\n\nvariables {f}\n\nlemma mem_map (x : \u03b1) : x \u2208 c \u2192 f x \u2208 chain.map c f :=\n\u03bb \u27e8i,h\u27e9, \u27e8i, h.symm \u25b8 rfl\u27e9\n\nlemma exists_of_mem_map {b : \u03b2} : b \u2208 c.map f \u2192 \u2203 a, a \u2208 c \u2227 f a = b :=\n\u03bb \u27e8i,h\u27e9, \u27e8c i, \u27e8i, rfl\u27e9, h.symm\u27e9\n\nlemma mem_map_iff {b : \u03b2} : b \u2208 c.map f \u2194 \u2203 a, a \u2208 c \u2227 f a = b :=\n\u27e8 exists_of_mem_map _, \u03bb h, by { rcases h with \u27e8w,h,h'\u27e9, subst b, apply mem_map c _ h, } \u27e9\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 : \u03b1 \u2192o \u03b2} (h : f \u2264 g) : c.map f \u2264 c.map g :=\n\u03bb 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\u2080 : chain \u03b1) (c\u2081 : chain \u03b2) : chain (\u03b1 \u00d7 \u03b2) :=\norder_hom.prod c\u2080 c\u2081\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 `\u03c9Sup`). In this sense, it is strictly weaker than join complete\nsemi-lattices as only \u03c9-sized totally ordered sets have a supremum.\n\nSee the definition on page 114 of [gunter1992]. -/\nclass omega_complete_partial_order (\u03b1 : Type*) extends partial_order \u03b1 :=\n(\u03c9Sup     : chain \u03b1 \u2192 \u03b1)\n(le_\u03c9Sup  : \u2200(c:chain \u03b1), \u2200 i, c i \u2264 \u03c9Sup c)\n(\u03c9Sup_le  : \u2200(c:chain \u03b1) x, (\u2200 i, c i \u2264 x) \u2192 \u03c9Sup c \u2264 x)\n\nend prio\n\nnamespace omega_complete_partial_order\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type*}\nvariables [omega_complete_partial_order \u03b1]\n\n/-- Transfer a `omega_complete_partial_order` on `\u03b2` to a `omega_complete_partial_order` on `\u03b1`\nusing a strictly monotone function `f : \u03b2 \u2192o \u03b1`, a definition of \u03c9Sup and a proof that `f` is\ncontinuous with regard to the provided `\u03c9Sup` and the \u03c9CPO on `\u03b1`. -/\n@[reducible]\nprotected def lift [partial_order \u03b2] (f : \u03b2 \u2192o \u03b1)\n  (\u03c9Sup\u2080 : chain \u03b2 \u2192 \u03b2)\n  (h : \u2200 x y, f x \u2264 f y \u2192 x \u2264 y)\n  (h' : \u2200 c, f (\u03c9Sup\u2080 c) = \u03c9Sup (c.map f)) : omega_complete_partial_order \u03b2 :=\n{ \u03c9Sup := \u03c9Sup\u2080,\n  \u03c9Sup_le := \u03bb c x hx, h _ _ (by rw h'; apply \u03c9Sup_le; intro; apply f.monotone (hx i)),\n  le_\u03c9Sup := \u03bb c i, h _ _ (by rw h'; apply le_\u03c9Sup (c.map f)) }\n\nlemma le_\u03c9Sup_of_le {c : chain \u03b1} {x : \u03b1} (i : \u2115) (h : x \u2264 c i) : x \u2264 \u03c9Sup c :=\nle_trans h (le_\u03c9Sup c _)\n\nlemma \u03c9Sup_total {c : chain \u03b1} {x : \u03b1} (h : \u2200 i, c i \u2264 x \u2228 x \u2264 c i) : \u03c9Sup c \u2264 x \u2228 x \u2264 \u03c9Sup c :=\nclassical.by_cases\n  (assume : \u2200 i, c i \u2264 x, or.inl (\u03c9Sup_le _ _ this))\n  (assume : \u00ac \u2200 i, c i \u2264 x,\n    have \u2203 i, \u00ac c i \u2264 x,\n      by simp only [not_forall] at this \u22a2; assumption,\n    let \u27e8i, hx\u27e9 := this in\n    have x \u2264 c i, from (h i).resolve_left hx,\n    or.inr $ le_\u03c9Sup_of_le _ this)\n\n@[mono]\nlemma \u03c9Sup_le_\u03c9Sup_of_le {c\u2080 c\u2081 : chain \u03b1} (h : c\u2080 \u2264 c\u2081) : \u03c9Sup c\u2080 \u2264 \u03c9Sup c\u2081 :=\n\u03c9Sup_le _ _ $\n\u03bb i, Exists.rec_on (h i) $\n\u03bb j h, le_trans h (le_\u03c9Sup _ _)\n\nlemma \u03c9Sup_le_iff (c : chain \u03b1) (x : \u03b1) : \u03c9Sup c \u2264 x \u2194 (\u2200 i, c i \u2264 x) :=\nbegin\n  split; intros,\n  { transitivity \u03c9Sup c,\n    exact le_\u03c9Sup _ _, assumption },\n  exact \u03c9Sup_le _ _ \u2039_\u203a,\nend\n\n/-- A subset `p : \u03b1 \u2192 Prop` of the type closed under `\u03c9Sup` induces an\n`omega_complete_partial_order` on the subtype `{a : \u03b1 // p a}`. -/\ndef subtype {\u03b1 : Type*} [omega_complete_partial_order \u03b1] (p : \u03b1 \u2192 Prop)\n  (hp : \u2200 (c : chain \u03b1), (\u2200 i \u2208 c, p i) \u2192 p (\u03c9Sup c)) :\n  omega_complete_partial_order (subtype p) :=\nomega_complete_partial_order.lift\n  (order_hom.subtype.val p)\n  (\u03bb c, \u27e8\u03c9Sup _, hp (c.map (order_hom.subtype.val p)) (\u03bb i \u27e8n, q\u27e9, q.symm \u25b8 (c n).2)\u27e9)\n  (\u03bb x y h, h)\n  (\u03bb c, rfl)\n\nsection continuity\nopen chain\n\nvariables [omega_complete_partial_order \u03b2]\nvariables [omega_complete_partial_order \u03b3]\n\n/-- A monotone function `f : \u03b1 \u2192o \u03b2` is continuous if it distributes over \u03c9Sup.\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 : \u03b1 \u2192o \u03b2) : Prop :=\n\u2200 c : chain \u03b1, f (\u03c9Sup c) = \u03c9Sup (c.map f)\n\n/-- `continuous' f` asserts that `f` is both monotone and continuous. -/\ndef continuous' (f : \u03b1 \u2192 \u03b2) : Prop :=\n\u2203 hf : monotone f, continuous \u27e8f, hf\u27e9\n\nlemma continuous'.to_monotone {f : \u03b1 \u2192 \u03b2} (hf : continuous' f) : monotone f := hf.fst\n\nlemma continuous.of_bundled (f : \u03b1 \u2192 \u03b2) (hf : monotone f)\n  (hf' : continuous \u27e8f, hf\u27e9) : continuous' f := \u27e8hf, hf'\u27e9\n\nlemma continuous.of_bundled' (f : \u03b1 \u2192o \u03b2) (hf' : continuous f) : continuous' f :=\n\u27e8f.mono, hf'\u27e9\n\nlemma continuous'.to_bundled (f : \u03b1 \u2192 \u03b2) (hf : continuous' f) :\n  continuous \u27e8f, hf.to_monotone\u27e9 := hf.snd\n\n@[simp, norm_cast] lemma continuous'_coe : \u2200 {f : \u03b1 \u2192o \u03b2}, continuous' f \u2194 continuous f\n| \u27e8f, hf\u27e9 := \u27e8\u03bb \u27e8hf', hc\u27e9, hc, \u03bb hc, \u27e8hf, hc\u27e9\u27e9\n\nvariables (f : \u03b1 \u2192o \u03b2) (g : \u03b2 \u2192o \u03b3)\n\nlemma continuous_id : continuous (@order_hom.id \u03b1 _) :=\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 \u03b1) :=\ncontinuous_id.of_bundled' _\n\nlemma continuous_const (x : \u03b2) : continuous (order_hom.const \u03b1 x) :=\n\u03bb c, eq_of_forall_ge_iff $ \u03bb z, by simp [\u03c9Sup_le_iff]\n\nlemma const_continuous' (x: \u03b2) : continuous' (function.const \u03b1 x) :=\ncontinuous.of_bundled' (order_hom.const \u03b1 x) (continuous_const x)\n\nend continuity\n\nend omega_complete_partial_order\n\nnamespace part\n\nvariables {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type*}\nopen omega_complete_partial_order\n\nlemma eq_of_chain {c : chain (part \u03b1)} {a b : \u03b1} (ha : some a \u2208 c) (hb : some b \u2208 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 \u2264 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) `\u03c9Sup` definition for the `\u03c9`-CPO structure on `part \u03b1`. -/\nprotected noncomputable def \u03c9Sup (c : chain (part \u03b1)) : part \u03b1 :=\nif h : \u2203a, some a \u2208 c then some (classical.some h) else none\n\nlemma \u03c9Sup_eq_some {c : chain (part \u03b1)} {a : \u03b1} (h : some a \u2208 c) : part.\u03c9Sup c = some a :=\nhave \u2203a, some a \u2208 c, from \u27e8a, h\u27e9,\nhave a' : some (classical.some this) \u2208 c, from classical.some_spec this,\ncalc part.\u03c9Sup c = some (classical.some this) : dif_pos this\n                ... = some a : congr_arg _ (eq_of_chain a' h)\n\nlemma \u03c9Sup_eq_none {c : chain (part \u03b1)} (h : \u00ac\u2203a, some a \u2208 c) : part.\u03c9Sup c = none :=\ndif_neg h\n\nlemma mem_chain_of_mem_\u03c9Sup {c : chain (part \u03b1)} {a : \u03b1} (h : a \u2208 part.\u03c9Sup c) : some a \u2208 c :=\nbegin\n  simp [part.\u03c9Sup] at h, split_ifs at h,\n  { have h' := classical.some_spec h_1,\n    rw \u2190 eq_some_iff at h, rw \u2190 h, exact h' },\n  { rcases h with \u27e8 \u27e8 \u27e9 \u27e9 }\nend\n\nnoncomputable instance omega_complete_partial_order : omega_complete_partial_order (part \u03b1) :=\n{ \u03c9Sup    := part.\u03c9Sup,\n  le_\u03c9Sup := \u03bb c i, by { intros x hx, rw \u2190 eq_some_iff at hx \u22a2,\n                         rw [\u03c9Sup_eq_some, \u2190 hx], rw \u2190 hx, exact \u27e8i,rfl\u27e9 },\n  \u03c9Sup_le := by { rintros c x hx a ha, replace ha := mem_chain_of_mem_\u03c9Sup ha,\n                  cases ha with i ha, apply hx i, rw \u2190 ha, apply mem_some } }\n\nsection inst\n\nlemma mem_\u03c9Sup (x : \u03b1) (c : chain (part \u03b1)) : x \u2208 \u03c9Sup c \u2194 some x \u2208 c :=\nbegin\n  simp [omega_complete_partial_order.\u03c9Sup,part.\u03c9Sup],\n  split,\n  { split_ifs, swap, rintro \u27e8\u27e8\u27e9\u27e9,\n    intro h', have hh := classical.some_spec h,\n    simp at h', subst x, exact hh },\n  { intro h,\n    have h' : \u2203 (a : \u03b1), some a \u2208 c := \u27e8_,h\u27e9,\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 {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Type*} {\u03b3 : Type*}\n\nopen omega_complete_partial_order omega_complete_partial_order.chain\n\ninstance [\u2200a, omega_complete_partial_order (\u03b2 a)] : omega_complete_partial_order (\u03a0a, \u03b2 a) :=\n{ \u03c9Sup    := \u03bbc a, \u03c9Sup (c.map (pi.eval_order_hom a)),\n  \u03c9Sup_le := assume c f hf a, \u03c9Sup_le _ _ $ by { rintro i, apply hf },\n  le_\u03c9Sup := assume c i x, le_\u03c9Sup_of_le _ $ le_rfl }\n\nnamespace omega_complete_partial_order\n\nvariables [\u2200 x, omega_complete_partial_order $ \u03b2 x]\nvariables [omega_complete_partial_order \u03b3]\n\nlemma flip\u2081_continuous'\n  (f : \u2200 x : \u03b1, \u03b3 \u2192 \u03b2 x) (a : \u03b1) (hf : continuous' (\u03bb x y, f y x)) :\n  continuous' (f a) :=\ncontinuous.of_bundled _\n  (\u03bb x y h, hf.to_monotone h a)\n  (\u03bb c, congr_fun (hf.to_bundled _ c) a)\n\nlemma flip\u2082_continuous'\n  (f : \u03b3 \u2192 \u03a0 x, \u03b2 x) (hf : \u2200 x, continuous' (\u03bb g, f g x)) : continuous' f :=\ncontinuous.of_bundled _\n  (\u03bb 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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\nvariables [omega_complete_partial_order \u03b1]\nvariables [omega_complete_partial_order \u03b2]\nvariables [omega_complete_partial_order \u03b3]\n\n/-- The supremum of a chain in the product `\u03c9`-CPO. -/\n@[simps]\nprotected def \u03c9Sup (c : chain (\u03b1 \u00d7 \u03b2)) : \u03b1 \u00d7 \u03b2 :=\n(\u03c9Sup (c.map order_hom.fst), \u03c9Sup (c.map order_hom.snd))\n\n@[simps \u03c9Sup_fst \u03c9Sup_snd]\ninstance : omega_complete_partial_order (\u03b1 \u00d7 \u03b2) :=\n{ \u03c9Sup := prod.\u03c9Sup,\n  \u03c9Sup_le := \u03bb c \u27e8x,x'\u27e9 h, \u27e8\u03c9Sup_le _ _ $ \u03bb i, (h i).1, \u03c9Sup_le _ _ $ \u03bb i, (h i).2\u27e9,\n  le_\u03c9Sup := \u03bb c i,\n    \u27e8le_\u03c9Sup (c.map order_hom.fst) i, le_\u03c9Sup (c.map order_hom.snd) i\u27e9 }\n\n\n\nend prod\n\nopen omega_complete_partial_order\n\nnamespace complete_lattice\nvariables (\u03b1 : Type u)\n\n/-- Any complete lattice has an `\u03c9`-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 \u03b1] : omega_complete_partial_order \u03b1 :=\n{ \u03c9Sup    := \u03bbc, \u2a06 i, c i,\n  \u03c9Sup_le := \u03bb \u27e8c, _\u27e9 s hs, by simp only [supr_le_iff, order_hom.coe_fun_mk] at \u22a2 hs;\n    intros i; apply hs i,\n  le_\u03c9Sup := assume \u27e8c, _\u27e9 i, by simp only [order_hom.coe_fun_mk]; apply le_supr_of_le i; refl }\n\nvariables {\u03b1} {\u03b2 : Type v} [omega_complete_partial_order \u03b1] [complete_lattice \u03b2]\n\nlemma Sup_continuous (s : set $ \u03b1 \u2192o \u03b2) (hs : \u2200 f \u2208 s, continuous f) :\n  continuous (Sup s) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  suffices : (\u2200 (f \u2208 s) n, (f : _) (c n) \u2264 z) \u2194 (\u2200 n (f \u2208 s), (f : _) (c n) \u2264 z),\n    by simpa [\u03c9Sup_le_iff, hs _ _ _] { contextual := tt },\n  exact \u27e8\u03bb H n f hf, H f hf n, \u03bb H f hf n, H n f hf\u27e9\nend\n\nlemma supr_continuous {\u03b9 : Sort*} {f : \u03b9 \u2192 \u03b1 \u2192o \u03b2} (h : \u2200 i, continuous (f i)) :\n  continuous (\u2a06 i, f i) :=\nSup_continuous _ $ set.forall_range_iff.2 h\n\ntheorem Sup_continuous' (s : set (\u03b1 \u2192 \u03b2)) (hc : \u2200 f \u2208 s, continuous' f) :\n  continuous' (Sup s) :=\nbegin\n  lift s to set (\u03b1 \u2192o \u03b2) using \u03bb 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 (\u03bb f, supr_continuous (\u03bb hf, hc f hf)),\nend\n\nlemma sup_continuous {f g : \u03b1 \u2192o \u03b2} (hf : continuous f) (hg : continuous g) :\n  continuous (f \u2294 g) :=\nbegin\n  rw \u2190 Sup_pair, apply Sup_continuous,\n  rintro f (rfl|rfl|_); assumption\nend\n\nlemma top_continuous :\n  continuous (\u22a4 : \u03b1 \u2192o \u03b2) :=\nbegin\n  intro c, apply eq_of_forall_ge_iff, intro z,\n  simp only [\u03c9Sup_le_iff, forall_const, chain.map_coe, (\u2218), function.const,\n             order_hom.has_top_top, order_hom.const_coe_coe],\nend\n\nlemma bot_continuous :\n  continuous (\u22a5 : \u03b1 \u2192o \u03b2) :=\nbegin\n  rw \u2190 Sup_empty,\n  exact Sup_continuous _ (\u03bb f hf, hf.elim),\nend\n\nend complete_lattice\n\nnamespace complete_lattice\nvariables {\u03b1 \u03b2 : Type*} [omega_complete_partial_order \u03b1] [complete_linear_order \u03b2]\n\nlemma inf_continuous (f g : \u03b1 \u2192o \u03b2) (hf : continuous f) (hg : continuous g) : continuous (f \u2293 g) :=\nbegin\n  refine \u03bb c, eq_of_forall_ge_iff (\u03bb z, _),\n  simp only [inf_le_iff, hf c, hg c, \u03c9Sup_le_iff, \u2190forall_or_distrib_left, \u2190forall_or_distrib_right,\n             function.comp_app, chain.map_coe, order_hom.has_inf_inf_coe],\n  exact \u27e8\u03bb h _, h _ _, \u03bb 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 _ _)\u27e9,\nend\n\nlemma inf_continuous' {f g : \u03b1 \u2192 \u03b2} (hf : continuous' f) (hg : continuous' g) :\n  continuous' (f \u2293 g) :=\n\u27e8_, inf_continuous _ _ hf.snd hg.snd\u27e9\n\nend complete_lattice\n\nnamespace omega_complete_partial_order\n\nvariables {\u03b1 : Type u} {\u03b1' : Type*} {\u03b2 : Type v} {\u03b2' : Type*} {\u03b3 : Type*} {\u03c6 : Type*}\n\nvariables [omega_complete_partial_order \u03b1] [omega_complete_partial_order \u03b2]\nvariables [omega_complete_partial_order \u03b3] [omega_complete_partial_order \u03c6]\nvariables [omega_complete_partial_order \u03b1'] [omega_complete_partial_order \u03b2']\n\nnamespace order_hom\n\n/-- The `\u03c9Sup` operator for monotone functions. -/\n@[simps]\nprotected def \u03c9Sup (c : chain (\u03b1 \u2192o \u03b2)) : \u03b1 \u2192o \u03b2 :=\n{ to_fun := \u03bb a, \u03c9Sup (c.map (order_hom.apply a)),\n  monotone' := \u03bb x y h, \u03c9Sup_le_\u03c9Sup_of_le (chain.map_le_map _ $ \u03bb a, a.monotone h) }\n\n@[simps \u03c9Sup_coe]\ninstance omega_complete_partial_order : omega_complete_partial_order (\u03b1 \u2192o \u03b2) :=\nomega_complete_partial_order.lift order_hom.coe_fn_hom order_hom.\u03c9Sup\n  (\u03bb x y h, h) (\u03bb c, rfl)\n\nend order_hom\n\nsection\nvariables (\u03b1 \u03b2)\n\n/-- A monotone function on `\u03c9`-continuous partial orders is said to be continuous\nif for every chain `c : chain \u03b1`, `f (\u2294 i, c i) = \u2294 i, f (c i)`.\nThis is just the bundled version of `order_hom.continuous`. -/\nstructure continuous_hom extends order_hom \u03b1 \u03b2 :=\n(cont : continuous (order_hom.mk to_fun monotone'))\n\nattribute [nolint doc_blame] continuous_hom.to_order_hom\n\ninfixr ` \u2192\ud835\udc84 `:25 := continuous_hom -- Input: \\r\\MIc\n\ninstance : has_coe_to_fun (\u03b1 \u2192\ud835\udc84 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := \u27e8\u03bb f, f.to_order_hom.to_fun\u27e9\n\ninstance : has_coe (\u03b1 \u2192\ud835\udc84 \u03b2) (\u03b1 \u2192o \u03b2) :=\n{ coe :=  continuous_hom.to_order_hom }\n\ninstance : partial_order (\u03b1 \u2192\ud835\udc84 \u03b2) :=\npartial_order.lift (\u03bb f, f.to_order_hom.to_fun) $ by rintro \u27e8\u27e8\u27e9\u27e9 \u27e8\u27e8\u27e9\u27e9 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 : \u03b1 \u2192\ud835\udc84 \u03b2) : \u03b1 \u2192 \u03b2 := h\n\ninitialize_simps_projections continuous_hom\n  (to_order_hom_to_fun \u2192 apply, -to_order_hom)\n\nend\n\nnamespace continuous_hom\n\ntheorem congr_fun {f g : \u03b1 \u2192\ud835\udc84 \u03b2} (h : f = g) (x : \u03b1) : f x = g x :=\ncongr_arg (\u03bb h : \u03b1 \u2192\ud835\udc84 \u03b2, h x) h\n\ntheorem congr_arg (f : \u03b1 \u2192\ud835\udc84 \u03b2) {x y : \u03b1} (h : x = y) : f x = f y :=\ncongr_arg (\u03bb x : \u03b1, f x) h\n\nprotected lemma monotone (f : \u03b1 \u2192\ud835\udc84 \u03b2) : monotone f := f.monotone'\n\n@[mono] lemma apply_mono {f g : \u03b1 \u2192\ud835\udc84 \u03b2} {x y : \u03b1} (h\u2081 : f \u2264 g) (h\u2082 : x \u2264 y) : f x \u2264 g y :=\norder_hom.apply_mono (show (f : \u03b1 \u2192o \u03b2) \u2264 g, from h\u2081) h\u2082\n\nlemma ite_continuous' {p : Prop} [hp : decidable p] (f g : \u03b1 \u2192 \u03b2)\n  (hf : continuous' f) (hg : continuous' g) : continuous' (\u03bb x, if p then f x else g x) :=\nby split_ifs; simp *\n\nlemma \u03c9Sup_bind {\u03b2 \u03b3 : Type v} (c : chain \u03b1) (f : \u03b1 \u2192o part \u03b2) (g : \u03b1 \u2192o \u03b2 \u2192 part \u03b3) :\n  \u03c9Sup (c.map (f.bind g)) = \u03c9Sup (c.map f) >>= \u03c9Sup (c.map g) :=\nbegin\n  apply eq_of_forall_ge_iff, intro x,\n  simp only [\u03c9Sup_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 \u03c9Sup_le _ _ _,\n    rintros i y hy, simp only [part.mem_\u03c9Sup] at hb,\n    rcases hb with \u27e8j,hb\u27e9, 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 \u2208 f (c (max i j))   := f.mono (c.mono (le_max_right i j)) _ hb,\n    replace hy : y \u2208 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 \u27e8_,hb,hy\u27e9, },\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 \u27e8b,hb\u2080,hb\u2081\u27e9,\n    apply h''' b _,\n    { apply le_\u03c9Sup (c.map g) _ _ _ hb\u2081 },\n    { apply le_\u03c9Sup (c.map f) i _ hb\u2080 } },\nend\n\nlemma bind_continuous' {\u03b2 \u03b3 : Type v} (f : \u03b1 \u2192 part \u03b2) (g : \u03b1 \u2192 \u03b2 \u2192 part \u03b3) :\n  continuous' f \u2192 continuous' g \u2192\n  continuous' (\u03bb x, f x >>= g x)\n| \u27e8hf,hf'\u27e9 \u27e8hg,hg'\u27e9 :=\ncontinuous.of_bundled' (order_hom.bind \u27e8f,hf\u27e9 \u27e8g,hg\u27e9)\n  (by intro c; rw [\u03c9Sup_bind, \u2190 hf', \u2190 hg']; refl)\n\nlemma map_continuous' {\u03b2 \u03b3 : Type v} (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 part \u03b2)\n  (hg : continuous' g) :\n  continuous' (\u03bb 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' {\u03b2 \u03b3 : Type v} (f : \u03b1 \u2192 part (\u03b2 \u2192 \u03b3)) (g : \u03b1 \u2192 part \u03b2)\n  (hf : continuous' f) (hg : continuous' g) :\n  continuous' (\u03bb 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\u2082_continuous'; intro;\n   apply map_continuous' _ _ hg\n\nlemma continuous (F : \u03b1 \u2192\ud835\udc84 \u03b2) (C : chain \u03b1) : F (\u03c9Sup C) = \u03c9Sup (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 : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192\ud835\udc84 \u03b2) (h : f = g) : \u03b1 \u2192\ud835\udc84 \u03b2 :=\nby refine {to_order_hom := {to_fun := f, ..}, ..}; subst h; rcases g with \u27e8\u27e8\u27e9\u27e9; assumption\n\n/-- Construct a continuous function from a monotone function with a proof of continuity. -/\n@[simps, reducible]\ndef of_mono (f : \u03b1 \u2192o \u03b2) (h : \u2200 c : chain \u03b1, f (\u03c9Sup c) = \u03c9Sup (c.map f)) : \u03b1 \u2192\ud835\udc84 \u03b2 :=\n{ to_fun := f,\n  monotone' := f.monotone,\n  cont := h }\n\n/-- The identity as a continuous function. -/\n@[simps]\ndef id : \u03b1 \u2192\ud835\udc84 \u03b1 :=\nof_mono order_hom.id continuous_id\n\n/-- The composition of continuous functions. -/\n@[simps]\ndef comp (f : \u03b2 \u2192\ud835\udc84 \u03b3) (g : \u03b1 \u2192\ud835\udc84 \u03b2) : \u03b1 \u2192\ud835\udc84 \u03b3 :=\nof_mono (order_hom.comp (\u2191f) (\u2191g)) (continuous_comp _ _ g.cont f.cont)\n\n@[ext]\nprotected lemma ext (f g : \u03b1 \u2192\ud835\udc84 \u03b2) (h : \u2200 x, f x = g x) : f = g :=\nby cases f; cases g; congr; ext; apply h\n\nprotected lemma coe_inj (f g : \u03b1 \u2192\ud835\udc84 \u03b2) (h : (f : \u03b1 \u2192 \u03b2) = g) : f = g :=\ncontinuous_hom.ext _ _ $ _root_.congr_fun h\n\n@[simp]\nlemma comp_id (f : \u03b2 \u2192\ud835\udc84 \u03b3) : f.comp id = f := by ext; refl\n\n@[simp]\nlemma id_comp (f : \u03b2 \u2192\ud835\udc84 \u03b3) : id.comp f = f := by ext; refl\n\n@[simp]\nlemma comp_assoc (f : \u03b3 \u2192\ud835\udc84 \u03c6) (g : \u03b2 \u2192\ud835\udc84 \u03b3) (h : \u03b1 \u2192\ud835\udc84 \u03b2) : f.comp (g.comp h) = (f.comp g).comp h :=\nby ext; refl\n\n@[simp]\nlemma coe_apply (a : \u03b1) (f : \u03b1 \u2192\ud835\udc84 \u03b2) : (f : \u03b1 \u2192o \u03b2) a = f a := rfl\n\n/-- `function.const` is a continuous function. -/\ndef const (x : \u03b2) : \u03b1 \u2192\ud835\udc84 \u03b2 :=\nof_mono (order_hom.const _ x) (continuous_const x)\n\n@[simp] theorem const_apply (f : \u03b2) (a : \u03b1) : const f a = f := rfl\n\ninstance [inhabited \u03b2] : inhabited (\u03b1 \u2192\ud835\udc84 \u03b2) :=\n\u27e8 const default \u27e9\n\n\n/-- The map from continuous functions to monotone functions is itself a monotone function. -/\n@[simps]\ndef to_mono : (\u03b1 \u2192\ud835\udc84 \u03b2) \u2192o (\u03b1 \u2192o \u03b2) :=\n{ to_fun := \u03bb f, f,\n  monotone' := \u03bb 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\u2080` only needs to be a\nchain of monotone functions, but it is only used with continuous functions. -/\n@[simp]\nlemma forall_forall_merge (c\u2080 : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) (c\u2081 : chain \u03b1) (z : \u03b2) :\n  (\u2200 (i j : \u2115), (c\u2080 i) (c\u2081 j) \u2264 z) \u2194 \u2200 (i : \u2115), (c\u2080 i) (c\u2081 i) \u2264 z :=\nbegin\n  split; introv h,\n  { apply h },\n  { apply le_trans _ (h (max i j)),\n    transitivity c\u2080 i (c\u2081 (max i j)),\n    { apply (c\u2080 i).monotone, apply c\u2081.monotone, apply le_max_right },\n    { apply c\u2080.monotone, apply le_max_left } }\nend\n\n@[simp]\nlemma forall_forall_merge' (c\u2080 : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) (c\u2081 : chain \u03b1) (z : \u03b2) :\n  (\u2200 (j i : \u2115), (c\u2080 i) (c\u2081 j) \u2264 z) \u2194 \u2200 (i : \u2115), (c\u2080 i) (c\u2081 i) \u2264 z :=\nby rw [forall_swap,forall_forall_merge]\n\n/-- The `\u03c9Sup` operator for continuous functions, which takes the pointwise countable supremum\nof the functions in the `\u03c9`-chain. -/\n@[simps]\nprotected def \u03c9Sup (c : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) : \u03b1 \u2192\ud835\udc84 \u03b2 :=\ncontinuous_hom.of_mono (\u03c9Sup $ c.map to_mono)\nbegin\n  intro c',\n  apply eq_of_forall_ge_iff, intro z,\n  simp only [\u03c9Sup_le_iff, (c _).continuous, chain.map_coe, order_hom.apply_coe,\n    to_mono_coe, coe_apply, order_hom.omega_complete_partial_order_\u03c9Sup_coe,\n    forall_forall_merge, forall_forall_merge', (\u2218), function.eval],\nend\n\n@[simps \u03c9Sup]\ninstance : omega_complete_partial_order (\u03b1 \u2192\ud835\udc84 \u03b2) :=\nomega_complete_partial_order.lift continuous_hom.to_mono continuous_hom.\u03c9Sup\n  (\u03bb x y h, h) (\u03bb c, rfl)\n\nnamespace prod\n\n/-- The application of continuous functions as a continuous function.  -/\n@[simps]\ndef apply : (\u03b1 \u2192\ud835\udc84 \u03b2) \u00d7 \u03b1 \u2192\ud835\udc84 \u03b2 :=\n{ to_fun := \u03bb f, f.1 f.2,\n  monotone' := \u03bb 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 \u03c9Sup_le, intros i,\n      dsimp,\n      rw (c _).fst.continuous,\n      apply \u03c9Sup_le, intros j,\n      apply le_\u03c9Sup_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 \u03c9Sup_le, intros i,\n      apply le_\u03c9Sup_of_le i,\n      dsimp,\n      apply order_hom.mono _,\n      apply le_\u03c9Sup_of_le i,\n      reflexivity, }\n  end }\n\nend prod\n\nlemma \u03c9Sup_def (c : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) (x : \u03b1) : \u03c9Sup c x = continuous_hom.\u03c9Sup c x := rfl\n\nlemma \u03c9Sup_apply_\u03c9Sup (c\u2080 : chain (\u03b1 \u2192\ud835\udc84 \u03b2)) (c\u2081 : chain \u03b1) :\n  \u03c9Sup c\u2080 (\u03c9Sup c\u2081) = prod.apply (\u03c9Sup (c\u2080.zip c\u2081)) :=\nby simp [prod.apply_apply, prod.\u03c9Sup_zip]\n\n/-- A family of continuous functions yields a continuous family of functions. -/\n@[simps]\ndef flip {\u03b1 : Type*} (f : \u03b1 \u2192 \u03b2 \u2192\ud835\udc84 \u03b3) : \u03b2 \u2192\ud835\udc84 \u03b1 \u2192 \u03b3 :=\n{ to_fun := \u03bb x y, f y x,\n  monotone' := \u03bb 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 {\u03b2 \u03b3 : Type v}\n  (f : \u03b1 \u2192\ud835\udc84 part \u03b2) (g : \u03b1 \u2192\ud835\udc84 \u03b2 \u2192 part \u03b3) : \u03b1 \u2192\ud835\udc84 part \u03b3 :=\nof_mono (order_hom.bind (\u2191f) (\u2191g)) $ \u03bb c, begin\n  rw [order_hom.bind, \u2190 order_hom.bind, \u03c9Sup_bind, \u2190 f.continuous, \u2190 g.continuous],\n  refl\nend\n\n/-- `part.map` as a continuous function. -/\n@[simps {rhs_md := reducible}]\nnoncomputable def map {\u03b2 \u03b3 : Type v} (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192\ud835\udc84 part \u03b2) : \u03b1 \u2192\ud835\udc84 part \u03b3 :=\nof_fun (\u03bb x, f <$> g x) (bind g (const (pure \u2218 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 {\u03b2 \u03b3 : Type v} (f : \u03b1 \u2192\ud835\udc84 part (\u03b2 \u2192 \u03b3)) (g : \u03b1 \u2192\ud835\udc84 part \u03b2) :\n  \u03b1 \u2192\ud835\udc84 part \u03b3 :=\nof_fun (\u03bb 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 : Sort _} {\u03b2 : Sort _}\n\nopen Function\n\nnamespace Setoid\n\n#print Setoid.ext /-\ntheorem ext {\u03b1 : Sort _} :\n    \u2200 {s t : Setoid \u03b1}, (\u2200 a b, @Setoid.r \u03b1 s a b \u2194 @Setoid.r \u03b1 t a b) \u2192 s = t\n  | \u27e8r, _\u27e9, \u27e8p, _\u27e9, 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} {rb : \u03b2 \u2192 \u03b2 \u2192 Prop} {\u03c6 : Quot ra \u2192 Quot rb \u2192 Sort _}\n\n-- mathport name: mk\nlocal notation:arg \"\u27e6\" a \"\u27e7\" => Quot.mk _ a\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [Inhabited \u03b1] : Inhabited (Quot r) :=\n  \u27e8\u27e6default\u27e7\u27e9\n\ninstance [Subsingleton \u03b1] : Subsingleton (Quot ra) :=\n  \u27e8fun x => Quot.inductionOn x fun y => Quot.ind fun b => congr_arg _ (Subsingleton.elim _ _)\u27e9\n\n#print Quot.hrecOn\u2082 /-\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrecOn\u2082 (qa : Quot ra) (qb : Quot rb) (f : \u2200 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n    (ca : \u2200 {b a\u2081 a\u2082}, ra a\u2081 a\u2082 \u2192 HEq (f a\u2081 b) (f a\u2082 b))\n    (cb : \u2200 {a b\u2081 b\u2082}, rb b\u2081 b\u2082 \u2192 HEq (f a b\u2081) (f a b\u2082)) : \u03c6 qa qb :=\n  Quot.hrecOn qa (fun a => Quot.hrecOn qb (f a) fun b\u2081 b\u2082 pb => cb pb) fun a\u2081 a\u2082 pa =>\n    Quot.inductionOn qb fun b =>\n      calc\n        HEq (@Quot.hrecOn _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2081) (@cb _)) (f a\u2081 b) := by simp [hEq_self_iff_true]\n        HEq _ (f a\u2082 b) := (ca pa)\n        HEq _ (@Quot.hrecOn _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2082) (@cb _)) := by simp [hEq_self_iff_true]\n        \n#align quot.hrec_on\u2082 Quot.hrecOn\u2082\n-/\n\n#print Quot.map /-\n/-- Map a function `f : \u03b1 \u2192 \u03b2` such that `ra x y` implies `rb (f x) (f y)`\nto a map `quot ra \u2192 quot rb`. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : (ra \u21d2 rb) f f) : Quot ra \u2192 Quot rb :=\n  Quot.lift (fun x => \u27e6f x\u27e7) fun x y (h\u2081 : ra x y) => Quot.sound <| h h\u2081\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 \u2192 quot ra'`. -/\nprotected def mapRight {ra' : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : \u2200 a\u2081 a\u2082, ra a\u2081 a\u2082 \u2192 ra' a\u2081 a\u2082) :\n    Quot ra \u2192 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 {\u03b1 : Type _} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) : Quot r \u2192 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 {\u03b1 : Type _} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) :\n    factor r s h \u2218 Quot.mk _ = Quot.mk _ :=\n  rfl\n#align quot.factor_mk_eq Quot.factor_mk_eq\n-/\n\nvariable {\u03b3 : Sort _} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 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\u2093'. -/\n#print Quot.lift_mk /-\n/-- **Alias** of `quot.lift_beta`. -/\ntheorem lift_mk (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) (a : \u03b1) :\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 : \u03b1) (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) :\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 : \u03b1 \u2192 \u03b3} (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) :\n    Surjective (lift f h) \u2194 Surjective f :=\n  \u27e8fun hf => hf.comp Quot.exists_rep, fun hf y =>\n    let \u27e8x, hx\u27e9 := hf y\n    \u27e8Quot.mk _ x, hx\u27e9\u27e9\n#align quot.surjective_lift Quot.surjective_lift\n-/\n\n#print Quot.lift\u2082 /-\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2`. -/\n@[reducible, elab_as_elim]\nprotected def lift\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) (q\u2081 : Quot r) (q\u2082 : Quot s) : \u03b3 :=\n  Quot.lift (fun a => Quot.lift (f a) (hr a))\n    (fun a\u2081 a\u2082 ha => funext fun q => Quot.inductionOn q fun b => hs a\u2081 a\u2082 b ha) q\u2081 q\u2082\n#align quot.lift\u2082 Quot.lift\u2082\n-/\n\n/- warning: quot.lift\u2082_mk -> Quot.lift\u2082_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} (f : \u03b1 -> \u03b2 -> \u03b3) (hr : forall (a : \u03b1) (b\u2081 : \u03b2) (b\u2082 : \u03b2), (s b\u2081 b\u2082) -> (Eq.{u3} \u03b3 (f a b\u2081) (f a b\u2082))) (hs : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b : \u03b2), (r a\u2081 a\u2082) -> (Eq.{u3} \u03b3 (f a\u2081 b) (f a\u2082 b))) (a : \u03b1) (b : \u03b2), Eq.{u3} \u03b3 (Quot.lift\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a\u2081 : \u03b1) (a\u2082 : \u03b1) => r a\u2081 a\u2082) (fun (b\u2081 : \u03b2) (b\u2082 : \u03b2) => s b\u2081 b\u2082) f hr hs (Quot.mk.{u1} \u03b1 r a) (Quot.mk.{u2} \u03b2 s b)) (f a b)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {\u03b3 : Sort.{u3}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} (f : \u03b1 -> \u03b2 -> \u03b3) (hr : forall (a : \u03b1) (b\u2081 : \u03b2) (b\u2082 : \u03b2), (s b\u2081 b\u2082) -> (Eq.{u3} \u03b3 (f a b\u2081) (f a b\u2082))) (hs : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b : \u03b2), (r a\u2081 a\u2082) -> (Eq.{u3} \u03b3 (f a\u2081 b) (f a\u2082 b))) (a : \u03b1) (b : \u03b2), Eq.{u3} \u03b3 (Quot.lift\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a\u2081 : \u03b1) (a\u2082 : \u03b1) => r a\u2081 a\u2082) (fun (b\u2081 : \u03b2) (b\u2082 : \u03b2) => s b\u2081 b\u2082) f hr hs (Quot.mk.{u2} \u03b1 r a) (Quot.mk.{u1} \u03b2 s b)) (f a b)\nCase conversion may be inaccurate. Consider using '#align quot.lift\u2082_mk Quot.lift\u2082_mk\u2093'. -/\n@[simp]\ntheorem lift\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) (a : \u03b1) (b : \u03b2) :\n    Quot.lift\u2082 f hr hs (Quot.mk r a) (Quot.mk s b) = f a b :=\n  rfl\n#align quot.lift\u2082_mk Quot.lift\u2082_mk\n\n#print Quot.liftOn\u2082 /-\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` and applies it. -/\n@[reducible, elab_as_elim]\nprotected def liftOn\u2082 (p : Quot r) (q : Quot s) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n    (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082) (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) : \u03b3 :=\n  Quot.lift\u2082 f hr hs p q\n#align quot.lift_on\u2082 Quot.liftOn\u2082\n-/\n\n/- warning: quot.lift_on\u2082_mk -> Quot.liftOn\u2082_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} (a : \u03b1) (b : \u03b2) (f : \u03b1 -> \u03b2 -> \u03b3) (hr : forall (a : \u03b1) (b\u2081 : \u03b2) (b\u2082 : \u03b2), (s b\u2081 b\u2082) -> (Eq.{u3} \u03b3 (f a b\u2081) (f a b\u2082))) (hs : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b : \u03b2), (r a\u2081 a\u2082) -> (Eq.{u3} \u03b3 (f a\u2081 b) (f a\u2082 b))), Eq.{u3} \u03b3 (Quot.liftOn\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 r s (Quot.mk.{u1} \u03b1 r a) (Quot.mk.{u2} \u03b2 s b) f hr hs) (f a b)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {\u03b3 : Sort.{u3}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} (a : \u03b1) (b : \u03b2) (f : \u03b1 -> \u03b2 -> \u03b3) (hr : forall (a : \u03b1) (b\u2081 : \u03b2) (b\u2082 : \u03b2), (s b\u2081 b\u2082) -> (Eq.{u3} \u03b3 (f a b\u2081) (f a b\u2082))) (hs : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b : \u03b2), (r a\u2081 a\u2082) -> (Eq.{u3} \u03b3 (f a\u2081 b) (f a\u2082 b))), Eq.{u3} \u03b3 (Quot.liftOn\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 r s (Quot.mk.{u2} \u03b1 r a) (Quot.mk.{u1} \u03b2 s b) f hr hs) (f a b)\nCase conversion may be inaccurate. Consider using '#align quot.lift_on\u2082_mk Quot.liftOn\u2082_mk\u2093'. -/\n@[simp]\ntheorem liftOn\u2082_mk (a : \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) :\n    Quot.liftOn\u2082 (Quot.mk r a) (Quot.mk s b) f hr hs = f a b :=\n  rfl\n#align quot.lift_on\u2082_mk Quot.liftOn\u2082_mk\n\nvariable {t : \u03b3 \u2192 \u03b3 \u2192 Prop}\n\n#print Quot.map\u2082 /-\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` wih values in a quotient of\n`\u03b3`. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b)) (q\u2081 : Quot r) (q\u2082 : Quot s) : Quot t :=\n  Quot.lift\u2082 (fun a b => Quot.mk t <| f a b) (fun a b\u2081 b\u2082 hb => Quot.sound (hr a b\u2081 b\u2082 hb))\n    (fun a\u2081 a\u2082 b ha => Quot.sound (hs a\u2081 a\u2082 b ha)) q\u2081 q\u2082\n#align quot.map\u2082 Quot.map\u2082\n-/\n\n/- warning: quot.map\u2082_mk -> Quot.map\u2082_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} {t : \u03b3 -> \u03b3 -> Prop} (f : \u03b1 -> \u03b2 -> \u03b3) (hr : forall (a : \u03b1) (b\u2081 : \u03b2) (b\u2082 : \u03b2), (s b\u2081 b\u2082) -> (t (f a b\u2081) (f a b\u2082))) (hs : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b : \u03b2), (r a\u2081 a\u2082) -> (t (f a\u2081 b) (f a\u2082 b))) (a : \u03b1) (b : \u03b2), Eq.{u3} (Quot.{u3} \u03b3 t) (Quot.map\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a\u2081 : \u03b1) (a\u2082 : \u03b1) => r a\u2081 a\u2082) (fun (b\u2081 : \u03b2) (b\u2082 : \u03b2) => s b\u2081 b\u2082) t f hr hs (Quot.mk.{u1} \u03b1 r a) (Quot.mk.{u2} \u03b2 s b)) (Quot.mk.{u3} \u03b3 t (f a b))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {\u03b3 : Sort.{u3}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} {t : \u03b3 -> \u03b3 -> Prop} (f : \u03b1 -> \u03b2 -> \u03b3) (hr : forall (a : \u03b1) (b\u2081 : \u03b2) (b\u2082 : \u03b2), (s b\u2081 b\u2082) -> (t (f a b\u2081) (f a b\u2082))) (hs : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b : \u03b2), (r a\u2081 a\u2082) -> (t (f a\u2081 b) (f a\u2082 b))) (a : \u03b1) (b : \u03b2), Eq.{u3} (Quot.{u3} \u03b3 t) (Quot.map\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a\u2081 : \u03b1) (a\u2082 : \u03b1) => r a\u2081 a\u2082) (fun (b\u2081 : \u03b2) (b\u2082 : \u03b2) => s b\u2081 b\u2082) t f hr hs (Quot.mk.{u2} \u03b1 r a) (Quot.mk.{u1} \u03b2 s b)) (Quot.mk.{u3} \u03b3 t (f a b))\nCase conversion may be inaccurate. Consider using '#align quot.map\u2082_mk Quot.map\u2082_mk\u2093'. -/\n@[simp]\ntheorem map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n    (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b)) (a : \u03b1) (b : \u03b2) :\n    Quot.map\u2082 f hr hs (Quot.mk r a) (Quot.mk s b) = Quot.mk t (f a b) :=\n  rfl\n#align quot.map\u2082_mk Quot.map\u2082_mk\n\n#print Quot.recOnSubsingleton\u2082 /-\n/-- A binary version of `quot.rec_on_subsingleton`. -/\n@[reducible, elab_as_elim]\nprotected def recOnSubsingleton\u2082 {\u03c6 : Quot r \u2192 Quot s \u2192 Sort _}\n    [h : \u2200 a b, Subsingleton (\u03c6 \u27e6a\u27e7 \u27e6b\u27e7)] (q\u2081 : Quot r) (q\u2082 : Quot s) (f : \u2200 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7) :\n    \u03c6 q\u2081 q\u2082 :=\n  @Quot.recOnSubsingleton' _ r (fun q => \u03c6 q q\u2082) (fun a => Quot.ind (h a) q\u2082) q\u2081 fun a =>\n    Quot.recOnSubsingleton' q\u2082 fun b => f a b\n#align quot.rec_on_subsingleton\u2082 Quot.recOnSubsingleton\u2082\n-/\n\n/- warning: quot.induction_on\u2082 -> Quot.induction_on\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} {\u03b4 : (Quot.{u1} \u03b1 r) -> (Quot.{u2} \u03b2 s) -> Prop} (q\u2081 : Quot.{u1} \u03b1 r) (q\u2082 : Quot.{u2} \u03b2 s), (forall (a : \u03b1) (b : \u03b2), \u03b4 (Quot.mk.{u1} \u03b1 r a) (Quot.mk.{u2} \u03b2 s b)) -> (\u03b4 q\u2081 q\u2082)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} {\u03b4 : (Quot.{u2} \u03b1 r) -> (Quot.{u1} \u03b2 s) -> Prop} (q\u2081 : Quot.{u2} \u03b1 r) (q\u2082 : Quot.{u1} \u03b2 s), (forall (a : \u03b1) (b : \u03b2), \u03b4 (Quot.mk.{u2} \u03b1 r a) (Quot.mk.{u1} \u03b2 s b)) -> (\u03b4 q\u2081 q\u2082)\nCase conversion may be inaccurate. Consider using '#align quot.induction_on\u2082 Quot.induction_on\u2082\u2093'. -/\n@[elab_as_elim]\nprotected theorem induction_on\u2082 {\u03b4 : Quot r \u2192 Quot s \u2192 Prop} (q\u2081 : Quot r) (q\u2082 : Quot s)\n    (h : \u2200 a b, \u03b4 (Quot.mk r a) (Quot.mk s b)) : \u03b4 q\u2081 q\u2082 :=\n  Quot.ind (fun a\u2081 => Quot.ind (fun a\u2082 => h a\u2081 a\u2082) q\u2082) q\u2081\n#align quot.induction_on\u2082 Quot.induction_on\u2082\n\n/- warning: quot.induction_on\u2083 -> Quot.induction_on\u2083 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} {t : \u03b3 -> \u03b3 -> Prop} {\u03b4 : (Quot.{u1} \u03b1 r) -> (Quot.{u2} \u03b2 s) -> (Quot.{u3} \u03b3 t) -> Prop} (q\u2081 : Quot.{u1} \u03b1 r) (q\u2082 : Quot.{u2} \u03b2 s) (q\u2083 : Quot.{u3} \u03b3 t), (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), \u03b4 (Quot.mk.{u1} \u03b1 r a) (Quot.mk.{u2} \u03b2 s b) (Quot.mk.{u3} \u03b3 t c)) -> (\u03b4 q\u2081 q\u2082 q\u2083)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u1}} {r : \u03b1 -> \u03b1 -> Prop} {s : \u03b2 -> \u03b2 -> Prop} {t : \u03b3 -> \u03b3 -> Prop} {\u03b4 : (Quot.{u3} \u03b1 r) -> (Quot.{u2} \u03b2 s) -> (Quot.{u1} \u03b3 t) -> Prop} (q\u2081 : Quot.{u3} \u03b1 r) (q\u2082 : Quot.{u2} \u03b2 s) (q\u2083 : Quot.{u1} \u03b3 t), (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), \u03b4 (Quot.mk.{u3} \u03b1 r a) (Quot.mk.{u2} \u03b2 s b) (Quot.mk.{u1} \u03b3 t c)) -> (\u03b4 q\u2081 q\u2082 q\u2083)\nCase conversion may be inaccurate. Consider using '#align quot.induction_on\u2083 Quot.induction_on\u2083\u2093'. -/\n@[elab_as_elim]\nprotected theorem induction_on\u2083 {\u03b4 : Quot r \u2192 Quot s \u2192 Quot t \u2192 Prop} (q\u2081 : Quot r) (q\u2082 : Quot s)\n    (q\u2083 : Quot t) (h : \u2200 a b c, \u03b4 (Quot.mk r a) (Quot.mk s b) (Quot.mk t c)) : \u03b4 q\u2081 q\u2082 q\u2083 :=\n  Quot.ind (fun a\u2081 => Quot.ind (fun a\u2082 => Quot.ind (fun a\u2083 => h a\u2081 a\u2082 a\u2083) q\u2083) q\u2082) q\u2081\n#align quot.induction_on\u2083 Quot.induction_on\u2083\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (f : \u03b1 \u2192 Prop) (h : \u2200 a b, r a b \u2192 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\u2082 f ha hb)` when `\u03b1 = \u03b2`. -/\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (ha : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082) (hb : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b)\n    [hf : \u2200 a, DecidablePred (f a)] (q\u2081 : Quot r) : DecidablePred (Quot.lift\u2082 f ha hb q\u2081) :=\n  fun q\u2082 => Quot.recOnSubsingleton\u2082 q\u2081 q\u2082 hf\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (q : Quot r) (f : \u03b1 \u2192 Prop) (h : \u2200 a b, r a b \u2192 f a = f b)\n    [DecidablePred f] : Decidable (Quot.liftOn q f h) :=\n  Quot.lift.decidablePred _ _ _ _\n\ninstance (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) (q\u2081 : Quot r) (q\u2082 : Quot s) (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (ha : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082) (hb : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b)\n    [\u2200 a, DecidablePred (f a)] : Decidable (Quot.liftOn\u2082 q\u2081 q\u2082 f ha hb) :=\n  Quot.lift\u2082.decidablePred _ _ _ _ _ _ _\n\nend Quot\n\nnamespace Quotient\n\nvariable [sa : Setoid \u03b1] [sb : Setoid \u03b2]\n\nvariable {\u03c6 : Quotient sa \u2192 Quotient sb \u2192 Sort _}\n\ninstance (s : Setoid \u03b1) [Inhabited \u03b1] : Inhabited (Quotient s) :=\n  \u27e8\u27e6default\u27e7\u27e9\n\ninstance (s : Setoid \u03b1) [Subsingleton \u03b1] : Subsingleton (Quotient s) :=\n  Quot.Subsingleton\n\ninstance {\u03b1 : Type _} [Setoid \u03b1] : IsEquiv \u03b1 (\u00b7 \u2248 \u00b7)\n    where\n  refl := Setoid.refl\n  symm a b := Setoid.symm\n  trans a b c := Setoid.trans\n\n#print Quotient.hrecOn\u2082 /-\n/-- Induction on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrecOn\u2082 (qa : Quotient sa) (qb : Quotient sb) (f : \u2200 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n    (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 HEq (f a\u2081 b\u2081) (f a\u2082 b\u2082)) : \u03c6 qa qb :=\n  Quot.hrecOn\u2082 qa qb f (fun _ _ _ p => c _ _ _ _ p (Setoid.refl _)) fun _ _ _ p =>\n    c _ _ _ _ (Setoid.refl _) p\n#align quotient.hrec_on\u2082 Quotient.hrecOn\u2082\n-/\n\n#print Quotient.map /-\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `quotient sa \u2192 quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : ((\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7)) f f) : Quotient sa \u2192 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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [sa : Setoid.{u1} \u03b1] [sb : Setoid.{u2} \u03b2] (f : \u03b1 -> \u03b2) (h : Relator.LiftFun.{u1, u1, u2, u2} \u03b1 \u03b1 \u03b2 \u03b2 (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 sa)) (HasEquiv\u2093.Equiv.{u2} \u03b2 (setoidHasEquiv.{u2} \u03b2 sb)) f f) (x : \u03b1), Eq.{u2} (Quotient.{u2} \u03b2 sb) (Quotient.map.{u1, u2} \u03b1 \u03b2 sa sb f h (Quotient.mk'.{u1} \u03b1 sa x)) (Quotient.mk'.{u2} \u03b2 sb (f x))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [sa : Setoid.{u2} \u03b1] [sb : Setoid.{u1} \u03b2] (f : \u03b1 -> \u03b2) (h : Relator.LiftFun.{u2, u2, u1, u1} \u03b1 \u03b1 \u03b2 \u03b2 (fun (x._@.Mathlib.Data.Quot._hyg.4515 : \u03b1) (x._@.Mathlib.Data.Quot._hyg.4517 : \u03b1) => HasEquiv.Equiv.{u2, 0} \u03b1 (instHasEquiv.{u2} \u03b1 sa) x._@.Mathlib.Data.Quot._hyg.4515 x._@.Mathlib.Data.Quot._hyg.4517) (fun (x._@.Mathlib.Data.Quot._hyg.4530 : \u03b2) (x._@.Mathlib.Data.Quot._hyg.4532 : \u03b2) => HasEquiv.Equiv.{u1, 0} \u03b2 (instHasEquiv.{u1} \u03b2 sb) x._@.Mathlib.Data.Quot._hyg.4530 x._@.Mathlib.Data.Quot._hyg.4532) f f) (x : \u03b1), Eq.{u1} (Quotient.{u1} \u03b2 sb) (Quotient.map.{u2, u1} \u03b1 \u03b2 sa sb f h (Quotient.mk.{u2} \u03b1 sa x)) (Quotient.mk.{u1} \u03b2 sb (f x))\nCase conversion may be inaccurate. Consider using '#align quotient.map_mk Quotient.map_mk\u2093'. -/\n@[simp]\ntheorem map_mk (f : \u03b1 \u2192 \u03b2) (h : ((\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7)) f f) (x : \u03b1) :\n    Quotient.map f h (\u27e6x\u27e7 : Quotient sa) = (\u27e6f x\u27e7 : Quotient sb) :=\n  rfl\n#align quotient.map_mk Quotient.map_mk\n\nvariable {\u03b3 : Sort _} [sc : Setoid \u03b3]\n\n#print Quotient.map\u2082 /-\n/-- Map a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` that sends equivalent elements to equivalent elements\nto a function `f : quotient sa \u2192 quotient sb \u2192 quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7)) f f) :\n    Quotient sa \u2192 Quotient sb \u2192 Quotient sc :=\n  Quotient.lift\u2082 (fun x y => \u27e6f x y\u27e7) fun x\u2081 y\u2081 x\u2082 y\u2082 h\u2081 h\u2082 => Quot.sound <| h h\u2081 h\u2082\n#align quotient.map\u2082 Quotient.map\u2082\n-/\n\n/- warning: quotient.map\u2082_mk -> Quotient.map\u2082_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [sa : Setoid.{u1} \u03b1] [sb : Setoid.{u2} \u03b2] {\u03b3 : Sort.{u3}} [sc : Setoid.{u3} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (h : Relator.LiftFun.{u1, u1, imax u2 u3, imax u2 u3} \u03b1 \u03b1 (\u03b2 -> \u03b3) (\u03b2 -> \u03b3) (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 sa)) (Relator.LiftFun.{u2, u2, u3, u3} \u03b2 \u03b2 \u03b3 \u03b3 (HasEquiv\u2093.Equiv.{u2} \u03b2 (setoidHasEquiv.{u2} \u03b2 sb)) (HasEquiv\u2093.Equiv.{u3} \u03b3 (setoidHasEquiv.{u3} \u03b3 sc))) f f) (x : \u03b1) (y : \u03b2), Eq.{u3} (Quotient.{u3} \u03b3 sc) (Quotient.map\u2082.{u1, u2, u3} \u03b1 \u03b2 sa sb \u03b3 sc f h (Quotient.mk'.{u1} \u03b1 sa x) (Quotient.mk'.{u2} \u03b2 sb y)) (Quotient.mk'.{u3} \u03b3 sc (f x y))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} [sa : Setoid.{u3} \u03b1] [sb : Setoid.{u2} \u03b2] {\u03b3 : Sort.{u1}} [sc : Setoid.{u1} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (h : Relator.LiftFun.{u3, u3, imax u2 u1, imax u2 u1} \u03b1 \u03b1 (\u03b2 -> \u03b3) (\u03b2 -> \u03b3) (fun (x._@.Mathlib.Data.Quot._hyg.4742 : \u03b1) (x._@.Mathlib.Data.Quot._hyg.4744 : \u03b1) => HasEquiv.Equiv.{u3, 0} \u03b1 (instHasEquiv.{u3} \u03b1 sa) x._@.Mathlib.Data.Quot._hyg.4742 x._@.Mathlib.Data.Quot._hyg.4744) (Relator.LiftFun.{u2, u2, u1, u1} \u03b2 \u03b2 \u03b3 \u03b3 (fun (x._@.Mathlib.Data.Quot._hyg.4760 : \u03b2) (x._@.Mathlib.Data.Quot._hyg.4762 : \u03b2) => HasEquiv.Equiv.{u2, 0} \u03b2 (instHasEquiv.{u2} \u03b2 sb) x._@.Mathlib.Data.Quot._hyg.4760 x._@.Mathlib.Data.Quot._hyg.4762) (fun (x._@.Mathlib.Data.Quot._hyg.4775 : \u03b3) (x._@.Mathlib.Data.Quot._hyg.4777 : \u03b3) => HasEquiv.Equiv.{u1, 0} \u03b3 (instHasEquiv.{u1} \u03b3 sc) x._@.Mathlib.Data.Quot._hyg.4775 x._@.Mathlib.Data.Quot._hyg.4777)) f f) (x : \u03b1) (y : \u03b2), Eq.{u1} (Quotient.{u1} \u03b3 sc) (Quotient.map\u2082.{u3, u2, u1} \u03b1 \u03b2 sa sb \u03b3 sc f h (Quotient.mk.{u3} \u03b1 sa x) (Quotient.mk.{u2} \u03b2 sb y)) (Quotient.mk.{u1} \u03b3 sc (f x y))\nCase conversion may be inaccurate. Consider using '#align quotient.map\u2082_mk Quotient.map\u2082_mk\u2093'. -/\n@[simp]\ntheorem map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7) \u21d2 (\u00b7 \u2248 \u00b7)) f f) (x : \u03b1) (y : \u03b2) :\n    Quotient.map\u2082 f h (\u27e6x\u27e7 : Quotient sa) (\u27e6y\u27e7 : Quotient sb) = (\u27e6f x y\u27e7 : Quotient sc) :=\n  rfl\n#align quotient.map\u2082_mk Quotient.map\u2082_mk\n\ninclude sa\n\ninstance (f : \u03b1 \u2192 Prop) (h : \u2200 a b, a \u2248 b \u2192 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\u2082 f h)` when `\u03b1 = \u03b2`. -/\ninstance (f : \u03b1 \u2192 \u03b2 \u2192 Prop) (h : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 = f a\u2082 b\u2082)\n    [hf : \u2200 a, DecidablePred (f a)] (q\u2081 : Quotient sa) : DecidablePred (Quotient.lift\u2082 f h q\u2081) :=\n  fun q\u2082 => Quotient.recOnSubsingleton\u2082 q\u2081 q\u2082 hf\n\nomit sb\n\ninstance (q : Quotient sa) (f : \u03b1 \u2192 Prop) (h : \u2200 a b, a \u2248 b \u2192 f a = f b) [DecidablePred f] :\n    Decidable (Quotient.liftOn q f h) :=\n  Quotient.lift.decidablePred _ _ _\n\ninstance (q\u2081 : Quotient sa) (q\u2082 : Quotient sb) (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (h : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 = f a\u2082 b\u2082) [\u2200 a, DecidablePred (f a)] :\n    Decidable (Quotient.liftOn\u2082 q\u2081 q\u2082 f h) :=\n  Quotient.lift\u2082.decidablePred _ _ _ _\n\nend Quotient\n\n#print Quot.eq /-\ntheorem Quot.eq {\u03b1 : Type _} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {x y : \u03b1} :\n    Quot.mk r x = Quot.mk r y \u2194 EqvGen r x y :=\n  \u27e8Quot.exact r, Quot.EqvGen_sound\u27e9\n#align quot.eq Quot.eq\n-/\n\n#print Quotient.eq' /-\n@[simp]\ntheorem Quotient.eq' [r : Setoid \u03b1] {x y : \u03b1} : \u27e6x\u27e7 = \u27e6y\u27e7 \u2194 x \u2248 y :=\n  \u27e8Quotient.exact, Quotient.sound\u27e9\n#align quotient.eq Quotient.eq'\n-/\n\n#print forall_quotient_iff /-\ntheorem forall_quotient_iff {\u03b1 : Type _} [r : Setoid \u03b1] {p : Quotient r \u2192 Prop} :\n    (\u2200 a : Quotient r, p a) \u2194 \u2200 a : \u03b1, p \u27e6a\u27e7 :=\n  \u27e8fun h x => h _, fun h a => a.inductionOn h\u27e9\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [s : Setoid.{u1} \u03b1] (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1) (b : \u03b1), (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 s) a b) -> (Eq.{u2} \u03b2 (f a) (f b))) (x : \u03b1), Eq.{u2} \u03b2 (Quotient.lift.{u1, u2} \u03b1 \u03b2 s f h (Quotient.mk'.{u1} \u03b1 s x)) (f x)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [s : Setoid.{u2} \u03b1] (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1) (b : \u03b1), (HasEquiv.Equiv.{u2, 0} \u03b1 (instHasEquiv.{u2} \u03b1 s) a b) -> (Eq.{u1} \u03b2 (f a) (f b))) (x : \u03b1), Eq.{u1} \u03b2 (Quotient.lift.{u2, u1} \u03b1 \u03b2 s f h (Quotient.mk.{u2} \u03b1 s x)) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_mk Quotient.lift_mk\u2093'. -/\n@[simp]\ntheorem Quotient.lift_mk [s : Setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 a b : \u03b1, a \u2248 b \u2192 f a = f b) (x : \u03b1) :\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Setoid.{u1} \u03b1] (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1) (b : \u03b1), (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 _inst_1) a b) -> (Eq.{u2} \u03b2 (f a) (f b))), Eq.{imax u1 u2} (\u03b1 -> \u03b2) (Function.comp.{u1, u1, u2} \u03b1 (Quotient.{u1} \u03b1 _inst_1) \u03b2 (Quotient.lift.{u1, u2} \u03b1 \u03b2 _inst_1 f h) (Quotient.mk'.{u1} \u03b1 _inst_1)) f\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [_inst_1 : Setoid.{u2} \u03b1] (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1) (b : \u03b1), (HasEquiv.Equiv.{u2, 0} \u03b1 (instHasEquiv.{u2} \u03b1 _inst_1) a b) -> (Eq.{u1} \u03b2 (f a) (f b))), Eq.{imax u2 u1} (\u03b1 -> \u03b2) (Function.comp.{u2, u2, u1} \u03b1 (Quotient.{u2} \u03b1 _inst_1) \u03b2 (Quotient.lift.{u2, u1} \u03b1 \u03b2 _inst_1 f h) (Quotient.mk.{u2} \u03b1 _inst_1)) f\nCase conversion may be inaccurate. Consider using '#align quotient.lift_comp_mk Quotient.lift_comp_mk\u2093'. -/\n@[simp]\ntheorem Quotient.lift_comp_mk [Setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 a b : \u03b1, a \u2248 b \u2192 f a = f b) :\n    Quotient.lift f h \u2218 Quotient.mk' = f :=\n  rfl\n#align quotient.lift_comp_mk Quotient.lift_comp_mk\n\n/- warning: quotient.lift\u2082_mk -> Quotient.lift\u2082_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} [_inst_1 : Setoid.{u1} \u03b1] [_inst_2 : Setoid.{u2} \u03b2] (f : \u03b1 -> \u03b2 -> \u03b3) (h : forall (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 _inst_1) a\u2081 b\u2081) -> (HasEquiv\u2093.Equiv.{u2} \u03b2 (setoidHasEquiv.{u2} \u03b2 _inst_2) a\u2082 b\u2082) -> (Eq.{u3} \u03b3 (f a\u2081 a\u2082) (f b\u2081 b\u2082))) (a : \u03b1) (b : \u03b2), Eq.{u3} \u03b3 (Quotient.lift\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 f h (Quotient.mk'.{u1} \u03b1 _inst_1 a) (Quotient.mk'.{u2} \u03b2 _inst_2 b)) (f a b)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u1}} [_inst_1 : Setoid.{u3} \u03b1] [_inst_2 : Setoid.{u2} \u03b2] (f : \u03b1 -> \u03b2 -> \u03b3) (h : forall (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), (HasEquiv.Equiv.{u3, 0} \u03b1 (instHasEquiv.{u3} \u03b1 _inst_1) a\u2081 b\u2081) -> (HasEquiv.Equiv.{u2, 0} \u03b2 (instHasEquiv.{u2} \u03b2 _inst_2) a\u2082 b\u2082) -> (Eq.{u1} \u03b3 (f a\u2081 a\u2082) (f b\u2081 b\u2082))) (a : \u03b1) (b : \u03b2), Eq.{u1} \u03b3 (Quotient.lift\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 f h (Quotient.mk.{u3} \u03b1 _inst_1 a) (Quotient.mk.{u2} \u03b2 _inst_2 b)) (f a b)\nCase conversion may be inaccurate. Consider using '#align quotient.lift\u2082_mk Quotient.lift\u2082_mk\u2093'. -/\n@[simp]\ntheorem Quotient.lift\u2082_mk {\u03b1 : Sort _} {\u03b2 : Sort _} {\u03b3 : Sort _} [Setoid \u03b1] [Setoid \u03b2]\n    (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n    (h : \u2200 (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) (a : \u03b1)\n    (b : \u03b2) : Quotient.lift\u2082 f h (Quotient.mk' a) (Quotient.mk' b) = f a b :=\n  rfl\n#align quotient.lift\u2082_mk Quotient.lift\u2082_mk\n\n/- warning: quotient.lift_on_mk -> Quotient.liftOn_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [s : Setoid.{u1} \u03b1] (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1) (b : \u03b1), (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 s) a b) -> (Eq.{u2} \u03b2 (f a) (f b))) (x : \u03b1), Eq.{u2} \u03b2 (Quotient.liftOn.{u1, u2} \u03b1 \u03b2 s (Quotient.mk'.{u1} \u03b1 s x) f h) (f x)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [s : Setoid.{u2} \u03b1] (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1) (b : \u03b1), (HasEquiv.Equiv.{u2, 0} \u03b1 (instHasEquiv.{u2} \u03b1 s) a b) -> (Eq.{u1} \u03b2 (f a) (f b))) (x : \u03b1), Eq.{u1} \u03b2 (Quotient.liftOn.{u2, u1} \u03b1 \u03b2 s (Quotient.mk.{u2} \u03b1 s x) f h) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on_mk Quotient.liftOn_mk\u2093'. -/\n@[simp]\ntheorem Quotient.liftOn_mk [s : Setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 a b : \u03b1, a \u2248 b \u2192 f a = f b) (x : \u03b1) :\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\u2082_mk -> Quotient.liftOn\u2082_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Setoid.{u1} \u03b1] (f : \u03b1 -> \u03b1 -> \u03b2) (h : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b\u2081 : \u03b1) (b\u2082 : \u03b1), (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 _inst_1) a\u2081 b\u2081) -> (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 _inst_1) a\u2082 b\u2082) -> (Eq.{u2} \u03b2 (f a\u2081 a\u2082) (f b\u2081 b\u2082))) (x : \u03b1) (y : \u03b1), Eq.{u2} \u03b2 (Quotient.liftOn\u2082.{u1, u1, u2} \u03b1 \u03b1 \u03b2 _inst_1 _inst_1 (Quotient.mk'.{u1} \u03b1 _inst_1 x) (Quotient.mk'.{u1} \u03b1 _inst_1 y) f h) (f x y)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [_inst_1 : Setoid.{u2} \u03b1] (f : \u03b1 -> \u03b1 -> \u03b2) (h : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1) (b\u2081 : \u03b1) (b\u2082 : \u03b1), (HasEquiv.Equiv.{u2, 0} \u03b1 (instHasEquiv.{u2} \u03b1 _inst_1) a\u2081 b\u2081) -> (HasEquiv.Equiv.{u2, 0} \u03b1 (instHasEquiv.{u2} \u03b1 _inst_1) a\u2082 b\u2082) -> (Eq.{u1} \u03b2 (f a\u2081 a\u2082) (f b\u2081 b\u2082))) (x : \u03b1) (y : \u03b1), Eq.{u1} \u03b2 (Quotient.liftOn\u2082.{u2, u2, u1} \u03b1 \u03b1 \u03b2 _inst_1 _inst_1 (Quotient.mk.{u2} \u03b1 _inst_1 x) (Quotient.mk.{u2} \u03b1 _inst_1 y) f h) (f x y)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on\u2082_mk Quotient.liftOn\u2082_mk\u2093'. -/\n@[simp]\ntheorem Quotient.liftOn\u2082_mk {\u03b1 : Sort _} {\u03b2 : Sort _} [Setoid \u03b1] (f : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n    (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082 : \u03b1, a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) (x y : \u03b1) :\n    Quotient.liftOn\u2082 (Quotient.mk' x) (Quotient.mk' y) f h = f x y :=\n  rfl\n#align quotient.lift_on\u2082_mk Quotient.liftOn\u2082_mk\n\n#print surjective_quot_mk /-\n/-- `quot.mk r` is a surjective function. -/\ntheorem surjective_quot_mk (r : \u03b1 \u2192 \u03b1 \u2192 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 (\u03b1 : Sort _) [s : Setoid \u03b1] :\n    Surjective (Quotient.mk' : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} (q : Quot r) : \u03b1 :=\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 : \u03b1 \u2192 \u03b1 \u2192 Prop} : Quot r \u2192 \u03b1 :=\n  unchecked_cast\n#align quot.unquot quot.unquot\n\n#print Quot.out_eq /-\n@[simp]\ntheorem Quot.out_eq {r : \u03b1 \u2192 \u03b1 \u2192 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 \u03b1] : Quotient s \u2192 \u03b1 :=\n  Quot.out\n#align quotient.out Quotient.out\n-/\n\n#print Quotient.out_eq /-\n@[simp]\ntheorem Quotient.out_eq [s : Setoid \u03b1] (q : Quotient s) : \u27e6q.out\u27e7 = 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 \u03b1] (a : \u03b1) : \u27e6a\u27e7.out \u2248 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 \u03b1] {x : \u03b1} {y : Quotient s} :\n    \u27e6x\u27e7 = y \u2194 x \u2248 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 \u03b1] {x : Quotient s} {y : \u03b1} :\n    x = \u27e6y\u27e7 \u2194 Quotient.out x \u2248 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 \u03b1} {x y : Quotient s} : x.out \u2248 y.out \u2194 x = y := by\n  rw [\u2190 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 \u03b1} : Injective (@Quotient.out \u03b1 s) := fun a b h =>\n  Quotient.out_equiv_out.1 <| h \u25b8 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 \u03b1} {x y : Quotient s} : x.out = y.out \u2194 x = y :=\n  \u27e8fun h => Quotient.out_injective h, fun h => h \u25b8 rfl\u27e9\n#align quotient.out_inj Quotient.out_inj\n-/\n\nsection Pi\n\n#print piSetoid /-\ninstance piSetoid {\u03b9 : Sort _} {\u03b1 : \u03b9 \u2192 Sort _} [\u2200 i, Setoid (\u03b1 i)] : Setoid (\u2200 i, \u03b1 i)\n    where\n  R a b := \u2200 i, a i \u2248 b i\n  iseqv :=\n    \u27e8fun a i => Setoid.refl _, fun a b h i => Setoid.symm (h _), fun a b c h\u2081 h\u2082 i =>\n      Setoid.trans (h\u2081 _) (h\u2082 _)\u27e9\n#align pi_setoid piSetoid\n-/\n\n#print Quotient.choice /-\n/-- Given a function `f : \u03a0 i, quotient (S i)`, returns the class of functions `\u03a0 i, \u03b1 i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def Quotient.choice {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [S : \u2200 i, Setoid (\u03b1 i)]\n    (f : \u2200 i, Quotient (S i)) : @Quotient (\u2200 i, \u03b1 i) (by infer_instance) :=\n  \u27e6fun i => (f i).out\u27e7\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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Type.{u2}} [_inst_1 : forall (i : \u03b9), Setoid.{succ u2} (\u03b1 i)] (f : forall (i : \u03b9), \u03b1 i), Eq.{max (succ u1) (succ u2)} (Quotient.{max (succ u1) (succ u2)} (forall (i : \u03b9), \u03b1 i) (piSetoid.{succ u1, succ u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i))) (Quotient.choice.{u1, u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) => Quotient.mk'.{succ u2} (\u03b1 i) (_inst_1 i) (f i))) (Quotient.mk'.{max (succ u1) (succ u2)} (forall (i : \u03b9), \u03b1 i) (piSetoid.{succ u1, succ u2} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)) f)\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Type.{u1}} [_inst_1 : forall (i : \u03b9), Setoid.{succ u1} (\u03b1 i)] (f : forall (i : \u03b9), \u03b1 i), Eq.{max (succ u2) (succ u1)} (Quotient.{max (succ u2) (succ u1)} (forall (i : \u03b9), \u03b1 i) (inferInstance.{max (succ u2) (succ u1)} (Setoid.{max (succ u2) (succ u1)} (forall (i : \u03b9), \u03b1 i)) (piSetoid.{succ u2, succ u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i)))) (Quotient.choice.{u2, u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i) (fun (i : \u03b9) => Quotient.mk.{succ u1} (\u03b1 i) (_inst_1 i) (f i))) (Quotient.mk.{max (succ u2) (succ u1)} (forall (i : \u03b9), \u03b1 i) (inferInstance.{max (succ u2) (succ u1)} (Setoid.{max (succ u2) (succ u1)} (forall (i : \u03b9), \u03b1 i)) (piSetoid.{succ u2, succ u1} \u03b9 (fun (i : \u03b9) => \u03b1 i) (fun (i : \u03b9) => _inst_1 i))) f)\nCase conversion may be inaccurate. Consider using '#align quotient.choice_eq Quotient.choice_eq\u2093'. -/\n@[simp]\ntheorem Quotient.choice_eq {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, Setoid (\u03b1 i)] (f : \u2200 i, \u03b1 i) :\n    (Quotient.choice fun i => \u27e6f i\u27e7) = \u27e6f\u27e7 :=\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 {\u03b9 : Type.{u1}} {\u03b1 : \u03b9 -> Sort.{u2}} [s : forall (i : \u03b9), Setoid.{u2} (\u03b1 i)] {p : (forall (i : \u03b9), Quotient.{u2} (\u03b1 i) (s i)) -> Prop} (f : forall (i : \u03b9), Quotient.{u2} (\u03b1 i) (s i)), (forall (a : forall (i : \u03b9), \u03b1 i), p (fun (i : \u03b9) => Quotient.mk'.{u2} (\u03b1 i) (s i) (a i))) -> (p f)\nbut is expected to have type\n  forall {\u03b9 : Type.{u2}} {\u03b1 : \u03b9 -> Sort.{u1}} [s : forall (i : \u03b9), Setoid.{u1} (\u03b1 i)] {p : (forall (i : \u03b9), Quotient.{u1} (\u03b1 i) (s i)) -> Prop} (f : forall (i : \u03b9), Quotient.{u1} (\u03b1 i) (s i)), (forall (a : forall (i : \u03b9), \u03b1 i), p (fun (i : \u03b9) => Quotient.mk.{u1} (\u03b1 i) (s i) (a i))) -> (p f)\nCase conversion may be inaccurate. Consider using '#align quotient.induction_on_pi Quotient.induction_on_pi\u2093'. -/\n@[elab_as_elim]\ntheorem Quotient.induction_on_pi {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Sort _} [s : \u2200 i, Setoid (\u03b1 i)]\n    {p : (\u2200 i, Quotient (s i)) \u2192 Prop} (f : \u2200 i, Quotient (s i))\n    (h : \u2200 a : \u2200 i, \u03b1 i, p fun i => \u27e6a i\u27e7) : p f :=\n  by\n  rw [\u2190 (funext fun i => Quotient.out_eq (f i) : (fun i => \u27e6(f i).out\u27e7) = 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 \u03b1) : Nonempty (Quotient s) \u2194 Nonempty \u03b1 :=\n  \u27e8fun \u27e8a\u27e9 => Quotient.inductionOn a Nonempty.intro, fun \u27e8a\u27e9 => \u27e8\u27e6a\u27e7\u27e9\u27e9\n#align nonempty_quotient_iff nonempty_quotient_iff\n-/\n\n/-! ### Truncation -/\n\n\n#print true_equivalence /-\ntheorem true_equivalence : @Equivalence \u03b1 fun _ _ => True :=\n  \u27e8fun _ => trivial, fun _ _ _ => trivial, fun _ _ _ _ _ => trivial\u27e9\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 `\u22a4 : setoid \u03b1`. -/\ndef trueSetoid : Setoid \u03b1 :=\n  \u27e8_, true_equivalence\u27e9\n#align true_setoid trueSetoid\n-/\n\n#print Trunc /-\n/-- `trunc \u03b1` is the quotient of `\u03b1` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty \u03b1`, but unlike `nonempty \u03b1`, `trunc \u03b1` is data,\n  so the VM representation is the same as `\u03b1`, and so this can be used to\n  maintain computability. -/\ndef Trunc.{u} (\u03b1 : Sort u) : Sort u :=\n  @Quotient \u03b1 trueSetoid\n#align trunc Trunc\n-/\n\nnamespace Trunc\n\n#print Trunc.mk /-\n/-- Constructor for `trunc \u03b1` -/\ndef mk (a : \u03b1) : Trunc \u03b1 :=\n  Quot.mk _ a\n#align trunc.mk Trunc.mk\n-/\n\ninstance [Inhabited \u03b1] : Inhabited (Trunc \u03b1) :=\n  \u27e8mk default\u27e9\n\n#print Trunc.lift /-\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : \u03b1 \u2192 \u03b2) (c : \u2200 a b : \u03b1, f a = f b) : Trunc \u03b1 \u2192 \u03b2 :=\n  Quot.lift f fun a b _ => c a b\n#align trunc.lift Trunc.lift\n-/\n\n#print Trunc.ind /-\ntheorem ind {\u03b2 : Trunc \u03b1 \u2192 Prop} : (\u2200 a : \u03b1, \u03b2 (mk a)) \u2192 \u2200 q : Trunc \u03b1, \u03b2 q :=\n  Quot.ind\n#align trunc.ind Trunc.ind\n-/\n\n#print Trunc.lift_mk /-\nprotected theorem lift_mk (f : \u03b1 \u2192 \u03b2) (c) (a : \u03b1) : 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 \u03b1`. -/\n@[reducible, elab_as_elim]\nprotected def liftOn (q : Trunc \u03b1) (f : \u03b1 \u2192 \u03b2) (c : \u2200 a b : \u03b1, f a = f b) : \u03b2 :=\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 {\u03b2 : Trunc \u03b1 \u2192 Prop} (q : Trunc \u03b1) (h : \u2200 a, \u03b2 (mk a)) : \u03b2 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 \u03b1) : \u2203 a : \u03b1, mk a = q :=\n  Quot.exists_rep q\n#align trunc.exists_rep Trunc.exists_rep\n-/\n\n/- warning: trunc.induction_on\u2082 -> Trunc.induction_on\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {C : (Trunc.{u1} \u03b1) -> (Trunc.{u2} \u03b2) -> Prop} (q\u2081 : Trunc.{u1} \u03b1) (q\u2082 : Trunc.{u2} \u03b2), (forall (a : \u03b1) (b : \u03b2), C (Trunc.mk.{u1} \u03b1 a) (Trunc.mk.{u2} \u03b2 b)) -> (C q\u2081 q\u2082)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {C : (Trunc.{u2} \u03b1) -> (Trunc.{u1} \u03b2) -> Prop} (q\u2081 : Trunc.{u2} \u03b1) (q\u2082 : Trunc.{u1} \u03b2), (forall (a : \u03b1) (b : \u03b2), C (Trunc.mk.{u2} \u03b1 a) (Trunc.mk.{u1} \u03b2 b)) -> (C q\u2081 q\u2082)\nCase conversion may be inaccurate. Consider using '#align trunc.induction_on\u2082 Trunc.induction_on\u2082\u2093'. -/\n@[elab_as_elim]\nprotected theorem induction_on\u2082 {C : Trunc \u03b1 \u2192 Trunc \u03b2 \u2192 Prop} (q\u2081 : Trunc \u03b1) (q\u2082 : Trunc \u03b2)\n    (h : \u2200 a b, C (mk a) (mk b)) : C q\u2081 q\u2082 :=\n  Trunc.induction_on q\u2081 fun a\u2081 => Trunc.induction_on q\u2082 (h a\u2081)\n#align trunc.induction_on\u2082 Trunc.induction_on\u2082\n\n#print Trunc.eq /-\nprotected theorem eq (a b : Trunc \u03b1) : a = b :=\n  Trunc.induction_on\u2082 a b fun x y => Quot.sound trivial\n#align trunc.eq Trunc.eq\n-/\n\ninstance : Subsingleton (Trunc \u03b1) :=\n  \u27e8Trunc.eq\u27e9\n\n#print Trunc.bind /-\n/-- The `bind` operator for the `trunc` monad. -/\ndef bind (q : Trunc \u03b1) (f : \u03b1 \u2192 Trunc \u03b2) : Trunc \u03b2 :=\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 : \u03b1 \u2192 \u03b2` defines a function `map f : trunc \u03b1 \u2192 trunc \u03b2`. -/\ndef map (f : \u03b1 \u2192 \u03b2) (q : Trunc \u03b1) : Trunc \u03b2 :=\n  bind q (Trunc.mk \u2218 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 \u03b1 q := Trunc.eq _ _\n  pure_bind \u03b1 \u03b2 q f := rfl\n  bind_assoc \u03b1 \u03b2 \u03b3 x f g := Trunc.eq _ _\n\nvariable {C : Trunc \u03b1 \u2192 Sort _}\n\n#print Trunc.rec /-\n/-- Recursion/induction principle for `trunc`. -/\n@[reducible, elab_as_elim]\nprotected def rec (f : \u2200 a, C (mk a))\n    (h : \u2200 a b : \u03b1, (Eq.ndrec (f a) (Trunc.eq (mk a) (mk b)) : C (mk b)) = f b) (q : Trunc \u03b1) :\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 \u03b1` as the first argument. -/\n@[reducible, elab_as_elim]\nprotected def recOn (q : Trunc \u03b1) (f : \u2200 a, C (mk a))\n    (h : \u2200 a b : \u03b1, (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 [\u2200 a, Subsingleton (C (mk a))] (q : Trunc \u03b1) (f : \u2200 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 \u03b1` (using the axiom of choice). -/\nnoncomputable def out : Trunc \u03b1 \u2192 \u03b1 :=\n  Quot.out\n#align trunc.out Trunc.out\n-/\n\n#print Trunc.out_eq /-\n@[simp]\ntheorem out_eq (q : Trunc \u03b1) : 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 \u03b1) : Nonempty \u03b1 :=\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 {\u03b3 : Sort _} {\u03c6 : Sort _} {s\u2081 : Setoid \u03b1} {s\u2082 : Setoid \u03b2} {s\u2083 : Setoid \u03b3}\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 \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk'' (a : \u03b1) : Quotient s\u2081 :=\n  Quot.mk s\u2081.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'' : \u03b1 \u2192 Quotient s\u2081) :=\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 \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_elim, reducible]\nprotected def liftOn' (q : Quotient s\u2081) (f : \u03b1 \u2192 \u03c6) (h : \u2200 a b, @Setoid.r \u03b1 s\u2081 a b \u2192 f a = f b) :\n    \u03c6 :=\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 {\u03b1 : Sort.{u1}} {\u03c6 : Sort.{u2}} {s\u2081 : Setoid.{u1} \u03b1} (f : \u03b1 -> \u03c6) (h : forall (a : \u03b1) (b : \u03b1), (Setoid.r.{u1} \u03b1 s\u2081 a b) -> (Eq.{u2} \u03c6 (f a) (f b))) (x : \u03b1), Eq.{u2} \u03c6 (Quotient.liftOn'.{u1, u2} \u03b1 \u03c6 s\u2081 (Quotient.mk''.{u1} \u03b1 s\u2081 x) f h) (f x)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03c6 : Sort.{u1}} {s\u2081 : Setoid.{u2} \u03b1} (f : \u03b1 -> \u03c6) (h : forall (a : \u03b1) (b : \u03b1), (Setoid.r.{u2} \u03b1 s\u2081 a b) -> (Eq.{u1} \u03c6 (f a) (f b))) (x : \u03b1), Eq.{u1} \u03c6 (Quotient.liftOn'.{u2, u1} \u03b1 \u03c6 s\u2081 (Quotient.mk''.{u2} \u03b1 s\u2081 x) f h) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on'_mk' Quotient.liftOn'_mk''\u2093'. -/\n@[simp]\nprotected theorem liftOn'_mk'' (f : \u03b1 \u2192 \u03c6) (h) (x : \u03b1) :\n    Quotient.liftOn' (@Quotient.mk'' _ s\u2081 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 {\u03b1 : Sort.{u1}} {\u03c6 : Sort.{u2}} {s\u2081 : Setoid.{u1} \u03b1} {f : \u03b1 -> \u03c6} (h : forall (a : \u03b1) (b : \u03b1), (Setoid.r.{u1} \u03b1 s\u2081 a b) -> (Eq.{u2} \u03c6 (f a) (f b))), Iff (Function.Surjective.{u1, u2} (Quotient.{u1} \u03b1 s\u2081) \u03c6 (fun (x : Quotient.{u1} \u03b1 s\u2081) => Quotient.liftOn'.{u1, u2} \u03b1 \u03c6 s\u2081 x f h)) (Function.Surjective.{u1, u2} \u03b1 \u03c6 f)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03c6 : Sort.{u1}} {s\u2081 : Setoid.{u2} \u03b1} {f : \u03b1 -> \u03c6} (h : forall (a : \u03b1) (b : \u03b1), (Setoid.r.{u2} \u03b1 s\u2081 a b) -> (Eq.{u1} \u03c6 (f a) (f b))), Iff (Function.Surjective.{u2, u1} (Quotient.{u2} \u03b1 s\u2081) \u03c6 (fun (x : Quotient.{u2} \u03b1 s\u2081) => Quotient.liftOn'.{u2, u1} \u03b1 \u03c6 s\u2081 x f h)) (Function.Surjective.{u2, u1} \u03b1 \u03c6 f)\nCase conversion may be inaccurate. Consider using '#align quotient.surjective_lift_on' Quotient.surjective_liftOn'\u2093'. -/\n@[simp]\ntheorem surjective_liftOn' {f : \u03b1 \u2192 \u03c6} (h : \u2200 a b, @Setoid.r \u03b1 s\u2081 a b \u2192 f a = f b) :\n    (Surjective fun x => Quotient.liftOn' x f h) \u2194 Surjective f :=\n  Quot.surjective_lift _\n#align quotient.surjective_lift_on' Quotient.surjective_liftOn'\n\n#print Quotient.liftOn\u2082' /-\n/-- A version of `quotient.lift_on\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_elim, reducible]\nprotected def liftOn\u2082' (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n    (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082, @Setoid.r \u03b1 s\u2081 a\u2081 b\u2081 \u2192 @Setoid.r \u03b2 s\u2082 a\u2082 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) : \u03b3 :=\n  Quotient.liftOn\u2082 q\u2081 q\u2082 f h\n#align quotient.lift_on\u2082' Quotient.liftOn\u2082'\n-/\n\n/- warning: quotient.lift_on\u2082'_mk' -> Quotient.liftOn\u2082'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {s\u2081 : Setoid.{u1} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} (f : \u03b1 -> \u03b2 -> \u03b3) (h : forall (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), (Setoid.r.{u1} \u03b1 s\u2081 a\u2081 b\u2081) -> (Setoid.r.{u2} \u03b2 s\u2082 a\u2082 b\u2082) -> (Eq.{u3} \u03b3 (f a\u2081 a\u2082) (f b\u2081 b\u2082))) (a : \u03b1) (b : \u03b2), Eq.{u3} \u03b3 (Quotient.liftOn\u2082'.{u1, u2, u3} \u03b1 \u03b2 \u03b3 s\u2081 s\u2082 (Quotient.mk''.{u1} \u03b1 s\u2081 a) (Quotient.mk''.{u2} \u03b2 s\u2082 b) f h) (f a b)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u1}} {s\u2081 : Setoid.{u3} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} (f : \u03b1 -> \u03b2 -> \u03b3) (h : forall (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), (Setoid.r.{u3} \u03b1 s\u2081 a\u2081 b\u2081) -> (Setoid.r.{u2} \u03b2 s\u2082 a\u2082 b\u2082) -> (Eq.{u1} \u03b3 (f a\u2081 a\u2082) (f b\u2081 b\u2082))) (a : \u03b1) (b : \u03b2), Eq.{u1} \u03b3 (Quotient.liftOn\u2082'.{u3, u2, u1} \u03b1 \u03b2 \u03b3 s\u2081 s\u2082 (Quotient.mk''.{u3} \u03b1 s\u2081 a) (Quotient.mk''.{u2} \u03b2 s\u2082 b) f h) (f a b)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on\u2082'_mk' Quotient.liftOn\u2082'_mk''\u2093'. -/\n@[simp]\nprotected theorem liftOn\u2082'_mk'' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (a : \u03b1) (b : \u03b2) :\n    Quotient.liftOn\u2082' (@Quotient.mk'' _ s\u2081 a) (@Quotient.mk'' _ s\u2082 b) f h = f a b :=\n  rfl\n#align quotient.lift_on\u2082'_mk' Quotient.liftOn\u2082'_mk''\n\n#print Quotient.ind' /-\n/-- A version of `quotient.ind` taking `{s : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_elim]\nprotected theorem ind' {p : Quotient s\u2081 \u2192 Prop} (h : \u2200 a, p (Quotient.mk'' a)) (q : Quotient s\u2081) :\n    p q :=\n  Quotient.ind h q\n#align quotient.ind' Quotient.ind'\n-/\n\n/- warning: quotient.ind\u2082' -> Quotient.ind\u2082' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {s\u2081 : Setoid.{u1} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} {p : (Quotient.{u1} \u03b1 s\u2081) -> (Quotient.{u2} \u03b2 s\u2082) -> Prop}, (forall (a\u2081 : \u03b1) (a\u2082 : \u03b2), p (Quotient.mk''.{u1} \u03b1 s\u2081 a\u2081) (Quotient.mk''.{u2} \u03b2 s\u2082 a\u2082)) -> (forall (q\u2081 : Quotient.{u1} \u03b1 s\u2081) (q\u2082 : Quotient.{u2} \u03b2 s\u2082), p q\u2081 q\u2082)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {s\u2081 : Setoid.{u2} \u03b1} {s\u2082 : Setoid.{u1} \u03b2} {p : (Quotient.{u2} \u03b1 s\u2081) -> (Quotient.{u1} \u03b2 s\u2082) -> Prop}, (forall (a\u2081 : \u03b1) (a\u2082 : \u03b2), p (Quotient.mk''.{u2} \u03b1 s\u2081 a\u2081) (Quotient.mk''.{u1} \u03b2 s\u2082 a\u2082)) -> (forall (q\u2081 : Quotient.{u2} \u03b1 s\u2081) (q\u2082 : Quotient.{u1} \u03b2 s\u2082), p q\u2081 q\u2082)\nCase conversion may be inaccurate. Consider using '#align quotient.ind\u2082' Quotient.ind\u2082'\u2093'. -/\n/-- A version of `quotient.ind\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem ind\u2082' {p : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Prop}\n    (h : \u2200 a\u2081 a\u2082, p (Quotient.mk'' a\u2081) (Quotient.mk'' a\u2082)) (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) :\n    p q\u2081 q\u2082 :=\n  Quotient.ind\u2082 h q\u2081 q\u2082\n#align quotient.ind\u2082' Quotient.ind\u2082'\n\n#print Quotient.inductionOn' /-\n/-- A version of `quotient.induction_on` taking `{s : setoid \u03b1}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_elim]\nprotected theorem inductionOn' {p : Quotient s\u2081 \u2192 Prop} (q : Quotient s\u2081)\n    (h : \u2200 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\u2082' -> Quotient.inductionOn\u2082' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {s\u2081 : Setoid.{u1} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} {p : (Quotient.{u1} \u03b1 s\u2081) -> (Quotient.{u2} \u03b2 s\u2082) -> Prop} (q\u2081 : Quotient.{u1} \u03b1 s\u2081) (q\u2082 : Quotient.{u2} \u03b2 s\u2082), (forall (a\u2081 : \u03b1) (a\u2082 : \u03b2), p (Quotient.mk''.{u1} \u03b1 s\u2081 a\u2081) (Quotient.mk''.{u2} \u03b2 s\u2082 a\u2082)) -> (p q\u2081 q\u2082)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {s\u2081 : Setoid.{u2} \u03b1} {s\u2082 : Setoid.{u1} \u03b2} {p : (Quotient.{u2} \u03b1 s\u2081) -> (Quotient.{u1} \u03b2 s\u2082) -> Prop} (q\u2081 : Quotient.{u2} \u03b1 s\u2081) (q\u2082 : Quotient.{u1} \u03b2 s\u2082), (forall (a\u2081 : \u03b1) (a\u2082 : \u03b2), p (Quotient.mk''.{u2} \u03b1 s\u2081 a\u2081) (Quotient.mk''.{u1} \u03b2 s\u2082 a\u2082)) -> (p q\u2081 q\u2082)\nCase conversion may be inaccurate. Consider using '#align quotient.induction_on\u2082' Quotient.inductionOn\u2082'\u2093'. -/\n/-- A version of `quotient.induction_on\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem inductionOn\u2082' {p : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Prop} (q\u2081 : Quotient s\u2081)\n    (q\u2082 : Quotient s\u2082) (h : \u2200 a\u2081 a\u2082, p (Quotient.mk'' a\u2081) (Quotient.mk'' a\u2082)) : p q\u2081 q\u2082 :=\n  Quotient.induction_on\u2082 q\u2081 q\u2082 h\n#align quotient.induction_on\u2082' Quotient.inductionOn\u2082'\n\n/- warning: quotient.induction_on\u2083' -> Quotient.inductionOn\u2083' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {s\u2081 : Setoid.{u1} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} {s\u2083 : Setoid.{u3} \u03b3} {p : (Quotient.{u1} \u03b1 s\u2081) -> (Quotient.{u2} \u03b2 s\u2082) -> (Quotient.{u3} \u03b3 s\u2083) -> Prop} (q\u2081 : Quotient.{u1} \u03b1 s\u2081) (q\u2082 : Quotient.{u2} \u03b2 s\u2082) (q\u2083 : Quotient.{u3} \u03b3 s\u2083), (forall (a\u2081 : \u03b1) (a\u2082 : \u03b2) (a\u2083 : \u03b3), p (Quotient.mk''.{u1} \u03b1 s\u2081 a\u2081) (Quotient.mk''.{u2} \u03b2 s\u2082 a\u2082) (Quotient.mk''.{u3} \u03b3 s\u2083 a\u2083)) -> (p q\u2081 q\u2082 q\u2083)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u1}} {s\u2081 : Setoid.{u3} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} {s\u2083 : Setoid.{u1} \u03b3} {p : (Quotient.{u3} \u03b1 s\u2081) -> (Quotient.{u2} \u03b2 s\u2082) -> (Quotient.{u1} \u03b3 s\u2083) -> Prop} (q\u2081 : Quotient.{u3} \u03b1 s\u2081) (q\u2082 : Quotient.{u2} \u03b2 s\u2082) (q\u2083 : Quotient.{u1} \u03b3 s\u2083), (forall (a\u2081 : \u03b1) (a\u2082 : \u03b2) (a\u2083 : \u03b3), p (Quotient.mk''.{u3} \u03b1 s\u2081 a\u2081) (Quotient.mk''.{u2} \u03b2 s\u2082 a\u2082) (Quotient.mk''.{u1} \u03b3 s\u2083 a\u2083)) -> (p q\u2081 q\u2082 q\u2083)\nCase conversion may be inaccurate. Consider using '#align quotient.induction_on\u2083' Quotient.inductionOn\u2083'\u2093'. -/\n/-- A version of `quotient.induction_on\u2083` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2} {s\u2083 : setoid \u03b3}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_elim]\nprotected theorem inductionOn\u2083' {p : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Quotient s\u2083 \u2192 Prop}\n    (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) (q\u2083 : Quotient s\u2083)\n    (h : \u2200 a\u2081 a\u2082 a\u2083, p (Quotient.mk'' a\u2081) (Quotient.mk'' a\u2082) (Quotient.mk'' a\u2083)) : p q\u2081 q\u2082 q\u2083 :=\n  Quotient.induction_on\u2083 q\u2081 q\u2082 q\u2083 h\n#align quotient.induction_on\u2083' Quotient.inductionOn\u2083'\n\n#print Quotient.recOnSubsingleton' /-\n/-- A version of `quotient.rec_on_subsingleton` taking `{s\u2081 : setoid \u03b1}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_elim]\nprotected def recOnSubsingleton' {\u03c6 : Quotient s\u2081 \u2192 Sort _} [h : \u2200 a, Subsingleton (\u03c6 \u27e6a\u27e7)]\n    (q : Quotient s\u2081) (f : \u2200 a, \u03c6 (Quotient.mk'' a)) : \u03c6 q :=\n  Quotient.recOnSubsingleton q f\n#align quotient.rec_on_subsingleton' Quotient.recOnSubsingleton'\n-/\n\n#print Quotient.recOnSubsingleton\u2082' /-\n/-- A version of `quotient.rec_on_subsingleton\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b1}`\nas implicit arguments instead of instance arguments. -/\n@[reducible, elab_as_elim]\nprotected def recOnSubsingleton\u2082' {\u03c6 : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Sort _}\n    [h : \u2200 a b, Subsingleton (\u03c6 \u27e6a\u27e7 \u27e6b\u27e7)] (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082)\n    (f : \u2200 a\u2081 a\u2082, \u03c6 (Quotient.mk'' a\u2081) (Quotient.mk'' a\u2082)) : \u03c6 q\u2081 q\u2082 :=\n  Quotient.recOnSubsingleton\u2082 q\u2081 q\u2082 f\n#align quotient.rec_on_subsingleton\u2082' Quotient.recOnSubsingleton\u2082'\n-/\n\n#print Quotient.hrecOn' /-\n/-- Recursion on a `quotient` argument `a`, result type depends on `\u27e6a\u27e7`. -/\nprotected def hrecOn' {\u03c6 : Quotient s\u2081 \u2192 Sort _} (qa : Quotient s\u2081) (f : \u2200 a, \u03c6 (Quotient.mk'' a))\n    (c : \u2200 a\u2081 a\u2082, a\u2081 \u2248 a\u2082 \u2192 HEq (f a\u2081) (f a\u2082)) : \u03c6 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 {\u03b1 : Sort.{u1}} {s\u2081 : Setoid.{u1} \u03b1} {\u03c6 : (Quotient.{u1} \u03b1 s\u2081) -> Sort.{u2}} (f : forall (a : \u03b1), \u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 a)) (c : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1), (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 s\u2081) a\u2081 a\u2082) -> (HEq.{u2} (\u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 a\u2081)) (f a\u2081) (\u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 a\u2082)) (f a\u2082))) (x : \u03b1), Eq.{u2} (\u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 x)) (Quotient.hrecOn'.{u1, u2} \u03b1 s\u2081 \u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 x) f c) (f x)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {s\u2081 : Setoid.{u2} \u03b1} {\u03c6 : (Quotient.{u2} \u03b1 s\u2081) -> Sort.{u1}} (f : forall (a : \u03b1), \u03c6 (Quotient.mk''.{u2} \u03b1 s\u2081 a)) (c : forall (a\u2081 : \u03b1) (a\u2082 : \u03b1), (HasEquiv.Equiv.{u2, 0} \u03b1 (instHasEquiv.{u2} \u03b1 s\u2081) a\u2081 a\u2082) -> (HEq.{u1} (\u03c6 (Quotient.mk''.{u2} \u03b1 s\u2081 a\u2081)) (f a\u2081) (\u03c6 (Quotient.mk''.{u2} \u03b1 s\u2081 a\u2082)) (f a\u2082))) (x : \u03b1), Eq.{u1} (\u03c6 (Quotient.mk''.{u2} \u03b1 s\u2081 x)) (Quotient.hrecOn'.{u2, u1} \u03b1 s\u2081 \u03c6 (Quotient.mk''.{u2} \u03b1 s\u2081 x) f c) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.hrec_on'_mk' Quotient.hrecOn'_mk''\u2093'. -/\n@[simp]\ntheorem hrecOn'_mk'' {\u03c6 : Quotient s\u2081 \u2192 Sort _} (f : \u2200 a, \u03c6 (Quotient.mk'' a))\n    (c : \u2200 a\u2081 a\u2082, a\u2081 \u2248 a\u2082 \u2192 HEq (f a\u2081) (f a\u2082)) (x : \u03b1) : (Quotient.mk'' x).hrecOn' f c = f x :=\n  rfl\n#align quotient.hrec_on'_mk' Quotient.hrecOn'_mk''\n\n#print Quotient.hrecOn\u2082' /-\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrecOn\u2082' {\u03c6 : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Sort _} (qa : Quotient s\u2081)\n    (qb : Quotient s\u2082) (f : \u2200 a b, \u03c6 (Quotient.mk'' a) (Quotient.mk'' b))\n    (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 HEq (f a\u2081 b\u2081) (f a\u2082 b\u2082)) : \u03c6 qa qb :=\n  Quotient.hrecOn\u2082 qa qb f c\n#align quotient.hrec_on\u2082' Quotient.hrecOn\u2082'\n-/\n\n/- warning: quotient.hrec_on\u2082'_mk' -> Quotient.hrecOn\u2082'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {s\u2081 : Setoid.{u1} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} {\u03c6 : (Quotient.{u1} \u03b1 s\u2081) -> (Quotient.{u2} \u03b2 s\u2082) -> Sort.{u3}} (f : forall (a : \u03b1) (b : \u03b2), \u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 a) (Quotient.mk''.{u2} \u03b2 s\u2082 b)) (c : forall (a\u2081 : \u03b1) (b\u2081 : \u03b2) (a\u2082 : \u03b1) (b\u2082 : \u03b2), (HasEquiv\u2093.Equiv.{u1} \u03b1 (setoidHasEquiv.{u1} \u03b1 s\u2081) a\u2081 a\u2082) -> (HasEquiv\u2093.Equiv.{u2} \u03b2 (setoidHasEquiv.{u2} \u03b2 s\u2082) b\u2081 b\u2082) -> (HEq.{u3} (\u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 a\u2081) (Quotient.mk''.{u2} \u03b2 s\u2082 b\u2081)) (f a\u2081 b\u2081) (\u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 a\u2082) (Quotient.mk''.{u2} \u03b2 s\u2082 b\u2082)) (f a\u2082 b\u2082))) (x : \u03b1) (qb : Quotient.{u2} \u03b2 s\u2082), Eq.{u3} (\u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 x) qb) (Quotient.hrecOn\u2082'.{u1, u2, u3} \u03b1 \u03b2 s\u2081 s\u2082 \u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 x) qb f c) (Quotient.hrecOn'.{u2, u3} \u03b2 s\u2082 (fun (qb : Quotient.{u2} \u03b2 s\u2082) => \u03c6 (Quotient.mk''.{u1} \u03b1 s\u2081 x) qb) qb (f x) (fun (b\u2081 : \u03b2) (b\u2082 : \u03b2) => c x b\u2081 x b\u2082 (Setoid.refl.{u1} \u03b1 s\u2081 x)))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {s\u2081 : Setoid.{u3} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} {\u03c6 : (Quotient.{u3} \u03b1 s\u2081) -> (Quotient.{u2} \u03b2 s\u2082) -> Sort.{u1}} (f : forall (a : \u03b1) (b : \u03b2), \u03c6 (Quotient.mk''.{u3} \u03b1 s\u2081 a) (Quotient.mk''.{u2} \u03b2 s\u2082 b)) (c : forall (a\u2081 : \u03b1) (b\u2081 : \u03b2) (a\u2082 : \u03b1) (b\u2082 : \u03b2), (HasEquiv.Equiv.{u3, 0} \u03b1 (instHasEquiv.{u3} \u03b1 s\u2081) a\u2081 a\u2082) -> (HasEquiv.Equiv.{u2, 0} \u03b2 (instHasEquiv.{u2} \u03b2 s\u2082) b\u2081 b\u2082) -> (HEq.{u1} (\u03c6 (Quotient.mk''.{u3} \u03b1 s\u2081 a\u2081) (Quotient.mk''.{u2} \u03b2 s\u2082 b\u2081)) (f a\u2081 b\u2081) (\u03c6 (Quotient.mk''.{u3} \u03b1 s\u2081 a\u2082) (Quotient.mk''.{u2} \u03b2 s\u2082 b\u2082)) (f a\u2082 b\u2082))) (x : \u03b1) (qb : Quotient.{u2} \u03b2 s\u2082), Eq.{u1} (\u03c6 (Quotient.mk''.{u3} \u03b1 s\u2081 x) qb) (Quotient.hrecOn\u2082'.{u3, u2, u1} \u03b1 \u03b2 s\u2081 s\u2082 \u03c6 (Quotient.mk''.{u3} \u03b1 s\u2081 x) qb f c) (Quotient.hrecOn'.{u2, u1} \u03b2 s\u2082 (\u03c6 (Quotient.mk''.{u3} \u03b1 s\u2081 x)) qb (f x) (fun (b\u2081 : \u03b2) (b\u2082 : \u03b2) => c x b\u2081 x b\u2082 (Setoid.refl.{u3} \u03b1 s\u2081 x)))\nCase conversion may be inaccurate. Consider using '#align quotient.hrec_on\u2082'_mk' Quotient.hrecOn\u2082'_mk''\u2093'. -/\n@[simp]\ntheorem hrecOn\u2082'_mk'' {\u03c6 : Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Sort _}\n    (f : \u2200 a b, \u03c6 (Quotient.mk'' a) (Quotient.mk'' b))\n    (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 HEq (f a\u2081 b\u2081) (f a\u2082 b\u2082)) (x : \u03b1) (qb : Quotient s\u2082) :\n    (Quotient.mk'' x).hrecOn\u2082' qb f c = qb.hrecOn' (f x) fun b\u2081 b\u2082 => c _ _ _ _ (Setoid.refl _) :=\n  rfl\n#align quotient.hrec_on\u2082'_mk' Quotient.hrecOn\u2082'_mk''\n\n#print Quotient.map' /-\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `quotient sa \u2192 quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : \u03b1 \u2192 \u03b2) (h : (s\u2081.R \u21d2 s\u2082.R) f f) : Quotient s\u2081 \u2192 Quotient s\u2082 :=\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {s\u2081 : Setoid.{u1} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} (f : \u03b1 -> \u03b2) (h : Relator.LiftFun.{u1, u1, u2, u2} \u03b1 \u03b1 \u03b2 \u03b2 (Setoid.r.{u1} \u03b1 s\u2081) (Setoid.r.{u2} \u03b2 s\u2082) f f) (x : \u03b1), Eq.{u2} (Quotient.{u2} \u03b2 s\u2082) (Quotient.map'.{u1, u2} \u03b1 \u03b2 s\u2081 s\u2082 f h (Quotient.mk''.{u1} \u03b1 s\u2081 x)) (Quotient.mk''.{u2} \u03b2 s\u2082 (f x))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} {s\u2081 : Setoid.{u2} \u03b1} {s\u2082 : Setoid.{u1} \u03b2} (f : \u03b1 -> \u03b2) (h : Relator.LiftFun.{u2, u2, u1, u1} \u03b1 \u03b1 \u03b2 \u03b2 (Setoid.r.{u2} \u03b1 s\u2081) (Setoid.r.{u1} \u03b2 s\u2082) f f) (x : \u03b1), Eq.{u1} (Quotient.{u1} \u03b2 s\u2082) (Quotient.map'.{u2, u1} \u03b1 \u03b2 s\u2081 s\u2082 f h (Quotient.mk''.{u2} \u03b1 s\u2081 x)) (Quotient.mk''.{u1} \u03b2 s\u2082 (f x))\nCase conversion may be inaccurate. Consider using '#align quotient.map'_mk' Quotient.map'_mk''\u2093'. -/\n@[simp]\ntheorem map'_mk'' (f : \u03b1 \u2192 \u03b2) (h) (x : \u03b1) :\n    (Quotient.mk'' x : Quotient s\u2081).map' f h = (Quotient.mk'' (f x) : Quotient s\u2082) :=\n  rfl\n#align quotient.map'_mk' Quotient.map'_mk''\n\n#print Quotient.map\u2082' /-\n/-- A version of `quotient.map\u2082` using curly braces and unification. -/\nprotected def map\u2082' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : (s\u2081.R \u21d2 s\u2082.R \u21d2 s\u2083.R) f f) :\n    Quotient s\u2081 \u2192 Quotient s\u2082 \u2192 Quotient s\u2083 :=\n  Quotient.map\u2082 f h\n#align quotient.map\u2082' Quotient.map\u2082'\n-/\n\n/- warning: quotient.map\u2082'_mk' -> Quotient.map\u2082'_mk'' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} {s\u2081 : Setoid.{u1} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} {s\u2083 : Setoid.{u3} \u03b3} (f : \u03b1 -> \u03b2 -> \u03b3) (h : Relator.LiftFun.{u1, u1, imax u2 u3, imax u2 u3} \u03b1 \u03b1 (\u03b2 -> \u03b3) (\u03b2 -> \u03b3) (Setoid.r.{u1} \u03b1 s\u2081) (Relator.LiftFun.{u2, u2, u3, u3} \u03b2 \u03b2 \u03b3 \u03b3 (Setoid.r.{u2} \u03b2 s\u2082) (Setoid.r.{u3} \u03b3 s\u2083)) f f) (x : \u03b1), Eq.{imax u2 u3} ((Quotient.{u2} \u03b2 s\u2082) -> (Quotient.{u3} \u03b3 s\u2083)) (Quotient.map\u2082'.{u1, u2, u3} \u03b1 \u03b2 \u03b3 s\u2081 s\u2082 s\u2083 f h (Quotient.mk''.{u1} \u03b1 s\u2081 x)) (Quotient.map'.{u2, u3} \u03b2 \u03b3 s\u2082 s\u2083 (f x) (h x x (Setoid.refl.{u1} \u03b1 s\u2081 x)))\nbut is expected to have type\n  forall {\u03b1 : Sort.{u3}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u1}} {s\u2081 : Setoid.{u3} \u03b1} {s\u2082 : Setoid.{u2} \u03b2} {s\u2083 : Setoid.{u1} \u03b3} (f : \u03b1 -> \u03b2 -> \u03b3) (h : Relator.LiftFun.{u3, u3, imax u2 u1, imax u2 u1} \u03b1 \u03b1 (\u03b2 -> \u03b3) (\u03b2 -> \u03b3) (Setoid.r.{u3} \u03b1 s\u2081) (Relator.LiftFun.{u2, u2, u1, u1} \u03b2 \u03b2 \u03b3 \u03b3 (Setoid.r.{u2} \u03b2 s\u2082) (Setoid.r.{u1} \u03b3 s\u2083)) f f) (x : \u03b1), Eq.{imax u2 u1} ((Quotient.{u2} \u03b2 s\u2082) -> (Quotient.{u1} \u03b3 s\u2083)) (Quotient.map\u2082'.{u3, u2, u1} \u03b1 \u03b2 \u03b3 s\u2081 s\u2082 s\u2083 f h (Quotient.mk''.{u3} \u03b1 s\u2081 x)) (Quotient.map'.{u2, u1} \u03b2 \u03b3 s\u2082 s\u2083 (f x) (h x x (Setoid.refl.{u3} \u03b1 s\u2081 x)))\nCase conversion may be inaccurate. Consider using '#align quotient.map\u2082'_mk' Quotient.map\u2082'_mk''\u2093'. -/\n@[simp]\ntheorem map\u2082'_mk'' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (x : \u03b1) :\n    (Quotient.mk'' x : Quotient s\u2081).map\u2082' f h =\n      (Quotient.map' (f x) (h (Setoid.refl x)) : Quotient s\u2082 \u2192 Quotient s\u2083) :=\n  rfl\n#align quotient.map\u2082'_mk' Quotient.map\u2082'_mk''\n\n#print Quotient.exact' /-\ntheorem exact' {a b : \u03b1} : (Quotient.mk'' a : Quotient s\u2081) = Quotient.mk'' b \u2192 @Setoid.r _ s\u2081 a b :=\n  Quotient.exact\n#align quotient.exact' Quotient.exact'\n-/\n\n#print Quotient.sound' /-\ntheorem sound' {a b : \u03b1} : @Setoid.r _ s\u2081 a b \u2192 @Quotient.mk'' \u03b1 s\u2081 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 : \u03b1} : @Quotient.mk'' \u03b1 s\u2081 a = Quotient.mk'' b \u2194 @Setoid.r _ s\u2081 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\u2081 : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : Quotient s\u2081) : \u03b1 :=\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\u2081) : 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 : \u03b1) : @Setoid.r \u03b1 s\u2081 (Quotient.mk'' a : Quotient s\u2081).out' a :=\n  Quotient.exact (Quotient.out_eq _)\n#align quotient.mk_out' Quotient.mk_out'\n-/\n\nsection\n\nvariable [Setoid \u03b1]\n\nprotected theorem mk''_eq_mk' (x : \u03b1) : Quotient.mk'' x = \u27e6x\u27e7 :=\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 {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} [_inst_1 : Setoid.{u1} \u03b1] (x : \u03b1) (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1) (b : \u03b1), (Setoid.r.{u1} \u03b1 _inst_1 a b) -> (Eq.{u2} \u03b2 (f a) (f b))), Eq.{u2} \u03b2 (Quotient.liftOn'.{u1, u2} \u03b1 \u03b2 _inst_1 (Quotient.mk'.{u1} \u03b1 _inst_1 x) f h) (f x)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u1}} [_inst_1 : Setoid.{u2} \u03b1] (x : \u03b1) (f : \u03b1 -> \u03b2) (h : forall (a : \u03b1) (b : \u03b1), (Setoid.r.{u2} \u03b1 _inst_1 a b) -> (Eq.{u1} \u03b2 (f a) (f b))), Eq.{u1} \u03b2 (Quotient.liftOn'.{u2, u1} \u03b1 \u03b2 _inst_1 (Quotient.mk.{u2} \u03b1 _inst_1 x) f h) (f x)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on'_mk Quotient.liftOn'_mk\u2093'. -/\n@[simp]\nprotected theorem liftOn'_mk (x : \u03b1) (f : \u03b1 \u2192 \u03b2) (h) : \u27e6x\u27e7.liftOn' f h = f x :=\n  rfl\n#align quotient.lift_on'_mk Quotient.liftOn'_mk\n\n/- warning: quotient.lift_on\u2082'_mk -> Quotient.liftOn\u2082'_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Sort.{u1}} {\u03b2 : Sort.{u2}} {\u03b3 : Sort.{u3}} [_inst_1 : Setoid.{u1} \u03b1] [_inst_2 : Setoid.{u2} \u03b2] (f : \u03b1 -> \u03b2 -> \u03b3) (h : forall (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), (Setoid.r.{u1} \u03b1 _inst_1 a\u2081 b\u2081) -> (Setoid.r.{u2} \u03b2 _inst_2 a\u2082 b\u2082) -> (Eq.{u3} \u03b3 (f a\u2081 a\u2082) (f b\u2081 b\u2082))) (a : \u03b1) (b : \u03b2), Eq.{u3} \u03b3 (Quotient.liftOn\u2082'.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 (Quotient.mk'.{u1} \u03b1 _inst_1 a) (Quotient.mk'.{u2} \u03b2 _inst_2 b) f h) (f a b)\nbut is expected to have type\n  forall {\u03b1 : Sort.{u2}} {\u03b2 : Sort.{u3}} {\u03b3 : Sort.{u1}} [_inst_1 : Setoid.{u2} \u03b1] [_inst_2 : Setoid.{u3} \u03b2] (f : \u03b1 -> \u03b2 -> \u03b3) (h : forall (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), (Setoid.r.{u2} \u03b1 _inst_1 a\u2081 b\u2081) -> (Setoid.r.{u3} \u03b2 _inst_2 a\u2082 b\u2082) -> (Eq.{u1} \u03b3 (f a\u2081 a\u2082) (f b\u2081 b\u2082))) (a : \u03b1) (b : \u03b2), Eq.{u1} \u03b3 (Quotient.liftOn\u2082'.{u2, u3, u1} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 (Quotient.mk.{u2} \u03b1 _inst_1 a) (Quotient.mk.{u3} \u03b2 _inst_2 b) f h) (f a b)\nCase conversion may be inaccurate. Consider using '#align quotient.lift_on\u2082'_mk Quotient.liftOn\u2082'_mk\u2093'. -/\n@[simp]\nprotected theorem liftOn\u2082'_mk [Setoid \u03b2] (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (a : \u03b1) (b : \u03b2) :\n    Quotient.liftOn\u2082' \u27e6a\u27e7 \u27e6b\u27e7 f h = f a b :=\n  Quotient.liftOn\u2082'_mk'' _ _ _ _\n#align quotient.lift_on\u2082'_mk Quotient.liftOn\u2082'_mk\n\n#print Quotient.map'_mk /-\n@[simp]\ntheorem map'_mk [Setoid \u03b2] (f : \u03b1 \u2192 \u03b2) (h) (x : \u03b1) : \u27e6x\u27e7.map' f h = \u27e6f x\u27e7 :=\n  rfl\n#align quotient.map'_mk Quotient.map'_mk\n-/\n\nend\n\ninstance (q : Quotient s\u2081) (f : \u03b1 \u2192 Prop) (h : \u2200 a b, @Setoid.r \u03b1 s\u2081 a b \u2192 f a = f b)\n    [DecidablePred f] : Decidable (Quotient.liftOn' q f h) :=\n  Quotient.lift.decidablePred _ _ q\n\ninstance (q\u2081 : Quotient s\u2081) (q\u2082 : Quotient s\u2082) (f : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (h : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, @Setoid.r \u03b1 s\u2081 a\u2081 a\u2082 \u2192 @Setoid.r \u03b2 s\u2082 b\u2081 b\u2082 \u2192 f a\u2081 b\u2081 = f a\u2082 b\u2082)\n    [\u2200 a, DecidablePred (f a)] : Decidable (Quotient.liftOn\u2082' q\u2081 q\u2082 f h) :=\n  Quotient.lift\u2082.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 {\u03b1 : Type u_1} [uniform_space \u03b1] [compact_space \u03b1]\n    [separated_space \u03b1] : uniformity \u03b1 = supr fun (x : \u03b1) => nhds (x, x) :=\n  sorry\n\ntheorem unique_uniformity_of_compact_t2 {\u03b1 : Type u_1} [t : topological_space \u03b1] [compact_space \u03b1]\n    [t2_space \u03b1] {u : uniform_space \u03b1} {u' : uniform_space \u03b1}\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 {\u03b1 : Type (max (max u_1 u_2 u_3) u_2)} [topological_space \u03b1]\n    [compact_space \u03b1] [t2_space \u03b1] : uniform_space \u03b1 :=\n  uniform_space.mk (uniform_space.core.mk (supr fun (x : \u03b1) => nhds (x, x)) sorry sorry sorry) sorry\n\n/-!\n###\u00a0Heine-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 {\u03b1 : Type u_1} {\u03b2 : Type u_2}\n    [uniform_space \u03b1] [uniform_space \u03b2] [compact_space \u03b1] [separated_space \u03b1] {f : \u03b1 \u2192 \u03b2}\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' {\u03b1 : Type u_1} {\u03b2 : Type u_2}\n    [uniform_space \u03b1] [uniform_space \u03b2] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2} (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2}\n    [uniform_space \u03b1] [uniform_space \u03b2] [separated_space \u03b1] {s : set \u03b1} {f : \u03b1 \u2192 \u03b2}\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 Hw7\nimport Lean.Elab.Print\nimport Lean.Elab.Command\n\ntheorem desiredType : \u2200 (\u03b1 : Type) (f : \u03b1 \u2192 \u03b1) (A : \u03b1 \u2192 Prop), (\u2200 (x : \u03b1), A x \u2192 A (f x)) \u2192 \u2200 (y : \u03b1), A y \u2192 A (f (f y)) := sorry \n\nopen Lean\nopen Lean.Meta\nopen Lean.Elab.Command\n\ndef collectAxiomsOf (constName : Name) : MetaM (List String) := do\n  let env \u2190 getEnv\n  let (_, s) := ((CollectAxioms.collect constName).run env).run {}\n  let a := s.axioms.toList.map toString\n  return a\n\n#eval isDefEq (Expr.const ``desiredType []) (Expr.const ``problem3 [])\n#eval collectAxiomsOf ``problem3\n", "meta": {"author": "UofSC-Fall-2022-Math-300-H01", "repo": "homework7", "sha": "4873226c2ce223b0f592894b99ced612f0f2712d", "save_path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-homework7", "path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-homework7/homework7-4873226c2ce223b0f592894b99ced612f0f2712d/_Tests/Problem3.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7185943925708561, "lm_q2_score": 0.6406358411176238, "lm_q1q2_score": 0.46035732310703836}}
{"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 : \u00ac 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 `\u2115`-indexed chain complex `P.complex` of projective objects,\nalong with a chain map `P.\u03c0` 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 `\u03c0` 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 \u27f6 Y` admits a lift to a chain map `P.complex \u27f6 Q.complex`.\n(It is a lift in the sense that\nthe projection maps `P.\u03c0` and `Q.\u03c0` 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 \u2964 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 `\u2115`-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 `\u03c0` 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 `\u2115`-indexed chain complex\n  (equipped with `projective` and `exact` instances)\n* `projective_resolution.\u03c0 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 `\u03c0` is a quasi-iso).\n-/\n@[nolint has_nonempty_instance]\nstructure ProjectiveResolution (Z : C) where\n  complex : ChainComplex C \u2115\n  \u03c0 : HomologicalComplex.Hom Complex ((ChainComplex.single\u2080 C).obj Z)\n  Projective : \u2200 n, Projective (Complex.pt n) := by infer_instance\n  exact\u2080 : Exact (Complex.d 1 0) (\u03c0.f 0)\n  exact : \u2200 n, Exact (Complex.d (n + 2) (n + 1)) (Complex.d (n + 1) n)\n  Epi : Epi (\u03c0.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 : \u2200 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 \u03c0_f_succ {Z : C} (P : ProjectiveResolution Z) (n : \u2115) : P.\u03c0.f (n + 1) = 0 :=\n  by\n  apply zero_of_target_iso_zero\n  dsimp; rfl\n#align category_theory.ProjectiveResolution.\u03c0_f_succ CategoryTheory.ProjectiveResolution.\u03c0_f_succ\n\n@[simp]\ntheorem complex_d_comp_\u03c0_f_zero {Z : C} (P : ProjectiveResolution Z) :\n    P.complex.d 1 0 \u226b P.\u03c0.f 0 = 0 :=\n  P.exact\u2080.w\n#align category_theory.ProjectiveResolution.complex_d_comp_\u03c0_f_zero CategoryTheory.ProjectiveResolution.complex_d_comp_\u03c0_f_zero\n\n@[simp]\ntheorem complex_d_succ_comp {Z : C} (P : ProjectiveResolution Z) (n : \u2115) :\n    P.complex.d (n + 2) (n + 1) \u226b 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 : \u2115) : CategoryTheory.Epi (P.\u03c0.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\u2080 C).obj Z\n  \u03c0 := \ud835\udfd9 ((ChainComplex.single\u2080 C).obj Z)\n  Projective n := by\n    cases n\n    \u00b7 dsimp\n      infer_instance\n    \u00b7 dsimp\n      infer_instance\n  exact\u2080 := 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 \u27f6 Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n    P.complex.pt 0 \u27f6 Q.complex.pt 0 :=\n  factorThru (P.\u03c0.f 0 \u226b f) (Q.\u03c0.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 \u27f6 Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n    P.complex.pt 1 \u27f6 Q.complex.pt 1 :=\n  Exact.lift (P.complex.d 1 0 \u226b liftFZero f P Q) (Q.complex.d 1 0) (Q.\u03c0.f 0) Q.exact\u2080\n    (by simp [lift_f_zero, P.exact\u2080.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 \u27f6 Z) (P : ProjectiveResolution Y)\n    (Q : ProjectiveResolution Z) :\n    liftFOne f P Q \u226b Q.complex.d 1 0 = P.complex.d 1 0 \u226b 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 : \u2115)\n    (g : P.complex.pt n \u27f6 Q.complex.pt n) (g' : P.complex.pt (n + 1) \u27f6 Q.complex.pt (n + 1))\n    (w : g' \u226b Q.complex.d (n + 1) n = P.complex.d (n + 1) n \u226b g) :\n    \u03a3'g'' : P.complex.pt (n + 2) \u27f6 Q.complex.pt (n + 2),\n      g'' \u226b Q.complex.d (n + 2) (n + 1) = P.complex.d (n + 2) (n + 1) \u226b g' :=\n  \u27e8Exact.lift (P.complex.d (n + 2) (n + 1) \u226b g') (Q.complex.d (n + 2) (n + 1))\n      (Q.complex.d (n + 1) n) (Q.exact _) (by simp [w]),\n    by simp\u27e9\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 \u27f6 Z) (P : ProjectiveResolution Y) (Q : ProjectiveResolution Z) :\n    P.complex \u27f6 Q.complex :=\n  ChainComplex.mkHom _ _ (liftFZero f _ _) (liftFOne f _ _) (liftFOne_zero_comm f _ _)\n    fun n \u27e8g, g', w\u27e9 => 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 \u27f6 Z) (P : ProjectiveResolution Y)\n    (Q : ProjectiveResolution Z) : lift f P Q \u226b Q.\u03c0 = P.\u03c0 \u226b (ChainComplex.single\u2080 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 \u27f6 Q.complex) (comm : f \u226b Q.\u03c0 = 0) : P.complex.pt 0 \u27f6 Q.complex.pt 1 :=\n  Exact.lift (f.f 0) (Q.complex.d 1 0) (Q.\u03c0.f 0) Q.exact\u2080\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 \u27f6 Q.complex) (comm : f \u226b Q.\u03c0 = 0) : P.complex.pt 1 \u27f6 Q.complex.pt 2 :=\n  Exact.lift (f.f 1 - P.complex.d 1 0 \u226b 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 \u27f6 Q.complex) (n : \u2115) (g : P.complex.pt n \u27f6 Q.complex.pt (n + 1))\n    (g' : P.complex.pt (n + 1) \u27f6 Q.complex.pt (n + 2))\n    (w : f.f (n + 1) = P.complex.d (n + 1) n \u226b g + g' \u226b Q.complex.d (n + 2) (n + 1)) :\n    P.complex.pt (n + 2) \u27f6 Q.complex.pt (n + 3) :=\n  Exact.lift (f.f (n + 2) - P.complex.d (n + 2) (n + 1) \u226b 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 \u27f6 Q.complex) (comm : f \u226b Q.\u03c0 = 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 \u27e8g, g', w\u27e9 =>\n    \u27e8liftHomotopyZeroSucc f n g g' w, by simp [lift_homotopy_zero_succ, w]\u27e9\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 \u27f6 Z) {P : ProjectiveResolution Y} {Q : ProjectiveResolution Z}\n    (g h : P.complex \u27f6 Q.complex) (g_comm : g \u226b Q.\u03c0 = P.\u03c0 \u226b (ChainComplex.single\u2080 C).map f)\n    (h_comm : h \u226b Q.\u03c0 = P.\u03c0 \u226b (ChainComplex.single\u2080 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 (\ud835\udfd9 X) P P) (\ud835\udfd9 P.complex) :=\n  by apply lift_homotopy (\ud835\udfd9 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 \u27f6 Y) (g : Y \u27f6 Z) (P : ProjectiveResolution X)\n    (Q : ProjectiveResolution Y) (R : ProjectiveResolution Z) :\n    Homotopy (lift (f \u226b g) P R) (lift f P Q \u226b lift g Q R) := by apply lift_homotopy (f \u226b 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 (\ud835\udfd9 X) P Q\n  inv := lift (\ud835\udfd9 X) Q P\n  homotopyHomInvId :=\n    by\n    refine' (lift_comp_homotopy (\ud835\udfd9 X) (\ud835\udfd9 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 (\ud835\udfd9 X) (\ud835\udfd9 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_\u03c0 {X : C} (P Q : ProjectiveResolution X) :\n    (homotopyEquiv P Q).Hom \u226b Q.\u03c0 = P.\u03c0 := by simp [HomotopyEquiv]\n#align category_theory.ProjectiveResolution.homotopy_equiv_hom_\u03c0 CategoryTheory.ProjectiveResolution.homotopyEquiv_hom_\u03c0\n\n@[simp, reassoc.1]\ntheorem homotopyEquiv_inv_\u03c0 {X : C} (P Q : ProjectiveResolution X) :\n    (homotopyEquiv P Q).inv \u226b P.\u03c0 = Q.\u03c0 := by simp [HomotopyEquiv]\n#align category_theory.ProjectiveResolution.homotopy_equiv_inv_\u03c0 CategoryTheory.ProjectiveResolution.homotopyEquiv_inv_\u03c0\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 \u2115 :=\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.\u03c0 (Z : C) [HasProjectiveResolution Z] :\n    projectiveResolution Z \u27f6 (ChainComplex.single\u2080 C).obj Z :=\n  (HasProjectiveResolution.out Z).some.\u03c0\n#align category_theory.projective_resolution.\u03c0 CategoryTheory.projectiveResolution.\u03c0\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 \u27f6 Y) [HasProjectiveResolution X]\n    [HasProjectiveResolution Y] : projectiveResolution X \u27f6 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(`\u2115`-indexed chain complexes and chain maps up to homotopy).\n-/\ndef projectiveResolutions : C \u2964 HomotopyCategory C (ComplexShape.down \u2115)\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 [\u2190 (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 [\u2190 (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 \u2192 tree \u2192 bool`,\nthe motive is `tree \u2192 bool`, and the inductive step calls the inductive hypotheses,\nwhich are `left : tree \u2192 bool` and `right : tree bool` on the current left and right subtrees.\n\nThis is an issue, because `tree \u2192 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 \u2192 bool`.\n\nIn general, for a W-type with nodes labeled by `\u03b1` and children by `\u03b2 : \u03b1 \u2192 Type`,\nwe write `stack_rec : W_type \u03b2 \u2192 \u03b3 \u2192 \u03b4`, defined primarily by\n  - `pre : \u03a0 x, \u03b2 x \u2192 \u03b3 \u2192 \u03b3`: \"prepares\" the arguments to the inductive hypothesis,\n    given the current node's children `\u03a0 x, \u03b2 x` and the current argument `\u03b3`\n  - `post : (\u03a0 x, (\u03b2 x \u2192 \u03b4) \u2192 \u03b4) \u2192 \u03b3 \u2192 \u03b4`: computes the result given the inductive\n  hypotheses `(\u03b2 x \u2192 \u03b4)` and the current argument `\u03b3`.\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 {\u03b1 : Type} {\u03b2 : Type} (base : \u03b1 \u2192 \u03b2) (pre\u2081 pre\u2082 : tree unit \u2192 tree unit \u2192 \u03b1 \u2192 \u03b1)\n  (post : \u03b2 \u2192 \u03b2 \u2192 tree unit \u2192 tree unit \u2192 \u03b1 \u2192 \u03b2)\n\n/-- Recursion with an explicit stack for `tree unit` -/\n@[simp]\ndef stack_rec : tree unit \u2192 \u03b1 \u2192 \u03b2\n| nil d := base d\n| (x \u25b3 y) d := post (stack_rec x (pre\u2081 x y d)) (stack_rec y (pre\u2082 x y d)) x y d\n\n/-- An element on the stack is either the result (`sum.inr (x : \u03b2)`), or\n  the: tree, the argument \u03b1, and potentially what the left branch computed\n  if that computation has finished (`option \u03b2`)\n  -/\nabbreviation iterator_stack (\u03b1 \u03b2 : Type) := (tree unit \u00d7 \u03b1 \u00d7 option \u03b2) \u2295 \u03b2\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 \u03b1 \u03b2) \u2192 list (iterator_stack \u03b1 \u03b2)\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\u2082 tree.left tree.right arg, none) :: L\n| (sum.inl (nil, arg, none) :: xs) := sum.inr (base arg) :: xs\n| L@(sum.inl (x \u25b3 y, arg, none) :: xs) := sum.inl (x, pre\u2081 x y arg, none) :: L\n| x := x\n\n@[simp] lemma stack_step_nil : stack_step base pre\u2081 pre\u2082 post [] = [] := rfl\n@[simp] lemma stack_step_singleton (res : \u03b2) :\n  stack_step base pre\u2081 pre\u2082 post [sum.inr res] = [sum.inr res] := rfl\n\ndef time_steps (x : tree unit) : \u2115 := 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 \u25b3 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 : \u03b1) (xs : list (iterator_stack \u03b1 \u03b2)) :\n  (stack_step base pre\u2081 pre\u2082 post)^[x.time_steps] (sum.inl (x, arg, none) :: xs) =\n  (sum.inr $ x.stack_rec base pre\u2081 pre\u2082 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 : \u03b1) {n : \u2115} (hn : x.time_steps \u2264 n) :\n  (stack_step base pre\u2081 pre\u2082 post)^[n] [sum.inl (x, arg, none)] =\n    [sum.inr $ x.stack_rec base pre\u2081 pre\u2082 post arg] :=\nbegin\n  rcases le_iff_exists_add'.mp hn with \u27e8n, rfl\u27e9,\n  simp [function.iterate_add, function.iterate_fixed],\nend\n\nlemma stack_step_iterate_min (x : tree unit) (arg : \u03b1) (n : \u2115) :\n  (stack_step base pre\u2081 pre\u2082 post)^[min n x.time_steps] [sum.inl (x, arg, none)] =\n    ((stack_step base pre\u2081 pre\u2082 post)^[n] [sum.inl (x, arg, none)]) :=\n(le_total n x.time_steps).elim \n  (\u03bb H, by rw min_eq_left_iff.mpr H)\n  (\u03bb H, by rwa [min_eq_right_iff.mpr H, stack_step_iterate, stack_step_iterate'])\n\nend tree\n\nnamespace list\nvariables {\u03b1 \u03b2 : Type} {\u03b3 : Type*} (base : \u03b1 \u2192 \u03b2) (pre : \u03b3 \u2192 list \u03b3 \u2192 \u03b1 \u2192 \u03b1)\n  (post : \u03b2 \u2192 \u03b3 \u2192 list \u03b3 \u2192 \u03b1 \u2192 \u03b2)\n\n@[simp] def stack_rec : list \u03b3 \u2192 \u03b1 \u2192 \u03b2\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 {\u03b1 \u03b2 : Type} (base : \u03b1 \u2192 \u03b2) (pre : \u2115 \u2192 \u03b1 \u2192 \u03b1) (post : \u03b2 \u2192 \u2115 \u2192 \u03b1 \u2192 \u03b2)\n\n@[simp] def stack_rec : \u2115 \u2192 \u03b1 \u2192 \u03b2\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 : \u2115} {\u03b1 : fin n \u2192 Type u}\n\ninstance [\u2200 i, inhabited (\u03b1 i)] : inhabited (d_array n \u03b1) :=\n\u27e8\u27e8\u03bb _, default _\u27e9\u27e9\n\nend d_array\n\nnamespace array\n\ninstance {n \u03b1} [inhabited \u03b1] : inhabited (array n \u03b1) :=\nd_array.inhabited\n\ntheorem to_list_of_heq {n\u2081 n\u2082 \u03b1} {a\u2081 : array n\u2081 \u03b1} {a\u2082 : array n\u2082 \u03b1}\n  (hn : n\u2081 = n\u2082) (ha : a\u2081 == a\u2082) : a\u2081.to_list = a\u2082.to_list :=\nby congr; assumption\n\n/- rev_list -/\n\nsection rev_list\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem rev_list_reverse_aux : \u2200 i (h : i \u2264 n) (t : list \u03b1),\n  (a.iterate_aux (\u03bb _, (::)) i h []).reverse_core t = a.rev_iterate_aux (\u03bb _, (::)) 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 [\u2190rev_list_reverse, list.reverse_reverse]\n\nend rev_list\n\n/- mem -/\n\nsection mem\nvariables {n : \u2115} {\u03b1 : Type u} {v : \u03b1} {a : array n \u03b1}\n\ntheorem mem.def : v \u2208 a \u2194 \u2203 i, a.read i = v :=\niff.rfl\n\ntheorem mem_rev_list_aux : \u2200 {i} (h : i \u2264 n),\n  (\u2203 (j : fin n), (j : \u2115) < i \u2227 read a j = v) \u2194 v \u2208 a.iterate_aux (\u03bb _, (::)) i h []\n| 0     _ := \u27e8\u03bb \u27e8i, n, _\u27e9, absurd n i.val.not_lt_zero, false.elim\u27e9\n| (i+1) h := let IH := mem_rev_list_aux (le_of_lt h) in\n  \u27e8\u03bb \u27e8j, ji1, e\u27e9, or.elim (lt_or_eq_of_le $ nat.le_of_succ_le_succ ji1)\n    (\u03bb ji, list.mem_cons_of_mem _ $ IH.1 \u27e8j, ji, e\u27e9)\n    (\u03bb je, by simp [d_array.iterate_aux]; apply or.inl; unfold read at e;\n          have H : j = \u27e8i, h\u27e9 := fin.eq_of_veq je; rwa [\u2190H, e]),\n  \u03bb m, begin\n    simp [d_array.iterate_aux, list.mem] at m,\n    cases m with e m',\n    exact \u27e8\u27e8i, h\u27e9, nat.lt_succ_self _, eq.symm e\u27e9,\n    exact let \u27e8j, ji, e\u27e9 := IH.2 m' in\n    \u27e8j, nat.le_succ_of_le ji, e\u27e9\n  end\u27e9\n\n@[simp] theorem mem_rev_list : v \u2208 a.rev_list \u2194 v \u2208 a :=\niff.symm $ iff.trans\n  (exists_congr $ \u03bb j, iff.symm $\n    show j.1 < n \u2227 read a j = v \u2194 read a j = v,\n    from and_iff_right j.2)\n  (mem_rev_list_aux _)\n\n@[simp] theorem mem_to_list : v \u2208 a.to_list \u2194 v \u2208 a :=\nby rw \u2190rev_list_reverse; exact list.mem_reverse.trans mem_rev_list\n\nend mem\n\n/- foldr -/\n\nsection foldr\nvariables {n : \u2115} {\u03b1 : Type u} {\u03b2 : Type w} {b : \u03b2} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem rev_list_foldr_aux : \u2200 {i} (h : i \u2264 n),\n  (d_array.iterate_aux a (\u03bb _, (::)) i h []).foldr f b = d_array.iterate_aux a (\u03bb _, f) i h b\n| 0     h := rfl\n| (j+1) h := congr_arg (f (read a \u27e8j, h\u27e9)) (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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type w} {b : \u03b2} {f : \u03b2 \u2192 \u03b1 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem to_list_foldl : a.to_list.foldl f b = a.foldl b (function.swap f) :=\nby rw [\u2190rev_list_reverse, list.foldl_reverse, rev_list_foldr]\n\nend foldl\n\n/- length -/\n\nsection length\nvariables {n : \u2115} {\u03b1 : Type u}\n\ntheorem rev_list_length_aux (a : array n \u03b1) (i h) :\n  (a.iterate_aux (\u03bb _, (::)) i h []).length = i :=\nby induction i; simp [*, d_array.iterate_aux]\n\n@[simp] theorem rev_list_length (a : array n \u03b1) : a.rev_list.length = n :=\nrev_list_length_aux a _ _\n\n@[simp] theorem to_list_length (a : array n \u03b1) : a.to_list.length = n :=\nby rw[\u2190rev_list_reverse, list.length_reverse, rev_list_length]\n\nend length\n\n/- nth -/\n\nsection nth\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem to_list_nth_le_aux (i : \u2115) (ih : i < n) : \u2200 j {jh t h'},\n  (\u2200 k tl, j + k = i \u2192 list.nth_le t k tl = a.read \u27e8i, ih\u27e9) \u2192\n  (a.rev_iterate_aux (\u03bb _, (::)) j jh t).nth_le i h' = a.read \u27e8i, ih\u27e9\n| 0     _  _ _  al := al i _ $ zero_add _\n| (j+1) jh t h' al := to_list_nth_le_aux j $ \u03bb k tl hjk,\n  show list.nth_le (a.read \u27e8j, jh\u27e9 :: t) k tl = a.read \u27e8i, ih\u27e9, 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 : \u2115) (h h') : list.nth_le a.to_list i h' = a.read \u27e8i, h\u27e9 :=\nto_list_nth_le_aux _ _ _ (\u03bb k tl, absurd tl k.not_lt_zero)\n\n@[simp] theorem to_list_nth_le' (a : array n \u03b1) (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 \u2194 \u2203 h, a.read \u27e8i, h\u27e9 = 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 \u27e8ll \u25b8 h, (to_list_nth_le _ _ _).symm\u27e9 },\n  { exact \u27e8ll.symm \u25b8 h, to_list_nth_le _ _ _\u27e9 }\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) $ \u03bb j h\u2081 h\u2082, begin\n  have h\u2083 : j < n, {simpa using h\u2081},\n  rw [to_list_nth_le _ h\u2083],\n  refine let \u27e8_, e\u27e9 := list.nth_eq_some.1 _ in e.symm,\n  by_cases ij : (i : \u2115) = j,\n  { subst j, rw [show (\u27e8(i : \u2115), h\u2083\u27e9 : fin _) = i, from fin.eq_of_veq rfl,\n      array.read_write, list.nth_update_nth_of_lt],\n    simp [h\u2083] },\n  { rw [list.nth_update_nth_ne _ _ ij, a.read_write_of_ne,\n        to_list_nth.2 \u27e8h\u2083, rfl\u27e9],\n    exact fin.ne_of_vne ij }\nend\n\nend nth\n\n/- enum -/\n\nsection enum\nvariables {n : \u2115} {\u03b1 : Type u} {a : array n \u03b1}\n\ntheorem mem_to_list_enum {i v} : (i, v) \u2208 a.to_list.enum \u2194 \u2203 h, a.read \u27e8i, h\u27e9 = 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 : \u2115} {\u03b1 : Type u}\n\n@[simp] theorem to_list_to_array (a : array n \u03b1) : a.to_list.to_array == a :=\nheq_of_heq_of_eq\n  (@@eq.drec_on (\u03bb m (e : a.to_list.length = m), (d_array.mk (\u03bb v, a.to_list.nth_le v.1 v.2)) ==\n    (@d_array.mk m (\u03bb _, \u03b1) $ \u03bb v, a.to_list.nth_le v.1 $ e.symm \u25b8 v.2)) a.to_list_length heq.rfl) $\n  d_array.ext $ \u03bb \u27e8i, h\u27e9, to_list_nth_le i h _\n\n@[simp] theorem to_array_to_list (l : list \u03b1) : l.to_array.to_list = l :=\nlist.ext_le (to_list_length _) $ \u03bb n h1 h2, to_list_nth_le _ h2 _\n\nend to_array\n\n/- push_back -/\n\nsection push_back\nvariables {n : \u2115} {\u03b1 : Type u} {v : \u03b1} {a : array n \u03b1}\n\nlemma push_back_rev_list_aux : \u2200 i h h',\n  d_array.iterate_aux (a.push_back v) (\u03bb _, (::)) i h [] = d_array.iterate_aux a (\u03bb _, (::)) i h' []\n| 0 h h' := rfl\n| (i+1) h h' := begin\n  simp [d_array.iterate_aux],\n  refine \u27e8_, push_back_rev_list_aux _ _ _\u27e9,\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 [\u2190rev_list_reverse, \u2190rev_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 : \u00ac 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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type v} {i : fin n} {f : fin n \u2192 \u03b1 \u2192 \u03b2} {a : array n \u03b1}\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 : \u2115} {\u03b1 : Type u} {\u03b2 : Type v} {i : fin n} {f : \u03b1 \u2192 \u03b2} {a : array n \u03b1}\n\ntheorem read_map : (a.map f).read i = f (a.read i) :=\nread_foreach\n\nend map\n\n/- map\u2082 -/\n\nsection map\u2082\nvariables {n : \u2115} {\u03b1 : Type u} {i : fin n} {f : \u03b1 \u2192 \u03b1 \u2192 \u03b1} {a\u2081 a\u2082 : array n \u03b1}\n\n@[simp] theorem read_map\u2082 : (map\u2082 f a\u2081 a\u2082).read i = f (a\u2081.read i) (a\u2082.read i) :=\nread_foreach\n\nend map\u2082\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 : \u2115} (\u03b1 : fin n \u2192 Type*) : d_array n \u03b1 \u2243 (\u03a0 i, \u03b1 i) :=\n\u27e8d_array.read, d_array.mk, \u03bb \u27e8f\u27e9, rfl, \u03bb f, rfl\u27e9\n\n/-- The natural equivalence between length-`n` arrays and functions from `fin n`. -/\ndef array_equiv_fin (n : \u2115) (\u03b1 : Type*) : array n \u03b1 \u2243 (fin n \u2192 \u03b1) :=\nd_array_equiv_fin _\n\n/-- The natural equivalence between length-`n` vectors and length-`n` arrays. -/\ndef vector_equiv_array (\u03b1 : Type*) (n : \u2115) : vector \u03b1 n \u2243 array n \u03b1 :=\n(vector_equiv_fin _ _).trans (array_equiv_fin _ _).symm\n\nend equiv\n\nnamespace array\nopen function\nvariable {n : \u2115}\n\ninstance : traversable (array n) :=\n@equiv.traversable (flip vector n) _ (\u03bb \u03b1, equiv.vector_equiv_array \u03b1 n) _\n\ninstance : is_lawful_traversable (array n) :=\n@equiv.is_lawful_traversable (flip vector n) _ (\u03bb \u03b1, equiv.vector_equiv_array \u03b1 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 data.real.irrational\nimport topology.basic\nimport algebra.order.floor\n\n\n--OUTPUT 1\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u00ac is_rat \u03b1) : \u2200 y \u2208 Icc 0 1, \u2203 x \u2208 Icc 0 1, \u2203 N : \u2124, |y - N * \u03b1| < 1 :=\nbegin\n  assume (y : \u211d) (h1 : y \u2208 Icc 0 1),\n  let S := {x : \u211d | \u2203 N : \u2124, x = N * \u03b1},\n  have h2 : \u2200 (i j : \u2124), i \u2260 j \u2192 {i * \u03b1} \u2260 {j * \u03b1}, from by auto [h\u03b1, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.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--OUTPUT 2\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h1 : \u00ac is_rat \u03b1) : \u2200 y \u2208 Icc 0 1, \u2203 x \u2208 Icc 0 1, \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |(n*\u03b1)%\u211d - y| < \u03b5 :=\nbegin\n  assume y h2,\n  have h3 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h1, is_rat_iff_rat],\n  have h4 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h3],\n  have h5 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h4],\n  have h6 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h5],\n  have h7 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h6],\n  have h8 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h7],\n  have h9 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h8],\n  have h10 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h9],\n  have h11 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h10],\n  have h12 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h11],\n  have h13 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h12],\n  have h14 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h13],\n  have h15 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h14],\n  have h16 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h15],\n  have h17 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h16],\n  have h18 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h17],\n  have h19 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h18],\n  have h20 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h19],\n  have h21 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h20],\n  have h22 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h21],\n  have h23 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h22],\n  have h24 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h23],\n  have h25 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h24],\n  have h26 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h25],\n  have h27 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h26],\n  have h28 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h27],\n  have h29 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h28],\n  have h30 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h29],\n  have h31 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h30],\n  have h32 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h31],\n  have h33 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h32],\n  have h34 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h33],\n  have h35 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h34],\n  have h36 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h35],\n  have h37 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h36],\n  have h38 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h37],\n  have h39 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h38],\n  have h40 : \u2200 i j : \u2124, i \u2260 j \u2192 (i*\u03b1)%\u211d - (j*\u03b1)%\u211d \u2260 0, from by auto [h39],\n \nend --Needs more than 2000 tokens!\n\n--OUTPUT 3\ntheorem irrational_orbit_dense {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h : \u00ac is_rat \u03b1) : \u2200 y \u2208 Icc 0 1, \u2203 x \u2208 (set.range (\u03bb n : \u2124, n \u2022 \u03b1)), |y - x| < 1 :=\nbegin\n  assume y h1,\n  have h2 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h3 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h4 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h5 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h6 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h7 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h8 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h9 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h10 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h11 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h12 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h13 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h14 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h15 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h16 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h17 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h18 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h19 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h20 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h21 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h22 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h23 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h24 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h25 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h26 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h27 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h28 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h29 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h30 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h31 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h32 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h33 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h34 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h35 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h36 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h37 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h38 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, from by auto [h, is_rat_iff_rat],\n  have h39 : \u2200 i j : \u2124, i \u2260 j \u2192 (i \u2022 \u03b1) % 1 \u2260 (j \u2022 \u03b1) % 1, 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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from by auto [abs_sub_lt_iff] using [linarith],\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : \u03b5 > 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 \u03b5 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 \u03b5 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 : \u2200 n > N, n > N1 \u2227 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 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \n  from by auto [h8, h10, h5, h9],\n\n  --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n  have h15 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \n  from by auto [h11] using [linarith],\n\n  --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n  --Hence the result\n  show  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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.2_max_tokens_2000_n_3/clean_files/Density of irrational orbit.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8354835452961425, "lm_q2_score": 0.5506073655352404, "lm_q1q2_score": 0.46002339382355173}}
{"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 \" \u2296 \" => Int.mk\n\ntheorem zero_mk_zero : 0 \u2296 0 = 0 := rfl\n\ntheorem zero_mk_succ (n) : (0 \u2296 n + 1) = Int.negSucc n := rfl\n\ntheorem succ_mk_zero (m) : (m + 1 \u2296 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 \u2296 n + 1) = (m \u2296 n) := by\n  rw [Int.mk, Int.subNatNat, Int.subNatNat, Nat.succ_sub_succ, Nat.succ_sub_succ]\n\ntheorem mk_zero (m) : (m \u2296 0) = ofNat m := by\n  rw [Int.mk, Int.subNatNat, Nat.zero_sub, Nat.sub_zero]\n\ntheorem zero_mk (n) : (0 \u2296 n) = negOfNat n :=\n  match n with\n  | 0 => rfl\n  | _+1 => rfl\n\ntheorem one_mk_zero : (1 \u2296 0) = 1 := rfl\n\nprotected def recMk.{u} {motive : Int \u2192 Sort u} (mk : (m n : Nat) \u2192 motive (m \u2296 n)) : (i : Int) \u2192 motive i\n| Int.ofNat m => mk_zero m \u25b8 mk m 0\n| Int.negSucc n => mk 0 (n + 1)\n\nprotected def recMkOn.{u} {motive : Int \u2192 Sort u} (i : Int) (mk : (m n : Nat) \u2192 motive (m \u2296 n)) : motive i := Int.recMk mk i\n\nprotected def casesMkOn.{u} {motive : Int \u2192 Sort u} (i : Int) (mk : (m n : Nat) \u2192 motive (m \u2296 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 \u2296 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 \u2296 k + n) = (m \u2296 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 \u2296 n + k) = (m \u2296 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 \u2296 n) + ofNat k = (m + k \u2296 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 \u2296 n) + negSucc k = (m \u2296 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\u2081 n\u2081 m\u2082 n\u2082) : (m\u2081 \u2296 n\u2081) + (m\u2082 \u2296 n\u2082) = (m\u2081 + m\u2082 \u2296 n\u2081 + n\u2082) := by\n  induction m\u2082, n\u2082 with\n  | zero_zero => rw [zero_mk_zero, Int.add_zero, Nat.add_zero, Nat.add_zero]\n  | zero_succ n\u2082 => rw [zero_mk_succ, Nat.add_succ', mk_add_negSucc]; rfl\n  | succ_zero m\u2082 => rw [mk_zero, mk_add_ofNat]; rfl\n  | succ_succ m\u2082 n\u2082 ih => rw [succ_mk_succ, Nat.add_succ' m\u2081 m\u2082, Nat.add_succ' n\u2081 n\u2082, succ_mk_succ]; exact ih\n\ntheorem neg_mk (m n) : -(m \u2296 n) = (n \u2296 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\u2081 n\u2081 m\u2082 n\u2082) : (m\u2081 \u2296 n\u2081) - (m\u2082 \u2296 n\u2082) = (m\u2081 + n\u2082 \u2296 n\u2081 + m\u2082) :=\n  show (m\u2081 \u2296 n\u2081) + -(m\u2082 \u2296 n\u2082) = (m\u2081 + n\u2082 \u2296 n\u2081 + m\u2082) by rw [neg_mk, mk_add_mk]\n\ntheorem nonNeg_mk (m n) : NonNeg (m \u2296 n) \u2194 n \u2264 m := by\n  induction m, n with\n  | zero_zero =>\n    rw [zero_mk_zero]\n    constr\n    \u00b7 intro; reflexivity\n    \u00b7 intro; apply NonNeg.mk\n  | zero_succ n =>\n    rw [zero_mk_succ]\n    constr\n    \u00b7 intro; contradiction\n    \u00b7 intro; contradiction\n  | succ_zero m =>\n    rw [succ_mk_zero]\n    constr\n    \u00b7 intro; apply Nat.zero_le\n    \u00b7 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\u2081 n\u2081 m\u2082 n\u2082) : (m\u2081 \u2296 n\u2081) \u2264 (m\u2082 \u2296 n\u2082) \u2194 n\u2082 + m\u2081 \u2264 m\u2082 + n\u2081 := by\n  simp only [LE.le, Int.le]\n  rw [mk_sub_mk, nonNeg_mk]\n  reflexivity\n\ntheorem mk_lt_mk (m\u2081 n\u2081 m\u2082 n\u2082) : (m\u2081 \u2296 n\u2081) < (m\u2082 \u2296 n\u2082) \u2194 n\u2082 + m\u2081 < m\u2082 + n\u2081 := by\n  simp only [LT.lt, Int.lt, Nat.lt]\n  rw [\u2190one_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\u2081 i\u2082 j\u2081 j\u2082 : Int) : (i\u2081 + i\u2082) + (j\u2081 + j\u2082) = (i\u2081 + j\u2081) + (i\u2082 + j\u2082) :=\n  calc\n  _ = i\u2081 + (i\u2082 + (j\u2081 + j\u2082)) := by rw [Int.add_assoc]\n  _ = i\u2081 + (j\u2081 + (i\u2082 + j\u2082)) := by rw [Int.add_left_comm i\u2082 j\u2081 j\u2082]\n  _ = (i\u2081 + j\u2081) + (i\u2082 + j\u2082) := 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 \u2296 n) * ofNat k = (m * k \u2296 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 \u2296 n) * negSucc k = (n * (k + 1) \u2296 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\u2081 n\u2081 m\u2082 n\u2082) : (m\u2081 \u2296 n\u2081) * (m\u2082 \u2296 n\u2082) = (m\u2081 * m\u2082 + n\u2081 * n\u2082 \u2296 m\u2081 * n\u2082 + n\u2081 * m\u2082) := by\n  induction m\u2082, n\u2082 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\u2082 => simp only [Nat.zero_mul, Nat.mul_zero, Nat.add_zero, Nat.zero_add, zero_mk_succ, mk_mul_negSucc]\n  | succ_zero m\u2082 => 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\u2082 n\u2082 ih => simp only [Nat.mul_succ, Nat.succ_mul]; rw [succ_mk_succ, Nat.add_cross_comm _ m\u2081 _ n\u2081, Nat.add_cross_comm _ m\u2081 _ n\u2081, 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\u2081 i\u2082 j\u2081 j\u2082 : Int) : (i\u2081 * i\u2082) * (j\u2081 * j\u2082) = (i\u2081 * j\u2081) * (i\u2082 * j\u2082) :=\n  calc\n  _ = i\u2081 * (i\u2082 * (j\u2081 * j\u2082)) := by rw [Int.mul_assoc]\n  _ = i\u2081 * (j\u2081 * (i\u2082 * j\u2082)) := by rw [Int.mul_left_comm i\u2082 j\u2081 j\u2082]\n  _ = (i\u2081 * j\u2081) * (i\u2082 * j\u2082) := 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 \u2264 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 \u2264 j \u2192 \u2203 (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 [\u2190hk, 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 \u2264 i\n\n-- assert theorem le_trans {i j k : Int} : i \u2264 j \u2192 j \u2264 k \u2192 i \u2264 k\n\n-- assert theorem le_antisymm {i j : Int} : i \u2264 j \u2192 j \u2264 i \u2192 i = j\n\n-- assert theorem le_total (i j : Int) : i \u2264 j \u2228 j \u2264 i\n\n-- assert theorem add_le_add_left {i j : Int} : i \u2264 j \u2192 \u2200 (k : Int), k + i \u2264 k + j\n\n-- assert theorem add_le_add_right {i j : Int} : i \u2264 j \u2192 \u2200 (k : Int), i + k \u2264 j + k\n\n-- assert theorem sub_le_sub_right {i j : Int} : i \u2264 j \u2192 \u2200 (k : Int), i - k \u2264 j - k\n\n-- assert theorem le_of_add_le_add_right {i j k : Int} (h : i + k \u2264 j + k) : i \u2264 j\n\n-- assert theorem le_of_add_le_add_left {i j k : Int} (h : i + j \u2264 i + k) : j \u2264 k\n\nprotected theorem le_succ_self (i : Int) : i \u2264 i + 1 := le.intro' ..\n\nprotected theorem lt_iff_succ_le (i j : Int) : i < j \u2194 i + 1 \u2264 j := Iff.rfl\n\nprotected theorem le_iff_lt_succ (i j : Int) : i \u2264 j \u2194 i < j + 1 := by\n  rw [Int.lt_iff_succ_le]\n  constr\n  \u00b7 apply Int.add_le_add_right (c:=1)\n  \u00b7 apply Int.le_of_add_le_add_right\n\n-- assert theorem le_of_lt {i j : Int} : i < j \u2192 i \u2264 j\n\n-- assert theorem lt_of_lt_of_le {i j k : Int} : i < j \u2192 j \u2264 k \u2192 i < k\n\n-- assert theorem lt_of_le_of_lt {i j k : Int} : i \u2264 j \u2192 j < k \u2192 i < k\n\n-- assert theorem lt_irrefl (i : Int) : \u00ac i < i\n\n-- assert theorem lt_trans {i j k : Int} : i < j \u2192 j < k \u2192 i < k\n\nprotected theorem le_or_gt (i j : Int) : i \u2264 j \u2228 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 \u2228 j \u2264 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 \u2264 j \u2192 i < j \u2228 i = j := by\n  intro hle\n  match le.dest' hle with\n  | \u27e80, (h : j = i + 0)\u27e9 =>\n    right\n    rw [h, Int.add_zero]\n  | \u27e8n+1, (h : j = i + (ofNat n + 1))\u27e9 =>\n    left\n    rw [Int.lt_iff_succ_le]\n    rw [h, \u2190Int.add_assoc, Int.add_right_comm]\n    apply Int.le.intro'\n\nprotected theorem lt_of_le_of_ne {i j : Int} : i \u2264 j \u2192 i \u2260 j \u2192 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 \u2260 j \u2192 i < j \u2228 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 \u2192 \u2200 (k : Int), i < k \u2228 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 (\u03b1:=Int) (.\u2264.) := \u27e8Int.le_refl\u27e9\ninstance : Relation.Transitive (\u03b1:=Int) (.\u2264.) := \u27e8Int.le_trans\u27e9\ninstance : Relation.Antisymmetric (\u03b1:=Int) (.\u2264.) := \u27e8Int.le_antisymm\u27e9\ninstance : Relation.Total (\u03b1:=Int) (.\u2264.) := \u27e8Int.le_total\u27e9\ninstance : Relation.Irreflexive (\u03b1:=Int) (.<.) := \u27e8Int.lt_irrefl\u27e9\ninstance : Relation.Transitive (\u03b1:=Int) (.<.) := \u27e8Int.lt_trans\u27e9\ninstance : Relation.Comparison (\u03b1:=Int) (.<.) := \u27e8Int.lt_compare\u27e9\ninstance : Relation.Connex (\u03b1:=Int) (.<.) := \u27e8Int.lt_connex\u27e9\ninstance : Relation.HTransitive (\u03b1:=Int) (.\u2264.) (.<.) (.<.) := \u27e8Int.lt_of_le_of_lt\u27e9\ninstance : Relation.HTransitive (\u03b1:=Int) (.<.) (.\u2264.) (.<.) := \u27e8Int.lt_of_lt_of_le\u27e9\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 := \u03bb _ _, star,\n  zero := star,\n  neg := \u03bb _, star,\n  mul := \u03bb _ _, star,\n  one := star,\n  .. };\nintros; exact subsingleton.elim _ _\n\ninstance : comm_group punit :=\n{ inv := \u03bb _, star,\n  mul_left_inv := \u03bb _, subsingleton.elim _ _,\n  .. punit.comm_ring }\n\ninstance : complete_boolean_algebra punit :=\nby refine\n{ le := \u03bb _ _, true,\n  le_antisymm := \u03bb _ _ _ _, subsingleton.elim _ _,\n  lt := \u03bb _ _, false,\n  lt_iff_le_not_le := \u03bb _ _, iff_of_false not_false (\u03bb H, H.2 trivial),\n  top := star,\n  bot := star,\n  sup := \u03bb _ _, star,\n  inf := \u03bb _ _, star,\n  Sup := \u03bb _, star,\n  Inf := \u03bb _, star,\n  sub := \u03bb _ _, star,\n  .. punit.comm_ring, .. };\nintros; trivial\n\ninstance : canonically_ordered_monoid punit :=\nby refine\n{ lt_of_add_lt_add_left := \u03bb _ _ _, id,\n  le_iff_exists_add := \u03bb _ _, iff_of_true _ \u27e8star, subsingleton.elim _ _\u27e9,\n  .. punit.comm_ring, .. punit.lattice.complete_boolean_algebra, .. };\nintros; trivial\n\ninstance : decidable_linear_ordered_cancel_comm_monoid punit :=\n{ add_left_cancel := \u03bb _ _ _ _, subsingleton.elim _ _,\n  add_right_cancel := \u03bb _ _ _ _, subsingleton.elim _ _,\n  le_of_add_le_add_left := \u03bb _ _ _ _, trivial,\n  le_total := \u03bb _ _, or.inl trivial,\n  decidable_le := \u03bb _ _, decidable.true,\n  decidable_eq := punit.decidable_eq,\n  decidable_lt := \u03bb _ _, decidable.false,\n  .. punit.canonically_ordered_monoid }\n\ninstance : module punit punit := module.of_core $\nby refine\n{ smul := \u03bb _ _, 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\u207b\u00b9 = star := rfl\nattribute [to_additive punit.neg_eq] punit.inv_eq\n@[simp] lemma smul_eq : x \u2022 y = star := rfl\n@[simp] lemma top_eq : (\u22a4 : punit) = star := rfl\n@[simp] lemma bot_eq : (\u22a5 : punit) = star := rfl\n@[simp] lemma sup_eq : x \u2294 y = star := rfl\n@[simp] lemma inf_eq : x \u2293 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 \u2264 y := trivial\n@[simp] lemma not_lt : \u00ac(x < y) := not_false\n\ninstance {\u03b1 : Type*} [monoid \u03b1] (f : \u03b1 \u2192 punit) : is_monoid_hom f :=\n\u27e8subsingleton.elim _ _, \u03bb _ _, subsingleton.elim _ _\u27e9\n\ninstance {\u03b1 : Type*} [add_monoid \u03b1] (f : \u03b1 \u2192 punit) : is_add_monoid_hom f :=\n\u27e8subsingleton.elim _ _, \u03bb _ _, subsingleton.elim _ _\u27e9\n\ninstance {\u03b1 : Type*} [group \u03b1] (f : \u03b1 \u2192 punit) : is_group_hom f :=\n\u27e8\u03bb _ _, subsingleton.elim _ _\u27e9\n\ninstance {\u03b1 : Type*} [add_group \u03b1] (f : \u03b1 \u2192 punit) : is_add_group_hom f :=\n\u27e8\u03bb _ _, subsingleton.elim _ _\u27e9\n\ninstance {\u03b1 : Type*} [semiring \u03b1] (f : \u03b1 \u2192 punit) : is_semiring_hom f :=\n{ .. punit.is_monoid_hom f, .. punit.is_add_monoid_hom f }\n\ninstance {\u03b1 : Type*} [ring \u03b1] (f : \u03b1 \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\n\nHahn decomposition theorem\n\nTODO:\n* introduce finite measures (into \u211d\u22650)\n* show general for signed measures (into \u211d)\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 {\u03b1 : Type u_1} [measurable_space \u03b1] {\u03bc : measure \u03b1} {\u03bd : measure \u03b1}\n    (h\u03bc : coe_fn \u03bc set.univ < \u22a4) (h\u03bd : coe_fn \u03bd set.univ < \u22a4) :\n    \u2203 (s : set \u03b1),\n        is_measurable s \u2227\n          (\u2200 (t : set \u03b1), is_measurable t \u2192 t \u2286 s \u2192 coe_fn \u03bd t \u2264 coe_fn \u03bc t) \u2227\n            \u2200 (t : set \u03b1), is_measurable t \u2192 t \u2286 (s\u1d9c) \u2192 coe_fn \u03bc t \u2264 coe_fn \u03bd 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\u00f6lzl, 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 \u27f6 Y` for the morphism spaces,\n* `f \u226b g` for composition in the 'arrows' convention.\n\nUsers may like to add `f \u229a g` for composition in the standard convention, using\n```lean\nlocal notation f ` \u229a `: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\u2081 v\u2082 u\u2081 u\u2082\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       : \u03a0 X : obj, hom X X)\n(comp     : \u03a0 {X Y Z : obj}, (X \u27f6 Y) \u2192 (Y \u27f6 Z) \u2192 (X \u27f6 Z))\n\nnotation `\ud835\udfd9` := category_struct.id -- type as \\b1\ninfixr ` \u226b `: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' : \u2200 {X Y : obj} (f : hom X Y), \ud835\udfd9 X \u226b f = f . obviously)\n(comp_id' : \u2200 {X Y : obj} (f : hom X Y), f \u226b \ud835\udfd9 Y = f . obviously)\n(assoc'   : \u2200 {W X Y Z : obj} (f : hom W X) (g : hom X Y) (h : hom Y Z),\n  (f \u226b g) \u226b h = f \u226b (g \u226b 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 \u2192 hom,\n  to_category_struct_comp \u2192 comp, to_category_struct_id \u2192 id, -to_category_struct)\n\n/-- postcompose an equation between morphisms by another morphism -/\nlemma eq_whisker {f g : X \u27f6 Y} (w : f = g) (h : Y \u27f6 Z) : f \u226b h = g \u226b h :=\nby rw w\n/-- precompose an equation between morphisms by another morphism -/\nlemma whisker_eq (f : X \u27f6 Y) {g h : Y \u27f6 Z} (w : g = h) : f \u226b g = f \u226b h :=\nby rw w\n\ninfixr ` =\u226b `:80 := eq_whisker\ninfixr ` \u226b= `:80 := whisker_eq\n\nlemma eq_of_comp_left_eq {f g : X \u27f6 Y} (w : \u2200 {Z : C} (h : Y \u27f6 Z), f \u226b h = g \u226b h) : f = g :=\nby { convert w (\ud835\udfd9 Y), tidy }\nlemma eq_of_comp_right_eq {f g : Y \u27f6 Z} (w : \u2200 {X : C} (h : X \u27f6 Y), h \u226b f = h \u226b g) : f = g :=\nby { convert w (\ud835\udfd9 Y), tidy }\n\nlemma eq_of_comp_left_eq' (f g : X \u27f6 Y)\n  (w : (\u03bb {Z : C} (h : Y \u27f6 Z), f \u226b h) = (\u03bb {Z : C} (h : Y \u27f6 Z), g \u226b h)) : f = g :=\neq_of_comp_left_eq (\u03bb Z h, by convert congr_fun (congr_fun w Z) h)\nlemma eq_of_comp_right_eq' (f g : Y \u27f6 Z)\n  (w : (\u03bb {X : C} (h : X \u27f6 Y), h \u226b f) = (\u03bb {X : C} (h : X \u27f6 Y), h \u226b g)) : f = g :=\neq_of_comp_right_eq (\u03bb X h, by convert congr_fun (congr_fun w X) h)\n\nlemma id_of_comp_left_id (f : X \u27f6 X) (w : \u2200 {Y : C} (g : X \u27f6 Y), f \u226b g = g) : f = \ud835\udfd9 X :=\nby { convert w (\ud835\udfd9 X), tidy }\nlemma id_of_comp_right_id (f : X \u27f6 X) (w : \u2200 {Y : C} (g : Y \u27f6 X), g \u226b f = g) : f = \ud835\udfd9 X :=\nby { convert w (\ud835\udfd9 X), tidy }\n\n\n\nlemma dite_comp {P : Prop} [decidable P]\n  {X Y Z : C} (f : P \u2192 (X \u27f6 Y)) (f' : \u00acP \u2192 (X \u27f6 Y)) (g : Y \u27f6 Z) :\n  (if h : P then f h else f' h) \u226b g = (if h : P then f h \u226b g else f' h \u226b g) :=\nby { split_ifs; refl }\n\n/--\nA morphism `f` is an epimorphism if it can be \"cancelled\" when precomposed:\n`f \u226b g = f \u226b h` implies `g = h`.\n\nSee https://stacks.math.columbia.edu/tag/003B.\n-/\nclass epi (f : X \u27f6 Y) : Prop :=\n(left_cancellation : \u03a0 {Z : C} (g h : Y \u27f6 Z) (w : f \u226b g = f \u226b h), g = h)\n\n/--\nA morphism `f` is a monomorphism if it can be \"cancelled\" when postcomposed:\n`g \u226b f = h \u226b f` implies `g = h`.\n\nSee https://stacks.math.columbia.edu/tag/003B.\n-/\nclass mono (f : X \u27f6 Y) : Prop :=\n(right_cancellation : \u03a0 {Z : C} (g h : Z \u27f6 X) (w : g \u226b f = h \u226b f), g = h)\n\ninstance (X : C) : epi (\ud835\udfd9 X) :=\n\u27e8\u03bb Z g h w, by simpa using w\u27e9\ninstance (X : C) : mono (\ud835\udfd9 X) :=\n\u27e8\u03bb Z g h w, by simpa using w\u27e9\n\nlemma cancel_epi (f : X \u27f6 Y) [epi f]  {g h : Y \u27f6 Z} : (f \u226b g = f \u226b h) \u2194 g = h :=\n\u27e8 \u03bb p, epi.left_cancellation g h p, begin intro a, subst a end \u27e9\nlemma cancel_mono (f : X \u27f6 Y) [mono f] {g h : Z \u27f6 X} : (g \u226b f = h \u226b f) \u2194 g = h :=\n\u27e8 \u03bb p, mono.right_cancellation g h p, begin intro a, subst a end \u27e9\n\nlemma cancel_epi_id (f : X \u27f6 Y) [epi f] {h : Y \u27f6 Y} : (f \u226b h = f) \u2194 h = \ud835\udfd9 Y :=\nby { convert cancel_epi f, simp, }\nlemma cancel_mono_id (f : X \u27f6 Y) [mono f] {g : X \u27f6 X} : (g \u226b f = f) \u2194 g = \ud835\udfd9 X :=\nby { convert cancel_mono f, simp, }\n\nlemma epi_comp {X Y Z : C} (f : X \u27f6 Y) [epi f] (g : Y \u27f6 Z) [epi g] : epi (f \u226b 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 \u27f6 Y) [mono f] (g : Y \u27f6 Z) [mono g] : mono (f \u226b 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 \u27f6 Y) (g : Y \u27f6 Z) [mono (f \u226b g)] : mono f :=\nbegin\n  split, intros Z a b w,\n  replace w := congr_arg (\u03bb k, k \u226b 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 \u27f6 Y} {g : Y \u27f6 Z} {h : X \u27f6 Z} [mono h] (w : f \u226b 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 \u27f6 Y) (g : Y \u27f6 Z) [epi (f \u226b g)] : epi g :=\nbegin\n  split, intros Z a b w,\n  replace w := congr_arg (\u03bb k, f \u226b k) w,\n  dsimp at w,\n  rw [\u2190category.assoc, \u2190category.assoc] at w,\n  exact (cancel_epi _).1 w,\nend\n\nlemma epi_of_epi_fac {X Y Z : C} {f : X \u27f6 Y} {g : Y \u27f6 Z} {h : X \u27f6 Z} [epi h] (w : f \u226b 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  := \u03bb X Y, (X.down \u27f6 Y.down),\n  id   := \u03bb X, \ud835\udfd9 X.down,\n  comp := \u03bb _ _ _ f g, f \u226b 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 \u27f6 Y` and `g : Y \u27f6 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 \u2200 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 \u2192 C \u2192 Type )\n( id : (X : C) \u2192 hom X X )\n( comp : {X Y Z : C} \u2192 hom X Y \u2192 hom Y Z \u2192 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 \" \ud835\udfd9 \" => category.id\ninfixr: 80 \" \u226b \" => category.comp\ninfixr: 10 \" \u27f6 \" => category.hom\n\nvariable (C : Type) [category C]\n\ninductive prod_coprod : Type\n| of_cat' : C \u2192 prod_coprod\n| init : prod_coprod\n| prod : prod_coprod \u2192 prod_coprod \u2192 prod_coprod\n| coprod : prod_coprod \u2192 prod_coprod \u2192 prod_coprod\n| term : prod_coprod\n\n\nvariable {C}\n\nnamespace prod_coprod\n\n@[simp] def size : prod_coprod C \u2192 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) \u2192 Type\n| of_cat {X Y : C} : (X \u27f6 Y) \u2192 syn (of_cat' X) (of_cat' Y)\n| prod_mk {X Y Z : prod_coprod C} : syn X Y \u2192 syn X Z \u2192 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 \u2192 syn Y Z \u2192 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 \u2192 syn Y Z \u2192 syn X Z\n\nnamespace syn\n\ninductive rel : {X Y : prod_coprod C} \u2192 syn X Y \u2192 syn X Y \u2192 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 \u2192 rel g f\n| trans {X Y : prod_coprod C} {f g h : syn X Y} : rel f g \u2192 rel g h \u2192 rel f h\n| comp_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syn X Y} {g\u2081 g\u2082 : syn Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.comp g\u2081) (f\u2082.comp g\u2082)\n| prod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syn X Y} {g\u2081 g\u2082 : syn X Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.prod_mk g\u2081) (f\u2082.prod_mk g\u2082)\n| coprod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : syn X Z} {g\u2081 g\u2082 : syn Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (f\u2081.coprod_mk g\u2081) (f\u2082.coprod_mk g\u2082)\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 (\ud835\udfd9 X)) (syn.id (of_cat' X))\n| of_cat_comp {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  rel (syn.of_cat (f \u226b 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 \" \u2665 \" => 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\u2081 : rel (f.comp syn.fst) (g.comp syn.fst))\n  (h\u2082 : 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\u2081 h\u2082) (rel.prod_eta g))\n\ntheorem rel_coprod {X Y Z : prod_coprod C} {f g : syn (X.coprod Y) Z}\n  (h\u2081 : rel (syn.inl.comp f) (syn.inl.comp g))\n  (h\u2082 : 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\u2081 h\u2082) (rel.coprod_eta g))\n\nend syn\n\ninductive norm_hom : (X Y : prod_coprod C) \u2192 Type\n| of_cat {X Y : C} (f : X \u27f6 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} \u2192 norm_hom X Y \u2192 norm_hom X Y \u2192 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 \u2192 rel f g\n| trans {X Y : prod_coprod C} {f g h : norm_hom X Y} : rel f g \u2192 rel g h \u2192 rel f h\n| coprod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Z} {g\u2081 g\u2082 : norm_hom Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (coprod_mk f\u2081 g\u2081) (coprod_mk f\u2082 g\u2082)\n| prod_mk_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Y} {g\u2081 g\u2082 : norm_hom X Z} :\n  rel f\u2081 f\u2082 \u2192 rel g\u2081 g\u2082 \u2192 rel (prod_mk f\u2081 g\u2081) (prod_mk f\u2082 g\u2082)\n| comp_inl_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Y} :\n  rel f\u2081 f\u2082 \u2192 rel (comp_inl f\u2081 : norm_hom X (coprod Y Z)) (comp_inl f\u2082)\n| comp_inr_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Z} :\n  rel f\u2081 f\u2082 \u2192 rel (comp_inr f\u2081 : norm_hom X (coprod Y Z)) (comp_inr f\u2082)\n| fst_comp_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom X Z} :\n  rel f\u2081 f\u2082 \u2192 rel (fst_comp f\u2081 : norm_hom (prod X Y) Z) (fst_comp f\u2082)\n| snd_comp_congr {X Y Z : prod_coprod C} {f\u2081 f\u2082 : norm_hom Y Z} :\n  rel f\u2081 f\u2082 \u2192 rel (snd_comp f\u2081 : norm_hom (prod X Y) Z) (snd_comp f\u2082)\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} \u2192 (f : norm_hom X (coprod Y Z)) \u2192\n  Option ((norm_hom X Y) \u2295 (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} \u2192 {f : norm_hom X (coprod Y Z)} \u2192\n  {g : norm_hom X Y} \u2192 to_inj f = some (Sum.inl g) \u2192 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 : \u2203 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 \u27e8i, rfl\u27e9\n    | some (Sum.inr _) => simp\n    | none => simp }\n  match hi with\n  | \u27e8i, hi\u27e9 => by\n  simp [hi, to_inj] at h\n  rw [\u2190 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 : \u2203 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 \u27e8i, rfl\u27e9\n    | some (Sum.inr _) => simp\n    | none => simp }\n  match hi with\n  | \u27e8i, hi\u27e9 => by\n  simp [hi, to_inj] at h\n  rw [\u2190 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 : \u2203 f' g', to_inj f = some (Sum.inl f') \u2227 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 \u27e8f', g', rfl, rfl\u27e9\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  | \u27e8f', g', hf, hg\u27e9 => by\n  simp [hf, hg, to_inj] at h\n  rw [\u2190 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} \u2192 {f : norm_hom X (coprod Y Z)} \u2192\n  {g : norm_hom X Z} \u2192 to_inj f = some (Sum.inr g) \u2192 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 : \u2203 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 \u27e8i, rfl\u27e9\n    | some (Sum.inl _) => simp\n    | none => simp }\n  match hi with\n  | \u27e8i, hi\u27e9 => by\n  simp [hi, to_inj] at h\n  rw [\u2190 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 : \u2203 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 \u27e8i, rfl\u27e9\n    | some (Sum.inl _) => simp\n    | none => simp }\n  match hi with\n  | \u27e8i, hi\u27e9 => by\n  simp [hi, to_inj] at h\n  rw [\u2190 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 : \u2203 f' g', to_inj f = some (Sum.inr f') \u2227 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 \u27e8f', g', rfl, rfl\u27e9\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  | \u27e8f', g', hf, hg\u27e9 => by\n  simp [hf, hg, to_inj] at h\n  rw [\u2190 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} : \u00acrel 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 \u03b1 \u03b2 \u03b3 \u03b4 : Type _}\n\nnamespace OrderIso\n\nsection LE\n\nvariable [LE \u03b1] [LE \u03b2] [LE \u03b3]\n\n/- warning: order_iso.range_eq -> OrderIso.range_eq is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (e : OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{succ u2} (Set.{u2} \u03b2) (Set.range.{u2, succ u1} \u03b2 \u03b1 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e)) (Set.univ.{u2} \u03b2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LE.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (e : OrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2), Eq.{succ u1} (Set.{u1} \u03b2) (Set.range.{u1, succ u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e)))) (Set.univ.{u1} \u03b2)\nCase conversion may be inaccurate. Consider using '#align order_iso.range_eq OrderIso.range_eq\u2093'. -/\ntheorem range_eq (e : \u03b1 \u2243o \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (e : OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u1} \u03b1), Eq.{succ u1} (Set.{u1} \u03b1) (Set.image.{u2, u1} \u03b2 \u03b1 (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} \u03b2 \u03b1 _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) => \u03b2 -> \u03b1) (RelIso.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) (OrderIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 e)) (Set.image.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) s)) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LE.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (e : OrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u2} \u03b1), Eq.{succ u2} (Set.{u2} \u03b1) (Set.image.{u1, u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b2) => \u03b1) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 \u03b1 (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} \u03b2 \u03b1)) (RelEmbedding.toEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 e)))) (Set.image.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _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\u2093'. -/\n@[simp]\ntheorem symm_image_image (e : \u03b1 \u2243o \u03b2) (s : Set \u03b1) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (e : OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u2} \u03b2), Eq.{succ u2} (Set.{u2} \u03b2) (Set.image.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) (Set.image.{u2, u1} \u03b2 \u03b1 (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} \u03b2 \u03b1 _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) => \u03b2 -> \u03b1) (RelIso.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) (OrderIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 e)) s)) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LE.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (e : OrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u1} \u03b2), Eq.{succ u1} (Set.{u1} \u03b2) (Set.image.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) (Set.image.{u1, u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b2) => \u03b1) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 \u03b1 (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} \u03b2 \u03b1)) (RelEmbedding.toEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 e)))) s)) s\nCase conversion may be inaccurate. Consider using '#align order_iso.image_symm_image OrderIso.image_symm_image\u2093'. -/\n@[simp]\ntheorem image_symm_image (e : \u03b1 \u2243o \u03b2) (s : Set \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (e : OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u1} \u03b1), Eq.{succ u2} (Set.{u2} \u03b2) (Set.image.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) s) (Set.preimage.{u2, u1} \u03b2 \u03b1 (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} \u03b2 \u03b1 _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) => \u03b2 -> \u03b1) (RelIso.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) (OrderIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 e)) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LE.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (e : OrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u2} \u03b1), Eq.{succ u1} (Set.{u1} \u03b2) (Set.image.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) s) (Set.preimage.{u1, u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b2) => \u03b1) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 \u03b1 (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} \u03b2 \u03b1)) (RelEmbedding.toEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 e)))) s)\nCase conversion may be inaccurate. Consider using '#align order_iso.image_eq_preimage OrderIso.image_eq_preimage\u2093'. -/\ntheorem image_eq_preimage (e : \u03b1 \u2243o \u03b2) (s : Set \u03b1) : e '' s = e.symm \u207b\u00b9' 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (e : OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u1} \u03b1), Eq.{succ u1} (Set.{u1} \u03b1) (Set.preimage.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) (Set.preimage.{u2, u1} \u03b2 \u03b1 (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} \u03b2 \u03b1 _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) => \u03b2 -> \u03b1) (RelIso.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) (OrderIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 e)) s)) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LE.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (e : OrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u2} \u03b1), Eq.{succ u2} (Set.{u2} \u03b1) (Set.preimage.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) (Set.preimage.{u1, u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b2) => \u03b1) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 \u03b1 (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} \u03b2 \u03b1)) (RelEmbedding.toEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 e)))) s)) s\nCase conversion may be inaccurate. Consider using '#align order_iso.preimage_symm_preimage OrderIso.preimage_symm_preimage\u2093'. -/\n@[simp]\ntheorem preimage_symm_preimage (e : \u03b1 \u2243o \u03b2) (s : Set \u03b1) : e \u207b\u00b9' (e.symm \u207b\u00b9' 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (e : OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u2} \u03b2), Eq.{succ u2} (Set.{u2} \u03b2) (Set.preimage.{u2, u1} \u03b2 \u03b1 (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} \u03b2 \u03b1 _inst_2 _inst_1) (fun (_x : RelIso.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) => \u03b2 -> \u03b1) (RelIso.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 _inst_2) (LE.le.{u1} \u03b1 _inst_1)) (OrderIso.symm.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 e)) (Set.preimage.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) s)) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LE.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (e : OrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u1} \u03b2), Eq.{succ u1} (Set.{u1} \u03b2) (Set.preimage.{u1, u2} \u03b2 \u03b1 (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b2) => \u03b1) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 \u03b1 (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} \u03b2 \u03b1)) (RelEmbedding.toEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2 e)))) (Set.preimage.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _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\u2093'. -/\n@[simp]\ntheorem symm_preimage_preimage (e : \u03b1 \u2243o \u03b2) (s : Set \u03b2) : e.symm \u207b\u00b9' (e \u207b\u00b9' 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (e : OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u2} \u03b2), Eq.{succ u2} (Set.{u2} \u03b2) (Set.image.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) (Set.preimage.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) s)) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LE.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (e : OrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u1} \u03b2), Eq.{succ u1} (Set.{u1} \u03b2) (Set.image.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) (Set.preimage.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _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\u2093'. -/\n@[simp]\ntheorem image_preimage (e : \u03b1 \u2243o \u03b2) (s : Set \u03b2) : e '' (e \u207b\u00b9' 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LE.{u1} \u03b1] [_inst_2 : LE.{u2} \u03b2] (e : OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u1} \u03b1), Eq.{succ u1} (Set.{u1} \u03b1) (Set.preimage.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) (Set.image.{u1, u2} \u03b1 \u03b2 (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 _inst_1) (LE.le.{u2} \u03b2 _inst_2)) e) s)) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LE.{u2} \u03b1] [_inst_2 : LE.{u1} \u03b2] (e : OrderIso.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (s : Set.{u2} \u03b1), Eq.{succ u2} (Set.{u2} \u03b1) (Set.preimage.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) e))) (Set.image.{u2, u1} \u03b1 \u03b2 (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _inst_2 x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 _inst_1 x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 _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\u2093'. -/\n@[simp]\ntheorem preimage_image (e : \u03b1 \u2243o \u03b2) (s : Set \u03b1) : e \u207b\u00b9' (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 \u03b1] [Preorder \u03b2] [Preorder \u03b3]\n\n#print OrderIso.setCongr /-\n/-- Order isomorphism between two equal sets. -/\ndef setCongr (s t : Set \u03b1) (h : s = t) : s \u2243o 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 \u03b1` and `\u03b1`. -/\ndef Set.univ : (Set.univ : Set \u03b1) \u2243o \u03b1\n    where\n  toEquiv := Equiv.Set.univ \u03b1\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 {\u03b1 \u03b2} [LinearOrder \u03b1] [Preorder \u03b2] (f : \u03b1 \u2192 \u03b2)\n    (s : Set \u03b1) (hf : StrictMonoOn f s) : s \u2243o 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 {\u03b1 \u03b2} [LinearOrder \u03b1] [Preorder \u03b2]\n\nvariable (f : \u03b1 \u2192 \u03b2) (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 : \u03b1 \u2243o 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 : \u03b1 \u2243o \u03b2 :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] (f : \u03b1 -> \u03b2) (h_mono : StrictMono.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 f) (h_surj : Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 f), Eq.{max (succ u1) (succ u2)} ((fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))))) (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2))) => \u03b1 -> \u03b2) (StrictMono.orderIsoOfSurjective.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f h_mono h_surj)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (OrderIso.{u1, u2} \u03b1 \u03b2 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) (Preorder.toLE.{u2} \u03b2 _inst_2)) (fun (_x : RelIso.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))))) (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2))) => \u03b1 -> \u03b2) (RelIso.hasCoeToFun.{u1, u2} \u03b1 \u03b2 (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))))) (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2))) (StrictMono.orderIsoOfSurjective.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f h_mono h_surj)) f\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] (f : \u03b1 -> \u03b2) (h_mono : StrictMono.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_2 f) (h_surj : Function.Surjective.{succ u2, succ u1} \u03b1 \u03b2 f), Eq.{max (succ u2) (succ u1)} (forall (a : \u03b1), (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 (fun (_x : \u03b1) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b1) => \u03b2) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b1 \u03b2) \u03b1 \u03b2 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b1 \u03b2)) (RelEmbedding.toEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b1 \u03b2 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (StrictMono.orderIsoOfSurjective.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem coe_orderIsoOfSurjective : (orderIsoOfSurjective f h_mono h_surj : \u03b1 \u2192 \u03b2) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] (f : \u03b1 -> \u03b2) (h_mono : StrictMono.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 f) (h_surj : Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 f) (a : \u03b1), Eq.{succ u1} \u03b1 (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} \u03b2 \u03b1 (Preorder.toLE.{u2} \u03b2 _inst_2) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))))) (fun (_x : RelIso.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (RelIso.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))))) (OrderIso.symm.{u1, u2} \u03b1 \u03b2 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) (Preorder.toLE.{u2} \u03b2 _inst_2) (StrictMono.orderIsoOfSurjective.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f h_mono h_surj)) (f a)) a\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] [_inst_2 : Preorder.{u1} \u03b2] (f : \u03b1 -> \u03b2) (h_mono : StrictMono.{u2, u1} \u03b1 \u03b2 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) _inst_2 f) (h_surj : Function.Surjective.{succ u2, succ u1} \u03b1 \u03b2 f) (a : \u03b1), Eq.{succ u2} ((fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b2) => \u03b1) (f a)) (FunLike.coe.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b2) => \u03b1) _x) (EmbeddingLike.toFunLike.{max (succ u1) (succ u2), succ u1, succ u2} (Function.Embedding.{succ u1, succ u2} \u03b2 \u03b1) \u03b2 \u03b1 (Function.instEmbeddingLikeEmbedding.{succ u1, succ u2} \u03b2 \u03b1)) (RelEmbedding.toEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u1, u2} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u1} \u03b2 (Preorder.toLE.{u1} \u03b2 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u2, u1} \u03b1 \u03b2 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) (Preorder.toLE.{u1} \u03b2 _inst_2) (StrictMono.orderIsoOfSurjective.{u2, u1} \u03b1 \u03b2 _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\u2093'. -/\n@[simp]\ntheorem orderIsoOfSurjective_symm_apply_self (a : \u03b1) :\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] (f : \u03b1 -> \u03b2) (h_mono : StrictMono.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) _inst_2 f) (h_surj : Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 f) (b : \u03b2), Eq.{succ u2} \u03b2 (f (coeFn.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (OrderIso.{u2, u1} \u03b2 \u03b1 (Preorder.toLE.{u2} \u03b2 _inst_2) (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))))) (fun (_x : RelIso.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))))) => \u03b2 -> \u03b1) (RelIso.hasCoeToFun.{u2, u1} \u03b2 \u03b1 (LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))))) (OrderIso.symm.{u1, u2} \u03b1 \u03b2 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) (Preorder.toLE.{u2} \u03b2 _inst_2) (StrictMono.orderIsoOfSurjective.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f h_mono h_surj)) b)) b\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : Preorder.{u2} \u03b2] (f : \u03b1 -> \u03b2) (h_mono : StrictMono.{u1, u2} \u03b1 \u03b2 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1))))) _inst_2 f) (h_surj : Function.Surjective.{succ u1, succ u2} \u03b1 \u03b2 f) (b : \u03b2), Eq.{succ u2} \u03b2 (f (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b2 \u03b1) \u03b2 (fun (_x : \u03b2) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : \u03b2) => \u03b1) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} \u03b2 \u03b1) \u03b2 \u03b1 (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} \u03b2 \u03b1)) (RelEmbedding.toEmbedding.{u2, u1} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{u2, u1} \u03b2 \u03b1 (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : \u03b2) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : \u03b2) => LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 _inst_2) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : \u03b1) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : \u03b1) => LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1)))))) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (OrderIso.symm.{u1, u2} \u03b1 \u03b2 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 _inst_1)))))) (Preorder.toLE.{u2} \u03b2 _inst_2) (StrictMono.orderIsoOfSurjective.{u1, u2} \u03b1 \u03b2 _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\u2093'. -/\ntheorem orderIsoOfSurjective_self_symm_apply (b : \u03b2) :\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 (\u03b1) [BooleanAlgebra \u03b1]\n\n#print OrderIso.compl /-\n/-- Taking complements as an order isomorphism to the order dual. -/\n@[simps]\ndef OrderIso.compl : \u03b1 \u2243o \u03b1\u1d52\u1d48 where\n  toFun := OrderDual.toDual \u2218 compl\n  invFun := compl \u2218 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 : \u03b1 \u2192 \u03b1) :=\n  (OrderIso.compl \u03b1).StrictMono\n#align compl_strict_anti compl_strictAnti\n-/\n\n#print compl_antitone /-\ntheorem compl_antitone : Antitone (compl : \u03b1 \u2192 \u03b1) :=\n  (OrderIso.compl \u03b1).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 \u27f6 Y` admits a descent to a chain map\n  `J.cocomplex \u27f6 I.cocomplex`. It is a descent in the sense that `I.\u03b9` 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 \u2964 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 \u27f6 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 \u27f6 Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.cocomplex.X 0 \u27f6 I.cocomplex.X 0 :=\nfactor_thru (f \u226b I.\u03b9.f 0) (J.\u03b9.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 \u27f6 Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.cocomplex.X 1 \u27f6 I.cocomplex.X 1 :=\nexact.desc (desc_f_zero f I J \u226b I.cocomplex.d 0 1) (J.\u03b9.f 0) (J.cocomplex.d 0 1)\n  (abelian.exact.op _ _ J.exact\u2080) (by simp [\u2190category.assoc, desc_f_zero])\n\n@[simp] lemma desc_f_one_zero_comm {Y Z : C}\n  (f : Z \u27f6 Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.cocomplex.d 0 1 \u226b desc_f_one f I J = desc_f_zero f I J \u226b 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 : \u2115) (g : J.cocomplex.X n \u27f6 I.cocomplex.X n) (g' : J.cocomplex.X (n+1) \u27f6 I.cocomplex.X (n+1))\n  (w : J.cocomplex.d n (n+1) \u226b g' = g \u226b I.cocomplex.d n (n+1)) :\n  \u03a3' g'' : J.cocomplex.X (n+2) \u27f6 I.cocomplex.X (n+2),\n    J.cocomplex.d (n+1) (n+2) \u226b g'' = g' \u226b I.cocomplex.d (n+1) (n+2) :=\n\u27e8@exact.desc C _ _ _ _ _ _ _ _ _\n  (g' \u226b 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 [\u2190category.assoc, w]), (by simp)\u27e9\n\n/-- A morphism in `C` descends to a chain map between injective resolutions. -/\ndef desc {Y Z : C}\n  (f : Z \u27f6 Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.cocomplex \u27f6 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  (\u03bb n \u27e8g, g', w\u27e9, \u27e8(desc_f_succ I J n g g' w.symm).1, (desc_f_succ I J n g g' w.symm).2.symm\u27e9)\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 \u27f6 Y) (I : InjectiveResolution Y) (J : InjectiveResolution Z) :\n  J.\u03b9 \u226b desc f I J = (cochain_complex.single\u2080 C).map f \u226b I.\u03b9 :=\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 \u27f6 J.cocomplex)\n  (comm : I.\u03b9 \u226b f = 0) : I.cocomplex.X 1 \u27f6 J.cocomplex.X 0 :=\nexact.desc (f.f 0) (I.\u03b9.f 0) (I.cocomplex.d 0 1) (abelian.exact.op _ _ I.exact\u2080)\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 \u27f6 J.cocomplex)\n  (comm : I.\u03b9 \u226b f = (0 : _ \u27f6 J.cocomplex)) : I.cocomplex.X 2 \u27f6 J.cocomplex.X 1 :=\nexact.desc (f.f 1 - desc_homotopy_zero_zero f comm \u226b 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, \u2190category.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 \u27f6 J.cocomplex) (n : \u2115)\n  (g : I.cocomplex.X (n + 1) \u27f6 J.cocomplex.X n)\n  (g' : I.cocomplex.X (n + 2) \u27f6 J.cocomplex.X (n + 1))\n  (w : f.f (n + 1) = I.cocomplex.d (n+1) (n+2) \u226b g' + g \u226b J.cocomplex.d n (n+1)) :\n  I.cocomplex.X (n + 3) \u27f6 J.cocomplex.X (n + 2) :=\nexact.desc (f.f (n+2) - g' \u226b 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, \u2190category.assoc, preadditive.sub_comp,\n        show I.cocomplex.d (n+1) (n+2) \u226b g' = f.f (n + 1) - g \u226b 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 \u27f6 J.cocomplex)\n  (comm : I.\u03b9 \u226b 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  (\u03bb n \u27e8g, g', w\u27e9, \u27e8desc_homotopy_zero_succ f n g g' (by simp only [w, add_comm]),\n    by simp [desc_homotopy_zero_succ, w]\u27e9)\n\n/-- Two descents of the same morphism are homotopic. -/\ndef desc_homotopy {Y Z : C} (f : Y \u27f6 Z) {I : InjectiveResolution Y} {J : InjectiveResolution Z}\n  (g h : I.cocomplex \u27f6 J.cocomplex)\n  (g_comm : I.\u03b9 \u226b g = (cochain_complex.single\u2080 C).map f \u226b J.\u03b9)\n  (h_comm : I.\u03b9 \u226b h = (cochain_complex.single\u2080 C).map f \u226b J.\u03b9) :\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 (\ud835\udfd9 X) I I) (\ud835\udfd9 I.cocomplex) :=\nby apply desc_homotopy (\ud835\udfd9 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 \u27f6 Y) (g : Y \u27f6 Z)\n  (I : InjectiveResolution X) (J : InjectiveResolution Y) (K : InjectiveResolution Z) :\n  homotopy (desc (f \u226b g) K I) (desc f J I \u226b desc g K J)  :=\nby apply desc_homotopy (f \u226b 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 (\ud835\udfd9 X) J I,\n  inv := desc (\ud835\udfd9 X) I J,\n  homotopy_hom_inv_id := (desc_comp_homotopy (\ud835\udfd9 X) (\ud835\udfd9 X) I J I).symm.trans $\n    by simpa [category.id_comp] using desc_id_homotopy _ _,\n  homotopy_inv_hom_id := (desc_comp_homotopy (\ud835\udfd9 X) (\ud835\udfd9 X) J I J).symm.trans $\n    by simpa [category.id_comp] using desc_id_homotopy _ _ }\n\n@[simp, reassoc] lemma homotopy_equiv_hom_\u03b9 {X : C} (I J : InjectiveResolution X) :\n  I.\u03b9 \u226b (homotopy_equiv I J).hom = J.\u03b9 :=\nby simp [homotopy_equiv]\n\n@[simp, reassoc] lemma homotopy_equiv_inv_\u03b9 {X : C} (I J : InjectiveResolution X) :\n  J.\u03b9 \u226b (homotopy_equiv I J).inv = I.\u03b9 :=\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 \u2115 :=\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.\u03b9 (Z : C) [has_injective_resolution Z] :\n  (cochain_complex.single\u2080 C).obj Z \u27f6 injective_resolution Z :=\n(has_injective_resolution.out Z).some.\u03b9\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 \u27f6 Y)\n  [has_injective_resolution X] [has_injective_resolution Y] :\n  injective_resolution X \u27f6 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(`\u2115`-indexed cochain complexes and chain maps up to homotopy).\n-/\ndef injective_resolutions : C \u2964 homotopy_category C (complex_shape.up \u2115) :=\n{ obj := \u03bb X, (homotopy_category.quotient _ _).obj (injective_resolution X),\n  map := \u03bb X Y f, (homotopy_category.quotient _ _).map (injective_resolution.desc f),\n  map_id' := \u03bb X, begin\n    rw \u2190(homotopy_category.quotient _ _).map_id,\n    apply homotopy_category.eq_of_homotopy,\n    apply InjectiveResolution.desc_id_homotopy,\n  end,\n  map_comp' := \u03bb X Y Z f g, begin\n    rw \u2190(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 \u27f6 Y) : exact f (d f) :=\n(abelian.exact_iff _ _).2 $\n  \u27e8by simp, zero_of_comp_mono (\u03b9 _) $ by rw [category.assoc, kernel.condition]\u27e9\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 \u2115 :=\ncochain_complex.mk'\n  (injective.under Z) (injective.syzygies (injective.\u03b9 Z)) (injective.d (injective.\u03b9 Z))\n  (\u03bb \u27e8X, Y, f\u27e9, \u27e8injective.syzygies f, injective.d f, (exact_f_d f).w\u27e9)\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  \u03b9 := cochain_complex.mk_hom _ _ (injective.\u03b9 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.\u03b9 Z)).w, } ) (\u03bb n _, \u27e80, by ext\u27e9),\n  injective := by { rintros (_|_|_|n); { apply injective.injective_under, } },\n  exact\u2080 := by simpa using exact_f_d (injective.\u03b9 Z),\n  exact := by { rintros (_|n); { simp, apply exact_f_d } },\n  mono := injective.\u03b9_mono Z }\n\n@[priority 100]\ninstance (Z : C) : has_injective_resolution Z :=\n{ out := \u27e8of Z\u27e9 }\n\n@[priority 100]\ninstance : has_injective_resolutions C :=\n{ out := \u03bb _, 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\u27e8\u03bb M N [monoid M] [monoid N], by exactI @monoid_hom.to_fun M N _ _,\n \u03bb M [monoid M], by exactI @monoid_hom.id M _,\n \u03bb M N P [monoid M] [monoid N] [monoid P], by exactI @monoid_hom.comp M N P _ _ _,\n \u03bb M N [monoid M] [monoid N], by exactI @monoid_hom.coe_inj M N _ _\u27e9\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 \u2192* Y) :\n  of X \u27f6 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 \u2192* 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\u27e8@of punit $ @group.to_monoid _ $ @comm_group.to_group _ punit.comm_group\u27e9\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 := \u27e8\u27e9\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\u27e8@of punit $ @comm_group.to_comm_monoid _ punit.comm_group\u27e9\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\u2082 CommMon Mon := bundled_hom.forget\u2082 _ _\n\n@[to_additive] instance : has_coe CommMon.{u} Mon.{u} :=\n{ coe := (forget\u2082 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 \u27f6 S) : (R : Type) \u2192 (S : Type) := f\nexample {R S : CommMon} (f : R \u27f6 S) : (R : Type) \u2192 (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 `\u21a5R`,\n-- rather than `R.\u03b1` or (as we used to have) `\u21a5(bundled.map comm_monoid.to_monoid R)`.\nexample (R : CommMon.{u}) : R \u27f6 R :=\n{ to_fun := \u03bb 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' := \u03bb x y,\n  begin rw [mul_assoc x y (x * y), \u2190mul_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 \u2243* Y) : Mon.of X \u2245 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 \u2243* Y) : CommMon.of X \u2245 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 \u2245 Y) : X \u2243* 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 \u2245 Y) : X \u2243* 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 \u2243* Y) \u2245 (Mon.of X \u2245 Mon.of Y) :=\n{ hom := \u03bb e, e.to_Mon_iso,\n  inv := \u03bb 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 \u2243* Y) \u2245 (CommMon.of X \u2245 CommMon.of Y) :=\n{ hom := \u03bb e, e.to_CommMon_iso,\n  inv := \u03bb i, i.CommMon_iso_to_mul_equiv, }\n\n@[to_additive]\ninstance Mon.forget_reflects_isos : reflects_isomorphisms (forget Mon.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Mon).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Mon_iso).1\u27e9,\n  end }\n\n@[to_additive]\ninstance CommMon.forget_reflects_isos : reflects_isomorphisms (forget CommMon.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommMon).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommMon_iso).1\u27e9,\n  end }\n\n/-!\nOnce we've shown that the forgetful functors to type reflect isomorphisms,\nwe automatically obtain that the `forget\u2082` functors between our concrete categories\nreflect isomorphisms.\n-/\nexample : reflects_isomorphisms (forget\u2082 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 : \u211d)- (z : \u211d)+ : expCone x 1 z :=\noptimality by\n  intros x' z' hx hz hexp\n  rw [\u2190exp_iff_expCone] at *\n  exact ((exp_le_exp.2 hx).trans\u2093 hexp).trans\u2093 hz\n\ndeclare_atom Vec.expCone [cone] (n : Nat)& (x : (Fin\u2093 n) \u2192 \u211d)- (z : (Fin\u2093 n) \u2192 \u211d)+ : 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\u2093 ((exp_iff_expCone _ _).2 (hexp i))).trans\u2093 (hz i)\n\ndeclare_atom posOrthCone [cone] (n : Nat)& (x : \u211d)+ : posOrthCone x :=\noptimality by\n  intros x' hx hx0\n  exact hx0.trans\u2093 hx\n\ndeclare_atom Vec.posOrthCone [cone] (n : Nat)& (x : (Fin\u2093 n) \u2192 \u211d)+ : Vec.posOrthCone x :=\noptimality by\n  intros x' hx hx0 i\n  exact (hx0 i).trans\u2093 (hx i)\n\ndeclare_atom Matrix.posOrthCone [cone] (m : Nat)& (n : Nat)& (M : Matrix.{0,0,0} (Fin\u2093 m) (Fin\u2093 n) \u211d)+ :\n  Real.Matrix.posOrthCone M :=\noptimality by\n  intros x' hx hx0 i j\n  exact (hx0 i j).trans\u2093 (hx i j)\n\ndeclare_atom rotatedSoCone [cone] (n : Nat)& (v : \u211d)+ (w : \u211d)+ (x : (Fin\u2093 n) \u2192 \u211d)? :\n  rotatedSoCone v w x :=\noptimality by\n  intros v' w' hv hw h\n  unfold rotatedSoCone at *\n  apply And.intro\n  \u00b7 apply h.1.trans\u2093\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\u2093 hw)\n    have : @Zero.zero Real (MulZeroClass\u2093.toHasZero Real) = 0 := by\n      rfl\n    rw [this]\n    simp only [(@Nat.cast_zero \u211d _).symm, (@Nat.cast_one \u211d _).symm]\n    apply Nat.cast_le.2\n    norm_num\n  \u00b7 exact \u27e8h.2.1.trans\u2093 hv, h.2.2.trans\u2093 hw\u27e9\n\ndeclare_atom Vec.rotatedSoCone [cone] (m : Nat)& (n : Nat)& (v : (Fin\u2093 n) \u2192 \u211d)+ (w : (Fin\u2093 n) \u2192 \u211d)+ (x : (Fin\u2093 n) \u2192 (Fin\u2093 m) \u2192 \u211d)? :\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 \u211d)? : \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\u2082_mk Quot.lift\u2082_mk\n\n-- Affine operations.\nsection RealAffine\n\nopen Real\n\ndeclare_atom add [affine] (x : \u211d)+ (y : \u211d)+ : x + y :=\nbconditions\nhomogenity by\n  change _ = _ + _ + HasSmul.smul \u03ba (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\u2093]\n  rw [add_comm\u2093 x' y', \u2190add_assoc\u2093 y y' x', add_comm\u2093 _ x']\noptimality fun _ _ => add_le_add\n\ndeclare_atom neg [affine] (x : \u211d)- : - x :=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (-x) + -Zero.zero = \n    -HasSmul.smul \u03ba x + HasSmul.smul \u03ba (-Zero.zero)\n  simp\n  rw [smul_zero, smul_neg, add_zero\u2093]\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 : \u211d)- : maximizeNeg x :=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (-x) + -Zero.zero = \n    -HasSmul.smul \u03ba x + HasSmul.smul \u03ba (-Zero.zero)\n  simp\n  rw [smul_zero, smul_neg, add_zero\u2093]\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 : \u211d)+ (y : \u211d)- : x - y :=\nbconditions\nhomogenity by\n  rw [smul_sub, sub_self, smul_zero]\n  rfl\nadditivity by\n  rw [sub_add_comm, add_comm\u2093, add_sub, add_sub_assoc, sub_sub, add_comm\u2093 y' y, \n    add_sub, sub_self, add_zero\u2093]\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 : \u211d)& (y : \u211d)+ : x * y :=\nbconditions (hx : 0 \u2264 x)\nhomogenity by\n  change HasSmul.smul \u03ba (x * y) + x * Zero.zero\n    = x * HasSmul.smul \u03ba y + HasSmul.smul \u03ba (x * Zero.zero)\n  rw [_root_.mul_zero, smul_zero, add_zero\u2093, add_zero\u2093, mul_smul_comm]\nadditivity by\n  change x * y + x * y' = x * (y + y') + x * Zero.zero\n  rw [mul_add\u2093, _root_.mul_zero, add_zero\u2093]\noptimality by\n  intros y' hy\n  apply ZeroLt.mul_le_mul_of_nonneg_left hy hx\n\ndeclare_atom mul2 [affine] (x : \u211d)+ (y : \u211d)& : x * y :=\nbconditions (hy : 0 \u2264 y)\nhomogenity by\n  change HasSmul.smul \u03ba (x * y) + Zero.zero * y \n    = (HasSmul.smul \u03ba x) * y + HasSmul.smul \u03ba (Zero.zero * y)\n  rw [_root_.zero_mul, smul_zero, add_zero\u2093, add_zero\u2093,\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\u2093, _root_.zero_mul, add_zero\u2093]\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\u2093 m \u2192 \u211d)? (i : Fin\u2093 m)& : x i :=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (x i) + Zero.zero\n    = HasSmul.smul \u03ba x i + HasSmul.smul \u03ba Zero.zero\n  rw [smul_zero, add_zero\u2093, add_zero\u2093]\n  rfl\nadditivity by\n  change x i + x' i = x i + x' i + Zero.zero\n  rw [add_zero\u2093]\noptimality le_refl\u2093 _\n\ndeclare_atom Vec.add [affine] (m : Nat)&  (x : Fin\u2093 m \u2192 \u211d)+ (y : Fin\u2093 m \u2192 \u211d)+ : x + y :=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (x + y) + (Zero.zero + Zero.zero) \n    = HasSmul.smul \u03ba x + HasSmul.smul \u03ba y + HasSmul.smul \u03ba (Zero.zero + Zero.zero)\n  rw [add_zero\u2093, add_zero\u2093, smul_zero, add_zero\u2093, smul_add]\n  rfl\nadditivity by\n  change x + y + (x' + y') = x + x' + (y + y') + (Zero.zero + Zero.zero)\n  rw [add_zero\u2093, add_zero\u2093, add_assoc\u2093, add_comm\u2093 x' y', \u2190add_assoc\u2093 y, add_comm\u2093 _ x']\n  simp [add_assoc\u2093]\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\u2093 m \u2192 \u211d)+ (y : Fin\u2093 m \u2192 \u211d)- : 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\u2093]\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\u2093 m \u2192 \u211d)+ : Vec.sum x :=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (Vec.sum x) + (\u2211 i, Zero.zero)\n    = Vec.sum (HasSmul.smul \u03ba x) + HasSmul.smul \u03ba (\u2211 i, Zero.zero)\n  unfold Vec.sum\n  rw [Finset.smul_sum, Finset.sum_const_zero, add_zero\u2093, smul_zero, add_zero\u2093]\n  rfl\nadditivity by\n  change (\u2211 i, x i) + (\u2211 i, x' i) = (\u2211 i, x i + x' i) + \u2211 i, Zero.zero\n  rw [Finset.sum_const_zero, add_zero\u2093, 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 : \u211d)+ (y : \u211d)& : x / y :=\nbconditions (hy : (0 : \u211d) \u2264 y)\nhomogenity by\n  change \u03ba * (x / y) + Zero.zero / y \n    = \u03ba * x / y + \u03ba * (Zero.zero / y)\n  rw [zero_div, add_zero\u2093, _root_.mul_zero, add_zero\u2093, mul_div]\nadditivity by\n  change x / y + x' / y = (x + x') / y + Zero.zero / y\n  rw [zero_div, add_zero\u2093, add_div]\noptimality by\n  intros x' hx\n  by_cases h : Zero.zero = y\n  \u00b7 rw [\u2190h, div_zero, div_zero]\n    exact le_refl\u2093 _\n  \u00b7 rw [div_le_div_right]\n    apply hx\n    apply lt_of_le_of_ne\u2093 hy h\n\ndeclare_atom Vec.dotProduct1 [affine] (m : Nat)& (x : Fin\u2093 m \u2192 \u211d)& (y : Fin\u2093 m \u2192 \u211d)? : Matrix.dotProduct x y := \nbconditions\nhomogenity by\n  change \u03ba * (Matrix.dotProduct x y) + Matrix.dotProduct x Zero.zero =\n    Matrix.dotProduct x (HasSmul.smul \u03ba y) + \u03ba * (Matrix.dotProduct x Zero.zero)\n  rw [Matrix.dot_product_zero, add_zero\u2093, _root_.mul_zero, add_zero\u2093,\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\u2093, Matrix.dot_product_add]\noptimality le_refl\u2093 _\n\ndeclare_atom Vec.dotProduct2 [affine] (m : Nat)& (x : Fin\u2093 m \u2192 \u211d)? (y : Fin\u2093 m \u2192 \u211d)& : Matrix.dotProduct x y := \nbconditions\nhomogenity by\n  change \u03ba * (Matrix.dotProduct x y) + Matrix.dotProduct Zero.zero y =\n    Matrix.dotProduct (HasSmul.smul \u03ba x) y + \u03ba * (Matrix.dotProduct Zero.zero y)\n  rw [Matrix.zero_dot_product, add_zero\u2093, _root_.mul_zero, add_zero\u2093,\n    Matrix.dot_product_comm (HasSmul.smul \u03ba 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\u2093 m \u2192 Real) y + Matrix.dotProduct Zero.zero y\n  rw [Matrix.zero_dot_product, add_zero\u2093, Matrix.add_dot_product]\noptimality le_refl\u2093 _\n\ndeclare_atom smul [affine] (n : \u2115)& (y : \u211d)+ : @HasSmul.smul \u2115 Real AddMonoid\u2093.hasSmulNat n y :=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (HasSmul.smul n y) + HasSmul.smul n Zero.zero =\n    HasSmul.smul n (HasSmul.smul \u03ba y) + HasSmul.smul \u03ba (HasSmul.smul n Zero.zero)\n  rw [smul_zero, add_zero\u2093, smul_zero, smul_zero, add_zero\u2093, 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\u2093, smul_add]\n  rfl\noptimality by\n  intros y' hy\n  apply smul_le_smul_of_nonneg hy (Nat.zero_le\u2093 _)\n\nend VecAffine\n\n-- Affine operations on matrices.\nsection MatrixAffine \n\ndeclare_atom Matrix.vec_cons [affine] (n : Nat)& (x : \u211d)+ (y : (Fin\u2093 n) \u2192 \u211d)+ : \n  Matrix.vecCons x y :=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (Matrix.vecCons x y) + Matrix.vecCons (Zero.zero : \u211d) (Zero.zero : (Fin\u2093 n) \u2192 \u211d) =\n    Matrix.vecCons (\u03ba * x) (HasSmul.smul \u03ba y) + HasSmul.smul \u03ba (Matrix.vecCons (Zero.zero : \u211d) (Zero.zero : (Fin\u2093 n) \u2192 \u211d))\n  ext \u27e8i, hi\u27e9\n  cases i\n  \u00b7 simp [HasSmul.smul, Matrix.Computable.Pi.hasSmul', Matrix.Computable.Mul.toHasSmul']\n  \u00b7 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' : \u211d) (y + y' : (Fin\u2093 n) \u2192 \u211d)\n      + Matrix.vecCons (Zero.zero : \u211d) (Zero.zero : (Fin\u2093 n) \u2192 \u211d)\n  ext \u27e8i, hi\u27e9\n  cases i\n  \u00b7 simp\n  \u00b7 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 \u27e8i, Nat.succ_lt_succ_iff.1 hi\u27e9]\n\ndeclare_atom Matrix.sum [affine] (m : Nat)& (X : Matrix.{0,0,0} (Fin\u2093 m) (Fin\u2093 m) \u211d)+ : Matrix.sum X :=\nbconditions\nhomogenity by\n  change \u03ba * (\u2211 i, \u2211 j, X i j) + (\u2211 i, \u2211 j, Zero.zero)\n    = (\u2211 i, \u2211 j, \u03ba * X i j) + \u03ba * (\u2211 i, \u2211 j, Zero.zero)\n  rw [Finset.sum_const_zero, Finset.sum_const_zero, _root_.mul_zero, add_zero\u2093, add_zero\u2093]\n  simp only [Finset.mul_sum]\nadditivity by\n  change (\u2211 i, \u2211 j, X i j) + (\u2211 i, \u2211 j, X' i j) \n    = (\u2211 i, \u2211 j, X i j + X' i j) + \u2211 i, \u2211 j, Zero.zero\n  rw [Finset.sum_const_zero, Finset.sum_const_zero, add_zero\u2093]\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\u2093 m) (Fin\u2093 m) \u211d)? (i : Fin\u2093 m)& : X i :=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (X i) + Zero.zero = HasSmul.smul \u03ba X i + HasSmul.smul \u03ba Zero.zero\n  rw [add_zero\u2093, smul_zero, add_zero\u2093]\n  rfl\nadditivity by\n  change X i + X' i = HAdd.hAdd X X' i + Zero.zero\n  rw [add_zero\u2093]\n  rfl\noptimality le_refl\u2093 _\n\ndeclare_atom Matrix.nth2 [affine] (m : Nat)& (X : Matrix.{0,0,0} (Fin\u2093 m) (Fin\u2093 m) \u211d)? (i : Fin\u2093 m)& (j : Fin\u2093 m)& : X i j :=\nbconditions\nhomogenity by\n  change _ + Zero.zero = _ + HasSmul.smul \u03ba Zero.zero\n  rw [smul_zero]\n  rfl\nadditivity by\n  change _ = _ + Zero.zero\n  rw [add_zero\u2093]\n  rfl\noptimality le_refl\u2093 _\n  \n-- TODO: make argument increasing, without breaking det-log-atom\ndeclare_atom Matrix.diag [affine] (n : \u2115)& (A : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)? : A.diag :=\nbconditions\nhomogenity by\n  change _ + Zero.zero\n    = _ + HasSmul.smul \u03ba Zero.zero\n  rw [add_zero\u2093, smul_zero, add_zero\u2093]\n  rfl\nadditivity by\n  change _  = _ + Zero.zero\n  rw [add_zero\u2093]\n  rfl\noptimality le_refl\u2093 _\n\ndeclare_atom Matrix.diagonal [affine] (n : \u2115)& (d : Fin\u2093 n \u2192 \u211d)+ : Matrix.diagonal d :=\nbconditions\nhomogenity by\n  ext i j\n  change\n    \u03ba * (Matrix.diagonal\u2093 d) i j + (Matrix.diagonal fun i => Zero.zero) i j =\n    Matrix.diagonal\u2093 (HasSmul.smul \u03ba d) i j + HasSmul.smul \u03ba (Matrix.diagonal Zero.zero) i j\n  by_cases h : i = j\n  \u00b7 simp [Matrix.diagonal, h]\n    change \u03ba * d j = HasSmul.smul \u03ba d j + \u03ba * Zero.zero\n    rw [_root_.mul_zero, add_zero\u2093]\n    rfl\n  \u00b7 simp [Matrix.diagonal, h]\n    change Zero.zero = \u03ba * Zero.zero\n    rw [_root_.mul_zero]\nadditivity by\n  change Matrix.diagonal\u2093 _ + Matrix.diagonal\u2093 _\n    = _ + Matrix.diagonal\u2093 fun i => Zero.zero\n  rw [Matrix.diagonal_add, Matrix.diagonal_zero, add_zero\u2093]\n  rfl\noptimality by\n  intros d' hd i j\n  by_cases h : i = j\n  \u00b7 simp [Matrix.diagonal, h, hd j]\n  \u00b7 simp [Matrix.diagonal, h, hd j]\n\ndeclare_atom Matrix.diagonal\u2093 [affine] (n : \u2115)& (d : Fin\u2093 n \u2192 \u211d)+ : Matrix.diagonal\u2093 d :=\nbconditions\nhomogenity by\n  ext i j\n  change\n    \u03ba * (Matrix.diagonal\u2093 d) i j + (Matrix.diagonal fun i => Zero.zero) i j =\n    Matrix.diagonal\u2093 (HasSmul.smul \u03ba d) i j + HasSmul.smul \u03ba (Matrix.diagonal Zero.zero) i j\n  by_cases h : i = j\n  \u00b7 simp [Matrix.diagonal, h]\n    change \u03ba * d j = HasSmul.smul \u03ba d j + \u03ba * Zero.zero\n    rw [_root_.mul_zero, add_zero\u2093]\n    rfl\n  \u00b7 simp [Matrix.diagonal, h]\n    change Zero.zero = \u03ba * Zero.zero\n    rw [_root_.mul_zero]\nadditivity by\n  change _ = _ + Matrix.diagonal\u2093 fun i => Zero.zero\n  rw [Matrix.diagonal_add, Matrix.diagonal_zero, add_zero\u2093]\n  rfl\noptimality by\n  intros d' hd i j\n  by_cases h : i = j\n  \u00b7 simp [Matrix.diagonal, h, hd j]\n  \u00b7 simp [Matrix.diagonal, h, hd j]\n\n-- NOTE: Helper lemma needed due to mathport\nlemma zero_eq_zero [Zero \u03b1] : (0 : \u03b1) = Zero.zero := rfl\n\ndeclare_atom Matrix.trace [affine] (m : Type)& (hm : Fintype.{0} m)& (A : Matrix.{0,0,0} m m \u211d)+ : Matrix.trace A:=\nbconditions\nhomogenity by\n  change HasSmul.smul \u03ba (Matrix.trace A) + Matrix.trace Zero.zero\n    = Matrix.trace (HasSmul.smul \u03ba A) + HasSmul.smul \u03ba (Matrix.trace Zero.zero)\n  rw [\u2190 Matrix.trace_smul, \u2190 Matrix.trace_smul, smul_zero]\n  rfl\nadditivity by\n  rw [zero_eq_zero, Matrix.trace_add, Matrix.trace_zero, add_zero\u2093]\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 : \u2115)& (A : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)+ : \n  A.toUpperTri :=\nbconditions\nhomogenity by\n  ext i j\n  change \u03ba * (Matrix.toUpperTri A) i j + (Matrix.toUpperTri 0) i j =\n    (Matrix.toUpperTri (HasSmul.smul \u03ba A)) i j + \u03ba * (Matrix.toUpperTri Zero.zero) i j\n  by_cases h : i \u2264 j\n  \u00b7 unfold Matrix.toUpperTri\n    simp [h]\n    change \u03ba * A i j + 0 = HasSmul.smul \u03ba A i j + \u03ba * Zero.zero\n    rw [_root_.mul_zero]\n    rfl\n  \u00b7 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 \u2264 j\n  \u00b7 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\u2093]\n    rfl\n  \u00b7 unfold Matrix.toUpperTri\n    simp [h]\noptimality by\n  intros A' hA\n  ext i j\n  by_cases h : i \u2264 j\n  \u00b7 unfold Matrix.toUpperTri\n    simp [h, hA i j]\n  \u00b7 unfold Matrix.toUpperTri\n    simp [h]\n\ndeclare_atom Matrix.transpose [affine] (n : \u2115)& (A : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)+ : \n  A.transpose :=\nbconditions\nhomogenity by\n  change _ = _ + HasSmul.smul _ (Matrix.transpose\u2093 Zero.zero)\n  simp [zero_eq_zero, Matrix.transpose_zero]\n  rw [smul_zero]\n  rfl\nadditivity by\n  change Matrix.transpose\u2093 _ + Matrix.transpose\u2093 _\n    = Matrix.transpose\u2093 _ + Matrix.transpose\u2093 _\n  simp\n  rfl\noptimality by\n  intros _ hA\n  ext i j\n  exact hA j i\n\ndeclare_atom Matrix.transpose\u2093 [affine] (n : \u2115)& (A : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)+ : \n  A.transpose\u2093 :=\nbconditions\nhomogenity by\n  simp [zero_eq_zero, Matrix.transpose_zero]\n  rw [smul_zero, add_zero\u2093]\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 \u03b1]: \n  Matrix.fromBlocks (0 : Matrix n l \u03b1) (0 : Matrix n m \u03b1) (0 : Matrix o l \u03b1) (0 : Matrix o m \u03b1) = 0 := by\n  ext i j\n  cases i\n  \u00b7 cases j\n    rfl\n    rfl\n  \u00b7 cases j\n    rfl\n    rfl\n\ndeclare_atom Matrix.fromBlocks [affine] (n : \u2115)& \n  (A : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)+ (B : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)+\n  (C : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)+ (D : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)+ :\n  Matrix.fromBlocks A B C D :=\nbconditions\nhomogenity by\n  change _ = _ + HasSmul.smul \u03ba _\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 \u211d)+ (B : Matrix.{0,0,0} m n \u211d)+ : A + B :=\nbconditions\nhomogenity by\n  rw [zero_eq_zero, add_zero\u2093, add_zero\u2093, smul_zero, add_zero\u2093, smul_add]\n  rfl\nadditivity by\n  rw [zero_eq_zero, add_zero\u2093, add_zero\u2093, add_assoc\u2093, add_comm\u2093 B, add_assoc\u2093 A', add_comm\u2093 B']\n  simp only [add_assoc\u2093]\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 \u211d)+ (B : Matrix.{0,0,0} m n \u211d)- : A - B :=\nbconditions\nhomogenity by\n  ext i j\n  rw [sub_self]\n  change\n    \u03ba * (A - B) i j + Zero.zero =\n    \u03ba * A i j - \u03ba * B i j + \u03ba * Zero.zero\n  rw [_root_.mul_zero, add_zero\u2093, add_zero\u2093, \u2190mul_sub]\n  rfl\nadditivity by\n  rw [sub_self, add_zero\u2093, sub_add_sub_comm]\noptimality by\n  intros A' B' hA hB i j\n  change A i j - B i j \u2264 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 \u211d)& (B : Matrix.{0,0,0} m m \u211d)? : A \u2b1d 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\u2093]\noptimality le_refl\u2093 (A \u2b1d B)\n\ndeclare_atom Matrix.mul2 [affine] (m : Type)& (hm : Fintype.{0} m)&\n  (A : Matrix.{0,0,0} m m \u211d)? (B : Matrix.{0,0,0} m m \u211d)& : A \u2b1d 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\u2093]\noptimality le_refl\u2093 (A \u2b1d B)\n\ndeclare_atom Matrix.mulVec [affine] (n : \u2115)& (m : \u2115)& (M : Matrix.{0,0,0} (Fin\u2093 m) (Fin\u2093 n) \u211d)& (v : Fin\u2093 n \u2192 \u211d)? :\n  Matrix.mulVec\u2093 M v :=\nbconditions\nhomogenity by\n  simp [zero_eq_zero]\n  rw [smul_zero, add_zero\u2093, Matrix.mul_vec_smul]\n  rfl\nadditivity by\n  simp [zero_eq_zero, Matrix.mul_vec_add]\noptimality le_refl\u2093 _\n\ndeclare_atom Matrix.vecMul [affine] (n : \u2115)& (m : \u2115)& (v : Fin\u2093 m \u2192 \u211d)? (M : Matrix.{0,0,0} (Fin\u2093 m) (Fin\u2093 n) \u211d)& :\n  Matrix.vecMul\u2093 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\u2093, Matrix.vec_mul_smul]\n  rfl\nadditivity by\n  simp [zero_eq_zero, Matrix.add_vec_mul]\noptimality le_refl\u2093 _\n\n\nend MatrixAffine \n\n-- Non-affine atoms on real variables.\nsection Real\n\nopen Real\n\ndeclare_atom le [concave] (x : \u211d)- (y : \u211d)+ : x \u2264 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\u2093 h).trans\u2093 hy\nvconditionElimination\n\ndeclare_atom eq [concave] (x : \u211d)? (y : \u211d)? : 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 : \u211d)? : x ^ 2 := \nvconditions\nimplementationVars (t : \u211d)\nimplementationObjective (t)\nimplementationConstraints\n  (c1 : rotatedSoCone t (1/2) (![x] : Fin\u2093 1 \u2192 \u211d))\nsolution\n  (t := x ^ 2)\nsolutionEqualsAtom rfl\nfeasibility\n  (c1 : by \n    simp [rotatedSoCone]\n    refine \u27e8?_, ?_, ?_\u27e9\n    \u00b7 have : (2 : \u211d) \u2260 0 := by\n        apply ne_of_gt\u2093\n        simp only [(@Nat.cast_zero \u211d _).symm, (@Nat.cast_one \u211d _).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 \u211d \u2115 \u211d instHPow x 2 := \n        by apply Real.rpow_nat_cast\n      rw [this]\n      exact le_refl\u2093 _\n    \u00b7 have : x ^ 2 = @HPow.hPow \u211d \u2115 \u211d instHPow x 2 := \n        by apply Real.rpow_nat_cast\n      rw [this]\n      exact sq_nonneg x\n    \u00b7 rw [zero_eq_zero]\n      rw [\u2190 zero_div 2]\n      have : (0 : \u211d) < (2 : \u211d) := by\n        simp only [(@Nat.cast_zero \u211d _).symm, (@Nat.cast_one \u211d _).symm]\n        apply Nat.cast_lt.2\n        norm_num\n      have := (@div_le_div_right \u211d _ 0 1 2 this).2\n      refine this ?_\n      have : ZeroLeOneClass \u211d := @OrderedSemiring.zeroLeOneClass \u211d Real.orderedSemiring\n      exact zero_le_one)\noptimality by\n  have := c1.1\n  have two_ne_zero : (2 : \u211d) \u2260 0 := by\n    apply ne_of_gt\u2093\n    simp only [(@Nat.cast_zero \u211d _).symm, (@Nat.cast_one \u211d _).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 \u211d \u2115 \u211d 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 : \u211d)+ : Real.exp x :=\nvconditions\nimplementationVars (t : \u211d)\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 \u27e8Real.zero_lt_one, ?_\u27e9\n  change x / One.one \u2264 x\n  rw [div_one]\n  apply le_refl\u2093 _)\noptimality by\n  intros x' hx\n  rw [\u2190exp_iff_expCone] at c_exp\n  exact (exp_le_exp.2 hx).trans\u2093 c_exp\nvconditionElimination\n\ndeclare_atom sqrt [concave] (x : \u211d)+ : Real.sqrt x := \nvconditions (cond : 0 \u2264 x)\nimplementationVars (t : \u211d)\nimplementationObjective (t)\nimplementationConstraints \n  (c1 : rotatedSoCone x (1/2) (![t] : Fin\u2093 1 \u2192 \u211d))\nsolution (t := Real.sqrt x)\nsolutionEqualsAtom by\n  rfl;\nfeasibility \n  (c1 : by\n    unfold rotatedSoCone\n    rw [\u2190 sq_sqrt cond]\n    have : sqrt x ^ 2 = @HPow.hPow \u211d \u2115 \u211d 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 \u211d \u2115 \u211d instHPow t (bit0 One.one) := \n      by apply Real.rpow_nat_cast\n  rw [\u2190this]\n  apply sqopt.trans\u2093 hy\nvconditionElimination (cond : fun _ hx => c1.2.1.trans\u2093 hx)\n\ndeclare_atom log [concave] (x : \u211d)+ : log x :=\nvconditions (cond : 0 < x)\nimplementationVars (t : \u211d)\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\u2093 _)\noptimality by \n  intros x' hx;\n  simp [expCone] at c_exp\n  cases c_exp with \n  | inl h => \n    rcases h with \u27e8_, h\u27e9\n    cases em (0 < x) with \n    | inl h0x => \n      erw [le_log_iff_exp_le (lt_of_lt_of_le\u2093 h0x hx)]\n      erw [div_one] at h\n      exact le_trans\u2093 h hx\n    | inr h0x => \n      exfalso\n      cases (eq_or_lt_of_not_lt\u2093 h0x) with \n      | inl heq => \n        erw [div_one] at h\n        exact lt_irrefl\u2093 0 (lt_of_lt_of_le\u2093 (exp_pos t) (heq \u25b8 h))\n      | inr hlt =>\n        erw [div_one] at h\n        exact lt_irrefl\u2093 0 (lt_trans\u2093 (lt_of_lt_of_le\u2093 (exp_pos t) h) hlt)\n  | inr h => \n    rcases h with \u27e8_, hc, _\u27e9; \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    \u00b7 intro h\n      exact fun _ h' => lt_of_lt_of_le\u2093 (lt_of_lt_of_le\u2093 (Real.exp_pos _) h.2) h'\n    \u00b7 intro h\n      exact False.elim $ zero_ne_one h.2.1.symm)\n\ndeclare_atom abs [convex] (x : \u211d)? : abs x :=\nvconditions\nimplementationVars (t : \u211d)\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, \u2190 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 [\u2190sub_nonneg, sub_neg_eq_add, add_comm\u2093, \u2190sub_nonneg (b := x)]\n  exact \u27e8c_neg, c_pos\u27e9\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\u2093 n) \u2192 \u211d)- (y : (Fin\u2093 n) \u2192 \u211d)+ : x \u2264 y :=\nvconditions\nimplementationVars\nimplementationObjective Real.Vec.posOrthCone (y - x : (Fin\u2093 n) \u2192 \u211d)\nimplementationConstraints\nsolution\nsolutionEqualsAtom by\n  unfold Real.Vec.posOrthCone\n  rw [\u2190 iff_iff_eq]\n  constructor\n  \u00b7 intros h i\n    rw [\u2190le.solEqAtom]\n    apply h\n  \u00b7 intros h i\n    change Zero.zero \u2264 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\u2093 n) \u2192 \u211d)+ : exp x :=\nvconditions\nimplementationVars (t : Fin\u2093 n \u2192 \u211d)\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\u2093 n) \u2192 \u211d)+ : log x :=\nvconditions (cond : \u2200 i, 0 < x i)\nimplementationVars (t : (Fin\u2093 n) \u2192 \u211d)\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\u2093 n) \u2192 \u211d)? : abs x :=\nvconditions\nimplementationVars (t : (Fin\u2093 n) \u2192 \u211d)\nimplementationObjective t\nimplementationConstraints\n  (c_pos : Real.Vec.posOrthCone (t - x : (Fin\u2093 n) \u2192 \u211d))\n  (c_neg : Real.Vec.posOrthCone (t + x : (Fin\u2093 n) \u2192 \u211d))\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 \u211d)? : 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 : \u2115)& (A : Matrix.{0,0,0} (Fin\u2093 n) (Fin\u2093 n) \u211d)? : Real.log A.det :=\nvconditions (hA : A.PosDef)\nimplementationVars (t : Fin\u2093 n \u2192 \u211d) (Y : Matrix (Fin\u2093 n) (Fin\u2093 n) \u211d)\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\u2093 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 \u2b1d (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 \u2b1d (LDL.lower hA).transpose) i)\n    rw [\u2190 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    \u00b7 exact t\n    \u00b7 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\u2093 m) (Fin\u2093 n) \u211d)? : Matrix.abs M :=\nvconditions\nimplementationVars (T : Matrix (Fin\u2093 m) (Fin\u2093 n) \u211d)\nimplementationObjective T\nimplementationConstraints\n  (c_pos : Real.Matrix.posOrthCone (T - M : Matrix (Fin\u2093 m) (Fin\u2093 n) \u211d))\n  (c_neg : Real.Matrix.posOrthCone (T + M : Matrix (Fin\u2093 m) (Fin\u2093 n) \u211d))\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 \u2192 type\n| arrow : type \u2192 type \u2192 type\n| tensor : type \u2192 type \u2192 type\n\nvariables (cT : Type)\n\n@[reducible] def context (cT : Type) : Type := list (string \u00d7 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 \u2192 Type) : \u03a0 (\u0393 : 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 (\u0393\u2081 \u0393\u2082 : context cT) {T\u2081 T\u2082 : type cT} (f : term \u0393\u2081 (T\u2081.arrow T\u2082)) (x : term \u0393\u2082 T\u2081) : \n    term (\u0393\u2081 ++' \u0393\u2082) T\u2082\n| lambda {\u0393 : context cT} (a : string) (T\u2081 : type cT) {T\u2082 : type cT}\n    (t : term (\u0393 ::' (a, T\u2081)) T\u2082) : term \u0393 (T\u2081.arrow T\u2082)\n\nopen category_theory\n\nvariables {R : Type} [comm_ring R] \n\nsection\n\nvariables (cTi : cT \u2192 Module.{0 0} R) \n\nopen_locale tensor_product\n\ndef typei : type cT \u2192 Module R\n| (type.const T)     := cTi T\n| (type.arrow T\u2081 T\u2082) := Module.of R (typei T\u2081 \u2192\u2097[R] typei T\u2082)\n| (type.tensor T\u2081 T\u2082) := Module.of R (typei T\u2081 \u2297[R] typei T\u2082)\n\ndef contexti : context cT \u2192 Module R\n| []       := Module.of R R\n| (T :: l) := Module.of R (contexti l \u2297[R] typei cTi T.2 )\n\ndef contexti_append : \u03a0 (\u0393\u2081 \u0393\u2082 : context cT), \n  (contexti cTi (\u0393\u2081 ++' \u0393\u2082)) \u2243\u2097[R] contexti cTi \u0393\u2081 \u2297[R] contexti cTi \u0393\u2082\n| \u0393\u2081      [] := (tensor_product.rid R (contexti cTi \u0393\u2081)).symm\n| \u0393\u2081 (A::\u0393\u2082) := (tensor_product.congr  \n    (contexti_append \u0393\u2081 \u0393\u2082) (linear_equiv.refl R (typei cTi A.2))).trans \n  (tensor_product.assoc R _ _ _)\n\nvariables {const_term : type cT \u2192 Type}\nvariables (const_termi : \u03a0 {T : type cT}, const_term T \u2192 typei cTi T)\n\ndef termi : \u03a0 {\u0393 : context cT} {A : type cT} (t : term const_term \u0393 A),\n  contexti cTi \u0393 \u2192\u2097[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\u2082 (@term.app  _ _ \u0393\u2081 \u0393\u2082 T\u2081 _ f x) := \n  linear_map.comp (tensor_product.uncurry R (contexti cTi \u0393\u2081) (contexti cTi \u0393\u2082) _\n       (linear_map.comp (linear_map.lcomp R _ (termi x)) (termi f)))\n     (contexti_append _ \u0393\u2081 \u0393\u2082).to_linear_map\n| \u0393 (type.arrow _ T\u2082) (term.lambda a T\u2081 t) := tensor_product.curry (termi t)\n\nend\n\nvariables {M : Module.{0 0} R} (op : M \u2192\u2097[R] M \u2192\u2097[R] M)\n\nopen term\n\ndef const_term : type unit \u2192 Type\n| (type.arrow (type.const ()) (type.arrow (type.const ()) (type.const ()))) := unit\n| _ := empty\n\ndef cTi : unit \u2192 Module R := \u03bb _, 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\u2081 T\u2082; try { apply empty.elim t },\n  cases T\u2081 with _ T\u2082 T\u2083; try { apply empty.elim t },\n  cases T\u2081,\n  cases T\u2082 with _ T\u2081 T\u2082; try { apply empty.elim t },\n  cases T\u2081 with _ T\u2081 T\u2082; try { apply empty.elim t },\n  cases T\u2081,\n  cases T\u2082 with _ T\u2081 T\u2082; 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\u2081 : @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\u2081 = sorry :=\nbegin\n  dunfold exmpl\u2081,\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 = \u03bc \u2022 x` \nfor some scalar `\u03bc`. The scalar `\u03bc` is called an eigenvalue. We express this\nby writing `eigenvector f \u03bc x`.\n\nA generalized eigenvector of a linear map `f` is a nonzero vector `x` such that \n`(f x - \u03bc \u2022 x) ^ k = 0` for some scalar `\u03bc` and some natural number `k`. The \nscalar `\u03bc` is called a generalized eigenvalue. We express this\nby writing `generalized_eigenvector f k \u03bc 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 \u03b1 (\u03b2 \u2192\u2097[\u03b1] \u03b2)` 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 {\u03b1 : Type v} {\u03b2 : Type w} [decidable_eq \u03b2] [add_comm_group \u03b2]\n\n/-- An eigenvector of a linear map `f` with eigenvalue `\u03bc` is a nonzero vector\n    `x` such that `f x = \u03bc \u2022 x`. -/\ndef eigenvector [field \u03b1] [vector_space \u03b1 \u03b2] \n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (\u03bc : \u03b1) (x : \u03b2) : Prop := x \u2260 0 \u2227 f x = \u03bc \u2022 x\n\nlocal notation `am` := algebra_map \u03b1 (\u03b2 \u2192\u2097[\u03b1] \u03b2)\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 \u03b1] [is_alg_closed \u03b1] [decidable_eq \u03b1] [vector_space \u03b1 \u03b2] [finite_dimensional \u03b1 \u03b2]\n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (hex : \u2203 v : \u03b2, v \u2260 0) : \n  \u2203 (x : \u03b2) (c : \u03b1), eigenvector f c x :=\nbegin\n  obtain \u27e8v, hv\u27e9 : \u2203 v : \u03b2, v \u2260 0 := hex,\n  have h_lin_dep : \u00ac linear_independent \u03b1 (\u03bb n : \u2115, (f ^ n) v),\n  { intro h_lin_indep, \n    have : cardinal.mk \u2115 < 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 (\u2203 (x : polynomial \u03b1), \u00ac(polynomial.eval\u2082 am f x v = 0 \u2192 x = 0)),\n  obtain \u27e8p, hp\u27e9 : \u2203 p, \u00ac(eval\u2082 am f p v = 0 \u2192 p = 0),\n  { exact not_forall.1 (\u03bb h, h_lin_dep ((linear_independent_iff_eval\u2082 f v).2 h)) },\n  obtain \u27e8h_eval_p, h_p_ne_0\u27e9 : eval\u2082 am f p v = 0 \u2227 p \u2260 0 := not_imp.1 hp,\n  obtain \u27e8q, hq_mem, hq_noninj\u27e9 : \u2203 q \u2208 factors p, \u00acfunction.injective \u21d1(eval\u2082 am f q), \n  { exact polynomial.exists_noninjective_factor_of_eval\u2082_0 f v hv p h_p_ne_0 h_eval_p },\n  have h_q_ne_0 : q \u2260 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\u2082 : polynomial.eval\u2082 am f q = q.leading_coeff \u2022 f + am (q.coeff 0),\n  { rw [polynomial.eq_X_add_C_of_degree_eq_one h_deg_q],\n    simp [eval\u2082_mul_noncomm am f _ _ (\u03bb x y, ( algebra.commutes' x y).symm)],\n    simp [leading_coeff_X_add_C _ _ (\u03bb h, h_q_ne_0 (leading_coeff_eq_zero.1 h))],\n    refl },\n  obtain \u27e8x, hx\u2081, hx\u2082\u27e9 : \u2203 (x : \u03b2), eval\u2082 am f q x = 0 \u2227 \u00acx = 0,\n  { rw [\u2190linear_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 \u2022 f x + coeff q 0 \u2022 x = 0,\n  { rw h_q_eval\u2082 at hx\u2081,\n    exact hx\u2081 },\n  show \u2203 (x : \u03b2) (c : \u03b1), x \u2260 0 \u2227 f x = c \u2022 x,\n  { use x, \n    use -(coeff q 0 / q.leading_coeff),\n    refine \u27e8hx\u2082, _\u27e9,\n    rw neg_smul,\n    have : (leading_coeff q)\u207b\u00b9 \u2022 leading_coeff q \u2022 f x = (leading_coeff q)\u207b\u00b9 \u2022 -(coeff q 0 \u2022 x) := \n      congr_arg (\u03bb x, (leading_coeff q)\u207b\u00b9 \u2022 x) (add_eq_zero_iff_eq_neg.1 h_fx_x_lin_dep),\n    simpa [smul_smul, inv_mul_cancel (\u03bb 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 \u03b1] [decidable_eq \u03b1] [vector_space \u03b1 \u03b2] \n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (\u03bcs : set \u03b1) (xs : \u03bcs \u2192 \u03b2) (h_eigenvec : \u2200 \u03bc : \u03bcs, eigenvector f \u03bc (xs \u03bc)): \n  linear_independent \u03b1 xs := \nbegin\n  rw linear_independent_iff,\n  intros l hl,\n  induction h_l_support : l.support using finset.induction with \u03bc\u2080 l_support' h\u03bc\u2080 ih generalizing l,\n  { exact finsupp.support_eq_empty.1 h_l_support },\n  { let l'_f := (\u03bb \u03bc : \u03bcs, (\u2191\u03bc - \u2191\u03bc\u2080) * l \u03bc),\n    have h_l_support' : \u2200 (\u03bc : \u03bcs), l'_f \u03bc \u2260 0 \u2194 \u03bc \u2208 l_support',\n    { intros \u03bc,\n      dsimp only [l'_f],\n      rw [mul_ne_zero_iff, sub_ne_zero, \u2190not_iff_not, not_and_distrib, not_not, not_not, \u2190subtype.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\u03bc,\n        have := finsupp.mem_support_iff.2 hl\u03bc,\n        rw [h_l_support, finset.mem_insert] at this,\n        cc } },\n    let l' : \u03bcs \u2192\u2080 \u03b1 := finsupp.on_finset l_support' l'_f (\u03bb \u03bc, (h_l_support' \u03bc).1),\n    have total_l' : (@linear_map.to_fun \u03b1 (finsupp \u03bcs \u03b1) \u03b2 _ _ _ _ _ (finsupp.total \u03bcs \u03b2 \u03b1 xs)) l' = 0,\n    { let g := f - am \u03bc\u2080, \n      have h_g\u03bc\u2080: g (l \u03bc\u2080 \u2022 xs \u03bc\u2080) = 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 (\u03bb (a : \u03bcs), l'_f a \u2260 0) l_support' = l_support',\n      { convert @finset.filter_congr _ _ _ (classical.dec_pred _) (classical.dec_pred _) _ _,\n        { apply finset.filter_true.symm },\n        exact \u03bb \u03bc h\u03bc, iff_of_true ((h_l_support' \u03bc).2 h\u03bc) true.intro },\n      have bodies_eq : \u2200 (\u03bc : \u03bcs), l'_f \u03bc \u2022 xs \u03bc = g (l \u03bc \u2022 xs \u03bc), \n      { intro \u03bc,\n        dsimp only [g, l'_f],\n        rw [linear_map.map_smul, linear_map.sub_apply, (h_eigenvec _).2, module.endomorphism_algebra_map_apply2, \u2190sub_smul, smul_smul, mul_comm] },\n      have := finsupp.total_on_finset l_support' l'_f xs _,\n      unfold_coes at this,\n      rw [this, \u2190linear_map.map_zero g,\n          \u2190congr_arg g hl, finsupp.total_apply, finsupp.sum, linear_map.map_sum, h_l_support,\n          finset.sum_insert h\u03bc\u2080, h_g\u03bc\u2080, 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 \u03bc,\n      rw finsupp.on_finset_mem_support l_support' l'_f _ \u03bc,\n      by_cases h_cases: \u03bc \u2208 l_support',\n      { refine iff_of_true _ h_cases,\n        exact (h_l_support' \u03bc).2 h_cases },\n      { refine iff_of_false _ h_cases,\n        rwa not_iff_not.2 (h_l_support' \u03bc) } },\n    have l'_eq_0 : l' = 0 := ih l' total_l' h_l'_support_eq,\n    \n    have h_mul_eq_0 : \u2200 \u03bc : \u03bcs, (\u2191\u03bc - \u2191\u03bc\u2080) * l \u03bc = 0,\n    { intro \u03bc,\n      calc (\u2191\u03bc - \u2191\u03bc\u2080) * l \u03bc = l' \u03bc : rfl\n      ... = 0 : by { rw [l'_eq_0], refl } },\n\n    have h_l\u03bc_eq_0 : \u2200 \u03bc : \u03bcs, \u03bc \u2260 \u03bc\u2080 \u2192 l \u03bc = 0,\n    { intros \u03bc h\u03bc,\n      apply classical.or_iff_not_imp_left.1 (mul_eq_zero.1 (h_mul_eq_0 \u03bc)),\n      rwa [sub_eq_zero, \u2190subtype.ext_iff] },\n\n    have h_sum_l_support'_eq_0 : finset.sum l_support' (\u03bb (\u03bc : \u21a5\u03bcs), l \u03bc \u2022 xs \u03bc) = 0,\n    { rw \u2190finset.sum_const_zero,\n      apply finset.sum_congr rfl,\n      intros \u03bc h\u03bc,\n      rw h_l\u03bc_eq_0,\n      apply zero_smul,\n      intro h,\n      rw h at h\u03bc,\n      contradiction },\n\n    have : l \u03bc\u2080 = 0,\n    { rw [finsupp.total_apply, finsupp.sum, h_l_support, \n          finset.sum_insert h\u03bc\u2080, h_sum_l_support'_eq_0, add_zero] at hl,\n      by_contra h,\n      exact (h_eigenvec \u03bc\u2080).1 ((vector_space.smul_neq_zero (xs \u03bc\u2080) h).1 hl) },\n\n    show l = 0,\n    { ext \u03bc,\n      by_cases h_cases : \u03bc = \u03bc\u2080,\n      { rw h_cases, \n        assumption },\n      exact h_l\u03bc_eq_0 \u03bc 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 \u03b1] [vector_space \u03b1 \u03b2] \n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (k : \u2115) (\u03bc : \u03b1) (x : \u03b2) : Prop := x \u2260 0 \u2227 ((f - am \u03bc) ^ 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 \u03b1] [vector_space \u03b1 \u03b2] \n  {f : \u03b2 \u2192\u2097[\u03b1] \u03b2} {k : \u2115} {\u03bc : \u03b1} {x : \u03b2} (h : generalized_eigenvector f k \u03bc x) : \n  k \u2260 0 :=\nbegin\n  rcases h with \u27e8h_nz, h\u27e9,\n  contrapose h_nz,\n  rw not_not at h_nz \u22a2,\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 \u03b1] [vector_space \u03b1 \u03b2] \n  {f : \u03b2 \u2192\u2097[\u03b1] \u03b2} {k : \u2115} {\u03bc : \u03b1} {x : \u03b2} (h : generalized_eigenvector f k \u03bc x) :\n  \u2200 m : \u2115, k \u2264 m \u2192 generalized_eigenvector f m \u03bc x :=\nbegin\n  intros m hm,\n  refine \u27e8h.1, _\u27e9,\n  rw \u2190pow_eq_pow_sub_mul _ hm,\n  change ((f - am \u03bc) ^ (m - k)) (((f - am \u03bc) ^ 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 \u03b1] [vector_space \u03b1 \u03b2] \n  {f : \u03b2 \u2192\u2097[\u03b1] \u03b2} {k : \u2115} {\u03bc : \u03b1} {x : \u03b2} (hx : eigenvector f \u03bc x) (hk : k > 0) :\n  generalized_eigenvector f k \u03bc x :=\nbegin\n  rw [generalized_eigenvector, \u2190nat.succ_pred_eq_of_pos hk, pow_succ'],\n  change x \u2260 0 \u2227 ((f - am \u03bc) ^ nat.pred k) ((f - am \u03bc) x) = 0,\n  have : (f - am \u03bc) 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 \u03bc\n    equals the kernel of (f - am \u03bc) ^ n, where n is the dimension of \n    the vector space (Axler's Lemma 3.1). -/\nlemma generalized_eigenvector_dim \n  [field \u03b1] [decidable_eq \u03b1] [vector_space \u03b1 \u03b2] [finite_dimensional \u03b1 \u03b2]\n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (\u03bc : \u03b1) (x : \u03b2) : \n  (\u2203 k : \u2115, generalized_eigenvector f k \u03bc x) \n    \u2194 generalized_eigenvector f (findim \u03b1 \u03b2) \u03bc x :=\nbegin\n  split,\n  { show (\u2203 (k : \u2115), generalized_eigenvector f k \u03bc x) \u2192 x \u2260 0 \u2227 ((f - am \u03bc) ^ findim \u03b1 \u03b2) x = 0,\n    intro h_exists_eigenvec,\n    let k := @nat.find (\u03bb k : \u2115, generalized_eigenvector f k \u03bc x) (classical.dec_pred _) h_exists_eigenvec,\n    let z := (\u03bb i : fin k, ((f - am \u03bc) ^ (i : \u2115)) x),\n\n    have h_x_nz : x \u2260 0, \n    { rcases h_exists_eigenvec with \u27e8k, h\u27e9,\n      exact h.1 },\n\n    have h_lin_indep : linear_independent \u03b1 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 : \u2200 j, j < i \u2192 ((f - am \u03bc) ^ (k - i.val - 1)) (l j \u2022 z j) = 0,\n      { intros j hj,\n        simp [ih j hj j rfl] }, \n\n      have h_zero_beyond_k : \u2200 m, k \u2264 m \u2192 ((f - am \u03bc) ^ m) x = 0,\n      { intros m hm,\n        apply (generalized_eigenvector_zero_beyond \n            (@nat.find_spec (\u03bb k : \u2115, generalized_eigenvector f k \u03bc x) (classical.dec_pred _) h_exists_eigenvec) _ hm).2 },\n\n      have h_zero_of_gt : \u2200 j, j > i \u2192 ((f - am \u03bc) ^ (k - i.val - 1)) (l j \u2022 z j) = 0,\n      { intros j hj,\n        dsimp only [z],\n        rw [linear_map.map_smul],\n        change l j \u2022 ((f - am \u03bc) ^ (k - i.val - 1) * ((f - am \u03bc) ^ \u2191j)) x = 0,\n        rw [\u2190pow_add, h_zero_beyond_k, smul_zero],\n        rw [nat.sub_sub, \u2190nat.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 \u2190nat.lt_iff_add_one_le,\n        unfold_coes,\n        change i.val < (j : \u2115),\n        exact hj }, \n\n      have h_zero_of_ne : \u2200 j, j \u2260 i \u2192 ((f - am \u03bc) ^ (k - i.val - 1)) (l j \u2022 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 \u2209 l.support \u2192 ((f - am \u03bc) ^ (k - i.val - 1)) (l i \u2022 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 \u2022 (((f - am \u03bc) ^ (k - 1)) x) = 0,\n      { have h_k_sub_1 : k - i.val - 1 + i.val = k - 1,\n        { rw \u2190nat.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 [\u2190h_k_sub_1, pow_add],\n        let g := (f - am \u03bc) ^ (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 (\u03bb 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 \u03bc) ^ (k - 1)) x \u2260 0 :=\n        not_and.1 (@nat.find_min (\u03bb k : \u2115, generalized_eigenvector f k \u03bc 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 \u2260 0 \u2227 ((f - am \u03bc) ^ findim \u03b1 \u03b2) x = 0,\n    { split,\n      { exact h_x_nz },\n      apply (generalized_eigenvector_zero_beyond \n        (@nat.find_spec (\u03bb k : \u2115, generalized_eigenvector f k \u03bc x) (classical.dec_pred _) h_exists_eigenvec) _ _).2,\n      rw [\u2190cardinal.nat_cast_le, \u2190cardinal.lift_mk_fin _, \u2190cardinal.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 \u03b1 \u03b2) \u03bc x \u2192 (\u2203 (k : \u2115), generalized_eigenvector f k \u03bc x),\n    exact \u03bbh, \u27e8_, h\u27e9, }\nend\n\nlemma generalized_eigenvector_restrict_aux [field \u03b1] [vector_space \u03b1 \u03b2] \n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (p : submodule \u03b1 \u03b2) (k : \u2115) (\u03bc : \u03b1) (x : p) \n  (hfp : \u2200 (x : \u03b2), x \u2208 p \u2192 f x \u2208 p) : \n  (((f.restrict p p hfp - algebra_map _ _ \u03bc) ^ k) x : \u03b2) \n  = ((f - algebra_map _ _ \u03bc) ^ 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 _ _ \u03bc) (((f.restrict p p hfp - algebra_map _ _ \u03bc) ^ k) x) : \u03b2) =\n        (f - algebra_map _ _ \u03bc) (((f - algebra_map _ _ \u03bc) ^ k) x),\n    rw [linear_map.sub_apply, linear_map.sub_apply, linear_map.restrict_apply, \u2190ih], \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 \u03b1] [vector_space \u03b1 \u03b2] \n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (p : submodule \u03b1 \u03b2) (k : \u2115) (\u03bc : \u03b1) (x : p) (hfp : \u2200 (x : \u03b2), x \u2208 p \u2192 f x \u2208 p) : \n  generalized_eigenvector (linear_map.restrict f p p hfp) k \u03bc x \n    \u2194 generalized_eigenvector f k \u03bc 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 \u03b1] [decidable_eq \u03b1] [vector_space \u03b1 \u03b2] [finite_dimensional \u03b1 \u03b2]\n  {f : \u03b2 \u2192\u2097[\u03b1] \u03b2} {\u03bc : \u03b1}\n  {k : \u2115} {x : \u03b2} (h : generalized_eigenvector f k \u03bc x) :\n  generalized_eigenvector f (findim \u03b1 \u03b2) \u03bc x :=\nbegin\n  rw \u2190generalized_eigenvector_dim,\n  { exact \u27e8k, h\u27e9 }\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 \u03b1] [decidable_eq \u03b1] [vector_space \u03b1 \u03b2] [finite_dimensional \u03b1 \u03b2]\n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (\u03bc : \u03b1) : \n  disjoint ((f - am \u03bc) ^ findim \u03b1 \u03b2).range ((f - am \u03bc) ^ findim \u03b1 \u03b2).ker :=\nbegin\n  rintros v \u27e8\u27e8u, _, hu\u27e9, hv\u27e9,\n  have h2n : ((f - am \u03bc) ^ (findim \u03b1 \u03b2 + findim \u03b1 \u03b2)) u = 0,\n  { rw [pow_add, \u2190linear_map.mem_ker.1 hv, \u2190hu], refl },\n  have hn : ((f - am \u03bc) ^ findim \u03b1 \u03b2) u = 0, \n  { by_cases h_cases: u = 0, \n    { simp [h_cases] },\n    { apply (generalized_eigenvector_dim_of_any \u27e8h_cases, h2n\u27e9).2 } },\n  have hv0 : v = 0, by rw [\u2190hn, hu],\n  show v \u2208 \u2191\u22a5, 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 \u03b1] [is_alg_closed \u03b1] [vector_space \u03b1 \u03b2] \n  {f : \u03b2 \u2192\u2097[\u03b1] \u03b2} {n : \u2115} {\u03bc : \u03b1} {x : \u03b2} (hx : eigenvector f \u03bc x) : \n  0 < dim \u03b1 ((f - am \u03bc) ^ n.succ).ker :=\nbegin\n  have x_mem : x \u2208 ((f - am \u03bc) ^ n.succ).ker,\n  { simp [pow_succ', hx.2, module.endomorphism_algebra_map_apply2] },\n  apply dim_pos_of_mem_ne_zero (\u27e8x, x_mem\u27e9 : ((f - am \u03bc) ^ 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 \u03b1] [is_alg_closed \u03b1] [vector_space \u03b1 \u03b2] [finite_dimensional \u03b1 \u03b2]\n  {f : \u03b2 \u2192\u2097[\u03b1] \u03b2} {n : \u2115} {\u03bc : \u03b1} {x : \u03b2} (hx : eigenvector f \u03bc x) : \n  0 < findim \u03b1 ((f - am \u03bc) ^ 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 \u03b1] [vector_space \u03b1 \u03b2] \n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) (\u03bc\u2080 : \u03b1) (n : \u2115) :\n((f - am \u03bc\u2080) ^ n).ker \n  \u2264 submodule.span \u03b1 ({x : \u03b2 | \u2203 (k : \u2115) (\u03bc : \u03b1), generalized_eigenvector f k \u03bc x}) :=\nbegin\n  intros x hx,\n  by_cases h_cases: x = 0,\n  { simp [h_cases] },\n  { apply submodule.subset_span,\n    exact \u27e8n, \u03bc\u2080, h_cases, linear_map.mem_ker.1 hx\u27e9 }\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 \u03b1] [vector_space \u03b1 \u03b2] \n  {f : \u03b2 \u2192\u2097[\u03b1] \u03b2} {\u03bc : \u03b1} {x : \u03b2} {n : \u2115}\n  (hx : x \u2208 ((f - am \u03bc) ^ n).range) : \n  f x \u2208 ((f - am \u03bc) ^ n).range :=\nbegin\n  rw linear_map.mem_range at *,\n  rcases hx with \u27e8w, hw\u27e9,\n  use f w,\n  have hcommutes : f.comp ((f - am \u03bc) ^ n) = ((f - am \u03bc) ^ n).comp f := \n    algebra.mul_sub_algebra_map_pow_commutes f \u03bc n,\n  rw [\u2190linear_map.comp_apply, \u2190hcommutes, linear_map.comp_apply, hw],\nend\n\n/-- The generalized eigenvectors of f span the vectorspace \u03b2. (Axler's Proposition 3.4). -/\nlemma generalized_eigenvector_span \n  [field \u03b1] [is_alg_closed \u03b1] [decidable_eq \u03b1] [vector_space \u03b1 \u03b2] [finite_dimensional \u03b1 \u03b2]\n  (f : \u03b2 \u2192\u2097[\u03b1] \u03b2) : \n  submodule.span \u03b1 {x | \u2203 k \u03bc, generalized_eigenvector f k \u03bc x} = \u22a4 :=\nbegin\n  rw \u2190top_le_iff,\n  tactic.unfreeze_local_instances,\n  induction h_dim : findim \u03b1 \u03b2 using nat.strong_induction_on with n ih generalizing \u03b2,\n  cases n,\n  { have h_findim_top: findim \u03b1 (\u22a4 : submodule \u03b1 \u03b2) = 0 := eq.trans (@finite_dimensional.findim_top \u03b1 \u03b2 _ _ _ _) h_dim,\n    have h_top_eq_bot : (\u22a4 : submodule \u03b1 \u03b2) = \u22a5 := bot_of_findim_zero _ h_findim_top,\n    simp only [h_top_eq_bot, bot_le] },\n  { have h_dim_pos : 0 < findim \u03b1 \u03b2,\n    { rw [h_dim],\n      apply nat.zero_lt_succ },\n    obtain \u27e8x, \u03bc\u2080, hx_ne_0, h\u03bc\u2080\u27e9 : \u2203 (x : \u03b2) (\u03bc\u2080 : \u03b1), x \u2260 0 \u2227 f x = \u03bc\u2080 \u2022 x,\n    { apply exists_eigenvector f \n        (exists_mem_ne_zero_of_findim_pos h_dim_pos) },\n    let V\u2081 := ((f - am \u03bc\u2080) ^ n.succ).ker,\n    let V\u2082 := ((f - am \u03bc\u2080) ^ n.succ).range,\n    have h_disjoint : disjoint V\u2082 V\u2081,\n    { simp only [V\u2081, V\u2082, h_dim.symm],\n      exact generalized_eigenvec_disjoint_range_ker f \u03bc\u2080 },\n    have h_dim_add : findim \u03b1 V\u2082 + findim \u03b1 V\u2081 = findim \u03b1 \u03b2,\n    { apply linear_map.findim_range_add_findim_ker },\n    have h_dim_V\u2081_pos : 0 < findim \u03b1 V\u2081,\n    { apply pos_findim_eigenker_of_eigenvec \u27e8hx_ne_0, h\u03bc\u2080\u27e9 },\n    have h_findim_V\u2082 : findim \u03b1 V\u2082 < n.succ := by linarith,\n    have h_f_V\u2082 : \u2200 (x : \u03b2), x \u2208 V\u2082 \u2192 f x \u2208 V\u2082, \n    { intros x hx, \n      apply image_mem_eigenrange_of_mem_eigenrange hx, },\n    have hV\u2082 : V\u2082 \u2264 submodule.span \u03b1 ({x : \u03b2 | \u2203 (k : \u2115) (\u03bc : \u03b1), generalized_eigenvector f k \u03bc x}),\n    { have : V\u2082 \u2264 submodule.span \u03b1 ({x : \u03b2 | \u2203 (k : \u2115) (\u03bc : \u03b1), generalized_eigenvector f k \u03bc x} \u2229 V\u2082),\n      { rw \u2190subtype.image_preimage_val,\n        rw \u2190submodule.subtype_eq_val V\u2082,\n        rw submodule.span_image (submodule.subtype V\u2082),\n        rw set.preimage_set_of_eq,\n        rw submodule.subtype_eq_val,\n        have h\u2080 : \u2200 p, submodule.map (submodule.subtype V\u2082) \u22a4 \n              \u2264 submodule.map (submodule.subtype V\u2082) p \n              \u2194 \u22a4 \u2264 p\n            := \u03bb _, (linear_map.map_le_map_iff' (submodule.ker_subtype V\u2082)),\n        have := submodule.range_subtype V\u2082,\n        unfold linear_map.range at this,\n        rw this at h\u2080,\n        rw h\u2080,\n        have := ih (findim \u03b1 V\u2082) h_findim_V\u2082 (f.restrict V\u2082 V\u2082 h_f_V\u2082) 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\u2081 : V\u2081 \u2264 submodule.span \u03b1 ({x : \u03b2 | \u2203 (k : \u2115) (\u03bc : \u03b1), generalized_eigenvector f k \u03bc x}),\n    { apply eigenker_le_span_gen_eigenvec },\n    show \u22a4 \u2264 submodule.span \u03b1 {x : \u03b2 | \u2203 (k : \u2115) (\u03bc : \u03b1), generalized_eigenvector f k \u03bc x},\n    { rw \u2190finite_dimensional.eq_top_of_disjoint V\u2082 V\u2081 h_dim_add h_disjoint,\n      apply sup_le hV\u2082 hV\u2081 } }\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 (\u03bb _, a) rfl rfl \n\ndef inv.filler {A : Type} {a b : A} (kan : has_hcom A) :\n  path A a b \u2192 I \u2192 I \u2192 A :=\nbegin\n  intro p, induction p with p _ _ p0 p1,\n  unfold eq.mp at *; simp at *,\n  apply (hcom (\u03bb _, p i0) [[ p ; (\u03bb _, p i0) ]] kan),\nend\n\ndef inv {A : Type} {a b : A} (kan : has_hcom A) :\n  path A a b \u2192 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 \u2192 path A b c \u2192 I \u2192 I \u2192 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 (\u03bb _, p i0) q rfl p1)),\nend\n\ndef comp {A : Type} {a b c : A} (kan : has_hcom A) :\n  path A a b \u2192 path A b c \u2192 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 (\u03bb _, 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 \u2192 A} (h : p = \u03bb _, 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 \u2964 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 \u2964 D` to a category `D` with biproducts\nlifts to a functor `Mat_.lift F : Mat_ C \u2964 D`,\nMoreover, this functor is unique (up to natural isomorphisms) amongst functors `L : Mat_ C \u2964 D`\nsuch that `embedding C \u22d9 L \u2245 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 \u224c 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\u2081 v\u2082 u\u2081 u\u2082\nvariables (C : Type u\u2081) [category.{v\u2081} C] [preadditive C]\n\n/--\nAn object in `Mat_ C` is a finite tuple of objects in `C`.\n-/\nstructure Mat_ : Type (max (v\u2081+1) u\u2081) :=\n(\u03b9 : Type v\u2081)\n[F : fintype \u03b9]\n[D : decidable_eq \u03b9]\n(X : \u03b9 \u2192 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\u2081 := dmatrix M.\u03b9 N.\u03b9 (\u03bb i j, M.X i \u27f6 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 := \u03bb 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\u03bb i k, \u2211 j : N.\u03b9, f i j \u226b g j k\n\nend hom\n\nsection\nlocal attribute [simp] hom.id hom.comp\n\ninstance : category.{v\u2081} (Mat_ C) :=\n{ hom := hom,\n  id := hom.id,\n  comp := \u03bb M N K f g, f.comp g,\n  id_comp' := \u03bb M N f, by simp [dite_comp],\n  comp_id' := \u03bb M N f, by simp [comp_dite],\n  assoc' := \u03bb 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  (\ud835\udfd9 M : hom M M) = \u03bb 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.\u03b9) :\n  (\ud835\udfd9 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.\u03b9) :\n  (\ud835\udfd9 M : hom M M) i i = \ud835\udfd9 _ :=\nby simp [id_apply]\n\n@[simp] lemma id_apply_of_ne (M : Mat_ C) (i j : M.\u03b9) (h : i \u2260 j) :\n  (\ud835\udfd9 M : hom M M) i j = 0 :=\nby simp [id_apply, h]\n\nlemma comp_def {M N K : Mat_ C} (f : M \u27f6 N) (g : N \u27f6 K) :\n  (f \u226b g) = \u03bb i k, \u2211 j : N.\u03b9, f i j \u226b g j k := rfl\n\n@[simp] lemma comp_apply {M N K : Mat_ C} (f : M \u27f6 N) (g : N \u27f6 K) (i k) :\n  (f \u226b g) i k = \u2211 j : N.\u03b9, f i j \u226b g j k := rfl\n\ninstance (M N : Mat_ C) : inhabited (M \u27f6 N) := \u27e8\u03bb i j, (0 : M.X i \u27f6 N.X j)\u27e9\n\nend\n\ninstance : preadditive (Mat_ C) :=\n{ hom_group := \u03bb M N, by { change add_comm_group (dmatrix M.\u03b9 N.\u03b9 _), apply_instance, },\n  add_comp' := \u03bb M N K f f' g, by { ext, simp [finset.sum_add_distrib], },\n  comp_add' := \u03bb 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 \u27f6 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 := \u03bb J \ud835\udc9f \u2131, by exactI\n  { has_biproduct := \u03bb f,\n    has_biproduct_of_total\n    { X := \u27e8\u03a3 j : J, (f j).\u03b9, \u03bb p, (f p.1).X p.2\u27e9,\n      \u03c0 := \u03bb j x y,\n      begin\n        dsimp at x \u22a2,\n        refine if h : x.1 = j then _ else 0,\n        refine if h' : (@eq.rec J x.1 (\u03bb j, (f j).\u03b9) 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      \u03b9 := \u03bb j x y,\n      begin\n        dsimp at y \u22a2,\n        refine if h : y.1 = j then _ else 0,\n        refine if h' : (@eq.rec J y.1 (\u03bb j, (f j).\u03b9) y.2 _ h) = x then _ else 0,\n        apply eq_to_hom,\n        substs h h',\n      end,\n      \u03b9_\u03c0 := \u03bb 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\u2081,\n      dsimp at i\u2081 \u22a2,\n      rcases i\u2081 with \u27e8j\u2081, i\u2081\u27e9,\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\u2082,\n        rcases i\u2082 with \u27e8j\u2082, i\u2082\u27e9,\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\u2081 = j\u2082,\n        { subst h, simp, },\n        { simp [h], }, },\n    end }}.\n\nend Mat_\n\nnamespace functor\nvariables {C} {D : Type*} [category.{v\u2081} 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 \u2964 D) [functor.additive F] : Mat_ C \u2964 Mat_ D :=\n{ obj := \u03bb M, \u27e8M.\u03b9, \u03bb i, F.obj (M.X i)\u27e9,\n  map := \u03bb M N f i j, F.map (f i j),\n  map_comp' := \u03bb 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 : (\ud835\udfed C).map_Mat_ \u2245 \ud835\udfed (Mat_ C) :=\nnat_iso.of_components (\u03bb M, eq_to_iso (by { cases M, refl, }))\n(\u03bb 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\u2081} E] [preadditive E]\n  (F : C \u2964 D) [functor.additive F] (G : D \u2964 E) [functor.additive G] :\n  (F \u22d9 G).map_Mat_ \u2245 F.map_Mat_ \u22d9 G.map_Mat_ :=\nnat_iso.of_components (\u03bb M, eq_to_iso (by { cases M, refl, }))\n(\u03bb 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 \u2964 Mat_ C :=\n{ obj := \u03bb X, \u27e8punit, \u03bb _, X\u27e9,\n  map := \u03bb X Y f, \u03bb _ _, f,\n  map_id' := \u03bb X, by { ext \u27e8\u27e9 \u27e8\u27e9, simp, },\n  map_comp' := \u03bb X Y Z f g, by { ext \u27e8\u27e9 \u27e8\u27e9, simp, }, }\n\nnamespace embedding\n\ninstance : faithful (embedding C) :=\n{ map_injective' := \u03bb X Y f g h, congr_fun (congr_fun h punit.star) punit.star, }\n\ninstance : full (embedding C) :=\n{ preimage := \u03bb X Y f, f punit.star punit.star, }\n\ninstance : functor.additive (embedding C) := {}\n\nend embedding\n\ninstance [inhabited C] : inhabited (Mat_ C) := \u27e8(embedding C).obj default\u27e9\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 \u2245 \u2a01 (\u03bb i, (embedding C).obj (M.X i)) :=\n{ hom := biproduct.lift (\u03bb i j k, if h : j = i then eq_to_hom (congr_arg M.X h) else 0),\n  inv := biproduct.desc (\u03bb 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_\u03c0, biproduct.\u03b9_desc_assoc, biproduct.\u03b9_\u03c0],\n    ext \u27e8\u27e9 \u27e8\u27e9,\n    simp [dite_comp, comp_dite],\n    split_ifs,\n    { subst h, simp, },\n    { simp [h], },\n  end, }.\n\nvariables {D : Type u\u2081} [category.{v\u2081} 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 \u2964 D) [functor.additive F] (M : Mat_ C) :\n  F.obj M \u2245 \u2a01 (\u03bb i, F.obj ((embedding C).obj (M.X i))) :=\n(F.map_iso (iso_biproduct_embedding M)) \u226a\u226b (F.map_biproduct _)\n\nvariables [has_finite_biproducts D]\n\n@[reassoc] lemma additive_obj_iso_biproduct_naturality (F : Mat_ C \u2964 D) [functor.additive F]\n  {M N : Mat_ C} (f : M \u27f6 N) :\n  F.map f \u226b (additive_obj_iso_biproduct F N).hom =\n    (additive_obj_iso_biproduct F M).hom \u226b\n      biproduct.matrix (\u03bb 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_\u03c0, functor.map_bicone_\u03c0,\n    biproduct.bicone_\u03c0, biproduct.lift_matrix],\n  dsimp [embedding],\n  simp only [\u2190F.map_comp, biproduct.lift_\u03c0, biproduct.matrix_\u03c0, category.assoc],\n  simp only [\u2190F.map_comp, \u2190F.map_sum, biproduct.lift_desc, biproduct.lift_\u03c0_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 \u2964 D) [functor.additive F]\n  {M N : Mat_ C} (f : M \u27f6 N) :\n  (additive_obj_iso_biproduct F M).inv \u226b F.map f =\n    biproduct.matrix (\u03bb i j, F.map ((embedding C).map (f i j)) : _) \u226b\n      (additive_obj_iso_biproduct F N).inv :=\nby rw [iso.inv_comp_eq, \u2190category.assoc, iso.eq_comp_inv, additive_obj_iso_biproduct_naturality]\n\n/-- Any additive functor `C \u2964 D` to a category `D` with finite biproducts extends to\na functor `Mat_ C \u2964 D`. -/\n@[simps]\ndef lift (F : C \u2964 D) [functor.additive F] : Mat_ C \u2964 D :=\n{ obj := \u03bb X, \u2a01 (\u03bb i, F.obj (X.X i)),\n  map := \u03bb X Y f, biproduct.matrix (\u03bb i j, F.map (f i j)),\n  map_id' := \u03bb 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' := \u03bb X Y Z f g, by { ext i j, simp, }, }.\n\ninstance lift_additive (F : C \u2964 D) [functor.additive F] : functor.additive (lift F) := {}\n\n/-- An additive functor `C \u2964 D` factors through its lift to `Mat_ C \u2964 D`. -/\n@[simps]\ndef embedding_lift_iso (F : C \u2964 D) [functor.additive F] : embedding C \u22d9 lift F \u2245 F :=\nnat_iso.of_components (\u03bb X,\n  { hom := biproduct.desc (\u03bb P, \ud835\udfd9 (F.obj X)),\n    inv := biproduct.lift (\u03bb P, \ud835\udfd9 (F.obj X)), })\n(\u03bb X Y f, begin\n  dsimp,\n  ext,\n  simp only [category.id_comp, biproduct.\u03b9_desc_assoc],\n  erw biproduct.\u03b9_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 \u2964 D` such that `F \u2245 embedding C \u22d9 L`.\n-/\ndef lift_unique (F : C \u2964 D) [functor.additive F] (L : Mat_ C \u2964 D) [functor.additive L]\n  (\u03b1 : embedding C \u22d9 L \u2245 F) :\n  L \u2245 lift F :=\nnat_iso.of_components\n  (\u03bb M, (additive_obj_iso_biproduct L M) \u226a\u226b\n    (biproduct.map_iso (\u03bb i, \u03b1.app (M.X i))) \u226a\u226b\n    (biproduct.map_iso (\u03bb i, (embedding_lift_iso F).symm.app (M.X i))) \u226a\u226b\n    (additive_obj_iso_biproduct (lift F) M).symm)\n(\u03bb 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 \u27e8\u27e9,\n  dsimp, simp,\n  convert \u03b1.hom.naturality (f j k),\n  erw [biproduct.matrix_\u03c0],\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 \u2964 D` are naturally isomorphic if\ntheir precompositions with `embedding C` are naturally isomorphic as functors `C \u2964 D`. -/\n@[ext]\ndef ext {F G : Mat_ C \u2964 D} [functor.additive F] [functor.additive G]\n  (\u03b1 : embedding C \u22d9 F \u2245 embedding C \u22d9 G) : F \u2245 G :=\n(lift_unique (embedding C \u22d9 G) _ \u03b1) \u226a\u226b (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 \u22d9 \ud835\udfed (Mat_ C) \u2245 embedding C \u22d9 lift (\ud835\udfed C) \u22d9 embedding C :=\nfunctor.right_unitor _ \u226a\u226b\n  (functor.left_unitor _).symm \u226a\u226b\n  (iso_whisker_right (embedding_lift_iso _).symm _) \u226a\u226b\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\u2081+1)) [large_category C] [preadditive C] [has_finite_biproducts C] :\n  Mat_ C \u224c C :=\nequivalence.mk -- I suspect this is already an adjoint equivalence, but it seems painful to verify.\n  (lift (\ud835\udfed C))\n  (embedding C)\n  (ext equivalence_self_of_has_finite_biproducts_aux)\n  (embedding_lift_iso (\ud835\udfed C))\n\n@[simp] lemma equivalence_self_of_has_finite_biproducts_functor\n  {C : Type (u\u2081+1)} [large_category C] [preadditive C] [has_finite_biproducts C] :\n  (equivalence_self_of_has_finite_biproducts C).functor = lift (\ud835\udfed C) :=\nrfl\n\n@[simp] lemma equivalence_self_of_has_finite_biproducts_inverse\n  {C : Type (u\u2081+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 := \u03bb X Y, matrix X Y R,\n  id := \u03bb X, 1,\n  comp := \u03bb X Y Z f g, f \u2b1d 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  \ud835\udfd9 M = \u03bb i j, if h : i = j then 1 else 0 :=\nrfl\n\nlemma id_apply (M : Mat R) (i j : M) :\n  (\ud835\udfd9 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  (\ud835\udfd9 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 \u2260 j) :\n  (\ud835\udfd9 M : matrix M M R) i j = 0 :=\nby simp [id_apply, h]\n\nlemma comp_def {M N K : Mat R} (f : M \u27f6 N) (g : N \u27f6 K) :\n  (f \u226b g) = \u03bb i k, \u2211 j : N, f i j * g j k := rfl\n\n@[simp] lemma comp_apply {M N K : Mat R} (f : M \u27f6 N) (g : N \u27f6 K) (i k) :\n  (f \u226b g) i k = \u2211 j : N, f i j * g j k := rfl\n\ninstance (M N : Mat R) : inhabited (M \u27f6 N) := \u27e8\u03bb (i : M) (j : N), (0 : R)\u27e9\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\u1d50\u1d52\u1d56) \u2964 Mat R :=\n{ obj := \u03bb X, Fintype.of X.\u03b9,\n  map := \u03bb X Y f i j, mul_opposite.unop (f i j),\n  map_id' := \u03bb 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' := \u03bb 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 := \u03bb X Y f i j, mul_opposite.op (f i j), }\n\ninstance : ess_surj (equivalence_single_obj_inverse R) :=\n{ mem_ess_image := \u03bb X,\n  \u27e8{ \u03b9 := X, X := \u03bb _, punit.star }, \u27e8eq_to_iso (by { dsimp, cases X, congr, })\u27e9\u27e9, }\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 \u224c Mat_ (single_obj R\u1d50\u1d52\u1d56) :=\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 {\u03b9 : Type u'} {c : complex_shape \u03b9}\n\n-- move this\nsection\nvariables {C : Type u} [category.{v} C] {Z : C \u2192 Prop}\n@[simps]\ndef lift_iso {X Y : { X : C // Z X }} (h : (X : C) \u2245 Y) : X \u2245 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 \u03b9) := \u03b9\n\ninductive walking_complex_hom : walking_complex c \u2192 walking_complex c \u2192 Type u'\n| id : \u03a0 i, walking_complex_hom i i\n| d : \u03a0 {i j}, c.rel i j \u2192 walking_complex_hom i j\n| zero : \u03a0 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 \u2192 walking_complex_hom j k \u2192 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 \u27f6 j) :=\n\u27e8walking_complex_hom.zero i j\u27e9\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 = \ud835\udfd9 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 \u27f6 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 \u226b 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 \u27f6 j) : h.X i \u27f6 h.X j :=\nbegin\n  cases f, exacts [\ud835\udfd9 _, 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 (\ud835\udfd9 i) = \ud835\udfd9 _ :=\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 \u27f6 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 \u2964 V :=\n{ obj := h.X, map := \u03bb 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 \u2964 V)\n  (hF : \u2200 i j, F.map (0 : i \u27f6 j) = 0) :\n  homological_complex V c :=\n{ X := F.obj,\n  d := \u03bb 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', \u2190 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 \u2964 { F : walking_complex c \u2964 V // \u2200 i j, F.map (0 : i \u27f6 j) = 0 } :=\n{ obj := \u03bb X, \u27e8complex_to_functor X, \u03bb _ _, rfl\u27e9, map := \u03bb X Y f, { app := f.f } }\n\n@[simps]\ndef functor_to_complex_functor :\n  { F : walking_complex c \u2964 V // \u2200 i j, F.map (0 : i \u27f6 j) = 0 } \u2964 homological_complex V c :=\n{ obj := \u03bb F, functor_to_complex F.1 F.2,\n  map := \u03bb 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  \ud835\udfed _ \u2245 complex_to_functor_functor V c \u22d9 functor_to_complex_functor V c :=\nnat_iso.of_components\n  (\u03bb X, hom.iso_of_components (\u03bb 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 \u22d9 complex_to_functor_functor V c \u2245 \ud835\udfed _ :=\nnat_iso.of_components\n  (\u03bb F, lift_iso $ nat_iso.of_components (\u03bb 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 \u224c { F : walking_complex c \u2964 V // \u2200 i j, F.map (0 : i \u27f6 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 \u2964 walking_complex c \u2964 V :=\ncomplex_to_functor_functor V c \u22d9 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 ` \u2218 `:80 g:80 := g \u226b 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 \u2192 b is a cofibration, then homotopy rel j is an\nequivalence relation. More generally, we will prove the\nfollowing. Suppose that G : Ia \u2192 x is a homotopy. In the diagram\n\n  f\u2080  - f\u2081\n  |\n  f\u2080' - f\u2081'\n\nsuppose that f\u2080 \u2243 f\u2080' rel j and that f\u2080 \u2243 f\u2081 and f\u2080' \u2243 f\u2081' via\nhomotopies that each restrict to G on a. Then f\u2081 \u2243 f\u2081' 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 \u27f6 b) (hj : is_cof j)\nparameters {x : C} {f\u2080 f\u2080' f\u2081 f\u2081' : b \u27f6 x}\nparameters {G : I.obj a \u27f6 x}\nparameters {H\u2080 : homotopy f\u2080 f\u2080'} (h\u2080 : H\u2080.is_rel j)\n\n-- Furthermore, we generalize over the direction of the homotopies\n-- between f\u2080 and f\u2081 and between f\u2080' and f\u2081'.\nparameters (\u03b5 : endpoint)\nparameters {H : homotopy_dir \u03b5 f\u2080 f\u2081} (h : H.H \u2218 I &> j = G)\nparameters {H' : homotopy_dir \u03b5 f\u2080' f\u2081'} (h' : H'.H \u2218 I &> j = G)\n-- Goal: construct a homotopy from f\u2081 to f\u2082 rel j.\n\n/-\n  a \u2294 a \u2192   Ia\n    \u2193       \u2193\n  b \u2294 b \u2192 b_Ia_b\n-/\n\ndef Po : pushout (\u2202I &> 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 &> (\u2202I &> j)) (I &> (ii @> a)) (I &> Po.map\u2080) (I &> Po.map\u2081) :=\nI_preserves_pushout_by_cof (cof_coprod hj hj) Po.is_pushout\n-- Moreover, I(a \u2294 a) = Ia \u2294 Ia and I(b \u2294 b) = Ib \u2294 Ib.\ndef Ia_Ia : Is_coproduct (I &> (i\u2080 : a \u27f6 a \u2294 a)) (I &> (i\u2081 : a \u27f6 a \u2294 a)) :=\nI_of_coprod_is_coproduct\ndef Ib_Ib : Is_coproduct (I &> (i\u2080 : b \u27f6 b \u2294 b)) (I &> (i\u2081 : b \u27f6 b \u2294 b)) :=\nI_of_coprod_is_coproduct\n-- Thus, we can \"glue\" the homotopies H and H' to form a map I(b \u2294 b) \u2192 X.\ndef HH' : I.obj (b \u2294 b) \u27f6 x :=\nIb_Ib.induced H.H H'.H\n-- Because the homotopies agree on a, the restriction of this map to I(a \u2294 a)\n-- extends to a map I(Ia) \u2192 X. Then we get an induced map on I(b \u2294\u2090 Ia \u2294\u2090 b).\ndef GIp : I.obj (I.obj a) \u27f6 x := G \u2218 I &> (p @> a)\n\ninclude h h'\ndef HH'' : I.obj b_Ia_b \u27f6 x :=\nIpo.induced HH' GIp $\n  -- This is a bit awful\n  begin\n    apply Ia_Ia.uniqueness;\n    rw [\u2190assoc, \u2190assoc, \u2190I.map_comp, \u2190I.map_comp];\n    change\n      _ \u2218 I &> (coprod_of_maps j j \u2218 _) =\n      _ \u2218 I &> (coprod.induced (i 0 @> a) (i 1 @> a) \u2218 _);\n    simp [HH', GIp]; rw h <|> rw h';\n    rw [\u2190assoc, \u2190I.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\u2080\nlemma HH''i\u03b5 : H\u2080.H \u2218 j' = HH'' \u2218 i \u03b5 @> _ :=\nhave t : \u2200 {z} (k : z \u27f6 _), H\u2080.H \u2218 j' \u2218 k = H\u2080.H \u2218 (j' \u2218 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 \u2190assoc, simp,\n      erw H\u2080.Hi\u2080 <|> erw H\u2080.Hi\u2081,\n      erw H.Hi\u03b5 <|> erw H'.Hi\u03b5 } },\n  { rw [i_nat_assoc, t], unfold j' GIp, simp,\n    erw [\u2190i_nat_assoc, \u2190h, \u2190i_nat_assoc, H.Hi\u03b5],\n    exact h\u2080 }\nend\nomit h\u2080\n\n-- Now we can apply the homotopy extension property of j'\nlemma Ex_E : \u2203 (E : I.obj (I.obj b) \u27f6 x),\n  E \u2218 i \u03b5 @> (I.obj b) = H\u2080.H \u2227 E \u2218 I &> j' = HH'' :=\nhep_cof j' (relative_cylinder j hj) \u03b5 _ _ _ HH''i\u03b5\n\nsection E\nparameters (E : I.obj (I.obj b) \u27f6 x)\n  (hE : E \u2218 i \u03b5 @> I.obj b = H\u2080.H \u2227 E \u2218 I &> j' = HH'')\n-- Now E \u2218 i \u03b5.v is supposed to be a homotopy from f\u2081 to f\u2081' rel j.\n\ninclude hE\nlemma Ei\u03b5vi_ :\n  E \u2218 i \u03b5.v @> I.obj b \u2218 i 0 @> b = f\u2081 \u2227\n  E \u2218 i \u03b5.v @> I.obj b \u2218 i 1 @> b = f\u2081' :=\nhave\n  i.{v} \u03b5.v @> I.obj b \u2218 i 0 @> b = I &> j' \u2218 I &> Po.map\u2080 \u2218 i \u03b5.v @> _ \u2218 i\u2080 \u2227\n  i.{v} \u03b5.v @> I.obj b \u2218 i 1 @> b = I &> j' \u2218 I &> Po.map\u2080 \u2218 i \u03b5.v @> _ \u2218 i\u2081, begin\n  split;\n  { rw \u2190I.map_comp, unfold j', simp, erw i_nat_assoc,\n    rw \u2190I.map_comp, dsimp [ii], simp,\n    apply (i _).naturality }\nend,\nbegin\n  split;\n  { rw \u2190assoc, 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\u03b5v <|> exact H'.Hi\u03b5v }\nend\n\ndef Ei\u03b5 : homotopy f\u2081 f\u2081' :=\n{ H := E \u2218 i \u03b5.v @> I.obj b, Hi\u2080 := Ei\u03b5vi_.1, Hi\u2081 := Ei\u03b5vi_.2 }\n\nlemma Ei\u03b5_is_rel : Ei\u03b5.is_rel j :=\nhave i \u03b5.v @> I.obj b \u2218 I &> j = I &> j' \u2218 I &> Po.map\u2081 \u2218 i \u03b5.v @> I.obj a, begin\n  rw \u2190I.map_comp, unfold j', simp,\n  rw \u2190(i \u03b5.v).naturality, refl\nend,\nbegin\n  dsimp [homotopy.is_rel, Ei\u03b5] { iota := tt },\n  rw [\u2190assoc, this], simp [hE.2, HH'', GIp],\n  rw [\u2190h, \u2190i_nat_assoc, \u2190i_nat_assoc, H.Hi\u03b5v]\nend\n\nend E\n\nlemma f\u2081_f\u2082 : f\u2081 \u2243 f\u2081' rel j :=\nlet \u27e8E, hE\u27e9 := Ex_E in \u27e8Ei\u03b5 E hE, Ei\u03b5_is_rel E hE\u27e9\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 \u27f6 b} (hj : is_cof j)\n\nlemma homotopic_rel.symm_trans {x : C} {f\u2080 f\u2081 f\u2082 : b \u27f6 x} :\n  f\u2080 \u2243 f\u2081 rel j \u2192 f\u2080 \u2243 f\u2082 rel j \u2192 f\u2081 \u2243 f\u2082 rel j :=\nassume \u27e8H\u2081, h\u2081\u27e9 \u27e8H\u2082, h\u2082\u27e9, equiv_private.f\u2081_f\u2082 j hj homotopy.refl_is_rel 0 h\u2081 h\u2082\n\nlemma homotopic_rel.symm {x : C} {f\u2080 f\u2081 : b \u27f6 x} (h : f\u2080 \u2243 f\u2081 rel j) : f\u2081 \u2243 f\u2080 rel j :=\nhomotopic_rel.symm_trans hj h (homotopic_rel.refl _)\n\nlemma homotopic_rel.trans {x : C} {f\u2080 f\u2081 f\u2082 : b \u27f6 x}\n  (h\u2081 : f\u2080 \u2243 f\u2081 rel j) (h\u2082 : f\u2081 \u2243 f\u2082 rel j) : f\u2080 \u2243 f\u2082 rel j :=\nhomotopic_rel.symm_trans hj (h\u2081.symm hj) h\u2082\n\nlemma homotopic_rel_is_equivalence {x : C} :\n  equivalence (homotopic_rel j : (b \u27f6 x) \u2192 (b \u27f6 x) \u2192 Prop) :=\n\u27e8homotopic_rel.refl,\n \u03bb f\u2080 f\u2081, homotopic_rel.symm hj,\n \u03bb f\u2080 f\u2081 f\u2082, homotopic_rel.trans hj\u27e9\n\n@[symm] lemma homotopic.symm {x : C} {f\u2080 f\u2081 : b \u27f6 x} (h : f\u2080 \u2243 f\u2081) : f\u2081 \u2243 f\u2080 :=\nbegin\n  rw \u2190(homotopic_rel_initial Ii_initial (! b)) at \u22a2 h,\n  exact homotopic_rel.symm (all_objects_cofibrant.cofibrant.{v} b) h,\nend\n\n@[trans] lemma homotopic.trans {x : C} {f\u2080 f\u2081 f\u2082 : b \u27f6 x} (h\u2081 : f\u2080 \u2243 f\u2081) (h\u2082 : f\u2081 \u2243 f\u2082) : f\u2080 \u2243 f\u2082 :=\nbegin\n  rw \u2190(homotopic_rel_initial Ii_initial (! b)) at \u22a2 h\u2081 h\u2082,\n  exact homotopic_rel.trans (all_objects_cofibrant.cofibrant.{v} b) h\u2081 h\u2082,\nend\n\nlemma homotopic_is_equivalence {x : C} :\n  equivalence (homotopic : (b \u27f6 x) \u2192 (b \u27f6 x) \u2192 Prop) :=\n\u27e8homotopic.refl, \u03bb f\u2080 f\u2081, homotopic.symm, \u03bb f\u2080 f\u2081 f\u2082, homotopic.trans\u27e9\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 {\u03b1:Type*} (s : set (set \u03b1)) : set \u03b1 \u2192 Prop\n| basic : \u2200 u, u\u2208 s \u2192 set.monotone_class u \n| inter : \u2200 f : \u2115 \u2192 set \u03b1, (\u2200 n, set.monotone_class (f n)) \u2192 \n                           (\u2200 (i:\u2115), f i.succ \u2286 f i) \u2192  \n                           set.monotone_class (set.Inter f)\n| union : \u2200 f : \u2115 \u2192 set \u03b1, (\u2200 n, set.monotone_class (f n)) \u2192\n                           monotone f \u2192\n                            set.monotone_class (set.Union f)\n\n--namespace measure_theory\n\nstructure set.is_algebra {\u03b1:Type*} (s:set (set \u03b1)) :=\n  (univ : set.univ \u2208 s)\n  (diff : \u2200 a b, a \u2208 s \u2192  b \u2208 s \u2192 (a \\ b) \u2208 s)\n\n\nlemma set.is_algebra.compl {\u03b1:Type*} {s:set (set \u03b1)} (A:s.is_algebra):\n  (\u2200 a, a\u2208 s \u2192 a\u1d9c \u2208 s) := begin\n  intros a h_a,\n  have h3:a\u1d9c = set.univ \\ a,\n  { ext \u03c9, 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 {\u03b1:Type*} {s:set (set \u03b1)} (A:s.is_algebra):\n  (\u2205 \u2208 s) := begin\n  rw \u2190 set.compl_univ,\n  apply A.compl,\n  apply A.univ,\nend\n\n\n\nlemma set.is_algebra.inter {\u03b1:Type*} {s:set (set \u03b1)} (A:s.is_algebra):\n  (\u2200 a b, a\u2208 s \u2192 b\u2208 s\u2192 a\u2229 b \u2208 s) := begin\n  intros a b h_a h_b,\n  have h3:a \u2229 b = a \\ b\u1d9c,\n  { ext \u03c9, 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 {\u03b1:Type*} {s : set (set \u03b1)} (A:s.is_algebra):\n  (\u2200 a b, a\u2208 s \u2192 b \u2208 s \u2192 a \u222a b \u2208 s) := begin\n  intros a b h_a h_b,\n  have h3:a \u222a b = (a\u1d9c \u2229 b\u1d9c)\u1d9c,\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 {\u03b1:Type*} (j_n:\u2115) (f:\u2115 \u2192 set \u03b1):\n  (\u22c3 (i : \u2115) (h : i \u2264 j_n.succ), f i) = (f j_n.succ) \u222a (\u22c3 (i : \u2115) (h : i \u2264 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 {\u03b1:Type*} {s : set (set \u03b1)} (A:s.is_algebra):\n  (\u2200 (f:\u2115 \u2192 (set \u03b1)), (\u2200 i, f i \u2208 s) \u2192 (\u2200 j, (\u22c3 (i:\u2115) (h:i \u2264 j), f i) \u2208 s)) := begin\n  intros f h3 j,\n  induction j,\n  { have h4:(\u22c3 (i : \u2115) (h : i \u2264 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 {\u03b1:Type*} {s : set (set \u03b1)} : \n  (\u2200 a \u2208 s, a\u1d9c \u2208 s) \u2192\n  (\u2200 (a:set \u03b1), s.monotone_class a \u2192 s.monotone_class a\u1d9c) := 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 \u03b1) _ (\u03bb (i : \u2115), (f i)\u1d9c),\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 {\u03b1:Type*} (a':set \u03b1) (f_b:\u2115 \u2192 set \u03b1):\n  a' \\ (set.Inter f_b) = set.Union (\u03bb i, a' \\ (f_b i)) :=\nbegin\n  ext \u03c9, split; intros h5_1; simp at h5_1; simp [h5_1],\nend\n\nlemma set.Inter_diff_distrib {\u03b1:Type*} (a':set \u03b1) (f_b:\u2115 \u2192 set \u03b1):\n  (set.Inter f_b) \\ a' = set.Inter (\u03bb i, (f_b i) \\ a') :=\nbegin\n  ext \u03c9, 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 {\u03b1:Type*} (a':set \u03b1) (f_b:\u2115 \u2192 set \u03b1):\n  a' \\ (set.Union f_b) = set.Inter (\u03bb i, a' \\ (f_b i)) :=\nbegin\n  ext \u03c9, split; intros h5_1; simp at h5_1; simp [h5_1],\n  apply (h5_1 0).left,\nend\n\nlemma set.Union_diff_distrib {\u03b1:Type*} (a':set \u03b1) (f_b:\u2115 \u2192 set \u03b1):\n  (set.Union f_b) \\ a' = set.Union (\u03bb i, (f_b i) \\ a') :=\nbegin\n  ext \u03c9, 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 {\u03b1:Type*} {s : set (set \u03b1)} : \n  (\u2200 a b, a\u2208 s \u2192 b \u2208 s \u2192 a \\ b \u2208 s) \u2192\n  (\u2200 (a b:set \u03b1), s.monotone_class a \u2192 s.monotone_class b \u2192\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 (\u03bb 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 \u03b1) _ (\u03bb (i : \u2115), 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 {\u03b1:Type*} {s : set (set \u03b1)} : \n  (set.univ \u2208 s) \u2192\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 {\u03b1:Type*} {s : set (set \u03b1)} (A:s.is_algebra):\n  set.is_algebra s.monotone_class := {\n  univ := @set.monotone_class.univ \u03b1 s (A.univ),\n  diff := @set.monotone_class.diff \u03b1 s (A.diff),\n}\n\nlemma set.monotone_class.pair_inter {\u03b1:Type*} {s : set (set \u03b1)} (A:s.is_algebra): \n  (\u2200 (a b:set \u03b1), s.monotone_class a \u2192 s.monotone_class b \u2192\n                  s.monotone_class (a \u2229 b)) := begin\n  have AM := A.monotone_class,\n  apply AM.inter,\nend\n\nlemma measurable_space.generate_measurable.inter {\u03b1:Type*} (s : set (set \u03b1)):\n \u2200 f : \u2115 \u2192 set \u03b1, (\u2200 n, measurable_space.generate_measurable s (f n)) \u2192 \n  measurable_space.generate_measurable s (\u22c2 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 {\u03b1:Type*} (s : set (set \u03b1)) (A:s.is_algebra):\n  (s.monotone_class = measurable_space.generate_measurable s) :=\nbegin\n  have h3:\u2200 a \u2208 s, a\u1d9c \u2208 s,\n  { apply  A.compl  },\n  have h4:\u2205 \u2208 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:\u2115 \u2192 set \u03b1 := \u03bb j, \u22c3 (i:\u2115) (h:i \u2264 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 \u03b1) _ 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 {\u03b1:Type*} (S:set (set \u03b1)):set (set \u03b1) :=\n  {s|\u2203 (m:\u2115) (f:fin m \u2192 set \u03b1), (\u2200 i, f i \u2208 S) \u2227 (pairwise (disjoint on f)) \u2227 (s=(\u22c3 i, f i)) }\n\nlemma set.mem_disjoint_union_closure_iff {\u03b1:Type*} (S:set (set \u03b1)) (s:set \u03b1):\n  s \u2208 S.disjoint_union_closure \u2194 \n  (\u2203 (m:\u2115) (f:fin m \u2192 set \u03b1), (\u2200 i, f i \u2208 S) \u2227 (pairwise (disjoint on f)) \u2227 (s=(\u22c3 i, f i))) := begin\n  unfold set.disjoint_union_closure,\n  simp,\nend\n\nlemma set.disjoint_union_closure_intro {\u03b1 \u03b2:Type*} [fintype \u03b2] (S:set (set \u03b1)) (f:\u03b2 \u2192 set \u03b1):\n  (\u2200 b, f b \u2208 S) \u2192\n  (pairwise (disjoint on f)) \u2192\n  (set.Union f) \u2208 S.disjoint_union_closure := begin\n  classical,\n  intros h1 h2,\n  simp [set.disjoint_union_closure],\n  have h3:=fintype.exists_equiv_fin \u03b2,\n  cases h3 with n h3,\n  apply exists.intro n,\n  let g := classical.choice h3,\n  let h:fin n \u2192 set \u03b1 := f \u2218 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 \u2260 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 \u03c9, 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 {\u03b1:Type*} (S:set (set \u03b1)) (s:set \u03b1):\n  (s \u2208 S) \u2192\n  (s\u2208 S.disjoint_union_closure) := begin\n  let f:unit \u2192 (set \u03b1) := (\u03bb _, 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 \u2190 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 {\u03b1:Type*} (s:set (set \u03b1)) :=\n  (univ : set.univ \u2208 s)\n  (empty : \u2205 \u2208 s)\n  (inter : \u2200 (a b:set \u03b1), a \u2208 s \u2192 b \u2208 s \u2192 a \u2229 b \u2208 s) \n  (compl : \u2200 (b:set \u03b1), b \u2208 s \u2192 b\u1d9c \u2208 s.disjoint_union_closure)\n\n\nlemma set.disjoint_union_closure_inter {\u03b1:Type*} (S:set (set \u03b1)):\n  (\u2200 (s t:set \u03b1), s \u2208 S \u2192 t \u2208 S \u2192 s \u2229 t \u2208 S) \u2192\n  (\u2200 (s t:set \u03b1), s \u2208 S.disjoint_union_closure \u2192\n   t \u2208 S.disjoint_union_closure \u2192 (s\u2229 t) \u2208 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 \u00d7 fin m_t) \u2192 set \u03b1 := (\u03bb p, f_s p.fst \u2229 f_t p.snd),\n  begin\n    have h4:set.Union f_s \u2229 set.Union f_t  = set.Union f,\n    { ext \u03c9, 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 \u2190 set.subset_empty_iff,\n     have h_ne_alt:i.fst \u2260 j.fst \u2228 i.snd \u2260 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 {\u03b1:Type*} (S:set (set \u03b1)):\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n   (set.univ \u2208 S.disjoint_union_closure) := begin\n  intros h1 h2,\n  rw \u2190 set.compl_empty,\n  apply h1,\n  apply h2,\nend\n\nlemma set.disjoint_union_closure_finite_Inter_finset {\u03b1 \u03b2:Type*} (S:set (set \u03b1))\n  {f:\u03b2 \u2192 set \u03b1} (T:finset \u03b2):\n  (\u2200 (s t:set \u03b1), s \u2208 S \u2192 t \u2208 S \u2192 s \u2229 t \u2208 S) \u2192\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n  (\u2200 (b:\u03b2), (f b) \u2208 S.disjoint_union_closure) \u2192\n   ((\u22c2 i \u2208 T, f i) \u2208 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 {\u03b1 \u03b2:Type*} [fintype \u03b2] (S:set (set \u03b1))\n  {f:\u03b2 \u2192 set \u03b1}:\n  (\u2200 (s t:set \u03b1), s \u2208 S \u2192 t \u2208 S \u2192 s \u2229 t \u2208 S) \u2192\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n  (\u2200 (b:\u03b2), (f b) \u2208 S.disjoint_union_closure) \u2192\n   ((\u22c2 i, f i) \u2208 S.disjoint_union_closure) := begin\n  intros h1 h2 h3 h4,\n  have h5:(\u22c2 i, f i) = (\u22c2 i \u2208 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 \u03b1 \u03b2 S f finset.univ\n    h1 h2 h3 h4,\nend\n\nlemma set.disjoint_union_closure_compl {\u03b1:Type*}  (S:set (set \u03b1)):\n  (\u2200 (s t:set \u03b1), s \u2208 S \u2192 t \u2208 S \u2192 s \u2229 t \u2208 S) \u2192\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n  (\u2200 s \u2208 S.disjoint_union_closure, s\u1d9c \u2208 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 {\u03b1:Type*}  (S:set (set \u03b1)):\n  (\u2200 (s t:set \u03b1), s \u2208 S \u2192 t \u2208 S \u2192 s \u2229 t \u2208 S) \u2192\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n  (\u2200 s t, s \u2208 S.disjoint_union_closure \u2192 t \u2208 S.disjoint_union_closure \u2192 \n   (s \\ t) \u2208 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 {\u03b1:Type*} {S:set (set \u03b1)} (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 {\u03b1 \u03b2:Type*} (S:set (set \u03b1)) \n  [E:encodable \u03b2] (f:\u03b2 \u2192 (set \u03b1)):\n  (\u2200 (b:\u03b2), f b \u2208 S) \u2192\n  (pairwise (disjoint on f)) \u2192\n  (\u2205 \u2208 S) \u2192 \n  (\u2203 (g:\u2115 \u2192 (set \u03b1)), (set.Union f = set.Union g) \u2227 (pairwise (disjoint on g)) \n   \u2227 (\u2200 i, g i \u2208 S)) := begin\n  intros h1 h2 h3,\n  let g:\u2115 \u2192 set \u03b1 := \u03bb (n:\u2115), (option.map f (encodable.decode2 \u03b2 n)).get_or_else \u2205,\n  begin\n    apply exists.intro g,\n    split,\n    ext1 \u03c9, 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 \u03b2 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 \u03b2 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 \u03b2 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 \u2260 j_val,\n      { intros contra, apply h_ne,\n        have h_partial:=@encodable.decode2_is_partial_inv \u03b2 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 \u2190 h_i,\n        rw \u2190 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 \u03b2 i),\n    repeat {simp [option.map, option.get_or_else, h3, h1]},\n  end\nend \n\n\nlemma measurable_space.closure_union_Union {\u03b1:Type*} (S:set (set \u03b1)) (f:\u2115 \u2192 (set \u03b1)):\n  (\u2200 i, f i \u2208 S.disjoint_union_closure) \u2192\n  (pairwise (disjoint on f)) \u2192\n  (\u2205 \u2208 S) \u2192  \n  (\u2203 (g:\u2115 \u2192 (set \u03b1)), (set.Union f = set.Union g) \u2227 (pairwise (disjoint on g))\n    \u2227 (\u2200 i, g i \u2208 S)) := begin\n  intros h1 h0,\n  have h2 := (\u03bb 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'':(\u03a3 (i:\u2115), fin (m i)) \u2192 set \u03b1 := \u03bb 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 \u2190 h4,\n    have h6:\u2200 i, \u2200 (j:fin (m i)), f'' (sigma.mk i j) \u2286 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 \u2260 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 \u2190 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 {\u03b1:Type*} (S:set (set \u03b1)) \n  (f:\u2115 \u2192 (set \u03b1)) (j:\u2115):\n  (\u2200 s t\u2208 S, s \u2229 t \u2208 S) \u2192\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n  (\u2200 i, f i \u2208 S.disjoint_union_closure) \u2192\n  ((\u22c2 (i_1 : \u2115) (H : i_1 < j), f i_1) \u2208 S.disjoint_union_closure) := begin\n  intros h1 h2 h3 h4,\n  induction j,\n  { simp, rw \u2190 set.compl_empty, apply h2, apply h3 },\n  { have h5:(\u22c2 (i_1 : \u2115) (H : i_1 < j_n.succ), f i_1) = \n    (f j_n) \u2229 (\u22c2 (i_1 : \u2115) (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 \u2190 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 {\u03b1:Type*} (S:set (set \u03b1)) (f:\u2115 \u2192 (set \u03b1)):\n  (\u2200 s t\u2208 S, s \u2229 t \u2208 S) \u2192\n  (\u2200 s \u2208 S, s\u1d9c \u2208 S.disjoint_union_closure) \u2192  \n  (\u2205 \u2208 S) \u2192\n  (\u2200 i, f i \u2208 S) \u2192\n  (\u2203 (g:\u2115 \u2192 (set \u03b1)), (set.Union f = set.Union g) \u2227 (pairwise (disjoint on g))\n    \u2227 (\u2200 i, g i \u2208 S)) := begin\n  intros h1 h2 h3 h4,\n  have h5:\u2203 f':\u2115 \u2192 set \u03b1, (set.Union f = set.Union f') \u2227 (\u2200 i, f' i \u2208 S.disjoint_union_closure) \u2227\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 tactic --hide\n\n/-Lemma\nFor any logical statement $P$, $(\\mathrm{true} \\implies \\mathrm{false})$ implies $P$. \n-/\nlemma true_to_false_imp_P (P : Prop) : (true \u2192 false) \u2192 P :=\nbegin\n intro h,\n exfalso,\n apply h,\n triv,\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/true_false/tf10.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8289388083214158, "lm_q2_score": 0.5544704649604273, "lm_q1q2_score": 0.4596220864737179}}
{"text": "import ..mcrl2_encap.mcrl2_encap\n\nopen mcrl2\n\nvariable {\u03b1 : Type}\nvariable [comm_semigroup_with_zero \u03b1]\nvariable {\u03b2 : Type}\n\n/- The relation used to prove congruence of the summation operator.-/\ninductive R_sum {f g} {D : set \u03b2} (R_\u03b1 : \u2200a, a \u2208 D \u2192 mcrl2 \u03b1 \u2192 mcrl2 \u03b1 \u2192 Prop) : \nmcrl2 \u03b1 \u2192 mcrl2 \u03b1 \u2192 Prop \n| R {x y a} {ha} (h : R_\u03b1 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\u2081 : R_sum (sum D f) (sum D g)) (h\u2081 : R_sum (sum D g) (sum D f))\n  (h\u2082: d \u2208 D) :\n  R_sum (f d) (g d)\n| stepr {d} \n  (h\u2081 : R_sum (sum D f) (sum D g)) (h\u2081 : R_sum (sum D g) (sum D f)) \n  (h\u2082: d \u2208 D) :\n  R_sum (g d) (f d)\n\nlemma R_sum.symm {f g} {D : set \u03b2} (R_\u03b1 : \u2200a, a \u2208 D \u2192 mcrl2 \u03b1 \u2192 mcrl2 \u03b1 \u2192 Prop) \n  (R_\u03b1_symm : \u2200a ha, symmetric (R_\u03b1 a ha)) :\nsymmetric (@R_sum \u03b1 _ \u03b2 f g D R_\u03b1) :=\nbegin\n  intros x y h,\n  cases h,\n  { apply R_sum.R,\n    apply R_\u03b1_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 : \u03b2 \u2192 mcrl2 \u03b1} {D} (h : \u2200a, a \u2208 D \u2192 f a \u2248 g a) :\nsum D f \u2248 sum D g :=\nbegin\n  choose R R\u2081x 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\u2081 h\u2082, \n    cases h\u2081,\n    { have h : (\u2203y', transition y a y' \u2227 option.rel (R h\u2081_a h\u2081_ha) x' y'),\n      by exact bisim_lift (R_bisim h\u2081_a h\u2081_ha) h\u2081_h h\u2082,\n      rcases h with \u27e8w, haw, hRw\u27e9,\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\u2082,\n      simp [transition.sum_iff, \u2190exists_and_distrib_right, and_assoc],\n      have h : (\u2203y', transition (g h\u2082_a') a y' \u2227 option.rel (R h\u2082_a' h\u2082_ha') x' y'),\n      by exact bisim_lift (R_bisim h\u2082_a' h\u2082_ha') (R\u2081x h\u2082_a' h\u2082_ha') h\u2082_h,\n      rcases h with \u27e8w, haw, hRw\u27e9,\n      apply exists.intro w,\n      apply exists.intro h\u2082_a',\n      apply and.intro h\u2082_ha',\n      apply and.intro haw,\n      apply option.rel.mono _ hRw,\n      intros x y,\n      exact R_sum.R},\n    { cases h\u2082,\n      simp [transition.sum_iff, \u2190exists_and_distrib_right, and_assoc],\n      have h : (\u2203y', transition (f h\u2082_a') a y' \u2227 option.rel (R h\u2082_a' h\u2082_ha') x' y'),\n      by exact bisim_lift (R_bisim h\u2082_a' h\u2082_ha') ((R_bisim h\u2082_a' h\u2082_ha').right (R\u2081x h\u2082_a' h\u2082_ha')) h\u2082_h,\n      rcases h with \u27e8w, haw, hRw\u27e9,\n      apply exists.intro w,\n      apply exists.intro h\u2082_a',\n      apply and.intro h\u2082_ha',\n      apply and.intro haw,\n      apply option.rel.mono _ hRw,\n      intros x y,\n      exact R_sum.R},\n    { have h : (\u2203y', transition (g h\u2081_d) a y' \u2227 option.rel (R h\u2081_d h\u2081_h\u2082) x' y'),\n      by exact bisim_lift (R_bisim h\u2081_d h\u2081_h\u2082) (R\u2081x h\u2081_d h\u2081_h\u2082) h\u2082,\n      rcases h with \u27e8w, haw, hRw\u27e9,\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 : (\u2203y', transition (f h\u2081_d) a y' \u2227 option.rel (R h\u2081_d h\u2081_h\u2082) x' y'),\n      by exact bisim_lift (R_bisim h\u2081_d h\u2081_h\u2082) ((R_bisim h\u2081_d h\u2081_h\u2082).right (R\u2081x h\u2081_d h\u2081_h\u2082)) h\u2082,\n      rcases h with \u27e8w, haw, hRw\u27e9,\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 \u2260 q \u2192 R a p q \u2192 R b p q \u2192 col p a b :=\n\u03bb h, not_3dim (seven12b h.symm).symm (seven5 p q).2\n\ntheorem coplanar {a : point} (b : point) {A : set point} : line A \u2192 a \u2209 A \u2192 b \u2208 pl A a :=\nbegin\nintros h h1,\ncases exists_of_exists_unique (eight17 h h1) with p hp,\nby_cases h2 : b \u2208 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 \u27e8h, (nine11 hc.2).2.1, h1, p, hp.2.2.1, h_1\u27e9,\n  apply or.inl (hc.2.symm.trans _),\n  exact nine12 h hp.2.2.1 (six4.2 \u27e8(four11 this).2.2.2.1, h_1\u27e9) (nine11 hc.2).2.1,\nrcases six22 h hp.2.2.1 with \u27e8q, h3, h4\u27e9,\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 \u27e8p, hp\u27e9 (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) := \u27e8P1, P2, P3, six24, rfl\u27e9\n\ntheorem in_Pl {a : point} : a \u2208 (Pl : set point) :=\ncoplanar a (six14 (six26 six24).1) six24\n\ntheorem unique_plane {Q : set point} : plane Q \u2192 Q = Pl :=\nbegin\nrintros \u27e8x, y, z, h, h1\u27e9,\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 \u2192 \u2203! A : set point, a \u2208 A \u2227 perp L A :=\nbegin\nintro h,\nby_cases h_1 : a \u2208 L,\n  rcases six22 h h_1 with \u27e8b, h1, hb\u27e9,\n  subst hb,\n  rcases eight21 h1 a with \u27e8p, t, hp, ht\u27e9,\n  clear ht,\n  replace hp := eight15 hp (six17a a b) (six17b p a),\n  refine exists_unique.intro (l p a) \u27e8six17b p a, a, hp\u27e9 _,\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 \u27e8z, hz, h5\u27e9,\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 \u27e8l a x, \u27e8(six17a a x), x, hx.1\u27e9, _\u27e9,\nrintros Y \u27e8h1, y, h2\u27e9,\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 \u2192 a \u2208 L \u2192 \u2203! A : set point, xperp a L A :=\nbegin\nintros h h1,\nrcases (unique_perp a h) with \u27e8A, h2, h3\u27e9,\nexact \u27e8A, eight15 h2.2 h1 h2.1, \u03bb Y hy, h3 Y \u27e8hy.2.2.2.1, a, hy\u27e9\u27e9\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 \u2228 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 \u27e8h.2.1, h.2.2.2.1, five2 h.1 h_2 (eleven21b h_2 h)\u27e9,\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 \u27e8d, h_2, (ten14 h1 h_2.2.2.1).symm\u27e9,\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 \u2227 line B \u2227 \u00ac\u2203 x, x \u2208 A \u2227 x \u2208 B\n\ndef par (A B : set point) : Prop := dpar A B \u2228 line A \u2227 A = B\n\ntheorem dpar_of_par_neq {A B : set point} : par A B \u2192 A \u2260 B \u2192 dpar A B :=\n\u03bb h h1, h.elim id (\u03bb h_1, absurd h_1.2 h1)\n\ntheorem line_of_par {A B : set point} : par A B \u2192 line A \u2227 line B :=\n\u03bb h, h.elim (\u03bb h, \u27e8h.1, h.2.1\u27e9) (\u03bb h, \u27e8h.1, h.2 \u25b8 h.1\u27e9)\n\ntheorem not_par_of_perp {A B : set point} : perp A B \u2192 \u00acpar A B :=\nbegin\nintro h,\ncases h with x hx,\nintro h_1,\ncases h_1,\n  exact h_1.2.2 \u27e8x, hx.2.2.1, hx.2.2.2.1\u27e9,\nexact (eight14b hx) h_1.2\nend\n\ntheorem is_iff_not_par {A B : set point} : (\u2203 x, is x A B) \u2194 line A \u2227 line B \u2227 \u00acpar A B :=\nbegin\nsplit,\n  intro h,\n  cases h with x hx,\n  refine \u27e8hx.1, hx.2.1, _\u27e9,\n  intro h_1,\n  cases h_1,\n    exact h_1.2.2 \u27e8x, hx.2.2.2.1, hx.2.2.2.2\u27e9,\n  exact hx.2.2.1 h_1.2,\nrintro \u27e8h, h1, h2\u27e9,\nrw [par, not_or_distrib] at h2,\nhave h3 : \u2203 x, x \u2208 A \u2227 x \u2208 B,\n  by_contradiction h_1,\n  exact h2.1 \u27e8h, h1, h_1\u27e9,\ncases h3 with x hx,\nrefine \u27e8x, h, h1, _, hx.1, hx.2\u27e9,\nintro h_1,\nsubst B,\nexact h2.2 \u27e8h1, rfl\u27e9\nend\n\ntheorem twelve1 {A B : set point} : dpar A B \u2192 A \u2260 B :=\nbegin\nintros h h1,\nrcases h.1 with \u27e8x, y, h2, h3\u27e9,\nsubst_vars,\nexact h.2.2 \u27e8x, six17a x y, six17a x y\u27e9\nend\n\ntheorem twelve2 {A B : set point} {a : point} : dpar A B \u2192 a \u2208 A \u2192 a \u2209 B :=\n\u03bb h h1 h2, h.2.2 \u27e8a, h1, h2\u27e9\n\ntheorem twelve3 {a b c : point} : par (l a b) (l a c) \u2192 col a b c :=\nbegin\nintro h,\ncases h,\n  exact (h.2.2 \u27e8a, six17a a b, six17a a c\u27e9).elim,\nchange c \u2208 l a b,\nsimp [h.2]\nend\n\ntheorem par.refl {A : set point} : line A \u2192 par A A :=\n\u03bb h, or.inr \u27e8h, rfl\u27e9\n\ntheorem dpar.symm {A B : set point} : dpar A B \u2192 dpar B A :=\n\u03bb h, \u27e8h.2.1, h.1, \u03bb \u27e8x, hx\u27e9, h.2.2 \u27e8x, hx.symm\u27e9\u27e9\n\ntheorem par.symm {A B : set point} : par A B \u2192 par B A :=\n\u03bb h, h.elim (\u03bb h, or.inl h.symm) (\u03bb h, or.inr \u27e8h.2 \u25b8 h.1, h.2.symm\u27e9)\n\ntheorem twelve5 {A B : set point} {x : point} : par A B \u2192 x \u2208 A \u2192 x \u2208 B \u2192 A = B :=\n\u03bb h h1 h2, h.elim (\u03bb h, (h.2.2 \u27e8x, h1, h2\u27e9).elim) (and.right)\n\ntheorem twelve6 {A B : set point} : dpar A B \u2192 \u2200 {b b'}, b \u2208 B \u2192 b' \u2208 B \u2192 side A b b' :=\nbegin\nintros h b b' h1 h2,\nhave h3 : b \u2209 A,\n  intro h_1,\n  exact h.2.2 \u27e8b, h_1, h1\u27e9,\ncases coplanar b' h.1 h3,\n  exact h_1.symm,\ncases h_1,\n  exact (h.2.2 \u27e8b', h_1, h2\u27e9).elim,\ncases h_1.2.2.2 with x hx,\napply (h.2.2 \u27e8x, hx.1, _\u27e9).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) \u2194 side (l a b) c d \u2227 \u00ac\u2203 x, col a b x \u2227 col c d x :=\nbegin\nsplit,\n  intro h,\n  refine \u27e8twelve6 h (six17a c d) (six17b c d), _\u27e9,\n  rintros \u27e8x, hx\u27e9,\n  exact h.2.2 \u27e8x, hx.1, hx.2\u27e9,\nrintros \u27e8h, h1\u27e9,\nhave h2 := six13 (nine11 h).1,\nhave h3 : c \u2260 d,\n  intro h_1,\n  subst d,\n  exact h1 \u27e8b, or.inl (three1 a b), or.inl (three3 c b)\u27e9,\nrefine \u27e8six14 h2, six14 h3, \u03bb h_1, _\u27e9,\ncases h_1 with x hx,\nexact h1 \u27e8x, hx.1, hx.2\u27e9\nend\n\ntheorem twelve9 {A B C : set point} : perp A C \u2192 perp B C \u2192 par A B :=\nbegin\nintros h h1,\nby_cases h_1 : A = B,\n  exact or.inr \u27e8(eight14e h).1, h_1\u27e9,\nrefine or.inl \u27e8(eight14e h).1, (eight14e h1).1, \u03bb h_2, _\u27e9,\ncases h_2 with x hx,\napply h_1,\nexact unique_of_exists_unique (unique_perp x (eight14e h1).2) \u27e8hx.1, h.symm\u27e9 \u27e8hx.2, h1.symm\u27e9\nend\n\ntheorem twelve10 {A : set point} {a : point} : line A \u2192 \u2203 B, par A B \u2227 a \u2208 B :=\nbegin\nintro h,\nby_cases h1 : a \u2208 A,\n  exact \u27e8A, or.inr \u27e8h, rfl\u27e9, h1\u27e9,\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 \u27e8B, twelve9 hc.2 hb.2.symm, hb.1\u27e9\nend\n\ntheorem twelve11 {A B C : set point} {a : point} : line A \u2192 a \u2209 A \u2192 par A B \u2192 a \u2208 B \u2192 par A C \u2192 a \u2208 C \u2192 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 \u25b8 h3)).elim,\nreplace h4 : dpar A C,\n  apply h4.elim (id),\n  intro h_2,\n  exact (h1 (h_2.2.symm \u25b8 h5)).elim,\nby_contradiction h_1,\nrcases h with \u27e8s, t, h, h6\u27e9,\nsubst h6,\nsuffices : \u2203 c', c' \u2208 C \u2227 Bl t B c',\n  rcases this with \u27e8c', hc1, hc2\u27e9,\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 \u2260 b,\n    intro h_2,\n    subst b,\n    suffices : c' \u2260 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 \u2208 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 \u2260 d,\n    rcases euclids hd.1 hd.2 this with \u27e8\u27e8x, y\u27e9, hx, hy, ht\u27e9,\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 \u27e8S a x, (seven24 (six14 hx.1) (six17a a x)).1 (six17b a x), _\u27e9,\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 \u27e8x, six17b a x, h_2\u27e9\nend\n\ntheorem twelve13 {A : set point} (a : point) : line A \u2192 \u2203! B, par A B \u2227 a \u2208 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 \u2208 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 \u2192 par B C \u2192 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 : \u2203 x, x \u2208 A \u2227 x \u2208 C,\n      by_contradiction h_1,\n      exact h2 \u27e8h.1, h1.2.1, h_1\u27e9,\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 \u2192 M b p d \u2192 a \u2260 b \u2192 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 \u27e8six14 h2, six18 (six14 h2) (two7 (seven13 p a b) h2) _ _\u27e9;\n  apply (seven24 (six14 h2) h3).1;\n  simp,\nrefine or.inl \u27e8six14 h2, six14 (two7 (seven13 p a b) h2), _\u27e9,\nintro h_1,\nrcases h_1 with \u27e8x, hx1, hx2\u27e9,\nhave h4 : x \u2260 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 [\u2190seven7 p a, \u2190seven7 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 \u2260 b \u2192 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 \u2192 eqd b c d a \u2192 \u00accol a b c \u2192 b \u2260 d \u2192 col a p c \u2192 \ncol b p d \u2192 par (l a b) (l c d) \u2227 par (l b c) (l d a) \u2227 Bl b (l a c) d \u2227 Bl a (l b d) c :=\nbegin\nintros h h1 h2 h3 h4 h5,\nhave h6 := seven21 h2 h3 h h1 h4 h5,\nrefine \u27e8twelve17 h6.1 h6.2 (six26 h2).1, twelve17 h6.2 h6.1.symm (six26 h2).2.1, _\u27e9,\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 \u2208 l b d,\n  exact h2 (six23.2 \u27e8l b d, six14 h3, h_1, six17a b d, this\u27e9),\nrw seven6 h6.1,\nexact (seven24 (six14 h3) (four11 h5).1).1 h_1\nend\n\ntheorem twelve19 {a b c d : point} : \u00accol a b c \u2192 par (l a b) (l c d) \u2192 par (l b c) (l d a) \u2192 \neqd a b c d \u2227 eqd b c d a \u2227 Bl b (l a c) d \u2227 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 \u2190hp,\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 \u27e8seven13 p a b, h3, h4.2.2.1, h4.2.2.2\u27e9,\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) \u2192 eqd a b c d \u2192 Bl b (l a c) d \u2192 \npar (l b c) (l d a) \u2227 eqd b c d a \u2227 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 \u2190hp,\n  exact (mid_to_Sa b d).symm,\nsubst d,\nhave h3 : p \u2209 l a b,\n  intro h_1,\n  suffices : a \u2208 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 (\u03bb 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 \u27e8h4, h5.2.1, h5.2.2.2\u27e9,\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 \u27e8(four11 (twelve3 h6)).2.1, _\u27e9) (h1.symm.flip.trans (seven13 p a b).flip),\nintro h_1,\nhave h7 : p \u2209 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 [\u2190seven7 p a, \u2190seven7 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 [\u2190seven7 p a, \u2190seven7 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 \u2192 (par (l a b) (l c d) \u2194 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 \u27e8hd.2.symm.flip, eqd_refl a c, (twelve20 h1 hd.2.symm h).2.1\u27e9,\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 \u2192 side (l p a) b d \u2192 (par (l a b) (l c d) \u2194 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 \u2190hp,\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) \u25b8 ((nine8 (nine1 (nine11 h1).1 (or.inr (or.inl (seven5 q a).1)) (nine11 h1).2.1)).2 h1).symm,\nexact \u27e8\u03bb h5, h2.trans ((twelve21 h4).1 (h3.symm.trans h5)), \u03bb h5, h3.trans ((twelve21 h4).2 (h2.symm.trans h5))\u27e9\nend\n\ntheorem twelve23 {a b c : point} : \u00accol a b c \u2192 \u2203 b' c', Bl b (l a c) b' \u2227 Bl c (l a b) c' \u2227 \nB b' a c' \u2227 eqa a b c b a c' \u2227 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 \u27e8S (mid a c) b, S (mid a b) c, h1, h2, _, h3, h4\u27e9,\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 \u25b8 ((twelve21 h1).2 h4.flip),\nexact ((nine18 h2.1 (six17a a b) (four11 h5).2.2.1).1 ((nine8 h2).2 (nine15 (\u03bb h_1, h (mid_to_Sa a c\n \u25b8 (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 \u2192 col o u v \u2192 o \u2260 u \u2192 o \u2260 v \u2192 R o u p \u2192 R o v q \u2192 \n(sided o p q \u2194 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 \u2260 v,\n  intro h_1,\n  subst q,\n  exact h_1 (six23.2 \u27e8l o v, six14 h3, six17a o v, (four11 h1).1, (four11 h).1\u27e9),\nhave h7 : xperp u (l o u) (l p u),\n  exact eight13.2 \u27e8six14 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\u27e9,\nhave h8 : xperp v (l o u) (l q v),\n  exact eight13.2 \u27e8six14 h2, six14 h6, h1, six17b q v, o, q, six17a o u, six17a q v, h3, h6, h5\u27e9,\ncases exists_of_exists_unique (unique_perp o (six14 h2)) with L hl,\nreplace h7 := twelve9 hl.2.symm \u27e8u, h7.symm\u27e9,\nreplace h8 := twelve9 hl.2.symm \u27e8v, h8.symm\u27e9,\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 \u2192 xperp x (l b c) (l a x) \u2192 xperp y (l e f) (l d y) \u2192 sided b c x \u2192 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 \u27e8p, q, h3\u27e9,\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 \u2208 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 \u2192 xperp x (l b c) (l a x) \u2192 xperp y (l e f) (l d y) \u2192 (sided b c x \u2194 sided e f y) :=\n\u03bb h h1 h2, \u27e8twelve24a h h1 h2, twelve24a h.symm h2 h1\u27e9\n\ntheorem twelve25 {A B C : set point} : par A B \u2192 perp A C \u2192 perp B C :=\nbegin\nintros h h1,\nhave h2 : \u00acpar B C,\n  intro h_1,\n  exact (not_par_of_perp h1) (h.trans h_1),\ncases is_iff_not_par.2 \u27e8(line_of_par h).2, (eight14e h1).2, h2\u27e9 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) \u27e8h, hx.2.2.2.1\u27e9,\nexact \u27e8twelve9 h1 hl.2.symm, hl.1\u27e9\nend\n\n-- distance + angle interface\n\ninstance eqd_setoid : setoid (point \u00d7 point) :=\n{ r := \u03bb a b, eqd a.1 a.2 b.1 b.2,\n  iseqv := \u27e8 \u03bb \u27e8a,b\u27e9, eqd.refl a b, \u03bb \u27e8a,b\u27e9 \u27e8c,d\u27e9, eqd.symm, \u03bb \u27e8a,b\u27e9 \u27e8c,d\u27e9 \u27e8e,f\u27e9, eqd.trans\u27e9\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 := \u03bb a b, quotient.lift_on\u2082 a b (\u03bb x y, distle x.1 x.2 y.1 y.2) (\u03bb a b c d h h1,\n    begin rw \u2190iff_iff_eq, split; intro h2, exact five6 h2 h h1, exact five6 h2 h.symm h1.symm end),\n  le_refl := \u03bb a, quotient.induction_on a $ \u03bb x, distle.refl x.1 x.2,\n  le_trans := \u03bb a b c, quotient.induction_on\u2083 a b c $ \u03bb x y z, distle.trans,\n  le_antisymm := \u03bb a b, quotient.induction_on\u2082 a b $\n    \u03bb x y h h1, quotient.sound (five9 h h1),\n  le_total := \u03bb a b, quotient.induction_on\u2082 a b $\n    \u03bb x y, five10 x.1 x.2 y.1 y.2 }\n\ninstance zero_dist : has_zero (dist point) := \u27e8\u27e6(P1, P1)\u27e7\u27e9\n\n@[simp] theorem zero_dist_def : \u27e6(P1, P1)\u27e7 = (0 : dist point) := rfl\n\n@[simp] theorem zero_class (a : point) : \u27e6(a, a)\u27e7 = (0 : dist point) :=\nquotient.sound (two8 a P1)\n\ntheorem eq_of_zero_dist {a b  : point} : \u27e6(a, b)\u27e7 = (0 : dist point) \u2192 a = b :=\n\u03bb h, id_eqd (quotient.exact (h.trans zero_dist_def.symm))\n\ntheorem non_zero_dist_of_neq {a b : point} : a \u2260 b \u2192 \u27e6(a, b)\u27e7 \u2260 (0 : dist point) :=\n\u03bb h h1, h (id_eqd (quotient.exact h1))\n\ndef seg_cons_dist {a b : point} (hab : a \u2260 b) (D : dist point) : {x // B a b x \u2227 quotient.mk (b, x) = D} :=\n\u27e8quotient.lift_on D (\u03bb x : point \u00d7 point, (seg_cons b x.1 x.2 a).1) \n(begin\nrintros \u27e8x, y\u27e9 \u27e8p, q\u27e9 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 \u27e8x, y\u27e9,\nexact \u27e8(seg_cons b x y a).2.1, quotient.sound (seg_cons b x y a).2.2\u27e9 end\u27e9\n\ndef sided_seg_cons {a b : point} {C : dist point} : a \u2260 b \u2192 C \u2260 0 \u2192 {x // sided b a x \u2227 \u27e6(b, x)\u27e7 = C} :=\nbegin\nintros h h1,\ncases three14 a b with d hd,\ncases seg_cons_dist hd.2.symm C with x hx,\nrefine \u27e8x, (six2 h _ hd.2.symm hd.1).1 hx.1.symm, hx.2\u27e9,\nintro h_1,\nsubst x,\napply h1.symm,\nsimpa using hx.2\nend\n\ndef set_angle (point : Type) := {x : point \u00d7 point \u00d7 point // x.1 \u2260 x.2.1 \u2227 x.2.2 \u2260 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 := \u27e8 \u03bb x, eqa.refl x.2.1 x.2.2, \u03bb x y, eqa.symm, \u03bb x y z, eqa.trans\u27e9\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 := \u03bb \u03b1 \u03b2, quotient.lift_on\u2082 \u03b1 \u03b2 (\u03bb 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) (\u03bb a b c d h h1, \n    begin rw \u2190iff_iff_eq, split; intro h2, exact eleven30 h2 h h1, exact eleven30 h2 h.symm h1.symm end),\n  le_refl := \u03bb \u03b1, quotient.induction_on \u03b1 $ \u03bb x, ang_le.refl x.2.1 x.2.2,\n  le_trans := \u03bb \u03b1 \u03b2 \u03b3, quotient.induction_on\u2083 \u03b1 \u03b2 \u03b3 $ \u03bb x y z, ang_le.trans,\n  le_antisymm := \u03bb \u03b1 \u03b2, quotient.induction_on\u2082 \u03b1 \u03b2 $\n    \u03bb x y h h1, quotient.sound (eleven34 h h1),\n  le_total := \u03bb \u03b1 \u03b2, quotient.induction_on\u2082 \u03b1 \u03b2 $\n    \u03bb x y, eleven35 x.2.1 x.2.2 y.2.1 y.2.2 }\n\ninstance zero_angle : has_zero (angle point) := \u27e8\u27e6\u27e8\u27e8P1, P2, P1\u27e9, three13, three13\u27e9\u27e7\u27e9\n\ntheorem zero_angle_def : (0 : angle point) = \u27e6\u27e8\u27e8P1, P2, P1\u27e9, three13, three13\u27e9\u27e7 := rfl \n\ntheorem zero_iff_sided {x : set_angle point} : \u27e6x\u27e7 = (0 : angle point) \u2194 sided x.1.2.1 x.1.1 x.1.2.2 :=\n\u27e8\u03bb h, (eleven21a (six5 three13)).1 (quotient.exact h.symm), \u03bb h, (quotient.sound ((eleven21a h).2 (six5 three13)))\u27e9\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 \u2248 y \u2192 acute_triple x = acute_triple y :=\nbegin\nintro h,\nsuffices : acute_triple x \u2194 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 \u2248 y \u2192 obtuse_triple x = obtuse_triple y :=\nbegin\nintro h,\nsuffices : obtuse_triple x \u2194 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 \u2248 y \u2192 right_triple x = right_triple y :=\nbegin\nintro h,\nsuffices : right_triple x \u2194 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 (\u03b1 : angle point) : acute \u03b1 \u2228 right \u03b1 \u2228 obtuse \u03b1 :=\nbegin\nrcases quotient.exists_rep \u03b1 with \u27e8\u27e8\u27e8a, b, c\u27e9, h\u27e9, h1\u27e9,\nsubst \u03b1,\nexact right_total h.1 h.2\nend\n\ndef supp_triple (x : set_angle point) : set_angle point := \u27e8\u27e8x.1.1, x.1.2.1, S x.1.2.1 x.1.2.2\u27e9, x.2.1, (seven12a x.2.2)\u27e9\n\ndef supp_well_defined (x y : set_angle point) : x \u2248 y \u2192 supp_triple x \u2248 supp_triple y :=\nbegin\nintro h,\nrcases x with \u27e8\u27e8a, b, c\u27e9, h1\u27e9,\nrcases y with \u27e8\u27e8d, e, f\u27e9, h2\u27e9,\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 (\u03bb x, \u27e6supp_triple x\u27e7) (\u03bb x y h, quotient.sound (@supp_well_defined point _ x y h))\n\ntheorem supp_def {a b c : point} (h : a \u2260 b) (h1 : c \u2260 b) : supp \u27e6\u27e8\u27e8a, b, c\u27e9, h, h1\u27e9\u27e7 = \u27e6\u27e8\u27e8a, b, S b c\u27e9, h, seven12a h1\u27e9\u27e7 :=\nquotient.sound (eqa.refl h (seven12a h1))\n\n@[simp] theorem supp_of_supp (\u03b1 : angle point) : supp (supp \u03b1) = \u03b1 :=\nbegin\nrcases quotient.exists_rep \u03b1 with \u27e8\u27e8\u27e8a, b, c\u27e9, h\u27e9, hx\u27e9,\nsubst \u03b1,\nunfold supp supp_triple,\napply quotient.sound,\nsimpa using eqa.refl h.1 h.2\nend\n\ntheorem supp_of_acute (\u03b1 : angle point) : acute \u03b1 \u2194 obtuse (supp \u03b1) :=\nbegin\nrcases quotient.exists_rep \u03b1 with \u27e8\u27e8\u27e8a, b, c\u27e9, h\u27e9, h1\u27e9,\nsubst \u03b1,\nexact (eleven40a h.1 h.2 (seven12a h.2) (seven5 b c).1)\nend\n\ntheorem supp_of_obtuse {\u03b1 : angle point} : obtuse \u03b1 \u2194 acute (supp \u03b1) :=\nbegin\nrw \u2190(supp_of_supp \u03b1),\nsimpa using (supp_of_acute (supp \u03b1)).symm\nend\n\ntheorem supp_of_right {\u03b1 : angle point} : right \u03b1 \u2194 right (supp \u03b1) :=\nbegin\nrcases quotient.exists_rep \u03b1 with \u27e8\u27e8\u27e8a, b, c\u27e9, h\u27e9, h1\u27e9,\nsubst \u03b1,\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} : \u00accol a b c \u2192 C \u2260 0 \u2192 {x : point \u00d7 point // sided b a x.1 \u2227 \u27e6(b, x.1)\u27e7 = C \u2227 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 \u2260 p,\n  intro h_1,\n  subst p,\n  apply h1,\n  rw \u2190zero_class b,\n  exact hp.2.symm,\nhave h3 : sided b a p,\n  exact \u27e8(six26 h).1, h2.symm, five2 hd.2.symm hd.1.symm hp.1\u27e9,\nhave h4 : \u00accol 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 (\u03bb x, xperp x (l b c) (l p x)) (exists_of_exists_unique (eight17 (six14 (six26 h).2.1) h4)) with x hx,\nexact \u27e8\u27e8p, x\u27e9, h3, hp.2, hx\u27e9\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 (\u03b1 : angle point) (C : dist point) : dist point :=\nquotient.lift_on \u03b1 (\u03bb x : set_angle point, cos_triple x C) (\u03bb 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 \u27e8\u27e8a, b, c\u27e9, h2\u27e9,\nrcases y with \u27e8\u27e8d, e, f\u27e9, h3\u27e9,\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 : \u00accol 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 \u27e8\u27e8p, x\u27e9, h6\u27e9,\nrcases thirteen3 h5 h1 with \u27e8\u27e8q, y\u27e9, h7\u27e9,\ndsimp at h7 h6 \u22a2,\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 \u27e8h7.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\u27e9,\n    have h9 : \u00accol 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 \u2260 y,\n    intro h_3,\n    subst y,\n    have h8 : xperp b (l b c) (l p b),\n      exact eight13.2 \u27e8h6.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\u27e9,\n    have h9 : \u00accol 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 \u27e8l b x, six14 h_2, six17a b x, or.inr (or.inr h_1), (four11 h_4).2.2.1\u27e9,\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 \u2260 b) (hcb : c \u2260 b) : cos \u27e6\u27e8\u27e8a, b, c\u27e9, hab, hcb\u27e9\u27e7 = cos_triple \u27e8\u27e8a, b, c\u27e9, hab, hcb\u27e9 :=\nrfl\n\ntheorem thirteen5a {\u03b1 : angle point} {x : set_angle point} {d : point} : \n\u27e6x\u27e7 = \u03b1 \u2192 \u00accol x.1.1 x.1.2.1 x.1.2.2 \u2192 xperp d (l x.1.2.1 x.1.2.2) (l x.1.1 d) \u2192 \u27e6(x.1.2.1, d)\u27e7 = cos \u03b1 \u27e6(x.1.1, x.1.2.1)\u27e7 :=\nbegin\nintros h h1 h2,\nrcases x with \u27e8\u27e8a, b, c\u27e9, h3, h4\u27e9,\nrw [\u2190h, 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 \u27e8\u27e8p, t\u27e9, ht\u27e9,\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) \u27e8ht.1.symm, quotient.exact ht.2.1\u27e9 \u27e8six5 h3, eqd_refl b a\u27e9\nend\n\ntheorem thirteen5b {a b c : point} (h : a \u2260 b) (h1 : c \u2260 b) : R a c b \u2192 \u27e6(c, b)\u27e7 = cos \u27e6\u27e8(a, b, c), \u27e8h, h1\u27e9\u27e9\u27e7 \u27e6(a, b)\u27e7 :=\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 (\u03bb h_2, (h1.symm h_2).elim),\nrw dif_neg h_1,\nrcases thirteen3 h_1 (non_zero_dist_of_neq h) with \u27e8\u27e8p, x\u27e9, h3\u27e9,\ndsimp at h3 \u22a2,\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 \u27e8h3.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\u27e9),\nexact unique_of_exists_unique (six11 h3.1.1 h3.1.1) \u27e8h3.1.symm, quotient.exact h3.2.1\u27e9 \u27e8six5 h, eqd_refl b a\u27e9\nend\n\ntheorem cos_zero {C : dist point} : cos 0 C = C :=\nbegin\nshow cos_triple \u27e8\u27e8P1, P2, P1\u27e9, three13, three13\u27e9 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 {\u03b1 : angle point} {C : dist point} : right \u03b1 \u2192 cos \u03b1 C = 0 :=\nbegin\nrcases quotient.exists_rep \u03b1 with \u27e8\u27e8\u27e8a, b, c\u27e9, h1, h2\u27e9, h3\u27e9,\nsubst \u03b1,\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 \u27e8\u27e8p, x\u27e9, h4\u27e9,\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 (\u03b1 : angle point) : cos \u03b1 0 = 0 :=\nbegin\ncases quotient.exists_rep \u03b1 with x hx,\nsubst \u03b1,\ndsimp [cos, cos_triple],\nrw dif_pos rfl\nend\n\ntheorem cos_supp (\u03b1 : angle point) : cos \u03b1 = cos (supp \u03b1) :=\nbegin\next C,\nrcases quotient.exists_rep \u03b1 with \u27e8\u27e8\u27e8a, b, c\u27e9, h1, h2\u27e9, h3\u27e9,\nsubst \u03b1,\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 : \u00accol 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 \u27e8\u27e8p, x\u27e9, h4\u27e9,\nrcases thirteen3 h3 h_1 with \u27e8\u27e8q, y\u27e9, h5\u27e9,\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) \u27e8six5 h4.1.2.1, eqd.refl b p\u27e9\n\u27e8h5.1.symm.trans h4.1, quotient.exact (h5.2.1.trans h4.2.1.symm)\u27e9\nend\n\ntheorem thirteen6a {C : dist point} {\u03b1 : angle point} : C \u2260 0 \u2192 cos \u03b1 C = 0 \u2192 right \u03b1 :=\nbegin\nunfold cos cos_triple,\nintros h h1,\nsimp only [dif_neg h] at h1,\nrcases quotient.exists_rep \u03b1 with \u27e8\u27e8\u27e8a, b, c\u27e9, h2, h3\u27e9, h4\u27e9,\nrw \u2190h4 at h1 \u22a2,\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 \u27e8\u27e8p, x\u27e9, h5\u27e9,\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 \u27e8h5.1.2.1, h3, h5.2.2.symm.2.2.2.2 (six17a p b) (six17b b c)\u27e9\nend\n\ntheorem thirteen6 {C D : dist point} {\u03b1 : angle point} : \u00acright \u03b1 \u2192 cos \u03b1 C = cos \u03b1 D \u2192 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 \u03b1 with \u27e8\u27e8\u27e8a, b, c\u27e9, h2, h3\u27e9, h4\u27e9,\nrw \u2190h4 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 \u27e8\u27e8p, x\u27e9, h5\u27e9,\nrcases thirteen3 h_3 h_2 with \u27e8\u27e8q, y\u27e9, h6\u27e9,\ndsimp at *,\nintro h1,\nhave h7 : b \u2260 x,\n  intro h_4,\n  subst x,\n  apply h,\n  apply ang_right.trans _ (eleven9 h5.1 (six5 h3)),\n  exact \u27e8h5.1.2.1, h3, h5.2.2.symm.2.2.2.2 (six17a p b) (six17b b c)\u27e9,\nhave h8 : b \u2260 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 \u2190h_4 at h5,\n    exact h7 (eight14d (eight15 \u27e8x, h5.2.2\u27e9 (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) \u27e8six5 this.1, eqd_refl b x\u27e9 \u27e8this.symm, two5 (quotient.exact h1).symm\u27e9,\nexact (thirteen8 (four11 (six4.1 (h5.1.symm.trans h6.1)).1).2.1 (six23.2 \u27e8l b c, h5.2.2.1, six17a b c, h5.2.2.2.2.1, h6.2.2.2.2.1\u27e9) \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 \u2208 F) (hy : y \u2208 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 \u2208 F) (hy : y \u2208 F)\n  (t : I) : hF.some_path hx hy t \u2208 F :=\njoined_in.some_path_mem _ t\n\nlemma range_some_path_subset (hF : is_path_connected F) {x y : X} (hx : x \u2208 F) (hy : y \u2208 F) :\n  range (hF.some_path hx hy) \u2286 F :=\nby { rintro _ \u27e8t, rfl\u27e9, 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 : \u2115} {p : fin (m+1) \u2192 X}\n  (hp : \u2200 i, p i \u2208 F) : \u2200 n : \u2115, 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 : \u2115} {p : fin (m+1) \u2192 X}\n  (hp : \u2200 i, p i \u2208 F) : \u2200 {n : \u2115}, range (hF.path_through hp n) \u2286 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 : \u2115} {p : fin (m+1) \u2192 X}\n  (hp : \u2200 i, p i \u2208 F) {i n : \u2115} (h : i \u2264 n) : p i \u2208 range (hF.path_through hp n) :=\nbegin\n  induction h with n hn ih,\n  { exact \u27e81, by simp\u27e9 },\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 : \u2115} {p : fin (m+1) \u2192 X}\n  (hp : \u2200 i, p i \u2208 F) {i : fin (m+1)} : p i \u2208 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 \u211d E]\n          {F : Type*} [normed_add_comm_group F] [normed_space \u211d F]\n\nlocal notation `d` := finrank \u211d 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 \u2192 F) (x : E) : Prop := \u2203 s \u2208 \ud835\udcdd x, smooth_on f s\n\nsection surrounding_points\n\nlocal notation `\u03b9` := 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 : \u03b9 \u2192 F) (w : \u03b9 \u2192 \u211d) : Prop :=\n(indep : affine_independent \u211d p)\n(w_pos : \u2200 i, 0 < w i)\n(w_sum : \u2211 i, w i = 1)\n(avg : \u2211 i, w i \u2022 p i = f)\n\nlemma surrounding_pts.tot [finite_dimensional \u211d F]\n  {f : F} {p : \u03b9 \u2192 F} {w : \u03b9 \u2192 \u211d} (h : surrounding_pts f p w) :\n  affine_span \u211d (range p) = \u22a4 :=\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 \u211d F]\n  {f : F} {p : \u03b9 \u2192 F} {w : \u03b9 \u2192 \u211d} (h : surrounding_pts f p w) :\n  p \u2208 affine_bases \u03b9 \u211d F :=\n\u27e8h.indep, h.tot\u27e9\n\nlemma surrounding_pts.coord_eq_w [finite_dimensional \u211d F]\n  {f : F} {p : \u03b9 \u2192 F} {w : \u03b9 \u2192 \u211d} (h : surrounding_pts f p w) :\n  (\u27e8p, h.indep, h.tot\u27e9 : affine_basis \u03b9 \u211d F).coords f = w :=\nbegin\n  let b : affine_basis \u03b9 \u211d F := \u27e8p, h.indep, h.tot\u27e9,\n  change b.coords f = w,\n  ext i,\n  rw [\u2190 h.avg, \u2190 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\u2203 p w, surrounding_pts f p w \u2227 \u2200 i, p i \u2208 s\n\nlemma surrounded_iff_mem_interior_convex_hull_aff_basis [finite_dimensional \u211d F]\n  {f : F} {s : set F} :\n  surrounded f s \u2194 \u2203 (b : set F)\n                     (h\u2080 : b \u2286 s)\n                     (h\u2081 : affine_independent \u211d (coe : b \u2192 F))\n                     (h\u2082 : affine_span \u211d b = \u22a4),\n                     f \u2208 interior (convex_hull \u211d b) :=\nbegin\n  split,\n  { rintros \u27e8p, w, \u27e8\u27e8indep, w_pos, w_sum, rfl\u27e9, h_mem\u27e9\u27e9,\n    have h_tot : affine_span \u211d (range p) = \u22a4 :=\n      indep.affine_span_eq_top_iff_card_eq_finrank_add_one.mpr (fintype.card_fin _),\n    refine \u27e8range p, range_subset_iff.mpr h_mem, indep.range, h_tot, _\u27e9,\n    let basis : affine_basis \u03b9 \u211d F := \u27e8p, indep, h_tot\u27e9,\n    erw basis.interior_convex_hull,\n    intros i,\n    erw [\u2190 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 \u27e8b, h\u2080, h\u2081, h\u2082, h\u2083\u27e9,\n    haveI : fintype b := (finite_set_of_fin_dim_affine_independent \u211d h\u2081).fintype,\n    have hb : fintype.card b = d + 1,\n    { rw [\u2190 h\u2081.affine_span_eq_top_iff_card_eq_finrank_add_one, subtype.range_coe_subtype,\n        set_of_mem_eq, h\u2082], },\n    let p := (coe : _ \u2192 F) \u2218 (fintype.equiv_fin_of_card_eq hb).symm,\n    have hp : b = range p,\n    { ext x,\n      exact \u27e8by { intros h, use fintype.equiv_fin_of_card_eq hb \u27e8x, h\u27e9, simp [p], },\n             by { rintros \u27e8y, rfl\u27e9, apply subtype.coe_prop, }\u27e9, },\n    rw hp at h\u2080 h\u2082 h\u2083,\n    replace h\u2081 : affine_independent \u211d p :=\n      h\u2081.comp_embedding (fintype.equiv_fin_of_card_eq hb).symm.to_embedding,\n    let basis : affine_basis \u03b9 \u211d F := \u27e8_, h\u2081, h\u2082\u27e9,\n    erw [basis.interior_convex_hull, mem_set_of_eq] at h\u2083,\n    refine \u27e8p, \u03bb i, basis.coord i f, \u27e8h\u2081, h\u2083, _, _\u27e9, \u03bb i, h\u2080 (mem_range_self i)\u27e9,\n    { exact basis.sum_coord_apply_eq_one f, },\n    { erw [\u2190 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 \u211d F]\n  {f : F} {s : set F} (hs : is_open s) (hsf : f \u2208 convex_hull \u211d s) :\n  surrounded f s :=\nbegin\n  rw surrounded_iff_mem_interior_convex_hull_aff_basis,\n  obtain \u27e8t, hts, hai, hf\u27e9 :=\n    (by simpa only [exists_prop, mem_Union] using convex_hull_eq_union.subst hsf :\n    \u2203 (t : finset F), (t : set F) \u2286 s \u2227 affine_independent \u211d (coe : t \u2192 F) \u2227\n      f \u2208 convex_hull \u211d (t : set F)),\n  have htne : (t : set F).nonempty := (@convex_hull_nonempty_iff \u211d _ _ _ _ _).mp \u27e8f, hf\u27e9,\n  obtain \u27e8b, hb\u2081, hb\u2082, hb\u2083, hb\u2084\u27e9 :=\n    hs.exists_between_affine_independent_span_eq_top hts htne hai,\n  have hb\u2080 : b.finite, { exact finite_set_of_fin_dim_affine_independent \u211d hb\u2083, },\n  obtain \u27e8c, hc\u27e9 := interior_convex_hull_nonempty_iff_affine_span_eq_top.mpr hb\u2084,\n  rw \u2190 hs.interior_eq at hb\u2082,\n  obtain \u27e8\u03b5, h\u03b5, hcs\u27e9 :=\n    (eventually_homothety_image_subset_of_finite_subset_interior \u211d c hb\u2080 hb\u2082).exists_gt,\n  have hb\u03b5 := convex.subset_interior_image_homothety_of_one_lt (convex_convex_hull \u211d _) hc \u03b5 h\u03b5,\n  rw affine_map.image_convex_hull at hb\u03b5,\n  let t : units \u211d := units.mk0 \u03b5 (by linarith),\n  refine \u27e8affine_map.homothety c (t : \u211d) '' b, hcs, _, _, hb\u03b5 (convex_hull_mono hb\u2081 hf)\u27e9,\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\u2084, },\nend\n\n-- lem:smooth_barycentric_coord\nlemma smooth_surrounding [finite_dimensional \u211d F] {x : F} {p : \u03b9 \u2192 F} {w : \u03b9 \u2192 \u211d}\n  (h : surrounding_pts x p w) :\n  \u2203 W : F \u2192 (\u03b9 \u2192 F) \u2192 (\u03b9 \u2192 \u211d),\n  \u2200\u1da0 (yq : F \u00d7 (\u03b9 \u2192 F)) in \ud835\udcdd (x, p), smooth_at' (uncurry W) yq \u2227\n                             (\u2200 i, 0 < W yq.1 yq.2 i) \u2227\n                             \u2211 i, W yq.1 yq.2 i = 1 \u2227\n                             \u2211 i, W yq.1 yq.2 i \u2022 yq.2 i = yq.1 :=\nbegin\n  classical,\n  use eval_barycentric_coords \u03b9 \u211d F,\n  let V : set (\u03b9 \u2192 \u211d) := set.pi set.univ (\u03bb i, Ioi (0 : \u211d)),\n  let W' : F \u00d7 (\u03b9 \u2192 F) \u2192 (\u03b9 \u2192 \u211d) := uncurry (eval_barycentric_coords \u03b9 \u211d F),\n  let A : set (F \u00d7 (\u03b9 \u2192 F)) := univ \u00d7\u02e2 affine_bases \u03b9 \u211d F,\n  let U : set (F \u00d7 (\u03b9 \u2192 F)) := A \u2229 (W' \u207b\u00b9' V),\n  have h\u03b9 : fintype.card \u03b9 = d + 1 := fintype.card_fin _,\n  have hp : p \u2208 affine_bases \u03b9 \u211d F := h.mem_affine_bases,\n  have hV : is_open V := is_open_set_pi finite_univ (\u03bb _ _, is_open_Ioi),\n  have hW' : continuous_on W' A := (smooth_barycentric \u03b9 \u211d F h\u03b9).continuous_on,\n  have hxp : W' (x, p) \u2208 V, { simp [W', hp, h.coord_eq_w, h.w_pos], },\n  have hA : is_open A,\n  { simp only [A, affine_bases_findim \u03b9 \u211d F h\u03b9],\n    exact is_open_univ.prod (is_open_affine_independent \u211d F), },\n  have hU\u2081 : U \u2286 A := set.inter_subset_left _ _,\n  have hU\u2082 : is_open U := hW'.preimage_open_of_open hA hV,\n  have hU\u2083 : U \u2208 \ud835\udcdd (x, p) :=\n    mem_nhds_iff.mpr \u27e8U, le_refl U, hU\u2082, set.mem_inter (by simp [hp]) (mem_preimage.mpr hxp)\u27e9,\n  apply eventually_of_mem hU\u2083,\n  rintros \u27e8y, q\u27e9 hyq,\n  have hq : q \u2208 affine_bases \u03b9 \u211d F, { simpa using hU\u2081 hyq, },\n  have hyq' : (y, q) \u2208 W' \u207b\u00b9' V := (set.inter_subset_right _ _) hyq,\n  refine \u27e8\u27e8U, mem_nhds_iff.mpr \u27e8U, le_refl U, hU\u2082, hyq\u27e9, (smooth_barycentric \u03b9 \u211d F h\u03b9).mono hU\u2081\u27e9, _, _, _\u27e9,\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 \u211d F] {x : F} {p : \u03b9 \u2192 F} {w : \u03b9 \u2192 \u211d}\n  (h : surrounding_pts x p w) :\n  \u2203 W : F \u2192 (\u03b9 \u2192 F) \u2192 (\u03b9 \u2192 \u211d),\n  \u2200\u1da0 (yq : F \u00d7 (\u03b9 \u2192 F)) in \ud835\udcdd (x, p), smooth_at' (uncurry W) yq \u2227\n    surrounding_pts yq.1 yq.2 (W yq.1 yq.2) :=\nbegin\n  refine exists_imp_exists (\u03bb W hW, _) (smooth_surrounding h),\n  rw [nhds_prod_eq] at hW \u22a2,\n  have := (is_open.eventually_mem (is_open_affine_independent \u211d F) h.indep).prod_inr (\ud835\udcdd x),\n  filter_upwards [hW, this], rintro \u27e8y, q\u27e9 \u27e8hW, h2W, h3W, hq\u27e9 h2q,\n  exact \u27e8hW, h2q, h2W, h3W, hq\u27e9\nend\n\nlemma surrounding_pts_eval_barycentric_coords_iff\n  (q : F) (v : \u03b9 \u2192 F) [decidable_pred (\u2208 affine_bases \u03b9 \u211d F)] :\n  surrounding_pts q v (eval_barycentric_coords \u03b9 \u211d F q v) \u2194\n  \u2200 i, 0 < eval_barycentric_coords \u03b9 \u211d F q v i :=\nbegin\n  refine \u27e8\u03bb h, h.w_pos, \u03bb h, _\u27e9,\n  have hv : v \u2208 affine_bases \u03b9 \u211d F,\n  { by_contra contra,\n    simpa [eval_barycentric_coords_apply_of_not_mem_bases \u03b9 \u211d F q contra] using h 0, },\n  have hv' : \u2211 i, eval_barycentric_coords \u03b9 \u211d F q v i = 1,\n  { simp [eval_barycentric_coords_apply_of_mem_bases \u03b9 \u211d F q hv], },\n  refine \u27e8hv.1, h, hv', _\u27e9,\n  simp_rw [\u2190 finset.univ.affine_combination_eq_linear_combination v _ hv',\n    eval_barycentric_coords_apply_of_mem_bases \u03b9 \u211d 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 \u211d F]\n\nlocal notation `\u03b9` := fin (finite_dimensional.finrank \u211d F + 1)\n\nlemma eventually_surrounding_pts_of_tendsto_of_tendsto {l : filter X} {m : filter Y}\n  {v : \u03b9 \u2192 F} {q : F} {p : \u03b9 \u2192 X \u2192 F} {f : Y \u2192 F}\n  (hq : \u2203 w, surrounding_pts q v w)\n  (hp : \u2200 i, tendsto (p i) l (\ud835\udcdd (v i)))\n  (hf : tendsto f m (\ud835\udcdd q)) :\n  \u2200\u1da0 (z : X \u00d7 Y) in l.prod m, \u2203 w, surrounding_pts (f z.2) (\u03bb i, p i z.1) w :=\nbegin\n  classical,\n  obtain \u27e8w, hw\u27e9 := hq,\n  let V : set (\u03b9 \u2192 \u211d) := set.pi set.univ (\u03bb i, Ioi (0 : \u211d)),\n  let W' : F \u00d7 (\u03b9 \u2192 F) \u2192 (\u03b9 \u2192 \u211d) := uncurry (eval_barycentric_coords \u03b9 \u211d F),\n  let A : set (F \u00d7 (\u03b9 \u2192 F)) := (univ : set F) \u00d7\u02e2 affine_bases \u03b9 \u211d F,\n  let S : set (F \u00d7 (\u03b9 \u2192 F)) := W' \u207b\u00b9' V,\n  have h\u03b9 : fintype.card \u03b9 = finite_dimensional.finrank \u211d F + 1 := fintype.card_fin _,\n  have hq' : v \u2208 affine_bases \u03b9 \u211d F := hw.mem_affine_bases,\n  have hqv : (q, v) \u2208 A, { simp [hq'], },\n  have hxp : W' (q, v) \u2208 V, { simp [W', hq', hw.coord_eq_w, hw.w_pos], },\n  have hV' : V \u2208 \ud835\udcdd (W' (q, v)) := (is_open_set_pi finite_univ (\u03bb _ _, is_open_Ioi)).mem_nhds hxp,\n  have hA : is_open A,\n  { simp only [A, affine_bases_findim \u03b9 \u211d F h\u03b9],\n    exact is_open_univ.prod (is_open_affine_independent \u211d F), },\n  have hW' : continuous_at W' (q, v) := (smooth_barycentric \u03b9 \u211d F h\u03b9).continuous_on.continuous_at\n    (mem_nhds_iff.mpr \u27e8A, subset.rfl, hA, hqv\u27e9),\n  have hS : S \u2208 \ud835\udcdd (q, v) := hW'.preimage_mem_nhds hV',\n  obtain \u27e8n\u2081, hn\u2081, n\u2082, hn\u2082, hS'\u27e9 := mem_nhds_prod_iff.mp hS,\n  have hn\u2081' := tendsto_def.mp hf _ hn\u2081,\n  have hn\u2082' := tendsto_def.mp (tendsto_pi_nhds.mpr hp) _ hn\u2082,\n  have come_on : ((swap p)\u207b\u00b9' n\u2082) \u00d7\u02e2 (f\u207b\u00b9' n\u2081) \u2208 l.prod m :=\n    mem_prod_iff.mpr \u27e8_, hn\u2082', _, hn\u2081', subset.rfl\u27e9,\n  refine eventually_of_mem come_on _,\n  rintros \u27e8y\u2082, y\u2081\u27e9 \u27e8hy\u2082 : swap p y\u2082 \u2208 n\u2082, hy\u2081 : f y\u2081 \u2208 n\u2081\u27e9,\n  refine \u27e8W' (f y\u2081, swap p y\u2082), (surrounding_pts_eval_barycentric_coords_iff\n    (f y\u2081) (swap p y\u2082)).mpr (\u03bb i, _)\u27e9,\n  change W' (f y\u2081, swap p y\u2082) i \u2208 Ioi (0 : \u211d),\n  suffices : (f y\u2081, swap p y\u2082) \u2208 S,\n  { rw [set.mem_preimage] at this, exact set.mem_pi.mp this i (mem_univ _), },\n  apply hS',\n  simp [hy\u2081, hy\u2082],\nend\n\nlemma eventually_surrounding_pts_of_tendsto_of_tendsto'\n  {v : \u03b9 \u2192 F} {q : F} {p : \u03b9 \u2192 X \u2192 F} {l : filter X} {f : X \u2192 F}\n  (hq : \u2203 w, surrounding_pts q v w)\n  (hp : \u2200 i, tendsto (p i) l (\ud835\udcdd (v i)))\n  (hf : tendsto f l (\ud835\udcdd q)) :\n  \u2200\u1da0 y in l, \u2203 w, surrounding_pts (f y) (\u03bb 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 \u27e8nnn, \u27e8n\u2081, hn\u2081, n\u2082, hn\u2082, hh\u27e9, h\u27e9 := this,\n  rw eventually_iff_exists_mem,\n  exact \u27e8n\u2081 \u2229 n\u2082, inter_mem hn\u2081 hn\u2082, \u03bb y hy, h (y, y) (by { apply hh, simpa using hy, })\u27e9,\nend\n\nend surrounding_points_limits\n\nnamespace loop\n\nvariables {\u03b3 \u03b3' : loop F} {x y : F} {t : \u211d}\n\n/-- A loop `\u03b3` surrounds a point `x` if `x` is surrounded by values of `\u03b3`. -/\ndef surrounds (\u03b3 : loop F) (x : F) : Prop :=\n\u2203 t w : fin (d + 1) \u2192 \u211d, surrounding_pts x (\u03b3 \u2218 t) w\n\nlemma surrounds_iff_range_subset_range :\n  \u03b3.surrounds x \u2194 \u2203 (p : fin (d + 1) \u2192 F) (w : fin (d + 1) \u2192 \u211d),\n  surrounding_pts x p w \u2227 range p \u2286 range \u03b3 :=\nbegin\n  split,\n  { exact \u03bb \u27e8t, w, h\u27e9, \u27e8(\u03b3 \u2218 t), w, h, range_comp_subset_range _ _\u27e9 },\n  { rintros \u27e8p, w, h\u2080, h\u2081\u27e9,\n    rw range_subset_iff at h\u2081,\n    choose t ht using h\u2081,\n    have hpt : \u03b3 \u2218 t = p := funext ht,\n    exact \u27e8t, w, hpt.symm \u25b8 h\u2080\u27e9 }\nend\n\nlemma affine_equiv_surrounds_iff (e : F \u2243\u1d43[\u211d] F) :\n  \u03b3.surrounds x \u2194 (\u03b3.transform e).surrounds (e x) :=\nbegin\n  suffices : \u2200 (\u03b3 : loop F) x (e : F \u2243\u1d43[\u211d] F), \u03b3.surrounds x \u2192 (\u03b3.transform e).surrounds (e x),\n  { refine \u27e8this \u03b3 x e, \u03bb h, _\u27e9,\n    specialize this (\u03b3.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 \u03b3 x e \u27e8t, w, indep, w_pos, w_sum, rfl\u27e9,\n  refine \u27e8t, w, \u27e8e.affine_independent_iff.mpr indep, w_pos, w_sum, _\u27e9\u27e9,\n  simp only [\u2190 finset.affine_combination_eq_linear_combination _ _ _ w_sum],\n  erw finset.map_affine_combination _ (\u03b3 \u2218 t) _ w_sum (e : F \u2192\u1d43[\u211d] F),\n  congr,\nend\n\nlemma vadd_surrounds : \u03b3.surrounds x \u2194 (y +\u1d65 \u03b3).surrounds (y + x) :=\nbegin\n  rw add_comm,\n  convert affine_equiv_surrounds_iff (affine_equiv.vadd_const \u211d y),\n  ext u,\n  simp [add_comm y],\nend\n\nlemma surrounds.vadd (h : \u03b3.surrounds x) : (y +\u1d65 \u03b3).surrounds (y + x) :=\nvadd_surrounds.mp h\n\nlemma surrounds.vadd0 (h : \u03b3.surrounds 0) : (y +\u1d65 \u03b3).surrounds y :=\nby { convert h.vadd, rw [add_zero] }\n\nlemma surrounds.smul0 (h : \u03b3.surrounds 0) (ht : t \u2260 0) : (t \u2022 \u03b3).surrounds 0 :=\nbegin\n  rw [affine_equiv_surrounds_iff (affine_equiv.homothety_units_mul_hom (0 : F) (units.mk0 t ht)\u207b\u00b9),\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 : \u03b3.surrounds x) (h2 : range \u03b3 \u2286 range \u03b3') : \u03b3'.surrounds x :=\nbegin\n  revert h, simp_rw [loop.surrounds_iff_range_subset_range],\n  refine exists_imp_exists (\u03bb t, _),\n  refine exists_imp_exists (\u03bb w, _),\n  exact and.imp_right (\u03bb h3, subset.trans h3 h2),\nend\n\nprotected lemma surrounds.reparam (h : \u03b3.surrounds x) {\u03c6 : equivariant_map}\n  (h\u03c6 : continuous \u03c6) : (\u03b3.reparam \u03c6).surrounds x :=\nbegin\n  refine h.mono _,\n  convert subset_of_eq (range_comp \u03b3 \u03c6).symm,\n  rw [(\u03c6.surjective h\u03c6).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 \u211d F] (h : \u03b3.surrounds x) :\n  \u2203 \u03b5 > 0, \u2200 (\u03b3' : loop F) (y : F), (\u2200 z, dist (\u03b3' z) (\u03b3 z) < \u03b5) \u2192 dist y x < \u03b5 \u2192 \u03b3'.surrounds y :=\nbegin\n  obtain \u27e8t, w, h\u27e9 := h,\n  obtain \u27e8W, hW\u27e9 := smooth_surrounding_pts h,\n  obtain \u27e8\u03b5, h\u03b5, h\u27e9 := metric.eventually_nhds_iff.mp hW,\n  refine \u27e8\u03b5, h\u03b5, \u03bb \u03b3' y h\u03b3' hy, \u27e8t, W y (\u03b3' \u2218 t), _\u27e9\u27e9,\n  refine (@h \u27e8y, \u03b3' \u2218 t\u27e9 _).2,\n  simp_rw [prod.dist_eq, max_lt_iff, dist_pi_lt_iff h\u03b5],\n  exact \u27e8hy, \u03bb b, h\u03b3' (t b)\u27e9\nend\n\n\nend loop\n\nsection surrounding_loop\n\nvariables {O : set F} {f b : F} {p : fin (d + 1) \u2192 F}\n  (O_conn : is_path_connected O)\n  (hp : \u2200 i, p i \u2208 O)\n  (hb : b \u2208 O)\n\n/-- witness of `surrounding_loop_of_convex_hull` -/\ndef surrounding_loop : \u211d \u2192 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 \u21bf(surrounding_loop O_conn hp hb) :=\nloop.round_trip_family_continuous\n\n@[simp] lemma surrounding_loop_zero_right (t : \u211d) : 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 : \u211d) : 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 : \u211d) : surrounding_loop O_conn hp hb t s \u2208 O :=\nbegin\n  revert s,\n  rw \u2190 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) \u2192 \u211d} (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 \u27e8p, w, h, _\u27e9,\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 : \u211d) :\n  surrounding_loop O_conn hp hb (proj_I t) = surrounding_loop O_conn hp hb t :=\nloop.round_trip_eq $ \u03bb s, by simp_rw [path.cast_coe, truncate_proj_I_right]\n\n-- unused\nlemma surrounding_loop_of_le_zero (s : \u211d) {t : \u211d} (ht : t \u2264 0) :\n  surrounding_loop O_conn hp hb t s = b :=\nby rw [\u2190 surrounding_loop_proj_I, proj_I_eq_zero.mpr ht, surrounding_loop_zero_left]\n\n-- unused\nlemma surrounding_loop_of_ge_one (s : \u211d) {t : \u211d} (ht : 1 \u2264 t) :\n  surrounding_loop O_conn hp hb t s = surrounding_loop O_conn hp hb 1 s :=\nby rw [\u2190 surrounding_loop_proj_I t, proj_I_eq_one.mpr ht]\n\nlemma surrounding_loop_of_convex_hull [finite_dimensional \u211d F] {f b : F} {O : set F}\n  (O_op : is_open O) (O_conn : is_connected O)\n  (hsf : f \u2208 convex_hull \u211d O) (hb : b \u2208 O) :\n  \u2203 \u03b3 : \u211d \u2192 loop F, continuous \u21bf\u03b3 \u2227\n                    (\u2200 t, \u03b3 t 0 = b) \u2227\n                    (\u2200 s, \u03b3 0 s = b) \u2227\n                    (\u2200 s t, \u03b3 (proj_I t) s = \u03b3 t s) \u2227\n                    (\u2200 t s, \u03b3 t s \u2208 O) \u2227\n                    (\u03b3 1).surrounds f :=\nbegin\n  rcases surrounded_of_convex_hull O_op hsf with \u27e8p, w, h, hp\u27e9,\n  rw \u2190 O_op.is_connected_iff_is_path_connected at O_conn,\n  exact \u27e8surrounding_loop O_conn hp hb, continuous_surrounding_loop, surrounding_loop_zero_right,\n    surrounding_loop_zero_left, \u03bb s t, by rw surrounding_loop_proj_I,\n    surrounding_loop_mem, surrounding_loop_surrounds h\u27e9\nend\n\nend surrounding_loop\n\n/-- `\u03b3` forms a family of loops surrounding `g` with base `b`.\nIn contrast to the notes we assume that `base` and `t\u2080` hold universally. -/\n@[protect_proj]\nstructure surrounding_family (g b : E \u2192 F) (\u03b3 : E \u2192 \u211d \u2192 loop F) (U : set E) : Prop :=\n(base : \u2200 (x : E) (t : \u211d), \u03b3 x t 0 = b x)\n(t\u2080 : \u2200 (x : E) (s : \u211d), \u03b3 x 0 s = b x)\n(proj_I : \u2200 (x : E) (t : \u211d) (s : \u211d), \u03b3 x (proj_I t) s = \u03b3 x t s)\n(surrounds : \u2200 x \u2208 U, (\u03b3 x 1).surrounds $ g x)\n(cont : continuous \u21bf\u03b3)\n\n/-- `\u03b3` forms a family of loops surrounding `g` with base `b` in `\u03a9`. -/\nstructure surrounding_family_in (g b : E \u2192 F) (\u03b3 : E \u2192 \u211d \u2192 loop F) (U : set E) (\u03a9 : set $ E \u00d7 F)\n  extends surrounding_family g b \u03b3 U : Prop :=\n(val_in' : \u2200 (x \u2208 U) (t \u2208 I) (s \u2208 I), (x, \u03b3 x t s) \u2208 \u03a9)\n\nnamespace surrounding_family\n\nvariables {g b : E \u2192 F} {\u03b3 : E \u2192 \u211d \u2192 loop F} {U : set E}\n\nprotected lemma one (h : surrounding_family g b \u03b3 U) (x : E) (t : \u211d) : \u03b3 x t 1 = b x :=\nby rw [loop.one, h.base]\n\nprotected lemma t_le_zero (h : surrounding_family g b \u03b3 U) (x : E) (s : \u211d) {t : \u211d} (ht : t \u2264 0) :\n  \u03b3 x t s = \u03b3 x 0 s :=\nby rw [\u2190 h.proj_I, proj_I_eq_zero.mpr ht]\n\nprotected lemma t_le_zero_eq_b (h : surrounding_family g b \u03b3 U) (x : E) (s : \u211d) {t : \u211d}\n  (ht : t \u2264 0) : \u03b3 x t s = b x :=\nby rw [h.t_le_zero x s ht, h.t\u2080]\n\nprotected lemma t_ge_one (h : surrounding_family g b \u03b3 U) (x : E) (s : \u211d) {t : \u211d} (ht : 1 \u2264 t) :\n  \u03b3 x t s = \u03b3 x 1 s :=\nby rw [\u2190 h.proj_I, proj_I_eq_one.mpr ht]\n\nprotected lemma mono (h : surrounding_family g b \u03b3 U) {V : set E} (hVU : V \u2286 U) :\n  surrounding_family g b \u03b3 V :=\n\u27e8h.base, h.t\u2080, h.proj_I, \u03bb x hx, h.surrounds x (hVU hx), h.cont\u27e9\n\nprotected lemma surrounds_of_close_univ [finite_dimensional \u211d E] [finite_dimensional \u211d F]\n  (hg : continuous g)\n  (h : surrounding_family g b \u03b3 univ) :\n  \u2203 \u03b5 : E \u2192 \u211d, (\u2200 x, 0 < \u03b5 x) \u2227 continuous \u03b5 \u2227\n  \u2200 x (\u03b3' : loop F), (\u2200 z, dist (\u03b3' z) (\u03b3 x 1 z) < \u03b5 x) \u2192 \u03b3'.surrounds (g x) :=\nbegin\n  let P : E \u2192 \u211d \u2192 Prop := \u03bb x t, 0 < t \u2227\n    \u2200 (\u03b3' : loop F), (\u2200 z, dist (\u03b3' z) (\u03b3 x 1 z) < t) \u2192 \u03b3'.surrounds (g x),\n  have hP : \u2200 x, convex \u211d {t | P x t} :=\n  begin\n    intros x,\n    rw [convex_iff_ord_connected],\n    constructor,\n    rintro \u03b5\u2081 h\u03b5\u2081 \u03b5\u2082 h\u03b5\u2082 \u03b5\u2083 \u27e8h\u03b5\u2081\u2083, h\u03b5\u2083\u2082\u27e9,\n    refine \u27e8h\u03b5\u2081.1.trans_le h\u03b5\u2081\u2083, \u03bb \u03b3 h\u03b3, h\u03b5\u2082.2 \u03b3 $ \u03bb z, (h\u03b3 z).trans_le h\u03b5\u2083\u2082\u27e9\n  end,\n  obtain \u27e8\u03b5, h\u03b5, hP\u03b5\u27e9 := exists_cont_diff_of_convex hP _,\n  { refine \u27e8\u03b5, \u03bb x, (hP\u03b5 x).1, cont_diff_zero.mp h\u03b5, \u03bb x, (hP\u03b5 x).2\u27e9 },\n  intros x,\n  obtain \u27e8\u03b5, h\u03b5, h2\u27e9 := (h.surrounds x (mem_univ _)).eventually_surrounds,\n  have h3 : {y : E | dist (g y) (g x) < \u03b5} \u2208 \ud835\udcdd x :=\n    (metric.is_open_ball.preimage hg).mem_nhds\n    (by simp_rw [mem_preimage, metric.mem_ball, dist_self, h\u03b5.lt]),\n  have h4 : {y : E | \u2200 z, dist (\u03b3 y 1 z) (\u03b3 x 1 z) < \u03b5 / 2} \u2208 \ud835\udcdd x,\n  { refine is_open.mem_nhds _ (\u03bb z, by simp_rw [dist_self, half_pos h\u03b5]),\n    have hc : continuous \u21bf(\u03bb y s, dist (\u03b3 y 1 s) (\u03b3 x 1 s)) :=\n    (h.cont.comp\u2083 continuous_fst continuous_const continuous_snd).dist\n      (h.cont.comp\u2083 continuous_const continuous_const continuous_snd),\n    have : is_open {y : E | Sup ((\u03bb z, dist (\u03b3 y 1 z) (\u03b3 x 1 z)) '' I) < \u03b5 / 2},\n    { refine is_open_lt (is_compact_Icc.continuous_Sup hc) continuous_const },\n    have hc : \u2200 y, continuous (\u03bb s, dist (\u03b3 y 1 s) (\u03b3 x 1 s)) :=\n    \u03bb y, hc.comp\u2082 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 \u27e8\u03bb h z hz, h z, \u03bb h z, _\u27e9,\n    rw [\u2190 (\u03b3 y 1).fract_eq, \u2190 (\u03b3 x 1).fract_eq],\n    exact h _ (unit_interval.fract_mem _) },\n  refine \u27e8_, inter_mem h4 h3, \u03bb _, \u03b5 / 2, cont_diff_on_const,\n    \u03bb y hy, \u27e8half_pos h\u03b5, \u03bb \u03b3' h\u03b3', h2 _ _ (\u03bb z, _) hy.2\u27e9\u27e9,\n  refine (dist_triangle _ _ _).trans_lt\n    ((add_lt_add (h\u03b3' z) (hy.1 z)).trans_le (add_halves \u03b5).le)\nend\n/- proof using `surrounds_of_close` -/\n-- begin\n--   obtain \u27e8\u03b5, h\u03b5, hc\u03b5, h\u03b3\u03b5\u27e9 := h.surrounds_of_close hg is_open_univ,\n--   exact \u27e8\u03b5, \u03bb x, h\u03b5 x (mem_univ _), continuous_iff_continuous_on_univ.mpr hc\u03b5,\n--     \u03bb x, h\u03b3\u03b5 x (mem_univ _)\u27e9\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 \u03b3 U) (x : E) (t : \u211d) :\n  path (b x) (b x) :=\n{ to_fun := \u03bb s, \u03b3 x t s,\n  continuous_to_fun :=\n    (h.cont.comp\u2083 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 \u03b3 U)\n  {t : X \u2192 \u211d} {f : X \u2192 E} {s : X \u2192 I} (hf : continuous f) (ht : continuous t)\n  (hs : continuous s) : continuous (\u03bb x, h.path (f x) (t x) (s x)) :=\nh.cont.comp\u2083 hf ht hs.subtype_coe\n\n@[simp]\nlemma path_extend_fract (h : surrounding_family g b \u03b3 U) (t s : \u211d) (x : E) :\n  (h.path x t).extend (fract s) = \u03b3 x t s :=\nby { rw [extend_extends _ (unit_interval.fract_mem s), \u2190 loop.fract_eq], refl }\n\n@[simp]\nlemma range_path (h : surrounding_family g b \u03b3 U) (x : E) (t : \u211d) :\n  range (h.path x t) = range (\u03b3 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\u2080 (h : surrounding_family g b \u03b3 U) (x : E) : h.path x 0 = refl (b x) :=\nby { ext t, exact h.t\u2080 x t }\n\nend surrounding_family\n\nvariables {g b : E \u2192 F} {U K C : set E} {\u03a9 : set (E \u00d7 F)}\n\nnamespace surrounding_family_in\n\nvariables {\u03b3 : E \u2192 \u211d \u2192 loop F}\n\n/-- Abbreviation for `to_surrounding_family` -/\nlemma to_sf (h : surrounding_family_in g b \u03b3 U \u03a9) : surrounding_family g b \u03b3 U :=\nh.to_surrounding_family\n\nlemma val_in (h : surrounding_family_in g b \u03b3 U \u03a9) {x : E} (hx : x \u2208 U) {t : \u211d} {s : \u211d} :\n  (x, \u03b3 x t s) \u2208 \u03a9 :=\nby { rw [\u2190 loop.fract_eq, \u2190 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 \u03b3 U \u03a9) {V : set E} (hVU : V \u2286 U) :\n  surrounding_family_in g b \u03b3 V \u03a9 :=\n\u27e8h.to_sf.mono hVU, \u03bb x hx, h.val_in' x (hVU hx)\u27e9\n\n/-- Continuously reparameterize a `surrounding_family_in` so that it is constant near\n  `s \u2208 {0,1}` and `t \u2208 {0,1}` -/\nprotected lemma reparam (h : surrounding_family_in g b \u03b3 U \u03a9) :\n  surrounding_family_in g b (\u03bb x t, (\u03b3 x (linear_reparam t)).reparam linear_reparam) U \u03a9 :=\nbegin\n  refine \u27e8\u27e8_, _, _, _, _\u27e9, _\u27e9,\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\u2080] },\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\u2083 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\u2080 : E} (h\u03a9_conn : is_path_connected (prod.mk x\u2080 \u207b\u00b9' \u03a9))\n  (hb_in : (x\u2080, b x\u2080) \u2208 \u03a9)\n  {p : fin (d + 1) \u2192 F}\n  (hp : \u2200 i, p i \u2208 prod.mk x\u2080 \u207b\u00b9' \u03a9)\n\n-- /-- The witness of `local_loops`. -/\n-- def local_loops_def (x : E) (t : \u211d) : loop F :=\n-- b x - b x\u2080 +\u1d65 surrounding_loop h\u03a9_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 \u211d F]\n  {x\u2080 : E}\n  (h\u03a9_op : \u2203 U \u2208 \ud835\udcdd x\u2080, is_open (\u03a9 \u2229 fst \u207b\u00b9' U))\n  (hg : continuous_at g x\u2080) (hb : continuous b)\n  (hconv : g x\u2080 \u2208 convex_hull \u211d (connected_component_in (prod.mk x\u2080 \u207b\u00b9' \u03a9) $ b x\u2080)) :\n  \u2203 (\u03b3 : E \u2192 \u211d \u2192 loop F) (U \u2208 \ud835\udcdd x\u2080), surrounding_family_in g b \u03b3 U \u03a9 :=\nbegin\n  have hbx\u2080 : continuous_at b x\u2080 := hb.continuous_at,\n  have h\u03a9_op_x\u2080 : is_open (connected_component_in (prod.mk x\u2080 \u207b\u00b9' \u03a9) $ b x\u2080) :=\n    (is_open_slice_of_is_open_over h\u03a9_op).connected_component_in,\n  have b_in : b x\u2080 \u2208 prod.mk x\u2080 \u207b\u00b9' \u03a9 :=\n    connected_component_in_nonempty_iff.mp (convex_hull_nonempty_iff.mp \u27e8g x\u2080, hconv\u27e9),\n  have h\u03a9_conn : is_connected (connected_component_in (prod.mk x\u2080 \u207b\u00b9' \u03a9) $ b x\u2080) :=\n  is_connected_connected_component_in_iff.mpr b_in,\n  have hb_in : b x\u2080 \u2208 (connected_component_in (prod.mk x\u2080 \u207b\u00b9' \u03a9) $ b x\u2080) :=\n    mem_connected_component_in b_in,\n  rcases surrounding_loop_of_convex_hull h\u03a9_op_x\u2080 h\u03a9_conn hconv hb_in with\n    \u27e8\u03b3, h1\u03b3, h2\u03b3, h3\u03b3, h4\u03b3, h5\u03b3, h6\u03b3\u27e9,\n  have h5\u03b3 : \u2200 (t s : \u211d), \u03b3 t s \u2208 mk x\u2080 \u207b\u00b9' \u03a9 := \u03bb t s, connected_component_in_subset _ _ (h5\u03b3 t s),\n  let \u03b4 : E \u2192 \u211d \u2192 loop F := \u03bb x t, b x - b x\u2080 +\u1d65 \u03b3 t,\n  have h\u03b4 : continuous \u21bf\u03b4,\n  { dsimp only [\u03b4, has_uncurry.uncurry, loop.vadd_apply],\n    refine (hb.fst'.sub continuous_const).add h1\u03b3.snd' },\n  have h\u03b4x\u2080 : \u2200 t s, \u03b4 x\u2080 t s = \u03b3 t s,\n  { intros t s, simp only [zero_add, loop.vadd_apply, sub_self] },\n  have h\u03b4s0 : \u2200 x t, \u03b4 x t 0 = b x,\n  { intros x t, simp only [h2\u03b3, loop.vadd_apply, sub_add_cancel] },\n  have h\u03b4t0 : \u2200 x s, \u03b4 x 0 s = b x,\n  { intros x s, simp [h3\u03b3, sub_add_cancel] },\n  have h\u03b4t1 : \u2200 x t s, \u03b4 x (proj_I t) s = \u03b4 x t s,\n  { intros x t s, simp [h4\u03b3] },\n  have h\u03b4\u03a9 : \u2200\u1da0 x in \ud835\udcdd x\u2080, \u2200 (t \u2208 I) (s \u2208 I), (x, \u03b4 x t s) \u2208 \u03a9,\n  { rcases h\u03a9_op with \u27e8U, hUx\u2080, hU\u27e9,\n    -- todo: this is nicer with `is_compact.eventually_forall_of_forall_eventually` twice, but then\n    -- we need the continuity of `\u03b4` with the arguments reassociated differently.\n    have : \u2200\u1da0 (x : E) in \ud835\udcdd x\u2080, \u2200 (ts : \u211d \u00d7 \u211d), ts \u2208 I \u00d7\u02e2 I \u2192 (x, \u03b4 x ts.1 ts.2) \u2208 \u03a9,\n    { refine is_compact.eventually_forall_mem (is_compact_Icc.prod is_compact_Icc)\n        (continuous_fst.prod_mk h\u03b4) _,\n      rintro \u27e8t, s\u27e9 \u27e8ht, hs\u27e9,\n      rw [h\u03b4x\u2080],\n      show \u03a9 \u2208 \ud835\udcdd (x\u2080, \u03b3 t s),\n      exact mem_nhds_iff.mpr\n        \u27e8_, inter_subset_left _ _, hU, \u27e8h5\u03b3 t s, show x\u2080 \u2208 U, from mem_of_mem_nhds hUx\u2080\u27e9\u27e9 },\n    refine this.mono _, intros x h t ht s hs, exact h (t, s) \u27e8ht, hs\u27e9 },\n  have h\u03b4surr : \u2200\u1da0 x in \ud835\udcdd x\u2080, (\u03b4 x 1).surrounds (g x),\n  { rcases h6\u03b3 with \u27e8p, w, h\u27e9,\n    obtain \u27e8W, hW\u27e9 := smooth_surrounding_pts h,\n    let c : E \u2192 F \u00d7 (fin (d+1) \u2192 F) := \u03bb x, (g x, \u03b4 x 1 \u2218 p),\n    have hc : continuous_at c x\u2080 := hg.prod\n      (((continuous_at_pi.2 (\u03bb _, hbx\u2080)).sub continuous_at_const).add continuous_at_const),\n    have hcx\u2080 : c x\u2080 = (g x\u2080, \u03b3 1 \u2218 p),\n    { simp only [c, h\u03b4x\u2080, function.comp, prod.mk.inj_iff, eq_self_iff_true, and_self] },\n    rw [\u2190 hcx\u2080] at hW,\n    filter_upwards [hc.tendsto.eventually hW], rintro x \u27e8hW, hx\u27e9,\n    exact \u27e8_, _, hx\u27e9 },\n  exact \u27e8\u03b4, _, h\u03b4\u03a9.and h\u03b4surr, \u27e8\u27e8h\u03b4s0, h\u03b4t0, h\u03b4t1, \u03bb x, and.right, h\u03b4\u27e9, \u03bb x, and.left\u27e9\u27e9\nend\n\n/-- A tiny reformulation of `local_loops` where the existing `U` is open. -/\nlemma local_loops_open [finite_dimensional \u211d F]\n  {x\u2080 : E}\n  (h\u03a9_op : \u2203 U \u2208 \ud835\udcdd x\u2080, is_open (\u03a9 \u2229 fst \u207b\u00b9' U))\n  (hg : continuous_at g x\u2080) (hb : continuous b)\n  (hconv : g x\u2080 \u2208 convex_hull \u211d (connected_component_in (prod.mk x\u2080 \u207b\u00b9' \u03a9) $ b x\u2080)) :\n  \u2203 (\u03b3 : E \u2192 \u211d \u2192 loop F) (U : set E), is_open U \u2227 x\u2080 \u2208 U \u2227 surrounding_family_in g b \u03b3 U \u03a9 :=\nbegin\n  obtain \u27e8\u03b3, U, hU, h\u03b3\u27e9 := local_loops h\u03a9_op hg hb hconv,\n  obtain \u27e8V, hVU, hV, hx\u2080V\u27e9 := mem_nhds_iff.mp hU,\n  exact \u27e8\u03b3, V, hV, hx\u2080V, h\u03b3.mono hVU\u27e9\nend\n\nend local_loops\n\n/-- Function used in `satisfied_or_refund`. Rename. -/\ndef \u03c1 (t : \u211d) : \u211d := proj_I $ 2 * (1 - t)\n\nlemma continuous_\u03c1 : continuous \u03c1 :=\ncontinuous_proj_I.comp $ continuous_const.mul $ continuous_const.sub continuous_id\n\n@[simp] lemma \u03c1_eq_one {x : \u211d} : \u03c1 x = 1 \u2194 x \u2264 1 / 2 :=\nby { rw [\u03c1, proj_I_eq_one], split; intros; linarith }\n\n@[simp] lemma \u03c1_eq_one_of_le {x : \u211d} (h : x \u2264 1 / 2) : \u03c1 x = 1 :=\n\u03c1_eq_one.mpr h\n\n@[simp] lemma \u03c1_eq_one_of_nonpos {x : \u211d} (h : x \u2264 0) : \u03c1 x = 1 :=\n\u03c1_eq_one_of_le $ h.trans $ by norm_num\n\n@[simp] lemma \u03c1_eq_zero {x : \u211d} : \u03c1 x = 0 \u2194 1 \u2264 x :=\nby { rw [\u03c1, proj_I_eq_zero], split; intros; linarith }\n\n@[simp] lemma \u03c1_eq_zero_of_le {x : \u211d} (h : 1 \u2264 x) : \u03c1 x = 0 :=\n\u03c1_eq_zero.mpr h\n\nlemma \u03c1_mem_I {x : \u211d} : \u03c1 x \u2208 I := proj_I_mem_Icc\n\nsection satisfied_or_refund\n\nvariables {\u03b3\u2080 \u03b3\u2081 : E \u2192 \u211d \u2192 loop F}\nvariables (h\u2080 : surrounding_family g b \u03b3\u2080 U) (h\u2081 : surrounding_family g b \u03b3\u2081 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 (\u03c4 : \u211d) (x : E) (t : \u211d) :=\nloop.of_path $ (h\u2080.path x $ \u03c1 \u03c4 * proj_I t).strans (h\u2081.path x $ \u03c1 (1 - \u03c4) * proj_I t) $\n  proj_Icc 0 1 zero_le_one (1 - \u03c4)\n\nvariables {h\u2080 h\u2081}\n\n@[simp] lemma sf_homotopy_zero : sf_homotopy h\u2080 h\u2081 0 = \u03b3\u2080 :=\nbegin\n  ext x t s,\n  simp only [sf_homotopy, one_mul, \u03c1_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\u2080.proj_I]\nend\n\n@[simp] lemma sf_homotopy_one : sf_homotopy h\u2080 h\u2081 1 = \u03b3\u2081 :=\nbegin\n  ext x t s,\n  simp only [sf_homotopy, path.strans_zero, Icc.mk_zero, one_mul, \u03c1_eq_one_of_nonpos,\n    surrounding_family.path_extend_fract, proj_Icc_left, loop.of_path_apply, sub_self,\n    h\u2081.proj_I]\nend\n\nlemma _root_.continuous.sf_homotopy {X : Type*} [uniform_space X]\n  [separated_space X] [locally_compact_space X]\n  {\u03c4 t s : X \u2192 \u211d} {f : X \u2192 E} (h\u03c4 : continuous \u03c4) (hf : continuous f) (ht : continuous t)\n  (hs : continuous s) : continuous (\u03bb x, sf_homotopy h\u2080 h\u2081 (\u03c4 x) (f x) (t x) (s x)) :=\nbegin\n  refine continuous.of_path _ _ _ _ hs,\n  refine continuous.path_strans _ _ _ _ _ continuous_snd,\n  { refine h\u2080.continuous_path hf.fst'.fst' _ continuous_snd,\n    exact (continuous_\u03c1.comp h\u03c4.fst'.fst').mul (continuous_proj_I.comp ht.fst'.fst') },\n  { refine h\u2081.continuous_path hf.fst'.fst' _ continuous_snd,\n    refine (continuous_\u03c1.comp _).mul (continuous_proj_I.comp ht.fst'.fst'),\n    exact continuous_const.sub h\u03c4.fst'.fst' },\n  { intros x s hs, simp only [proj_Icc_eq_zero, sub_nonpos] at hs,\n    simp only [hs, h\u2080.t\u2080, zero_mul, surrounding_family.path_apply, \u03c1_eq_zero_of_le] },\n  { intros x s hs, simp only [proj_Icc_eq_one] at hs,\n    simp only [hs, h\u2081.t\u2080, zero_mul, surrounding_family.path_apply, \u03c1_eq_zero_of_le] },\n  { refine continuous_proj_Icc.comp (continuous_const.sub h\u03c4.fst') }\nend\n\n/-- In this lemmas and the lemmas below we add `finite_dimensional \u211d E` so that we can conclude\n `locally_compact_space E`. -/\nlemma continuous_sf_homotopy [finite_dimensional \u211d E] : continuous \u21bf(sf_homotopy h\u2080 h\u2081) :=\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 \u211d E] (\u03c4 : \u211d) :\n  surrounding_family g b (sf_homotopy h\u2080 h\u2081 \u03c4) 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 : \u03c1 \u03c4 * t \u2264 0 := mul_nonpos_of_nonneg_of_nonpos (\u03c1_nonneg \u03c4) ht,\n    -- have h3t : \u03c1 (1 - \u03c4) * t \u2264 0 := mul_nonpos_of_nonneg_of_nonpos (\u03c1_nonneg _) ht,\n    -- have h4t : t \u2264 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\u2080] },\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 \u03c4 (1 / 2) with h h,\n    { have : \u03c4 < 1 := h.trans_lt (by norm_num),\n      refine (h\u2080.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, \u03c1_eq_one_of_le, h])\n        (subset_range_strans_left $ by simp [this]) },\n    { have : 0 < \u03c4 := lt_of_lt_of_le (by norm_num) h,\n      have h : 1 - \u03c4 \u2264 1 / 2, { rw [sub_le_comm], convert h, norm_num },\n      refine (h\u2081.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, \u03c1_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' {\u03b9} (h\u2080 : surrounding_family g b \u03b3\u2080 U) (h\u2081 : surrounding_family g b \u03b3\u2081 U)\n  (\u03c4 : \u03b9 \u2192 \u211d) (x : \u03b9 \u2192 E) (i : \u03b9) {V : set E} (hx : x i \u2208 V) {t : \u211d} (ht : t \u2208 I) {s : \u211d}\n  (h_in\u2080 : \u2200 i (hx : x i \u2208 V) (t \u2208 I) (s : \u211d), \u03c4 i \u2260 1 \u2192 (x i, \u03b3\u2080 (x i) t s) \u2208 \u03a9)\n  (h_in\u2081 : \u2200 i (hx : x i \u2208 V) (t \u2208 I) (s : \u211d), \u03c4 i \u2260 0 \u2192 (x i, \u03b3\u2081 (x i) t s) \u2208 \u03a9) :\n  (x i, sf_homotopy h\u2080 h\u2081 (\u03c4 i) (x i) t s) \u2208 \u03a9 :=\nbegin\n  by_cases h\u03c40 : \u03c4 i = 0, { simp [h\u03c40], exact h_in\u2080 i hx t ht s (by norm_num [h\u03c40]) },\n  by_cases h\u03c41 : \u03c4 i = 1, { simp [h\u03c41], exact h_in\u2081 i hx t ht s (by norm_num [h\u03c41]) },\n  generalize hy : sf_homotopy h\u2080 h\u2081 (\u03c4 i) (x i) t s = y,\n  have h2y : y \u2208 range (sf_homotopy h\u2080 h\u2081 (\u03c4 i) (x i) t), { rw [\u2190 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 \u27e8s', rfl\u27e9|\u27e8s', rfl\u27e9,\n  { exact h_in\u2080 _ hx _ (unit_interval.mul_mem \u03c1_mem_I ht) _ h\u03c41 },\n  { exact h_in\u2081 _ hx _ (unit_interval.mul_mem \u03c1_mem_I ht) _ h\u03c40 }\nend\n\nlemma sf_homotopy_in (h\u2080 : surrounding_family_in g b \u03b3\u2080 U \u03a9) (h\u2081 : surrounding_family_in g b \u03b3\u2081 U \u03a9)\n  (\u03c4 : \u211d) \u2983x : E\u2984 (hx : x \u2208 U) {t : \u211d} (ht : t \u2208 I) {s : \u211d} :\n  (x, sf_homotopy h\u2080.to_sf h\u2081.to_sf \u03c4 x t s) \u2208 \u03a9 :=\nsf_homotopy_in' h\u2080.to_sf h\u2081.to_sf (\u03bb _, \u03c4) (\u03bb _, x) () hx ht\n  (\u03bb i hx t ht s _, h\u2080.val_in hx)\n  (\u03bb i hx t ht s _, h\u2081.val_in hx)\n\nlemma surrounding_family_in_sf_homotopy [finite_dimensional \u211d E]\n  (h\u2080 : surrounding_family_in g b \u03b3\u2080 U \u03a9) (h\u2081 : surrounding_family_in g b \u03b3\u2081 U \u03a9) (\u03c4 : \u211d) :\n  surrounding_family_in g b (sf_homotopy h\u2080.to_sf h\u2081.to_sf \u03c4) U \u03a9 :=\n\u27e8surrounding_family_sf_homotopy _, \u03bb x hx t ht s hs, sf_homotopy_in _ _ _ hx ht\u27e9\n\nlemma satisfied_or_refund [finite_dimensional \u211d E] {\u03b3\u2080 \u03b3\u2081 : E \u2192 \u211d \u2192 loop F}\n  (h\u2080 : surrounding_family_in g b \u03b3\u2080 U \u03a9) (h\u2081 : surrounding_family_in g b \u03b3\u2081 U \u03a9) :\n  \u2203 \u03b3 : \u211d \u2192 E \u2192 \u211d \u2192 loop F,\n    (\u2200 \u03c4, surrounding_family_in g b (\u03b3 \u03c4) U \u03a9) \u2227\n    \u03b3 0 = \u03b3\u2080 \u2227\n    \u03b3 1 = \u03b3\u2081 \u2227\n    continuous \u21bf\u03b3 :=\n\u27e8sf_homotopy h\u2080.to_sf h\u2081.to_sf, surrounding_family_in_sf_homotopy h\u2080 h\u2081, sf_homotopy_zero,\n  sf_homotopy_one, continuous_sf_homotopy\u27e9\n\nend satisfied_or_refund\n\nsection extend_loops\n\nvariables [finite_dimensional \u211d E]\n\n/-\nNote: we also want add the condition that `\u03b3 = \u03b3\u2080` outside a neighborhood of `U\u2081\u1d9c`.\nThis makes it easier to find the limit of a sequence of these constructions.\n-/\nlemma extend_loops {U\u2080 U\u2081 K\u2080 K\u2081 : set E} (hU\u2080 : is_open U\u2080) (hU\u2081 : is_open U\u2081)\n  (hK\u2080 : is_closed K\u2080) (hK\u2081 : is_closed K\u2081) (hKU\u2080 : K\u2080 \u2286 U\u2080) (hKU\u2081 : K\u2081 \u2286 U\u2081)\n  {\u03b3\u2080 \u03b3\u2081 : E \u2192 \u211d \u2192 loop F}\n  (h\u2080 : surrounding_family_in g b \u03b3\u2080 U\u2080 \u03a9) (h\u2081 : surrounding_family_in g b \u03b3\u2081 U\u2081 \u03a9) :\n  \u2203 (U \u2208 \ud835\udcdd\u02e2 (K\u2080 \u222a K\u2081)) (\u03b3 : E \u2192 \u211d \u2192 loop F),\n    surrounding_family_in g b \u03b3 U \u03a9 \u2227\n    (\u2200\u1da0 x in \ud835\udcdd\u02e2 K\u2080, \u03b3 x = \u03b3\u2080 x) \u2227\n    (\u2200\u1da0 x in \ud835\udcdd\u02e2 U\u2081\u1d9c, \u03b3 x = \u03b3\u2080 x) :=\nbegin\n  obtain \u27e8V\u2080, hV\u2080, hKV\u2080, hVU\u2080\u27e9 := normal_exists_closure_subset hK\u2080 hU\u2080 hKU\u2080,\n  let L\u2081 := K\u2081 \\ U\u2080,\n  have hL\u2081 : is_closed L\u2081 := hK\u2081.sdiff hU\u2080,\n  have hV\u2080L\u2081 : disjoint (closure V\u2080) L\u2081 := disjoint_sdiff_self_right.mono hVU\u2080 subset.rfl,\n  obtain \u27e8V\u2082, hV\u2082, hLV\u2082, h2V\u2082\u27e9 :=\n  normal_exists_closure_subset hL\u2081\n    (is_closed_closure.is_open_compl.inter hU\u2081)\n    (subset_inter (subset_compl_iff_disjoint_left.mpr hV\u2080L\u2081) $ (diff_subset _ _).trans hKU\u2081),\n  obtain \u27e8V\u2081, hV\u2081, hLV\u2081, hV\u2081\u2082\u27e9 :=\n    normal_exists_closure_subset hL\u2081 hV\u2082 hLV\u2082,\n  rw [subset_inter_iff, subset_compl_iff_disjoint_left] at h2V\u2082,\n  rcases h2V\u2082 with \u27e8hV\u2080\u2082, hV\u2082U\u2081\u27e9,\n  have hVU\u2081 : V\u2081 \u2286 U\u2081 := subset_closure.trans (hV\u2081\u2082.trans $ subset_closure.trans hV\u2082U\u2081),\n  have hdisj : disjoint (closure V\u2080 \u222a V\u2082\u1d9c) (closure V\u2081),\n  { refine disjoint.union_left (hV\u2080\u2082.mono_right (hV\u2081\u2082.trans subset_closure)) _,\n    rw [\u2190 subset_compl_iff_disjoint_left, compl_compl], exact hV\u2081\u2082 },\n  refine \u27e8V\u2080 \u222a (U\u2081 \u2229 U\u2080) \u222a V\u2081, ((hV\u2080.union $ hU\u2081.inter hU\u2080).union hV\u2081).mem_nhds_set.mpr _, _\u27e9,\n  { refine union_subset (hKV\u2080.trans $ (subset_union_left _ _).trans $ subset_union_left _ _) _,\n    rw [\u2190 inter_union_diff K\u2081], exact\n      union_subset_union ((inter_subset_inter_left _ hKU\u2081).trans $ subset_union_right _ _) hLV\u2081 },\n  obtain \u27e8\u03c1, h0\u03c1, h1\u03c1, h\u03c1\u27e9 := exists_continuous_zero_one_of_closed\n    (is_closed_closure.union hV\u2082.is_closed_compl) is_closed_closure hdisj,\n  let h\u2080' : surrounding_family_in g b \u03b3\u2080 (U\u2081 \u2229 U\u2080) \u03a9 := h\u2080.mono (inter_subset_right _ _),\n  let h\u2081' : surrounding_family_in g b \u03b3\u2081 (U\u2081 \u2229 U\u2080) \u03a9 := h\u2081.mono (inter_subset_left _ _),\n  let \u03b3 := sf_homotopy h\u2080'.to_sf h\u2081'.to_sf,\n  have h\u03b3 : \u2200 \u03c4, surrounding_family_in g b (\u03b3 \u03c4) (U\u2081 \u2229 U\u2080) \u03a9 :=\n    surrounding_family_in_sf_homotopy _ _,\n  have heq1 : \u2200 x \u2208 closure V\u2080 \u222a V\u2082\u1d9c, \u03b3 (\u03c1 x) x = \u03b3\u2080 x,\n  { intros x hx, simp_rw [\u03b3, h0\u03c1 hx, pi.zero_apply, sf_homotopy_zero] },\n  have heq2 : \u2200 x \u2208 V\u2080, \u03b3 (\u03c1 x) x = \u03b3\u2080 x :=\n  \u03bb x hx, heq1 x (subset_closure.trans (subset_union_left _ _) hx),\n  refine \u27e8\u03bb x t, \u03b3 (\u03c1 x) x t, _, _, _\u27e9,\n  { refine \u27e8\u27e8\u03bb x, (h\u03b3 $ \u03c1 x).base x, \u03bb x, (h\u03b3 $ \u03c1 x).t\u2080 x,\n      \u03bb x, (h\u03b3 $ \u03c1 x).proj_I x, _, _\u27e9, _\u27e9,\n    { rintro x ((hx|hx)|hx),\n      { simp_rw [heq2 x hx, h\u2080.surrounds x (hVU\u2080 $ subset_closure hx)] },\n      { simp_rw [\u03b3, (h\u03b3 $ \u03c1 x).surrounds x hx] },\n      { simp_rw [\u03b3, h1\u03c1 (subset_closure hx), pi.one_apply, sf_homotopy_one,\n          h\u2081.surrounds x (hVU\u2081 hx)] } },\n    { exact continuous.sf_homotopy \u03c1.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\u03c1x, refine h\u2080.val_in _, rcases hx with (hx|\u27e8-,hx\u27e9)|hx,\n        { exact (subset_closure.trans hVU\u2080) hx },\n        { exact hx },\n        { exact (h\u03c1x $ h1\u03c1 $ subset_closure hx).elim } },\n      { intros x hx t ht s h\u03c1x, refine h\u2081.val_in _, rcases hx with (hx|\u27e8hx,-\u27e9)|hx,\n        { exact (h\u03c1x $ h0\u03c1 $ subset_closure.trans (subset_union_left _ _) hx).elim },\n        { exact hx },\n        { exact hVU\u2081 hx } } } },\n  { exact eventually_of_mem (hV\u2080.mem_nhds_set.mpr hKV\u2080) heq2 },\n  { refine eventually_of_mem\n      (is_closed_closure.is_open_compl.mem_nhds_set.mpr $ compl_subset_compl.mpr hV\u2082U\u2081)\n      (\u03bb 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} (\u03c6 : germ (\ud835\udcdd x) (\u211d \u2192 loop F)) : Prop :=\nquotient.lift_on' \u03c6 (\u03bb \u03b3, \u2200 (t s : \u211d), continuous_at (\u03bb p : E \u00d7 \u211d \u00d7 \u211d, \u03b3 p.1 p.2.1 p.2.2) (x, t, s))\nbegin\n  rintros \u03b3 \u03b3' (h : {x | \u03b3 x = \u03b3' x} \u2208 \ud835\udcdd x),\n  ext,\n  refine forall_congr (\u03bb t, forall_congr (\u03bb s, continuous_at_congr _)),\n  rw [nhds_prod_eq],\n  apply mem_of_superset (filter.prod_mem_prod h univ_mem),\n  rintros \u27e8x', p\u27e9 \u27e8hx' : \u03b3 x' = \u03b3' x', -\u27e9,\n  simp only [mem_set_of_eq, hx']\nend\n\nvariables (g b \u03a9)\n\nstructure loop_family_germ (x : E) (\u03c6 : germ (\ud835\udcdd x) (\u211d \u2192 loop F)) : Prop :=\n(base : \u2200 t, \u03c6.value t 0 = b x)\n(t\u2080 : \u2200 s, \u03c6.value 0 s = b x)\n(proj_I : \u2200 (t : \u211d) (s : \u211d), \u03c6.value (proj_I t) s = \u03c6.value t s)\n(cont : continuous_germ \u03c6)\n\nstructure surrounding_family_germ (x : E) (\u03c6 : germ (\ud835\udcdd x) (\u211d \u2192 loop F)) : Prop :=\n(surrounds : (\u03c6.value 1).surrounds $ g x)\n(val_in' : \u2200 (t \u2208 I) (s \u2208 I), (x, \u03c6.value t s) \u2208 \u03a9)\n\nvariables {g b \u03a9}\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 {\u03b3 : E \u2192 \u211d \u2192 loop F} :\n  surrounding_family_in g b \u03b3 C \u03a9 \u2194 (\u2200 x, loop_family_germ b x \u03b3) \u2227\n                                    (\u2200 x \u2208 C, surrounding_family_germ g \u03a9 x \u03b3) :=\nbegin\n  split,\n  { rintro \u27e8\u27e8base, t\u2080, proj_I, family_surrounds, family_cont\u27e9, H\u27e9,\n    exact \u27e8\u03bb x, \u27e8base x, t\u2080 x, proj_I x, \u03bb t s, family_cont.continuous_at\u27e9,\n           \u03bb x x_in, \u27e8family_surrounds x x_in, H x x_in\u27e9\u27e9 },\n  { rintro \u27e8h, h'\u27e9,\n    refine \u27e8\u27e8\u03bb x, (h x).base, \u03bb x, (h x).t\u2080, \u03bb x, (h x).proj_I,  \u03bb x hx, (h' x hx).surrounds, _\u27e9,\n            \u03bb x hx, (h' x hx).val_in'\u27e9,\n    apply continuous_iff_continuous_at.mpr,\n    rintros \u27e8x, t, s\u27e9,\n    apply (h x).cont }\nend\n\nvariables [finite_dimensional \u211d E] [finite_dimensional \u211d F] [second_countable_topology E]\n\nlemma exists_surrounding_loops\n  (hK : is_closed K)\n  (h\u03a9_op : is_open \u03a9)\n  (hg : \u2200 x, continuous_at g x) (hb : continuous b)\n  (hconv : \u2200 x, g x \u2208 convex_hull \u211d (connected_component_in (prod.mk x \u207b\u00b9' \u03a9) $ b x))\n  {\u03b3\u2080 :  E \u2192 \u211d \u2192 loop F}\n  (h\u03b3\u2080_surr : \u2203 V \u2208 \ud835\udcdd\u02e2 K, surrounding_family_in g b \u03b3\u2080 V \u03a9) :\n  \u2203 \u03b3 : E \u2192 \u211d \u2192 loop F, surrounding_family_in g b \u03b3 univ \u03a9 \u2227 \u2200\u1da0 x in \ud835\udcdd\u02e2 K, \u03b3 x = \u03b3\u2080 x :=\nbegin\n  rcases h\u03b3\u2080_surr with \u27e8V, V_in, hV\u27e9,\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, \u2190 forall_and_distrib],\n  apply inductive_construction' (loop_family_germ b) (surrounding_family_germ g \u03a9) hK hV\n    (mem_of_superset V_in h'V),\n  { intros x,\n    rcases local_loops \u27e8univ, univ_mem, by  simp only [preimage_univ, inter_univ,h\u03a9_op ]\u27e9\n      (hg x) hb (hconv x) with \u27e8\u03b3, U, U_in, H\u27e9,\n    cases surrounding_family_in_iff_germ.mp H with H H',\n    exact \u27e8\u03b3, H, mem_of_superset U_in H'\u27e9 },\n  { intros U\u2081 U\u2082 K\u2081  K\u2082 \u03b3\u2081 \u03b3\u2082 hU\u2081 hU\u2082 hK\u2081 hK\u2082 hKU\u2081 hKU\u2082 h\u03b3\u2081 h\u03b3\u2082 h'\u03b3\u2081 h'\u03b3\u2082,\n    rcases extend_loops hU\u2081 hU\u2082 hK\u2081 hK\u2082 hKU\u2081 hKU\u2082 (surrounding_family_in_iff_germ.mpr \u27e8h\u03b3\u2081, h'\u03b3\u2081\u27e9)\n      (surrounding_family_in_iff_germ.mpr \u27e8h\u03b3\u2082, h'\u03b3\u2082\u27e9) with \u27e8U, U_in, \u03b3, H, H''\u27e9,\n    cases surrounding_family_in_iff_germ.mp H with H H',\n    refine \u27e8\u03b3, H, mem_of_superset U_in H', eventually_nhds_set_union.mpr H''\u27e9 }\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 \u00d7 S) :=\n{ star := \u03bb x, (star x.1, star x.2) }\n\n@[simp] lemma fst_star [has_star R] [has_star S] (x : R \u00d7 S) : (star x).1 = star x.1 := rfl\n@[simp] lemma snd_star [has_star R] [has_star S] (x : R \u00d7 S) : (star x).2 = star x.2 := rfl\n\nlemma star_def [has_star R] [has_star S] (x : R \u00d7 S) : star x = (star x.1, star x.2) := rfl\n\ninstance [has_involutive_star R] [has_involutive_star S] : has_involutive_star (R \u00d7 S) :=\n{ star_involutive := \u03bb _, prod.ext (star_star _) (star_star _) }\n\ninstance [semigroup R] [semigroup S] [star_semigroup R] [star_semigroup S] :\n  star_semigroup (R \u00d7 S) :=\n{ star_mul := \u03bb _ _, 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 \u00d7 S) :=\n{ star_add := \u03bb _ _, 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 \u00d7 S) :=\n{ ..prod.star_add_monoid, ..(prod.star_semigroup : star_semigroup (R \u00d7 S)) }\n\ninstance {\u03b1 : Type w} [has_smul \u03b1 R] [has_smul \u03b1 S] [has_star \u03b1] [has_star R] [has_star S]\n  [star_module \u03b1 R] [star_module \u03b1 S] :\n  star_module \u03b1 (R \u00d7 S) :=\n{ star_smul := \u03bb 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\u02e3) :\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\u00e9mi Bottinelli. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Antoine Labelle, R\u00e9mi 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\u2081 v\u2082 u u\u2081 u\u2082\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 \u27f6 v) : u' \u27f6 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\u2093'. -/\ntheorem Hom.cast_eq_cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u \u27f6 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\u2093'. -/\n@[simp]\ntheorem Hom.cast_rfl_rfl {u v : U} (e : u \u27f6 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\u2093'. -/\n@[simp]\ntheorem Hom.cast_cast {u v u' v' u'' v'' : U} (e : u \u27f6 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\u2093'. -/\ntheorem Hom.cast_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u \u27f6 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\u2093'. -/\ntheorem Hom.cast_eq_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u \u27f6 v) (e' : u' \u27f6 v') :\n    e.cast hu hv = e' \u2194 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\u2093'. -/\ntheorem Hom.eq_cast_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u \u27f6 v) (e' : u' \u27f6 v') :\n    e' = e.cast hu hv \u2194 HEq e' e :=\n  by\n  rw [eq_comm, hom.cast_eq_iff_heq]\n  exact \u27e8HEq.symm, HEq.symm\u27e9\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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' \u2194 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\u2093'. -/\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 \u2194 HEq p' p :=\n  \u27e8fun 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\u27e9\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\u2093'. -/\ntheorem Path.cast_cons {u v w u' w' : U} (p : Path u v) (e : v \u27f6 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\u2093'. -/\ntheorem cast_eq_of_cons_eq_cons {u v v' w : U} {p : Path u v} {p' : Path u v'} {e : v \u27f6 w}\n    {e' : v' \u27f6 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\u2093'. -/\ntheorem hom_cast_eq_of_cons_eq_cons {u v v' w : U} {p : Path u v} {p' : Path u v'} {e : v \u27f6 w}\n    {e' : v' \u27f6 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\u2093'. -/\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 \u27f6 Y`, `\u03c0 : Y \u27f6 Z` to be a split\ncoequalizer: there is a section `s` of `\u03c0` and a section `t` of `g`, which additionally satisfy\n`t \u226b f = \u03c0 \u226b 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 \u27f6 Y` has a split coequalizer if there is a `Z` and `\u03c0 : Y \u27f6 Z` making `f,g,\u03c0` a\nsplit coequalizer.\nA pair `f g : X \u27f6 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\u2082 u u\u2082\n\nvariable {C : Type u} [Category.{v} C]\n\nvariable {D : Type u\u2082} [Category.{v\u2082} D]\n\nvariable (G : C \u2964 D)\n\nvariable {X Y : C} (f g : X \u27f6 Y)\n\n/-- A split coequalizer diagram consists of morphisms\n\n      f   \u03c0\n    X \u21c9 Y \u2192 Z\n      g\n\nsatisfying `f \u226b \u03c0 = g \u226b \u03c0` together with morphisms\n\n      t   s\n    X \u2190 Y \u2190 Z\n\nsatisfying `s \u226b \u03c0 = \ud835\udfd9 Z`, `t \u226b g = \ud835\udfd9 Y` and `t \u226b f = \u03c0 \u226b 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} (\u03c0 : Y \u27f6 Z) where\n  /-- A map from the coequalizer to `Y` -/\n  rightSection : Z \u27f6 Y\n  /-- A map in the opposite direction to `f` and `g` -/\n  leftSection : Y \u27f6 X\n  /-- Composition of `\u03c0` with `f` and with `g` agree -/\n  condition : f \u226b \u03c0 = g \u226b \u03c0\n  /-- `rightSection` splits `\u03c0` -/\n  rightSection_\u03c0 : rightSection \u226b \u03c0 = \ud835\udfd9 Z\n  /-- `leftSection` splits `g` -/\n  leftSection_bottom : leftSection \u226b g = \ud835\udfd9 Y\n  /-- `leftSection` composed with `f` is `pi` composed with `rightSection` -/\n  leftSection_top : leftSection \u226b f = \u03c0 \u226b 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_\u03c0 CategoryTheory.IsSplitCoequalizer.rightSection_\u03c0\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 (\ud835\udfd9 X) (\ud835\udfd9 X) (\ud835\udfd9 X)) where\n  default := \u27e8\ud835\udfd9 X, \ud835\udfd9 X, rfl, Category.id_comp _, Category.id_comp _, rfl\u27e9\n\nopen IsSplitCoequalizer\n\nattribute [reassoc] condition\n\nattribute [reassoc (attr := simp)] rightSection_\u03c0 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} {\u03c0 : Y \u27f6 Z} (q : IsSplitCoequalizer f g \u03c0) (F : C \u2964 D) :\n    IsSplitCoequalizer (F.map f) (F.map g) (F.map \u03c0)\n    where\n  rightSection := F.map q.rightSection\n  leftSection := F.map q.leftSection\n  condition := by rw [\u2190 F.map_comp, q.condition, F.map_comp]\n  rightSection_\u03c0 := by rw [\u2190 F.map_comp, q.rightSection_\u03c0, F.map_id]\n  leftSection_bottom := by rw [\u2190 F.map_comp, q.leftSection_bottom, F.map_id]\n  leftSection_top := by rw [\u2190 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 \u27f6 Z} (t : IsSplitCoequalizer f g h) :\n    Cofork f g := Cofork.of\u03c0 h t.condition\n#align category_theory.is_split_coequalizer.as_cofork CategoryTheory.IsSplitCoequalizer.asCofork\n\n@[simp]\ntheorem IsSplitCoequalizer.asCofork_\u03c0 {Z : C} {h : Y \u27f6 Z} (t : IsSplitCoequalizer f g h) :\n    t.asCofork.\u03c0 = h := rfl\n#align category_theory.is_split_coequalizer.as_cofork_\u03c0 CategoryTheory.IsSplitCoequalizer.asCofork_\u03c0\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 \u27f6 Z} (t : IsSplitCoequalizer f g h) :\n    IsColimit t.asCofork :=\n  Cofork.IsColimit.mk' _ fun s =>\n    \u27e8t.rightSection \u226b s.\u03c0, by\n      dsimp\n      rw [\u2190 t.leftSection_top_assoc, s.condition, t.leftSection_bottom_assoc], fun hm => by\n      simp [\u2190 hm]\u27e9\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 \u27f6 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 : \u2203 (Z : C)(h : Y \u27f6 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 \u27f6 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\u03c0 [HasSplitCoequalizer f g] :\n    Y \u27f6 HasSplitCoequalizer.coequalizerOfSplit f g :=\n  (@splittable _ _ _ _ f g).choose_spec.choose\n#align category_theory.has_split_coequalizer.coequalizer_\u03c0 CategoryTheory.HasSplitCoequalizer.coequalizer\u03c0\n\n/-- The coequalizer morphism `coequalize\u03c0` gives a split coequalizer on `f,g`. -/\nnoncomputable def HasSplitCoequalizer.isSplitCoequalizer [HasSplitCoequalizer f g] :\n    IsSplitCoequalizer f g (HasSplitCoequalizer.coequalizer\u03c0 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    \u27e8_, _, \u27e8IsSplitCoequalizer.map (HasSplitCoequalizer.isSplitCoequalizer f g) _\u27e9\u27e9\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 \u27e8_, (HasSplitCoequalizer.isSplitCoequalizer f g).isCoequalizer\u27e9\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 := \u27e8\u27e9\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 := \u27e8Group.of punit\u27e9\n\n@[to_additive]\ninstance : inhabited Group := \u27e81\u27e9\n\n@[to_additive]\ninstance one.unique : unique (1 : Group) :=\n{ default := 1,\n  uniq := \u03bb a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : Group) (g : G) : (1 : G \u27f6 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\u2082 Group Mon := bundled_hom.forget\u2082 _ _\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 := \u27e8\u27e9\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 := \u27e8CommGroup.of punit\u27e9\n\n@[to_additive] instance : inhabited CommGroup := \u27e81\u27e9\n\n@[to_additive]\ninstance one.unique : unique (1 : CommGroup) :=\n{ default := 1,\n  uniq := \u03bb a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : CommGroup) (g : G) : (1 : G \u27f6 H) g = 1 := rfl\n\n@[to_additive,ext]\nlemma ext (G H : CommGroup) (f\u2081 f\u2082 : G \u27f6 H) (w : \u2200 x, f\u2081 x = f\u2082 x) : f\u2081 = f\u2082 :=\nby { ext1, apply w }\n\nattribute [ext] AddCommGroup.ext\n\n@[to_additive has_forget_to_AddGroup]\ninstance has_forget_to_Group : has_forget\u2082 CommGroup Group := bundled_hom.forget\u2082 _ _\n\n@[to_additive has_forget_to_AddCommMon]\ninstance has_forget_to_CommMon : has_forget\u2082 CommGroup CommMon :=\ninduced_category.has_forget\u2082 (\u03bb 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 \u27f6 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 `\u2124` sending\n`1` to that element. -/\n-- Note that because `\u2124 : 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 \u2124) \u27f6 G :=\ngmultiples_hom G g\n\n@[simp]\nlemma as_hom_apply {G : AddCommGroup.{0}} (g : G) (i : \u2124) : (as_hom g) i = i \u2022 g := rfl\n\nlemma as_hom_injective {G : AddCommGroup.{0}} : function.injective (@as_hom G) :=\n\u03bb h k w, by convert congr_arg (\u03bb k : (AddCommGroup.of \u2124) \u27f6 G, (k : \u2124 \u2192 G) (1 : \u2124)) w; simp\n\n@[ext]\nlemma int_hom_ext\n  {G : AddCommGroup.{0}} (f g : (AddCommGroup.of \u2124) \u27f6 G) (w : f (1 : \u2124) = g (1 : \u2124)) : 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 \u27f6 H) [mono f] : function.injective f :=\n\u03bb g\u2081 g\u2082 h,\nbegin\n  have t0 : as_hom g\u2081 \u226b f = as_hom g\u2082 \u226b f :=\n  begin\n    ext,\n    simpa [as_hom_apply] using h,\n  end,\n  have t1 : as_hom g\u2081 = as_hom g\u2082 := (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 \u2243* Y) : Group.of X \u2245 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 \u2243* Y) :\n  CommGroup.of X \u2245 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 \u2245 Y) : X \u2243* 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 \u2245 Y) : X \u2243* 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 \u2243* Y) \u2245 (Group.of X \u2245 Group.of Y) :=\n{ hom := \u03bb e, e.to_Group_iso,\n  inv := \u03bb 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 \u2243* Y) \u2245 (CommGroup.of X \u2245 CommGroup.of Y) :=\n{ hom := \u03bb e, e.to_CommGroup_iso,\n  inv := \u03bb 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 {\u03b1 : Type u} : Group.of (Aut \u03b1) \u2245 Group.of (equiv.perm \u03b1) :=\n{ hom := \u27e8\u03bb g, g.to_equiv, (by tidy), (by tidy)\u27e9,\n  inv := \u27e8\u03bb g, g.to_iso, (by tidy), (by tidy)\u27e9 }\n\n/-- The (unbundled) group of automorphisms of a type is `mul_equiv` to the (unbundled) group\nof permutations. -/\ndef mul_equiv_perm {\u03b1 : Type u} : Aut \u03b1 \u2243* equiv.perm \u03b1 :=\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 := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Group).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Group_iso).1\u27e9,\n  end }\n\n@[to_additive]\ninstance CommGroup.forget_reflects_isos : reflects_isomorphisms (forget CommGroup.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommGroup).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommGroup_iso).1\u27e9,\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 \u2964 Type u) : cone F :=\n  cone.mk (\u21a5(functor.sections F))\n    (nat_trans.mk\n      fun (j : J) (u : functor.obj (functor.obj (functor.const J) \u21a5(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 \u2964 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.\u03c0 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) (\ud835\udca5 : small_category J) =>\n      has_limits_of_shape.mk fun (F : J \u2964 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 \u2964 Type u} {c : cone F} (t : is_limit c) : cone.X c \u2243 \u21a5(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 \u2964 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.\u03c0 c) j x :=\n  rfl\n\n@[simp] theorem is_limit_equiv_sections_symm_apply {J : Type u} [small_category J] {F : J \u2964 Type u} {c : cone F} (t : is_limit c) (x : \u21a5(functor.sections F)) (j : J) : nat_trans.app (cone.\u03c0 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 \u2964 Type u) : limit F \u2243 \u21a5(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 \u2964 Type u) (x : limit F) (j : J) : coe (coe_fn (limit_equiv_sections F) x) j = limit.\u03c0 F j x :=\n  rfl\n\n@[simp] theorem limit_equiv_sections_symm_apply {J : Type u} [small_category J] (F : J \u2964 Type u) (x : \u21a5(functor.sections F)) (j : J) : limit.\u03c0 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 : \u03a0 j, F.obj j`\nwhich are \"coherent\": `\u2200 (j j') (f : j \u27f6 j'), F.map f (x j) = x j'`.\n-/\ndef limit.mk {J : Type u} [small_category J] (F : J \u2964 Type u) (x : (j : J) \u2192 functor.obj F j) (h : \u2200 (j j' : J) (f : j \u27f6 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.\u03c0_mk {J : Type u} [small_category J] (F : J \u2964 Type u) (x : (j : J) \u2192 functor.obj F j) (h : \u2200 (j j' : J) (f : j \u27f6 j'), functor.map F f (x j) = x j') (j : J) : limit.\u03c0 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 \u2964 Type u) (x : limit F) (y : limit F) (w : \u2200 (j : J), limit.\u03c0 F j x = limit.\u03c0 F j y) : x = y := sorry\n\ntheorem limit_ext_iff {J : Type u} [small_category J] (F : J \u2964 Type u) (x : limit F) (y : limit F) : x = y \u2194 \u2200 (j : J), limit.\u03c0 F j x = limit.\u03c0 F j y :=\n  { mp := fun (t : x = y) (_x : J) => t \u25b8 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 \u2964 Type u} {j : J} {j' : J} {x : limit F} (f : j \u27f6 j') : functor.map F f (limit.\u03c0 F j x) = limit.\u03c0 F j' x :=\n  congr_fun (limit.w F f) x\n\n@[simp] theorem limit.lift_\u03c0_apply {J : Type u} [small_category J] (F : J \u2964 Type u) (s : cone F) (j : J) (x : cone.X s) : limit.\u03c0 F j (limit.lift F s x) = nat_trans.app (cone.\u03c0 s) j x :=\n  congr_fun (limit.lift_\u03c0 s j) x\n\n@[simp] theorem limit.map_\u03c0_apply {J : Type u} [small_category J] {F : J \u2964 Type u} {G : J \u2964 Type u} (\u03b1 : F \u27f6 G) (j : J) (x : limit F) : limit.\u03c0 G j (lim_map \u03b1 x) = nat_trans.app \u03b1 j (limit.\u03c0 F j x) :=\n  congr_fun (lim_map_\u03c0 \u03b1 j) x\n\n/--\nThe relation defining the quotient type which implements the colimit of a functor `F : J \u2964 Type u`.\nSee `category_theory.limits.types.quot`.\n-/\ndef quot.rel {J : Type u} [small_category J] (F : J \u2964 Type u) : (sigma fun (j : J) => functor.obj F j) \u2192 (sigma fun (j : J) => functor.obj F j) \u2192 Prop :=\n  fun (p p' : sigma fun (j : J) => functor.obj F j) =>\n    \u2203 (f : sigma.fst p \u27f6 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 \u2964 Type u`,\nas pairs `\u27e8j, x\u27e9` where `x : F.obj j`, modulo the equivalence relation generated by\n`\u27e8j, x\u27e9 ~ \u27e8j', x'\u27e9` whenever there is a morphism `f : j \u27f6 j'` so `F.map f x = x'`.\n-/\ndef quot {J : Type u} [small_category J] (F : J \u2964 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 \u2964 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 \u2964 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.\u03b9 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) (\ud835\udca5 : small_category J) =>\n      has_colimits_of_shape.mk\n        fun (F : J \u2964 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 \u2964 Type u) : colimit F \u2243 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 \u2964 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.\u03b9 F j x :=\n  rfl\n\n@[simp] theorem colimit_equiv_quot_apply {J : Type u} [small_category J] (F : J \u2964 Type u) (j : J) (x : functor.obj F j) : coe_fn (colimit_equiv_quot F) (colimit.\u03b9 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 \u2964 Type u} {j : J} {j' : J} {x : functor.obj F j} (f : j \u27f6 j') : colimit.\u03b9 F j' (functor.map F f x) = colimit.\u03b9 F j x :=\n  congr_fun (colimit.w F f) x\n\n@[simp] theorem colimit.\u03b9_desc_apply {J : Type u} [small_category J] (F : J \u2964 Type u) (s : cocone F) (j : J) (x : functor.obj F j) : colimit.desc F s (colimit.\u03b9 F j x) = nat_trans.app (cocone.\u03b9 s) j x :=\n  congr_fun (colimit.\u03b9_desc s j) x\n\n@[simp] theorem colimit.\u03b9_map_apply {J : Type u} [small_category J] {F : J \u2964 Type u} {G : J \u2964 Type u} (\u03b1 : F \u27f6 G) (j : J) (x : functor.obj F j) : functor.map colim \u03b1 (colimit.\u03b9 F j x) = colimit.\u03b9 G j (nat_trans.app \u03b1 j x) :=\n  congr_fun (colimit.\u03b9_map \u03b1 j) x\n\ntheorem colimit_sound {J : Type u} [small_category J] {F : J \u2964 Type u} {j : J} {j' : J} {x : functor.obj F j} {x' : functor.obj F j'} (f : j \u27f6 j') (w : functor.map F f x = x') : colimit.\u03b9 F j x = colimit.\u03b9 F j' x' := sorry\n\ntheorem colimit_sound' {J : Type u} [small_category J] {F : J \u2964 Type u} {j : J} {j' : J} {x : functor.obj F j} {x' : functor.obj F j'} {j'' : J} (f : j \u27f6 j'') (f' : j' \u27f6 j'') (w : functor.map F f x = functor.map F f' x') : colimit.\u03b9 F j x = colimit.\u03b9 F j' x' := sorry\n\ntheorem colimit_eq {J : Type u} [small_category J] {F : J \u2964 Type u} {j : J} {j' : J} {x : functor.obj F j} {x' : functor.obj F j'} (w : colimit.\u03b9 F j x = colimit.\u03b9 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 \u2964 Type u) {t : cocone F} (h : is_colimit t) (x : cocone.X t) : \u2203 (j : J), \u2203 (y : functor.obj F j), nat_trans.app (cocone.\u03b9 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 \u2964 Type u} (x : colimit F) : \u2203 (j : J), \u2203 (y : functor.obj F j), colimit.\u03b9 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 `\u03a3 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 \u2964 Type u) (x : sigma fun (j : J) => functor.obj F j) (y : sigma fun (j : J) => functor.obj F j) :=\n  \u2203 (k : J),\n    \u2203 (f : sigma.fst x \u27f6 k), \u2203 (g : sigma.fst y \u27f6 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 \u2964 Type u) (x : sigma fun (j : J) => functor.obj F j) (y : sigma fun (j : J) => functor.obj F j) : (\u2203 (f : sigma.fst x \u27f6 sigma.fst y), sigma.snd y = functor.map F f (sigma.snd x)) \u2192 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 \u2964 Type u) (t : cocone F) (hsurj : \u2200 (x : cocone.X t), \u2203 (i : J), \u2203 (xi : functor.obj F i), x = nat_trans.app (cocone.\u03b9 t) i xi) (hinj : \u2200 (i j : J) (xi : functor.obj F i) (xj : functor.obj F j),\n  nat_trans.app (cocone.\u03b9 t) i xi = nat_trans.app (cocone.\u03b9 t) j xj \u2192\n    \u2203 (k : J), \u2203 (f : i \u27f6 k), \u2203 (g : j \u27f6 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 \u2964 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 \u2964 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      \u2203 (f : sigma.fst x \u27f6 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 \u2964 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.\u03b9 (colimit_cocone F)) i xi = nat_trans.app (cocone.\u03b9 (colimit_cocone F)) j xj \u2194\n  \u2203 (k : J), \u2203 (f : i \u27f6 k), \u2203 (g : j \u27f6 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 \u2964 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.\u03b9 t) i xi = nat_trans.app (cocone.\u03b9 t) j xj \u2194\n  \u2203 (k : J), \u2203 (f : i \u27f6 k), \u2203 (g : j \u27f6 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 \u2964 Type u) [is_filtered_or_empty J] {i : J} {j : J} {xi : functor.obj F i} {xj : functor.obj F j} : colimit.\u03b9 F i xi = colimit.\u03b9 F j xj \u2194 \u2203 (k : J), \u2203 (f : i \u27f6 k), \u2203 (g : j \u27f6 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 {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2) :=\n  \u21a5(set.range f)\n\nprotected instance image.inhabited {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2) [Inhabited \u03b1] : Inhabited (image f) :=\n  { default := { val := f Inhabited.default, property := sorry } }\n\n/-- the inclusion of `image f` into the target -/\ndef image.\u03b9 {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2) : image f \u27f6 \u03b2 :=\n  subtype.val\n\nprotected instance image.\u03b9.category_theory.mono {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2) : mono (image.\u03b9 f) :=\n  iff.mpr (mono_iff_injective (image.\u03b9 f)) subtype.val_injective\n\n/-- the universal property for the image factorisation -/\ndef image.lift {\u03b1 : Type u} {\u03b2 : Type u} {f : \u03b1 \u27f6 \u03b2} (F' : mono_factorisation f) : image f \u27f6 mono_factorisation.I F' :=\n  fun (x : image f) =>\n    mono_factorisation.e F'\n      (subtype.val (classical.indefinite_description (fun (x_1 : \u03b1) => f x_1 = subtype.val x) sorry))\n\ntheorem image.lift_fac {\u03b1 : Type u} {\u03b2 : Type u} {f : \u03b1 \u27f6 \u03b2} (F' : mono_factorisation f) : image.lift F' \u226b mono_factorisation.m F' = image.\u03b9 f := sorry\n\n/-- the factorisation of any morphism in Type through a mono. -/\ndef mono_factorisation {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2) : mono_factorisation f :=\n  mono_factorisation.mk (image f) (image.\u03b9 f) (set.range_factorization f)\n\n/-- the facorisation through a mono has the universal property of the image. -/\ndef is_image {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2) : is_image (mono_factorisation f) :=\n  is_image.mk image.lift\n\nprotected instance category_theory.limits.has_image {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u27f6 \u03b2) : 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 \u00a9 2019 Fran\u00e7ois 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 {\u03b1 : Type u} : list \u03b1 \u2192 Type u\n| head (x : \u03b1) (xs : list \u03b1) : index (x :: xs)\n| tail (x : \u03b1) (xs : list \u03b1) : index xs \u2192 index (x :: xs)\n\nnamespace index\nvariable {\u03b1 : Type*}\n\n@[reducible]\ndefinition val : \u03a0 {xs : list \u03b1}, index xs \u2192 \u03b1\n| _ (index.head x _) := x\n| _ (index.tail _ _ i) := val i\n\n@[simp] theorem val_head (x : \u03b1) (xs : list \u03b1) : val (index.head x xs) = x := rfl\n\n@[simp] theorem val_tail (x : \u03b1) (xs : list \u03b1) (i : index xs) : val (index.tail x xs i) = val i := rfl\n\ndefinition nil_elim {C : Sort*} : \u03a0 (i : index (@list.nil \u03b1)), C .\n\n@[simp] theorem val_eq_rec : \u03a0 {xs ys : list \u03b1} (h : xs = ys) (i : index xs), val (eq.rec_on h i : index ys) = i.val\n| _ _ rfl _ := rfl\n\nsection map\nvariables {\u03b2 : Type*} (f : \u03b1 \u2192 \u03b2)\n\ndefinition map : \u03a0 {xs : list \u03b1}, index xs \u2192 index (xs.map f)\n| _ (index.head _ _) := index.head _ _\n| _ (index.tail _ _ i) := index.tail _ _ (map i)\n\n@[simp] theorem map_head (x : \u03b1) (xs : list \u03b1) : map f (index.head x xs) = index.head (f x) (xs.map f) := rfl\n\n@[simp] theorem map_tail (x : \u03b1) (xs : list \u03b1) (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 : \u2200 {xs : list \u03b1} (i : index xs), (i.map f).val = f i.val\n| _ (index.head _ _) := rfl\n| _ (index.tail _ _ i) := val_map i\n\ndefinition unmap : \u03a0 {xs : list \u03b1}, index (xs.map f) \u2192 index xs\n| (_::_) (index.head _ _) := index.head _ _\n| (_::_) (index.tail _ _ i) := index.tail _ _ (unmap i)\n\n@[simp] theorem map_unmap : \u2200 {xs : list \u03b1} (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 : \u2200 {xs : list \u03b1} (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 : \u03a0 (xs ys : list \u03b1), index xs \u2192 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 : \u2200 (xs ys : list \u03b1) (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 : \u03a0 (xs ys : list \u03b1), index ys \u2192 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 : \u2200 (xs ys : list \u03b1) (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 : \u03a0 (xss : list (list \u03b1)) (i : index xss), index i.val \u2192 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 : \u2200 (xss : list (list \u03b1)) (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 : \u03a0 (xs : list \u03b1), list (index xs)\n| [] := []\n| (x :: xs) := (index.head x xs) :: list.map (index.tail x xs) (iota xs)\n\ndefinition iota_index : \u03a0 {xs : list \u03b1}, index xs \u2192 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 : \u03a0 {xs : list \u03b1} (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 : \u03a0 {xs : list \u03b1}, index xs \u2192 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 : \u03a0 {xs : list \u03b1}, fin xs.length \u2192 index xs\n| [] \u27e8i, hi\u27e9 := absurd hi (nat.not_lt_zero i)\n| (x :: xs) \u27e80, _\u27e9 := index.head x xs\n| (x :: xs) \u27e8i+1, hi\u27e9 := index.tail x xs (of_fin \u27e8i, nat.lt_of_succ_lt_succ hi\u27e9)\n\nabbreviation to_nat {xs : list \u03b1} (i : index xs) : nat := (to_fin i).val\n\ntheorem to_nat_lt_lenth {xs : list \u03b1} (i : index xs) : i.to_nat < xs.length := (to_fin i).is_lt\n\ndefinition of_nat {xs : list \u03b1} (i : nat) : option (index xs) :=\nif hi : i < xs.length then some (of_fin \u27e8i, hi\u27e9) else none\n\nabbreviation of_nat_lt_length {xs : list \u03b1} (i : nat) : i < xs.length \u2192 index xs := \u03bb hi, of_fin \u27e8i, hi\u27e9\n\nabbreviation dtup {xs : list \u03b1} (\u03b2 : index xs \u2192 Sort*) := \u03a0 i, \u03b2 i\n\nnamespace dtup\n\nsection nil\nvariable {\u03b2 : index (@list.nil \u03b1) \u2192 Sort*}\n\ndefinition nil : \u03a0 i, \u03b2 i .\n\n@[simp] theorem eq_nil (t : \u03a0 i, \u03b2 i) : t = nil := funext $ \u03bb i, nil i\n\ntheorem eq_of_nil (t\u2081 t\u2082 : \u03a0 i, \u03b2 i) : t\u2081 = t\u2082 := by rw [dtup.eq_nil t\u2081, dtup.eq_nil t\u2082]\n\nend nil\n\nsection cons\nvariables {x : \u03b1} {xs : list \u03b1} {\u03b2 : index (x :: xs) \u2192 Sort*}\n\nabbreviation head : (\u03a0 i, \u03b2 i) \u2192 \u03b2 (index.head x xs) := \u03bb t, t (index.head x xs) \n\nabbreviation tail : (\u03a0 i, \u03b2 i) \u2192 (\u03a0 i, \u03b2 (index.tail x xs i)) := \u03bb t i, t (index.tail x xs i) \n\ndefinition cons : head \u03b2 \u2192 (\u03a0 i, tail \u03b2 i) \u2192 (\u03a0 i, \u03b2 i)\n| h _ (index.head _ _) := h\n| _ t (index.tail _ _ i) := t i\n\n@[simp] theorem cons_head_tail (t : \u03a0 i, \u03b2 i) : cons (head t) (tail t) = t :=\nfunext $ \u03bb i, match i with\n| (index.head _ _) := rfl\n| (index.tail _ _ i) := rfl\nend\n\nvariables (h : head \u03b2) (t : \u03a0 i, tail \u03b2 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 \u03b1} {\u03b2 : index xs \u2192 Type*} (t : \u03a0 i, \u03b2 i) \n\nabbreviation enum : list (sigma \u03b2) := list.map (\u03bb i, \u27e8i, t i\u27e9) (iota xs)\n\nabbreviation enum_index : index xs \u2192 index (enum t) := \u03bb i, map _ (iota_index i)\n\n@[simp] theorem enum_index_val (i : index xs) : (enum_index t i).val = \u27e8i, t i\u27e9 :=\nby rw [val_map, iota_index_val]\n\nend enum\n\nabbreviation to_list {xs : list \u03b1} {\u03b2 : Type*} (t : index xs \u2192 \u03b2) : list \u03b2 :=\nlist.map (\u03bb (z : sigma (\u03bb _, \u03b2)), sigma.snd z) (enum t)\n\nabbreviation to_list_index {xs : list \u03b1} {\u03b2 : Type*} (t : index xs \u2192 \u03b2) : index xs \u2192 index (to_list t) :=\n\u03bb i, index.map (\u03bb (z : sigma (\u03bb _, \u03b2)), sigma.snd z) (enum_index t i)\n\n@[simp] theorem to_list_index_val {xs : list \u03b1} {\u03b2 : Type*} (t : index xs \u2192 \u03b2) (i : index xs) : (to_list_index t i).val = t i :=\nby rw [val_map, enum_index_val]\n\nsection fold\n\ndefinition foldl : \u03a0 {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {\u03b3 : Sort*} (f : \u03a0 {{i}}, \u03b3 \u2192 \u03b2 i \u2192 \u03b3), \u03b3 \u2192 (\u03a0 i, \u03b2 i) \u2192 \u03b3\n| [] _ _ _ z _ := z\n| (_::_) _ _ f z t := f (foldl (tail f) z (tail t)) (head t)\n\ndefinition foldr : \u03a0 {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {\u03b3 : Sort*} (f : \u03a0 {{i}}, \u03b2 i \u2192 \u03b3 \u2192 \u03b3), \u03b3 \u2192 (\u03a0 i, \u03b2 i) \u2192 \u03b3\n| [] _ _ _ z _ := z\n| (_::_) _ _ f z t := f (head t) (foldr (tail f) z (tail t))\n\n@[simp] theorem foldl_nil {\u03b2 : index (@list.nil \u03b1) \u2192 Sort*} {\u03b3 : Sort*} (f : \u03a0 {{i}}, \u03b3 \u2192 \u03b2 i \u2192 \u03b3) (z : \u03b3) :\nfoldl f z nil = z := rfl\n\n@[simp] theorem foldr_nil {\u03b2 : index (@list.nil \u03b1) \u2192 Sort*} {\u03b3 : Sort*} (f : \u03a0 {{i}}, \u03b2 i \u2192 \u03b3 \u2192 \u03b3) (z : \u03b3) :\nfoldr f z nil = z := rfl\n\nvariables {x : \u03b1} {xs : list \u03b1} {\u03b2 : index (x :: xs) \u2192 Sort*} {\u03b3 : Sort*}\n\n@[simp] theorem foldl_cons (f : \u03a0 {{i}}, \u03b3 \u2192 \u03b2 i \u2192 \u03b3) (z : \u03b3) (h : head \u03b2) (t : \u03a0 i, tail \u03b2 i) :\nfoldl f z (cons h t) = f (foldl (tail f) z t) h := rfl\n\n@[simp] theorem foldr_cons (f : \u03a0 {{i}}, \u03b2 i \u2192 \u03b3 \u2192 \u03b3) (z : \u03b3) (h : head \u03b2) (t : \u03a0 i, tail \u03b2 i) :\nfoldr f z (cons h t) = f h (foldr (tail f) z t) := rfl\n\n@[simp] theorem foldl_head_tail (f : \u03a0 {{i}}, \u03b3 \u2192 \u03b2 i \u2192 \u03b3) (z : \u03b3) (t : \u03a0 i, \u03b2 i) :\nfoldl f z t = f (foldl (tail f) z (tail t)) (head t) := rfl\n\n@[simp] theorem foldr_head_tail (f : \u03a0 {{i}}, \u03b2 i \u2192 \u03b3 \u2192 \u03b3) (z : \u03b3) (t : \u03a0 i, \u03b2 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 : \u03a0 {xs : list \u03b1} (p : index xs \u2192 Prop) (dp : \u2200 i, decidable (p i)), decidable (\u2203 i, p i)\n| [] _ _ := decidable.is_false (\u03bb \u27e8i,_\u27e9, 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 $ \u03bb i hi, \u27e8_, hi\u27e9)\n  | decidable.is_false ht :=\n    match dtup.head dp with\n    | decidable.is_true hh := decidable.is_true \u27e8_, hh\u27e9\n    | decidable.is_false hh :=\n      have \u00ac \u2203 i, p i, \n      begin\n      intro h,\n      cases h with i hi,\n      cases i,\n      exact hh hi,\n      exact ht \u27e8_, hi\u27e9,\n      end,\n      decidable.is_false this\n    end\n  end\n\ninstance decidable_exists {xs : list \u03b1} (p : index xs \u2192 Prop) [dp : \u03a0 i, decidable (p i)] : decidable (\u2203 i, p i) := decidable_exists_def p dp\n\ndefinition decidable_forall_def : \u03a0 {xs : list \u03b1} (p : index xs \u2192 Prop) (dp : \u2200 i, decidable (p i)), decidable (\u2200 i, p i)\n| [] _ _ := decidable.is_true (\u03bb 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 (\u03bb h, ht (dtup.tail h))\n  | decidable.is_true ht :=\n    match dtup.head dp with\n    | decidable.is_false hh := decidable.is_false (\u03bb 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 \u03b1} (p : index xs \u2192 Prop) [dp : \u03a0 i, decidable (p i)] : decidable (\u2200 i, p i) := decidable_forall_def p dp\n\ntheorem choice : \u2200 {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*}, (\u2200 i, nonempty (\u03b2 i)) \u2192 nonempty (\u03a0 i, \u03b2 i)\n| [] _ _ := nonempty.intro dtup.nil\n| (_::_) C H := \n  have Hh : nonempty (dtup.head C), from dtup.head H,\n  have Ht : nonempty (\u03a0 i, dtup.tail C i), from choice (dtup.tail H),\n  nonempty.elim Hh $ \u03bb h, nonempty.elim Ht $ \u03bb t, nonempty.intro (dtup.cons h t)\n\nsection relation\nopen relation\n\ntheorem ec_of_ec_tail {x : \u03b1} {xs : list \u03b1} {\u03b2 : index (x :: xs) \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hhr : reflexive (dtup.head r)) {h : dtup.head \u03b2} {t\u2081 t\u2082 : \u03a0 i, dtup.tail \u03b2 i} :\nec (pi (dtup.tail r)) t\u2081 t\u2082 \u2192 ec (pi r) (dtup.cons h t\u2081) (dtup.cons h t\u2082) :=\n\u03bb e, ec.rec_on e\n  (\u03bb _ _ hxy, ec.base $ dtup.cons (hhr h) hxy) \n  (\u03bb _, ec.refl _) \n  (\u03bb _ _ _ _ _ hxy hxz, ec.eucl hxy hxz)\n\ntheorem ec_of_ec_head {x : \u03b1} {xs : list \u03b1} {\u03b2 : index (x :: xs) \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (htr : reflexive (pi (dtup.tail r))) {h\u2081 h\u2082 : dtup.head \u03b2} {t : \u03a0 i, dtup.tail \u03b2 i} :\nec (dtup.head r) h\u2081 h\u2082 \u2192 ec (pi r) (dtup.cons h\u2081 t) (dtup.cons h\u2082 t) :=\n\u03bb e, ec.rec_on e\n  (\u03bb _ _ hxy, ec.base $ dtup.cons hxy (htr _)) \n  (\u03bb _, ec.refl _) \n  (\u03bb _ _ _ _ _ hxy hxz, ec.eucl hxy hxz)\n\ntheorem ec_of_ec_head_tail {x : \u03b1} {xs : list \u03b1} {\u03b2 : index (x :: xs) \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hr : \u2200 i, reflexive (r i)) {h\u2081 h\u2082 : dtup.head \u03b2} {t\u2081 t\u2082 : \u03a0 i, dtup.tail \u03b2 i} :\nec (dtup.head r) h\u2081 h\u2082 \u2192 ec (pi (dtup.tail r)) t\u2081 t\u2082 \u2192 ec (pi r) (dtup.cons h\u2081 t\u2081) (dtup.cons h\u2082 t\u2082) :=\n\u03bb 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\u2081 : ec (pi r) (dtup.cons h\u2081 t\u2081) (dtup.cons h\u2082 t\u2081), from ec_of_ec_head htr eh, \nhave e\u2082 : ec (pi r) (dtup.cons h\u2082 t\u2081) (dtup.cons h\u2082 t\u2082), from ec_of_ec_tail hhr et,\nec.trans e\u2081 e\u2082\n\ntheorem ec_pi_of_pi_ec : \u2200 {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hr : \u2200 i, reflexive (r i)) {t\u2081 t\u2082 : \u03a0 i, \u03b2 i}, pi (\u03bb i, ec (r i)) t\u2081 t\u2082 \u2192 ec (pi r) t\u2081 t\u2082\n| [] _ _ _ t\u2081 t\u2082 _ := by { rw [dtup.eq_nil t\u2081, dtup.eq_nil t\u2082], apply ec.refl _ }\n| (_::_) _ r hr t\u2081 t\u2082 h :=\n  have eh : ec (dtup.head r) (dtup.head t\u2081) (dtup.head t\u2082), from dtup.head h,\n  have et : ec (pi (dtup.tail r)) (dtup.tail t\u2081) (dtup.tail t\u2082), from ec_pi_of_pi_ec (dtup.tail hr) (dtup.tail h),\n  by {rw [\u2190 dtup.cons_head_tail t\u2081, \u2190 dtup.cons_head_tail t\u2082], exact ec_of_ec_head_tail hr eh et }\n\nvariables {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hr : \u2200 i, reflexive (r i))\n\ntheorem pi_ec_iff_ec_pi (t\u2081 t\u2082 : \u03a0 i, \u03b2 i) : pi (\u03bb i, ec (r i)) t\u2081 t\u2082 \u2194 ec (pi r) t\u2081 t\u2082 :=\n\u27e8ec_pi_of_pi_ec hr, pi_ec_of_ec_pi\u27e9\n\ntheorem pi_ec_eq_ec_pi : pi (\u03bb i, ec (r i)) = ec (pi r) :=\nfunext $ \u03bb t\u2081, funext $ \u03bb t\u2082, propext $ pi_ec_iff_ec_pi hr t\u2081 t\u2082\n\nend relation\n\nsection setoid\n\ninstance setoid {xs : list \u03b1} (\u03b2 : index xs \u2192 Sort*) [\u03a0 i, setoid (\u03b2 i)] : setoid (\u03a0 i, \u03b2 i) :=\n{ r := \u03bb x y, \u2200 i, x i \u2248 y i\n, iseqv := mk_equivalence _\n  (\u03bb x i, setoid.refl (x i))\n  (\u03bb _ _ h i, setoid.symm (h i))\n  (\u03bb _ _ _ hxy hyz i, setoid.trans (hxy i) (hyz i))\n}\n\ntheorem setoid.r_iff {xs : list \u03b1} {C : index xs \u2192 Sort*} [\u03a0 i, setoid (C i)] (t\u2081 t\u2082 : \u03a0 i, C i) :\nt\u2081 \u2248 t\u2082 \u2194 (\u2200 i, t\u2081 i \u2248 t\u2082 i) := iff.rfl\n\ntheorem setoid.r_cons_iff {x : \u03b1} {xs : list \u03b1} {C : index (x :: xs) \u2192 Sort*} [\u03a0 i, setoid (C i)] (t\u2081 t\u2082 : \u03a0 i, C i) :\nt\u2081 \u2248 t\u2082 \u2194 dtup.head t\u2081 \u2248 dtup.head t\u2082 \u2227 dtup.tail t\u2081 \u2248 dtup.tail t\u2082 :=\n\u27e8 \u03bb h, have h : \u2200 i, t\u2081 i \u2248 t\u2082 i, from (setoid.r_iff t\u2081 t\u2082).mp h, \u27e8dtup.head h, dtup.tail h\u27e9\n, \u03bb \u27e8hh, ht\u27e9, have h : \u2200 i, t\u2081 i \u2248 t\u2082 i, from dtup.cons hh ht, (setoid.r_iff t\u2081 t\u2082).mpr h\n\u27e9\n\ntheorem setoid.r_cons {x : \u03b1} {xs : list \u03b1} {C : index (x :: xs) \u2192 Sort*} [\u03a0 i, setoid (C i)]\n(h\u2081 h\u2082 : dtup.head C) (t\u2081 t\u2082 : \u03a0 i, dtup.tail C i) : h\u2081 \u2248 h\u2082 \u2192 t\u2081 \u2248 t\u2082 \u2192 dtup.cons h\u2081 t\u2081 \u2248 dtup.cons h\u2082 t\u2082 :=\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 {\u03b1 : Type*}\n\nabbreviation index_mk {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} (r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop) (t : \u03a0 i, \u03b2 i) : \u03a0 i, quot (r i) := \u03bb i, quot.mk (r i) (t i)\n\n@[elab_as_eliminator]\ntheorem index_ind : \u2200 {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hr : \u2200 i, reflexive (r i)) {P : (\u03a0 i, quot (r i)) \u2192 Prop},\n(\u2200 (t : \u03a0 i, \u03b2 i), P (\u03bb i, quot.mk (r i) (t i))) \u2192 \u2200 q, P q\n| [] \u03b2 r hr P H q := by { rw [dtup.eq_nil q, \u2190 dtup.eq_nil (\u03bb i, @quot.mk (\u03b2 i) (r i) (dtup.nil i))], apply H }\n| (x::xs) \u03b2 r hr P H q :=\n  have \u2200 (h : dtup.head \u03b2) (t : \u03a0 i, dtup.tail \u03b2 i), (\u03bb i, quot.mk (r i) (dtup.cons h t i)) = dtup.cons (quot.mk (dtup.head r) h) (\u03bb i, quot.mk (dtup.tail r i) (t i)), by { intros, funext i, cases i; reflexivity },\n  have IH : \u2200 (h : dtup.head \u03b2) (q : \u03a0 i, quot (dtup.tail r i)), P (dtup.cons (quot.mk (dtup.head r) h) q),\n  from \u03bb h q, index_ind (dtup.tail hr) (by {introv, rw \u2190 this, apply H}) q,\n  begin\n  rw [\u2190 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 \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hr : \u2200 i, reflexive (r i)) {P : (\u03a0 i, quot (r i)) \u2192 Prop} (q : \u03a0 i, quot (r i)) :\n(\u2200 (t : \u03a0 i, \u03b2 i), P (\u03bb i, quot.mk (r i) (t i))) \u2192 P q :=\n\u03bb H, index_ind hr H q\n\ndef index_map {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} (r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop) :\nquot (pi r) \u2192 \u03a0 i, quot (r i) :=\nquot.lift (\u03bb (t : \u03a0 i, \u03b2 i) (i : index xs), quot.mk (r i) (t i)) $\n\u03bb (t\u2081 t\u2082 : \u03a0 i, \u03b2 i) (h : pi r t\u2081 t\u2082), funext $ \u03bb i, quot.sound (h i)\n\ndef index_map_beta {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (t : \u03a0 i, \u03b2 i) :\nindex_map r (quot.mk (pi r) t) = \u03bb i, quot.mk (r i) (t i) := rfl\n\nsection index_cons\nvariables {x : \u03b1} {xs : list \u03b1} {\u03b2 : index (x :: xs) \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop}\n\ndef index_cons_func (hr : reflexive (dtup.head r)) : dtup.head \u03b2 \u2192 quot (pi (dtup.tail r)) \u2192 quot (pi r) :=\n\u03bb h, quot.lift (\u03bb t, quot.mk (pi r) (dtup.cons h t)) $\n\u03bb t\u2081 t\u2082 ht, quot.sound (dtup.cons (hr h) ht)\n\ntheorem index_cons_func_beta {hr : reflexive (dtup.head r)} (h : dtup.head \u03b2) (t : \u03a0 i, dtup.tail \u03b2 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 : \u2200 i, reflexive (r i)) : quot (dtup.head r) \u2192 quot (pi (dtup.tail r)) \u2192 quot (pi r) :=\nquot.lift (index_cons_func (dtup.head hr)) $\nbegin\nintros h\u2081 h\u2082 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 : \u2200 i, reflexive (r i)} (h : dtup.head \u03b2) (t : \u03a0 i, dtup.tail \u03b2 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 : \u03a0 {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hr : \u03a0 i, reflexive (r i)), \n(\u03a0 i, quot (r i)) \u2192 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 {\u03b2 : index (@list.nil \u03b1) \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u03a0 i, reflexive (r i)} :\nindex_inv hr dtup.nil = quot.mk (pi r) dtup.nil := rfl\n\ntheorem index_inv_cons {x : \u03b1} {xs : list \u03b1} {\u03b2 : index (x :: xs) \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u03a0 i, reflexive (r i)} (h : quot (dtup.head r)) (t : \u03a0 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 : \u03b1} {xs : list \u03b1} {\u03b2 : index (x :: xs) \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u03a0 i, reflexive (r i)} (q : \u03a0 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 : \u03a0 {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u03a0 i, reflexive (r i)} (t : \u03a0 i, \u03b2 i), \nindex_inv hr (\u03bb i, quot.mk (r i) (t i)) = quot.mk (pi r) t\n| [] _ _ _ t := by { rw [dtup.eq_nil t], reflexivity }\n| (x::xs) \u03b2 r hr t := by { rw [index_inv_head_tail, index_inv_beta, index_cons_beta], simp }\n\ntheorem index_inv_map {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u2200 i, reflexive (r i)} :\n\u2200 (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 \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u2200 i, reflexive (r i)} :\n\u2200 (q : \u03a0 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 \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hr : \u03a0 i, reflexive (r i)) {\u03b3 : Sort*} (f : (\u03a0 i, \u03b2 i) \u2192 \u03b3) :\n(\u2200 t\u2081 t\u2082, pi r t\u2081 t\u2082 \u2192 f t\u2081 = f t\u2082) \u2192 (\u03a0 i, quot (r i)) \u2192 \u03b3 := \u03bb H q, quot.lift f H (index_inv hr q)\n\n@[elab_as_eliminator, reducible]\nabbreviation index_lift_on {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} (hr : \u03a0 i, reflexive (r i)) (q : \u03a0 i, quot (r i)) {\u03b3 : Sort*} (f : (\u03a0 i, \u03b2 i) \u2192 \u03b3) :\n(\u2200 t\u2081 t\u2082, pi r t\u2081 t\u2082 \u2192 f t\u2081 = f t\u2082) \u2192 \u03b3 := \u03bb H, index_lift hr f H q\n\ntheorem index_lift_def {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u03a0 i, reflexive (r i)} {\u03b3 : Sort*} (f : (\u03a0 i, \u03b2 i) \u2192 \u03b3) {H : \u2200 t\u2081 t\u2082, pi r t\u2081 t\u2082 \u2192 f t\u2081 = f t\u2082} (q : \u03a0 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 \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u03a0 i, reflexive (r i)} {\u03b3 : Sort*} (f : (\u03a0 i, \u03b2 i) \u2192 \u03b3) {H : \u2200 t\u2081 t\u2082, pi r t\u2081 t\u2082 \u2192 f t\u2081 = f t\u2082} (q : quot (pi r)) :\nindex_lift hr f H (index_map r q) = quot.lift f H q := by rw [\u2190 index_inv_map q] {occs:=occurrences.pos[2]}\n\ntheorem index_lift_beta {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} {r : \u03a0 i, \u03b2 i \u2192 \u03b2 i \u2192 Prop} {hr : \u03a0 i, reflexive (r i)} {\u03b3 : Sort*} (f : (\u03a0 i, \u03b2 i) \u2192 \u03b3) {H : \u2200 t\u2081 t\u2082, pi r t\u2081 t\u2082 \u2192 f t\u2081 = f t\u2082} (t : \u03a0 i, \u03b2 i) :\nindex_lift hr f H (\u03bb i, quot.mk (r i) (t i)) = f t := by rw [\u2190 index_map_beta, index_lift_map]\n\nend quot\n\nnamespace quotient\nopen index\nvariables {\u03b1 : Type*} {xs : list \u03b1} {\u03b2 : index xs \u2192 Sort*} [s : \u03a0 i, setoid (\u03b2 i)]\ninclude s\n\ndefinition index_lift {\u03b3 : Sort*} (f : (\u03a0 i, \u03b2 i) \u2192 \u03b3) :\n(\u2200 (t\u2081 t\u2082 : \u03a0 i, \u03b2 i), (\u2200 i, t\u2081 i \u2248 t\u2082 i) \u2192 f t\u2081 = f t\u2082) \u2192 (\u03a0 i, quotient (s i)) \u2192 \u03b3 :=\nhave hr : \u2200 i, reflexive (setoid.r : \u03b2 i \u2192 \u03b2 i \u2192 Prop), from \u03bb i, (s i).iseqv.refl,\nquot.index_lift hr f\n\ntheorem index_lift_beta {\u03b3 : Sort*} (f : (\u03a0 i, \u03b2 i) \u2192 \u03b3) {H : \u2200 (t\u2081 t\u2082 : \u03a0 i, \u03b2 i), (\u2200 i, t\u2081 i \u2248 t\u2082 i) \u2192 f t\u2081 = f t\u2082} :\n\u2200 (t : \u03a0 i, \u03b2 i), index_lift f H (\u03bb i, \u27e6t i\u27e7) = f t := \nhave hr : \u2200 i, reflexive (setoid.r : \u03b2 i \u2192 \u03b2 i \u2192 Prop), from \u03bb i, (s i).iseqv.refl,\nbegin\nintro,\ndunfold index_lift,\napply quot.index_lift_beta,\nend\n\ntheorem index_ind {P : (\u03a0 i, quotient (s i)) \u2192 Prop} :\n(\u2200 (t : \u03a0 i, \u03b2 i), P (\u03bb i, \u27e6t i\u27e7)) \u2192 \u2200 q, P q := \nhave hr : \u2200 i, reflexive (setoid.r : \u03b2 i \u2192 \u03b2 i \u2192 Prop), from \u03bb i, (s i).iseqv.refl,\n\u03bb H, quot.index_ind hr H\n\ntheorem index_induction_on {P : (\u03a0 i, quotient (s i)) \u2192 Prop} (q : \u03a0 i, quotient (s i)) :\n(\u2200 (t : \u03a0 i, \u03b2 i), P (\u03bb i, \u27e6t i\u27e7)) \u2192 P q := \u03bb H, index_ind H q\n\nend quotient\n\nnamespace list\nvariable {\u03b1 : Type*}\n\ntheorem mem_join (x : \u03b1) : \u03a0 {xss : list (list \u03b1)} (i : index xss), x \u2208 i.val \u2192 x \u2208 xss.join\n| _ (index.head xs xss) hi := show x \u2208 xs ++ xss.join, by { rw mem_append, left, exact hi }\n| _ (index.tail xs xss i) hi := show x \u2208 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": "/-\nCopyright (c) 2020 Microsoft Corporation. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Leonardo de Moura, Mario Carneiro\n-/\nprelude -- Don't import Init, because we're in Init itself\nset_option linter.missingDocs true -- keep it documented\n\n/-!\n# Init.Prelude\n\nThis is the first file in the lean import hierarchy. It is responsible for setting\nup basic definitions, most of which lean already has \"built in knowledge\" about,\nso it is important that they be set up in exactly this way. (For example, lean will\nuse `PUnit` in the desugaring of `do` notation, or in the pattern match compiler.)\n\n-/\n\nuniverse u v w\n\n/--\nThe identity function. `id` takes an implicit argument `\u03b1 : Sort u`\n(a type in any universe), and an argument `a : \u03b1`, and returns `a`.\n\nAlthough this may look like a useless function, one application of the identity\nfunction is to explicitly put a type on an expression. If `e` has type `T`,\nand `T'` is definitionally equal to `T`, then `@id T' e` typechecks, and lean\nknows that this expression has type `T'` rather than `T`. This can make a\ndifference for typeclass inference, since `T` and `T'` may have different\ntypeclass instances on them. `show T' from e` is sugar for an `@id T' e`\nexpression.\n-/\n@[inline] def id {\u03b1 : Sort u} (a : \u03b1) : \u03b1 := a\n\n/--\nFunction composition is the act of pipelining the result of one function, to the input of another, creating an entirely new function.\nExample:\n```\n#eval Function.comp List.reverse (List.drop 2) [3, 2, 4, 1]\n-- [1, 4]\n```\nYou can use the notation `f \u2218 g` as shorthand for `Function.comp f g`.\n```\n#eval (List.reverse \u2218 List.drop 2) [3, 2, 4, 1]\n-- [1, 4]\n```\nA simpler way of thinking about it, is that `List.reverse \u2218 List.drop 2`\nis equivalent to `fun xs => List.reverse (List.drop 2 xs)`,\nthe benefit is that the meaning of composition is obvious,\nand the representation is compact.\n-/\n@[inline] def Function.comp {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b4 : Sort w} (f : \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 \u03b4 :=\n  fun x => f (g x)\n\n/--\nThe constant function. If `a : \u03b1`, then `Function.const \u03b2 a : \u03b2 \u2192 \u03b1` is the\n\"constant function with value `a`\", that is, `Function.const \u03b2 a b = a`.\n```\nexample (b : Bool) : Function.const Bool 10 b = 10 :=\n  rfl\n\n#check Function.const Bool 10\n-- Bool \u2192 Nat\n```\n-/\n@[inline] def Function.const {\u03b1 : Sort u} (\u03b2 : Sort v) (a : \u03b1) : \u03b2 \u2192 \u03b1 :=\n  fun _ => a\n\nset_option checkBinderAnnotations false in\n/--\n`inferInstance` synthesizes a value of any target type by typeclass\ninference. This function has the same type signature as the identity\nfunction, but the square brackets on the `[i : \u03b1]` argument means that it will\nattempt to construct this argument by typeclass inference. (This will fail if\n`\u03b1` is not a `class`.) Example:\n```\n#check (inferInstance : Inhabited Nat) -- Inhabited Nat\n\ndef foo : Inhabited (Nat \u00d7 Nat) :=\n  inferInstance\n\nexample : foo.default = (default, default) :=\n  rfl\n```\n-/\nabbrev inferInstance {\u03b1 : Sort u} [i : \u03b1] : \u03b1 := i\n\nset_option checkBinderAnnotations false in\n/-- `inferInstanceAs \u03b1` synthesizes a value of any target type by typeclass\ninference. This is just like `inferInstance` except that `\u03b1` is given\nexplicitly instead of being inferred from the target type. It is especially\nuseful when the target type is some `\u03b1'` which is definitionally equal to `\u03b1`,\nbut the instance we are looking for is only registered for `\u03b1` (because\ntypeclass search does not unfold most definitions, but definitional equality\ndoes.) Example:\n```\n#check inferInstanceAs (Inhabited Nat) -- Inhabited Nat\n```\n-/\nabbrev inferInstanceAs (\u03b1 : Sort u) [i : \u03b1] : \u03b1 := i\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\n/--\nThe unit type, the canonical type with one element, named `unit` or `()`.\nThis is the universe-polymorphic version of `Unit`; it is preferred to use\n`Unit` instead where applicable.\nFor more information about universe levels: [Types as objects](https://leanprover.github.io/theorem_proving_in_lean4/dependent_type_theory.html#types-as-objects)\n-/\ninductive PUnit : Sort u where\n  /-- `PUnit.unit : PUnit` is the canonical element of the unit type. -/\n  | unit : PUnit\n\n/--\nThe unit type, the canonical type with one element, named `unit` or `()`.\nIn other words, it describes only a single value, which consists of said constructor applied\nto no arguments whatsoever.\nThe `Unit` type is similar to `void` in languages derived from C.\n\n`Unit` is actually defined as `PUnit.{0}` where `PUnit` is the universe\npolymorphic version. The `Unit` should be preferred over `PUnit` where possible to avoid\nunnecessary universe parameters.\n\nIn functional programming, `Unit` is the return type of things that \"return\nnothing\", since a type with one element conveys no additional information.\nWhen programming with monads, the type `m Unit` represents an action that has\nsome side effects but does not return a value, while `m \u03b1` would be an action\nthat has side effects and returns a value of type `\u03b1`.\n-/\nabbrev Unit : Type := PUnit\n\n/--\n`Unit.unit : Unit` is the canonical element of the unit type.\nIt can also be written as `()`.\n-/\n@[match_pattern] abbrev Unit.unit : Unit := PUnit.unit\n\n/-- Marker for information that has been erased by the code generator. -/\nunsafe axiom lcErased : Type\n\n/--\nAuxiliary unsafe constant used by the Compiler when erasing proofs from code.\n\nIt may look strange to have an axiom that says \"every proposition is true\",\nsince this is obviously unsound, but the `unsafe` marker ensures that the\nkernel will not let this through into regular proofs. The lower levels of the\ncode generator don't need proofs in terms, so this is used to stub the proofs\nout.\n-/\nunsafe axiom lcProof {\u03b1 : Prop} : \u03b1\n\n/--\nAuxiliary unsafe constant used by the Compiler when erasing casts.\n-/\nunsafe axiom lcCast {\u03b1 : Sort u} {\u03b2 : Sort v} (a : \u03b1) : \u03b2\n\n\n/--\nAuxiliary unsafe constant used by the Compiler to mark unreachable code.\n\nLike `lcProof`, this is an `unsafe axiom`, which means that even though it is\nnot sound, the kernel will not let us use it for regular proofs.\n\nExecuting this expression to actually synthesize a value of type `\u03b1` causes\n**immediate undefined behavior**, and the compiler does take advantage of this\nto optimize the code assuming that it is not called. If it is not optimized out,\nit is likely to appear as a print message saying \"unreachable code\", but this\nbehavior is not guaranteed or stable in any way.\n-/\nunsafe axiom lcUnreachable {\u03b1 : Sort u} : \u03b1\n\n/--\n`True` is a proposition and has only an introduction rule, `True.intro : True`.\nIn other words, `True` is simply true, and has a canonical proof, `True.intro`\nFor more information: [Propositional Logic](https://leanprover.github.io/theorem_proving_in_lean4/propositions_and_proofs.html#propositional-logic)\n-/\ninductive True : Prop where\n  /-- `True` is true, and `True.intro` (or more commonly, `trivial`)\n  is the proof. -/\n  | intro : True\n\n/--\n`False` is the empty proposition. Thus, it has no introduction rules.\nIt represents a contradiction. `False` elimination rule, `False.rec`,\nexpresses the fact that anything follows from a contradiction.\nThis rule is sometimes called ex falso (short for ex falso sequitur quodlibet),\nor the principle of explosion.\nFor more information: [Propositional Logic](https://leanprover.github.io/theorem_proving_in_lean4/propositions_and_proofs.html#propositional-logic)\n-/\ninductive False : Prop\n\n/--\nThe empty type. It has no constructors. The `Empty.rec`\neliminator expresses the fact that anything follows from the empty type.\n-/\ninductive Empty : Type\n\nset_option bootstrap.inductiveCheckResultingUniverse false in\n/--\nThe universe-polymorphic empty type. Prefer `Empty` or `False` where\npossible.\n-/\ninductive PEmpty : Sort u where\n\n/--\n`Not p`, or `\u00acp`, is the negation of `p`. It is defined to be `p \u2192 False`,\nso if your goal is `\u00acp` you can use `intro h` to turn the goal into\n`h : p \u22a2 False`, and if you have `hn : \u00acp` and `h : p` then `hn h : False`\nand `(hn h).elim` will prove anything.\nFor more information: [Propositional Logic](https://leanprover.github.io/theorem_proving_in_lean4/propositions_and_proofs.html#propositional-logic)\n-/\ndef Not (a : Prop) : Prop := a \u2192 False\n\n/--\n`False.elim : False \u2192 C` says that from `False`, any desired proposition\n`C` holds. Also known as ex falso quodlibet (EFQ) or the principle of explosion.\n\nThe target type is actually `C : Sort u` which means it works for both\npropositions and types. When executed, this acts like an \"unreachable\"\ninstruction: it is **undefined behavior** to run, but it will probably print\n\"unreachable code\". (You would need to construct a proof of false to run it\nanyway, which you can only do using `sorry` or unsound axioms.)\n-/\n@[macro_inline] def False.elim {C : Sort u} (h : False) : C :=\n  h.rec\n\n/--\nAnything follows from two contradictory hypotheses. Example:\n```\nexample (hp : p) (hnp : \u00acp) : q := absurd hp hnp\n```\nFor more information: [Propositional Logic](https://leanprover.github.io/theorem_proving_in_lean4/propositions_and_proofs.html#propositional-logic)\n-/\n@[macro_inline] def absurd {a : Prop} {b : Sort v} (h\u2081 : a) (h\u2082 : Not a) : b :=\n  (h\u2082 h\u2081).rec\n\n/--\nThe equality relation. It has one introduction rule, `Eq.refl`.\nWe use `a = b` as notation for `Eq a b`.\nA fundamental property of equality is that it is an equivalence relation.\n```\nvariable (\u03b1 : Type) (a b c d : \u03b1)\nvariable (hab : a = b) (hcb : c = b) (hcd : c = d)\n\nexample : a = d :=\n  Eq.trans (Eq.trans hab (Eq.symm hcb)) hcd\n```\nEquality is much more than an equivalence relation, however. It has the important property that every assertion\nrespects the equivalence, in the sense that we can substitute equal expressions without changing the truth value.\nThat is, given `h1 : a = b` and `h2 : p a`, we can construct a proof for `p b` using substitution: `Eq.subst h1 h2`.\nExample:\n```\nexample (\u03b1 : Type) (a b : \u03b1) (p : \u03b1 \u2192 Prop)\n        (h1 : a = b) (h2 : p a) : p b :=\n  Eq.subst h1 h2\n\nexample (\u03b1 : Type) (a b : \u03b1) (p : \u03b1 \u2192 Prop)\n    (h1 : a = b) (h2 : p a) : p b :=\n  h1 \u25b8 h2\n```\nThe triangle in the second presentation is a macro built on top of `Eq.subst` and `Eq.symm`, and you can enter it by typing `\\t`.\nFor more information: [Equality](https://leanprover.github.io/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)\n-/\ninductive Eq : \u03b1 \u2192 \u03b1 \u2192 Prop where\n  /-- `Eq.refl a : a = a` is reflexivity, the unique constructor of the\n  equality type. See also `rfl`, which is usually used instead. -/\n  | refl (a : \u03b1) : Eq a a\n\n/-- Non-dependent recursor for the equality type. -/\n@[simp] abbrev Eq.ndrec.{u1, u2} {\u03b1 : Sort u2} {a : \u03b1} {motive : \u03b1 \u2192 Sort u1} (m : motive a) {b : \u03b1} (h : Eq a b) : motive b :=\n  h.rec m\n\n/--\n`rfl : a = a` is the unique constructor of the equality type. This is the\nsame as `Eq.refl` except that it takes `a` implicitly instead of explicitly.\n\nThis is a more powerful theorem than it may appear at first, because although\nthe statement of the theorem is `a = a`, lean will allow anything that is\ndefinitionally equal to that type. So, for instance, `2 + 2 = 4` is proven in\nlean by `rfl`, because both sides are the same up to definitional equality.\n-/\n@[match_pattern] def rfl {\u03b1 : Sort u} {a : \u03b1} : Eq a a := Eq.refl a\n\n/-- `id x = x`, as a `@[simp]` lemma. -/\n@[simp] theorem id_eq (a : \u03b1) : Eq (id a) a := rfl\n\n/--\nThe substitution principle for equality. If `a = b ` and `P a` holds,\nthen `P b` also holds. We conventionally use the name `motive` for `P` here,\nso that you can specify it explicitly using e.g.\n`Eq.subst (motive := fun x => x < 5)` if it is not otherwise inferred correctly.\n\nThis theorem is the underlying mechanism behind the `rw` tactic, which is\nessentially a fancy algorithm for finding good `motive` arguments to usefully\napply this theorem to replace occurrences of `a` with `b` in the goal or\nhypotheses.\n\nFor more information: [Equality](https://leanprover.github.io/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)\n-/\ntheorem Eq.subst {\u03b1 : Sort u} {motive : \u03b1 \u2192 Prop} {a b : \u03b1} (h\u2081 : Eq a b) (h\u2082 : motive a) : motive b :=\n  Eq.ndrec h\u2082 h\u2081\n\n/--\nEquality is symmetric: if `a = b` then `b = a`.\n\nBecause this is in the `Eq` namespace, if you have a variable `h : a = b`,\n`h.symm` can be used as shorthand for `Eq.symm h` as a proof of `b = a`.\n\nFor more information: [Equality](https://leanprover.github.io/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)\n-/\ntheorem Eq.symm {\u03b1 : Sort u} {a b : \u03b1} (h : Eq a b) : Eq b a :=\n  h \u25b8 rfl\n\n/--\nEquality is transitive: if `a = b` and `b = c` then `a = c`.\n\nBecause this is in the `Eq` namespace, if you have variables or expressions\n`h\u2081 : a = b` and `h\u2082 : b = c`, you can use `h\u2081.trans h\u2082 : a = c` as shorthand\nfor `Eq.trans h\u2081 h\u2082`.\n\nFor more information: [Equality](https://leanprover.github.io/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)\n-/\ntheorem Eq.trans {\u03b1 : Sort u} {a b c : \u03b1} (h\u2081 : Eq a b) (h\u2082 : Eq b c) : Eq a c :=\n  h\u2082 \u25b8 h\u2081\n\n/--\nCast across a type equality. If `h : \u03b1 = \u03b2` is an equality of types, and\n`a : \u03b1`, then `a : \u03b2` will usually not typecheck directly, but this function\nwill allow you to work around this and embed `a` in type `\u03b2` as `cast h a : \u03b2`.\n\nIt is best to avoid this function if you can, because it is more complicated\nto reason about terms containing casts, but if the types don't match up\ndefinitionally sometimes there isn't anything better you can do.\n\nFor more information: [Equality](https://leanprover.github.io/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)\n-/\n@[macro_inline] def cast {\u03b1 \u03b2 : Sort u} (h : Eq \u03b1 \u03b2) (a : \u03b1) : \u03b2 :=\n  h.rec a\n\n/--\nCongruence in the function argument: if `a\u2081 = a\u2082` then `f a\u2081 = f a\u2082` for\nany (nondependent) function `f`. This is more powerful than it might look at first, because\nyou can also use a lambda expression for `f` to prove that\n`<something containing a\u2081> = <something containing a\u2082>`. This function is used\ninternally by tactics like `congr` and `simp` to apply equalities inside\nsubterms.\n\nFor more information: [Equality](https://leanprover.github.io/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)\n-/\ntheorem congrArg {\u03b1 : Sort u} {\u03b2 : Sort v} {a\u2081 a\u2082 : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : Eq a\u2081 a\u2082) : Eq (f a\u2081) (f a\u2082) :=\n  h \u25b8 rfl\n\n/--\nCongruence in both function and argument. If `f\u2081 = f\u2082` and `a\u2081 = a\u2082` then\n`f\u2081 a\u2081 = f\u2082 a\u2082`. This only works for nondependent functions; the theorem\nstatement is more complex in the dependent case.\n\nFor more information: [Equality](https://leanprover.github.io/theorem_proving_in_lean4/quantifiers_and_equality.html#equality)\n-/\ntheorem congr {\u03b1 : Sort u} {\u03b2 : Sort v} {f\u2081 f\u2082 : \u03b1 \u2192 \u03b2} {a\u2081 a\u2082 : \u03b1} (h\u2081 : Eq f\u2081 f\u2082) (h\u2082 : Eq a\u2081 a\u2082) : Eq (f\u2081 a\u2081) (f\u2082 a\u2082) :=\n  h\u2081 \u25b8 h\u2082 \u25b8 rfl\n\n/-- Congruence in the function part of an application: If `f = g` then `f a = g a`. -/\ntheorem congrFun {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {f g : (x : \u03b1) \u2192 \u03b2 x} (h : Eq f g) (a : \u03b1) : Eq (f a) (g a) :=\n  h \u25b8 rfl\n\n/-!\nInitialize the Quotient Module, which effectively adds the following definitions:\n```\nopaque Quot {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Sort u\n\nopaque Quot.mk {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : Quot r\n\nopaque Quot.lift {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) :\n  (\u2200 a b : \u03b1, r a b \u2192 Eq (f a) (f b)) \u2192 Quot r \u2192 \u03b2\n\nopaque Quot.ind {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b2 : Quot r \u2192 Prop} :\n  (\u2200 a : \u03b1, \u03b2 (Quot.mk r a)) \u2192 \u2200 q : Quot r, \u03b2 q\n```\n-/\ninit_quot\n\n/--\nLet `\u03b1` be any type, and let `r` be an equivalence relation on `\u03b1`.\nIt is mathematically common to form the \"quotient\" `\u03b1 / r`, that is, the type of\nelements of `\u03b1` \"modulo\" `r`. Set theoretically, one can view `\u03b1 / r` as the set\nof equivalence classes of `\u03b1` modulo `r`. If `f : \u03b1 \u2192 \u03b2` is any function that\nrespects the equivalence relation in the sense that for every `x y : \u03b1`,\n`r x y` implies `f x = f y`, then f \"lifts\" to a function `f' : \u03b1 / r \u2192 \u03b2`\ndefined on each equivalence class `\u27e6x\u27e7` by `f' \u27e6x\u27e7 = f x`.\nLean extends the Calculus of Constructions with additional constants that\nperform exactly these constructions, and installs this last equation as a\ndefinitional reduction rule.\n\nGiven a type `\u03b1` and any binary relation `r` on `\u03b1`, `Quot r` is a type. Note\nthat `r` is not required to be an equivalence relation. `Quot` is the basic\nbuilding block used to construct later the type `Quotient`.\n-/\nadd_decl_doc Quot\n\n/--\nGiven a type `\u03b1` and any binary relation `r` on `\u03b1`, `Quot.mk` maps `\u03b1` to `Quot r`.\nSo that if `r : \u03b1 \u2192 \u03b1 \u2192 Prop` and `a : \u03b1`, then `Quot.mk r a` is an element of `Quot r`.\n\nSee `Quot`.\n-/\nadd_decl_doc Quot.mk\n\n/--\nGiven a type `\u03b1` and any binary relation `r` on `\u03b1`,\n`Quot.ind` says that every element of `Quot r` is of the form `Quot.mk r a`.\n\nSee `Quot` and `Quot.lift`.\n-/\nadd_decl_doc Quot.ind\n\n/--\nGiven a type `\u03b1`, any binary relation `r` on `\u03b1`, a function `f : \u03b1 \u2192 \u03b2`, and a proof `h`\nthat `f` respects the relation `r`, then `Quot.lift f h` is the corresponding function on `Quot r`.\n\nThe idea is that for each element `a` in `\u03b1`, the function `Quot.lift f h` maps `Quot.mk r a`\n(the `r`-class containing `a`) to `f a`, wherein `h` shows that this function is well defined.\nIn fact, the computation principle is declared as a reduction rule.\n-/\nadd_decl_doc Quot.lift\n\n/--\nUnsafe auxiliary constant used by the compiler to erase `Quot.lift`.\n-/\nunsafe axiom Quot.lcInv {\u03b1 : Sort u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (q : Quot r) : \u03b1\n\n/--\nHeterogeneous equality. `HEq a b` asserts that `a` and `b` have the same\ntype, and casting `a` across the equality yields `b`, and vice versa.\n\nYou should avoid using this type if you can. Heterogeneous equality does not\nhave all the same properties as `Eq`, because the assumption that the types of\n`a` and `b` are equal is often too weak to prove theorems of interest. One\nimportant non-theorem is the analogue of `congr`: If `HEq f g` and `HEq x y`\nand `f x` and `g y` are well typed it does not follow that `HEq (f x) (g y)`.\n(This does follow if you have `f = g` instead.) However if `a` and `b` have\nthe same type then `a = b` and `HEq a b` are equivalent.\n-/\ninductive HEq : {\u03b1 : Sort u} \u2192 \u03b1 \u2192 {\u03b2 : Sort u} \u2192 \u03b2 \u2192 Prop where\n  /-- Reflexivity of heterogeneous equality. -/\n  | refl (a : \u03b1) : HEq a a\n\n/-- A version of `HEq.refl` with an implicit argument. -/\n@[match_pattern] protected def HEq.rfl {\u03b1 : Sort u} {a : \u03b1} : HEq a a :=\n  HEq.refl a\n\ntheorem eq_of_heq {\u03b1 : Sort u} {a a' : \u03b1} (h : HEq a a') : Eq a a' :=\n  have : (\u03b1 \u03b2 : Sort u) \u2192 (a : \u03b1) \u2192 (b : \u03b2) \u2192 HEq a b \u2192 (h : Eq \u03b1 \u03b2) \u2192 Eq (cast h a) b :=\n    fun _ _ _ _ h\u2081 =>\n      h\u2081.rec (fun _ => rfl)\n  this \u03b1 \u03b1 a a' h rfl\n\n/--\nProduct type (aka pair). You can use `\u03b1 \u00d7 \u03b2` as notation for `Prod \u03b1 \u03b2`.\nGiven `a : \u03b1` and `b : \u03b2`, `Prod.mk a b : Prod \u03b1 \u03b2`. You can use `(a, b)`\nas notation for `Prod.mk a b`. Moreover, `(a, b, c)` is notation for\n`Prod.mk a (Prod.mk b c)`.\nGiven `p : Prod \u03b1 \u03b2`, `p.1 : \u03b1` and `p.2 : \u03b2`. They are short for `Prod.fst p`\nand `Prod.snd p` respectively. You can also write `p.fst` and `p.snd`.\nFor more information: [Constructors with Arguments](https://leanprover.github.io/theorem_proving_in_lean4/inductive_types.html?highlight=Prod#constructors-with-arguments)\n-/\nstructure Prod (\u03b1 : Type u) (\u03b2 : Type v) where\n  /-- The first projection out of a pair. if `p : \u03b1 \u00d7 \u03b2` then `p.1 : \u03b1`. -/\n  fst : \u03b1\n  /-- The second projection out of a pair. if `p : \u03b1 \u00d7 \u03b2` then `p.2 : \u03b2`. -/\n  snd : \u03b2\n\nattribute [unbox] Prod\n\n/--\nSimilar to `Prod`, but `\u03b1` and `\u03b2` can be propositions.\nWe use this Type internally to automatically generate the `brecOn` recursor.\n-/\nstructure PProd (\u03b1 : Sort u) (\u03b2 : Sort v) where\n  /-- The first projection out of a pair. if `p : PProd \u03b1 \u03b2` then `p.1 : \u03b1`. -/\n  fst : \u03b1\n  /-- The second projection out of a pair. if `p : PProd \u03b1 \u03b2` then `p.2 : \u03b2`. -/\n  snd : \u03b2\n\n/--\nSimilar to `Prod`, but `\u03b1` and `\u03b2` are in the same universe.\nWe say `MProd` is the universe monomorphic product type.\n-/\nstructure MProd (\u03b1 \u03b2 : Type u) where\n  /-- The first projection out of a pair. if `p : MProd \u03b1 \u03b2` then `p.1 : \u03b1`. -/\n  fst : \u03b1\n  /-- The second projection out of a pair. if `p : MProd \u03b1 \u03b2` then `p.2 : \u03b2`. -/\n  snd : \u03b2\n\n/--\n`And a b`, or `a \u2227 b`, is the conjunction of propositions. It can be\nconstructed and destructed like a pair: if `ha : a` and `hb : b` then\n`\u27e8ha, hb\u27e9 : a \u2227 b`, and if `h : a \u2227 b` then `h.left : a` and `h.right : b`.\n-/\nstructure And (a b : Prop) : Prop where\n  /-- `And.intro : a \u2192 b \u2192 a \u2227 b` is the constructor for the And operation. -/\n  intro ::\n  /-- Extract the left conjunct from a conjunction. `h : a \u2227 b` then\n  `h.left`, also notated as `h.1`, is a proof of `a`. -/\n  left : a\n  /-- Extract the right conjunct from a conjunction. `h : a \u2227 b` then\n  `h.right`, also notated as `h.2`, is a proof of `b`. -/\n  right : b\n\n/--\n`Or a b`, or `a \u2228 b`, is the disjunction of propositions. There are two\nconstructors for `Or`, called `Or.inl : a \u2192 a \u2228 b` and `Or.inr : b \u2192 a \u2228 b`,\nand you can use `match` or `cases` to destruct an `Or` assumption into the\ntwo cases.\n-/\ninductive Or (a b : Prop) : Prop where\n  /-- `Or.inl` is \"left injection\" into an `Or`. If `h : a` then `Or.inl h : a \u2228 b`. -/\n  | inl (h : a) : Or a b\n  /-- `Or.inr` is \"right injection\" into an `Or`. If `h : b` then `Or.inr h : a \u2228 b`. -/\n  | inr (h : b) : Or a b\n\n/-- Alias for `Or.inl`. -/\ntheorem Or.intro_left (b : Prop) (h : a) : Or a b :=\n  Or.inl h\n\n/-- Alias for `Or.inr`. -/\ntheorem Or.intro_right (a : Prop) (h : b) : Or a b :=\n  Or.inr h\n\n/--\nProof by cases on an `Or`. If `a \u2228 b`, and both `a` and `b` imply\nproposition `c`, then `c` is true.\n-/\ntheorem Or.elim {c : Prop} (h : Or a b) (left : a \u2192 c) (right : b \u2192 c) : c :=\n  match h with\n  | Or.inl h => left h\n  | Or.inr h => right h\n\n/--\n`Bool` is the type of boolean values, `true` and `false`. Classically,\nthis is equivalent to `Prop` (the type of propositions), but the distinction\nis important for programming, because values of type `Prop` are erased in the\ncode generator, while `Bool` corresponds to the type called `bool` or `boolean`\nin most programming languages.\n-/\ninductive Bool : Type where\n  /-- The boolean value `false`, not to be confused with the proposition `False`. -/\n  | false : Bool\n  /-- The boolean value `true`, not to be confused with the proposition `True`. -/\n  | true : Bool\n\nexport Bool (false true)\n\n/--\n`Subtype p`, usually written as `{x : \u03b1 // p x}`, is a type which\nrepresents all the elements `x : \u03b1` for which `p x` is true. It is structurally\na pair-like type, so if you have `x : \u03b1` and `h : p x` then\n`\u27e8x, h\u27e9 : {x // p x}`. An element `s : {x // p x}` will coerce to `\u03b1` but\nyou can also make it explicit using `s.1` or `s.val`.\n-/\nstructure Subtype {\u03b1 : Sort u} (p : \u03b1 \u2192 Prop) where\n  /-- If `s : {x // p x}` then `s.val : \u03b1` is the underlying element in the base\n  type. You can also write this as `s.1`, or simply as `s` when the type is\n  known from context. -/\n  val : \u03b1\n  /-- If `s : {x // p x}` then `s.2` or `s.property` is the assertion that\n  `p s.1`, that is, that `s` is in fact an element for which `p` holds. -/\n  property : p val\n\nset_option linter.unusedVariables.funArgs false in\n/--\nGadget for optional parameter support.\n\nA binder like `(x : \u03b1 := default)` in a declaration is syntax sugar for\n`x : optParam \u03b1 default`, and triggers the elaborator to attempt to use\n`default` to supply the argument if it is not supplied.\n-/\n@[reducible] def optParam (\u03b1 : Sort u) (default : \u03b1) : Sort u := \u03b1\n\n/--\nGadget for marking output parameters in type classes.\n\nFor example, the `Membership` class is defined as:\n```\nclass Membership (\u03b1 : outParam (Type u)) (\u03b3 : Type v)\n```\nThis means that whenever a typeclass goal of the form `Membership ?\u03b1 ?\u03b3` comes\nup, lean will wait to solve it until `?\u03b3` is known, but then it will run\ntypeclass inference, and take the first solution it finds, for any value of `?\u03b1`,\nwhich thereby determines what `?\u03b1` should be.\n\nThis expresses that in a term like `a \u2208 s`, `s` might be a `Set \u03b1` or\n`List \u03b1` or some other type with a membership operation, and in each case\nthe \"member\" type `\u03b1` is determined by looking at the container type.\n-/\n@[reducible] def outParam (\u03b1 : Sort u) : Sort u := \u03b1\n\nset_option linter.unusedVariables.funArgs false in\n/-- Auxiliary declaration used to implement named patterns like `x@h:p`. -/\n@[reducible] def namedPattern {\u03b1 : Sort u} (x a : \u03b1) (h : Eq x a) : \u03b1 := a\n\n/--\nAuxiliary axiom used to implement `sorry`.\n\nThe `sorry` term/tactic expands to `sorryAx _ (synthetic := false)`. This is a\nproof of anything, which is intended for stubbing out incomplete parts of a\nproof while still having a syntactically correct proof skeleton. Lean will give\na warning whenever a proof uses `sorry`, so you aren't likely to miss it, but\nyou can double check if a theorem depends on `sorry` by using\n`#print axioms my_thm` and looking for `sorryAx` in the axiom list.\n\nThe `synthetic` flag is false when written explicitly by the user, but it is\nset to `true` when a tactic fails to prove a goal, or if there is a type error\nin the expression. A synthetic `sorry` acts like a regular one, except that it\nsuppresses follow-up errors in order to prevent one error from causing a cascade\nof other errors because the desired term was not constructed.\n-/\n@[extern \"lean_sorry\", never_extract]\naxiom sorryAx (\u03b1 : Sort u) (synthetic := false) : \u03b1\n\ntheorem eq_false_of_ne_true : {b : Bool} \u2192 Not (Eq b true) \u2192 Eq b false\n  | true, h => False.elim (h rfl)\n  | false, _ => rfl\n\ntheorem eq_true_of_ne_false : {b : Bool} \u2192 Not (Eq b false) \u2192 Eq b true\n  | true, _ => rfl\n  | false, h => False.elim (h rfl)\n\ntheorem ne_false_of_eq_true : {b : Bool} \u2192 Eq b true \u2192 Not (Eq b false)\n  | true, _  => fun h => Bool.noConfusion h\n  | false, h => Bool.noConfusion h\n\ntheorem ne_true_of_eq_false : {b : Bool} \u2192 Eq b false \u2192 Not (Eq b true)\n  | true, h  => Bool.noConfusion h\n  | false, _ => fun h => Bool.noConfusion h\n\n/--\n`Inhabited \u03b1` is a typeclass that says that `\u03b1` has a designated element,\ncalled `(default : \u03b1)`. This is sometimes referred to as a \"pointed type\".\n\nThis class is used by functions that need to return a value of the type\nwhen called \"out of domain\". For example, `Array.get! arr i : \u03b1` returns\na value of type `\u03b1` when `arr : Array \u03b1`, but if `i` is not in range of\nthe array, it reports a panic message, but this does not halt the program,\nso it must still return a value of type `\u03b1` (and in fact this is required\nfor logical consistency), so in this case it returns `default`.\n-/\nclass Inhabited (\u03b1 : Sort u) where\n  /-- `default` is a function that produces a \"default\" element of any\n  `Inhabited` type. This element does not have any particular specified\n  properties, but it is often an all-zeroes value. -/\n  default : \u03b1\n\nexport Inhabited (default)\n\n/--\n`Nonempty \u03b1` is a typeclass that says that `\u03b1` is not an empty type,\nthat is, there exists an element in the type. It differs from `Inhabited \u03b1`\nin that `Nonempty \u03b1` is a `Prop`, which means that it does not actually carry\nan element of `\u03b1`, only a proof that *there exists* such an element.\nGiven `Nonempty \u03b1`, you can construct an element of `\u03b1` *nonconstructively*\nusing `Classical.choice`.\n-/\nclass inductive Nonempty (\u03b1 : Sort u) : Prop where\n  /-- If `val : \u03b1`, then `\u03b1` is nonempty. -/\n  | intro (val : \u03b1) : Nonempty \u03b1\n\n/--\n**The axiom of choice**. `Nonempty \u03b1` is a proof that `\u03b1` has an element,\nbut the element itself is erased. The axiom `choice` supplies a particular\nelement of `\u03b1` given only this proof.\n\nThe textbook axiom of choice normally makes a family of choices all at once,\nbut that is implied from this formulation, because if `\u03b1 : \u03b9 \u2192 Type` is a\nfamily of types and `h : \u2200 i, Nonempty (\u03b1 i)` is a proof that they are all\nnonempty, then `fun i => Classical.choice (h i) : \u2200 i, \u03b1 i` is a family of\nchosen elements. This is actually a bit stronger than the ZFC choice axiom;\nthis is sometimes called \"[global choice](https://en.wikipedia.org/wiki/Axiom_of_global_choice)\".\n\nIn lean, we use the axiom of choice to derive the law of excluded middle\n(see `Classical.em`), so it will often show up in axiom listings where you\nmay not expect. You can use `#print axioms my_thm` to find out if a given\ntheorem depends on this or other axioms.\n\nThis axiom can be used to construct \"data\", but obviously there is no algorithm\nto compute it, so lean will require you to mark any definition that would\ninvolve executing `Classical.choice` or other axioms as `noncomputable`, and\nwill not produce any executable code for such definitions.\n-/\naxiom Classical.choice {\u03b1 : Sort u} : Nonempty \u03b1 \u2192 \u03b1\n\n/--\nThe elimination principle for `Nonempty \u03b1`. If `Nonempty \u03b1`, and we can\nprove `p` given any element `x : \u03b1`, then `p` holds. Note that it is essential\nthat `p` is a `Prop` here; the version with `p` being a `Sort u` is equivalent\nto `Classical.choice`.\n-/\nprotected def Nonempty.elim {\u03b1 : Sort u} {p : Prop} (h\u2081 : Nonempty \u03b1) (h\u2082 : \u03b1 \u2192 p) : p :=\n  match h\u2081 with\n  | intro a => h\u2082 a\n\ninstance {\u03b1 : Sort u} [Inhabited \u03b1] : Nonempty \u03b1 :=\n  \u27e8default\u27e9\n\n/--\nA variation on `Classical.choice` that uses typeclass inference to\ninfer the proof of `Nonempty \u03b1`.\n-/\nnoncomputable def Classical.ofNonempty {\u03b1 : Sort u} [Nonempty \u03b1] : \u03b1 :=\n  Classical.choice inferInstance\n\ninstance (\u03b1 : Sort u) {\u03b2 : Sort v} [Nonempty \u03b2] : Nonempty (\u03b1 \u2192 \u03b2) :=\n  Nonempty.intro fun _ => Classical.ofNonempty\n\ninstance (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(a : \u03b1) \u2192 Nonempty (\u03b2 a)] : Nonempty ((a : \u03b1) \u2192 \u03b2 a) :=\n  Nonempty.intro fun _ => Classical.ofNonempty\n\ninstance : Inhabited (Sort u) where\n  default := PUnit\n\ninstance (\u03b1 : Sort u) {\u03b2 : Sort v} [Inhabited \u03b2] : Inhabited (\u03b1 \u2192 \u03b2) where\n  default := fun _ => default\n\ninstance (\u03b1 : Sort u) {\u03b2 : \u03b1 \u2192 Sort v} [(a : \u03b1) \u2192 Inhabited (\u03b2 a)] : Inhabited ((a : \u03b1) \u2192 \u03b2 a) where\n  default := fun _ => default\n\nderiving instance Inhabited for Bool\n\n/-- Universe lifting operation from `Sort u` to `Type u`. -/\nstructure PLift (\u03b1 : Sort u) : Type u where\n  /-- Lift a value into `PLift \u03b1` -/    up ::\n  /-- Extract a value from `PLift \u03b1` -/ down : \u03b1\n\n/-- Bijection between `\u03b1` and `PLift \u03b1` -/\ntheorem PLift.up_down {\u03b1 : Sort u} (b : PLift \u03b1) : Eq (up (down b)) b := rfl\n\n/-- Bijection between `\u03b1` and `PLift \u03b1` -/\ntheorem PLift.down_up {\u03b1 : Sort u} (a : \u03b1) : Eq (down (up a)) a := rfl\n\n/--\n`NonemptyType.{u}` is the type of nonempty types in universe `u`.\nIt is mainly used in constant declarations where we wish to introduce a type\nand simultaneously assert that it is nonempty, but otherwise make the type\nopaque.\n-/\ndef NonemptyType := Subtype fun \u03b1 : Type u => Nonempty \u03b1\n\n/-- The underlying type of a `NonemptyType`. -/\nabbrev NonemptyType.type (type : NonemptyType.{u}) : Type u :=\n  type.val\n\n/-- `NonemptyType` is inhabited, because `PUnit` is a nonempty type. -/\ninstance : Inhabited NonemptyType.{u} where\n  default := \u27e8PUnit, \u27e8\u27e8\u27e9\u27e9\u27e9\n\n/--\nUniverse lifting operation from a lower `Type` universe to a higher one.\nTo express this using level variables, the input is `Type s` and the output is\n`Type (max s r)`, so if `s \u2264 r` then the latter is (definitionally) `Type r`.\n\nThe universe variable `r` is written first so that `ULift.{r} \u03b1` can be used\nwhen `s` can be inferred from the type of `\u03b1`.\n-/\nstructure ULift.{r, s} (\u03b1 : Type s) : Type (max s r) where\n  /-- Lift a value into `ULift \u03b1` -/    up ::\n  /-- Extract a value from `ULift \u03b1` -/ down : \u03b1\n\n/-- Bijection between `\u03b1` and `ULift.{v} \u03b1` -/\ntheorem ULift.up_down {\u03b1 : Type u} (b : ULift.{v} \u03b1) : Eq (up (down b)) b := rfl\n\n/-- Bijection between `\u03b1` and `ULift.{v} \u03b1` -/\ntheorem ULift.down_up {\u03b1 : Type u} (a : \u03b1) : Eq (down (up.{v} a)) a := rfl\n\n/--\n`Decidable p` is a data-carrying class that supplies a proof that `p` is\neither `true` or `false`. It is equivalent to `Bool` (and in fact it has the\nsame code generation as `Bool`) together with a proof that the `Bool` is\ntrue iff `p` is.\n\n`Decidable` instances are used to infer \"computation strategies\" for\npropositions, so that you can have the convenience of writing propositions\ninside `if` statements and executing them (which actually executes the inferred\ndecidability instance instead of the proposition, which has no code).\n\nIf a proposition `p` is `Decidable`, then `(by decide : p)` will prove it by\nevaluating the decidability instance to `isTrue h` and returning `h`.\n-/\nclass inductive Decidable (p : Prop) where\n  /-- Prove that `p` is decidable by supplying a proof of `\u00acp` -/\n  | isFalse (h : Not p) : Decidable p\n  /-- Prove that `p` is decidable by supplying a proof of `p` -/\n  | isTrue (h : p) : Decidable p\n\n/--\nConvert a decidable proposition into a boolean value.\n\nIf `p : Prop` is decidable, then `decide p : Bool` is the boolean value\nwhich is `true` if `p` is true and `false` if `p` is false.\n-/\n@[inline_if_reduce, nospecialize] def Decidable.decide (p : Prop) [h : Decidable p] : Bool :=\n  h.casesOn (fun _ => false) (fun _ => true)\n\nexport Decidable (isTrue isFalse decide)\n\n/-- A decidable predicate. See `Decidable`. -/\nabbrev DecidablePred {\u03b1 : Sort u} (r : \u03b1 \u2192 Prop) :=\n  (a : \u03b1) \u2192 Decidable (r a)\n\n/-- A decidable relation. See `Decidable`. -/\nabbrev DecidableRel {\u03b1 : Sort u} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :=\n  (a b : \u03b1) \u2192 Decidable (r a b)\n\n/--\nAsserts that `\u03b1` has decidable equality, that is, `a = b` is decidable\nfor all `a b : \u03b1`. See `Decidable`.\n-/\nabbrev DecidableEq (\u03b1 : Sort u) :=\n  (a b : \u03b1) \u2192 Decidable (Eq a b)\n\n/-- Proves that `a = b` is decidable given `DecidableEq \u03b1`. -/\ndef decEq {\u03b1 : Sort u} [inst : DecidableEq \u03b1] (a b : \u03b1) : Decidable (Eq a b) :=\n  inst a b\n\nset_option linter.unusedVariables false in\ntheorem decide_eq_true : [inst : Decidable p] \u2192 p \u2192 Eq (decide p) true\n  | isTrue  _, _   => rfl\n  | isFalse h\u2081, h\u2082 => absurd h\u2082 h\u2081\n\ntheorem decide_eq_false : [Decidable p] \u2192 Not p \u2192 Eq (decide p) false\n  | isTrue  h\u2081, h\u2082 => absurd h\u2081 h\u2082\n  | isFalse _, _   => rfl\n\ntheorem of_decide_eq_true [inst : Decidable p] : Eq (decide p) true \u2192 p := fun h =>\n  match (generalizing := false) inst with\n  | isTrue  h\u2081 => h\u2081\n  | isFalse h\u2081 => absurd h (ne_true_of_eq_false (decide_eq_false h\u2081))\n\ntheorem of_decide_eq_false [inst : Decidable p] : Eq (decide p) false \u2192 Not p := fun h =>\n  match (generalizing := false) inst with\n  | isTrue  h\u2081 => absurd h (ne_false_of_eq_true (decide_eq_true h\u2081))\n  | isFalse h\u2081 => h\u2081\n\ntheorem of_decide_eq_self_eq_true [inst : DecidableEq \u03b1] (a : \u03b1) : Eq (decide (Eq a a)) true :=\n  match (generalizing := false) inst a a with\n  | isTrue  _  => rfl\n  | isFalse h\u2081 => absurd rfl h\u2081\n\n/-- Decidable equality for Bool -/\n@[inline] def Bool.decEq (a b : Bool) : Decidable (Eq a b) :=\n   match a, b with\n   | false, false => isTrue rfl\n   | false, true  => isFalse (fun h => Bool.noConfusion h)\n   | true, false  => isFalse (fun h => Bool.noConfusion h)\n   | true, true   => isTrue rfl\n\n@[inline] instance : DecidableEq Bool :=\n   Bool.decEq\n\n/--\n`BEq \u03b1` is a typeclass for supplying a boolean-valued equality relation on\n`\u03b1`, notated as `a == b`. Unlike `DecidableEq \u03b1` (which uses `a = b`), this\nis `Bool` valued instead of `Prop` valued, and it also does not have any\naxioms like being reflexive or agreeing with `=`. It is mainly intended for\nprogramming applications. See `LawfulBEq` for a version that requires that\n`==` and `=` coincide.\n-/\nclass BEq (\u03b1 : Type u) where\n  /-- Boolean equality, notated as `a == b`. -/\n  beq : \u03b1 \u2192 \u03b1 \u2192 Bool\n\nopen BEq (beq)\n\ninstance [DecidableEq \u03b1] : BEq \u03b1 where\n  beq a b := decide (Eq a b)\n\n\n/--\n\"Dependent\" if-then-else, normally written via the notation `if h : c then t(h) else e(h)`,\nis sugar for `dite c (fun h => t(h)) (fun h => e(h))`, and it is the same as\n`if c then t else e` except that `t` is allowed to depend on a proof `h : c`,\nand `e` can depend on `h : \u00acc`. (Both branches use the same name for the hypothesis,\neven though it has different types in the two cases.)\n\nWe use this to be able to communicate the if-then-else condition to the branches.\nFor example, `Array.get arr \u27e8i, h\u27e9` expects a proof `h : i < arr.size` in order to\navoid a bounds check, so you can write `if h : i < arr.size then arr.get \u27e8i, h\u27e9 else ...`\nto avoid the bounds check inside the if branch. (Of course in this case we have only\nlifted the check into an explicit `if`, but we could also use this proof multiple times\nor derive `i < arr.size` from some other proposition that we are checking in the `if`.)\n-/\n@[macro_inline] def dite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t : c \u2192 \u03b1) (e : Not c \u2192 \u03b1) : \u03b1 :=\n  h.casesOn e t\n\n/-! # if-then-else -/\n\n/--\n`if c then t else e` is notation for `ite c t e`, \"if-then-else\", which decides to\nreturn `t` or `e` depending on whether `c` is true or false. The explicit argument\n`c : Prop` does not have any actual computational content, but there is an additional\n`[Decidable c]` argument synthesized by typeclass inference which actually\ndetermines how to evaluate `c` to true or false.\n\nBecause lean uses a strict (call-by-value) evaluation strategy, the signature of this\nfunction is problematic in that it would require `t` and `e` to be evaluated before\ncalling the `ite` function, which would cause both sides of the `if` to be evaluated.\nEven if the result is discarded, this would be a big performance problem,\nand is undesirable for users in any case. To resolve this, `ite` is marked as\n`@[macro_inline]`, which means that it is unfolded during code generation, and\nthe definition of the function uses `fun _ => t` and `fun _ => e` so this recovers\nthe expected \"lazy\" behavior of `if`: the `t` and `e` arguments delay evaluation\nuntil `c` is known.\n-/\n@[macro_inline] def ite {\u03b1 : Sort u} (c : Prop) [h : Decidable c] (t e : \u03b1) : \u03b1 :=\n  h.casesOn (fun _ => e) (fun _ => t)\n\n@[macro_inline] instance {p q} [dp : Decidable p] [dq : Decidable q] : Decidable (And p q) :=\n  match dp with\n  | isTrue  hp =>\n    match dq with\n    | isTrue hq  => isTrue \u27e8hp, hq\u27e9\n    | isFalse hq => isFalse (fun h => hq (And.right h))\n  | isFalse hp =>\n    isFalse (fun h => hp (And.left h))\n\n@[macro_inline] instance [dp : Decidable p] [dq : Decidable q] : Decidable (Or p q) :=\n  match dp with\n  | isTrue  hp => isTrue (Or.inl hp)\n  | isFalse hp =>\n    match dq with\n    | isTrue hq  => isTrue (Or.inr hq)\n    | isFalse hq =>\n      isFalse fun h => match h with\n        | Or.inl h => hp h\n        | Or.inr h => hq h\n\ninstance [dp : Decidable p] : Decidable (Not p) :=\n  match dp with\n  | isTrue hp  => isFalse (absurd hp)\n  | isFalse hp => isTrue hp\n\n/-! # Boolean operators -/\n\n/--\n`cond b x y` is the same as `if b then x else y`, but optimized for a\nboolean condition. It can also be written as `bif b then x else y`.\nThis is `@[macro_inline]` because `x` and `y` should not\nbe eagerly evaluated (see `ite`).\n-/\n@[macro_inline] def cond {\u03b1 : Type u} (c : Bool) (x y : \u03b1) : \u03b1 :=\n  match c with\n  | true  => x\n  | false => y\n\n/--\n`or x y`, or `x || y`, is the boolean \"or\" operation (not to be confused\nwith `Or : Prop \u2192 Prop \u2192 Prop`, which is the propositional connective).\nIt is `@[macro_inline]` because it has C-like short-circuiting behavior:\nif `x` is true then `y` is not evaluated.\n-/\n@[macro_inline] def or (x y : Bool) : Bool :=\n  match x with\n  | true  => true\n  | false => y\n\n/--\n`and x y`, or `x && y`, is the boolean \"and\" operation (not to be confused\nwith `And : Prop \u2192 Prop \u2192 Prop`, which is the propositional connective).\nIt is `@[macro_inline]` because it has C-like short-circuiting behavior:\nif `x` is false then `y` is not evaluated.\n-/\n@[macro_inline] def and (x y : Bool) : Bool :=\n  match x with\n  | false => false\n  | true  => y\n\n/--\n`not x`, or `!x`, is the boolean \"not\" operation (not to be confused\nwith `Not : Prop \u2192 Prop`, which is the propositional connective).\n-/\n@[inline] def not : Bool \u2192 Bool\n  | true  => false\n  | false => true\n\n/--\nThe type of natural numbers, starting at zero. It is defined as an\ninductive type freely generated by \"zero is a natural number\" and\n\"the successor of a natural number is a natural number\".\n\nYou can prove a theorem `P n` about `n : Nat` by `induction n`, which will\nexpect a proof of the theorem for `P 0`, and a proof of `P (succ i)` assuming\na proof of `P i`. The same method also works to define functions by recursion\non natural numbers: induction and recursion are two expressions of the same\noperation from lean's point of view.\n\n```\nopen Nat\nexample (n : Nat) : n < succ n := by\n  induction n with\n  | zero =>\n    show 0 < 1\n    decide\n  | succ i ih => -- ih : i < succ i\n    show succ i < succ (succ i)\n    exact Nat.succ_lt_succ ih\n```\n\nThis type is special-cased by both the kernel and the compiler:\n* The type of expressions contains \"`Nat` literals\" as a primitive constructor,\n  and the kernel knows how to reduce zero/succ expressions to nat literals.\n* If implemented naively, this type would represent a numeral `n` in unary as a\n  linked list with `n` links, which is horribly inefficient. Instead, the\n  runtime itself has a special representation for `Nat` which stores numbers up\n  to 2^63 directly and larger numbers use an arbitrary precision \"bignum\"\n  library (usually [GMP](https://gmplib.org/)).\n-/\ninductive Nat where\n  /-- `Nat.zero`, normally written `0 : Nat`, is the smallest natural number.\n  This is one of the two constructors of `Nat`. -/\n  | zero : Nat\n  /-- The successor function on natural numbers, `succ n = n + 1`.\n  This is one of the two constructors of `Nat`. -/\n  | succ (n : Nat) : Nat\n\ninstance : Inhabited Nat where\n  default := Nat.zero\n\n/--\nThe class `OfNat \u03b1 n` powers the numeric literal parser. If you write\n`37 : \u03b1`, lean will attempt to synthesize `OfNat \u03b1 37`, and will generate\nthe term `(OfNat.ofNat 37 : \u03b1)`.\n\nThere is a bit of infinite regress here since the desugaring apparently\nstill contains a literal `37` in it. The type of expressions contains a\nprimitive constructor for \"raw natural number literals\", which you can directly\naccess using the macro `nat_lit 37`. Raw number literals are always of type `Nat`.\nSo it would be more correct to say that lean looks for an instance of\n`OfNat \u03b1 (nat_lit 37)`, and it generates the term `(OfNat.ofNat (nat_lit 37) : \u03b1)`.\n-/\nclass OfNat (\u03b1 : Type u) (_ : Nat) where\n  /-- The `OfNat.ofNat` function is automatically inserted by the parser when\n  the user writes a numeric literal like `1 : \u03b1`. Implementations of this\n  typeclass can therefore customize the behavior of `n : \u03b1` based on `n` and\n  `\u03b1`. -/\n  ofNat : \u03b1\n\n@[default_instance 100] /- low prio -/\ninstance (n : Nat) : OfNat Nat n where\n  ofNat := n\n\n/-- `LE \u03b1` is the typeclass which supports the notation `x \u2264 y` where `x y : \u03b1`.-/\nclass LE (\u03b1 : Type u) where\n  /-- The less-equal relation: `x \u2264 y` -/\n  le : \u03b1 \u2192 \u03b1 \u2192 Prop\n\n/-- `LT \u03b1` is the typeclass which supports the notation `x < y` where `x y : \u03b1`.-/\nclass LT (\u03b1 : Type u) where\n  /-- The less-than relation: `x < y` -/\n  lt : \u03b1 \u2192 \u03b1 \u2192 Prop\n\n/-- `a \u2265 b` is an abbreviation for `b \u2264 a`. -/\n@[reducible] def GE.ge {\u03b1 : Type u} [LE \u03b1] (a b : \u03b1) : Prop := LE.le b a\n/-- `a > b` is an abbreviation for `b < a`. -/\n@[reducible] def GT.gt {\u03b1 : Type u} [LT \u03b1] (a b : \u03b1) : Prop := LT.lt b a\n\n/-- `Max \u03b1` is the typeclass which supports the operation `max x y` where `x y : \u03b1`.-/\nclass Max (\u03b1 : Type u) where\n  /-- The maximum operation: `max x y`. -/\n  max : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nexport Max (max)\n\n/-- Implementation of the `max` operation using `\u2264`. -/\n-- Marked inline so that `min x y + max x y` can be optimized to a single branch.\n@[inline]\ndef maxOfLe [LE \u03b1] [DecidableRel (@LE.le \u03b1 _)] : Max \u03b1 where\n  max x y := ite (LE.le x y) y x\n\n/-- `Min \u03b1` is the typeclass which supports the operation `min x y` where `x y : \u03b1`.-/\nclass Min (\u03b1 : Type u) where\n  /-- The minimum operation: `min x y`. -/\n  min : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\nexport Min (min)\n\n/-- Implementation of the `min` operation using `\u2264`. -/\n-- Marked inline so that `min x y + max x y` can be optimized to a single branch.\n@[inline]\ndef minOfLe [LE \u03b1] [DecidableRel (@LE.le \u03b1 _)] : Min \u03b1 where\n  min x y := ite (LE.le x y) x y\n\n/--\nTransitive chaining of proofs, used e.g. by `calc`.\n\nIt takes two relations `r` and `s` as \"input\", and produces an \"output\"\nrelation `t`, with the property that `r a b` and `s b c` implies `t a c`.\nThe `calc` tactic uses this so that when it sees a chain with `a \u2264 b` and `b < c`\nit knows that this should be a proof of `a < c` because there is an instance\n`Trans (\u00b7\u2264\u00b7) (\u00b7<\u00b7) (\u00b7<\u00b7)`.\n-/\nclass Trans (r : \u03b1 \u2192 \u03b2 \u2192 Sort u) (s : \u03b2 \u2192 \u03b3 \u2192 Sort v) (t : outParam (\u03b1 \u2192 \u03b3 \u2192 Sort w)) where\n  /-- Compose two proofs by transitivity, generalized over the relations involved. -/\n  trans : r a b \u2192 s b c \u2192 t a c\n\nexport Trans (trans)\n\ninstance (r : \u03b1 \u2192 \u03b3 \u2192 Sort u) : Trans Eq r r where\n  trans heq h' := heq \u25b8 h'\n\ninstance (r : \u03b1 \u2192 \u03b2 \u2192 Sort u) : Trans r Eq r where\n  trans h' heq := heq \u25b8 h'\n\n/--\nThe notation typeclass for heterogeneous addition.\nThis enables the notation `a + b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\n-/\nclass HAdd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a + b` computes the sum of `a` and `b`.\n  The meaning of this notation is type-dependent. -/\n  hAdd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/--\nThe notation typeclass for heterogeneous subtraction.\nThis enables the notation `a - b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\n-/\nclass HSub (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a - b` computes the difference of `a` and `b`.\n  The meaning of this notation is type-dependent.\n  * For natural numbers, this operator saturates at 0: `a - b = 0` when `a \u2264 b`. -/\n  hSub : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/--\nThe notation typeclass for heterogeneous multiplication.\nThis enables the notation `a * b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\n-/\nclass HMul (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a * b` computes the product of `a` and `b`.\n  The meaning of this notation is type-dependent. -/\n  hMul : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/--\nThe notation typeclass for heterogeneous division.\nThis enables the notation `a / b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\n-/\nclass HDiv (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a / b` computes the result of dividing `a` by `b`.\n  The meaning of this notation is type-dependent.\n  * For most types like `Nat`, `Int`, `Rat`, `Real`, `a / 0` is defined to be `0`.\n  * For `Nat` and `Int`, `a / b` rounds toward 0.\n  * For `Float`, `a / 0` follows the IEEE 754 semantics for division,\n    usually resulting in `inf` or `nan`. -/\n  hDiv : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/--\nThe notation typeclass for heterogeneous modulo / remainder.\nThis enables the notation `a % b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\n-/\nclass HMod (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a % b` computes the remainder upon dividing `a` by `b`.\n  The meaning of this notation is type-dependent.\n  * For `Nat` and `Int`, `a % 0` is defined to be `a`. -/\n  hMod : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/--\nThe notation typeclass for heterogeneous exponentiation.\nThis enables the notation `a ^ b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\n-/\nclass HPow (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a ^ b` computes `a` to the power of `b`.\n  The meaning of this notation is type-dependent. -/\n  hPow : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/--\nThe notation typeclass for heterogeneous append.\nThis enables the notation `a ++ b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\n-/\nclass HAppend (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a ++ b` is the result of concatenation of `a` and `b`, usually read \"append\".\n  The meaning of this notation is type-dependent. -/\n  hAppend : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/--\nThe typeclass behind the notation `a <|> b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\nBecause `b` is \"lazy\" in this notation, it is passed as `Unit \u2192 \u03b2` to the\nimplementation so it can decide when to evaluate it.\n-/\nclass HOrElse (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a <|> b` executes `a` and returns the result, unless it fails in which\n  case it executes and returns `b`. Because `b` is not always executed, it\n  is passed as a thunk so it can be forced only when needed.\n  The meaning of this notation is type-dependent. -/\n  hOrElse : \u03b1 \u2192 (Unit \u2192 \u03b2) \u2192 \u03b3\n\n/--\nThe typeclass behind the notation `a >> b : \u03b3` where `a : \u03b1`, `b : \u03b2`.\nBecause `b` is \"lazy\" in this notation, it is passed as `Unit \u2192 \u03b2` to the\nimplementation so it can decide when to evaluate it.\n-/\nclass HAndThen (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a >> b` executes `a`, ignores the result, and then executes `b`.\n  If `a` fails then `b` is not executed. Because `b` is not always executed, it\n  is passed as a thunk so it can be forced only when needed.\n  The meaning of this notation is type-dependent. -/\n  hAndThen : \u03b1 \u2192 (Unit \u2192 \u03b2) \u2192 \u03b3\n\n/-- The typeclass behind the notation `a &&& b : \u03b3` where `a : \u03b1`, `b : \u03b2`. -/\nclass HAnd (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a &&& b` computes the bitwise AND of `a` and `b`.\n  The meaning of this notation is type-dependent. -/\n  hAnd : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/-- The typeclass behind the notation `a ^^^ b : \u03b3` where `a : \u03b1`, `b : \u03b2`. -/\nclass HXor (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a ^^^ b` computes the bitwise XOR of `a` and `b`.\n  The meaning of this notation is type-dependent. -/\n  hXor : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/-- The typeclass behind the notation `a ||| b : \u03b3` where `a : \u03b1`, `b : \u03b2`. -/\nclass HOr (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a ||| b` computes the bitwise OR of `a` and `b`.\n  The meaning of this notation is type-dependent. -/\n  hOr : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/-- The typeclass behind the notation `a <<< b : \u03b3` where `a : \u03b1`, `b : \u03b2`. -/\nclass HShiftLeft (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a <<< b` computes `a` shifted to the left by `b` places.\n  The meaning of this notation is type-dependent.\n  * On `Nat`, this is equivalent to `a * 2 ^ b`.\n  * On `UInt8` and other fixed width unsigned types, this is the same but\n    truncated to the bit width. -/\n  hShiftLeft : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/-- The typeclass behind the notation `a >>> b : \u03b3` where `a : \u03b1`, `b : \u03b2`. -/\nclass HShiftRight (\u03b1 : Type u) (\u03b2 : Type v) (\u03b3 : outParam (Type w)) where\n  /-- `a >>> b` computes `a` shifted to the right by `b` places.\n  The meaning of this notation is type-dependent.\n  * On `Nat` and fixed width unsigned types like `UInt8`,\n    this is equivalent to `a / 2 ^ b`. -/\n  hShiftRight : \u03b1 \u2192 \u03b2 \u2192 \u03b3\n\n/-- The homogeneous version of `HAdd`: `a + b : \u03b1` where `a b : \u03b1`. -/\nclass Add (\u03b1 : Type u) where\n  /-- `a + b` computes the sum of `a` and `b`. See `HAdd`. -/\n  add : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/-- The homogeneous version of `HSub`: `a - b : \u03b1` where `a b : \u03b1`. -/\nclass Sub (\u03b1 : Type u) where\n  /-- `a - b` computes the difference of `a` and `b`. See `HSub`. -/\n  sub : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/-- The homogeneous version of `HMul`: `a * b : \u03b1` where `a b : \u03b1`. -/\nclass Mul (\u03b1 : Type u) where\n  /-- `a * b` computes the product of `a` and `b`. See `HMul`. -/\n  mul : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/--\nThe notation typeclass for negation.\nThis enables the notation `-a : \u03b1` where `a : \u03b1`.\n-/\nclass Neg (\u03b1 : Type u) where\n  /-- `-a` computes the negative or opposite of `a`.\n  The meaning of this notation is type-dependent. -/\n  neg : \u03b1 \u2192 \u03b1\n\n/-- The homogeneous version of `HDiv`: `a / b : \u03b1` where `a b : \u03b1`. -/\nclass Div (\u03b1 : Type u) where\n  /-- `a / b` computes the result of dividing `a` by `b`. See `HDiv`. -/\n  div : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/-- The homogeneous version of `HMod`: `a % b : \u03b1` where `a b : \u03b1`. -/\nclass Mod (\u03b1 : Type u) where\n  /-- `a % b` computes the remainder upon dividing `a` by `b`. See `HMod`. -/\n  mod : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/--\nThe homogeneous version of `HPow`: `a ^ b : \u03b1` where `a : \u03b1`, `b : \u03b2`.\n(The right argument is not the same as the left since we often want this even\nin the homogeneous case.)\n-/\nclass Pow (\u03b1 : Type u) (\u03b2 : Type v) where\n  /-- `a ^ b` computes `a` to the power of `b`. See `HPow`. -/\n  pow : \u03b1 \u2192 \u03b2 \u2192 \u03b1\n\n/-- The homogeneous version of `HAppend`: `a ++ b : \u03b1` where `a b : \u03b1`. -/\nclass Append (\u03b1 : Type u) where\n  /-- `a ++ b` is the result of concatenation of `a` and `b`. See `HAppend`. -/\n  append : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/--\nThe homogeneous version of `HOrElse`: `a <|> b : \u03b1` where `a b : \u03b1`.\nBecause `b` is \"lazy\" in this notation, it is passed as `Unit \u2192 \u03b1` to the\nimplementation so it can decide when to evaluate it.\n-/\nclass OrElse (\u03b1 : Type u) where\n  /-- The implementation of `a <|> b : \u03b1`. See `HOrElse`. -/\n  orElse  : \u03b1 \u2192 (Unit \u2192 \u03b1) \u2192 \u03b1\n\n/--\nThe homogeneous version of `HAndThen`: `a >> b : \u03b1` where `a b : \u03b1`.\nBecause `b` is \"lazy\" in this notation, it is passed as `Unit \u2192 \u03b1` to the\nimplementation so it can decide when to evaluate it.\n-/\nclass AndThen (\u03b1 : Type u) where\n  /-- The implementation of `a >> b : \u03b1`. See `HAndThen`. -/\n  andThen : \u03b1 \u2192 (Unit \u2192 \u03b1) \u2192 \u03b1\n\n/--\nThe homogeneous version of `HAnd`: `a &&& b : \u03b1` where `a b : \u03b1`.\n(It is called `AndOp` because `And` is taken for the propositional connective.)\n-/\nclass AndOp (\u03b1 : Type u) where\n  /-- The implementation of `a &&& b : \u03b1`. See `HAnd`. -/\n  and : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/-- The homogeneous version of `HXor`: `a ^^^ b : \u03b1` where `a b : \u03b1`. -/\nclass Xor (\u03b1 : Type u) where\n  /-- The implementation of `a ^^^ b : \u03b1`. See `HXor`. -/\n  xor : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/--\nThe homogeneous version of `HOr`: `a ||| b : \u03b1` where `a b : \u03b1`.\n(It is called `OrOp` because `Or` is taken for the propositional connective.)\n-/\nclass OrOp (\u03b1 : Type u) where\n  /-- The implementation of `a ||| b : \u03b1`. See `HOr`. -/\n  or : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/-- The typeclass behind the notation `~~~a : \u03b1` where `a : \u03b1`. -/\nclass Complement (\u03b1 : Type u) where\n  /-- The implementation of `~~~a : \u03b1`. -/\n  complement : \u03b1 \u2192 \u03b1\n\n/-- The homogeneous version of `HShiftLeft`: `a <<< b : \u03b1` where `a b : \u03b1`. -/\nclass ShiftLeft (\u03b1 : Type u) where\n  /-- The implementation of `a <<< b : \u03b1`. See `HShiftLeft`. -/\n  shiftLeft : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n/-- The homogeneous version of `HShiftRight`: `a >>> b : \u03b1` where `a b : \u03b1`. -/\nclass ShiftRight (\u03b1 : Type u) where\n  /-- The implementation of `a >>> b : \u03b1`. See `HShiftRight`. -/\n  shiftRight : \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n@[default_instance]\ninstance [Add \u03b1] : HAdd \u03b1 \u03b1 \u03b1 where\n  hAdd a b := Add.add a b\n\n@[default_instance]\ninstance [Sub \u03b1] : HSub \u03b1 \u03b1 \u03b1 where\n  hSub a b := Sub.sub a b\n\n@[default_instance]\ninstance [Mul \u03b1] : HMul \u03b1 \u03b1 \u03b1 where\n  hMul a b := Mul.mul a b\n\n@[default_instance]\ninstance [Div \u03b1] : HDiv \u03b1 \u03b1 \u03b1 where\n  hDiv a b := Div.div a b\n\n@[default_instance]\ninstance [Mod \u03b1] : HMod \u03b1 \u03b1 \u03b1 where\n  hMod a b := Mod.mod a b\n\n@[default_instance]\ninstance [Pow \u03b1 \u03b2] : HPow \u03b1 \u03b2 \u03b1 where\n  hPow a b := Pow.pow a b\n\n@[default_instance]\ninstance [Append \u03b1] : HAppend \u03b1 \u03b1 \u03b1 where\n  hAppend a b := Append.append a b\n\n@[default_instance]\ninstance [OrElse \u03b1] : HOrElse \u03b1 \u03b1 \u03b1 where\n  hOrElse a b := OrElse.orElse a b\n\n@[default_instance]\ninstance [AndThen \u03b1] : HAndThen \u03b1 \u03b1 \u03b1 where\n  hAndThen a b := AndThen.andThen a b\n\n@[default_instance]\ninstance [AndOp \u03b1] : HAnd \u03b1 \u03b1 \u03b1 where\n  hAnd a b := AndOp.and a b\n\n@[default_instance]\ninstance [Xor \u03b1] : HXor \u03b1 \u03b1 \u03b1 where\n  hXor a b := Xor.xor a b\n\n@[default_instance]\ninstance [OrOp \u03b1] : HOr \u03b1 \u03b1 \u03b1 where\n  hOr a b := OrOp.or a b\n\n@[default_instance]\ninstance [ShiftLeft \u03b1] : HShiftLeft \u03b1 \u03b1 \u03b1 where\n  hShiftLeft a b := ShiftLeft.shiftLeft a b\n\n@[default_instance]\ninstance [ShiftRight \u03b1] : HShiftRight \u03b1 \u03b1 \u03b1 where\n  hShiftRight a b := ShiftRight.shiftRight a b\n\nopen HAdd (hAdd)\nopen HMul (hMul)\nopen HPow (hPow)\nopen HAppend (hAppend)\n\n/--\nThe typeclass behind the notation `a \u2208 s : Prop` where `a : \u03b1`, `s : \u03b3`.\nBecause `\u03b1` is an `outParam`, the \"container type\" `\u03b3` determines the type\nof the elements of the container.\n-/\nclass Membership (\u03b1 : outParam (Type u)) (\u03b3 : Type v) where\n  /-- The membership relation `a \u2208 s : Prop` where `a : \u03b1`, `s : \u03b3`. -/\n  mem : \u03b1 \u2192 \u03b3 \u2192 Prop\n\nset_option bootstrap.genMatcherCode false in\n/--\nAddition of natural numbers.\n\nThis definition is overridden in both the kernel and the compiler to efficiently\nevaluate using the \"bignum\" representation (see `Nat`). The definition provided\nhere is the logical model (and it is soundness-critical that they coincide).\n-/\n@[extern \"lean_nat_add\"]\nprotected def Nat.add : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, Nat.zero   => a\n  | a, Nat.succ b => Nat.succ (Nat.add a b)\n\ninstance : Add Nat where\n  add := Nat.add\n\n/- We mark the following definitions as pattern to make sure they can be used in recursive equations,\n   and reduced by the equation Compiler. -/\nattribute [match_pattern] Nat.add Add.add HAdd.hAdd Neg.neg\n\nset_option bootstrap.genMatcherCode false in\n/--\nMultiplication of natural numbers.\n\nThis definition is overridden in both the kernel and the compiler to efficiently\nevaluate using the \"bignum\" representation (see `Nat`). The definition provided\nhere is the logical model (and it is soundness-critical that they coincide).\n-/\n@[extern \"lean_nat_mul\"]\nprotected def Nat.mul : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | _, 0          => 0\n  | a, Nat.succ b => Nat.add (Nat.mul a b) a\n\ninstance : Mul Nat where\n  mul := Nat.mul\n\nset_option bootstrap.genMatcherCode false in\n/--\nThe power operation on natural numbers.\n\nThis definition is overridden in the compiler to efficiently\nevaluate using the \"bignum\" representation (see `Nat`). The definition provided\nhere is the logical model.\n-/\n@[extern \"lean_nat_pow\"]\nprotected def Nat.pow (m : @& Nat) : (@& Nat) \u2192 Nat\n  | 0      => 1\n  | succ n => Nat.mul (Nat.pow m n) m\n\ninstance : Pow Nat Nat where\n  pow := Nat.pow\n\nset_option bootstrap.genMatcherCode false in\n/--\n(Boolean) equality of natural numbers.\n\nThis definition is overridden in both the kernel and the compiler to efficiently\nevaluate using the \"bignum\" representation (see `Nat`). The definition provided\nhere is the logical model (and it is soundness-critical that they coincide).\n-/\n@[extern \"lean_nat_dec_eq\"]\ndef Nat.beq : (@& Nat) \u2192 (@& Nat) \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ _ => false\n  | succ _, zero   => false\n  | succ n, succ m => beq n m\n\ninstance : BEq Nat where\n  beq := Nat.beq\n\ntheorem Nat.eq_of_beq_eq_true : {n m : Nat} \u2192 Eq (beq n m) true \u2192 Eq n m\n  | zero,   zero,   _ => rfl\n  | zero,   succ _, h => Bool.noConfusion h\n  | succ _, zero,   h => Bool.noConfusion h\n  | succ n, succ m, h =>\n    have : Eq (beq n m) true := h\n    have : Eq n m := eq_of_beq_eq_true this\n    this \u25b8 rfl\n\ntheorem Nat.ne_of_beq_eq_false : {n m : Nat} \u2192 Eq (beq n m) false \u2192 Not (Eq n m)\n  | zero,   zero,   h\u2081, _  => Bool.noConfusion h\u2081\n  | zero,   succ _, _,  h\u2082 => Nat.noConfusion h\u2082\n  | succ _, zero,   _,  h\u2082 => Nat.noConfusion h\u2082\n  | succ n, succ m, h\u2081, h\u2082 =>\n    have : Eq (beq n m) false := h\u2081\n    Nat.noConfusion h\u2082 (fun h\u2082 => absurd h\u2082 (ne_of_beq_eq_false this))\n\n/--\nA decision procedure for equality of natural numbers.\n\nThis definition is overridden in the compiler to efficiently\nevaluate using the \"bignum\" representation (see `Nat`). The definition provided\nhere is the logical model.\n-/\n@[reducible, extern \"lean_nat_dec_eq\"]\nprotected def Nat.decEq (n m : @& Nat) : Decidable (Eq n m) :=\n  match h:beq n m with\n  | true  => isTrue (eq_of_beq_eq_true h)\n  | false => isFalse (ne_of_beq_eq_false h)\n\n@[inline] instance : DecidableEq Nat := Nat.decEq\n\nset_option bootstrap.genMatcherCode false in\n/--\nThe (Boolean) less-equal relation on natural numbers.\n\nThis definition is overridden in both the kernel and the compiler to efficiently\nevaluate using the \"bignum\" representation (see `Nat`). The definition provided\nhere is the logical model (and it is soundness-critical that they coincide).\n-/\n@[extern \"lean_nat_dec_le\"]\ndef Nat.ble : @& Nat \u2192 @& Nat \u2192 Bool\n  | zero,   zero   => true\n  | zero,   succ _ => true\n  | succ _, zero   => false\n  | succ n, succ m => ble n m\n\n/--\nAn inductive definition of the less-equal relation on natural numbers,\ncharacterized as the least relation `\u2264` such that `n \u2264 n` and `n \u2264 m \u2192 n \u2264 m + 1`.\n-/\nprotected inductive Nat.le (n : Nat) : Nat \u2192 Prop\n  /-- Less-equal is reflexive: `n \u2264 n` -/\n  | refl     : Nat.le n n\n  /-- If `n \u2264 m`, then `n \u2264 m + 1`. -/\n  | step {m} : Nat.le n m \u2192 Nat.le n (succ m)\n\ninstance : LE Nat where\n  le := Nat.le\n\n/-- The strict less than relation on natural numbers is defined as `n < m := n + 1 \u2264 m`. -/\nprotected def Nat.lt (n m : Nat) : Prop :=\n  Nat.le (succ n) m\n\ninstance : LT Nat where\n  lt := Nat.lt\n\ntheorem Nat.not_succ_le_zero : \u2200 (n : Nat), LE.le (succ n) 0 \u2192 False\n  | 0,      h => nomatch h\n  | succ _, h => nomatch h\n\ntheorem Nat.not_lt_zero (n : Nat) : Not (LT.lt n 0) :=\n  not_succ_le_zero n\n\ntheorem Nat.zero_le : (n : Nat) \u2192 LE.le 0 n\n  | zero   => Nat.le.refl\n  | succ n => Nat.le.step (zero_le n)\n\ntheorem Nat.succ_le_succ : LE.le n m \u2192 LE.le (succ n) (succ m)\n  | Nat.le.refl   => Nat.le.refl\n  | Nat.le.step h => Nat.le.step (succ_le_succ h)\n\ntheorem Nat.zero_lt_succ (n : Nat) : LT.lt 0 (succ n) :=\n  succ_le_succ (zero_le n)\n\ntheorem Nat.le_step (h : LE.le n m) : LE.le n (succ m) :=\n  Nat.le.step h\n\nprotected theorem Nat.le_trans {n m k : Nat} : LE.le n m \u2192 LE.le m k \u2192 LE.le n k\n  | h,  Nat.le.refl    => h\n  | h\u2081, Nat.le.step h\u2082 => Nat.le.step (Nat.le_trans h\u2081 h\u2082)\n\nprotected theorem Nat.lt_trans {n m k : Nat} (h\u2081 : LT.lt n m) : LT.lt m k \u2192 LT.lt n k :=\n  Nat.le_trans (le_step h\u2081)\n\ntheorem Nat.le_succ (n : Nat) : LE.le n (succ n) :=\n  Nat.le.step Nat.le.refl\n\ntheorem Nat.le_succ_of_le {n m : Nat} (h : LE.le n m) : LE.le n (succ m) :=\n  Nat.le_trans h (le_succ m)\n\nprotected theorem Nat.le_refl (n : Nat) : LE.le n n :=\n  Nat.le.refl\n\ntheorem Nat.succ_pos (n : Nat) : LT.lt 0 (succ n) :=\n  zero_lt_succ n\n\nset_option bootstrap.genMatcherCode false in\n/--\nThe predecessor function on natural numbers.\n\nThis definition is overridden in the compiler to use `n - 1` instead.\nThe definition provided here is the logical model.\n-/\n@[extern c inline \"lean_nat_sub(#1, lean_box(1))\"]\ndef Nat.pred : (@& Nat) \u2192 Nat\n  | 0      => 0\n  | succ a => a\n\ntheorem Nat.pred_le_pred : {n m : Nat} \u2192 LE.le n m \u2192 LE.le (pred n) (pred m)\n  | _,           _, Nat.le.refl   => Nat.le.refl\n  | 0,      succ _, Nat.le.step h => h\n  | succ _, succ _, Nat.le.step h => Nat.le_trans (le_succ _) h\n\ntheorem Nat.le_of_succ_le_succ {n m : Nat} : LE.le (succ n) (succ m) \u2192 LE.le n m :=\n  pred_le_pred\n\ntheorem Nat.le_of_lt_succ {m n : Nat} : LT.lt m (succ n) \u2192 LE.le m n :=\n  le_of_succ_le_succ\n\nprotected theorem Nat.eq_or_lt_of_le : {n m: Nat} \u2192 LE.le n m \u2192 Or (Eq n m) (LT.lt n m)\n  | zero,   zero,   _ => Or.inl rfl\n  | zero,   succ _, _ => Or.inr (Nat.succ_le_succ (Nat.zero_le _))\n  | succ _, zero,   h => absurd h (not_succ_le_zero _)\n  | succ n, succ m, h =>\n    have : LE.le n m := Nat.le_of_succ_le_succ h\n    match Nat.eq_or_lt_of_le this with\n    | Or.inl h => Or.inl (h \u25b8 rfl)\n    | Or.inr h => Or.inr (succ_le_succ h)\n\nprotected theorem Nat.lt_or_ge (n m : Nat) : Or (LT.lt n m) (GE.ge n m) :=\n  match m with\n  | zero   => Or.inr (zero_le n)\n  | succ m =>\n    match Nat.lt_or_ge n m with\n    | Or.inl h => Or.inl (le_succ_of_le h)\n    | Or.inr h =>\n      match Nat.eq_or_lt_of_le h with\n      | Or.inl h1 => Or.inl (h1 \u25b8 Nat.le_refl _)\n      | Or.inr h1 => Or.inr h1\n\ntheorem Nat.not_succ_le_self : (n : Nat) \u2192 Not (LE.le (succ n) n)\n  | 0      => not_succ_le_zero _\n  | succ n => fun h => absurd (le_of_succ_le_succ h) (not_succ_le_self n)\n\nprotected theorem Nat.lt_irrefl (n : Nat) : Not (LT.lt n n) :=\n  Nat.not_succ_le_self n\n\nprotected theorem Nat.lt_of_le_of_lt {n m k : Nat} (h\u2081 : LE.le n m) (h\u2082 : LT.lt m k) : LT.lt n k :=\n  Nat.le_trans (Nat.succ_le_succ h\u2081) h\u2082\n\nprotected theorem Nat.le_antisymm {n m : Nat} (h\u2081 : LE.le n m) (h\u2082 : LE.le m n) : Eq n m :=\n  match h\u2081 with\n  | Nat.le.refl   => rfl\n  | Nat.le.step h => absurd (Nat.lt_of_le_of_lt h h\u2082) (Nat.lt_irrefl n)\n\nprotected theorem Nat.lt_of_le_of_ne {n m : Nat} (h\u2081 : LE.le n m) (h\u2082 : Not (Eq n m)) : LT.lt n m :=\n  match Nat.lt_or_ge n m with\n  | Or.inl h\u2083 => h\u2083\n  | Or.inr h\u2083 => absurd (Nat.le_antisymm h\u2081 h\u2083) h\u2082\n\ntheorem Nat.le_of_ble_eq_true (h : Eq (Nat.ble n m) true) : LE.le n m :=\n  match n, m with\n  | 0,      _      => Nat.zero_le _\n  | succ _, succ _ => Nat.succ_le_succ (le_of_ble_eq_true h)\n\ntheorem Nat.ble_self_eq_true : (n : Nat) \u2192 Eq (Nat.ble n n) true\n  | 0      => rfl\n  | succ n => ble_self_eq_true n\n\ntheorem Nat.ble_succ_eq_true : {n m : Nat} \u2192 Eq (Nat.ble n m) true \u2192 Eq (Nat.ble n (succ m)) true\n  | 0,      _,      _ => rfl\n  | succ n, succ _, h => ble_succ_eq_true (n := n) h\n\ntheorem Nat.ble_eq_true_of_le (h : LE.le n m) : Eq (Nat.ble n m) true :=\n  match h with\n  | Nat.le.refl   => Nat.ble_self_eq_true n\n  | Nat.le.step h => Nat.ble_succ_eq_true (ble_eq_true_of_le h)\n\ntheorem Nat.not_le_of_not_ble_eq_true (h : Not (Eq (Nat.ble n m) true)) : Not (LE.le n m) :=\n  fun h' => absurd (Nat.ble_eq_true_of_le h') h\n\n@[extern \"lean_nat_dec_le\"]\ninstance Nat.decLe (n m : @& Nat) : Decidable (LE.le n m) :=\n  dite (Eq (Nat.ble n m) true) (fun h => isTrue (Nat.le_of_ble_eq_true h)) (fun h => isFalse (Nat.not_le_of_not_ble_eq_true h))\n\n@[extern \"lean_nat_dec_lt\"]\ninstance Nat.decLt (n m : @& Nat) : Decidable (LT.lt n m) :=\n  decLe (succ n) m\n\ninstance : Min Nat := minOfLe\n\nset_option bootstrap.genMatcherCode false in\n/--\n(Truncated) subtraction of natural numbers. Because natural numbers are not\nclosed under subtraction, we define `m - n` to be `0` when `n < m`.\n\nThis definition is overridden in both the kernel and the compiler to efficiently\nevaluate using the \"bignum\" representation (see `Nat`). The definition provided\nhere is the logical model (and it is soundness-critical that they coincide).\n-/\n@[extern \"lean_nat_sub\"]\nprotected def Nat.sub : (@& Nat) \u2192 (@& Nat) \u2192 Nat\n  | a, 0      => a\n  | a, succ b => pred (Nat.sub a b)\n\ninstance : Sub Nat where\n  sub := Nat.sub\n\n/--\nGets the word size of the platform. That is, whether the platform is 64 or 32 bits.\n\nThis function is opaque because we cannot guarantee at compile time that the target\nwill have the same size as the host, and also because we would like to avoid\ntypechecking being architecture-dependent. Nevertheless, lean only works on\n64 and 32 bit systems so we can encode this as a fact available for proof purposes.\n-/\n@[extern \"lean_system_platform_nbits\"] opaque System.Platform.getNumBits : Unit \u2192 Subtype fun (n : Nat) => Or (Eq n 32) (Eq n 64) :=\n  fun _ => \u27e864, Or.inr rfl\u27e9 -- inhabitant\n\n/-- Gets the word size of the platform. That is, whether the platform is 64 or 32 bits. -/\ndef System.Platform.numBits : Nat :=\n  (getNumBits ()).val\n\ntheorem System.Platform.numBits_eq : Or (Eq numBits 32) (Eq numBits 64) :=\n  (getNumBits ()).property\n\n/--\n`Fin n` is a natural number `i` with the constraint that `0 \u2264 i < n`.\nIt is the \"canonical type with `n` elements\".\n-/\nstructure Fin (n : Nat) where\n  /-- If `i : Fin n`, then `i.val : \u2115` is the described number. It can also be\n  written as `i.1` or just `i` when the target type is known. -/\n  val  : Nat\n  /-- If `i : Fin n`, then `i.2` is a proof that `i.1 < n`. -/\n  isLt : LT.lt val n\n\ntheorem Fin.eq_of_val_eq {n} : \u2200 {i j : Fin n}, Eq i.val j.val \u2192 Eq i j\n  | \u27e8_, _\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Fin.val_eq_of_eq {n} {i j : Fin n} (h : Eq i j) : Eq i.val j.val :=\n  h \u25b8 rfl\n\ntheorem Fin.ne_of_val_ne {n} {i j : Fin n} (h : Not (Eq i.val j.val)) : Not (Eq i j) :=\n  fun h' => absurd (val_eq_of_eq h') h\n\ninstance (n : Nat) : DecidableEq (Fin n) :=\n  fun i j =>\n    match decEq i.val j.val with\n    | isTrue h  => isTrue (Fin.eq_of_val_eq h)\n    | isFalse h => isFalse (Fin.ne_of_val_ne h)\n\ninstance {n} : LT (Fin n) where\n  lt a b := LT.lt a.val b.val\n\ninstance {n} : LE (Fin n) where\n  le a b := LE.le a.val b.val\n\ninstance Fin.decLt {n} (a b : Fin n) : Decidable (LT.lt a b) := Nat.decLt ..\ninstance Fin.decLe {n} (a b : Fin n) : Decidable (LE.le a b) := Nat.decLe ..\n\n/-- The size of type `UInt8`, that is, `2^8 = 256`. -/\ndef UInt8.size : Nat := 256\n\n/--\nThe type of unsigned 8-bit integers. This type has special support in the\ncompiler to make it actually 8 bits rather than wrapping a `Nat`.\n-/\nstructure UInt8 where\n  /-- Unpack a `UInt8` as a `Nat` less than `2^8`.\n  This function is overridden with a native implementation. -/\n  val : Fin UInt8.size\n\nattribute [extern \"lean_uint8_of_nat_mk\"] UInt8.mk\nattribute [extern \"lean_uint8_to_nat\"] UInt8.val\n\n/--\nPack a `Nat` less than `2^8` into a `UInt8`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint8_of_nat\"]\ndef UInt8.ofNatCore (n : @& Nat) (h : LT.lt n UInt8.size) : UInt8 where\n  val := { val := n, isLt := h }\n\nset_option bootstrap.genMatcherCode false in\n/--\nDecides equality on `UInt8`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint8_dec_eq\"]\ndef UInt8.decEq (a b : UInt8) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt8.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt8 := UInt8.decEq\n\ninstance : Inhabited UInt8 where\n  default := UInt8.ofNatCore 0 (by decide)\n\n/-- The size of type `UInt16`, that is, `2^16 = 65536`. -/\ndef UInt16.size : Nat := 65536\n\n/--\nThe type of unsigned 16-bit integers. This type has special support in the\ncompiler to make it actually 16 bits rather than wrapping a `Nat`.\n-/\nstructure UInt16 where\n  /-- Unpack a `UInt16` as a `Nat` less than `2^16`.\n  This function is overridden with a native implementation. -/\n  val : Fin UInt16.size\n\nattribute [extern \"lean_uint16_of_nat_mk\"] UInt16.mk\nattribute [extern \"lean_uint16_to_nat\"] UInt16.val\n\n/--\nPack a `Nat` less than `2^16` into a `UInt16`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint16_of_nat\"]\ndef UInt16.ofNatCore (n : @& Nat) (h : LT.lt n UInt16.size) : UInt16 where\n  val := { val := n, isLt := h }\n\nset_option bootstrap.genMatcherCode false in\n/--\nDecides equality on `UInt16`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint16_dec_eq\"]\ndef UInt16.decEq (a b : UInt16) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt16.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt16 := UInt16.decEq\n\ninstance : Inhabited UInt16 where\n  default := UInt16.ofNatCore 0 (by decide)\n\n/-- The size of type `UInt32`, that is, `2^32 = 4294967296`. -/\ndef UInt32.size : Nat := 4294967296\n\n/--\nThe type of unsigned 32-bit integers. This type has special support in the\ncompiler to make it actually 32 bits rather than wrapping a `Nat`.\n-/\nstructure UInt32 where\n  /-- Unpack a `UInt32` as a `Nat` less than `2^32`.\n  This function is overridden with a native implementation. -/\n  val : Fin UInt32.size\n\nattribute [extern \"lean_uint32_of_nat_mk\"] UInt32.mk\nattribute [extern \"lean_uint32_to_nat\"] UInt32.val\n\n/--\nPack a `Nat` less than `2^32` into a `UInt32`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint32_of_nat\"]\ndef UInt32.ofNatCore (n : @& Nat) (h : LT.lt n UInt32.size) : UInt32 where\n  val := { val := n, isLt := h }\n\n/--\nUnpack a `UInt32` as a `Nat`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint32_to_nat\"]\ndef UInt32.toNat (n : UInt32) : Nat := n.val.val\n\nset_option bootstrap.genMatcherCode false in\n/--\nDecides equality on `UInt32`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint32_dec_eq\"]\ndef UInt32.decEq (a b : UInt32) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt32.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt32 := UInt32.decEq\n\ninstance : Inhabited UInt32 where\n  default := UInt32.ofNatCore 0 (by decide)\n\ninstance : LT UInt32 where\n  lt a b := LT.lt a.val b.val\n\ninstance : LE UInt32 where\n  le a b := LE.le a.val b.val\n\nset_option bootstrap.genMatcherCode false in\n/--\nDecides less-equal on `UInt32`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint32_dec_lt\"]\ndef UInt32.decLt (a b : UInt32) : Decidable (LT.lt a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LT.lt n m))\n\nset_option bootstrap.genMatcherCode false in\n/--\nDecides less-than on `UInt32`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint32_dec_le\"]\ndef UInt32.decLe (a b : UInt32) : Decidable (LE.le a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LE.le n m))\n\ninstance (a b : UInt32) : Decidable (LT.lt a b) := UInt32.decLt a b\ninstance (a b : UInt32) : Decidable (LE.le a b) := UInt32.decLe a b\ninstance : Max UInt32 := maxOfLe\ninstance : Min UInt32 := minOfLe\n\n/-- The size of type `UInt64`, that is, `2^64 = 18446744073709551616`. -/\ndef UInt64.size : Nat := 18446744073709551616\n/--\nThe type of unsigned 64-bit integers. This type has special support in the\ncompiler to make it actually 64 bits rather than wrapping a `Nat`.\n-/\nstructure UInt64 where\n  /-- Unpack a `UInt64` as a `Nat` less than `2^64`.\n  This function is overridden with a native implementation. -/\n  val : Fin UInt64.size\n\nattribute [extern \"lean_uint64_of_nat_mk\"] UInt64.mk\nattribute [extern \"lean_uint64_to_nat\"] UInt64.val\n\n/--\nPack a `Nat` less than `2^64` into a `UInt64`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint64_of_nat\"]\ndef UInt64.ofNatCore (n : @& Nat) (h : LT.lt n UInt64.size) : UInt64 where\n  val := { val := n, isLt := h }\n\nset_option bootstrap.genMatcherCode false in\n/--\nDecides equality on `UInt64`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint64_dec_eq\"]\ndef UInt64.decEq (a b : UInt64) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => UInt64.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq UInt64 := UInt64.decEq\n\ninstance : Inhabited UInt64 where\n  default := UInt64.ofNatCore 0 (by decide)\n\n/--\nThe size of type `UInt16`, that is, `2^System.Platform.numBits`, which may\nbe either `2^32` or `2^64` depending on the platform's architecture.\n-/\ndef USize.size : Nat := hPow 2 System.Platform.numBits\n\ntheorem usize_size_eq : Or (Eq USize.size 4294967296) (Eq USize.size 18446744073709551616) :=\n  show Or (Eq (hPow 2 System.Platform.numBits) 4294967296) (Eq (hPow 2 System.Platform.numBits) 18446744073709551616) from\n  match System.Platform.numBits, System.Platform.numBits_eq with\n  | _, Or.inl rfl => Or.inl (by decide)\n  | _, Or.inr rfl => Or.inr (by decide)\n\n/--\nA `USize` is an unsigned integer with the size of a word\nfor the platform's architecture.\n\nFor example, if running on a 32-bit machine, USize is equivalent to UInt32.\nOr on a 64-bit machine, UInt64.\n-/\nstructure USize where\n  /-- Unpack a `USize` as a `Nat` less than `USize.size`.\n  This function is overridden with a native implementation. -/\n  val : Fin USize.size\n\nattribute [extern \"lean_usize_of_nat_mk\"] USize.mk\nattribute [extern \"lean_usize_to_nat\"] USize.val\n\n/--\nPack a `Nat` less than `USize.size` into a `USize`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNatCore (n : @& Nat) (h : LT.lt n USize.size) : USize := {\n  val := { val := n, isLt := h }\n}\n\nset_option bootstrap.genMatcherCode false in\n/--\nDecides equality on `USize`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_usize_dec_eq\"]\ndef USize.decEq (a b : USize) : Decidable (Eq a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h =>isTrue (h \u25b8 rfl)) (fun h => isFalse (fun h' => USize.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq USize := USize.decEq\n\ninstance : Inhabited USize where\n  default := USize.ofNatCore 0 (match USize.size, usize_size_eq with\n    | _, Or.inl rfl => by decide\n    | _, Or.inr rfl => by decide)\n\n/--\nUpcast a `Nat` less than `2^32` to a `USize`.\nThis is lossless because `USize.size` is either `2^32` or `2^64`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_usize_of_nat\"]\ndef USize.ofNat32 (n : @& Nat) (h : LT.lt n 4294967296) : USize where\n  val := {\n    val  := n\n    isLt := match USize.size, usize_size_eq with\n      | _, Or.inl rfl => h\n      | _, Or.inr rfl => Nat.lt_trans h (by decide)\n  }\n\n/--\nA `Nat` denotes a valid unicode codepoint if it is less than `0x110000`, and\nit is also not a \"surrogate\" character (the range `0xd800` to `0xdfff` inclusive).\n-/\nabbrev Nat.isValidChar (n : Nat) : Prop :=\n  Or (LT.lt n 0xd800) (And (LT.lt 0xdfff n) (LT.lt n 0x110000))\n\n/--\nA `UInt32` denotes a valid unicode codepoint if it is less than `0x110000`, and\nit is also not a \"surrogate\" character (the range `0xd800` to `0xdfff` inclusive).\n-/\nabbrev UInt32.isValidChar (n : UInt32) : Prop :=\n  n.toNat.isValidChar\n\n/-- The `Char` Type represents an unicode scalar value.\n    See http://www.unicode.org/glossary/#unicode_scalar_value). -/\nstructure Char where\n  /-- The underlying unicode scalar value as a `UInt32`. -/\n  val   : UInt32\n  /-- The value must be a legal codepoint. -/\n  valid : val.isValidChar\n\nprivate theorem isValidChar_UInt32 {n : Nat} (h : n.isValidChar) : LT.lt n UInt32.size :=\n  match h with\n  | Or.inl h      => Nat.lt_trans h (by decide)\n  | Or.inr \u27e8_, h\u27e9 => Nat.lt_trans h (by decide)\n\n/--\nPack a `Nat` encoding a valid codepoint into a `Char`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_uint32_of_nat\"]\ndef Char.ofNatAux (n : @& Nat) (h : n.isValidChar) : Char :=\n  { val := \u27e8{ val := n, isLt := isValidChar_UInt32 h }\u27e9, valid := h }\n\n/--\nConvert a `Nat` into a `Char`. If the `Nat` does not encode a valid unicode scalar value,\n`'\\0'` is returned instead.\n-/\n@[noinline, match_pattern]\ndef Char.ofNat (n : Nat) : Char :=\n  dite (n.isValidChar)\n    (fun h => Char.ofNatAux n h)\n    (fun _ => { val := \u27e8{ val := 0, isLt := by decide }\u27e9, valid := Or.inl (by decide) })\n\ntheorem Char.eq_of_val_eq : \u2200 {c d : Char}, Eq c.val d.val \u2192 Eq c d\n  | \u27e8_, _\u27e9, \u27e8_, _\u27e9, rfl => rfl\n\ntheorem Char.val_eq_of_eq : \u2200 {c d : Char}, Eq c d \u2192 Eq c.val d.val\n  | _, _, rfl => rfl\n\ntheorem Char.ne_of_val_ne {c d : Char} (h : Not (Eq c.val d.val)) : Not (Eq c d) :=\n  fun h' => absurd (val_eq_of_eq h') h\n\ntheorem Char.val_ne_of_ne {c d : Char} (h : Not (Eq c d)) : Not (Eq c.val d.val) :=\n  fun h' => absurd (eq_of_val_eq h') h\n\ninstance : DecidableEq Char :=\n  fun c d =>\n    match decEq c.val d.val with\n    | isTrue h  => isTrue (Char.eq_of_val_eq h)\n    | isFalse h => isFalse (Char.ne_of_val_ne h)\n\n/-- Returns the number of bytes required to encode this `Char` in UTF-8. -/\ndef Char.utf8Size (c : Char) : UInt32 :=\n  let v := c.val\n  ite (LE.le v (UInt32.ofNatCore 0x7F (by decide)))\n    (UInt32.ofNatCore 1 (by decide))\n    (ite (LE.le v (UInt32.ofNatCore 0x7FF (by decide)))\n      (UInt32.ofNatCore 2 (by decide))\n      (ite (LE.le v (UInt32.ofNatCore 0xFFFF (by decide)))\n        (UInt32.ofNatCore 3 (by decide))\n        (UInt32.ofNatCore 4 (by decide))))\n\n/--\n`Option \u03b1` is the type of values which are either `some a` for some `a : \u03b1`,\nor `none`. In functional programming languages, this type is used to represent\nthe possibility of failure, or sometimes nullability.\n\nFor example, the function `HashMap.find? : HashMap \u03b1 \u03b2 \u2192 \u03b1 \u2192 Option \u03b2` looks up\na specified key `a : \u03b1` inside the map. Because we do not know in advance\nwhether the key is actually in the map, the return type is `Option \u03b2`, where\n`none` means the value was not in the map, and `some b` means that the value\nwas found and `b` is the value retrieved.\n\nTo extract a value from an `Option \u03b1`, we use pattern matching:\n```\ndef map (f : \u03b1 \u2192 \u03b2) (x : Option \u03b1) : Option \u03b2 :=\n  match x with\n  | some a => some (f a)\n  | none => none\n```\nWe can also use `if let` to pattern match on `Option` and get the value\nin the branch:\n```\ndef map (f : \u03b1 \u2192 \u03b2) (x : Option \u03b1) : Option \u03b2 :=\n  if let some a := x then\n    some (f a)\n  else\n    none\n```\n-/\ninductive Option (\u03b1 : Type u) where\n  /-- No value. -/\n  | none : Option \u03b1\n  /-- Some value of type `\u03b1`. -/\n  | some (val : \u03b1) : Option \u03b1\n\nattribute [unbox] Option\n\nexport Option (none some)\n\ninstance {\u03b1} : Inhabited (Option \u03b1) where\n  default := none\n\n/--\nGet with default. If `opt : Option \u03b1` and `dflt : \u03b1`, then `opt.getD dflt`\nreturns `a` if `opt = some a` and `dflt` otherwise.\n\nThis function is `@[macro_inline]`, so `dflt` will not be evaluated unless\n`opt` turns out to be `none`.\n-/\n@[macro_inline] def Option.getD : Option \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  | some x, _ => x\n  | none,   e => e\n\n/--\nMap a function over an `Option` by applying the function to the contained\nvalue if present.\n-/\n@[inline] protected def Option.map (f : \u03b1 \u2192 \u03b2) : Option \u03b1 \u2192 Option \u03b2\n  | some x => some (f x)\n  | none   => none\n\n/--\n`List \u03b1` is the type of ordered lists with elements of type `\u03b1`.\nIt is implemented as a linked list.\n\n`List \u03b1` is isomorphic to `Array \u03b1`, but they are useful for different things:\n* `List \u03b1` is easier for reasoning, and\n  `Array \u03b1` is modeled as a wrapper around `List \u03b1`\n* `List \u03b1` works well as a persistent data structure, when many copies of the\n  tail are shared. When the value is not shared, `Array \u03b1` will have better\n  performance because it can do destructive updates.\n-/\ninductive List (\u03b1 : Type u) where\n  /-- `[]` is the empty list. -/\n  | nil : List \u03b1\n  /-- If `a : \u03b1` and `l : List \u03b1`, then `cons a l`, or `a :: l`, is the\n  list whose first element is `a` and with `l` as the rest of the list. -/\n  | cons (head : \u03b1) (tail : List \u03b1) : List \u03b1\n\ninstance {\u03b1} : Inhabited (List \u03b1) where\n  default := List.nil\n\n/-- Implements decidable equality for `List \u03b1`, assuming `\u03b1` has decidable equality. -/\nprotected def List.hasDecEq {\u03b1 : Type u} [DecidableEq \u03b1] : (a b : List \u03b1) \u2192 Decidable (Eq a b)\n  | nil,       nil       => isTrue rfl\n  | cons _ _, nil        => isFalse (fun h => List.noConfusion h)\n  | nil,       cons _ _  => isFalse (fun h => List.noConfusion h)\n  | cons a as, cons b bs =>\n    match decEq a b with\n    | isTrue hab  =>\n      match List.hasDecEq as bs with\n      | isTrue habs  => isTrue (hab \u25b8 habs \u25b8 rfl)\n      | isFalse nabs => isFalse (fun h => List.noConfusion h (fun _ habs => absurd habs nabs))\n    | isFalse nab => isFalse (fun h => List.noConfusion h (fun hab _ => absurd hab nab))\n\ninstance {\u03b1 : Type u} [DecidableEq \u03b1] : DecidableEq (List \u03b1) := List.hasDecEq\n\n/--\nFolds a function over a list from the left:\n`foldl f z [a, b, c] = f (f (f z a) b) c`\n-/\n@[specialize]\ndef List.foldl {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b1) : (init : \u03b1) \u2192 List \u03b2 \u2192 \u03b1\n  | a, nil      => a\n  | a, cons b l => foldl f (f a b) l\n\n/--\n`l.set n a` sets the value of list `l` at (zero-based) index `n` to `a`:\n`[a, b, c, d].set 1 b' = [a, b', c, d]`\n-/\ndef List.set : List \u03b1 \u2192 Nat \u2192 \u03b1 \u2192 List \u03b1\n  | cons _ as, 0,          b => cons b as\n  | cons a as, Nat.succ n, b => cons a (set as n b)\n  | nil,       _,          _ => nil\n\n/--\nThe length of a list: `[].length = 0` and `(a :: l).length = l.length + 1`.\n\nThis function is overridden in the compiler to `lengthTR`, which uses constant\nstack space, while leaving this function to use the \"naive\" recursion which is\neasier for reasoning.\n-/\ndef List.length : List \u03b1 \u2192 Nat\n  | nil       => 0\n  | cons _ as => HAdd.hAdd (length as) 1\n\n/-- Auxiliary function for `List.lengthTR`. -/\ndef List.lengthTRAux : List \u03b1 \u2192 Nat \u2192 Nat\n  | nil,       n => n\n  | cons _ as, n => lengthTRAux as (Nat.succ n)\n\n/--\nA tail-recursive version of `List.length`, used to implement `List.length`\nwithout running out of stack space.\n-/\ndef List.lengthTR (as : List \u03b1) : Nat :=\n  lengthTRAux as 0\n\n@[simp] theorem List.length_cons {\u03b1} (a : \u03b1) (as : List \u03b1) : Eq (cons a as).length as.length.succ :=\n  rfl\n\n/-- `l.concat a` appends `a` at the *end* of `l`, that is, `l ++ [a]`. -/\ndef List.concat {\u03b1 : Type u} : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1\n  | nil,       b => cons b nil\n  | cons a as, b => cons a (concat as b)\n\n/--\n`as.get i` returns the `i`'th element of the list `as`.\nThis version of the function uses `i : Fin as.length` to ensure that it will\nnot index out of bounds.\n-/\ndef List.get {\u03b1 : Type u} : (as : List \u03b1) \u2192 Fin as.length \u2192 \u03b1\n  | cons a _,  \u27e80, _\u27e9 => a\n  | cons _ as, \u27e8Nat.succ i, h\u27e9 => get as \u27e8i, Nat.le_of_succ_le_succ h\u27e9\n\n/--\n`String` is the type of (UTF-8 encoded) strings.\n\nThe compiler overrides the data representation of this type to a byte sequence,\nand both `String.utf8ByteSize` and `String.length` are cached and O(1).\n-/\nstructure String where\n  /-- Pack a `List Char` into a `String`. This function is overridden by the\n  compiler and is O(n) in the length of the list. -/\n  mk ::\n  /-- Unpack `String` into a `List Char`. This function is overridden by the\n  compiler and is O(n) in the length of the list. -/\n  data : List Char\n\nattribute [extern \"lean_string_mk\"] String.mk\nattribute [extern \"lean_string_data\"] String.data\n\n/--\nDecides equality on `String`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_string_dec_eq\"]\ndef String.decEq (s\u2081 s\u2082 : @& String) : Decidable (Eq s\u2081 s\u2082) :=\n  match s\u2081, s\u2082 with\n  | \u27e8s\u2081\u27e9, \u27e8s\u2082\u27e9 =>\n    dite (Eq s\u2081 s\u2082) (fun h => isTrue (congrArg _ h)) (fun h => isFalse (fun h' => String.noConfusion h' (fun h' => absurd h' h)))\n\ninstance : DecidableEq String := String.decEq\n\n/--\nA byte position in a `String`. Internally, `String`s are UTF-8 encoded.\nCodepoint positions (counting the Unicode codepoints rather than bytes)\nare represented by plain `Nat`s instead.\nIndexing a `String` by a byte position is constant-time, while codepoint\npositions need to be translated internally to byte positions in linear-time.\n-/\nstructure String.Pos where\n  /-- Get the underlying byte index of a `String.Pos` -/\n  byteIdx : Nat := 0\n\ninstance : Inhabited String.Pos where\n  default := {}\n\ninstance : DecidableEq String.Pos :=\n  fun \u27e8a\u27e9 \u27e8b\u27e9 => match decEq a b with\n    | isTrue h => isTrue (h \u25b8 rfl)\n    | isFalse h => isFalse (fun he => String.Pos.noConfusion he fun he => absurd he h)\n\n/--\nA `Substring` is a view into some subslice of a `String`.\nThe actual string slicing is deferred because this would require copying the\nstring; here we only store a reference to the original string for\ngarbage collection purposes.\n-/\nstructure Substring where\n  /-- The underlying string to slice. -/\n  str      : String\n  /-- The byte position of the start of the string slice. -/\n  startPos : String.Pos\n  /-- The byte position of the end of the string slice. -/\n  stopPos  : String.Pos\n\ninstance : Inhabited Substring where\n  default := \u27e8\"\", {}, {}\u27e9\n\n/-- The byte length of the substring. -/\n@[inline] def Substring.bsize : Substring \u2192 Nat\n  | \u27e8_, b, e\u27e9 => e.byteIdx.sub b.byteIdx\n\n/-- Returns the number of bytes required to encode this `Char` in UTF-8. -/\ndef String.csize (c : Char) : Nat :=\n  c.utf8Size.toNat\n\n/--\nThe UTF-8 byte length of this string.\nThis is overridden by the compiler to be cached and O(1).\n-/\n@[extern \"lean_string_utf8_byte_size\"]\ndef String.utf8ByteSize : (@& String) \u2192 Nat\n  | \u27e8s\u27e9 => go s\nwhere\n  go : List Char \u2192 Nat\n   | .nil       => 0\n   | .cons c cs => hAdd (go cs) (csize c)\n\ninstance : HAdd String.Pos String.Pos String.Pos where\n  hAdd p\u2081 p\u2082 := { byteIdx := hAdd p\u2081.byteIdx p\u2082.byteIdx }\n\ninstance : HSub String.Pos String.Pos String.Pos where\n  hSub p\u2081 p\u2082 := { byteIdx := HSub.hSub p\u2081.byteIdx p\u2082.byteIdx }\n\ninstance : HAdd String.Pos Char String.Pos where\n  hAdd p c := { byteIdx := hAdd p.byteIdx (String.csize c) }\n\ninstance : HAdd String.Pos String String.Pos where\n  hAdd p s := { byteIdx := hAdd p.byteIdx s.utf8ByteSize }\n\ninstance : LE String.Pos where\n  le p\u2081 p\u2082 := LE.le p\u2081.byteIdx p\u2082.byteIdx\n\ninstance : LT String.Pos where\n  lt p\u2081 p\u2082 := LT.lt p\u2081.byteIdx p\u2082.byteIdx\n\ninstance (p\u2081 p\u2082 : String.Pos) : Decidable (LE.le p\u2081 p\u2082) :=\n  inferInstanceAs (Decidable (LE.le p\u2081.byteIdx p\u2082.byteIdx))\n\ninstance (p\u2081 p\u2082 : String.Pos) : Decidable (LT.lt p\u2081 p\u2082) :=\n  inferInstanceAs (Decidable (LT.lt p\u2081.byteIdx p\u2082.byteIdx))\n\n/-- A `String.Pos` pointing at the end of this string. -/\n@[inline] def String.endPos (s : String) : String.Pos where\n  byteIdx := utf8ByteSize s\n\n/-- Convert a `String` into a `Substring` denoting the entire string. -/\n@[inline] def String.toSubstring (s : String) : Substring where\n  str      := s\n  startPos := {}\n  stopPos  := s.endPos\n\n/-- `String.toSubstring` without `[inline]` annotation. -/\ndef String.toSubstring' (s : String) : Substring :=\n  s.toSubstring\n\n/--\nThis function will cast a value of type `\u03b1` to type `\u03b2`, and is a no-op in the\ncompiler. This function is **extremely dangerous** because there is no guarantee\nthat types `\u03b1` and `\u03b2` have the same data representation, and this can lead to\nmemory unsafety. It is also logically unsound, since you could just cast\n`True` to `False`. For all those reasons this function is marked as `unsafe`.\n\nIt is implemented by lifting both `\u03b1` and `\u03b2` into a common universe, and then\nusing `cast (lcProof : ULift (PLift \u03b1) = ULift (PLift \u03b2))` to actually perform\nthe cast. All these operations are no-ops in the compiler.\n\nUsing this function correctly requires some knowledge of the data representation\nof the source and target types. Some general classes of casts which are safe in\nthe current runtime:\n\n* `Array \u03b1` to `Array \u03b2` where `\u03b1` and `\u03b2` have compatible representations,\n  or more generally for other inductive types.\n* `Quot \u03b1 r` and `\u03b1`.\n* `@Subtype \u03b1 p` and `\u03b1`, or generally any structure containing only one\n  non-`Prop` field of type `\u03b1`.\n* Casting `\u03b1` to/from `NonScalar` when `\u03b1` is a boxed generic type\n  (i.e. a function that accepts an arbitrary type `\u03b1` and is not specialized to\n  a scalar type like `UInt8`).\n-/\nunsafe def unsafeCast {\u03b1 : Sort u} {\u03b2 : Sort v} (a : \u03b1) : \u03b2 :=\n  PLift.down (ULift.down.{max u v} (cast lcProof (ULift.up.{max u v} (PLift.up a))))\n\n\n/-- Auxiliary definition for `panic`. -/\n/-\nThis is a workaround for `panic` occurring in monadic code. See issue #695.\nThe `panicCore` definition cannot be specialized since it is an extern.\nWhen `panic` occurs in monadic code, the `Inhabited \u03b1` parameter depends on a\n`[inst : Monad m]` instance. The `inst` parameter will not be eliminated during\nspecialization if it occurs inside of a binder (to avoid work duplication), and\nwill prevent the actual monad from being \"copied\" to the code being specialized.\nWhen we reimplement the specializer, we may consider copying `inst` if it also\noccurs outside binders or if it is an instance.\n-/\n@[never_extract, extern \"lean_panic_fn\"]\ndef panicCore {\u03b1 : Type u} [Inhabited \u03b1] (msg : String) : \u03b1 := default\n\n/--\n`(panic \"msg\" : \u03b1)` has a built-in implementation which prints `msg` to\nthe error buffer. It *does not* terminate execution, and because it is a safe\nfunction, it still has to return an element of `\u03b1`, so it takes `[Inhabited \u03b1]`\nand returns `default`. It is primarily intended for debugging in pure contexts,\nand assertion failures.\n\nBecause this is a pure function with side effects, it is marked as\n`@[never_extract]` so that the compiler will not perform common sub-expression\nelimination and other optimizations that assume that the expression is pure.\n-/\n@[noinline, never_extract]\ndef panic {\u03b1 : Type u} [Inhabited \u03b1] (msg : String) : \u03b1 :=\n  panicCore msg\n\n-- TODO: this be applied directly to `Inhabited`'s definition when we remove the above workaround\nattribute [nospecialize] Inhabited\n\n/--\nThe class `GetElem cont idx elem dom` implements the `xs[i]` notation.\nWhen you write this, given `xs : cont` and `i : idx`, lean looks for an instance\nof `GetElem cont idx elem dom`. Here `elem` is the type of `xs[i]`, while\n`dom` is whatever proof side conditions are required to make this applicable.\nFor example, the instance for arrays looks like\n`GetElem (Array \u03b1) Nat \u03b1 (fun xs i => i < xs.size)`.\n\nThe proof side-condition `dom xs i` is automatically dispatched by the\n`get_elem_tactic` tactic, which can be extended by adding more clauses to\n`get_elem_tactic_trivial`.\n-/\nclass GetElem (cont : Type u) (idx : Type v) (elem : outParam (Type w)) (dom : outParam (cont \u2192 idx \u2192 Prop)) where\n  /--\n  The syntax `arr[i]` gets the `i`'th element of the collection `arr`.\n  If there are proof side conditions to the application, they will be automatically\n  inferred by the `get_elem_tactic` tactic.\n\n  The actual behavior of this class is type-dependent,\n  but here are some important implementations:\n  * `arr[i] : \u03b1` where `arr : Array \u03b1` and `i : Nat` or `i : USize`:\n    does array indexing with no bounds check and a proof side goal `i < arr.size`.\n  * `l[i] : \u03b1` where `l : List \u03b1` and `i : Nat`: index into a list,\n    with proof side goal `i < l.length`.\n  * `stx[i] : Syntax` where `stx : Syntax` and `i : Nat`: get a syntax argument,\n    no side goal (returns `.missing` out of range)\n\n  There are other variations on this syntax:\n  * `arr[i]`: proves the proof side goal by `get_elem_tactic`\n  * `arr[i]!`: panics if the side goal is false\n  * `arr[i]?`: returns `none` if the side goal is false\n  * `arr[i]'h`: uses `h` to prove the side goal\n  -/\n  getElem (xs : cont) (i : idx) (h : dom xs i) : elem\n\nexport GetElem (getElem)\n\n/--\n`Array \u03b1` is the type of [dynamic arrays](https://en.wikipedia.org/wiki/Dynamic_array)\nwith elements from `\u03b1`. This type has special support in the runtime.\n\nAn array has a size and a capacity; the size is `Array.size` but the capacity\nis not observable from lean code. Arrays perform best when unshared; as long\nas they are used \"linearly\" all updates will be performed destructively on the\narray, so it has comparable performance to mutable arrays in imperative\nprogramming languages.\n-/\nstructure Array (\u03b1 : Type u) where\n  /-- Convert a `List \u03b1` into an `Array \u03b1`. This function is overridden\n  to `List.toArray` and is O(n) in the length of the list. -/\n  mk ::\n  /-- Convert an `Array \u03b1` into a `List \u03b1`. This function is overridden\n  to `Array.toList` and is O(n) in the length of the list. -/\n  data : List \u03b1\n\nattribute [extern \"lean_array_data\"] Array.data\nattribute [extern \"lean_array_mk\"] Array.mk\n\n/-- Construct a new empty array with initial capacity `c`. -/\n@[extern \"lean_mk_empty_array_with_capacity\"]\ndef Array.mkEmpty {\u03b1 : Type u} (c : @& Nat) : Array \u03b1 where\n  data := List.nil\n\n/-- Construct a new empty array. -/\ndef Array.empty {\u03b1 : Type u} : Array \u03b1 := mkEmpty 0\n\n/-- Get the size of an array. This is a cached value, so it is O(1) to access. -/\n@[reducible, extern \"lean_array_get_size\"]\ndef Array.size {\u03b1 : Type u} (a : @& Array \u03b1) : Nat :=\n a.data.length\n\n/-- Access an element from an array without bounds checks, using a `Fin` index. -/\n@[extern \"lean_array_fget\"]\ndef Array.get {\u03b1 : Type u} (a : @& Array \u03b1) (i : @& Fin a.size) : \u03b1 :=\n  a.data.get i\n\n/-- Access an element from an array, or return `v\u2080` if the index is out of bounds. -/\n@[inline] abbrev Array.getD (a : Array \u03b1) (i : Nat) (v\u2080 : \u03b1) : \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.get \u27e8i, h\u27e9) (fun _ => v\u2080)\n\n/-- Access an element from an array, or panic if the index is out of bounds. -/\n@[extern \"lean_array_get\"]\ndef Array.get! {\u03b1 : Type u} [Inhabited \u03b1] (a : @& Array \u03b1) (i : @& Nat) : \u03b1 :=\n  Array.getD a i default\n\ninstance : GetElem (Array \u03b1) Nat \u03b1 fun xs i => LT.lt i xs.size where\n  getElem xs i h := xs.get \u27e8i, h\u27e9\n\n/--\nPush an element onto the end of an array. This is amortized O(1) because\n`Array \u03b1` is internally a dynamic array.\n-/\n@[extern \"lean_array_push\"]\ndef Array.push {\u03b1 : Type u} (a : Array \u03b1) (v : \u03b1) : Array \u03b1 where\n  data := List.concat a.data v\n\n/-- Create array `#[]` -/\ndef Array.mkArray0 {\u03b1 : Type u} : Array \u03b1 :=\n  mkEmpty 0\n\n/-- Create array `#[a\u2081]` -/\ndef Array.mkArray1 {\u03b1 : Type u} (a\u2081 : \u03b1) : Array \u03b1 :=\n  (mkEmpty 1).push a\u2081\n\n/-- Create array `#[a\u2081, a\u2082]` -/\ndef Array.mkArray2 {\u03b1 : Type u} (a\u2081 a\u2082 : \u03b1) : Array \u03b1 :=\n  ((mkEmpty 2).push a\u2081).push a\u2082\n\n/-- Create array `#[a\u2081, a\u2082, a\u2083]` -/\ndef Array.mkArray3 {\u03b1 : Type u} (a\u2081 a\u2082 a\u2083 : \u03b1) : Array \u03b1 :=\n  (((mkEmpty 3).push a\u2081).push a\u2082).push a\u2083\n\n/-- Create array `#[a\u2081, a\u2082, a\u2083, a\u2084]` -/\ndef Array.mkArray4 {\u03b1 : Type u} (a\u2081 a\u2082 a\u2083 a\u2084 : \u03b1) : Array \u03b1 :=\n  ((((mkEmpty 4).push a\u2081).push a\u2082).push a\u2083).push a\u2084\n\n/-- Create array `#[a\u2081, a\u2082, a\u2083, a\u2084, a\u2085]` -/\ndef Array.mkArray5 {\u03b1 : Type u} (a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 : \u03b1) : Array \u03b1 :=\n  (((((mkEmpty 5).push a\u2081).push a\u2082).push a\u2083).push a\u2084).push a\u2085\n\n/-- Create array `#[a\u2081, a\u2082, a\u2083, a\u2084, a\u2085, a\u2086]` -/\ndef Array.mkArray6 {\u03b1 : Type u} (a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086 : \u03b1) : Array \u03b1 :=\n  ((((((mkEmpty 6).push a\u2081).push a\u2082).push a\u2083).push a\u2084).push a\u2085).push a\u2086\n\n/-- Create array `#[a\u2081, a\u2082, a\u2083, a\u2084, a\u2085, a\u2086, a\u2087]` -/\ndef Array.mkArray7 {\u03b1 : Type u} (a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086 a\u2087 : \u03b1) : Array \u03b1 :=\n  (((((((mkEmpty 7).push a\u2081).push a\u2082).push a\u2083).push a\u2084).push a\u2085).push a\u2086).push a\u2087\n\n/-- Create array `#[a\u2081, a\u2082, a\u2083, a\u2084, a\u2085, a\u2086, a\u2087, a\u2088]` -/\ndef Array.mkArray8 {\u03b1 : Type u} (a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086 a\u2087 a\u2088 : \u03b1) : Array \u03b1 :=\n  ((((((((mkEmpty 8).push a\u2081).push a\u2082).push a\u2083).push a\u2084).push a\u2085).push a\u2086).push a\u2087).push a\u2088\n\n/--\nSet an element in an array without bounds checks, using a `Fin` index.\n\nThis will perform the update destructively provided that `a` has a reference\ncount of 1 when called.\n-/\n@[extern \"lean_array_fset\"]\ndef Array.set (a : Array \u03b1) (i : @& Fin a.size) (v : \u03b1) : Array \u03b1 where\n  data := a.data.set i.val v\n\n/--\nSet an element in an array, or do nothing if the index is out of bounds.\n\nThis will perform the update destructively provided that `a` has a reference\ncount of 1 when called.\n-/\n@[inline] def Array.setD (a : Array \u03b1) (i : Nat) (v : \u03b1) : Array \u03b1 :=\n  dite (LT.lt i a.size) (fun h => a.set \u27e8i, h\u27e9 v) (fun _ => a)\n\n/--\nSet an element in an array, or panic if the index is out of bounds.\n\nThis will perform the update destructively provided that `a` has a reference\ncount of 1 when called.\n-/\n@[extern \"lean_array_set\"]\ndef Array.set! (a : Array \u03b1) (i : @& Nat) (v : \u03b1) : Array \u03b1 :=\n  Array.setD a i v\n\n/-- Slower `Array.append` used in quotations. -/\nprotected def Array.appendCore {\u03b1 : Type u}  (as : Array \u03b1) (bs : Array \u03b1) : Array \u03b1 :=\n  let rec loop (i : Nat) (j : Nat) (as : Array \u03b1) : Array \u03b1 :=\n    dite (LT.lt j bs.size)\n      (fun hlt =>\n        match i with\n        | 0           => as\n        | Nat.succ i' => loop i' (hAdd j 1) (as.push (bs.get \u27e8j, hlt\u27e9)))\n      (fun _ => as)\n  loop bs.size 0 as\n\n/--\n  Returns the slice of `as` from indices `start` to `stop` (exclusive).\n  If `start` is greater or equal to `stop`, the result is empty.\n  If `stop` is greater than the length of `as`, the length is used instead. -/\n-- NOTE: used in the quotation elaborator output\ndef Array.extract (as : Array \u03b1) (start stop : Nat) : Array \u03b1 :=\n  let rec loop (i : Nat) (j : Nat) (bs : Array \u03b1) : Array \u03b1 :=\n    dite (LT.lt j as.size)\n      (fun hlt =>\n        match i with\n        | 0           => bs\n        | Nat.succ i' => loop i' (hAdd j 1) (bs.push (as.get \u27e8j, hlt\u27e9)))\n      (fun _ => bs)\n  let sz' := Nat.sub (min stop as.size) start\n  loop sz' start (mkEmpty sz')\n\n/-- Auxiliary definition for `List.toArray`. -/\n@[inline_if_reduce]\ndef List.toArrayAux : List \u03b1 \u2192 Array \u03b1 \u2192 Array \u03b1\n  | nil,       r => r\n  | cons a as, r => toArrayAux as (r.push a)\n\n/-- A non-tail-recursive version of `List.length`, used for `List.toArray`. -/\n@[inline_if_reduce]\ndef List.redLength : List \u03b1 \u2192 Nat\n  | nil       => 0\n  | cons _ as => as.redLength.succ\n\n/--\nConvert a `List \u03b1` into an `Array \u03b1`. This is O(n) in the length of the list.\n\nThis function is exported to C, where it is called by `Array.mk`\n(the constructor) to implement this functionality.\n-/\n@[inline, match_pattern, export lean_list_to_array]\ndef List.toArray (as : List \u03b1) : Array \u03b1 :=\n  as.toArrayAux (Array.mkEmpty as.redLength)\n\n/-- The typeclass which supplies the `>>=` \"bind\" function. See `Monad`. -/\nclass Bind (m : Type u \u2192 Type v) where\n  /-- If `x : m \u03b1` and `f : \u03b1 \u2192 m \u03b2`, then `x >>= f : m \u03b2` represents the\n  result of executing `x` to get a value of type `\u03b1` and then passing it to `f`. -/\n  bind : {\u03b1 \u03b2 : Type u} \u2192 m \u03b1 \u2192 (\u03b1 \u2192 m \u03b2) \u2192 m \u03b2\n\nexport Bind (bind)\n\n/-- The typeclass which supplies the `pure` function. See `Monad`. -/\nclass Pure (f : Type u \u2192 Type v) where\n  /-- If `a : \u03b1`, then `pure a : f \u03b1` represents a monadic action that does\n  nothing and returns `a`. -/\n  pure {\u03b1 : Type u} : \u03b1 \u2192 f \u03b1\n\nexport Pure (pure)\n\n/--\nIn functional programming, a \"functor\" is a function on types `F : Type u \u2192 Type v`\nequipped with an operator called `map` or `<$>` such that if `f : \u03b1 \u2192 \u03b2` then\n`map f : F \u03b1 \u2192 F \u03b2`, so `f <$> x : F \u03b2` if `x : F \u03b1`. This corresponds to the\ncategory-theory notion of [functor](https://en.wikipedia.org/wiki/Functor) in\nthe special case where the category is the category of types and functions\nbetween them, except that this class supplies only the operations and not the\nlaws (see `LawfulFunctor`).\n-/\nclass Functor (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  /-- If `f : \u03b1 \u2192 \u03b2` and `x : F \u03b1` then `f <$> x : F \u03b2`. -/\n  map : {\u03b1 \u03b2 : Type u} \u2192 (\u03b1 \u2192 \u03b2) \u2192 f \u03b1 \u2192 f \u03b2\n  /-- The special case `const a <$> x`, which can sometimes be implemented more\n  efficiently. -/\n  mapConst : {\u03b1 \u03b2 : Type u} \u2192 \u03b1 \u2192 f \u03b2 \u2192 f \u03b1 := Function.comp map (Function.const _)\n\n/-- The typeclass which supplies the `<*>` \"seq\" function. See `Applicative`. -/\nclass Seq (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  /-- If `mf : F (\u03b1 \u2192 \u03b2)` and `mx : F \u03b1`, then `mf <*> mx : F \u03b2`.\n  In a monad this is the same as `do let f \u2190 mf; x \u2190 mx; pure (f x)`:\n  it evaluates first the function, then the argument, and applies one to the other.\n\n  To avoid surprising evaluation semantics, `mx` is taken \"lazily\", using a\n  `Unit \u2192 f \u03b1` function. -/\n  seq : {\u03b1 \u03b2 : Type u} \u2192 f (\u03b1 \u2192 \u03b2) \u2192 (Unit \u2192 f \u03b1) \u2192 f \u03b2\n\n/-- The typeclass which supplies the `<*` \"seqLeft\" function. See `Applicative`. -/\nclass SeqLeft (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  /-- If `x : F \u03b1` and `y : F \u03b2`, then `x <* y` evaluates `x`, then `y`,\n  and returns the result of `x`.\n\n  To avoid surprising evaluation semantics, `y` is taken \"lazily\", using a\n  `Unit \u2192 f \u03b2` function. -/\n  seqLeft : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 (Unit \u2192 f \u03b2) \u2192 f \u03b1\n\n/-- The typeclass which supplies the `*>` \"seqRight\" function. See `Applicative`. -/\nclass SeqRight (f : Type u \u2192 Type v) : Type (max (u+1) v) where\n  /-- If `x : F \u03b1` and `y : F \u03b2`, then `x *> y` evaluates `x`, then `y`,\n  and returns the result of `y`.\n\n  To avoid surprising evaluation semantics, `y` is taken \"lazily\", using a\n  `Unit \u2192 f \u03b2` function. -/\n  seqRight : {\u03b1 \u03b2 : Type u} \u2192 f \u03b1 \u2192 (Unit \u2192 f \u03b2) \u2192 f \u03b2\n\n/--\nAn [applicative functor](https://en.wikipedia.org/wiki/Applicative_functor) is\nan intermediate structure between `Functor` and `Monad`. It mainly consists of\ntwo operations:\n\n* `pure : \u03b1 \u2192 F \u03b1`\n* `seq : F (\u03b1 \u2192 \u03b2) \u2192 F \u03b1 \u2192 F \u03b2` (written as `<*>`)\n\nThe `seq` operator gives a notion of evaluation order to the effects, where\nthe first argument is executed before the second, but unlike a monad the results\nof earlier computations cannot be used to define later actions.\n-/\nclass Applicative (f : Type u \u2192 Type v) extends Functor f, Pure f, Seq f, SeqLeft f, SeqRight f where\n  map      := fun x y => Seq.seq (pure x) fun _ => y\n  seqLeft  := fun a b => Seq.seq (Functor.map (Function.const _) a) b\n  seqRight := fun a b => Seq.seq (Functor.map (Function.const _ id) a) b\n\n/--\nA [monad](https://en.wikipedia.org/wiki/Monad_(functional_programming)) is a\nstructure which abstracts the concept of sequential control flow.\nIt mainly consists of two operations:\n\n* `pure : \u03b1 \u2192 F \u03b1`\n* `bind : F \u03b1 \u2192 (\u03b1 \u2192 F \u03b2) \u2192 F \u03b2` (written as `>>=`)\n\nLike many functional programming languages, Lean makes extensive use of monads\nfor structuring programs. In particular, the `do` notation is a very powerful\nsyntax over monad operations, and it depends on a `Monad` instance.\n\nSee [the `do` notation](https://leanprover.github.io/lean4/doc/do.html)\nchapter of the manual for details.\n-/\nclass Monad (m : Type u \u2192 Type v) extends Applicative m, Bind m : Type (max (u+1) v) where\n  map      f x := bind x (Function.comp pure f)\n  seq      f x := bind f fun y => Functor.map y (x ())\n  seqLeft  x y := bind x fun a => bind (y ()) (fun _ => pure a)\n  seqRight x y := bind x fun _ => y ()\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] : Inhabited (\u03b1 \u2192 m \u03b1) where\n  default := pure\n\ninstance {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] [Inhabited \u03b1] : Inhabited (m \u03b1) where\n  default := pure default\n\ninstance [Monad m] : [Nonempty \u03b1] \u2192 Nonempty (m \u03b1)\n  | \u27e8x\u27e9 => \u27e8pure x\u27e9\n\n/-- A fusion of Haskell's `sequence` and `map`. Used in syntax quotations. -/\ndef Array.sequenceMap {\u03b1 : Type u} {\u03b2 : Type v} {m : Type v \u2192 Type w} [Monad m] (as : Array \u03b1) (f : \u03b1 \u2192 m \u03b2) : m (Array \u03b2) :=\n  let rec loop (i : Nat) (j : Nat) (bs : Array \u03b2) : m (Array \u03b2) :=\n    dite (LT.lt j as.size)\n      (fun hlt =>\n        match i with\n        | 0           => pure bs\n        | Nat.succ i' => Bind.bind (f (as.get \u27e8j, hlt\u27e9)) fun b => loop i' (hAdd j 1) (bs.push b))\n      (fun _ => pure bs)\n  loop as.size 0 (Array.mkEmpty as.size)\n\n/--\nA function for lifting a computation from an inner `Monad` to an outer `Monad`.\nLike Haskell's [`MonadTrans`], but `n` does not have to be a monad transformer.\nAlternatively, an implementation of [`MonadLayer`] without `layerInvmap` (so far).\n\n  [`MonadTrans`]: https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Class.html\n  [`MonadLayer`]: https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLayer\n-/\nclass MonadLift (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  /-- Lifts a value from monad `m` into monad `n`. -/\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\n/--\nThe reflexive-transitive closure of `MonadLift`. `monadLift` is used to\ntransitively lift monadic computations such as `StateT.get` or `StateT.put s`.\nCorresponds to Haskell's [`MonadLift`].\n\n  [`MonadLift`]: https://hackage.haskell.org/package/layers-0.1/docs/Control-Monad-Layer.html#t:MonadLift\n-/\nclass MonadLiftT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  /-- Lifts a value from monad `m` into monad `n`. -/\n  monadLift : {\u03b1 : Type u} \u2192 m \u03b1 \u2192 n \u03b1\n\nexport MonadLiftT (monadLift)\n\n/-- Lifts a value from monad `m` into monad `n`. -/\nabbrev liftM := @monadLift\n\n@[always_inline]\ninstance (m n o) [MonadLift n o] [MonadLiftT m n] : MonadLiftT m o where\n  monadLift x := MonadLift.monadLift (m := n) (monadLift x)\n\ninstance (m) : MonadLiftT m m where\n  monadLift x := x\n\n/--\nA functor in the category of monads. Can be used to lift monad-transforming functions.\nBased on [`MFunctor`] from the `pipes` Haskell package, but not restricted to\nmonad transformers. Alternatively, an implementation of [`MonadTransFunctor`].\n\n  [`MFunctor`]: https://hackage.haskell.org/package/pipes-2.4.0/docs/Control-MFunctor.html\n  [`MonadTransFunctor`]: http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadTransFunctor\n-/\nclass MonadFunctor (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  /-- Lifts a monad morphism `f : {\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2` to\n  `monadMap f : {\u03b1 : Type u} \u2192 n \u03b1 \u2192 n \u03b1`. -/\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\n/-- The reflexive-transitive closure of `MonadFunctor`.\n`monadMap` is used to transitively lift `Monad` morphisms. -/\nclass MonadFunctorT (m : Type u \u2192 Type v) (n : Type u \u2192 Type w) where\n  /-- Lifts a monad morphism `f : {\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2` to\n  `monadMap f : {\u03b1 : Type u} \u2192 n \u03b1 \u2192 n \u03b1`. -/\n  monadMap {\u03b1 : Type u} : ({\u03b2 : Type u} \u2192 m \u03b2 \u2192 m \u03b2) \u2192 n \u03b1 \u2192 n \u03b1\n\nexport MonadFunctorT (monadMap)\n\n@[always_inline]\ninstance (m n o) [MonadFunctor n o] [MonadFunctorT m n] : MonadFunctorT m o where\n  monadMap f := MonadFunctor.monadMap (m := n) (monadMap (m := m) f)\n\ninstance monadFunctorRefl (m) : MonadFunctorT m m where\n  monadMap f := f\n\n/--\n`Except \u03b5 \u03b1` is a type which represents either an error of type `\u03b5`, or an \"ok\"\nvalue of type `\u03b1`. The error type is listed first because\n`Except \u03b5 : Type \u2192 Type` is a `Monad`: the pure operation is `ok` and the bind\noperation returns the first encountered `error`.\n-/\ninductive Except (\u03b5 : Type u) (\u03b1 : Type v) where\n  /-- A failure value of type `\u03b5` -/\n  | error : \u03b5 \u2192 Except \u03b5 \u03b1\n  /-- A success value of type `\u03b1` -/\n  | ok    : \u03b1 \u2192 Except \u03b5 \u03b1\n\nattribute [unbox] Except\n\ninstance {\u03b5 : Type u} {\u03b1 : Type v} [Inhabited \u03b5] : Inhabited (Except \u03b5 \u03b1) where\n  default := Except.error default\n\n/--\nAn implementation of Haskell's [`MonadError`] class. A `MonadError \u03b5 m` is a\nmonad `m` with two operations:\n\n* `throw : \u03b5 \u2192 m \u03b1` \"throws an error\" of type `\u03b5` to the nearest enclosing\n  catch block\n* `tryCatch (body : m \u03b1) (handler : \u03b5 \u2192 m \u03b1) : m \u03b1` will catch any errors in\n  `body` and pass the resulting error to `handler`.\n  Errors in `handler` will not be caught.\n\nThe `try ... catch e => ...` syntax inside `do` blocks is sugar for the\n`tryCatch` operation.\n\n  [`MonadError`]: https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Except.html#t:MonadError\n-/\nclass MonadExceptOf (\u03b5 : Type u) (m : Type v \u2192 Type w) where\n  /-- `throw : \u03b5 \u2192 m \u03b1` \"throws an error\" of type `\u03b5` to the nearest enclosing\n  catch block. -/\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  /-- `tryCatch (body : m \u03b1) (handler : \u03b5 \u2192 m \u03b1) : m \u03b1` will catch any errors in\n  `body` and pass the resulting error to `handler`.\n  Errors in `handler` will not be caught. -/\n  tryCatch {\u03b1 : Type v} (body : m \u03b1) (handler : \u03b5 \u2192 m \u03b1) : m \u03b1\n\n/--\nThis is the same as `throw`, but allows specifying the particular error type\nin case the monad supports throwing more than one type of error.\n-/\nabbrev throwThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (e : \u03b5) : m \u03b1 :=\n  MonadExceptOf.throw e\n\n/--\nThis is the same as `tryCatch`, but allows specifying the particular error type\nin case the monad supports throwing more than one type of error.\n-/\nabbrev tryCatchThe (\u03b5 : Type u) {m : Type v \u2192 Type w} [MonadExceptOf \u03b5 m] {\u03b1 : Type v} (x : m \u03b1) (handle : \u03b5 \u2192 m \u03b1) : m \u03b1 :=\n  MonadExceptOf.tryCatch x handle\n\n/-- Similar to `MonadExceptOf`, but `\u03b5` is an `outParam` for convenience. -/\nclass MonadExcept (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) where\n  /-- `throw : \u03b5 \u2192 m \u03b1` \"throws an error\" of type `\u03b5` to the nearest enclosing\n  catch block. -/\n  throw {\u03b1 : Type v} : \u03b5 \u2192 m \u03b1\n  /-- `tryCatch (body : m \u03b1) (handler : \u03b5 \u2192 m \u03b1) : m \u03b1` will catch any errors in\n  `body` and pass the resulting error to `handler`.\n  Errors in `handler` will not be caught. -/\n  tryCatch {\u03b1 : Type v} : m \u03b1 \u2192 (\u03b5 \u2192 m \u03b1) \u2192 m \u03b1\n\n/-- \"Unwraps\" an `Except \u03b5 \u03b1` to get the `\u03b1`, or throws the exception otherwise. -/\ndef MonadExcept.ofExcept [Monad m] [MonadExcept \u03b5 m] : Except \u03b5 \u03b1 \u2192 m \u03b1\n  | .ok a    => pure a\n  | .error e => throw e\n\nexport MonadExcept (throw tryCatch ofExcept)\n\ninstance (\u03b5 : outParam (Type u)) (m : Type v \u2192 Type w) [MonadExceptOf \u03b5 m] : MonadExcept \u03b5 m where\n  throw    := throwThe \u03b5\n  tryCatch := tryCatchThe \u03b5\n\nnamespace MonadExcept\nvariable {\u03b5 : Type u} {m : Type v \u2192 Type w}\n\n/-- A `MonadExcept` can implement `t\u2081 <|> t\u2082` as `try t\u2081 catch _ => t\u2082`. -/\n@[inline] protected def orElse [MonadExcept \u03b5 m] {\u03b1 : Type v} (t\u2081 : m \u03b1) (t\u2082 : Unit \u2192 m \u03b1) : m \u03b1 :=\n  tryCatch t\u2081 fun _ => t\u2082 ()\n\ninstance [MonadExcept \u03b5 m] {\u03b1 : Type v} : OrElse (m \u03b1) where\n  orElse := MonadExcept.orElse\n\nend MonadExcept\n\n/--\nAn implementation of Haskell's [`ReaderT`]. This is a monad transformer which\nequips a monad with additional read-only state, of type `\u03c1`.\n\n  [`ReaderT`]: https://hackage.haskell.org/package/transformers-0.5.5.0/docs/Control-Monad-Trans-Reader.html#t:ReaderT\n-/\ndef ReaderT (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) : Type (max u v) :=\n  \u03c1 \u2192 m \u03b1\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) (\u03b1 : Type u) [Inhabited (m \u03b1)] : Inhabited (ReaderT \u03c1 m \u03b1) where\n  default := fun _ => default\n\n/--\nIf `x : ReaderT \u03c1 m \u03b1` and `r : \u03c1`, then `x.run r : \u03c1` runs the monad with the\ngiven reader state.\n-/\n@[always_inline, inline]\ndef ReaderT.run {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u} (x : ReaderT \u03c1 m \u03b1) (r : \u03c1) : m \u03b1 :=\n  x r\n\nnamespace ReaderT\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v} {\u03b1 : Type u}\n\ninstance  : MonadLift m (ReaderT \u03c1 m) where\n  monadLift x := fun _ => x\n\n@[always_inline]\ninstance (\u03b5) [MonadExceptOf \u03b5 m] : MonadExceptOf \u03b5 (ReaderT \u03c1 m) where\n  throw e  := liftM (m := m) (throw e)\n  tryCatch := fun x c r => tryCatchThe \u03b5 (x r) (fun e => (c e) r)\n\nend\n\nsection\nvariable {\u03c1 : Type u} {m : Type u \u2192 Type v}\n\n/-- `(\u2190 read) : \u03c1` gets the read-only state of a `ReaderT \u03c1`. -/\n@[always_inline, inline]\nprotected def read [Monad m] : ReaderT \u03c1 m \u03c1 :=\n  pure\n\n/-- The `pure` operation of the `ReaderT` monad. -/\n@[always_inline, inline]\nprotected def pure [Monad m] {\u03b1} (a : \u03b1) : ReaderT \u03c1 m \u03b1 :=\n  fun _ => pure a\n\n/-- The `bind` operation of the `ReaderT` monad. -/\n@[always_inline, inline]\nprotected def bind [Monad m] {\u03b1 \u03b2} (x : ReaderT \u03c1 m \u03b1) (f : \u03b1 \u2192 ReaderT \u03c1 m \u03b2) : ReaderT \u03c1 m \u03b2 :=\n  fun r => bind (x r) fun a => f a r\n\n@[always_inline]\ninstance [Monad m] : Functor (ReaderT \u03c1 m) where\n  map      f x r := Functor.map f (x r)\n  mapConst a x r := Functor.mapConst a (x r)\n\n@[always_inline]\ninstance [Monad m] : Applicative (ReaderT \u03c1 m) where\n  pure           := ReaderT.pure\n  seq      f x r := Seq.seq (f r) fun _ => x () r\n  seqLeft  a b r := SeqLeft.seqLeft (a r) fun _ => b () r\n  seqRight a b r := SeqRight.seqRight (a r) fun _ => b () r\n\ninstance [Monad m] : Monad (ReaderT \u03c1 m) where\n  bind := ReaderT.bind\n\ninstance (\u03c1 m) : MonadFunctor m (ReaderT \u03c1 m) where\n  monadMap f x := fun ctx => f (x ctx)\n\n/--\n`adapt (f : \u03c1' \u2192 \u03c1)` precomposes function `f` on the reader state of a\n`ReaderT \u03c1`, yielding a `ReaderT \u03c1'`.\n-/\n@[always_inline, inline]\nprotected def adapt {\u03c1' \u03b1 : Type u} (f : \u03c1' \u2192 \u03c1) : ReaderT \u03c1 m \u03b1 \u2192 ReaderT \u03c1' m \u03b1 :=\n  fun x r => x (f r)\n\nend\nend ReaderT\n\n/--\nAn implementation of Haskell's [`MonadReader`] (sans functional dependency; see also `MonadReader`\nin this module). It does not contain `local` because this\nfunction cannot be lifted using `monadLift`. `local` is instead provided by\nthe `MonadWithReader` class as `withReader`.\n\nNote: This class can be seen as a simplification of the more \"principled\" definition\n```\nclass MonadReaderOf (\u03c1 : Type u) (n : Type u \u2192 Type u) where\n  lift {\u03b1 : Type u} : ({m : Type u \u2192 Type u} \u2192 [Monad m] \u2192 ReaderT \u03c1 m \u03b1) \u2192 n \u03b1\n```\n\n  [`MonadReader`]: https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Reader-Class.html#t:MonadReader\n-/\nclass MonadReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  /-- `(\u2190 read) : \u03c1` reads the state out of monad `m`. -/\n  read : m \u03c1\n\n/--\nLike `read`, but with `\u03c1` explicit. This is useful if a monad supports\n`MonadReaderOf` for multiple different types `\u03c1`.\n-/\n@[always_inline, inline]\ndef readThe (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadReaderOf \u03c1 m] : m \u03c1 :=\n  MonadReaderOf.read\n\n/-- Similar to `MonadReaderOf`, but `\u03c1` is an `outParam` for convenience. -/\nclass MonadReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  /-- `(\u2190 read) : \u03c1` reads the state out of monad `m`. -/\n  read : m \u03c1\n\nexport MonadReader (read)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadReaderOf \u03c1 m] : MonadReader \u03c1 m where\n  read := readThe \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadReaderOf \u03c1 m] : MonadReaderOf \u03c1 n where\n  read := liftM (m := m) read\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadReaderOf \u03c1 (ReaderT \u03c1 m) where\n  read := ReaderT.read\n\n/--\n`MonadWithReaderOf \u03c1` adds the operation `withReader : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1`.\nThis runs the inner `x : m \u03b1` inside a modified context after applying the\nfunction `f : \u03c1 \u2192 \u03c1`. In addition to `ReaderT` itself, this operation lifts\nover most monad transformers, so it allows us to apply `withReader` to monads\ndeeper in the stack.\n-/\nclass MonadWithReaderOf (\u03c1 : Type u) (m : Type u \u2192 Type v) where\n  /-- `withReader (f : \u03c1 \u2192 \u03c1) (x : m \u03b1) : m \u03b1`  runs the inner `x : m \u03b1` inside\n  a modified context after applying the function `f : \u03c1 \u2192 \u03c1`.-/\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\n/--\nLike `withReader`, but with `\u03c1` explicit. This is useful if a monad supports\n`MonadWithReaderOf` for multiple different types `\u03c1`.\n-/\n@[always_inline, inline]\ndef withTheReader (\u03c1 : Type u) {m : Type u \u2192 Type v} [MonadWithReaderOf \u03c1 m] {\u03b1 : Type u} (f : \u03c1 \u2192 \u03c1) (x : m \u03b1) : m \u03b1 :=\n  MonadWithReaderOf.withReader f x\n\n/-- Similar to `MonadWithReaderOf`, but `\u03c1` is an `outParam` for convenience. -/\nclass MonadWithReader (\u03c1 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  /-- `withReader (f : \u03c1 \u2192 \u03c1) (x : m \u03b1) : m \u03b1`  runs the inner `x : m \u03b1` inside\n  a modified context after applying the function `f : \u03c1 \u2192 \u03c1`.-/\n  withReader {\u03b1 : Type u} : (\u03c1 \u2192 \u03c1) \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadWithReader (withReader)\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [MonadWithReaderOf \u03c1 m] : MonadWithReader \u03c1 m where\n  withReader := withTheReader \u03c1\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type v} [MonadFunctor m n] [MonadWithReaderOf \u03c1 m] : MonadWithReaderOf \u03c1 n where\n  withReader f := monadMap (m := m) (withTheReader \u03c1 f)\n\ninstance {\u03c1 : Type u} {m : Type u \u2192 Type v} [Monad m] : MonadWithReaderOf \u03c1 (ReaderT \u03c1 m) where\n  withReader f x := fun ctx => x (f ctx)\n\n/--\nAn implementation of [`MonadState`]. In contrast to the Haskell implementation,\nwe use overlapping instances to derive instances automatically from `monadLift`.\n\n  [`MonadState`]: https://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-State-Class.html\n-/\nclass MonadStateOf (\u03c3 : Type u) (m : Type u \u2192 Type v) where\n  /-- `(\u2190 get) : \u03c3` gets the state out of a monad `m`. -/\n  get : m \u03c3\n  /-- `set (s : \u03c3)` replaces the state with value `s`. -/\n  set : \u03c3 \u2192 m PUnit\n  /-- `modifyGet (f : \u03c3 \u2192 \u03b1 \u00d7 \u03c3)` applies `f` to the current state, replaces\n  the state with the return value, and returns a computed value.\n\n  It is equivalent to `do let (a, s) := f (\u2190 get); put s; pure a`, but\n  `modifyGet f` may be preferable because the former does not use the state\n  linearly (without sufficient inlining). -/\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadStateOf (set)\n\n/--\nLike `withReader`, but with `\u03c1` explicit. This is useful if a monad supports\n`MonadWithReaderOf` for multiple different types `\u03c1`.\n-/\nabbrev getThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] : m \u03c3 :=\n  MonadStateOf.get\n\n/--\nLike `modify`, but with `\u03c3` explicit. This is useful if a monad supports\n`MonadStateOf` for multiple different types `\u03c3`.\n-/\n@[always_inline, inline]\nabbrev modifyThe (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  MonadStateOf.modifyGet fun s => (PUnit.unit, f s)\n\n/--\nLike `modifyGet`, but with `\u03c3` explicit. This is useful if a monad supports\n`MonadStateOf` for multiple different types `\u03c3`.\n-/\n@[always_inline, inline]\nabbrev modifyGetThe {\u03b1 : Type u} (\u03c3 : Type u) {m : Type u \u2192 Type v} [MonadStateOf \u03c3 m] (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : m \u03b1 :=\n  MonadStateOf.modifyGet f\n\n/-- Similar to `MonadStateOf`, but `\u03c3` is an `outParam` for convenience. -/\nclass MonadState (\u03c3 : outParam (Type u)) (m : Type u \u2192 Type v) where\n  /-- `(\u2190 get) : \u03c3` gets the state out of a monad `m`. -/\n  get : m \u03c3\n  /-- `set (s : \u03c3)` replaces the state with value `s`. -/\n  set : \u03c3 \u2192 m PUnit\n  /-- `modifyGet (f : \u03c3 \u2192 \u03b1 \u00d7 \u03c3)` applies `f` to the current state, replaces\n  the state with the return value, and returns a computed value.\n\n  It is equivalent to `do let (a, s) := f (\u2190 get); put s; pure a`, but\n  `modifyGet f` may be preferable because the former does not use the state\n  linearly (without sufficient inlining). -/\n  modifyGet {\u03b1 : Type u} : (\u03c3 \u2192 Prod \u03b1 \u03c3) \u2192 m \u03b1\n\nexport MonadState (get modifyGet)\n\ninstance (\u03c3 : Type u) (m : Type u \u2192 Type v) [MonadStateOf \u03c3 m] : MonadState \u03c3 m where\n  set         := MonadStateOf.set\n  get         := getThe \u03c3\n  modifyGet f := MonadStateOf.modifyGet f\n\n/--\n`modify (f : \u03c3 \u2192 \u03c3)` applies the function `f` to the state.\n\nIt is equivalent to `do put (f (\u2190 get))`, but `modify f` may be preferable\nbecause the former does not use the state linearly (without sufficient inlining).\n-/\n@[always_inline, inline]\ndef modify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] (f : \u03c3 \u2192 \u03c3) : m PUnit :=\n  modifyGet fun s => (PUnit.unit, f s)\n\n/--\n`getModify f` gets the state, applies function `f`, and returns the old value\nof the state. It is equivalent to `get <* modify f` but may be more efficient.\n-/\n@[always_inline, inline]\ndef getModify {\u03c3 : Type u} {m : Type u \u2192 Type v} [MonadState \u03c3 m] [Monad m] (f : \u03c3 \u2192 \u03c3) : m \u03c3 :=\n  modifyGet fun s => (s, f s)\n\n-- NOTE: The Ordering of the following two instances determines that the top-most `StateT` Monad layer\n-- will be picked first\n@[always_inline]\ninstance {\u03c3 : Type u} {m : Type u \u2192 Type v} {n : Type u \u2192 Type w} [MonadLift m n] [MonadStateOf \u03c3 m] : MonadStateOf \u03c3 n where\n  get         := liftM (m := m) MonadStateOf.get\n  set       s := liftM (m := m) (MonadStateOf.set s)\n  modifyGet f := monadLift (m := m) (MonadState.modifyGet f)\n\nnamespace EStateM\n\n/--\n`Result \u03b5 \u03c3 \u03b1` is equivalent to `Except \u03b5 \u03b1 \u00d7 \u03c3`, but using a single\ncombined inductive yields a more efficient data representation.\n-/\ninductive Result (\u03b5 \u03c3 \u03b1 : Type u) where\n  /-- A success value of type `\u03b1`, and a new state `\u03c3`. -/\n  | ok    : \u03b1 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n  /-- A failure value of type `\u03b5`, and a new state `\u03c3`. -/\n  | error : \u03b5 \u2192 \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nvariable {\u03b5 \u03c3 \u03b1 : Type u}\n\ninstance [Inhabited \u03b5] [Inhabited \u03c3] : Inhabited (Result \u03b5 \u03c3 \u03b1) where\n  default := Result.error default default\n\nend EStateM\n\nopen EStateM (Result) in\n/--\n`EStateM \u03b5 \u03c3` is a combined error and state monad, equivalent to\n`ExceptT \u03b5 (StateM \u03c3)` but more efficient.\n-/\ndef EStateM (\u03b5 \u03c3 \u03b1 : Type u) := \u03c3 \u2192 Result \u03b5 \u03c3 \u03b1\n\nnamespace EStateM\n\nvariable {\u03b5 \u03c3 \u03b1 \u03b2 : Type u}\n\ninstance [Inhabited \u03b5] : Inhabited (EStateM \u03b5 \u03c3 \u03b1) where\n  default := fun s => Result.error default s\n\n/-- The `pure` operation of the `EStateM` monad. -/\n@[always_inline, inline]\nprotected def pure (a : \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.ok a s\n\n/-- The `set` operation of the `EStateM` monad. -/\n@[always_inline, inline]\nprotected def set (s : \u03c3) : EStateM \u03b5 \u03c3 PUnit := fun _ =>\n  Result.ok \u27e8\u27e9 s\n\n/-- The `get` operation of the `EStateM` monad. -/\n@[always_inline, inline]\nprotected def get : EStateM \u03b5 \u03c3 \u03c3 := fun s =>\n  Result.ok s s\n\n/-- The `modifyGet` operation of the `EStateM` monad. -/\n@[always_inline, inline]\nprotected def modifyGet (f : \u03c3 \u2192 Prod \u03b1 \u03c3) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  match f s with\n  | (a, s) => Result.ok a s\n\n/-- The `throw` operation of the `EStateM` monad. -/\n@[always_inline, inline]\nprotected def throw (e : \u03b5) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  Result.error e s\n\n/--\nAuxiliary instance for saving/restoring the \"backtrackable\" part of the state.\nHere `\u03c3` is the state, and `\u03b4` is some subpart of it, and we have a\ngetter and setter for it (a \"lens\" in the Haskell terminology).\n-/\nclass Backtrackable (\u03b4 : outParam (Type u)) (\u03c3 : Type u) where\n  /-- `save s : \u03b4` retrieves a copy of the backtracking state out of the state. -/\n  save    : \u03c3 \u2192 \u03b4\n  /-- `restore (s : \u03c3) (x : \u03b4) : \u03c3` applies the old backtracking state `x` to\n  the state `s` to get a backtracked state `s'`. -/\n  restore : \u03c3 \u2192 \u03b4 \u2192 \u03c3\n\n/-- Implementation of `tryCatch` for `EStateM` where the state is `Backtrackable`. -/\n@[always_inline, inline]\nprotected def tryCatch {\u03b4} [Backtrackable \u03b4 \u03c3] {\u03b1} (x : EStateM \u03b5 \u03c3 \u03b1) (handle : \u03b5 \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s\n  match x s with\n  | Result.error e s => handle e (Backtrackable.restore s d)\n  | ok               => ok\n\n/-- Implementation of `orElse` for `EStateM` where the state is `Backtrackable`. -/\n@[always_inline, inline]\nprotected def orElse {\u03b4} [Backtrackable \u03b4 \u03c3] (x\u2081 : EStateM \u03b5 \u03c3 \u03b1) (x\u2082 : Unit \u2192 EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b1 := fun s =>\n  let d := Backtrackable.save s;\n  match x\u2081 s with\n  | Result.error _ s => x\u2082 () (Backtrackable.restore s d)\n  | ok               => ok\n\n/-- Map the exception type of a `EStateM \u03b5 \u03c3 \u03b1` by a function `f : \u03b5 \u2192 \u03b5'`. -/\n@[always_inline, inline]\ndef adaptExcept {\u03b5' : Type u} (f : \u03b5 \u2192 \u03b5') (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5' \u03c3 \u03b1 := fun s =>\n  match x s with\n  | Result.error e s => Result.error (f e) s\n  | Result.ok a s    => Result.ok a s\n\n/-- The `bind` operation of the `EStateM` monad. -/\n@[always_inline, inline]\nprotected def bind (x : EStateM \u03b5 \u03c3 \u03b1) (f : \u03b1 \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => f a s\n  | Result.error e s => Result.error e s\n\n/-- The `map` operation of the `EStateM` monad. -/\n@[always_inline, inline]\nprotected def map (f : \u03b1 \u2192 \u03b2) (x : EStateM \u03b5 \u03c3 \u03b1) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok a s    => Result.ok (f a) s\n  | Result.error e s => Result.error e s\n\n/-- The `seqRight` operation of the `EStateM` monad. -/\n@[always_inline, inline]\nprotected def seqRight (x : EStateM \u03b5 \u03c3 \u03b1) (y : Unit \u2192 EStateM \u03b5 \u03c3 \u03b2) : EStateM \u03b5 \u03c3 \u03b2 := fun s =>\n  match x s with\n  | Result.ok _ s    => y () s\n  | Result.error e s => Result.error e s\n\n@[always_inline]\ninstance : Monad (EStateM \u03b5 \u03c3) where\n  bind     := EStateM.bind\n  pure     := EStateM.pure\n  map      := EStateM.map\n  seqRight := EStateM.seqRight\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : OrElse (EStateM \u03b5 \u03c3 \u03b1) where\n  orElse := EStateM.orElse\n\ninstance : MonadStateOf \u03c3 (EStateM \u03b5 \u03c3) where\n  set       := EStateM.set\n  get       := EStateM.get\n  modifyGet := EStateM.modifyGet\n\ninstance {\u03b4} [Backtrackable \u03b4 \u03c3] : MonadExceptOf \u03b5 (EStateM \u03b5 \u03c3) where\n  throw    := EStateM.throw\n  tryCatch := EStateM.tryCatch\n\n/-- Execute an `EStateM` on initial state `s` to get a `Result`. -/\n@[always_inline, inline]\ndef run (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Result \u03b5 \u03c3 \u03b1 := x s\n\n/--\nExecute an `EStateM` on initial state `s` for the returned value `\u03b1`.\nIf the monadic action throws an exception, returns `none` instead.\n-/\n@[always_inline, inline]\ndef run' (x : EStateM \u03b5 \u03c3 \u03b1) (s : \u03c3) : Option \u03b1 :=\n  match run x s with\n  | Result.ok v _   => some v\n  | Result.error .. => none\n\n/-- The `save` implementation for `Backtrackable PUnit \u03c3`. -/\n@[inline] def dummySave : \u03c3 \u2192 PUnit := fun _ => \u27e8\u27e9\n\n/-- The `restore` implementation for `Backtrackable PUnit \u03c3`. -/\n@[inline] def dummyRestore : \u03c3 \u2192 PUnit \u2192 \u03c3 := fun s _ => s\n\n/--\nDummy default instance. This makes every `\u03c3` trivially \"backtrackable\"\nby doing nothing on backtrack. Because this is the first declared instance\nof `Backtrackable _ \u03c3`, it will be picked only if there are no other\n`Backtrackable _ \u03c3` instances registered.\n-/\ninstance nonBacktrackable : Backtrackable PUnit \u03c3 where\n  save    := dummySave\n  restore := dummyRestore\n\nend EStateM\n\n/-- A class for types that can be hashed into a `UInt64`. -/\nclass Hashable (\u03b1 : Sort u) where\n  /-- Hashes the value `a : \u03b1` into a `UInt64`. -/\n  hash : \u03b1 \u2192 UInt64\n\nexport Hashable (hash)\n\n/-- Converts a `UInt64` to a `USize` by reducing modulo `USize.size`. -/\n@[extern \"lean_uint64_to_usize\"]\nopaque UInt64.toUSize (u : UInt64) : USize\n\n/--\nUpcast a `USize` to a `UInt64`.\nThis is lossless because `USize.size` is either `2^32` or `2^64`.\nThis function is overridden with a native implementation.\n-/\n@[extern \"lean_usize_to_uint64\"]\ndef USize.toUInt64 (u : USize) : UInt64 where\n  val := {\n    val  := u.val.val\n    isLt :=\n      let \u27e8n, h\u27e9 := u\n      show LT.lt n _ from\n      match USize.size, usize_size_eq, h with\n      | _, Or.inl rfl, h => Nat.lt_trans h (by decide)\n      | _, Or.inr rfl, h => h\n  }\n\n/-- An opaque hash mixing operation, used to implement hashing for tuples. -/\n@[extern \"lean_uint64_mix_hash\"]\nopaque mixHash (u\u2081 u\u2082 : UInt64) : UInt64\n\ninstance [Hashable \u03b1] {p : \u03b1 \u2192 Prop} : Hashable (Subtype p) where\n  hash a := hash a.val\n\n/-- An opaque string hash function. -/\n@[extern \"lean_string_hash\"]\nprotected opaque String.hash (s : @& String) : UInt64\n\ninstance : Hashable String where\n  hash := String.hash\n\nnamespace Lean\n\n/--\nHierarchical names. We use hierarchical names to name declarations and\nfor creating unique identifiers for free variables and metavariables.\n\nYou can create hierarchical names using the following quotation notation.\n```\n`Lean.Meta.whnf\n```\nIt is short for `.str (.str (.str .anonymous \"Lean\") \"Meta\") \"whnf\"`\nYou can use double quotes to request Lean to statically check whether the name\ncorresponds to a Lean declaration in scope.\n```\n``Lean.Meta.whnf\n```\nIf the name is not in scope, Lean will report an error.\n-/\ninductive Name where\n  /-- The \"anonymous\" name. -/\n  | anonymous : Name\n  /--\n  A string name. The name `Lean.Meta.run` is represented at\n  ```lean\n  .str (.str (.str .anonymous \"Lean\") \"Meta\") \"run\"\n  ```\n  -/\n  | str (pre : Name) (str : String)\n  /--\n  A numerical name. This kind of name is used, for example, to create hierarchical names for\n  free variables and metavariables. The identifier `_uniq.231` is represented as\n  ```lean\n  .num (.str .anonymous \"_uniq\") 231\n  ```\n  -/\n  | num (pre : Name) (i : Nat)\nwith\n  /-- A hash function for names, which is stored inside the name itself as a\n  computed field. -/\n  @[computed_field] hash : Name \u2192 UInt64\n    | .anonymous => .ofNatCore 1723 (by decide)\n    | .str p s => mixHash p.hash s.hash\n    | .num p v => mixHash p.hash (dite (LT.lt v UInt64.size) (fun h => UInt64.ofNatCore v h) (fun _ => UInt64.ofNatCore 17 (by decide)))\n\ninstance : Inhabited Name where\n  default := Name.anonymous\n\ninstance : Hashable Name where\n  hash := Name.hash\n\nnamespace Name\n\n/--\n`.str p s` is now the preferred form.\n-/\n@[export lean_name_mk_string]\nabbrev mkStr (p : Name) (s : String) : Name :=\n  Name.str p s\n\n/--\n`.num p v` is now the preferred form.\n-/\n@[export lean_name_mk_numeral]\nabbrev mkNum (p : Name) (v : Nat) : Name :=\n  Name.num p v\n\n/--\nShort for `.str .anonymous s`.\n-/\nabbrev mkSimple (s : String) : Name :=\n  .str .anonymous s\n\n/-- Make name `s\u2081` -/\n@[reducible] def mkStr1 (s\u2081 : String) : Name :=\n  .str .anonymous s\u2081\n\n/-- Make name `s\u2081.s\u2082` -/\n@[reducible] def mkStr2 (s\u2081 s\u2082 : String) : Name :=\n  .str (.str .anonymous s\u2081) s\u2082\n\n/-- Make name `s\u2081.s\u2082.s\u2083` -/\n@[reducible] def mkStr3 (s\u2081 s\u2082 s\u2083 : String) : Name :=\n  .str (.str (.str .anonymous s\u2081) s\u2082) s\u2083\n\n/-- Make name `s\u2081.s\u2082.s\u2083.s\u2084` -/\n@[reducible] def mkStr4 (s\u2081 s\u2082 s\u2083 s\u2084 : String) : Name :=\n  .str (.str (.str (.str .anonymous s\u2081) s\u2082) s\u2083) s\u2084\n\n/-- Make name `s\u2081.s\u2082.s\u2083.s\u2084.s\u2085` -/\n@[reducible] def mkStr5 (s\u2081 s\u2082 s\u2083 s\u2084 s\u2085 : String) : Name :=\n  .str (.str (.str (.str (.str .anonymous s\u2081) s\u2082) s\u2083) s\u2084) s\u2085\n\n/-- Make name `s\u2081.s\u2082.s\u2083.s\u2084.s\u2085.s\u2086` -/\n@[reducible] def mkStr6 (s\u2081 s\u2082 s\u2083 s\u2084 s\u2085 s\u2086 : String) : Name :=\n  .str (.str (.str (.str (.str (.str .anonymous s\u2081) s\u2082) s\u2083) s\u2084) s\u2085) s\u2086\n\n/-- Make name `s\u2081.s\u2082.s\u2083.s\u2084.s\u2085.s\u2086.s\u2087` -/\n@[reducible] def mkStr7 (s\u2081 s\u2082 s\u2083 s\u2084 s\u2085 s\u2086 s\u2087 : String) : Name :=\n  .str (.str (.str (.str (.str (.str (.str .anonymous s\u2081) s\u2082) s\u2083) s\u2084) s\u2085) s\u2086) s\u2087\n\n/-- Make name `s\u2081.s\u2082.s\u2083.s\u2084.s\u2085.s\u2086.s\u2087.s\u2088` -/\n@[reducible] def mkStr8 (s\u2081 s\u2082 s\u2083 s\u2084 s\u2085 s\u2086 s\u2087 s\u2088 : String) : Name :=\n  .str (.str (.str (.str (.str (.str (.str (.str .anonymous s\u2081) s\u2082) s\u2083) s\u2084) s\u2085) s\u2086) s\u2087) s\u2088\n\n/-- (Boolean) equality comparator for names. -/\n@[extern \"lean_name_eq\"]\nprotected def beq : (@& Name) \u2192 (@& Name) \u2192 Bool\n  | anonymous, anonymous => true\n  | str p\u2081 s\u2081, str p\u2082 s\u2082 => and (BEq.beq s\u2081 s\u2082) (Name.beq p\u2081 p\u2082)\n  | num p\u2081 n\u2081, num p\u2082 n\u2082 => and (BEq.beq n\u2081 n\u2082) (Name.beq p\u2081 p\u2082)\n  | _,         _         => false\n\ninstance : BEq Name where\n  beq := Name.beq\n\n/--\nThis function does not have special support for macro scopes.\nSee `Name.append`.\n-/\ndef appendCore : Name \u2192 Name \u2192 Name\n  | n, .anonymous => n\n  | n, .str p s => .str (appendCore n p) s\n  | n, .num p d => .num (appendCore n p) d\n\nend Name\n\n/-! # Syntax -/\n\n/-- Source information of tokens. -/\ninductive SourceInfo where\n  /--\n  Token from original input with whitespace and position information.\n  `leading` will be inferred after parsing by `Syntax.updateLeading`. During parsing,\n  it is not at all clear what the preceding token was, especially with backtracking.\n  -/\n  | original (leading : Substring) (pos : String.Pos) (trailing : Substring) (endPos : String.Pos)\n  /--\n  Synthesized syntax (e.g. from a quotation) annotated with a span from the original source.\n  In the delaborator, we \"misuse\" this constructor to store synthetic positions identifying\n  subterms.\n\n  The `canonical` flag on synthetic syntax is enabled for syntax that is not literally part\n  of the original input syntax but should be treated \"as if\" the user really wrote it\n  for the purpose of hovers and error messages. This is usually used on identifiers,\n  to connect the binding site to the user's original syntax even if the name of the identifier\n  changes during expansion, as well as on tokens where we will attach targeted messages.\n\n  The syntax `token%$stx` in a syntax quotation will annotate the token `token` with the span\n  from `stx` and also mark it as canonical.\n\n  As a rough guide, a macro expansion should only use a given piece of input syntax in\n  a single canonical token, although this is sometimes violated when the same identifier\n  is used to declare two binders, as in the macro expansion for dependent if:\n  ```\n  `(if $h : $cond then $t else $e) ~>\n  `(dite $cond (fun $h => $t) (fun $h => $t))\n  ```\n  In these cases if the user hovers over `h` they will see information about both binding sites.\n  -/\n  | synthetic (pos : String.Pos) (endPos : String.Pos) (canonical := false)\n  /-- Synthesized token without position information. -/\n  | protected none\n\ninstance : Inhabited SourceInfo := \u27e8SourceInfo.none\u27e9\n\nnamespace SourceInfo\n\n/--\nGets the position information from a `SourceInfo`, if available.\nIf `originalOnly` is true, then `.synthetic` syntax will also return `none`.\n-/\ndef getPos? (info : SourceInfo) (canonicalOnly := false) : Option String.Pos :=\n  match info, canonicalOnly with\n  | original (pos := pos) ..,  _\n  | synthetic (pos := pos) (canonical := true) .., _\n  | synthetic (pos := pos) .., false => some pos\n  | _,                         _     => none\n\nend SourceInfo\n\n/--\nA `SyntaxNodeKind` classifies `Syntax.node` values. It is an abbreviation for\n`Name`, and you can use name literals to construct `SyntaxNodeKind`s, but\nthey need not refer to declarations in the environment. Conventionally, a\n`SyntaxNodeKind` will correspond to the `Parser` or `ParserDesc` declaration\nthat parses it.\n-/\nabbrev SyntaxNodeKind := Name\n\n/-! # Syntax AST -/\n\n/--\nBinding information resolved and stored at compile time of a syntax quotation.\nNote: We do not statically know whether a syntax expects a namespace or term name,\nso a `Syntax.ident` may contain both preresolution kinds.\n-/\ninductive Syntax.Preresolved where\n  /-- A potential namespace reference -/\n  | namespace (ns : Name)\n  /-- A potential global constant or section variable reference, with additional field accesses -/\n  | decl (n : Name) (fields : List String)\n\n/--\nSyntax objects used by the parser, macro expander, delaborator, etc.\n-/\ninductive Syntax where\n  /-- A `missing` syntax corresponds to a portion of the syntax tree that is\n  missing because of a parse error. The indexing operator on Syntax also\n  returns `missing` for indexing out of bounds. -/\n  | missing : Syntax\n  /-- Node in the syntax tree.\n\n  The `info` field is used by the delaborator to store the position of the\n  subexpression corresponding to this node. The parser sets the `info` field\n  to `none`.\n  The parser sets the `info` field to `none`, with position retrieval continuing recursively.\n  Nodes created by quotations use the result from `SourceInfo.fromRef` so that they are marked\n  as synthetic even when the leading/trailing token is not.\n  The delaborator uses the `info` field to store the position of the subexpression\n  corresponding to this node.\n\n  (Remark: the `node` constructor did not have an `info` field in previous\n  versions. This caused a bug in the interactive widgets, where the popup for\n  `a + b` was the same as for `a`. The delaborator used to associate\n  subexpressions with pretty-printed syntax by setting the (string) position\n  of the first atom/identifier to the (expression) position of the\n  subexpression. For example, both `a` and `a + b` have the same first\n  identifier, and so their infos got mixed up.) -/\n  | node   (info : SourceInfo) (kind : SyntaxNodeKind) (args : Array Syntax) : Syntax\n  /-- An `atom` corresponds to a keyword or piece of literal unquoted syntax.\n  These correspond to quoted strings inside `syntax` declarations.\n  For example, in `(x + y)`, `\"(\"`, `\"+\"` and `\")\"` are `atom`\n  and `x` and `y` are `ident`. -/\n  | atom   (info : SourceInfo) (val : String) : Syntax\n  /-- An `ident` corresponds to an identifier as parsed by the `ident` or\n  `rawIdent` parsers.\n  * `rawVal` is the literal substring from the input file\n  * `val` is the parsed identifier (with hygiene)\n  * `preresolved` is the list of possible declarations this could refer to\n  -/\n  | ident  (info : SourceInfo) (rawVal : Substring) (val : Name) (preresolved : List Syntax.Preresolved) : Syntax\n\n/-- Create syntax node with 1 child -/\ndef Syntax.node1 (info : SourceInfo) (kind : SyntaxNodeKind) (a\u2081 : Syntax) : Syntax :=\n  Syntax.node info kind (Array.mkArray1 a\u2081)\n\n/-- Create syntax node with 2 children -/\ndef Syntax.node2 (info : SourceInfo) (kind : SyntaxNodeKind) (a\u2081 a\u2082 : Syntax) : Syntax :=\n  Syntax.node info kind (Array.mkArray2 a\u2081 a\u2082)\n\n/-- Create syntax node with 3 children -/\ndef Syntax.node3 (info : SourceInfo) (kind : SyntaxNodeKind) (a\u2081 a\u2082 a\u2083 : Syntax) : Syntax :=\n  Syntax.node info kind (Array.mkArray3 a\u2081 a\u2082 a\u2083)\n\n/-- Create syntax node with 4 children -/\ndef Syntax.node4 (info : SourceInfo) (kind : SyntaxNodeKind) (a\u2081 a\u2082 a\u2083 a\u2084 : Syntax) : Syntax :=\n  Syntax.node info kind (Array.mkArray4 a\u2081 a\u2082 a\u2083 a\u2084)\n\n/-- Create syntax node with 5 children -/\ndef Syntax.node5 (info : SourceInfo) (kind : SyntaxNodeKind) (a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 : Syntax) : Syntax :=\n  Syntax.node info kind (Array.mkArray5 a\u2081 a\u2082 a\u2083 a\u2084 a\u2085)\n\n/-- Create syntax node with 6 children -/\ndef Syntax.node6 (info : SourceInfo) (kind : SyntaxNodeKind) (a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086 : Syntax) : Syntax :=\n  Syntax.node info kind (Array.mkArray6 a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086)\n\n/-- Create syntax node with 7 children -/\ndef Syntax.node7 (info : SourceInfo) (kind : SyntaxNodeKind) (a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086 a\u2087 : Syntax) : Syntax :=\n  Syntax.node info kind (Array.mkArray7 a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086 a\u2087)\n\n/-- Create syntax node with 8 children -/\ndef Syntax.node8 (info : SourceInfo) (kind : SyntaxNodeKind) (a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086 a\u2087 a\u2088 : Syntax) : Syntax :=\n  Syntax.node info kind (Array.mkArray8 a\u2081 a\u2082 a\u2083 a\u2084 a\u2085 a\u2086 a\u2087 a\u2088)\n\n/-- `SyntaxNodeKinds` is a set of `SyntaxNodeKind` (implemented as a list). -/\ndef SyntaxNodeKinds := List SyntaxNodeKind\n\n/--\nA `Syntax` value of one of the given syntax kinds.\nNote that while syntax quotations produce/expect `TSyntax` values of the correct kinds,\nthis is not otherwise enforced and can easily be circumvented by direct use of the constructor.\nThe namespace `TSyntax.Compat` can be opened to expose a general coercion from `Syntax` to any\n`TSyntax ks` for porting older code.\n-/\nstructure TSyntax (ks : SyntaxNodeKinds) where\n  /-- The underlying `Syntax` value. -/\n  raw : Syntax\n\ninstance : Inhabited Syntax where\n  default := Syntax.missing\n\ninstance : Inhabited (TSyntax ks) where\n  default := \u27e8default\u27e9\n\n/-! Builtin kinds -/\n\n/--\nThe `choice` kind is used when a piece of syntax has multiple parses, and the\ndetermination of which to use is deferred until typing information is available.\n-/\nabbrev choiceKind : SyntaxNodeKind := `choice\n\n/-- The null kind is used for raw list parsers like `many`. -/\nabbrev nullKind : SyntaxNodeKind := `null\n\n/--\nThe `group` kind is by the `group` parser, to avoid confusing with the null\nkind when used inside `optional`.\n-/\nabbrev groupKind : SyntaxNodeKind := `group\n\n/--\n`ident` is not actually used as a node kind, but it is returned by\n`getKind` in the `ident` case so that things that handle different node\nkinds can also handle `ident`.\n-/\nabbrev identKind : SyntaxNodeKind := `ident\n\n/-- `str` is the node kind of string literals like `\"foo\"`. -/\nabbrev strLitKind : SyntaxNodeKind := `str\n\n/-- `char` is the node kind of character literals like `'A'`. -/\nabbrev charLitKind : SyntaxNodeKind := `char\n\n/-- `num` is the node kind of number literals like `42`. -/\nabbrev numLitKind : SyntaxNodeKind := `num\n\n/-- `scientific` is the node kind of floating point literals like `1.23e-3`. -/\nabbrev scientificLitKind : SyntaxNodeKind := `scientific\n\n/-- `name` is the node kind of name literals like `` `foo ``. -/\nabbrev nameLitKind : SyntaxNodeKind := `name\n\n/-- `fieldIdx` is the node kind of projection indices like the `2` in `x.2`. -/\nabbrev fieldIdxKind : SyntaxNodeKind := `fieldIdx\n\n/--\n`interpolatedStrLitKind` is the node kind of interpolated string literal\nfragments like `\"value = {` and `}\"` in `s!\"value = {x}\"`.\n-/\nabbrev interpolatedStrLitKind : SyntaxNodeKind := `interpolatedStrLitKind\n/--\n`interpolatedStrKind` is the node kind of an interpolated string literal\nlike `\"value = {x}\"` in `s!\"value = {x}\"`.\n-/\nabbrev interpolatedStrKind : SyntaxNodeKind := `interpolatedStrKind\n\n/-- Creates an info-less node of the given kind and children. -/\n@[inline] def mkNode (k : SyntaxNodeKind) (args : Array Syntax) : TSyntax (.cons k .nil) :=\n  \u27e8Syntax.node SourceInfo.none k args\u27e9\n\n/-- Creates an info-less `nullKind` node with the given children, if any. -/\n-- NOTE: used by the quotation elaborator output\n@[inline] def mkNullNode (args : Array Syntax := Array.empty) : Syntax :=\n  mkNode nullKind args |>.raw\n\nnamespace Syntax\n\n/--\nGets the kind of a `Syntax` node. For non-`node` syntax, we use \"pseudo kinds\":\n`identKind` for `ident`, `missing` for `missing`, and the atom's string literal\nfor atoms.\n-/\ndef getKind (stx : Syntax) : SyntaxNodeKind :=\n  match stx with\n  | Syntax.node _ k _    => k\n  -- We use these \"pseudo kinds\" for antiquotation kinds.\n  -- For example, an antiquotation `$id:ident` (using Lean.Parser.Term.ident)\n  -- is compiled to ``if stx.isOfKind `ident ...``\n  | Syntax.missing     => `missing\n  | Syntax.atom _ v    => Name.mkSimple v\n  | Syntax.ident ..    => identKind\n\n/--\nChanges the kind at the root of a `Syntax` node to `k`.\nDoes nothing for non-`node` nodes.\n-/\ndef setKind (stx : Syntax) (k : SyntaxNodeKind) : Syntax :=\n  match stx with\n  | Syntax.node info _ args => Syntax.node info k args\n  | _                       => stx\n\n/-- Is this a syntax with node kind `k`? -/\ndef isOfKind (stx : Syntax) (k : SyntaxNodeKind) : Bool :=\n  beq stx.getKind k\n\n/--\nGets the `i`'th argument of the syntax node. This can also be written `stx[i]`.\nReturns `missing` if `i` is out of range.\n-/\ndef getArg (stx : Syntax) (i : Nat) : Syntax :=\n  match stx with\n  | Syntax.node _ _ args => args.getD i Syntax.missing\n  | _                    => Syntax.missing\n\ninstance : GetElem Syntax Nat Syntax fun _ _ => True where\n  getElem stx i _ := stx.getArg i\n\n/-- Gets the list of arguments of the syntax node, or `#[]` if it's not a `node`. -/\ndef getArgs (stx : Syntax) : Array Syntax :=\n  match stx with\n  | Syntax.node _ _ args => args\n  | _                    => Array.empty\n\n/-- Gets the number of arguments of the syntax node, or `0` if it's not a `node`. -/\ndef getNumArgs (stx : Syntax) : Nat :=\n  match stx with\n  | Syntax.node _ _ args => args.size\n  | _                    => 0\n\n/--\nAssuming `stx` was parsed by `optional`, returns the enclosed syntax\nif it parsed something and `none` otherwise.\n-/\ndef getOptional? (stx : Syntax) : Option Syntax :=\n  match stx with\n  | Syntax.node _ k args => match and (beq k nullKind) (beq args.size 1) with\n    | true  => some (args.get! 0)\n    | false => none\n  | _                    => none\n\n/-- Is this syntax `.missing`? -/\ndef isMissing : Syntax \u2192 Bool\n  | Syntax.missing => true\n  | _ => false\n\n/-- Is this syntax a `node` with kind `k`? -/\ndef isNodeOf (stx : Syntax) (k : SyntaxNodeKind) (n : Nat) : Bool :=\n  and (stx.isOfKind k) (beq stx.getNumArgs n)\n\n/-- `stx.isIdent` is `true` iff `stx` is an identifier. -/\ndef isIdent : Syntax \u2192 Bool\n  | ident .. => true\n  | _        => false\n\n/-- If this is an `ident`, return the parsed value, else `.anonymous`. -/\ndef getId : Syntax \u2192 Name\n  | ident _ _ val _ => val\n  | _               => Name.anonymous\n\n/--\nUpdates the argument list without changing the node kind.\nDoes nothing for non-`node` nodes.\n-/\ndef setArgs (stx : Syntax) (args : Array Syntax) : Syntax :=\n  match stx with\n  | node info k _ => node info k args\n  | stx           => stx\n\n/--\nUpdates the `i`'th argument of the syntax.\nDoes nothing for non-`node` nodes, or if `i` is out of bounds of the node list.\n-/\ndef setArg (stx : Syntax) (i : Nat) (arg : Syntax) : Syntax :=\n  match stx with\n  | node info k args => node info k (args.setD i arg)\n  | stx              => stx\n\n/-- Retrieve the left-most node or leaf's info in the Syntax tree. -/\npartial def getHeadInfo? : Syntax \u2192 Option SourceInfo\n  | atom info _   => some info\n  | ident info .. => some info\n  | node SourceInfo.none _ args   =>\n    let rec loop (i : Nat) : Option SourceInfo :=\n      match decide (LT.lt i args.size) with\n      | true => match getHeadInfo? (args.get! i) with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | node info _ _ => some info\n  | _             => none\n\n/-- Retrieve the left-most leaf's info in the Syntax tree, or `none` if there is no token. -/\npartial def getHeadInfo (stx : Syntax) : SourceInfo :=\n  match stx.getHeadInfo? with\n  | some info => info\n  | none      => SourceInfo.none\n\n/--\nGet the starting position of the syntax, if possible.\nIf `canonicalOnly` is true, non-canonical `synthetic` nodes are treated as not carrying\nposition information.\n-/\ndef getPos? (stx : Syntax) (canonicalOnly := false) : Option String.Pos :=\n  stx.getHeadInfo.getPos? canonicalOnly\n\n\n/--\nGet the ending position of the syntax, if possible.\nIf `canonicalOnly` is true, non-canonical `synthetic` nodes are treated as not carrying\nposition information.\n-/\npartial def getTailPos? (stx : Syntax) (canonicalOnly := false) : Option String.Pos :=\n  match stx, canonicalOnly with\n  | atom (SourceInfo.original (endPos := pos) ..) .., _\n  | atom (SourceInfo.synthetic (endPos := pos) (canonical := true) ..) _, _\n  | atom (SourceInfo.synthetic (endPos := pos) ..) _,  false\n  | ident (SourceInfo.original (endPos := pos) ..) .., _\n  | ident (SourceInfo.synthetic (endPos := pos) (canonical := true) ..) .., _\n  | ident (SourceInfo.synthetic (endPos := pos) ..) .., false\n  | node (SourceInfo.original (endPos := pos) ..) .., _\n  | node (SourceInfo.synthetic (endPos := pos) (canonical := true) ..) .., _\n  | node (SourceInfo.synthetic (endPos := pos) ..) .., false => some pos\n  | node _ _ args, _ =>\n    let rec loop (i : Nat) : Option String.Pos :=\n      match decide (LT.lt i args.size) with\n      | true => match getTailPos? (args.get! ((args.size.sub i).sub 1)) canonicalOnly with\n         | some info => some info\n         | none      => loop (hAdd i 1)\n      | false => none\n    loop 0\n  | _, _ => none\n\n/--\nAn array of syntax elements interspersed with separators. Can be coerced\nto/from `Array Syntax` to automatically remove/insert the separators.\n-/\nstructure SepArray (sep : String) where\n  /-- The array of elements and separators, ordered like\n  `#[el1, sep1, el2, sep2, el3]`. -/\n  elemsAndSeps : Array Syntax\n\n/-- A typed version of `SepArray`. -/\nstructure TSepArray (ks : SyntaxNodeKinds) (sep : String) where\n  /-- The array of elements and separators, ordered like\n  `#[el1, sep1, el2, sep2, el3]`. -/\n  elemsAndSeps : Array Syntax\n\nend Syntax\n\n/-- An array of syntaxes of kind `ks`. -/\nabbrev TSyntaxArray (ks : SyntaxNodeKinds) := Array (TSyntax ks)\n\n/-- Implementation of `TSyntaxArray.raw`. -/\nunsafe def TSyntaxArray.rawImpl : TSyntaxArray ks \u2192 Array Syntax := unsafeCast\n\n/-- Converts a `TSyntaxArray` to an `Array Syntax`, without reallocation. -/\n@[implemented_by TSyntaxArray.rawImpl]\nopaque TSyntaxArray.raw (as : TSyntaxArray ks) : Array Syntax := Array.empty\n\n/-- Implementation of `TSyntaxArray.mk`. -/\nunsafe def TSyntaxArray.mkImpl : Array Syntax \u2192 TSyntaxArray ks := unsafeCast\n\n/-- Converts an `Array Syntax` to a `TSyntaxArray`, without reallocation. -/\n@[implemented_by TSyntaxArray.mkImpl]\nopaque TSyntaxArray.mk (as : Array Syntax) : TSyntaxArray ks := Array.empty\n\n/-- Constructs a synthetic `SourceInfo` using a `ref : Syntax` for the span. -/\ndef SourceInfo.fromRef (ref : Syntax) (canonical := false) : SourceInfo :=\n  let noncanonical ref :=\n    match ref.getPos?, ref.getTailPos? with\n    | some pos, some tailPos => .synthetic pos tailPos\n    | _,        _            => .none\n  match canonical with\n  | true =>\n    match ref.getPos? true, ref.getTailPos? true with\n    | some pos, some tailPos => .synthetic pos tailPos true\n    | _,        _            => noncanonical ref\n  | false => noncanonical ref\n\n/-- Constructs a synthetic `atom` with no source info. -/\ndef mkAtom (val : String) : Syntax :=\n  Syntax.atom SourceInfo.none val\n\n/-- Constructs a synthetic `atom` with source info coming from `src`. -/\ndef mkAtomFrom (src : Syntax) (val : String) (canonical := false) : Syntax :=\n  Syntax.atom (SourceInfo.fromRef src canonical) val\n\n/-! # Parser descriptions -/\n\n/--\nA `ParserDescr` is a grammar for parsers. This is used by the `syntax` command\nto produce parsers without having to `import Lean`.\n-/\ninductive ParserDescr where\n  /-- A (named) nullary parser, like `ppSpace` -/\n  | const  (name : Name)\n  /-- A (named) unary parser, like `group(p)` -/\n  | unary  (name : Name) (p : ParserDescr)\n  /-- A (named) binary parser, like `orelse` or `andthen`\n  (written as `p1 <|> p2` and `p1 p2` respectively in `syntax`) -/\n  | binary (name : Name) (p\u2081 p\u2082 : ParserDescr)\n  /-- Parses using `p`, then pops the stack to create a new node with kind `kind`.\n  The precedence `prec` is used to determine whether the parser should apply given\n  the current precedence level. -/\n  | node (kind : SyntaxNodeKind) (prec : Nat) (p : ParserDescr)\n  /-- Like `node` but for trailing parsers (which start with a nonterminal).\n  Assumes the lhs is already on the stack, and parses using `p`, then pops the\n  stack including the lhs to create a new node with kind `kind`.\n  The precedence `prec` and `lhsPrec` are used to determine whether the parser\n  should apply. -/\n  | trailingNode (kind : SyntaxNodeKind) (prec lhsPrec : Nat) (p : ParserDescr)\n  /-- A literal symbol parser: parses `val` as a literal.\n  This parser does not work on identifiers, so `symbol` arguments are declared\n  as \"keywords\" and cannot be used as identifiers anywhere in the file. -/\n  | symbol (val : String)\n  /-- Like `symbol`, but without reserving `val` as a keyword.\n  If `includeIdent` is true then `ident` will be reinterpreted as `atom` if it matches. -/\n  | nonReservedSymbol (val : String) (includeIdent : Bool)\n  /-- Parses using the category parser `catName` with right binding power\n  (i.e. precedence) `rbp`. -/\n  | cat (catName : Name) (rbp : Nat)\n  /-- Parses using another parser `declName`, which can be either\n  a `Parser` or `ParserDescr`. -/\n  | parser (declName : Name)\n  /-- Like `node`, but also declares that the body can be matched using an antiquotation\n  with name `name`. For example, `def $id:declId := 1` uses an antiquotation with\n  name `declId` in the place where a `declId` is expected. -/\n  | nodeWithAntiquot (name : String) (kind : SyntaxNodeKind) (p : ParserDescr)\n  /-- A `sepBy(p, sep)` parses 0 or more occurrences of `p` separated by `sep`.\n  `psep` is usually the same as `symbol sep`, but it can be overridden.\n  `sep` is only used in the antiquot syntax: `$x;*` would match if `sep` is `\";\"`.\n  `allowTrailingSep` is true if e.g. `a, b,` is also allowed to match. -/\n  | sepBy  (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n  /-- `sepBy1` is just like `sepBy`, except it takes 1 or more instead of\n  0 or more occurrences of `p`. -/\n  | sepBy1 (p : ParserDescr) (sep : String) (psep : ParserDescr) (allowTrailingSep : Bool := false)\n\ninstance : Inhabited ParserDescr where\n  default := ParserDescr.symbol \"\"\n\n/--\nAlthough `TrailingParserDescr` is an abbreviation for `ParserDescr`, Lean will\nlook at the declared type in order to determine whether to add the parser to\nthe leading or trailing parser table. The determination is done automatically\nby the `syntax` command.\n-/\nabbrev TrailingParserDescr := ParserDescr\n\n/-!\nRuntime support for making quotation terms auto-hygienic, by mangling identifiers\nintroduced by them with a \"macro scope\" supplied by the context. Details to appear in a\npaper soon.\n-/\n\n/--\nA macro scope identifier is just a `Nat` that gets bumped every time we\nenter a new macro scope. Within a macro scope, all occurrences of identifier `x`\nparse to the same thing, but `x` parsed from different macro scopes will\nproduce different identifiers.\n-/\nabbrev MacroScope := Nat\n/-- Macro scope used internally. It is not available for our frontend. -/\ndef reservedMacroScope := 0\n/-- First macro scope available for our frontend -/\ndef firstFrontendMacroScope := hAdd reservedMacroScope 1\n\n/--\nA `MonadRef` is a monad that has a `ref : Syntax` in the read-only state.\nThis is used to keep track of the location where we are working; if an exception\nis thrown, the `ref` gives the location where the error will be reported,\nassuming no more specific location is provided.\n-/\nclass MonadRef (m : Type \u2192 Type) where\n  /-- Get the current value of the `ref` -/\n  getRef      : m Syntax\n  /-- Run `x : m \u03b1` with a modified value for the `ref` -/\n  withRef {\u03b1} : Syntax \u2192 m \u03b1 \u2192 m \u03b1\n\nexport MonadRef (getRef)\n\ninstance (m n : Type \u2192 Type) [MonadLift m n] [MonadFunctor m n] [MonadRef m] : MonadRef n where\n  getRef        := liftM (getRef : m _)\n  withRef ref x := monadMap (m := m) (MonadRef.withRef ref) x\n\n/--\nReplaces `oldRef` with `ref`, unless `ref` has no position info.\nThis biases us to having a valid span to report an error on.\n-/\ndef replaceRef (ref : Syntax) (oldRef : Syntax) : Syntax :=\n  match ref.getPos? with\n  | some _ => ref\n  | _      => oldRef\n\n/--\nRun `x : m \u03b1` with a modified value for the `ref`. This is not exactly\nthe same as `MonadRef.withRef`, because it uses `replaceRef` to avoid putting\nsyntax with bad spans in the state.\n-/\n@[always_inline, inline]\ndef withRef [Monad m] [MonadRef m] {\u03b1} (ref : Syntax) (x : m \u03b1) : m \u03b1 :=\n  bind getRef fun oldRef =>\n  let ref := replaceRef ref oldRef\n  MonadRef.withRef ref x\n\n/-- A monad that supports syntax quotations. Syntax quotations (in term\n    position) are monadic values that when executed retrieve the current \"macro\n    scope\" from the monad and apply it to every identifier they introduce\n    (independent of whether this identifier turns out to be a reference to an\n    existing declaration, or an actually fresh binding during further\n    elaboration). We also apply the position of the result of `getRef` to each\n    introduced symbol, which results in better error positions than not applying\n    any position. -/\nclass MonadQuotation (m : Type \u2192 Type) extends MonadRef m where\n  /-- Get the fresh scope of the current macro invocation -/\n  getCurrMacroScope : m MacroScope\n  /-- Get the module name of the current file. This is used to ensure that\n  hygienic names don't clash across multiple files. -/\n  getMainModule     : m Name\n  /--\n  Execute action in a new macro invocation context. This transformer should be\n  used at all places that morally qualify as the beginning of a \"macro call\",\n  e.g. `elabCommand` and `elabTerm` in the case of the elaborator. However, it\n  can also be used internally inside a \"macro\" if identifiers introduced by\n  e.g. different recursive calls should be independent and not collide. While\n  returning an intermediate syntax tree that will recursively be expanded by\n  the elaborator can be used for the same effect, doing direct recursion inside\n  the macro guarded by this transformer is often easier because one is not\n  restricted to passing a single syntax tree. Modelling this helper as a\n  transformer and not just a monadic action ensures that the current macro\n  scope before the recursive call is restored after it, as expected.\n  -/\n  withFreshMacroScope {\u03b1 : Type} : m \u03b1 \u2192 m \u03b1\n\nexport MonadQuotation (getCurrMacroScope getMainModule withFreshMacroScope)\n\n/-- Construct a synthetic `SourceInfo` from the `ref` in the monad state. -/\n@[inline]\ndef MonadRef.mkInfoFromRefPos [Monad m] [MonadRef m] : m SourceInfo :=\n  return SourceInfo.fromRef (\u2190 getRef)\n\ninstance [MonadFunctor m n] [MonadLift m n] [MonadQuotation m] : MonadQuotation n where\n  getCurrMacroScope   := liftM (m := m) getCurrMacroScope\n  getMainModule       := liftM (m := m) getMainModule\n  withFreshMacroScope := monadMap (m := m) withFreshMacroScope\n\n/-!\nWe represent a name with macro scopes as\n```\n<actual name>._@.(<module_name>.<scopes>)*.<module_name>._hyg.<scopes>\n```\nExample: suppose the module name is `Init.Data.List.Basic`, and name is `foo.bla`, and macroscopes [2, 5]\n```\nfoo.bla._@.Init.Data.List.Basic._hyg.2.5\n```\n\nWe may have to combine scopes from different files/modules.\nThe main modules being processed is always the right-most one.\nThis situation may happen when we execute a macro generated in\nan imported file in the current file.\n```\nfoo.bla._@.Init.Data.List.Basic.2.1.Init.Lean.Expr._hyg.4\n```\n\nThe delimiter `_hyg` is used just to improve the `hasMacroScopes` performance.\n-/\n\n/-- Does this name have hygienic macro scopes? -/\ndef Name.hasMacroScopes : Name \u2192 Bool\n  | str _ s => beq s \"_hyg\"\n  | num p _ => hasMacroScopes p\n  | _       => false\n\nprivate def eraseMacroScopesAux : Name \u2192 Name\n  | .str p s   => match beq s \"_@\" with\n    | true  => p\n    | false => eraseMacroScopesAux p\n  | .num p _   => eraseMacroScopesAux p\n  | .anonymous => Name.anonymous\n\n/-- Remove the macro scopes from the name. -/\n@[export lean_erase_macro_scopes]\ndef Name.eraseMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => eraseMacroScopesAux n\n  | false => n\n\nprivate def simpMacroScopesAux : Name \u2192 Name\n  | .num p i => Name.mkNum (simpMacroScopesAux p) i\n  | n        => eraseMacroScopesAux n\n\n/-- Helper function we use to create binder names that do not need to be unique. -/\n@[export lean_simp_macro_scopes]\ndef Name.simpMacroScopes (n : Name) : Name :=\n  match n.hasMacroScopes with\n  | true  => simpMacroScopesAux n\n  | false => n\n\n/--\nA `MacroScopesView` represents a parsed hygienic name. `extractMacroScopes`\nwill decode it from a `Name`, and `.review` will re-encode it. The grammar of a\nhygienic name is:\n```\n<name>._@.(<module_name>.<scopes>)*.<mainModule>._hyg.<scopes>\n```\n-/\nstructure MacroScopesView where\n  /-- The original (unhygienic) name. -/\n  name       : Name\n  /-- All the name components `(<module_name>.<scopes>)*` from the imports\n  concatenated together. -/\n  imported   : Name\n  /-- The main module in which this identifier was parsed. -/\n  mainModule : Name\n  /-- The list of macro scopes. -/\n  scopes     : List MacroScope\n\ninstance : Inhabited MacroScopesView where\n  default := \u27e8default, default, default, default\u27e9\n\n/-- Encode a hygienic name from the parsed pieces. -/\ndef MacroScopesView.review (view : MacroScopesView) : Name :=\n  match view.scopes with\n  | List.nil      => view.name\n  | List.cons _ _ =>\n    let base := (Name.mkStr (Name.appendCore (Name.appendCore (Name.mkStr view.name \"_@\") view.imported) view.mainModule) \"_hyg\")\n    view.scopes.foldl Name.mkNum base\n\nprivate def assembleParts : List Name \u2192 Name \u2192 Name\n  | .nil,                acc => acc\n  | .cons (.str _ s) ps, acc => assembleParts ps (Name.mkStr acc s)\n  | .cons (.num _ n) ps, acc => assembleParts ps (Name.mkNum acc n)\n  | _,                   _   => panic \"Error: unreachable @ assembleParts\"\n\nprivate def extractImported (scps : List MacroScope) (mainModule : Name) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := mainModule, imported := assembleParts parts Name.anonymous, scopes := scps }\n    | false => extractImported scps mainModule p (List.cons n parts)\n  | n@(Name.num p _), parts => extractImported scps mainModule p (List.cons n parts)\n  | _,                    _     => panic \"Error: unreachable @ extractImported\"\n\nprivate def extractMainModule (scps : List MacroScope) : Name \u2192 List Name \u2192 MacroScopesView\n  | n@(Name.str p str), parts =>\n    match beq str \"_@\" with\n    | true  => { name := p, mainModule := assembleParts parts Name.anonymous, imported := Name.anonymous, scopes := scps }\n    | false => extractMainModule scps p (List.cons n parts)\n  | n@(Name.num _ _), acc => extractImported scps (assembleParts acc Name.anonymous) n List.nil\n  | _,                    _   => panic \"Error: unreachable @ extractMainModule\"\n\nprivate def extractMacroScopesAux : Name \u2192 List MacroScope \u2192 MacroScopesView\n  | Name.num p scp, acc => extractMacroScopesAux p (List.cons scp acc)\n  | Name.str p _  , acc => extractMainModule acc p List.nil -- str must be \"_hyg\"\n  | _,                _   => panic \"Error: unreachable @ extractMacroScopesAux\"\n\n/--\n  Revert all `addMacroScope` calls. `v = extractMacroScopes n \u2192 n = v.review`.\n  This operation is useful for analyzing/transforming the original identifiers, then adding back\n  the scopes (via `MacroScopesView.review`). -/\ndef extractMacroScopes (n : Name) : MacroScopesView :=\n  match n.hasMacroScopes with\n  | true  => extractMacroScopesAux n List.nil\n  | false => { name := n, scopes := List.nil, imported := Name.anonymous, mainModule := Name.anonymous }\n\n/-- Add a new macro scope onto the name `n`, in the given `mainModule`. -/\ndef addMacroScope (mainModule : Name) (n : Name) (scp : MacroScope) : Name :=\n  match n.hasMacroScopes with\n  | true =>\n    let view := extractMacroScopes n\n    match beq view.mainModule mainModule with\n    | true  => Name.mkNum n scp\n    | false =>\n      { view with\n        imported   := view.scopes.foldl Name.mkNum (Name.appendCore view.imported view.mainModule)\n        mainModule := mainModule\n        scopes     := List.cons scp List.nil\n      }.review\n  | false =>\n    Name.mkNum (Name.mkStr (Name.appendCore (Name.mkStr n \"_@\") mainModule) \"_hyg\") scp\n\n/--\nAppend two names that may have macro scopes. The macro scopes in `b` are always erased.\nIf `a` has macro scopes, then they are propagated to the result of `append a b`.\n-/\ndef Name.append (a b : Name) : Name :=\n  match a.hasMacroScopes, b.hasMacroScopes with\n  | true, true  =>\n    panic \"Error: invalid `Name.append`, both arguments have macro scopes, consider using `eraseMacroScopes`\"\n  | true, false =>\n    let view := extractMacroScopes a\n    { view with name := appendCore view.name b }.review\n  | false, true =>\n    let view := extractMacroScopes b\n    { view with name := appendCore a view.name }.review\n  | false, false => appendCore a b\n\ninstance : Append Name where\n  append := Name.append\n\n/--\nAdd a new macro scope onto the name `n`, using the monad state to supply the\nmain module and current macro scope.\n-/\n@[inline] def MonadQuotation.addMacroScope {m : Type \u2192 Type} [MonadQuotation m] [Monad m] (n : Name) : m Name :=\n  bind getMainModule     fun mainModule =>\n  bind getCurrMacroScope fun scp =>\n  pure (Lean.addMacroScope mainModule n scp)\n\n/-- The default maximum recursion depth. This is adjustable using the `maxRecDepth` option. -/\ndef defaultMaxRecDepth := 512\n\n/-- The message to display on stack overflow. -/\ndef maxRecDepthErrorMessage : String :=\n  \"maximum recursion depth has been reached (use `set_option maxRecDepth <num>` to increase limit)\"\n\nnamespace Syntax\n\n/-- Is this syntax a null `node`? -/\ndef matchesNull (stx : Syntax) (n : Nat) : Bool :=\n  stx.isNodeOf nullKind n\n\n/--\n  Function used for determining whether a syntax pattern `` `(id) `` is matched.\n  There are various conceivable notions of when two syntactic identifiers should be regarded as identical,\n  but semantic definitions like whether they refer to the same global name cannot be implemented without\n  context information (i.e. `MonadResolveName`). Thus in patterns we default to the structural solution\n  of comparing the identifiers' `Name` values, though we at least do so modulo macro scopes so that\n  identifiers that \"look\" the same match. This is particularly useful when dealing with identifiers that\n  do not actually refer to Lean bindings, e.g. in the `stx` pattern `` `(many($p)) ``. -/\ndef matchesIdent (stx : Syntax) (id : Name) : Bool :=\n  and stx.isIdent (beq stx.getId.eraseMacroScopes id.eraseMacroScopes)\n\n/-- Is this syntax a node kind `k` wrapping an `atom _ val`? -/\ndef matchesLit (stx : Syntax) (k : SyntaxNodeKind) (val : String) : Bool :=\n  match stx with\n  | Syntax.node _ k' args => and (beq k k') (match args.getD 0 Syntax.missing with\n    | Syntax.atom _ val' => beq val val'\n    | _                  => false)\n  | _                     => false\n\nend Syntax\n\nnamespace Macro\n\n/-- References -/\nprivate opaque MethodsRefPointed : NonemptyType.{0}\n\nprivate def MethodsRef : Type := MethodsRefPointed.type\n\ninstance : Nonempty MethodsRef := MethodsRefPointed.property\n\n/-- The read-only context for the `MacroM` monad. -/\nstructure Context where\n  /-- An opaque reference to the `Methods` object. This is done to break a\n  dependency cycle: the `Methods` involve `MacroM` which has not been defined yet. -/\n  methods        : MethodsRef\n  /-- The currently parsing module. -/\n  mainModule     : Name\n  /-- The current macro scope. -/\n  currMacroScope : MacroScope\n  /-- The current recursion depth. -/\n  currRecDepth   : Nat := 0\n  /-- The maximum recursion depth. -/\n  maxRecDepth    : Nat := defaultMaxRecDepth\n  /-- The syntax which supplies the position of error messages. -/\n  ref            : Syntax\n\n/-- An exception in the `MacroM` monad. -/\ninductive Exception where\n  /-- A general error, given a message and a span (expressed as a `Syntax`). -/\n  | error             : Syntax \u2192 String \u2192 Exception\n  /-- An unsupported syntax exception. We keep this separate because it is\n  used for control flow: if one macro does not support a syntax then we try\n  the next one. -/\n  | unsupportedSyntax : Exception\n\n/-- The mutable state for the `MacroM` monad. -/\nstructure State where\n  /-- The global macro scope counter, used for producing fresh scope names. -/\n  macroScope : MacroScope\n  /-- The list of trace messages that have been produced, each with a trace\n  class and a message. -/\n  traceMsgs  : List (Prod Name String) := List.nil\n  deriving Inhabited\n\nend Macro\n\n/--\nThe `MacroM` monad is the main monad for macro expansion. It has the\ninformation needed to handle hygienic name generation, and is the monad that\n`macro` definitions live in.\n\nNotably, this is a (relatively) pure monad: there is no `IO` and no access to\nthe `Environment`. That means that things like declaration lookup are\nimpossible here, as well as `IO.Ref` or other side-effecting operations.\nFor more capabilities, macros can instead be written as `elab` using `adaptExpander`.\n-/\nabbrev MacroM := ReaderT Macro.Context (EStateM Macro.Exception Macro.State)\n\n/--\nA `macro` has type `Macro`, which is a `Syntax \u2192 MacroM Syntax`: it\nreceives an input syntax and is supposed to \"expand\" it into another piece of\nsyntax.\n-/\nabbrev Macro := Syntax \u2192 MacroM Syntax\n\nnamespace Macro\n\ninstance : MonadRef MacroM where\n  getRef     := bind read fun ctx => pure ctx.ref\n  withRef    := fun ref x => withReader (fun ctx => { ctx with ref := ref }) x\n\n/-- Add a new macro scope to the name `n`. -/\ndef addMacroScope (n : Name) : MacroM Name :=\n  bind read fun ctx =>\n  pure (Lean.addMacroScope ctx.mainModule n ctx.currMacroScope)\n\n/-- Throw an `unsupportedSyntax` exception. -/\ndef throwUnsupported {\u03b1} : MacroM \u03b1 :=\n  throw Exception.unsupportedSyntax\n\n/--\nThrow an error with the given message,\nusing the `ref` for the location information.\n-/\ndef throwError {\u03b1} (msg : String) : MacroM \u03b1 :=\n  bind getRef fun ref =>\n  throw (Exception.error ref msg)\n\n/-- Throw an error with the given message and location information. -/\ndef throwErrorAt {\u03b1} (ref : Syntax) (msg : String) : MacroM \u03b1 :=\n  withRef ref (throwError msg)\n\n/--\nIncrements the macro scope counter so that inside the body of `x` the macro\nscope is fresh.\n-/\n@[inline] protected def withFreshMacroScope {\u03b1} (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind (modifyGet (fun s => (s.macroScope, { s with macroScope := hAdd s.macroScope 1 }))) fun fresh =>\n  withReader (fun ctx => { ctx with currMacroScope := fresh }) x\n\n/-- Run `x` with an incremented recursion depth counter. -/\n@[inline] def withIncRecDepth {\u03b1} (ref : Syntax) (x : MacroM \u03b1) : MacroM \u03b1 :=\n  bind read fun ctx =>\n  match beq ctx.currRecDepth ctx.maxRecDepth with\n  | true  => throw (Exception.error ref maxRecDepthErrorMessage)\n  | false => withReader (fun ctx => { ctx with currRecDepth := hAdd ctx.currRecDepth 1 }) x\n\ninstance : MonadQuotation MacroM where\n  getCurrMacroScope ctx := pure ctx.currMacroScope\n  getMainModule     ctx := pure ctx.mainModule\n  withFreshMacroScope   := Macro.withFreshMacroScope\n\n/-- The opaque methods that are available to `MacroM`. -/\nstructure Methods where\n  /-- Expands macros in the given syntax. A return value of `none` means there\n  was nothing to expand. -/\n  expandMacro?      : Syntax \u2192 MacroM (Option Syntax)\n  /-- Get the current namespace in the file. -/\n  getCurrNamespace  : MacroM Name\n  /-- Check if a given name refers to a declaration. -/\n  hasDecl           : Name \u2192 MacroM Bool\n  /-- Resolves the given name to an overload list of namespaces. -/\n  resolveNamespace  : Name \u2192 MacroM (List Name)\n  /-- Resolves the given name to an overload list of global definitions.\n  The `List String` in each alternative is the deduced list of projections\n  (which are ambiguous with name components). -/\n  resolveGlobalName : Name \u2192 MacroM (List (Prod Name (List String)))\n  deriving Inhabited\n\n/-- Implementation of `mkMethods`. -/\nunsafe def mkMethodsImp (methods : Methods) : MethodsRef :=\n  unsafeCast methods\n\n/-- Make an opaque reference to a `Methods`. -/\n@[implemented_by mkMethodsImp]\nopaque mkMethods (methods : Methods) : MethodsRef\n\ninstance : Inhabited MethodsRef where\n  default := mkMethods default\n\n/-- Implementation of `getMethods`. -/\nunsafe def getMethodsImp : MacroM Methods :=\n  bind read fun ctx => pure (unsafeCast (ctx.methods))\n\n/-- Extract the methods list from the `MacroM` state. -/\n@[implemented_by getMethodsImp] opaque getMethods : MacroM Methods\n\n/--\n`expandMacro? stx` returns `some stxNew` if `stx` is a macro,\nand `stxNew` is its expansion.\n-/\ndef expandMacro? (stx : Syntax) : MacroM (Option Syntax) := do\n  (\u2190 getMethods).expandMacro? stx\n\n/-- Returns `true` if the environment contains a declaration with name `declName` -/\ndef hasDecl (declName : Name) : MacroM Bool := do\n  (\u2190 getMethods).hasDecl declName\n\n/-- Gets the current namespace given the position in the file. -/\ndef getCurrNamespace : MacroM Name := do\n  (\u2190 getMethods).getCurrNamespace\n\n  /-- Resolves the given name to an overload list of namespaces. -/\ndef resolveNamespace (n : Name) : MacroM (List Name) := do\n  (\u2190 getMethods).resolveNamespace n\n\n/--\nResolves the given name to an overload list of global definitions.\nThe `List String` in each alternative is the deduced list of projections\n(which are ambiguous with name components).\n-/\ndef resolveGlobalName (n : Name) : MacroM (List (Prod Name (List String))) := do\n  (\u2190 getMethods).resolveGlobalName n\n\n/-- Add a new trace message, with the given trace class and message. -/\ndef trace (clsName : Name) (msg : String) : MacroM Unit := do\n  modify fun s => { s with traceMsgs := List.cons (Prod.mk clsName msg) s.traceMsgs }\n\nend Macro\n\nexport Macro (expandMacro?)\n\nnamespace PrettyPrinter\n\n/--\nThe unexpander monad, essentially `Syntax \u2192 Option \u03b1`. The `Syntax` is the `ref`,\nand it has the possibility of failure without an error message.\n-/\nabbrev UnexpandM := ReaderT Syntax (EStateM Unit Unit)\n\n/--\nFunction that tries to reverse macro expansions as a post-processing step of delaboration.\nWhile less general than an arbitrary delaborator, it can be declared without importing `Lean`.\nUsed by the `[app_unexpander]` attribute.\n-/\n-- a `kindUnexpander` could reasonably be added later\nabbrev Unexpander := Syntax \u2192 UnexpandM Syntax\n\ninstance : MonadQuotation UnexpandM where\n  getRef              := read\n  withRef ref x       := withReader (fun _ => ref) x\n  -- unexpanders should not need to introduce new names\n  getCurrMacroScope   := pure 0\n  getMainModule       := pure `_fakeMod\n  withFreshMacroScope := id\n\nend PrettyPrinter\n\nend Lean\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/Prelude.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 {\u03b1 : Type} \n\nnamespace form\n\n\ndef skolem_term (k ms) : term := \nlist.foldl (\u03bb t1 m, t1 ^* # m) (& k) ms\n\ndef snf_core : nat \u2192 form \u2192 (nat \u00d7 form)\n| k \u22a4*        := (k, \u22a4*) \n| k \u22a5*        := (k, \u22a5*) \n| k (m ** ts) := (k, m ** ts)\n| k (\u00ac* p)    := (k, \u00ac* p)\n| k (p \u2227* q)  := \n  let (m, p') := snf_core k p in \n  let (n, q') := snf_core m q in \n  (n, p' \u2227* q')\n| k (p \u2228* q)  := \n  let (m, p') := snf_core k p in \n  let (n, q') := snf_core m q in \n  (n, p' \u2228* q')\n| k (\u2200* p)    := \n  let (m, p') := snf_core k p in (m, \u2200* p')\n| k (\u2203* 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 : \u2200 p, (sat \u03b1 (snf p) \u2194 sat \u03b1 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": "import Smt\n\ntheorem modus_ponens {p q : Prop} : p \u2192 (p \u2192 q) \u2192 q := 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/ModusPonens.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7248702761768248, "lm_q2_score": 0.63341024983754, "lm_q1q2_score": 0.4591402627329692}}
{"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 {\u03b1 \u03b2 \u03b3 : Type _} [LinearOrder \u03b1] [TopologicalSpace \u03b3] {a b c : \u03b1} {h : a \u2264 b}\n\n/- warning: filter.tendsto.Icc_extend -> Filter.Tendsto.IccExtend' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u3} \u03b3] {a : \u03b1} {b : \u03b1} {h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b} (f : \u03b3 -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) {z : \u03b3} {l : Filter.{u1} \u03b1} {l' : Filter.{u2} \u03b2}, (Filter.Tendsto.{max u3 u1, u2} (Prod.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))) \u03b2 (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (\u03b3 -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (Prod.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))) \u03b2 (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} \u03b3 ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2 (Function.hasUncurryBase.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2)) f) (Filter.prod.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) (nhds.{u3} \u03b3 _inst_2 z) (Filter.map.{u1, u1} \u03b1 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) (Set.projIcc.{u1} \u03b1 _inst_1 a b h) l)) l') -> (Filter.Tendsto.{max u3 u1, u2} (Prod.{u3, u1} \u03b3 \u03b1) \u03b2 (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (\u03b3 -> \u03b1 -> \u03b2) (Prod.{u3, u1} \u03b3 \u03b1) \u03b2 (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} \u03b3 (\u03b1 -> \u03b2) \u03b1 \u03b2 (Function.hasUncurryBase.{u1, u2} \u03b1 \u03b2)) (Function.comp.{succ u3, max (succ u1) (succ u2), max (succ u1) (succ u2)} \u03b3 ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (\u03b1 -> \u03b2) (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h) f)) (Filter.prod.{u3, u1} \u03b3 \u03b1 (nhds.{u3} \u03b3 _inst_2 z) l) l')\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : LinearOrder.{u3} \u03b1] [_inst_2 : TopologicalSpace.{u1} \u03b3] {a : \u03b1} {b : \u03b1} {h : LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1)))))) a b} (f : \u03b3 -> (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) {z : \u03b3} {l : Filter.{u3} \u03b1} {l' : Filter.{u2} \u03b2}, (Filter.Tendsto.{max u3 u1, u2} (Prod.{u1, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b))) \u03b2 (Function.HasUncurry.uncurry.{max (max u3 u2) u1, max u3 u1, u2} (\u03b3 -> (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) (Prod.{u1, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b))) \u03b2 (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} \u03b3 ((Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) \u03b2 (Function.hasUncurryBase.{u3, u2} (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) \u03b2)) f) (Filter.prod.{u1, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) (nhds.{u1} \u03b3 _inst_2 z) (Filter.map.{u3, u3} \u03b1 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) (Set.projIcc.{u3} \u03b1 _inst_1 a b h) l)) l') -> (Filter.Tendsto.{max u3 u1, u2} (Prod.{u1, u3} \u03b3 \u03b1) \u03b2 (Function.HasUncurry.uncurry.{max (max u3 u2) u1, max u3 u1, u2} (\u03b3 -> \u03b1 -> \u03b2) (Prod.{u1, u3} \u03b3 \u03b1) \u03b2 (Function.hasUncurryInduction.{u1, max u3 u2, u3, u2} \u03b3 (\u03b1 -> \u03b2) \u03b1 \u03b2 (Function.hasUncurryBase.{u3, u2} \u03b1 \u03b2)) (Function.comp.{succ u1, max (succ u2) (succ u3), max (succ u2) (succ u3)} \u03b3 ((Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) (\u03b1 -> \u03b2) (Set.IccExtend.{u3, u2} \u03b1 \u03b2 _inst_1 a b h) f)) (Filter.prod.{u1, u3} \u03b3 \u03b1 (nhds.{u1} \u03b3 _inst_2 z) l) l')\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.Icc_extend Filter.Tendsto.IccExtend'\u2093'. -/\ntheorem Filter.Tendsto.IccExtend' (f : \u03b3 \u2192 Icc a b \u2192 \u03b2) {z : \u03b3} {l : Filter \u03b1} {l' : Filter \u03b2}\n    (hf : Tendsto (\u21bff) (\ud835\udcdd z \u00d7\u1da0 l.map (projIcc a b h)) l') :\n    Tendsto (\u21bf(IccExtend h \u2218 f)) (\ud835\udcdd z \u00d7\u1da0 l) l' :=\n  show Tendsto (\u21bff \u2218 Prod.map id (projIcc a b h)) (\ud835\udcdd z \u00d7\u1da0 l) l' from\n    hf.comp <| tendsto_id.Prod_map tendsto_map\n#align filter.tendsto.Icc_extend Filter.Tendsto.IccExtend'\n\nvariable [TopologicalSpace \u03b1] [OrderTopology \u03b1] [TopologicalSpace \u03b2]\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    \u27e8projIcc_surjective h, fun s =>\n      \u27e8fun hs => hs.Preimage continuous_projIcc, fun hs =>\n        \u27e8_, hs, by\n          ext\n          simp\u27e9\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b} [_inst_3 : TopologicalSpace.{u1} \u03b1] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_3 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_5 : TopologicalSpace.{u2} \u03b2] {f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2}, Iff (Continuous.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_5 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f)) (Continuous.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2 (Subtype.topologicalSpace.{u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) _inst_3) _inst_5 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} {h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b} [_inst_3 : TopologicalSpace.{u2} \u03b1] [_inst_4 : OrderTopology.{u2} \u03b1 _inst_3 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_5 : TopologicalSpace.{u1} \u03b2] {f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2}, Iff (Continuous.{u2, u1} \u03b1 \u03b2 _inst_3 _inst_5 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f)) (Continuous.{u2, u1} (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) \u03b2 (instTopologicalSpaceSubtype.{u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) _inst_3) _inst_5 f)\nCase conversion may be inaccurate. Consider using '#align continuous_Icc_extend_iff continuous_IccExtend_iff\u2093'. -/\n@[simp]\ntheorem continuous_IccExtend_iff {f : Icc a b \u2192 \u03b2} : Continuous (IccExtend h f) \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u3} \u03b3] {a : \u03b1} {b : \u03b1} {h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b} [_inst_3 : TopologicalSpace.{u1} \u03b1] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_3 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_5 : TopologicalSpace.{u2} \u03b2] {f : \u03b3 -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2} {g : \u03b3 -> \u03b1}, (Continuous.{max u3 u1, u2} (Prod.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))) \u03b2 (Prod.topologicalSpace.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) _inst_2 (Subtype.topologicalSpace.{u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) _inst_3)) _inst_5 (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (\u03b3 -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (Prod.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))) \u03b2 (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} \u03b3 ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2 (Function.hasUncurryBase.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2)) f)) -> (Continuous.{u3, u1} \u03b3 \u03b1 _inst_2 _inst_3 g) -> (Continuous.{u3, u2} \u03b3 \u03b2 _inst_2 _inst_5 (fun (a_1 : \u03b3) => Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h (f a_1) (g a_1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} [_inst_1 : LinearOrder.{u3} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b3] {a : \u03b1} {b : \u03b1} {h : LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1)))))) a b} [_inst_3 : TopologicalSpace.{u3} \u03b1] [_inst_4 : OrderTopology.{u3} \u03b1 _inst_3 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1)))))] [_inst_5 : TopologicalSpace.{u1} \u03b2] {f : \u03b3 -> (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2} {g : \u03b3 -> \u03b1}, (Continuous.{max u3 u2, u1} (Prod.{u2, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b))) \u03b2 (instTopologicalSpaceProd.{u2, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) _inst_2 (instTopologicalSpaceSubtype.{u3} \u03b1 (fun (x : \u03b1) => Membership.mem.{u3, u3} \u03b1 (Set.{u3} \u03b1) (Set.instMembershipSet.{u3} \u03b1) x (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) _inst_3)) _inst_5 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (\u03b3 -> (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) (Prod.{u2, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b))) \u03b2 (Function.hasUncurryInduction.{u2, max u3 u1, u3, u1} \u03b3 ((Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) \u03b2 (Function.hasUncurryBase.{u3, u1} (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) \u03b2)) f)) -> (Continuous.{u2, u3} \u03b3 \u03b1 _inst_2 _inst_3 g) -> (Continuous.{u2, u1} \u03b3 \u03b2 _inst_2 _inst_5 (fun (a_1 : \u03b3) => Set.IccExtend.{u3, u1} \u03b1 \u03b2 _inst_1 a b h (f a_1) (g a_1)))\nCase conversion may be inaccurate. Consider using '#align continuous.Icc_extend Continuous.IccExtend\u2093'. -/\n/-- See Note [continuity lemma statement]. -/\ntheorem Continuous.IccExtend {f : \u03b3 \u2192 Icc a b \u2192 \u03b2} {g : \u03b3 \u2192 \u03b1} (hf : Continuous \u21bff)\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrder.{u1} \u03b1] {a : \u03b1} {b : \u03b1} {h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b} [_inst_3 : TopologicalSpace.{u1} \u03b1] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_3 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_5 : TopologicalSpace.{u2} \u03b2] {f : (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2}, (Continuous.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2 (Subtype.topologicalSpace.{u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) _inst_3) _inst_5 f) -> (Continuous.{u1, u2} \u03b1 \u03b2 _inst_3 _inst_5 (Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrder.{u2} \u03b1] {a : \u03b1} {b : \u03b1} {h : LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))) a b} [_inst_3 : TopologicalSpace.{u2} \u03b1] [_inst_4 : OrderTopology.{u2} \u03b1 _inst_3 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1)))))] [_inst_5 : TopologicalSpace.{u1} \u03b2] {f : (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) -> \u03b2}, (Continuous.{u2, u1} (Set.Elem.{u2} \u03b1 (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) \u03b2 (instTopologicalSpaceSubtype.{u2} \u03b1 (fun (x : \u03b1) => Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x (Set.Icc.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (SemilatticeInf.toPartialOrder.{u2} \u03b1 (Lattice.toSemilatticeInf.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 _inst_1))))) a b)) _inst_3) _inst_5 f) -> (Continuous.{u2, u1} \u03b1 \u03b2 _inst_3 _inst_5 (Set.IccExtend.{u2, u1} \u03b1 \u03b2 _inst_1 a b h f))\nCase conversion may be inaccurate. Consider using '#align continuous.Icc_extend' Continuous.Icc_extend'\u2093'. -/\n/-- A useful special case of `continuous.Icc_extend`. -/\n@[continuity]\ntheorem Continuous.Icc_extend' {f : Icc a b \u2192 \u03b2} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : LinearOrder.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u3} \u03b3] {a : \u03b1} {b : \u03b1} {h : LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))) a b} [_inst_3 : TopologicalSpace.{u1} \u03b1] [_inst_4 : OrderTopology.{u1} \u03b1 _inst_3 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1))))] [_inst_5 : TopologicalSpace.{u2} \u03b2] {x : \u03b3} (f : \u03b3 -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) {g : \u03b3 -> \u03b1}, (ContinuousAt.{max u3 u1, u2} (Prod.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))) \u03b2 (Prod.topologicalSpace.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) _inst_2 (Subtype.topologicalSpace.{u1} \u03b1 (fun (x : \u03b1) => Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) _inst_3)) _inst_5 (Function.HasUncurry.uncurry.{max u3 u1 u2, max u3 u1, u2} (\u03b3 -> (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (Prod.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b))) \u03b2 (Function.hasUncurryInduction.{u3, max u1 u2, u1, u2} \u03b3 ((coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) -> \u03b2) (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2 (Function.hasUncurryBase.{u1, u2} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) \u03b2)) f) (Prod.mk.{u3, u1} \u03b3 (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.Icc.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (SemilatticeInf.toPartialOrder.{u1} \u03b1 (Lattice.toSemilatticeInf.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 _inst_1)))) a b)) x (Set.projIcc.{u1} \u03b1 _inst_1 a b h (g x)))) -> (ContinuousAt.{u3, u1} \u03b3 \u03b1 _inst_2 _inst_3 g x) -> (ContinuousAt.{u3, u2} \u03b3 \u03b2 _inst_2 _inst_5 (fun (a_1 : \u03b3) => Set.IccExtend.{u1, u2} \u03b1 \u03b2 _inst_1 a b h (f a_1) (g a_1)) x)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} [_inst_1 : LinearOrder.{u3} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b3] {a : \u03b1} {b : \u03b1} {h : LE.le.{u3} \u03b1 (Preorder.toLE.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1)))))) a b} [_inst_3 : TopologicalSpace.{u3} \u03b1] [_inst_4 : OrderTopology.{u3} \u03b1 _inst_3 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1)))))] [_inst_5 : TopologicalSpace.{u1} \u03b2] {x : \u03b3} (f : \u03b3 -> (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) {g : \u03b3 -> \u03b1}, (ContinuousAt.{max u3 u2, u1} (Prod.{u2, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b))) \u03b2 (instTopologicalSpaceProd.{u2, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) _inst_2 (instTopologicalSpaceSubtype.{u3} \u03b1 (fun (x : \u03b1) => Membership.mem.{u3, u3} \u03b1 (Set.{u3} \u03b1) (Set.instMembershipSet.{u3} \u03b1) x (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) _inst_3)) _inst_5 (Function.HasUncurry.uncurry.{max (max u3 u1) u2, max u3 u2, u1} (\u03b3 -> (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) (Prod.{u2, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b))) \u03b2 (Function.hasUncurryInduction.{u2, max u3 u1, u3, u1} \u03b3 ((Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) -> \u03b2) (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) \u03b2 (Function.hasUncurryBase.{u3, u1} (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) \u03b2)) f) (Prod.mk.{u2, u3} \u03b3 (Set.Elem.{u3} \u03b1 (Set.Icc.{u3} \u03b1 (PartialOrder.toPreorder.{u3} \u03b1 (SemilatticeInf.toPartialOrder.{u3} \u03b1 (Lattice.toSemilatticeInf.{u3} \u03b1 (DistribLattice.toLattice.{u3} \u03b1 (instDistribLattice.{u3} \u03b1 _inst_1))))) a b)) x (Set.projIcc.{u3} \u03b1 _inst_1 a b h (g x)))) -> (ContinuousAt.{u2, u3} \u03b3 \u03b1 _inst_2 _inst_3 g x) -> (ContinuousAt.{u2, u1} \u03b3 \u03b2 _inst_2 _inst_5 (fun (a_1 : \u03b3) => Set.IccExtend.{u3, u1} \u03b1 \u03b2 _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\u2093'. -/\ntheorem ContinuousAt.IccExtend {x : \u03b3} (f : \u03b3 \u2192 Icc a b \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1}\n    (hf : ContinuousAt (\u21bff) (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 (\u21bff \u2218 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 \u00d7 D) \u2964 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 := \u03bb \u27e8Y, X\u27e9 => F \u27e8X, Y\u27e9\n      hom_map := \u03bb \u27e8g, f\u27e9 => F.hom_map \u27e8f, g\u27e9\n      hom_map_comp := \u03bb \u27e8g\u2081, f\u2081\u27e9 \u27e8g\u2082, f\u2082\u27e9 => by\n        show F.hom_map (_, _ \u226b _) = F.hom_map _ \u226b F.hom_map _ \n        rw [\u2190hom_map_comp]\n        show F.hom_map (_, _ \u226b _) = F.hom_map ((_ \u226b _), (_ \u226b _))\n        simp\n      hom_map_id := \u03bb Y => by\n        show F.hom_map (\ud835\udfd9 _) = \ud835\udfd9 _ \n        simp\n\n    def fixLeft {C D E} [Category C] [Category D] [Category E]\n      (F : Bi C D E) (X : C) : D \u2964 E where\n      obj_map := \u03bb Y => F \u27e8X, Y\u27e9\n      hom_map := @\u03bb Y\u2081 Y\u2082 g => \n        show F \u27e8X, Y\u2081\u27e9 \u27f6 F \u27e8X, Y\u2082\u27e9 from\n        F.hom_map \u27e8\ud835\udfd9 _, g\u27e9\n      hom_map_comp := \u03bb {Y\u2081 Y\u2082 Y\u2083} g\u2081 g\u2082 => by\n        show F.hom_map (_, _ \u226b _) = F.hom_map _ \u226b F.hom_map _ \n        rw [\u2190hom_map_comp]\n        show F.hom_map (_, _ \u226b _) = F.hom_map ((_ \u226b _), (_ \u226b _))\n        simp\n      hom_map_id := \u03bb Y => by\n        show F.hom_map (\ud835\udfd9 _) = \ud835\udfd9 _ \n        simp\n\n    def fixRight {C D E} [Category C] [Category D] [Category E]\n      (F : Bi C D E) (Y : D) : C \u2964 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 \u2964 D \u2964 E where\n      obj_map := F.fixLeft\n      hom_map {X\u2081 X\u2082} f := {\n        component := \u03bb Y => F.hom_map (f, \ud835\udfd9 Y)\n        naturality := \u03bb {Y\u2081 Y\u2082} g => by\n          show F.hom_map _ \u226b F.hom_map _ = F.hom_map _ \u226b F.hom_map _\n          rw [\u2190hom_map_comp, \u2190hom_map_comp]\n          apply congrArg F.hom_map\n          show (_ \u226b _, _ \u226b _) = (_ \u226b _, _ \u226b _)\n          simp\n      }\n      hom_map_comp {X\u2081 X\u2082 X\u2083} f\u2081 f\u2082 := by\n        apply eq_of_component_eq\n        funext Y\n        show F.hom_map _ = F.hom_map _ \u226b F.hom_map _\n        rw [\u2190hom_map_comp]\n        apply congrArg F.hom_map\n        show _ = (_ \u226b _, _ \u226b _)\n        simp\n      hom_map_id X := by\n        apply eq_of_component_eq\n        funext Y\n        show F.hom_map (\ud835\udfd9 _) = \ud835\udfd9 _ \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 \u2964 E) : Bi C D E where\n      obj_map := \u03bb \u27e8X, _\u27e9 => F X\n      hom_map := \u03bb \u27e8f, _\u27e9 => 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 \u2964 E) : Bi C D E where\n      obj_map := \u03bb \u27e8_, Y\u27e9 => F Y\n      hom_map := \u03bb \u27e8_, f\u27e9 => F.hom_map f\n      hom_map_comp _ _ := by simp\n      hom_map_id _ := by simp\n\n    def pack {C D\u2081 D\u2082} [Category C] [Category D\u2081] [Category D\u2082] \n      (F\u2081 : C \u2964 D\u2081) (F\u2082 : C \u2964 D\u2082) : C \u2964 D\u2081 \u00d7 D\u2082 where\n      obj_map X := \u27e8F\u2081 X, F\u2082 X\u27e9\n      hom_map f := \u27e8F\u2081.hom_map f, F\u2082.hom_map f\u27e9\n      hom_map_comp f g := by simp; rfl\n      hom_map_id X := by simp; rfl\n\n    def prod {C D E\u2081 E\u2082} [Category C] [Category D] [Category E\u2081] [Category E\u2082]\n      (F\u2081 : C \u2964 E\u2081) (F\u2082 : D \u2964 E\u2082) : Bi C D (E\u2081 \u00d7 E\u2082) :=\n      F\u2081.asLHSofBi.pack F\u2082.asRHSofBi\n  end\n\n  section\n    def fixLeft {C D E} [Category C] [Category D] [Category E]\n      (F : C \u2964 D \u2964 E) (X : C) : D \u2964 E := F X\n\n    def fixRight {C D E} [Category C] [Category D] [Category E]\n      (F : C \u2964 D \u2964 E) (Y : D) : C \u2964 E where\n      obj_map := \u03bb X => F X Y\n      hom_map := \u03bb {X\u2081 X\u2082} 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 \u2964 D \u2964 E) : Bi C D E where\n      obj_map := \u03bb \u27e8X, Y\u27e9 => F X Y\n      hom_map := @\u03bb \u27e8X\u2081, Y\u2081\u27e9 \u27e8X\u2082, Y\u2082\u27e9 \u27e8f, g\u27e9 => \n        show F X\u2081 Y\u2081 \u27f6 F X\u2082 Y\u2082 from\n        (F X\u2081).hom_map g \u226b (F.fixRight Y\u2082).hom_map f\n      hom_map_comp := @\u03bb \u27e8X\u2081, Y\u2081\u27e9 \u27e8X\u2082, Y\u2082\u27e9 \u27e8X\u2083, Y\u2083\u27e9 \u27e8f\u2081, g\u2081\u27e9 \u27e8f\u2082, g\u2082\u27e9 => by\n        simp [fixRight]\n        rw [assoc ((F X\u2081).hom_map g\u2081), \u2190assoc ((F X\u2081).hom_map g\u2082)]\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 \u2964 D \u2964 E) : D \u2964 C \u2964 E := F.uncurry.swap.curry\n  end\n\n  section\n    namespace Bi\n    -- define the evaluation bifunctor : X, F \u21a6 F X\n    def evaluation (C D) [Category C] [Category D] : Bi C (C \u2964 D) D :=\n      (\ud835\udfed (C \u2964 D)).uncurry.swap\n\n    --\n    -- def ofLeftAndRightFunctors {C D E} [Category C] [Category D] [Category E]\n    --   (F : C \u2964 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 \u2964 D} (\u03b1 : F \u2245 G) (X : C) \n      : F X \u2245 G X :=\n      ((Bi.evaluation C D).fixLeft X).isom_images_of_isom_objects \u03b1\n\n    -- example {C D} [Category C] [Category D] {F G : C \u2964 D} (h : \u2200 X, F X \u2245 G X) : F \u2245 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 {\u03b1 : Type*}\n\ndef is_prefix (l\u2081 : list \u03b1) (l\u2082 : list \u03b1) : Prop :=\n\u2203 t, l\u2081 ++ t = l\u2082\n\ninfix ` <+: `:50 := is_prefix\n\nsection\nlocal attribute [simp]\ntheorem list.is_prefix_refl (l : list \u03b1) : l <+: l :=\n\u27e8[], by simp\u27e9\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 \u2192 Type v) [Functor f] : Prop where\n  mapConst_eq :\n    \u2200 {\u03b1 \u03b2 : Type u},\n      ((\u00b7 <$ \u00b7) : \u03b1 \u2192 f \u03b2 \u2192 f \u03b1) =\n        (\u00b7 <$> \u00b7) \u2218 const \u03b2 := by\n    intros\n    rfl\n  -- `functor` is indeed a categorical functor\n  id_map : \u2200 {\u03b1 : Type u} (x : f \u03b1), id <$> x = x\n  comp_map : \u2200 {\u03b1 \u03b2 \u03b3 : Type u} (g : \u03b1 \u2192 \u03b2) (h : \u03b2 \u2192 \u03b3) (x : f \u03b1), (h \u2218 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 \u2192 Type v) [Applicative f] extends LawfulFunctor f : Prop where\n  seqLeft_eq :\n    \u2200 {\u03b1 \u03b2 : Type u} (a : f \u03b1) (b : f \u03b2),\n      a <* b = const \u03b2 <$> a <*> b := by\n    intros\n    rfl\n  seqRight_eq :\n    \u2200 {\u03b1 \u03b2 : Type u} (a : f \u03b1) (b : f \u03b2),\n      a *> b = const \u03b1 id <$> a <*> b := by\n    intros\n    rfl\n  -- applicative laws\n  pure_seq : \u2200 {\u03b1 \u03b2 : Type u} (g : \u03b1 \u2192 \u03b2) (x : f \u03b1), pure g <*> x = g <$> x\n  map_pure : \u2200 {\u03b1 \u03b2 : Type u} (g : \u03b1 \u2192 \u03b2) (x : \u03b1), g <$> (pure x : f \u03b1) = pure (g x)\n  seq_pure : \u2200 {\u03b1 \u03b2 : Type u} (g : f (\u03b1 \u2192 \u03b2)) (x : \u03b1), g <*> pure x = (fun g : \u03b1 \u2192 \u03b2 => g x) <$> g\n  seq_assoc :\n    \u2200 {\u03b1 \u03b2 \u03b3 : Type u} (x : f \u03b1) (g : f (\u03b1 \u2192 \u03b2)) (h : f (\u03b2 \u2192 \u03b3)),\n      h <*> (g <*> x) = @comp \u03b1 \u03b2 \u03b3 <$> 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 {\u03b1 : Type.{u1}} {f : Type.{u1} -> Type.{u2}} [_inst_1 : Applicative.{u1, u2} f] [_inst_2 : LawfulApplicative.{u1, u2} f _inst_1] (x : f \u03b1), Eq.{succ u2} (f \u03b1) (Seq.seq.{u1, u2} f (Applicative.toHasSeq.{u1, u2} f _inst_1) \u03b1 \u03b1 (Pure.pure.{u1, u2} f (Applicative.toHasPure.{u1, u2} f _inst_1) (\u03b1 -> \u03b1) (id.{succ u1} \u03b1)) x) x\nbut is expected to have type\n  forall {\u03b1 : Type.{u2} -> Type.{u1}} {f : Type.{u2}} [_inst_1 : Applicative.{u2, u1} \u03b1] [_inst_2 : LawfulApplicative.{u2, u1} \u03b1 _inst_1] (x : \u03b1 f), Eq.{succ u1} (\u03b1 f) (Seq.seq.{u2, u1} \u03b1 (Applicative.toSeq.{u2, u1} \u03b1 _inst_1) f f (Pure.pure.{u2, u1} \u03b1 (Applicative.toPure.{u2, u1} \u03b1 _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\u2093'. -/\n-- applicative \"law\" derivable from other laws\n@[simp]\ntheorem pure_id_seq {\u03b1 : Type u} {f : Type u \u2192 Type v} [Applicative f] [LawfulApplicative f]\n    (x : f \u03b1) : 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 \u2192 Type v) [Monad m] extends LawfulApplicative m : Prop where\n  bind_pure_comp_eq_map :\n    \u2200 {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) (x : m \u03b1),\n      x >>= pure \u2218 f = f <$> x := by\n    intros\n    rfl\n  bind_map_eq_seq :\n    \u2200 {\u03b1 \u03b2 : Type u} (f : m (\u03b1 \u2192 \u03b2)) (x : m \u03b1),\n      f >>= (\u00b7 <$> x) = f <*> x := by\n    intros\n    rfl\n  -- monad laws\n  pure_bind : \u2200 {\u03b1 \u03b2 : Type u} (x : \u03b1) (f : \u03b1 \u2192 m \u03b2), pure x >>= f = f x\n  bind_assoc :\n    \u2200 {\u03b1 \u03b2 \u03b3 : Type u} (x : m \u03b1) (f : \u03b1 \u2192 m \u03b2) (g : \u03b2 \u2192 m \u03b3),\n      x >>= f >>= g = x >>= fun x => f x >>= g\n  pure_seq := (by intros <;> rw [\u2190 bind_map_eq_seq] <;> simp [pure_bind])\n  map_pure := (by intros <;> rw [\u2190 bind_pure_comp_eq_map] <;> simp [pure_bind])\n  seq_pure := (by intros <;> rw [\u2190 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 {\u03b1 : Type.{u1}} {m : Type.{u1} -> Type.{u2}} [_inst_1 : Monad.{u1, u2} m] [_inst_2 : LawfulMonad.{u1, u2} m _inst_1] (x : m \u03b1), Eq.{succ u2} (m \u03b1) (Bind.bind.{u1, u2} m (Monad.toHasBind.{u1, u2} m _inst_1) \u03b1 \u03b1 x (Pure.pure.{u1, u2} m (Applicative.toHasPure.{u1, u2} m (Monad.toApplicative.{u1, u2} m _inst_1)) \u03b1)) x\nbut is expected to have type\n  forall {\u03b1 : Type.{u2} -> Type.{u1}} {m : Type.{u2}} [_inst_1 : Monad.{u2, u1} \u03b1] [_inst_2 : LawfulMonad.{u2, u1} \u03b1 _inst_1] (x : \u03b1 m), Eq.{succ u1} (\u03b1 m) (Bind.bind.{u2, u1} \u03b1 (Monad.toBind.{u2, u1} \u03b1 _inst_1) m m x (Pure.pure.{u2, u1} \u03b1 (Applicative.toPure.{u2, u1} \u03b1 (Monad.toApplicative.{u2, u1} \u03b1 _inst_1)) m)) x\nCase conversion may be inaccurate. Consider using '#align bind_pure bind_pure\u2093'. -/\n-- monad \"law\" derivable from other laws\n@[simp]\ntheorem bind_pure {\u03b1 : Type u} {m : Type u \u2192 Type v} [Monad m] [LawfulMonad m] (x : m \u03b1) :\n    x >>= pure = x :=\n  show x >>= pure \u2218 id = x by rw [bind_pure_comp_eq_map] <;> simp [id_map]\n#align bind_pure bind_pure\n\ntheorem bind_ext_congr {\u03b1 \u03b2} {m : Type u \u2192 Type v} [Bind m] {x : m \u03b1} {f g : \u03b1 \u2192 m \u03b2} :\n    (\u2200 a, f a = g a) \u2192 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 {\u03b1 \u03b2} {m : Type u \u2192 Type v} [Functor m] {x : m \u03b1} {f g : \u03b1 \u2192 \u03b2} :\n    (\u2200 a, f a = g a) \u2192 (f <$> x : m \u03b2) = 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 {\u03b1 \u03b2 : Type}\n\n@[simp]\ntheorem map_eq (x : id \u03b1) (f : \u03b1 \u2192 \u03b2) : f <$> x = f x :=\n  rfl\n#align id.map_eq id.map_eq\n\n@[simp]\ntheorem bind_eq (x : id \u03b1) (f : \u03b1 \u2192 id \u03b2) : x >>= f = f x :=\n  rfl\n#align id.bind_eq id.bind_eq\n\n@[simp]\ntheorem pure_eq (a : \u03b1) : (pure a : id \u03b1) = 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 {\u03c3 : Type u}\n\nvariable {m : Type u \u2192 Type v}\n\nvariable {\u03b1 \u03b2 : Type u}\n\nvariable (x : StateT \u03c3 m \u03b1) (st : \u03c3)\n\ntheorem ext {x x' : StateT \u03c3 m \u03b1} (h : \u2200 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\u2093.ext\n\nvariable [Monad m]\n\n@[simp]\ntheorem run_pure (a) : (pure a : StateT \u03c3 m \u03b1).run st = pure (a, st) :=\n  rfl\n#align state_t.run_pure StateT\u2093.run_pure\n\n@[simp]\ntheorem run_bind (f : \u03b1 \u2192 StateT \u03c3 m \u03b2) :\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\u2093.run_bind\n\n@[simp]\ntheorem run_map (f : \u03b1 \u2192 \u03b2) [LawfulMonad m] :\n    (f <$> x).run st = (fun p : \u03b1 \u00d7 \u03c3 => (f (Prod.fst p), Prod.snd p)) <$> x.run st :=\n  by\n  rw [\u2190 bind_pure_comp_eq_map _ (x.run st)]\n  change (x >>= pure \u2218 f).run st = _\n  simp\n#align state_t.run_map StateT\u2093.run_map\n\n@[simp]\ntheorem run_monadLift {n} [HasMonadLiftT n m] (x : n \u03b1) :\n    (monadLift x : StateT \u03c3 m \u03b1).run st = do\n      let a \u2190 (monadLift x : m \u03b1)\n      pure (a, st) :=\n  rfl\n#align state_t.run_monad_lift StateT\u2093.run_monadLift\n\n@[simp]\ntheorem run_monadMap {m' n n'} [Monad m'] [MonadFunctorT n n' m m'] (f : \u2200 {\u03b1}, n \u03b1 \u2192 n' \u03b1) :\n    (monadMap (@f) x : StateT \u03c3 m' \u03b1).run st = monadMap (@f) (x.run st) :=\n  rfl\n#align state_t.run_monad_map StateT\u2093.run_monadMap\n\n@[simp]\ntheorem run_adapt {\u03c3' \u03c3''} (st : \u03c3) (split : \u03c3 \u2192 \u03c3' \u00d7 \u03c3'') (join : \u03c3' \u2192 \u03c3'' \u2192 \u03c3)\n    (x : StateT \u03c3' m \u03b1) :\n    (StateT.adapt split join x : StateT \u03c3 m \u03b1).run st = do\n      let (st, ctx) := split st\n      let (a, st') \u2190 x.run st\n      pure (a, join st' ctx) :=\n  by delta StateT.adapt <;> rfl\n#align state_t.run_adapt StateT\u2093.run_adapt\n\n@[simp]\ntheorem run_get : (StateT.get : StateT \u03c3 m \u03c3).run st = pure (st, st) :=\n  rfl\n#align state_t.run_get StateT\u2093.run_get\n\n@[simp]\ntheorem run_put (st') : (StateT.put st' : StateT \u03c3 m _).run st = pure (PUnit.unit, st') :=\n  rfl\n#align state_t.run_put StateT\u2093.run_put\n\nend\n\nend StateT\n\ninstance (m : Type u \u2192 Type v) [Monad m] [LawfulMonad m] (\u03c3 : Type u) : LawfulMonad (StateT \u03c3 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 {\u03b1 \u03b2 \u03b5 : Type u} {m : Type u \u2192 Type v} (x : ExceptT \u03b5 m \u03b1)\n\ntheorem ext {x x' : ExceptT \u03b5 m \u03b1} (h : x.run = x'.run) : x = x' := by\n  cases x <;> cases x' <;> simp_all\n#align except_t.ext ExceptT\u2093.ext\n\nvariable [Monad m]\n\n@[simp]\ntheorem run_pure (a) : (pure a : ExceptT \u03b5 m \u03b1).run = pure (@Except.ok \u03b5 \u03b1 a) :=\n  rfl\n#align except_t.run_pure ExceptT\u2093.run_pure\n\n@[simp]\ntheorem run_bind (f : \u03b1 \u2192 ExceptT \u03b5 m \u03b2) : (x >>= f).run = x.run >>= ExceptT.bindCont f :=\n  rfl\n#align except_t.run_bind ExceptT\u2093.run_bind\n\n@[simp]\ntheorem run_map (f : \u03b1 \u2192 \u03b2) [LawfulMonad m] : (f <$> x).run = Except.map f <$> x.run :=\n  by\n  rw [\u2190 bind_pure_comp_eq_map _ x.run]\n  change x.run >>= ExceptT.bindCont (pure \u2218 f) = _\n  apply bind_ext_congr\n  intro a <;> cases a <;> simp [ExceptT.bindCont, Except.map]\n#align except_t.run_map ExceptT\u2093.run_map\n\n@[simp]\ntheorem run_monadLift {n} [HasMonadLiftT n m] (x : n \u03b1) :\n    (monadLift x : ExceptT \u03b5 m \u03b1).run = Except.ok <$> (monadLift x : m \u03b1) :=\n  rfl\n#align except_t.run_monad_lift ExceptT\u2093.run_monadLift\n\n@[simp]\ntheorem run_monadMap {m' n n'} [Monad m'] [MonadFunctorT n n' m m'] (f : \u2200 {\u03b1}, n \u03b1 \u2192 n' \u03b1) :\n    (monadMap (@f) x : ExceptT \u03b5 m' \u03b1).run = monadMap (@f) x.run :=\n  rfl\n#align except_t.run_monad_map ExceptT\u2093.run_monadMap\n\nend ExceptT\n\ninstance (m : Type u \u2192 Type v) [Monad m] [LawfulMonad m] (\u03b5 : Type u) : LawfulMonad (ExceptT \u03b5 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 {\u03c1 : Type u}\n\nvariable {m : Type u \u2192 Type v}\n\nvariable {\u03b1 \u03b2 : Type u}\n\nvariable (x : ReaderT \u03c1 m \u03b1) (r : \u03c1)\n\ntheorem ext {x x' : ReaderT \u03c1 m \u03b1} (h : \u2200 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\u2093.ext\n\nvariable [Monad m]\n\n@[simp]\ntheorem run_pure (a) : (pure a : ReaderT \u03c1 m \u03b1).run r = pure a :=\n  rfl\n#align reader_t.run_pure ReaderT\u2093.run_pure\n\n@[simp]\ntheorem run_bind (f : \u03b1 \u2192 ReaderT \u03c1 m \u03b2) : (x >>= f).run r = x.run r >>= fun a => (f a).run r :=\n  rfl\n#align reader_t.run_bind ReaderT\u2093.run_bind\n\n@[simp]\ntheorem run_map (f : \u03b1 \u2192 \u03b2) [LawfulMonad m] : (f <$> x).run r = f <$> x.run r := by\n  rw [\u2190 bind_pure_comp_eq_map _ (x.run r)] <;> rfl\n#align reader_t.run_map ReaderT\u2093.run_map\n\n@[simp]\ntheorem run_monadLift {n} [HasMonadLiftT n m] (x : n \u03b1) :\n    (monadLift x : ReaderT \u03c1 m \u03b1).run r = (monadLift x : m \u03b1) :=\n  rfl\n#align reader_t.run_monad_lift ReaderT\u2093.run_monadLift\n\n@[simp]\ntheorem run_monadMap {m' n n'} [Monad m'] [MonadFunctorT n n' m m'] (f : \u2200 {\u03b1}, n \u03b1 \u2192 n' \u03b1) :\n    (monadMap (@f) x : ReaderT \u03c1 m' \u03b1).run r = monadMap (@f) (x.run r) :=\n  rfl\n#align reader_t.run_monad_map ReaderT\u2093.run_monadMap\n\n@[simp]\ntheorem run_read : (ReaderT.read : ReaderT \u03c1 m \u03c1).run r = pure r :=\n  rfl\n#align reader_t.run_read ReaderT\u2093.run_read\n\nend\n\nend ReaderT\n\ninstance (\u03c1 : Type u) (m : Type u \u2192 Type v) [Monad m] [LawfulMonad m] : LawfulMonad (ReaderT \u03c1 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 {\u03b1 \u03b2 : Type u} {m : Type u \u2192 Type v} (x : OptionT m \u03b1)\n\ntheorem ext {x x' : OptionT m \u03b1} (h : x.run = x'.run) : x = x' := by\n  cases x <;> cases x' <;> simp_all\n#align option_t.ext OptionT\u2093.ext\n\nvariable [Monad m]\n\n@[simp]\ntheorem run_pure (a) : (pure a : OptionT m \u03b1).run = pure (some a) :=\n  rfl\n#align option_t.run_pure OptionT\u2093.run_pure\n\n@[simp]\ntheorem run_bind (f : \u03b1 \u2192 OptionT m \u03b2) : (x >>= f).run = x.run >>= OptionT.bindCont f :=\n  rfl\n#align option_t.run_bind OptionT\u2093.run_bind\n\n@[simp]\ntheorem run_map (f : \u03b1 \u2192 \u03b2) [LawfulMonad m] : (f <$> x).run = Option.map f <$> x.run :=\n  by\n  rw [\u2190 bind_pure_comp_eq_map _ x.run]\n  change x.run >>= OptionT.bindCont (pure \u2218 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\u2093.run_map\n\n@[simp]\ntheorem run_monadLift {n} [HasMonadLiftT n m] (x : n \u03b1) :\n    (monadLift x : OptionT m \u03b1).run = some <$> (monadLift x : m \u03b1) :=\n  rfl\n#align option_t.run_monad_lift OptionT\u2093.run_monadLift\n\n@[simp]\ntheorem run_monadMap {m' n n'} [Monad m'] [MonadFunctorT n n' m m'] (f : \u2200 {\u03b1}, n \u03b1 \u2192 n' \u03b1) :\n    (monadMap (@f) x : OptionT m' \u03b1).run = monadMap (@f) x.run :=\n  rfl\n#align option_t.run_monad_map OptionT\u2093.run_monadMap\n\nend OptionT\n\ninstance (m : Type u \u2192 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\u2082 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\u2082} K]\n\n@[simp, reassoc]\nlemma limit.lift_\u03c0_app (H : J \u2964 K \u2964 C) [has_limit H] (c : cone H) (j : J) (k : K) :\n  (limit.lift H c).app k \u226b (limit.\u03c0 H j).app k = (c.\u03c0.app j).app k :=\ncongr_app (limit.lift_\u03c0 c j) k\n\n@[simp, reassoc]\nlemma colimit.\u03b9_desc_app (H : J \u2964 K \u2964 C) [has_colimit H] (c : cocone H) (j : J) (k : K) :\n  (colimit.\u03b9 H j).app k \u226b (colimit.desc H c).app k = (c.\u03b9.app j).app k :=\ncongr_app (colimit.\u03b9_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 \u2964 K \u2964 C} (c : cone F)\n  (t : \u03a0 (k : K), is_limit (((evaluation K C).obj k).map_cone c)) : is_limit c :=\n{ lift := \u03bb s,\n  { app := \u03bb k, (t k).lift \u27e8s.X.obj k, whisker_right s.\u03c0 ((evaluation K C).obj k)\u27e9,\n    naturality' := \u03bb X Y f, (t Y).hom_ext $ \u03bb j,\n    begin\n      rw [assoc, (t Y).fac _ j],\n      simpa using\n        ((t X).fac_assoc \u27e8s.X.obj X, whisker_right s.\u03c0 ((evaluation K C).obj X)\u27e9 j _).symm,\n    end },\n  fac' := \u03bb s j, nat_trans.ext _ _ $ funext $ \u03bb k, (t k).fac _ j,\n  uniq' := \u03bb s m w, nat_trans.ext _ _ $ funext $ \u03bb x, (t x).hom_ext $ \u03bb j,\n      (congr_app (w j) x).trans\n        ((t x).fac \u27e8s.X.obj _, whisker_right s.\u03c0 ((evaluation K C).obj _)\u27e9 j).symm }\n\n/--\nGiven a functor `F` and a collection of limit cones for each diagram `X \u21a6 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 \u2964 K \u2964 C) (c : \u03a0 (k : K), limit_cone (F.flip.obj k)) :\n  cone F :=\n{ X :=\n  { obj := \u03bb k, (c k).cone.X,\n    map := \u03bb k\u2081 k\u2082 f, (c k\u2082).is_limit.lift \u27e8_, (c k\u2081).cone.\u03c0 \u226b F.flip.map f\u27e9,\n    map_id' := \u03bb k, (c k).is_limit.hom_ext (\u03bb j, by { dsimp, simp }),\n    map_comp' := \u03bb k\u2081 k\u2082 k\u2083 f\u2081 f\u2082, (c k\u2083).is_limit.hom_ext (\u03bb j, by simp) },\n  \u03c0 :=\n  { app := \u03bb j, { app := \u03bb k, (c k).cone.\u03c0.app j },\n    naturality' := \u03bb j\u2081 j\u2082 g, nat_trans.ext _ _ $ funext $ \u03bb k, (c k).cone.\u03c0.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 \u2964 K \u2964 C) (c : \u03a0 (k : K), limit_cone (F.flip.obj k)) (k : K) :\n  ((evaluation K C).obj k).map_cone (combine_cones F c) \u2245 (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 \u2964 K \u2964 C) (c : \u03a0 (k : K), limit_cone (F.flip.obj k)) :\n  is_limit (combine_cones F c) :=\nevaluation_jointly_reflects_limits _\n  (\u03bb 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 \u2964 K \u2964 C} (c : cocone F)\n  (t : \u03a0 (k : K), is_colimit (((evaluation K C).obj k).map_cocone c)) : is_colimit c :=\n{ desc := \u03bb s,\n  { app := \u03bb k, (t k).desc \u27e8s.X.obj k, whisker_right s.\u03b9 ((evaluation K C).obj k)\u27e9,\n    naturality' := \u03bb X Y f, (t X).hom_ext $ \u03bb j,\n    begin\n      rw [(t X).fac_assoc _ j],\n      erw \u2190 (c.\u03b9.app j).naturality_assoc f,\n      erw (t Y).fac \u27e8s.X.obj _, whisker_right s.\u03b9 _\u27e9 j,\n      dsimp,\n      simp,\n    end },\n  fac' := \u03bb s j, nat_trans.ext _ _ $ funext $ \u03bb k, (t k).fac _ j,\n  uniq' := \u03bb s m w, nat_trans.ext _ _ $ funext $ \u03bb x, (t x).hom_ext $ \u03bb j,\n      (congr_app (w j) x).trans\n        ((t x).fac \u27e8s.X.obj _, whisker_right s.\u03b9 ((evaluation K C).obj _)\u27e9 j).symm }\n\n/--\nGiven a functor `F` and a collection of colimit cocones for each diagram `X \u21a6 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 \u2964 K \u2964 C) (c : \u03a0 (k : K), colimit_cocone (F.flip.obj k)) :\n  cocone F :=\n{ X :=\n  { obj := \u03bb k, (c k).cocone.X,\n    map := \u03bb k\u2081 k\u2082 f, (c k\u2081).is_colimit.desc \u27e8_, F.flip.map f \u226b (c k\u2082).cocone.\u03b9\u27e9,\n    map_id' := \u03bb k, (c k).is_colimit.hom_ext (\u03bb j, by { dsimp, simp }),\n    map_comp' := \u03bb k\u2081 k\u2082 k\u2083 f\u2081 f\u2082, (c k\u2081).is_colimit.hom_ext (\u03bb j, by simp) },\n  \u03b9 :=\n  { app := \u03bb j, { app := \u03bb k, (c k).cocone.\u03b9.app j },\n    naturality' := \u03bb j\u2081 j\u2082 g, nat_trans.ext _ _ $ funext $ \u03bb k, (c k).cocone.\u03b9.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 \u2964 K \u2964 C) (c : \u03a0 (k : K), colimit_cocone (F.flip.obj k)) (k : K) :\n  ((evaluation K C).obj k).map_cocone (combine_cocones F c) \u2245 (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 \u2964 K \u2964 C) (c : \u03a0 (k : K), colimit_cocone (F.flip.obj k)) :\n  is_colimit (combine_cocones F c) :=\nevaluation_jointly_reflects_colimits _\n  (\u03bb 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 \u2964 C) :=\n{ has_limit := \u03bb F, has_limit.mk\n  { cone := combine_cones F (\u03bb 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 \u2964 C) :=\n{ has_colimit := \u03bb F, has_colimit.mk\n  { cocone := combine_cocones _ (\u03bb k, get_colimit_cocone _),\n    is_colimit := combined_is_colimit _ _ } }\n\ninstance functor_category_has_limits [has_limits C] : has_limits (K \u2964 C) := {}\n\ninstance functor_category_has_colimits [has_colimits C] : has_colimits (K \u2964 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  \u03bb 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 \u2964 K \u2964 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 \u2964 K \u2964 C) (k : K) :\n  (limit F).obj k \u2245 limit (F \u22d9 ((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_\u03c0\n  [has_limits_of_shape J C] (F : J \u2964 (K \u2964 C)) (j : J) (k : K) :\n  (limit_obj_iso_limit_comp_evaluation F k).hom \u226b limit.\u03c0 (F \u22d9 ((evaluation K C).obj k)) j =\n    (limit.\u03c0 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_\u03c0_app\n  [has_limits_of_shape J C] (F : J \u2964 (K \u2964 C)) (j : J) (k : K):\n  (limit_obj_iso_limit_comp_evaluation F k).inv \u226b (limit.\u03c0 F j).app k =\n    limit.\u03c0 (F \u22d9 ((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 \u2964 K \u2964 C} [has_limits_of_shape J C]\n  {k : K} {W : C} {f g : W \u27f6 (limit H).obj k}\n  (w : \u2200 j, f \u226b (limits.limit.\u03c0 H j).app k = g \u226b (limits.limit.\u03c0 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  \u03bb 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 \u2964 K \u2964 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 \u2964 K \u2964 C) (k : K) :\n  (colimit F).obj k \u2245 colimit (F \u22d9 ((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_\u03b9_inv\n  [has_colimits_of_shape J C] (F : J \u2964 (K \u2964 C)) (j : J) (k : K) :\n  colimit.\u03b9 (F \u22d9 ((evaluation K C).obj k)) j \u226b (colimit_obj_iso_colimit_comp_evaluation F k).inv =\n    (colimit.\u03b9 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_\u03b9_app_hom\n  [has_colimits_of_shape J C] (F : J \u2964 (K \u2964 C)) (j : J) (k : K) :\n  (colimit.\u03b9 F j).app k \u226b (colimit_obj_iso_colimit_comp_evaluation F k).hom =\n     colimit.\u03b9 (F \u22d9 ((evaluation K C).obj k)) j :=\nbegin\n  dsimp [colimit_obj_iso_colimit_comp_evaluation],\n  rw \u2190iso.eq_comp_inv,\n  simp,\nend\n\n@[ext]\nlemma colimit_obj_ext {H : J \u2964 K \u2964 C} [has_colimits_of_shape J C]\n  {k : K} {W : C} {f g : (colimit H).obj k \u27f6 W}\n  (w : \u2200 j, (colimit.\u03b9 H j).app k \u226b f = (colimit.\u03b9 H j).app k \u226b 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 := \u03bb J \ud835\udca5, 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 := \u03bb J \ud835\udca5, 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 `\u22a4`.\n* `bot_hom`: Maps which preserve `\u22a5`.\n* `bounded_order_hom`: Bounded order homomorphisms. Monotone maps which preserve `\u22a4` and `\u22a5`.\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 \u03b1 \u03b2 \u03b3 \u03b4 : Type*}\n\n/-- The type of `\u22a4`-preserving functions from `\u03b1` to `\u03b2`. -/\nstructure top_hom (\u03b1 \u03b2 : Type*) [has_top \u03b1] [has_top \u03b2] :=\n(to_fun   : \u03b1 \u2192 \u03b2)\n(map_top' : to_fun \u22a4 = \u22a4)\n\n/-- The type of `\u22a5`-preserving functions from `\u03b1` to `\u03b2`. -/\nstructure bot_hom (\u03b1 \u03b2 : Type*) [has_bot \u03b1] [has_bot \u03b2] :=\n(to_fun   : \u03b1 \u2192 \u03b2)\n(map_bot' : to_fun \u22a5 = \u22a5)\n\n/-- The type of bounded order homomorphisms from `\u03b1` to `\u03b2`. -/\nstructure bounded_order_hom (\u03b1 \u03b2 : Type*) [preorder \u03b1] [preorder \u03b2] [bounded_order \u03b1]\n  [bounded_order \u03b2]\n  extends order_hom \u03b1 \u03b2 :=\n(map_top' : to_fun \u22a4 = \u22a4)\n(map_bot' : to_fun \u22a5 = \u22a5)\n\nsection\nset_option old_structure_cmd true\n\n/-- `top_hom_class F \u03b1 \u03b2` states that `F` is a type of `\u22a4`-preserving morphisms.\n\nYou should extend this class when you extend `top_hom`. -/\nclass top_hom_class (F : Type*) (\u03b1 \u03b2 : out_param $ Type*) [has_top \u03b1] [has_top \u03b2]\n  extends fun_like F \u03b1 (\u03bb _, \u03b2) :=\n(map_top (f : F) : f \u22a4 = \u22a4)\n\n/-- `bot_hom_class F \u03b1 \u03b2` states that `F` is a type of `\u22a5`-preserving morphisms.\n\nYou should extend this class when you extend `bot_hom`. -/\nclass bot_hom_class (F : Type*) (\u03b1 \u03b2 : out_param $ Type*) [has_bot \u03b1] [has_bot \u03b2]\n  extends fun_like F \u03b1 (\u03bb _, \u03b2) :=\n(map_bot (f : F) : f \u22a5 = \u22a5)\n\n/-- `bounded_order_hom_class F \u03b1 \u03b2` 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*) (\u03b1 \u03b2 : out_param $ Type*) [has_le \u03b1] [has_le \u03b2]\n  [bounded_order \u03b1] [bounded_order \u03b2]\n  extends rel_hom_class F ((\u2264) : \u03b1 \u2192 \u03b1 \u2192 Prop) ((\u2264) : \u03b2 \u2192 \u03b2 \u2192 Prop) :=\n(map_top (f : F) : f \u22a4 = \u22a4)\n(map_bot (f : F) : f \u22a5 = \u22a5)\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 \u03b1] [has_le \u03b2]\n  [bounded_order \u03b1] [bounded_order \u03b2] [bounded_order_hom_class F \u03b1 \u03b2] :\n  top_hom_class F \u03b1 \u03b2 :=\n{ .. \u2039bounded_order_hom_class F \u03b1 \u03b2\u203a }\n\n@[priority 100] -- See note [lower instance priority]\ninstance bounded_order_hom_class.to_bot_hom_class [has_le \u03b1] [has_le \u03b2]\n  [bounded_order \u03b1] [bounded_order \u03b2] [bounded_order_hom_class F \u03b1 \u03b2] :\n  bot_hom_class F \u03b1 \u03b2 :=\n{ .. \u2039bounded_order_hom_class F \u03b1 \u03b2\u203a }\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_top_hom_class [has_le \u03b1] [order_top \u03b1] [partial_order \u03b2] [order_top \u03b2]\n  [order_iso_class F \u03b1 \u03b2] :\n  top_hom_class F \u03b1 \u03b2 :=\n{ map_top := \u03bb f, top_le_iff.1 $ (map_inv_le_iff f).1 le_top,\n  .. show order_hom_class F \u03b1 \u03b2, from infer_instance }\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_bot_hom_class [has_le \u03b1] [order_bot \u03b1] [partial_order \u03b2] [order_bot \u03b2]\n  [order_iso_class F \u03b1 \u03b2] :\n  bot_hom_class F \u03b1 \u03b2 :=\n--\u27e8\u03bb f, le_bot_iff.1 $ (le_map_inv_iff f).1 bot_le\u27e9\n{ map_bot := \u03bb f, le_bot_iff.1 $ (le_map_inv_iff f).1 bot_le,\n  .. show order_hom_class F \u03b1 \u03b2, from infer_instance }\n\n@[priority 100] -- See note [lower instance priority]\ninstance order_iso_class.to_bounded_order_hom_class [has_le \u03b1] [bounded_order \u03b1] [partial_order \u03b2]\n  [bounded_order \u03b2] [order_iso_class F \u03b1 \u03b2] :\n  bounded_order_hom_class F \u03b1 \u03b2 :=\n{ ..show order_hom_class F \u03b1 \u03b2, 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 \u03b1] [order_top \u03b1] [partial_order \u03b2] [order_top \u03b2]\n  [order_iso_class F \u03b1 \u03b2] (f : F) {a : \u03b1} : f a = \u22a4 \u2194 a = \u22a4 :=\nby rw [\u2190map_top f, (equiv_like.injective f).eq_iff]\n\n@[simp] lemma map_eq_bot_iff [has_le \u03b1] [order_bot \u03b1] [partial_order \u03b2] [order_bot \u03b2]\n  [order_iso_class F \u03b1 \u03b2] (f : F) {a : \u03b1} : f a = \u22a5 \u2194 a = \u22a5 :=\nby rw [\u2190map_bot f, (equiv_like.injective f).eq_iff]\n\ninstance [has_top \u03b1] [has_top \u03b2] [top_hom_class F \u03b1 \u03b2] : has_coe_t F (top_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f, \u27e8f, map_top f\u27e9\u27e9\n\ninstance [has_bot \u03b1] [has_bot \u03b2] [bot_hom_class F \u03b1 \u03b2] : has_coe_t F (bot_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f, \u27e8f, map_bot f\u27e9\u27e9\n\ninstance [preorder \u03b1] [preorder \u03b2] [bounded_order \u03b1] [bounded_order \u03b2]\n  [bounded_order_hom_class F \u03b1 \u03b2] : has_coe_t F (bounded_order_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f, { to_fun := f, map_top' := map_top f, map_bot' := map_bot f, ..(f : \u03b1 \u2192o \u03b2) }\u27e9\n\n/-! ### Top homomorphisms -/\n\nnamespace top_hom\nvariables [has_top \u03b1]\n\nsection has_top\nvariables [has_top \u03b2] [has_top \u03b3] [has_top \u03b4]\n\ninstance : top_hom_class (top_hom \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := top_hom.to_fun,\n  coe_injective' := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : top_hom \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n-- this must come after the coe_to_fun definition\ninitialize_simps_projections top_hom (to_fun \u2192 apply)\n\n@[ext] lemma ext {f g : top_hom \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : top_hom \u03b1 \u03b2 :=\n{ to_fun := f',\n  map_top' := h.symm \u25b8 f.map_top' }\n\n@[simp] lemma coe_copy (f : top_hom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(f.copy f' h) = f' := rfl\nlemma copy_eq (f : top_hom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : f.copy f' h = f := fun_like.ext' h\n\ninstance : inhabited (top_hom \u03b1 \u03b2) := \u27e8\u27e8\u03bb _, \u22a4, rfl\u27e9\u27e9\n\nvariables (\u03b1)\n\n/-- `id` as a `top_hom`. -/\nprotected def id : top_hom \u03b1 \u03b1 := \u27e8id, rfl\u27e9\n\n@[simp] lemma coe_id : \u21d1(top_hom.id \u03b1) = id := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : top_hom.id \u03b1 a = a := rfl\n\n/-- Composition of `top_hom`s as a `top_hom`. -/\ndef comp (f : top_hom \u03b2 \u03b3) (g : top_hom \u03b1 \u03b2) : top_hom \u03b1 \u03b3 :=\n{ to_fun := f \u2218 g,\n  map_top' := by rw [comp_apply, map_top, map_top] }\n\n@[simp] lemma coe_comp (f : top_hom \u03b2 \u03b3) (g : top_hom \u03b1 \u03b2) : (f.comp g : \u03b1 \u2192 \u03b3) = f \u2218 g := rfl\n@[simp] lemma comp_apply (f : top_hom \u03b2 \u03b3) (g : top_hom \u03b1 \u03b2) (a : \u03b1) :\n  (f.comp g) a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : top_hom \u03b3 \u03b4) (g : top_hom \u03b2 \u03b3) (h : top_hom \u03b1 \u03b2) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : top_hom \u03b1 \u03b2) : f.comp (top_hom.id \u03b1) = f := top_hom.ext $ \u03bb a, rfl\n@[simp] lemma id_comp (f : top_hom \u03b1 \u03b2) : (top_hom.id \u03b2).comp f = f := top_hom.ext $ \u03bb a, rfl\n\nlemma cancel_right {g\u2081 g\u2082 : top_hom \u03b2 \u03b3} {f : top_hom \u03b1 \u03b2} (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, top_hom.ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : top_hom \u03b2 \u03b3} {f\u2081 f\u2082 : top_hom \u03b1 \u03b2} (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, top_hom.ext $ \u03bb a, hg $\n  by rw [\u2190top_hom.comp_apply, h, top_hom.comp_apply], congr_arg _\u27e9\n\nend has_top\n\ninstance [preorder \u03b2] [has_top \u03b2] : preorder (top_hom \u03b1 \u03b2) :=\npreorder.lift (coe_fn : top_hom \u03b1 \u03b2 \u2192 \u03b1 \u2192 \u03b2)\n\ninstance [partial_order \u03b2] [has_top \u03b2] : partial_order (top_hom \u03b1 \u03b2) :=\npartial_order.lift _ fun_like.coe_injective\n\nsection order_top\nvariables [preorder \u03b2] [order_top \u03b2]\n\ninstance : order_top (top_hom \u03b1 \u03b2) := \u27e8\u27e8\u22a4, rfl\u27e9, \u03bb _, le_top\u27e9\n\n@[simp] lemma coe_top : \u21d1(\u22a4 : top_hom \u03b1 \u03b2) = \u22a4 := rfl\n@[simp] lemma top_apply (a : \u03b1) : (\u22a4 : top_hom \u03b1 \u03b2) a = \u22a4 := rfl\n\nend order_top\n\nsection semilattice_inf\nvariables [semilattice_inf \u03b2] [order_top \u03b2] (f g : top_hom \u03b1 \u03b2)\n\ninstance : has_inf (top_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f g, \u27e8f \u2293 g, by rw [pi.inf_apply, map_top, map_top, inf_top_eq]\u27e9\u27e9\n\ninstance : semilattice_inf (top_hom \u03b1 \u03b2) := fun_like.coe_injective.semilattice_inf _ $ \u03bb _ _, rfl\n\n@[simp] lemma coe_inf : \u21d1(f \u2293 g) = f \u2293 g := rfl\n@[simp] lemma inf_apply (a : \u03b1) : (f \u2293 g) a = f a \u2293 g a := rfl\n\nend semilattice_inf\n\nsection semilattice_sup\nvariables [semilattice_sup \u03b2] [order_top \u03b2] (f g : top_hom \u03b1 \u03b2)\n\ninstance : has_sup (top_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f g, \u27e8f \u2294 g, by rw [pi.sup_apply, map_top, map_top, sup_top_eq]\u27e9\u27e9\n\ninstance : semilattice_sup (top_hom \u03b1 \u03b2) := fun_like.coe_injective.semilattice_sup _ $ \u03bb _ _, rfl\n\n@[simp] lemma coe_sup : \u21d1(f \u2294 g) = f \u2294 g := rfl\n@[simp] lemma sup_apply (a : \u03b1) : (f \u2294 g) a = f a \u2294 g a := rfl\n\nend semilattice_sup\n\ninstance [lattice \u03b2] [order_top \u03b2] : lattice (top_hom \u03b1 \u03b2) :=\nfun_like.coe_injective.lattice _ (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [distrib_lattice \u03b2] [order_top \u03b2] : distrib_lattice (top_hom \u03b1 \u03b2) :=\nfun_like.coe_injective.distrib_lattice _ (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\nend top_hom\n\n/-! ### Bot homomorphisms -/\n\nnamespace bot_hom\nvariables [has_bot \u03b1]\n\nsection has_bot\nvariables [has_bot \u03b2] [has_bot \u03b3] [has_bot \u03b4]\n\ninstance : bot_hom_class (bot_hom \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := bot_hom.to_fun,\n  coe_injective' := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : bot_hom \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n-- this must come after the coe_to_fun definition\ninitialize_simps_projections bot_hom (to_fun \u2192 apply)\n\n@[ext] lemma ext {f g : bot_hom \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : bot_hom \u03b1 \u03b2 :=\n{ to_fun := f',\n  map_bot' := h.symm \u25b8 f.map_bot' }\n\n@[simp] lemma coe_copy (f : bot_hom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : \u21d1(f.copy f' h) = f' := rfl\nlemma copy_eq (f : bot_hom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : f.copy f' h = f := fun_like.ext' h\n\ninstance : inhabited (bot_hom \u03b1 \u03b2) := \u27e8\u27e8\u03bb _, \u22a5, rfl\u27e9\u27e9\n\nvariables (\u03b1)\n\n/-- `id` as a `bot_hom`. -/\nprotected def id : bot_hom \u03b1 \u03b1 := \u27e8id, rfl\u27e9\n\n@[simp] lemma coe_id : \u21d1(bot_hom.id \u03b1) = id := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : bot_hom.id \u03b1 a = a := rfl\n\n/-- Composition of `bot_hom`s as a `bot_hom`. -/\ndef comp (f : bot_hom \u03b2 \u03b3) (g : bot_hom \u03b1 \u03b2) : bot_hom \u03b1 \u03b3 :=\n{ to_fun := f \u2218 g,\n  map_bot' := by rw [comp_apply, map_bot, map_bot] }\n\n@[simp] lemma coe_comp (f : bot_hom \u03b2 \u03b3) (g : bot_hom \u03b1 \u03b2) : (f.comp g : \u03b1 \u2192 \u03b3) = f \u2218 g := rfl\n@[simp] lemma comp_apply (f : bot_hom \u03b2 \u03b3) (g : bot_hom \u03b1 \u03b2) (a : \u03b1) :\n  (f.comp g) a = f (g a) := rfl\n@[simp] lemma comp_assoc (f : bot_hom \u03b3 \u03b4) (g : bot_hom \u03b2 \u03b3) (h : bot_hom \u03b1 \u03b2) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : bot_hom \u03b1 \u03b2) : f.comp (bot_hom.id \u03b1) = f := bot_hom.ext $ \u03bb a, rfl\n@[simp] lemma id_comp (f : bot_hom \u03b1 \u03b2) : (bot_hom.id \u03b2).comp f = f := bot_hom.ext $ \u03bb a, rfl\n\nlemma cancel_right {g\u2081 g\u2082 : bot_hom \u03b2 \u03b3} {f : bot_hom \u03b1 \u03b2} (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, bot_hom.ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : bot_hom \u03b2 \u03b3} {f\u2081 f\u2082 : bot_hom \u03b1 \u03b2} (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, bot_hom.ext $ \u03bb a, hg $\n  by rw [\u2190bot_hom.comp_apply, h, bot_hom.comp_apply], congr_arg _\u27e9\n\nend has_bot\n\ninstance [preorder \u03b2] [has_bot \u03b2] : preorder (bot_hom \u03b1 \u03b2) :=\npreorder.lift (coe_fn : bot_hom \u03b1 \u03b2 \u2192 \u03b1 \u2192 \u03b2)\n\ninstance [partial_order \u03b2] [has_bot \u03b2] : partial_order (bot_hom \u03b1 \u03b2) :=\npartial_order.lift _ fun_like.coe_injective\n\nsection order_bot\nvariables [preorder \u03b2] [order_bot \u03b2]\n\ninstance : order_bot (bot_hom \u03b1 \u03b2) := \u27e8\u27e8\u22a5, rfl\u27e9, \u03bb _, bot_le\u27e9\n\n@[simp] lemma coe_bot : \u21d1(\u22a5 : bot_hom \u03b1 \u03b2) = \u22a5 := rfl\n@[simp] lemma bot_apply (a : \u03b1) : (\u22a5 : bot_hom \u03b1 \u03b2) a = \u22a5 := rfl\n\nend order_bot\n\nsection semilattice_inf\nvariables [semilattice_inf \u03b2] [order_bot \u03b2] (f g : bot_hom \u03b1 \u03b2)\n\ninstance : has_inf (bot_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f g, \u27e8f \u2293 g, by rw [pi.inf_apply, map_bot, map_bot, inf_bot_eq]\u27e9\u27e9\n\ninstance : semilattice_inf (bot_hom \u03b1 \u03b2) := fun_like.coe_injective.semilattice_inf _ $ \u03bb _ _, rfl\n\n@[simp] lemma coe_inf : \u21d1(f \u2293 g) = f \u2293 g := rfl\n@[simp] lemma inf_apply (a : \u03b1) : (f \u2293 g) a = f a \u2293 g a := rfl\n\nend semilattice_inf\n\nsection semilattice_sup\nvariables [semilattice_sup \u03b2] [order_bot \u03b2] (f g : bot_hom \u03b1 \u03b2)\n\ninstance : has_sup (bot_hom \u03b1 \u03b2) :=\n\u27e8\u03bb f g, \u27e8f \u2294 g, by rw [pi.sup_apply, map_bot, map_bot, sup_bot_eq]\u27e9\u27e9\n\ninstance : semilattice_sup (bot_hom \u03b1 \u03b2) := fun_like.coe_injective.semilattice_sup _ $ \u03bb _ _, rfl\n\n@[simp] lemma coe_sup : \u21d1(f \u2294 g) = f \u2294 g := rfl\n@[simp] lemma sup_apply (a : \u03b1) : (f \u2294 g) a = f a \u2294 g a := rfl\n\nend semilattice_sup\n\ninstance [lattice \u03b2] [order_bot \u03b2] : lattice (bot_hom \u03b1 \u03b2) :=\nfun_like.coe_injective.lattice _ (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\ninstance [distrib_lattice \u03b2] [order_bot \u03b2] : distrib_lattice (bot_hom \u03b1 \u03b2) :=\nfun_like.coe_injective.distrib_lattice _ (\u03bb _ _, rfl) (\u03bb _ _, rfl)\n\nend bot_hom\n\n/-! ### Bounded order homomorphisms -/\n\nnamespace bounded_order_hom\nvariables [preorder \u03b1] [preorder \u03b2] [preorder \u03b3] [preorder \u03b4] [bounded_order \u03b1] [bounded_order \u03b2]\n  [bounded_order \u03b3] [bounded_order \u03b4]\n\n/-- Reinterpret a `bounded_order_hom` as a `top_hom`. -/\ndef to_top_hom (f : bounded_order_hom \u03b1 \u03b2) : top_hom \u03b1 \u03b2 := { ..f }\n\n/-- Reinterpret a `bounded_order_hom` as a `bot_hom`. -/\ndef to_bot_hom (f : bounded_order_hom \u03b1 \u03b2) : bot_hom \u03b1 \u03b2 := { ..f }\n\ninstance : bounded_order_hom_class (bounded_order_hom \u03b1 \u03b2) \u03b1 \u03b2 :=\n{ coe := \u03bb f, f.to_fun,\n  coe_injective' := \u03bb f g h, by obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := f; obtain \u27e8\u27e8_, _\u27e9, _\u27e9 := g; congr',\n  map_rel := \u03bb f, f.monotone',\n  map_top := \u03bb f, f.map_top',\n  map_bot := \u03bb 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 \u03b1 \u03b2) (\u03bb _, \u03b1 \u2192 \u03b2) := fun_like.has_coe_to_fun\n\n@[simp] lemma to_fun_eq_coe {f : bounded_order_hom \u03b1 \u03b2} : f.to_fun = (f : \u03b1 \u2192 \u03b2) := rfl\n\n@[ext] lemma ext {f g : bounded_order_hom \u03b1 \u03b2} (h : \u2200 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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : bounded_order_hom \u03b1 \u03b2 :=\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 \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) :\n  \u21d1(f.copy f' h) = f' :=\nrfl\n\nlemma copy_eq (f : bounded_order_hom \u03b1 \u03b2) (f' : \u03b1 \u2192 \u03b2) (h : f' = f) : f.copy f' h = f :=\nfun_like.ext' h\n\nvariables (\u03b1)\n\n/-- `id` as a `bounded_order_hom`. -/\nprotected def id : bounded_order_hom \u03b1 \u03b1 := { ..order_hom.id, ..top_hom.id \u03b1, ..bot_hom.id \u03b1 }\n\ninstance : inhabited (bounded_order_hom \u03b1 \u03b1) := \u27e8bounded_order_hom.id \u03b1\u27e9\n\n@[simp] lemma coe_id : \u21d1(bounded_order_hom.id \u03b1) = id := rfl\n\nvariables {\u03b1}\n\n@[simp] lemma id_apply (a : \u03b1) : bounded_order_hom.id \u03b1 a = a := rfl\n\n/-- Composition of `bounded_order_hom`s as a `bounded_order_hom`. -/\ndef comp (f : bounded_order_hom \u03b2 \u03b3) (g : bounded_order_hom \u03b1 \u03b2) : bounded_order_hom \u03b1 \u03b3 :=\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 \u03b2 \u03b3) (g : bounded_order_hom \u03b1 \u03b2) :\n  (f.comp g : \u03b1 \u2192 \u03b3) = f \u2218 g := rfl\n@[simp] lemma comp_apply (f : bounded_order_hom \u03b2 \u03b3) (g : bounded_order_hom \u03b1 \u03b2) (a : \u03b1) :\n  (f.comp g) a = f (g a) := rfl\n@[simp] lemma coe_comp_order_hom (f : bounded_order_hom \u03b2 \u03b3) (g : bounded_order_hom \u03b1 \u03b2) :\n  (f.comp g : order_hom \u03b1 \u03b3) = (f : order_hom \u03b2 \u03b3).comp g := rfl\n@[simp] lemma coe_comp_top_hom (f : bounded_order_hom \u03b2 \u03b3) (g : bounded_order_hom \u03b1 \u03b2) :\n  (f.comp g : top_hom \u03b1 \u03b3) = (f : top_hom \u03b2 \u03b3).comp g := rfl\n@[simp] lemma coe_comp_bot_hom (f : bounded_order_hom \u03b2 \u03b3) (g : bounded_order_hom \u03b1 \u03b2) :\n  (f.comp g : bot_hom \u03b1 \u03b3) = (f : bot_hom \u03b2 \u03b3).comp g := rfl\n@[simp] lemma comp_assoc (f : bounded_order_hom \u03b3 \u03b4) (g : bounded_order_hom \u03b2 \u03b3)\n  (h : bounded_order_hom \u03b1 \u03b2) :\n  (f.comp g).comp h = f.comp (g.comp h) := rfl\n@[simp] lemma comp_id (f : bounded_order_hom \u03b1 \u03b2) : f.comp (bounded_order_hom.id \u03b1) = f :=\nbounded_order_hom.ext $ \u03bb a, rfl\n@[simp] lemma id_comp (f : bounded_order_hom \u03b1 \u03b2) : (bounded_order_hom.id \u03b2).comp f = f :=\nbounded_order_hom.ext $ \u03bb a, rfl\n\nlemma cancel_right {g\u2081 g\u2082 : bounded_order_hom \u03b2 \u03b3} {f : bounded_order_hom \u03b1 \u03b2} (hf : surjective f) :\n  g\u2081.comp f = g\u2082.comp f \u2194 g\u2081 = g\u2082 :=\n\u27e8\u03bb h, bounded_order_hom.ext $ hf.forall.2 $ fun_like.ext_iff.1 h, congr_arg _\u27e9\n\nlemma cancel_left {g : bounded_order_hom \u03b2 \u03b3} {f\u2081 f\u2082 : bounded_order_hom \u03b1 \u03b2} (hg : injective g) :\n  g.comp f\u2081 = g.comp f\u2082 \u2194 f\u2081 = f\u2082 :=\n\u27e8\u03bb h, bounded_order_hom.ext $ \u03bb a, hg $\n  by rw [\u2190bounded_order_hom.comp_apply, h, bounded_order_hom.comp_apply], congr_arg _\u27e9\n\nend bounded_order_hom\n\n/-! ### Dual homs -/\n\nnamespace top_hom\nvariables [has_le \u03b1] [order_top \u03b1] [has_le \u03b2] [order_top \u03b2] [has_le \u03b3] [order_top \u03b3]\n\n/-- Reinterpret a top homomorphism as a bot homomorphism between the dual lattices. -/\n@[simps] protected def dual : top_hom \u03b1 \u03b2 \u2243 bot_hom \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 :=\n{ to_fun := \u03bb f, \u27e8f, f.map_top'\u27e9,\n  inv_fun := \u03bb f, \u27e8f, f.map_bot'\u27e9,\n  left_inv := \u03bb f, top_hom.ext $ \u03bb _, rfl,\n  right_inv := \u03bb f, bot_hom.ext $ \u03bb _, rfl }\n\n@[simp] lemma dual_id : (top_hom.id \u03b1).dual = bot_hom.id _ := rfl\n@[simp] lemma dual_comp (g : top_hom \u03b2 \u03b3) (f : top_hom \u03b1 \u03b2) :\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 \u03b1 := rfl\n@[simp] lemma symm_dual_comp (g : bot_hom \u03b2\u1d52\u1d48 \u03b3\u1d52\u1d48) (f : bot_hom \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48) :\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 \u03b1] [order_bot \u03b1] [has_le \u03b2] [order_bot \u03b2] [has_le \u03b3] [order_bot \u03b3]\n\n/-- Reinterpret a bot homomorphism as a top homomorphism between the dual lattices. -/\n@[simps] protected def dual : bot_hom \u03b1 \u03b2 \u2243 top_hom \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 :=\n{ to_fun := \u03bb f, \u27e8f, f.map_bot'\u27e9,\n  inv_fun := \u03bb f, \u27e8f, f.map_top'\u27e9,\n  left_inv := \u03bb f, bot_hom.ext $ \u03bb _, rfl,\n  right_inv := \u03bb f, top_hom.ext $ \u03bb _, rfl }\n\n@[simp] lemma dual_id : (bot_hom.id \u03b1).dual = top_hom.id _ := rfl\n@[simp] lemma dual_comp (g : bot_hom \u03b2 \u03b3) (f : bot_hom \u03b1 \u03b2) :\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 \u03b1 := rfl\n@[simp] lemma symm_dual_comp (g : top_hom \u03b2\u1d52\u1d48 \u03b3\u1d52\u1d48) (f : top_hom \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48) :\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 \u03b1] [bounded_order \u03b1] [preorder \u03b2] [bounded_order \u03b2] [preorder \u03b3]\n  [bounded_order \u03b3]\n\n/-- Reinterpret a bounded order homomorphism as a bounded order homomorphism between the dual\norders. -/\n@[simps] protected def dual : bounded_order_hom \u03b1 \u03b2 \u2243 bounded_order_hom \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48 :=\n{ to_fun := \u03bb f, \u27e8f.to_order_hom.dual, f.map_bot', f.map_top'\u27e9,\n  inv_fun := \u03bb f, \u27e8order_hom.dual.symm f.to_order_hom, f.map_bot', f.map_top'\u27e9,\n  left_inv := \u03bb f, ext $ \u03bb a, rfl,\n  right_inv := \u03bb f, ext $ \u03bb a, rfl }\n\n@[simp] lemma dual_id : (bounded_order_hom.id \u03b1).dual = bounded_order_hom.id _ := rfl\n@[simp] lemma dual_comp (g : bounded_order_hom \u03b2 \u03b3) (f : bounded_order_hom \u03b1 \u03b2) :\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 \u03b1 := rfl\n@[simp] lemma symm_dual_comp (g : bounded_order_hom \u03b2\u1d52\u1d48 \u03b3\u1d52\u1d48) (f : bounded_order_hom \u03b1\u1d52\u1d48 \u03b2\u1d52\u1d48) :\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 \u211d or \u2102: 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 (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (A : set E) (B : set E) :=\n  \u2203 (r : \u211d), \u2203 (H : r > 0), \u2200 (a : \ud835\udd5c), r \u2264 norm a \u2192 B \u2286 a \u2022 A\n\n/-- A set is absorbent if it absorbs every singleton. -/\ndef absorbent (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (A : set E) :=\n  \u2200 (x : E), \u2203 (r : \u211d), \u2203 (H : r > 0), \u2200 (a : \ud835\udd5c), r \u2264 norm a \u2192 x \u2208 a \u2022 A\n\n/-- A set `A` is balanced if `a \u2022 A` is contained in `A` whenever `a`\nhas norm no greater than one. -/\ndef balanced (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (A : set E) :=\n  \u2200 (a : \ud835\udd5c), norm a \u2264 1 \u2192 a \u2022 A \u2286 A\n\n/-- A balanced set absorbs itself. -/\ntheorem balanced.absorbs_self {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} (hA : balanced \ud835\udd5c A) : absorbs \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} [topological_space E] [topological_vector_space \ud835\udd5c E] (hA : A \u2208 nhds 0) : absorbent \ud835\udd5c A := sorry\n\n/-- The union of `{0}` with the interior of a balanced set\n    is balanced. -/\ntheorem balanced_zero_union_interior {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} [topological_space E] [topological_vector_space \ud835\udd5c E] (hA : balanced \ud835\udd5c A) : balanced \ud835\udd5c (singleton 0 \u222a interior A) := sorry\n\n/-- The interior of a balanced set is balanced if it contains the origin. -/\ntheorem balanced.interior {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} [topological_space E] [topological_vector_space \ud835\udd5c E] (hA : balanced \ud835\udd5c A) (h : 0 \u2208 interior A) : balanced \ud835\udd5c (interior A) := sorry\n\n/-- The closure of a balanced set is balanced. -/\ntheorem balanced.closure {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} [topological_space E] [topological_vector_space \ud835\udd5c E] (hA : balanced \ud835\udd5c A) : balanced \ud835\udd5c (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 (\ud835\udd5c : Type u_1) (E : Type u_2) [normed_field \ud835\udd5c] [add_comm_group E] [vector_space \ud835\udd5c E] \nwhere\n  to_fun : E \u2192 \u211d\n  smul' : \u2200 (a : \ud835\udd5c) (x : E), to_fun (a \u2022 x) = norm a * to_fun x\n  triangle' : \u2200 (x y : E), to_fun (x + y) \u2264 to_fun x + to_fun y\n\nprotected instance seminorm.inhabited {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] : Inhabited (seminorm \ud835\udd5c E) :=\n  { default := seminorm.mk (fun (_x : E) => 0) sorry sorry }\n\nprotected instance seminorm.has_coe_to_fun {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] : has_coe_to_fun (seminorm \ud835\udd5c E) :=\n  has_coe_to_fun.mk (fun (p : seminorm \ud835\udd5c E) => E \u2192 \u211d) fun (p : seminorm \ud835\udd5c E) => seminorm.to_fun p\n\nnamespace seminorm\n\n\nprotected theorem smul {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (c : \ud835\udd5c) (x : E) : coe_fn p (c \u2022 x) = norm c * coe_fn p x :=\n  smul' p c x\n\nprotected theorem triangle {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) (y : E) : coe_fn p (x + y) \u2264 coe_fn p x + coe_fn p y :=\n  triangle' p x y\n\n@[simp] protected theorem zero {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) : coe_fn p 0 = 0 := sorry\n\n@[simp] protected theorem neg {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) : coe_fn p (-x) = coe_fn p x := sorry\n\ntheorem nonneg {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) : 0 \u2264 coe_fn p x := sorry\n\ntheorem sub_rev {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) (r : \u211d) : set E :=\n  set_of fun (y : E) => coe_fn p (y - x) < r\n\ntheorem mem_ball {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) (y : E) (r : \u211d) : y \u2208 ball p x r \u2194 coe_fn p (y - x) < r :=\n  iff.rfl\n\ntheorem mem_ball_zero {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (y : E) (r : \u211d) : y \u2208 ball p 0 r \u2194 coe_fn p y < r :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (y \u2208 ball p 0 r \u2194 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 \u2194 coe_fn p y < r)) (sub_zero y))) (iff.refl (coe_fn p y < r)))\n\ntheorem ball_zero_eq {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (r : \u211d) : 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (r : \u211d) : balanced \ud835\udd5c (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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 : Sort*} {\u03b2 : Sort*}\n\nnamespace setoid\n\nlemma ext {\u03b1 : Sort*} :\n  \u2200{s t : setoid \u03b1}, (\u2200a b, @setoid.r \u03b1 s a b \u2194 @setoid.r \u03b1 t a b) \u2192 s = t\n| \u27e8r, _\u27e9 \u27e8p, _\u27e9 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} {rb : \u03b2 \u2192 \u03b2 \u2192 Prop} {\u03c6 : quot ra \u2192 quot rb \u2192 Sort*}\nlocal notation `\u27e6`:max a `\u27e7` := quot.mk _ a\n\ninstance [inhabited \u03b1] : inhabited (quot ra) := \u27e8\u27e6default\u27e7\u27e9\n\ninstance [subsingleton \u03b1] : subsingleton (quot ra) :=\n\u27e8\u03bb x, quot.induction_on x (\u03bb y, quot.ind (\u03bb b, congr_arg _ (subsingleton.elim _ _)))\u27e9\n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082 (qa : quot ra) (qb : quot rb) (f : \u03a0 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n  (ca : \u2200 {b a\u2081 a\u2082}, ra a\u2081 a\u2082 \u2192 f a\u2081 b == f a\u2082 b)\n  (cb : \u2200 {a b\u2081 b\u2082}, rb b\u2081 b\u2082 \u2192 f a b\u2081 == f a b\u2082) : \u03c6 qa qb :=\nquot.hrec_on qa (\u03bb a, quot.hrec_on qb (f a) (\u03bb b\u2081 b\u2082 pb, cb pb)) $ \u03bb a\u2081 a\u2082 pa,\n  quot.induction_on qb $ \u03bb b,\n    calc @quot.hrec_on _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2081) (@cb _)\n          == f a\u2081 b                                     : by simp [heq_self_iff_true]\n      ... == f a\u2082 b                                     : ca pa\n      ... == @quot.hrec_on _ _ (\u03c6 _) \u27e6b\u27e7 (f a\u2082) (@cb _) : by simp [heq_self_iff_true]\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` such that `ra x y` implies `rb (f x) (f y)`\nto a map `quot ra \u2192 quot rb`. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : (ra \u21d2 rb) f f) : quot ra \u2192 quot rb :=\nquot.lift (\u03bb x, \u27e6f x\u27e7) $ assume x y (h\u2081 : ra x y), quot.sound $ h h\u2081\n\n/-- If `ra` is a subrelation of `ra'`, then we have a natural map `quot ra \u2192 quot ra'`. -/\nprotected def map_right {ra' : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : \u2200a\u2081 a\u2082, ra a\u2081 a\u2082 \u2192 ra' a\u2081 a\u2082) :\n  quot ra \u2192 quot ra' :=\nquot.map id h\n\n/-- weaken the relation of a quotient -/\ndef factor {\u03b1 : Type*} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) :\n  quot r \u2192 quot s :=\nquot.lift (quot.mk s) (\u03bb x y rxy, quot.sound (h x y rxy))\n\nlemma factor_mk_eq {\u03b1 : Type*} (r s : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : \u2200 x y, r x y \u2192 s x y) :\n  factor r s h \u2218 quot.mk _ = quot.mk _ := rfl\n\nvariables {\u03b3 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n\n/-- **Alias** of `quot.lift_beta`. -/\nlemma lift_mk (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) (a : \u03b1) :\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 : \u03b1) (f : \u03b1 \u2192 \u03b3) (h : \u2200 a\u2081 a\u2082, r a\u2081 a\u2082 \u2192 f a\u2081 = f a\u2082) :\n  quot.lift_on (quot.mk r a) f h = f a := rfl\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2`. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift\u2082\n  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b)\n  (q\u2081 : quot r) (q\u2082 : quot s) : \u03b3 :=\nquot.lift (\u03bb a, quot.lift (f a) (hr a))\n(\u03bb a\u2081 a\u2082 ha, funext (\u03bb q, quot.induction_on q (\u03bb b, hs a\u2081 a\u2082 b ha)))\nq\u2081 q\u2082\n\n@[simp]\nlemma lift\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) (a : \u03b1) (b : \u03b2) :\n  quot.lift\u2082 f hr hs (quot.mk r a) (quot.mk s b) = f a b := rfl\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` and applies it. -/\nattribute [reducible, elab_as_eliminator]\nprotected def lift_on\u2082 (p : quot r) (q : quot s) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) : \u03b3 := quot.lift\u2082 f hr hs p q\n\n@[simp]\nlemma lift_on\u2082_mk (a : \u03b1) (b : \u03b2) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 f a b\u2081 = f a b\u2082)\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 f a\u2081 b = f a\u2082 b) :\n  quot.lift_on\u2082 (quot.mk r a) (quot.mk s b) f hr hs = f a b := rfl\n\nvariables {t : \u03b3 \u2192 \u03b3 \u2192 Prop}\n\n/-- Descends a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` to quotients of `\u03b1` and `\u03b2` wih values in a quotient of\n`\u03b3`. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b))\n  (q\u2081 : quot r) (q\u2082 : quot s) : quot t :=\nquot.lift\u2082 (\u03bb a b, quot.mk t $ f a b) (\u03bb a b\u2081 b\u2082 hb, quot.sound (hr a b\u2081 b\u2082 hb))\n(\u03bb a\u2081 a\u2082 b ha, quot.sound (hs a\u2081 a\u2082 b ha)) q\u2081 q\u2082\n\n@[simp]\nlemma map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (hr : \u2200 a b\u2081 b\u2082, s b\u2081 b\u2082 \u2192 t (f a b\u2081) (f a b\u2082))\n  (hs : \u2200 a\u2081 a\u2082 b, r a\u2081 a\u2082 \u2192 t (f a\u2081 b) (f a\u2082 b))\n  (a : \u03b1) (b : \u03b2) : quot.map\u2082 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\u2082\n  {\u03b4 : quot r \u2192 quot s \u2192 Prop} (q\u2081 : quot r) (q\u2082 : quot s)\n  (h : \u2200 a b, \u03b4 (quot.mk r a) (quot.mk s b)) : \u03b4 q\u2081 q\u2082 :=\nquot.ind (\u03bb a\u2081, quot.ind (\u03bb a\u2082, h a\u2081 a\u2082) q\u2082) q\u2081\n\nattribute [elab_as_eliminator]\nprotected lemma induction_on\u2083\n  {\u03b4 : quot r \u2192 quot s \u2192 quot t \u2192 Prop} (q\u2081 : quot r) (q\u2082 : quot s) (q\u2083 : quot t)\n  (h : \u2200 a b c, \u03b4 (quot.mk r a) (quot.mk s b) (quot.mk t c)) : \u03b4 q\u2081 q\u2082 q\u2083 :=\nquot.ind (\u03bb a\u2081, quot.ind (\u03bb a\u2082, quot.ind (\u03bb a\u2083, h a\u2081 a\u2082 a\u2083) q\u2083) q\u2082) q\u2081\n\nend quot\n\nnamespace quotient\nvariables [sa : setoid \u03b1] [sb : setoid \u03b2]\nvariables {\u03c6 : quotient sa \u2192 quotient sb \u2192 Sort*}\n\ninstance [inhabited \u03b1] : inhabited (quotient sa) := \u27e8\u27e6default\u27e7\u27e9\n\ninstance (s : setoid \u03b1) [subsingleton \u03b1] : subsingleton (quotient s) :=\nquot.subsingleton\n\n/-- Induction on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082 (qa : quotient sa) (qb : quotient sb) (f : \u03a0 a b, \u03c6 \u27e6a\u27e7 \u27e6b\u27e7)\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) : \u03c6 qa qb :=\nquot.hrec_on\u2082 qa qb f\n  (\u03bb _ _ _ p, c _ _ _ _ p (setoid.refl _))\n  (\u03bb _ _ _ p, c _ _ _ _ (setoid.refl _) p)\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `quotient sa \u2192 quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map (f : \u03b1 \u2192 \u03b2) (h : ((\u2248) \u21d2 (\u2248)) f f) : quotient sa \u2192 quotient sb :=\nquot.map f h\n\n@[simp] lemma map_mk (f : \u03b1 \u2192 \u03b2) (h : ((\u2248) \u21d2 (\u2248)) f f) (x : \u03b1) :\n  quotient.map f h (\u27e6x\u27e7 : quotient sa) = (\u27e6f x\u27e7 : quotient sb) :=\nrfl\n\nvariables {\u03b3 : Sort*} [sc : setoid \u03b3]\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` that sends equivalent elements to equivalent elements\nto a function `f : quotient sa \u2192 quotient sb \u2192 quotient sc`.\nUseful to define binary operations on quotients. -/\nprotected def map\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u2248) \u21d2 (\u2248) \u21d2 (\u2248)) f f) :\n  quotient sa \u2192 quotient sb \u2192 quotient sc :=\nquotient.lift\u2082 (\u03bb x y, \u27e6f x y\u27e7) (\u03bb x\u2081 y\u2081 x\u2082 y\u2082 h\u2081 h\u2082, quot.sound $ h h\u2081 h\u2082)\n\n@[simp] lemma map\u2082_mk (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u2248) \u21d2 (\u2248) \u21d2 (\u2248)) f f) (x : \u03b1) (y : \u03b2) :\n  quotient.map\u2082 f h (\u27e6x\u27e7 : quotient sa) (\u27e6y\u27e7 : quotient sb) = (\u27e6f x y\u27e7 : quotient sc) := rfl\n\nend quotient\n\nlemma quot.eq {\u03b1 : Type*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {x y : \u03b1} :\n  quot.mk r x = quot.mk r y \u2194 eqv_gen r x y :=\n\u27e8quot.exact r, quot.eqv_gen_sound\u27e9\n\n@[simp] theorem quotient.eq [r : setoid \u03b1] {x y : \u03b1} : \u27e6x\u27e7 = \u27e6y\u27e7 \u2194 x \u2248 y :=\n\u27e8quotient.exact, quotient.sound\u27e9\n\ntheorem forall_quotient_iff {\u03b1 : Type*} [r : setoid \u03b1] {p : quotient r \u2192 Prop} :\n  (\u2200a:quotient r, p a) \u2194 (\u2200a:\u03b1, p \u27e6a\u27e7) :=\n\u27e8assume h x, h _, assume h a, a.induction_on h\u27e9\n\n@[simp] lemma quotient.lift_mk [s : setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b)\n  (x : \u03b1) :\n  quotient.lift f h (quotient.mk x) = f x := rfl\n\n@[simp] lemma quotient.lift\u2082_mk {\u03b1 : Sort*} {\u03b2 : Sort*} {\u03b3 : Sort*} [setoid \u03b1] [setoid \u03b2]\n  (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (h : \u2200 (a\u2081 : \u03b1) (a\u2082 : \u03b2) (b\u2081 : \u03b1) (b\u2082 : \u03b2), a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082)\n  (a : \u03b1) (b : \u03b2) :\n  quotient.lift\u2082 f h (quotient.mk a) (quotient.mk b) = f a b := rfl\n\n@[simp] lemma quotient.lift_on_mk [s : setoid \u03b1] (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2248 b \u2192 f a = f b)\n  (x : \u03b1) :\n  quotient.lift_on (quotient.mk x) f h = f x := rfl\n\n@[simp] theorem quotient.lift_on\u2082_mk {\u03b1 : Sort*} {\u03b2 : Sort*} [setoid \u03b1] (f : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n  (h : \u2200 (a\u2081 a\u2082 b\u2081 b\u2082 : \u03b1), a\u2081 \u2248 b\u2081 \u2192 a\u2082 \u2248 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) (x y : \u03b1) :\n  quotient.lift_on\u2082 (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 : \u03b1 \u2192 \u03b1 \u2192 Prop) : function.surjective (quot.mk r) :=\nquot.exists_rep\n\n/-- `quotient.mk` is a surjective function. -/\nlemma surjective_quotient_mk (\u03b1 : Sort*) [s : setoid \u03b1] :\n  function.surjective (quotient.mk : \u03b1 \u2192 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 : \u03b1 \u2192 \u03b1 \u2192 Prop} (q : quot r) : \u03b1 :=\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 : \u03b1 \u2192 \u03b1 \u2192 Prop} : quot r \u2192 \u03b1 := unchecked_cast\n\n@[simp] theorem quot.out_eq {r : \u03b1 \u2192 \u03b1 \u2192 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 \u03b1] : quotient s \u2192 \u03b1 := quot.out\n\n@[simp] theorem quotient.out_eq [s : setoid \u03b1] (q : quotient s) : \u27e6q.out\u27e7 = q := q.out_eq\n\ntheorem quotient.mk_out [s : setoid \u03b1] (a : \u03b1) : \u27e6a\u27e7.out \u2248 a :=\nquotient.exact (quotient.out_eq _)\n\nlemma quotient.mk_eq_iff_out [s : setoid \u03b1] {x : \u03b1} {y : quotient s} :\n  \u27e6x\u27e7 = y \u2194 x \u2248 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 \u03b1] {x : quotient s} {y : \u03b1} :\n  x = \u27e6y\u27e7 \u2194 quotient.out x \u2248 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 \u03b1] {x y : quotient s} :\n  x.out \u2248 y.out \u2194 x = y :=\nby rw [\u2190 quotient.eq_mk_iff_out, quotient.out_eq]\n\n@[simp] lemma quotient.out_inj [s : setoid \u03b1] {x y : quotient s} :\n  x.out = y.out \u2194 x = y :=\n\u27e8\u03bb h, quotient.out_equiv_out.1 $ h \u25b8 setoid.refl _, \u03bb h, h \u25b8 rfl\u27e9\n\nsection pi\n\ninstance pi_setoid {\u03b9 : Sort*} {\u03b1 : \u03b9 \u2192 Sort*} [\u2200 i, setoid (\u03b1 i)] : setoid (\u03a0 i, \u03b1 i) :=\n{ r := \u03bb a b, \u2200 i, a i \u2248 b i,\n  iseqv := \u27e8\n    \u03bb a i, setoid.refl _,\n    \u03bb a b h i, setoid.symm (h _),\n    \u03bb a b c h\u2081 h\u2082 i, setoid.trans (h\u2081 _) (h\u2082 _)\u27e9 }\n\n/-- Given a function `f : \u03a0 i, quotient (S i)`, returns the class of functions `\u03a0 i, \u03b1 i` sending\neach `i` to an element of the class `f i`. -/\nnoncomputable def quotient.choice {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [S : \u03a0 i, setoid (\u03b1 i)]\n  (f : \u03a0 i, quotient (S i)) : @quotient (\u03a0 i, \u03b1 i) (by apply_instance) :=\n\u27e6\u03bb i, (f i).out\u27e7\n\n@[simp] theorem quotient.choice_eq {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Type*} [\u03a0 i, setoid (\u03b1 i)]\n  (f : \u03a0 i, \u03b1 i) : quotient.choice (\u03bb i, \u27e6f i\u27e7) = \u27e6f\u27e7 :=\nquotient.sound $ \u03bb i, quotient.mk_out _\n\n@[elab_as_eliminator] lemma quotient.induction_on_pi\n   {\u03b9 : Type*} {\u03b1 : \u03b9 \u2192 Sort*} [s : \u2200 i, setoid (\u03b1 i)]\n   {p : (\u03a0 i, quotient (s i)) \u2192 Prop} (f : \u03a0 i, quotient (s i))\n   (h : \u2200 a : \u03a0 i, \u03b1 i, p (\u03bb i, \u27e6a i\u27e7)) : p f :=\nbegin\n  rw \u2190 (funext (\u03bb i, quotient.out_eq (f i)) : (\u03bb i,  \u27e6(f i).out\u27e7) = f),\n  apply h,\nend\n\nend pi\n\nlemma nonempty_quotient_iff (s : setoid \u03b1) : nonempty (quotient s) \u2194 nonempty \u03b1 :=\n\u27e8assume \u27e8a\u27e9, quotient.induction_on a nonempty.intro, assume \u27e8a\u27e9, \u27e8\u27e6a\u27e7\u27e9\u27e9\n\n/-- `trunc \u03b1` is the quotient of `\u03b1` by the always-true relation. This\n  is related to the propositional truncation in HoTT, and is similar\n  in effect to `nonempty \u03b1`, but unlike `nonempty \u03b1`, `trunc \u03b1` is data,\n  so the VM representation is the same as `\u03b1`, and so this can be used to\n  maintain computability. -/\ndef {u} trunc (\u03b1 : Sort u) : Sort u := @quot \u03b1 (\u03bb _ _, true)\n\ntheorem true_equivalence : @equivalence \u03b1 (\u03bb _ _, true) :=\n\u27e8\u03bb _, trivial, \u03bb _ _ _, trivial, \u03bb _ _ _ _ _, trivial\u27e9\n\nnamespace trunc\n\n/-- Constructor for `trunc \u03b1` -/\ndef mk (a : \u03b1) : trunc \u03b1 := quot.mk _ a\n\ninstance [inhabited \u03b1] : inhabited (trunc \u03b1) := \u27e8mk default\u27e9\n\n/-- Any constant function lifts to a function out of the truncation -/\ndef lift (f : \u03b1 \u2192 \u03b2) (c : \u2200 a b : \u03b1, f a = f b) : trunc \u03b1 \u2192 \u03b2 :=\nquot.lift f (\u03bb a b _, c a b)\n\ntheorem ind {\u03b2 : trunc \u03b1 \u2192 Prop} : (\u2200 a : \u03b1, \u03b2 (mk a)) \u2192 \u2200 q : trunc \u03b1, \u03b2 q := quot.ind\n\nprotected theorem lift_mk (f : \u03b1 \u2192 \u03b2) (c) (a : \u03b1) : lift f c (mk a) = f a := rfl\n\n/-- Lift a constant function on `q : trunc \u03b1`. -/\n@[reducible, elab_as_eliminator]\nprotected def lift_on (q : trunc \u03b1) (f : \u03b1 \u2192 \u03b2)\n  (c : \u2200 a b : \u03b1, f a = f b) : \u03b2 := lift f c q\n\n@[elab_as_eliminator]\nprotected theorem induction_on {\u03b2 : trunc \u03b1 \u2192 Prop} (q : trunc \u03b1)\n  (h : \u2200 a, \u03b2 (mk a)) : \u03b2 q := ind h q\n\ntheorem exists_rep (q : trunc \u03b1) : \u2203 a : \u03b1, mk a = q := quot.exists_rep q\n\nattribute [elab_as_eliminator]\nprotected theorem induction_on\u2082 {C : trunc \u03b1 \u2192 trunc \u03b2 \u2192 Prop} (q\u2081 : trunc \u03b1) (q\u2082 : trunc \u03b2)\n  (h : \u2200 a b, C (mk a) (mk b)) : C q\u2081 q\u2082 :=\ntrunc.induction_on q\u2081 $ \u03bb a\u2081, trunc.induction_on q\u2082 (h a\u2081)\n\nprotected theorem eq (a b : trunc \u03b1) : a = b :=\ntrunc.induction_on\u2082 a b (\u03bb x y, quot.sound trivial)\n\ninstance : subsingleton (trunc \u03b1) := \u27e8trunc.eq\u27e9\n\n/-- The `bind` operator for the `trunc` monad. -/\ndef bind (q : trunc \u03b1) (f : \u03b1 \u2192 trunc \u03b2) : trunc \u03b2 :=\ntrunc.lift_on q f (\u03bb a b, trunc.eq _ _)\n\n/-- A function `f : \u03b1 \u2192 \u03b2` defines a function `map f : trunc \u03b1 \u2192 trunc \u03b2`. -/\ndef map (f : \u03b1 \u2192 \u03b2) (q : trunc \u03b1) : trunc \u03b2 := bind q (trunc.mk \u2218 f)\n\ninstance : monad trunc :=\n{ pure := @trunc.mk,\n  bind := @trunc.bind }\n\ninstance : is_lawful_monad trunc :=\n{ id_map := \u03bb \u03b1 q, trunc.eq _ _,\n  pure_bind := \u03bb \u03b1 \u03b2 q f, rfl,\n  bind_assoc := \u03bb \u03b1 \u03b2 \u03b3 x f g, trunc.eq _ _ }\n\nvariable {C : trunc \u03b1 \u2192 Sort*}\n\n/-- Recursion/induction principle for `trunc`. -/\n@[reducible, elab_as_eliminator]\nprotected def rec\n   (f : \u03a0 a, C (mk a)) (h : \u2200 (a b : \u03b1), (eq.rec (f a) (trunc.eq (mk a) (mk b)) : C (mk b)) = f b)\n   (q : trunc \u03b1) : C q :=\nquot.rec f (\u03bb a b _, h a b) q\n\n/-- A version of `trunc.rec` taking `q : trunc \u03b1` as the first argument. -/\n@[reducible, elab_as_eliminator]\nprotected def rec_on (q : trunc \u03b1) (f : \u03a0 a, C (mk a))\n  (h : \u2200 (a b : \u03b1), (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   [\u2200 a, subsingleton (C (mk a))] (q : trunc \u03b1) (f : \u03a0 a, C (mk a)) : C q :=\ntrunc.rec f (\u03bb a b, subsingleton.elim _ (f b)) q\n\n/-- Noncomputably extract a representative of `trunc \u03b1` (using the axiom of choice). -/\nnoncomputable def out : trunc \u03b1 \u2192 \u03b1 := quot.out\n\n@[simp] theorem out_eq (q : trunc \u03b1) : mk q.out = q := trunc.eq _ _\n\nprotected theorem nonempty (q : trunc \u03b1) : nonempty \u03b1 :=\nnonempty_of_exists q.exists_rep\n\nend trunc\n\nnamespace quotient\nvariables {\u03b3 : Sort*} {\u03c6 : Sort*}\n  {s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2} {s\u2083 : setoid \u03b3}\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 \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nprotected def mk' (a : \u03b1) : quotient s\u2081 := quot.mk s\u2081.1 a\n\n/-- `quotient.mk'` is a surjective function. -/\nlemma surjective_quotient_mk' : function.surjective (quotient.mk' : \u03b1 \u2192 quotient s\u2081) :=\nquot.exists_rep\n\n/-- A version of `quotient.lift_on` taking `{s : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on' (q : quotient s\u2081) (f : \u03b1 \u2192 \u03c6)\n  (h : \u2200 a b, @setoid.r \u03b1 s\u2081 a b \u2192 f a = f b) : \u03c6 := quotient.lift_on q f h\n\n@[simp]\nprotected lemma lift_on'_mk' (f : \u03b1 \u2192 \u03c6) (h) (x : \u03b1) :\n  quotient.lift_on' (@quotient.mk' _ s\u2081 x) f h = f x := rfl\n\n/-- A version of `quotient.lift_on\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator, reducible]\nprotected def lift_on\u2082' (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n  (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082, @setoid.r \u03b1 s\u2081 a\u2081 b\u2081 \u2192 @setoid.r \u03b2 s\u2082 a\u2082 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) : \u03b3 :=\nquotient.lift_on\u2082 q\u2081 q\u2082 f h\n\n@[simp]\nprotected lemma lift_on\u2082'_mk' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (a : \u03b1) (b : \u03b2) :\n  quotient.lift_on\u2082' (@quotient.mk' _ s\u2081 a) (@quotient.mk' _ s\u2082 b) f h = f a b := rfl\n\n/-- A version of `quotient.ind` taking `{s : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\n@[elab_as_eliminator]\nprotected lemma ind' {p : quotient s\u2081 \u2192 Prop}\n  (h : \u2200 a, p (quotient.mk' a)) (q : quotient s\u2081) : p q :=\nquotient.ind h q\n\n/-- A version of `quotient.ind\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit arguments\ninstead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma ind\u2082' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Prop}\n  (h : \u2200 a\u2081 a\u2082, p (quotient.mk' a\u2081) (quotient.mk' a\u2082))\n  (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) : p q\u2081 q\u2082 :=\nquotient.ind\u2082 h q\u2081 q\u2082\n\n/-- A version of `quotient.induction_on` taking `{s : setoid \u03b1}` as an implicit argument instead\nof an instance argument. -/\n@[elab_as_eliminator]\nprotected lemma induction_on' {p : quotient s\u2081 \u2192 Prop} (q : quotient s\u2081)\n  (h : \u2200 a, p (quotient.mk' a)) : p q := quotient.induction_on q h\n\n/-- A version of `quotient.induction_on\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2}` as implicit\narguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on\u2082' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Prop} (q\u2081 : quotient s\u2081)\n  (q\u2082 : quotient s\u2082) (h : \u2200 a\u2081 a\u2082, p (quotient.mk' a\u2081) (quotient.mk' a\u2082)) : p q\u2081 q\u2082 :=\nquotient.induction_on\u2082 q\u2081 q\u2082 h\n\n/-- A version of `quotient.induction_on\u2083` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b2} {s\u2083 : setoid \u03b3}`\nas implicit arguments instead of instance arguments. -/\n@[elab_as_eliminator]\nprotected lemma induction_on\u2083' {p : quotient s\u2081 \u2192 quotient s\u2082 \u2192 quotient s\u2083 \u2192 Prop}\n  (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (q\u2083 : quotient s\u2083)\n  (h : \u2200 a\u2081 a\u2082 a\u2083, p (quotient.mk' a\u2081) (quotient.mk' a\u2082) (quotient.mk' a\u2083)) : p q\u2081 q\u2082 q\u2083 :=\nquotient.induction_on\u2083 q\u2081 q\u2082 q\u2083 h\n\n/-- A version of `quotient.rec_on_subsingleton` taking `{s\u2081 : setoid \u03b1}` as an implicit argument\ninstead of an instance argument. -/\n@[elab_as_eliminator]\nprotected def rec_on_subsingleton' {\u03c6 : quotient s\u2081 \u2192 Sort*}\n  [h : \u2200 a, subsingleton (\u03c6 \u27e6a\u27e7)] (q : quotient s\u2081) (f : \u03a0 a, \u03c6 (quotient.mk' a)) : \u03c6 q :=\nquotient.rec_on_subsingleton q f\n\n/-- A version of `quotient.rec_on_subsingleton\u2082` taking `{s\u2081 : setoid \u03b1} {s\u2082 : setoid \u03b1}`\nas implicit arguments instead of instance arguments. -/\nattribute [reducible, elab_as_eliminator]\nprotected def rec_on_subsingleton\u2082'\n   {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*} [h : \u2200 a b, subsingleton (\u03c6 \u27e6a\u27e7 \u27e6b\u27e7)]\n   (q\u2081 : quotient s\u2081) (q\u2082 : quotient s\u2082) (f : \u03a0 a\u2081 a\u2082, \u03c6 (quotient.mk' a\u2081) (quotient.mk' a\u2082)) :\n   \u03c6 q\u2081 q\u2082 :=\nquotient.rec_on_subsingleton\u2082 q\u2081 q\u2082 f\n\n/-- Recursion on a `quotient` argument `a`, result type depends on `\u27e6a\u27e7`. -/\nprotected def hrec_on' {\u03c6 : quotient s\u2081 \u2192 Sort*} (qa : quotient s\u2081) (f : \u03a0 a, \u03c6 (quotient.mk' a))\n  (c : \u2200 a\u2081 a\u2082, a\u2081 \u2248 a\u2082 \u2192 f a\u2081 == f a\u2082) : \u03c6 qa :=\nquot.hrec_on qa f c\n\n@[simp] \n\n/-- Recursion on two `quotient` arguments `a` and `b`, result type depends on `\u27e6a\u27e7` and `\u27e6b\u27e7`. -/\nprotected def hrec_on\u2082' {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*} (qa : quotient s\u2081)\n  (qb : quotient s\u2082) (f : \u2200 a b, \u03c6 (quotient.mk' a) (quotient.mk' b))\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) : \u03c6 qa qb :=\nquotient.hrec_on\u2082 qa qb f c\n\n@[simp] lemma hrec_on\u2082'_mk' {\u03c6 : quotient s\u2081 \u2192 quotient s\u2082 \u2192 Sort*}\n  (f : \u2200 a b, \u03c6 (quotient.mk' a) (quotient.mk' b))\n  (c : \u2200 a\u2081 b\u2081 a\u2082 b\u2082, a\u2081 \u2248 a\u2082 \u2192 b\u2081 \u2248 b\u2082 \u2192 f a\u2081 b\u2081 == f a\u2082 b\u2082) (x : \u03b1) (qb : quotient s\u2082) :\n  (quotient.mk' x).hrec_on\u2082' qb f c = qb.hrec_on' (f x) (\u03bb b\u2081 b\u2082, c _ _ _ _ (setoid.refl _)) :=\nrfl\n\n/-- Map a function `f : \u03b1 \u2192 \u03b2` that sends equivalent elements to equivalent elements\nto a function `quotient sa \u2192 quotient sb`. Useful to define unary operations on quotients. -/\nprotected def map' (f : \u03b1 \u2192 \u03b2) (h : ((\u2248) \u21d2 (\u2248)) f f) :\n  quotient s\u2081 \u2192 quotient s\u2082 :=\nquot.map f h\n\n@[simp] lemma map'_mk' (f : \u03b1 \u2192 \u03b2) (h) (x : \u03b1) :\n  (quotient.mk' x : quotient s\u2081).map' f h = (quotient.mk' (f x) : quotient s\u2082) :=\nrfl\n\n/-- A version of `quotient.map\u2082` using curly braces and unification. -/\nprotected def map\u2082' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h : ((\u2248) \u21d2 (\u2248) \u21d2 (\u2248)) f f) :\n  quotient s\u2081 \u2192 quotient s\u2082 \u2192 quotient s\u2083 :=\nquotient.map\u2082 f h\n\n@[simp] lemma map\u2082'_mk' (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (h) (x : \u03b1) :\n  (quotient.mk' x : quotient s\u2081).map\u2082' f h =\n    (quotient.map' (f x) (h (setoid.refl x)) : quotient s\u2082 \u2192 quotient s\u2083) :=\nrfl\n\nlemma exact' {a b : \u03b1} :\n  (quotient.mk' a : quotient s\u2081) = quotient.mk' b \u2192 @setoid.r _ s\u2081 a b :=\nquotient.exact\n\nlemma sound' {a b : \u03b1} : @setoid.r _ s\u2081 a b \u2192 @quotient.mk' \u03b1 s\u2081 a = quotient.mk' b :=\nquotient.sound\n\n@[simp]\nprotected lemma eq' {a b : \u03b1} : @quotient.mk' \u03b1 s\u2081 a = quotient.mk' b \u2194 @setoid.r _ s\u2081 a b :=\nquotient.eq\n\n/-- A version of `quotient.out` taking `{s\u2081 : setoid \u03b1}` as an implicit argument instead of an\ninstance argument. -/\nnoncomputable def out' (a : quotient s\u2081) : \u03b1 := quotient.out a\n\n@[simp] theorem out_eq' (q : quotient s\u2081) : quotient.mk' q.out' = q := q.out_eq\n\ntheorem mk_out' (a : \u03b1) : @setoid.r \u03b1 s\u2081 (quotient.mk' a : quotient s\u2081).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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 \u2964 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 {\u03b1 \u03b2 : Type*}\n\nnamespace measure_theory\n\nnamespace measure\n\nvariables [measurable_space \u03b1] [measurable_space \u03b2]\n\n/-- Measurability structure on `measure`: Measures are measurable w.r.t. all projections -/\ninstance : measurable_space (measure \u03b1) :=\n\u2a06 (s : set \u03b1) (hs : measurable_set s), (borel \u211d\u22650\u221e).comap (\u03bb \u03bc, \u03bc s)\n\nlemma measurable_coe {s : set \u03b1} (hs : measurable_set s) : measurable (\u03bb \u03bc : measure \u03b1, \u03bc s) :=\nmeasurable.of_comap_le $ le_supr_of_le s $ le_supr_of_le hs $ le_rfl\n\nlemma measurable_of_measurable_coe (f : \u03b2 \u2192 measure \u03b1)\n  (h : \u2200 (s : set \u03b1) (hs : measurable_set s), measurable (\u03bb b, f b s)) :\n  measurable f :=\nmeasurable.of_le_map $ supr\u2082_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 {\u03b1 : Type*} {m : measurable_space \u03b1} : has_measurable_add\u2082 (measure \u03b1) :=\nbegin\n  refine \u27e8measure.measurable_of_measurable_coe _ (\u03bb s hs, _)\u27e9,\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 {\u03bc : \u03b1 \u2192 measure \u03b2} :\n  measurable \u03bc \u2194 \u2200 (s : set \u03b2) (hs : measurable_set s), measurable (\u03bb b, \u03bc b s) :=\n\u27e8\u03bb h\u03bc s hs, (measurable_coe hs).comp h\u03bc, measurable_of_measurable_coe \u03bc\u27e9\n\nlemma measurable_map (f : \u03b1 \u2192 \u03b2) (hf : measurable f) :\n  measurable (\u03bb \u03bc : measure \u03b1, map f \u03bc) :=\nbegin\n  refine measurable_of_measurable_coe _ (\u03bb s hs, _),\n  simp_rw map_apply hf hs,\n  exact measurable_coe (hf hs),\nend\n\nlemma measurable_dirac : measurable (measure.dirac : \u03b1 \u2192 measure \u03b1) :=\nbegin\n  refine measurable_of_measurable_coe _ (\u03bb s hs, _),\n  simp_rw [dirac_apply' _ hs],\n  exact measurable_one.indicator hs\nend\n\nlemma measurable_lintegral {f : \u03b1 \u2192 \u211d\u22650\u221e} (hf : measurable f) :\n  measurable (\u03bb \u03bc : measure \u03b1, \u222b\u207b x, f x \u2202\u03bc) :=\nbegin\n  simp only [lintegral_eq_supr_eapprox_lintegral, hf, simple_func.lintegral],\n  refine measurable_supr (\u03bb n, finset.measurable_sum _ (\u03bb 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 \u03b1)) : measure \u03b1 :=\nmeasure.of_measurable\n  (\u03bb s hs, \u222b\u207b \u03bc, \u03bc s \u2202m)\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 \u03b1)} {s : set \u03b1} (hs : measurable_set s) :\n  join m s = \u222b\u207b \u03bc, \u03bc s \u2202m :=\nmeasure.of_measurable_apply s hs\n\n@[simp] lemma join_zero : (0 : measure (measure \u03b1)).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 \u03b1) \u2192 measure \u03b1) :=\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 \u03b1)} {f : \u03b1 \u2192 \u211d\u22650\u221e} (hf : measurable f) :\n  \u222b\u207b x, f x \u2202(join m) = \u222b\u207b \u03bc, \u222b\u207b x, f x \u2202\u03bc \u2202m :=\nbegin\n  simp_rw [lintegral_eq_supr_eapprox_lintegral hf,\n    simple_func.lintegral, join_apply (simple_func.measurable_set_preimage _ _)],\n  suffices : \u2200 (s : \u2115 \u2192 finset \u211d\u22650\u221e) (f : \u2115 \u2192 \u211d\u22650\u221e \u2192 measure \u03b1 \u2192 \u211d\u22650\u221e)\n    (hf : \u2200 n r, measurable (f n r)) (hm : monotone (\u03bb n \u03bc, \u2211 r in s n, r * f n r \u03bc)),\n    (\u2a06 n, \u2211 r in s n, r * \u222b\u207b \u03bc, f n r \u03bc \u2202m) = \u222b\u207b \u03bc, \u2a06 n, \u2211 r in s n, r * f n r \u03bc \u2202m,\n  { refine this (\u03bb n, simple_func.range (simple_func.eapprox f n))\n      (\u03bb n r \u03bc, \u03bc (simple_func.eapprox f n \u207b\u00b9' {r})) _ _,\n    { exact \u03bb n r, measurable_coe (simple_func.measurable_set_preimage _ _), },\n    { exact \u03bb n m h \u03bc, 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 \u03bb n, finset.measurable_sum _ (\u03bb 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 \u03bb 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 \u03b1) (f : \u03b1 \u2192 measure \u03b2) : measure \u03b2 := join (map f m)\n\n@[simp] lemma bind_zero_left (f : \u03b1 \u2192 measure \u03b2) : bind 0 f = 0 :=\nby simp [bind]\n\n@[simp] lemma bind_zero_right (m : measure \u03b1) :\n  bind m (0 : \u03b1 \u2192 measure \u03b2) = 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 \u03b1) :\n  bind m (\u03bb _, 0 : \u03b1 \u2192 measure \u03b2) = 0 :=\nbind_zero_right m\n\n@[simp] lemma bind_apply {m : measure \u03b1} {f : \u03b1 \u2192 measure \u03b2} {s : set \u03b2}\n  (hs : measurable_set s) (hf : measurable f) :\n  bind m f s = \u222b\u207b a, f a s \u2202m :=\nby rw [bind, join_apply hs, lintegral_map (measurable_coe hs) hf]\n\nlemma measurable_bind' {g : \u03b1 \u2192 measure \u03b2} (hg : measurable g) : measurable (\u03bb m, bind m g) :=\nmeasurable_join.comp (measurable_map _ hg)\n\nlemma lintegral_bind {m : measure \u03b1} {\u03bc : \u03b1 \u2192 measure \u03b2} {f : \u03b2 \u2192 \u211d\u22650\u221e}\n  (h\u03bc : measurable \u03bc) (hf : measurable f) :\n  \u222b\u207b x, f x \u2202 (bind m \u03bc) = \u222b\u207b a, \u222b\u207b x, f x \u2202(\u03bc a) \u2202m :=\n(lintegral_join hf).trans (lintegral_map (measurable_lintegral hf) h\u03bc)\n\nlemma bind_bind {\u03b3} [measurable_space \u03b3] {m : measure \u03b1} {f : \u03b1 \u2192 measure \u03b2} {g : \u03b2 \u2192 measure \u03b3}\n  (hf : measurable f) (hg : measurable g) :\n  bind (bind m f) g = bind m (\u03bb 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 : \u03b1 \u2192 measure \u03b2} (hf : measurable f) (a : \u03b1) : 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 \u03b1} : 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 (\u03bc : measure (measure \u03b1)) : join \u03bc = bind \u03bc id :=\nby rw [bind, map_id]\n\nlemma join_map_map {f : \u03b1 \u2192 \u03b2} (hf : measurable f) (\u03bc : measure (measure \u03b1)) :\n  join (map (map f) \u03bc) = map f (join \u03bc) :=\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 (\u03bc : measure (measure (measure \u03b1))) :\n  join (map join \u03bc) = join (join \u03bc) :=\nbegin\n  show bind \u03bc join = join (join \u03bc),\n  rw [join_eq_bind, join_eq_bind, bind_bind measurable_id measurable_id],\n  apply congr_arg (bind \u03bc),\n  funext \u03bd,\n  exact join_eq_bind \u03bd\nend\n\nlemma join_map_dirac (\u03bc : measure \u03b1) : join (map dirac \u03bc) = \u03bc :=\ndirac_bind\n\nlemma join_dirac (\u03bc : measure \u03b1) : join (dirac \u03bc) = \u03bc :=\n(join_eq_bind (dirac \u03bc)).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\u00e9bastien Gou\u00ebzel, 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 {\u03b1 \u03b2 : Type*}\n\nnamespace list\n\nattribute [simp] join\n\n@[simp] lemma join_singleton (l : list \u03b1) : [l].join = l :=\nby rw [join, join, append_nil]\n\n@[simp] lemma join_eq_nil : \u2200 {L : list (list \u03b1)}, join L = [] \u2194 \u2200 l \u2208 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\u2081 L\u2082 : list (list \u03b1)) : join (L\u2081 ++ L\u2082) = join L\u2081 ++ join L\u2082 :=\nby induction L\u2081; [refl, simp only [*, join, cons_append, append_assoc]]\n\nlemma join_concat (L : list (list \u03b1)) (l : list \u03b1) : join (L.concat l) = join L ++ l :=\nby simp\n\n@[simp] lemma join_filter_empty_eq_ff [decidable_pred (\u03bb l : list \u03b1, l.empty = ff)] :\n  \u2200 {L : list (list \u03b1)}, join (L.filter (\u03bb 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 (\u03bb l : list \u03b1, l \u2260 [])] {L : list (list \u03b1)} :\n  join (L.filter (\u03bb l, l \u2260 [])) = L.join :=\nby simp [join_filter_empty_eq_ff, \u2190 empty_iff_eq_nil]\n\nlemma join_join (l : list (list (list \u03b1))) : l.join.join = (l.map join).join :=\nby { induction l, simp, simp [l_ih] }\n\n@[simp] lemma length_join (L : list (list \u03b1)) : 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 \u03b1) (f : \u03b1 \u2192 list \u03b2) :\n  length (list.bind l f) = sum (map (length \u2218 f) l) :=\nby rw [list.bind, length_join, map_map]\n\n@[simp] lemma bind_eq_nil {l : list \u03b1} {f : \u03b1 \u2192 list \u03b2} :\n  list.bind l f = [] \u2194 \u2200 x \u2208 l, f x = [] :=\njoin_eq_nil.trans $ by simp only [mem_map, forall_exists_index, and_imp, forall_apply_eq_imp_iff\u2082]\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 \u03b1)) (i : \u2115) :\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 \u03b1)) (i : \u2115) :\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 \u03b1) {i : \u2115} (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 `\u2264 i`. -/\nlemma drop_take_succ_join_eq_nth_le (L : list (list \u03b1)) {i : \u2115} (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 \u03b1)) {i j : \u2115}\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 \u03b1)) {i j : \u2115}\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 \u03b1)) {i j : \u2115}\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 \u03b1)) :\n  L = L' \u2194 L.join = L'.join \u2227 map length L = map length L' :=\nbegin\n  refine \u27e8\u03bb H, by simp [H], _\u27e9,\n  rintros \u27e8join_eq, length_eq\u27e9,\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\u2081 h\u2082,\n    rw [\u2190 drop_take_succ_join_eq_nth_le, \u2190 drop_take_succ_join_eq_nth_le, join_eq, length_eq] }\nend\n\nlemma join_drop_length_sub_one {L : list (list \u03b1)} (h : L \u2260 []) :\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\u2081 ++ x) ++ (l\u2082 ++ x) ++ ... ++ (l\u2099 ++ x)` to\n`(x ++ l\u2081) ++ (x ++ l\u2082) ++ ... ++ (x ++ l\u2099) ++ x` where `L = [l\u2081, l\u2082, ..., l\u2099]`. -/\nlemma append_join_map_append (L : list (list \u03b1)) (x : list \u03b1) :\n  x ++ (list.map (\u03bb l, l ++ x) L).join = (list.map (\u03bb 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 \u03b1)) :\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 \u03b1)) :\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 : \u2200 a:\u03b1, \u2203 b:\u03b2, p a b |- G` produces\n`f : \u03b1 \u2192 \u03b2, hf: \u2200 a, p a (f a) |- G`.\n\nTODO: switch to `rcases` syntax: `choose \u27e8i, j, h\u2081 -\u27e9 := expr`.\n-/\n\nopen Lean Meta Elab Tactic\n\nnamespace Mathlib.Tactic.Choose\n\n/-- Given `\u03b1 : Sort u`, `nonemp : Nonempty \u03b1`, `p : \u03b1 \u2192 Prop`, a context of free variables\n`ctx`, and a pair of an element `val : \u03b1` and `spec : p val`,\n`mk_sometimes u \u03b1 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) (\u03b1 nonemp p : Expr) :\n  List Expr \u2192 Expr \u00d7 Expr \u2192 MetaM (Expr \u00d7 Expr)\n| [], (val, spec) => pure (val, spec)\n| (e :: ctx), (val, spec) => do\n  let (val, spec) \u2190 mk_sometimes u \u03b1 nonemp p ctx (val, spec)\n  let t \u2190 inferType e\n  let b \u2190 isProp t\n  if b then do\n    let val' \u2190 mkLambdaFVars #[e] val\n    pure\n      (mkApp4 (Expr.const ``Function.sometimes [Level.zero, u]) t \u03b1 nonemp val',\n      mkApp7 (Expr.const ``Function.sometimes_spec [u]) t \u03b1 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 \u2208 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 \u2192 ElimStatus \u2192 ElimStatus\n| success, _ => success\n| _, success => success\n| failure ts\u2081, failure ts\u2082 => failure (ts\u2081 ++ ts\u2082)\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 : \u2200xs, \u2203a:\u03b1, p a) \u22a2 g` to `(d : \u2200xs, a) \u22a2 (s : \u2200xs, p (d xs)) \u2192 g` and\n`(h : \u2200xs, p xs \u2227 q xs) \u22a2 g` to `(d : \u2200xs, p xs) \u22a2 (s : \u2200xs, q xs) \u2192 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 `\u03b1` 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 : \u2200xs ys, \u2203a:\u03b1, p a) \u22a2 g` becomes `(d : \u2200xs, a) (s : \u2200xs ys, p (d xs)) \u22a2 g`. -/\ndef choose1 (g : MVarId) (nondep : Bool) (h : Option Expr) (data : Name) :\n  MetaM (ElimStatus \u00d7 Expr \u00d7 MVarId) := do\n  let (g, h) \u2190 match h with\n  | some e => pure (g, e)\n  | none   => do\n    let (e, g) \u2190 g.intro1P\n    pure (g, .fvar e)\n  g.withContext do\n    let h \u2190 instantiateMVars h\n    let t \u2190 inferType h\n    forallTelescopeReducing t fun ctx t \u21a6 do\n      (\u2190 withTransparency .all (whnf t)).withApp fun\n      | .const ``Exists [u], #[\u03b1, p] => do\n        let data \u2190 mkFreshNameFrom data ((\u2190 p.getBinderName).getD `h)\n        let ((neFail : ElimStatus), (nonemp : Option Expr)) \u2190 if nondep then\n          let ne := (Expr.const ``Nonempty [u]).app \u03b1\n          let m \u2190 mkFreshExprMVar ne\n          let mut g' := m.mvarId!\n          for e in ctx do\n            if (\u2190 isProof e) then continue\n            let ty \u2190 whnf (\u2190 inferType e)\n            let nety := (Expr.const ``Nonempty [u]).app ty\n            let neval := mkApp2 (Expr.const ``Nonempty.intro [u]) ty e\n            g' \u2190 g'.assert .anonymous nety neval\n          (_, g') \u2190 g'.intros\n          g'.withContext do\n            match \u2190 synthInstance? (\u2190 g'.getType) with\n            | some e => do\n              g'.assign e\n              let m \u2190 instantiateMVars m\n              pure (.success, some m)\n            | none => pure (.failure [ne], none)\n        else pure (.failure [], none)\n        let ctx' \u2190 if nonemp.isSome then ctx.filterM (not <$> isProof \u00b7) else pure ctx\n        let dataTy \u2190 mkForallFVars ctx' \u03b1\n        let mut dataVal := mkApp3 (.const ``Classical.choose [u]) \u03b1 p (mkAppN h ctx)\n        let mut specVal := mkApp3 (.const ``Classical.choose_spec [u]) \u03b1 p (mkAppN h ctx)\n        if let some nonemp := nonemp then\n          (dataVal, specVal) \u2190 mk_sometimes u \u03b1 nonemp p ctx.toList (dataVal, specVal)\n        dataVal \u2190 mkLambdaFVars ctx' dataVal\n        specVal \u2190 mkLambdaFVars ctx specVal\n        let (fvar, g) \u2190 withLocalDeclD .anonymous dataTy fun d \u21a6 do\n          let specTy \u2190 mkForallFVars ctx (p.app (mkAppN d ctx')).headBeta\n          g.withContext <| withLocalDeclD data dataTy fun d' \u21a6 do\n            let mvarTy \u2190 mkArrow (specTy.replaceFVar d d') (\u2190 g.getType)\n            let newMVar \u2190 mkFreshExprSyntheticOpaqueMVar mvarTy (\u2190 g.getTag)\n            g.assign <| mkApp2 (\u2190 mkLambdaFVars #[d'] newMVar) dataVal specVal\n            pure (d', newMVar.mvarId!)\n        let g \u2190 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 \u2190 mkFreshNameFrom data `h\n        let e1 \u2190 mkLambdaFVars ctx $ mkApp3 (.const ``And.left  []) p q (mkAppN h ctx)\n        let e2 \u2190 mkLambdaFVars ctx $ mkApp3 (.const ``And.right []) p q (mkAppN h ctx)\n        let t1 \u2190 inferType e1\n        let t2 \u2190 inferType e2\n        let (fvar, g) \u2190 (\u2190 (\u2190 g.assert .anonymous t2 e2).assert data t1 e1).intro1P\n        let g \u2190 match h with\n        | .fvar v => g.clear v\n        | _ => pure g\n        return (.success, .fvar fvar, g)\n      -- TODO: support \u03a3, \u00d7, or even any inductive type with 1 constructor ?\n      | _, _ => throwError \"expected a term of the shape `\u2200xs, \u2203a, p xs a` or `\u2200xs, p xs \u2227 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 \u00d7 MVarId) := do\n  let n := if let `(binderIdent| $n:ident) := data then n.getId else `_\n  let (status, fvar, g) \u2190 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) \u2192 ElimStatus \u2192 MVarId \u2192 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!\"{(\u2190 mkFreshExprMVar ty).mvarId!}\"\n    throwError msg\n  | _, _ => do\n    let (fvar, g) \u2190 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) \u2190 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  `\u2200 (x : X) (y : Y), \u2203 (a : A) (b : B), P x y a b \u2227 Q x y a b`\n  for some `P Q : X \u2192 Y \u2192 A \u2192 B \u2192 Prop` and outputs\n  into context a function `a : X \u2192 Y \u2192 A`, `b : X \u2192 Y \u2192 B` and two assumptions:\n  `h : \u2200 (x : X) (y : Y), P x y (a x y) (b x y)` and\n  `h' : \u2200 (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 \u2192 A`, `b : X \u2192 B`, and the assumptions\n  `h : \u2200 (x : X) (y : Y), P x y (a x) (b x)` and\n  `h' : \u2200 (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 : \u2200 n m : \u2115, \u2203 i j, m = n + i \u2228 m + j = n) : True := by\n  choose i j h using h\n  guard_hyp i : \u2115 \u2192 \u2115 \u2192 \u2115\n  guard_hyp j : \u2115 \u2192 \u2115 \u2192 \u2115\n  guard_hyp h : \u2200 (n m : \u2115), m = n + i n m \u2228 m + j n m = n\n  trivial\n```\n\n```\nexample (h : \u2200 i : \u2115, i < 7 \u2192 \u2203 j, i < j \u2227 j < i+i) : True := by\n  choose! f h h' using h\n  guard_hyp f : \u2115 \u2192 \u2115\n  guard_hyp h : \u2200 (i : \u2115), i < 7 \u2192 i < f i\n  guard_hyp h' : \u2200 (i : \u2115), i < 7 \u2192 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 \u2190 h.mapM (Elab.Tactic.elabTerm \u00b7 none)\n  let g \u2190 elabChoose b.isSome h ids.toList (.failure []) (\u2190 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 \u03b1` as a structure containing a term `a : \u03b1` for any type `\u03b1`,\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 \u27f6 Y` in `Discrete \u03b1` as `X = Y`,\none might define it as `PLift (X = Y)`.\nIn fact, to allow `Discrete \u03b1` to be a `SmallCategory`\n(i.e. with morphisms in the same universe as the objects),\nwe actually define the hom type `X \u27f6 Y` as `ULift (PLift (X = Y))`.\n\n`Discrete.functor` promotes a function `f : I \u2192 C` (for any category `C`) to a functor\n`Discrete.functor f : Discrete I \u2964 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\u2081 v\u2082 v\u2083 u\u2081 u\u2081' u\u2082 u\u2083\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 \u03b1` and `\u03b1`. 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 (\u03b1 : Type u\u2081) where\n  /-- A wrapper for promoting any type to a category,\n  with the only morphisms being equalities.\n  -/\n  as : \u03b1\n#align category_theory.discrete CategoryTheory.Discrete\n\n@[simp]\ntheorem Discrete.mk_as {\u03b1 : Type u\u2081} (X : Discrete \u03b1) : Discrete.mk X.as = X := by\n  ext\n  rfl\n#align category_theory.discrete.mk_as CategoryTheory.Discrete.mk_as\n\n/-- `Discrete \u03b1` is equivalent to the original type `\u03b1`.-/\n@[simps]\ndef discreteEquiv {\u03b1 : Type u\u2081} : Discrete \u03b1 \u2243 \u03b1 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 {\u03b1 : Type u\u2081} [DecidableEq \u03b1] : DecidableEq (Discrete \u03b1) :=\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 \u27f6 Y` as `ULift (PLift (X = Y))`.\n\nSee <https://stacks.math.columbia.edu/tag/001A>\n-/\ninstance discreteCategory (\u03b1 : Type u\u2081) : SmallCategory (Discrete \u03b1) 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 \u27e8\u27e8\u27e8\u27e9\u27e9\u27e9\n    exact g\n#align category_theory.discrete_category CategoryTheory.discreteCategory\n\nnamespace Discrete\n\nvariable {\u03b1 : Type u\u2081}\n\ninstance [Inhabited \u03b1] : Inhabited (Discrete \u03b1) :=\n  \u27e8\u27e8default\u27e9\u27e9\n\ninstance [Subsingleton \u03b1] : Subsingleton (Discrete \u03b1) :=\n  \u27e8by\n    intros\n    ext\n    apply Subsingleton.elim\u27e9\n\ninstance (X Y : Discrete \u03b1) : Subsingleton (X \u27f6 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 _) \u27f6 (_ : discrete _), PLift _]]\n-/\n\n/- Porting note: rewrote `discrete_cases` tactic -/\n/-- A simple tactic to run `cases` on any `discrete \u03b1` hypotheses. -/\nmacro \"discrete_cases\": tactic =>\n  `(tactic|casesm* Discrete _, (_ : Discrete _) \u27f6 (_ : Discrete _), PLift _)\n\ninstance [Unique \u03b1] : Unique (Discrete \u03b1) :=\n  Unique.mk' (Discrete \u03b1)\n\n/-- Extract the equation from a morphism in a discrete category. -/\ntheorem eq_of_hom {X Y : Discrete \u03b1} (i : X \u27f6 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 \u03b1` to a morphism `X \u27f6 Y`\nin the discrete category. -/\nprotected abbrev eqToHom {X Y : Discrete \u03b1} (h : X.as = Y.as) : X \u27f6 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 \u03b1` to an isomorphism `X \u2245 Y`\nin the discrete category. -/\nprotected abbrev eqToIso {X Y : Discrete \u03b1} (h : X.as = Y.as) : X \u2245 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 : \u03b1} (h : a = b) : Discrete.mk a \u27f6 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 : \u03b1} (h : a = b) : Discrete.mk a \u2245 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 \u03b1) : ULift.up (PLift.up (Eq.refl X.as)) = \ud835\udfd9 X :=\n  rfl\n#align category_theory.discrete.id_def CategoryTheory.Discrete.id_def\n\nvariable {C : Type u\u2082} [Category.{v\u2082} C]\n\ninstance {I : Type u\u2081} {i j : Discrete I} (f : i \u27f6 j) : IsIso f :=\n  \u27e8\u27e8Discrete.eqToHom (eq_of_hom f).symm, by aesop_cat\u27e9\u27e9\n\n/-- Any function `I \u2192 C` gives a functor `Discrete I \u2964 C`.-/\ndef functor {I : Type u\u2081} (F : I \u2192 C) : Discrete I \u2964 C where\n  obj := F \u2218 Discrete.as\n  map {X Y} f := by\n    dsimp\n    rcases f with \u27e8\u27e8h\u27e9\u27e9\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\u2081} (F : I \u2192 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\u2081} (F : I \u2192 C) {i : Discrete I} (f : i \u27f6 i) :\n    (Discrete.functor F).map f = \ud835\udfd9 (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\u2081} {J : Type u\u2081'} (f : J \u2192 C) (g : I \u2192 J) :\n    Discrete.functor (f \u2218 g) \u2245 Discrete.functor (Discrete.mk \u2218 g) \u22d9 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\u2081} {F G : Discrete I \u2964 C} (f : \u2200 i : Discrete I, F.obj i \u27f6 G.obj i) : F \u27f6 G\n    where\n  app := f\n  naturality := fun {X Y} \u27e8\u27e8g\u27e9\u27e9 => by\n    discrete_cases\n    rcases g\n    change F.map (\ud835\udfd9 _) \u226b _ = _ \u226b G.map (\ud835\udfd9 _)\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\u2081} {F G : Discrete I \u2964 C} (f : \u2200 i : Discrete I, F.obj i \u2245 G.obj i) : F \u2245 G :=\n  NatIso.ofComponents f fun \u27e8\u27e8g\u27e9\u27e9 => by\n    discrete_cases\n    rcases g\n    change F.map (\ud835\udfd9 _) \u226b _ = _ \u226b G.map (\ud835\udfd9 _)\n    simp\n#align category_theory.discrete.nat_iso CategoryTheory.Discrete.natIso\n\n@[simp]\ntheorem natIso_app {I : Type u\u2081} {F G : Discrete I \u2964 C} (f : \u2200 i : Discrete I, F.obj i \u2245 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\u2081} {F : Discrete I \u2964 C} : F \u2245 Discrete.functor (F.obj \u2218 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\u2081} {D : Type u\u2083} [Category.{v\u2083} D] (F : I \u2192 C) (G : C \u2964 D) :\n    Discrete.functor F \u22d9 G \u2245 Discrete.functor (G.obj \u2218 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\u2081} {J : Type u\u2082} (e : I \u2243 J) : Discrete I \u224c Discrete J where\n  functor := Discrete.functor (Discrete.mk \u2218 (e : I \u2192 J))\n  inverse := Discrete.functor (Discrete.mk \u2218 (e.symm : J \u2192 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 {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (h : Discrete \u03b1 \u224c Discrete \u03b2) : \u03b1 \u2243 \u03b2 where\n  toFun := Discrete.as \u2218 h.functor.obj \u2218 Discrete.mk\n  invFun := Discrete.as \u2218 h.inverse.obj \u2218 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\u2081}\n\nopen Opposite\n\n/-- A discrete category is equivalent to its opposite category. -/\n@[simps! functor_obj_as inverse_obj]\nprotected def opposite (\u03b1 : Type u\u2081) : (Discrete \u03b1)\u1d52\u1d56 \u224c Discrete \u03b1 :=\n  let F : Discrete \u03b1 \u2964 (Discrete \u03b1)\u1d52\u1d56 := Discrete.functor fun x => op (Discrete.mk x)\n  Equivalence.mk F.leftOp F\n  (NatIso.ofComponents (fun \u27e8X\u27e9 => Iso.refl _) <| fun {X Y} \u27e8\u27e8f\u27e9\u27e9 => 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 \u27e8X\u27e9 => 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\u2082} [Category.{v\u2082} C]\n\n@[simp]\ntheorem functor_map_id (F : Discrete J \u2964 C) {j : Discrete J} (f : j \u27f6 j) : F.map f = \ud835\udfd9 (F.obj j) :=\n  by\n  have h : f = \ud835\udfd9 j := by\n    rcases f with \u27e8\u27e8f\u27e9\u27e9\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 {\u03b1 : Type*} {R : \u03b1 \u2192 \u03b1 \u2192 \u03b1 \u2192 Prop}\n\nnamespace list\n\ntheorem chain3_split {a b c d : \u03b1} {l1 l2 : list \u03b1} : \n  chain3 R a b (l1 ++ c :: d :: l2) \u2194\n  chain3 R a b (l1 ++ [c, d]) \u2227 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 : \u03b1} {l1 l2 : list \u03b1} :\n  chain3 R a b (l1 ++ c :: d :: e :: l2) \u2194 \n  chain3 R a b (l1 ++ [c, d]) \u2227 R c d e \u2227 \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 : \u03b1) : chain3' R [a] := trivial\n\n@[simp] theorem chain3'_pair (a b : \u03b1) : chain3' R [a, b] := chain3.nil\n\n@[simp] theorem chain3'_cons {x y z l} : \n  chain3' R (x :: y :: z :: l) \u2194 R x y z \u2227 chain3' R (y :: z :: l) := \nchain3_cons \n\ntheorem chain3'_split {a b : \u03b1}: \u2200 {l1 l2 : list \u03b1},\n  chain3' R (l1 ++ a :: b :: l2) \u2194\n  chain3' R (l1 ++ [a, b]) \u2227 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 : \u03b1} {l1 l2 : list \u03b1} :\n  chain3' R (l1 ++ a :: b :: c :: l2) \u2194\n  chain3' R (l1 ++ [a, b]) \u2227 R a b c \u2227\n  chain3' R (b :: c :: l2) :=\nby rw [chain3'_split, chain3'_cons]\n\ntheorem chain3'.left_of_append {l1 l2 : list \u03b1}\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 \u22a2 h, tauto,\nend\n\ntheorem chain3'.right_of_append {l1 l2 : list \u03b1}\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 \u22a2 h', exact h'.right,\nend\n\ntheorem chain3'.infix {l\u2081 l : list \u03b1 } \n  (h : chain3' R l) (h' : l\u2081 <:+: l) : chain3' R l\u2081 :=\nby { rcases h' with \u27e8l\u2082, l\u2083, rfl\u27e9, exact h.left_of_append.right_of_append }\n\ntheorem chain3'.suffix \n  {l\u2081 l : list \u03b1} (h : chain3' R l) (h' : l\u2081 <:+ l) : chain3' R l\u2081 := \n  h.infix h'.is_infix\n\ntheorem chain3'.prefix \n  {l\u2081 l : list \u03b1} (h : chain3' R l) (h' : l\u2081 <+: l) : chain3' R l\u2081 := \n  h.infix h'.is_infix\n\ntheorem chain3'.drop \n  {l : list \u03b1} (h : chain3' R l) (n : \u2115) : chain3' R (drop n l) := \n  h.suffix (drop_suffix _ _)\n\ntheorem chain3'.init \n  {l : list \u03b1} (h : chain3' R l) : chain3' R l.init := \n  h.prefix l.init_prefix\n\ntheorem chain3'.take \n  {l : list \u03b1} (h : chain3' R l) (n : \u2115) : chain3' R (take n l) := \n  h.prefix (take_prefix _ _)\n\ntheorem chain3'.tail \n  {l : list \u03b1} (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 \u22a2 h, exact h.right,\nend \n\ntheorem chain3'_mirror [linear_order \u03b1] {l : list \u03b1} : \n  chain3' (mirror3 R) l.mirror \u2194 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 \u2190ih,\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 (\u03b1 : Sort*) := (succ : \u03b1 \u2192 \u03b1)\n\nprefix `Succ `:85 := has_succ.succ\n\ndef numeral {\u03b1 : Type*} [has_zero \u03b1] [has_succ \u03b1] : \u2115 \u2192 \u03b1\n| 0       := 0\n| (n + 1) := Succ (numeral n)\n\ninstance numeral_has_one {\u03b1 : Type*} [has_zero \u03b1] [has_succ \u03b1] : has_one \u03b1 := \u27e8Succ 0\u27e9\n\nlemma numeral_one_def  {\u03b1 : Type*} [has_zero \u03b1] [has_succ \u03b1] : (1 : \u03b1) = Succ 0 := rfl \n\n@[notation_class] class has_eq (\u03b1 : out_param (Sort*)) (\u03b2 : Sort*) := (eq : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n\n@[notation_class] class has_prec (\u03b1 : out_param (Sort*)) (\u03b2 : Sort*) := (prec : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n\n@[notation_class] class has_preceq (\u03b1 : out_param (Sort*)) (\u03b2 : Sort*) := (preceq : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n\n@[notation_class] class has_elem (\u03b1 : out_param (Sort*)) (\u03b2 : Sort*) := (elem : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n\n@[notation_class] class has_negation (\u03b1 : Sort*) := (neg : \u03b1 \u2192 \u03b1)\n\n@[notation_class] class has_arrow (\u03b1 : Sort*) := (arrow : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n\n@[notation_class] class has_univ_quantifier (\u03b1 : Sort*) := (univ : \u03b1 \u2192 \u03b1)\n\n@[notation_class] class has_exists_quantifier (\u03b1 : Sort*) := (ex : \u03b1 \u2192 \u03b1)\n\n@[notation_class] class has_univ_quantifier' (\u03b1 : \u2115 \u2192 Sort*) := (univ : \u03a0 {n}, \u03b1 (n + 1) \u2192 \u03b1 n)\n\n@[notation_class] class has_exists_quantifier' (\u03b1 : \u2115 \u2192 Sort*) := (ex : \u03a0 {n}, \u03b1 (n + 1) \u2192 \u03b1 n)\n\nlocalized \"infix (name := has_eq.eq) ` =' `:50 := has_eq.eq\" in logic_symbol\nlocalized \"infix (name := has_prec.prec) ` \u227a `:50 := has_prec.prec\" in logic_symbol\nlocalized \"infix (name := has_preceq.preceq) ` \u227c `:50 := has_preceq.preceq\" in logic_symbol\nlocalized \"infix (name := has_elem.elem) ` \u220a `:50 := has_elem.elem\" in logic_symbol\nlocalized \"prefix (name := has_negation.neg) `\u223c`:75 := has_negation.neg\" in logic_symbol\nlocalized \"infixr (name := has_arrow.arrow) ` \u27f6 `:60 := has_arrow.arrow\" in logic_symbol\nlocalized \"prefix (name := has_univ_quantifier.univ) `\u2200.`:64 := has_univ_quantifier.univ\" in logic_symbol\nlocalized \"prefix (name := has_exists_quantifier.ex) `\u2203.`:64 := has_exists_quantifier.ex\" in logic_symbol\nlocalized \"prefix (name := has_univ_quantifier'.univ) `\u2200'`:64 := has_univ_quantifier'.univ\" in logic_symbol\nlocalized \"prefix (name := has_exists_quantifier'.ex) `\u2203'`:64 := has_exists_quantifier'.ex\" in logic_symbol\nopen_locale logic_symbol\n\nsection has_univ_quantifier'\nvariables  {\u03b1 : \u2115 \u2192 Sort*} [has_univ_quantifier' \u03b1]\n\ndef nforall {n} : \u03a0 (k), \u03b1 (n + k) \u2192 \u03b1 n\n| 0     a := a\n| (k+1) a := nforall _ \u2200'a\n\n@[simp] def universal_closure : \u03a0 {n}, \u03b1 n \u2192 \u03b1 0\n| 0     a := a\n| (k+1) a := universal_closure \u2200'a\n\nlocalized \"notation (name := universal_closure) `\u2200'*`:64 := universal_closure\" in logic_symbol\n\nend has_univ_quantifier'\n\nsection has_exists_quantifier'\nvariables {\u03b1 : \u2115 \u2192 Sort*} [has_exists_quantifier' \u03b1]\n\ndef nexists {n} : \u03a0 (k), \u03b1 (n + k) \u2192 \u03b1 n\n| 0     a := a\n| (k+1) a := nexists _ \u2203'a\n\n@[simp] def exists_close : \u03a0 {n}, \u03b1 n \u2192 \u03b1 0\n| 0     a := a\n| (k+1) a := exists_close \u2203'a\n\nlocalized \"notation (name := exists_close) `\u2203'*`:64 := exists_close\" in logic_symbol\n\nend has_exists_quantifier'\n\n@[reducible] def has_eq.ineq {\u03b1 : out_param (Sort*)} {\u03b2 : Sort*}\n  [has_eq \u03b1 \u03b2] [has_negation \u03b2] (a b : \u03b1) : \u03b2 := \u223c(a =' b)\n\nlocalized \"infix (name := has_eq.ineq) ` \u2260' `:50 := has_eq.ineq\" in logic_symbol\n\n@[notation_class] class has_turnstile (\u03b1 : Sort*) := (turnstile : set \u03b1 \u2192 \u03b1 \u2192 Prop)\n\ninfix ` \u22a2 `:45 := has_turnstile.turnstile\nnotation T ` \u22a2{`:45 \u03b2 `} `:45 p := has_turnstile.turnstile T \u03b2 p\n\nnamespace has_turnstile\nvariables {\u03b1 : Type*} [has_turnstile \u03b1]\n\ndef turnstile_set (T : set \u03b1) (\u0393 : set \u03b1) : Prop := \u2200 p \u2208 \u0393, T \u22a2 p\n\ninfix ` \u22a2* `:45 := turnstile_set\n\nend has_turnstile\n\n@[notation_class] class has_Longarrow (\u03b1 : Sort*) := (Longarrow : set \u03b1 \u2192 \u03b1 \u2192 Type u)\n\ninfix ` \u27f9 `:45 := has_Longarrow.Longarrow\n\ndef has_arrow.lrarrow {\u03b1 : Type*} [has_arrow \u03b1] [has_inf \u03b1] (a b : \u03b1) : \u03b1 := (a \u27f6 b) \u2293 (b \u27f6 a)\n\nlocalized \"infix (name := has_arrow.lrarrow) ` \u27f7 `:59 := has_arrow.lrarrow\" in logic_symbol\n\nlemma lrarrow_def {\u03b1 : Type*} [has_arrow \u03b1] [has_inf \u03b1] (a b : \u03b1) : a \u27f7 b = (a \u27f6 b) \u2293 (b \u27f6 a) := rfl\n\n@[notation_class] class has_double_turnstile (\u03b1 : Sort*) (\u03b2 : Sort*) := (double_turnstile : \u03b1 \u2192 \u03b2 \u2192 Prop)\n\ninfix ` \u22a7 ` :55 := has_double_turnstile.double_turnstile\n\nnamespace has_double_turnstile\nvariables {\u03b1 : Type*} {\u03b2 : Type*} [has_double_turnstile \u03b1 \u03b2]\n\ndef double_turnstile_set (T : \u03b1) (S : set \u03b2) : Prop := \u2200 p \u2208 S, T \u22a7 p\n\ninfix ` \u22a7* `: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 \u2192 F) (imply : F \u2192 F \u2192 F)\n\ndef logic_simbol_default (F : Type*) (top : F) (neg : F \u2192 F) (imply : F \u2192 F \u2192 F) : has_logic_symbol F :=\n{ bot := neg top,\n  top := top,\n  sup := \u03bb p q, imply (neg p) q,\n  inf := \u03bb 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 \u2192 F) (and : F \u2192 F \u2192 F) (or : F \u2192 F \u2192 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 := \u03bb 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\u2081 u\u2082 u\u2083 v\u2081 v\u2082 v\u2083 u\u2084 v\u2084 u\u2085 v\u2085 \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\n/--\nIf `\u03b1 : G \u27f6 H` then\n`whisker_left F \u03b1 : (F \u22d9 G) \u27f6 (F \u22d9 H)` has components `\u03b1.app (F.obj X)`.\n-/\n@[simp] theorem whisker_left_app {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u27f6 H) (X : C) : nat_trans.app (whisker_left F \u03b1) X = nat_trans.app \u03b1 (functor.obj F X) :=\n  Eq.refl (nat_trans.app (whisker_left F \u03b1) X)\n\n/--\nIf `\u03b1 : G \u27f6 H` then\n`whisker_right \u03b1 F : (G \u22d9 F) \u27f6 (G \u22d9 F)` has components `F.map (\u03b1.app X)`.\n-/\ndef whisker_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u27f6 H) (F : D \u2964 E) : G \u22d9 F \u27f6 H \u22d9 F :=\n  nat_trans.mk fun (X : C) => functor.map F (nat_trans.app \u03b1 X)\n\n/--\nLeft-composition gives a functor `(C \u2964 D) \u2964 ((D \u2964 E) \u2964 (C \u2964 E))`.\n\n`(whiskering_lift.obj F).obj G` is `F \u22d9 G`, and\n`(whiskering_lift.obj F).map \u03b1` is `whisker_left F \u03b1`.\n-/\ndef whiskering_left (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (E : Type u\u2083) [category E] : (C \u2964 D) \u2964 (D \u2964 E) \u2964 C \u2964 E :=\n  functor.mk (fun (F : C \u2964 D) => functor.mk (fun (G : D \u2964 E) => F \u22d9 G) fun (G H : D \u2964 E) (\u03b1 : G \u27f6 H) => whisker_left F \u03b1)\n    fun (F G : C \u2964 D) (\u03c4 : F \u27f6 G) =>\n      nat_trans.mk fun (H : D \u2964 E) => nat_trans.mk fun (c : C) => functor.map H (nat_trans.app \u03c4 c)\n\n/--\nRight-composition gives a functor `(D \u2964 E) \u2964 ((C \u2964 D) \u2964 (C \u2964 E))`.\n\n`(whiskering_right.obj H).obj F` is `F \u22d9 H`, and\n`(whiskering_right.obj H).map \u03b1` is `whisker_right \u03b1 H`.\n-/\n@[simp] theorem whiskering_right_obj_map (C : Type u\u2081) [category C] (D : Type u\u2082) [category D] (E : Type u\u2083) [category E] (H : D \u2964 E) (_x : C \u2964 D) : \u2200 (_x_1 : C \u2964 D) (\u03b1 : _x \u27f6 _x_1), functor.map (functor.obj (whiskering_right C D E) H) \u03b1 = whisker_right \u03b1 H :=\n  fun (_x_1 : C \u2964 D) (\u03b1 : _x \u27f6 _x_1) => Eq.refl (functor.map (functor.obj (whiskering_right C D E) H) \u03b1)\n\n@[simp] theorem whisker_left_id {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} : whisker_left F (nat_trans.id G) = nat_trans.id (F \u22d9 G) :=\n  rfl\n\n@[simp] theorem whisker_left_id' {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} : whisker_left F \ud835\udfd9 = \ud835\udfd9 :=\n  rfl\n\n@[simp] theorem whisker_right_id {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {G : C \u2964 D} (F : D \u2964 E) : whisker_right (nat_trans.id G) F = nat_trans.id (G \u22d9 F) :=\n  functor.map_id (functor.obj (whiskering_right C D E) F) G\n\n@[simp] theorem whisker_right_id' {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {G : C \u2964 D} (F : D \u2964 E) : whisker_right \ud835\udfd9 F = \ud835\udfd9 :=\n  functor.map_id (functor.obj (whiskering_right C D E) F) G\n\n@[simp] theorem whisker_left_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} {K : D \u2964 E} (\u03b1 : G \u27f6 H) (\u03b2 : H \u27f6 K) : whisker_left F (\u03b1 \u226b \u03b2) = whisker_left F \u03b1 \u226b whisker_left F \u03b2 :=\n  rfl\n\n@[simp] theorem whisker_right_comp {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} {K : C \u2964 D} (\u03b1 : G \u27f6 H) (\u03b2 : H \u27f6 K) (F : D \u2964 E) : whisker_right (\u03b1 \u226b \u03b2) F = whisker_right \u03b1 F \u226b whisker_right \u03b2 F :=\n  functor.map_comp (functor.obj (whiskering_right C D E) F) \u03b1 \u03b2\n\n/--\nIf `\u03b1 : G \u2245 H` is a natural isomorphism then\n`iso_whisker_left F \u03b1 : (F \u22d9 G) \u2245 (F \u22d9 H)` has components `\u03b1.app (F.obj X)`.\n-/\ndef iso_whisker_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u2245 H) : F \u22d9 G \u2245 F \u22d9 H :=\n  functor.map_iso (functor.obj (whiskering_left C D E) F) \u03b1\n\n@[simp] theorem iso_whisker_left_hom {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u2245 H) : iso.hom (iso_whisker_left F \u03b1) = whisker_left F (iso.hom \u03b1) :=\n  rfl\n\n@[simp] theorem iso_whisker_left_inv {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u2245 H) : iso.inv (iso_whisker_left F \u03b1) = whisker_left F (iso.inv \u03b1) :=\n  rfl\n\n/--\nIf `\u03b1 : G \u2245 H` then\n`iso_whisker_right \u03b1 F : (G \u22d9 F) \u2245 (G \u22d9 F)` has components `F.map_iso (\u03b1.app X)`.\n-/\ndef iso_whisker_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) : G \u22d9 F \u2245 H \u22d9 F :=\n  functor.map_iso (functor.obj (whiskering_right C D E) F) \u03b1\n\n@[simp] theorem iso_whisker_right_hom {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) : iso.hom (iso_whisker_right \u03b1 F) = whisker_right (iso.hom \u03b1) F :=\n  rfl\n\n@[simp] theorem iso_whisker_right_inv {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u2245 H) (F : D \u2964 E) : iso.inv (iso_whisker_right \u03b1 F) = whisker_right (iso.inv \u03b1) F :=\n  rfl\n\nprotected instance is_iso_whisker_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] (F : C \u2964 D) {G : D \u2964 E} {H : D \u2964 E} (\u03b1 : G \u27f6 H) [is_iso \u03b1] : is_iso (whisker_left F \u03b1) :=\n  is_iso.mk (iso.inv (iso_whisker_left F (as_iso \u03b1)))\n\nprotected instance is_iso_whisker_right {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u27f6 H) (F : D \u2964 E) [is_iso \u03b1] : is_iso (whisker_right \u03b1 F) :=\n  is_iso.mk (iso.inv (iso_whisker_right (as_iso \u03b1) F))\n\n@[simp] theorem whisker_left_twice {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {B : Type u\u2084} [category B] (F : B \u2964 C) (G : C \u2964 D) {H : D \u2964 E} {K : D \u2964 E} (\u03b1 : H \u27f6 K) : whisker_left F (whisker_left G \u03b1) = whisker_left (F \u22d9 G) \u03b1 :=\n  rfl\n\n@[simp] theorem whisker_right_twice {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {B : Type u\u2084} [category B] {H : B \u2964 C} {K : B \u2964 C} (F : C \u2964 D) (G : D \u2964 E) (\u03b1 : H \u27f6 K) : whisker_right (whisker_right \u03b1 F) G = whisker_right \u03b1 (F \u22d9 G) :=\n  rfl\n\ntheorem whisker_right_left {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {E : Type u\u2083} [category E] {B : Type u\u2084} [category B] (F : B \u2964 C) {G : C \u2964 D} {H : C \u2964 D} (\u03b1 : G \u27f6 H) (K : D \u2964 E) : whisker_right (whisker_left F \u03b1) K = whisker_left F (whisker_right \u03b1 K) :=\n  rfl\n\nnamespace functor\n\n\n/--\nThe left unitor, a natural isomorphism `((\ud835\udfed _) \u22d9 F) \u2245 F`.\n-/\n@[simp] theorem left_unitor_hom_app {A : Type u\u2081} [category A] {B : Type u\u2082} [category B] (F : A \u2964 B) (X : A) : nat_trans.app (iso.hom (left_unitor F)) X = \ud835\udfd9 :=\n  Eq.refl (nat_trans.app (iso.hom (left_unitor F)) X)\n\n/--\nThe right unitor, a natural isomorphism `(F \u22d9 (\ud835\udfed B)) \u2245 F`.\n-/\n@[simp] theorem right_unitor_hom_app {A : Type u\u2081} [category A] {B : Type u\u2082} [category B] (F : A \u2964 B) (X : A) : nat_trans.app (iso.hom (right_unitor F)) X = \ud835\udfd9 :=\n  Eq.refl (nat_trans.app (iso.hom (right_unitor F)) X)\n\n/--\nThe associator for functors, a natural isomorphism `((F \u22d9 G) \u22d9 H) \u2245 (F \u22d9 (G \u22d9 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\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083} [category C] {D : Type u\u2084} [category D] (F : A \u2964 B) (G : B \u2964 C) (H : C \u2964 D) (_x : A) : nat_trans.app (iso.inv (associator F G H)) _x = \ud835\udfd9 :=\n  Eq.refl (nat_trans.app (iso.inv (associator F G H)) _x)\n\ntheorem triangle {A : Type u\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083} [category C] (F : A \u2964 B) (G : B \u2964 C) : iso.hom (associator F \ud835\udfed G) \u226b whisker_left F (iso.hom (left_unitor G)) = whisker_right (iso.hom (right_unitor F)) G := sorry\n\ntheorem pentagon {A : Type u\u2081} [category A] {B : Type u\u2082} [category B] {C : Type u\u2083} [category C] {D : Type u\u2084} [category D] {E : Type u\u2085} [category E] (F : A \u2964 B) (G : B \u2964 C) (H : C \u2964 D) (K : D \u2964 E) : whisker_right (iso.hom (associator F G H)) K \u226b\n    iso.hom (associator F (G \u22d9 H) K) \u226b whisker_left F (iso.hom (associator G H K)) =\n  iso.hom (associator (F \u22d9 G) H K) \u226b iso.hom (associator F G (H \u22d9 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 {\u03b1 : Type*} {F : set \u03b1 \u2192 Prop}\n\ndef finite_charactor (P : set \u03b1 \u2192 Prop) : Prop := \u2200 a, P a \u2194 (\u2200 s \u2286 a, s.finite \u2192 P s)\n\nlemma of_ss (H : finite_charactor F) {a} (ha : F a) {b} (ss : b \u2286 a) : F b :=\nbegin\n  have : \u2200 s \u2286 a, s.finite \u2192 F s, from (H a).mp ha,\n  have : \u2200 s \u2286 b, s.finite \u2192 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 \u2205 :=\nof_ss H ha (by simp)\n\nlemma finite_chain_sup (H : finite_charactor F) {c : set (set \u03b1)} (ch : is_chain has_subset.subset c) :\n  \u2200 {d : set (set \u03b1)} (hs : d.finite) (nemp : d.nonempty) (ss : d \u2286 c), \u2203 m \u2208 d, \u22c3\u2080d \u2286 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 : \u2203 (m \u2208 s), \u22c3\u2080 s \u2286 m, from IH nemp (set.subset.trans (by simp) ss),\n    rcases this with \u27e8m, mem, hs\u27e9,\n    have : m \u2286 a \u2228 a \u2286 m, from is_chain.total ch (show m \u2208 c, from ss (by simp[mem])) (show a \u2208 c, from ss (by simp)),\n    rcases this,\n    { refine \u27e8a, by simp, _\u27e9,\n      simp at hs \u22a2, refine \u27e8by refl, \u03bb t ht, set.subset.trans (hs t ht) this\u27e9 },\n    { refine \u27e8m, by simp[mem], _\u27e9,\n      simp at hs \u22a2, refine \u27e8this, hs\u27e9 } },\n  { have : s = \u2205, from set.not_nonempty_iff_eq_empty.mp nemp, rcases this with rfl,\n    refine \u27e8a, by simp\u27e9 }\nend\n\ntheorem exists_maximum (H : finite_charactor F) (a : set \u03b1) (ha : F a) :\n  \u2203 m, F m \u2227 a \u2286 m \u2227 \u2200 s, F s \u2192 m \u2286 s \u2192 s = m :=\nbegin\n  suffices : \u2203 (m : set \u03b1) (H : m \u2208 {x : set \u03b1 | F x}),\n  a \u2286 m \u2227 \u2200 (a : set \u03b1), a \u2208 {x : set \u03b1 | F x} \u2192 m \u2286 a \u2192 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 (\u22c3\u2080 c),\n  { have : \u2200 s \u2286 \u22c3\u2080 c, s.finite \u2192 F s,\n    { rw[set.sUnion_eq_Union], intros s s_ss s_fin,\n      have : \u2203 (d : set (set \u03b1)), d \u2286 c \u2227 d.finite \u2227 s \u2286 \u22c3\u2080 d,\n      { rcases set.finite_subset_Union s_fin s_ss with \u27e8I, I_fin, s_ss\u27e9,  simp at s_ss,\n        refine \u27e8coe '' I, by simp, set.finite.image coe I_fin, by simpa using s_ss\u27e9 },\n      rcases this with \u27e8d, d_ss, d_fin, hs\u27e9,\n      by_cases d_nemp : d.nonempty,\n      { have : \u2203 m \u2208 d, \u22c3\u2080d \u2286 m, from finite_chain_sup H hc d_fin d_nemp d_ss,\n        rcases this with \u27e8m, m_mem, ss_m\u27e9,\n        exact of_ss H (show F m, from hF (d_ss m_mem)) (show s \u2286 m, from set.subset.trans hs ss_m) },\n      { have : d = \u2205, from set.not_nonempty_iff_eq_empty.mp d_nemp, rcases this with rfl,\n        simp at hs, have : s = \u2205, exact set.subset_eq_empty hs rfl, rcases this with rfl,\n        rcases set.nonempty_def.mp nemp with \u27e8x, hx\u27e9, refine empty_of_nonempty H (hF hx) } },\n    refine (H (\u22c3\u2080 c)).mpr this },\n  refine \u27e8\u22c3\u2080 c, this, \u03bb _, set.subset_sUnion_of_mem\u27e9\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 \u2964 J \u2964 CondensedSet.{u})\n\nnoncomputable\ndef colim_to_lim :\n  colimit (limit F) \u27f6 limit (colimit F.flip) :=\ncolimit.desc (limit F) \u27e8limit (colimit F.flip),\n{ app := \u03bb j, limit.lift (colimit F.flip) \u27e8(limit F).obj j,\n  { app := \u03bb k, (limit.\u03c0 F k).app j \u226b (colimit.\u03b9 F.flip j).app k,\n    naturality' := \u03bb X Y f, by begin\n      erw [functor.const_obj_map, category.id_comp, category.assoc],\n      rw [\u2190 nat_trans.naturality, \u2190 category.assoc],\n      simp only [functor.flip_obj_map, \u2190 nat_trans.comp_app, limit.w],\n    end }\u27e9,\n  naturality' := \u03bb 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_\u03c0, nat_trans.naturality_assoc],\n    simp only [\u2190 functor.flip_map_app, \u2190 nat_trans.comp_app, colimit.w],\n  end }\u27e9\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) \u2245 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 \u2964 D) (F : J \u2964 C)\n  [has_limit F] [has_limit (F \u22d9 G)] [preserves_limit F G] :\n  G.obj (limit F) \u2245 limit (F \u22d9 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_\u03c0 {J C D : Type*}\n  [small_category J] [category C] [category D]\n  (G : C \u2964 D) (F : J \u2964 C)\n  [has_limit F] [has_limit (F \u22d9 G)] [preserves_limit F G]\n  (j : J) :\n  (G.map_limit F).hom \u226b limit.\u03c0 (F \u22d9 G) j = G.map (limit.\u03c0 F j) :=\nby simp only [category_theory.functor.map_limit, functor.map_cone_\u03c0_app,\n    limit.cone_point_unique_up_to_iso_hom_comp, limit.cone_\u03c0]\n\ndef _root_.category_theory.functor.map_colimit {J C D : Type*}\n  [small_category J] [category C] [category D]\n  (G : C \u2964 D) (F : J \u2964 C)\n  [has_colimit F] [has_colimit (F \u22d9 G)] [preserves_colimit F G] :\n  G.obj (colimit F) \u2245 colimit (F \u22d9 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.\u03b9_map_colimit_inv {J C D : Type*}\n  [small_category J] [category C] [category D]\n  (G : C \u2964 D) (F : J \u2964 C)\n  [has_colimit F] [has_colimit (F \u22d9 G)] [preserves_colimit F G]\n  (j : J) :\n  colimit.\u03b9 (F \u22d9 G) j \u226b (G.map_colimit F).inv = G.map (colimit.\u03b9 F j) :=\nby simp only [category_theory.functor.map_colimit, functor.map_cocone_\u03b9_app,\n    colimit.comp_cocone_point_unique_up_to_iso_inv, colimit.cocone_\u03b9]\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 \u2964 K \u2964 C) (G : C \u2964 D) [has_limit F]\n  [H : \u2200 k, has_limit (F.flip.obj k)] [\u2200 k, preserves_limit (F.flip.obj k) G]\n  [\u2200 k, preserves_limit F ((category_theory.evaluation K C).obj k)] :\n  limit F \u22d9 G \u2245 F.flip \u22d9 ((whiskering_right _ _ _).obj G) \u22d9 lim :=\nbegin\n  refine nat_iso.of_components _ _,\n  { intro k,\n    refine G.map_iso _ \u226a\u226b G.map_limit _,\n    letI : has_limit (F \u22d9 (category_theory.evaluation K C).obj k) := H k,\n    refine ((category_theory.evaluation _ _).obj k).map_limit _ \u226a\u226b _,\n    refine limits.lim.map_iso _,\n    exact iso.refl _ },\n  { intros k\u2081 k\u2082 f,\n    ext j,\n    dsimp,\n    simp only [functor.map_comp, category_theory.functor.map_limit_hom_\u03c0, category.assoc,\n      lim_map_\u03c0, whisker_right_app, functor.flip_map_app,\n      category_theory.functor.map_limit_hom_\u03c0_assoc],\n    simp only [\u2190 functor.map_comp, category.assoc], congr' 1,\n    simp only [lim_map_\u03c0, lim_map_\u03c0_assoc, category_theory.functor.map_limit_hom_\u03c0_assoc,\n      category_theory.functor.map_limit_hom_\u03c0],\n    erw [\u2190 evaluation_map_app K C, \u2190 category.assoc, \u2190 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 \u2964 K \u2964 C) (G : C \u2964 D) [has_colimit F]\n  [H : \u2200 k, has_colimit (F.flip.obj k)] [\u2200 k, preserves_colimit (F.flip.obj k) G]\n  [\u2200 k, preserves_colimit F ((category_theory.evaluation K C).obj k)] :\n  colimit F \u22d9 G \u2245 F.flip \u22d9 ((whiskering_right _ _ _).obj G) \u22d9 colim :=\nbegin\n  refine nat_iso.of_components _ _,\n  { intro k,\n    refine G.map_iso _ \u226a\u226b G.map_colimit _,\n    letI : has_colimit (F \u22d9 (category_theory.evaluation K C).obj k) := H k,\n    refine ((category_theory.evaluation _ _).obj k).map_colimit _ \u226a\u226b _,\n    refine colim.map_iso _,\n    exact iso.refl _ },\n  { intros k\u2081 k\u2082 f,\n    rw [\u2190 iso.inv_comp_eq, \u2190 category.assoc, \u2190 iso.eq_comp_inv],\n    ext j,\n    dsimp,\n    simp only [category.assoc, category_theory.functor.\u03b9_map_colimit_inv_assoc, colimit.\u03b9_map_assoc,\n      whisker_right_app, functor.flip_map_app],\n    simp only [\u2190 functor.map_comp, category.assoc], congr' 1,\n    simp only [colimit.\u03b9_map_assoc, category_theory.functor.\u03b9_map_colimit_inv_assoc,\n      category_theory.functor.\u03b9_map_colimit_inv],\n    rw [\u2190 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\u2081 (S : Profinite.{u}\u1d52\u1d56) :\n  (colimit (limit F)).val.obj S \u2245 colimit (curry.obj (category_theory.prod.swap J K \u22d9\n    (uncurry.{u+1 u+1}.obj F \u22d9\n    (CondensedSet_to_presheaf.{u} \u22d9 (category_theory.evaluation.{u u+1 u+1 u+2} Profinite.{u}\u1d52\u1d56 (Type (u+1))).obj S))) \u22d9 lim) :=\nbegin\n  let VS := CondensedSet_to_presheaf.{u} \u22d9 (category_theory.evaluation.{u u+1 u+1 u+2} Profinite.{u}\u1d52\u1d56 (Type (u+1))).obj S,\n  refine VS.map_colimit (limit F) \u226a\u226b _,\n  refine colim.map_iso _,\n  refine limit_comp_iso _ _ \u226a\u226b _,\n  refine (functor.associator _ _ _).symm \u226a\u226b _,\n  refine ((whiskering_right _ _ _).obj lim).map_iso _,\n  refine nat_iso.of_components _ _,\n  { intro k, refine nat_iso.of_components (\u03bb 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\u2082 (S : Profinite.{u}\u1d52\u1d56) :\n  (limit (colimit F.flip)).val.obj S \u2245\n  limit (curry.obj (uncurry.{u+1 u+1}.obj F \u22d9\n    (CondensedSet_to_presheaf.{u} \u22d9 (category_theory.evaluation.{u u+1 u+1 u+2} Profinite.{u}\u1d52\u1d56 (Type (u+1))).obj S)) \u22d9 colim) :=\nbegin\n  let VS := CondensedSet_to_presheaf.{u} \u22d9 (category_theory.evaluation.{u u+1 u+1 u+2} Profinite.{u}\u1d52\u1d56 (Type (u+1))).obj S,\n  refine VS.map_limit (colimit F.flip) \u226a\u226b _,\n  refine limits.lim.map_iso _,\n  refine colimit_comp_iso _ _ \u226a\u226b _,\n  refine (functor.associator _ _ _).symm \u226a\u226b _,\n  refine ((whiskering_right _ _ _).obj colim).map_iso _,\n  refine nat_iso.of_components _ _,\n  { intro k, refine nat_iso.of_components (\u03bb 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}\u1d52\u1d56) :\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\u2081 F S).hom \u226b colimit_limit_to_limit_colimit _ \u226b (is_iso_colim_to_lim_component_e\u2082 F S).inv,\n  { rw [this, is_iso_iff_is_iso_comp_left, is_iso_iff_is_iso_comp_right], apply_instance },\n  rw [\u2190 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\u2081, is_iso_colim_to_lim_component_e\u2082],\n  simp only [category.assoc, limit.lift_\u03c0, colimit.\u03b9_desc, colimit.\u03b9_map_assoc,\n    category_theory.functor.\u03b9_map_colimit_inv_assoc,\n    category_theory.functor.map_limit_hom_\u03c0_assoc,\n    lim_map_\u03c0, 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 [\u2190 functor.map_iso_hom, \u2190 functor.map_iso_inv, iso.inv_comp_eq],\n  simp only [\u2190 category.assoc, \u2190 iso.eq_comp_inv],\n  simp only [category.assoc, functor.map_iso_hom, functor.map_iso_inv,\n    colimit.\u03b9_map_assoc, lim_map_eq_lim_map, lim_map_\u03c0_assoc,\n    nat_iso.of_components_hom_app, nat_iso.of_components_inv_app],\n  conv_rhs\n  { erw [category_theory.functor.\u03b9_map_colimit_inv,\n      category_theory.functor.map_limit_hom_\u03c0_assoc,\n      iso.refl_hom, iso.refl_inv, category.id_comp, category.id_comp], },\n  simp only [\u2190 nat_trans.comp_app, \u2190 Sheaf.hom.comp_val,\n    CondensedSet_to_presheaf_map, evaluation_obj_map, functor.comp_map,\n    \u2190 category_theory.nat_trans.comp_app_assoc, \u2190 category_theory.Sheaf.hom.comp_val_assoc],\n  simp only [colim_to_lim, colimit.\u03b9_desc_assoc, limit.lift_\u03c0_assoc, category.assoc],\n  congr' 2,\n  simp only [\u2190 lim_map_eq_lim_map, \u2190 functor.map_iso_hom, \u2190 functor.map_iso_inv, iso.inv_comp_eq],\n  simp only [\u2190 category.assoc, \u2190 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_\u03c0_assoc, colimit.\u03b9_map_assoc,\n    category_theory.functor.\u03b9_map_colimit_inv, category_theory.functor.map_limit_hom_\u03c0_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 (\u03b1 : Type (u+1))\n  (X : \u03b1 \u2192 J \u2964 CondensedSet.{u}) (j) :\n  (\u220f X).obj j \u2245 \u220f (\u03bb i, (X i).obj j) :=\npreserves_limit_iso ((category_theory.evaluation _ _).obj j) _ \u226a\u226b\nhas_limit.iso_of_nat_iso (discrete.nat_iso $ \u03bb i, iso.refl _)\n\ndef is_colimit_pow_functor_map_cocone_aux (\u03b1 : Type (u+1)) [fintype \u03b1] (F : J \u2964 CondensedSet)\n  (S : cocone (F \u22d9 pow_functor CondensedSet \u03b1)) :\n  cocone (\u220f \u03bb (i : \u03b1), F) :=\n{ X := S.X,\n  \u03b9 :=\n  { app := \u03bb j, begin\n      refine (prod_eval_iso _ _ _).hom \u226b _,\n      refine S.\u03b9.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 \u2190 S.w f,\n      simp only [\u2190 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_\u03c0,\n        discrete.nat_iso_hom_app, preserves_limits_iso_hom_\u03c0_assoc,\n        evaluation_obj_map, nat_trans.naturality_assoc, lim_map_\u03c0, discrete.nat_trans_app,\n        has_limit.iso_of_nat_iso_hom_\u03c0_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) \u2245 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 (\u03b1 : Type (u+1)) [fintype \u03b1] (F : J \u2964 CondensedSet.{u}) :\n  colimit (\u220f \u03bb i : \u03b1, F) \u2245 \u220f (\u03bb i : \u03b1, colimit F) :=\ncolimit_limit_iso_limit_colimit (discrete.functor $ \u03bb i : \u03b1, F) \u226a\u226b\nhas_limit.iso_of_nat_iso (discrete.nat_iso $ \u03bb i,\nbegin\n  refine (preserves_colimit_iso ((category_theory.evaluation _ _).obj i) _) \u226a\u226b _,\n  refine has_colimit.iso_of_nat_iso _,\n  refine nat_iso.of_components (\u03bb 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 (\u03b1 : Type (u+1)) [fintype \u03b1] (F : J \u2964 CondensedSet) :\n  is_colimit ((pow_functor CondensedSet \u03b1).map_cocone (colimit.cocone F)) :=\n{ desc := \u03bb S, (colimit_pow_iso \u03b1 F).inv \u226b\n    colimit.desc (\u220f \u03bb (i : \u03b1), F) (is_colimit_pow_functor_map_cocone_aux \u03b1 F S),\n  fac' := begin\n    intros S j, dsimp,  simp only [\u2190 category.assoc], let t := _, change t \u226b _ = _,\n    have ht : t = (prod_eval_iso _ _ _).inv \u226b colimit.\u03b9 _ j,\n    { rw iso.eq_inv_comp,\n      dsimp [t], rw [\u2190 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.\u03b9_desc_assoc, has_limit.lift_iso_of_nat_iso_hom],\n      apply limit.hom_ext, intros k,\n      simp only [category.assoc, lim_map_\u03c0, discrete.nat_trans_app,\n        has_limit.iso_of_nat_iso_hom_\u03c0_assoc, discrete.nat_iso_hom_app,\n        preserves_limits_iso_hom_\u03c0_assoc, evaluation_obj_map, limit.lift_\u03c0,\n        cones.postcompose_obj_\u03c0, 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 \u03b1) CondensedSet).obj k) _).fac_assoc,\n      erw colimit.\u03b9_desc, refl },\n    rw [ht, category.assoc, colimit.\u03b9_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.\u03b9_desc],\n    erw colimit.\u03b9_desc_assoc, dsimp [is_colimit_pow_functor_map_cocone_aux],\n    simp_rw [\u2190 hm, \u2190 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_\u03c0, cones.postcompose_obj_\u03c0,\n      nat_trans.comp_app, discrete.nat_iso_hom_app, iso.trans_hom, category.assoc, lim_map_\u03c0,\n      discrete.nat_trans_app, has_limit.iso_of_nat_iso_hom_\u03c0_assoc,\n      preserves_limits_iso_hom_\u03c0_assoc, evaluation_obj_map],\n    erw (is_colimit_of_preserves ((category_theory.evaluation\n      (discrete \u03b1) CondensedSet).obj k) _).fac_assoc,\n    erw colimit.\u03b9_desc,\n    dsimp, simp,\n  end }\n\n-- Filtered colimits commute with finite products in condensed sets\nnoncomputable\ninstance pow_functor_preserves_filtered_colimits (\u03b1 : Type (u+1)) [fintype \u03b1] :\n  preserves_filtered_colimits\n  (pow_functor CondensedSet.{u} \u03b1) :=\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\u2082 v\u2082 \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 \u2245 Y` : same as `iso X Y`;\n- `\u03b1 \u226a\u226b \u03b2` : 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 \u27f6 Y\n  inv : Y \u27f6 X\n  hom_inv_id' :\n    autoParam (hom \u226b inv = \ud835\udfd9)\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 \u226b hom = \ud835\udfd9)\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 \u226b iso.inv c = \ud835\udfd9 :=\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 \u226b iso.hom c = \ud835\udfd9 :=\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 \u27f6 X') : iso.hom c \u226b iso.inv c \u226b f' = f' :=\n  sorry\n\ninfixr:10 \" \u2245 \" => Mathlib.category_theory.iso\n\nnamespace iso\n\n\ntheorem ext {C : Type u} [category C] {X : C} {Y : C} {\u03b1 : X \u2245 Y} {\u03b2 : X \u2245 Y} (w : hom \u03b1 = hom \u03b2) :\n    \u03b1 = \u03b2 :=\n  sorry\n\n/-- Inverse isomorphism. -/\ndef symm {C : Type u} [category C] {X : C} {Y : C} (I : X \u2245 Y) : Y \u2245 X := mk (inv I) (hom I)\n\n@[simp] theorem symm_hom {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) :\n    hom (symm \u03b1) = inv \u03b1 :=\n  rfl\n\n@[simp] theorem symm_inv {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) :\n    inv (symm \u03b1) = hom \u03b1 :=\n  rfl\n\n@[simp] theorem symm_mk {C : Type u} [category C] {X : C} {Y : C} (hom : X \u27f6 Y) (inv : Y \u27f6 X)\n    (hom_inv_id : hom \u226b inv = \ud835\udfd9) (inv_hom_id : inv \u226b hom = \ud835\udfd9) : 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} (\u03b1 : X \u2245 Y) :\n    symm (symm \u03b1) = \u03b1 :=\n  sorry\n\n@[simp] theorem symm_eq_iff {C : Type u} [category C] {X : C} {Y : C} {\u03b1 : X \u2245 Y} {\u03b2 : X \u2245 Y} :\n    symm \u03b1 = symm \u03b2 \u2194 \u03b1 = \u03b2 :=\n  { mp := fun (h : symm \u03b1 = symm \u03b2) => symm_symm_eq \u03b1 \u25b8 symm_symm_eq \u03b2 \u25b8 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) = \ud835\udfd9 :=\n  Eq.refl (inv (refl X))\n\nprotected instance inhabited {C : Type u} [category C] {X : C} : Inhabited (X \u2245 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} (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 Z) : X \u2245 Z :=\n  mk (hom \u03b1 \u226b hom \u03b2) (inv \u03b2 \u226b inv \u03b1)\n\ninfixr:80 \" \u226a\u226b \" => Mathlib.category_theory.iso.trans\n\n@[simp] theorem trans_mk {C : Type u} [category C] {X : C} {Y : C} {Z : C} (hom : X \u27f6 Y)\n    (inv : Y \u27f6 X) (hom_inv_id : hom \u226b inv = \ud835\udfd9) (inv_hom_id : inv \u226b hom = \ud835\udfd9) (hom' : Y \u27f6 Z)\n    (inv' : Z \u27f6 Y) (hom_inv_id' : hom' \u226b inv' = \ud835\udfd9) (inv_hom_id' : inv' \u226b hom' = \ud835\udfd9)\n    (hom_inv_id'' : (hom \u226b hom') \u226b inv' \u226b inv = \ud835\udfd9) (inv_hom_id'' : (inv' \u226b inv) \u226b hom \u226b hom' = \ud835\udfd9) :\n    mk hom inv \u226a\u226b mk hom' inv' = mk (hom \u226b hom') (inv' \u226b inv) :=\n  rfl\n\n@[simp] theorem trans_symm {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u2245 Y)\n    (\u03b2 : Y \u2245 Z) : symm (\u03b1 \u226a\u226b \u03b2) = symm \u03b2 \u226a\u226b symm \u03b1 :=\n  rfl\n\n@[simp] theorem trans_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} {Z' : C} (\u03b1 : X \u2245 Y)\n    (\u03b2 : Y \u2245 Z) (\u03b3 : Z \u2245 Z') : (\u03b1 \u226a\u226b \u03b2) \u226a\u226b \u03b3 = \u03b1 \u226a\u226b \u03b2 \u226a\u226b \u03b3 :=\n  sorry\n\n@[simp] theorem refl_trans {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) :\n    refl X \u226a\u226b \u03b1 = \u03b1 :=\n  ext (category.id_comp (hom \u03b1))\n\n@[simp] theorem trans_refl {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) :\n    \u03b1 \u226a\u226b refl Y = \u03b1 :=\n  ext (category.comp_id (hom \u03b1))\n\n@[simp] theorem symm_self_id {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) :\n    symm \u03b1 \u226a\u226b \u03b1 = refl Y :=\n  ext (inv_hom_id \u03b1)\n\n@[simp] theorem self_symm_id {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) :\n    \u03b1 \u226a\u226b symm \u03b1 = refl X :=\n  ext (hom_inv_id \u03b1)\n\n@[simp] theorem symm_self_id_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u2245 Y)\n    (\u03b2 : Y \u2245 Z) : symm \u03b1 \u226a\u226b \u03b1 \u226a\u226b \u03b2 = \u03b2 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (symm \u03b1 \u226a\u226b \u03b1 \u226a\u226b \u03b2 = \u03b2)) (Eq.symm (trans_assoc (symm \u03b1) \u03b1 \u03b2))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((symm \u03b1 \u226a\u226b \u03b1) \u226a\u226b \u03b2 = \u03b2)) (symm_self_id \u03b1)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (refl Y \u226a\u226b \u03b2 = \u03b2)) (refl_trans \u03b2))) (Eq.refl \u03b2)))\n\n@[simp] theorem self_symm_id_assoc {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u2245 Y)\n    (\u03b2 : X \u2245 Z) : \u03b1 \u226a\u226b symm \u03b1 \u226a\u226b \u03b2 = \u03b2 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u03b1 \u226a\u226b symm \u03b1 \u226a\u226b \u03b2 = \u03b2)) (Eq.symm (trans_assoc \u03b1 (symm \u03b1) \u03b2))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((\u03b1 \u226a\u226b symm \u03b1) \u226a\u226b \u03b2 = \u03b2)) (self_symm_id \u03b1)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (refl X \u226a\u226b \u03b2 = \u03b2)) (refl_trans \u03b2))) (Eq.refl \u03b2)))\n\ntheorem inv_comp_eq {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u2245 Y) {f : X \u27f6 Z}\n    {g : Y \u27f6 Z} : inv \u03b1 \u226b f = g \u2194 f = hom \u03b1 \u226b g :=\n  sorry\n\ntheorem eq_inv_comp {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u2245 Y) {f : X \u27f6 Z}\n    {g : Y \u27f6 Z} : g = inv \u03b1 \u226b f \u2194 hom \u03b1 \u226b g = f :=\n  iff.symm (inv_comp_eq (symm \u03b1))\n\ntheorem comp_inv_eq {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u2245 Y) {f : Z \u27f6 Y}\n    {g : Z \u27f6 X} : f \u226b inv \u03b1 = g \u2194 f = g \u226b hom \u03b1 :=\n  sorry\n\ntheorem eq_comp_inv {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u2245 Y) {f : Z \u27f6 Y}\n    {g : Z \u27f6 X} : g = f \u226b inv \u03b1 \u2194 g \u226b hom \u03b1 = f :=\n  iff.symm (comp_inv_eq (symm \u03b1))\n\ntheorem inv_eq_inv {C : Type u} [category C] {X : C} {Y : C} (f : X \u2245 Y) (g : X \u2245 Y) :\n    inv f = inv g \u2194 hom f = hom g :=\n  sorry\n\ntheorem hom_comp_eq_id {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) {f : Y \u27f6 X} :\n    hom \u03b1 \u226b f = \ud835\udfd9 \u2194 f = inv \u03b1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (hom \u03b1 \u226b f = \ud835\udfd9 \u2194 f = inv \u03b1)) (Eq.symm (propext (eq_inv_comp \u03b1)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (f = inv \u03b1 \u226b \ud835\udfd9 \u2194 f = inv \u03b1)) (category.comp_id (inv \u03b1))))\n      (iff.refl (f = inv \u03b1)))\n\ntheorem comp_hom_eq_id {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) {f : Y \u27f6 X} :\n    f \u226b hom \u03b1 = \ud835\udfd9 \u2194 f = inv \u03b1 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (f \u226b hom \u03b1 = \ud835\udfd9 \u2194 f = inv \u03b1)) (Eq.symm (propext (eq_comp_inv \u03b1)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (f = \ud835\udfd9 \u226b inv \u03b1 \u2194 f = inv \u03b1)) (category.id_comp (inv \u03b1))))\n      (iff.refl (f = inv \u03b1)))\n\ntheorem hom_eq_inv {C : Type u} [category C] {X : C} {Y : C} (\u03b1 : X \u2245 Y) (\u03b2 : Y \u2245 X) :\n    hom \u03b1 = inv \u03b2 \u2194 hom \u03b2 = inv \u03b1 :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (hom \u03b1 = inv \u03b2 \u2194 hom \u03b2 = inv \u03b1)) (propext (inv_eq_inv (symm \u03b1) \u03b2))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (hom (symm \u03b1) = hom \u03b2 \u2194 hom \u03b2 = inv \u03b1)) (propext eq_comm)))\n      (iff.refl (hom \u03b2 = hom (symm \u03b1))))\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 \u27f6 Y) where\n  inv : Y \u27f6 X\n  hom_inv_id' :\n    autoParam (f \u226b inv = \ud835\udfd9)\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 \u226b f = \ud835\udfd9)\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 \u27f6 Y) [h : is_iso f] : X \u2245 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 \u27f6 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 \u27f6 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 \u27f6 Y) [is_iso f] :\n    f \u226b inv f = \ud835\udfd9 :=\n  hom_inv_id'\n\n@[simp] theorem inv_hom_id {C : Type u} [category C] {X : C} {Y : C} (f : X \u27f6 Y) [is_iso f] :\n    inv f \u226b f = \ud835\udfd9 :=\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 \u27f6 Y)\n    [is_iso f] (g : X \u27f6 Z) : f \u226b inv f \u226b 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 \u27f6 Y)\n    [is_iso f] (g : Y \u27f6 Z) : inv f \u226b f \u226b 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 \ud835\udfd9 := mk \ud835\udfd9\n\nprotected instance of_iso {C : Type u} [category C] {X : C} {Y : C} (f : X \u2245 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 \u2245 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 \u27f6 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 \u27f6 Y}\n    {h : Y \u27f6 Z} [is_iso f] [is_iso h] : is_iso (f \u226b h) :=\n  is_iso.of_iso (as_iso f \u226a\u226b as_iso h)\n\n@[simp] theorem inv_id {C : Type u} [category C] {X : C} : inv \ud835\udfd9 = \ud835\udfd9 := rfl\n\n@[simp] theorem inv_comp {C : Type u} [category C] {X : C} {Y : C} {Z : C} {f : X \u27f6 Y} {h : Y \u27f6 Z}\n    [is_iso f] [is_iso h] : inv (f \u226b h) = inv h \u226b inv f :=\n  rfl\n\n@[simp] theorem inv_inv {C : Type u} [category C] {X : C} {Y : C} {f : X \u27f6 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 \u2245 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 \u2245 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} (\u03b1 : X \u27f6 Y) [is_iso \u03b1]\n    {f : X \u27f6 Z} {g : Y \u27f6 Z} : inv \u03b1 \u226b f = g \u2194 f = \u03b1 \u226b g :=\n  iso.inv_comp_eq (as_iso \u03b1)\n\n@[simp] theorem eq_inv_comp {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u27f6 Y) [is_iso \u03b1]\n    {f : X \u27f6 Z} {g : Y \u27f6 Z} : g = inv \u03b1 \u226b f \u2194 \u03b1 \u226b g = f :=\n  iso.eq_inv_comp (as_iso \u03b1)\n\n@[simp] theorem comp_inv_eq {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u27f6 Y) [is_iso \u03b1]\n    {f : Z \u27f6 Y} {g : Z \u27f6 X} : f \u226b inv \u03b1 = g \u2194 f = g \u226b \u03b1 :=\n  iso.comp_inv_eq (as_iso \u03b1)\n\n@[simp] theorem eq_comp_inv {C : Type u} [category C] {X : C} {Y : C} {Z : C} (\u03b1 : X \u27f6 Y) [is_iso \u03b1]\n    {f : Z \u27f6 Y} {g : Z \u27f6 X} : g = f \u226b inv \u03b1 \u2194 g \u226b \u03b1 = f :=\n  iso.eq_comp_inv (as_iso \u03b1)\n\nprotected instance epi_of_iso {C : Type u} [category C] {X : C} {Y : C} (f : X \u27f6 Y) [is_iso f] :\n    epi f :=\n  epi.mk\n    fun (Z : C) (g h : Y \u27f6 Z) (w : f \u226b g = f \u226b 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 \u226b f \u226b g = h)) w))\n          (eq.mpr (id (Eq._oldrec (Eq.refl (inv f \u226b f \u226b 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 \u27f6 Y) [is_iso f] :\n    mono f :=\n  mono.mk\n    fun (Z : C) (g h : Z \u27f6 X) (w : g \u226b f = h \u226b 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 \u226b \ud835\udfd9 = h)) (Eq.symm (category.comp_id h))))\n          (eq.mpr (id (Eq._oldrec (Eq.refl (g \u226b \ud835\udfd9 = h \u226b \ud835\udfd9)) (Eq.symm (hom_inv_id f))))\n            (eq.mpr\n              (id\n                (Eq._oldrec (Eq.refl (g \u226b f \u226b inv f = h \u226b f \u226b inv f))\n                  (Eq.symm (category.assoc g f (inv f)))))\n              (eq.mpr (id (Eq._oldrec (Eq.refl ((g \u226b f) \u226b inv f = h \u226b f \u226b inv f)) w))\n                (eq.mpr\n                  (id\n                    (Eq._oldrec (Eq.refl ((h \u226b f) \u226b inv f = h \u226b f \u226b inv f))\n                      (Eq.symm (category.assoc h f (inv f)))))\n                  (Eq.refl ((h \u226b f) \u226b 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 \u27f6 Y} {g : X \u27f6 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 \u27f6 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 \u27f6 Y} {g : X \u27f6 Y}\n    [is_iso f] [is_iso g] : inv f = inv g \u2194 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 \u27f6 Y) [is_iso g]\n    {f : Y \u27f6 X} : g \u226b f = \ud835\udfd9 \u2194 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 \u27f6 Y) [is_iso g]\n    {f : Y \u27f6 X} : f \u226b g = \ud835\udfd9 \u2194 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 \u27f6 Y`.\nPresumably we could write `X \u21aa Y` and `X \u21a0 Y`.\n-/\n\n@[simp] theorem cancel_iso_hom_left {C : Type u} [category C] {X : C} {Y : C} {Z : C} (f : X \u2245 Y)\n    (g : Y \u27f6 Z) (g' : Y \u27f6 Z) : hom f \u226b g = hom f \u226b g' \u2194 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 \u2245 X)\n    (g : Y \u27f6 Z) (g' : Y \u27f6 Z) : inv f \u226b g = inv f \u226b g' \u2194 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 \u27f6 Y)\n    (f' : X \u27f6 Y) (g : Y \u2245 Z) : f \u226b hom g = f' \u226b hom g \u2194 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 \u27f6 Y)\n    (f' : X \u27f6 Y) (g : Z \u2245 Y) : f \u226b inv g = f' \u226b inv g \u2194 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 \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y) (h : Y \u2245 Z) :\n    f \u226b g \u226b hom h = f' \u226b g' \u226b hom h \u2194 f \u226b g = f' \u226b 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 \u27f6 X) (g : X \u27f6 Y) (f' : W \u27f6 X') (g' : X' \u27f6 Y) (h : Z \u2245 Y) :\n    f \u226b g \u226b inv h = f' \u226b g' \u226b inv h \u2194 f \u226b g = f' \u226b g' :=\n  sorry\n\nend iso\n\n\nnamespace functor\n\n\n/-- A functor `F : C \u2964 D` sends isomorphisms `i : X \u2245 Y` to isomorphisms `F.obj X \u2245 F.obj Y` -/\ndef map_iso {C : Type u} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) {X : C} {Y : C}\n    (i : X \u2245 Y) : obj F X \u2245 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\u2082} [category D] (F : C \u2964 D) {X : C}\n    {Y : C} (i : X \u2245 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\u2082} [category D] (F : C \u2964 D) {X : C}\n    {Y : C} (i : X \u2245 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\u2082} [category D] (F : C \u2964 D)\n    {X : C} {Y : C} (i : X \u2245 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\u2082} [category D] (F : C \u2964 D)\n    {X : C} {Y : C} {Z : C} (i : X \u2245 Y) (j : Y \u2245 Z) :\n    map_iso F (i \u226a\u226b j) = map_iso F i \u226a\u226b 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\u2082} [category D] (F : C \u2964 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\u2082} [category D]\n    (F : C \u2964 D) (f : X \u27f6 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\u2082} [category D] (F : C \u2964 D) {X : C}\n    {Y : C} (f : X \u27f6 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\u2082} [category D] (F : C \u2964 D) {X : C} {Y : C}\n    (f : X \u27f6 Y) [is_iso f] : map F f \u226b map F (inv f) = \ud835\udfd9 :=\n  sorry\n\ntheorem map_inv_hom {C : Type u} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D) {X : C} {Y : C}\n    (f : X \u27f6 Y) [is_iso f] : map F (inv f) \u226b map F f = \ud835\udfd9 :=\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 {\u03b1:Type*} [M:measurable_space \u03b1] \n(\u03bc:measure_theory.measure \u03b1)\n(S:set \u03b1):\n\u03bc S = \u2a05 (t : set \u03b1) (st : S \u2286 t) (ht : measurable_set t), \u03bc t :=\nbegin\n  have h1:\u03bc S = \u03bc.to_outer_measure.trim S,\n  { rw \u03bc.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 {\u03b1:Type*} [M:measurable_space \u03b1] \n(\u03bc:measure_theory.measure \u03b1)\n(S:set \u03b1):\n(\u03bc S \u2260 \u22a4) \u2192\n\u2203 (f:\u2115 \u2192 set \u03b1),\n\u2200 n, measurable_set (f n) \u2227 (S \u2286 f n) \u2227 \u03bc (f n) \u2264 ((\u03bc S) + (1)/((n:ennreal) + 1)) :=   \nbegin\n  intros h1,\n  \n  have h2 : \u03bc S = \u2a05 (t : set \u03b1) (st : S \u2286 t) (ht : measurable_set t), \u03bc t,\n  { apply measure_theory.measure_unmeasurable },\n  rw \u2190  ennreal.lt_top_iff_ne_top at h1,\n  have h4 := h1,\n \n   rw h2 at h1,\n  have h:\u2200 (n:\u2115), \u2203 (T:set \u03b1), measurable_set T \u2227 (S \u2286 T) \u2227 \n          \u03bc T \u2264 ((\u03bc S) + (1)/((n:ennreal) + 1)),\n  { intros n,\n    have h3_4 : \u03bc S + ((n:ennreal) + 1)\u207b\u00b9 < \u22a4,\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 \u2190 h2 at h3_2,\n    have h3_5 : S \u2286 t,\n    { apply ennreal.infi_prop_le_elim (S \u2286 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)\u207b\u00b9,\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 {\u03b1:Type*} [M:measurable_space \u03b1]\n(\u03bc:measure_theory.measure \u03b1) (S:set \u03b1):\u2203 T:set \u03b1, \nmeasurable_set T \u2227 \u03bc T = \u03bc S \u2227 S \u2286 T := \nbegin\n  have h1:\u03bc S = \u03bc.to_outer_measure.trim S,\n  { rw \u03bc.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 : ((\u03bc S) = (\u22a4:ennreal)) \u2228 ((\u03bc S) \u2260 (\u22a4:ennreal)),\n  { apply em },\n  cases h2,\n  { apply exists.intro set.univ, split,\n    apply measurable_set.univ, split,\n    rw h2, rw \u2190 top_le_iff, \n    rw \u2190 h2, apply measure_theory.measure_mono, simp, simp },\n  { have h3 := measure_theory.measurable_sequence \u03bc S h2,\n    cases h3 with f h3,\n    have h7:S \u2286 \u22c2 (n:\u2115), f n,\n    { rw set.subset_Inter_iff, intro n, apply (h3 n).right.left },\n    apply exists.intro (\u22c2 n, f n),\n    split,\n    apply measurable_set.Inter,\n    apply (\u03bb n, (h3 n).left),\n    split,\n    apply le_antisymm,\n    { apply ennreal.le_of_forall_pos_le_add,\n      intros \u03b5 h4 h5,\n      have h6 := nnreal.exists_unit_frac_lt_pos h4,\n      cases h6 with n h6,\n      apply @le_trans _ _ _ (\u03bc (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 \u2190 ennreal.coe_one,\n      have C8A1:(n:ennreal) = ((n:nnreal):ennreal),\n      { simp },\n      rw C8A1,\n      rw \u2190 ennreal.coe_add,\n      rw \u2190 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' {\u03b1:Type*} [M:measurable_space \u03b1] \n  {\u03bc:measure_theory.measure \u03b1} {s t:set \u03b1}:measurable_set t \u2192 \u03bc s = \u03bc (s \u2229 t) + \u03bc (s \\ t) :=\nbegin\n  intros A1,\n  have A2:M \u2264 \u03bc.to_outer_measure.caratheodory := measure_theory.le_to_outer_measure_caratheodory \u03bc,\n  have A3:\u03bc.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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) : Prop := sorry\n\nclass IsSmooth {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) : Prop where\n  (proof : is_smooth f)\n\ninstance identity : IsSmooth fun a : \u03b1 => a := sorry\ninstance const (b : \u03b2) : IsSmooth fun a : \u03b1 => b := sorry\ninstance swap (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) [\u2200 a, IsSmooth (f a)] : IsSmooth (\u03bb b a => f a b) := sorry\ninstance parm (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) [IsSmooth f] (b : \u03b2) : IsSmooth (\u03bb a => f a b) := sorry\ninstance comp (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) [IsSmooth f] [IsSmooth g] : IsSmooth (fun a => f (g a)) := sorry\ninstance diag (f : \u03b2 \u2192 \u03b4 \u2192 \u03b3) (g : \u03b1 \u2192 \u03b2) (h : \u03b1 \u2192 \u03b4) [IsSmooth f] [\u2200 b, IsSmooth (f b)] [IsSmooth g] [IsSmooth h] : IsSmooth (\u03bb 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 : \u03b2 \u2192 \u03b4 \u2192 \u03b3) [IsSmooth f] (d : \u03b4) : IsSmooth (\u03bb (g : \u03b1 \u2192 \u03b2) 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 \u2964 C` with a left adjoint `F` such\nthat `\u03b5_X : FUX \u27f6 X` is a regular epi. Then for any category `A` with coequalizers of reflexive\npairs, a functor `R : A \u2964 B` has a left adjoint if (and only if) the composite `R \u22d9 U` does.\nNote that the condition on `U` regarding `\u03b5_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 \u2964 B` has a left adjoint provided `R \u22d9 U` does.\n\nThe adjoint lifting theorem says that given a commutative square of functors (up to isomorphism):\n\n      Q\n    A \u2192 B\n  U \u2193   \u2193 V\n    C \u2192 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 `(\u03b7, \u03b5)` for the unit\nand counit of the adjunction `adj\u2081 : F \u22a3 U` and `(\u03b9, \u03b4)` for the unit and counit of the adjunction\n`adj\u2082 : F' \u22a3 R \u22d9 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\u2081 v\u2082 v\u2083 v\u2084 u\u2081 u\u2082 u\u2083 u\u2084\n\nvariable {A : Type u\u2081} {B : Type u\u2082} {C : Type u\u2083}\n\nvariable [Category.{v\u2081} A] [Category.{v\u2082} B] [Category.{v\u2083} C]\n\n-- Hide implementation details in this namespace\nnamespace LiftAdjoint\n\nvariable {U : B \u2964 C} {F : C \u2964 B} (R : A \u2964 B) (F' : C \u2964 A)\n\nvariable (adj\u2081 : F \u22a3 U) (adj\u2082 : F' \u22a3 R \u22d9 U)\n\n/-- To show that `\u03b5_X` is a coequalizer for `(FU\u03b5_X, \u03b5_FUX)`, it suffices to assume it's always a\ncoequalizer of something (i.e. a regular epi).\n-/\ndef counitCoequalises [\u2200 X : B, RegularEpi (adj\u2081.counit.app X)] (X : B) :\n    IsColimit (Cofork.of\u03c0 (adj\u2081.counit.app X) (adj\u2081.counit_naturality _)) :=\n  Cofork.IsColimit.mk' _ fun s =>\n    by\n    refine' \u27e8(regular_epi.desc' (adj\u2081.counit.app X) s.\u03c0 _).1, _, _\u27e9\n    \u00b7 rw [\u2190 cancel_epi (adj\u2081.counit.app (regular_epi.W (adj\u2081.counit.app X)))]\n      rw [\u2190 adj\u2081.counit_naturality_assoc]\n      dsimp only [functor.comp_obj]\n      rw [\u2190 s.condition, \u2190 F.map_comp_assoc, \u2190 U.map_comp, regular_epi.w, U.map_comp,\n        F.map_comp_assoc, s.condition, \u2190 adj\u2081.counit_naturality_assoc]\n    \u00b7 apply (regular_epi.desc' (adj\u2081.counit.app X) s.\u03c0 _).2\n    \u00b7 intro m hm\n      rw [\u2190 cancel_epi (adj\u2081.counit.app X)]\n      apply hm.trans (regular_epi.desc' (adj\u2081.counit.app X) s.\u03c0 _).2.symm\n#align category_theory.lift_adjoint.counit_coequalises CategoryTheory.LiftAdjoint.counitCoequalises\n\ninclude adj\u2081 adj\u2082\n\n/-- (Implementation)\nTo construct the left adjoint, we use the coequalizer of `F' U \u03b5_Y` with the composite\n\n`F' U F U X \u27f6 F' U F U R F U' X \u27f6 F' U R F' U X \u27f6 F' U X`\n\nwhere the first morphism is `F' U F \u03b9_UX`, the second is `F' U \u03b5_RF'UX`, and the third is `\u03b4_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))) \u27f6 F'.obj (U.obj X) :=\n  F'.map (U.map (F.map (adj\u2082.Unit.app _) \u226b adj\u2081.counit.app _)) \u226b adj\u2082.counit.app _\n#align category_theory.lift_adjoint.other_map CategoryTheory.LiftAdjoint.otherMap\n\n/--\n`(F'U\u03b5_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\u2081.counit.app X))) (otherMap _ _ adj\u2081 adj\u2082 X) :=\n  IsReflexivePair.mk' (F'.map (adj\u2081.Unit.app (U.obj X)))\n    (by\n      rw [\u2190 F'.map_comp, adj\u2081.right_triangle_components]\n      apply F'.map_id)\n    (by\n      dsimp [other_map]\n      rw [\u2190 F'.map_comp_assoc, U.map_comp, adj\u2081.unit_naturality_assoc,\n        adj\u2081.right_triangle_components, comp_id, adj\u2082.left_triangle_components])\n\nvariable [HasReflexiveCoequalizers A]\n\n/-- Construct the object part of the desired left adjoint as the coequalizer of `F'U\u03b5_Y` with\n`other_map`.\n-/\nnoncomputable def constructLeftAdjointObj (Y : B) : A :=\n  coequalizer (F'.map (U.map (adj\u2081.counit.app Y))) (otherMap _ _ adj\u2081 adj\u2082 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 [\u2200 X : B, RegularEpi (adj\u2081.counit.app X)] (Y : A)\n    (X : B) : (constructLeftAdjointObj _ _ adj\u2081 adj\u2082 X \u27f6 Y) \u2243 (X \u27f6 R.obj Y) :=\n  calc\n    (constructLeftAdjointObj _ _ adj\u2081 adj\u2082 X \u27f6 Y) \u2243\n        { f : F'.obj (U.obj X) \u27f6 Y //\n          F'.map (U.map (adj\u2081.counit.app X)) \u226b f = otherMap _ _ adj\u2081 adj\u2082 _ \u226b f } :=\n      Cofork.IsColimit.homIso (colimit.isColimit _) _\n    _ \u2243\n        { g : U.obj X \u27f6 U.obj (R.obj Y) //\n          U.map (F.map g \u226b adj\u2081.counit.app _) = U.map (adj\u2081.counit.app _) \u226b g } :=\n      by\n      apply (adj\u2082.hom_equiv _ _).subtypeEquiv _\n      intro f\n      rw [\u2190 (adj\u2082.hom_equiv _ _).Injective.eq_iff, eq_comm, adj\u2082.hom_equiv_naturality_left,\n        other_map, assoc, adj\u2082.hom_equiv_naturality_left, \u2190 adj\u2082.counit_naturality,\n        adj\u2082.hom_equiv_naturality_left, adj\u2082.hom_equiv_unit, adj\u2082.right_triangle_components,\n        comp_id, functor.comp_map, \u2190 U.map_comp, assoc, \u2190 adj\u2081.counit_naturality,\n        adj\u2082.hom_equiv_unit, adj\u2082.hom_equiv_unit, F.map_comp, assoc]\n      rfl\n    _ \u2243 { z : F.obj (U.obj X) \u27f6 R.obj Y // _ } :=\n      by\n      apply (adj\u2081.hom_equiv _ _).symm.subtypeEquiv\n      intro g\n      rw [\u2190 (adj\u2081.hom_equiv _ _).symm.Injective.eq_iff, adj\u2081.hom_equiv_counit,\n        adj\u2081.hom_equiv_counit, adj\u2081.hom_equiv_counit, F.map_comp, assoc, U.map_comp, F.map_comp,\n        assoc, adj\u2081.counit_naturality, adj\u2081.counit_naturality_assoc]\n      apply eq_comm\n    _ \u2243 (X \u27f6 R.obj Y) := (Cofork.IsColimit.homIso (counitCoequalises adj\u2081 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 [\u2200 X : B, RegularEpi (adj\u2081.counit.app X)] : B \u2964 A :=\n  by\n  refine'\n    adjunction.left_adjoint_of_equiv (fun X Y => construct_left_adjoint_equiv R _ adj\u2081 adj\u2082 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, \u2190\n    adj\u2081.hom_equiv_naturality_right_symm, cofork.is_colimit.hom_iso_natural,\n    adj\u2082.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 \u2964 C` has a left adjoint `F` such that each counit\n`\u03b5_X : FUX \u27f6 X` is a regular epimorphism. Then if a category `A` has coequalizers of reflexive\npairs, then a functor `R : A \u2964 B` has a left adjoint if the composite `R \u22d9 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 \u2964 C} {F : C \u2964 B} (R : A \u2964 B) (adj\u2081 : F \u22a3 U)\n    [\u2200 X : B, RegularEpi (adj\u2081.counit.app X)] [HasReflexiveCoequalizers A]\n    [IsRightAdjoint (R \u22d9 U)] : IsRightAdjoint R\n    where\n  left := LiftAdjoint.constructLeftAdjoint R _ adj\u2081 (Adjunction.ofRightAdjoint _)\n  adj := Adjunction.adjunctionOfEquivLeft _ _\n#align category_theory.adjoint_triangle_lift CategoryTheory.adjointTriangleLift\n\n/-- If `R \u22d9 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 \u2964 C) [MonadicRightAdjoint U] {R : A \u2964 B}\n    [HasReflexiveCoequalizers A] [IsRightAdjoint (R \u22d9 U)] : IsRightAdjoint R :=\n  by\n  let R' : A \u2964 _ := R \u22d9 monad.comparison (adjunction.of_right_adjoint U)\n  rsuffices : is_right_adjoint R'\n  \u00b7 let this : is_right_adjoint (R' \u22d9 (monad.comparison (adjunction.of_right_adjoint U)).inv) := by\n      infer_instance\n    \u00b7 let this : R' \u22d9 (monad.comparison (adjunction.of_right_adjoint U)).inv \u2245 R :=\n        (iso_whisker_left R (monad.comparison _).asEquivalence.unitIso.symm : _) \u226a\u226b R.right_unitor\n      exact adjunction.right_adjoint_of_nat_iso this\n  let this : is_right_adjoint (R' \u22d9 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 : \u2200 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 \u27e8_, _, _, _, monad.beck_algebra_coequalizer X\u27e9\n  exact adjoint_triangle_lift R' (monad.adj _)\n#align category_theory.monadic_adjoint_triangle_lift CategoryTheory.monadicAdjointTriangleLift\n\nvariable {D : Type u\u2084}\n\nvariable [Category.{v\u2084} D]\n\n/-- Suppose we have a commutative square of functors\n\n      Q\n    A \u2192 B\n  U \u2193   \u2193 V\n    C \u2192 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 \u2964 B) (V : B \u2964 D) (U : A \u2964 C) (R : C \u2964 D)\n    (comm : U \u22d9 R \u2245 Q \u22d9 V) [IsRightAdjoint U] [IsRightAdjoint V] [IsRightAdjoint R]\n    [\u2200 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 \u2192 B\n  U \u2193   \u2193 V\n    C \u2192 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 \u2964 B) (V : B \u2964 D) (U : A \u2964 C) (R : C \u2964 D)\n    (comm : U \u22d9 R \u2245 Q \u22d9 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 (\u03b1 : Type*) [partial_order \u03b1] [bounded_order \u03b1] : BoundedOrder := \u27e8\u27e8\u03b1\u27e9\u27e9\n\n@[simp] lemma coe_of (\u03b1 : Type*) [partial_order \u03b1] [bounded_order \u03b1] : \u21a5(of \u03b1) = \u03b1 := rfl\n\ninstance : inhabited BoundedOrder := \u27e8of punit\u27e9\n\ninstance large_category : large_category.{u} BoundedOrder :=\n{ hom := \u03bb X Y, bounded_order_hom X Y,\n  id := \u03bb X, bounded_order_hom.id X,\n  comp := \u03bb X Y Z f g, g.comp f,\n  id_comp' := \u03bb X Y, bounded_order_hom.comp_id,\n  comp_id' := \u03bb X Y, bounded_order_hom.id_comp,\n  assoc' := \u03bb W X Y Z _ _ _, bounded_order_hom.comp_assoc _ _ _ }\n\ninstance concrete_category : concrete_category BoundedOrder :=\n{ forget := \u27e8coe_sort, \u03bb X Y, coe_fn, \u03bb X, rfl, \u03bb X Y Z f g, rfl\u27e9,\n  forget_faithful := \u27e8\u03bb X Y, by convert fun_like.coe_injective\u27e9 }\n\ninstance has_forget_to_PartialOrder : has_forget\u2082 BoundedOrder PartialOrder :=\n{ forget\u2082 := { obj := \u03bb X, X.to_PartialOrder, map := \u03bb X Y, bounded_order_hom.to_order_hom } }\n\ninstance has_forget_to_Bipointed : has_forget\u2082 BoundedOrder Bipointed :=\n{ forget\u2082 := { obj := \u03bb X, \u27e8X, \u22a5, \u22a4\u27e9, map := \u03bb X Y f, \u27e8f, map_bot f, map_top f\u27e9 },\n  forget_comp := rfl }\n\n/-- `order_dual` as a functor. -/\n@[simps] def dual : BoundedOrder \u2964 BoundedOrder :=\n{ obj := \u03bb X, of (order_dual X), map := \u03bb 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 {\u03b1 \u03b2 : BoundedOrder.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2 :=\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 \u224c BoundedOrder :=\nequivalence.mk dual dual\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n\nend BoundedOrder\n\nlemma BoundedOrder_dual_comp_forget_to_PartialOrder :\n  BoundedOrder.dual \u22d9 forget\u2082 BoundedOrder PartialOrder =\n    forget\u2082 BoundedOrder PartialOrder \u22d9 PartialOrder.dual := rfl\n\nlemma BoundedOrder_dual_comp_forget_to_Bipointed :\n  BoundedOrder.dual \u22d9 forget\u2082 BoundedOrder Bipointed =\n    forget\u2082 BoundedOrder Bipointed \u22d9 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.\u03b9 R` is the canonical R-linear map `M \u2192 tensor_algebra R M`.\n3. Given a linear map `f : M \u2192 A` to an R-algebra `A`, `lift R f` is the lift of `f` to an\n  `R`-algebra morphism `tensor_algebra R M \u2192 A`.\n\n## Theorems\n\n1. `\u03b9_comp_lift` states that the composition `(lift R f) \u2218 (\u03b9 R)` is identical to `f`.\n2. `lift_unique` states that whenever an R-algebra morphism `g : tensor_algebra R M \u2192 A` is\n  given whose composition with `\u03b9 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_\u03b9` is a combination of `\u03b9_comp_lift` and `lift_unique`. It states that the lift\n  of the composition of an algebra morphism with `\u03b9` 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 \u2192 FreeAlgebra R M \u2192 Prop-- force `\u03b9` to be linear\n\n  | add {a b : M} : Rel (FreeAlgebra.\u03b9 R (a + b)) (FreeAlgebra.\u03b9 R a + FreeAlgebra.\u03b9 R b)\n  |\n  smul {r : R} {a : M} :\n    Rel (FreeAlgebra.\u03b9 R (r \u2022 a)) (algebraMap R (FreeAlgebra R M) r * FreeAlgebra.\u03b9 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  \u00ab./././Mathport/Syntax/Translate/Command.lean:42:9: unsupported derive handler algebra[algebra] R\u00bb\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 \u2192\u2097[R] tensor_algebra R M`.\n-/\nirreducible_def \u03b9 : M \u2192\u2097[R] TensorAlgebra R M :=\n  { toFun := fun m => RingQuot.mkAlgHom R _ (FreeAlgebra.\u03b9 R m)\n    map_add' := fun x y => by\n      rw [\u2190 AlgHom.map_add]\n      exact RingQuot.mkAlgHom_rel R rel.add\n    map_smul' := fun r x => by\n      rw [\u2190 AlgHom.map_smul]\n      exact RingQuot.mkAlgHom_rel R rel.smul }\n#align tensor_algebra.\u03b9 TensorAlgebra.\u03b9\n\ntheorem ringQuot_mkAlgHom_freeAlgebra_\u03b9_eq_\u03b9 (m : M) :\n    RingQuot.mkAlgHom R (Rel R M) (FreeAlgebra.\u03b9 R m) = \u03b9 R m :=\n  by\n  rw [\u03b9]\n  rfl\n#align tensor_algebra.ring_quot_mk_alg_hom_free_algebra_\u03b9_eq_\u03b9 TensorAlgebra.ringQuot_mkAlgHom_freeAlgebra_\u03b9_eq_\u03b9\n\n/-- Given a linear map `f : M \u2192 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 \u2192 A`.\n-/\n@[simps symm_apply]\nirreducible_def lift {A : Type _} [Semiring A] [Algebra R A] :\n  (M \u2192\u2097[R] A) \u2243 (TensorAlgebra R M \u2192\u2090[R] A) :=\n  { toFun :=\n      RingQuot.liftAlgHom R \u2218 fun f =>\n        \u27e8FreeAlgebra.lift R \u21d1f, fun x y (h : Rel R M x y) => by\n          induction h <;>\n            simp only [Algebra.smul_def, FreeAlgebra.lift_\u03b9_apply, LinearMap.map_smul\u209b\u2097,\n              RingHom.id_apply, map_mul, AlgHom.commutes, map_add]\u27e9\n    invFun := fun F => F.toLinearMap.comp (\u03b9 R)\n    left_inv := fun f => by\n      rw [\u03b9]\n      ext1 x\n      exact (RingQuot.liftAlgHom_mkAlgHom_apply _ _ _ _).trans (FreeAlgebra.lift_\u03b9_apply f x)\n    right_inv := fun F =>\n      RingQuot.ringQuot_ext' _ _ _ <|\n        FreeAlgebra.hom_ext <|\n          funext fun x => by\n            rw [\u03b9]\n            exact\n              (RingQuot.liftAlgHom_mkAlgHom_apply _ _ _ _).trans (FreeAlgebra.lift_\u03b9_apply _ _) }\n#align tensor_algebra.lift TensorAlgebra.lift\n\nvariable {R}\n\n@[simp]\ntheorem \u03b9_comp_lift {A : Type _} [Semiring A] [Algebra R A] (f : M \u2192\u2097[R] A) :\n    (lift R f).toLinearMap.comp (\u03b9 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.\u03b9_comp_lift TensorAlgebra.\u03b9_comp_lift\n\n@[simp]\ntheorem lift_\u03b9_apply {A : Type _} [Semiring A] [Algebra R A] (f : M \u2192\u2097[R] A) (x) :\n    lift R f (\u03b9 R x) = f x := by\n  conv_rhs => rw [\u2190 \u03b9_comp_lift f]\n  rfl\n#align tensor_algebra.lift_\u03b9_apply TensorAlgebra.lift_\u03b9_apply\n\n@[simp]\ntheorem lift_unique {A : Type _} [Semiring A] [Algebra R A] (f : M \u2192\u2097[R] A)\n    (g : TensorAlgebra R M \u2192\u2090[R] A) : g.toLinearMap.comp (\u03b9 R) = f \u2194 g = lift R f :=\n  by\n  rw [\u2190 (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_\u03b9 {A : Type _} [Semiring A] [Algebra R A] (g : TensorAlgebra R M \u2192\u2090[R] A) :\n    lift R (g.toLinearMap.comp (\u03b9 R)) = g :=\n  by\n  rw [\u2190 lift_symm_apply]\n  exact (lift R).apply_symm_apply g\n#align tensor_algebra.lift_comp_\u03b9 TensorAlgebra.lift_comp_\u03b9\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 \u2192\u2090[R] A}\n    (w : f.toLinearMap.comp (\u03b9 R) = g.toLinearMap.comp (\u03b9 R)) : f = g :=\n  by\n  rw [\u2190 lift_symm_apply, \u2190 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 `\u03b9` 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 \u2192 Prop}\n    (h_grade0 : \u2200 r, C (algebraMap R (TensorAlgebra R M) r)) (h_grade1 : \u2200 x, C (\u03b9 R x))\n    (h_mul : \u2200 a b, C a \u2192 C b \u2192 C (a * b)) (h_add : \u2200 a b, C a \u2192 C b \u2192 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 \u2192\u2097[R] s := (\u03b9 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 \u2192\u2090[R] R :=\n  lift R (0 : M \u2192\u2097[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 \u2194 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 \u2194 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 \u2194 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.\u03b9` to `triv_sq_zero_ext.inr`. -/\ndef toTrivSqZeroExt [Module R\u1d50\u1d52\u1d56 M] [IsCentralScalar R M] :\n    TensorAlgebra R M \u2192\u2090[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_\u03b9 (x : M) [Module R\u1d50\u1d52\u1d56 M] [IsCentralScalar R M] :\n    toTrivSqZeroExt (\u03b9 R x) = TrivSqZeroExt.inr x :=\n  lift_\u03b9_apply _ _\n#align tensor_algebra.to_triv_sq_zero_ext_\u03b9 TensorAlgebra.toTrivSqZeroExt_\u03b9\n\n/-- The left-inverse of `\u03b9`.\n\nAs an implementation detail, we implement this using `triv_sq_zero_ext` which has a suitable\nalgebra structure. -/\ndef \u03b9Inv : TensorAlgebra R M \u2192\u2097[R] M :=\n  by\n  letI : Module R\u1d50\u1d52\u1d56 M := Module.compHom _ ((RingHom.id R).fromOpposite mul_comm)\n  haveI : IsCentralScalar R M := \u27e8fun r m => rfl\u27e9\n  exact (TrivSqZeroExt.sndHom R M).comp to_triv_sq_zero_ext.to_linear_map\n#align tensor_algebra.\u03b9_inv TensorAlgebra.\u03b9Inv\n\ntheorem \u03b9_leftInverse : Function.LeftInverse \u03b9Inv (\u03b9 R : M \u2192 TensorAlgebra R M) := fun x => by\n  simp [\u03b9_inv]\n#align tensor_algebra.\u03b9_left_inverse TensorAlgebra.\u03b9_leftInverse\n\nvariable (R)\n\n@[simp]\ntheorem \u03b9_inj (x y : M) : \u03b9 R x = \u03b9 R y \u2194 x = y :=\n  \u03b9_leftInverse.Injective.eq_iff\n#align tensor_algebra.\u03b9_inj TensorAlgebra.\u03b9_inj\n\n@[simp]\ntheorem \u03b9_eq_zero_iff (x : M) : \u03b9 R x = 0 \u2194 x = 0 := by rw [\u2190 \u03b9_inj R x 0, LinearMap.map_zero]\n#align tensor_algebra.\u03b9_eq_zero_iff TensorAlgebra.\u03b9_eq_zero_iff\n\nvariable {R}\n\n@[simp]\ntheorem \u03b9_eq_algebraMap_iff (x : M) (r : R) : \u03b9 R x = algebraMap R _ r \u2194 x = 0 \u2227 r = 0 :=\n  by\n  refine' \u27e8fun h => _, _\u27e9\n  \u00b7 letI : Module R\u1d50\u1d52\u1d56 M := Module.compHom _ ((RingHom.id R).fromOpposite mul_comm)\n    haveI : IsCentralScalar R M := \u27e8fun r m => rfl\u27e9\n    have hf0 : to_triv_sq_zero_ext (\u03b9 R x) = (0, x) := lift_\u03b9_apply _ _\n    rw [h, AlgHom.commutes] at hf0\n    have : r = 0 \u2227 0 = x := Prod.ext_iff.1 hf0\n    exact this.symm.imp_left Eq.symm\n  \u00b7 rintro \u27e8rfl, rfl\u27e9\n    rw [LinearMap.map_zero, RingHom.map_zero]\n#align tensor_algebra.\u03b9_eq_algebra_map_iff TensorAlgebra.\u03b9_eq_algebraMap_iff\n\n@[simp]\ntheorem \u03b9_ne_one [Nontrivial R] (x : M) : \u03b9 R x \u2260 1 :=\n  by\n  rw [\u2190 (algebraMap R (TensorAlgebra R M)).map_one, Ne.def, \u03b9_eq_algebra_map_iff]\n  exact one_ne_zero \u2218 And.right\n#align tensor_algebra.\u03b9_ne_one TensorAlgebra.\u03b9_ne_one\n\n/-- The generators of the tensor algebra are disjoint from its scalars. -/\ntheorem \u03b9_range_disjoint_one :\n    Disjoint (LinearMap.range (\u03b9 R : M \u2192\u2097[R] TensorAlgebra R M))\n      (1 : Submodule R (TensorAlgebra R M)) :=\n  by\n  rw [Submodule.disjoint_def]\n  rintro _ \u27e8x, hx\u27e9 \u27e8r, rfl : algebraMap _ _ _ = _\u27e9\n  rw [\u03b9_eq_algebra_map_iff x] at hx\n  rw [hx.2, RingHom.map_zero]\n#align tensor_algebra.\u03b9_range_disjoint_one TensorAlgebra.\u03b9_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 : \u2115) : MultilinearMap R (fun i : Fin n => M) (TensorAlgebra R M) :=\n  (MultilinearMap.mkPiAlgebraFin R n (TensorAlgebra R M)).compLinearMap fun _ => \u03b9 R\n#align tensor_algebra.tprod TensorAlgebra.tprod\n\n@[simp]\ntheorem tprod_apply {n : \u2115} (x : Fin n \u2192 M) : tprod R M n x = (List.ofFn fun i => \u03b9 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.\u03b9 R x` to `tensor_algebra.\u03b9 R x`. -/\ndef toTensor : FreeAlgebra R M \u2192\u2090[R] TensorAlgebra R M :=\n  FreeAlgebra.lift R (TensorAlgebra.\u03b9 R)\n#align free_algebra.to_tensor FreeAlgebra.toTensor\n\n@[simp]\ntheorem toTensor_\u03b9 (m : M) : (FreeAlgebra.\u03b9 R m).toTensor = TensorAlgebra.\u03b9 R m := by\n  simp [to_tensor]\n#align free_algebra.to_tensor_\u03b9 FreeAlgebra.toTensor_\u03b9\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 \u226b g = 0`\n\nWe define the map, as the lift of `image.\u03b9 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 \u226b 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 \u27f6 B) (g : B \u27f6 C) (w : f \u226b g = 0) : limits.image f \u27f6 limits.kernel g :=\n  limits.kernel.lift g (limits.image.\u03b9 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 \u27f6 C) [limits.has_zero_object V] {w : 0 \u226b 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 \u27f6 B) {w : f \u226b 0 = 0} : image_to_kernel_map f 0 w = limits.image.\u03b9 f \u226b inv (limits.kernel.\u03b9 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 \u27f6 B) (g : B \u27f6 C) {D : V} (h : C \u27f6 D) (w : f \u226b g = 0) : image_to_kernel_map f (g \u226b h)\n    (eq.mpr\n      (id\n        (Eq.trans\n          ((fun (a a_1 : A \u27f6 D) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 D) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n            (f \u226b g \u226b 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 \u226b\n    limits.kernel.lift (g \u226b h) (limits.kernel.\u03b9 g)\n      (eq.mpr\n        (id\n          (Eq.trans\n            ((fun (a a_1 : limits.kernel g \u27f6 D) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : limits.kernel g \u27f6 D) (e_2 : \u1fb0 = \u1fb0_1) =>\n                congr (congr_arg Eq e_1) e_2)\n              (limits.kernel.\u03b9 g \u226b g \u226b 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 \u27f6 B) (g : B \u27f6 C) {Z : V} (h : Z \u27f6 A) (w : f \u226b g = 0) : image_to_kernel_map (h \u226b f) g\n    (eq.mpr\n      (id\n        (Eq.trans\n          ((fun (a a_1 : Z \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : Z \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n            ((h \u226b f) \u226b g) 0\n            (Eq.trans\n              (Eq.trans (category.assoc h f g)\n                ((fun (\u1fb0 \u1fb0_1 : Z \u27f6 A) (e_1 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : A \u27f6 C) (e_2 : \u1fb0_2 = \u1fb0_3) =>\n                    congr (congr_arg category_struct.comp e_1) e_2)\n                  h h (Eq.refl h) (f \u226b 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 \u226b 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 \u27f6 B) (g : B \u27f6 C) {D : V} (h : C \u27f6 D) [is_iso h] (w : f \u226b g \u226b h = 0) : image_to_kernel_map f (g \u226b 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 \u27f6 D) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 D) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n              ((f \u226b g) \u226b h) (f \u226b g \u226b h) (category.assoc f g h) (0 \u226b h) 0 limits.zero_comp))\n          (eq.mp (Eq.refl (f \u226b g \u226b h = 0)) w))) \u226b\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 \u27f6 B) (g : B \u27f6 C) {Z : V} (h : Z \u27f6 A) [is_iso h] (w : (h \u226b f) \u226b g = 0) : image_to_kernel_map (h \u226b f) g w =\n  limits.image.pre_comp h f \u226b\n    image_to_kernel_map f g\n      (iff.mp (cancel_epi h)\n        (eq.mpr\n          (id\n            ((fun (a a_1 : Z \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : Z \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n              (h \u226b f \u226b g) (h \u226b f \u226b g) (Eq.refl (h \u226b f \u226b g)) (h \u226b 0) 0 limits.comp_zero))\n          (eq.mp\n            ((fun (a a_1 : Z \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : Z \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n              ((h \u226b f) \u226b g) (h \u226b f \u226b 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 \u27f6 B) (g : B \u27f6 C) {Z : V} {i : B \u2245 Z} (w : (f \u226b iso.hom i) \u226b iso.inv i \u226b g = 0) : image_to_kernel_map (f \u226b iso.hom i) (iso.inv i \u226b g) w =\n  iso.inv (limits.image.post_comp_is_iso f (iso.hom i)) \u226b\n    image_to_kernel_map f g\n        (eq.mpr (id (Eq.refl (f \u226b g = 0)))\n          (eq.mp\n            ((fun (a a_1 : A \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2)\n              ((f \u226b iso.hom i) \u226b iso.inv i \u226b g) (f \u226b g)\n              (Eq.trans (category.assoc f (iso.hom i) (iso.inv i \u226b g))\n                ((fun (\u1fb0 \u1fb0_1 : A \u27f6 B) (e_1 : \u1fb0 = \u1fb0_1) (\u1fb0_2 \u1fb0_3 : B \u27f6 C) (e_2 : \u1fb0_2 = \u1fb0_3) =>\n                    congr (congr_arg category_struct.comp e_1) e_2)\n                  f f (Eq.refl f) (iso.hom i \u226b iso.inv i \u226b g) g (iso.hom_inv_id_assoc i g)))\n              0 0 (Eq.refl 0))\n            w)) \u226b\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 \u27f6 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 \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2) (0 \u226b 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 \u27f6 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 \u27f6 C) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : A \u27f6 C) (e_2 : \u1fb0 = \u1fb0_1) => congr (congr_arg Eq e_1) e_2) (f \u226b 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 \u2964 \u03a0 i, C i` into a category of indexed families,\n1. we can assemble a collection of cones over `F \u22d9 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 \u22d9 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\u2081 v\u2082 u\u2081 u\u2082\n\nvariables {I : Type v\u2081} {C : I \u2192 Type u\u2081} [\u03a0 i, category.{v\u2081} (C i)]\nvariables {J : Type v\u2081} [small_category J]\nvariables {F : J \u2964 \u03a0 i, C i}\n\n/--\nA cone over `F : J \u2964 \u03a0 i, C i` has as its components cones over each of the `F \u22d9 pi.eval C i`.\n-/\ndef cone_comp_eval (c : cone F) (i : I) : cone (F \u22d9 pi.eval C i) :=\n{ X := c.X i,\n  \u03c0 :=\n  { app := \u03bb j, c.\u03c0.app j i,\n    naturality' := \u03bb j j' f, congr_fun (c.\u03c0.naturality f) i, } }\n\n/--\nA cocone over `F : J \u2964 \u03a0 i, C i` has as its components cocones over each of the `F \u22d9 pi.eval C i`.\n-/\ndef cocone_comp_eval (c : cocone F) (i : I) : cocone (F \u22d9 pi.eval C i) :=\n{ X := c.X i,\n  \u03b9 :=\n  { app := \u03bb j, c.\u03b9.app j i,\n    naturality' := \u03bb j j' f, congr_fun (c.\u03b9.naturality f) i, } }\n\n/--\nGiven a family of cones over the `F \u22d9 pi.eval C i`, we can assemble these together as a `cone F`.\n-/\ndef cone_of_cone_comp_eval (c : \u03a0 i, cone (F \u22d9 pi.eval C i)) : cone F :=\n{ X := \u03bb i, (c i).X,\n  \u03c0 :=\n  { app := \u03bb j i, (c i).\u03c0.app j,\n    naturality' := \u03bb j j' f, by { ext i, exact (c i).\u03c0.naturality f, } } }\n\n/--\nGiven a family of cocones over the `F \u22d9 pi.eval C i`,\nwe can assemble these together as a `cocone F`.\n-/\ndef cocone_of_cocone_comp_eval (c : \u03a0 i, cocone (F \u22d9 pi.eval C i)) : cocone F :=\n{ X := \u03bb i, (c i).X,\n  \u03b9 :=\n  { app := \u03bb j i, (c i).\u03b9.app j,\n    naturality' := \u03bb j j' f, by { ext i, exact (c i).\u03b9.naturality f, } } }\n\n/--\nGiven a family of limit cones over the `F \u22d9 pi.eval C i`,\nassembling them together as a `cone F` produces a limit cone.\n-/\ndef cone_of_cone_eval_is_limit {c : \u03a0 i, cone (F \u22d9 pi.eval C i)} (P : \u03a0 i, is_limit (c i)) :\n  is_limit (cone_of_cone_comp_eval c) :=\n{ lift := \u03bb s i, (P i).lift (cone_comp_eval s i),\n  fac' := \u03bb s j,\n  begin\n    ext i,\n    exact (P i).fac (cone_comp_eval s i) j,\n  end,\n  uniq' := \u03bb s m w,\n  begin\n    ext i,\n    exact (P i).uniq (cone_comp_eval s i) (m i) (\u03bb j, congr_fun (w j) i)\n  end }\n\n/--\nGiven a family of colimit cocones over the `F \u22d9 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 : \u03a0 i, cocone (F \u22d9 pi.eval C i)} (P : \u03a0 i, is_colimit (c i)) :\n  is_colimit (cocone_of_cocone_comp_eval c) :=\n{ desc := \u03bb s i, (P i).desc (cocone_comp_eval s i),\n  fac' := \u03bb s j,\n  begin\n    ext i,\n    exact (P i).fac (cocone_comp_eval s i) j,\n  end,\n  uniq' := \u03bb s m w,\n  begin\n    ext i,\n    exact (P i).uniq (cocone_comp_eval s i) (m i) (\u03bb j, congr_fun (w j) i)\n  end }\n\nsection\n\nvariables [\u2200 i, has_limit (F \u22d9 pi.eval C i)]\n\n/--\nIf we have a functor `F : J \u2964 \u03a0 i, C i` into a category of indexed families,\nand we have limits for each of the `F \u22d9 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 (\u03bb i, limit.cone _),\n  is_limit := cone_of_cone_eval_is_limit (\u03bb i, limit.is_limit _), }\n\nend\n\nsection\n\nvariables [\u2200 i, has_colimit (F \u22d9 pi.eval C i)]\n\n/--\nIf we have a functor `F : J \u2964 \u03a0 i, C i` into a category of indexed families,\nand colimits exist for each of the `F \u22d9 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 (\u03bb i, colimit.cocone _),\n  is_colimit := cocone_of_cocone_eval_is_colimit (\u03bb 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 \u2192 Type v\u2081) := \u27e8by apply_instance\u27e9\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 \u03b1 : Type\n\n@[reducible]\nprivate def pred := \u03b1 \u2192 Prop\n\nstructure program : Type 2 :=\n  (asm : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  (mch : nondet.program \u03b1)\n\nparameter {\u03b1}\n\nstructure compatible {t : Type} (hasm : \u03b1 \u2192 \u03b1 \u2192 Prop) (m : t \u2192 program) : Prop :=\n  (step : \u2200 i j, i \u2260 j \u2192 \u2200 s s', is_step (m j).mch s s' \u2192 (m i).asm s s')\n  (asm : \u2200 i, \u2200 s s', hasm s s' \u2192 (m i).asm s s')\n\nnoncomputable def compose {t : Type} (m : t \u2192 program) {s\u2080 : \u03b1}\n  (hasm : \u03b1 \u2192 \u03b1 \u2192 Prop)\n  (h\u2080 : \u2200 i, (m i).mch.first s\u2080)\n  (h : compatible hasm m)\n  [scheduling.sched t]\n  [\u2200 i, scheduling.sched (m i).mch.lbl]\n: program :=\n{ mch :=\n    { lbl := \u03a3 i, (m i).mch.lbl\n    , lbl_is_sched := by apply_instance\n    , first := \u03bb s, \u2200 i, (m i).mch.first s\n    , first_fis := \u27e8_,h\u2080\u27e9\n    , event' := \u03bb i, (m i.1).mch.event' i.2 }\n, asm := hasm }\n\ndef step (p : program) (s s' : \u03b1) : Prop :=\nnondet.is_step p.mch s s' \u2228 p.asm s s'\n\ninstance : system program :=\n{ \u03c3 := \u03b1\n, init := nondet.program.init \u2218 program.mch\n, step := step\n, transient := nondet.program.transient \u2218 program.mch\n, transient_false := \u03bb s, @system.transient_false _ _ s.mch\n, transient_antimono := \u03bb s, @system.transient_antimono _ _ s.mch }\n\nstructure program.ex (s : program) (\u03c4 : stream \u03b1) : Prop :=\n    (init : s.mch.first (\u03c4 0))\n    (safety : unitb.saf_ex s \u03c4)\n    (liveness : \u2200 e, fair' s.mch e \u03c4)\n\nlemma ex_of_ex_mch (s : program) (\u03c4 : stream \u03b1)\n  (h : s.mch.ex \u03c4)\n: s.ex \u03c4 :=\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 := \u03bb p, program.ex p\n, init_sem  := \u03bb s p \u03c4 H\u03c4 H\u2080, by { apply H\u2080, apply H\u03c4.init }\n, inhabited := \u03bb s, exists_imp_exists (ex_of_ex_mch s) (system_sem.inhabited s.mch)\n, safety    := \u03bb s p, decomposition.program.ex.safety\n, transient_sem := \u03bb s p q \u03c4 H\u03c4 T, by apply transient.semantics' _ H\u03c4.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 : \u2200 f : polynomial F, f.degree > 1 \u2192 \u2203 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 : \u2200 x : K, \u2203 f : polynomial F, f.monic \u2227 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 \u2243 K :=\n(hom : is_ring_hom to_fun)\n(fix : \u2200 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) : \u2200 f g : Gal i, (\u2200 x, f.to_equiv x = g.to_equiv x) \u2192 f = g\n| \u27e8_, _, _\u27e9 \u27e8_, _, _\u27e9 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(\u22a5 : ideal R).radical = \u22a5\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 \u2297 (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) \u2192 Gal S.algebra)\n(proj_commutes : \u2200 f : Gal (algebraic_closure F), \u2200 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 := \u03bb f g, \u27e8f.to_equiv.trans g.to_equiv,\n    @@is_ring_hom.comp _ _ _ f.hom _ _ g.hom,\n    \u03bb _, by simp [equiv.trans, f.fix, g.fix]\u27e9,\n  mul_assoc := \u03bb _ _ _, Gal.ext _ _ _ $ \u03bb _, by simp,\n  one := \u27e8equiv.refl _, is_ring_hom.id, \u03bb _, rfl\u27e9,\n  one_mul := \u03bb _, Gal.ext _ _ _ $ \u03bb _, rfl,\n  mul_one := \u03bb _, Gal.ext _ _ _ $ \u03bb _, rfl,\n  inv := \u03bb f, \u27e8f.to_equiv.symm,\n      \u27e8show f.to_equiv.symm 1 = 1,\n        by rw [equiv.symm_apply_eq, is_ring_hom.map_one f.to_equiv],\n      \u03bb 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      \u03bb 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]\u27e9,\n    \u03bb x, show f.to_equiv.symm (i x) = i x,\n      by rw equiv.symm_apply_eq; from (f.fix x).symm\u27e9,\n  mul_left_inv := \u03bb _, Gal.ext _ _ _ $ \u03bb _,\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) := \u22a4\n\ninstance Gal.finite_Galois_extension.topological_group (E : finite_Galois_extension F) :\n  topological_group (Gal E.S.algebra) :=\n{ continuous_mul := \u03bb x1 h1, by apply is_open_prod_iff.2; intros x y H;\n    refine \u27e8{x}, {y}, trivial, trivial, _, _, _\u27e9; 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  (\u03a0 E : finite_Galois_extension F, Gal E.S.algebra)\n  (\u03bb f E, E.proj f)\n  (@Pi.topological_space _ _ (\u03bb _, \u22a4))\n\ninstance Gal.topological_group : topological_group (Gal $ algebraic_closure F) :=\n@topological_group.induced _ _ _ _ _\n  (@Pi.topological_group (finite_Galois_extension F) (\u03bb E, Gal E.S.algebra) _ _ _)\n  (\u03bb 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 \u22a2;\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 | \u2200 x \u2208 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 := \u03bb 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 := \u03bb x hx, rfl,\n  inv_mem := \u03bb 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 := \u03bb 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 \u27e8x, hx\u27e9,\n    by simp at this \u22a2; rw [\u2190 this, hf, this];\n      [simp, from (((E.proj g).to_equiv) \u27e8x, hx\u27e9).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 \u2297[R] N)\n/-- (implementation) tensor product of morphisms R-modules -/\ndef tensor_hom {M N M' N' : Module R} (f : M \u27f6 N) (g : M' \u27f6 N') :\n  tensor_obj M M' \u27f6 tensor_obj N N' :=\ntensor_product.map f g\n\nlemma tensor_id (M N : Module R) : tensor_hom (\ud835\udfd9 M) (\ud835\udfd9 N) = \ud835\udfd9 (Module.of R (\u21a5M \u2297 \u21a5N)) :=\nby tidy\n\nlemma tensor_comp {X\u2081 Y\u2081 Z\u2081 X\u2082 Y\u2082 Z\u2082 : Module R}\n  (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (g\u2081 : Y\u2081 \u27f6 Z\u2081) (g\u2082 : Y\u2082 \u27f6 Z\u2082) :\n    tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082) = tensor_hom f\u2081 f\u2082 \u226b tensor_hom g\u2081 g\u2082 :=\nby tidy\n\n/-- (implementation) the associator for R-modules -/\ndef associator (M N K : Module R) : tensor_obj (tensor_obj M N) K \u2245 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\u2081 X\u2082 X\u2083 : Type*}\n  [add_comm_monoid X\u2081] [add_comm_monoid X\u2082] [add_comm_monoid X\u2083]\n  [module R X\u2081] [module R X\u2082] [module R X\u2083]\n  {Y\u2081 Y\u2082 Y\u2083 : Type*}\n  [add_comm_monoid Y\u2081] [add_comm_monoid Y\u2082] [add_comm_monoid Y\u2083]\n  [module R Y\u2081] [module R Y\u2082] [module R Y\u2083]\n  (f\u2081 : X\u2081 \u2192\u2097[R] Y\u2081) (f\u2082 : X\u2082 \u2192\u2097[R] Y\u2082) (f\u2083 : X\u2083 \u2192\u2097[R] Y\u2083) :\n  (\u2191(assoc R Y\u2081 Y\u2082 Y\u2083) \u2218\u2097 (map (map f\u2081 f\u2082) f\u2083)) = ((map f\u2081 (map f\u2082 f\u2083)) \u2218\u2097 \u2191(assoc R X\u2081 X\u2082 X\u2083)) :=\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 \u2192\u2097[R] W) (assoc R X Y Z).to_linear_map).comp (assoc R W (X \u2297[R] Y) Z).to_linear_map)\n    .comp (map \u2191(assoc R W X Y) (1 : Z \u2192\u2097[R] Z)) =\n  (assoc R W X (Y \u2297[R] Z)).to_linear_map.comp (assoc R (W \u2297[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\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : Module R}\n  (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083) :\n    tensor_hom (tensor_hom f\u2081 f\u2082) f\u2083 \u226b (associator Y\u2081 Y\u2082 Y\u2083).hom =\n    (associator X\u2081 X\u2082 X\u2083).hom \u226b tensor_hom f\u2081 (tensor_hom f\u2082 f\u2083) :=\nby convert associator_naturality_aux f\u2081 f\u2082 f\u2083 using 1\n\nlemma pentagon (W X Y Z : Module R) :\n  tensor_hom (associator W X Y).hom (\ud835\udfd9 Z) \u226b (associator W (tensor_obj X Y) Z).hom\n  \u226b tensor_hom (\ud835\udfd9 W) (associator X Y Z).hom =\n    (associator (tensor_obj W X) Y Z).hom \u226b (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 \u2297[R] M) \u2245 M :=\n(linear_equiv.to_Module_iso (tensor_product.lid R M) : of R (R \u2297 M) \u2245 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 \u2297[R] R) \u2245 M :=\n(linear_equiv.to_Module_iso (tensor_product.rid R M) : of R (M \u2297 R) \u2245 of R M).trans (of_self_iso M)\n\nlemma right_unitor_naturality {M N : Module R} (f : M \u27f6 N) :\n  tensor_hom f (\ud835\udfd9 (Module.of R R)) \u226b (right_unitor N).hom = (right_unitor M).hom \u226b 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 \u226b tensor_hom (\ud835\udfd9 M) (left_unitor N).hom =\n    tensor_hom (right_unitor M).hom (\ud835\udfd9 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'               := \u03bb M N, tensor_id M N,\n  tensor_comp'             := \u03bb M N K M' N' K' f g h, tensor_comp f g h,\n  associator_naturality'   := \u03bb M N K M' N' K' f g h, associator_naturality f g h,\n  left_unitor_naturality'  := \u03bb M N f, left_unitor_naturality f,\n  right_unitor_naturality' := \u03bb M N f, right_unitor_naturality f,\n  pentagon'                := \u03bb M N K L, pentagon M N K L,\n  triangle'                := \u03bb M N, triangle M N, }\n\n/-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative ring. -/\ninstance : comm_ring ((\ud835\udfd9_ (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 \u27f6 L) (g : M \u27f6 N) (k : K) (m : M) :\n  (f \u2297 g) (k \u2297\u209c m) = f k \u2297\u209c g m := rfl\n\n@[simp]\nlemma left_unitor_hom_apply {M : Module.{u} R} (r : R) (m : M) :\n  ((\u03bb_ M).hom : \ud835\udfd9_ (Module R) \u2297 M \u27f6 M) (r \u2297\u209c[R] m) = r \u2022 m :=\ntensor_product.lid_tmul m r\n\n@[simp]\nlemma left_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((\u03bb_ M).inv : M \u27f6 \ud835\udfd9_ (Module.{u} R) \u2297 M) m = 1 \u2297\u209c[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  ((\u03c1_ M).hom : M \u2297 \ud835\udfd9_ (Module R) \u27f6 M) (m \u2297\u209c r) = r \u2022 m :=\ntensor_product.rid_tmul m r\n\n@[simp]\nlemma right_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((\u03c1_ M).inv : M \u27f6 M \u2297 \ud835\udfd9_ (Module.{u} R)) m = m \u2297\u209c[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  ((\u03b1_ M N K).hom : (M \u2297 N) \u2297 K \u27f6 M \u2297 (N \u2297 K)) ((m \u2297\u209c n) \u2297\u209c k) = (m \u2297\u209c (n \u2297\u209c k)) := rfl\n\n@[simp]\nlemma associator_inv_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((\u03b1_ M N K).inv : M \u2297 (N \u2297 K) \u27f6 (M \u2297 N) \u2297 K) (m \u2297\u209c (n \u2297\u209c k)) = ((m \u2297\u209c n) \u2297\u209c k) := rfl\n\nend monoidal_category\n\n/-- (implementation) the braiding for R-modules -/\ndef braiding (M N : Module R) : tensor_obj M N \u2245 tensor_obj N M :=\nlinear_equiv.to_Module_iso (tensor_product.comm R M N)\n\n@[simp] lemma braiding_naturality {X\u2081 X\u2082 Y\u2081 Y\u2082 : Module.{u} R} (f : X\u2081 \u27f6 Y\u2081) (g : X\u2082 \u27f6 Y\u2082) :\n  (f \u2297 g) \u226b (Y\u2081.braiding Y\u2082).hom =\n    (X\u2081.braiding X\u2082).hom \u226b (g \u2297 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  (\u03b1_ X Y Z).hom \u226b (braiding X _).hom \u226b (\u03b1_ Y Z X).hom =\n  ((braiding X Y).hom \u2297 \ud835\udfd9 Z) \u226b (\u03b1_ Y X Z).hom \u226b (\ud835\udfd9 Y \u2297 (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  (\u03b1_ X Y Z).inv \u226b (braiding _ Z).hom \u226b (\u03b1_ Z X Y).inv =\n  (\ud835\udfd9 X \u2297 (Y.braiding Z).hom) \u226b (\u03b1_ X Z Y).inv \u226b ((X.braiding Z).hom \u2297 \ud835\udfd9 Y) :=\nbegin\n  apply (cancel_epi (\u03b1_ 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' := \u03bb X\u2081 X\u2082 Y\u2081 Y\u2082 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  ((\u03b2_ M N).hom : M \u2297 N \u27f6 N \u2297 M) (m \u2297\u209c n) = n \u2297\u209c m := rfl\n\n@[simp] lemma braiding_inv_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((\u03b2_ M N).inv : N \u2297 M \u27f6 M \u2297 N) (n \u2297\u209c m) = m \u2297\u209c 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 \u27f6 P) \u2243\n    (N \u27f6 ((linear_coyoneda R (Module R)).obj (op M)).obj P) :=\n{ to_fun := \u03bb f, linear_map.compr\u2082 (tensor_product.mk R N M) ((\u03b2_ N M).hom \u226b f),\n  inv_fun := \u03bb f, (\u03b2_ M N).hom \u226b tensor_product.lift f,\n  left_inv := \u03bb f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr\u2082_apply,\n      function.comp_app, coe_comp, monoidal_category.braiding_hom_apply],\n  end,\n  right_inv := \u03bb f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr\u2082_apply,\n      symmetric_category.symmetry_assoc],\n  end, }\n\ninstance : monoidal_closed (Module.{u} R) :=\n{ closed' := \u03bb 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 := \u03bb 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 \u2297 N \u27f6 P) (x : M) (y : N) :\n  @coe_fn _ _ linear_map.has_coe_to_fun ((monoidal_closed.curry f : N \u2192\u2097[R] (M \u2192\u2097[R] P)) y) x =\n    f (x \u2297\u209c[R] y) :=\nrfl\n\n@[simp]\nlemma monoidal_closed_uncurry {M N P : Module.{u} R}\n  (f : N \u27f6 (M \u27f6[Module.{u} R] P)) (x : M) (y : N) :\n  monoidal_closed.uncurry f (x \u2297\u209c[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 : \u2115`. We prove that the obvious inclusion functor `Fintype.skeleton \u2964 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 := \u27e8\u27e8pempty\u27e9\u27e9\ninstance {X : Fintype} : fintype X := X.2\n\ninstance : category Fintype := induced_category.category bundled.\u03b1\n\n/-- The fully faithful embedding of `Fintype` into the category of types. -/\n@[derive [full, faithful], simps]\ndef incl : Fintype \u2964 Type* := induced_functor _\n\ninstance : concrete_category Fintype := \u27e8incl\u27e9\n\n/--\nThe \"standard\" skeleton for `Fintype`. This is the full subcategory of `Fintype` spanned by objects\nof the form `fin n` for `n : \u2115`. We parameterize the objects of `Fintype.skeleton` directly as `\u2115`,\nas the type `fin m \u2243 fin n` is nonempty if and only if `n = m`.\n-/\ndef skeleton := \u2115\n\nnamespace skeleton\n\n/-- Given any natural number `n`, this creates the associated object of `Fintype.skeleton`. -/\ndef mk : \u2115 \u2192 skeleton := id\n\ninstance : inhabited skeleton := \u27e8mk 0\u27e9\n\n/-- Given any object of `Fintype.skeleton`, this returns the associated natural number. -/\ndef to_nat : skeleton \u2192 \u2115 := id\n\ninstance : category skeleton :=\n{ hom := \u03bb X Y, fin X \u2192 fin Y,\n  id := \u03bb _, id,\n  comp := \u03bb _ _ _ f g, g \u2218 f }\n\nlemma is_skeletal : skeletal skeleton := \u03bb X Y \u27e8h\u27e9, fin.equiv_iff_eq.mp $ nonempty.intro $\n{ to_fun := h.1,\n  inv_fun := h.2,\n  left_inv := \u03bb _, by {change (h.hom \u226b h.inv) _ = _, simpa},\n  right_inv := \u03bb _, by {change (h.inv \u226b h.hom) _ = _, simpa} }\n\n/-- The canonical fully faithful embedding of `Fintype.skeleton` into `Fintype`. -/\ndef incl : skeleton \u2964 Fintype :=\n{ obj := \u03bb X, Fintype.of (fin X),\n  map := \u03bb _ _ f, f }\n\ninstance : full incl := { preimage := \u03bb _ _ f, f }\ninstance : faithful incl := {}\ninstance : ess_surj incl :=\n{ mem_ess_image := \u03bb X,\n  let F := fintype.equiv_fin X in\n  \u27e8fintype.card X, \u27e8\u27e8F.symm, F, F.self_comp_symm, F.symm_comp_self\u27e9\u27e9\u27e9 }\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 \u224c Fintype := incl.as_equivalence\n\n@[simp] lemma incl_mk_nat_card (n : \u2115) : 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 \u2115,\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 : \u2115)\n(p : x = 0)\n\nlemma test_terminal_goal_2 : \u2203 F : terminal_goal_struct, F = \u27e8 0, by refl \u27e9 :=\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 : \u2115 \u2192 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 \u2115,\n  exact []\nend\n\ndef f : unit \u2192 Type := \u03bb _, \u2115\n\ndef test_terminal_goal_4 : \u03a3 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 \u2115 :=\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\nimport field_theory.finite.basic\nimport field_theory.tower\nimport field_theory.subfield\nimport linear_algebra.finite_dimensional\n\n\nuniverse u\n\nvariables {F0 F1 F2 : Type u} [F0_field: field F0] [F1_field: field F1] [F2_field: field F2]\nvariables [F1_in_F0: algebra F0 F1] [F2_in_F1: algebra F1 F2]\n\n\n\n/- Prove F2 is a subfield of F0-/\nlemma zero_in_F0_is_0_in_F2 : F2_field.one \u2208 F2_field :=\nbegin\n  sorry,\nend\n\n", "meta": {"author": "Jun2M", "repo": "lean_WSL", "sha": "c2e274196f48861206810c6b1bf20c1660723e7e", "save_path": "github-repos/lean/Jun2M-lean_WSL", "path": "github-repos/lean/Jun2M-lean_WSL/lean_WSL-c2e274196f48861206810c6b1bf20c1660723e7e/src/Galois.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.810478926981208, "lm_q2_score": 0.5660185351961015, "lm_q1q2_score": 0.4587460950572115}}
{"text": "import tactic\n\nnamespace vilnius\n\n\n/- ### implication -/\n\nexample (P Q : Prop) : P \u2192 Q \u2192 P :=\nbegin\n  sorry\nend\n\n/- ### not -/\n\nexample (P Q : Prop) : (P \u2192 \u00ac Q) \u2192 (Q \u2192 \u00ac P) :=\nbegin\n  sorry\nend\n\n\n/- ### and -/\n\nexample (P Q : Prop) : P \u2227 Q \u2192 Q :=\nbegin\n  sorry\nend\n\nexample (P Q : Prop) : P \u2192 Q \u2192 P \u2227 Q :=\nbegin\n  sorry,\nend\n\n\nexample (P Q : Prop) : P \u2227 Q \u2192 Q \u2227 P :=\nbegin\n  sorry\nend\n\n\nexample (P : Prop) : P \u2227 \u00ac P \u2192 false :=\nbegin\n  sorry,\nend\n\n\n/- ## Or -/\n\n\nexample (P Q : Prop) : \u00ac P \u2228 Q \u2192 P \u2192 Q :=\nbegin\n  sorry,\nend\n\n\nexample (P Q R : Prop) : P \u2228 (Q \u2227 R) \u2192 \u00ac P \u2192 \u00ac Q \u2192 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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R`, where `I\u2081 : R\u2081 \u2192+* R` and `I\u2082 : R\u2082 \u2192+* R` are ring homomorphisms and\n`M\u2081` is a module over `R\u2081` and `M\u2082` is a module over `R\u2082`.\nSesquilinear forms are the special case that `M\u2081 = M\u2082`, `R\u2081 = R\u2082 = R`, and `I\u2081 = ring_hom.id R`.\nTaking additionally `I\u2082 = 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\u2081 R\u2082 R\u2083 M M\u2081 M\u2082 M\u2097\u2081 M\u2097\u2081' M\u2097\u2082 M\u2097\u2082' K K\u2081 K\u2082 V V\u2081 V\u2082 n : Type*}\n\nnamespace linear_map\n\n/-! ### Orthogonal vectors -/\n\nsection comm_ring\n\n-- the `\u2097` subscript variables are for special cases about linear (as opposed to semilinear) maps\nvariables [comm_semiring R] [comm_semiring R\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  [comm_semiring R\u2082] [add_comm_monoid M\u2082] [module R\u2082 M\u2082]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2082 \u2192+* R} {I\u2081' : R\u2081 \u2192+* R}\n\n/-- The proposition that two elements of a sesquilinear form space are orthogonal -/\ndef is_ortho (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x y) : Prop := B x y = 0\n\nlemma is_ortho_def {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} {x y} : B.is_ortho x y \u2194 B x y = 0 := iff.rfl\n\nlemma is_ortho_zero_left (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x) : is_ortho B (0 : M\u2081) x :=\nby { dunfold is_ortho, rw [ map_zero B, zero_apply] }\n\nlemma is_ortho_zero_right (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) (x) : is_ortho B x (0 : M\u2082) :=\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 \u2260 j`, `B (v i) (v j) = 0`. For orthogonality between two elements, use\n`bilin_form.is_ortho` -/\ndef is_Ortho (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2081'] R) (v : n \u2192 M\u2081) : Prop :=\npairwise (B.is_ortho on v)\n\nlemma is_Ortho_def {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2081'] R} {v : n \u2192 M\u2081} :\n  B.is_Ortho v \u2194 \u2200 i j : n, i \u2260 j \u2192 B (v i) (v j) = 0 := iff.rfl\n\nlemma is_Ortho_flip (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2081'] R) {v : n \u2192 M\u2081} :\n  B.is_Ortho v \u2194 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\u2081] [add_comm_group V\u2081] [module K\u2081 V\u2081]\n  [field K\u2082] [add_comm_group V\u2082] [module K\u2082 V\u2082]\n  {I\u2081 : K\u2081 \u2192+* K} {I\u2082 : K\u2082 \u2192+* K} {I\u2081' : K\u2081 \u2192+* K}\n  {J\u2081 : K \u2192+* K} {J\u2082 : K \u2192+* K}\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J\u2081 is invertible\nlemma ortho_smul_left {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2082 \u2192\u209b\u2097[I\u2082] K} {x y} {a : K\u2081} (ha : a \u2260 0) :\n  (is_ortho B x y) \u2194 (is_ortho B (a \u2022 x) y) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smul\u209b\u2097\u2082, H, smul_zero]},\n  { rw [map_smul\u209b\u2097\u2082, smul_eq_zero] at H,\n    cases H,\n    { rw map_eq_zero I\u2081 at H, trivial },\n    { exact H }}\nend\n\n-- todo: this also holds for [comm_ring R] [is_domain R] when J\u2082 is invertible\nlemma ortho_smul_right {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2082 \u2192\u209b\u2097[I\u2082] K} {x y} {a : K\u2082} {ha : a \u2260 0} :\n(is_ortho B x y) \u2194 (is_ortho B x (a \u2022 y)) :=\nbegin\n  dunfold is_ortho,\n  split; intro H,\n  { rw [map_smul\u209b\u2097, H, smul_zero] },\n  { rw [map_smul\u209b\u2097, 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) \u2260 0`. -/\nlemma linear_independent_of_is_Ortho {B : V\u2081 \u2192\u209b\u2097[I\u2081] V\u2081 \u2192\u209b\u2097[I\u2081'] K} {v : n \u2192 V\u2081}\n  (hv\u2081 : B.is_Ortho v) (hv\u2082 : \u2200 i, \u00ac B.is_ortho (v i) (v i)) : linear_independent K\u2081 v :=\nbegin\n  classical,\n  rw linear_independent_iff',\n  intros s w hs i hi,\n  have : B (s.sum $ \u03bb (i : n), w i \u2022 v i) (v i) = 0,\n  { rw [hs, map_zero, zero_apply] },\n  have hsum : s.sum (\u03bb (j : n), I\u2081(w j) * B (v j) (v i)) = I\u2081(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\u2081 _ _ hij, mul_zero], },\n  simp_rw [B.map_sum\u2082, map_smul\u209b\u2097\u2082, smul_eq_mul, hsum] at this,\n  apply (map_eq_zero I\u2081).mp,\n  exact eq_zero_of_ne_zero_of_mul_right_eq_zero (hv\u2082 i) this,\nend\n\nend field\n\n\n/-! ### Reflexive bilinear forms -/\n\nsection reflexive\n\nvariables [comm_semiring R] [comm_semiring R\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2081 \u2192+* R}\n  {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R}\n\n/-- The proposition that a sesquilinear form is reflexive -/\ndef is_refl (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : Prop :=\n  \u2200 (x y), B x y = 0 \u2192 B y x = 0\n\nnamespace is_refl\n\nvariable (H : B.is_refl)\n\nlemma eq_zero : \u2200 {x y}, B x y = 0 \u2192 B y x = 0 := \u03bb x y, H x y\n\nlemma ortho_comm {x y} : is_ortho B x y \u2194 is_ortho B y x := \u27e8eq_zero H, eq_zero H\u27e9\n\nlemma dom_restrict_refl (H : B.is_refl) (p : submodule R\u2081 M\u2081) : (B.dom_restrict\u2081\u2082 p p).is_refl :=\n\u03bb _ _, by { simp_rw dom_restrict\u2081\u2082_apply, exact H _ _}\n\n@[simp] lemma flip_is_refl_iff : B.flip.is_refl \u2194 B.is_refl :=\n\u27e8\u03bb h x y H, h y x ((B.flip_apply _ _).trans H), \u03bb h x y, h y x\u27e9\n\nlemma ker_flip_eq_bot (H : B.is_refl) (h : B.ker = \u22a5) : B.flip.ker = \u22a5 :=\nbegin\n  refine ker_eq_bot'.mpr (\u03bb _ 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 = \u22a5 \u2194 B.flip.ker = \u22a5 :=\nbegin\n  refine \u27e8ker_flip_eq_bot H, \u03bb h, _\u27e9,\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 \u2192+* R} {B : M \u2192\u209b\u2097[I] M \u2192\u2097[R] R}\n\n/-- The proposition that a sesquilinear form is symmetric -/\ndef is_symm (B : M \u2192\u209b\u2097[I] M \u2192\u2097[R] R) : Prop :=\n  \u2200 (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 := \u03bb x y H1, by { rw \u2190H.eq, simp [H1] }\n\nlemma ortho_comm (H : B.is_symm) {x y} : is_ortho B x y \u2194 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\u2081\u2082 p p).is_symm :=\n\u03bb _ _, by { simp_rw dom_restrict\u2081\u2082_apply, exact H _ _}\n\nend is_symm\n\nlemma is_symm_iff_eq_flip {B : M \u2192\u2097[R] M \u2192\u2097[R] R} : B.is_symm \u2194 B = B.flip :=\nbegin\n  split; intro h,\n  { ext,\n    rw [\u2190h, 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\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2081 \u2192+* R} {I : R\u2081 \u2192+* R} {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R}\n\n/-- The proposition that a sesquilinear form is alternating -/\ndef is_alt (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : Prop := \u2200 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 [\u2190neg H, h, neg_zero],\nend\n\nlemma ortho_comm {x y} : is_ortho B x y \u2194 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\u2081 \u2192\u209b\u2097[I] M\u2081 \u2192\u209b\u2097[I] R} :\n  B.is_alt \u2194 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\u2082 h x x,\n  simp only [neg_apply, flip_apply, \u2190add_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\u2081] [add_comm_group M\u2081] [module R\u2081 M\u2081]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2081 \u2192+* R}\n  {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] 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\u2081 M\u2081) (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2081 \u2192\u209b\u2097[I\u2082] R) : submodule R\u2081 M\u2081 :=\n{ carrier := { m | \u2200 n \u2208 N, B.is_ortho n m },\n  zero_mem' := \u03bb x _, B.is_ortho_zero_right x,\n  add_mem' := \u03bb 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' := \u03bb c x hx n hn,\n    by rw [linear_map.is_ortho, linear_map.map_smul\u209b\u2097, show B n x = 0, by exact hx n hn,\n        smul_zero] }\n\nvariables {N L : submodule R\u2081 M\u2081}\n\n@[simp] lemma mem_orthogonal_bilin_iff {m : M\u2081} :\n  m \u2208 N.orthogonal_bilin B \u2194 \u2200 n \u2208 N, B.is_ortho n m := iff.rfl\n\nlemma orthogonal_bilin_le (h : N \u2264 L) : L.orthogonal_bilin B \u2264 N.orthogonal_bilin B :=\n\u03bb _ hn l hl, hn l (h hl)\n\nlemma le_orthogonal_bilin_orthogonal_bilin (b : B.is_refl) :\n  N \u2264 (N.orthogonal_bilin B).orthogonal_bilin B :=\n\u03bb 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\u2081] [add_comm_group V\u2081] [module K\u2081 V\u2081]\n  {J : K \u2192+* K} {J\u2081 : K\u2081 \u2192+* K} {J\u2081' : K\u2081 \u2192+* K}\n\n-- \u2193 This lemma only applies in fields as we require `a * b = 0 \u2192 a = 0 \u2228 b = 0`\nlemma span_singleton_inf_orthogonal_eq_bot\n  (B : V\u2081 \u2192\u209b\u2097[J\u2081] V\u2081 \u2192\u209b\u2097[J\u2081'] K) (x : V\u2081) (hx : \u00ac B.is_ortho x x) :\n  (K\u2081 \u2219 x) \u2293 submodule.orthogonal_bilin (K\u2081 \u2219 x) B = \u22a5 :=\nbegin\n  rw \u2190 finset.coe_singleton,\n  refine eq_bot_iff.2 (\u03bb y h, _),\n  rcases mem_span_finset.1 h.1 with \u27e8\u03bc, rfl\u27e9,\n  have := h.2 x _,\n  { rw finset.sum_singleton at this \u22a2,\n    suffices h\u03bczero : \u03bc x = 0,\n    { rw [h\u03bczero, zero_smul, submodule.mem_bot] },\n    change B x (\u03bc x \u2022 x) = 0 at this, rw [map_smul\u209b\u2097, smul_eq_mul] at this,\n    exact or.elim (zero_eq_mul.mp this.symm)\n    (\u03bb y, by { simp at y, exact y })\n    (\u03bb hfalse, false.elim $ hx hfalse) },\n  { rw submodule.mem_span; exact \u03bb _ hp, hp $ finset.mem_singleton_self _ }\nend\n\n-- \u2193 This lemma only applies in fields since we use the `mul_eq_zero`\nlemma orthogonal_span_singleton_eq_to_lin_ker {B : V \u2192\u2097[K] V \u2192\u209b\u2097[J] K} (x : V) :\n  submodule.orthogonal_bilin (K \u2219 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 \u03bb h, h x \u27e81, one_smul _ _\u27e9 },\n  { rintro h _ \u27e8z, rfl\u27e9,\n    rw [is_ortho, map_smul\u209b\u2097\u2082, 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 \u2192\u2097[K] V \u2192\u2097[K] K}\n  {x : V} (hx : \u00ac B.is_ortho x x) :\n  (K \u2219 x) \u2294 submodule.orthogonal_bilin (K \u2219 x) B = \u22a4 :=\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 \u2260 0`, the span of the singleton of `x`\n  is complement to its orthogonal complement. -/\nlemma is_compl_span_singleton_orthogonal {B : V \u2192\u2097[K] V \u2192\u2097[K] K}\n  {x : V} (hx : \u00ac B.is_ortho x x) : is_compl (K \u2219 x) (submodule.orthogonal_bilin (K \u2219 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\u2081] [module R M\u2081]\nvariables [add_comm_monoid M\u2082] [module R M\u2082]\nvariables {I : R \u2192+* R}\nvariables {B F : M \u2192\u2097[R] M \u2192\u209b\u2097[I] R} {B' : M\u2081 \u2192\u2097[R] M\u2081 \u2192\u209b\u2097[I] R} {B'' : M\u2082 \u2192\u2097[R] M\u2082 \u2192\u209b\u2097[I] R}\nvariables {f f' : M \u2192\u2097[R] M\u2081} {g g' : M\u2081 \u2192\u2097[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 := \u2200 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\u2082 :\n  is_adjoint_pair B B' f g \u2194 B'.comp f = B.compl\u2082 g :=\nbegin\n  split; intros h,\n  { ext x y, rw [comp_apply, compl\u2082_apply], exact h x y },\n  { intros _ _, rw [\u2190compl\u2082_apply, \u2190comp_apply, h] },\nend\n\nlemma is_adjoint_pair_zero : is_adjoint_pair B B' 0 0 :=\n\u03bb _ _, by simp only [zero_apply, map_zero]\n\nlemma is_adjoint_pair_id : is_adjoint_pair B B 1 1 := \u03bb 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\u03bb x _, by rw [f.add_apply, g.add_apply, B'.map_add\u2082, (B x).map_add, h, h']\n\nlemma is_adjoint_pair.comp {f' : M\u2081 \u2192\u2097[R] M\u2082} {g' : M\u2082 \u2192\u2097[R] M\u2081}\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\u03bb _ _, 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\u2081] [module R M\u2081]\nvariables {B F : M \u2192\u2097[R] M \u2192\u2097[R] R} {B' : M\u2081 \u2192\u2097[R] M\u2081 \u2192\u2097[R] R}\nvariables {f f' : M \u2192\u2097[R] M\u2081} {g g' : M\u2081 \u2192\u2097[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\u03bb x _, by rw [f.sub_apply, g.sub_apply, B'.map_sub\u2082, (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 \u2022 f) (c \u2022 g) :=\n\u03bb _ _, 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 \u2192+* R}\nvariables (B F : M \u2192\u2097[R] M \u2192\u209b\u2097[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\u2081] [module R M\u2081]\n(B F : M \u2192\u2097[R] M \u2192\u2097[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'  := \u03bb f g hf hg, hf.add hg,\n  smul_mem' := \u03bb 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 \u2208 is_pair_self_adjoint_submodule B F \u2194 is_pair_self_adjoint B F f :=\niff.rfl\n\nlemma is_pair_self_adjoint_equiv (e : M\u2081 \u2243\u2097[R] M) (f : module.End R M) :\n  is_pair_self_adjoint B F f \u2194\n    is_pair_self_adjoint (B.compl\u2081\u2082 \u2191e \u2191e) (F.compl\u2081\u2082 \u2191e \u2191e) (e.symm.conj f) :=\nbegin\n  have h\u2097 : (F.compl\u2081\u2082 (\u2191e : M\u2081 \u2192\u2097[R] M) (\u2191e : M\u2081 \u2192\u2097[R] M)).comp (e.symm.conj f) =\n    (F.comp f).compl\u2081\u2082 (\u2191e : M\u2081 \u2192\u2097[R] M) (\u2191e : M\u2081 \u2192\u2097[R] M) :=\n  by { ext, simp only [linear_equiv.symm_conj_apply, coe_comp, linear_equiv.coe_coe, compl\u2081\u2082_apply,\n    linear_equiv.apply_symm_apply], },\n  have h\u1d63 : (B.compl\u2081\u2082 (\u2191e : M\u2081 \u2192\u2097[R] M) (\u2191e : M\u2081 \u2192\u2097[R] M)).compl\u2082 (e.symm.conj f) =\n    (B.compl\u2082 f).compl\u2081\u2082 (\u2191e : M\u2081 \u2192\u2097[R] M) (\u2191e : M\u2081 \u2192\u2097[R] M) :=\n  by { ext, simp only [linear_equiv.symm_conj_apply, compl\u2082_apply, coe_comp, linear_equiv.coe_coe,\n      compl\u2081\u2082_apply, linear_equiv.apply_symm_apply] },\n  have he : function.surjective (\u21d1(\u2191e : M\u2081 \u2192\u2097[R] M) : M\u2081 \u2192 M) := e.surjective,\n  simp_rw [is_pair_self_adjoint, is_adjoint_pair_iff_comp_eq_compl\u2082, h\u2097, h\u1d63,\n    compl\u2081\u2082_inj he he],\nend\n\nlemma is_skew_adjoint_iff_neg_self_adjoint (f : module.End R M) :\n  B.is_skew_adjoint f \u2194 is_adjoint_pair (-B) B f f :=\nshow (\u2200 x y, B (f x) y = B x ((-f) y)) \u2194 \u2200 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 \u2208 B.self_adjoint_submodule \u2194 B.is_self_adjoint f := iff.rfl\n\n@[simp] lemma mem_skew_adjoint_submodule (f : module.End R M) :\n  f \u2208 B.skew_adjoint_submodule \u2194 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\u2081] [add_comm_monoid M\u2081] [module R\u2081 M\u2081]\n  [comm_semiring R\u2082] [add_comm_monoid M\u2082] [module R\u2082 M\u2082]\n  {I\u2081 : R\u2081 \u2192+* R} {I\u2082 : R\u2082 \u2192+* R} {I\u2081' : R\u2081 \u2192+* 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\u2081`, there exists `y` in `M\u2082` with `B x y \u2260 0`.-/\ndef separating_left (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) : Prop :=\n\u2200 x : M\u2081, (\u2200 y : M\u2082, B x y = 0) \u2192 x = 0\n\nvariables (M\u2081 M\u2082 I\u2081 I\u2082)\n\n/-- In a non-trivial module, zero is not non-degenerate. -/\nlemma not_separating_left_zero [nontrivial M\u2081] : \u00ac(0 : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R).separating_left :=\nlet \u27e8m, hm\u27e9 := exists_ne (0 : M\u2081) in \u03bb h, hm (h m $ \u03bb n, rfl)\n\nvariables {M\u2081 M\u2082 I\u2081 I\u2082}\n\nlemma separating_left.ne_zero [nontrivial M\u2081] {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R}\n  (h : B.separating_left) : B \u2260 0 :=\n\u03bb h0, not_separating_left_zero M\u2081 M\u2082 I\u2081 I\u2082 $ h0 \u25b8 h\n\nsection linear\n\nvariables [add_comm_monoid M\u2097\u2081] [add_comm_monoid M\u2097\u2082] [add_comm_monoid M\u2097\u2081'] [add_comm_monoid M\u2097\u2082']\nvariables [module R M\u2097\u2081] [module R M\u2097\u2082] [module R M\u2097\u2081'] [module R M\u2097\u2082']\nvariables {B : M\u2097\u2081 \u2192\u2097[R] M\u2097\u2082 \u2192\u2097[R] R} (e\u2081 : M\u2097\u2081 \u2243\u2097[R] M\u2097\u2081') (e\u2082 : M\u2097\u2082 \u2243\u2097[R] M\u2097\u2082')\n\nlemma separating_left.congr (h : B.separating_left) :\n  (e\u2081.arrow_congr (e\u2082.arrow_congr (linear_equiv.refl R R)) B).separating_left :=\nbegin\n  intros x hx,\n  rw \u2190e\u2081.symm.map_eq_zero_iff,\n  refine h (e\u2081.symm x) (\u03bb y, _),\n  specialize hx (e\u2082 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\u2081.arrow_congr (e\u2082.arrow_congr (linear_equiv.refl R R)) B).separating_left \u2194 B.separating_left :=\n\u27e8\u03bb h, begin\n  convert h.congr e\u2081.symm e\u2082.symm,\n  ext x y,\n  simp,\nend, separating_left.congr e\u2081 e\u2082\u27e9\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\u2082`, there exists `x` in `M\u2081` with `B x y \u2260 0`.-/\ndef separating_right (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) : Prop :=\n\u2200 y : M\u2082, (\u2200 x : M\u2081, B x y = 0) \u2192 y = 0\n\n/-- A bilinear form is called non-degenerate if it is left-separating and right-separating. -/\ndef nondegenerate (B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R) : Prop := separating_left B \u2227 separating_right B\n\n@[simp] lemma flip_separating_right {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.flip.separating_right \u2194 B.separating_left := \u27e8\u03bb hB x hy, hB x hy, \u03bb hB x hy, hB x hy\u27e9\n\n@[simp] lemma flip_separating_left {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.flip.separating_left \u2194 separating_right B := by rw [\u2190flip_separating_right, flip_flip]\n\n@[simp] lemma flip_nondegenerate {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.flip.nondegenerate \u2194 B.nondegenerate :=\niff.trans and.comm (and_congr flip_separating_right flip_separating_left)\n\nlemma separating_left_iff_linear_nontrivial {B : M\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.separating_left \u2194 \u2200 x : M\u2081, B x = 0 \u2192 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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.separating_right \u2194 \u2200 y : M\u2082, B.flip y = 0 \u2192 y = 0 :=\nby rw [\u2190flip_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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.separating_left \u2194 B.ker = \u22a5 :=\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\u2081 \u2192\u209b\u2097[I\u2081] M\u2082 \u2192\u209b\u2097[I\u2082] R} :\n  B.separating_right \u2194 B.flip.ker = \u22a5 :=\nby rw [\u2190flip_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 \u2192+* R}\n\nlemma is_refl.nondegenerate_of_separating_left {B : M \u2192\u2097[R] M \u2192\u2097[R] R}\n  (hB : B.is_refl) (hB' : B.separating_left) : B.nondegenerate :=\nbegin\n  refine \u27e8hB', _\u27e9,\n  rw [separating_right_iff_flip_ker_eq_bot, hB.ker_eq_bot_iff_ker_flip_eq_bot.mp],\n  rwa \u2190separating_left_iff_ker_eq_bot,\nend\n\nlemma is_refl.nondegenerate_of_separating_right {B : M \u2192\u2097[R] M \u2192\u2097[R] R}\n  (hB : B.is_refl) (hB' : B.separating_right) : B.nondegenerate :=\nbegin\n  refine \u27e8_, hB'\u27e9,\n  rw [separating_left_iff_ker_eq_bot, hB.ker_eq_bot_iff_ker_flip_eq_bot.mpr],\n  rwa \u2190separating_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 \u2192\u2097[R] M \u2192\u2097[R] R} (hB : B.is_refl)\n  {W : submodule R M} (hW : disjoint W (W.orthogonal_bilin B)) :\n  (B.dom_restrict\u2081\u2082 W W).nondegenerate :=\nbegin\n  refine (hB.dom_restrict_refl W).nondegenerate_of_separating_left  _,\n  rintro \u27e8x, hx\u27e9 b\u2081,\n  rw [submodule.mk_eq_zero, \u2190 submodule.mem_bot R],\n  refine hW.le_bot \u27e8hx, \u03bb y hy, _\u27e9,\n  specialize b\u2081 \u27e8y, hy\u27e9,\n  simp_rw [dom_restrict\u2081\u2082_apply, submodule.coe_mk] at b\u2081,\n  rw hB.ortho_comm,\n  exact b\u2081,\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 \u2192\u209b\u2097[I] M \u2192\u209b\u2097[I'] R} {v : basis n R M} (h : B.is_Ortho v) (hB : B.separating_left)\n  (i : n) : \u00acB.is_ortho (v i) (v i) :=\nbegin\n  intro ho,\n  refine v.ne_zero i (hB (v i) $ \u03bb m, _),\n  obtain \u27e8vi, rfl\u27e9 := 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\u209b\u2097,\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 \u2192\u209b\u2097[I] M \u2192\u209b\u2097[I'] R} {v : basis n R M} (h : B.is_Ortho v) (hB : B.separating_right)\n  (i : n) : \u00acB.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 \u2192\u2097[R] M \u2192\u2097[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : \u2200 i, \u00acB.is_ortho (v i) (v i)) :\n  B.separating_left :=\nbegin\n  intros m hB,\n  obtain \u27e8vi, rfl\u27e9 := 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\u2082, map_smul\u209b\u2097\u2082,\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 \u2192\u2097[R] M \u2192\u2097[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : \u2200 i, \u00acB.is_ortho (v i) (v i)) :\n  B.separating_right :=\nbegin\n  rw is_Ortho_flip at hO,\n  rw [\u2190flip_separating_left],\n  refine is_Ortho.separating_left_of_not_is_ortho_basis_self v hO (\u03bb 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 \u2192\u2097[R] M \u2192\u2097[R] R} (v : basis n R M) (hO : B.is_Ortho v) (h : \u2200 i, \u00acB.is_ortho (v i) (v i)) :\n  B.nondegenerate :=\n\u27e8is_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\u27e9\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 {\u03b1 : Type} {p : Prop} (xs : List \u03b1) (h\u2081 : (a : \u03b1) \u2192 (as : List \u03b1) \u2192 xs = a :: as \u2192 p) (h\u2082 : xs = [] \u2192 p) : p :=\nby match (generalizing := false) h : xs with\n   | []    => exact h\u2082 h\n   | z::zs => apply h\u2081 z zs; assumption\n\ntheorem tst1' {\u03b1 : Type} {p : Prop} (xs : List \u03b1) (h\u2081 : (a : \u03b1) \u2192 (as : List \u03b1) \u2192 xs = a :: as \u2192 p) (h\u2082 : xs = [] \u2192 p) : p :=\nby match xs with\n   | []    => exact h\u2082 rfl\n   | z::zs => exact h\u2081 z zs rfl\n\ntheorem tst2 {\u03b1 : Type} {p : Prop} (xs : List \u03b1) (h\u2081 : (a : \u03b1) \u2192 (as : List \u03b1) \u2192 xs = a :: as \u2192 p) (h\u2082 : xs = [] \u2192 p) : p :=\nby match (generalizing := false) h:xs with\n   | []    => ?nilCase\n   | z::zs => ?consCase;\n   case consCase => exact h\u2081 z zs h;\n   case nilCase => exact h\u2082 h\n\ndef tst3 {\u03b1 \u03b2 \u03b3 : Type} (h : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3) : \u03b2 \u00d7 \u03b1 \u00d7 \u03b3 :=\nby {\n  match h with\n  | (a, b, c) => exact (b, a, c)\n}\n\ntheorem tst4 {\u03b1 : Type} {p : Prop} (xs : List \u03b1) (h\u2081 : (a : \u03b1) \u2192 (as : List \u03b1) \u2192 xs = a :: as \u2192 p) (h\u2082 : xs = [] \u2192 p) : p := by\nmatch (generalizing := false) h : xs with\n| []    => _\n| z::zs => _\ncase match_2 => exact h\u2081 z zs h\nexact h\u2082 h\n\ntheorem tst5 {p q r} (h : p \u2228 q \u2228 r) : r \u2228 q \u2228 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 \u2228 q \u2228 r) : r \u2228 q \u2228 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 \u2228 q \u2228 r) : r \u2228 q \u2228 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} {\u03b1 : Type u} : List \u03b1 \u2192 Type u\n| empty    : ListLast []\n| nonEmpty : (as : List \u03b1) \u2192 (a : \u03b1) \u2192 ListLast (as ++ [a])\n\naxiom last {\u03b1} (xs : List \u03b1) : ListLast xs\naxiom back {\u03b1} [Inhabited \u03b1] (xs : List \u03b1) : \u03b1\naxiom popBack {\u03b1} : List \u03b1 \u2192 List \u03b1\naxiom backEq {\u03b1} [Inhabited \u03b1] : (xs : List \u03b1) \u2192 (x : \u03b1) \u2192 back (xs ++ [x]) = x\naxiom popBackEq {\u03b1} : (xs : List \u03b1) \u2192 (x : \u03b1) \u2192 popBack (xs ++ [x]) = xs\n\ntheorem tst8 {\u03b1} [Inhabited \u03b1] (xs : List \u03b1) : xs \u2260 [] \u2192 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 {\u03b1} [Inhabited \u03b1] (xs : List \u03b1) : xs \u2260 [] \u2192 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' {\u03b1} [Inhabited \u03b1] (xs : List \u03b1) : xs \u2260 [] \u2192 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'' {\u03b1} [Inhabited \u03b1] (xs : List \u03b1) (h : xs \u2260 []) : 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 \u03b1) : 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 {\u03b1 : Type*} {\u03b2 : Type*} {s : set \u03b1}\n\ndef extend_by_zero [has_zero \u03b2] (f : s \u2192 \u03b2) : \u03b1 \u2192 \u03b2 :=\n\u03bb z, if h : z \u2208 s then f \u27e8z, h\u27e9 else 0\n\nlemma extend_by_zero_eq_of_mem [has_zero \u03b2] (f : s \u2192 \u03b2) (x : \u03b1) (hx : x \u2208 s):\n  (extend_by_zero f) x = f \u27e8 x, hx \u27e9 :=\nbegin\n  rw extend_by_zero, dsimp, split_ifs, tauto,\nend\n\nlemma extend_by_zero_zero [has_zero \u03b2] :\nextend_by_zero (\u03bb s, 0 : s \u2192 \u03b2) = (\u03bb h, 0) :=\nby ext z; by_cases h : z \u2208 s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_zero' [has_zero \u03b2] :\nextend_by_zero (0 : s \u2192 \u03b2) = 0 :=\nby ext z; by_cases h : z \u2208 s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_f_eq_zero [has_zero \u03b2] (f : s \u2192 \u03b2)\n(h : extend_by_zero f = 0) : f = 0 :=\nbegin\n\nsorry,\nend\n\nlemma extend_by_zero_f_neq_zero [has_zero \u03b2] (f : s \u2192 \u03b2)\n(h : extend_by_zero f \u2260 0) : f \u2260 0 :=\nbegin\n\nsorry,\nend\n\nlemma extend_by_zero_add [add_group \u03b2] (f g : s \u2192 \u03b2) :\nextend_by_zero (f + g) = extend_by_zero f + extend_by_zero g :=\nby ext z; by_cases h : z \u2208 s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_sum [add_comm_monoid \u03b2] (\u03b9  : finset \u03b1) (F : \u03b9 \u2192  s \u2192 \u03b2) :\nextend_by_zero (\u03bb (x : s), \u2211 (i : \u03b9 ), F i x) = \u2211 (i : \u03b9), extend_by_zero (F i) :=\nbegin\next z,\nby_cases h : z \u2208 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 \u03b2] (f g : s \u2192 \u03b2) :\nextend_by_zero (f * g) = extend_by_zero f * extend_by_zero g :=\nby ext z; by_cases h : z \u2208 s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_neg [add_group \u03b2] (f : s \u2192 \u03b2) :\nextend_by_zero (-f) = -extend_by_zero f :=\nby ext z; by_cases h : z \u2208 s; simp [extend_by_zero, h]\n\nlemma extend_by_zero_smul [ring \u03b2] (c : \u03b2) (f : s \u2192 \u03b2) :\n  extend_by_zero (c \u2022 f) = c \u2022 extend_by_zero f :=\n  by ext z; by_cases h : z \u2208 s; simp [extend_by_zero, h]\n\nend\n\ndef open_subs := topological_space.opens \u2102\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 \u2192 \u2102) : Prop :=\n  \u2200 z : D.1, \u2203 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 \u2192 \u2102):\n  differentiable_on \u2102 (extend_by_zero f) D.1 \u2194 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 \u27e8x, hx\u27e9,\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 : \u2102):\n\u2200 (y : \u2102), (y \u2208 (D.1 : set \u2102)) \u2192 extend_by_zero (\u03bb z : D.1, (c : \u2102)) 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 \u2192 \u2102) (y : \u2102) (h: y \u2208 (D.1 : set \u2102)):\n  extend_by_zero (f ) y = (f \u27e8 y, h\u27e9) :=\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 \u2192 \u2102) (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 : \u2102) : is_holomorphic_on (\u03bb z : D.1, (c : \u2102)) :=\nbegin\n  rw is_holomorphic_on,\n  intro z,\n  use (0: \u2102),\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 (\u03bb z : D.1, (0 : \u2102)) :=\nbegin\n  apply const_hol (0:\u2102 ),\nend\n\nlemma one_hol (D: open_subs) : is_holomorphic_on (\u03bb z : D.1, (1 : \u2102)) :=\nbegin\napply const_hol (1: \u2102),\n\nend\nlemma add_hol (f g : D.1 \u2192 \u2102) (f_hol : is_holomorphic_on f) (g_hol : is_holomorphic_on g) :\n  is_holomorphic_on (f + g) :=\nbegin\n  intro z\u2080,\n  cases f_hol z\u2080 with f'z\u2080 Hf,\n  cases g_hol z\u2080 with g'z\u2080 Hg,\n  existsi (f'z\u2080 + g'z\u2080),\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 \u2192 \u2102) (f_hol : is_holomorphic_on f) (g_hol : is_holomorphic_on g) :\n  is_holomorphic_on (f * g) :=\nbegin\n  intro z\u2080,\n  cases f_hol z\u2080 with f'z\u2080 Hf,\n  cases g_hol z\u2080 with g'z\u2080 Hg,\n  existsi f'z\u2080*(extend_by_zero g z\u2080) + (extend_by_zero f z\u2080)*g'z\u2080,\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 \u2192 \u2102) (f_hol : is_holomorphic_on f) : is_holomorphic_on (-f) :=\nbegin\n  intro z\u2080,\n  cases f_hol z\u2080 with f'z\u2080 H,\n  existsi -f'z\u2080,\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 \u2192 \u2102) :=\n{ carrier := {f : D.1 \u2192 \u2102 | 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 : \u2102) (f : D.1 \u2192 \u2102) (f_hol : is_holomorphic_on f) : is_holomorphic_on (c \u2022 f) :=\nbegin\n  intro z\u2080,\n  cases f_hol z\u2080 with f'z\u2080 Hf,\n  existsi c * f'z\u2080,\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 (\u2102)  (D.1 \u2192 \u2102) :=\n{ carrier := {f : D.1 \u2192 \u2102 | 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 \u2102) (h :  s \u2286 t) : s \u2229 d \u2286 t :=\nbegin\n  intros x hx,\n  apply h,\n  simp at *,\n  apply hx.1,\nend\n\nlemma aux2 (x : \u2102) (a b : \u211d) : metric.ball x a \u2229 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 \u2192 \u2102) (h : \u2200 x : D.1, \u2203 (\u03b5: \u211d), 0 < \u03b5 \u2227 (metric.ball x.1 \u03b5 \u2286 D.val ) \u2227\n  differentiable_on \u2102 (extend_by_zero f) (metric.ball x \u03b5)) :\n  differentiable_on \u2102 (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 \u27e8x, hx\u27e9,\n  obtain \u27e8\u03b5, h\u03b5, hb, H\u27e9:= hh,\n  have HH:= H x,\n  simp only [metric.mem_ball, subtype.coe_mk, dist_self] at HH,\n  have HHH:= HH h\u03b5,\n  obtain \u27e8f', hf'\u27e9:= HHH,\n  use f',\n  simp_rw has_fderiv_within_at_iff_tendsto at *,\n  rw metric.tendsto_nhds at *,\n  intros \u03b4 h\u03b4,\n  have hf2 := hf'  \u03b4 h\u03b4,\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 \u27e8S, hS, HD\u27e9 := hf2,\n  simp_rw metric.mem_nhds_within_iff at *,\n  obtain \u27e8e, he, HE\u27e9:= hS,\n  use S,\n  split,\n  use min e \u03b5,\n  simp only [gt_iff_lt, topological_space.opens.mem_coe, lt_min_iff, subtype.val_eq_coe] at *,\n  simp only [he, h\u03b5, and_self],\n  simp only [true_and],\n  have : metric.ball x e \u2229 metric.ball x \u03b5 = metric.ball x (min e \u03b5), by {apply aux2,},\n  rw this at HE,\n  apply aux _ _ _ HE,\n  apply HD,\nend\n\nlemma tendsto_unif_extend_by_zero (F : \u2115 \u2192 D.1 \u2192 \u2102) (f : D.1 \u2192 \u2102)\n(h: tendsto_uniformly F f filter.at_top ) :\n  tendsto_uniformly_on (\u03bb (n : \u2115), 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 \u03b5 h\u03b5,\n  have h2:= h \u03b5 h\u03b5,\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 \u27e8a, ha\u27e9:= h2,\n  use a,\n  intros b hb x hx,\n  have hf:= ext_by_zero_apply D f \u27e8x, hx\u27e9,\n  have hFb:= ext_by_zero_apply D (F b) \u27e8x, hx\u27e9,\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 \u2192 Type v}\n\nvariable [Applicative F] [LawfulApplicative F]\n\nvariable {\u03b1 \u03b2 \u03b3 \u03c3 : Type u}\n\ntheorem Applicative.map_seq_map (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (g : \u03c3 \u2192 \u03b2) (x : F \u03b1) (y : F \u03c3) :\n    f <$> x <*> g <$> y = (flip (\u00b7 \u2218 \u00b7) g \u2218 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 : \u03b1 \u2192 \u03b2) : (\u00b7 <*> \u00b7) (pure f : F (\u03b1 \u2192 \u03b2)) = (\u00b7 <$> \u00b7) 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    \u2200 {A1 : Applicative F} {A2 : Applicative F} [@LawfulApplicative F A1] [@LawfulApplicative F A2],\n      (\u2200 {\u03b1 : Type u} (x : \u03b1), @Pure.pure _ A1.toPure _ x = @Pure.pure _ A2.toPure _ x) \u2192\n      (\u2200 {\u03b1 \u03b2 : Type u} (f : F (\u03b1 \u2192 \u03b2)) (x : F \u03b1),\n          @Seq.seq _ A1.toSeq _ _ f (fun _ => x) = @Seq.seq _ A2.toSeq _ _ f (fun _ => x)) \u2192\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 \u03b1 x\n      apply H1\n    obtain rfl : @s1 = @s2 := by\n      funext \u03b1 \u03b2 f x\n      exact H2 f (x Unit.unit)\n    obtain \u27e8seqLeft_eq1, seqRight_eq1, pure_seq1, -\u27e9 := L1\n    obtain \u27e8seqLeft_eq2, seqRight_eq2, pure_seq2, -\u27e9 := L2\n    obtain rfl : F1 = F2 := by\n      apply Functor.ext\n      intros\n      exact (pure_seq1 _ _).symm.trans (pure_seq2 _ _)\n    congr <;> funext \u03b1 \u03b2 x y\n    \u00b7 exact (seqLeft_eq1 _ (y Unit.unit)).trans (seqLeft_eq2 _ _).symm\n    \u00b7 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 \u2192 Type w} {G : Type v \u2192 Type u}\n\nvariable [Applicative F] [Applicative G]\n\nvariable [LawfulApplicative F] [LawfulApplicative G]\n\nvariable {\u03b1 \u03b2 \u03b3 : Type v}\n\ntheorem map_pure (f : \u03b1 \u2192 \u03b2) (x : \u03b1) : (f <$> pure x : Comp F G \u03b2) = 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 (\u03b1 \u2192 \u03b2)) (x : \u03b1) : f <*> pure x = (fun g : \u03b1 \u2192 \u03b2 => g x) <$> f :=\n  Comp.ext <| by simp [(\u00b7 \u2218 \u00b7), functor_norm]\n#align functor.comp.seq_pure Functor.Comp.seq_pure\n\ntheorem seq_assoc (x : Comp F G \u03b1) (f : Comp F G (\u03b1 \u2192 \u03b2)) (g : Comp F G (\u03b2 \u2192 \u03b3)) :\n    g <*> (f <*> x) = @Function.comp \u03b1 \u03b2 \u03b3 <$> g <*> f <*> x :=\n  Comp.ext <| by simp [(\u00b7 \u2218 \u00b7), functor_norm]\n#align functor.comp.seq_assoc Functor.Comp.seq_assoc\n\ntheorem pure_seq_eq_map (f : \u03b1 \u2192 \u03b2) (x : Comp F G \u03b1) : 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 \u2192 Type w} {g : Type v \u2192 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, (\u00b7 \u2218 \u00b7), 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 {\u03b1 \u03b2 : Type w} {f : Type u \u2192 Type v} {g : Type w \u2192 Type u} [Applicative f]\n    [Applicative g] (h : f (g (\u03b1 \u2192 \u03b2))) (x : f (g \u03b1)) :\n    Comp.mk h <*> Comp.mk x = Comp.mk ((\u00b7 <*> \u00b7) <$> 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 {\u03b1} [One \u03b1] [Mul \u03b1] : Applicative (Const \u03b1) where\n  pure _ := (1 : \u03b1)\n  seq f x := (show \u03b1 from f) * (show \u03b1 from x Unit.unit)\n\n-- Porting note: `(\u00b7 <*> \u00b7)` needed to change to `Seq.seq` in the `simp`.\n-- Also, `simp` didn't close `refl` goals.\n\ninstance {\u03b1} [Monoid \u03b1] : LawfulApplicative (Const \u03b1) := by\n  refine' { .. } <;> intros <;> simp [mul_assoc, (\u00b7 <$> \u00b7), Seq.seq, pure] <;> rfl\n\ninstance {\u03b1} [Zero \u03b1] [Add \u03b1] : Applicative (AddConst \u03b1) where\n  pure _ := (0 : \u03b1)\n  seq f x := (show \u03b1 from f) + (show \u03b1 from x Unit.unit)\n\ninstance {\u03b1} [AddMonoid \u03b1] : LawfulApplicative (AddConst \u03b1) := by\n  refine' { .. } <;> intros <;> simp [add_assoc, (\u00b7 <$> \u00b7), 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 : \u03b1 \u2192 \u03b2` such that `r a b \u2192 s (f a) (f b)`. -/\nstructure rel_hom {\u03b1 : Type u_4} {\u03b2 : Type u_5} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) where\n  to_fun : \u03b1 \u2192 \u03b2\n  map_rel' : \u2200 {a b : \u03b1}, r a b \u2192 s (to_fun a) (to_fun b)\n\ninfixl:25 \" \u2192r \" => Mathlib.rel_hom\n\nnamespace rel_hom\n\n\nprotected instance has_coe_to_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} : has_coe_to_fun (r \u2192r s) :=\n  has_coe_to_fun.mk (fun (_x : r \u2192r s) => \u03b1 \u2192 \u03b2) fun (o : r \u2192r s) => to_fun o\n\ntheorem map_rel {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u2192r s)\n    {a : \u03b1} {b : \u03b1} : r a b \u2192 s (coe_fn f a) (coe_fn f b) :=\n  map_rel' f\n\n@[simp] theorem coe_fn_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2192 \u03b2) (o : \u2200 {a b : \u03b1}, r a b \u2192 s (f a) (f b)) : \u21d1(mk f o) = f :=\n  rfl\n\n@[simp] theorem coe_fn_to_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2192r s) : to_fun f = \u21d1f :=\n  rfl\n\n/-- The map `coe_fn : (r \u2192r s) \u2192 (\u03b1 \u2192 \u03b2)` is injective. We can't use `function.injective`\nhere but mimic its signature by using `\u2983e\u2081 e\u2082\u2984`. -/\ntheorem coe_fn_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {e\u2081 : r \u2192r s}\n    {e\u2082 : r \u2192r s} : \u21d1e\u2081 = \u21d1e\u2082 \u2192 e\u2081 = e\u2082 :=\n  sorry\n\ntheorem ext {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {f : r \u2192r s}\n    {g : r \u2192r s} (h : \u2200 (x : \u03b1), coe_fn f x = coe_fn g x) : f = g :=\n  coe_fn_inj (funext h)\n\ntheorem ext_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {f : r \u2192r s}\n    {g : r \u2192r s} : f = g \u2194 \u2200 (x : \u03b1), coe_fn f x = coe_fn g x :=\n  { mp := fun (h : f = g) (x : \u03b1) => h \u25b8 rfl,\n    mpr := fun (h : \u2200 (x : \u03b1), coe_fn f x = coe_fn g x) => ext h }\n\n/-- Identity map is a relation homomorphism. -/\nprotected def id {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : r \u2192r r := mk id sorry\n\n/-- Composition of two relation homomorphisms is a relation homomorphism. -/\nprotected def comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {t : \u03b3 \u2192 \u03b3 \u2192 Prop} (g : s \u2192r t) (f : r \u2192r s) : r \u2192r t :=\n  mk (to_fun g \u2218 to_fun f) sorry\n\n@[simp] theorem id_apply {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (x : \u03b1) : coe_fn (rel_hom.id r) x = x :=\n  rfl\n\n@[simp] theorem comp_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {t : \u03b3 \u2192 \u03b3 \u2192 Prop} (g : s \u2192r t) (f : r \u2192r s) (a : \u03b1) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2192r s) : function.swap r \u2192r function.swap s :=\n  mk \u21d1f sorry\n\n/-- A function is a relation homomorphism from the preimage relation of `s` to `s`. -/\ndef preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) : f \u207b\u00b9'o s \u2192r s :=\n  mk f sorry\n\nprotected theorem is_irrefl {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2192r s) [is_irrefl \u03b2 s] : is_irrefl \u03b1 r :=\n  sorry\n\nprotected theorem is_asymm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2192r s) [is_asymm \u03b2 s] : is_asymm \u03b1 r :=\n  sorry\n\nprotected theorem acc {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2192r s) (a : \u03b1) : acc s (coe_fn f a) \u2192 acc r a :=\n  sorry\n\nprotected theorem well_founded {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2192r s) (h : well_founded s) : well_founded r :=\n  well_founded.dcases_on h\n    fun (h : \u2200 (a : \u03b2), acc s a) =>\n      idRhs (well_founded r) (well_founded.intro fun (a : \u03b1) => rel_hom.acc f a (h (coe_fn f a)))\n\ntheorem map_inf {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semilattice_inf \u03b1] [linear_order \u03b2]\n    (a : Less \u2192r Less) (m : \u03b2) (n : \u03b2) : coe_fn a (m \u2293 n) = coe_fn a m \u2293 coe_fn a n :=\n  sorry\n\ntheorem map_sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semilattice_sup \u03b1] [linear_order \u03b2] (a : gt \u2192r gt)\n    (m : \u03b2) (n : \u03b2) : coe_fn a (m \u2294 n) = coe_fn a m \u2294 coe_fn a n :=\n  sorry\n\nend rel_hom\n\n\n/-- An increasing function is injective -/\ntheorem injective_of_increasing {\u03b1 : Type u_1} {\u03b2 : Type u_2} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop)\n    [is_trichotomous \u03b1 r] [is_irrefl \u03b2 s] (f : \u03b1 \u2192 \u03b2) (hf : \u2200 {x y : \u03b1}, r x y \u2192 s (f x) (f y)) :\n    function.injective f :=\n  sorry\n\n/-- An increasing function is injective -/\ntheorem rel_hom.injective_of_increasing {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} [is_trichotomous \u03b1 r] [is_irrefl \u03b2 s] (f : r \u2192r s) : function.injective \u21d1f :=\n  injective_of_increasing r s \u21d1f fun (x y : \u03b1) => rel_hom.map_rel f\n\ntheorem surjective.well_founded_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {f : \u03b1 \u2192 \u03b2} (hf : function.surjective f)\n    (o : \u2200 {a b : \u03b1}, r a b \u2194 s (f a) (f b)) : well_founded r \u2194 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 : \u03b1 \u21aa \u03b2` such that `r a b \u2194 s (f a) (f b)`. -/\nstructure rel_embedding {\u03b1 : Type u_4} {\u03b2 : Type u_5} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop)\n    extends \u03b1 \u21aa \u03b2 where\n  map_rel_iff' : \u2200 {a b : \u03b1}, s (coe_fn _to_embedding a) (coe_fn _to_embedding b) \u2194 r a b\n\ninfixl:25 \" \u21aar \" => Mathlib.rel_embedding\n\n/-- An order embedding is an embedding `f : \u03b1 \u21aa \u03b2` such that `a \u2264 b \u2194 (f a) \u2264 (f b)`.\nThis definition is an abbreviation of `rel_embedding (\u2264) (\u2264)`. -/\ndef order_embedding (\u03b1 : Type u_1) (\u03b2 : Type u_2) [HasLessEq \u03b1] [HasLessEq \u03b2] := LessEq \u21aar LessEq\n\ninfixl:25 \" \u21aao \" => 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 \u2192 X \u2192 Prop) (p : X \u2192 Prop) :\n    subtype.val \u207b\u00b9'o r \u21aar r :=\n  rel_embedding.mk (function.embedding.subtype p) sorry\n\ntheorem preimage_equivalence {\u03b1 : Sort u_1} {\u03b2 : Sort u_2} (f : \u03b1 \u2192 \u03b2) {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (hs : equivalence s) : equivalence (f \u207b\u00b9'o s) :=\n  sorry\n\nnamespace rel_embedding\n\n\n/-- A relation embedding is also a relation homomorphism -/\ndef to_rel_hom {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) :\n    r \u2192r 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} : has_coe (r \u21aar s) (r \u2192r s) :=\n  has_coe.mk to_rel_hom\n\nprotected instance has_coe_to_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} : has_coe_to_fun (r \u21aar s) :=\n  has_coe_to_fun.mk (fun (_x : r \u21aar s) => \u03b1 \u2192 \u03b2) fun (o : r \u21aar s) => \u21d1(to_embedding o)\n\n@[simp] theorem to_rel_hom_eq_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) : to_rel_hom f = \u2191f :=\n  rfl\n\n@[simp] theorem coe_coe_fn {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) : \u21d1\u2191f = \u21d1f :=\n  rfl\n\ntheorem injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) :\n    function.injective \u21d1f :=\n  function.embedding.inj' (to_embedding f)\n\ntheorem map_rel_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s)\n    {a : \u03b1} {b : \u03b1} : s (coe_fn f a) (coe_fn f b) \u2194 r a b :=\n  map_rel_iff' f\n\n@[simp] theorem coe_fn_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u21aa \u03b2) (o : \u2200 {a b : \u03b1}, s (coe_fn f a) (coe_fn f b) \u2194 r a b) : \u21d1(mk f o) = \u21d1f :=\n  rfl\n\n@[simp] theorem coe_fn_to_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) : \u21d1(to_embedding f) = \u21d1f :=\n  rfl\n\n/-- The map `coe_fn : (r \u21aar s) \u2192 (\u03b1 \u2192 \u03b2)` is injective. We can't use `function.injective`\nhere but mimic its signature by using `\u2983e\u2081 e\u2082\u2984`. -/\ntheorem coe_fn_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {e\u2081 : r \u21aar s}\n    {e\u2082 : r \u21aar s} : \u21d1e\u2081 = \u21d1e\u2082 \u2192 e\u2081 = e\u2082 :=\n  sorry\n\ntheorem ext {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {f : r \u21aar s}\n    {g : r \u21aar s} (h : \u2200 (x : \u03b1), coe_fn f x = coe_fn g x) : f = g :=\n  coe_fn_inj (funext h)\n\ntheorem ext_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {f : r \u21aar s}\n    {g : r \u21aar s} : f = g \u2194 \u2200 (x : \u03b1), coe_fn f x = coe_fn g x :=\n  { mp := fun (h : f = g) (x : \u03b1) => h \u25b8 rfl,\n    mpr := fun (h : \u2200 (x : \u03b1), coe_fn f x = coe_fn g x) => ext h }\n\n/-- Identity map is a relation embedding. -/\nprotected def refl {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : r \u21aar r :=\n  mk (function.embedding.refl \u03b1) sorry\n\n/-- Composition of two relation embeddings is a relation embedding. -/\nprotected def trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {t : \u03b3 \u2192 \u03b3 \u2192 Prop} (f : r \u21aar s) (g : s \u21aar t) : r \u21aar t :=\n  mk (function.embedding.trans (to_embedding f) (to_embedding g)) sorry\n\nprotected instance inhabited {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Inhabited (r \u21aar r) :=\n  { default := rel_embedding.refl r }\n\n@[simp] theorem refl_apply {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (x : \u03b1) :\n    coe_fn (rel_embedding.refl r) x = x :=\n  rfl\n\ntheorem trans_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {t : \u03b3 \u2192 \u03b3 \u2192 Prop} (f : r \u21aar s) (g : s \u21aar t) (a : \u03b1) :\n    coe_fn (rel_embedding.trans f g) a = coe_fn g (coe_fn f a) :=\n  rfl\n\n@[simp] theorem coe_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {t : \u03b3 \u2192 \u03b3 \u2192 Prop} (f : r \u21aar s) (g : s \u21aar t) :\n    \u21d1(rel_embedding.trans f g) = \u21d1g \u2218 \u21d1f :=\n  rfl\n\n/-- A relation embedding is also a relation embedding between dual relations. -/\nprotected def swap {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) : function.swap r \u21aar 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) : \u21d1f \u207b\u00b9'o s \u21aar s :=\n  mk f sorry\n\ntheorem eq_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) : r = \u21d1f \u207b\u00b9'o s :=\n  funext fun (a : \u03b1) => funext fun (b : \u03b1) => propext (iff.symm (map_rel_iff f))\n\nprotected theorem is_irrefl {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_irrefl \u03b2 s] : is_irrefl \u03b1 r :=\n  is_irrefl.mk fun (a : \u03b1) => mt (iff.mpr (map_rel_iff f)) (irrefl (coe_fn f a))\n\nprotected theorem is_refl {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_refl \u03b2 s] : is_refl \u03b1 r :=\n  is_refl.mk fun (a : \u03b1) => iff.mp (map_rel_iff f) (refl (coe_fn f a))\n\nprotected theorem is_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_symm \u03b2 s] : is_symm \u03b1 r :=\n  is_symm.mk fun (a b : \u03b1) => imp_imp_imp (iff.mpr (map_rel_iff f)) (iff.mp (map_rel_iff f)) symm\n\nprotected theorem is_asymm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_asymm \u03b2 s] : is_asymm \u03b1 r :=\n  is_asymm.mk\n    fun (a b : \u03b1) (h\u2081 : r a b) (h\u2082 : r b a) =>\n      asymm (iff.mpr (map_rel_iff f) h\u2081) (iff.mpr (map_rel_iff f) h\u2082)\n\nprotected theorem is_antisymm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_antisymm \u03b2 s] : is_antisymm \u03b1 r :=\n  sorry\n\nprotected theorem is_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_trans \u03b2 s] : is_trans \u03b1 r :=\n  sorry\n\nprotected theorem is_total {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_total \u03b2 s] : is_total \u03b1 r :=\n  sorry\n\nprotected theorem is_preorder {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_preorder \u03b2 s] : is_preorder \u03b1 r :=\n  idRhs (is_preorder \u03b1 r) is_preorder.mk\n\nprotected theorem is_partial_order {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) [is_partial_order \u03b2 s] : is_partial_order \u03b1 r :=\n  idRhs (is_partial_order \u03b1 r) is_partial_order.mk\n\nprotected theorem is_linear_order {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) [is_linear_order \u03b2 s] : is_linear_order \u03b1 r :=\n  idRhs (is_linear_order \u03b1 r) is_linear_order.mk\n\nprotected theorem is_strict_order {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) [is_strict_order \u03b2 s] : is_strict_order \u03b1 r :=\n  idRhs (is_strict_order \u03b1 r) is_strict_order.mk\n\nprotected theorem is_trichotomous {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) [is_trichotomous \u03b2 s] : is_trichotomous \u03b1 r :=\n  sorry\n\nprotected theorem is_strict_total_order' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) [is_strict_total_order' \u03b2 s] : is_strict_total_order' \u03b1 r :=\n  idRhs (is_strict_total_order' \u03b1 r) is_strict_total_order'.mk\n\nprotected theorem acc {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) (a : \u03b1) : acc s (coe_fn f a) \u2192 acc r a :=\n  sorry\n\nprotected theorem well_founded {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) (h : well_founded s) : well_founded r :=\n  well_founded.dcases_on h\n    fun (h : \u2200 (a : \u03b2), acc s a) =>\n      idRhs (well_founded r)\n        (well_founded.intro fun (a : \u03b1) => rel_embedding.acc f a (h (coe_fn f a)))\n\nprotected theorem is_well_order {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u21aar s) [is_well_order \u03b2 s] : is_well_order \u03b1 r :=\n  idRhs (is_well_order \u03b1 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    [is_trichotomous \u03b1 r] [is_asymm \u03b2 s] (f : \u03b1 \u2192 \u03b2) (H : \u2200 (a b : \u03b1), r a b \u2192 s (f a) (f b)) :\n    r \u21aar s :=\n  mk (function.embedding.mk f sorry) sorry\n\n@[simp] theorem of_monotone_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    [is_trichotomous \u03b1 r] [is_asymm \u03b2 s] (f : \u03b1 \u2192 \u03b2) (H : \u2200 (a b : \u03b1), r a b \u2192 s (f a) (f b)) :\n    \u21d1(of_monotone f H) = f :=\n  rfl\n\n/-- Embeddings of partial orders that preserve `<` also preserve `\u2264`  -/\ndef order_embedding_of_lt_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} [partial_order \u03b1]\n    [partial_order \u03b2] (f : Less \u21aar Less) : \u03b1 \u21aao \u03b2 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2) :\n    Less \u21aar Less :=\n  rel_embedding.mk (rel_embedding.to_embedding f) sorry\n\n@[simp] theorem lt_embedding_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2]\n    (f : \u03b1 \u21aao \u03b2) (x : \u03b1) : coe_fn (lt_embedding f) x = coe_fn f x :=\n  rfl\n\n@[simp] theorem le_iff_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2)\n    {a : \u03b1} {b : \u03b1} : coe_fn f a \u2264 coe_fn f b \u2194 a \u2264 b :=\n  rel_embedding.map_rel_iff f\n\n@[simp] theorem lt_iff_lt {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2)\n    {a : \u03b1} {b : \u03b1} : coe_fn f a < coe_fn f b \u2194 a < b :=\n  rel_embedding.map_rel_iff (lt_embedding f)\n\n@[simp] theorem eq_iff_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2)\n    {a : \u03b1} {b : \u03b1} : coe_fn f a = coe_fn f b \u2194 a = b :=\n  function.injective.eq_iff (rel_embedding.injective f)\n\nprotected theorem monotone {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2) :\n    monotone \u21d1f :=\n  fun (x y : \u03b1) => iff.mpr (le_iff_le f)\n\nprotected theorem strict_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2) :\n    strict_mono \u21d1f :=\n  fun (x y : \u03b1) => iff.mpr (lt_iff_lt f)\n\nprotected theorem acc {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2) (a : \u03b1) :\n    acc Less (coe_fn f a) \u2192 acc Less a :=\n  rel_embedding.acc (lt_embedding f) a\n\nprotected theorem well_founded {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2]\n    (f : \u03b1 \u21aao \u03b2) : well_founded Less \u2192 well_founded Less :=\n  rel_embedding.well_founded (lt_embedding f)\n\nprotected theorem is_well_order {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2)\n    [is_well_order \u03b2 Less] : is_well_order \u03b1 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u21aao \u03b2) :\n    order_dual \u03b1 \u21aao order_dual \u03b2 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] [preorder \u03b2] (f : \u03b1 \u2192 \u03b2)\n    (h : strict_mono f) : \u03b1 \u21aao \u03b2 :=\n  rel_embedding.mk (function.embedding.mk f (strict_mono.injective h)) sorry\n\n@[simp] theorem coe_of_strict_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] [preorder \u03b2]\n    {f : \u03b1 \u2192 \u03b2} (h : strict_mono f) : \u21d1(of_strict_mono f h) = f :=\n  rfl\n\n/-- Embedding of a subtype into the ambient type as an `order_embedding`. -/\ndef subtype {\u03b1 : Type u_1} [preorder \u03b1] (p : \u03b1 \u2192 Prop) : Subtype p \u21aao \u03b1 :=\n  rel_embedding.mk (function.embedding.subtype p) sorry\n\n@[simp] theorem coe_subtype {\u03b1 : Type u_1} [preorder \u03b1] (p : \u03b1 \u2192 Prop) : \u21d1(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 {\u03b1 : Type u_4} {\u03b2 : Type u_5} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) extends \u03b1 \u2243 \u03b2\n    where\n  map_rel_iff' : \u2200 {a b : \u03b1}, s (coe_fn _to_equiv a) (coe_fn _to_equiv b) \u2194 r a b\n\ninfixl:25 \" \u2243r \" => Mathlib.rel_iso\n\n/-- An order isomorphism is an equivalence such that `a \u2264 b \u2194 (f a) \u2264 (f b)`.\nThis definition is an abbreviation of `rel_iso (\u2264) (\u2264)`. -/\ndef order_iso (\u03b1 : Type u_1) (\u03b2 : Type u_2) [HasLessEq \u03b1] [HasLessEq \u03b2] := LessEq \u2243r LessEq\n\ninfixl:25 \" \u2243o \" => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2243r s) : r \u21aar 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} : has_coe (r \u2243r s) (r \u21aar s) :=\n  has_coe.mk to_rel_embedding\n\nprotected instance has_coe_to_fun {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} : has_coe_to_fun (r \u2243r s) :=\n  has_coe_to_fun.mk (fun (_x : r \u2243r s) => \u03b1 \u2192 \u03b2) fun (f : r \u2243r s) => \u21d1f\n\n@[simp] theorem to_rel_embedding_eq_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u2243r s) : to_rel_embedding f = \u2191f :=\n  rfl\n\n@[simp] theorem coe_coe_fn {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2243r s) : \u21d1\u2191f = \u21d1f :=\n  rfl\n\ntheorem map_rel_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u2243r s)\n    {a : \u03b1} {b : \u03b1} : s (coe_fn f a) (coe_fn f b) \u2194 r a b :=\n  map_rel_iff' f\n\n@[simp] theorem coe_fn_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2243 \u03b2) (o : \u2200 {a b : \u03b1}, s (coe_fn f a) (coe_fn f b) \u2194 r a b) : \u21d1(mk f o) = \u21d1f :=\n  rfl\n\n@[simp] theorem coe_fn_to_equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2243r s) : \u21d1(to_equiv f) = \u21d1f :=\n  rfl\n\ntheorem injective_to_equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} :\n    function.injective to_equiv :=\n  sorry\n\n/-- The map `coe_fn : (r \u2243r s) \u2192 (\u03b1 \u2192 \u03b2)` is injective. Lean fails to parse\n`function.injective (\u03bb e : r \u2243r s, (e : \u03b1 \u2192 \u03b2))`, so we use a trick to say the same. -/\ntheorem injective_coe_fn {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} :\n    function.injective fun (e : r \u2243r s) (x : \u03b1) => coe_fn e x :=\n  function.injective.comp equiv.injective_coe_fn injective_to_equiv\n\ntheorem ext {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {f : r \u2243r s}\n    {g : r \u2243r s} (h : \u2200 (x : \u03b1), coe_fn f x = coe_fn g x) : f = g :=\n  injective_coe_fn (funext h)\n\ntheorem ext_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {f : r \u2243r s}\n    {g : r \u2243r s} : f = g \u2194 \u2200 (x : \u03b1), coe_fn f x = coe_fn g x :=\n  { mp := fun (h : f = g) (x : \u03b1) => h \u25b8 rfl,\n    mpr := fun (h : \u2200 (x : \u03b1), coe_fn f x = coe_fn g x) => ext h }\n\n/-- Identity map is a relation isomorphism. -/\nprotected def refl {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : r \u2243r r := mk (equiv.refl \u03b1) sorry\n\n/-- Inverse map of a relation isomorphism is a relation isomorphism. -/\nprotected def symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2243r s) : s \u2243r r :=\n  mk (equiv.symm (to_equiv f)) sorry\n\n/-- Composition of two relation isomorphisms is a relation isomorphism. -/\nprotected def trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {t : \u03b3 \u2192 \u03b3 \u2192 Prop} (f\u2081 : r \u2243r s) (f\u2082 : s \u2243r t) : r \u2243r t :=\n  mk (equiv.trans (to_equiv f\u2081) (to_equiv f\u2082)) sorry\n\nprotected instance inhabited {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : Inhabited (r \u2243r r) :=\n  { default := rel_iso.refl r }\n\n@[simp] theorem default_def {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2243r s) : function.swap r \u2243r function.swap s :=\n  mk (to_equiv f) sorry\n\n@[simp] theorem coe_fn_symm_mk {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2243 \u03b2) (o : \u2200 {a b : \u03b1}, s (coe_fn f a) (coe_fn f b) \u2194 r a b) :\n    \u21d1(rel_iso.symm (mk f o)) = \u21d1(equiv.symm f) :=\n  rfl\n\n@[simp] theorem refl_apply {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (x : \u03b1) :\n    coe_fn (rel_iso.refl r) x = x :=\n  rfl\n\n@[simp] theorem trans_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} {t : \u03b3 \u2192 \u03b3 \u2192 Prop} (f : r \u2243r s) (g : s \u2243r t) (a : \u03b1) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (e : r \u2243r s) (x : \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (e : r \u2243r s) (x : \u03b1) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (e : r \u2243r s) {x : \u03b1} {y : \u03b2} : r x (coe_fn (rel_iso.symm e) y) \u2194 s (coe_fn e x) y :=\n  sorry\n\ntheorem symm_apply_rel {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (e : r \u2243r s) {x : \u03b2} {y : \u03b1} : r (coe_fn (rel_iso.symm e) x) y \u2194 s x (coe_fn e y) :=\n  sorry\n\nprotected theorem bijective {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (e : r \u2243r s) : function.bijective \u21d1e :=\n  equiv.bijective (to_equiv e)\n\nprotected theorem injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (e : r \u2243r s) : function.injective \u21d1e :=\n  equiv.injective (to_equiv e)\n\nprotected theorem surjective {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (e : r \u2243r s) : function.surjective \u21d1e :=\n  equiv.surjective (to_equiv e)\n\n@[simp] theorem range_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (e : r \u2243r s) : set.range \u21d1e = set.univ :=\n  function.surjective.range_eq (rel_iso.surjective e)\n\n@[simp] theorem eq_iff_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : r \u2243r s) {a : \u03b1} {b : \u03b1} : coe_fn f a = coe_fn f b \u2194 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2243 \u03b2) (s : \u03b2 \u2192 \u03b2 \u2192 Prop) :\n    \u21d1f \u207b\u00b9'o s \u2243r s :=\n  mk f sorry\n\n/-- A surjective relation embedding is a relation isomorphism. -/\ndef of_surjective {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s)\n    (H : function.surjective \u21d1f) : r \u2243r s :=\n  mk (equiv.of_bijective \u21d1f sorry) sorry\n\n@[simp] theorem of_surjective_coe {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : r \u21aar s) (H : function.surjective \u21d1f) : \u21d1(of_surjective f H) = \u21d1f :=\n  rfl\n\n/--\nGiven relation isomorphisms `r\u2081 \u2243r r\u2082` and `s\u2081 \u2243r s\u2082`, construct a relation isomorphism for the\nlexicographic orders on the sum.\n-/\ndef sum_lex_congr {\u03b1\u2081 : Type u_1} {\u03b1\u2082 : Type u_2} {\u03b2\u2081 : Type u_3} {\u03b2\u2082 : Type u_4}\n    {r\u2081 : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 Prop} {r\u2082 : \u03b1\u2082 \u2192 \u03b1\u2082 \u2192 Prop} {s\u2081 : \u03b2\u2081 \u2192 \u03b2\u2081 \u2192 Prop} {s\u2082 : \u03b2\u2082 \u2192 \u03b2\u2082 \u2192 Prop}\n    (e\u2081 : r\u2081 \u2243r r\u2082) (e\u2082 : s\u2081 \u2243r s\u2082) : sum.lex r\u2081 s\u2081 \u2243r sum.lex r\u2082 s\u2082 :=\n  mk (equiv.sum_congr (to_equiv e\u2081) (to_equiv e\u2082)) sorry\n\n/--\nGiven relation isomorphisms `r\u2081 \u2243r r\u2082` and `s\u2081 \u2243r s\u2082`, construct a relation isomorphism for the\nlexicographic orders on the product.\n-/\ndef prod_lex_congr {\u03b1\u2081 : Type u_1} {\u03b1\u2082 : Type u_2} {\u03b2\u2081 : Type u_3} {\u03b2\u2082 : Type u_4}\n    {r\u2081 : \u03b1\u2081 \u2192 \u03b1\u2081 \u2192 Prop} {r\u2082 : \u03b1\u2082 \u2192 \u03b1\u2082 \u2192 Prop} {s\u2081 : \u03b2\u2081 \u2192 \u03b2\u2081 \u2192 Prop} {s\u2082 : \u03b2\u2082 \u2192 \u03b2\u2082 \u2192 Prop}\n    (e\u2081 : r\u2081 \u2243r r\u2082) (e\u2082 : s\u2081 \u2243r s\u2082) : prod.lex r\u2081 s\u2081 \u2243r prod.lex r\u2082 s\u2082 :=\n  mk (equiv.prod_congr (to_equiv e\u2081) (to_equiv e\u2082)) sorry\n\nprotected instance group {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} : group (r \u2243r r) :=\n  group.mk (fun (f\u2081 f\u2082 : r \u2243r r) => rel_iso.trans f\u2082 f\u2081) sorry (rel_iso.refl r) sorry sorry\n    rel_iso.symm\n    (div_inv_monoid.div._default (fun (f\u2081 f\u2082 : r \u2243r r) => rel_iso.trans f\u2082 f\u2081) sorry\n      (rel_iso.refl r) sorry sorry rel_iso.symm)\n    sorry\n\n@[simp] theorem coe_one {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} : \u21d11 = id := rfl\n\n@[simp] theorem coe_mul {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (e\u2081 : r \u2243r r) (e\u2082 : r \u2243r r) :\n    \u21d1(e\u2081 * e\u2082) = \u21d1e\u2081 \u2218 \u21d1e\u2082 :=\n  rfl\n\ntheorem mul_apply {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (e\u2081 : r \u2243r r) (e\u2082 : r \u2243r r) (x : \u03b1) :\n    coe_fn (e\u2081 * e\u2082) x = coe_fn e\u2081 (coe_fn e\u2082 x) :=\n  rfl\n\n@[simp] theorem inv_apply_self {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (e : r \u2243r r) (x : \u03b1) :\n    coe_fn (e\u207b\u00b9) (coe_fn e x) = x :=\n  symm_apply_apply e x\n\n@[simp] theorem apply_inv_self {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (e : r \u2243r r) (x : \u03b1) :\n    coe_fn e (coe_fn (e\u207b\u00b9) 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2] (e : \u03b1 \u2243o \u03b2) :\n    \u03b1 \u21aao \u03b2 :=\n  rel_iso.to_rel_embedding e\n\n@[simp] theorem coe_to_order_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2]\n    (e : \u03b1 \u2243o \u03b2) : \u21d1(to_order_embedding e) = \u21d1e :=\n  rfl\n\nprotected theorem bijective {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2] (e : \u03b1 \u2243o \u03b2) :\n    function.bijective \u21d1e :=\n  equiv.bijective (rel_iso.to_equiv e)\n\nprotected theorem injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2] (e : \u03b1 \u2243o \u03b2) :\n    function.injective \u21d1e :=\n  equiv.injective (rel_iso.to_equiv e)\n\nprotected theorem surjective {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2]\n    (e : \u03b1 \u2243o \u03b2) : function.surjective \u21d1e :=\n  equiv.surjective (rel_iso.to_equiv e)\n\n@[simp] theorem range_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2] (e : \u03b1 \u2243o \u03b2) :\n    set.range \u21d1e = set.univ :=\n  function.surjective.range_eq (order_iso.surjective e)\n\n@[simp] theorem apply_eq_iff_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2]\n    (e : \u03b1 \u2243o \u03b2) {x : \u03b1} {y : \u03b1} : coe_fn e x = coe_fn e y \u2194 x = y :=\n  equiv.apply_eq_iff_eq (rel_iso.to_equiv e)\n\n/-- Inverse of an order isomorphism. -/\ndef symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2] (e : \u03b1 \u2243o \u03b2) : \u03b2 \u2243o \u03b1 :=\n  rel_iso.symm e\n\n@[simp] theorem apply_symm_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2]\n    (e : \u03b1 \u2243o \u03b2) (x : \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2]\n    (e : \u03b1 \u2243o \u03b2) (x : \u03b1) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2] (e : \u03b1 \u2243o \u03b2) {x : \u03b1}\n    {y : \u03b2} : coe_fn (symm e) y = x \u2194 y = coe_fn e x :=\n  equiv.symm_apply_eq (rel_iso.to_equiv e)\n\n@[simp] theorem symm_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2] (e : \u03b1 \u2243o \u03b2) :\n    symm (symm e) = e :=\n  rel_iso.ext fun (x : \u03b1) => Eq.refl (coe_fn (symm (symm e)) x)\n\ntheorem symm_injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2] :\n    function.injective symm :=\n  sorry\n\n@[simp] theorem to_equiv_symm {\u03b1 : Type u_1} {\u03b2 : Type u_2} [HasLessEq \u03b1] [HasLessEq \u03b2]\n    (e : \u03b1 \u2243o \u03b2) : 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [HasLessEq \u03b1] [HasLessEq \u03b2] [HasLessEq \u03b3]\n    (e : \u03b1 \u2243o \u03b2) (e' : \u03b2 \u2243o \u03b3) : \u03b1 \u2243o \u03b3 :=\n  rel_iso.trans e e'\n\n@[simp] theorem coe_trans {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [HasLessEq \u03b1] [HasLessEq \u03b2]\n    [HasLessEq \u03b3] (e : \u03b1 \u2243o \u03b2) (e' : \u03b2 \u2243o \u03b3) : \u21d1(trans e e') = \u21d1e' \u2218 \u21d1e :=\n  rfl\n\ntheorem trans_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [HasLessEq \u03b1] [HasLessEq \u03b2]\n    [HasLessEq \u03b3] (e : \u03b1 \u2243o \u03b2) (e' : \u03b2 \u2243o \u03b3) (x : \u03b1) :\n    coe_fn (trans e e') x = coe_fn e' (coe_fn e x) :=\n  rfl\n\nprotected theorem monotone {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2) :\n    monotone \u21d1e :=\n  order_embedding.monotone (to_order_embedding e)\n\nprotected theorem strict_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2) :\n    strict_mono \u21d1e :=\n  order_embedding.strict_mono (to_order_embedding e)\n\n@[simp] theorem le_iff_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    {x : \u03b1} {y : \u03b1} : coe_fn e x \u2264 coe_fn e y \u2194 x \u2264 y :=\n  rel_iso.map_rel_iff e\n\n@[simp] theorem lt_iff_lt {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    {x : \u03b1} {y : \u03b1} : coe_fn e x < coe_fn e y \u2194 x < y :=\n  order_embedding.lt_iff_lt (to_order_embedding e)\n\n@[simp] theorem preimage_Iic {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    (b : \u03b2) : \u21d1e \u207b\u00b9' set.Iic b = set.Iic (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ici {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    (b : \u03b2) : \u21d1e \u207b\u00b9' set.Ici b = set.Ici (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Iio {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    (b : \u03b2) : \u21d1e \u207b\u00b9' set.Iio b = set.Iio (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ioi {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    (b : \u03b2) : \u21d1e \u207b\u00b9' set.Ioi b = set.Ioi (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Icc {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    (a : \u03b2) (b : \u03b2) : \u21d1e \u207b\u00b9' set.Icc a b = set.Icc (coe_fn (symm e) a) (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ico {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    (a : \u03b2) (b : \u03b2) : \u21d1e \u207b\u00b9' set.Ico a b = set.Ico (coe_fn (symm e) a) (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ioc {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    (a : \u03b2) (b : \u03b2) : \u21d1e \u207b\u00b9' set.Ioc a b = set.Ioc (coe_fn (symm e) a) (coe_fn (symm e) b) :=\n  sorry\n\n@[simp] theorem preimage_Ioo {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (e : \u03b1 \u2243o \u03b2)\n    (a : \u03b2) (b : \u03b2) : \u21d1e \u207b\u00b9' set.Ioo a b = set.Ioo (coe_fn (symm e) a) (coe_fn (symm e) b) :=\n  sorry\n\n/-- To show that `f : \u03b1 \u2192 \u03b2`, `g : \u03b2 \u2192 \u03b1` 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] [linear_order \u03b2] (f : \u03b1 \u2192 \u03b2)\n    (g : \u03b2 \u2192 \u03b1) (h : \u2200 (a : \u03b1) (b : \u03b2), cmp a (g b) = cmp (f a) b) : \u03b1 \u2243o \u03b2 :=\n  (fun (gf : \u2200 (a : \u03b1), 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 {\u03b1 : Type u_1} [preorder \u03b1] (s : set \u03b1) (t : set \u03b1) (h : s = t) : \u21a5s \u2243o \u21a5t :=\n  rel_iso.mk (equiv.set_congr h) sorry\n\n/-- Order isomorphism between `univ : set \u03b1` and `\u03b1`. -/\ndef set.univ {\u03b1 : Type u_1} [preorder \u03b1] : \u21a5set.univ \u2243o \u03b1 := rel_iso.mk (equiv.set.univ \u03b1) 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1]\n    [preorder \u03b2] (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (hf : strict_mono_incr_on f s) : \u21a5s \u2243o \u21a5(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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] [preorder \u03b2]\n    (f : \u03b1 \u2192 \u03b2) (h_mono : strict_mono f) : \u03b1 \u2243o \u21a5(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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [linear_order \u03b1] [preorder \u03b2]\n    (f : \u03b1 \u2192 \u03b2) (h_mono : strict_mono f) (h_surj : function.surjective f) : \u03b1 \u2243o \u03b2 :=\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 {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (p : set \u03b1) : \u21a5p \u2192 \u21a5p \u2192 Prop := coe \u207b\u00b9'o r\n\n@[simp] theorem subrel_val {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (p : set \u03b1) {a : \u21a5p} {b : \u21a5p} :\n    subrel r p a b \u2194 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 {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (p : set \u03b1) : subrel r p \u21aar r :=\n  rel_embedding.mk (function.embedding.subtype fun (x : \u03b1) => x \u2208 p) sorry\n\n@[simp] theorem rel_embedding_apply {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (p : set \u03b1) (a : \u21a5p) :\n    coe_fn (subrel.rel_embedding r p) a = subtype.val a :=\n  rfl\n\nprotected instance is_well_order {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) [is_well_order \u03b1 r] (p : set \u03b1) :\n    is_well_order (\u21a5p) (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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (p : set \u03b2) (f : r \u21aar s) (H : \u2200 (a : \u03b1), coe_fn f a \u2208 p) : r \u21aar 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {s : \u03b2 \u2192 \u03b2 \u2192 Prop} (p : set \u03b2) (f : r \u21aar s) (H : \u2200 (a : \u03b1), coe_fn f a \u2208 p) (a : \u03b1) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u2243o \u03b2) :\n    order_dual \u03b1 \u2243o order_dual \u03b2 :=\n  rel_iso.mk (rel_iso.to_equiv f) sorry\n\ntheorem order_iso.map_bot' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [partial_order \u03b1] [partial_order \u03b2]\n    (f : \u03b1 \u2243o \u03b2) {x : \u03b1} {y : \u03b2} (hx : \u2200 (x' : \u03b1), x \u2264 x') (hy : \u2200 (y' : \u03b2), y \u2264 y') :\n    coe_fn f x = y :=\n  sorry\n\ntheorem order_iso.map_bot {\u03b1 : Type u_1} {\u03b2 : Type u_2} [order_bot \u03b1] [order_bot \u03b2] (f : \u03b1 \u2243o \u03b2) :\n    coe_fn f \u22a5 = \u22a5 :=\n  order_iso.map_bot' f (fun (_x : \u03b1) => bot_le) fun (_x : \u03b2) => bot_le\n\ntheorem order_iso.map_top' {\u03b1 : Type u_1} {\u03b2 : Type u_2} [partial_order \u03b1] [partial_order \u03b2]\n    (f : \u03b1 \u2243o \u03b2) {x : \u03b1} {y : \u03b2} (hx : \u2200 (x' : \u03b1), x' \u2264 x) (hy : \u2200 (y' : \u03b2), y' \u2264 y) :\n    coe_fn f x = y :=\n  order_iso.map_bot' (order_iso.dual f) hx hy\n\ntheorem order_iso.map_top {\u03b1 : Type u_1} {\u03b2 : Type u_2} [order_top \u03b1] [order_top \u03b2] (f : \u03b1 \u2243o \u03b2) :\n    coe_fn f \u22a4 = \u22a4 :=\n  order_iso.map_bot (order_iso.dual f)\n\ntheorem order_embedding.map_inf_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semilattice_inf \u03b1]\n    [semilattice_inf \u03b2] (f : \u03b1 \u21aao \u03b2) (x : \u03b1) (y : \u03b1) : coe_fn f (x \u2293 y) \u2264 coe_fn f x \u2293 coe_fn f y :=\n  monotone.map_inf_le (order_embedding.monotone f) x y\n\ntheorem order_iso.map_inf {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semilattice_inf \u03b1] [semilattice_inf \u03b2]\n    (f : \u03b1 \u2243o \u03b2) (x : \u03b1) (y : \u03b1) : coe_fn f (x \u2293 y) = coe_fn f x \u2293 coe_fn f y :=\n  sorry\n\ntheorem order_embedding.le_map_sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semilattice_sup \u03b1]\n    [semilattice_sup \u03b2] (f : \u03b1 \u21aao \u03b2) (x : \u03b1) (y : \u03b1) : coe_fn f x \u2294 coe_fn f y \u2264 coe_fn f (x \u2294 y) :=\n  monotone.le_map_sup (order_embedding.monotone f) x y\n\ntheorem order_iso.map_sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} [semilattice_sup \u03b1] [semilattice_sup \u03b2]\n    (f : \u03b1 \u2243o \u03b2) (x : \u03b1) (y : \u03b1) : coe_fn f (x \u2294 y) = coe_fn f x \u2294 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 \u2243 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 {\u03b1 \u03b2 \u03b3 : 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 \u2243 S') :\n  sim_oracle spec spec' S' :=\n{ default_state := mask so.default_state,\n  o := \u03bb 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 \u2243 S') (mask' : S' \u2243 S'')\n  (a : \u03b1) (i : spec.\u03b9) (t : spec.domain i) (oa : oracle_comp spec \u03b1)\n  (ob : \u03b1 \u2192 oracle_comp spec \u03b2) (s : S) (s' : S') (s'' : S'')\n  (x : spec.domain i \u00d7 S') (y : spec.range i \u00d7 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' (\u03bb \u03b1 a s, _) _ (\u03bb i t s, _),\n  { rw [support_simulate_return, set.image_singleton, prod_map, id.def, equiv.apply_symm_apply] },\n  { refine \u03bb \u03b1 \u03b2 oa ob s, set.ext (\u03bb x, _),\n    simp_rw [support_simulate_bind, set.image_Union, set.mem_Union],\n    refine \u27e8\u03bb h, _, \u03bb h, _\u27e9,\n    { obtain \u27e8\u27e8a, t\u27e9, hta, hx\u27e9 := h,\n      exact \u27e8(a, mask t), \u27e8(a, t), hta, rfl\u27e9, (mask.symm_apply_apply t).symm \u25b8 hx\u27e9 },\n    { obtain \u27e8\u27e8a, t\u27e9, \u27e8\u27e8a', t'\u27e9, \u27e8htas, hta\u27e9\u27e9, hx\u27e9 := 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 \u27e8(a', mask.symm t), this.symm \u25b8 htas, hta.1.symm \u25b8 hx\u27e9 } },\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) \u207b\u00b9' (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 \u03bb 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) \u207b\u00b9' (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 : \u2045so.mask_state mask i (t, s')\u2046 =\n  (\u2045so i (t, mask.symm s')\u2046).map (prod.map id mask) :=\nby simpa only [mask_state_apply_eq, eval_dist_map]\n\n@[simp]\ntheorem eval_dist_simulate_mask : \u2045simulate (so.mask_state mask) oa s'\u2046\n  = (\u2045simulate so oa (mask.symm s')\u2046).map (prod.map id mask) :=\nbegin\n  induction oa using oracle_comp.induction_on with \u03b1 a \u03b1 \u03b2 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 $ \u03bb 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 : \u03b1 \u00d7 S') : \u2045simulate (so.mask_state mask) oa s'\u2046 x =\n  \u2045simulate so oa (mask.symm s')\u2046 (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) $ \u03bb y hy, _).trans _,\n  { have : x \u2260 prod.map id \u21d1mask y := \u03bb 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 : \u2045simulate' (so.mask_state mask) oa s'\u2046 =\n  \u2045simulate' so oa (mask.symm s')\u2046 :=\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 : \u2045simulate' (so.mask_state mask) oa s'\u2046 a =\n  \u2045simulate' so oa (mask.symm s')\u2046 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 \u00d7 S')) :\n  \u2045e | so.mask_state mask i (t, s')\u2046 = \u2045(prod.map id mask) \u207b\u00b9' e | so i (t, mask.symm s')\u2046 :=\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 (\u03b1 \u00d7 S')) :\n  \u2045e | simulate (so.mask_state mask) oa s'\u2046 =\n    \u2045(prod.map id mask) \u207b\u00b9' e | simulate so oa (mask.symm s')\u2046 :=\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 (\u03b1 \u00d7 S')) :\n  \u2045e | simulate (so.mask_state mask) oa s'\u2046 =\n    \u2045(prod.map id mask.symm) '' e | simulate so oa (mask.symm s')\u2046 :=\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 \u27e8\u03bb \u27e8x', hx'\u27e9, by simpa only [\u2190 hx'.2, equiv.apply_symm_apply, prod.mk.eta] using hx'.1,\n    \u03bb h, \u27e8(x.1, mask x.2), h, prod.eq_iff_fst_eq_snd_eq.2 \u27e8rfl, equiv.symm_apply_apply _ _\u27e9\u27e9\u27e9\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 {\u03b1 : Type u} {\u03b1' : Type w} {\u03b2 : Type v} {\u03b2' : Type x}\nopen sum\n\n/-- Check if a sum is `inl` and if so, retrieve its contents. -/\n@[simp] def sum.get_left {\u03b1 \u03b2} : \u03b1 \u2295 \u03b2 \u2192 option \u03b1\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 {\u03b1 \u03b2} : \u03b1 \u2295 \u03b2 \u2192 option \u03b2\n| (inr b) := some b\n| (inl _) := none\n\n/-- Check if a sum is `inl`. -/\n@[simp] def sum.is_left {\u03b1 \u03b2} : \u03b1 \u2295 \u03b2 \u2192 bool\n| (inl _) := tt\n| (inr _) := ff\n\n/-- Check if a sum is `inr`. -/\n@[simp] def sum.is_right {\u03b1 \u03b2} : \u03b1 \u2295 \u03b2 \u2192 bool\n| (inl _) := ff\n| (inr _) := tt\n\nattribute [derive decidable_eq] sum\n\n@[simp] theorem sum.forall {p : \u03b1 \u2295 \u03b2 \u2192 Prop} : (\u2200 x, p x) \u2194 (\u2200 a, p (inl a)) \u2227 (\u2200 b, p (inr b)) :=\n\u27e8\u03bb h, \u27e8\u03bb a, h _, \u03bb b, h _\u27e9, \u03bb \u27e8h\u2081, h\u2082\u27e9, sum.rec h\u2081 h\u2082\u27e9\n\n@[simp] theorem sum.exists {p : \u03b1 \u2295 \u03b2 \u2192 Prop} : (\u2203 x, p x) \u2194 (\u2203 a, p (inl a)) \u2228 \u2203 b, p (inr b) :=\n\u27e8\u03bb h, match h with\n| \u27e8inl a, h\u27e9 := or.inl \u27e8a, h\u27e9\n| \u27e8inr b, h\u27e9 := or.inr \u27e8b, h\u27e9\nend, \u03bb h, match h with\n| or.inl \u27e8a, h\u27e9 := \u27e8inl a, h\u27e9\n| or.inr \u27e8b, h\u27e9 := \u27e8inr b, h\u27e9\nend\u27e9\n\nnamespace sum\n\nlemma inl_injective : function.injective (sum.inl : \u03b1 \u2192 \u03b1 \u2295 \u03b2) :=\n\u03bb x y, sum.inl.inj\n\nlemma inr_injective : function.injective (sum.inr : \u03b2 \u2192 \u03b1 \u2295 \u03b2) :=\n\u03bb x y, sum.inr.inj\n\n/-- Map `\u03b1 \u2295 \u03b2` to `\u03b1' \u2295 \u03b2'` sending `\u03b1` to `\u03b1'` and `\u03b2` to `\u03b2'`. -/\nprotected def map (f : \u03b1 \u2192 \u03b1') (g : \u03b2 \u2192 \u03b2')  : \u03b1 \u2295 \u03b2 \u2192 \u03b1' \u2295 \u03b2'\n| (sum.inl x) := sum.inl (f x)\n| (sum.inr x) := sum.inr (g x)\n\n@[simp] lemma map_inl (f : \u03b1 \u2192 \u03b1') (g : \u03b2 \u2192 \u03b2') (x : \u03b1) : (inl x).map f g = inl (f x) := rfl\n@[simp] lemma map_inr (f : \u03b1 \u2192 \u03b1') (g : \u03b2 \u2192 \u03b2') (x : \u03b2) : (inr x).map f g = inr (g x) := rfl\n\n@[simp] lemma map_map {\u03b1'' \u03b2''} (f' : \u03b1' \u2192 \u03b1'') (g' : \u03b2' \u2192 \u03b2'') (f : \u03b1 \u2192 \u03b1') (g : \u03b2 \u2192 \u03b2') :\n  \u2200 x : \u03b1 \u2295 \u03b2, (x.map f g).map f' g' = x.map (f' \u2218 f) (g' \u2218 g)\n| (inl a) := rfl\n| (inr b) := rfl\n\n@[simp] lemma map_comp_map {\u03b1'' \u03b2''} (f' : \u03b1' \u2192 \u03b1'') (g' : \u03b2' \u2192 \u03b2'') (f : \u03b1 \u2192 \u03b1') (g : \u03b2 \u2192 \u03b2') :\n  (sum.map f' g') \u2218 (sum.map f g) = sum.map (f' \u2218 f) (g' \u2218 g) :=\nfunext $ map_map f' g' f g\n\n@[simp] lemma map_id_id (\u03b1 \u03b2) : sum.map (@id \u03b1) (@id \u03b2) = id :=\nfunext $ \u03bb x, sum.rec_on x (\u03bb _, rfl) (\u03bb _, rfl)\n\ntheorem inl.inj_iff {a b} : (inl a : \u03b1 \u2295 \u03b2) = inl b \u2194 a = b :=\n\u27e8inl.inj, congr_arg _\u27e9\n\ntheorem inr.inj_iff {a b} : (inr a : \u03b1 \u2295 \u03b2) = inr b \u2194 a = b :=\n\u27e8inr.inj, congr_arg _\u27e9\n\ntheorem inl_ne_inr {a : \u03b1} {b : \u03b2} : inl a \u2260 inr b.\n\ntheorem inr_ne_inl {a : \u03b1} {b : \u03b2} : inr b \u2260 inl a.\n\n/-- Define a function on `\u03b1 \u2295 \u03b2` by giving separate definitions on `\u03b1` and `\u03b2`. -/\nprotected def elim {\u03b1 \u03b2 \u03b3 : Sort*} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) : \u03b1 \u2295 \u03b2 \u2192 \u03b3 := \u03bb x, sum.rec_on x f g\n\n@[simp] lemma elim_inl {\u03b1 \u03b2 \u03b3 : Sort*} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) (x : \u03b1) :\n  sum.elim f g (inl x) = f x := rfl\n\n@[simp] lemma elim_inr {\u03b1 \u03b2 \u03b3 : Sort*} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) (x : \u03b2) :\n  sum.elim f g (inr x) = g x := rfl\n\n@[simp] lemma elim_comp_inl {\u03b1 \u03b2 \u03b3 : Sort*} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) :\n  sum.elim f g \u2218 inl = f := rfl\n\n@[simp] lemma elim_comp_inr {\u03b1 \u03b2 \u03b3 : Sort*} (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b3) :\n  sum.elim f g \u2218 inr = g := rfl\n\n@[simp] lemma elim_inl_inr {\u03b1 \u03b2 : Sort*} :\n  @sum.elim \u03b1 \u03b2 _ inl inr = id :=\nfunext $ \u03bb x, sum.cases_on x (\u03bb _, rfl) (\u03bb _, rfl)\n\nlemma comp_elim {\u03b1 \u03b2 \u03b3 \u03b4 : Sort*} (f : \u03b3 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b3) (h : \u03b2 \u2192 \u03b3):\n  f \u2218 sum.elim g h = sum.elim (f \u2218 g) (f \u2218 h) :=\nfunext $ \u03bb x, sum.cases_on x (\u03bb _, rfl) (\u03bb _, rfl)\n\n@[simp] lemma elim_comp_inl_inr {\u03b1 \u03b2 \u03b3 : Sort*} (f : \u03b1 \u2295 \u03b2 \u2192 \u03b3) :\n  sum.elim (f \u2218 inl) (f \u2218 inr) = f :=\nfunext $ \u03bb x, sum.cases_on x (\u03bb _, rfl) (\u03bb _, 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 {\u03b1 \u03b2 \u03b3} [decidable_eq \u03b1] [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3} {i : \u03b1} {x : \u03b3} :\n  update (sum.elim f g) (inl i) x = sum.elim (update f i x) g :=\nupdate_eq_iff.2 \u27e8by simp, by simp { contextual := tt }\u27e9\n\n@[simp] lemma update_elim_inr {\u03b1 \u03b2 \u03b3} [decidable_eq \u03b2] [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3} {i : \u03b2} {x : \u03b3} :\n  update (sum.elim f g) (inr i) x = sum.elim f (update g i x) :=\nupdate_eq_iff.2 \u27e8by simp, by simp { contextual := tt }\u27e9\n\n@[simp] lemma update_inl_comp_inl {\u03b1 \u03b2 \u03b3} [decidable_eq \u03b1] [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} {i : \u03b1} {x : \u03b3} :\n  update f (inl i) x \u2218 inl = update (f \u2218 inl) i x :=\nupdate_comp_eq_of_injective _ inl_injective _ _\n\n@[simp] lemma update_inl_apply_inl {\u03b1 \u03b2 \u03b3} [decidable_eq \u03b1] [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} {i j : \u03b1} {x : \u03b3} :\n  update f (inl i) x (inl j) = update (f \u2218 inl) i x j :=\nby rw \u2190 update_inl_comp_inl\n\n@[simp] lemma update_inl_comp_inr {\u03b1 \u03b2 \u03b3} [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} {i : \u03b1} {x : \u03b3} :\n  update f (inl i) x \u2218 inr = f \u2218 inr :=\nupdate_comp_eq_of_forall_ne _ _ $ \u03bb _, inr_ne_inl\n\n@[simp] lemma update_inl_apply_inr {\u03b1 \u03b2 \u03b3} [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} {i : \u03b1} {j : \u03b2} {x : \u03b3} :\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 {\u03b1 \u03b2 \u03b3} [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} {i : \u03b2} {x : \u03b3} :\n  update f (inr i) x \u2218 inl = f \u2218 inl :=\nupdate_comp_eq_of_forall_ne _ _ $ \u03bb _, inl_ne_inr\n\n@[simp] lemma update_inr_apply_inl {\u03b1 \u03b2 \u03b3} [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} {i : \u03b1} {j : \u03b2} {x : \u03b3} :\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 {\u03b1 \u03b2 \u03b3} [decidable_eq \u03b2] [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} {i : \u03b2} {x : \u03b3} :\n  update f (inr i) x \u2218 inr = update (f \u2218 inr) i x :=\nupdate_comp_eq_of_injective _ inr_injective _ _\n\n@[simp] lemma update_inr_apply_inr {\u03b1 \u03b2 \u03b3} [decidable_eq \u03b2] [decidable_eq (\u03b1 \u2295 \u03b2)]\n  {f : \u03b1 \u2295 \u03b2 \u2192 \u03b3} {i j : \u03b2} {x : \u03b3} :\n  update f (inr i) x (inr j) = update (f \u2218 inr) i x j :=\nby rw \u2190 update_inr_comp_inr\n\nsection\n  variables (ra : \u03b1 \u2192 \u03b1 \u2192 Prop) (rb : \u03b2 \u2192 \u03b2 \u2192 Prop)\n\n  /-- Lexicographic order for sum. Sort all the `inl a` before the `inr b`,\n    otherwise use the respective order on `\u03b1` or `\u03b2`. -/\n  inductive lex : \u03b1 \u2295 \u03b2 \u2192 \u03b1 \u2295 \u03b2 \u2192 Prop\n  | inl {a\u2081 a\u2082} (h : ra a\u2081 a\u2082) : lex (inl a\u2081) (inl a\u2082)\n  | inr {b\u2081 b\u2082} (h : rb b\u2081 b\u2082) : lex (inr b\u2081) (inr b\u2082)\n  | sep (a b) : lex (inl a) (inr b)\n\n  variables {ra rb}\n\n  @[simp] theorem lex_inl_inl {a\u2081 a\u2082} : lex ra rb (inl a\u2081) (inl a\u2082) \u2194 ra a\u2081 a\u2082 :=\n  \u27e8\u03bb h, by cases h; assumption, lex.inl\u27e9\n\n  @[simp] theorem lex_inr_inr {b\u2081 b\u2082} : lex ra rb (inr b\u2081) (inr b\u2082) \u2194 rb b\u2081 b\u2082 :=\n  \u27e8\u03bb h, by cases h; assumption, lex.inr\u27e9\n\n  @[simp] theorem lex_inr_inl {b a} : \u00ac lex ra rb (inr b) (inl a) :=\n  \u03bb 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 : \u2200 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 : \u2200 a, acc (lex ra rb) (inl a), from \u03bb a, lex_acc_inl (ha.apply a),\n  \u27e8\u03bb x, sum.rec_on x aca (\u03bb b, lex_acc_inr aca (hb.apply b))\u27e9\n\nend\n\n/-- Swap the factors of a sum type -/\n@[simp] def swap : \u03b1 \u2295 \u03b2 \u2192 \u03b2 \u2295 \u03b1\n| (inl a) := inr a\n| (inr b) := inl b\n\n@[simp] lemma swap_swap (x : \u03b1 \u2295 \u03b2) : swap (swap x) = x :=\nby cases x; refl\n\n@[simp] lemma swap_swap_eq : swap \u2218 swap = @id (\u03b1 \u2295 \u03b2) :=\nfunext $ swap_swap\n\n@[simp] lemma swap_left_inverse : function.left_inverse (@swap \u03b1 \u03b2) swap :=\nswap_swap\n\n@[simp] lemma swap_right_inverse : function.right_inverse (@swap \u03b1 \u03b2) swap :=\nswap_swap\n\nend sum\n\nnamespace function\n\nopen sum\n\nlemma injective.sum_elim {\u03b3} {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b3}\n  (hf : injective f) (hg : injective g) (hfg : \u2200 a b, f a \u2260 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 : \u03b1 \u2192 \u03b2} {g : \u03b1' \u2192 \u03b2'} (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 : \u03b1 \u2192 \u03b2} {g : \u03b1' \u2192 \u03b2'} (hf : surjective f) (hg : surjective g) :\n  surjective (sum.map f g)\n| (inl y) := let \u27e8x, hx\u27e9 := hf y in \u27e8inl x, congr_arg inl hx\u27e9\n| (inr y) := let \u27e8x, hx\u27e9 := hg y in \u27e8inr x, congr_arg inr hx\u27e9\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": "import c0.dyn_ok\n\nnamespace c0\n\nopen ast ast.gdecl\n\nnamespace ast\n\ninductive okind : ast \u2192 Prop\n| nil : okind []\n| cons {d \u0393} : gdecl.ok \u0393 d \u2192 okind \u0393 \u2192 okind (d :: \u0393)\n\ntheorem ok.ind {\u0393 : ast} (h : \u0393.ok) : \u0393.okind :=\nbegin\n  rw \u2190 \u0393.reverse_reverse,\n  suffices : \u2200 \u0393 ds, ok' \u0393 ds \u2192 okind \u0393 \u2192 okind (list.reverse_core ds \u0393),\n  from this [] \u0393.reverse h.gdecls okind.nil,\n  clear h \u0393, introv h\u2081 h\u2082,\n  induction h\u2081, {exact h\u2082},\n  exact h\u2081_ih (okind.cons h\u2081_a h\u2082)\nend\n\ninductive below (P : ast \u2192 Prop) : ast \u2192 Prop\n| nil {} : below []\n| cons (d \u0393) : gdecl.ok \u0393 d \u2192 P \u0393 \u2192 below (d :: \u0393)\n\n@[elab_as_eliminator]\ntheorem okind.induction' {P : ast \u2192 Prop} {\u0393 : ast} (h : \u0393.okind)\n  (H : \u2200 \u0393, okind \u0393 \u2192 below P \u0393 \u2192 P \u0393) : P \u0393 :=\nokind.rec_on h (H [] okind.nil below.nil)\n  (\u03bb d \u0393 h\u2081 ok h\u2082, H _ (okind.cons h\u2081 ok) (below.cons d \u0393 h\u2081 h\u2082))\n\nnamespace eval_ty\n\n@[elab_as_eliminator]\ntheorem induction\u2081 {P : type \u2192 c0.type \u2192 Prop} {\u0393 : ast}\n  {\u03c4 \u03c4'} (H : eval_ty \u0393 \u03c4 \u03c4')\n  (Hint : P type.int c0.type.int)\n  (Hbool : P type.bool c0.type.bool)\n  (Href : \u2200 \u03c4 \u03c4', eval_ty \u0393 \u03c4 \u03c4' \u2192 P \u03c4 \u03c4' \u2192 P (type.ref \u03c4) (c0.type.ref \u03c4'))\n  (Harr : \u2200 \u03c4 \u03c4', eval_ty \u0393 \u03c4 \u03c4' \u2192 P \u03c4 \u03c4' \u2192 P (type.arr \u03c4) (c0.type.arr \u03c4'))\n  (Hstruct : \u2200 s, P (type.struct s) (c0.type.struct s))\n  (Hweak : \u2200 d \u0393', \u0393 = d :: \u0393' \u2192 \u2200 \u03c4 \u03c4', eval_ty \u0393' \u03c4 \u03c4' \u2192 P \u03c4 \u03c4')\n  (Hvar : \u2200 v \u03c4\u2080 \u0393', \u0393 = typedef v \u03c4\u2080 :: \u0393' \u2192\n    \u2200 \u03c4', eval_ty \u0393 \u03c4\u2080 \u03c4' \u2192 P \u03c4\u2080 \u03c4' \u2192 P (type.var v) \u03c4') : P \u03c4 \u03c4' :=\nbegin\n  generalize e : \u0393 = \u0393', rw e at H,\n  induction H; cases e; try {solve_by_elim},\n  { exact Hvar _ _ _ rfl _ (weak H_a) (Hweak _ _ rfl _ _ H_a) },\n  { exact Href _ _ H_a (H_ih rfl) },\n  { exact Harr _ _ H_a (H_ih rfl) }\nend\n\ntheorem var_determ {\u0393 : ast} (ok : \u0393.okind) : \u2200 {v \u03c4\u2081 \u03c4\u2082},\n  typedef v \u03c4\u2081 \u2208 \u0393 \u2192 typedef v \u03c4\u2082 \u2208 \u0393 \u2192 \u03c4\u2081 = \u03c4\u2082 :=\nbegin\n  induction ok with d \u0393 h _ IH, {rintro _ _ _ \u27e8\u27e9},\n  rintro v \u03c4\u2081 \u03c4\u2082 (rfl | h\u2081) (\u27e8\u27e8\u27e9\u27e9 | h\u2082),\n  { refl },\n  { cases h, cases h_a _ h\u2082 },\n  { cases h, cases h_a _ h\u2081 },\n  { exact IH h\u2081 h\u2082 }\nend\n\ntheorem mem_of_var {\u0393 : ast} {v \u03c4} :\n  eval_ty \u0393 (type.var v) \u03c4 \u2192 \u2203 \u03c4', typedef v \u03c4' \u2208 \u0393 \u2227\n    \u2203 d \u0393', \u0393 = d :: \u0393' \u2227 eval_ty \u0393' \u03c4' \u03c4 :=\nbegin\n  generalize e : type.var v = x,\n  intro h, induction h; cases e,\n  { exact \u27e8_, or.inl rfl, _, _, rfl, h_a\u27e9 },\n  { rcases h_ih rfl with \u27e8\u03c4', h\u2081, d', \u0393'', rfl, h\u2082\u27e9,\n    exact \u27e8\u03c4', or.inr h\u2081, _, _, rfl, weak h\u2082\u27e9 }\nend\n\ntheorem int' : \u2200 \u0393, eval_ty \u0393 type.int c0.type.int\n| [] := int\n| (d::\u0393) := weak (int' _)\n\ntheorem bool' : \u2200 \u0393, eval_ty \u0393 type.bool c0.type.bool\n| [] := bool\n| (d::\u0393) := weak (bool' _)\n\ntheorem struct' (s) : \u2200 \u0393, eval_ty \u0393 (type.struct s) (c0.type.struct s)\n| [] := struct\n| (d::\u0393) := weak (struct' _)\n\ntheorem ref_inv {\u0393 t \u03c4} (H : eval_ty \u0393 (type.ref t) \u03c4) :\n  \u2203 \u03c4', eval_ty \u0393 t \u03c4' \u2227 c0.type.ref \u03c4' = \u03c4 :=\nbegin\n  generalize e : type.ref t = t', rw e at H,\n  induction H; cases e,\n  { exact \u27e8_, H_a, rfl\u27e9 },\n  { rcases H_ih rfl with \u27e8\u03c4', h\u2081, h\u2082\u27e9,\n    exact \u27e8\u03c4', weak h\u2081, h\u2082\u27e9 }\nend\n\ntheorem arr_inv {\u0393 t \u03c4} (H : eval_ty \u0393 (type.arr t) \u03c4) :\n  \u2203 \u03c4', eval_ty \u0393 t \u03c4' \u2227 c0.type.arr \u03c4' = \u03c4 :=\nbegin\n  generalize e : type.arr t = t', rw e at H,\n  induction H; cases e,\n  { exact \u27e8_, H_a, rfl\u27e9 },\n  { rcases H_ih rfl with \u27e8\u03c4', h\u2081, h\u2082\u27e9,\n    exact \u27e8\u03c4', weak h\u2081, h\u2082\u27e9 }\nend\n\ntheorem determ {\u0393 : ast} (ok : \u0393.okind) : \u2200 {t \u03c4\u2081 \u03c4\u2082}\n  (h\u2081 : eval_ty \u0393 t \u03c4\u2081) (h\u2082 : eval_ty \u0393 t \u03c4\u2082), \u03c4\u2081 = \u03c4\u2082 :=\nokind.induction' ok $ \u03bb \u0393 ok IH t, begin\n  induction t,\n  { suffices : \u2200 {\u03c4}, eval_ty \u0393 type.int \u03c4 \u2192 \u03c4 = c0.type.int,\n    { intros, exact (this h\u2081).trans (this h\u2082).symm },\n    intros, cases a, {refl},\n    { cases IH, exact IH_a_1 a_a (eval_ty.int' _) } },\n  { suffices : \u2200 {\u03c4}, eval_ty \u0393 type.bool \u03c4 \u2192 \u03c4 = c0.type.bool,\n    { intros, exact (this h\u2081).trans (this h\u2082).symm },\n    intros, cases a, {refl},\n    { cases IH, exact IH_a_1 a_a (eval_ty.bool' _) } },\n  { intros,\n    rcases mem_of_var h\u2081 with \u27e8\u03c4, m\u2081, d, \u0393', rfl, h\u2081'\u27e9,\n    rcases mem_of_var h\u2082 with \u27e8\u03c4', m\u2082, _, _, \u27e8\u27e9, h\u2082'\u27e9,\n    cases var_determ ok m\u2081 m\u2082,\n    cases IH, exact IH_a_1 h\u2081' h\u2082' },\n  { intros,\n    rcases ref_inv h\u2081 with \u27e8\u03c4\u2081', h\u2081', rfl\u27e9,\n    rcases ref_inv h\u2082 with \u27e8\u03c4\u2082', h\u2082', rfl\u27e9,\n    cases t_ih h\u2081' h\u2082', refl },\n  { intros,\n    rcases arr_inv h\u2081 with \u27e8\u03c4\u2081', h\u2081', rfl\u27e9,\n    rcases arr_inv h\u2082 with \u27e8\u03c4\u2082', h\u2082', rfl\u27e9,\n    cases t_ih h\u2081' h\u2082', refl },\n  { suffices : \u2200 {s \u03c4}, eval_ty \u0393 (type.struct s) \u03c4 \u2192 \u03c4 = c0.type.struct s,\n    { intros, exact (this h\u2081).trans (this h\u2082).symm },\n    intros, cases a, {refl},\n    { cases IH, exact IH_a_1 a_a (eval_ty.struct' _ _) } }\nend\n\ntheorem determ_opt {\u0393 : ast} (ok : \u0393.okind) {t \u03c4\u2081 \u03c4\u2082}\n  (h\u2081 : option.forall\u2082 (eval_ty \u0393) t \u03c4\u2081)\n  (h\u2082 : option.forall\u2082 (eval_ty \u0393) t \u03c4\u2082) : \u03c4\u2081 = \u03c4\u2082 :=\nbegin\n  cases h\u2081; cases h\u2082, {refl},\n  cases determ ok h\u2081_a_1 h\u2082_a_1, refl\nend\n\ntheorem determ_alist {\u03b1} {\u0393 : ast} (ok : \u0393.okind) : \u2200 {xts \u0394\u2081 \u0394\u2082}\n  (h\u2081 : alist.forall\u2082 (\u03bb _:\u03b1, eval_ty \u0393) xts \u0394\u2081)\n  (h\u2082 : alist.forall\u2082 (\u03bb _, eval_ty \u0393) xts \u0394\u2082), \u0394\u2081 = \u0394\u2082\n| \u27e8xts, nd\u27e9 \u27e8L\u2081, nd\u2081\u27e9 \u27e8L\u2082, nd\u2082\u27e9 h\u2081 h\u2082 := begin\n  congr, dsimp [alist.forall\u2082] at h\u2081 h\u2082, clear nd nd\u2081 nd\u2082 determ_alist,\n  induction xts with xt xts generalizing L\u2081 L\u2082; cases h\u2081; cases h\u2082, {refl},\n  rcases h\u2081_a_1 with \u27e8i, x, \u03c4, _\u27e9,\n  rcases h\u2082_a_1 with \u27e8_, _, \u03c4', _\u27e9,\n  cases xts_ih _ _ h\u2081_a_2 h\u2082_a_2,\n  cases determ ok h\u2081_a_1_a h\u2082_a_1_a_1, refl\nend\n\nend eval_ty\n\ntheorem get_fdef.weak {\u0393 f fd d} (h : get_fdef \u0393 f fd) : get_fdef (d :: \u0393) f fd :=\nby cases h with h f x\u03c4s \u03c4s' \u03c4 \u03c4' body \u0393 h\u2081 h\u2082 h\u2083; exact\n\u27e8or.inr h\u2081, h\u2082.imp (\u03bb _ _, eval_ty.weak), h\u2083.imp (\u03bb _ _, eval_ty.weak)\u27e9\n\ntheorem get_body.weak {\u0393 f \u03c4 \u0394 s d} (h : get_body \u0393 f \u03c4 \u0394 s) : get_body (d :: \u0393) f \u03c4 \u0394 s :=\nby cases h with h f x\u03c4s \u0394 \u03c4 \u03c4' nd body \u0393 h\u2081 h\u2082 h\u2083; exact\n\u27e8or.inr h\u2081, h\u2082.imp (\u03bb _ _ _, eval_ty.weak), h\u2083.imp (\u03bb _ _, eval_ty.weak)\u27e9\n\ntheorem is_fdef.weak {\u0393 f d} : is_fdef \u0393 f \u2192 is_fdef (d :: \u0393) f\n| \u27e8\u03c4, x\u03c4s, s, h\u27e9 := \u27e8\u03c4, x\u03c4s, s, h.weak\u27e9\n\ntheorem is_extern.weak {\u0393 f d} (h : is_extern \u0393 f) : is_extern (d :: \u0393) f :=\nby cases h with f x\u03c4s \u03c4 body \u0393 h; exact \u27e8or.inr h\u27e9\n\ntheorem get_sdef.weak {\u0393 s sd d} (h : get_sdef \u0393 s sd) : get_sdef (d :: \u0393) s sd :=\nby cases h with s x\u03c4s nd \u0394 \u0393 h\u2081 h\u2082; exact\n\u27e8or.inr h\u2081, h\u2082.imp (\u03bb _ _ _, eval_ty.weak)\u27e9\n\ntheorem sized.weak {\u0393 \u03c4 d} (h : sized \u0393 \u03c4) : sized (d :: \u0393) \u03c4 :=\nbegin\n  cases \u03c4; try {trivial},\n  exact h.imp (\u03bb _, get_sdef.weak)\nend\n\ntheorem get_body.get_fdef {\u0393 : ast} {f \u03c4 \u0394 s}\n  (h : \u0393.get_body f \u03c4 \u0394 s) : \u0393.get_fdef f \u27e8\u0394.values, \u03c4\u27e9 :=\nbegin\n  cases h with h x\u03c4s ts _ t _ nd _ _ m ts\u0394 t\u03c4,\n  refine \u27e8m, _, t\u03c4\u27e9,\n  cases \u0394 with \u0394 nd',\n  refine list.forall\u2082_map_right_iff.2 ((list.forall\u2082_map_left_iff.1 ts\u0394).imp _),\n  rintro \u27e8i, t\u27e9 \u27e8_, \u03c4\u27e9 \u27e8_, _, _, h\u27e9, exact h\nend\n\nnamespace exp\n\ntheorem ok.weak {\u0393 \u0394 e \u03c4 d} (h : exp.ok \u0393 \u0394 e \u03c4) : exp.ok (d :: \u0393) \u0394 e \u03c4 :=\nbegin\n  induction h,\n  { exact ok.int },\n  { exact ok.bool },\n  { exact ok.null },\n  { exact ok.var h_a },\n  { exact ok.binop h_ih_a h_ih_a_1 h_a_2 },\n  { exact ok.unop h_ih h_a_1 },\n  { exact ok.cond h_ih_a h_ih_a_1 h_ih_a_2 h_a_3 },\n  { exact ok.nil },\n  { exact ok.cons h_ih_a h_ih_a_1 },\n  { exact ok.call h_a.weak h_ih },\n  { exact ok.field h_ih h_a_1.weak h_a_2 },\n  { exact ok.deref h_ih h_a_1 },\n  { exact ok.index h_ih_a h_ih_a_1 },\n  { exact ok.alloc_ref h_a.weak h_a_1.weak },\n  { exact ok.alloc_arr h_a.weak h_a_1.weak h_ih },\nend\n\ntheorem ok.weak' {\u0393 \u0394 e \u03c4 v t h} (H : exp.ok \u0393 \u0394 e \u03c4) : exp.ok \u0393 (\u0394.cons v t h) e \u03c4 :=\nbegin\n  induction H,\n  { exact ok.int },\n  { exact ok.bool },\n  { exact ok.null },\n  { exact ok.var (alist.lookup_cons_of_lookup H_a) },\n  { exact ok.binop H_ih_a H_ih_a_1 H_a_2 },\n  { exact ok.unop H_ih H_a_1 },\n  { exact ok.cond H_ih_a H_ih_a_1 H_ih_a_2 H_a_3 },\n  { exact ok.nil },\n  { exact ok.cons H_ih_a H_ih_a_1 },\n  { exact ok.call H_a H_ih },\n  { exact ok.field H_ih H_a_1 H_a_2 },\n  { exact ok.deref H_ih H_a_1 },\n  { exact ok.index H_ih_a H_ih_a_1 },\n  { exact ok.alloc_ref H_a H_a_1 },\n  { exact ok.alloc_arr H_a H_a_1 H_ih },\nend\n\ntheorem uses.mono {R \u03b4 \u03b4'} (ss : \u03b4 \u2286 \u03b4') : \u2200 {e}, uses R \u03b4 e \u2192 uses R \u03b4' e\n| (int _) h := h\n| (bool _) h := h\n| null h := h\n| (var v) h := ss h\n| (binop _ e\u2081 e\u2082) \u27e8h\u2081, h\u2082\u27e9 := \u27e8h\u2081.mono, h\u2082.mono\u27e9\n| (unop _ e) h := @uses.mono e h\n| (cond c e\u2081 e\u2082) \u27e8h\u2081, h\u2082, h\u2083\u27e9 := \u27e8h\u2081.mono, h\u2082.mono, h\u2083.mono\u27e9\n| nil h := h\n| (cons e es) \u27e8h\u2081, h\u2082\u27e9 := \u27e8h\u2081.mono, h\u2082.mono\u27e9\n| (call f es) \u27e8h\u2081, h\u2082\u27e9 := \u27e8h\u2081, h\u2082.mono\u27e9\n| (field e f) h := @uses.mono e h\n| (deref e) h := @uses.mono e h\n| (index e\u2081 e\u2082) \u27e8h\u2081, h\u2082\u27e9 := \u27e8h\u2081.mono, h\u2082.mono\u27e9\n| (alloc_ref _) h := h\n| (alloc_arr _ e) h := @uses.mono e h\n\nend exp\n\ntheorem lval.ok : \u2200 (lv : lval), lv_ok lv.to_exp\n| (lval.var v)       := lv_ok.var\n| (lval.deref e)     := lv_ok.deref\n| (lval.index e\u2081 e\u2082) := lv_ok.index\n| (lval.field e f)   := lv_ok.field (lval.ok e)\n\ntheorem lval.uses.mono {R \u03b4 \u03b4'} (ss : \u03b4 \u2286 \u03b4') {lv : lval}\n  (h : lval.uses R \u03b4 lv) : lval.uses R \u03b4' lv :=\nby unfold lval.uses at *; cases (lval.is_var lv).is_some;\n   [exact h.mono ss, trivial]\n\nnamespace stmt\n\ntheorem ok.weak {\u0393 ret_\u03c4 \u0394 s d} (h : stmt.ok \u0393 ret_\u03c4 \u0394 s) : stmt.ok (d :: \u0393) ret_\u03c4 \u0394 s :=\nbegin\n  induction h,\n  { exact ok.decl h_h h_a.weak h_a_1 h_ih },\n  { exact ok.decl_asgn h_h h_a.weak h_a_1 h_a_2.weak h_ih },\n  { exact ok.If h_a.weak h_ih_a h_ih_a_1 },\n  { exact ok.while h_a.weak h_ih },\n  { exact ok.asgn h_a.weak h_a_1.weak h_a_2 },\n  { exact ok.asnop h_a.weak h_a_1.weak h_a_2 },\n  { exact ok.eval h_a.weak h_a_1 },\n  { exact ok.assert h_a.weak },\n  { exact ok.ret (h_a.imp (\u03bb _ _, exp.ok.weak)) },\n  { exact ok.nop },\n  { exact ok.seq h_ih_a h_ih_a_1 },\nend\n\ntheorem init.subset {\u0393 R \u0394 ret \u03b3 \u03b4 s \u03b4'} (ok : stmt.ok \u0393 ret \u0394 s)\n  (e : \u0394.keys.to_finset = \u03b3)\n  (h : init R \u03b3 \u03b4 s \u03b4') (ss : \u03b4 \u2286 \u03b3) : \u03b4 \u2286 \u03b4' \u2227 \u03b4' \u2286 \u03b3 :=\nbegin\n  have lem : \u2200 {\u0394 : ctx} {\u03b3 \u03b4 \u03b4' : finset ident} {v},\n    list.to_finset (alist.keys \u0394) = \u03b3 \u2192 v \u2209 \u0394 \u2192\n    \u03b4 \u2286 \u03b3 \u2192 \u03b4 \u2286 \u03b4' \u2227 \u03b4' \u2286 insert v \u03b3 \u2192 \u03b4 \u2286 \u03b4'.erase v \u2227 \u03b4'.erase v \u2286 \u03b3,\n  { rintro \u0394 \u03b3 \u03b4 \u03b4' v e hn ss \u27e8ss\u2081, ss\u2082\u27e9,\n    refine \u27e8\u03bb x x\u03b4, finset.mem_erase.2 \u27e8_, ss\u2081 x\u03b4\u27e9,\n      finset.subset.trans (finset.erase_subset_erase _ ss\u2082)\n        (finset.erase_insert_subset _ _)\u27e9,\n    rintro rfl, subst \u03b3,\n    cases hn (alist.mem_keys.1 $ list.mem_to_finset.1 $ ss x\u03b4) },\n  induction ok generalizing \u03b3 \u03b4 \u03b4'; cases h; try {exact \u27e8\u03bb x, id, ss\u27e9},\n  { refine lem e ok_h ss (ok_ih _ h_a\n      (\u03bb x x\u03b4, finset.mem_insert_of_mem (ss x\u03b4))),\n    subst \u03b3, simp },\n  { cases ok_ih _ h_a_1 (finset.insert_subset_insert _ ss) with IH\u2081 IH\u2082,\n    refine lem e ok_h ss \u27e8\u03bb x x\u03b4, IH\u2081 (finset.mem_insert_of_mem x\u03b4), IH\u2082\u27e9,\n    subst \u03b3, simp },\n  { cases ok_ih_a e h_a_1 ss with l\u2081 r\u2081,\n    cases ok_ih_a_1 e h_a_2 ss with l\u2082 r\u2082,\n    exact \u27e8\u03bb x x\u03b4, finset.mem_inter.2 \u27e8l\u2081 x\u03b4, l\u2082 x\u03b4\u27e9,\n      \u03bb x x\u03b4, r\u2081 (finset.mem_inter.1 x\u03b4).1\u27e9 },\n  { cases ok_lv; try {exact \u27e8\u03bb x, id, ss\u27e9},\n    refine \u27e8finset.subset_insert _ _, finset.insert_subset.2 \u27e8_, ss\u27e9\u27e9,\n    subst \u03b3, cases ok_a,\n    exact list.mem_to_finset.2 (alist.mem_keys.2 $\n      alist.exists_mem_lookup_iff.1 \u27e8_, ok_a_a\u27e9) },\n  { exact \u27e8ss, \u03bb _, id\u27e9 },\n  { cases ok_ih_a e h_a ss with l\u2081 r\u2081,\n    cases ok_ih_a_1 e h_a_1 r\u2081 with l\u2082 r\u2082,\n    exact \u27e8finset.subset.trans l\u2081 l\u2082, r\u2082\u27e9 }\nend\n\ntheorem init.mono {R \u03b3 \u03b4\u2081 \u03b4\u2082 s \u03b4\u2081'}\n  (h : init R \u03b3 \u03b4\u2081 s \u03b4\u2081') (ss : \u03b4\u2081 \u2286 \u03b4\u2082) :\n  \u2203 \u03b4\u2082', \u03b4\u2081' \u2286 \u03b4\u2082' \u2227 init R \u03b3 \u03b4\u2082 s \u03b4\u2082' :=\nbegin\n  induction h generalizing \u03b4\u2082,\n  { rcases h_ih ss with \u27e8\u03b4\u2082', ss', i\u27e9,\n    exact \u27e8_, finset.erase_subset_erase _ ss', init.decl i\u27e9 },\n  { rcases h_ih (finset.insert_subset_insert _ ss) with \u27e8\u03b4\u2082', ss', i\u27e9,\n    exact \u27e8_, finset.erase_subset_erase _ ss',\n      init.decl_asgn (h_a.mono ss) i\u27e9 },\n  { rcases h_ih_a ss with \u27e8\u03b4\u2083, ss\u2081, i\u2081\u27e9,\n    rcases h_ih_a_1 ss with \u27e8\u03b4\u2084, ss\u2082, i\u2082\u27e9,\n    exact \u27e8_, finset.inter_subset_inter ss\u2081 ss\u2082,\n      init.If (h_a.mono ss) i\u2081 i\u2082\u27e9 },\n  { rcases h_ih ss with \u27e8\u03b4', ss', i\u27e9,\n    exact \u27e8_, ss, init.while (h_a.mono ss) i\u27e9 },\n  { refine \u27e8_, _, init.asgn (h_a.mono ss) (h_a_1.mono ss)\u27e9,\n    cases h_lv; try {exact ss},\n    exact finset.insert_subset_insert _ ss },\n  { exact \u27e8_, ss, init.asnop (h_a.mono ss) (h_a_1.mono ss)\u27e9 },\n  { exact \u27e8_, ss, init.eval (h_a.mono ss)\u27e9 },\n  { exact \u27e8_, ss, init.assert (h_a.mono ss)\u27e9 },\n  { exact \u27e8_, \u03bb _, id, init.ret (\u03bb e h, (h_a e h).mono ss)\u27e9 },\n  { exact \u27e8_, ss, init.nop\u27e9 },\n  { rcases h_ih_a ss with \u27e8\u03b4\u2083, ss\u2081, i\u2081\u27e9,\n    rcases h_ih_a_1 ss\u2081 with \u27e8\u03b4\u2084, ss\u2082, i\u2082\u27e9,\n    exact \u27e8_, ss\u2082, init.seq i\u2081 i\u2082\u27e9 }\nend\n\nend stmt\nend ast\n\ninductive fdecl_ok (\u0393 : ast) (header x\u03c4s ret body) : Prop\n| mk (\u0394 ret' h) :\n  alist.forall\u2082 (\u03bb (i:ident) \u03c4 \u03c4', eval_ty \u0393 \u03c4 \u03c4' \u2227 \u03c4'.small) (alist.mk' x\u03c4s h) \u0394 \u2192\n  option.forall\u2082 (\u03bb \u03c4 \u03c4', eval_ty \u0393 \u03c4 \u03c4' \u2227 \u03c4'.small) ret ret' \u2192\n  (\u2200 s \u2208 (body : option stmt),\n    header = ff \u2227\n    stmt.ok \u0393 ret' \u0394 s \u2227\n    (s.returns \u2228 ret = none)) \u2192\n  fdecl_ok\n\ntheorem fdecl_ok_of_mem {\u0393 : ast} (ok : \u0393.okind)\n  {header f x\u03c4s ret body} :\n  fdecl header f x\u03c4s ret body \u2208 \u0393 \u2192\n  fdecl_ok \u0393 header x\u03c4s ret body :=\nbegin\n  induction ok with d \u0393 g ok IH; rintro (rfl | m),\n  { cases g with _ _ _ \u0394 _ ret' _ h\u2081 h\u2082 h\u2083 h\u2084,\n    refine \u27e8\u0394, ret', h\u2081,\n      h\u2082.imp (\u03bb _ _ _ \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081.weak, h\u2082\u27e9),\n      h\u2083.imp (\u03bb _ _ \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081.weak, h\u2082\u27e9),\n      \u03bb s hs, _\u27e9,\n    rcases h\u2084 s hs with \u27e8hs\u2081, _, hs\u2082, hs\u2083\u27e9,\n    exact \u27e8hs\u2081, hs\u2082, hs\u2083\u27e9 },\n  { cases IH m with \u0394 ret' h\u2081 h\u2082 h\u2083 h\u2084,\n    refine \u27e8\u0394, ret', h\u2081,\n      h\u2082.imp (\u03bb _ _ _ \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081.weak, h\u2082\u27e9),\n      h\u2083.imp (\u03bb _ _ \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2081.weak, h\u2082\u27e9),\n      \u03bb s hs, _\u27e9,\n    rcases h\u2084 s hs with \u27e8hs\u2081, hs\u2082, hs\u2083\u27e9,\n    exact \u27e8hs\u2081, hs\u2082.weak, hs\u2083\u27e9 }\nend\n\ntheorem get_fdecl_pairwise {\u0393 : ast} (ok : \u0393.okind) {f} :\n  \u0393.pairwise (\u03bb d\u2081 d\u2082, \u2200 \u2983h\u2081 h\u2082 x\u03c4s\u2081 x\u03c4s\u2082 ret\u2081 ret\u2082 s\u2081 s\u2082\u2984,\n    d\u2081 = fdecl h\u2081 f x\u03c4s\u2081 ret\u2081 (some s\u2081) \u2192\n    d\u2082 = fdecl h\u2082 f x\u03c4s\u2082 ret\u2082 (some s\u2082) \u2192 false) :=\nbegin\n  induction ok with d \u0393 g ok IH; constructor,\n  { rintro _ h h\u2081 h\u2082 x\u03c4s\u2081 x\u03c4s\u2082 ret\u2081 ret\u2082 s\u2081 s\u2082 rfl rfl,\n    -- rcases (get_fdef_ex_iff ok).2 \u27e8_, h\u27e9 with \u27e8sd, h'\u27e9,\n    cases g,\n    cases fdecl_ok_of_mem ok h,\n    cases (g_a_2 _ rfl).2.1 \u27e8_, _, _,\n      \u27e8h, a.imp (\u03bb _ _ _, and.left), a_1.imp (\u03bb _ _, and.left)\u27e9\u27e9 },\n  { exact IH }\nend\n\ntheorem ast.get_body.determ {\u0393 : ast} (ok : \u0393.okind) {f \u03c4\u2081 \u03c4\u2082 x\u03c4s\u2081 x\u03c4s\u2082 s\u2081 s\u2082}\n  (h\u2081 : get_body \u0393 f \u03c4\u2081 x\u03c4s\u2081 s\u2081) (h\u2082 : get_body \u0393 f \u03c4\u2082 x\u03c4s\u2082 s\u2082) :\n  (\u03c4\u2081, x\u03c4s\u2081, s\u2081) = (\u03c4\u2082, x\u03c4s\u2082, s\u2082) :=\nbegin\n  have : \u2200 (d\u2081 \u2208 \u0393) (d\u2082 \u2208 \u0393) \u2983h\u2081 h\u2082 x\u03c4s\u2081 x\u03c4s\u2082 \u03c4\u2081 \u03c4\u2082 s\u2081 s\u2082\u2984,\n    d\u2081 = fdecl h\u2081 f x\u03c4s\u2081 \u03c4\u2081 (some s\u2081) \u2192\n    d\u2082 = fdecl h\u2082 f x\u03c4s\u2082 \u03c4\u2082 (some s\u2082) \u2192 (\u03c4\u2081, x\u03c4s\u2081, s\u2081) = (\u03c4\u2082, x\u03c4s\u2082, s\u2082),\n  { refine list.forall_of_forall_of_pairwise _ _ ((get_fdecl_pairwise ok).imp _),\n    { exact \u03bb x y H h\u2081 h\u2082 x\u03c4s\u2081 x\u03c4s\u2082 \u03c4\u2081 \u03c4\u2082 s\u2081 s\u2082 e\u2081 e\u2082, (H e\u2082 e\u2081).symm },\n    { rintro _ _ _ _ _ _ _ _ _ _ rfl \u27e8\u27e9, refl }, swap,\n    { rintro a b H _ _ _ _ _ _ _ _ h\u2081 h\u2082, cases H h\u2081 h\u2082 } },\n  cases h\u2081, cases h\u2082,\n  cases this _ h\u2081_a _ h\u2082_a rfl rfl,\n  cases ast.eval_ty.determ_alist ok h\u2081_a_1 h\u2082_a_1,\n  cases ast.eval_ty.determ_opt ok h\u2081_a_2 h\u2082_a_2,\n  refl\nend\n\ntheorem lv_ok_of_struct {\u0393 : ast} {\u0394 e s} (ok : \u0393.okind)\n  (eok : exp.ok \u0393 \u0394 e (exp.type.reg (c0.type.struct s))) : lv_ok e :=\nbegin\n  generalize_hyp eq : exp.type.reg (c0.type.struct s) = \u03c4 at eok,\n  induction eok generalizing s;\n    try {cases eq, done}; try {constructor, done},\n  { cases eok_a_2; cases eq },\n  { cases eok_a_1; cases eq },\n  { cases eq, cases eok_a_3 },\n  { cases eok_a,\n    cases fdecl_ok_of_mem ok eok_a_a,\n    cases eok_a_a_2; cases eq,\n    rcases a_1 with _|\u27e8_, _, h\u2081, h\u2082\u27e9,\n    cases ast.eval_ty.determ ok eok_a_a_2_a_1 h\u2081,\n    cases h\u2082 },\n  { exact lv_ok.field (eok_ih rfl) }\nend\n\ntheorem sdecl_ok1 {\u0393 : ast} {s x\u03c4s}\n  (g : c0.ast.gdecl.ok \u0393 (sdecl s (some x\u03c4s))) :\n  \u2203 nd \u0394, alist.forall\u2082 (\u03bb _, eval_ty \u0393) (alist.mk' x\u03c4s nd) \u0394 \u2227\n   \u2200 \u03c4 \u2208 \u0394.values, \u0393.sized \u03c4 :=\nbegin\n  rcases g with _|_|_|\u27e8_, _, h, nd, H\u27e9, clear h, refine \u27e8nd, _\u27e9,\n  induction x\u03c4s with x\u03c4 x\u03c4s IH,\n  { exact \u27e8\u2205, list.forall\u2082.nil, list.forall_mem_nil _\u27e9 },\n  cases x\u03c4 with x \u03c4,\n  cases list.nodup_cons.1 nd with nd\u2081 nd\u2082,\n  rcases list.forall_mem_cons.1 H with \u27e8\u27e8\u03c4', h, hs\u27e9, H'\u27e9,\n  rcases IH nd\u2082 H' with \u27e8\u0394, h\u2081, h\u2082\u27e9,\n  refine \u27e8\u0394.cons x \u03c4' _, list.forall\u2082.cons \u27e8h\u27e9 h\u2081,\n    list.forall_mem_cons.2 \u27e8hs, h\u2082\u27e9\u27e9,\n  rwa [\u2190 h\u2081.mem_iff, alist.mem_keys, alist.mk'_keys]\nend\n\ntheorem sdecl_ok_of_mem {\u0393 : ast} (ok : \u0393.okind) {s x\u03c4s} :\n  sdecl s (some x\u03c4s) \u2208 \u0393 \u2192\n  \u2203 nd \u0394, alist.forall\u2082 (\u03bb _, eval_ty \u0393) (alist.mk' x\u03c4s nd) \u0394 \u2227\n   \u2200 \u03c4 \u2208 \u0394.values, \u0393.sized \u03c4 :=\nbegin\n  induction ok with d \u0393 g ok IH; intro m, {cases m},\n  suffices : \u2203 nd \u0394,\n    alist.forall\u2082 (\u03bb _, eval_ty \u0393) (alist.mk' x\u03c4s nd) \u0394 \u2227\n    \u2200 \u03c4 \u2208 \u0394.values, \u0393.sized \u03c4,\n  { rcases this with \u27e8nd, \u0394, h\u2081, h\u2082\u27e9,\n    exact \u27e8nd, \u0394, h\u2081.imp (\u03bb _ _ _, eval_ty.weak), \u03bb \u03c4 h, (h\u2082 \u03c4 h).weak\u27e9 },\n  rcases m with rfl | m,\n  { exact sdecl_ok1 g },\n  { exact IH m }\nend\n\ntheorem get_sdef_ex_iff {\u0393 : ast} (ok : \u0393.okind) {s} :\n  (\u2203 sd, get_sdef \u0393 s sd) \u2194 \u2203 body, gdecl.sdecl s (some body) \u2208 \u0393 :=\nbegin\n  split,\n  { rintro \u27e8sd, _, x\u03c4s, _, _, _, m, h\u27e9, exact \u27e8_, m\u27e9 },\n  { rintro \u27e8x\u03c4s, m\u27e9,\n    rcases sdecl_ok_of_mem ok m with \u27e8nd, \u0394, h\u2081, h\u2082\u27e9,\n    exact \u27e8_, m, h\u2081\u27e9 }\nend\n\ntheorem get_sdef_pairwise {\u0393 : ast} (ok : \u0393.okind) {s} :\n  \u0393.pairwise (\u03bb d\u2081 d\u2082, \u2200 x\u03c4s\u2081 x\u03c4s\u2082,\n    d\u2081 = sdecl s (some x\u03c4s\u2081) \u2192 d\u2082 = sdecl s (some x\u03c4s\u2082) \u2192 false) :=\nbegin\n  induction ok with d \u0393 g ok IH; constructor,\n  { rintro _ h x\u03c4s\u2081 x\u03c4s\u2082 rfl rfl,\n    rcases (get_sdef_ex_iff ok).2 \u27e8_, h\u27e9 with \u27e8sd, h'\u27e9,\n    cases g, cases g_a _ h' },\n  { exact IH }\nend\n\ntheorem get_sdef_determ {\u0393 : ast} (ok : \u0393.okind) {s sd\u2081 sd\u2082}\n  (h\u2081 : get_sdef \u0393 s sd\u2081) (h\u2082 : get_sdef \u0393 s sd\u2082) : sd\u2081 = sd\u2082 :=\nbegin\n  have : \u2200 (d\u2081 \u2208 \u0393) (d\u2082 \u2208 \u0393) x\u03c4s\u2081 x\u03c4s\u2082,\n    d\u2081 = sdecl s (some x\u03c4s\u2081) \u2192 d\u2082 = sdecl s (some x\u03c4s\u2082) \u2192 x\u03c4s\u2081 = x\u03c4s\u2082,\n  { refine list.forall_of_forall_of_pairwise _ _ ((get_sdef_pairwise ok).imp _),\n    { exact \u03bb x y H x\u03c4s\u2081 x\u03c4s\u2082 h\u2081 h\u2082, (H _ _ h\u2082 h\u2081).symm },\n    { rintro _ _ _ _ rfl \u27e8\u27e9, refl }, swap,\n    { rintro a b H _ _ h\u2081 h\u2082, cases H _ _ h\u2081 h\u2082 } },\n  cases h\u2081, cases h\u2082,\n  cases this _ h\u2081_a _ h\u2082_a _ _ rfl rfl,\n  exact ast.eval_ty.determ_alist ok h\u2081_a_1 h\u2082_a_1\nend\n\ninstance is_sdecl (s d) : decidable (\u2203 body, d = gdecl.sdecl s (some body)) :=\nby rcases d with _|_|\u27e8_, _|_\u27e9;\n   try { apply is_false, rintro \u27e8body, h\u27e9, cases h, done };\n   { simp, apply_instance }\n\ninstance sdecl_mem (\u0393 : ast) (s) : decidable (\u2203 body, gdecl.sdecl s (some body) \u2208 \u0393) :=\ndecidable_of_iff' (\u2203 d \u2208 \u0393, \u2203 body, d = gdecl.sdecl s (some body))\n  \u27e8by rintro \u27e8x, h\u27e9; exact \u27e8_, h, x, rfl\u27e9,\n   by rintro \u27e8_, h, x, rfl\u27e9; exact \u27e8x, h\u27e9\u27e9\n\ndef get_sdef_dec {\u0393 : ast} (ok : \u0393.okind) {s} : decidable (\u2203 sd, get_sdef \u0393 s sd) :=\ndecidable_of_iff' _ (get_sdef_ex_iff ok)\n\ntheorem get_body_ok' {\u0393 : ast} (ok : \u0393.okind) {f \u03c4 \u0394 s} (h : \u0393.get_body f \u03c4 \u0394 s) :\n  stmt.ok \u0393 \u03c4 \u0394 s \u2227 (stmt.returns s \u2228 \u03c4 = none) :=\nbegin\n  cases h,\n  cases fdecl_ok_of_mem ok h_a,\n  have : option.forall\u2082 (eval_ty \u0393) h_\u03c4 ret' := a_1.imp (\u03bb _ _, and.left),\n  cases ast.eval_ty.determ_opt ok h_a_2 this,\n  have : alist.forall\u2082 (\u03bb _, eval_ty \u0393) (alist.mk' h_x\u03c4s h_nd) \u0394_1 :=\n    a.imp (\u03bb _ _ _, and.left),\n  cases ast.eval_ty.determ_alist ok h_a_1 this,\n  refine (a_2 _ rfl).2.imp_right (or.imp_right _),\n  rintro rfl, cases a_1, refl\nend\n\ntheorem get_body_ok {\u0393 : ast} (ok : \u0393.okind) {f \u03c4 \u0394 s}\n  (h : \u0393.get_body f \u03c4 \u0394 s) : stmt.ok \u0393 \u03c4 \u0394 s :=\n(get_body_ok' ok h).1\n\ntheorem vars_ty.ok.mem {\u0394 \u03c3} (\u03c3ok : vars_ty.ok \u0394 \u03c3) {x} (h : x \u2208 \u03c3) : x \u2208 \u0394 :=\nlet \u27e8\u03c4, h\u27e9 := finmap.exists_mem_lookup_iff.2 h,\n    \u27e8v, t, h\u27e9 := \u03c3ok _ _ h in alist.exists_mem_lookup_iff.1 \u27e8v, t\u27e9\n\ntheorem vars_ty.ok.subset {\u0394 \u03c3} (\u03c3ok : vars_ty.ok \u0394 \u03c3) : \u03c3.keys \u2286 \u0394.keys.to_finset :=\n\u03bb x h, list.mem_to_finset.2 $ alist.mem_keys.2 $ \u03c3ok.mem $ finmap.mem_keys.1 h\n\ntheorem vars_ty.ok.weak {\u0394 \u03c3 x \u03c4} (h) (\u03c3ok : vars_ty.ok \u0394 \u03c3) :\n  vars_ty.ok (\u0394.cons x \u03c4 h) \u03c3 :=\n\u03bb x' \u03c4' h, let \u27e8t, m, h\u27e9 := \u03c3ok _ _ h in\n  \u27e8t, alist.lookup_cons_of_lookup m, h\u27e9\n\ntheorem vars_ty.ok.insert {\u0394 \u03c3 x t \u03c4}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3) (hn : x \u2209 \u03c3) (h\u2081 : t \u2208 alist.lookup x \u0394)\n  (h\u2082 : vtype.of_ty (exp.type.reg t) \u03c4) : vars_ty.ok \u0394 (\u03c3.insert x \u03c4) :=\n\u03bb x' \u03c4' h, begin\n  rcases (finmap.lookup_insert_of_neg hn).1 h with \u27e8\u27e8\u27e9\u27e9 | h,\n  exacts [\u27e8_, h\u2081, h\u2082\u27e9, \u03c3ok _ _ h]\nend\n\ntheorem vars_ty.ok.erase {\u0394 \u03c3 x t h}\n  (\u03c3ok : vars_ty.ok (alist.cons \u0394 x t h) \u03c3) : vars_ty.ok \u0394 (\u03c3.erase x) :=\n\u03bb x' \u03c4' h, begin\n  rcases finmap.lookup_erase'.1 h with \u27e8ne, h\u27e9,\n  rcases \u03c3ok _ _ h with \u27e8t', m, t\u03c4'\u27e9,\n  rcases alist.lookup_cons_iff.1 m with \u27e8\u27e8\u27e9\u27e9 | m, {cases ne rfl},\n  exact \u27e8t', m, t\u03c4'\u27e9\nend\n\ntheorem vars_ty.ok.ok_of_mem {\u0394 \u03c3 x t \u03c4}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3) (h\u2081 : \u03c4 \u2208 \u03c3.lookup x) (h\u2082 : t \u2208 \u0394.lookup x) : vtype.of_ty (exp.type.reg t) \u03c4 :=\nlet \u27e8v', m, h\u27e9 := \u03c3ok _ _ h\u2081 in option.mem_unique m h\u2082 \u25b8 h\n\ntheorem vars.ok.mem {\u0393 E \u03c3 \u03b7} (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3) {x} (h : x \u2208 \u03c3) : x \u2208 \u03b7 :=\nlet \u27e8\u03c4, h\u27e9 := finmap.exists_mem_lookup_iff.2 h,\n    \u27e8v, t, h\u27e9 := \u03b7ok _ _ h in finmap.exists_mem_lookup_iff.1 \u27e8v, t\u27e9\n\ntheorem vars.ok.ok_of_mem {\u0393 E \u03c3 \u03b7} (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3)\n  {x \u03c4} (h\u2081 : \u03c4 \u2208 \u03c3.lookup x) {v} (h\u2082 : v \u2208 \u03b7.lookup x) : value.ok \u0393 E v \u03c4 :=\nlet \u27e8v', m, h\u27e9 := \u03b7ok _ _ h\u2081 in option.mem_unique m h\u2082 \u25b8 h\n\ntheorem vars.ok.insert {\u0393 E \u03c3 \u03b7 x v \u03c4} (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3)\n  (hn : x \u2209 \u03b7) (vok : value.ok \u0393 E v \u03c4) :\n  vars.ok \u0393 E (\u03b7.insert x v) (\u03c3.insert x \u03c4) :=\n\u03bb x' \u03c4' h, begin\n  rcases (finmap.lookup_insert_of_neg (mt \u03b7ok.mem hn)).1 h with \u27e8\u27e8\u27e9\u27e9 | h,\n  { exact \u27e8_, finmap.lookup_insert_self hn, vok\u27e9 },\n  { rcases \u03b7ok _ _ h with \u27e8v, v\u03b7, h\u27e9,\n    exact \u27e8v, (finmap.lookup_insert_of_neg hn).2 (or.inr v\u03b7), h\u27e9 }\nend\n\ntheorem vars.ok.erase {\u0393 E \u03c3 \u03b7 x}\n  (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3) : vars.ok \u0393 E \u03b7 (\u03c3.erase x) :=\n\u03bb x' \u03c4' h, \u03b7ok _ _ (finmap.lookup_erase'.1 h).2\n\ntheorem heap_le_nth {E E' : heap_ty} (EE : E \u2264 E')\n  {i \u03c4} (h : \u03c4 \u2208 E.nth i) : \u03c4 \u2208 E'.nth i :=\nbegin\n  rcases EE with \u27e8l, rfl\u27e9,\n  induction E with \u03c4' E IH generalizing i, {cases h},\n  cases i; [{cases h, exact rfl}, exact IH h]\nend\n\ntheorem value.ok.mono {\u0393 E E' v \u03c4} (EE : E \u2264 E')\n  (h : value.ok \u0393 E v \u03c4) : value.ok \u0393 E' v \u03c4 :=\nbegin\n  induction h; constructor; try {assumption},\n  { exact \u03bb x h, heap_le_nth EE (h_a_1 x h) },\n  { exact \u03bb x h, (h_a_1 x h).imp (\u03bb _, heap_le_nth EE) }\nend\n\ntheorem vars.ok.mono {\u0393 E E' \u03c3 \u03b7} (EE : E \u2264 E')\n  (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3) : vars.ok \u0393 E' \u03b7 \u03c3 :=\n\u03bb i \u03c4 h, let \u27e8t, h\u2081, h\u2082\u27e9 := \u03b7ok i \u03c4 h in \u27e8t, h\u2081, h\u2082.mono EE\u27e9\n\ntheorem addr.ok.mono {\u0393 E E' \u03c3 a \u03c4} (EE : E \u2264 E')\n (aok : addr.ok \u0393 E \u03c3 a \u03c4) : addr.ok \u0393 E' \u03c3 a \u03c4 :=\nbegin\n  induction aok; constructor; try {assumption},\n  exact heap_le_nth EE aok_a\nend\n\ntheorem addr_opt.ok.mono {\u0393 E E' \u03c3} (EE : E \u2264 E') :\n  \u2200 {a \u03c4}, addr_opt.ok \u0393 E \u03c3 a \u03c4 \u2192 addr_opt.ok \u0393 E' \u03c3 a \u03c4\n| none     \u03c4 h := trivial\n| (some a) \u03c4 h := addr.ok.mono EE h\n\ntheorem cont.ok.mono {\u0393 E E' \u03c3 \u0394 ret \u03b4 \u03b1 \u03c4 K} (EE : E \u2264 E')\n  (Kok : @cont.ok \u0393 E \u03c3 \u0394 ret \u03b4 \u03b1 \u03c4 K) : cont.ok \u0393 E' \u03c3 \u0394 ret \u03b4 \u03c4 K :=\nby induction Kok; constructor; {\n  assumption <|>\n  exact addr_opt.ok.mono EE (by assumption) <|>\n  exact value.ok.mono EE (by assumption) <|>\n  exact \u03bb a h, (Kok_a _ h).imp (\u03bb _, addr.ok.mono EE) }\n\ntheorem stack.ok.mono {\u0393 E E' \u03c3s S ret} (EE : E \u2264 E')\n  (Sok : stack.ok \u0393 E \u03c3s S ret) : stack.ok \u0393 E' \u03c3s S ret :=\nby induction Sok; constructor; {\n  assumption <|>\n  exact vars.ok.mono EE (by assumption) <|>\n  exact cont.ok.mono EE (by assumption) }\n\ntheorem heap_ty.le_add (E : heap_ty) (\u03c4) : E \u2264 E.add \u03c4 := \u27e8_, rfl\u27e9\n\ntheorem heap.ok.add {\u0393 E H v \u03c4}\n  (Eok : heap.ok \u0393 H E) (vok : value.ok \u0393 (E.add \u03c4) v \u03c4) :\n  heap.ok \u0393 (H ++ [v]) (E.add \u03c4) :=\nlist.forall\u2082_concat.2 \u27e8Eok.imp (\u03bb _ _, value.ok.mono (E.le_add _)), vok\u27e9\n\ntheorem env.ok.empty {\u0393} : env.ok \u0393 \u2205 \u2205 vtype.int :=\n\u27e8by rintro _ _ \u27e8\u27e9, list.forall\u2082.nil, by rintro _ _ \u27e8\u27e9, stack.ok.nil\u27e9\n\nnamespace vtype\n\nopen ast.exp.type\ndef of_ty_fn : \u2200 \u03c4, {v\u03c4 // of_ty \u03c4 v\u03c4}\n| void := \u27e8_, of_ty.void\u27e9\n| (reg type.int) := \u27e8_, of_ty.int\u27e9\n| (reg type.bool) := \u27e8_, of_ty.bool\u27e9\n| (reg (type.ref \u03c4)) := let f := of_ty_fn (reg \u03c4) in \u27e8_, of_ty.ref f.2\u27e9\n| (reg (type.arr \u03c4)) := let f := of_ty_fn (reg \u03c4) in \u27e8_, of_ty.arr f.2\u27e9\n| (reg (type.struct s)) := \u27e8_, of_ty.struct\u27e9\n| (ls []) := \u27e8_, of_ty.nil\u27e9\n| (ls (\u03c4 :: \u03c4s)) :=\n  let f\u2081 := of_ty_fn (reg \u03c4),\n      f\u2082 := of_ty_fn (ls \u03c4s) in\n  \u27e8_, of_ty.cons f\u2081.2 f\u2082.2\u27e9\n\ntheorem of_ty_eq : \u2200 {\u03c4 v\u03c4}, of_ty \u03c4 v\u03c4 \u2192 v\u03c4 = (of_ty_fn \u03c4).1\n| void                  v\u03c4 h := by cases h; refl\n| (reg type.int)        v\u03c4 h := by cases h; refl\n| (reg type.bool)       v\u03c4 h := by cases h; refl\n| (reg (type.ref \u03c4))    v\u03c4 h := by cases h; rw [of_ty_eq h_a, of_ty_fn]\n| (reg (type.arr \u03c4))    v\u03c4 h := by cases h; rw [of_ty_eq h_a, of_ty_fn]\n| (reg (type.struct s)) v\u03c4 h := by cases h; refl\n| (ls [])               v\u03c4 h := by cases h; refl\n| (ls (\u03c4 :: \u03c4s))        v\u03c4 h := by cases h; rw [of_ty_eq h_a, of_ty_eq h_a_1, of_ty_fn]\n\ntheorem of_ty_determ {\u03c4 v\u03c4\u2081 v\u03c4\u2082} (h\u2081 : of_ty \u03c4 v\u03c4\u2081) (h\u2082 : of_ty \u03c4 v\u03c4\u2082) : v\u03c4\u2081 = v\u03c4\u2082 :=\n(of_ty_eq h\u2081).trans (of_ty_eq h\u2082).symm\n\n@[simp] theorem of_map_cons {vs x v h} :\n  of_map (alist.cons vs x v h) = cons (named x v) (of_map vs) :=\nalist.rec'_cons _ _ _ _\n\ntheorem of_ty_alist (sd) :\n {\u03c4s // alist.forall\u2082 (\u03bb (_x : ident) (t : type), vtype.of_ty (exp.type.reg t)) sd \u03c4s} :=\n\u27e8alist.map (\u03bb _ \u03c4, (vtype.of_ty_fn (exp.type.reg \u03c4)).1) sd,\n alist.forall\u2082_map_right_iff.2 (alist.forall\u2082_same $ \u03bb _ \u03c4 _, (vtype.of_ty_fn _).2)\u27e9\n\nend vtype\n\nnamespace value\n\ntheorem ok.null {\u0393 E \u03c4} : value.ok \u0393 E (value.ref none) (vtype.ref \u03c4) :=\nvalue.ok.ref $ by rintro _ \u27e8\u27e9\n\ntheorem ok.null_arr {\u0393 E \u03c4} : value.ok \u0393 E (value.ref none) (vtype.refarr \u03c4) :=\nvalue.ok.refarr $ by rintro _ \u27e8\u27e9\n\ntheorem is_nth.ok {\u0393 E i n v v' \u03c4}\n  (vok : ok \u0393 E v (vtype.arr' \u03c4 n)) (lt : i < n)\n  (h : is_nth i v v') : ok \u0393 E v' \u03c4 :=\nbegin\n  induction h generalizing n,\n  { cases n, {cases lt},\n    cases vok, exact vok_a },\n  { cases n, {cases lt},\n    cases vok, exact h_ih vok_a_1 (nat.lt_of_succ_lt_succ lt) }\nend\n\ndef ok_type_or_sdef (\u0393 E) (v : value) : type \u2295 sdef \u2192 Prop\n| (sum.inl \u03c4) := \u2203 \u03c4', vtype.of_ty (exp.type.reg \u03c4) \u03c4' \u2227 value.ok \u0393 E v \u03c4'\n| (sum.inr sd) := \u2203 vs, v = of_map vs \u2227\n  alist.forall\u2082 (\u03bb _ \u03c4 v', \u2203 v\u03c4, vtype.of_ty (exp.type.reg \u03c4) v\u03c4 \u2227 value.ok \u0393 E v' v\u03c4) sd vs\n\ntheorem default.weak {\u0393 d sd v} (h : default \u0393 sd v) : default (d :: \u0393) sd v :=\nby induction h; constructor; try {assumption}; exact h_a.weak\n\n@[simp] theorem of_map_cons {vs x v} (h) :\n  of_map (alist.cons vs x v h) = cons (named x v) (of_map vs) :=\nalist.rec'_cons _ _ _ _\n\ntheorem of_map_inj {vs} : \u2200 {vs'}, of_map vs = of_map vs' \u2192 vs = vs' :=\nbegin\n  refine alist.rec' _ (\u03bb vs x v h IH, _) vs; intro vs';\n    refine alist.rec' _ (\u03bb vs' y v' h' IH', _) vs'; intro e,\n  {refl}, {cases e}, {cases e},\n  rw [of_map_cons, of_map_cons] at e,\n  injection e, cases h_1, cases IH h_2, refl\nend\n\ntheorem of_map_ok {\u0393 E v \u03c4s} :\n  ok \u0393 E v (vtype.of_map \u03c4s) \u2194\n  \u2203 vs, v = of_map vs \u2227 alist.forall\u2082 (\u03bb _, ok \u0393 E) vs \u03c4s :=\nbegin\n  refine alist.rec' _ (\u03bb \u03c4s x \u03c4 h IH, _) \u03c4s v; intro vs; split,\n  { rintro \u27e8\u27e9, exact \u27e8\u2205, rfl, by constructor\u27e9 },\n  { rintro \u27e8\u27e8vs, _\u27e9, rfl, \u27e8\u27e9\u27e9, constructor },\n  { intro H, rw vtype.of_map_cons at H,\n    generalize_hyp e\u2082 : vtype.of_map \u03c4s = \u03c4' at H,\n    cases H, cases H_a, subst \u03c4',\n    rcases (IH _).1 H_a_1 with \u27e8vs, rfl, al\u27e9,\n    exact \u27e8_, (of_map_cons (mt al.mem_iff.1 h)).symm,\n      alist.forall\u2082_cons.2 \u27e8H_a_a, al\u27e9\u27e9 },\n  { rintro \u27e8vs, rfl, H\u27e9,\n    generalize_hyp e : alist.cons \u03c4s x \u03c4 h = \u03c4s' at H, revert e,\n    refine alist.forall\u2082.induction H (by rintro \u27e8\u27e9) _,\n    intros vs \u03c4s x v \u03c4 h\u2081 h\u2082 vok h _ e,\n    rcases alist.cons_inj e with \u27e8\u27e8\u27e9, rfl\u27e9,\n    rw [vtype.of_map_cons, of_map_cons],\n    exact ok.cons (ok.named vok) ((IH _).2 \u27e8_, rfl, h\u27e9) },\nend\n\nend value\n\nnamespace addr\n\ntheorem ok.ref_opt {\u0393 E \u03c3 n \u03c4}\n  (h : value.ok \u0393 E (value.ref n) (vtype.ref \u03c4)) :\n  addr_opt.ok \u0393 E \u03c3 (addr.ref <$> n) \u03c4 :=\nby cases h; cases n; [trivial, exact addr.ok.ref (h_a_1 _ rfl)]\n\ntheorem ok.refarr_opt {\u0393 E \u03c3 n \u03c4}\n  (h : value.ok \u0393 E (value.ref n) (vtype.refarr \u03c4))\n  (a \u2208 addr.ref <$> n) : \u2203 i, addr.ok \u0393 E \u03c3 a (vtype.arr \u03c4 i) :=\nbegin\n  cases n; cases H; cases h,\n  exact (h_a_1 _ rfl).imp (\u03bb _, addr.ok.ref)\nend\n\ntheorem at_head.ok {\u0393 E \u03c4 \u03c4s} {R : value \u2192 value \u2192 Prop}\n  (Rok : \u2200 x, value.ok \u0393 E x \u03c4 \u2192 \u2200 y, R x y \u2192 value.ok \u0393 E y \u03c4)\n  (x) (xok : value.ok \u0393 E x (vtype.cons \u03c4 \u03c4s)) (y)\n  (h : value.at_head R x y) : value.ok \u0393 E y (vtype.cons \u03c4 \u03c4s) :=\nbegin\n  rcases xok with _|_|_|_|\u27e8x, vs, _, _, xok, xsok\u27e9,\n  rcases h with \u27e8x, y, vs, r\u27e9,\n  exact value.ok.cons (Rok _ xok _ r) xsok\nend\n\ntheorem at_tail.ok {\u0393 E \u03c4 \u03c4s} {R : value \u2192 value \u2192 Prop}\n  (Rok : \u2200 x, value.ok \u0393 E x \u03c4s \u2192 \u2200 y, R x y \u2192 value.ok \u0393 E y \u03c4s)\n  (x) (xok : value.ok \u0393 E x (vtype.cons \u03c4 \u03c4s)) (y)\n  (h : value.at_tail R x y) : value.ok \u0393 E y (vtype.cons \u03c4 \u03c4s) :=\nbegin\n  rcases xok with _|_|_|_|\u27e8x, vs, _, _, xok, xsok\u27e9,\n  rcases h with \u27e8x, y, vs, r\u27e9,\n  exact value.ok.cons xok (Rok _ xsok _ r)\nend\n\ntheorem at_nth'.ok {\u0393 E \u03c4 i n} {R : value \u2192 value \u2192 Prop}\n  (Rok : \u2200 x, value.ok \u0393 E x \u03c4 \u2192 \u2200 y, R x y \u2192 value.ok \u0393 E y \u03c4)\n  (lt : i < n) (x) (xok : value.ok \u0393 E x (vtype.arr' \u03c4 n)) (y)\n  (r : value.at_nth' R i x y) : value.ok \u0393 E y (vtype.arr' \u03c4 n) :=\nbegin\n  induction i generalizing n lt x xok y,\n  { cases n, {cases lt},\n    exact at_head.ok Rok _ xok _ r },\n  { cases n, {cases lt},\n    refine at_tail.ok _ _ xok _ r,\n    exact i_ih (nat.lt_of_succ_lt_succ lt) }\nend\n\ntheorem at_nth.ok {\u0393 E \u03c4 i n} {R : value \u2192 value \u2192 Prop}\n  (Rok : \u2200 x, value.ok \u0393 E x \u03c4 \u2192 \u2200 y, R x y \u2192 value.ok \u0393 E y \u03c4)\n  (lt : i < n) (x) (xok : value.ok \u0393 E x (vtype.arr \u03c4 n)) (y)\n  (h : value.at_nth R i x y) : value.ok \u0393 E y (vtype.arr \u03c4 n) :=\nbegin\n  rcases xok with _|_|_|_|_|\u27e8x,_,n,xok'\u27e9,\n  rcases h with \u27e8_, y, _, lt, r\u27e9,\n  exact value.ok.arr (at_nth'.ok Rok lt _ xok' _ r)\nend\n\ntheorem at_field.ok {\u0393 : ast} (ok : \u0393.okind) {E \u03c4 f s} {R : value \u2192 value \u2192 Prop}\n  (Rok : \u2200 x, value.ok \u0393 E x \u03c4 \u2192 \u2200 y, R x y \u2192 value.ok \u0393 E y \u03c4)\n  {sd} (hd : \u0393.get_sdef s sd)\n  {t} (ht : t \u2208 sd.lookup f) (t\u03c4 : vtype.of_ty (exp.type.reg t) \u03c4)\n  (x) (xok : value.ok \u0393 E x (vtype.struct s)) (y)\n  (h : value.at_field R f x y) : value.ok \u0393 E y (vtype.struct s) :=\nbegin\n  rcases xok with _|_|_|_|_|_|_|_|\u27e8_, vs, _, al, e\u27e9,\n  cases h, cases value.of_map_inj (e.symm.trans h_a_2),\n  refine value.ok.struct (\u03bb sd' \u03c4s hd' h, _) h_a_3,\n  cases get_sdef_determ ok hd hd',\n  rcases value.of_map_ok.1 (al sd \u03c4s hd h) with \u27e8vs', e, al'\u27e9,\n  cases value.of_map_inj e,\n  rcases alist.forall\u2082.rel_of_lookup_right h ht with \u27e8\u03c4', h', t\u03c4'\u27e9,\n  cases vtype.of_ty_determ t\u03c4 t\u03c4',\n  have al\u2081 := list.forall\u2082_and_right.2 \u27e8(alist.replace_forall\u2082 _ _ _).flip, \u03bb _, id\u27e9,\n  have al\u2082 := list.forall\u2082_and_right.2 \u27e8al', \u03bb _, id\u27e9,\n  refine value.of_map_ok.2 \u27e8_, rfl, list.forall\u2082.mp_trans _ al\u2081 al\u2082\u27e9,\n  rintro _ _ _ \u27e8\u27e8x, v', v, h\u27e9, m\u2081\u27e9 \u27e8\u27e8_, _, \u03c4', vok\u27e9, m\u2082\u27e9, refine \u27e8_\u27e9,\n  cases h with _ _ _ h,\n  { cases option.mem_unique h_a_1 (alist.mem_lookup_iff.2 m\u2081),\n    cases option.mem_unique h' (alist.mem_lookup_iff.2 m\u2082),\n    exact Rok _ vok _ h_a },\n  { exact vok }\nend\n\ntheorem eq.ok {\u0393 E \u03c4 v} (vok : value.ok \u0393 E v \u03c4) :\n  \u2200 x, value.ok \u0393 E x \u03c4 \u2192 \u2200 y, v = y \u2192 value.ok \u0393 E y \u03c4\n| _ _ _ rfl := vok\n\ntheorem get.ok {\u0393 E \u0394 H \u03c3 \u03b7}\n  (\u03c3ok : vars_ty.ok \u0394 \u03c3) (Hok : heap.ok \u0393 H E) (\u03b7ok : vars.ok \u0393 E \u03b7 \u03c3)\n  {v a \u03c4} (aok : addr.ok \u0393 E \u03c3 a \u03c4) (h : get H \u03b7 a v) : value.ok \u0393 E v \u03c4 :=\nbegin\n  induction h generalizing \u03c4,\n  case c0.addr.get.ref : n v h {\n    cases aok, exact list.forall\u2082.nth Hok h aok_a },\n  case c0.addr.get.var : n v h {\n    cases aok, exact \u03b7ok.ok_of_mem aok_a h },\n  case c0.addr.get.head : a v vs h IH {\n    rcases aok with _|_|\u27e8_, _, \u03c4s, aok\u27e9,\n    cases IH aok, exact a_1 },\n  case c0.addr.get.tail : a v vs h IH {\n    rcases aok with _|_|_|\u27e8_, \u03c4\u2081, _, aok\u27e9,\n    cases IH aok, exact a_2 },\n  case c0.addr.get.nth : a i n v v' h h' IH {\n    rcases aok with _|_|_|_|\u27e8a, _, n', d, lt, aok\u27e9,\n    rcases IH aok with _|_|_|_|_|\u27e8_, _, _, vok\u27e9,\n    exact h'.ok vok lt },\n  case c0.addr.get.field : a f vs v h hf IH {\n    rcases aok with _|_|_|_|_|\u27e8_, s, _, t, sd, _, hsd, m, t\u03c4, aok\u27e9,\n    have := IH aok, generalize_hyp e : value.of_map vs = v' at this,\n    cases this, subst v', cases value.of_map_inj this_a_1,\n    cases vtype.of_ty_alist sd with \u03c4s s\u03c4,\n    rcases value.of_map_ok.1 (this_a _ _ hsd s\u03c4) with \u27e8vs', e, h\u27e9,\n    cases value.of_map_inj e,\n    rcases s\u03c4.rel_of_lookup_right m with \u27e8\u03c4', m', t\u03c4'\u27e9,\n    cases vtype.of_ty_determ t\u03c4 t\u03c4',\n    exact h.rel_of_lookup hf m' }\nend\n\nend addr\n\ntheorem stmt_list.ok.eq_none {\u0393 \u0394 \u03b4 ret}\n  (Kok : stmt_list.ok \u0393 ret \u0394 \u03b4 []) : ret = none :=\nbegin\n  generalize e : ([]:list stmt) = ss, rw e at Kok,\n  induction Kok; cases e; [exact Kok_a, exact Kok_ih rfl]\nend\n\nend c0\n", "meta": {"author": "digama0", "repo": "vc0", "sha": "b8b192c8c139e0b5a25a7284b93ed53cdf7fd7a5", "save_path": "github-repos/lean/digama0-vc0", "path": "github-repos/lean/digama0-vc0/vc0-b8b192c8c139e0b5a25a7284b93ed53cdf7fd7a5/src/vc0/basic.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7279754489059774, "lm_q2_score": 0.6297746074044134, "lm_q1q2_score": 0.45846045253481355}}
{"text": "constants p q : Prop\n\ntheorem t1 : p \u2192 q \u2192 p := \u03bb hp : p, \u03bb 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 {\u03b1 : Type u} {\u03b2 : Type v}\n\nsection map_with_index\n\nlemma map_with_index_core_eq (l : list \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (n : \u2115) :\n  l.map_with_index_core f n = l.map_with_index (\u03bb 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 \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) :\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (start : \u2115) (b : \u03b2)\n  (as : list \u03b1) : \u03b2 :=\nfoldr (uncurry f) b $ enum_from start as\n\ntheorem foldr_with_index_aux_spec_cons (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2)\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (as : list \u03b1) :\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 : \u03b1 \u2192 Prop) [decidable_pred p]\n  (as : list \u03b1) :\n  indexes_values p as = filter (p \u2218 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 : \u03b1 \u2192 Prop) [decidable_pred p]\n  (as : list \u03b1) :\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (start : \u2115) (a : \u03b1)\n  (bs : list \u03b2) : \u03b1 :=\nfoldl (\u03bb a (p : \u2115 \u00d7 \u03b2), f p.fst a p.snd) a $ enum_from start bs\n\ntheorem foldl_with_index_aux_spec_cons (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1)\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (bs : list \u03b2) :\n  foldl_with_index f a bs =\n  foldl (\u03bb a (p : \u2115 \u00d7 \u03b2), 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 \u2192 Type v} [monad m]\n\ntheorem mfoldr_with_index_eq_mfoldr_enum {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 m \u03b2) (b : \u03b2) (as : list \u03b1) :\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] {\u03b1 \u03b2}\n  (f : \u2115 \u2192 \u03b2 \u2192 \u03b1 \u2192 m \u03b2) (b : \u03b2) (as : list \u03b1) :\n  mfoldl_with_index f b as =\n    mfoldl (\u03bb b (p : \u2115 \u00d7 \u03b1), 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 \u2192 Type v} [applicative m]\n\n/-- Specification of `mmap_with_index_aux`. -/\ndef mmap_with_index_aux_spec {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (start : \u2115) (as : list \u03b1) :\n  m (list \u03b2) :=\nlist.traverse (uncurry f) $ enum_from start as\n-- Note: `traverse` the class method would require a less universe-polymorphic\n-- `m : Type u \u2192 Type u`.\n\ntheorem mmap_with_index_aux_spec_cons {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (start : \u2115)\n  (a : \u03b1) (as : list \u03b1) :\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 {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2)\n  (start : \u2115) (as : list \u03b1) :\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 {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (as : list \u03b1) :\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 \u2192 Type v} [applicative m] [is_lawful_applicative m]\n\ntheorem mmap_with_index'_aux_eq_mmap_with_index_aux {\u03b1} (f : \u2115 \u2192 \u03b1 \u2192 m punit)\n  (start : \u2115) (as : list \u03b1) :\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 {\u03b1} (f : \u2115 \u2192 \u03b1 \u2192 m punit) (as : list \u03b1) :\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\u207b\u00b9` 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 [] : \u2200 a b : A, \u2203 c : A, a * c = b \u2228 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\u02e3 K)\n\ninstance : inhabited (value_group A K) := \u27e8quotient.mk' 0\u27e9\n\ninstance : has_le (value_group A K) := has_le.mk $ \u03bb x y,\nquotient.lift_on\u2082' x y (\u03bb a b, \u2203 c : A, c \u2022 b = a)\nbegin\n  rintros _ _ a b \u27e8c,rfl\u27e9 \u27e8d,rfl\u27e9, ext,\n  split,\n  { rintros \u27e8e,he\u27e9, use ((c\u207b\u00b9 : A\u02e3) * e * d),\n    apply_fun (\u03bb t, c\u207b\u00b9 \u2022 t) at he,\n    simpa [mul_smul] using he },\n  { rintros \u27e8e,he\u27e9, dsimp,\n    use (d\u207b\u00b9 : A\u02e3) * c * e,\n    erw [\u2190 he, \u2190 mul_smul, \u2190 mul_smul],\n    congr' 1,\n    rw mul_comm,\n    simp only [\u2190 mul_assoc, \u2190 units.coe_mul, mul_inv_self, one_mul] }\nend\n\ninstance : has_zero (value_group A K) := \u27e8quotient.mk' 0\u27e9\ninstance : has_one (value_group A K) := \u27e8quotient.mk' 1\u27e9\n\ninstance : has_mul (value_group A K) := has_mul.mk $ \u03bb x y,\nquotient.lift_on\u2082' x y (\u03bb a b, quotient.mk' $ a * b)\nbegin\n  rintros _ _ a b \u27e8c,rfl\u27e9 \u27e8d,rfl\u27e9,\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 $ \u03bb x,\nquotient.lift_on' x (\u03bb a, quotient.mk' a\u207b\u00b9)\nbegin\n  rintros _ a \u27e8b,rfl\u27e9,\n  apply quotient.sound',\n  use b\u207b\u00b9,\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 \u2264 b \u2228 b \u2264 a :=\nbegin\n  rcases a with \u27e8a\u27e9, rcases b with \u27e8b\u27e9,\n  obtain \u27e8xa,ya,hya,rfl\u27e9 : \u2203 (a b : A), _ := is_fraction_ring.div_surjective a,\n  obtain \u27e8xb,yb,hyb,rfl\u27e9 : \u2203 (a b : A), _ := is_fraction_ring.div_surjective b,\n  have : (algebra_map A K) ya \u2260 0 :=\n    is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors hya,\n  have : (algebra_map A K) yb \u2260 0 :=\n    is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors hyb,\n  obtain \u27e8c,(h|h)\u27e9 := valuation_ring.cond (xa * yb) (xb * ya),\n  { right,\n    use c,\n    rw algebra.smul_def,\n    field_simp,\n    simp only [\u2190 ring_hom.map_mul, \u2190 h], congr' 1, ring },\n  { left,\n    use c,\n    rw algebra.smul_def,\n    field_simp,\n    simp only [\u2190 ring_hom.map_mul, \u2190 h], congr' 1, ring }\nend\n\nnoncomputable\ninstance : linear_ordered_comm_group_with_zero (value_group A K) :=\n{ le_refl := by { rintro \u27e8\u27e9, use 1, rw one_smul },\n  le_trans := by { rintros \u27e8a\u27e9 \u27e8b\u27e9 \u27e8c\u27e9 \u27e8e,rfl\u27e9 \u27e8f,rfl\u27e9, use (e * f), rw mul_smul },\n  le_antisymm := begin\n    rintros \u27e8a\u27e9 \u27e8b\u27e9 \u27e8e,rfl\u27e9 \u27e8f,hf\u27e9,\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 [\u2190 mul_smul, algebra.smul_def] at hf,\n      nth_rewrite 1 \u2190 one_mul b at hf,\n      rw \u2190 (algebra_map A K).map_one at hf,\n      exact is_fraction_ring.injective _ _ (mul_right_cancel\u2080 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 \u27e8a\u27e9 \u27e8b\u27e9 \u27e8c\u27e9, apply quotient.sound', rw mul_assoc, apply setoid.refl' },\n  one_mul := by { rintros \u27e8a\u27e9, apply quotient.sound', rw one_mul, apply setoid.refl' },\n  mul_one := by { rintros \u27e8a\u27e9, apply quotient.sound', rw mul_one, apply setoid.refl' },\n  mul_comm := by { rintros \u27e8a\u27e9 \u27e8b\u27e9, apply quotient.sound', rw mul_comm, apply setoid.refl' },\n  mul_le_mul_left := begin\n    rintros \u27e8a\u27e9 \u27e8b\u27e9 \u27e8c,rfl\u27e9 \u27e8d\u27e9,\n    use c, simp only [algebra.smul_def], ring,\n  end,\n  zero_mul := by { rintros \u27e8a\u27e9, apply quotient.sound', rw zero_mul, apply setoid.refl' },\n  mul_zero := by { rintros \u27e8a\u27e9, apply quotient.sound', rw mul_zero, apply setoid.refl' },\n  zero_le_one := \u27e80, by rw zero_smul\u27e9,\n  exists_pair_ne := begin\n    use [0,1],\n    intro c, obtain \u27e8d,hd\u27e9 := quotient.exact' c,\n    apply_fun (\u03bb t, d\u207b\u00b9 \u2022 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 \u27e8a\u27e9 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 \u22a2,\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' := \u03bb _ _, rfl,\n  map_add_le_max' := begin\n    intros a b,\n    obtain \u27e8xa,ya,hya,rfl\u27e9 : \u2203 (a b : A), _ := is_fraction_ring.div_surjective a,\n    obtain \u27e8xb,yb,hyb,rfl\u27e9 : \u2203 (a b : A), _ := is_fraction_ring.div_surjective b,\n    have : (algebra_map A K) ya \u2260 0 :=\n      is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors hya,\n    have : (algebra_map A K) yb \u2260 0 :=\n      is_fraction_ring.to_map_ne_zero_of_mem_non_zero_divisors hyb,\n    obtain \u27e8c,(h|h)\u27e9 := 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 [\u2190 ring_hom.map_mul, \u2190 ring_hom.map_add, \u2190 (algebra_map A K).map_one, \u2190 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 [\u2190 ring_hom.map_mul, \u2190 ring_hom.map_add, \u2190 (algebra_map A K).map_one, \u2190 h],\n      congr' 1, ring }\n  end }\n\nlemma mem_integer_iff (x : K) : x \u2208 (valuation A K).integer \u2194 \u2203 a : A, algebra_map A K a = x :=\nbegin\n  split,\n  { rintros \u27e8c,rfl\u27e9,\n    use c,\n    rw [algebra.smul_def, mul_one] },\n  { rintro \u27e8c,rfl\u27e9,\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 \u2243+* (valuation A K).integer :=\nring_equiv.of_bijective (show A \u2192\u2099+* (valuation A K).integer, from\n{ to_fun := \u03bb a, \u27e8algebra_map A K a, (mem_integer_iff _ _ _).mpr \u27e8a,rfl\u27e9\u27e9,\n  map_mul' := \u03bb _ _, by { ext1, exact (algebra_map A K).map_mul _ _ },\n  map_zero' := by { ext1, exact (algebra_map A K).map_zero },\n  map_add' := \u03bb _ _, by { ext1, exact (algebra_map A K).map_add _ _ } })\nbegin\n  split,\n  { intros x y h,\n    apply_fun (coe : _ \u2192 K) at h,\n    dsimp at h,\n    exact is_fraction_ring.injective _ _ h },\n  { rintros \u27e8a,(ha : a \u2208 (valuation A K).integer)\u27e9,\n    rw mem_integer_iff at ha,\n    obtain \u27e8a,rfl\u27e9 := 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 \u27e8c,(h|h)\u27e9 := 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 ((\u2264) : ideal A \u2192 ideal A \u2192 Prop)] : linear_order (ideal A) :=\n{ le_total := begin\n    intros \u03b1 \u03b2,\n    by_cases h : \u03b1 \u2264 \u03b2, { exact or.inl h },\n    erw not_forall at h,\n    push_neg at h,\n    obtain \u27e8a,h\u2081,h\u2082\u27e9 := h,\n    right,\n    intros b hb,\n    obtain \u27e8c,(h|h)\u27e9 := valuation_ring.cond a b,\n    { rw \u2190 h,\n      exact ideal.mul_mem_right _ _ h\u2081 },\n    { exfalso, apply h\u2082, rw \u2190 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 \u2194 is_total R (\u2223) :=\nbegin\n  classical,\n  refine \u27e8\u03bb H, \u27e8\u03bb a b, _\u27e9, \u03bb H, \u27e8\u03bb a b, _\u27e9\u27e9; resetI,\n  { obtain \u27e8c,rfl|rfl\u27e9 := @@valuation_ring.cond _ _ H a b; simp },\n  { obtain (\u27e8c, rfl\u27e9|\u27e8c, rfl\u27e9) := @is_total.total _ _ H a b; use c; simp }\nend\n\nlemma iff_ideal_total :\n  valuation_ring R \u2194 is_total (ideal R) (\u2264) :=\nbegin\n  classical,\n  refine \u27e8\u03bb _, by exactI \u27e8le_total\u27e9, \u03bb H, iff_dvd_total.mpr \u27e8\u03bb a b, _\u27e9\u27e9,\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 \u2223 y \u2228 y \u2223 x :=\n@@is_total.total _ (iff_dvd_total.mp h) x y\n\nlemma unique_irreducible [valuation_ring R] \u2983p q : R\u2984\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 \u2194 \u2200 x : K, is_localization.is_integer R x \u2228 is_localization.is_integer R x\u207b\u00b9 :=\nbegin\n  split,\n  { introsI H x,\n    obtain \u27e8x : R, y, hy, rfl\u27e9 := 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 \u27e8s, rfl|rfl\u27e9 := valuation_ring.cond x y,\n    { exact or.inr \u27e8s, eq_inv_of_mul_eq_one_left $\n        by rwa [mul_div, div_eq_one_iff_eq, map_mul, mul_comm]\u27e9 },\n    { exact or.inl \u27e8s, by rwa [eq_div_iff, map_mul, mul_comm]\u27e9 } },\n  { intro H,\n    constructor,\n    intros a b,\n    by_cases ha : a = 0, { subst ha, exact \u27e80, or.inr $ mul_zero b\u27e9 },\n    by_cases hb : b = 0, { subst hb, exact \u27e80, or.inl $ mul_zero a\u27e9 },\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 \u27e8c, e\u27e9|\u27e8c, e\u27e9 := H (algebra_map R K a / algebra_map R K b),\n    { rw [eq_div_iff hb, \u2190 map_mul, (is_fraction_ring.injective R K).eq_iff, mul_comm] at e,\n      exact \u27e8c, or.inr e\u27e9 },\n    { rw [inv_div, eq_div_iff ha, \u2190 map_mul,\n        (is_fraction_ring.injective R K).eq_iff, mul_comm c] at e,\n      exact \u27e8c, or.inl e\u27e9 } }\nend\n\nvariable {K}\n\nlemma is_integer_or_is_integer [h : valuation_ring R] (x : K) :\n  is_localization.is_integer R x \u2228 is_localization.is_integer R x\u207b\u00b9 :=\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 \u27e8\u27e8_, rfl\u27e9\u27e9 },\n  { erw sup_eq_left.mpr h, exact \u27e8\u27e8_, rfl\u27e9\u27e9 }\nend\n\nlemma iff_local_bezout_domain :\n  valuation_ring R \u2194 local_ring R \u2227 is_bezout R :=\nbegin\n  classical,\n  refine \u27e8\u03bb H, by exactI \u27e8infer_instance, infer_instance\u27e9, _\u27e9,\n  rintro \u27e8h\u2081, h\u2082\u27e9,\n  resetI,\n  refine iff_dvd_total.mpr \u27e8\u03bb a b, _\u27e9,\n  obtain \u27e8g, e : _ = ideal.span _\u27e9 := is_bezout.span_pair_is_principal a b,\n  obtain \u27e8a, rfl\u27e9 := ideal.mem_span_singleton'.mp\n    (show a \u2208 ideal.span {g}, by { rw [\u2190 e], exact ideal.subset_span (by simp) }),\n  obtain \u27e8b, rfl\u27e9 := ideal.mem_span_singleton'.mp\n    (show b \u2208 ideal.span {g}, by { rw [\u2190 e], exact ideal.subset_span (by simp) }),\n  obtain \u27e8x, y, e'\u27e9 := ideal.mem_span_pair.mp\n    (show g \u2208 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\u2080 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    \u2200 x : fraction_ring R, is_localization.is_integer R x \u2228 is_localization.is_integer R x\u207b\u00b9,\n    is_total R (\u2223),\n    is_total (ideal R) (\u2264),\n    local_ring R \u2227 is_bezout R] :=\nbegin\n  tfae_have : 1 \u2194 2, { exact iff_is_integer_or_is_integer R _ },\n  tfae_have : 1 \u2194 3, { exact iff_dvd_total },\n  tfae_have : 1 \u2194 4, { exact iff_ideal_total },\n  tfae_have : 1 \u2194 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 \u2192+* S) (hf : function.surjective f) :\n  valuation_ring S :=\n\u27e8\u03bb a b, begin\n  obtain \u27e8\u27e8a, rfl\u27e9, \u27e8b, rfl\u27e9\u27e9 := \u27e8hf a, hf b\u27e9,\n  obtain \u27e8c, rfl|rfl\u27e9 := valuation_ring.cond a b,\n  exacts [\u27e8f c, or.inl $ (map_mul _ _ _).symm\u27e9, \u27e8f c, or.inr $ (map_mul _ _ _).symm\u27e9],\nend\u27e9\n\nsection\n\nvariables {\ud835\udcaa : Type u} {K : Type v} {\u0393 : Type w}\n  [comm_ring \ud835\udcaa] [is_domain \ud835\udcaa] [field K] [algebra \ud835\udcaa K]\n  [linear_ordered_comm_group_with_zero \u0393]\n  (v : _root_.valuation K \u0393) (hh : v.integers \ud835\udcaa)\n\ninclude hh\n\n/-- If `\ud835\udcaa` satisfies `v.integers \ud835\udcaa` where `v` is a valuation on a field, then `\ud835\udcaa`\nis a valuation ring. -/\nlemma of_integers : valuation_ring \ud835\udcaa :=\nbegin\n  constructor,\n  intros a b,\n  cases le_total (v (algebra_map \ud835\udcaa K a)) (v (algebra_map \ud835\udcaa K b)),\n  { obtain \u27e8c,hc\u27e9 := valuation.integers.dvd_of_le hh h,\n    use c, exact or.inr hc.symm },\n  { obtain \u27e8c,hc\u27e9 := 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\u207b\u00b9, 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 \u27e8\u03d6,h\u03d6\u27e9 := discrete_valuation_ring.exists_irreducible A,\n  obtain \u27e8m,u,rfl\u27e9 := discrete_valuation_ring.eq_unit_mul_pow_irreducible ha h\u03d6,\n  obtain \u27e8n,v,rfl\u27e9 := discrete_valuation_ring.eq_unit_mul_pow_irreducible hb h\u03d6,\n  cases le_total m n with h h,\n  { use (u\u207b\u00b9 * v : A\u02e3) * \u03d6^(n-m), left,\n    simp_rw [mul_comm (u : A), units.coe_mul, \u2190 mul_assoc, mul_assoc _ (u : A)],\n    simp only [units.mul_inv, mul_one, mul_comm _ (v : A), mul_assoc, \u2190 pow_add],\n    congr' 2,\n    linarith },\n  { use (v\u207b\u00b9 * u : A\u02e3) * \u03d6^(m-n), right,\n    simp_rw [mul_comm (v : A), units.coe_mul, \u2190 mul_assoc, mul_assoc _ (v : A)],\n    simp only [units.mul_inv, mul_one, mul_comm _ (u : A), mul_assoc, \u2190 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\u2081 v\u2082 u\u2081 u\u2082 l \n\nnamespace Mathlib\n\nnamespace category_theory\n\n\ntheorem left_adjoint_preserves_epi {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] {F : C \u2964 D}\n    {G : D \u2964 C} (adj : F \u22a3 G) {X : C} {Y : C} {f : X \u27f6 Y} (hf : epi f) : epi (functor.map F f) :=\n  sorry\n\ntheorem right_adjoint_preserves_mono {C : Type u\u2081} [category C] {D : Type u\u2082} [category D]\n    {F : C \u2964 D} {G : D \u2964 C} (adj : F \u22a3 G) {X : D} {Y : D} {f : X \u27f6 Y} (hf : mono f) :\n    mono (functor.map G f) :=\n  sorry\n\ntheorem faithful_reflects_epi {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D)\n    [faithful F] {X : C} {Y : C} {f : X \u27f6 Y} (hf : epi (functor.map F f)) : epi f :=\n  sorry\n\ntheorem faithful_reflects_mono {C : Type u\u2081} [category C] {D : Type u\u2082} [category D] (F : C \u2964 D)\n    [faithful F] {X : C} {Y : C} {f : X \u27f6 Y} (hf : mono (functor.map F f)) : mono f :=\n  sorry\n\n/--\nA split monomorphism is a morphism `f : X \u27f6 Y` admitting a retraction `retraction f : Y \u27f6 X`\nsuch that `f \u226b retraction f = \ud835\udfd9 X`.\n\nEvery split monomorphism is a monomorphism.\n-/\nclass split_mono {C : Type u\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 Y) where\n  retraction : Y \u27f6 X\n  id' :\n    autoParam (f \u226b retraction = \ud835\udfd9)\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 \u27f6 Y` admitting a section `section_ f : Y \u27f6 X`\nsuch that `section_ f \u226b f = \ud835\udfd9 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 Y) where\n  section_ : Y \u27f6 X\n  id' :\n    autoParam (section_ \u226b f = \ud835\udfd9)\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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 Y) [split_mono f] : Y \u27f6 X :=\n  split_mono.retraction f\n\n@[simp] theorem split_mono.id_assoc {C : Type u\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 Y)\n    [split_mono f] {X' : C} (f' : X \u27f6 X') : f \u226b retraction f \u226b 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 Y) [split_epi f] : Y \u27f6 X :=\n  split_epi.section_ f\n\n@[simp] theorem split_epi.id_assoc {C : Type u\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 Y)\n    [split_epi f] {X' : C} (f' : Y \u27f6 X') : section_ f \u226b f \u226b 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 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\u2081} [category C] {X : C} {Y : C} (f : X \u27f6 Y)\n    [split_epi f] : epi f :=\n  epi.mk\n    fun (Z : C) (g h : Y \u27f6 Z) (w : f \u226b g = f \u226b h) =>\n      eq.mpr (id (Eq.refl (g = h)))\n        (eq.mp\n          ((fun (a a_1 : Y \u27f6 Z) (e_1 : a = a_1) (\u1fb0 \u1fb0_1 : Y \u27f6 Z) (e_2 : \u1fb0 = \u1fb0_1) =>\n              congr (congr_arg Eq e_1) e_2)\n            (section_ f \u226b f \u226b g) g (split_epi.id_assoc f g) (section_ f \u226b f \u226b h) h\n            (split_epi.id_assoc f h))\n          (section_ f \u226b= w))\n\n/-- Every split mono whose retraction is mono is an iso. -/\ndef is_iso.of_mono_retraction {C : Type u\u2081} [category C] {X : C} {Y : C} {f : X \u27f6 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\u2081} [category C] {X : C} {Y : C} {f : X \u27f6 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\u2081} [category C] {A : C\u1d52\u1d56} {B : C\u1d52\u1d56} (f : A \u27f6 B)\n    [epi f] : mono (has_hom.hom.unop f) :=\n  mono.mk\n    fun (Z : C) (g h : Z \u27f6 opposite.unop B)\n      (eq : g \u226b has_hom.hom.unop f = h \u226b 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\u2081} [category C] {A : C\u1d52\u1d56} {B : C\u1d52\u1d56} (f : A \u27f6 B)\n    [mono f] : epi (has_hom.hom.unop f) :=\n  epi.mk\n    fun (Z : C) (g h : opposite.unop A \u27f6 Z)\n      (eq : has_hom.hom.unop f \u226b g = has_hom.hom.unop f \u226b 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\u2081} [category C] {A : C} {B : C} (f : A \u27f6 B) [epi f] :\n    mono (has_hom.hom.op f) :=\n  mono.mk\n    fun (Z : C\u1d52\u1d56) (g h : Z \u27f6 opposite.op B) (eq : g \u226b has_hom.hom.op f = h \u226b 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\u2081} [category C] {A : C} {B : C} (f : A \u27f6 B) [mono f] :\n    epi (has_hom.hom.op f) :=\n  epi.mk\n    fun (Z : C\u1d52\u1d56) (g h : opposite.op A \u27f6 Z) (eq : has_hom.hom.op f \u226b g = has_hom.hom.op f \u226b 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\u2081} [category C] {D : Type u\u2082} [category D]\n    {X : C} {Y : C} (f : X \u27f6 Y) [split_mono f] (F : C \u2964 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\u2081} [category C] {D : Type u\u2082} [category D]\n    {X : C} {Y : C} (f : X \u27f6 Y) [split_epi f] (F : C \u2964 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 {\u03b1 : Type u} {\u03b2 : Type v}\n\nsection map_with_index\n\nlemma map_with_index_core_eq (l : list \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) (n : \u2115) :\n  l.map_with_index_core f n = l.map_with_index (\u03bb 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 \u03b1) (f : \u2115 \u2192 \u03b1 \u2192 \u03b2) :\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (start : \u2115) (b : \u03b2)\n  (as : list \u03b1) : \u03b2 :=\nfoldr (uncurry f) b $ enum_from start as\n\ntheorem foldr_with_index_aux_spec_cons (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2)\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (as : list \u03b1) :\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 : \u03b1 \u2192 Prop) [decidable_pred p]\n  (as : list \u03b1) :\n  indexes_values p as = filter (p \u2218 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 : \u03b1 \u2192 Prop) [decidable_pred p]\n  (as : list \u03b1) :\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (start : \u2115) (a : \u03b1)\n  (bs : list \u03b2) : \u03b1 :=\nfoldl (\u03bb a (p : \u2115 \u00d7 \u03b2), f p.fst a p.snd) a $ enum_from start bs\n\ntheorem foldl_with_index_aux_spec_cons (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1)\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (bs : list \u03b2) :\n  foldl_with_index f a bs =\n  foldl (\u03bb a (p : \u2115 \u00d7 \u03b2), 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 \u2192 Type v} [monad m]\n\ntheorem mfoldr_with_index_eq_mfoldr_enum {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 m \u03b2) (b : \u03b2) (as : list \u03b1) :\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] {\u03b1 \u03b2}\n  (f : \u2115 \u2192 \u03b2 \u2192 \u03b1 \u2192 m \u03b2) (b : \u03b2) (as : list \u03b1) :\n  mfoldl_with_index f b as =\n    mfoldl (\u03bb b (p : \u2115 \u00d7 \u03b1), 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 \u2192 Type v} [applicative m]\n\n/-- Specification of `mmap_with_index_aux`. -/\ndef mmap_with_index_aux_spec {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (start : \u2115) (as : list \u03b1) :\n  m (list \u03b2) :=\nlist.traverse (uncurry f) $ enum_from start as\n-- Note: `traverse` the class method would require a less universe-polymorphic\n-- `m : Type u \u2192 Type u`.\n\ntheorem mmap_with_index_aux_spec_cons {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (start : \u2115)\n  (a : \u03b1) (as : list \u03b1) :\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 {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2)\n  (start : \u2115) (as : list \u03b1) :\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 {\u03b1 \u03b2} (f : \u2115 \u2192 \u03b1 \u2192 m \u03b2) (as : list \u03b1) :\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 \u2192 Type v} [applicative m] [is_lawful_applicative m]\n\ntheorem mmap_with_index'_aux_eq_mmap_with_index_aux {\u03b1} (f : \u2115 \u2192 \u03b1 \u2192 m punit)\n  (start : \u2115) (as : list \u03b1) :\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 {\u03b1} (f : \u2115 \u2192 \u03b1 \u2192 m punit) (as : list \u03b1) :\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\u2225res ? - (M.d ??) ?\u2225 \u2264 const * \u2225(M.d ?? ?\u2225 + \u03b5.\n```\n(Recall that `res` is a restriction among certain complexes, `M.d` stands for a differential,\n`const` is a constant; the error `\u03b5` is a non-negative real number.  For the weak version, we\nquantify over all `0 < \u03b5 \u2208 \u211d`.  For the non-weak version, we use `\u03b5 = 0`.)\n\nMore in detail, at the heart of the computation, is a proof of an inequality of the form\n```lean\n\u2225res m - (M.d (i - 1) i) y\u2225 \u2264 K * (1 + K' * r\u2081 * r\u2082) * \u2225(M.d i (i + 1)) m\u2225 + \u03b5.\n```\nIn the weak normed snake dual lemma, for any choice of positive `0 < \u03b5`, 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 `\u03b5 = 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 `\u03c1 = 1 + K' * r\u2081 * r\u2082` forms itself.\nOnce the factor `\u03c1` 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 \u27f6 N} {g : N \u27f6 P}\n\n/-  I (DT) extracted this lemma to speed up the proof of `weak_normed_snake_dual`. -/\nlemma \u03b5\u2081_le_\u03b5 {\u03b5 \u03b5\u2081 : \u211d} (h\u03b5 : 0 \u2264 \u03b5) (mK : \u211d\u22650) (h\u03b5\u2081 : \u03b5\u2081 = \u03b5 / 2 * (1 + mK)\u207b\u00b9) :\n  \u03b5\u2081 \u2264 \u03b5 :=\nby { rw [h\u03b5\u2081, div_eq_mul_inv, mul_assoc, \u2190 mul_inv],\n     exact mul_le_of_le_one_right h\u03b5 (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 `\u2225res m - (M.d i' i) m\u2081\u2225` into a sum of two expressions:\n\n* `\u2225(res (f m) : N c i) - N.d i' i (res n\u2081)\u2225`, and\n* `\u2225(N.d i' i ((N.d i'' i') n\u2082 + nnew\u2081) : N c i)\u2225`.\n-/\nlemma norm_sub_le_split {k' c c\u2081 : \u211d\u22650} {i i' i'' : \u2115}\n  [hk' : fact (1 \u2264 k')] [fc : fact (c \u2264 c\u2081)]\n  (hfnorm : \u2200 (c : \u211d\u22650) (i : \u2115) (x : (M c i)), \u2225(f.apply) x\u2225 = \u2225x\u2225)\n  {n\u2081 : N (k' * c) i'} {n\u2082 : N c i''} {nnew\u2081 : N c i'} {m\u2081 : M c i'} {m : (M c\u2081 i)}\n  (hm\u2081 : f m\u2081 = res n\u2081 - ((N.d i'' i') n\u2082) - nnew\u2081) :\n  \u2225res m - (M.d i' i) m\u2081\u2225 \u2264\n    \u2225(res (f m) : N c i) - N.d i' i (res n\u2081)\u2225 + \u2225(N.d i' i ((N.d i'' i') n\u2082 + nnew\u2081) : N c i)\u2225 :=\ncalc \u2225res m - (M.d i' i) m\u2081\u2225\n      = \u2225f (res m - (M.d i' i) m\u2081)\u2225 : (hfnorm _ _ _).symm\n  ... = \u2225res (f m) - (N.d i' i (res n\u2081) - N.d i' i ((N.d i'' i') n\u2082 + nnew\u2081))\u2225 :\n    by rw [hom_apply, _root_.map_sub, \u2190hom_apply, \u2190hom_apply, \u2190res_apply,\n      \u2190d_apply, hm\u2081, sub_sub, _root_.map_sub]\n  ... = \u2225(res (f m) - N.d i' i (res n\u2081)) + N.d i' i ((N.d i'' i') n\u2082 + nnew\u2081)\u2225 :\n    by rw [sub_eq_add_neg, neg_sub, sub_eq_neg_add, \u2190 add_assoc, \u2190 sub_eq_add_neg]\n  ... \u2264 \u2225res (f m) - N.d i' i (res n\u2081)\u2225 + \u2225N.d i' i ((N.d i'' i') n\u2082 + nnew\u2081)\u2225 : 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 : \u2225(res (res (f m) - (N.d i' i) n\u2081) : N c i)\u2225 \u2264 \u2225res (f m) - (N.d i' i) n\u2081\u2225)`.)\n-/\nlemma norm_sub_le_mul_norm_add_lhs {k' K c c\u2081 : \u211d\u22650} {\u03b5\u2081 : \u211d} {i i' : \u2115}\n  [hk' : fact (1 \u2264 k')] [fc\u2081 : fact (k' * c \u2264 c\u2081)] [fc : fact (c \u2264 c\u2081)]\n  {n\u2081 : N (k' * c) i'} {m : (M c\u2081 i)}\n  (hN_adm : N.admissible)\n  (hn\u2081 : \u2225res (f m) - (N.d i' i) n\u2081\u2225 \u2264 K * \u2225(N.d i (i + 1)) (f m)\u2225 + \u03b5\u2081) :\n  \u2225(res (f m) : N c i) - N.d i' i (res n\u2081)\u2225 \u2264 K * \u2225(N.d i (i + 1)) (f m)\u2225 + \u03b5\u2081 :=\ncalc \u2225(res (f m) : N c i) - N.d i' i (res n\u2081)\u2225\n      = \u2225res (res (f m) - (N.d i' i) n\u2081)\u2225 : by rw [_root_.map_sub, d_res, \u2190 res_res]\n  ... \u2264 K * \u2225(N.d i (i + 1)) (f m)\u2225 + \u03b5\u2081  : trans (hN_adm.res_norm_noninc _ c _ _ _) hn\u2081\n\n/-!\nAnd we also massage the right-hand side.  Here, the factor `K' * r\u2081 * r\u2082` appears.\n\n(The hypothesis `(hN_adm : N.admissible)` is only used via `(hN_adm.d_norm_noninc _ _ i' i nnew\u2081)`,\nproducing the inequality `(dis : \u2225(N.d i' i) nnew\u2081\u2225 \u2264 \u2225nnew\u2081\u2225)`.)\n-/\nlemma norm_sub_le_mul_norm_add_rhs {k' K K' r\u2081 r\u2082 c c\u2081 : \u211d\u22650} {\u03b5\u2081 \u03b5\u2082 : \u211d}\n  {i i' i'' : \u2115} (hii' : i' + 1 = i)\n  [hk' : fact (1 \u2264 k')] [fc\u2081 : fact (k' * c \u2264 c\u2081)]\n  (hgnorm : \u2200 (c : \u211d\u22650) (i : \u2115) (x : (N c i)), \u2225g x\u2225 \u2264 \u2191r\u2081 * \u2225x\u2225)\n  {n\u2081 : N (k' * c) i'} {n\u2082 : N c i''} {nnew\u2081 : N c i'} {m : (M c\u2081 i)}\n  (hN_adm : N.admissible)\n  (hn\u2081 : \u2225res (f m) - (N.d i' i) n\u2081\u2225 \u2264 K * \u2225(N.d i (i + 1)) (f m)\u2225 + \u03b5\u2081)\n  (hp\u2082 : \u2225res (g n\u2081) - (P.d i'' i') (g n\u2082)\u2225 \u2264 K' * \u2225(P.d i' (i' + 1)) (g n\u2081)\u2225 + \u03b5\u2082)\n  (hnormnnew\u2081 : \u2225nnew\u2081\u2225 \u2264 r\u2082 * \u2225g (res n\u2081 - ((N.d i'' i') n\u2082))\u2225)\n  (hfm : \u2225g ((N.d i' i) n\u2081)\u2225 = \u2225g (res (f m) - (N.d i' i) n\u2081)\u2225) :\n  \u2225(N.d i' i ((N.d i'' i') n\u2082 + nnew\u2081) : N c i)\u2225 \u2264\n    K * K' * r\u2081 * r\u2082 * \u2225(N.d i (i+1)) (f m)\u2225 + K' * r\u2081 * r\u2082 * \u03b5\u2081 + r\u2082 * \u03b5\u2082 :=\ncalc \u2225(N.d i' i ((N.d i'' i') n\u2082 + nnew\u2081) : N c i)\u2225\n      = \u2225N.d i' i nnew\u2081\u2225 : by simp only [map_add, zero_add, d_d]\n  ... \u2264 r\u2082 * \u2225g (res n\u2081 - (N.d i'' i') n\u2082)\u2225 : trans (hN_adm.d_norm_noninc _ _ i' i nnew\u2081) hnormnnew\u2081\n  ... = r\u2082 * \u2225res (g n\u2081) - P.d i'' i' (g n\u2082)\u2225 :\n    by rw [hom_apply, _root_.map_sub, \u2190hom_apply, \u2190hom_apply, \u2190res_apply _ _ g, \u2190d_apply]\n  ... \u2264 r\u2082 * (K' * \u2225P.d i' (i'+1) (g n\u2081)\u2225 + \u03b5\u2082) : mul_le_mul_of_nonneg_left hp\u2082 r\u2082.coe_nonneg\n  ... = r\u2082 * (K' * \u2225g (res (f m) - N.d i' i n\u2081)\u2225 + \u03b5\u2082) : by rw [d_apply _ _ g _, hii', hfm]\n  ... \u2264 r\u2082 * (K' * (r\u2081 * \u2225res (f m) - N.d i' i n\u2081\u2225) + \u03b5\u2082) :\n    mul_le_mul_of_nonneg_left (add_le_add_right (mul_le_mul_of_nonneg_left\n      (hgnorm _ _ _) K'.coe_nonneg) _) $ r\u2082.coe_nonneg\n  ... = r\u2082 * (K' * r\u2081 * \u2225res (f m) - N.d i' i n\u2081\u2225 + \u03b5\u2082) : by rw mul_assoc\n  ... \u2264 r\u2082 * (K' * r\u2081 * (K * \u2225(N.d i (i+1)) (f m)\u2225 + \u03b5\u2081) + \u03b5\u2082) :\n    mul_le_mul_of_nonneg_left (add_le_add_right (mul_le_mul_of_nonneg_left\n      hn\u2081 $ mul_nonneg K'.coe_nonneg r\u2081.coe_nonneg) _) r\u2082.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\u2081 r\u2082 c c\u2081 : \u211d\u22650} {\u03b5 \u03b5\u2081 \u03b5\u2082 : \u211d}\n  {i i' i'' : \u2115} (hii' : i' + 1 = i)\n  [hk' : fact (1 \u2264 k')] [fc\u2081 : fact (k' * c \u2264 c\u2081)] [fc : fact (c \u2264 c\u2081)]\n  (hN_adm : N.admissible)\n  (hgnorm : \u2200 (c : \u211d\u22650) (i : \u2115) (x : (N c i)), \u2225g x\u2225 \u2264 \u2191r\u2081 * \u2225x\u2225)\n  (hfnorm : \u2200 (c : \u211d\u22650) (i : \u2115) (x : (M c i)), \u2225(f.apply) x\u2225 = \u2225x\u2225)\n  {n\u2081 : N (k' * c) i'} {n\u2082 : N c i''} {nnew\u2081 : N c i'} {m\u2081 : M c i'} {m : (M c\u2081 i)}\n  (hmul\u03b5\u2081 : \u03b5\u2081 * (1 + K' * r\u2081 * r\u2082) = \u03b5 / 2)\n  (hle : (r\u2082 : \u211d) * \u03b5\u2082 \u2264 \u03b5 / 2)\n  (hn\u2081 : \u2225res (f m) - (N.d i' i) n\u2081\u2225 \u2264 K * \u2225(N.d i (i + 1)) (f m)\u2225 + \u03b5\u2081)\n  (hp\u2082 : \u2225res (g n\u2081) - (P.d i'' i') (g n\u2082)\u2225 \u2264 K' * \u2225(P.d i' (i' + 1)) (g n\u2081)\u2225 + \u03b5\u2082)\n  (hnormnnew\u2081 : \u2225nnew\u2081\u2225 \u2264 r\u2082 * \u2225g (res n\u2081 - ((N.d i'' i') n\u2082))\u2225)\n  (hm\u2081 : f m\u2081 = res n\u2081 - ((N.d i'' i') n\u2082) - nnew\u2081)\n  (hfm : \u2225g ((N.d i' i) n\u2081)\u2225 = \u2225g (res (f m) - (N.d i' i) n\u2081)\u2225) :\n  \u2225res m - (M.d i' i) m\u2081\u2225 \u2264 (K + r\u2081 * r\u2082 * K * K') * \u2225(M.d i (i + 1)) m\u2225 + \u03b5 :=\ncalc\n\u2225res m - (M.d i' i) m\u2081\u2225 \u2264 \u2225res (f m) - N.d i' i (res n\u2081)\u2225 + \u2225N.d i' i ((N.d i'' i') n\u2082 + nnew\u2081)\u2225 :\n    norm_sub_le_split hfnorm hm\u2081\n  ... \u2264 (K * \u2225(N.d i (i + 1)) (f m)\u2225 + \u03b5\u2081) +\n        (K * K' * r\u2081 * r\u2082 * \u2225(N.d i (i+1)) (f m)\u2225 + K' * r\u2081 * r\u2082 * \u03b5\u2081 + r\u2082 * \u03b5\u2082) : add_le_add\n      (norm_sub_le_mul_norm_add_lhs hN_adm hn\u2081)\n      (norm_sub_le_mul_norm_add_rhs hii' hgnorm hN_adm hn\u2081 hp\u2082 hnormnnew\u2081 hfm)\n  ... = (K + r\u2081 * r\u2082 * K * K') * \u2225N.d i (i+1) (f m)\u2225 + \u03b5\u2081 * (1 + K' * r\u2081 * r\u2082) + r\u2082 * \u03b5\u2082 : by ring\n  ... = (K + r\u2081 * r\u2082 * K * K') * \u2225N.d i (i+1) (f m)\u2225 + \u03b5 / 2 + r\u2082 * \u03b5\u2082 :\n    congr_arg (\u03bb e, (\u2191K + \u2191r\u2081 * \u2191r\u2082 * \u2191K * \u2191K') * \u2225(N.d i (i + 1)) (f m)\u2225 + e + \u2191r\u2082 * \u03b5\u2082) hmul\u03b5\u2081\n  ... \u2264 (K + r\u2081 * r\u2082 * K * K') * \u2225N.d i (i+1) (f m)\u2225 + \u03b5 / 2 + \u03b5 / 2 : add_le_add_left hle _\n  ... = (K + r\u2081 * r\u2082 * K * K') * \u2225(M.d i (i+1)) m\u2225 + \u03b5 :\n    by rw [add_assoc, add_halves', d_apply, hom_apply, hfnorm]\n\n/-!\nWe shall apply this lemma with `\u03c1 = K + r\u2081 * r\u2082 * K * K' = K * (1 + K' * r\u2081 * r\u2082)`.\n-/\nlemma exists_norm_sub_le_mul_add {k k' c \u03c1 : \u211d\u22650}\n  {i : \u2115}\n  [hk : fact (1 \u2264 k)] [hk' : fact (1 \u2264 k')]\n  (hM_adm : M.admissible)\n  (ex_le : (\u2200 (m : (M (k * (k' * c)) i)) (\u03b5 : \u211d), 0 < \u03b5 \u2192\n        (\u2203 (i\u2080 : \u2115) (hi\u2080 : i\u2080 = i - 1) (y : (M c i\u2080)),\n           \u2225res m - (M.d i\u2080 i) y\u2225 \u2264 \u2191\u03c1 * \u2225(M.d i (i + 1)) m\u2225 + \u03b5)))\n  {m\u2081 : (M (k * k' * c) i)}\n  {\u03b5 : \u211d} (h\u03b5 : 0 < \u03b5) :\n  \u2203 (i\u2080 j : \u2115) (hi\u2080 : i\u2080 = i - 1) (hj : i + 1 = j) (y : (M c i\u2080)),\n      \u2225res m\u2081 - (M.d i\u2080 i) y\u2225 \u2264 \u2191\u03c1 * \u2225(M.d i j) m\u2081\u2225 + \u03b5 :=\nbegin\n  haveI : fact (k * (k' * c) \u2264 k * k' * c) := { out := (mul_assoc _ _ _).symm.le },\n  rcases ex_le (res m\u2081) \u03b5 h\u03b5 with \u27e8i\u2080, rfl, y, hy\u27e9,\n  rw [res_res, d_res] at hy,\n  refine \u27e8i - 1, _, rfl, rfl, _\u27e9,\n  refine \u27e8y, hy.trans (add_le_add_right (mul_le_mul_of_nonneg_left _ \u03c1.2) \u03b5)\u27e9,\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 \u27f6 N}\n  {k k' K c : \u211d\u22650} (mK : \u211d\u22650) {\u03b5 \u03b5\u2081 : \u211d} {m : M (k * (k' * c)) 0} {n\u2081 : N (k' * c) 0} {m\u2081 : M c 0}\n  (ee1 : \u03b5\u2081 \u2264 \u03b5)\n  [hk : fact (1 \u2264 k)] [hk' : fact (1 \u2264 k')]\n  (hfnorm : \u2200 (c : \u211d\u22650) (i : \u2115) (x : (M c i)), \u2225(f.apply) x\u2225 = \u2225x\u2225)\n  (inadm : \u2225((res (res m : (M (k' * c) 0))) : (M c 0))\u2225 \u2264 \u2225(res m : (M (k' * c) 0))\u2225 )\n  (hn\u2081 : \u2225res (f m) - (N.d 0 0) n\u2081\u2225 \u2264 \u2191K * \u2225(N.d 0 (0 + 1)) (f m)\u2225 + \u03b5\u2081) :\n  \u2225res m - (M.d 0 0) m\u2081\u2225 \u2264 (K * (1 + mK)) * \u2225(M.d 0 (0 + 1)) m\u2225 + \u03b5 :=\nbegin\n  simp only [d_self_apply, sub_zero, nnreal.coe_add, nnreal.coe_mul] at hn\u2081 \u22a2,\n  rw [res_apply, hom_apply f (res m), hfnorm] at hn\u2081,\n  have new : fact (c \u2264 k' * c) := { out := le_mul_of_one_le_left c.2 hk'.out },\n  rw \u2190res_res _ _ _ new,\n  refine le_trans inadm (le_trans hn\u2081 _),\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 `\u03b5 = 0` is allowed.  Indeed, the weak normed snake dual lemma uses `0 \u2264 \u03b5`, while the\nnormed snake dual lemma uses `\u03b5 = 0`.\n-/\nlemma exist_norm_sub_le_mul_norm_add {k k' K K' r\u2081 r\u2082 c\u2080 c : \u211d\u22650}\n  {a i : \u2115} {\u03b5 : \u211d} (h\u03b5 : 0 \u2264 \u03b5)\n  [hk : fact (1 \u2264 k)] [hk' : fact (1 \u2264 k')]\n  (hN_adm : N.admissible)\n  (hgnrm : \u2200 (c : \u211d\u22650) (i : \u2115) (x : (N c i)), \u2225g x\u2225 \u2264 r\u2081 * \u2225x\u2225)\n  (Hg : \u2200 (c : \u211d\u22650) [_inst_1 : fact (c\u2080 \u2264 c)] (i : \u2115),\n          i \u2264 a + 1 + 1 \u2192 \u2200 (y : (P c i)), \u2203 (x : (N c i)), g x = y \u2227 \u2225x\u2225 \u2264 r\u2082 * \u2225y\u2225)\n  (hg : \u2200 (c : \u211d\u22650) (i : \u2115), (range f.apply : add_subgroup (N c i)) = ker g.apply)\n  (hf : \u2200 (c : \u211d\u22650) (i : \u2115), (isometry (f.apply : M c i \u27f6 N c i) : _))\n  (hc : fact (c\u2080 \u2264 c))\n  (hi : i \u2264 a)\n  {m : M (k * (k' * c)) i} {n\u2081 : N (k' * c) (i - 1)}\n  (hn\u2081 : \u2225res (f m) - (N.d (i - 1) i) n\u2081\u2225 \u2264\n    K * \u2225(N.d i (i + 1)) (f m)\u2225 + \u03b5 / 2 * (1 + K' * r\u2081 * r\u2082)\u207b\u00b9)\n  (Hi' : i - 1 \u2264 a + 1)\n  (p\u2082 : P c (i - 1 - 1)) (hp\u2082 : \u2225res (g n\u2081) - (P.d (i - 1 - 1) (i - 1)) p\u2082\u2225 \u2264\n    K' * \u2225(P.d (i - 1) (i - 1 + 1)) (g n\u2081)\u2225 + ite (r\u2082 = 0) 1 (\u03b5 / 2 * (r\u2082)\u207b\u00b9)) :\n  \u2203 (i\u2080 : \u2115) (hi\u2080 : i\u2080 = i - 1) (y : (M c i\u2080)),\n    \u2225res m - (M.d i\u2080 i) y\u2225 \u2264 (K + r\u2081 * r\u2082 * K * K') * \u2225(M.d i (i + 1)) m\u2225 + \u03b5 :=\nbegin\n  obtain \u27e8n\u2082, rfl, hnormn\u2082\u27e9 :=\n    Hg c (i - 1 - 1) (trans (nat.pred_le _) (trans Hi' (nat.le_succ _))) p\u2082,\n  let n\u2081' := N.d (i - 1 - 1) (i - 1) n\u2082,\n  obtain \u27e8nnew\u2081, hnnew\u2081, hnrmnew\u2081\u27e9 := Hg c (i - 1) (trans Hi' a.succ.le_succ) (g (res n\u2081 - n\u2081')),\n  have hker : (res n\u2081 - n\u2081') - nnew\u2081 \u2208 g.apply.ker,\n  { rw [mem_ker, _root_.map_sub, sub_eq_zero, \u2190hom_apply, \u2190hom_apply, hnnew\u2081] },\n  rw \u2190hg at hker,\n  obtain \u27e8m\u2081, hm\u2081 : f m\u2081 = res n\u2081 - n\u2081' - nnew\u2081\u27e9 := (mem_range _ _).1 hker,\n  refine \u27e8i - 1, rfl, m\u2081, _\u27e9,\n  have hfnrm : \u2200 c i (x : M c i), \u2225f.apply x\u2225 = \u2225x\u2225 := \u03bb 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\u2081 * r\u2082) _ hfnrm _ hn\u2081,\n    { norm_cast, ring },\n    { exact \u03b5\u2081_le_\u03b5 h\u03b5 (K' * r\u2081 * r\u2082) 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\u2081 hp\u2082 hnrmnew\u2081 hm\u2081 _,\n    { exact nat.succ_pred_eq_of_pos (nat.pos_of_ne_zero hizero) },\n    { rw inv_mul_cancel_right\u2080,\n      exact ne_of_gt (add_pos_of_pos_of_nonneg zero_lt_one (zero_le (K' * r\u2081 * r\u2082))) },\n    { by_cases H : r\u2082 = 0,\n      { simp only [H, nnreal.coe_zero, if_true, zero_mul, (div_nonneg h\u03b5 zero_le_two)] },\n      { simp only [H, nnreal.coe_eq_zero, if_false, mul_comm,\n          mul_inv_cancel_left\u2080 (nnreal.coe_ne_zero.mpr H)] } },\n    { have : f (res m : M (k' * c) i) \u2208 f.apply.range, { rw mem_range, exact \u27e8res m, rfl\u27e9 },\n      rw [hg, mem_ker] at this,\n      rw [hom_apply g (res (f m) - (N.d (i - 1) i) n\u2081), res_apply, _root_.map_sub, this,\n        zero_sub, norm_neg, \u2190hom_apply] } }\nend\n\n/-!\nWe apply this lemma with `\u03c1 = K + r\u2081 * r\u2082 * K * K'`.\n-/\nlemma exists_norm_sub_le_mul {M : system_of_complexes} {k k' c \u03c1 : \u211d\u22650}\n  {i : \u2115}\n  [hk : fact (1 \u2264 k)] [hk' : fact (1 \u2264 k')]\n  (hM_adm : M.admissible)\n  (ex_le : (\u2200 (m : (M (k * (k' * c)) i)),\n        (\u2203 (i\u2080 : \u2115) (hi\u2080 : i\u2080 = i - 1) (y : (M c i\u2080)),\n           \u2225res m - (M.d i\u2080 i) y\u2225 \u2264 \u2191\u03c1 * \u2225(M.d i (i + 1)) m\u2225)))\n  (m\u2081 : (M (k * k' * c) i)) :\n  \u2203 (i\u2080 j : \u2115) (hi\u2080 : i\u2080 = i - 1) (hj : i + 1 = j) (y : (M c i\u2080)),\n      \u2225res m\u2081 - (M.d i\u2080 i) y\u2225 \u2264 \u2191\u03c1 * \u2225(M.d i j) m\u2081\u2225 :=\nbegin\n  haveI : fact (k * (k' * c) \u2264 k * k' * c) := { out := (mul_assoc _ _ _).symm.le },\n  rcases ex_le (res m\u2081) with \u27e8i\u2080, rfl, y, hy\u27e9,\n  rw [res_res, d_res] at hy,\n  refine \u27e8i - 1, _, rfl, rfl, _\u27e9,\n  refine \u27e8y, hy.trans (mul_le_mul_of_nonneg_left _ \u03c1.2)\u27e9,\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\u2081 r\u2082 : \u211d\u22650)\n  [hk : fact (1 \u2264 k)] [hk' : fact (1 \u2264 k')]\n  {a : \u2115} {c\u2080 : \u211d\u22650}\n  (hN : N.is_weak_bounded_exact k K (a + 1) c\u2080)\n  (hP : P.is_weak_bounded_exact k' K' (a + 1) c\u2080)\n  (hN_adm : N.admissible)\n  (hgnrm : \u2200 c i (x : N c i), \u2225g x\u2225 \u2264 r\u2081 * \u2225x\u2225)\n  (Hg : \u2200 (c : \u211d\u22650) [fact (c\u2080 \u2264 c)] (i : \u2115) (hi : i \u2264 a + 1 + 1) (y : P c i),\n    \u2203 (x : N c i), g x = y \u2227 \u2225x\u2225 \u2264 r\u2082 * \u2225y\u2225)\n  (hg : \u2200 c i, (f.apply : M c i \u27f6 N c i).range = g.apply.ker)\n  (hf : \u2200 c i, @isometry (M c i) (N c i) _ _ f.apply) :\n  M.is_weak_bounded_exact (k * k') (K + r\u2081 * r\u2082 * K * K') a c\u2080 :=\nbegin\n  introsI c hc i hi,\n  apply exists_norm_sub_le_mul_add (admissible_of_isometry hN_adm hf),\n  intros m \u03b5 h\u03b5,\n\n  have h\u03b5\u2081 : 0 < \u03b5 / 2 * (1 + K' * r\u2081 * r\u2082)\u207b\u00b9 := mul_pos (half_pos h\u03b5)\n    (inv_pos.2 $ add_pos_of_pos_of_nonneg zero_lt_one ((K' * r\u2081 * r\u2082).coe_nonneg)),\n  obtain \u27e8_, _, rfl, rfl, n\u2081, hn\u2081\u27e9 :=\n    hN _ \u27e8hc.out.trans $ le_mul_of_one_le_left' hk'.out\u27e9 _ (trans hi a.le_succ) (f m) _ h\u03b5\u2081,\n  have Hi' : i - 1 \u2264 a + 1 := trans i.pred_le (trans hi a.le_succ),\n  obtain \u27e8_, _, rfl, rfl, p\u2082, hp\u2082\u27e9 := hP _ hc _ Hi' (g n\u2081)\n    (if (r\u2082 : \u211d) = 0 then 1 else (\u03b5 / 2) * r\u2082\u207b\u00b9) _,\n  { simp_rw [nnreal.coe_eq_zero r\u2082] at hp\u2082,\n    apply exist_norm_sub_le_mul_norm_add h\u03b5.le hN_adm hgnrm Hg hg hf hc hi hn\u2081 Hi' p\u2082,\n    convert hp\u2082, },\n  { by_cases H : r\u2082 = 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\u03b5) (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\u2081 r\u2082 : \u211d\u22650}\n  [hk : fact (1 \u2264 k)] [hk' : fact (1 \u2264 k')]\n  {a : \u2115} {c\u2080 : \u211d\u22650}\n  (hN : N.is_bounded_exact k K (a + 1) c\u2080)\n  (hP : P.is_bounded_exact k' K' (a + 1) c\u2080)\n  (hN_adm : N.admissible)\n  (hgnorm : \u2200 c i (x : N c i), \u2225g x\u2225 \u2264 r\u2081 * \u2225x\u2225)\n  (Hg : \u2200 (c : \u211d\u22650) [fact (c\u2080 \u2264 c)] (i : \u2115) (hi : i \u2264 a + 1 + 1) (y : P c i),\n    \u2203 (x : N c i), g x = y \u2227 \u2225x\u2225 \u2264 r\u2082 * \u2225y\u2225)\n  (hg : \u2200 c i, (f.apply : M c i \u27f6 N c i).range = g.apply.ker)\n  (hf : \u2200 c i, @isometry (M c i) (N c i) _ _ f.apply) :\n  M.is_bounded_exact (k * k') (K + r\u2081 * r\u2082 * K * K') a c\u2080 :=\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 \u27e8_, _, rfl, rfl, n\u2081, hn\u2081\u27e9 :=\n    hN _ \u27e8hc.out.trans $ le_mul_of_one_le_left' hk'.out\u27e9 _ (trans hi a.le_succ) (f m),\n  have Hi' : (i - 1) \u2264 a + 1 := trans i.pred_le (trans hi a.le_succ),\n  obtain \u27e8_, _, rfl, rfl, p\u2082, hp\u2082\u27e9 := hP _ hc _ Hi' (g n\u2081),\n  rw \u2190 add_zero (_ * \u2225_\u2225) at \u22a2,\n  have hn\u2081\u2081 :  \u2225res (f m) - (N.d (i - 1) i) n\u2081\u2225 \u2264\n    K * \u2225(N.d i (i + 1)) (f m)\u2225 + 0 / 2 * (1 + K' * r\u2081 * r\u2082)\u207b\u00b9, 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\u2081\u2081 Hi' p\u2082,\n  by_cases hr : r\u2082 = 0,\n  { subst hr,\n    simp at \u22a2 F,\n    exact F (trans hp\u2082 (le_add_of_nonneg_right zero_le_one)) },\n  { exact F (by { convert hp\u2082, 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 \u2295 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 \u2295 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 <<<\u207b\u00b9 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 \u2964 Profinite\u1d52\u1d56 \u2964 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 \u2964 Profinite\u1d52\u1d56 \u2964 SemiNormedGroup :=\n{ obj := \u03bb V,\n  { obj := \u03bb S, SemiNormedGroup.of $ locally_constant (unop S : Profinite) V,\n    map := \u03bb S\u2081 S\u2082 f, comap_hom (f.unop) (f.unop.continuous),\n    map_id' := \u03bb S, comap_hom_id,\n    map_comp' := \u03bb S\u2081 S\u2082 S\u2083 f g, (comap_hom_comp _ _ _ _).symm },\n  map := \u03bb V W f,\n  { app := \u03bb S, map_hom f,\n    naturality' := \u03bb S\u2081 S\u2082 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 \u27f6 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\u1d52\u1d56) (\u03c6 : X \u27f6 Y) :\n  ((LocallyConstant.obj V).map \u03c6).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 {\ud835\udc9c : Type u} [category.{v} \ud835\udc9c] [abelian \ud835\udc9c]\nvariables {A B C : \ud835\udc9c} {f : A \u27f6 B} {g : B \u27f6 C}\n\nnamespace category_theory\n\nnamespace exact_seq\n\nlemma drop : \u2200 {L : list (arrow \ud835\udc9c)} (h : exact_seq \ud835\udc9c L) (n : \u2115),\n  exact_seq \ud835\udc9c (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 : \u2200 {L : list (arrow \ud835\udc9c)} (h : exact_seq \ud835\udc9c (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, \u2190 hf]\n\nlemma eq_zero_of_mono (h : exact f g) (hg : mono g) : f = 0 :=\nby rw [\u2190 cancel_mono g, h.w, zero_comp]\n\nlemma mono_iff_eq_zero (h : exact f g) : mono g \u2194 f = 0 :=\n\u27e8h.eq_zero_of_mono, h.mono_of_eq_zero\u27e9\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, \u2190 hg]\n\nlemma eq_zero_of_epi (h : exact f g) (hf : category_theory.epi f) : g = 0 :=\nby rw [\u2190 cancel_epi f, h.w, comp_zero]\n\nlemma epi_iff_eq_zero (h : exact f g) : category_theory.epi f \u2194 g = 0 :=\n\u27e8h.eq_zero_of_epi, h.epi_of_eq_zero\u27e9\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 \ud835\udc9c [f, g] :=\n(exact_iff_exact_seq _ _).mp h\n\nlemma cons (h : exact f g) {L : list (arrow \ud835\udc9c)} (hL : exact_seq \ud835\udc9c (g :: L)) :\n  exact_seq \ud835\udc9c (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'' (\u03b1 \u03b2 : Type)\n| cons : \u2124 \u2192 (\u2115 \u2192 \u03b1) \u2192 (list \u2115 \u2192 \u03b1) \u2192 (\u2124 \u2192 \u03b2) \u2192 list_F''\n| a : \u03b1 \u2192 list_F''\n| b : \u03b2 \u2192 list_F''\n| nil : list_F''\n-- #exit\n-- @[derive mvqpf]\nqpf list_F (\u03b1 : Type)\n| nil : list_F\n| cons : \u2124 \u2192 \u03b1 \u2192 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 : \u2200 (\u03b1 : Type), list_F.internal (typevec.of_ind (typevec.ind.cons \u03b1 typevec.ind.nil)) = list_F \u03b1 :=\n-- list_F.internal_eq\n\n-- example : \u03a0 (\u03b1 \u03b2 : typevec 1), \u03b1 \u27f9 \u03b2 \u2192 list_F.internal \u03b1 \u2192 list_F.internal \u03b2 :=\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 : \u2200 (\u03b1 \u03b1' : Type) (f0 : \u03b1 \u2192 \u03b1'),\n--   list_F.internal.map (typevec.of_ind (typevec.ind.cons \u03b1 typevec.ind.nil))\n--       (typevec.of_ind (typevec.ind.cons \u03b1' typevec.ind.nil))\n--       (typevec.append_fun typevec.nil_fun f0)\n--       _ =\n--     list_F.nil \u03b1' :=\n-- list_F.internal.map._equation_0\n\n-- example : \u2200 (\u03b1 \u03b1' : Type) (f0 : \u03b1 \u2192 \u03b1') (a : \u2124) (a_1 : \u03b1),\n--   list_F.internal.map (typevec.of_ind (typevec.ind.cons \u03b1 typevec.ind.nil))\n--       (typevec.of_ind (typevec.ind.cons \u03b1' 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.\u03b1\n-- -- #print hidden.list_F'.child_t.\u03b2\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 : \u2200 (\u03b1 \u03b2 : Type),\n--   list_F'.internal (typevec.of_ind (typevec.ind.cons \u03b1 (typevec.ind.cons \u03b2 typevec.ind.nil))) = list_F' \u03b1 \u03b2 :=\n-- list_F'.internal_eq\n\n-- example : \u03a0 (\u03b1 \u03b2 : typevec 2), \u03b1 \u27f9 \u03b2 \u2192 list_F'.internal \u03b1 \u2192 list_F'.internal \u03b2 :=\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 : \u2200 (\u03b1 \u03b2 \u03b1' \u03b2' : Type) (f0 : \u03b1 \u2192 \u03b1') (f1 : \u03b2 \u2192 \u03b2'),\n--   list_F'.internal.map (typevec.of_ind (typevec.ind.cons \u03b1 (typevec.ind.cons \u03b2 typevec.ind.nil)))\n--       (typevec.of_ind (typevec.ind.cons \u03b1' (typevec.ind.cons \u03b2' typevec.ind.nil)))\n--       (typevec.append_fun (typevec.append_fun typevec.nil_fun f1) f0)\n--       _ =\n--     list_F'.nil \u03b1' \u03b2' :=\n-- list_F'.internal.map._equation_0\n\n-- example : \u2200 (\u03b1 \u03b2 \u03b1' \u03b2' : Type) (f0 : \u03b1 \u2192 \u03b1') (f1 : \u03b2 \u2192 \u03b2') (a : \u03b1) (a_1 : \u03b2),\n--   list_F'.internal.map (typevec.of_ind (typevec.ind.cons \u03b1 (typevec.ind.cons \u03b2 typevec.ind.nil)))\n--       (typevec.of_ind (typevec.ind.cons \u03b1' (typevec.ind.cons \u03b2' 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''_ (\u03b1 \u03b2 \u03b3 : Type u)\n| nil : (\u03b2 \u2192 \u03b3) \u2192 list_F''_\n| cons : (\u03b1 \u2192 \u03b2) \u2192 list_F''_\n\n-- #exit\n-- #print hidden.list_F''.head_t\n-- #print hidden.list_F''.child_t.\u03b3\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 : \u2200 (\u03b1 : Type*) (\u03b2 : Type*) (\u03b3 : Type*),\n--     list_F''.internal \u03b1 \u03b2 (typevec.of_ind (typevec.ind.cons \u03b3 typevec.ind.nil)) = list_F'' \u03b1 \u03b2 \u03b3 :=\n-- list_F''.internal_eq\n\n-- example : \u03a0 (\u03b1 : Type*) (\u03b2 : Type*) (\u03b1_1 \u03b2_1 : typevec 1),\n--     \u03b1_1 \u27f9 \u03b2_1 \u2192 list_F''.internal \u03b1 \u03b2 \u03b1_1 \u2192 list_F''.internal \u03b1 \u03b2 \u03b2_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 : \u2200 (\u03b1 : Type u_1) (\u03b2 : Type u_1) (\u03b3 \u03b3' : Type u_1) (f2 : \u03b3 \u2192 \u03b3') (a : \u03b2 \u2192 \u03b3),\n--   list_F''.internal.map \u03b1 \u03b2 (typevec.of_ind (typevec.ind.cons \u03b3 typevec.ind.nil))\n--       (typevec.of_ind (typevec.ind.cons \u03b3' typevec.ind.nil))\n--       (typevec.append_fun typevec.nil_fun f2)\n--       _ =\n--     list_F''.nil \u03b1 (\u03bb (a_1 : \u03b2), f2 (a a_1)) :=\n-- list_F''.internal.map._equation_0\n\n-- example : \u2200 (\u03b1 : Type u_1) (\u03b2 : Type u_1) (\u03b3 \u03b3' : Type u_1) (f2 : \u03b3 \u2192 \u03b3') (a : \u03b1 \u2192 \u03b2),\n--   list_F''.internal.map \u03b1 \u03b2 (typevec.of_ind (typevec.ind.cons \u03b3 typevec.ind.nil))\n--       (typevec.of_ind (typevec.ind.cons \u03b3' typevec.ind.nil))\n--       (typevec.append_fun typevec.nil_fun f2)\n--       _ =\n--     list_F''.cons \u03b3' (\u03bb (a_1 : \u03b1), a a_1) :=\n-- list_F''.internal.map._equation_1\n\n-- @[derive mvqpf]\nqpf list_F''' (\u03b1 \u03b2 \u03b3 : Type u)\n| nil : list_F'''\n| cons : (\u03b3 \u2192 \u03b2) \u2192 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.\u03b1\n-- #print hidden.list_F'''.child_t.\u03b2\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 : \u2200 (\u03b1 \u03b2 \u03b3 : Type*),\n--     list_F'''.internal \u03b3 (typevec.of_ind (typevec.ind.cons \u03b1 (typevec.ind.cons \u03b2 typevec.ind.nil))) =\n--       list_F''' \u03b1 \u03b2 \u03b3 :=\n-- list_F'''.internal_eq\n\n-- example : \u03a0 (\u03b3 : Type*) (\u03b1 \u03b2 : typevec 2), \u03b1 \u27f9 \u03b2 \u2192 list_F'''.internal \u03b3 \u03b1 \u2192 list_F'''.internal \u03b3 \u03b2 :=\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 : \u2200 (\u03b1 \u03b2 \u03b3 \u03b1' \u03b2' : Type u) (f0 : \u03b1 \u2192 \u03b1') (f1 : \u03b2 \u2192 \u03b2'),\n--   list_F'''.internal.map \u03b3 (typevec.of_ind (typevec.ind.cons \u03b1 (typevec.ind.cons \u03b2 typevec.ind.nil)))\n--       (typevec.of_ind (typevec.ind.cons \u03b1' (typevec.ind.cons \u03b2' typevec.ind.nil)))\n--       (typevec.append_fun (typevec.append_fun typevec.nil_fun f1) f0)\n--       _ = --(list_F'''.nil \u03b1 \u03b2 \u03b3) =\n--     list_F'''.nil \u03b1' \u03b2' \u03b3 :=\n-- list_F'''.internal.map._equation_0\n\n-- example : \u2200 (\u03b1 \u03b2 \u03b3 \u03b1' \u03b2' : Type u) (f0 : \u03b1 \u2192 \u03b1') (f1 : \u03b2 \u2192 \u03b2') (a : \u03b3 \u2192 \u03b2),\n--   list_F'''.internal.map \u03b3 (typevec.of_ind (typevec.ind.cons \u03b1 (typevec.ind.cons \u03b2 typevec.ind.nil)))\n--       (typevec.of_ind (typevec.ind.cons \u03b1' (typevec.ind.cons \u03b2' typevec.ind.nil)))\n--       (typevec.append_fun (typevec.append_fun typevec.nil_fun f1) f0)\n--       ( _ ) =\n--     list_F'''.cons \u03b1' (\u03bb (a_1 : \u03b3), f1 (a a_1)) :=\n-- list_F'''.internal.map._equation_1\n\n-- @[derive mvqpf]\nqpf list_F'''' (\u03b1 \u03b2 \u03b3 : Type u)\n| nil : (\u03b2 \u2192 \u03b3) \u2192 (\u03b3 \u2192 \u03b1) \u2192 list_F''''\n| cons : (\u03b1 \u2192 \u03b2) \u2192 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 : \u2200 (\u03b1 : Type*) (\u03b2 : Type*) (\u03b3 : Type*),\n--     list_F''''.internal \u03b1 \u03b2 \u03b3 (typevec.of_ind typevec.ind.nil) = list_F'''' \u03b1 \u03b2 \u03b3 :=\n-- @list_F''''.internal_eq\n\nexample : \u03a0 (\u03b1 : Type*) (\u03b2 : Type*) (\u03b3 : Type*) (\u03b1_1 \u03b2_1 : typevec 0),\n    \u03b1_1 \u27f9 \u03b2_1 \u2192 list_F''''.internal \u03b1 \u03b2 \u03b3 \u03b1_1 \u2192 list_F''''.internal \u03b1 \u03b2 \u03b3 \u03b2_1 :=\n@list_F''''.internal.map\n\n-- #test hidden.list_F''''.internal.map._equation_0\n\nexample : \u2200 (\u03b1 : Type u_1) (\u03b2 : Type u_1) (\u03b3 : Type u_1) (a : \u03b2 \u2192 \u03b3) (a_1 : \u03b3 \u2192 \u03b1),\n  list_F''''.internal.map \u03b1 \u03b2 \u03b3 \u2983 \u2984 \u2983 \u2984 typevec.nil_fun\n      _ =\n    list_F''''.nil (\u03bb (a_1 : \u03b2), a a_1) (\u03bb (a : \u03b3), a_1 a) :=\nlist_F''''.internal.map._equation_0\n\nexample : \u2200 (\u03b1 : Type u_1) (\u03b2 : Type u_1) (\u03b3 : Type u_1) (a : \u03b1 \u2192 \u03b2),\n  list_F''''.internal.map \u03b1 \u03b2 \u03b3 (\u2983 \u2984) ( \u2983 \u2984 ) typevec.nil_fun\n      _ =\n    list_F''''.cons \u03b3 (\u03bb (a_1 : \u03b1), a a_1) :=\nlist_F''''.internal.map._equation_1\n\n-- data list\n-- | nil : list\n-- | cons : \u2124 \u2192 list \u2192 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 {\u03b1 \u03b2 : Type u} {s : set \u03b1} {f : \u03b1 \u2192 set \u03b2} {g : set (\u03b1 \u2192 \u03b2)}\n\ninstance : monad.{u} set :=\n{ pure       := \u03bb \u03b1 a, {a},\n  bind       := \u03bb \u03b1 \u03b2 s f, \u22c3 i \u2208 s, f i,\n  seq        := \u03bb \u03b1 \u03b2, set.seq,\n  map        := \u03bb \u03b1 \u03b2, set.image }\n\n@[simp] lemma bind_def : s >>= f = \u22c3 i \u2208 s, f i := rfl\n@[simp] lemma fmap_eq_image (f : \u03b1 \u2192 \u03b2) : f <$> s = f '' s := rfl\n@[simp] lemma seq_eq_set_seq (s : set (\u03b1 \u2192 \u03b2)) (t : set \u03b1) : s <*> t = s.seq t := rfl\n@[simp] lemma pure_def (a : \u03b1) : (pure a : set \u03b1) = {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 {\u03b1 \u03b2 \u03b3 : Type*} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : set \u03b1) (t : set \u03b2) :\n  image2 f s t = f <$> s <*> t :=\nby { ext, simp }\n\ninstance : is_lawful_monad set :=\n{ id_map                := \u03bb \u03b1, image_id,\n  comp_map              := \u03bb \u03b1 \u03b2 \u03b3 f g s, image_comp _ _ _,\n  pure_bind             := \u03bb \u03b1 \u03b2, bUnion_singleton,\n  bind_assoc            := \u03bb \u03b1 \u03b2 \u03b3 s f g, by simp only [bind_def, bUnion_Union],\n  bind_pure_comp_eq_map := \u03bb \u03b1 \u03b2 f s, (image_eq_Union _ _).symm,\n  bind_map_eq_seq       := \u03bb \u03b1 \u03b2 s t, seq_def.symm }\n\ninstance : is_comm_applicative (set : Type u \u2192 Type u) :=\n\u27e8 \u03bb \u03b1 \u03b2 s t, prod_image_seq_comm s t \u27e9\n\ninstance : alternative set :=\n{ orelse := \u03bb \u03b1, (\u222a),\n  failure := \u03bb \u03b1, \u2205,\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 `\u27e8X, b\u27e9`, 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\nnoncomputable theory\n\nnamespace category_theory\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] [monoidal_category C]\n\n/--\nA half-braiding on `X : C` is a family of isomorphisms `X \u2297 U \u2245 U \u2297 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(\u03b2 : \u03a0 U, X \u2297 U \u2245 U \u2297 X)\n(monoidal' : \u2200 U U', (\u03b2 (U \u2297 U')).hom =\n  (\u03b1_ _ _ _).inv \u226b ((\u03b2 U).hom \u2297 \ud835\udfd9 U') \u226b (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 U \u2297 (\u03b2 U').hom) \u226b (\u03b1_ _ _ _).inv\n  . obviously)\n(naturality' : \u2200 {U U'} (f : U \u27f6 U'), (\ud835\udfd9 X \u2297 f) \u226b (\u03b2 U').hom = (\u03b2 U).hom \u226b (f \u2297 \ud835\udfd9 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 `\u27e8X, b\u27e9`, where `X : C`\nand `b` is a half-braiding on `X`.\n-/\n@[nolint has_inhabited_instance]\ndef center := \u03a3 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 \u27f6 Y.1)\n(comm' : \u2200 U, (f \u2297 \ud835\udfd9 U) \u226b (Y.2.\u03b2 U).hom = (X.2.\u03b2 U).hom \u226b (\ud835\udfd9 U \u2297 f) . obviously)\n\nrestate_axiom hom.comm'\nattribute [simp, reassoc] hom.comm\n\ninstance : category (center C) :=\n{ hom := hom,\n  id := \u03bb X, { f := \ud835\udfd9 X.1, },\n  comp := \u03bb X Y Z f g, { f := f.f \u226b g.f, }, }\n\n@[simp] lemma id_f (X : center C) : hom.f (\ud835\udfd9 X) = \ud835\udfd9 X.1 := rfl\n@[simp] lemma comp_f {X Y Z : center C} (f : X \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g).f = f.f \u226b g.f := rfl\n\n@[ext]\nlemma ext {X Y : center C} (f g : X \u27f6 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 \u27f6 Y) [is_iso f.f] : X \u2245 Y :=\n{ hom := f,\n  inv := \u27e8inv f.f, \u03bb U, by simp [\u2190cancel_epi (f.f \u2297 \ud835\udfd9 U), \u2190comp_tensor_id_assoc, \u2190id_tensor_comp]\u27e9 }\n\ninstance is_iso_of_f_is_iso {X Y : center C} (f : X \u27f6 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\u27e8X.1 \u2297 Y.1,\n  { \u03b2 := \u03bb U, \u03b1_ _ _ _ \u226a\u226b (iso.refl X.1 \u2297 Y.2.\u03b2 U) \u226a\u226b (\u03b1_ _ _ _).symm\n      \u226a\u226b (X.2.\u03b2 U \u2297 iso.refl Y.1) \u226a\u226b \u03b1_ _ _ _,\n    monoidal' := \u03bb 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, \u2190pentagon_assoc,\n        \u2190id_tensor_comp_assoc, iso.hom_inv_id, tensor_id, category.id_comp,\n        \u2190associator_naturality_assoc, cancel_epi, cancel_epi,\n        \u2190associator_inv_naturality_assoc (X.2.\u03b2 U).hom,\n        associator_inv_naturality_assoc _ _ (Y.2.\u03b2 U').hom, tensor_id, tensor_id,\n        id_tensor_comp_tensor_id_assoc, associator_naturality_assoc (X.2.\u03b2 U).hom,\n        \u2190associator_naturality_assoc _ _ (Y.2.\u03b2 U').hom, tensor_id, tensor_id,\n        tensor_id_comp_id_tensor_assoc, \u2190id_tensor_comp_tensor_id, tensor_id, category.comp_id,\n        \u2190is_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, \u2190is_iso.inv_comp_eq, is_iso.iso.inv_hom,\n        \u2190pentagon_inv_assoc, \u2190comp_tensor_id_assoc, iso.inv_hom_id, tensor_id, category.id_comp,\n        \u2190associator_inv_naturality_assoc, cancel_epi, cancel_epi, \u2190is_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' := \u03bb U U' f,\n    begin\n      dsimp,\n      rw [category.assoc, category.assoc, category.assoc, category.assoc,\n        id_tensor_associator_naturality_assoc, \u2190id_tensor_comp_assoc, half_braiding.naturality,\n        id_tensor_comp_assoc, associator_inv_naturality_assoc, \u2190comp_tensor_id_assoc,\n        half_braiding.naturality, comp_tensor_id_assoc, associator_naturality, \u2190tensor_id],\n    end, }\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\n@[simps]\ndef tensor_hom {X\u2081 Y\u2081 X\u2082 Y\u2082 : center C} (f : X\u2081 \u27f6 Y\u2081) (g : X\u2082 \u27f6 Y\u2082) :\n  tensor_obj X\u2081 X\u2082 \u27f6 tensor_obj Y\u2081 Y\u2082 :=\n{ f := f.f \u2297 g.f,\n  comm' := \u03bb U, begin\n    dsimp,\n    rw [category.assoc, category.assoc, category.assoc, category.assoc,\n      associator_naturality_assoc, \u2190tensor_id_comp_id_tensor, category.assoc,\n      \u2190id_tensor_comp_assoc, g.comm, id_tensor_comp_assoc, tensor_id_comp_id_tensor_assoc,\n      \u2190id_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, \u2190tensor_id_comp_id_tensor g.f, category.assoc,\n      \u2190comp_tensor_id_assoc, f.comm, comp_tensor_id_assoc, id_tensor_associator_naturality,\n      associator_naturality_assoc, \u2190id_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\u27e8\ud835\udfd9_ C,\n  { \u03b2 := \u03bb U, (\u03bb_ U) \u226a\u226b (\u03c1_ U).symm,\n    monoidal' := \u03bb U U', by simp,\n    naturality' := \u03bb U U' f, begin\n      dsimp,\n      rw [left_unitor_naturality_assoc, right_unitor_inv_naturality, category.assoc],\n    end, }\u27e9\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 \u2245 tensor_obj X (tensor_obj Y Z) :=\niso_mk \u27e8(\u03b1_ X.1 Y.1 Z.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [category.assoc, comp_tensor_id, id_tensor_comp],\n  rw [pentagon, pentagon_assoc, \u2190associator_naturality_assoc (\ud835\udfd9 X.1) (\ud835\udfd9 Y.1), tensor_id, cancel_epi,\n    cancel_epi, iso.eq_inv_comp, \u2190pentagon_assoc, \u2190id_tensor_comp_assoc, iso.hom_inv_id, tensor_id,\n    category.id_comp, \u2190associator_naturality_assoc, cancel_epi, cancel_epi, \u2190is_iso.inv_comp_eq,\n    inv_tensor, is_iso.inv_id, is_iso.iso.inv_inv, pentagon_assoc, iso.hom_inv_id_assoc, \u2190tensor_id,\n    \u2190associator_naturality_assoc],\nend\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef left_unitor (X : center C) : tensor_obj tensor_unit X \u2245 X :=\niso_mk \u27e8(\u03bb_ X.1).hom, \u03bb 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 [\u2190left_unitor_tensor, left_unitor_naturality, left_unitor_tensor'_assoc],\nend\u27e9\n\n/-- Auxiliary definition for the `monoidal_category` instance on `center C`. -/\ndef right_unitor (X : center C) : tensor_obj X tensor_unit \u2245 X :=\niso_mk \u27e8(\u03c1_ X.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [tensor_id_comp_id_tensor_assoc, triangle_assoc, id_tensor_comp, category.assoc],\n  rw [\u2190tensor_id_comp_id_tensor_assoc (\u03c1_ U).inv, cancel_epi, \u2190right_unitor_tensor_inv_assoc,\n    \u2190right_unitor_inv_naturality_assoc],\n  simp,\nend\u27e9\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 := \u03bb X Y, tensor_obj X Y,\n  tensor_hom := \u03bb X\u2081 Y\u2081 X\u2082 Y\u2082 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 \u2297 Y).1 = X.1 \u2297 Y.1 := rfl\n\n@[simp] lemma tensor_\u03b2 (X Y : center C) (U : C) :\n  (X \u2297 Y).2.\u03b2 U =\n    \u03b1_ _ _ _ \u226a\u226b (iso.refl X.1 \u2297 Y.2.\u03b2 U) \u226a\u226b (\u03b1_ _ _ _).symm\n      \u226a\u226b (X.2.\u03b2 U \u2297 iso.refl Y.1) \u226a\u226b \u03b1_ _ _ _ :=\nrfl\n@[simp] \n\n@[simp] lemma tensor_unit_\u03b2 (U : C) : (\ud835\udfd9_ (center C)).2.\u03b2 U = (\u03bb_ U) \u226a\u226b (\u03c1_ U).symm := rfl\n\n@[simp] lemma associator_hom_f (X Y Z : center C) : hom.f (\u03b1_ X Y Z).hom = (\u03b1_ X.1 Y.1 Z.1).hom :=\nrfl\n\n@[simp] lemma associator_inv_f (X Y Z : center C) : hom.f (\u03b1_ X Y Z).inv = (\u03b1_ X.1 Y.1 Z.1).inv :=\nby { ext, rw [\u2190associator_hom_f, \u2190comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma left_unitor_hom_f (X : center C) : hom.f (\u03bb_ X).hom = (\u03bb_ X.1).hom :=\nrfl\n\n@[simp] lemma left_unitor_inv_f (X : center C) : hom.f (\u03bb_ X).inv = (\u03bb_ X.1).inv :=\nby { ext, rw [\u2190left_unitor_hom_f, \u2190comp_f, iso.hom_inv_id], refl, }\n\n@[simp] lemma right_unitor_hom_f (X : center C) : hom.f (\u03c1_ X).hom = (\u03c1_ X.1).hom :=\nrfl\n\n@[simp] lemma right_unitor_inv_f (X : center C) : hom.f (\u03c1_ X).inv = (\u03c1_ X.1).inv :=\nby { ext, rw [\u2190right_unitor_hom_f, \u2190comp_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 := \u03bb X, X.1,\n  map := \u03bb X Y f, f.f,\n  \u03b5 := \ud835\udfd9 (\ud835\udfd9_ C),\n  \u03bc := \u03bb X Y, \ud835\udfd9 (X.1 \u2297 Y.1), }\n\ninstance : reflects_isomorphisms (forget C).to_functor :=\n{ reflects := \u03bb 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 \u2297 Y \u2245 Y \u2297 X :=\niso_mk \u27e8(X.2.\u03b2 Y.1).hom, \u03bb U, begin\n  dsimp,\n  simp only [category.assoc],\n  rw [\u2190is_iso.inv_comp_eq, is_iso.iso.inv_hom, \u2190half_braiding.monoidal_assoc,\n    \u2190half_braiding.naturality_assoc, half_braiding.monoidal],\n  simp,\nend\u27e9\n\ninstance braided_category_center : braided_category (center C) :=\n{ braiding := braiding,\n  braiding_naturality' := \u03bb X Y X' Y' f g, begin\n    ext,\n    dsimp,\n    rw [\u2190tensor_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\u27e8X, { \u03b2 := \u03bb Y, \u03b2_ X Y,\n  monoidal' := \u03bb U U', begin\n    rw [iso.eq_inv_comp, \u2190category.assoc, \u2190category.assoc, iso.eq_comp_inv,\n      category.assoc, category.assoc],\n    exact hexagon_forward X U U',\n  end }\u27e9\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 := \u03bb X X' f,\n  { f := f,\n    comm' := \u03bb U, braiding_naturality _ _, },\n  \u03b5 :=\n  { f := \ud835\udfd9 _,\n    comm' := \u03bb U, begin\n      dsimp,\n      rw [tensor_id, category.id_comp, tensor_id, category.comp_id, \u2190braiding_right_unitor,\n        category.assoc, iso.hom_inv_id, category.comp_id],\n    end, },\n  \u03bc := \u03bb X Y,\n  { f := \ud835\udfd9 _,\n    comm' := \u03bb U, begin\n      dsimp,\n      rw [tensor_id, tensor_id, category.id_comp, category.comp_id,\n        \u2190iso.inv_comp_eq, \u2190category.assoc, \u2190category.assoc, \u2190iso.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 `\u03bc.inv : A \u21a6 \u03bc(A\u207b\u00b9)` and show that it is right invariant iff\n  `\u03bc` is left invariant.\n* We define a class `is_haar_measure \u03bc`, requiring that the measure `\u03bc` 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 `\u03bc` 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 (\u03bc : set G \u2192 \u211d\u22650\u221e) : Prop :=\n\u2200 (g : G) {A : set G} (h : measurable_set A), \u03bc ((\u03bb h, g * h) \u207b\u00b9' A) = \u03bc A\n\n/-- A measure `\u03bc` 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 (\u03bc : set G \u2192 \u211d\u22650\u221e) : Prop :=\n\u2200 (g : G) {A : set G} (h : measurable_set A), \u03bc ((\u03bb h, h * g) \u207b\u00b9' A) = \u03bc A\n\n@[to_additive measure_theory.is_add_left_invariant.smul]\nlemma is_mul_left_invariant.smul {\u03bc : measure G} (h : is_mul_left_invariant \u03bc) (c : \u211d\u22650\u221e) :\n  is_mul_left_invariant ((c \u2022 \u03bc : measure G) : set G \u2192 \u211d\u22650\u221e) :=\n\u03bb 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 {\u03bc : measure G} (h : is_mul_right_invariant \u03bc) (c : \u211d\u22650\u221e) :\n  is_mul_right_invariant ((c \u2022 \u03bc : measure G) : set G \u2192 \u211d\u22650\u221e) :=\n\u03bb 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  {\u03bc : measure G} : (\u2200 g, measure.map ((*) g) \u03bc = \u03bc) \u2194 is_mul_left_invariant \u03bc :=\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  {\u03bc : measure G} (h : is_mul_left_invariant \u03bc) (g : G) (A : set G) :\n  \u03bc ((\u03bb h, g * h) \u207b\u00b9' A) = \u03bc A :=\ncalc \u03bc ((\u03bb h, g * h) \u207b\u00b9' A) = measure.map (\u03bb h, g * h) \u03bc A :\n  ((homeomorph.mul_left g).to_measurable_equiv.map_apply A).symm\n... = \u03bc 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  {\u03bc : measure G} :\n  (\u2200 g, measure.map (\u03bb h, h * g) \u03bc = \u03bc) \u2194 is_mul_right_invariant \u03bc :=\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 \u21a6 \u03bc (A\u207b\u00b9)`, where `A\u207b\u00b9` is the pointwise inverse of `A`. -/\n@[to_additive \"The measure `A \u21a6 \u03bc (- A)`, where `- A` is the pointwise negation of `A`.\"]\nprotected def inv [has_inv G] (\u03bc : measure G) : measure G :=\nmeasure.map inv \u03bc\n\nvariables [group G] [topological_space G] [topological_group G] [borel_space G]\n\n@[to_additive]\nlemma inv_apply (\u03bc : measure G) (s : set G) :\n  \u03bc.inv s = \u03bc s\u207b\u00b9 :=\n(measurable_equiv.inv G).map_apply s\n\n@[simp, to_additive] protected lemma inv_inv (\u03bc : measure G) : \u03bc.inv.inv = \u03bc :=\n(measurable_equiv.inv G).map_symm_map\n\nvariables {\u03bc : measure G}\n\n@[to_additive]\ninstance regular.inv [t2_space G] [regular \u03bc] : regular \u03bc.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  {\u03bc : measure G}\n\n@[simp, to_additive] lemma regular_inv_iff [t2_space G] : \u03bc.inv.regular \u2194 \u03bc.regular :=\nbegin\n  split,\n  { introI h,\n    rw \u2190\u03bc.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 \u03bc) :\n  is_mul_right_invariant \u03bc.inv :=\nbegin\n  intros g A hA,\n  rw [\u03bc.inv_apply, \u03bc.inv_apply],\n  convert h g\u207b\u00b9 (measurable_inv hA) using 2,\n  simp only [\u2190preimage_comp, \u2190 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 \u03bc) : is_mul_left_invariant \u03bc.inv :=\nbegin\n  intros g A hA,\n  rw [\u03bc.inv_apply, \u03bc.inv_apply],\n  convert h g\u207b\u00b9 (measurable_inv hA) using 2,\n  simp only [\u2190preimage_comp, \u2190 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 \u03bc.inv \u2194 is_mul_left_invariant \u03bc :=\n\u27e8\u03bb h, by { rw \u2190 \u03bc.inv_inv, exact h.inv }, \u03bb h, h.inv\u27e9\n\n@[simp, to_additive]\nlemma is_mul_left_invariant_inv : is_mul_left_invariant \u03bc.inv \u2194 is_mul_right_invariant \u03bc :=\n\u27e8\u03bb h, by { rw \u2190 \u03bc.inv_inv, exact h.inv }, \u03bb h, h.inv\u27e9\n\nend inv\n\nsection group\n\nvariables [measurable_space G] [topological_space G] [borel_space G] {\u03bc : 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\u03bc : is_mul_left_invariant \u03bc)\n  (K : set G) (hK : is_compact K) (h : \u03bc K \u2260 0) {U : set G} (hU : is_open U) (h'U : U.nonempty) :\n  0 < \u03bc U :=\nbegin\n  contrapose! h,\n  rw \u2190 nonpos_iff_eq_zero,\n  rw nonpos_iff_eq_zero at h,\n  rw \u2190 hU.interior_eq at h'U,\n  obtain \u27e8t, hKt\u27e9 : \u2203 (t : finset G), K \u2286 \u22c3 (g : G) (H : g \u2208 t), (\u03bb (h : G), g * h) \u207b\u00b9' U :=\n    compact_covered_by_mul_left_translates hK h'U,\n  calc \u03bc K \u2264 \u03bc (\u22c3 (g : G) (H : g \u2208 t), (\u03bb (h : G), g * h) \u207b\u00b9' U) : measure_mono hKt\n  ... \u2264 \u2211 g in t, \u03bc ((\u03bb (h : G), g * h) \u207b\u00b9' U) : measure_bUnion_finset_le _ _\n  ... = 0 : by simp [h\u03bc _ 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 \u03bc] (h\u03bc : is_mul_left_invariant \u03bc)\n  (h3\u03bc : \u03bc \u2260 0) {s : set G} (hs : is_open s) :\n  \u03bc s = 0 \u2194 s = \u2205 :=\nbegin\n  obtain \u27e8K, hK, h2K\u27e9 := regular.exists_compact_not_null.mpr h3\u03bc,\n  refine \u27e8\u03bb h, _, \u03bb h, by simp only [h, measure_empty]\u27e9,\n  contrapose h,\n  exact (h\u03bc.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 \u03bc] (h2\u03bc : is_mul_left_invariant \u03bc)\n  {s : set G} (hs : is_open s) :\n  \u03bc s = 0 \u2194 s = \u2205 \u2228 \u03bc = 0 :=\nbegin\n  by_cases h3\u03bc : \u03bc = 0, { simp [h3\u03bc] },\n  simp only [h3\u03bc, or_false],\n  exact h2\u03bc.null_iff_empty h3\u03bc hs,\nend\n\n@[to_additive]\nlemma is_mul_left_invariant.measure_ne_zero_iff_nonempty [regular \u03bc]\n  (h2\u03bc : is_mul_left_invariant \u03bc) (h3\u03bc : \u03bc \u2260 0) {s : set G} (hs : is_open s) :\n  \u03bc s \u2260 0 \u2194 s.nonempty :=\nby simp_rw [\u2190 ne_empty_iff_nonempty, ne.def, h2\u03bc.null_iff_empty h3\u03bc hs]\n\n@[to_additive]\nlemma is_mul_left_invariant.measure_pos_iff_nonempty [regular \u03bc]\n  (h2\u03bc : is_mul_left_invariant \u03bc) (h3\u03bc : \u03bc \u2260 0) {s : set G} (hs : is_open s) :\n  0 < \u03bc s \u2194 s.nonempty :=\npos_iff_ne_zero.trans $ h2\u03bc.measure_ne_zero_iff_nonempty h3\u03bc 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\u03bc : is_mul_left_invariant \u03bc)\n  (U : set G) (hU : is_open U) (h'U : U.nonempty) (h : \u03bc U \u2260 \u221e) {K : set G} (hK : is_compact K) :\n  \u03bc K < \u221e :=\nbegin\n  rw \u2190 hU.interior_eq at h'U,\n  obtain \u27e8t, hKt\u27e9 : \u2203 (t : finset G), K \u2286 \u22c3 (g : G) (H : g \u2208 t), (\u03bb (h : G), g * h) \u207b\u00b9' U :=\n    compact_covered_by_mul_left_translates hK h'U,\n  calc \u03bc K \u2264 \u03bc (\u22c3 (g : G) (H : g \u2208 t), (\u03bb (h : G), g * h) \u207b\u00b9' U) : measure_mono hKt\n  ... \u2264 \u2211 g in t, \u03bc ((\u03bb (h : G), g * h) \u207b\u00b9' U) : measure_bUnion_finset_le _ _\n  ... = finset.card t * \u03bc U : by simp only [h\u03bc _ hU.measurable_set, finset.sum_const, nsmul_eq_mul]\n  ... < \u221e : 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\u03bc : is_mul_left_invariant \u03bc)\n  (U : set G) (hU : (interior U).nonempty) (h : \u03bc U \u2260 \u221e) {K : set G} (hK : is_compact K) :\n  \u03bc K < \u221e :=\nh\u03bc.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 \u03bc]\n  (h2\u03bc : is_mul_left_invariant \u03bc) (h3\u03bc : \u03bc \u2260 0) {f : G \u2192 \u211d\u22650\u221e} (hf : continuous f) :\n  \u222b\u207b x, f x \u2202\u03bc = 0 \u2194 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 \u27e8r, h1r, h2r\u27e9 : \u2203 r : \u211d\u22650\u221e, 0 < r \u2227 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 [\u2190 ne.def, \u2190 pos_iff_ne_zero],\n  have : 0 < r * \u03bc (f \u207b\u00b9' Ioi r),\n  { have : (f \u207b\u00b9' Ioi r).nonempty, from \u27e8x, h2r\u27e9,\n    simpa [h1r.ne', h2\u03bc.measure_pos_iff_nonempty h3\u03bc h3r, h1r] },\n  refine this.trans_le _,\n  rw [\u2190 set_lintegral_const, \u2190 lintegral_indicator _ h3r.measurable_set],\n  apply lintegral_mono,\n  refine indicator_le (\u03bb y, le_of_lt),\nend\n\nend group\n\nsection integration\n\nvariables [measurable_space G] [topological_space G] [borel_space G] {\u03bc : 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\u03bc : is_mul_left_invariant \u03bc) (f : G \u2192 \u211d\u22650\u221e) (g : G) :\n  \u222b\u207b x, f (g * x) \u2202\u03bc = \u222b\u207b x, f x \u2202\u03bc :=\nbegin\n  have : measure.map (has_mul.mul g) \u03bc = \u03bc,\n  { rw \u2190 map_mul_left_eq_self at h\u03bc,\n    exact h\u03bc 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\u03bc : is_mul_right_invariant \u03bc) (f : G \u2192 \u211d\u22650\u221e) (g : G) :\n  \u222b\u207b x, f (x * g) \u2202\u03bc = \u222b\u207b x, f x \u2202\u03bc :=\nbegin\n  have : measure.map (\u03bb g', g' * g) \u03bc = \u03bc,\n  { rw \u2190 map_mul_right_eq_self at h\u03bc,\n    exact h\u03bc 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  (\u03bc : measure G) : Prop :=\n(left_invariant : is_mul_left_invariant \u03bc)\n(compact_lt_top : \u2200 (K : set G), is_compact K \u2192 \u03bc K < \u221e)\n(open_pos : \u2200 (U : set G), is_open U \u2192 U.nonempty \u2192 0 < \u03bc 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  (\u03bc : measure G) : Prop :=\n(add_left_invariant : is_add_left_invariant \u03bc)\n(compact_lt_top : \u2200 (K : set G), is_compact K \u2192 \u03bc K < \u221e)\n(open_pos : \u2200 (U : set G), is_open U \u2192 U.nonempty \u2192 0 < \u03bc U)\n\nattribute [to_additive] is_haar_measure\n\nsection\n\nvariables [group G] [measurable_space G] [topological_space G] (\u03bc : measure G) [is_haar_measure \u03bc]\n\n@[to_additive]\nlemma _root_.is_compact.haar_lt_top {K : set G} (hK : is_compact K) :\n  \u03bc K < \u221e :=\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 < \u03bc 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 < \u03bc U :=\nlt_of_lt_of_le (is_open_interior.haar_pos \u03bc hU) (measure_mono (interior_subset))\n\n@[to_additive]\nlemma is_mul_left_invariant_haar : is_mul_left_invariant \u03bc :=\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  \u03bc ((\u03bb h, g * h) \u207b\u00b9' A) = \u03bc A :=\n(is_mul_left_invariant_haar \u03bc).measure_preimage_mul _ _\n\n@[simp, to_additive]\nlemma haar_singleton [topological_group G] [borel_space G] (g : G) :\n  \u03bc {g} = \u03bc {(1 : G)} :=\nbegin\n  convert haar_preimage_mul \u03bc (g\u207b\u00b9) _,\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] (\u03bc : measure G) [is_haar_measure \u03bc]\n  [topological_group G] [borel_space G] (g : G) (A : set G) :\n  \u03bc ((\u03bb h, h * g) \u207b\u00b9' A) = \u03bc A :=\nby simp_rw [mul_comm, haar_preimage_mul \u03bc g A]\n\n@[to_additive measure_theory.measure.is_add_haar_measure.smul]\nlemma is_haar_measure.smul {c : \u211d\u22650\u221e} (cpos : c \u2260 0) (ctop : c \u2260 \u221e) :\n  is_haar_measure (c \u2022 \u03bc) :=\n{ left_invariant := (is_mul_left_invariant_haar \u03bc).smul _,\n  compact_lt_top := \u03bb K hK, begin\n    change c * \u03bc K < \u221e,\n    simp [lt_top_iff_ne_top, (hK.haar_lt_top \u03bc).ne, cpos, ctop],\n  end,\n  open_pos := \u03bb U U_open U_ne, bot_lt_iff_ne_bot.2 $ begin\n    change c * \u03bc U \u2260 0,\n    simp [cpos, (_root_.is_open.haar_pos \u03bc 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  (\u03bc : measure G) (h\u03bc : is_mul_left_invariant \u03bc)\n  (K : set G) (hK : is_compact K) (h'K : (interior K).nonempty) (h : \u03bc K \u2260 0) (h' : \u03bc K \u2260 \u221e) :\n  is_haar_measure \u03bc :=\n{ left_invariant := h\u03bc,\n  compact_lt_top := \u03bb L hL, h\u03bc.measure_lt_top_of_is_compact' _ h'K h' hL,\n  open_pos := \u03bb U hU, h\u03bc.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 \u2243* H) (hf : continuous f) (hfsymm : continuous f.symm) :\n  is_haar_measure (measure.map f \u03bc) :=\n{ left_invariant := begin\n    rw \u2190 map_mul_left_eq_self,\n    assume h,\n    rw map_map (continuous_mul_left h).measurable hf.measurable,\n    conv_rhs { rw \u2190 map_mul_left_eq_self.2 (is_mul_left_invariant_haar \u03bc) (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 \u207b\u00b9' K := equiv.image_eq_preimage _ _,\n    rw \u2190 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 \u207b\u00b9' U := equiv.image_eq_preimage _ _,\n    rw \u2190 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  (\u03bc : measure G) [\u03bc.is_haar_measure] :\n  sigma_finite \u03bc :=\n\u27e8\u27e8{ set := compact_covering G,\n  set_mem := \u03bb n, mem_univ _,\n  finite := \u03bb n, is_compact.haar_lt_top \u03bc $ is_compact_compact_covering G n,\n  spanning := Union_compact_covering G }\u27e9\u27e9\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] [(\ud835\udcdd[{(1 : G)}\u1d9c] (1 : G)).ne_bot]\n  (\u03bc : measure G) [\u03bc.is_haar_measure] :\n  has_no_atoms \u03bc :=\nbegin\n  suffices H : \u03bc {(1 : G)} \u2264 0, by { constructor, simp [le_bot_iff.1 H] },\n  obtain \u27e8K, K_compact, K_int\u27e9 : \u2203 (K : set G), is_compact K \u2227 (1 : G) \u2208 interior K,\n  { rcases exists_compact_subset is_open_univ (mem_univ (1 : G)) with \u27e8K, hK\u27e9,\n    exact \u27e8K, hK.1, hK.2.1\u27e9 },\n  have K_inf : set.infinite K := infinite_of_mem_nhds (1 : G) (mem_interior_iff_mem_nhds.1 K_int),\n  have \u03bcKlt : \u03bc K \u2260 \u221e := (K_compact.haar_lt_top \u03bc).ne,\n  have I : \u2200 (n : \u2115), \u03bc {(1 : G)} \u2264 \u03bc K / n,\n  { assume n,\n    obtain \u27e8t, tK, tn\u27e9 : \u2203 (t : finset G), \u2191t \u2286 K \u2227 t.card = n := K_inf.exists_subset_card_eq n,\n    have A : \u03bc t \u2264 \u03bc K := measure_mono tK,\n    have B : \u03bc t = n * \u03bc {(1 : G)},\n    { rw \u2190 bUnion_of_singleton \u2191t,\n      change \u03bc (\u22c3 (x \u2208 t), {x}) = n * \u03bc {1},\n      rw @measure_bUnion_finset G G _ \u03bc t (\u03bb 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 \u03bcKlt), mul_comm],\n    right,\n    apply ne_of_gt (haar_pos_of_nonempty_interior \u03bc \u27e8_, K_int\u27e9) },\n  have J : tendsto (\u03bb (n : \u2115),  \u03bc K / n) at_top (\ud835\udcdd (\u03bc K / \u221e)) :=\n    ennreal.tendsto.const_div ennreal.tendsto_nat_nhds_top (or.inr \u03bcKlt),\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 \u211d E] [nontrivial E] [finite_dimensional \u211d E]\n  [measurable_space E] [borel_space E] (\u03bc : measure E) [is_add_haar_measure \u03bc] :\n  has_no_atoms \u03bc := 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 : \u2115) := [n, 7*n]\n\ndef Z : list \u2115 :=\ndo x \u2190 X,\n   y \u2190 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 : \u2115) := if 2 \u2223 n then some (n/2) else none\n\ndef Y (n : \u2115) :=\ndo n \u2190 h n,\n   n \u2190 h n,\n   n \u2190 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 := \u03bb \u03b1 \u03b2 o f, match o with | none := none | some a := f a end, map := \u03bb \u03b1 \u03b2 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 \u2115 :=\ndo x \u2190 X,\n   y \u2190 g x,\n   guard (3 \u2223 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\u03b1 \u2192 list \u03b1 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 \u2964 D` to another `G : C \u2964 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 \u27f6 Y`.\nThen the two arrows F X  \u2192 F Y \u2192 G Y and F X \u2192 G X \u2192 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 \u2964 Grp.\n\nA monad is a functor `T` from Type to Type, along with natural transformations\n`\u03b7 : 1 \u27f6 T` and `\u03bc : TT \u27f6 T`.\ni.e. for each Type \u03b1, the component of \u03b7 at \u03b1 is a function from \u03b1 \u2192 T \u03b1 (`pure`).\ni.e. for each Type \u03b1, the component of \u03bc at \u03b1 is a function from T T \u03b1 \u2192 T \u03b1.\n-/\n\ndef state_ (\u03c3 : Type) (\u03b1 : Type) := \u03c3 \u2192 \u03c3 \u00d7 \u03b1\n\ninstance (\u03c3 : Type) : monad (state_ \u03c3) :=\n{pure := \u03bb \u03b1 a s, (s, a),\n bind := \u03bb \u03b1 \u03b2 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 \u2190 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 \u2190 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 \u2227 1=1 :=\nbegin\n    split,\n    swap'',\n    refl,\n    trivial,\nend\n\nmeta def swap''' : tactic unit :=\ndo a :: b :: t \u2190 get_goals | fail \"There must be at least two goals!\",\n   set_goals [b,a]\n\nexample : true \u2227 true \u2227 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 \u2190 local_context,\n   trace ctx,\n   ctx.mmap infer_type >>= trace,\n   skip\n\nmeta def target' : tactic expr :=\ndo gs \u2190 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 \u2190 get_goals,\n   z \u2190 to_expr ``(0 : \u2115),\n   trace gs,\n   gs.mmap' (\u03bb g, try_core $ unify g z),\n   trace gs,\n   skip\n\nset_option pp.instantiate_mvars false\ndef bar : \u2115 \u00d7 \u2115 \u00d7 list \u2124 :=\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\u2081 v\u2082 v u u\u2082\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 \u2192 WalkingCospan \u2192 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 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 \u2192 WalkingSpan \u2192 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 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 \u2964 C} {s t : Cone F} (i : s.pt \u2245 t.pt)\n    (w\u2081 : s.\u03c0.app WalkingCospan.left = i.hom \u226b t.\u03c0.app WalkingCospan.left)\n    (w\u2082 : s.\u03c0.app WalkingCospan.right = i.hom \u226b t.\u03c0.app WalkingCospan.right) : s \u2245 t := by\n  apply Cones.ext i\n  rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9)\n  \u00b7 have h\u2081 := s.\u03c0.naturality WalkingCospan.Hom.inl\n    dsimp at h\u2081\n    simp only [Category.id_comp] at h\u2081\n    have h\u2082 := t.\u03c0.naturality WalkingCospan.Hom.inl\n    dsimp at h\u2082\n    simp only [Category.id_comp] at h\u2082\n    simp_rw [h\u2082, \u2190 Category.assoc, \u2190 w\u2081, \u2190 h\u2081]\n  \u00b7 exact w\u2081\n  \u00b7 exact w\u2082\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 \u2964 C} {s t : Cocone F} (i : s.pt \u2245 t.pt)\n    (w\u2081 : s.\u03b9.app WalkingCospan.left \u226b i.hom = t.\u03b9.app WalkingCospan.left)\n    (w\u2082 : s.\u03b9.app WalkingCospan.right \u226b i.hom = t.\u03b9.app WalkingCospan.right) : s \u2245 t := by\n  apply Cocones.ext i\n  rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9)\n  \u00b7 have h\u2081 := s.\u03b9.naturality WalkingSpan.Hom.fst\n    dsimp at h\u2081\n    simp only [Category.comp_id] at h\u2081\n    have h\u2082 := t.\u03b9.naturality WalkingSpan.Hom.fst\n    dsimp at h\u2082\n    simp only [Category.comp_id] at h\u2082\n    simp_rw [\u2190 h\u2081, Category.assoc, w\u2081, h\u2082]\n  \u00b7 exact w\u2081\n  \u00b7 exact w\u2082\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 \u27f6 Z) (g : Y \u27f6 Z) : WalkingCospan \u2964 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 \u27f6 Y) (g : X \u27f6 Z) : WalkingSpan \u2964 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 Z) (w : WalkingCospan) :\n    (cospan f g).map (WalkingCospan.Hom.id w) = \ud835\udfd9 _ := 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 \u27f6 Y) (g : X \u27f6 Z) (w : WalkingSpan) :\n    (span f g).map (WalkingSpan.Hom.id w) = \ud835\udfd9 _ := 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 \u2964 C) : F \u2245 cospan (F.map inl) (F.map inr) :=\n  NatIso.ofComponents\n  (fun j => eqToIso (by rcases j with (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) <;> rfl))\n  (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) 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 \u2964 C) : F \u2245 span (F.map fst) (F.map snd) :=\n  NatIso.ofComponents\n  (fun j => eqToIso (by rcases j with (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) <;> rfl))\n  (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) f <;> cases f <;> dsimp <;> simp)\n#align category_theory.limits.diagram_iso_span CategoryTheory.Limits.diagramIsoSpan\n\nvariable {D : Type u\u2082} [Category.{v\u2082} D]\n\n/-- A functor applied to a cospan is a cospan. -/\ndef cospanCompIso (F : C \u2964 D) {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z) :\n    cospan f g \u22d9 F \u2245 cospan (F.map f) (F.map g) :=\n  NatIso.ofComponents (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) <;> exact Iso.refl _)\n    (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) f <;> cases f <;> dsimp <;> simp)\n#align category_theory.limits.cospan_comp_iso CategoryTheory.Limits.cospanCompIso\n\nsection\n\nvariable (F : C \u2964 D) {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 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 = \ud835\udfd9 _ :=\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 = \ud835\udfd9 _ :=\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 = \ud835\udfd9 _ := 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 = \ud835\udfd9 _ :=\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 = \ud835\udfd9 _ :=\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 = \ud835\udfd9 _ := 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 \u2964 D) {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z) :\n    span f g \u22d9 F \u2245 span (F.map f) (F.map g) :=\n  NatIso.ofComponents (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) <;> exact Iso.refl _)\n    (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) f <;> cases f <;> dsimp <;> simp)\n#align category_theory.limits.span_comp_iso CategoryTheory.Limits.spanCompIso\n\nsection\n\nvariable (F : C \u2964 D) {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 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 = \ud835\udfd9 _ := 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 = \ud835\udfd9 _ := 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 = \ud835\udfd9 _ := 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 = \ud835\udfd9 _ := 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 = \ud835\udfd9 _ := 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 = \ud835\udfd9 _ := 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 \u2245 X') (iY : Y \u2245 Y') (iZ : Z \u2245 Z')\n\nsection\n\nvariable {f : X \u27f6 Z} {g : Y \u27f6 Z} {f' : X' \u27f6 Z'} {g' : Y' \u27f6 Z'}\n\n/-- Construct an isomorphism of cospans from components. -/\ndef cospanExt (wf : iX.hom \u226b f' = f \u226b iZ.hom) (wg : iY.hom \u226b g' = g \u226b iZ.hom) :\n    cospan f g \u2245 cospan f' g' :=\n  NatIso.ofComponents\n    (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9); exacts [iZ, iX, iY])\n    (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) f <;> cases f <;> dsimp <;> simp [wf, wg])\n#align category_theory.limits.cospan_ext CategoryTheory.Limits.cospanExt\n\nvariable (wf : iX.hom \u226b f' = f \u226b iZ.hom) (wg : iY.hom \u226b g' = g \u226b 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 \u27f6 Y} {g : X \u27f6 Z} {f' : X' \u27f6 Y'} {g' : X' \u27f6 Z'}\n\n/-- Construct an isomorphism of spans from components. -/\ndef spanExt (wf : iX.hom \u226b f' = f \u226b iY.hom) (wg : iX.hom \u226b g' = g \u226b iZ.hom) :\n    span f g \u2245 span f' g' :=\n  NatIso.ofComponents (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9); exacts [iX, iY, iZ])\n    (by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) f <;> cases f <;> dsimp <;> simp [wf, wg])\n#align category_theory.limits.span_ext CategoryTheory.Limits.spanExt\n\nvariable (wf : iX.hom \u226b f' = f \u226b iY.hom) (wg : iX.hom \u226b g' = g \u226b 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 \u27f6 Z` and\n    `g : Y \u27f6 Z`.-/\nabbrev PullbackCone (f : X \u27f6 Z) (g : Y \u27f6 Z) :=\n  Cone (cospan f g)\n#align category_theory.limits.pullback_cone CategoryTheory.Limits.PullbackCone\n\nnamespace PullbackCone\n\nvariable {f : X \u27f6 Z} {g : Y \u27f6 Z}\n\n/-- The first projection of a pullback cone. -/\nabbrev fst (t : PullbackCone f g) : t.pt \u27f6 X :=\n  t.\u03c0.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 \u27f6 Y :=\n  t.\u03c0.app WalkingCospan.right\n#align category_theory.limits.pullback_cone.snd CategoryTheory.Limits.PullbackCone.snd\n\n@[simp]\ntheorem \u03c0_app_left (c : PullbackCone f g) : c.\u03c0.app WalkingCospan.left = c.fst := rfl\n#align category_theory.limits.pullback_cone.\u03c0_app_left CategoryTheory.Limits.PullbackCone.\u03c0_app_left\n\n@[simp]\ntheorem \u03c0_app_right (c : PullbackCone f g) : c.\u03c0.app WalkingCospan.right = c.snd := rfl\n#align category_theory.limits.pullback_cone.\u03c0_app_right CategoryTheory.Limits.PullbackCone.\u03c0_app_right\n\n@[simp]\ntheorem condition_one (t : PullbackCone f g) : t.\u03c0.app WalkingCospan.one = t.fst \u226b f := by\n  have w := t.\u03c0.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 : \u2200 s : PullbackCone f g, s.pt \u27f6 t.pt)\n    (fac_left : \u2200 s : PullbackCone f g, lift s \u226b t.fst = s.fst)\n    (fac_right : \u2200 s : PullbackCone f g, lift s \u226b t.snd = s.snd)\n    (uniq : \u2200 (s : PullbackCone f g) (m : s.pt \u27f6 t.pt)\n      (_ : \u2200 j : WalkingCospan, m \u226b t.\u03c0.app j = s.\u03c0.app j), m = lift s) : IsLimit t :=\n  { lift\n    fac := fun s j => Option.casesOn j (by\n        rw [\u2190 s.w inl, \u2190 t.w inl, \u2190 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      \u2200 s : PullbackCone f g,\n        { l //\n          l \u226b t.fst = s.fst \u2227\n            l \u226b t.snd = s.snd \u2227 \u2200 {m}, m \u226b t.fst = s.fst \u2192 m \u226b t.snd = s.snd \u2192 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 \u27f6 X` and `snd : W \u27f6 Y`\n    such that `fst \u226b f = snd \u226b g`. -/\n@[simps]\ndef mk {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) : PullbackCone f g where\n  pt := W\n  \u03c0 := { app := fun j => Option.casesOn j (fst \u226b f) fun j' => WalkingPair.casesOn j' fst snd\n         naturality := by rintro (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) (\u27e8\u27e9 | \u27e8\u27e8\u27e9\u27e9) j <;> cases j <;> dsimp <;> simp [eq] }\n#align category_theory.limits.pullback_cone.mk CategoryTheory.Limits.PullbackCone.mk\n\n@[simp]\ntheorem mk_\u03c0_app_left {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n    (mk fst snd eq).\u03c0.app WalkingCospan.left = fst := rfl\n#align category_theory.limits.pullback_cone.mk_\u03c0_app_left CategoryTheory.Limits.PullbackCone.mk_\u03c0_app_left\n\n@[simp]\ntheorem mk_\u03c0_app_right {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n    (mk fst snd eq).\u03c0.app WalkingCospan.right = snd := rfl\n#align category_theory.limits.pullback_cone.mk_\u03c0_app_right CategoryTheory.Limits.PullbackCone.mk_\u03c0_app_right\n\n@[simp]\ntheorem mk_\u03c0_app_one {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b g) :\n    (mk fst snd eq).\u03c0.app WalkingCospan.one = fst \u226b f := rfl\n#align category_theory.limits.pullback_cone.mk_\u03c0_app_one CategoryTheory.Limits.PullbackCone.mk_\u03c0_app_one\n\n@[simp]\ntheorem mk_fst {W : C} (fst : W \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b 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 \u27f6 X) (snd : W \u27f6 Y) (eq : fst \u226b f = snd \u226b 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 \u226b f = snd t \u226b 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 \u27f6 t.pt} (h\u2080 : k \u226b fst t = l \u226b fst t)\n    (h\u2081 : k \u226b snd t = l \u226b snd t) : \u2200 j : WalkingCospan, k \u226b t.\u03c0.app j = l \u226b t.\u03c0.app j\n  | some WalkingPair.left => h\u2080\n  | some WalkingPair.right => h\u2081\n  | none => by rw [\u2190 t.w inl]; dsimp [h\u2080]; simp only [\u2190 Category.assoc, congrArg (\u00b7 \u226b f) h\u2080]\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 \u27f6 t.pt}\n    (h\u2080 : k \u226b fst t = l \u226b fst t) (h\u2081 : k \u226b snd t = l \u226b snd t) : k = l :=\n  ht.hom_ext <| equalizer_ext _ h\u2080 h\u2081\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 \u27e8fun {W} h k i => IsLimit.hom_ext ht ?_ i\u27e9\n  rw [\u2190 cancel_mono f, Category.assoc, Category.assoc, condition]\n  have := congrArg (\u00b7 \u226b 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 \u27e8fun {W} h k i => IsLimit.hom_ext ht i ?_\u27e9\n  rw [\u2190 cancel_mono g, Category.assoc, Category.assoc, \u2190condition]\n  have := congrArg (\u00b7 \u226b 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 \u2245 t.pt) (w\u2081 : s.fst = i.hom \u226b t.fst)\n    (w\u2082 : s.snd = i.hom \u226b t.snd) : s \u2245 t :=\n  WalkingCospan.ext i w\u2081 w\u2082\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 \u27f6 X` and `k : W \u27f6 Y` are such that\n    `h \u226b f = k \u226b g`, then we get `l : W \u27f6 t.pt`, which satisfies `l \u226b fst t = h`\n    and `l \u226b 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 \u27f6 X) (k : W \u27f6 Y)\n    (w : h \u226b f = k \u226b g) : W \u27f6 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 \u27f6 X) (k : W \u27f6 Y)\n    (w : h \u226b f = k \u226b g) : IsLimit.lift ht h k w \u226b 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 \u27f6 X) (k : W \u27f6 Y)\n    (w : h \u226b f = k \u226b g) : IsLimit.lift ht h k w \u226b snd t = k := ht.fac _ _\n\n/-- If `t` is a limit pullback cone over `f` and `g` and `h : W \u27f6 X` and `k : W \u27f6 Y` are such that\n    `h \u226b f = k \u226b g`, then we have `l : W \u27f6 t.pt` satisfying `l \u226b fst t = h` and `l \u226b snd t = k`.\n    -/\ndef IsLimit.lift' {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W \u27f6 X) (k : W \u27f6 Y)\n    (w : h \u226b f = k \u226b g) : { l : W \u27f6 t.pt // l \u226b fst t = h \u2227 l \u226b snd t = k } :=\n  \u27e8IsLimit.lift ht h k w, by simp\u27e9\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 \u27f6 X} {snd : W \u27f6 Y} (eq : fst \u226b f = snd \u226b g)\n    (lift : \u2200 s : PullbackCone f g, s.pt \u27f6 W)\n    (fac_left : \u2200 s : PullbackCone f g, lift s \u226b fst = s.fst)\n    (fac_right : \u2200 s : PullbackCone f g, lift s \u226b snd = s.snd)\n    (uniq :\n      \u2200 (s : PullbackCone f g) (m : s.pt \u27f6 W) (_ : m \u226b fst = s.fst) (_ : m \u226b 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 \u27f6 X} {k : W \u27f6 Y} {comm : h \u226b f = k \u226b g}\n    (t : IsLimit (mk _ _ comm.symm)) : IsLimit (mk _ _ comm) :=\n  isLimitAux' _ fun s =>\n    by\n    refine'\n      \u27e8(IsLimit.lift' t _ _ s.condition.symm).1, (IsLimit.lift' t _ _ _).2.2,\n        (IsLimit.lift' t _ _ _).2.1, fun m\u2081 m\u2082 => t.hom_ext _\u27e9\n    apply (mk k h _).equalizer_ext\n    \u00b7 rwa [(IsLimit.lift' t _ _ _).2.1]\n    \u00b7 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 `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y) [Mono f] : IsLimit (mk (\ud835\udfd9 X) (\ud835\udfd9 X) rfl : PullbackCone f f) :=\n  IsLimit.mk _ (fun s => s.fst) (fun s => Category.comp_id _)\n    (fun s => by rw [\u2190 cancel_mono f, Category.comp_id, s.condition]) fun s m m\u2081 _ => by\n    simpa using m\u2081\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 `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y) (t : IsLimit (mk (\ud835\udfd9 X) (\ud835\udfd9 X) rfl : PullbackCone f f)) :\n    Mono f :=\n  \u27e8fun {Z} g h eq => by\n    rcases PullbackCone.IsLimit.lift' t _ _ eq with \u27e8_, rfl, rfl\u27e9\n    rfl\u27e9\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 \u27f6 Z) (g : Y \u27f6 Z) (h : W \u27f6 Z) [Mono h] (x : X \u27f6 W) (y : Y \u27f6 W)\n    (hxh : x \u226b h = f) (hyh : y \u226b h = g) (s : PullbackCone f g) (hs : IsLimit s) :\n    IsLimit\n      (PullbackCone.mk _ _\n        (show s.fst \u226b x = s.snd \u226b 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 \u226b x \u226b h = snd t \u226b y \u226b h := by  -- Porting note: reassoc workaround\n      rw [\u2190 Category.assoc, \u2190 Category.assoc]\n      apply congrArg (\u00b7 \u226b h) t.condition\n    \u27e8hs.lift (PullbackCone.mk t.fst t.snd <| by rw [\u2190 hxh, \u2190 hyh, this]),\n      \u27e8hs.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'\u22a2 <;>\n            simp only [hr, hr'] <;>\n          symm\n        exacts[hs.fac _ WalkingCospan.left, hs.fac _ WalkingCospan.right]\u27e9\u27e9\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 \u226b i, g \u226b i` for any mono `i`. -/\ndef isLimitOfCompMono (f : X \u27f6 W) (g : Y \u27f6 W) (i : W \u27f6 Z) [Mono i] (s : PullbackCone f g)\n    (H : IsLimit s) :\n    IsLimit\n      (PullbackCone.mk _ _\n        (show s.fst \u226b f \u226b i = s.snd \u226b g \u226b i by\n          rw [\u2190 Category.assoc, \u2190 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    \u27e8l, h\u2081, h\u2082\u27e9\n  refine' \u27e8l, h\u2081, h\u2082, _\u27e9\n  intro m hm\u2081 hm\u2082\n  exact (PullbackCone.IsLimit.hom_ext H (hm\u2081.trans h\u2081.symm) (hm\u2082.trans h\u2082.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 \u27f6 Y` and\n    `g : X \u27f6 Z`.-/\nabbrev PushoutCocone (f : X \u27f6 Y) (g : X \u27f6 Z) :=\n  Cocone (span f g)\n#align category_theory.limits.pushout_cocone CategoryTheory.Limits.PushoutCocone\n\nnamespace PushoutCocone\n\nvariable {f : X \u27f6 Y} {g : X \u27f6 Z}\n\n/-- The first inclusion of a pushout cocone. -/\nabbrev inl (t : PushoutCocone f g) : Y \u27f6 t.pt :=\n  t.\u03b9.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 \u27f6 t.pt :=\n  t.\u03b9.app WalkingSpan.right\n#align category_theory.limits.pushout_cocone.inr CategoryTheory.Limits.PushoutCocone.inr\n\n@[simp]\ntheorem \u03b9_app_left (c : PushoutCocone f g) : c.\u03b9.app WalkingSpan.left = c.inl := rfl\n#align category_theory.limits.pushout_cocone.\u03b9_app_left CategoryTheory.Limits.PushoutCocone.\u03b9_app_left\n\n@[simp]\ntheorem \u03b9_app_right (c : PushoutCocone f g) : c.\u03b9.app WalkingSpan.right = c.inr := rfl\n#align category_theory.limits.pushout_cocone.\u03b9_app_right CategoryTheory.Limits.PushoutCocone.\u03b9_app_right\n\n@[simp]\ntheorem condition_zero (t : PushoutCocone f g) : t.\u03b9.app WalkingSpan.zero = f \u226b t.inl := by\n  have w := t.\u03b9.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 : \u2200 s : PushoutCocone f g, t.pt \u27f6 s.pt)\n    (fac_left : \u2200 s : PushoutCocone f g, t.inl \u226b desc s = s.inl)\n    (fac_right : \u2200 s : PushoutCocone f g, t.inr \u226b desc s = s.inr)\n    (uniq : \u2200 (s : PushoutCocone f g) (m : t.pt \u27f6 s.pt)\n    (_ : \u2200 j : WalkingSpan, t.\u03b9.app j \u226b m = s.\u03b9.app j), m = desc s) : IsColimit t :=\n  { desc\n    fac := fun s j =>\n      Option.casesOn j (by simp [\u2190 s.w fst, \u2190 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      \u2200 s : PushoutCocone f g,\n        { l //\n          t.inl \u226b l = s.inl \u2227\n            t.inr \u226b l = s.inr \u2227 \u2200 {m}, t.inl \u226b m = s.inl \u2192 t.inr \u226b m = s.inr \u2192 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 \u27f6 W` and `inr : Z \u27f6 W` such\n    that `f \u226b inl = g \u21a0 inr`. -/\n@[simps]\ndef mk {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) : PushoutCocone f g where\n  pt := W\n  \u03b9 := { app := fun j => Option.casesOn j (f \u226b inl) fun j' => WalkingPair.casesOn j' inl inr\n         naturality := by\n          rintro (\u27e8\u27e9|\u27e8\u27e8\u27e9\u27e9) (\u27e8\u27e9|\u27e8\u27e8\u27e9\u27e9) <;> intro f <;> cases f <;> dsimp <;> aesop }\n#align category_theory.limits.pushout_cocone.mk CategoryTheory.Limits.PushoutCocone.mk\n\n@[simp]\ntheorem mk_\u03b9_app_left {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n    (mk inl inr eq).\u03b9.app WalkingSpan.left = inl := rfl\n#align category_theory.limits.pushout_cocone.mk_\u03b9_app_left CategoryTheory.Limits.PushoutCocone.mk_\u03b9_app_left\n\n@[simp]\ntheorem mk_\u03b9_app_right {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n    (mk inl inr eq).\u03b9.app WalkingSpan.right = inr := rfl\n#align category_theory.limits.pushout_cocone.mk_\u03b9_app_right CategoryTheory.Limits.PushoutCocone.mk_\u03b9_app_right\n\n@[simp]\ntheorem mk_\u03b9_app_zero {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b inr) :\n    (mk inl inr eq).\u03b9.app WalkingSpan.zero = f \u226b inl := rfl\n#align category_theory.limits.pushout_cocone.mk_\u03b9_app_zero CategoryTheory.Limits.PushoutCocone.mk_\u03b9_app_zero\n\n@[simp]\ntheorem mk_inl {W : C} (inl : Y \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b 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 \u27f6 W) (inr : Z \u27f6 W) (eq : f \u226b inl = g \u226b 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 \u226b inl t = g \u226b 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 \u27f6 W}\n    (h\u2080 : inl t \u226b k = inl t \u226b l) (h\u2081 : inr t \u226b k = inr t \u226b l) :\n    \u2200 j : WalkingSpan, t.\u03b9.app j \u226b k = t.\u03b9.app j \u226b l\n  | some WalkingPair.left => h\u2080\n  | some WalkingPair.right => h\u2081\n  | none => by rw [\u2190 t.w fst, Category.assoc, Category.assoc, h\u2080]\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 \u27f6 W}\n    (h\u2080 : inl t \u226b k = inl t \u226b l) (h\u2081 : inr t \u226b k = inr t \u226b l) : k = l :=\n  ht.hom_ext <| coequalizer_ext _ h\u2080 h\u2081\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 \u27f6 W` and `k : Z \u27f6 W` are\n    morphisms satisfying `f \u226b h = g \u226b k`, then we have a factorization `l : t.pt \u27f6 W` such that\n    `inl t \u226b l = h` and `inr t \u226b l = k`, see `IsColimit.inl_desc` and `IsColimit.inr_desc`-/\ndef IsColimit.desc {t : PushoutCocone f g} (ht : IsColimit t) {W : C} (h : Y \u27f6 W) (k : Z \u27f6 W)\n    (w : f \u226b h = g \u226b k) : t.pt \u27f6 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 \u27f6 W) (k : Z \u27f6 W)\n    (w : f \u226b h = g \u226b k) : inl t \u226b 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 \u27f6 W) (k : Z \u27f6 W)\n    (w : f \u226b h = g \u226b k) : inr t \u226b 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 \u27f6 W` and `k : Z \u27f6 W` are\n    morphisms satisfying `f \u226b h = g \u226b k`, then we have a factorization `l : t.pt \u27f6 W` such that\n    `inl t \u226b l = h` and `inr t \u226b l = k`. -/\ndef IsColimit.desc' {t : PushoutCocone f g} (ht : IsColimit t) {W : C} (h : Y \u27f6 W) (k : Z \u27f6 W)\n    (w : f \u226b h = g \u226b k) : { l : t.pt \u27f6 W // inl t \u226b l = h \u2227 inr t \u226b l = k } :=\n  \u27e8IsColimit.desc ht h k w, by simp\u27e9\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  \u27e8fun {W} h k i => IsColimit.hom_ext ht (by simp [\u2190 cancel_epi f, t.condition_assoc, i]) i\u27e9\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  \u27e8fun {W} h k i => IsColimit.hom_ext ht i (by simp [\u2190 cancel_epi g, \u2190 t.condition_assoc, i])\u27e9\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 \u2245 t.pt) (w\u2081 : s.inl \u226b i.hom = t.inl)\n    (w\u2082 : s.inr \u226b i.hom = t.inr) : s \u2245 t :=\n  WalkingSpan.ext i w\u2081 w\u2082\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 \u27f6 W} {inr : Z \u27f6 W} (eq : f \u226b inl = g \u226b inr)\n    (desc : \u2200 s : PushoutCocone f g, W \u27f6 s.pt)\n    (fac_left : \u2200 s : PushoutCocone f g, inl \u226b desc s = s.inl)\n    (fac_right : \u2200 s : PushoutCocone f g, inr \u226b desc s = s.inr)\n    (uniq :\n      \u2200 (s : PushoutCocone f g) (m : W \u27f6 s.pt) (_ : inl \u226b m = s.inl) (_ : inr \u226b 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 \u27f6 W} {k : Z \u27f6 W} {comm : f \u226b h = g \u226b k}\n    (t : IsColimit (mk _ _ comm.symm)) : IsColimit (mk _ _ comm) :=\n  isColimitAux' _ fun s =>\n    by\n    refine'\n      \u27e8(IsColimit.desc' t _ _ s.condition.symm).1, (IsColimit.desc' t _ _ _).2.2,\n        (IsColimit.desc' t _ _ _).2.1, fun m\u2081 m\u2082 => t.hom_ext _\u27e9\n    apply (mk k h _).coequalizer_ext\n    \u00b7 rwa [(IsColimit.desc' t _ _ _).2.1]\n    \u00b7 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 `(\ud835\udfd9 X, \ud835\udfd9 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 \u27f6 Y) [Epi f] : IsColimit (mk (\ud835\udfd9 Y) (\ud835\udfd9 Y) rfl : PushoutCocone f f) :=\n  IsColimit.mk _ (fun s => s.inl) (fun s => Category.id_comp _)\n    (fun s => by rw [\u2190 cancel_epi f, Category.id_comp, s.condition]) fun s m m\u2081 _ => by\n    simpa using m\u2081\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 `(\ud835\udfd9 X, \ud835\udfd9 X)` is a colimit for the pair `(f, f)`.\nThe converse is given in `PushoutCocone.isColimitMkIdId`.\n-/\ntheorem epi_of_isColimitMkIdId (f : X \u27f6 Y)\n    (t : IsColimit (mk (\ud835\udfd9 Y) (\ud835\udfd9 Y) rfl : PushoutCocone f f)) : Epi f :=\n  \u27e8fun {Z} g h eq =>\n    by\n    rcases PushoutCocone.IsColimit.desc' t _ _ eq with \u27e8_, rfl, rfl\u27e9\n    rfl\u27e9\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 \u27f6 Y) (g : X \u27f6 Z) (h : X \u27f6 W) [Epi h] (x : W \u27f6 Y) (y : W \u27f6 Z)\n    (hhx : h \u226b x = f) (hhy : h \u226b y = g) (s : PushoutCocone f g) (hs : IsColimit s) :\n    have reassoc\u2081 : h \u226b x \u226b inl s = f \u226b inl s := by  -- Porting note: working around reassoc\n      rw [\u2190 Category.assoc]; apply congrArg (\u00b7 \u226b inl s) hhx\n    have reassoc\u2082 : h \u226b y \u226b inr s = g \u226b inr s := by\n      rw [\u2190 Category.assoc]; apply congrArg (\u00b7 \u226b inr s) hhy\n    IsColimit (PushoutCocone.mk _ _ (show x \u226b s.inl = y \u226b s.inr from\n          (cancel_epi h).1 <| by rw [reassoc\u2081, reassoc\u2082, s.condition])) :=\n  PushoutCocone.isColimitAux' _ fun t => \u27e8hs.desc (PushoutCocone.mk t.inl t.inr <| by\n    rw [\u2190 hhx, \u2190 hhy, Category.assoc, Category.assoc, t.condition]),\n      \u27e8hs.fac _ WalkingSpan.left, hs.fac _ WalkingSpan.right, fun hr hr' => by\n        apply PushoutCocone.IsColimit.hom_ext hs;\n        \u00b7 simp only [PushoutCocone.mk_inl, PushoutCocone.mk_inr] at hr hr'\u22a2\n          simp only [hr, hr']\n          symm\n          exact hs.fac _ WalkingSpan.left\n        \u00b7 simp only [PushoutCocone.mk_inl, PushoutCocone.mk_inr] at hr hr'\u22a2\n          simp only [hr, hr']\n          symm\n          exact hs.fac _ WalkingSpan.right\u27e9\u27e9\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 \u226b f, h \u226b g` for any epi `h`. -/\ndef isColimitOfEpiComp (f : X \u27f6 Y) (g : X \u27f6 Z) (h : W \u27f6 X) [Epi h] (s : PushoutCocone f g)\n    (H : IsColimit s) :\n    IsColimit\n      (PushoutCocone.mk _ _\n        (show (h \u226b f) \u226b s.inl = (h \u226b g) \u226b 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    \u27e8l, h\u2081, h\u2082\u27e9\n  refine' \u27e8l, h\u2081, h\u2082, _\u27e9\n  intro m hm\u2081 hm\u2082\n  exact (PushoutCocone.IsColimit.hom_ext H (hm\u2081.trans h\u2081.symm) (hm\u2082.trans h\u2082.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 \u2964 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 \u2964 C} (t : PullbackCone (F.map inl) (F.map inr)) : Cone F\n    where\n  pt := t.pt\n  \u03c0 := t.\u03c0 \u226b (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 \u2964 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 \u2964 C} (t : PushoutCocone (F.map fst) (F.map snd)) :\n    Cocone F where\n  pt := t.pt\n  \u03b9 := (diagramIsoSpan F).hom \u226b t.\u03b9\n#align category_theory.limits.cocone.of_pushout_cocone CategoryTheory.Limits.Cocone.ofPushoutCocone\n\n/-- Given `F : WalkingCospan \u2964 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 \u2964 C} (t : Cone F) : PullbackCone (F.map inl) (F.map inr)\n    where\n  pt := t.pt\n  \u03c0 := t.\u03c0 \u226b (diagramIsoCospan F).hom\n#align category_theory.limits.pullback_cone.of_cone CategoryTheory.Limits.PullbackCone.ofCone\n\n/-- A diagram `WalkingCospan \u2964 C` is isomorphic to some `PullbackCone.mk` after\ncomposing with `diagramIsoCospan`. -/\n@[simps!]\ndef PullbackCone.isoMk {F : WalkingCospan \u2964 C} (t : Cone F) :\n    (Cones.postcompose (diagramIsoCospan.{v} _).hom).obj t \u2245\n      PullbackCone.mk (t.\u03c0.app WalkingCospan.left) (t.\u03c0.app WalkingCospan.right)\n        ((t.\u03c0.naturality inl).symm.trans (t.\u03c0.naturality inr : _)) :=\n  Cones.ext (Iso.refl _) <| by\n    rintro (_ | (_ | _)) <;>\n      \u00b7 dsimp\n        simp\n#align category_theory.limits.pullback_cone.iso_mk CategoryTheory.Limits.PullbackCone.isoMk\n\n/-- Given `F : WalkingSpan \u2964 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 \u2964 C} (t : Cocone F) :\n    PushoutCocone (F.map fst) (F.map snd) where\n  pt := t.pt\n  \u03b9 := (diagramIsoSpan F).inv \u226b t.\u03b9\n#align category_theory.limits.pushout_cocone.of_cocone CategoryTheory.Limits.PushoutCocone.ofCocone\n\n/-- A diagram `WalkingSpan \u2964 C` is isomorphic to some `PushoutCocone.mk` after composing with\n`diagramIsoSpan`. -/\n@[simps!]\ndef PushoutCocone.isoMk {F : WalkingSpan \u2964 C} (t : Cocone F) :\n    (Cocones.precompose (diagramIsoSpan.{v} _).inv).obj t \u2245\n      PushoutCocone.mk (t.\u03b9.app WalkingSpan.left) (t.\u03b9.app WalkingSpan.right)\n        ((t.\u03b9.naturality fst).trans (t.\u03b9.naturality snd).symm) :=\n  Cocones.ext (Iso.refl _) <| by\n    rintro (_ | (_ | _)) <;>\n      \u00b7 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 \u27f6 Z` and `g : Y \u27f6 Z`.\n-/\nabbrev HasPullback {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y` and `g : X \u27f6 Z`.\n-/\nabbrev HasPushout {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] : pullback f g \u27f6 X :=\n  limit.\u03c0 (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 \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] : pullback f g \u27f6 Y :=\n  limit.\u03c0 (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 \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] : Y \u27f6 pushout f g :=\n  colimit.\u03b9 (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 \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] : Z \u27f6 pushout f g :=\n  colimit.\u03b9 (span f g) WalkingSpan.right\n#align category_theory.limits.pushout.inr CategoryTheory.Limits.pushout.inr\n\n/-- A pair of morphisms `h : W \u27f6 X` and `k : W \u27f6 Y` satisfying `h \u226b f = k \u226b g` induces a morphism\n    `pullback.lift : W \u27f6 pullback f g`. -/\nabbrev pullback.lift {W X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] (h : W \u27f6 X) (k : W \u27f6 Y)\n    (w : h \u226b f = k \u226b g) : W \u27f6 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 \u27f6 W` and `k : Z \u27f6 W` satisfying `f \u226b h = g \u226b k` induces a morphism\n    `pushout.desc : pushout f g \u27f6 W`. -/\nabbrev pushout.desc {W X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W)\n    (w : f \u226b h = g \u226b k) : pushout f g \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 Z) (g : Y \u27f6 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 \u27f6 X) (g : Z \u27f6 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 \u27f6 X) (g : Z \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] (h : W \u27f6 X)\n    (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : pullback.lift h k w \u226b pullback.fst = h :=\n  limit.lift_\u03c0 _ _\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 \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] (h : W \u27f6 X)\n    (k : W \u27f6 Y) (w : h \u226b f = k \u226b g) : pullback.lift h k w \u226b pullback.snd = k :=\n  limit.lift_\u03c0 _ _\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 \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] (h : Y \u27f6 W)\n    (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : pushout.inl \u226b pushout.desc h k w = h :=\n  colimit.\u03b9_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 \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] (h : Y \u27f6 W)\n    (k : Z \u27f6 W) (w : f \u226b h = g \u226b k) : pushout.inr \u226b pushout.desc h k w = k :=\n  colimit.\u03b9_desc _ _\n#align category_theory.limits.pushout.inr_desc CategoryTheory.Limits.pushout.inr_desc\n\n/-- A pair of morphisms `h : W \u27f6 X` and `k : W \u27f6 Y` satisfying `h \u226b f = k \u226b g` induces a morphism\n    `l : W \u27f6 pullback f g` such that `l \u226b pullback.fst = h` and `l \u226b pullback.snd = k`. -/\ndef pullback.lift' {W X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] (h : W \u27f6 X) (k : W \u27f6 Y)\n    (w : h \u226b f = k \u226b g) : { l : W \u27f6 pullback f g // l \u226b pullback.fst = h \u2227 l \u226b pullback.snd = k } :=\n  \u27e8pullback.lift h k w, pullback.lift_fst _ _ _, pullback.lift_snd _ _ _\u27e9\n#align category_theory.limits.pullback.lift' CategoryTheory.Limits.pullback.lift'\n\n/-- A pair of morphisms `h : Y \u27f6 W` and `k : Z \u27f6 W` satisfying `f \u226b h = g \u226b k` induces a morphism\n    `l : pushout f g \u27f6 W` such that `pushout.inl \u226b l = h` and `pushout.inr \u226b l = k`. -/\ndef pullback.desc' {W X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] (h : Y \u27f6 W) (k : Z \u27f6 W)\n    (w : f \u226b h = g \u226b k) : { l : pushout f g \u27f6 W // pushout.inl \u226b l = h \u2227 pushout.inr \u226b l = k } :=\n  \u27e8pushout.desc h k w, pushout.inl_desc _ _ _, pushout.inr_desc _ _ _\u27e9\n#align category_theory.limits.pullback.desc' CategoryTheory.Limits.pullback.desc'\n\n@[reassoc]\ntheorem pullback.condition {X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] :\n    (pullback.fst : pullback f g \u27f6 X) \u226b f = pullback.snd \u226b 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 \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] :\n    f \u226b (pushout.inl : Y \u27f6 pushout f g) = g \u226b 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 \u00d7\u209b X \u27f6 Y \u00d7\u209c Z`.\n\n    W  \u27f6  Y\n      \u2198      \u2198\n        S  \u27f6  T\n      \u2197      \u2197\n    X  \u27f6  Z\n\n-/\nabbrev pullback.map {W X Y Z S T : C} (f\u2081 : W \u27f6 S) (f\u2082 : X \u27f6 S) [HasPullback f\u2081 f\u2082] (g\u2081 : Y \u27f6 T)\n    (g\u2082 : Z \u27f6 T) [HasPullback g\u2081 g\u2082] (i\u2081 : W \u27f6 Y) (i\u2082 : X \u27f6 Z) (i\u2083 : S \u27f6 T)\n    (eq\u2081 : f\u2081 \u226b i\u2083 = i\u2081 \u226b g\u2081) (eq\u2082 : f\u2082 \u226b i\u2083 = i\u2082 \u226b g\u2082) : pullback f\u2081 f\u2082 \u27f6 pullback g\u2081 g\u2082 :=\n  pullback.lift (pullback.fst \u226b i\u2081) (pullback.snd \u226b i\u2082)\n    (by simp [\u2190 eq\u2081, \u2190 eq\u2082, pullback.condition_assoc])\n#align category_theory.limits.pullback.map CategoryTheory.Limits.pullback.map\n\n/-- The canonical map `X \u00d7\u209b Y \u27f6 X \u00d7\u209c Y` given `S \u27f6 T`. -/\nabbrev pullback.mapDesc {X Y S T : C} (f : X \u27f6 S) (g : Y \u27f6 S) (i : S \u27f6 T) [HasPullback f g]\n    [HasPullback (f \u226b i) (g \u226b i)] : pullback f g \u27f6 pullback (f \u226b i) (g \u226b i) :=\n  pullback.map f g (f \u226b i) (g \u226b i) (\ud835\udfd9 _) (\ud835\udfd9 _) 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 \u2a3f\u209b X \u27f6 Y \u2a3f\u209c Z`.\n\n        W  \u27f6  Y\n      \u2197      \u2197\n    S  \u27f6  T\n      \u2198      \u2198\n        X  \u27f6  Z\n\n-/\nabbrev pushout.map {W X Y Z S T : C} (f\u2081 : S \u27f6 W) (f\u2082 : S \u27f6 X) [HasPushout f\u2081 f\u2082] (g\u2081 : T \u27f6 Y)\n    (g\u2082 : T \u27f6 Z) [HasPushout g\u2081 g\u2082] (i\u2081 : W \u27f6 Y) (i\u2082 : X \u27f6 Z) (i\u2083 : S \u27f6 T) (eq\u2081 : f\u2081 \u226b i\u2081 = i\u2083 \u226b g\u2081)\n    (eq\u2082 : f\u2082 \u226b i\u2082 = i\u2083 \u226b g\u2082) : pushout f\u2081 f\u2082 \u27f6 pushout g\u2081 g\u2082 :=\n  pushout.desc (i\u2081 \u226b pushout.inl) (i\u2082 \u226b pushout.inr)\n    (by\n      simp only [\u2190 Category.assoc, eq\u2081, eq\u2082]\n      simp [pushout.condition])\n#align category_theory.limits.pushout.map CategoryTheory.Limits.pushout.map\n\n/-- The canonical map `X \u2a3f\u209b Y \u27f6 X \u2a3f\u209c Y` given `S \u27f6 T`. -/\nabbrev pushout.mapLift {X Y S T : C} (f : T \u27f6 X) (g : T \u27f6 Y) (i : S \u27f6 T) [HasPushout f g]\n    [HasPushout (i \u226b f) (i \u226b g)] : pushout (i \u226b f) (i \u226b g) \u27f6 pushout f g :=\n  pushout.map (i \u226b f) (i \u226b g) f g (\ud835\udfd9 _) (\ud835\udfd9 _) 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 \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] {W : C}\n    {k l : W \u27f6 pullback f g} (h\u2080 : k \u226b pullback.fst = l \u226b pullback.fst)\n    (h\u2081 : k \u226b pullback.snd = l \u226b pullback.snd) : k = l :=\n  limit.hom_ext <| PullbackCone.equalizer_ext _ h\u2080 h\u2081\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 \u27f6 Z) (g : Y \u27f6 Z) [HasPullback f g] :\n    IsLimit (PullbackCone.mk (pullback.fst : pullback f g \u27f6 _) 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 \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] [Mono g] :\n    Mono (pullback.fst : pullback f g \u27f6 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 \u27f6 Z} {g : Y \u27f6 Z} [HasPullback f g] [Mono f] :\n    Mono (pullback.snd : pullback f g \u27f6 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 \u00d7[Z] Y \u27f6 X \u00d7 Y` is mono. -/\ninstance mono_pullback_to_prod {C : Type _} [Category C] {X Y Z : C} (f : X \u27f6 Z) (g : Y \u27f6 Z)\n    [HasPullback f g] [HasBinaryProduct X Y] :\n    Mono (prod.lift pullback.fst pullback.snd : pullback f g \u27f6 _) :=\n  \u27e8fun {W} i\u2081 i\u2082 h => by\n    ext\n    \u00b7 simpa using congrArg (fun f => f \u226b prod.fst) h\n    \u00b7 simpa using congrArg (fun f => f \u226b prod.snd) h\u27e9\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 \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] {W : C}\n    {k l : pushout f g \u27f6 W} (h\u2080 : pushout.inl \u226b k = pushout.inl \u226b l)\n    (h\u2081 : pushout.inr \u226b k = pushout.inr \u226b l) : k = l :=\n  colimit.hom_ext <| PushoutCocone.coequalizer_ext _ h\u2080 h\u2081\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 \u27f6 Y) (g : X \u27f6 Z) [HasPushout f g] :\n    IsColimit (PushoutCocone.mk (pushout.inl : _ \u27f6 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 \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] [Epi g] :\n    Epi (pushout.inl : Y \u27f6 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 \u27f6 Y} {g : X \u27f6 Z} [HasPushout f g] [Epi f] :\n    Epi (pushout.inr : Z \u27f6 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 \u2a3f Y \u27f6 X \u2a3f[Z] Y` is epi. -/\ninstance epi_coprod_to_pushout {C : Type _} [Category C] {X Y Z : C} (f : X \u27f6 Y) (g : X \u27f6 Z)\n    [HasPushout f g] [HasBinaryCoproduct Y Z] :\n    Epi (coprod.desc pushout.inl pushout.inr : _ \u27f6 pushout f g) :=\n  \u27e8fun {W} i\u2081 i\u2082 h => by\n    ext\n    \u00b7 simpa using congrArg (fun f => coprod.inl \u226b f) h\n    \u00b7 simpa using congrArg (fun f => coprod.inr \u226b f) h\u27e9\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\u2081 : W \u27f6 S) (f\u2082 : X \u27f6 S) [HasPullback f\u2081 f\u2082]\n    (g\u2081 : Y \u27f6 T) (g\u2082 : Z \u27f6 T) [HasPullback g\u2081 g\u2082] (i\u2081 : W \u27f6 Y) (i\u2082 : X \u27f6 Z) (i\u2083 : S \u27f6 T)\n    (eq\u2081 : f\u2081 \u226b i\u2083 = i\u2081 \u226b g\u2081) (eq\u2082 : f\u2082 \u226b i\u2083 = i\u2082 \u226b g\u2082) [IsIso i\u2081] [IsIso i\u2082] [IsIso i\u2083] :\n    IsIso (pullback.map f\u2081 f\u2082 g\u2081 g\u2082 i\u2081 i\u2082 i\u2083 eq\u2081 eq\u2082) := by\n  refine' \u27e8\u27e8pullback.map _ _ _ _ (inv i\u2081) (inv i\u2082) (inv i\u2083) _ _, _, _\u27e9\u27e9\n  \u00b7 rw [IsIso.comp_inv_eq, Category.assoc, eq\u2081, IsIso.inv_hom_id_assoc]\n  \u00b7 rw [IsIso.comp_inv_eq, Category.assoc, eq\u2082, IsIso.inv_hom_id_assoc]\n  \u00b7 aesop_cat\n  \u00b7 aesop_cat\n#align category_theory.limits.pullback.map_is_iso CategoryTheory.Limits.pullback.map_isIso\n\n/-- If `f\u2081 = f\u2082` and `g\u2081 = g\u2082`, we may construct a canonical\nisomorphism `pullback f\u2081 g\u2081 \u2245 pullback f\u2082 g\u2082` -/\n@[simps! hom]\ndef pullback.congrHom {X Y Z : C} {f\u2081 f\u2082 : X \u27f6 Z} {g\u2081 g\u2082 : Y \u27f6 Z} (h\u2081 : f\u2081 = f\u2082) (h\u2082 : g\u2081 = g\u2082)\n    [HasPullback f\u2081 g\u2081] [HasPullback f\u2082 g\u2082] : pullback f\u2081 g\u2081 \u2245 pullback f\u2082 g\u2082 :=\n  asIso <| pullback.map _ _ _ _ (\ud835\udfd9 _) (\ud835\udfd9 _) (\ud835\udfd9 _) (by simp [h\u2081]) (by simp [h\u2082])\n#align category_theory.limits.pullback.congr_hom CategoryTheory.Limits.pullback.congrHom\n\n@[simp]\ntheorem pullback.congrHom_inv {X Y Z : C} {f\u2081 f\u2082 : X \u27f6 Z} {g\u2081 g\u2082 : Y \u27f6 Z} (h\u2081 : f\u2081 = f\u2082)\n    (h\u2082 : g\u2081 = g\u2082) [HasPullback f\u2081 g\u2081] [HasPullback f\u2082 g\u2082] :\n    (pullback.congrHom h\u2081 h\u2082).inv =\n      pullback.map _ _ _ _ (\ud835\udfd9 _) (\ud835\udfd9 _) (\ud835\udfd9 _) (by simp [h\u2081]) (by simp [h\u2082]) := by\n  ext\n  \u00b7 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  \u00b7 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\u2081 : S \u27f6 W) (f\u2082 : S \u27f6 X) [HasPushout f\u2081 f\u2082]\n    (g\u2081 : T \u27f6 Y) (g\u2082 : T \u27f6 Z) [HasPushout g\u2081 g\u2082] (i\u2081 : W \u27f6 Y) (i\u2082 : X \u27f6 Z) (i\u2083 : S \u27f6 T)\n    (eq\u2081 : f\u2081 \u226b i\u2081 = i\u2083 \u226b g\u2081) (eq\u2082 : f\u2082 \u226b i\u2082 = i\u2083 \u226b g\u2082) [IsIso i\u2081] [IsIso i\u2082] [IsIso i\u2083] :\n    IsIso (pushout.map f\u2081 f\u2082 g\u2081 g\u2082 i\u2081 i\u2082 i\u2083 eq\u2081 eq\u2082) := by\n  refine' \u27e8\u27e8pushout.map _ _ _ _ (inv i\u2081) (inv i\u2082) (inv i\u2083) _ _, _, _\u27e9\u27e9\n  \u00b7 rw [IsIso.comp_inv_eq, Category.assoc, eq\u2081, IsIso.inv_hom_id_assoc]\n  \u00b7 rw [IsIso.comp_inv_eq, Category.assoc, eq\u2082, IsIso.inv_hom_id_assoc]\n  \u00b7 aesop_cat\n  \u00b7 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 \u27f6 T) (g : Y \u27f6 T) (i : T \u27f6 S) (i' : S \u27f6 S')\n    [HasPullback f g] [HasPullback (f \u226b i) (g \u226b i)] [HasPullback (f \u226b i \u226b i') (g \u226b i \u226b i')]\n    [HasPullback ((f \u226b i) \u226b i') ((g \u226b i) \u226b i')] :\n    pullback.mapDesc f g (i \u226b i') = pullback.mapDesc f g i \u226b pullback.mapDesc _ _ i' \u226b\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\u2081 = f\u2082` and `g\u2081 = g\u2082`, we may construct a canonical\nisomorphism `pushout f\u2081 g\u2081 \u2245 pullback f\u2082 g\u2082` -/\n@[simps! hom]\ndef pushout.congrHom {X Y Z : C} {f\u2081 f\u2082 : X \u27f6 Y} {g\u2081 g\u2082 : X \u27f6 Z} (h\u2081 : f\u2081 = f\u2082) (h\u2082 : g\u2081 = g\u2082)\n    [HasPushout f\u2081 g\u2081] [HasPushout f\u2082 g\u2082] : pushout f\u2081 g\u2081 \u2245 pushout f\u2082 g\u2082 :=\n  asIso <| pushout.map _ _ _ _ (\ud835\udfd9 _) (\ud835\udfd9 _) (\ud835\udfd9 _) (by simp [h\u2081]) (by simp [h\u2082])\n#align category_theory.limits.pushout.congr_hom CategoryTheory.Limits.pushout.congrHom\n\n@[simp]\ntheorem pushout.congrHom_inv {X Y Z : C} {f\u2081 f\u2082 : X \u27f6 Y} {g\u2081 g\u2082 : X \u27f6 Z} (h\u2081 : f\u2081 = f\u2082)\n    (h\u2082 : g\u2081 = g\u2082) [HasPushout f\u2081 g\u2081] [HasPushout f\u2082 g\u2082] :\n    (pushout.congrHom h\u2081 h\u2082).inv =\n      pushout.map _ _ _ _ (\ud835\udfd9 _) (\ud835\udfd9 _) (\ud835\udfd9 _) (by simp [h\u2081]) (by simp [h\u2082]) := by\n  ext\n  \u00b7 erw [pushout.inl_desc]\n    rw [Iso.comp_inv_eq, Category.id_comp]\n    erw [pushout.inl_desc]\n    rw [Category.id_comp]\n  \u00b7 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 \u27f6 X) (g : T \u27f6 Y) (i : S \u27f6 T) (i' : S' \u27f6 S)\n    [HasPushout f g] [HasPushout (i \u226b f) (i \u226b g)] [HasPushout (i' \u226b i \u226b f) (i' \u226b i \u226b g)]\n    [HasPushout ((i' \u226b i) \u226b f) ((i' \u226b i) \u226b g)] :\n    pushout.mapLift f g (i' \u226b i) =\n      (pushout.congrHom (Category.assoc _ _ _) (Category.assoc _ _ _)).hom \u226b\n        pushout.mapLift _ _ i' \u226b 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 \u2964 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 \u27f6 Z) (g : Y \u27f6 Z) [HasPullback f g] [HasPullback (G.map f) (G.map g)] :\n    G.obj (pullback f g) \u27f6 pullback (G.map f) (G.map g) :=\n  pullback.lift (G.map pullback.fst) (G.map pullback.snd)\n    (by simp only [\u2190 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 \u27f6 Z) (g : Y \u27f6 Z) [HasPullback f g]\n    [HasPullback (G.map f) (G.map g)] :\n    pullbackComparison G f g \u226b 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 \u27f6 Z) (g : Y \u27f6 Z) [HasPullback f g]\n    [HasPullback (G.map f) (G.map g)] :\n    pullbackComparison G f g \u226b 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 \u27f6 Z) (g : Y \u27f6 Z) [HasPullback f g]\n    [HasPullback (G.map f) (G.map g)] {W : C} {h : W \u27f6 X} {k : W \u27f6 Y} (w : h \u226b f = k \u226b g) :\n    G.map (pullback.lift _ _ w) \u226b pullbackComparison G f g =\n      pullback.lift (G.map h) (G.map k) (by simp only [\u2190 G.map_comp, w]) := by\n  ext <;> simp [\u2190 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 \u27f6 Y) (g : X \u27f6 Z) [HasPushout f g] [HasPushout (G.map f) (G.map g)] :\n    pushout (G.map f) (G.map g) \u27f6 G.obj (pushout f g) :=\n  pushout.desc (G.map pushout.inl) (G.map pushout.inr)\n    (by simp only [\u2190 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 \u27f6 Y) (g : X \u27f6 Z) [HasPushout f g]\n    [HasPushout (G.map f) (G.map g)] : pushout.inl \u226b 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 \u27f6 Y) (g : X \u27f6 Z) [HasPushout f g]\n    [HasPushout (G.map f) (G.map g)] : pushout.inr \u226b 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 \u27f6 Y) (g : X \u27f6 Z) [HasPushout f g]\n    [HasPushout (G.map f) (G.map g)] {W : C} {h : Y \u27f6 W} {k : Z \u27f6 W} (w : f \u226b h = g \u226b k) :\n    pushoutComparison G f g \u226b G.map (pushout.desc _ _ w) =\n      pushout.desc (G.map h) (G.map k) (by simp only [\u2190 G.map_comp, w]) := by\n  ext <;> simp [\u2190 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 \u27f6 Z) (g : Y \u27f6 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  \u27e8\u27e8\u27e8PullbackCone.mk _ _ pullback.condition.symm,\n        PullbackCone.flipIsLimit (pullbackIsPullback _ _)\u27e9\u27e9\u27e9\n#align category_theory.limits.has_pullback_symmetry CategoryTheory.Limits.hasPullback_symmetry\n\nattribute [local instance] hasPullback_symmetry\n\n/-- The isomorphism `X \u00d7[Z] Y \u2245 Y \u00d7[Z] X`. -/\ndef pullbackSymmetry [HasPullback f g] : pullback f g \u2245 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 \u226b 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 \u226b 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 \u226b 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 \u226b 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 \u27f6 Y) (g : X \u27f6 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  \u27e8\u27e8\u27e8PushoutCocone.mk _ _ pushout.condition.symm,\n        PushoutCocone.flipIsColimit (pushoutIsPushout _ _)\u27e9\u27e9\u27e9\n#align category_theory.limits.has_pushout_symmetry CategoryTheory.Limits.hasPushout_symmetry\n\nattribute [local instance] hasPushout_symmetry\n\n/-- The isomorphism `Y \u2a3f[X] Z \u2245 Z \u2a3f[X] Y`. -/\ndef pushoutSymmetry [HasPushout f g] : pushout f g \u2245 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 \u226b (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 \u226b (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 \u226b (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 \u226b (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 \u226b i, g \u226b i` for any mono `i`. -/\nnoncomputable def pullbackIsPullbackOfCompMono (f : X \u27f6 W) (g : Y \u27f6 W) (i : W \u27f6 Z) [Mono i]\n    [HasPullback f g] : IsLimit (PullbackCone.mk pullback.fst pullback.snd\n      (show pullback.fst \u226b f \u226b i = pullback.snd \u226b g \u226b i from by -- Porting note: used to be _\n        simp only [\u2190 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 \u27f6 W) (g : Y \u27f6 W) (i : W \u27f6 Z) [Mono i] [HasPullback f g] :\n    HasPullback (f \u226b i) (g \u226b i) :=\n  \u27e8\u27e8\u27e8_, pullbackIsPullbackOfCompMono f g i\u27e9\u27e9\u27e9\n#align category_theory.limits.has_pullback_of_comp_mono CategoryTheory.Limits.hasPullback_of_comp_mono\n\nvariable (f : X \u27f6 Z) (g : Y \u27f6 Z) [IsIso f]\n\n/-- If `f : X \u27f6 Z` is iso, then `X \u00d7[Z] Y \u2245 Y`. This is the explicit limit cone. -/\ndef pullbackConeOfLeftIso : PullbackCone f g :=\n  PullbackCone.mk (g \u226b inv f) (\ud835\udfd9 _) <| 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 \u226b 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 = \ud835\udfd9 _ := 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_\u03c0_app_none : (pullbackConeOfLeftIso f g).\u03c0.app none = g := by simp\n#align category_theory.limits.pullback_cone_of_left_iso_\u03c0_app_none CategoryTheory.Limits.pullbackConeOfLeftIso_\u03c0_app_none\n\n@[simp]\ntheorem pullbackConeOfLeftIso_\u03c0_app_left : (pullbackConeOfLeftIso f g).\u03c0.app left = g \u226b inv f :=\n  rfl\n#align category_theory.limits.pullback_cone_of_left_iso_\u03c0_app_left CategoryTheory.Limits.pullbackConeOfLeftIso_\u03c0_app_left\n\n@[simp]\ntheorem pullbackConeOfLeftIso_\u03c0_app_right : (pullbackConeOfLeftIso f g).\u03c0.app right = \ud835\udfd9 _ := rfl\n#align category_theory.limits.pullback_cone_of_left_iso_\u03c0_app_right CategoryTheory.Limits.pullbackConeOfLeftIso_\u03c0_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 => \u27e8s.snd, by simp [\u2190 s.condition_assoc]\u27e9\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  \u27e8\u27e8\u27e8_, pullbackConeOfLeftIsoIsLimit f g\u27e9\u27e9\u27e9\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 \u27f6 _) := by\n  refine' \u27e8\u27e8pullback.lift (g \u226b inv f) (\ud835\udfd9 _) (by simp), _, by simp\u27e9\u27e9\n  ext\n  \u00b7 simp [\u2190 pullback.condition_assoc]\n  \u00b7 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 \u27f6 W) [Mono i]\n\ninstance hasPullback_of_right_factors_mono (f : X \u27f6 Z) : HasPullback i (f \u226b i) := by\n  conv =>\n    congr\n    rw [\u2190 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 \u27f6 Z) :\n    IsIso (pullback.snd : pullback i (f \u226b i) \u27f6 _) := by\n  convert (congrArg IsIso (show _ \u226b pullback.snd = _ from\n    limit.isoLimitCone_hom_\u03c0 \u27e8_, pullbackIsPullbackOfCompMono (\ud835\udfd9 _) f i\u27e9 WalkingCospan.right)).mp\n    inferInstance;\n  \u00b7 exact (Category.id_comp _).symm\n  \u00b7 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 \u27f6 Z) (g : Y \u27f6 Z) [IsIso g]\n\n/-- If `g : Y \u27f6 Z` is iso, then `X \u00d7[Z] Y \u2245 X`. This is the explicit limit cone. -/\ndef pullbackConeOfRightIso : PullbackCone f g :=\n  PullbackCone.mk (\ud835\udfd9 _) (f \u226b 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 = \ud835\udfd9 _ := 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 \u226b 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_\u03c0_app_none : (pullbackConeOfRightIso f g).\u03c0.app none = f := by simp\n#align category_theory.limits.pullback_cone_of_right_iso_\u03c0_app_none CategoryTheory.Limits.pullbackConeOfRightIso_\u03c0_app_none\n\n@[simp]\ntheorem pullbackConeOfRightIso_\u03c0_app_left : (pullbackConeOfRightIso f g).\u03c0.app left = \ud835\udfd9 _ :=\n  rfl\n#align category_theory.limits.pullback_cone_of_right_iso_\u03c0_app_left CategoryTheory.Limits.pullbackConeOfRightIso_\u03c0_app_left\n\n@[simp]\ntheorem pullbackConeOfRightIso_\u03c0_app_right : (pullbackConeOfRightIso f g).\u03c0.app right = f \u226b inv g\n  := rfl\n#align category_theory.limits.pullback_cone_of_right_iso_\u03c0_app_right CategoryTheory.Limits.pullbackConeOfRightIso_\u03c0_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 => \u27e8s.fst, by simp [s.condition_assoc]\u27e9\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  \u27e8\u27e8\u27e8_, pullbackConeOfRightIsoIsLimit f g\u27e9\u27e9\u27e9\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 \u27f6 _) := by\n  refine' \u27e8\u27e8pullback.lift (\ud835\udfd9 _) (f \u226b inv g) (by simp), _, by simp\u27e9\u27e9\n  ext\n  \u00b7 simp\n  \u00b7 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 \u27f6 W) [Mono i]\n\ninstance hasPullback_of_left_factors_mono (f : X \u27f6 Z) : HasPullback (f \u226b i) i := by\n  conv =>\n    congr\n    case g => rw [\u2190 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 \u27f6 Z) :\n    IsIso (pullback.fst : pullback (f \u226b i) i \u27f6 _) := by\n  convert (congrArg IsIso (show _ \u226b pullback.fst = _ from\n    limit.isoLimitCone_hom_\u03c0 \u27e8_, pullbackIsPullbackOfCompMono f (\ud835\udfd9 _) i\u27e9 WalkingCospan.left)).mp\n    inferInstance;\n  \u00b7 exact (Category.id_comp _).symm\n  \u00b7 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 \u226b f, h \u226b g` for any epi `h`. -/\nnoncomputable def pushoutIsPushoutOfEpiComp (f : X \u27f6 Y) (g : X \u27f6 Z) (h : W \u27f6 X) [Epi h]\n    [HasPushout f g] : IsColimit (PushoutCocone.mk pushout.inl pushout.inr\n    (show (h \u226b f) \u226b pushout.inl = (h \u226b g) \u226b 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 \u27f6 Y) (g : X \u27f6 Z) (h : W \u27f6 X) [Epi h] [HasPushout f g] :\n    HasPushout (h \u226b f) (h \u226b g) :=\n  \u27e8\u27e8\u27e8_, pushoutIsPushoutOfEpiComp f g h\u27e9\u27e9\u27e9\n#align category_theory.limits.has_pushout_of_epi_comp CategoryTheory.Limits.hasPushout_of_epi_comp\n\nvariable (f : X \u27f6 Y) (g : X \u27f6 Z) [IsIso f]\n\n/-- If `f : X \u27f6 Y` is iso, then `Y \u2a3f[X] Z \u2245 Z`. This is the explicit colimit cocone. -/\ndef pushoutCoconeOfLeftIso : PushoutCocone f g :=\n  PushoutCocone.mk (inv f \u226b g) (\ud835\udfd9 _) <| 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 \u226b 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 = \ud835\udfd9 _ := 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_\u03b9_app_none : (pushoutCoconeOfLeftIso f g).\u03b9.app none = g := by\n  simp\n#align category_theory.limits.pushout_cocone_of_left_iso_\u03b9_app_none CategoryTheory.Limits.pushoutCoconeOfLeftIso_\u03b9_app_none\n\n@[simp]\ntheorem pushoutCoconeOfLeftIso_\u03b9_app_left : (pushoutCoconeOfLeftIso f g).\u03b9.app left = inv f \u226b g :=\n  rfl\n#align category_theory.limits.pushout_cocone_of_left_iso_\u03b9_app_left CategoryTheory.Limits.pushoutCoconeOfLeftIso_\u03b9_app_left\n\n@[simp]\ntheorem pushoutCoconeOfLeftIso_\u03b9_app_right : (pushoutCoconeOfLeftIso f g).\u03b9.app right = \ud835\udfd9 _ := rfl\n#align category_theory.limits.pushout_cocone_of_left_iso_\u03b9_app_right CategoryTheory.Limits.pushoutCoconeOfLeftIso_\u03b9_app_right\n\n/-- Verify that the constructed cocone is indeed a colimit. -/\ndef pushoutCoconeOfLeftIsoIsLimit : IsColimit (pushoutCoconeOfLeftIso f g) :=\n  PushoutCocone.isColimitAux' _ fun s => \u27e8s.inr, by simp [\u2190 s.condition]\u27e9\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 : _ \u27f6 pushout f g) := by\n  refine' \u27e8\u27e8pushout.desc (inv f \u226b g) (\ud835\udfd9 _) (by simp), by simp, _\u27e9\u27e9\n  ext\n  \u00b7 simp [\u2190 pushout.condition]\n  \u00b7 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 \u27f6 X) [Epi h]\n\ninstance hasPushout_of_right_factors_epi (f : X \u27f6 Y) : HasPushout h (h \u226b f) := by\n  conv =>\n    congr\n    rw [\u2190 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 \u27f6 Y) :\n    IsIso (pushout.inr : _ \u27f6 pushout h (h \u226b f)) := by\n  convert (congrArg IsIso (show pushout.inr \u226b _ = _ from colimit.isoColimitCocone_\u03b9_inv\n    \u27e8_, pushoutIsPushoutOfEpiComp (\ud835\udfd9 _) f h\u27e9 WalkingSpan.right)).mp\n    inferInstance\n  \u00b7 apply (Category.comp_id _).symm\n  \u00b7 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 \u27f6 Y) (g : X \u27f6 Z) [IsIso g]\n\n/-- If `f : X \u27f6 Z` is iso, then `Y \u2a3f[X] Z \u2245 Y`. This is the explicit colimit cocone. -/\ndef pushoutCoconeOfRightIso : PushoutCocone f g :=\n  PushoutCocone.mk (\ud835\udfd9 _) (inv g \u226b 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 = \ud835\udfd9 _ := 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 \u226b 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_\u03b9_app_none : (pushoutCoconeOfRightIso f g).\u03b9.app none = f := by\n  simp\n#align category_theory.limits.pushout_cocone_of_right_iso_\u03b9_app_none CategoryTheory.Limits.pushoutCoconeOfRightIso_\u03b9_app_none\n\n@[simp]\ntheorem pushoutCoconeOfRightIso_\u03b9_app_left : (pushoutCoconeOfRightIso f g).\u03b9.app left = \ud835\udfd9 _ := rfl\n#align category_theory.limits.pushout_cocone_of_right_iso_\u03b9_app_left CategoryTheory.Limits.pushoutCoconeOfRightIso_\u03b9_app_left\n\n@[simp]\ntheorem pushoutCoconeOfRightIso_\u03b9_app_right :\n    (pushoutCoconeOfRightIso f g).\u03b9.app right = inv g \u226b f := rfl\n#align category_theory.limits.pushout_cocone_of_right_iso_\u03b9_app_right CategoryTheory.Limits.pushoutCoconeOfRightIso_\u03b9_app_right\n\n/-- Verify that the constructed cocone is indeed a colimit. -/\ndef pushoutCoconeOfRightIsoIsLimit : IsColimit (pushoutCoconeOfRightIso f g) :=\n  PushoutCocone.isColimitAux' _ fun s => \u27e8s.inl, by simp [\u2190 s.condition]\u27e9\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  \u27e8\u27e8\u27e8_, pushoutCoconeOfRightIsoIsLimit f g\u27e9\u27e9\u27e9\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 : _ \u27f6 pushout f g) := by\n  refine' \u27e8\u27e8pushout.desc (\ud835\udfd9 _) (inv g \u226b f) (by simp), by simp, _\u27e9\u27e9\n  ext\n  \u00b7 simp [\u2190 pushout.condition]\n  \u00b7 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 \u27f6 X) [Epi h]\n\ninstance hasPushout_of_left_factors_epi (f : X \u27f6 Y) : HasPushout (h \u226b f) h := by\n  conv =>\n    congr\n    case g => rw [\u2190 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 \u27f6 Y) :\n    IsIso (pushout.inl : _ \u27f6 pushout (h \u226b f) h) := by\n  convert (congrArg IsIso (show pushout.inl \u226b _ = _ from colimit.isoColimitCocone_\u03b9_inv\n    \u27e8_, pushoutIsPushoutOfEpiComp f (\ud835\udfd9 _) h\u27e9 WalkingSpan.left)).mp\n        inferInstance;\n  \u00b7 exact (Category.comp_id _).symm\n  \u00b7 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 \u27f6 Y)\n\ninstance has_kernel_pair_of_mono [Mono f] : HasPullback f f :=\n  \u27e8\u27e8\u27e8_, PullbackCone.isLimitMkIdId f\u27e9\u27e9\u27e9\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 \u27f6 _) = 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 = \ud835\udfd9 _ := 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 \u27f6 _) := by\n  refine' \u27e8\u27e8pullback.lift (\ud835\udfd9 _) (\ud835\udfd9 _) (by simp), _, by simp\u27e9\u27e9\n  ext\n  \u00b7 simp\n  \u00b7 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 \u27f6 _) := by\n  rw [\u2190 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 \u27f6 Y)\n\ninstance has_cokernel_pair_of_epi [Epi f] : HasPushout f f :=\n  \u27e8\u27e8\u27e8_, PushoutCocone.isColimitMkIdId f\u27e9\u27e9\u27e9\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 : _ \u27f6 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 = \ud835\udfd9 _ := 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 : _ \u27f6 pushout f f) := by\n  refine' \u27e8\u27e8pushout.desc (\ud835\udfd9 _) (\ud835\udfd9 _) (by simp), by simp, _\u27e9\u27e9\n  apply pushout.hom_ext\n  \u00b7 simp\n  \u00b7 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 : _ \u27f6 pushout f f) := by\n  rw [\u2190 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\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : C} (f\u2081 : X\u2081 \u27f6 X\u2082) (f\u2082 : X\u2082 \u27f6 X\u2083) (g\u2081 : Y\u2081 \u27f6 Y\u2082) (g\u2082 : Y\u2082 \u27f6 Y\u2083)\n\nvariable (i\u2081 : X\u2081 \u27f6 Y\u2081) (i\u2082 : X\u2082 \u27f6 Y\u2082) (i\u2083 : X\u2083 \u27f6 Y\u2083)\n\nvariable (h\u2081 : i\u2081 \u226b g\u2081 = f\u2081 \u226b i\u2082) (h\u2082 : i\u2082 \u226b g\u2082 = f\u2082 \u226b i\u2083)\n\n/-- Given\n\nX\u2081 - f\u2081 -> X\u2082 - f\u2082 -> X\u2083\n|          |          |\ni\u2081         i\u2082         i\u2083\n\u2228          \u2228          \u2228\nY\u2081 - g\u2081 -> Y\u2082 - g\u2082 -> Y\u2083\n\nThen the big square is a pullback if both the small squares are.\n-/\ndef bigSquareIsPullback (H : IsLimit (PullbackCone.mk _ _ h\u2082))\n    (H' : IsLimit (PullbackCone.mk _ _ h\u2081)) :\n    IsLimit\n      (PullbackCone.mk _ _\n        (show i\u2081 \u226b g\u2081 \u226b g\u2082 = (f\u2081 \u226b f\u2082) \u226b i\u2083 by\n          rw [\u2190 Category.assoc, h\u2081, Category.assoc, h\u2082, Category.assoc])) := by\n  fapply PullbackCone.isLimitAux'\n  intro s\n  have : (s.fst \u226b g\u2081) \u226b g\u2082 = s.snd \u226b i\u2083 := by rw [\u2190 s.condition, Category.assoc]\n  rcases PullbackCone.IsLimit.lift' H (s.fst \u226b g\u2081) s.snd this with \u27e8l\u2081, hl\u2081, hl\u2081'\u27e9\n  rcases PullbackCone.IsLimit.lift' H' s.fst l\u2081 hl\u2081.symm with \u27e8l\u2082, hl\u2082, hl\u2082'\u27e9\n  use l\u2082\n  use hl\u2082\n  use\n    show l\u2082 \u226b f\u2081 \u226b f\u2082 = s.snd by\n      rw [\u2190 hl\u2081', \u2190 hl\u2082', Category.assoc]\n      rfl\n  intro m hm\u2081 hm\u2082\n  apply PullbackCone.IsLimit.hom_ext H'\n  \u00b7 erw [hm\u2081, hl\u2082]\n  \u00b7 apply PullbackCone.IsLimit.hom_ext H\n    \u00b7 erw [Category.assoc, \u2190 h\u2081, \u2190 Category.assoc, hm\u2081, \u2190 hl\u2082, Category.assoc, Category.assoc, h\u2081]\n      rfl\n    \u00b7 erw [Category.assoc, hm\u2082, \u2190 hl\u2081', \u2190 hl\u2082']\n#align category_theory.limits.big_square_is_pullback CategoryTheory.Limits.bigSquareIsPullback\n\n/-- Given\n\nX\u2081 - f\u2081 -> X\u2082 - f\u2082 -> X\u2083\n|          |          |\ni\u2081         i\u2082         i\u2083\n\u2228          \u2228          \u2228\nY\u2081 - g\u2081 -> Y\u2082 - g\u2082 -> Y\u2083\n\nThen the big square is a pushout if both the small squares are.\n-/\ndef bigSquareIsPushout (H : IsColimit (PushoutCocone.mk _ _ h\u2082))\n    (H' : IsColimit (PushoutCocone.mk _ _ h\u2081)) :\n    IsColimit\n      (PushoutCocone.mk _ _\n        (show i\u2081 \u226b g\u2081 \u226b g\u2082 = (f\u2081 \u226b f\u2082) \u226b i\u2083 by\n          rw [\u2190 Category.assoc, h\u2081, Category.assoc, h\u2082, Category.assoc])) := by\n  fapply PushoutCocone.isColimitAux'\n  intro s\n  have : i\u2081 \u226b s.inl = f\u2081 \u226b f\u2082 \u226b s.inr := by rw [s.condition, Category.assoc]\n  rcases PushoutCocone.IsColimit.desc' H' s.inl (f\u2082 \u226b s.inr) this with \u27e8l\u2081, hl\u2081, hl\u2081'\u27e9\n  rcases PushoutCocone.IsColimit.desc' H l\u2081 s.inr hl\u2081' with \u27e8l\u2082, hl\u2082, hl\u2082'\u27e9\n  use l\u2082\n  use\n    show (g\u2081 \u226b g\u2082) \u226b l\u2082 = s.inl by\n      rw [\u2190 hl\u2081, \u2190 hl\u2082, Category.assoc]\n      rfl\n  use hl\u2082'\n  intro m hm\u2081 hm\u2082\n  apply PushoutCocone.IsColimit.hom_ext H\n  \u00b7 apply PushoutCocone.IsColimit.hom_ext H'\n    \u00b7 erw [\u2190 Category.assoc, hm\u2081, hl\u2082, hl\u2081]\n    \u00b7 erw [\u2190 Category.assoc, h\u2082, Category.assoc, hm\u2082, \u2190 hl\u2082', \u2190 Category.assoc, \u2190 Category.assoc, \u2190\n        h\u2082]\n      rfl\n  \u00b7 erw [hm\u2082, hl\u2082']\n#align category_theory.limits.big_square_is_pushout CategoryTheory.Limits.bigSquareIsPushout\n\n/-- Given\n\nX\u2081 - f\u2081 -> X\u2082 - f\u2082 -> X\u2083\n|          |          |\ni\u2081         i\u2082         i\u2083\n\u2228          \u2228          \u2228\nY\u2081 - g\u2081 -> Y\u2082 - g\u2082 -> Y\u2083\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\u2082))\n    (H' :\n      IsLimit\n        (PullbackCone.mk _ _\n          (show i\u2081 \u226b g\u2081 \u226b g\u2082 = (f\u2081 \u226b f\u2082) \u226b i\u2083 by\n            rw [\u2190 Category.assoc, h\u2081, Category.assoc, h\u2082, Category.assoc]))) :\n    IsLimit (PullbackCone.mk _ _ h\u2081) := by\n  fapply PullbackCone.isLimitAux'\n  intro s\n  have : s.fst \u226b g\u2081 \u226b g\u2082 = (s.snd \u226b f\u2082) \u226b i\u2083 := by\n    rw [\u2190 Category.assoc, s.condition, Category.assoc, Category.assoc, h\u2082]\n  rcases PullbackCone.IsLimit.lift' H' s.fst (s.snd \u226b f\u2082) this with \u27e8l\u2081, hl\u2081, hl\u2081'\u27e9\n  use l\u2081\n  use hl\u2081\n  constructor\n  \u00b7 apply PullbackCone.IsLimit.hom_ext H\n    \u00b7 erw [Category.assoc, \u2190 h\u2081, \u2190 Category.assoc, hl\u2081, s.condition]\n      rfl\n    \u00b7 erw [Category.assoc, hl\u2081']\n      rfl\n  \u00b7 intro m hm\u2081 hm\u2082\n    apply PullbackCone.IsLimit.hom_ext H'\n    \u00b7 erw [hm\u2081, hl\u2081]\n    \u00b7 erw [hl\u2081', \u2190 hm\u2082]\n      exact (Category.assoc _ _ _).symm\n#align category_theory.limits.left_square_is_pullback CategoryTheory.Limits.leftSquareIsPullback\n\n/-- Given\n\nX\u2081 - f\u2081 -> X\u2082 - f\u2082 -> X\u2083\n|          |          |\ni\u2081         i\u2082         i\u2083\n\u2228          \u2228          \u2228\nY\u2081 - g\u2081 -> Y\u2082 - g\u2082 -> Y\u2083\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\u2081))\n    (H' :\n      IsColimit\n        (PushoutCocone.mk _ _\n          (show i\u2081 \u226b g\u2081 \u226b g\u2082 = (f\u2081 \u226b f\u2082) \u226b i\u2083 by\n            rw [\u2190 Category.assoc, h\u2081, Category.assoc, h\u2082, Category.assoc]))) :\n    IsColimit (PushoutCocone.mk _ _ h\u2082) := by\n  fapply PushoutCocone.isColimitAux'\n  intro s\n  have : i\u2081 \u226b g\u2081 \u226b s.inl = (f\u2081 \u226b f\u2082) \u226b s.inr := by\n    rw [Category.assoc, \u2190 s.condition, \u2190 Category.assoc, \u2190 Category.assoc, h\u2081]\n  rcases PushoutCocone.IsColimit.desc' H' (g\u2081 \u226b s.inl) s.inr this with \u27e8l\u2081, hl\u2081, hl\u2081'\u27e9\n  dsimp at *\n  use l\u2081\n  refine' \u27e8_, _, _\u27e9\n  \u00b7 apply PushoutCocone.IsColimit.hom_ext H\n    \u00b7 erw [\u2190 Category.assoc, hl\u2081]\n      rfl\n    \u00b7 erw [\u2190 Category.assoc, h\u2082, Category.assoc, hl\u2081', s.condition]\n  \u00b7 exact hl\u2081'\n  \u00b7 intro m hm\u2081 hm\u2082\n    apply PushoutCocone.IsColimit.hom_ext H'\n    \u00b7 erw [hl\u2081, Category.assoc, hm\u2081]\n    \u00b7 erw [hm\u2082, hl\u2081']\n#align category_theory.limits.right_square_is_pushout CategoryTheory.Limits.rightSquareIsPushout\n\nend PasteLemma\n\nsection\n\nvariable (f : X \u27f6 Z) (g : Y \u27f6 Z) (f' : W \u27f6 X)\n\nvariable [HasPullback f g] [HasPullback f' (pullback.fst : pullback f g \u27f6 _)]\n\nvariable [HasPullback (f' \u226b f) g]\n\n/-- The canonical isomorphism `W \u00d7[X] (X \u00d7[Z] Y) \u2245 W \u00d7[Z] Y` -/\nnoncomputable def pullbackRightPullbackFstIso :\n    pullback f' (pullback.fst : pullback f g \u27f6 _) \u2245 pullback (f' \u226b f) g := by\n  let this :=\n    bigSquareIsPullback (pullback.snd : pullback f' (pullback.fst : pullback f g \u27f6 _) \u27f6 _)\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 \u226b 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 \u226b pullback.snd = pullback.snd \u226b 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 \u226b 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 \u226b pullback.snd \u226b 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 \u226b pullback.snd \u226b pullback.fst = pullback.fst \u226b f' := by\n  rw [\u2190 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 \u27f6 Y) (g : X \u27f6 Z) (g' : Z \u27f6 W)\n\nvariable [HasPushout f g] [HasPushout (pushout.inr : _ \u27f6 pushout f g) g']\n\nvariable [HasPushout f (g \u226b g')]\n\n/-- The canonical isomorphism `(Y \u2a3f[X] Z) \u2a3f[Z] W \u2245 Y \u00d7[X] W` -/\nnoncomputable def pushoutLeftPushoutInrIso :\n    pushout (pushout.inr : _ \u27f6 pushout f g) g' \u2245 pushout f (g \u226b 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 \u226b (pushoutLeftPushoutInrIso f g g').inv = pushout.inl \u226b 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 \u226b (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 \u226b (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 \u226b pushout.inl \u226b (pushoutLeftPushoutInrIso f g g').hom = pushout.inl := by\n  rw [\u2190 Category.assoc, \u2190 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 \u226b pushout.inl \u226b (pushoutLeftPushoutInrIso f g g').hom = g' \u226b pushout.inr := by\n  rw [\u2190 Category.assoc, \u2190 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\u2082 - g\u2084 -> X\u2083\n           |          |\n           g\u2083         f\u2084\n           \u2228          \u2228\nZ\u2081 - g\u2082 -> X\u2082 - f\u2083 -> Y\u2082\n|          |\ng\u2081         f\u2082\n\u2228          \u2228\nX\u2081 - f\u2081 -> Y\u2081\n\nwhere the two squares are pullbacks.\n\nWe can then construct the pullback squares\n\nW  - l\u2082 -> Z\u2082 - g\u2084 -> X\u2083\n|                     |\nl\u2081                    f\u2084\n\u2228                     \u2228\nZ\u2081 - g\u2082 -> X\u2082 - f\u2083 -> Y\u2082\n\nand\n\nW' - l\u2082' -> Z\u2082\n|           |\nl\u2081'         g\u2083\n\u2228           \u2228\nZ\u2081          X\u2082\n|           |\ng\u2081          f\u2082\n\u2228           \u2228\nX\u2081 -  f\u2081 -> Y\u2081\n\nWe will show that both `W` and `W'` are pullbacks over `g\u2081, g\u2082`, and thus we may construct a\ncanonical isomorphism between them. -/\nvariable {X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2081) (f\u2083 : X\u2082 \u27f6 Y\u2082)\n\nvariable (f\u2084 : X\u2083 \u27f6 Y\u2082) [HasPullback f\u2081 f\u2082] [HasPullback f\u2083 f\u2084]\n\n-- include f\u2081 f\u2082 f\u2083 f\u2084 Porting note: removed\n\nlocal notation \"Z\u2081\" => pullback f\u2081 f\u2082\n\nlocal notation \"Z\u2082\" => pullback f\u2083 f\u2084\n\nlocal notation \"g\u2081\" => (pullback.fst : Z\u2081 \u27f6 X\u2081)\n\nlocal notation \"g\u2082\" => (pullback.snd : Z\u2081 \u27f6 X\u2082)\n\nlocal notation \"g\u2083\" => (pullback.fst : Z\u2082 \u27f6 X\u2082)\n\nlocal notation \"g\u2084\" => (pullback.snd : Z\u2082 \u27f6 X\u2083)\n\nlocal notation \"W\" => pullback (g\u2082 \u226b f\u2083) f\u2084\n\nlocal notation \"W'\" => pullback f\u2081 (g\u2083 \u226b f\u2082)\n\nlocal notation \"l\u2081\" => (pullback.fst : W \u27f6 Z\u2081)\n\nlocal notation \"l\u2082\" =>\n  (pullback.lift (pullback.fst \u226b g\u2082) pullback.snd\n      (Eq.trans (Category.assoc _ _ _) pullback.condition) :\n    W \u27f6 Z\u2082)\n\nlocal notation \"l\u2081'\" =>\n  (pullback.lift pullback.fst (pullback.snd \u226b g\u2083)\n      (pullback.condition.trans (Eq.symm (Category.assoc _ _ _))) :\n    W' \u27f6 Z\u2081)\n\nlocal notation \"l\u2082'\" => (pullback.snd : W' \u27f6 Z\u2082)\n\n/-- `(X\u2081 \u00d7[Y\u2081] X\u2082) \u00d7[Y\u2082] X\u2083` is the pullback `(X\u2081 \u00d7[Y\u2081] X\u2082) \u00d7[X\u2082] (X\u2082 \u00d7[Y\u2082] X\u2083)`. -/\ndef pullbackPullbackLeftIsPullback [HasPullback (g\u2082 \u226b f\u2083) f\u2084] :\n    IsLimit (PullbackCone.mk l\u2081 l\u2082 (show l\u2081 \u226b g\u2082 = l\u2082 \u226b g\u2083 from (pullback.lift_fst _ _ _).symm)) :=\n  by\n  apply leftSquareIsPullback\n  exact pullbackIsPullback f\u2083 f\u2084\n  convert pullbackIsPullback (g\u2082 \u226b f\u2083) f\u2084\n  rw [pullback.lift_snd]\n#align category_theory.limits.pullback_pullback_left_is_pullback CategoryTheory.Limits.pullbackPullbackLeftIsPullback\n\n/-- `(X\u2081 \u00d7[Y\u2081] X\u2082) \u00d7[Y\u2082] X\u2083` is the pullback `X\u2081 \u00d7[Y\u2081] (X\u2082 \u00d7[Y\u2082] X\u2083)`. -/\ndef pullbackAssocIsPullback [HasPullback (g\u2082 \u226b f\u2083) f\u2084] :\n    IsLimit\n      (PullbackCone.mk (l\u2081 \u226b g\u2081) l\u2082\n        (show (l\u2081 \u226b g\u2081) \u226b f\u2081 = l\u2082 \u226b g\u2083 \u226b f\u2082 by\n          rw [pullback.lift_fst_assoc, Category.assoc, Category.assoc, pullback.condition])) := by\n  apply PullbackCone.flipIsLimit\n  apply bigSquareIsPullback\n  \u00b7 apply PullbackCone.flipIsLimit\n    exact pullbackIsPullback f\u2081 f\u2082\n  \u00b7 apply PullbackCone.flipIsLimit\n    apply pullbackPullbackLeftIsPullback\n  \u00b7 exact pullback.lift_fst _ _ _\n  \u00b7 exact pullback.condition.symm\n#align category_theory.limits.pullback_assoc_is_pullback CategoryTheory.Limits.pullbackAssocIsPullback\n\ntheorem hasPullback_assoc [HasPullback (g\u2082 \u226b f\u2083) f\u2084] : HasPullback f\u2081 (g\u2083 \u226b f\u2082) :=\n  \u27e8\u27e8\u27e8_, pullbackAssocIsPullback f\u2081 f\u2082 f\u2083 f\u2084\u27e9\u27e9\u27e9\n#align category_theory.limits.has_pullback_assoc CategoryTheory.Limits.hasPullback_assoc\n\n/-- `X\u2081 \u00d7[Y\u2081] (X\u2082 \u00d7[Y\u2082] X\u2083)` is the pullback `(X\u2081 \u00d7[Y\u2081] X\u2082) \u00d7[X\u2082] (X\u2082 \u00d7[Y\u2082] X\u2083)`. -/\ndef pullbackPullbackRightIsPullback [HasPullback f\u2081 (g\u2083 \u226b f\u2082)] :\n    IsLimit (PullbackCone.mk l\u2081' l\u2082' (show l\u2081' \u226b g\u2082 = l\u2082' \u226b g\u2083 from pullback.lift_snd _ _ _)) := by\n  apply PullbackCone.flipIsLimit\n  apply leftSquareIsPullback\n  \u00b7 apply PullbackCone.flipIsLimit\n    exact pullbackIsPullback f\u2081 f\u2082\n  \u00b7 apply PullbackCone.flipIsLimit\n    convert pullbackIsPullback f\u2081 (g\u2083 \u226b f\u2082)\n    rw [pullback.lift_fst]\n  \u00b7 exact pullback.condition.symm\n#align category_theory.limits.pullback_pullback_right_is_pullback CategoryTheory.Limits.pullbackPullbackRightIsPullback\n\n/-- `X\u2081 \u00d7[Y\u2081] (X\u2082 \u00d7[Y\u2082] X\u2083)` is the pullback `(X\u2081 \u00d7[Y\u2081] X\u2082) \u00d7[Y\u2082] X\u2083`. -/\ndef pullbackAssocSymmIsPullback [HasPullback f\u2081 (g\u2083 \u226b f\u2082)] :\n    IsLimit\n      (PullbackCone.mk l\u2081' (l\u2082' \u226b g\u2084)\n        (show l\u2081' \u226b g\u2082 \u226b f\u2083 = (l\u2082' \u226b g\u2084) \u226b f\u2084 by\n          rw [pullback.lift_snd_assoc, Category.assoc, Category.assoc, pullback.condition])) := by\n  apply bigSquareIsPullback\n  exact pullbackIsPullback f\u2083 f\u2084\n  apply pullbackPullbackRightIsPullback\n#align category_theory.limits.pullback_assoc_symm_is_pullback CategoryTheory.Limits.pullbackAssocSymmIsPullback\n\ntheorem hasPullback_assoc_symm [HasPullback f\u2081 (g\u2083 \u226b f\u2082)] : HasPullback (g\u2082 \u226b f\u2083) f\u2084 :=\n  \u27e8\u27e8\u27e8_, pullbackAssocSymmIsPullback f\u2081 f\u2082 f\u2083 f\u2084\u27e9\u27e9\u27e9\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\u2082 \u226b f\u2083) f\u2084] [HasPullback f\u2081 (g\u2083 \u226b f\u2082)] -/\nvariable [HasPullback (g\u2082 \u226b f\u2083) f\u2084] [HasPullback f\u2081 ((pullback.fst : Z\u2082 \u27f6  X\u2082) \u226b f\u2082)]\n\n/-- The canonical isomorphism `(X\u2081 \u00d7[Y\u2081] X\u2082) \u00d7[Y\u2082] X\u2083 \u2245 X\u2081 \u00d7[Y\u2081] (X\u2082 \u00d7[Y\u2082] X\u2083)`. -/\nnoncomputable def pullbackAssoc [HasPullback ((pullback.snd : Z\u2081 \u27f6 X\u2082) \u226b f\u2083) f\u2084]\n    [HasPullback f\u2081 ((pullback.fst : Z\u2082 \u27f6  X\u2082) \u226b f\u2082)] :\n    pullback (pullback.snd \u226b f\u2083 : pullback f\u2081 f\u2082 \u27f6 _) f\u2084 \u2245\n      pullback f\u2081 (pullback.fst \u226b f\u2082 : pullback f\u2083 f\u2084 \u27f6 _) :=\n  (pullbackPullbackLeftIsPullback f\u2081 f\u2082 f\u2083 f\u2084).conePointUniqueUpToIso\n    (pullbackPullbackRightIsPullback f\u2081 f\u2082 f\u2083 f\u2084)\n#align category_theory.limits.pullback_assoc CategoryTheory.Limits.pullbackAssoc\n\n@[reassoc (attr := simp)]\ntheorem pullbackAssoc_inv_fst_fst [HasPullback ((pullback.snd : Z\u2081 \u27f6 X\u2082) \u226b f\u2083) f\u2084]\n    [HasPullback f\u2081 ((pullback.fst : Z\u2082 \u27f6  X\u2082) \u226b f\u2082)]:\n    (pullbackAssoc f\u2081 f\u2082 f\u2083 f\u2084).inv \u226b pullback.fst \u226b pullback.fst = pullback.fst := by\n  trans l\u2081' \u226b pullback.fst\n  rw [\u2190 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\u2081 \u27f6 X\u2082) \u226b f\u2083) f\u2084]\n    [HasPullback f\u2081 ((pullback.fst : Z\u2082 \u27f6  X\u2082) \u226b f\u2082)] :\n    (pullbackAssoc f\u2081 f\u2082 f\u2083 f\u2084).hom \u226b pullback.fst = pullback.fst \u226b pullback.fst := by\n  rw [\u2190 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\u2081 \u27f6 X\u2082) \u226b f\u2083) f\u2084]\n    [HasPullback f\u2081 ((pullback.fst : Z\u2082 \u27f6  X\u2082) \u226b f\u2082)] :\n    (pullbackAssoc f\u2081 f\u2082 f\u2083 f\u2084).hom \u226b pullback.snd \u226b pullback.fst = pullback.fst \u226b pullback.snd :=\n  by\n  trans l\u2082 \u226b pullback.fst\n  rw [\u2190 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\u2081 \u27f6 X\u2082) \u226b f\u2083) f\u2084]\n    [HasPullback f\u2081 ((pullback.fst : Z\u2082 \u27f6  X\u2082) \u226b f\u2082)] :\n    (pullbackAssoc f\u2081 f\u2082 f\u2083 f\u2084).hom \u226b pullback.snd \u226b pullback.snd = pullback.snd := by\n  trans l\u2082 \u226b pullback.snd\n  rw [\u2190 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\u2081 \u27f6 X\u2082) \u226b f\u2083) f\u2084]\n    [HasPullback f\u2081 ((pullback.fst : Z\u2082 \u27f6  X\u2082) \u226b f\u2082)] :\n    (pullbackAssoc f\u2081 f\u2082 f\u2083 f\u2084).inv \u226b pullback.fst \u226b pullback.snd = pullback.snd \u226b 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\u2081 \u27f6 X\u2082) \u226b f\u2083) f\u2084]\n    [HasPullback f\u2081 ((pullback.fst : Z\u2082 \u27f6  X\u2082) \u226b f\u2082)] :\n    (pullbackAssoc f\u2081 f\u2082 f\u2083 f\u2084).inv \u226b pullback.snd = pullback.snd \u226b 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\u2082 - g\u2084 -> X\u2083\n           |          |\n           g\u2083         f\u2084\n           \u2228          \u2228\nZ\u2081 - g\u2082 -> X\u2082 - f\u2083 -> Y\u2082\n|          |\ng\u2081         f\u2082\n\u2228          \u2228\nX\u2081 - f\u2081 -> Y\u2081\n\nwhere the two squares are pushouts.\n\nWe can then construct the pushout squares\n\nZ\u2081 - g\u2082 -> X\u2082 - f\u2083 -> Y\u2082\n|                     |\ng\u2081                    l\u2082\n\u2228                     \u2228\nX\u2081 - f\u2081 -> Y\u2081 - l\u2081 -> W\n\nand\n\nZ\u2082 - g\u2084  -> X\u2083\n|           |\ng\u2083          f\u2084\n\u2228           \u2228\nX\u2082          Y\u2082\n|           |\nf\u2082          l\u2082'\n\u2228           \u2228\nY\u2081 - l\u2081' -> W'\n\nWe will show that both `W` and `W'` are pushouts over `f\u2082, f\u2083`, and thus we may construct a\ncanonical isomorphism between them. -/\nvariable {X\u2081 X\u2082 X\u2083 Z\u2081 Z\u2082 : C} (g\u2081 : Z\u2081 \u27f6 X\u2081) (g\u2082 : Z\u2081 \u27f6 X\u2082) (g\u2083 : Z\u2082 \u27f6 X\u2082)\n\nvariable (g\u2084 : Z\u2082 \u27f6 X\u2083) [HasPushout g\u2081 g\u2082] [HasPushout g\u2083 g\u2084]\n\n-- include g\u2081 g\u2082 g\u2083 g\u2084 Porting note: removed\n\nlocal notation \"Y\u2081\" => pushout g\u2081 g\u2082\n\nlocal notation \"Y\u2082\" => pushout g\u2083 g\u2084\n\nlocal notation \"f\u2081\" => (pushout.inl : X\u2081 \u27f6 Y\u2081)\n\nlocal notation \"f\u2082\" => (pushout.inr : X\u2082 \u27f6 Y\u2081)\n\nlocal notation \"f\u2083\" => (pushout.inl : X\u2082 \u27f6 Y\u2082)\n\nlocal notation \"f\u2084\" => (pushout.inr : X\u2083 \u27f6 Y\u2082)\n\nlocal notation \"W\" => pushout g\u2081 (g\u2082 \u226b f\u2083)\n\nlocal notation \"W'\" => pushout (g\u2083 \u226b f\u2082) g\u2084\n\nlocal notation \"l\u2081\" =>\n  (pushout.desc pushout.inl (f\u2083 \u226b pushout.inr) (pushout.condition.trans (Category.assoc _ _ _)) :\n    Y\u2081 \u27f6 W)\n\nlocal notation \"l\u2082\" => (pushout.inr : Y\u2082 \u27f6 W)\n\nlocal notation \"l\u2081'\" => (pushout.inl : Y\u2081 \u27f6 W')\n\nlocal notation \"l\u2082'\" =>\n  (pushout.desc (f\u2082 \u226b pushout.inl) pushout.inr\n      (Eq.trans (Eq.symm (Category.assoc _ _ _)) pushout.condition) :\n    Y\u2082 \u27f6 W')\n\n/-- `(X\u2081 \u2a3f[Z\u2081] X\u2082) \u2a3f[Z\u2082] X\u2083` is the pushout `(X\u2081 \u2a3f[Z\u2081] X\u2082) \u00d7[X\u2082] (X\u2082 \u2a3f[Z\u2082] X\u2083)`. -/\ndef pushoutPushoutLeftIsPushout [HasPushout (g\u2083 \u226b f\u2082) g\u2084] :\n    IsColimit\n      (PushoutCocone.mk l\u2081' l\u2082' (show f\u2082 \u226b l\u2081' = f\u2083 \u226b l\u2082' from (pushout.inl_desc _ _ _).symm)) := by\n  apply PushoutCocone.flipIsColimit\n  apply rightSquareIsPushout\n  \u00b7 apply PushoutCocone.flipIsColimit\n    exact pushoutIsPushout _ _\n  \u00b7 apply PushoutCocone.flipIsColimit\n    convert pushoutIsPushout (g\u2083 \u226b f\u2082) g\u2084\n    exact pushout.inr_desc _ _ _\n  \u00b7 exact pushout.condition.symm\n#align category_theory.limits.pushout_pushout_left_is_pushout CategoryTheory.Limits.pushoutPushoutLeftIsPushout\n\n/-- `(X\u2081 \u2a3f[Z\u2081] X\u2082) \u2a3f[Z\u2082] X\u2083` is the pushout `X\u2081 \u2a3f[Z\u2081] (X\u2082 \u2a3f[Z\u2082] X\u2083)`. -/\ndef pushoutAssocIsPushout [HasPushout (g\u2083 \u226b f\u2082) g\u2084] :\n    IsColimit\n      (PushoutCocone.mk (f\u2081 \u226b l\u2081') l\u2082'\n        (show g\u2081 \u226b f\u2081 \u226b l\u2081' = (g\u2082 \u226b f\u2083) \u226b l\u2082' by\n          rw [Category.assoc, pushout.inl_desc, pushout.condition_assoc])) := by\n  apply bigSquareIsPushout\n  \u00b7 apply pushoutPushoutLeftIsPushout\n  \u00b7 exact pushoutIsPushout _ _\n#align category_theory.limits.pushout_assoc_is_pushout CategoryTheory.Limits.pushoutAssocIsPushout\n\ntheorem hasPushout_assoc [HasPushout (g\u2083 \u226b f\u2082) g\u2084] : HasPushout g\u2081 (g\u2082 \u226b f\u2083) :=\n  \u27e8\u27e8\u27e8_, pushoutAssocIsPushout g\u2081 g\u2082 g\u2083 g\u2084\u27e9\u27e9\u27e9\n#align category_theory.limits.has_pushout_assoc CategoryTheory.Limits.hasPushout_assoc\n\n/-- `X\u2081 \u2a3f[Z\u2081] (X\u2082 \u2a3f[Z\u2082] X\u2083)` is the pushout `(X\u2081 \u2a3f[Z\u2081] X\u2082) \u00d7[X\u2082] (X\u2082 \u2a3f[Z\u2082] X\u2083)`. -/\ndef pushoutPushoutRightIsPushout [HasPushout g\u2081 (g\u2082 \u226b f\u2083)] :\n    IsColimit (PushoutCocone.mk l\u2081 l\u2082 (show f\u2082 \u226b l\u2081 = f\u2083 \u226b l\u2082 from pushout.inr_desc _ _ _)) := by\n  apply rightSquareIsPushout\n  \u00b7 exact pushoutIsPushout _ _\n  \u00b7 convert pushoutIsPushout g\u2081 (g\u2082 \u226b f\u2083)\n    rw [pushout.inl_desc]\n#align category_theory.limits.pushout_pushout_right_is_pushout CategoryTheory.Limits.pushoutPushoutRightIsPushout\n\n/-- `X\u2081 \u2a3f[Z\u2081] (X\u2082 \u2a3f[Z\u2082] X\u2083)` is the pushout `(X\u2081 \u2a3f[Z\u2081] X\u2082) \u2a3f[Z\u2082] X\u2083`. -/\ndef pushoutAssocSymmIsPushout [HasPushout g\u2081 (g\u2082 \u226b f\u2083)] :\n    IsColimit\n      (PushoutCocone.mk l\u2081 (f\u2084 \u226b l\u2082)\n        (show (g\u2083 \u226b f\u2082) \u226b l\u2081 = g\u2084 \u226b f\u2084 \u226b l\u2082 by\n          rw [Category.assoc, pushout.inr_desc, pushout.condition_assoc])) := by\n  apply PushoutCocone.flipIsColimit\n  apply bigSquareIsPushout\n  \u00b7 apply PushoutCocone.flipIsColimit\n    apply pushoutPushoutRightIsPushout\n  \u00b7 apply PushoutCocone.flipIsColimit\n    exact pushoutIsPushout _ _\n  \u00b7 exact pushout.condition.symm\n  \u00b7 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\u2081 (g\u2082 \u226b f\u2083)] : HasPushout (g\u2083 \u226b f\u2082) g\u2084 :=\n  \u27e8\u27e8\u27e8_, pushoutAssocSymmIsPushout g\u2081 g\u2082 g\u2083 g\u2084\u27e9\u27e9\u27e9\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\u2083 \u226b f\u2082) g\u2084] [HasPushout g\u2081 (g\u2082 \u226b f\u2083)]\n\n/-- The canonical isomorphism `(X\u2081 \u2a3f[Z\u2081] X\u2082) \u2a3f[Z\u2082] X\u2083 \u2245 X\u2081 \u2a3f[Z\u2081] (X\u2082 \u2a3f[Z\u2082] X\u2083)`. -/\nnoncomputable def pushoutAssoc [HasPushout (g\u2083 \u226b (pushout.inr : X\u2082 \u27f6  Y\u2081)) g\u2084]\n    [HasPushout g\u2081 (g\u2082 \u226b (pushout.inl : X\u2082 \u27f6  Y\u2082))]:\n    pushout (g\u2083 \u226b pushout.inr : _ \u27f6 pushout g\u2081 g\u2082) g\u2084 \u2245\n      pushout g\u2081 (g\u2082 \u226b pushout.inl : _ \u27f6 pushout g\u2083 g\u2084) :=\n  (pushoutPushoutLeftIsPushout g\u2081 g\u2082 g\u2083 g\u2084).coconePointUniqueUpToIso\n    (pushoutPushoutRightIsPushout g\u2081 g\u2082 g\u2083 g\u2084)\n#align category_theory.limits.pushout_assoc CategoryTheory.Limits.pushoutAssoc\n\n@[reassoc (attr := simp)]\ntheorem inl_inl_pushoutAssoc_hom [HasPushout (g\u2083 \u226b (pushout.inr : X\u2082 \u27f6  Y\u2081)) g\u2084]\n    [HasPushout g\u2081 (g\u2082 \u226b (pushout.inl : X\u2082 \u27f6  Y\u2082))] :\n    pushout.inl \u226b pushout.inl \u226b (pushoutAssoc g\u2081 g\u2082 g\u2083 g\u2084).hom = pushout.inl := by\n  trans f\u2081 \u226b l\u2081\n  \u00b7 congr 1\n    exact\n      (pushoutPushoutLeftIsPushout g\u2081 g\u2082 g\u2083 g\u2084).comp_coconePointUniqueUpToIso_hom _\n        WalkingCospan.left\n  \u00b7 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\u2083 \u226b (pushout.inr : X\u2082 \u27f6  Y\u2081)) g\u2084]\n    [HasPushout g\u2081 (g\u2082 \u226b (pushout.inl : X\u2082 \u27f6  Y\u2082))] :\n    pushout.inr \u226b pushout.inl \u226b (pushoutAssoc g\u2081 g\u2082 g\u2083 g\u2084).hom = pushout.inl \u226b pushout.inr := by\n  trans f\u2082 \u226b l\u2081\n  \u00b7 congr 1\n    exact\n      (pushoutPushoutLeftIsPushout g\u2081 g\u2082 g\u2083 g\u2084).comp_coconePointUniqueUpToIso_hom _\n        WalkingCospan.left\n  \u00b7 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\u2083 \u226b (pushout.inr : X\u2082 \u27f6  Y\u2081)) g\u2084]\n    [HasPushout g\u2081 (g\u2082 \u226b (pushout.inl : X\u2082 \u27f6  Y\u2082))] :\n    pushout.inr \u226b pushout.inr \u226b (pushoutAssoc g\u2081 g\u2082 g\u2083 g\u2084).inv = pushout.inr := by\n  trans f\u2084 \u226b l\u2082'\n  \u00b7 congr 1\n    exact\n      (pushoutPushoutLeftIsPushout g\u2081 g\u2082 g\u2083 g\u2084).comp_coconePointUniqueUpToIso_inv\n        (pushoutPushoutRightIsPushout g\u2081 g\u2082 g\u2083 g\u2084) WalkingCospan.right\n  \u00b7 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\u2083 \u226b (pushout.inr : X\u2082 \u27f6  Y\u2081)) g\u2084]\n    [HasPushout g\u2081 (g\u2082 \u226b (pushout.inl : X\u2082 \u27f6  Y\u2082))] :\n    pushout.inl \u226b (pushoutAssoc g\u2081 g\u2082 g\u2083 g\u2084).inv = pushout.inl \u226b 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\u2083 \u226b (pushout.inr : X\u2082 \u27f6  Y\u2081)) g\u2084]\n    [HasPushout g\u2081 (g\u2082 \u226b (pushout.inl : X\u2082 \u27f6  Y\u2082))] :\n    pushout.inl \u226b pushout.inr \u226b (pushoutAssoc g\u2081 g\u2082 g\u2083 g\u2084).inv = pushout.inr \u226b pushout.inl := by\n  rw [\u2190 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\u2083 \u226b (pushout.inr : X\u2082 \u27f6  Y\u2081)) g\u2084]\n    [HasPushout g\u2081 (g\u2082 \u226b (pushout.inl : X\u2082 \u27f6  Y\u2082))] :\n    pushout.inr \u226b (pushoutAssoc g\u2081 g\u2082 g\u2083 g\u2084).hom = pushout.inr \u226b pushout.inr := by\n  rw [\u2190 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    [\u2200 {X Y Z : C} {f : X \u27f6 Z} {g : Y \u27f6 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    [\u2200 {X Y Z : C} {f : X \u27f6 Y} {g : X \u27f6 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\u1d52\u1d56 \u224c WalkingCospan` -/\n@[simps!]\ndef walkingSpanOpEquiv : WalkingSpan\u1d52\u1d56 \u224c WalkingCospan :=\n  widePushoutShapeOpEquiv _\n#align category_theory.limits.walking_span_op_equiv CategoryTheory.Limits.walkingSpanOpEquiv\n\n/-- The duality equivalence `WalkingCospan\u1d52\u1d56 \u224c WalkingSpan` -/\n@[simps!]\ndef walkingCospanOpEquiv : WalkingCospan\u1d52\u1d56 \u224c 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 \u27f6 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 \u27f6 Y) : Over Y \u2964 Over X where\n  obj g := Over.mk (pullback.snd : pullback g.hom f \u27f6 _)\n  map i := Over.homMk (pullback.map _ _ _ _ i.left (\ud835\udfd9 _) (\ud835\udfd9 _) (by simp) (by simp)) (by simp)\n  map_id Z := by\n    apply Over.OverMorphism.ext; apply pullback.hom_ext\n    \u00b7 dsimp; simp\n    \u00b7 dsimp; simp\n  map_comp f g := by\n    apply Over.OverMorphism.ext; apply pullback.hom_ext\n    \u00b7 dsimp; simp\n    \u00b7 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 {\u03b9 : Type*} [add_monoid \u03b9] \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 := \u22a4\n\nexample : (unit.star  : with_top unit) \u2260 (\u22a4 : 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\u2099 : \u2115 \u2192 (set (ideal V))) (hI\u2099 : \u2200 i j, i < j \u2192 I\u2099 i \u2286 I\u2099 j) (n : \u2115)\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\u2099 : \u2115 \u2192 (set I))\n  {hI\u2099 : \u2200 i j, i < j \u2192 I\u2099 i \u2286 I\u2099 j} (n : \u2115) : I\u2099 0 \u2286 I\u2099 n :=\nbegin\n  induction n with m h\u2082,\n  { refl},\n  { -- have H : I\u2099 n = I\u2099 (n + 1),\n    have H := hI\u2099 m (m + 1) (show m < m + 1, by linarith),\n    tauto\n  },\nend\n\nlemma second (I : set (ideal V)) {I\u2099 : \u2115 \u2192 (set I)} \n  {hI\u2099 : \u2200 i j, i < j \u2192 I\u2099 i \u2286 I\u2099 j} (n : \u2115) (a : I) : a \u2208 I\u2099 0 \u2192 a \u2208 I\u2099 n := \nbegin\n  have H := first_sub_all I I\u2099 n,\n  rw set.subset_def at H,\n  exact H a,\n  exact hI\u2099,\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\u2099 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\u2099 : \u2115 \u2192 (set (ideal V)))\n  (hI\u2099 : \u2200 i j, i < j \u2192 I\u2099 i \u2286 I\u2099 j) (a : ideal V) : a \u2208 I\u2099 0 \u2192 a \u2208 \u22c3 n, I\u2099 n :=\nbegin\n  intros ha,\n  rw set.mem_Union,\n  use 0,\n  exact ha,\nend \n\n#check \u22c3 n, I\u2099 n\nvariables (J : set (\u22c3 n, I\u2099 n)) (x : ideal V) (hx : x \u2208 I\u2099 0) \n#check zorn.chain (\u2264) (I\u2099 0)\n#check nonempty J\n#check J.nonempty\n\n#check third I\u2099 hI\u2099 x hx\nopen set\n\nlemma big_union_nonempty {I\u2099 : \u2115 \u2192 set(ideal V)} (hI\u2099 : \u2200 i j, i < j \u2192 I\u2099 i \u2286 I\u2099 j) : \n  (I\u2099 0).nonempty \u2192 (\u22c3 n, I\u2099 n).nonempty :=\nbegin\n  intros hI\u2099, \n  rw set.nonempty_def at hI\u2099,\n  cases hI\u2099 with x hx,\n  rw set.nonempty_def,\n  use x,\n  exact third I\u2099 hI\u2099 x hx,\nend\n\nexample (I : set (ideal V)) : zorn.chain (\u2264) 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-- \u2203 (m : ?m_1) (H : m \u2208 ?m_2), \u2200 (z : ?m_1), z \u2208 ?m_2 \u2192 m \u2264 z \u2192 z = m\nlemma exists_maximal_in_set (I : set (ideal V)) (H : zorn.chain (\u2264) I) (hI : I.nonempty)\n  {I\u2099 : \u2115 \u2192 set(ideal V)} {hI\u2099 : \u2200 i j, i < j \u2192 I\u2099 i \u2286 I\u2099 j}\n  : \u2203 s \u2208 I, \u2200 t \u2208 I, s \u2264 t \u2192 t = s:=\nbegin\n  apply zorn.zorn_partial_order\u2080,\n  intros X hXI XChain,\n  -- use (\u2a06 n, I\u2099 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 \u2264 b\n#check S.nonempty\n#check ideal.exists_maximal V \n\nlemma test (hS : zorn.chain (\u2264) T) : \u2203 ub, \u2200 a \u2208 T, a \u2264 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 := \u2115 \u2192 alphabet\nconstant a : String\n\n-- States that substring [i, j) is decent\nconstant decent : \u2115 \u2192 \u2115 \u2192 String \u2192 Prop\ndef indecent (i j : \u2115) (a : String) : Prop := \u00ac decent i j a\n\ndef prefix_decent (i : \u2115) (a : String) : Prop :=\n  \u2200 (j : \u2115), i < j \u2192 decent i j a\n\nlemma lemma0 {a : Prop} {b : Prop} : \u00ac (a \u2192 b) \u2192 a :=\nbegin\n  tautology!,\nend\n\ndef breakable (a : String)\n              (prop : \u2115 \u2192 \u2115 \u2192 String \u2192 Prop) : Prop\n              := \u2203 (P : \u2115 \u2192 Prop),\n                 \u2203 (n : \u2115),\n                 (\u2203 (i : \u2115), (P i)) \u2227\n                  \u2200 (i : \u2115), (P i) \u2192 \u2203 (j : \u2115), i < j \u2227 prop i j a \u2227 P j\n\ntheorem kolmogorov : breakable a decent \u2228 breakable a indecent :=\nbegin\n  by_cases h : \u2203 (n : \u2115), \u2200 (i : \u2115), n < i \u2192 \u00ac prefix_decent i a,\n    cases h with n h1,\n    -- Suppose we have h\n      right,\n        unfold breakable,\n        let P : \u2115 \u2192 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 : \u2203 (x : \u2115), \u00ac(i < x \u2192 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 : \u2115 \u2192 Prop := \u03bb i, 0 < i \u2227 prefix_decent i a,\n          existsi [Q, 0],\n            -- We can start the ball rolling at i\n            have q : \u2203 (i : \u2115), \u00ac(0 < i \u2192 \u00acprefix_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 : \u2203 (j : \u2115), \u00ac(i < j \u2192 \u00acprefix_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 `* \u27f6 X` and elements of `X`.  -/\ndef from_point {X : Profinite.{u}} :\n  (point \u27f6 X) \u2243 X :=\n{ to_fun := \u03bb f, f punit.star,\n  inv_fun := \u03bb x, \u27e8\u03bb _, x\u27e9,\n  left_inv := \u03bb x, by { ext \u27e8\u27e9, refl },\n  right_inv := \u03bb x, rfl}\n\nlemma from_point_apply {X Y : Profinite} (f : point \u27f6 X) (g : X \u27f6 Y) :\n  g (from_point f) = from_point (f \u226b g) :=\nrfl\n\nnoncomputable def mk_pullback {X Y Z : Profinite.{u}} {f : X \u27f6 Z} {g : Y \u27f6 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 \u27e8\u27e9, exact h }))\n\nlemma mk_pullback_fst {X Y Z : Profinite} {f : X \u27f6 Z} {g : Y \u27f6 Z} {x : X} {y : Y}\n  {h : f x = g y} : (pullback.fst : pullback f g \u27f6 _) (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 \u27f6 Z} {g : Y \u27f6 Z} {x : X} {y : Y}\n  {h : f x = g y} : (pullback.snd : pullback f g \u27f6 _) (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 := \u03bb X S, \u2203 (\u03b9 : Type u) [fintype \u03b9] (Y : \u03b9 \u2192 Profinite) (f : \u03a0 (i : \u03b9), Y i \u27f6 X),\n      (\u2200 (x : X), \u2203 i (y : Y i), f i y = x) \u2227 S = presieve.of_arrows Y f,\n  has_isos := \u03bb X Y f i,\n  begin\n    refine \u27e8punit, infer_instance, \u03bb _, Y, \u03bb _, f, _, _\u27e9,\n    { introI x,\n      refine \u27e8punit.star, inv f x, _\u27e9,\n      change (inv f \u226b f) x = x,\n      rw is_iso.inv_hom_id,\n      simp },\n    { rw presieve.of_arrows_punit },\n  end,\n  pullbacks := \u03bb X Y f S,\n  begin\n    rintro \u27e8\u03b9, h\u03b9, Z, g, hg, rfl\u27e9,\n    refine \u27e8\u03b9, h\u03b9, \u03bb i, pullback (g i) f, \u03bb i, pullback.snd, _, _\u27e9,\n    { intro y,\n      rcases hg (f y) with \u27e8i, z, hz\u27e9,\n      exact \u27e8i, mk_pullback hz, mk_pullback_snd\u27e9 },\n    { rw presieve.of_arrows_pullback }\n  end,\n  transitive := \u03bb X S Ti,\n  begin\n    rintro \u27e8\u03b9, h\u03b9, Z, g, hY, rfl\u27e9 hTi,\n    choose j hj W k hk\u2081 hk\u2082 using hTi,\n    resetI,\n    refine \u27e8\u03a3 (i : \u03b9), j (g i) (presieve.of_arrows.mk _), infer_instance, \u03bb i, W _ _ i.2, _, _, _\u27e9,\n    { intro ij,\n      exact k _ _ ij.2 \u226b g ij.1 },\n    { intro x,\n      obtain \u27e8i, y, rfl\u27e9 := hY x,\n      obtain \u27e8i', z, rfl\u27e9 := hk\u2081 (g i) (presieve.of_arrows.mk _) y,\n      refine \u27e8\u27e8i, i'\u27e9, z, rfl\u27e9 },\n    { have : Ti = \u03bb Y f H, presieve.of_arrows (W f H) (k f H),\n      { ext Y f H : 3,\n        apply hk\u2082 },\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 `\ud835\udd4e R \u2192+* \ud835\udd4e R`.\nIt turns out that this endomorphism can be described by polynomials over `\u2124`\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 : \ud835\udd4e R \u2192 \ud835\udd4e 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 : \u2115} {R S : Type*} [hp : fact p.prime] [comm_ring R] [comm_ring S]\nlocal notation `\ud835\udd4e` := 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 : \u2115) : mv_polynomial \u2115 \u211a :=\nbind\u2081 (witt_polynomial p \u211a \u2218 \u03bb n, n + 1) (X_in_terms_of_W p \u211a n)\n\nlemma bind\u2081_frobenius_poly_rat_witt_polynomial (n : \u2115) :\n  bind\u2081 (frobenius_poly_rat p) (witt_polynomial p \u211a n) = (witt_polynomial p \u211a (n+1)) :=\nbegin\n  delta frobenius_poly_rat,\n  rw [\u2190 bind\u2081_bind\u2081, bind\u2081_X_in_terms_of_W_witt_polynomial, bind\u2081_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 : \u2115+) : \u2115 :=\n(multiplicity p n).get $ multiplicity.finite_nat_iff.mpr $ \u27e8ne_of_gt hp.1.one_lt, n.2\u27e9\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 : \u2115 \u2192 mv_polynomial \u2115 \u2124\n| n := X (n + 1) - \u2211 i : fin n, have _ := i.is_lt,\n  \u2211 j in range (p ^ (n - i)),\n    (X i ^ p) ^ (p ^ (n - i) - (j + 1)) *\n      (frobenius_poly_aux i) ^ (j + 1) *\n      C \u2191((p ^ (n - i)).choose (j + 1) / (p ^ (n - i - v p \u27e8j + 1, nat.succ_pos j\u27e9)) *\n      \u2191p ^ (j - v p \u27e8j + 1, nat.succ_pos j\u27e9) : \u2115)\n\nlemma frobenius_poly_aux_eq (n : \u2115) :\n  frobenius_poly_aux p n =\n  X (n + 1) - \u2211 i in range n, \u2211 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 \u2191((p ^ (n - i)).choose (j + 1) / (p ^ (n - i - v p \u27e8j + 1, nat.succ_pos j\u27e9)) *\n      \u2191p ^ (j - v p \u27e8j + 1, nat.succ_pos j\u27e9) : \u2115) :=\nby { rw [frobenius_poly_aux, \u2190 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 : \u2115) : mv_polynomial \u2115 \u2124 :=\nX n ^ p + C \u2191p * (frobenius_poly_aux p n)\n\n/-\nOur next goal is to prove\n```\nlemma map_frobenius_poly (n : \u2115) :\n  mv_polynomial.map (int.cast_ring_hom \u211a) (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\u2081 (n j : \u2115) (hj : j < p ^ (n)) :\n  p ^ (n - v p \u27e8j + 1, j.succ_pos\u27e9) \u2223 (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\u2082 {n i j : \u2115} (hi : i \u2264 n) (hj : j < p ^ (n - i)) :\n  j - v p \u27e8j + 1, j.succ_pos\u27e9 + n = i + j + (n - i - v p \u27e8j + 1, j.succ_pos\u27e9) :=\nbegin\n  generalize h : (v p \u27e8j + 1, j.succ_pos\u27e9) = m,\n  rsuffices \u27e8h\u2081, h\u2082\u27e9 : m \u2264 n - i \u2227 m \u2264 j,\n  { rw [tsub_add_eq_add_tsub h\u2082, add_comm i j,\n      add_tsub_assoc_of_le (h\u2081.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\u2081))] },\n  have hle : p ^ m \u2264 j + 1,\n    from h \u25b8 nat.le_of_dvd j.succ_pos (multiplicity.pow_multiplicity_dvd _),\n  exact \u27e8(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)\u27e9\nend\n\nlemma map_frobenius_poly (n : \u2115) :\n  mv_polynomial.map (int.cast_ring_hom \u211a) (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\u2081_C_right],\n  have h1 : (\u2191p ^ n) * (\u215f (\u2191p : \u211a) ^ n) = 1 := by rw [\u2190mul_pow, mul_inv_of_self, one_pow],\n  rw [bind\u2081_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 (\u2191p ^ (n + 1))), \u2190C_mul, \u2190C_mul, pow_succ,\n      mul_assoc \u2191p (\u2191p ^ n), h1, mul_one, C_1, one_mul, add_comm _ (X n ^ p), add_assoc, \u2190add_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 \u2191p * X (n + 1)), \u2190add_sub, add_right_inj, neg_eq_iff_eq_neg, neg_sub, eq_comm],\n  simp only [ring_hom.map_sum, mul_sum, sum_mul, \u2190sum_sub_distrib],\n  apply sum_congr rfl,\n  intros i hi,\n  rw mem_range at hi,\n  rw [\u2190 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 \u2191p ^ i), mul_comm _ ((X i ^ p) ^ _), mul_comm (C \u2191p ^ (j + 1)), mul_comm (C \u2191p)],\n  simp only [mul_assoc],\n  apply congr_arg,\n  apply congr_arg,\n  rw [\u2190C_eq_coe_nat],\n  simp only [\u2190ring_hom.map_pow, \u2190C_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\u2081 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 \u27e8j + 1, j.succ_pos\u27e9) * p * p ^ n : \u211a) =\n    p ^ j * p * ((p ^ (n - i)).choose (j + 1) * p ^ i) * p ^ (n - i - v p \u27e8j + 1, j.succ_pos\u27e9),\n  { have aux : \u2200 k : \u2115, (p ^ k : \u211a) \u2260 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 : \u211a), mul_assoc, mul_assoc, \u2190 pow_add, map_frobenius_poly.key\u2082 p hi.le hj],\n  ring_exp\nend\n\nlemma frobenius_poly_zmod (n : \u2115) :\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\u2081_frobenius_poly_witt_polynomial (n : \u2115) :\n  bind\u2081 (frobenius_poly p) (witt_polynomial p \u2124 n) = (witt_polynomial p \u2124 (n+1)) :=\nbegin\n  apply mv_polynomial.map_injective (int.cast_ring_hom \u211a) int.cast_injective,\n  simp only [map_bind\u2081, map_frobenius_poly, bind\u2081_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 : \ud835\udd4e R \u2192+* frobenius \ud835\udd4e R`. -/\ndef frobenius_fun (x : \ud835\udd4e R) : \ud835\udd4e R :=\nmk p $ \u03bb n, mv_polynomial.aeval x.coeff (frobenius_poly p n)\n\nlemma coeff_frobenius_fun (x : \ud835\udd4e R) (n : \u2115) :\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 (\u03bb R _Rcr, @frobenius_fun p R _ _Rcr) :=\n\u27e8\u27e8frobenius_poly p, by { introsI, funext n, apply coeff_frobenius_fun }\u27e9\u27e9\n\nvariable {p}\n\n@[ghost_simps] lemma ghost_component_frobenius_fun (n : \u2115) (x : \ud835\udd4e R) :\n  ghost_component n (frobenius_fun x) = ghost_component (n + 1) x :=\nby simp only [ghost_component_apply, frobenius_fun, coeff_mk,\n    \u2190 bind\u2081_frobenius_poly_witt_polynomial, aeval_bind\u2081]\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 : \ud835\udd4e R \u2192+* \ud835\udd4e R`.\n\nThe underlying function of this morphism is `witt_vector.frobenius_fun`.\n-/\ndef frobenius : \ud835\udd4e R \u2192+* \ud835\udd4e 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 : \ud835\udd4e R) (n : \u2115) :\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 : \u2115) (x : \ud835\udd4e 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 (\u03bb 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 : \ud835\udd4e R) (n : \u2115) :\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 (\u03bb k, x.coeff k) (frobenius_poly p n)\n      = aeval (\u03bb k, x.coeff k)\n          (mv_polynomial.map (int.cast_ring_hom (zmod p)) (frobenius_poly p n)) : _\n  ... = aeval (\u03bb k, x.coeff k) (X n ^ p : mv_polynomial \u2115 (zmod p)) : _\n  ... = (x.coeff n) ^ p : _,\n  { conv_rhs { rw [aeval_eq_eval\u2082_hom, eval\u2082_hom_map_hom] },\n    apply eval\u2082_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 : \ud835\udd4e (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 \u2243+* witt_vector p R :=\n{ to_fun := witt_vector.frobenius,\n  inv_fun := map (pth_root R p),\n  left_inv := \u03bb f, ext $ \u03bb n, by { rw frobenius_eq_map_frobenius, exact pth_root_frobenius _ },\n  right_inv := \u03bb f, ext $ \u03bb n, by { rw frobenius_eq_map_frobenius, exact frobenius_pth_root _ },\n   ..(witt_vector.frobenius : witt_vector p R \u2192+* 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 \u2192 Type v}\n\n@[simp]\ntheorem mfoldl_nil [monad m]\n                   {s : Type u}\n                   {\u03b1 : Type w}\n                   (f : s \u2192 \u03b1 \u2192 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                    {\u03b1 : Type w}\n                    (f : s \u2192 \u03b1 \u2192 m s)\n                    (x : s)\n                    (h : \u03b1)\n                    (r : list \u03b1)\n: mfoldl f x (h :: r) =  f x h >>= \u03bby, 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 {\u03b1 : Type*} [decidable_eq \u03b1]\n\n/-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/\ndef next_or : \u03a0 (xs : list \u03b1) (x default : \u03b1), \u03b1\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 : \u03b1) : next_or [] x d = d := rfl\n\n@[simp] lemma next_or_singleton (x y d : \u03b1) : next_or [y] x d = d := rfl\n\n@[simp] lemma next_or_self_cons_cons (xs : list \u03b1) (x y d : \u03b1) :\n  next_or (x :: y :: xs) x d = y :=\nif_pos rfl\n\nlemma next_or_cons_of_ne (xs : list \u03b1) (y x d : \u03b1) (h : x \u2260 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 \u03b1) (x d d' : \u03b1)\n  (x_mem : x \u2208 xs) (x_ne : x \u2260 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 \u03b1} {x d : \u03b1} (h : next_or xs x d \u2260 d) :\n  x \u2208 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 \u03b1} {x : \u03b1} (d : \u03b1) (h : x \u2209 xs) :\n  next_or (xs ++ [x]) x d = d :=\nbegin\n  induction xs with z zs IH,\n  { simp },\n  { obtain \u27e8hz, hzs\u27e9 := 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 \u03b1} {x d : \u03b1} (hd : d \u2208 xs) :\n  next_or xs x d \u2208 xs :=\nbegin\n  revert hd,\n  suffices : \u2200 (xs' : list \u03b1) (h : \u2200 x \u2208 xs, x \u2208 xs') (hd : d \u2208 xs'), next_or xs x d \u2208 xs',\n  { exact this xs (\u03bb _, 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 (\u03bb _ h, hxs' _ (mem_cons_of_mem _ h)) },\nend\n\n/--\nGiven an element `x : \u03b1` of `l : list \u03b1` such that `x \u2208 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 \u03b1) (x : \u03b1) (h : x \u2208 l) : \u03b1 :=\nnext_or l x (l.nth_le 0 (length_pos_of_mem h))\n\n/--\nGiven an element `x : \u03b1` of `l : list \u03b1` such that `x \u2208 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 : \u03a0 (l : list \u03b1) (x : \u03b1) (h : x \u2208 l), \u03b1\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 \u03b1) (x : \u03b1) (h : x \u2208 l)\n\n@[simp] lemma next_singleton (x y : \u03b1) (h : x \u2208 [y]) :\n  next [y] x h = y := rfl\n\n@[simp] lemma prev_singleton (x y : \u03b1) (h : x \u2208 [y]) :\n  prev [y] x h = y := rfl\n\nlemma next_cons_cons_eq' (y z : \u03b1) (h : x \u2208 (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 : \u03b1) (h : x \u2208 (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 : \u03b1) (h : x \u2208 (y :: l)) (hy : x \u2260 y)\n  (hx : x \u2260 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 : \u03b1) (hy : x \u2260 y) (hx : x \u2209 l)\n  (h : x \u2208 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 : \u03b1) (h : x \u2208 (y :: l)) (hy : x \u2260 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, \u2190init_append_last (cons_ne_nil y l), hx, next_or_concat],\n  subst hx,\n  intro H,\n  obtain \u27e8_ | k, hk, hk'\u27e9 := 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 : \u03b1) (h : x \u2208 (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 \u2208 (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 : \u03b1) (h : x \u2208 (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 : \u03b1) (h : x \u2208 (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 : \u03b1) (h : x \u2208 (y :: z :: l)) (hy : x \u2260 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 : \u03b1) (h : x \u2208 (y :: x :: l)) (hy : x \u2260 y) :\n  prev (y :: x :: l) x h = y :=\nprev_cons_cons_of_ne' _ _ _ _ _ hy rfl\n\nlemma prev_ne_cons_cons (y z : \u03b1) (h : x \u2208 (y :: z :: l)) (hy : x \u2260 y) (hz : x \u2260 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 \u2208 l :=\nnext_or_mem (nth_le_mem _ _ _)\n\nlemma prev_mem : l.prev x h \u2208 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 \u03b1) (h : nodup l) (n : \u2115) (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 \u2264 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 \u2260 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 \u03b1) (h : nodup l) (n : \u2115) (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 : \u2200 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, \u2190nat.add_succ, nat.add_mod_right, nat.succ_add, \u2190nat.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 (\u03bb _ 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 (\u03bb _ 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 \u03b1) (h : nodup l) (x : \u03b1) (hx : x \u2208 l) :\n  prev l (next l x hx) (next_mem _ _ _) = x :=\nbegin\n  obtain \u27e8n, hn, rfl\u27e9 := 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 \u03b1) (h : nodup l) (x : \u03b1) (hx : x \u2208 l) :\n  next l (prev l x hx) (prev_mem _ _ _) = x :=\nbegin\n  obtain \u27e8n, hn, rfl\u27e9 := 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 \u03b1) (h : nodup l) (x : \u03b1) (hx : x \u2208 l) :\n  prev l.reverse x (mem_reverse.mpr hx) = next l x hx :=\nbegin\n  obtain \u27e8k, hk, rfl\u27e9 := 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 \u2190nth_le_pmap l.next (\u03bb _ h, h) (by simpa using hk),\n  simp_rw [\u2190nth_le_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h],\n  rw \u2190nth_le_pmap l.reverse.prev (\u03bb _ 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 \u2190nth_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 \u03b1) (h : nodup l) (x : \u03b1) (hx : x \u2208 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 \u03b1} (h : l ~r l') (hn : nodup l) {x : \u03b1} (hx : x \u2208 l) :\n  l.next x hx = l'.next x (h.mem_iff.mp hx) :=\nbegin\n  obtain \u27e8k, hk, rfl\u27e9 := nth_le_of_mem hx,\n  obtain \u27e8n, rfl\u27e9 := id h,\n  rw [next_nth_le _ hn],\n  simp_rw \u2190nth_le_rotate' _ n k,\n  rw [next_nth_le _ (h.nodup_iff.mp hn), \u2190nth_le_rotate' _ n],\n  simp [add_assoc]\nend\n\nlemma is_rotated_prev_eq {l l' : list \u03b1} (h : l ~r l') (hn : nodup l) {x : \u03b1} (hx : x \u2208 l) :\n  l.prev x hx = l'.prev x (h.mem_iff.mp hx) :=\nbegin\n  rw [\u2190next_reverse_eq_prev _ hn, \u2190next_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 \u03b1` is the quotient of `list \u03b1` by cyclic permutation.\nDuplicates are allowed.\n-/\ndef cycle (\u03b1 : Type*) : Type* := quotient (is_rotated.setoid \u03b1)\n\nnamespace cycle\n\nvariables {\u03b1 : Type*}\n\ninstance : has_coe (list \u03b1) (cycle \u03b1) := \u27e8quot.mk _\u27e9\n\n@[simp] lemma coe_eq_coe {l\u2081 l\u2082 : list \u03b1} : (l\u2081 : cycle \u03b1) = l\u2082 \u2194 (l\u2081 ~r l\u2082) :=\n@quotient.eq _ (is_rotated.setoid _) _ _\n\n@[simp] lemma mk_eq_coe (l : list \u03b1) :\n  quot.mk _ l = (l : cycle \u03b1) := rfl\n\n@[simp] lemma mk'_eq_coe (l : list \u03b1) :\n  quotient.mk' l = (l : cycle \u03b1) := rfl\n\ninstance : inhabited (cycle \u03b1) := \u27e8(([] : list \u03b1) : cycle \u03b1)\u27e9\n\n/--\nFor `x : \u03b1`, `s : cycle \u03b1`, `x \u2208 s` indicates that `x` occurs at least once in `s`.\n-/\ndef mem (a : \u03b1) (s : cycle \u03b1) : Prop :=\nquot.lift_on s (\u03bb l, a \u2208 l) (\u03bb l\u2081 l\u2082 (e : l\u2081 ~r l\u2082), propext $ e.mem_iff)\n\ninstance : has_mem \u03b1 (cycle \u03b1) := \u27e8mem\u27e9\n\n@[simp] lemma mem_coe_iff {a : \u03b1} {l : list \u03b1} :\n  a \u2208 (l : cycle \u03b1) \u2194 a \u2208 l := iff.rfl\n\ninstance [decidable_eq \u03b1] : decidable_eq (cycle \u03b1) :=\n\u03bb s\u2081 s\u2082, quotient.rec_on_subsingleton\u2082' s\u2081 s\u2082 (\u03bb l\u2081 l\u2082,\n  decidable_of_iff' _ quotient.eq')\n\ninstance [decidable_eq \u03b1] (x : \u03b1) (s : cycle \u03b1) : decidable (x \u2208 s) :=\nquotient.rec_on_subsingleton' s (\u03bb l, list.decidable_mem x l)\n\n/--\nReverse a `s : cycle \u03b1` by reversing the underlying `list`.\n-/\ndef reverse (s : cycle \u03b1) : cycle \u03b1 :=\nquot.map reverse (\u03bb l\u2081 l\u2082 (e : l\u2081 ~r l\u2082), e.reverse) s\n\n@[simp] lemma reverse_coe (l : list \u03b1) :\n  (l : cycle \u03b1).reverse = l.reverse := rfl\n\n@[simp] lemma mem_reverse_iff {a : \u03b1} {s : cycle \u03b1} :\n  a \u2208 s.reverse \u2194 a \u2208 s :=\nquot.induction_on s (\u03bb _, mem_reverse)\n\n@[simp] lemma reverse_reverse (s : cycle \u03b1) :\n  s.reverse.reverse = s :=\nquot.induction_on s (\u03bb _, by simp)\n\n/--\nThe length of the `s : cycle \u03b1`, which is the number of elements, counting duplicates.\n-/\ndef length (s : cycle \u03b1) : \u2115 :=\nquot.lift_on s length (\u03bb l\u2081 l\u2082 (e : l\u2081 ~r l\u2082), e.perm.length_eq)\n\n@[simp] lemma length_coe (l : list \u03b1) :\n  length (l : cycle \u03b1) = l.length := rfl\n\n@[simp] lemma length_reverse (s : cycle \u03b1) :\n  s.reverse.length = s.length :=\nquot.induction_on s length_reverse\n\n/--\nA `s : cycle \u03b1` that is at most one element.\n-/\ndef subsingleton (s : cycle \u03b1) : Prop :=\ns.length \u2264 1\n\nlemma length_subsingleton_iff {s : cycle \u03b1} :\n  subsingleton s \u2194 length s \u2264 1 := iff.rfl\n\n@[simp] lemma subsingleton_reverse_iff {s : cycle \u03b1} :\n  s.reverse.subsingleton \u2194 s.subsingleton :=\nby simp [length_subsingleton_iff]\n\nlemma subsingleton.congr {s : cycle \u03b1} (h : subsingleton s) :\n  \u2200 \u2983x\u2984 (hx : x \u2208 s) \u2983y\u2984 (hy : y \u2208 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|\u27e8z, rfl\u27e9;\n  simp\nend\n\n/--\nA `s : cycle \u03b1` that is made up of at least two unique elements.\n-/\ndef nontrivial (s : cycle \u03b1) : Prop := \u2203 (x y : \u03b1) (h : x \u2260 y), x \u2208 s \u2227 y \u2208 s\n\n@[simp] lemma nontrivial_coe_nodup_iff {l : list \u03b1} (hl : l.nodup) :\n  nontrivial (l : cycle \u03b1) \u2194 2 \u2264 l.length :=\nbegin\n  rw nontrivial,\n  rcases l with (_ | \u27e8hd, _ | \u27e8hd', tl\u27e9\u27e9),\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 \u27e8hd, hd', _, by simp\u27e9,\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 \u03b1} :\n  s.reverse.nontrivial \u2194 s.nontrivial :=\nby simp [nontrivial]\n\nlemma length_nontrivial {s : cycle \u03b1} (h : nontrivial s) :\n  2 \u2264 length s :=\nbegin\n  obtain \u27e8x, y, hxy, hx, hy\u27e9 := h,\n  induction s using quot.induction_on with l,\n  rcases l with (_ | \u27e8hd, _ | \u27e8hd', tl\u27e9\u27e9),\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 \u03b1` contains no duplicates.\n-/\ndef nodup (s : cycle \u03b1) : Prop :=\nquot.lift_on s nodup (\u03bb l\u2081 l\u2082 (e : l\u2081 ~r l\u2082), propext $ e.nodup_iff)\n\n@[simp] lemma nodup_coe_iff {l : list \u03b1} :\n  nodup (l : cycle \u03b1) \u2194 l.nodup := iff.rfl\n\n@[simp] lemma nodup_reverse_iff {s : cycle \u03b1} :\n  s.reverse.nodup \u2194 s.nodup :=\nquot.induction_on s (\u03bb _, nodup_reverse)\n\nlemma subsingleton.nodup {s : cycle \u03b1} (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 \u03b1} (h : nodup s) :\n  nontrivial s \u2194 \u00ac 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 \u03b1` as a `multiset \u03b1`.\n-/\ndef to_multiset (s : cycle \u03b1) : multiset \u03b1 :=\nquotient.lift_on' s (\u03bb l, (l : multiset \u03b1)) (\u03bb l\u2081 l\u2082 (h : l\u2081 ~r l\u2082), multiset.coe_eq_coe.mpr h.perm)\n\n/--\nThe lift of `list.map`.\n-/\ndef map {\u03b2 : Type*} (f : \u03b1 \u2192 \u03b2) : cycle \u03b1 \u2192 cycle \u03b2 :=\nquotient.map' (list.map f) $ \u03bb l\u2081 l\u2082 h, h.map _\n\n/--\nThe `multiset` of lists that can make the cycle.\n-/\ndef lists (s : cycle \u03b1) : multiset (list \u03b1) :=\nquotient.lift_on' s\n  (\u03bb l, (l.cyclic_permutations : multiset (list \u03b1))) $\n  \u03bb l\u2081 l\u2082 (h : l\u2081 ~r l\u2082), by simpa using h.cyclic_permutations.perm\n\n@[simp] lemma mem_lists_iff_coe_eq {s : cycle \u03b1} {l : list \u03b1} :\n  l \u2208 s.lists \u2194 (l : cycle \u03b1) = 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 \u03b1]\n\n/--\nAuxiliary decidability algorithm for lists that contain at least two unique elements.\n-/\ndef decidable_nontrivial_coe : \u03a0 (l : list \u03b1), decidable (nontrivial (l : cycle \u03b1))\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 \u03b1))\n    (by simp [h, nontrivial])\n    (decidable_nontrivial_coe (x :: l))\n  else is_true \u27e8x, y, h, by simp, by simp\u27e9\n\ninstance {s : cycle \u03b1} : decidable (nontrivial s) :=\nquot.rec_on_subsingleton s decidable_nontrivial_coe\n\ninstance {s : cycle \u03b1} : decidable (nodup s) :=\nquot.rec_on_subsingleton s (\u03bb (l : list \u03b1), list.nodup_decidable l)\n\ninstance fintype_nodup_cycle [fintype \u03b1] : fintype {s : cycle \u03b1 // s.nodup} :=\nfintype.of_surjective (\u03bb (l : {l : list \u03b1 // l.nodup}), \u27e8l.val, by simpa using l.prop\u27e9) (\u03bb \u27e8s, hs\u27e9,\n  begin\n    induction s using quotient.induction_on',\n    exact \u27e8\u27e8s, hs\u27e9, by simp\u27e9\n  end)\n\ninstance fintype_nodup_nontrivial_cycle [fintype \u03b1] :\n  fintype {s : cycle \u03b1 // s.nodup \u2227 s.nontrivial} :=\nfintype.subtype (((finset.univ : finset {s : cycle \u03b1 // s.nodup}).map\n  (function.embedding.subtype _)).filter cycle.nontrivial)\n  (by simp)\n\n/--\nThe `s : cycle \u03b1` as a `finset \u03b1`.\n-/\ndef to_finset (s : cycle \u03b1) : finset \u03b1 :=\ns.to_multiset.to_finset\n\n/-- Given a `s : cycle \u03b1` such that `nodup s`, retrieve the next element after `x \u2208 s`. -/\ndef next : \u03a0 (s : cycle \u03b1) (hs : nodup s) (x : \u03b1) (hx : x \u2208 s), \u03b1 :=\n\u03bb s, quot.hrec_on s (\u03bb l hn x hx, next l x hx)\n  (\u03bb l\u2081 l\u2082 (h : l\u2081 ~r l\u2082),\n  function.hfunext (propext h.nodup_iff) (\u03bb h\u2081 h\u2082 he, function.hfunext rfl\n    (\u03bb x y hxy, function.hfunext (propext (by simpa [eq_of_heq hxy] using h.mem_iff))\n    (\u03bb hm hm' he', heq_of_eq (by simpa [eq_of_heq hxy] using is_rotated_next_eq h h\u2081 _)))))\n\n/-- Given a `s : cycle \u03b1` such that `nodup s`, retrieve the previous element before `x \u2208 s`. -/\ndef prev : \u03a0 (s : cycle \u03b1) (hs : nodup s) (x : \u03b1) (hx : x \u2208 s), \u03b1 :=\n\u03bb s, quot.hrec_on s (\u03bb l hn x hx, prev l x hx)\n  (\u03bb l\u2081 l\u2082 (h : l\u2081 ~r l\u2082),\n  function.hfunext (propext h.nodup_iff) (\u03bb h\u2081 h\u2082 he, function.hfunext rfl\n    (\u03bb x y hxy, function.hfunext (propext (by simpa [eq_of_heq hxy] using h.mem_iff))\n    (\u03bb hm hm' he', heq_of_eq (by simpa [eq_of_heq hxy] using is_rotated_prev_eq h h\u2081 _)))))\n\n@[simp] lemma prev_reverse_eq_next (s : cycle \u03b1) (hs : nodup s) (x : \u03b1) (hx : x \u2208 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 \u03b1) (hs : nodup s) (x : \u03b1) (hx : x \u2208 s) :\n  s.reverse.next (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.prev hs x hx :=\nby simp [\u2190prev_reverse_eq_next]\n\n@[simp] lemma next_mem (s : cycle \u03b1) (hs : nodup s) (x : \u03b1) (hx : x \u2208 s) :\n  s.next hs x hx \u2208 s :=\nbegin\n  induction s using quot.induction_on,\n  exact next_mem _ _ _\nend\n\nlemma prev_mem (s : cycle \u03b1) (hs : nodup s) (x : \u03b1) (hx : x \u2208 s) :\n  s.prev hs x hx \u2208 s :=\nby { rw [\u2190next_reverse_eq_prev, \u2190mem_reverse_iff], exact next_mem _ _ _ _ }\n\n@[simp] lemma prev_next (s : cycle \u03b1) (hs : nodup s) (x : \u03b1) (hx : x \u2208 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 \u03b1) (hs : nodup s) (x : \u03b1) (hx : x \u2208 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 \u03b1] : has_repr (cycle \u03b1) :=\n\u27e8\u03bb s, \"c[\" ++ string.intercalate \", \" ((s.map repr).lists.sort (\u2264)).head ++ \"]\"\u27e9\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\u2081 v\u2081 u\u2082 v\u2082\n\nvariables {C : Type u\u2081} [\ud835\udc9e : category.{v\u2081 u\u2081} C] {D : Type u\u2082} [\ud835\udc9f : category.{v\u2082 u\u2082} D]\ninclude \ud835\udc9e \ud835\udc9f\n\nstructure Adjunction (L : C \u2964 D) (R : D \u2964 C) :=\n  (unit       : functor.id _ \u27f9 (L \u22d9 R))\n  (counit     : (R \u22d9 L) \u27f9 functor.id _)\n  (triangle_1 : \u2200 X : D, (unit.app (R.obj X)) \u226b (R.map (counit.app X)) = \ud835\udfd9 (R.obj X))\n  (triangle_2 : \u2200 X : C, (L.map (unit.app X)) \u226b (counit.app (L.obj X)) = \ud835\udfd9 (L.obj X))\n\nattribute [simp,search] Adjunction.triangle_1 Adjunction.triangle_2\n\nlemma Adjunctions_pointwise_equal\n  (L : C \u2964 D) (R : D \u2964 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 \u2964 D} {R : D \u2964 C} (A : Adjunction L R) {X Y : C} (f : X \u27f6 Y) : (A.unit.app X) \u226b (R.map (L.map f)) = f \u226b (A.unit.app Y) :=\nby obviously\n\n@[simp,search] lemma Adjunction.counit_naturality {L : C \u2964 D} {R : D \u2964 C} (A : Adjunction L R) {X Y : D} (f : X \u27f6 Y) : (L.map (R.map f)) \u226b (A.counit.app Y) = (A.counit.app X) \u226b f :=\nby obviously\n\nend\n\ninfix ` \u22a3 `:50 := Adjunction\n\nsection\nuniverses u\u2081 v\u2081\n\nvariables {C : Type u\u2081} [\ud835\udc9e : category.{v\u2081 u\u2081} C] {D : Type u\u2081} [\ud835\udc9f : category.{v\u2081 u\u2081} D]\ninclude \ud835\udc9e \ud835\udc9f \n\ndef hom_adjunction (L : C \u2964 D) (R : D \u2964 C) :=\n    ((functor.prod L.op (functor.id D)) \u22d9 (functor.hom D))\n      \u2245 \n    (functor.prod (functor.id (C\u1d52\u1d56)) R) \u22d9 (functor.hom C)\n\ndef mate {L : C \u2964 D} {R : D \u2964 C} (A : hom_adjunction L R) {X : C} {Y : D} (f : (L.obj X) \u27f6 Y) : \n  X \u27f6 (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\u2081 u\u2081 u\u2082 v\u2082 u\u2083 v\u2083 u\u2084 v\u2084\n\nsection\nvariables {A : Type u\u2081} [\ud835\udc9c : category.{v\u2081 u\u2081} A] {B : Type u\u2082} [\u212c : category.{v\u2082 u\u2082} B] {C : Type u\u2083} [\ud835\udc9e : category.{v\u2083 u\u2083} C] {D : Type u\u2084} [\ud835\udc9f : category.{v\u2084 u\u2084} D]\ninclude \ud835\udc9c \u212c \ud835\udc9e \ud835\udc9f\n\n@[simp,search] lemma prod_obj' (F : A \u2964 B) (G : C \u2964 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 \u2964 B} {H I : C \u2964 D} (\u03b1 : F \u27f9 G) (\u03b2 : H \u27f9 I) (a : A) (c : C) : (nat_trans.prod \u03b1 \u03b2).app (a, c) = (\u03b1.app a, \u03b2.app c) := rfl\nend\n\nvariables {C : Type u\u2081} [\ud835\udc9e : category.{v\u2081 u\u2081} C] {D : Type u\u2081} [\ud835\udc9f : category.{v\u2081 u\u2081} D]\ninclude \ud835\udc9e \ud835\udc9f\nvariables {L : C \u2964 D} {R : D \u2964 C}\n\n@[reducible] private def Adjunction_to_HomAdjunction_morphism (A : L \u22a3 R)\n  : ((functor.prod L.op (functor.id D)) \u22d9 (functor.hom D)) \u27f9\n                          (functor.prod (functor.id (C\u1d52\u1d56)) R) \u22d9 (functor.hom C) :=\n{ app := \u03bb 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    \u03bb f, (A.unit.app (unop P.1)) \u226b (R.map f) }\n\n@[reducible] private def Adjunction_to_HomAdjunction_inverse (A : L \u22a3 R)\n  : (functor.prod (functor.id (C\u1d52\u1d56)) R) \u22d9 (functor.hom C) \u27f9\n                          ((functor.prod L.op (functor.id D)) \u22d9 (functor.hom D)) :=\n{ app := \u03bb 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    \u03bb f, (L.map f) \u226b (A.counit.app P.2) }\n\ndef Adjunction_to_HomAdjunction (A : L \u22a3 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 \u27f6 Y) : (((A.hom).app (op X, L.obj X)) (\ud835\udfd9 (L.obj X))) \u226b\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) (\ud835\udfd9 (op X), L.map f),\n  have q := congr_fun p (L.map (\ud835\udfd9 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 \u27f6 Y) : f \u226b (((A.hom).app (op Y, L.obj Y)) (\ud835\udfd9 (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, \ud835\udfd9 (L.obj Y)),\n  have q := congr_fun p (L.map (\ud835\udfd9 Y)),\n  obviously,\nend\n\n@[simp,search] lemma mate_of_R (A : hom_adjunction L R) {X Y : D} (f : X \u27f6 Y) : (L.map (R.map f)) \u226b (((A.inv).app (op (R.obj Y), Y)) (\ud835\udfd9 (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, \ud835\udfd9 Y),\n  have q := congr_fun p (R.map (\ud835\udfd9 Y)),\n  tidy,\nend\n\n@[simp,search] lemma mate_of_R' (A : hom_adjunction L R) {X Y : D} (f : X \u27f6 Y) : (((A.inv).app (op (R.obj X), X)) (\ud835\udfd9 (R.obj X))) \u226b 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) (\ud835\udfd9 (op (R.obj X)), f),\n  have q := congr_fun p (R.map (\ud835\udfd9 X)),\n  obviously,\nend\n\nprivate def counit_from_HomAdjunction (A : hom_adjunction L R) : (R \u22d9 L) \u27f9 (functor.id _) :=\n{ app := \u03bb X : D, (A.inv.app (op (R.obj X), X)) (\ud835\udfd9 (R.obj X)) }\n\nprivate def unit_from_HomAdjunction (A : hom_adjunction L R) : (functor.id _) \u27f9 (L \u22d9 R) :=\n{ app := \u03bb X : C, (A.hom.app (op X, L.obj X)) (\ud835\udfd9 (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\u00e9my 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 \u03bc := integrable f (\u03bc.restrict s)` and prove theorems like\n`integrable_on_union : integrable_on f (s \u222a t) \u03bc \u2194 integrable_on f s \u03bc \u2227 integrable_on f t \u03bc`.\n\nNext we define a predicate `integrable_at_filter (f : \u03b1 \u2192 E) (l : filter \u03b1) (\u03bc : measure \u03b1)`\nsaying that `f` is integrable at some set `s \u2208 l` and prove that a measurable function is integrable\nat `l` with respect to `\u03bc` provided that `f` is bounded above at `l \u2293 \u03bc.ae` and `\u03bc` 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 {\u03b1 \u03b2 E F : Type*} [measurable_space \u03b1]\n\nsection\n\nvariables [topological_space \u03b2] {l l' : filter \u03b1} {f g : \u03b1 \u2192 \u03b2} {\u03bc \u03bd : measure \u03b1}\n\n/-- A function `f` is strongly measurable at a filter `l` w.r.t. a measure `\u03bc` if it is\nae strongly measurable w.r.t. `\u03bc.restrict s` for some `s \u2208 l`. -/\ndef strongly_measurable_at_filter (f : \u03b1 \u2192 \u03b2) (l : filter \u03b1) (\u03bc : measure \u03b1 . volume_tac) :=\n\u2203 s \u2208 l, ae_strongly_measurable f (\u03bc.restrict s)\n\n@[simp] lemma strongly_measurable_at_bot {f : \u03b1 \u2192 \u03b2} : strongly_measurable_at_filter f \u22a5 \u03bc :=\n\u27e8\u2205, mem_bot, by simp\u27e9\n\nprotected lemma strongly_measurable_at_filter.eventually (h : strongly_measurable_at_filter f l \u03bc) :\n  \u2200\u1da0 s in l.small_sets, ae_strongly_measurable f (\u03bc.restrict s) :=\n(eventually_small_sets' $ \u03bb 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 \u03bc) (h' : l' \u2264 l) :\n  strongly_measurable_at_filter f l' \u03bc :=\nlet \u27e8s, hsl, hs\u27e9 := h in \u27e8s, h' hsl, hs\u27e9\n\nprotected lemma measure_theory.ae_strongly_measurable.strongly_measurable_at_filter\n  (h : ae_strongly_measurable f \u03bc) :\n  strongly_measurable_at_filter f l \u03bc :=\n\u27e8univ, univ_mem, by rwa measure.restrict_univ\u27e9\n\nlemma ae_strongly_measurable.strongly_measurable_at_filter_of_mem\n  {s} (h : ae_strongly_measurable f (\u03bc.restrict s)) (hl : s \u2208 l) :\n  strongly_measurable_at_filter f l \u03bc :=\n\u27e8s, hl, h\u27e9\n\nprotected lemma measure_theory.strongly_measurable.strongly_measurable_at_filter\n  (h : strongly_measurable f) :\n  strongly_measurable_at_filter f l \u03bc :=\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 : \u03b1 \u2192 E} {s : set \u03b1}\n  {\u03bc : measure \u03b1} {C}  (hs : \u03bc s < \u221e) (hf : \u2200\u1d50 x \u2202(\u03bc.restrict s), \u2016f x\u2016 \u2264 C) :\n  has_finite_integral f (\u03bc.restrict s) :=\nby haveI : is_finite_measure (\u03bc.restrict s) := \u27e8by rwa [measure.restrict_apply_univ]\u27e9;\n  exact has_finite_integral_of_bounded hf\n\nvariables [normed_add_comm_group E] {f g : \u03b1 \u2192 E} {s t : set \u03b1} {\u03bc \u03bd : measure \u03b1}\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 : \u03b1 \u2192 E) (s : set \u03b1) (\u03bc : measure \u03b1 . volume_tac) : Prop :=\nintegrable f (\u03bc.restrict s)\n\nlemma integrable_on.integrable (h : integrable_on f s \u03bc) :\n  integrable f (\u03bc.restrict s) := h\n\n@[simp] lemma integrable_on_empty : integrable_on f \u2205 \u03bc :=\nby simp [integrable_on, integrable_zero_measure]\n\n@[simp] lemma integrable_on_univ : integrable_on f univ \u03bc \u2194 integrable f \u03bc :=\nby rw [integrable_on, measure.restrict_univ]\n\nlemma integrable_on_zero : integrable_on (\u03bb _, (0:E)) s \u03bc := integrable_zero _ _ _\n\n@[simp] lemma integrable_on_const {C : E} : integrable_on (\u03bb _, C) s \u03bc \u2194 C = 0 \u2228 \u03bc s < \u221e :=\nintegrable_const_iff.trans $ by rw [measure.restrict_apply_univ]\n\nlemma integrable_on.mono (h : integrable_on f t \u03bd) (hs : s \u2286 t) (h\u03bc : \u03bc \u2264 \u03bd) :\n  integrable_on f s \u03bc :=\nh.mono_measure $ measure.restrict_mono hs h\u03bc\n\nlemma integrable_on.mono_set (h : integrable_on f t \u03bc) (hst : s \u2286 t) :\n  integrable_on f s \u03bc :=\nh.mono hst le_rfl\n\nlemma integrable_on.mono_measure (h : integrable_on f s \u03bd) (h\u03bc : \u03bc \u2264 \u03bd) :\n  integrable_on f s \u03bc :=\nh.mono (subset.refl _) h\u03bc\n\nlemma integrable_on.mono_set_ae (h : integrable_on f t \u03bc) (hst : s \u2264\u1d50[\u03bc] t) :\n  integrable_on f s \u03bc :=\nh.integrable.mono_measure $ measure.restrict_mono_ae hst\n\nlemma integrable_on.congr_set_ae (h : integrable_on f t \u03bc) (hst : s =\u1d50[\u03bc] t) :\n  integrable_on f s \u03bc :=\nh.mono_set_ae hst.le\n\nlemma integrable_on.congr_fun' (h : integrable_on f s \u03bc) (hst : f =\u1d50[\u03bc.restrict s] g) :\n  integrable_on g s \u03bc :=\nintegrable.congr h hst\n\nlemma integrable_on.congr_fun (h : integrable_on f s \u03bc) (hst : eq_on f g s)\n  (hs : measurable_set s) :\n  integrable_on g s \u03bc :=\nh.congr_fun' ((ae_restrict_iff' hs).2 (eventually_of_forall hst))\n\nlemma integrable.integrable_on (h : integrable f \u03bc) : integrable_on f s \u03bc :=\nh.mono_measure $ measure.restrict_le_self\n\nlemma integrable.integrable_on' (h : integrable f (\u03bc.restrict s)) : integrable_on f s \u03bc :=\nh\n\nlemma integrable_on.restrict (h : integrable_on f s \u03bc) (hs : measurable_set s) :\n  integrable_on f s (\u03bc.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 \u222a t) \u03bc) : integrable_on f s \u03bc :=\nh.mono_set $ subset_union_left _ _\n\nlemma integrable_on.right_of_union (h : integrable_on f (s \u222a t) \u03bc) : integrable_on f t \u03bc :=\nh.mono_set $ subset_union_right _ _\n\nlemma integrable_on.union (hs : integrable_on f s \u03bc) (ht : integrable_on f t \u03bc) :\n  integrable_on f (s \u222a t) \u03bc :=\n(hs.add_measure ht).mono_measure $ measure.restrict_union_le _ _\n\n@[simp] lemma integrable_on_union :\n  integrable_on f (s \u222a t) \u03bc \u2194 integrable_on f s \u03bc \u2227 integrable_on f t \u03bc :=\n\u27e8\u03bb h, \u27e8h.left_of_union, h.right_of_union\u27e9, \u03bb h, h.1.union h.2\u27e9\n\n@[simp] lemma integrable_on_singleton_iff {x : \u03b1} [measurable_singleton_class \u03b1] :\n  integrable_on f {x} \u03bc \u2194 f x = 0 \u2228 \u03bc {x} < \u221e :=\nbegin\n  have : f =\u1d50[\u03bc.restrict {x}] (\u03bb 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 \u03b2} (hs : s.finite)\n  {t : \u03b2 \u2192 set \u03b1} : integrable_on f (\u22c3 i \u2208 s, t i) \u03bc \u2194 \u2200 i \u2208 s, integrable_on f (t i) \u03bc :=\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 \u03b2} {t : \u03b2 \u2192 set \u03b1} :\n  integrable_on f (\u22c3 i \u2208 s, t i) \u03bc \u2194 \u2200 i \u2208 s, integrable_on f (t i) \u03bc :=\nintegrable_on_finite_bUnion s.finite_to_set\n\n@[simp] lemma integrable_on_finite_Union [finite \u03b2] {t : \u03b2 \u2192 set \u03b1} :\n  integrable_on f (\u22c3 i, t i) \u03bc \u2194 \u2200 i, integrable_on f (t i) \u03bc :=\nby { casesI nonempty_fintype \u03b2,\n  simpa using @integrable_on_finset_Union _ _ _ _ _ f \u03bc finset.univ t }\n\nlemma integrable_on.add_measure (h\u03bc : integrable_on f s \u03bc) (h\u03bd : integrable_on f s \u03bd) :\n  integrable_on f s (\u03bc + \u03bd) :=\nby { delta integrable_on, rw measure.restrict_add, exact h\u03bc.integrable.add_measure h\u03bd }\n\n@[simp] lemma integrable_on_add_measure :\n  integrable_on f s (\u03bc + \u03bd) \u2194 integrable_on f s \u03bc \u2227 integrable_on f s \u03bd :=\n\u27e8\u03bb h, \u27e8h.mono_measure (measure.le_add_right le_rfl),\n  h.mono_measure (measure.le_add_left le_rfl)\u27e9,\n  \u03bb h, h.1.add_measure h.2\u27e9\n\nlemma _root_.measurable_embedding.integrable_on_map_iff [measurable_space \u03b2] {e : \u03b1 \u2192 \u03b2}\n  (he : measurable_embedding e) {f : \u03b2 \u2192 E} {\u03bc : measure \u03b1} {s : set \u03b2} :\n  integrable_on f s (measure.map e \u03bc) \u2194 integrable_on (f \u2218 e) (e \u207b\u00b9' s) \u03bc :=\nby simp only [integrable_on, he.restrict_map, he.integrable_map_iff]\n\nlemma integrable_on_map_equiv [measurable_space \u03b2] (e : \u03b1 \u2243\u1d50 \u03b2) {f : \u03b2 \u2192 E} {\u03bc : measure \u03b1}\n  {s : set \u03b2} :\n  integrable_on f s (measure.map e \u03bc) \u2194 integrable_on (f \u2218 e) (e \u207b\u00b9' s) \u03bc :=\nby simp only [integrable_on, e.restrict_map, integrable_map_equiv e]\n\nlemma measure_preserving.integrable_on_comp_preimage [measurable_space \u03b2] {e : \u03b1 \u2192 \u03b2} {\u03bd}\n  (h\u2081 : measure_preserving e \u03bc \u03bd) (h\u2082 : measurable_embedding e) {f : \u03b2 \u2192 E} {s : set \u03b2} :\n  integrable_on (f \u2218 e) (e \u207b\u00b9' s) \u03bc \u2194 integrable_on f s \u03bd :=\n(h\u2081.restrict_preimage_emb h\u2082 s).integrable_comp_emb h\u2082\n\nlemma measure_preserving.integrable_on_image [measurable_space \u03b2] {e : \u03b1 \u2192 \u03b2} {\u03bd}\n  (h\u2081 : measure_preserving e \u03bc \u03bd) (h\u2082 : measurable_embedding e) {f : \u03b2 \u2192 E} {s : set \u03b1} :\n  integrable_on f (e '' s) \u03bd \u2194  integrable_on (f \u2218 e) s \u03bc :=\n((h\u2081.restrict_image_emb h\u2082 s).integrable_comp_emb h\u2082).symm\n\nlemma integrable_indicator_iff (hs : measurable_set s) :\n  integrable (indicator s f) \u03bc \u2194 integrable_on f s \u03bc :=\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 \u03bc) (hs : measurable_set s) :\n  integrable (indicator s f) \u03bc :=\n(integrable_indicator_iff hs).2 h\n\nlemma integrable.indicator (h : integrable f \u03bc) (hs : measurable_set s) :\n  integrable (indicator s f) \u03bc :=\nh.integrable_on.integrable_indicator hs\n\nlemma integrable_on.indicator (h : integrable_on f s \u03bc) (ht : measurable_set t) :\n  integrable_on (indicator t f) s \u03bc :=\nintegrable.indicator h ht\n\nlemma integrable_indicator_const_Lp {E} [normed_add_comm_group E]\n  {p : \u211d\u22650\u221e} {s : set \u03b1} (hs : measurable_set s) (h\u03bcs : \u03bc s \u2260 \u221e) (c : E) :\n  integrable (indicator_const_Lp p hs h\u03bcs c) \u03bc :=\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\u03bcs,\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 \u03bc s` coincides with its restriction\nto `s`. -/\nlemma integrable_on.restrict_to_measurable (hf : integrable_on f s \u03bc) (h's : \u2200 x \u2208 s, f x \u2260 0) :\n  \u03bc.restrict (to_measurable \u03bc s) = \u03bc.restrict s :=\nbegin\n  rcases exists_seq_strict_anti_tendsto (0 : \u211d) with \u27e8u, u_anti, u_pos, u_lim\u27e9,\n  let v := \u03bb n, to_measurable (\u03bc.restrict s) {x | u n \u2264 \u2016f x\u2016},\n  have A : \u2200 n, \u03bc (s \u2229 v n) \u2260 \u221e,\n  { assume n,\n    rw [inter_comm, \u2190 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 < \u2016f x\u2016, by simp only [h's x hx, norm_pos_iff, ne.def, not_false_iff],\n  obtain \u27e8n, hn\u27e9 : \u2203 n, u n < \u2016f x\u2016, from ((tendsto_order.1 u_lim).2 _ this).exists,\n  refine mem_Union.2 \u27e8n, _\u27e9,\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 \u03bc)\n  (ht : null_measurable_set t \u03bc) (h't : \u2200\u1d50 x \u2202\u03bc, x \u2208 t \\ s \u2192 f x = 0) :\n  integrable_on f t \u03bc :=\nbegin\n  let u := {x \u2208 s | f x \u2260 0},\n  have hu : integrable_on f u \u03bc := hf.mono_set (\u03bb x hx, hx.1),\n  let v := to_measurable \u03bc u,\n  have A : integrable_on f v \u03bc,\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) \u03bc,\n  { apply integrable_on_zero.congr,\n    filter_upwards [ae_restrict_of_ae h't, ae_restrict_mem\u2080\n      (ht.diff (measurable_set_to_measurable \u03bc u).null_measurable_set)] with x hxt hx,\n    by_cases h'x : x \u2208 s,\n    { by_contra H,\n      exact hx.2 (subset_to_measurable \u03bc u \u27e8h'x, ne.symm H\u27e9) },\n    { exact (hxt \u27e8hx.1, h'x\u27e9).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 \u03bc)\n  (ht : measurable_set t) (h't : \u2200 x \u2208 t \\ s, f x = 0) :\n  integrable_on f t \u03bc :=\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 \u03bc)\n  (h't : \u2200\u1d50 x \u2202\u03bc, x \u2209 s \u2192 f x = 0) : integrable f \u03bc :=\nbegin\n  rw \u2190 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 \u03bc)\n  (h't : \u2200 x \u2209 s, f x = 0) : integrable f \u03bc :=\nhf.integrable_of_ae_not_mem_eq_zero (eventually_of_forall (\u03bb x hx, h't x hx))\n\nlemma integrable_on_iff_integrable_of_support_subset (h1s : support f \u2286 s) :\n  integrable_on f s \u03bc \u2194 integrable f \u03bc :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb h, h.integrable_on\u27e9,\n  apply h.integrable_of_forall_not_mem_eq_zero (\u03bb 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 : \u211d\u22650\u221e} {s : set \u03b1} (f : Lp E p \u03bc) (hp : 1 \u2264 p) (h\u03bcs : \u03bc s \u2260 \u221e) :\n  integrable_on f s \u03bc :=\nbegin\n  refine mem_\u2112p_one_iff_integrable.mp _,\n  have h\u03bc_restrict_univ : (\u03bc.restrict s) set.univ < \u221e,\n    by simpa only [set.univ_inter, measurable_set.univ, measure.restrict_apply, lt_top_iff_ne_top],\n  haveI h\u03bc_finite : is_finite_measure (\u03bc.restrict s) := \u27e8h\u03bc_restrict_univ\u27e9,\n  exact ((Lp.mem_\u2112p _).restrict s).mem_\u2112p_of_exponent_le hp,\nend\n\nlemma integrable.lintegral_lt_top {f : \u03b1 \u2192 \u211d} (hf : integrable f \u03bc) :\n  \u222b\u207b x, ennreal.of_real (f x) \u2202\u03bc < \u221e :=\ncalc \u222b\u207b x, ennreal.of_real (f x) \u2202\u03bc\n    \u2264 \u222b\u207b x, \u2191\u2016f x\u2016\u208a \u2202\u03bc : lintegral_of_real_le_lintegral_nnnorm f\n... < \u221e : hf.2\n\nlemma integrable_on.set_lintegral_lt_top {f : \u03b1 \u2192 \u211d} {s : set \u03b1} (hf : integrable_on f s \u03bc) :\n  \u222b\u207b x in s, ennreal.of_real (f x) \u2202\u03bc < \u221e :=\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 \u2208 l`. Equivalently, it is eventually integrable on `s` in `l.small_sets`. -/\ndef integrable_at_filter (f : \u03b1 \u2192 E) (l : filter \u03b1) (\u03bc : measure \u03b1 . volume_tac) :=\n\u2203 s \u2208 l, integrable_on f s \u03bc\n\nvariables {l l' : filter \u03b1}\n\nlemma integrable.integrable_at_filter (h : integrable f \u03bc) (l : filter \u03b1) :\n  integrable_at_filter f l \u03bc :=\n\u27e8univ, filter.univ_mem, integrable_on_univ.2 h\u27e9\n\nprotected lemma integrable_at_filter.eventually (h : integrable_at_filter f l \u03bc) :\n  \u2200\u1da0 s in l.small_sets, integrable_on f s \u03bc :=\niff.mpr (eventually_small_sets' $ \u03bb s t hst ht, ht.mono_set hst) h\n\nlemma integrable_at_filter.filter_mono (hl : l \u2264 l') (hl' : integrable_at_filter f l' \u03bc) :\n  integrable_at_filter f l \u03bc :=\nlet \u27e8s, hs, hsf\u27e9 := hl' in \u27e8s, hl hs, hsf\u27e9\n\nlemma integrable_at_filter.inf_of_left (hl : integrable_at_filter f l \u03bc) :\n  integrable_at_filter f (l \u2293 l') \u03bc :=\nhl.filter_mono inf_le_left\n\nlemma integrable_at_filter.inf_of_right (hl : integrable_at_filter f l \u03bc) :\n  integrable_at_filter f (l' \u2293 l) \u03bc :=\nhl.filter_mono inf_le_right\n\n@[simp] lemma integrable_at_filter.inf_ae_iff {l : filter \u03b1} :\n  integrable_at_filter f (l \u2293 \u03bc.ae) \u03bc \u2194 integrable_at_filter f l \u03bc :=\nbegin\n  refine \u27e8_, \u03bb h, h.filter_mono inf_le_left\u27e9,\n  rintros \u27e8s, \u27e8t, ht, u, hu, rfl\u27e9, hf\u27e9,\n  refine \u27e8t, ht, _\u27e9,\n  refine hf.integrable.mono_measure (\u03bb v hv, _),\n  simp only [measure.restrict_apply hv],\n  refine measure_mono_ae (mem_of_superset hu $ \u03bb x hx, _),\n  exact \u03bb \u27e8hv, ht\u27e9, \u27e8hv, \u27e8ht, hx\u27e9\u27e9\nend\n\nalias integrable_at_filter.inf_ae_iff \u2194 integrable_at_filter.of_inf_ae _\n\n/-- If `\u03bc` 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 \u03b1} [is_measurably_generated l]\n  (hfm : strongly_measurable_at_filter f l \u03bc) (h\u03bc : \u03bc.finite_at_filter l)\n  (hf : l.is_bounded_under (\u2264) (norm \u2218 f)) :\n  integrable_at_filter f l \u03bc :=\nbegin\n  obtain \u27e8C, hC\u27e9 : \u2203 C, \u2200\u1da0 s in l.small_sets, \u2200 x \u2208 s, \u2016f x\u2016 \u2264 C,\n    from hf.imp (\u03bb C hC, eventually_small_sets.2 \u27e8_, hC, \u03bb t, id\u27e9),\n  rcases (hfm.eventually.and (h\u03bc.eventually.and hC)).exists_measurable_mem_of_small_sets\n    with \u27e8s, hsl, hsm, hfm, h\u03bc, hC\u27e9,\n  refine \u27e8s, hsl, \u27e8hfm, has_finite_integral_restrict_of_bounded h\u03bc _\u27e9\u27e9,\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 \u03b1} [is_measurably_generated l] (hfm : strongly_measurable_at_filter f l \u03bc)\n  (h\u03bc : \u03bc.finite_at_filter l) {b} (hf : tendsto f (l \u2293 \u03bc.ae) (\ud835\udcdd b)) :\n  integrable_at_filter f l \u03bc :=\n(h\u03bc.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 \u2190\n  _root_.filter.tendsto.integrable_at_filter_ae\n\nlemma measure.finite_at_filter.integrable_at_filter_of_tendsto {l : filter \u03b1}\n  [is_measurably_generated l] (hfm : strongly_measurable_at_filter f l \u03bc)\n  (h\u03bc : \u03bc.finite_at_filter l) {b} (hf : tendsto f l (\ud835\udcdd b)) :\n  integrable_at_filter f l \u03bc :=\nh\u03bc.integrable_at_filter hfm hf.norm.is_bounded_under_le\n\nalias measure.finite_at_filter.integrable_at_filter_of_tendsto \u2190\n  _root_.filter.tendsto.integrable_at_filter\n\nlemma integrable_add_of_disjoint {f g : \u03b1 \u2192 E}\n  (h : disjoint (support f) (support g)) (hf : strongly_measurable f) (hg : strongly_measurable g) :\n  integrable (f + g) \u03bc \u2194 integrable f \u03bc \u2227 integrable g \u03bc :=\nbegin\n  refine \u27e8\u03bb hfg, \u27e8_, _\u27e9, \u03bb h, h.1.add h.2\u27e9,\n  { rw \u2190 indicator_add_eq_left h, exact hfg.indicator hf.measurable_set_support },\n  { rw \u2190 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`\u03bc.restrict s`. -/\nlemma continuous_on.ae_measurable [topological_space \u03b1] [opens_measurable_space \u03b1]\n  [measurable_space \u03b2] [topological_space \u03b2] [borel_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1} (hf : continuous_on f s) (hs : measurable_set s) :\n  ae_measurable f (\u03bc.restrict s) :=\nbegin\n  nontriviality \u03b1, inhabit \u03b1,\n  have : piecewise s f (\u03bb _, f default) =\u1d50[\u03bc.restrict s] f := piecewise_ae_eq_restrict hs,\n  refine \u27e8piecewise s f (\u03bb _, f default), _, this.symm\u27e9,\n  apply measurable_of_is_open,\n  assume t ht,\n  obtain \u27e8u, u_open, hu\u27e9 : \u2203 (u : set \u03b1), is_open u \u2227 f \u207b\u00b9' t \u2229 s = u \u2229 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 `\u03bc.restrict s`. -/\nlemma continuous_on.ae_strongly_measurable_of_is_separable\n  [topological_space \u03b1] [pseudo_metrizable_space \u03b1] [opens_measurable_space \u03b1]\n  [topological_space \u03b2] [pseudo_metrizable_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1} (hf : continuous_on f s) (hs : measurable_set s)\n  (h's : topological_space.is_separable s) :\n  ae_strongly_measurable f (\u03bc.restrict s) :=\nbegin\n  letI := pseudo_metrizable_space_pseudo_metric \u03b1,\n  borelize \u03b2,\n  rw ae_strongly_measurable_iff_ae_measurable_separable,\n  refine \u27e8hf.ae_measurable hs, f '' s, hf.is_separable_image h's, _\u27e9,\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 `\u03bc.restrict s` when either the source space or the target space is second-countable. -/\nlemma continuous_on.ae_strongly_measurable\n  [topological_space \u03b1] [topological_space \u03b2] [h : second_countable_topology_either \u03b1 \u03b2]\n  [opens_measurable_space \u03b1] [pseudo_metrizable_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1} (hf : continuous_on f s) (hs : measurable_set s) :\n  ae_strongly_measurable f (\u03bc.restrict s) :=\nbegin\n  borelize \u03b2,\n  refine ae_strongly_measurable_iff_ae_measurable_separable.2 \u27e8hf.ae_measurable hs, f '' s, _,\n    mem_of_superset (self_mem_ae_restrict hs) (subset_preimage_image _ _)\u27e9,\n  casesI h.out,\n  { let f' : s \u2192 \u03b2 := 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 `\u03bc.restrict s`. -/\nlemma continuous_on.ae_strongly_measurable_of_is_compact\n  [topological_space \u03b1] [opens_measurable_space \u03b1] [topological_space \u03b2] [pseudo_metrizable_space \u03b2]\n  {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1}\n  (hf : continuous_on f s) (hs : is_compact s) (h's : measurable_set s) :\n  ae_strongly_measurable f (\u03bc.restrict s) :=\nbegin\n  letI := pseudo_metrizable_space_pseudo_metric \u03b2,\n  borelize \u03b2,\n  rw ae_strongly_measurable_iff_ae_measurable_separable,\n  refine \u27e8hf.ae_measurable h's, f '' s, _, _\u27e9,\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 \u03b1] [pseudo_metrizable_space \u03b1]\n  [opens_measurable_space \u03b1] {\u03bc : measure \u03b1} [is_locally_finite_measure \u03bc]\n  {a : \u03b1} {t : set \u03b1} {f : \u03b1 \u2192 E} (hft : continuous_on f t) (ht : measurable_set t)\n  (h't : topological_space.is_separable t) (ha : a \u2208 t) :\n  integrable_at_filter f (\ud835\udcdd[t] a) \u03bc :=\nbegin\n  haveI : (\ud835\udcdd[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _,\n  exact (hft a ha).integrable_at_filter \u27e8_, self_mem_nhds_within,\n    hft.ae_strongly_measurable_of_is_separable ht h't\u27e9 (\u03bc.finite_at_nhds_within _ _),\nend\n\nlemma continuous_on.integrable_at_nhds_within\n  [topological_space \u03b1] [second_countable_topology_either \u03b1 E]\n  [opens_measurable_space \u03b1] {\u03bc : measure \u03b1} [is_locally_finite_measure \u03bc]\n  {a : \u03b1} {t : set \u03b1} {f : \u03b1 \u2192 E} (hft : continuous_on f t) (ht : measurable_set t) (ha : a \u2208 t) :\n  integrable_at_filter f (\ud835\udcdd[t] a) \u03bc :=\nbegin\n  haveI : (\ud835\udcdd[t] a).is_measurably_generated := ht.nhds_within_is_measurably_generated _,\n  exact (hft a ha).integrable_at_filter \u27e8_, self_mem_nhds_within, hft.ae_strongly_measurable ht\u27e9\n    (\u03bc.finite_at_nhds_within _ _),\nend\n\nlemma continuous.integrable_at_nhds\n  [topological_space \u03b1] [second_countable_topology_either \u03b1 E]\n  [opens_measurable_space \u03b1] {\u03bc : measure \u03b1} [is_locally_finite_measure \u03bc]\n  {f : \u03b1 \u2192 E} (hf : continuous f) (a : \u03b1) :\n  integrable_at_filter f (\ud835\udcdd a) \u03bc :=\nbegin\n  rw \u2190 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`\ud835\udcdd x` for all `x \u2208 s` if either the source space or the target space is second-countable. -/\nlemma continuous_on.strongly_measurable_at_filter [topological_space \u03b1]\n  [opens_measurable_space \u03b1] [topological_space \u03b2] [pseudo_metrizable_space \u03b2]\n  [second_countable_topology_either \u03b1 \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1}\n  (hs : is_open s) (hf : continuous_on f s) :\n  \u2200 x \u2208 s, strongly_measurable_at_filter f (\ud835\udcdd x) \u03bc :=\n\u03bb x hx, \u27e8s, is_open.mem_nhds hs hx, hf.ae_strongly_measurable hs.measurable_set\u27e9\n\nlemma continuous_at.strongly_measurable_at_filter\n  [topological_space \u03b1] [opens_measurable_space \u03b1] [second_countable_topology_either \u03b1 E]\n  {f : \u03b1 \u2192 E} {s : set \u03b1} {\u03bc : measure \u03b1} (hs : is_open s) (hf : \u2200 x \u2208 s, continuous_at f x) :\n  \u2200 x \u2208 s, strongly_measurable_at_filter f (\ud835\udcdd x) \u03bc :=\ncontinuous_on.strongly_measurable_at_filter hs $ continuous_at.continuous_on hf\n\nlemma continuous.strongly_measurable_at_filter [topological_space \u03b1] [opens_measurable_space \u03b1]\n  [topological_space \u03b2] [pseudo_metrizable_space \u03b2] [second_countable_topology_either \u03b1 \u03b2]\n  {f : \u03b1 \u2192 \u03b2} (hf : continuous f) (\u03bc : measure \u03b1) (l : filter \u03b1) :\n  strongly_measurable_at_filter f l \u03bc :=\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  `\ud835\udcdd[s] x` for all `x`. -/\nlemma continuous_on.strongly_measurable_at_filter_nhds_within {\u03b1 \u03b2 : Type*} [measurable_space \u03b1]\n  [topological_space \u03b1] [opens_measurable_space \u03b1] [topological_space \u03b2] [pseudo_metrizable_space \u03b2]\n  [second_countable_topology_either \u03b1 \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {\u03bc : measure \u03b1}\n  (hf : continuous_on f s) (hs : measurable_set s) (x : \u03b1) :\n  strongly_measurable_at_filter f (\ud835\udcdd[s] x) \u03bc :=\n\u27e8s, self_mem_nhds_within, hf.ae_strongly_measurable hs\u27e9\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 : \u2124\nconstant f : \u2124 \u2192 \u2124\nconstant g : \u2124 \u2192 \u2124 \u2192 \u2124\n\n#check \u03bb x : \u2124, g (f (g a x)) (g x _)\n-- \u03bb (x : \u2124), g (f (g a x)) (g x ?M_1) : \u2124 \u2192 \u2124\n#check \u03bbx, g (f (g a x)) (g x b)\n-- \u03bb x <=> \u03bbx\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\u2082: trool \u2192 bool\n| trool.true := tt\n| trool.false := ff\n| _ := ff\n\n-- def prime (p : \u2115) := 2 \u2264 p \u2227 \u2200 m \u2223 p, m = 1 \u2228 m = p\ndef or (a b : trool) := (a = trool.true) \u2228 (b = trool.true)\n\n-- or a a = (a = trool.true) \u2228 (a = trool.true) = X \u2228 X = X = (a = trool.true)\n-- (a = trool.true) => \n-- case 1: trool_to_bool trool.true  \u2194 (trool.true  = trool.true)\n-- case 2: trool_to_bool trool.false \u2194 (trool.false = trool.true)\n-- case 3: trool_to_bool trool.maybe \u2194 (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]: \u21a5ff ==> false\n    -- [iff_self]: false \u2194 false ==> true\n    rw bool.coe_sort_ff,\n    -- apply iff.symm,\n    -- change false \u2194 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 : \u2124\n-- lemma a_less_b : a < b := sorry \n-- <=>\naxiom a_less_b : a < b\naxiom symm_lt (x y : \u2124): x < y \u2192 y > x\naxiom not_eq_imp_lt (x y : \u2124): x \u2260 y \u2192 x < y \u2228 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 \u2192 P \u2227 \u00ac Q \u2192 false := \nbegin\n  intro pq,\n  rw \u2190 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 \u2227 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 \u2192 p \u2227 \u00ac q \u2192 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-- \u03bb (p : Prop), (eq_self_iff_true p).mpr true.intro\n\n-- this can be proved by reflexivity\nlemma example_forward_proof\u2082 (p : Prop) : p = p := eq.refl _\n\n#print example_forward_proof\u2082 -- \u03bb (p : Prop), eq.refl p\n\nlemma example_forward_proof\u2083 (p q : Prop) : p = q \u2192 (p \u2227 q) = p :=\nbegin\n  assume h1 : p = q,\n  have h2 : p \u2227 p \u2194 p := and_self p,\n  have h3 : (p \u2227 p) = p := h2.to_eq, -- iff.to_eq\n  have h4 : (p \u2227 p) = p \u2192 (p \u2227 q) = p := \n    assume (h: (p \u2227 p) = p), eq.subst h1 h,\n  show (p \u2227 q) = p, from h4 h3, -- \u2248 exact h4 h3, but more readable\nend\n\nexample (expr : Prop): (expr \u2228 expr) \u2192 true :=\nbegin\n  -- simp,\n-- 0. [simplify.rewrite] [or_self]: expr \u2228 expr ==> expr\n-- 0. [simplify.rewrite] [forall_true_iff]: expr \u2192 true ==> true\n  rw or_self,\n  rw forall_true_iff,\n  exact true.intro,\nend\n\n-- id <=> \u2200 A : Type, A \u2192 A\nexample : \u2200 A : Type, A \u2192 A := \u03bb _, id\nexample : \u2200 A : Type, A \u2192 A := \u03bb A, @id A\nexample : \u2200 A : Type, A \u2192 A := assume A, @id A\nexample (A : Type) : A \u2192 A := id -- explicit (argument)\nexample {A : Type} : A \u2192 A := id -- implicit {argument}\nexample \u2983A : Type\u2984 : A \u2192 A := id -- i don't know, but possible\n\nexample (x y : \u2124): \u00ac (x = y) \u2227 \u00ac (x > y) \u2192 (y > x) :=\nbegin\n  assume f : \u00acx = y \u2227 \u00acx > y,\n  apply symm_lt,\n  -- exact a_less_b, -- not works\n  have f\u2082 : _ \u2227 _ := f, -- example pattern matching\n  clear f\u2082,\n  have h\u2082 : \u00ac (x = y) \u2192 x \u2260 y, by {\n    tactic.trace_state,\n  -- simp,\n  -- [ne.def]: x \u2260 y ==> \u00acx = y\n  -- [classical.not_not]: \u00ac\u00acx = y ==> x = y\n  -- [imp_self]: \u00acx = y \u2192 \u00acx = y ==> true\n    show_term { rw [ne.def], },\n    exact id, -- id <=> \u2200 A : Type, A \u2192 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 \u2260 y := h\u2082 f1,\n  have h\u2083 : x < y \u2228 x > y := not_eq_imp_lt _ _ not_eq_xy,\n  cases h\u2083 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\u2081 := p_q_not second f2,\n    -- have h\u2085 := 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 \u2192 b, we have b. (Goal unchanged)\nFrom b and b \u2192 c, we have c, as desired.\n* A forward proof only manipulates theorems, not goals.\n\nBackward proof:\nTo prove c, by b \u2192 c it suffices to prove b. (Goal changed from \u22a2 c to \u22a2 b)\nTo prove b, by a \u2192 b it suffices to prove a. (Goal changed from \u22a2 b to \u22a2 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  \u2200 a b : Prop, a \u2192 b \u2192 (a \u2192 b) :=\nbegin -- \u22a2 \u2200 (a b : Prop), a \u2192 b \u2192 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  \u2200 a b : Prop, a \u2192 b \u2192 a :=\nbegin -- \u22a2 \u2200 (a b : Prop), a \u2192 b \u2192 a\n  introv, -- \u22a2 a \u2192 b \u2192 a (Goal changed)\n  intros ha hb, -- \u22a2 a (Goal changed)\n  apply ha, -- goals accomplished (Goal changed)\nend\n\nlemma and_swap :\n  \u2200 a b : Prop, a \u2227 b \u2192 b \u2227 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 : \u2115) := n + n\n\nlemma nat_exists_double_iden :\n  \u2203 n : \u2115, double n = n :=\nbegin\n  apply exists.intro 0, -- \u2194 use 0\n  refl,\nend\n\nlemma double_prop : \u2200 n : \u2115, n \u2260 1 \u2192 double n \u2260 n + 1 :=\nbegin\n  type_check double.equations._eqn_1, -- \u2200 (n : \u2115), double n = n + n\n  intros,\n  apply not.intro,\n  induction n with x hx,\n  simp [double],\n  have a2 : x \u2260 0, from sorry,\n  dsimp only [double],\n  simp,\n  -- simp at hx \u22a2, -- example how to simplify goal and hypothesis simultaniously\n  simp only [a],\n  -- show_term { trivial, }, -- \u03bb (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 : \u2115) :\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 \u2200 (m n : \u2115), 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 \u2227 b \u2192 b \u2227 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  \u2200 a b : Prop, a \u2192 b \u2192 a :=\nassume a b : Prop,\nassume (ha : a)(hb : b),\nshow a, from ha\n\nlemma snd_of_two_props'' :\n  \u2200 a b : Prop, a \u2192 b \u2192 b :=\nassume _ b : Prop,\nassume (_)(hb : b),\nshow _, from hb -- placeholder _ is important thing\n\nlemma prop_comp (a b c : Prop) (hab : a \u2192 b) (hbc : b \u2192 c) :\n  a \u2192 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-- \u03bb (a b : Prop) (ha : a) (hb : b), show a, from ha\n#print snd_of_two_props''\n-- \u03bb (_x b : Prop) (_x : _x) (hb : b), show b, from hb\n#print prop_comp\n-- \u03bb (a b c : Prop) (hab : a \u2192 b) (hbc : b \u2192 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 {\u03b1 : Type} (t : \u03b1) (p : \u03b1 \u2192 Prop) :\n--   (\u2200x, x = t \u2192 p x) \u2194 p t :=\n-- iff.intro\n--   (assume hall : \u2200x, x = t \u2192 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 \u2192 2 = 3 \u2192 1 = 3 := \n  \u03bb (h\u2081 : 1 = 2) (h\u2082 : 2 = 3), @eq.subst nat (\u03bb n, 1 = n) 2 3 h\u2082 h\u2081\n\nexample : 1 = 2 \u2192 2 = 3 \u2192 1 = 3 := by {\n  intros h1 h2,\n  -- apply @eq.subst nat (\u03bb n, 1 = n) 2 3 h2 h1,\n  -- exact eq.subst h2 h1,\n  exact h2 \u25b8 h1,\n}\n\nlemma forall.one_point' {\u03b1 : Type} (t : \u03b1) (p : \u03b1 \u2192 Prop) :\n  (\u2200x, x = t \u2192 p x) \u2194 p t :=\niff.intro\n  (assume hall: \u2200 x, x = t \u2192 p x, \n   have h\u2081 : t = t \u2192 p t, from hall t,\n   show p t, from h\u2081 (rfl : t = t))\n  (\u03bb h\u2081 x (h\u2082 : x = t), \n  show p x, from (h\u2082.symm : t = x) \u25b8 (h\u2081 : p t)) -- \u03bb \u2194 assume\n  --by {\n    -- refine @eq.subst \u03b1 _ t x h\u2082.symm h\u2081,\n  -- exact h\u2082.symm \u25b8 h\u2081 }\n\nlemma beast_666 (beast : \u2115) :\n  (\u2200n, n = 666 \u2192 beast \u2265 n) \u2194 beast \u2265 666 :=\nforall.one_point' 666 (\u03bb n, nat.le n beast) -- x \u2265 y \u2194 ge x y \u2194 le y x\n -- nat.ge don't exists because developers of lean lib want to minimize number of equivalent functions\n-- \u03bb (beast : \u2115), forall.one_point' 666 (\u03bb (n : \u2115), beast \u2265 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\u2082 (m n : nat) :\n  2 * m + n = m + n + m :=\nhave h\u2081 : 2 * m + n = (m + m) + n :=\n  by rewrite two_mul,\nhave h\u2082 : (m + m) + n = m + n + m :=\n  by show_term { cc },\nshow _, from\n  eq.trans h\u2081 h\u2082\n\nend lemma_statements\n\nnamespace proofs_by_induction\n\nconstant add : \u2115 \u2192 \u2115 \u2192 \u2115\n\naxiom add_zero (m : \u2115): add m 0 = m\naxiom add_succ (m n : \u2115): add n (nat.succ n) = nat.succ (add m n)\n\n-- lemma add_zero (n : \u2115)\n\nend proofs_by_induction\n\nnamespace induction_by_pattern_matching\n\ndef reverse {\u03b1 : Type} : list \u03b1 \u2192 list \u03b1\n| []       := []\n| (x :: xs) := reverse xs ++ [x]\n\n-- The induction step is:\n-- ih : \u2200xs, reverse (reverse xs) = xs \u22a2 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 {\u03b1 : Type} :\n--   \u2200xs ys : list \u03b1, 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 {\u03b1 : Type} :\n  \u2200 xs ys : list \u03b1, 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 {\u03b1 : Type} :\n  \u2200 xs ys : list \u03b1, 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\u2082 {\u03b1 : Type} (xs ys : list \u03b1) :\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 {\u03b1 : Type} :\n  \u2200xs : list \u03b1, 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 \u2227 true ==> true\nend\n\nlemma reverse_reverse\u2082 {\u03b1 : Type} :\n  \u2200xs : list \u03b1, reverse (reverse xs) = xs\n| [] := rfl\n| (x :: xs) := by simp [reverse, reverse_append, reverse_reverse\u2082 xs]\n\n\n\nend induction_by_pattern_matching\nnamespace inductive_types\n\nnamespace hidden\ninductive nat : Type\n| zero : nat\n| succ : nat \u2192 nat\nend hidden\n-- <=>\nnamespace hidden2\nconstant nat : Type\nconstant nat.zero : nat\nconstant nat.succ : nat \u2192 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 : \u2115) :\n  nat.succ n \u2260 n :=\nbegin\n  induction n with n ih,\n  {\n    -- [nat.nat_zero_eq_zero]: 0 ==> 0\n    -- [ne.def]: 1 \u2260 0 ==> \u00ac1 = 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 \u2260 n_n.succ ==> \u00acn_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]: \u00acfalse ==> 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 \u2192\u2097[R] p`, `\u2200 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 \u2293 q = \u22a5`, `p \u2294 q = \u22a4`. 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] [complete_space \ud835\udd5c] (f : continuous_linear_map \ud835\udd5c E F) [finite_dimensional \ud835\udd5c \u21a5(range f)] : submodule.closed_complemented (ker f) := sorry\n\n/-- If `f : E \u2192L[R] F` and `g : E \u2192L[R] G` are two surjective linear maps and\ntheir kernels are complement of each other, then `x \u21a6 (f x, g x)` defines\na linear equivalence `E \u2243L[R] F \u00d7 G`. -/\ndef equiv_prod_of_surjective_of_is_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] [complete_space E] [complete_space (F \u00d7 G)] (f : continuous_linear_map \ud835\udd5c E F) (g : continuous_linear_map \ud835\udd5c E G) (hf : range f = \u22a4) (hg : range g = \u22a4) (hfg : is_compl (ker f) (ker g)) : continuous_linear_equiv \ud835\udd5c E (F \u00d7 G) :=\n  linear_equiv.to_continuous_linear_equiv_of_continuous\n    (linear_map.equiv_prod_of_surjective_of_is_compl (\u2191f) (\u2191g) hf hg hfg) sorry\n\n@[simp] theorem coe_equiv_prod_of_surjective_of_is_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] [complete_space E] [complete_space (F \u00d7 G)] {f : continuous_linear_map \ud835\udd5c E F} {g : continuous_linear_map \ud835\udd5c E G} (hf : range f = \u22a4) (hg : range g = \u22a4) (hfg : is_compl (ker f) (ker g)) : \u2191(equiv_prod_of_surjective_of_is_compl f g hf hg hfg) = \u2191(continuous_linear_map.prod f g) :=\n  rfl\n\n@[simp] theorem equiv_prod_of_surjective_of_is_compl_to_linear_equiv {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] [complete_space E] [complete_space (F \u00d7 G)] {f : continuous_linear_map \ud835\udd5c E F} {g : continuous_linear_map \ud835\udd5c E G} (hf : range f = \u22a4) (hg : range g = \u22a4) (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 (\u2191f) (\u2191g) hf hg hfg :=\n  rfl\n\n@[simp] theorem equiv_prod_of_surjective_of_is_compl_apply {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] [complete_space E] [complete_space (F \u00d7 G)] {f : continuous_linear_map \ud835\udd5c E F} {g : continuous_linear_map \ud835\udd5c E G} (hf : range f = \u22a4) (hg : range g = \u22a4) (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 \u00d7 q` is continuously\nisomorphic to `E`. -/\ndef prod_equiv_of_closed_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] (p : subspace \ud835\udd5c E) (q : subspace \ud835\udd5c E) (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) : continuous_linear_equiv \ud835\udd5c (\u21a5p \u00d7 \u21a5q) 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] (p : subspace \ud835\udd5c E) (q : subspace \ud835\udd5c E) (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) : continuous_linear_map \ud835\udd5c E \u21a5p :=\n  continuous_linear_map.comp (continuous_linear_map.fst \ud835\udd5c \u21a5p \u21a5q)\n    \u2191(continuous_linear_equiv.symm (prod_equiv_of_closed_compl p q h hp hq))\n\n@[simp] theorem coe_prod_equiv_of_closed_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E} {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) : \u21d1(prod_equiv_of_closed_compl p q h hp hq) = \u21d1(submodule.prod_equiv_of_is_compl p q h) :=\n  rfl\n\n@[simp] theorem coe_prod_equiv_of_closed_compl_symm {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E} {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) : \u21d1(continuous_linear_equiv.symm (prod_equiv_of_closed_compl p q h hp hq)) =\n  \u21d1(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E} {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) : \u2191(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' {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E} {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) : \u21d1(linear_proj_of_closed_compl p q h hp hq) = \u21d1(submodule.linear_proj_of_is_compl p q h) :=\n  rfl\n\ntheorem closed_complemented_of_closed_compl {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E} {q : subspace \ud835\udd5c E} (h : is_compl p q) (hp : is_closed \u2191p) (hq : is_closed \u2191q) : 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E} : submodule.closed_complemented p \u2194 is_closed \u2191p \u2227 \u2203 (q : subspace \ud835\udd5c E), \u2203 (hq : is_closed \u2191q), is_compl p q := sorry\n\ntheorem closed_complemented_of_quotient_finite_dimensional {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] [complete_space E] {p : subspace \ud835\udd5c E} [complete_space \ud835\udd5c] [finite_dimensional \ud835\udd5c (submodule.quotient p)] (hp : is_closed \u2191p) : 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 : \u2115}\n\nvariable R : \u21a5(finset.powerset_len k (finset.univ : finset V))\n\nvariable red_edges : (finset \u21a5G.edge_finset)\n\nvariable red_edges_by_R : \nfinset \u21a5(G.edge_finset \\ ((G.induced_subgraph R).edge_finset)) \u00d7\nfinset \u21a5((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 \u21a5(G.edge_finset \\ ((G.induced_subgraph R).edge_finset)) \u00d7\n  finset \u21a5((G.induced_subgraph R).edge_finset) ) \u2192\n  (finset \u21a5G.edge_finset) := \u03bb c, \n  \u2191(\u27e8finset.map (function.embedding.subtype _) c.fst \u222a\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\u27e9 : {s // s \u2286 G.edge_finset})\n\ninstance red_edges_by_R_has_coe : has_coe\n  ( finset \u21a5(G.edge_finset \\ ((G.induced_subgraph R).edge_finset)) \u00d7\n    finset \u21a5((G.induced_subgraph R).edge_finset))\n  (finset \u21a5G.edge_finset) \n:= \u27e8red_edges_by_R_coe G R\u27e9\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 \u2286 G.edge_finset} \u2192 finset \u21a5(G.edge_finset))\n    with subset_subtype.finset_subtype.coe,\n  intros c\u2081 c\u2082,\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\u2081,\n      have e_coe_in\u2081 := finset.mem_map_of_mem \n        (function.embedding.subtype _) e_in\u2081,\n      rw function.embedding.coe_subtype _ at e_coe_in\u2081,\n      have e_coe_in_union : \n        \u2191e \u2208 finset.map (function.embedding.subtype _) c\u2081.fst \u222a\n          finset.map (function.embedding.subtype _) c\u2081.snd,\n      { rw finset.mem_union,\n        left,\n        exact e_coe_in\u2081, },\n      rw h_union at e_coe_in_union,\n      have e_coe_in\u2082 : \n        \u2191e \u2208 finset.map (function.embedding.subtype _) c\u2082.fst,\n      { rw finset.mem_union at e_coe_in_union,\n        cases e_coe_in_union with e_coe_in\u2082 e_coe_in_false,\n        { exact e_coe_in\u2082, },\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\u2082,\n      exact e_coe_in\u2082.right, },\n    { intro e_in\u2082,\n      have e_coe_in\u2082 := finset.mem_map_of_mem \n        (function.embedding.subtype _) e_in\u2082,\n      rw function.embedding.coe_subtype _ at e_coe_in\u2082,\n      have e_coe_in_union : \n        \u2191e \u2208 finset.map (function.embedding.subtype _) c\u2082.fst \u222a\n          finset.map (function.embedding.subtype _) c\u2082.snd,\n      { rw finset.mem_union,\n        left,\n        exact e_coe_in\u2082, },\n      rw \u2190 h_union at e_coe_in_union,\n      have e_coe_in\u2081 : \n        \u2191e \u2208 finset.map (function.embedding.subtype _) c\u2081.fst,\n      { rw finset.mem_union at e_coe_in_union,\n        cases e_coe_in_union with e_coe_in\u2081 e_coe_in_false,\n        { exact e_coe_in\u2081, },\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\u2081,\n      exact e_coe_in\u2081.right, }, },\n  { rw finset.ext_iff,\n    intro e,\n    split,\n    { intro e_in\u2081,\n      have e_coe_in\u2081 := finset.mem_map_of_mem \n        (function.embedding.subtype _) e_in\u2081, \n      rw function.embedding.coe_subtype at e_coe_in\u2081,\n      have e_coe_in_union : \n        \u2191e \u2208 finset.map (function.embedding.subtype _) c\u2081.fst \u222a\n          finset.map (function.embedding.subtype _) c\u2081.snd,\n      { rw finset.mem_union,\n        right,\n        exact e_coe_in\u2081, },\n      rw h_union at e_coe_in_union,\n      have e_coe_in\u2082 : \n        \u2191e \u2208 finset.map (function.embedding.subtype _) c\u2082.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\u2082,\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\u2082, }, },\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\u2082,\n      exact e_coe_in\u2082.right, },\n    { intro e_in\u2082,\n      have e_coe_in\u2082 := finset.mem_map_of_mem \n        (function.embedding.subtype _) e_in\u2082, \n      rw function.embedding.coe_subtype at e_coe_in\u2082,\n      have e_coe_in_union : \n        \u2191e \u2208 finset.map (function.embedding.subtype _) c\u2082.fst \u222a\n          finset.map (function.embedding.subtype _) c\u2082.snd,\n      { rw finset.mem_union,\n        right,\n        exact e_coe_in\u2082, },\n      rw \u2190 h_union at e_coe_in_union,\n      have e_coe_in\u2081 : \n        \u2191e \u2208 finset.map (function.embedding.subtype _) c\u2081.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\u2081,\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\u2081, }, },\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\u2081,\n      exact e_coe_in\u2081.right, }, },\nend\n\ndef A : Prop := \n\u2200 (e\u2081 : \u21a5((G.induced_subgraph R).edge_finset)) \n  (e\u2082 : \u21a5((G.induced_subgraph R).edge_finset)),\n( set.inclusion (G.induced_subgraph R).edge_finset_subset e\u2081 \u2208 red_edges \u2227\n  set.inclusion (G.induced_subgraph R).edge_finset_subset e\u2082 \u2208 red_edges ) \u2228\n( set.inclusion (G.induced_subgraph R).edge_finset_subset e\u2081 \u2209 red_edges \u2227 \n  set.inclusion (G.induced_subgraph R).edge_finset_subset e\u2082 \u2209 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 \u21a5(G.edge_finset)) := \nfinset.univ\n\ndef two_colourings_sat_A_R : finset (finset \u21a5(G.edge_finset)) := \nfinset.filter (A G R) (finset_univ_two_colouring G)\n\ndef empty_univ_col_R : \nfinset (finset \u21a5(G.edge_finset \\ ((G.induced_subgraph R).edge_finset)) \u00d7\n finset \u21a5((G.induced_subgraph R).edge_finset)) := \nfinset.product finset.univ {\u2205, finset.univ}\n\ntheorem all_red_colourings_sat_A_R : \ntwo_colourings_sat_A_R (complete_graph V) R = \nfinset.map \n  \u27e8red_edges_by_R_coe (complete_graph V) R, red_edges_by_R_coe_inj _ _\u27e9\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 \u2286 (complete_graph V).edge_finset} \u2192 \n      finset \u21a5((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 \u2190 @finset.map_inj _ _ \n      (function.embedding.subtype (\u2208 (complete_graph V).edge_finset)) _ _,\n    rw subset_subtype.coe_type,\n    have h_union : \n      finset.map (function.embedding.subtype _) cRc \u222a\n      finset.map (function.embedding.subtype _) cR =\n      finset.map (function.embedding.subtype _) c,\n    { rw \u2190 h_cR,\n      rw \u2190 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        (\u2208 ((complete_graph V).induced_subgraph \u2191R).edge_finset) \n          (finset.map (function.embedding.subtype _) c),\n      have h_eq_c : \n        finset.filter\n          (\u2208 (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\u2081 e\u2081_in,\n        apply finset.ext,\n        intro e\u2082,\n        split,\n        { revert e\u2082,\n          exact cR.subset_univ, },\n        { intro e\u2082_in,\n          specialize hA e\u2081 e\u2082,\n          cases hA with h_red h_blue,\n          { rw \u2190 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\u2082_in_set : \u2191e\u2082 \u2208 (complete_graph V).edge_set,\n            { have e\u2082_in_finset := finset.mem_of_subset \n                ((complete_graph V).induced_subgraph R).edge_finset_subset\n                e\u2082.property,\n              unfold simple_graph.edge_finset at e\u2082_in_finset,\n              rw set.mem_to_finset at e\u2082_in_finset,\n              exact e\u2082_in_finset, },\n            use e\u2082_in_set,\n          exact h_red.right, },\n          { exfalso,\n            have e\u2081_not_in := h_blue.left,\n            rw \u2190 h_cR at e\u2081_in,\n            unfold simple_graph.induced_subgraph.edge_subtype_finset \n              at e\u2081_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\u2081_in,\n            cases e\u2081_in with _ e\u2081_in,\n            exact h_blue.left e\u2081_in, }, }, },\n        { exact h_union, }, }, },\n  { rintro \u27e8cRc, cR, hcR, h_union\u27e9,\n    cases hcR with cR_empty cR_univ,\n    { intros e\u2081 e\u2082,\n      right,\n      rw \u2190 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 \u27e8\u27e8a, a_in\u27e9, h_eq\u27e9,\n        rw subtype.mk_eq_mk at h_eq,\n        change a = e\u2081.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\u2081.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 \u27e8\u27e8a, a_in\u27e9, h_eq\u27e9,\n        rw subtype.mk_eq_mk at h_eq,\n        change a = e\u2082.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\u2082.property, }, },\n    { intros e\u2081 e\u2082,\n      left,\n      rw \u2190 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\u2081,\n        { rw set.mem_def,\n          rw \u2190 finset.mem_def,\n          rw finset.mem_union, \n          right,\n          change (function.embedding.subtype _) e\u2081 \u2208 finset.map\n              (function.embedding.subtype _) finset.univ,\n          rw finset.mem_map' (function.embedding.subtype _),\n          exact finset.mem_univ e\u2081, },\n        refl, },\n      { use e\u2082,\n        { rw set.mem_def,\n          rw \u2190 finset.mem_def,\n          rw finset.mem_union, \n          right,\n          change (function.embedding.subtype _) e\u2082 \u2208 finset.map \n              (function.embedding.subtype _) finset.univ,\n          rw finset.mem_map' (function.embedding.subtype _),\n          exact finset.mem_univ e\u2082, },\n        refl, }, }, },\nend\n\ntheorem card_red_colourings_sat_A_R (hk : k \u2265 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 (\u2191R : set V) with (\u2191(\u2191R : 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 \u2190 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) \u00d7\n  finset \u21a5G.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  (\u03bb R, finset.map \u27e8prod.mk R, prod.mk.inj_left R\u27e9 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) \u00d7\n  finset \u21a5G.edge_finset) :=\nfinset.filter (\u03bb Rc, A G Rc.fst Rc.snd) (finset_univ_prod_R_colouring G k)\n\nlemma function.uncurry.comp_prod_mk_eq_self \n  {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a : \u03b1) :\n(function.uncurry f) \u2218 (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 (\u03bb R, finset.map\n    \u27e8prod.mk R, prod.mk.inj_left R\u27e9\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 (\u03bb Rc : \n      \u21a5(finset.powerset_len k finset.univ) \u00d7 finset \u21a5(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 \u2265 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 \u27e8R\u2081, c\u27e9 Rc_in \u27e8R'\u2081, c'\u27e9 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 \u2190 Rc_in.right,\n  rw \u2190 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 \u21a5G.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 \u2265 2) : \nfinset_univ_colouring_sat_A (complete_graph V) k \u2282 \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 \u2190 finset.card_lt_iff_ne_univ,\n    calc (finset_univ_colouring_sat_A (complete_graph V) k).card \u2264\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 \u2265 2) :\n\u2203 c : finset \u21a5((complete_graph V).edge_finset),\n  \u00ac\u2203 R' : \u21a5(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 \u27e8c, c_in, c_not_in\u27e9,\n  use c,\n  convert_to \u00ac\u2203 R', \n    (R', c) \u2208 (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 : \u2115)\n  variables (h\u2081 : x = y) (h\u2082 : y = z)\n\n  include h\u2081 h\u2082\n  theorem foo : x = z :=\n  begin\n    rw [h\u2081, h\u2082]\n  end\n  omit h\u2081 h\u2082\n\n  theorem bar : x = z :=\n    eq.trans h\u2081 h\u2082\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 : \u2115 \u2192. \u2115} (hf : partrec f) : partrec\n  (unpaired\n    fun (a m : \u2115) =>\n      roption.map (fun (_x : \u2115) => _x + m)\n        (rfind fun (n : \u2115) => (fun (m : \u2115) => 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 \u2192 code \u2192 code\n| comp : code \u2192 code \u2192 code\n| prec : code \u2192 code \u2192 code\n| rfind' : code \u2192 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 : \u2115 \u2192 code :=\n  sorry\n\ntheorem const_inj {n\u2081 : \u2115} {n\u2082 : \u2115} : code.const n\u2081 = code.const n\u2082 \u2192 n\u2081 = n\u2082 := sorry\n\nprotected def id : code :=\n  pair left right\n\ndef curry (c : code) (n : \u2115) : code :=\n  comp c (pair (code.const n) code.id)\n\ndef encode_code : code \u2192 \u2115 :=\n  sorry\n\ndef of_nat_code : \u2115 \u2192 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) \u2227 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) \u2227 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) \u2227 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\u2082 pair := sorry\n\ntheorem comp_prim : primrec\u2082 comp := sorry\n\ntheorem prec_prim : primrec\u2082 prec := sorry\n\ntheorem rfind_prim : primrec rfind' := sorry\n\ntheorem rec_prim' {\u03b1 : Type u_1} {\u03c3 : Type u_2} [primcodable \u03b1] [primcodable \u03c3] {c : \u03b1 \u2192 code} (hc : primrec c) {z : \u03b1 \u2192 \u03c3} (hz : primrec z) {s : \u03b1 \u2192 \u03c3} (hs : primrec s) {l : \u03b1 \u2192 \u03c3} (hl : primrec l) {r : \u03b1 \u2192 \u03c3} (hr : primrec r) {pr : \u03b1 \u2192 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3 \u2192 \u03c3} (hpr : primrec\u2082 pr) {co : \u03b1 \u2192 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3 \u2192 \u03c3} (hco : primrec\u2082 co) {pc : \u03b1 \u2192 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3 \u2192 \u03c3} (hpc : primrec\u2082 pc) {rf : \u03b1 \u2192 code \u00d7 \u03c3 \u2192 \u03c3} (hrf : primrec\u2082 rf) : let PR : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3 := fun (a : \u03b1) (cf cg : code) (hf hg : \u03c3) => pr a (cf, cg, hf, hg);\nlet CO : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3 := fun (a : \u03b1) (cf cg : code) (hf hg : \u03c3) => co a (cf, cg, hf, hg);\nlet PC : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3 := fun (a : \u03b1) (cf cg : code) (hf hg : \u03c3) => pc a (cf, cg, hf, hg);\nlet RF : \u03b1 \u2192 code \u2192 \u03c3 \u2192 \u03c3 := fun (a : \u03b1) (cf : code) (hf : \u03c3) => rf a (cf, hf);\nlet F : \u03b1 \u2192 code \u2192 \u03c3 := fun (a : \u03b1) (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 : \u03b1) => F a (c a) := sorry\n\ntheorem rec_prim {\u03b1 : Type u_1} {\u03c3 : Type u_2} [primcodable \u03b1] [primcodable \u03c3] {c : \u03b1 \u2192 code} (hc : primrec c) {z : \u03b1 \u2192 \u03c3} (hz : primrec z) {s : \u03b1 \u2192 \u03c3} (hs : primrec s) {l : \u03b1 \u2192 \u03c3} (hl : primrec l) {r : \u03b1 \u2192 \u03c3} (hr : primrec r) {pr : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3} (hpr : primrec\n  fun (a : \u03b1 \u00d7 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3) =>\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 : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3} (hco : primrec\n  fun (a : \u03b1 \u00d7 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3) =>\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 : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3} (hpc : primrec\n  fun (a : \u03b1 \u00d7 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3) =>\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 : \u03b1 \u2192 code \u2192 \u03c3 \u2192 \u03c3} (hrf : primrec fun (a : \u03b1 \u00d7 code \u00d7 \u03c3) => rf (prod.fst a) (prod.fst (prod.snd a)) (prod.snd (prod.snd a))) : let F : \u03b1 \u2192 code \u2192 \u03c3 := fun (a : \u03b1) (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 : \u03b1) => F a (c a) := sorry\n\n/- TODO(Mario): less copy-paste from previous proof -/\n\ntheorem rec_computable {\u03b1 : Type u_1} {\u03c3 : Type u_2} [primcodable \u03b1] [primcodable \u03c3] {c : \u03b1 \u2192 code} (hc : computable c) {z : \u03b1 \u2192 \u03c3} (hz : computable z) {s : \u03b1 \u2192 \u03c3} (hs : computable s) {l : \u03b1 \u2192 \u03c3} (hl : computable l) {r : \u03b1 \u2192 \u03c3} (hr : computable r) {pr : \u03b1 \u2192 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3 \u2192 \u03c3} (hpr : computable\u2082 pr) {co : \u03b1 \u2192 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3 \u2192 \u03c3} (hco : computable\u2082 co) {pc : \u03b1 \u2192 code \u00d7 code \u00d7 \u03c3 \u00d7 \u03c3 \u2192 \u03c3} (hpc : computable\u2082 pc) {rf : \u03b1 \u2192 code \u00d7 \u03c3 \u2192 \u03c3} (hrf : computable\u2082 rf) : let PR : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3 := fun (a : \u03b1) (cf cg : code) (hf hg : \u03c3) => pr a (cf, cg, hf, hg);\nlet CO : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3 := fun (a : \u03b1) (cf cg : code) (hf hg : \u03c3) => co a (cf, cg, hf, hg);\nlet PC : \u03b1 \u2192 code \u2192 code \u2192 \u03c3 \u2192 \u03c3 \u2192 \u03c3 := fun (a : \u03b1) (cf cg : code) (hf hg : \u03c3) => pc a (cf, cg, hf, hg);\nlet RF : \u03b1 \u2192 code \u2192 \u03c3 \u2192 \u03c3 := fun (a : \u03b1) (cf : code) (hf : \u03c3) => rf a (cf, hf);\nlet F : \u03b1 \u2192 code \u2192 \u03c3 := fun (a : \u03b1) (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 : \u03b1) => F a (c a) := sorry\n\ndef eval : code \u2192 \u2115 \u2192. \u2115 :=\n  sorry\n\nprotected instance has_mem : has_mem (\u2115 \u2192. \u2115) code :=\n  has_mem.mk fun (f : \u2115 \u2192. \u2115) (c : code) => eval c = f\n\n@[simp] theorem eval_const (n : \u2115) (m : \u2115) : eval (code.const n) m = roption.some n := sorry\n\n@[simp] theorem eval_id (n : \u2115) : eval code.id n = roption.some n := sorry\n\n@[simp] theorem eval_curry (c : code) (n : \u2115) (x : \u2115) : eval (curry c n) x = eval c (mkpair n x) := sorry\n\ntheorem const_prim : primrec code.const := sorry\n\ntheorem curry_prim : primrec\u2082 curry :=\n  primrec\u2082.comp comp_prim primrec.fst\n    (primrec\u2082.comp pair_prim (primrec.comp const_prim primrec.snd) (primrec.const code.id))\n\ntheorem curry_inj {c\u2081 : code} {c\u2082 : code} {n\u2081 : \u2115} {n\u2082 : \u2115} (h : curry c\u2081 n\u2081 = curry c\u2082 n\u2082) : c\u2081 = c\u2082 \u2227 n\u2081 = n\u2082 := sorry\n\ntheorem smn : \u2203 (f : code \u2192 \u2115 \u2192 code), computable\u2082 f \u2227 \u2200 (c : code) (n x : \u2115), eval (f c n) x = eval c (mkpair n x) :=\n  Exists.intro curry { left := primrec\u2082.to_comp curry_prim, right := eval_curry }\n\ntheorem exists_code {f : \u2115 \u2192. \u2115} : partrec f \u2194 \u2203 (c : code), eval c = f := sorry\n\ndef evaln (k : \u2115) : code \u2192 \u2115 \u2192 Option \u2115 :=\n  sorry\n\ntheorem evaln_bound {k : \u2115} {c : code} {n : \u2115} {x : \u2115} : x \u2208 evaln k c n \u2192 n < k := sorry\n\ntheorem evaln_mono {k\u2081 : \u2115} {k\u2082 : \u2115} {c : code} {n : \u2115} {x : \u2115} : k\u2081 \u2264 k\u2082 \u2192 x \u2208 evaln k\u2081 c n \u2192 x \u2208 evaln k\u2082 c n := sorry\n\ntheorem evaln_sound {k : \u2115} {c : code} {n : \u2115} {x : \u2115} : x \u2208 evaln k c n \u2192 x \u2208 eval c n := sorry\n\ntheorem evaln_complete {c : code} {n : \u2115} {x : \u2115} : x \u2208 eval c n \u2194 \u2203 (k : \u2115), x \u2208 evaln k c n := sorry\n\ntheorem evaln_prim : primrec fun (a : (\u2115 \u00d7 code) \u00d7 \u2115) => evaln (prod.fst (prod.fst a)) (prod.snd (prod.fst a)) (prod.snd a) := sorry\n\ntheorem eval_eq_rfind_opt (c : code) (n : \u2115) : eval c n = rfind_opt fun (k : \u2115) => evaln k c n :=\n  roption.ext\n    fun (x : \u2115) => iff.trans evaln_complete (iff.symm (rfind_opt_mono fun (a m n_1 : \u2115) (hl : m \u2264 n_1) => evaln_mono hl))\n\ntheorem eval_part : partrec\u2082 eval := sorry\n\ntheorem fixed_point {f : code \u2192 code} (hf : computable f) : \u2203 (c : code), eval (f c) = eval c := sorry\n\ntheorem fixed_point\u2082 {f : code \u2192 \u2115 \u2192. \u2115} (hf : partrec\u2082 f) : \u2203 (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 \u2297[\u2124] additive K\u02e3\n\nvariables {K F}\n\ndef units.as (x : K\u02e3) : mul_base_change K F :=\n1 \u2297\u209c additive.of_mul x\n\nnamespace units\n\n@[simp]\nlemma as_mul (u v : K\u02e3) : ((u * v).as : mul_base_change K F) = u.as + v.as := \ntensor_product.tmul_add _ _ _\n\n@[simp]\nlemma as_one : ((1 : K\u02e3).as : mul_base_change K F) = 0 := \ntensor_product.tmul_zero _ _\n\n@[simp]\nlemma as_inv (u : K\u02e3) : (u\u207b\u00b9.as : mul_base_change K F) = - u.as := \ntensor_product.tmul_neg _ _\n\nlemma as_div (u v : K\u02e3) : ((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\u02e3 :=\n{ carrier := { u | u.as \u2208 T },\n  mul_mem' := \u03bb u v hu hv, begin\n    dsimp at hu hv \u22a2,\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 \u22a2,\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  \u2200 (u v : K\u02e3) (h : (u : K) + v = 1) (f g : dual F (mul_base_change K F))\n    (hf : f \u2208 H) (hg : g \u2208 H), f u.as * g v.as = f v.as * g u.as) \n(neg_one : \u2200 (f : dual F (mul_base_change K F)) (hf : f \u2208 H), f ((-1 : K\u02e3).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\u02e3).as \u2208 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\u02e3) (huv : (u : K) + v = 1) : \n  \u00ac 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 \u03b2 := basis.sum_extend c,\n  let f : dual F _ := \u03b2.coord (sum.inl 0),\n  let g : dual F _ := \u03b2.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 [\u2190 he0, \u2190 he1] at HH,\n  dsimp only [e,f,g,\u03b2] at HH,\n  simp only [\n      \u2190 basis.sum_extend_extends _ c 0, \n      \u2190 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) \u2260 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 (\u03b1 : Type u) {Lvl : Type v} [BoundedLattice Lvl] [GradedSetoid \u03b1 Lvl] (maxLvl : Lvl := \u22a4) \n  := Quotient (instSetoidGradedSetoidRepr \u03b1 maxLvl)\n\n\nnamespace GradedQuotient\n\n\n  variable {\u03b1 : Type u} {Lvl : Type v} [BoundedLattice Lvl] [inst : GradedSetoid \u03b1 Lvl] [\u2200 l l' : Lvl, Decidable (l \u2264 l')]\n\n  notation \" \u27e6 \" lvl \" | \" x \" \u27e7 \" => \u27e6GradedSetoid.reduceToLvl lvl x\u27e7\n\n  noncomputable\n  def repr (a : GradedQuotient \u03b1 maxLvl) : \u03b1 := (Quotient.repr a).1\n\n  @[simp high]\n  theorem repr_quotient (a : GradedQuotient \u03b1 maxLvl) [GradedSetoid.Reduce \u03b1 maxLvl]\n    : \u27e6maxLvl| a.repr\u27e7 = a\n    := sorry_proof\n\n  def ungraded (a : GradedQuotient \u03b1 maxLvl) := a.liftOn (\u03bb a => \u27e6a.1\u27e7) sorry_proof\n\n  @[simp high]\n  theorem repr_ungraded (a : GradedQuotient \u03b1 maxLvl) \n    : \u27e6a.repr\u27e7 = a.ungraded\n    := sorry_proof\n\n  noncomputable\n  def grepr (a : GradedQuotient \u03b1 maxLvl) : GradedSetoid.Repr \u03b1 maxLvl := Quotient.repr a\n\n  @[simp high]\n  theorem grepr_quotient (a : GradedQuotient \u03b1 maxLvl)\n    : \u27e6a.grepr\u27e7 = a\n    := sorry_proof\n\n  noncomputable\n  def lvl (a : GradedQuotient \u03b1 maxLvl) : Lvl := (Quotient.repr a).2\n\n  def reduce (lvl : Lvl) [GradedSetoid.Reduce \u03b1 (lvl \u2293 maxLvl)] (a : GradedQuotient \u03b1 maxLvl) : GradedQuotient \u03b1 maxLvl \n    := \u27e6a.grepr.reduce lvl\u27e7 rewrite_by simp\n\n  /-- Reduction on quotient does nothing, it only changes the internal representation -/\n  theorem reduce_identity (a : GradedQuotient \u03b1 maxLvl) (lvl : Lvl) [GradedSetoid.Reduce \u03b1 (lvl \u2293 maxLvl)]\n    : a.reduce lvl = a := sorry_proof\n\n  def normalize [inst : GradedSetoid.Reduce \u03b1 \u22a5] (a : GradedQuotient \u03b1 maxLvl) : GradedQuotient \u03b1 maxLvl :=\n    have h :  \u22a5 = (\u22a5 \u2293 maxLvl : Lvl) := sorry_proof\n    have : GradedSetoid.Reduce \u03b1 (\u22a5 \u2293 maxLvl) := h \u25b8 inst\n    a.reduce \u22a5 \n\n  def nrepr [inst : GradedSetoid.Reduce \u03b1 \u22a5] (a : GradedQuotient \u03b1 maxLvl) : \u03b1 := \n    a.liftOn (\u03bb a => a.normalize.1) sorry_proof\n\n  @[simp]\n  theorem nrepr_quotient_mk [inst : GradedSetoid.Reduce \u03b1 \u22a5] (a : GradedQuotient \u03b1 maxLvl)\n    : \u27e6a.nrepr\u27e7 = a.ungraded\n  := sorry_proof\n\n  @[simp]\n  theorem nrepr_graded_quotient_mk [GradedSetoid.Reduce \u03b1 \u22a5] [GradedSetoid.Reduce \u03b1 maxLvl] (a : GradedQuotient \u03b1 maxLvl)\n    : \u27e6maxLvl| a.nrepr\u27e7 = a\n  := sorry_proof\n\n  variable {\u03b2 : Type w} [GradedSetoid \u03b2 Lvl]\n\n  @[simp high]\n  theorem lift_graded_morphism   \n    {Lvl : Type u'} [BoundedLattice Lvl] {lvl : Lvl}\n    {\u03b1 : Type u} [GradedSetoid \u03b1 Lvl] [GradedSetoid.Reduce \u03b1 lvl]\n    {\u03b2 : Type v} [GradedSetoid \u03b2 Lvl] [GradedSetoid.Reduce \u03b2 lvl]\n    (f : \u03b1 \u2192 \u03b2) [GradedSetoid.Morphism f] \n    (x : \u03b1)\n    : \u27e6lvl| f x\u27e7 = Quotient.lift (\u03bb (a : GradedSetoid.Repr \u03b1 lvl) => \u27e6GradedSetoid.Repr.mk (f a.1) a.2 sorry_proof sorry_proof\u27e7) sorry_proof \u27e6lvl| x\u27e7\n    := sorry_proof\n\n  @[simp]\n  theorem lift_graded_morphism\u2082  \n    {Lvl : Type u'} {lvl : Lvl} [BoundedLattice Lvl] \n    {\u03b1 : Type u} [GradedSetoid \u03b1 Lvl] [GradedSetoid.Reduce \u03b1 lvl]\n    {\u03b2 : Type v} [GradedSetoid \u03b2 Lvl] [GradedSetoid.Reduce \u03b2 lvl]\n    {\u03b3 : Type v} [GradedSetoid \u03b3 Lvl] [GradedSetoid.Reduce \u03b3 lvl]\n    (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) [GradedSetoid.Morphism\u2082 f] \n    (x : \u03b1) (y : \u03b2)\n    : \u27e6lvl| f x y\u27e7 = Quotient.lift\u2082 (\u03bb (x : GradedSetoid.Repr \u03b1 lvl) (y : GradedSetoid.Repr \u03b2 lvl) => \u27e6GradedSetoid.Repr.mk (f x.1 y.1) x.2 sorry_proof x.4\u27e7) sorry_proof \u27e6lvl| x\u27e7 \u27e6lvl| y\u27e7\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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u2964 chain_complex C \u2115`\nfor any preadditive category `C`. For any simplicial object `X` in `C`,\nthis is the homological complex `... \u2192 X_2 \u2192 X_1 \u2192 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 \u27f6 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 : \u2115) : X _[n+1] \u27f6 X _[n] :=\n\u2211 (i : fin (n+2)), (-1 : \u2124)^(i : \u2115) \u2022 X.\u03b4 i\n\n/--\n## The chain complex relation `d \u226b d`\n-/\nlemma d_squared (n : \u2115) : obj_d X (n+1) \u226b obj_d X n = 0 :=\nbegin\n  /- we start by expanding d \u226b d as a double sum -/\n  dsimp,\n  rw comp_sum,\n  let d_l := \u03bb (j : fin (n+3)), (-1 : \u2124)^(j : \u2115) \u2022 X.\u03b4 j,\n  let d_r := \u03bb (i : fin (n+2)), (-1 : \u2124)^(i : \u2115) \u2022 X.\u03b4 i,\n  rw [show (\u03bb i , (\u2211 j : fin (n+3), d_l j) \u226b d_r i) =\n    (\u03bb i, \u2211 j : fin (n+3), (d_l j \u226b d_r i)), by { ext i, rw sum_comp, }],\n  rw \u2190 finset.sum_product',\n  /- then, we decompose the index set P into a subet S and its complement S\u1d9c -/\n  let P := fin (n+2) \u00d7 fin (n+3),\n  let S := finset.univ.filter (\u03bb (ij : P), (ij.2 : \u2115) \u2264 (ij.1 : \u2115)),\n  let term := \u03bb (ij : P), d_l ij.2 \u226b d_r ij.1,\n  erw [show \u2211 (ij : P), term ij =\n    (\u2211 ij in S, term ij) + (\u2211 ij in S\u1d9c, term ij), by rw finset.sum_add_sum_compl],\n  rw [\u2190 eq_neg_iff_add_eq_zero, \u2190 finset.sum_neg_distrib],\n  /- we are reduced to showing that two sums are equal, and this is obtained\n  by constructing a bijection \u03c6 : S -> S\u1d9c, which maps (i,j) to (j,i+1),\n  and by comparing the terms -/\n  let \u03c6 : \u03a0 (ij : P), ij \u2208 S \u2192 P := \u03bb 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 \u03c6,\n  { -- \u03c6(S) is contained in S\u1d9c\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 \u22a2,\n    linarith, },\n  { /- identification of corresponding terms in both sums -/\n    rintro \u27e8i, j\u27e9 hij,\n    simp only [term, d_l, d_r, \u03c6, comp_zsmul, zsmul_comp, \u2190 neg_smul, \u2190 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) := (\u03c6 (i,j) hij).1,\n    have ineq : jj \u2264 i, { rw \u2190 fin.coe_fin_le, simpa using hij, },\n    rw [category_theory.simplicial_object.\u03b4_comp_\u03b4 X ineq, fin.cast_succ_cast_lt, mul_comm] },\n  { -- \u03c6 : S \u2192 S\u1d9c is injective\n    rintro \u27e8i, j\u27e9 \u27e8i', j'\u27e9 hij hij' h,\n    rw [prod.mk.inj_iff],\n    refine \u27e8by simpa using congr_arg prod.snd h, _\u27e9,\n    have h1 := congr_arg fin.cast_succ (congr_arg prod.fst h),\n    simpa [fin.cast_succ_cast_lt] using h1 },\n  { -- \u03c6 : S \u2192 S\u1d9c is surjective\n    rintro \u27e8i', j'\u27e9 hij',\n    simp only [true_and, finset.mem_univ, finset.compl_filter, not_le,\n      finset.mem_filter] at hij',\n    refine \u27e8(j'.pred _, fin.cast_succ i'), _, _\u27e9,\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 \u2115 := chain_complex.of (\u03bb 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 \u27f6 Y) : obj X \u27f6 obj Y :=\nchain_complex.of_hom _ _ _ _ _ _\n  (\u03bb n, f.app (op [n]))\n  (\u03bb n,\n    begin\n      dsimp,\n      rw [comp_sum, sum_comp],\n      apply finset.sum_congr rfl (\u03bb 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 \u2964 chain_complex C \u2115 :=\n{ obj := alternating_face_map_complex.obj,\n  map := \u03bb 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 \u2964 D) [F.additive] :\n  alternating_face_map_complex C \u22d9 F.map_homological_complex _ =\n  (simplicial_object.whiskering C D).obj F \u22d9 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 \u27f6 (alternating_face_map_complex A).obj X :=\nchain_complex.of_hom _ _ _ _ _ _\n  (\u03bb n, (normalized_Moore_complex.obj_X X n).arrow)\n  (\u03bb 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 := \u03bb (j : fin (n+2)), (normalized_Moore_complex.obj_X X (n+1)).arrow \u226b\n        ((-1 : \u2124)^(j : \u2115) \u2022 X.\u03b4 j),\n      have def_t : (\u2200 j : fin (n+2), t j = (normalized_Moore_complex.obj_X X (n+1)).arrow \u226b\n        ((-1 : \u2124)^(j : \u2115) \u2022 X.\u03b4 j)) := by { intro j, refl, },\n      rw [fin.sum_univ_succ t],\n      have null : \u2200 j : fin (n+1), t j.succ = 0,\n      { intro j,\n        rw [def_t, comp_zsmul, \u2190 zsmul_zero ((-1 : \u2124)^(j.succ : \u2115))],\n        apply congr_arg,\n        rw normalized_Moore_complex.obj_X,\n        rw \u2190 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.\u03b4 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.\u03b4 0 -/\n      let eq := def_t 0,\n      rw [show (-1 : \u2124)^((0 : fin (n+2)) : \u2115) = 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) \u27f6 (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) \u27f6 X` is the inclusion morphism.\n\nWe provide\n* `def pullback [has_pullbacks C] (f : X \u27f6 Y) : subobject Y \u2964 subobject X`\n* `def map (f : X \u27f6 Y) [mono f] : subobject X \u2964 subobject Y`\n* `def \u00abexists\u00bb [has_images C] (f : X \u27f6 Y) : subobject X \u2964 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 \u2264 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\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable theory\nnamespace category_theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {X Y Z : C}\nvariables {D : Type u\u2082} [category.{v\u2082} 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 \u27f6 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 \u2192 Prop)\n  (h : \u2200 \u2983A : C\u2984 (f : A \u27f6 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\u2082 {X : C} (p : subobject X \u2192 subobject X \u2192 Prop)\n  (h : \u2200 \u2983A B : C\u2984 (f : A \u27f6 X) (g : B \u27f6 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\u2082',\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 {\u03b1 : Sort*} {X : C} (F : \u03a0 \u2983A : C\u2984 (f : A \u27f6 X) [mono f], \u03b1)\n  (h : \u2200 \u2983A B : C\u2984 (f : A \u27f6 X) (g : B \u27f6 X) [mono f] [mono g] (i : A \u2245 B),\n    i.hom \u226b g = f \u2192 by exactI F f = F g) : subobject X \u2192 \u03b1 :=\n\u03bb P, quotient.lift_on' P (\u03bb m, by exactI F m.arrow) $ \u03bb m n \u27e8i\u27e9,\n  h m.arrow n.arrow ((mono_over.forget X \u22d9 over.forget X).map_iso i) (over.w i.hom)\n\n@[simp]\nprotected lemma lift_mk {\u03b1 : Sort*} {X : C} (F : \u03a0 \u2983A : C\u2984 (f : A \u27f6 X) [mono f], \u03b1) {h A}\n  (f : A \u27f6 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 \u224c 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 \u2964 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) \u2245 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 \u2964 C :=\nrepresentative \u22d9 mono_over.forget _ \u22d9 over.forget _\n\ninstance : has_coe (subobject X) C :=\n{ coe := \u03bb 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 \u27f6 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 \u27f6 Y) [mono f] : (subobject.mk f : C) \u2245 X :=\n(mono_over.forget _ \u22d9 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) \u27f6 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 (\u03bb X : subobject A, (X : C)) h) \u226b 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 \u27f6 Z) :\n  underlying.map f \u226b arrow Z = arrow Y :=\nover.w (representative.map f)\n\n@[simp, reassoc, elementwise]\nlemma underlying_iso_arrow {X Y : C} (f : X \u27f6 Y) [mono f] :\n  (underlying_iso f).inv \u226b (subobject.mk f).arrow = f :=\nover.w _\n\n@[simp, reassoc]\nlemma underlying_iso_hom_comp_eq_mk {X Y : C} (f : X \u27f6 Y) [mono f] :\n  (underlying_iso f).hom \u226b 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 \u27f6 P} (h : f \u226b P.arrow = g \u226b P.arrow) : f = g :=\n(cancel_mono P.arrow).mp h\n\nlemma mk_le_mk_of_comm {B A\u2081 A\u2082 : C} {f\u2081 : A\u2081 \u27f6 B} {f\u2082 : A\u2082 \u27f6 B} [mono f\u2081] [mono f\u2082] (g : A\u2081 \u27f6 A\u2082)\n  (w : g \u226b f\u2082 = f\u2081) : mk f\u2081 \u2264 mk f\u2082 :=\n\u27e8mono_over.hom_mk _ w\u27e9\n\n@[simp] lemma mk_arrow (P : subobject X) : mk P.arrow = P :=\nquotient.induction_on' P $ \u03bb Q,\nbegin\n  obtain \u27e8e\u27e9 := @quotient.mk_out' _ (is_isomorphic_setoid _) Q,\n  refine quotient.sound' \u27e8mono_over.iso_mk _ _ \u226a\u226b e\u27e9;\n  tidy\nend\n\nlemma le_of_comm {B : C} {X Y : subobject B} (f : (X : C) \u27f6 (Y : C)) (w : f \u226b Y.arrow = X.arrow) :\n  X \u2264 Y :=\nby convert mk_le_mk_of_comm _ w; simp\n\nlemma le_mk_of_comm {B A : C} {X : subobject B} {f : A \u27f6 B} [mono f] (g : (X : C) \u27f6 A)\n  (w : g \u226b f = X.arrow) : X \u2264 mk f :=\nle_of_comm (g \u226b (underlying_iso f).inv) $ by simp [w]\n\nlemma mk_le_of_comm {B A : C} {X : subobject B} {f : A \u27f6 B} [mono f] (g : A \u27f6 (X : C))\n  (w : g \u226b X.arrow = f) : mk f \u2264 X :=\nle_of_comm ((underlying_iso f).hom \u226b 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) \u2245 (Y : C))\n  (w : f.hom \u226b 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 \u27f6 B) [mono f] (i : (X : C) \u2245 A)\n  (w : i.hom \u226b 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 \u27f6 B) [mono f] (i : A \u2245 (X : C))\n  (w : i.hom \u226b 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\u2081 A\u2082 : C} (f : A\u2081 \u27f6 B) (g : A\u2082 \u27f6 B) [mono f] [mono g]\n  (i : A\u2081 \u2245 A\u2082) (w : i.hom \u226b 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 \u2264 Y) : (X : C) \u27f6 (Y : C) :=\nunderlying.map $ h.hom\n\n@[simp, reassoc] lemma of_le_arrow {B : C} {X Y : subobject B} (h : X \u2264 Y) :\n  of_le X Y h \u226b Y.arrow = X.arrow :=\nunderlying_arrow _\n\ninstance {B : C} (X Y : subobject B) (h : X \u2264 Y) : mono (of_le X Y h) :=\nbegin\n  fsplit,\n  intros Z f g w,\n  replace w := w =\u226b Y.arrow,\n  ext,\n  simpa using w,\nend\n\nlemma of_le_mk_le_mk_of_comm\n  {B A\u2081 A\u2082 : C} {f\u2081 : A\u2081 \u27f6 B} {f\u2082 : A\u2082 \u27f6 B} [mono f\u2081] [mono f\u2082] (g : A\u2081 \u27f6 A\u2082) (w : g \u226b f\u2082 = f\u2081) :\n  of_le _ _ (mk_le_mk_of_comm g w) = (underlying_iso _).hom \u226b g \u226b (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 \u27f6 B) [mono f] (h : X \u2264 mk f) : (X : C) \u27f6 A :=\nof_le X (mk f) h \u226b (underlying_iso f).hom\n\n@[simp] lemma of_le_mk_comp {B A : C} {X : subobject B} {f : A \u27f6 B} [mono f] (h : X \u2264 mk f) :\n  of_le_mk X f h \u226b 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 \u27f6 B) [mono f] (X : subobject B) (h : mk f \u2264 X) : A \u27f6 (X : C) :=\n(underlying_iso f).inv \u226b of_le (mk f) X h\n\n@[simp] lemma of_mk_le_arrow {B A : C} {f : A \u27f6 B} [mono f] {X : subobject B} (h : mk f \u2264 X) :\n  of_mk_le f X h \u226b 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\u2081 A\u2082 : C} (f : A\u2081 \u27f6 B) (g : A\u2082 \u27f6 B) [mono f] [mono g] (h : mk f \u2264 mk g) :\n  A\u2081 \u27f6 A\u2082 :=\n(underlying_iso f).inv \u226b of_le (mk f) (mk g) h \u226b (underlying_iso g).hom\n\n@[simp] lemma of_mk_le_mk_comp {B A\u2081 A\u2082 : C} {f : A\u2081 \u27f6 B} {g : A\u2082 \u27f6 B} [mono f] [mono g]\n  (h : mk f \u2264 mk g) : of_mk_le_mk f g h \u226b 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\u2081 : X \u2264 Y) (h\u2082 : Y \u2264 Z) :\n  of_le X Y h\u2081 \u226b of_le Y Z h\u2082 = of_le X Z (h\u2081.trans h\u2082) :=\nby simp [of_le, \u2190functor.map_comp underlying]\n\n@[simp, reassoc] lemma of_le_comp_of_le_mk {B A : C} (X Y : subobject B) (f : A \u27f6 B) [mono f]\n  (h\u2081 : X \u2264 Y) (h\u2082 : Y \u2264 mk f) : of_le X Y h\u2081 \u226b of_le_mk Y f h\u2082 = of_le_mk X f (h\u2081.trans h\u2082) :=\nby simp [of_mk_le, of_le_mk, of_le, \u2190functor.map_comp_assoc underlying]\n\n@[simp, reassoc] lemma of_le_mk_comp_of_mk_le {B A : C} (X : subobject B) (f : A \u27f6 B) [mono f]\n  (Y : subobject B) (h\u2081 : X \u2264 mk f) (h\u2082 : mk f \u2264 Y) :\n  of_le_mk X f h\u2081 \u226b of_mk_le f Y h\u2082 = of_le X Y (h\u2081.trans h\u2082) :=\nby simp [of_mk_le, of_le_mk, of_le, \u2190functor.map_comp underlying]\n\n@[simp, reassoc] lemma of_le_mk_comp_of_mk_le_mk {B A\u2081 A\u2082 : C} (X : subobject B) (f : A\u2081 \u27f6 B)\n  [mono f] (g : A\u2082 \u27f6 B) [mono g] (h\u2081 : X \u2264 mk f) (h\u2082 : mk f \u2264 mk g) :\n  of_le_mk X f h\u2081 \u226b of_mk_le_mk f g h\u2082 = of_le_mk X g (h\u2081.trans h\u2082) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, \u2190functor.map_comp_assoc underlying]\n\n@[simp, reassoc] lemma of_mk_le_comp_of_le {B A\u2081 : C} (f : A\u2081 \u27f6 B) [mono f] (X Y : subobject B)\n  (h\u2081 : mk f \u2264 X) (h\u2082 : X \u2264 Y) :\n  of_mk_le f X h\u2081 \u226b of_le X Y h\u2082 = of_mk_le f Y (h\u2081.trans h\u2082) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, \u2190functor.map_comp underlying]\n\n@[simp, reassoc] lemma of_mk_le_comp_of_le_mk {B A\u2081 A\u2082 : C} (f : A\u2081 \u27f6 B) [mono f] (X : subobject B)\n  (g : A\u2082 \u27f6 B) [mono g] (h\u2081 : mk f \u2264 X) (h\u2082 : X \u2264 mk g) :\n  of_mk_le f X h\u2081 \u226b of_le_mk X g h\u2082 = of_mk_le_mk f g (h\u2081.trans h\u2082) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, \u2190functor.map_comp_assoc underlying]\n\n@[simp, reassoc] lemma of_mk_le_mk_comp_of_mk_le {B A\u2081 A\u2082 : C} (f : A\u2081 \u27f6 B) [mono f] (g : A\u2082 \u27f6 B)\n  [mono g] (X : subobject B) (h\u2081 : mk f \u2264 mk g) (h\u2082 : mk g \u2264 X) :\n  of_mk_le_mk f g h\u2081 \u226b of_mk_le g X h\u2082 = of_mk_le f X (h\u2081.trans h\u2082) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, \u2190functor.map_comp underlying]\n\n@[simp, reassoc] lemma of_mk_le_mk_comp_of_mk_le_mk {B A\u2081 A\u2082 A\u2083 : C} (f : A\u2081 \u27f6 B) [mono f]\n  (g : A\u2082 \u27f6 B) [mono g] (h : A\u2083 \u27f6 B) [mono h] (h\u2081 : mk f \u2264 mk g) (h\u2082 : mk g \u2264 mk h) :\n  of_mk_le_mk f g h\u2081 \u226b of_mk_le_mk g h h\u2082 = of_mk_le_mk f h (h\u2081.trans h\u2082) :=\nby simp [of_mk_le, of_le_mk, of_le, of_mk_le_mk, \u2190functor.map_comp_assoc underlying]\n\n@[simp] lemma of_le_refl {B : C} (X : subobject B) :\n  of_le X X le_rfl = \ud835\udfd9 _ :=\nby { apply (cancel_mono X.arrow).mp, simp }\n\n@[simp] lemma of_mk_le_mk_refl {B A\u2081 : C} (f : A\u2081 \u27f6 B) [mono f] :\n  of_mk_le_mk f f le_rfl = \ud835\udfd9 _ :=\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) \u2245 (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 \u27f6 B) [mono f] (h : X = mk f) : (X : C) \u2245 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 \u27f6 B) [mono f] (X : subobject B) (h : mk f = X) : A \u2245 (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\u2081 A\u2082 : C} (f : A\u2081 \u27f6 B) (g : A\u2082 \u27f6 B) [mono f] [mono g] (h : mk f = mk g) :\n  A\u2081 \u2245 A\u2082 :=\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 \u2964 mono_over Y` descends to a functor\n`subobject X \u2964 subobject Y`, because `mono_over Y` is thin. -/\ndef lower {Y : D} (F : mono_over X \u2964 mono_over Y) : subobject X \u2964 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\u2081 F\u2082 : mono_over X \u2964 mono_over Y) (h : F\u2081 \u2245 F\u2082) :\n  lower F\u2081 = lower F\u2082 :=\nthin_skeleton.map_iso_eq h\n\n/-- A ternary version of `subobject.lower`. -/\ndef lower\u2082 (F : mono_over X \u2964 mono_over Y \u2964 mono_over Z) :\n  subobject X \u2964 subobject Y \u2964 subobject Z :=\nthin_skeleton.map\u2082 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 \u2964 mono_over B} {R : mono_over B \u2964 mono_over A} (h : L \u22a3 R) :\n  lower L \u22a3 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 \u224c mono_over B) : subobject A \u224c 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 \u27f6 Y` induces a functor `subobject Y \u2964 subobject X`,\nby pulling back a monomorphism along `f`. -/\ndef pullback (f : X \u27f6 Y) : subobject Y \u2964 subobject X :=\nlower (mono_over.pullback f)\n\nlemma pullback_id (x : subobject X) : (pullback (\ud835\udfd9 X)).obj x = x :=\nbegin\n  apply quotient.induction_on' x,\n  intro f,\n  apply quotient.sound,\n  exact \u27e8mono_over.pullback_id.app f\u27e9,\nend\n\nlemma pullback_comp (f : X \u27f6 Y) (g : Y \u27f6 Z) (x : subobject Z) :\n  (pullback (f \u226b 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 \u27e8(mono_over.pullback_comp _ _).app t\u27e9,\nend\n\ninstance (f : X \u27f6 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 \u27f6 Y`.\n-/\ndef map (f : X \u27f6 Y) [mono f] : subobject X \u2964 subobject Y :=\nlower (mono_over.map f)\n\nlemma map_id (x : subobject X) : (map (\ud835\udfd9 X)).obj x = x :=\nbegin\n  apply quotient.induction_on' x,\n  intro f,\n  apply quotient.sound,\n  exact \u27e8mono_over.map_id.app f\u27e9,\nend\n\nlemma map_comp (f : X \u27f6 Y) (g : Y \u27f6 Z) [mono f] [mono g] (x : subobject X) :\n  (map (f \u226b 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 \u27e8(mono_over.map_comp _ _).app t\u27e9,\nend\n\n/-- Isomorphic objects have equivalent subobject lattices. -/\ndef map_iso {A B : C} (e : A \u2245 B) : subobject A \u224c 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 \u2245 Y) : subobject X \u2243o subobject Y :=\n{ to_fun := (map e.hom).obj,\n  inv_fun := (map e.inv).obj,\n  left_inv := \u03bb g, by simp_rw [\u2190 map_comp, e.hom_inv_id, map_id],\n  right_inv := \u03bb g, by simp_rw [\u2190 map_comp, e.inv_hom_id, map_id],\n  map_rel_iff' := \u03bb A B, begin\n    dsimp, fsplit,\n    { intro h,\n      apply_fun (map e.inv).obj at h,\n      simp_rw [\u2190 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 \u2245 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 \u2245 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 \u2964 subobject Y` is\nthe left adjoint of `pullback f : subobject Y \u2964 subobject X`. -/\ndef map_pullback_adj [has_pullbacks C] (f : X \u27f6 Y) [mono f] : map f \u22a3 pullback f :=\nlower_adjunction (mono_over.map_pullback_adj f)\n\n@[simp]\nlemma pullback_map_self [has_pullbacks C] (f : X \u27f6 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 \u27e8(mono_over.pullback_map_self f).app _\u27e9,\nend\n\nlemma map_pullback [has_pullbacks C]\n  {X Y Z W : C} {f : X \u27f6 Y} {g : X \u27f6 Z} {h : Y \u27f6 W} {k : Z \u27f6 W} [mono h] [mono g]\n  (comm : f \u226b h = g \u226b 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 _ \u226b a.arrow \u226b h = (pullback.snd \u226b g) \u226b _,\n    rw [assoc, \u2190 comm, pullback.condition_assoc] },\n  { refine mono_over.hom_mk (pullback.lift pullback.fst\n                        (pullback_cone.is_limit.lift' t (pullback.fst \u226b a.arrow) pullback.snd _).1\n                        (pullback_cone.is_limit.lift' _ _ _ _).2.1.symm) _,\n    { rw [\u2190 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 \u00abexists\u00bb\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 \u00abexists\u00bb (f : X \u27f6 Y) : subobject X \u2964 subobject Y :=\nlower (mono_over.exists f)\n\n/--\nWhen `f : X \u27f6 Y` is a monomorphism, `exists f` agrees with `map f`.\n-/\nlemma exists_iso_map (f : X \u27f6 Y) [mono f] : \u00abexists\u00bb f = map f :=\nlower_iso _ _ (mono_over.exists_iso_map f)\n\n/--\n`exists f : subobject X \u2964 subobject Y` is\nleft adjoint to `pullback f : subobject Y \u2964 subobject X`.\n-/\ndef exists_pullback_adj (f : X \u27f6 Y) [has_pullbacks C] : \u00abexists\u00bb f \u22a3 pullback f :=\nlower_adjunction (mono_over.exists_pullback_adj f)\n\nend  \u00abexists\u00bb\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 \u22a2 p) : \u2b1d\u22a2 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 \u2a00 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 : \u2115}\n\nlemma to_snf_univ_closure (p : formula L m) :\n  \u2203 n (p\u2080 : subformula (L + L.skolem) m n) (h : p\u2080.is_open), p.to_snf = \u2200'*p\u2080 :=\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\u22c3 (\u03c3 : sentence L) (h\u03c3 : \u03c3 \u2208 T) {n} (p\u2080 : subformula (L + L.skolem) 0 n) (hp\u2080 : p\u2080.is_open)\n  (h : \u03c3.to_snf = (\u2200'*p\u2080 : subformula _ _ _)),\n  set.range (\u03bb x, sentence.to_pl (substs x p\u2080) (by simpa using hp\u2080))\n\nlemma Satisfiable_of_to_pl_Satisfiable (T : Theory L) (h : pl.Satisfiable (T.to_pl \u222a pl.equal_axioms (L + L.skolem))) : Satisfiable T :=\nbegin\n  rcases h with \u27e8V, hV\u27e9,\n  have hV\u0393 : V \u22a7 T.to_pl, from (logic.semantics.models_union.mp hV).1,\n  have hVeq : V \u22a7 pl.equal_axioms _, from (logic.semantics.models_union.mp hV).2,\n  let S := Structure.Herbrand V hVeq,\n  have : \u2200 {\u03c3 : sentence L} (h\u03c3 : \u03c3 \u2208 T), S \u22a7 \u03c3.to_snf,\n  { intros \u03c3 h\u03c3, rcases formula.to_snf_univ_closure \u03c3 with \u27e8n, p\u2080, hp\u2080, h\u27e9,\n    have : \u2200 x, S \u22a7 substs x p\u2080,\n    { intros x,\n      have : V \u22a7 sentence.to_pl (substs (Structure.Herbrand.qu_inv \u2218 subterm.val S fin.nil fin.nil \u2218 x) p\u2080) _,\n      from hV\u0393 (by simp[Theory.to_pl]; refine \u27e8\u03c3, h\u03c3, n, p\u2080, h, hp\u2080, _, rfl\u27e9),\n      simpa[sentence_models_def, Structure.Herbrand.val_iff_subst p\u2080 hp\u2080] using this },  \n    have : S \u22a7 \u2200'*p\u2080, by simpa[Structure.Herbrand.models_forall_iff] using this,\n    simpa[h] using this },\n  refine \u27e8S.restrict add_left, by intros \u03c3 h\u03c3; exact skolem.restrict_models _ (this h\u03c3)\u27e9\nend\n\ntheorem compactness {T : Theory L} : Satisfiable T \u2194 (\u2200 u \u2286 T, u.finite \u2192 Satisfiable u) :=\n\u27e8by rintros \u27e8S, hS\u27e9 u hu u_fin; refine \u27e8S, logic.semantics.models_of_ss hu hS\u27e9,\nbegin\n  contrapose, intros h,\n  have : \u00acpl.Satisfiable (T.to_pl \u222a pl.equal_axioms (L + L.skolem)),\n  from mt (Satisfiable_of_to_pl_Satisfiable T) h,\n  rcases pl.compactness'.mp this with \u27e8u, u_ss, u_fin, hu\u27e9,\n  let g := u \\ pl.equal_axioms _,\n  have : g \u2286 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 \u2286\n    \u22c3 (\u03c3 \u2208 T) {n} (p\u2080 : subformula (L + L.skolem) 0 n) (hp\u2080 : p\u2080.is_open) (h : to_snf \u03c3 = (\u2200'*p\u2080 : subformula _ _ _)),\n    set.range (\u03bb x, substs x p\u2080),\n  by simpa[Theory.to_pl, set.image_Union, \u2190set.range_comp, (\u2218)] 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 : \u00acpl.Satisfiable (g \u222a pl.equal_axioms _),\n  { intros A, suffices : pl.Satisfiable u, by contradiction, refine logic.semantics.Satisfiable_of_ss (by simp) A },\n  have : \u00acSatisfiable (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 \u27e8s, s_fin, hs\u27e9,\n  simp[-set.image_subset_iff] at hs \u22a2,\n  refine \u27e8s \u2229 T, by simp, set.finite.inter_of_left s_fin T, _\u27e9,\n  assume A,\n  suffices : Satisfiable (pl.formula.to_fol '' g), by contradiction,\n  rcases skolem.Satisfiability.mpr A with \u27e8S, hS\u27e9,\n  refine \u27e8S, _\u27e9, intros p hp,\n  have : \u2203 (\u03c3 \u2208 s \u2229 T) {n} (p\u2080 : subformula (L + L.skolem) 0 n),\n    p\u2080.is_open \u2227 to_snf \u03c3 = (\u2200'*p\u2080 : subformula _ _ _) \u2227 \u2203 x, substs x p\u2080 = p,\n  by simpa[and_assoc] using hs hp,\n  rcases this with \u27e8\u03c3, h\u03c3, n, p\u2080, hp\u2080, h, x, rfl\u27e9,\n  have : S \u22a7 \u2200'*p\u2080, { rw\u2190h, refine hS (set.mem_image_of_mem _ h\u03c3) },\n  simp[sentence_models_def] at this \u22a2, exact this _  \nend\u27e9\n\nend compactness\n\nopen subformula logic logic.Theory\n     axiomatic_classical_logic' axiomatic_classical_logic\n     Structure\nvariables {L} {m n : \u2115} [inhabited (L.fn 0)]\n\nlemma provable_of_valid_aux (p : subformula L 0 n) (hp : p.is_open) (H : valid (\u2203'*p)) : \u2205 \u22a2 \u2203'*p :=\nbegin\n  rcases (valid_iff_pl_consequence p hp).mp H with \u27e8v, hv\u27e9,\n  have lmm\u2081 : \u2205 \u22a2 (v.map (\u03bb t, substs t p)).disjunction \u27f6 \u2203'*p, from ldisj_imply_of (by simp),\n  have lmm\u2082 : \u2205 \u22a2 (v.map (\u03bb t, substs t p)).disjunction,\n    by simpa[(\u2218)] using pl.provable.to_fol (pl.completeness.mpr hv),\n  exact lmm\u2081 \u2a00 lmm\u2082\nend\n\nlemma provable_of_valid (\u03c3 : sentence L) (H : valid \u03c3) : \u2205 \u22a2 \u03c3 :=\nbegin\n  rcases formula.to_snf_univ_closure (\u223c\u03c3) with \u27e8n, p, hp, h\u27e9,\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 \u2115) (w : \u2203 x \u2208 xs, x < 3) : \u2200 y \u2208 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 : \u2115) (h : 2 \u2223 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 (\u03b1 : Type) (xs ys : list \u03b1) : xs ++ ys = ys ++ xs := by slim_check\n-- ===================\n\n-- ===================\n-- Found problems!\n\n-- Found problems!\n\n-- \u03b1 := \u2124\n\n-- \u03b1 := \u2124\n-- xs := [-4]\n\n-- xs := [-4]\n-- ys := [1]\n\n-- ys := [1]\n-- -------------------\n\n-- -------------------\n\nexample : \u2200 x \u2208 [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 \u2115,\nh : \u2203 (x : \u2115) (H : x \u2208 xs), x < 3\n\u22a2 \u2200 (y : \u2115), y \u2208 xs \u2192 y < 5\n```\n\nThe local constants are reverted and an instance is found for\n`testable (\u2200 (xs : list \u2115), (\u2203 x \u2208 xs, x < 3) \u2192 (\u2200 y \u2208 xs, y < 5))`.\nThe `testable` instance is supported by instances of `sampleable (list \u2115)`,\n`decidable (x < 3)` and `decidable (y < 5)`. `slim_check` builds a\n`testable` instance step by step with:\n\n```\n- testable (\u2200 (xs : list \u2115), (\u2203 x \u2208 xs, x < 3) \u2192 (\u2200 y \u2208 xs, y < 5))\n                                     -: sampleable (list xs)\n- testable ((\u2203 x \u2208 xs, x < 3) \u2192 (\u2200 y \u2208 xs, y < 5))\n- testable (\u2200 x \u2208 xs, x < 3 \u2192 (\u2200 y \u2208 xs, y < 5))\n- testable (x < 3 \u2192 (\u2200 y \u2208 xs, y < 5))\n                                     -: decidable (x < 3)\n- testable (\u2200 y \u2208 xs, y < 5)\n                                     -: decidable (y < 5)\n```\n\n`sampleable (list \u2115)` lets us create random data of type `list \u2115` 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 (\u2200 (\u03b1 : Type) (xs ys : list \u03b1), xs ++ ys = ys ++ xs)\n-- ===================\n\n-- ===================\n-- Found problems!\n\n-- Found problems!\n\n-- \u03b1 := \u2124\n\n-- \u03b1 := \u2124\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 {\u03b1 : Type*}\n\ndef is_prefix (l\u2081 : list \u03b1) (l\u2082 : list \u03b1) : Prop :=\n  \u2203 t, l\u2081 ++ t = l\u2082\n\ninstance list_has_le : has_le (list \u03b1) := \u27e8is_prefix\u27e9\n\ntheorem list.is_prefix_refl (l : list \u03b1) : l \u2264 l :=\n  \u27e8[], by simp\u27e9\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\u2080 E\u2081 E\u2082 : Type*} [finite E] [finite E\u2081] [finite E\u2082] \n{M\u2080 : matroid E\u2080} {M\u2081 : matroid E\u2081} {M\u2082 : matroid E\u2082}\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\u2081 : matroid E\u2081) (M\u2082 : matroid E\u2082) (e : E\u2081 \u2243 E\u2082) := \n  \u2200 B, M\u2081.base B \u2194 M\u2082.base (e '' B)  \n\n/-- A bundled isomorphism between two matroids -/\nstructure iso (M\u2081 : matroid E\u2081) (M\u2082 : matroid E\u2082) := \n(to_fun : E\u2081 \u2243 E\u2082)\n(on_base : \u2200 B, M\u2081.base B \u2194 M\u2082.base (to_fun '' B))\n\ninfix ` \u2243i ` :75 :=  matroid.iso\n\ninstance : has_coe_to_fun (M\u2081 \u2243i M\u2082) (\u03bb _, E\u2081 \u2192 E\u2082) :=\n  \u27e8\u03bb e, e.to_fun\u27e9  \n\ndef iso.refl (M : matroid E) : M \u2243i M := \u27e8equiv.refl E, \u03bb B, by simp\u27e9   \ndef iso.symm (e : M\u2081 \u2243i M\u2082) : M\u2082 \u2243i M\u2081 := \u27e8e.to_fun.symm, \u03bb B, by {rw e.on_base, simp, }\u27e9  \n\n/-- An equivalence between types induces a map from a matroid on one type to one on another -/\ndef congr_equiv (M\u2081 : matroid E\u2081) (e : E\u2081 \u2243 E\u2082)  :\n  matroid E\u2082 :=\n{ base := \u03bb B, M\u2081.base (e \u207b\u00b9' B),\n  exists_base' := by \n    {obtain \u27e8B\u2081,hB\u2081\u27e9 := M\u2081.exists_base, exact \u27e8e '' B\u2081, by simpa using hB\u2081\u27e9} ,\n  base_exchange' := \n  begin\n    rintro B\u2081 B\u2082 hB\u2081 hB\u2082 x hx,\n    have hx' : e.symm x \u2208 e \u207b\u00b9' B\u2081 \\ e\u207b\u00b9' B\u2082, by simpa,\n    obtain \u27e8y, hy, hBy\u27e9 := hB\u2081.exchange hB\u2082 hx',  \n    refine \u27e8e y, by simpa, _\u27e9, \n    dsimp only, \n    simp_rw [\u2190union_singleton, preimage_union, preimage_diff] at \u22a2 hBy, \n    convert hBy;\n    simp [preimage_equiv_eq_image_symm],\n  end}\n\n@[simp] lemma congr_equiv_apply_base {e : E\u2081 \u2243 E\u2082} {M\u2081 : matroid E\u2081} {B : set E\u2082} :\n  (M\u2081.congr_equiv e).base B \u2194 M\u2081.base (e \u207b\u00b9' B) := \niff.rfl \n\n@[simp] lemma congr_equiv_apply_indep {e : E\u2081 \u2243 E\u2082} {M\u2081 : matroid E\u2081} {I : set E\u2082} :\n  (M\u2081.congr_equiv e).indep I \u2194 M\u2081.indep (e \u207b\u00b9' I) := \nbegin\n  simp_rw [indep, congr_equiv_apply_base], \n  split, \n  { rintro \u27e8B\u2082, hB\u2082, hIB\u2082\u27e9, exact \u27e8_, hB\u2082, preimage_mono hIB\u2082\u27e9},\n  rintro \u27e8B\u2081, hB\u2081, hIB\u2081\u27e9, \n  refine \u27e8e '' B\u2081, by {convert hB\u2081, simp}, _\u27e9,  \n  rwa [\u2190equiv.subset_image, \u2190preimage_equiv_eq_image_symm], \nend \n\n@[simp] lemma congr_equiv_apply_symm_base {e : E\u2081 \u2243 E\u2082} {M\u2082 : matroid E\u2082} {B : set E\u2081} :\n  (M\u2082.congr_equiv e.symm).base B \u2194 M\u2082.base (e '' B) := \nby simp [\u2190image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_symm_indep {e : E\u2081 \u2243 E\u2082} {M\u2082 : matroid E\u2082} {I : set E\u2081} :\n  (M\u2082.congr_equiv e.symm).indep I \u2194 M\u2082.indep (e '' I) := \nby simp [\u2190image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_basis {e : E\u2081 \u2243 E\u2082} {M\u2081 : matroid E\u2081} {I X : set E\u2082} :\n  (M\u2081.congr_equiv e).basis I X \u2194 M\u2081.basis (e \u207b\u00b9' I) (e \u207b\u00b9' X) := \nbegin\n  simp only [basis, congr_equiv_apply_indep, equiv.preimage_subset, and.congr_right_iff], \n  refine \u03bb hI hIX, \u27e8\u03bb h J hJ hIJ hJX, _,\u03bb h J hJ hIJ hJX, _\u27e9, \n  { rw h (e '' J) (by simpa) _ (by simpa), \n    { simp, },\n    rw \u2190e.image_preimage I,\n    exact image_subset e hIJ}, \n  have h' := h (e \u207b\u00b9' 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\u2081 \u2243 E\u2082} {M\u2082 : matroid E\u2082} {I X : set E\u2081} :\n  (M\u2082.congr_equiv e.symm).basis I X \u2194 M\u2082.basis (e '' I) (e '' X) := \nby simp [\u2190image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_r {e : E\u2081 \u2243 E\u2082} {M\u2081 : matroid E\u2081} (X : set E\u2082) :\n  (M\u2081.congr_equiv e).r X = M\u2081.r (e \u207b\u00b9' X) := \nbegin\n  obtain \u27e8I, hI\u27e9 := (M\u2081.congr_equiv e).exists_basis X, \n  rw [\u2190hI.r, hI.indep.r], \n  rw [congr_equiv_apply_basis] at hI,\n  rw [\u2190hI.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\u2081 \u2243 E\u2082} {M\u2082 : matroid E\u2082} (X : set E\u2081) :\n  (M\u2082.congr_equiv e.symm).r X = M\u2082.r (e '' X) := \nby simp [\u2190image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_circuit {e : E\u2081 \u2243 E\u2082} {M\u2081 : matroid E\u2081} {C : set E\u2082} :\n  (M\u2081.congr_equiv e).circuit C \u2194 M\u2081.circuit (e \u207b\u00b9' 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 \u27e8\u03bb h x hxC, _,\u03bb h x (hx : e x \u2208 C), _\u27e9, \n  { convert h (e.symm x) (by simpa), \n    rw [\u2190image_singleton, preimage_equiv_eq_image_symm]},\n  convert h _ hx, \n  rw [\u2190image_singleton, preimage_image_eq _ e.injective], \nend \n\n@[simp] lemma congr_equiv_apply_symm_circuit {e : E\u2081 \u2243 E\u2082} {M\u2082 : matroid E\u2082} {C : set E\u2081} :\n  (M\u2082.congr_equiv e.symm).circuit C = M\u2082.circuit (e '' C) := \nby simp [\u2190image_equiv_eq_preimage_symm]\n\n@[simp] lemma congr_equiv_apply_flat {e : E\u2081 \u2243 E\u2082} {M\u2081 : matroid E\u2081} {F : set E\u2082} :\n  (M\u2081.congr_equiv e).flat F \u2194 M\u2081.flat (e \u207b\u00b9' F) :=\nbegin\n  simp_rw [flat_def, congr_equiv_apply_basis], \n  refine \u27e8\u03bb h I X hIF hFX, _,\u03bb h I X hIF hFX, _\u27e9, \n  { rw [\u2190image_subset_iff], \n    exact h (e '' I) (e '' X) (by simpa) (by simpa)},\n  exact (equiv.preimage_subset e X F).mp (h (\u21d1e \u207b\u00b9' I) (\u21d1e \u207b\u00b9' X) hIF hFX), \nend \n\n@[simp] lemma congr_equiv_apply_symm_flat {e : E\u2081 \u2243 E\u2082} {M\u2082 : matroid E\u2082} {F : set E\u2081} :\n  (M\u2082.congr_equiv e.symm).flat F = M\u2082.flat (e '' F) := \nby simp [\u2190image_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 (\u03b1 : Type) (\u03b2 : Type) [inhabited \u03b1] : inhabited (\u03b1 \u2295 \u03b2) :=\n    \u27e8@sum.inl \u03b1 \u03b2 (default \u03b1)\u27e9\n\n    instance inhabited_nonempty (\u03b1 : Type) [inhabited \u03b1] : inhabited (list \u03b1) :=\n    \u27e8list.cons (default \u03b1) list.nil\u27e9\n\n\n    def add_lists (\u03b1 : Type) [has_add \u03b1] : list \u03b1 \u2192 list \u03b1 \u2192 list \u03b1\n    | [] [] := []\n    | l1 [] := l1\n    | [] l2 := l2\n    | (hd1::tl1) (hd2::tl2) := (hd1 + hd2)::(add_lists tl1 tl2)\n\n    instance list_has_add (\u03b1 : Type) [has_add \u03b1] : has_add (list \u03b1) :=\n    \u27e8add_lists \u03b1\u27e9\n\n    example : [3, 2] + [] = [3, 2] := rfl\n    example : [] + [3, 2] = [3, 2] := rfl\n    example : (@list.nil \u2115) + [] = [] := 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": "import Smt\n\ntheorem conjunction (p q : Prop) : p \u2192 q \u2192 p \u2227 q := 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/Conjunction.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7772998611746911, "lm_q2_score": 0.588889130767832, "lm_q1q2_score": 0.4577434395931203}}
{"text": "lemma imp_trans (P Q R : Prop) : (P \u2192 Q) \u2192 ((Q \u2192 R) \u2192 (P \u2192 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 := \u27e8\u27e9\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 \u2192* Y) : of X \u27f6 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 := \u27e8Group.of punit\u27e9\n\n@[to_additive]\ninstance : inhabited Group := \u27e81\u27e9\n\n@[to_additive]\ninstance one.unique : unique (1 : Group) :=\n{ default := 1,\n  uniq := \u03bb a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : Group) (g : G) : (1 : G \u27f6 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\u2082 Group Mon := bundled_hom.forget\u2082 _ _\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 := \u27e8\u27e9\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 \u2192* Y) :\n  of X \u27f6 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 := \u27e8CommGroup.of punit\u27e9\n\n@[to_additive] instance : inhabited CommGroup := \u27e81\u27e9\n\n@[to_additive]\ninstance one.unique : unique (1 : CommGroup) :=\n{ default := 1,\n  uniq := \u03bb a, begin cases a, refl, end }\n\n@[simp, to_additive]\nlemma one_apply (G H : CommGroup) (g : G) : (1 : G \u27f6 H) g = 1 := rfl\n\n@[ext, to_additive]\nlemma ext (G H : CommGroup) (f\u2081 f\u2082 : G \u27f6 H) (w : \u2200 x, f\u2081 x = f\u2082 x) : f\u2081 = f\u2082 :=\nby { ext1, apply w }\n\n@[to_additive has_forget_to_AddGroup]\ninstance has_forget_to_Group : has_forget\u2082 CommGroup Group := bundled_hom.forget\u2082 _ _\n\n@[to_additive has_forget_to_AddCommMon]\ninstance has_forget_to_CommMon : has_forget\u2082 CommGroup CommMon :=\ninduced_category.has_forget\u2082 (\u03bb 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 \u27f6 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 `\u2124` sending\n`1` to that element. -/\n-- Note that because `\u2124 : 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 \u2124) \u27f6 G :=\nzmultiples_hom G g\n\n@[simp]\nlemma as_hom_apply {G : AddCommGroup.{0}} (g : G) (i : \u2124) : (as_hom g) i = i \u2022 g := rfl\n\nlemma as_hom_injective {G : AddCommGroup.{0}} : function.injective (@as_hom G) :=\n\u03bb h k w, by convert congr_arg (\u03bb k : (AddCommGroup.of \u2124) \u27f6 G, (k : \u2124 \u2192 G) (1 : \u2124)) w; simp\n\n@[ext]\nlemma int_hom_ext\n  {G : AddCommGroup.{0}} (f g : (AddCommGroup.of \u2124) \u27f6 G) (w : f (1 : \u2124) = g (1 : \u2124)) : 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 \u27f6 H) [mono f] : function.injective f :=\n\u03bb g\u2081 g\u2082 h,\nbegin\n  have t0 : as_hom g\u2081 \u226b f = as_hom g\u2082 \u226b f :=\n  begin\n    ext,\n    simpa [as_hom_apply] using h,\n  end,\n  have t1 : as_hom g\u2081 = as_hom g\u2082 := (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 \u2243* Y) : Group.of X \u2245 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 \u2243* Y) :\n  CommGroup.of X \u2245 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 \u2245 Y) : X \u2243* 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 \u2245 Y) : X \u2243* 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 \u2243* Y) \u2245 (Group.of X \u2245 Group.of Y) :=\n{ hom := \u03bb e, e.to_Group_iso,\n  inv := \u03bb 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 \u2243* Y) \u2245 (CommGroup.of X \u2245 CommGroup.of Y) :=\n{ hom := \u03bb e, e.to_CommGroup_iso,\n  inv := \u03bb 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 {\u03b1 : Type u} : Group.of (Aut \u03b1) \u2245 Group.of (equiv.perm \u03b1) :=\n{ hom := \u27e8\u03bb g, g.to_equiv, (by tidy), (by tidy)\u27e9,\n  inv := \u27e8\u03bb g, g.to_iso, (by tidy), (by tidy)\u27e9 }\n\n/-- The (unbundled) group of automorphisms of a type is `mul_equiv` to the (unbundled) group\nof permutations. -/\ndef mul_equiv_perm {\u03b1 : Type u} : Aut \u03b1 \u2243* equiv.perm \u03b1 :=\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 := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget Group).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_Group_iso).1\u27e9,\n  end }\n\n@[to_additive]\ninstance CommGroup.forget_reflects_isos : reflects_isomorphisms (forget CommGroup.{u}) :=\n{ reflects := \u03bb X Y f _,\n  begin\n    resetI,\n    let i := as_iso ((forget CommGroup).map f),\n    let e : X \u2243* Y := { ..f, ..i.to_equiv },\n    exact \u27e8(is_iso.of_iso e.to_CommGroup_iso).1\u27e9,\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 {\u03b1 : Type u}\n\nlemma del_root_del_root_view (t : btree \u03b1) :\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 \u27e8x, a', sh\u27e9,\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\u2081; assumption,\n      },\n      { simp only [if_neg h'],\n        apply del_root_view.nonempty_nonempty\u2082; try { assumption, },\n        linarith,\n      },\n    },\n  },\nend\n\n/- Auxiliary del_root lemma for forall_delete -/\nlemma forall_del_root (t : btree \u03b1) (k : nat) (p : nat \u2192 nat \u2192 Prop) :\n  forall_keys p k t \u2192 forall_keys p k (del_root t) :=\nbegin\n  intro h\u2081,\n  cases t,\n  case empty {\n    simp [del_root],\n    exact h\u2081,\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\u2081 \u22a2,\n      intros k' h\u2082,\n      apply h\u2081,\n      simp [bound],\n      tauto,\n    },\n    case nonempty_nonempty\u2081 {\n      apply forall_rotate_left,\n      rw \u2190 forall_keys_char,\n      repeat { split },\n      { rw \u2190 forall_keys_char at h\u2081, \n        cases_matching* (_ \u2227 _),\n        apply forall_shrink_aux_1 (and.intro h\u2081_left h),\n      },\n      { rw \u2190 forall_keys_char at h\u2081,\n        cases_matching* (_ \u2227 _),\n        apply forall_shrink_aux_2 (and.intro h\u2081_left h),\n      },\n      { unfold forall_keys at h\u2081 \u22a2, \n        intros k' h\u2082,\n        apply h\u2081,\n        simp [bound],\n        tauto,\n      },\n    },\n    case nonempty_nonempty\u2082 {\n      rw \u2190 forall_keys_char,\n      repeat { split },\n      { rw \u2190 forall_keys_char at h\u2081, \n        cases_matching* (_ \u2227 _),\n        apply forall_shrink_aux_1 (and.intro h\u2081_left h),\n      },\n      { rw \u2190 forall_keys_char at h\u2081, \n        cases_matching* (_ \u2227 _),\n        apply forall_shrink_aux_2 (and.intro h\u2081_left h),\n      },\n      { unfold forall_keys at h\u2081 \u22a2, \n        intros k' h\u2082,\n        apply h\u2081,\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 \u03b1) :\n  ordered t \u2192 ordered (del_root t) :=\nbegin\n  intro h\u2081,\n  cases t,\n  case empty {\n    simp [del_root, ordered],\n  },\n  case node : tl tk ta tr {\n    simp [ordered] at h\u2081,\n    cases_matching* (_ \u2227 _),\n    cases' del_root_del_root_view (node tl tk ta tr),\n    case nonempty_empty { assumption, },\n    case nonempty_nonempty\u2081 { \n      apply rotate_left_ordered, \n      rw ordered,\n      repeat { split },\n      { apply shrink_ordered_aux_1 (and.intro h\u2081_left h),  },\n      { assumption, },\n      { apply shrink_ordered_aux_2 (and.intro h\u2081_left h), },\n      { apply forall_keys_trans _ (<) k, \n        { apply forall_shrink_aux_2 (and.intro h\u2081_right_right_left h), },\n        { apply trans, },\n        { assumption, },\n      },\n    },\n    case nonempty_nonempty\u2082 { \n      rw ordered, \n      repeat { split },\n      { apply shrink_ordered_aux_1 (and.intro h\u2081_left h), },\n      { assumption, },\n      { apply shrink_ordered_aux_2 (and.intro h\u2081_left h), },\n      { apply forall_keys_trans _ (<) k, \n        { apply forall_shrink_aux_2 (and.intro h\u2081_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 `\u211d\u22650` for the nonnegative real numbers.\n\nopen category_theory ProFiltPseuNormGrpWithTinv polyhedral_lattice opposite\n\nvariables (r r' : \u211d\u22650)\nvariables [fact (0 < r)] [fact (0 < r')] [fact (r < r')] [fact (r' < 1)]\nvariables (BD : breen_deligne.package) (\u03ba : \u2115 \u2192 \u211d\u22650)\nvariables [BD.data.very_suitable r r' \u03ba] [\u2200 (i : \u2115), fact (0 < \u03ba i)]\n\ninclude r r' BD \u03ba\n\n/-- A mix of Theorems 9.4 and 9.5 in [Analytic] -/\ntheorem first_target :\n  \u2200 m : \u2115, \u2203 (k K : \u211d\u22650) (hk : fact (1 \u2264 k)) (c\u2080 : \u211d\u22650),\n  \u2200 (S : Type) [fintype S] (V : SemiNormedGroup.{u}) [normed_with_aut r V],\n    \u200b((BD.data.system \u03ba r V r').obj (op $ of r' (Lbar r' S))).is_weak_bounded_exact k K m c\u2080 :=\nbegin\n  intro m,\n  obtain \u27e8k, K, hk, H\u27e9 := thm95'' BD r r' \u03ba m,\n  obtain \u27e8c\u2080, H\u27e9 := H \u2124,\n  use [k, K, hk, c\u2080],\n  introsI S hS V hV,\n  specialize H S V,\n  let i := (BD.data.system \u03ba 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 \u2190 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 \u03ba]` assumes that the nonnegative reals `\u03ba 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`: `\u2225T(v)\u2225 = r * \u2225v\u2225`.\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  `\u2264 k`-exact in degrees `\u2264 m` for `c \u2265 c\u2080` (where `c` is an index to the system of complexes).\n-/\n\nexample : first_target_stmt r r' BD \u03ba := first_target r r' BD \u03ba\n\n/-- Theorem 9.4 in [Analytic] for weak bounded exactness -/\ntheorem thm94_weak :\n  \u2200 m : \u2115, \u2203 (k K : \u211d\u22650) (hk : fact (1 \u2264 k)) (c\u2080 : \u211d\u22650),\n  \u2200 (S : Profinite) (V : SemiNormedGroup.{u}) [normed_with_aut r V],\n    \u200b((BD.data.system \u03ba r V r').obj (op $ of r' ((Lbar.functor.{0 0} r').obj S)))\n      .is_weak_bounded_exact k K m c\u2080 :=\nbegin\n  intro m,\n  obtain \u27e8k, K, hk, H\u27e9 := thm95''.profinite BD r r' \u03ba m,\n  obtain \u27e8c\u2080, H\u27e9 := H \u2124,\n  use [k, K, hk, c\u2080],\n  introsI S V hV,\n  specialize H S V,\n  let i := (BD.data.system \u03ba 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 \u2190 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  \u2200 m : \u2115, \u2203 (k K : \u211d\u22650) (hk : fact (1 \u2264 k)) (c\u2080 : \u211d\u22650),\n  \u2200 (S : Profinite) (V : SemiNormedGroup.{u}) [normed_with_aut r V],\n    \u200b((BD.data.system \u03ba r V r').obj (op $ of r' ((Lbar.functor.{0 0} r').obj S)))\n      .is_bounded_exact k K m c\u2080 :=\nbegin\n  intro m,\n  obtain \u27e8k, K, hk, c\u2080, H\u27e9 := thm94_weak r r' BD \u03ba m,\n  resetI,\n  refine \u27e8k ^ 2, K + 1, infer_instance, c\u2080, _\u27e9,\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  \u2200 m : \u2115, \u2203 (k K : \u211d\u22650) (hk : fact (1 \u2264 k)) (c\u2080 : \u211d\u22650),\n  \u2200 (S : Profinite) (V : SemiNormedGroup.{u}) [normed_with_aut r V],\n    \u200b((BD.data.system \u03ba r V r').obj (op $ of r' ((Lbar.functor.{0 0} r').obj S)))\n      .is_weak_bounded_exact k K m c\u2080 :=\nbegin\n  intro m,\n  obtain \u27e8k, K, hk, H\u27e9 := thm95''.profinite BD r r' \u03ba m,\n  obtain \u27e8c\u2080, H\u27e9 := H \u2124,\n  use [k, K, hk, c\u2080],\n  introsI S V hV,\n  specialize H S V,\n  let i := (BD.data.system \u03ba 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 \u2190 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": "--\n\ntheorem ex1 : False :=\nby {\n   assumption -- should not use the auxiliary declaration `ex1 : False`\n}\n\nvariable (x y : Nat) in\ntheorem ex2 : x = y :=\nby {\n  subst x; -- should not use the auxiliary declaration `ex2 : x = y`\n  exact rfl\n}\n\nset_option pp.auxDecls true in\ntheorem ex3 : False :=\nby {\n   assumption -- should not use the auxiliary declaration `ex1 : False`\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/auxDeclIssue.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7577943712746404, "lm_q2_score": 0.6039318337259584, "lm_q1q2_score": 0.45765614423110335}}
{"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 \u2115` 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 `\u03b1` could be modelled as\n`\u03b1` 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' \u03b1 false`: Atoms as ZFA prelists. Basically a copy of `\u03b1`.\n* `Lists' \u03b1 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 \u03b1`: ZFA lists. Sum of the atoms and proper ZFA prelists.\n* `Finsets \u03b1`: ZFA sets. Defined as `Lists` quotiented by `Lists.Equiv`, the extensional\n  equivalence.\n-/\n\n\nvariable {\u03b1 : Type _}\n\n/-- Prelists, helper type to define `Lists`. `Lists' \u03b1 false` are the \"atoms\", a copy of `\u03b1`.\n`Lists' \u03b1 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} (\u03b1 : Type u) : Bool \u2192 Type u\n  | atom : \u03b1 \u2192 Lists' \u03b1 false\n  | nil : Lists' \u03b1 true\n  | cons' {b} : Lists' \u03b1 b \u2192 Lists' \u03b1 true \u2192 Lists' \u03b1 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 `\u03b1`, 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 (\u03b1 : Type _) :=\n  \u03a3b, Lists' \u03b1 b\n#align lists Lists\n\nnamespace Lists'\n\ninstance [Inhabited \u03b1] : \u2200 b, Inhabited (Lists' \u03b1 b)\n  | true => \u27e8nil\u27e9\n  | false => \u27e8atom default\u27e9\n\n/-- Appending a ZFA list to a proper ZFA prelist. -/\ndef cons : Lists \u03b1 \u2192 Lists' \u03b1 true \u2192 Lists' \u03b1 true\n  | \u27e8_, a\u27e9, 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 : \u2200 {b}, Lists' \u03b1 b \u2192 List (Lists \u03b1)\n  | _, atom _ => []\n  | _, nil => []\n  | _, cons' a l => \u27e8_, a\u27e9 :: 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 \u03b1) (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 \u03b1) \u2192 Lists' \u03b1 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 \u03b1)) : toList (ofList l) = l := by induction l <;> simp [*]\n#align lists'.to_of_list Lists'.to_ofList\n\n@[simp]\ntheorem of_toList : \u2200 l : Lists' \u03b1 true, ofList (toList l) = l :=\n  suffices\n    \u2200 (b) (h : true = b) (l : Lists' \u03b1 b),\n      let l' : Lists' \u03b1 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 \u03b1 \u2192 Lists \u03b1 \u2192 Prop\n    | refl (l) : Lists.Equiv l l\n    | antisymm {l\u2081 l\u2082 : Lists' \u03b1 true} :\n      Lists'.Subset l\u2081 l\u2082 \u2192 Lists'.Subset l\u2082 l\u2081 \u2192 Lists.Equiv \u27e8_, l\u2081\u27e9 \u27e8_, l\u2082\u27e9\n  inductive Lists'.Subset : Lists' \u03b1 true \u2192 Lists' \u03b1 true \u2192 Prop\n    | nil {l} : Lists'.Subset Lists'.nil l\n    | cons {a a' l l'} :\n      Lists.Equiv a a' \u2192\n        a' \u2208 Lists'.toList l' \u2192 Lists'.Subset l l' \u2192 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' \u03b1 true) :=\n  \u27e8Lists'.Subset\u27e9\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 \u03b1) (Lists' \u03b1 b) :=\n  \u27e8fun a l => \u2203 a' \u2208 l.toList, a ~ a'\u27e9\n\ntheorem mem_def {b a} {l : Lists' \u03b1 b} : a \u2208 l \u2194 \u2203 a' \u2208 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 \u2208 @cons \u03b1 y l \u2194 a ~ y \u2228 a \u2208 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\u2081 l\u2082 : Lists' \u03b1 true} : Lists'.cons a l\u2081 \u2286 l\u2082 \u2194 a \u2208 l\u2082 \u2227 l\u2081 \u2286 l\u2082 := by\n  refine' \u27e8fun h => _, fun \u27e8\u27e8a', m, e\u27e9, s\u27e9 => Subset.cons e m s\u27e9\n  generalize h' : Lists'.cons a l\u2081 = l\u2081' at h\n  cases' h with l a' a'' l l' e m s;\n  \u00b7 cases a\n    cases h'\n  cases a; cases a'; cases h'; exact \u27e8\u27e8_, m, e\u27e9, s\u27e9\n#align lists'.cons_subset Lists'.cons_subset\n\ntheorem ofList_subset {l\u2081 l\u2082 : List (Lists \u03b1)} (h : l\u2081 \u2286 l\u2082) :\n    Lists'.ofList l\u2081 \u2286 Lists'.ofList l\u2082 := by\n  induction' l\u2081 with _ _ l\u2081_ih; \u00b7 exact Subset.nil\n  refine' Subset.cons (Lists.Equiv.refl _) _ (l\u2081_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' \u03b1 true} : l \u2286 l := by\n  rw [\u2190 Lists'.of_toList l]; exact ofList_subset (List.Subset.refl _)\n#align lists'.subset.refl Lists'.Subset.refl\n\ntheorem subset_nil {l : Lists' \u03b1 true} : l \u2286 Lists'.nil \u2192 l = Lists'.nil := by\n  rw [\u2190 of_toList l]\n  induction toList l <;> intro h\n  \u00b7 rfl\n  \u00b7 rcases cons_subset.1 h with \u27e8\u27e8_, \u27e8\u27e9, _\u27e9, _\u27e9\n#align lists'.subset_nil Lists'.subset_nil\n\n\n\ntheorem subset_def {l\u2081 l\u2082 : Lists' \u03b1 true} : l\u2081 \u2286 l\u2082 \u2194 \u2200 a \u2208 l\u2081.toList, a \u2208 l\u2082 :=\n  \u27e8fun H a => mem_of_subset' H, fun H =>\n    by\n    rw [\u2190 of_toList l\u2081]\n    revert H; induction' toList l\u2081 with h t t_ih <;> intro H\n    \u00b7 exact Subset.nil\n    \u00b7 simp only [ofList, List.find?, List.mem_cons, forall_eq_or_imp] at *\n      exact cons_subset.2 \u27e8H.1, t_ih H.2\u27e9\u27e9\n#align lists'.subset_def Lists'.subset_def\n\nend Lists'\n\nnamespace Lists\n\n/-- Sends `a : \u03b1` to the corresponding atom in `Lists \u03b1`. -/\n@[match_pattern]\ndef atom (a : \u03b1) : Lists \u03b1 :=\n  \u27e8_, Lists'.atom a\u27e9\n#align lists.atom Lists.atom\n\n/-- Converts a proper ZFA prelist to a ZFA list. -/\n@[match_pattern]\ndef of' (l : Lists' \u03b1 true) : Lists \u03b1 :=\n  \u27e8_, l\u27e9\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 \u03b1 \u2192 List (Lists \u03b1)\n  | \u27e8_, l\u27e9 => l.toList\n#align lists.to_list Lists.toList\n\n/-- Predicate stating that a ZFA list is proper. -/\ndef IsList (l : Lists \u03b1) : 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 \u03b1)) : Lists \u03b1 :=\n  of' (Lists'.ofList l)\n#align lists.of_list Lists.ofList\n\ntheorem isList_toList (l : List (Lists \u03b1)) : IsList (ofList l) :=\n  Eq.refl _\n#align lists.is_list_to_list Lists.isList_toList\n\ntheorem to_ofList (l : List (Lists \u03b1)) : toList (ofList l) = l := by simp [ofList, of']\n#align lists.to_of_list Lists.to_ofList\n\ntheorem of_toList : \u2200 {l : Lists \u03b1}, IsList l \u2192 ofList (toList l) = l\n  | \u27e8true, l\u27e9, _ => by simp_all [ofList, of']\n#align lists.of_to_list Lists.of_toList\n\ninstance : Inhabited (Lists \u03b1) :=\n  \u27e8of' Lists'.nil\u27e9\n\ninstance [DecidableEq \u03b1] : DecidableEq (Lists \u03b1) := 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 \u03b1] : SizeOf (Lists \u03b1) := 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 \u03b1 \u2192 Sort _) (D : Lists' \u03b1 true \u2192 Sort _)\n    (C0 : \u2200 a, C (atom a)) (C1 : \u2200 l, D l \u2192 C (of' l))\n    (D0 : D Lists'.nil) (D1 : \u2200 a l, C a \u2192 D l \u2192 D (Lists'.cons a l)) :\n    PProd (\u2200 l, C l) (\u2200 l, D l) := by\n  suffices\n    \u2200 {b} (l : Lists' \u03b1 b),\n      PProd (C \u27e8_, l\u27e9)\n        (match b, l with\n        | true, l => D l\n        | false, _ => PUnit)\n    by exact \u27e8fun \u27e8b, l\u27e9 => (this _).1, fun l => (this l).2\u27e9\n  intros b l\n  induction' l with a b a l IH\u2081 IH\n  \u00b7 exact \u27e8C0 _, \u27e8\u27e9\u27e9\n  \u00b7 exact \u27e8C1 _ D0, D0\u27e9\n  \u00b7 have : D (Lists'.cons' a l) := D1 \u27e8_, _\u27e9 _ IH\u2081.1 IH.2\n    exact \u27e8C1 _ this, this\u27e9\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 \u03b1) : Lists \u03b1 \u2192 Prop\n  | \u27e8false, _\u27e9 => False\n  | \u27e8_, l\u27e9 => a \u2208 l\n#align lists.mem Lists.mem\n\ninstance : Membership (Lists \u03b1) (Lists \u03b1) :=\n  \u27e8mem\u27e9\n\ntheorem isList_of_mem {a : Lists \u03b1} : \u2200 {l : Lists \u03b1}, a \u2208 l \u2192 IsList l\n  | \u27e8_, Lists'.nil\u27e9, _ => rfl\n  | \u27e8_, Lists'.cons' _ _\u27e9, _ => rfl\n#align lists.is_list_of_mem Lists.isList_of_mem\n\ntheorem Equiv.antisymm_iff {l\u2081 l\u2082 : Lists' \u03b1 true} : of' l\u2081 ~ of' l\u2082 \u2194 l\u2081 \u2286 l\u2082 \u2227 l\u2082 \u2286 l\u2081 := by\n  refine' \u27e8fun h => _, fun \u27e8h\u2081, h\u2082\u27e9 => Equiv.antisymm h\u2081 h\u2082\u27e9\n  cases' h with _ _ _ h\u2081 h\u2082\n  \u00b7 simp [Lists'.Subset.refl]\n  . exact \u27e8h\u2081, h\u2082\u27e9\n#align lists.equiv.antisymm_iff Lists.Equiv.antisymm_iff\n\nattribute [refl] Equiv.refl\n\ntheorem equiv_atom {a} {l : Lists \u03b1} : atom a ~ l \u2194 atom a = l :=\n  \u27e8fun h => by cases h; rfl, fun h => h \u25b8 Equiv.refl _\u27e9\n#align lists.equiv_atom Lists.equiv_atom\n\ntheorem Equiv.symm {l\u2081 l\u2082 : Lists \u03b1} (h : l\u2081 ~ l\u2082) : l\u2082 ~ l\u2081 := by\n  cases' h with _ _ _ h\u2081 h\u2082 <;> [rfl, exact Equiv.antisymm h\u2082 h\u2081]\n#align lists.equiv.symm Lists.Equiv.symm\n\ntheorem Equiv.trans : \u2200 {l\u2081 l\u2082 l\u2083 : Lists \u03b1}, l\u2081 ~ l\u2082 \u2192 l\u2082 ~ l\u2083 \u2192 l\u2081 ~ l\u2083 := by\n  let trans := fun l\u2081 : Lists \u03b1 => \u2200 \u2983l\u2082 l\u2083\u2984, l\u2081 ~ l\u2082 \u2192 l\u2082 ~ l\u2083 \u2192 l\u2081 ~ l\u2083\n  suffices PProd (\u2200 l\u2081, trans l\u2081) (\u2200 (l : Lists' \u03b1 true), \u2200 l' \u2208 l.toList, trans l') by exact this.1\n  apply inductionMut\n  \u00b7 intro a l\u2082 l\u2083 h\u2081 h\u2082\n    rwa [\u2190 equiv_atom.1 h\u2081] at h\u2082\n  \u00b7 intro l\u2081 IH l\u2082 l\u2083 h\u2081 h\u2082\n    -- Porting note: Two 'have's are for saving the state.\n    have h\u2081' := h\u2081\n    have h\u2082' := h\u2082\n    cases' h\u2081 with _ _ l\u2082\n    \u00b7 exact h\u2082\n    cases' h\u2082 with _ _ l\u2083\n    \u00b7 exact h\u2081'\n    cases' Equiv.antisymm_iff.1 h\u2081' with hl\u2081 hr\u2081\n    cases' Equiv.antisymm_iff.1 h\u2082' with hl\u2082 hr\u2082\n    apply Equiv.antisymm_iff.2; constructor <;> apply Lists'.subset_def.2\n    \u00b7 intro a\u2081 m\u2081\n      rcases Lists'.mem_of_subset' hl\u2081 m\u2081 with \u27e8a\u2082, m\u2082, e\u2081\u2082\u27e9\n      rcases Lists'.mem_of_subset' hl\u2082 m\u2082 with \u27e8a\u2083, m\u2083, e\u2082\u2083\u27e9\n      exact \u27e8a\u2083, m\u2083, IH _ m\u2081 e\u2081\u2082 e\u2082\u2083\u27e9\n    \u00b7 intro a\u2083 m\u2083\n      rcases Lists'.mem_of_subset' hr\u2082 m\u2083 with \u27e8a\u2082, m\u2082, e\u2083\u2082\u27e9\n      rcases Lists'.mem_of_subset' hr\u2081 m\u2082 with \u27e8a\u2081, m\u2081, e\u2082\u2081\u27e9\n      exact \u27e8a\u2081, m\u2081, (IH _ m\u2081 e\u2082\u2081.symm e\u2083\u2082.symm).symm\u27e9\n  \u00b7 rintro _ \u27e8\u27e9\n  \u00b7 intro a l IH\u2081 IH\n    -- Porting note: Previous code was:\n    -- simpa [IH\u2081] 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\u2082 l\u2083 h\u2081 h\u2082\n      exact IH\u2081 h\u2081 h\u2082\n    . intros a h\u2081 l\u2082 l\u2083 h\u2082 h\u2083\n      exact IH _ h\u2081 h\u2082 h\u2083\n#align lists.equiv.trans Lists.Equiv.trans\n\ninstance : Setoid (Lists \u03b1) :=\n  \u27e8(\u00b7 ~ \u00b7), Equiv.refl, @Equiv.symm _, @Equiv.trans _\u27e9\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 (\u03a3' _l\u2081 : Lists \u03b1, Lists \u03b1) <|\n        PSum (\u03a3' _l\u2081 : Lists' \u03b1 true, Lists' \u03b1 true) (\u03a3' _a : Lists \u03b1, Lists' \u03b1 true)) \u2192\n      \u2115\n  | PSum.inl \u27e8l\u2081, l\u2082\u27e9 => SizeOf.sizeOf l\u2081 + SizeOf.sizeOf l\u2082\n  | PSum.inr <| PSum.inl \u27e8l\u2081, l\u2082\u27e9 => SizeOf.sizeOf l\u2081 + SizeOf.sizeOf l\u2082\n  | PSum.inr <| PSum.inr \u27e8l\u2081, l\u2082\u27e9 => SizeOf.sizeOf l\u2081 + SizeOf.sizeOf l\u2082\n#align lists.equiv.decidable_meas Lists.Equiv.decidableMeas\n\ntheorem sizeof_pos {b} (l : Lists' \u03b1 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' \u03b1 b) (l) :\n    SizeOf.sizeOf (\u27e8b, a\u27e9 : Lists \u03b1) < 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 \u03b1]\n\nmutual\n  instance Equiv.decidable : \u2200 l\u2081 l\u2082 : Lists \u03b1, Decidable (l\u2081 ~ l\u2082)\n    | \u27e8false, l\u2081\u27e9, \u27e8false, l\u2082\u27e9 =>\n      decidable_of_iff' (l\u2081 = l\u2082) <| by\n        cases l\u2081\n        apply equiv_atom.trans\n        simp [atom]\n        constructor <;> (rintro \u27e8rfl\u27e9; rfl)\n    | \u27e8false, l\u2081\u27e9, \u27e8true, l\u2082\u27e9 => isFalse <| by rintro \u27e8\u27e9\n    | \u27e8true, l\u2081\u27e9, \u27e8false, l\u2082\u27e9 => isFalse <| by rintro \u27e8\u27e9\n    | \u27e8true, l\u2081\u27e9, \u27e8true, l\u2082\u27e9 => by\n      haveI : Decidable (l\u2081 \u2286 l\u2082) :=\n        have : SizeOf.sizeOf l\u2081 + SizeOf.sizeOf l\u2082 <\n            SizeOf.sizeOf (\u27e8true, l\u2081\u27e9 : Lists \u03b1) + SizeOf.sizeOf (\u27e8true, l\u2082\u27e9 : Lists \u03b1) :=\n          by decreasing_tactic\n        Subset.decidable l\u2081 l\u2082\n      haveI : Decidable (l\u2082 \u2286 l\u2081) :=\n        have : SizeOf.sizeOf l\u2082 + SizeOf.sizeOf l\u2081 <\n            SizeOf.sizeOf (\u27e8true, l\u2081\u27e9 : Lists \u03b1) + SizeOf.sizeOf (\u27e8true, l\u2082\u27e9 : Lists \u03b1) :=\n          by decreasing_tactic\n        Subset.decidable l\u2082 l\u2081\n      exact decidable_of_iff' _ Equiv.antisymm_iff\n  instance Subset.decidable  : \u2200 l\u2081 l\u2082 : Lists' \u03b1 true, Decidable (l\u2081 \u2286 l\u2082)\n    | Lists'.nil, l\u2082 => isTrue Lists'.Subset.nil\n    | @Lists'.cons' _ b a l\u2081, l\u2082 => by\n      haveI :=\n        have : sizeOf (\u27e8b, a\u27e9 : Lists \u03b1) < 1 + 1 + sizeOf a + sizeOf l\u2081 := by simp [sizeof_pos]\n        mem.decidable \u27e8b, a\u27e9 l\u2082\n      haveI :=\n        have : SizeOf.sizeOf l\u2081 + SizeOf.sizeOf l\u2082 <\n            SizeOf.sizeOf (Lists'.cons' a l\u2081) + SizeOf.sizeOf l\u2082 :=\n          by decreasing_tactic\n        Subset.decidable l\u2081 l\u2082\n      exact decidable_of_iff' _ (@Lists'.cons_subset _ \u27e8_, _\u27e9 _ _)\n  instance mem.decidable  : \u2200 (a : Lists \u03b1) (l : Lists' \u03b1 true), Decidable (a \u2208 l)\n    | a, Lists'.nil => isFalse <| by rintro \u27e8_, \u27e8\u27e9, _\u27e9\n    | a, Lists'.cons' b l\u2082 => by\n      haveI :=\n        have : sizeOf (\u27e8_, b\u27e9 : Lists \u03b1) < 1 + 1 + sizeOf b + sizeOf l\u2082 := by simp [sizeof_pos]\n        Equiv.decidable a \u27e8_, b\u27e9\n      haveI :=\n        have :\n          SizeOf.sizeOf a + SizeOf.sizeOf l\u2082 <\n            SizeOf.sizeOf a + SizeOf.sizeOf (Lists'.cons' b l\u2082) :=\n          by decreasing_tactic\n        mem.decidable a l\u2082\n      refine' decidable_of_iff' (a ~ \u27e8_, b\u27e9 \u2228 a \u2208 l\u2082) _\n      rw [\u2190 Lists'.mem_cons]; rfl\nend termination_by' \u27e8_, InvImage.wf Equiv.decidableMeas Nat.lt_wfRel.wf\u27e9\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' \u03b1 true} : \u2200 {a a'}, a ~ a' \u2192 (a \u2208 l \u2194 a' \u2208 l) :=\n  suffices \u2200 {a a'}, a ~ a' \u2192 a \u2208 l \u2192 a' \u2208 l from fun e => \u27e8this e, this e.symm\u27e9\n  fun e\u2081 \u27e8_, m\u2083, e\u2082\u27e9 => \u27e8_, m\u2083, e\u2081.symm.trans e\u2082\u27e9\n#align lists'.mem_equiv_left Lists'.mem_equiv_left\n\ntheorem mem_of_subset {a} {l\u2081 l\u2082 : Lists' \u03b1 true} (s : l\u2081 \u2286 l\u2082) : a \u2208 l\u2081 \u2192 a \u2208 l\u2082\n  | \u27e8_, m, e\u27e9 => (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\u2081 l\u2082 l\u2083 : Lists' \u03b1 true} (h\u2081 : l\u2081 \u2286 l\u2082) (h\u2082 : l\u2082 \u2286 l\u2083) : l\u2081 \u2286 l\u2083 :=\n  subset_def.2 fun _ m\u2081 => mem_of_subset h\u2082 <| mem_of_subset' h\u2081 m\u2081\n#align lists'.subset.trans Lists'.Subset.trans\n\nend Lists'\n\n/-- `Finsets` are defined via equivalence classes of `Lists` -/\ndef Finsets (\u03b1 : Type _) :=\n  Quotient (@Lists.instSetoidLists \u03b1)\n#align finsets Finsets\n\nnamespace Finsets\n\ninstance : EmptyCollection (Finsets \u03b1) :=\n  \u27e8\u27e6Lists.of' Lists'.nil\u27e7\u27e9\n\ninstance : Inhabited (Finsets \u03b1) :=\n  \u27e8\u2205\u27e9\n\ninstance [DecidableEq \u03b1] : DecidableEq (Finsets \u03b1) := 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": "import tactic\n\n-- example {P Q : Prop} (p : P) (h : P \u2192 Q) : Q :=\n-- begin\n--   by hint,\n--   sorry,\n-- end\n\nexample {P Q : Prop} (p : P) (h : P \u2192 Q) : Q :=\nby tauto\n\nexample {P Q : Prop} (p : P) (h : P \u2192 Q) : Q :=\nby finish\n\nexample {P Q : Prop} (p : P) (h : P \u2192 Q) : Q :=\nby solve_by_elim\n\n-- Al colocar el cursor sobre hint escribe\n--    the following tactics solve the goal:\n--    ----\n--    Try this: tauto\n--    Try this: finish\n--    Try this: solve_by_elim\n\n-- Ver la documentaci\u00f3n en https://bit.ly/2Z56ceN\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/La_tactica_hint.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6513548646660543, "lm_q2_score": 0.7025300449389326, "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 \u211d or \u2102: 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 (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (A : set E) (B : set E) :=\n  \u2203 (r : \u211d), \u2203 (H : r > 0), \u2200 (a : \ud835\udd5c), r \u2264 norm a \u2192 B \u2286 a \u2022 A\n\n/-- A set is absorbent if it absorbs every singleton. -/\ndef absorbent (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (A : set E) :=\n  \u2200 (x : E), \u2203 (r : \u211d), \u2203 (H : r > 0), \u2200 (a : \ud835\udd5c), r \u2264 norm a \u2192 x \u2208 a \u2022 A\n\n/-- A set `A` is balanced if `a \u2022 A` is contained in `A` whenever `a`\nhas norm no greater than one. -/\ndef balanced (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (A : set E) :=\n  \u2200 (a : \ud835\udd5c), norm a \u2264 1 \u2192 a \u2022 A \u2286 A\n\n/-- A balanced set absorbs itself. -/\ntheorem balanced.absorbs_self {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} (hA : balanced \ud835\udd5c A) : absorbs \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} [topological_space E]\n    [topological_vector_space \ud835\udd5c E] (hA : A \u2208 nhds 0) : absorbent \ud835\udd5c A :=\n  sorry\n\n/-- The union of `{0}` with the interior of a balanced set\n    is balanced. -/\ntheorem balanced_zero_union_interior {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} [topological_space E]\n    [topological_vector_space \ud835\udd5c E] (hA : balanced \ud835\udd5c A) : balanced \ud835\udd5c (singleton 0 \u222a interior A) :=\n  sorry\n\n/-- The interior of a balanced set is balanced if it contains the origin. -/\ntheorem balanced.interior {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} [topological_space E]\n    [topological_vector_space \ud835\udd5c E] (hA : balanced \ud835\udd5c A) (h : 0 \u2208 interior A) :\n    balanced \ud835\udd5c (interior A) :=\n  sorry\n\n/-- The closure of a balanced set is balanced. -/\ntheorem balanced.closure {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] {A : set E} [topological_space E]\n    [topological_vector_space \ud835\udd5c E] (hA : balanced \ud835\udd5c A) : balanced \ud835\udd5c (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 (\ud835\udd5c : Type u_1) (E : Type u_2) [normed_field \ud835\udd5c] [add_comm_group E]\n    [vector_space \ud835\udd5c E]\n    where\n  to_fun : E \u2192 \u211d\n  smul' : \u2200 (a : \ud835\udd5c) (x : E), to_fun (a \u2022 x) = norm a * to_fun x\n  triangle' : \u2200 (x y : E), to_fun (x + y) \u2264 to_fun x + to_fun y\n\nprotected instance seminorm.inhabited {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] : Inhabited (seminorm \ud835\udd5c E) :=\n  { default := seminorm.mk (fun (_x : E) => 0) sorry sorry }\n\nprotected instance seminorm.has_coe_to_fun {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [add_comm_group E] [vector_space \ud835\udd5c E] : has_coe_to_fun (seminorm \ud835\udd5c E) :=\n  has_coe_to_fun.mk (fun (p : seminorm \ud835\udd5c E) => E \u2192 \u211d) fun (p : seminorm \ud835\udd5c E) => seminorm.to_fun p\n\nnamespace seminorm\n\n\nprotected theorem smul {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (c : \ud835\udd5c) (x : E) :\n    coe_fn p (c \u2022 x) = norm c * coe_fn p x :=\n  smul' p c x\n\nprotected theorem triangle {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) (y : E) :\n    coe_fn p (x + y) \u2264 coe_fn p x + coe_fn p y :=\n  triangle' p x y\n\n@[simp] protected theorem zero {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) : coe_fn p 0 = 0 :=\n  sorry\n\n@[simp] protected theorem neg {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) : coe_fn p (-x) = coe_fn p x :=\n  sorry\n\ntheorem nonneg {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) : 0 \u2264 coe_fn p x :=\n  sorry\n\ntheorem sub_rev {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) (r : \u211d) : set E :=\n  set_of fun (y : E) => coe_fn p (y - x) < r\n\ntheorem mem_ball {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (x : E) (y : E) (r : \u211d) :\n    y \u2208 ball p x r \u2194 coe_fn p (y - x) < r :=\n  iff.rfl\n\ntheorem mem_ball_zero {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (y : E) (r : \u211d) : y \u2208 ball p 0 r \u2194 coe_fn p y < r :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (y \u2208 ball p 0 r \u2194 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 \u2194 coe_fn p y < r)) (sub_zero y)))\n      (iff.refl (coe_fn p y < r)))\n\ntheorem ball_zero_eq {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [add_comm_group E]\n    [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (r : \u211d) :\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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [add_comm_group E] [vector_space \ud835\udd5c E] (p : seminorm \ud835\udd5c E) (r : \u211d) : balanced \ud835\udd5c (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) 2022 Arthur Paulino. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Arthur Paulino, Gabriel Ebner\n-/\n\nimport Lean\n\n/-!\nDefines the `use` tactic.\n\nTODO: This does not match the full functionality of `use` from mathlib3.\nSee failing tests in `test/Use.lean`.\n-/\n\nopen Lean.Elab.Tactic\n\nnamespace Mathlib.Tactic\n\n/--\n`use e\u2081, e\u2082, \u22ef` applies the tactic `refine \u27e8e\u2081, e\u2082, \u22ef, ?_\u27e9` and then tries\nto close the goal with `with_reducible rfl` (which may or may not close it). It's\nuseful, for example, to advance on existential goals, for which terms as\nwell as proofs of some claims about them are expected.\n\nExamples:\n\n```lean\nexample : \u2203 x : Nat, x = x := by use 42\n\nexample : \u2203 x : Nat, \u2203 y : Nat, x = y := by use 42, 42\n\nexample : \u2203 x : String \u00d7 String, x.1 = x.2 := by use (\"forty-two\", \"forty-two\")\n```\n-/\n-- TODO extend examples in doc-string once mathlib3 parity is achieved.\nmacro \"use \" es:term,+ : tactic =>\n  `(tactic|(refine \u27e8$es,*, ?_\u27e9; try with_reducible 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/Tactic/Use.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.5926665855647394, "lm_q2_score": 0.7718434978390747, "lm_q1q2_score": 0.4574458504546297}}
{"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 (\u03b1 : Type u)\n\nnamespace MulOpposite\n\n/-!\n### Additive structures on `\u03b1\u1d50\u1d52\u1d56`\n-/\n\n\n@[to_additive]\ninstance [NatCast \u03b1] : NatCast \u03b1\u1d50\u1d52\u1d56 :=\n  \u27e8fun n => op n\u27e9\n\n@[to_additive]\ninstance [IntCast \u03b1] : IntCast \u03b1\u1d50\u1d52\u1d56 :=\n  \u27e8fun n => op n\u27e9\n\ninstance [AddSemigroup \u03b1] : AddSemigroup \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddSemigroup _ fun x y => rfl\n\ninstance [AddLeftCancelSemigroup \u03b1] : AddLeftCancelSemigroup \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddLeftCancelSemigroup _ fun x y => rfl\n\ninstance [AddRightCancelSemigroup \u03b1] : AddRightCancelSemigroup \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddRightCancelSemigroup _ fun x y => rfl\n\ninstance [AddCommSemigroup \u03b1] : AddCommSemigroup \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddCommSemigroup _ fun x y => rfl\n\ninstance [AddZeroClass \u03b1] : AddZeroClass \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddZeroClass _ rfl fun x y => rfl\n\ninstance [AddMonoid \u03b1] : AddMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [AddCommMonoid \u03b1] : AddCommMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddCommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [AddMonoidWithOne \u03b1] : AddMonoidWithOne \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.addMonoid \u03b1, MulOpposite.hasOne \u03b1,\n    MulOpposite.hasNatCast\n      _ with\n    natCast_zero := show op ((0 : \u2115) : \u03b1) = 0 by rw [Nat.cast_zero, op_zero]\n    natCast_succ := show \u2200 n, op ((n + 1 : \u2115) : \u03b1) = op (n : \u2115) + 1 by simp }\n\ninstance [AddCommMonoidWithOne \u03b1] : AddCommMonoidWithOne \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.addMonoidWithOne \u03b1, MulOpposite.addCommMonoid \u03b1 with }\n\ninstance [SubNegMonoid \u03b1] : SubNegMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.SubNegMonoid _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [AddGroup \u03b1] : AddGroup \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    fun _ _ => rfl\n\ninstance [AddCommGroup \u03b1] : AddCommGroup \u03b1\u1d50\u1d52\u1d56 :=\n  unop_injective.AddCommGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [AddGroupWithOne \u03b1] : AddGroupWithOne \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.addMonoidWithOne \u03b1,\n    MulOpposite.addGroup \u03b1 with\n    intCast := fun n => op n\n    intCast_ofNat := fun n => show op ((n : \u2124) : \u03b1) = op n by rw [Int.cast_ofNat]\n    intCast_negSucc := fun n =>\n      show op _ = op (-unop (op ((n + 1 : \u2115) : \u03b1))) by erw [unop_op, Int.cast_negSucc] <;> rfl }\n\ninstance [AddCommGroupWithOne \u03b1] : AddCommGroupWithOne \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.addGroupWithOne \u03b1, MulOpposite.addCommGroup \u03b1 with }\n\n/-!\n### Multiplicative structures on `\u03b1\u1d50\u1d52\u1d56`\n\nWe also generate additive structures on `\u03b1\u1d43\u1d52\u1d56` using `to_additive`\n-/\n\n\n@[to_additive]\ninstance [Semigroup \u03b1] : Semigroup \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.hasMul \u03b1 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 \u03b1] : LeftCancelSemigroup \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.semigroup \u03b1 with\n    mul_left_cancel := fun x y z H => unop_injective <| mul_right_cancel <| op_injective H }\n\n@[to_additive]\ninstance [LeftCancelSemigroup \u03b1] : RightCancelSemigroup \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.semigroup \u03b1 with\n    mul_right_cancel := fun x y z H => unop_injective <| mul_left_cancel <| op_injective H }\n\n@[to_additive]\ninstance [CommSemigroup \u03b1] : CommSemigroup \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.semigroup \u03b1 with\n    mul_comm := fun x y => unop_injective <| mul_comm (unop y) (unop x) }\n\n@[to_additive]\ninstance [MulOneClass \u03b1] : MulOneClass \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.hasMul \u03b1,\n    MulOpposite.hasOne\n      \u03b1 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 \u03b1] : Monoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.semigroup \u03b1,\n    MulOpposite.mulOneClass \u03b1 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 \u03b1] : LeftCancelMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.leftCancelSemigroup \u03b1, MulOpposite.monoid \u03b1 with }\n\n@[to_additive]\ninstance [LeftCancelMonoid \u03b1] : RightCancelMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.rightCancelSemigroup \u03b1, MulOpposite.monoid \u03b1 with }\n\n@[to_additive]\ninstance [CancelMonoid \u03b1] : CancelMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.rightCancelMonoid \u03b1, MulOpposite.leftCancelMonoid \u03b1 with }\n\n@[to_additive]\ninstance [CommMonoid \u03b1] : CommMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.monoid \u03b1, MulOpposite.commSemigroup \u03b1 with }\n\n@[to_additive]\ninstance [CancelCommMonoid \u03b1] : CancelCommMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.cancelMonoid \u03b1, MulOpposite.commMonoid \u03b1 with }\n\n@[to_additive AddOpposite.subNegMonoid]\ninstance [DivInvMonoid \u03b1] : DivInvMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.monoid \u03b1,\n    MulOpposite.hasInv \u03b1 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 \u03b1] : DivisionMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.divInvMonoid \u03b1,\n    MulOpposite.hasInvolutiveInv\n      \u03b1 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 \u03b1] : DivisionCommMonoid \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.divisionMonoid \u03b1, MulOpposite.commSemigroup \u03b1 with }\n\n@[to_additive]\ninstance [Group \u03b1] : Group \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.divInvMonoid \u03b1 with\n    mul_left_inv := fun x => unop_injective <| mul_inv_self <| unop x }\n\n@[to_additive]\ninstance [CommGroup \u03b1] : CommGroup \u03b1\u1d50\u1d52\u1d56 :=\n  { MulOpposite.group \u03b1, MulOpposite.commMonoid \u03b1 with }\n\nvariable {\u03b1}\n\n#print MulOpposite.op_natCast /-\n@[simp, norm_cast, to_additive]\ntheorem op_natCast [NatCast \u03b1] (n : \u2115) : op (n : \u03b1) = 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 \u03b1] (n : \u2124) : op (n : \u03b1) = 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 \u03b1] (n : \u2115) : unop (n : \u03b1\u1d50\u1d52\u1d56) = 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 \u03b1] (n : \u2124) : unop (n : \u03b1\u1d50\u1d52\u1d56) = 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 {\u03b1 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} \u03b1] (x : MulOpposite.{u1} \u03b1) (y : MulOpposite.{u1} \u03b1), Eq.{succ u1} \u03b1 (MulOpposite.unop.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (MulOpposite.{u1} \u03b1) (MulOpposite.{u1} \u03b1) (MulOpposite.{u1} \u03b1) (instHDiv.{u1} (MulOpposite.{u1} \u03b1) (DivInvMonoid.toHasDiv.{u1} (MulOpposite.{u1} \u03b1) (MulOpposite.divInvMonoid.{u1} \u03b1 _inst_1))) x y)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 _inst_1)))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 _inst_1) (MulOpposite.unop.{u1} \u03b1 y)) (MulOpposite.unop.{u1} \u03b1 x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} \u03b1] (x : MulOpposite.{u1} \u03b1) (y : MulOpposite.{u1} \u03b1), Eq.{succ u1} \u03b1 (MulOpposite.unop.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} (MulOpposite.{u1} \u03b1) (MulOpposite.{u1} \u03b1) (MulOpposite.{u1} \u03b1) (instHDiv.{u1} (MulOpposite.{u1} \u03b1) (DivInvMonoid.toDiv.{u1} (MulOpposite.{u1} \u03b1) (MulOpposite.divInvMonoid.{u1} \u03b1 _inst_1))) x y)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 _inst_1)))) (Inv.inv.{u1} \u03b1 (DivInvMonoid.toInv.{u1} \u03b1 _inst_1) (MulOpposite.unop.{u1} \u03b1 y)) (MulOpposite.unop.{u1} \u03b1 x))\nCase conversion may be inaccurate. Consider using '#align mul_opposite.unop_div MulOpposite.unop_div\u2093'. -/\n@[simp, to_additive]\ntheorem unop_div [DivInvMonoid \u03b1] (x y : \u03b1\u1d50\u1d52\u1d56) : unop (x / y) = (unop y)\u207b\u00b9 * 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 {\u03b1 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (MulOpposite.{u1} \u03b1) (MulOpposite.op.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 _inst_1)) x y)) (HMul.hMul.{u1, u1, u1} (MulOpposite.{u1} \u03b1) (MulOpposite.{u1} \u03b1) (MulOpposite.{u1} \u03b1) (instHMul.{u1} (MulOpposite.{u1} \u03b1) (MulOpposite.hasMul.{u1} \u03b1 (MulOneClass.toHasMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 _inst_1))))) (Inv.inv.{u1} (MulOpposite.{u1} \u03b1) (MulOpposite.hasInv.{u1} \u03b1 (DivInvMonoid.toHasInv.{u1} \u03b1 _inst_1)) (MulOpposite.op.{u1} \u03b1 y)) (MulOpposite.op.{u1} \u03b1 x))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : DivInvMonoid.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Eq.{succ u1} (MulOpposite.{u1} \u03b1) (MulOpposite.op.{u1} \u03b1 (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toDiv.{u1} \u03b1 _inst_1)) x y)) (HMul.hMul.{u1, u1, u1} (MulOpposite.{u1} \u03b1) (MulOpposite.{u1} \u03b1) (MulOpposite.{u1} \u03b1) (instHMul.{u1} (MulOpposite.{u1} \u03b1) (MulOpposite.mul.{u1} \u03b1 (MulOneClass.toMul.{u1} \u03b1 (Monoid.toMulOneClass.{u1} \u03b1 (DivInvMonoid.toMonoid.{u1} \u03b1 _inst_1))))) (Inv.inv.{u1} (MulOpposite.{u1} \u03b1) (MulOpposite.inv.{u1} \u03b1 (DivInvMonoid.toInv.{u1} \u03b1 _inst_1)) (MulOpposite.op.{u1} \u03b1 y)) (MulOpposite.op.{u1} \u03b1 x))\nCase conversion may be inaccurate. Consider using '#align mul_opposite.op_div MulOpposite.op_div\u2093'. -/\n@[simp, to_additive]\ntheorem op_div [DivInvMonoid \u03b1] (x y : \u03b1) : op (x / y) = (op y)\u207b\u00b9 * 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 \u03b1] {a x y : \u03b1} : SemiconjBy (op a) (op y) (op x) \u2194 SemiconjBy a x y := by\n  simp only [SemiconjBy, \u2190 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 \u03b1] {a x y : \u03b1\u1d50\u1d52\u1d56} :\n    SemiconjBy (unop a) (unop y) (unop x) \u2194 SemiconjBy a x y := by\n  conv_rhs => rw [\u2190 op_unop a, \u2190 op_unop x, \u2190 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 \u03b1] {a x y : \u03b1} (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 \u03b1] {a x y : \u03b1\u1d50\u1d52\u1d56} (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 \u03b1] {x y : \u03b1} (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 \u03b1] {x y : \u03b1\u1d50\u1d52\u1d56} (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 \u03b1] {x y : \u03b1} : Commute (op x) (op y) \u2194 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 \u03b1] {x y : \u03b1\u1d50\u1d52\u1d56} : Commute (unop x) (unop y) \u2194 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 \u03b1] : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56 :=\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 \u03b1] : (opAddEquiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).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 `\u03b1\u1d43\u1d52\u1d56`\n-/\n\n\nnamespace AddOpposite\n\ninstance [Semigroup \u03b1] : Semigroup \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.Semigroup _ fun x y => rfl\n\ninstance [LeftCancelSemigroup \u03b1] : LeftCancelSemigroup \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.LeftCancelSemigroup _ fun x y => rfl\n\ninstance [RightCancelSemigroup \u03b1] : RightCancelSemigroup \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.RightCancelSemigroup _ fun x y => rfl\n\ninstance [CommSemigroup \u03b1] : CommSemigroup \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.CommSemigroup _ fun x y => rfl\n\ninstance [MulOneClass \u03b1] : MulOneClass \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.MulOneClass _ rfl fun x y => rfl\n\ninstance {\u03b2} [Pow \u03b1 \u03b2] : Pow \u03b1\u1d43\u1d52\u1d56 \u03b2 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 (\u03b1 : Type.{u1}) {\u03b2 : Type.{u2}} [_inst_1 : Pow.{u1, u2} \u03b1 \u03b2] (a : \u03b1) (b : \u03b2), Eq.{succ u1} (AddOpposite.{u1} \u03b1) (AddOpposite.op.{u1} \u03b1 (HPow.hPow.{u1, u2, u1} \u03b1 \u03b2 \u03b1 (instHPow.{u1, u2} \u03b1 \u03b2 _inst_1) a b)) (HPow.hPow.{u1, u2, u1} (AddOpposite.{u1} \u03b1) \u03b2 (AddOpposite.{u1} \u03b1) (instHPow.{u1, u2} (AddOpposite.{u1} \u03b1) \u03b2 (AddOpposite.hasPow.{u1, u2} \u03b1 \u03b2 _inst_1)) (AddOpposite.op.{u1} \u03b1 a) b)\nbut is expected to have type\n  forall (\u03b1 : Type.{u2}) {\u03b2 : Type.{u1}} [_inst_1 : Pow.{u2, u1} \u03b1 \u03b2] (a : \u03b1) (b : \u03b2), Eq.{succ u2} (AddOpposite.{u2} \u03b1) (AddOpposite.op.{u2} \u03b1 (HPow.hPow.{u2, u1, u2} \u03b1 \u03b2 \u03b1 (instHPow.{u2, u1} \u03b1 \u03b2 _inst_1) a b)) (HPow.hPow.{u2, u1, u2} (AddOpposite.{u2} \u03b1) \u03b2 (AddOpposite.{u2} \u03b1) (instHPow.{u2, u1} (AddOpposite.{u2} \u03b1) \u03b2 (AddOpposite.pow.{u2, u1} \u03b1 \u03b2 _inst_1)) (AddOpposite.op.{u2} \u03b1 a) b)\nCase conversion may be inaccurate. Consider using '#align add_opposite.op_pow AddOpposite.op_pow\u2093'. -/\n@[simp]\ntheorem op_pow {\u03b2} [Pow \u03b1 \u03b2] (a : \u03b1) (b : \u03b2) : 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 (\u03b1 : Type.{u1}) {\u03b2 : Type.{u2}} [_inst_1 : Pow.{u1, u2} \u03b1 \u03b2] (a : AddOpposite.{u1} \u03b1) (b : \u03b2), Eq.{succ u1} \u03b1 (AddOpposite.unop.{u1} \u03b1 (HPow.hPow.{u1, u2, u1} (AddOpposite.{u1} \u03b1) \u03b2 (AddOpposite.{u1} \u03b1) (instHPow.{u1, u2} (AddOpposite.{u1} \u03b1) \u03b2 (AddOpposite.hasPow.{u1, u2} \u03b1 \u03b2 _inst_1)) a b)) (HPow.hPow.{u1, u2, u1} \u03b1 \u03b2 \u03b1 (instHPow.{u1, u2} \u03b1 \u03b2 _inst_1) (AddOpposite.unop.{u1} \u03b1 a) b)\nbut is expected to have type\n  forall (\u03b1 : Type.{u2}) {\u03b2 : Type.{u1}} [_inst_1 : Pow.{u2, u1} \u03b1 \u03b2] (a : AddOpposite.{u2} \u03b1) (b : \u03b2), Eq.{succ u2} \u03b1 (AddOpposite.unop.{u2} \u03b1 (HPow.hPow.{u2, u1, u2} (AddOpposite.{u2} \u03b1) \u03b2 (AddOpposite.{u2} \u03b1) (instHPow.{u2, u1} (AddOpposite.{u2} \u03b1) \u03b2 (AddOpposite.pow.{u2, u1} \u03b1 \u03b2 _inst_1)) a b)) (HPow.hPow.{u2, u1, u2} \u03b1 \u03b2 \u03b1 (instHPow.{u2, u1} \u03b1 \u03b2 _inst_1) (AddOpposite.unop.{u2} \u03b1 a) b)\nCase conversion may be inaccurate. Consider using '#align add_opposite.unop_pow AddOpposite.unop_pow\u2093'. -/\n@[simp]\ntheorem unop_pow {\u03b2} [Pow \u03b1 \u03b2] (a : \u03b1\u1d43\u1d52\u1d56) (b : \u03b2) : unop (a ^ b) = unop a ^ b :=\n  rfl\n#align add_opposite.unop_pow AddOpposite.unop_pow\n\ninstance [Monoid \u03b1] : Monoid \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.Monoid _ rfl (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [CommMonoid \u03b1] : CommMonoid \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.CommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [DivInvMonoid \u03b1] : DivInvMonoid \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.DivInvMonoid _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl)\n    (fun _ _ => rfl) fun _ _ => rfl\n\ninstance [Group \u03b1] : Group \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.Group _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    fun _ _ => rfl\n\ninstance [CommGroup \u03b1] : CommGroup \u03b1\u1d43\u1d52\u1d56 :=\n  unop_injective.CommGroup _ rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)\n    fun _ _ => rfl\n\n-- NOTE: `add_monoid_with_one \u03b1 \u2192 add_monoid_with_one \u03b1\u1d43\u1d52\u1d56` does not hold\ninstance [AddCommMonoidWithOne \u03b1] : AddCommMonoidWithOne \u03b1\u1d43\u1d52\u1d56 :=\n  { AddOpposite.addCommMonoid \u03b1, AddOpposite.hasOne,\n    AddOpposite.hasNatCast\n      _ with\n    natCast_zero := show op ((0 : \u2115) : \u03b1) = 0 by rw [Nat.cast_zero, op_zero]\n    natCast_succ := show \u2200 n, op ((n + 1 : \u2115) : \u03b1) = op (n : \u2115) + 1 by simp [add_comm] }\n\ninstance [AddCommGroupWithOne \u03b1] : AddCommGroupWithOne \u03b1\u1d43\u1d52\u1d56 :=\n  { AddOpposite.addCommMonoidWithOne _, AddOpposite.addCommGroup \u03b1,\n    AddOpposite.hasIntCast\n      \u03b1 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 {\u03b1}\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 \u03b1] : \u03b1 \u2243* \u03b1\u1d43\u1d52\u1d56 :=\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 \u03b1] : (opMulEquiv : \u03b1 \u2243* \u03b1\u1d43\u1d52\u1d56).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'\u2093'. -/\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 \u2243* G\u1d50\u1d52\u1d56 :=\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 \u2192\u2099* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism to `N\u1d50\u1d52\u1d56`. -/\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\u1d43\u1d52\u1d56`.\",\n  simps (config := { fullyApplied := false })]\ndef MulHom.toOpposite {M N : Type _} [Mul M] [Mul N] (f : M \u2192\u2099* N)\n    (hf : \u2200 x y, Commute (f x) (f y)) : M \u2192\u2099* N\u1d50\u1d52\u1d56\n    where\n  toFun := MulOpposite.op \u2218 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 \u2192\u2099* N` such that `f x` commutes with `f y` for all `x, y`\ndefines a semigroup homomorphism from `M\u1d50\u1d52\u1d56`. -/\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\u1d43\u1d52\u1d56`.\",\n  simps (config := { fullyApplied := false })]\ndef MulHom.fromOpposite {M N : Type _} [Mul M] [Mul N] (f : M \u2192\u2099* N)\n    (hf : \u2200 x y, Commute (f x) (f y)) : M\u1d50\u1d52\u1d56 \u2192\u2099* N\n    where\n  toFun := f \u2218 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\u2093'. -/\n/-- A monoid homomorphism `f : M \u2192* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism to `N\u1d50\u1d52\u1d56`. -/\n@[to_additive\n      \"An additive monoid homomorphism `f : M \u2192+ N` such that `f x` additively commutes\\nwith `f y` for all `x, y` defines an additive monoid homomorphism to `S\u1d43\u1d52\u1d56`.\",\n  simps (config := { fullyApplied := false })]\ndef MonoidHom.toOpposite {M N : Type _} [MulOneClass M] [MulOneClass N] (f : M \u2192* N)\n    (hf : \u2200 x y, Commute (f x) (f y)) : M \u2192* N\u1d50\u1d52\u1d56\n    where\n  toFun := MulOpposite.op \u2218 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\u2093'. -/\n/-- A monoid homomorphism `f : M \u2192* N` such that `f x` commutes with `f y` for all `x, y` defines\na monoid homomorphism from `M\u1d50\u1d52\u1d56`. -/\n@[to_additive\n      \"An additive monoid homomorphism `f : M \u2192+ N` such that `f x` additively commutes\\nwith `f y` for all `x`, `y` defines an additive monoid homomorphism from `M\u1d43\u1d52\u1d56`.\",\n  simps (config := { fullyApplied := false })]\ndef MonoidHom.fromOpposite {M N : Type _} [MulOneClass M] [MulOneClass N] (f : M \u2192* N)\n    (hf : \u2200 x y, Commute (f x) (f y)) : M\u1d50\u1d52\u1d56 \u2192* N\n    where\n  toFun := f \u2218 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\u2093'. -/\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\u1d50\u1d52\u1d56\u02e3 \u2243* M\u02e3\u1d50\u1d52\u1d56\n    where\n  toFun u := op \u27e8unop u, unop \u2191u\u207b\u00b9, op_injective u.4, op_injective u.3\u27e9\n  invFun := MulOpposite.rec' fun u => \u27e8op \u2191u, op \u2191u\u207b\u00b9, unop_injective <| u.4, unop_injective u.3\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem Units.coe_unop_opEquiv {M} [Monoid M] (u : M\u1d50\u1d52\u1d56\u02e3) :\n    ((Units.opEquiv u).unop : M) = unop (u : M\u1d50\u1d52\u1d56) :=\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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem Units.coe_opEquiv_symm {M} [Monoid M] (u : M\u02e3\u1d50\u1d52\u1d56) :\n    (Units.opEquiv.symm u : M\u1d50\u1d52\u1d56) = 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 \u2192\u2099* N` can equivalently be viewed as a semigroup homomorphism\n`M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-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\u1d43\u1d52\u1d56 N\u1d43\u1d52\u1d56`. This is the action of the (fully faithful)\\n`\u1d43\u1d52\u1d56`-functor on morphisms.\",\n  simps]\ndef MulHom.op {M N} [Mul M] [Mul N] : (M \u2192\u2099* N) \u2243 (M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56)\n    where\n  toFun f :=\n    { toFun := op \u2218 f \u2218 unop\n      map_mul' := fun x y => unop_injective (f.map_mul y.unop x.unop) }\n  invFun f :=\n    { toFun := unop \u2218 f \u2218 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\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56`. Inverse to `mul_hom.op`. -/\n@[simp,\n  to_additive\n      \"The 'unopposite' of an additive semigroup homomorphism `M\u1d43\u1d52\u1d56 \u2192\u2099+ N\u1d43\u1d52\u1d56`. Inverse\\nto `add_hom.op`.\"]\ndef MulHom.unop {M N} [Mul M] [Mul N] : (M\u1d50\u1d52\u1d56 \u2192\u2099* N\u1d50\u1d52\u1d56) \u2243 (M \u2192\u2099* 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\u1d50\u1d52\u1d56 N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on\nmorphisms. -/\n@[simps]\ndef AddHom.mulOp {M N} [Add M] [Add N] : AddHom M N \u2243 AddHom M\u1d50\u1d52\u1d56 N\u1d50\u1d52\u1d56\n    where\n  toFun f :=\n    { toFun := op \u2218 f \u2218 unop\n      map_add' := fun x y => unop_injective (f.map_add x.unop y.unop) }\n  invFun f :=\n    { toFun := unop \u2218 f \u2218 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 `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56`. Inverse to\n`add_hom.mul_op`. -/\n@[simp]\ndef AddHom.mulUnop {\u03b1 \u03b2} [Add \u03b1] [Add \u03b2] : AddHom \u03b1\u1d50\u1d52\u1d56 \u03b2\u1d50\u1d52\u1d56 \u2243 AddHom \u03b1 \u03b2 :=\n  AddHom.mulOp.symm\n#align add_hom.mul_unop AddHom.mulUnop\n-/\n\n#print MonoidHom.op /-\n/-- A monoid homomorphism `M \u2192* N` can equivalently be viewed as a monoid homomorphism\n`M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on morphisms. -/\n@[to_additive\n      \"An additive monoid homomorphism `M \u2192+ N` can equivalently be viewed as an\\nadditive monoid homomorphism `M\u1d43\u1d52\u1d56 \u2192+ N\u1d43\u1d52\u1d56`. This is the action of the (fully faithful)\\n`\u1d43\u1d52\u1d56`-functor on morphisms.\",\n  simps]\ndef MonoidHom.op {M N} [MulOneClass M] [MulOneClass N] : (M \u2192* N) \u2243 (M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56)\n    where\n  toFun f :=\n    { toFun := op \u2218 f \u2218 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 \u2218 f \u2218 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\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56`. Inverse to `monoid_hom.op`. -/\n@[simp,\n  to_additive\n      \"The 'unopposite' of an additive monoid homomorphism `M\u1d43\u1d52\u1d56 \u2192+ N\u1d43\u1d52\u1d56`. Inverse to\\n`add_monoid_hom.op`.\"]\ndef MonoidHom.unop {M N} [MulOneClass M] [MulOneClass N] : (M\u1d50\u1d52\u1d56 \u2192* N\u1d50\u1d52\u1d56) \u2243 (M \u2192* 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 \u2192+ N` can equivalently be viewed as an additive homomorphism\n`M\u1d50\u1d52\u1d56 \u2192+ N\u1d50\u1d52\u1d56`. This is the action of the (fully faithful) `\u1d50\u1d52\u1d56`-functor on morphisms. -/\n@[simps]\ndef AddMonoidHom.mulOp {M N} [AddZeroClass M] [AddZeroClass N] : (M \u2192+ N) \u2243 (M\u1d50\u1d52\u1d56 \u2192+ N\u1d50\u1d52\u1d56)\n    where\n  toFun f :=\n    { toFun := op \u2218 f \u2218 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 \u2218 f \u2218 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 `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56`. Inverse to\n`add_monoid_hom.mul_op`. -/\n@[simp]\ndef AddMonoidHom.mulUnop {\u03b1 \u03b2} [AddZeroClass \u03b1] [AddZeroClass \u03b2] : (\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2\u1d50\u1d52\u1d56) \u2243 (\u03b1 \u2192+ \u03b2) :=\n  AddMonoidHom.mulOp.symm\n#align add_monoid_hom.mul_unop AddMonoidHom.mulUnop\n-/\n\n#print AddEquiv.mulOp /-\n/-- A iso `\u03b1 \u2243+ \u03b2` can equivalently be viewed as an iso `\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56`. -/\n@[simps]\ndef AddEquiv.mulOp {\u03b1 \u03b2} [Add \u03b1] [Add \u03b2] : \u03b1 \u2243+ \u03b2 \u2243 (\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56)\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 `\u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56`. Inverse to `add_equiv.mul_op`. -/\n@[simp]\ndef AddEquiv.mulUnop {\u03b1 \u03b2} [Add \u03b1] [Add \u03b2] : \u03b1\u1d50\u1d52\u1d56 \u2243+ \u03b2\u1d50\u1d52\u1d56 \u2243 (\u03b1 \u2243+ \u03b2) :=\n  AddEquiv.mulOp.symm\n#align add_equiv.mul_unop AddEquiv.mulUnop\n-/\n\n#print MulEquiv.op /-\n/-- A iso `\u03b1 \u2243* \u03b2` can equivalently be viewed as an iso `\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56`. -/\n@[to_additive \"A iso `\u03b1 \u2243+ \u03b2` can equivalently be viewed as an iso `\u03b1\u1d43\u1d52\u1d56 \u2243+ \u03b2\u1d43\u1d52\u1d56`.\", simps]\ndef MulEquiv.op {\u03b1 \u03b2} [Mul \u03b1] [Mul \u03b2] : \u03b1 \u2243* \u03b2 \u2243 (\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56)\n    where\n  toFun f :=\n    { toFun := op \u2218 f \u2218 unop\n      invFun := op \u2218 f.symm \u2218 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 \u2218 f \u2218 op\n      invFun := unop \u2218 f.symm \u2218 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 `\u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56`. Inverse to `mul_equiv.op`. -/\n@[simp, to_additive \"The 'unopposite' of an iso `\u03b1\u1d43\u1d52\u1d56 \u2243+ \u03b2\u1d43\u1d52\u1d56`. Inverse to `add_equiv.op`.\"]\ndef MulEquiv.unop {\u03b1 \u03b2} [Mul \u03b1] [Mul \u03b2] : \u03b1\u1d50\u1d52\u1d56 \u2243* \u03b2\u1d50\u1d52\u1d56 \u2243 (\u03b1 \u2243* \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : AddZeroClass.{u1} \u03b1] [_inst_2 : AddZeroClass.{u2} \u03b2] (f : AddMonoidHom.{u1, u2} (MulOpposite.{u1} \u03b1) \u03b2 (MulOpposite.addZeroClass.{u1} \u03b1 _inst_1) _inst_2) (g : AddMonoidHom.{u1, u2} (MulOpposite.{u1} \u03b1) \u03b2 (MulOpposite.addZeroClass.{u1} \u03b1 _inst_1) _inst_2), (Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (AddMonoidHom.comp.{u1, u1, u2} \u03b1 (MulOpposite.{u1} \u03b1) \u03b2 _inst_1 (MulOpposite.addZeroClass.{u1} \u03b1 _inst_1) _inst_2 f (AddEquiv.toAddMonoidHom.{u1, u1} \u03b1 (MulOpposite.{u1} \u03b1) _inst_1 (MulOpposite.addZeroClass.{u1} \u03b1 _inst_1) (MulOpposite.opAddEquiv.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 _inst_1)))) (AddMonoidHom.comp.{u1, u1, u2} \u03b1 (MulOpposite.{u1} \u03b1) \u03b2 _inst_1 (MulOpposite.addZeroClass.{u1} \u03b1 _inst_1) _inst_2 g (AddEquiv.toAddMonoidHom.{u1, u1} \u03b1 (MulOpposite.{u1} \u03b1) _inst_1 (MulOpposite.addZeroClass.{u1} \u03b1 _inst_1) (MulOpposite.opAddEquiv.{u1} \u03b1 (AddZeroClass.toHasAdd.{u1} \u03b1 _inst_1))))) -> (Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u1, u2} (MulOpposite.{u1} \u03b1) \u03b2 (MulOpposite.addZeroClass.{u1} \u03b1 _inst_1) _inst_2) f g)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : AddZeroClass.{u2} \u03b1] [_inst_2 : AddZeroClass.{u1} \u03b2] (f : AddMonoidHom.{u2, u1} (MulOpposite.{u2} \u03b1) \u03b2 (MulOpposite.addZeroClass.{u2} \u03b1 _inst_1) _inst_2) (g : AddMonoidHom.{u2, u1} (MulOpposite.{u2} \u03b1) \u03b2 (MulOpposite.addZeroClass.{u2} \u03b1 _inst_1) _inst_2), (Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2) (AddMonoidHom.comp.{u2, u2, u1} \u03b1 (MulOpposite.{u2} \u03b1) \u03b2 _inst_1 (MulOpposite.addZeroClass.{u2} \u03b1 _inst_1) _inst_2 f (AddEquiv.toAddMonoidHom.{u2, u2} \u03b1 (MulOpposite.{u2} \u03b1) _inst_1 (MulOpposite.addZeroClass.{u2} \u03b1 _inst_1) (MulOpposite.opAddEquiv.{u2} \u03b1 (AddZeroClass.toAdd.{u2} \u03b1 _inst_1)))) (AddMonoidHom.comp.{u2, u2, u1} \u03b1 (MulOpposite.{u2} \u03b1) \u03b2 _inst_1 (MulOpposite.addZeroClass.{u2} \u03b1 _inst_1) _inst_2 g (AddEquiv.toAddMonoidHom.{u2, u2} \u03b1 (MulOpposite.{u2} \u03b1) _inst_1 (MulOpposite.addZeroClass.{u2} \u03b1 _inst_1) (MulOpposite.opAddEquiv.{u2} \u03b1 (AddZeroClass.toAdd.{u2} \u03b1 _inst_1))))) -> (Eq.{max (succ u2) (succ u1)} (AddMonoidHom.{u2, u1} (MulOpposite.{u2} \u03b1) \u03b2 (MulOpposite.addZeroClass.{u2} \u03b1 _inst_1) _inst_2) f g)\nCase conversion may be inaccurate. Consider using '#align add_monoid_hom.mul_op_ext AddMonoidHom.mul_op_ext\u2093'. -/\n/-- This ext lemma change equalities on `\u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2` to equalities on `\u03b1 \u2192+ \u03b2`.\nThis is useful because there are often ext lemmas for specific `\u03b1`s that will apply\nto an equality of `\u03b1 \u2192+ \u03b2` such as `finsupp.add_hom_ext'`. -/\n@[ext]\ntheorem AddMonoidHom.mul_op_ext {\u03b1 \u03b2} [AddZeroClass \u03b1] [AddZeroClass \u03b2] (f g : \u03b1\u1d50\u1d52\u1d56 \u2192+ \u03b2)\n    (h :\n      f.comp (opAddEquiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).toAddMonoidHom =\n        g.comp (opAddEquiv : \u03b1 \u2243+ \u03b1\u1d50\u1d52\u1d56).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 : \u22a4_ C \u27f6 Y) (f : U \u27f6 X) (\u03c7 : X \u27f6 Y)  :=\n(comm : f \u226b \u03c7 = (terminal.from U) \u226b truth)\n(is_pb : is_limit (pullback_cone.mk _ _ comm))\n\nattribute [reassoc] classifying_pullback.comm\n\nabbreviation classifying {\u03a9 U X : C} (truth : \u22a4_ C \u27f6 \u03a9) (f : U \u27f6 X) (\u03c7 : X \u27f6 \u03a9) := classifying_pullback truth f \u03c7 \n\nstructure is_subobject_classifier {\u03a9 : C} (truth : \u22a4_ C \u27f6 \u03a9) :=\n(classifier_of : \u2200 {U X} (f : U \u27f6 X) [mono.{v} f], X \u27f6 \u03a9)\n(classifies' : \u2200 {U X} (f : U \u27f6 X) [mono f], classifying truth f (classifier_of f))\n(uniquely' : \u2200 {U X} (f : U \u27f6 X) [mono f] (\u03c7\u2081 : X \u27f6 \u03a9), classifying truth f \u03c7\u2081 \u2192 classifier_of f = \u03c7\u2081)\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(\u03a9 : C)\n(truth : \u22a4_ C \u27f6 \u03a9)\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 \u03a9 : C := has_subobject_classifier.\u03a9.{v}\n/-- Convenience notation for the classifier given the typeclass `has_subobject_classifier`. -/\ndef truth : \u22a4_ C \u27f6 \u03a9 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 \u27f6 X) [mono f] : X \u27f6 \u03a9 C :=\n(subobj_classifier_is_subobj_classifier C).classifier_of f\ndef classifies {U X : C} (f : U \u27f6 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 \u27f6 X) [mono f] (\u03c7\u2081 : X \u27f6 \u03a9 C) (h\u03c7 : classifying (truth C) f \u03c7\u2081) : classifier_of f = \u03c7\u2081 :=\n(subobj_classifier_is_subobj_classifier C).uniquely' f \u03c7\u2081 h\u03c7\n \nlemma classifier.comm {U X : C} (f : U \u27f6 X) [mono f] : \n  f \u226b (classifier_of f) = terminal.from _ \u226b truth C :=\nclassifying_pullback.comm (classifies _)\n\nlemma classifier.is_pb {U X : C} (f : U \u27f6 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 \u03c3 : X \u2192 \u03a9 then we have the following pullback, we call { \u03c3 } the canonical subobject\n  { \u03c3 } -> \u22a4\n    |      |\n    X ---> \u03a9 \n-/\n\nvariable {C}\nnotation `s{` \u03c3 `}s` := pullback \u03c3 (classifier.truth _)\n\n\n\nopen classifier\n\n\n/- true_X from McLane -/\nabbreviation lift_truth (X : C) : X \u27f6 \u03a9 C := terminal.from X \u226b truth C\n\nabbreviation canonical_incl {X : C} [has_pullbacks C] (\u03c3 : X \u27f6 \u03a9 C) : s{ \u03c3 }s \u27f6 X := pullback.fst\n\ndef canonical_incl_of_mono {X Y : C} [has_pullbacks C] (m : X \u27f6 Y) [mono m] : \n  s{ classifier_of m }s \u27f6 Y :=\ncanonical_incl (classifier_of m)\n\nvariables [has_pullbacks C] (\u03c3 : X \u27f6 \u03a9 C)\n\ninstance canonical_incl_mono : mono (canonical_incl \u03c3) := pullback.fst_of_mono\n\nlemma canonical_incl_comm : canonical_incl \u03c3 \u226b \u03c3 = terminal.from s{ \u03c3 }s \u226b truth C :=\nbegin\n  convert pullback.condition\nend\n\nabbreviation canonical_sub : subobject X := subobject.mk (canonical_incl \u03c3)\n\ndef canonical_sub_iso_canonical : \u2191(canonical_sub \u03c3) \u2245 s{ \u03c3 }s :=\nbegin\n  apply subobject.iso_of_eq_mk _ (canonical_incl \u03c3), refl\nend\n\ndef canonical_iso_canonical_sub : s{ \u03c3 }s \u2245 \u2191(canonical_sub \u03c3) := \n(canonical_sub_iso_canonical \u03c3).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 \u03c3 (truth C) :=\npullback_cone.mk (canonical_sub \u03c3).arrow (terminal.from _) \n(by { rw [\u2190subobject.underlying_iso_hom_comp_eq_mk, assoc, \n          canonical_incl_comm, \u2190assoc, terminal.comp_from] })\n\nlemma pb_cone_of_canonical_sub_arrow_X : \n  (pb_cone_of_canonical_sub_arrow \u03c3).X = \u2191(canonical_sub \u03c3) := rfl\n\nlemma is_pullback_canonical_arrow :\n  is_limit (pb_cone_of_canonical_sub_arrow \u03c3) :=\nbegin\n  apply is_limit.of_iso_limit (pullback_is_pullback \u03c3 (truth C)),\n  symmetry,\n  refine pullback_cone.ext (subobject.underlying_iso (canonical_incl \u03c3)) _ \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 \u03c3) (terminal.from _) (canonical_incl_comm \u03c3)) :=\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 \u03c3) \u03c3 :=\n{ comm := canonical_incl_comm \u03c3,\n  is_pb := canonical_is_pullback \u03c3 }\n \n@[simp] lemma classifier_of_canonical_incl_eq_self : classifier_of (canonical_incl \u03c3) = \u03c3 :=\nuniquely _ _ (canonical_incl_classifies \u03c3)\n\n\n\n/- The truth classifies the identity -/\nvariable (C)\n\nlemma terminal_from_self_is_id : terminal.from (\u22a4_ C) = \ud835\udfd9 (\u22a4_ C) := \nis_terminal.from_self terminal_is_terminal\n\nlemma truth_classifies_id : classifying (truth C) (\ud835\udfd9 (\u22a4_ C)) (truth C) := \n{ comm := by rw (terminal_from_self_is_id ),\n  is_pb := \n  begin\n    conv in (terminal.from (\u22a4_ 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 : \ud835\udfd9 (\u22a4_ C) \u226b (truth C) = \ud835\udfd9 (\u22a4_ C) \u226b (truth C) := by simp\nlemma truth_classifies_id.is_pb : \n  is_limit (pullback_cone.mk (\ud835\udfd9 (\u22a4_ C)) (\ud835\udfd9 (\u22a4_ C)) (truth_classifies_id.comm C)) :=\nbegin \n  have h := (truth_classifies_id C).is_pb,\n  conv at h in (terminal.from (\u22a4_ 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 {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] : filter.tendsto floor filter.at_top filter.at_top := sorry\n\ntheorem tendsto_floor_at_bot {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] : filter.tendsto floor filter.at_bot filter.at_bot :=\n  monotone.tendsto_at_bot_at_bot (fun (a b : \u03b1) (hab : a \u2264 b) => floor_mono hab)\n    fun (b : \u2124) => Exists.intro (\u2191b) (eq.mpr (id (Eq._oldrec (Eq.refl (floor \u2191b \u2264 b)) (floor_coe b))) (le_refl b))\n\ntheorem tendsto_ceil_at_top {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] : 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 {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] : 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 {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] (n : \u2124) : continuous_on (fun (x : \u03b1) => \u2191(floor x)) (set.Ico (\u2191n) (\u2191n + 1)) :=\n  iff.mpr (continuous_on_congr (floor_eq_on_Ico' n)) continuous_on_const\n\ntheorem continuous_on_ceil {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] (n : \u2124) : continuous_on (fun (x : \u03b1) => \u2191(ceil x)) (set.Ioc (\u2191n - 1) \u2191n) :=\n  iff.mpr (continuous_on_congr (ceil_eq_on_Ioc' n)) continuous_on_const\n\ntheorem tendsto_floor_right' {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] (n : \u2124) : filter.tendsto (fun (x : \u03b1) => \u2191(floor x)) (nhds_within (\u2191n) (set.Ici \u2191n)) (nhds \u2191n) := sorry\n\ntheorem tendsto_ceil_left' {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] (n : \u2124) : filter.tendsto (fun (x : \u03b1) => \u2191(ceil x)) (nhds_within (\u2191n) (set.Iic \u2191n)) (nhds \u2191n) := sorry\n\ntheorem tendsto_floor_right {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] (n : \u2124) : filter.tendsto (fun (x : \u03b1) => \u2191(floor x)) (nhds_within (\u2191n) (set.Ici \u2191n)) (nhds_within (\u2191n) (set.Ici \u2191n)) := sorry\n\ntheorem tendsto_ceil_left {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] (n : \u2124) : filter.tendsto (fun (x : \u03b1) => \u2191(ceil x)) (nhds_within (\u2191n) (set.Iic \u2191n)) (nhds_within (\u2191n) (set.Iic \u2191n)) := sorry\n\ntheorem tendsto_floor_left {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] (n : \u2124) : filter.tendsto (fun (x : \u03b1) => \u2191(floor x)) (nhds_within (\u2191n) (set.Iio \u2191n)) (nhds_within (\u2191n - 1) (set.Iic (\u2191n - 1))) := sorry\n\ntheorem tendsto_ceil_right {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] (n : \u2124) : filter.tendsto (fun (x : \u03b1) => \u2191(ceil x)) (nhds_within (\u2191n) (set.Ioi \u2191n)) (nhds_within (\u2191n + 1) (set.Ici (\u2191n + 1))) := sorry\n\ntheorem tendsto_floor_left' {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] (n : \u2124) : filter.tendsto (fun (x : \u03b1) => \u2191(floor x)) (nhds_within (\u2191n) (set.Iio \u2191n)) (nhds (\u2191n - 1)) := sorry\n\ntheorem tendsto_ceil_right' {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] (n : \u2124) : filter.tendsto (fun (x : \u03b1) => \u2191(ceil x)) (nhds_within (\u2191n) (set.Ioi \u2191n)) (nhds (\u2191n + 1)) := sorry\n\ntheorem continuous_on_fract {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [topological_add_group \u03b1] (n : \u2124) : continuous_on fract (set.Ico (\u2191n) (\u2191n + 1)) :=\n  continuous_on.sub continuous_on_id (continuous_on_floor n)\n\ntheorem tendsto_fract_left' {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] [topological_add_group \u03b1] (n : \u2124) : filter.tendsto fract (nhds_within (\u2191n) (set.Iio \u2191n)) (nhds 1) := sorry\n\ntheorem tendsto_fract_left {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] [topological_add_group \u03b1] (n : \u2124) : filter.tendsto fract (nhds_within (\u2191n) (set.Iio \u2191n)) (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' {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] [topological_add_group \u03b1] (n : \u2124) : filter.tendsto fract (nhds_within (\u2191n) (set.Ici \u2191n)) (nhds 0) := sorry\n\ntheorem tendsto_fract_right {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] [order_closed_topology \u03b1] [topological_add_group \u03b1] (n : \u2124) : filter.tendsto fract (nhds_within (\u2191n) (set.Ici \u2191n)) (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' {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] {\u03b2 : Type u_2} {\u03b3 : Type u_3} [order_topology \u03b1] [topological_add_group \u03b1] [topological_space \u03b2] [topological_space \u03b3] {f : \u03b2 \u2192 \u03b1 \u2192 \u03b3} (h : continuous_on (function.uncurry f) (set.prod set.univ (set.Icc 0 1))) (hf : \u2200 (s : \u03b2), f s 0 = f s 1) : continuous fun (st : \u03b2 \u00d7 \u03b1) => f (prod.fst st) (fract (prod.snd st)) := sorry\n\ntheorem continuous_on.comp_fract {\u03b1 : Type u_1} [linear_ordered_ring \u03b1] [floor_ring \u03b1] [topological_space \u03b1] {\u03b2 : Type u_2} [order_topology \u03b1] [topological_add_group \u03b1] [topological_space \u03b2] {f : \u03b1 \u2192 \u03b2} (h : continuous_on f (set.Icc 0 1)) (hf : f 0 = f 1) : continuous (f \u2218 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) 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 testing.slim_check.functions\n! leanprover-community/mathlib commit f9c300047a57aeda7c2fe15a3ac2455eb05ec225\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\nimport Mathbin.Data.Int.Range\nimport Mathbin.Data.Finsupp.Defs\nimport Mathbin.Data.Finsupp.ToDfinsupp\nimport Mathbin.Tactic.PrettyCases\nimport Mathbin.Testing.SlimCheck.Sampleable\nimport Mathbin.Testing.SlimCheck.Testable\n\n/-!\n## `slim_check`: generators for functions\n\nThis file defines `sampleable` instances for `\u03b1 \u2192 \u03b2` functions and\n`\u2124 \u2192 \u2124` 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 : \u03b1 \u2192 \u03b1` could be generated easily instead of\n`\u2124 \u2192 \u2124` by generating a `list \u03b1`, 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 : \u2124 \u2192 \u2124` 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 `\u03b1 \u2192 \u03b1` 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\n\nuniverse u v w\n\nvariable {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Sort w}\n\nnamespace SlimCheck\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 \u21a6 f x` when `x \u2208 f` and `x \u21a6 y`\notherwise.\n\nWe use `\u03a3` to encode mappings instead of `\u00d7` because we\nrely on the association list API defined in `data.list.sigma`.\n -/\ninductive TotalFunction (\u03b1 : Type u) (\u03b2 : Type v) : Type max u v\n  | with_default : List (\u03a3_ : \u03b1, \u03b2) \u2192 \u03b2 \u2192 total_function\n#align slim_check.total_function SlimCheck.TotalFunction\n\ninstance TotalFunction.inhabited [Inhabited \u03b2] : Inhabited (TotalFunction \u03b1 \u03b2) :=\n  \u27e8TotalFunction.with_default \u2205 default\u27e9\n#align slim_check.total_function.inhabited SlimCheck.TotalFunction.inhabited\n\nnamespace TotalFunction\n\n/-- Apply a total function to an argument. -/\ndef apply [DecidableEq \u03b1] : TotalFunction \u03b1 \u03b2 \u2192 \u03b1 \u2192 \u03b2\n  | total_function.with_default m y, x => (m.dlookup x).getD y\n#align slim_check.total_function.apply SlimCheck.TotalFunction.apply\n\n/-- Implementation of `has_repr (total_function \u03b1 \u03b2)`.\n\nCreates a string for a given `finmap` and output, `x\u2080 \u21a6 y\u2080, .. x\u2099 \u21a6 y\u2099`\nfor each of the entries. The brackets are provided by the calling function.\n-/\ndef reprAux [Repr \u03b1] [Repr \u03b2] (m : List (\u03a3_ : \u03b1, \u03b2)) : String :=\n  String.join <|\n    List.qsort (fun x y => x < y)\n      (m.map fun x => s!\"{(repr <| Sigma.fst x)} \u21a6 {repr <| Sigma.snd x}, \")\n#align slim_check.total_function.repr_aux SlimCheck.TotalFunction.reprAux\n\n/-- Produce a string for a given `total_function`.\nThe output is of the form `[x\u2080 \u21a6 f x\u2080, .. x\u2099 \u21a6 f x\u2099, _ \u21a6 y]`.\n-/\nprotected def repr [Repr \u03b1] [Repr \u03b2] : TotalFunction \u03b1 \u03b2 \u2192 String\n  | total_function.with_default m y => s!\"[{(reprAux m)}_ \u21a6 {Repr.repr y}]\"\n#align slim_check.total_function.repr SlimCheck.TotalFunction.repr\n\ninstance (\u03b1 : Type u) (\u03b2 : Type v) [Repr \u03b1] [Repr \u03b2] : Repr (TotalFunction \u03b1 \u03b2) :=\n  \u27e8TotalFunction.repr\u27e9\n\n/-- Create a `finmap` from a list of pairs. -/\ndef List.toFinmap' (xs : List (\u03b1 \u00d7 \u03b2)) : List (\u03a3_ : \u03b1, \u03b2) :=\n  xs.map Prod.toSigma\n#align slim_check.total_function.list.to_finmap' SlimCheck.TotalFunction.List.toFinmap'\n\nsection\n\nvariable [Sampleable \u03b1] [Sampleable \u03b2]\n\n/-- Redefine `sizeof` to follow the structure of `sampleable` instances. -/\ndef Total.sizeof : TotalFunction \u03b1 \u03b2 \u2192 \u2115\n  | \u27e8m, x\u27e9 => 1 + @SizeOf.sizeOf _ Sampleable.wf m + SizeOf.sizeOf x\n#align slim_check.total_function.total.sizeof SlimCheck.TotalFunction.Total.sizeof\n\ninstance (priority := 2000) : SizeOf (TotalFunction \u03b1 \u03b2) :=\n  \u27e8Total.sizeof\u27e9\n\nvariable [DecidableEq \u03b1]\n\n/-- Shrink a total function by shrinking the lists that represent it. -/\nprotected def shrink : ShrinkFn (TotalFunction \u03b1 \u03b2)\n  | \u27e8m, x\u27e9 =>\n    (Sampleable.shrink (m, x)).map fun \u27e8\u27e8m', x'\u27e9, h\u27e9 =>\n      \u27e8\u27e8List.dedupKeys m', x'\u27e9,\n        lt_of_le_of_lt\n          (by unfold_wf <;> refine' @List.sizeOf_dedupKeys _ _ _ (@sampleable.wf _ _) _) h\u27e9\n#align slim_check.total_function.shrink SlimCheck.TotalFunction.shrink\n\nvariable [Repr \u03b1] [Repr \u03b2]\n\ninstance Pi.sampleableExt : SampleableExt (\u03b1 \u2192 \u03b2)\n    where\n  ProxyRepr := TotalFunction \u03b1 \u03b2\n  interp := TotalFunction.apply\n  sample := do\n    let xs \u2190 (Sampleable.sample (List (\u03b1 \u00d7 \u03b2)) : Gen (List (\u03b1 \u00d7 \u03b2)))\n    let \u27e8x\u27e9 \u2190 (Uliftable.up <| sample \u03b2 : Gen (ULift.{max u v} \u03b2))\n    pure <| total_function.with_default (list.to_finmap' xs) x\n  shrink := TotalFunction.shrink\n#align slim_check.total_function.pi.sampleable_ext SlimCheck.TotalFunction.Pi.sampleableExt\n\nend\n\nsection Finsupp\n\nvariable [Zero \u03b2]\n\n/-- Map a total_function to one whose default value is zero so that it represents a finsupp. -/\n@[simp]\ndef zeroDefault : TotalFunction \u03b1 \u03b2 \u2192 TotalFunction \u03b1 \u03b2\n  | with_default A y => with_default A 0\n#align slim_check.total_function.zero_default SlimCheck.TotalFunction.zeroDefault\n\nvariable [DecidableEq \u03b1] [DecidableEq \u03b2]\n\n/-- The support of a zero default `total_function`. -/\n@[simp]\ndef zeroDefaultSupp : TotalFunction \u03b1 \u03b2 \u2192 Finset \u03b1\n  | with_default A y =>\n    List.toFinset <| (A.dedupKeys.filter\u2093 fun ab => Sigma.snd ab \u2260 0).map Sigma.fst\n#align slim_check.total_function.zero_default_supp SlimCheck.TotalFunction.zeroDefaultSupp\n\n/-- Create a finitely supported function from a total function by taking the default value to\nzero. -/\ndef applyFinsupp (tf : TotalFunction \u03b1 \u03b2) : \u03b1 \u2192\u2080 \u03b2\n    where\n  support := zeroDefaultSupp tf\n  toFun := tf.zeroDefault.apply\n  mem_support_toFun := by\n    intro a\n    rcases tf with \u27e8A, y\u27e9\n    simp only [apply, zero_default_supp, List.mem_map, List.mem_filter, exists_and_right,\n      List.mem_toFinset, exists_eq_right, Sigma.exists, Ne.def, zero_default]\n    constructor\n    \u00b7 rintro \u27e8od, hval, hod\u27e9\n      have := List.mem_dlookup (List.nodupKeys_dedupKeys A) hval\n      rw [(_ : List.dlookup a A = od)]\n      \u00b7 simpa\n      \u00b7 simpa [List.dlookup_dedupKeys, WithTop.some_eq_coe]\n    \u00b7 intro h\n      use (A.lookup a).getD (0 : \u03b2)\n      rw [\u2190 List.dlookup_dedupKeys] at h\u22a2\n      simp only [h, \u2190 List.mem_dlookup_iff A.nodupkeys_dedupkeys, and_true_iff, not_false_iff,\n        Option.mem_def]\n      cases List.dlookup a A.dedupkeys\n      \u00b7 simpa using h\n      \u00b7 simp\n#align slim_check.total_function.apply_finsupp SlimCheck.TotalFunction.applyFinsupp\n\nvariable [Sampleable \u03b1] [Sampleable \u03b2]\n\ninstance Finsupp.sampleableExt [Repr \u03b1] [Repr \u03b2] : SampleableExt (\u03b1 \u2192\u2080 \u03b2)\n    where\n  ProxyRepr := TotalFunction \u03b1 \u03b2\n  interp := TotalFunction.applyFinsupp\n  sample := do\n    let xs \u2190 (Sampleable.sample (List (\u03b1 \u00d7 \u03b2)) : Gen (List (\u03b1 \u00d7 \u03b2)))\n    let \u27e8x\u27e9 \u2190 (Uliftable.up <| sample \u03b2 : Gen (ULift.{max u v} \u03b2))\n    pure <| total_function.with_default (list.to_finmap' xs) x\n  shrink := TotalFunction.shrink\n#align slim_check.total_function.finsupp.sampleable_ext SlimCheck.TotalFunction.Finsupp.sampleableExt\n\n-- TODO: support a non-constant codomain type\ninstance Dfinsupp.sampleableExt [Repr \u03b1] [Repr \u03b2] : SampleableExt (\u03a0\u2080 a : \u03b1, \u03b2)\n    where\n  ProxyRepr := TotalFunction \u03b1 \u03b2\n  interp := Finsupp.toDfinsupp \u2218 TotalFunction.applyFinsupp\n  sample := do\n    let xs \u2190 (Sampleable.sample (List (\u03b1 \u00d7 \u03b2)) : Gen (List (\u03b1 \u00d7 \u03b2)))\n    let \u27e8x\u27e9 \u2190 (Uliftable.up <| sample \u03b2 : Gen (ULift.{max u v} \u03b2))\n    pure <| total_function.with_default (list.to_finmap' xs) x\n  shrink := TotalFunction.shrink\n#align slim_check.total_function.dfinsupp.sampleable_ext SlimCheck.TotalFunction.Dfinsupp.sampleableExt\n\nend Finsupp\n\nsection SampleableExt\n\nopen SampleableExt\n\ninstance (priority := 2000) PiPred.sampleableExt [SampleableExt (\u03b1 \u2192 Bool)] :\n    SampleableExt.{u + 1} (\u03b1 \u2192 Prop)\n    where\n  ProxyRepr := ProxyRepr (\u03b1 \u2192 Bool)\n  interp m x := interp (\u03b1 \u2192 Bool) m x\n  sample := sample (\u03b1 \u2192 Bool)\n  shrink := shrink\n#align slim_check.total_function.pi_pred.sampleable_ext SlimCheck.TotalFunction.PiPred.sampleableExt\n\ninstance (priority := 2000) PiUncurry.sampleableExt [SampleableExt (\u03b1 \u00d7 \u03b2 \u2192 \u03b3)] :\n    SampleableExt.{imax (u + 1) (v + 1) w} (\u03b1 \u2192 \u03b2 \u2192 \u03b3)\n    where\n  ProxyRepr := ProxyRepr (\u03b1 \u00d7 \u03b2 \u2192 \u03b3)\n  interp m x y := interp (\u03b1 \u00d7 \u03b2 \u2192 \u03b3) m (x, y)\n  sample := sample (\u03b1 \u00d7 \u03b2 \u2192 \u03b3)\n  shrink := shrink\n#align slim_check.total_function.pi_uncurry.sampleable_ext SlimCheck.TotalFunction.PiUncurry.sampleableExt\n\nend SampleableExt\n\nend TotalFunction\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`map_to_self f` encodes `x \u21a6 f x` when `x \u2208 f` and `x \u21a6 x`,\ni.e. `x` to itself, otherwise.\n\nWe use `\u03a3` to encode mappings instead of `\u00d7` because we\nrely on the association list API defined in `data.list.sigma`.\n-/\ninductive InjectiveFunction (\u03b1 : Type u) : Type u\n  |\n  map_to_self (xs : List (\u03a3_ : \u03b1, \u03b1)) :\n    xs.map Sigma.fst ~ xs.map Sigma.snd \u2192 List.Nodup (xs.map Sigma.snd) \u2192 injective_function\n#align slim_check.injective_function SlimCheck.InjectiveFunction\n\ninstance : Inhabited (InjectiveFunction \u03b1) :=\n  \u27e8\u27e8[], List.Perm.nil, List.nodup_nil\u27e9\u27e9\n\nnamespace InjectiveFunction\n\n/-- Apply a total function to an argument. -/\ndef apply [DecidableEq \u03b1] : InjectiveFunction \u03b1 \u2192 \u03b1 \u2192 \u03b1\n  | injective_function.map_to_self m _ _, x => (m.dlookup x).getD x\n#align slim_check.injective_function.apply SlimCheck.InjectiveFunction.apply\n\n/-- Produce a string for a given `total_function`.\nThe output is of the form `[x\u2080 \u21a6 f x\u2080, .. x\u2099 \u21a6 f x\u2099, x \u21a6 x]`.\nUnlike for `total_function`, the default value is not a constant\nbut the identity function.\n-/\nprotected def repr [Repr \u03b1] : InjectiveFunction \u03b1 \u2192 String\n  | injective_function.map_to_self m _ _ => s! \"[{TotalFunction.reprAux m}x \u21a6 x]\"\n#align slim_check.injective_function.repr SlimCheck.InjectiveFunction.repr\n\ninstance (\u03b1 : Type u) [Repr \u03b1] : Repr (InjectiveFunction \u03b1) :=\n  \u27e8InjectiveFunction.repr\u27e9\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.applyId [DecidableEq \u03b1] (xs : List (\u03b1 \u00d7 \u03b1)) (x : \u03b1) : \u03b1 :=\n  ((xs.map Prod.toSigma).dlookup x).getD x\n#align slim_check.injective_function.list.apply_id SlimCheck.InjectiveFunction.List.applyId\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem List.applyId_cons [DecidableEq \u03b1] (xs : List (\u03b1 \u00d7 \u03b1)) (x y z : \u03b1) :\n    List.applyId ((y, z)::xs) x = if y = x then z else List.applyId xs x := by\n  simp only [list.apply_id, List.dlookup, eq_rec_constant, Prod.toSigma, List.map] <;> split_ifs <;>\n    rfl\n#align slim_check.injective_function.list.apply_id_cons SlimCheck.InjectiveFunction.List.applyId_cons\n\nopen Function _Root_.List\n\nopen _Root_.Prod (toSigma)\n\nopen _Root_.Nat\n\ntheorem List.applyId_zip_eq [DecidableEq \u03b1] {xs ys : List \u03b1} (h\u2080 : List.Nodup xs)\n    (h\u2081 : xs.length = ys.length) (x y : \u03b1) (i : \u2115) (h\u2082 : xs.get? i = some x) :\n    List.applyId.{u} (xs.zip ys) x = y \u2194 ys.get? i = some y :=\n  by\n  induction xs generalizing ys i\n  case nil ys i h\u2081 h\u2082 => cases h\u2082\n  case cons x' xs xs_ih ys i h\u2081 h\u2082 =>\n    cases i\n    \u00b7 injection h\u2082 with h\u2080 h\u2081\n      subst h\u2080\n      cases ys\n      \u00b7 cases h\u2081\n      \u00b7\n        simp only [list.apply_id, to_sigma, Option.getD_some, nth, lookup_cons_eq, zip_cons_cons,\n          List.map]\n    \u00b7 cases ys\n      \u00b7 cases h\u2081\n      \u00b7 cases' h\u2080 with _ _ h\u2080 h\u2081\n        simp only [nth, zip_cons_cons, list.apply_id_cons] at h\u2082\u22a2\n        rw [if_neg]\n        \u00b7 apply xs_ih <;> solve_by_elim [succ.inj]\n        \u00b7 apply h\u2080\n          apply nth_mem h\u2082\n#align slim_check.injective_function.list.apply_id_zip_eq SlimCheck.InjectiveFunction.List.applyId_zip_eq\n\n/- ./././Mathport/Syntax/Translate/Tactic/Lean3.lean:564:6: unsupported: specialize @hyp -/\ntheorem applyId_mem_iff [DecidableEq \u03b1] {xs ys : List \u03b1} (h\u2080 : List.Nodup xs) (h\u2081 : xs ~ ys)\n    (x : \u03b1) : List.applyId.{u} (xs.zip ys) x \u2208 ys \u2194 x \u2208 xs :=\n  by\n  simp only [list.apply_id]\n  cases h\u2083 : lookup x (map Prod.toSigma (xs.zip ys))\n  \u00b7 dsimp [Option.getD]\n    rw [h\u2081.mem_iff]\n  \u00b7 have h\u2082 : ys.nodup := h\u2081.nodup_iff.1 h\u2080\n    replace h\u2081 : xs.length = ys.length := h\u2081.length_eq\n    dsimp\n    induction xs generalizing ys\n    case nil ys h\u2083 h\u2082 h\u2081 => contradiction\n    case cons x' xs xs_ih ys h\u2083 h\u2082 h\u2081 =>\n      cases' ys with y ys\n      \u00b7 cases h\u2083\n      dsimp [lookup] at h\u2083; split_ifs  at h\u2083\n      \u00b7 subst x'\n        subst val\n        simp only [mem_cons_iff, true_or_iff, eq_self_iff_true]\n      \u00b7 cases' h\u2080 with _ _ h\u2080 h\u2085\n        cases' h\u2082 with _ _ h\u2082 h\u2084\n        have h\u2086 := Nat.succ.inj h\u2081\n        specialize xs_ih h\u2085 ys h\u2083 h\u2084 h\u2086\n        simp only [Ne.symm h, xs_ih, mem_cons_iff, false_or_iff]\n        suffices : val \u2208 ys\n        tauto\n        erw [\u2190 Option.mem_def, mem_lookup_iff] at h\u2083\n        simp only [to_sigma, mem_map, heq_iff_eq, Prod.exists] at h\u2083\n        rcases h\u2083 with \u27e8a, b, h\u2083, h\u2084, h\u2085\u27e9\n        subst a\n        subst b\n        apply (mem_zip h\u2083).2\n        simp only [nodupkeys, keys, comp, Prod.fst_toSigma, map_map]\n        rwa [map_fst_zip _ _ (le_of_eq h\u2086)]\n#align slim_check.injective_function.apply_id_mem_iff SlimCheck.InjectiveFunction.applyId_mem_iff\n\ntheorem List.applyId_eq_self [DecidableEq \u03b1] {xs ys : List \u03b1} (x : \u03b1) :\n    x \u2209 xs \u2192 List.applyId.{u} (xs.zip ys) x = x :=\n  by\n  intro h\n  dsimp [list.apply_id]\n  rw [lookup_eq_none.2]; rfl\n  simp only [keys, not_exists, to_sigma, exists_and_right, exists_eq_right, mem_map, comp_app,\n    map_map, Prod.exists]\n  intro y hy\n  exact h (mem_zip hy).1\n#align slim_check.injective_function.list.apply_id_eq_self SlimCheck.InjectiveFunction.List.applyId_eq_self\n\ntheorem applyId_injective [DecidableEq \u03b1] {xs ys : List \u03b1} (h\u2080 : List.Nodup xs) (h\u2081 : xs ~ ys) :\n    Injective.{u + 1, u + 1} (List.applyId (xs.zip ys)) :=\n  by\n  intro x y h\n  by_cases hx : x \u2208 xs <;> by_cases hy : y \u2208 xs\n  \u00b7 rw [mem_iff_nth] at hx hy\n    cases' hx with i hx\n    cases' hy with j hy\n    suffices some x = some y by injection this\n    have h\u2082 := h\u2081.length_eq\n    rw [list.apply_id_zip_eq h\u2080 h\u2082 _ _ _ hx] at h\n    rw [\u2190 hx, \u2190 hy]\n    congr\n    apply nth_injective _ (h\u2081.nodup_iff.1 h\u2080)\n    \u00b7 symm\n      rw [h]\n      rw [\u2190 list.apply_id_zip_eq] <;> assumption\n    \u00b7 rw [\u2190 h\u2081.length_eq]\n      rw [nth_eq_some] at hx\n      cases' hx with hx hx'\n      exact hx\n  \u00b7 rw [\u2190 apply_id_mem_iff h\u2080 h\u2081] at hx hy\n    rw [h] at hx\n    contradiction\n  \u00b7 rw [\u2190 apply_id_mem_iff h\u2080 h\u2081] at hx hy\n    rw [h] at hx\n    contradiction\n  \u00b7 rwa [list.apply_id_eq_self, list.apply_id_eq_self] at h <;> assumption\n#align slim_check.injective_function.apply_id_injective SlimCheck.InjectiveFunction.applyId_injective\n\nopen TotalFunction (list.to_finmap')\n\nopen Sampleable\n\n/-- Remove 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 [DecidableEq \u03b1] (n m : \u2115) :\n    (\u03a3'xs ys : List \u03b1, xs ~ ys \u2227 ys.Nodup) \u2192 \u03a3'xs ys : List \u03b1, xs ~ ys \u2227 ys.Nodup\n  | \u27e8xs, ys, h, h'\u27e9 =>\n    let xs' := List.dropSlice n m xs\n    have h\u2080 : xs' ~ ys.inter xs' := Perm.dropSlice_inter _ _ h h'\n    \u27e8xs', ys.inter xs', h\u2080, h'.inter _\u27e9\n#align slim_check.injective_function.perm.slice SlimCheck.InjectiveFunction.Perm.slice\n\n/-- A lazy list, in decreasing order, of sizes that should be\nsliced off a list of length `n`\n-/\ndef sliceSizes : \u2115 \u2192 LazyList \u2115+\n  | n =>\n    if h : 0 < n then\n      have : n / 2 < n := div_lt_self h (by decide)\n      LazyList.cons \u27e8_, h\u27e9 (slice_sizes <| n / 2)\n    else LazyList.nil\n#align slim_check.injective_function.slice_sizes SlimCheck.InjectiveFunction.sliceSizes\n\n/-- Shrink 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 shrinkPerm {\u03b1 : Type} [DecidableEq \u03b1] [SizeOf \u03b1] :\n    ShrinkFn (\u03a3'xs ys : List \u03b1, xs ~ ys \u2227 ys.Nodup)\n  | xs => do\n    let k := xs.1.length\n    let n \u2190 sliceSizes k\n    let i \u2190 LazyList.ofList <| List.finRange <| k / n\n    have : \u2191i * \u2191n < xs.1.length :=\n        Nat.lt_of_div_lt_div\n          (lt_of_le_of_lt (by simp only [Nat.mul_div_cancel, gt_iff_lt, [anonymous], PNat.pos]) i.2)\n      pure\n        \u27e8perm.slice (i * n) n xs, by\n          rcases xs with \u27e8a, b, c, d\u27e9 <;> dsimp [sizeof_lt] <;> unfold_wf <;>\n                simp only [perm.slice] <;>\n              unfold_wf <;>\n            apply List.sizeOf_dropSlice_lt _ _ n.2 _ this\u27e9\n#align slim_check.injective_function.shrink_perm SlimCheck.InjectiveFunction.shrinkPerm\n\ninstance [SizeOf \u03b1] : SizeOf (InjectiveFunction \u03b1) :=\n  \u27e8fun \u27e8xs, _, _\u27e9 => SizeOf.sizeOf (xs.map Sigma.fst)\u27e9\n\n/-- Shrink 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 {\u03b1 : Type} [SizeOf \u03b1] [DecidableEq \u03b1] : ShrinkFn (InjectiveFunction \u03b1)\n  | \u27e8xs, h\u2080, h\u2081\u27e9 => do\n    let \u27e8\u27e8xs', ys', h\u2080, h\u2081\u27e9, h\u2082\u27e9 \u2190 InjectiveFunction.shrinkPerm \u27e8_, _, h\u2080, h\u2081\u27e9\n    have h\u2083 : xs' \u2264 ys' := le_of_eq (perm.length_eq h\u2080)\n      have h\u2084 : ys' \u2264 xs' := le_of_eq (perm.length_eq h\u2080)\n      pure\n        \u27e8\u27e8(List.zip xs' ys').map Prod.toSigma, by\n            simp only [comp, map_fst_zip, map_snd_zip, *, Prod.fst_toSigma, Prod.snd_toSigma,\n              map_map],\n            by simp only [comp, map_snd_zip, *, Prod.snd_toSigma, map_map]\u27e9,\n          by\n          revert h\u2082 <;> dsimp [sizeof_lt] <;> unfold_wf <;>\n                  simp only [has_sizeof._match_1, map_map, comp, map_fst_zip, *,\n                    Prod.fst_toSigma] <;>\n                unfold_wf <;>\n              intro h\u2082 <;>\n            convert h\u2082\u27e9\n#align slim_check.injective_function.shrink SlimCheck.InjectiveFunction.shrink\n\n/-- Create an injective function from one list and a permutation of that list. -/\nprotected def mk (xs ys : List \u03b1) (h : xs ~ ys) (h' : ys.Nodup) : InjectiveFunction \u03b1 :=\n  have h\u2080 : xs.length \u2264 ys.length := le_of_eq h.length_eq\n  have h\u2081 : ys.length \u2264 xs.length := le_of_eq h.length_eq.symm\n  InjectiveFunction.map_to_self (List.toFinmap' (xs.zip ys))\n    (by\n      simp only [list.to_finmap', comp, map_fst_zip, map_snd_zip, *, Prod.fst_toSigma,\n        Prod.snd_toSigma, map_map])\n    (by simp only [list.to_finmap', comp, map_snd_zip, *, Prod.snd_toSigma, map_map])\n#align slim_check.injective_function.mk SlimCheck.InjectiveFunction.mk\n\nprotected theorem injective [DecidableEq \u03b1] (f : InjectiveFunction \u03b1) : Injective (apply f) :=\n  by\n  cases' f with xs hperm hnodup\n  generalize h\u2080 : map Sigma.fst xs = xs\u2080\n  generalize h\u2081 : xs.map (@id ((\u03a3_ : \u03b1, \u03b1) \u2192 \u03b1) <| @Sigma.snd \u03b1 fun _ : \u03b1 => \u03b1) = xs\u2081\n  dsimp [id] at h\u2081\n  have hxs : xs = total_function.list.to_finmap' (xs\u2080.zip xs\u2081) :=\n    by\n    rw [\u2190 h\u2080, \u2190 h\u2081, list.to_finmap']\n    clear h\u2080 h\u2081 xs\u2080 xs\u2081 hperm hnodup\n    induction xs\n    case nil => simp only [zip_nil_right, map_nil]\n    case\n      cons xs_hd xs_tl xs_ih =>\n      simp only [true_and_iff, to_sigma, eq_self_iff_true, Sigma.eta, zip_cons_cons, List.map]\n      exact xs_ih\n  revert hperm hnodup\n  rw [hxs]\n  intros\n  apply apply_id_injective\n  \u00b7 rwa [\u2190 h\u2080, hxs, hperm.nodup_iff]\n  \u00b7 rwa [\u2190 hxs, h\u2080, h\u2081] at hperm\n#align slim_check.injective_function.injective SlimCheck.InjectiveFunction.injective\n\ninstance PiInjective.sampleableExt : SampleableExt { f : \u2124 \u2192 \u2124 // Function.Injective f }\n    where\n  ProxyRepr := InjectiveFunction \u2124\n  interp f := \u27e8apply f, f.Injective\u27e9\n  sample :=\n    Gen.sized fun sz => do\n      let xs' := Int.range (-(2 * sz + 2)) (2 * sz + 2)\n      let ys \u2190 Gen.permutationOf xs'\n      have Hinj : injective fun r : \u2115 => -(2 * sz + 2 : \u2124) + \u2191r := fun x y h =>\n          Int.ofNat.inj (add_right_injective _ h)\n        let r : injective_function \u2124 :=\n          InjectiveFunction.mk.{0} xs' ys.1 ys.2 (ys.2.nodup_iff.1 <| (nodup_range _).map Hinj)\n        pure r\n  shrink := @InjectiveFunction.shrink \u2124 _ _\n#align slim_check.injective_function.pi_injective.sampleable_ext SlimCheck.InjectiveFunction.PiInjective.sampleableExt\n\nend InjectiveFunction\n\nopen Function\n\ninstance Injective.testable (f : \u03b1 \u2192 \u03b2)\n    [I :\n      Testable\n        (NamedBinder \"x\" <|\n          \u2200 x : \u03b1, NamedBinder \"y\" <| \u2200 y : \u03b1, NamedBinder \"H\" <| f x = f y \u2192 x = y)] :\n    Testable (Injective f) :=\n  I\n#align slim_check.injective.testable SlimCheck.Injective.testable\n\ninstance Monotone.testable [Preorder \u03b1] [Preorder \u03b2] (f : \u03b1 \u2192 \u03b2)\n    [I :\n      Testable\n        (NamedBinder \"x\" <|\n          \u2200 x : \u03b1, NamedBinder \"y\" <| \u2200 y : \u03b1, NamedBinder \"H\" <| x \u2264 y \u2192 f x \u2264 f y)] :\n    Testable (Monotone f) :=\n  I\n#align slim_check.monotone.testable SlimCheck.Monotone.testable\n\ninstance Antitone.testable [Preorder \u03b1] [Preorder \u03b2] (f : \u03b1 \u2192 \u03b2)\n    [I :\n      Testable\n        (NamedBinder \"x\" <|\n          \u2200 x : \u03b1, NamedBinder \"y\" <| \u2200 y : \u03b1, NamedBinder \"H\" <| x \u2264 y \u2192 f y \u2264 f x)] :\n    Testable (Antitone f) :=\n  I\n#align slim_check.antitone.testable SlimCheck.Antitone.testable\n\nend SlimCheck\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/Testing/SlimCheck/Functions.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7217432062975979, "lm_q2_score": 0.6334102636778401, "lm_q1q2_score": 0.45715955460865126}}
{"text": "/-\nCopyright (c) 2019 S\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 `\u2113^\u221e(\u211d)` up to isometry, which is a well-defined type,\nand define the distance as the infimum of the Hausdorff distance over all\nembeddings in `\u2113^\u221e(\u211d)`. We prove that this coincides with the previous description,\nas all separable metric spaces embed isometrically into `\u2113^\u221e(\u211d)`, 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 `\u2113_infty_\u211d`:= lp (\u03bb n : \u2115, \u211d) \u221e\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 `\u2113^\u221e(\u211d)` 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 \u2113_infty_\u211d \u2192 nonempty_compacts \u2113_infty_\u211d \u2192 Prop :=\n  \u03bb x y, nonempty (x.val \u2243\u1d62 y.val)\n\n/-- This is indeed an equivalence relation -/\nprivate lemma is_equivalence_isometry_rel : equivalence isometry_rel :=\n\u27e8\u03bb x, \u27e8isometric.refl _\u27e9, \u03bb x y \u27e8e\u27e9, \u27e8e.symm\u27e9, \u03bb x y z \u27e8e\u27e9 \u27e8f\u27e9, \u27e8e.trans f\u27e9\u27e9\n\n/-- setoid instance identifying two isometric nonempty compact subspaces of \u2113^\u221e(\u211d) -/\ninstance isometry_rel.setoid : setoid (nonempty_compacts \u2113_infty_\u211d) :=\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  \u27e6nonempty_compacts.Kuratowski_embedding X\u27e7\n\ninstance : inhabited GH_space := \u27e8quot.mk _ \u27e8{0}, by simp\u27e9\u27e9\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 \u2113_infty_\u211d} :\n  \u27e6p\u27e7 = to_GH_space X \u2194 \u2203 \u03a8 : X \u2192 \u2113_infty_\u211d, isometry \u03a8 \u2227 range \u03a8 = p.val :=\nbegin\n  simp only [to_GH_space, quotient.eq],\n  refine \u27e8\u03bb h, _, _\u27e9,\n  { rcases setoid.symm h with \u27e8e\u27e9,\n    have f := (Kuratowski_embedding.isometry X).isometric_on_range.trans e,\n    use [\u03bb 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 \u27e8\u03a8, \u27e8isom\u03a8, range\u03a8\u27e9\u27e9,\n    have f := ((Kuratowski_embedding.isometry X).isometric_on_range.symm.trans\n               isom\u03a8.isometric_on_range).symm,\n    have E : (range \u03a8 \u2243\u1d62 (nonempty_compacts.Kuratowski_embedding X).val) =\n        (p.val \u2243\u1d62 range (Kuratowski_embedding X)),\n      by { dunfold nonempty_compacts.Kuratowski_embedding, rw [range\u03a8]; refl },\n    exact \u27e8cast E f\u27e9 }\nend\n\nlemma eq_to_GH_space {p : nonempty_compacts \u2113_infty_\u211d} : \u27e6p\u27e7 = to_GH_space p.val :=\neq_to_GH_space_iff.2 \u27e8\u03bb x, x, isometry_subtype_coe, subtype.range_coe\u27e9\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 \u2190 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 \u2194 nonempty (X \u2243\u1d62 Y) :=\n\u27e8begin\n  simp only [to_GH_space, quotient.eq],\n  rintro \u27e8e\u27e9,\n  have I : ((nonempty_compacts.Kuratowski_embedding X).val \u2243\u1d62\n             (nonempty_compacts.Kuratowski_embedding Y).val)\n          = ((range (Kuratowski_embedding X)) \u2243\u1d62 (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 \u27e8f.trans $ (cast I e).trans g\u27e9\nend,\nbegin\n  rintro \u27e8e\u27e9,\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)) \u2243\u1d62 (range (Kuratowski_embedding Y))) =\n    ((nonempty_compacts.Kuratowski_embedding X).val \u2243\u1d62\n      (nonempty_compacts.Kuratowski_embedding Y).val),\n    by { dunfold nonempty_compacts.Kuratowski_embedding, refl },\n  exact \u27e8cast I ((f.trans e).trans g)\u27e9\nend\u27e9\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 `\u2113^\u221e(\u211d)`, but we will prove below that it works for all spaces. -/\ninstance : has_dist (GH_space) :=\n{ dist := \u03bb x y, Inf $\n    (\u03bb p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d,\n      Hausdorff_dist p.1.val p.2.val) '' ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = 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] : \u211d := 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  {\u03b3 : Type w} [metric_space \u03b3] {\u03a6 : X \u2192 \u03b3} {\u03a8 : Y \u2192 \u03b3} (ha : isometry \u03a6) (hb : isometry \u03a8) :\n  GH_dist X Y \u2264 Hausdorff_dist (range \u03a6) (range \u03a8) :=\nbegin\n  /- For the proof, we want to embed `\u03b3` in `\u2113^\u221e(\u211d)`, to say that the Hausdorff distance is realized\n  in `\u2113^\u221e(\u211d)` and therefore bounded below by the Gromov-Hausdorff-distance. However, `\u03b3` is not\n  separable in general. We restrict to the union of the images of `X` and `Y` in `\u03b3`, which is\n  separable and therefore embeddable in `\u2113^\u221e(\u211d)`. -/\n  rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n  let s : set \u03b3 := (range \u03a6) \u222a (range \u03a8),\n  let \u03a6' : X \u2192 subtype s := \u03bb y, \u27e8\u03a6 y, mem_union_left _ (mem_range_self _)\u27e9,\n  let \u03a8' : Y \u2192 subtype s := \u03bb y, \u27e8\u03a8 y, mem_union_right _ (mem_range_self _)\u27e9,\n  have I\u03a6' : isometry \u03a6' := \u03bb x y, ha x y,\n  have I\u03a8' : isometry \u03a8' := \u03bb 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) := \u27e8is_compact_iff_is_compact_univ.1 \u2039is_compact s\u203a\u27e9,\n  haveI : nonempty (subtype s) := \u27e8\u03a6' xX\u27e9,\n  have \u03a6\u03a6' : \u03a6 = subtype.val \u2218 \u03a6', by { funext, refl },\n  have \u03a8\u03a8' : \u03a8 = subtype.val \u2218 \u03a8', by { funext, refl },\n  have : Hausdorff_dist (range \u03a6) (range \u03a8) = Hausdorff_dist (range \u03a6') (range \u03a8'),\n  { rw [\u03a6\u03a6', \u03a8\u03a8', range_comp, range_comp],\n    exact Hausdorff_dist_image (isometry_subtype_coe) },\n  rw this,\n  -- Embed `s` in `\u2113^\u221e(\u211d)` through its Kuratowski embedding\n  let F := Kuratowski_embedding (subtype s),\n  have : Hausdorff_dist (F '' (range \u03a6')) (F '' (range \u03a8')) =\n    Hausdorff_dist (range \u03a6') (range \u03a8') := Hausdorff_dist_image (Kuratowski_embedding.isometry _),\n  rw \u2190 this,\n  -- Let `A` and `B` be the images of `X` and `Y` under this embedding. They are in `\u2113^\u221e(\u211d)`, and\n  -- their Hausdorff distance is the same as in the original space.\n  let A : nonempty_compacts \u2113_infty_\u211d := \u27e8F '' (range \u03a6'), \u27e8(range_nonempty _).image _,\n      (is_compact_range I\u03a6'.continuous).image (Kuratowski_embedding.isometry _).continuous\u27e9\u27e9,\n  let B : nonempty_compacts \u2113_infty_\u211d := \u27e8F '' (range \u03a8'), \u27e8(range_nonempty _).image _,\n      (is_compact_range I\u03a8'.continuous).image (Kuratowski_embedding.isometry _).continuous\u27e9\u27e9,\n  have AX : \u27e6A\u27e7 = to_GH_space X,\n  { rw eq_to_GH_space_iff,\n    exact \u27e8\u03bb x, F (\u03a6' x), \u27e8(Kuratowski_embedding.isometry _).comp I\u03a6', by rw range_comp\u27e9\u27e9 },\n  have BY : \u27e6B\u27e7 = to_GH_space Y,\n  { rw eq_to_GH_space_iff,\n    exact \u27e8\u03bb x, F (\u03a8' x), \u27e8(Kuratowski_embedding.isometry _).comp I\u03a8', by rw range_comp\u27e9\u27e9 },\n  refine cInf_le \u27e80,\n    begin simp [lower_bounds], assume t _ _ _ _ ht, rw \u2190 ht, exact Hausdorff_dist_nonneg end\u27e9 _,\n  apply (mem_image _ _ _).2,\n  existsi (\u27e8A, B\u27e9 : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\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 `\u2264`, 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 \u2295 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 : \u2200 p q : nonempty_compacts (\u2113_infty_\u211d), \u27e6p\u27e7 = to_GH_space X \u2192 \u27e6q\u27e7 = to_GH_space Y \u2192\n        Hausdorff_dist (p.val) (q.val) < diam (univ : set X) + 1 + diam (univ : set Y) \u2192\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) \u2264\n        Hausdorff_dist (p.val) (q.val),\n  { assume p q hp hq bound,\n    rcases eq_to_GH_space_iff.1 hp with \u27e8\u03a6, \u27e8\u03a6isom, \u03a6range\u27e9\u27e9,\n    rcases eq_to_GH_space_iff.1 hq with \u27e8\u03a8, \u27e8\u03a8isom, \u03a8range\u27e9\u27e9,\n    have I : diam (range \u03a6 \u222a range \u03a8) \u2264 2 * diam (univ : set X) + 1 + 2 * diam (univ : set Y),\n    { rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n      have : \u2203 y \u2208 range \u03a8, dist (\u03a6 xX) y < diam (univ : set X) + 1 + diam (univ : set Y),\n      { rw \u03a8range,\n        have : \u03a6 xX \u2208 p.val := \u03a6range \u25b8 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 \u27e8y, hy, dy\u27e9,\n      rcases mem_range.1 hy with \u27e8z, hzy\u27e9,\n      rw \u2190 hzy at dy,\n      have D\u03a6 : diam (range \u03a6) = diam (univ : set X) := \u03a6isom.diam_range,\n      have D\u03a8 : diam (range \u03a8) = diam (univ : set Y) := \u03a8isom.diam_range,\n      calc\n        diam (range \u03a6 \u222a range \u03a8) \u2264 diam (range \u03a6) + dist (\u03a6 xX) (\u03a8 z) + diam (range \u03a8) :\n          diam_union (mem_range_self _) (mem_range_self _)\n        ... \u2264 diam (univ : set X) + (diam (univ : set X) + 1 + diam (univ : set Y)) +\n              diam (univ : set Y) :\n          by { rw [D\u03a6, D\u03a8], 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 \u2295 Y \u2192 \u2113_infty_\u211d := \u03bb x, match x with | inl y := \u03a6 y | inr z := \u03a8 z end,\n    let F : (X \u2295 Y) \u00d7 (X \u2295 Y) \u2192 \u211d := \u03bb p, dist (f p.1) (f p.2),\n    -- check that the induced \"distance\" is a candidate\n    have Fgood : F \u2208 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 \u03bb x y, calc\n        F (inl x, inl y) = dist (\u03a6 x) (\u03a6 y) : rfl\n        ... = dist x y : \u03a6isom.dist_eq x y },\n      { exact \u03bb x y, calc\n        F (inr x, inr y) = dist (\u03a8 x) (\u03a8 y) : rfl\n        ... = dist x y : \u03a8isom.dist_eq x y },\n      { exact \u03bb x y, dist_comm _ _ },\n      { exact \u03bb x y z, dist_triangle _ _ _ },\n      { exact \u03bb x y, calc\n        F (x, y) \u2264 diam (range \u03a6 \u222a range \u03a8) :\n        begin\n          have A : \u2200 z : X \u2295 Y, f z \u2208 range \u03a6 \u222a range \u03a8,\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 [\u03a6range, \u03a8range],\n          exact (p.2.2.union q.2.2).bounded,\n        end\n        ... \u2264 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)) \u2264 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 (\u03bb r hr, _)),\n    have I1 : \u2200 x : X, (\u2a05 y, Fb (inl x, inr y)) \u2264 r,\n    { assume x,\n      have : f (inl x) \u2208 p.val, by { rw [\u2190 \u03a6range], 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 \u27e8z, zq, hz\u27e9,\n      have : z \u2208 range \u03a8, by rwa [\u2190 \u03a8range] at zq,\n      rcases mem_range.1 this with \u27e8y, hy\u27e9,\n      calc (\u2a05 y, Fb (inl x, inr y)) \u2264 Fb (inl x, inr y) :\n          cinfi_le (by simpa using HD_below_aux1 0) y\n        ... = dist (\u03a6 x) (\u03a8 y) : rfl\n        ... = dist (f (inl x)) z : by rw hy\n        ... \u2264 r : le_of_lt hz },\n    have I2 : \u2200 y : Y, (\u2a05 x, Fb (inl x, inr y)) \u2264 r,\n    { assume y,\n      have : f (inr y) \u2208 q.val, by { rw [\u2190 \u03a8range], 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 \u27e8z, zq, hz\u27e9,\n      have : z \u2208 range \u03a6, by rwa [\u2190 \u03a6range] at zq,\n      rcases mem_range.1 this with \u27e8x, hx\u27e9,\n      calc (\u2a05 x, Fb (inl x, inr y)) \u2264 Fb (inl x, inr y) :\n          cinfi_le (by simpa using HD_below_aux2 0) x\n        ... = dist (\u03a6 x) (\u03a8 y) : rfl\n        ... = dist z (f (inr y)) : by rw hx\n        ... \u2264 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 : \u2200 p q : nonempty_compacts (\u2113_infty_\u211d), \u27e6p\u27e7 = to_GH_space X \u2192 \u27e6q\u27e7 = to_GH_space Y \u2192\n        Hausdorff_dist (range (optimal_GH_injl X Y)) (range (optimal_GH_injr X Y)) \u2264\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               \u2264 HD (candidates_b_dist X Y) :\n             Hausdorff_dist_optimal_le_HD _ _ (candidates_b_dist_mem_candidates_b)\n           ... \u2264 diam (univ : set X) + 1 + diam (univ : set Y) : HD_candidates_b_dist_le\n           ... \u2264 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 \u27e8_, rfl\u27e9 },\n    { rintro b \u27e8\u27e8p, q\u27e9, \u27e8hp, hq\u27e9, rfl\u27e9,\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 `\u2113^\u221e(\u211d)`, 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  \u2203 \u03a6 : X \u2192 \u2113_infty_\u211d, \u2203 \u03a8 : Y \u2192 \u2113_infty_\u211d, isometry \u03a6 \u2227 isometry \u03a8 \u2227\n  GH_dist X Y = Hausdorff_dist (range \u03a6) (range \u03a8) :=\nbegin\n  let F := Kuratowski_embedding (optimal_GH_coupling X Y),\n  let \u03a6 := F \u2218 optimal_GH_injl X Y,\n  let \u03a8 := F \u2218 optimal_GH_injr X Y,\n  refine \u27e8\u03a6, \u03a8, _, _, _\u27e9,\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 [\u2190 image_univ, \u2190 image_univ, image_comp F, image_univ, image_comp F (optimal_GH_injr X Y),\n      image_univ, \u2190 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 := \u03bb x, begin\n    rcases exists_rep x with \u27e8y, hy\u27e9,\n    refine le_antisymm _ _,\n    { apply cInf_le,\n      { exact \u27e80, by { rintro b \u27e8\u27e8u, v\u27e9, \u27e8hu, hv\u27e9, rfl\u27e9, exact Hausdorff_dist_nonneg } \u27e9},\n      { simp, existsi [y, y], simpa } },\n    { apply le_cInf,\n      { exact (nonempty.prod \u27e8y, hy\u27e9 \u27e8y, hy\u27e9).image _ },\n      { rintro b \u27e8\u27e8u, v\u27e9, \u27e8hu, hv\u27e9, rfl\u27e9, exact Hausdorff_dist_nonneg } },\n  end,\n  dist_comm := \u03bb x y, begin\n    have A : (\u03bb (p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\n                 Hausdorff_dist ((p.fst).val) ((p.snd).val)) ''\n             ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = y})\n           = ((\u03bb (p : nonempty_compacts \u2113_infty_\u211d \u00d7 nonempty_compacts \u2113_infty_\u211d),\n                 Hausdorff_dist ((p.fst).val) ((p.snd).val)) \u2218 prod.swap) ''\n                 ({a | \u27e6a\u27e7 = x} \u00d7\u02e2 {b | \u27e6b\u27e7 = 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 := \u03bb 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 \u27e8\u03a6, \u03a8, \u03a6isom, \u03a8isom, D\u03a6\u03a8\u27e9,\n    rw [\u2190 dist_GH_dist, hxy] at D\u03a6\u03a8,\n    have : range \u03a6 = range \u03a8,\n    { have h\u03a6 : is_compact (range \u03a6) := is_compact_range \u03a6isom.continuous,\n      have h\u03a8 : is_compact (range \u03a8) := is_compact_range \u03a8isom.continuous,\n      apply (is_closed.Hausdorff_dist_zero_iff_eq _ _ _).1 (D\u03a6\u03a8.symm),\n      { exact h\u03a6.is_closed },\n      { exact h\u03a8.is_closed },\n      { exact Hausdorff_edist_ne_top_of_nonempty_of_bounded (range_nonempty _)\n          (range_nonempty _) h\u03a6.bounded h\u03a8.bounded } },\n    have T : ((range \u03a8) \u2243\u1d62 y.rep) = ((range \u03a6) \u2243\u1d62 y.rep), by rw this,\n    have e\u03a8 := cast T \u03a8isom.isometric_on_range.symm,\n    have e := \u03a6isom.isometric_on_range.trans e\u03a8,\n    rw [\u2190 x.to_GH_space_rep, \u2190 y.to_GH_space_rep, to_GH_space_eq_to_GH_space_iff_isometric],\n    exact \u27e8e\u27e9\n  end,\n  dist_triangle := \u03bb 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 `\u03b31`, and an optimal coupling between `Y` and `Z` in a space\n    `\u03b32`. Then, glue these metric spaces along `Y`. We get a new space `\u03b3` 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 `\u03b3` to conclude. -/\n    let X := x.rep,\n    let Y := y.rep,\n    let Z := z.rep,\n    let \u03b31 := optimal_GH_coupling X Y,\n    let \u03b32 := optimal_GH_coupling Y Z,\n    let \u03a6 : Y \u2192 \u03b31 := optimal_GH_injr X Y,\n    have h\u03a6 : isometry \u03a6 := isometry_optimal_GH_injr X Y,\n    let \u03a8 : Y \u2192 \u03b32 := optimal_GH_injl Y Z,\n    have h\u03a8 : isometry \u03a8 := isometry_optimal_GH_injl Y Z,\n    let \u03b3 := glue_space h\u03a6 h\u03a8,\n    letI : metric_space \u03b3 := metric.metric_space_glue_space h\u03a6 h\u03a8,\n    have Comm : (to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y) =\n      (to_glue_r h\u03a6 h\u03a8) \u2218 (optimal_GH_injl Y Z) := to_glue_commute h\u03a6 h\u03a8,\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      ... \u2264 Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injl X Y)))\n                       (range ((to_glue_r h\u03a6 h\u03a8) \u2218 (optimal_GH_injr Y Z))) :\n        GH_dist_le_Hausdorff_dist\n          ((to_glue_l_isometry h\u03a6 h\u03a8).comp (isometry_optimal_GH_injl X Y))\n          ((to_glue_r_isometry h\u03a6 h\u03a8).comp (isometry_optimal_GH_injr Y Z))\n      ... \u2264 Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injl X Y)))\n                           (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y)))\n          + Hausdorff_dist (range ((to_glue_l h\u03a6 h\u03a8) \u2218 (optimal_GH_injr X Y)))\n                           (range ((to_glue_r h\u03a6 h\u03a8) \u2218 (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\u03a6 h\u03a8).comp\n              (isometry_optimal_GH_injl X Y)))).bounded },\n          { exact (is_compact_range (isometry.continuous ((to_glue_l_isometry h\u03a6 h\u03a8).comp\n              (isometry_optimal_GH_injr X Y)))).bounded }\n        end\n      ... = Hausdorff_dist ((to_glue_l h\u03a6 h\u03a8) '' (range (optimal_GH_injl X Y)))\n                           ((to_glue_l h\u03a6 h\u03a8) '' (range (optimal_GH_injr X Y)))\n          + Hausdorff_dist ((to_glue_r h\u03a6 h\u03a8) '' (range (optimal_GH_injl Y Z)))\n                           ((to_glue_r h\u03a6 h\u03a8) '' (range (optimal_GH_injr Y Z))) :\n        by simp only [\u2190 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\u03a6 h\u03a8),\n               Hausdorff_dist_image (to_glue_r_isometry h\u03a6 h\u03a8)]\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 \u2264 dist p q :=\nbegin\n  have ha : isometry (coe : p.val \u2192 X) := isometry_subtype_coe,\n  have hb : isometry (coe : q.val \u2192 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 \u2192 X), by simp,\n  have J : q.val = range (coe : q.val \u2192 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 \u2192 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 \u2192 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 `\u03b5\u2082`, then their\nGromov-Hausdorff distance is bounded by `\u03b5\u2082 / 2`. More generally, if there are subsets which are\n`\u03b5\u2081`-dense and `\u03b5\u2083`-dense in two spaces, and isometric up to `\u03b5\u2082`, then the Gromov-Hausdorff\ndistance between the spaces is bounded by `\u03b5\u2081 + \u03b5\u2082/2 + \u03b5\u2083`. 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 `\u03b5\u2081`-dense and `\u03b5\u2083`-dense in two spaces, and\nisometric up to `\u03b5\u2082`, then the Gromov-Hausdorff distance between the spaces is bounded by\n`\u03b5\u2081 + \u03b5\u2082/2 + \u03b5\u2083`. -/\ntheorem GH_dist_le_of_approx_subsets {s : set X} (\u03a6 : s \u2192 Y) {\u03b5\u2081 \u03b5\u2082 \u03b5\u2083 : \u211d}\n  (hs : \u2200 x : X, \u2203 y \u2208 s, dist x y \u2264 \u03b5\u2081) (hs' : \u2200 x : Y, \u2203 y : s, dist x (\u03a6 y) \u2264 \u03b5\u2083)\n  (H : \u2200 x y : s, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5\u2082) :\n  GH_dist X Y \u2264 \u03b5\u2081 + \u03b5\u2082 / 2 + \u03b5\u2083 :=\nbegin\n  refine le_of_forall_pos_le_add (\u03bb \u03b4 \u03b40, _),\n  rcases exists_mem_of_nonempty X with \u27e8xX, _\u27e9,\n  rcases hs xX with \u27e8xs, hxs, Dxs\u27e9,\n  have sne : s.nonempty := \u27e8xs, hxs\u27e9,\n  letI : nonempty s := sne.to_subtype,\n  have : 0 \u2264 \u03b5\u2082 := le_trans (abs_nonneg _) (H \u27e8xs, hxs\u27e9 \u27e8xs, hxs\u27e9),\n  have : \u2200 p q : s, |dist p q - dist (\u03a6 p) (\u03a6 q)| \u2264 2 * (\u03b5\u2082/2 + \u03b4) := \u03bb p q, calc\n    |dist p q - dist (\u03a6 p) (\u03a6 q)| \u2264 \u03b5\u2082 : H p q\n    ... \u2264 2 * (\u03b5\u2082/2 + \u03b4) : by linarith,\n  -- glue `X` and `Y` along the almost matching subsets\n  letI : metric_space (X \u2295 Y) :=\n    glue_metric_approx (\u03bb x:s, (x:X)) (\u03bb x, \u03a6 x) (\u03b5\u2082/2 + \u03b4) (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 (\u03bb x y, rfl),\n  have Ir : isometry Fr := isometry_emetric_iff_metric.2 (\u03bb 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  `\u03a6 s`, and of `\u03a6 s` and `Y` (in the coupling or, equivalently, in the original space). The first\n  term is bounded by `\u03b5\u2081`, by `\u03b5\u2081`-density. The third one is bounded by `\u03b5\u2083`. And the middle one is\n  bounded by `\u03b5\u2082/2` as in the coupling the points `x` and `\u03a6 x` are at distance `\u03b5\u2082/2` by\n  construction of the coupling (in fact `\u03b5\u2082/2 + \u03b4` where `\u03b4` 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 \u2295 Y`). -/\n  have : GH_dist X Y \u2264 Hausdorff_dist (range Fl) (range Fr) :=\n    GH_dist_le_Hausdorff_dist Il Ir,\n  have : Hausdorff_dist (range Fl) (range Fr) \u2264 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) \u2264 Hausdorff_dist (Fl '' s) (Fr '' (range \u03a6))\n                                             + Hausdorff_dist (Fr '' (range \u03a6)) (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) \u2264 \u03b5\u2081,\n  { rw [\u2190 image_univ, Hausdorff_dist_image Il],\n    have : 0 \u2264 \u03b5\u2081 := le_trans dist_nonneg Dxs,\n    refine Hausdorff_dist_le_of_mem_dist this (\u03bb x hx, hs x)\n      (\u03bb x hx, \u27e8x, mem_univ _, by simpa\u27e9) },\n  have : Hausdorff_dist (Fl '' s) (Fr '' (range \u03a6)) \u2264 \u03b5\u2082/2 + \u03b4,\n  { refine Hausdorff_dist_le_of_mem_dist (by linarith) _ _,\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with \u27e8x, \u27e8x_in_s, xx'\u27e9\u27e9,\n      rw \u2190 xx',\n      use [Fr (\u03a6 \u27e8x, x_in_s\u27e9), mem_image_of_mem Fr (mem_range_self _)],\n      exact le_of_eq (glue_dist_glued_points (\u03bb x:s, (x:X)) \u03a6 (\u03b5\u2082/2 + \u03b4) \u27e8x, x_in_s\u27e9) },\n    { assume x' hx',\n      rcases (set.mem_image _ _ _).1 hx' with \u27e8y, \u27e8y_in_s', yx'\u27e9\u27e9,\n      rcases mem_range.1 y_in_s' with \u27e8x, xy\u27e9,\n      use [Fl x, mem_image_of_mem _ x.2],\n      rw [\u2190 yx', \u2190 xy, dist_comm],\n      exact le_of_eq (glue_dist_glued_points (@subtype.val X s) \u03a6 (\u03b5\u2082/2 + \u03b4) x) } },\n  have : Hausdorff_dist (Fr '' (range \u03a6)) (range Fr) \u2264 \u03b5\u2083,\n  { rw [\u2190 @image_univ _ _ Fr, Hausdorff_dist_image Ir],\n    rcases exists_mem_of_nonempty Y with \u27e8xY, _\u27e9,\n    rcases hs' xY with \u27e8xs', Dxs'\u27e9,\n    have : 0 \u2264 \u03b5\u2083 := le_trans dist_nonneg Dxs',\n    refine Hausdorff_dist_le_of_mem_dist this (\u03bb x hx, \u27e8x, mem_univ _, by simpa\u27e9) (\u03bb x _, _),\n    rcases hs' x with \u27e8y, Dy\u27e9,\n    exact \u27e8\u03a6 y, mem_range_self _, Dy\u27e9 },\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 (\u03bb \u03b4 \u03b4pos, _),\n  let \u03b5 := (2/5) * \u03b4,\n  have \u03b5pos : 0 < \u03b5 := mul_pos (by norm_num) \u03b4pos,\n  have : \u2200 p:GH_space, \u2203 s : set (p.rep), finite s \u2227 (univ \u2286 (\u22c3x\u2208s, ball x \u03b5)) :=\n    \u03bb p, by simpa using finite_cover_balls_of_compact (@compact_univ p.rep _ _) \u03b5pos,\n  -- for each `p`, `s p` is a finite `\u03b5`-dense subset of `p` (or rather the metric space\n  -- `p.rep` representing `p`)\n  choose s hs using this,\n  have : \u2200 p:GH_space, \u2200 t:set (p.rep), finite t \u2192 \u2203 n:\u2115, \u2203 e:equiv t (fin n), true,\n  { assume p t ht,\n    letI : fintype t := finite.fintype ht,\n    exact \u27e8fintype.card t, fintype.equiv_fin t, trivial\u27e9 },\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 := \u03bb 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 := \u03bb 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 `\u03b5`-dense set `s p`.\n  let F : GH_space \u2192 \u03a3n:\u2115, (fin n \u2192 fin n \u2192 \u2124) :=\n    \u03bbp, \u27e8N p, \u03bba b, \u230a\u03b5\u207b\u00b9 * dist ((E p).symm a) ((E p).symm b)\u230b\u27e9,\n  refine \u27e8\u03a3 n, fin n \u2192 fin n \u2192 \u2124, by apply_instance, F, \u03bbp q hpq, _\u27e9,\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 `\u2264 \u03b4`.\n  For this, we construct a map `\u03a6` from `s p \u2286 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 `\u03a8` between `s p` and `s q`, and then\n  composing with the canonical inclusion we get `\u03a6`. -/\n  have Npq : N p = N q := (sigma.mk.inj_iff.1 hpq).1,\n  let \u03a8 : s p \u2192 s q := \u03bb x, (E q).symm (fin.cast Npq ((E p) x)),\n  let \u03a6 : s p \u2192 q.rep := \u03bb x, \u03a8 x,\n  -- Use the almost isometry `\u03a6` to show that `p.rep` and `q.rep`\n  -- are within controlled Gromov-Hausdorff distance.\n  have main : GH_dist p.rep q.rep \u2264 \u03b5 + \u03b5/2 + \u03b5,\n  { refine GH_dist_le_of_approx_subsets \u03a6  _ _ _,\n    show \u2200 x : p.rep, \u2203 (y : p.rep) (H : y \u2208 s p), dist x y \u2264 \u03b5,\n    { -- by construction, `s p` is `\u03b5`-dense\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s p), ball y \u03b5 := (hs p).2 (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      exact \u27e8y, ys, le_of_lt hy\u27e9 },\n    show \u2200 x : q.rep, \u2203 (z : s p), dist x (\u03a6 z) \u2264 \u03b5,\n    { -- by construction, `s q` is `\u03b5`-dense, and it is the range of `\u03a6`\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s q), ball y \u03b5 := (hs q).2 (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      let i : \u2115 := E q \u27e8y, ys\u27e9,\n      let hi := ((E q) \u27e8y, ys\u27e9).is_lt,\n      have ihi_eq : (\u27e8i, hi\u27e9 : fin (N q)) = (E q) \u27e8y, ys\u27e9, 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 \u27e8i, hip\u27e9,\n      use z,\n      have C1 : (E p) z = \u27e8i, hip\u27e9 := (E p).apply_symm_apply \u27e8i, hip\u27e9,\n      have C2 : fin.cast Npq \u27e8i, hip\u27e9 = \u27e8i, hi\u27e9 := rfl,\n      have C3 : (E q).symm \u27e8i, hi\u27e9 = \u27e8y, ys\u27e9,\n        by { rw ihi_eq, exact (E q).symm_apply_apply \u27e8y, ys\u27e9 },\n      have : \u03a6 z = y :=\n        by { simp only [\u03a6, \u03a8], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_of_lt hy },\n    show \u2200 x y : s p, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `\u03a6 x` and `\u03a6 y` (two points of `s q`) is encoded in `F q`, all this up to `\u03b5`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (\u03a6 x) (\u03a6 y) = dist (\u03a8 x) (\u03a8 y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `\u03a6 x` in `fin (N p) = fin (N q)`\n      let i : \u2115 := 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) (\u03a8 x)), by { simp [\u03a8] },\n      -- introduce `j`, that codes both `y` and `\u03a6 y` in `fin (N p) = fin (N q)`\n      let j : \u2115 := 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) (\u03a8 y)).1, by { simp [\u03a8] },\n      -- Express `dist x y` in terms of `F p`\n      have : (F p).2 ((E p) x) ((E p) y) = floor (\u03b5\u207b\u00b9 * dist x y),\n        by simp only [F, (E p).symm_apply_apply],\n      have Ap : (F p).2 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9 = floor (\u03b5\u207b\u00b9 * dist x y),\n        by { rw \u2190 this, congr; apply (fin.ext_iff _ _).2; refl },\n      -- Express `dist (\u03a6 x) (\u03a6 y)` in terms of `F q`\n      have : (F q).2 ((E q) (\u03a8 x)) ((E q) (\u03a8 y)) = floor (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)),\n        by simp only [F, (E q).symm_apply_apply],\n      have Aq : (F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9 = floor (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)),\n        by { rw \u2190 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 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9 = (F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9,\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 \u22a2,\n        subst hpq,\n        intros,\n        refl },\n      rw [Ap, Aq] at this,\n      -- deduce that the distances coincide up to `\u03b5`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)| =\n          |\u03b5\u207b\u00b9 * (dist x y - dist (\u03a8 x) (\u03a8 y))| : (abs_mul _ _).symm\n        ... = |(\u03b5\u207b\u00b9 * dist x y) - (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y))| : by { congr, ring }\n        ... \u2264 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (\u03a8 x) (\u03a8 y)| = (\u03b5 * \u03b5\u207b\u00b9) * |dist x y - dist (\u03a8 x) (\u03a8 y)| :\n          by rw [mul_inv_cancel (ne_of_gt \u03b5pos), one_mul]\n        ... = \u03b5 * (|\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 \u03b5pos)), mul_assoc]\n        ... \u2264 \u03b5 * 1 : mul_le_mul_of_nonneg_left I (le_of_lt \u03b5pos)\n        ... = \u03b5 : mul_one _ } },\n  calc dist p q = GH_dist (p.rep) (q.rep) : dist_GH_dist p q\n    ... \u2264 \u03b5 + \u03b5/2 + \u03b5 : main\n    ... = \u03b4 : by { simp [\u03b5], 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 `\u03b5` the number of balls of radius `\u03b5` 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 : \u211d} {u : \u2115 \u2192 \u211d} {K : \u2115 \u2192 \u2115}\n  (ulim : tendsto u at_top (\ud835\udcdd 0))\n  (hdiam : \u2200 p \u2208 t, diam (univ : set (GH_space.rep p)) \u2264 C)\n  (hcov : \u2200 p \u2208 t, \u2200 n:\u2115, \u2203 s : set (GH_space.rep p),\n    cardinal.mk s \u2264 K n \u2227 univ \u2286 \u22c3x\u2208s, ball x (u n)) :\n  totally_bounded t :=\nbegin\n  /- Let `\u03b4>0`, and `\u03b5 = \u03b4/5`. For each `p`, we construct a finite subset `s p` of `p`, which\n  is `\u03b5`-dense and has cardinality at most `K n`. Encoding the mutual distances of points in `s p`,\n  up to `\u03b5`, we will get a map `F` associating to `p` finitely many data, and making it possible to\n  reconstruct `p` up to `\u03b5`. This is enough to prove total boundedness. -/\n  refine metric.totally_bounded_of_finite_discretization (\u03bb \u03b4 \u03b4pos, _),\n  let \u03b5 := (1/5) * \u03b4,\n  have \u03b5pos : 0 < \u03b5 := mul_pos (by norm_num) \u03b4pos,\n  -- choose `n` for which `u n < \u03b5`\n  rcases metric.tendsto_at_top.1 ulim \u03b5 \u03b5pos with \u27e8n, hn\u27e9,\n  have u_le_\u03b5 : u n \u2264 \u03b5,\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 `\u03b5`-dense and has cardinal `\u2264 K n`\n  have : \u2200 p:GH_space, \u2203 s : set (p.rep), \u2203 N \u2264 K n, \u2203 E : equiv s (fin N),\n    p \u2208 t \u2192 univ \u2286 \u22c3x\u2208s, ball x (u n),\n  { assume p,\n    by_cases hp : p \u2209 t,\n    { have : nonempty (equiv (\u2205 : set (p.rep)) (fin 0)),\n      { rw \u2190 fintype.card_eq, simp },\n      use [\u2205, 0, bot_le, choice (this)] },\n    { rcases hcov _ (set.not_not_mem.1 hp) n with \u27e8s, \u27e8scard, scover\u27e9\u27e9,\n      rcases cardinal.lt_omega.1 (lt_of_le_of_lt scard (cardinal.nat_lt_omega _)) with \u27e8N, hN\u27e9,\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 `\u03b5`, namely the (discretized) distances between elements of `s p`.\n  let M := \u230a\u03b5\u207b\u00b9 * max C 0\u230b\u208a,\n  let F : GH_space \u2192 (\u03a3k:fin ((K n).succ), (fin k \u2192 fin k \u2192 fin (M.succ))) :=\n    \u03bb p, \u27e8\u27e8N p, lt_of_le_of_lt (hN p) (nat.lt_succ_self _)\u27e9,\n         \u03bb a b, \u27e8min M \u230a\u03b5\u207b\u00b9 * dist ((E p).symm a) ((E p).symm b)\u230b\u208a,\n                ( min_le_left _ _).trans_lt (nat.lt_succ_self _) \u27e9 \u27e9,\n  refine \u27e8_, _, (\u03bb p, F p), _\u27e9, apply_instance,\n  -- It remains to show that if `F p = F q`, then `p` and `q` are `\u03b5`-close\n  rintros \u27e8p, pt\u27e9 \u27e8q, qt\u27e9 hpq,\n  have Npq : N p = N q := (fin.ext_iff _ _).1 (sigma.mk.inj_iff.1 hpq).1,\n  let \u03a8 : s p \u2192 s q := \u03bb x, (E q).symm (fin.cast Npq ((E p) x)),\n  let \u03a6 : s p \u2192 q.rep := \u03bb x, \u03a8 x,\n  have main : GH_dist (p.rep) (q.rep) \u2264 \u03b5 + \u03b5/2 + \u03b5,\n  { -- to prove the main inequality, argue that `s p` is `\u03b5`-dense in `p`, and `s q` is `\u03b5`-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 \u03a6  _ _ _,\n    show \u2200 x : p.rep, \u2203 (y : p.rep) (H : y \u2208 s p), dist x y \u2264 \u03b5,\n    { -- by construction, `s p` is `\u03b5`-dense\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s p), ball y (u n) := (hs p pt) (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      exact \u27e8y, ys, le_trans (le_of_lt hy) u_le_\u03b5\u27e9 },\n    show \u2200 x : q.rep, \u2203 (z : s p), dist x (\u03a6 z) \u2264 \u03b5,\n    { -- by construction, `s q` is `\u03b5`-dense, and it is the range of `\u03a6`\n      assume x,\n      have : x \u2208 \u22c3y\u2208(s q), ball y (u n) := (hs q qt) (mem_univ _),\n      rcases mem_Union\u2082.1 this with \u27e8y, ys, hy\u27e9,\n      let i : \u2115 := E q \u27e8y, ys\u27e9,\n      let hi := ((E q) \u27e8y, ys\u27e9).2,\n      have ihi_eq : (\u27e8i, hi\u27e9 : fin (N q)) = (E q) \u27e8y, ys\u27e9, 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 \u27e8i, hip\u27e9,\n      use z,\n      have C1 : (E p) z = \u27e8i, hip\u27e9 := (E p).apply_symm_apply \u27e8i, hip\u27e9,\n      have C2 : fin.cast Npq \u27e8i, hip\u27e9 = \u27e8i, hi\u27e9 := rfl,\n      have C3 : (E q).symm \u27e8i, hi\u27e9 = \u27e8y, ys\u27e9,\n        by { rw ihi_eq, exact (E q).symm_apply_apply \u27e8y, ys\u27e9 },\n      have : \u03a6 z = y :=\n        by { simp only [\u03a6, \u03a8], rw [C1, C2, C3], refl },\n      rw this,\n      exact le_trans (le_of_lt hy) u_le_\u03b5 },\n    show \u2200 x y : s p, |dist x y - dist (\u03a6 x) (\u03a6 y)| \u2264 \u03b5,\n    { /- the distance between `x` and `y` is encoded in `F p`, and the distance between\n      `\u03a6 x` and `\u03a6 y` (two points of `s q`) is encoded in `F q`, all this up to `\u03b5`.\n      As `F p = F q`, the distances are almost equal. -/\n      assume x y,\n      have : dist (\u03a6 x) (\u03a6 y) = dist (\u03a8 x) (\u03a8 y) := rfl,\n      rw this,\n      -- introduce `i`, that codes both `x` and `\u03a6 x` in `fin (N p) = fin (N q)`\n      let i : \u2115 := 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) (\u03a8 x)), by { simp [\u03a8] },\n      -- introduce `j`, that codes both `y` and `\u03a6 y` in `fin (N p) = fin (N q)`\n      let j : \u2115 := 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) (\u03a8 y)), by { simp [\u03a8] },\n      -- Express `dist x y` in terms of `F p`\n      have Ap : ((F p).2 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a := calc\n        ((F p).2 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = ((F p).2 ((E p) x) ((E p) y)).1 :\n          by { congr; apply (fin.ext_iff _ _).2; refl }\n        ... = min M \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a :\n          by simp only [F, (E p).symm_apply_apply]\n        ... = \u230a\u03b5\u207b\u00b9 * dist x y\u230b\u208a :\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 \u03b5pos).le),\n          change dist (x : p.rep) y \u2264 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 (\u03a6 x) (\u03a6 y)` in terms of `F q`\n      have Aq : ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).1 = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a := calc\n        ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).1 = ((F q).2 ((E q) (\u03a8 x)) ((E q) (\u03a8 y))).1 :\n          by { congr; apply (fin.ext_iff _ _).2; [exact i', exact j'] }\n        ... = min M \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a :\n          by simp only [F, (E q).symm_apply_apply]\n        ... = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b\u208a :\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 \u03b5pos).le),\n          change dist (\u03a8 x : q.rep) (\u03a8 y) \u2264 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 \u27e8i, hip\u27e9 \u27e8j, hjp\u27e9).1 = ((F q).2 \u27e8i, hiq\u27e9 \u27e8j, hjq\u27e9).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 \u22a2,\n        subst hpq,\n        intros,\n        refl },\n      have : \u230a\u03b5\u207b\u00b9 * dist x y\u230b = \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b,\n      { rw [Ap, Aq] at this,\n        have D : 0 \u2264 \u230a\u03b5\u207b\u00b9 * dist x y\u230b :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 \u03b5pos)) dist_nonneg),\n        have D' : 0 \u2264 \u230a\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y)\u230b :=\n          floor_nonneg.2 (mul_nonneg (le_of_lt (inv_pos.2 \u03b5pos)) dist_nonneg),\n        rw [\u2190 int.to_nat_of_nonneg D, \u2190 int.to_nat_of_nonneg D', int.floor_to_nat,int.floor_to_nat,\n          this] },\n      -- deduce that the distances coincide up to `\u03b5`, by a straightforward computation\n      -- that should be automated\n      have I := calc\n        |\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)| =\n          |\u03b5\u207b\u00b9 * (dist x y - dist (\u03a8 x) (\u03a8 y))| : (abs_mul _ _).symm\n        ... = |(\u03b5\u207b\u00b9 * dist x y) - (\u03b5\u207b\u00b9 * dist (\u03a8 x) (\u03a8 y))| : by { congr, ring }\n        ... \u2264 1 : le_of_lt (abs_sub_lt_one_of_floor_eq_floor this),\n      calc\n        |dist x y - dist (\u03a8 x) (\u03a8 y)| = (\u03b5 * \u03b5\u207b\u00b9) * |dist x y - dist (\u03a8 x) (\u03a8 y)| :\n          by rw [mul_inv_cancel (ne_of_gt \u03b5pos), one_mul]\n        ... = \u03b5 * (|\u03b5\u207b\u00b9| * |dist x y - dist (\u03a8 x) (\u03a8 y)|) :\n          by rw [abs_of_nonneg (le_of_lt (inv_pos.2 \u03b5pos)), mul_assoc]\n        ... \u2264 \u03b5 * 1 : mul_le_mul_of_nonneg_left I (le_of_lt \u03b5pos)\n        ... = \u03b5 : mul_one _ } },\n  calc dist p q = GH_dist (p.rep) (q.rep) : dist_GH_dist p q\n    ... \u2264 \u03b5 + \u03b5/2 + \u03b5 : main\n    ... = \u03b4/2 : by { simp [\u03b5], ring }\n    ... < \u03b4 : half_lt_self \u03b4pos\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 : \u2115 \u2192 Type) [\u2200 n, metric_space (X n)] [\u2200 n, compact_space (X n)] [\u2200 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 \u2192 space)\n(isom   : isometry embed)\n\ninstance (A : Type) [metric_space A] : inhabited (aux_gluing_struct A) :=\n\u27e8{ space := A,\n  metric := by apply_instance,\n  embed := id,\n  isom := \u03bb x y, rfl }\u27e9\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 : \u2115) : aux_gluing_struct (X n) := nat.rec_on n\n  { space  := X 0,\n    metric := by apply_instance,\n    embed  := id,\n    isom   := \u03bb x y, rfl }\n(\u03bb 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              \u2218 (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 : \u2200 (n : \u2115), 0 < ((1:\u211d) / 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 (\u03bb n, (1/2)^n) this (\u03bb u hu, _),\n  -- `X n` is a representative of `u n`\n  let X := \u03bb 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 : \u2200 n, metric_space (Y n).space := \u03bb n, (Y n).metric,\n  have E : \u2200 n : \u2115,\n    glue_space (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)) = (Y n.succ).space :=\n    \u03bb n, by { simp [Y, aux_gluing], refl },\n  let c := \u03bb n, cast (E n),\n  have ic : \u2200 n, isometry (c n) := \u03bb n x y, rfl,\n  -- there is a canonical embedding of `Y n` in `Y (n+1)`, by construction\n  let f : \u03a0n, (Y n).space \u2192 (Y n.succ).space :=\n    \u03bb n, (c n) \u2218 (to_glue_l (aux_gluing X n).isom (isometry_optimal_GH_injl (X n) (X n.succ))),\n  have I : \u2200 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 \u03a6 := to_inductive_limit I,\n  let coeZ := (coe : Z0 \u2192 Z),\n  -- let `X2 n` be the image of `X n` in the space `Z`\n  let X2 := \u03bb n, range (coeZ \u2218 (\u03a6 n) \u2218 (Y n).embed),\n  have isom : \u2200 n, isometry (coeZ \u2218 (\u03a6 n) \u2218 (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 : \u2200 n, Hausdorff_dist (X2 n) (X2 n.succ) < (1/2)^n,\n  { assume n,\n    have X2n : X2 n = range ((coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n      \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      \u2218 (optimal_GH_injl (X n) (X n.succ))),\n    { change X2 n = range (coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n        \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ)))\n        \u2218 (optimal_GH_injl (X n) (X n.succ))),\n      simp only [X2, \u03a6],\n      rw [\u2190 to_inductive_limit_commute I],\n      simp only [f],\n      rw \u2190 to_glue_commute },\n    rw range_comp at X2n,\n    have X2nsucc : X2 n.succ = range ((coeZ \u2218 (\u03a6 n.succ) \u2218 (c n)\n      \u2218 (to_glue_r (Y n).isom (isometry_optimal_GH_injl (X n) (X n.succ))))\n      \u2218 (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, \u2190 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 : \u2115 \u2192 nonempty_compacts Z := \u03bb n, \u27e8X2 n,\n    \u27e8range_nonempty _, is_compact_range (isom n).continuous \u27e9\u27e9,\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) (\u03bb 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 \u27e8L, hL\u27e9,\n  -- the images of `X3 n` in the Gromov-Hausdorff space converge to the image of `L`\n  have M : tendsto (\u03bb n, (X3 n).to_GH_space) at_top (\ud835\udcdd 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 : \u2200 n, (X3 n).to_GH_space = u n,\n  { assume n,\n    rw [nonempty_compacts.to_GH_space, \u2190 (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 \u27e8L.to_GH_space, by simpa [this] using M\u27e9\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' {\u03b1 : Type u} [discrete_field \u03b1] {x : \u03b1} {n : \u2115} : (x\u207b\u00b9)^n = (x^n)\u207b\u00b9 :=\ndecidable.by_cases\n  (assume H : x = 0, or.cases_on (nat.eq_zero_or_pos n)\n    (\u03bb hn, by rw [H, hn, pow_zero, pow_zero, inv_one])\n    (\u03bb hn, by rw [H, zero_pow hn, inv_zero, zero_pow hn]))\n  (\u03bb H, division_ring.inv_pow H n)\n\ntheorem pow_eq_zero {\u03b1 : Type u} [domain \u03b1] {x : \u03b1} {n : \u2115} (H : x^n = 0) : x = 0 :=\nbegin\n  induction n with n ih,\n  { rw pow_zero at H,\n    rw [\u2190 mul_one x, H, mul_zero] },\n  exact or.cases_on (mul_eq_zero.1 H) id ih\nend\n\nclass char_p (\u03b1 : Type u) [semiring \u03b1] (p : \u2115) : Prop :=\n(cast_eq_zero_iff : \u2200 x:\u2115, (x:\u03b1) = 0 \u2194 p \u2223 x)\n\ntheorem char_p.cast_eq_zero (\u03b1 : Type u) [semiring \u03b1] (p : \u2115) [char_p \u03b1 p] : (p:\u03b1) = 0 :=\n(char_p.cast_eq_zero_iff \u03b1 p p).2 (dvd_refl p)\n\ntheorem char_p.eq (\u03b1 : Type u) [semiring \u03b1] {p q : \u2115} (c1 : char_p \u03b1 p) (c2 : char_p \u03b1 q) : p = q :=\nnat.dvd_antisymm\n  ((char_p.cast_eq_zero_iff \u03b1 p q).1 (char_p.cast_eq_zero _ _))\n  ((char_p.cast_eq_zero_iff \u03b1 q p).1 (char_p.cast_eq_zero _ _))\n\ninstance char_p.of_char_zero (\u03b1 : Type u) [semiring \u03b1] [char_zero \u03b1] : char_p \u03b1 0 :=\n\u27e8\u03bb x, by rw [zero_dvd_iff, \u2190 nat.cast_zero, nat.cast_inj]\u27e9\n\ntheorem char_p.exists (\u03b1 : Type u) [semiring \u03b1] : \u2203 p, char_p \u03b1 p :=\nby letI := classical.dec_eq \u03b1; exact\nclassical.by_cases\n  (assume H : \u2200 p:\u2115, (p:\u03b1) = 0 \u2192 p = 0, \u27e80,\n    \u27e8\u03bb x, by rw [zero_dvd_iff]; exact \u27e8H x, by rintro rfl; refl\u27e9\u27e9\u27e9)\n  (\u03bb H, \u27e8nat.find (classical.not_forall.1 H), \u27e8\u03bb x,\n    \u27e8\u03bb H1, nat.dvd_of_mod_eq_zero (by_contradiction $ \u03bb 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 \u27e8by rwa [\u2190 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\u27e9)),\n    \u03bb H1, by rw [\u2190 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]\u27e9\u27e9\u27e9)\n\ntheorem char_p.exists_unique (\u03b1 : Type u) [semiring \u03b1] : \u2203! p, char_p \u03b1 p :=\nlet \u27e8c, H\u27e9 := char_p.exists \u03b1 in \u27e8c, H, \u03bb y H2, char_p.eq \u03b1 H2 H\u27e9\n\nnoncomputable def ring_char (\u03b1 : Type u) [semiring \u03b1] : \u2115 :=\nclassical.some (char_p.exists_unique \u03b1)\n\ntheorem ring_char.spec (\u03b1 : Type u) [semiring \u03b1] : \u2200 x:\u2115, (x:\u03b1) = 0 \u2194 ring_char \u03b1 \u2223 x :=\nby letI := (classical.some_spec (char_p.exists_unique \u03b1)).1;\nunfold ring_char; exact char_p.cast_eq_zero_iff \u03b1 (ring_char \u03b1)\n\ntheorem ring_char.eq (\u03b1 : Type u) [semiring \u03b1] {p : \u2115} (C : char_p \u03b1 p) : p = ring_char \u03b1 :=\n(classical.some_spec (char_p.exists_unique \u03b1)).2 p C\n\ntheorem add_pow_char (\u03b1 : Type u) [comm_ring \u03b1] {p : \u2115} (hp : nat.prime p)\n  [char_p \u03b1 p] (x y : \u03b1) : (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 [\u2190 nat.div_mul_cancel this, nat.cast_mul, char_p.cast_eq_zero \u03b1 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\u2080 {\u03b1 : Type u} {op : \u03b1 \u2192 \u03b1} {x : \u03b1} (H : op x = x) {n : \u2115} :\n  op^[n] x = x :=\nby induction n; [simp only [nat.iterate_zero], simp only [nat.iterate_succ', H, *]]\n\ntheorem nat.iterate\u2081 {\u03b1 : Type u} {\u03b2 : Type v} {op : \u03b1 \u2192 \u03b1} {op' : \u03b2 \u2192 \u03b2} {op'' : \u03b1 \u2192 \u03b2}\n  (H : \u2200 x, op' (op'' x) = op'' (op x)) {n : \u2115} {x : \u03b1} :\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\u2082 {\u03b1 : Type u} {op : \u03b1 \u2192 \u03b1} {op' : \u03b1 \u2192 \u03b1 \u2192 \u03b1} (H : \u2200 x y, op (op' x y) = op' (op x) (op y)) {n : \u2115} {x y : \u03b1} :\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 {\u03b1 : Type u} {op op' : \u03b1 \u2192 \u03b1} (H : \u2200 x, op (op' x) = x) {n : \u2115} {x : \u03b1} : op^[n] (op'^[n] x) = x :=\nby induction n; [refl, rwa [nat.iterate_succ, nat.iterate_succ', H]]\n\ntheorem nat.iterate_inj {\u03b1 : Type u} {op : \u03b1 \u2192 \u03b1} (Hinj : function.injective op) (n : \u2115) (x y : \u03b1)\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 (\u03b1 : Type u) [monoid \u03b1] (p : \u2115) (x : \u03b1) : \u03b1 := x^p\n\ntheorem frobenius_def (\u03b1 : Type u) [monoid \u03b1] (p : \u2115) (x : \u03b1) : frobenius \u03b1 p x = x ^ p := rfl\n\ntheorem frobenius_mul (\u03b1 : Type u) [comm_monoid \u03b1] (p : \u2115) (x y : \u03b1) :\n  frobenius \u03b1 p (x * y) = frobenius \u03b1 p x * frobenius \u03b1 p y := mul_pow x y p\ntheorem frobenius_one (\u03b1 : Type u) [monoid \u03b1] (p : \u2115) :\n  frobenius \u03b1 p 1 = 1 := one_pow _\n\ntheorem is_monoid_hom.map_frobenius {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192 \u03b2) [is_monoid_hom f]\n  (p : \u2115) (x : \u03b1) : f (frobenius \u03b1 p x) = frobenius \u03b2 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 {\u03b1 : Type u} [comm_ring \u03b1] (p : \u2115) [hp : nat.prime p] [char_p \u03b1 p] : is_ring_hom (frobenius \u03b1 p) :=\n{ map_one := frobenius_one \u03b1 p,\n  map_mul := frobenius_mul \u03b1 p,\n  map_add := add_pow_char \u03b1 hp }\n\nsection\nvariables (\u03b1 : Type u) [comm_ring \u03b1] (p : \u2115) [hp : nat.prime p]\ntheorem frobenius_zero : frobenius \u03b1 p 0 = 0 := zero_pow hp.pos\nvariables [char_p \u03b1 p] (x y : \u03b1)\ninclude hp\ntheorem frobenius_add : frobenius \u03b1 p (x + y) = frobenius \u03b1 p x + frobenius \u03b1 p y := is_ring_hom.map_add _\ntheorem frobenius_neg : frobenius \u03b1 p (-x) = -frobenius \u03b1 p x := is_ring_hom.map_neg _\ntheorem frobenius_sub : frobenius \u03b1 p (x - y) = frobenius \u03b1 p x - frobenius \u03b1 p y := is_ring_hom.map_sub _\nend\n\ntheorem frobenius_inj (\u03b1 : Type u) [integral_domain \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] (x y : \u03b1)\n  (H : frobenius \u03b1 p x = frobenius \u03b1 p y) : x = y :=\nby rw \u2190 sub_eq_zero at H \u22a2; rw \u2190 frobenius_sub at H; exact pow_eq_zero H\n\ntheorem frobenius_nat_cast (\u03b1 : Type u) [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] (x : \u2115) :\n  frobenius \u03b1 p x = x :=\nby induction x; simp only [nat.cast_zero, nat.cast_succ, frobenius_zero, frobenius_one, frobenius_add, *]\n\nclass perfect_field (\u03b1 : Type u) [field \u03b1] (p : \u2115) [char_p \u03b1 p] : Type u :=\n(pth_root : \u03b1 \u2192 \u03b1)\n(frobenius_pth_root : \u2200 x, frobenius \u03b1 p (pth_root x) = x)\n\ntheorem frobenius_pth_root (\u03b1 : Type u) [field \u03b1] (p : \u2115) [char_p \u03b1 p] [perfect_field \u03b1 p] (x : \u03b1) :\n  frobenius \u03b1 p (perfect_field.pth_root p x) = x :=\nperfect_field.frobenius_pth_root p x\n\ntheorem pth_root_frobenius (\u03b1 : Type u) [field \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] [perfect_field \u03b1 p] (x : \u03b1) :\n  perfect_field.pth_root p (frobenius \u03b1 p x) = x :=\nfrobenius_inj \u03b1 p _ _ (by rw frobenius_pth_root)\n\ninstance pth_root.is_ring_hom (\u03b1 : Type u) [field \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] [perfect_field \u03b1 p] :\n  is_ring_hom (@perfect_field.pth_root \u03b1 _ p _ _) :=\n{ map_one := frobenius_inj \u03b1 p _ _ (by rw [frobenius_pth_root, frobenius_one]),\n  map_mul := \u03bb x y, frobenius_inj \u03b1 p _ _ (by simp only [frobenius_pth_root, frobenius_mul]),\n  map_add := \u03bb x y, frobenius_inj \u03b1 p _ _ (by simp only [frobenius_pth_root, frobenius_add]) }\n\ntheorem is_ring_hom.pth_root {\u03b1 : Type u} [field \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] [perfect_field \u03b1 p]\n  {\u03b2 : Type v} [field \u03b2] [char_p \u03b2 p] [perfect_field \u03b2 p] (f : \u03b1 \u2192 \u03b2) [is_ring_hom f] {x : \u03b1} :\n  f (perfect_field.pth_root p x) = perfect_field.pth_root p (f x) :=\nfrobenius_inj \u03b2 p _ _ (by rw [\u2190 is_monoid_hom.map_frobenius f, frobenius_pth_root, frobenius_pth_root])\n\ninductive perfect_closure.r (\u03b1 : Type u) [monoid \u03b1] (p : \u2115) : (\u2115 \u00d7 \u03b1) \u2192 (\u2115 \u00d7 \u03b1) \u2192 Prop\n| intro : \u2200 n x, perfect_closure.r (n, x) (n+1, frobenius \u03b1 p x)\nrun_cmd tactic.mk_iff_of_inductive_prop `perfect_closure.r `perfect_closure.r_iff\n\ndef perfect_closure (\u03b1 : Type u) [monoid \u03b1] (p : \u2115) : Type u :=\nquot (perfect_closure.r \u03b1 p)\n\nnamespace perfect_closure\n\nvariables (\u03b1 : Type u)\n\nprivate lemma mul_aux_left [comm_monoid \u03b1] (p : \u2115) (x1 x2 y : \u2115 \u00d7 \u03b1) (H : r \u03b1 p x1 x2) :\n  quot.mk (r \u03b1 p) (x1.1 + y.1, ((frobenius \u03b1 p)^[y.1] x1.2) * ((frobenius \u03b1 p)^[x1.1] y.2)) =\n  quot.mk (r \u03b1 p) (x2.1 + y.1, ((frobenius \u03b1 p)^[y.1] x2.2) * ((frobenius \u03b1 p)^[x2.1] y.2)) :=\nmatch x1, x2, H with\n| _, _, r.intro _ n x := quot.sound $ by rw [\u2190 nat.iterate_succ, nat.iterate_succ',\n    nat.iterate_succ', \u2190 frobenius_mul, nat.succ_add]; apply r.intro\nend\n\nprivate lemma mul_aux_right [comm_monoid \u03b1] (p : \u2115) (x y1 y2 : \u2115 \u00d7 \u03b1) (H : r \u03b1 p y1 y2) :\n  quot.mk (r \u03b1 p) (x.1 + y1.1, ((frobenius \u03b1 p)^[y1.1] x.2) * ((frobenius \u03b1 p)^[x.1] y1.2)) =\n  quot.mk (r \u03b1 p) (x.1 + y2.1, ((frobenius \u03b1 p)^[y2.1] x.2) * ((frobenius \u03b1 p)^[x.1] y2.2)) :=\nmatch y1, y2, H with\n| _, _, r.intro _ n y := quot.sound $ by rw [\u2190 nat.iterate_succ, nat.iterate_succ',\n    nat.iterate_succ', \u2190 frobenius_mul]; apply r.intro\nend\n\ninstance [comm_monoid \u03b1] (p : \u2115) : has_mul (perfect_closure \u03b1 p) :=\n\u27e8quot.lift (\u03bb x:\u2115\u00d7\u03b1, quot.lift (\u03bb y:\u2115\u00d7\u03b1, quot.mk (r \u03b1 p)\n    (x.1 + y.1, ((frobenius \u03b1 p)^[y.1] x.2) * ((frobenius \u03b1 p)^[x.1] y.2))) (mul_aux_right \u03b1 p x))\n  (\u03bb x1 x2 (H : r \u03b1 p x1 x2), funext $ \u03bb e, quot.induction_on e $ \u03bb y,\nmul_aux_left \u03b1 p x1 x2 y H)\u27e9\n\ninstance [comm_monoid \u03b1] (p : \u2115) : comm_monoid (perfect_closure \u03b1 p) :=\n{ mul_assoc := \u03bb e f g, quot.induction_on e $ \u03bb \u27e8m, x\u27e9, quot.induction_on f $ \u03bb \u27e8n, y\u27e9,\n    quot.induction_on g $ \u03bb \u27e8s, z\u27e9, congr_arg (quot.mk _) $\n    by simp only [add_assoc, mul_assoc, nat.iterate\u2082 (frobenius_mul _ _),\n      (nat.iterate_add _ _ _ _).symm, add_comm, add_left_comm],\n  one := quot.mk _ (0, 1),\n  one_mul := \u03bb e, quot.induction_on e (\u03bb \u27e8n, x\u27e9, congr_arg (quot.mk _) $\n    by simp only [nat.iterate\u2080 (frobenius_one _ _), nat.iterate_zero, one_mul, zero_add]),\n  mul_one := \u03bb e, quot.induction_on e (\u03bb \u27e8n, x\u27e9, congr_arg (quot.mk _) $\n    by simp only [nat.iterate\u2080 (frobenius_one _ _), nat.iterate_zero, mul_one, add_zero]),\n  mul_comm := \u03bb e f, quot.induction_on e (\u03bb \u27e8m, x\u27e9, quot.induction_on f (\u03bb \u27e8n, y\u27e9,\n    congr_arg (quot.mk _) $ by simp only [add_comm, mul_comm])),\n  .. (infer_instance : has_mul (perfect_closure \u03b1 p)) }\n\nprivate lemma add_aux_left [comm_ring \u03b1] (p : \u2115) (hp : nat.prime p) [char_p \u03b1 p]\n  (x1 x2 y : \u2115 \u00d7 \u03b1) (H : r \u03b1 p x1 x2) :\n  quot.mk (r \u03b1 p) (x1.1 + y.1, ((frobenius \u03b1 p)^[y.1] x1.2) + ((frobenius \u03b1 p)^[x1.1] y.2)) =\n  quot.mk (r \u03b1 p) (x2.1 + y.1, ((frobenius \u03b1 p)^[y.1] x2.2) + ((frobenius \u03b1 p)^[x2.1] y.2)) :=\nmatch x1, x2, H with\n| _, _, r.intro _ n x := quot.sound $ by rw [\u2190 nat.iterate_succ, nat.iterate_succ',\n    nat.iterate_succ', \u2190 frobenius_add, nat.succ_add]; apply r.intro\nend\n\nprivate lemma add_aux_right [comm_ring \u03b1] (p : \u2115) (hp : nat.prime p) [char_p \u03b1 p]\n  (x y1 y2 : \u2115 \u00d7 \u03b1) (H : r \u03b1 p y1 y2) :\n  quot.mk (r \u03b1 p) (x.1 + y1.1, ((frobenius \u03b1 p)^[y1.1] x.2) + ((frobenius \u03b1 p)^[x.1] y1.2)) =\n  quot.mk (r \u03b1 p) (x.1 + y2.1, ((frobenius \u03b1 p)^[y2.1] x.2) + ((frobenius \u03b1 p)^[x.1] y2.2)) :=\nmatch y1, y2, H with\n| _, _, r.intro _ n y := quot.sound $ by rw [\u2190 nat.iterate_succ, nat.iterate_succ',\n    nat.iterate_succ', \u2190 frobenius_add]; apply r.intro\nend\n\ninstance [comm_ring \u03b1] (p : \u2115) [hp : nat.prime p] [char_p \u03b1 p] : has_add (perfect_closure \u03b1 p) :=\n\u27e8quot.lift (\u03bb x:\u2115\u00d7\u03b1, quot.lift (\u03bb y:\u2115\u00d7\u03b1, quot.mk (r \u03b1 p)\n    (x.1 + y.1, ((frobenius \u03b1 p)^[y.1] x.2) + ((frobenius \u03b1 p)^[x.1] y.2))) (add_aux_right \u03b1 p hp x))\n  (\u03bb x1 x2 (H : r \u03b1 p x1 x2), funext $ \u03bb e, quot.induction_on e $ \u03bb y,\nadd_aux_left \u03b1 p hp x1 x2 y H)\u27e9\n\ninstance [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] : has_neg (perfect_closure \u03b1 p) :=\n\u27e8quot.lift (\u03bb x:\u2115\u00d7\u03b1, quot.mk (r \u03b1 p) (x.1, -x.2)) (\u03bb x y (H : r \u03b1 p x y), match x, y, H with\n| _, _, r.intro _ n x := quot.sound $ by rw \u2190 frobenius_neg; apply r.intro\nend)\u27e9\n\ntheorem mk_zero [comm_ring \u03b1] (p : \u2115) [nat.prime p] (n : \u2115) : quot.mk (r \u03b1 p) (n, 0) = quot.mk (r \u03b1 p) (0, 0) :=\nby induction n with n ih; [refl, rw \u2190 ih]; symmetry; apply quot.sound;\nhave := r.intro p n (0:\u03b1); rwa [frobenius_zero \u03b1 p] at this\n\ntheorem r.sound [monoid \u03b1] (p m n : \u2115) (x y : \u03b1) (H : frobenius \u03b1 p^[m] x = y) :\n  quot.mk (r \u03b1 p) (n, x) = quot.mk (r \u03b1 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 \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] : comm_ring (perfect_closure \u03b1 p) :=\n{ add_assoc := \u03bb e f g, quot.induction_on e $ \u03bb \u27e8m, x\u27e9, quot.induction_on f $ \u03bb \u27e8n, y\u27e9,\n    quot.induction_on g $ \u03bb \u27e8s, z\u27e9, congr_arg (quot.mk _) $\n    by simp only [add_assoc, nat.iterate\u2082 (frobenius_add \u03b1 p),\n      (nat.iterate_add _ _ _ _).symm, add_comm, add_left_comm],\n  zero := quot.mk _ (0, 0),\n  zero_add := \u03bb e, quot.induction_on e (\u03bb \u27e8n, x\u27e9, congr_arg (quot.mk _) $\n    by simp only [nat.iterate\u2080 (frobenius_zero \u03b1 p), nat.iterate_zero, zero_add]),\n  add_zero := \u03bb e, quot.induction_on e (\u03bb \u27e8n, x\u27e9, congr_arg (quot.mk _) $\n    by simp only [nat.iterate\u2080 (frobenius_zero \u03b1 p), nat.iterate_zero, add_zero]),\n  add_left_neg := \u03bb e, quot.induction_on e (\u03bb \u27e8n, x\u27e9, show quot.mk _ _ = _,\n    by simp only [nat.iterate\u2081 (frobenius_neg \u03b1 p), add_left_neg, mk_zero]; refl),\n  add_comm := \u03bb e f, quot.induction_on e (\u03bb \u27e8m, x\u27e9, quot.induction_on f (\u03bb \u27e8n, y\u27e9,\n    congr_arg (quot.mk _) $ by simp only [add_comm])),\n  left_distrib := \u03bb e f g, quot.induction_on e $ \u03bb \u27e8m, x\u27e9, quot.induction_on f $ \u03bb \u27e8n, y\u27e9,\n    quot.induction_on g $ \u03bb \u27e8s, z\u27e9, show quot.mk _ _ = quot.mk _ _,\n    by simp only [add_assoc, add_comm, add_left_comm]; apply r.sound;\n    simp only [nat.iterate\u2082 (frobenius_mul \u03b1 p), nat.iterate\u2082 (frobenius_add \u03b1 p),\n      (nat.iterate_add _ _ _ _).symm, mul_add, add_comm, add_left_comm],\n  right_distrib := \u03bb e f g, quot.induction_on e $ \u03bb \u27e8m, x\u27e9, quot.induction_on f $ \u03bb \u27e8n, y\u27e9,\n    quot.induction_on g $ \u03bb \u27e8s, z\u27e9, 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\u2082 (frobenius_mul \u03b1 p), nat.iterate\u2082 (frobenius_add \u03b1 p),\n      (nat.iterate_add _ _ _ _).symm, add_mul, add_comm, add_left_comm],\n  .. (infer_instance : has_add (perfect_closure \u03b1 p)),\n  .. (infer_instance : has_neg (perfect_closure \u03b1 p)),\n  .. (infer_instance : comm_monoid (perfect_closure \u03b1 p)) }\n\ninstance [discrete_field \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] : has_inv (perfect_closure \u03b1 p) :=\n\u27e8quot.lift (\u03bb x:\u2115\u00d7\u03b1, quot.mk (r \u03b1 p) (x.1, x.2\u207b\u00b9)) (\u03bb x y (H : r \u03b1 p x y), match x, y, H with\n| _, _, r.intro _ n x := quot.sound $ by simp only [frobenius]; rw [\u2190 inv_pow']; apply r.intro\nend)\u27e9\n\ntheorem eq_iff' [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p]\n  (x y : \u2115 \u00d7 \u03b1) : quot.mk (r \u03b1 p) x = quot.mk (r \u03b1 p) y \u2194\n    \u2203 z, (frobenius \u03b1 p^[y.1 + z] x.2) = (frobenius \u03b1 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 \u27e80, rfl\u27e9 },\n    case eqv_gen.refl : H\n    { exact \u27e80, rfl\u27e9 },\n    case eqv_gen.symm : x y H ih\n    { cases ih with w ih, exact \u27e8w, ih.symm\u27e9 },\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 [\u2190 add_assoc, nat.iterate_add, ih1],\n      rw [\u2190 nat.iterate_add, add_comm, nat.iterate_add, ih2],\n      rw [\u2190 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 \u03b1 p (n+z) m x _ rfl, r.sound \u03b1 p (m+z) n y _ rfl, H],\n  rw [add_assoc, add_comm, add_comm z]\nend\n\ntheorem eq_iff [integral_domain \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p]\n  (x y : \u2115 \u00d7 \u03b1) : quot.mk (r \u03b1 p) x = quot.mk (r \u03b1 p) y \u2194\n    (frobenius \u03b1 p^[y.1] x.2) = (frobenius \u03b1 p^[x.1] y.2) :=\n(eq_iff' \u03b1 p x y).trans \u27e8\u03bb \u27e8z, H\u27e9, nat.iterate_inj (frobenius_inj \u03b1 p) z _ _ $\n  by simpa only [add_comm, nat.iterate_add] using H,\n\u03bb H, \u27e80, H\u27e9\u27e9\n\ninstance [discrete_field \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] : discrete_field (perfect_closure \u03b1 p) :=\n{ zero_ne_one := \u03bb H, zero_ne_one ((eq_iff _ _ _ _).1 H),\n  mul_inv_cancel := \u03bb e, quot.induction_on e $ \u03bb \u27e8m, x\u27e9 H,\n    have _ := mt (eq_iff _ _ _ _).2 H, (eq_iff _ _ _ _).2\n      (by simp only [nat.iterate\u2080 (frobenius_one _ _), nat.iterate\u2080 (frobenius_zero \u03b1 p),\n        nat.iterate_zero, (nat.iterate\u2082 (frobenius_mul \u03b1 p)).symm] at this \u22a2;\n        rw [mul_inv_cancel this, nat.iterate\u2080 (frobenius_one _ _)]),\n  inv_mul_cancel := \u03bb e, quot.induction_on e $ \u03bb \u27e8m, x\u27e9 H,\n    have _ := mt (eq_iff _ _ _ _).2 H, (eq_iff _ _ _ _).2\n      (by simp only [nat.iterate\u2080 (frobenius_one _ _), nat.iterate\u2080 (frobenius_zero \u03b1 p),\n        nat.iterate_zero, (nat.iterate\u2082 (frobenius_mul \u03b1 p)).symm] at this \u22a2;\n        rw [inv_mul_cancel this, nat.iterate\u2080 (frobenius_one _ _)]),\n  has_decidable_eq := \u03bb e f, quot.rec_on_subsingleton e $ \u03bb \u27e8m, x\u27e9,\n    quot.rec_on_subsingleton f $ \u03bb \u27e8n, y\u27e9,\n    decidable_of_iff' _ (eq_iff \u03b1 p _ _),\n  inv_zero := congr_arg (quot.mk (r \u03b1 p)) (by rw [inv_zero]),\n  .. (infer_instance : has_inv (perfect_closure \u03b1 p)),\n  .. (infer_instance : comm_ring (perfect_closure \u03b1 p)) }\n\ntheorem frobenius_mk [comm_monoid \u03b1] (p : \u2115) (x : \u2115 \u00d7 \u03b1) :\n  frobenius (perfect_closure \u03b1 p) p (quot.mk (r \u03b1 p) x) = quot.mk _ (x.1, x.2^p) :=\nbegin\n  unfold frobenius, cases x with n x, dsimp only,\n  suffices : \u2200 p':\u2115, (quot.mk (r \u03b1 p) (n, x) ^ p' : perfect_closure \u03b1 p) = quot.mk (r \u03b1 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\u2080 (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\u2082 (frobenius_mul _ _)]\n  }\nend\n\ndef frobenius_equiv [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] :\n  perfect_closure \u03b1 p \u2243 perfect_closure \u03b1 p :=\n{ to_fun := frobenius (perfect_closure \u03b1 p) p,\n  inv_fun := \u03bb e, quot.lift_on e (\u03bb x, quot.mk (r \u03b1 p) (x.1 + 1, x.2)) (\u03bb x y H,\n    match x, y, H with\n    | _, _, r.intro _ n x := quot.sound (r.intro _ _ _)\n    end),\n  left_inv := \u03bb e, quot.induction_on e (\u03bb \u27e8m, x\u27e9, by rw frobenius_mk;\n    symmetry; apply quot.sound; apply r.intro),\n  right_inv := \u03bb e, quot.induction_on e (\u03bb \u27e8m, x\u27e9, by rw frobenius_mk;\n    symmetry; apply quot.sound; apply r.intro) }\n\ntheorem frobenius_equiv_apply [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] {x : perfect_closure \u03b1 p} :\n  frobenius_equiv \u03b1 p x = frobenius _ p x :=\nrfl\n\ntheorem nat_cast [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] (n x : \u2115) :\n  (x : perfect_closure \u03b1 p) = quot.mk (r \u03b1 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 \u2190 frobenius_nat_cast \u03b1 p x},\n  apply r.intro\nend\n\ntheorem int_cast [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] (x : \u2124) :\n  (x : perfect_closure \u03b1 p) = quot.mk (r \u03b1 p) (0, x) :=\nby induction x; simp only [int.cast_of_nat, int.cast_neg_succ_of_nat, nat_cast \u03b1 p 0]; refl\n\ntheorem nat_cast_eq_iff [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] (x y : \u2115) :\n  (x : perfect_closure \u03b1 p) = y \u2194 (x : \u03b1) = y :=\nbegin\n  split; intro H,\n  { rw [nat_cast \u03b1 p 0, nat_cast \u03b1 p 0, eq_iff'] at H,\n    cases H with z H,\n    simpa only [zero_add, nat.iterate\u2080 (frobenius_nat_cast \u03b1 p _)] using H },\n  rw [nat_cast \u03b1 p 0, nat_cast \u03b1 p 0, H]\nend\n\ninstance [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] : char_p (perfect_closure \u03b1 p) p :=\nbegin\n  constructor, intro x, rw \u2190 char_p.cast_eq_zero_iff \u03b1,\n  rw [\u2190 nat.cast_zero, nat_cast_eq_iff, nat.cast_zero]\nend\n\ninstance [discrete_field \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] : perfect_field (perfect_closure \u03b1 p) p :=\n{ pth_root := (frobenius_equiv \u03b1 p).symm,\n  frobenius_pth_root := (frobenius_equiv \u03b1 p).apply_inverse_apply }\n\ndef of [monoid \u03b1] (p : \u2115) (x : \u03b1) : perfect_closure \u03b1 p :=\nquot.mk _ (0, x)\n\ninstance [comm_ring \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] : is_ring_hom (of \u03b1 p) :=\n{ map_one := rfl,\n  map_mul := \u03bb x y, rfl,\n  map_add := \u03bb x y, rfl }\n\ntheorem eq_pth_root [discrete_field \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p] (m : \u2115) (x : \u03b1) :\n  quot.mk (r \u03b1 p) (m, x) = (perfect_field.pth_root p^[m] (of \u03b1 p x) : perfect_closure \u03b1 p) :=\nbegin\n  unfold of,\n  induction m with m ih, {refl},\n  rw [nat.iterate_succ', \u2190 ih]; refl\nend\n\ndef UMP [discrete_field \u03b1] (p : \u2115) [nat.prime p] [char_p \u03b1 p]\n  (\u03b2 : Type v) [discrete_field \u03b2] [char_p \u03b2 p] [perfect_field \u03b2 p] :\n  { f : \u03b1 \u2192 \u03b2 // is_ring_hom f } \u2243 { f : perfect_closure \u03b1 p \u2192 \u03b2 // is_ring_hom f } :=\n{ to_fun := \u03bb f, \u27e8\u03bb e, quot.lift_on e (\u03bb x, perfect_field.pth_root p^[x.1] (f.1 x.2))\n      (\u03bb 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    \u03bb j k, quot.induction_on j $ \u03bb \u27e8m, x\u27e9, quot.induction_on k $ \u03bb \u27e8n, y\u27e9,\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\u2081 (\u03bb x, (is_monoid_hom.map_frobenius f.1 p x).symm)).symm,\n          @nat.iterate\u2082 \u03b2 _ (*) (\u03bb x y, is_ring_hom.map_mul (perfect_field.pth_root p))];\n        rw [nat.iterate_add, nat.iterate_cancel (pth_root_frobenius \u03b2 p),\n          add_comm, nat.iterate_add, nat.iterate_cancel (pth_root_frobenius \u03b2 p)],\n    \u03bb j k, quot.induction_on j $ \u03bb \u27e8m, x\u27e9, quot.induction_on k $ \u03bb \u27e8n, y\u27e9,\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\u2081 (\u03bb x, (is_monoid_hom.map_frobenius f.1 p x).symm)).symm,\n          @nat.iterate\u2082 \u03b2 _ (+) (\u03bb x y, is_ring_hom.map_add (perfect_field.pth_root p))];\n        rw [nat.iterate_add, nat.iterate_cancel (pth_root_frobenius \u03b2 p),\n          add_comm m, nat.iterate_add, nat.iterate_cancel (pth_root_frobenius \u03b2 p)]\u27e9,\n  inv_fun := \u03bb f, \u27e8f.1 \u2218 of \u03b1 p, @@is_ring_hom.comp _ _ _ _ _ _ f.2\u27e9,\n  left_inv := \u03bb \u27e8f, hf\u27e9, subtype.eq rfl,\n  right_inv := \u03bb \u27e8f, hf\u27e9, subtype.eq $ funext $ \u03bb i, quot.induction_on i $ \u03bb \u27e8m, x\u27e9,\n    show perfect_field.pth_root p^[m] (f _) = f _,\n    by resetI; rw [eq_pth_root, @nat.iterate\u2081 _ _ _ _ f (\u03bb x:perfect_closure \u03b1 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 \u2192* 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 \u2192+ M) (n : \u2115) : nat.iterate (\u21d1f) 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 \u2192* M) (n : \u2115) (x : M) (y : M) : nat.iterate (\u21d1f) n (x * y) = nat.iterate (\u21d1f) n x * nat.iterate (\u21d1f) n y :=\n  function.semiconj\u2082.iterate (map_mul f) n x y\n\n@[simp] theorem iterate_map_inv {G : Type u_3} [group G] (f : G \u2192* G) (n : \u2115) (x : G) : nat.iterate (\u21d1f) n (x\u207b\u00b9) = (nat.iterate (\u21d1f) n x\u207b\u00b9) :=\n  function.commute.iterate_left (map_inv f) n x\n\ntheorem iterate_map_pow {M : Type u_1} [monoid M] (f : M \u2192* M) (a : M) (n : \u2115) (m : \u2115) : nat.iterate (\u21d1f) n (a ^ m) = nat.iterate (\u21d1f) 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 \u2192* G) (a : G) (n : \u2115) (m : \u2124) : nat.iterate (\u21d1f) n (a ^ m) = nat.iterate (\u21d1f) 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 \u2192+ G) (n : \u2115) (x : G) (y : G) : nat.iterate (\u21d1f) n (x - y) = nat.iterate (\u21d1f) n x - nat.iterate (\u21d1f) n y :=\n  function.semiconj\u2082.iterate (map_sub f) n x y\n\ntheorem iterate_map_smul {M : Type u_1} [add_monoid M] (f : M \u2192+ M) (n : \u2115) (m : \u2115) (x : M) : nat.iterate (\u21d1f) n (m \u2022\u2115 x) = m \u2022\u2115 nat.iterate (\u21d1f) 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 \u2192+ G) (n : \u2115) (m : \u2124) (x : G) : nat.iterate (\u21d1f) n (m \u2022\u2124 x) = m \u2022\u2124 nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) : \u21d1(f ^ n) = nat.iterate (\u21d1f) n := sorry\n\ntheorem iterate_map_one {R : Type u_5} [semiring R] (f : R \u2192+* R) (n : \u2115) : nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) : nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (x : R) (y : R) : nat.iterate (\u21d1f) n (x + y) = nat.iterate (\u21d1f) n x + nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (x : R) (y : R) : nat.iterate (\u21d1f) n (x * y) = nat.iterate (\u21d1f) n x * nat.iterate (\u21d1f) 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 \u2192+* R) (a : R) (n : \u2115) (m : \u2115) : nat.iterate (\u21d1f) n (a ^ m) = nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (m : \u2115) (x : R) : nat.iterate (\u21d1f) n (m \u2022\u2115 x) = m \u2022\u2115 nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (x : R) (y : R) : nat.iterate (\u21d1f) n (x - y) = nat.iterate (\u21d1f) n x - nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (x : R) : nat.iterate (\u21d1f) n (-x) = -nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (m : \u2124) (x : R) : nat.iterate (\u21d1f) n (m \u2022\u2124 x) = m \u2022\u2124 nat.iterate (\u21d1f) 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 : \u2115) : 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 : \u2115) : nat.iterate (Add.add a) n = Add.add (n \u2022\u2115 a) :=\n  mul_left_iterate a n\n\n@[simp] theorem mul_right_iterate {M : Type u_1} [monoid M] (a : M) (n : \u2115) : 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 : \u2115) : nat.iterate (fun (x : M) => x + a) n = fun (x : M) => x + n \u2022\u2115 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\ud835\udce4 X` on `X \u00d7 X` satisfying some conditions\nwhich makes it reasonable to say that `\u2200\u1da0 (p : X \u00d7 X) in \ud835\udce4 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 \u2208 \ud835\udce4 X \u2194 \u2203 \u03b5 > 0, { p | dist p.1 p.2 < \u03b5 } \u2286 V`\n* If `G` is an additive topological group, `V \u2208 \ud835\udce4 G \u2194 \u2203 U \u2208 \ud835\udcdd (0 : G), {p | p.2 - p.1 \u2208 U} \u2286 V`\n\nThose examples are generalizations in two different directions of the elementary example where\n`X = \u211d` and `V \u2208 \ud835\udce4 \u211d \u2194 \u2203 \u03b5 > 0, { p | |p.2 - p.1| < \u03b5 } \u2286 V` which features both the topological\ngroup structure on `\u211d` and its metric space structure.\n\nEach uniform structure on `X` induces a topology on `X` characterized by\n\n> `nhds_eq_comap_uniformity : \u2200 {x : X}, \ud835\udcdd x = comap (prod.mk x) (\ud835\udce4 X)`\n\nwhere `prod.mk x : X \u2192 X \u00d7 X := (\u03bb 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) \u2208 V` for some `V \u2208 \ud835\udce4 X`\n* a ball `ball x r` roughly corresponds to `uniform_space.ball x V := {y | (x, y) \u2208 V}`\n  for some `V \u2208 \ud835\udce4 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 \u2194 \u2200 x \u2208 s, \u2203 V \u2208 \ud835\udce4 X, ball x V \u2286 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`\u2200 (x y z : X) (r r' : \u211d), dist x y \u2264 r \u2192 dist y z \u2264 r' \u2192 dist x z \u2264 r + r'`.\nThen, for any `V` and `W` with type `set (X \u00d7 X)`, the composition `V \u25cb W : set (X \u00d7 X)` is\ndefined as `{ p : X \u00d7 X | \u2203 z, (p.1, z) \u2208 V \u2227 (z, p.2) \u2208 W }`.\nIn the metric space case, if `V = { p | dist p.1 p.2 \u2264 r }` and `W = { p | dist p.1 p.2 \u2264 r' }`\nthen the triangle inequality, as reformulated above, says `V \u25cb W` is contained in\n`{p | dist p.1 p.2 \u2264 r + r'}` which is the entourage associated to the radius `r + r'`.\nIn general we have `mem_ball_comp (h : y \u2208 ball x V) (h' : z \u2208 ball y W) : z \u2208 ball x (V \u25cb 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 `\ud835\udce4 X` to satisfy the following:\n* every `V \u2208 \ud835\udce4 X` contains the diagonal `id_rel = { p | p.1 = p.2 }`. This abstracts the fact\n  that `dist x x \u2264 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 \u2208 \ud835\udce4 X \u2192 prod.swap '' V \u2208 \ud835\udce4 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* `\u2200 V \u2208 \ud835\udce4 X, \u2203 W \u2208 \ud835\udce4 X, W \u25cb W \u2286 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##\u00a0Main 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 : \u03b1 \u2192 \u03b2` between uniform spaces\n  is uniformly continuous : `\u2200 r \u2208 \ud835\udce4 \u03b2, \u2200\u1da0 (x : \u03b1 \u00d7 \u03b1) in \ud835\udce4 \u03b1, (f x.1, f x.2) \u2208 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 `\ud835\udce4 X` for the uniformity on a uniform space `X`,\nand `\u25cb` for composition of relations, seen as terms with type `set (X \u00d7 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 (\u03b1 \u03b2 : Type*) := \u03b1 \u2192 \u03b2 \u2192 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 (\u03b1 \u00d7 \u03b1)`\ninstead of `rel \u03b1 \u03b1` because we really need sets to use the filter library, and elements\nof filters on `\u03b1 \u00d7 \u03b1` have type `set (\u03b1 \u00d7 \u03b1)`.\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 (\u03b1 \u00d7 \u03b1)`\n-/\n\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} {\u03b3 : Type _} {\u03b4 : Type _} {\u03b9 : Sort _}\n\n#print idRel /-\n/-- The identity relation, or the graph of the identity function -/\ndef idRel {\u03b1 : Type _} :=\n  { p : \u03b1 \u00d7 \u03b1 | p.1 = p.2 }\n#align id_rel idRel\n-/\n\n#print mem_idRel /-\n@[simp]\ntheorem mem_idRel {a b : \u03b1} : (a, b) \u2208 @idRel \u03b1 \u2194 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 (\u03b1 \u00d7 \u03b1)} : idRel \u2286 s \u2194 \u2200 a, (a, a) \u2208 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 {\u03b1 : Type u} (r\u2081 r\u2082 : Set (\u03b1 \u00d7 \u03b1)) :=\n  { p : \u03b1 \u00d7 \u03b1 | \u2203 z : \u03b1, (p.1, z) \u2208 r\u2081 \u2227 (z, p.2) \u2208 r\u2082 }\n#align comp_rel compRel\n-/\n\n-- mathport name: uniformity.comp_rel\nscoped[uniformity] infixl:55 \" \u25cb \" => compRel\n\n#print mem_compRel /-\n@[simp]\ntheorem mem_compRel {r\u2081 r\u2082 : Set (\u03b1 \u00d7 \u03b1)} {x y : \u03b1} :\n    (x, y) \u2208 r\u2081 \u25cb r\u2082 \u2194 \u2203 z, (x, z) \u2208 r\u2081 \u2227 (z, y) \u2208 r\u2082 :=\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 \u03b1 :=\n  Set.ext fun \u27e8a, b\u27e9 => 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u2} \u03b2] {f : \u03b2 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))} {g : \u03b2 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Monotone.{u2, u1} \u03b2 (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) f) -> (Monotone.{u2, u1} \u03b2 (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) g) -> (Monotone.{u2, u1} \u03b2 (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) (fun (x : \u03b2) => compRel.{u1} \u03b1 (f x) (g x)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Preorder.{u2} \u03b2] {f : \u03b2 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))} {g : \u03b2 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Monotone.{u2, u1} \u03b2 (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) f) -> (Monotone.{u2, u1} \u03b2 (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) g) -> (Monotone.{u2, u1} \u03b2 (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) _inst_1 (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) (fun (x : \u03b2) => compRel.{u1} \u03b1 (f x) (g x)))\nCase conversion may be inaccurate. Consider using '#align monotone.comp_rel Monotone.compRel\u2093'. -/\ntheorem Monotone.compRel [Preorder \u03b2] {f g : \u03b2 \u2192 Set (\u03b1 \u00d7 \u03b1)} (hf : Monotone f) (hg : Monotone g) :\n    Monotone fun x => f x \u25cb g x := fun a b h p \u27e8z, h\u2081, h\u2082\u27e9 => \u27e8z, hf h h\u2081, hg h h\u2082\u27e9\n#align monotone.comp_rel Monotone.compRel\n\n#print compRel_mono /-\n@[mono]\ntheorem compRel_mono {f g h k : Set (\u03b1 \u00d7 \u03b1)} (h\u2081 : f \u2286 h) (h\u2082 : g \u2286 k) : f \u25cb g \u2286 h \u25cb k :=\n  fun \u27e8x, y\u27e9 \u27e8z, h, h'\u27e9 => \u27e8z, h\u2081 h, h\u2082 h'\u27e9\n#align comp_rel_mono compRel_mono\n-/\n\n#print prod_mk_mem_compRel /-\ntheorem prod_mk_mem_compRel {a b c : \u03b1} {s t : Set (\u03b1 \u00d7 \u03b1)} (h\u2081 : (a, c) \u2208 s) (h\u2082 : (c, b) \u2208 t) :\n    (a, b) \u2208 s \u25cb t :=\n  \u27e8c, h\u2081, h\u2082\u27e9\n#align prod_mk_mem_comp_rel prod_mk_mem_compRel\n-/\n\n#print id_compRel /-\n@[simp]\ntheorem id_compRel {r : Set (\u03b1 \u00d7 \u03b1)} : idRel \u25cb r = r :=\n  Set.ext fun \u27e8a, b\u27e9 => by simp\n#align id_comp_rel id_compRel\n-/\n\n#print compRel_assoc /-\ntheorem compRel_assoc {r s t : Set (\u03b1 \u00d7 \u03b1)} : r \u25cb s \u25cb t = r \u25cb (s \u25cb 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 (\u03b1 \u00d7 \u03b1)} (h : idRel \u2286 t) : s \u2286 s \u25cb t := fun \u27e8x, y\u27e9 xy_in =>\n  \u27e8y, xy_in, h <| rfl\u27e9\n#align left_subset_comp_rel left_subset_compRel\n-/\n\n#print right_subset_compRel /-\ntheorem right_subset_compRel {s t : Set (\u03b1 \u00d7 \u03b1)} (h : idRel \u2286 s) : t \u2286 s \u25cb t := fun \u27e8x, y\u27e9 xy_in =>\n  \u27e8x, h <| rfl, xy_in\u27e9\n#align right_subset_comp_rel right_subset_compRel\n-/\n\n#print subset_comp_self /-\ntheorem subset_comp_self {s : Set (\u03b1 \u00d7 \u03b1)} (h : idRel \u2286 s) : s \u2286 s \u25cb 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 (\u03b1 \u00d7 \u03b1)} (h : idRel \u2286 s) (n : \u2115) :\n    t \u2286 ((\u00b7 \u25cb \u00b7) 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 (\u03b1 \u00d7 \u03b1)) : Prop :=\n  Prod.swap \u207b\u00b9' 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 (\u03b1 \u00d7 \u03b1)) : Set (\u03b1 \u00d7 \u03b1) :=\n  V \u2229 Prod.swap \u207b\u00b9' V\n#align symmetrize_rel symmetrizeRel\n-/\n\n#print symmetric_symmetrizeRel /-\ntheorem symmetric_symmetrizeRel (V : Set (\u03b1 \u00d7 \u03b1)) : SymmetricRel (symmetrizeRel V) := by\n  simp [SymmetricRel, symmetrizeRel, preimage_inter, inter_comm, \u2190 preimage_comp]\n#align symmetric_symmetrize_rel symmetric_symmetrizeRel\n-/\n\n#print symmetrizeRel_subset_self /-\ntheorem symmetrizeRel_subset_self (V : Set (\u03b1 \u00d7 \u03b1)) : symmetrizeRel V \u2286 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 (\u03b1 \u00d7 \u03b1)} (h : V \u2286 W) : symmetrizeRel V \u2286 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 (\u03b1 \u00d7 \u03b1)} (hV : SymmetricRel V) {x y : \u03b1} :\n    (x, y) \u2208 V \u2194 (y, x) \u2208 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 (\u03b1 \u00d7 \u03b1)} (hU : SymmetricRel U) : Prod.swap \u207b\u00b9' 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 {\u03b1 : Type.{u1}} {U : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)} {V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (SymmetricRel.{u1} \u03b1 U) -> (SymmetricRel.{u1} \u03b1 V) -> (SymmetricRel.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasInter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) U V))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {U : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)} {V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (SymmetricRel.{u1} \u03b1 U) -> (SymmetricRel.{u1} \u03b1 V) -> (SymmetricRel.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instInterSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) U V))\nCase conversion may be inaccurate. Consider using '#align symmetric_rel.inter SymmetricRel.inter\u2093'. -/\ntheorem SymmetricRel.inter {U V : Set (\u03b1 \u00d7 \u03b1)} (hU : SymmetricRel U) (hV : SymmetricRel V) :\n    SymmetricRel (U \u2229 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 (\u03b1 : Type u) where\n  uniformity : Filter (\u03b1 \u00d7 \u03b1)\n  refl : \ud835\udcdf idRel \u2264 uniformity\n  symm : Tendsto Prod.swap uniformity uniformity\n  comp : (uniformity.lift' fun s => s \u25cb s) \u2264 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 {\u03b1 : Type.{u1}} (U : Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r U) -> (forall (x : \u03b1), Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x x) r)) -> (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r U) -> (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.preimage.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) r) U)) -> (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r U) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t U) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t U) => HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) r)))) -> (UniformSpace.Core.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (U : Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r U) -> (forall (x : \u03b1), Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x x) r)) -> (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r U) -> (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.preimage.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) r) U)) -> (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r U) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t U) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) r)))) -> (UniformSpace.Core.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align uniform_space.core.mk' UniformSpace.Core.mk'\u2093'. -/\n/-- An alternative constructor for `uniform_space.core`. This version unfolds various\n`filter`-related definitions. -/\ndef UniformSpace.Core.mk' {\u03b1 : Type u} (U : Filter (\u03b1 \u00d7 \u03b1)) (refl : \u2200 r \u2208 U, \u2200 (x), (x, x) \u2208 r)\n    (symm : \u2200 r \u2208 U, Prod.swap \u207b\u00b9' r \u2208 U) (comp : \u2200 r \u2208 U, \u2203 t \u2208 U, t \u25cb t \u2286 r) :\n    UniformSpace.Core \u03b1 :=\n  \u27e8U, fun r ru => idRel_subset.2 (refl _ ru), symm, fun r ru =>\n    let \u27e8s, hs, hsr\u27e9 := comp _ ru\n    mem_of_superset (mem_lift' hs) hsr\u27e9\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 {\u03b1 : Type.{u1}} (B : FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r B) -> (forall (x : \u03b1), Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x x) r)) -> (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t B) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t B) => HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (Set.preimage.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) r))))) -> (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t B) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t B) => HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) r)))) -> (UniformSpace.Core.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} (B : FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r B) -> (forall (x : \u03b1), Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x x) r)) -> (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t B) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (Set.preimage.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) r))))) -> (forall (r : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) r B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (FilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilterBasis.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t B) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) r)))) -> (UniformSpace.Core.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align uniform_space.core.mk_of_basis UniformSpace.Core.mkOfBasis\u2093'. -/\n/-- Defining an `uniform_space.core` from a filter basis satisfying some uniformity-like axioms. -/\ndef UniformSpace.Core.mkOfBasis {\u03b1 : Type u} (B : FilterBasis (\u03b1 \u00d7 \u03b1))\n    (refl : \u2200 r \u2208 B, \u2200 (x), (x, x) \u2208 r) (symm : \u2200 r \u2208 B, \u2203 t \u2208 B, t \u2286 Prod.swap \u207b\u00b9' r)\n    (comp : \u2200 r \u2208 B, \u2203 t \u2208 B, t \u25cb t \u2286 r) : UniformSpace.Core \u03b1\n    where\n  uniformity := B.filter\u2093\n  refl := B.HasBasis.ge_iff.mpr fun r ru => idRel_subset.2 <| refl _ ru\n  symm := (B.HasBasis.tendsto_iff\u2093 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 {\u03b1 : Type u} (u : UniformSpace.Core \u03b1) : TopologicalSpace \u03b1\n    where\n  IsOpen s := \u2200 x \u2208 s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 u.uniformity\n  isOpen_univ := by simp <;> intro <;> exact univ_mem\n  isOpen_inter := fun s t hs ht x \u27e8xs, xt\u27e9 => by\n    filter_upwards [hs x xs, ht x xt] <;> simp (config := { contextual := true })\n  isOpen_union\u209b := fun s hs x \u27e8t, ts, xt\u27e9 => by\n    filter_upwards [hs t ts x xt]with p ph h using\u27e8t, ts, ph h\u27e9\n#align uniform_space.core.to_topological_space UniformSpace.Core.toTopologicalSpace\n-/\n\n#print UniformSpace.core_eq /-\ntheorem UniformSpace.core_eq :\n    \u2200 {u\u2081 u\u2082 : UniformSpace.Core \u03b1}, u\u2081.uniformity = u\u2082.uniformity \u2192 u\u2081 = u\u2082\n  | \u27e8u\u2081, _, _, _\u27e9, \u27e8u\u2082, _, _, _\u27e9, 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 `\u03b1 \u00d7 \u03b1` 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 (\u03b1 : Type u) extends TopologicalSpace \u03b1, UniformSpace.Core \u03b1 where\n  isOpen_uniformity :\n    \u2200 s, @IsOpen _ to_topological_space s \u2194 \u2200 x \u2208 s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 uniformity\n#align uniform_space UniformSpace\n-/\n\n#print UniformSpace.mk' /-\n/-- Alternative constructor for `uniform_space \u03b1` when a topology is already given. -/\n@[match_pattern]\ndef UniformSpace.mk' {\u03b1} (t : TopologicalSpace \u03b1) (c : UniformSpace.Core \u03b1)\n    (is_open_uniformity :\n      \u2200 s : Set \u03b1, IsOpen s \u2194 \u2200 x \u2208 s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 c.uniformity) :\n    UniformSpace \u03b1 :=\n  \u27e8c, isOpen_uniformity\u27e9\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 {\u03b1 : Type u} (u : UniformSpace.Core \u03b1) : UniformSpace \u03b1\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 {\u03b1 : Type u} (u : UniformSpace.Core \u03b1) (t : TopologicalSpace \u03b1)\n    (h : t = u.toTopologicalSpace) : UniformSpace \u03b1\n    where\n  toCore := u\n  toTopologicalSpace := t\n  isOpen_uniformity a := h.symm \u25b8 Iff.rfl\n#align uniform_space.of_core_eq UniformSpace.ofCoreEq\n-/\n\n#print UniformSpace.toCore_toTopologicalSpace /-\ntheorem UniformSpace.toCore_toTopologicalSpace (u : UniformSpace \u03b1) :\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 \u03b1 \u00d7 \u03b1 (inferred from an ambient uniform space\n  structure on \u03b1). -/\ndef uniformity (\u03b1 : Type u) [UniformSpace \u03b1] : Filter (\u03b1 \u00d7 \u03b1) :=\n  (@UniformSpace.toCore \u03b1 _).uniformity\n#align uniformity uniformity\n-/\n\n-- mathport name: uniformity_of\nscoped[Topology] notation \"\ud835\udce4[\" u \"]\" => @uniformity hole! u\n\n#print uniformSpace_eq /-\n@[ext]\ntheorem uniformSpace_eq : \u2200 {u\u2081 u\u2082 : UniformSpace \u03b1}, \ud835\udce4[u\u2081] = \ud835\udce4[u\u2082] \u2192 u\u2081 = u\u2082\n  | UniformSpace.mk' t\u2081 u\u2081 o\u2081, UniformSpace.mk' t\u2082 u\u2082 o\u2082, h =>\n    by\n    have : u\u2081 = u\u2082 := UniformSpace.core_eq h\n    have : t\u2081 = t\u2082 := topologicalSpace_eq <| funext fun s => by rw [o\u2081, o\u2082] <;> simp [this]\n    simp [*]\n#align uniform_space_eq uniformSpace_eq\n-/\n\n#print UniformSpace.ofCoreEq_toCore /-\ntheorem UniformSpace.ofCoreEq_toCore (u : UniformSpace \u03b1) (t : TopologicalSpace \u03b1)\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 {\u03b1 : Type _} [i : TopologicalSpace \u03b1] (u : UniformSpace \u03b1)\n    (h : i = u.toTopologicalSpace) : UniformSpace \u03b1 :=\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 {\u03b1 : Type _} [i : TopologicalSpace \u03b1] (u : UniformSpace \u03b1)\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : OrderedAddCommMonoid.{u2} \u03b2] (d : \u03b1 -> \u03b1 -> \u03b2), (forall (x : \u03b1), Eq.{succ u2} \u03b2 (d x x) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))))) -> (forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (d x y) (d y x)) -> (forall (x : \u03b1) (y : \u03b1) (z : \u03b1), LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) (d x z) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1))))) (d x y) (d y z))) -> (forall (\u03b5 : \u03b2), (GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) \u03b5 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))))) -> (Exists.{succ u2} \u03b2 (fun (\u03b4 : \u03b2) => Exists.{0} (GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) \u03b4 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))))) (fun (H : GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) \u03b4 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))))) => forall (x : \u03b2), (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) x \u03b4) -> (forall (y : \u03b2), (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) y \u03b4) -> (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1))))) x y) \u03b5)))))) -> (UniformSpace.{u1} \u03b1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : OrderedAddCommMonoid.{u2} \u03b2] (d : \u03b1 -> \u03b1 -> \u03b2), (forall (x : \u03b1), Eq.{succ u2} \u03b2 (d x x) (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddMonoid.toZero.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))) -> (forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (d x y) (d y x)) -> (forall (x : \u03b1) (y : \u03b1) (z : \u03b1), LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) (d x z) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1))))) (d x y) (d y z))) -> (forall (\u03b5 : \u03b2), (GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) \u03b5 (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddMonoid.toZero.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))) -> (Exists.{succ u2} \u03b2 (fun (\u03b4 : \u03b2) => And (GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) \u03b4 (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddMonoid.toZero.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))) (forall (x : \u03b2), (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) x \u03b4) -> (forall (y : \u03b2), (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) y \u03b4) -> (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 _inst_1))) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1))))) x y) \u03b5)))))) -> (UniformSpace.{u1} \u03b1)\nCase conversion may be inaccurate. Consider using '#align uniform_space.of_fun UniformSpace.ofFun\u2093'. -/\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 {\u03b1 \u03b2 : Type _} [OrderedAddCommMonoid \u03b2] (d : \u03b1 \u2192 \u03b1 \u2192 \u03b2)\n    (refl : \u2200 x, d x x = 0) (symm : \u2200 x y, d x y = d y x)\n    (triangle : \u2200 x y z, d x z \u2264 d x y + d y z)\n    (half : \u2200 \u03b5 > (0 : \u03b2), \u2203 \u03b4 > (0 : \u03b2), \u2200 x < \u03b4, \u2200 y < \u03b4, x + y < \u03b5) : UniformSpace \u03b1 :=\n  UniformSpace.ofCore\n    { uniformity := \u2a05 r > 0, \ud835\udcdf { x | d x.1 x.2 < r }\n      refl := le_inf\u1d62\u2082 fun r hr => principal_mono.2 <| idRel_subset.2 fun x => by simpa [refl]\n      symm :=\n        tendsto_inf\u1d62_inf\u1d62 fun r =>\n          tendsto_inf\u1d62_inf\u1d62 fun _ =>\n            tendsto_principal_principal.2 fun x hx => by rwa [mem_set_of, symm]\n      comp :=\n        le_inf\u1d62\u2082 fun r hr =>\n          let \u27e8\u03b4, h0, h\u03b4r\u27e9 := half r hr\n          le_principal_iff.2 <|\n            mem_of_superset\n              (mem_lift' <| mem_inf\u1d62_of_mem \u03b4 <| mem_inf\u1d62_of_mem h0 <| mem_principal_self _)\n              fun \u27e8x, z\u27e9 \u27e8y, h\u2081, h\u2082\u27e9 => (triangle _ _ _).trans_lt (h\u03b4r _ h\u2081 _ h\u2082) }\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrderedAddCommMonoid.{u2} \u03b2], (Exists.{succ u2} \u03b2 (fun (x : \u03b2) => LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))))))) x)) -> (forall (d : \u03b1 -> \u03b1 -> \u03b2) (refl : forall (x : \u03b1), Eq.{succ u2} \u03b2 (d x x) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1))))))))) (symm : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (d x y) (d y x)) (triangle : forall (x : \u03b1) (y : \u03b1) (z : \u03b1), LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (d x z) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))))) (d x y) (d y z))) (half : forall (\u03b5 : \u03b2), (GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) \u03b5 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1))))))))) -> (Exists.{succ u2} \u03b2 (fun (\u03b4 : \u03b2) => Exists.{0} (GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) \u03b4 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1))))))))) (fun (H : GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) \u03b4 (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1))))))))) => forall (x : \u03b2), (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) x \u03b4) -> (forall (y : \u03b2), (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) y \u03b4) -> (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toHasAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))))) x y) \u03b5)))))), Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 (UniformSpace.ofFun.{u1, u2} \u03b1 \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1) d refl symm triangle half)) (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (OfNat.ofNat.{u2} \u03b2 0 (OfNat.mk.{u2} \u03b2 0 (Zero.zero.{u2} \u03b2 (AddZeroClass.toHasZero.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (OrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1))))))))) (fun (\u03b5 : \u03b2) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (d (Prod.fst.{u1, u1} \u03b1 \u03b1 x) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) \u03b5)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrderedAddCommMonoid.{u2} \u03b2], (Exists.{succ u2} \u03b2 (fun (x : \u03b2) => LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddMonoid.toZero.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1))))) x)) -> (forall (d : \u03b1 -> \u03b1 -> \u03b2) (refl : forall (x : \u03b1), Eq.{succ u2} \u03b2 (d x x) (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddMonoid.toZero.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))) (symm : forall (x : \u03b1) (y : \u03b1), Eq.{succ u2} \u03b2 (d x y) (d y x)) (triangle : forall (x : \u03b1) (y : \u03b1) (z : \u03b1), LE.le.{u2} \u03b2 (Preorder.toLE.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (d x z) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1))))) (d x y) (d y z))) (half : forall (\u03b5 : \u03b2), (GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) \u03b5 (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddMonoid.toZero.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))) -> (Exists.{succ u2} \u03b2 (fun (\u03b4 : \u03b2) => And (GT.gt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) \u03b4 (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddMonoid.toZero.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1)))))) (forall (x : \u03b2), (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) x \u03b4) -> (forall (y : \u03b2), (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) y \u03b4) -> (LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (HAdd.hAdd.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHAdd.{u2} \u03b2 (AddZeroClass.toAdd.{u2} \u03b2 (AddMonoid.toAddZeroClass.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1))))) x y) \u03b5)))))), Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 (UniformSpace.ofFun.{u1, u2} \u03b1 \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1) d refl symm triangle half)) (fun (x._@.Mathlib.Topology.UniformSpace.Basic._hyg.4156 : \u03b2) => LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (OfNat.ofNat.{u2} \u03b2 0 (Zero.toOfNat0.{u2} \u03b2 (AddMonoid.toZero.{u2} \u03b2 (AddCommMonoid.toAddMonoid.{u2} \u03b2 (LinearOrderedAddCommMonoid.toAddCommMonoid.{u2} \u03b2 _inst_1))))) x._@.Mathlib.Topology.UniformSpace.Basic._hyg.4156) (fun (\u03b5 : \u03b2) => setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u1, u1} \u03b1 \u03b1) => LT.lt.{u2} \u03b2 (Preorder.toLT.{u2} \u03b2 (PartialOrder.toPreorder.{u2} \u03b2 (OrderedAddCommMonoid.toPartialOrder.{u2} \u03b2 (LinearOrderedAddCommMonoid.toOrderedAddCommMonoid.{u2} \u03b2 _inst_1)))) (d (Prod.fst.{u1, u1} \u03b1 \u03b1 x) (Prod.snd.{u1, u1} \u03b1 \u03b1 x)) \u03b5)))\nCase conversion may be inaccurate. Consider using '#align uniform_space.has_basis_of_fun UniformSpace.hasBasis_ofFun\u2093'. -/\ntheorem UniformSpace.hasBasis_ofFun {\u03b1 \u03b2 : Type _} [LinearOrderedAddCommMonoid \u03b2]\n    (h\u2080 : \u2203 x : \u03b2, 0 < x) (d : \u03b1 \u2192 \u03b1 \u2192 \u03b2) (refl : \u2200 x, d x x = 0) (symm : \u2200 x y, d x y = d y x)\n    (triangle : \u2200 x y z, d x z \u2264 d x y + d y z)\n    (half : \u2200 \u03b5 > (0 : \u03b2), \u2203 \u03b4 > (0 : \u03b2), \u2200 x < \u03b4, \u2200 y < \u03b4, x + y < \u03b5) :\n    \ud835\udce4[UniformSpace.ofFun d refl symm triangle half].HasBasis ((\u00b7 < \u00b7) (0 : \u03b2)) fun \u03b5 =>\n      { x | d x.1 x.2 < \u03b5 } :=\n  hasBasis_binf\u1d62_principal'\n    (fun \u03b5\u2081 h\u2081 \u03b5\u2082 h\u2082 =>\n      \u27e8min \u03b5\u2081 \u03b5\u2082, lt_min h\u2081 h\u2082, 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 _ _)\u27e9)\n    h\u2080\n#align uniform_space.has_basis_of_fun UniformSpace.hasBasis_ofFun\n\nsection UniformSpace\n\nvariable [UniformSpace \u03b1]\n\n-- mathport name: uniformity\nscoped[uniformity] notation \"\ud835\udce4\" => uniformity\n\n#print isOpen_uniformity /-\ntheorem isOpen_uniformity {s : Set \u03b1} :\n    IsOpen s \u2194 \u2200 x \u2208 s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 \ud835\udce4 \u03b1 :=\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (Filter.principal.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (idRel.{u1} \u03b1)) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (Filter.principal.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (idRel.{u1} \u03b1)) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align refl_le_uniformity refl_le_uniformity\u2093'. -/\ntheorem refl_le_uniformity : \ud835\udcdf idRel \u2264 \ud835\udce4 \u03b1 :=\n  (@UniformSpace.toCore \u03b1 _).refl\n#align refl_le_uniformity refl_le_uniformity\n\n#print uniformity.neBot /-\ninstance uniformity.neBot [Nonempty \u03b1] : NeBot (\ud835\udce4 \u03b1) :=\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 : \u03b1} {s : Set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) : (x, x) \u2208 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 : \u03b1} {s : Set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) (hx : x = y) : (x, y) \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (Filter.map.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1)) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (Filter.map.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1)) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align symm_le_uniformity symm_le_uniformity\u2093'. -/\ntheorem symm_le_uniformity : map (@Prod.swap \u03b1 \u03b1) (\ud835\udce4 _) \u2264 \ud835\udce4 _ :=\n  (@UniformSpace.toCore \u03b1 _).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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (Filter.lift'.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => compRel.{u1} \u03b1 s s)) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (Filter.lift'.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => compRel.{u1} \u03b1 s s)) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align comp_le_uniformity comp_le_uniformity\u2093'. -/\ntheorem comp_le_uniformity : ((\ud835\udce4 \u03b1).lift' fun s : Set (\u03b1 \u00d7 \u03b1) => s \u25cb s) \u2264 \ud835\udce4 \u03b1 :=\n  (@UniformSpace.toCore \u03b1 _).comp\n#align comp_le_uniformity comp_le_uniformity\n\n#print tendsto_swap_uniformity /-\ntheorem tendsto_swap_uniformity : Tendsto (@Prod.swap \u03b1 \u03b1) (\ud835\udce4 \u03b1) (\ud835\udce4 \u03b1) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) => HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) s)))\nCase conversion may be inaccurate. Consider using '#align comp_mem_uniformity_sets comp_mem_uniformity_sets\u2093'. -/\ntheorem comp_mem_uniformity_sets {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) : \u2203 t \u2208 \ud835\udce4 \u03b1, t \u25cb t \u2286 s :=\n  have : s \u2208 (\ud835\udce4 \u03b1).lift' fun t : Set (\u03b1 \u00d7 \u03b1) => t \u25cb 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 \u2208 \ud835\udce4 \u03b1`, then for any natural `n`, for a subset `t` of a sufficiently small set in `\ud835\udce4 \u03b1`,\nwe have `t \u25cb t \u25cb ... \u25cb t \u2286 s` (`n` compositions). -/\ntheorem eventually_uniformity_iterate_comp_subset {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) (n : \u2115) :\n    \u2200\u1da0 t in (\ud835\udce4 \u03b1).smallSets, ((\u00b7 \u25cb \u00b7) t^[n]) t \u2286 s :=\n  by\n  suffices : \u2200\u1da0 t in (\ud835\udce4 \u03b1).smallSets, t \u2286 s \u2227 ((\u00b7 \u25cb \u00b7) t^[n]) t \u2286 s\n  exact (eventually_and.1 this).2\n  induction' n with n ihn generalizing s; \u00b7 simpa\n  rcases comp_mem_uniformity_sets hs with \u27e8t, htU, hts\u27e9\n  refine' (ihn htU).mono fun U hU => _\n  rw [Function.iterate_succ_apply']\n  exact\n    \u27e8hU.1.trans <| (subset_comp_self <| refl_le_uniformity htU).trans hts,\n      (compRel_mono hU.1 hU.2).trans hts\u27e9\n#align eventually_uniformity_iterate_comp_subset eventually_uniformity_iterate_comp_subset\n-/\n\n#print eventually_uniformity_comp_subset /-\n/-- If `s \u2208 \ud835\udce4 \u03b1`, then for any natural `n`, for a subset `t` of a sufficiently small set in `\ud835\udce4 \u03b1`,\nwe have `t \u25cb t \u2286 s`. -/\ntheorem eventually_uniformity_comp_subset {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n    \u2200\u1da0 t in (\ud835\udce4 \u03b1).smallSets, t \u25cb t \u2286 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 `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is transitive. -/\ntheorem Filter.Tendsto.uniformity_trans {l : Filter \u03b2} {f\u2081 f\u2082 f\u2083 : \u03b2 \u2192 \u03b1}\n    (h\u2081\u2082 : Tendsto (fun x => (f\u2081 x, f\u2082 x)) l (\ud835\udce4 \u03b1))\n    (h\u2082\u2083 : Tendsto (fun x => (f\u2082 x, f\u2083 x)) l (\ud835\udce4 \u03b1)) : Tendsto (fun x => (f\u2081 x, f\u2083 x)) l (\ud835\udce4 \u03b1) :=\n  by\n  refine' le_trans (le_lift'.2 fun s hs => mem_map.2 _) comp_le_uniformity\n  filter_upwards [h\u2081\u2082 hs, h\u2082\u2083 hs]with x hx\u2081\u2082 hx\u2082\u2083 using\u27e8_, hx\u2081\u2082, hx\u2082\u2083\u27e9\n#align filter.tendsto.uniformity_trans Filter.Tendsto.uniformity_trans\n-/\n\n#print Filter.Tendsto.uniformity_symm /-\n/-- Relation `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is symmetric -/\ntheorem Filter.Tendsto.uniformity_symm {l : Filter \u03b2} {f : \u03b2 \u2192 \u03b1 \u00d7 \u03b1} (h : Tendsto f l (\ud835\udce4 \u03b1)) :\n    Tendsto (fun x => ((f x).2, (f x).1)) l (\ud835\udce4 \u03b1) :=\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 `\u03bb f g, tendsto (\u03bb x, (f x, g x)) l (\ud835\udce4 \u03b1)` is reflexive. -/\ntheorem tendsto_diag_uniformity (f : \u03b2 \u2192 \u03b1) (l : Filter \u03b2) :\n    Tendsto (fun x => (f x, f x)) l (\ud835\udce4 \u03b1) := 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 : \u03b1} {f : Filter \u03b2} : Tendsto (fun _ => (a, a)) f (\ud835\udce4 \u03b1) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) => And (forall (a : \u03b1) (b : \u03b1), (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) t) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 b a) t)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (And (forall (a : \u03b1) (b : \u03b1), (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) t) -> (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 b a) t)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t s))))\nCase conversion may be inaccurate. Consider using '#align symm_of_uniformity symm_of_uniformity\u2093'. -/\ntheorem symm_of_uniformity {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n    \u2203 t \u2208 \ud835\udce4 \u03b1, (\u2200 a b, (a, b) \u2208 t \u2192 (b, a) \u2208 t) \u2227 t \u2286 s :=\n  have : preimage Prod.swap s \u2208 \ud835\udce4 \u03b1 := symm_le_uniformity hs\n  \u27e8s \u2229 preimage Prod.swap s, inter_mem hs this, fun a b \u27e8h\u2081, h\u2082\u27e9 => \u27e8h\u2082, h\u2081\u27e9, inter_subset_left _ _\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) => And (forall {a : \u03b1} {b : \u03b1}, (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) t) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 b a) t)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (And (forall {a : \u03b1} {b : \u03b1}, (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) t) -> (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 b a) t)) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) s))))\nCase conversion may be inaccurate. Consider using '#align comp_symm_of_uniformity comp_symm_of_uniformity\u2093'. -/\ntheorem comp_symm_of_uniformity {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n    \u2203 t \u2208 \ud835\udce4 \u03b1, (\u2200 {a b}, (a, b) \u2208 t \u2192 (b, a) \u2208 t) \u2227 t \u25cb t \u2286 s :=\n  let \u27e8t, ht\u2081, ht\u2082\u27e9 := comp_mem_uniformity_sets hs\n  let \u27e8t', ht', ht'\u2081, ht'\u2082\u27e9 := symm_of_uniformity ht\u2081\n  \u27e8t', ht', ht'\u2081, Subset.trans (monotone_id.compRel monotone_id ht'\u2082) ht\u2082\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (uniformity.{u1} \u03b1 _inst_1) (Functor.map.{u1, u1} Filter.{u1} Filter.functor.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (uniformity.{u1} \u03b1 _inst_1) (Functor.map.{u1, u1} Filter.{u1} Filter.instFunctorFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align uniformity_le_symm uniformity_le_symm\u2093'. -/\ntheorem uniformity_le_symm : \ud835\udce4 \u03b1 \u2264 @Prod.swap \u03b1 \u03b1 <$> \ud835\udce4 \u03b1 := 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 : \ud835\udce4 \u03b1 = @Prod.swap \u03b1 \u03b1 <$> \ud835\udce4 \u03b1 :=\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 \u03b1 \u03b1) (\ud835\udce4 \u03b1) = \ud835\udce4 \u03b1 :=\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 (\u03b1 \u00d7 \u03b1)} (h : V \u2208 \ud835\udce4 \u03b1) : symmetrizeRel V \u2208 \ud835\udce4 \u03b1 :=\n  by\n  apply (\ud835\udce4 \u03b1).inter_sets h\n  rw [\u2190 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 `\ud835\udce4 \u03b1` -/\ntheorem UniformSpace.hasBasis_symmetric :\n    (\ud835\udce4 \u03b1).HasBasis (fun s : Set (\u03b1 \u00d7 \u03b1) => s \u2208 \ud835\udce4 \u03b1 \u2227 SymmetricRel s) id :=\n  hasBasis_self.2 fun t t_in =>\n    \u27e8symmetrizeRel t, symmetrize_mem_uniformity t_in, symmetric_symmetrizeRel t,\n      symmetrizeRel_subset_self t\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {g : (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) -> (Filter.{u2} \u03b2)} {f : Filter.{u2} \u03b2}, (Monotone.{u1, u2} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.partialOrder.{u2} \u03b2)) g) -> (LE.le.{u2} (Filter.{u2} \u03b2) (Preorder.toLE.{u2} (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.partialOrder.{u2} \u03b2))) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => g (Set.preimage.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) s))) f) -> (LE.le.{u2} (Filter.{u2} \u03b2) (Preorder.toLE.{u2} (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.partialOrder.{u2} \u03b2))) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) g) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {g : (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) -> (Filter.{u2} \u03b2)} {f : Filter.{u2} \u03b2}, (Monotone.{u1, u2} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.instPartialOrderFilter.{u2} \u03b2)) g) -> (LE.le.{u2} (Filter.{u2} \u03b2) (Preorder.toLE.{u2} (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.instPartialOrderFilter.{u2} \u03b2))) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => g (Set.preimage.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (Prod.swap.{u1, u1} \u03b1 \u03b1) s))) f) -> (LE.le.{u2} (Filter.{u2} \u03b2) (Preorder.toLE.{u2} (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.instPartialOrderFilter.{u2} \u03b2))) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) g) f)\nCase conversion may be inaccurate. Consider using '#align uniformity_lift_le_swap uniformity_lift_le_swap\u2093'. -/\ntheorem uniformity_lift_le_swap {g : Set (\u03b1 \u00d7 \u03b1) \u2192 Filter \u03b2} {f : Filter \u03b2} (hg : Monotone g)\n    (h : ((\ud835\udce4 \u03b1).lift fun s => g (preimage Prod.swap s)) \u2264 f) : (\ud835\udce4 \u03b1).lift g \u2264 f :=\n  calc\n    (\ud835\udce4 \u03b1).lift g \u2264 (Filter.map (@Prod.swap \u03b1 \u03b1) <| \ud835\udce4 \u03b1).lift g :=\n      lift_mono uniformity_le_symm le_rfl\n    _ \u2264 _ := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {f : (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) -> (Filter.{u2} \u03b2)}, (Monotone.{u1, u2} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.completeBooleanAlgebra.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.partialOrder.{u2} \u03b2)) f) -> (LE.le.{u2} (Filter.{u2} \u03b2) (Preorder.toLE.{u2} (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.partialOrder.{u2} \u03b2))) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => f (compRel.{u1} \u03b1 s s))) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {f : (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) -> (Filter.{u2} \u03b2)}, (Monotone.{u1, u2} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instCompleteBooleanAlgebraSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.instPartialOrderFilter.{u2} \u03b2)) f) -> (LE.le.{u2} (Filter.{u2} \u03b2) (Preorder.toLE.{u2} (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.instPartialOrderFilter.{u2} \u03b2))) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => f (compRel.{u1} \u03b1 s s))) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) f))\nCase conversion may be inaccurate. Consider using '#align uniformity_lift_le_comp uniformity_lift_le_comp\u2093'. -/\ntheorem uniformity_lift_le_comp {f : Set (\u03b1 \u00d7 \u03b1) \u2192 Filter \u03b2} (h : Monotone f) :\n    ((\ud835\udce4 \u03b1).lift fun s => f (s \u25cb s)) \u2264 (\ud835\udce4 \u03b1).lift f :=\n  calc\n    ((\ud835\udce4 \u03b1).lift fun s => f (s \u25cb s)) = ((\ud835\udce4 \u03b1).lift' fun s : Set (\u03b1 \u00d7 \u03b1) => s \u25cb s).lift f :=\n      by\n      rw [lift_lift'_assoc]\n      exact monotone_id.comp_rel monotone_id\n      exact h\n    _ \u2264 (\ud835\udce4 \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (Filter.lift'.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => compRel.{u1} \u03b1 s (compRel.{u1} \u03b1 s s))) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (Filter.lift'.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => compRel.{u1} \u03b1 s (compRel.{u1} \u03b1 s s))) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align comp_le_uniformity3 comp_le_uniformity3\u2093'. -/\ntheorem comp_le_uniformity3 : ((\ud835\udce4 \u03b1).lift' fun s : Set (\u03b1 \u00d7 \u03b1) => s \u25cb (s \u25cb s)) \u2264 \ud835\udce4 \u03b1 :=\n  calc\n    ((\ud835\udce4 \u03b1).lift' fun d => d \u25cb (d \u25cb d)) =\n        (\ud835\udce4 \u03b1).lift fun s => (\ud835\udce4 \u03b1).lift' fun t : Set (\u03b1 \u00d7 \u03b1) => s \u25cb (t \u25cb 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    _ \u2264 (\ud835\udce4 \u03b1).lift fun s => (\ud835\udce4 \u03b1).lift' fun t : Set (\u03b1 \u00d7 \u03b1) => s \u25cb t :=\n      (lift_mono' fun s hs =>\n        @uniformity_lift_le_comp \u03b1 _ _ (\ud835\udcdf \u2218 (\u00b7 \u25cb \u00b7) s) <|\n          monotone_principal.comp (monotone_const.compRel monotone_id))\n    _ = (\ud835\udce4 \u03b1).lift' fun s : Set (\u03b1 \u00d7 \u03b1) => s \u25cb s :=\n      (lift_lift'_same_eq_lift' (fun s => monotone_const.compRel monotone_id) fun s =>\n        monotone_id.compRel monotone_const)\n    _ \u2264 \ud835\udce4 \u03b1 := 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) => And (SymmetricRel.{u1} \u03b1 t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (And (SymmetricRel.{u1} \u03b1 t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) s))))\nCase conversion may be inaccurate. Consider using '#align comp_symm_mem_uniformity_sets comp_symm_mem_uniformity_sets\u2093'. -/\n/-- See also `comp_open_symm_mem_uniformity_sets`. -/\ntheorem comp_symm_mem_uniformity_sets {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n    \u2203 t \u2208 \ud835\udce4 \u03b1, SymmetricRel t \u2227 t \u25cb t \u2286 s :=\n  by\n  obtain \u27e8w, w_in, w_sub\u27e9 : \u2203 w \u2208 \ud835\udce4 \u03b1, w \u25cb w \u2286 s := comp_mem_uniformity_sets hs\n  use symmetrizeRel w, symmetrize_mem_uniformity w_in, symmetric_symmetrizeRel w\n  have : symmetrizeRel w \u2286 w := symmetrizeRel_subset_self w\n  calc\n    symmetrizeRel w \u25cb symmetrizeRel w \u2286 w \u25cb w := by mono\n    _ \u2286 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 (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) : s \u2286 s \u25cb 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) => And (SymmetricRel.{u1} \u03b1 t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 (compRel.{u1} \u03b1 t t) t) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (And (SymmetricRel.{u1} \u03b1 t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 (compRel.{u1} \u03b1 t t) t) s))))\nCase conversion may be inaccurate. Consider using '#align comp_comp_symm_mem_uniformity_sets comp_comp_symm_mem_uniformity_sets\u2093'. -/\ntheorem comp_comp_symm_mem_uniformity_sets {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n    \u2203 t \u2208 \ud835\udce4 \u03b1, SymmetricRel t \u2227 t \u25cb t \u25cb t \u2286 s :=\n  by\n  rcases comp_symm_mem_uniformity_sets hs with \u27e8w, w_in, w_symm, w_sub\u27e9\n  rcases comp_symm_mem_uniformity_sets w_in with \u27e8t, t_in, t_symm, t_sub\u27e9\n  use t, t_in, t_symm\n  have : t \u2286 t \u25cb t := subset_comp_self_of_mem_uniformity t_in\n  calc\n    t \u25cb t \u25cb t \u2286 w \u25cb t := by mono\n    _ \u2286 w \u25cb (t \u25cb t) := by mono\n    _ \u2286 w \u25cb w := by mono\n    _ \u2286 s := w_sub\n    \n#align comp_comp_symm_mem_uniformity_sets comp_comp_symm_mem_uniformity_sets\n\n/-!\n###\u00a0Balls in uniform spaces\n-/\n\n\n#print UniformSpace.ball /-\n/-- The ball around `(x : \u03b2)` with respect to `(V : set (\u03b2 \u00d7 \u03b2))`. Intended to be\nused for `V \u2208 \ud835\udce4 \u03b2`, 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 : \u03b2) (V : Set (\u03b2 \u00d7 \u03b2)) : Set \u03b2 :=\n  Prod.mk x \u207b\u00b9' 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 : \u03b1) {V : Set (\u03b1 \u00d7 \u03b1)} (hV : V \u2208 \ud835\udce4 \u03b1) : x \u2208 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 (\u03b2 \u00d7 \u03b2)} {x y z} (h : y \u2208 ball x V) (h' : z \u2208 ball y W) :\n    z \u2208 ball x (V \u25cb 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 (\u03b2 \u00d7 \u03b2)} {x y} (h : x \u2208 ball y W) (h' : W \u25cb W \u2286 V) :\n    ball x W \u2286 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 (\u03b2 \u00d7 \u03b2)} (h : V \u2286 W) (x : \u03b2) : ball x V \u2286 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 {\u03b2 : Type.{u1}} (x : \u03b2) (V : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (W : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)), Eq.{succ u1} (Set.{u1} \u03b2) (UniformSpace.ball.{u1} \u03b2 x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.hasInter.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) V W)) (Inter.inter.{u1} (Set.{u1} \u03b2) (Set.hasInter.{u1} \u03b2) (UniformSpace.ball.{u1} \u03b2 x V) (UniformSpace.ball.{u1} \u03b2 x W))\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} (x : \u03b2) (V : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (W : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)), Eq.{succ u1} (Set.{u1} \u03b2) (UniformSpace.ball.{u1} \u03b2 x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.instInterSet.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) V W)) (Inter.inter.{u1} (Set.{u1} \u03b2) (Set.instInterSet.{u1} \u03b2) (UniformSpace.ball.{u1} \u03b2 x V) (UniformSpace.ball.{u1} \u03b2 x W))\nCase conversion may be inaccurate. Consider using '#align ball_inter ball_inter\u2093'. -/\ntheorem ball_inter (x : \u03b2) (V W : Set (\u03b2 \u00d7 \u03b2)) : ball x (V \u2229 W) = ball x V \u2229 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 {\u03b2 : Type.{u1}} (x : \u03b2) (V : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (W : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)), HasSubset.Subset.{u1} (Set.{u1} \u03b2) (Set.hasSubset.{u1} \u03b2) (UniformSpace.ball.{u1} \u03b2 x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.hasInter.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) V W)) (UniformSpace.ball.{u1} \u03b2 x V)\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} (x : \u03b2) (V : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (W : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)), HasSubset.Subset.{u1} (Set.{u1} \u03b2) (Set.instHasSubsetSet.{u1} \u03b2) (UniformSpace.ball.{u1} \u03b2 x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.instInterSet.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) V W)) (UniformSpace.ball.{u1} \u03b2 x V)\nCase conversion may be inaccurate. Consider using '#align ball_inter_left ball_inter_left\u2093'. -/\ntheorem ball_inter_left (x : \u03b2) (V W : Set (\u03b2 \u00d7 \u03b2)) : ball x (V \u2229 W) \u2286 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 {\u03b2 : Type.{u1}} (x : \u03b2) (V : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (W : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)), HasSubset.Subset.{u1} (Set.{u1} \u03b2) (Set.hasSubset.{u1} \u03b2) (UniformSpace.ball.{u1} \u03b2 x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.hasInter.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) V W)) (UniformSpace.ball.{u1} \u03b2 x W)\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} (x : \u03b2) (V : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (W : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)), HasSubset.Subset.{u1} (Set.{u1} \u03b2) (Set.instHasSubsetSet.{u1} \u03b2) (UniformSpace.ball.{u1} \u03b2 x (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.instInterSet.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) V W)) (UniformSpace.ball.{u1} \u03b2 x W)\nCase conversion may be inaccurate. Consider using '#align ball_inter_right ball_inter_right\u2093'. -/\ntheorem ball_inter_right (x : \u03b2) (V W : Set (\u03b2 \u00d7 \u03b2)) : ball x (V \u2229 W) \u2286 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 (\u03b2 \u00d7 \u03b2)} (hV : SymmetricRel V) {x y} :\n    x \u2208 ball y V \u2194 y \u2208 ball x V :=\n  show (x, y) \u2208 Prod.swap \u207b\u00b9' V \u2194 (x, y) \u2208 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 (\u03b2 \u00d7 \u03b2)} (hV : SymmetricRel V) {x} :\n    ball x V = { y | (y, x) \u2208 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 (\u03b2 \u00d7 \u03b2)} {x y z : \u03b2} (hV : SymmetricRel V)\n    (hx : x \u2208 ball z V) (hy : y \u2208 ball z W) : (x, y) \u2208 V \u25cb W :=\n  by\n  rw [mem_ball_symmetry hV] at hx\n  exact \u27e8z, hx, hy\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] (x : \u03b1) {V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V) -> (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.ball.{u1} \u03b1 x V))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] (x : \u03b1) {V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V) -> (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.ball.{u1} \u03b1 x V))\nCase conversion may be inaccurate. Consider using '#align uniform_space.is_open_ball UniformSpace.isOpen_ball\u2093'. -/\ntheorem UniformSpace.isOpen_ball (x : \u03b1) {V : Set (\u03b1 \u00d7 \u03b1)} (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 {\u03b2 : Type.{u1}} {V : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)} {W : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)} {M : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)}, (SymmetricRel.{u1} \u03b2 W) -> (forall {p : Prod.{u1, u1} \u03b2 \u03b2}, Iff (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b2 \u03b2) (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) p (compRel.{u1} \u03b2 (compRel.{u1} \u03b2 V M) W)) (Set.Nonempty.{u1} (Prod.{u1, u1} \u03b2 \u03b2) (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.hasInter.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.prod.{u1, u1} \u03b2 \u03b2 (UniformSpace.ball.{u1} \u03b2 (Prod.fst.{u1, u1} \u03b2 \u03b2 p) V) (UniformSpace.ball.{u1} \u03b2 (Prod.snd.{u1, u1} \u03b2 \u03b2 p) W)) M)))\nbut is expected to have type\n  forall {\u03b2 : Type.{u1}} {V : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)} {W : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)} {M : Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)}, (SymmetricRel.{u1} \u03b2 W) -> (forall {p : Prod.{u1, u1} \u03b2 \u03b2}, Iff (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b2 \u03b2) (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) p (compRel.{u1} \u03b2 (compRel.{u1} \u03b2 V M) W)) (Set.Nonempty.{u1} (Prod.{u1, u1} \u03b2 \u03b2) (Inter.inter.{u1} (Set.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.instInterSet.{u1} (Prod.{u1, u1} \u03b2 \u03b2)) (Set.prod.{u1, u1} \u03b2 \u03b2 (UniformSpace.ball.{u1} \u03b2 (Prod.fst.{u1, u1} \u03b2 \u03b2 p) V) (UniformSpace.ball.{u1} \u03b2 (Prod.snd.{u1, u1} \u03b2 \u03b2 p) W)) M)))\nCase conversion may be inaccurate. Consider using '#align mem_comp_comp mem_comp_comp\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem mem_comp_comp {V W M : Set (\u03b2 \u00d7 \u03b2)} (hW' : SymmetricRel W) {p : \u03b2 \u00d7 \u03b2} :\n    p \u2208 V \u25cb M \u25cb W \u2194 (ball p.1 V \u00d7\u02e2 ball p.2 W \u2229 M).Nonempty :=\n  by\n  cases' p with x y\n  constructor\n  \u00b7 rintro \u27e8z, \u27e8w, hpw, hwz\u27e9, hzy\u27e9\n    exact \u27e8(w, z), \u27e8hpw, by rwa [mem_ball_symmetry hW']\u27e9, hwz\u27e9\n  \u00b7 rintro \u27e8\u27e8w, z\u27e9, \u27e8w_in, z_in\u27e9, hwz\u27e9\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 : \u03b1} {s : Set \u03b1} :\n    s \u2208 \ud835\udcdd x \u2194 { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 \ud835\udce4 \u03b1 :=\n  by\n  refine' \u27e8_, fun hs => _\u27e9\n  \u00b7 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  \u00b7 refine' mem_nhds_iff.mpr \u27e8{ x | { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 \ud835\udce4 \u03b1 }, _, _, hs\u27e9\n    \u00b7 exact fun y hy => refl_mem_uniformity hy rfl\n    \u00b7 refine' is_open_uniformity.mpr fun y hy => _\n      rcases comp_mem_uniformity_sets hy with \u27e8t, ht, tr\u27e9\n      filter_upwards [ht]\n      rintro \u27e8a, b\u27e9 hp' rfl\n      filter_upwards [ht]\n      rintro \u27e8a', b'\u27e9 hp'' rfl\n      exact @tr (a, b') \u27e8a', hp', hp''\u27e9 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 : \u03b1} {s : Set \u03b1} :\n    s \u2208 \ud835\udcdd x \u2194 { p : \u03b1 \u00d7 \u03b1 | p.2 = x \u2192 p.1 \u2208 s } \u2208 \ud835\udce4 \u03b1 :=\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 : \u03b1} : \ud835\udcdd x = (\ud835\udce4 \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s) (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s) (forall (x : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s))))\nCase conversion may be inaccurate. Consider using '#align is_open_iff_ball_subset isOpen_iff_ball_subset\u2093'. -/\n/-- See also `is_open_iff_open_ball_subset`. -/\ntheorem isOpen_iff_ball_subset {s : Set \u03b1} : IsOpen s \u2194 \u2200 x \u2208 s, \u2203 V \u2208 \ud835\udce4 \u03b1, ball x V \u2286 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 {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p s) -> (forall {x : \u03b1}, Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x) p (fun (i : \u03b9) => UniformSpace.ball.{u1} \u03b1 x (s i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : UniformSpace.{u2} \u03b1] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} \u03b1 \u03b1) \u03b9 (uniformity.{u2} \u03b1 _inst_1) p s) -> (forall {x : \u03b1}, Filter.HasBasis.{u2, u1} \u03b1 \u03b9 (nhds.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) x) p (fun (i : \u03b9) => UniformSpace.ball.{u2} \u03b1 x (s i)))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_uniformity' nhds_basis_uniformity'\u2093'. -/\ntheorem nhds_basis_uniformity' {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 Set (\u03b1 \u00d7 \u03b1)} (h : (\ud835\udce4 \u03b1).HasBasis p s)\n    {x : \u03b1} : (\ud835\udcdd 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 {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p s) -> (forall {x : \u03b1}, Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x) p (fun (i : \u03b9) => setOf.{u1} \u03b1 (fun (y : \u03b1) => Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 y x) (s i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : UniformSpace.{u2} \u03b1] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} \u03b1 \u03b1) \u03b9 (uniformity.{u2} \u03b1 _inst_1) p s) -> (forall {x : \u03b1}, Filter.HasBasis.{u2, u1} \u03b1 \u03b9 (nhds.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) x) p (fun (i : \u03b9) => setOf.{u2} \u03b1 (fun (y : \u03b1) => Membership.mem.{u2, u2} (Prod.{u2, u2} \u03b1 \u03b1) (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (Prod.mk.{u2, u2} \u03b1 \u03b1 y x) (s i))))\nCase conversion may be inaccurate. Consider using '#align nhds_basis_uniformity nhds_basis_uniformity\u2093'. -/\ntheorem nhds_basis_uniformity {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 Set (\u03b1 \u00d7 \u03b1)} (h : (\ud835\udce4 \u03b1).HasBasis p s)\n    {x : \u03b1} : (\ud835\udcdd x).HasBasis p fun i => { y | (y, x) \u2208 s i } :=\n  by\n  replace h := h.comap Prod.swap\n  rw [\u2190 map_swap_eq_comap_swap, \u2190 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 : \u03b1} : \ud835\udcdd x = (\ud835\udce4 \u03b1).comap fun y => (y, x) :=\n  (nhds_basis_uniformity (\ud835\udce4 \u03b1).basis_sets).eq_of_same_basis <| (\ud835\udce4 \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {x : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {x : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s)))\nCase conversion may be inaccurate. Consider using '#align uniform_space.mem_nhds_iff UniformSpace.mem_nhds_iff\u2093'. -/\ntheorem UniformSpace.mem_nhds_iff {x : \u03b1} {s : Set \u03b1} : s \u2208 \ud835\udcdd x \u2194 \u2203 V \u2208 \ud835\udce4 \u03b1, ball x V \u2286 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 : \u03b1) \u2983V : Set (\u03b1 \u00d7 \u03b1)\u2984 (V_in : V \u2208 \ud835\udce4 \u03b1) : ball x V \u2208 \ud835\udcdd x :=\n  by\n  rw [UniformSpace.mem_nhds_iff]\n  exact \u27e8V, V_in, subset.refl _\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {x : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) s (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) => And (SymmetricRel.{u1} \u03b1 V) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {x : \u03b1} {s : Set.{u1} \u03b1}, Iff (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) s (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (And (SymmetricRel.{u1} \u03b1 V) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s))))\nCase conversion may be inaccurate. Consider using '#align uniform_space.mem_nhds_iff_symm UniformSpace.mem_nhds_iff_symm\u2093'. -/\ntheorem UniformSpace.mem_nhds_iff_symm {x : \u03b1} {s : Set \u03b1} :\n    s \u2208 \ud835\udcdd x \u2194 \u2203 V \u2208 \ud835\udce4 \u03b1, SymmetricRel V \u2227 ball x V \u2286 s :=\n  by\n  rw [UniformSpace.mem_nhds_iff]\n  constructor\n  \u00b7 rintro \u27e8V, V_in, V_sub\u27e9\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  \u00b7 rintro \u27e8V, V_in, V_symm, V_sub\u27e9\n    exact \u27e8V, V_in, V_sub\u27e9\n#align uniform_space.mem_nhds_iff_symm UniformSpace.mem_nhds_iff_symm\n\n#print UniformSpace.hasBasis_nhds /-\ntheorem UniformSpace.hasBasis_nhds (x : \u03b1) :\n    HasBasis (\ud835\udcdd x) (fun s : Set (\u03b1 \u00d7 \u03b1) => s \u2208 \ud835\udce4 \u03b1 \u2227 SymmetricRel s) fun s => ball x s :=\n  \u27e8fun t => by simp [UniformSpace.mem_nhds_iff_symm, and_assoc']\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1} {x : \u03b1}, Iff (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (closure.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s)) (forall {V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) -> (SymmetricRel.{u1} \u03b1 V) -> (Set.Nonempty.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) s (UniformSpace.ball.{u1} \u03b1 x V))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1} {x : \u03b1}, Iff (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x (closure.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s)) (forall {V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) -> (SymmetricRel.{u1} \u03b1 V) -> (Set.Nonempty.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.instInterSet.{u1} \u03b1) s (UniformSpace.ball.{u1} \u03b1 x V))))\nCase conversion may be inaccurate. Consider using '#align uniform_space.mem_closure_iff_symm_ball UniformSpace.mem_closure_iff_symm_ball\u2093'. -/\ntheorem UniformSpace.mem_closure_iff_symm_ball {s : Set \u03b1} {x} :\n    x \u2208 closure s \u2194 \u2200 {V}, V \u2208 \ud835\udce4 \u03b1 \u2192 SymmetricRel V \u2192 (s \u2229 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1} {x : \u03b1}, Iff (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x (closure.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s)) (forall {V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) -> (Set.Nonempty.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.hasInter.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1} {x : \u03b1}, Iff (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x (closure.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s)) (forall {V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) -> (Set.Nonempty.{u1} \u03b1 (Inter.inter.{u1} (Set.{u1} \u03b1) (Set.instInterSet.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s)))\nCase conversion may be inaccurate. Consider using '#align uniform_space.mem_closure_iff_ball UniformSpace.mem_closure_iff_ball\u2093'. -/\ntheorem UniformSpace.mem_closure_iff_ball {s : Set \u03b1} {x} :\n    x \u2208 closure s \u2194 \u2200 {V}, V \u2208 \ud835\udce4 \u03b1 \u2192 (ball x V \u2229 s).Nonempty := by\n  simp [mem_closure_iff_nhds_basis' (nhds_basis_uniformity' (\ud835\udce4 \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y)) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) (SymmetricRel.{u1} \u03b1 s)) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Set.prod.{u1, u1} \u03b1 \u03b1 (UniformSpace.ball.{u1} \u03b1 x s) (UniformSpace.ball.{u1} \u03b1 y s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] (x : \u03b1) (y : \u03b1), Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y)) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) (SymmetricRel.{u1} \u03b1 s)) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Set.prod.{u1, u1} \u03b1 \u03b1 (UniformSpace.ball.{u1} \u03b1 x s) (UniformSpace.ball.{u1} \u03b1 y s))\nCase conversion may be inaccurate. Consider using '#align uniform_space.has_basis_nhds_prod UniformSpace.hasBasis_nhds_prod\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem UniformSpace.hasBasis_nhds_prod (x y : \u03b1) :\n    HasBasis (\ud835\udcdd (x, y)) (fun s => s \u2208 \ud835\udce4 \u03b1 \u2227 SymmetricRel s) fun s => ball x s \u00d7\u02e2 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 \u27e8U_in, U_symm\u27e9 \u27e8V_in, V_symm\u27e9\n  exact\n    \u27e8U \u2229 V, \u27e8(\ud835\udce4 \u03b1).inter_sets U_in V_in, U_symm.inter V_symm\u27e9, ball_inter_left x U V,\n      ball_inter_right y U V\u27e9\n#align uniform_space.has_basis_nhds_prod UniformSpace.hasBasis_nhds_prod\n\n#print nhds_eq_uniformity /-\ntheorem nhds_eq_uniformity {x : \u03b1} : \ud835\udcdd x = (\ud835\udce4 \u03b1).lift' (ball x) :=\n  (nhds_basis_uniformity' (\ud835\udce4 \u03b1).basis_sets).eq_binf\u1d62\n#align nhds_eq_uniformity nhds_eq_uniformity\n-/\n\n#print nhds_eq_uniformity' /-\ntheorem nhds_eq_uniformity' {x : \u03b1} : \ud835\udcdd x = (\ud835\udce4 \u03b1).lift' fun s => { y | (y, x) \u2208 s } :=\n  (nhds_basis_uniformity (\ud835\udce4 \u03b1).basis_sets).eq_binf\u1d62\n#align nhds_eq_uniformity' nhds_eq_uniformity'\n-/\n\n#print mem_nhds_left /-\ntheorem mem_nhds_left (x : \u03b1) {s : Set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) : { y : \u03b1 | (x, y) \u2208 s } \u2208 \ud835\udcdd 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 : \u03b1) {s : Set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) : { x : \u03b1 | (x, y) \u2208 s } \u2208 \ud835\udcdd 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {a : \u03b1} {U : Set.{u1} \u03b1}, (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) U (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) a)) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (V : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) V (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) a)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (Filter.hasMem.{u1} \u03b1) V (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) a)) => Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) => forall (a' : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a' V) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 a' t) U))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {a : \u03b1} {U : Set.{u1} \u03b1}, (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) U (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) a)) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (V : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Filter.{u1} \u03b1) (instMembershipSetFilter.{u1} \u03b1) V (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) a)) (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (forall (a' : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) a' V) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 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\u2093'. -/\ntheorem exists_mem_nhds_ball_subset_of_mem_nhds {a : \u03b1} {U : Set \u03b1} (h : U \u2208 \ud835\udcdd a) :\n    \u2203 V \u2208 \ud835\udcdd a, \u2203 t \u2208 \ud835\udce4 \u03b1, \u2200 a' \u2208 V, UniformSpace.ball a' t \u2286 U :=\n  let \u27e8t, ht, htU\u27e9 := comp_mem_uniformity_sets (mem_nhds_uniformity_iff_right.1 h)\n  \u27e8_, mem_nhds_left a ht, t, ht, fun a\u2081 h\u2081 a\u2082 h\u2082 => @htU (a, a\u2082) \u27e8a\u2081, h\u2081, h\u2082\u27e9 rfl\u27e9\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 {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p s) -> (forall {K : Set.{u1} \u03b1}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) K) -> (Filter.HasBasis.{u1, u2} \u03b1 \u03b9 (nhdsSet.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) K) p (fun (i : \u03b9) => Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x K) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x K) => UniformSpace.ball.{u1} \u03b1 x (s i))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : UniformSpace.{u2} \u03b1] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} \u03b1 \u03b1) \u03b9 (uniformity.{u2} \u03b1 _inst_1) p s) -> (forall {K : Set.{u2} \u03b1}, (IsCompact.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) K) -> (Filter.HasBasis.{u2, u1} \u03b1 \u03b9 (nhdsSet.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) K) p (fun (i : \u03b9) => Set.union\u1d62.{u2, succ u2} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x K) (fun (H : Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x K) => UniformSpace.ball.{u2} \u03b1 x (s i))))))\nCase conversion may be inaccurate. Consider using '#align is_compact.nhds_set_basis_uniformity IsCompact.nhdsSet_basis_uniformity\u2093'. -/\ntheorem IsCompact.nhdsSet_basis_uniformity {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 Set (\u03b1 \u00d7 \u03b1)}\n    (hU : (\ud835\udce4 \u03b1).HasBasis p s) {K : Set \u03b1} (hK : IsCompact K) :\n    (\ud835\udcdd\u02e2 K).HasBasis p fun i => \u22c3 x \u2208 K, ball x (s i) :=\n  by\n  refine' \u27e8fun U => _\u27e9\n  simp only [mem_nhdsSet_iff_forall, (nhds_basis_uniformity' hU).mem_iff, Union\u2082_subset_iff]\n  refine' \u27e8fun H => _, fun \u27e8i, hpi, hi\u27e9 x hx => \u27e8i, hpi, hi x hx\u27e9\u27e9\n  replace H : \u2200 x \u2208 K, \u2203 i : { i // p i }, ball x (s i \u25cb s i) \u2286 U\n  \u00b7 intro x hx\n    rcases H x hx with \u27e8i, hpi, hi\u27e9\n    rcases comp_mem_uniformity_sets (hU.mem_of_mem hpi) with \u27e8t, ht_mem, ht\u27e9\n    rcases hU.mem_iff.1 ht_mem with \u27e8j, hpj, hj\u27e9\n    exact \u27e8\u27e8j, hpj\u27e9, subset.trans (ball_mono ((compRel_mono hj hj).trans ht) _) hi\u27e9\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    \u27e8t, htK, ht\u27e9\n  obtain \u27e8i, hpi, hi\u27e9 : \u2203 (i : _)(hpi : p i), s i \u2286 \u22c2 x \u2208 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\u2082_iff] at hi\n  refine' \u27e8i, hpi, fun x hx => _\u27e9\n  rcases mem_Union\u2082.1 (ht hx) with \u27e8z, hzt : z \u2208 t, hzx : x \u2208 ball z (s (I z))\u27e9\n  calc\n    ball x (s i) \u2286 ball z (s (I z) \u25cb s (I z)) := fun y hy => \u27e8x, hzx, hi z hzt hy\u27e9\n    _ \u2286 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {A : Set.{u1} \u03b1} {B : Set.{u1} \u03b1}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) A) -> (IsClosed.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) B) -> (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) A B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) => Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) (Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x A) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x A) => UniformSpace.ball.{u1} \u03b1 x V))) (Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x B) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x B) => UniformSpace.ball.{u1} \u03b1 x V))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {A : Set.{u1} \u03b1} {B : Set.{u1} \u03b1}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) A) -> (IsClosed.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) B) -> (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b1) (Preorder.toLE.{u1} (Set.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) A B) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b1) (Preorder.toLE.{u1} (Set.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x A) (fun (h._@.Mathlib.Topology.UniformSpace.Basic._hyg.10418 : Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x A) => UniformSpace.ball.{u1} \u03b1 x V))) (Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x B) (fun (h._@.Mathlib.Topology.UniformSpace.Basic._hyg.10451 : Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x B) => UniformSpace.ball.{u1} \u03b1 x V))))))\nCase conversion may be inaccurate. Consider using '#align disjoint.exists_uniform_thickening Disjoint.exists_uniform_thickening\u2093'. -/\ntheorem Disjoint.exists_uniform_thickening {A B : Set \u03b1} (hA : IsCompact A) (hB : IsClosed B)\n    (h : Disjoint A B) : \u2203 V \u2208 \ud835\udce4 \u03b1, Disjoint (\u22c3 x \u2208 A, ball x V) (\u22c3 x \u2208 B, ball x V) :=\n  by\n  have : B\u1d9c \u2208 \ud835\udcdd\u02e2 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 \u27e8U, hU, hUAB\u27e9\n  rcases comp_symm_mem_uniformity_sets hU with \u27e8V, hV, hVsymm, hVU\u27e9\n  refine' \u27e8V, hV, set.disjoint_left.mpr fun x => _\u27e9\n  simp only [mem_Union\u2082]\n  rintro \u27e8a, ha, hxa\u27e9 \u27e8b, hb, hxb\u27e9\n  rw [mem_ball_symmetry hVsymm] at hxa hxb\n  exact hUAB (mem_Union\u2082_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 {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p s) -> (forall {A : Set.{u1} \u03b1} {B : Set.{u1} \u03b1}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) A) -> (IsClosed.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) B) -> (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) A B) -> (Exists.{u2} \u03b9 (fun (i : \u03b9) => And (p i) (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) (Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x A) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x A) => UniformSpace.ball.{u1} \u03b1 x (s i)))) (Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x B) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x B) => UniformSpace.ball.{u1} \u03b1 x (s i))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : UniformSpace.{u2} \u03b1] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} \u03b1 \u03b1) \u03b9 (uniformity.{u2} \u03b1 _inst_1) p s) -> (forall {A : Set.{u2} \u03b1} {B : Set.{u2} \u03b1}, (IsCompact.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) A) -> (IsClosed.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) B) -> (Disjoint.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} \u03b1) (Preorder.toLE.{u2} (Set.{u2} \u03b1) (PartialOrder.toPreorder.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) A B) -> (Exists.{u1} \u03b9 (fun (i : \u03b9) => And (p i) (Disjoint.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} \u03b1) (Preorder.toLE.{u2} (Set.{u2} \u03b1) (PartialOrder.toPreorder.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) (Set.union\u1d62.{u2, succ u2} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x A) (fun (H : Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x A) => UniformSpace.ball.{u2} \u03b1 x (s i)))) (Set.union\u1d62.{u2, succ u2} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x B) (fun (H : Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x B) => UniformSpace.ball.{u2} \u03b1 x (s i))))))))\nCase conversion may be inaccurate. Consider using '#align disjoint.exists_uniform_thickening_of_basis Disjoint.exists_uniform_thickening_of_basis\u2093'. -/\ntheorem Disjoint.exists_uniform_thickening_of_basis {p : \u03b9 \u2192 Prop} {s : \u03b9 \u2192 Set (\u03b1 \u00d7 \u03b1)}\n    (hU : (\ud835\udce4 \u03b1).HasBasis p s) {A B : Set \u03b1} (hA : IsCompact A) (hB : IsClosed B)\n    (h : Disjoint A B) : \u2203 i, p i \u2227 Disjoint (\u22c3 x \u2208 A, ball x (s i)) (\u22c3 x \u2208 B, ball x (s i)) :=\n  by\n  rcases h.exists_uniform_thickening hA hB with \u27e8V, hV, hVAB\u27e9\n  rcases hU.mem_iff.1 hV with \u27e8i, hi, hiV\u27e9\n  exact\n    \u27e8i, hi,\n      hVAB.mono (Union\u2082_mono fun a _ => ball_mono hiV a) (Union\u2082_mono fun b _ => ball_mono hiV b)\u27e9\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 : \u03b1} : Tendsto (fun a' => (a', a)) (\ud835\udcdd a) (\ud835\udce4 \u03b1) := 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 : \u03b1} : Tendsto (fun a' => (a, a')) (\ud835\udcdd a) (\ud835\udce4 \u03b1) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {x : \u03b1} {g : (Set.{u1} \u03b1) -> (Filter.{u2} \u03b2)}, (Monotone.{u1, u2} (Set.{u1} \u03b1) (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.partialOrder.{u2} \u03b2)) g) -> (Eq.{succ u2} (Filter.{u2} \u03b2) (Filter.lift.{u1, u2} \u03b1 \u03b2 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x) g) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => g (UniformSpace.ball.{u1} \u03b1 x s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {x : \u03b1} {g : (Set.{u1} \u03b1) -> (Filter.{u2} \u03b2)}, (Monotone.{u1, u2} (Set.{u1} \u03b1) (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.instPartialOrderFilter.{u2} \u03b2)) g) -> (Eq.{succ u2} (Filter.{u2} \u03b2) (Filter.lift.{u1, u2} \u03b1 \u03b2 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x) g) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => g (UniformSpace.ball.{u1} \u03b1 x s))))\nCase conversion may be inaccurate. Consider using '#align lift_nhds_left lift_nhds_left\u2093'. -/\ntheorem lift_nhds_left {x : \u03b1} {g : Set \u03b1 \u2192 Filter \u03b2} (hg : Monotone g) :\n    (\ud835\udcdd x).lift g = (\ud835\udce4 \u03b1).lift fun s : Set (\u03b1 \u00d7 \u03b1) => 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {x : \u03b1} {g : (Set.{u1} \u03b1) -> (Filter.{u2} \u03b2)}, (Monotone.{u1, u2} (Set.{u1} \u03b1) (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.partialOrder.{u2} \u03b2)) g) -> (Eq.{succ u2} (Filter.{u2} \u03b2) (Filter.lift.{u1, u2} \u03b1 \u03b2 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x) g) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => g (setOf.{u1} \u03b1 (fun (y : \u03b1) => Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 y x) s)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {x : \u03b1} {g : (Set.{u1} \u03b1) -> (Filter.{u2} \u03b2)}, (Monotone.{u1, u2} (Set.{u1} \u03b1) (Filter.{u2} \u03b2) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1))))))) (PartialOrder.toPreorder.{u2} (Filter.{u2} \u03b2) (Filter.instPartialOrderFilter.{u2} \u03b2)) g) -> (Eq.{succ u2} (Filter.{u2} \u03b2) (Filter.lift.{u1, u2} \u03b1 \u03b2 (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) x) g) (Filter.lift.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => g (setOf.{u1} \u03b1 (fun (y : \u03b1) => Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 y x) s)))))\nCase conversion may be inaccurate. Consider using '#align lift_nhds_right lift_nhds_right\u2093'. -/\ntheorem lift_nhds_right {x : \u03b1} {g : Set \u03b1 \u2192 Filter \u03b2} (hg : Monotone g) :\n    (\ud835\udcdd x).lift g = (\ud835\udce4 \u03b1).lift fun s : Set (\u03b1 \u00d7 \u03b1) => g { y | (y, x) \u2208 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 : \u03b1} :\n    \ud835\udcdd a \u00d7\u1da0 \ud835\udcdd b =\n      (\ud835\udce4 \u03b1).lift fun s : Set (\u03b1 \u00d7 \u03b1) =>\n        (\ud835\udce4 \u03b1).lift' fun t : Set (\u03b1 \u00d7 \u03b1) => { y : \u03b1 | (y, a) \u2208 s } \u00d7\u02e2 { y : \u03b1 | (b, y) \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b)) (Filter.lift'.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Set.prod.{u1, u1} \u03b1 \u03b1 (setOf.{u1} \u03b1 (fun (y : \u03b1) => Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 y a) s)) (setOf.{u1} \u03b1 (fun (y : \u03b1) => Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 b y) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {a : \u03b1} {b : \u03b1}, Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b)) (Filter.lift'.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u1, u1} \u03b1 \u03b1) (uniformity.{u1} \u03b1 _inst_1) (fun (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Set.prod.{u1, u1} \u03b1 \u03b1 (setOf.{u1} \u03b1 (fun (y : \u03b1) => Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 y a) s)) (setOf.{u1} \u03b1 (fun (y : \u03b1) => Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 b y) s))))\nCase conversion may be inaccurate. Consider using '#align nhds_eq_uniformity_prod nhds_eq_uniformity_prod\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem nhds_eq_uniformity_prod {a b : \u03b1} :\n    \ud835\udcdd (a, b) =\n      (\ud835\udce4 \u03b1).lift' fun s : Set (\u03b1 \u00d7 \u03b1) => { y : \u03b1 | (y, a) \u2208 s } \u00d7\u02e2 { y : \u03b1 | (b, y) \u2208 s } :=\n  by\n  rw [nhds_prod_eq, nhds_nhds_eq_uniformity_uniformity_prod, lift_lift'_same_eq_lift']\n  \u00b7 intro s\n    exact monotone_const.set_prod monotone_preimage\n  \u00b7 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {d : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)} (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) d (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) t) (And (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => Exists.{succ u1} \u03b1 (fun (x : \u03b1) => Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u1} \u03b1 \u03b1 p) x) d) (And (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) s) (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 y (Prod.snd.{u1, u1} \u03b1 \u03b1 p)) d))))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {d : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)} (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) d (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) t) (And (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (setOf.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => Exists.{succ u1} \u03b1 (fun (x : \u03b1) => Exists.{succ u1} \u03b1 (fun (y : \u03b1) => And (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u1} \u03b1 \u03b1 p) x) d) (And (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) s) (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 y (Prod.snd.{u1, u1} \u03b1 \u03b1 p)) d))))))))))\nCase conversion may be inaccurate. Consider using '#align nhdset_of_mem_uniformity nhdset_of_mem_uniformity\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t \u00abexpr \u2286 \u00bb cl_d) -/\ntheorem nhdset_of_mem_uniformity {d : Set (\u03b1 \u00d7 \u03b1)} (s : Set (\u03b1 \u00d7 \u03b1)) (hd : d \u2208 \ud835\udce4 \u03b1) :\n    \u2203 t : Set (\u03b1 \u00d7 \u03b1),\n      IsOpen t \u2227 s \u2286 t \u2227 t \u2286 { p | \u2203 x y, (p.1, x) \u2208 d \u2227 (x, y) \u2208 s \u2227 (y, p.2) \u2208 d } :=\n  let cl_d := { p : \u03b1 \u00d7 \u03b1 | \u2203 x y, (p.1, x) \u2208 d \u2227 (x, y) \u2208 s \u2227 (y, p.2) \u2208 d }\n  have : \u2200 p \u2208 s, \u2203 (t : _)(_ : t \u2286 cl_d), IsOpen t \u2227 p \u2208 t := fun \u27e8x, y\u27e9 hp =>\n    mem_nhds_iff.mp <|\n      show cl_d \u2208 \ud835\udcdd (x, y) by\n        rw [nhds_eq_uniformity_prod, mem_lift'_sets]\n        exact \u27e8d, hd, fun \u27e8a, b\u27e9 \u27e8ha, hb\u27e9 => \u27e8x, y, ha, hp, hb\u27e9\u27e9\n        exact monotone_preimage.set_prod monotone_preimage\n  have :\n    \u2203 t : \u2200 (p : \u03b1 \u00d7 \u03b1) (h : p \u2208 s), Set (\u03b1 \u00d7 \u03b1),\n      \u2200 p, \u2200 h : p \u2208 s, t p h \u2286 cl_d \u2227 IsOpen (t p h) \u2227 p \u2208 t p h :=\n    by simp [Classical.skolem] at this <;> simp <;> assumption\n  match this with\n  | \u27e8t, ht\u27e9 =>\n    \u27e8(\u22c3 p : \u03b1 \u00d7 \u03b1, \u22c3 h : p \u2208 s, t p h : Set (\u03b1 \u00d7 \u03b1)),\n      isOpen_union\u1d62 fun p : \u03b1 \u00d7 \u03b1 => isOpen_union\u1d62 fun hp => (ht p hp).right.left, fun \u27e8a, b\u27e9 hp =>\n      by simp <;> exact \u27e8a, b, hp, (ht (a, b) hp).right.right\u27e9,\n      union\u1d62_subset fun p => union\u1d62_subset fun hp => (ht p hp).left\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] (x : \u03b1), LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x x)) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] (x : \u03b1), LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x x)) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align nhds_le_uniformity nhds_le_uniformity\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem nhds_le_uniformity (x : \u03b1) : \ud835\udcdd (x, x) \u2264 \ud835\udce4 \u03b1 :=\n  by\n  intro V V_in\n  rcases comp_symm_mem_uniformity_sets V_in with \u27e8w, w_in, w_symm, w_sub\u27e9\n  have : ball x w \u00d7\u02e2 ball x w \u2208 \ud835\udcdd (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 \u27e8u, v\u27e9 \u27e8u_in, v_in\u27e9\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\u1d62_nhds_le_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (sup\u1d62.{u1, succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (ConditionallyCompleteLattice.toHasSup.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.completeLattice.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) \u03b1 (fun (x : \u03b1) => nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x x))) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (sup\u1d62.{u1, succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (ConditionallyCompleteLattice.toSupSet.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instCompleteLatticeFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) \u03b1 (fun (x : \u03b1) => nhds.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x x))) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align supr_nhds_le_uniformity sup\u1d62_nhds_le_uniformity\u2093'. -/\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem sup\u1d62_nhds_le_uniformity : (\u2a06 x : \u03b1, \ud835\udcdd (x, x)) \u2264 \ud835\udce4 \u03b1 :=\n  sup\u1d62_le nhds_le_uniformity\n#align supr_nhds_le_uniformity sup\u1d62_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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.partialOrder.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (nhdsSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Set.diagonal.{u1} \u03b1)) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], LE.le.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Preorder.toLE.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (PartialOrder.toPreorder.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.instPartialOrderFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) (nhdsSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (Set.diagonal.{u1} \u03b1)) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align nhds_set_diagonal_le_uniformity nhdsSet_diagonal_le_uniformity\u2093'. -/\n/-- Entourages are neighborhoods of the diagonal. -/\ntheorem nhdsSet_diagonal_le_uniformity : \ud835\udcdd\u02e2 (diagonal \u03b1) \u2264 \ud835\udce4 \u03b1 :=\n  (nhdsSet_diagonal \u03b1).trans_le sup\u1d62_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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), Eq.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (closure.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) s) (Set.inter\u1d62.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Set.inter\u1d62.{u1, 0} (Prod.{u1, u1} \u03b1 \u03b1) (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))) (Set.hasMem.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))) V (setOf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (SymmetricRel.{u1} \u03b1 V)))) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))) (Set.hasMem.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))) V (setOf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (SymmetricRel.{u1} \u03b1 V)))) => compRel.{u1} \u03b1 (compRel.{u1} \u03b1 V s) V)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] (s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)), Eq.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (closure.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) s) (Set.inter\u1d62.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Set.inter\u1d62.{u1, 0} (Prod.{u1, u1} \u03b1 \u03b1) (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))) (Set.instMembershipSet.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))) V (setOf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (SymmetricRel.{u1} \u03b1 V)))) (fun (H : Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))) (Set.instMembershipSet.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))) V (setOf.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (SymmetricRel.{u1} \u03b1 V)))) => compRel.{u1} \u03b1 (compRel.{u1} \u03b1 V s) V)))\nCase conversion may be inaccurate. Consider using '#align closure_eq_uniformity closure_eq_uniformity\u2093'. -/\ntheorem closure_eq_uniformity (s : Set <| \u03b1 \u00d7 \u03b1) :\n    closure s = \u22c2 V \u2208 { V | V \u2208 \ud835\udce4 \u03b1 \u2227 SymmetricRel V }, V \u25cb s \u25cb V :=\n  by\n  ext \u27e8x, y\u27e9\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, \u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (IsClosed.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V)) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (IsClosed.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V)) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))\nCase conversion may be inaccurate. Consider using '#align uniformity_has_basis_closed uniformity_hasBasis_closed\u2093'. -/\ntheorem uniformity_hasBasis_closed :\n    HasBasis (\ud835\udce4 \u03b1) (fun V : Set (\u03b1 \u00d7 \u03b1) => V \u2208 \ud835\udce4 \u03b1 \u2227 IsClosed V) id :=\n  by\n  refine' Filter.hasBasis_self.2 fun t h => _\n  rcases comp_comp_symm_mem_uniformity_sets h with \u27e8w, w_in, w_symm, r\u27e9\n  refine' \u27e8closure w, mem_of_superset w_in subset_closure, isClosed_closure, _\u27e9\n  refine' subset.trans _ r\n  rw [closure_eq_uniformity]\n  apply Inter_subset_of_subset\n  apply Inter_subset\n  exact \u27e8w_in, w_symm\u27e9\n#align uniformity_has_basis_closed uniformity_hasBasis_closed\n\n#print uniformity_eq_uniformity_closure /-\ntheorem uniformity_eq_uniformity_closure : \ud835\udce4 \u03b1 = (\ud835\udce4 \u03b1).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 {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p U) -> (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p (fun (i : \u03b9) => closure.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) (U i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : UniformSpace.{u2} \u03b1] {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} \u03b1 \u03b1) \u03b9 (uniformity.{u2} \u03b1 _inst_1) p U) -> (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} \u03b1 \u03b1) \u03b9 (uniformity.{u2} \u03b1 _inst_1) p (fun (i : \u03b9) => closure.{u2} (Prod.{u2, u2} \u03b1 \u03b1) (instTopologicalSpaceProd.{u2, u2} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1)) (U i)))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniformity_closure Filter.HasBasis.uniformity_closure\u2093'. -/\ntheorem Filter.HasBasis.uniformity_closure {p : \u03b9 \u2192 Prop} {U : \u03b9 \u2192 Set (\u03b1 \u00d7 \u03b1)}\n    (h : (\ud835\udce4 \u03b1).HasBasis p U) : (\ud835\udce4 \u03b1).HasBasis p fun i => closure (U i) :=\n  (@uniformity_eq_uniformity_closure \u03b1 _).symm \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (closure.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (closure.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align uniformity_has_basis_closure uniformity_hasBasis_closure\u2093'. -/\n/-- Closed entourages form a basis of the uniformity filter. -/\ntheorem uniformity_hasBasis_closure : HasBasis (\ud835\udce4 \u03b1) (fun V : Set (\u03b1 \u00d7 \u03b1) => V \u2208 \ud835\udce4 \u03b1) closure :=\n  (\ud835\udce4 \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, Eq.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (closure.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) t) (Set.inter\u1d62.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (d : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Set.inter\u1d62.{u1, 0} (Prod.{u1, u1} \u03b1 \u03b1) (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) d (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) d (uniformity.{u1} \u03b1 _inst_1)) => compRel.{u1} \u03b1 d (compRel.{u1} \u03b1 t d))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, Eq.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (closure.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) t) (Set.inter\u1d62.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (d : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Set.inter\u1d62.{u1, 0} (Prod.{u1, u1} \u03b1 \u03b1) (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) d (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) d (uniformity.{u1} \u03b1 _inst_1)) => compRel.{u1} \u03b1 d (compRel.{u1} \u03b1 t d))))\nCase conversion may be inaccurate. Consider using '#align closure_eq_inter_uniformity closure_eq_inter_uniformity\u2093'. -/\ntheorem closure_eq_inter_uniformity {t : Set (\u03b1 \u00d7 \u03b1)} : closure t = \u22c2 d \u2208 \ud835\udce4 \u03b1, d \u25cb (t \u25cb d) :=\n  calc\n    closure t = \u22c2 (V) (hV : V \u2208 \ud835\udce4 \u03b1 \u2227 SymmetricRel V), V \u25cb t \u25cb V := closure_eq_uniformity t\n    _ = \u22c2 V \u2208 \ud835\udce4 \u03b1, V \u25cb t \u25cb V :=\n      (Eq.symm <|\n        UniformSpace.hasBasis_symmetric.binter\u1d62_mem fun V\u2081 V\u2082 hV =>\n          compRel_mono (compRel_mono hV Subset.rfl) hV)\n    _ = \u22c2 V \u2208 \ud835\udce4 \u03b1, V \u25cb (t \u25cb 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 : \ud835\udce4 \u03b1 = (\ud835\udce4 \u03b1).lift' interior :=\n  le_antisymm\n    (le_inf\u1d62 fun d =>\n      le_inf\u1d62 fun hd =>\n        by\n        let \u27e8s, hs, hs_comp\u27e9 :=\n          (mem_lift'_sets <| monotone_id.compRel <| monotone_id.compRel monotone_id).mp\n            (comp_le_uniformity3 hd)\n        let \u27e8t, ht, hst, ht_comp\u27e9 := nhdset_of_mem_uniformity s hs\n        have : s \u2286 interior d :=\n          calc\n            s \u2286 t := hst\n            _ \u2286 interior d :=\n              ht.subset_interior_iff.mpr fun x (hx : x \u2208 t) =>\n                let \u27e8x, y, h\u2081, h\u2082, h\u2083\u27e9 := ht_comp hx\n                hs_comp \u27e8x, h\u2081, y, h\u2082, h\u2083\u27e9\n            \n        have : interior d \u2208 \ud835\udce4 \u03b1 := by filter_upwards [hs]using this\n        simp [this])\n    fun s hs => ((\ud835\udce4 \u03b1).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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (interior.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) s) (uniformity.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (interior.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) s) (uniformity.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align interior_mem_uniformity interior_mem_uniformity\u2093'. -/\ntheorem interior_mem_uniformity {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) : interior s \u2208 \ud835\udce4 \u03b1 := 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) => And (IsClosed.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (And (IsClosed.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t s))))\nCase conversion may be inaccurate. Consider using '#align mem_uniformity_is_closed mem_uniformity_isClosed\u2093'. -/\ntheorem mem_uniformity_isClosed {s : Set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) : \u2203 t \u2208 \ud835\udce4 \u03b1, IsClosed t \u2227 t \u2286 s :=\n  let \u27e8t, \u27e8ht_mem, htc\u27e9, hts\u27e9 := uniformity_hasBasis_closed.mem_iff.1 h\n  \u27e8t, ht_mem, htc, hts\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s) (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) => And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1}, Iff (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s) (forall (x : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V) (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) s)))))\nCase conversion may be inaccurate. Consider using '#align is_open_iff_open_ball_subset isOpen_iff_open_ball_subset\u2093'. -/\ntheorem isOpen_iff_open_ball_subset {s : Set \u03b1} :\n    IsOpen s \u2194 \u2200 x \u2208 s, \u2203 V \u2208 \ud835\udce4 \u03b1, IsOpen V \u2227 ball x V \u2286 s :=\n  by\n  rw [isOpen_iff_ball_subset]\n  constructor <;> intro h x hx\n  \u00b7 obtain \u27e8V, hV, hV'\u27e9 := h x hx\n    exact\n      \u27e8interior V, interior_mem_uniformity hV, isOpen_interior,\n        (ball_mono interior_subset x).trans hV'\u27e9\n  \u00b7 obtain \u27e8V, hV, -, hV'\u27e9 := h x hx\n    exact \u27e8V, hV, hV'\u27e9\n#align is_open_iff_open_ball_subset isOpen_iff_open_ball_subset\n\n#print Dense.bunion\u1d62_uniformity_ball /-\n/-- The uniform neighborhoods of all points of a dense set cover the whole space. -/\ntheorem Dense.bunion\u1d62_uniformity_ball {s : Set \u03b1} {U : Set (\u03b1 \u00d7 \u03b1)} (hs : Dense s) (hU : U \u2208 \ud835\udce4 \u03b1) :\n    (\u22c3 x \u2208 s, ball x U) = univ :=\n  by\n  refine' Union\u2082_eq_univ_iff.2 fun y => _\n  rcases hs.inter_nhds_nonempty (mem_nhds_right y hU) with \u27e8x, hxs, hxy : (x, y) \u2208 U\u27e9\n  exact \u27e8x, hxs, hxy\u27e9\n#align dense.bUnion_uniformity_ball Dense.bunion\u1d62_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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V)) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V)) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))\nCase conversion may be inaccurate. Consider using '#align uniformity_has_basis_open uniformity_hasBasis_open\u2093'. -/\n/-- Open elements of `\ud835\udce4 \u03b1` form a basis of `\ud835\udce4 \u03b1`. -/\ntheorem uniformity_hasBasis_open : HasBasis (\ud835\udce4 \u03b1) (fun V : Set (\u03b1 \u00d7 \u03b1) => V \u2208 \ud835\udce4 \u03b1 \u2227 IsOpen V) id :=\n  hasBasis_self.2 fun s hs =>\n    \u27e8interior s, interior_mem_uniformity hs, isOpen_interior, interior_subset\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {p : \u03b2 -> Prop} {s : \u03b2 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) p s) -> (forall {t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, Iff (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (Exists.{succ u2} \u03b2 (fun (i : \u03b2) => Exists.{0} (p i) (fun (hi : p i) => forall (a : \u03b1) (b : \u03b1), (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) (s i)) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) t)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {p : \u03b2 -> Prop} {s : \u03b2 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, succ u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (uniformity.{u1} \u03b1 _inst_1) p s) -> (forall {t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, Iff (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (Exists.{succ u2} \u03b2 (fun (i : \u03b2) => And (p i) (forall (a : \u03b1) (b : \u03b1), (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) (s i)) -> (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) t)))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.mem_uniformity_iff Filter.HasBasis.mem_uniformity_iff\u2093'. -/\ntheorem Filter.HasBasis.mem_uniformity_iff {p : \u03b2 \u2192 Prop} {s : \u03b2 \u2192 Set (\u03b1 \u00d7 \u03b1)}\n    (h : (\ud835\udce4 \u03b1).HasBasis p s) {t : Set (\u03b1 \u00d7 \u03b1)} :\n    t \u2208 \ud835\udce4 \u03b1 \u2194 \u2203 (i : _)(hi : p i), \u2200 a b, (a, b) \u2208 s i \u2192 (a, b) \u2208 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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V) (SymmetricRel.{u1} \u03b1 V))) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1], Filter.HasBasis.{u1, succ u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 _inst_1) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V) (SymmetricRel.{u1} \u03b1 V))) (id.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))\nCase conversion may be inaccurate. Consider using '#align uniformity_has_basis_open_symmetric uniformity_hasBasis_open_symmetric\u2093'. -/\n/-- Open elements `s : set (\u03b1 \u00d7 \u03b1)` of `\ud835\udce4 \u03b1` such that `(x, y) \u2208 s \u2194 (y, x) \u2208 s` form a basis\nof `\ud835\udce4 \u03b1`. -/\ntheorem uniformity_hasBasis_open_symmetric :\n    HasBasis (\ud835\udce4 \u03b1) (fun V : Set (\u03b1 \u00d7 \u03b1) => V \u2208 \ud835\udce4 \u03b1 \u2227 IsOpen V \u2227 SymmetricRel V) id :=\n  by\n  simp only [\u2190 and_assoc']\n  refine' uniformity_has_basis_open.restrict fun s hs => \u27e8symmetrizeRel s, _\u27e9\n  exact\n    \u27e8\u27e8symmetrize_mem_uniformity hs.1, IsOpen.inter hs.2 (hs.2.Preimage continuous_swap)\u27e9,\n      symmetric_symmetrizeRel s, symmetrizeRel_subset_self s\u27e9\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) => And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) t) (And (SymmetricRel.{u1} \u03b1 t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasSubset.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) s)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) s (uniformity.{u1} \u03b1 _inst_1)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (t : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) t (uniformity.{u1} \u03b1 _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) t) (And (SymmetricRel.{u1} \u03b1 t) (HasSubset.Subset.{u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instHasSubsetSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (compRel.{u1} \u03b1 t t) s)))))\nCase conversion may be inaccurate. Consider using '#align comp_open_symm_mem_uniformity_sets comp_open_symm_mem_uniformity_sets\u2093'. -/\ntheorem comp_open_symm_mem_uniformity_sets {s : Set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n    \u2203 t \u2208 \ud835\udce4 \u03b1, IsOpen t \u2227 SymmetricRel t \u2227 t \u25cb t \u2286 s :=\n  by\n  obtain \u27e8t, ht\u2081, ht\u2082\u27e9 := comp_mem_uniformity_sets hs\n  obtain \u27e8u, \u27e8hu\u2081, hu\u2082, hu\u2083\u27e9, hu\u2084 : u \u2286 t\u27e9 := uniformity_has_basis_open_symmetric.mem_iff.mp ht\u2081\n  exact \u27e8u, hu\u2081, hu\u2082, hu\u2083, (compRel_mono hu\u2084 hu\u2084).trans ht\u2082\u27e9\n#align comp_open_symm_mem_uniformity_sets comp_open_symm_mem_uniformity_sets\n\nsection\n\nvariable (\u03b1)\n\n#print UniformSpace.has_seq_basis /-\ntheorem UniformSpace.has_seq_basis [IsCountablyGenerated <| \ud835\udce4 \u03b1] :\n    \u2203 V : \u2115 \u2192 Set (\u03b1 \u00d7 \u03b1), HasAntitoneBasis (\ud835\udce4 \u03b1) V \u2227 \u2200 n, SymmetricRel (V n) :=\n  let \u27e8U, hsym, hbasis\u27e9 := UniformSpace.hasBasis_symmetric.exists_antitone_subbasis\n  \u27e8U, hbasis, fun n => (hsym n).2\u27e9\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\u1d62_bunion\u1d62_ball is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p U) -> (forall (s : Set.{u1} \u03b1), Eq.{succ u1} (Set.{u1} \u03b1) (Set.inter\u1d62.{u1, u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.inter\u1d62.{u1, 0} \u03b1 (p i) (fun (hi : p i) => Set.union\u1d62.{u1, succ u1} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) (fun (H : Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) => UniformSpace.ball.{u1} \u03b1 x (U i)))))) (closure.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} [_inst_1 : UniformSpace.{u2} \u03b1] {p : \u03b9 -> Prop} {U : \u03b9 -> (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1))}, (Filter.HasBasis.{u2, u1} (Prod.{u2, u2} \u03b1 \u03b1) \u03b9 (uniformity.{u2} \u03b1 _inst_1) p U) -> (forall (s : Set.{u2} \u03b1), Eq.{succ u2} (Set.{u2} \u03b1) (Set.inter\u1d62.{u2, u1} \u03b1 \u03b9 (fun (i : \u03b9) => Set.inter\u1d62.{u2, 0} \u03b1 (p i) (fun (hi : p i) => Set.union\u1d62.{u2, succ u2} \u03b1 \u03b1 (fun (x : \u03b1) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x s) (fun (H : Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x s) => UniformSpace.ball.{u2} \u03b1 x (U i)))))) (closure.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) s))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.bInter_bUnion_ball Filter.HasBasis.binter\u1d62_bunion\u1d62_ball\u2093'. -/\ntheorem Filter.HasBasis.binter\u1d62_bunion\u1d62_ball {p : \u03b9 \u2192 Prop} {U : \u03b9 \u2192 Set (\u03b1 \u00d7 \u03b1)}\n    (h : HasBasis (\ud835\udce4 \u03b1) p U) (s : Set \u03b1) : (\u22c2 (i) (hi : p i), \u22c3 x \u2208 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\u1d62_bunion\u1d62_ball\n\n/-! ### Uniform continuity -/\n\n\n#print UniformContinuous /-\n/-- A function `f : \u03b1 \u2192 \u03b2` 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 `\u03b1`. -/\ndef UniformContinuous [UniformSpace \u03b2] (f : \u03b1 \u2192 \u03b2) :=\n  Tendsto (fun x : \u03b1 \u00d7 \u03b1 => (f x.1, f x.2)) (\ud835\udce4 \u03b1) (\ud835\udce4 \u03b2)\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 : \u03b1 \u2192 \u03b2` is *uniformly continuous* on `s : set \u03b1` if `(f x, f y)` tends to\nthe diagonal as `(x, y)` tends to the diagonal while remaining in `s \u00d7\u02e2 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 \u03b2] (f : \u03b1 \u2192 \u03b2) (s : Set \u03b1) : Prop :=\n  Tendsto (fun x : \u03b1 \u00d7 \u03b1 => (f x.1, f x.2)) (\ud835\udce4 \u03b1 \u2293 principal (s \u00d7\u02e2 s)) (\ud835\udce4 \u03b2)\n#align uniform_continuous_on UniformContinuousOn\n-/\n\n#print uniformContinuous_def /-\ntheorem uniformContinuous_def [UniformSpace \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    UniformContinuous f \u2194 \u2200 r \u2208 \ud835\udce4 \u03b2, { x : \u03b1 \u00d7 \u03b1 | (f x.1, f x.2) \u2208 r } \u2208 \ud835\udce4 \u03b1 :=\n  Iff.rfl\n#align uniform_continuous_def uniformContinuous_def\n-/\n\n#print uniformContinuous_iff_eventually /-\ntheorem uniformContinuous_iff_eventually [UniformSpace \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    UniformContinuous f \u2194 \u2200 r \u2208 \ud835\udce4 \u03b2, \u2200\u1da0 x : \u03b1 \u00d7 \u03b1 in \ud835\udce4 \u03b1, (f x.1, f x.2) \u2208 r :=\n  Iff.rfl\n#align uniform_continuous_iff_eventually uniformContinuous_iff_eventually\n-/\n\n#print uniformContinuousOn_univ /-\ntheorem uniformContinuousOn_univ [UniformSpace \u03b2] {f : \u03b1 \u2192 \u03b2} :\n    UniformContinuousOn f univ \u2194 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 \u03b2] {c : \u03b1 \u2192 \u03b2} (h : \u2200 a b, c a = c b) :\n    UniformContinuous c :=\n  have : (fun x : \u03b1 \u00d7 \u03b1 => (c x.fst, c x.snd)) \u207b\u00b9' idRel = univ :=\n    eq_univ_iff_forall.2 fun \u27e8a, b\u27e9 => 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 \u03b1) := by\n  simp [UniformContinuous] <;> exact tendsto_id\n#align uniform_continuous_id uniformContinuous_id\n-/\n\n#print uniformContinuous_const /-\ntheorem uniformContinuous_const [UniformSpace \u03b2] {b : \u03b2} : UniformContinuous fun a : \u03b1 => b :=\n  uniformContinuous_of_const fun _ _ => rfl\n#align uniform_continuous_const uniformContinuous_const\n-/\n\n#print UniformContinuous.comp /-\ntheorem UniformContinuous.comp [UniformSpace \u03b2] [UniformSpace \u03b3] {g : \u03b2 \u2192 \u03b3} {f : \u03b1 \u2192 \u03b2}\n    (hg : UniformContinuous g) (hf : UniformContinuous f) : UniformContinuous (g \u2218 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b9 : Sort.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] {\u03b9' : Sort.{u4}} [_inst_2 : UniformSpace.{u2} \u03b2] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, u3} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p s) -> (forall {q : \u03b9' -> Prop} {t : \u03b9' -> (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2))}, (Filter.HasBasis.{u2, u4} (Prod.{u2, u2} \u03b2 \u03b2) \u03b9' (uniformity.{u2} \u03b2 _inst_2) q t) -> (forall {f : \u03b1 -> \u03b2}, Iff (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f) (forall (i : \u03b9'), (q i) -> (Exists.{u3} \u03b9 (fun (j : \u03b9) => Exists.{0} (p j) (fun (hj : p j) => forall (x : \u03b1) (y : \u03b1), (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) (s j)) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} \u03b2 \u03b2) (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Set.hasMem.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Prod.mk.{u2, u2} \u03b2 \u03b2 (f x) (f y)) (t i))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u4}} {\u03b9 : Sort.{u1}} [_inst_1 : UniformSpace.{u3} \u03b1] {\u03b9' : Sort.{u2}} [_inst_2 : UniformSpace.{u4} \u03b2] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u3} (Prod.{u3, u3} \u03b1 \u03b1))}, (Filter.HasBasis.{u3, u1} (Prod.{u3, u3} \u03b1 \u03b1) \u03b9 (uniformity.{u3} \u03b1 _inst_1) p s) -> (forall {q : \u03b9' -> Prop} {t : \u03b9' -> (Set.{u4} (Prod.{u4, u4} \u03b2 \u03b2))}, (Filter.HasBasis.{u4, u2} (Prod.{u4, u4} \u03b2 \u03b2) \u03b9' (uniformity.{u4} \u03b2 _inst_2) q t) -> (forall {f : \u03b1 -> \u03b2}, Iff (UniformContinuous.{u3, u4} \u03b1 \u03b2 _inst_1 _inst_2 f) (forall (i : \u03b9'), (q i) -> (Exists.{u1} \u03b9 (fun (j : \u03b9) => And (p j) (forall (x : \u03b1) (y : \u03b1), (Membership.mem.{u3, u3} (Prod.{u3, u3} \u03b1 \u03b1) (Set.{u3} (Prod.{u3, u3} \u03b1 \u03b1)) (Set.instMembershipSet.{u3} (Prod.{u3, u3} \u03b1 \u03b1)) (Prod.mk.{u3, u3} \u03b1 \u03b1 x y) (s j)) -> (Membership.mem.{u4, u4} (Prod.{u4, u4} \u03b2 \u03b2) (Set.{u4} (Prod.{u4, u4} \u03b2 \u03b2)) (Set.instMembershipSet.{u4} (Prod.{u4, u4} \u03b2 \u03b2)) (Prod.mk.{u4, u4} \u03b2 \u03b2 (f x) (f y)) (t i))))))))\nCase conversion may be inaccurate. Consider using '#align filter.has_basis.uniform_continuous_iff Filter.HasBasis.uniformContinuous_iff\u2093'. -/\ntheorem Filter.HasBasis.uniformContinuous_iff {\u03b9'} [UniformSpace \u03b2] {p : \u03b9 \u2192 Prop}\n    {s : \u03b9 \u2192 Set (\u03b1 \u00d7 \u03b1)} (ha : (\ud835\udce4 \u03b1).HasBasis p s) {q : \u03b9' \u2192 Prop} {t : \u03b9' \u2192 Set (\u03b2 \u00d7 \u03b2)}\n    (hb : (\ud835\udce4 \u03b2).HasBasis q t) {f : \u03b1 \u2192 \u03b2} :\n    UniformContinuous f \u2194\n      \u2200 (i) (hi : q i), \u2203 (j : _)(hj : p j), \u2200 x y, (x, y) \u2208 s j \u2192 (f x, f y) \u2208 t i :=\n  (ha.tendsto_iff\u2093 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b9 : Sort.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] {\u03b9' : Sort.{u4}} [_inst_2 : UniformSpace.{u2} \u03b2] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1))}, (Filter.HasBasis.{u1, u3} (Prod.{u1, u1} \u03b1 \u03b1) \u03b9 (uniformity.{u1} \u03b1 _inst_1) p s) -> (forall {q : \u03b9' -> Prop} {t : \u03b9' -> (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2))}, (Filter.HasBasis.{u2, u4} (Prod.{u2, u2} \u03b2 \u03b2) \u03b9' (uniformity.{u2} \u03b2 _inst_2) q t) -> (forall {f : \u03b1 -> \u03b2} {S : Set.{u1} \u03b1}, Iff (UniformContinuousOn.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f S) (forall (i : \u03b9'), (q i) -> (Exists.{u3} \u03b9 (fun (j : \u03b9) => Exists.{0} (p j) (fun (hj : p j) => forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x S) -> (forall (y : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y S) -> (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) (s j)) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} \u03b2 \u03b2) (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Set.hasMem.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Prod.mk.{u2, u2} \u03b2 \u03b2 (f x) (f y)) (t i)))))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u4}} {\u03b9 : Sort.{u1}} [_inst_1 : UniformSpace.{u3} \u03b1] {\u03b9' : Sort.{u2}} [_inst_2 : UniformSpace.{u4} \u03b2] {p : \u03b9 -> Prop} {s : \u03b9 -> (Set.{u3} (Prod.{u3, u3} \u03b1 \u03b1))}, (Filter.HasBasis.{u3, u1} (Prod.{u3, u3} \u03b1 \u03b1) \u03b9 (uniformity.{u3} \u03b1 _inst_1) p s) -> (forall {q : \u03b9' -> Prop} {t : \u03b9' -> (Set.{u4} (Prod.{u4, u4} \u03b2 \u03b2))}, (Filter.HasBasis.{u4, u2} (Prod.{u4, u4} \u03b2 \u03b2) \u03b9' (uniformity.{u4} \u03b2 _inst_2) q t) -> (forall {f : \u03b1 -> \u03b2} {S : Set.{u3} \u03b1}, Iff (UniformContinuousOn.{u3, u4} \u03b1 \u03b2 _inst_1 _inst_2 f S) (forall (i : \u03b9'), (q i) -> (Exists.{u1} \u03b9 (fun (j : \u03b9) => And (p j) (forall (x : \u03b1), (Membership.mem.{u3, u3} \u03b1 (Set.{u3} \u03b1) (Set.instMembershipSet.{u3} \u03b1) x S) -> (forall (y : \u03b1), (Membership.mem.{u3, u3} \u03b1 (Set.{u3} \u03b1) (Set.instMembershipSet.{u3} \u03b1) y S) -> (Membership.mem.{u3, u3} (Prod.{u3, u3} \u03b1 \u03b1) (Set.{u3} (Prod.{u3, u3} \u03b1 \u03b1)) (Set.instMembershipSet.{u3} (Prod.{u3, u3} \u03b1 \u03b1)) (Prod.mk.{u3, u3} \u03b1 \u03b1 x y) (s j)) -> (Membership.mem.{u4, u4} (Prod.{u4, u4} \u03b2 \u03b2) (Set.{u4} (Prod.{u4, u4} \u03b2 \u03b2)) (Set.instMembershipSet.{u4} (Prod.{u4, u4} \u03b2 \u03b2)) (Prod.mk.{u4, u4} \u03b2 \u03b2 (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\u2093'. -/\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 \u00abexpr \u2208 \u00bb S) -/\ntheorem Filter.HasBasis.uniformContinuousOn_iff {\u03b9'} [UniformSpace \u03b2] {p : \u03b9 \u2192 Prop}\n    {s : \u03b9 \u2192 Set (\u03b1 \u00d7 \u03b1)} (ha : (\ud835\udce4 \u03b1).HasBasis p s) {q : \u03b9' \u2192 Prop} {t : \u03b9' \u2192 Set (\u03b2 \u00d7 \u03b2)}\n    (hb : (\ud835\udce4 \u03b2).HasBasis q t) {f : \u03b1 \u2192 \u03b2} {S : Set \u03b1} :\n    UniformContinuousOn f S \u2194\n      \u2200 (i) (hi : q i),\n        \u2203 (j : _)(hj : p j), \u2200 (x) (_ : x \u2208 S) (y) (_ : y \u2208 S), (x, y) \u2208 s j \u2192 (f x, f y) \u2208 t i :=\n  ((ha.inf_principal (S \u00d7\u02e2 S)).tendsto_iff\u2093 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 \u03b1)\n    where\n  le t s := t.uniformity \u2264 s.uniformity\n  le_antisymm t s h\u2081 h\u2082 := uniformSpace_eq <| le_antisymm h\u2081 h\u2082\n  le_refl t := le_rfl\n  le_trans a b c h\u2081 h\u2082 := le_trans h\u2081 h\u2082\n\ninstance : InfSet (UniformSpace \u03b1) :=\n  \u27e8fun s =>\n    UniformSpace.ofCore\n      { uniformity := \u2a05 u \u2208 s, \ud835\udce4[u]\n        refl := le_inf\u1d62 fun u => le_inf\u1d62 fun hu => u.refl\n        symm :=\n          le_inf\u1d62 fun u =>\n            le_inf\u1d62 fun hu => le_trans (map_mono <| inf\u1d62_le_of_le _ <| inf\u1d62_le _ hu) u.symm\n        comp :=\n          le_inf\u1d62 fun u =>\n            le_inf\u1d62 fun hu =>\n              le_trans (lift'_mono (inf\u1d62_le_of_le _ <| inf\u1d62_le _ hu) <| le_rfl) u.comp }\u27e9\n\n/- warning: Inf_le -> inf\u209b_le is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CompleteSemilatticeInf.{u1} \u03b1] {s : Set.{u1} \u03b1} {a : \u03b1}, (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) a s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 _inst_1))) (InfSet.inf\u209b.{u1} \u03b1 (CompleteSemilatticeInf.toHasInf.{u1} \u03b1 _inst_1) s) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CompleteSemilatticeInf.{u1} \u03b1] {s : Set.{u1} \u03b1} {a : \u03b1}, (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) a s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 _inst_1))) (InfSet.inf\u209b.{u1} \u03b1 (CompleteSemilatticeInf.toInfSet.{u1} \u03b1 _inst_1) s) a)\nCase conversion may be inaccurate. Consider using '#align Inf_le inf\u209b_le\u2093'. -/\nprivate theorem inf\u209b_le {tt : Set (UniformSpace \u03b1)} {t : UniformSpace \u03b1} (h : t \u2208 tt) :\n    inf\u209b tt \u2264 t :=\n  show (\u2a05 u \u2208 tt, \ud835\udce4[u]) \u2264 \ud835\udce4[t] from inf\u1d62\u2082_le t h\n#align Inf_le inf\u209b_le\n\n/- warning: le_Inf -> le_inf\u209b is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CompleteSemilatticeInf.{u1} \u03b1] {s : Set.{u1} \u03b1} {a : \u03b1}, (forall (b : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) b s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 _inst_1))) a b)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 _inst_1))) a (InfSet.inf\u209b.{u1} \u03b1 (CompleteSemilatticeInf.toHasInf.{u1} \u03b1 _inst_1) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : CompleteSemilatticeInf.{u1} \u03b1] {s : Set.{u1} \u03b1} {a : \u03b1}, (forall (b : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) b s) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 _inst_1))) a b)) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 _inst_1))) a (InfSet.inf\u209b.{u1} \u03b1 (CompleteSemilatticeInf.toInfSet.{u1} \u03b1 _inst_1) s))\nCase conversion may be inaccurate. Consider using '#align le_Inf le_inf\u209b\u2093'. -/\nprivate theorem le_inf\u209b {tt : Set (UniformSpace \u03b1)} {t : UniformSpace \u03b1} (h : \u2200 t' \u2208 tt, t \u2264 t') :\n    t \u2264 inf\u209b tt :=\n  show \ud835\udce4[t] \u2264 \u2a05 u \u2208 tt, \ud835\udce4[u] from le_inf\u1d62\u2082 h\n#align le_Inf le_inf\u209b\n\ninstance : Top (UniformSpace \u03b1) :=\n  \u27e8UniformSpace.ofCore\n      { uniformity := \u22a4\n        refl := le_top\n        symm := le_top\n        comp := le_top }\u27e9\n\ninstance : Bot (UniformSpace \u03b1) :=\n  \u27e8{  toTopologicalSpace := \u22a5\n      uniformity := \ud835\udcdf 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] }\u27e9\n\ninstance : Inf (UniformSpace \u03b1) :=\n  \u27e8fun u\u2081 u\u2082 =>\n    @UniformSpace.replaceTopology _ (u\u2081.toTopologicalSpace \u2293 u\u2082.toTopologicalSpace)\n        (UniformSpace.ofCore\n          { uniformity := u\u2081.uniformity \u2293 u\u2082.uniformity\n            refl := le_inf u\u2081.refl u\u2082.refl\n            symm := u\u2081.symm.inf u\u2082.symm\n            comp := (lift'_inf_le _ _ _).trans <| inf_le_inf u\u2081.comp u\u2082.comp }) <|\n      eq_of_nhds_eq_nhds fun a => by\n        simpa only [nhds_inf, nhds_eq_comap_uniformity] using comap_inf.symm\u27e9\n\ninstance : CompleteLattice (UniformSpace \u03b1) :=\n  {\n    UniformSpace.partialOrder with\n    sup := fun a b => inf\u209b { x | a \u2264 x \u2227 b \u2264 x }\n    le_sup_left := fun a b => le_inf\u209b fun _ \u27e8h, _\u27e9 => h\n    le_sup_right := fun a b => le_inf\u209b fun _ \u27e8_, h\u27e9 => h\n    sup_le := fun a b c h\u2081 h\u2082 => inf\u209b_le \u27e8h\u2081, h\u2082\u27e9\n    inf := (\u00b7 \u2293 \u00b7)\n    le_inf := fun a b c h\u2081 h\u2082 => show a.uniformity \u2264 _ from le_inf h\u2081 h\u2082\n    inf_le_left := fun a b => show _ \u2264 a.uniformity from inf_le_left\n    inf_le_right := fun a b => show _ \u2264 b.uniformity from inf_le_right\n    top := \u22a4\n    le_top := fun a => show a.uniformity \u2264 \u22a4 from le_top\n    bot := \u22a5\n    bot_le := fun u => u.refl\n    sup\u209b := fun tt => inf\u209b { t | \u2200 t' \u2208 tt, t' \u2264 t }\n    le_sup := fun s u h => le_inf\u209b fun u' h' => h' u h\n    sup_le := fun s u h => inf\u209b_le h\n    inf\u209b := inf\u209b\n    le_inf := fun s a hs => le_inf\u209b hs\n    inf_le := fun s a ha => inf\u209b_le ha }\n\n/- warning: infi_uniformity -> inf\u1d62_uniformity is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} {u : \u03b9 -> (UniformSpace.{u1} \u03b1)}, Eq.{succ u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (uniformity.{u1} \u03b1 (inf\u1d62.{u1, u2} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) \u03b9 u)) (inf\u1d62.{u1, u2} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (ConditionallyCompleteLattice.toHasInf.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (CompleteLattice.toConditionallyCompleteLattice.{u1} (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.completeLattice.{u1} (Prod.{u1, u1} \u03b1 \u03b1)))) \u03b9 (fun (i : \u03b9) => uniformity.{u1} \u03b1 (u i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} {u : \u03b9 -> (UniformSpace.{u2} \u03b1)}, Eq.{succ u2} (Filter.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (uniformity.{u2} \u03b1 (inf\u1d62.{u2, u1} (UniformSpace.{u2} \u03b1) (instInfSetUniformSpace.{u2} \u03b1) \u03b9 u)) (inf\u1d62.{u2, u1} (Filter.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (ConditionallyCompleteLattice.toInfSet.{u2} (Filter.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (CompleteLattice.toConditionallyCompleteLattice.{u2} (Filter.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (Filter.instCompleteLatticeFilter.{u2} (Prod.{u2, u2} \u03b1 \u03b1)))) \u03b9 (fun (i : \u03b9) => uniformity.{u2} \u03b1 (u i)))\nCase conversion may be inaccurate. Consider using '#align infi_uniformity inf\u1d62_uniformity\u2093'. -/\ntheorem inf\u1d62_uniformity {\u03b9 : Sort _} {u : \u03b9 \u2192 UniformSpace \u03b1} : \ud835\udce4[inf\u1d62 u] = \u2a05 i, \ud835\udce4[u i] :=\n  inf\u1d62_range\n#align infi_uniformity inf\u1d62_uniformity\n\n#print inf_uniformity /-\ntheorem inf_uniformity {u v : UniformSpace \u03b1} : \ud835\udce4[u \u2293 v] = \ud835\udce4[u] \u2293 \ud835\udce4[v] :=\n  rfl\n#align inf_uniformity inf_uniformity\n-/\n\n#print inhabitedUniformSpace /-\ninstance inhabitedUniformSpace : Inhabited (UniformSpace \u03b1) :=\n  \u27e8\u22a5\u27e9\n#align inhabited_uniform_space inhabitedUniformSpace\n-/\n\n#print inhabitedUniformSpaceCore /-\ninstance inhabitedUniformSpaceCore : Inhabited (UniformSpace.Core \u03b1) :=\n  \u27e8@UniformSpace.toCore _ default\u27e9\n#align inhabited_uniform_space_core inhabitedUniformSpaceCore\n-/\n\n#print UniformSpace.comap /-\n/-- Given `f : \u03b1 \u2192 \u03b2` and a uniformity `u` on `\u03b2`, the inverse image of `u` under `f`\n  is the inverse image in the filter sense of the induced function `\u03b1 \u00d7 \u03b1 \u2192 \u03b2 \u00d7 \u03b2`. -/\ndef UniformSpace.comap (f : \u03b1 \u2192 \u03b2) (u : UniformSpace \u03b2) : UniformSpace \u03b1\n    where\n  uniformity := \ud835\udce4[u].comap fun p : \u03b1 \u00d7 \u03b1 => (f p.1, f p.2)\n  toTopologicalSpace := u.toTopologicalSpace.induced f\n  refl := le_trans (by simp <;> exact fun \u27e8a, b\u27e9 (h : a = b) => h \u25b8 rfl) (comap_mono u.refl)\n  symm := by\n    simp [tendsto_comap_iff, Prod.swap, (\u00b7 \u2218 \u00b7)] <;>\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 \u27e8a\u2081, a\u2082\u27e9 \u27e8x, h\u2081, h\u2082\u27e9 => \u27e8f x, h\u2081, h\u2082\u27e9\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, \u2190 mem_comap_prod_mk, \u2190 uniformity]\n#align uniform_space.comap UniformSpace.comap\n-/\n\n#print uniformity_comap /-\ntheorem uniformity_comap [UniformSpace \u03b2] (f : \u03b1 \u2192 \u03b2) :\n    \ud835\udce4[UniformSpace.comap f \u2039_\u203a] = comap (Prod.map f f) (\ud835\udce4 \u03b2) :=\n  rfl\n#align uniformity_comap uniformity_comap\n-/\n\n#print uniformSpace_comap_id /-\n@[simp]\ntheorem uniformSpace_comap_id {\u03b1 : Type _} : UniformSpace.comap (id : \u03b1 \u2192 \u03b1) = 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [u\u03b3 : UniformSpace.{u3} \u03b3] {f : \u03b1 -> \u03b2} {g : \u03b2 -> \u03b3}, Eq.{succ u1} (UniformSpace.{u1} \u03b1) (UniformSpace.comap.{u1, u3} \u03b1 \u03b3 (Function.comp.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 g f) u\u03b3) (UniformSpace.comap.{u1, u2} \u03b1 \u03b2 f (UniformSpace.comap.{u2, u3} \u03b2 \u03b3 g u\u03b3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {u\u03b3 : UniformSpace.{u1} \u03b3} {f : \u03b1 -> \u03b2} {g : \u03b2 -> \u03b3}, Eq.{succ u3} (UniformSpace.{u3} \u03b1) (UniformSpace.comap.{u3, u1} \u03b1 \u03b3 (Function.comp.{succ u3, succ u2, succ u1} \u03b1 \u03b2 \u03b3 g f) u\u03b3) (UniformSpace.comap.{u3, u2} \u03b1 \u03b2 f (UniformSpace.comap.{u2, u1} \u03b2 \u03b3 g u\u03b3))\nCase conversion may be inaccurate. Consider using '#align uniform_space.comap_comap UniformSpace.comap_comap\u2093'. -/\ntheorem UniformSpace.comap_comap {\u03b1 \u03b2 \u03b3} [u\u03b3 : UniformSpace \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} :\n    UniformSpace.comap (g \u2218 f) u\u03b3 = UniformSpace.comap f (UniformSpace.comap g u\u03b3) :=\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 {\u03b1 : Type.{u1}} {\u03b3 : Type.{u2}} {u\u2081 : UniformSpace.{u2} \u03b3} {u\u2082 : UniformSpace.{u2} \u03b3} {f : \u03b1 -> \u03b3}, Eq.{succ u1} (UniformSpace.{u1} \u03b1) (UniformSpace.comap.{u1, u2} \u03b1 \u03b3 f (Inf.inf.{u2} (UniformSpace.{u2} \u03b3) (UniformSpace.hasInf.{u2} \u03b3) u\u2081 u\u2082)) (Inf.inf.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) (UniformSpace.comap.{u1, u2} \u03b1 \u03b3 f u\u2081) (UniformSpace.comap.{u1, u2} \u03b1 \u03b3 f u\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b3 : Type.{u1}} {u\u2081 : UniformSpace.{u1} \u03b3} {u\u2082 : UniformSpace.{u1} \u03b3} {f : \u03b1 -> \u03b3}, Eq.{succ u2} (UniformSpace.{u2} \u03b1) (UniformSpace.comap.{u2, u1} \u03b1 \u03b3 f (Inf.inf.{u1} (UniformSpace.{u1} \u03b3) (instInfUniformSpace.{u1} \u03b3) u\u2081 u\u2082)) (Inf.inf.{u2} (UniformSpace.{u2} \u03b1) (instInfUniformSpace.{u2} \u03b1) (UniformSpace.comap.{u2, u1} \u03b1 \u03b3 f u\u2081) (UniformSpace.comap.{u2, u1} \u03b1 \u03b3 f u\u2082))\nCase conversion may be inaccurate. Consider using '#align uniform_space.comap_inf UniformSpace.comap_inf\u2093'. -/\ntheorem UniformSpace.comap_inf {\u03b1 \u03b3} {u\u2081 u\u2082 : UniformSpace \u03b3} {f : \u03b1 \u2192 \u03b3} :\n    (u\u2081 \u2293 u\u2082).comap f = u\u2081.comap f \u2293 u\u2082.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\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b9 : Sort.{u1}} {\u03b1 : Type.{u2}} {\u03b3 : Type.{u3}} {u : \u03b9 -> (UniformSpace.{u3} \u03b3)} {f : \u03b1 -> \u03b3}, Eq.{succ u2} (UniformSpace.{u2} \u03b1) (UniformSpace.comap.{u2, u3} \u03b1 \u03b3 f (inf\u1d62.{u3, u1} (UniformSpace.{u3} \u03b3) (UniformSpace.hasInf.{u3} \u03b3) \u03b9 (fun (i : \u03b9) => u i))) (inf\u1d62.{u2, u1} (UniformSpace.{u2} \u03b1) (UniformSpace.hasInf.{u2} \u03b1) \u03b9 (fun (i : \u03b9) => UniformSpace.comap.{u2, u3} \u03b1 \u03b3 f (u i)))\nbut is expected to have type\n  forall {\u03b9 : Sort.{u3}} {\u03b1 : Type.{u2}} {\u03b3 : Type.{u1}} {u : \u03b9 -> (UniformSpace.{u1} \u03b3)} {f : \u03b1 -> \u03b3}, Eq.{succ u2} (UniformSpace.{u2} \u03b1) (UniformSpace.comap.{u2, u1} \u03b1 \u03b3 f (inf\u1d62.{u1, u3} (UniformSpace.{u1} \u03b3) (instInfSetUniformSpace.{u1} \u03b3) \u03b9 (fun (i : \u03b9) => u i))) (inf\u1d62.{u2, u3} (UniformSpace.{u2} \u03b1) (instInfSetUniformSpace.{u2} \u03b1) \u03b9 (fun (i : \u03b9) => UniformSpace.comap.{u2, u1} \u03b1 \u03b3 f (u i)))\nCase conversion may be inaccurate. Consider using '#align uniform_space.comap_infi UniformSpace.comap_inf\u1d62\u2093'. -/\ntheorem UniformSpace.comap_inf\u1d62 {\u03b9 \u03b1 \u03b3} {u : \u03b9 \u2192 UniformSpace \u03b3} {f : \u03b1 \u2192 \u03b3} :\n    (\u2a05 i, u i).comap f = \u2a05 i, (u i).comap f :=\n  by\n  ext : 1\n  simp [uniformity_comap, inf\u1d62_uniformity]\n#align uniform_space.comap_infi UniformSpace.comap_inf\u1d62\n\n/- warning: uniform_space.comap_mono -> UniformSpace.comap_mono is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b3 : Type.{u2}} {f : \u03b1 -> \u03b3}, Monotone.{u2, u1} (UniformSpace.{u2} \u03b3) (UniformSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u2} (UniformSpace.{u2} \u03b3) (UniformSpace.partialOrder.{u2} \u03b3)) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.partialOrder.{u1} \u03b1)) (fun (u : UniformSpace.{u2} \u03b3) => UniformSpace.comap.{u1, u2} \u03b1 \u03b3 f u)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b3 : Type.{u1}} {f : \u03b1 -> \u03b3}, Monotone.{u1, u2} (UniformSpace.{u1} \u03b3) (UniformSpace.{u2} \u03b1) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b3) (instPartialOrderUniformSpace.{u1} \u03b3)) (PartialOrder.toPreorder.{u2} (UniformSpace.{u2} \u03b1) (instPartialOrderUniformSpace.{u2} \u03b1)) (fun (u : UniformSpace.{u1} \u03b3) => UniformSpace.comap.{u2, u1} \u03b1 \u03b3 f u)\nCase conversion may be inaccurate. Consider using '#align uniform_space.comap_mono UniformSpace.comap_mono\u2093'. -/\ntheorem UniformSpace.comap_mono {\u03b1 \u03b3} {f : \u03b1 \u2192 \u03b3} : Monotone fun u : UniformSpace \u03b3 => u.comap f :=\n  by\n  intro u\u2081 u\u2082 hu\n  change \ud835\udce4 _ \u2264 \ud835\udce4 _\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {u\u03b1 : UniformSpace.{u1} \u03b1} {u\u03b2 : UniformSpace.{u2} \u03b2} {f : \u03b1 -> \u03b2}, Iff (UniformContinuous.{u1, u2} \u03b1 \u03b2 u\u03b1 u\u03b2 f) (LE.le.{u1} (UniformSpace.{u1} \u03b1) (Preorder.toLE.{u1} (UniformSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.partialOrder.{u1} \u03b1))) u\u03b1 (UniformSpace.comap.{u1, u2} \u03b1 \u03b2 f u\u03b2))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {u\u03b1 : UniformSpace.{u2} \u03b1} {u\u03b2 : UniformSpace.{u1} \u03b2} {f : \u03b1 -> \u03b2}, Iff (UniformContinuous.{u2, u1} \u03b1 \u03b2 u\u03b1 u\u03b2 f) (LE.le.{u2} (UniformSpace.{u2} \u03b1) (Preorder.toLE.{u2} (UniformSpace.{u2} \u03b1) (PartialOrder.toPreorder.{u2} (UniformSpace.{u2} \u03b1) (instPartialOrderUniformSpace.{u2} \u03b1))) u\u03b1 (UniformSpace.comap.{u2, u1} \u03b1 \u03b2 f u\u03b2))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_iff uniformContinuous_iff\u2093'. -/\ntheorem uniformContinuous_iff {\u03b1 \u03b2} {u\u03b1 : UniformSpace \u03b1} {u\u03b2 : UniformSpace \u03b2} {f : \u03b1 \u2192 \u03b2} :\n    UniformContinuous f \u2194 u\u03b1 \u2264 u\u03b2.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 {\u03b1 : Type.{u1}} {u : UniformSpace.{u1} \u03b1} {v : UniformSpace.{u1} \u03b1}, Iff (LE.le.{u1} (UniformSpace.{u1} \u03b1) (Preorder.toLE.{u1} (UniformSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.partialOrder.{u1} \u03b1))) u v) (UniformContinuous.{u1, u1} \u03b1 \u03b1 u v (id.{succ u1} \u03b1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {u : UniformSpace.{u1} \u03b1} {v : UniformSpace.{u1} \u03b1}, Iff (LE.le.{u1} (UniformSpace.{u1} \u03b1) (Preorder.toLE.{u1} (UniformSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b1) (instPartialOrderUniformSpace.{u1} \u03b1))) u v) (UniformContinuous.{u1, u1} \u03b1 \u03b1 u v (id.{succ u1} \u03b1))\nCase conversion may be inaccurate. Consider using '#align le_iff_uniform_continuous_id le_iff_uniformContinuous_id\u2093'. -/\ntheorem le_iff_uniformContinuous_id {u v : UniformSpace \u03b1} :\n    u \u2264 v \u2194 @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 : \u03b1 \u2192 \u03b2} [u : UniformSpace \u03b2] :\n    @UniformContinuous \u03b1 \u03b2 (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 : \u03b1 \u2192 \u03b2} {u : UniformSpace \u03b2} :\n    @UniformSpace.toTopologicalSpace _ (UniformSpace.comap f u) =\n      TopologicalSpace.induced f (@UniformSpace.toTopologicalSpace \u03b2 u) :=\n  rfl\n#align to_topological_space_comap toTopologicalSpace_comap\n-/\n\n#print uniformContinuous_comap' /-\ntheorem uniformContinuous_comap' {f : \u03b3 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} [v : UniformSpace \u03b2] [u : UniformSpace \u03b1]\n    (h : UniformContinuous (f \u2218 g)) : @UniformContinuous \u03b1 \u03b3 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 {\u03b1 : Type.{u1}} {u\u2081 : UniformSpace.{u1} \u03b1} {u\u2082 : UniformSpace.{u1} \u03b1}, (LE.le.{u1} (UniformSpace.{u1} \u03b1) (Preorder.toLE.{u1} (UniformSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.partialOrder.{u1} \u03b1))) u\u2081 u\u2082) -> (forall (a : \u03b1), LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.partialOrder.{u1} \u03b1))) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 u\u2081) a) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 u\u2082) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {u\u2081 : UniformSpace.{u1} \u03b1} {u\u2082 : UniformSpace.{u1} \u03b1}, (LE.le.{u1} (UniformSpace.{u1} \u03b1) (Preorder.toLE.{u1} (UniformSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b1) (instPartialOrderUniformSpace.{u1} \u03b1))) u\u2081 u\u2082) -> (forall (a : \u03b1), LE.le.{u1} (Filter.{u1} \u03b1) (Preorder.toLE.{u1} (Filter.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Filter.{u1} \u03b1) (Filter.instPartialOrderFilter.{u1} \u03b1))) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 u\u2081) a) (nhds.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 u\u2082) a))\nCase conversion may be inaccurate. Consider using '#align to_nhds_mono to_nhds_mono\u2093'. -/\ntheorem to_nhds_mono {u\u2081 u\u2082 : UniformSpace \u03b1} (h : u\u2081 \u2264 u\u2082) (a : \u03b1) :\n    @nhds _ (@UniformSpace.toTopologicalSpace _ u\u2081) a \u2264\n      @nhds _ (@UniformSpace.toTopologicalSpace _ u\u2082) a :=\n  by rw [@nhds_eq_uniformity \u03b1 u\u2081 a, @nhds_eq_uniformity \u03b1 u\u2082 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 {\u03b1 : Type.{u1}} {u\u2081 : UniformSpace.{u1} \u03b1} {u\u2082 : UniformSpace.{u1} \u03b1}, (LE.le.{u1} (UniformSpace.{u1} \u03b1) (Preorder.toLE.{u1} (UniformSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.partialOrder.{u1} \u03b1))) u\u2081 u\u2082) -> (LE.le.{u1} (TopologicalSpace.{u1} \u03b1) (Preorder.toLE.{u1} (TopologicalSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.partialOrder.{u1} \u03b1))) (UniformSpace.toTopologicalSpace.{u1} \u03b1 u\u2081) (UniformSpace.toTopologicalSpace.{u1} \u03b1 u\u2082))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {u\u2081 : UniformSpace.{u1} \u03b1} {u\u2082 : UniformSpace.{u1} \u03b1}, (LE.le.{u1} (UniformSpace.{u1} \u03b1) (Preorder.toLE.{u1} (UniformSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (UniformSpace.{u1} \u03b1) (instPartialOrderUniformSpace.{u1} \u03b1))) u\u2081 u\u2082) -> (LE.le.{u1} (TopologicalSpace.{u1} \u03b1) (Preorder.toLE.{u1} (TopologicalSpace.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.instPartialOrderTopologicalSpace.{u1} \u03b1))) (UniformSpace.toTopologicalSpace.{u1} \u03b1 u\u2081) (UniformSpace.toTopologicalSpace.{u1} \u03b1 u\u2082))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_mono toTopologicalSpace_mono\u2093'. -/\ntheorem toTopologicalSpace_mono {u\u2081 u\u2082 : UniformSpace \u03b1} (h : u\u2081 \u2264 u\u2082) :\n    @UniformSpace.toTopologicalSpace _ u\u2081 \u2264 @UniformSpace.toTopologicalSpace _ u\u2082 :=\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 \u03b1] [UniformSpace \u03b2] {f : \u03b1 \u2192 \u03b2}\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 {\u03b1 : Type.{u1}}, Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 (Bot.bot.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.hasBot.{u1} \u03b1))) (Bot.bot.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toHasBot.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.completeLattice.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}}, Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 (Bot.bot.{u1} (UniformSpace.{u1} \u03b1) (instBotUniformSpace.{u1} \u03b1))) (Bot.bot.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toBot.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_bot toTopologicalSpace_bot\u2093'. -/\ntheorem toTopologicalSpace_bot : @UniformSpace.toTopologicalSpace \u03b1 \u22a5 = \u22a5 :=\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 {\u03b1 : Type.{u1}}, Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 (Top.top.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.hasTop.{u1} \u03b1))) (Top.top.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toHasTop.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.completeLattice.{u1} \u03b1)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}}, Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 (Top.top.{u1} (UniformSpace.{u1} \u03b1) (instTopUniformSpace.{u1} \u03b1))) (Top.top.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toTop.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u1} \u03b1)))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_top toTopologicalSpace_top\u2093'. -/\ntheorem toTopologicalSpace_top : @UniformSpace.toTopologicalSpace \u03b1 \u22a4 = \u22a4 :=\n  top_unique fun s hs =>\n    s.eq_empty_or_nonempty.elim (fun this : s = \u2205 => this.symm \u25b8 @isOpen_empty _ \u22a4) fun \u27e8x, hx\u27e9 =>\n      have : s = univ := top_unique fun y hy => hs x hx (x, y) rfl\n      this.symm \u25b8 @isOpen_univ _ \u22a4\n#align to_topological_space_top toTopologicalSpace_top\n\n/- warning: to_topological_space_infi -> toTopologicalSpace_inf\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Sort.{u2}} {u : \u03b9 -> (UniformSpace.{u1} \u03b1)}, Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 (inf\u1d62.{u1, u2} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) \u03b9 u)) (inf\u1d62.{u1, u2} (TopologicalSpace.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.completeLattice.{u1} \u03b1))) \u03b9 (fun (i : \u03b9) => UniformSpace.toTopologicalSpace.{u1} \u03b1 (u i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Sort.{u1}} {u : \u03b9 -> (UniformSpace.{u2} \u03b1)}, Eq.{succ u2} (TopologicalSpace.{u2} \u03b1) (UniformSpace.toTopologicalSpace.{u2} \u03b1 (inf\u1d62.{u2, u1} (UniformSpace.{u2} \u03b1) (instInfSetUniformSpace.{u2} \u03b1) \u03b9 u)) (inf\u1d62.{u2, u1} (TopologicalSpace.{u2} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u2} (TopologicalSpace.{u2} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u2} (TopologicalSpace.{u2} \u03b1) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u2} \u03b1))) \u03b9 (fun (i : \u03b9) => UniformSpace.toTopologicalSpace.{u2} \u03b1 (u i)))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_infi toTopologicalSpace_inf\u1d62\u2093'. -/\ntheorem toTopologicalSpace_inf\u1d62 {\u03b9 : Sort _} {u : \u03b9 \u2192 UniformSpace \u03b1} :\n    (inf\u1d62 u).toTopologicalSpace = \u2a05 i, (u i).toTopologicalSpace :=\n  by\n  refine' eq_of_nhds_eq_nhds fun a => _\n  simp only [nhds_inf\u1d62, nhds_eq_uniformity, inf\u1d62_uniformity]\n  exact lift'_infi_of_map_univ (ball_inter _) preimage_univ\n#align to_topological_space_infi toTopologicalSpace_inf\u1d62\n\n/- warning: to_topological_space_Inf -> toTopologicalSpace_inf\u209b is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} (UniformSpace.{u1} \u03b1)}, Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 (InfSet.inf\u209b.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) s)) (inf\u1d62.{u1, succ u1} (TopologicalSpace.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.completeLattice.{u1} \u03b1))) (UniformSpace.{u1} \u03b1) (fun (i : UniformSpace.{u1} \u03b1) => inf\u1d62.{u1, 0} (TopologicalSpace.{u1} \u03b1) (ConditionallyCompleteLattice.toHasInf.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.completeLattice.{u1} \u03b1))) (Membership.Mem.{u1, u1} (UniformSpace.{u1} \u03b1) (Set.{u1} (UniformSpace.{u1} \u03b1)) (Set.hasMem.{u1} (UniformSpace.{u1} \u03b1)) i s) (fun (H : Membership.Mem.{u1, u1} (UniformSpace.{u1} \u03b1) (Set.{u1} (UniformSpace.{u1} \u03b1)) (Set.hasMem.{u1} (UniformSpace.{u1} \u03b1)) i s) => UniformSpace.toTopologicalSpace.{u1} \u03b1 i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {s : Set.{u1} (UniformSpace.{u1} \u03b1)}, Eq.{succ u1} (TopologicalSpace.{u1} \u03b1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 (InfSet.inf\u209b.{u1} (UniformSpace.{u1} \u03b1) (instInfSetUniformSpace.{u1} \u03b1) s)) (inf\u1d62.{u1, succ u1} (TopologicalSpace.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u1} \u03b1))) (UniformSpace.{u1} \u03b1) (fun (i : UniformSpace.{u1} \u03b1) => inf\u1d62.{u1, 0} (TopologicalSpace.{u1} \u03b1) (ConditionallyCompleteLattice.toInfSet.{u1} (TopologicalSpace.{u1} \u03b1) (CompleteLattice.toConditionallyCompleteLattice.{u1} (TopologicalSpace.{u1} \u03b1) (TopologicalSpace.instCompleteLatticeTopologicalSpace.{u1} \u03b1))) (Membership.mem.{u1, u1} (UniformSpace.{u1} \u03b1) (Set.{u1} (UniformSpace.{u1} \u03b1)) (Set.instMembershipSet.{u1} (UniformSpace.{u1} \u03b1)) i s) (fun (H : Membership.mem.{u1, u1} (UniformSpace.{u1} \u03b1) (Set.{u1} (UniformSpace.{u1} \u03b1)) (Set.instMembershipSet.{u1} (UniformSpace.{u1} \u03b1)) i s) => UniformSpace.toTopologicalSpace.{u1} \u03b1 i)))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_Inf toTopologicalSpace_inf\u209b\u2093'. -/\ntheorem toTopologicalSpace_inf\u209b {s : Set (UniformSpace \u03b1)} :\n    (inf\u209b s).toTopologicalSpace = \u2a05 i \u2208 s, @UniformSpace.toTopologicalSpace \u03b1 i :=\n  by\n  rw [inf\u209b_eq_inf\u1d62]\n  simp only [\u2190 toTopologicalSpace_inf\u1d62]\n#align to_topological_space_Inf toTopologicalSpace_inf\u209b\n\n#print toTopologicalSpace_inf /-\ntheorem toTopologicalSpace_inf {u v : UniformSpace \u03b1} :\n    (u \u2293 v).toTopologicalSpace = u.toTopologicalSpace \u2293 v.toTopologicalSpace :=\n  rfl\n#align to_topological_space_inf toTopologicalSpace_inf\n-/\n\n#print ULift.uniformSpace /-\n/-- Uniform space structure on `ulift \u03b1`. -/\ninstance ULift.uniformSpace [UniformSpace \u03b1] : UniformSpace (ULift \u03b1) :=\n  UniformSpace.comap ULift.down \u2039_\u203a\n#align ulift.uniform_space ULift.uniformSpace\n-/\n\nsection UniformContinuousInfi\n\n#print UniformContinuous.inf_rng /-\ntheorem UniformContinuous.inf_rng {f : \u03b1 \u2192 \u03b2} {u\u2081 : UniformSpace \u03b1} {u\u2082 u\u2083 : UniformSpace \u03b2}\n    (h\u2081 : @UniformContinuous u\u2081 u\u2082 f) (h\u2082 : @UniformContinuous u\u2081 u\u2083 f) :\n    @UniformContinuous u\u2081 (u\u2082 \u2293 u\u2083) f :=\n  tendsto_inf.mpr \u27e8h\u2081, h\u2082\u27e9\n#align uniform_continuous_inf_rng UniformContinuous.inf_rng\n-/\n\n#print UniformContinuous.inf_dom_left /-\ntheorem UniformContinuous.inf_dom_left {f : \u03b1 \u2192 \u03b2} {u\u2081 u\u2082 : UniformSpace \u03b1} {u\u2083 : UniformSpace \u03b2}\n    (hf : @UniformContinuous u\u2081 u\u2083 f) : @UniformContinuous (u\u2081 \u2293 u\u2082) u\u2083 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 : \u03b1 \u2192 \u03b2} {u\u2081 u\u2082 : UniformSpace \u03b1} {u\u2083 : UniformSpace \u03b2}\n    (hf : @UniformContinuous u\u2082 u\u2083 f) : @UniformContinuous (u\u2081 \u2293 u\u2082) u\u2083 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\u209b_dom is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : \u03b1 -> \u03b2} {u\u2081 : Set.{u1} (UniformSpace.{u1} \u03b1)} {u\u2082 : UniformSpace.{u2} \u03b2} {u : UniformSpace.{u1} \u03b1}, (Membership.Mem.{u1, u1} (UniformSpace.{u1} \u03b1) (Set.{u1} (UniformSpace.{u1} \u03b1)) (Set.hasMem.{u1} (UniformSpace.{u1} \u03b1)) u u\u2081) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 u u\u2082 f) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 (InfSet.inf\u209b.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) u\u2081) u\u2082 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : \u03b1 -> \u03b2} {u\u2081 : Set.{u1} (UniformSpace.{u1} \u03b1)} {u\u2082 : UniformSpace.{u2} \u03b2} {u : UniformSpace.{u1} \u03b1}, (Membership.mem.{u1, u1} (UniformSpace.{u1} \u03b1) (Set.{u1} (UniformSpace.{u1} \u03b1)) (Set.instMembershipSet.{u1} (UniformSpace.{u1} \u03b1)) u u\u2081) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 u u\u2082 f) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 (InfSet.inf\u209b.{u1} (UniformSpace.{u1} \u03b1) (instInfSetUniformSpace.{u1} \u03b1) u\u2081) u\u2082 f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_Inf_dom uniformContinuous_inf\u209b_dom\u2093'. -/\ntheorem uniformContinuous_inf\u209b_dom {f : \u03b1 \u2192 \u03b2} {u\u2081 : Set (UniformSpace \u03b1)} {u\u2082 : UniformSpace \u03b2}\n    {u : UniformSpace \u03b1} (h\u2081 : u \u2208 u\u2081) (hf : @UniformContinuous u u\u2082 f) :\n    @UniformContinuous (inf\u209b u\u2081) u\u2082 f :=\n  by\n  rw [UniformContinuous, inf\u209b_eq_inf\u1d62', inf\u1d62_uniformity]\n  exact tendsto_infi' \u27e8u, h\u2081\u27e9 hf\n#align uniform_continuous_Inf_dom uniformContinuous_inf\u209b_dom\n\n/- warning: uniform_continuous_Inf_rng -> uniformContinuous_inf\u209b_rng is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : \u03b1 -> \u03b2} {u\u2081 : UniformSpace.{u1} \u03b1} {u\u2082 : Set.{u2} (UniformSpace.{u2} \u03b2)}, (forall (u : UniformSpace.{u2} \u03b2), (Membership.Mem.{u2, u2} (UniformSpace.{u2} \u03b2) (Set.{u2} (UniformSpace.{u2} \u03b2)) (Set.hasMem.{u2} (UniformSpace.{u2} \u03b2)) u u\u2082) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 u\u2081 u f)) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 u\u2081 (InfSet.inf\u209b.{u2} (UniformSpace.{u2} \u03b2) (UniformSpace.hasInf.{u2} \u03b2) u\u2082) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {f : \u03b1 -> \u03b2} {u\u2081 : UniformSpace.{u1} \u03b1} {u\u2082 : Set.{u2} (UniformSpace.{u2} \u03b2)}, (forall (u : UniformSpace.{u2} \u03b2), (Membership.mem.{u2, u2} (UniformSpace.{u2} \u03b2) (Set.{u2} (UniformSpace.{u2} \u03b2)) (Set.instMembershipSet.{u2} (UniformSpace.{u2} \u03b2)) u u\u2082) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 u\u2081 u f)) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 u\u2081 (InfSet.inf\u209b.{u2} (UniformSpace.{u2} \u03b2) (instInfSetUniformSpace.{u2} \u03b2) u\u2082) f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_Inf_rng uniformContinuous_inf\u209b_rng\u2093'. -/\ntheorem uniformContinuous_inf\u209b_rng {f : \u03b1 \u2192 \u03b2} {u\u2081 : UniformSpace \u03b1} {u\u2082 : Set (UniformSpace \u03b2)}\n    (h : \u2200 u \u2208 u\u2082, @UniformContinuous u\u2081 u f) : @UniformContinuous u\u2081 (inf\u209b u\u2082) f :=\n  by\n  rw [UniformContinuous, inf\u209b_eq_inf\u1d62', inf\u1d62_uniformity]\n  exact tendsto_infi.mpr fun \u27e8u, hu\u27e9 => h u hu\n#align uniform_continuous_Inf_rng uniformContinuous_inf\u209b_rng\n\n/- warning: uniform_continuous_infi_dom -> uniformContinuous_inf\u1d62_dom is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b9 : Sort.{u3}} {f : \u03b1 -> \u03b2} {u\u2081 : \u03b9 -> (UniformSpace.{u1} \u03b1)} {u\u2082 : UniformSpace.{u2} \u03b2} {i : \u03b9}, (UniformContinuous.{u1, u2} \u03b1 \u03b2 (u\u2081 i) u\u2082 f) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 (inf\u1d62.{u1, u3} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) \u03b9 u\u2081) u\u2082 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b9 : Sort.{u1}} {f : \u03b1 -> \u03b2} {u\u2081 : \u03b9 -> (UniformSpace.{u2} \u03b1)} {u\u2082 : UniformSpace.{u3} \u03b2} {i : \u03b9}, (UniformContinuous.{u2, u3} \u03b1 \u03b2 (u\u2081 i) u\u2082 f) -> (UniformContinuous.{u2, u3} \u03b1 \u03b2 (inf\u1d62.{u2, u1} (UniformSpace.{u2} \u03b1) (instInfSetUniformSpace.{u2} \u03b1) \u03b9 u\u2081) u\u2082 f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_infi_dom uniformContinuous_inf\u1d62_dom\u2093'. -/\ntheorem uniformContinuous_inf\u1d62_dom {f : \u03b1 \u2192 \u03b2} {u\u2081 : \u03b9 \u2192 UniformSpace \u03b1} {u\u2082 : UniformSpace \u03b2}\n    {i : \u03b9} (hf : @UniformContinuous (u\u2081 i) u\u2082 f) : @UniformContinuous (inf\u1d62 u\u2081) u\u2082 f :=\n  by\n  rw [UniformContinuous, inf\u1d62_uniformity]\n  exact tendsto_infi' i hf\n#align uniform_continuous_infi_dom uniformContinuous_inf\u1d62_dom\n\n/- warning: uniform_continuous_infi_rng -> uniformContinuous_inf\u1d62_rng is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b9 : Sort.{u3}} {f : \u03b1 -> \u03b2} {u\u2081 : UniformSpace.{u1} \u03b1} {u\u2082 : \u03b9 -> (UniformSpace.{u2} \u03b2)}, (forall (i : \u03b9), UniformContinuous.{u1, u2} \u03b1 \u03b2 u\u2081 (u\u2082 i) f) -> (UniformContinuous.{u1, u2} \u03b1 \u03b2 u\u2081 (inf\u1d62.{u2, u3} (UniformSpace.{u2} \u03b2) (UniformSpace.hasInf.{u2} \u03b2) \u03b9 u\u2082) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b9 : Sort.{u1}} {f : \u03b1 -> \u03b2} {u\u2081 : UniformSpace.{u2} \u03b1} {u\u2082 : \u03b9 -> (UniformSpace.{u3} \u03b2)}, (forall (i : \u03b9), UniformContinuous.{u2, u3} \u03b1 \u03b2 u\u2081 (u\u2082 i) f) -> (UniformContinuous.{u2, u3} \u03b1 \u03b2 u\u2081 (inf\u1d62.{u3, u1} (UniformSpace.{u3} \u03b2) (instInfSetUniformSpace.{u3} \u03b2) \u03b9 u\u2082) f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_infi_rng uniformContinuous_inf\u1d62_rng\u2093'. -/\ntheorem uniformContinuous_inf\u1d62_rng {f : \u03b1 \u2192 \u03b2} {u\u2081 : UniformSpace \u03b1} {u\u2082 : \u03b9 \u2192 UniformSpace \u03b2}\n    (h : \u2200 i, @UniformContinuous u\u2081 (u\u2082 i) f) : @UniformContinuous u\u2081 (inf\u1d62 u\u2082) f := by\n  rwa [UniformContinuous, inf\u1d62_uniformity, tendsto_infi]\n#align uniform_continuous_infi_rng uniformContinuous_inf\u1d62_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\u03b1 : UniformSpace \u03b1] (h : uniformity \u03b1 = \ud835\udcdf idRel) :\n    DiscreteTopology \u03b1 :=\n  \u27e8(uniformSpace_eq h.symm : \u22a5 = h\u03b1) \u25b8 rfl\u27e9\n#align discrete_topology_of_discrete_uniformity discreteTopology_of_discrete_uniformity\n-/\n\ninstance : UniformSpace Empty :=\n  \u22a5\n\ninstance : UniformSpace PUnit :=\n  \u22a5\n\ninstance : UniformSpace Bool :=\n  \u22a5\n\ninstance : UniformSpace \u2115 :=\n  \u22a5\n\ninstance : UniformSpace \u2124 :=\n  \u22a5\n\nsection\n\nvariable [UniformSpace \u03b1]\n\nopen Additive Multiplicative\n\ninstance : UniformSpace (Additive \u03b1) :=\n  \u2039UniformSpace \u03b1\u203a\n\ninstance : UniformSpace (Multiplicative \u03b1) :=\n  \u2039UniformSpace \u03b1\u203a\n\n#print uniformContinuous_ofMul /-\ntheorem uniformContinuous_ofMul : UniformContinuous (ofMul : \u03b1 \u2192 Additive \u03b1) :=\n  uniformContinuous_id\n#align uniform_continuous_of_mul uniformContinuous_ofMul\n-/\n\n#print uniformContinuous_toMul /-\ntheorem uniformContinuous_toMul : UniformContinuous (toMul : Additive \u03b1 \u2192 \u03b1) :=\n  uniformContinuous_id\n#align uniform_continuous_to_mul uniformContinuous_toMul\n-/\n\n#print uniformContinuous_ofAdd /-\ntheorem uniformContinuous_ofAdd : UniformContinuous (ofAdd : \u03b1 \u2192 Multiplicative \u03b1) :=\n  uniformContinuous_id\n#align uniform_continuous_of_add uniformContinuous_ofAdd\n-/\n\n#print uniformContinuous_toAdd /-\ntheorem uniformContinuous_toAdd : UniformContinuous (toAdd : Multiplicative \u03b1 \u2192 \u03b1) :=\n  uniformContinuous_id\n#align uniform_continuous_to_add uniformContinuous_toAdd\n-/\n\n#print uniformity_additive /-\ntheorem uniformity_additive : \ud835\udce4 (Additive \u03b1) = (\ud835\udce4 \u03b1).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 : \ud835\udce4 (Multiplicative \u03b1) = (\ud835\udce4 \u03b1).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 : \u03b1 \u2192 Prop} [t : UniformSpace \u03b1] : UniformSpace (Subtype p) :=\n  UniformSpace.comap Subtype.val t\n\n#print uniformity_subtype /-\ntheorem uniformity_subtype {p : \u03b1 \u2192 Prop} [t : UniformSpace \u03b1] :\n    \ud835\udce4 (Subtype p) = comap (fun q : Subtype p \u00d7 Subtype p => (q.1.1, q.2.1)) (\ud835\udce4 \u03b1) :=\n  rfl\n#align uniformity_subtype uniformity_subtype\n-/\n\n#print uniformity_setCoe /-\ntheorem uniformity_setCoe {s : Set \u03b1} [t : UniformSpace \u03b1] :\n    \ud835\udce4 s = comap (Prod.map (coe : s \u2192 \u03b1) (coe : s \u2192 \u03b1)) (\ud835\udce4 \u03b1) :=\n  rfl\n#align uniformity_set_coe uniformity_setCoe\n-/\n\n#print uniformContinuous_subtype_val /-\ntheorem uniformContinuous_subtype_val {p : \u03b1 \u2192 Prop} [UniformSpace \u03b1] :\n    UniformContinuous (Subtype.val : { a : \u03b1 // p a } \u2192 \u03b1) :=\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\u2093'. -/\n#print uniformContinuous_subtype_val /-\ntheorem uniformContinuous_subtype_val {p : \u03b1 \u2192 Prop} [UniformSpace \u03b1] :\n    UniformContinuous (coe : { a : \u03b1 // p a } \u2192 \u03b1) :=\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 : \u03b1 \u2192 Prop} [UniformSpace \u03b1] [UniformSpace \u03b2] {f : \u03b2 \u2192 \u03b1}\n    (hf : UniformContinuous f) (h : \u2200 x, p (f x)) :\n    UniformContinuous (fun x => \u27e8f x, h x\u27e9 : \u03b2 \u2192 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 \u03b1] [UniformSpace \u03b2] {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1} :\n    UniformContinuousOn f s \u2194 UniformContinuous (s.restrict f) :=\n  by\n  unfold UniformContinuousOn Set.restrict UniformContinuous tendsto\n  conv_rhs =>\n    rw [show (fun x : s \u00d7 s => (f x.1, f x.2)) = Prod.map f f \u2218 Prod.map coe coe from rfl,\n      uniformity_setCoe, \u2190 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 \u03b1] [UniformSpace \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {s : Set \u03b1} {a : \u03b1} (hf : UniformContinuous fun x : s => f x.val) (ha : s \u2208 \ud835\udcdd a) :\n    Tendsto f (\ud835\udcdd a) (\ud835\udcdd (f a)) := by\n  rw [(@map_nhds_subtype_coe_eq_nhds \u03b1 _ 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 \u03b1] [UniformSpace \u03b2] {f : \u03b1 \u2192 \u03b2} {s : Set \u03b1}\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 \u03b1] : UniformSpace \u03b1\u1d50\u1d52\u1d56 :=\n  UniformSpace.comap MulOpposite.unop \u2039_\u203a\n\n#print uniformity_mulOpposite /-\n@[to_additive]\ntheorem uniformity_mulOpposite [UniformSpace \u03b1] :\n    \ud835\udce4 \u03b1\u1d50\u1d52\u1d56 = comap (fun q : \u03b1\u1d50\u1d52\u1d56 \u00d7 \u03b1\u1d50\u1d52\u1d56 => (q.1.unop, q.2.unop)) (\ud835\udce4 \u03b1) :=\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 \u03b1] :\n    comap (fun p : \u03b1 \u00d7 \u03b1 => (MulOpposite.op p.1, MulOpposite.op p.2)) (\ud835\udce4 \u03b1\u1d50\u1d52\u1d56) = \ud835\udce4 \u03b1 := by\n  simpa [uniformity_mulOpposite, comap_comap, (\u00b7 \u2218 \u00b7)] 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 \u03b1] : UniformContinuous (unop : \u03b1\u1d50\u1d52\u1d56 \u2192 \u03b1) :=\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 \u03b1] : UniformContinuous (op : \u03b1 \u2192 \u03b1\u1d50\u1d52\u1d56) :=\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\u2081 : UniformSpace \u03b1] [u\u2082 : UniformSpace \u03b2] : UniformSpace (\u03b1 \u00d7 \u03b2) :=\n  u\u2081.comap Prod.fst \u2293 u\u2082.comap Prod.snd\n\n-- check the above produces no diamond\nexample [u\u2081 : UniformSpace \u03b1] [u\u2082 : UniformSpace \u03b2] :\n    (Prod.topologicalSpace : TopologicalSpace (\u03b1 \u00d7 \u03b2)) = UniformSpace.toTopologicalSpace :=\n  rfl\n\n/- warning: uniformity_prod -> uniformity_prod is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Eq.{succ (max u1 u2)} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (uniformity.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (Inf.inf.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (Filter.hasInf.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (Filter.comap.{max u1 u2, u1} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (uniformity.{u1} \u03b1 _inst_1)) (Filter.comap.{max u1 u2, u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u2, u2} \u03b2 \u03b2) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (uniformity.{u2} \u03b2 _inst_2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Eq.{max (succ u1) (succ u2)} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (uniformity.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (Inf.inf.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (Filter.instInfFilter.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (Filter.comap.{max u1 u2, u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (uniformity.{u1} \u03b1 _inst_1)) (Filter.comap.{max u1 u2, u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u2, u2} \u03b2 \u03b2) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (uniformity.{u2} \u03b2 _inst_2)))\nCase conversion may be inaccurate. Consider using '#align uniformity_prod uniformity_prod\u2093'. -/\ntheorem uniformity_prod [UniformSpace \u03b1] [UniformSpace \u03b2] :\n    \ud835\udce4 (\u03b1 \u00d7 \u03b2) =\n      ((\ud835\udce4 \u03b1).comap fun p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2 => (p.1.1, p.2.1)) \u2293\n        (\ud835\udce4 \u03b2).comap fun p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2 => (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Eq.{succ (max u1 u2)} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (uniformity.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (Filter.comap.{max u1 u2, max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2)) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) (Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (Prod.mk.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)))) (Filter.prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) (uniformity.{u1} \u03b1 _inst_1) (uniformity.{u2} \u03b2 _inst_2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Eq.{max (succ u1) (succ u2)} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (uniformity.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (Filter.comap.{max u1 u2, max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2)) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) (Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (Prod.mk.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)))) (Filter.prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) (uniformity.{u1} \u03b1 _inst_1) (uniformity.{u2} \u03b2 _inst_2)))\nCase conversion may be inaccurate. Consider using '#align uniformity_prod_eq_comap_prod uniformity_prod_eq_comap_prod\u2093'. -/\ntheorem uniformity_prod_eq_comap_prod [UniformSpace \u03b1] [UniformSpace \u03b2] :\n    \ud835\udce4 (\u03b1 \u00d7 \u03b2) = comap (fun p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2 => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (\ud835\udce4 \u03b1 \u00d7\u1da0 \ud835\udce4 \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Eq.{succ (max u1 u2)} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (uniformity.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (Filter.map.{max u1 u2, max u1 u2} (Prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2)) (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2)) => Prod.mk.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) (Prod.mk.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) p)) (Prod.fst.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) p))) (Prod.mk.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) p)) (Prod.snd.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) p)))) (Filter.prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) (uniformity.{u1} \u03b1 _inst_1) (uniformity.{u2} \u03b2 _inst_2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Eq.{max (succ u1) (succ u2)} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (uniformity.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (Filter.map.{max u1 u2, max u2 u1} (Prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2)) (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2)) => Prod.mk.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) (Prod.mk.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) p)) (Prod.fst.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) p))) (Prod.mk.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) p)) (Prod.snd.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) p)))) (Filter.prod.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{u2, u2} \u03b2 \u03b2) (uniformity.{u1} \u03b1 _inst_1) (uniformity.{u2} \u03b2 _inst_2)))\nCase conversion may be inaccurate. Consider using '#align uniformity_prod_eq_prod uniformity_prod_eq_prod\u2093'. -/\ntheorem uniformity_prod_eq_prod [UniformSpace \u03b1] [UniformSpace \u03b2] :\n    \ud835\udce4 (\u03b1 \u00d7 \u03b2) = map (fun p : (\u03b1 \u00d7 \u03b1) \u00d7 \u03b2 \u00d7 \u03b2 => ((p.1.1, p.2.1), (p.1.2, p.2.2))) (\ud835\udce4 \u03b1 \u00d7\u1da0 \ud835\udce4 \u03b2) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] {s : Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)} {f : \u03b1 -> \u03b1 -> \u03b2}, (UniformContinuous.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (Prod.uniformSpace.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_2 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => f (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))) -> (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.hasMem.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) s (uniformity.{u2} \u03b2 _inst_2)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (u : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) u (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) u (uniformity.{u1} \u03b1 _inst_1)) => forall (a : \u03b1) (b : \u03b1) (c : \u03b1), (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) u) -> (Membership.Mem.{u2, u2} (Prod.{u2, u2} \u03b2 \u03b2) (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Set.hasMem.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Prod.mk.{u2, u2} \u03b2 \u03b2 (f a c) (f b c)) s))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] {s : Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)} {f : \u03b1 -> \u03b1 -> \u03b2}, (UniformContinuous.{u1, u2} (Prod.{u1, u1} \u03b1 \u03b1) \u03b2 (instUniformSpaceProd.{u1, u1} \u03b1 \u03b1 _inst_1 _inst_1) _inst_2 (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => f (Prod.fst.{u1, u1} \u03b1 \u03b1 p) (Prod.snd.{u1, u1} \u03b1 \u03b1 p))) -> (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) s (uniformity.{u2} \u03b2 _inst_2)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (u : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) u (uniformity.{u1} \u03b1 _inst_1)) (forall (a : \u03b1) (b : \u03b1) (c : \u03b1), (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 a b) u) -> (Membership.mem.{u2, u2} (Prod.{u2, u2} \u03b2 \u03b2) (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Prod.mk.{u2, u2} \u03b2 \u03b2 (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\u2093'. -/\ntheorem mem_uniformity_of_uniformContinuous_invariant [UniformSpace \u03b1] [UniformSpace \u03b2]\n    {s : Set (\u03b2 \u00d7 \u03b2)} {f : \u03b1 \u2192 \u03b1 \u2192 \u03b2} (hf : UniformContinuous fun p : \u03b1 \u00d7 \u03b1 => f p.1 p.2)\n    (hs : s \u2208 \ud835\udce4 \u03b2) : \u2203 u \u2208 \ud835\udce4 \u03b1, \u2200 a b c, (a, b) \u2208 u \u2192 (f a c, f b c) \u2208 s :=\n  by\n  rw [UniformContinuous, uniformity_prod_eq_prod, tendsto_map'_iff, (\u00b7 \u2218 \u00b7)] at hf\n  rcases mem_prod_iff.1 (mem_map.1 <| hf hs) with \u27e8u, hu, v, hv, huvt\u27e9\n  exact \u27e8u, hu, fun a b c hab => @huvt ((_, _), (_, _)) \u27e8hab, refl_mem_uniformity hv\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [t\u2081 : UniformSpace.{u1} \u03b1] [t\u2082 : UniformSpace.{u2} \u03b2] {a : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)} {b : Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) a (uniformity.{u1} \u03b1 t\u2081)) -> (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.hasMem.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) b (uniformity.{u2} \u03b2 t\u2082)) -> (Membership.Mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (Filter.hasMem.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (setOf.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => And (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) a) (Membership.Mem.{u2, u2} (Prod.{u2, u2} \u03b2 \u03b2) (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Set.hasMem.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Prod.mk.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) b))) (uniformity.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 t\u2081 t\u2082)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [t\u2081 : UniformSpace.{u1} \u03b1] [t\u2082 : UniformSpace.{u2} \u03b2] {a : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)} {b : Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) a (uniformity.{u1} \u03b1 t\u2081)) -> (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) b (uniformity.{u2} \u03b2 t\u2082)) -> (Membership.mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (instMembershipSetFilter.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2))) (setOf.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => And (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) a) (Membership.mem.{u2, u2} (Prod.{u2, u2} \u03b2 \u03b2) (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Prod.mk.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) b))) (uniformity.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 t\u2081 t\u2082)))\nCase conversion may be inaccurate. Consider using '#align mem_uniform_prod mem_uniform_prod\u2093'. -/\ntheorem mem_uniform_prod [t\u2081 : UniformSpace \u03b1] [t\u2082 : UniformSpace \u03b2] {a : Set (\u03b1 \u00d7 \u03b1)}\n    {b : Set (\u03b2 \u00d7 \u03b2)} (ha : a \u2208 \ud835\udce4 \u03b1) (hb : b \u2208 \ud835\udce4 \u03b2) :\n    { p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2 | (p.1.1, p.2.1) \u2208 a \u2227 (p.1.2, p.2.2) \u2208 b } \u2208 \ud835\udce4 (\u03b1 \u00d7 \u03b2) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Filter.Tendsto.{max u1 u2, u1} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (uniformity.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (uniformity.{u1} \u03b1 _inst_1)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Filter.Tendsto.{max u1 u2, u1} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u1, u1} \u03b1 \u03b1) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u1, u1} \u03b1 \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.fst.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (uniformity.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (uniformity.{u1} \u03b1 _inst_1)\nCase conversion may be inaccurate. Consider using '#align tendsto_prod_uniformity_fst tendsto_prod_uniformity_fst\u2093'. -/\ntheorem tendsto_prod_uniformity_fst [UniformSpace \u03b1] [UniformSpace \u03b2] :\n    Tendsto (fun p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2 => (p.1.1, p.2.1)) (\ud835\udce4 (\u03b1 \u00d7 \u03b2)) (\ud835\udce4 \u03b1) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Filter.Tendsto.{max u1 u2, u2} (Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u2, u2} \u03b2 \u03b2) (fun (p : Prod.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (uniformity.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (uniformity.{u2} \u03b2 _inst_2)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Filter.Tendsto.{max u1 u2, u2} (Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) (Prod.{u2, u2} \u03b2 \u03b2) (fun (p : Prod.{max u2 u1, max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2)) => Prod.mk.{u2, u2} \u03b2 \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.fst.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p)) (Prod.snd.{u1, u2} \u03b1 \u03b2 (Prod.snd.{max u1 u2, max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u1, u2} \u03b1 \u03b2) p))) (uniformity.{max u2 u1} (Prod.{u1, u2} \u03b1 \u03b2) (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (uniformity.{u2} \u03b2 _inst_2)\nCase conversion may be inaccurate. Consider using '#align tendsto_prod_uniformity_snd tendsto_prod_uniformity_snd\u2093'. -/\ntheorem tendsto_prod_uniformity_snd [UniformSpace \u03b1] [UniformSpace \u03b2] :\n    Tendsto (fun p : (\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2 => (p.1.2, p.2.2)) (\ud835\udce4 (\u03b1 \u00d7 \u03b2)) (\ud835\udce4 \u03b2) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], UniformContinuous.{max u1 u2, u1} (Prod.{u1, u2} \u03b1 \u03b2) \u03b1 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_1 (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => Prod.fst.{u1, u2} \u03b1 \u03b2 p)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], UniformContinuous.{max u1 u2, u1} (Prod.{u1, u2} \u03b1 \u03b2) \u03b1 (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_1 (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => Prod.fst.{u1, u2} \u03b1 \u03b2 p)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_fst uniformContinuous_fst\u2093'. -/\ntheorem uniformContinuous_fst [UniformSpace \u03b1] [UniformSpace \u03b2] :\n    UniformContinuous fun p : \u03b1 \u00d7 \u03b2 => 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], UniformContinuous.{max u1 u2, u2} (Prod.{u1, u2} \u03b1 \u03b2) \u03b2 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_2 (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => Prod.snd.{u1, u2} \u03b1 \u03b2 p)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], UniformContinuous.{max u1 u2, u2} (Prod.{u1, u2} \u03b1 \u03b2) \u03b2 (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_2 (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => Prod.snd.{u1, u2} \u03b1 \u03b2 p)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_snd uniformContinuous_snd\u2093'. -/\ntheorem uniformContinuous_snd [UniformSpace \u03b1] [UniformSpace \u03b2] :\n    UniformContinuous fun p : \u03b1 \u00d7 \u03b2 => p.2 :=\n  tendsto_prod_uniformity_snd\n#align uniform_continuous_snd uniformContinuous_snd\n\nvariable [UniformSpace \u03b1] [UniformSpace \u03b2] [UniformSpace \u03b3]\n\n/- warning: uniform_continuous.prod_mk -> UniformContinuous.prod_mk is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] {f\u2081 : \u03b1 -> \u03b2} {f\u2082 : \u03b1 -> \u03b3}, (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f\u2081) -> (UniformContinuous.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 f\u2082) -> (UniformContinuous.{u1, max u2 u3} \u03b1 (Prod.{u2, u3} \u03b2 \u03b3) _inst_1 (Prod.uniformSpace.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (a : \u03b1) => Prod.mk.{u2, u3} \u03b2 \u03b3 (f\u2081 a) (f\u2082 a)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] {f\u2081 : \u03b1 -> \u03b2} {f\u2082 : \u03b1 -> \u03b3}, (UniformContinuous.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2 f\u2081) -> (UniformContinuous.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 f\u2082) -> (UniformContinuous.{u1, max u3 u2} \u03b1 (Prod.{u2, u3} \u03b2 \u03b3) _inst_1 (instUniformSpaceProd.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3) (fun (a : \u03b1) => Prod.mk.{u2, u3} \u03b2 \u03b3 (f\u2081 a) (f\u2082 a)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.prod_mk UniformContinuous.prod_mk\u2093'. -/\ntheorem UniformContinuous.prod_mk {f\u2081 : \u03b1 \u2192 \u03b2} {f\u2082 : \u03b1 \u2192 \u03b3} (h\u2081 : UniformContinuous f\u2081)\n    (h\u2082 : UniformContinuous f\u2082) : UniformContinuous fun a => (f\u2081 a, f\u2082 a) := by\n  rw [UniformContinuous, uniformity_prod] <;>\n    exact tendsto_inf.2 \u27e8tendsto_comap_iff.2 h\u2081, tendsto_comap_iff.2 h\u2082\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] {f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03b3}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 f) -> (forall (b : \u03b2), UniformContinuous.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 (fun (a : \u03b1) => f (Prod.mk.{u1, u2} \u03b1 \u03b2 a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] {f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03b3}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 f) -> (forall (b : \u03b2), UniformContinuous.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 (fun (a : \u03b1) => f (Prod.mk.{u1, u2} \u03b1 \u03b2 a b)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.prod_mk_left UniformContinuous.prod_mk_left\u2093'. -/\ntheorem UniformContinuous.prod_mk_left {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] {f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03b3}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 f) -> (forall (a : \u03b1), UniformContinuous.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3 (fun (b : \u03b2) => f (Prod.mk.{u1, u2} \u03b1 \u03b2 a b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] {f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03b3}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 f) -> (forall (a : \u03b1), UniformContinuous.{u2, u3} \u03b2 \u03b3 _inst_2 _inst_3 (fun (b : \u03b2) => f (Prod.mk.{u1, u2} \u03b1 \u03b2 a b)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.prod_mk_right UniformContinuous.prod_mk_right\u2093'. -/\ntheorem UniformContinuous.prod_mk_right {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] [_inst_4 : UniformSpace.{u4} \u03b4] {f : \u03b1 -> \u03b3} {g : \u03b2 -> \u03b4}, (UniformContinuous.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 f) -> (UniformContinuous.{u2, u4} \u03b2 \u03b4 _inst_2 _inst_4 g) -> (UniformContinuous.{max u1 u2, max u3 u4} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u3, u4} \u03b3 \u03b4) (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (Prod.uniformSpace.{u3, u4} \u03b3 \u03b4 _inst_3 _inst_4) (Prod.map.{u1, u3, u2, u4} \u03b1 \u03b3 \u03b2 \u03b4 f g))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] [_inst_4 : UniformSpace.{u4} \u03b4] {f : \u03b1 -> \u03b3} {g : \u03b2 -> \u03b4}, (UniformContinuous.{u1, u3} \u03b1 \u03b3 _inst_1 _inst_3 f) -> (UniformContinuous.{u2, u4} \u03b2 \u03b4 _inst_2 _inst_4 g) -> (UniformContinuous.{max u2 u1, max u4 u3} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.{u3, u4} \u03b3 \u03b4) (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) (instUniformSpaceProd.{u3, u4} \u03b3 \u03b4 _inst_3 _inst_4) (Prod.map.{u1, u3, u2, u4} \u03b1 \u03b3 \u03b2 \u03b4 f g))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous.prod_map UniformContinuous.prod_map\u2093'. -/\ntheorem UniformContinuous.prod_map [UniformSpace \u03b4] {f : \u03b1 \u2192 \u03b3} {g : \u03b2 \u2192 \u03b4}\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [u : UniformSpace.{u1} \u03b1] [v : UniformSpace.{u2} \u03b2], Eq.{succ (max u1 u2)} (TopologicalSpace.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (UniformSpace.toTopologicalSpace.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 u v)) (Prod.topologicalSpace.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 u) (UniformSpace.toTopologicalSpace.{u2} \u03b2 v))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [u : UniformSpace.{u2} \u03b1] [v : UniformSpace.{u1} \u03b2], Eq.{max (succ u2) (succ u1)} (TopologicalSpace.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (UniformSpace.toTopologicalSpace.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2) (instUniformSpaceProd.{u2, u1} \u03b1 \u03b2 u v)) (instTopologicalSpaceProd.{u2, u1} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b1 u) (UniformSpace.toTopologicalSpace.{u1} \u03b2 v))\nCase conversion may be inaccurate. Consider using '#align to_topological_space_prod toTopologicalSpace_prod\u2093'. -/\ntheorem toTopologicalSpace_prod {\u03b1} {\u03b2} [u : UniformSpace \u03b1] [v : UniformSpace \u03b2] :\n    @UniformSpace.toTopologicalSpace (\u03b1 \u00d7 \u03b2) Prod.uniformSpace =\n      @Prod.topologicalSpace \u03b1 \u03b2 u.toTopologicalSpace v.toTopologicalSpace :=\n  rfl\n#align to_topological_space_prod toTopologicalSpace_prod\n\n/- warning: uniform_continuous_inf_dom_left\u2082 -> uniformContinuous_inf_dom_left\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {ua1 : UniformSpace.{u1} \u03b1} {ua2 : UniformSpace.{u1} \u03b1} {ub1 : UniformSpace.{u2} \u03b2} {ub2 : UniformSpace.{u2} \u03b2} {uc1 : UniformSpace.{u3} \u03b3}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 ua1 ub1) uc1 (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => f (Prod.fst.{u1, u2} \u03b1 \u03b2 p) (Prod.snd.{u1, u2} \u03b1 \u03b2 p))) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 (Inf.inf.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) ua1 ua2) (Inf.inf.{u2} (UniformSpace.{u2} \u03b2) (UniformSpace.hasInf.{u2} \u03b2) ub1 ub2)) uc1 (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => f (Prod.fst.{u1, u2} \u03b1 \u03b2 p) (Prod.snd.{u1, u2} \u03b1 \u03b2 p)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {f : \u03b1 -> \u03b2 -> \u03b3} {ua1 : UniformSpace.{u3} \u03b1} {ua2 : UniformSpace.{u3} \u03b1} {ub1 : UniformSpace.{u2} \u03b2} {ub2 : UniformSpace.{u2} \u03b2} {uc1 : UniformSpace.{u1} \u03b3}, (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u3, u2} \u03b1 \u03b2 ua1 ub1) uc1 (fun (p : Prod.{u3, u2} \u03b1 \u03b2) => f (Prod.fst.{u3, u2} \u03b1 \u03b2 p) (Prod.snd.{u3, u2} \u03b1 \u03b2 p))) -> (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u3, u2} \u03b1 \u03b2 (Inf.inf.{u3} (UniformSpace.{u3} \u03b1) (instInfUniformSpace.{u3} \u03b1) ua1 ua2) (Inf.inf.{u2} (UniformSpace.{u2} \u03b2) (instInfUniformSpace.{u2} \u03b2) ub1 ub2)) uc1 (fun (p : Prod.{u3, u2} \u03b1 \u03b2) => f (Prod.fst.{u3, u2} \u03b1 \u03b2 p) (Prod.snd.{u3, u2} \u03b1 \u03b2 p)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_inf_dom_left\u2082 uniformContinuous_inf_dom_left\u2082\u2093'. -/\n/-- A version of `uniform_continuous_inf_dom_left` for binary functions -/\ntheorem uniformContinuous_inf_dom_left\u2082 {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {ua1 ua2 : UniformSpace \u03b1}\n    {ub1 ub2 : UniformSpace \u03b2} {uc1 : UniformSpace \u03b3}\n    (h : by haveI := ua1 <;> haveI := ub1 <;> exact UniformContinuous fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2) :\n    by\n    haveI := ua1 \u2293 ua2 <;> haveI := ub1 \u2293 ub2 <;>\n      exact UniformContinuous fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2 :=\n  by\n  -- proof essentially copied from ``continuous_inf_dom_left\u2082`\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 \u2293 ua2) (ub1 \u2293 ub2) ua1 ub1 _ _ ha hb\n  exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id\n#align uniform_continuous_inf_dom_left\u2082 uniformContinuous_inf_dom_left\u2082\n\n/- warning: uniform_continuous_inf_dom_right\u2082 -> uniformContinuous_inf_dom_right\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {ua1 : UniformSpace.{u1} \u03b1} {ua2 : UniformSpace.{u1} \u03b1} {ub1 : UniformSpace.{u2} \u03b2} {ub2 : UniformSpace.{u2} \u03b2} {uc1 : UniformSpace.{u3} \u03b3}, (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 ua2 ub2) uc1 (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => f (Prod.fst.{u1, u2} \u03b1 \u03b2 p) (Prod.snd.{u1, u2} \u03b1 \u03b2 p))) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 (Inf.inf.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) ua1 ua2) (Inf.inf.{u2} (UniformSpace.{u2} \u03b2) (UniformSpace.hasInf.{u2} \u03b2) ub1 ub2)) uc1 (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => f (Prod.fst.{u1, u2} \u03b1 \u03b2 p) (Prod.snd.{u1, u2} \u03b1 \u03b2 p)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {f : \u03b1 -> \u03b2 -> \u03b3} {ua1 : UniformSpace.{u3} \u03b1} {ua2 : UniformSpace.{u3} \u03b1} {ub1 : UniformSpace.{u2} \u03b2} {ub2 : UniformSpace.{u2} \u03b2} {uc1 : UniformSpace.{u1} \u03b3}, (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u3, u2} \u03b1 \u03b2 ua2 ub2) uc1 (fun (p : Prod.{u3, u2} \u03b1 \u03b2) => f (Prod.fst.{u3, u2} \u03b1 \u03b2 p) (Prod.snd.{u3, u2} \u03b1 \u03b2 p))) -> (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u3, u2} \u03b1 \u03b2 (Inf.inf.{u3} (UniformSpace.{u3} \u03b1) (instInfUniformSpace.{u3} \u03b1) ua1 ua2) (Inf.inf.{u2} (UniformSpace.{u2} \u03b2) (instInfUniformSpace.{u2} \u03b2) ub1 ub2)) uc1 (fun (p : Prod.{u3, u2} \u03b1 \u03b2) => f (Prod.fst.{u3, u2} \u03b1 \u03b2 p) (Prod.snd.{u3, u2} \u03b1 \u03b2 p)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_inf_dom_right\u2082 uniformContinuous_inf_dom_right\u2082\u2093'. -/\n/-- A version of `uniform_continuous_inf_dom_right` for binary functions -/\ntheorem uniformContinuous_inf_dom_right\u2082 {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {ua1 ua2 : UniformSpace \u03b1}\n    {ub1 ub2 : UniformSpace \u03b2} {uc1 : UniformSpace \u03b3}\n    (h : by haveI := ua2 <;> haveI := ub2 <;> exact UniformContinuous fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2) :\n    by\n    haveI := ua1 \u2293 ua2 <;> haveI := ub1 \u2293 ub2 <;>\n      exact UniformContinuous fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2 :=\n  by\n  -- proof essentially copied from ``continuous_inf_dom_right\u2082`\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 \u2293 ua2) (ub1 \u2293 ub2) ua2 ub2 _ _ ha hb\n  exact @UniformContinuous.comp _ _ _ (id _) (id _) _ _ _ h h_unif_cont_id\n#align uniform_continuous_inf_dom_right\u2082 uniformContinuous_inf_dom_right\u2082\n\n/- warning: uniform_continuous_Inf_dom\u2082 -> uniformContinuous_inf\u209b_dom\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {f : \u03b1 -> \u03b2 -> \u03b3} {uas : Set.{u1} (UniformSpace.{u1} \u03b1)} {ubs : Set.{u2} (UniformSpace.{u2} \u03b2)} {ua : UniformSpace.{u1} \u03b1} {ub : UniformSpace.{u2} \u03b2} {uc : UniformSpace.{u3} \u03b3}, (Membership.Mem.{u1, u1} (UniformSpace.{u1} \u03b1) (Set.{u1} (UniformSpace.{u1} \u03b1)) (Set.hasMem.{u1} (UniformSpace.{u1} \u03b1)) ua uas) -> (Membership.Mem.{u2, u2} (UniformSpace.{u2} \u03b2) (Set.{u2} (UniformSpace.{u2} \u03b2)) (Set.hasMem.{u2} (UniformSpace.{u2} \u03b2)) ub ubs) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 ua ub) uc (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => f (Prod.fst.{u1, u2} \u03b1 \u03b2 p) (Prod.snd.{u1, u2} \u03b1 \u03b2 p))) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 (InfSet.inf\u209b.{u1} (UniformSpace.{u1} \u03b1) (UniformSpace.hasInf.{u1} \u03b1) uas) (InfSet.inf\u209b.{u2} (UniformSpace.{u2} \u03b2) (UniformSpace.hasInf.{u2} \u03b2) ubs)) uc (fun (p : Prod.{u1, u2} \u03b1 \u03b2) => f (Prod.fst.{u1, u2} \u03b1 \u03b2 p) (Prod.snd.{u1, u2} \u03b1 \u03b2 p)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} {f : \u03b1 -> \u03b2 -> \u03b3} {uas : Set.{u3} (UniformSpace.{u3} \u03b1)} {ubs : Set.{u2} (UniformSpace.{u2} \u03b2)} {ua : UniformSpace.{u3} \u03b1} {ub : UniformSpace.{u2} \u03b2} {uc : UniformSpace.{u1} \u03b3}, (Membership.mem.{u3, u3} (UniformSpace.{u3} \u03b1) (Set.{u3} (UniformSpace.{u3} \u03b1)) (Set.instMembershipSet.{u3} (UniformSpace.{u3} \u03b1)) ua uas) -> (Membership.mem.{u2, u2} (UniformSpace.{u2} \u03b2) (Set.{u2} (UniformSpace.{u2} \u03b2)) (Set.instMembershipSet.{u2} (UniformSpace.{u2} \u03b2)) ub ubs) -> (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u3, u2} \u03b1 \u03b2 ua ub) uc (fun (p : Prod.{u3, u2} \u03b1 \u03b2) => f (Prod.fst.{u3, u2} \u03b1 \u03b2 p) (Prod.snd.{u3, u2} \u03b1 \u03b2 p))) -> (UniformContinuous.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u3, u2} \u03b1 \u03b2 (InfSet.inf\u209b.{u3} (UniformSpace.{u3} \u03b1) (instInfSetUniformSpace.{u3} \u03b1) uas) (InfSet.inf\u209b.{u2} (UniformSpace.{u2} \u03b2) (instInfSetUniformSpace.{u2} \u03b2) ubs)) uc (fun (p : Prod.{u3, u2} \u03b1 \u03b2) => f (Prod.fst.{u3, u2} \u03b1 \u03b2 p) (Prod.snd.{u3, u2} \u03b1 \u03b2 p)))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous_Inf_dom\u2082 uniformContinuous_inf\u209b_dom\u2082\u2093'. -/\n/-- A version of `uniform_continuous_Inf_dom` for binary functions -/\ntheorem uniformContinuous_inf\u209b_dom\u2082 {\u03b1 \u03b2 \u03b3} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {uas : Set (UniformSpace \u03b1)}\n    {ubs : Set (UniformSpace \u03b2)} {ua : UniformSpace \u03b1} {ub : UniformSpace \u03b2} {uc : UniformSpace \u03b3}\n    (ha : ua \u2208 uas) (hb : ub \u2208 ubs) (hf : UniformContinuous fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2) : by\n    haveI := Inf uas <;> haveI := Inf ubs <;>\n      exact @UniformContinuous _ _ _ uc fun p : \u03b1 \u00d7 \u03b2 => f p.1 p.2 :=\n  by\n  -- proof essentially copied from ``continuous_Inf_dom`\n  let t : UniformSpace (\u03b1 \u00d7 \u03b2) := Prod.uniformSpace\n  have ha := uniformContinuous_inf\u209b_dom ha uniformContinuous_id\n  have hb := uniformContinuous_inf\u209b_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\u2082 uniformContinuous_inf\u209b_dom\u2082\n\nend Prod\n\nsection\n\nopen UniformSpace Function\n\nvariable {\u03b4' : Type _} [UniformSpace \u03b1] [UniformSpace \u03b2] [UniformSpace \u03b3] [UniformSpace \u03b4]\n  [UniformSpace \u03b4']\n\n-- mathport name: \u00abexpr \u2218\u2082 \u00bb\nlocal notation f \" \u2218\u2082 \" g => Function.bicompr f g\n\n#print UniformContinuous\u2082 /-\n/-- Uniform continuity for functions of two variables. -/\ndef UniformContinuous\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :=\n  UniformContinuous (uncurry f)\n#align uniform_continuous\u2082 UniformContinuous\u2082\n-/\n\n/- warning: uniform_continuous\u2082_def -> uniformContinuous\u2082_def is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3), Iff (UniformContinuous\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f) (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3), Iff (UniformContinuous\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f) (UniformContinuous.{max u2 u1, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous\u2082_def uniformContinuous\u2082_def\u2093'. -/\ntheorem uniformContinuous\u2082_def (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :\n    UniformContinuous\u2082 f \u2194 UniformContinuous (uncurry f) :=\n  Iff.rfl\n#align uniform_continuous\u2082_def uniformContinuous\u2082_def\n\n/- warning: uniform_continuous\u2082.uniform_continuous -> UniformContinuous\u2082.uniformContinuous is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3}, (UniformContinuous\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f) -> (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3}, (UniformContinuous\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f) -> (UniformContinuous.{max u2 u1, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 (Function.uncurry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous\u2082.uniform_continuous UniformContinuous\u2082.uniformContinuous\u2093'. -/\ntheorem UniformContinuous\u2082.uniformContinuous {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} (h : UniformContinuous\u2082 f) :\n    UniformContinuous (uncurry f) :=\n  h\n#align uniform_continuous\u2082.uniform_continuous UniformContinuous\u2082.uniformContinuous\n\n/- warning: uniform_continuous\u2082_curry -> uniformContinuous\u2082_curry is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] (f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03b3), Iff (UniformContinuous\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 (Function.curry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f)) (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (Prod.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] (f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03b3), Iff (UniformContinuous\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 (Function.curry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f)) (UniformContinuous.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (instUniformSpaceProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2) _inst_3 f)\nCase conversion may be inaccurate. Consider using '#align uniform_continuous\u2082_curry uniformContinuous\u2082_curry\u2093'. -/\ntheorem uniformContinuous\u2082_curry (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) :\n    UniformContinuous\u2082 (Function.curry f) \u2194 UniformContinuous f := by\n  rw [UniformContinuous\u2082, uncurry_curry]\n#align uniform_continuous\u2082_curry uniformContinuous\u2082_curry\n\n#print UniformContinuous\u2082.comp /-\ntheorem UniformContinuous\u2082.comp {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {g : \u03b3 \u2192 \u03b4} (hg : UniformContinuous g)\n    (hf : UniformContinuous\u2082 f) : UniformContinuous\u2082 (g \u2218\u2082 f) :=\n  hg.comp hf\n#align uniform_continuous\u2082.comp UniformContinuous\u2082.comp\n-/\n\n/- warning: uniform_continuous\u2082.bicompl -> UniformContinuous\u2082.bicompl is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} {\u03b4' : Type.{u5}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] [_inst_3 : UniformSpace.{u3} \u03b3] [_inst_4 : UniformSpace.{u4} \u03b4] [_inst_5 : UniformSpace.{u5} \u03b4'] {f : \u03b1 -> \u03b2 -> \u03b3} {ga : \u03b4 -> \u03b1} {gb : \u03b4' -> \u03b2}, (UniformContinuous\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f) -> (UniformContinuous.{u4, u1} \u03b4 \u03b1 _inst_4 _inst_1 ga) -> (UniformContinuous.{u5, u2} \u03b4' \u03b2 _inst_5 _inst_2 gb) -> (UniformContinuous\u2082.{u4, u5, u3} \u03b4 \u03b4' \u03b3 _inst_4 _inst_5 _inst_3 (Function.bicompl.{u4, u5, u1, u2, u3} \u03b4 \u03b4' \u03b1 \u03b2 \u03b3 f ga gb))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} {\u03b4' : Type.{u1}} [_inst_1 : UniformSpace.{u2} \u03b1] [_inst_2 : UniformSpace.{u3} \u03b2] [_inst_3 : UniformSpace.{u4} \u03b3] [_inst_4 : UniformSpace.{u5} \u03b4] [_inst_5 : UniformSpace.{u1} \u03b4'] {f : \u03b1 -> \u03b2 -> \u03b3} {ga : \u03b4 -> \u03b1} {gb : \u03b4' -> \u03b2}, (UniformContinuous\u2082.{u2, u3, u4} \u03b1 \u03b2 \u03b3 _inst_1 _inst_2 _inst_3 f) -> (UniformContinuous.{u5, u2} \u03b4 \u03b1 _inst_4 _inst_1 ga) -> (UniformContinuous.{u1, u3} \u03b4' \u03b2 _inst_5 _inst_2 gb) -> (UniformContinuous\u2082.{u5, u1, u4} \u03b4 \u03b4' \u03b3 _inst_4 _inst_5 _inst_3 (Function.bicompl.{u5, u1, u2, u3, u4} \u03b4 \u03b4' \u03b1 \u03b2 \u03b3 f ga gb))\nCase conversion may be inaccurate. Consider using '#align uniform_continuous\u2082.bicompl UniformContinuous\u2082.bicompl\u2093'. -/\ntheorem UniformContinuous\u2082.bicompl {f : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {ga : \u03b4 \u2192 \u03b1} {gb : \u03b4' \u2192 \u03b2}\n    (hf : UniformContinuous\u2082 f) (hga : UniformContinuous ga) (hgb : UniformContinuous gb) :\n    UniformContinuous\u2082 (bicompl f ga gb) :=\n  hf.UniformContinuous.comp (hga.Prod_map hgb)\n#align uniform_continuous\u2082.bicompl UniformContinuous\u2082.bicompl\n\nend\n\n#print toTopologicalSpace_subtype /-\ntheorem toTopologicalSpace_subtype [u : UniformSpace \u03b1] {p : \u03b1 \u2192 Prop} :\n    @UniformSpace.toTopologicalSpace (Subtype p) Subtype.uniformSpace =\n      @Subtype.topologicalSpace \u03b1 p u.toTopologicalSpace :=\n  rfl\n#align to_topological_space_subtype toTopologicalSpace_subtype\n-/\n\nsection Sum\n\nvariable [UniformSpace \u03b1] [UniformSpace \u03b2]\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 \u03b1 \u03b2) :=\n  UniformSpace.Core.mk'\n    (map (fun p : \u03b1 \u00d7 \u03b1 => (inl p.1, inl p.2)) (\ud835\udce4 \u03b1) \u2294\n      map (fun p : \u03b2 \u00d7 \u03b2 => (inr p.1, inr p.2)) (\ud835\udce4 \u03b2))\n    (fun r \u27e8H\u2081, H\u2082\u27e9 x => by\n      cases x <;> [apply refl_mem_uniformity H\u2081, apply refl_mem_uniformity H\u2082])\n    (fun r \u27e8H\u2081, H\u2082\u27e9 => \u27e8symm_le_uniformity H\u2081, symm_le_uniformity H\u2082\u27e9) fun r \u27e8Hr\u03b1, Hr\u03b2\u27e9 =>\n    by\n    rcases comp_mem_uniformity_sets Hr\u03b1 with \u27e8t\u03b1, ht\u03b1, Ht\u03b1\u27e9\n    rcases comp_mem_uniformity_sets Hr\u03b2 with \u27e8t\u03b2, ht\u03b2, Ht\u03b2\u27e9\n    refine'\n      \u27e8_,\n        \u27e8mem_map_iff_exists_image.2 \u27e8t\u03b1, ht\u03b1, subset_union_left _ _\u27e9,\n          mem_map_iff_exists_image.2 \u27e8t\u03b2, ht\u03b2, subset_union_right _ _\u27e9\u27e9,\n        _\u27e9\n    rintro \u27e8_, _\u27e9 \u27e8z, \u27e8\u27e8a, b\u27e9, hab, \u27e8\u27e9\u27e9 | \u27e8\u27e8a, b\u27e9, hab, \u27e8\u27e9\u27e9, \u27e8\u27e8_, c\u27e9, hbc, \u27e8\u27e9\u27e9 | \u27e8\u27e8_, c\u27e9, hbc, \u27e8\u27e9\u27e9\u27e9\n    \u00b7 have A : (a, c) \u2208 t\u03b1 \u25cb t\u03b1 := \u27e8b, hab, hbc\u27e9\n      exact Ht\u03b1 A\n    \u00b7 have A : (a, c) \u2208 t\u03b2 \u25cb t\u03b2 := \u27e8b, hab, hbc\u27e9\n      exact Ht\u03b2 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] {a : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) a (uniformity.{u1} \u03b1 _inst_1)) -> (forall {b : Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)}, (Membership.Mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.hasMem.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) b (uniformity.{u2} \u03b2 _inst_2)) -> (Membership.Mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.hasMem.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Union.union.{max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Set.hasUnion.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Set.image.{u1, max u1 u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u1, u1} \u03b1 \u03b1 p)) (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u1, u1} \u03b1 \u03b1 p))) a) (Set.image.{u2, max u1 u2} (Prod.{u2, u2} \u03b2 \u03b2) (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u2, u2} \u03b2 \u03b2) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u2, u2} \u03b2 \u03b2 p)) (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u2, u2} \u03b2 \u03b2 p))) b)) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (UniformSpace.Core.sum.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] {a : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)}, (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) a (uniformity.{u1} \u03b1 _inst_1)) -> (forall {b : Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)}, (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (Filter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} \u03b2 \u03b2)) b (uniformity.{u2} \u03b2 _inst_2)) -> (Membership.mem.{max u2 u1, max u1 u2} (Set.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (instMembershipSetFilter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Union.union.{max u2 u1} (Set.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Set.instUnionSet.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Set.image.{u1, max u2 u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => Prod.mk.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u1, u1} \u03b1 \u03b1 p)) (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u1, u1} \u03b1 \u03b1 p))) a) (Set.image.{u2, max u1 u2} (Prod.{u2, u2} \u03b2 \u03b2) (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u2, u2} \u03b2 \u03b2) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u2, u2} \u03b2 \u03b2 p)) (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u2, u2} \u03b2 \u03b2 p))) b)) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (UniformSpace.Core.sum.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2))))\nCase conversion may be inaccurate. Consider using '#align union_mem_uniformity_sum union_mem_uniformity_sum\u2093'. -/\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 (\u03b1 \u00d7 \u03b1)} (ha : a \u2208 \ud835\udce4 \u03b1) {b : Set (\u03b2 \u00d7 \u03b2)} (hb : b \u2208 \ud835\udce4 \u03b2) :\n    (fun p : \u03b1 \u00d7 \u03b1 => (inl p.1, inl p.2)) '' a \u222a (fun p : \u03b2 \u00d7 \u03b2 => (inr p.1, inr p.2)) '' b \u2208\n      (@UniformSpace.Core.sum \u03b1 \u03b2 _ _).uniformity :=\n  \u27e8mem_map_iff_exists_image.2 \u27e8_, ha, subset_union_left _ _\u27e9,\n    mem_map_iff_exists_image.2 \u27e8_, hb, subset_union_right _ _\u27e9\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] {s : Set.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)}, (IsOpen.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.topologicalSpace.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_2)) s) -> (forall {x : Sum.{u1, u2} \u03b1 \u03b2}, (Membership.Mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Set.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) (Set.hasMem.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) x s) -> (Membership.Mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.hasMem.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (setOf.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) => (Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Prod.fst.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) p) x) -> (Membership.Mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Set.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) (Set.hasMem.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) (Prod.snd.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) p) s))) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (UniformSpace.Core.sum.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] {s : Set.{max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2)}, (IsOpen.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (instTopologicalSpaceSum.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_2)) s) -> (forall {x : Sum.{u1, u2} \u03b1 \u03b2}, (Membership.mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Set.{max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2)) (Set.instMembershipSet.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) x s) -> (Membership.mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (instMembershipSetFilter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (setOf.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) => (Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Prod.fst.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) p) x) -> (Membership.mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Set.{max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2)) (Set.instMembershipSet.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) (Prod.snd.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) p) s))) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (UniformSpace.Core.sum.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2))))\nCase conversion may be inaccurate. Consider using '#align uniformity_sum_of_open_aux uniformity_sum_of_open_aux\u2093'. -/\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 \u03b1 \u03b2)} (hs : IsOpen s) {x : Sum \u03b1 \u03b2} (xs : x \u2208 s) :\n    { p : Sum \u03b1 \u03b2 \u00d7 Sum \u03b1 \u03b2 | p.1 = x \u2192 p.2 \u2208 s } \u2208 (@UniformSpace.Core.sum \u03b1 \u03b2 _ _).uniformity :=\n  by\n  cases x\n  \u00b7 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 _ \u27e8\u27e8_, b\u27e9, h, \u27e8\u27e9\u27e9 \u27e8\u27e9\n    exact h rfl\n  \u00b7 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 _ \u27e8\u27e8a, _\u27e9, h, \u27e8\u27e9\u27e9 \u27e8\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] {s : Set.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)}, (forall (x : Sum.{u1, u2} \u03b1 \u03b2), (Membership.Mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Set.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) (Set.hasMem.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) x s) -> (Membership.Mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.hasMem.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (setOf.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) => (Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Prod.fst.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) p) x) -> (Membership.Mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Set.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) (Set.hasMem.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) (Prod.snd.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) p) s))) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (UniformSpace.Core.sum.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)))) -> (IsOpen.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.topologicalSpace.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_2)) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2] {s : Set.{max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2)}, (forall (x : Sum.{u1, u2} \u03b1 \u03b2), (Membership.mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Set.{max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2)) (Set.instMembershipSet.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) x s) -> (Membership.mem.{max u1 u2, max u1 u2} (Set.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (instMembershipSetFilter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (setOf.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) => (Eq.{max (succ u1) (succ u2)} (Sum.{u1, u2} \u03b1 \u03b2) (Prod.fst.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) p) x) -> (Membership.mem.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Set.{max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2)) (Set.instMembershipSet.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2)) (Prod.snd.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) p) s))) (UniformSpace.Core.uniformity.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (UniformSpace.Core.sum.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)))) -> (IsOpen.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (instTopologicalSpaceSum.{u1, u2} \u03b1 \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_2)) s)\nCase conversion may be inaccurate. Consider using '#align open_of_uniformity_sum_aux open_of_uniformity_sum_aux\u2093'. -/\ntheorem open_of_uniformity_sum_aux {s : Set (Sum \u03b1 \u03b2)}\n    (hs :\n      \u2200 x \u2208 s,\n        { p : Sum \u03b1 \u03b2 \u00d7 Sum \u03b1 \u03b2 | p.1 = x \u2192 p.2 \u2208 s } \u2208\n          (@UniformSpace.Core.sum \u03b1 \u03b2 _ _).uniformity) :\n    IsOpen s := by\n  constructor\n  \u00b7 refine' (@isOpen_iff_mem_nhds \u03b1 _ _).2 fun a ha => mem_nhds_uniformity_iff_right.2 _\n    rcases mem_map_iff_exists_image.1 (hs _ ha).1 with \u27e8t, ht, st\u27e9\n    refine' mem_of_superset ht _\n    rintro p pt rfl\n    exact st \u27e8_, pt, rfl\u27e9 rfl\n  \u00b7 refine' (@isOpen_iff_mem_nhds \u03b2 _ _).2 fun b hb => mem_nhds_uniformity_iff_right.2 _\n    rcases mem_map_iff_exists_image.1 (hs _ hb).2 with \u27e8t, ht, st\u27e9\n    refine' mem_of_superset ht _\n    rintro p pt rfl\n    exact st \u27e8_, pt, rfl\u27e9 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 \u03b1 \u03b2)\n    where\n  toCore := UniformSpace.Core.sum\n  isOpen_uniformity s := \u27e8uniformity_sum_of_open_aux, open_of_uniformity_sum_aux\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Eq.{succ (max u1 u2)} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (uniformity.{max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (Sup.sup.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (SemilatticeSup.toHasSup.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Lattice.toSemilatticeSup.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (ConditionallyCompleteLattice.toLattice.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (CompleteLattice.toConditionallyCompleteLattice.{max u1 u2} (Filter.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.completeLattice.{max u1 u2} (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))))))) (Filter.map.{u1, max u1 u2} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u1, u1} \u03b1 \u03b1 p)) (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u1, u1} \u03b1 \u03b1 p))) (uniformity.{u1} \u03b1 _inst_1)) (Filter.map.{u2, max u1 u2} (Prod.{u2, u2} \u03b2 \u03b2) (Prod.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u2, u2} \u03b2 \u03b2) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u2, u2} \u03b2 \u03b2 p)) (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u2, u2} \u03b2 \u03b2 p))) (uniformity.{u2} \u03b2 _inst_2)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : UniformSpace.{u2} \u03b2], Eq.{max (succ u1) (succ u2)} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (uniformity.{max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.uniformSpace.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) (Sup.sup.{max u2 u1} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (SemilatticeSup.toSup.{max u1 u2} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Lattice.toSemilatticeSup.{max u1 u2} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (ConditionallyCompleteLattice.toLattice.{max u1 u2} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (CompleteLattice.toConditionallyCompleteLattice.{max u1 u2} (Filter.{max u2 u1} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))) (Filter.instCompleteLatticeFilter.{max u1 u2} (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2))))))) (Filter.map.{u1, max u2 u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u1, u1} \u03b1 \u03b1) => Prod.mk.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u1, u1} \u03b1 \u03b1 p)) (Sum.inl.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u1, u1} \u03b1 \u03b1 p))) (uniformity.{u1} \u03b1 _inst_1)) (Filter.map.{u2, max u1 u2} (Prod.{u2, u2} \u03b2 \u03b2) (Prod.{max u2 u1, max u2 u1} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2)) (fun (p : Prod.{u2, u2} \u03b2 \u03b2) => Prod.mk.{max u1 u2, max u1 u2} (Sum.{u1, u2} \u03b1 \u03b2) (Sum.{u1, u2} \u03b1 \u03b2) (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.fst.{u2, u2} \u03b2 \u03b2 p)) (Sum.inr.{u1, u2} \u03b1 \u03b2 (Prod.snd.{u2, u2} \u03b2 \u03b2 p))) (uniformity.{u2} \u03b2 _inst_2)))\nCase conversion may be inaccurate. Consider using '#align sum.uniformity Sum.uniformity\u2093'. -/\ntheorem Sum.uniformity :\n    \ud835\udce4 (Sum \u03b1 \u03b2) =\n      map (fun p : \u03b1 \u00d7 \u03b1 => (inl p.1, inl p.2)) (\ud835\udce4 \u03b1) \u2294\n        map (fun p : \u03b2 \u00d7 \u03b2 => (inr p.1, inr p.2)) (\ud835\udce4 \u03b2) :=\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 {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1} {\u03b9 : Sort.{u2}} {c : \u03b9 -> (Set.{u1} \u03b1)}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s) -> (forall (i : \u03b9), IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (c i)) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s (Set.union\u1d62.{u1, u2} \u03b1 \u03b9 (fun (i : \u03b9) => c i))) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (n : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) n (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) n (uniformity.{u1} \u03b1 _inst_1)) => forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (Exists.{u2} \u03b9 (fun (i : \u03b9) => HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (setOf.{u1} \u03b1 (fun (y : \u03b1) => Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) n)) (c i))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : UniformSpace.{u2} \u03b1] {s : Set.{u2} \u03b1} {\u03b9 : Sort.{u1}} {c : \u03b9 -> (Set.{u2} \u03b1)}, (IsCompact.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) s) -> (forall (i : \u03b9), IsOpen.{u2} \u03b1 (UniformSpace.toTopologicalSpace.{u2} \u03b1 _inst_1) (c i)) -> (HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) s (Set.union\u1d62.{u2, u1} \u03b1 \u03b9 (fun (i : \u03b9) => c i))) -> (Exists.{succ u2} (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (fun (n : Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) => And (Membership.mem.{u2, u2} (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (Filter.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (instMembershipSetFilter.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) n (uniformity.{u2} \u03b1 _inst_1)) (forall (x : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Set.{u2} \u03b1) (Set.instMembershipSet.{u2} \u03b1) x s) -> (Exists.{u1} \u03b9 (fun (i : \u03b9) => HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (setOf.{u2} \u03b1 (fun (y : \u03b1) => Membership.mem.{u2, u2} (Prod.{u2, u2} \u03b1 \u03b1) (Set.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (Set.instMembershipSet.{u2} (Prod.{u2, u2} \u03b1 \u03b1)) (Prod.mk.{u2, u2} \u03b1 \u03b1 x y) n)) (c i))))))\nCase conversion may be inaccurate. Consider using '#align lebesgue_number_lemma lebesgue_number_lemma\u2093'. -/\n/-- Let `c : \u03b9 \u2192 set \u03b1` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x \u2208 s` its `n`-neighborhood is contained in some `c i`. -/\ntheorem lebesgue_number_lemma {\u03b1 : Type u} [UniformSpace \u03b1] {s : Set \u03b1} {\u03b9} {c : \u03b9 \u2192 Set \u03b1}\n    (hs : IsCompact s) (hc\u2081 : \u2200 i, IsOpen (c i)) (hc\u2082 : s \u2286 \u22c3 i, c i) :\n    \u2203 n \u2208 \ud835\udce4 \u03b1, \u2200 x \u2208 s, \u2203 i, { y | (x, y) \u2208 n } \u2286 c i :=\n  by\n  let u n := { x | \u2203 i, \u2203 m \u2208 \ud835\udce4 \u03b1, { y | (x, y) \u2208 m \u25cb n } \u2286 c i }\n  have hu\u2081 : \u2200 n \u2208 \ud835\udce4 \u03b1, IsOpen (u n) :=\n    by\n    refine' fun n hn => isOpen_uniformity.2 _\n    rintro x \u27e8i, m, hm, h\u27e9\n    rcases comp_mem_uniformity_sets hm with \u27e8m', hm', mm'\u27e9\n    apply (\ud835\udce4 \u03b1).sets_of_superset hm'\n    rintro \u27e8x, y\u27e9 hp rfl\n    refine' \u27e8i, m', hm', fun z hz => h (monotone_id.comp_rel monotone_const mm' _)\u27e9\n    dsimp [-mem_compRel] at hz\u22a2\n    rw [compRel_assoc]\n    exact \u27e8y, hp, hz\u27e9\n  have hu\u2082 : s \u2286 \u22c3 n \u2208 \ud835\udce4 \u03b1, u n := by\n    intro x hx\n    rcases mem_Union.1 (hc\u2082 hx) with \u27e8i, h\u27e9\n    rcases comp_mem_uniformity_sets (isOpen_uniformity.1 (hc\u2081 i) x h) with \u27e8m', hm', mm'\u27e9\n    exact mem_bUnion hm' \u27e8i, _, hm', fun y hy => mm' hy rfl\u27e9\n  rcases hs.elim_finite_subcover_image hu\u2081 hu\u2082 with \u27e8b, bu, b_fin, b_cover\u27e9\n  refine' \u27e8_, (bInter_mem b_fin).2 bu, fun x hx => _\u27e9\n  rcases mem_Union\u2082.1 (b_cover hx) with \u27e8n, bn, i, m, hm, h\u27e9\n  refine' \u27e8i, fun y hy => h _\u27e9\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\u209b is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1} {c : Set.{u1} (Set.{u1} \u03b1)}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s) -> (forall (t : Set.{u1} \u03b1), (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) t c) -> (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) t)) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) s (Set.union\u209b.{u1} \u03b1 c)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (n : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) n (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) n (uniformity.{u1} \u03b1 _inst_1)) => forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x s) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (t : Set.{u1} \u03b1) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) t c) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.hasMem.{u1} (Set.{u1} \u03b1)) t c) => forall (y : \u03b1), (Membership.Mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) n) -> (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) y t)))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {s : Set.{u1} \u03b1} {c : Set.{u1} (Set.{u1} \u03b1)}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) s) -> (forall (t : Set.{u1} \u03b1), (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) t c) -> (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) t)) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) s (Set.union\u209b.{u1} \u03b1 c)) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (n : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) n (uniformity.{u1} \u03b1 _inst_1)) (forall (x : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x s) -> (Exists.{succ u1} (Set.{u1} \u03b1) (fun (t : Set.{u1} \u03b1) => And (Membership.mem.{u1, u1} (Set.{u1} \u03b1) (Set.{u1} (Set.{u1} \u03b1)) (Set.instMembershipSet.{u1} (Set.{u1} \u03b1)) t c) (forall (y : \u03b1), (Membership.mem.{u1, u1} (Prod.{u1, u1} \u03b1 \u03b1) (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Set.instMembershipSet.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Prod.mk.{u1, u1} \u03b1 \u03b1 x y) n) -> (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) y t)))))))\nCase conversion may be inaccurate. Consider using '#align lebesgue_number_lemma_sUnion lebesgue_number_lemma_union\u209b\u2093'. -/\n/-- Let `c : set (set \u03b1)` be an open cover of a compact set `s`. Then there exists an entourage\n`n` such that for each `x \u2208 s` its `n`-neighborhood is contained in some `t \u2208 c`. -/\ntheorem lebesgue_number_lemma_union\u209b {\u03b1 : Type u} [UniformSpace \u03b1] {s : Set \u03b1} {c : Set (Set \u03b1)}\n    (hs : IsCompact s) (hc\u2081 : \u2200 t \u2208 c, IsOpen t) (hc\u2082 : s \u2286 \u22c3\u2080 c) :\n    \u2203 n \u2208 \ud835\udce4 \u03b1, \u2200 x \u2208 s, \u2203 t \u2208 c, \u2200 y, (x, y) \u2208 n \u2192 y \u2208 t := by\n  rw [sUnion_eq_Union] at hc\u2082 <;> simpa using lebesgue_number_lemma hs (by simpa) hc\u2082\n#align lebesgue_number_lemma_sUnion lebesgue_number_lemma_union\u209b\n\n/- warning: lebesgue_number_of_compact_open -> lebesgue_number_of_compact_open is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {K : Set.{u1} \u03b1} {U : Set.{u1} \u03b1}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) K) -> (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) U) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) K U) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => Exists.{0} (Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (fun (H : Membership.Mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.hasMem.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) => And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (Prod.topologicalSpace.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V) (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.hasMem.{u1} \u03b1) x K) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) U)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b1] {K : Set.{u1} \u03b1} {U : Set.{u1} \u03b1}, (IsCompact.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) K) -> (IsOpen.{u1} \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) U) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) K U) -> (Exists.{succ u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (fun (V : Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) => And (Membership.mem.{u1, u1} (Set.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (Filter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) (instMembershipSetFilter.{u1} (Prod.{u1, u1} \u03b1 \u03b1)) V (uniformity.{u1} \u03b1 _inst_1)) (And (IsOpen.{u1} (Prod.{u1, u1} \u03b1 \u03b1) (instTopologicalSpaceProd.{u1, u1} \u03b1 \u03b1 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1)) V) (forall (x : \u03b1), (Membership.mem.{u1, u1} \u03b1 (Set.{u1} \u03b1) (Set.instMembershipSet.{u1} \u03b1) x K) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (UniformSpace.ball.{u1} \u03b1 x V) U)))))\nCase conversion may be inaccurate. Consider using '#align lebesgue_number_of_compact_open lebesgue_number_of_compact_open\u2093'. -/\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 \u03b1] {K U : Set \u03b1} (hK : IsCompact K)\n    (hU : IsOpen U) (hKU : K \u2286 U) : \u2203 V \u2208 \ud835\udce4 \u03b1, IsOpen V \u2227 \u2200 x \u2208 K, UniformSpace.ball x V \u2286 U :=\n  by\n  let W : K \u2192 Set (\u03b1 \u00d7 \u03b1) := fun k =>\n    Classical.choose <| is_open_iff_open_ball_subset.mp hU k.1 <| hKU k.2\n  have hW : \u2200 k, W k \u2208 \ud835\udce4 \u03b1 \u2227 IsOpen (W k) \u2227 UniformSpace.ball k.1 (W k) \u2286 U :=\n    by\n    intro k\n    obtain \u27e8h\u2081, h\u2082, h\u2083\u27e9 := Classical.choose_spec (is_open_iff_open_ball_subset.mp hU k.1 (hKU k.2))\n    exact \u27e8h\u2081, h\u2082, h\u2083\u27e9\n  let c : K \u2192 Set \u03b1 := fun k => UniformSpace.ball k.1 (W k)\n  have hc\u2081 : \u2200 k, IsOpen (c k) := fun k => UniformSpace.isOpen_ball k.1 (hW k).2.1\n  have hc\u2082 : K \u2286 \u22c3 i, c i := by\n    intro k hk\n    simp only [mem_Union, SetCoe.exists]\n    exact \u27e8k, hk, UniformSpace.mem_ball_self k (hW \u27e8k, hk\u27e9).1\u27e9\n  have hc\u2083 : \u2200 k, c k \u2286 U := fun k => (hW k).2.2\n  obtain \u27e8V, hV, hV'\u27e9 := lebesgue_number_lemma hK hc\u2081 hc\u2082\n  refine' \u27e8interior V, interior_mem_uniformity hV, isOpen_interior, _\u27e9\n  intro k hk\n  obtain \u27e8k', hk'\u27e9 := hV' k hk\n  exact ((ball_mono interior_subset k).trans hk').trans (hc\u2083 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 \u03b1]\n\n#print Uniform.tendsto_nhds_right /-\ntheorem tendsto_nhds_right {f : Filter \u03b2} {u : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n    Tendsto u f (\ud835\udcdd a) \u2194 Tendsto (fun x => (a, u x)) f (\ud835\udce4 \u03b1) := 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 \u03b2} {u : \u03b2 \u2192 \u03b1} {a : \u03b1} :\n    Tendsto u f (\ud835\udcdd a) \u2194 Tendsto (fun x => (u x, a)) f (\ud835\udce4 \u03b1) := 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 \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n    ContinuousAt f b \u2194 Tendsto (fun x => (f b, f x)) (\ud835\udcdd b) (\ud835\udce4 \u03b1) := 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 \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n    ContinuousAt f b \u2194 Tendsto (fun x => (f x, f b)) (\ud835\udcdd b) (\ud835\udce4 \u03b1) := 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {b : \u03b2}, Iff (ContinuousAt.{u2, u1} \u03b2 \u03b1 _inst_2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) f b) (Filter.Tendsto.{u2, u1} (Prod.{u2, u2} \u03b2 \u03b2) (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u2, u2} \u03b2 \u03b2) => Prod.mk.{u1, u1} \u03b1 \u03b1 (f (Prod.fst.{u2, u2} \u03b2 \u03b2 x)) (f (Prod.snd.{u2, u2} \u03b2 \u03b2 x))) (nhds.{u2} (Prod.{u2, u2} \u03b2 \u03b2) (Prod.topologicalSpace.{u2, u2} \u03b2 \u03b2 _inst_2 _inst_2) (Prod.mk.{u2, u2} \u03b2 \u03b2 b b)) (uniformity.{u1} \u03b1 _inst_1))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u1} \u03b1] [_inst_2 : TopologicalSpace.{u2} \u03b2] {f : \u03b2 -> \u03b1} {b : \u03b2}, Iff (ContinuousAt.{u2, u1} \u03b2 \u03b1 _inst_2 (UniformSpace.toTopologicalSpace.{u1} \u03b1 _inst_1) f b) (Filter.Tendsto.{u2, u1} (Prod.{u2, u2} \u03b2 \u03b2) (Prod.{u1, u1} \u03b1 \u03b1) (fun (x : Prod.{u2, u2} \u03b2 \u03b2) => Prod.mk.{u1, u1} \u03b1 \u03b1 (f (Prod.fst.{u2, u2} \u03b2 \u03b2 x)) (f (Prod.snd.{u2, u2} \u03b2 \u03b2 x))) (nhds.{u2} (Prod.{u2, u2} \u03b2 \u03b2) (instTopologicalSpaceProd.{u2, u2} \u03b2 \u03b2 _inst_2 _inst_2) (Prod.mk.{u2, u2} \u03b2 \u03b2 b b)) (uniformity.{u1} \u03b1 _inst_1))\nCase conversion may be inaccurate. Consider using '#align uniform.continuous_at_iff_prod Uniform.continuousAt_iff_prod\u2093'. -/\ntheorem continuousAt_iff_prod [TopologicalSpace \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} :\n    ContinuousAt f b \u2194 Tendsto (fun x : \u03b2 \u00d7 \u03b2 => (f x.1, f x.2)) (\ud835\udcdd (b, b)) (\ud835\udce4 \u03b1) :=\n  \u27e8fun 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\u27e9\n#align uniform.continuous_at_iff_prod Uniform.continuousAt_iff_prod\n\n#print Uniform.continuousWithinAt_iff'_right /-\ntheorem continuousWithinAt_iff'_right [TopologicalSpace \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} {s : Set \u03b2} :\n    ContinuousWithinAt f s b \u2194 Tendsto (fun x => (f b, f x)) (\ud835\udcdd[s] b) (\ud835\udce4 \u03b1) := 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 \u03b2] {f : \u03b2 \u2192 \u03b1} {b : \u03b2} {s : Set \u03b2} :\n    ContinuousWithinAt f s b \u2194 Tendsto (fun x => (f x, f b)) (\ud835\udcdd[s] b) (\ud835\udce4 \u03b1) := 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 \u03b2] {f : \u03b2 \u2192 \u03b1} {s : Set \u03b2} :\n    ContinuousOn f s \u2194 \u2200 b \u2208 s, Tendsto (fun x => (f b, f x)) (\ud835\udcdd[s] b) (\ud835\udce4 \u03b1) := 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 \u03b2] {f : \u03b2 \u2192 \u03b1} {s : Set \u03b2} :\n    ContinuousOn f s \u2194 \u2200 b \u2208 s, Tendsto (fun x => (f x, f b)) (\ud835\udcdd[s] b) (\ud835\udce4 \u03b1) := 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 \u03b2] {f : \u03b2 \u2192 \u03b1} :\n    Continuous f \u2194 \u2200 b, Tendsto (fun x => (f b, f x)) (\ud835\udcdd b) (\ud835\udce4 \u03b1) :=\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 \u03b2] {f : \u03b2 \u2192 \u03b1} :\n    Continuous f \u2194 \u2200 b, Tendsto (fun x => (f x, f b)) (\ud835\udcdd b) (\ud835\udce4 \u03b1) :=\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u2} \u03b2] {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2} {l : Filter.{u1} \u03b1} {b : \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_1) b)) -> (Filter.Tendsto.{u1, u2} \u03b1 (Prod.{u2, u2} \u03b2 \u03b2) (fun (x : \u03b1) => Prod.mk.{u2, u2} \u03b2 \u03b2 (f x) (g x)) l (uniformity.{u2} \u03b2 _inst_1)) -> (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_1) b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b2] {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2} {l : Filter.{u2} \u03b1} {b : \u03b2}, (Filter.Tendsto.{u2, u1} \u03b1 \u03b2 f l (nhds.{u1} \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b2 _inst_1) b)) -> (Filter.Tendsto.{u2, u1} \u03b1 (Prod.{u1, u1} \u03b2 \u03b2) (fun (x : \u03b1) => Prod.mk.{u1, u1} \u03b2 \u03b2 (f x) (g x)) l (uniformity.{u1} \u03b2 _inst_1)) -> (Filter.Tendsto.{u2, u1} \u03b1 \u03b2 g l (nhds.{u1} \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b2 _inst_1) b))\nCase conversion may be inaccurate. Consider using '#align filter.tendsto.congr_uniformity Filter.Tendsto.congr_uniformity\u2093'. -/\ntheorem Filter.Tendsto.congr_uniformity {\u03b1 \u03b2} [UniformSpace \u03b2] {f g : \u03b1 \u2192 \u03b2} {l : Filter \u03b1} {b : \u03b2}\n    (hf : Tendsto f l (\ud835\udcdd b)) (hg : Tendsto (fun x => (f x, g x)) l (\ud835\udce4 \u03b2)) : Tendsto g l (\ud835\udcdd 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : UniformSpace.{u2} \u03b2] {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2} {l : Filter.{u1} \u03b1} {b : \u03b2}, (Filter.Tendsto.{u1, u2} \u03b1 (Prod.{u2, u2} \u03b2 \u03b2) (fun (x : \u03b1) => Prod.mk.{u2, u2} \u03b2 \u03b2 (f x) (g x)) l (uniformity.{u2} \u03b2 _inst_1)) -> (Iff (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 f l (nhds.{u2} \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_1) b)) (Filter.Tendsto.{u1, u2} \u03b1 \u03b2 g l (nhds.{u2} \u03b2 (UniformSpace.toTopologicalSpace.{u2} \u03b2 _inst_1) b)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : UniformSpace.{u1} \u03b2] {f : \u03b1 -> \u03b2} {g : \u03b1 -> \u03b2} {l : Filter.{u2} \u03b1} {b : \u03b2}, (Filter.Tendsto.{u2, u1} \u03b1 (Prod.{u1, u1} \u03b2 \u03b2) (fun (x : \u03b1) => Prod.mk.{u1, u1} \u03b2 \u03b2 (f x) (g x)) l (uniformity.{u1} \u03b2 _inst_1)) -> (Iff (Filter.Tendsto.{u2, u1} \u03b1 \u03b2 f l (nhds.{u1} \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b2 _inst_1) b)) (Filter.Tendsto.{u2, u1} \u03b1 \u03b2 g l (nhds.{u1} \u03b2 (UniformSpace.toTopologicalSpace.{u1} \u03b2 _inst_1) b)))\nCase conversion may be inaccurate. Consider using '#align uniform.tendsto_congr Uniform.tendsto_congr\u2093'. -/\ntheorem Uniform.tendsto_congr {\u03b1 \u03b2} [UniformSpace \u03b2] {f g : \u03b1 \u2192 \u03b2} {l : Filter \u03b1} {b : \u03b2}\n    (hfg : Tendsto (fun x => (f x, g x)) l (\ud835\udce4 \u03b2)) : Tendsto f l (\ud835\udcdd b) \u2194 Tendsto g l (\ud835\udcdd b) :=\n  \u27e8fun h => h.congr_uniformity hfg, fun h => h.congr_uniformity hfg.uniformity_symm\u27e9\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 \u25b8 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 {\u03b1 \u03b2 \u03b3 : Sort*} {f : \u03b1 \u2192 \u03b2}\n\n/-- Evaluate a function at an argument. Useful if you want to talk about the partially applied\n  `function.eval x : (\u03a0 x, \u03b2 x) \u2192 \u03b2 x`. -/\n@[reducible] def eval {\u03b2 : \u03b1 \u2192 Sort*} (x : \u03b1) (f : \u03a0 x, \u03b2 x) : \u03b2 x := f x\n\n@[simp] lemma eval_apply {\u03b2 : \u03b1 \u2192 Sort*} (x : \u03b1) (f : \u03a0 x, \u03b2 x) : eval x f = f x := rfl\n\nlemma comp_apply {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03c6 : Sort w} (f : \u03b2 \u2192 \u03c6) (g : \u03b1 \u2192 \u03b2) (a : \u03b1) :\n  (f \u2218 g) a = f (g a) := rfl\n\nlemma const_def {y : \u03b2} : (\u03bb x : \u03b1, y) = const \u03b1 y := rfl\n\n@[simp] lemma const_apply {y : \u03b2} {x : \u03b1} : const \u03b1 y x = y := rfl\n\n@[simp] lemma const_comp {f : \u03b1 \u2192 \u03b2} {c : \u03b3} : const \u03b2 c \u2218 f = const \u03b1 c := rfl\n\n@[simp] lemma comp_const {f : \u03b2 \u2192 \u03b3} {b : \u03b2} : f \u2218 const \u03b1 b = const \u03b1 (f b) := rfl\n\nlemma id_def : @id \u03b1 = \u03bb x, x := rfl\n\nlemma hfunext {\u03b1 \u03b1': Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {\u03b2' : \u03b1' \u2192 Sort v} {f : \u03a0a, \u03b2 a} {f' : \u03a0a, \u03b2' a}\n  (h\u03b1 : \u03b1 = \u03b1') (h : \u2200a a', a == a' \u2192 f a == f' a') : f == f' :=\nbegin\n  subst h\u03b1,\n  have : \u2200a, f a == f' a,\n  { intro a, exact h a a (heq.refl a) },\n  have : \u03b2 = \u03b2',\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 {\u03b2 : \u03b1 \u2192 Sort*} {f\u2081 f\u2082 : \u03a0 (x : \u03b1), \u03b2 x} : f\u2081 = f\u2082 \u2194 (\u2200a, f\u2081 a = f\u2082 a) :=\niff.intro (assume h a, h \u25b8 rfl) funext\n\nprotected lemma bijective.injective {f : \u03b1 \u2192 \u03b2} (hf : bijective f) : injective f := hf.1\nprotected lemma bijective.surjective {f : \u03b1 \u2192 \u03b2} (hf : bijective f) : surjective f := hf.2\n\ntheorem injective.eq_iff (I : injective f) {a b : \u03b1} :\n  f a = f b \u2194 a = b :=\n\u27e8@I _ _, congr_arg f\u27e9\n\ntheorem injective.eq_iff' (I : injective f) {a b : \u03b1} {c : \u03b2} (h : f b = c) :\n  f a = c \u2194 a = b :=\nh \u25b8 I.eq_iff\n\nlemma injective.ne (hf : injective f) {a\u2081 a\u2082 : \u03b1} : a\u2081 \u2260 a\u2082 \u2192 f a\u2081 \u2260 f a\u2082 :=\nmt (assume h, hf h)\n\nlemma injective.ne_iff (hf : injective f) {x y : \u03b1} : f x \u2260 f y \u2194 x \u2260 y :=\n\u27e8mt $ congr_arg f, hf.ne\u27e9\n\nlemma injective.ne_iff' (hf : injective f) {x y : \u03b1} {z : \u03b2} (h : f y = z) :\n  f x \u2260 z \u2194 x \u2260 y :=\nh \u25b8 hf.ne_iff\n\n/-- If the co-domain `\u03b2` of an injective function `f : \u03b1 \u2192 \u03b2` has decidable equality, then\nthe domain `\u03b1` also has decidable equality. -/\ndef injective.decidable_eq [decidable_eq \u03b2] (I : injective f) : decidable_eq \u03b1 :=\n\u03bb a b, decidable_of_iff _ I.eq_iff\n\nlemma injective.of_comp {g : \u03b3 \u2192 \u03b1} (I : injective (f \u2218 g)) : injective g :=\n\u03bb x y h, I $ show f (g x) = f (g y), from congr_arg f h\n\nlemma injective.of_comp_iff {f : \u03b1 \u2192 \u03b2} (hf : injective f) (g : \u03b3 \u2192 \u03b1) :\n  injective (f \u2218 g) \u2194 injective g :=\n\u27e8injective.of_comp, hf.comp\u27e9\n\nlemma injective.of_comp_iff' (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : bijective g) :\n  injective (f \u2218 g) \u2194 injective f :=\n\u27e8 \u03bb h x y, let \u27e8x', hx\u27e9 := hg.surjective x, \u27e8y', hy\u27e9 := hg.surjective y in\n    hx \u25b8 hy \u25b8 \u03bb hf, h hf \u25b8 rfl,\n  \u03bb h, h.comp hg.injective\u27e9\n\n/-- Composition by an injective function on the left is itself injective. -/\nlemma injective.comp_left {g : \u03b2 \u2192 \u03b3} (hg : function.injective g) :\n  function.injective ((\u2218) g : (\u03b1 \u2192 \u03b2) \u2192 (\u03b1 \u2192 \u03b3)) :=\n\u03bb f\u2081 f\u2082 hgf, funext $ \u03bb i, hg $ (congr_fun hgf i : _)\n\nlemma injective_of_subsingleton [subsingleton \u03b1] (f : \u03b1 \u2192 \u03b2) :\n  injective f :=\n\u03bb a b ab, subsingleton.elim _ _\n\nlemma injective.dite (p : \u03b1 \u2192 Prop) [decidable_pred p]\n  {f : {a : \u03b1 // p a} \u2192 \u03b2} {f' : {a : \u03b1 // \u00ac p a} \u2192 \u03b2}\n  (hf : injective f) (hf' : injective f')\n  (im_disj : \u2200 {x x' : \u03b1} {hx : p x} {hx' : \u00ac p x'}, f \u27e8x, hx\u27e9 \u2260 f' \u27e8x', hx'\u27e9) :\n  function.injective (\u03bb x, if h : p x then f \u27e8x, h\u27e9 else f' \u27e8x, h\u27e9) :=\n\u03bb x\u2081 x\u2082 h, begin\n  dsimp only at h,\n  by_cases h\u2081 : p x\u2081; by_cases h\u2082 : p x\u2082,\n  { rw [dif_pos h\u2081, dif_pos h\u2082] at h, injection (hf h), },\n  { rw [dif_pos h\u2081, dif_neg h\u2082] at h, exact (im_disj h).elim, },\n  { rw [dif_neg h\u2081, dif_pos h\u2082] at h, exact (im_disj h.symm).elim, },\n  { rw [dif_neg h\u2081, dif_neg h\u2082] at h, injection (hf' h), },\nend\n\nlemma surjective.of_comp {g : \u03b3 \u2192 \u03b1} (S : surjective (f \u2218 g)) : surjective f :=\n\u03bb y, let \u27e8x, h\u27e9 := S y in \u27e8g x, h\u27e9\n\nlemma surjective.of_comp_iff (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : surjective g) :\n  surjective (f \u2218 g) \u2194 surjective f :=\n\u27e8surjective.of_comp, \u03bb h, h.comp hg\u27e9\n\nlemma surjective.of_comp_iff' (hf : bijective f) (g : \u03b3 \u2192 \u03b1) :\n  surjective (f \u2218 g) \u2194 surjective g :=\n\u27e8\u03bb h x, let \u27e8x', hx'\u27e9 := h (f x) in \u27e8x', hf.injective hx'\u27e9, hf.surjective.comp\u27e9\n\ninstance decidable_eq_pfun (p : Prop) [decidable p] (\u03b1 : p \u2192 Type*)\n  [\u03a0 hp, decidable_eq (\u03b1 hp)] : decidable_eq (\u03a0 hp, \u03b1 hp)\n| f g := decidable_of_iff (\u2200 hp, f hp = g hp) funext_iff.symm\n\nprotected theorem surjective.forall (hf : surjective f) {p : \u03b2 \u2192 Prop} :\n  (\u2200 y, p y) \u2194 \u2200 x, p (f x) :=\n\u27e8\u03bb h x, h (f x), \u03bb h y, let \u27e8x, hx\u27e9 := hf y in hx \u25b8 h x\u27e9\n\nprotected theorem surjective.forall\u2082 (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2200 y\u2081 y\u2082, p y\u2081 y\u2082) \u2194 \u2200 x\u2081 x\u2082, p (f x\u2081) (f x\u2082) :=\nhf.forall.trans $ forall_congr $ \u03bb x, hf.forall\n\nprotected theorem surjective.forall\u2083 (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2200 y\u2081 y\u2082 y\u2083, p y\u2081 y\u2082 y\u2083) \u2194 \u2200 x\u2081 x\u2082 x\u2083, p (f x\u2081) (f x\u2082) (f x\u2083) :=\nhf.forall.trans $ forall_congr $ \u03bb x, hf.forall\u2082\n\nprotected theorem surjective.exists (hf : surjective f) {p : \u03b2 \u2192 Prop} :\n  (\u2203 y, p y) \u2194 \u2203 x, p (f x) :=\n\u27e8\u03bb \u27e8y, hy\u27e9, let \u27e8x, hx\u27e9 := hf y in \u27e8x, hx.symm \u25b8 hy\u27e9, \u03bb \u27e8x, hx\u27e9, \u27e8f x, hx\u27e9\u27e9\n\nprotected theorem surjective.exists\u2082 (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2203 y\u2081 y\u2082, p y\u2081 y\u2082) \u2194 \u2203 x\u2081 x\u2082, p (f x\u2081) (f x\u2082) :=\nhf.exists.trans $ exists_congr $ \u03bb x, hf.exists\n\nprotected theorem surjective.exists\u2083 (hf : surjective f) {p : \u03b2 \u2192 \u03b2 \u2192 \u03b2 \u2192 Prop} :\n  (\u2203 y\u2081 y\u2082 y\u2083, p y\u2081 y\u2082 y\u2083) \u2194 \u2203 x\u2081 x\u2082 x\u2083, p (f x\u2081) (f x\u2082) (f x\u2083) :=\nhf.exists.trans $ exists_congr $ \u03bb x, hf.exists\u2082\n\nlemma surjective.injective_comp_right (hf : surjective f) :\n  injective (\u03bb g : \u03b2 \u2192 \u03b3, g \u2218 f) :=\n\u03bb g\u2081 g\u2082 h, funext $ hf.forall.2 $ congr_fun h\n\nprotected lemma surjective.right_cancellable (hf : surjective f) {g\u2081 g\u2082 : \u03b2 \u2192 \u03b3} :\n  g\u2081 \u2218 f = g\u2082 \u2218 f \u2194 g\u2081 = g\u2082 :=\nhf.injective_comp_right.eq_iff\n\nlemma surjective_of_right_cancellable_Prop (h : \u2200 g\u2081 g\u2082 : \u03b2 \u2192 Prop, g\u2081 \u2218 f = g\u2082 \u2218 f \u2192 g\u2081 = g\u2082) :\n  surjective f :=\nbegin\n  specialize h (\u03bb _, true) (\u03bb y, \u2203 x, f x = y) (funext $ \u03bb x, _),\n  { simp only [(\u2218), exists_apply_eq_apply] },\n  { intro y,\n    have : true = \u2203 x, f x = y, from congr_fun h y,\n    rw \u2190 this, exact trivial }\nend\n\nlemma bijective_iff_exists_unique (f : \u03b1 \u2192 \u03b2) : bijective f \u2194\n  \u2200 b : \u03b2, \u2203! (a : \u03b1), f a = b :=\n\u27e8 \u03bb hf b, let \u27e8a, ha\u27e9 := hf.surjective b in \u27e8a, ha, \u03bb a' ha', hf.injective (ha'.trans ha.symm)\u27e9,\n  \u03bb he, \u27e8\n    \u03bb a a' h, unique_of_exists_unique (he (f a')) h rfl,\n    \u03bb b, exists_of_exists_unique (he b) \u27e9\u27e9\n\n/-- Shorthand for using projection notation with `function.bijective_iff_exists_unique`. -/\nprotected lemma bijective.exists_unique {f : \u03b1 \u2192 \u03b2} (hf : bijective f) (b : \u03b2) :\n  \u2203! (a : \u03b1), f a = b :=\n(bijective_iff_exists_unique f).mp hf b\n\nlemma bijective.exists_unique_iff {f : \u03b1 \u2192 \u03b2} (hf : bijective f) {p : \u03b2 \u2192 Prop} :\n  (\u2203! y, p y) \u2194 \u2203! x, p (f x) :=\n\u27e8\u03bb \u27e8y, hpy, hy\u27e9, let \u27e8x, hx\u27e9 := hf.surjective y in \u27e8x, by rwa hx,\n  \u03bb z (hz : p (f z)), hf.injective $ hx.symm \u25b8 hy _ hz\u27e9,\n  \u03bb \u27e8x, hpx, hx\u27e9, \u27e8f x, hpx, \u03bb y hy,\n    let \u27e8z, hz\u27e9 := hf.surjective y in hz \u25b8 congr_arg f $ hx _ $ by rwa hz\u27e9\u27e9\n\nlemma bijective.of_comp_iff (f : \u03b1 \u2192 \u03b2) {g : \u03b3 \u2192 \u03b1} (hg : bijective g) :\n  bijective (f \u2218 g) \u2194 bijective f :=\nand_congr (injective.of_comp_iff' _ hg) (surjective.of_comp_iff _ hg.surjective)\n\nlemma bijective.of_comp_iff' {f : \u03b1 \u2192 \u03b2} (hf : bijective f) (g : \u03b3 \u2192 \u03b1) :\n  function.bijective (f \u2218 g) \u2194 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 `\u03b1`\nto `set \u03b1`. -/\ntheorem cantor_surjective {\u03b1} (f : \u03b1 \u2192 set \u03b1) : \u00ac function.surjective f | h :=\nlet \u27e8D, e\u27e9 := h (\u03bb a, \u00ac 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 \u03b1`\nto `\u03b1`. -/\ntheorem cantor_injective {\u03b1 : Type*} (f : (set \u03b1) \u2192 \u03b1) :\n  \u00ac function.injective f | i :=\ncantor_surjective (\u03bb a b, \u2200 U, a = f U \u2192 U b) $\nright_inverse.surjective (\u03bb U, funext $ \u03bb a, propext \u27e8\u03bb h, h U rfl, \u03bb h' U' e, i e \u25b8 h'\u27e9)\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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 option \u03b1) : Prop :=\n\u2200 x y, g y = some x \u2194 f x = y\n\ntheorem is_partial_inv_left {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g) (x) : g (f x) = some x :=\n(H _ _).2 rfl\n\ntheorem injective_of_partial_inv {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g) : injective f :=\n\u03bb a b h, option.some.inj $ ((H _ _).2 h).symm.trans ((H _ _).2 rfl)\n\ntheorem injective_of_partial_inv_right {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} {g} (H : is_partial_inv f g)\n (x y b) (h\u2081 : b \u2208 g x) (h\u2082 : b \u2208 g y) : x = y :=\n((H _ _).1 h\u2081).symm.trans ((H _ _).1 h\u2082)\n\ntheorem left_inverse.comp_eq_id {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse f g) : f \u2218 g = id :=\nfunext h\n\ntheorem left_inverse_iff_comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} : left_inverse f g \u2194 f \u2218 g = id :=\n\u27e8left_inverse.comp_eq_id, congr_fun\u27e9\n\ntheorem right_inverse.comp_eq_id {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : right_inverse f g) : g \u2218 f = id :=\nfunext h\n\ntheorem right_inverse_iff_comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} : right_inverse f g \u2194 g \u2218 f = id :=\n\u27e8right_inverse.comp_eq_id, congr_fun\u27e9\n\ntheorem left_inverse.comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} {h : \u03b2 \u2192 \u03b3} {i : \u03b3 \u2192 \u03b2}\n  (hf : left_inverse f g) (hh : left_inverse h i) : left_inverse (h \u2218 f) (g \u2218 i) :=\nassume a, show h (f (g (i a))) = a, by rw [hf (i a), hh a]\n\ntheorem right_inverse.comp {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} {h : \u03b2 \u2192 \u03b3} {i : \u03b3 \u2192 \u03b2}\n  (hf : right_inverse f g) (hh : right_inverse h i) : right_inverse (h \u2218 f) (g \u2218 i) :=\nleft_inverse.comp hh hf\n\ntheorem left_inverse.right_inverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse g f) :\n  right_inverse f g := h\n\ntheorem right_inverse.left_inverse {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : right_inverse g f) :\n  left_inverse f g := h\n\ntheorem left_inverse.surjective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse f g) :\n  surjective f :=\nh.right_inverse.surjective\n\ntheorem right_inverse.injective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : right_inverse f g) :\n  injective f :=\nh.left_inverse.injective\n\ntheorem left_inverse.right_inverse_of_injective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse f g)\n  (hf : injective f) :\n  right_inverse f g :=\n\u03bb x, hf $ h (f x)\n\ntheorem left_inverse.right_inverse_of_surjective {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : left_inverse f g)\n  (hg : surjective g) :\n  right_inverse f g :=\n\u03bb x, let \u27e8y, hy\u27e9 := hg x in hy \u25b8 congr_arg g (h y)\n\ntheorem left_inverse.eq_right_inverse {f : \u03b1 \u2192 \u03b2} {g\u2081 g\u2082 : \u03b2 \u2192 \u03b1} (h\u2081 : left_inverse g\u2081 f)\n  (h\u2082 : right_inverse g\u2082 f) :\n  g\u2081 = g\u2082 :=\ncalc g\u2081 = g\u2081 \u2218 f \u2218 g\u2082 : by rw [h\u2082.comp_eq_id, comp.right_id]\n    ... = g\u2082          : by rw [\u2190 comp.assoc, h\u2081.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 {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (b : \u03b2) : option \u03b1 :=\nif h : \u2203 a, f a = b then some (classical.some h) else none\n\ntheorem partial_inv_of_injective {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} (I : injective f) :\n  is_partial_inv f (partial_inv f) | a b :=\n\u27e8\u03bb h, if h' : \u2203 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 \u03bb e, e \u25b8 have h : \u2203 a', f a' = f a, from \u27e8_, rfl\u27e9,\n   (dif_pos h).trans (congr_arg _ (I $ classical.some_spec h))\u27e9\n\ntheorem partial_inv_left {\u03b1 \u03b2} {f : \u03b1 \u2192 \u03b2} (I : injective f) : \u2200 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 {\u03b1 \u03b2 : Sort*} [nonempty \u03b1] {f : \u03b1 \u2192 \u03b2} {a : \u03b1} {b : \u03b2}\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 : \u03b1 \u2192 \u03b2) : \u03b2 \u2192 \u03b1 :=\n\u03bb y, if h : \u2203 x, f x = y then h.some else classical.arbitrary \u03b1\n\ntheorem inv_fun_eq (h : \u2203 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 : \u00ac \u2203 a, f a = b) : inv_fun f b = classical.choice \u2039_\u203a :=\ndif_neg h\n\ntheorem inv_fun_eq_of_injective_of_right_inverse {g : \u03b2 \u2192 \u03b1}\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 \u27e8g b, hg b\u27e9 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\u03bb b, hf $ inv_fun_eq \u27e8b, rfl\u27e9\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 \u2218 f = id := funext $ left_inverse_inv_fun hf\n\nlemma injective.has_left_inverse (hf : injective f) : has_left_inverse f :=\n\u27e8inv_fun f, left_inverse_inv_fun hf\u27e9\n\nlemma injective_iff_has_left_inverse : injective f \u2194 has_left_inverse f :=\n\u27e8injective.has_left_inverse, has_left_inverse.injective\u27e9\n\nend inv_fun\n\nsection surj_inv\nvariables {\u03b1 : Sort u} {\u03b2 : Sort v} {\u03b3 : Sort w} {f : \u03b1 \u2192 \u03b2}\n\n/-- The inverse of a surjective function. (Unlike `inv_fun`, this does not require\n  `\u03b1` to be inhabited.) -/\nnoncomputable def surj_inv {f : \u03b1 \u2192 \u03b2} (h : surjective f) (b : \u03b2) : \u03b1 := 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\u27e8_, right_inverse_surj_inv hf\u27e9\n\nlemma surjective_iff_has_right_inverse : surjective f \u2194 has_right_inverse f :=\n\u27e8surjective.has_right_inverse, has_right_inverse.surjective\u27e9\n\nlemma bijective_iff_has_inverse : bijective f \u2194 \u2203 g, left_inverse g f \u2227 right_inverse g f :=\n\u27e8\u03bb hf, \u27e8_, left_inverse_surj_inv hf, right_inverse_surj_inv hf.2\u27e9,\n \u03bb \u27e8g, gl, gr\u27e9, \u27e8gl.injective,  gr.surjective\u27e9\u27e9\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 \u03b1] [subsingleton \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  surjective f :=\n\u03bb y, let \u27e8a\u27e9 := na in \u27e8a, subsingleton.elim _ _\u27e9\n\n/-- Composition by an surjective function on the left is itself surjective. -/\nlemma surjective.comp_left {g : \u03b2 \u2192 \u03b3} (hg : surjective g) :\n  surjective ((\u2218) g : (\u03b1 \u2192 \u03b2) \u2192 (\u03b1 \u2192 \u03b3)) :=\n\u03bb f, \u27e8surj_inv hg \u2218 f, funext $ \u03bb x, right_inverse_surj_inv _ _\u27e9\n\n/-- Composition by an bijective function on the left is itself bijective. -/\nlemma bijective.comp_left {g : \u03b2 \u2192 \u03b3} (hg : bijective g) :\n  bijective ((\u2218) g : (\u03b1 \u2192 \u03b2) \u2192 (\u03b1 \u2192 \u03b3)) :=\n\u27e8hg.injective.comp_left, hg.surjective.comp_left\u27e9\n\nend surj_inv\n\nsection update\nvariables {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} {\u03b1' : Sort w} [decidable_eq \u03b1] [decidable_eq \u03b1']\n\n/-- Replacing the value of a function at a given point by a given value. -/\ndef update (f : \u03a0a, \u03b2 a) (a' : \u03b1) (v : \u03b2 a') (a : \u03b1) : \u03b2 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 {\u03b2 : Sort*} (f : \u03b1 \u2192 \u03b2) (a' : \u03b1) (b : \u03b2) (a : \u03b1) :\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 : \u03b1) (v : \u03b2 a) (f : \u03a0a, \u03b2 a) : update f a v a = v :=\ndif_pos rfl\n\nlemma surjective_eval {\u03b1 : Sort u} {\u03b2 : \u03b1 \u2192 Sort v} [h : \u03a0 a, nonempty (\u03b2 a)] (a : \u03b1) :\n  surjective (eval a : (\u03a0 a, \u03b2 a) \u2192 \u03b2 a) :=\n\u03bb b, \u27e8@update _ _ (classical.dec_eq \u03b1) (\u03bb a, (h a).some) a b,\n  @update_same _ _ (classical.dec_eq \u03b1) _ _ _\u27e9\n\nlemma update_injective (f : \u03a0a, \u03b2 a) (a' : \u03b1) : injective (update f a') :=\n\u03bb v v' h, have _ := congr_fun h a', by rwa [update_same, update_same] at this\n\n@[simp] lemma update_noteq {a a' : \u03b1} (h : a \u2260 a') (v : \u03b2 a') (f : \u03a0a, \u03b2 a) :\n  update f a' v a = f a :=\ndif_neg h\n\nlemma forall_update_iff (f : \u03a0 a, \u03b2 a) {a : \u03b1} {b : \u03b2 a} (p : \u03a0 a, \u03b2 a \u2192 Prop) :\n  (\u2200 x, p x (update f a b x)) \u2194 p a b \u2227 \u2200 x \u2260 a, p x (f x) :=\nby { rw [\u2190 and_forall_ne a, update_same], simp { contextual := tt } }\n\nlemma exists_update_iff (f : \u03a0 a, \u03b2 a) {a : \u03b1} {b : \u03b2 a} (p : \u03a0 a, \u03b2 a \u2192 Prop) :\n  (\u2203 x, p x (update f a b x)) \u2194 p a b \u2228 \u2203 x \u2260 a, p x (f x) :=\nby { rw [\u2190 not_forall_not, forall_update_iff f (\u03bb a b, \u00acp a b)], simp [not_and_distrib] }\n\nlemma update_eq_iff {a : \u03b1} {b : \u03b2 a} {f g : \u03a0 a, \u03b2 a} :\n  update f a b = g \u2194 b = g a \u2227 \u2200 x \u2260 a, f x = g x :=\nfunext_iff.trans $ forall_update_iff _ (\u03bb x y, y = g x)\n\nlemma eq_update_iff {a : \u03b1} {b : \u03b2 a} {f g : \u03a0 a, \u03b2 a} :\n  g = update f a b \u2194 g a = b \u2227 \u2200 x \u2260 a, g x = f x :=\nfunext_iff.trans $ forall_update_iff _ (\u03bb x y, g x = y)\n\n@[simp] lemma update_eq_self (a : \u03b1) (f : \u03a0a, \u03b2 a) : update f a (f a) = f :=\nupdate_eq_iff.2 \u27e8rfl, \u03bb _ _, rfl\u27e9\n\nlemma update_comp_eq_of_forall_ne' {\u03b1'} (g : \u03a0 a, \u03b2 a) {f : \u03b1' \u2192 \u03b1} {i : \u03b1} (a : \u03b2 i)\n  (h : \u2200 x, f x \u2260 i) :\n  (\u03bb j, (update g i a) (f j)) = (\u03bb j, g (f j)) :=\nfunext $ \u03bb x, update_noteq (h _) _ _\n\n/-- Non-dependent version of `function.update_comp_eq_of_forall_ne'` -/\nlemma update_comp_eq_of_forall_ne {\u03b1 \u03b2 : Sort*} (g : \u03b1' \u2192 \u03b2) {f : \u03b1 \u2192 \u03b1'} {i : \u03b1'} (a : \u03b2)\n  (h : \u2200 x, f x \u2260 i) :\n  (update g i a) \u2218 f = g \u2218 f :=\nupdate_comp_eq_of_forall_ne' g a h\n\nlemma update_comp_eq_of_injective' (g : \u03a0 a, \u03b2 a) {f : \u03b1' \u2192 \u03b1} (hf : function.injective f)\n  (i : \u03b1') (a : \u03b2 (f i)) :\n  (\u03bb j, update g (f i) a (f j)) = update (\u03bb i, g (f i)) i a :=\neq_update_iff.2 \u27e8update_same _ _ _, \u03bb j hj, update_noteq (hf.ne hj) _ _\u27e9\n\n/-- Non-dependent version of `function.update_comp_eq_of_injective'` -/\nlemma update_comp_eq_of_injective {\u03b2 : Sort*} (g : \u03b1' \u2192 \u03b2) {f : \u03b1 \u2192 \u03b1'}\n  (hf : function.injective f) (i : \u03b1) (a : \u03b2) :\n  (function.update g (f i) a) \u2218 f = function.update (g \u2218 f) i a :=\nupdate_comp_eq_of_injective' g hf i a\n\nlemma apply_update {\u03b9 : Sort*} [decidable_eq \u03b9] {\u03b1 \u03b2 : \u03b9 \u2192 Sort*}\n  (f : \u03a0 i, \u03b1 i \u2192 \u03b2 i) (g : \u03a0 i, \u03b1 i) (i : \u03b9) (v : \u03b1 i) (j : \u03b9) :\n  f j (update g i v j) = update (\u03bb 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\u2082 {\u03b9 : Sort*} [decidable_eq \u03b9] {\u03b1 \u03b2 \u03b3 : \u03b9 \u2192 Sort*}\n  (f : \u03a0 i, \u03b1 i \u2192 \u03b2 i \u2192 \u03b3 i) (g : \u03a0 i, \u03b1 i) (h : \u03a0 i, \u03b2 i) (i : \u03b9) (v : \u03b1 i) (w : \u03b2 i) (j : \u03b9) :\n  f j (update g i v j) (update h i w j) = update (\u03bb 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 {\u03b1' : Sort*} {\u03b2 : Sort*} (f : \u03b1' \u2192 \u03b2) (g : \u03b1 \u2192 \u03b1') (i : \u03b1) (v : \u03b1') :\n  f \u2218 (update g i v) = update (f \u2218 g) i (f v) :=\nfunext $ apply_update _ _ _ _\n\ntheorem update_comm {\u03b1} [decidable_eq \u03b1] {\u03b2 : \u03b1 \u2192 Sort*}\n  {a b : \u03b1} (h : a \u2260 b) (v : \u03b2 a) (w : \u03b2 b) (f : \u03a0a, \u03b2 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\u2081 : c = b; by_cases h\u2082 : c = a; try {simp [h\u2081, h\u2082]},\n  cases h (h\u2082.symm.trans h\u2081),\nend\n\n@[simp] theorem update_idem {\u03b1} [decidable_eq \u03b1] {\u03b2 : \u03b1 \u2192 Sort*}\n  {a : \u03b1} (v w : \u03b2 a) (f : \u03a0a, \u03b2 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 {\u03b1 \u03b2 \u03b3 : Sort*} {f : \u03b1 \u2192 \u03b2}\n\n/-- `extend f g e'` extends a function `g : \u03b1 \u2192 \u03b3`\nalong a function `f : \u03b1 \u2192 \u03b2` to a function `\u03b2 \u2192 \u03b3`,\nby using the values of `g` on the range of `f`\nand the values of an auxiliary function `e' : \u03b2 \u2192 \u03b3` elsewhere.\n\nMostly useful when `f` is injective. -/\ndef extend (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) : \u03b2 \u2192 \u03b3 :=\n\u03bb b, if h : \u2203 a, f a = b then g (classical.some h) else e' b\n\nlemma extend_def (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (b : \u03b2) [decidable (\u2203 a, f a = b)] :\n  extend f g e' b = if h : \u2203 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 : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (a : \u03b1) :\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 : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (b : \u03b2) (hb : \u00ac\u2203 a, f a = b) :\n  extend f g e' b = e' b :=\nby simp [function.extend_def, hb]\n\nlemma apply_extend {\u03b4} (hf : injective f) (F : \u03b3 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) (b : \u03b2) :\n  F (extend f g e' b) = extend f (F \u2218 g) (F \u2218 e') b :=\nbegin\n  by_cases hb : \u2203 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' : \u03b2 \u2192 \u03b3) :\n  injective (\u03bb g, extend f g e') :=\nbegin\n  intros g\u2081 g\u2082 hg,\n  refine funext (\u03bb 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 : \u03b1 \u2192 \u03b3) (e' : \u03b2 \u2192 \u03b3) :\n  extend f g e' \u2218 f = g :=\nfunext $ \u03bb a, extend_apply hf g e' a\n\nlemma injective.surjective_comp_right' (hf : injective f) (g\u2080 : \u03b2 \u2192 \u03b3) :\n  surjective (\u03bb g : \u03b2 \u2192 \u03b3, g \u2218 f) :=\n\u03bb g, \u27e8extend f g g\u2080, extend_comp hf _ _\u27e9\n\nlemma injective.surjective_comp_right [nonempty \u03b3] (hf : injective f) :\n  surjective (\u03bb g : \u03b2 \u2192 \u03b3, g \u2218 f) :=\nhf.surjective_comp_right' (\u03bb _, classical.choice \u2039_\u203a)\n\nlemma bijective.comp_right (hf : bijective f) :\n  bijective (\u03bb g : \u03b2 \u2192 \u03b3, g \u2218 f) :=\n\u27e8hf.surjective.injective_comp_right,\n  \u03bb g, \u27e8g \u2218 surj_inv hf.surjective,\n    by simp only [comp.assoc g _ f, (left_inverse_surj_inv hf).comp_eq_id, comp.right_id]\u27e9\u27e9\n\nend extend\n\nlemma uncurry_def {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : uncurry f = (\u03bbp, f p.1 p.2) :=\nrfl\n\n@[simp] lemma uncurry_apply_pair {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (x : \u03b1) (y : \u03b2) :\n  uncurry f (x, y) = f x y :=\nrfl\n\n@[simp] lemma curry_apply {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) (x : \u03b1) (y : \u03b2) :\n  curry f x y = f (x, y) :=\nrfl\n\nsection bicomp\nvariables {\u03b1 \u03b2 \u03b3 \u03b4 \u03b5 : 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 : \u03b3 \u2192 \u03b4 \u2192 \u03b5) (g : \u03b1 \u2192 \u03b3) (h : \u03b2 \u2192 \u03b4) (a b) :=\nf (g a) (h b)\n\n/-- Compose an unary function `f` with a binary function `g`. -/\ndef bicompr (f : \u03b3 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (a b) :=\nf (g a b)\n\n-- Suggested local notation:\nlocal notation f `\u2218\u2082` g := bicompr f g\n\nlemma uncurry_bicompr (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (g : \u03b3 \u2192 \u03b4) :\n  uncurry (g \u2218\u2082 f) = (g \u2218 uncurry f) := rfl\n\n\n\nend bicomp\n\nsection uncurry\n\nvariables {\u03b1 \u03b2 \u03b3 \u03b4 : Type*}\n\n/-- Records a way to turn an element of `\u03b1` into a function from `\u03b2` to `\u03b3`. The most generic use\nis to recursively uncurry. For instance `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4` will be turned into\n`\u21bff : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3 \u2192 \u03b4`. One can also add instances for bundled maps. -/\nclass has_uncurry (\u03b1 : Type*) (\u03b2 : out_param Type*) (\u03b3 : out_param Type*) := (uncurry : \u03b1 \u2192 (\u03b2 \u2192 \u03b3))\n\n/-- Uncurrying operator. The most generic use is to recursively uncurry. For instance\n`f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4` will be turned into `\u21bff : \u03b1 \u00d7 \u03b2 \u00d7 \u03b3 \u2192 \u03b4`. One can also add instances\nfor bundled maps.-/\nadd_decl_doc has_uncurry.uncurry\n\nnotation `\u21bf`:max x:max := has_uncurry.uncurry x\n\ninstance has_uncurry_base : has_uncurry (\u03b1 \u2192 \u03b2) \u03b1 \u03b2 := \u27e8id\u27e9\n\ninstance has_uncurry_induction [has_uncurry \u03b2 \u03b3 \u03b4] : has_uncurry (\u03b1 \u2192 \u03b2) (\u03b1 \u00d7 \u03b3) \u03b4 :=\n\u27e8\u03bb f p, \u21bf(f p.1) p.2\u27e9\n\nend uncurry\n\n/-- A function is involutive, if `f \u2218 f = id`. -/\ndef involutive {\u03b1} (f : \u03b1 \u2192 \u03b1) : Prop := \u2200 x, f (f x) = x\n\nlemma involutive_iff_iter_2_eq_id {\u03b1} {f : \u03b1 \u2192 \u03b1} : involutive f \u2194 (f^[2] = id) :=\nfunext_iff.symm\n\nnamespace involutive\nvariables {\u03b1 : Sort u} {f : \u03b1 \u2192 \u03b1} (h : involutive f)\ninclude h\n\n@[simp]\nlemma comp_self : f \u2218 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 := \u03bb x, \u27e8f x, h x\u27e9\nprotected lemma bijective : bijective f := \u27e8h.injective, h.surjective\u27e9\n\n/-- Involuting an `ite` of an involuted value `x : \u03b1` negates the `Prop` condition in the `ite`. -/\nprotected lemma ite_not (P : Prop) [decidable P] (x : \u03b1) :\n  f (ite P x (f x)) = ite (\u00ac 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 : \u03b1} : f x = y \u2194 x = f y :=\nh.injective.eq_iff' (h y)\n\nend involutive\n\n/-- The property of a binary function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` being injective.\nMathematically this should be thought of as the corresponding function `\u03b1 \u00d7 \u03b2 \u2192 \u03b3` being injective.\n-/\n@[reducible] def injective2 {\u03b1 \u03b2 \u03b3} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : Prop :=\n\u2200 \u2983a\u2081 a\u2082 b\u2081 b\u2082\u2984, f a\u2081 b\u2081 = f a\u2082 b\u2082 \u2192 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082\n\nnamespace injective2\nvariables {\u03b1 \u03b2 \u03b3 : Type*} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3)\n\nprotected lemma left (hf : injective2 f) \u2983a\u2081 a\u2082 b\u2081 b\u2082\u2984 (h : f a\u2081 b\u2081 = f a\u2082 b\u2082) : a\u2081 = a\u2082 :=\n(hf h).1\n\nprotected lemma right (hf : injective2 f) \u2983a\u2081 a\u2082 b\u2081 b\u2082\u2984 (h : f a\u2081 b\u2081 = f a\u2082 b\u2082) : b\u2081 = b\u2082 :=\n(hf h).2\n\nlemma eq_iff (hf : injective2 f) \u2983a\u2081 a\u2082 b\u2081 b\u2082\u2984 : f a\u2081 b\u2081 = f a\u2082 b\u2082 \u2194 a\u2081 = a\u2082 \u2227 b\u2081 = b\u2082 :=\n\u27e8\u03bb h, hf h, \u03bb\u27e8h1, h2\u27e9, congr_arg2 f h1 h2\u27e9\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 `\u03b1` is a proposition, in which case `f` is necessarily a\nconstant function, so that `sometimes f = f a` for all `a`. -/\nnoncomputable def sometimes {\u03b1 \u03b2} [nonempty \u03b2] (f : \u03b1 \u2192 \u03b2) : \u03b2 :=\nif h : nonempty \u03b1 then f (classical.choice h) else classical.choice \u2039_\u203a\n\ntheorem sometimes_eq {p : Prop} {\u03b1} [nonempty \u03b1] (f : p \u2192 \u03b1) (a : p) : sometimes f = f a :=\ndif_pos \u27e8a\u27e9\n\ntheorem sometimes_spec {p : Prop} {\u03b1} [nonempty \u03b1]\n  (P : \u03b1 \u2192 Prop) (f : p \u2192 \u03b1) (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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Sort v} (s : set \u03b1) (f g : \u03a0i, \u03b2 i)\n  [\u2200j, decidable (j \u2208 s)] :\n  \u03a0i, \u03b2 i :=\n\u03bbi, if i \u2208 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 {\u03b1 : Sort*} {C : \u03b1 \u2192 Sort*} :\n  \u2200 {a a' : \u03b1} (h : a = a'), function.bijective (@eq.rec_on _ _ C _ h)\n| _ _ rfl := \u27e8\u03bb x y, id, \u03bb x, \u27e8x, rfl\u27e9\u27e9\n\nlemma eq_mp_bijective {\u03b1 \u03b2 : Sort*} (h : \u03b1 = \u03b2) : function.bijective (eq.mp h) :=\neq_rec_on_bijective h\n\nlemma eq_mpr_bijective {\u03b1 \u03b2 : Sort*} (h : \u03b1 = \u03b2) : function.bijective (eq.mpr h) :=\neq_rec_on_bijective h.symm\n\nlemma cast_bijective {\u03b1 \u03b2 : Sort*} (h : \u03b1 = \u03b2) : 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 {\u03b1 : Sort*} {a a' : \u03b1} (h : a = a') {C : \u03b1 \u2192 Type*} (x y : C a) :\n  (eq.rec x h : C a') = eq.rec y h \u2194 x = y :=\n(eq_rec_on_bijective h).injective.eq_iff\n\n@[simp]\nlemma cast_inj {\u03b1 \u03b2 : Type*} (h : \u03b1 = \u03b2) {x y : \u03b1} : cast h x = cast h y \u2194 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 {\u03b1 \u03b2 : Type*} (A : set (\u03b1 \u2192 \u03b2)) : Prop :=\n\u2200 \u2983x y : \u03b1\u2984, x \u2260 y \u2192 \u2203 f \u2208 A, (f x : \u03b2) \u2260 f y\n\nlemma is_symm_op.flip_eq {\u03b1 \u03b2} (op) [is_symm_op \u03b1 \u03b2 op] : flip op = op :=\nfunext $ \u03bb a, funext $ \u03bb b, (is_symm_op.symm_op a b).symm\n\nlemma inv_image.equivalence {\u03b1 : Sort u} {\u03b2 : Sort v} (r : \u03b2 \u2192 \u03b2 \u2192 Prop) (f : \u03b1 \u2192 \u03b2)\n  (h : equivalence r) : equivalence (inv_image r f) :=\n\u27e8\u03bb _, h.1 _, \u03bb _ _ x, h.2.1 x, inv_image.trans r f h.2.2\u27e9\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 {\u03c4 : Type} {\u03c3 : Type*} {sig : signature \u03c4 \u03c3} {\u03b9 : Type} {ax : \u03b9 \u2192 identity sig}\n\nnamespace proof\nvariables {\u03b9' : Type} {ax' : \u03b9' \u2192 identity sig} (ht : \u03a0 (i : \u03b9), proof ax' (ax i).lhs (ax i).rhs)\n\ndefinition transfer {dom} : \u03a0 {cod} {t\u2081 t\u2082 : term sig dom cod} (p : proof ax t\u2081 t\u2082), proof ax' t\u2081 t\u2082\n| _ _ _ (proof.ax i sub) := proof.subst sub (ht i) \n| _ _ _ (proof.proj _) := proof.proj _\n| _ _ _ (proof.func f ps) := proof.func f (\u03bb i, transfer (ps i))\n| _ _ _ (proof.eucl p\u2081 p\u2082) := proof.eucl (transfer p\u2081) (transfer p\u2082)\n\ndefinition transfer_of_map (f : \u03b9 \u2192 \u03b9') (hf : \u2200 i, ax' (f i) = ax i) (i : \u03b9) : 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} : \u03a0 {cod} {t\u2081 t\u2082 : term sig dom cod}, proof ax t\u2081 t\u2082 \u2192 \u03b9 \u2192 Prop\n| _ _ _ (proof.ax i _) j := i = j\n| _ _ _ (proof.proj _) _ := false\n| _ _ _ (proof.func _ ps) j := \u2203 i, proof.occurs (ps i) j\n| _ _ _ (proof.eucl p\u2081 p\u2082) j := proof.occurs p\u2081 j \u2228 proof.occurs p\u2082 j\n\ndefinition proof.use {dom} : \u03a0 {cod} {t\u2081 t\u2082 : term sig dom cod}, proof ax t\u2081 t\u2082 \u2192 list \u03b9\n| _ _ _ (proof.ax i _) := [i]\n| _ _ _ (proof.proj _) := []\n| _ _ _ (proof.func _ ps) := list.join $ index.dtup.to_list (\u03bb i, proof.use (ps i))\n| _ _ _ (proof.eucl p\u2081 p\u2082) := proof.use p\u2081 ++ proof.use p\u2082\n\ntheorem proof.mem_use_of_occurs {dom} : \u03a0 {cod} {t\u2081 t\u2082 : term sig dom cod} {p : proof ax t\u2081 t\u2082} {i : \u03b9}, proof.occurs p i \u2192 i \u2208 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 $ \u03bb i hi,\n  let i' : index (index.dtup.to_list (\u03bb i, proof.use (ps i))) := index.map _ (index.dtup.enum_index _ i) in\n  have hi' : j \u2208 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\u2081 p\u2082) j h :=  or.elim h (\u03bb h, list.mem_append_left _ (proof.mem_use_of_occurs h)) (\u03bb h, list.mem_append_right _ (proof.mem_use_of_occurs h))\n\ndefinition proof.of_use {dom} : \u03a0 {cod} {t\u2081 t\u2082 : term sig dom cod} (p : proof ax t\u2081 t\u2082), proof (\u03bb (i : index p.use), ax i.val) t\u2081 t\u2082\n| _ t\u2081 t\u2082 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 : \u03a0 (i : sig.index f) (j : index (ps i).use), index p.use :=\n  \u03bb i j, index.join_map _ (index.dtup.to_list_index _ i) $ eq.rec_on (index.dtup.to_list_index_val (\u03bb i, (ps i).use) i).symm j in\n  let ps : \u03a0 (i : sig.index f), proof (\u03bb (i : index p.use), ax i.val) (lhs i) (rhs i) :=\n  \u03bb 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\u2081 t\u2082 p@(@proof.eucl _ _ _ _ _ _ _ t _ _ p\u2081 p\u2082) :=\n  let p\u2081 : proof (\u03bb (i : index p.use), ax i.val) t t\u2081 :=\n  proof.transfer (proof.transfer_of_map (index.append_left _ _) (by {intro, rw [index.append_left_val]})) (proof.of_use p\u2081) in\n  let p\u2082 : proof (\u03bb (i : index p.use), ax i.val) t t\u2082 :=\n  proof.transfer (proof.transfer_of_map (index.append_right _ _) (by {intro, rw [index.append_right_val]})) (proof.of_use p\u2082) in\n  proof.eucl p\u2081 p\u2082\n\ntheorem compactness (e : identity sig) : models ax e \u2192 \u2203 (as : list \u03b9), models (\u03bb (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 {\u03b1 : \u211d} (h\u03b1_irrat : irrational \u03b1) : closure ((\u03bb m : \u2124, int.fract (\u03b1 * \u2191m)) '' (@set.univ \u2124)) = set.Icc 0 1 :=density_of_irrational_orbit (\u03b1 : \u211d) (h\u03b1 : \u00ac is_rat \u03b1) : \u2200 y \u2208 Icc 0 1, \u2203 x \u2208 Icc 0 1, \u2203 N : \u2124, |y - (N : \u211d) * 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 : \u211d) (h1 : y \u2208 Icc 0 1),\n  have h2 : \u2200 (i j : \u2124), i \u2260 j \u2192 (i : \u211d) * \u03b1 - (i : \u211d) \u2260 (j : \u211d) * \u03b1 - (j : \u211d), from by auto [h\u03b1, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.def, is_rat.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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by auto [set.subset_of_mem_powerset, set.subset_of_mem_powerset],\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by auto [set.inter_subset_left],\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by auto [set.subset.trans],\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by auto using [use (a\u207b\u00b9 * b)],\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by auto using [use b * a\u207b\u00b9], \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from by auto [h1],\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 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 : \u2115 \u2192 \u211d) (l : \u211d) : \nlet seq_limit : (\u2115 \u2192 \u211d) \u2192 \u211d \u2192 Prop :=  \u03bb (u : \u2115 \u2192 \u211d) (l : \u211d), \u2200 \u03b5 > 0, \u2203 N, \u2200 n > N, |u n - l| < \u03b5 in\n seq_limit y l \u2192 seq_limit z l \u2192  (\u2200 n : \u2115, (y n) \u2264 (x n) \u2227 (x n) \u2264 (z n)) \u2192 seq_limit x l :=\nbegin\n  assume seq_limit (h2 : seq_limit y l) (h3 : seq_limit z l) (h4 : \u2200 (n : \u2115), y n \u2264 x n \u2227 x n \u2264 z n) (\u03b5), \n\n  --From Negative of Absolute Value: $\\size {x - l} < \\epsilon \\iff l - \\epsilon < x < l + \\epsilon$\n  have h5 : \u2200 x, |x - l| < \u03b5 \u2194 (((l - \u03b5) < x) \u2227 (x < (l + \u03b5))), \n  from by auto [abs_sub_lt_iff] using [linarith],\n  \n  --Let $\\epsilon > 0$.\n  assume (h7 : \u03b5 > 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 \u03b5 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 \u03b5 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 : \u2200 n > N, n > N1 \u2227 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 : \u2200 n > N, (((l - \u03b5) < (y n)) \u2227 ((y n) \u2264 (x n))) \u2227 (((x n) \u2264 (z n)) \u2227 ((z n) < l+\u03b5)), \n  from by auto [h8, h10, h5, h9],\n\n  --$\\forall n > N: l - \\epsilon < x_n < l + \\epsilon$\n  have h15 : \u2200 n > N, ((l - \u03b5) < (x n)) \u2227 ((x n) < (l+\u03b5)), \n  from by auto [h11] using [linarith],\n\n  --So $\\forall n > N: \\size {x_n - l} < \\epsilon$\n  --Hence the result\n  show  \u2200 (n : \u2115), n > N \u2192 |x n - l| < \u03b5, \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 \u2192 Fin n\n  rank : Nat \u2192 Nat\n  rank_lt : \u2200 i, (parent i).1 \u2260 i \u2192 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 \u2264 k) : UFModel k where\n  parent i :=\n    if h : i < n then\n      let \u27e8a, h'\u27e9 := m.parent \u27e8i, h\u27e9\n      \u27e8a, lt_of_lt_of_le h' le\u27e9\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    \u00b7 simp [(m.parent \u27e8i, h\u27e9).2, h]; exact m.rank_lt _\n    \u00b7 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    \u00b7 rw [\u2190 h']; exact fun _ \u21a6 h\n    \u00b7 exact m.rank_lt i\n\ndef setParentBump {n} (m : UFModel n) (x y : Fin n)\n    (H : m.rank x \u2264 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 \u2227 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\u2081; simp [h\u2081]; split <;> rename_i h\u2082 <;>\n        (intro h; simp [h] at h\u2082 <;> simp [h\u2081, h\u2082, h]))\n    \u00b7 simp [\u2190 h\u2081]; split <;> rename_i h\u2083\n      \u00b7 rw [h\u2083]; apply Nat.lt_succ_self\n      \u00b7 exact lt_of_le_of_ne H h\u2083\n    \u00b7 have := Fin.eq_of_val_eq h\u2082.1; subst this\n      simp [hroot] at h\n    \u00b7 have := m.rank_lt i h\n      split <;> rename_i h\u2083\n      \u00b7 rw [h\u2083.1]; exact Nat.lt_succ_of_lt this\n      \u00b7 exact this\n\nend UFModel\n\nstructure UFNode (\u03b1 : Type _) where\n  parent : Nat\n  value : \u03b1\n  rank : Nat\n\ninductive UFModel.Agrees (arr : Array \u03b1) (f : \u03b1 \u2192 \u03b2) : \u2200 {n}, (Fin n \u2192 \u03b2) \u2192 Prop\n| mk : Agrees arr f fun i \u21a6 f (arr.get i)\n\nnamespace UFModel.Agrees\n\ntheorem mk' {arr : Array \u03b1} {f : \u03b1 \u2192 \u03b2} {n} {g : Fin n \u2192 \u03b2}\n  (e : n = arr.size)\n  (H : \u2200 i h\u2081 h\u2082, f (arr.get \u27e8i, h\u2081\u27e9) = g \u27e8i, h\u2082\u27e9) :\n  Agrees arr f g := by\n    cases e\n    have : (fun i \u21a6 f (arr.get i)) = g := by funext \u27e8i, h\u27e9; apply H\n    cases this; constructor\n\n\n\ntheorem get_eq {arr : Array \u03b1} {n} {m : Fin n \u2192 \u03b2} (H : Agrees arr f m) :\n  \u2200 i h\u2081 h\u2082, f (arr.get \u27e8i, h\u2081\u27e9) = m \u27e8i, h\u2082\u27e9 := by\n  cases H; exact fun i h _ \u21a6 rfl\n\ntheorem get_eq' {arr : Array \u03b1} {m : Fin arr.size \u2192 \u03b2} (H : Agrees arr f m)\n  (i) : f (arr.get i) = m i := H.get_eq ..\n\ntheorem empty {f : \u03b1 \u2192 \u03b2} {g : Fin 0 \u2192 \u03b2} : Agrees #[] f g := mk' rfl \u03bb.\n\ntheorem push {arr : Array \u03b1} {n} {m : Fin n \u2192 \u03b2} (H : Agrees arr f m)\n  (k) (hk : k = n + 1) (x) (m' : Fin k \u2192 \u03b2)\n  (hm\u2081 : \u2200 (i : Fin k) (h : i < n), m' i = m \u27e8i, h\u27e9)\n  (hm\u2082 : \u2200 (h : n < k), f x = m' \u27e8n, h\u27e9) : 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\u2081 h\u2082 \u21a6 ?_\n  simp [Array.get_push]; split <;> (rename_i h; simp at hm\u2081 \u22a2)\n  \u00b7 rw [\u2190 hm\u2081 \u27e8i, h\u2082\u27e9]; assumption\n  \u00b7 cases show i = arr.size by apply le_antisymm <;> simp_all [Nat.lt_succ]\n    rw [hm\u2082]\n\ntheorem set {arr : Array \u03b1} {n} {m : Fin n \u2192 \u03b2} (H : Agrees arr f m)\n  {i : Fin arr.size} {x} {m' : Fin n \u2192 \u03b2}\n  (hm\u2081 : \u2200 (j : Fin n), j.1 \u2260 i \u2192 m' j = m j)\n  (hm\u2082 : \u2200 (h : i < n), f x = m' \u27e8i, h\u27e9) : Agrees (arr.set i x) f m' := by\n  cases H\n  refine mk' (by simp) fun j hj\u2081 hj\u2082 \u21a6 ?_\n  suffices f (Array.set arr i x)[j] = m' \u27e8j, hj\u2082\u27e9 by simp_all [Array.get_set]\n  by_cases h : i = j\n  \u00b7 subst h; rw [Array.get_set_eq, \u2190 hm\u2082]\n  \u00b7 rw [arr.get_set_ne _ _ _ h, hm\u2081 \u27e8j, _\u27e9 (Ne.symm h)]; rfl\n\nend UFModel.Agrees\n\ndef UFModel.Models (arr : Array (UFNode \u03b1)) {n} (m : UFModel n) :=\n  UFModel.Agrees arr (\u00b7.parent) (fun i \u21a6 m.parent i) \u2227\n  UFModel.Agrees arr (\u00b7.rank) (fun i : Fin n \u21a6 m.rank i)\n\nnamespace UFModel.Models\n\ntheorem size_eq {arr : Array (UFNode \u03b1)} {n} {m : UFModel n} (H : m.Models arr) :\n  n = arr.size := H.1.size_eq\n\ntheorem parent_eq {arr : Array (UFNode \u03b1)} {n} {m : UFModel n} (H : m.Models arr)\n  (i : Nat) (h\u2081 : i < arr.size) (h\u2082) : arr[i].parent = m.parent \u27e8i, h\u2082\u27e9 := H.1.get_eq ..\n\ntheorem parent_eq' {arr : Array (UFNode \u03b1)} {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 \u03b1)} {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 (\u03b1 := \u03b1) #[] := \u27e8Agrees.empty, Agrees.empty\u27e9\n\ntheorem push {arr : Array (UFNode \u03b1)} {n} {m : UFModel n} (H : m.Models arr)\n  (k) (hk : k = n + 1) (x) :\n  (m.push k (hk \u25b8 Nat.le_add_right ..)).Models (arr.push \u27e8n, x, 0\u27e9) := by\n  apply H.imp <;>\n  \u00b7 intro H\n    refine H.push _ hk _ _ (fun i h \u21a6 ?_) (fun h \u21a6 ?_) <;>\n    simp [UFModel.push, h, lt_irrefl]\n\ntheorem setParent {arr : Array (UFNode \u03b1)} {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 \u27e8i.1, hi\u27e9 x) :=\n  \u27e8hm.1.set\n      (fun k (h : (k:\u2115) \u2260 i) \u21a6 by simp [UFModel.setParent, h.symm])\n      (fun h \u21a6 by simp [UFModel.setParent, hp]),\n    hm.2.set (fun _ _ \u21a6 rfl) (fun _ \u21a6 hrk.trans $ hm.2.get_eq ..)\u27e9\n\nend UFModel.Models\n\nstructure UnionFind (\u03b1) where\n  arr : Array (UFNode \u03b1)\n  model : \u2203 (n : _) (m : UFModel n), m.Models arr\n\nnamespace UnionFind\n\ndef size (self : UnionFind \u03b1) := self.arr.size\n\ntheorem model' (self : UnionFind \u03b1) : \u2203 (m : UFModel self.arr.size), m.Models self.arr := by\n  let \u27e8n, m, hm\u27e9 := self.model; cases hm.size_eq; exact \u27e8m, hm\u27e9\n\ndef empty : UnionFind \u03b1 where\n  arr := #[]\n  model := \u27e8_, _, UFModel.Models.empty\u27e9\n\ndef mkEmpty (c : Nat) : UnionFind \u03b1 where\n  arr := Array.mkEmpty c\n  model := \u27e8_, _, UFModel.Models.empty\u27e9\n\ndef rank (self : UnionFind \u03b1) (i : Nat) : Nat :=\n  if h : i < self.size then (self.arr.get \u27e8i, h\u27e9).rank else 0\n\ndef rankMaxAux (self : UnionFind \u03b1) : \u2200 (i : Nat),\n  {k : Nat // \u2200 j < i, \u2200 h, (self.arr.get \u27e8j, h\u27e9).rank \u2264 k}\n| 0 => \u27e80, \u03bb.\u27e9\n| i+1 => by\n  let \u27e8k, H\u27e9 := rankMaxAux self i\n  refine \u27e8max k (if h : _ then (self.arr.get \u27e8i, h\u27e9).rank else 0), fun j hj h \u21a6 ?_\u27e9\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 \u03b1) := (rankMaxAux self self.size).1 + 1\n\ntheorem lt_rankMax' (self : UnionFind \u03b1) (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 \u03b1) (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 \u03b1) {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 \u03b1) {i : Nat} (h) : self.arr[i].parent \u2260 i \u2192\n  self.rank i < self.rank self.arr[i].parent := by\n  let \u27e8m, hm\u27e9 := self.model'\n  simpa [hm.parent_eq, hm.rank_eq, rank, size, h, (m.parent \u27e8i, h\u27e9).2] using m.rank_lt \u27e8i, h\u27e9\n\ntheorem parent_lt (self : UnionFind \u03b1) (i : Nat) (h) : self.arr[i].parent < self.size := by\n  let \u27e8m, hm\u27e9 := self.model'\n  simp [hm.parent_eq, size, (m.parent \u27e8i, h\u27e9).2, h]\n\ndef push (self : UnionFind \u03b1) (x : \u03b1) : UnionFind \u03b1 where\n  arr := self.arr.push \u27e8self.arr.size, x, 0\u27e9\n  model := let \u27e8_, hm\u27e9 := self.model'; \u27e8_, _, hm.push _ rfl _\u27e9\n\ndef findAux (self : UnionFind \u03b1) (x : Fin self.size) :\n  (s : Array (UFNode \u03b1)) \u00d7' (root : Fin s.size) \u00d7'\n    \u2203 n, \u2203 (m : UFModel n) (m' : UFModel n),\n      m.Models self.arr \u2227 m'.Models s \u2227 m'.rank = m.rank \u2227\n      (\u2203 hr, (m'.parent \u27e8root, hr\u27e9).1 = root) \u2227\n      m.rank x \u2264 m.rank root := by\n  let y := self.arr[x].parent\n  refine if h : y = x then \u27e8self.arr, x, ?a'\u27e9 else\n    have := Nat.sub_lt_sub_left (self.lt_rankMax x) (self.rank_lt _ h)\n    let \u27e8arr\u2081, root, H\u27e9 := self.findAux \u27e8y, self.parent_lt _ x.2\u27e9\n    have hx := ?hx\n    let arr\u2082 := arr\u2081.set \u27e8x, hx\u27e9 {arr\u2081.get \u27e8x, hx\u27e9 with parent := root}\n    \u27e8arr\u2082, \u27e8root, by simp [root.2]\u27e9, ?b'\u27e9\n  -- start proof\n  case a' => -- FIXME: hygiene bug causes `case a` to fail\n    let \u27e8m, hm\u27e9 := self.model'\n    exact \u27e8_, m, m, hm, hm, rfl, \u27e8x.2, by rwa [\u2190 hm.parent_eq]\u27e9, le_refl _\u27e9\n  all_goals let \u27e8n, m, m', hm, hm', e, \u27e8_, hr\u27e9, le\u27e9 := H\n  case hx => exact hm'.size_eq \u25b8 hm.size_eq.symm \u25b8 x.2\n  case b' =>\n    let x' : Fin n := \u27e8x, hm.size_eq \u25b8 x.2\u27e9\n    let root : Fin n := \u27e8root, hm'.size_eq.symm \u25b8 root.2\u27e9\n    have hy : (UFModel.parent m x').1 = y := by rw [\u2190 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 \u27e8n, m, _, hm,\n      hm'.setParent x' root (by rw [e]; exact this) hx _ rfl rfl, e,\n      \u27e8root.2, ?_\u27e9, le_of_lt this\u27e9\n    have : x.1 \u2260 root := mt (congrArg _) (ne_of_lt this); dsimp only at this\n    simp [UFModel.setParent, this, hr]\ntermination_by _ \u03b1 self x => self.rankMax - self.rank x\n\ndef find (self : UnionFind \u03b1) (x : Fin self.size) :\n  (s : UnionFind \u03b1) \u00d7 (root : Fin s.size) \u00d7'\n    s.size = self.size \u2227 (s.arr.get root).parent = root :=\n  let \u27e8s, root, H\u27e9 := self.findAux x\n  have : _ \u2227 s.size = self.size \u2227 s[root.1].parent = root :=\n    let \u27e8n, _, m', hm, hm', _, \u27e8_, hr\u27e9, _\u27e9 := H\n    \u27e8\u27e8n, m', hm'\u27e9, hm'.size_eq.symm.trans hm.size_eq, by rwa [hm'.parent_eq]\u27e9\n  \u27e8\u27e8s, this.1\u27e9, root, this.2\u27e9\n\ndef link (self : UnionFind \u03b1) (x y : Fin self.size)\n  (yroot : (self.arr.get y).parent = y) : UnionFind \u03b1 := 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      \u27e8self.arr.set y {ny with parent := x}, ?a\u27e9\n    else\n      let arr\u2081 := self.arr.set x {nx with parent := y}\n      let arr\u2082 := if nx.rank = ny.rank then\n        arr\u2081.set \u27e8y, by simp; exact y.2\u27e9 {ny with rank := ny.rank + 1}\n      else arr\u2081\n      \u27e8arr\u2082, ?b\u27e9\n  -- start proof\n  case a =>\n    let \u27e8m, hm\u27e9 := self.model'\n    exact \u27e8_, _, hm.setParent y x (by simpa [hm.rank_eq] using h) _ _ rfl rfl\u27e9\n  case b =>\n    let \u27e8m, hm\u27e9 := self.model'; let n := self.size\n    refine \u27e8_, m.setParentBump x y (by simpa [hm.rank_eq] using h)\n      (by simpa [\u2190 hm.parent_eq'] using yroot), ?_\u27e9\n    let parent (i : Fin n) := (if x.1 = i then y else m.parent i).1\n    have : UFModel.Agrees arr\u2081 (\u00b7.parent) parent :=\n      hm.1.set (fun i h \u21a6 by simp; rw [if_neg h.symm]) (fun h \u21a6 by simp)\n    have H1 : UFModel.Agrees arr\u2082 (\u00b7.parent) parent := by\n      simp; split\n      \u00b7 exact this.set (fun i h \u21a6 by simp [h.symm]) (fun h \u21a6 by simp [ne, hm.parent_eq'])\n      \u00b7 exact this\n    have : UFModel.Agrees arr\u2081 (\u00b7.rank) (fun i : Fin n \u21a6 m.rank i) :=\n      hm.2.set (fun i _ \u21a6 by simp) (fun _ \u21a6 by simp [hm.rank_eq])\n    let rank (i : Fin n) := if y.1 = i \u2227 m.rank x = m.rank y then m.rank y + 1 else m.rank i\n    have H2 : UFModel.Agrees arr\u2082 (\u00b7.rank) rank := by\n      simp; split <;> (rename_i xy; simp [hm.rank_eq] at xy; simp [xy])\n      \u00b7 exact this.set (fun i h \u21a6 by rw [if_neg h.symm]) (fun h \u21a6 by simp [hm.rank_eq])\n      \u00b7 exact this\n    exact \u27e8H1, H2\u27e9\n\ndef union (self : UnionFind \u03b1) (x y : Fin self.size) : UnionFind \u03b1 :=\n  let \u27e8self\u2081, rx, e, _\u27e9 := self.find x\n  let \u27e8self\u2082, ry, e, hry\u27e9 := self\u2081.find \u27e8y, by rw [e]; exact y.2\u27e9\n  self\u2082.link \u27e8rx, by rw [e]; exact rx.2\u27e9 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\u00e4rn. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: David W\u00e4rn, 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 \u27f6 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 \u2192 V \u2192 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\u2081 v\u2082 u u\u2081 u\u2082\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 \u27f6 b` of arrows from `a` to `b`.\n\nFor graphs with no repeated edges, one can use `quiver.{0} V`, which ensures\n`a \u27f6 b : Prop`. For multigraphs, one can use `quiver.{v+1} V`, which ensures\n`a \u27f6 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 `\u27f6` notation instead.\n-/\nclass Quiver (V : Type u) where\n  Hom : V \u2192 V \u2192 Sort v\n#align quiver Quiver\n-/\n\n-- mathport name: \u00abexpr \u27f6 \u00bb\ninfixr:10 \" \u27f6 \" => 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\u2093'. -/\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\u2081) [Quiver.{v\u2081} V] (W : Type u\u2082) [Quiver.{v\u2082} W] where\n  obj : V \u2192 W\n  map : \u2200 {X Y : V}, (X \u27f6 Y) \u2192 (obj X \u27f6 obj Y)\n#align prefunctor Prefunctor\n\nnamespace Prefunctor\n\n#print Prefunctor.ext /-\n@[ext]\ntheorem ext {V : Type u} [Quiver.{v\u2081} V] {W : Type u\u2082} [Quiver.{v\u2082} W] {F G : Prefunctor V W}\n    (h_obj : \u2200 X, F.obj X = G.obj X)\n    (h_map :\n      \u2200 (X Y : V) (f : X \u27f6 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  \u27e8id V\u27e9\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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: \u00abexpr \u2964q \u00bb\ninfixl:50 \" \u2964q \" => Prefunctor\n\n-- mathport name: \u00abexpr \u22d9q \u00bb\ninfixl:60 \" \u22d9q \" => Prefunctor.comp\n\n-- mathport name: \u00abexpr\ud835\udfedq\u00bb\nnotation \"\ud835\udfedq\" => id\n\nend Prefunctor\n\nnamespace Quiver\n\n#print Quiver.opposite /-\n/-- `V\u1d52\u1d56` reverses the direction of all arrows of `V`. -/\ninstance opposite {V} [Quiver V] : Quiver V\u1d52\u1d56 :=\n  \u27e8fun a b => unop b \u27f6 unop a\u27e9\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 \u27f6 Y) : op Y \u27f6 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\u1d52\u1d56`, we can take the \"unopposite\" back in `V`.\n-/\ndef Hom.unop {V} [Quiver V] {X Y : V\u1d52\u1d56} (f : X \u27f6 Y) : unop Y \u27f6 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  \u27e8fun a b => PEmpty\u27e9\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 \u27f6 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  \u2200 a b : V, Subsingleton (a \u27f6 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\u00f6der-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 \u2192 \\beta` and :math:`g : \\beta \u2192 \\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\u00f6der, 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\u00f6der 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\u00f6der 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\u00f6der 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 {\u03b1 \u03b2 : Type*} [nonempty \u03b2]\n-- QUOTE.\n\n/- TEXT:\nThe annotation ``[nonempty \u03b2]`` specifies that ``\u03b2`` 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 \u03b2]`` for the operation\n``inv_fun`` that is defined in mathlib.\nGiven ``x : \u03b1``, ``inv_fun g x`` chooses a preimage of ``x``\nin ``\u03b2`` if there is one,\nand returns an arbitrary element of ``\u03b2`` 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 : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1)\n\ndef sb_aux : \u2115 \u2192 set \u03b1\n| 0       := univ \\ (g '' univ)\n| (n + 1) := g '' (f '' sb_aux n)\n\ndef sb_set := \u22c3 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 \u2216 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 : \u03b1) : \u03b2 := if x \u2208 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 : \u03b1} (hx : x \u2209 sb_set f g) :\n    g (inv_fun g x) = x :=\nbegin\n  have : x \u2208 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 \u27e8mem_univ _, hx\u27e9 },\n-- BOTH:\n  have : \u2203 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\u2081 x\u2082,\n  assume hxeq : h x\u2081 = h x\u2082,\n  show x\u2081 = x\u2082,\n  simp only [h_def, sb_fun, \u2190A_def] at hxeq,\n  by_cases xA : x\u2081 \u2208 A \u2228 x\u2082 \u2208 A,\n  { wlog : x\u2081 \u2208 A := xA using [x\u2081 x\u2082, x\u2082 x\u2081],\n    have x\u2082A : x\u2082 \u2208 A,\n    { apply not_imp_self.mp,\n      assume x\u2082nA : x\u2082 \u2209 A,\n      rw [if_pos xA, if_neg x\u2082nA] at hxeq,\n      rw [A_def, sb_set, mem_Union] at xA,\n      have x\u2082eq : x\u2082 = g (f x\u2081),\n/- EXAMPLES:\n      { sorry },\nSOLUTIONS: -/\n      { rw [hxeq, sb_right_inv f g x\u2082nA] },\n-- BOTH:\n      rcases xA with \u27e8n, hn\u27e9,\n      rw [A_def, sb_set, mem_Union],\n      use n + 1,\n      simp [sb_aux],\n      exact \u27e8x\u2081, hn, x\u2082eq.symm\u27e9 },\n/- EXAMPLES:\n    sorry },\nSOLUTIONS: -/\n    rw [if_pos xA, if_pos x\u2082A] 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 [\u2190sb_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 \u2208 sb_aux f g 0``\nand ``g y \u2208 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 \u2208 A,\n  { rw [A_def, sb_set, mem_Union] at gyA,\n    rcases gyA with \u27e8n, hn\u27e9,\n    cases n with n,\n    { simp [sb_aux] at hn,\n      contradiction },\n    simp [sb_aux] at hn,\n    rcases hn with \u27e8x, xmem, hx\u27e9,\n    use x,\n    have : x \u2208 A,\n    { rw [A_def, sb_set, mem_Union],\n      exact \u27e8n, xmem\u27e9 },\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 \u2227 surjective h``.\nEXAMPLES: -/\n-- QUOTE:\ntheorem schroeder_bernstein {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1}\n    (hf: injective f) (hg : injective g) :\n  \u2203 h : \u03b1 \u2192 \u03b2, bijective h :=\n\u27e8sb_fun f g, sb_injective f g hf hg, sb_surjective f g hf hg\u27e9\n-- QUOTE.\n\n/- Auxliary information -/\n\nsection\n\nvariables  (g : \u03b2 \u2192 \u03b1) (x : \u03b1)\n\n-- TAG: inv_fun g\n#check (inv_fun g : \u03b1 \u2192 \u03b2)\n\n#check (left_inverse_inv_fun : injective g \u2192 left_inverse (inv_fun g) g)\n#check (left_inverse_inv_fun : injective g \u2192 \u2200 y, inv_fun g (g y) = y)\n\n#check (inv_fun_eq : (\u2203 y, g y = x) \u2192 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: S\u00e9bastien Gou\u00ebzel\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 \ud835\udd5c 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 [\u00d7n]\u2192L[\ud835\udd5c] 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 `\ud835\udd5c`, from `E` to `F`, is given by a family of\nmultilinear maps from `E^n` to `F` for all `n`. -/\ndef formal_multilinear_series (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] (E : Type u_2)\n    [normed_group E] [normed_space \ud835\udd5c E] (F : Type u_3) [normed_group F] [normed_space \ud835\udd5c F] :=\n  (n : \u2115) \u2192 continuous_multilinear_map \ud835\udd5c (fun (i : fin n) => E) F\n\nprotected instance formal_multilinear_series.inhabited {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F]\n    [normed_space \ud835\udd5c F] : Inhabited (formal_multilinear_series \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F]\n    [normed_space \ud835\udd5c F] : module \ud835\udd5c (formal_multilinear_series \ud835\udd5c E F) :=\n  let _inst : (n : \u2115) \u2192 module \ud835\udd5c (continuous_multilinear_map \ud835\udd5c (fun (i : fin n) => E) F) :=\n    fun (n : \u2115) => continuous_multilinear_map.semimodule;\n  pi.semimodule \u2115 (fun (n : \u2115) => continuous_multilinear_map \ud835\udd5c (fun (i : fin n) => E) F) \ud835\udd5c\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 \u2192L[\ud835\udd5c] 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E]\n    [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    (p : formal_multilinear_series \ud835\udd5c E F) :\n    formal_multilinear_series \ud835\udd5c E (continuous_linear_map \ud835\udd5c E F) :=\n  fun (n : \u2115) => continuous_multilinear_map.curry_right (p (Nat.succ n))\n\n/-- Adding a zeroth term to a formal multilinear series taking values in `E \u2192L[\ud835\udd5c] 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E]\n    [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    (q : formal_multilinear_series \ud835\udd5c E (continuous_linear_map \ud835\udd5c E F)) (z : F) :\n    formal_multilinear_series \ud835\udd5c E F :=\n  sorry\n\n/-- Killing the zeroth coefficient in a formal multilinear series -/\ndef remove_zero {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E]\n    [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    (p : formal_multilinear_series \ud835\udd5c E F) : formal_multilinear_series \ud835\udd5c E F :=\n  sorry\n\n@[simp] theorem remove_zero_coeff_zero {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    (p : formal_multilinear_series \ud835\udd5c E F) : remove_zero p 0 = 0 :=\n  rfl\n\n@[simp] theorem remove_zero_coeff_succ {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    (p : formal_multilinear_series \ud835\udd5c E F) (n : \u2115) : remove_zero p (n + 1) = p (n + 1) :=\n  rfl\n\ntheorem remove_zero_of_pos {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    (p : formal_multilinear_series \ud835\udd5c E F) {n : \u2115} (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E]\n    [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    (p : formal_multilinear_series \ud835\udd5c E F) {m : \u2115} {n : \u2115} {v : fin m \u2192 E} {w : fin n \u2192 E}\n    (h1 : m = n)\n    (h2 :\n      \u2200 (i : \u2115) (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\u2099` 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G] (p : formal_multilinear_series \ud835\udd5c F G)\n    (u : continuous_linear_map \ud835\udd5c E F) : formal_multilinear_series \ud835\udd5c E G :=\n  fun (n : \u2115) => continuous_multilinear_map.comp_continuous_linear_map (p n) fun (i : fin n) => u\n\n@[simp] theorem comp_continuous_linear_map_apply {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c]\n    {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F]\n    [normed_space \ud835\udd5c F] {G : Type u_4} [normed_group G] [normed_space \ud835\udd5c G]\n    (p : formal_multilinear_series \ud835\udd5c F G) (u : continuous_linear_map \ud835\udd5c E F) (n : \u2115)\n    (v : fin n \u2192 E) : coe_fn (comp_continuous_linear_map p u n) v = coe_fn (p n) (\u21d1u \u2218 v) :=\n  rfl\n\n/-- Reinterpret a formal `\ud835\udd5c'`-multilinear series as a formal `\ud835\udd5c`-multilinear series, where `\ud835\udd5c'` is a\nnormed algebra over `\ud835\udd5c`. -/\n@[simp] protected def restrict_scalars (\ud835\udd5c : Type u_1) [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2}\n    [normed_group E] [normed_space \ud835\udd5c E] {F : Type u_3} [normed_group F] [normed_space \ud835\udd5c F]\n    {\ud835\udd5c' : Type u_5} [nondiscrete_normed_field \ud835\udd5c'] [normed_algebra \ud835\udd5c \ud835\udd5c'] [normed_space \ud835\udd5c' E]\n    [is_scalar_tower \ud835\udd5c \ud835\udd5c' E] [normed_space \ud835\udd5c' F] [is_scalar_tower \ud835\udd5c \ud835\udd5c' F]\n    (p : formal_multilinear_series \ud835\udd5c' E F) : formal_multilinear_series \ud835\udd5c E F :=\n  fun (n : \u2115) => continuous_multilinear_map.restrict_scalars \ud835\udd5c (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 `\u03b1` with a monoid structure, `single_obj \u03b1` is `unit` type with `category` structure\nsuch that `End (single_obj \u03b1).star` is the monoid `\u03b1`.  This can be extended to a functor `Mon \u2964\nCat`.\n\nIf `\u03b1` is a group, then `single_obj \u03b1` is a groupoid.\n\nAn element `x : \u03b1` can be reinterpreted as an element of `End (single_obj.star \u03b1)` using\n`single_obj.to_End`.\n\n## Implementation notes\n\n- `category_struct.comp` on `End (single_obj.star \u03b1)` is `flip (*)`, not `(*)`. This way\n  multiplication on `End` agrees with the multiplication on `\u03b1`.\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 (\u03b1 : 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 (\u03b1 : Type u) [HasOne \u03b1] [Mul \u03b1] : category_struct (single_obj \u03b1) :=\n  category_struct.mk (fun (_x : single_obj \u03b1) => 1)\n    fun (_x _x_1 _x_2 : single_obj \u03b1) (x : _x \u27f6 _x_1) (y : _x_1 \u27f6 _x_2) => y * x\n\n/-- Monoid laws become category laws for the single object category. -/\nprotected instance category (\u03b1 : Type u) [monoid \u03b1] : category (single_obj \u03b1) :=\n  category.mk\n\n/--\nGroupoid structure on `single_obj \u03b1`.\n\nSee https://stacks.math.columbia.edu/tag/0019.\n-/\nprotected instance groupoid (\u03b1 : Type u) [group \u03b1] : groupoid (single_obj \u03b1) :=\n  groupoid.mk fun (_x _x_1 : single_obj \u03b1) (x : _x \u27f6 _x_1) => x\u207b\u00b9\n\n/-- The single object in `single_obj \u03b1`. -/\nprotected def star (\u03b1 : Type u) : single_obj \u03b1 :=\n  Unit.unit\n\n/-- The endomorphisms monoid of the only object in `single_obj \u03b1` is equivalent to the original\n     monoid \u03b1. -/\ndef to_End (\u03b1 : Type u) [monoid \u03b1] : \u03b1 \u2243* End (single_obj.star \u03b1) :=\n  mul_equiv.mk (equiv.to_fun (equiv.refl \u03b1)) (equiv.inv_fun (equiv.refl \u03b1)) sorry sorry sorry\n\ntheorem to_End_def (\u03b1 : Type u) [monoid \u03b1] (x : \u03b1) : coe_fn (to_End \u03b1) x = x :=\n  rfl\n\n/-- There is a 1-1 correspondence between monoid homomorphisms `\u03b1 \u2192 \u03b2` 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 (\u03b1 : Type u) (\u03b2 : Type v) [monoid \u03b1] [monoid \u03b2] : (\u03b1 \u2192* \u03b2) \u2243 single_obj \u03b1 \u2964 single_obj \u03b2 :=\n  equiv.mk (fun (f : \u03b1 \u2192* \u03b2) => functor.mk id fun (_x _x : single_obj \u03b1) => \u21d1f)\n    (fun (f : single_obj \u03b1 \u2964 single_obj \u03b2) => monoid_hom.mk (functor.map f) sorry sorry) sorry sorry\n\ntheorem map_hom_id (\u03b1 : Type u) [monoid \u03b1] : coe_fn (map_hom \u03b1 \u03b1) (monoid_hom.id \u03b1) = \ud835\udfed :=\n  rfl\n\ntheorem map_hom_comp {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2) {\u03b3 : Type w} [monoid \u03b3] (g : \u03b2 \u2192* \u03b3) : coe_fn (map_hom \u03b1 \u03b3) (monoid_hom.comp g f) = coe_fn (map_hom \u03b1 \u03b2) f \u22d9 coe_fn (map_hom \u03b2 \u03b3) 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 : \u03b1 \u2192 \u03b2` as a functor `(single_obj \u03b1) \u2964 (single_obj \u03b2)`.\nSee also `category_theory.single_obj.map_hom` for an equivalence between these types. -/\ndef to_functor {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2) : category_theory.single_obj \u03b1 \u2964 category_theory.single_obj \u03b2 :=\n  coe_fn (category_theory.single_obj.map_hom \u03b1 \u03b2) f\n\n@[simp] theorem id_to_functor (\u03b1 : Type u) [monoid \u03b1] : to_functor (id \u03b1) = \ud835\udfed :=\n  rfl\n\n@[simp] theorem comp_to_functor {\u03b1 : Type u} {\u03b2 : Type v} [monoid \u03b1] [monoid \u03b2] (f : \u03b1 \u2192* \u03b2) {\u03b3 : Type w} [monoid \u03b3] (g : \u03b2 \u2192* \u03b3) : to_functor (comp g f) = to_functor f \u22d9 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 (\u03b1 : Type u) [monoid \u03b1] : units \u03b1 \u2243* category_theory.Aut (category_theory.single_obj.star \u03b1) :=\n  mul_equiv.trans (map_equiv (category_theory.single_obj.to_End \u03b1))\n    (category_theory.Aut.units_End_equiv_Aut (category_theory.single_obj.star \u03b1))\n\n@[simp] theorem to_Aut_hom (\u03b1 : Type u) [monoid \u03b1] (x : units \u03b1) : category_theory.iso.hom (coe_fn (to_Aut \u03b1) x) = coe_fn (category_theory.single_obj.to_End \u03b1) \u2191x :=\n  rfl\n\n@[simp] theorem to_Aut_inv (\u03b1 : Type u) [monoid \u03b1] (x : units \u03b1) : category_theory.iso.inv (coe_fn (to_Aut \u03b1) x) = coe_fn (category_theory.single_obj.to_End \u03b1) \u2191(x\u207b\u00b9) :=\n  rfl\n\nend units\n\n\nnamespace Mon\n\n\n/-- The fully faithful functor from `Mon` to `Cat`. -/\ndef to_Cat : Mon \u2964 category_theory.Cat :=\n  category_theory.functor.mk (fun (x : Mon) => category_theory.Cat.of (category_theory.single_obj \u21a5x))\n    fun (x y : Mon) (f : x \u27f6 y) => coe_fn (category_theory.single_obj.map_hom \u21a5x \u21a5y) 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 \u21a5x \u21a5y)\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\u00f6lzl\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' {\u03b1} [discrete_field \u03b1] (a b : \u03b1) : (a * b)\u207b\u00b9 = b\u207b\u00b9 * a\u207b\u00b9 :=\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 ` \u2192_{`: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 \u2192 F)\n  extends is_linear_map k L : Prop :=\n(bound : \u2203 M, M > 0 \u2227 \u2200 x : E, \u2225 L x \u2225 \u2264 M * \u2225 x \u2225)\n\ninclude k\n\nlemma is_linear_map.with_bound\n  {L : E \u2192 F} (hf : is_linear_map k L) (M : \u211d) (h : \u2200 x : E, \u2225 L x \u2225 \u2264 M * \u2225 x \u2225) :\n  is_bounded_linear_map k L :=\n\u27e8 hf, classical.by_cases\n  (assume : M \u2264 0, \u27e81, 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)\u27e9)\n  (assume : \u00ac M \u2264 0, \u27e8M, lt_of_not_ge this, h\u27e9)\u27e9\n\nnamespace is_bounded_linear_map\n\ndef to_linear_map (f : E \u2192 F) (h : is_bounded_linear_map k f) : E \u2192\u2097[k] F :=\n(is_linear_map.mk' _ h.to_is_linear_map)\n\nlemma zero : is_bounded_linear_map k (\u03bb (x:E), (0:F)) :=\n(0 : E \u2192\u2097 F).is_linear.with_bound 0 $ by simp [le_refl]\n\nlemma id : is_bounded_linear_map k (\u03bb (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 \u2192 F} (c : k) : is_bounded_linear_map k f \u2192 is_bounded_linear_map k (\u03bb e, c \u2022 f e)\n| \u27e8hf, \u27e8M, hM, h\u27e9\u27e9 := (c \u2022 hf.mk' f).is_linear.with_bound (\u2225c\u2225 * M) $ assume x,\n  calc \u2225c \u2022 f x\u2225 = \u2225c\u2225 * \u2225f x\u2225 : norm_smul c (f x)\n    ... \u2264 \u2225c\u2225 * (M * \u2225x\u2225) : mul_le_mul_of_nonneg_left (h x) (norm_nonneg c)\n    ... = (\u2225c\u2225 * M) * \u2225x\u2225 : (mul_assoc _ _ _).symm\n\nlemma neg {f : E \u2192 F} (hf : is_bounded_linear_map k f) : is_bounded_linear_map k (\u03bb e, -f e) :=\nbegin\n  rw show (\u03bb e, -f e) = (\u03bb e, (-1 : k) \u2022 f e), { funext, simp },\n  exact smul (-1) hf\nend\n\nlemma add {f : E \u2192 F} {g : E \u2192 F} :\n  is_bounded_linear_map k f \u2192 is_bounded_linear_map k g \u2192 is_bounded_linear_map k (\u03bb e, f e + g e)\n| \u27e8hlf, Mf, hMf, hf\u27e9  \u27e8hlg, Mg, hMg, hg\u27e9 := (hlf.mk' _ + hlg.mk' _).is_linear.with_bound (Mf + Mg) $ assume x,\n  calc \u2225f x + g x\u2225 \u2264 \u2225f x\u2225 + \u2225g x\u2225 : norm_triangle _ _\n    ... \u2264 Mf * \u2225x\u2225 + Mg * \u2225x\u2225 : add_le_add (hf x) (hg x)\n    ... \u2264 (Mf + Mg) * \u2225x\u2225 : by rw add_mul\n\nlemma sub {f : E \u2192 F} {g : E \u2192 F} (hf : is_bounded_linear_map k f) (hg : is_bounded_linear_map k g) :\n  is_bounded_linear_map k (\u03bb e, f e - g e) := add hf (neg hg)\n\nlemma comp {f : E \u2192 F} {g : F \u2192 G} :\n  is_bounded_linear_map k g \u2192 is_bounded_linear_map k f \u2192 is_bounded_linear_map k (g \u2218 f)\n| \u27e8hlg, Mg, hMg, hg\u27e9 \u27e8hlf, Mf, hMf, hf\u27e9 := ((hlg.mk' _).comp (hlf.mk' _)).is_linear.with_bound (Mg * Mf) $ assume x,\n  calc \u2225g (f x)\u2225 \u2264 Mg * \u2225f x\u2225 : hg _\n    ... \u2264 Mg * (Mf * \u2225x\u2225) : mul_le_mul_of_nonneg_left (hf _) (le_of_lt hMg)\n    ... = Mg * Mf * \u2225x\u2225 : (mul_assoc _ _ _).symm\n\nlemma tendsto {L : E \u2192 F} (x : E) : is_bounded_linear_map k L \u2192 L \u2192_{x} (L x)\n| \u27e8hL, M, hM, h_ineq\u27e9 := tendsto_iff_norm_tendsto_zero.2 $\n  squeeze_zero (assume e, norm_nonneg _)\n    (assume e, calc \u2225L e - L x\u2225 = \u2225hL.mk' L (e - x)\u2225 : by rw (hL.mk' _).map_sub e x; refl\n      ... \u2264 M*\u2225e-x\u2225 : h_ineq (e-x))\n    (suffices (\u03bb (e : E), M * \u2225e - x\u2225) \u2192_{x} (M * 0), by simpa,\n      tendsto_mul tendsto_const_nhds (lim_norm _))\n\nlemma continuous {L : E \u2192 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 \u2192 F} (H : is_bounded_linear_map k L) : (L \u2192_{0} 0) :=\n(H.1.mk' _).map_zero \u25b8 continuous_iff_continuous_at.1 H.continuous 0\n\nsection\nopen asymptotics filter\n\ntheorem is_O_id {L : E \u2192 F} (h : is_bounded_linear_map k L) (l : filter E) :\n  is_O L (\u03bb x, x) l :=\nlet \u27e8M, Mpos, hM\u27e9 := h.bound in\n\u27e8M, Mpos, mem_sets_of_superset univ_mem_sets (\u03bb x _, hM x)\u27e9\n\ntheorem is_O_comp {L : F \u2192 G} (h : is_bounded_linear_map k L)\n  {f : E \u2192 F} (l : filter E) : is_O (\u03bb x', L (f x')) f l :=\n((h.is_O_id \u22a4).comp _).mono (map_le_iff_le_comap.mp lattice.le_top)\n\ntheorem is_O_sub {L : E \u2192 F} (h : is_bounded_linear_map k L) (l : filter E) (x : E) :\n  is_O (\u03bb x', L (x' - x)) (\u03bb 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 \u211d\nlemma bounded_continuous_linear_map\n  {E : Type*} [normed_space \u211d E] {F : Type*} [normed_space \u211d F] {L : E \u2192 F}\n  (lin : is_linear_map \u211d L) (cont : continuous L) : is_bounded_linear_map \u211d L :=\nlet \u27e8\u03b4, \u03b4_pos, h\u03b4\u27e9 := exists_delta_of_continuous cont zero_lt_one 0 in\nhave HL0 : L 0 = 0, from (lin.mk' _).map_zero,\nhave H : \u2200{a}, \u2225a\u2225 \u2264 \u03b4 \u2192 \u2225L a\u2225 < 1, by simpa only [HL0, dist_zero_right] using h\u03b4,\nlin.with_bound (\u03b4\u207b\u00b9) $ assume x,\nclassical.by_cases (assume : x = 0, by simp only [this, HL0, norm_zero, mul_zero]) $\nassume h : x \u2260 0,\nlet p := \u2225x\u2225 * \u03b4\u207b\u00b9, q := p\u207b\u00b9 in\nhave p_inv : p\u207b\u00b9 = \u03b4*\u2225x\u2225\u207b\u00b9, by simp,\n\nhave norm_x_pos : \u2225x\u2225 > 0 := (norm_pos_iff x).2 h,\nhave norm_x : \u2225x\u2225 \u2260 0 := mt (norm_eq_zero x).1 h,\n\nhave p_pos : p > 0 := mul_pos norm_x_pos (inv_pos \u03b4_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 \u2225p\u207b\u00b9 \u2022 x\u2225 = \u03b4 := calc\n  \u2225p\u207b\u00b9 \u2022 x\u2225 = abs p\u207b\u00b9 * \u2225x\u2225 : by rw norm_smul; refl\n  ... = p\u207b\u00b9 * \u2225x\u2225 : by rw [abs_of_nonneg $ le_of_lt q_pos]\n  ... = \u03b4 : by simp [mul_assoc, inv_mul_cancel norm_x],\n\ncalc \u2225L x\u2225 = (p * q) * \u2225L x\u2225 : begin dsimp [q], rw [mul_inv_cancel p0, one_mul] end\n  ... = p * \u2225L (q \u2022 x)\u2225 : by simp [lin.smul, norm_smul, real.norm_eq_abs, abs_of_pos q_pos, mul_assoc]\n  ... \u2264 p * 1 : mul_le_mul_of_nonneg_left (le_of_lt $ H $ le_of_eq $ this) (le_of_lt p_pos)\n  ... = \u03b4\u207b\u00b9 * \u2225x\u2225 : 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    {\u2102\u2081 \u2102\u2082 : Fam.Cat}\n    (F : Fam.Cat.Func \u2102\u2081 \u2102\u2082)\n\n  theorem Fam.Cat.Func.proper_inv\n    {\u03b1 \u03b2 : \u2102\u2081.Obj}\n    {f\u2081 : \u03b1 \u21a0 \u03b2}\n    {f\u2082 : \u03b2 \u21a0 \u03b1}\n    (h : f\u2081 \u229a f\u2082 \u2248 \u2102\u2081.id)\n  : (F.fMap f\u2081) \u229a (F.fMap f\u2082) \u2248 F.id :=\n    let f\u2081' :=\n      F.fMap f\u2081\n    let f\u2082' :=\n      F.fMap f\u2082\n    let h\u2081 : f\u2081' \u229a f\u2082' \u2248 F.fMap (f\u2081 \u229a f\u2082) :=\n      F.comp_law f\u2081 f\u2082\n      |> Setoid.symm\n    let h\u2082 : f\u2081' \u229a f\u2082' \u2248 F.fMap \u2102\u2081.id :=\n      F.fmap_proper h\n      |> Setoid.trans h\u2081\n    let h\u2083 : f\u2081' \u229a f\u2082' \u2248 \u2102\u2082.id :=\n      F.id_law' \u03b2\n      |> Setoid.trans h\u2082\n    h\u2083\n\n  /-- Functors preserve the *iso* property over arrows. -/\n  instance instIsoFuncIso\n    {F : Fam.Cat.Func \u2102\u2081 \u2102\u2082}\n    {\u03b1 \u03b2 : \u2102\u2081.Obj}\n    (f : \u03b1 \u21a0 \u03b2)\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    {\u03b1 \u03b2 : \u2102\u2081.Obj}\n    (h_iso : \u03b1 \u2245 \u03b2)\n  : F \u03b1 \u2245 F \u03b2 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    {\u2102\u2081 \u2102\u2082 : Fam.Cat}\n    (F : Fam.Cat.Func \u2102\u2081 \u2102\u2082)\n\n  /-- Proof that a functor is *faithful*, *i.e.* `F f \u2248 F g \u2192 f \u2248 g`. -/\n  class Fam.Cat.Func.Faithful\n    {\u2102\u2081 \u2102\u2082 : Cat}\n    (F : Func \u2102\u2081 \u2102\u2082)\n  where\n    /-- Faithfulness law. -/\n    law' :\n      \u2200 {\u03b1 \u03b2 : \u2102\u2081.Obj} (f g : \u03b1 \u21a0 \u03b2),\n        F.fmap f \u2248 F.fmap g \u2192 f \u2248 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    {\u03b1 \u03b2 : \u2102\u2081.Obj}\n    {f g : \u03b1 \u21a0 \u03b2}\n  : F.fmap f \u2248 F.fmap g \u2192 f \u2248 g :=\n    inst.law' f g\n\n  /-- Faithfulness is closed under functor composition. -/\n  instance instFaithfulFuncComp\n    (F\u2082\u2083 : Fam.Cat.Func \u2102\u2082 \u2102\u2083)\n    [inst\u2082\u2083 : Fam.Cat.Func.Faithful F\u2082\u2083]\n    (F\u2081\u2082 : Fam.Cat.Func \u2102\u2081 \u2102\u2082)\n    [inst\u2081\u2082 : Fam.Cat.Func.Faithful F\u2081\u2082]\n  : Fam.Cat.Func.Faithful (F\u2082\u2083 \u2299 F\u2081\u2082) where\n    law' {\u03b1 \u03b2} (f g) h :=\n      by\n        apply inst\u2081\u2082.law\n        apply inst\u2082\u2083.law\n        exact h\n\n\n\n  /-- Proof that a functor is *full*, *i.e.* any `h : F \u03b1 \u21a0 F \u03b2` has a preimage by `F.fmap`. -/\n  class Fam.Cat.Func.Full\n    {\u2102\u2081 \u2102\u2082 : Cat}\n    (F : Func \u2102\u2081 \u2102\u2082)\n  where\n    /-- Yields the preimage of `h` by `F.fmap`. -/\n    preimage\n      {\u03b1 \u03b2 : \u2102\u2081.Obj}\n      (h : F \u03b1 \u21a0 F \u03b2)\n    : \u03b1 \u21a0 \u03b2\n    /-- Proof that `h` and the image of its preimage are equivalent. -/\n    law'\n      {\u03b1 \u03b2 : \u2102\u2081.Obj}\n      (h : F \u03b1 \u21a0 F \u03b2)\n    : h \u2248 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    {\u03b1 \u03b2 : \u2102\u2081.Obj}\n    {h : F \u03b1 \u21a0 F \u03b2}\n  : h \u2248 F.fmap (inst.preimage h) :=\n    inst.law' h\n\n  /-- Fullness is closed under functor composition. -/\n  instance instFullFuncComp\n    (F\u2082\u2083 : Fam.Cat.Func \u2102\u2082 \u2102\u2083)\n    [inst\u2082\u2083 : Fam.Cat.Func.Full F\u2082\u2083]\n    (F\u2081\u2082 : Fam.Cat.Func \u2102\u2081 \u2102\u2082)\n    [inst\u2081\u2082 : Fam.Cat.Func.Full F\u2081\u2082]\n  : Fam.Cat.Func.Full (F\u2082\u2083 \u2299 F\u2081\u2082) where\n    preimage h :=\n      inst\u2082\u2083.preimage h\n      |> inst\u2081\u2082.preimage\n    law' g\u2083 :=\n      let g\u2082 :=\n        inst\u2082\u2083.preimage g\u2083\n      let g\u2081 :=\n        inst\u2081\u2082.preimage g\u2082\n      let h : g\u2083 \u2248 F\u2082\u2083.fmap g\u2082 :=\n        inst\u2082\u2083.law\n      let h' : g\u2082 \u2248 F\u2081\u2082.fmap g\u2081 :=\n        inst\u2081\u2082.law\n      let h : g\u2083 \u2248 F\u2082\u2083.fmap (F\u2081\u2082.fmap g\u2081) :=\n        F\u2082\u2083.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 \u27f6 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 \u27f6 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 : \u03a0 X Y : C, module R (X \u27f6 Y) . tactic.apply_instance)\n(smul_comp' : \u2200 (X Y Z : C) (r : R) (f : X \u27f6 Y) (g : Y \u27f6 Z),\n  (r \u2022 f) \u226b g = r \u2022 (f \u226b g) . obviously)\n(comp_smul' : \u2200 (X Y Z : C) (f : X \u27f6 Y) (r : R) (g : Y \u27f6 Z),\n  f \u226b (r \u2022 g) = r \u2022 (f \u226b 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 \u2115 C :=\n{ smul_comp' := \u03bb X Y Z r f g, (preadditive.right_comp X g).map_nsmul f r,\n  comp_smul' := \u03bb X Y Z f r g, (preadditive.left_comp Z f).map_nsmul g r, }\n\ninstance preadditive_int_linear : linear \u2124 C :=\n{ smul_comp' := \u03bb X Y Z r f g, (preadditive.right_comp X g).map_zsmul f r,\n  comp_smul' := \u03bb 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 (\u03bb r f g, comp_smul _ _ _ _ _ _) (\u03bb 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 \u2192 C)\n\ninstance induced_category : linear.{w v} R (induced_category C F) :=\n{ hom_module := \u03bb X Y, @linear.hom_module R _ C _ _ _ (F X) (F Y),\n  smul_comp' := \u03bb P Q R f f' g, smul_comp' _ _ _ _ _ _,\n  comp_smul' := \u03bb P Q R f g g', comp_smul' _ _ _ _ _ _, }\n\nend induced_category\n\ninstance full_subcategory (Z : C \u2192 Prop) : linear.{w v} R (full_subcategory Z) :=\n{ hom_module := \u03bb X Y, @linear.hom_module R _ C _ _ _ X.obj Y.obj,\n  smul_comp' := \u03bb P Q R f f' g, smul_comp' _ _ _ _ _ _,\n  comp_smul' := \u03bb 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 \u27f6 Y) : (Y \u27f6 Z) \u2192\u2097[R] (X \u27f6 Z) :=\n{ to_fun := \u03bb g, f \u226b 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 \u27f6 Z) : (X \u27f6 Y) \u2192\u2097[R] (X \u27f6 Z) :=\n{ to_fun := \u03bb f, f \u226b g,\n  map_add' := by simp,\n  map_smul' := by simp, }\n\ninstance {X Y : C} (f : X \u27f6 Y) [epi f] (r : R) [invertible r] : epi (r \u2022 f) :=\n\u27e8\u03bb R g g' H, begin\n  rw [smul_comp, smul_comp, \u2190comp_smul, \u2190comp_smul, cancel_epi] at H,\n  simpa [smul_smul] using congr_arg (\u03bb f, \u215fr \u2022 f) H,\nend\u27e9\n\ninstance {X Y : C} (f : X \u27f6 Y) [mono f] (r : R) [invertible r] : mono (r \u2022 f) :=\n\u27e8\u03bb R g g' H, begin\n  rw [comp_smul, comp_smul, \u2190smul_comp, \u2190smul_comp, cancel_mono] at H,\n  simpa [smul_smul] using congr_arg (\u03bb f, \u215fr \u2022 f) H,\nend\u27e9\n\n/-- Given isomorphic objects `X \u2245 Y, W \u2245 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\u2081 : X \u2245 Y) (f\u2082 : W \u2245 Z) :\n  (X \u27f6 W) \u2243\u2097[k] (Y \u27f6 Z) :=\n{ inv_fun := (left_comp k W f\u2081.hom).comp (right_comp k Y f\u2082.symm.hom),\n  left_inv := \u03bb 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 := \u03bb 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\u2082.hom).comp (left_comp k W f\u2081.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\u2081 : X \u2245 Y) (f\u2082 : W \u2245 Z) (f : X \u27f6 W) :\n  hom_congr k f\u2081 f\u2082 f = (f\u2081.inv \u226b f) \u226b f\u2082.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\u2081 : X \u2245 Y) (f\u2082 : W \u2245 Z) (f : Y \u27f6 Z) :\n  (hom_congr k f\u2081 f\u2082).symm f = f\u2081.hom \u226b f \u226b f\u2082.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 \u27f6 Y) \u2192\u2097[S] ((Y \u27f6 Z) \u2192\u2097[S] (X \u27f6 Z)) :=\n{ to_fun := \u03bb 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 \u2227 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 \u2208+ l` notation is shorthand for `List.Duplicate x l`.\n\n-/\n\n\nvariable {\u03b1 : Type _}\n\nnamespace List\n\n/-- Property that an element `x : \u03b1` of `l : list \u03b1` can be found in the list more than once. -/\ninductive Duplicate (x : \u03b1) : List \u03b1 \u2192 Prop\n  | cons_mem {l : List \u03b1} : x \u2208 l \u2192 Duplicate x (x :: l)\n  | cons_duplicate {y : \u03b1} {l : List \u03b1} : Duplicate x l \u2192 Duplicate x (y :: l)\n#align list.duplicate List.Duplicate\n\n-- mathport name: \u00abexpr \u2208+ \u00bb\nlocal infixl:50 \" \u2208+ \" => List.Duplicate\n\nvariable {l : List \u03b1} {x : \u03b1}\n\ntheorem Mem.duplicate_cons_self (h : x \u2208 l) : x \u2208+ 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 \u2208+ l) (y : \u03b1) : x \u2208+ y :: l :=\n  Duplicate.cons_duplicate h\n#align list.duplicate.duplicate_cons List.Duplicate.duplicate_cons\n\ntheorem Duplicate.mem (h : x \u2208+ l) : x \u2208 l := by\n  induction' h with l' _ y l' _ hm\n  \u00b7 exact mem_cons_self _ _\n  \u00b7 exact mem_cons_of_mem _ hm\n#align list.duplicate.mem List.Duplicate.mem\n\ntheorem Duplicate.mem_cons_self (h : x \u2208+ x :: l) : x \u2208 l := by\n  cases' h with _ h _ _ h\n  \u00b7 exact h\n  \u00b7 exact h.mem\n#align list.duplicate.mem_cons_self List.Duplicate.mem_cons_self\n\n@[simp]\ntheorem duplicate_cons_self_iff : x \u2208+ x :: l \u2194 x \u2208 l :=\n  \u27e8Duplicate.mem_cons_self, Mem.duplicate_cons_self\u27e9\n#align list.duplicate_cons_self_iff List.duplicate_cons_self_iff\n\ntheorem Duplicate.ne_nil (h : x \u2208+ l) : l \u2260 [] := fun H => (mem_nil_iff x).mp (H \u25b8 h.mem)\n#align list.duplicate.ne_nil List.Duplicate.ne_nil\n\n@[simp]\ntheorem not_duplicate_nil (x : \u03b1) : \u00acx \u2208+ [] := fun H => H.ne_nil rfl\n#align list.not_duplicate_nil List.not_duplicate_nil\n\ntheorem Duplicate.ne_singleton (h : x \u2208+ l) (y : \u03b1) : l \u2260 [y] := by\n  induction' h with l' h z l' h _\n  \u00b7 simp [ne_nil_of_mem h]\n  \u00b7 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 \u2208+ []) : False :=\n  not_duplicate_nil x h\n#align list.duplicate.elim_nil List.Duplicate.elim_nil\n\ntheorem Duplicate.elim_singleton {y : \u03b1} (h : x \u2208+ [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 : \u03b1} : x \u2208+ y :: l \u2194 y = x \u2227 x \u2208 l \u2228 x \u2208+ l := by\n  refine' \u27e8fun h => _, fun h => _\u27e9\n  \u00b7 cases' h with _ hm _ _ hm\n    \u00b7 exact Or.inl \u27e8rfl, hm\u27e9\n    \u00b7 exact Or.inr hm\n  \u00b7 rcases h with (\u27e8rfl | h\u27e9 | h)\n    \u00b7 simpa\n    \u00b7 exact h.cons_duplicate\n#align list.duplicate_cons_iff List.duplicate_cons_iff\n\ntheorem Duplicate.of_duplicate_cons {y : \u03b1} (h : x \u2208+ y :: l) (hx : x \u2260 y) : x \u2208+ 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 : \u03b1} (hne : x \u2260 y) : x \u2208+ y :: l \u2194 x \u2208+ 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 \u03b1} (hx : x \u2208+ l) (h : l <+ l') : x \u2208+ l' := by\n  induction' h with l\u2081 l\u2082 y _ IH l\u2081 l\u2082 y h IH\n  \u00b7 exact hx\n  \u00b7 exact (IH hx).duplicate_cons _\n  \u00b7 rw [duplicate_cons_iff] at hx\u22a2\n    rcases hx with (\u27e8rfl, hx\u27e9 | hx)\n    \u00b7 simp [h.subset hx]\n    \u00b7 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 \u2208+ l \u2194 [x, x] <+ l := by\n  induction' l with y l IH\n  \u00b7 simp\n  \u00b7 by_cases hx : x = y\n    \u00b7 simp [hx, cons_sublist_cons_iff, singleton_sublist]\n    \u00b7 rw [duplicate_cons_iff_of_ne hx, IH]\n      refine' \u27e8sublist_cons_of_sublist y, fun h => _\u27e9\n      cases h\n      \u00b7 assumption\n      \u00b7 contradiction\n#align list.duplicate_iff_sublist List.duplicate_iff_sublist\n\ntheorem nodup_iff_forall_not_duplicate : Nodup l \u2194 \u2200 x : \u03b1, \u00acx \u2208+ 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 : (\u2203 x : \u03b1, x \u2208+ l) \u2194 \u00acNodup 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 \u2208+ l) : \u00acNodup 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 \u03b1] : x \u2208+ l \u2194 2 \u2264 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 \u03b1] (x : \u03b1) : \u2200 l : List \u03b1, Decidable (x \u2208+ 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 \u2227 x \u2208 l then isTrue (hx.left.symm \u25b8 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 \ud835\udc9c`, for working with an algebra `A` that is\ninternally graded by a collection of submodules `\ud835\udc9c : \u03b9 \u2192 submodule R A`.\nSee the docstring of that typeclass for more information.\n\n## Main definitions\n\n* `graded_ring \ud835\udc9c`: the typeclass, which is a combination of `set_like.graded_monoid`, and\n  `direct_sum.decomposition \ud835\udc9c`.\n* `graded_algebra \ud835\udc9c`: A convenience alias for `graded_ring` when `\ud835\udc9c` is a family of submodules.\n* `direct_sum.decompose_ring_equiv \ud835\udc9c : A \u2243\u2090[R] \u2a01 i, \ud835\udc9c i`, a more bundled version of\n  `direct_sum.decompose \ud835\udc9c`.\n* `direct_sum.decompose_alg_equiv \ud835\udc9c : A \u2243\u2090[R] \u2a01 i, \ud835\udc9c i`, a more bundled version of\n  `direct_sum.decompose \ud835\udc9c`.\n* `graded_algebra.proj \ud835\udc9c i` is the linear map from `A` to its degree `i : \u03b9` component, such that\n  `proj \ud835\udc9c i x = decompose \ud835\udc9c 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 `\ud835\udc9c : \u03b9 \u2192 submodule \u2115 A` and `\ud835\udc9c : \u03b9 \u2192 submodule \u2124 A` respectively, since all\n`semiring`s are \u2115-algebras via `algebra_nat`, and all `ring`s are `\u2124`-algebras via `algebra_int`.\n\n## Tags\n\ngraded algebra, graded ring, graded semiring, decomposition\n-/\n\n\nopen DirectSum BigOperators\n\nvariable {\u03b9 R A \u03c3 : Type _}\n\nsection GradedRing\n\nvariable [DecidableEq \u03b9] [AddMonoid \u03b9] [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable [SetLike \u03c3 A] [AddSubmonoidClass \u03c3 A] (\ud835\udc9c : \u03b9 \u2192 \u03c3)\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 `\u03b9` such that the canonical map `A \u2192 \u2a01 i, \ud835\udc9c 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 \ud835\udc9c`, implies an externally-graded\nalgebra structure `direct_sum.galgebra R (\u03bb i, \u21a5(\ud835\udc9c i))`, which in turn makes available an\n`algebra R (\u2a01 i, \ud835\udc9c i)` instance.\n-/\nclass GradedRing (\ud835\udc9c : \u03b9 \u2192 \u03c3) extends SetLike.GradedMonoid \ud835\udc9c, DirectSum.Decomposition \ud835\udc9c\n#align graded_ring GradedRing\n\nvariable [GradedRing \ud835\udc9c]\n\nnamespace DirectSum\n\n/-- If `A` is graded by `\u03b9` with degree `i` component `\ud835\udc9c i`, then it is isomorphic as\na ring to a direct sum of components. -/\ndef decomposeRingEquiv : A \u2243+* \u2a01 i, \ud835\udc9c i :=\n  RingEquiv.symm\n    {\n      (decomposeAddEquiv \ud835\udc9c).symm with\n      map_mul' := (coeRingHom \ud835\udc9c).map_mul\n      map_add' := (coeRingHom \ud835\udc9c).map_add }\n#align direct_sum.decompose_ring_equiv DirectSum.decomposeRingEquiv\n\n@[simp]\ntheorem decompose_one : decompose \ud835\udc9c (1 : A) = 1 :=\n  map_one (decomposeRingEquiv \ud835\udc9c)\n#align direct_sum.decompose_one DirectSum.decompose_one\n\n@[simp]\ntheorem decompose_symm_one : (decompose \ud835\udc9c).symm 1 = (1 : A) :=\n  map_one (decomposeRingEquiv \ud835\udc9c).symm\n#align direct_sum.decompose_symm_one DirectSum.decompose_symm_one\n\n@[simp]\ntheorem decompose_mul (x y : A) : decompose \ud835\udc9c (x * y) = decompose \ud835\udc9c x * decompose \ud835\udc9c y :=\n  map_mul (decomposeRingEquiv \ud835\udc9c) x y\n#align direct_sum.decompose_mul DirectSum.decompose_mul\n\n@[simp]\ntheorem decompose_symm_mul (x y : \u2a01 i, \ud835\udc9c i) :\n    (decompose \ud835\udc9c).symm (x * y) = (decompose \ud835\udc9c).symm x * (decompose \ud835\udc9c).symm y :=\n  map_mul (decomposeRingEquiv \ud835\udc9c).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 : \u03b9) : A \u2192+ A :=\n  (AddSubmonoidClass.Subtype (\ud835\udc9c i)).comp <|\n    (Dfinsupp.evalAddMonoidHom i).comp <|\n      RingHom.toAddMonoidHom <| RingEquiv.toRingHom <| DirectSum.decomposeRingEquiv \ud835\udc9c\n#align graded_ring.proj GradedRing.proj\n\n@[simp]\ntheorem GradedRing.proj_apply (i : \u03b9) (r : A) :\n    GradedRing.proj \ud835\udc9c i r = (decompose \ud835\udc9c r : \u2a01 i, \ud835\udc9c i) i :=\n  rfl\n#align graded_ring.proj_apply GradedRing.proj_apply\n\ntheorem GradedRing.proj_recompose (a : \u2a01 i, \ud835\udc9c i) (i : \u03b9) :\n    GradedRing.proj \ud835\udc9c i ((decompose \ud835\udc9c).symm a) = (decompose \ud835\udc9c).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 [\u2200 (i) (x : \ud835\udc9c i), Decidable (x \u2260 0)] (r : A) (i : \u03b9) :\n    i \u2208 (decompose \ud835\udc9c r).support \u2194 GradedRing.proj \ud835\udc9c i r \u2260 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 \u03b9] [Semiring A] [SetLike \u03c3 A] [AddSubmonoidClass \u03c3 A] (\ud835\udc9c : \u03b9 \u2192 \u03c3)\n\nvariable {i j : \u03b9}\n\nnamespace DirectSum\n\ntheorem coe_decompose_mul_add_of_left_mem [AddLeftCancelMonoid \u03b9] [GradedRing \ud835\udc9c] {a b : A}\n    (a_mem : a \u2208 \ud835\udc9c i) : (decompose \ud835\udc9c (a * b) (i + j) : A) = a * decompose \ud835\udc9c b j :=\n  by\n  lift a to \ud835\udc9c 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 \u03b9] [GradedRing \ud835\udc9c] {a b : A}\n    (b_mem : b \u2208 \ud835\udc9c j) : (decompose \ud835\udc9c (a * b) (i + j) : A) = decompose \ud835\udc9c a i * b :=\n  by\n  lift b to \ud835\udc9c 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 \u03b9] [GradedRing \ud835\udc9c] (a : \ud835\udc9c i) {b : A} :\n    decompose \ud835\udc9c (\u2191a * b) (i + j) =\n      @GradedMonoid.GMul.mul \u03b9 (fun i => \ud835\udc9c i) _ _ _ _ a (decompose \ud835\udc9c b j) :=\n  Subtype.ext <| coe_decompose_mul_add_of_left_mem \ud835\udc9c a.2\n#align direct_sum.decompose_mul_add_left DirectSum.decompose_mul_add_left\n\ntheorem decompose_mul_add_right [AddRightCancelMonoid \u03b9] [GradedRing \ud835\udc9c] {a : A} (b : \ud835\udc9c j) :\n    decompose \ud835\udc9c (a * \u2191b) (i + j) =\n      @GradedMonoid.GMul.mul \u03b9 (fun i => \ud835\udc9c i) _ _ _ _ (decompose \ud835\udc9c a i) b :=\n  Subtype.ext <| coe_decompose_mul_add_of_right_mem \ud835\udc9c 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 \u03b9] [AddMonoid \u03b9] [CommSemiring R] [Semiring A] [Algebra R A]\n\nvariable (\ud835\udc9c : \u03b9 \u2192 Submodule R A)\n\n/-- A special case of `graded_ring` with `\u03c3 = 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 \ud835\udc9c\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 \ud835\udc9c] (decompose : A \u2192\u2090[R] \u2a01 i, \ud835\udc9c i)\n    (right_inv : (DirectSum.coeAlgHom \ud835\udc9c).comp decompose = AlgHom.id R A)\n    (left_inv : \u2200 (i) (x : \ud835\udc9c i), decompose (x : A) = DirectSum.of (fun i => \u21a5(\ud835\udc9c i)) i x) :\n    GradedAlgebra \ud835\udc9c where\n  decompose' := decompose\n  left_inv := AlgHom.congr_fun right_inv\n  right_inv := by\n    suffices : decompose.comp (DirectSum.coeAlgHom \ud835\udc9c) = 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 \ud835\udc9c]\n\nnamespace DirectSum\n\n/-- If `A` is graded by `\u03b9` with degree `i` component `\ud835\udc9c i`, then it is isomorphic as\nan algebra to a direct sum of components. -/\n@[simps]\ndef decomposeAlgEquiv : A \u2243\u2090[R] \u2a01 i, \ud835\udc9c i :=\n  AlgEquiv.symm\n    { (decomposeAddEquiv \ud835\udc9c).symm with\n      map_mul' := (coeAlgHom \ud835\udc9c).map_mul\n      map_add' := (coeAlgHom \ud835\udc9c).map_add\n      commutes' := (coeAlgHom \ud835\udc9c).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 (\ud835\udc9c : \u03b9 \u2192 Submodule R A) [GradedAlgebra \ud835\udc9c] (i : \u03b9) : A \u2192\u2097[R] A :=\n  (\ud835\udc9c i).Subtype.comp <| (Dfinsupp.lapply i).comp <| (decomposeAlgEquiv \ud835\udc9c).toAlgHom.toLinearMap\n#align graded_algebra.proj GradedAlgebra.proj\n\n@[simp]\ntheorem GradedAlgebra.proj_apply (i : \u03b9) (r : A) :\n    GradedAlgebra.proj \ud835\udc9c i r = (decompose \ud835\udc9c r : \u2a01 i, \ud835\udc9c i) i :=\n  rfl\n#align graded_algebra.proj_apply GradedAlgebra.proj_apply\n\ntheorem GradedAlgebra.proj_recompose (a : \u2a01 i, \ud835\udc9c i) (i : \u03b9) :\n    GradedAlgebra.proj \ud835\udc9c i ((decompose \ud835\udc9c).symm a) = (decompose \ud835\udc9c).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 : \u03b9) :\n    i \u2208 (decompose \ud835\udc9c r).support \u2194 GradedAlgebra.proj \ud835\udc9c i r \u2260 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 \u03b9]\n\nvariable [CanonicallyOrderedAddMonoid \u03b9]\n\nvariable [SetLike \u03c3 A] [AddSubmonoidClass \u03c3 A] (\ud835\udc9c : \u03b9 \u2192 \u03c3) [GradedRing \ud835\udc9c]\n\n/-- If `A` is graded by a canonically ordered add monoid, then the projection map `x \u21a6 x\u2080` is a ring\nhomomorphism.\n-/\n@[simps]\ndef GradedRing.projZeroRingHom : A \u2192+* A\n    where\n  toFun a := decompose \ud835\udc9c a 0\n  map_one' := decompose_of_mem_same \ud835\udc9c 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 \ud835\udc9c (fun x => _) _ _\n    \u00b7 simp only [MulZeroClass.zero_mul, decompose_zero, zero_apply, ZeroMemClass.coe_zero]\n    \u00b7 rintro i \u27e8c, hc\u27e9\n      refine' DirectSum.Decomposition.inductionOn \ud835\udc9c _ _ _\n      \u00b7 simp only [MulZeroClass.mul_zero, decompose_zero, zero_apply, ZeroMemClass.coe_zero]\n      \u00b7 rintro j \u27e8c', hc'\u27e9\n        \u00b7 simp only [Subtype.coe_mk]\n          by_cases h : i + j = 0\n          \u00b7\n            rw [decompose_of_mem_same \ud835\udc9c (show c * c' \u2208 \ud835\udc9c 0 from h \u25b8 mul_mem hc hc'),\n              decompose_of_mem_same \ud835\udc9c (show c \u2208 \ud835\udc9c 0 from (add_eq_zero_iff.mp h).1 \u25b8 hc),\n              decompose_of_mem_same \ud835\udc9c (show c' \u2208 \ud835\udc9c 0 from (add_eq_zero_iff.mp h).2 \u25b8 hc')]\n          \u00b7 rw [decompose_of_mem_ne \ud835\udc9c (mul_mem hc hc') h]\n            cases' show i \u2260 0 \u2228 j \u2260 0 by rwa [add_eq_zero_iff, not_and_or] at h with h' h'\n            \u00b7 simp only [decompose_of_mem_ne \ud835\udc9c hc h', MulZeroClass.zero_mul]\n            \u00b7 simp only [decompose_of_mem_ne \ud835\udc9c hc' h', MulZeroClass.mul_zero]\n      \u00b7 intro _ _ hd he\n        simp only [mul_add, decompose_add, add_apply, AddMemClass.coe_add, hd, he]\n    \u00b7 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 : \u03b9}\n\nnamespace DirectSum\n\ntheorem coe_decompose_mul_of_left_mem_of_not_le (a_mem : a \u2208 \ud835\udc9c i) (h : \u00aci \u2264 n) :\n    (decompose \ud835\udc9c (a * b) n : A) = 0 :=\n  by\n  lift a to \ud835\udc9c 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 \u2208 \ud835\udc9c i) (h : \u00aci \u2264 n) :\n    (decompose \ud835\udc9c (a * b) n : A) = 0 :=\n  by\n  lift b to \ud835\udc9c 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 \u03b9] [OrderedSub \u03b9] [ContravariantClass \u03b9 \u03b9 (\u00b7 + \u00b7) (\u00b7 \u2264 \u00b7)]\n\ntheorem coe_decompose_mul_of_left_mem_of_le (a_mem : a \u2208 \ud835\udc9c i) (h : i \u2264 n) :\n    (decompose \ud835\udc9c (a * b) n : A) = a * decompose \ud835\udc9c b (n - i) :=\n  by\n  lift a to \ud835\udc9c 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 \u2208 \ud835\udc9c i) (h : i \u2264 n) :\n    (decompose \ud835\udc9c (a * b) n : A) = decompose \ud835\udc9c a (n - i) * b :=\n  by\n  lift b to \ud835\udc9c 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 \u2264 n)] (a_mem : a \u2208 \ud835\udc9c i) :\n    (decompose \ud835\udc9c (a * b) n : A) = if i \u2264 n then a * decompose \ud835\udc9c b (n - i) else 0 :=\n  by\n  lift a to \ud835\udc9c 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 \u2264 n)] (b_mem : b \u2208 \ud835\udc9c i) :\n    (decompose \ud835\udc9c (a * b) n : A) = if i \u2264 n then decompose \ud835\udc9c a (n - i) * b else 0 :=\n  by\n  lift b to \ud835\udc9c 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 := \u03bb 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}) := \u27e8X.presheaf, X.is_sheaf\u27e9\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)) := \u27e8punit (Top.of pempty)\u27e9\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) \u2964 (PresheafedSpace C) :=\ninduced_functor _\n\nvariables {C}\n\nsection\nlocal attribute [simp] id comp\n\n@[simp] lemma id_base (X : SheafedSpace C) :\n  ((\ud835\udfd9 X) : X \u27f6 X).base = (\ud835\udfd9 (X : Top.{v})) := rfl\n\nlemma id_c (X : SheafedSpace C) :\n  ((\ud835\udfd9 X) : X \u27f6 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  ((\ud835\udfd9 X) : X \u27f6 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 \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g).base = f.base \u226b g.base := rfl\n\n@[simp] lemma comp_c_app {X Y Z : SheafedSpace C} (\u03b1 : X \u27f6 Y) (\u03b2 : Y \u27f6 Z) (U) :\n  (\u03b1 \u226b \u03b2).c.app U = (\u03b2.c).app U \u226b (\u03b1.c).app (op ((opens.map (\u03b2.base)).obj (unop U)))\n:= rfl\n\nvariables (C)\n\n/-- The forgetful functor from `SheafedSpace` to `Top`. -/\ndef forget : SheafedSpace C \u2964 Top :=\n{ obj := \u03bb X, (X : Top.{v}),\n  map := \u03bb 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 \u27f6 (X : Top.{v})} (h : open_embedding f) : SheafedSpace C :=\n{ is_sheaf := \u03bb \u03b9 \ud835\udcb0, \u27e8is_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 \ud835\udcb0).symm\u27e9,\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 \u22a4) \u2245 X :=\n@preimage_iso _ _ _ _ forget_to_PresheafedSpace _ _\n  (X.restrict (opens.open_embedding \u22a4)) _\n  X.to_PresheafedSpace.restrict_top_iso\n\n/--\nThe global sections, notated Gamma.\n-/\ndef \u0393 : (SheafedSpace C)\u1d52\u1d56 \u2964 C :=\nforget_to_PresheafedSpace.op \u22d9 PresheafedSpace.\u0393\n\nlemma \u0393_def : (\u0393 : _ \u2964 C) = forget_to_PresheafedSpace.op \u22d9 PresheafedSpace.\u0393 := rfl\n\n@[simp] \n\nlemma \u0393_obj_op (X : SheafedSpace C) : \u0393.obj (op X) = X.presheaf.obj (op \u22a4) := rfl\n\n@[simp] lemma \u0393_map {X Y : (SheafedSpace C)\u1d52\u1d56} (f : X \u27f6 Y) :\n  \u0393.map f = f.unop.c.app (op \u22a4) := rfl\n\nlemma \u0393_map_op {X Y : SheafedSpace C} (f : X \u27f6 Y) :\n  \u0393.map f.op = f.c.app (op \u22a4) := rfl\n\nnoncomputable\ninstance [has_limits C] : creates_colimits (forget_to_PresheafedSpace : SheafedSpace C \u2964 _) :=\n\u27e8\u03bb J hJ, by exactI \u27e8\u03bb K, creates_colimit_of_fully_faithful_of_iso\n  \u27e8(PresheafedSpace.colimit_cocone (K \u22d9 forget_to_PresheafedSpace)).X,\n    limit_is_sheaf _ (\u03bb j, sheaf.pushforward_sheaf_of_sheaf _ (K.obj (unop j)).2)\u27e9\n  (colimit.iso_colimit_cocone \u27e8_, PresheafedSpace.colimit_cocone_is_colimit _\u27e9).symm\u27e9\u27e9\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` (`\u21d2`, `\\r=`). -/\nstructure Morph.{ua, ub}\n  (\u03b1 : Setoid.{ua})\n  (\u03b2 : Setoid.{ub})\n: Type (max ua ub) where\n\n  /-- Maps values from `\u03b1`'s carrier to values of `\u03b2`'s carrier. -/\n  map : |\u03b1| \u2192 |\u03b2|\n\n  /-- `map` is proper for setoid equivalence (`\u2248`). -/\n  proper {a\u2081 a\u2082 : |\u03b1|} :\n    a\u2081 \u2248 a\u2082 \u2192 map a\u2081 \u2248 map a\u2082\n\ninfixr:3 \" \u21d2 \" =>\n  Morph\n\n\n\nsection Morph\n\n  universe u_\u03b1 u_\u03b2\n\n  variable\n    {\u03b1 : Setoid.{u_\u03b1}}\n    {\u03b2 : Setoid.{u_\u03b2}}\n\n  /-- Domain accessor. -/\n  def Morph.dom\n    (_ : \u03b1 \u21d2 \u03b2)\n  : Setoid.{u_\u03b1} :=\n    \u03b1\n  /-- Codomain accessor. -/\n  def Morph.cod\n    (_ : \u03b1 \u21d2 \u03b2)\n  : Setoid.{u_\u03b2} :=\n    \u03b2\n\n  /-- Applies the underlying function. -/\n  def Morph.app\n    (self : \u03b1 \u21d2 \u03b2)\n  : |\u03b1| \u2192 |\u03b2| :=\n    (self.map \u00b7)\n\n\n  /-! ## Equivalence relation on morphisms -/\n  section equiv\n\n    /-- Equivalence relation (extensional equality, `\u2248`, `\\~~`). -/\n    abbrev Morph.equiv\n      {\u03b1 \u03b2 : Setoid}\n      (f g : \u03b1 \u21d2 \u03b2)\n    : Prop :=\n      \u2200 (a : |\u03b1|), f.map a \u2248 g.map a\n\n    /-- Give access to `\u2248` (`\\~~`) equivalence notation. -/\n    instance instHasEquivMorph\n    : HasEquiv (\u03b1 \u21d2 \u03b2) where\n      Equiv :=\n        Morph.equiv\n\n    /-- `Morph.equiv` is reflexive. -/\n    def Morph.equiv.refl\n      (m : \u03b1 \u21d2 \u03b2)\n    : m \u2248 m :=\n      (m.map \u00b7 |> \u03b2.refl)\n\n    /-- `Morph.equiv` is symmetric. -/\n    def Morph.equiv.symm\n      {f g : \u03b1 \u21d2 \u03b2}\n      (h : equiv f g)\n    : g \u2248 f :=\n      (h \u00b7 |> \u03b2.symm)\n\n    /-- `Morph.equiv` is transitive. -/\n    def Morph.equiv.trans\n      {f g h : \u03b1 \u21d2 \u03b2}\n      (eqFG : equiv f g)\n      (eqGH : equiv g h)\n    : f \u2248 h :=\n      fun a =>\n        \u03b2.trans (eqFG a) (eqGH a)\n\n    /-- `Morph.equiv` is an equivalence relation. -/\n    def Morph.equiv.iseqv\n    : @Equivalence (\u03b1 \u21d2 \u03b2) Morph.equiv :=\n      \u27e8refl, symm, trans\u27e9\n\n\n\n    def Morph.equiv.rewrite\n      {f g h : \u03b1 \u21d2 \u03b2}\n      (self : f \u2248 g)\n      (subgoal : f \u2248 h)\n    : g \u2248 h :=\n      self.symm.trans subgoal\n\n\n\n    instance instTransMorphTrans\n      {\u03b1 \u03b2 : Setoid}\n    : let I := @instHasEquivMorph \u03b1 \u03b2\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 (`\u2218M`). -/\n  def Morph.compose\n    (f : \u03b2 \u21d2 \u03b3)\n    (g : \u03b1 \u21d2 \u03b2)\n  : \u03b1 \u21d2 \u03b3 where\n    map :=\n      f.map \u2218 g.map\n    proper :=\n      f.proper \u2218 g.proper\n\n  infix:100 \" \u2218M \" =>\n    Morph.compose\n\n  /-- Morphism composition (`\u2218M`) is associative. -/\n  theorem Morph.compose.assoc\n    (f : \u03b3 \u21d2 \u03b4)\n    (g : \u03b2 \u21d2 \u03b3)\n    (h : \u03b1 \u21d2 \u03b2)\n  : f \u2218M (g \u2218M h) \u2248 (f \u2218M g) \u2218M h :=\n    fun a =>\n      by simp [compose, \u03b4.refl]\n\n  /-- Morphism composition (`\u2218M`) abides by congruence laws. -/\n  def Morph.compose.congr\n  : Congr (\u03b2 \u21d2 \u03b3) (\u03b1 \u21d2 \u03b2) (\u03b1 \u21d2 \u03b3) 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 (`\u2218m`). -/\n  def Morph.kompose\n    (f : \u03b2 \u21d2 \u03b3)\n    (g : \u03b1 \u21d2 \u03b2)\n  : |\u03b1| \u2192 |\u03b3| :=\n    (f.compose g).map\n\n  infix:100 \" \u2218m \" =>\n    Morph.kompose\n\n\n\n  /-- Identity morphism over an implicit erased setoid `\u03b1`. -/\n  protected def Morph.id\n    {\u03b1 : Setoid}\n  : \u03b1 \u21d2 \u03b1 where\n    map := id\n    proper := id\n\n  /-- Identity morphism over an explicit erased setoid `\u03b1`. -/\n  protected abbrev Morph.id'\n    (\u03b1 : Setoid)\n  : \u03b1 \u21d2 \u03b1 :=\n    @Morph.id \u03b1\n\n  /-- `Morph.id` is a left-identity for `\u2218M`. -/\n  theorem Morph.id_compose\n    (f : \u03b1 \u21d2 \u03b2)\n  : Morph.id \u2218M f \u2248 f :=\n    fun _a =>\n      \u03b2.refl _\n\n  /-- `Morph.id` is a right-identity for `\u2218M`. -/\n  theorem Morph.compose_id\n    (f : \u03b1 \u21d2 \u03b2)\n  : f \u2218M Morph.id \u2248 f :=\n    fun _a =>\n      \u03b2.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 (\u03b1 \u21d2 \u03b2) where\n      r :=\n        Morph.equiv\n      iseqv :=\n        Morph.equiv.iseqv\n\n    /-- Builds the `Setoid` for `\u03b1 \u21d2 \u03b2`, written `\u03b1 \u21db \u03b2` (`\\r==`).\n\n    Note that you should not need to write `|\u03b1 \u21db \u03b2|` since the carrier of `\u03b1 \u21db \u03b2` is simply `\u03b1 \u21d2 \u03b2`.\n    It is however sometimes more readable to write `|\u03b1 \u21db \u03b2 \u21db \u03b3|` for `\u03b1 \u21d2 \u03b2 \u21db \u03b3`.\n    -/\n    def Morph.mkSetoid\n      (\u03b1 : Setoid.{u_a})\n      (\u03b2 : Setoid.{u_b})\n    : Setoid where\n      Carrier :=\n        \u03b1 \u21d2 \u03b2\n      instZetoid :=\n        instZetoidMorph\n\n    infixr:4 \" \u21db \" =>\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    {\u03b3 : Setoid.{u_\u03b3}}\n    (self : \u03b1 \u21d2 \u03b2 \u21db \u03b3)\n    -- (self : |\u03b1 \u21db \u03b2 \u21db \u03b3|) -- alternatively, same as the above\n    (a : |\u03b1|)\n  : |\u03b2| \u2192 |\u03b3| :=\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 \u2192 Obj \u2192 Setoid}\n    (compose :\n      (\u03b1 \u03b2 \u03b3 : Obj) \u2192 |Hom \u03b2 \u03b3 \u21db Hom \u03b1 \u03b2 \u21db Hom \u03b1 \u03b3|)\n    {\u03b1 \u03b2 \u03b3 : outParam Obj}\n  : |Hom \u03b2 \u03b3| \u2192 |Hom \u03b1 \u03b2| \u2192 |Hom \u03b1 \u03b3| :=\n    compose \u03b1 \u03b2 \u03b3\n    |>.app2\n\n  macro \"\u27e6 \" f:term \" \u27e7\" : 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 (\u03b1 \u21d2 \u03b2) (\ud835\udd42 $ |\u03b1| \u2192 |\u03b2|) where\n  coe m :=\n    m.map\n/-- Allows using a `Morph` setoid directly as its underlying function. -/\ninstance instCoeFunMorphSetoid\n: CoeFun (|\u03b1 \u21db \u03b2|) (\ud835\udd42 $ |\u03b1| \u2192 |\u03b2|) 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 \u2192 Ty \u2192 Ty\n\n/-!\nWe can write a function to translate `Ty` values to a Lean type\n\u2014 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 \u2192 Type\n  | nat    => Nat\n  | fn a b => a.denote \u2192 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 \u2192 Type) : Ty \u2192 Type\n  | var   : rep ty \u2192 Term' rep ty\n  | const : Nat \u2192 Term' rep .nat\n  | plus  : Term' rep .nat \u2192 Term' rep .nat \u2192 Term' rep .nat\n  | lam   : (rep dom \u2192 Term' rep ran) \u2192 Term' rep (.fn dom ran)\n  | app   : Term' rep (.fn dom ran) \u2192 Term' rep dom \u2192 Term' rep ran\n  | let   : Term' rep ty\u2081 \u2192 (rep ty\u2081 \u2192 Term' rep ty\u2082) \u2192 Term' rep ty\u2082\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 \u2192 Type) \u2192 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 \u2192 Type} \u2192 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 \u2192 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 \u2192 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 \u2192 Type} \u2192 rep ty1 \u2192 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 \u2192 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 \u2192 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 `\u2190` 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`, `\u2190 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\u2081 he\u2082 => simp [\u2190 iha, \u2190 ihb, he\u2081, he\u2082]\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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u2227 complete \u2192 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 {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*} {\u03b9 : Sort*}\n\n/-- The identity relation, or the graph of the identity function -/\ndef id_rel {\u03b1 : Type*} := {p : \u03b1 \u00d7 \u03b1 | p.1 = p.2}\n\n@[simp] theorem mem_id_rel {a b : \u03b1} : (a, b) \u2208 @id_rel \u03b1 \u2194 a = b := iff.rfl\n\n@[simp] theorem id_rel_subset {s : set (\u03b1 \u00d7 \u03b1)} : id_rel \u2286 s \u2194 \u2200 a, (a, a) \u2208 s :=\nby simp [subset_def]; exact forall_congr (\u03bb a, by simp)\n\n/-- The composition of relations -/\ndef comp_rel {\u03b1 : Type u} (r\u2081 r\u2082 : set (\u03b1\u00d7\u03b1)) := {p : \u03b1 \u00d7 \u03b1 | \u2203z:\u03b1, (p.1, z) \u2208 r\u2081 \u2227 (z, p.2) \u2208 r\u2082}\n\n@[simp] theorem mem_comp_rel {r\u2081 r\u2082 : set (\u03b1\u00d7\u03b1)}\n  {x y : \u03b1} : (x, y) \u2208 comp_rel r\u2081 r\u2082 \u2194 \u2203 z, (x, z) \u2208 r\u2081 \u2227 (z, y) \u2208 r\u2082 := iff.rfl\n\n@[simp] theorem swap_id_rel : prod.swap '' id_rel = @id_rel \u03b1 :=\nset.ext $ assume \u27e8a, b\u27e9, by simp [image_swap_eq_preimage_swap]; exact eq_comm\n\ntheorem monotone_comp_rel [preorder \u03b2] {f g : \u03b2 \u2192 set (\u03b1\u00d7\u03b1)}\n  (hf : monotone f) (hg : monotone g) : monotone (\u03bbx, comp_rel (f x) (g x)) :=\nassume a b h p \u27e8z, h\u2081, h\u2082\u27e9, \u27e8z, hf h h\u2081, hg h h\u2082\u27e9\n\nlemma prod_mk_mem_comp_rel {a b c : \u03b1} {s t : set (\u03b1\u00d7\u03b1)} (h\u2081 : (a, c) \u2208 s) (h\u2082 : (c, b) \u2208 t) :\n  (a, b) \u2208 comp_rel s t :=\n\u27e8c, h\u2081, h\u2082\u27e9\n\n@[simp] lemma id_comp_rel {r : set (\u03b1\u00d7\u03b1)} : comp_rel id_rel r = r :=\nset.ext $ assume \u27e8a, b\u27e9, by simp\n\nlemma comp_rel_assoc {r s t : set (\u03b1\u00d7\u03b1)} :\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 (\u03b1 : Type u) :=\n(uniformity : filter (\u03b1 \u00d7 \u03b1))\n(refl       : principal id_rel \u2264 uniformity)\n(symm       : tendsto prod.swap uniformity uniformity)\n(comp       : uniformity.lift' (\u03bbs, comp_rel s s) \u2264 uniformity)\n\ndef uniform_space.core.mk' {\u03b1 : Type u} (U : filter (\u03b1 \u00d7 \u03b1))\n  (refl : \u2200 (r \u2208 U) x, (x, x) \u2208 r)\n  (symm : \u2200 r \u2208 U, {p | prod.swap p \u2208 r} \u2208 U)\n  (comp : \u2200 r \u2208 U, \u2203 t \u2208 U, comp_rel t t \u2286 r) : uniform_space.core \u03b1 :=\n\u27e8U, \u03bb 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\u27e9\n\n/-- A uniform space generates a topological space -/\ndef uniform_space.core.to_topological_space {\u03b1 : Type u} (u : uniform_space.core \u03b1) :\n  topological_space \u03b1 :=\n{ is_open        := \u03bbs, \u2200x\u2208s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 u.uniformity,\n  is_open_univ   := by simp; intro; exact univ_mem_sets,\n  is_open_inter  :=\n    assume s t hs ht x \u27e8xs, xt\u27e9, by filter_upwards [hs x xs, ht x xt]; simp {contextual := tt},\n  is_open_sUnion :=\n    assume s hs x \u27e8t, ts, xt\u27e9, by filter_upwards [hs t ts x xt] assume p ph h, \u27e8t, ts, ph h\u27e9 }\n\nlemma uniform_space.core_eq : \u2200{u\u2081 u\u2082 : uniform_space.core \u03b1}, u\u2081.uniformity = u\u2082.uniformity \u2192 u\u2081 = u\u2082\n| \u27e8u\u2081, _, _, _\u27e9  \u27e8u\u2082, _, _, _\u27e9 h := have u\u2081 = u\u2082, 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 `\u03b1 \u00d7 \u03b1` 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 (\u03b1 : Type u) extends topological_space \u03b1, uniform_space.core \u03b1 :=\n(is_open_uniformity : \u2200s, is_open s \u2194 (\u2200x\u2208s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 uniformity))\n\n@[pattern] def uniform_space.mk' {\u03b1} (t : topological_space \u03b1)\n  (c : uniform_space.core \u03b1)\n  (is_open_uniformity : \u2200s:set \u03b1, t.is_open s \u2194\n    (\u2200x\u2208s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 c.uniformity)) :\n  uniform_space \u03b1 := \u27e8c, is_open_uniformity\u27e9\n\ndef uniform_space.of_core {\u03b1 : Type u} (u : uniform_space.core \u03b1) : uniform_space \u03b1 :=\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 {\u03b1 : Type u} (u : uniform_space.core \u03b1) (t : topological_space \u03b1)\n  (h : t = u.to_topological_space) : uniform_space \u03b1 :=\n{ to_core := u,\n  to_topological_space := t,\n  is_open_uniformity := assume a, h.symm \u25b8 iff.refl _ }\n\nlemma uniform_space.to_core_to_topological_space (u : uniform_space \u03b1) :\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 : \u2200{u\u2081 u\u2082 : uniform_space \u03b1}, u\u2081.uniformity = u\u2082.uniformity \u2192 u\u2081 = u\u2082\n| (uniform_space.mk' t\u2081 u\u2081 o\u2081)  (uniform_space.mk' t\u2082 u\u2082 o\u2082) h :=\n  have u\u2081 = u\u2082, from uniform_space.core_eq h,\n  have t\u2081 = t\u2082, from topological_space_eq $ funext $ assume s, by rw [o\u2081, o\u2082]; simp [this],\n  by simp [*]\n\nlemma uniform_space.of_core_eq_to_core\n  (u : uniform_space \u03b1) (t : topological_space \u03b1) (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 \u03b1]\n\n/-- The uniformity is a filter on \u03b1 \u00d7 \u03b1 (inferred from an ambient uniform space\n  structure on \u03b1). -/\ndef uniformity (\u03b1 : Type u) [uniform_space \u03b1] : filter (\u03b1 \u00d7 \u03b1) :=\n  (@uniform_space.to_core \u03b1 _).uniformity\n\nlocal notation `\ud835\udce4` := uniformity\n\nlemma is_open_uniformity {s : set \u03b1} :\n  is_open s \u2194 (\u2200x\u2208s, { p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s } \u2208 \ud835\udce4 \u03b1) :=\nuniform_space.is_open_uniformity s\n\nlemma refl_le_uniformity : principal id_rel \u2264 \ud835\udce4 \u03b1 :=\n(@uniform_space.to_core \u03b1 _).refl\n\nlemma refl_mem_uniformity {x : \u03b1} {s : set (\u03b1 \u00d7 \u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) :\n  (x, x) \u2208 s :=\nrefl_le_uniformity h rfl\n\nlemma symm_le_uniformity : map (@prod.swap \u03b1 \u03b1) (\ud835\udce4 _) \u2264 (\ud835\udce4 _) :=\n(@uniform_space.to_core \u03b1 _).symm\n\nlemma comp_le_uniformity : (\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), comp_rel s s) \u2264 \ud835\udce4 \u03b1 :=\n(@uniform_space.to_core \u03b1 _).comp\n\nlemma tendsto_swap_uniformity : tendsto (@prod.swap \u03b1 \u03b1) (\ud835\udce4 \u03b1) (\ud835\udce4 \u03b1) :=\nsymm_le_uniformity\n\nlemma tendsto_const_uniformity {a : \u03b1} {f : filter \u03b2} : tendsto (\u03bb _, (a, a)) f (\ud835\udce4 \u03b1) :=\nassume s hs,\nshow {x | (a, a) \u2208 s} \u2208 f,\n  from univ_mem_sets' $ assume b, refl_mem_uniformity hs\n\nlemma comp_mem_uniformity_sets {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, comp_rel t t \u2286 s :=\nhave s \u2208 (\ud835\udce4 \u03b1).lift' (\u03bbt:set (\u03b1\u00d7\u03b1), 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 (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, (\u2200a b, (a, b) \u2208 t \u2192 (b, a) \u2208 t) \u2227 t \u2286 s :=\nhave preimage prod.swap s \u2208 \ud835\udce4 \u03b1, from symm_le_uniformity hs,\n\u27e8s \u2229 preimage prod.swap s, inter_mem_sets hs this, assume a b \u27e8h\u2081, h\u2082\u27e9, \u27e8h\u2082, h\u2081\u27e9, inter_subset_left _ _\u27e9\n\nlemma comp_symm_of_uniformity {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203 t \u2208 \ud835\udce4 \u03b1, (\u2200{a b}, (a, b) \u2208 t \u2192 (b, a) \u2208 t) \u2227 comp_rel t t \u2286 s :=\nlet \u27e8t, ht\u2081, ht\u2082\u27e9 := comp_mem_uniformity_sets hs in\nlet \u27e8t', ht', ht'\u2081, ht'\u2082\u27e9 := symm_of_uniformity ht\u2081 in\n\u27e8t', ht', ht'\u2081, subset.trans (monotone_comp_rel monotone_id monotone_id ht'\u2082) ht\u2082\u27e9\n\nlemma uniformity_le_symm : \ud835\udce4 \u03b1 \u2264 (@prod.swap \u03b1 \u03b1) <$> \ud835\udce4 \u03b1 :=\nby rw [map_swap_eq_comap_swap];\nfrom map_le_iff_le_comap.1 tendsto_swap_uniformity\n\nlemma uniformity_eq_symm : \ud835\udce4 \u03b1 = (@prod.swap \u03b1 \u03b1) <$> \ud835\udce4 \u03b1 :=\nle_antisymm uniformity_le_symm symm_le_uniformity\n\ntheorem uniformity_lift_le_swap {g : set (\u03b1\u00d7\u03b1) \u2192 filter \u03b2} {f : filter \u03b2} (hg : monotone g)\n  (h : (\ud835\udce4 \u03b1).lift (\u03bbs, g (preimage prod.swap s)) \u2264 f) : (\ud835\udce4 \u03b1).lift g \u2264 f :=\ncalc (\ud835\udce4 \u03b1).lift g \u2264 (filter.map (@prod.swap \u03b1 \u03b1) $ \ud835\udce4 \u03b1).lift g :\n    lift_mono uniformity_le_symm (le_refl _)\n  ... \u2264 _ :\n    by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]; exact h\n\nlemma uniformity_lift_le_comp {f : set (\u03b1\u00d7\u03b1) \u2192 filter \u03b2} (h : monotone f):\n  (\ud835\udce4 \u03b1).lift (\u03bbs, f (comp_rel s s)) \u2264 (\ud835\udce4 \u03b1).lift f :=\ncalc (\ud835\udce4 \u03b1).lift (\u03bbs, f (comp_rel s s)) =\n    ((\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), 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  ... \u2264 (\ud835\udce4 \u03b1).lift f : lift_mono comp_le_uniformity (le_refl _)\n\nlemma comp_le_uniformity3 :\n  (\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), comp_rel s (comp_rel s s)) \u2264 (\ud835\udce4 \u03b1) :=\ncalc (\ud835\udce4 \u03b1).lift' (\u03bbd, comp_rel d (comp_rel d d)) =\n  (\ud835\udce4 \u03b1).lift (\u03bbs, (\ud835\udce4 \u03b1).lift' (\u03bbt:set(\u03b1\u00d7\u03b1), 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  ... \u2264 (\ud835\udce4 \u03b1).lift (\u03bbs, (\ud835\udce4 \u03b1).lift' (\u03bbt:set(\u03b1\u00d7\u03b1), comp_rel s t)) :\n    lift_mono' $ assume s hs, @uniformity_lift_le_comp \u03b1 _ _ (principal \u2218 comp_rel s) $\n      monotone_comp (monotone_comp_rel monotone_const monotone_id) monotone_principal\n  ... = (\ud835\udce4 \u03b1).lift' (\u03bbs:set(\u03b1\u00d7\u03b1), 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  ... \u2264 (\ud835\udce4 \u03b1) : comp_le_uniformity\n\nlemma mem_nhds_uniformity_iff {x : \u03b1} {s : set \u03b1} :\n  s \u2208 nhds x \u2194 {p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s} \u2208 \ud835\udce4 \u03b1 :=\n\u27e8 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 \u27e8x', y\u27e9 h eq, ts $ h eq\n  end,\n\n  assume hs,\n  mem_nhds_sets_iff.mpr \u27e8{x | {p : \u03b1 \u00d7 \u03b1 | p.1 = x \u2192 p.2 \u2208 s} \u2208 \ud835\udce4 \u03b1},\n    assume x' hx', refl_mem_uniformity hx' rfl,\n    is_open_uniformity.mpr $ assume x' hx',\n      let \u27e8t, ht, tr\u27e9 := comp_mem_uniformity_sets hx' in\n      by filter_upwards [ht] assume \u27e8a, b\u27e9 hp' (hax' : a = x'),\n      by filter_upwards [ht] assume \u27e8a, b'\u27e9 hp'' (hab : a = b),\n      have hp : (x', b) \u2208 t, from hax' \u25b8 hp',\n      have (b, b') \u2208 t, from hab \u25b8 hp'',\n      have (x', b') \u2208 comp_rel t t, from \u27e8b, hp, this\u27e9,\n      show b' \u2208 s,\n        from tr this rfl,\n    hs\u27e9\u27e9\n\nlemma nhds_eq_comap_uniformity {x : \u03b1} : nhds x = (\ud835\udce4 \u03b1).comap (prod.mk x) :=\nby ext s; rw [mem_nhds_uniformity_iff, mem_comap_sets]; from iff.intro\n  (assume hs, \u27e8_, hs, assume x hx, hx rfl\u27e9)\n  (assume \u27e8t, h, ht\u27e9, (\ud835\udce4 \u03b1).sets_of_superset h $\n    assume \u27e8p\u2081, p\u2082\u27e9 hp (h : p\u2081 = x), ht $ by simp [h.symm, hp])\n\nlemma nhds_eq_uniformity {x : \u03b1} : nhds x = (\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), {y | (x, y) \u2208 s}) :=\nbegin\n  ext s,\n  rw [mem_lift'_sets], tactic.swap, apply monotone_preimage,\n  simp [mem_nhds_uniformity_iff],\n  exact \u27e8assume h, \u27e8_, h, assume y h, h rfl\u27e9,\n    assume \u27e8t, h\u2081, h\u2082\u27e9,\n    (\ud835\udce4 \u03b1).sets_of_superset h\u2081 $\n    assume \u27e8x', y\u27e9 hp (eq : x' = x), h\u2082 $\n    show (x, y) \u2208 t, from eq \u25b8 hp\u27e9\nend\n\nlemma mem_nhds_left (x : \u03b1) {s : set (\u03b1\u00d7\u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) :\n  {y : \u03b1 | (x, y) \u2208 s} \u2208 nhds x :=\nhave nhds x \u2264 principal {y : \u03b1 | (x, y) \u2208 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 : \u03b1) {s : set (\u03b1\u00d7\u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) :\n  {x : \u03b1 | (x, y) \u2208 s} \u2208 nhds y :=\nmem_nhds_left _ (symm_le_uniformity h)\n\nlemma tendsto_right_nhds_uniformity {a : \u03b1} : tendsto (\u03bba', (a', a)) (nhds a) (\ud835\udce4 \u03b1) :=\nassume s, mem_nhds_right a\n\nlemma tendsto_left_nhds_uniformity {a : \u03b1} : tendsto (\u03bba', (a, a')) (nhds a) (\ud835\udce4 \u03b1) :=\nassume s, mem_nhds_left a\n\nlemma lift_nhds_left {x : \u03b1} {g : set \u03b1 \u2192 filter \u03b2} (hg : monotone g) :\n  (nhds x).lift g = (\ud835\udce4 \u03b1).lift (\u03bbs:set (\u03b1\u00d7\u03b1), g {y | (x, y) \u2208 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 : \u03b1} {g : set \u03b1 \u2192 filter \u03b2} (hg : monotone g) :\n  (nhds x).lift g = (\ud835\udce4 \u03b1).lift (\u03bbs:set (\u03b1\u00d7\u03b1), g {y | (y, x) \u2208 s}) :=\ncalc (nhds x).lift g = (\ud835\udce4 \u03b1).lift (\u03bbs:set (\u03b1\u00d7\u03b1), g {y | (x, y) \u2208 s}) : lift_nhds_left hg\n  ... = ((@prod.swap \u03b1 \u03b1) <$> (\ud835\udce4 \u03b1)).lift (\u03bbs:set (\u03b1\u00d7\u03b1), g {y | (x, y) \u2208 s}) : by rw [\u2190uniformity_eq_symm]\n  ... = (\ud835\udce4 \u03b1).lift (\u03bbs:set (\u03b1\u00d7\u03b1), g {y | (x, y) \u2208 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 : \u03b1} :\n  filter.prod (nhds a) (nhds b) =\n  (\ud835\udce4 \u03b1).lift (\u03bbs:set (\u03b1\u00d7\u03b1), (\ud835\udce4 \u03b1).lift' (\u03bbt:set (\u03b1\u00d7\u03b1),\n    set.prod {y : \u03b1 | (y, a) \u2208 s} {y : \u03b1 | (b, y) \u2208 t})) :=\nbegin\n  rw [prod_def],\n  show (nhds a).lift (\u03bbs:set \u03b1, (nhds b).lift (\u03bbt:set \u03b1, 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 : \u03b1} :\n  nhds (a, b) =\n  (\ud835\udce4 \u03b1).lift' (\u03bbs:set (\u03b1\u00d7\u03b1), set.prod {y : \u03b1 | (y, a) \u2208 s} {y : \u03b1 | (b, y) \u2208 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 (\u03b1\u00d7\u03b1)} (s : set (\u03b1\u00d7\u03b1)) (hd : d \u2208 \ud835\udce4 \u03b1) :\n  \u2203(t : set (\u03b1\u00d7\u03b1)), is_open t \u2227 s \u2286 t \u2227 t \u2286 {p | \u2203x y, (p.1, x) \u2208 d \u2227 (x, y) \u2208 s \u2227 (y, p.2) \u2208 d} :=\nlet cl_d := {p:\u03b1\u00d7\u03b1 | \u2203x y, (p.1, x) \u2208 d \u2227 (x, y) \u2208 s \u2227 (y, p.2) \u2208 d} in\nhave \u2200p \u2208 s, \u2203t \u2286 cl_d, is_open t \u2227 p \u2208 t, from\n  assume \u27e8x, y\u27e9 hp, mem_nhds_sets_iff.mp $\n  show cl_d \u2208 nhds (x, y),\n  begin\n    rw [nhds_eq_uniformity_prod, mem_lift'_sets],\n    exact \u27e8d, hd, assume \u27e8a, b\u27e9 \u27e8ha, hb\u27e9, \u27e8x, y, ha, hp, hb\u27e9\u27e9,\n    exact monotone_prod monotone_preimage monotone_preimage\n  end,\nhave \u2203t:(\u03a0(p:\u03b1\u00d7\u03b1) (h:p \u2208 s), set (\u03b1\u00d7\u03b1)),\n    \u2200p, \u2200h:p \u2208 s, t p h \u2286 cl_d \u2227 is_open (t p h) \u2227 p \u2208 t p h,\n  by simp [classical.skolem] at this; simp; assumption,\nmatch this with\n| \u27e8t, ht\u27e9 :=\n  \u27e8(\u22c3 p:\u03b1\u00d7\u03b1, \u22c3 h : p \u2208 s, t p h : set (\u03b1\u00d7\u03b1)),\n    is_open_Union $ assume (p:\u03b1\u00d7\u03b1), is_open_Union $ assume hp, (ht p hp).right.left,\n    assume \u27e8a, b\u27e9 hp, begin simp; exact \u27e8a, b, hp, (ht (a,b) hp).right.right\u27e9 end,\n    Union_subset $ assume p, Union_subset $ assume hp, (ht p hp).left\u27e9\nend\n\nlemma closure_eq_inter_uniformity {t : set (\u03b1\u00d7\u03b1)} :\n  closure t = (\u22c2 d \u2208 \ud835\udce4 \u03b1, comp_rel d (comp_rel t d)) :=\nset.ext $ assume \u27e8a, b\u27e9,\ncalc (a, b) \u2208 closure t \u2194 (nhds (a, b) \u2293 principal t \u2260 \u22a5) : by simp [closure_eq_nhds]\n  ... \u2194 (((@prod.swap \u03b1 \u03b1) <$> \ud835\udce4 \u03b1).lift'\n      (\u03bb (s : set (\u03b1 \u00d7 \u03b1)), set.prod {x : \u03b1 | (x, a) \u2208 s} {y : \u03b1 | (b, y) \u2208 s}) \u2293 principal t \u2260 \u22a5) :\n    by rw [\u2190uniformity_eq_symm, nhds_eq_uniformity_prod]\n  ... \u2194 ((map (@prod.swap \u03b1 \u03b1) (\ud835\udce4 \u03b1)).lift'\n      (\u03bb (s : set (\u03b1 \u00d7 \u03b1)), set.prod {x : \u03b1 | (x, a) \u2208 s} {y : \u03b1 | (b, y) \u2208 s}) \u2293 principal t \u2260 \u22a5) :\n    by refl\n  ... \u2194 ((\ud835\udce4 \u03b1).lift'\n      (\u03bb (s : set (\u03b1 \u00d7 \u03b1)), set.prod {y : \u03b1 | (a, y) \u2208 s} {x : \u03b1 | (x, b) \u2208 s}) \u2293 principal t \u2260 \u22a5) :\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  ... \u2194 (\u2200s \u2208 \ud835\udce4 \u03b1, \u2203x, x \u2208 set.prod {y : \u03b1 | (a, y) \u2208 s} {x : \u03b1 | (x, b) \u2208 s} \u2229 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  ... \u2194 (\u2200 s \u2208 \ud835\udce4 \u03b1, (a, b) \u2208 comp_rel s (comp_rel t s)) :\n    forall_congr $ assume s, forall_congr $ assume hs,\n    \u27e8assume \u27e8\u27e8x, y\u27e9, \u27e8\u27e8hx, hy\u27e9, hxyt\u27e9\u27e9, \u27e8x, hx, y, hxyt, hy\u27e9,\n      assume \u27e8x, hx, y, hxyt, hy\u27e9, \u27e8\u27e8x, y\u27e9, \u27e8\u27e8hx, hy\u27e9, hxyt\u27e9\u27e9\u27e9\n  ... \u2194 _ : by simp\n\nlemma uniformity_eq_uniformity_closure : \ud835\udce4 \u03b1 = (\ud835\udce4 \u03b1).lift' closure :=\nle_antisymm\n  (le_infi $ assume s, le_infi $ assume hs, by simp; filter_upwards [hs] subset_closure)\n  (calc (\ud835\udce4 \u03b1).lift' closure \u2264 (\ud835\udce4 \u03b1).lift' (\u03bbd, 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    ... \u2264 (\ud835\udce4 \u03b1) : comp_le_uniformity3)\n\nlemma uniformity_eq_uniformity_interior : \ud835\udce4 \u03b1 = (\ud835\udce4 \u03b1).lift' interior :=\nle_antisymm\n  (le_infi $ assume d, le_infi $ assume hd,\n    let \u27e8s, hs, hs_comp\u27e9 := (mem_lift'_sets $\n      monotone_comp_rel monotone_id $ monotone_comp_rel monotone_id monotone_id).mp (comp_le_uniformity3 hd) in\n    let \u27e8t, ht, hst, ht_comp\u27e9 := nhdset_of_mem_uniformity s hs in\n    have s \u2286 interior d, from\n      calc s \u2286 t : hst\n       ... \u2286 interior d : (subset_interior_iff_subset_of_open ht).mpr $\n        assume x, assume : x \u2208 t, let \u27e8x, y, h\u2081, h\u2082, h\u2083\u27e9 := ht_comp this in hs_comp \u27e8x, h\u2081, y, h\u2082, h\u2083\u27e9,\n    have interior d \u2208 \ud835\udce4 \u03b1, by filter_upwards [hs] this,\n    by simp [this])\n  (assume s hs, ((\ud835\udce4 \u03b1).lift' interior).sets_of_superset (mem_lift' hs) interior_subset)\n\nlemma interior_mem_uniformity {s : set (\u03b1 \u00d7 \u03b1)} (hs : s \u2208 \ud835\udce4 \u03b1) :\n  interior s \u2208 \ud835\udce4 \u03b1 :=\nby rw [uniformity_eq_uniformity_interior]; exact mem_lift' hs\n\nlemma mem_uniformity_is_closed [uniform_space \u03b1] {s : set (\u03b1\u00d7\u03b1)} (h : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203t \u2208 \ud835\udce4 \u03b1, is_closed t \u2227 t \u2286 s :=\nhave s \u2208 (\ud835\udce4 \u03b1).lift' closure, by rwa [uniformity_eq_uniformity_closure] at h,\nhave \u2203 t \u2208 \ud835\udce4 \u03b1, closure t \u2286 s,\n  by rwa [mem_lift'_sets] at this; apply closure_mono,\nlet \u27e8t, ht, hst\u27e9 := this in\n\u27e8closure t, (\ud835\udce4 \u03b1).sets_of_superset ht subset_closure, is_closed_closure, hst\u27e9\n\n/- uniform continuity -/\n\ndef uniform_continuous [uniform_space \u03b2] (f : \u03b1 \u2192 \u03b2) :=\ntendsto (\u03bbx:\u03b1\u00d7\u03b1, (f x.1, f x.2)) (\ud835\udce4 \u03b1) (\ud835\udce4 \u03b2)\n\ntheorem uniform_continuous_def [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} :\n  uniform_continuous f \u2194 \u2200 r \u2208 \ud835\udce4 \u03b2,\n    {x : \u03b1 \u00d7 \u03b1 | (f x.1, f x.2) \u2208 r} \u2208 \ud835\udce4 \u03b1 :=\niff.rfl\n\nlemma uniform_continuous_of_const [uniform_space \u03b2] {c : \u03b1 \u2192 \u03b2} (h : \u2200a b, c a = c b) :\n  uniform_continuous c :=\nhave (\u03bb (x : \u03b1 \u00d7 \u03b1), (c (x.fst), c (x.snd))) \u207b\u00b9' id_rel = univ, from\n  eq_univ_iff_forall.2 $ assume \u27e8a, b\u27e9, 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 \u03b1) :=\nby simp [uniform_continuous]; exact tendsto_id\n\nlemma uniform_continuous_const [uniform_space \u03b2] {b : \u03b2} : uniform_continuous (\u03bba:\u03b1, b) :=\n@tendsto_const_uniformity _ _ _ b (\ud835\udce4 \u03b1)\n\nlemma uniform_continuous.comp [uniform_space \u03b2] [uniform_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3}\n  (hf : uniform_continuous f) (hg : uniform_continuous g) : uniform_continuous (g \u2218 f) :=\nhf.comp hg\n\nlemma uniform_continuous.continuous [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2}\n  (hf : uniform_continuous f) : continuous f :=\ncontinuous_iff_continuous_at.mpr $ assume a,\ncalc map f (nhds a) \u2264\n    (map (\u03bbp:\u03b1\u00d7\u03b1, (f p.1, f p.2)) (\ud835\udce4 \u03b1)).lift' (\u03bbs:set (\u03b2\u00d7\u03b2), {y | (f a, y) \u2208 s}) :\n  begin\n    rw [nhds_eq_uniformity, map_lift'_eq, map_lift'_eq2],\n    exact (lift'_mono' $ assume s hs b \u27e8a', (ha' : (_, a') \u2208 s), a'_eq\u27e9,\n      \u27e8(a, a'), ha', show (f a, f a') = (f a, b), from a'_eq \u25b8 rfl\u27e9),\n    exact monotone_preimage,\n    exact monotone_preimage\n  end\n  ... \u2264 nhds (f a) :\n    by rw [nhds_eq_uniformity]; exact lift'_mono hf (le_refl _)\nend uniform_space\nend\n\nlocal notation `\ud835\udce4` := uniformity\n\nsection constructions\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*} {\u03b4 : Type*} {\u03b9 : Sort*}\n\ninstance : partial_order (uniform_space \u03b1) :=\n{ le          := \u03bbt s, s.uniformity \u2264 t.uniformity,\n  le_antisymm := assume t s h\u2081 h\u2082, uniform_space_eq $ le_antisymm h\u2082 h\u2081,\n  le_refl     := assume t, le_refl _,\n  le_trans    := assume a b c h\u2081 h\u2082, @le_trans _ _ c.uniformity b.uniformity a.uniformity h\u2082 h\u2081 }\n\ninstance : has_Sup (uniform_space \u03b1) :=\n\u27e8assume s, uniform_space.of_core {\n  uniformity := (\u2a05u\u2208s, @uniformity \u03b1 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 }\u27e9\n\nprivate lemma le_Sup {tt : set (uniform_space \u03b1)} {t : uniform_space \u03b1} (h : t \u2208 tt) :\n  t \u2264 Sup tt :=\nshow (\u2a05u\u2208tt, @uniformity \u03b1 u) \u2264 t.uniformity,\n  from infi_le_of_le t $ infi_le _ h\n\nprivate lemma Sup_le {tt : set (uniform_space \u03b1)} {t : uniform_space \u03b1} (h : \u2200t'\u2208tt, t' \u2264 t) :\n  Sup tt \u2264 t :=\nshow t.uniformity \u2264 (\u2a05u\u2208tt, @uniformity \u03b1 u),\n  from le_infi $ assume t', le_infi $ assume ht', h t' ht'\n\ninstance : has_bot (uniform_space \u03b1) :=\n\u27e8uniform_space.of_core { uniformity := \u22a4, refl := le_top, symm := le_top, comp := le_top }\u27e9\n\ninstance : has_top (uniform_space \u03b1) :=\n\u27e8{ to_topological_space := \u22a4,\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 } } \u27e9\n\ninstance : complete_lattice (uniform_space \u03b1) :=\n{ sup           := \u03bba 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\u2081 h\u2082, Sup_le $ assume t',\n    begin simp, intro h, cases h with h h, repeat { subst h; assumption } end,\n  inf           := \u03bba b, Sup {x | x \u2264 a \u2227 x \u2264 b},\n  le_inf        := assume a b c h\u2081 h\u2082, le_Sup \u27e8h\u2081, h\u2082\u27e9,\n  inf_le_left   := assume a b, Sup_le $ assume x \u27e8ha, hb\u27e9, ha,\n  inf_le_right  := assume a b, Sup_le $ assume x \u27e8ha, hb\u27e9, hb,\n  top           := \u22a4,\n  le_top        := assume u, u.refl,\n  bot           := \u22a5,\n  bot_le        := assume a, show a.uniformity \u2264 \u22a4, from le_top,\n  Sup           := Sup,\n  le_Sup        := assume s u, le_Sup,\n  Sup_le        := assume s u, Sup_le,\n  Inf           := \u03bbtt, Sup {t | \u2200t'\u2208tt, t \u2264 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 {\u03b9 : Sort*} {u : \u03b9 \u2192 uniform_space \u03b1} :\n  (supr u).uniformity = (\u2a05i, (u i).uniformity) :=\nshow (\u2a05a (h : \u2203i:\u03b9, u i = a), a.uniformity) = _, from\nle_antisymm\n  (le_infi $ assume i, infi_le_of_le (u i) $ infi_le _ \u27e8i, rfl\u27e9)\n  (le_infi $ assume a, le_infi $ assume \u27e8i, (ha : u i = a)\u27e9, ha \u25b8 infi_le _ _)\n\nlemma sup_uniformity {u v : uniform_space \u03b1} :\n  (u \u2294 v).uniformity = u.uniformity \u2293 v.uniformity :=\nhave (u \u2294 v) = (\u2a06i (h : i = u \u2228 i = v), i), by simp [supr_or, supr_sup_eq],\ncalc (u \u2294 v).uniformity = ((\u2a06i (h : i = u \u2228 i = v), i) : uniform_space \u03b1).uniformity : by rw [this]\n  ... = _ : by simp [supr_uniformity, infi_or, infi_inf_eq]\n\ninstance inhabited_uniform_space : inhabited (uniform_space \u03b1) := \u27e8\u22a4\u27e9\n\n/-- Given `f : \u03b1 \u2192 \u03b2` and a uniformity `u` on `\u03b2`, the inverse image of `u` under `f`\n  is the inverse image in the filter sense of the induced function `\u03b1 \u00d7 \u03b1 \u2192 \u03b2 \u00d7 \u03b2`. -/\ndef uniform_space.comap (f : \u03b1 \u2192 \u03b2) (u : uniform_space \u03b2) : uniform_space \u03b1 :=\n{ uniformity := u.uniformity.comap (\u03bbp:\u03b1\u00d7\u03b1, (f p.1, f p.2)),\n  to_topological_space := u.to_topological_space.induced f,\n  refl := le_trans (by simp; exact assume \u27e8a, b\u27e9 (h : a = b), h \u25b8 rfl) (comap_mono u.refl),\n  symm := by simp [tendsto_comap_iff, prod.swap, (\u2218)]; 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 \u27e8a\u2081, a\u2082\u27e9 \u27e8x, h\u2081, h\u2082\u27e9, \u27e8f x, h\u2081, h\u2082\u27e9),\n      repeat { exact monotone_comp_rel monotone_id monotone_id }\n    end\n    (comap_mono u.comp),\n  is_open_uniformity := \u03bb s, begin\n    change (@is_open \u03b1 (u.to_topological_space.induced f) s \u2194 _),\n    simp [is_open_iff_nhds, nhds_induced_eq_comap, mem_nhds_uniformity_iff, filter.comap, and_comm],\n    refine ball_congr (\u03bb x hx, \u27e8_, _\u27e9),\n    { rintro \u27e8t, hts, ht\u27e9, refine \u27e8_, ht, _\u27e9,\n      rintro \u27e8x\u2081, x\u2082\u27e9 h rfl, exact hts (h rfl) },\n    { rintro \u27e8t, ht, hts\u27e9,\n      exact \u27e8{y | (f x, y) \u2208 t}, \u03bb y hy, @hts (x, y) hy rfl,\n        mem_nhds_uniformity_iff.1 $ mem_nhds_left _ ht\u27e9 }\n  end }\n\nlemma uniform_space_comap_id {\u03b1 : Type*} : uniform_space.comap (id : \u03b1 \u2192 \u03b1) = id :=\nby ext u ; dsimp [uniform_space.comap] ; rw [prod.id_prod, filter.comap_id]\n\nlemma uniform_space.comap_comap_comp {\u03b1 \u03b2 \u03b3} [u\u03b3 : uniform_space \u03b3] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b3} :\n  uniform_space.comap (g \u2218 f) u\u03b3 = uniform_space.comap f (uniform_space.comap g u\u03b3) :=\nby ext ; dsimp [uniform_space.comap] ; rw filter.comap_comap_comp\n\nlemma uniform_continuous_iff {\u03b1 \u03b2} [u\u03b1 : uniform_space \u03b1] [u\u03b2 : uniform_space \u03b2] (f : \u03b1 \u2192 \u03b2) :\n  uniform_continuous f \u2194 u\u03b2.comap f \u2264 u\u03b1 :=\nfilter.map_le_iff_le_comap\n\nlemma uniform_continuous_comap {f : \u03b1 \u2192 \u03b2} [u : uniform_space \u03b2] :\n  @uniform_continuous \u03b1 \u03b2 (uniform_space.comap f u) u f :=\ntendsto_comap\n\ntheorem to_topological_space_comap {f : \u03b1 \u2192 \u03b2} {u : uniform_space \u03b2} :\n  @uniform_space.to_topological_space _ (uniform_space.comap f u) =\n  topological_space.induced f (@uniform_space.to_topological_space \u03b2 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 ((\ud835\udce4 \u03b2).lift' (preimage (\u03bbb, (f a, b)))) =\n      (u.uniformity.comap (\u03bbp:\u03b1\u00d7\u03b1, (f p.1, f p.2))).lift' (preimage (\u03bba', (a, a'))),\n  rw [comap_lift'_eq monotone_preimage, comap_lift'_eq2 monotone_preimage],\n  exact rfl\nend\n\nlemma uniform_continuous_comap' {f : \u03b3 \u2192 \u03b2} {g : \u03b1 \u2192 \u03b3} [v : uniform_space \u03b2] [u : uniform_space \u03b1]\n  (h : uniform_continuous (f \u2218 g)) : @uniform_continuous \u03b1 \u03b3 u (uniform_space.comap f v) g :=\ntendsto_comap_iff.2 h\n\nlemma to_topological_space_mono {u\u2081 u\u2082 : uniform_space \u03b1} (h : u\u2081 \u2264 u\u2082) :\n  @uniform_space.to_topological_space _ u\u2081 \u2264 @uniform_space.to_topological_space _ u\u2082 :=\nle_of_nhds_le_nhds $ assume a,\n  by rw [@nhds_eq_uniformity \u03b1 u\u2081 a, @nhds_eq_uniformity \u03b1 u\u2082 a]; exact (lift'_mono h $ le_refl _)\n\nlemma to_topological_space_top : @uniform_space.to_topological_space \u03b1 \u22a4 = \u22a4 := rfl\n\nlemma to_topological_space_bot : @uniform_space.to_topological_space \u03b1 \u22a5 = \u22a5 :=\nbot_unique $ assume s hs, classical.by_cases\n  (assume : s = \u2205, this.symm \u25b8 @is_open_empty _ \u22a5)\n  (assume : s \u2260 \u2205,\n    let \u27e8x, hx\u27e9 := 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 \u25b8 @is_open_univ _ \u22a5)\n\nlemma to_topological_space_supr {\u03b9 : Sort*} {u : \u03b9 \u2192 uniform_space \u03b1} :\n  @uniform_space.to_topological_space \u03b1 (supr u) = (\u2a06i, @uniform_space.to_topological_space \u03b1 (u i)) :=\nclassical.by_cases\n  (assume h : nonempty \u03b9,\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 \u03b1 (u i) a),\n        exact h,\n        exact assume a b, rfl\n      end\n    end)\n  (assume : \u00ac nonempty \u03b9,\n    le_antisymm\n      (have supr u = \u22a5, from bot_unique $ supr_le $ assume i, (this \u27e8i\u27e9).elim,\n        have @uniform_space.to_topological_space _ (supr u) = \u22a5,\n          from this.symm \u25b8 to_topological_space_bot,\n        this.symm \u25b8 bot_le)\n      (supr_le $ assume i, to_topological_space_mono $ le_supr _ _))\n\nlemma to_topological_space_Sup {s : set (uniform_space \u03b1)} :\n  @uniform_space.to_topological_space \u03b1 (Sup s) = (\u2a06i\u2208s, @uniform_space.to_topological_space \u03b1 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 \u03b1} :\n  @uniform_space.to_topological_space \u03b1 (u \u2294 v) =\n    @uniform_space.to_topological_space \u03b1 u \u2294 @uniform_space.to_topological_space \u03b1 v :=\nord_continuous_sup $ assume s, to_topological_space_Sup\n\ninstance : uniform_space empty := \u22a4\ninstance : uniform_space unit := \u22a4\ninstance : uniform_space bool := \u22a4\ninstance : uniform_space \u2115 := \u22a4\ninstance : uniform_space \u2124 := \u22a4\n\ninstance {p : \u03b1 \u2192 Prop} [t : uniform_space \u03b1] : uniform_space (subtype p) :=\nuniform_space.comap subtype.val t\n\nlemma uniformity_subtype {p : \u03b1 \u2192 Prop} [t : uniform_space \u03b1] :\n  \ud835\udce4 (subtype p) = comap (\u03bbq:subtype p \u00d7 subtype p, (q.1.1, q.2.1)) (\ud835\udce4 \u03b1) :=\nrfl\n\nlemma uniform_continuous_subtype_val {p : \u03b1 \u2192 Prop} [uniform_space \u03b1] :\n  uniform_continuous (subtype.val : {a : \u03b1 // p a} \u2192 \u03b1) :=\nuniform_continuous_comap\n\nlemma uniform_continuous_subtype_mk {p : \u03b1 \u2192 Prop} [uniform_space \u03b1] [uniform_space \u03b2]\n  {f : \u03b2 \u2192 \u03b1} (hf : uniform_continuous f) (h : \u2200x, p (f x)) :\n  uniform_continuous (\u03bbx, \u27e8f x, h x\u27e9 : \u03b2 \u2192 subtype p) :=\nuniform_continuous_comap' hf\n\nlemma tendsto_of_uniform_continuous_subtype\n  [uniform_space \u03b1] [uniform_space \u03b2] {f : \u03b1 \u2192 \u03b2} {s : set \u03b1} {a : \u03b1}\n  (hf : uniform_continuous (\u03bbx:s, f x.val)) (ha : s \u2208 nhds a) :\n  tendsto f (nhds a) (nhds (f a)) :=\nby rw [(@map_nhds_subtype_val_eq \u03b1 _ 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\u2081 : uniform_space \u03b1] [u\u2082 : uniform_space \u03b2] : uniform_space (\u03b1 \u00d7 \u03b2) :=\nuniform_space.of_core_eq\n  (u\u2081.comap prod.fst \u2294 u\u2082.comap prod.snd).to_core\n  prod.topological_space\n  (calc prod.topological_space = (u\u2081.comap prod.fst \u2294 u\u2082.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 \u03b1] [uniform_space \u03b2] : @uniformity (\u03b1 \u00d7 \u03b2) _ =\n  (\ud835\udce4 \u03b1).comap (\u03bbp:(\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2, (p.1.1, p.2.1)) \u2293\n  (\ud835\udce4 \u03b2).comap (\u03bbp:(\u03b1 \u00d7 \u03b2) \u00d7 \u03b1 \u00d7 \u03b2, (p.1.2, p.2.2)) :=\nsup_uniformity\n\nlemma uniformity_prod_eq_prod [uniform_space \u03b1] [uniform_space \u03b2] :\n  \ud835\udce4 (\u03b1\u00d7\u03b2) =\n    map (\u03bbp:(\u03b1\u00d7\u03b1)\u00d7(\u03b2\u00d7\u03b2), ((p.1.1, p.2.1), (p.1.2, p.2.2))) (filter.prod (\ud835\udce4 \u03b1) (\ud835\udce4 \u03b2)) :=\nhave map (\u03bbp:(\u03b1\u00d7\u03b1)\u00d7(\u03b2\u00d7\u03b2), ((p.1.1, p.2.1), (p.1.2, p.2.2))) =\n  comap (\u03bbp:(\u03b1\u00d7\u03b2)\u00d7(\u03b1\u00d7\u03b2), ((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 \u27e8\u27e8_, _\u27e9, \u27e8_, _\u27e9\u27e9, rfl) (funext $ assume \u27e8\u27e8_, _\u27e9, \u27e8_, _\u27e9\u27e9, rfl),\nby rw [this, uniformity_prod, filter.prod, comap_inf, comap_comap_comp, comap_comap_comp]\n\nlemma mem_map_sets_iff' {\u03b1 : Type*} {\u03b2 : Type*} {f : filter \u03b1} {m : \u03b1 \u2192 \u03b2} {t : set \u03b2} :\n  t \u2208 (map m f).sets \u2194 (\u2203s\u2208f, m '' s \u2286 t) :=\nmem_map_sets_iff\n\nlemma mem_uniformity_of_uniform_continuous_invarant [uniform_space \u03b1] {s:set (\u03b1\u00d7\u03b1)} {f : \u03b1 \u2192 \u03b1 \u2192 \u03b1}\n  (hf : uniform_continuous (\u03bbp:\u03b1\u00d7\u03b1, f p.1 p.2)) (hs : s \u2208 \ud835\udce4 \u03b1) :\n  \u2203u\u2208\ud835\udce4 \u03b1, \u2200a b c, (a, b) \u2208 u \u2192 (f a c, f b c) \u2208 s :=\nbegin\n  rw [uniform_continuous, uniformity_prod_eq_prod, tendsto_map'_iff, (\u2218)] at hf,\n  rcases mem_map_sets_iff'.1 (hf hs) with \u27e8t, ht, hts\u27e9, clear hf,\n  rcases mem_prod_iff.1 ht with \u27e8u, hu, v, hv, huvt\u27e9, clear ht,\n  refine \u27e8u, hu, assume a b c hab, hts $ (mem_image _ _ _).2 \u27e8\u27e8\u27e8a, b\u27e9, \u27e8c, c\u27e9\u27e9, huvt \u27e8_, _\u27e9, _\u27e9\u27e9,\n  exact hab,\n  exact refl_mem_uniformity hv,\n  refl\nend\n\nlemma mem_uniform_prod [t\u2081 : uniform_space \u03b1] [t\u2082 : uniform_space \u03b2] {a : set (\u03b1 \u00d7 \u03b1)} {b : set (\u03b2 \u00d7 \u03b2)}\n  (ha : a \u2208 \ud835\udce4 \u03b1) (hb : b \u2208 \ud835\udce4 \u03b2) :\n  {p:(\u03b1\u00d7\u03b2)\u00d7(\u03b1\u00d7\u03b2) | (p.1.1, p.2.1) \u2208 a \u2227 (p.1.2, p.2.2) \u2208 b } \u2208 (@uniformity (\u03b1 \u00d7 \u03b2) _) :=\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 \u03b1] [uniform_space \u03b2] :\n  tendsto (\u03bbp:(\u03b1\u00d7\u03b2)\u00d7(\u03b1\u00d7\u03b2), (p.1.1, p.2.1)) (\ud835\udce4 (\u03b1 \u00d7 \u03b2)) (\ud835\udce4 \u03b1) :=\nle_trans (map_mono (@le_sup_left (uniform_space (\u03b1\u00d7\u03b2)) _ _ _)) map_comap_le\n\nlemma tendsto_prod_uniformity_snd [uniform_space \u03b1] [uniform_space \u03b2] :\n  tendsto (\u03bbp:(\u03b1\u00d7\u03b2)\u00d7(\u03b1\u00d7\u03b2), (p.1.2, p.2.2)) (\ud835\udce4 (\u03b1 \u00d7 \u03b2)) (\ud835\udce4 \u03b2) :=\nle_trans (map_mono (@le_sup_right (uniform_space (\u03b1\u00d7\u03b2)) _ _ _)) map_comap_le\n\nlemma uniform_continuous_fst [uniform_space \u03b1] [uniform_space \u03b2] : uniform_continuous (\u03bbp:\u03b1\u00d7\u03b2, p.1) :=\ntendsto_prod_uniformity_fst\n\nlemma uniform_continuous_snd [uniform_space \u03b1] [uniform_space \u03b2] : uniform_continuous (\u03bbp:\u03b1\u00d7\u03b2, p.2) :=\ntendsto_prod_uniformity_snd\n\nvariables [uniform_space \u03b1] [uniform_space \u03b2] [uniform_space \u03b3]\nlemma uniform_continuous.prod_mk\n  {f\u2081 : \u03b1 \u2192 \u03b2} {f\u2082 : \u03b1 \u2192 \u03b3} (h\u2081 : uniform_continuous f\u2081) (h\u2082 : uniform_continuous f\u2082) :\n  uniform_continuous (\u03bba, (f\u2081 a, f\u2082 a)) :=\nby rw [uniform_continuous, uniformity_prod]; exact\ntendsto_inf.2 \u27e8tendsto_comap_iff.2 h\u2081, tendsto_comap_iff.2 h\u2082\u27e9\n\nlemma uniform_continuous.prod_mk_left {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (h : uniform_continuous f) (b) :\n  uniform_continuous (\u03bb a, f (a,b)) :=\n(uniform_continuous_id.prod_mk uniform_continuous_const).comp h\n\nlemma uniform_continuous.prod_mk_right {f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3} (h : uniform_continuous f) (a) :\n  uniform_continuous (\u03bb b, f (a,b)) :=\n(uniform_continuous_const.prod_mk  uniform_continuous_id).comp h\n\nlemma to_topological_space_prod [u : uniform_space \u03b1] [v : uniform_space \u03b2] :\n  @uniform_space.to_topological_space (\u03b1 \u00d7 \u03b2) prod.uniform_space =\n    @prod.topological_space \u03b1 \u03b2 u.to_topological_space v.to_topological_space := rfl\n\nend prod\n\nlemma to_topological_space_subtype [u : uniform_space \u03b1] {p : \u03b1 \u2192 Prop} :\n  @uniform_space.to_topological_space (subtype p) subtype.uniform_space =\n    @subtype.topological_space \u03b1 p u.to_topological_space := rfl\n\nsection sum\nvariables [uniform_space \u03b1] [uniform_space \u03b2]\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 (\u03b1 \u2295 \u03b2) :=\nuniform_space.core.mk'\n  (map (\u03bb p : \u03b1 \u00d7 \u03b1, (inl p.1, inl p.2)) (\ud835\udce4 \u03b1) \u2294 map (\u03bb p : \u03b2 \u00d7 \u03b2, (inr p.1, inr p.2)) (\ud835\udce4 \u03b2))\n  (\u03bb r \u27e8H\u2081, H\u2082\u27e9 x, by cases x; [apply refl_mem_uniformity H\u2081, apply refl_mem_uniformity H\u2082])\n  (\u03bb r \u27e8H\u2081, H\u2082\u27e9, \u27e8symm_le_uniformity H\u2081, symm_le_uniformity H\u2082\u27e9)\n  (\u03bb r \u27e8Hr\u03b1, Hr\u03b2\u27e9, begin\n    rcases comp_mem_uniformity_sets Hr\u03b1 with \u27e8t\u03b1, ht\u03b1, Ht\u03b1\u27e9,\n    rcases comp_mem_uniformity_sets Hr\u03b2 with \u27e8t\u03b2, ht\u03b2, Ht\u03b2\u27e9,\n    refine \u27e8_,\n      \u27e8mem_map_sets_iff.2 \u27e8t\u03b1, ht\u03b1, subset_union_left _ _\u27e9,\n       mem_map_sets_iff.2 \u27e8t\u03b2, ht\u03b2, subset_union_right _ _\u27e9\u27e9, _\u27e9,\n    rintros \u27e8_, _\u27e9 \u27e8z, \u27e8\u27e8a, b\u27e9, hab, \u27e8\u27e9\u27e9 | \u27e8\u27e8a, b\u27e9, hab, \u27e8\u27e9\u27e9,\n                       \u27e8\u27e8_, c\u27e9, hbc, \u27e8\u27e9\u27e9 | \u27e8\u27e8_, c\u27e9, hbc, \u27e8\u27e9\u27e9\u27e9,\n    { have A : (a, c) \u2208 comp_rel t\u03b1 t\u03b1 := \u27e8b, hab, hbc\u27e9,\n      exact Ht\u03b1 A },\n    { have A : (a, c) \u2208 comp_rel t\u03b2 t\u03b2 := \u27e8b, hab, hbc\u27e9,\n      exact Ht\u03b2 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 (\u03b1 \u00d7 \u03b1)} (ha : a \u2208 \ud835\udce4 \u03b1) {b : set (\u03b2 \u00d7 \u03b2)} (hb : b \u2208 \ud835\udce4 \u03b2) :\n  ((\u03bb p : (\u03b1 \u00d7 \u03b1), (inl p.1, inl p.2)) '' a \u222a (\u03bb p : (\u03b2 \u00d7 \u03b2), (inr p.1, inr p.2)) '' b) \u2208 (@uniform_space.core.sum \u03b1 \u03b2 _ _).uniformity :=\n\u27e8mem_map_sets_iff.2 \u27e8_, ha, subset_union_left _ _\u27e9, mem_map_sets_iff.2 \u27e8_, hb, subset_union_right _ _\u27e9\u27e9\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 (\u03b1 \u2295 \u03b2)} (hs : is_open s) {x : \u03b1 \u2295 \u03b2} (xs : x \u2208 s) :\n  { p : ((\u03b1 \u2295 \u03b2) \u00d7 (\u03b1 \u2295 \u03b2)) | p.1 = x \u2192 p.2 \u2208 s } \u2208 (@uniform_space.core.sum \u03b1 \u03b2 _ _).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 _ \u27e8\u27e8_, b\u27e9, h, \u27e8\u27e9\u27e9 \u27e8\u27e9,\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 _ \u27e8\u27e8a, _\u27e9, h, \u27e8\u27e9\u27e9 \u27e8\u27e9,\n    exact h rfl },\nend\n\nlemma open_of_uniformity_sum_aux {s : set (\u03b1 \u2295 \u03b2)}\n  (hs : \u2200x \u2208 s, { p : ((\u03b1 \u2295 \u03b2) \u00d7 (\u03b1 \u2295 \u03b2)) | p.1 = x \u2192 p.2 \u2208 s } \u2208 (@uniform_space.core.sum \u03b1 \u03b2 _ _).uniformity) :\n  is_open s :=\nbegin\n  split,\n  { refine (@is_open_iff_mem_nhds \u03b1 _ _).2 (\u03bb a ha, mem_nhds_uniformity_iff.2 _),\n    rcases mem_map_sets_iff.1 (hs _ ha).1 with \u27e8t, ht, st\u27e9,\n    refine mem_sets_of_superset ht _,\n    rintro p pt rfl, exact st \u27e8_, pt, rfl\u27e9 rfl },\n  { refine (@is_open_iff_mem_nhds \u03b2 _ _).2 (\u03bb b hb, mem_nhds_uniformity_iff.2 _),\n    rcases mem_map_sets_iff.1 (hs _ hb).2 with \u27e8t, ht, st\u27e9,\n    refine mem_sets_of_superset ht _,\n    rintro p pt rfl, exact st \u27e8_, pt, rfl\u27e9 rfl }\nend\n\n/- We can now define the uniform structure on the disjoint union -/\ninstance sum.uniform_space [u\u2081 : uniform_space \u03b1] [u\u2082 : uniform_space \u03b2] : uniform_space (\u03b1 \u2295 \u03b2) :=\n{ to_core := uniform_space.core.sum,\n  is_open_uniformity := \u03bb s, \u27e8uniformity_sum_of_open_aux, open_of_uniformity_sum_aux\u27e9 }\n\nlemma sum.uniformity [uniform_space \u03b1] [uniform_space \u03b2] :\n  \ud835\udce4 (\u03b1 \u2295 \u03b2) =\n    map (\u03bb p : \u03b1 \u00d7 \u03b1, (inl p.1, inl p.2)) (\ud835\udce4 \u03b1) \u2294\n    map (\u03bb p : \u03b2 \u00d7 \u03b2, (inr p.1, inr p.2)) (\ud835\udce4 \u03b2) := rfl\n\nend sum\n\nend constructions\n\nlemma lebesgue_number_lemma {\u03b1 : Type u} [uniform_space \u03b1] {s : set \u03b1} {\u03b9} {c : \u03b9 \u2192 set \u03b1}\n  (hs : compact s) (hc\u2081 : \u2200 i, is_open (c i)) (hc\u2082 : s \u2286 \u22c3 i, c i) :\n  \u2203 n \u2208 \ud835\udce4 \u03b1, \u2200 x \u2208 s, \u2203 i, {y | (x, y) \u2208 n} \u2286 c i :=\nbegin\n  let u := \u03bb n, {x | \u2203 i (m \u2208 \ud835\udce4 \u03b1), {y | (x, y) \u2208 comp_rel m n} \u2286 c i},\n  have hu\u2081 : \u2200 n \u2208 \ud835\udce4 \u03b1, is_open (u n),\n  { refine \u03bb n hn, is_open_uniformity.2 _,\n    rintro x \u27e8i, m, hm, h\u27e9,\n    rcases comp_mem_uniformity_sets hm with \u27e8m', hm', mm'\u27e9,\n    apply (\ud835\udce4 \u03b1).sets_of_superset hm',\n    rintros \u27e8x, y\u27e9 hp rfl,\n    refine \u27e8i, m', hm', \u03bb z hz, h (monotone_comp_rel monotone_id monotone_const mm' _)\u27e9,\n    dsimp at hz \u22a2, rw comp_rel_assoc,\n    exact \u27e8y, hp, hz\u27e9 },\n  have hu\u2082 : s \u2286 \u22c3 n \u2208 \ud835\udce4 \u03b1, u n,\n  { intros x hx,\n    rcases mem_Union.1 (hc\u2082 hx) with \u27e8i, h\u27e9,\n    rcases comp_mem_uniformity_sets (is_open_uniformity.1 (hc\u2081 i) x h) with \u27e8m', hm', mm'\u27e9,\n    exact mem_bUnion hm' \u27e8i, _, hm', \u03bb y hy, mm' hy rfl\u27e9 },\n  rcases compact_elim_finite_subcover_image hs hu\u2081 hu\u2082 with \u27e8b, bu, b_fin, b_cover\u27e9,\n  refine \u27e8_, Inter_mem_sets b_fin bu, \u03bb x hx, _\u27e9,\n  rcases mem_bUnion_iff.1 (b_cover hx) with \u27e8n, bn, i, m, hm, h\u27e9,\n  refine \u27e8i, \u03bb y hy, h _\u27e9,\n  exact prod_mk_mem_comp_rel (refl_mem_uniformity hm) (bInter_subset_of_mem bn hy)\nend\n\nlemma lebesgue_number_lemma_sUnion {\u03b1 : Type u} [uniform_space \u03b1] {s : set \u03b1} {c : set (set \u03b1)}\n  (hs : compact s) (hc\u2081 : \u2200 t \u2208 c, is_open t) (hc\u2082 : s \u2286 \u22c3\u2080 c) :\n  \u2203 n \u2208 \ud835\udce4 \u03b1, \u2200 x \u2208 s, \u2203 t \u2208 c, \u2200 y, (x, y) \u2208 n \u2192 y \u2208 t :=\nby rw sUnion_eq_Union at hc\u2082;\n   simpa using lebesgue_number_lemma hs (by simpa) hc\u2082\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 \u03b9 : Type*} [ordered_cancel_comm_monoid M] {f g : \u03b9 \u2192 M} {s t : finset \u03b9}\nopen_locale big_operators\n\n--TODO: move\n@[to_additive sum_pos'] lemma one_lt_prod' (Hle : \u2200 i \u2208 s, 1 \u2264 f i) (Hlt : \u2203 i \u2208 s, 1 < f i) :\n  1 < (\u220f 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 {\ud835\udd5c : Type*} [is_R_or_C \ud835\udd5c] {m n : Type*} [fintype m] [fintype n]\nopen_locale matrix\n\n/-- A matrix `M : matrix n n \ud835\udd5c` is positive semidefinite if it is hermitian\n   and `x\u1d34Mx` is nonnegative for all `x`. -/\ndef pos_semidef (M : matrix n n \ud835\udd5c) :=\nM.is_hermitian \u2227 \u2200 x : n \u2192 \ud835\udd5c, 0 \u2264 is_R_or_C.re (dot_product (star x) (M.mul_vec x))\n\nlemma pos_def.pos_semidef {M : matrix n n \ud835\udd5c} (hM : M.pos_def) : M.pos_semidef :=\nbegin\n  refine \u27e8hM.1, _\u27e9,\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 \ud835\udd5c} (hM : M.pos_semidef) : M.is_hermitian := hM.1\n\nlemma pos_semidef.transpose {M : matrix n n \ud835\udd5c} (hM : M.pos_semidef) : M\u1d40.pos_semidef :=\nbegin\n  refine \u27e8is_hermitian.transpose hM.1, \u03bb x, _\u27e9,\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 \u2192 \u211d} (hf : \u2200 i, 0 \u2264 f i) :\n  (diagonal f).pos_semidef :=\nbegin\n  refine \u27e8is_hermitian_diagonal _, _\u27e9,\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 \u2192 \u211d} (hf : \u2200 i, 0 < f i) :\n  (diagonal f).pos_def :=\nbegin\n  refine \u27e8is_hermitian_diagonal _, _\u27e9,\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 \ud835\udd5c := by apply_instance--infinite.nontrivial \ud835\udd5c\ninstance : is_domain \ud835\udd5c := 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 \u2192 R) (h : M.mul_vec x = 0) : x = 0 :=\ncalc\n  x = (M\u207b\u00b9 \u2b1d M).mul_vec x : by rw [nonsing_inv_mul M hM, one_mul_vec]\n  ... = 0 : by rw [\u2190 mul_vec_mul_vec, h, mul_vec_zero]\n\nlemma pos_def.det_ne_zero [decidable_eq n] {M : matrix n n \ud835\udd5c} (hM : M.pos_def) : M.det \u2260 0 :=\nbegin\n  rw \u2190 matrix.nondegenerate_iff_det_ne_zero,\n  intros v hv,\n  have hv' := hv (star v),\n  rw [\u2190 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 \ud835\udd5c}\n  (hM : M.is_hermitian) (hMdet : is_unit M.det):\n  M\u207b\u00b9.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 \ud835\udd5c} (hM : M.pos_def) :\n  M\u207b\u00b9.pos_def :=\nbegin\n  refine \u27e8is_hermitian.nonsingular_inv hM.1 (is_unit_iff_ne_zero.2 hM.det_ne_zero), _\u27e9,\n  intros x hx,\n  have hMMinv := (mul_nonsing_inv _ (is_unit_iff_ne_zero.2 hM.det_ne_zero)),\n  have hMinvdet : M\u207b\u00b9.det \u2260 0 := det_ne_zero_of_left_inverse hMMinv,\n  have := hM.2 (M\u207b\u00b9.mul_vec x) (\u03bb 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 [\u2190 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 \ud835\udd5c) (hM : M.is_hermitian) :\n  (N\u1d34 \u2b1d M \u2b1d 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 \ud835\udd5c) (hM : M.pos_def) (hN : N.det \u2260 0):\n  (N\u1d34 \u2b1d M \u2b1d N).pos_def :=\nbegin\n  refine \u27e8hM.1.conj_transpose_mul_mul M N, _\u27e9,\n  intros x hx,\n  convert hM.2 (N.mul_vec x) (\u03bb h, hx (eq_zero_of_mul_vec_eq_zero hN h)) using 2,\n  rw [matrix.mul_assoc, mul_vec_mul_vec, \u2190mul_vec_mul_vec, dot_product_mul_vec, star_mul_vec]\nend\n\nlemma pos_semidef.conj_transpose_mul_mul (M N : matrix n n \ud835\udd5c) (hM : M.pos_semidef) :\n  (N\u1d34 \u2b1d M \u2b1d N).pos_semidef :=\nbegin\n  refine \u27e8hM.1.conj_transpose_mul_mul M N, _\u27e9,\n  intro x,\n  convert hM.2 (N.mul_vec x) using 2,\n  rw [matrix.mul_assoc, mul_vec_mul_vec, \u2190mul_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 \ud835\udd5c}\n    (hM : M.pos_semidef) (hN : N.is_hermitian) :\n  (N \u2b1d M \u2b1d N).pos_semidef :=\nby { convert hM.conj_transpose_mul_mul M N, exact hN.symm }\n\nlemma pos_semidef.submatrix {M : matrix n n \ud835\udd5c} (hM : M.pos_semidef) (e : m \u2243 n):\n  (M.submatrix e e).pos_semidef :=\nbegin\n  refine \u27e8hM.1.submatrix e, \u03bb x, _\u27e9,\n  have : (M.submatrix \u21d1e \u21d1e).mul_vec x = M.mul_vec (\u03bb (i : n), x (e.symm i)) \u2218 e,\n  { ext i,\n    dsimp only [(\u2218), mul_vec, dot_product],\n    rw finset.sum_bij' (\u03bb i _, e i) _ _ (\u03bb 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 (\u03bb i, x (e.symm i)) using 3,\n  unfold dot_product,\n  rw [finset.sum_bij' (\u03bb i _, e i) _ _ (\u03bb 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 \ud835\udd5c} (e : m \u2243 n) :\n  (M.submatrix e e).pos_semidef \u2194 M.pos_semidef :=\n\u27e8\u03bb h, by simpa using h.submatrix e.symm, \u03bb h, h.submatrix _\u27e9\n\nlemma pos_semidef.add {M N: matrix n n \ud835\udd5c} (hM : M.pos_semidef) (hN : N.pos_semidef) :\n  (M + N).pos_semidef :=\nbegin\n  refine \u27e8hM.1.add hN.1, \u03bb x, _\u27e9,\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 \u211d} (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 _ (\u03bb h, _),\n  have h_det : (hM.is_hermitian.eigenvector_matrix)\u1d40.det = 0,\n    from matrix.det_eq_zero_of_row_eq_zero i (\u03bb 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\u1d40,\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 \u211d} (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 \u211d} (h : M\u207b\u00b9.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 \u211d) : M\u207b\u00b9.pos_def \u2194 M.pos_def :=\nbegin\n  refine \u27e8\u03bb hM, _, \u03bb hM, hM.nonsingular_inv\u27e9,\n  rw \u2190 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 \u211d} (hM : M.pos_semidef)\ninclude hM\n\nlemma eigenvalues_nonneg [decidable_eq n] (i : n) : 0 \u2264 hM.1.eigenvalues i :=\nby {rw hM.is_hermitian.eigenvalues_eq, apply hM.2}\n\nlemma det_nonneg [decidable_eq n] : 0 \u2264 det M :=\nbegin\n  rw [hM.1.det_eq_prod_eigenvalues],\n  apply finset.prod_nonneg (\u03bb 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 : \u2115) (h\u2081 : x = y + z) (h\u2082 : 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 \u2192 RPS\n  | rock => paper\n  | paper => scissors\n  | scissors => rock\n\ndef RPS.prev : RPS \u2192 RPS := next \u2218 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 \u2192 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 \u2192 RPS\n  | lose => l.prev\n  | draw => l\n  | win => l.next\n\ndef Result.points : Result \u2192 Nat\n  | lose => 0\n  | draw => 3\n  | win => 6\n\nnamespace Parse\n  def rps! : String \u2192 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 \u2192 Result\n    | \"X\" => Result.lose\n    | \"Y\" => Result.draw\n    | \"Z\" => Result.win\n    | _ => panic! \"invalid input [they]\"\n\n  def input! [Inhabited \u03b1] [Inhabited \u03b2] (fLeft:String \u2192 \u03b1) (fRight:String \u2192 \u03b2) (ls:List String) : List (\u03b1 \u00d7 \u03b2) :=\n    ls\n    |>.map (fun l => l.split (' ' == \u00b7))\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 \u00d7 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 \u00a73.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 (\u03b1 : Type _) {\u03b2 : Type _} := \u2115 \u2192 (\u03b1 \u2192 \u03b2) \u2192 \u03b2\n\ndef stream_cps.expose {\u03b1 \u03b2 : Type _} (s : stream_cps \u03b1) (k : \u03b1 \u2192 \u03b2) : \u03b2 := s 0 k\n\ndef stream_cps.const {\u03b1 \u03b2 : Type _} (x : \u03b1) : stream_cps \u03b1 :=\n  (\u03bb (n : \u2115) (k' : \u03b1 \u2192 \u03b2), k' x)\n\ndef stream_cps.cons {\u03b1 \u03b2 : Type _} (x : \u03b1) (s : stream_cps \u03b1) : stream_cps \u03b1 :=\n  (\u03bb (n : \u2115) (k' : \u03b1 \u2192 \u03b2),\n    match n with\n    | 0 := k' x\n    | nat.succ n := s n k'\n    end)\n\ndef stream_cps.drop {\u03b1 \u03b2 : Type _} (n : \u2115) (s : stream_cps \u03b1) : stream_cps \u03b1 :=\n  \u03bb (n' : \u2115) (k' : \u03b1 \u2192 \u03b2), 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 {\u03b1 \u03b2 : Type _} (s_cps : stream_cps \u03b1) (s : stream \u03b1) :=\n  \u2200(n : \u2115) (k : \u03b1 \u2192 \u03b2), 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 {\u03b2 : Type _} :\n  @stream_equiv \u2115 \u03b2 (stream_cps.const 2) (stream.const 2) :=\n\u03bb _ _, rfl\n\nlemma cons_cps_equiv_cons {\u03b1 \u03b2 : Type _} :\n  \u2200 (s_cps : @stream_cps \u03b1 \u03b2) (s : stream \u03b1) (x : \u03b1),\n  stream_equiv s_cps s \u2194\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 {\u03b1 \u03b2 : Type _} :\n  \u2200 (s_cps : @stream_cps \u03b1 \u03b2) (s : stream \u03b1) (n : \u2115),\n    stream_equiv s_cps s \u2192\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-- \u2261 the CPS/non-CPS stream equivalence relation):\n-- C<4, 3, 3, ...> \u2262 <2, 3, 3, ...> even though\n-- (drop_cps 1 C<4, 3, 3, ...>) \u2261 <3, 3, ...> = (drop 1 <2, 3, 3, ...>)\nlemma drop_equiv_not_bicond :\n  \u00ac(\u2200 (\u03b1 \u03b2 : Type _) (s_cps : @stream_cps \u03b1 \u03b2) (s : stream \u03b1) (n : \u2115),\n    stream_equiv (stream_cps.drop n s_cps) (stream.drop n s)\n      \u2192 stream_equiv s_cps s) :=\nbegin\n  intro h,\n  let s_cps := @stream_cps.cons (ulift \u2115) (ulift \u2115)\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) := \u03bb_ _, rfl,\n\n  have h_not_equiv : \u00ac(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\u2081 = u\u2082`\n    have h_equiv_at_0 := h_s_cps_equiv_s 0 (ulift.up \u2218 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 \u2115 false {down := 2} {down := 4} h_equiv_at_0)\n            (\u03bbh2eq4, (@nat.no_confusion false 2 4 h2eq4)\n              (\u03bbh', (@nat.no_confusion false 1 3 h')\n                (\u03bbh'', nat.no_confusion h'')))\n  end,\n  have h_for_contra := h (ulift \u2115) (ulift \u2115) 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\u00efve 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 {\u03b1 \u03b2 \u03b3 : Sort _}\n                        (f_res : stream \u03b1)\n                        (f_res_cps : (@stream_cps \u03b1 \u03b2 \u2192 \u03b3) \u2192 \u03b3) :=\n\u2200 (k : @stream_cps \u03b1 \u03b2 \u2192 \u03b3)\n    (k' : stream \u03b1 \u2192 \u03b3)\n    (hks : \u2200(s : stream_cps \u03b1) (s' : stream \u03b1),\n        stream_equiv s s' \u2192 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 {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (f : \u03b1 \u2192 (\u03b2 \u2192 \u03b3) \u2192 \u03b3)\n                                    (s : stream_cps \u03b1)\n                                    (k : stream_cps \u03b2 \u2192 \u03b4) : \u03b4 :=\nk (\u03bb(n : \u2115) (k' : \u03b2 \u2192 \u03b3), s n (\u03bbel, f el k'))\n\nlemma map_cps_equiv_map {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (f : \u03b1 \u2192 \u03b2) :\n  \u2200(s : stream \u03b1) (s_cps : @stream_cps \u03b1 \u03b3) (hequiv : stream_equiv s_cps s),\n    stream_cps_fn_equiv (stream.map f s)\n                        (@stream_cps.map \u03b1 \u03b2 \u03b3 \u03b4 (\u03bb(x : \u03b1) (k'' : \u03b2 \u2192 \u03b3),\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 \u03b2-reduction for us...for once\n  rw \u2190hequiv n_se (\u03bb (el : \u03b1), 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 : \u03a0 {\u03b1 : Sort _} {motive : \u2115 \u2192 Sort _} (n : \u2115),\n  motive 0 \u2192\n  (\u03a0 (n : \u2115), motive n \u2192 (motive n.succ \u2192 \u03b1) \u2192 \u03b1) \u2192\n  (motive n \u2192 \u03b1) \u2192 \u03b1\n| \u03b1 motive 0 val0 fn_succ k := k val0\n| \u03b1 motive (nat.succ n) val0 fn_succ k :=\n    nat.rec_on_cps n val0 fn_succ (\u03bbv_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 {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 (\u03b1 \u2192 \u03b2) \u2192 \u03b2)\n                                        (a : \u03b1)\n                                        (outer_k : @stream_cps \u03b1 \u03b2 \u2192 \u03b3) : \u03b3 :=\nouter_k (\u03bb(n : \u2115) (k : \u03b1 \u2192 \u03b2),\n@nat.rec_on (\u03bb_, (\u03b1 \u2192 \u03b2) \u2192 \u03b2)\n            n\n            (\u03bb (k' : \u03b1 \u2192 \u03b2), k' a)\n            (\u03bb (_ : \u2115) (r : (\u03b1 \u2192 \u03b2) \u2192 \u03b2) (k' : \u03b1 \u2192 \u03b2),\n              r (\u03bb(prev : \u03b1), f prev k'))\n            k)\n```\n\nFor wrapping your head around the full-CPS version, it's helpful to consider\nthat `motive n = ((\u03b1 \u2192 \u03b2) \u2192 \u03b2)`, so `fn_succ` has type `(((\u03b1 \u2192 \u03b2) \u2192 \u03b2) \u2192 \u03b3) \u2192 \u03b3`\n-/\ndef stream_cps.iterate {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 (\u03b1 \u2192 \u03b2) \u2192 \u03b2)\n                                        (a : \u03b1)\n                                        (outer_k : @stream_cps \u03b1 \u03b2 \u2192 \u03b3) : \u03b3 :=\nouter_k (\u03bb(n : \u2115) (k : \u03b1 \u2192 \u03b2),\n  @nat.rec_on_cps _ (\u03bb_, (\u03b1 \u2192 \u03b2) \u2192 \u03b2)\n              n\n              (\u03bb (k' : \u03b1 \u2192 \u03b2), k' a)\n              (\u03bb (_ : \u2115) (r : (\u03b1 \u2192 \u03b2) \u2192 \u03b2) (k' : ((\u03b1 \u2192 \u03b2) \u2192 \u03b2) \u2192 \u03b2),\n                k' (\u03bb(inner_k : \u03b1 \u2192 \u03b2), r (\u03bb(prev : \u03b1), f prev inner_k)))\n              (\u03bbnth_el_accessor, nth_el_accessor k)\n                 -- the motive type takes a continuation; we ultimately need to\n                 -- produce a \u03b2, 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 {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} (f : \u03b1 \u2192 (\u03b2 \u2192 \u03b3) \u2192 \u03b3)\n                                      (g : \u03b1 \u2192 (\u03b1 \u2192 \u03b3) \u2192 \u03b3) :\n                                      \u03b1 \u2192 (stream_cps \u03b2 \u2192 \u03b4) \u2192 \u03b4 :=\n\u03bb (a : \u03b1) (k : stream_cps \u03b2 \u2192 \u03b4),\n  k (\u03bb(n : \u2115) (k : \u03b2 \u2192 \u03b3),\n    stream_cps.iterate g a (\u03bbs_seeds,\n      stream_cps.map f s_seeds (\u03bbs, 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 {\u03b1 \u03b2 : Sort _} :\n  \u2200 {mot : \u2115 \u2192 Sort _}\n    (n : \u2115)\n    (el0 : mot 0)\n    (f_succ : \u03a0(n' : \u2115), mot n' \u2192 mot (nat.succ n'))\n    (k : mot n \u2192 \u03b1),\n  k (@nat.rec_on mot n el0 f_succ)\n    = nat.rec_on_cps n el0 (\u03bbn' 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 \u2190(ih el0 (\u03bb (n' : \u2115) (x : mot n'), f_succ n' x)\n                (\u03bb (v_prev : mot n), k (f_succ n v_prev))),\n  }\nend\n\nlemma iterate_cps_equiv_iterate {\u03b1 \u03b2 \u03b3 : Type _} :\n  \u2200 (f : \u03b1 \u2192 \u03b1)\n    (a : \u03b1),\n    stream_cps_fn_equiv (stream.iterate f a)\n                        (@stream_cps.iterate \u03b1 \u03b2 \u03b3 (\u03bb(x : \u03b1) (k'' : \u03b1 \u2192 \u03b2),\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 \u2190(@nat_rec_on_cps_equiv_nat_rec_on \u03b2 \u03b1),\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 \u2190(ih f a k k' hks) },\nend\n\nlemma corec_cps_equiv_corec {\u03b1 \u03b2 \u03b3 \u03b4 : Type _} :\n  \u2200 (f : \u03b1 \u2192 \u03b2) (g : \u03b1 \u2192 \u03b1) (a : \u03b1),\n    stream_cps_fn_equiv (stream.corec f g a)\n                        (@stream_cps.corec \u03b1 \u03b2 \u03b3 \u03b4 (\u03bbx k, k (f x))\n                                                   (\u03bbx 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 := \u03bb (s : stream \u03b1), 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            (\u03bb(s : stream \u03b2), 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 {\u03b1 \u03b2 : Type _} : \u03b1 \u00d7 list \u03b1 \u00d7 \u03b1 \u00d7 list \u03b1 \u2192 (\u03b1 \u2192 \u03b2) \u2192 \u03b2\n| (v, _, _, _) k := k v\n\ndef stream_cps.cycle_g {\u03b1 \u03b2 : Type _} :\n  \u03b1 \u00d7 list \u03b1 \u00d7 \u03b1 \u00d7 list \u03b1 \u2192 (\u03b1 \u00d7 list \u03b1 \u00d7 \u03b1 \u00d7 list \u03b1 \u2192 \u03b2) \u2192 \u03b2\n| (v\u2081, [], v\u2080, l\u2080) k := k (v\u2080, l\u2080, v\u2080, l\u2080)\n| (v\u2081, list.cons v\u2082 l\u2082, v\u2080, l\u2080) k := k (v\u2082, l\u2082, v\u2080, l\u2080)\n\ndef stream_cps.cycle {\u03b1 \u03b2 \u03b3 : Type _} :\n  \u03a0 (l : list \u03b1), l \u2260 [] \u2192 (@stream_cps \u03b1 \u03b3 \u2192 \u03b2) \u2192 \u03b2\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 (\u03bb_, list \u2115)\n                  20\n                  []\n                  (\u03bbn r, stream_cps.cycle [1, 9, 5, 1, 88]\n                                          (by apply list.no_confusion)\n                                          (\u03bbs, s n (\u03bbel, 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 {\u03b1 \u03b2 \u03b3 : Type _} :\n  \u2200 (l : list \u03b1) (hl : l \u2260 []) (k : @stream_cps \u03b1 \u03b2 \u2192 \u03b3) (k' : stream \u03b1 \u2192 \u03b3)\n    (hks : \u2200(s : stream_cps \u03b1) (s' : stream \u03b1),\n        stream_equiv s s' \u2192 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 : \u2200{\u03b1 \u03b2 : Type _},\n      (\u03bb (x : \u03b1 \u00d7 list \u03b1 \u00d7 \u03b1 \u00d7 list \u03b1) (k : \u03b1 \u2192 \u03b2), k (stream.cycle_f x))\n      = stream_cps.cycle_f := \n    begin\n      intros \u03b1 \u03b2,\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: \u2200{\u03b1 \u03b2 : Type _}, (\u03bb (x : \u03b1 \u00d7 list \u03b1 \u00d7 \u03b1 \u00d7 list \u03b1)\n                                 (k : \u03b1 \u00d7 list \u03b1 \u00d7 \u03b1 \u00d7 list \u03b1 \u2192 \u03b2),\n                                   k (stream.cycle_g x)) = stream_cps.cycle_g := \n    begin\n      intros \u03b1 \u03b2,\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 [\u2190hf, \u2190hg],\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 {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2)\n                                    (s : stream \u03b1)\n                                    (k : stream \u03b2 \u2192 \u03b3) :=\n  k (\u03bbn, f (s n))\n\nlemma boring_map_cps_equiv_map {\u03b1 \u03b2 \u03b3 : Type _} :\n  \u2200 (f : \u03b1 \u2192 \u03b2) (s : stream \u03b1) (k : stream \u03b2 \u2192 \u03b3),\n  k (stream.map f s) = boring_map_cps f s k := \u03bb_ _ _, 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\u2081 : Type*} [add_comm_monoid M\u2081] [module R M\u2081] \n{N\u2081 : Type*} [add_comm_monoid N\u2081] [module R N\u2081] \n{M\u2082 : Type*} [add_comm_monoid M\u2082] [module R M\u2082] \n{N\u2082 : Type*} [add_comm_monoid N\u2082] [module R N\u2082] \n{M\u2083 : Type*} [add_comm_monoid M\u2083] [module R M\u2083] \n{N\u2083 : Type*} [add_comm_monoid N\u2083] [module R N\u2083]\n\nnamespace tensor_product\n\nlemma map_assoc (f\u2081 : M\u2081 \u2192\u2097[R] N\u2081) (f\u2082 : M\u2082 \u2192\u2097[R] N\u2082) (f\u2083 : M\u2083 \u2192\u2097[R] N\u2083) : \n  (\u2191(tensor_product.assoc R N\u2081 N\u2082 N\u2083)) \u2218\u2097 (tensor_product.map (tensor_product.map f\u2081 f\u2082) f\u2083)\n  = (tensor_product.map (f\u2081 : M\u2081 \u2192\u2097[R] N\u2081) (tensor_product.map f\u2082 f\u2083)) \u2218\u2097 \n  \u2191(tensor_product.assoc R M\u2081 M\u2082 M\u2083) := \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 [\u2190 hx,\u2190 hy] },\nend\n\nlemma lid_comm_ltensor (f\u2081 : M\u2081 \u2192\u2097[R] N\u2081) : \u2191(tensor_product.lid R N\u2081) \u2218\u2097 \n  (tensor_product.map (linear_map.id : R \u2192\u2097[R] R) f\u2081) =  f\u2081 \u2218\u2097 \u2191(tensor_product.lid R M\u2081) :=\nby apply tensor_product.ext'; simp [linear_map.comp_apply]\n\nlemma rid_comm_rtensor (f\u2081 : M\u2081 \u2192\u2097[R] N\u2081) : \u2191(tensor_product.rid R N\u2081) \u2218\u2097 \n  (tensor_product.map f\u2081 (linear_map.id : R \u2192\u2097[R] R)) =  f\u2081 \u2218\u2097 \u2191(tensor_product.rid R M\u2081) :=\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 \u2297 A \u2192\u2097[R] A) \u2218\u2097 (_root_.tensor_product.map (lmul' R) \n  (linear_map.id : A \u2192\u2097[R] A)) = (lmul' R : A \u2297 A \u2192\u2097[R] A) \u2218\u2097\n  (_root_.tensor_product.map linear_map.id (lmul' R)) \u2218\u2097 \u2191(_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 [\u2190hx, \u2190hy] }\nend\n\nlemma algebra_map_id_left : (lmul' R : A \u2297 A \u2192\u2097[R] A) \u2218\u2097 \n  (_root_.tensor_product.map (algebra.linear_map R A) linear_map.id) = \n  \u2191(_root_.tensor_product.lid R A) := \nby apply tensor_product.ext'; simp[algebra.smul_def]\n\nlemma algebra_map_id_right : (lmul' R : A \u2297 A \u2192\u2097[R] A) \u2218\u2097 \n  (_root_.tensor_product.map linear_map.id (algebra.linear_map R A) ) = \n  \u2191(_root_.tensor_product.rid R A) := \nby apply tensor_product.ext'; simp[\u2190 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 \u2192\u2097[R] R)\n(comul  : C \u2192\u2097[R] (C \u2297[R] C))\n(counit_left : \u2191(tensor_product.lid R C) \u2218\u2097 (tensor_product.map counit linear_map.id) \u2218\u2097 comul = \n  (linear_map.id : C \u2192\u2097[R] C))\n(counit_right : \u2191(tensor_product.rid R C) \u2218\u2097 (tensor_product.map linear_map.id counit) \u2218\u2097 comul =\n  (linear_map.id : C \u2192\u2097[R] C))\n(coassoc : \u2191(tensor_product.assoc R C C C) \u2218\u2097 (tensor_product.map comul linear_map.id) \u2218\u2097 comul = \n    (tensor_product.map linear_map.id  comul) \u2218\u2097 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 \u2192\u2097[R] A \n\nvariables {R} {C} {A}\n\nlemma coassoc' : (tensor_product.map comul linear_map.id) \u2218\u2097 (comul : C \u2192\u2097[R] C \u2297 C) = \n  \u2191(tensor_product.assoc R C C C).symm \u2218\u2097 (tensor_product.map linear_map.id comul) \n  \u2218\u2097 (comul : C \u2192\u2097[R] C \u2297 C) :=\nbegin\n  rw [\u2190linear_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 \u2297\u209c[R] c\n\nnamespace conv_alg\n\ninstance : has_mul (conv_alg R C A) :=\n \u27e8\u03bb f g, (algebra.lmul' R) \u2218\u2097 (tensor_product.map f g) \u2218\u2097 comul\u27e9\n\n@[simp] \nlemma mul_def (f g : conv_alg R C A) : \n  f * g = (algebra.lmul' R) \u2218\u2097 (tensor_product.map f g) \u2218\u2097 comul := rfl \n\ninstance : has_one (conv_alg R C A) := \u27e8(algebra.linear_map R A) \u2218\u2097 counit\u27e9\n\n@[simp]\nlemma one_def : (1 : conv_alg R C A) = (algebra.linear_map R A) \u2218\u2097 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 [\u2190 linear_map.id_comp f,tensor_product.map_comp, \u2190 linear_map.comp_id f,\n        \u2190 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 \u2192\u2097[R] C \u2297 C)) = ((algebra.lmul' R : A \u2297 A \u2192\u2097[R] A) \u2218\u2097 \n      (tensor_product.map (algebra.linear_map R A) linear_map.id)) \u2218\u2097 \n      (tensor_product.map linear_map.id f) \u2218\u2097 \n      ((tensor_product.map counit linear_map.id) \u2218\u2097 (comul : C \u2192\u2097[R] C \u2297 C)),\n    { simp only [linear_map.comp_assoc] },\n  rw [hassoc, algebra.algebra_map_id_left, \u2190linear_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 [\u2190 linear_map.id_comp f,tensor_product.map_comp, \u2190 linear_map.comp_id f,\n        \u2190 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 \u2192\u2097[R] C \u2297 C)) = ((algebra.lmul' R : A \u2297 A \u2192\u2097[R] A) \u2218\u2097 \n      (tensor_product.map  linear_map.id (algebra.linear_map R A) )) \u2218\u2097 \n      (tensor_product.map f linear_map.id) \u2218\u2097 \n      ((tensor_product.map linear_map.id counit) \u2218\u2097 (comul : C \u2192\u2097[R] C \u2297 C)),\n    { simp only [linear_map.comp_assoc] },\n  rw [hassoc, algebra.algebra_map_id_right, \u2190linear_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 [\u2190 linear_map.comp_id f, \u2190 linear_map.comp_assoc,tensor_product.map_comp, \n        linear_map.comp_assoc, \u2190 coassoc, \u2190 linear_map.id_comp f, tensor_product.map_comp,\n        linear_map.comp_assoc],\n      congr, skip,\n      rw [\u2190 linear_map.comp_assoc,\u2190 tensor_product.map_assoc],\n    end,\n  conv_rhs\n    begin\n      simp only [\u2190 linear_map.comp_assoc],\n      congr, congr, congr,\n      rw  [linear_map.comp_assoc, \u2190 algebra.lmul'_assoc],\n    end,\n  simp[\u2190 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\u2081 : Type*) [add_comm_monoid C\u2081] [module R C\u2081] \n  [coalgebra R C\u2081] (C\u2082 : Type*) [add_comm_monoid C\u2082] [module R C\u2082] [coalgebra R C\u2082] :=\n(to_map : C\u2081 \u2192\u2097[R] C\u2082)\n(map_counit' : (coalgebra.counit \u2218\u2097 to_map : C\u2081 \u2192 R) = coalgebra.counit) \n(map_comul' : coalgebra.comul \u2218\u2097 to_map  = (tensor_product.map to_map to_map) \u2218\u2097 coalgebra.comul)\n\ninfixr ` \u2192\u1d9c `:25 := coalg_hom _\nnotation A ` \u2192\u1d9c[`: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 : \u2200 x y : B, counit (x * y) = (counit x) * (counit y))\n(comul_one : comul 1 = 1)\n(comul_mul : \u2200 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} {\u03b1 : Sort u} {t e : \u03b1}\n  {\u03b2 : Sort v} (f : \u03b1 \u2192 \u03b2) : 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 : \u2115) : n.succ < m.succ \u2194 n < m :=\n\u27e8nat.lt_of_succ_lt_succ, nat.succ_lt_succ\u27e9\n\ntheorem nat.sub_lt_sub_right : \u03a0 {n m k : \u2115} (h\u2081 : n < m) (h\u2082 : k \u2264 n), n - k < m - k\n| n     m     0     h\u2081 h\u2082 := h\u2081\n| (n+1) (m+1) (k+1) h\u2081 h\u2082 := by simp; apply nat.sub_lt_sub_right (nat.lt_of_succ_lt_succ h\u2081) (nat.le_of_succ_le_succ h\u2082)\n\ntheorem nat.le_sub_one_of_lt {a b : \u2115} (h : a < b) : a \u2264 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 {\u03b1 \u03b2 : Type u}\n@[simp]\nlemma nth_map (xs : list \u03b1) (f : \u03b1 \u2192 \u03b2) (i : \u2115) : (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 \u03b1) (i k : \u2115) : (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 \u03b1) (i k : \u2115) : (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 \u03b1) (i : \u2115) : (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 : \u2115)\n| top\n| \u00abfun\u00bb (domain body : type)\n| abs (bound body : type)\n| mu (rec : type)\n\nopen type\n\ninfixr ` \u2192\u209b `:55 := type.fun\nnotation `\u22000<: ` t `, ` s := abs t s\n\n/- Parallel substitution -/\n\ndef rename := \u2115 \u2192 \u2115\ndef rename.up (\u03be : rename) : rename\n| 0     := 0\n| (k+1) := \u03be k + 1\n\n@[simp]\ndef type.rename : rename \u2192 type \u2192 type\n| \u03be (var x)    := var (\u03be x)\n| \u03be top        := top\n| \u03be (a \u2192\u209b b)   := a.rename \u03be \u2192\u209b b.rename \u03be\n| \u03be (\u22000<:a, b) := \u22000<:a.rename \u03be, b.rename \u03be.up\n| \u03be (mu a)     := mu (a.rename \u03be.up)\n\ndef subst := \u2115 \u2192 type\ndef subst.up (\u03c3 : subst) : subst\n| 0     := var 0\n| (k+1) := (\u03c3 k).rename (+1)\n\n@[simp]\ndef type.subst : subst \u2192 type \u2192 type\n| \u03c3 (var x)    := \u03c3 x\n| \u03c3 top        := top\n| \u03c3 (a \u2192\u209b b)   := a.subst \u03c3 \u2192\u209b b.subst \u03c3\n| \u03c3 (\u22000<:a, b) := \u22000<:a.subst \u03c3, b.subst \u03c3.up\n| \u03c3 (mu a)     := mu (a.subst \u03c3.up)\n\ndef subst.comp (\u03c3' \u03c3 : subst) : subst := type.subst \u03c3' \u2218 \u03c3\n\ninfix ` \u2218\u209b `:90 := subst.comp\n\ndef lift_idx (k : \u2115) (d := 0) : rename :=\n\u03bb i, if i \u2265 d then i + k else i\n\ndef type.lift (a : type) (k : \u2115) (d := 0) : type :=\na.rename (lift_idx k d)\n\ndef instantiate_idx (r : type) (d := 0) : subst :=\n\u03bb 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 \u2192 \u2115\n| (var d)     := d + 1\n| top         := 0\n| (a \u2192\u209b b)    := max a.free_range b.free_range\n| (\u22000<: 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 \u2192 \u2115 \u2192 opt_param \u2115 0 \u2192 env\n| [] k d := []\n| (a::e) k d := a.lift k (d + e.length) :: env.lift e k d\n\ninductive sub : env \u2192 type \u2192 type \u2192 Prop\n  notation e ` \u22a2 `:40 a ` <: `:40 b:40 := sub e a b\n| var_refl (e x) : e \u22a2 var x <: var x\n| env {e x a b} : list.nth e x = some a \u2192 e \u22a2 a.lift (x+1) <: b \u2192 e \u22a2 var x <: b\n| top (e a) : e \u22a2 a <: top\n| \u00abfun\u00bb {e a a' b b'} : e \u22a2 a' <: a \u2192 e \u22a2 b <: b' \u2192 e \u22a2 a \u2192\u209b b <: a' \u2192\u209b b'\n| abs {e a a' b b'} : e \u22a2 a' <: a \u2192 a'::e \u22a2 b <: b' \u2192 e \u22a2 \u22000<:a, b <: \u22000<:a', b'\n-- violates the positivity restriction\n--| mu {e a a'} : (\u2200 b b', e \u22a2 b <: b' \u2192 e \u22a2 type.instantiate a b <: type.instantiate a' b') \u2192 e \u22a2 mu a <: mu a'\n| mu_refl (e a) : e \u22a2 mu a <: mu a\n| exp\u2097 {e a a'} : e \u22a2 type.expand a <: a' \u2192 e \u22a2 mu a <: a'\n| exp\u1d63 {e a a'} : e \u22a2 a <: type.expand a' \u2192 e \u22a2 a <: mu a'\n\nnotation e ` \u22a2 `:40 a:41 ` <: `:40 b:40 := sub e a b\nnotation a ` <: `:40 b:40 := sub [] a b\n\nlemma sub.refl : \u03a0 e a, e \u22a2 a <: a\n| e (var x)    := sub.var_refl e x\n| e top        := sub.top e top\n| e (a \u2192\u209b b)   := sub.fun (sub.refl e a) (sub.refl e b)\n| e (\u22000<: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 `\u27e6\u209b`:1000\ndef mu_helper := 0\nnotation `\u03bc ` binder `, ` a:scoped := mu_helper a\ndef ctx_helper := 0\nnotation `bctx ` binder <: a:50 `\u22a2` b:scoped := ctx_helper a b\n\nprivate meta def parse_type : \u2115 \u2192 \u2115 \u2192 pexpr \u2192 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 \u2190 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-- ``(\u2200 x <: %%a, %%b)\n| d d' (pi _ _ _ (pi _ _ (app (app (app (const `system_f_sub.sub []) _) (expr.var 0)) a) b)) :=\ndo a \u2190 parse_type (d+1) (d'+1) a, b \u2190 parse_type (d+1) (d'+1) b, pure ``(\u22000<:%%a, %%b)\n| d d' (expr.pi _ _ dom b) :=\nif (@unchecked_cast _ expr b).has_var_idx 0 then\n     do b \u2190 parse_type (d+1) d' b, pure ``(\u22000<:top, %%b)\n   else\n     do dom \u2190 parse_type d d' dom, b \u2190 parse_type d (d'+1) b, pure ``(%%dom \u2192\u209b %%b)\n| d d' e := match e.get_structure_instance_info with\n  | some info :=\n    do fields \u2190 (info.field_names.zip info.field_values).mmap (\u03bb \u27e8n, v\u27e9,\n      do v \u2190 parse_type d d' v,\n         pure ``(\u27e8%%(const (`system_f_sub.labels ++ n) [] : pexpr), %%v\u27e9)),\n    pure (app (const `system_f_sub.record []) (fields.foldr (\u03bb 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 \u2192 pexpr \u2192 parser pexpr\n| ctx (app (app (const ``ctx_helper _) a) (lam _ _ _ b)) :=\ndo a \u2190 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 \u2190 parse_type ctx.length 0 a,\n   b \u2190 parse_type ctx.length 0 b,\n   pure ``(sub %%(ctx.foldl (\u03bb ctx a, ``(%%a :: %%ctx)) ``([])) %%a %%b)\n| _ e := parse_type 0 0 e\n\nprivate meta def erase_all_annotations : expr \u2192 expr :=\n\u03bb e, expr.replace e (\u03bb 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 \"\u27e6\u209b\") (e : parse $ parser.pexpr <* tk \"\u27e7\") : 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 := \u22000<:top, var 0 \u2192\u209b var 0 \u2192\u209b var 0\ndef Bool := \u27e6\u209b \u2200 a, a \u2192 a \u2192 a \u27e7\ndef True := \u27e6\u209b \u2200 a, a \u2192 top \u2192 a \u27e7\ndef False := \u27e6\u209b \u2200 a, top \u2192 a \u2192 a \u27e7\ndef None := \u27e6\u209b \u2200 a, top \u2192 top \u2192 a \u27e7\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) := \u27e6\u209b \u2200 r, (a \u2192 b \u2192 r) \u2192 r \u27e7\ninfix ` \u00d7\u209b `:45 := prod\n\ndef tuple : list type \u2192 type\n| []      := top\n| (a::as) := a \u00d7\u209b tuple as\n\nstructure field :=\n(idx : \u2115)\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 (\u03bb i, (field.type <$> fields.find (\u03bb 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 (\u03be \u03be' : rename) : \u03be'.up \u2218 \u03be.up = rename.up (\u03be' \u2218 \u03be) :=\nbegin\n  apply funext, intro i,\n  cases i; simp [function.comp, rename.up]\nend\n\n@[simp]\nlemma rename_rename (a : type) (\u03be \u03be') : (a.rename \u03be).rename \u03be' = a.rename (\u03be' \u2218 \u03be) :=\nby induction a generalizing \u03be \u03be'; simp [*,rename_up_comp_rename_up]\n\nlemma subst_up_comp_rename_up (\u03be : rename) (\u03c3 : subst) : \u03c3.up \u2218 \u03be.up = subst.up (\u03c3 \u2218 \u03be) :=\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) (\u03be \u03c3) : (a.rename \u03be).subst \u03c3 = a.subst (\u03c3 \u2218 \u03be) :=\nby induction a generalizing \u03be \u03c3; simp [*,subst_up_comp_rename_up]\n\nlemma rename_up_comp_subst_up (\u03be : rename) (\u03c3 : subst) : type.rename \u03be.up \u2218 \u03c3.up = subst.up (type.rename \u03be \u2218 \u03c3) :=\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) (\u03be \u03c3) : (a.subst \u03c3).rename \u03be = a.subst (type.rename \u03be \u2218 \u03c3) :=\nby induction a generalizing \u03be \u03c3; simp [*,rename_up_comp_subst_up]\n\nlemma subst_up_comp_subst_up (\u03c3 \u03c3' : subst) : \u03c3'.up \u2218\u209b \u03c3.up = (\u03c3' \u2218\u209b \u03c3).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) (\u03c3 \u03c3') : (a.subst \u03c3).subst \u03c3' = a.subst (\u03c3' \u2218\u209b \u03c3) :=\nbegin\n  induction a generalizing \u03c3 \u03c3'; 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 \u2264 d' \u2192 d' \u2264 k + d \u2192 (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 \u2265 d,\n  { simp [ge, h, type.lift, lift_idx, le_trans \u2039d' \u2264 k + d\u203a (add_le_add_left h _)] },\n  { have : \u00acd' \u2264 i, from \u03bb hcontr, h (le_trans \u2039d \u2264 d'\u203a 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 \u2264 d' \u2192 (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 \u2264 d', from le_trans (nat.le_add_right _ _) \u2039k + d \u2264 d'\u203a,\n  by_cases i \u2265 d,\n  { by_cases d' \u2264 k + i with h',\n    { have : d' - k \u2264 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 : \u00ac d' - k \u2264 i, begin\n        assume hcontr, apply h',\n        have : d' - k + k \u2264 i + k, from nat.add_le_add_right hcontr k,\n        simp [nat.sub_add_cancel \u2039k \u2264 d'\u203a] 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 : \u00acd' - k \u2264 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 \u2039k + d \u2264 d'\u203a,\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 \u2264 d', from le_trans (nat.le_add_left _ _) \u2039k + d \u2264 d'\u203a,\n    have : \u00acd' \u2264 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 : \u2115) : n.succ \u2264 m \u2194 n < m := \u27e8nat.succ_le_of_lt, nat.lt_of_succ_le\u27e9\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 _) \u2039d < i\u203a,\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 \u2264 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 : \u00ac d \u2264 i, from h \u2218 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 {\u03b1 \u03b2 : Type} (f : \u03b1 \u2192 \u03b2) : f <$> none = none := rfl\n\n@[simp]\nlemma option_has_map_map_some {\u03b1 \u03b2 : Type} (f : \u03b1 \u2192 \u03b2) (x : \u03b1) : f <$> some x = f x := rfl\n\n@[simp]\nlemma env.nth_lift {e : env} (k d i) : (e.lift k d).nth i = (\u03bb 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 \u2260 d.succ, from h \u2218 nat.succ.inj,\n        simp [*] }\n    }\n  }\nend\n\nsection\nvariables (k d : \u2115)\n@[simp] def type.lift_idx (x : \u2115) : (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 \u2192\u209b b).lift k d = a.lift k d \u2192\u209b b.lift k d := rfl\n@[simp] def type.lift_abs (a b) : (\u22000<:a, b).lift k d = \u22000<: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 : \u2115) : (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 \u2192\u209b b).instantiate r d = a.instantiate r d \u2192\u209b b.instantiate r d := rfl\n@[simp] def type.instantiate_abs (a b) : (\u22000<: a, b).instantiate r d = \u22000<: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\u2081 e\u2082 : env} {a b c} : e\u2081 ++ e\u2082 \u22a2 a <: b \u2192 e\u2081.lift 1 ++ c::e\u2082 \u22a2 a.lift 1 e\u2081.length <: b.lift 1 e\u2081.length :=\nbegin\n  generalize he' : e\u2081 ++ e\u2082 = e',\n  intro h, induction h generalizing c e\u2081,\n  all_goals { simp [lift_idx, -add_comm], try {constructor; done} },\n  case sub.env e' x a b h\u2081 h\u2082 ih {\n    subst e',\n    by_cases x \u2265 e\u2081.length,\n    { simp [if_pos h], apply sub.env,\n      { have : \u00ac (x + 1 < e\u2081.length), from\n          \u03bb 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\u2081,\n        apply h\u2081 },\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 \u22a2 h\u2081,\n        -- HACK\n        show _ = some (a.lift 1 (e\u2081.length - 1 - x)),\n        simp [h\u2081], 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\u2081),\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\u2097 {\n    apply sub.exp\u2097,\n    simp only [expand_lift],\n    apply ih_1 he'\n  },\n  case sub.exp\u1d63 {\n    apply sub.exp\u1d63,\n    simp only [expand_lift],\n    apply ih_1 he'\n  }\nend\n\nlemma prod.sub {e : env} {a a' b b'} :\n  e \u22a2 a <: a' \u2192\n  e \u22a2 b <: b' \u2192\n  e \u22a2 a \u00d7\u209b b <: a' \u00d7\u209b 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 {\u03b1 \u03b2 : Type u} {a : \u03b1} {b : \u03b2} {p as bs} : p \u2208 list.zip as bs \u2192 p \u2208 list.zip (a::as) (b::bs) :=\nor.inr\n\nlemma list.sub {e : env} {as as'} : list.length as = list.length as' \u2192 (\u2200 p \u2208 as.zip as', e \u22a2 prod.fst p <: p.2) \u2192 e \u22a2 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 (\u03bb 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 _) \u2039d < i\u203a,\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 \u2260 d.succ, from h \u2218 nat.succ.inj] }\n  }\nend\n\n@[simp]\nlemma instantiate_tuple (as b d) : (tuple as).instantiate b d = tuple (as.map (\u03bb 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 \u2260 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 (\u03bb \u27e8i, a\u27e9, \u27e8i, a.instantiate b\u27e9)) :=\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 \u2265 (record_list fs').length \u2192\n  (\u2200 p : _ \u00d7 _, p \u2208 (record_list fs).zip (record_list fs') \u2192 e \u22a2 p.1 <: p.2) \u2192\n  e \u22a2 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 \u2264 m \u2192 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 \u2264 m, from le_trans (le_max_right _ _) h,\n      show body.free_range \u2264 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 \u2192 (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 : \u2115} : max a b \u2264 c \u2192 a \u2264 c :=\nbegin\n  intro h,\n  by_cases a \u2264 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 : \u2115} : max a b \u2264 c \u2192 b \u2264 c :=\nbegin\n  intro h,\n  by_cases a \u2264 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 \u2264 d \u2192 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 \u2192 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 \u2190 tactic.get_local `h >>= tactic.infer_type,\n    match h with\n    | `(_ \u2228 _) := `[\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 := \u27e6\u209b { a := Bool, b := top } \u27e7\ndef bar := \u27e6\u209b { a := Bool, b := Bool, c := Bool } \u27e7\n\nexample : bar <: foo :=\nrecord.sub dec_trivial (\u03bb \u27e8a, b\u27e9 h, begin\n  conv at h {\n    change (a, b) = (Bool, Bool) \u2228 _,\n    simp,\n  },\n  cases h with h h; simp [h],\n  { apply sub.refl },\n  { apply sub.top },\nend)\n\ndef A := \u27e6\u209b { a := Bool } \u27e7\ndef B := \u27e6\u209b \u2200 \u03b1 <: A, \u03bc \u03b2, { a := Bool, b := Bool \u2192 \u03b1 \u2192 \u03b2 } \u27e7\ndef C := \u27e6\u209b \u2200 \u03b1 <: A, { a := Bool, b := Bool \u2192 \u03b1 \u2192 A } \u27e7\n\n@[simp] lemma A.is_closed : A.closed :=\nshow A.free_range = 0, from rfl\n\nexample : B <: C :=\nbegin\n  suffices : \u27e6\u209b bctx \u03b1 <: A \u22a2\n    (\u03bc \u03b2, { a := Bool, b := Bool \u2192 \u03b1 \u2192 \u03b2 }) <:\n          { a := Bool, b := Bool \u2192 \u03b1 \u2192 A } \u27e7,\n    from sub.abs (sub.refl _ _) this,\n  suffices : \u27e6\u209b bctx \u03b1 <: A \u22a2\n    { a := Bool, b := Bool \u2192 \u03b1 \u2192 \u03bc \u03b2, { a := Bool, b := Bool \u2192 \u03b1 \u2192 \u03b2 } } <:\n    { a := Bool, b := Bool \u2192 \u03b1 \u2192 A } \u27e7,\n    from sub.exp\u2097 this,\n  record.fieldwise_eq,\n  show \u27e6\u209b bctx \u03b1 <: A \u22a2\n    (Bool \u2192 \u03b1 \u2192 \u03bc \u03b2, { a := Bool, b := Bool \u2192 \u03b1 \u2192 \u03b2 }) <:\n    (Bool \u2192 \u03b1 \u2192 A) \u27e7,\n  { suffices : \u27e6\u209b bctx \u03b1 <: A \u22a2 (\u03bc \u03b2, { a := Bool, b := Bool \u2192 \u03b1 \u2192 \u03b2 }) <: A \u27e7,\n      by simp at this; simp [sub.fun, sub.refl, this],\n    suffices : \u27e6\u209b bctx \u03b1 <: A \u22a2 { a := Bool, b := Bool \u2192 \u03b1 \u2192 (\u03bc \u03b2, { a := Bool, b := Bool \u2192 \u03b1 \u2192 \u03b2 }) } <: A \u27e7,\n      from sub.exp\u2097 this,\n    simp [lift_closed],\n    record.fieldwise_eq,\n    show [A] \u22a2 Bool <: Bool, from sub.refl _ _\n  },\n  show [A] \u22a2 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 \u2190 ident,\n   base \u2190 resolve_constant base,\n   env \u2190 get_env,\n   guard (env.is_inductive base) <|> fail \"expected inductive type\",\n   tk \"with\",\n   decl \u2190 inductive_decl.parse dmi,\n   [idecl] \u2190 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 \u2190 declaration.type <$> env.get base,\n   is \u2190 (env.constructors_of base).mmap (\u03bb ctor,\n     do ty \u2190 declaration.type <$> env.get ctor,\n     let ty := ty.replace (\u03bb 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 (\u03bb 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 \u00d7 expr \u00d7 bool) := do\n  (expr.const f_name _) \u2190 return e.get_app_fn,\n  es \u2190 get_eqn_lemmas_for ff f_name,\n  guard $ es.length > 1,\n  sl \u2190 es.mfoldl simp_lemmas.add_simp simp_lemmas.mk,\n  new_e \u2190 sl.drewrite e,\n  return (u, new_e, tt)\nin do e \u2190 target,\n      (c, new_e) \u2190 dsimplify_core () (\u03bb 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 \u2190 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 \u2964 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 := \u27e8{to_Top := { \u03b1 := pempty }}\u27e9\n\ninstance : has_coe_to_sort CompHaus Type* := \u27e8\u03bb X, X.to_Top\u27e9\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 := \u2039_\u203a,\n  is_hausdorff := \u2039_\u203a }\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 \u27f6 Y) : is_closed_map f :=\n\u03bb 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 \u27f6 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 \u2190 E.image_eq_preimage,\n    exact is_closed_map f S hS },\n  refine \u27e8\u27e8\u27e8E.symm, hE\u27e9, _, _\u27e9\u27e9,\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 \u27f6 Y) (bij : function.bijective f) : X \u2245 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} \u2964 Top.{u} := induced_functor _\n\ninstance CompHaus.forget_reflects_isomorphisms : reflects_isomorphisms (forget CompHaus.{u}) :=\n\u27e8by introsI A B f hf; exact CompHaus.is_iso_of_bijective _ ((is_iso_iff_bijective f).mp hf)\u27e9\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 \u27f6 Y) \u2243 (X \u27f6 CompHaus_to_Top.obj Y) :=\n{ to_fun := \u03bb f,\n  { to_fun := f \u2218 stone_cech_unit,\n    continuous_to_fun := f.2.comp (@continuous_stone_cech_unit X _) },\n  inv_fun := \u03bb 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 \u27e8f : stone_cech X \u27f6 Y, hf : continuous f\u27e9,\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 _ \u27e8y, rfl\u27e9,\n    apply congr_fun (stone_cech_extend_extends (hf.comp _)) y,\n  end,\n  right_inv :=\n  begin\n    rintro \u27e8f : (X : Type*) \u27f6 Y, hf : continuous f\u27e9,\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} \u2964 CompHaus.{u} :=\nadjunction.left_adjoint_of_equiv stone_cech_equivalence.{u} (\u03bb _ _ _ _ _, rfl)\n\nlemma Top_to_CompHaus_obj (X : Top) : \u21a5(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 := \u27e8Top_to_CompHaus, adjunction.adjunction_of_equiv_left _ _\u27e9 }\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 \u2964 CompHaus`, defined in terms of\n`Top.limit_cone`. -/\ndef limit_cone {J : Type v} [small_category J] (F : J \u2964 CompHaus.{max v u}) :\n  limits.cone F :=\n{ X :=\n  { to_Top := (Top.limit_cone (F \u22d9 CompHaus_to_Top)).X,\n    is_compact := begin\n      show compact_space \u21a5{u : \u03a0 j, (F.obj j) | \u2200 {i j : J} (f : i \u27f6 j), (F.map f) (u i) = u j},\n      rw \u2190 is_compact_iff_compact_space,\n      apply is_closed.is_compact,\n      have : {u : \u03a0 j, F.obj j | \u2200 {i j : J} (f : i \u27f6 j), F.map f (u i) = u j} =\n        \u22c2 (i j : J) (f : i \u27f6 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 \u21a5{u : \u03a0 j, (F.obj j) | \u2200 {i j : J} (f : i \u27f6 j), (F.map f) (u i) = u j},\n      from infer_instance },\n  \u03c0 :=\n  { app := \u03bb j, (Top.limit_cone (F \u22d9 CompHaus_to_Top)).\u03c0.app j,\n    naturality' := by { intros _ _ _, ext \u27e8x, hx\u27e9,\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 \u2964 CompHaus.{max v u}) :\n  limits.is_limit (limit_cone F) :=\n{ lift := \u03bb S,\n    (Top.limit_cone_is_limit (F \u22d9 CompHaus_to_Top)).lift (CompHaus_to_Top.map_cone S),\n  uniq' := \u03bb 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 \u27f6 Y) : epi f \u2194 function.surjective f :=\nbegin\n  split,\n  { contrapose!,\n    rintros \u27e8y, hy\u27e9 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 \u27e8y', hy'\u27e9, exact hy y' hy' },\n    haveI : normal_space \u21a5(Y.to_Top) := normal_of_compact_t2,\n    obtain \u27e8\u03c6, h\u03c60, h\u03c61, h\u03c601\u27e9 := exists_continuous_zero_one_of_closed hC hD hCD,\n    haveI : compact_space (ulift.{u} $ set.Icc (0:\u211d) 1) := homeomorph.ulift.symm.compact_space,\n    haveI : t2_space (ulift.{u} $ set.Icc (0:\u211d) 1) := homeomorph.ulift.symm.t2_space,\n    let Z := of (ulift.{u} $ set.Icc (0:\u211d) 1),\n    let g : Y \u27f6 Z := \u27e8\u03bb y', \u27e8\u27e8\u03c6 y', h\u03c601 y'\u27e9\u27e9,\n      continuous_ulift_up.comp (continuous_subtype_mk (\u03bb y', h\u03c601 y') \u03c6.continuous)\u27e9,\n    let h : Y \u27f6 Z := \u27e8\u03bb _, \u27e8\u27e80, set.left_mem_Icc.mpr zero_le_one\u27e9\u27e9, continuous_const\u27e9,\n    have H : h = g,\n    { rw \u2190 cancel_epi f,\n      ext x, dsimp,\n      simp only [comp_apply, continuous_map.coe_mk, subtype.coe_mk, h\u03c60 (set.mem_range_self x),\n        pi.zero_apply], },\n    apply_fun (\u03bb e, (e y).down) at H,\n    dsimp at H,\n    simp only [subtype.mk_eq_mk, h\u03c61 (set.mem_singleton y), pi.one_apply] at H,\n    exact zero_ne_one H, },\n  { rw \u2190 category_theory.epi_iff_surjective,\n    apply faithful_reflects_epi (forget CompHaus) },\nend\n\nlemma mono_iff_injective {X Y : CompHaus.{u}} (f : X \u27f6 Y) : mono f \u2194 function.injective f :=\nbegin\n  split,\n  { introsI hf x\u2081 x\u2082 h,\n    let g\u2081 : of punit \u27f6 X := \u27e8\u03bb _, x\u2081, continuous_of_discrete_topology\u27e9,\n    let g\u2082 : of punit \u27f6 X := \u27e8\u03bb _, x\u2082, continuous_of_discrete_topology\u27e9,\n    have : g\u2081 \u226b f = g\u2082 \u226b f, by { ext, exact h },\n    rw cancel_mono at this,\n    apply_fun (\u03bb e, e punit.star) at this,\n    exact this },\n  { rw \u2190 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 \u00a9 2019 Fran\u00e7ois 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 (\u03b1 : Type*) :=\n(op : \u03b1 \u2192 \u03b1 \u2192 \u03b1)\n(id : \u03b1)\n\nnamespace unital_sig\nvariables {\u03b1 : Type*} (s : unital_sig \u03b1)\n\n@[signature_instance]\ndefinition to_magma : magma_sig \u03b1 :=\n{ op := s.op\n}\n\nend unital_sig\n\nvariables {\u03b1 : Type*} (s : unital_sig \u03b1)\nlocal infix \u2219 := 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\u03bb x, show e \u2219 x = x, from calc _\n= x \u2219 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\u2081 v\u2082 u\u2081 u\u2082 -- morphism levels before object levels. See note [category_theory universes].\nvariables {T : Type u\u2081} [category.{v\u2081} 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 (\ud835\udfed T) X\n\n-- Satisfying the inhabited linter\ninstance over.inhabited [inhabited T] : inhabited (over (default : T)) :=\n{ default :=\n  { left := default,\n    hom := \ud835\udfd9 _ } }\n\nnamespace over\n\nvariables {X : T}\n\n@[ext] lemma over_morphism.ext {X : T} {U V : over X} {f g : U \u27f6 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 (\ud835\udfd9 U) = \ud835\udfd9 U.left := rfl\n@[simp] lemma comp_left (a b c : over X) (f : a \u27f6 b) (g : b \u27f6 c) :\n  (f \u226b g).left = f.left \u226b g.left := rfl\n\n@[simp, reassoc] lemma w {A B : over X} (f : A \u27f6 B) : f.left \u226b 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 V.left) (w : f \u226b V.hom = U.hom . obviously) :\n  U \u27f6 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 \u2245 g.left) (hw : hl.hom \u226b g.hom = f.hom . obviously) :\n  f \u2245 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 \u2964 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 \u27f6 V} : (forget X).map f = f.left := rfl\n\n/-- The natural cocone over the forgetful functor `over X \u2964 T` with cocone point `X`. -/\n@[simps] def forget_cocone (X : T) : limits.cocone (forget X) :=\n{ X := X, \u03b9 := { app := comma.hom } }\n\n/--\nA morphism `f : X \u27f6 Y` induces a functor `over X \u2964 over Y` in the obvious way.\n\nSee https://stacks.math.columbia.edu/tag/001G.\n-/\ndef map {Y : T} (f : X \u27f6 Y) : over X \u2964 over Y := comma.map_right _ $ discrete.nat_trans (\u03bb _, f)\n\nsection\nvariables {Y : T} {f : X \u27f6 Y} {U V : over X} {g : U \u27f6 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 \u226b 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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f \u226b g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map f \u22d9 map g :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := \u03bb Y Z f t, by exactI\n  \u27e8\u27e8over.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\u27e9\u27e9 }\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 \u27f6 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 \u27f6 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 \u27f6 g) [mono k] : mono k.left :=\nbegin\n  refine \u27e8\u03bb (Y : T) l m a, _\u27e9,\n  let l' : mk (m \u226b f.hom) \u27f6 f := hom_mk l (by { dsimp, rw [\u2190over.w k, reassoc_of a] }),\n  suffices : l' = hom_mk m,\n  { apply congr_arg comma_morphism.left this },\n  rw \u2190 cancel_mono k,\n  ext,\n  apply a,\nend\n\nsection iterated_slice\nvariables (f : over X)\n\n/-- Given f : Y \u27f6 X, this is the obvious functor from (T/X)/f to T/Y -/\n@[simps]\ndef iterated_slice_forward : over f \u2964 over f.left :=\n{ obj := \u03bb \u03b1, over.mk \u03b1.hom.left,\n  map := \u03bb \u03b1 \u03b2 \u03ba, over.hom_mk \u03ba.left.left (by { rw auto_param_eq, rw \u2190 over.w \u03ba, refl }) }\n\n/-- Given f : Y \u27f6 X, this is the obvious functor from T/Y to (T/X)/f -/\n@[simps]\ndef iterated_slice_backward : over f.left \u2964 over f :=\n{ obj := \u03bb g, mk (hom_mk g.hom : mk (g.hom \u226b f.hom) \u27f6 f),\n  map := \u03bb g h \u03b1, hom_mk (hom_mk \u03b1.left (w_assoc \u03b1 f.hom)) (over_morphism.ext (w \u03b1)) }\n\n/-- Given f : Y \u27f6 X, we have an equivalence between (T/X)/f and T/Y -/\n@[simps]\ndef iterated_slice_equiv : over f \u224c over f.left :=\n{ functor := iterated_slice_forward f,\n  inverse := iterated_slice_backward f,\n  unit_iso :=\n    nat_iso.of_components\n    (\u03bb g, over.iso_mk (over.iso_mk (iso.refl _) (by tidy)) (by tidy))\n    (\u03bb X Y g, by { ext, dsimp, simp }),\n  counit_iso :=\n    nat_iso.of_components\n    (\u03bb g, over.iso_mk (iso.refl _) (by tidy))\n    (\u03bb X Y g, by { ext, dsimp, simp }) }\n\nlemma iterated_slice_forward_forget :\n  iterated_slice_forward f \u22d9 forget f.left = forget f \u22d9 forget X :=\nrfl\n\nlemma iterated_slice_backward_forget_forget :\n  iterated_slice_backward f \u22d9 forget f \u22d9 forget X = forget f.left :=\nrfl\n\nend iterated_slice\n\nsection\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `F : T \u2964 D` induces a functor `over X \u2964 over (F.obj X)` in the obvious way. -/\n@[simps]\ndef post (F : T \u2964 D) : over X \u2964 over (F.obj X) :=\n{ obj := \u03bb Y, mk $ F.map Y.hom,\n  map := \u03bb Y\u2081 Y\u2082 f,\n  { left := F.map f.left,\n    w' := by tidy; erw [\u2190 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 (\ud835\udfed T)\n\n-- Satisfying the inhabited linter\ninstance under.inhabited [inhabited T] : inhabited (under (default : T)) :=\n{ default :=\n  { right := default,\n    hom := \ud835\udfd9 _ } }\n\nnamespace under\n\nvariables {X : T}\n\n@[ext] lemma under_morphism.ext {X : T} {U V : under X} {f g : U \u27f6 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 (\ud835\udfd9 U) = \ud835\udfd9 U.right := rfl\n@[simp] lemma comp_right (a b c : under X) (f : a \u27f6 b) (g : b \u27f6 c) :\n  (f \u226b g).right = f.right \u226b g.right := rfl\n\n@[simp, reassoc] lemma w {A B : under X} (f : A \u27f6 B) : A.hom \u226b 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 \u27f6 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 \u27f6 V.right) (w : U.hom \u226b f = V.hom . obviously) :\n  U \u27f6 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 \u2245 g.right) (hw : f.hom \u226b hr.hom = g.hom) : f \u2245 g :=\nstructured_arrow.iso_mk hr hw\n\n@[simp]\nlemma iso_mk_hom_right {f g : under X} (hr : f.right \u2245 g.right) (hw : f.hom \u226b 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 \u2245 g.right) (hw : f.hom \u226b 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 \u2964 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 \u27f6 V} : (forget X).map f = f.right := rfl\n\n/-- The natural cone over the forgetful functor `under X \u2964 T` with cone point `X`. -/\n@[simps] def forget_cone (X : T) : limits.cone (forget X) :=\n{ X := X, \u03c0 := { app := comma.hom } }\n\n/-- A morphism `X \u27f6 Y` induces a functor `under Y \u2964 under X` in the obvious way. -/\ndef map {Y : T} (f : X \u27f6 Y) : under Y \u2964 under X := comma.map_left _ $ discrete.nat_trans (\u03bb _, f)\n\nsection\nvariables {Y : T} {f : X \u27f6 Y} {U V : under Y} {g : U \u27f6 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 \u226b 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 (\ud835\udfd9 Y) \u2245 \ud835\udfed _ :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\n/-- Mapping by the composite morphism `f \u226b g` is the same as mapping by `f` then by `g`. -/\ndef map_comp {Y Z : T} (f : X \u27f6 Y) (g : Y \u27f6 Z) : map (f \u226b g) \u2245 map g \u22d9 map f :=\nnat_iso.of_components (\u03bb X, iso_mk (iso.refl _) (by tidy)) (by tidy)\n\nend\n\ninstance forget_reflects_iso : reflects_isomorphisms (forget X) :=\n{ reflects := \u03bb Y Z f t, by exactI\n  \u27e8\u27e8under.hom_mk (inv ((under.forget X).map f)) ((is_iso.comp_inv_eq _).2 (under.w f).symm),\n    by tidy\u27e9\u27e9 }\n\ninstance forget_faithful : faithful (forget X) := {}.\n\nsection\nvariables {D : Type u\u2082} [category.{v\u2082} D]\n\n/-- A functor `F : T \u2964 D` induces a functor `under X \u2964 under (F.obj X)` in the obvious way. -/\n@[simps]\ndef post {X : T} (F : T \u2964 D) : under X \u2964 under (F.obj X) :=\n{ obj := \u03bb Y, mk $ F.map Y.hom,\n  map := \u03bb Y\u2081 Y\u2082 f,\n  { right := F.map f.right,\n    w' := by tidy; erw [\u2190 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 \u00d7 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 \u2264 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 \u00d7 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 \u2243o add_submonoid (additive M) :=\n{ to_fun := \u03bb S,\n  { carrier := additive.to_mul \u207b\u00b9' S,\n    zero_mem' := S.one_mem',\n    add_mem' := S.mul_mem' },\n  inv_fun := \u03bb S,\n  { carrier := additive.of_mul \u207b\u00b9' S,\n    one_mem' := S.zero_mem',\n    mul_mem' := S.add_mem' },\n  left_inv := \u03bb x, by cases x; refl,\n  right_inv := \u03bb x, by cases x; refl,\n  map_rel_iff' := \u03bb 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) \u2243o 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 \u207b\u00b9' 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 \u207b\u00b9' 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 \u2243o submonoid (multiplicative A) :=\n{ to_fun := \u03bb S,\n  { carrier := multiplicative.to_add \u207b\u00b9' S,\n    one_mem' := S.zero_mem',\n    mul_mem' := S.add_mem' },\n  inv_fun := \u03bb S,\n  { carrier := multiplicative.of_add \u207b\u00b9' S,\n    zero_mem' := S.one_mem',\n    add_mem' := S.mul_mem' },\n  left_inv := \u03bb x, by cases x; refl,\n  right_inv := \u03bb x, by cases x; refl,\n  map_rel_iff' := \u03bb 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) \u2243o 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 \u207b\u00b9' 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 \u207b\u00b9' 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 \u2192* N) (S : submonoid N) : submonoid M :=\n{ carrier := (f \u207b\u00b9' S),\n  one_mem' := show f 1 \u2208 S, by rw f.map_one; exact S.one_mem,\n  mul_mem' := \u03bb a b ha hb,\n    show f (a * b) \u2208 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 \u2192* N) : (S.comap f : set M) = f \u207b\u00b9' S := rfl\n\n@[simp, to_additive]\nlemma mem_comap {S : submonoid N} {f : M \u2192* N} {x : M} : x \u2208 S.comap f \u2194 f x \u2208 S := iff.rfl\n\n@[to_additive]\nlemma comap_comap (S : submonoid P) (g : N \u2192* P) (f : M \u2192* 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 \u2192* N) (S : submonoid M) : submonoid N :=\n{ carrier := (f '' S),\n  one_mem' := \u27e81, S.one_mem, f.map_one\u27e9,\n  mul_mem' := begin rintros _ _ \u27e8x, hx, rfl\u27e9 \u27e8y, hy, rfl\u27e9, exact \u27e8x * y, S.mul_mem hx hy,\n    by rw f.map_mul; refl\u27e9 end }\n\n@[simp, to_additive]\nlemma coe_map (f : M \u2192* N) (S : submonoid M) :\n  (S.map f : set N) = f '' S := rfl\n\n@[simp, to_additive]\nlemma mem_map {f : M \u2192* N} {S : submonoid M} {y : N} :\n  y \u2208 S.map f \u2194 \u2203 x \u2208 S, f x = y :=\nmem_image_iff_bex\n\n@[to_additive]\nlemma mem_map_of_mem (f : M \u2192* N) {S : submonoid M} {x : M} (hx : x \u2208 S) : f x \u2208 S.map f :=\nmem_image_of_mem f hx\n\n@[to_additive]\nlemma apply_coe_mem_map (f : M \u2192* N) (S : submonoid M) (x : S) : f x \u2208 S.map f :=\nmem_map_of_mem f x.prop\n\n@[to_additive]\nlemma map_map (g : N \u2192* P) (f : M \u2192* 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 \u2192* N} (hf : function.injective f) {S : submonoid M} {x : M} :\n  f x \u2208 S.map f \u2194 x \u2208 S :=\nhf.mem_set_image\n\n@[to_additive]\nlemma map_le_iff_le_comap {f : M \u2192* N} {S : submonoid M} {T : submonoid N} :\n  S.map f \u2264 T \u2194 S \u2264 T.comap f :=\nimage_subset_iff\n\n@[to_additive]\nlemma gc_map_comap (f : M \u2192* N) : galois_connection (map f) (comap f) :=\n\u03bb S T, map_le_iff_le_comap\n\n@[to_additive]\nlemma map_le_of_le_comap {T : submonoid N} {f : M \u2192* N} : S \u2264 T.comap f \u2192 S.map f \u2264 T :=\n(gc_map_comap f).l_le\n\n@[to_additive]\nlemma le_comap_of_map_le {T : submonoid N} {f : M \u2192* N} : S.map f \u2264 T \u2192 S \u2264 T.comap f :=\n(gc_map_comap f).le_u\n\n@[to_additive]\nlemma le_comap_map {f : M \u2192* N} : S \u2264 (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 \u2192* N} : (S.comap f).map f \u2264 S :=\n(gc_map_comap f).l_u_le _\n\n@[to_additive]\nlemma monotone_map {f : M \u2192* N} : monotone (map f) :=\n(gc_map_comap f).monotone_l\n\n@[to_additive]\nlemma monotone_comap {f : M \u2192* N} : monotone (comap f) :=\n(gc_map_comap f).monotone_u\n\n@[simp, to_additive]\nlemma map_comap_map {f : M \u2192* 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 \u2192* 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 \u2192* N) : (S \u2294 T).map f = S.map f \u2294 T.map f :=\n(gc_map_comap f).l_sup\n\n@[to_additive]\nlemma map_supr {\u03b9 : Sort*} (f : M \u2192* N) (s : \u03b9 \u2192 submonoid M) :\n  (supr s).map f = \u2a06 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 \u2192* N) : (S \u2293 T).comap f = S.comap f \u2293 T.comap f :=\n(gc_map_comap f).u_inf\n\n@[to_additive]\nlemma comap_infi {\u03b9 : Sort*} (f : M \u2192* N) (s : \u03b9 \u2192 submonoid N) :\n  (infi s).comap f = \u2a05 i, (s i).comap f :=\n(gc_map_comap f).u_infi\n\n@[simp, to_additive] lemma map_bot (f : M \u2192* N) : (\u22a5 : submonoid M).map f = \u22a5 :=\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 (\u03bb x, \u27e8\u03bb \u27e8_, h, rfl\u27e9, h, \u03bb h, \u27e8_, h, rfl\u27e9\u27e9)\n\nsection galois_coinsertion\n\nvariables {\u03b9 : Type*} {f : M \u2192* 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  (\u03bb 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 \u2293 T.map f).comap f = S \u2293 T :=\n(gci_map_comap hf).u_inf_l _ _\n\n@[to_additive]\nlemma comap_infi_map_of_injective (S : \u03b9 \u2192 submonoid M) : (\u2a05 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 \u2294 T.map f).comap f = S \u2294 T :=\n(gci_map_comap hf).u_sup_l _ _\n\n@[to_additive]\nlemma comap_supr_map_of_injective (S : \u03b9 \u2192 submonoid M) : (\u2a06 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 \u2264 T.map f \u2194 S \u2264 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 {\u03b9 : Type*} {f : M \u2192* 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  (\u03bb S x h, let \u27e8y, hy\u27e9 := hf x in mem_map.2 \u27e8y, by simp [hy, h]\u27e9)\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 \u2293 T.comap f).map f = S \u2293 T :=\n(gi_map_comap hf).l_inf_u _ _\n\n@[to_additive]\nlemma map_infi_comap_of_surjective (S : \u03b9 \u2192 submonoid N) : (\u2a05 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 \u2294 T.comap f).map f = S \u2294 T :=\n(gi_map_comap hf).l_sup_u _ _\n\n@[to_additive]\nlemma map_supr_comap_of_surjective (S : \u03b9 \u2192 submonoid N) : (\u2a06 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 \u2264 T.comap f \u2194 S \u2264 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 := \u27e8\u03bb a b, \u27e8a.1 * b.1, S.mul_mem a.2 b.2\u27e9\u27e9\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 := \u27e8\u27e8_, S.one_mem\u27e9\u27e9\n\n@[simp, norm_cast, to_additive] lemma coe_mul (x y : S) : (\u2191(x * y) : M) = \u2191x * \u2191y := 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 \u2208 S) (hy : y \u2208 S) :\n  (\u27e8x, hx\u27e9 : S) * \u27e8y, hy\u27e9 = \u27e8x * y, S.mul_mem hx hy\u27e9 := rfl\n\n@[to_additive] lemma mul_def (x y : S) : x * y = \u27e8x * y, S.mul_mem x.2 y.2\u27e9 := rfl\n@[to_additive] lemma one_def : (1 : S) = \u27e81, S.one_mem\u27e9 := 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 (\u03bb _ _, 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 \u2192* M := \u27e8coe, rfl, \u03bb _ _, rfl\u27e9\n\n@[simp, to_additive] theorem coe_subtype : \u21d1S.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 \u2192* N) (hf : function.injective f) : S \u2243* S.map f :=\n{ map_mul' := \u03bb _ _, 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 \u2192* 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 \u2192 Prop}\n  (Hs : \u2200 x (h : x \u2208 s), p \u27e8x, subset_closure h\u27e9)\n  (H1 : p 1)\n  (Hmul : \u2200 x y, p x \u2192 p y \u2192 p (x * y))\n  (x : closure s) :\n  p x :=\nsubtype.rec_on x $ \u03bb x hx, begin\n  refine exists.elim _ (\u03bb (hx : x \u2208 closure s) (hc : p \u27e8x, hx\u27e9), hc),\n  exact closure_induction hx\n    (\u03bb x hx, \u27e8subset_closure hx, Hs x hx\u27e9)\n    \u27e8one_mem _, H1\u27e9\n    (\u03bb x y hx hy, exists.elim hx $ \u03bb hx' hx, exists.elim hy $ \u03bb hy' hy,\n      \u27e8mul_mem _ hx' hy', Hmul _ _ hx hy\u27e9),\nend\n\n@[simp, to_additive]\nlemma closure_closure_coe_preimage {s : set M} : closure ((coe : closure s \u2192 M) \u207b\u00b9' s) = \u22a4 :=\nbegin\n  refine eq_top_iff.2 (\u03bb x hx, closure_induction' (\u03bb x, _) _ _ (\u03bb g\u2081 g\u2082 hg\u2081 hg\u2082, _) x),\n  { intros g hg,\n    exact subset_closure hg },\n  { exact submonoid.one_mem _ },\n  { exact submonoid.mul_mem _ hg\u2081 hg\u2082 },\nend\n\n/-- Given `submonoid`s `s`, `t` of monoids `M`, `N` respectively, `s \u00d7 t` as a submonoid\nof `M \u00d7 N`. -/\n@[to_additive prod \"Given `add_submonoid`s `s`, `t` of `add_monoid`s `A`, `B` respectively, `s \u00d7 t`\nas an `add_submonoid` of `A \u00d7 B`.\"]\ndef prod (s : submonoid M) (t : submonoid N) : submonoid (M \u00d7 N) :=\n{ carrier := (s : set M).prod t,\n  one_mem' := \u27e8s.one_mem, t.one_mem\u27e9,\n  mul_mem' := \u03bb p q hp hq, \u27e8s.mul_mem hp.1 hq.1, t.mul_mem hp.2 hq.2\u27e9 }\n\n@[to_additive coe_prod]\nlemma coe_prod (s : submonoid M) (t : submonoid N) :\n (s.prod t : set (M \u00d7 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 \u00d7 N} :\n  p \u2208 s.prod t \u2194 p.1 \u2208 s \u2227 p.2 \u2208 t := iff.rfl\n\n@[to_additive prod_mono]\nlemma prod_mono {s\u2081 s\u2082 : submonoid M} {t\u2081 t\u2082 : submonoid N} (hs : s\u2081 \u2264 s\u2082) (ht : t\u2081 \u2264 t\u2082) :\n  s\u2081.prod t\u2081 \u2264 s\u2082.prod t\u2082 :=\nset.prod_mono hs ht\n\n@[to_additive prod_top]\nlemma prod_top (s : submonoid M) :\n  s.prod (\u22a4 : submonoid N) = s.comap (monoid_hom.fst M N) :=\next $ \u03bb x, by simp [mem_prod, monoid_hom.coe_fst]\n\n@[to_additive top_prod]\nlemma top_prod (s : submonoid N) :\n  (\u22a4 : submonoid M).prod s = s.comap (monoid_hom.snd M N) :=\next $ \u03bb x, by simp [mem_prod, monoid_hom.coe_snd]\n\n@[simp, to_additive top_prod_top]\nlemma top_prod_top : (\u22a4 : submonoid M).prod (\u22a4 : submonoid N) = \u22a4 :=\n(top_prod _).trans $ comap_top _\n\n@[to_additive] lemma bot_prod_bot : (\u22a5 : submonoid M).prod (\u22a5 : submonoid N) = \u22a5 :=\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 \u2243* s \u00d7 t :=\n{ map_mul' := \u03bb x y, rfl, .. equiv.set.prod \u2191s \u2191t }\n\nopen monoid_hom\n\n@[to_additive]\nlemma map_inl (s : submonoid M) : s.map (inl M N) = s.prod \u22a5 :=\next $ \u03bb p, \u27e8\u03bb \u27e8x, hx, hp\u27e9, hp \u25b8 \u27e8hx, set.mem_singleton 1\u27e9,\n  \u03bb \u27e8hps, hp1\u27e9, \u27e8p.1, hps, prod.ext rfl $ (set.eq_of_mem_singleton hp1).symm\u27e9\u27e9\n\n@[to_additive]\nlemma map_inr (s : submonoid N) : s.map (inr M N) = prod \u22a5 s :=\next $ \u03bb p, \u27e8\u03bb \u27e8x, hx, hp\u27e9, hp \u25b8 \u27e8set.mem_singleton 1, hx\u27e9,\n  \u03bb \u27e8hp1, hps\u27e9, \u27e8p.2, hps, prod.ext (set.eq_of_mem_singleton hp1).symm rfl\u27e9\u27e9\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 \u22a5) \u2294 (prod \u22a5 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 \u25b8 mul_mem _\n  ((le_sup_left : s.prod \u22a5 \u2264 s.prod \u22a5 \u2294 prod \u22a5 t) \u27e8hp.1, set.mem_singleton 1\u27e9)\n  ((le_sup_right : prod \u22a5 t \u2264 s.prod \u22a5 \u2294 prod \u22a5 t) \u27e8set.mem_singleton 1, hp.2\u27e9)\n\n@[to_additive]\nlemma mem_map_equiv {f : M \u2243* N} {K : submonoid M} {x : N} :\n  x \u2208 K.map f.to_monoid_hom \u2194 f.symm x \u2208 K :=\n@set.mem_image_equiv _ _ \u2191K f.to_equiv x\n\n@[to_additive]\nlemma map_equiv_eq_comap_symm (f : M \u2243* 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 \u2243* 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 `\u21a5(set.range f)` and `\u21a5f.range` are\ninterchangeable without proof obligations.\n\nA convenient candidate definition for range which is mathematically correct is `map \u22a4 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 \u2208 \u22a4`\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 `(\u22a4 : 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 \u25b8 S.one_mem',\n  mul_mem' := hs.symm \u25b8 S.mul_mem' }\n```\nand then finally define:\n```lean\ndef mrange (f : M \u2192* N) : submonoid N :=\n((\u22a4 : 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 \u2192* N) : submonoid N :=\n((\u22a4 : submonoid M).map f).copy (set.range f) set.image_univ.symm\n\n@[simp, to_additive]\nlemma coe_mrange (f : M \u2192* N) :\n  (f.mrange : set N) = set.range f :=\nrfl\n\n@[simp, to_additive] lemma mem_mrange {f : M \u2192* N} {y : N} :\n  y \u2208 f.mrange \u2194 \u2203 x, f x = y :=\niff.rfl\n\n@[to_additive] lemma mrange_eq_map (f : M \u2192* N) : f.mrange = (\u22a4 : submonoid M).map f :=\ncopy_eq _\n\n@[to_additive]\nlemma map_mrange (g : N \u2192* P) (f : M \u2192* N) : f.mrange.map g = (g.comp f).mrange :=\nby simpa only [mrange_eq_map] using (\u22a4 : submonoid M).map_map g f\n\n@[to_additive]\nlemma mrange_top_iff_surjective {N} [mul_one_class N] {f : M \u2192* N} :\n  f.mrange = (\u22a4 : submonoid N) \u2194 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 \u2192* N) (hf : function.surjective f) :\n  f.mrange = (\u22a4 : submonoid N) :=\nmrange_top_iff_surjective.2 hf\n\n@[to_additive]\nlemma mclosure_preimage_le (f : M \u2192* N) (s : set N) :\n  closure (f \u207b\u00b9' s) \u2264 (closure s).comap f :=\nclosure_le.2 $ \u03bb 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 \u2192* 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 \u2192* N) (S : submonoid M) : S \u2192* N :=\nf.comp S.subtype\n\n@[simp, to_additive]\nlemma mrestrict_apply {N : Type*} [mul_one_class N] (f : M \u2192* 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 \u2192* N) (S : submonoid N) (h : \u2200 x, f x \u2208 S) : M \u2192* S :=\n{ to_fun := \u03bb n, \u27e8f n, h n\u27e9,\n  map_one' := subtype.eq f.map_one,\n  map_mul' := \u03bb 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 \u2192* N) : M \u2192* f.mrange :=\nf.cod_mrestrict f.mrange $ \u03bb x, \u27e8x, rfl\u27e9\n\n@[simp, to_additive]\nlemma coe_mrange_restrict {N} [mul_one_class N] (f : M \u2192* 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 \u2192* N) : submonoid M := (\u22a5 : submonoid N).comap f\n\n@[to_additive]\nlemma mem_mker (f : M \u2192* N) {x : M} : x \u2208 f.mker \u2194 f x = 1 := iff.rfl\n\n@[to_additive]\nlemma coe_mker (f : M \u2192* N) : (f.mker : set M) = (f : M \u2192 N) \u207b\u00b9' {1} := rfl\n\n@[to_additive]\ninstance decidable_mem_mker [decidable_eq N] (f : M \u2192* N) :\n  decidable_pred (\u2208 f.mker) :=\n\u03bb x, decidable_of_iff (f x = 1) f.mem_mker\n\n@[to_additive]\nlemma comap_mker (g : N \u2192* P) (f : M \u2192* N) : g.mker.comap f = (g.comp f).mker := rfl\n\n@[simp, to_additive] lemma comap_bot' (f : M \u2192* N) :\n  (\u22a5 : submonoid N).comap f = f.mker := rfl\n\n@[to_additive] lemma range_restrict_mker (f : M \u2192* N) : mker (mrange_restrict f) = mker f :=\nbegin\n  ext,\n  change (\u27e8f x, _\u27e9 : mrange f) = \u27e81, _\u27e9 \u2194 f x = 1,\n  simp only [],\nend\n\n@[simp, to_additive]\nlemma mker_one : (1 : M \u2192* N).mker = \u22a4 :=\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 \u2192* N) (g : M' \u2192* 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 \u2192* N)\n  (g : M' \u2192* N') : (prod_map f g).mker = f.mker.prod g.mker :=\nby rw [\u2190comap_bot', \u2190comap_bot', \u2190comap_bot', \u2190prod_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 \u22a4 \u22a5 :=\nby simpa only [mrange_eq_map] using map_inl \u22a4\n\n@[to_additive]\nlemma mrange_inr : (inr M N).mrange = prod \u22a5 \u22a4 :=\nby simpa only [mrange_eq_map] using map_inr \u22a4\n\n@[to_additive]\nlemma mrange_inl' : (inl M N).mrange = comap (snd M N) \u22a5 := mrange_inl.trans (top_prod _)\n\n@[to_additive]\nlemma mrange_inr' : (inr M N).mrange = comap (fst M N) \u22a5 := mrange_inr.trans (prod_top _)\n\n@[simp, to_additive]\nlemma mrange_fst : (fst M N).mrange = \u22a4 :=\n(fst M N).mrange_top_of_surjective $ @prod.fst_surjective _ _ \u27e81\u27e9\n\n@[simp, to_additive]\nlemma mrange_snd : (snd M N).mrange = \u22a4 :=\n(snd M N).mrange_top_of_surjective $ @prod.snd_surjective _ _ \u27e81\u27e9\n@[simp, to_additive]\n\nlemma mrange_inl_sup_mrange_inr : (inl M N).mrange \u2294 (inr M N).mrange = \u22a4 :=\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 \u2264 T) : S \u2192* T :=\nS.subtype.cod_mrestrict _ (\u03bb 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 = \u22a4 \u2194 \u2200 x : M, x \u2208 S :=\neq_top_iff.trans \u27e8\u03bb h m, h $ mem_top m, \u03bb h m _, h m\u27e9\n\n@[to_additive] lemma eq_bot_iff_forall : S = \u22a5 \u2194 \u2200 x \u2208 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 \u2194 \u2203 x \u2208 S, x \u2260 (1:M) :=\ncalc nontrivial S \u2194 \u2203 x : S, x \u2260 1                                   : nontrivial_iff_exists_ne 1\n              ... \u2194 \u2203 x (hx : x \u2208 S), (\u27e8x, hx\u27e9 : S) \u2260 \u27e81, S.one_mem\u27e9 : subtype.exists\n              ... \u2194 \u2203 x \u2208 S, x \u2260 (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 = \u22a5 \u2228 nontrivial S :=\nby simp only [eq_bot_iff_forall, nontrivial_iff_exists_ne_one, \u2190 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 = \u22a5 \u2228 \u2203 x \u2208 S, x \u2260 (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 \u2243* T :=\n{ map_mul' :=  \u03bb _ _, 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 \u2192* N` with a left-inverse `g : N \u2192 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 \u2192+ N` with a left-inverse `g : N \u2192 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 \u2192* N) {g : N \u2192 M} (h : function.left_inverse g f) : M \u2243* f.mrange :=\n{ to_fun := f.mrange_restrict,\n  inv_fun := g \u2218 f.mrange.subtype,\n  left_inv := h,\n  right_inv := \u03bb x, subtype.ext $\n    let \u27e8x', hx'\u27e9 := monoid_hom.mem_mrange.mp x.prop in\n    show f (g x) = x, by rw [\u2190hx', h x'],\n  .. f.mrange_restrict }\n\n/-- A `mul_equiv` `\u03c6` between two monoids `M` and `N` induces a `mul_equiv` between\na submonoid `S \u2264 M` and the submonoid `\u03c6(S) \u2264 N`. -/\n@[to_additive \"An `add_equiv` `\u03c6` between two additive monoids `M` and `N` induces an `add_equiv`\nbetween a submonoid `S \u2264 M` and the submonoid `\u03c6(S) \u2264 N`. \", simps]\ndef submonoid_equiv_map (e : M \u2243* N) (S : submonoid M) : S \u2243* S.map e.to_monoid_hom :=\n{ to_fun := \u03bb x, \u27e8e x, _\u27e9,\n  inv_fun := \u03bb x, \u27e8e.symm x, _\u27e9, -- we restate this for `simps` to avoid `\u21d1e.symm.to_equiv x`\n  map_mul' := \u03bb _ _, 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 \u2022 a` onto the\naction by an element `s : S` of a submonoid `S : submonoid M` such that `s \u2022 a = (s : M) \u2022 a`.\n\nThese instances work particularly well in conjunction with `monoid.to_mul_action`, enabling\n`s \u2022 m` as an alias for `\u2191s * m`.\n-/\n\nnamespace submonoid\n\nvariables {M' : Type*} {\u03b1 \u03b2 : 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' \u03b1] (S : submonoid M') : mul_action S \u03b1 :=\nmul_action.comp_hom _ S.subtype\n\n@[to_additive]\nlemma smul_def [mul_action M' \u03b1] {S : submonoid M'} (g : S) (m : \u03b1) : g \u2022 m = (g : M') \u2022 m := rfl\n\n/-- The action by a submonoid is the action by the underlying monoid. -/\ninstance [add_monoid \u03b1] [distrib_mul_action M' \u03b1] (S : submonoid M') : distrib_mul_action S \u03b1 :=\ndistrib_mul_action.comp_hom _ S.subtype\n\n/-- The action by a submonoid is the action by the underlying monoid. -/\ninstance [monoid \u03b1] [mul_distrib_mul_action M' \u03b1] (S : submonoid M') : mul_distrib_mul_action S \u03b1 :=\nmul_distrib_mul_action.comp_hom _ S.subtype\n\n@[to_additive]\ninstance smul_comm_class_left\n  [mul_action M' \u03b2] [has_scalar \u03b1 \u03b2] [smul_comm_class M' \u03b1 \u03b2] (S : submonoid M') :\n  smul_comm_class S \u03b1 \u03b2 :=\n\u27e8\u03bb a, (smul_comm (a : M') : _)\u27e9\n\n@[to_additive]\ninstance smul_comm_class_right\n  [has_scalar \u03b1 \u03b2] [mul_action M' \u03b2] [smul_comm_class \u03b1 M' \u03b2] (S : submonoid M') :\n  smul_comm_class \u03b1 S \u03b2 :=\n\u27e8\u03bb a s, (smul_comm a (s : M') : _)\u27e9\n\n/-- Note that this provides `is_scalar_tower S M' M'` which is needed by `smul_mul_assoc`. -/\ninstance\n  [has_scalar \u03b1 \u03b2] [mul_action M' \u03b1] [mul_action M' \u03b2] [is_scalar_tower M' \u03b1 \u03b2] (S : submonoid M') :\n  is_scalar_tower S \u03b1 \u03b2 :=\n\u27e8\u03bb a, (smul_assoc (a : M') : _)\u27e9\n\nexample {S : submonoid M'} : is_scalar_tower S M' M' := by apply_instance\n\ninstance [mul_action M' \u03b1] [has_faithful_scalar M' \u03b1] (S : submonoid M') :\n  has_faithful_scalar S \u03b1 :=\n{ eq_of_smul_eq_smul := \u03bb 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 {\u03b1 : Type u}\n\nsection ind\n\nopen nat\n\nparameter {\u03b1' : Type u}\n\nvariables {P : \u2200 {n : \u2115}, vector \u03b1' n \u2192 Prop}\nvariables {n : \u2115} (v : vector \u03b1' n)\nvariables h\u2080 : P nil\nvariables hn : \u2200 {n : \u2115} (x : \u03b1') (v : vector \u03b1' n), P v \u2192 P (x :: v)\n\ninclude hn\n\nlemma induction : \u2200 {n : \u2115} (v : vector \u03b1' n), P v\n | 0 \u27e8[],P\u27e9 := h\u2080\n | (succ n) \u27e8x :: xs, P\u27e9 :=\n begin\n   apply hn x \u27e8xs,_\u27e9 (induction \u27e8xs, _\u27e9),\n   have P' : succ (list.length xs) = succ n, { apply P },\n   injection P',\n end\n\nlemma induction_on : P v := induction h\u2080 @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 \u2124 :=\n\u27e8\u03bb i, if i.val < 2^31 then i.val else i.val - 2^32\u27e9\n\ninstance : comm_ring int32 := by unfold int32; apply_instance\n\ninstance : decidable_eq int32 :=\n\u03bb x y, decidable_of_iff _ (zmod.val_injective _).eq_iff\n\ntheorem coe_inj {i j : int32} : (i : \u2124) = j \u2194 i = j :=\n\u27e8\u03bb h : (ite (i.val < 2 ^ 31) i.val (i.val - 2 ^ 32) : \u2124) =\n       ite (j.val < 2 ^ 31) j.val (j.val - 2 ^ 32), begin\n  rw \u2190 (_ : ((2 ^ 32 : \u2115) : \u2124) = 2 ^ 32) at h,\n  swap, {apply int.coe_nat_pow},\n  split_ifs at h with h\u2081 h\u2082,\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 [\u2190 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 _\u27e9\n\ninstance : decidable_linear_order int32 :=\n{ decidable_le := \u03bb x y, int.decidable_le _ _,\n  decidable_eq := int32.decidable_eq,\n  ..linear_order.lift (coe : int32 \u2192 \u2124) (\u03bb _ _, coe_inj.1) }\n\ntheorem coe_le {i j : int32} : (i : \u2124) \u2264 j \u2194 i \u2264 j := iff.rfl\n\ntheorem coe_lt {i j : int32} : (i : \u2124) < j \u2194 i < j :=\nby rw [\u2190 not_le, coe_le, not_le]\n\ntheorem coe_zero : ((0 : int32) : \u2124) = 0 :=\nby unfold_coes; exact if_pos (nat.pow_pos dec_trivial _)\n\ndef of_int (n : \u2124) : option int32 :=\nif -2^31 \u2264 n \u2227 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 \u2264 n \u2227 n < 32 then of_int (int.shiftl m n) else none\n\ndef shr (m n : int32) : option int32 :=\nif 0 \u2264 n \u2227 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 : \u2115 \u2192 List \u03b1 \u2192 List \u03b1 \u00d7 List \u03b1\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 : \u2115 \u2192 List \u03b1 \u2192 \u03b1 \u2192 List \u03b1 \u00d7 List \u03b1\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 {\u03b1 : Type u} (P : \u03b1 \u2192 Prop) [DecidablePred P] : List \u03b1 \u2192 (List \u03b1 \u2192 List \u03b1) \u2192 List (List \u03b1)\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 {\u03b1 : Type u} (P : \u03b1 \u2192 Prop) [DecidablePred P] (l : List \u03b1) : List (List \u03b1) :=\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 {\u03b1 : Type u} [DecidableEq \u03b1] (a : \u03b1) (as : List \u03b1) : List (List \u03b1) :=\n  as.splitOnP (\u00b7 = 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 \u03b1 \u2192 List \u03b1) : \u2115 \u2192 List \u03b1 \u2192 List \u03b1\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 : \u03b1 \u2192 \u03b1) : List \u03b1 \u2192 List \u03b1\n| [] => []\n| a :: l => f a :: l\n\n/-- Apply `f` to the nth element of the list, if it exists. -/\ndef modifyNth (f : \u03b1 \u2192 \u03b1) : \u2115 \u2192 List \u03b1 \u2192 List \u03b1 :=\n  modifyNthTail (modifyHead f)\n\n/-- Apply `f` to the last element of `l`, if it exists. -/\n@[simp]\ndef modifyLast (f : \u03b1 \u2192 \u03b1) : List \u03b1 \u2192 List \u03b1\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 : \u2115) (a : \u03b1) : List \u03b1 \u2192 List \u03b1 :=\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 : \u2200 n : \u2115, List \u03b1 \u2192 \u03b1 \u2192 List \u03b1\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b1) : \u03b1 \u2192 List \u03b2 \u2192 List \u03b1\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) : List \u03b1 \u2192 \u03b2 \u00d7 List \u03b2\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (l : List \u03b1) : List \u03b2 :=\n  let (b', l') := scanrAux f b l\n  b' :: l'\n\n/-- Given a function `f : \u03b1 \u2192 \u03b2 \u2295 \u03b3`, `partitionMap f l` maps the list by `f`\n  whilst partitioning the result it into a pair of lists, `list \u03b2 \u00d7 list \u03b3`,\n  partitioning the `sum.inl _` into the left list, and the `sum.inr _` into the right List.\n  `partitionMap (id : \u2115 \u2295 \u2115 \u2192 \u2115 \u2295 \u2115) [inl 0, inr 1, inl 2] = ([0,2], [1])`    -/\ndef partitionMap (f : \u03b1 \u2192 \u03b2 \u2295 \u03b3) : List \u03b1 \u2192 List \u03b2 \u00d7 List \u03b3\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 : \u03b1 \u2192 Prop) [DecidablePred p] : List \u03b1 \u2192 Option \u03b1\n| [] => none\n| a :: l => if p a then some a else find p l\n\n/-- Auxiliary definition for `foldlIdx`. -/\ndef foldlIdxAux (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) : \u2115 \u2192 \u03b1 \u2192 List \u03b2 \u2192 \u03b1\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b1) (a : \u03b1) (l : List \u03b2) : \u03b1 :=\n  foldlIdxAux f 0 a l\n\n/-- Auxiliary definition for `foldrIdx`. -/\ndef foldrIdxAux (f : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) : \u2115 \u2192 \u03b2 \u2192 List \u03b1 \u2192 \u03b2\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 : \u2115 \u2192 \u03b1 \u2192 \u03b2 \u2192 \u03b2) (b : \u03b2) (l : List \u03b1) : \u03b2 :=\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 : \u03b1 \u2192 Prop) [DecidablePred p] (l : List \u03b1) : 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 : \u03b1 \u2192 Prop) [DecidablePred p] (l : List \u03b1) : List (\u2115 \u00d7 \u03b1) :=\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 \u03b1] (a : \u03b1) : List \u03b1 \u2192 List Nat :=\n  findIdxs (Eq a)\n\n/-- `lookmap` is a combination of `lookup` and `filterMap`.\n  `lookmap f l` will apply `f : \u03b1 \u2192 option \u03b1` to each element of the list,\n  replacing `a \u2192 b` at the first value `a` in the list such that `f a = some b`. -/\ndef lookmap (f : \u03b1 \u2192 Option \u03b1) : List \u03b1 \u2192 List \u03b1\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 : \u03b1 \u2192 Prop) [DecidablePred p] : List \u03b1 \u2192 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 \u03b1] (a : \u03b1) : List \u03b1 \u2192 Nat :=\n  countp (Eq a)\n\n/-- `isPrefix l\u2081 l\u2082`, or `l\u2081 <+: l\u2082`, means that `l\u2081` is a prefix of `l\u2082`,\n  that is, `l\u2082` has the form `l\u2081 ++ t` for some `t`. -/\ndef isPrefix (l\u2081 : List \u03b1) (l\u2082 : List \u03b1) : Prop :=\n  \u2203 t, l\u2081 ++ t = l\u2082\n\n/-- `isSuffix l\u2081 l\u2082`, or `l\u2081 <:+ l\u2082`, means that `l\u2081` is a suffix of `l\u2082`,\n  that is, `l\u2082` has the form `t ++ l\u2081` for some `t`. -/\ndef isSuffix (l\u2081 : List \u03b1) (l\u2082 : List \u03b1) : Prop :=\n  \u2203 t, t ++ l\u2081 = l\u2082\n\n/-- `isInfix l\u2081 l\u2082`, or `l\u2081 <:+: l\u2082`, means that `l\u2081` is a contiguous\n  substring of `l\u2082`, that is, `l\u2082` has the form `s ++ l\u2081 ++ t` for some `s, t`. -/\ndef isInfix (l\u2081 : List \u03b1) (l\u2082 : List \u03b1) : Prop :=\n  \u2203 s t, s ++ l\u2081 ++ t = l\u2082\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 \u03b1 \u2192 List (List \u03b1)\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 \u03b1 \u2192 List (List \u03b1)\n| [] => [[]]\n| a :: l => (a :: l) :: tails l\n\ndef sublists'Aux : List \u03b1 \u2192 (List \u03b1 \u2192 List \u03b2) \u2192 List (List \u03b2) \u2192 List (List \u03b2)\n| [], f, r => f [] :: r\n| a :: l, f, r => sublists'Aux l f (sublists'Aux l (f \u2218 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 \u03b1) : List (List \u03b1) :=\n  sublists'Aux l id []\n\ndef sublistsAux : List \u03b1 \u2192 (List \u03b1 \u2192 List \u03b2 \u2192 List \u03b2) \u2192 List \u03b2\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 \u03b1) : List (List \u03b1) :=\n  [] :: sublistsAux l cons\n\ndef sublistsAux\u2081 : List \u03b1 \u2192 (List \u03b1 \u2192 List \u03b2) \u2192 List \u03b2\n| [], f => []\n| a :: l, f => f [a] ++ sublistsAux\u2081 l fun ys => f ys ++ f (a :: ys)\n\nsection Forall\u2082\n\nvariable {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop}\n\n/-- `Forall\u2082 R l\u2081 l\u2082` means that `l\u2081` and `l\u2082` have the same length,\n  and whenever `a` is the nth element of `l\u2081`, and `b` is the nth element of `l\u2082`,\n  then `R a b` is satisfied. -/\ninductive Forall\u2082 (R : \u03b1 \u2192 \u03b2 \u2192 Prop) : List \u03b1 \u2192 List \u03b2 \u2192 Prop\n  | nil : Forall\u2082 R [] []\n  | cons {a b l\u2081 l\u2082} : R a b \u2192 Forall\u2082 R l\u2081 l\u2082 \u2192 Forall\u2082 R (a :: l\u2081) (b :: l\u2082)\n\nattribute [simp] Forall\u2082.nil\n\nend Forall\u2082\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\u2081, l\u2082, l\u2083] = [a::l\u2081, b::l\u2082, c::l\u2083]` -/\ndef transposeAux : List \u03b1 \u2192 List (List \u03b1) \u2192 List (List \u03b1)\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 \u03b1) \u2192 List (List \u03b1)\n| [] => []\n| l :: ls => transposeAux l (transpose ls)\n\n/-- List of all sections through a list of lists. A section\n  of `[L\u2081, L\u2082, ..., L\u2099]` is a list whose first element comes from\n  `L\u2081`, whose second element comes from `L\u2082`, and so on. -/\ndef sections : List (List \u03b1) \u2192 List (List \u03b1)\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 : \u03b1 \u2192 Prop) [DecidablePred p] : List \u03b1 \u2192 List \u03b1\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 : \u03b1 \u2192 Prop) [DecidablePred p] : List \u03b1 \u2192 Option \u03b1 \u00d7 List \u03b1\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 \u03b1) : List (\u03b1 \u00d7 \u03b1) :=\n  zip l l.reverse\n\n/-- `product l\u2081 l\u2082` is the list of pairs `(a, b)` where `a \u2208 l\u2081` and `b \u2208 l\u2082`.\n```\nproduct [1, 2] [5, 6] = [(1, 5), (1, 6), (2, 5), (2, 6)]\n``` -/\ndef product (l\u2081 : List \u03b1) (l\u2082 : List \u03b2) : List (\u03b1 \u00d7 \u03b2) :=\n  l\u2081.bind $ fun a => l\u2082.map $ Prod.mk a\n\n/-- `sigma l\u2081 l\u2082` is the list of dependent pairs `(a, b)` where `a \u2208 l\u2081` and `b \u2208 l\u2082 a`.\n```\nsigma [1, 2] (\u03bb_, [(5 : \u2115), 6]) = [(1, 5), (1, 6), (2, 5), (2, 6)]\n``` -/\nprotected def sigma {\u03c3 : \u03b1 \u2192 Type _} (l\u2081 : List \u03b1) (l\u2082 : \u2200 a, List (\u03c3 a)) : List (\u03a3 a, \u03c3 a) :=\n  l\u2081.bind $ fun a => (l\u2082 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 \u2192 \u03b1) : \u2200 m, m \u2264 n \u2192 List \u03b1 \u2192 List \u03b1\n| 0, h, l => l\n| m+1, h, l => ofFnAux f m (Nat.le_of_lt h) (f \u27e8m, h\u27e9 :: l)\n\n/-- `ofFn f` with `f : fin n \u2192 \u03b1` 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 \u2192 \u03b1) : List \u03b1 :=\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 \u2192 \u03b1) (i : \u2115) : Option \u03b1 :=\n  if h : i < n then some (f \u27e8i, h\u27e9) else none\n\n/-- `disjoint l\u2081 l\u2082` means that `l\u2081` and `l\u2082` have no elements in common. -/\ndef disjoint (l\u2081 l\u2082 : List \u03b1) : Prop :=\n  \u2200 \u2983a\u2984, a \u2208 l\u2081 \u2192 a \u2208 l\u2082 \u2192 False\n\nsection Pairwise\n\nvariable (R : \u03b1 \u2192 \u03b1 \u2192 Prop)\n\n-- ././Mathport/Syntax/Translate/Basic.lean:452:2: warning: expanding binder collection (a' \u00abexpr \u2208 \u00bb 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] \u2194 R 1 2 \u2227 R 1 3 \u2227 R 2 3\n  For example if `R = (\u2260)` then it asserts `l` has no duplicates,\n  and if `R = (<)` then it asserts that `l` is (strictly) sorted. -/\ninductive Pairwise : List \u03b1 \u2192 Prop\n  | nil : Pairwise []\n  | cons : \u2200 {a : \u03b1} {l : List \u03b1}, (\u2200 a' \u2208 l, R a a') \u2192 Pairwise l \u2192 Pairwise (a :: l)\n\nend Pairwise\n\n-- ././Mathport/Syntax/Translate/Basic.lean:452:2: warning: expanding binder collection (y \u00abexpr \u2208 \u00bb IH)\n/-- `pwFilter R l` is a maximal sublist of `l` which is `Pairwise R`.\n  `pwFilter (\u2260)` 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 : \u03b1 \u2192 \u03b1 \u2192 Prop) [DecidableRel R] : List \u03b1 \u2192 List \u03b1\n| [] => []\n| x :: xs =>\n  let IH := pwFilter R xs\n  if \u2200 y \u2208 IH, R x y then x :: IH else IH\n\nsection Chain\n\nvariable (R : \u03b1 \u2192 \u03b1 \u2192 Prop)\n\n/-- `Chain R a l` means that `R` holds between adjacent elements of `a::l`.\n```\nChain R a [b, c, d] \u2194 R a b \u2227 R b c \u2227 R c d\n``` -/\ninductive Chain : \u03b1 \u2192 List \u03b1 \u2192 Prop\n  | nil {a : \u03b1} : Chain a []\n  | cons : \u2200 {a b : \u03b1} {l : List \u03b1}, R a b \u2192 Chain b l \u2192 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] \u2194 R a b \u2227 R b c \u2227 R c d\n``` -/\ndef Chain' : List \u03b1 \u2192 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 (\u2260)`. -/\ndef Nodup : List \u03b1 \u2192 Prop :=\n  Pairwise (\u00b7 \u2260 \u00b7)\n\n/-- `eraseDup l` removes duplicates from `l` (taking only the first occurrence).\n  Defined as `pwFilter (\u2260)`.\n\n    eraseDup [1, 0, 2, 2, 1] = [0, 2, 1] -/\ndef eraseDup [DecidableEq \u03b1] : List \u03b1 \u2192 List \u03b1 :=\n  pwFilter (\u00b7 \u2260 \u00b7)\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' : \u2115 \u2192 \u2115 \u2192 List \u2115\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 {\u03b1} : List (Option \u03b1) \u2192 List \u03b1 :=\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' {\u03b1} : \u03b1 \u2192 List \u03b1 \u2192 \u03b1\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' {\u03b1} : List \u03b1 \u2192 Option \u03b1\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 \u03b1) (n : \u2115) : List \u03b1 :=\n  let (l\u2081, l\u2082) := List.splitAt (n % l.length) l\n  l\u2082 ++ l\u2081\n\n/-- rotate' is the same as `rotate`, but slower. Used for proofs about `rotate`-/\ndef rotate' : List \u03b1 \u2192 \u2115 \u2192 List \u03b1\n| [], n => []\n| l, 0 => l\n| a :: l, n+1 => rotate' (l ++ [a]) n\n\ndef mmap {m : Type u \u2192 Type v} [Monad m] {\u03b1 \u03b2} (f : \u03b1 \u2192 m \u03b2) : List \u03b1 \u2192 m (List \u03b2)\n| [] => pure []\n| h :: t => return (\u2190 f h) :: (\u2190 mmap f t)\n\ndef mmap' {m : Type \u2192 Type v} [Monad m] {\u03b1 \u03b2} (f : \u03b1 \u2192 m \u03b2) : List \u03b1 \u2192 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 \u2192 Type v} [Monad m] {\u03b1 \u03b2} (f : \u03b1 \u2192 m (Option \u03b2)) : List \u03b1 \u2192 m (List \u03b2)\n| [] => pure []\n| h :: t => do\n  let b \u2190 f h\n  let t' \u2190 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 \u00d7 l`.\nThat is, for each `e \u2208 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 [\u2190 f 1 1, \u2190 f 1 2, \u2190 f 1 3, \u2190 f 2 2, \u2190 f 2 3, \u2190 f 3 3]\n``` -/\ndef mmapUpperTriangle {m} [Monad m] {\u03b1 \u03b2 : Type u} (f : \u03b1 \u2192 \u03b1 \u2192 m \u03b2) : List \u03b1 \u2192 m (List \u03b2)\n| [] => pure []\n| h :: t => return (\u2190 f h h) :: (\u2190 t.mmap (f h)) ++ (\u2190 t.mmapUpperTriangle f)\n\n/--\n`mmap'Diag f l` calls `f` on all elements in the upper triangular part of `l \u00d7 l`.\nThat is, for each `e \u2208 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] {\u03b1} (f : \u03b1 \u2192 \u03b1 \u2192 m Unit) : List \u03b1 \u2192 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 \u2192 Type v} [Applicative F] {\u03b1 \u03b2} (f : \u03b1 \u2192 F \u03b2) : List \u03b1 \u2192 F (List \u03b2)\n| [] => pure []\n| x :: xs => cons <$> f x <*> List.traverse f xs\n\n/-- `getRest l l\u2081` returns `some l\u2082` if `l = l\u2081 ++ l\u2082`.\n  If `l\u2081` is not a prefix of `l`, returns `none` -/\ndef getRest [DecidableEq \u03b1] : List \u03b1 \u2192 List \u03b1 \u2192 Option (List \u03b1)\n| l, [] => some l\n| [], _ => none\n| x :: l, y :: l\u2081 => if x = y then getRest l l\u2081 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 {\u03b1} : \u2115 \u2192 \u2115 \u2192 List \u03b1 \u2192 List \u03b1\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\u2082`. `map\u2082Left' f as bs` applies `f` to each\npair of elements `a\u1d62 \u2208 as` and `b\u1d62 \u2208 bs`. If `bs` is shorter than `as`, `f` is\napplied to `none` for the remaining `a\u1d62`. Returns the results of the `f`\napplications and the remaining `bs`.\n```\nmap\u2082Left' prod.mk [1, 2] ['a'] = ([(1, some 'a'), (2, none)], [])\nmap\u2082Left' prod.mk [1] ['a', 'b'] = ([(1, some 'a')], ['b'])\n```\n-/\n@[simp]\ndef map\u2082Left' (f : \u03b1 \u2192 Option \u03b2 \u2192 \u03b3) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3 \u00d7 List \u03b2\n| [], bs => ([], bs)\n| a :: as, [] => ((a :: as).map fun a => f a none, [])\n| a :: as, b :: bs => let r := map\u2082Left' f as bs; (f a (some b) :: r.1, r.2)\n\n/--\nRight-biased version of `List.map\u2082`. `map\u2082Right' f as bs` applies `f` to each\npair of elements `a\u1d62 \u2208 as` and `b\u1d62 \u2208 bs`. If `as` is shorter than `bs`, `f` is\napplied to `none` for the remaining `b\u1d62`. Returns the results of the `f`\napplications and the remaining `as`.\n```\nmap\u2082Right' prod.mk [1] ['a', 'b'] = ([(some 1, 'a'), (none, 'b')], [])\nmap\u2082Right' prod.mk [1, 2] ['a'] = ([(some 1, 'a')], [2])\n```\n-/\ndef map\u2082Right' (f : Option \u03b1 \u2192 \u03b2 \u2192 \u03b3) (as : List \u03b1) (bs : List \u03b2) : List \u03b3 \u00d7 List \u03b1 :=\n  map\u2082Left' (flip f) bs as\n\n/--\nLeft-biased version of `List.zip`. `zipLeft' as bs` returns the list of\npairs `(a\u1d62, b\u1d62)` for `a\u1d62 \u2208 as` and `b\u1d62 \u2208 bs`. If `bs` is shorter than `as`, the\nremaining `a\u1d62` 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\u2082Left' prod.mk\n```\n-/\ndef zipLeft' : List \u03b1 \u2192 List \u03b2 \u2192 List (\u03b1 \u00d7 Option \u03b2) \u00d7 List \u03b2 :=\n  map\u2082Left' Prod.mk\n\n/--\nRight-biased version of `List.zip`. `zipRight' as bs` returns the list of\npairs `(a\u1d62, b\u1d62)` for `a\u1d62 \u2208 as` and `b\u1d62 \u2208 bs`. If `as` is shorter than `bs`, the\nremaining `b\u1d62` 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\u2082Right' prod.mk\n```\n-/\ndef zipRight' : List \u03b1 \u2192 List \u03b2 \u2192 List (Option \u03b1 \u00d7 \u03b2) \u00d7 List \u03b1 :=\n  map\u2082Right' Prod.mk\n\n/--\nLeft-biased version of `List.map\u2082`. `map\u2082Left f as bs` applies `f` to each pair\n`a\u1d62 \u2208 as` and `b\u1d62 \u200c\u2208 bs`. If `bs` is shorter than `as`, `f` is applied to `none`\nfor the remaining `a\u1d62`.\n```\nmap\u2082Left prod.mk [1, 2] ['a'] = [(1, some 'a'), (2, none)]\nmap\u2082Left prod.mk [1] ['a', 'b'] = [(1, some 'a')]\nmap\u2082Left f as bs = (map\u2082Left' f as bs).fst\n```\n-/\n@[simp]\ndef map\u2082Left (f : \u03b1 \u2192 Option \u03b2 \u2192 \u03b3) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3\n| [], _ => []\n| a :: as, [] => (a :: as).map fun a => f a none\n| a :: as, b :: bs => f a (some b) :: map\u2082Left f as bs\n\n/--\nRight-biased version of `List.map\u2082`. `map\u2082Right f as bs` applies `f` to each\npair `a\u1d62 \u2208 as` and `b\u1d62 \u200c\u2208 bs`. If `as` is shorter than `bs`, `f` is applied to\n`none` for the remaining `b\u1d62`.\n```\nmap\u2082Right prod.mk [1, 2] ['a'] = [(some 1, 'a')]\nmap\u2082Right prod.mk [1] ['a', 'b'] = [(some 1, 'a'), (none, 'b')]\nmap\u2082Right f as bs = (map\u2082Right' f as bs).fst\n```\n-/\ndef map\u2082Right (f : Option \u03b1 \u2192 \u03b2 \u2192 \u03b3) (as : List \u03b1) (bs : List \u03b2) : List \u03b3 :=\n  map\u2082Left (flip f) bs as\n\n/--\nLeft-biased version of `List.zip`. `zipLeft as bs` returns the list of pairs\n`(a\u1d62, b\u1d62)` for `a\u1d62 \u2208 as` and `b\u1d62 \u2208 bs`. If `bs` is shorter than `as`, the\nremaining `a\u1d62` are paired with `none`.\n```\nzipLeft [1, 2] ['a'] = [(1, some 'a'), (2, none)]\nzipLeft [1] ['a', 'b'] = [(1, some 'a')]\nzipLeft = map\u2082Left prod.mk\n```\n-/\ndef zipLeft : List \u03b1 \u2192 List \u03b2 \u2192 List (\u03b1 \u00d7 Option \u03b2) :=\n  map\u2082Left Prod.mk\n\n/--\nRight-biased version of `List.zip`. `zipRight as bs` returns the list of pairs\n`(a\u1d62, b\u1d62)` for `a\u1d62 \u2208 as` and `b\u1d62 \u2208 bs`. If `as` is shorter than `bs`, the\nremaining `b\u1d62` are paired with `none`.\n```\nzipRight [1, 2] ['a'] = [(some 1, 'a')]\nzipRight [1] ['a', 'b'] = [(some 1, 'a'), (none, 'b')]\nzipRight = map\u2082Right prod.mk\n```\n-/\ndef zipRight : List \u03b1 \u2192 List \u03b2 \u2192 List (Option \u03b1 \u00d7 \u03b2) :=\n  map\u2082Right Prod.mk\n\n/--\nIf all elements of `xs` are `some x\u1d62`, `allSome xs` returns the `x\u1d62`. Otherwise\nit returns `none`.\n```\nallSome [some 1, some 2] = some [1, 2]\nallSome [some 1, none  ] = none\n```\n-/\ndef allSome : List (Option \u03b1) \u2192 Option (List \u03b1)\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 {\u03b1} : List (Option \u03b1) \u2192 List \u03b1 \u2192 List \u03b1\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\u2081 ... n\u2098`,\nit first takes the `n\u2081` initial elements from `as`, then the next `n\u2082` ones,\netc. It returns the sublists of `as` -- one for each `n\u1d62` -- and the remaining\nelements of `as`. If `as` does not have at least as many elements as the sum of\nthe `n\u1d62`, the corresponding sublists will have less than `n\u1d62` 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 {\u03b1} : List \u03b1 \u2192 List \u2115 \u2192 List (List \u03b1) \u00d7 List \u03b1\n| xs, [] => ([], xs)\n| xs, n :: ns =>\n  let \u27e8xs\u2081, xs\u2082\u27e9 := xs.splitAt n\n  let \u27e8xss, rest\u27e9 := takeList xs\u2082 ns\n  (xs\u2081 :: 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 {\u03b1} (n : \u2115) : List \u03b1 \u2192 \u2115 \u2192 List \u03b1 \u00d7 List (List \u03b1)\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 {\u03b1} : \u2115 \u2192 List \u03b1 \u2192 List (List \u03b1)\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\u2083 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 $ \u03bb \u27e8x, y, z\u27e9, f x y z`.\n-/\n\n\n/-- Ternary version of `List.zipWith`. -/\ndef zipWith\u2083 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3 \u2192 List \u03b4\n| x :: xs, y :: ys, z :: zs => f x y z :: zipWith\u2083 f xs ys zs\n| _, _, _ => []\n\n/-- Quaternary version of `List.zipWith`. -/\ndef zipWith\u2084 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4 \u2192 \u03b5) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3 \u2192 List \u03b4 \u2192 List \u03b5\n| x :: xs, y :: ys, z :: zs, u :: us => f x y z u :: zipWith\u2084 f xs ys zs us\n| _, _, _, _ => []\n\n/-- Quinary version of `List.zipWith`. -/\ndef zipWith\u2085 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4 \u2192 \u03b5 \u2192 \u03b6) : List \u03b1 \u2192 List \u03b2 \u2192 List \u03b3 \u2192 List \u03b4 \u2192 List \u03b5 \u2192 List \u03b6\n| x :: xs, y :: ys, z :: zs, u :: us, v :: vs => f x y z u v :: zipWith\u2085 f xs ys zs us vs\n| _, _, _, _, _ => []\n\n/-- An auxiliary function for `List.mapWithPrefixSuffix`. -/\ndef mapWithPrefixSuffixAux {\u03b1 \u03b2} (f : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1 \u2192 \u03b2) : List \u03b1 \u2192 List \u03b1 \u2192 List \u03b2\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 \u2208 l` with `l = pref ++ [a] ++ suff`, `a` is mapped to `f pref a suff`.\nExample: if `f : list \u2115 \u2192 \u2115 \u2192 list \u2115 \u2192 \u03b2`,\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 {\u03b1 \u03b2} (f : List \u03b1 \u2192 \u03b1 \u2192 List \u03b1 \u2192 \u03b2) (l : List \u03b1) : List \u03b2 :=\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 \u2208 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 : \u2115 \u2192 list \u2115 \u2192 \u03b2`, `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 {\u03b1 \u03b2} (f : \u03b1 \u2192 List \u03b1 \u2192 \u03b2) : List \u03b1 \u2192 List \u03b2 :=\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 \u03b2`,\nfor some type index `\u03b2`.\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 {\u03b1 : Type u} {\u03b2 : \u03b1 \u2192 Type v}\n\n#print AList /-\n/-- `alist \u03b2` 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 (\u03b2 : \u03b1 \u2192 Type v) : Type max u v where\n  entries : List (Sigma \u03b2)\n  NodupKeys : entries.NodupKeys\n#align alist AList\n-/\n\n#print List.toAList /-\n/-- Given `l : list (sigma \u03b2)`, create a term of type `alist \u03b2` by removing\nentries with duplicate keys. -/\ndef List.toAList [DecidableEq \u03b1] {\u03b2 : \u03b1 \u2192 Type v} (l : List (Sigma \u03b2)) : AList \u03b2\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 : \u2200 {s t : AList \u03b2}, s.entries = t.entries \u2192 s = t\n  | \u27e8l\u2081, h\u2081\u27e9, \u27e8l\u2082, h\u2082\u27e9, H => by congr\n#align alist.ext AList.ext\n-/\n\n#print AList.ext_iff /-\ntheorem ext_iff {s t : AList \u03b2} : s = t \u2194 s.entries = t.entries :=\n  \u27e8congr_arg _, ext\u27e9\n#align alist.ext_iff AList.ext_iff\n-/\n\ninstance [DecidableEq \u03b1] [\u2200 a, DecidableEq (\u03b2 a)] : DecidableEq (AList \u03b2) := 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 \u03b2) : List \u03b1 :=\n  s.entries.keys\n#align alist.keys AList.keys\n-/\n\n#print AList.keys_nodup /-\ntheorem keys_nodup (s : AList \u03b2) : s.keys.Nodup :=\n  s.NodupKeys\n#align alist.keys_nodup AList.keys_nodup\n-/\n\n/-! ### mem -/\n\n\n/-- The predicate `a \u2208 s` means that `s` has a value associated to the key `a`. -/\ninstance : Membership \u03b1 (AList \u03b2) :=\n  \u27e8fun a s => a \u2208 s.keys\u27e9\n\n#print AList.mem_keys /-\ntheorem mem_keys {a : \u03b1} {s : AList \u03b2} : a \u2208 s \u2194 a \u2208 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 : \u03b1} {s\u2081 s\u2082 : AList \u03b2} (p : s\u2081.entries ~ s\u2082.entries) : a \u2208 s\u2081 \u2194 a \u2208 s\u2082 :=\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 \u03b2) :=\n  \u27e8\u27e8[], nodupKeys_nil\u27e9\u27e9\n\ninstance : Inhabited (AList \u03b2) :=\n  \u27e8\u2205\u27e9\n\n#print AList.not_mem_empty /-\n@[simp]\ntheorem not_mem_empty (a : \u03b1) : a \u2209 (\u2205 : AList \u03b2) :=\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 : (\u2205 : AList \u03b2).entries = [] :=\n  rfl\n#align alist.empty_entries AList.empty_entries\n-/\n\n#print AList.keys_empty /-\n@[simp]\ntheorem keys_empty : (\u2205 : AList \u03b2).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 : \u03b1) (b : \u03b2 a) : AList \u03b2 :=\n  \u27e8[\u27e8a, b\u27e9], nodupKeys_singleton _\u27e9\n#align alist.singleton AList.singleton\n-/\n\n#print AList.singleton_entries /-\n@[simp]\ntheorem singleton_entries (a : \u03b1) (b : \u03b2 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 : \u03b1) (b : \u03b2 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 \u03b1]\n\n#print AList.lookup /-\n/-- Look up the value associated to a key in an association list. -/\ndef lookup (a : \u03b1) (s : AList \u03b2) : Option (\u03b2 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 (\u2205 : AList \u03b2) = none :=\n  rfl\n#align alist.lookup_empty AList.lookup_empty\n-/\n\n#print AList.lookup_isSome /-\ntheorem lookup_isSome {a : \u03b1} {s : AList \u03b2} : (s.dlookup a).isSome \u2194 a \u2208 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 : \u03b1} {s : AList \u03b2} : lookup a s = none \u2194 a \u2209 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 : \u03b1} {b : \u03b2 a} {s : AList \u03b2} :\n    b \u2208 lookup a s \u2194 Sigma.mk a b \u2208 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 : \u03b1} {s\u2081 s\u2082 : AList \u03b2} (p : s\u2081.entries ~ s\u2082.entries) :\n    s\u2081.dlookup a = s\u2082.dlookup a :=\n  perm_dlookup _ s\u2081.NodupKeys s\u2082.NodupKeys p\n#align alist.perm_lookup AList.perm_lookup\n-/\n\ninstance (a : \u03b1) (s : AList \u03b2) : Decidable (a \u2208 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 : \u03b1) (b : \u03b2 a) (s : AList \u03b2) : AList \u03b2 :=\n  \u27e8kreplace a b s.entries, (kreplace_nodupKeys a b).2 s.NodupKeys\u27e9\n#align alist.replace AList.replace\n-/\n\n#print AList.keys_replace /-\n@[simp]\ntheorem keys_replace (a : \u03b1) (b : \u03b2 a) (s : AList \u03b2) : (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' : \u03b1} {b : \u03b2 a} {s : AList \u03b2} : a' \u2208 replace a b s \u2194 a' \u2208 s := by\n  rw [mem_keys, keys_replace, \u2190 mem_keys]\n#align alist.mem_replace AList.mem_replace\n-/\n\n#print AList.perm_replace /-\ntheorem perm_replace {a : \u03b1} {b : \u03b2 a} {s\u2081 s\u2082 : AList \u03b2} :\n    s\u2081.entries ~ s\u2082.entries \u2192 (replace a b s\u2081).entries ~ (replace a b s\u2082).entries :=\n  Perm.kreplace s\u2081.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 {\u03b4 : Type w} (f : \u03b4 \u2192 \u2200 a, \u03b2 a \u2192 \u03b4) (d : \u03b4) (m : AList \u03b2) : \u03b4 :=\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 \u03b1]\n\n#print AList.erase /-\n/-- Erase a key from the map. If the key is not present, do nothing. -/\ndef erase (a : \u03b1) (s : AList \u03b2) : AList \u03b2 :=\n  \u27e8s.entries.kerase a, s.NodupKeys.kerase a\u27e9\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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (a : \u03b1) (s : AList.{u1, u2} \u03b1 \u03b2), Eq.{succ u1} (List.{u1} \u03b1) (AList.keys.{u1, u2} \u03b1 \u03b2 (AList.erase.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a s)) (List.erase\u2093.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (AList.keys.{u1, u2} \u03b1 \u03b2 s) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] (a : \u03b1) (s : AList.{u1, u2} \u03b1 \u03b2), Eq.{succ u1} (List.{u1} \u03b1) (AList.keys.{u1, u2} \u03b1 \u03b2 (AList.erase.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a s)) (List.erase.{u1} \u03b1 (instBEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (AList.keys.{u1, u2} \u03b1 \u03b2 s) a)\nCase conversion may be inaccurate. Consider using '#align alist.keys_erase AList.keys_erase\u2093'. -/\n@[simp]\ntheorem keys_erase (a : \u03b1) (s : AList \u03b2) : (erase a s).keys = s.keys.erase\u2093 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' : \u03b1} {s : AList \u03b2} : a' \u2208 erase a s \u2194 a' \u2260 a \u2227 a' \u2208 s := by\n  rw [mem_keys, keys_erase, s.keys_nodup.mem_erase_iff, \u2190 mem_keys]\n#align alist.mem_erase AList.mem_erase\n-/\n\n#print AList.perm_erase /-\ntheorem perm_erase {a : \u03b1} {s\u2081 s\u2082 : AList \u03b2} :\n    s\u2081.entries ~ s\u2082.entries \u2192 (erase a s\u2081).entries ~ (erase a s\u2082).entries :=\n  Perm.kerase s\u2081.NodupKeys\n#align alist.perm_erase AList.perm_erase\n-/\n\n#print AList.lookup_erase /-\n@[simp]\ntheorem lookup_erase (a) (s : AList \u03b2) : 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 \u03b2} (h : a \u2260 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' : \u03b1) (s : AList \u03b2) : (s.erase\u2093 a).erase\u2093 a' = (s.erase\u2093 a').erase\u2093 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 : \u03b1) (b : \u03b2 a) (s : AList \u03b2) : AList \u03b2 :=\n  \u27e8kinsert a b s.entries, kinsert_nodupKeys a b s.NodupKeys\u27e9\n#align alist.insert AList.insert\n-/\n\n#print AList.insert_entries /-\n@[simp]\ntheorem insert_entries {a} {b : \u03b2 a} {s : AList \u03b2} :\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 : \u03b2 a} {s : AList \u03b2} (h : a \u2209 s) :\n    (insert a b s).entries = \u27e8a, b\u27e9 :: 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 : \u03b2 a} {s : AList \u03b2} (h : a \u2209 s) :\n    insert a b s = \u27e8\u27e8a, b\u27e9 :: s.entries, nodupKeys_cons.2 \u27e8h, s.2\u27e9\u27e9 :=\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 : \u03b2 a) : insert a b \u2205 = 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' : \u03b2 a'} (s : AList \u03b2) : a \u2208 insert a' b' s \u2194 a = a' \u2228 a \u2208 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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {a : \u03b1} {b : \u03b2 a} (s : AList.{u1, u2} \u03b1 \u03b2), Eq.{succ u1} (List.{u1} \u03b1) (AList.keys.{u1, u2} \u03b1 (fun {a : \u03b1} => \u03b2 a) (AList.insert.{u1, u2} \u03b1 (fun {a : \u03b1} => \u03b2 a) (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b s)) (List.cons.{u1} \u03b1 a (List.erase\u2093.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (AList.keys.{u1, u2} \u03b1 \u03b2 s) a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {a : \u03b1} {b : \u03b2 a} (s : AList.{u1, u2} \u03b1 \u03b2), Eq.{succ u1} (List.{u1} \u03b1) (AList.keys.{u1, u2} \u03b1 \u03b2 (AList.insert.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b s)) (List.cons.{u1} \u03b1 a (List.erase.{u1} \u03b1 (instBEq.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b)) (AList.keys.{u1, u2} \u03b1 \u03b2 s) a))\nCase conversion may be inaccurate. Consider using '#align alist.keys_insert AList.keys_insert\u2093'. -/\n@[simp]\ntheorem keys_insert {a} {b : \u03b2 a} (s : AList \u03b2) : (insert a b s).keys = a :: s.keys.erase\u2093 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 : \u03b2 a} {s\u2081 s\u2082 : AList \u03b2} (p : s\u2081.entries ~ s\u2082.entries) :\n    (insert a b s\u2081).entries ~ (insert a b s\u2082).entries := by\n  simp only [insert_entries] <;> exact p.kinsert s\u2081.nodupkeys\n#align alist.perm_insert AList.perm_insert\n-/\n\n#print AList.lookup_insert /-\n@[simp]\ntheorem lookup_insert {a} {b : \u03b2 a} (s : AList \u03b2) : 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' : \u03b2 a'} {s : AList \u03b2} (h : a \u2260 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 \u03b2)) : 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' : \u03b2 a} (s : AList \u03b2) : (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*_ \u2227 _ <;> 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 : \u03b2 a} {b' : \u03b2 a'} (s : AList \u03b2) (h : a \u2260 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 : \u03b1} {b b' : \u03b2 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 \u03b2)) : (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 : \u03b1) (b : \u03b2 a) (xs : List (Sigma \u03b2)) :\n    List.toAList (\u27e8a, b\u27e9 :: 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 \u03b2) (l : List (Sigma \u03b2)) (h : (c :: l).NodupKeys) :\n    (\u27e8c :: l, h\u27e9 : AList \u03b2) = insert c.1 c.2 \u27e8l, nodupKeys_of_nodupKeys_cons h\u27e9 := 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 \u03b2 \u2192 Sort _} (H0 : C \u2205)\n    (IH : \u2200 (a : \u03b1) (b : \u03b2 a) (l : AList \u03b2) (h : a \u2209 l), C l \u2192 C (l.insert a b)) :\n    \u2200 l : AList \u03b2, C l\n  | \u27e8[], _\u27e9 => H0\n  | \u27e8c :: l, h\u27e9 => 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 \u03b2) : 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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {C : (AList.{u1, u2} \u03b1 \u03b2) -> Sort.{u3}} (H0 : C (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} \u03b1 \u03b2) (AList.hasEmptyc.{u1, u2} \u03b1 \u03b2))) (IH : forall (a : \u03b1) (b : \u03b2 a) (l : AList.{u1, u2} \u03b1 \u03b2), (Not (Membership.Mem.{u1, max u1 u2} \u03b1 (AList.{u1, u2} \u03b1 \u03b2) (AList.hasMem.{u1, u2} \u03b1 \u03b2) a l)) -> (C l) -> (C (AList.insert.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l))), Eq.{u3} (C (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} \u03b1 \u03b2) (AList.hasEmptyc.{u1, u2} \u03b1 \u03b2))) (AList.insertRec.{u1, u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} \u03b1 \u03b2) (AList.hasEmptyc.{u1, u2} \u03b1 \u03b2))) H0\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : \u03b1 -> Type.{u3}} [_inst_1 : DecidableEq.{succ u2} \u03b1] {C : (AList.{u2, u3} \u03b1 \u03b2) -> Sort.{u1}} (H0 : C (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} \u03b1 \u03b2) (AList.instEmptyCollectionAList.{u2, u3} \u03b1 \u03b2))) (IH : forall (a : \u03b1) (b : \u03b2 a) (l : AList.{u2, u3} \u03b1 \u03b2), (Not (Membership.mem.{u2, max u2 u3} \u03b1 (AList.{u2, u3} \u03b1 \u03b2) (AList.instMembershipAList.{u2, u3} \u03b1 \u03b2) a l)) -> (C l) -> (C (AList.insert.{u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l))), Eq.{u1} (C (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} \u03b1 \u03b2) (AList.instEmptyCollectionAList.{u2, u3} \u03b1 \u03b2))) (AList.insertRec.{u2, u3, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} \u03b1 \u03b2) (AList.instEmptyCollectionAList.{u2, u3} \u03b1 \u03b2))) H0\nCase conversion may be inaccurate. Consider using '#align alist.insert_rec_empty AList.insertRec_empty\u2093'. -/\n@[simp]\ntheorem insertRec_empty {C : AList \u03b2 \u2192 Sort _} (H0 : C \u2205)\n    (IH : \u2200 (a : \u03b1) (b : \u03b2 a) (l : AList \u03b2) (h : a \u2209 l), C l \u2192 C (l.insert a b)) :\n    @insertRec \u03b1 \u03b2 _ C H0 IH \u2205 = H0 :=\n  by\n  change @insert_rec \u03b1 \u03b2 _ C H0 IH \u27e8[], _\u27e9 = 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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {C : (AList.{u1, u2} \u03b1 \u03b2) -> Sort.{u3}} (H0 : C (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} \u03b1 \u03b2) (AList.hasEmptyc.{u1, u2} \u03b1 \u03b2))) (IH : forall (a : \u03b1) (b : \u03b2 a) (l : AList.{u1, u2} \u03b1 \u03b2), (Not (Membership.Mem.{u1, max u1 u2} \u03b1 (AList.{u1, u2} \u03b1 \u03b2) (AList.hasMem.{u1, u2} \u03b1 \u03b2) a l)) -> (C l) -> (C (AList.insert.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l))) {c : Sigma.{u1, u2} \u03b1 \u03b2} {l : AList.{u1, u2} \u03b1 \u03b2} (h : Not (Membership.Mem.{u1, max u1 u2} \u03b1 (AList.{u1, u2} \u03b1 \u03b2) (AList.hasMem.{u1, u2} \u03b1 \u03b2) (Sigma.fst.{u1, u2} \u03b1 \u03b2 c) l)), Eq.{u3} (C (AList.insert.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Sigma.fst.{u1, u2} \u03b1 \u03b2 c) (Sigma.snd.{u1, u2} \u03b1 \u03b2 c) l)) (AList.insertRec.{u1, u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH (AList.insert.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Sigma.fst.{u1, u2} \u03b1 \u03b2 c) (Sigma.snd.{u1, u2} \u03b1 \u03b2 c) l)) (IH (Sigma.fst.{u1, u2} \u03b1 \u03b2 c) (Sigma.snd.{u1, u2} \u03b1 \u03b2 c) l h (AList.insertRec.{u1, u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH l))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : \u03b1 -> Type.{u3}} [_inst_1 : DecidableEq.{succ u2} \u03b1] {C : (AList.{u2, u3} \u03b1 \u03b2) -> Sort.{u1}} (H0 : C (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} \u03b1 \u03b2) (AList.instEmptyCollectionAList.{u2, u3} \u03b1 \u03b2))) (IH : forall (a : \u03b1) (b : \u03b2 a) (l : AList.{u2, u3} \u03b1 \u03b2), (Not (Membership.mem.{u2, max u2 u3} \u03b1 (AList.{u2, u3} \u03b1 \u03b2) (AList.instMembershipAList.{u2, u3} \u03b1 \u03b2) a l)) -> (C l) -> (C (AList.insert.{u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l))) {c : Sigma.{u2, u3} \u03b1 \u03b2} {l : AList.{u2, u3} \u03b1 \u03b2} (h : Not (Membership.mem.{u2, max u2 u3} \u03b1 (AList.{u2, u3} \u03b1 \u03b2) (AList.instMembershipAList.{u2, u3} \u03b1 \u03b2) (Sigma.fst.{u2, u3} \u03b1 \u03b2 c) l)), Eq.{u1} (C (AList.insert.{u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Sigma.fst.{u2, u3} \u03b1 \u03b2 c) (Sigma.snd.{u2, u3} \u03b1 \u03b2 c) l)) (AList.insertRec.{u2, u3, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH (AList.insert.{u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) (Sigma.fst.{u2, u3} \u03b1 \u03b2 c) (Sigma.snd.{u2, u3} \u03b1 \u03b2 c) l)) (IH (Sigma.fst.{u2, u3} \u03b1 \u03b2 c) (Sigma.snd.{u2, u3} \u03b1 \u03b2 c) l h (AList.insertRec.{u2, u3, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH l))\nCase conversion may be inaccurate. Consider using '#align alist.insert_rec_insert AList.insertRec_insert\u2093'. -/\ntheorem insertRec_insert {C : AList \u03b2 \u2192 Sort _} (H0 : C \u2205)\n    (IH : \u2200 (a : \u03b1) (b : \u03b2 a) (l : AList \u03b2) (h : a \u2209 l), C l \u2192 C (l.insert a b)) {c : Sigma \u03b2}\n    {l : AList \u03b2} (h : c.1 \u2209 l) :\n    @insertRec \u03b1 \u03b2 _ C H0 IH (l.insert c.1 c.2) = IH c.1 c.2 l h (@insertRec \u03b1 \u03b2 _ C H0 IH l) :=\n  by\n  cases' l with l hl\n  suffices\n    HEq (@insert_rec \u03b1 \u03b2 _ C H0 IH \u27e8c :: l, nodupkeys_cons.2 \u27e8h, hl\u27e9\u27e9)\n      (IH c.1 c.2 \u27e8l, hl\u27e9 h (@insert_rec \u03b1 \u03b2 _ C H0 IH \u27e8l, hl\u27e9))\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 {\u03b1 : Type.{u1}} {\u03b2 : \u03b1 -> Type.{u2}} [_inst_1 : DecidableEq.{succ u1} \u03b1] {C : (AList.{u1, u2} \u03b1 \u03b2) -> Sort.{u3}} (H0 : C (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} \u03b1 \u03b2) (AList.hasEmptyc.{u1, u2} \u03b1 \u03b2))) (IH : forall (a : \u03b1) (b : \u03b2 a) (l : AList.{u1, u2} \u03b1 \u03b2), (Not (Membership.Mem.{u1, max u1 u2} \u03b1 (AList.{u1, u2} \u03b1 \u03b2) (AList.hasMem.{u1, u2} \u03b1 \u03b2) a l)) -> (C l) -> (C (AList.insert.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l))) {a : \u03b1} (b : \u03b2 a) {l : AList.{u1, u2} \u03b1 \u03b2} (h : Not (Membership.Mem.{u1, max u1 u2} \u03b1 (AList.{u1, u2} \u03b1 \u03b2) (AList.hasMem.{u1, u2} \u03b1 \u03b2) a l)), Eq.{u3} (C (AList.insert.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l)) (AList.insertRec.{u1, u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH (AList.insert.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l)) (IH a b l h (AList.insertRec.{u1, u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH l))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : \u03b1 -> Type.{u3}} [_inst_1 : DecidableEq.{succ u2} \u03b1] {C : (AList.{u2, u3} \u03b1 \u03b2) -> Sort.{u1}} (H0 : C (EmptyCollection.emptyCollection.{max u2 u3} (AList.{u2, u3} \u03b1 \u03b2) (AList.instEmptyCollectionAList.{u2, u3} \u03b1 \u03b2))) (IH : forall (a : \u03b1) (b : \u03b2 a) (l : AList.{u2, u3} \u03b1 \u03b2), (Not (Membership.mem.{u2, max u2 u3} \u03b1 (AList.{u2, u3} \u03b1 \u03b2) (AList.instMembershipAList.{u2, u3} \u03b1 \u03b2) a l)) -> (C l) -> (C (AList.insert.{u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l))) {a : \u03b1} (b : \u03b2 a) {l : AList.{u2, u3} \u03b1 \u03b2} (h : Not (Membership.mem.{u2, max u2 u3} \u03b1 (AList.{u2, u3} \u03b1 \u03b2) (AList.instMembershipAList.{u2, u3} \u03b1 \u03b2) a l)), Eq.{u1} (C (AList.insert.{u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l)) (AList.insertRec.{u2, u3, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH (AList.insert.{u2, u3} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) a b l)) (IH a b l h (AList.insertRec.{u2, u3, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_1 a b) C H0 IH l))\nCase conversion may be inaccurate. Consider using '#align alist.recursion_insert_mk AList.insertRec_insert_mk\u2093'. -/\ntheorem insertRec_insert_mk {C : AList \u03b2 \u2192 Sort _} (H0 : C \u2205)\n    (IH : \u2200 (a : \u03b1) (b : \u03b2 a) (l : AList \u03b2) (h : a \u2209 l), C l \u2192 C (l.insert a b)) {a : \u03b1} (b : \u03b2 a)\n    {l : AList \u03b2} (h : a \u2209 l) :\n    @insertRec \u03b1 \u03b2 _ C H0 IH (l.insert a b) = IH a b l h (@insertRec \u03b1 \u03b2 _ C H0 IH l) :=\n  @insertRec_insert \u03b1 \u03b2 _ C H0 IH \u27e8a, b\u27e9 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 : \u03b1) (s : AList \u03b2) : Option (\u03b2 a) \u00d7 AList \u03b2 :=\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, \u27e8l, h\u27e9)\n#align alist.extract AList.extract\n-/\n\n#print AList.extract_eq_lookup_erase /-\n@[simp]\ntheorem extract_eq_lookup_erase (a : \u03b1) (s : AList \u03b2) : 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\u2081 \u222a s\u2082` is the key-based union of two association lists. It is\nleft-biased: if there exists an `a \u2208 s\u2081`, `lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081`.\n-/\ndef union (s\u2081 s\u2082 : AList \u03b2) : AList \u03b2 :=\n  \u27e8s\u2081.entries.kunion s\u2082.entries, s\u2081.NodupKeys.kunion s\u2082.NodupKeys\u27e9\n#align alist.union AList.union\n-/\n\ninstance : Union (AList \u03b2) :=\n  \u27e8union\u27e9\n\n#print AList.union_entries /-\n@[simp]\ntheorem union_entries {s\u2081 s\u2082 : AList \u03b2} : (s\u2081 \u222a s\u2082).entries = kunion s\u2081.entries s\u2082.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 \u03b2} : (\u2205 : AList \u03b2) \u222a 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 \u03b2} : s \u222a (\u2205 : AList \u03b2) = 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\u2081 s\u2082 : AList \u03b2} : a \u2208 s\u2081 \u222a s\u2082 \u2194 a \u2208 s\u2081 \u2228 a \u2208 s\u2082 :=\n  mem_keys_kunion\n#align alist.mem_union AList.mem_union\n-/\n\n#print AList.perm_union /-\ntheorem perm_union {s\u2081 s\u2082 s\u2083 s\u2084 : AList \u03b2} (p\u2081\u2082 : s\u2081.entries ~ s\u2082.entries)\n    (p\u2083\u2084 : s\u2083.entries ~ s\u2084.entries) : (s\u2081 \u222a s\u2083).entries ~ (s\u2082 \u222a s\u2084).entries := by\n  simp [p\u2081\u2082.kunion s\u2083.nodupkeys p\u2083\u2084]\n#align alist.perm_union AList.perm_union\n-/\n\n#print AList.union_erase /-\ntheorem union_erase (a : \u03b1) (s\u2081 s\u2082 : AList \u03b2) : erase a (s\u2081 \u222a s\u2082) = erase a s\u2081 \u222a erase a s\u2082 :=\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\u2081 s\u2082 : AList \u03b2} : a \u2208 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2081 :=\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\u2081 s\u2082 : AList \u03b2} : a \u2209 s\u2081 \u2192 lookup a (s\u2081 \u222a s\u2082) = lookup a s\u2082 :=\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 : \u03b2 a} {s\u2081 s\u2082 : AList \u03b2} :\n    b \u2208 lookup a (s\u2081 \u222a s\u2082) \u2194 b \u2208 lookup a s\u2081 \u2228 a \u2209 s\u2081 \u2227 b \u2208 lookup a s\u2082 :=\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 : \u03b2 a} {s\u2081 s\u2082 s\u2083 : AList \u03b2} :\n    b \u2208 lookup a (s\u2081 \u222a s\u2083) \u2192 a \u2209 s\u2082 \u2192 b \u2208 lookup a (s\u2081 \u222a s\u2082 \u222a s\u2083) :=\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 : \u03b2 a} {s\u2081 s\u2082 : AList \u03b2} : insert a b (s\u2081 \u222a s\u2082) = insert a b s\u2081 \u222a s\u2082 :=\n  by ext <;> simp\n#align alist.insert_union AList.insert_union\n-/\n\n#print AList.union_assoc /-\ntheorem union_assoc {s\u2081 s\u2082 s\u2083 : AList \u03b2} : (s\u2081 \u222a s\u2082 \u222a s\u2083).entries ~ (s\u2081 \u222a (s\u2082 \u222a s\u2083)).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\u2081 s\u2082 : AList \u03b2) : Prop :=\n  \u2200 k \u2208 s\u2081.keys, \u00ack \u2208 s\u2082.keys\n#align alist.disjoint AList.Disjoint\n-/\n\nvariable [DecidableEq \u03b1]\n\n#print AList.union_comm_of_disjoint /-\ntheorem union_comm_of_disjoint {s\u2081 s\u2082 : AList \u03b2} (h : Disjoint s\u2081 s\u2082) :\n    (s\u2081 \u222a s\u2082).entries ~ (s\u2082 \u222a s\u2081).entries :=\n  lookup_ext (AList.nodupKeys _) (AList.nodupKeys _)\n    (by\n      intros ; simp\n      constructor <;> intro h'\n      cases h'\n      \u00b7 right\n        refine' \u27e8_, h'\u27e9\n        apply h\n        rw [keys, \u2190 List.dlookup_isSome, h']\n        exact rfl\n      \u00b7 left\n        rw [h'.2]\n      cases h'\n      \u00b7 right\n        refine' \u27e8_, h'\u27e9\n        intro h''\n        apply h _ h''\n        rw [keys, \u2190 List.dlookup_isSome, h']\n        exact rfl\n      \u00b7 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) : \u03b1 := 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 `\u03b1`, or `\u2115` 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 `\u03b1`. -/\n/-- Lift an instance cache tactic (probably from `norm_num`) to the `ring_m` monad. This uses\nthe instance cache corresponding to `\u2115`, 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 `\u2115` and\n`\u211a` 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (x : \u03b1) (n : \u2115) (b : \u03b1) : horner 0 x n b = b :=\n  sorry\n\ntheorem horner_horner {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (n\u2082 : \u2115) (b : \u03b1)\n    (n' : \u2115) (h : n\u2081 + n\u2082 = n') : horner (horner a\u2081 x n\u2081 0) x n\u2082 b = horner a\u2081 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (k : \u03b1) (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1)\n    (b' : \u03b1) (h : k + b = b') : k + horner a x n b = horner a x n b' :=\n  sorry\n\ntheorem horner_add_const {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) (k : \u03b1)\n    (b' : \u03b1) (h : b + k = b') : horner a x n b + k = horner a x n b' :=\n  sorry\n\ntheorem horner_add_horner_lt {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (b\u2081 : \u03b1)\n    (a\u2082 : \u03b1) (n\u2082 : \u2115) (b\u2082 : \u03b1) (k : \u2115) (a' : \u03b1) (b' : \u03b1) (h\u2081 : n\u2081 + k = n\u2082)\n    (h\u2082 : a\u2081 + horner a\u2082 x k 0 = a') (h\u2083 : b\u2081 + b\u2082 = b') :\n    horner a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2081 b' :=\n  sorry\n\ntheorem horner_add_horner_gt {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (b\u2081 : \u03b1)\n    (a\u2082 : \u03b1) (n\u2082 : \u2115) (b\u2082 : \u03b1) (k : \u2115) (a' : \u03b1) (b' : \u03b1) (h\u2081 : n\u2082 + k = n\u2081)\n    (h\u2082 : horner a\u2081 x k 0 + a\u2082 = a') (h\u2083 : b\u2081 + b\u2082 = b') :\n    horner a\u2081 x n\u2081 b\u2081 + horner a\u2082 x n\u2082 b\u2082 = horner a' x n\u2082 b' :=\n  sorry\n\ntheorem horner_add_horner_eq {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n : \u2115) (b\u2081 : \u03b1)\n    (a\u2082 : \u03b1) (b\u2082 : \u03b1) (a' : \u03b1) (b' : \u03b1) (t : \u03b1) (h\u2081 : a\u2081 + a\u2082 = a') (h\u2082 : b\u2081 + b\u2082 = b')\n    (h\u2083 : horner a' x n b' = t) : horner a\u2081 x n b\u2081 + horner a\u2082 x n b\u2082 = t :=\n  sorry\n\n/-- Evaluate `a + b` where `a` and `b` are already in normal form. -/\ntheorem horner_neg {\u03b1 : Type u_1} [comm_ring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) (a' : \u03b1) (b' : \u03b1)\n    (h\u2081 : -a = a') (h\u2082 : -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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (c : \u03b1) (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1)\n    (a' : \u03b1) (b' : \u03b1) (h\u2081 : c * a = a') (h\u2082 : c * b = b') : c * horner a x n b = horner a' x n b' :=\n  sorry\n\ntheorem horner_mul_const {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) (c : \u03b1)\n    (a' : \u03b1) (b' : \u03b1) (h\u2081 : a * c = a') (h\u2082 : 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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (b\u2081 : \u03b1)\n    (a\u2082 : \u03b1) (n\u2082 : \u2115) (aa : \u03b1) (t : \u03b1) (h\u2081 : horner a\u2081 x n\u2081 b\u2081 * a\u2082 = aa)\n    (h\u2082 : horner aa x n\u2082 0 = t) : horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 0 = t :=\n  sorry\n\ntheorem horner_mul_horner {\u03b1 : Type u_1} [comm_semiring \u03b1] (a\u2081 : \u03b1) (x : \u03b1) (n\u2081 : \u2115) (b\u2081 : \u03b1)\n    (a\u2082 : \u03b1) (n\u2082 : \u2115) (b\u2082 : \u03b1) (aa : \u03b1) (haa : \u03b1) (ab : \u03b1) (bb : \u03b1) (t : \u03b1)\n    (h\u2081 : horner a\u2081 x n\u2081 b\u2081 * a\u2082 = aa) (h\u2082 : horner aa x n\u2082 0 = haa) (h\u2083 : a\u2081 * b\u2082 = ab)\n    (h\u2084 : b\u2081 * b\u2082 = bb) (H : haa + horner ab x n\u2081 bb = t) :\n    horner a\u2081 x n\u2081 b\u2081 * horner a\u2082 x n\u2082 b\u2082 = t :=\n  sorry\n\n/-- Evaluate `a * b` where `a` and `b` are in normal form. -/\ntheorem horner_pow {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (m : \u2115) (n' : \u2115)\n    (a' : \u03b1) (h\u2081 : n * m = n') (h\u2082 : a ^ m = a') : horner a x n 0 ^ m = horner a' x n' 0 :=\n  sorry\n\ntheorem pow_succ {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (n : \u2115) (b : \u03b1) (c : \u03b1) (h\u2081 : a ^ n = b)\n    (h\u2082 : b * a = c) : a ^ (n + 1) = c :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = c)) (Eq.symm h\u2082)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (a ^ (n + 1) = b * a)) (Eq.symm h\u2081)))\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 {\u03b1 : Type u_1} [comm_semiring \u03b1] (x : \u03b1) : x = horner 1 x 1 0 := sorry\n\n/-- Evaluate `a` where `a` is an atom. -/\ntheorem subst_into_pow {\u03b1 : Type u_1} [monoid \u03b1] (l : \u03b1) (r : \u2115) (tl : \u03b1) (tr : \u2115) (t : \u03b1)\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 {\u03b1 : Type u_1} [add_group \u03b1] (a : \u03b1) (b : \u03b1) (c : \u03b1) (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 {\u03b1 : Type u_1} [division_ring \u03b1] (a : \u03b1) (b : \u03b1) (c : \u03b1) (h : a * (b\u207b\u00b9) = 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\u207b\u00b9) = 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' {\u03b1 : Type u_1} [comm_semiring \u03b1] (a : \u03b1) (x : \u03b1) (n : \u2115) (b : \u03b1) :\n    horner a x n b = x ^ n * a + b :=\n  sorry\n\ntheorem mul_assoc_rev {\u03b1 : Type u_1} [semigroup \u03b1] (a : \u03b1) (b : \u03b1) (c : \u03b1) :\n    a * (b * c) = a * b * c :=\n  sorry\n\ntheorem pow_add_rev {\u03b1 : Type u_1} [monoid \u03b1] (a : \u03b1) (m : \u2115) (n : \u2115) :\n    a ^ m * a ^ n = a ^ (m + n) :=\n  sorry\n\ntheorem pow_add_rev_right {\u03b1 : Type u_1} [monoid \u03b1] (a : \u03b1) (b : \u03b1) (m : \u2115) (n : \u2115) :\n    b * a ^ m * a ^ n = b * a ^ (m + n) :=\n  sorry\n\ntheorem add_neg_eq_sub {\u03b1 : Type u_1} [add_group \u03b1] (a : \u03b1) (b : \u03b1) : 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\u00e9goire\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\u2081 : Type v} [add_comm_group M\u2081] [module R M\u2081]\nvariables {M\u2082 : Type w} [add_comm_group M\u2082] [module R M\u2082]\nvariables {M\u2083 : Type x} [add_comm_group M\u2083] [module R M\u2083]\n\nopen linear_map\nopen submodule\n\nlemma linear_map.ker_le_range_iff {f : M\u2081 \u2192\u2097[R] M\u2082} {g : M\u2082 \u2192\u2097[R] M\u2083} :\n  g.ker \u2264 f.range \u2194 f.range.mkq.comp g.ker.subtype = 0 :=\nby rw [\u2190range_le_ker_iff, ker_mkq, range_subtype]\n\n/-\u27e8\u03bb h, ker_eq_top.1 $ eq_top_iff'.2 $ \u03bb x, mem_ker.2 $ by simpa using mem_range.1 (h x.2),\n \u03bb h,\n begin\n  rw \u2190range_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 \u2190submodule.ker_mkq f.range,\n  apply mem_ker.2,\n  rw \u2190zero_apply x,\n  rw \u2190h,\n  --rw \u2190submodule.subtype_apply _ \u27e8x, hx\u27e9,\n  exact mem_ker.2 (@linear_map.congr _ _ _ _ _ _ _ _\n    (comp (mkq (range f)) (submodule.subtype (ker g))) 0 \u27e8x, hx\u27e9 h),-/\n end\u27e9-/\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 : \u2115}\n  (\u0393 : Type)\n  (tops : vector (list \u0393) n)\n  (bottoms : vector (list \u0393) 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    {\u0393 : Type}\n    {n : \u2115} :\n      \u03a0 (symbols : vector (list \u0393) n), list (fin n) \u2192 list \u0393\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 : \u2115}\n    {\u0393 : Type}\n    {tops : vector (list \u0393) n}\n    {bottoms : vector (list \u0393) n} :\n      pcp \u0393 tops bottoms \u2192 Prop\n      | _ := \u2203 (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 : \u2115) := vector \u2115 n\n\n  -- We define an ordering on scores such that s\u2081 \u2264 s\u2082 iff they are equal up to\n  -- some index i, wherein s\u2081[i] \u2264 s\u2082[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 : \u2115} (s1 : score n) (s2 : score n) : Prop :=\n    \u2203 (i : \u2115), \u03a0 (ltin : i < n),\n      (nth s1 (fin.mk i ltin)) \u2264\n      (nth s2 (fin.mk i ltin)) \u2227\n        \u2200 (j : \u2115), \u03a0 (ltji : j < i),\n          (nth s1 \u27e8j, lt.trans ltji ltin\u27e9) =\n          (nth s2 \u27e8j, lt.trans ltji ltin\u27e9)\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 \u2192 \u2115 := sorry\n\ndef map_to_binary\n  {n : \u2115}\n  {\u0393 : Type}\n\n  {tops : vector (list \u0393) n}\n  {bottoms : vector (list \u0393) n}\n\n  {new_tops : vector (list bin) (n * alphabet_width \u0393)}\n  {new_bottoms : vector (list bin) (n * alphabet_width \u0393)}:\n    pcp \u0393 tops bottoms \u2192 pcp bin new_tops new_bottoms :=\n      sorry\n\n-- TODO: Debug it\n-- theorem binary_equivalence {n : \u2115}\n--                            {\u0393 : Type}\n--                            {tops bottoms : vector (list \u0393) n}\n--                            (problem : pcp \u0393 tops bottoms) :\n--   problem.has_solution \u2194 (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 \u0393\n    | a : \u0393\n    | b : \u0393\n\n  open \u0393\n\n  def top_l := [[b], [a]]\n  def bot_l := [[], [b, a]]\n\n  def tops : vector (list \u0393) 2 := \u27e8top_l, by refl\u27e9\n  def bottoms : vector (list \u0393) 2 := \u27e8bot_l, by refl\u27e9\n\n  theorem simple_pcp (problem : pcp \u0393 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 := \u27e8[0, 0, 1, 3, 5], by refl\u27e9\n  def y : score 5 := \u27e8[0, 0, 2, 1, 7], by refl\u27e9\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 \u2264 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) \u2227 ..., not (\u03a0 (ltin : i < n), ...\nnamespace hidden_break_score\n  open ot\n  open vector\n\n  def x : score 5 := \u27e8[0, 0, 2, 3, 5], by refl\u27e9\n  def y : score 5 := \u27e8[0, 0, 1, 1, 7], by refl\u27e9\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 (\u03b1 : Type u) :=\n(excl : option (exclusive \u03b1))\n(frag : \u03b1)\n\nnamespace auth\n\nnotation `\u25cf `:75 a:75 := auth.mk (some (exclusive.mk a)) 1\nnotation `\u25ef `:75 a:75 := auth.mk none a\n\ninstance {\u03b1 : Type u} [ofe \u03b1] : ofe (auth \u03b1) := {\n  eq_at := \u03bb n a b, a.excl =[n] b.excl \u2227 a.frag =[n] b.frag,\n  eq_at_reflexive := by intros n a; split; refl,\n  eq_at_symmetric := \u03bb n a b h, \u27e8eq_at_symmetric n h.1, eq_at_symmetric n h.2\u27e9,\n  eq_at_transitive := begin\n    rintros n a b c \u27e8hab\u2081, hab\u2082\u27e9 \u27e8hbc\u2081, hbc\u2082\u27e9,\n    split; transitivity; assumption,\n  end,\n  eq_at_mono' := \u03bb m n hmn a b h, \u27e8eq_at_mono hmn h.1, eq_at_mono hmn h.2\u27e9,\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 {\u03b1 : Type u} [unital_camera \u03b1] {n : \u2115} {a b : \u03b1} :\n  \u25cf a =[n] \u25cf b \u2192 a =[n] b :=\n\u03bb h, exclusive.mk_eq_at (option.eq_at_of_some_eq_at h.1)\n\n@[simp] lemma excl_eq_at_iff {\u03b1 : Type u} [unital_camera \u03b1] {n : \u2115} {a b : \u03b1} :\n  \u25cf a =[n] \u25cf b \u2194 a =[n] b :=\n\u27e8excl_eq_at, \u03bb h, \u27e8option.some_eq_at_iff.mpr (exclusive.mk_eq_at_iff.mpr h), eq_at_refl n 1\u27e9\u27e9\n\nlemma frag_eq_at {\u03b1 : Type u} [ofe \u03b1] {n : \u2115} {a b : \u03b1} :\n  \u25ef a =[n] \u25ef b \u2192 a =[n] b :=\n\u03bb h, h.2\n\n@[simp] lemma frag_eq_at_iff {\u03b1 : Type u} [ofe \u03b1] {n : \u2115} {a b : \u03b1} :\n  \u25ef a =[n] \u25ef b \u2194 a =[n] b :=\n\u27e8\u03bb h, h.2, \u03bb h, \u27e8eq_at_refl n _, h\u27e9\u27e9\n\ninstance {\u03b1 : Type u} [comm_semigroup \u03b1] : comm_semigroup (auth \u03b1) := {\n  mul := \u03bb a b, \u27e8a.excl * b.excl, a.frag * b.frag\u27e9,\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 {\u03b1 : Type u} [comm_semigroup \u03b1] (a b : auth \u03b1) :\n  (a * b).excl = a.excl * b.excl := rfl\n\n@[simp] lemma mul_frag {\u03b1 : Type u} [comm_semigroup \u03b1] (a b : auth \u03b1) :\n  (a * b).frag = a.frag * b.frag := rfl\n\n@[simp] lemma mul_mk {\u03b1 : Type u} [comm_semigroup \u03b1]\n  (ax bx : option (exclusive \u03b1)) (af bf : \u03b1) :\n  (\u27e8ax, af\u27e9 : auth \u03b1) * \u27e8bx, bf\u27e9 = \u27e8ax * bx, af * bf\u27e9 := rfl\n\ninductive validn {\u03b1 : Type u} [camera \u03b1] (n : \u2115) : auth \u03b1 \u2192 Prop\n| none {b : \u03b1} : \u2713[n] b \u2192 validn (\u25ef b)\n| mk {a b : \u03b1} : b \u227c[n] a \u2192 \u2713[n] a \u2192 validn \u27e8some (exclusive.mk a), b\u27e9\n\nprivate lemma validn_nonexpansive {\u03b1 : Type u} [camera \u03b1] {n : \u2115} {xa ya : option (exclusive \u03b1)}\n  {xf yf : \u03b1} : (\u27e8xa, xf\u27e9 : auth \u03b1) =[n] \u27e8ya, yf\u27e9 \u2192 validn n \u27e8xa, xf\u27e9 \u2192 validn n \u27e8ya, yf\u27e9 :=\nbegin\n  intros h h',\n  obtain (\u27e8_, h\u2081\u27e9 | \u27e8z, _, \u27e8c, hc\u27e9, h\u2083\u27e9) := h',\n  { cases h.1,\n    refine validn.none _,\n    refine camera.validn_of_eq_at (frag_eq_at h) _,\n    assumption, },\n  { obtain \u27e8h\u2081, h\u2082\u27e9 := h,\n    simp only [option.exists_eq_iff_some_eq, exclusive.exists_eq_iff_mk_eq] at h\u2081,\n    obtain \u27e8_, rfl, \u27e8b', rfl, h\u2081\u27e9\u27e9 := h\u2081,\n    refine validn.mk \u27e8c, _\u27e9 _,\n    simp only at h\u2082,\n    refine eq_at_trans z _ h\u2081,\n    refine eq_at_trans (xf * c) _ hc,\n    exact camera.mul_eq_at_left (eq_at_symm h\u2082),\n    exact camera.validn_of_eq_at h\u2081 h\u2083, },\nend\n\nprivate lemma excl_validn {\u03b1 : Type u} [camera \u03b1] {n : \u2115} {a : auth \u03b1} : validn n a \u2192 \u2713[n] a.excl :=\nbegin\n  rintro (h | h) a (h | h),\n  intro h', cases h',\nend\n\nprivate lemma frag_validn {\u03b1 : Type u} [camera \u03b1] {n : \u2115} {a : auth \u03b1} : validn n a \u2192 \u2713[n] a.frag :=\nbegin\n  rintro (h | h),\n  assumption,\n  exact camera.validn_incln \u2039_\u203a \u2039_\u203a,\nend\n\ndef extend {\u03b1 : Type u} [unital_camera \u03b1] {n : \u2115} {a b\u2081 b\u2082 : auth \u03b1}\n  (h\u2081 : validn n a) (h\u2082 : a =[n] b\u2081 * b\u2082) : auth \u03b1 \u00d7 auth \u03b1 :=\n\u27e8\u27e8(camera.extend (excl_validn h\u2081) h\u2082.1).1, (camera.extend (frag_validn h\u2081) h\u2082.2).1\u27e9,\n  \u27e8(camera.extend (excl_validn h\u2081) h\u2082.1).2, (camera.extend (frag_validn h\u2081) h\u2082.2).2\u27e9\u27e9\n\ninstance {\u03b1 : Type u} [unital_camera \u03b1] : camera (auth \u03b1) := {\n  validn := \u27e8\u03bb a, \u27e8\u03bb n, validn n a, begin\n    intros m n hmn h,\n    cases h,\n    exact validn.none (camera.validn_mono hmn \u2039_\u203a),\n    exact validn.mk (incln_mono hmn \u2039_\u203a) (camera.validn_mono hmn \u2039_\u203a),\n  end\u27e9, begin\n    rintros n \u27e8xa, xf\u27e9 \u27e8ya, yf\u27e9 h m hmn,\n    exact \u27e8validn_nonexpansive (eq_at_mono hmn h),\n      validn_nonexpansive (eq_at_mono hmn (eq_at_symm h))\u27e9,\n  end\u27e9,\n  core := \u27e8\u03bb a, some (\u25ef |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\u27e9,\n  extend := @extend _ _,\n  mul_is_nonexpansive := \u03bb n a b h, \u27e8camera.mul_eq_at h.1.1 h.2.1, camera.mul_eq_at h.1.2 h.2.2\u27e9,\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 := \u03bb 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 \u27e8c, rfl\u27e9,\n    simp only [nonexpansive_fun.coe_fn_mk, mul_frag] at hca \u22a2,\n    obtain \u27e8d, hd\u27e9 := unital_camera.abs_mono a.frag (a.frag * c.frag) \u27e8c.frag, rfl\u27e9,\n    refine \u27e8some (\u25ef d), _\u27e9,\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 \u27e8ax, af\u27e9 \u27e8bx, bf\u27e9 n h,\n    simp only [nonexpansive_fun.coe_fn_mk, sprop.coe_fn_mk, mul_mk] at h \u22a2,\n    cases ax,\n    { cases bx,\n      { obtain (\u27e8_, h\u27e9 | _) := h,\n        exact validn.none (camera.validn_mul_left h), },\n      { obtain (_ | \u27e8c, _, \u27e8d, hd\u27e9, hc\u27e9) := 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 (_ | \u27e8c, _, \u27e8d, hd\u27e9, hc\u27e9) := h,\n        refine validn.mk \u27e8bf * d, _\u27e9 hc,\n        convert hd using 1,\n        rw \u2190 mul_assoc,\n        refl, },\n      { cases h, }, },\n  end,\n  extend_mul_eq := begin\n    intros n a b\u2081 b\u2082 h\u2081 b\u2082,\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\u2081 b\u2082 h\u2081 b\u2082,\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\u2081 b\u2082 h\u2081 b\u2082,\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 (\u03bbx, trace `(5))\n\n-- This one already works (serendipity!)\nmeta def assump' : tactic unit :=\ndo\n  ctxt \u2190 local_context,\n  list.mfirst (\u03bbx, exact x) ctxt\n\n-- Shorter version (blind guess)\nmeta def assump : tactic unit := local_context >>= list.mfirst (\u03bbx, exact x)\n\nexample (A B C : Prop) (ha : A) (hb : B) (hc : C) : C :=\nby assump\n\nexample (n: \u2115)(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 `\u00ac P` for some proposition `P`.\nIt should use this contradiction to close the goal.\n\nBonus: handle `P \u2192 false` as well as `\u00ac 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 \u2190 local_context,\nlist.mfirst\n  (\u03bb e, list.mfirst (\u03bbx, \n  -- Shorter than the next 3 lines: `to_expr ``(%%x %%e) >>= exact`\n  do\n  apli \u2190 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-- \u03bb ctx, list.mfirst\n-- (\u03bb e, list.mfirst (\u03bbx, to_expr ``(%%x %%e) >>= exact ) ctx) ctx\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hnq : \u00ac Q) : false :=\nby contr'\n\n\nexample (P Q R : Prop) (hnq : \u00ac Q) (hp : P) (hq : Q) (hr : \u00ac R) : 0 = 1 :=\nby contr'\n\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hnq : Q \u2192 false) : false :=\nby contr'\n\n-- Unexpected!\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hqr : Q \u2192 R) : R :=\nby contr'\n\nmeta def tactic.interactive.contr : tactic unit :=\ndo\ntgt \u2190 target,\nctx \u2190 local_context,\nlist.mfirst\n  (\u03bb e, list.mfirst (\u03bbx, to_expr ``(absurd %%x %%e) >>= exact)\n   ctx) ctx,\ndone\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hnq : \u00ac Q) : false :=\nby contr\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hnq : \u00ac Q) : false :=\nby contr\n\nexample (P Q R : Prop) (hnq : \u00ac Q) (hp : P) (hq : Q) (hr : \u00ac R) : 0 = 1 :=\nby exact false.rec.{0} (0 = 1) (hnq hq)\n\nexample (P Q R : Prop) (hp : P) (hq : Q) (hr : \u00ac R) (hnq : Q \u2192 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 `\u2115`\n(presumably with some arguments), e.g. `nat.add : \u2115 \u2192 \u2115 \u2192 \u2115`\nor `list.length : \u03a0 \u03b1 : Type, list \u03b1 \u2192 \u2115`.\nIt should add a new declaration to the environment which proves all applications\nof this function are nonnegative,\ne.g. `nat.add_nonneg : \u2200 m n : \u2115, 0 \u2264 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 : \u211a) (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 : \u211a) (h : q / (3 / 4) > 0) : false :=\nbegin\n  -- cancel_denoms at h,\n  sorry\nend\n\nexample (p q : \u211a) (h : q / 2 / 3 < q) : false :=\nbegin\n  -- cancel_denoms at h,\n  sorry\nend\n\nexample (p q : \u211a) (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 : \u211a) (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 (\u03b1 : Type u) : Nat \u2192 Type u\n  | nil : Vec \u03b1 0\n  | cons : \u03b1 \u2192 Vec \u03b1 n \u2192 Vec \u03b1 (n+1)\n\ndef f1 (xs : Vec \u03b1 n) : Nat :=\n  Vec.casesOn xs 0 fun _ _ => 1\n\ndef f2 (xs : Vec \u03b1 n) : Nat :=\n  xs.casesOn 0 -- Error insufficient number of arguments\n\ndef f3 (x : Nat) : Nat \u2192 (Nat \u2192 Nat) \u2192 Nat :=\n  x.casesOn\n\ndef f4 (xs : List Nat) : xs \u2260 [] \u2192 xs.length > 0 :=\n  xs.casesOn (by intros; contradiction) (by intros; simp_arith)\n\ndef f5 (xs : List Nat) (h : xs \u2260 []) : 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 \u03b1 n) : Nat :=\n  xs.casesOn (a := 10) 0 -- Error unused named args\n\ndef f8 (xs : List Nat) : xs \u2260 [] \u2192 xs.length > 0 :=\n  @List.casesOn _ (fun xs => xs \u2260 [] \u2192 xs.length > 0) xs (by dsimp; intros; contradiction) (by dsimp; intros; simp_arith)\n\ndef f5' (xs : List Nat) (h : xs \u2260 []) : xs.length > 0 :=\n  xs.casesOn (fun h => absurd rfl h) (fun _ _ _ => Nat.zero_lt_succ ..) h\n\nexample (h\u2081 : a = b) (h\u2082 : b = c) : a = c :=\n  Eq.rec h\u2082 h\u2081.symm\n\n@[elab_as_elim] theorem subst {p : (b : \u03b1) \u2192 a = b \u2192 Prop} (h\u2081 : a = b) (h\u2082 : p a rfl) : p b h\u2081 := by\n  cases h\u2081\n  assumption\n\nexample (h\u2081 : a = b) (h\u2082 : b = c) : a = c :=\n  subst h\u2081.symm h\u2082\n\ntheorem not_or_not : (\u00acp \u2228 \u00acq) \u2192 \u00ac(p \u2227 q) := \u03bb h \u27e8hp, hq\u27e9 =>\n  h.rec (\u03bb h1 => h1 hp) (\u03bb 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 \u2192 pos_num\n  | bit0 : pos_num \u2192 pos_num\n\ninductive num : Type\n  | zero  : num\n  | pos   : pos_num \u2192 num\n\ninductive znum : Type\n  | zero : znum\n  | pos  : pos_num \u2192 znum\n  | neg  : pos_num \u2192 znum\n\ndef pos_num.pred' : pos_num \u2192 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 \u2192 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 \u2192 Nat :=\n  Nat.rec 0 (fun x _ => x)\n\nexample : \u2200 x, x \u2265 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 `(\u2a01 i\u2081, M\u2081 i\u2081) \u2297 (\u2a01 i\u2082, M\u2082 i\u2082) \u2243 (\u2a01 i\u2081, \u2a01 i\u2082, M\u2081 i\u2081 \u2297 M\u2082 i\u2082)`, i.e.\n\"tensor product distributes over direct sum\". -/\ndef direct_sum (R : Type u_1) [comm_ring R] (\u03b9\u2081 : Type u_2) (\u03b9\u2082 : Type u_3) [DecidableEq \u03b9\u2081]\n    [DecidableEq \u03b9\u2082] (M\u2081 : \u03b9\u2081 \u2192 Type u_4) (M\u2082 : \u03b9\u2082 \u2192 Type u_5) [(i\u2081 : \u03b9\u2081) \u2192 add_comm_group (M\u2081 i\u2081)]\n    [(i\u2082 : \u03b9\u2082) \u2192 add_comm_group (M\u2082 i\u2082)] [(i\u2081 : \u03b9\u2081) \u2192 module R (M\u2081 i\u2081)]\n    [(i\u2082 : \u03b9\u2082) \u2192 module R (M\u2082 i\u2082)] :\n    linear_equiv R\n        (tensor_product R (direct_sum \u03b9\u2081 fun (i\u2081 : \u03b9\u2081) => M\u2081 i\u2081)\n          (direct_sum \u03b9\u2082 fun (i\u2082 : \u03b9\u2082) => M\u2082 i\u2082))\n        (direct_sum (\u03b9\u2081 \u00d7 \u03b9\u2082)\n          fun (i : \u03b9\u2081 \u00d7 \u03b9\u2082) => tensor_product R (M\u2081 (prod.fst i)) (M\u2082 (prod.snd i))) :=\n  linear_equiv.of_linear\n    (lift\n      (direct_sum.to_module R \u03b9\u2081\n        (linear_map R (direct_sum \u03b9\u2082 fun (i\u2082 : \u03b9\u2082) => M\u2082 i\u2082)\n          (direct_sum (\u03b9\u2081 \u00d7 \u03b9\u2082)\n            fun (i : \u03b9\u2081 \u00d7 \u03b9\u2082) => tensor_product R (M\u2081 (prod.fst i)) (M\u2082 (prod.snd i))))\n        fun (i\u2081 : \u03b9\u2081) =>\n          linear_map.flip\n            (direct_sum.to_module R \u03b9\u2082\n              (linear_map R (M\u2081 i\u2081)\n                (direct_sum (\u03b9\u2081 \u00d7 \u03b9\u2082)\n                  fun (i : \u03b9\u2081 \u00d7 \u03b9\u2082) => tensor_product R (M\u2081 (prod.fst i)) (M\u2082 (prod.snd i))))\n              fun (i\u2082 : \u03b9\u2082) =>\n                linear_map.flip\n                  (curry\n                    (direct_sum.lof R (\u03b9\u2081 \u00d7 \u03b9\u2082)\n                      (fun (i : \u03b9\u2081 \u00d7 \u03b9\u2082) => tensor_product R (M\u2081 (prod.fst i)) (M\u2082 (prod.snd i)))\n                      (i\u2081, i\u2082))))))\n    (direct_sum.to_module R (\u03b9\u2081 \u00d7 \u03b9\u2082)\n      (tensor_product R (direct_sum \u03b9\u2081 fun (i\u2081 : \u03b9\u2081) => M\u2081 i\u2081)\n        (direct_sum \u03b9\u2082 fun (i\u2082 : \u03b9\u2082) => M\u2082 i\u2082))\n      fun (i : \u03b9\u2081 \u00d7 \u03b9\u2082) =>\n        map (direct_sum.lof R \u03b9\u2081 M\u2081 (prod.fst i)) (direct_sum.lof R \u03b9\u2082 M\u2082 (prod.snd i)))\n    sorry sorry\n\n@[simp] theorem direct_sum_lof_tmul_lof (R : Type u_1) [comm_ring R] (\u03b9\u2081 : Type u_2) (\u03b9\u2082 : Type u_3)\n    [DecidableEq \u03b9\u2081] [DecidableEq \u03b9\u2082] (M\u2081 : \u03b9\u2081 \u2192 Type u_4) (M\u2082 : \u03b9\u2082 \u2192 Type u_5)\n    [(i\u2081 : \u03b9\u2081) \u2192 add_comm_group (M\u2081 i\u2081)] [(i\u2082 : \u03b9\u2082) \u2192 add_comm_group (M\u2082 i\u2082)]\n    [(i\u2081 : \u03b9\u2081) \u2192 module R (M\u2081 i\u2081)] [(i\u2082 : \u03b9\u2082) \u2192 module R (M\u2082 i\u2082)] (i\u2081 : \u03b9\u2081) (m\u2081 : M\u2081 i\u2081) (i\u2082 : \u03b9\u2082)\n    (m\u2082 : M\u2082 i\u2082) :\n    coe_fn (direct_sum R \u03b9\u2081 \u03b9\u2082 M\u2081 M\u2082)\n          (tmul R (coe_fn (direct_sum.lof R \u03b9\u2081 M\u2081 i\u2081) m\u2081) (coe_fn (direct_sum.lof R \u03b9\u2082 M\u2082 i\u2082) m\u2082)) =\n        coe_fn\n          (direct_sum.lof R (\u03b9\u2081 \u00d7 \u03b9\u2082)\n            (fun (i : \u03b9\u2081 \u00d7 \u03b9\u2082) => tensor_product R (M\u2081 (prod.fst i)) (M\u2082 (prod.snd i))) (i\u2081, i\u2082))\n          (tmul R m\u2081 m\u2082) :=\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) 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 mathd_algebra_451\n  (\u03c3 : equiv \u211d \u211d)\n  (h\u2080 : \u03c3.2 (-15) = 0)\n  (h\u2081 : \u03c3.2 0 = 3)\n  (h\u2082 : \u03c3.2 3 = 9)\n  (h\u2083 : \u03c3.2 9 = 20) :\n  \u03c3.1 (\u03c3.1 9) = 0 :=\nbegin\n  simp [\u2190 h\u2081, \u2190 h\u2082],\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/mathd/algebra/p451.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7799928900257126, "lm_q2_score": 0.5851011542032312, "lm_q1q2_score": 0.45637474022435837}}
{"text": "import Preloaded tactic\n\n-- Task 1: Prove that n + m = n + m\ntheorem immediate : \u2200 n m : \u2115, n + m = n + m :=\n  by intros; refl\n\n-- Task 2: Prove that n + m = m + n\ntheorem plus_comm : \u2200 n m : \u2115, n + m = m + n :=\n  by intros; apply add_comm\n\n-- Task 3: Prove excluded middle\ntheorem excluded_middle : \u2200 p : Prop, p \u2228 \u00acp := em\n\n-- Task 4: Prove that 1 + 1 = 3\ntheorem one_plus_one_is_three : 1 + 1 = 3 := sorry", "meta": {"author": "DonaldKellett", "repo": "CW-Lean3-Examples", "sha": "9dd81b7c9327b029c859f37534232ab556f69699", "save_path": "github-repos/lean/DonaldKellett-CW-Lean3-Examples", "path": "github-repos/lean/DonaldKellett-CW-Lean3-Examples/CW-Lean3-Examples-9dd81b7c9327b029c859f37534232ab556f69699/kata2/Solution.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.8918110454379297, "lm_q2_score": 0.5117166047041654, "lm_q1q2_score": 0.4563545202091695}}
{"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\u2081 P\u2082` (notation: `P\u2081 \u2243\u1d43[k] P\u2082`) to be the type of affine\nequivalences between `P\u2081` and `P\u2082, 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\u2081 P\u2082 : Type*) {V\u2081 V\u2082 : Type*} [ring k]\n  [add_comm_group V\u2081] [module k V\u2081] [add_torsor V\u2081 P\u2081]\n  [add_comm_group V\u2082] [module k V\u2082] [add_torsor V\u2082 P\u2082] extends P\u2081 \u2243 P\u2082 :=\n(linear : V\u2081 \u2243\u2097[k] V\u2082)\n(map_vadd' : \u2200 (p : P\u2081) (v : V\u2081), to_equiv (v +\u1d65 p) = linear v +\u1d65 to_equiv p)\n\nnotation P\u2081 ` \u2243\u1d43[`:25 k:25 `] `:0 P\u2082:0 := affine_equiv k P\u2081 P\u2082\n\nvariables {k V\u2081 V\u2082 V\u2083 V\u2084 P\u2081 P\u2082 P\u2083 P\u2084 : Type*} [ring k]\n  [add_comm_group V\u2081] [module k V\u2081] [add_torsor V\u2081 P\u2081]\n  [add_comm_group V\u2082] [module k V\u2082] [add_torsor V\u2082 P\u2082]\n  [add_comm_group V\u2083] [module k V\u2083] [add_torsor V\u2083 P\u2083]\n  [add_comm_group V\u2084] [module k V\u2084] [add_torsor V\u2084 P\u2084]\n\nnamespace affine_equiv\n\ninclude V\u2081 V\u2082\n\ninstance : has_coe_to_fun (P\u2081 \u2243\u1d43[k] P\u2082) (\u03bb _, P\u2081 \u2192 P\u2082) := \u27e8\u03bb e, e.to_fun\u27e9\n\ninstance : has_coe (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2243 P\u2082) := \u27e8affine_equiv.to_equiv\u27e9\n\nvariables (k P\u2081)\n\nomit V\u2082\n\n/-- Identity map as an `affine_equiv`. -/\n@[refl] def refl : P\u2081 \u2243\u1d43[k] P\u2081 :=\n{ to_equiv := equiv.refl P\u2081,\n  linear := linear_equiv.refl k V\u2081,\n  map_vadd' := \u03bb _ _, rfl }\n\n@[simp] lemma coe_refl : \u21d1(refl k P\u2081) = id := rfl\n\nlemma refl_apply (x : P\u2081) : refl k P\u2081 x = x := rfl\n\n@[simp] lemma to_equiv_refl : (refl k P\u2081).to_equiv = equiv.refl P\u2081 := rfl\n\n@[simp] lemma linear_refl : (refl k P\u2081).linear = linear_equiv.refl k V\u2081 := rfl\n\nvariables {k P\u2081}\n\ninclude V\u2082\n\n@[simp] lemma map_vadd (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2081) (v : V\u2081) : e (v +\u1d65 p) = e.linear v +\u1d65 e p :=\ne.map_vadd' p v\n\n@[simp] lemma coe_to_equiv (e : P\u2081 \u2243\u1d43[k] P\u2082) : \u21d1e.to_equiv = e := rfl\n\n/-- Reinterpret an `affine_equiv` as an `affine_map`. -/\ndef to_affine_map (e : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192\u1d43[k] P\u2082 := { to_fun := e, .. e }\n\ninstance : has_coe (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2192\u1d43[k] P\u2082) := \u27e8to_affine_map\u27e9\n\n@[simp] lemma coe_to_affine_map (e : P\u2081 \u2243\u1d43[k] P\u2082) :\n  (e.to_affine_map : P\u2081 \u2192 P\u2082) = (e : P\u2081 \u2192 P\u2082) :=\nrfl\n\n@[simp] lemma to_affine_map_mk (f : P\u2081 \u2243 P\u2082) (f' : V\u2081 \u2243\u2097[k] V\u2082) (h) :\n  to_affine_map (mk f f' h) = \u27e8f, f', h\u27e9 :=\nrfl\n\n@[norm_cast, simp] lemma coe_coe (e : P\u2081 \u2243\u1d43[k] P\u2082) : ((e : P\u2081 \u2192\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082) = e := rfl\n\n@[simp] lemma linear_to_affine_map (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.to_affine_map.linear = e.linear := rfl\n\nlemma to_affine_map_injective : injective (to_affine_map : (P\u2081 \u2243\u1d43[k] P\u2082) \u2192 (P\u2081 \u2192\u1d43[k] P\u2082)) :=\nbegin\n  rintros \u27e8e, el, h\u27e9 \u27e8e', el', h'\u27e9 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\u2081 \u2243\u1d43[k] P\u2082} :\n  e.to_affine_map = e'.to_affine_map \u2194 e = e' :=\nto_affine_map_injective.eq_iff\n\n@[ext] lemma ext {e e' : P\u2081 \u2243\u1d43[k] P\u2082} (h : \u2200 x, e x = e' x) : e = e' :=\nto_affine_map_injective $ affine_map.ext h\n\nlemma coe_fn_injective : @injective (P\u2081 \u2243\u1d43[k] P\u2082) (P\u2081 \u2192 P\u2082) coe_fn :=\n\u03bb e e' H, ext $ congr_fun H\n\n@[simp, norm_cast] lemma coe_fn_inj {e e' : P\u2081 \u2243\u1d43[k] P\u2082} : (e : P\u2081 \u2192 P\u2082) = e' \u2194 e = e' :=\ncoe_fn_injective.eq_iff\n\nlemma to_equiv_injective : injective (to_equiv : (P\u2081 \u2243\u1d43[k] P\u2082) \u2192 (P\u2081 \u2243 P\u2082)) :=\n\u03bb e e' H, ext $ equiv.ext_iff.1 H\n\n@[simp] lemma to_equiv_inj {e e' : P\u2081 \u2243\u1d43[k] P\u2082} : e.to_equiv = e'.to_equiv \u2194 e = e' :=\nto_equiv_injective.eq_iff\n\n@[simp] lemma coe_mk (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (h) :\n  ((\u27e8e, e', h\u27e9 : P\u2081 \u2243\u1d43[k] P\u2082) : P\u2081 \u2192 P\u2082) = 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\u2081 \u2192 P\u2082`, a linear equivalence\n`e' : V\u2081 \u2243\u2097[k] V\u2082`, and a point `p` such that for any other point `p'` we have\n`e p' = e' (p' -\u1d65 p) +\u1d65 e p`. -/\ndef mk' (e : P\u2081 \u2192 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (p : P\u2081) (h : \u2200 p' : P\u2081, e p' = e' (p' -\u1d65 p) +\u1d65 e p) :\n  P\u2081 \u2243\u1d43[k] P\u2082 :=\n{ to_fun := e,\n  inv_fun := \u03bb q' : P\u2082, e'.symm (q' -\u1d65 e p) +\u1d65 p,\n  left_inv := \u03bb p', by simp [h p'],\n  right_inv := \u03bb q', by simp [h (e'.symm (q' -\u1d65 e p) +\u1d65 p)],\n  linear := e',\n  map_vadd' := \u03bb p' v, by { simp [h p', h (v +\u1d65 p'), vadd_vsub_assoc, vadd_vadd] } }\n\n@[simp] lemma coe_mk' (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (p h) : \u21d1(mk' e e' p h) = e := rfl\n@[simp] lemma linear_mk' (e : P\u2081 \u2243 P\u2082) (e' : V\u2081 \u2243\u2097[k] V\u2082) (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\u2081 \u2243\u1d43[k] P\u2082) : P\u2082 \u2243\u1d43[k] P\u2081 :=\n{ to_equiv := e.to_equiv.symm,\n  linear := e.linear.symm,\n  map_vadd' := \u03bb 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\u2081 \u2243\u1d43[k] P\u2082) : e.to_equiv.symm = e.symm.to_equiv := rfl\n\n@[simp] lemma symm_linear (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.linear.symm = e.symm.linear := rfl\n\nprotected lemma bijective (e : P\u2081 \u2243\u1d43[k] P\u2082) : bijective e := e.to_equiv.bijective\nprotected lemma surjective (e : P\u2081 \u2243\u1d43[k] P\u2082) : surjective e := e.to_equiv.surjective\nprotected lemma injective (e : P\u2081 \u2243\u1d43[k] P\u2082) : injective e := e.to_equiv.injective\n\n@[simp] lemma range_eq (e : P\u2081 \u2243\u1d43[k] P\u2082) : range e = univ := e.surjective.range_eq\n\n@[simp] lemma apply_symm_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2082) : e (e.symm p) = p :=\ne.to_equiv.apply_symm_apply p\n\n@[simp] lemma symm_apply_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (p : P\u2081) : e.symm (e p) = p :=\ne.to_equiv.symm_apply_apply p\n\nlemma apply_eq_iff_eq_symm_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) {p\u2081 p\u2082} : e p\u2081 = p\u2082 \u2194 p\u2081 = e.symm p\u2082 :=\ne.to_equiv.apply_eq_iff_eq_symm_apply\n\n@[simp] lemma apply_eq_iff_eq (e : P\u2081 \u2243\u1d43[k] P\u2082) {p\u2081 p\u2082 : P\u2081} : e p\u2081 = e p\u2082 \u2194 p\u2081 = p\u2082 :=\ne.to_equiv.apply_eq_iff_eq\n\nomit V\u2082\n\n@[simp] lemma symm_refl : (refl k P\u2081).symm = refl k P\u2081 := rfl\n\ninclude V\u2082 V\u2083\n\n/-- Composition of two `affine_equiv`alences, applied left to right. -/\n@[trans] def trans (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) : P\u2081 \u2243\u1d43[k] P\u2083 :=\n{ to_equiv := e.to_equiv.trans e'.to_equiv,\n  linear := e.linear.trans e'.linear,\n  map_vadd' := \u03bb p v, by simp only [linear_equiv.trans_apply, coe_to_equiv, (\u2218),\n    equiv.coe_trans, map_vadd] }\n\n@[simp] lemma coe_trans (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) : \u21d1(e.trans e') = e' \u2218 e := rfl\n\nlemma trans_apply (e : P\u2081 \u2243\u1d43[k] P\u2082) (e' : P\u2082 \u2243\u1d43[k] P\u2083) (p : P\u2081) : e.trans e' p = e' (e p) := rfl\n\ninclude V\u2084\n\nlemma trans_assoc (e\u2081 : P\u2081 \u2243\u1d43[k] P\u2082) (e\u2082 : P\u2082 \u2243\u1d43[k] P\u2083) (e\u2083 : P\u2083 \u2243\u1d43[k] P\u2084) :\n  (e\u2081.trans e\u2082).trans e\u2083 = e\u2081.trans (e\u2082.trans e\u2083) :=\next $ \u03bb _, rfl\n\nomit V\u2083 V\u2084\n\n@[simp] lemma trans_refl (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.trans (refl k P\u2082) = e :=\next $ \u03bb _, rfl\n\n@[simp] lemma refl_trans (e : P\u2081 \u2243\u1d43[k] P\u2082) : (refl k P\u2081).trans e = e :=\next $ \u03bb _, rfl\n\n@[simp] lemma self_trans_symm (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.trans e.symm = refl k P\u2081 :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : P\u2081 \u2243\u1d43[k] P\u2082) : e.symm.trans e = refl k P\u2082 :=\next e.apply_symm_apply\n\n@[simp] lemma apply_line_map (e : P\u2081 \u2243\u1d43[k] P\u2082) (a b : P\u2081) (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\u2082\n\ninstance : group (P\u2081 \u2243\u1d43[k] P\u2081) :=\n{ one := refl k P\u2081,\n  mul := \u03bb e e', e'.trans e,\n  inv := symm,\n  mul_assoc := \u03bb e\u2081 e\u2082 e\u2083, 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\u2081 \u2243\u1d43[k] P\u2081) = refl k P\u2081 := rfl\n\n@[simp] lemma coe_one : \u21d1(1 : P\u2081 \u2243\u1d43[k] P\u2081) = id := rfl\n\nlemma mul_def (e e' : P\u2081 \u2243\u1d43[k] P\u2081) : e * e' = e'.trans e := rfl\n\n@[simp] lemma coe_mul (e e' : P\u2081 \u2243\u1d43[k] P\u2081) : \u21d1(e * e') = e \u2218 e' := rfl\n\nlemma inv_def (e : P\u2081 \u2243\u1d43[k] P\u2081) : e\u207b\u00b9 = e.symm := rfl\n\nvariable (k)\n\n/-- The map `v \u21a6 v +\u1d65 b` as an affine equivalence between a module `V` and an affine space `P` with\ntangent space `V`. -/\ndef vadd_const (b : P\u2081) : V\u2081 \u2243\u1d43[k] P\u2081 :=\n{ to_equiv := equiv.vadd_const b,\n  linear := linear_equiv.refl _ _,\n  map_vadd' := \u03bb p v, add_vadd _ _ _ }\n\n@[simp] lemma linear_vadd_const (b : P\u2081) : (vadd_const k b).linear = linear_equiv.refl k V\u2081 := rfl\n\n@[simp] lemma vadd_const_apply (b : P\u2081) (v : V\u2081) : vadd_const k b v = v +\u1d65 b := rfl\n\n@[simp] lemma vadd_const_symm_apply (b p : P\u2081) : (vadd_const k b).symm p = p -\u1d65 b := rfl\n\n/-- `p' \u21a6 p -\u1d65 p'` as an equivalence. -/\ndef const_vsub (p : P\u2081) : P\u2081 \u2243\u1d43[k] V\u2081 :=\n{ to_equiv := equiv.const_vsub p,\n  linear := linear_equiv.neg k,\n  map_vadd' := \u03bb p' v, by simp [vsub_vadd_eq_vsub_sub, neg_add_eq_sub] }\n\n@[simp] lemma coe_const_vsub (p : P\u2081) : \u21d1(const_vsub k p) = (-\u1d65) p := rfl\n\n@[simp] lemma coe_const_vsub_symm (p : P\u2081) : \u21d1(const_vsub k p).symm = \u03bb v, -v +\u1d65 p := rfl\n\nvariable (P\u2081)\n\n/-- The map `p \u21a6 v +\u1d65 p` as an affine automorphism of an affine space. -/\ndef const_vadd (v : V\u2081) : P\u2081 \u2243\u1d43[k] P\u2081 :=\n{ to_equiv := equiv.const_vadd P\u2081 v,\n  linear := linear_equiv.refl _ _,\n  map_vadd' := \u03bb p w, vadd_comm _ _ _ }\n\n@[simp] lemma linear_const_vadd (v : V\u2081) : (const_vadd k P\u2081 v).linear = linear_equiv.refl _ _ := rfl\n\n@[simp] lemma const_vadd_apply (v : V\u2081) (p : P\u2081) : const_vadd k P\u2081 v p = v +\u1d65 p := rfl\n\n@[simp] lemma const_vadd_symm_apply (v : V\u2081) (p : P\u2081) : (const_vadd k P\u2081 v).symm p = -v +\u1d65 p := rfl\n\nsection homothety\n\nomit V\u2081\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 \u2192* P \u2243\u1d43[R] P :=\n{ to_fun   := \u03bb t,\n  { to_fun    := affine_map.homothety p (t : R),\n    inv_fun   := affine_map.homothety p (\u2191t\u207b\u00b9 : R),\n    left_inv  := \u03bb p, by simp [\u2190 affine_map.comp_apply, \u2190 affine_map.homothety_mul],\n    right_inv := \u03bb p, by simp [\u2190 affine_map.comp_apply, \u2190 affine_map.homothety_mul],\n    linear    :=\n    { inv_fun   := linear_map.lsmul R V (\u2191t\u207b\u00b9 : R),\n      left_inv  := \u03bb v, by simp [smul_smul],\n      right_inv := \u03bb v, by simp [smul_smul],\n      .. linear_map.lsmul R V t, },\n    map_vadd' := \u03bb 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' := \u03bb t\u2081 t\u2082, by { ext, simp [\u2190 affine_map.comp_apply, \u2190 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 \u2192 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 \u2192 P) = affine_map.homothety p (\u2191t\u207b\u00b9 : R) :=\nrfl\n\n@[simp] lemma coe_homothety_units_mul_hom_eq_homothety_hom_coe (p : P) :\n  (coe : (P \u2243\u1d43[R] P) \u2192 P \u2192\u1d43[R] P) \u2218 homothety_units_mul_hom p =\n  (affine_map.homothety_hom p) \u2218 (coe : units R \u2192 R) :=\nby { ext, simp, }\n\nend homothety\n\nvariable {P\u2081}\nopen function\n\n/-- Point reflection in `x` as a permutation. -/\ndef point_reflection (x : P\u2081) : P\u2081 \u2243\u1d43[k] P\u2081 := (const_vsub k x).trans (vadd_const k x)\n\nlemma point_reflection_apply (x y : P\u2081) : point_reflection k x y = x -\u1d65 y +\u1d65 x := rfl\n\n@[simp] lemma point_reflection_symm (x : P\u2081) : (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\u2081) :\n  (point_reflection k x).to_equiv = equiv.point_reflection x :=\nrfl\n\n@[simp] lemma point_reflection_self (x : P\u2081) : point_reflection k x x = x := vsub_vadd _ _\n\nlemma point_reflection_involutive (x : P\u2081) : involutive (point_reflection k x : P\u2081 \u2192 P\u2081) :=\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 \u2194 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\u2081} (h : injective (bit0 : V\u2081 \u2192 V\u2081)) :\n  point_reflection k x y = y \u2194 y = x :=\nequiv.point_reflection_fixed_iff_of_injective_bit0 h\n\nlemma injective_point_reflection_left_of_injective_bit0 (h : injective (bit0 : V\u2081 \u2192 V\u2081)) (y : P\u2081) :\n  injective (\u03bb x : P\u2081, 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  \u2200 y, injective (\u03bb x : P\u2081, point_reflection k x y) :=\ninjective_point_reflection_left_of_injective_bit0 k $ \u03bb x y h,\n  by rwa [bit0, bit0, \u2190 two_smul k x, \u2190 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\u2081} :\n  point_reflection k x y = y \u2194 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\u2081 \u2243\u2097[k] V\u2082) : V\u2081 \u2243\u1d43[k] V\u2082 :=\n{ to_equiv := e.to_equiv,\n  linear := e,\n  map_vadd' := \u03bb p v, e.map_add v p }\n\n@[simp] lemma coe_to_affine_equiv (e : V\u2081 \u2243\u2097[k] V\u2082) : \u21d1e.to_affine_equiv = e := rfl\n\nend linear_equiv\n\nnamespace affine_map\n\nopen affine_equiv\n\ninclude V\u2081\n\nlemma line_map_vadd (v v' : V\u2081) (p : P\u2081) (c : k) :\n  line_map v v' c +\u1d65 p = line_map (v +\u1d65 p) (v' +\u1d65 p) c :=\n(vadd_const k p).apply_line_map v v' c\n\nlemma line_map_vsub (p\u2081 p\u2082 p\u2083 : P\u2081) (c : k) :\n  line_map p\u2081 p\u2082 c -\u1d65 p\u2083 = line_map (p\u2081 -\u1d65 p\u2083) (p\u2082 -\u1d65 p\u2083) c :=\n(vadd_const k p\u2083).symm.apply_line_map p\u2081 p\u2082 c\n\nlemma vsub_line_map (p\u2081 p\u2082 p\u2083 : P\u2081) (c : k) :\n  p\u2081 -\u1d65 line_map p\u2082 p\u2083 c = line_map (p\u2081 -\u1d65 p\u2082) (p\u2081 -\u1d65 p\u2083) c :=\n(const_vsub k p\u2081).apply_line_map p\u2082 p\u2083 c\n\nlemma vadd_line_map (v : V\u2081) (p\u2081 p\u2082 : P\u2081) (c : k) :\n  v +\u1d65 line_map p\u2081 p\u2082 c = line_map (v +\u1d65 p\u2081) (v +\u1d65 p\u2082) c :=\n(const_vadd k P\u2081 v).apply_line_map p\u2081 p\u2082 c\n\nvariables {R' : Type*} [comm_ring R'] [module R' V\u2081]\n\nlemma homothety_neg_one_apply (c p : P\u2081) :\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 {\u03b1 : Type u} (R : \u03b1 \u2192 \u03b1 \u2192 Prop) :\n    \u2200 (\u1fb0 : List \u03b1),\n        pairwise R \u1fb0 \u2194\n          \u1fb0 = [] \u2228\n            Exists\n              fun {a : \u03b1} =>\n                Exists\n                  fun {l : List \u03b1} => (\u2200 (a' : \u03b1), a' \u2208 l \u2192 R a a') \u2227 pairwise R l \u2227 \u1fb0 = a :: l :=\n  sorry\n\ntheorem rel_of_pairwise_cons {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1}\n    (p : pairwise R (a :: l)) {a' : \u03b1} : a' \u2208 l \u2192 R a a' :=\n  and.left (iff.mp pairwise_cons p)\n\ntheorem pairwise_of_pairwise_cons {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {l : List \u03b1}\n    (p : pairwise R (a :: l)) : pairwise R l :=\n  and.right (iff.mp pairwise_cons p)\n\ntheorem pairwise.tail {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} (p : pairwise R l) :\n    pairwise R (tail l) :=\n  sorry\n\ntheorem pairwise.imp_of_mem {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1}\n    (H : \u2200 {a b : \u03b1}, a \u2208 l \u2192 b \u2208 l \u2192 R a b \u2192 S a b) (p : pairwise R l) : pairwise S l :=\n  sorry\n\ntheorem pairwise.imp {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (H : \u2200 (a b : \u03b1), R a b \u2192 S a b) {l : List \u03b1} : pairwise R l \u2192 pairwise S l :=\n  pairwise.imp_of_mem fun (a b : \u03b1) (_x : a \u2208 l) (_x : b \u2208 l) => H a b\n\ntheorem pairwise.and {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    pairwise (fun (a b : \u03b1) => R a b \u2227 S a b) l \u2194 pairwise R l \u2227 pairwise S l :=\n  sorry\n\ntheorem pairwise.imp\u2082 {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop} {T : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (H : \u2200 (a b : \u03b1), R a b \u2192 S a b \u2192 T a b) {l : List \u03b1} (hR : pairwise R l) (hS : pairwise S l) :\n    pairwise T l :=\n  pairwise.imp (fun (a b : \u03b1) => And._oldrec (H a b))\n    (iff.mpr pairwise.and { left := hR, right := hS })\n\ntheorem pairwise.iff_of_mem {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1}\n    (H : \u2200 {a b : \u03b1}, a \u2208 l \u2192 b \u2208 l \u2192 (R a b \u2194 S a b)) : pairwise R l \u2194 pairwise S l :=\n  { mp := pairwise.imp_of_mem fun (a b : \u03b1) (m : a \u2208 l) (m' : b \u2208 l) => iff.mp (H m m'),\n    mpr := pairwise.imp_of_mem fun (a b : \u03b1) (m : a \u2208 l) (m' : b \u2208 l) => iff.mpr (H m m') }\n\ntheorem pairwise.iff {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (H : \u2200 (a b : \u03b1), R a b \u2194 S a b) {l : List \u03b1} : pairwise R l \u2194 pairwise S l :=\n  pairwise.iff_of_mem fun (a b : \u03b1) (_x : a \u2208 l) (_x : b \u2208 l) => H a b\n\ntheorem pairwise_of_forall {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} (H : \u2200 (x y : \u03b1), R x y) :\n    pairwise R l :=\n  sorry\n\ntheorem pairwise.and_mem {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    pairwise R l \u2194 pairwise (fun (x y : \u03b1) => x \u2208 l \u2227 y \u2208 l \u2227 R x y) l :=\n  sorry\n\ntheorem pairwise.imp_mem {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    pairwise R l \u2194 pairwise (fun (x y : \u03b1) => x \u2208 l \u2192 y \u2208 l \u2192 R x y) l :=\n  sorry\n\ntheorem pairwise_of_sublist {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l\u2081 : List \u03b1} {l\u2082 : List \u03b1} :\n    l\u2081 <+ l\u2082 \u2192 pairwise R l\u2082 \u2192 pairwise R l\u2081 :=\n  sorry\n\ntheorem forall_of_forall_of_pairwise {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (H : symmetric R) {l : List \u03b1}\n    (H\u2081 : \u2200 (x : \u03b1), x \u2208 l \u2192 R x x) (H\u2082 : pairwise R l) (x : \u03b1) :\n    x \u2208 l \u2192 \u2200 (y : \u03b1), y \u2208 l \u2192 R x y :=\n  sorry\n\ntheorem forall_of_pairwise {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (H : symmetric R) {l : List \u03b1}\n    (hl : pairwise R l) (a : \u03b1) : a \u2208 l \u2192 \u2200 (b : \u03b1), b \u2208 l \u2192 a \u2260 b \u2192 R a b :=\n  forall_of_forall_of_pairwise\n    (fun (a b : \u03b1) (h : a \u2260 b \u2192 R a b) (hne : b \u2260 a) => H (h (ne.symm hne)))\n    (fun (_x : \u03b1) (_x_1 : _x \u2208 l) (h : _x \u2260 _x) => false.elim (h rfl))\n    (pairwise.imp (fun (_x _x_1 : \u03b1) (h : R _x _x_1) (_x : _x \u2260 _x_1) => h) hl)\n\ntheorem pairwise_singleton {\u03b1 : Type u} (R : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : pairwise R [a] := sorry\n\ntheorem pairwise_pair {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} : pairwise R [a, b] \u2194 R a b :=\n  sorry\n\ntheorem pairwise_append {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l\u2081 : List \u03b1} {l\u2082 : List \u03b1} :\n    pairwise R (l\u2081 ++ l\u2082) \u2194\n        pairwise R l\u2081 \u2227 pairwise R l\u2082 \u2227 \u2200 (x : \u03b1), x \u2208 l\u2081 \u2192 \u2200 (y : \u03b1), y \u2208 l\u2082 \u2192 R x y :=\n  sorry\n\ntheorem pairwise_append_comm {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (s : symmetric R) {l\u2081 : List \u03b1}\n    {l\u2082 : List \u03b1} : pairwise R (l\u2081 ++ l\u2082) \u2194 pairwise R (l\u2082 ++ l\u2081) :=\n  sorry\n\ntheorem pairwise_middle {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (s : symmetric R) {a : \u03b1} {l\u2081 : List \u03b1}\n    {l\u2082 : List \u03b1} : pairwise R (l\u2081 ++ a :: l\u2082) \u2194 pairwise R (a :: (l\u2081 ++ l\u2082)) :=\n  sorry\n\ntheorem pairwise_map {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (f : \u03b2 \u2192 \u03b1) {l : List \u03b2} :\n    pairwise R (map f l) \u2194 pairwise (fun (a b : \u03b2) => R (f a) (f b)) l :=\n  sorry\n\ntheorem pairwise_of_pairwise_map {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2192 \u03b2) (H : \u2200 (a b : \u03b1), S (f a) (f b) \u2192 R a b) {l : List \u03b1} (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 {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (f : \u03b1 \u2192 \u03b2) (H : \u2200 (a b : \u03b1), R a b \u2192 S (f a) (f b)) {l : List \u03b1} (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 {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (f : \u03b2 \u2192 Option \u03b1)\n    {l : List \u03b2} :\n    pairwise R (filter_map f l) \u2194\n        pairwise (fun (a a' : \u03b2) => \u2200 (b : \u03b1), b \u2208 f a \u2192 \u2200 (b' : \u03b1), b' \u2208 f a' \u2192 R b b') l :=\n  sorry\n\ntheorem pairwise_filter_map_of_pairwise {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {S : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 Option \u03b2)\n    (H : \u2200 (a a' : \u03b1), R a a' \u2192 \u2200 (b : \u03b2), b \u2208 f a \u2192 \u2200 (b' : \u03b2), b' \u2208 f a' \u2192 S b b') {l : List \u03b1}\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 {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (p : \u03b1 \u2192 Prop) [decidable_pred p]\n    {l : List \u03b1} : pairwise R (filter p l) \u2194 pairwise (fun (x y : \u03b1) => p x \u2192 p y \u2192 R x y) l :=\n  sorry\n\ntheorem pairwise_filter_of_pairwise {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} (p : \u03b1 \u2192 Prop)\n    [decidable_pred p] {l : List \u03b1} : pairwise R l \u2192 pairwise R (filter p l) :=\n  pairwise_of_sublist (filter_sublist l)\n\ntheorem pairwise_pmap {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {p : \u03b2 \u2192 Prop}\n    {f : (b : \u03b2) \u2192 p b \u2192 \u03b1} {l : List \u03b2} (h : \u2200 (x : \u03b2), x \u2208 l \u2192 p x) :\n    pairwise R (pmap f l h) \u2194\n        pairwise (fun (b\u2081 b\u2082 : \u03b2) => \u2200 (h\u2081 : p b\u2081) (h\u2082 : p b\u2082), R (f b\u2081 h\u2081) (f b\u2082 h\u2082)) l :=\n  sorry\n\ntheorem pairwise.pmap {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} (hl : pairwise R l)\n    {p : \u03b1 \u2192 Prop} {f : (a : \u03b1) \u2192 p a \u2192 \u03b2} (h : \u2200 (x : \u03b1), x \u2208 l \u2192 p x) {S : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (hS : \u2200 {x : \u03b1} (hx : p x) {y : \u03b1} (hy : p y), R x y \u2192 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 : \u03b1) (\u1fb0 : a \u2208 l) (\u1fb0_1 : b \u2208 l) (\u1fb0_2 : R a b) (h\u2081 : p a) (h\u2082 : p b) => hS h\u2081 h\u2082 \u1fb0_2)\n      hl)\n\ntheorem pairwise_join {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {L : List (List \u03b1)} :\n    pairwise R (join L) \u2194\n        (\u2200 (l : List \u03b1), l \u2208 L \u2192 pairwise R l) \u2227\n          pairwise (fun (l\u2081 l\u2082 : List \u03b1) => \u2200 (x : \u03b1), x \u2208 l\u2081 \u2192 \u2200 (y : \u03b1), y \u2208 l\u2082 \u2192 R x y) L :=\n  sorry\n\n@[simp] theorem pairwise_reverse {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    pairwise R (reverse l) \u2194 pairwise (fun (x y : \u03b1) => R y x) l :=\n  sorry\n\ntheorem pairwise_iff_nth_le {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    pairwise R l \u2194\n        \u2200 (i j : \u2115) (h\u2081 : j < length l) (h\u2082 : i < j),\n          R (nth_le l i (lt_trans h\u2082 h\u2081)) (nth_le l j h\u2081) :=\n  sorry\n\ntheorem pairwise_sublists' {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} :\n    pairwise R l \u2192 pairwise (lex (function.swap R)) (sublists' l) :=\n  sorry\n\ntheorem pairwise_sublists {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} (H : pairwise R l) :\n    pairwise (fun (l\u2081 l\u2082 : List \u03b1) => lex R (reverse l\u2081) (reverse l\u2082)) (sublists l) :=\n  sorry\n\n/- pairwise reduct -/\n\n@[simp] theorem pw_filter_nil {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] :\n    pw_filter R [] = [] :=\n  rfl\n\n@[simp] theorem pw_filter_cons_of_pos {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] {a : \u03b1}\n    {l : List \u03b1} (h : \u2200 (b : \u03b1), b \u2208 pw_filter R l \u2192 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 {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] {a : \u03b1}\n    {l : List \u03b1} (h : \u00ac\u2200 (b : \u03b1), b \u2208 pw_filter R l \u2192 R a b) :\n    pw_filter R (a :: l) = pw_filter R l :=\n  if_neg h\n\ntheorem pw_filter_map {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] (f : \u03b2 \u2192 \u03b1)\n    (l : List \u03b2) : pw_filter R (map f l) = map f (pw_filter (fun (x y : \u03b2) => R (f x) (f y)) l) :=\n  sorry\n\ntheorem pw_filter_sublist {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] (l : List \u03b1) :\n    pw_filter R l <+ l :=\n  sorry\n\ntheorem pw_filter_subset {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] (l : List \u03b1) :\n    pw_filter R l \u2286 l :=\n  sublist.subset (pw_filter_sublist l)\n\ntheorem pairwise_pw_filter {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] (l : List \u03b1) :\n    pairwise R (pw_filter R l) :=\n  sorry\n\ntheorem pw_filter_eq_self {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] {l : List \u03b1} :\n    pw_filter R l = l \u2194 pairwise R l :=\n  sorry\n\n@[simp] theorem pw_filter_idempotent {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R] {l : List \u03b1} :\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 {\u03b1 : Type u} {R : \u03b1 \u2192 \u03b1 \u2192 Prop} [DecidableRel R]\n    (neg_trans : \u2200 {x y z : \u03b1}, R x z \u2192 R x y \u2228 R y z) (a : \u03b1) (l : List \u03b1) :\n    (\u2200 (b : \u03b1), b \u2208 pw_filter R l \u2192 R a b) \u2194 \u2200 (b : \u03b1), b \u2208 l \u2192 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 \u2964 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\u2081 u u\u2081 u\u2082\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 : \u2200 X Y : C, \u2203 (Z : _)(f : X \u27f6 Z)(g : Y \u27f6 Z), True\n  cocone_maps : \u2200 \u2983X Y : C\u2984 (f g : X \u27f6 Y), \u2203 (Z : _)(h : Y \u27f6 Z), f \u226b h = g \u226b 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 (\u03b1 : Type u) [SemilatticeSup \u03b1] :\n    IsFilteredOrEmpty \u03b1\n    where\n  cocone_objs X Y := \u27e8X \u2294 Y, homOfLE le_sup_left, homOfLE le_sup_right, trivial\u27e9\n  cocone_maps X Y f g := \u27e8Y, \ud835\udfd9 _, by ext\u27e9\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 (\u03b1 : Type u) [SemilatticeSup \u03b1]\n    [Nonempty \u03b1] : IsFiltered \u03b1 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 (\u03b1 : Type u) [Preorder \u03b1]\n    [IsDirected \u03b1 (\u00b7 \u2264 \u00b7)] : IsFilteredOrEmpty \u03b1\n    where\n  cocone_objs X Y :=\n    let \u27e8Z, h1, h2\u27e9 := exists_ge_ge X Y\n    \u27e8Z, homOfLE h1, homOfLE h2, trivial\u27e9\n  cocone_maps X Y f g := \u27e8Y, \ud835\udfd9 _, by simp\u27e9\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 (\u03b1 : Type u) [Preorder \u03b1]\n    [IsDirected \u03b1 (\u00b7 \u2264 \u00b7)] [Nonempty \u03b1] : IsFiltered \u03b1 where\n#align category_theory.is_filtered_of_directed_le_nonempty CategoryTheory.isFiltered_of_directed_le_nonempty\n-/\n\n-- Sanity checks\nexample (\u03b1 : Type u) [SemilatticeSup \u03b1] [OrderBot \u03b1] : IsFiltered \u03b1 := by infer_instance\n\nexample (\u03b1 : Type u) [SemilatticeSup \u03b1] [OrderTop \u03b1] : IsFiltered \u03b1 := by infer_instance\n\ninstance : IsFiltered (Discrete PUnit)\n    where\n  cocone_objs X Y := \u27e8\u27e8PUnit.unit\u27e9, \u27e8\u27e8by decide\u27e9\u27e9, \u27e8\u27e8by decide\u27e9\u27e9, trivial\u27e9\n  cocone_maps X Y f g := \u27e8\u27e8PUnit.unit\u27e9, \u27e8\u27e8by decide\u27e9\u27e9, by decide\u27e9\n  Nonempty := \u27e8\u27e8PUnit.unit\u27e9\u27e9\n\nnamespace IsFiltered\n\nsection AllowEmpty\n\nvariable {C} [IsFilteredOrEmpty C]\n\ntheorem cocone_objs : \u2200 X Y : C, \u2203 (Z : _)(f : X \u27f6 Z)(g : Y \u27f6 Z), True :=\n  IsFilteredOrEmpty.cocone_objs\n#align category_theory.is_filtered.cocone_objs CategoryTheory.IsFiltered.cocone_objs\n\ntheorem cocone_maps : \u2200 \u2983X Y : C\u2984 (f g : X \u27f6 Y), \u2203 (Z : _)(h : Y \u27f6 Z), f \u226b h = g \u226b 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 \u27f6 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' \u27f6 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 \u27f6 j'`, is an arbitrary choice of object\nwhich admits a morphism `coeq_hom f f' : j' \u27f6 coeq f f'` such that\n`coeq_condition : f \u226b coeq_hom f f' = f' \u226b coeq_hom f f'`.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq {j j' : C} (f f' : j \u27f6 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 \u27f6 j'`, is an arbitrary choice of morphism\n`coeq_hom f f' : j' \u27f6 coeq f f'` such that\n`coeq_condition : f \u226b coeq_hom f f' = f' \u226b coeq_hom f f'`.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeqHom {j j' : C} (f f' : j \u27f6 j') : j' \u27f6 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 \u27f6 j'`, is the proof that\n`f \u226b coeq_hom f f' = f' \u226b coeq_hom f f'`.\n-/\n@[simp, reassoc.1]\ntheorem coeq_condition {j j' : C} (f f' : j \u27f6 j') : f \u226b coeqHom f f' = f' \u226b 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) : \u2203 S : C, \u2200 {X}, X \u2208 O \u2192 Nonempty (X \u27f6 S) := by\n  classical\n    apply Finset.induction_on O\n    \u00b7 exact \u27e8is_filtered.nonempty.some, by rintro - \u27e8\u27e9\u27e9\n    \u00b7 rintro X O' nm \u27e8S', w'\u27e9\n      use max X S'\n      rintro Y mY\n      obtain rfl | h := eq_or_ne Y X\n      \u00b7 exact \u27e8left_to_max _ _\u27e9\n      \u00b7 exact \u27e8(w' (Finset.mem_of_mem_insert_of_ne mY h)).some \u226b right_to_max _ _\u27e9\n#align category_theory.is_filtered.sup_objs_exists CategoryTheory.IsFiltered.sup_objs_exists\n-/\n\nvariable (O : Finset C) (H : Finset (\u03a3'(X Y : C)(mX : X \u2208 O)(mY : Y \u2208 O), X \u27f6 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 \u27f6 S` from each `X`,\nsuch that the triangles commute: `f \u226b T Y = T X`, for `f : X \u27f6 Y` in the `finset`.\n-/\ntheorem sup_exists :\n    \u2203 (S : C)(T : \u2200 {X : C}, X \u2208 O \u2192 (X \u27f6 S)),\n      \u2200 {X Y : C} (mX : X \u2208 O) (mY : Y \u2208 O) {f : X \u27f6 Y},\n        (\u27e8X, Y, mX, mY, f\u27e9 : \u03a3'(X Y : C)(mX : X \u2208 O)(mY : Y \u2208 O), X \u27f6 Y) \u2208 H \u2192 f \u226b T mY = T mX :=\n  by\n  classical\n    apply Finset.induction_on H\n    \u00b7 obtain \u27e8S, f\u27e9 := sup_objs_exists O\n      refine' \u27e8S, fun X mX => (f mX).some, _\u27e9\n      rintro - - - - - \u27e8\u27e9\n    \u00b7 rintro \u27e8X, Y, mX, mY, f\u27e9 H' nmf \u27e8S', T', w'\u27e9\n      refine' \u27e8coeq (f \u226b T' mY) (T' mX), fun Z mZ => T' mZ \u226b coeq_hom (f \u226b T' mY) (T' mX), _\u27e9\n      intro X' Y' mX' mY' f' mf'\n      rw [\u2190 category.assoc]\n      by_cases h : X = X' \u2227 Y = Y'\n      \u00b7 rcases h with \u27e8rfl, rfl\u27e9\n        by_cases hf : f = f'\n        \u00b7 subst hf\n          apply coeq_condition\n        \u00b7 rw [@w' _ _ mX mY f' (by simpa [hf \u2218 Eq.symm] using mf')]\n      \u00b7 rw [@w' _ _ mX' mY' f' _]\n        apply Finset.mem_of_mem_insert_of_ne mf'\n        contrapose! h\n        obtain \u27e8rfl, h\u27e9 := h\n        rw [heq_iff_eq, PSigma.mk.inj_iff] at h\n        exact \u27e8rfl, h.1.symm\u27e9\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 \u2208 O) : X \u27f6 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 \u2208 O) (mY : Y \u2208 O) {f : X \u27f6 Y}\n    (mf : (\u27e8X, Y, mX, mY, f\u27e9 : \u03a3'(X Y : C)(mX : X \u2208 O)(mY : Y \u2208 O), X \u27f6 Y) \u2208 H) :\n    f \u226b 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 \u2964 C` with `fin_category J`,\nthere exists a cocone over `F`.\n-/\ntheorem cocone_nonempty (F : J \u2964 C) : Nonempty (Cocone F) := by\n  classical\n    let O := finset.univ.image F.obj\n    let H : Finset (\u03a3'(X Y : C)(mX : X \u2208 O)(mY : Y \u2208 O), X \u27f6 Y) :=\n      finset.univ.bUnion fun X : J =>\n        finset.univ.bUnion fun Y : J =>\n          finset.univ.image fun f : X \u27f6 Y => \u27e8F.obj X, F.obj Y, by simp, by simp, F.map f\u27e9\n    obtain \u27e8Z, f, w\u27e9 := sup_exists O H\n    refine' \u27e8\u27e8Z, \u27e8fun X => f (by simp), _\u27e9\u27e9\u27e9\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\u1d62, exists_and_left, exists_prop_of_true,\n      Finset.mem_image]\n    exact \u27e8j, rfl, j', g, by simp\u27e9\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 \u2964 C`, for `fin_category J` and `is_filtered C`.\n-/\nnoncomputable def cocone (F : J \u2964 C) : Cocone F :=\n  (cocone_nonempty F).some\n#align category_theory.is_filtered.cocone CategoryTheory.IsFiltered.cocone\n-/\n\nvariable {D : Type u\u2081} [Category.{v\u2081} D]\n\n#print CategoryTheory.IsFiltered.of_right_adjoint /-\n/-- If `C` is filtered, and we have a functor `R : C \u2964 D` with a left adjoint, then `D` is filtered.\n-/\ntheorem of_right_adjoint {L : D \u2964 C} {R : C \u2964 D} (h : L \u22a3 R) : IsFiltered D :=\n  { cocone_objs := fun X Y =>\n      \u27e8_, h.homEquiv _ _ (leftToMax _ _), h.homEquiv _ _ (rightToMax _ _), \u27e8\u27e9\u27e9\n    cocone_maps := fun X Y f g =>\n      \u27e8_, h.homEquiv _ _ (coeqHom _ _), by\n        rw [\u2190 h.hom_equiv_naturality_left, \u2190 h.hom_equiv_naturality_left, coeq_condition]\u27e9\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 \u2964 D`, then `D` is filtered. -/\ntheorem of_isRightAdjoint (R : C \u2964 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\u2093'. -/\n/-- Being filtered is preserved by equivalence of categories. -/\ntheorem of_equivalence (h : C \u224c 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\u2083 /-\n/-- `max\u2083 j\u2081 j\u2082 j\u2083` is an arbitrary choice of object to the right of `j\u2081`, `j\u2082` and `j\u2083`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def max\u2083 (j\u2081 j\u2082 j\u2083 : C) : C :=\n  max (max j\u2081 j\u2082) j\u2083\n#align category_theory.is_filtered.max\u2083 CategoryTheory.IsFiltered.max\u2083\n-/\n\n#print CategoryTheory.IsFiltered.firstToMax\u2083 /-\n/-- `first_to_max\u2083 j\u2081 j\u2082 j\u2083` is an arbitrary choice of morphism from `j\u2081` to `max\u2083 j\u2081 j\u2082 j\u2083`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def firstToMax\u2083 (j\u2081 j\u2082 j\u2083 : C) : j\u2081 \u27f6 max\u2083 j\u2081 j\u2082 j\u2083 :=\n  leftToMax j\u2081 j\u2082 \u226b leftToMax (max j\u2081 j\u2082) j\u2083\n#align category_theory.is_filtered.first_to_max\u2083 CategoryTheory.IsFiltered.firstToMax\u2083\n-/\n\n#print CategoryTheory.IsFiltered.secondToMax\u2083 /-\n/-- `second_to_max\u2083 j\u2081 j\u2082 j\u2083` is an arbitrary choice of morphism from `j\u2082` to `max\u2083 j\u2081 j\u2082 j\u2083`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def secondToMax\u2083 (j\u2081 j\u2082 j\u2083 : C) : j\u2082 \u27f6 max\u2083 j\u2081 j\u2082 j\u2083 :=\n  rightToMax j\u2081 j\u2082 \u226b leftToMax (max j\u2081 j\u2082) j\u2083\n#align category_theory.is_filtered.second_to_max\u2083 CategoryTheory.IsFiltered.secondToMax\u2083\n-/\n\n#print CategoryTheory.IsFiltered.thirdToMax\u2083 /-\n/-- `third_to_max\u2083 j\u2081 j\u2082 j\u2083` is an arbitrary choice of morphism from `j\u2083` to `max\u2083 j\u2081 j\u2082 j\u2083`,\nwhose existence is ensured by `is_filtered`.\n-/\nnoncomputable def thirdToMax\u2083 (j\u2081 j\u2082 j\u2083 : C) : j\u2083 \u27f6 max\u2083 j\u2081 j\u2082 j\u2083 :=\n  rightToMax (max j\u2081 j\u2082) j\u2083\n#align category_theory.is_filtered.third_to_max\u2083 CategoryTheory.IsFiltered.thirdToMax\u2083\n-/\n\n#print CategoryTheory.IsFiltered.coeq\u2083 /-\n/-- `coeq\u2083 f g h`, for morphisms `f g h : j\u2081 \u27f6 j\u2082`, is an arbitrary choice of object\nwhich admits a morphism `coeq\u2083_hom f g h : j\u2082 \u27f6 coeq\u2083 f g h` such that\n`coeq\u2083_condition\u2081`, `coeq\u2083_condition\u2082` and `coeq\u2083_condition\u2083` are satisfied.\nIts existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq\u2083 {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) : C :=\n  coeq (coeqHom f g \u226b leftToMax (coeq f g) (coeq g h))\n    (coeqHom g h \u226b rightToMax (coeq f g) (coeq g h))\n#align category_theory.is_filtered.coeq\u2083 CategoryTheory.IsFiltered.coeq\u2083\n-/\n\n#print CategoryTheory.IsFiltered.coeq\u2083Hom /-\n/-- `coeq\u2083_hom f g h`, for morphisms `f g h : j\u2081 \u27f6 j\u2082`, is an arbitrary choice of morphism\n`j\u2082 \u27f6 coeq\u2083 f g h` such that `coeq\u2083_condition\u2081`, `coeq\u2083_condition\u2082` and `coeq\u2083_condition\u2083`\nare satisfied. Its existence is ensured by `is_filtered`.\n-/\nnoncomputable def coeq\u2083Hom {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) : j\u2082 \u27f6 coeq\u2083 f g h :=\n  coeqHom f g \u226b\n    leftToMax (coeq f g) (coeq g h) \u226b\n      coeqHom (coeqHom f g \u226b leftToMax (coeq f g) (coeq g h))\n        (coeqHom g h \u226b rightToMax (coeq f g) (coeq g h))\n#align category_theory.is_filtered.coeq\u2083_hom CategoryTheory.IsFiltered.coeq\u2083Hom\n-/\n\n#print CategoryTheory.IsFiltered.coeq\u2083_condition\u2081 /-\ntheorem coeq\u2083_condition\u2081 {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) : f \u226b coeq\u2083Hom f g h = g \u226b coeq\u2083Hom f g h :=\n  by rw [coeq\u2083_hom, reassoc_of (coeq_condition f g)]\n#align category_theory.is_filtered.coeq\u2083_condition\u2081 CategoryTheory.IsFiltered.coeq\u2083_condition\u2081\n-/\n\n#print CategoryTheory.IsFiltered.coeq\u2083_condition\u2082 /-\ntheorem coeq\u2083_condition\u2082 {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) : g \u226b coeq\u2083Hom f g h = h \u226b coeq\u2083Hom f g h :=\n  by\n  dsimp [coeq\u2083_hom]\n  slice_lhs 2 4 => rw [\u2190 category.assoc, coeq_condition _ _]\n  slice_rhs 2 4 => rw [\u2190 category.assoc, coeq_condition _ _]\n  slice_lhs 1 3 => rw [\u2190 category.assoc, coeq_condition _ _]\n  simp only [category.assoc]\n#align category_theory.is_filtered.coeq\u2083_condition\u2082 CategoryTheory.IsFiltered.coeq\u2083_condition\u2082\n-/\n\n#print CategoryTheory.IsFiltered.coeq\u2083_condition\u2083 /-\ntheorem coeq\u2083_condition\u2083 {j\u2081 j\u2082 : C} (f g h : j\u2081 \u27f6 j\u2082) : f \u226b coeq\u2083Hom f g h = h \u226b coeq\u2083Hom f g h :=\n  Eq.trans (coeq\u2083_condition\u2081 f g h) (coeq\u2083_condition\u2082 f g h)\n#align category_theory.is_filtered.coeq\u2083_condition\u2083 CategoryTheory.IsFiltered.coeq\u2083_condition\u2083\n-/\n\n#print CategoryTheory.IsFiltered.span /-\n/-- For every span `j \u27f5 i \u27f6 j'`, there\n   exists a cocone `j \u27f6 k \u27f5 j'` such that the square commutes. -/\ntheorem span {i j j' : C} (f : i \u27f6 j) (f' : i \u27f6 j') :\n    \u2203 (k : C)(g : j \u27f6 k)(g' : j' \u27f6 k), f \u226b g = f' \u226b g' :=\n  let \u27e8K, G, G', _\u27e9 := cocone_objs j j'\n  let \u27e8k, e, he\u27e9 := cocone_maps (f \u226b G) (f' \u226b G')\n  \u27e8k, G \u226b e, G' \u226b e, by simpa only [\u2190 category.assoc] \u27e9\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\u2081   j\u2082\n |\\  /|\n | \\/ |\n | /\\ |\n |/  \\\u2223\n vv  vv\n k\u2081  k\u2082\n```\nin a filtered category, we can construct an object `s` and two morphisms from `k\u2081` and `k\u2082` to `s`,\nmaking the resulting squares commute.\n-/\ntheorem bowtie {j\u2081 j\u2082 k\u2081 k\u2082 : C} (f\u2081 : j\u2081 \u27f6 k\u2081) (g\u2081 : j\u2081 \u27f6 k\u2082) (f\u2082 : j\u2082 \u27f6 k\u2081) (g\u2082 : j\u2082 \u27f6 k\u2082) :\n    \u2203 (s : C)(\u03b1 : k\u2081 \u27f6 s)(\u03b2 : k\u2082 \u27f6 s), f\u2081 \u226b \u03b1 = g\u2081 \u226b \u03b2 \u2227 f\u2082 \u226b \u03b1 = g\u2082 \u226b \u03b2 :=\n  by\n  obtain \u27e8t, k\u2081t, k\u2082t, ht\u27e9 := span f\u2081 g\u2081\n  obtain \u27e8s, ts, hs\u27e9 := cocone_maps (f\u2082 \u226b k\u2081t) (g\u2082 \u226b k\u2082t)\n  simp_rw [category.assoc] at hs\n  exact \u27e8s, k\u2081t \u226b ts, k\u2082t \u226b ts, by rw [reassoc_of ht], hs\u27e9\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\u2081    j\u2082    j\u2083\n |\\   / \\   / |\n | \\ /   \\ /  |\n |  vv    vv  |\n \\  k\u2081    k\u2082 /\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\u2081`, `k\u2082` and `l`\nto `s`, making the resulting squares commute.\n-/\ntheorem tulip {j\u2081 j\u2082 j\u2083 k\u2081 k\u2082 l : C} (f\u2081 : j\u2081 \u27f6 k\u2081) (f\u2082 : j\u2082 \u27f6 k\u2081) (f\u2083 : j\u2082 \u27f6 k\u2082) (f\u2084 : j\u2083 \u27f6 k\u2082)\n    (g\u2081 : j\u2081 \u27f6 l) (g\u2082 : j\u2083 \u27f6 l) :\n    \u2203 (s : C)(\u03b1 : k\u2081 \u27f6 s)(\u03b2 : l \u27f6 s)(\u03b3 : k\u2082 \u27f6 s),\n      f\u2081 \u226b \u03b1 = g\u2081 \u226b \u03b2 \u2227 f\u2082 \u226b \u03b1 = f\u2083 \u226b \u03b3 \u2227 f\u2084 \u226b \u03b3 = g\u2082 \u226b \u03b2 :=\n  by\n  obtain \u27e8l', k\u2081l, k\u2082l, hl\u27e9 := span f\u2082 f\u2083\n  obtain \u27e8s, ls, l's, hs\u2081, hs\u2082\u27e9 := bowtie g\u2081 (f\u2081 \u226b k\u2081l) g\u2082 (f\u2084 \u226b k\u2082l)\n  refine' \u27e8s, k\u2081l \u226b l's, ls, k\u2082l \u226b l's, _, by rw [reassoc_of hl], _\u27e9 <;>\n    simp only [hs\u2081, hs\u2082, 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 : \u2200 X Y : C, \u2203 (W : _)(f : W \u27f6 X)(g : W \u27f6 Y), True\n  cone_maps : \u2200 \u2983X Y : C\u2984 (f g : X \u27f6 Y), \u2203 (W : _)(h : W \u27f6 X), h \u226b f = h \u226b 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 (\u03b1 : Type u) [SemilatticeInf \u03b1] :\n    IsCofilteredOrEmpty \u03b1\n    where\n  cone_objs X Y := \u27e8X \u2293 Y, homOfLE inf_le_left, homOfLE inf_le_right, trivial\u27e9\n  cone_maps X Y f g := \u27e8X, \ud835\udfd9 _, by ext\u27e9\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 (\u03b1 : Type u) [SemilatticeInf \u03b1]\n    [Nonempty \u03b1] : IsCofiltered \u03b1 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 (\u03b1 : Type u) [Preorder \u03b1]\n    [IsDirected \u03b1 (\u00b7 \u2265 \u00b7)] : IsCofilteredOrEmpty \u03b1\n    where\n  cone_objs X Y :=\n    let \u27e8Z, hX, hY\u27e9 := exists_le_le X Y\n    \u27e8Z, homOfLE hX, homOfLE hY, trivial\u27e9\n  cone_maps X Y f g := \u27e8X, \ud835\udfd9 _, by simp\u27e9\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 (\u03b1 : Type u) [Preorder \u03b1]\n    [IsDirected \u03b1 (\u00b7 \u2265 \u00b7)] [Nonempty \u03b1] : IsCofiltered \u03b1 where\n#align category_theory.is_cofiltered_of_directed_ge_nonempty CategoryTheory.isCofiltered_of_directed_ge_nonempty\n-/\n\n-- Sanity checks\nexample (\u03b1 : Type u) [SemilatticeInf \u03b1] [OrderBot \u03b1] : IsCofiltered \u03b1 := by infer_instance\n\nexample (\u03b1 : Type u) [SemilatticeInf \u03b1] [OrderTop \u03b1] : IsCofiltered \u03b1 := by infer_instance\n\ninstance : IsCofiltered (Discrete PUnit)\n    where\n  cone_objs X Y := \u27e8\u27e8PUnit.unit\u27e9, \u27e8\u27e8by decide\u27e9\u27e9, \u27e8\u27e8by decide\u27e9\u27e9, trivial\u27e9\n  cone_maps X Y f g := \u27e8\u27e8PUnit.unit\u27e9, \u27e8\u27e8by decide\u27e9\u27e9, by decide\u27e9\n  Nonempty := \u27e8\u27e8PUnit.unit\u27e9\u27e9\n\nnamespace IsCofiltered\n\nsection AllowEmpty\n\nvariable {C} [IsCofilteredOrEmpty C]\n\ntheorem cone_objs : \u2200 X Y : C, \u2203 (W : _)(f : W \u27f6 X)(g : W \u27f6 Y), True :=\n  IsCofilteredOrEmpty.cone_objs\n#align category_theory.is_cofiltered.cone_objs CategoryTheory.IsCofiltered.cone_objs\n\ntheorem cone_maps : \u2200 \u2983X Y : C\u2984 (f g : X \u27f6 Y), \u2203 (W : _)(h : W \u27f6 X), h \u226b f = h \u226b 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' \u27f6 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' \u27f6 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 \u27f6 j'`, is an arbitrary choice of object\nwhich admits a morphism `eq_hom f f' : eq f f' \u27f6 j` such that\n`eq_condition : eq_hom f f' \u226b f = eq_hom f f' \u226b f'`.\nIts existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def eq {j j' : C} (f f' : j \u27f6 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 \u27f6 j'`, is an arbitrary choice of morphism\n`eq_hom f f' : eq f f' \u27f6 j` such that\n`eq_condition : eq_hom f f' \u226b f = eq_hom f f' \u226b f'`.\nIts existence is ensured by `is_cofiltered`.\n-/\nnoncomputable def eqHom {j j' : C} (f f' : j \u27f6 j') : eq f f' \u27f6 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 \u27f6 j'`, is the proof that\n`eq_hom f f' \u226b f = eq_hom f f' \u226b f'`.\n-/\n@[simp, reassoc.1]\ntheorem eq_condition {j j' : C} (f f' : j \u27f6 j') : eqHom f f' \u226b f = eqHom f f' \u226b 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 \u27f6 i \u27f5 j'`,\n there exists a cone `j \u27f5 k \u27f6 j'` such that the square commutes. -/\ntheorem cospan {i j j' : C} (f : j \u27f6 i) (f' : j' \u27f6 i) :\n    \u2203 (k : C)(g : k \u27f6 j)(g' : k \u27f6 j'), g \u226b f = g' \u226b f' :=\n  let \u27e8K, G, G', _\u27e9 := cone_objs j j'\n  let \u27e8k, e, he\u27e9 := cone_maps (G \u226b f) (G' \u226b f')\n  \u27e8k, e \u226b G, e \u226b G', by simpa only [category.assoc] using he\u27e9\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\u2093'. -/\ntheorem CategoryTheory.Functor.ranges_directed (F : C \u2964 Type _) (j : C) :\n    Directed (\u00b7 \u2287 \u00b7) fun f : \u03a3'i, i \u27f6 j => Set.range (F.map f.2) := fun \u27e8i, ij\u27e9 \u27e8k, kj\u27e9 =>\n  by\n  let \u27e8l, li, lk, e\u27e9 := cospan ij kj\n  refine' \u27e8\u27e8l, lk \u226b kj\u27e9, e \u25b8 _, _\u27e9 <;> 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) : \u2203 S : C, \u2200 {X}, X \u2208 O \u2192 Nonempty (S \u27f6 X) := by\n  classical\n    apply Finset.induction_on O\n    \u00b7 exact \u27e8is_cofiltered.nonempty.some, by rintro - \u27e8\u27e9\u27e9\n    \u00b7 rintro X O' nm \u27e8S', w'\u27e9\n      use min X S'\n      rintro Y mY\n      obtain rfl | h := eq_or_ne Y X\n      \u00b7 exact \u27e8min_to_left _ _\u27e9\n      \u00b7 exact \u27e8min_to_right _ _ \u226b (w' (Finset.mem_of_mem_insert_of_ne mY h)).some\u27e9\n#align category_theory.is_cofiltered.inf_objs_exists CategoryTheory.IsCofiltered.inf_objs_exists\n-/\n\nvariable (O : Finset C) (H : Finset (\u03a3'(X Y : C)(mX : X \u2208 O)(mY : Y \u2208 O), X \u27f6 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 \u27f6 X` from each `X`,\nsuch that the triangles commute: `T X \u226b f = T Y`, for `f : X \u27f6 Y` in the `finset`.\n-/\ntheorem inf_exists :\n    \u2203 (S : C)(T : \u2200 {X : C}, X \u2208 O \u2192 (S \u27f6 X)),\n      \u2200 {X Y : C} (mX : X \u2208 O) (mY : Y \u2208 O) {f : X \u27f6 Y},\n        (\u27e8X, Y, mX, mY, f\u27e9 : \u03a3'(X Y : C)(mX : X \u2208 O)(mY : Y \u2208 O), X \u27f6 Y) \u2208 H \u2192 T mX \u226b f = T mY :=\n  by\n  classical\n    apply Finset.induction_on H\n    \u00b7 obtain \u27e8S, f\u27e9 := inf_objs_exists O\n      refine' \u27e8S, fun X mX => (f mX).some, _\u27e9\n      rintro - - - - - \u27e8\u27e9\n    \u00b7 rintro \u27e8X, Y, mX, mY, f\u27e9 H' nmf \u27e8S', T', w'\u27e9\n      refine' \u27e8Eq (T' mX \u226b f) (T' mY), fun Z mZ => eq_hom (T' mX \u226b f) (T' mY) \u226b T' mZ, _\u27e9\n      intro X' Y' mX' mY' f' mf'\n      rw [category.assoc]\n      by_cases h : X = X' \u2227 Y = Y'\n      \u00b7 rcases h with \u27e8rfl, rfl\u27e9\n        by_cases hf : f = f'\n        \u00b7 subst hf\n          apply eq_condition\n        \u00b7 rw [@w' _ _ mX mY f' (by simpa [hf \u2218 Eq.symm] using mf')]\n      \u00b7 rw [@w' _ _ mX' mY' f' _]\n        apply Finset.mem_of_mem_insert_of_ne mf'\n        contrapose! h\n        obtain \u27e8rfl, h\u27e9 := h\n        rw [heq_iff_eq, PSigma.mk.inj_iff] at h\n        exact \u27e8rfl, h.1.symm\u27e9\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 \u2208 O) : inf O H \u27f6 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 \u2208 O) (mY : Y \u2208 O) {f : X \u27f6 Y}\n    (mf : (\u27e8X, Y, mX, mY, f\u27e9 : \u03a3'(X Y : C)(mX : X \u2208 O)(mY : Y \u2208 O), X \u27f6 Y) \u2208 H) :\n    infTo O H mX \u226b 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 \u2964 C` with `fin_category J`,\nthere exists a cone over `F`.\n-/\ntheorem cone_nonempty (F : J \u2964 C) : Nonempty (Cone F) := by\n  classical\n    let O := finset.univ.image F.obj\n    let H : Finset (\u03a3'(X Y : C)(mX : X \u2208 O)(mY : Y \u2208 O), X \u27f6 Y) :=\n      finset.univ.bUnion fun X : J =>\n        finset.univ.bUnion fun Y : J =>\n          finset.univ.image fun f : X \u27f6 Y => \u27e8F.obj X, F.obj Y, by simp, by simp, F.map f\u27e9\n    obtain \u27e8Z, f, w\u27e9 := inf_exists O H\n    refine' \u27e8\u27e8Z, \u27e8fun X => f (by simp), _\u27e9\u27e9\u27e9\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\u1d62, exists_and_left, exists_prop_of_true,\n      Finset.mem_image]\n    exact \u27e8j, rfl, j', g, by simp\u27e9\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 \u2964 C`, for `fin_category J` and `is_cofiltered C`.\n-/\nnoncomputable def cone (F : J \u2964 C) : Cone F :=\n  (cone_nonempty F).some\n#align category_theory.is_cofiltered.cone CategoryTheory.IsCofiltered.cone\n-/\n\nvariable {D : Type u\u2081} [Category.{v\u2081} D]\n\n#print CategoryTheory.IsCofiltered.of_left_adjoint /-\n/-- If `C` is cofiltered, and we have a functor `L : C \u2964 D` with a right adjoint,\nthen `D` is cofiltered.\n-/\ntheorem of_left_adjoint {L : C \u2964 D} {R : D \u2964 C} (h : L \u22a3 R) : IsCofiltered D :=\n  { cone_objs := fun X Y =>\n      \u27e8L.obj (min (R.obj X) (R.obj Y)), (h.homEquiv _ X).symm (minToLeft _ _),\n        (h.homEquiv _ Y).symm (minToRight _ _), \u27e8\u27e9\u27e9\n    cone_maps := fun X Y f g =>\n      \u27e8L.obj (eq (R.map f) (R.map g)), (h.homEquiv _ _).symm (eqHom _ _), by\n        rw [\u2190 h.hom_equiv_naturality_right_symm, \u2190 h.hom_equiv_naturality_right_symm, eq_condition]\u27e9\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 \u2964 D`, then `D` is cofiltered. -/\ntheorem of_isLeftAdjoint (L : C \u2964 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\u2093'. -/\n/-- Being cofiltered is preserved by equivalence of categories. -/\ntheorem of_equivalence (h : C \u224c 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\u1d52\u1d56\n    where\n  cone_objs X Y :=\n    \u27e8op (IsFiltered.max X.unop Y.unop), (IsFiltered.leftToMax _ _).op,\n      (IsFiltered.rightToMax _ _).op, trivial\u27e9\n  cone_maps X Y f g :=\n    \u27e8op (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, \u2190 op_comp, \u2190 op_comp]\n      congr 1\n      exact is_filtered.coeq_condition f.unop g.unop\u27e9\n  Nonempty := \u27e8op IsFiltered.nonempty.some\u27e9\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\u1d52\u1d56\n    where\n  cocone_objs X Y :=\n    \u27e8op (IsCofiltered.min X.unop Y.unop), (IsCofiltered.minToLeft X.unop Y.unop).op,\n      (IsCofiltered.minToRight X.unop Y.unop).op, trivial\u27e9\n  cocone_maps X Y f g :=\n    \u27e8op (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, \u2190 op_comp, \u2190 op_comp]\n      congr 1\n      exact is_cofiltered.eq_condition f.unop g.unop\u27e9\n  Nonempty := \u27e8op IsCofiltered.nonempty.some\u27e9\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\u2082} C) :=\n  IsFiltered.of_equivalence ULift.equivalence\n\ninstance [IsCofiltered C] : IsCofiltered (ULift.{u\u2082} 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 (\u03b1\u2081 : Type _) (\u03b1\u2082 : Type _) [NCRing \u03b1\u2081] [NCRing \u03b1\u2082] : NCRing (\u03b1\u2081 \u00d7 \u03b1\u2082) where\n      toNeg := (Group.Product \u03b1\u2081 \u03b1\u2082).toNeg\n      add_neg := (Group.Product \u03b1\u2081 \u03b1\u2082).add_neg\n\n    protected instance multi_product {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, NCRing (f\u03b9 i)] : NCRing (MultiProd f\u03b9) where\n      toNeg   := (Group.multi_product f\u03b9).toNeg\n      add_neg := (Group.multi_product f\u03b9).add_neg\n\n    theorem neg_mul [NCRing \u03b1] (a b : \u03b1) : -a * b = -(a * b) := by\n      rw [\u2190add_right_cancel _ _ (a * b), neg_add, \u2190mul_distrib_right, neg_add, zero_mul]\n    theorem mul_neg [NCRing \u03b1] (a b : \u03b1) : a * -b = -(a * b) := by\n      rw [\u2190add_right_cancel _ _ (a * b), neg_add, \u2190mul_distrib_left, neg_add, mul_zero]\n    theorem mul_neg_swap [NCRing \u03b1] (a b : \u03b1) : a * -b = -a * b := by\n      rw [mul_neg, neg_mul]\n\n    theorem neg_one_mul [NCRing \u03b1] (a : \u03b1) : -1 * a = -a := by\n      rw [neg_mul, one_mul]\n    theorem neg_one_mul_add [NCRing \u03b1] (a b : \u03b1) : -1 * (a + b) = -a + -b := by\n      rw [mul_distrib_left, neg_one_mul, neg_one_mul]\n    theorem neg_one_mul_add' [NCRing \u03b1] (a b : \u03b1) : -1 * (a + b) = -b + -a := by\n      rw [neg_one_mul, neg_add_distrib]\n\n    theorem sub_mul_distrib_left [NCRing \u03b1] (a b c : \u03b1) : 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 \u03b1] (a b c : \u03b1) : (a - b) * c = a * c - b * c := by\n      rw [sub_def, mul_distrib_right, neg_mul]; rfl\n\n    protected class constructor_ncr (\u03b1 : Type _) extends Group.constructor_g \u03b1, One \u03b1, Mul \u03b1 where\n      mul_one           : \u2200 a : \u03b1, a * 1 = a\n      one_mul           : \u2200 a : \u03b1, 1 * a = a\n      mul_assoc         : \u2200 a b c : \u03b1, (a * b) * c = a * (b * c)\n      mul_distrib_left  : \u2200 a b c : \u03b1, a * (b + c) = a * b + a * c\n      mul_distrib_right : \u2200 a b c : \u03b1, (a + b) * c = a * c + b * c\n\n    protected def construct {\u03b1 : Type _} (c : NCRing.constructor_ncr \u03b1) : NCRing \u03b1 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 : \u2200 a : \u03b1, -a = -1 * a := fun a => by\n                rw [\u2190(Group.construct c.toconstructor_g).add_right_cancel _ _ a,\n                  (Group.construct c.toconstructor_g).neg_add]\n                conv => rhs rhs rw [\u2190c.one_mul a]\n                rw [\u2190c.mul_distrib_right, (Group.construct c.toconstructor_g).neg_add,\n                  \u2190(Group.construct c.toconstructor_g).add_right_cancel _ _ (0 * a),\n                  \u2190c.mul_distrib_right, c.add_zero, (Group.construct c.toconstructor_g).zero_add]\n              rw [this (b + a), c.mul_distrib_left, \u2190this, \u2190this])\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 [\u2190(Group.construct c.toconstructor_g).add_right_cancel _ _ (a * 0),\n              \u2190c.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 [\u2190(Group.construct c.toconstructor_g).add_right_cancel _ _ (0 * a),\n              \u2190c.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 (\u03b1 : Type _) [NCRing \u03b1] : NCRing.constructor_ncr \u03b1 where\n      toconstructor_g   := Group.to_constructor \u03b1\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 (\u03b1\u2081 : Type _) (\u03b1\u2082 : Type _) [Ring \u03b1\u2081] [Ring \u03b1\u2082] : Ring (\u03b1\u2081 \u00d7 \u03b1\u2082) where\n      toNCRing := NCRing.Product \u03b1\u2081 \u03b1\u2082\n      mul_comm := (Semiring.Product \u03b1\u2081 \u03b1\u2082).mul_comm\n\n    protected instance multi_product {\u03b9 : Type _} (f\u03b9 : \u03b9 \u2192 Type _) [\u2200 i, Ring (f\u03b9 i)] : Ring (MultiProd f\u03b9) where\n      mul_comm := (Semiring.multi_product f\u03b9).mul_comm\n\n    def is_NonTrivial (\u03b1 : Type _) [Ring \u03b1] : Prop := (1 : \u03b1) \u2260 0\n    def is_NonTrivial.toNonTrivialRing [Ring \u03b1] (h : is_NonTrivial \u03b1) : NonTrivialRing \u03b1 where\n      toNonTrivial.one_neq_zero := h\n\n    protected class constructor_r (\u03b1 : Type _) extends AbelianGroup.constructor_ab \u03b1, One \u03b1, Mul \u03b1 where\n      mul_one           : \u2200 a : \u03b1, a * 1 = a\n      mul_assoc         : \u2200 a b c : \u03b1, (a * b) * c = a * (b * c)\n      mul_distrib_left  : \u2200 a b c : \u03b1, a * (b + c) = a * b + a * c\n      mul_comm          : \u2200 a b : \u03b1, a * b = b * a\n\n    protected def construct {\u03b1 : Type _} (c : Ring.constructor_r \u03b1) : Ring \u03b1 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 (\u03b1 : Type _) [Ring \u03b1] : Ring.constructor_r \u03b1 where\n      toconstructor_ab  := AbelianGroup.to_constructor \u03b1\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 \u03b1] : Ring.is_NonTrivial \u03b1 := 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl, 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 `\u03b1`, for example, is obtained by requiring both the\ninstances `add_monoid \u03b1` and `has_continuous_add \u03b1`. -/\nclass has_continuous_add (M : Type u_5) [topological_space M] [Add M] \nwhere\n  continuous_add : continuous fun (p : M \u00d7 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 `\u03b1`, for example, is obtained by requiring both the instances `monoid \u03b1`\nand `has_continuous_mul \u03b1`. -/\nclass has_continuous_mul (M : Type u_5) [topological_space M] [Mul M] \nwhere\n  continuous_mul : continuous fun (p : M \u00d7 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 \u00d7 M) => prod.fst p + prod.snd p :=\n  has_continuous_add.continuous_add\n\ntheorem continuous.mul {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Mul M] [has_continuous_mul M] [topological_space \u03b1] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} (hf : continuous f) (hg : continuous g) : continuous fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] [topological_space \u03b1] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} {s : set \u03b1} (hf : continuous_on f s) (hg : continuous_on g s) : continuous_on (fun (x : \u03b1) => 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 \u00d7 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 {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} {x : filter \u03b1} {a : M} {b : M} (hf : filter.tendsto f x (nhds a)) (hg : filter.tendsto g x (nhds b)) : filter.tendsto (fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Mul M] [has_continuous_mul M] (b : M) {c : M} {f : \u03b1 \u2192 M} {l : filter \u03b1} (h : filter.tendsto (fun (k : \u03b1) => f k) l (nhds c)) : filter.tendsto (fun (k : \u03b1) => b * f k) l (nhds (b * c)) :=\n  filter.tendsto.mul tendsto_const_nhds h\n\ntheorem tendsto.add_const {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] (b : M) {c : M} {f : \u03b1 \u2192 M} {l : filter \u03b1} (h : filter.tendsto (fun (k : \u03b1) => f k) l (nhds c)) : filter.tendsto (fun (k : \u03b1) => f k + b) l (nhds (c + b)) :=\n  filter.tendsto.add h tendsto_const_nhds\n\ntheorem continuous_at.add {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] [topological_space \u03b1] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} {x : \u03b1} (hf : continuous_at f x) (hg : continuous_at g x) : continuous_at (fun (x : \u03b1) => f x + g x) x :=\n  filter.tendsto.add hf hg\n\ntheorem continuous_within_at.add {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [Add M] [has_continuous_add M] [topological_space \u03b1] {f : \u03b1 \u2192 M} {g : \u03b1 \u2192 M} {s : set \u03b1} {x : \u03b1} (hf : continuous_within_at f s x) (hg : continuous_within_at g s x) : continuous_within_at (fun (x : \u03b1) => 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 \u00d7 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 : \u2200 (x\u2080 : M), nhds x\u2080 = filter.map (fun (x : M) => x\u2080 * x) (nhds 1)) (hright : \u2200 (x\u2080 : M), nhds x\u2080 = filter.map (fun (x : M) => x * x\u2080) (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 : \u2200 (x\u2080 : M), nhds x\u2080 = filter.map (fun (x : M) => x\u2080 * 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 \u2191s + closure \u2191s \u2286 closure \u2191s := 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 \u2191s * closure \u2191s = closure \u2191s := 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 \u2191s) 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 \u2264 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 \u2191(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 \u2264 t) (ht : is_closed \u2191t) : submonoid.topological_closure s \u2264 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 \u2208 nhds 0) : \u2203 (V : set M), is_open V \u2227 0 \u2208 V \u2227 \u2200 (v : M), v \u2208 V \u2192 \u2200 (w : M), w \u2208 V \u2192 v + w \u2208 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 \u2208 nhds 0) : \u2203 (V : set M), \u2203 (H : V \u2208 nhds 0), \u2200 (v : M), v \u2208 V \u2192 \u2200 (w : M), w \u2208 V \u2192 v + w \u2208 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 \u2208 nhds 1) : \u2203 (V : set M), \u2203 (H : V \u2208 nhds 1), \u2200 {v w s t : M}, v \u2208 V \u2192 w \u2208 V \u2192 s \u2208 V \u2192 t \u2208 V \u2192 v * w * s * t \u2208 u := sorry\n\n/-- Given a neighborhood `U` of `1` there is an open neighborhood `V` of `1`\nsuch that `VV \u2286 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 \u2208 nhds 1) : \u2203 (V : set M), is_open V \u2227 1 \u2208 V \u2227 V * V \u2286 U := sorry\n\ntheorem tendsto_list_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M] [add_monoid M] [has_continuous_add M] {f : \u03b2 \u2192 \u03b1 \u2192 M} {x : filter \u03b1} {a : \u03b2 \u2192 M} (l : List \u03b2) : (\u2200 (c : \u03b2), c \u2208 l \u2192 filter.tendsto (f c) x (nhds (a c))) \u2192\n  filter.tendsto (fun (b : \u03b1) => list.sum (list.map (fun (c : \u03b2) => f c b) l)) x (nhds (list.sum (list.map a l))) := sorry\n\ntheorem continuous_list_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M] [add_monoid M] [has_continuous_add M] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1 \u2192 M} (l : List \u03b2) (h : \u2200 (c : \u03b2), c \u2208 l \u2192 continuous (f c)) : continuous fun (a : \u03b1) => list.sum (list.map (fun (c : \u03b2) => f c a) l) :=\n  iff.mpr continuous_iff_continuous_at\n    fun (x : \u03b1) => tendsto_list_sum l fun (c : \u03b2) (hc : c \u2208 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 : \u2115) : continuous fun (a : M) => a ^ n := sorry\n\ntheorem continuous.pow {\u03b1 : Type u_1} {M : Type u_3} [topological_space M] [monoid M] [has_continuous_mul M] {f : \u03b1 \u2192 M} [topological_space \u03b1] (h : continuous f) (n : \u2115) : continuous fun (b : \u03b1) => 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 \u2191S) : \u2191S \u2208 nhds 1 :=\n  mem_nhds_sets oS (submonoid.one_mem S)\n\ntheorem tendsto_multiset_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M] [comm_monoid M] [has_continuous_mul M] {f : \u03b2 \u2192 \u03b1 \u2192 M} {x : filter \u03b1} {a : \u03b2 \u2192 M} (s : multiset \u03b2) : (\u2200 (c : \u03b2), c \u2208 s \u2192 filter.tendsto (f c) x (nhds (a c))) \u2192\n  filter.tendsto (fun (b : \u03b1) => multiset.prod (multiset.map (fun (c : \u03b2) => f c b) s)) x\n    (nhds (multiset.prod (multiset.map a s))) := sorry\n\ntheorem tendsto_finset_sum {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M] [add_comm_monoid M] [has_continuous_add M] {f : \u03b2 \u2192 \u03b1 \u2192 M} {x : filter \u03b1} {a : \u03b2 \u2192 M} (s : finset \u03b2) : (\u2200 (c : \u03b2), c \u2208 s \u2192 filter.tendsto (f c) x (nhds (a c))) \u2192\n  filter.tendsto (fun (b : \u03b1) => finset.sum s fun (c : \u03b2) => f c b) x (nhds (finset.sum s fun (c : \u03b2) => a c)) :=\n  tendsto_multiset_sum (finset.val s)\n\ntheorem continuous_multiset_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M] [comm_monoid M] [has_continuous_mul M] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1 \u2192 M} (s : multiset \u03b2) : (\u2200 (c : \u03b2), c \u2208 s \u2192 continuous (f c)) \u2192 continuous fun (a : \u03b1) => multiset.prod (multiset.map (fun (c : \u03b2) => f c a) s) := sorry\n\ntheorem continuous_finset_prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} {M : Type u_3} [topological_space M] [comm_monoid M] [has_continuous_mul M] [topological_space \u03b1] {f : \u03b2 \u2192 \u03b1 \u2192 M} (s : finset \u03b2) : (\u2200 (c : \u03b2), c \u2208 s \u2192 continuous (f c)) \u2192 continuous fun (a : \u03b1) => finset.prod s fun (c : \u03b2) => 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 (\u03b1 : Type u)   | ll {}  : cmonad\n                                | rr {}  : cmonad\n                                | dim {} : \u03b1 \u2192 cmonad\nopen cmonad\n\ndef bool_to_cmonad {\u03b1 : Type u} : bool \u2192 cmonad \u03b1\n| ff := ll\n| tt := rr\n\ninstance inst_bool_to_cmonad (\u03b1 : Type u) : has_coe bool (cmonad \u03b1) :=\n\u27e8 bool_to_cmonad \u27e9\n\n@[inline] def cmor (\u03b1 \u03b2) := \u03b1 \u2192 cmonad \u03b2\n\n@[inline] def cbind {\u03b1 : Type u} {\u03b2 : Type v} (x) (f : cmor \u03b1 \u03b2) : cmonad \u03b2 :=\nmatch x with\n| ll    := ll\n| rr    := rr\n| dim x := f x\nend\n\ndef cmap {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (x : cmonad \u03b1) : cmonad \u03b2 :=\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 {\u03b1 \u03b2 : Type u} (b : bool) (f : cmor \u03b1 \u03b2) : (\u2191b >>= f) = \u2191b :=\nby cases b; reflexivity; reflexivity; reflexivity\n\ntheorem cbind_dim {\u03b1 \u03b2 : Type u} (a : \u03b1) (f : cmor \u03b1 \u03b2) : (dim a >>= f) = f a :=\nrfl\n\ntheorem cbind_assoc {\u03b1 \u03b2 \u03b3 : Type u} (a : cmonad \u03b1) (f : cmor \u03b1 \u03b2) (g : cmor \u03b2 \u03b3) :\n  ((a >>= f) >>= g) = (a >>= (\u03bb 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 {\u03b1 \u03b2 \u03b3} (g : cmor \u03b2 \u03b3) (f : cmor \u03b1 \u03b2) : cmor \u03b1 \u03b3 :=\n\u03bb x, do y <- f x,\n        g y\n\ninfixl ` \u2218c `:90 := ccomp\n\n/- The monad laws for cmonad -/\ntheorem cid_left {\u03b1 \u03b2} (f : cmor \u03b1 \u03b2) (x : \u03b1) : (dim \u2218c 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 {\u03b1 \u03b2} (f : cmor \u03b1 \u03b2) (x : \u03b1) : (f \u2218c dim) x = f x :=\nbegin\n  simp[ccomp],\n  exact rfl\nend\n\ntheorem ccomp_assoc {\u03b1 \u03b2 \u03b3 \u03b4} (f : cmor \u03b1 \u03b2) (g : cmor \u03b2 \u03b3) (h : cmor \u03b3 \u03b4) (x) :\n    ((h \u2218c g) \u2218c f) x = (h \u2218c (g \u2218c 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 {\u03b1 \u03b2} (f : cmor \u03b1 \u03b2) : Prop := \u2200 a, \u2203 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\u2081 v\u2082 u\u2081 u\u2082 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 \u2964 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 \u2245 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\u2081} [category C] [monoidal_category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] (F : C \u2192 D) [functorial F]\n    where\n  \u03b5 : \ud835\udfd9_ \u27f6 F \ud835\udfd9_\n  \u03bc : (X Y : C) \u2192 F X \u2297 F Y \u27f6 F (X \u2297 Y)\n  \u03bc_natural' :\n    autoParam\n      (\u2200 {X Y X' Y' : C} (f : X \u27f6 Y) (g : X' \u27f6 Y'),\n        (map F f \u2297 map F g) \u226b \u03bc Y Y' = \u03bc X X' \u226b map F (f \u2297 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      (\u2200 (X Y Z : C),\n        (\u03bc X Y \u2297 \ud835\udfd9) \u226b \u03bc (X \u2297 Y) Z \u226b map F (iso.hom \u03b1_) = iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 \u03bc Y Z) \u226b \u03bc X (Y \u2297 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 (\u2200 (X : C), iso.hom \u03bb_ = (\u03b5 \u2297 \ud835\udfd9) \u226b \u03bc \ud835\udfd9_ X \u226b map F (iso.hom \u03bb_))\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 (\u2200 (X : C), iso.hom \u03c1_ = (\ud835\udfd9 \u2297 \u03b5) \u226b \u03bc X \ud835\udfd9_ \u226b map F (iso.hom \u03c1_))\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.\u03bc_natural {C : Type u\u2081} [category C] [monoidal_category C]\n    {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2192 D} [functorial F] [c : lax_monoidal F]\n    {X : C} {Y : C} {X' : C} {Y' : C} (f : X \u27f6 Y) (g : X' \u27f6 Y') :\n    (map F f \u2297 map F g) \u226b lax_monoidal.\u03bc F Y Y' = lax_monoidal.\u03bc F X X' \u226b map F (f \u2297 g) :=\n  sorry\n\ntheorem lax_monoidal.left_unitality {C : Type u\u2081} [category C] [monoidal_category C] {D : Type u\u2082}\n    [category D] [monoidal_category D] {F : C \u2192 D} [functorial F] [c : lax_monoidal F] (X : C) :\n    iso.hom \u03bb_ = (lax_monoidal.\u03b5 F \u2297 \ud835\udfd9) \u226b lax_monoidal.\u03bc F \ud835\udfd9_ X \u226b map F (iso.hom \u03bb_) :=\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\u2081} [category C] [monoidal_category C] {D : Type u\u2082}\n    [category D] [monoidal_category D] {F : C \u2192 D} [functorial F] [c : lax_monoidal F] (X : C) :\n    iso.hom \u03c1_ = (\ud835\udfd9 \u2297 lax_monoidal.\u03b5 F) \u226b lax_monoidal.\u03bc F X \ud835\udfd9_ \u226b map F (iso.hom \u03c1_) :=\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\u2081} [category C] [monoidal_category C]\n    {D : Type u\u2082} [category D] [monoidal_category D] {F : C \u2192 D} [functorial F] [c : lax_monoidal F]\n    (X : C) (Y : C) (Z : C) :\n    (lax_monoidal.\u03bc F X Y \u2297 \ud835\udfd9) \u226b lax_monoidal.\u03bc F (X \u2297 Y) Z \u226b map F (iso.hom \u03b1_) =\n        iso.hom \u03b1_ \u226b (\ud835\udfd9 \u2297 lax_monoidal.\u03bc F Y Z) \u226b lax_monoidal.\u03bc F X (Y \u2297 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_\u03bc {C : Type u\u2081} [category C] [monoidal_category C] {D : Type u\u2082} [category D]\n    [monoidal_category D] (F : C \u2192 D) [I\u2081 : functorial F] [I\u2082 : lax_monoidal F] (X : C) (Y : C) :\n    \u03bc (of F) X Y = lax_monoidal.\u03bc F X Y :=\n  Eq.refl (\u03bc (of F) X Y)\n\nend lax_monoidal_functor\n\n\nprotected instance lax_monoidal_functor.obj.lax_monoidal {C : Type u\u2081} [category C]\n    [monoidal_category C] {D : Type u\u2082} [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.\u03b5 F) (lax_monoidal_functor.\u03bc F)\n\nprotected instance lax_monoidal_id {C : Type u\u2081} [category C] [monoidal_category C] :\n    lax_monoidal id :=\n  lax_monoidal.mk \ud835\udfd9 fun (X Y : C) => \ud835\udfd9\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 `\u03c4 > 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 \u03b1 N \u03c4` is the type of all satellite configurations of `N + 1` points\n  in the metric space `\u03b1`, with parameter `\u03c4`.\n* `has_besicovitch_covering` is a class recording that there exist `N` and `\u03c4 > 1` such that\n  there is no satellite configuration of `N + 1` points with parameter `\u03c4`.\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 `\u03c1 (closed_ball x r) / \u03bc (closed_ball x r)` tends\n  almost surely to the Radon-Nikodym derivative of `\u03c1` with respect to `\u03bc` 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., `\u03bc (s \u2229 closed_ball x r) / \u03bc (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 `\u03c4` 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 `\u03c4 \u2265 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 `\u03c4`). 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 (\u03b1 : Type*) [metric_space \u03b1] (N : \u2115) (\u03c4 : \u211d) :=\n(c : fin N.succ \u2192 \u03b1)\n(r : fin N.succ \u2192 \u211d)\n(rpos : \u2200 i, 0 < r i)\n(h : \u2200 i j, i \u2260 j \u2192 (r i \u2264 dist (c i) (c j) \u2227 r j \u2264 \u03c4 * r i) \u2228\n                    (r j \u2264 dist (c j) (c i) \u2227 r i \u2264 \u03c4 * r j))\n(hlast : \u2200 i < last N, r i \u2264 dist (c i) (c (last N)) \u2227 r (last N) \u2264 \u03c4 * r i)\n(inter : \u2200 i < last N, dist (c i) (c (last N)) \u2264 r i + r (last N))\n\n/-- A metric space has the Besicovitch covering property if there exist `N` and `\u03c4 > 1` such that\nthere are no satellite configuration of parameter `\u03c4` 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 (\u03b1 : Type*) [metric_space \u03b1] : Prop :=\n(no_satellite_config [] : \u2203 (N : \u2115) (\u03c4 : \u211d), 1 < \u03c4 \u2227 is_empty (besicovitch.satellite_config \u03b1 N \u03c4))\n\n/-- There is always a satellite configuration with a single point. -/\ninstance {\u03b1 : Type*} {\u03c4 : \u211d} [inhabited \u03b1] [metric_space \u03b1] :\n  inhabited (besicovitch.satellite_config \u03b1 0 \u03c4) :=\n\u27e8{ c := default,\n  r := \u03bb i, 1,\n  rpos := \u03bb i, zero_lt_one,\n  h := \u03bb i j hij, (hij (subsingleton.elim i j)).elim,\n  hlast := \u03bb i hi, by { rw subsingleton.elim i (last 0) at hi, exact (lt_irrefl _ hi).elim },\n  inter := \u03bb i hi, by { rw subsingleton.elim i (last 0) at hi, exact (lt_irrefl _ hi).elim } }\u27e9\n\nnamespace besicovitch\n\nnamespace satellite_config\nvariables {\u03b1 : Type*} [metric_space \u03b1] {N : \u2115} {\u03c4 : \u211d} (a : satellite_config \u03b1 N \u03c4)\n\nlemma inter' (i : fin N.succ) : dist (a.c i) (a.c (last N)) \u2264 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 \u2264 \u03c4) : a.r (last N) \u2264 \u03c4 * 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 (\u03b2 : Type*) (\u03b1 : Type*) :=\n(c : \u03b2 \u2192 \u03b1)\n(r : \u03b2 \u2192 \u211d)\n(rpos : \u2200 b, 0 < r b)\n(r_bound : \u211d)\n(r_le : \u2200 b, r b \u2264 r_bound)\n\n/-- The ball package made of unit balls. -/\ndef unit_ball_package (\u03b1 : Type*) : ball_package \u03b1 \u03b1 :=\n{ c := id,\n  r := \u03bb _, 1,\n  rpos := \u03bb _, zero_lt_one,\n  r_bound := 1,\n  r_le := \u03bb _, le_rfl }\n\ninstance (\u03b1 : Type*) : inhabited (ball_package \u03b1 \u03b1) :=\n\u27e8unit_ball_package \u03b1\u27e9\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 (\u03b2 : Type*) (\u03b1 : Type*) extends ball_package \u03b2 \u03b1 :=\n(\u03c4 : \u211d)\n(one_lt_tau : 1 < \u03c4)\n\ninstance (\u03b1 : Type*) : inhabited (tau_package \u03b1 \u03b1) :=\n\u27e8{ \u03c4 := 2,\n  one_lt_tau := one_lt_two,\n  .. unit_ball_package \u03b1 }\u27e9\n\nvariables {\u03b1 : Type*} [metric_space \u03b1] {\u03b2 : Type u}\n\nnamespace tau_package\n\nvariables [nonempty \u03b2] (p : tau_package \u03b2 \u03b1)\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} \u2192 \u03b2\n| i :=\n    -- `Z` is the set of points that are covered by already constructed balls\n    let Z := \u22c3 (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 (\u03bb b : {b : \u03b2 // p.c b \u2209 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 / \u03c4`, if such an index exists (and garbage otherwise).\n    classical.epsilon (\u03bb b : \u03b2, p.c b \u2209 Z \u2227 R \u2264 p.\u03c4 * 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 \u03b1 :=\n\u22c3 (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' (\u03bb r, \u27e8\u27e8r, r.2.trans_le hij\u27e9, subset.rfl\u27e9),\nend\n\n/-- Supremum of the radii of balls whose centers are not yet covered at step `i`. -/\ndef R (i : ordinal.{u}) : \u211d :=\nsupr (\u03bb b : {b : \u03b2 // p.c b \u2209 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} \u2192 \u2115\n| i := let A : set \u2115 := \u22c3 (j : {j // j < i})\n          (hj : (closed_ball (p.c (p.index j)) (p.r (p.index j))\n            \u2229 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 | \u00ac \u2203 (b : \u03b2), p.c b \u2209 p.Union_up_to i \u2227 p.R i \u2264 p.\u03c4 * p.r b}\n\nlemma last_step_nonempty :\n  {i | \u00ac \u2203 (b : \u03b2), p.c b \u2209 p.Union_up_to i \u2227 p.R i \u2264 p.\u03c4 * 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 \u2264 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) \u2209 p.Union_up_to y,\n  { have : p.index y = classical.epsilon (\u03bb b : \u03b2, p.c b \u2209 p.Union_up_to y \u2227 p.R y \u2264 p.\u03c4 * 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 : \u03b2) : p.c x \u2208 p.Union_up_to p.last_step :=\nbegin\n  have A : \u2200 (z : \u03b2), p.c z \u2208 p.Union_up_to p.last_step \u2228 p.\u03c4 * p.r z < p.R p.last_step,\n  { have : p.last_step \u2208 {i | \u00ac \u2203 (b : \u03b2), p.c b \u2209 p.Union_up_to i \u2227 p.R i \u2264 p.\u03c4 * 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.\u03c4\u207b\u00b9 * p.R p.last_step < p.R p.last_step,\n  { conv_rhs { rw \u2190 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 \u27e8y, hy1, hy2\u27e9 : \u2203 (y : \u03b2),\n    p.c y \u2209 p.Union_up_to p.last_step \u2227 (p.\u03c4)\u207b\u00b9 * 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 [\u2190 image_univ, nonempty_image_iff],\n    exact \u27e8\u27e8_, h\u27e9, mem_univ _\u27e9 },\n  rcases A y with Hy|Hy,\n  { exact hy1 Hy },\n  { rw \u2190 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 : \u2115} (hN : is_empty (satellite_config \u03b1 N p.\u03c4)) :\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 \u2115 := \u22c3 (j : {j // j < i})\n         (hj : (closed_ball (p.c (p.index j)) (p.r (p.index j))\n            \u2229 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 \u2208 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) \u2260 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 : \u2200 k, k < N \u2192 \u2203 j, j < i\n    \u2227 (closed_ball (p.c (p.index j)) (p.r (p.index j))\n        \u2229 closed_ball (p.c (p.index i)) (p.r (p.index i))).nonempty\n    \u2227 k = p.color j,\n  { assume k hk,\n    rw \u2190 Inf_eq_N at hk,\n    have : k \u2208 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 : \u2115 \u2192 ordinal := \u03bb n, if n = N then i else g n,\n  have color_G : \u2200 n, n \u2264 N \u2192 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 : \u2200 n, n \u2264 N \u2192 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 : \u2200 n, n \u2264 N \u2192\n    p.c (p.index (G n)) \u2209 p.Union_up_to (G n) \u2227 p.R (G n) \u2264 p.\u03c4 * p.r (p.index (G n)),\n  { assume n hn,\n    have: p.index (G n) = classical.epsilon\n      (\u03bb t, p.c t \u2209 p.Union_up_to (G n) \u2227 p.R (G n) \u2264 p.\u03c4 * p.r t), by { rw index, refl },\n    rw this,\n    have : \u2203 t, p.c t \u2209 p.Union_up_to (G n) \u2227 p.R (G n) \u2264 p.\u03c4 * 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 : \u2200 (a b : fin (nat.succ N)), G a < G b \u2192\n    p.r (p.index (G a)) \u2264 dist (p.c (p.index (G a))) (p.c (p.index (G b)))\n      \u2227 p.r (p.index (G b)) \u2264 p.\u03c4 * p.r (p.index (G a)),\n  { assume a b G_lt,\n    have ha : (a : \u2115) \u2264 N := nat.lt_succ_iff.1 a.2,\n    have hb : (b : \u2115) \u2264 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)) \u2209 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 \u2209 p.Union_up_to (G a)} := \u27e8p.index (G b), B\u27e9,\n      apply @le_csupr _ _ _ (\u03bb t : {t // p.c t \u2209 p.Union_up_to (G a)}, p.r t) _ b',\n      refine \u27e8p.r_bound, \u03bb t ht, _\u27e9,\n      simp only [exists_prop, mem_range, subtype.exists, subtype.coe_mk] at ht,\n      rcases ht with \u27e8u, hu\u27e9,\n      rw \u2190 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 \u03b1 N p.\u03c4 :=\n  { c := \u03bb k, p.c (p.index (G k)),\n    r := \u03bb k, p.r (p.index (G k)),\n    rpos := \u03bb k, p.rpos (p.index (G k)),\n    h := begin\n      assume a b a_ne_b,\n      wlog G_le : G a \u2264 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 : \u2115) \u2260 b := fin.coe_injective.ne a_ne_b,\n        rw [\u2190 color_G a (nat.lt_succ_iff.1 a.2), \u2190 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 : \u2115) < 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 : \u2115) < 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 : \u2115} {\u03c4 : \u211d}\n  (h\u03c4 : 1 < \u03c4) (hN : is_empty (satellite_config \u03b1 N \u03c4)) (q : ball_package \u03b2 \u03b1) :\n  \u2203 s : fin N \u2192 set \u03b2,\n    (\u2200 (i : fin N), (s i).pairwise_disjoint (\u03bb j, closed_ball (q.c j) (q.r j))) \u2227\n      (range q.c \u2286 \u22c3 (i : fin N), \u22c3 (j \u2208 s i), ball (q.c j) (q.r j)) :=\nbegin\n  -- first exclude the trivial case where `\u03b2` 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 \u03b2,\n  { refine \u27e8\u03bb i, \u2205, \u03bb i, pairwise_disjoint_empty, _\u27e9,\n    rw [\u2190 image_univ, eq_empty_of_is_empty (univ : set \u03b2)],\n    simp },\n  -- Now, assume `\u03b2` is nonempty.\n  let p : tau_package \u03b2 \u03b1 := { \u03c4 := \u03c4, one_lt_tau := h\u03c4, .. q },\n  -- we use for `s i` the balls of color `i`.\n  let s := \u03bb (i : fin N),\n    \u22c3 (k : ordinal.{u}) (hk : k < p.last_step) (h'k : p.color k = i), ({p.index k} : set \u03b2),\n  refine \u27e8s, \u03bb i, _, _\u27e9,\n  { -- show that balls of the same color are disjoint\n    assume x hx y hy x_ne_y,\n    obtain \u27e8jx, jx_lt, jxi, rfl\u27e9 :\n      \u2203 (jx : ordinal), jx < p.last_step \u2227 p.color jx = i \u2227 x = p.index jx,\n        by simpa only [exists_prop, mem_Union, mem_singleton_iff] using hx,\n    obtain \u27e8jy, jy_lt, jyi, rfl\u27e9 :\n      \u2203 (jy : ordinal), jy < p.last_step \u2227 p.color jy = i \u2227 y = p.index jy,\n        by simpa only [exists_prop, mem_Union, mem_singleton_iff] using hy,\n    wlog jxy : jx \u2264 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 \u2115 := \u22c3 (j : {j // j < jy})\n         (hj : (closed_ball (p.c (p.index j)) (p.r (p.index j))\n            \u2229 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 \u2208 univ \\ A,\n    { rw color_j,\n      apply Inf_mem,\n      refine \u27e8N, _\u27e9,\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, \u2190 not_disjoint_iff_nonempty_inter] },\n  { -- show that the balls of color at most `N` cover every center.\n    refine range_subset_iff.2 (\u03bb b, _),\n    obtain \u27e8a, ha\u27e9 :\n      \u2203 (a : ordinal), a < p.last_step \u2227 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 \u27e8\u27e8p.color a, p.color_lt ha.1 hN\u27e9, a, rfl, ha\u27e9 }\nend\n\n/-!\n### The measurable Besicovitch covering theorem\n-/\n\nopen_locale nnreal\nvariables [second_countable_topology \u03b1] [measurable_space \u03b1] [opens_measurable_space \u03b1]\n\n/-- Consider, for each `x` in a set `s`, a radius `r x \u2208 (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  (\u03bc : measure \u03b1) [is_finite_measure \u03bc] {N : \u2115} {\u03c4 : \u211d}\n  (h\u03c4 : 1 < \u03c4) (hN : is_empty (satellite_config \u03b1 N \u03c4)) (s : set \u03b1)\n  (r : \u03b1 \u2192 \u211d) (rpos : \u2200 x \u2208 s, 0 < r x) (rle : \u2200 x \u2208 s, r x \u2264 1) :\n  \u2203 (t : finset \u03b1), (\u2191t \u2286 s) \u2227 \u03bc (s \\ (\u22c3 (x \u2208 t), closed_ball x (r x))) \u2264 N/(N+1) * \u03bc s\n    \u2227 (t : set \u03b1).pairwise_disjoint (\u03bb x, closed_ball x (r x)) :=\nbegin\n  -- exclude the trivial case where `\u03bc s = 0`.\n  rcases le_or_lt (\u03bc s) 0 with h\u03bcs|h\u03bcs,\n  { have : \u03bc s = 0 := le_bot_iff.1 h\u03bcs,\n    refine \u27e8\u2205, by simp only [finset.coe_empty, empty_subset], _, _\u27e9,\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 \u03b1,\n  { simp only [eq_empty_of_is_empty s, measure_empty] at h\u03bcs,\n    exact (lt_irrefl _ h\u03bcs).elim },\n  have Npos : N \u2260 0,\n  { unfreezingI { rintros rfl },\n    inhabit \u03b1,\n    exact (not_is_empty_of_nonempty _) hN },\n  -- introduce a measurable superset `o` with the same measure, for measure computations\n  obtain \u27e8o, so, omeas, \u03bco\u27e9 : \u2203 (o : set \u03b1), s \u2286 o \u2227 measurable_set o \u2227 \u03bc o = \u03bc s :=\n    exists_measurable_superset \u03bc 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 \u03b1 :=\n  { c := \u03bb x, x,\n    r := \u03bb x, r x,\n    rpos := \u03bb x, rpos x x.2,\n    r_bound := 1,\n    r_le := \u03bb x, rle x x.2 },\n  rcases exist_disjoint_covering_families h\u03c4 hN a with \u27e8u, hu, hu'\u27e9,\n  have u_count : \u2200 i, (u i).countable,\n  { assume i,\n    refine (hu i).countable_of_nonempty_interior (\u03bb j hj, _),\n    have : (ball (j : \u03b1) (r j)).nonempty := nonempty_ball.2 (a.rpos _),\n    exact this.mono ball_subset_interior_closed_ball },\n  let v : fin N \u2192 set \u03b1 := \u03bb i, \u22c3 (x : s) (hx : x \u2208 u i), closed_ball x (r x),\n  have : \u2200 i, measurable_set (v i) :=\n    \u03bb i, measurable_set.bUnion (u_count i) (\u03bb b hb, measurable_set_closed_ball),\n  have A : s = \u22c3 (i : fin N), s \u2229 v i,\n  { refine subset.antisymm _ (Union_subset (\u03bb i, inter_subset_left _ _)),\n    assume x hx,\n    obtain \u27e8i, y, hxy, h'\u27e9 : \u2203 (i : fin N) (i_1 : \u21a5s) (i : i_1 \u2208 u i), x \u2208 ball \u2191i_1 (r \u2191i_1),\n    { have : x \u2208 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 \u27e8i, \u27e8hx, _\u27e9\u27e9,\n    simp only [v, exists_prop, mem_Union, set_coe.exists, exists_and_distrib_right, subtype.coe_mk],\n    exact \u27e8y, \u27e8y.2, by simpa only [subtype.coe_eta]\u27e9, ball_subset_closed_ball h'\u27e9 },\n  have S : \u2211 (i : fin N), \u03bc s / N \u2264 \u2211 i, \u03bc (s \u2229 v i) := calc\n    \u2211 (i : fin N), \u03bc s / N = \u03bc 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    ... \u2264 \u2211 i, \u03bc (s \u2229 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 \u27e8i, -, hi\u27e9 : \u2203 (i : fin N) (hi : i \u2208 finset.univ), \u03bc s / N \u2264 \u03bc (s \u2229 v i),\n  { apply ennreal.exists_le_of_sum_le _ S,\n    exact \u27e8\u27e80, bot_lt_iff_ne_bot.2 Npos\u27e9, finset.mem_univ _\u27e9 },\n  replace hi : \u03bc s / (N + 1) < \u03bc (s \u2229 v i),\n  { apply lt_of_lt_of_le _ hi,\n    apply (ennreal.mul_lt_mul_left h\u03bcs.ne' (measure_lt_top \u03bc s).ne).2,\n    rw ennreal.inv_lt_inv,\n    conv_lhs {rw \u2190 add_zero (N : \u211d\u22650\u221e) },\n    exact ennreal.add_lt_add_left (ennreal.nat_ne_top N) zero_lt_one },\n  have B : \u03bc (o \u2229 v i) = \u2211' (x : u i), \u03bc (o \u2229 closed_ball x (r x)),\n  { have : o \u2229 v i = \u22c3 (x : s) (hx : x \u2208 u i), o \u2229 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 (\u03bb k, inter_subset_right _ _) },\n    { exact \u03bb 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 \u27e8w, hw\u27e9 : \u2203 (w : finset (u i)),\n    \u03bc s / (N + 1) < \u2211 (x : u i) in w, \u03bc (o \u2229 closed_ball (x : \u03b1) (r (x : \u03b1))),\n  { have C : has_sum (\u03bb (x : u i), \u03bc (o \u2229 closed_ball x (r x))) (\u03bc (o \u2229 v i)),\n      by { rw B, exact ennreal.summable.has_sum },\n    have : \u03bc s / (N+1) < \u03bc (o \u2229 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 `\u2191(u i)` to a finset of `\u03b1`, and check that it works by design.\n  refine \u27e8finset.image (\u03bb (x : u i), x) w, _, _, _\u27e9,\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 : \u03bc (o \\ \u22c3 x \u2208 w, closed_ball \u2191x (r \u2191x)) \u2264 N/(N+1) * \u03bc s,\n      { rw [finset.set_bUnion_finset_image],\n        exact le_trans (measure_mono (diff_subset_diff so (subset.refl _))) H },\n    rw [\u2190 diff_inter_self_eq_diff,\n      measure_diff_le_iff_le_add _ (inter_subset_right _ _) ((measure_lt_top \u03bc _).ne)], swap,\n    { apply measurable_set.inter _ omeas,\n      haveI : encodable (u i) := (u_count i).to_encodable,\n      exact measurable_set.Union\n        (\u03bb b, measurable_set.Union (\u03bb hb, measurable_set_closed_ball)) },\n    calc\n    \u03bc o = 1/(N+1) * \u03bc s + N/(N+1) * \u03bc s :\n      by { rw [\u03bco, \u2190 add_mul, ennreal.div_add_div_same, add_comm, ennreal.div_self, one_mul]; simp }\n    ... \u2264 \u03bc ((\u22c3 (x \u2208 w), closed_ball \u2191x (r \u2191x)) \u2229 o) + N/(N+1) * \u03bc s : begin\n      refine add_le_add _ le_rfl,\n      rw [div_eq_mul_inv, one_mul, mul_comm, \u2190 div_eq_mul_inv],\n      apply hw.le.trans (le_of_eq _),\n      rw [\u2190 finset.set_bUnion_coe, inter_comm _ o, inter_Union\u2082, finset.set_bUnion_coe,\n          measure_bUnion_finset],\n      { have : (w : set (u i)).pairwise_disjoint (\u03bb (b : u i), closed_ball (b : \u03b1) (r (b : \u03b1))),\n          by { assume k hk l hl hkl, exact hu i k.2 l.2 (subtype.coe_injective.ne hkl) },\n        exact this.mono (\u03bb 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 \u27e8k', k'w, rfl\u27e9 : \u2203 (k' : u i), k' \u2208 w \u2227 \u2191\u2191k' = k,\n      by simpa only [mem_image, finset.mem_coe, coe_coe, finset.coe_image] using hk,\n    obtain \u27e8l', l'w, rfl\u27e9 : \u2203 (l' : u i), l' \u2208 w \u2227 \u2191\u2191l' = l,\n      by simpa only [mem_image, finset.mem_coe, coe_coe, finset.coe_image] using hl,\n    have k'nel' : (k' : s) \u2260 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 \u03b1]\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 `\u03b1 \u00d7 \u211d`) 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  (\u03bc : measure \u03b1) [is_finite_measure \u03bc]\n  (f : \u03b1 \u2192 set \u211d) (s : set \u03b1) (hf : \u2200 x \u2208 s, \u2200 \u03b4 > 0, (f x \u2229 Ioo 0 \u03b4).nonempty) :\n  \u2203 (t : set (\u03b1 \u00d7 \u211d)), t.countable\n    \u2227 (\u2200 (p : \u03b1 \u00d7 \u211d), p \u2208 t \u2192 p.1 \u2208 s) \u2227 (\u2200 (p : \u03b1 \u00d7 \u211d), p \u2208 t \u2192 p.2 \u2208 f p.1)\n    \u2227 \u03bc (s \\ (\u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 t), closed_ball p.1 p.2)) = 0\n    \u2227 t.pairwise_disjoint (\u03bb p, closed_ball p.1 p.2) :=\nbegin\n  rcases has_besicovitch_covering.no_satellite_config \u03b1 with \u27e8N, \u03c4, h\u03c4, hN\u27e9,\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 (\u03b1 \u00d7 \u211d) \u2192 Prop := \u03bb t,\n    (t : set (\u03b1 \u00d7 \u211d)).pairwise_disjoint (\u03bb p, closed_ball p.1 p.2) \u2227\n    (\u2200 (p : \u03b1 \u00d7 \u211d), p \u2208 t \u2192 p.1 \u2208 s) \u2227 (\u2200 (p : \u03b1 \u00d7 \u211d), p \u2208 t \u2192 p.2 \u2208 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 : \u2200 (t : finset (\u03b1 \u00d7 \u211d)), P t \u2192 \u2203 (u : finset (\u03b1 \u00d7 \u211d)), t \u2286 u \u2227 P u \u2227\n    \u03bc (s \\ (\u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 u), closed_ball p.1 p.2)) \u2264\n      N/(N+1) * \u03bc (s \\ (\u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 t), closed_ball p.1 p.2)),\n  { assume t ht,\n    set B := \u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 t), closed_ball p.1 p.2 with hB,\n    have B_closed : is_closed B :=\n      is_closed_bUnion (finset.finite_to_set _) (\u03bb i hi, is_closed_ball),\n    set s' := s \\ B with hs',\n    have : \u2200 x \u2208 s', \u2203 r \u2208 f x \u2229 Ioo 0 1, disjoint B (closed_ball x r),\n    { assume x hx,\n      have xs : x \u2208 s := ((mem_diff x).1 hx).1,\n      rcases eq_empty_or_nonempty B with hB|hB,\n      { have : (0 : \u211d) < 1 := zero_lt_one,\n        rcases hf x xs 1 zero_lt_one with \u27e8r, hr, h'r\u27e9,\n        exact \u27e8r, \u27e8hr, h'r\u27e9, by simp only [hB, empty_disjoint]\u27e9 },\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 \u27e8r, hr, h'r\u27e9,\n        refine \u27e8r, \u27e8hr, \u27e8h'r.1, h'r.2.trans_le (min_le_right _ _)\u27e9\u27e9, _\u27e9,\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 \u27e8v, vs', h\u03bcv, hv\u27e9 : \u2203 (v : finset \u03b1), \u2191v \u2286 s'\n      \u2227 \u03bc (s' \\ \u22c3 (x \u2208 v), closed_ball x (r x)) \u2264 N/(N+1) * \u03bc s'\n      \u2227 (v : set \u03b1).pairwise_disjoint (\u03bb (x : \u03b1), closed_ball x (r x)),\n    { have rI : \u2200 x \u2208 s', r x \u2208 Ioo (0 : \u211d) 1 := \u03bb x hx, (hr x hx).1.2,\n      exact exist_finset_disjoint_balls_large_measure \u03bc h\u03c4 hN s' r (\u03bb x hx, (rI x hx).1)\n        (\u03bb x hx, (rI x hx).2.le) },\n    refine \u27e8t \u222a (finset.image (\u03bb x, (x, r x)) v), finset.subset_union_left _ _, \u27e8_, _, _\u27e9, _\u27e9,\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 \u27e8p', p'v, rfl\u27e9,\n        rcases (mem_image _ _ _).1 hq with \u27e8q', q'v, rfl\u27e9,\n        refine hv p'v q'v (\u03bb 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 \u27e8q', q'v, rfl\u27e9,\n        apply disjoint_of_subset_left _ (hr q' (vs' q'v)).2,\n        rw [hB, \u2190 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 \u27e8p', p'v, rfl\u27e9,\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 \u27e8p', p'v, rfl\u27e9,\n        exact (hr p' (vs' p'v)).1.1 } },\n    { convert h\u03bcv using 2,\n      rw [finset.set_bUnion_union, \u2190 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 := \u03bb n, F^[n] \u2205,\n  have u_succ : \u2200 (n : \u2115), u n.succ = F (u n) :=\n    \u03bb n, by simp only [u, function.comp_app, function.iterate_succ'],\n  have Pu : \u2200 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 \u27e8\u22c3 n, u n, countable_Union (\u03bb n, (u n).countable_to_set), _, _, _, _\u27e9,\n  { assume p hp,\n    rcases mem_Union.1 hp with \u27e8n, hn\u27e9,\n    exact (Pu n).2.1 p (finset.mem_coe.1 hn) },\n  { assume p hp,\n    rcases mem_Union.1 hp with \u27e8n, hn\u27e9,\n    exact (Pu n).2.2 p (finset.mem_coe.1 hn) },\n  { have A : \u2200 n, \u03bc (s \\ \u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 \u22c3 (n : \u2115), (u n : set (\u03b1 \u00d7 \u211d))),\n                     closed_ball p.fst p.snd)\n                \u2264 \u03bc (s \\ \u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 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 (\u03bb i, (u i : set (\u03b1 \u00d7 \u211d))) n) },\n    have B : \u2200 n, \u03bc (s \\ \u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 u n), closed_ball p.fst p.snd)\n      \u2264 (N/(N+1))^n * \u03bc 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        \u03bc (s \\ \u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 u n.succ), closed_ball p.fst p.snd)\n            \u2264 (N/(N+1)) * \u03bc (s \\ \u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 u n), closed_ball p.fst p.snd) :\n              by { rw u_succ, exact (hF (u n) (Pu n)).2.2 }\n        ... \u2264 (N/(N+1))^n.succ * \u03bc s :\n          by { rw [pow_succ, mul_assoc], exact mul_le_mul_left' IH _ } },\n    have C : tendsto (\u03bb (n : \u2115), ((N : \u211d\u22650\u221e)/(N+1))^n * \u03bc s) at_top (\ud835\udcdd (0 * \u03bc s)),\n    { apply ennreal.tendsto.mul_const _ (or.inr (measure_lt_top \u03bc 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 \u2190 add_zero (N : \u211d\u22650\u221e) },\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 (\u03bb n, (A n).trans (B n)) },\n  { refine (pairwise_disjoint_Union _).2 (\u03bb n, (Pu n).1),\n    apply (monotone_nat_of_le_succ (\u03bb 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 `\u03b1 \u00d7 \u211d`) 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 (\u03bc : measure \u03b1) [sigma_finite \u03bc]\n  (f : \u03b1 \u2192 set \u211d) (s : set \u03b1) (hf : \u2200 x \u2208 s, \u2200 \u03b4 > 0, (f x \u2229 Ioo 0 \u03b4).nonempty) :\n  \u2203 (t : set (\u03b1 \u00d7 \u211d)), t.countable\n    \u2227 (\u2200 (p : \u03b1 \u00d7 \u211d), p \u2208 t \u2192 p.1 \u2208 s) \u2227 (\u2200 (p : \u03b1 \u00d7 \u211d), p \u2208 t \u2192 p.2 \u2208 f p.1)\n    \u2227 \u03bc (s \\ (\u22c3 (p : \u03b1 \u00d7 \u211d) (hp : p \u2208 t), closed_ball p.1 p.2)) = 0\n    \u2227 t.pairwise_disjoint (\u03bb 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 \u03bc with \u27e8\u03bd, h\u03bd, h\u03bc\u03bd\u27e9 },\n  rcases exists_disjoint_closed_ball_covering_ae_of_finite_measure_aux \u03bd f s hf\n    with \u27e8t, t_count, ts, tr, t\u03bd, tdisj\u27e9,\n  exact \u27e8t, t_count, ts, tr, h\u03bc\u03bd t\u03bd, tdisj\u27e9,\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 (\u03bc : measure \u03b1) [sigma_finite \u03bc]\n  (f : \u03b1 \u2192 set \u211d) (s : set \u03b1) (hf : \u2200 x \u2208 s, \u2200 \u03b4 > 0, (f x \u2229 Ioo 0 \u03b4).nonempty)\n  (R : \u03b1 \u2192 \u211d) (hR : \u2200 x \u2208 s, 0 < R x):\n  \u2203 (t : set \u03b1) (r : \u03b1 \u2192 \u211d), t.countable \u2227 t \u2286 s \u2227 (\u2200 x \u2208 t, r x \u2208 f x \u2229 Ioo 0 (R x))\n    \u2227 \u03bc (s \\ (\u22c3 (x \u2208 t), closed_ball x (r x))) = 0\n    \u2227 t.pairwise_disjoint (\u03bb x, closed_ball x (r x)) :=\nbegin\n  let g := \u03bb x, f x \u2229 Ioo 0 (R x),\n  have hg : \u2200 x \u2208 s, \u2200 \u03b4 > 0, (g x \u2229 Ioo 0 \u03b4).nonempty,\n  { assume x hx \u03b4 \u03b4pos,\n    rcases hf x hx (min \u03b4 (R x)) (lt_min \u03b4pos (hR x hx)) with \u27e8r, hr\u27e9,\n    exact \u27e8r, \u27e8\u27e8hr.1, hr.2.1, hr.2.2.trans_le (min_le_right _ _)\u27e9,\n      \u27e8hr.2.1, hr.2.2.trans_le (min_le_left _ _)\u27e9\u27e9\u27e9 },\n  rcases exists_disjoint_closed_ball_covering_ae_aux \u03bc g s hg\n    with \u27e8v, v_count, vs, vg, \u03bcv, v_disj\u27e9,\n  let t := prod.fst '' v,\n  have : \u2200 x \u2208 t, \u2203 (r : \u211d), (x, r) \u2208 v,\n  { assume x hx,\n    rcases (mem_image _ _ _).1 hx with \u27e8\u27e8p, q\u27e9, hp, rfl\u27e9,\n    exact \u27e8q, hp\u27e9 },\n  choose! r hr using this,\n  have im_t : (\u03bb x, (x, r x)) '' t = v,\n  { have I : \u2200 (p : \u03b1 \u00d7 \u211d), p \u2208 v \u2192 0 \u2264 p.2 :=\n      \u03bb p hp, (vg p hp).2.1.le,\n    apply subset.antisymm,\n    { simp only [image_subset_iff],\n      rintros \u27e8x, p\u27e9 hxp,\n      simp only [mem_preimage],\n      exact hr _ (mem_image_of_mem _ hxp) },\n    { rintros \u27e8x, p\u27e9 hxp,\n      have hxrx : (x, r x) \u2208 v := hr _ (mem_image_of_mem _ hxp),\n      have : p = r x,\n      { by_contra,\n        have A : (x, p) \u2260 (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 \u27e8x, by simp [I _ hxp, I _ hxrx]\u27e9 },\n      rw this,\n      apply mem_image_of_mem,\n      exact mem_image_of_mem _ hxp } },\n  refine \u27e8t, r, v_count.image _, _, _, _, _\u27e9,\n  { assume x hx,\n    rcases (mem_image _ _ _).1 hx with \u27e8\u27e8p, q\u27e9, hp, rfl\u27e9,\n    exact vs _ hp },\n  { assume x hx,\n    rcases (mem_image _ _ _).1 hx with \u27e8\u27e8p, q\u27e9, hp, rfl\u27e9,\n    exact vg _ (hr _ hx) },\n  { have : (\u22c3 (x : \u03b1) (H : x \u2208 t), closed_ball x (r x)) =\n      (\u22c3 (p : \u03b1 \u00d7 \u211d) (H : p \u2208 (\u03bb 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 \u03bcv },\n  { have A : inj_on (\u03bb x : \u03b1, (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 [\u2190 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 `\u03bc s + \u03b5`, for any positive `\u03b5`. 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  (\u03bc : measure \u03b1) [sigma_finite \u03bc] [measure.outer_regular \u03bc]\n  {\u03b5 : \u211d\u22650\u221e} (h\u03b5 : \u03b5 \u2260 0) (f : \u03b1 \u2192 set \u211d) (s : set \u03b1)\n  (hf : \u2200 x \u2208 s, \u2200 \u03b4 > 0, (f x \u2229 Ioo 0 \u03b4).nonempty) :\n  \u2203 (t : set \u03b1) (r : \u03b1 \u2192 \u211d), t.countable \u2227 t \u2286 s \u2227 (\u2200 x \u2208 t, r x \u2208 f x)\n    \u2227 s \u2286 (\u22c3 (x \u2208 t), closed_ball x (r x))\n    \u2227 \u2211' (x : t), \u03bc (closed_ball x (r x)) \u2264 \u03bc s + \u03b5  :=\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 `\u03bc s + \u03b5 / 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 `\u03b5 / (2 N)`, the sum of their measures is at most `\u03b5 / 2`, completing the proof. -/\n  obtain \u27e8u, su, u_open, \u03bcu\u27e9 : \u2203 U \u2287 s, is_open U \u2227 \u03bc U \u2264 \u03bc s + \u03b5 / 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\u03b5),\n  have : \u2200 x \u2208 s, \u2203 R > 0, ball x R \u2286 u :=\n    \u03bb x hx, metric.mem_nhds_iff.1 (u_open.mem_nhds (su hx)),\n  choose! R hR using this,\n  obtain \u27e8t0, r0, t0_count, t0s, hr0, \u03bct0, t0_disj\u27e9 :\n    \u2203 (t0 : set \u03b1) (r0 : \u03b1 \u2192 \u211d), t0.countable \u2227 t0 \u2286 s \u2227 (\u2200 x \u2208 t0, r0 x \u2208 f x \u2229 Ioo 0 (R x))\n      \u2227 \u03bc (s \\ (\u22c3 (x \u2208 t0), closed_ball x (r0 x))) = 0\n      \u2227 t0.pairwise_disjoint (\u03bb x, closed_ball x (r0 x)) :=\n        exists_disjoint_closed_ball_covering_ae \u03bc f s hf R (\u03bb 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 \\ (\u22c3 (x \u2208 t0), closed_ball x (r0 x)),\n  have s's : s' \u2286 s := diff_subset _ _,\n  obtain \u27e8N, \u03c4, h\u03c4, H\u27e9 : \u2203 N \u03c4, 1 < \u03c4 \u2227 is_empty (besicovitch.satellite_config \u03b1 N \u03c4) :=\n    has_besicovitch_covering.no_satellite_config \u03b1,\n  obtain \u27e8v, s'v, v_open, \u03bcv\u27e9 : \u2203 v \u2287 s', is_open v \u2227 \u03bc v \u2264 \u03bc s' + (\u03b5 / 2) / N :=\n    set.exists_is_open_le_add _ _\n      (by simp only [h\u03b5, 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 : \u2200 x \u2208 s', \u2203 r1 \u2208 (f x \u2229 Ioo (0 : \u211d) 1), closed_ball x r1 \u2286 v,\n  { assume x hx,\n    rcases metric.mem_nhds_iff.1 (v_open.mem_nhds (s'v hx)) with \u27e8r, rpos, hr\u27e9,\n    rcases hf x (s's hx) (min r 1) (lt_min rpos zero_lt_one) with \u27e8R', hR'\u27e9,\n    exact \u27e8R', \u27e8hR'.1, hR'.2.1, hR'.2.2.trans_le (min_le_right _ _)\u27e9,\n      subset.trans (closed_ball_subset_ball (hR'.2.2.trans_le (min_le_left _ _))) hr\u27e9, },\n  choose! r1 hr1 using this,\n  let q : ball_package s' \u03b1 :=\n  { c := \u03bb x, x,\n    r := \u03bb x, r1 x,\n    rpos := \u03bb x, (hr1 x.1 x.2).1.2.1,\n    r_bound := 1,\n    r_le := \u03bb 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 \u27e8S, S_disj, hS\u27e9 : \u2203 S : fin N \u2192 set s',\n    (\u2200 (i : fin N), (S i).pairwise_disjoint (\u03bb j, closed_ball (q.c j) (q.r j))) \u2227\n      (range q.c \u2286 \u22c3 (i : fin N), \u22c3 (j \u2208 S i), ball (q.c j) (q.r j)) :=\n    exist_disjoint_covering_families h\u03c4 H q,\n  have S_count : \u2200 i, (S i).countable,\n  { assume i,\n    apply (S_disj i).countable_of_nonempty_interior (\u03bb j hj, _),\n    have : (ball (j : \u03b1) (r1 j)).nonempty := nonempty_ball.2 (q.rpos _),\n    exact this.mono ball_subset_interior_closed_ball },\n  let r := \u03bb x, if x \u2208 s' then r1 x else r0 x,\n  have r_t0 : \u2200 x \u2208 t0, r x = r0 x,\n  { assume x hx,\n    have : \u00ac (x \u2208 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 \u27e8x, hx, _\u27e9,\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 \u27e8t0 \u222a (\u22c3 (i : fin N), (coe : s' \u2192 \u03b1) '' (S i)), r, _, _, _, _, _\u27e9,\n  -- it remains to check that they have the desired properties\n  { exact t0_count.union (countable_Union (\u03bb 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 \u2208 s',\n      { simp only [mem_Union, mem_image] at hx,\n        rcases hx with \u27e8i, y, ySi, rfl\u27e9,\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 \u2208 s',\n    { obtain \u27e8i, y, ySi, xy\u27e9 : \u2203 (i : fin N) (y : \u21a5s') (ySi : y \u2208 S i), x \u2208 ball (y : \u03b1) (r1 y),\n      { have A : x \u2208 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\u2082.2 \u27e8y, or.inr _, _\u27e9,\n      { simp only [mem_Union, mem_image],\n        exact \u27e8i, y, ySi, rfl\u27e9 },\n      { have : (y : \u03b1) \u2208 s' := y.2,\n        simp only [r, if_pos this],\n        exact ball_subset_closed_ball xy } },\n    { obtain \u27e8y, yt0, hxy\u27e9 : \u2203 (y : \u03b1), y \u2208 t0 \u2227 x \u2208 closed_ball y (r0 y),\n        by simpa [hx, -mem_closed_ball] using h'x,\n      refine mem_Union\u2082.2 \u27e8y, or.inl yt0, _\u27e9,\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 `\u03bc s + \u03b5 / 2`\n    have A : \u2211' (x : t0), \u03bc (closed_ball x (r x)) \u2264 \u03bc s + \u03b5 / 2 := calc\n      \u2211' (x : t0), \u03bc (closed_ball x (r x))\n      = \u2211' (x : t0), \u03bc (closed_ball x (r0 x)) :\n        by { congr' 1, ext x, rw r_t0 x x.2 }\n      ... = \u03bc (\u22c3 (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 \u03bb i, measurable_set_closed_ball }\n        end\n      ... \u2264 \u03bc 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      ... \u2264 \u03bc s + \u03b5 / 2 : \u03bcu,\n    -- each subfamily in the second step has measure at most `\u03b5 / (2 N)`.\n    have B : \u2200 (i : fin N),\n      \u2211' (x : (coe : s' \u2192 \u03b1) '' (S i)), \u03bc (closed_ball x (r x)) \u2264 (\u03b5 / 2) / N := \u03bb i, calc\n      \u2211' (x : (coe : s' \u2192 \u03b1) '' (S i)), \u03bc (closed_ball x (r x)) =\n            \u2211' (x : S i), \u03bc (closed_ball x (r x)) :\n        begin\n          have : inj_on (coe : s' \u2192 \u03b1) (S i) := subtype.coe_injective.inj_on _,\n          let F : S i \u2243 (coe : s' \u2192 \u03b1) '' (S i) := this.bij_on_image.equiv _,\n          exact (F.tsum_eq (\u03bb x, \u03bc (closed_ball x (r x)))).symm,\n        end\n      ... = \u2211' (x : S i), \u03bc (closed_ball x (r1 x)) :\n        by { congr' 1, ext x, have : (x : \u03b1) \u2208 s' := x.1.2, simp only [r, if_pos this] }\n      ... = \u03bc (\u22c3 (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 \u03bb i, measurable_set_closed_ball }\n        end\n      ... \u2264 \u03bc 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      ... \u2264 (\u03b5 / 2) / N : by { have : \u03bc s' = 0 := \u03bct0, rwa [this, zero_add] at \u03bcv },\n    -- add up all these to prove the desired estimate\n    calc \u2211' (x : (t0 \u222a \u22c3 (i : fin N), (coe : s' \u2192 \u03b1) '' S i)), \u03bc (closed_ball x (r x))\n        \u2264 \u2211' (x : t0), \u03bc (closed_ball x (r x))\n          + \u2211' (x : \u22c3 (i : fin N), (coe : s' \u2192 \u03b1) '' S i), \u03bc (closed_ball x (r x)) :\n            ennreal.tsum_union_le (\u03bb x, \u03bc (closed_ball x (r x))) _ _\n    ... \u2264 \u2211' (x : t0), \u03bc (closed_ball x (r x))\n          + \u2211 (i : fin N), \u2211' (x : (coe : s' \u2192 \u03b1) '' S i), \u03bc (closed_ball x (r x)) :\n            add_le_add le_rfl (ennreal.tsum_Union_le (\u03bb x, \u03bc (closed_ball x (r x))) _)\n    ... \u2264 (\u03bc s + \u03b5 / 2) + \u2211 (i : fin N), (\u03b5 / 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    ... \u2264 (\u03bc s + \u03b5 / 2) + \u03b5 / 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    ... = \u03bc s + \u03b5 : 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 (\u03bc : measure \u03b1) [sigma_finite \u03bc] :\n  vitali_family \u03bc :=\n{ sets_at := \u03bb x, (\u03bb (r : \u211d), closed_ball x r) '' (Ioi (0 : \u211d)),\n  measurable_set' := begin\n    assume x y hy,\n    obtain \u27e8r, rpos, rfl\u27e9 : \u2203 (r : \u211d), 0 < r \u2227 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 \u27e8r, rpos, rfl\u27e9 : \u2203 (r : \u211d), 0 < r \u2227 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 := \u03bb x \u03b5 \u03b5pos, \u27e8closed_ball x \u03b5, mem_image_of_mem _ \u03b5pos, subset.refl _\u27e9,\n  covering := begin\n    assume s f fsubset ffine,\n    let g : \u03b1 \u2192 set \u211d := \u03bb x, {r | 0 < r \u2227 closed_ball x r \u2208 f x},\n    have A : \u2200 x \u2208 s, \u2200 \u03b4 > 0, (g x \u2229 Ioo 0 \u03b4).nonempty,\n    { assume x xs \u03b4 \u03b4pos,\n      obtain \u27e8t, tf, ht\u27e9 : \u2203 (t : set \u03b1) (H : t \u2208 f x), t \u2286 closed_ball x (\u03b4/2) :=\n        ffine x xs (\u03b4/2) (half_pos \u03b4pos),\n      obtain \u27e8r, rpos, rfl\u27e9 : \u2203 (r : \u211d), 0 < r \u2227 closed_ball x r = t,\n        by simpa using fsubset x xs tf,\n      rcases le_total r (\u03b4/2) with H|H,\n      { exact \u27e8r, \u27e8rpos, tf\u27e9, \u27e8rpos, H.trans_lt (half_lt_self \u03b4pos)\u27e9\u27e9 },\n      { have : closed_ball x r = closed_ball x (\u03b4/2) :=\n          subset.antisymm ht (closed_ball_subset_closed_ball H),\n        rw this at tf,\n        refine \u27e8\u03b4/2, \u27e8half_pos \u03b4pos, tf\u27e9, \u27e8half_pos \u03b4pos, half_lt_self \u03b4pos\u27e9\u27e9 } },\n    obtain \u27e8t, r, t_count, ts, tg, \u03bct, tdisj\u27e9 : \u2203 (t : set \u03b1) (r : \u03b1 \u2192 \u211d), t.countable\n      \u2227 t \u2286 s \u2227 (\u2200 x \u2208 t, r x \u2208 g x \u2229 Ioo 0 1)\n      \u2227 \u03bc (s \\ (\u22c3 (x \u2208 t), closed_ball x (r x))) = 0\n      \u2227 t.pairwise_disjoint (\u03bb x, closed_ball x (r x)) :=\n        exists_disjoint_closed_ball_covering_ae \u03bc g s A (\u03bb _, 1) (\u03bb _ _, zero_lt_one),\n    let F : \u03b1 \u2192 \u03b1 \u00d7 set \u03b1 := \u03bb x, (x, closed_ball x (r x)),\n    refine \u27e8F '' t, _, _, _, _\u27e9,\n    { rintros - \u27e8x, hx, rfl\u27e9, exact ts hx },\n    { rintros p \u27e8x, hx, rfl\u27e9 q \u27e8y, hy, rfl\u27e9 hxy,\n      exact tdisj hx hy (ne_of_apply_ne F hxy) },\n    { rintros - \u27e8x, hx, rfl\u27e9, 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 (\u03bc : measure \u03b1) [sigma_finite \u03bc] (x : \u03b1) :\n  tendsto (\u03bb r, closed_ball x r) (\ud835\udcdd[>] 0) ((besicovitch.vitali_family \u03bc).filter_at x) :=\nbegin\n  assume s hs,\n  simp only [mem_map],\n  obtain \u27e8\u03b5, \u03b5pos, h\u03b5\u27e9 : \u2203 (\u03b5 : \u211d) (H : \u03b5 > 0), \u2200 (a : set \u03b1),\n    a \u2208 (besicovitch.vitali_family \u03bc).sets_at x \u2192 a \u2286 closed_ball x \u03b5 \u2192 a \u2208 s :=\n      (vitali_family.mem_filter_at_iff _).1 hs,\n  have : Ioc (0 : \u211d) \u03b5 \u2208 \ud835\udcdd[>] (0 : \u211d) := Ioc_mem_nhds_within_Ioi \u27e8le_rfl, \u03b5pos\u27e9,\n  filter_upwards [this] with _ hr,\n  apply h\u03b5,\n  { exact mem_image_of_mem _ hr.1 },\n  { exact closed_ball_subset_closed_ball hr.2 }\nend\n\nvariables [metric_space \u03b2] [measurable_space \u03b2] [borel_space \u03b2] [second_countable_topology \u03b2]\n  [has_besicovitch_covering \u03b2]\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  (\u03c1 \u03bc : measure \u03b2) [is_locally_finite_measure \u03bc] [is_locally_finite_measure \u03c1] :\n  \u2200\u1d50 x \u2202\u03bc, tendsto (\u03bb r, \u03c1 (closed_ball x r) / \u03bc (closed_ball x r))\n    (\ud835\udcdd[>] 0) (\ud835\udcdd (\u03c1.rn_deriv \u03bc x)) :=\nbegin\n  filter_upwards [vitali_family.ae_tendsto_rn_deriv (besicovitch.vitali_family \u03bc) \u03c1] with x hx,\n  exact hx.comp (tendsto_filter_at \u03bc x)\nend\n\n/-- Given a measurable set `s`, then `\u03bc (s \u2229 closed_ball x r) / \u03bc (closed_ball x r)` converges when\n`r` tends to `0`, for almost every `x`. The limit is `1` for `x \u2208 s` and `0` for `x \u2209 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  (\u03bc : measure \u03b2) [is_locally_finite_measure \u03bc] {s : set \u03b2} (hs : measurable_set s) :\n  \u2200\u1d50 x \u2202\u03bc, tendsto (\u03bb r, \u03bc (s \u2229 closed_ball x r) / \u03bc (closed_ball x r))\n    (\ud835\udcdd[>] 0) (\ud835\udcdd (s.indicator 1 x)) :=\nbegin\n  filter_upwards [vitali_family.ae_tendsto_measure_inter_div_of_measurable_set\n    (besicovitch.vitali_family \u03bc) hs],\n  assume x hx,\n  exact hx.comp (tendsto_filter_at \u03bc x)\nend\n\n/-- Given an arbitrary set `s`, then `\u03bc (s \u2229 closed_ball x r) / \u03bc (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 (\u03bc : measure \u03b2) [is_locally_finite_measure \u03bc] (s : set \u03b2) :\n  \u2200\u1d50 x \u2202(\u03bc.restrict s), tendsto (\u03bb r, \u03bc (s \u2229 (closed_ball x r)) / \u03bc (closed_ball x r))\n    (\ud835\udcdd[>] 0) (\ud835\udcdd 1) :=\nby filter_upwards [vitali_family.ae_tendsto_measure_inter_div (besicovitch.vitali_family \u03bc)]\n    with x hx using hx.comp (tendsto_filter_at \u03bc 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 (\u03b1 : Type _) where\n  Id : Type\n  id : \u03b1 \u2192 Id\n  time : \u03b1 \u2192 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 \u03b5] : List \u03b5 \u2192 Prop\n  | nil : Sorted []\n  | singleton : Sorted [e]\n  | cons : (inst.time fst \u2264 inst.time snd) \u2192 Sorted (snd :: tl) \u2192 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 (\u03b5 : Type) [inst : EventType \u03b5] (bound : Time) where\n  events : Array \u03b5\n  sorted : Queue.Sorted events.data\n  bounded : \u2200 {event}, (events[0]? = some event) \u2192 bound \u2264 inst.time event\n  -- TODO: Add the property:\n  -- \u2200 {event\u2081 event\u2082}, (event\u2081 \u2208 events) \u2192 (event\u2082 \u2208 events) \u2192 (time event\u2081 > bound) \u2192\n  --                    (time event\u2081 \u2260 time event\u2082) \u2228 (id event\u2081 \u2260 id event\u2082)\n\nnamespace Queue\nopen EventType\n\nvariable [EventType \u03b5]\n\n@[reducible]\ninstance : Membership \u03b5 (Queue \u03b5 bound) where\n  mem e q := e \u2208 q.events.data\n\n-- TODO: What's the story for theorems about `Array`s in Lean 4?\ntheorem all_events_bounded {queue : Queue \u03b5 bound} :\n  \u2200 {event}, event \u2208 queue.events.data \u2192 bound \u2264 time event := by\n  sorry\n\n/-- A queue is empty if its underlying list of events is empty. -/\ndef isEmpty (q : Queue \u03b5 bound) : Bool := q.events.isEmpty\n\n/-- The size of a queue is the number of its events. -/\ndef size (q : Queue \u03b5 bound) : Nat := q.events.size\n\ninstance : GetElem (Queue \u03b5 bound) Nat { e : \u03b5 // bound \u2264 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 \u03b5 bound} {i : Nat} :\n  (queue[i]? = some event) \u2192 (queue.events[i]? = event.val) := by\n  intro h\n  sorry\n\n@[simp]\ntheorem getElem?_none_events_getElem?_none {queue : Queue \u03b5 bound} {i : Nat} :\n  (queue[i]? = none) \u2192 (queue.events[i]? = none) := by\n  intro h\n  sorry\n\n/-- Creates an empty queue. -/\ndef nil : Queue \u03b5 bound where\n  events := #[]\n  sorted := .nil\n  bounded := by simp\n\nnotation \"\u00b0[]\" => Queue.nil\n\ninstance : Inhabited (Queue \u03b5 bound) where\n  default := \u00b0[]\n\n/-- Creates a queue with a single event. -/\ndef singleton (event : \u03b5) (h : bound \u2264 time event) : Queue \u03b5 bound where\n  events := #[event]\n  sorted := .singleton\n  bounded := by intros; simp_all\n\nnotation \"\u00b0[\" 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 \u03b5) : Queue \u03b5 0 where\n  events := events.insertionSort (time \u00b7 \u2264 time \u00b7)\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 \u03b5 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 \u03b5 bound} :\n  (queue.nextTime = some next) \u2192\n  (\u2203 event, queue[0]? = some event \u2227 (time event.val) \u2265 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 [\u2190h]\n\ntheorem nextTime_isSome_iff_not_isEmpty {queue : Queue \u03b5 bound} :\n  queue.nextTime.isSome \u2194 \u00acqueue.isEmpty := by\n  rw [Queue.isEmpty, \u2190Array.getElem?_zero_isSome_iff_not_isEmpty]\n  simp [nextTime]\n  constructor <;> split <;> simp_all [Option.isSome]\n  \u00b7 simp [Queue.getElem?_some_events_getElem?_some \u2039_\u203a]\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 \u03b5 bound) (anchor : Time) (h : \u2200 next, queue.nextTime = some next \u2192 anchor \u2264 next) :\n  Array \u03b5 \u00d7 Queue \u03b5 anchor :=\n  let \u27e8candidates, later\u27e9 := queue.events.split (time \u00b7 = anchor)\n  let \u27e8next, postponed\u27e9 := candidates.unique (EventType.id \u00b7)\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\u2081 ++ queue\u2082`.\n-- TODO: Implement all of this properly once something like `Array.merge` arrives in Std.\ndef merge [inst : EventType \u03b5] (queue\u2081 queue\u2082 : Queue \u03b5 bound) : Queue \u03b5 bound :=\n  if queue\u2081.isEmpty      then queue\u2082\n  else if queue\u2082.isEmpty then queue\u2081\n  else\n  -- Note, using `split` is inefficient as it traverses the entire array.\n  let \u27e8immediate\u2081, future\u2081\u27e9 := queue\u2081.events.split (time \u00b7 = bound)\n  let \u27e8immediate\u2082, future\u2082\u27e9 := queue\u2082.events.split (time \u00b7 = bound)\n  {\n    events := (mergeImmediate immediate\u2081 immediate\u2082) ++ (mergeFuture future\u2081 future\u2082)\n    sorted := sorry\n    bounded := sorry\n  }\nwhere\n  mergeImmediate (is\u2081 is\u2082 : Array \u03b5) : Array \u03b5 :=\n    (is\u2081 ++ is\u2082).insertionSort (time \u00b7 \u2264 time \u00b7)\n  mergeFuture (fs\u2081 fs\u2082 : Array \u03b5) : Array \u03b5 :=\n    let fs\u2081' := fs\u2081.filter fun event\u2081 =>\n      \u00ac fs\u2082.any fun event\u2082 =>\n        (inst.time event\u2081 = inst.time event\u2082) \u2227\n        (inst.id event\u2081 = inst.id event\u2082)\n    (fs\u2081' ++ fs\u2082).insertionSort (time \u00b7 \u2264 time \u00b7)\n\ntheorem merge_mem\u2082 {queue\u2081 queue\u2082 : Queue \u03b5 bound} :\n  (event \u2208 queue\u2082) \u2192 (event \u2208 queue\u2081.merge queue\u2082) := 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\u2082` and thus retained as part of `mergeImmediate`\n      sorry\n    case inr ht =>\n      -- `event` is in `future\u2082` and thus retained as part of `mergeFuture`\n      sorry\n\n/--\nMaps a queue of event type `\u03b5` to a queue of event type `\u03b4`. To ensure that the resulting queue is\nstill sorted and bounded, the map must preserve time stamps.\n-/\ndef map [EventType \u03b4] (queue : Queue \u03b5 bound) (f : \u03b5 \u2192 \u03b4) (h : \u2200 e : \u03b5, time e = time (f e)) :\n  Queue \u03b4 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 \u2964 Type`, an object of `F.elements` is a pair `(X : C, x : F.obj X)`.\nA morphism `(X, x) \u27f6 (Y, y)` is a morphism `f : X \u27f6 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 \u2964 Type`\nis a pair `(X : C, x : F.obj X)`.\n-/\n@[nolint has_inhabited_instance]\ndef functor.elements (F : C \u2964 Type w) := (\u03a3 c : C, F.obj c)\n\n/-- The category structure on `F.elements`, for `F : C \u2964 Type`.\n    A morphism `(X, x) \u27f6 (Y, y)` is a morphism `f : X \u27f6 Y` in `C`, so `F.map f` takes `x` to `y`.\n -/\ninstance category_of_elements (F : C \u2964 Type w) : category.{v} F.elements :=\n{ hom := \u03bb p q, { f : p.1 \u27f6 q.1 // (F.map f) p.2 = q.2 },\n  id := \u03bb p, \u27e8\ud835\udfd9 p.1, by obviously\u27e9,\n  comp := \u03bb p q r f g, \u27e8f.val \u226b g.val, by obviously\u27e9 }\n\nnamespace category_of_elements\n\n@[ext]\nlemma ext (F : C \u2964 Type w) {x y : F.elements} (f g : x \u27f6 y) (w : f.val = g.val) : f = g :=\nsubtype.ext_val w\n\n@[simp] lemma comp_val {F : C \u2964 Type w} {p q r : F.elements} {f : p \u27f6 q} {g : q \u27f6 r} :\n  (f \u226b g).val = f.val \u226b g.val := rfl\n\n@[simp] lemma id_val {F : C \u2964 Type w} {p : F.elements} : (\ud835\udfd9 p : p \u27f6 p).val = \ud835\udfd9 p.1 := rfl\n\nend category_of_elements\n\nnoncomputable\ninstance groupoid_of_elements {G : Type u} [groupoid.{v} G] (F : G \u2964 Type w) :\n  groupoid F.elements :=\n{ inv := \u03bb p q f, \u27e8inv 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 \u226b F.map (inv f.val)) p.2 : by simp\n                             ... = p.2 : by {rw \u2190functor.map_comp, simp}\u27e9, }\n\nnamespace category_of_elements\nvariable (F : C \u2964 Type w)\n\n/-- The functor out of the category of elements which forgets the element. -/\n@[simps]\ndef \u03c0 : F.elements \u2964 C :=\n{ obj := \u03bb X, X.1,\n  map := \u03bb 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\u2081 F\u2082 : C \u2964 Type w} (\u03b1 : F\u2081 \u27f6 F\u2082) : F\u2081.elements \u2964 F\u2082.elements :=\n{ obj := \u03bb t, \u27e8t.1, \u03b1.app t.1 t.2\u27e9,\n  map := \u03bb t\u2081 t\u2082 k, \u27e8k.1, by simpa [\u2190k.2] using (functor_to_types.naturality _ _ \u03b1 k.1 t\u2081.2).symm\u27e9 }\n\n@[simp] lemma map_\u03c0 {F\u2081 F\u2082 : C \u2964 Type w} (\u03b1 : F\u2081 \u27f6 F\u2082) : map \u03b1 \u22d9 \u03c0 F\u2082 = \u03c0 F\u2081 := rfl\n\n/-- The forward direction of the equivalence `F.elements \u2245 (*, F)`. -/\ndef to_structured_arrow : F.elements \u2964 structured_arrow punit F :=\n{ obj := \u03bb X, structured_arrow.mk (\u03bb _, X.2),\n  map := \u03bb 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 := \u03bb _, X.2 } := rfl\n@[simp] lemma to_comma_map_right {X Y} (f : X \u27f6 Y) :\n  ((to_structured_arrow F).map f).right = f.val := rfl\n\n/-- The reverse direction of the equivalence `F.elements \u2245 (*, F)`. -/\ndef from_structured_arrow : structured_arrow punit F \u2964 F.elements :=\n{ obj := \u03bb X, \u27e8X.right, X.hom (punit.star)\u27e9,\n  map := \u03bb X Y f, \u27e8f.right, congr_fun f.w'.symm punit.star\u27e9 }\n\n@[simp] lemma from_structured_arrow_obj (X) :\n  (from_structured_arrow F).obj X = \u27e8X.right, X.hom (punit.star)\u27e9 := rfl\n@[simp] lemma from_structured_arrow_map {X Y} (f : X \u27f6 Y) :\n  (from_structured_arrow F).map f = \u27e8f.right, congr_fun f.w'.symm punit.star\u27e9 := 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 \u224c structured_arrow punit F :=\nequivalence.mk (to_structured_arrow F) (from_structured_arrow F)\n  (nat_iso.of_components (\u03bb X, eq_to_iso (by tidy)) (by tidy))\n  (nat_iso.of_components\n    (\u03bb X, { hom := { right := \ud835\udfd9 _ }, inv := { right := \ud835\udfd9 _ } })\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\u207f 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 : \u2115} : 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 \u00d7 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 (\u2205 : 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 \u2229 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 \u222a 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\u1d9c) :=\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\u1d9c) : def_set S s :=\nby { rw \u2190compl_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 \u2208 s \u2194 x \u2208 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 {\u03b9 : Type*} [fintype \u03b9] {t : \u03b9 \u2192 set X}\n  (ht : \u2200 i, def_set S (t i)) : def_set S (\u22c2 i, t i) :=\nsuffices \u2200 {s : set \u03b9}, set.finite s \u2192 def_set S (\u22c2 i \u2208 s, t i),\nby { convert this finite_univ, simp },\n\u03bb s hs, finite.induction_on hs\n  (by { convert def_set_univ _, simp, apply_instance }) -- why is apply_instance needed here?\n  (\u03bb i s _ _ IH, by { convert (ht i).inter IH, simp })\n\nlemma def_set_Union {\u03b9 : Type*} [fintype \u03b9] {t : \u03b9 \u2192 set X}\n  (ht : \u2200 i, def_set S (t i)) : def_set S (\u22c3 i, t i) :=\nbegin\n  apply def_set.compl',\n  rw compl_Union,\n  exact def_set_Inter (\u03bb i, (ht i).compl)\nend\n\nlemma def_set.or {s t : X \u2192 Prop} (hs : def_set S {x : X | s x}) (ht : def_set S {x : X | t x}) :\n  def_set S {x | s x \u2228 t x} :=\nhs.union ht\n\nlemma def_set.and {s t : X \u2192 Prop} (hs : def_set S {x : X | s x}) (ht : def_set S {x : X | t x}) :\n  def_set S {x | s x \u2227 t x} :=\nhs.inter ht\n\nlemma def_set.not {s : X \u2192 Prop} (hs : def_set S {x : X | s x}) :\n  def_set S {x | \u00ac s x} :=\nhs.compl\n\nlemma def_set.imp {s t : X \u2192 Prop} (hs : def_set S {x : X | s x}) (ht : def_set S {x : X | t x}) :\n  def_set S {x | s x \u2192 t x} :=\nbegin\n  simp [imp_iff_not_or], -- classical!\n  exact hs.not.or ht\nend\n\nlemma def_set.forall_fintype {\u03b9 : Type*} [fintype \u03b9] {t : \u03b9 \u2192 set X}\n  (ht : \u2200 i, def_set S (t i)) : def_set S {x | \u2200 i, x \u2208 t i} :=\nbegin\n  convert def_set_Inter ht using 1,\n  ext x,\n  simp\nend\n\nlemma def_set.exists_fintype {\u03b9 : Type*} [fintype \u03b9] {t : \u03b9 \u2192 set X}\n  (ht : \u2200 i, def_set S (t i)) : def_set S {x | \u2203 i, x \u2208 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 \u00d7 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 \u00d7 X | s p.2 p.1}`?\n-- After all, Lean prefers to form `Z \u00d7 Y \u00d7 X = Z \u00d7 (Y \u00d7 X)`\nlemma def_set.exists {s : X \u2192 Y \u2192 Prop} (hs : def_set S {p : X \u00d7 Y | s p.1 p.2}) :\n  def_set S {x | \u2203 y, s x y} :=\nbegin\n  convert def_set.proj hs,\n  ext, simp\nend\n\nlemma def_set.forall {s : X \u2192 Y \u2192 Prop} (hs : def_set S {p : X \u00d7 Y | s p.1 p.2}) :\n  def_set S {x | \u2200 y, s x y} :=\nbegin\n  -- classical!!\n  have : \u2200 (s : X \u2192 Y \u2192 Prop) (hs : def_set S {p : X \u00d7 Y | s p.1 p.2}),\n    def_set S {x | \u2200 y, \u00ac s x y},\n  { intros t ht, simpa using ht.exists.not },\n  simpa using this (\u03bb x y, \u00ac s x y) hs.not,\nend\n\nlemma def_set.reindex {f : X \u2192 Y} (hf : is_reindexing R f)\n  {s : set Y} (hs : def_set S s) : def_set S (f \u207b\u00b9' s) :=\nbegin\n  cases hf with f\u03c3 hf,\n  unfold def_set,\n  -- The preimage f \u207b\u00b9' s, as a subset of the R\u207f 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\u03c3 hs),\n  ext z,\n  suffices : (\u2203 (x : X), f x \u2208 s \u2227 coords R x = z) \u2194\n    z \u2208 range (coords R) \u2227 \u2203 (y : Y), y \u2208 s \u2227 coords R y = z \u2218 f\u03c3,\n  { simpa },\n  -- TODO: funext'd version of `is_reindexing.hf`\n  replace hf : \u2200 (x : X), coords R x \u2218 f\u03c3 = coords R (f x) := \u03bb x, funext (\u03bb i, (hf x i)),\n  split,\n  { rintro \u27e8x, hfx, rfl\u27e9,\n    refine \u27e8mem_range_self _, f x, hfx, (hf x).symm\u27e9 },\n  { rintro \u27e8\u27e8x, rfl\u27e9, y, hy, H\u27e9,\n    rw hf x at H,\n    replace hf := injective_coords _ H,\n    subst y,\n    exact \u27e8x, hy, rfl\u27e9 }\nend\n\nlemma def_set_diag : def_set S {p : X \u00d7 X | p.1 = p.2} :=\nbegin\n  unfold def_set,\n  -- The image of the diagonal of X in R\u207f \u00d7 R\u207f\n  -- is the diagonal of R\u207f intersected with X \u00d7 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 _ \u2194 _ \u2227 finvec.left z = finvec.right z,\n  split,\n  { rintro \u27e8\u27e8x, y\u27e9, h, rfl\u27e9,\n    change x = y at h,\n    simp [coordinate_image, h] },\n  { rintro \u27e8\u27e8hz\u2081, _\u27e9, hz\u2082\u27e9,\n    rcases hz\u2081 with \u27e8x, hx\u27e9,\n    refine \u27e8\u27e8x, x\u27e9, rfl, _\u27e9,\n    convert finvec.left_append_right _,\n    refine finvec.append.inj_iff.mpr _,\n    simp [hx, hz\u2082] }\nend\n\nlemma def_set.prod_univ {s : set X} (hs : def_set S s) :\n  def_set S {p : X \u00d7 Y | p.1 \u2208 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 \u00d7 Y | p.2 \u2208 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 \u2192 Y is definable if its graph is a definable set. -/\ndef def_fun (f : X \u2192 Y) : Prop := def_set S {p : X \u00d7 Y | f p.1 = p.2}\n\nvariables {S}\n\nlemma def_fun.id : def_fun S (id : X \u2192 X) :=\ndef_set_diag\n\nlemma def_fun.comp {g : Y \u2192 Z} (hg : def_fun S g) {f : X \u2192 Y} (hf : def_fun S f) :\n  def_fun S (g \u2218 f) :=\nbegin\n  suffices : def_set S {p : X \u00d7 Z | \u2203 y, f p.1 = y \u2227 g y = p.2},\n  { unfold def_fun,\n    convert this,\n    ext \u27e8x, z\u27e9,\n    simp },\n  apply def_set.exists,\n  apply def_set.and,\n  { have : is_reindexing R (\u03bb p : (X \u00d7 Z) \u00d7 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 (\u03bb p : (X \u00d7 Z) \u00d7 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 \u2192 Y} (hf : is_reindexing R f) :\n  def_fun S f :=\nbegin\n  cases hf with f\u03c3 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\u03c3 (def_set_univ Y)),\n  ext z,\n  split,\n  { rintro \u27e8\u27e8x, y\u27e9, h, rfl\u27e9,\n    change f x = y at h, subst y,\n    show _ \u2227 _ \u2227 _,\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 \u27e8\u27e8x, _\u27e9, _\u27e9,\n    { simp },\n    { ext i,\n      apply hf, }, },\n  { rintro \u27e8\u27e8x, hx\u27e9, \u27e8hz, \u27e8y, \u27e8\u27e9, hy\u27e9\u27e9\u27e9,\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 \u2190 hf,\n      rw [\u2190 hx, \u2190 hy] at hz,\n      exact congr_fun hz i },\n    { simp [hx, hy] } }\nend\n\nlemma def_fun.preimage {f : X \u2192 Y} (hf : def_fun S f) {s : set Y} (hs : def_set S s) :\n  def_set S (f \u207b\u00b9' s) :=\nbegin\n  -- f \u207b\u00b9' s = {x | \u2203 (p : X \u00d7 Y), p.1 = x \u2227 p \u2208 \u0393(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 (\u03bb 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 (\u03bb x : X, coords R x i) :=\nis_reindexing.def_fun (is_reindexing.coord i)\n\nlemma def_fun.coord_rn {n : \u2115} (i : fin n) : def_fun S (\u03bb x : finvec n R, x i) :=\ndef_fun.coord i\n\nlemma def_fun.fst : def_fun S (prod.fst : X \u00d7 Y \u2192 X) :=\nis_reindexing.def_fun is_reindexing.fst\n\nlemma def_fun.snd : def_fun S (prod.snd : X \u00d7 Y \u2192 Y) :=\nis_reindexing.def_fun is_reindexing.snd\n\nlemma def_fun.prod' {f : X \u2192 Y} {g : X \u2192 Z} (hf : def_fun S f) (hg : def_fun S g) :\n  def_fun S (\u03bb x, (f x, g x)) :=\nbegin\n  unfold def_fun,\n  let p1 : X \u00d7 (Y \u00d7 Z) \u2192 X \u00d7 Y := \u03bb 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 \u00d7 (Y \u00d7 Z) \u2192 X \u00d7 Z := \u03bb 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 \u27e8x,y,z\u27e9,\n  show (f x, g x) = (y,z) \u2194 _,\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 \u2192 Z} {g : Y \u2192 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 \u2192 X) :=\nby haveI := is_definable.subtype hs; exact\nis_reindexing.subtype.val.def_fun\n\nlemma def_fun.finvec.left {n m : \u2115} : def_fun S (\u03bb x : finvec (n+m) R, x.left) :=\nis_reindexing.finvec.left.def_fun\n\nlemma def_fun.finvec.right {n m : \u2115} : def_fun S (\u03bb x : finvec (n+m) R, x.right) :=\nis_reindexing.finvec.right.def_fun\n\nlemma def_fun.finvec.init {n : \u2115} : def_fun S (\u03bb x : finvec (n+1) R, x.init) :=\nis_reindexing.finvec.init.def_fun\n\nlemma def_fun.finvec.snoc' {n : \u2115} : def_fun S (\u03bb p : finvec n R \u00d7 R, p.1.snoc p.2) :=\nis_reindexing.finvec.snoc.def_fun\n\nlemma def_fun.finvec.snoc {n : \u2115} {f : X \u2192 finvec n R} (hf : def_fun S f) {g : X \u2192 R} (hg : def_fun S g) :\n  def_fun S (\u03bb x, (f x).snoc (g x)) :=\ndef_fun.finvec.snoc'.comp (hf.prod' hg)\n\nlemma def_set_eq {f g : X \u2192 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 \u2192 Z} (dg : def_fun S g) (hg : function.injective g)\n  {f : X \u2192 Y} (h : def_fun S (g \u2218 f)) : def_fun S f :=\nbegin\n  unfold def_fun,\n  suffices : def_set S {p : X \u00d7 Y | (g \u2218 f) p.fst = g p.snd},\n  { convert \u2190this,\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 \u2192 X} (df : def_fun S f) (h : \u2200 y, f y \u2208 s) :\n  by haveI := is_definable.subtype hs; exact\n  def_fun S (\u03bb y, (\u27e8f y, h y\u27e9 : 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 \u2192 s} :\n  by haveI := is_definable.subtype ds; exact\n  def_fun S f \u2194 def_fun S (subtype.val \u2218 f) :=\nby haveI := is_definable.subtype ds; exact\n\u27e8\u03bb h, def_fun_subtype_val.comp h, \u03bb h, def_fun_subtype_val.cancel subtype.val_injective h\u27e9\n\nlemma def_fun.image {f : X \u2192 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 | \u2203 x, x \u2208 s \u2227 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 \u2192 Y} (hf : def_fun S f) : def_set S (range f) :=\nby { rw \u2190image_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 \u2208 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 : \u2200 (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 \u2192 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 \u207b\u00b9' {y}), from\nhf.preimage hy\n\nlemma def_set_const_eq' {f : X \u2192 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 (\u03bb (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} = \u22c2 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 \u2192 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 \u2192 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 (\u03bb (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\u00f6lzl, 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\u2081 u\u2081' 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\u2081 is a submodule of V, then dim (V/V\u2081) + dim V\u2081 = 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\u2081`, `V\u2082`, ... 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 : \u21a5b) => \u2191i) =>\n      cardinal.mk \u21a5(subtype.val b)\n\ntheorem is_basis.le_span {K : Type u} {V : Type v} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : \u03b9 \u2192 V} {J : set V} (hv : is_basis K v) (hJ : submodule.span K J = \u22a4) :\n    cardinal.mk \u21a5(set.range v) \u2264 cardinal.mk \u21a5J :=\n  sorry\n\n/-- dimension theorem -/\ntheorem mk_eq_mk_of_basis {K : Type u} {V : Type v} {\u03b9 : Type w} {\u03b9' : Type w'} [field K]\n    [add_comm_group V] [vector_space K V] {v : \u03b9 \u2192 V} {v' : \u03b9' \u2192 V} (hv : is_basis K v)\n    (hv' : is_basis K v') : cardinal.lift (cardinal.mk \u03b9) = cardinal.lift (cardinal.mk \u03b9') :=\n  sorry\n\ntheorem mk_eq_mk_of_basis' {K : Type u} {V : Type v} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {\u03b9' : Type w} {v : \u03b9 \u2192 V} {v' : \u03b9' \u2192 V} (hv : is_basis K v)\n    (hv' : is_basis K v') : cardinal.mk \u03b9 = cardinal.mk \u03b9' :=\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] {\u03b9 : Type v} {v : \u03b9 \u2192 V} (h : is_basis K v) :\n    cardinal.mk \u03b9 = vector_space.dim K V :=\n  sorry\n\ntheorem is_basis.mk_range_eq_dim {K : Type u} {V : Type v} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : \u03b9 \u2192 V} (h : is_basis K v) :\n    cardinal.mk \u21a5(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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : \u03b9 \u2192 V} (h : is_basis K v) :\n    cardinal.lift (cardinal.mk \u03b9) = cardinal.lift (vector_space.dim K V) :=\n  sorry\n\ntheorem is_basis.mk_eq_dim' {K : Type u} {V : Type v} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : \u03b9 \u2192 V} (h : is_basis K v) :\n    cardinal.lift (cardinal.mk \u03b9) = cardinal.lift (vector_space.dim K V) :=\n  eq.mpr (id (propext cardinal.lift_max))\n    (eq.mp (Eq.refl (cardinal.lift (cardinal.mk \u03b9) = 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 : \u2115}\n    (H : \u2200 (s : finset V), (linear_independent K fun (i : \u21a5\u2191s) => \u2191i) \u2192 finset.card s \u2264 n) :\n    vector_space.dim K V \u2264 \u2191n :=\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\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_equiv K V V\u2081) :\n    vector_space.dim K V = vector_space.dim K V\u2081 :=\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\u2081 : Type v} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081]\n    (cond : vector_space.dim K V = vector_space.dim K V\u2081) : Nonempty (linear_equiv K V V\u2081) :=\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\u2081 : Type v) [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081]\n    (cond : vector_space.dim K V = vector_space.dim K V\u2081) : linear_equiv K V V\u2081 :=\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') \u2194\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\u2081 : Type v} [field K]\n    [add_comm_group V] [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] :\n    Nonempty (linear_equiv K V V\u2081) \u2194 vector_space.dim K V = vector_space.dim K V\u2081 :=\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 \u21a5\u22a5 = 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 \u21a5\u22a4 = vector_space.dim K V :=\n  linear_equiv.dim_eq (linear_equiv.of_top \u22a4 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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {v : \u03b9 \u2192 V} (hv : linear_independent K v) :\n    vector_space.dim K \u21a5(submodule.span K (set.range v)) = cardinal.mk \u21a5(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 : \u21a5s) => \u2191x) :\n    vector_space.dim K \u21a5(submodule.span K s) = cardinal.mk \u21a5s :=\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] {\u03b9 : Type w} {v : \u03b9 \u2192 V} (hv : linear_independent K v) :\n    cardinal.lift (cardinal.mk \u03b9) \u2264 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] {\u03b9 : Type v} {v : \u03b9 \u2192 V} (hv : linear_independent K v) :\n    cardinal.mk \u03b9 \u2264 vector_space.dim K V :=\n  eq.mpr (id (Eq.refl (cardinal.mk \u03b9 \u2264 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 : \u21a5s) => \u2191x) : cardinal.mk \u21a5s \u2264 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 \u21a5(submodule.span K s) \u2264 cardinal.mk \u21a5s :=\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 \u21a5(submodule.span K \u2191s) < cardinal.omega :=\n  sorry\n\ntheorem dim_prod {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] :\n    vector_space.dim K (V \u00d7 V\u2081) = vector_space.dim K V + vector_space.dim K V\u2081 :=\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 \u21a5p = 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) \u2264 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\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081) :\n    vector_space.dim K \u21a5(linear_map.range f) + vector_space.dim K \u21a5(linear_map.ker f) =\n        vector_space.dim K V :=\n  sorry\n\ntheorem dim_range_le {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081) :\n    vector_space.dim K \u21a5(linear_map.range f) \u2264 vector_space.dim K V :=\n  sorry\n\ntheorem dim_map_le {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081)\n    (p : submodule K V) : vector_space.dim K \u21a5(submodule.map f p) \u2264 vector_space.dim K \u21a5p :=\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 \u21d1f) :\n    vector_space.dim K \u21a5(linear_map.range f) = vector_space.dim K V' :=\n  sorry\n\ntheorem dim_eq_of_surjective {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081)\n    (h : function.surjective \u21d1f) :\n    vector_space.dim K V = vector_space.dim K V\u2081 + vector_space.dim K \u21a5(linear_map.ker f) :=\n  sorry\n\ntheorem dim_le_of_surjective {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081)\n    (h : function.surjective \u21d1f) : vector_space.dim K V\u2081 \u2264 vector_space.dim K V :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (vector_space.dim K V\u2081 \u2264 vector_space.dim K V))\n        (dim_eq_of_surjective f h)))\n    (self_le_add_right (vector_space.dim K V\u2081) (vector_space.dim K \u21a5(linear_map.ker f)))\n\ntheorem dim_eq_of_injective {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081)\n    (h : function.injective \u21d1f) : vector_space.dim K V = vector_space.dim K \u21a5(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 \u21a5s \u2264 vector_space.dim K V :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (vector_space.dim K \u21a5s \u2264 vector_space.dim K V))\n        (Eq.symm (dim_quotient_add_dim s))))\n    (self_le_add_left (vector_space.dim K \u21a5s) (vector_space.dim K (submodule.quotient s)))\n\ntheorem dim_le_of_injective {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081)\n    (h : function.injective \u21d1f) : vector_space.dim K V \u2264 vector_space.dim K V\u2081 :=\n  eq.mpr\n    (id\n      (Eq._oldrec (Eq.refl (vector_space.dim K V \u2264 vector_space.dim K V\u2081))\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 \u2264 t) :\n    vector_space.dim K \u21a5s \u2264 vector_space.dim K \u21a5t :=\n  sorry\n\ntheorem linear_independent_le_dim {K : Type u} {V : Type v} {\u03b9 : Type w} [field K]\n    [add_comm_group V] [vector_space K V] {v : \u03b9 \u2192 V} (hv : linear_independent K v) :\n    cardinal.lift (cardinal.mk \u03b9) \u2264 cardinal.lift (vector_space.dim K V) :=\n  sorry\n\ntheorem linear_independent_le_dim' {K : Type u} {V : Type v} {\u03b9 : Type w} [field K]\n    [add_comm_group V] [vector_space K V] {v : \u03b9 \u2192 V} (hs : linear_independent K v) :\n    cardinal.lift (cardinal.mk \u03b9) \u2264 cardinal.lift (vector_space.dim K V) :=\n  cardinal.mk_range_eq_lift (linear_independent.injective hs) \u25b8\n    dim_span hs \u25b8 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\u2081 : Type v} {V\u2082 : Type v} {V\u2083 : Type v}\n    [field K] [add_comm_group V] [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081]\n    [add_comm_group V\u2082] [vector_space K V\u2082] [add_comm_group V\u2083] [vector_space K V\u2083]\n    (db : linear_map K V\u2082 V) (eb : linear_map K V\u2083 V) (cd : linear_map K V\u2081 V\u2082)\n    (ce : linear_map K V\u2081 V\u2083) (hde : \u22a4 \u2264 linear_map.range db \u2294 linear_map.range eb)\n    (hgd : linear_map.ker cd = \u22a5) (eq : linear_map.comp db cd = linear_map.comp eb ce)\n    (eq\u2082 :\n      \u2200 (d : V\u2082) (e : V\u2083),\n        coe_fn db d = coe_fn eb e \u2192 \u2203 (c : V\u2081), coe_fn cd c = d \u2227 coe_fn ce c = e) :\n    vector_space.dim K V + vector_space.dim K V\u2081 = vector_space.dim K V\u2082 + vector_space.dim K V\u2083 :=\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 \u21a5(s \u2294 t) + vector_space.dim K \u21a5(s \u2293 t) =\n        vector_space.dim K \u21a5s + vector_space.dim K \u21a5t :=\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 \u21a5(s \u2294 t) \u2264 vector_space.dim K \u21a5s + vector_space.dim K \u21a5t :=\n  sorry\n\ntheorem dim_pi {K : Type u} {\u03b7 : Type u\u2081'} {\u03c6 : \u03b7 \u2192 Type u_1} [field K] [fintype \u03b7]\n    [(i : \u03b7) \u2192 add_comm_group (\u03c6 i)] [(i : \u03b7) \u2192 vector_space K (\u03c6 i)] :\n    vector_space.dim K ((i : \u03b7) \u2192 \u03c6 i) = cardinal.sum fun (i : \u03b7) => vector_space.dim K (\u03c6 i) :=\n  sorry\n\ntheorem dim_fun {K : Type u} [field K] {V : Type u} {\u03b7 : Type u} [fintype \u03b7] [add_comm_group V]\n    [vector_space K V] : vector_space.dim K (\u03b7 \u2192 V) = \u2191(fintype.card \u03b7) * vector_space.dim K V :=\n  sorry\n\ntheorem dim_fun_eq_lift_mul {K : Type u} {V : Type v} {\u03b7 : Type u\u2081'} [field K] [add_comm_group V]\n    [vector_space K V] [fintype \u03b7] :\n    vector_space.dim K (\u03b7 \u2192 V) = \u2191(fintype.card \u03b7) * cardinal.lift (vector_space.dim K V) :=\n  sorry\n\ntheorem dim_fun' {K : Type u} {\u03b7 : Type u\u2081'} [field K] [fintype \u03b7] :\n    vector_space.dim K (\u03b7 \u2192 K) = \u2191(fintype.card \u03b7) :=\n  sorry\n\ntheorem dim_fin_fun {K : Type u} [field K] (n : \u2115) : vector_space.dim K (fin n \u2192 K) = \u2191n := 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 \u2260 \u22a5) : \u2203 (b : V), b \u2208 s \u2227 b \u2260 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 \u21a5s) :\n    \u2203 (b : V), b \u2208 s \u2227 b \u2260 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    \u2203 (s : set V), is_basis K subtype.val \u2227 Nonempty (fintype \u21a5s) :=\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 \u21a5(linear_map.range f)\n\ntheorem rank_le_domain {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081) :\n    rank f \u2264 vector_space.dim K V :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (rank f \u2264 vector_space.dim K V)) (Eq.symm (dim_range_add_dim_ker f))))\n    (self_le_add_right (rank f) (vector_space.dim K \u21a5(linear_map.ker f)))\n\ntheorem rank_le_range {K : Type u} {V : Type v} {V\u2081 : Type v} [field K] [add_comm_group V]\n    [vector_space K V] [add_comm_group V\u2081] [vector_space K V\u2081] (f : linear_map K V V\u2081) :\n    rank f \u2264 vector_space.dim K V\u2081 :=\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) \u2264 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 \u21a5(linear_map.range 0) = 0)) linear_map.range_zero))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (vector_space.dim K \u21a5\u22a5 = 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'] {\u03b7 : Type u_1} (s : finset \u03b7)\n    (f : \u03b7 \u2192 linear_map K V V') :\n    rank (finset.sum s fun (d : \u03b7) => f d) \u2264 finset.sum s fun (d : \u03b7) => rank (f d) :=\n  finset.sum_hom_rel (le_of_eq rank_zero)\n    fun (i : \u03b7) (g : linear_map K V V') (c : cardinal) (h : rank g \u2264 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) \u2264 rank f :=\n  sorry\n\ntheorem rank_comp_le2 {K : Type u} {V : Type v} {V' : Type v'} {V'\u2081 : 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'\u2081] [vector_space K V'\u2081] (g : linear_map K V V') (f : linear_map K V' V'\u2081) :\n    rank (linear_map.comp f g) \u2264 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 \u2194 \u2200 (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 \u2194 \u2203 (x : V), x \u2260 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 \u2194 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 \u2264 1 \u2194 \u2203 (v\u2080 : V), \u2200 (v : V), \u2203 (r : K), r \u2022 v\u2080 = 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 \u21a5s \u2264 1 \u2194 \u2203 (v\u2080 : V), \u2203 (H : v\u2080 \u2208 s), s \u2264 submodule.span K (singleton v\u2080) :=\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 \u21a5s \u2264 1 \u2194 \u2203 (v\u2080 : V), s \u2264 submodule.span K (singleton v\u2080) :=\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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u211d\n\nWe introduce the necessary bits to be able to define manifolds modelled over `\u211d^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 \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n)` for the model space used\n  to define `n`-dimensional real manifolds with boundary\n* `model_with_corners \u211d (euclidean_space \u211d (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* `\ud835\udce1 n` for the identity model with corners on `euclidean_space \u211d (fin n)`\n* `\ud835\udce1\u2202 n` for `model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n)`.\n\nFor instance, if a manifold `M` is boundaryless, smooth and modelled on `euclidean_space \u211d (fin m)`,\nand `N` is smooth with boundary modelled on `euclidean_half_space n`, and `f : M \u2192 N` is a smooth\nmap, then the derivative of `f` can be written simply as `mfderiv (\ud835\udce1 m) (\ud835\udce1\u2202 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 `\u211d^n`, used to model manifolds with boundary. We only define it when\n`1 \u2264 n`, as the definition only makes sense in this case.\n-/\ndef euclidean_half_space (n : \u2115) [HasZero (fin n)] :=\n  Subtype fun (x : euclidean_space \u211d (fin n)) => 0 \u2264 x 0\n\n/--\nThe quadrant in `\u211d^n`, used to model manifolds with corners, made of all vectors with nonnegative\ncoordinates.\n-/\ndef euclidean_quadrant (n : \u2115) :=\n  Subtype fun (x : euclidean_space \u211d (fin n)) => \u2200 (i : fin n), 0 \u2264 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 : \u2115} [HasZero (fin n)] : topological_space (euclidean_half_space n) :=\n  subtype.topological_space\n\nprotected instance euclidean_quadrant.topological_space {n : \u2115} : topological_space (euclidean_quadrant n) :=\n  subtype.topological_space\n\nprotected instance euclidean_half_space.inhabited {n : \u2115} [HasZero (fin n)] : Inhabited (euclidean_half_space n) :=\n  { default := { val := 0, property := sorry } }\n\nprotected instance euclidean_quadrant.inhabited {n : \u2115} : Inhabited (euclidean_quadrant n) :=\n  { default := { val := 0, property := sorry } }\n\ntheorem range_half_space (n : \u2115) [HasZero (fin n)] : (set.range fun (x : euclidean_half_space n) => subtype.val x) = set_of fun (x : euclidean_space \u211d (fin n)) => 0 \u2264 x 0 := sorry\n\ntheorem range_quadrant (n : \u2115) : (set.range fun (x : euclidean_quadrant n) => subtype.val x) =\n  set_of fun (x : euclidean_space \u211d (fin n)) => \u2200 (i : fin n), 0 \u2264 x i := sorry\n\n/--\nDefinition of the model with corners `(euclidean_space \u211d (fin n), euclidean_half_space n)`, used as a\nmodel for manifolds with boundary. In the locale `manifold`, use the shortcut `\ud835\udce1\u2202 n`.\n-/\ndef model_with_corners_euclidean_half_space (n : \u2115) [HasZero (fin n)] : model_with_corners \u211d (euclidean_space \u211d (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 \u211d (fin n)) =>\n        { val := fun (i : fin n) => dite (i = 0) (fun (h : i = 0) => max (x i) 0) fun (h : \u00aci = 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 \u211d (fin n), euclidean_quadrant n)`, used as a\nmodel for manifolds with corners -/\ndef model_with_corners_euclidean_quadrant (n : \u2115) : model_with_corners \u211d (euclidean_space \u211d (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 \u211d (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 : \u211d) (y : \u211d) [fact (x < y)] : local_homeomorph (\u21a5(set.Icc x y)) (euclidean_half_space 1) :=\n  local_homeomorph.mk\n    (local_equiv.mk (fun (z : \u21a5(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 : \u21a5(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 : \u211d) (y : \u211d) [fact (x < y)] : local_homeomorph (\u21a5(set.Icc x y)) (euclidean_half_space 1) :=\n  local_homeomorph.mk\n    (local_equiv.mk (fun (z : \u21a5(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 : \u21a5(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 : \u211d) (y : \u211d) [fact (x < y)] : charted_space (euclidean_half_space 1) \u21a5(set.Icc x y) :=\n  charted_space.mk (insert (Icc_left_chart x y) (singleton (Icc_right_chart x y)))\n    (fun (z : \u21a5(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 : \u211d) (y : \u211d) [fact (x < y)] : smooth_manifold_with_corners (model_with_corners_euclidean_half_space 1) \u21a5(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) \u21a5(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) \u21a5(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 \u2192 G \u2192 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\"\u207b\u00b9\" => grp.inv g\n\ndef leftTranslationOnSet : G \u2192 Set G \u2192 Set G := (liftToSet (onSelf law))\ndef rightTranslationOnSet : G \u2192 Set G \u2192 Set G := (@liftToSet G _ (onSelf (law\u1d52\u1d56)))\ndef conjugationOnSet : G \u2192 Set G \u2192 Set G := (liftToSet (conjugation law))\n\nlocal infix:70 \" \u2022\u2097 \" => leftTranslationOnSet law\nlocal notation:70 lhs:70 \" \u2022\u1d63 \" rhs:70 => rightTranslationOnSet law rhs lhs\nlocal infix:70 \" \u2022\u2022  \" => conjugationOnSet law\n\ninstance leftActionOnSet : Action G law (leftTranslationOnSet law) := actionOnSet _ _\n\ntheorem rightTranslationIdentity (P : Set G) : P \u2022\u1d63 one = P :=\n((@actionOnSet G (law\u1d52\u1d56) _ _ (onSelf (law\u1d52\u1d56)) _).identity P)\n\ntheorem rightTranslationCompat (g g' : G) (P : Set G) : (P \u2022\u1d63 (g * g')) = (P \u2022\u1d63 g) \u2022\u1d63 g' :=\n(@actionOnSet G (law\u1d52\u1d56) _ _ (onSelf (law\u1d52\u1d56)) _).compat g' g P\n\ntheorem translationCompat (g g' : G) (P : Set G) : (g \u2022\u2097 P) \u2022\u1d63 g' = g \u2022\u2097 (P \u2022\u1d63 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 \u2022\u2022 P = (g \u2022\u2097 P) \u2022\u1d63 g\u207b\u00b9 :=\nby\n  simp only [leftTranslationOnSet, rightTranslationOnSet, conjugationOnSet, liftToSet, Set.imgComp]\n  apply Set.imgCongrFun\n  rfl\n\ndef mulOnSet : Set G \u2192 Set G \u2192 Set G := \u03bb P Q =>\n  \u03bb h => \u2203 g, g \u2208 P \u2227 \u2203 g', g' \u2208 Q \u2227 h = g * g'\n\nlocal infixl:70 \" ** \" => mulOnSet law\n\ndef mulOnSetCompat\u2081 (P Q : Set G) (g : G) : P ** (g \u2022\u2097 Q) = (P \u2022\u1d63 g) ** Q :=\nby\n  funext x\n  apply propext\n  have p\u2081 : (P ** (g \u2022\u2097 Q)) x \u2194 \u2203 p, p \u2208 P \u2227 \u2203 q, q \u2208 Q \u2227 x = p * (g * q)\n  by\n    apply Iff.intro\n    exact \u03bb h => match h with\n      | \u27e8 p, pIn, res, \u27e8 q, qIn, resEq \u27e9, xEq \u27e9 =>\n        \u27e8 p, pIn, q, qIn, xEq \u25b8 resEq \u25b8 rfl \u27e9\n    exact \u03bb h => match h with\n      | \u27e8 p, pIn, q, qIn, h \u27e9 =>\n        \u27e8 p, pIn, g * q, \u27e8 q, qIn, rfl \u27e9, h \u27e9\n  have p\u2082 : (\u2203 p, p \u2208 P \u2227 \u2203 q, q \u2208 Q \u2227 x = p * g * q) \u2194 ((P \u2022\u1d63 g) ** Q) x\n  by\n    apply Iff.intro\n    exact \u03bb h => match h with\n      | \u27e8 p, pIn, q, qIn, h \u27e9 =>\n        \u27e8 p * g, \u27e8 p, pIn, rfl \u27e9, q, qIn, h \u27e9\n    exact \u03bb h => match h with\n      | \u27e8 res, \u27e8 p, pIn, resEq \u27e9, q, qIn, xEq \u27e9 =>\n        \u27e8 p, pIn, q, qIn, xEq \u25b8 resEq \u25b8 rfl \u27e9\n  have p\u2083 : (\u2203 p, p \u2208 P \u2227 \u2203 q, q \u2208 Q \u2227 x = p * (g * q)) \u2194\n    \u2203 p, p \u2208 P \u2227 \u2203 q, q \u2208 Q \u2227 x = p * g * q\n  by simp\n  exact p\u2081.trans <| p\u2083.trans p\u2082\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 \u27f6 Y` is an open immersions if\nthe underlying map of spaces is an open embedding `f : X \u27f6 U \u2286 Y`,\nand the sheaf map `Y(V) \u27f6 f _* X(V)` is an iso for each `V \u2286 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 \u27f6 U \u2286 Y` of the underlying\nspaces, such that the sheaf map `Y(V) \u27f6 f _* X(V)` is an iso for each `V \u2286 U`.\n-/\nclass PresheafedSpace.is_open_immersion {X Y : PresheafedSpace C} (f : X \u27f6 Y) : Prop :=\n(base_open : open_embedding f.base)\n(c_iso : \u2200 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 \u27f6 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 \u27f6 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 \u27f6 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 \u27f6 Y} (H : is_open_immersion f)\n\n/-- The functor `opens X \u2964 opens Y` associated with an open immersion `f : X \u27f6 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 \u27f6 Y` induces an isomorphism `X \u2245 Y|_{f(X)}`. -/\n@[simps] noncomputable\ndef iso_restrict : X \u2245 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)))) \u226a\u226b 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, \u2190X.presheaf.map_comp],\n    erw [f.c.naturality_assoc, \u2190X.presheaf.map_comp],\n    congr }\nend\n\n@[simp] lemma iso_restrict_hom_of_restrict : H.iso_restrict.hom \u226b 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, \u2190X.presheaf.map_comp],\n    transitivity f.c.app x \u226b X.presheaf.map (\ud835\udfd9 _),\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 \u226b f = Y.of_restrict _ :=\nby { rw iso.inv_comp_eq, simp }\n\ninstance mono [H : is_open_immersion f] : mono f :=\nby { rw \u2190 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 \u27f6 Y) [hf : is_open_immersion f] (g : Y \u27f6 Z)\n  [hg : is_open_immersion g] :\n  is_open_immersion (f \u226b g) :=\n{ base_open := hg.base_open.comp hf.base_open,\n  c_iso := \u03bb 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, \u2190set.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, \u2190set.image_image],\n        congr },\n      rw this,\n      apply_instance }\n  end }\n\n/-- For an open immersion `f : X \u27f6 Y` and an open set `U \u2286 X`, we have the map `X(U) \u27f6 Y(U)`. -/\nnoncomputable\ndef inv_app (U : opens X) : X.presheaf.obj (op U) \u27f6 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])) \u226b\n  inv (f.c.app (op (H.open_functor.obj U)))\n\n@[simp, reassoc] lemma inv_naturality {U V : (opens X)\u1d52\u1d56} (i : U \u27f6 V) :\n  X.presheaf.map i \u226b H.inv_app (unop V) = H.inv_app (unop U) \u226b\n    Y.presheaf.map (H.open_functor.op.map i) :=\nbegin\n  simp only [inv_app, \u2190category.assoc],\n  rw [is_iso.comp_inv_eq],\n  simp only [category.assoc, f.c.naturality, is_iso.inv_hom_id_assoc, \u2190 X.presheaf.map_comp],\n  erw \u2190 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)) \u226b\n    X.presheaf.map (eq_to_hom (by simp [opens.map, set.preimage_image_eq _ H.base_open.inj])) :=\nbegin\n  rw \u2190 cancel_epi (H.inv_app U),\n  rw is_iso.hom_inv_id,\n  delta inv_app,\n  simp [\u2190 functor.map_comp]\nend\n\n@[simp, reassoc] lemma inv_app_app (U : opens X) :\n  H.inv_app U \u226b 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) \u226b 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 \u27f6 op (H.open_functor.obj ((opens.map f.base).obj U))) :=\nby { erw \u2190 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) \u2286 set.range f.base) :\n  f.c.app (op U) \u226b 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 \u2286 _,\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 \u27e8\u03bb _ h, h, hU\u27e9 } })).op :=\nby { erw \u2190 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 \u2245 Y) : is_open_immersion H.hom :=\n{ base_open := (Top.homeo_of_iso ((forget C).map_iso H)).open_embedding,\n  c_iso := \u03bb _, infer_instance }\n\n@[priority 100]\ninstance of_is_iso {X Y : PresheafedSpace C} (f : X \u27f6 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 \u27f6 Y.carrier}\n  (hf : open_embedding f) : is_open_immersion (Y.of_restrict hf) :=\n{ base_open := hf,\n  c_iso := \u03bb 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 (\ud835\udfd9 _)), 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 \u27f6 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 \u2243\u209c Y := (homeomorph.of_embedding _ h.base_open.to_embedding).trans\n    { to_fun := subtype.val, inv_fun := \u03bb x, \u27e8x,\n      by { rw set.range_iff_surjective.mpr ((Top.epi_iff_surjective _).mp h'), trivial }\u27e9,\n      left_inv := \u03bb \u27e8_,_\u27e9, rfl, right_inv := \u03bb _, 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 \u2190 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 : \u2115) (h : x < 2) : classical.some \u27e8x, h\u27e9 < 2 :=\nbegin\n  generalize_proofs a,\n  guard_hyp a : \u2203 x, x < 2,\n  guard_target classical.some a < 2,\n  exact classical.some_spec a,\nend\n\nexample (a : \u2203 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 : \u2115) (h : x < 2) (a : \u2203 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 : \u2115) (h : x < 2) (H : classical.some \u27e8x, h\u27e9 < 2) : classical.some \u27e8x, h\u27e9 < 2 :=\nbegin\n  generalize_proofs a at H \u22a2,\n  guard_hyp a : \u2203 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 : \u2200 x, x = 1) : (if h : \u2203 (k : \u2115), k = 1 then classical.some h else 0) = 1 :=\nbegin\n  rw [dif_pos], tactic.swap, { exact \u27e81, rfl\u27e9 },\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 \u22a2,\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 (\u03b1 : Sort*) (L\u2081 L\u2082 L\u2083 : list \u03b1)\n  (H : L\u2081 ++ L\u2082 = L\u2083) : true :=\nbegin\n  have : L\u2081 ++ L\u2082 = L\u2082,\n  { generalize_hyp h : L\u2081 ++ L\u2082 = L at H,\n    induction L with hd tl ih,\n    case list.nil\n    { tactic.cleanup,\n      change list.nil = L\u2083 at H,\n      admit },\n    case list.cons\n    { change list.cons hd tl = L\u2083 at H,\n      admit } },\n  trivial\nend\n\nexample (x y : \u2115) (p q : Prop) (h : x = y) (h' : p \u2194 q) : true :=\nbegin\n  symmetry' at h,\n  guard_hyp' h : y = x,\n  guard_hyp' h' : p \u2194 q,\n  symmetry' at *,\n  guard_hyp' h : x = y,\n  guard_hyp' h' : q \u2194 p,\n  trivial\nend\n\nsection h_generalize\n\nvariables {\u03b1 \u03b2 \u03b3 \u03c6 \u03c8 : Type} (f : \u03b1 \u2192 \u03b1 \u2192 \u03b1 \u2192 \u03c6 \u2192 \u03b3)\n          (x y : \u03b1) (a b : \u03b2) (z : \u03c6)\n          (h\u2080 : \u03b2 = \u03b1) (h\u2081 : \u03b2 = \u03b1) (h\u2082 : \u03c6 = \u03b2)\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\u2080 a) (cast h\u2080 b) (eq.mpr h\u2081.symm a) (eq.mpr h\u2082 a) :=\nbegin\n  guard_hyp_nums 16,\n  h_generalize hp : a == p with hh,\n  guard_hyp_nums 19,\n  guard_hyp' hh : \u03b2 = \u03b1,\n  guard_target f x y x z = f p (cast h\u2080 b) p (eq.mpr h\u2082 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\u2082 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 {\u03b1 \u03b2 \u03b3 \u03c6 \u03c8 : Type} (f : list \u03b1 \u2192 list \u03b1 \u2192 \u03b3)\n          (x : list \u03b1) (a : list \u03b2) (z : \u03c6)\n          (h\u2080 : \u03b2 = \u03b1) (h\u2081 : list \u03b2 = list \u03b1)\n          (hx : x == a)\ninclude f x z a hx h\u2080 h\u2081\n\nexample : true :=\nbegin\n  have : f x x = f (eq.rec_on h\u2080 a) (cast h\u2081 a),\n  { guard_hyp_nums 11,\n    h_generalize : a == p with _,\n    guard_hyp_nums 13,\n    guard_hyp' h : \u03b2 = \u03b1,\n    guard_target f x x = f p (cast h\u2081 a),\n    h_generalize! : a == q ,\n    guard_hyp_nums 13,\n    guard_target \u2200 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\u2080 : p \u2194 q)\n  (h\u2081 : q \u2194 r)\n  (h\u2082 : r \u2194 s) :\n  p \u2194 s :=\nbegin\n  scc,\nend\n\nexample (p' p q r r' s s' : Prop)\n  (h\u2080 : p' \u2192 p)\n  (h\u2080 : p \u2192 q)\n  (h\u2081 : q \u2192 r)\n  (h\u2081 : r' \u2192 r)\n  (h\u2082 : r \u2194 s)\n  (h\u2082 : s \u2192 p)\n  (h\u2082 : s \u2192 s') :\n  p \u2194 s :=\nbegin\n  scc,\nend\n\nexample (p' p q r r' s s' : Prop)\n  (h\u2080 : p' \u2192 p)\n  (h\u2080 : p \u2192 q)\n  (h\u2081 : q \u2192 r)\n  (h\u2081 : r' \u2192 r)\n  (h\u2082 : r \u2194 s)\n  (h\u2082 : s \u2192 p)\n  (h\u2082 : s \u2192 s') :\n  p \u2194 s :=\nbegin\n  scc',\n  assumption\nend\n\nexample : tfae [true, \u2200 n : \u2115, 0 \u2264 n * n, true, true] := begin\n  tfae_have : 3 \u2192 1, { intro h, constructor },\n  tfae_have : 2 \u2192 3, { intro h, constructor },\n  tfae_have : 2 \u2190 1, { intros h n, apply nat.zero_le },\n  tfae_have : 4 \u2194 2, { tauto },\n  tfae_finish,\nend\n\nexample : tfae [] := begin\n  tfae_finish,\nend\n\nvariables P Q R : Prop\n\nexample (pq : P \u2192 Q) (qr : Q \u2192 R) (rp : R \u2192 P) : tfae [P, Q, R] :=\nbegin\n  tfae_finish\nend\n\nexample (pq : P \u2194 Q) (qr : Q \u2194 R) : tfae [P, Q, R] :=\nbegin\n  tfae_finish -- the success or failure of this tactic is nondeterministic!\nend\n\nexample (p : unit \u2192 Prop) : tfae [p (), p ()] :=\nbegin\n  tfae_have : 1 \u2194 2, from iff.rfl,\n  tfae_finish\nend\n\nend tfae\n\nsection clear_aux_decl\n\nexample (n m : \u2115) (h\u2081 : n = m) (h\u2082 : \u2203 a : \u2115, a = n \u2227 a = m) : 2 * m = 2 * n :=\nlet \u27e8a, ha\u27e9 := h\u2082 in\nbegin\n  clear_aux_decl, -- subst will fail without this line\n  subst h\u2081\nend\n\nexample (x y : \u2115) (h\u2081 : \u2203 n : \u2115, n * 1 = 2) (h\u2082 : 1 + 1 = 2 \u2192 x * 1 = y) : x = y :=\nlet \u27e8n, hn\u27e9 := h\u2081 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 {\u03b1\u2081 \u03b1\u2082 \u03b1\u2083 : Type} : true :=\nby {have : \u03b1\u2081, have : \u03b1\u2082, have : \u03b1\u2083, 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 \u2190 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 \u27f6 Y) (y : Y \u27f6 Z) (z z' : Z \u27f6 W) (w : X \u27f6 Z)\n  (h : x \u226b y = w)\n  (h' : y \u226b z = y \u226b z') :\n  x \u226b y \u226b z = w \u226b 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 (\u03b1 : Sort*) (\u03b2 : Sort*) :=\n(to_fun    : \u03b1 \u2192 \u03b2)\n(inv_fun   : \u03b2 \u2192 \u03b1)\n(left_inv  : left_inverse inv_fun to_fun)\n(right_inv : right_inverse inv_fun to_fun)\n\ninfix ` my\u2243 `:25 := my_equiv\n\nprotected def my_rfl {\u03b1} : \u03b1 my\u2243 \u03b1 :=\n\u27e8id, \u03bb x, x, \u03bb x, rfl, \u03bb x, rfl\u27e9\n\ndef eta_expansion_test : \u2115 \u00d7 \u2115 := ((1,0).1,(1,0).2)\nrun_cmd do e \u2190 get_env, x \u2190 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 : \u2115 my\u2243 \u2115 :=\n\u27e8my_rfl.to_fun, my_rfl.inv_fun, \u03bb x, rfl, \u03bb x, rfl\u27e9\n\nrun_cmd do e \u2190 get_env, x \u2190 e.get `eta_expansion_test2,\n  let v := (x.value.get_app_args).drop 2,\n  projs \u2190 e.structure_fields_full `my_equiv,\n  b \u2190 expr.is_eta_expansion_aux x.value (projs.zip v),\n  guard $ b = some `(@my_rfl \u2115)\n\nrun_cmd do e \u2190 get_env, x1 \u2190 e.get `eta_expansion_test, x2 \u2190 e.get `eta_expansion_test2,\n  b1 \u2190 expr.is_eta_expansion x1.value,\n  b2 \u2190 expr.is_eta_expansion x2.value,\n  guard $ b1 = some `((1, 0)) \u2227 b2 = some `(@my_rfl \u2115)\n\nstructure my_str (n : \u2115) := (x y : \u2115)\n\ndef dummy : my_str 3 := \u27e81, 1\u27e9\ndef wrong_param : my_str 2 := \u27e8dummy.1, dummy.2\u27e9\ndef right_param : my_str 3 := \u27e8dummy.1, dummy.2\u27e9\n\nrun_cmd do e \u2190 get_env,\n  x \u2190 e.get `wrong_param, o \u2190 x.value.is_eta_expansion,\n  guard o.is_none,\n  x \u2190 e.get `right_param, o \u2190 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 : \u2115}\nvariables (h  : x + y + z \u2264 w)\n          (h' : x \u2264 y + z + w)\ninclude h h'\n\nexample : x + y + z \u2264 w :=\nbegin\n  elide 0 at h,\n  elide 2 at h',\n  guard_hyp h : @hidden _ (x + y + z \u2264 w),\n  guard_hyp h' : x \u2264 @has_add.add (@hidden Type nat) (@hidden (has_add nat) nat.has_add)\n                                   (@hidden \u2115 (y + z)) (@hidden \u2115 w),\n  unelide at h,\n  unelide at h',\n  guard_hyp h' : x \u2264 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 (\u03b1 : Type*) :=\n(x y : \u2115)\n(z : {z // z < x})\n(k : \u03b1)\n(h : x < y)\n\nexample {\u03b1 : Type*} : \u03a0 (x y : foo \u03b1), x.x = y.x \u2192 x.y = y.y \u2192 x.z == y.z \u2192 x.k = y.k \u2192 x = y :=\nfoo.ext\n\nexample {\u03b1 : Type*} : \u03a0 (x y : foo \u03b1), x = y \u2194 x.x = y.x \u2227 x.y = y.y \u2227 x.z == y.z \u2227 x.k = y.k :=\nfoo.ext_iff\n\nexample {\u03b1} (x y : foo \u03b1) (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 : \u2124) (n : \u2115) : (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 : \u2115) (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 : \u2115) : fin a \u2192 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 \u03bb _, ()\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 : \u2115) (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 {\u03b1 \u03b2 : Type} {f : \u03b1 \u2192 \u03b2} {t : set \u03b2} :\n    (\u2200 s, f '' s \u2286 t) = \u2200 s : set \u03b1, \u2200 x \u2208 s, x \u2208 f \u207b\u00b9' 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 : \u2115 \u2192 Type} {n : \u2115} : let k := n + 3, l := k + n, f : A k \u2192 A k := id in\n  \u2200(x : A k) (y : A (n + k)) (z : A n) (h : k = n + n), unit :=\nbegin\n  intros, guard_target unit,\n  do { e \u2190 get_local `k, e1 \u2190 tactic.local_def_value e, e2 \u2190 to_expr ```(n + 3), guard $ e1 = e2 },\n  do { e \u2190 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 \u2190 get_local `k,\n    tactic.revert_reverse_dependencies_of_hyp e,\n    l \u2190 local_context,\n    guard $ e \u2208 l,\n    intros },\n  exact unit.star\nend\n\nexample {A : \u2115 \u2192 Type} {n : \u2115} : let k := n + 3, l := k + n, f : A k \u2192 A (n+3) := id in\n  \u2200(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 : \u2115 \u2192 Type} {n : \u2115} : let k := n + 3, l := k + n, f : A k \u2192 A (n+3) := id in\n  \u2200(x : A k) (y : A (n + k)) (z : A n) (h : k = n + n), unit :=\nbegin\n  intros,\n  tactic.to_expr ```(n + n) >>= \u03bb 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 : \u2115 \u2192 Type} {n : \u2115} : let k := n + 3, l := k + n, f : A k \u2192 A k := id in\n  \u2200(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 : \u2200 x y : \u2124, let z := x + y in x = z - y \u2192 x = y - z \u2192 true :=\nbegin\n  introv h h,\n  guard_hyp x : \u2124,\n  guard_hyp y : \u2124,\n  guard_hyp z : \u2124 := 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 : \u2124,\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 : \u2115) : k = 5 \u2192 unit :=\nbegin\n  generalize' : 5 = n,\n  guard_target (k = n \u2192 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 : \u2115) : k = 5 \u2192 unit :=\nbegin\n  generalize' h : 5 = n,\n  guard_target (k = n \u2192 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 \u2190 get_user_attribute_name `library_note, guard $ nm = `library_note_attr\nrun_cmd do nm \u2190 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)\u1d52\u1d56 \u2964 C`,\nand inherit the category structure with natural transformations as morphisms.\n\nWe define\n* `pushforward_obj {X Y : Top.{v}} (f : X \u27f6 Y) (\u2131 : X.presheaf C) : Y.presheaf C`\nwith notation `f _* \u2131`\nand for `\u2131 : X.presheaf C` provide the natural isomorphisms\n* `pushforward.id : (\ud835\udfd9 X) _* \u2131 \u2245 \u2131``\n* `pushforward.comp : (f \u226b g) _* \u2131 \u2245 g _* (f _* \u2131)`\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 \u21a5X\u1d52\u1d56 \u2964 C\n\nnamespace presheaf\n\n\n/-- Pushforward a presheaf on `X` along a continuous map `f : X \u27f6 Y`, obtaining a presheaf on `Y`. -/\ndef pushforward_obj {C : Type u} [category_theory.category C] {X : Top} {Y : Top} (f : X \u27f6 Y)\n    (\u2131 : presheaf C X) : presheaf C Y :=\n  category_theory.functor.op (topological_space.opens.map f) \u22d9 \u2131\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 \u27f6 Y) (\u2131 : presheaf C X) (U : topological_space.opens \u21a5Y\u1d52\u1d56) :\n    category_theory.functor.obj (f _* \u2131) U =\n        category_theory.functor.obj \u2131\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 \u27f6 Y) (\u2131 : presheaf C X) {U : topological_space.opens \u21a5Y\u1d52\u1d56}\n    {V : topological_space.opens \u21a5Y\u1d52\u1d56} (i : U \u27f6 V) :\n    category_theory.functor.map (f _* \u2131) i =\n        category_theory.functor.map \u2131\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 \u27f6 Y}\n    {g : X \u27f6 Y} (h : f = g) (\u2131 : presheaf C X) : f _* \u2131 \u2245 g _* \u2131 :=\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    \u2131\n\n@[simp] theorem pushforward_eq_hom_app {C : Type u} [category_theory.category C] {X : Top} {Y : Top}\n    {f : X \u27f6 Y} {g : X \u27f6 Y} (h : f = g) (\u2131 : presheaf C X) (U : topological_space.opens \u21a5Y\u1d52\u1d56) :\n    category_theory.nat_trans.app (category_theory.iso.hom (pushforward_eq h \u2131)) U =\n        category_theory.functor.map \u2131\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 \u27f6 Y) (\u2131 : presheaf C X) (U : topological_space.opens \u21a5Y) :\n    category_theory.nat_trans.app (category_theory.iso.hom (pushforward_eq rfl \u2131)) (opposite.op U) =\n        \ud835\udfd9 :=\n  sorry\n\ntheorem pushforward_eq_eq {C : Type u} [category_theory.category C] {X : Top} {Y : Top} {f : X \u27f6 Y}\n    {g : X \u27f6 Y} (h\u2081 : f = g) (h\u2082 : f = g) (\u2131 : presheaf C X) :\n    pushforward_eq h\u2081 \u2131 = pushforward_eq h\u2082 \u2131 :=\n  rfl\n\nnamespace pushforward\n\n\ndef id {C : Type u} [category_theory.category C] {X : Top} (\u2131 : presheaf C X) : \ud835\udfd9 _* \u2131 \u2245 \u2131 :=\n  category_theory.iso_whisker_right\n      (category_theory.nat_iso.op (category_theory.iso.symm (topological_space.opens.map_id X)))\n      \u2131 \u226a\u226b\n    category_theory.functor.left_unitor \u2131\n\n@[simp] theorem id_hom_app' {C : Type u} [category_theory.category C] {X : Top} (\u2131 : presheaf C X)\n    (U : set \u21a5X) (p : is_open U) :\n    category_theory.nat_trans.app (category_theory.iso.hom (id \u2131))\n          (opposite.op { val := U, property := p }) =\n        category_theory.functor.map \u2131 \ud835\udfd9 :=\n  sorry\n\n@[simp] theorem id_hom_app {C : Type u} [category_theory.category C] {X : Top} (\u2131 : presheaf C X)\n    (U : topological_space.opens \u21a5X\u1d52\u1d56) :\n    category_theory.nat_trans.app (category_theory.iso.hom (id \u2131)) U =\n        category_theory.functor.map \u2131\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} (\u2131 : presheaf C X)\n    (U : set \u21a5X) (p : is_open U) :\n    category_theory.nat_trans.app (category_theory.iso.inv (id \u2131))\n          (opposite.op { val := U, property := p }) =\n        category_theory.functor.map \u2131 \ud835\udfd9 :=\n  sorry\n\ndef comp {C : Type u} [category_theory.category C] {X : Top} (\u2131 : presheaf C X) {Y : Top} {Z : Top}\n    (f : X \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g) _* \u2131 \u2245 g _* (f _* \u2131) :=\n  category_theory.iso_whisker_right\n    (category_theory.nat_iso.op (category_theory.iso.symm (topological_space.opens.map_comp f g))) \u2131\n\n@[simp] theorem comp_hom_app {C : Type u} [category_theory.category C] {X : Top} (\u2131 : presheaf C X)\n    {Y : Top} {Z : Top} (f : X \u27f6 Y) (g : Y \u27f6 Z) (U : topological_space.opens \u21a5Z\u1d52\u1d56) :\n    category_theory.nat_trans.app (category_theory.iso.hom (comp \u2131 f g)) U = \ud835\udfd9 :=\n  sorry\n\n@[simp] theorem comp_inv_app {C : Type u} [category_theory.category C] {X : Top} (\u2131 : presheaf C X)\n    {Y : Top} {Z : Top} (f : X \u27f6 Y) (g : Y \u27f6 Z) (U : topological_space.opens \u21a5Z\u1d52\u1d56) :\n    category_theory.nat_trans.app (category_theory.iso.inv (comp \u2131 f g)) U = \ud835\udfd9 :=\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 \u27f6 Y)\n    {\u2131 : presheaf C X} {\ud835\udca2 : presheaf C X} (\u03b1 : \u2131 \u27f6 \ud835\udca2) : f _* \u2131 \u27f6 f _* \ud835\udca2 :=\n  category_theory.nat_trans.mk\n    fun (U : topological_space.opens \u21a5Y\u1d52\u1d56) =>\n      category_theory.nat_trans.app \u03b1\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 : \u2102 \u2192 \u2102) (z : \u2102) : differentiable_at \u2102 f z \u2194 analytic_at \u2102 f z :=\nsorry\n\ntheorem smooth_within_at_iff_holomorph_within_at (f : \u2102 \u2192 \u2102) {s : set \u2102} (h : is_open s) : \u2200 (z : \u2102), (differentiable_within_at \u2102 f s z \u2194 times_cont_diff_within_at \u2102 \u22a4 f s z):=\nsorry\n\ntheorem smooth_at_iff_holomorph_at (f : \u2102 \u2192 \u2102) : \u2200 (z : \u2102), (differentiable_at \u2102 f z \u2194 times_cont_diff_at \u2102 \u22a4 f z) :=\nsorry\n\ntheorem smooth_on_iff_holomorph_on (f : \u2102 \u2192 \u2102) {s : set \u2102} (h : is_open s) : differentiable_on \u2102 f s \u2194 times_cont_diff_on \u2102 \u22a4 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--- \u2203 (V : set X), is_open V \u2227 U \u2229 (V \\ {z}) = \u2205\n\ndef accumulation_pt (X : Type*) [topological_space X] (U : set X) (z : X) : Prop :=\n\u2200 (V : set X), V \u2208 (\ud835\udcdd z) \u2192 \u2203 (v : X), v \u2208 U \u2229 V \u2227 \u00ac 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 \u2208 U') (hz : accumulation_pt X U z) :\n  accumulation_pt X (U \u2229 U') z := \n\u03bb V hV, (set.inter_assoc U U' V).symm \u25b8 \n  (hz (U' \u2229 V) $ _root_.mem_nhds_iff.mpr $ \n    let \u27e8t, ht, ht\u2081, ht\u2082\u27e9 := _root_.mem_nhds_iff.mp hV in \n    \u27e8U' \u2229 t, \u27e8set.inter_subset_inter_right U' ht, \u27e8is_open.inter hU' ht\u2081, \u27e8HU', ht\u2082\u27e9\u27e9\u27e9\u27e9)\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 \u2208 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 \u27e8v, hv\u2081, hv\u2082\u27e9,\n  use v,\n  rw set.inter_comm at hv\u2081,\n  exact hv\u2081,\nend\n\nend accuml_pts\n\nsection crowded_space\n\nclass crowded_space (X : Type*) [t : topological_space X] :=\n(is_crowded : \u2200 (x : X), \u00ac t.is_open {x})\n\nlemma crowded_space.def (X : Type*) [t : topological_space X] [cr : crowded_space X] : \n\u2200 (x : X), \u00ac t.is_open {x} := cr.is_crowded\n\nlemma mem_frontier (X : Type*) [t : topological_space X] {U : set X} {z : X} : \n  z \u2208 frontier U \u2192 \u2200 (V : set X), V \u2208 \ud835\udcdd z \u2192 (V \u2229 U \u2260 \u2205 \u2227 V \\ U \u2260 \u2205) :=\nbegin\n  intros hz,\n  rw frontier at hz,\n  have h : \u2200 (o : set X), is_open o \u2192 z \u2208 o \u2192 (o \u2229 U).nonempty := \n    _root_.mem_closure_iff.mp (mem_of_mem_diff hz),\n  have h' : \u00ac (\u2203 (o : set X) (H : o \u2286 U), is_open o \u2227 z \u2208 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 \u27e8V', hV'\u2081, hV'\u2082, hV'\u2083\u27e9,\n  split,\n  { exact set.nonempty.ne_empty (set.nonempty.mono (set.inter_subset_inter_left _ hV'\u2081) $ h V' hV'\u2082 hV'\u2083), },\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'\u2081 w) hV'\u2082) hV'\u2083, },\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 : \u2200 (x : X), \u2203 (y : X), \u00ac y = x) (x : X) : \u00ac t.is_open {x} :=\nbegin\n  by_contra w,\n  rcases hX x with \u27e8y, hy\u27e9,\n  have minor\u2081 : is_open {x}\u1d9c := is_open_compl_singleton,\n  have : set.nonempty {x}\u1d9c,\n  { use y, rw [\u2190 ne.def, \u2190 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 \u2208 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 \u27e8V', hV'\u2081, hV'\u2082, hV'\u2083\u27e9,\n  rcases hU z hz with \u27e8U', hU'\u2081, hU'\u2082, hU'\u2083\u27e9,\n  have : \u00ac (U' \u2229 V') = {z} := by_contra (\u03bb h, ht z $ (not_not.mp h) \u25b8 is_open.inter hU'\u2082 hV'\u2082),\n  rw set.ext_iff at this,\n  simp at this,\n  rcases this with \u27e8v, hV\u27e9,\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 \u27e8\u27e8hU'\u2081 h.1, hV'\u2081 h.2.1\u27e9, h.2.2\u27e9, },\n  { simp at h,\n    exfalso,\n    exact h.2 (h.1.symm \u25b8 hU'\u2083) (h.1.symm \u25b8 hV'\u2083), },\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 \u2208 frontier U) :\n  accumulation_pt X U z := \nif h : z \u2208 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 \u27e8v, hv\u27e9,\n    use v,\n    have : \u00ac v = z := begin\n      by_contra w,\n      rw \u2190 w at h,\n      exact h hv.2,\n    end,\n    rw set.inter_comm at hv,\n    exact \u27e8hv, this\u27e9,\n  end\n\ninstance complex_plane_crowded_space : crowded_space \u2102 :=\n{ is_crowded := begin\n    have : \u2200 (x : \u2102), \u2203 y, \u00ac y = x :=\n    begin\n      intros x,\n      by_cases (x = 0),\n      { rw h,\n        exact \u27e81, one_ne_zero\u27e9, },\n      { exact \u27e80, \u03bb h', h h'.symm\u27e9, },\n    end,\n    exact t1_space_connected_with_two_points_is_crowded \u2102 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 \u2208 closure U)\n  {Y : Type*} [topological_space Y] {e : local_homeomorph X Y} (he : x \u2208 e.to_local_equiv.source) :\n  e x \u2208 closure (e '' U) :=\nbegin\n  rw _root_.mem_closure_iff at hx \u22a2,\n  intros o ho hxo,\n  have : e.is_image (e\u207b\u00b9' 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 \u2229 e\u207b\u00b9' o,\n  have subkey : x \u2208 o' := \u27e8he, hxo\u27e9,\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 \u27e8z, hz\u2081, hz\u2082\u27e9,\n  rcases hz\u2081 with \u27e8hz\u2081\u2081, hz\u2081\u2082\u27e9,\n  use e z,\n  exact \u27e8hz\u2081\u2082, set.mem_image_of_mem e hz\u2082\u27e9,\nend\n\nlemma mem_closure_inter\n  {X : Type*} [topological_space X] {U : set X} {x : X} (hx : x \u2208 closure U)\n  {U' : set X} (hU' : is_open U') (h : x \u2208 U') :\n  x \u2208 closure (U \u2229 U') :=\nbegin\n  rw _root_.mem_closure_iff at hx \u22a2,\n  intros o ho hxo,\n  specialize hx (o \u2229 U') (is_open.inter ho hU') \u27e8hxo, h\u27e9,\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 \u2208 e.to_local_equiv.source) :\n  accumulation_pt Y (e '' U) (e x) :=\nbegin\n  rw accumulation_pt at hx \u22a2,\n  intros V hV,\n  rcases _root_.mem_nhds_iff.mp hV with \u27e8V', hV'\u2081, hV'\u2082, hV'\u2083\u27e9,\n  specialize hx (e.to_local_equiv.source \u2229 e\u207b\u00b9' (V' \u2229 e.to_local_equiv.target)),\n  have : (e.to_local_equiv.source \u2229 e\u207b\u00b9' (V' \u2229 e.to_local_equiv.target)) \u2208 \ud835\udcdd x :=\n  begin\n    have minor : is_open (V' \u2229 e.to_local_equiv.target) := is_open.inter hV'\u2082 e.open_target,\n    have key : x \u2208 (e\u207b\u00b9' (V' \u2229 e.to_local_equiv.target)) := set.mem_preimage.mpr \u27e8hV'\u2083, local_equiv.map_source _ he\u27e9,\n    refine is_open.mem_nhds _ \u27e8he, key\u27e9,\n    apply local_homeomorph.preimage_open_of_open,\n    exact is_open.inter hV'\u2082 e.open_target,\n  end,\n  rcases hx this with \u27e8a, ha\u2081, ha\u2082\u27e9,\n  rcases ha\u2081 with \u27e8haa, hab\u27e9,\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 [\u2190 local_homeomorph.coe_coe, \n        \u2190 local_equiv.symm_image_target_inter_eq e.to_local_equiv V'] at p,\n    have : set.left_inv_on \u21d1(e.to_local_equiv) \n          \u21d1(e.to_local_equiv.symm) e.to_local_equiv.target := \n    begin\n      nth_rewrite 0 \u2190 local_equiv.symm_symm e.to_local_equiv,\n      rw [\u2190local_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'\u2081 p.2, },\n  rw set.mem_image at p,\n  rcases p with \u27e8b, hb\u27e9,\n  rcases hb with \u27e8left, right\u27e9,\n  rcases left with \u27e8hb\u2081, hb\u2082\u27e9,\n  { intros w,\n    have key : a = b := by rwa [eq_comm, \u2190local_homeomorph.coe_coe e, \n          set.inj_on.eq_iff (local_equiv.inj_on e.to_local_equiv) hab.1 hb\u2081] at right,\n    rw \u2190 right at w,\n    rw [eq_comm, \u2190local_homeomorph.coe_coe e, \n        set.inj_on.eq_iff (local_equiv.inj_on e.to_local_equiv) he hb\u2081] at w,\n    rw \u2190 key at w,\n    exact ha\u2082 (eq_comm.mp w), },\nend\n\nend accuml_pts_homeomorph\n\nsection complex_theorems\n\ntheorem identity_theorem\n  {f : \u2102 \u2192 \u2102} {g : \u2102 \u2192 \u2102}\n  {U : set \u2102} (hU\u2081 : is_open U) (hU\u2082 : is_connected U)\n  (hf : differentiable_on \u2102 f U) (hg : differentiable_on \u2102 g U)\n  {s\u2080 : \u2102} {S : set \u2102} (hS : S \u2286 U) (hS' : set.eq_on f g S)\n  (hs\u2080 : s\u2080 \u2208 S) (hs\u2080' : accumulation_pt \u2102 S s\u2080):\n  set.eq_on f g U :=\nsorry\n\ntheorem eq_of_eq_on_open\n  {f : \u2102 \u2192 \u2102} {g : \u2102 \u2192 \u2102}\n  {U : set \u2102} (hU\u2081 : is_open U) (hU\u2082 : is_connected U)\n  (hf : differentiable_on \u2102 f U) (hg : differentiable_on \u2102 g U)\n  {V : set \u2102} (hV\u2081 : is_open V) (hV\u2082 : V.nonempty) (hV\u2083 : set.eq_on f g V) (hV\u2084 : V \u2286 U) :\n  set.eq_on f g U := \nlet \u27e8v, hv\u27e9 := hV\u2082 in \n  identity_theorem hU\u2081 hU\u2082 hf hg hV\u2084 hV\u2083 hv $ accumulation_pt_of_mem_open_nondiscrete \u2102 hV\u2081 hv\n\ntheorem open_mapping_complex\n  {f : \u2102 \u2192 \u2102}\n  {U : set \u2102} (hU\u2081 : is_open U) (hU\u2082 : is_connected U)\n  (hf\u2081 : differentiable_on \u2102 f U)\n  (hf\u2082 : \u2203 (x y : \u2102), x \u2208 U \u2227 y \u2208 U \u2227 \u00ac f x = f y) :\n  \u2200 (U' : set \u2102), U' \u2286 U \u2192 is_open U' \u2192 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(\u03b5 : \u211d) {h\u03b5 : \u03b5 > 0}\n(f : \u2102 \u2192 \u2102)\n(w : \u2102)\n{hf\u2081 : \u2203 (z : \u2102), z \u2208 ball w \u03b5 \u2227 \u00acf z = 0}\n{hf\u2082 : \u2200 (z : \u2102), z \u2208 ball w \u03b5  \u2192 analytic_at \u2102 f z} {hf\u2082 : f w = 0}:\n\u2203 (k : \u2115) (r : \u211d) (g : \u2102 \u2192 \u2102),\nk > 0 \u2227 r \u2264 \u03b5 \u2227 0 < r \u2227\n\u2200 (x : \u2102), x \u2208 ball w r \u2192 f = (\u03bb x, ((x - w) ^ k) * g x)\n\u2227 \u00ac g x = 0 \u2227 analytic_at \u2102 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 : \u2102 \u2192 \u2102)\n(w : \u2102)\n{hf : analytic_at \u2102 f w}:\n(\u2203 (k : \u2115),\n\u00ac iterated_deriv k f w = 0)\n\u2194 (\u2203 (\u03b5 : \u211d), 0 < \u03b5 \u2227 (\u2200 (z : \u2102), z \u2208 ball w \u03b5 \u2192 analytic_at \u2102 f z) \n\u2227 (\u2203 (z : \u2102), z \u2208 ball w \u03b5 \u2227 \u00acf z = 0)) := \nsorry\n\nlemma nonvanishing_disk_of_continuous\n(f : \u2102 \u2192 \u2102)\n(z : \u2102) {hf\u2081 : continuous_at f z} {hf\u2082 : \u00ac f z = 0}:\n\u2203 (\u03b5 : \u211d),\n0 < \u03b5 \u2227 \u2200 (x : \u2102), x \u2208 ball z \u03b5 \u2192 \u00ac f x = 0 :=\nbegin\n  have := hf\u2081,\n  rw continuous_at_iff at this,\n    let \u03b5' := \u2225f z\u2225 / 2,\n    rw [\u2190 ne.def, \u2190 norm_pos_iff] at hf\u2082,\n    have h\u03b5' : 0 < \u2225f z\u2225 / 2 := by linarith,\n    rcases this \u03b5' h\u03b5' with \u27e8\u03b4, h\u03b4, h\u27e9,\n    use min \u03b5' \u03b4,\n    split,\n    simp,\n    exact \u27e8h\u03b5', h\u03b4\u27e9,\n    {\n      intros x hx,\n      rw [mem_ball', dist_comm] at hx,\n      have lt_\u03b4 : dist x z < \u03b4 := lt_of_lt_of_le hx (min_le_right _ _),\n      specialize h lt_\u03b4,\n      rw [dist_eq_norm, norm_sub_rev] at h,\n      have key : 0 < \u2225f x\u2225 :=\n        calc \u2225f x\u2225 = \u2225f z - (f z - f x)\u2225 : by simp\n        ... \u2265 \u2225f z\u2225 - \u2225f z - f x\u2225 : norm_sub_norm_le _ _\n        ... \u2265 \u2225f z\u2225 - \u03b5' : begin simp, apply le_of_lt, exact h, end\n        ... \u2265 \u2225f z\u2225 - \u2225f z\u2225 / 2 : begin simp, apply le_of_eq, rw \u2190 norm_eq_abs, end\n        ... = \u2225f z\u2225 / 2 : by linarith\n        ... > 0 : h\u03b5',\n      rw [norm_pos_iff] at key,\n      exact key,\n    },\nend\n\nlemma is_open_nonvanishing_of_continuous\n(f : \u2102 \u2192 \u2102)\n(U : set \u2102) {hU : is_open U}\n{hf : \u2200 (z : \u2102), z \u2208 U \u2192 continuous_at f z} : \nis_open {z : \u2102 | z \u2208 U \u2227 \u00ac f z = 0} :=\nbegin\n  rw metric.is_open_iff at *,\n  dsimp,\n  intros z hz,\n  rcases hz with \u27e8hz\u2081, hz\u2082\u27e9,\n  specialize hU z hz\u2081,\n  specialize hf z hz\u2081,\n  rcases hU with \u27e8\u03b4, h\u03b4\u2081, h\u03b4\u2082\u27e9,\n  rcases nonvanishing_disk_of_continuous f z with \u27e8\u03b5, h\u03b5\u2081, h\u03b5\u2082\u27e9,\n  assumption',\n  use min \u03b4 \u03b5,\n  split,\n  simp at h\u03b4\u2081,\n  exact lt_min h\u03b4\u2081 h\u03b5\u2081,\n  rw subset_def,\n  dsimp,\n  intros x hx,\n  have key\u2081 : x \u2208 U := h\u03b4\u2082 ((ball_subset_ball $ min_le_left \u03b4 \u03b5) hx),\n  have key\u2082 : \u00ac f x = 0 := h\u03b5\u2082 x ((ball_subset_ball $ min_le_right \u03b4 \u03b5) hx),\n  exact \u27e8key\u2081, key\u2082\u27e9,\nend\n\nlemma isolated_zeros_of_nonvanishing\n(\u03b5 : \u211d) {h\u03b5 : \u03b5 > 0}\n(f : \u2102 \u2192 \u2102)\n(w : \u2102)\n{hf\u2081 : \u2203 (z : \u2102), z \u2208 ball w \u03b5 \u2227 \u00acf z = 0} \n{hf\u2082 : \u2200 (z : \u2102), z \u2208 ball w \u03b5  \u2192 analytic_at \u2102 f z}:\n\u2203 (r : \u211d),\nr \u2264 \u03b5 \u2227 0 < r \u2227\n\u2200 (x : \u2102), x \u2208 ball w r \u2192 \u00ac x - w = 0 \u2192 \u00ac 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 \u03b5 f w with \u27e8k, r, g, H\u27e9,\n    rcases H with \u27e8H\u2081, H\u2082, H\u2083, H\u2084\u27e9,\n    use r,\n    split,\n    exact H\u2082,\n    {\n      split,\n      exact H\u2083,\n      {\n        intros x hx\u2081 hx\u2082,\n        by_contra h',\n        specialize H\u2084 x hx\u2081,\n        rcases H\u2084 with \u27e8h\u2082\u2081, h\u2082\u2082, h\u2082\u2083\u27e9,\n        rw h\u2082\u2081 at h',\n        have key : (x - w) ^ k = 0 \u2228 g x = 0 := eq_zero_or_eq_zero_of_mul_eq_zero h',\n        cases key with key\u2081 key\u2082,\n        {\n          rw [\u2190 complex.cpow_nat_cast, complex.cpow_eq_zero_iff] at key\u2081,\n          exact hx\u2082 key\u2081.1,\n        },\n        {\n          exact h\u2082\u2082 key\u2082,\n        },\n      },\n    },\n    assumption',\n  },\n  -- the case where f w \u2260 0; use the continuity of f at w\n  {\n    specialize hf\u2082 w (mem_ball_self h\u03b5),\n    rcases nonvanishing_disk_of_continuous f w with \u27e8r, hr\u27e9,\n    assumption',\n    use min r \u03b5,\n    split,\n    exact min_le_right _ _,\n    split,\n    {\n      simp,\n      exact \u27e8hr.1, h\u03b5\u27e9,\n    },\n    {\n      intros x hx\u2081 hx\u2082,\n      rw [mem_ball'] at hx\u2081,\n      have key : dist w x < r := lt_of_lt_of_le hx\u2081 (min_le_left _ _),\n      rw [\u2190 mem_ball'] at key,\n      exact hr.2 x key,\n    },\n    exact analytic_at.continuous_at hf\u2082,\n  },\nend\n\ndef is_accumulation_point (U : set \u2102) (z : \u2102) : Prop :=\n\u2200 (V : set \u2102), V \u2208 (\ud835\udcdd z) \u2192 \u2203 (v : \u2102), v \u2208 U \u2229 V \u2227 \u00ac v - z = 0\n\nlemma vanishing_disk_of_accumulation_point\n(U : set \u2102) {hU : is_open U}\n(f : \u2102 \u2192 \u2102) {hf : \u2200 (z : \u2102), z \u2208 U \u2192 analytic_at \u2102 f z}\n(s\u2080 : \u2102) \n{hs\u2080 : is_accumulation_point {s : \u2102 | f s = 0 \u2227 s \u2208 U} s\u2080} \n{hs\u2080' : s\u2080 \u2208 {s : \u2102 | f s = 0 \u2227 s \u2208 U}}:\n\u2203 (\u03b5 : \u211d), 0 < \u03b5 \u2227 ball s\u2080 \u03b5 \u2286 U \u2227\n\u2200 (z : \u2102), z \u2208 ball s\u2080 \u03b5 \u2192 f z = 0 :=\nbegin\n  by_contra w,\n  simp only [not_exists, not_and] at w,\n  dsimp at hs\u2080',\n  rw metric.is_open_iff at hU,\n  specialize hU s\u2080 hs\u2080'.2,\n  rcases hU with \u27e8\u03b5, h\u03b5\u2081, h\u03b5\u2082\u27e9,\n  specialize w \u03b5 h\u03b5\u2081 h\u03b5\u2082,\n  simp only [not_forall] at w,\n  rcases w with \u27e8z, hz\u2081, hz\u2082\u27e9,\n  have hf\u2081 : \u2203 (z : \u2102), z \u2208 ball s\u2080 \u03b5 \u2227 \u00acf z = 0 := \u27e8z, \u27e8hz\u2081, hz\u2082\u27e9\u27e9,\n  have hf\u2082 : \u2200 (x : \u2102), x \u2208 ball s\u2080 \u03b5 \u2192 analytic_at \u2102 f x := \u03bb x hx, hf x $ h\u03b5\u2082 hx,\n  rcases isolated_zeros_of_nonvanishing \u03b5 f s\u2080 with \u27e8r, hr\u2081, hr\u2082, hr\u2083\u27e9,\n  assumption',\n  have : \u2203 (v : \u2102), v \u2208 {s : \u2102 | f s = 0 \u2227 s \u2208 U} \u2229 (ball s\u2080 r) \u2227 \u00ac v - s\u2080 = 0 := \n    hs\u2080 (ball s\u2080 r) (ball_mem_nhds s\u2080 hr\u2082),\n  rcases this with \u27e8v, hv\u2081, hv\u2082\u27e9,\n  dsimp at hv\u2081,\n  show false, from (hr\u2083 v hv\u2081.2 hv\u2082) hv\u2081.1.1,\nend\n\ntheorem vanishing_if_zeros_accumulate\n(U : set \u2102) {hU\u2081 : is_open U} {hU\u2082 : is_connected U}\n(f : \u2102 \u2192 \u2102) {hf : \u2200 (z : \u2102), z \u2208 U \u2192 analytic_at \u2102 f z}\n(s\u2080 : \u2102)\n{hs\u2080 : is_accumulation_point {s : \u2102 | f s = 0 \u2227 s \u2208 U} s\u2080} \n{hs\u2080' : s\u2080 \u2208 {s : \u2102 | f s = 0 \u2227 s \u2208 U}}:\n\u2200 (z : \u2102), z \u2208 U \u2192 f z = 0:=\nbegin\n  let U\u2081 : set \u2102 := {z : \u2102 | z \u2208 U \u2227 \u2203 (r : \u211d), 0 < r \u2227 ball z r \u2286 U \u2227 \u2200 (x : \u2102), x \u2208 ball z r \u2192 f x = 0},\n  let U\u2082 : set \u2102 := {z : \u2102 | z \u2208 U \u2227 \u2203 (k : \u2115), \u00ac iterated_deriv k f z = 0},\n  have h\u2081 : U\u2081 \u222a U\u2082 = U :=\n  begin\n    ext,\n    split,\n    {\n      intro h,\n      dsimp at h,\n      cases h with H\u2081 H\u2082,\n      exact H\u2081.1,\n      exact H\u2082.1,\n    },\n    {\n      intro H,\n      by_cases (x \u2208 U\u2082),\n      exact (mem_union_right U\u2081) h,\n      {\n        by_cases h' : f x = 0,\n        {\n          have key : is_accumulation_point {s : \u2102 | f s = 0 \u2227 s \u2208 U} x \u2227 x \u2208 {s : \u2102 | f s = 0 \u2227 s \u2208 U}:=\n          begin\n            by_contradiction w,\n            rw not_and_distrib at w,\n            cases w with w\u2081 w\u2082,\n            {\n              -- sorry,\n              unfold is_accumulation_point at w\u2081,\n              simp at w\u2081,\n              rcases w\u2081 with \u27e8U', hU\u2081', hU\u2082'\u27e9,\n              rw metric.mem_nhds_iff at hU\u2081',\n              rcases hU\u2081' with \u27e8r, hr\u2081, hr\u2082\u27e9,\n              let U'' : set \u2102 := ball x r \u2229 U,\n              have key\u2081 : is_open U'' := is_open.inter metric.is_open_ball hU\u2081,\n              rw metric.is_open_iff at key\u2081,\n              specialize key\u2081 x (mem_inter (mem_ball_self hr\u2081) H),\n              rcases key\u2081 with \u27e8\u03b5, h\u03b5\u2081, h\u03b5\u2082\u27e9,\n              let x' : \u2102 := x + \u03b5 / 2,\n              have key\u2082 : x' \u2208 ball x \u03b5 := \n              begin \n                simp,\n                have : 0 \u2264 \u03b5 / 2 := by linarith,\n                exact calc dist x' x = \u2225(x + \u03b5 / 2) - x\u2225 : by rw dist_eq_norm\n                  ... = complex.abs \u2191(\u03b5 / 2) : by simp\n                  ... = \u03b5 / 2 : by rw complex.abs_of_nonneg this\n                  ... < \u03b5 : by linarith,\n              end,\n              have key\u2083 : \u00ac f x' = 0 :=\n              begin\n                by_contra w',\n                have : x' \u2208 U'' := h\u03b5\u2082 key\u2082,\n                simp only [mem_inter_eq] at this,\n                specialize hU\u2082' x' w' this.2 (hr\u2082 this.1),\n                have key : \u00ac x' - x = 0 := begin\n                  simp,\n                  exact ne_of_gt h\u03b5\u2081,\n                end,\n                show false, from key hU\u2082',\n              end,\n              have : \u2203 (\u03b5 : \u211d), \u03b5 > 0 \u2227 (\u2200 (z : \u2102), z \u2208 ball x \u03b5 \u2192 analytic_at \u2102 f z) \u2227 \u2203 (z : \u2102), z \u2208 ball x \u03b5 \u2227 \u00acf z = 0 :=\n              begin\n                use \u03b5,\n                split,\n                exact h\u03b5\u2081,\n                split,\n                intros z hz, \n                exact hf z (mem_of_mem_inter_right (h\u03b5\u2082 hz)),\n                exact \u27e8x', \u27e8key\u2082, key\u2083\u27e9\u27e9,\n              end,\n              have key\u2084 : x \u2208 U\u2082 :=\n              begin\n                dsimp,\n                split,\n                exact H,\n                rcases iff.elim_right (nonvanishing_iter_deriv_of_nonvanishing f x) this with \u27e8k, hk\u27e9,\n                use k,\n                exact hf x H,\n              end, \n              show false, from h key\u2084,\n            },\n            {\n              simp at w\u2082,\n              show false, from (w\u2082 h') H,\n            },\n          end,\n          rcases vanishing_disk_of_accumulation_point U f x with \u27e8\u03b5, h\u03b5\u2081, h\u03b5\u2082, h\u03b5\u2083\u27e9,\n          assumption',\n          have : x \u2208 U\u2081 :=\n          begin\n            dsimp [U\u2081],\n            split,\n            exact H,\n            {\n              use \u03b5,\n              exact \u27e8h\u03b5\u2081, \u27e8h\u03b5\u2082, h\u03b5\u2083\u27e9\u27e9,\n            },\n          end,\n          exact (mem_union_left U\u2082) this,\n          exact key.1,\n          exact key.2,\n        },\n        {\n          have key\u2081 : \u2203 (k : \u2115), \u00ac iterated_deriv k f x = 0 := by use 0,\n          have key\u2082 : x \u2208 U\u2082 := begin\n            simp,\n            exact \u27e8H, key\u2081\u27e9,\n          end,\n          exfalso,\n          exact h key\u2082,\n        },\n      },\n    },  \n  end,\n  have h\u2082 : U\u2081 \u2229 U\u2082 = \u2205 :=\n  begin\n    by_contra,\n    rw [\u2190 ne.def, ne_empty_iff_nonempty, nonempty_def] at h,\n    rcases h with \u27e8x, hx\u27e9,\n    dsimp at hx,\n    rcases iff.elim_left (nonvanishing_iter_deriv_of_nonvanishing f x) hx.2.2 with \u27e8\u03b5, h\u03b5\u2081, h\u03b5\u2082, h\u03b5\u2083\u27e9,\n    rcases isolated_zeros_of_nonvanishing \u03b5 f x with \u27e8r, hr\u2081, hr\u2082, hr\u2083\u27e9,\n    assumption',\n    swap,\n    exact hf x hx.1.1,\n    rcases hx.1.2 with \u27e8r', hr\u2081', hr\u2082', hr\u2083'\u27e9,\n    let r'' : \u211d := min r r',\n    have minor\u2081 : 0 < r'' := \n    begin\n      rw lt_min_iff,\n      exact \u27e8hr\u2082, gt.lt hr\u2081'\u27e9,\n    end,\n    have minor\u2082 : \u2203 (x' : \u2102), x' \u2208 ball x r'' \u2227 \u00ac x' - x = 0 := \n    begin\n      let x' : \u2102 := x + r'' / 2,\n      use x',\n      split,\n      simp only [metric.mem_ball],\n      have : 0 \u2264 r'' / 2 := by linarith,\n      exact calc dist x' x = \u2225(x + r'' / 2) - x\u2225 : by rw dist_eq_norm\n        ... = complex.abs \u2191(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\u2081,\n    end,\n    rcases minor\u2082 with \u27e8x', hx\u2081', hx\u2082'\u27e9,\n    have key\u2081 : f x' = 0 := hr\u2083' x' ((ball_subset_ball (min_le_right r r')) hx\u2081'),\n    have key\u2082 : \u00ac f x' = 0 := hr\u2083 x' ((ball_subset_ball (min_le_left r r')) hx\u2081') hx\u2082',\n    show false, from key\u2082 key\u2081,\n  end,\n  have h\u2083 : is_open U\u2081 :=\n  begin\n    rw metric.is_open_iff,\n    intros x hx,\n    dsimp at hx,\n    rcases hx with \u27e8hx\u2081, \u03b5, h\u03b5\u2081, h\u03b5\u2082, h\u03b5\u2083\u27e9,\n    use \u03b5,\n    split,\n    exact h\u03b5\u2081,\n    intros z hz,\n    dsimp,\n    split,\n    exact h\u03b5\u2082 hz,\n    have : \u2203 (r : \u211d), (0 < r \u2227 ball z r \u2286 U) \u2227 ball z r \u2286 ball x \u03b5 :=\n    begin\n      have key : is_open (ball x \u03b5) := is_open_ball,\n      rw metric.is_open_iff at key,\n      specialize key z hz,\n      rcases key with \u27e8r, hr\u2081, hr\u2082\u27e9,\n      use r,\n      split,\n      exact \u27e8hr\u2081, subset.trans hr\u2082 h\u03b5\u2082\u27e9,\n      exact hr\u2082,\n    end,\n    rcases this with \u27e8r, hr\u2081, hr\u2082\u27e9,\n    use r,\n    split,\n    exact hr\u2081.1,\n    split,\n    exact hr\u2081.2,\n    intros x' hx',\n    exact h\u03b5\u2083 x' (hr\u2082 hx'),\n  end,\n  have h\u2084 : is_open U\u2082 :=\n  begin\n    sorry,   \n  end,\n  have h\u2085 : U\u2081.nonempty :=\n  begin\n    rw nonempty_def,\n    use s\u2080,\n    dsimp,\n    simp at hs\u2080',\n    split,\n    exact hs\u2080'.2,\n    rcases vanishing_disk_of_accumulation_point U f s\u2080 with \u27e8\u03b5, h\u03b5\u2081, h\u03b5\u2082, h\u03b5\u2083\u27e9,\n    assumption',\n    use \u03b5,\n    exact \u27e8h\u03b5\u2081, \u27e8h\u03b5\u2082, h\u03b5\u2083\u27e9\u27e9,\n  end,\n  have hfinal : U\u2081 = U :=\n  begin\n    have : is_preconnected U := is_connected.is_preconnected hU\u2082,\n    rw is_preconnected_iff_subset_of_disjoint at this,\n    specialize this U\u2081 U\u2082 h\u2083 h\u2084 (eq.subset (eq.symm h\u2081)),\n    have minor : U \u2229 (U\u2081 \u2229 U\u2082) = \u2205 := \n    begin\n      rw h\u2082,\n      simp,\n    end,\n    specialize this minor,\n    cases this,\n    {\n      have minor' : U\u2081 \u2286 U :=\n      begin\n        let h := set.subset_union_left U\u2081 U\u2082,\n        rw h\u2081 at h,\n        exact h,\n      end,\n      exact has_subset.subset.antisymm minor' this,\n    },\n    {\n      have minor\u2081 : U\u2081 \u2286 U :=\n      begin\n        let h := set.subset_union_left U\u2081 U\u2082,\n        rw h\u2081 at h,\n        exact h,\n      end,\n      have minor\u2082 : U\u2082 \u2286 U :=\n      begin\n        let h := set.subset_union_right U\u2081 U\u2082,\n        rw h\u2081 at h,\n        exact h,\n      end,\n      have minor\u2083 : U\u2082 = U := has_subset.subset.antisymm minor\u2082 this,\n      have key : U\u2081 = \u2205 :=\n      begin\n        rw [inter_comm, \u2190 set.subset_empty_iff, \u2190 set.diff_eq_self] at h\u2082,\n        rw \u2190 h\u2082,\n        by_contra w,\n        rw [\u2190 ne.def, set.ne_empty_iff_nonempty, set.nonempty_diff, minor\u2083] at w,\n        show false, from w minor\u2081,\n      end,\n      rw [\u2190 set.not_nonempty_iff_eq_empty] at key,\n      exfalso,\n      exact key h\u2085,\n    },\n  end,\n  intros z hz,\n  have : z \u2208 U\u2081 := (eq.subset (eq.symm hfinal)) hz,\n  dsimp at this,\n  rcases this.2 with \u27e8r, hr\u2081, hr\u2082, hr\u2083\u27e9,\n  specialize hr\u2083 z (mem_ball_self hr\u2081),\n  exact hr\u2083,\nend\n\ntheorem eq_if_eq_points_accumulate\n(U : set \u2102) {hU\u2081 : is_open U} {hU\u2082 : is_connected U}\n(f : \u2102 \u2192 \u2102) {hf : \u2200 (z : \u2102), z \u2208 U \u2192 analytic_at \u2102 f z}\n(g : \u2102 \u2192 \u2102) {hg : \u2200 (z : \u2102), z \u2208 U \u2192 analytic_at \u2102 g z}\n(s\u2080 : \u2102)\n{hs\u2080 : is_accumulation_point {s : \u2102 | f s = g s \u2227 s \u2208 U} s\u2080} \n{hs\u2080' : s\u2080 \u2208 {s : \u2102 | f s = g s \u2227 s \u2208 U}} :\n\u2200 (z : \u2102), z \u2208 U \u2192 f z = g z :=\nbegin\n  let h : \u2102 \u2192 \u2102 := f - g,\n  have minor : \u2200 (z : \u2102), z \u2208 U \u2192 analytic_at \u2102 h z := \u03bb z hz, analytic_at.sub (hf z hz) $ hg z hz,\n  have key : {s : \u2102 | f s = g s \u2227 s \u2208 U} = {s : \u2102 | h s = 0 \u2227 s \u2208 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 \u2190 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\u2080 hs\u2080',\n  intros z hz,\n  have : h z = 0 := vanishing_if_zeros_accumulate U h s\u2080 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 \u2192 Type _} {C : \u03a0a, B a \u2192 Type _} {D : \u03a0a b, C a b \u2192 Type _}\n          {E : \u03a0a b c, D a b c \u2192 Type _} {F : \u03a0a b c d, E a b c d \u2192 Type _}\n          {G : \u03a0a b c d e, F a b c d e \u2192 Type _} {H : \u03a0a b c d e f, G a b c d e f \u2192 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\u2080i\u2081...i\u2099.\n      Here i\u2080, ... i\u2099 are digits, n is the arity of the function(s),\n        and i\u2c7c specifies the dimension of the path between the j\u1d57\u02b0 argument\n        (i\u2080 specifies the dimension of the path between the functions).\n      A value i\u2c7c \u2261 0 means that the j\u1d57\u02b0 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\u2080i\u2081...i\u2099.\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 : \u03a0a b, C a b)         : Type _ :=\n  \u03a0a b, f a b = g a b\n  @[hott, reducible] def homotopy3 (f g : \u03a0a b c, D a b c)     : Type _ :=\n  \u03a0a b c, f a b c = g a b c\n  @[hott, reducible] def homotopy4 (f g : \u03a0a b c d, E a b c d) : Type _ :=\n  \u03a0a 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 : \u03a0 a b, C a b) : f ~2 f := by intros _ _; refl\n  @[refl] def homotopy3.refl (f : \u03a0 a b c, D a b c) : f ~3 f := by intros _ _ _; refl\n  @[refl] def homotopy4.refl (f : \u03a0 a b c d, E a b c d) : f ~4 f := by intros _ _ _ _; refl\n\n  @[hott] def ap0111 (f : U \u2192 V \u2192 W \u2192 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 \u2192 V \u2192 W \u2192 X \u2192 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 \u2192 V \u2192 W \u2192 X \u2192 Y \u2192 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 \u2192 V \u2192 W \u2192 X \u2192 Y \u2192 Z \u2192 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 \u2192 \u03a0a, B a) (Hx : x = x') : f x ~ f x' :=\n  \u03bb b, ap (\u03bba, f a b) Hx\n\n  @[hott] def ap0100 (f : X \u2192 \u03a0a 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 \u2192 \u03a0a 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 : \u03a0a, B a \u2192 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 : \u03a0a b, C a b \u2192 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 \u2192 Y \u2192 Type _} {r : R x y} {r' : R x' y'} (f : \u03a0x y, R x y \u2192 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 : \u03a0a b c, D a b c \u2192 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 : \u03a0a b c d, E a b c d \u2192 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 : \u03a0a b c d e, F a b c d e \u2192 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 : \u03a0a b c d e ff, G a b c d e ff \u2192 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 : \u03a0a b c d e ff g, G a b c d e ff g \u2192 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 : \u03a0a b, C a b} (p : f = g) : f ~2 g :=\n  \u03bba b, apd10 (apd10 p a) b\n\n  @[hott] def apd1000 {f g : \u03a0a b c, D a b c} (p : f = g) : f ~3 g :=\n  \u03bba 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 \u2192 \u03a0a, B a) (p : x = x') (q : x' = x'') :\n    ap010 f (p \u2b1d q) a = ap010 f p a \u2b1d ap010 f q a :=\n  eq.rec_on q (eq.rec_on p idp)\n\n  @[hott] def ap010_ap (f : X \u2192 \u03a0a, B a) (g : Y \u2192 X) (p : y = y') :\n    ap010 f (ap g p) a = (ap010 (f \u2218 g) p) a :=\n  eq.rec_on p idp\n\n  @[hott] def ap_eq_ap010 {A B C : Type _} (f : A \u2192 B \u2192 C) {a a' : A} (p : a = a') (b : B) :\n    ap (\u03bba, f a b) p = ap010 f p b :=\n  idp\n\n  @[hott] def ap011_idp {A B C : Type _} (f : A \u2192 B \u2192 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 \u2192 B \u2192 C) {a a' : A} {b b' : B} (p : a = a') (q : b = b') :\n    ap011 f p q = (ap011 (\u03bbb 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 : \u03a0a b, C a b} (H : f ~2 g) : f = g :=\n  eq_of_homotopy (\u03bba, eq_of_homotopy (H a))\n\n  @[hott] def eq_of_homotopy3 {f g : \u03a0a b c, D a b c} (H : f ~3 g) : f = g :=\n  eq_of_homotopy (\u03bba, eq_of_homotopy2 (H a))\n\n  @[hott] def eq_of_homotopy2_id (f : \u03a0a b, C a b)\n    : eq_of_homotopy2 (\u03bba b, idpath (f a b)) = idpath f :=\n  begin\n    transitivity eq_of_homotopy (\u03bb 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 : \u03a0a b c, D a b c)\n    : eq_of_homotopy3 (\u03bba 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 : \u03a0a b, C a b} (H : f ~2 g)\n    : eq_of_homotopy2 (\u03bba b, (H a b).inverse) = (eq_of_homotopy2 H)\u207b\u00b9 :=\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 : \u03a0a b c, D a b c} (H : f ~3 g)\n    : eq_of_homotopy3 (\u03bba b c, (H a b c).inverse) = (eq_of_homotopy3 H)\u207b\u00b9 :=\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 : \u03a0a b, C a b} (H1 : f ~2 g) (H2 : g ~2 h)\n    : eq_of_homotopy2 (\u03bba b, H1 a b \u2b1d H2 a b) = eq_of_homotopy2 H1 \u2b1d 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 : \u03a0a b c, D a b c} (H1 : f ~3 g) (H2 : g ~3 h)\n    : eq_of_homotopy3 (\u03bba b c, H1 a b c \u2b1d H2 a b c) = eq_of_homotopy3 H1 \u2b1d 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 : \u03a0a 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 (\u03bbx : \u03a0 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 : \u03a0a 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 (\u03bb x : \u03a0 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 : \u03a0a b, C a b} {P : (f ~2 g) \u2192 Type _}\n    (p : f ~2 g) (H : \u03a0(q : f = g), P (apd100 q)) : P p :=\n  right_inv apd100 p \u25b8 H (eq_of_homotopy2 p)\n\n  @[hott] protected def homotopy3.rec_on {f g : \u03a0a b c, D a b c} {P : (f ~3 g) \u2192 Type _}\n    (p : f ~3 g) (H : \u03a0(q : f = g), P (apd1000 q)) : P p :=\n  right_inv apd1000 p \u25b8 H (eq_of_homotopy3 p)\n\n  @[hott] def eq_equiv_homotopy2 (f g : \u03a0a b, C a b) : (f = g) \u2243 (f ~2 g) :=\n  equiv.mk apd100 (by apply_instance)\n\n  @[hott] def eq_equiv_homotopy3 (f g : \u03a0a b c, D a b c) : (f = g) \u2243 (f ~3 g) :=\n  equiv.mk apd1000 (by apply_instance)\n\n  @[hott] def apd10_ap (f : X \u2192 \u03a0a, 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 \u2192 \u03a0a, B a) (p : x = x')\n    : eq_of_homotopy (ap010 f p) = ap f p :=\n  inv_eq_of_eq (apd10_ap _ _)\u207b\u00b9\n\n  @[hott] def ap_eq_ap_of_homotopy {f : X \u2192 \u03a0a, 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 := \u2203 S : finset M, closure L \u2191S = N\n\ntheorem fg_def {N : L.substructure M} :\n  N.fg \u2194 \u2203 S : set M, S.finite \u2227 closure L S = N :=\n\u27e8\u03bb \u27e8t, h\u27e9, \u27e8_, finset.finite_to_set t, h\u27e9, begin\n  rintro \u27e8t', h, rfl\u27e9,\n  rcases finite.exists_finset_coe h with \u27e8t, rfl\u27e9,\n  exact \u27e8t, rfl\u27e9\nend\u27e9\n\nlemma fg_iff_exists_fin_generating_family {N : L.substructure M} :\n  N.fg \u2194 \u2203 (n : \u2115) (s : fin n \u2192 M), closure L (range s) = N :=\nbegin\n  rw fg_def,\n  split,\n  { rintros \u27e8S, Sfin, hS\u27e9,\n    obtain \u27e8n, f, rfl\u27e9 := Sfin.fin_embedding,\n    exact \u27e8n, f, hS\u27e9, },\n  { rintros \u27e8n, s, hs\u27e9,\n    refine \u27e8range s, finite_range s, hs\u27e9 },\nend\n\ntheorem fg_bot : (\u22a5 : L.substructure M).fg :=\n\u27e8\u2205, by rw [finset.coe_empty, closure_empty]\u27e9\n\ntheorem fg_closure {s : set M} (hs : s.finite) : fg (closure L s) :=\n\u27e8hs.to_finset, by rw [hs.coe_to_finset]\u27e9\n\ntheorem fg_closure_singleton (x : M) : fg (closure L ({x} : set M)) :=\nfg_closure (finite_singleton x)\n\ntheorem fg.sup {N\u2081 N\u2082 : L.substructure M}\n  (hN\u2081 : N\u2081.fg) (hN\u2082 : N\u2082.fg) : (N\u2081 \u2294 N\u2082).fg :=\nlet \u27e8t\u2081, ht\u2081\u27e9 := fg_def.1 hN\u2081, \u27e8t\u2082, ht\u2082\u27e9 := fg_def.1 hN\u2082 in\nfg_def.2 \u27e8t\u2081 \u222a t\u2082, ht\u2081.1.union ht\u2082.1, by rw [closure_union, ht\u2081.2, ht\u2082.2]\u27e9\n\ntheorem fg.map {N : Type*} [L.Structure N] (f : M \u2192[L] N) {s : L.substructure M} (hs : s.fg) :\n  (s.map f).fg :=\nlet \u27e8t, ht\u27e9 := fg_def.1 hs in fg_def.2 \u27e8f '' t, ht.1.image _, by rw [closure_image, ht.2]\u27e9\n\ntheorem fg.of_map_embedding {N : Type*} [L.Structure N] (f : M \u21aa[L] N) {s : L.substructure M}\n  (hs : (s.map f.to_hom).fg) : s.fg :=\nbegin\n  rcases hs with \u27e8t, h\u27e9,\n  rw fg_def,\n  refine \u27e8f \u207b\u00b9' t, t.finite_to_set.preimage (f.injective.inj_on _), _\u27e9,\n  have hf : function.injective f.to_hom := f.injective,\n  refine map_injective_of_injective hf _,\n  rw [\u2190 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 := \u2203 S : set M, S.countable \u2227 closure L S = N\n\n\n\ntheorem fg.cg {N : L.substructure M} (h : N.fg) : N.cg :=\nbegin\n  obtain \u27e8s, hf, rfl\u27e9 := fg_def.1 h,\n  refine \u27e8s, hf.countable, rfl\u27e9,\nend\n\nlemma cg_iff_empty_or_exists_nat_generating_family {N : L.substructure M} :\n  N.cg \u2194 (\u2191N = (\u2205 : set M)) \u2228 \u2203 (s : \u2115 \u2192 M), closure L (range s) = N :=\nbegin\n  rw cg_def,\n  split,\n  { rintros \u27e8S, Scount, hS\u27e9,\n    cases eq_empty_or_nonempty \u2191N with h h,\n    { exact or.intro_left _ h },\n    obtain \u27e8f, h'\u27e9 := (Scount.union (set.countable_singleton h.some)).exists_eq_range\n      (singleton_nonempty h.some).inr,\n    refine or.intro_right _ \u27e8f, _\u27e9,\n    rw [\u2190 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 \u27e8\u2205, countable_empty, closure_eq_of_le (empty_subset _) _\u27e9,\n      rw [\u2190 set_like.coe_subset_coe, h],\n      exact empty_subset _ },\n    { obtain \u27e8f, rfl\u27e9 := h,\n      exact \u27e8range f, countable_range _, rfl\u27e9 } },\nend\n\ntheorem cg_bot : (\u22a5 : L.substructure M).cg := fg_bot.cg\n\ntheorem cg_closure {s : set M} (hs : s.countable) : cg (closure L s) :=\n\u27e8s, hs, rfl\u27e9\n\ntheorem cg_closure_singleton (x : M) : cg (closure L ({x} : set M)) := (fg_closure_singleton x).cg\n\ntheorem cg.sup {N\u2081 N\u2082 : L.substructure M}\n  (hN\u2081 : N\u2081.cg) (hN\u2082 : N\u2082.cg) : (N\u2081 \u2294 N\u2082).cg :=\nlet \u27e8t\u2081, ht\u2081\u27e9 := cg_def.1 hN\u2081, \u27e8t\u2082, ht\u2082\u27e9 := cg_def.1 hN\u2082 in\ncg_def.2 \u27e8t\u2081 \u222a t\u2082, ht\u2081.1.union ht\u2082.1, by rw [closure_union, ht\u2081.2, ht\u2082.2]\u27e9\n\ntheorem cg.map {N : Type*} [L.Structure N] (f : M \u2192[L] N) {s : L.substructure M} (hs : s.cg) :\n  (s.map f).cg :=\nlet \u27e8t, ht\u27e9 := cg_def.1 hs in cg_def.2 \u27e8f '' t, ht.1.image _, by rw [closure_image, ht.2]\u27e9\n\ntheorem cg.of_map_embedding {N : Type*} [L.Structure N] (f : M \u21aa[L] N) {s : L.substructure M}\n  (hs : (s.map f.to_hom).cg) : s.cg :=\nbegin\n  rcases hs with \u27e8t, h1, h2\u27e9,\n  rw cg_def,\n  refine \u27e8f \u207b\u00b9' t, h1.preimage f.injective, _\u27e9,\n  have hf : function.injective f.to_hom := f.injective,\n  refine map_injective_of_injective hf _,\n  rw [\u2190 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 (\u03a3l, L.functions l)] {s : L.substructure M} :\n  s.cg \u2194 countable s :=\nbegin\n  refine \u27e8_, \u03bb h, \u27e8s, h.to_set, s.closure_eq\u27e9\u27e9,\n  rintro \u27e8s, h, rfl\u27e9,\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 : (\u22a4 : L.substructure M).fg)\n\n/-- A structure is countably generated if it is the closure of a countable subset. -/\nclass cg : Prop := (out : (\u22a4 : L.substructure M).cg)\n\nvariables {L M}\n\nlemma fg_def : fg L M \u2194 (\u22a4 : L.substructure M).fg := \u27e8\u03bb h, h.1, \u03bb h, \u27e8h\u27e9\u27e9\n\n/-- An equivalent expression of `Structure.fg` in terms of `set.finite` instead of `finset`. -/\nlemma fg_iff : fg L M \u2194 \u2203 S : set M, S.finite \u2227 closure L S = (\u22a4 : 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 \u2192[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 \u2192[L] N)\n  (hs : function.surjective f) :\n  fg L N :=\nbegin\n  rw \u2190 hom.range_eq_top at hs,\n  rw [fg_def, \u2190 hs],\n  exact h.range f,\nend\n\n\n\n/-- An equivalent expression of `Structure.cg`. -/\nlemma cg_iff : cg L M \u2194 \u2203 S : set M, S.countable \u2227 closure L S = (\u22a4 : 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 \u2192[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 \u2192[L] N)\n  (hs : function.surjective f) :\n  cg L N :=\nbegin\n  rw \u2190 hom.range_eq_top at hs,\n  rw [cg_def, \u2190 hs],\n  exact h.range f,\nend\n\nlemma cg_iff_countable [countable (\u03a3l, L.functions l)] : cg L M \u2194 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 \u2243[L] N) :\n  Structure.fg L M \u2194 Structure.fg L N :=\n\u27e8\u03bb h, h.map_of_surjective f.to_hom f.to_equiv.surjective,\n  \u03bb h, h.map_of_surjective f.symm.to_hom f.to_equiv.symm.surjective\u27e9\n\nlemma substructure.fg_iff_Structure_fg (S : L.substructure M) :\n  S.fg \u2194 Structure.fg L S :=\nbegin\n  rw Structure.fg_def,\n  refine \u27e8\u03bb h, fg.of_map_embedding S.subtype _, \u03bb h, _\u27e9,\n  { rw [\u2190 hom.range_eq_map, range_subtype],\n    exact h },\n  { have h := h.map S.subtype.to_hom,\n    rw [\u2190 hom.range_eq_map, range_subtype] at h,\n    exact h }\nend\n\nlemma equiv.cg_iff {N : Type*} [L.Structure N] (f : M \u2243[L] N) :\n  Structure.cg L M \u2194 Structure.cg L N :=\n\u27e8\u03bb h, h.map_of_surjective f.to_hom f.to_equiv.surjective,\n  \u03bb h, h.map_of_surjective f.symm.to_hom f.to_equiv.symm.surjective\u27e9\n\nlemma substructure.cg_iff_Structure_cg (S : L.substructure M) :\n  S.cg \u2194 Structure.cg L S :=\nbegin\n  rw Structure.cg_def,\n  refine \u27e8\u03bb h, cg.of_map_embedding S.subtype _, \u03bb h, _\u27e9,\n  { rw [\u2190 hom.range_eq_map, range_subtype],\n    exact h },\n  { have h := h.map S.subtype.to_hom,\n    rw [\u2190 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Johannes H\u00f6lzl (CMU)\n-/\n\nnamespace name\n\ndef last_string : name \u2192 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 $ \u03bbc d, if c = s then some (s'.lift_vars 0 d) else none\n\nmeta def local_binder_info : expr \u2192 binder_info\n| (local_const x n bi t) := bi\n| e                      := binder_info.default\n\nmeta def to_implicit_binder : expr \u2192 expr\n| (local_const n\u2081 n\u2082 _ d) := local_const n\u2081 n\u2082 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 \u2192 expr \u2192 expr \u00d7 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 \u2192 expr \u00d7 list expr :=\nget_app_fn_args_aux []\n\nend expr\n\nnamespace tactic\nopen level expr tactic\n\nmeta def mk_local_pisn : expr \u2192 nat \u2192 tactic (list expr \u00d7 expr)\n| (pi n bi d b) (c + 1) := do\n  p \u2190 mk_local' n bi d,\n  (ps, r) \u2190 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 \u2192 expr \u2192 tactic expr\n| (list.cons v vs) (pi n bi d b) := do\n  t \u2190 infer_type v,\n  guard (t =\u2090 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) \u2190 solve_aux type tac,\n  body \u2190 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 (\u03bbarg i:expr, do\n    t \u2190 infer_type arg,\n    sort l \u2190 infer_type t,\n    return $ if arg.occurs i \u2228 l \u2260 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 \u2192 expr\n| []        := empty\n| [e]       := e\n| (e :: es) := op e $ mk_op_lst es\n\nmeta def mk_and_lst : list expr \u2192 expr := mk_op_lst `(and) `(true)\n\nmeta def mk_or_lst : list expr \u2192 expr := mk_op_lst `(or) `(false)\n\nmeta def elim_gen_prod : nat \u2192 expr \u2192 list expr \u2192 tactic (list expr \u00d7 expr)\n| 0       e hs := return (hs, e)\n| (n + 1) e hs := do\n  [(_, [h, h'], _)] \u2190 induction e [],\n  elim_gen_prod n h' (hs ++ [h])\n\nprivate meta def elim_gen_sum_aux : nat \u2192 expr \u2192 list expr \u2192 tactic (list expr \u00d7 expr)\n| 0       e hs := return (hs, e)\n| (n + 1) e hs := do\n  [(_, [h], _), (_, [h'], _)] \u2190 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') \u2190 elim_gen_sum_aux n e [],\n  gs \u2190 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 {\u03b1 : Sort u} {p q : \u03b1 \u2192 Prop} (h : \u2200a, implies (p a) (q a)) :\n  implies (\u03a0a, p a) (\u03a0a, q a) :=\nassume h' a, h a (h' a)\n\nlemma monotonicity.imp {p p' q q' : Prop} (h\u2081 : implies p' q') (h\u2082 : implies q p) :\n  implies (p \u2192 p') (q \u2192 q') :=\nassume h, h\u2081 \u2218 h \u2218 h\u2082\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 {\u03b1 : Sort u} {p q : \u03b1 \u2192 Prop} (h : \u2200a, implies (p a) (q a)) :\n  implies (\u2203a, p a) (\u2203a, 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 \u2227 q) (p' \u2227 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 \u2228 q) (p' \u2228 q') :=\nor.imp hp hq\n\n@[monotonicity]\nlemma monotonicity.not {p q : Prop} (h : implies p q) :\n  implies (\u00ac q) (\u00ac 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) \u2190 target,\n    (do is_def_eq p q, eapplyc `monotone.const) <|>\n    (do\n      (expr.pi pn pbi pd pb) \u2190 whnf p,\n      (expr.pi qn qbi qd qb) \u2190 whnf q,\n      sort u \u2190 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 \u2227 is_arrow p \u2227 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 $ \u03bbh, apply_core h {md := transparency.none, new_goals := new_goals.non_dep_only} >> skip) <|>\n  first (ns.map $ \u03bbn, do c \u2190 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 \u2190 target,\n  t' \u2190 infer_type e,\n  ns \u2190 attribute.get_instances `monotonicity,\n  ((), p) \u2190 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 \u2192 Prop\n  | r : \u2200A 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 \u2192 Prop) : a \u2192 Prop\n  | r : \u2200a [f], b[pred/pred'] \u2192 pred.functional a [f] p\n\n  lemma {u} pred.functional.mono (A) ([pred\u2081] [pred\u2082] : a \u2192 Prop) [(h : \u2200b, pred\u2081 b \u2192 pred\u2082 b)] :\n    \u2200p, pred.functional A pred\u2081 p \u2192 pred.functional A pred\u2082 p\n\n  def {u} pred_i (A) (a) : Prop :=\n  \u2203[pred'], (\u039bi, \u2200a, pred_i a \u2192 pred_i.functional A [pred] a) \u2227 pred'_i a\n\n  lemma {u} pred_i.corec_functional (A) [\u039bi, C_i : a_i \u2192 Prop] [\u039bi, h : \u2200a, C_i a \u2192 pred_i.functional A C_i a] :\n    \u2200a, C_i a \u2192 pred_i A a\n\n  lemma {u} pred_i.destruct (A) (a) : pred A a \u2192 pred.functional A [pred A] a\n\n  lemma {u} pred_i.construct (A) : \u2200a, pred_i.functional A [pred A] a \u2192 pred_i A a\n\n  lemma {u} pred_i.cases_on (A) (C : a \u2192 Prop) {a} (h : pred_i a) [\u039bi, \u2200a, b \u2192 C p] \u2192 C a\n\n  lemma {u} pred_i.corec_on (A) [(C : a \u2192 Prop)] (a) (h : C_i a)\n    [\u039bi, h_i : \u2200a, C_i a \u2192 [V j \u2203b, 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\u2081 f\u2082    : 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\u2081_l (pd : coind_pred) : expr :=\npd.f\u2081.app_of_list pd.locals\n\nmeta def f\u2082_l (pd : coind_pred) : expr :=\npd.f\u2082.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\u2081 f\u2082 : expr) : expr :=\n(imp (f\u2081.app_of_list pd.locals) (f\u2082.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  \u2190 get_env,\n   decl \u2190 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 := \u03bb as, \u2203 bs, \u039b_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 \u2192 list (expr \u00d7 expr) \u2192 list expr \u00d7 list (expr \u00d7 expr)\n| [] ps      := ([], ps)\n| (list.cons b bs) ps :=\n  match ps.span (\u03bbap:expr \u00d7 expr, \u00ac ap.2 =\u2090 b) with\n    | (_, [])           := let (bs, ps) := compact_relation bs ps in (b::bs, ps)\n    | (ps\u2081, list.cons (a, _) ps\u2082) := let i := a.instantiate_local b.local_uniq_name in\n      compact_relation (bs.map i) ((ps\u2081 ++ ps\u2082).map (\u03bb\u27e8a, p\u27e9, (a, i p)))\n  end\n\nmeta def add_coinductive_predicate\n  (u_names : list name) (params : list expr) (preds : list $ expr \u00d7 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 \u2190 preds.mmap (\u03bb\u27e8c, is\u27e9, do\n    (ls, t) \u2190 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\u2081 \u2190 mk_local_def (mk_simple_name $ \"C\" ++ n) c.local_type,\n    f\u2082 \u2190 mk_local_def (mk_simple_name $ \"C\u2082\" ++ n) c.local_type,\n    return (ls, (f\u2081, f\u2082))),\n\n  let fs := pre_info.map prod.snd,\n  let fs\u2081 := fs.map prod.fst,\n  let fs\u2082 := fs.map prod.snd,\n\n  pds \u2190 (preds.zip pre_info).mmap (\u03bb\u27e8\u27e8c, is\u27e9, ls, f\u2081, f\u2082\u27e9, do\n    sort u_f \u2190 infer_type f\u2081 >>= infer_type,\n    let pred_g := \u03bbc:expr, (const c.local_uniq_name u_params : expr).app_of_list params,\n    intros \u2190 is.mmap (\u03bbi, do\n      (args, t') \u2190 mk_local_pis i.local_type,\n      (name.mk_string sub p) \u2190 return i.local_uniq_name,\n      let loc_args := args.map $ \u03bbe, (fs\u2081.zip preds).foldl (\u03bb(e:expr) \u27e8f, c, _\u27e9,\n        e.replace_with (pred_g c) f) e,\n      let t' := t'.replace_with (pred_g c) f\u2082,\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\u2081 := f\u2081, f\u2082 := f\u2082, u_f := u_f,\n      intros := intros, locals := ls, params := params, u_names := u_names }),\n\n  /- Introduce all functionals -/\n  pds.mmap' (\u03bbpd:coind_pred, do\n    let func_f\u2081 := pd.func_g.app_of_list $ fs\u2081,\n    let func_f\u2082 := pd.func_g.app_of_list $ fs\u2082,\n\n    /- Define functional for `pd` as inductive predicate -/\n    func_intros \u2190 pd.intros.mmap (\u03bbr:coind_rule, do\n      let t := instantiate_local pd.f\u2082.local_uniq_name (pd.func_g.app_of_list fs\u2081) r.loc_type,\n      return (r.func_nm, r.orig_nm, t.pis $ params ++ fs\u2081)),\n    add_inductive pd.func.const_name u_names\n      (params.length + preds.length) (pd.type.pis $ params ++ fs\u2081) (func_intros.map $ \u03bb\u27e8t, _, r\u27e9, (t, r)),\n\n    /- Prove monotonicity rule -/\n    mono_params \u2190 pds.mmap (\u03bbpd, do\n      h \u2190 mk_local_def `h $ pd.le pd.f\u2081 pd.f\u2082,\n      return [pd.f\u2081, pd.f\u2082, h]),\n    pd.add_theorem (pd.func.const_name ++ \"mono\")\n      ((pd.le func_f\u2081 func_f\u2082).pis $ params ++ mono_params.join)\n      (do\n      ps \u2190 intro_lst $ params.map expr.local_pp_name,\n      fs \u2190 pds.mmap (\u03bbpd, do\n        [f\u2081, f\u2082, h] \u2190 intro_lst [pd.f\u2081.local_pp_name, pd.f\u2082.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\u2081.app_of_list pd.locals) (f\u2082.app_of_list pd.locals)).pis pd.locals).instantiate_locals $\n          (ps.zip params).map $ \u03bb\u27e8lv, p\u27e9, (p.local_uniq_name, lv),\n        return (f\u2082, h')),\n      m \u2190 pd.rec',\n      eapply $ m.app_of_list ps, -- somehow `induction` / `cases` doesn't work?\n      func_intros.mmap' (\u03bb\u27e8n, pp_n, t\u27e9, solve1 $ do\n        bs \u2190 intros,\n        ms \u2190 apply_core ((const n u_params).app_of_list $ ps ++ fs.map prod.fst) {new_goals := new_goals.all},\n        params \u2190 (ms.zip bs).enum.mfilter (\u03bb\u27e8n, m, d\u27e9, bnot <$> is_assigned m.2),\n        params.mmap' (\u03bb\u27e8n, m, d\u27e9, 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' (\u03bbpd, do\n    let func_f := \u03bbpd:coind_pred, pd.func_g.app_of_list $ pds.map coind_pred.f\u2081,\n\n    /- define final predicate -/\n    pred_body \u2190 mk_exists_lst (pds.map coind_pred.f\u2081) $\n      mk_and_lst $ (pds.map $ \u03bbpd, pd.le pd.f\u2081 (func_f pd)) ++ [pd.f\u2081.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 \u2190 pds.mmap $ \u03bbpd:coind_pred, mk_local_def `hc $ pd.le pd.f\u2081 (func_f pd),\n    pd.add_theorem (pd.pred.const_name ++ \"corec_functional\")\n      ((pd.le pd.f\u2081 pd.pred_g).pis $ params ++ fs\u2081 ++ hs)\n      (do\n      intro_lst $ params.map local_pp_name,\n      fs \u2190 intro_lst $ fs\u2081.map local_pp_name,\n      hs \u2190 intro_lst $ hs.map local_pp_name,\n      ls \u2190 intro_lst $ pd.locals.map local_pp_name,\n      h \u2190 intro `h,\n      whnf_target,\n      fs.mmap' existsi,\n      hs.mmap' (\u03bbf, econstructor >> exact f),\n      exact h)),\n\n  let func_f := \u03bbpd : coind_pred, pd.func_g.app_of_list $ pds.map coind_pred.pred_g,\n\n  /- prove `destruct` rules -/\n  pds.enum.mmap' (\u03bb\u27e8n, pd\u27e9, 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 \u2190 intro_lst $ params.map local_pp_name,\n      ls \u2190 intro_lst $ pd.locals.map local_pp_name,\n      h \u2190 intro `h,\n      (fs, h) \u2190 elim_gen_prod pds.length h [],\n      (hs, h) \u2190 elim_gen_prod pds.length h [],\n      eapply $ pd.mono.app_of_list ps,\n      pds.mmap' (\u03bbpd:coind_pred, focus1 $ do\n        eapply $ pd.corec_functional,\n        focus $ hs.map exact),\n      some h' \u2190 return $ hs.nth n,\n      eapply h',\n      exact h)),\n\n  /- prove `construct` rules -/\n  pds.mmap' (\u03bbpd,\n    pd.add_theorem (pd.pred.const_name ++ \"construct\")\n      ((pd.le (func_f pd) pd.pred_g).pis params) (do\n      ps \u2190 intro_lst $ params.map local_pp_name,\n      let func_pred_g := \u03bbpd:coind_pred,\n        pd.func.app_of_list $ ps ++ pds.map (\u03bbpd: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' (\u03bbpd:coind_pred, solve1 $ do\n        eapply $ pd.mono.app_of_list ps,\n        pds.mmap' (\u03bbpd, solve1 $ eapply (pd.destruct.app_of_list ps) >> skip)))),\n\n  /- prove `cases_on` rules -/\n  pds.mmap' (\u03bbpd, do\n    let C := pd.f\u2081.to_implicit_binder,\n    h \u2190 mk_local_def `h $ pd.pred_g.app_of_list pd.locals,\n    rules \u2190 pd.intros.mmap (\u03bbr: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 \u2190 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 \u2190 intro_lst $ params.map local_pp_name,\n        C  \u2190 intro `C,\n        ls \u2190 intro_lst $ pd.locals.map local_pp_name,\n        h  \u2190 intro `h,\n        rules  \u2190 intro_lst $ rules.map local_pp_name,\n        func_rec \u2190 pd.rec',\n        eapply $ func_rec.app_of_list $ ps ++ pds.map (\u03bbpd, 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' (\u03bbpd, do\n    rules \u2190 pds.mmap (\u03bbpd, do\n      intros \u2190 pd.intros.mmap (\u03bbr, do\n        let (bs, eqs) := compact_relation r.loc_args $ pd.locals.zip r.insts,\n        eqs \u2190 eqs.mmap (\u03bb\u27e8l, i\u27e9, do\n          sort u \u2190 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\u2081.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 \u2190 mk_local_def `h $ pd.f\u2081.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\u2081 ++ pd.impl_locals ++ [h] ++ rules)\n      (do\n        ps \u2190 intro_lst $ params.map local_pp_name,\n        fs \u2190 intro_lst $ fs\u2081.map local_pp_name,\n        ls \u2190 intro_lst $ pd.locals.map local_pp_name,\n        h  \u2190 intro `h,\n        rules  \u2190 intro_lst $ rules.map local_pp_name,\n        eapply $ pd.corec_functional.app_of_list $ ps ++ fs,\n        (pds.zip $ rules.zip shape).mmap (\u03bb\u27e8pd, hr, s\u27e9, solve1 $ do\n          ls \u2190 intro_lst $ pd.locals.map local_pp_name,\n          h' \u2190 intro `h,\n          h' \u2190 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 \u2190 elim_gen_sum n h',\n            (hs.zip $ pd.intros.zip s).mmap' (\u03bb\u27e8h, r, n_bs, n_eqs\u27e9, solve1 $ do\n              (as, h) \u2190 elim_gen_prod (n_bs - (if n_eqs = 0 then 1 else 0)) h [],\n              if n_eqs > 0 then do\n                (eqs, eq') \u2190 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' (\u03bbpd, pd.intros.mmap' (\u03bbr,\n    pd.add_theorem r.orig_nm (r.type.pis params) $ do\n      ps \u2190 intro_lst $ params.map local_pp_name,\n      bs \u2190 intros,\n      eapply $ pd.construct,\n      exact $ (const r.func_nm u_params).app_of_list $ ps ++ pds.map (\u03bbpd, pd.pred.app_of_list ps) ++ bs)),\n\n  pds.mmap' (\u03bbpd: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 \u2190 inductive_decl.parse meta_info,\n  add_coinductive_predicate decl.u_names decl.params $ decl.decls.map $ \u03bb d, (d.sig, d.intros),\n  decl.decls.mmap' $ \u03bb d, do {\n    get_env >>= \u03bb 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 \u2190 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' \u2190 intros,\n  ctxts \u2190 ctxts'.mmap (\u03bbv,\n    local_const v.local_uniq_name v.local_pp_name v.local_binder_info <$> infer_type v),\n  mvars \u2190 apply_core rule {approx := ff, new_goals := new_goals.all},\n  -- analyse relation\n  g \u2190 list.head <$> get_goals,\n  (list.cons _ m_is) \u2190 return $ mvars.drop_while (\u03bbv, v.2 \u2260 g),\n  tgt \u2190 target,\n  (is, ty) \u2190 mk_local_pis tgt,\n\n  -- construct coinduction predicate\n  (bs, eqs) \u2190 compact_relation ctxts <$>\n    ((is.zip m_is).mmap (\u03bb\u27e8i, m\u27e9, prod.mk i <$> instantiate_mvars m.2)),\n\n  solve1 (do\n    eqs \u2190 mk_and_lst <$> eqs.mmap (\u03bb\u27e8i, m\u27e9, mk_app `eq [m, i] >>= instantiate_mvars),\n    rel \u2190 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 \u2190 intro_lst $ is.map expr.local_pp_name,\n    h \u2190 intro1,\n    (_, h) \u2190 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) \u2190 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 \u2190 mk_const corec_name,\n  locals \u2190 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 \u2192 wide_pullback_shape J \u2192 Type v\n| id : \u03a0 X, hom X X\n| term : \u03a0 (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 := \u03bb j, hom.id j,\n  comp := \u03bb j\u2081 j\u2082 j\u2083 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) := \u27e8hom.id (none : wide_pullback_shape J)\u27e9\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance subsingleton_hom (j j' : wide_pullback_shape J) : subsingleton (j \u27f6 j') :=\n\u27e8by tidy\u27e9\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 = \ud835\udfd9 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 \u2192 C) (arrows : \u03a0 (j : J), objs j \u27f6 B) :\n  wide_pullback_shape J \u2964 C :=\n{ obj := \u03bb j, option.cases_on j B objs,\n  map := \u03bb X Y f,\n  begin\n    cases f with _ j,\n    { apply (\ud835\udfd9 _) },\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 \u2964 C) :\n  F \u2245 wide_cospan (F.obj none) (\u03bb j, F.obj (some j)) (\u03bb j, F.map (hom.term j)) :=\nnat_iso.of_components (\u03bb 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 \u2964 C} {X : C}\n  (f : X \u27f6 F.obj none) (\u03c0 : \u03a0 j, X \u27f6 F.obj (some j))\n  (w : \u2200 j, \u03c0 j \u226b F.map (hom.term j) = f) : cone F :=\n{ X := X,\n  \u03c0 :=\n  { app := \u03bb j, match j with\n    | none := f\n    | (some j) := \u03c0 j\n    end,\n    naturality' := \u03bb 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 \u2192 wide_pushout_shape J \u2192 Type v\n| id : \u03a0 X, hom X X\n| init : \u03a0 (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 := \u03bb j, hom.id j,\n  comp := \u03bb j\u2081 j\u2082 j\u2083 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) := \u27e8hom.id (none : wide_pushout_shape J)\u27e9\n\nlocal attribute [tidy] tactic.case_bash\n\ninstance subsingleton_hom (j j' : wide_pushout_shape J) : subsingleton (j \u27f6 j') :=\n\u27e8by tidy\u27e9\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 = \ud835\udfd9 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 \u2192 C) (arrows : \u03a0 (j : J), B \u27f6 objs j) : wide_pushout_shape J \u2964 C :=\n{ obj := \u03bb j, option.cases_on j B objs,\n  map := \u03bb X Y f,\n  begin\n    cases f with _ j,\n    { apply (\ud835\udfd9 _) },\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 \u2964 C) :\n  F \u2245 wide_span (F.obj none) (\u03bb j, F.obj (some j)) (\u03bb j, F.map (hom.init j)) :=\nnat_iso.of_components (\u03bb 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 \u2964 C} {X : C}\n  (f : F.obj none \u27f6 X) (\u03b9 : \u03a0 j, F.obj (some j) \u27f6 X)\n  (w : \u2200 j, F.map (hom.init j) \u226b \u03b9 j = f) : cocone F :=\n{ X := X,\n  \u03b9 :=\n  { app := \u03bb j, match j with\n    | none := f\n    | (some j) := \u03b9 j\n    end,\n    naturality' := \u03bb 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\u03a0 (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\u03a0 (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\u2081 v\u2082 u\u2081 u\u2082\n\nnamespace category_theory\nopen category limits\n\nvariables {C : Type u\u2081} {D : Type u\u2082} [category.{v\u2081} C] [category.{v\u2082} D]\nvariables (F : C \u2964 D)\n\n/-- If `F` preserves pullbacks, then it preserves monomorphisms. -/\ninstance preserves_mono {X Y : C} (f : X \u27f6 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 \u27f6 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 [\u2190F.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 \u27f6 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 \u27f6 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 [\u2190 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 (\u03b1 : Type)\n  | P : (string \u2192 option (\u03b1 \u00d7 string)) \u2192 Parser\n\nopen Parser\n\nvariables {\u03b1 \u03b2 : Type}\n\ndef parse : Parser \u03b1 \u2192 string \u2192 option (\u03b1 \u00d7 string)\n  | (P p) inp := p inp\n\ndef item : Parser char :=\n  P (\u03bb inp, match inp.to_list with\n              | [] := none\n              | (x::xs) := some (x, \u27e8xs\u27e9)\n            end )\n\ninstance : monad Parser :=\n{ pure := \u03bb \u03b1 v, P (\u03bb inp, some (v, inp)),\n  bind := \u03bb \u03b1 \u03b2 p f, P (\u03bb 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 : \u03b1 \u2192 Parser \u03b1 := return\n\n-- `>>=` is notation for `bind`.\nexample (f : \u03b1 \u2192 Parser \u03b2) (p : Parser \u03b1) : Parser \u03b2 := 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 \u03b1 := P (\u03bb _, none)\n\ndef return_first_and_third : Parser (char \u00d7 char) :=\n  do  x \u2190 item,\n      item,\n      y \u2190 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 := \u03bb \u03b1, P (\u03bb _, none),\n  orelse := \u03bb \u03b1 p q, P (\u03bb 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 \u03b1) : Prop := \u2200 (inp : string), (parse p inp = none \u2228 \n  \u2203 v out, (parse p inp) = some (v, out) \u2227 out.length < inp.length)\n\ndef consumes' : Parser \u03b1 \u2192 Prop\n| (P p) := \u2200 (inp : string), p inp = none \u2228 \u2203 v out, p inp = some (v, out) \u2227 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 [\u2190inp.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 [\u2190inp.as_string_inv_to_list, h], simp, }, }\nend\n\n/-\nDerived primatives\n-/\ndef sat (p : char \u2192 bool) : Parser char :=\n  do  x \u2190 item,\n      if p x then return x else failure\n\ndef digit : Parser char := sat (\u03bb c, to_bool c.is_digit)\n\ndef lower : Parser char := sat (\u03bb c, to_bool c.is_lower)\n\ndef upper : Parser char := sat (\u03bb c, to_bool c.is_upper)\n\ndef letter : Parser char := sat (\u03bb c, to_bool c.is_alpha)\n\ndef alphanum : Parser char := sat (\u03bb c, to_bool c.is_alphanum)\n\ndef is_space : Parser char := sat (\u03bb c, to_bool c.is_whitespace)\n\ndef charp (x : char) : Parser char := sat (\u03bb 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 \u2192 Parser string\n  | [] := return \"\"\n  | (x::xs) := do charp x,\n                  list_char_parser xs,\n                  return \u27e8x :: xs\u27e9\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 \u03b1) : Parser (list \u03b1) :=\n  P (\u03bb 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 \u03b1) : Parser (list \u03b1) :=\n  P (\u03bb 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 \u03b1) : \u2115 \u2192 Parser (list \u03b1)\n  | 0 := return []\n  | (n+1) := do x <- p,\n                xs \u2190 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 \u03b1) : Parser (list \u03b1) :=\n  (do x \u2190 p, xs \u2190 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 \u03b1) : Parser (list \u03b1) :=\n  (do x \u2190 p, xs \u2190 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 : \u2115) : \u2115 \u2192 Prop\n| refl : less_than_or_equal a\n| step : \u03a0 {b}, less_than_or_equal b \u2192 less_than_or_equal (succ b) -/\n\n/- inductive opt_rel : option (\u03b1 \u00d7 string) \u2192 option (\u03b1 \u00d7 string) \u2192 Prop\n| none_lt_some  -/\n\ndef opt_rel : option (\u03b1 \u00d7 string) \u2192 option (\u03b1 \u00d7 string) \u2192 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 \u03b1 none none = false := rfl\n\nlemma not_some_lt_none (v : \u03b1) (inp : string) : @opt_rel \u03b1 (some (v, inp)) none = false := rfl\n\nlemma some_lt_some {v1 v2 : \u03b1} {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 (\u03b1 \u00d7 string)) : \u00ac (opt_rel r none) :=\nbegin\n  intro h,\n  rcases r with _ | \u27e8v, inp\u27e9,\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    \u03b1 : Type,\n    n : \u2115,\n    ih : \u2200 (inp : string) (v : \u03b1), inp.length = n \u2192 acc opt_rel (some (v, inp)),\n    inp : string,\n    v : \u03b1,\n    hl : inp.length = n.succ\n    \u22a2 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\u2082,\n    { rw e, exact ih, },\n    { exact acc.inv ih h\u2082, }, }\nend\n\nlemma acc_opt_rel_none : acc (@opt_rel \u03b1) 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 : \u2115} (h : s.length = n.succ) : \u2203 x xs, s = (x :: xs).as_string :=\nbegin\n  let sl := s.to_list,\n  have h\u2081 : sl.length = n.succ,\n  { rw s.length_to_list, exact h, },\n  rcases (s.to_list).exists_of_length_succ h\u2081 with \u27e8x, xs, h\u2082\u27e9,\n  use [x, xs],  \n  rw [\u2190h\u2082, s.as_string_inv_to_list],\nend\n\nlemma acc_opt_rel_some (n : \u2115) : \u2200 (inp : string) (v : \u03b1),\n  inp.length < n \u2192 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 _ | \u27e8v', inp'\u27e9,\n    { exact acc_opt_rel_none, },\n    { have h\u2082 := 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 _ | \u27e8v', inp'\u27e9,\n    { exact acc_opt_rel_none, },\n    { cases (nat.eq_or_lt_of_le (nat.le_of_succ_le_succ hl)) with e h\u2082,\n      sorry,\n      sorry,\n     },\n   },\nend\n\n/- lemma acc_opt_rel_some (n : \u2115) : \u2200 (inp : string) (v : \u03b1),\n  inp.length = n \u2192 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 _ | \u27e8v', inp'\u27e9,\n    { exact acc_opt_rel_none, },\n    { have h\u2082 := some_lt_some h, rw hl at h\u2082, exfalso, refine nat.not_lt_zero _ h\u2082, }, },    \n  { intros inp v hl, \n    refine acc.intro (some (v, inp)) _,\n    intros m h,\n    rcases m with _ | \u27e8v', inp'\u27e9,\n    { exact acc_opt_rel_none, },\n    { rcases string_succ hl with \u27e8x, xs, h\u2082\u27e9,\n      have h\u2083 : (x :: xs).as_string.length = n.succ, { rw [\u2190h\u2082, hl], },\n      have h\u2084 : xs.as_string.length = n,\n      { simp only [nat.succ_eq_add_one, list.length_as_string, add_left_inj, list.length] at h\u2083 \u22a2,\n        exact h\u2083, },\n      have h\u2085 : inp'.length < inp.length := some_lt_some h,\n      rw h\u2082 at h\u2085, simp only [list.length_as_string, list.length] at h\u2085,\n      cases (nat.eq_or_lt_of_le (nat.le_of_succ_le_succ h\u2085)) with e h\u2086,\n      { apply ih, rw [e, \u2190h\u2084], simp,  },\n      sorry,\n     },\n   },\nend -/\n\n\nexample : well_founded (@opt_rel \u03b1) := well_founded.intro $\nbegin\n  rintro (_ | \u27e8v, inp\u27e9),\n  { exact acc_opt_rel_none, },\n  { \n    sorry,\n   },\nend\n\n\nexample : well_founded (@opt_rel \u03b1) := well_founded.intro $\nbegin\n  rintro (_ | \u27e8v, inp\u27e9),\n  { exact acc_opt_rel_none, },\n  { rw \u2190inp.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 _ | \u27e8v', inp'\u27e9,\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 _ | \u27e8v', inp'\u27e9,\n      { exact acc_opt_rel_none, },\n      { /- have h\u2082 : inp'.length < (x :: xs).as_string.length := some_lt_some h,\n        simp only [list.length_as_string, list.length] at h\u2082, -/\n        cases (nat.eq_or_lt_of_le (nat.le_of_succ_le_succ h)) with e h\u2082,\n        { specialize ih v' inp', sorry, },\n        { sorry, }\n       }\n\n      }\n  \n   },\nend\n\nexample : @well_founded (\u2115) (nat.lt) :=\nwell_founded.intro (\u03bb x, acc.intro x (\u03bb y h, (acc.intro y (\u03bb z p, sorry))))\n\nexample : @well_founded (option (\u03b1 \u00d7 string)) (@opt_rel \u03b1) :=\nwell_founded.intro (\u03bb x, acc.intro x (\u03bb y h, sorry))\n\nmeta def many_many1 : bool \u2192 \u03a0 (p : Parser \u03b1) (h : consumes' p), Parser (list \u03b1)\n| tt (P p) := \u03bb h, P (\u03bb inp, parse (many_many1 ff (P p) h <|> return []) inp)\n| ff (P p) := \u03bb h, P (\u03bb inp, parse  (do v \u2190 (P p),\n                                        vs \u2190 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 \u2190 lower,\n      xs \u2190 many alphanum,\n      return (x :: xs)\n\nmeta def ident : Parser string := do xs \u2190 identc, return \u27e8xs\u27e9\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 `\u2115`.\nAs Lean functions are total, we choose to convert `c` to `0` if `c` is not a digit.\n-/\ndef char_to_nat : char \u2192 \u2115\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 \u2115 \u2192 \u2115\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) : \u2115 :=\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 \u2115 :=\n  do  xs \u2190 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 \u2124 :=\n  (do  charp '-',\n      n \u2190 natp,\n      return (-n))\n  <|> do n \u2190 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 \" \u25b8  \u00ac fish\" -- consumes the whitespace, returning `star`.\n\nmeta def token (p : Parser \u03b1) : Parser \u03b1 :=\n  do  space,\n      v \u2190 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 \u2115 := 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 \u2115) := \n  do  symbol \"[\",\n      n \u2190 natural,\n      ns \u2190 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 \u2115`.\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 : \u2115) [h : char_p R p] : char_p R[X] p :=\nlet \u27e8h\u27e9 := h in \u27e8\u03bb n, by rw [\u2190 map_nat_cast C, \u2190 C_0, C_inj, h]\u27e9\n\nvariables (R)\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree \u2264 `n`. -/\ndef degree_le (n : with_bot \u2115) : submodule R R[X] :=\n\u2a05 k : \u2115, \u2a05 h : \u2191k > n, (lcoeff R k).ker\n\n/-- The `R`-submodule of `R[X]` consisting of polynomials of degree < `n`. -/\ndef degree_lt (n : \u2115) : submodule R R[X] :=\n\u2a05 k : \u2115, \u2a05 h : k \u2265 n, (lcoeff R k).ker\n\nvariable {R}\n\ntheorem mem_degree_le {n : with_bot \u2115} {f : R[X]} :\n  f \u2208 degree_le R n \u2194 degree f \u2264 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 \u2115} (H : m \u2264 n) :\n  degree_le R m \u2264 degree_le R n :=\n\u03bb f hf, mem_degree_le.2 (le_trans (mem_degree_le.1 hf) H)\n\ntheorem degree_le_eq_span_X_pow {n : \u2115} :\n  degree_le R n = submodule.span R \u2191((finset.range (n+1)).image (\u03bb n, (X : R[X])^n)) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_le.1 hp,\n    rw [\u2190 polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (\u03bb k hk, _),\n    show monomial _ _ \u2208 _,\n    have := with_bot.coe_le_coe.1 (finset.sup_le_iff.1 hp k hk),\n    rw [\u2190 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 \u27e8_, finset.mem_range.2 (nat.lt_succ_of_le this), rfl\u27e9) },\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 : \u2115} {f : R[X]} :\n  f \u2208 degree_lt R n \u2194 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 : \u2115} (H : m \u2264 n) :\n  degree_lt R m \u2264 degree_lt R n :=\n\u03bb 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 : \u2115} :\n  degree_lt R n = submodule.span R \u2191((finset.range n).image (\u03bb n, X^n) : finset R[X]) :=\nbegin\n  apply le_antisymm,\n  { intros p hp, replace hp := mem_degree_lt.1 hp,\n    rw [\u2190 polynomial.sum_monomial_eq p, polynomial.sum],\n    refine submodule.sum_mem _ (\u03bb k hk, _),\n    show monomial _ _ \u2208 _,\n    have := with_bot.coe_lt_coe.1 ((finset.sup_lt_iff $ with_bot.bot_lt_coe n).1 hp k hk),\n    rw [\u2190 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 \u27e8_, finset.mem_range.2 this, rfl\u27e9) },\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 \u2192 R`. -/\ndef degree_lt_equiv (R) [semiring R] (n : \u2115) : degree_lt R n \u2243\u2097[R] (fin n \u2192 R) :=\n{ to_fun := \u03bb p n, (\u2191p : R[X]).coeff n,\n  inv_fun := \u03bb f, \u27e8\u2211 i : fin n, monomial i (f i),\n    (degree_lt R n).sum_mem (\u03bb 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)))\u27e9,\n  map_add' := \u03bb p q, by { ext, rw [submodule.coe_add, coeff_add], refl },\n  map_smul' := \u03bb x p, by { ext, rw [submodule.coe_smul, coeff_smul], refl },\n  left_inv :=\n  begin\n    rintro \u27e8p, hp\u27e9, 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, \u2190 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 [\u2190 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 : \u2115} {p : R[X]} (hp : p \u2208 degree_lt R n) :\n  degree_lt_equiv _ _ \u27e8p, hp\u27e9 = 0 \u2194 p = 0 :=\nby rw [linear_equiv.map_eq_zero_iff, submodule.mk_eq_zero]\n\ntheorem eval_eq_sum_degree_lt_equiv {n : \u2115} {p : R[X]} (hp : p \u2208 degree_lt R n) (x : R) :\n  p.eval x = \u2211 i, degree_lt_equiv _ _ \u27e8p, hp\u27e9 i * (x ^ (i : \u2115)) :=\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 (\u03bb n, p.coeff n) p.support\n\nlemma frange_zero : frange (0 : R[X]) = \u2205 :=\nrfl\n\nlemma mem_frange_iff {p : R[X]} {c : R} :\n  c \u2208 p.frange \u2194 \u2203 n \u2208 p.support, c = p.coeff n :=\nby simp [frange, eq_comm]\n\nlemma frange_one : frange (1 : R[X]) \u2286 {1} :=\nbegin\n  simp [frange, finset.image_subset_iff],\n  simp only [\u2190 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 : \u2115) (h : p.coeff n \u2260 0) :\n  p.coeff n \u2208 p.frange :=\nbegin\n  simp only [frange, exists_prop, mem_support_iff, finset.mem_image, ne.def],\n  exact \u27e8n, h, rfl\u27e9,\nend\n\nlemma geom_sum_X_comp_X_add_one_eq_sum (n : \u2115) :\n  (\u2211 i in range n, (X : R[X]) ^ i).comp (X + 1) =\n  (finset.range n).sum (\u03bb (i : \u2115), (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, \u2190 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 : \u2115} (hn : n \u2260 0) : (\u2211 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 : \u2115} (hn : n \u2260 0) :\n  (\u2211 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 (\u2191p.frange : set R)) :=\n\u2211 i in p.support, monomial i (\u27e8p.coeff i,\n  if H : p.coeff i = 0 then H.symm \u25b8 (subring.closure _).zero_mem\n  else subring.subset_closure (p.coeff_mem_frange _ H)\u27e9 : (subring.closure (\u2191p.frange : set R)))\n\n@[simp] theorem coeff_restriction {p : R[X]} {n : \u2115} :\n  \u2191(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 : \u2115} :\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 [\u2190 coeff_restriction] },\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\nend\n\n@[simp] theorem map_restriction {R : Type u} [comm_ring R]\n  (p : R[X]) : p.restriction.map (algebra_map _ _) = p :=\next $ \u03bb 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) \u2194 monic p :=\nbegin\n  simp only [monic, leading_coeff, nat_degree_restriction],\n  rw [\u2190@coeff_restriction _ _ p],\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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 $ \u03bb i, subtype.eq $ by rw [coeff_restriction', coeff_one, coeff_one]; split_ifs; refl\n\nvariables [semiring S] {f : R \u2192+* S} {x : S}\n\ntheorem eval\u2082_restriction {p : R[X]} :\n  eval\u2082 f x p =\n  eval\u2082 (f.comp (subring.subtype (subring.closure (p.frange : set R)))) x p.restriction :=\nbegin\n  simp only [eval\u2082_eq_sum, sum, support_restriction, \u2190@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 : (\u2191p.frange : set R) \u2286 T) : T[X] :=\n\u2211 i in p.support, monomial i (\u27e8p.coeff i,\n  if H : p.coeff i = 0 then H.symm \u25b8 T.zero_mem\n  else hp (p.coeff_mem_frange _ H)\u27e9 : T)\n\nvariables (hp : (\u2191p.frange : set R) \u2286 T)\ninclude hp\n\n@[simp] theorem coeff_to_subring {n : \u2115} : \u2191(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 : \u2115} : (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 [\u2190 coeff_to_subring p T hp] },\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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) \u2194 monic p :=\nbegin\n  simp_rw [monic, leading_coeff, nat_degree_to_subring, \u2190 coeff_to_subring p T hp],\n  exact \u27e8\u03bb H, by { rw H, refl }, \u03bb H, subtype.coe_injective H\u27e9\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 $ \u03bb 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\u2211 i in p.support, monomial i (p.coeff i : R)\n\nlemma coeff_of_subring (p : T[X]) (n : \u2115) :\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  (\u2191(p.of_subring T).frange : set R) \u2286 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 \u27e8n, hn, h'n\u27e9,\n  rw [\u2190 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 \u2208 (mod_by_monic_hom q).ker \u2194 q \u2223 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 (\u03bb 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' := \u03bb _ _, I.add_mem,\n  smul_mem' := \u03bb c x H, by { rw [\u2190 C_mul'], exact I.mul_mem_left _ H } }\n\nvariables {I : ideal R[X]}\ntheorem mem_of_polynomial (x) : x \u2208 I.of_polynomial \u2194 x \u2208 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 \u2264 `n`. -/\ndef degree_le (n : with_bot \u2115) : submodule R R[X] :=\ndegree_le R n \u2293 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 \u2264 `n`. -/\ndef leading_coeff_nth (n : \u2115) : 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\u2a06 n : \u2115, 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 : \u2200 (n : \u2115), (p.coeff n) \u2208 I.comap (C : R \u2192+* R[X])) : p \u2208 I :=\nsum_C_mul_X_pow_eq p \u25b8 submodule.sum_mem I (\u03bb 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 \u2208 (ideal.map (C : R \u2192+* R[X]) I : ideal R[X]) \u2194 \u2200 n : \u2115, f.coeff n \u2208 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 [\u2190 hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [h] } },\n    { simp },\n    { exact \u03bb f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine \u03bb f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (\u03bb c hc, I.mul_mem_left (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw \u2190 sum_monomial_eq f,\n    refine (I.map C : ideal R[X]).sum_mem (\u03bb n hn, _),\n    simp [\u2190 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 \u2192+* S) :\n  (polynomial.map_ring_hom f).ker = f.ker.map (C : R \u2192+* 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 : \u2115) (x) :\n  x \u2208 I.leading_coeff_nth n \u2194 \u2203 p \u2208 I, degree p \u2264 n \u2227 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 \u27e8p, \u27e8hpdeg, hpI\u27e9, rfl\u27e9,\n    cases lt_or_eq_of_le hpdeg with hpdeg hpdeg,\n    { refine \u27e80, I.zero_mem, bot_le, _\u27e9,\n      rw [leading_coeff_zero, eq_comm],\n      exact coeff_eq_zero_of_degree_lt hpdeg },\n    { refine \u27e8p, hpI, le_of_eq hpdeg, _\u27e9,\n      rw [polynomial.leading_coeff, nat_degree, hpdeg], refl } },\n  { rintro \u27e8p, hpI, hpdeg, rfl\u27e9,\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 \u27e8p * X ^ (n - nat_degree p), \u27e8_, I.mul_mem_right _ hpI\u27e9, _\u27e9,\n    { apply le_trans (degree_mul_le _ _) _,\n      apply le_trans (add_le_add (degree_le_nat_degree) (degree_X_pow_le _)) _,\n      rw [\u2190 with_bot.coe_add, this],\n      exact le_rfl },\n    { rw [polynomial.leading_coeff, \u2190 coeff_mul_X_pow p (n - nat_degree p), this] } }\nend\n\ntheorem mem_leading_coeff_nth_zero (x) :\n  x \u2208 I.leading_coeff_nth 0 \u2194 C x \u2208 I :=\n(mem_leading_coeff_nth _ _ _).trans\n\u27e8\u03bb \u27e8p, hpI, hpdeg, hpx\u27e9, by rwa [\u2190 hpx, polynomial.leading_coeff,\n  nat.eq_zero_of_le_zero (nat_degree_le_of_degree_le hpdeg),\n  \u2190 eq_C_of_degree_le_zero hpdeg],\n\u03bb hx, \u27e8C x, hx, degree_C_le, leading_coeff_C x\u27e9\u27e9\n\ntheorem leading_coeff_nth_mono {m n : \u2115} (H : m \u2264 n) :\n  I.leading_coeff_nth m \u2264 I.leading_coeff_nth n :=\nbegin\n  intros r hr,\n  simp only [set_like.mem_coe, mem_leading_coeff_nth] at hr \u22a2,\n  rcases hr with \u27e8p, hpI, hpdeg, rfl\u27e9,\n  refine \u27e8p * X ^ (n - m), I.mul_mem_right _ hpI, _, leading_coeff_mul_X_pow\u27e9,\n  refine le_trans (degree_mul_le _ _) _,\n  refine le_trans (add_le_add hpdeg (degree_X_pow_le _)) _,\n  rw [\u2190 with_bot.coe_add, add_tsub_cancel_of_le H],\n  exact le_rfl\nend\n\ntheorem mem_leading_coeff (x) :\n  x \u2208 I.leading_coeff \u2194 \u2203 p \u2208 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 \u27e8i, p, hpI, hpdeg, rfl\u27e9, exact \u27e8p, hpI, rfl\u27e9 },\n    rintro \u27e8p, hpI, rfl\u27e9, exact \u27e8nat_degree p, p, hpI, degree_le_nat_degree, rfl\u27e9 },\n  intros i j, exact \u27e8i + j, I.leading_coeff_nth_mono (nat.le_add_right _ _),\n    I.leading_coeff_nth_mono (nat.le_add_left _ _)\u27e9\nend\n\n/--\nIf `I` is an ideal, and `p\u1d62` is a finite family of polynomials each satisfying\n`\u2200 k, (p\u1d62)\u2096 \u2208 I\u207f\u2071\u207b\u1d4f` for some `n\u1d62`, then `p = \u220f p\u1d62` also satisfies `\u2200 k, p\u2096 \u2208 I\u207f\u207b\u1d4f` with `n = \u2211 n\u1d62`.\n-/\nlemma _root_.polynomial.coeff_prod_mem_ideal_pow_tsub {\u03b9 : Type*} (s : finset \u03b9) (f : \u03b9 \u2192 R[X])\n  (I : ideal R) (n : \u03b9 \u2192 \u2115) (h : \u2200 (i \u2208 s) k, (f i).coeff k \u2208 I ^ (n i - k)) (k : \u2115) :\n  (s.prod f).coeff k \u2208 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 \u27e8i, j\u27e9 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 (\u03bb 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 : \u00ac is_field R[X] :=\nbegin\n  nontriviality R,\n  intro hR,\n  obtain \u27e8p, hp\u27e9 := hR.mul_inv_cancel X_ne_zero,\n  have hp0 : p \u2260 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 [\u2190X_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 \u2208 I) : x = 0 :=\nbegin\n  refine classical.by_contradiction (\u03bb hx0, hI.ne_top ((eq_top_iff_one I).2 _)),\n  obtain \u27e8y, hy\u27e9 := hR.mul_inv_cancel hx0,\n  convert I.mul_mem_left (C y) hx,\n  rw [\u2190 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 \u2192+* R[X]) P : ideal R[X]) \u2194 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 \u2192+* 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, \u2190 eq_top_iff_one], exact h.1 },\n    { intros f g, simp only [mem_map_C_iff], contrapose!,\n      rintro \u27e8hf, hg\u27e9,\n      classical,\n      let m := nat.find hf,\n      let n := nat.find hg,\n      refine \u27e8m + n, _\u27e9,\n      rw [coeff_mul, \u2190 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 \u27e8nat.find_spec hf, nat.find_spec hg\u27e9 },\n      apply P.sum_mem,\n      rintro \u27e8i, j\u27e9 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 \u2228 j < n,\n      { rw [or_iff_not_imp_left, not_lt, le_iff_lt_or_eq],\n        rintro (hmi|rfl),\n        { rw [\u2190 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 \u2192+* 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 : \u2115) :\n  submodule.fg (I.degree_le n) :=\nis_noetherian_submodule_left.1 (is_noetherian_of_fg_of_noetherian _\n  \u27e8_, degree_le_eq_span_X_pow.symm\u27e9) _\n\nend comm_ring\n\nend ideal\n\nvariables {\u03c3 : Type v} {M : Type w}\nvariables [comm_ring R] [comm_ring S] [add_comm_group M] [module R M]\n\nsection prime\nvariables (\u03c3) {r : R}\n\nnamespace polynomial\nlemma prime_C_iff : prime (C r) \u2194 prime r :=\n\u27e8 comap_prime C (eval_ring_hom (0 : R)) (\u03bb r, eval_C),\n  \u03bb hr, by { have := hr.1,\n    rw \u2190 ideal.span_singleton_prime at hr \u22a2,\n    { convert ideal.is_prime_map_C_of_is_prime hr using 1,\n      rw [ideal.map_span, set.image_singleton] },\n    exacts [\u03bb h, this (C_eq_zero.1 h), this] } \u27e9\nend polynomial\n\nnamespace mv_polynomial\n\nprivate lemma prime_C_iff_of_fintype [fintype \u03c3] : prime (C r : mv_polynomial \u03c3 R) \u2194 prime r :=\nbegin\n  rw (rename_equiv R (fintype.equiv_fin \u03c3)).to_mul_equiv.prime_iff,\n  convert_to prime (C r) \u2194 _, { congr, apply rename_C },\n  { symmetry, induction fintype.card \u03c3 with d hd,\n    { exact (is_empty_alg_equiv R (fin 0)).to_mul_equiv.symm.prime_iff },\n    { rw [hd, \u2190 polynomial.prime_C_iff],\n      convert (fin_succ_equiv R d).to_mul_equiv.symm.prime_iff,\n      rw \u2190 fin_succ_equiv_comp_C_eq_C, refl } },\nend\n\nlemma prime_C_iff : prime (C r : mv_polynomial \u03c3 R) \u2194 prime r :=\n\u27e8 comap_prime C constant_coeff (constant_coeff_C _),\n  \u03bb hr, \u27e8 \u03bb h, hr.1 $ by { rw [\u2190 C_inj, h], simp },\n    \u03bb h, hr.2.1 $ by { rw \u2190 constant_coeff_C _ r, exact h.map _ },\n    \u03bb a b hd, begin\n      obtain \u27e8s,a',b',rfl,rfl\u27e9 := exists_finset_rename\u2082 a b,\n      rw \u2190 algebra_map_eq at hd, have : algebra_map R _ r \u2223 a' * b',\n      { convert (kill_compl subtype.coe_injective).to_ring_hom.map_dvd hd, simpa, simp },\n      rw \u2190 rename_C (coe : s \u2192 \u03c3), let f := (rename (coe : s \u2192 \u03c3)).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 \u27e9 \u27e9\n\nvariable {\u03c3}\nlemma prime_rename_iff (s : set \u03c3) {p : mv_polynomial s R} :\n  prime (rename (coe : s \u2192 \u03c3) p) \u2194 prime p :=\nbegin\n  classical, symmetry, let eqv := (sum_alg_equiv R _ _).symm.trans\n    (rename_equiv R $ (equiv.sum_comm \u21a5s\u1d9c s).trans $ equiv.set.sum_compl s),\n  rw [\u2190 prime_C_iff \u21a5s\u1d9c, 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 (\u27e8\u03bb (p : R[X]),\n        ((if p = 0 then \u22a4 else \u2191p.degree : with_top (with_bot \u2115)), p.leading_coeff), _\u27e9 :\n        dvd_not_unit \u2192r prod.lex (<) dvd_not_unit)\n      (prod.lex_wf (with_top.well_founded_lt $ with_bot.well_founded_lt nat.lt_wf)\n        \u2039wf_dvd_monoid R\u203a.well_founded_dvd_not_unit),\n    rintros a b \u27e8ane0, \u27e8c, \u27e8not_unit_c, rfl\u27e9\u27e9\u27e9,\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 \u2260 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 _ \u27e8_, \u27e8c.leading_coeff, (\u03bb unit_c, not_unit_c _), rfl\u27e9\u27e9,\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          \u2190 with_bot.coe_add, with_bot.coe_lt_coe],\n      exact lt_add_of_pos_right _ (nat.pos_of_ne_zero (\u03bb h, hdeg (h.symm \u25b8 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 \u27e8assume 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) \u27e8_, \u27e80, rfl\u27e9\u27e9 in\nhave hm : M \u2208 set.range I.leading_coeff_nth := well_founded.min_mem _ _ _,\nlet \u27e8N, HN\u27e9 := hm, \u27e8s, hs\u27e9 := I.is_fg_degree_le N in\nhave hm2 : \u2200 k, I.leading_coeff_nth k \u2264 M := \u03bb k, or.cases_on (le_or_lt k N)\n  (\u03bb h, HN \u25b8 I.leading_coeff_nth_mono h)\n  (\u03bb h x hx, classical.by_contradiction $ \u03bb hxm,\n    have \u00acM < I.leading_coeff_nth k, by refine well_founded.not_lt_min\n      (well_founded_submodule_gt _ _) _ _ _; exact \u27e8k, rfl\u27e9,\n    this \u27e8HN \u25b8 I.leading_coeff_nth_mono (le_of_lt h), \u03bb H, hxm (H hx)\u27e9),\nhave hs2 : \u2200 {x}, x \u2208 I.degree_le N \u2192 x \u2208 ideal.span (\u2191s : set R[X]),\nfrom hs \u25b8 \u03bb x hx, submodule.span_induction hx (\u03bb _ hx, ideal.subset_span hx) (ideal.zero_mem _)\n  (\u03bb _ _, ideal.add_mem _) (\u03bb c f hf, f.C_mul' c \u25b8 ideal.mul_mem_left _ _ hf),\n\u27e8s, le_antisymm\n  (ideal.span_le.2 $ \u03bb x hx, have x \u2208 I.degree_le N, from hs \u25b8 submodule.subset_span hx, this.2) $\nbegin\n  have : submodule.span R[X] \u2191s = ideal.span \u2191s, 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 \u27e8polynomial.mem_degree_le.2\n      (le_trans polynomial.degree_le_nat_degree $ with_bot.coe_le_coe.2 h), hp\u27e9 },\n  { have hp0 : p \u2260 0,\n    { rintro rfl, cases hn, exact nat.not_lt_zero _ h },\n    have : (0 : R) \u2260 1,\n    { intro h, apply hp0, ext i, refine (mul_one _).symm.trans _,\n      rw [\u2190 h, mul_zero], refl },\n    haveI : nontrivial R := \u27e8\u27e80, 1, this\u27e9\u27e9,\n    have : p.leading_coeff \u2208 I.leading_coeff_nth N,\n    { rw HN, exact hm2 k ((I.mem_leading_coeff_nth _ _).2\n        \u27e8_, hp, hn \u25b8 polynomial.degree_le_nat_degree, rfl\u27e9) },\n    rw I.mem_leading_coeff_nth at this,\n    rcases this with \u27e8q, hq, hdq, hlqp\u27e9,\n    have hq0 : q \u2260 0,\n    { intro H, rw [\u2190 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 [\u2190 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 [\u2190 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 \u2190 sub_add_cancel p (q * polynomial.X ^ (k - q.nat_degree)),\n    refine (ideal.span \u2191s).add_mem _ ((ideal.span \u2191s).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 \u27e8polynomial.mem_degree_le.2 hdq, hq\u27e9 }\nend\u27e9\u27e9\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) : \u2203 g, irreducible g \u2227 g \u2223 f :=\nwf_dvd_monoid.exists_irreducible_factor\n  (\u03bb huf, ne_of_gt hf $ degree_eq_zero_of_is_unit huf)\n  (\u03bb hf0, not_lt_of_lt hf $ hf0.symm \u25b8 (@degree_zero R _).symm \u25b8 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) : \u2203 g, irreducible g \u2227 g \u2223 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 \u2260 0) : \u2203 g, irreducible g \u2227 g \u2223 f :=\nexists_irreducible_of_nat_degree_pos $ nat.pos_of_ne_zero hf\n\nlemma linear_independent_powers_iff_aeval\n  (f : M \u2192\u2097[R] M) (v : M) :\n  linear_independent R (\u03bb n : \u2115, (f ^ n) v)\n    \u2194 \u2200 (p : R[X]), aeval f p v = 0 \u2192 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 \u2192\u2097[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 \u27e8p', q', hpq'\u27e9,\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 (\u03bb p : R[X], aeval f p v) hpq'.symm,\nend\n\nlemma sup_aeval_range_eq_top_of_coprime\n  (f : M \u2192\u2097[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  (aeval f p).range \u2294 (aeval f q).range = \u22a4 :=\nbegin\n  rw eq_top_iff,\n  intros v hv,\n  rw submodule.mem_sup,\n  rcases hpq with \u27e8p', q', hpq'\u27e9,\n  use aeval f (p * p') v,\n  use linear_map.mem_range.2 \u27e8aeval f p' v, by simp only [linear_map.mul_apply, aeval_mul]\u27e9,\n  use aeval f (q * q') v,\n  use linear_map.mem_range.2 \u27e8aeval f q' v, by simp only [linear_map.mul_apply, aeval_mul]\u27e9,\n  simpa only [mul_comm p p', mul_comm q q', aeval_one, aeval_add]\n    using congr_arg (\u03bb p : R[X], aeval f p v) hpq'\nend\n\nlemma sup_ker_aeval_le_ker_aeval_mul {f : M \u2192\u2097[R] M} {p q : R[X]} :\n  (aeval f p).ker \u2294 (aeval f q).ker \u2264 (aeval f (p * q)).ker :=\nbegin\n  intros v hv,\n  rcases submodule.mem_sup.1 hv with \u27e8x, hx, y, hy, hxy\u27e9,\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, \u2190hxy, 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 \u2192\u2097[R] M) {p q : R[X]} (hpq : is_coprime p q) :\n  (aeval f p).ker \u2294 (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 \u27e8p', q', hpq'\u27e9,\n  have h_eval\u2082_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\u2082_pqq' := calc\n    aeval f (p * (q * q')) v = aeval f (q' * (p * q)) v :\n      by rw [\u2190mul_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\u2082_qpp' h_eval\u2082_pqq',\n  refine \u27e8aeval f (q * q') v, linear_map.mem_ker.1 h_eval\u2082_pqq',\n          aeval f (p * p') v, linear_map.mem_ker.1 h_eval\u2082_qpp', _\u27e9,\n  rw [add_comm, mul_comm p p', mul_comm q q'],\n  simpa only [map_add, map_mul, aeval_one] using congr_arg (\u03bb 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  \u2200 {n : \u2115}, 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 \u03c3] [is_noetherian_ring R] :\n  is_noetherian_ring (mv_polynomial \u03c3 R) :=\nby casesI nonempty_fintype \u03c3; exact\n@is_noetherian_ring_of_ring_equiv (mv_polynomial (fin (fintype.card \u03c3)) R) _ _ _\n  (rename_equiv R (fintype.equiv_fin \u03c3).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  \u2200 (n : \u2115), 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) (\u03c3 : Type v) [comm_semiring R] [finite \u03c3]\n  [no_zero_divisors R] : no_zero_divisors (mv_polynomial \u03c3 R) :=\nbegin\n  casesI nonempty_fintype \u03c3,\n  haveI := no_zero_divisors_fin R (fintype.card \u03c3),\n  exact (rename_equiv R (fintype.equiv_fin \u03c3)).injective.no_zero_divisors _ (map_zero _) (map_mul _)\nend\n\ninstance {R : Type u} [comm_semiring R] [no_zero_divisors R] {\u03c3 : Type v} :\n  no_zero_divisors (mv_polynomial \u03c3 R) :=\n\u27e8\u03bb p q h, begin\n  obtain \u27e8s, p, rfl\u27e9 := exists_finset_rename p,\n  obtain \u27e8t, q, rfl\u27e9 := exists_finset_rename q,\n  have :\n    rename (subtype.map id (finset.subset_union_left s t) : {x // x \u2208 s} \u2192 {x // x \u2208 s \u222a t}) p *\n    rename (subtype.map id (finset.subset_union_right s t) : {x // x \u2208 t} \u2192 {x // x \u2208 s \u222a 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 \u2208 (s \u222a 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\u27e9\n\n/-- The multivariate polynomial ring over an integral domain is an integral domain. -/\ninstance {R : Type u} {\u03c3 : Type v} [comm_ring R] [is_domain R] : is_domain (mv_polynomial \u03c3 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\u2082 {S : Type*} [comm_ring S] [finite \u03c3]\n  (\u03d5 : mv_polynomial \u03c3 R \u2192+* S) (p : mv_polynomial \u03c3 R) :\n  \u03d5 p = mv_polynomial.eval\u2082 (\u03d5.comp mv_polynomial.C) (\u03bb s, \u03d5 (mv_polynomial.X s)) p :=\nbegin\n  casesI nonempty_fintype \u03c3,\n  refine trans (congr_arg \u03d5 (mv_polynomial.as_sum p)) _,\n  rw [mv_polynomial.eval\u2082_eq', \u03d5.map_sum],\n  congr,\n  ext,\n  simp only [monomial_eq, \u03d5.map_pow, \u03d5.map_prod, \u03d5.comp_apply, \u03d5.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 \u03c3 R)) (p : mv_polynomial \u03c3 R)\n  (hcoe : \u2200 (m : \u03c3 \u2192\u2080 \u2115), p.coeff m \u2208 I.comap (C : R \u2192+* mv_polynomial \u03c3 R)) : p \u2208 I :=\nbegin\n  rw as_sum p,\n  suffices : \u2200 m \u2208 p.support, monomial m (mv_polynomial.coeff m p) \u2208 I,\n  { exact submodule.sum_mem I this },\n  intros m hm,\n  rw [\u2190 mul_one (coeff m p), \u2190 C_mul_monomial],\n  suffices : C (coeff m p) \u2208 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 \u03c3 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 \u03c3 R} :\n  f \u2208 (ideal.map (C : R \u2192+* mv_polynomial \u03c3 R) I :\n  ideal (mv_polynomial \u03c3 R)) \u2194 \u2200 (m : \u03c3 \u2192\u2080 \u2115), f.coeff m \u2208 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 [\u2190 hx.right, coeff_C],\n      by_cases (n = 0),\n      { simpa [h] using hx.left },\n      { simp [ne.symm h] } },\n    { simp },\n    { exact \u03bb f g hf hg n, by simp [I.add_mem (hf n) (hg n)] },\n    { refine \u03bb f g hg n, _,\n      rw [smul_eq_mul, coeff_mul],\n      exact I.sum_mem (\u03bb c hc, I.mul_mem_left (f.coeff c.fst) (hg c.snd)) } },\n  { intros hf,\n    rw as_sum f,\n    suffices : \u2200 m \u2208 f.support, monomial m (coeff m f) \u2208\n      (ideal.map C I : ideal (mv_polynomial \u03c3 R)),\n    { exact submodule.sum_mem _ this },\n    intros m hm,\n    rw [\u2190 mul_one (coeff m f), \u2190 C_mul_monomial],\n    suffices : C (coeff m f) \u2208 (ideal.map C I : ideal (mv_polynomial \u03c3 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 \u2192+* S) :\n  (map f : mv_polynomial \u03c3 R \u2192+* mv_polynomial \u03c3 S).ker = f.ker.map (C : R \u2192+* mv_polynomial \u03c3 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] (\u03c3)\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 \u03c3] :\n  unique_factorization_monoid (mv_polynomial \u03c3 D) :=\n(rename_equiv D (fintype.equiv_fin \u03c3)).to_mul_equiv.symm.unique_factorization_monoid $\nbegin\n  induction fintype.card \u03c3 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 \u03c3 D) :=\nbegin\n  rw iff_exists_prime_factors,\n  intros a ha, obtain \u27e8s,a',rfl\u27e9 := exists_finset_rename a,\n  obtain \u27e8w,h,u,hw\u27e9 := iff_exists_prime_factors.1\n    (unique_factorization_monoid_of_fintype s) a' (\u03bb h, ha $ by simp [h]),\n  exact \u27e8 w.map (rename coe),\n    \u03bb b hb, let \u27e8b',hb',he\u27e9 := multiset.mem_map.1 hb in he \u25b8 (prime_rename_iff \u2191s).2 (h b' hb'),\n    units.map (@rename s \u03c3 D _ coe).to_ring_hom.to_monoid_hom u,\n    by erw [multiset.prod_hom, \u2190 map_mul, hw] \u27e9,\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 `\u03a0 i, f i` where `f : \u03b9 \u2192 C`. It is a\nlimit cone over the diagram formed by `f`, implemented by converting `f` into a functor\n`discrete \u03b9 \u2964 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\u2082 u u\u2082\n\nopen category_theory\n\nnamespace category_theory.limits\n\nvariables {\u03b2 : 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 : \u03b2 \u2192 C` consists of a collection of maps from an object `P` to every `f b`. -/\nabbreviation fan (f : \u03b2 \u2192 C) := cone (discrete.functor f)\n/-- A cofan over `f : \u03b2 \u2192 C` consists of a collection of maps from every `f b` to an object `P`. -/\nabbreviation cofan (f : \u03b2 \u2192 C) := cocone (discrete.functor f)\n\n/-- A fan over `f : \u03b2 \u2192 C` consists of a collection of maps from an object `P` to every `f b`. -/\n@[simps]\ndef fan.mk {f : \u03b2 \u2192 C} (P : C) (p : \u03a0 b, P \u27f6 f b) : fan f :=\n{ X := P,\n  \u03c0 := { app := \u03bb X, p X.as } }\n\n/-- A cofan over `f : \u03b2 \u2192 C` consists of a collection of maps from every `f b` to an object `P`. -/\n@[simps]\ndef cofan.mk {f : \u03b2 \u2192 C} (P : C) (p : \u03a0 b, f b \u27f6 P) : cofan f :=\n{ X := P,\n  \u03b9 := { app := \u03bb 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 : \u03b2 \u2192 C} (p : fan f) (j : \u03b2) : p.X \u27f6 f j := p.\u03c0.app (discrete.mk j)\n@[simp] lemma fan_mk_proj {f : \u03b2 \u2192 C} (P : C) (p : \u03a0 b, P \u27f6 f b) (j : \u03b2) :\n  (fan.mk P p).proj j = p j := rfl\n\n/-- An abbreviation for `has_limit (discrete.functor f)`. -/\nabbreviation has_product (f : \u03b2 \u2192 C) := has_limit (discrete.functor f)\n\n/-- An abbreviation for `has_colimit (discrete.functor f)`. -/\nabbreviation has_coproduct (f : \u03b2 \u2192 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 : \u03b2 \u2192 C} (t : fan f)\n  (lift : \u03a0 s : fan f, s.X \u27f6 t.X)\n  (fac : \u2200 (s : fan f) (j : \u03b2), lift s \u226b (t.proj j) = s.proj j)\n  (uniq : \u2200 (s : fan f) (m : s.X \u27f6 t.X) (w : \u2200 j : \u03b2, m \u226b t.proj j = s.proj j), m = lift s) :\n  is_limit t :=\n{ lift := lift,\n  fac' := \u03bb s j, by convert fac s j.as; simp,\n  uniq' := \u03bb s m w, uniq s m (\u03bb 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 (\u03b2 : Type v) := has_limits_of_shape.{v} (discrete \u03b2)\n/-- An abbreviation for `has_colimits_of_shape (discrete f)`. -/\nabbreviation has_coproducts_of_shape (\u03b2 : Type v) := has_colimits_of_shape.{v} (discrete \u03b2)\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 : \u03b2 \u2192 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 : \u03b2 \u2192 C) [has_coproduct f] := colimit (discrete.functor f)\n\nnotation `\u220f ` f:20 := pi_obj f\nnotation `\u2210 ` f:20 := sigma_obj f\n\n/-- The `b`-th projection from the pi object over `f` has the form `\u220f f \u27f6 f b`. -/\nabbreviation pi.\u03c0 (f : \u03b2 \u2192 C) [has_product f] (b : \u03b2) : \u220f f \u27f6 f b :=\nlimit.\u03c0 (discrete.functor f) (discrete.mk b)\n/-- The `b`-th inclusion into the sigma object over `f` has the form `f b \u27f6 \u2210 f`. -/\nabbreviation sigma.\u03b9 (f : \u03b2 \u2192 C) [has_coproduct f] (b : \u03b2) : f b \u27f6 \u2210 f :=\ncolimit.\u03b9 (discrete.functor f) (discrete.mk b)\n\n/-- The fan constructed of the projections from the product is limiting. -/\ndef product_is_product (f : \u03b2 \u2192 C) [has_product f] :\n  is_limit (fan.mk _ (pi.\u03c0 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 : \u03b2 \u2192 C) [has_coproduct f] :\n  is_colimit (cofan.mk _ (sigma.\u03b9 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 \u27f6 f b` induces a morphism `P \u27f6 \u220f f`. -/\nabbreviation pi.lift {f : \u03b2 \u2192 C} [has_product f] {P : C} (p : \u03a0 b, P \u27f6 f b) : P \u27f6 \u220f f :=\nlimit.lift _ (fan.mk P p)\n/-- A collection of morphisms `f b \u27f6 P` induces a morphism `\u2210 f \u27f6 P`. -/\nabbreviation sigma.desc {f : \u03b2 \u2192 C} [has_coproduct f] {P : C} (p : \u03a0 b, f b \u27f6 P) : \u2210 f \u27f6 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 : \u03b2 \u2192 C} [has_product f] [has_product g]\n  (p : \u03a0 b, f b \u27f6 g b) : \u220f f \u27f6 \u220f g :=\nlim_map (discrete.nat_trans (\u03bb X, p X.as))\n\ninstance pi.map_mono {f g : \u03b2 \u2192 C} [has_product f] [has_product g]\n  (p : \u03a0 b, f b \u27f6 g b) [\u03a0 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 : \u03b2 \u2192 C} [has_products_of_shape \u03b2 C]\n  (p : \u03a0 b, f b \u2245 g b) : \u220f f \u2245 \u220f g :=\nlim.map_iso (discrete.nat_iso (\u03bb 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 : \u03b2 \u2192 C} [has_coproduct f] [has_coproduct g]\n  (p : \u03a0 b, f b \u27f6 g b) : \u2210 f \u27f6 \u2210 g :=\ncolim_map (discrete.nat_trans (\u03bb X, p X.as))\n\ninstance sigma.map_epi {f g : \u03b2 \u2192 C} [has_coproduct f] [has_coproduct g]\n  (p : \u03a0 b, f b \u27f6 g b) [\u03a0 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 : \u03b2 \u2192 C} [has_coproducts_of_shape \u03b2 C]\n  (p : \u03a0 b, f b \u2245 g b) : \u2210 f \u2245 \u2210 g :=\ncolim.map_iso (discrete.nat_iso (\u03bb X, p X.as))\n\nsection comparison\n\nvariables {D : Type u\u2082} [category.{v\u2082} D] (G : C \u2964 D)\nvariables (f : \u03b2 \u2192 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 (\u03bb b, G.obj (f b))] :\n  G.obj (\u220f f) \u27f6 \u220f (\u03bb b, G.obj (f b)) :=\npi.lift (\u03bb b, G.map (pi.\u03c0 f b))\n\n@[simp, reassoc]\nlemma pi_comparison_comp_\u03c0 [has_product f] [has_product (\u03bb b, G.obj (f b))] (b : \u03b2) :\n  pi_comparison G f \u226b pi.\u03c0 _ b = G.map (pi.\u03c0 f b) :=\nlimit.lift_\u03c0 _ (discrete.mk b)\n\n@[simp, reassoc]\nlemma map_lift_pi_comparison [has_product f] [has_product (\u03bb b, G.obj (f b))]\n  (P : C) (g : \u03a0 j, P \u27f6 f j) :\n  G.map (pi.lift g) \u226b pi_comparison G f = pi.lift (\u03bb j, G.map (g j)) :=\nby { ext, discrete_cases, simp [\u2190 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 (\u03bb b, G.obj (f b))] :\n  \u2210 (\u03bb b, G.obj (f b)) \u27f6 G.obj (\u2210 f) :=\nsigma.desc (\u03bb b, G.map (sigma.\u03b9 f b))\n\n@[simp, reassoc]\nlemma \u03b9_comp_sigma_comparison [has_coproduct f] [has_coproduct (\u03bb b, G.obj (f b))] (b : \u03b2) :\n  sigma.\u03b9 _ b \u226b sigma_comparison G f = G.map (sigma.\u03b9 f b) :=\ncolimit.\u03b9_desc _ (discrete.mk b)\n\n@[simp, reassoc]\nlemma sigma_comparison_map_desc [has_coproduct f] [has_coproduct (\u03bb b, G.obj (f b))]\n  (P : C) (g : \u03a0 j, f j \u27f6 P) :\n  sigma_comparison G f \u226b G.map (sigma.desc g) = sigma.desc (\u03bb j, G.map (g j)) :=\nby { ext, discrete_cases, simp [\u2190 G.map_comp] }\n\nend comparison\n\nvariables (C)\n\n/-- An abbreviation for `\u03a0 J, has_limits_of_shape (discrete J) C` -/\nabbreviation has_products := \u03a0 (J : Type w), has_limits_of_shape (discrete J) C\n/-- An abbreviation for `\u03a0 J, has_colimits_of_shape (discrete J) C` -/\nabbreviation has_coproducts := \u03a0 (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\u03bb J, has_limits_of_shape_of_equivalence\n  (discrete.equivalence equiv.ulift : discrete (ulift.{w} J) \u224c _)\n\nlemma has_smallest_coproducts_of_has_coproducts [has_coproducts.{w} C] : has_coproducts.{0} C :=\n\u03bb J, has_colimits_of_shape_of_equivalence\n  (discrete.equivalence equiv.ulift : discrete (ulift.{w} J) \u224c _)\n\nlemma has_products_of_limit_fans (lf : \u2200 {J : Type w} (f : J \u2192 C), fan f)\n  (lf_is_limit : \u2200 {J : Type w} (f : J \u2192 C), is_limit (lf f)) : has_products.{w} C :=\n\u03bb (J : Type w), { has_limit := \u03bb F, has_limit.mk\n  \u27e8(cones.postcompose discrete.nat_iso_functor.inv).obj (lf (\u03bb j, F.obj \u27e8j\u27e9)),\n    (is_limit.postcompose_inv_equiv _ _).symm (lf_is_limit _)\u27e9 }\n\n/-!\n(Co)products over a type with a unique term.\n-/\nsection unique\nvariables {C} [unique \u03b2] (f : \u03b2 \u2192 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    \u03c0 := { app := \u03bb j, eq_to_hom (by { dsimp, congr, }), }, },\n  is_limit :=\n  { lift := \u03bb s, s.\u03c0.app default,\n    fac' := \u03bb s j, begin\n      have w := (s.\u03c0.naturality (eq_to_hom (unique.default_eq _))).symm,\n      dsimp at w,\n      simpa [eq_to_hom_map] using w,\n    end,\n    uniq' := \u03bb 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 : \u220f f \u2245 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    \u03b9 := { app := \u03bb j, eq_to_hom (by { discrete_cases, dsimp, congr, }), }, },\n  is_colimit :=\n  { desc := \u03bb s, s.\u03b9.app default,\n    fac' := \u03bb s j, begin\n      have w := (s.\u03b9.naturality (eq_to_hom (unique.eq_default _))),\n      dsimp at w,\n      simpa [eq_to_hom_map] using w,\n    end,\n    uniq' := \u03bb 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 : \u2210 f \u2245 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} {\u03b3 : Type v} (\u03b5 : \u03b2 \u2243 \u03b3) (f : \u03b3 \u2192 C)\n\nsection\nvariables [has_product f] [has_product (f \u2218 \u03b5)]\n\n/-- Reindex a categorical product via an equivalence of the index types. -/\ndef pi.reindex : pi_obj (f \u2218 \u03b5) \u2245 pi_obj f :=\nhas_limit.iso_of_equivalence (discrete.equivalence \u03b5) (discrete.nat_iso (\u03bb i, iso.refl _))\n\n@[simp, reassoc]\nlemma pi.reindex_hom_\u03c0 (b : \u03b2) : (pi.reindex \u03b5 f).hom \u226b pi.\u03c0 f (\u03b5 b) = pi.\u03c0 (f \u2218 \u03b5) b :=\nbegin\n  dsimp [pi.reindex],\n  simp only [has_limit.iso_of_equivalence_hom_\u03c0, 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 \u2218 \u03b5)) (discrete.eq_to_hom' (\u03b5.symm_apply_apply b)),\nend\n\n@[simp, reassoc]\nlemma pi.reindex_inv_\u03c0 (b : \u03b2) : (pi.reindex \u03b5 f).inv \u226b pi.\u03c0 (f \u2218 \u03b5) b = pi.\u03c0 f (\u03b5 b) :=\nby simp [iso.inv_comp_eq]\n\nend\n\nsection\nvariables [has_coproduct f] [has_coproduct (f \u2218 \u03b5)]\n\n/-- Reindex a categorical coproduct via an equivalence of the index types. -/\ndef sigma.reindex : sigma_obj (f \u2218 \u03b5) \u2245 sigma_obj f :=\nhas_colimit.iso_of_equivalence (discrete.equivalence \u03b5) (discrete.nat_iso (\u03bb i, iso.refl _))\n\n@[simp, reassoc]\nlemma sigma.\u03b9_reindex_hom (b : \u03b2) : sigma.\u03b9 (f \u2218 \u03b5) b \u226b (sigma.reindex \u03b5 f).hom = sigma.\u03b9 f (\u03b5 b) :=\nbegin\n  dsimp [sigma.reindex],\n  simp only [has_colimit.iso_of_equivalence_hom_\u03c0, 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    \u2190colimit.w (discrete.functor f) (discrete.eq_to_hom' (\u03b5.apply_symm_apply (\u03b5 b)))],\nend\n\n@[simp, reassoc]\nlemma sigma.\u03b9_reindex_inv (b : \u03b2) : sigma.\u03b9 f (\u03b5 b) \u226b (sigma.reindex \u03b5 f).inv = sigma.\u03b9 (f \u2218 \u03b5) 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\u2081 v\u2082 w w\u2081 w\u2082\n\n\n/-!\n\n# Reification of Dijkstra monads\n\nGiven a Dijkstra monad `M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type v` over a monad `W : Type u \u2192 Type w`, one sometimes wants to take the value of type `M \u03b1 w` into computation of a monad `m : Type u \u2192 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 \u03b1` and a \"specification\" `w : W \u03b1` can be represented by `X : M \u03b1 w`.\nSometimes, the specification `X` assures that the computation result of `x` actually lies in the subtype `{a : \u03b1 // p a}` rather than `\u03b1` for some predicate `p : \u03b1 \u2192 Prop`.\nIn other words, `X` enables to pass the result of `x` to the next computation of the form `(a : \u03b1) \u2192 p a \u2192 m \u03b2`.\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 \u2192 Type v`, a type `\u03b1 : Type u`, and a prediate `p : \u03b1 \u2192 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 (\u03b1 : Type u) (p : Pred \u03b1) \u2261 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 {\u03b1: Type u} {p : Pred \u03b1} : (a : \u03b1) \u2192 (h : p a) \u2192 SubtypeT m \u03b1 p :=\n  \u03bb a h => return (Subtype.mk a h)\n\ndef weaken {\u03b1 :Type u} {p q : Pred \u03b1} : MonadRel.rel p q \u2192 SubtypeT m \u03b1 p \u2192 SubtypeT m \u03b1 q :=\n  \u03bb hpq x => x >>= \u03bb a => return \u27e8a.val, hpq a.val a.property\u27e9\n```\n\n-/\n\ndef SubtypeT (m : Type u \u2192 Type v) (\u03b1 : Type u) (p : Pred \u03b1) : Type v := m (Subtype p)\n\nnamespace SubtypeT\n\nvariable {m : Type u \u2192 Type v} [Monad m]\n\ninstance instDijkstraMonadSubtypeT : DijkstraMonad Pred (SubtypeT m) where\n  dpure a := pure \u27e8a,rfl\u27e9\n  dbind x f := x >>= \u03bb a => f a.val >>= \u03bb b => return \u27e8b, \u27e8a, a.property, b.property\u27e9\u27e9\n\ndef pureMk {\u03b1 : Type u} {p : Pred \u03b1} (a : \u03b1) (h : p a) : SubtypeT m \u03b1 p :=\n  pure \u27e8a,h\u27e9\n\ndef weaken {\u03b1 : Type u} {p q : Pred \u03b1} (hpq : mrel p q) (x : SubtypeT m \u03b1 p) : SubtypeT m \u03b1 q :=\n  x >>= \u03bb a => return \u27e8a.val, hpq a a.property\u27e9\n\ntheorem deq_of_iff [LawfulMonad m] {\u03b1 : Type u} {p q : Pred \u03b1} (hpq : \u2200 a, p a \u2194 q a) : \u2200 (x : SubtypeT m \u03b1 p), DEq (SubtypeT m \u03b1) x (x.weaken \u03bb a => (hpq a).mp) := by\n  have : p = q := funext (\u03bb 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 \u03b1 p x\n    dsimp [dbind, dpure]\n    conv =>\n      lhs; rhs; ext a; rw [pure_bind]; dsimp [pure]\n    have : \u2200 a, (p >>= pure) a \u2194 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 \u03b1 \u03b2 wf a f\n    dsimp [dbind, dpure]\n    conv => lhs; rw [pure_bind]; dsimp\n    have : \u2200 a\u2081, (pure a >>= wf) a\u2081 \u2194 wf a a\u2081 := 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 \u03b1 \u03b2 \u03b3 wa wf wg x f g\n    have : \u2200 c, (wa >>= wf >>= wg) c \u2194 (wa >>= \u03bb 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 \u2192 Type v\u2081} [Monad W] {Z : Type u \u2192 Type v\u2082} [Monad Z] (r : MonadRel W Z) (M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type w\u2081) [DijkstraMonad W M] (N : (\u03b1 : Type u) \u2192 Z \u03b1 \u2192 Type w\u2082) [DijkstraMonad Z N] where\n  dLift {\u03b1 : Type u} {w : W \u03b1} {z : Z \u03b1} : r.rel w z \u2192 M \u03b1 w \u2192 N \u03b1 z\n\n/-- Axioms for Dijkstra lifts -/\nclass DijkstraLift.Lawful {W : Type u \u2192 Type v\u2081} [Monad W] {Z : Type u \u2192 Type v\u2082} [Monad Z] (r : MonadRel W Z) (M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type w\u2081) [DijkstraMonad W M] (N : (\u03b1 : Type u) \u2192 Z \u03b1 \u2192 Type w\u2082) [DijkstraMonad Z N] [DijkstraLift r M N] where\n  -- Compatibility with `DijkstraMonad.dpure`\n  dLift_dpure {\u03b1 : Type u} (a : \u03b1) : dLift (r.pure a) (dpure (M:=M) a) = dpure (M:=N) a\n  -- Compatibility with `DijkstraMonad.dbind`\n  dLift_dbind {\u03b1 \u03b2 : Type u} {wa : W \u03b1} {wf : \u03b1 \u2192 W \u03b2} {za : Z \u03b1} {zf : \u03b1 \u2192 Z \u03b2} {ha : r.rel wa za} {hf : \u2200 a, r.rel (wf a) (zf a)} (x : M \u03b1 wa) (f : (a : \u03b1) \u2192 M \u03b2 (wf a)) : dLift (r.bind ha hf) (dbind (M:=M) x f) = dbind (M:=N) (dLift ha x) \u03bb 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 \u2261 \u2200 a, p a \u2192 q a`. -/\ninstance instDijkstraLiftSubtypeTweaken (m : Type u \u2192 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 \u2192 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 : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 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 \u2192 Type w` is called a ***reification of `M`*** with respect to `r` if there is a Dijkstra lift `reify : r w p \u2192 M \u03b1 w \u2192 SubtypeT m p` which satisfies the follogin conditions.\n\n```lean\nreify_weaken {\u03b1 : Type u} {p q : Pred \u03b1} (hpq : \u2200 a, p a \u2192 q a): \u2200 {wp : WPPure \u03b1} {x : M \u03b1 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 \u2192 Type w} [Monad W] [SpecMonad W] (r : SpecMonadRel W Pred) (M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type v) [DijkstraMonad W M] (m : Type u \u2192 Type v\u2081) [Monad m] extends DijkstraLift r.toMonadRel M (SubtypeT m)\n\ndef reify {W : Type u \u2192 Type w} [Monad W] [SpecMonad W] {r : SpecMonadRel W Pred} {M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type v} [DijkstraMonad W M] {m : Type u \u2192 Type v\u2081} [Monad m] [self : Reification r M m] {\u03b1 : Type u} {w : W \u03b1} (p : Pred \u03b1) : r.rel w p \u2192 M \u03b1 w \u2192 SubtypeT m \u03b1 p :=\n  self.dLift\n\n/-- The axioms for reification -/\nclass Reification.Lawful {W : Type u \u2192 Type w} [Monad W] [SpecMonad W] (r : SpecMonadRel W Pred) (M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type v) [DijkstraMonad W M] (m : Type u \u2192 Type v\u2081) [Monad m] [Reification r M m] extends DijkstraLift.Lawful r.toMonadRel M (SubtypeT m) where\n  --- `reify` and `weaken`\n  reify_weaken {\u03b1 : Type u} {wa : W \u03b1} {p q : Pred \u03b1} (hpq : mrel p q) : \u2200 {x : M \u03b1 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 \u2192 Type w} [Monad W] [SpecMonad W] {r : SpecMonadRel W Pred} {M : (\u03b1 :Type u) \u2192 W \u03b1 \u2192 Type v} [DijkstraMonad W M] {m :Type u \u2192 Type v\u2081} [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 {\u03b1 : Type u} (a : \u03b1) : 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 {\u03b1 \u03b2 : Type u} {wa : W \u03b1} {wf : \u03b1 \u2192 W \u03b2} {pa : Pred \u03b1} {pf : \u03b1 \u2192 Pred \u03b2} {ha : r.rel wa pa} {hf : \u2200 a, r.rel (wf a) (pf a)} (x : M \u03b1 wa) (f : (a : \u03b1) \u2192 M \u03b2 (wf a)) : reify (M:=M) (pa >>= pf) (r.bind ha hf) (dbind x f) = dbind (M:=SubtypeT m) (reify (M:=M) pa ha x) (\u03bb 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\u00f4pital'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 `\ud835\udcdd a`,\n`at_top` or `at_bot`. In fact, we give a slightly stronger statement by\nallowing it to be any filter on `\u211d`.\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\u00f4pital's rule, L'Hopital's rule\n-/\n\nopen filter set\nopen_locale filter topological_space pointwise\n\nvariables {a b : \u211d} (hab : a < b) {l : filter \u211d} {f f' g g' : \u211d \u2192 \u211d}\n\n/-!\n## Interval-based versions\n\nWe start by proving statements where all conditions (derivability, `g' \u2260 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[Ioi a] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[Ioi a] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[Ioi a] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[Ioi a] a) l :=\nbegin\n  have sub : \u2200 x \u2208 Ioo a b, Ioo a x \u2286 Ioo a b := \u03bb x hx, Ioo_subset_Ioo (le_refl a) (le_of_lt hx.2),\n  have hg : \u2200 x \u2208 (Ioo a b), g x \u2260 0,\n  { intros x hx h,\n    have : tendsto g (\ud835\udcdd[Iio x] x) (\ud835\udcdd 0),\n    { rw [\u2190 h, \u2190 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 \u27e8y, hyx, hy\u27e9 : \u2203 c \u2208 Ioo a x, g' c = 0,\n      from exists_has_deriv_at_eq_zero' hx.1 hga this (\u03bb y hy, hgg' y $ sub x hx hy),\n    exact hg' y (sub x hx hyx) hy },\n  have : \u2200 x \u2208 Ioo a b, \u2203 c \u2208 Ioo a x, (f x) * (g' c) = (g x) * (f' c),\n  { intros x hx,\n    rw [\u2190 sub_zero (f x), \u2190 sub_zero (g x)],\n    exact exists_ratio_has_deriv_at_eq_ratio_slope' g g' hx.1 f f'\n      (\u03bb y hy, hgg' y $ sub x hx hy) (\u03bb 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 : \u2200 x \u2208 Ioo a b, ((\u03bb x', (f' x') / (g' x')) \u2218 c) x = f x / g x,\n  { intros x hx,\n    rcases hc x hx with \u27e8h\u2081, h\u2082\u27e9,\n    field_simp [hg x hx, hg' (c x) ((sub x hx) h\u2081)],\n    simp only [h\u2082],\n    rwa mul_comm },\n  have cmp : \u2200 x \u2208 Ioo a b, a < c x \u2227 c x < x,\n    from \u03bb x hx, (hc x hx).1,\n  rw \u2190 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 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' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (nhds_within a (Ioi a)) l) :\n  tendsto (\u03bb 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 [\u2190 hfa, \u2190 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 [\u2190 hga, \u2190 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioo a b, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfb : tendsto f (nhds_within b (Iio b)) (\ud835\udcdd 0)) (hgb : tendsto g (nhds_within b (Iio b)) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (nhds_within b (Iio b)) l) :\n  tendsto (\u03bb 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 : \u2200 x \u2208 -Ioo a b, has_deriv_at (f \u2218 has_neg.neg) (f' (-x) * (-1)) x,\n    from \u03bb x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : \u2200 x \u2208 -Ioo a b, has_deriv_at (g \u2218 has_neg.neg) (g' (-x) * (-1)) x,\n    from \u03bb 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 \u2190 preimage_neg_Ioo at hx, exact hx}),\n          rwa [mul_comm, \u2190 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 $ \u03bb 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' : \u2200 x \u2208 Ioo a b, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 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' : \u2200 x \u2208 Ioo a b, g' x \u2260 0)\n  (hfb : f b = 0) (hgb : g b = 0)\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (nhds_within b (Iio b)) l) :\n  tendsto (\u03bb 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 [\u2190 hfb, \u2190 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 [\u2190 hgb, \u2190 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' : \u2200 x \u2208 Ioi a, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Ioi a, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Ioi a, g' x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  obtain \u27e8 a', haa', ha'\u27e9 : \u2203 a', a < a' \u2227 0 < a' :=\n    \u27e81 + max a 0, \u27e8lt_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 _)\u27e9\u27e9,\n  have fact1 : \u2200 (x:\u211d), x \u2208 Ioo 0 a'\u207b\u00b9 \u2192 x \u2260 0 := \u03bb _ hx, (ne_of_lt hx.1).symm,\n  have fact2 : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, a < x\u207b\u00b9,\n    from \u03bb _ hx, lt_trans haa' ((lt_inv ha' hx.1).mpr hx.2),\n  have hdnf : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, has_deriv_at (f \u2218 has_inv.inv) (f' (x\u207b\u00b9) * (-(x^2)\u207b\u00b9)) x,\n    from \u03bb x hx, comp x (hff' (x\u207b\u00b9) $ fact2 x hx) (has_deriv_at_inv $ fact1 x hx),\n  have hdng : \u2200 x \u2208 Ioo 0 a'\u207b\u00b9, has_deriv_at (g \u2218 has_inv.inv) (g' (x\u207b\u00b9) * (-(x^2)\u207b\u00b9)) x,\n    from \u03bb x hx, comp x (hgg' (x\u207b\u00b9) $ 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\u2080],\nend\n\ntheorem lhopital_zero_at_bot_on_Iio\n  (hff' : \u2200 x \u2208 Iio a, has_deriv_at f (f' x) x) (hgg' : \u2200 x \u2208 Iio a, has_deriv_at g (g' x) x)\n  (hg' : \u2200 x \u2208 Iio a, g' x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_bot l) :\n  tendsto (\u03bb 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 : \u2200 x \u2208 -Iio a, has_deriv_at (f \u2218 has_neg.neg) (f' (-x) * (-1)) x,\n    from \u03bb x hx, comp x (hff' (-x) hx) (has_deriv_at_neg x),\n  have hdng : \u2200 x \u2208 -Iio a, has_deriv_at (g \u2218 has_neg.neg) (g' (-x) * (-1)) x,\n    from \u03bb 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 \u2190 preimage_neg_Iio at hx, exact hx}),\n          rwa [mul_comm, \u2190 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 $ \u03bb 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 \u211d f (Ioo a b)) (hg' : \u2200 x \u2208 Ioo a b, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[Ioi a] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[Ioi a] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[Ioi a] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[Ioi a] a) l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioo a b, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : \u2200 x \u2208 Ioo a b, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_right_on_Ioo hab (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb x hx, (hdg x hx).has_deriv_at) hg' hfa hga hdiv\nend\n\ntheorem lhopital_zero_right_on_Ico\n  (hdf : differentiable_on \u211d f (Ioo a b))\n  (hcf : continuous_on f (Ico a b)) (hcg : continuous_on g (Ico a b))\n  (hg' : \u2200 x \u2208 (Ioo a b), (deriv g) x \u2260 0)\n  (hfa : f a = 0) (hga : g a = 0)\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (nhds_within a (Ioi a)) l) :\n  tendsto (\u03bb 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 [\u2190 hfa, \u2190 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 [\u2190 hga, \u2190 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 \u211d f (Ioo a b))\n  (hg' : \u2200 x \u2208 (Ioo a b), (deriv g) x \u2260 0)\n  (hfb : tendsto f (nhds_within b (Iio b)) (\ud835\udcdd 0)) (hgb : tendsto g (nhds_within b (Iio b)) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (nhds_within b (Iio b)) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (nhds_within b (Iio b)) l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioo a b, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioo_mem_nhds hx.1 hx.2),\n  have hdg : \u2200 x \u2208 Ioo a b, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_left_on_Ioo hab (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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 \u211d f (Ioi a))\n  (hg' : \u2200 x \u2208 (Ioi a), (deriv g) x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  have hdf : \u2200 x \u2208 Ioi a, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Ioi_mem_nhds hx),\n  have hdg : \u2200 x \u2208 Ioi a, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_top_on_Ioi (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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 \u211d f (Iio a))\n  (hg' : \u2200 x \u2208 (Iio a), (deriv g) x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdf : \u2200 x \u2208 Iio a, differentiable_at \u211d f x,\n    from \u03bb x hx, (hdf x hx).differentiable_at (Iio_mem_nhds hx),\n  have hdg : \u2200 x \u2208 Iio a, differentiable_at \u211d g x,\n    from \u03bb x hx, classical.by_contradiction (\u03bb h, hg' x hx (deriv_zero_of_not_differentiable_at h)),\n  exact has_deriv_at.lhopital_zero_at_bot_on_Iio (\u03bb x hx, (hdf x hx).has_deriv_at)\n    (\u03bb 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\u00f4pital's rule for approaching a real from the right, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_right\n  (hff' : \u2200\u1da0 x in \ud835\udcdd[Ioi a] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[Ioi a] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[Ioi a] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[Ioi a] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[Ioi a] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[Ioi a] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[Ioi a] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 \ud835\udcdd[Ioi a] a := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_nhds_within_Ioi_iff_exists_Ioo_subset at hs,\n  rcases hs with \u27e8u, hau, hu\u27e9,\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\u00f4pital's rule for approaching a real from the left, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds_left\n  (hff' : \u2200\u1da0 x in \ud835\udcdd[Iio a] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[Iio a] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[Iio a] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[Iio a] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[Iio a] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[Iio a] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[Iio a] a) l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 \ud835\udcdd[Iio a] a := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_nhds_within_Iio_iff_exists_Ioo_subset at hs,\n  rcases hs with \u27e8l, hal, hl\u27e9,\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\u00f4pital'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' : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[univ \\ {a}] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[univ \\ {a}] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) (\ud835\udcdd[univ \\ {a}] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[univ \\ {a}] a) l :=\nbegin\n  have : univ \\ {a} = Iio a \u222a 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 \u27e8lhopital_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\u27e9\nend\n\n/-- **L'H\u00f4pital's rule** for approaching a real, `has_deriv_at` version -/\ntheorem lhopital_zero_nhds\n  (hff' : \u2200\u1da0 x in \ud835\udcdd a, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in \ud835\udcdd a, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd a, g' x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, f' x / g' x) (\ud835\udcdd a) l) :\n  tendsto (\u03bb x, f x / g x) (\ud835\udcdd[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\u00f4pital's rule for approaching +\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_top\n  (hff' : \u2200\u1da0 x in at_top, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in at_top, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in at_top, g' x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 at_top := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_at_top_sets at hs,\n  rcases hs with \u27e8l, hl\u27e9,\n  have hl' : Ioi l \u2286 s := \u03bb x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_top_on_Ioi _ _ (\u03bb 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\u00f4pital's rule for approaching -\u221e, `has_deriv_at` version -/\ntheorem lhopital_zero_at_bot\n  (hff' : \u2200\u1da0 x in at_bot, has_deriv_at f (f' x) x)\n  (hgg' : \u2200\u1da0 x in at_bot, has_deriv_at g (g' x) x)\n  (hg' : \u2200\u1da0 x in at_bot, g' x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, (f' x) / (g' x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  rw eventually_iff_exists_mem at *,\n  rcases hff' with \u27e8s\u2081, hs\u2081, hff'\u27e9,\n  rcases hgg' with \u27e8s\u2082, hs\u2082, hgg'\u27e9,\n  rcases hg' with \u27e8s\u2083, hs\u2083, hg'\u27e9,\n  let s := s\u2081 \u2229 s\u2082 \u2229 s\u2083,\n  have hs : s \u2208 at_bot := inter_mem (inter_mem hs\u2081 hs\u2082) hs\u2083,\n  rw mem_at_bot_sets at hs,\n  rcases hs with \u27e8l, hl\u27e9,\n  have hl' : Iio l \u2286 s := \u03bb x hx, hl x (le_of_lt hx),\n  refine lhopital_zero_at_bot_on_Iio _ _ (\u03bb 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\u00f4pital's rule** for approaching a real from the right, `deriv` version -/\ntheorem lhopital_zero_nhds_right\n  (hdf : \u2200\u1da0 x in \ud835\udcdd[Ioi a] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[Ioi a] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[Ioi a] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[Ioi a] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[Ioi a] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[Ioi a] a) l :=\nbegin\n  have hdg : \u2200\u1da0 x in \ud835\udcdd[Ioi a] a, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in \ud835\udcdd[Ioi a] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in \ud835\udcdd[Ioi a] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital's rule** for approaching a real from the left, `deriv` version -/\ntheorem lhopital_zero_nhds_left\n  (hdf : \u2200\u1da0 x in \ud835\udcdd[Iio a] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[Iio a] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[Iio a] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[Iio a] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[Iio a] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[Iio a] a) l :=\nbegin\n  have hdg : \u2200\u1da0 x in \ud835\udcdd[Iio a] a, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in \ud835\udcdd[Iio a] a, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in \ud835\udcdd[Iio a] a, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital'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 : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd[univ \\ {a}] a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd[univ \\ {a}] a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd[univ \\ {a}] a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd[univ \\ {a}] a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[univ \\ {a}] a) l :=\nbegin\n  have : univ \\ {a} = Iio a \u222a 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 \u27e8lhopital_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\u27e9,\nend\n\n/-- **L'H\u00f4pital's rule** for approaching a real, `deriv` version -/\ntheorem lhopital_zero_nhds\n  (hdf : \u2200\u1da0 x in \ud835\udcdd a, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 x in \ud835\udcdd a, deriv g x \u2260 0)\n  (hfa : tendsto f (\ud835\udcdd a) (\ud835\udcdd 0)) (hga : tendsto g (\ud835\udcdd a) (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) (\ud835\udcdd a) l) :\n  tendsto (\u03bb x, (f x) / (g x)) (\ud835\udcdd[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\u00f4pital's rule** for approaching +\u221e, `deriv` version -/\ntheorem lhopital_zero_at_top\n  (hdf : \u2200\u1da0 (x : \u211d) in at_top, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 (x : \u211d) in at_top, deriv g x \u2260 0)\n  (hftop : tendsto f at_top (\ud835\udcdd 0)) (hgtop : tendsto g at_top (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_top l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_top l :=\nbegin\n  have hdg : \u2200\u1da0 x in at_top, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in at_top, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in at_top, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00f4pital's rule** for approaching -\u221e, `deriv` version -/\ntheorem lhopital_zero_at_bot\n  (hdf : \u2200\u1da0 (x : \u211d) in at_bot, differentiable_at \u211d f x)\n  (hg' : \u2200\u1da0 (x : \u211d) in at_bot, deriv g x \u2260 0)\n  (hfbot : tendsto f at_bot (\ud835\udcdd 0)) (hgbot : tendsto g at_bot (\ud835\udcdd 0))\n  (hdiv : tendsto (\u03bb x, ((deriv f) x) / ((deriv g) x)) at_bot l) :\n  tendsto (\u03bb x, (f x) / (g x)) at_bot l :=\nbegin\n  have hdg : \u2200\u1da0 x in at_bot, differentiable_at \u211d g x,\n    from hg'.mp (eventually_of_forall $\n      \u03bb _ hg', classical.by_contradiction (\u03bb h, hg' (deriv_zero_of_not_differentiable_at h))),\n  have hdf' : \u2200\u1da0 x in at_bot, has_deriv_at f (deriv f x) x,\n    from hdf.mp (eventually_of_forall $ \u03bb _, differentiable_at.has_deriv_at),\n  have hdg' : \u2200\u1da0 x in at_bot, has_deriv_at g (deriv g x) x,\n    from hdg.mp (eventually_of_forall $ \u03bb _, 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\u00ebl Dillies, Bhavik Mehta. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl Dillies, Bhavik Mehta\n-/\nimport analysis.specific_limits\nimport combinatorics.simplicial_complex.basic\nimport set_theory.fincard\n\nopen affine set\n\nvariables {m : \u2115} {E : Type*} [normed_group E] [normed_space \u211d E]\n  {S\u2081 S\u2082 : simplicial_complex E}\n\n/--\nS\u2081 \u2264 S\u2082 (S\u2081 is a subdivision of S\u2082) iff their underlying space is the same and each face of S\u2081 is\ncontained in some face of S\u2082\n-/\ninstance : has_le (simplicial_complex E) := \u27e8\u03bb S\u2081 S\u2082, S\u2081.space = S\u2082.space \u2227\n  \u2200 {X\u2081 : finset  E}, X\u2081 \u2208 S\u2081.faces \u2192 \u2203 X\u2082 \u2208 S\u2082.faces,\n  convex_hull (X\u2081 : set E) \u2286 convex_hull (X\u2082 : set E)\u27e9\n\nlemma subdivision_iff_combi_interiors_subset_combi_interiors :\n  S\u2081 \u2264 S\u2082 \u2194 S\u2082.space \u2286 S\u2081.space \u2227\n  \u2200 {X\u2081}, X\u2081 \u2208 S\u2081.faces \u2192 \u2203 {X\u2082}, X\u2082 \u2208 S\u2082.faces \u2227 combi_interior X\u2081 \u2286 combi_interior X\u2082 :=\nbegin\n  split,\n  { rintro \u27e8hspace, hS\u27e9,\n    use ge_of_eq hspace,\n    rintro X hX,\n    obtain \u27e8Y, hY, hXY\u27e9 := hS hX,\n    obtain \u27e8Z, hZY, hXZ\u27e9 := simplex_combi_interiors_split_interiors (S\u2082.indep hY) hXY,\n    exact \u27e8Z, S\u2082.down_closed hY hZY, hXZ\u27e9 },\n  { rintro \u27e8hspace, hS\u27e9,\n    split,\n    { apply subset.antisymm _ hspace,\n      rintro x hx,\n      obtain \u27e8X\u2081, hX\u2081, hx\u27e9 := mem_space_iff.1 hx,\n      obtain \u27e8X\u2082, hX\u2082, hX\u2081X\u2082\u27e9 := hS hX\u2081,\n      rw mem_space_iff,\n      refine \u27e8X\u2082, hX\u2082, _\u27e9,\n      apply convex_hull_subset_convex_hull_of_combi_interior_subset_combi_interior _ _ hX\u2081X\u2082 hx,\n      { apply S\u2081.indep hX\u2081 },\n      { apply S\u2082.indep hX\u2082 } },\n    { rintro X\u2081 hX\u2081,\n      obtain \u27e8X\u2082, hX\u2082, hX\u2081X\u2082\u27e9 := hS hX\u2081,\n      refine \u27e8_, hX\u2082, convex_hull_subset_convex_hull_of_combi_interior_subset_combi_interior _ _ _\u27e9,\n      { apply S\u2081.indep hX\u2081 },\n      { apply S\u2082.indep hX\u2082 },\n      { apply hX\u2081X\u2082 }}}\nend\n\nlemma subdivision_iff_partition :\n  S\u2081 \u2264 S\u2082 \u2194 (S\u2081.faces.nonempty \u2192 S\u2082.faces.nonempty) \u2227 S\u2081.space \u2286 S\u2082.space \u2227 \u2200 {X\u2082}, X\u2082 \u2208 S\u2082.faces \u2192\n  \u2203 {F}, F \u2286 S\u2081.faces \u2227 combi_interior X\u2082 = \u22c3 (X\u2081 \u2208 F), combi_interior X\u2081 :=\nbegin\n  split,\n  { rintro \u27e8hspace, hsubdiv\u27e9,\n    split,\n    { rintro \u27e8X\u2081, hX\u2081\u27e9,\n      obtain \u27e8X\u2082, hX\u2082, hX\u2081X\u2082\u27e9 := hsubdiv hX\u2081,\n      exact \u27e8X\u2082, hX\u2082\u27e9 },\n    use le_of_eq hspace,\n    rintro X hX,\n    use [{Y | Y \u2208 S\u2081.faces \u2227 combi_interior Y \u2286 combi_interior X}, (\u03bb Y hY, hY.1)],\n    ext x,\n    split,\n    { rintro hxX,\n      have hxspace := mem_space_iff.2 \u27e8X, hX, hxX.1\u27e9,\n      rw [\u2190hspace, combi_interiors_cover, mem_bUnion_iff] at hxspace,\n      obtain \u27e8Y, hY, hxY\u27e9 := hxspace,\n      apply mem_bUnion _ hxY,\n      use hY,\n      rintro y hyY,\n      obtain \u27e8Z, hZ, hYZ\u27e9 := hsubdiv hY,\n      obtain \u27e8W, hWZ, hYW\u27e9 := simplex_combi_interiors_split_interiors (S\u2082.indep hZ) hYZ,\n      rw disjoint_interiors hX (S\u2082.down_closed hZ hWZ) hxX (hYW hxY),\n      exact hYW hyY },\n    { rw mem_bUnion_iff,\n      rintro \u27e8Y, \u27e8hY, hYX\u27e9, hxY\u27e9,\n      exact hYX hxY }},\n  { rintro \u27e8hempty, hspace, hpartition\u27e9,\n    have hspace : S\u2081.space = S\u2082.space,\n    { apply subset.antisymm hspace,\n      rintro x hx,\n      rw [combi_interiors_cover, mem_bUnion_iff] at \u22a2 hx,\n      obtain \u27e8X, hX, hxX\u27e9 := hx,\n      obtain \u27e8F, hF, hXint\u27e9 := hpartition hX,\n      rw [hXint, mem_bUnion_iff] at hxX,\n      obtain \u27e8Y, hY, hxY\u27e9 := hxX,\n      exact \u27e8Y, hF hY, hxY\u27e9 },\n    use hspace,\n    rintro X hX,\n    cases finset.eq_empty_or_nonempty X with hXempty hXnonempty,\n    { obtain \u27e8Y, hY\u27e9 := hempty \u27e8X, hX\u27e9,\n      use [Y, hY],\n      rw hXempty,\n      simp },\n    obtain \u27e8x, hx\u27e9 := nonempty_combi_interior_of_nonempty (S\u2081.indep hX) hXnonempty,\n    have hxspace := mem_space_iff.2 \u27e8X, hX, hx.1\u27e9,\n    rw [hspace, combi_interiors_cover, mem_bUnion_iff] at hxspace,\n    obtain \u27e8Y, hY, hxY\u27e9 := hxspace,\n    use [Y, hY],\n    rw \u2190closure_combi_interior_eq_convex_hull (S\u2081.indep hX),\n    apply closure_minimal _ is_closed_convex_hull,\n    rintro x' hx',\n    have hxspace := mem_space_iff.2 \u27e8X, hX, hx'.1\u27e9,\n    rw [hspace, combi_interiors_cover, mem_bUnion_iff] at hxspace,\n    obtain \u27e8Y', hY', hxY'\u27e9 := hxspace,\n    suffices hYY' : Y = Y',\n    { rw hYY',\n      exact hxY'.1 },\n    obtain \u27e8F, hF, hinterior\u27e9 := hpartition hY,\n    obtain \u27e8F', hF', hinterior'\u27e9 := hpartition hY',\n    apply disjoint_interiors hY hY' (_ : x \u2208 _) _,\n    { rw [hinterior, mem_bUnion_iff] at \u22a2 hxY,\n      obtain \u27e8Z, hZ, hxZ\u27e9 := hxY,\n      use [Z, hZ, hxZ] },\n    { rw [hinterior', mem_bUnion_iff] at \u22a2 hxY',\n      obtain \u27e8Z, hZ, hxZ\u27e9 := hxY',\n      use [Z, hZ],\n      rw \u2190disjoint_interiors hX (hF' hZ) hx' hxZ,\n      exact hx }}\nend\n\ninstance : partial_order (simplicial_complex E) :=\n{ le := \u03bb S\u2081 S\u2082, S\u2081 \u2264 S\u2082,\n  le_refl := (\u03bb S, \u27e8rfl, (\u03bb X hX, \u27e8X, hX, subset.refl _\u27e9)\u27e9),\n  le_trans := begin\n    rintro S\u2081 S\u2082 S\u2083 h\u2081\u2082 h\u2082\u2083,\n    use eq.trans h\u2081\u2082.1 h\u2082\u2083.1,\n    rintro X\u2081 hX\u2081,\n    obtain \u27e8X\u2082, hX\u2082, hX\u2081\u2082\u27e9 := h\u2081\u2082.2 hX\u2081,\n    obtain \u27e8X\u2083, hX\u2083, hX\u2082\u2083\u27e9 := h\u2082\u2083.2 hX\u2082,\n    exact \u27e8X\u2083, hX\u2083, subset.trans hX\u2081\u2082 hX\u2082\u2083\u27e9,\n  end,\n  le_antisymm := begin\n    suffices aux_lemma : \u2200 {S\u2081 S\u2082 : simplicial_complex E}, S\u2081 \u2264 S\u2082 \u2192 S\u2082 \u2264 S\u2081 \u2192 \u2200 {X},\n      X \u2208 S\u2081.faces \u2192 X \u2208 S\u2082.faces,\n    { rintro S\u2081 S\u2082 h\u2081 h\u2082,\n      ext X,\n      exact \u27e8\u03bb hX, aux_lemma h\u2081 h\u2082 hX, \u03bb hX, aux_lemma h\u2082 h\u2081 hX\u27e9 },\n    rintro S\u2081 S\u2082 h\u2081 h\u2082 X hX,\n    rw subdivision_iff_partition at h\u2082 h\u2081,\n    cases finset.eq_empty_or_nonempty X with hXempty hXnonempty,\n    { rw hXempty,\n      exact empty_mem_faces_of_nonempty (h\u2081.1 \u27e8X, hX\u27e9) },\n    obtain \u27e8x, hxX\u27e9 := nonempty_combi_interior_of_nonempty (S\u2081.indep hX) hXnonempty,\n    obtain \u27e8F, hF, hFX\u27e9 := h\u2082.2.2 hX,\n    have hxX' := hxX,\n    rw [hFX, mem_bUnion_iff] at hxX',\n    obtain \u27e8Y, hY, hxY\u27e9 := hxX',\n    obtain \u27e8F', hF', hF'Y\u27e9 := h\u2081.2.2 (hF hY),\n    rw [hF'Y, mem_bUnion_iff] at hxY,\n    obtain \u27e8Z, hZ, hxZ\u27e9 := 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\u2081.indep hX) (S\u2082.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) : \u211d := sorry --max diameter of simplices\n\ndef barycentrisation : list (fin m \u2192 \u211d) \u2192 fin m \u2192 \u211d :=\n  \u03bb L,\n\ndef simplicial_complex.barycentric_subdivision (S : simplicial_complex E) : simplicial_complex E :=\n{ faces := {X | \u2203 {L : list (fin m \u2192 \u211d)}, list.to_finset L \u2208 S.faces \u2227 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 \u2113\u2081 \u2113\u2082 \u2113\u2083 \u2113\u2084 \u2113obj \u2113hom \u2113obj\u2081 \u2113hom\u2081 \u2113obj\u2082 \u2113hom\u2082 \u2113obj\u2083 \u2113hom\u2083 \u2113obj\u2084 \u2113hom\u2084 \u2113obj\u2085 \u2113hom\u2085\n\n/-! #brief A functor between categories.\n-/\nstructure Fun (C : Cat.{\u2113obj\u2081 \u2113hom\u2081}) (D : Cat.{\u2113obj\u2082 \u2113hom\u2082})\n    : Type (max \u2113obj\u2081 \u2113hom\u2081 \u2113obj\u2082 \u2113hom\u2082)\n:= (obj : C^.obj \u2192 D^.obj)\n   (hom : \u2200 {x y : C^.obj}, C^.hom x y \u2192 D^.hom (obj x) (obj y))\n   (hom_id : \u2200 {x : C^.obj}, hom \u27e8\u27e8x\u27e9\u27e9 = \u27e8\u27e8obj x\u27e9\u27e9)\n   (hom_circ : \u2200 {x y z : C^.obj}\n                 {g : C^.hom y z} {f : C^.hom x y}\n               , hom (g \u2218\u2218 f) = hom g \u2218\u2218 hom f)\n\nattribute [simp] Fun.hom_id\n\n-- A functor between categories.\n-- \\rightrightarrows\nnotation C `\u21c9` D := Fun C D\n\n/-! #brief Helper for proving two functors are equal.\n-/\ntheorem Fun.eq {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    : \u2200 {F G : Fun C D}\n        (\u03c9obj : \u2200 (x : C^.obj), F^.obj x = G^.obj x)\n        (\u03c9hom : \u2200 (\u03c9 : \u2200 (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  \u03c9obj \u03c9hom\n:= begin\n     assert \u03c9obj' : Fobj = Gobj, { exact funext \u03c9obj },\n     subst \u03c9obj',\n     assert \u03c9hom' : @Fhom = @Ghom,\n     { apply funext, intro x,\n       apply funext, intro y,\n       apply funext, intro f,\n       apply eq_of_heq,\n       apply \u03c9hom \u03c9obj\n     },\n     subst \u03c9hom'\n   end\n\n/-! #brief Helper for proving two functors are heterogeneously equal.\n-/\ntheorem Fun.heq\n    : \u2200 {C\u2081 : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D\u2081 : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {F\u2081 : Fun C\u2081 D\u2081}\n        {C\u2082 : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D\u2082 : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {F\u2082 : Fun C\u2082 D\u2082}\n        (\u03c9C : C\u2081 = C\u2082) (\u03c9D : D\u2081 = D\u2082)\n        (\u03c9obj : \u2200 (x\u2081 : C\u2081^.obj) (x\u2082 : C\u2082^.obj)\n                , x\u2081 == x\u2082 \u2192 F\u2081^.obj x\u2081 == F\u2082^.obj x\u2082)\n        (\u03c9hom : \u2200 (x\u2081 y\u2081 : C\u2081^.obj) (x\u2082 y\u2082 : C\u2082^.obj)\n                  (f\u2081 : C\u2081^.hom x\u2081 y\u2081) (f\u2082 : C\u2082^.hom x\u2082 y\u2082)\n                , f\u2081 == f\u2082 \u2192 (F\u2081^.hom f\u2081) == (F\u2082^.hom f\u2082))\n      , F\u2081 == F\u2082\n| C D F\u2081 .(C) .(D) F\u2082 (eq.refl .(C)) (eq.refl .(D)) \u03c9obj \u03c9hom\n:= begin\n     apply heq_of_eq,\n     apply Fun.eq,\n     { intro x,\n       apply eq_of_heq,\n       apply \u03c9obj,\n       apply heq.refl\n     },\n     { intros \u03c9obj x y f,\n       apply \u03c9hom,\n       apply heq.refl\n     }\n   end\n\n/-! #brief Congruence on objects.\n-/\ntheorem Fun.congr_obj {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    : \u2200 {x y : C^.obj}\n        (\u03c9 : 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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    : \u2200 {x y : C^.obj} {f\u2081 f\u2082 : C^.hom x y}\n        (\u03c9 : f\u2081 = f\u2082)\n      , F^.hom f\u2081 = F^.hom f\u2082\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    : \u2200 {x y : C^.obj}\n        {\u03c9 : x = y}\n      , F^.hom (cast_hom \u03c9) = cast_hom begin rw \u03c9 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.{\u2113obj \u2113hom}) : Fun C C\n:= { obj := \u03bb x, x\n   , hom := \u03bb x y f, f\n   , hom_id := \u03bb x, rfl\n   , hom_circ := \u03bb x y z g f, rfl\n   }\n\n@[simp] theorem Fun.id.simp_obj {C : Cat.{\u2113obj \u2113hom}}\n    (c : C^.obj)\n    : (Fun.id C)^.obj c = c\n:= rfl\n\n@[simp] theorem Fun.id.simp_hom {C : Cat.{\u2113obj \u2113hom}}\n    {c\u2081 c\u2082 : C^.obj} (f : C^.hom c\u2081 c\u2082)\n    : (Fun.id C)^.hom f = f\n:= rfl\n\n/-! #brief Composition of functors.\n-/\ndefinition Fun.comp {B : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    (G : Fun C D) (F : Fun B C)\n    : Fun B D\n:= { obj := \u03bb x, G^.obj (F^.obj x)\n   , hom := \u03bb x y f, G^.hom (F^.hom f)\n   , hom_id := \u03bb x, begin dsimp, simp end\n   , hom_circ := \u03bb x y z g f, begin dsimp, simp [Fun.hom_circ] end\n   }\n\n-- Composition of functors.\n-- \\Box\\Box\ninfixl ` \u25a1\u25a1 ` : 150 := Fun.comp\n\n@[simp] theorem Fun.comp.simp_obj {B : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    (G : Fun C D) (F : Fun B C) {x\u2081 x\u2082 : B^.obj} (f : B^.hom x\u2081 x\u2082)\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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}} {E : Cat.{\u2113obj\u2084 \u2113hom\u2084}}\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 \u03c9obj 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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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 \u03c9obj 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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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 \u03c9obj 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.{\u2113obj\u2081 \u2113hom\u2081}}\n    (F : Fun C C)\n    : \u2115 \u2192 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.{\u2113obj\u2081 \u2113hom\u2081}}\n    {F : Fun C C}\n    {n : \u2115}\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.{\u2113obj\u2081 \u2113hom\u2081}}\n    {F : Fun C C}\n    : \u2200 {n : \u2115}\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.{\u2113obj\u2081 \u2113hom\u2081}}\n    (F : Fun C C)\n    : \u2115 \u2192 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.{\u2113obj\u2081 \u2113hom\u2081}}\n    {F : Fun C C}\n    : \u2200 {n : \u2115}\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.{\u2113obj\u2081 \u2113hom\u2081}}\n    {F : Fun C C}\n    {n : \u2115}\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.{\u2113obj\u2081 \u2113hom\u2081}}\n    {F : Fun C C}\n    {n : \u2115}\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.{\u2113obj\u2081 \u2113hom\u2081}) {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (d : D^.obj)\n    : Fun C D\n:= { obj := \u03bb c, d\n   , hom := \u03bb c\u2081 c\u2082 f, D^.id d\n   , hom_id := \u03bb c, rfl\n   , hom_circ := \u03bb c\u2081 c\u2082 c\u2083 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.{\u2113obj\u2082 \u2113hom\u2082})\n    : Fun C UnitCat.{\u2113obj\u2081 \u2113hom\u2081}\n:= { obj := \u03bb c, punit.star\n   , hom := \u03bb c\u2081 c\u2082 f, punit.star\n   , hom_id := \u03bb c, rfl\n   , hom_circ := \u03bb c\u2081 c\u2082 c\u2083 g f, rfl\n   }\n\n/-! #brief The final functor is unique.\n-/\ntheorem FinalFun.uniq {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C UnitCat.{\u2113obj\u2081 \u2113hom\u2081}}\n    : F = FinalFun.{\u2113obj\u2081 \u2113hom\u2081} C\n:= Fun.eq\n    (\u03bb c, begin cases F^.obj c, trivial end)\n    (\u03bb \u03c9 c\u2081 c\u2082 f, begin cases F^.hom f, trivial end)\n\n/-! #brief The initial functor.\n-/\ndefinition InitFun (C : Cat.{\u2113obj\u2082 \u2113hom\u2082})\n    : Fun EmptyCat.{\u2113obj\u2081 \u2113hom\u2081} C\n:= { obj := \u03bb e, by cases e\n   , hom := \u03bb e\u2081 e\u2082 f, by cases f\n   , hom_id := \u03bb e, by cases e\n   , hom_circ := \u03bb e\u2081 e\u2082 e\u2083 g f, by cases f\n   }\n\n/-! #brief The initial functor is unique.\n-/\ntheorem InitFun.uniq {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun EmptyCat.{\u2113obj\u2081 \u2113hom\u2081} C}\n    : F = InitFun.{\u2113obj\u2081 \u2113hom\u2081} C\n:= Fun.eq\n    (\u03bb c, by cases c)\n    (\u03bb \u03c9 c\u2081 c\u2082 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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    {c\u2081 c\u2082 : C^.obj}\n    {f\u2081\u2082 : C^.hom c\u2081 c\u2082} {f\u2082\u2081 : C^.hom c\u2082 c\u2081}\n    (iso : Iso f\u2081\u2082 f\u2082\u2081)\n    : Iso (F^.hom f\u2081\u2082) (F^.hom f\u2082\u2081)\n:= { id\u2081 := by calc F^.hom f\u2082\u2081 \u2218\u2218 F^.hom f\u2081\u2082\n                        = F^.hom (f\u2082\u2081 \u2218\u2218 f\u2081\u2082) : by rw F^.hom_circ\n                    ... = F^.hom (C^.id c\u2081)   : by rw iso^.id\u2081\n                    ... = \u27e8\u27e8F^.obj c\u2081\u27e9\u27e9       : by rw F^.hom_id\n   , id\u2082 := by calc F^.hom f\u2081\u2082 \u2218\u2218 F^.hom f\u2082\u2081\n                        = F^.hom (f\u2081\u2082 \u2218\u2218 f\u2082\u2081) : by rw F^.hom_circ\n                    ... = F^.hom (C^.id c\u2082)   : by rw iso^.id\u2082\n                    ... = \u27e8\u27e8F^.obj c\u2082\u27e9\u27e9       : 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 \u2113obj \u2113hom) + 1) ((max \u2113obj \u2113hom) + 1)}\n:= { obj := Cat.{\u2113obj \u2113hom}\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.{\u2113obj \u2113hom} LeanCat.{\u2113obj}\n:= { obj := \u03bb C, C^.obj\n   , hom := \u03bb C\u2081 C\u2082 F, F^.obj\n   , hom_id := \u03bb C, rfl\n   , hom_circ := \u03bb C\u2081 C\u2082 C\u2083 g f, rfl\n   }\n\n/-! #brief A general hom in a category.\n-/\nstructure Cat.GeneralHom (C : Cat.{\u2113obj\u2081 \u2113hom\u2081})\n    : Type (max \u2113obj\u2081 \u2113hom\u2081)\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.{\u2113obj \u2113hom} LeanCat.{max \u2113obj \u2113hom}\n:= { obj := Cat.GeneralHom\n   , hom\n      := \u03bb C\u2081 C\u2082 F h\n         , { dom := F^.obj h^.dom\n           , codom := F^.obj h^.codom\n           , hom := F^.hom h^.hom\n           }\n   , hom_id := \u03bb C, begin apply funext, intro x, cases x, trivial end\n   , hom_circ := \u03bb C\u2081 C\u2082 C\u2083 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.{\u2113\u2081}) : Type (max \u2113\u2081 \u2113\u2082)\n| lift : A \u2192 Lean.LevelMax\n\ndefinition Lean.LevelMax.unlift {A : Type.{\u2113\u2081}}\n    : Lean.LevelMax.{\u2113\u2081 \u2113\u2082} A \u2192 A\n| (Lean.LevelMax.lift a) := a\n\n-- /-! #brief Lean.LevelMax.lift is injective.\n-- -/\n-- theorem Lean.LevelMax.lift.inj {A : Type.{\u2113\u2081}}\n--     : \u2200 {a\u2081 a\u2082 : A}\n--         (\u03c9 : Lean.LevelMax.lift.{\u2113\u2081 \u2113\u2082} a\u2081 = Lean.LevelMax.lift.{\u2113\u2081 \u2113\u2082} a\u2082)\n--       , a\u2081 = a\u2082\n-- | a .(a) (eq.refl .(Lean.LevelMax.lift.{\u2113\u2081 \u2113\u2082} a)) := rfl\n\n/-! #brief Apply a function to a Lean.Level1.\n-/\ndefinition Lean.LevelMax.map {A : Type.{\u2113\u2081}} {B : Type.{\u2113\u2082}}\n    (f : A \u2192 B)\n    : Lean.LevelMax.{\u2113\u2081 \u2113\u2083} A \u2192 Lean.LevelMax.{\u2113\u2082 \u2113\u2084} 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.{\u2113\u2081} LeanCat.{max \u2113\u2081 \u2113\u2082}\n:= { obj := Lean.LevelMax\n   , hom := @Lean.LevelMax.map\n   , hom_id := \u03bb X, begin apply funext, intro x, cases x, trivial end\n   , hom_circ := \u03bb 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.{\u2113\u2081}) : Type (\u2113\u2081 + 1)\n:= Lean.LevelMax.{\u2113\u2081 (\u2113\u2081 + 1)} A\n\n/-! #brief Apply a function to a Lean.Level1.\n-/\ndefinition Lean.Level1.map {A : Type.{\u2113\u2081}} {B : Type.{\u2113\u2082}}\n    (f : A \u2192 B)\n    : Lean.Level1 A \u2192 Lean.Level1 B\n:= Lean.LevelMax.map f\n\n/-! #brief Increasing the universe level by 1.\n-/\ndefinition LeanCat.Level1\n    : Fun LeanCat.{\u2113\u2081} LeanCat.{\u2113\u2081 + 1}\n:= LeanCat.LevelMax.{\u2113\u2081 (\u2113\u2081 + 1)}\n\n/- -----------------------------------------------------------------------\nBijections of categories and conjugate functors.\n----------------------------------------------------------------------- -/\n\n/-! #brief A bijection of categories.\n-/\nstructure Cat.Bij {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    (G : Fun D C)\n    : Prop\n:= (id\u2081 : Fun.comp G F = Fun.id C)\n   (id\u2082 : 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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    {G : Fun D C}\n    (bij : Cat.Bij F G)\n    : Cat.Bij G F\n:= { id\u2081 := bij^.id\u2082\n   , id\u2082 := bij^.id\u2081\n   }\n\n/-! #brief Bijections have unique inverses.\n-/\ntheorem Cat.Bij.inv_uniq\u2082 {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    {G\u2081 G\u2082 : Fun D C}\n    (bij\u2081 : Cat.Bij F G\u2081)\n    (bij\u2082 : Cat.Bij F G\u2082)\n    : G\u2081 = G\u2082\n:= by calc G\u2081  = G\u2081 \u25a1\u25a1 Fun.id D : by rw Fun.comp_id_right\n           ... = G\u2081 \u25a1\u25a1 (F \u25a1\u25a1 G\u2082) : by rw bij\u2082^.id\u2082\n           ... = G\u2081 \u25a1\u25a1 F \u25a1\u25a1 G\u2082   : by rw Fun.comp_assoc\n           ... = Fun.id C \u25a1\u25a1 G\u2082 : by rw bij\u2081^.id\u2081\n           ... = G\u2082             : by rw Fun.comp_id_left\n\n/-! #brief Bijections have unique inverses.\n-/\ntheorem Cat.Bij.inv_uniq\u2081 {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F\u2081 F\u2082 : Fun C D}\n    {G : Fun D C}\n    (bij\u2081 : Cat.Bij F\u2081 G)\n    (bij\u2082 : Cat.Bij F\u2082 G)\n    : F\u2081 = F\u2082\n:= Cat.Bij.inv_uniq\u2082 (Cat.Bij.flip bij\u2081) (Cat.Bij.flip bij\u2082)\n\n/-! #brief The identity functor is a bijection of categories.\n-/\ntheorem Fun.id.Bij (C : Cat.{\u2113obj \u2113hom})\n    : Cat.Bij (Fun.id C) (Fun.id C)\n:= { id\u2081 := Fun.comp_id_left\n   , id\u2082 := 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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    {F\u2082 : Fun C D} {G\u2082 : Fun D C} (bij\u2082 : Cat.Bij F\u2082 G\u2082)\n    {F\u2081 : Fun B C} {G\u2081 : Fun C B} (bij\u2081 : Cat.Bij F\u2081 G\u2081)\n    : Cat.Bij (Fun.comp F\u2082 F\u2081) (Fun.comp G\u2081 G\u2082)\n:= { id\u2081\n      := by calc\n          G\u2081 \u25a1\u25a1 G\u2082 \u25a1\u25a1 (F\u2082 \u25a1\u25a1 F\u2081)\n              = G\u2081 \u25a1\u25a1 (G\u2082 \u25a1\u25a1 F\u2082) \u25a1\u25a1 F\u2081  : by repeat { rw Fun.comp_assoc }\n          ... = G\u2081 \u25a1\u25a1 Fun.id C \u25a1\u25a1 F\u2081    : by rw bij\u2082^.id\u2081\n          ... = G\u2081 \u25a1\u25a1 F\u2081                : by rw Fun.comp_id_right\n          ... = Fun.id B                : by rw bij\u2081^.id\u2081\n   , id\u2082\n      := by calc\n          F\u2082 \u25a1\u25a1 F\u2081 \u25a1\u25a1 (G\u2081 \u25a1\u25a1 G\u2082)\n              = F\u2082 \u25a1\u25a1 (F\u2081 \u25a1\u25a1 G\u2081) \u25a1\u25a1 G\u2082  : by repeat { rw Fun.comp_assoc }\n          ... = F\u2082 \u25a1\u25a1 (Fun.id C) \u25a1\u25a1 G\u2082  : by rw bij\u2081^.id\u2082\n          ... = F\u2082 \u25a1\u25a1 G\u2082                : by rw Fun.comp_id_right\n          ... = Fun.id D                : by rw bij\u2082^.id\u2082\n   }\n\n/-! #brief The casting functor.\n-/\ndefinition CastFun\n    : \u2200 {C\u2081 C\u2082 : Cat.{\u2113obj \u2113hom}}\n        (\u03c9 : C\u2081 = C\u2082)\n       , Fun C\u2081 C\u2082\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    : \u2200 {C : Cat.{\u2113obj \u2113hom}}\n         (\u03c9 : C = C)\n      , CastFun \u03c9 = Fun.id C\n| C (eq.refl .(C)) := rfl\n\n/-! #brief The casting functor is compatible with transitivity.\n-/\ntheorem CastFun.trans\n    : \u2200 {C\u2081 C\u2082 C\u2083 : Cat.{\u2113obj \u2113hom}}\n        (\u03c9\u2082\u2083 : C\u2082 = C\u2083)\n        (\u03c9\u2081\u2082 : C\u2081 = C\u2082)\n      , CastFun \u03c9\u2082\u2083 \u25a1\u25a1 CastFun \u03c9\u2081\u2082 = CastFun (eq.trans \u03c9\u2081\u2082 \u03c9\u2082\u2083)\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    : \u2200 {C\u2081 C\u2082 : Cat.{\u2113obj \u2113hom}}\n         (\u03c9\u2081\u2082 : C\u2081 = C\u2082)\n         (\u03c9\u2082\u2081 : C\u2082 = C\u2081)\n      , Cat.Bij (CastFun \u03c9\u2081\u2082) (CastFun \u03c9\u2082\u2081)\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\u2081 C\u2082 : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D\u2081 D\u2082 : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (FC\u2081\u2082 : Fun C\u2081 C\u2082) (FC\u2082\u2081 : Fun C\u2082 C\u2081)\n    (FD\u2081\u2082 : Fun D\u2081 D\u2082) (FD\u2082\u2081 : Fun D\u2082 D\u2081)\n    (F\u2081 : Fun C\u2081 D\u2081) (F\u2082 : Fun C\u2082 D\u2082)\n    : Prop\n:= (dom_bij : Cat.Bij FC\u2081\u2082 FC\u2082\u2081)\n   (codom_bij : Cat.Bij FD\u2081\u2082 FD\u2082\u2081)\n   (id\u2082 : F\u2082 = Fun.comp (Fun.comp FD\u2081\u2082 F\u2081) FC\u2082\u2081)\n\ntheorem Fun.Conj.outside {C\u2081 C\u2082 : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D\u2081 D\u2082 : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {FC\u2081\u2082 : Fun C\u2081 C\u2082} {FC\u2082\u2081 : Fun C\u2082 C\u2081}\n    {FD\u2081\u2082 : Fun D\u2081 D\u2082} {FD\u2082\u2081 : Fun D\u2082 D\u2081}\n    {F\u2081 : Fun C\u2081 D\u2081} {F\u2082 : Fun C\u2082 D\u2082}\n    (conj : Fun.Conj FC\u2081\u2082 FC\u2082\u2081 FD\u2081\u2082 FD\u2082\u2081 F\u2081 F\u2082)\n    : Fun.comp FD\u2082\u2081 F\u2082 = Fun.comp F\u2081 FC\u2082\u2081\n:= by calc FD\u2082\u2081 \u25a1\u25a1 F\u2082\n               = FD\u2082\u2081 \u25a1\u25a1 (FD\u2081\u2082 \u25a1\u25a1 F\u2081 \u25a1\u25a1 FC\u2082\u2081) : by rw conj^.id\u2082\n           ... = (FD\u2082\u2081 \u25a1\u25a1 FD\u2081\u2082) \u25a1\u25a1 F\u2081 \u25a1\u25a1 FC\u2082\u2081 : by repeat {rw Fun.comp_assoc}\n           ... = Fun.id D\u2081 \u25a1\u25a1 F\u2081 \u25a1\u25a1 FC\u2082\u2081     : by rw conj^.codom_bij^.id\u2081\n           ... = F\u2081 \u25a1\u25a1 FC\u2082\u2081                   : by rw Fun.comp_id_left\n\ntheorem Fun.Conj.inside {C\u2081 C\u2082 : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D\u2081 D\u2082 : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {FC\u2081\u2082 : Fun C\u2081 C\u2082} {FC\u2082\u2081 : Fun C\u2082 C\u2081}\n    {FD\u2081\u2082 : Fun D\u2081 D\u2082} {FD\u2082\u2081 : Fun D\u2082 D\u2081}\n    {F\u2081 : Fun C\u2081 D\u2081} {F\u2082 : Fun C\u2082 D\u2082}\n    (conj : Fun.Conj FC\u2081\u2082 FC\u2082\u2081 FD\u2081\u2082 FD\u2082\u2081 F\u2081 F\u2082)\n    : Fun.comp F\u2082 FC\u2081\u2082 = Fun.comp FD\u2081\u2082 F\u2081\n:= by calc F\u2082 \u25a1\u25a1 FC\u2081\u2082\n               = (FD\u2081\u2082 \u25a1\u25a1 F\u2081 \u25a1\u25a1 FC\u2082\u2081) \u25a1\u25a1 FC\u2081\u2082 : by rw conj^.id\u2082\n           ... = FD\u2081\u2082 \u25a1\u25a1 F\u2081 \u25a1\u25a1 (FC\u2082\u2081 \u25a1\u25a1 FC\u2081\u2082) : by repeat {rw Fun.comp_assoc}\n           ... = FD\u2081\u2082 \u25a1\u25a1 F\u2081 \u25a1\u25a1 Fun.id C\u2081     : by rw conj^.dom_bij^.id\u2081\n           ... = FD\u2081\u2082 \u25a1\u25a1 F\u2081                  : by rw Fun.comp_id_right\n\ntheorem Fun.Conj.id\u2081 {C\u2081 C\u2082 : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D\u2081 D\u2082 : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {FC\u2081\u2082 : Fun C\u2081 C\u2082} {FC\u2082\u2081 : Fun C\u2082 C\u2081}\n    {FD\u2081\u2082 : Fun D\u2081 D\u2082} {FD\u2082\u2081 : Fun D\u2082 D\u2081}\n    {F\u2081 : Fun C\u2081 D\u2081} {F\u2082 : Fun C\u2082 D\u2082}\n    (conj : Fun.Conj FC\u2081\u2082 FC\u2082\u2081 FD\u2081\u2082 FD\u2082\u2081 F\u2081 F\u2082)\n    : Fun.comp (Fun.comp FD\u2082\u2081 F\u2082) FC\u2081\u2082 = F\u2081\n:= by calc FD\u2082\u2081 \u25a1\u25a1 F\u2082 \u25a1\u25a1 FC\u2081\u2082\n               = FD\u2082\u2081 \u25a1\u25a1 (FD\u2081\u2082 \u25a1\u25a1 F\u2081 \u25a1\u25a1 FC\u2082\u2081) \u25a1\u25a1 FC\u2081\u2082   : by rw conj^.id\u2082\n           ... = (FD\u2082\u2081 \u25a1\u25a1 FD\u2081\u2082) \u25a1\u25a1 F\u2081 \u25a1\u25a1 (FC\u2082\u2081 \u25a1\u25a1 FC\u2081\u2082) : by repeat {rw Fun.comp_assoc}\n           ... = Fun.id D\u2081 \u25a1\u25a1 F\u2081 \u25a1\u25a1 Fun.id C\u2081           : by rw [conj^.dom_bij^.id\u2081, conj^.codom_bij^.id\u2081]\n           ... = F\u2081                                     : 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\u2081 C\u2082 : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D\u2081 D\u2082 : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {FC\u2081\u2082 : Fun C\u2081 C\u2082} {FC\u2082\u2081 : Fun C\u2082 C\u2081}\n    {FD\u2081\u2082 : Fun D\u2081 D\u2082} {FD\u2082\u2081 : Fun D\u2082 D\u2081}\n    {F\u2081 : Fun C\u2081 D\u2081} {F\u2082 : Fun C\u2082 D\u2082}\n    (conj : Fun.Conj FC\u2081\u2082 FC\u2082\u2081 FD\u2081\u2082 FD\u2082\u2081 F\u2081 F\u2082)\n    : Fun.Conj FC\u2082\u2081 FC\u2081\u2082 FD\u2082\u2081 FD\u2081\u2082 F\u2082 F\u2081\n:= { dom_bij := Cat.Bij.flip conj^.dom_bij\n   , codom_bij := Cat.Bij.flip conj^.codom_bij\n   , id\u2082 := eq.symm conj^.id\u2081\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.{\u2113obj \u2113hom})\n    [C_HasFinal : HasFinal C]\n    : Fun C (OverCat C (final C))\n:= { obj := \u03bb c, { obj := c, hom := final_hom c }\n   , hom := \u03bb c\u2081 c\u2082 f, { hom := f, triangle := eq.symm (final_hom.uniq C) }\n   , hom_id := \u03bb c, OverHom.eq rfl\n   , hom_circ := \u03bb c\u2081 c\u2082 c\u2083 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.{\u2113obj \u2113hom})\n    [C_HasFinal : HasFinal C]\n    : Fun (OverCat C (final C)) C\n:= { obj := \u03bb c, c^.obj\n   , hom := \u03bb c\u2081 c\u2082 f, f^.hom\n   , hom_id := \u03bb c, rfl\n   , hom_circ := \u03bb c\u2081 c\u2082 c\u2083 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.{\u2113obj \u2113hom})\n    [C_HasFinal : HasFinal C]\n    : Cat.Bij (OverFinal.to C) (OverFinal.from C)\n:= { id\u2081 := rfl\n   , id\u2082 := Fun.eq\n             (\u03bb c, OverObj.eq rfl (heq_of_eq (eq.symm (final_hom.uniq C))))\n             (\u03bb \u03c9 x y f, OverHom.heq (\u03c9 _) (\u03c9 _) (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.{\u2113\u2081} CatOfSemigroups.{\u2113\u2081}\n:= { obj := \u03bb A\n            , { fst := A^.fst\n              , snd := @monoid.to_semigroup A^.fst A^.snd\n              }\n   , hom := \u03bb A B f\n            , { val := f^.val\n              , property := monoid.hom.to_hom f^.property\n              }\n   , hom_id := \u03bb A, subtype.eq rfl\n   , hom_circ := \u03bb 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.{\u2113\u2081} CatOfMonoids.{\u2113\u2081}\n:= { obj := \u03bb A\n            , { fst := A^.fst\n              , snd := @group.to_monoid A^.fst A^.snd\n              }\n   , hom := \u03bb A B f\n            , { val := f^.val\n              , property := @group.hom.to_monoid_hom _ A^.snd _ B^.snd _ f^.property\n              }\n   , hom_id := \u03bb A, subtype.eq rfl\n   , hom_circ := \u03bb 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 \u2113\u2081} [A_monoid : monoid A]\n    {B : Type \u2113\u2081} [B_monoid : monoid B]\n    {f : A \u2192 B}\n    (f_hom : monoid.hom f)\n    : Fun (MonoidCat A) (MonoidCat B)\n:= { obj := \u03bb u, punit.star\n   , hom := \u03bb u\u2081 u\u2082 a, f a\n   , hom_id := \u03bb u, f_hom^.id\n   , hom_circ := \u03bb u\u2081 u\u2082 u\u2083 a\u2082 a\u2081, f_hom^.dist a\u2082 a\u2081\n   }\n\n/-! #brief Every group homomorphism induces a functor.\n-/\ndefinition GroupFun\n    {A : Type \u2113\u2081} [A_group : group A]\n    {B : Type \u2113\u2081} [B_group : group B]\n    {f : A \u2192 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 \u2113\u2081} {r : A \u2192 A \u2192 Prop}\n    {r_refl : reflexive r} {r_trans : transitive r}\n    {B : Type \u2113\u2082} {s : B \u2192 B \u2192 Prop}\n    {s_refl : reflexive s} {s_trans : transitive s}\n    (f : A \u2192 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 := \u03bb a, proof_irrel _ _\n   , hom_circ := \u03bb a\u2081 a\u2082 a\u2083 g f, proof_irrel _ _\n   }\n\n@[simp] definition PreorderFun.simp_obj\n    {A : Type \u2113\u2081} {r : A \u2192 A \u2192 Prop}\n    {r_refl : reflexive r} {r_trans : transitive r}\n    {B : Type \u2113\u2082} {s : B \u2192 B \u2192 Prop}\n    {s_refl : reflexive s} {s_trans : transitive s}\n    (f : A \u2192 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 \u2113\u2081} {r : A \u2192 A \u2192 Prop}\n    {r_refl : reflexive r} {r_trans : transitive r}\n    {B : Type \u2113\u2082} {s : B \u2192 B \u2192 Prop}\n    {s_refl : reflexive s} {s_trans : transitive s}\n    (f : A \u2192 B)\n    (f_monotone : monotone r s f)\n    {a\u2081 a\u2082 : A} (\u03c9 : r a\u2081 a\u2082)\n    : (@PreorderFun A r r_refl r_trans B s s_refl s_trans f f_monotone)^.hom \u03c9 = f_monotone a\u2081 a\u2082 \u03c9\n:= rfl\n\n/-! #brief Every function induces a functor between object categories.\n-/\ndefinition ObjFun {A : Type \u2113\u2081} {B : Type \u2113\u2082} (f : A \u2192 B)\n    : Fun (ObjCat A) (ObjCat B)\n:= PreorderFun f (\u03bb a\u2081 a\u2082, congr_arg f)\n\n@[simp] definition ObjFun.simp_obj {A : Type \u2113\u2081} {B : Type \u2113\u2082} (f : A \u2192 B)\n    (a : A)\n    : (ObjFun f)^.obj a = f a\n:= rfl\n\n@[simp] definition ObjFun.simp_hom {A : Type \u2113\u2081} {B : Type \u2113\u2082} (f : A \u2192 B)\n    {a\u2081 a\u2082 : A} (\u03c9 : a\u2081 = a\u2082)\n    : (ObjFun f)^.hom \u03c9 = congr_arg f \u03c9\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.\u03c0\u2081 (C : Cat.{\u2113obj\u2081 \u2113hom\u2081}) (D : Cat.{\u2113obj\u2082 \u2113hom\u2082})\n    : Fun (ProdCat C D) C\n:= { obj := \u03bb x, x^.fst\n   , hom := \u03bb x y f, f^.fst\n   , hom_id := \u03bb x, rfl\n   , hom_circ := \u03bb x y z g f, rfl\n   }\n\n/-! #brief Right-projection out of a product category.\n-/\ndefinition ProdCat.\u03c0\u2082 (C : Cat.{\u2113obj\u2081 \u2113hom\u2081}) (D : Cat.{\u2113obj\u2082 \u2113hom\u2082})\n    : Fun (ProdCat C D) D\n:= { obj := \u03bb x, x^.snd\n   , hom := \u03bb x y f, f^.snd\n   , hom_id := \u03bb x, rfl\n   , hom_circ := \u03bb 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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    (l : Fun B C)\n    (r : Fun B D)\n    : Fun B (ProdCat C D)\n:= { obj := \u03bb b, { fst := l^.obj b, snd := r^.obj b }\n   , hom := \u03bb b\u2081 b\u2082 f, { fst := l^.hom f, snd := r^.hom f }\n   , hom_id := \u03bb b, begin rw [l^.hom_id, r^.hom_id], trivial end\n   , hom_circ := \u03bb b\u2081 b\u2082 b\u2083 g f, begin rw [l^.hom_circ, r^.hom_circ], trivial end\n   }\n\n/-! #brief Factoring through Product.into.\n-/\ntheorem ProdCat.\u03c0\u2081_into {B : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    {l : Fun B C}\n    {r : Fun B D}\n    : Fun.comp (ProdCat.\u03c0\u2081 C D) (ProdCat.into l r) = l\n:= begin\n     apply Fun.eq,\n     { intro b, trivial },\n     { intros \u03c9obj b\u2081 b\u2082 f, trivial },\n   end\n\n/-! #brief Factoring through Product.into.\n-/\ntheorem ProdCat.\u03c0\u2082_into {B : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    {l : Fun B C}\n    {r : Fun B D}\n    : Fun.comp (ProdCat.\u03c0\u2082 C D) (ProdCat.into l r) = r\n:= begin\n     apply Fun.eq,\n     { intro b, trivial },\n     { intros \u03c9obj b\u2081 b\u2082 f, trivial },\n   end\n\n/-! #brief ProdCat.into on the projections is trivial.\n-/\ntheorem ProdCat.into_\u03c0 {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    : ProdCat.into (ProdCat.\u03c0\u2081 C D) (ProdCat.\u03c0\u2082 C D) = Fun.id (ProdCat C D)\n:= begin\n     apply Fun.eq,\n     { intro cd, cases cd with c d, trivial },\n     { intros \u03c9obj cd\u2081 cd\u2082 f, cases f with f\u2081 f\u2082, trivial }\n   end\n\n/-! #brief Composition of ProdCat.into.\n-/\ntheorem ProdCat.into.comp\n    {A : Cat.{\u2113obj\u2081 \u2113hom\u2081}}\n    {B : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {C : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    {D : Cat.{\u2113obj\u2084 \u2113hom\u2084}}\n    {E : Cat.{\u2113obj\u2085 \u2113hom\u2085}}\n    {l\u2081 : Fun A B} {r\u2081 : Fun A C}\n    {l\u2082 : Fun (ProdCat B C) D} {r\u2082 : Fun (ProdCat B C) E}\n    : Fun.comp (ProdCat.into l\u2082 r\u2082) (ProdCat.into l\u2081 r\u2081)\n       = ProdCat.into (Fun.comp l\u2082 (ProdCat.into l\u2081 r\u2081))\n                      (Fun.comp r\u2082 (ProdCat.into l\u2081 r\u2081))\n:= begin\n     apply Fun.eq,\n     { intro a, trivial },\n     { intros \u03c9obj a\u2081 a\u2082 f, trivial },\n   end\n\n/-! #brief Flipping the order of a product.\n-/\ndefinition ProdCat.flip (C : Cat.{\u2113obj\u2081 \u2113hom\u2081}) (D : Cat.{\u2113obj\u2082 \u2113hom\u2082})\n    : Fun (ProdCat C D) (ProdCat D C)\n:= ProdCat.into (ProdCat.\u03c0\u2082 C D) (ProdCat.\u03c0\u2081 C D)\n\n/-! #brief Flipping the order of a product is a bijection of categories.\n-/\ntheorem ProdCat.flip.Bij (C : Cat.{\u2113obj\u2081 \u2113hom\u2081}) (D : Cat.{\u2113obj\u2082 \u2113hom\u2082})\n    : Cat.Bij (ProdCat.flip C D) (ProdCat.flip D C)\n:= { id\u2081 := begin\n              unfold ProdCat.flip,\n              rw [ProdCat.into.comp, ProdCat.\u03c0\u2082_into, ProdCat.\u03c0\u2081_into, ProdCat.into_\u03c0]\n            end\n   , id\u2082 := begin\n              unfold ProdCat.flip,\n              rw [ProdCat.into.comp, ProdCat.\u03c0\u2082_into, ProdCat.\u03c0\u2081_into, ProdCat.into_\u03c0]\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.{\u2113obj \u2113hom})\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.{\u2113obj \u2113hom})\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.{\u2113obj \u2113hom})\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    : Fun (OpCat C) (OpCat D)\n:= { obj := \u03bb c, F^.obj c\n   , hom := \u03bb c\u2081 c\u2082 f, F^.hom f\n   , hom_id := \u03bb c, F^.hom_id\n   , hom_circ := \u03bb c\u2081 c\u2082 c\u2083 g f, F^.hom_circ\n   }\n\n@[simp] theorem OpFun.simp_obj {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    {x\u2081 x\u2082 : (OpCat C)^.obj} (f : (OpCat C)^.hom x\u2081 x\u2082)\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.{\u2113obj \u2113hom}}\n    : OpFun (Fun.id C) = Fun.id (OpCat C)\n:= begin\n     apply Fun.eq,\n     { intro c, trivial },\n     { intros \u03c9obj c\u2081 c\u2082 f, trivial }\n   end\n\n/-! #brief The opposite functor distributes over composition.\n-/\ntheorem OpFun.comp {B : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\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 \u03c9obj c\u2081 c\u2082 f, trivial }\n   end\n\n/-! #brief OpFun preserves bijections.\n-/\ntheorem OpFun.Bij {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D} {G : Fun D C}\n    (bij : Cat.Bij F G)\n    : Cat.Bij (OpFun F) (OpFun G)\n:= { id\u2081 := by calc OpFun G \u25a1\u25a1 OpFun F\n                        = OpFun (G \u25a1\u25a1 F)   : by rw OpFun.comp\n                    ... = OpFun (Fun.id C) : by rw bij^.id\u2081\n                    ... = Fun.id (OpCat C) : by rw OpFun.id\n   , id\u2082 := by calc OpFun F \u25a1\u25a1 OpFun G\n                        = OpFun (F \u25a1\u25a1 G)   : by rw OpFun.comp\n                    ... = OpFun (Fun.id D) : by rw bij^.id\u2082\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.{\u2113obj \u2113hom}}\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.{\u2113obj \u2113hom}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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\u2082 := begin\n              apply Fun.eq,\n              { intro c, cases C, cases D, trivial },\n              { intros \u03c9obj c\u2081 c\u2082 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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    : Type (max \u2113obj\u2081 \u2113hom\u2081 \u2113obj\u2082 \u2113hom\u2082)\n:= (hom : \u2200 [C_HasFinal : HasFinal C]\n            (d : D^.obj)\n          , D^.hom d (F^.obj (final C)))\n   (pres : \u2200 [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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    : Type (max \u2113obj\u2081 \u2113hom\u2081 \u2113obj\u2082 \u2113hom\u2082)\n:= PresFinal (OpFun F)\n-- := (hom : \u2200 [C_HasInit : HasInit C]\n--             (d : D^.obj)\n--           , D^.hom (F^.obj (init C)) d)\n--    (pres : \u2200 [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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}) (c : C^.obj)\n    : Fun (OverCat C c) C\n:= { obj := \u03bb x, x^.obj\n   , hom := \u03bb x y f, f^.hom\n   , hom_id := \u03bb x, rfl\n   , hom_circ := \u03bb x y z g f, rfl\n   }\n\n/-! #brief Functors induce functors of over categories.\n-/\ndefinition OverFun {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (X : C^.obj)\n    (F : Fun C D)\n    : Fun (OverCat C X) (OverCat D (F^.obj X))\n:= { obj := \u03bb A, OverObj.mk (F^.obj A^.dom) (F^.hom A^.down)\n   , hom := \u03bb A B f, OverHom.mk (F^.hom f^.hom) (by rw [f^.triangle, F^.hom_circ])\n   , hom_id := \u03bb A, OverHom.eq F^.hom_id\n   , hom_circ := \u03bb a b c g f, OverHom.eq F^.hom_circ\n   }\n\n/-! #brief Heterogeneous equality for OverFun.\n-/\ntheorem OverFun.heq {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {X : C^.obj}\n    : \u2200 {F\u2081 F\u2082 : Fun C D}\n         (\u03c9 : F\u2081 = F\u2082)\n      , OverFun X F\u2081 == OverFun X F\u2082\n| F .(F) (eq.refl .(F)) := heq.refl _\n\n/-! #brief OverFun preserves identity functors.\n-/\ntheorem OverFun.id {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} (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 \u03c9obj a b f,\n       apply OverHom.heq (\u03c9obj _) (\u03c9obj _),\n       { trivial }\n     }\n   end\n\n/-! #brief OverFun distributes over composition of functors.\n-/\ntheorem OverFun.comp {B : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\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 \u03c9obj a b f, trivial }\n   end\n\n/-! #brief Functors induce functors of under categories.\n-/\ndefinition UnderFun {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} (X : C^.obj)\n    : UnderFun X (Fun.id C) = Fun.id (UnderCat C X)\n:= by calc OpFun (@OverFun C\u207b\u00b9 C\u207b\u00b9 X (OpFun (Fun.id C)))\n               = OpFun (@OverFun C\u207b\u00b9 C\u207b\u00b9 X (Fun.id C\u207b\u00b9)) : congr_arg OpFun (eq_of_heq (OverFun.heq OpFun.id))\n           ... = OpFun (Fun.id (OverCat C\u207b\u00b9 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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\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\u207b\u00b9 D\u207b\u00b9 X (OpFun (G \u25a1\u25a1 F)))\n               = OpFun (@OverFun B\u207b\u00b9 D\u207b\u00b9 X (OpFun G \u25a1\u25a1 OpFun F))                                       : congr_arg OpFun (eq_of_heq (OverFun.heq OpFun.comp))\n           ... = OpFun (@OverFun C\u207b\u00b9 D\u207b\u00b9 ((OpFun F)^.obj X) (OpFun G) \u25a1\u25a1 @OverFun B\u207b\u00b9 C\u207b\u00b9 X (OpFun F)) : congr_arg OpFun (@OverFun.comp B\u207b\u00b9 C\u207b\u00b9 D\u207b\u00b9 X (OpFun G) (OpFun F))\n           ... = OpFun (@OverFun C\u207b\u00b9 D\u207b\u00b9 (F^.obj X) (OpFun G)) \u25a1\u25a1 OpFun (@OverFun B\u207b\u00b9 C\u207b\u00b9 X (OpFun F)) : OpFun.comp\n\n/-! #brief Under and over categories are dual concepts.\n-/\ndefinition Under_dual_Over (C : Cat.{\u2113obj \u2113hom}) (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.{\u2113obj \u2113hom}) (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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    : Type (max \u2113obj\u2081 \u2113obj\u2082 \u2113hom\u2082)\n:= (obj : D^.obj)\n   (hom : \u2200 (c : C^.obj), D^.hom obj (F^.obj c))\n   (comm : \u2200 {c\u2081 c\u2082 : C^.obj} (f : C^.hom c\u2081 c\u2082)\n           , hom c\u2082 = F^.hom f \u2218\u2218 hom c\u2081)\n\n/-! #brief Composition of a cone with a hom.\n-/\ndefinition Cone.circ {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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 := \u03bb c, D^.circ (cone^.hom c) h\n   , comm := \u03bb c\u2081 c\u2082 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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    (X Y : Cone F)\n    : Type \u2113hom\u2082\n:= (mediate : D^.hom X^.obj Y^.obj)\n   (factor : \u2200 (c : C^.obj), X^.hom c = Y^.hom c \u2218\u2218 mediate)\n\n/-! #brief Equality of homs in a cone category.\n-/\ntheorem ConeHom.eq {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    {X Y : Cone F}\n    : \u2200 {f\u2081 f\u2082 : ConeHom F X Y}\n      , f\u2081^.mediate = f\u2082^.mediate\n      \u2192 f\u2081 = f\u2082\n| (ConeHom.mk f \u03c9\u2081) (ConeHom.mk .(f) \u03c9\u2082) (eq.refl .(f)) := rfl\n\n/-! #brief An identity hom in a cone category.\n-/\ndefinition ConeHom.id {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    (X : Cone F)\n    : ConeHom F X X\n:= { mediate := D^.id X^.obj\n   , factor := \u03bb c, eq.symm D^.circ_id_right\n   }\n\n@[simp] theorem ConeHom.id.simp_mediate {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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 := \u03bb c, by rw [D^.circ_assoc, -g^.factor, -f^.factor]\n   }\n\n@[simp] theorem ConeHom.comp.simp_mediate {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    : Cat.{(max \u2113obj\u2081 \u2113obj\u2082 \u2113hom\u2082) (\u2113hom\u2082 + 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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F\u2081 F\u2082 : Fun C D}\n    (\u03c9 : F\u2081 = F\u2082)\n    : Fun (ConeCat F\u2081) (ConeCat F\u2082)\n:= CastFun (congr_arg ConeCat \u03c9)\n\n/-! #brief A co-cone category.\n-/\ndefinition CoConeCat {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    : Cat.{(max \u2113obj\u2081 \u2113obj\u2082 \u2113hom\u2082) (\u2113hom\u2082 + 1)}\n:= ConeCat (OpFun F)\n\n/-! #brief Equal functors give equal co-cone categories.\n-/\ndefinition CoConeCat.CastFun {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F\u2081 F\u2082 : Fun C D}\n    (\u03c9 : F\u2081 = F\u2082)\n    : Fun (CoConeCat F\u2081) (CoConeCat F\u2082)\n:= CastFun (congr_arg CoConeCat \u03c9)\n\n/-! #brief An object in a co-cone category.\n-/\ndefinition CoCone {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    : Type (max \u2113obj\u2081 \u2113obj\u2082 \u2113hom\u2082)\n:= (CoConeCat F)^.obj\n\n/-! #brief Composition of a co-cone with a hom.\n-/\ndefinition CoCone.circ {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    (d : D^.obj)\n    (to : \u2200 (c : C^.obj), D^.hom (F^.obj c) d)\n    (\u03c9 : \u2200 {c\u2081 c\u2082 : C^.obj} (f : C^.hom c\u2081 c\u2082)\n         , to c\u2081 = to c\u2082 \u2218\u2218 F^.hom f)\n    : CoCone F\n:= { obj := d\n   , hom := to\n   , comm := \u03bb c\u2081 c\u2082, \u03c9\n   }\n\n/-! #brief A hom in a co-cone category.\n-/\ndefinition CoConeHom {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    (F : Fun C D)\n    (A B : CoCone F)\n    : Type \u2113hom\u2082\n:= (CoConeCat F)^.hom A B\n\n/-! #brief Construct a hom in a co-cone category.\n-/\ndefinition CoConeHom.mk {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\n    {F : Fun C D}\n    {A B : CoCone F}\n    (f : D^.hom B^.obj A^.obj)\n    (\u03c9 : \u2200 (c : C^.obj), A^.hom c = f \u2218\u2218 B^.hom c)\n    : CoConeHom F A B\n:= { mediate := f\n   , factor := \u03c9\n   }\n\n/-! #brief Co-cones and cones are dual concepts.\n-/\ntheorem CoCone_dual_Cone {C : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {D : Cat.{\u2113obj\u2082 \u2113hom\u2082}}\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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    (G : Fun C D)\n    (F : Fun B C)\n    : Fun (ConeCat F) (ConeCat (G \u25a1\u25a1 F))\n:= { obj := \u03bb c, { obj := G^.obj c^.obj\n                 , hom := \u03bb a, G^.hom (c^.hom a)\n                 , comm := \u03bb a\u2081 a\u2082 f\n                           , begin\n                               rw [c^.comm f, G^.hom_circ],\n                               trivial\n                             end\n                 }\n   , hom := \u03bb c\u2081 c\u2082 h, { mediate := G^.hom h^.mediate\n                      , factor := \u03bb b, begin dsimp, rw [h^.factor, G^.hom_circ] end\n                      }\n   , hom_id := \u03bb c, ConeHom.eq G^.hom_id\n   , hom_circ := \u03bb c\u2081 c\u2082 c\u2083 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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    (G : Fun C D)\n    (F : Fun B C)\n    : Fun (ConeCat G) (ConeCat (G \u25a1\u25a1 F))\n:= { obj := \u03bb c, { obj := c^.obj\n                 , hom := \u03bb a, (c^.hom (F^.obj a))\n                 , comm := \u03bb a\u2081 a\u2082 f, c^.comm (F^.hom f)\n                 }\n   , hom := \u03bb c\u2081 c\u2082 h, { mediate := h^.mediate\n                      , factor := \u03bb b, h^.factor (F^.obj b)\n                      }\n   , hom_id := \u03bb c, rfl\n   , hom_circ := \u03bb c\u2081 c\u2082 c\u2083 g f, rfl\n   }\n\n/-! #brief Functors induce functors on cone categories by composition.\n-/\ndefinition ConeFun\n    {A : Cat.{\u2113obj\u2081 \u2113hom\u2081}} {B : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {C : Cat.{\u2113obj\u2083 \u2113hom\u2083}} {D : Cat.{\u2113obj\u2084 \u2113hom\u2084}}\n    (H : Fun C D)\n    (G : Fun B C)\n    (F : Fun A B)\n    : Fun (ConeCat G) (ConeCat (H \u25a1\u25a1 G \u25a1\u25a1 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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    (H : Fun C D)\n    (F : Fun B C)\n    : Fun (CoConeCat F) (CoConeCat (H \u25a1\u25a1 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.{\u2113obj\u2081 \u2113hom\u2081}} {C : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {D : Cat.{\u2113obj\u2083 \u2113hom\u2083}}\n    (F : Fun C D)\n    (H : Fun B C)\n    : Fun (CoConeCat F) (CoConeCat (F \u25a1\u25a1 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.{\u2113obj\u2081 \u2113hom\u2081}} {B : Cat.{\u2113obj\u2082 \u2113hom\u2082}} {C : Cat.{\u2113obj\u2083 \u2113hom\u2083}} {D : Cat.{\u2113obj\u2084 \u2113hom\u2084}}\n    (H : Fun C D)\n    (G : Fun B C)\n    (F : Fun A B)\n    : Fun (CoConeCat G) (CoConeCat (H \u25a1\u25a1 G \u25a1\u25a1 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\u2081 \u2192 Fitree E R\u2082 \u2192 Fitree E R\u2081)\n    = Functor.map \u2218 Function.const R\u2082 :=\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\u2081 \u2192 R\u2082) (g: R\u2082 \u2192 R\u2083) (t: Fitree E R\u2081):\n    (g \u2218 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\u2081: Fitree E R\u2081) (t\u2082: Fitree E R\u2082):\n    t\u2081 <* t\u2082 = Function.const R\u2082 <$> t\u2081 <*> t\u2082 := by\n  simp [SeqLeft.seqLeft, Seq.seq]\n  induction t\u2081 with\n  | Ret _ => rfl\n  | Vis _ _ ih => simp [bind]; funext _; simp [ih]; sorry -- rfl\n\ntheorem Fitree.seqRight_eq (t\u2081: Fitree E R\u2081) (t\u2082: Fitree E R\u2082):\n    t\u2081 *> t\u2082 = Function.const R\u2081 id <$> t\u2081 <*> t\u2082 := by\n  simp [SeqRight.seqRight, Seq.seq]\n  induction t\u2081 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\u2081 \u2192 R\u2082) (t: Fitree E R\u2081):\n    pure f <*> t = f <$> t :=\n  rfl\n\ntheorem Fitree.map_pure (f: R\u2081 \u2192 R\u2082) (r: R\u2081):\n    f <$> (pure r) = pure (f := Fitree E) (f r) :=\n  rfl\n\ntheorem Fitree.seq_pure (f: Fitree E (R\u2081 \u2192 R\u2082)) (r: R\u2081):\n    f <*> pure r = (fun h => h r) <$> f :=\n  rfl\n\ntheorem Fitree.seq_assoc (t\u2081: Fitree E R\u2081)\n    (t\u2082: Fitree E (R\u2081 \u2192 R\u2082)) (t\u2083: Fitree E (R\u2082 \u2192 R\u2083)):\n    t\u2083 <*> (t\u2082 <*> t\u2081) = ((@Function.comp R\u2081 R\u2082 R\u2083) <$> t\u2083) <*> t\u2082 <*> t\u2081 := 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\u2081 \u2192 R\u2082) (t: Fitree E R\u2081):\n    bind t (fun r => pure (f r)) = f <$> t :=\n  rfl\n\ntheorem Fitree.bind_map (f: Fitree E (R\u2081 \u2192 R\u2082)) (t: Fitree E R\u2081):\n    bind f (. <$> t) = f <*> t :=\n  rfl\n\ntheorem Fitree.pure_bind (r: R\u2081) (k: R\u2081 \u2192 Fitree E R\u2082):\n    bind (pure r) k = k r :=\n  rfl\n\ntheorem Fitree.bind_assoc (t: Fitree E R\u2081)\n    (k\u2081: R\u2081 \u2192 Fitree E R\u2082) (k\u2082: R\u2082 \u2192 Fitree E R\u2083):\n    bind (bind t k\u2081) k\u2082 = bind t (fun x => bind (k\u2081 x) k\u2082) := 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 \u27f6 Y) (e : C \u224c 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 (\u03b1 : Type _)\n\t| deadlock {} : completed\n\t| some   {} : \u03b1 \u2192 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   : \u2200 c, \u2203 a \u2208 str.actions c, str.execute c a \u2260 \u2205)\n    [\u2200 c, decidable (str.actions c = \u2205)]\n: STR C (completed A) := \n{ \n    initial := str.initial,\n    actions := \u03bb c, if str.actions c = \u2205 then \n            (singleton completed.deadlock) \n        else \n            { oa | \u2200 a \u2208 str.actions c, oa = completed.some a }, \n    execute := \u03bb 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, \u2200 a \u2208 str.actions c, str.execute c a = \u2205 , 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  \u2200 c, \n    (str.actions c).nonempty\n  \u2227 \u2203 a \u2208 str.actions c, (str.execute c a).nonempty\n\ndef has_deadlock \n  (C A : Type)\n  (str : STR C A)\n: Prop := \n  \u2203 c, \n    str.actions c = \u2205 \n  \u2228 \u2200 a \u2208 str.actions c, str.execute c a = \u2205\n\ndef deadlock_configuration \n  {C A : Type}\n  (str : STR C A)\n  (c : C)\n: Prop :=\n  str.actions c = \u2205 \n  \u2228 \u2200 a \u2208 str.actions c, str.execute c a = \u2205\n\n\n\n@[simp]\ndef add_implicit_steps\n  (C A : Type)\n  (str : STR C A)\n  [\u2200 c, decidable (str.actions c = \u2205)]\n  [\u2200 c, decidable (\u2200 a \u2208 str.actions c, str.execute c a = \u2205)]\n: STR C (completed A) :=\n{\n  initial := str.initial,\n  actions := \u03bb c, \n              if  str.actions c = \u2205 \n                \u2228 \u2200 a \u2208 str.actions c, str.execute c a = \u2205 \n              then \n                  singleton completed.deadlock\n              else\n                  { oa | \u2200 a \u2208 str.actions c, oa = (completed.some a)},\n  execute := \u03bb 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 = \u2205\ndef all_executions_block (C A : Type) (str : STR C A) (c : C) :=\n(\u2200 a \u2208 str.actions c, str.execute c a = \u2205)\n\ndef add_implicit_steps'\n  (C A : Type)\n  (str : STR C A)\n  -- [\u2200 c, decidable (str.actions c = \u2205)]\n  -- [\u2200 c, decidable (\u2200 a \u2208 str.actions c, str.execute c a = \u2205)]\n: STR C (completed A) :=\n{\n  initial := str.initial,\n  actions := \u03bb c, { a | (str.actions c = \u2205 \u2228 (\u2200 a \u2208 str.actions c, str.execute c a = \u2205) \u2192 a = completed.deadlock) \n                        \u2228 \u2200 oa \u2208 str.actions c, a = (completed.some oa)}, \n  execute := \u03bb 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 : \u00ac no_deadlock C A str)\n  [\u2200 c, decidable (str.actions c = \u2205)]\n  [\u2200 c, decidable (\u2200 (a : A), a \u2208 str.actions c \u2192 str.execute c a = \u2205)]\n  [\u2200 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 \u27e8_, _\u27e9, \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 \u1fb0_1, refine not_imp.mpr _, split, \n  revert \u1fb0, refine imp_or_distrib.mpr _, refine or.inl _, safe *,\n   sorry,\n  -- -- hint, \n  -- refine not_imp.mpr _, norm_num, revert \u1fb0, 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 {\u03b1 : Type u} [DecidableEq \u03b1]\n\n@[simp]\ntheorem dedup_nil : dedup [] = ([] : List \u03b1) :=\n  rfl\n#align list.dedup_nil List.dedup_nil\n\ntheorem dedup_cons_of_mem' {a : \u03b1} {l : List \u03b1} (h : a \u2208 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 : \u03b1} {l : List \u03b1} (h : a \u2209 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 : \u03b1} {l : List \u03b1} : a \u2208 dedup l \u2194 a \u2208 l := by\n  have := not_congr (@forall_mem_pwFilter \u03b1 (\u00b7 \u2260 \u00b7) _ ?_ 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 \u21a6 h.1.trans h.2) xz\n\n#align list.mem_dedup List.mem_dedup\n\n@[simp]\ntheorem dedup_cons_of_mem {a : \u03b1} {l : List \u03b1} (h : a \u2208 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 : \u03b1} {l : List \u03b1} (h : a \u2209 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 : \u2200 l : List \u03b1, dedup l <+ l :=\n  pwFilter_sublist\n#align list.dedup_sublist List.dedup_sublist\n\ntheorem dedup_subset : \u2200 l : List \u03b1, dedup l \u2286 l :=\n  pwFilter_subset\n#align list.dedup_subset List.dedup_subset\n\ntheorem subset_dedup (l : List \u03b1) : l \u2286 dedup l := fun _ => mem_dedup.2\n#align list.subset_dedup List.subset_dedup\n\ntheorem nodup_dedup : \u2200 l : List \u03b1, Nodup (dedup l) :=\n  pairwise_pwFilter\n#align list.nodup_dedup List.nodup_dedup\n\ntheorem dedup_eq_self {l : List \u03b1} : dedup l = l \u2194 Nodup l :=\n  pwFilter_eq_self\n#align list.dedup_eq_self List.dedup_eq_self\n\nprotected theorem Nodup.dedup {l : List \u03b1} (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 \u03b1} : dedup (dedup l) = dedup l :=\n  pwFilter_idempotent\n#align list.dedup_idempotent List.dedup_idempotent\n\ntheorem dedup_append (l\u2081 l\u2082 : List \u03b1) : dedup (l\u2081 ++ l\u2082) = l\u2081 \u222a dedup l\u2082 := by\n  induction' l\u2081 with a l\u2081 IH; \u00b7 rfl\n  simp only [instUnionList, cons_union] at *\n  rw [\u2190 IH, cons_append]\n  by_cases h : a \u2208 dedup (l\u2081 ++ l\u2082)\n  \u00b7 rw [dedup_cons_of_mem' h, insert_of_mem h]\n  \u00b7 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 : \u03b1} : \u2200 {k}, k \u2260 0 \u2192 (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 \u27e8n.succ_ne_zero, rfl\u27e9),\n      replicate_dedup n.succ_ne_zero]\n#align list.replicate_dedup List.replicate_dedup\n\ntheorem count_dedup (l : List \u03b1) (a : \u03b1) : l.dedup.count a = if a \u2208 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 : \u03b1 \u2192 Bool) (l : List \u03b1) :\n    ((l.dedup.filter p).map fun x => l.count x).sum = l.countp p := by\n  induction' l with a as h\n  \u00b7 simp\n  \u00b7 simp_rw [List.countp_cons, List.count_cons', List.sum_map_add]\n    congr 1\n    \u00b7 refine' _root_.trans _ h\n      by_cases ha : a \u2208 as\n      \u00b7 simp [dedup_cons_of_mem ha]\n      \u00b7 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    \u00b7 by_cases hp : p a\n      \u00b7 refine' _root_.trans (sum_map_eq_nsmul_single a _ fun _ h _ => by simp [h]) _\n        simp [hp, count_dedup]\n      \u00b7 refine' _root_.trans (List.sum_eq_zero fun n hn => _) (by simp [hp])\n        obtain \u27e8a', ha'\u27e9 := List.mem_map.1 hn\n        split_ifs at ha' with ha\n        \u00b7 simp only [ha, mem_filter, mem_dedup, find?, mem_cons, true_or, hp,\n            and_false, false_and] at ha'\n        \u00b7 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 \u03b1) :\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 \u03b7\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 \u2192 utlc \u2192 Prop := \u03bb f g, f = \u039b (g \u2191\u00b9 0)\u00b7\u21930\n\ninstance : has_\u03b7_reduction utlc := \u27e8 reduction_step_of head_step \u27e9\n\n@[simp] theorem down_step {n: \u2115}: \u00ac \u2193n \u2192\u03b7 g :=\nbegin\n  simp [has_\u03b7_reduction.step, reduction_step],\nend\n\ntheorem lambda_step_lambda : f \u2192\u03b7 g \u2192 (\u039b f) \u2192\u03b7 (\u039b g) :=\nbegin\n  intro p,\n  simp [has_\u03b7_reduction.step, reduction_step],\n  exact or.inr p\nend\n\ntheorem lambda_step_head (f: utlc): \u039b (f \u2191\u00b9 0)\u00b7\u21930 \u2192\u03b7 f :=\nby simp [has_\u03b7_reduction.step, reduction_step]\n\ntheorem lambda_step_head': f = (g \u2191\u00b9 0)\u00b7\u21930 \u2192 \u039b f \u2192\u03b7 g :=\nby { intro p, rw[p], exact lambda_step_head _ }\n\ntheorem lambda_step_iff: \u039b f \u2192\u03b7 g \u2194 (\u2203 x, g = x \u2227 f = (x \u2191\u00b9 0)\u00b7\u21930) \u2228 (\u2203 x, g = \u039b x \u2227 f \u2192\u03b7 x) :=\nby simp [has_\u03b7_reduction.step, reduction_step]\n\ntheorem lambda_step_cases : \u039b f \u2192\u03b7 g \u2192 (\u2203 x, g = \u039b x \u2227 f \u2192\u03b7 x \u2228 g = x \u2227 f = (x \u2191\u00b9 0)\u00b7\u21930) :=\nbegin\n  simp [has_\u03b7_reduction.step, reduction_step],\n  intro p,\n  cases p,\n  use g,\n  exact or.inr \u27e8rfl, p\u27e9,\n  cases g,\n  all_goals { simp [has_\u03b7_reduction.step, reduction_step] at * },\n  any_goals { contradiction },\n  use g,\n  exact or.inl \u27e8rfl, p\u27e9,  \nend\n\ntheorem lambda_step_cases': \u039b f \u2192\u03b7 g \u2192 (\u2203 x, g = \u039b x \u2227 f \u2192\u03b7 x) \u2228 \u2203 x, g = x \u2227 f = (x \u2191\u00b9 0)\u00b7\u21930 :=\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 \u2192\u03b7 f' \u2192 (f\u00b7g) \u2192\u03b7 (f'\u00b7g) :=\nbegin\n  intro p,\n  simp [has_\u03b7_reduction.step, reduction_step],\n  exact or.inl p,\nend\n\ntheorem dot_step_dot_right : g \u2192\u03b7 g' \u2192 (f\u00b7g) \u2192\u03b7 (f\u00b7g') :=\nbegin\n  intro p,\n  simp [has_\u03b7_reduction.step, reduction_step],\n  exact or.inr p,\nend\n\ntheorem dot_step_iff: (f\u00b7f') \u2192\u03b7 g \u2194 \u2203 x x', g = x\u00b7x' \u2227 (x' = f' \u2227 f \u2192\u03b7 x \u2228 x = f \u2227 f' \u2192\u03b7 x') :=\nbegin\n  cases g,\n  all_goals { simp [has_\u03b7_reduction.step, and_assoc] },\nend\n\ntheorem dot_step_iff': (f\u00b7f') \u2192\u03b7 g \u2194 (\u2203 x x', x' = f' \u2227 g = x\u00b7x' \u2227 f \u2192\u03b7 x) \u2228 (\u2203 x x', x = f \u2227 g = x\u00b7x' \u2227 f' \u2192\u03b7 x') :=\nbegin\n  cases g,\n  all_goals { simp [has_\u03b7_reduction.step, and_assoc] },\nend\n\ntheorem dot_step_cases: (f\u00b7f') \u2192\u03b7 g \u2192 \u2203 x x', g = x\u00b7x' \u2227 (x' = f' \u2227 f \u2192\u03b7 x \u2228 x = f \u2227 f' \u2192\u03b7 x') :=\nbegin\n  cases g,\n  all_goals { simp [has_\u03b7_reduction.step, and_assoc] },\nend\n\ntheorem dot_step_cases': (f\u00b7f') \u2192\u03b7 g \u2192 (\u2203 x x', x' = f' \u2227 g = x\u00b7x' \u2227 f \u2192\u03b7 x) \u2228 (\u2203 x x', x = f \u2227 g = x\u00b7x' \u2227 f' \u2192\u03b7 x') :=\nbegin\n  cases g,\n  all_goals { simp [has_\u03b7_reduction.step, and_assoc] },\nend\n\ntheorem reduction_step_shift (n: \u2115): f \u2191\u00b9 n \u2192\u03b7 g \u2191\u00b9 n \u2192 f \u2192\u03b7 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 \u2191\u00b9 n).uses n = x.uses (n + 1),\n      { simp [hgx, uses] },\n      have h: \u2203 y, x = y \u2191\u00b9 (n+1),\n      { apply shift_of_uses_zero,\n        rw [\u2190 h],\n        simp [shift_uses] },\n      cases h with y hy,\n      rw [hy,\n          \u2190 show (\u039b y) \u2191\u00b9 n = \u039b y \u2191\u00b9 (n+1), by simp,\n          shift_inj_iff] at hgx,\n      rw [hgx],\n      apply lambda_step_lambda,\n      apply f_ih,\n      rw [\u2190 hy],\n      apply hfx },\n    { cases p with hgx hfx,\n      -- rw [\u2190 hgx, \u2190 shift_comm] at hfx,\n      apply lambda_step_head',\n      rw [\u2190 shift_inj_iff (n + 1), hfx],\n      simp [down_shift],\n      rw [\u2190 shift_comm_zero, hgx] } },\n  { simp,\n    intro p,\n    cases g;\n    try { simp[has_\u03b7_reduction.step, reduction_step, dot_step_iff, down_shift] at p,\n      contradiction },\n    rcases dot_step_cases p with \u27e8x, y, hgxy, p\u27e9,\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 [\u2190 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 [\u2190 hgxy.right] at hfy,\n    exact dot_step_dot_right (f_ih_g _ hfy)\n     }\nend\n\ntheorem reduction_step_uses: f \u2192\u03b7 g \u2192 \u2200 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 \u2260 n + 1, by linarith] } },\n  {\n    intros p m,\n    rcases dot_step_cases p with \u27e8x, y, hg, p\u27e9,\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 \u2192\u03b7 g \u2192 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 \u27e8x, hgx, hfx\u27e9,\n    simp [f_ih hfx, hgx] },\n  { intro p,\n    rcases dot_step_cases p with \u27e8x, y, hgxy, p\u27e9,\n    cases p with p p;\n    rcases p with \u27e8heq, hstep\u27e9,\n    simp [f_ih_f hstep, hgxy, \u2190 heq],\n    ring,\n    simp [f_ih_g hstep, hgxy, \u2190 heq],\n    ring,\n  }\nend\n\ntheorem reduction_step_size_mono: f \u2192\u03b7 g \u2192 g.size < f.size :=\nby intro p; simp [reduction_step_size p]\n\n@[simp] theorem down_reduction_iff {n: \u2115}: \u2193n \u21a0\u03b7 g \u2194 g = \u2193n :=\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 \u21a0\u03b7 f' \u2192 \u039b f \u21a0\u03b7 \u039b 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 \u21a0\u03b7 f' \u2192 f\u00b7g \u21a0\u03b7 f'\u00b7g :=\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 \u21a0\u03b7 g' \u2192 f\u00b7g \u21a0\u03b7 f\u00b7g' :=\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 \u21a0\u03b7 f' \u2192 g \u21a0\u03b7 g' \u2192 f\u00b7g \u21a0\u03b7 f'\u00b7g' :=\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 \u21a0\u03b7 g): \u2200 {m n}, f = m\u00b7n \u2192 \u2203 x y, g = x\u00b7y \u2227 m \u21a0\u03b7 x \u2227 n \u21a0\u03b7 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 \u27e8 m, n, p, by refl, by refl\u27e9 },\n  { intros m n p,\n    rw [p] at hf,\n    rcases dot_step_cases hf with \u27e8a, b, hab, h\u27e9,\n    rcases ih hab with \u27e8i, j, ih\u27e9,\n    refine \u27e8i, j, ih.left, trans _ ih.right.left, trans _ ih.right.right\u27e9;\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\u00b7f' \u21a0\u03b7 g): \u2203 x y, g = x\u00b7y \u2227 f \u21a0\u03b7 x \u2227 f' \u21a0\u03b7 y := dot_exists_reduction h rfl\n\ntheorem dot_reduction_dot_iff: f\u00b7g \u21a0\u03b7 f'\u00b7g' \u2194 f \u21a0\u03b7 f' \u2227 g \u21a0\u03b7 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: \u2115}: head_step (f \u2191\u00b9 n) (g \u2191\u00b9 n) \u2194 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 [\u2190 @shift_comm 1 (n + 1) _ (by linarith)] };\n  try { simp [\u2190 @shift_comm 0 n _ (by linarith)] };\n  repeat { intro };\n  try { linarith };\n  split;\n  intro;\n  try { linarith },\n  rw [\u2190 @shift_inj_iff _ (n + 1 + 1), shift_comm],\n  assumption,\n  linarith,\n  rw [\u2190 shift_comm, shift_inj_iff],\n  assumption,\n  linarith,\nend\n\ntheorem head_step_substitution: head_step f f' \u2192 \u2200 n g, f[n:=g] \u21a0\u03b7 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 \u2192 bool\n| (\u2193 _):= true\n| (\u039b f) := match f with\n  | (\u2193 _) := true\n  | (\u039b _) := true\n  | (f\u00b7g) := f.uses 0 > 0 \u2228 g \u2260 \u21930\n  end\n| (_\u00b7_) := true\n\ndef reduced := reduced_of head_reduced\n\ntheorem head_reduced_iff_not_head_step: head_reduced f \u2194 \u2200 g, \u00ac 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 \u2194 \u2200 g, \u00ac f \u2192\u03b7 g :=\n  reduced_iff_not_reduction_step @head_reduced_iff_not_head_step _\n\n\n@[simp] theorem down_reduced (n: \u2115): reduced \u2193n := by simp [reduced, head_reduced, down_reduced]\n\ntheorem lambda_reduced (f: utlc): reduced (\u039b f) \u2194 head_reduced (\u039b f) \u2227 reduced f :=\nby simp [reduced, head_reduced, lambda_reduced]\n\n@[simp] theorem dot_reduced (f g: utlc): reduced (f\u00b7g) \u2194 reduced f \u2227 reduced g := by simp [reduced, head_reduced, dot_reduced]\n\n-- inductive hypothesis useful when dealing with \u03b7 reductions\n-- splits (\u039b f\u00b7\u21930) up to handle the (\u039b f)\u00b7g \u21d4 f[0:=g] case\n-- theorem \u03b7_induction_on (p: utlc \u2192 Prop): \u03a0 (f: utlc)\n--   (down: \u03a0 n, p \u2193n)\n--   (dot_lambda: \u03a0 x (hx: p x) (h: x.uses 0 = 0), p (\u039b x\u00b7\u21930))\n--   (lambda: \u03a0 x (hx: p x) (h: head_reduced x), p (\u039b x))\n--   (dot : \u03a0 x y (hx: p x) (hy: p y), p (x\u00b7y)),\n--   (p f)\n-- | (\u2193n) := \u03bb hn hx hdx hlx, hn n\n-- | (\u039b x) := \u03bb hn hx hdx hlx, hx x (\u03b2_induction_on x hn hx hdx hlx)\n\nend \u03b7\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 : \u2115} {F : typevec.{u} (n+1) \u2192 Type u} [mvfunctor F] [q : mvqpf F]\ninclude q\n\ndef corecF {\u03b1 : typevec n} {\u03b2 : Type*} (g : \u03b2 \u2192 F (\u03b1.append1 \u03b2)) : \u03b2 \u2192 q.P.M \u03b1 :=\nq.P.M_corec (\u03bb x, repr (g x))\n\ntheorem corecF_eq {\u03b1 : typevec n} {\u03b2 : Type*} (g : \u03b2 \u2192 F (\u03b1.append1 \u03b2)) (x : \u03b2) :\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 {\u03b1 : typevec n} (r : q.P.M \u03b1 \u2192 q.P.M \u03b1 \u2192 Prop) : Prop :=\n  \u2200 \u2983x y\u2984, r x y \u2192\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 {\u03b1 : typevec n} : q.P.M \u03b1 \u2192 q.P.M \u03b1 \u2192 Prop :=\n\u03bb x y, \u2203 r, is_precongr r \u2227 r x y\n\ndef cofix (F : typevec (n + 1) \u2192 Type u) [mvfunctor F] [q : mvqpf F] (\u03b1 : typevec n):=\nquot (@Mcongr _ F _ q \u03b1)\n\ndef cofix.map {\u03b1 \u03b2 : typevec n} (g : \u03b1 \u27f9 \u03b2) : cofix F \u03b1 \u2192 cofix F \u03b2 :=\nquot.lift (\u03bb x : q.P.M \u03b1, quot.mk Mcongr (g <$$> x))\n  begin\n    rintros a\u2081 a\u2082 \u27e8r, pr, ra\u2081a\u2082\u27e9, apply quot.sound,\n    let r' := \u03bb b\u2081 b\u2082, \u2203 a\u2081 a\u2082 : q.P.M \u03b1, r a\u2081 a\u2082 \u2227 b\u2081 = g <$$> a\u2081 \u2227 b\u2082 = g <$$> a\u2082,\n    use r', split,\n    { show is_precongr r',\n      rintros b\u2081 b\u2082 \u27e8a\u2081, a\u2082, ra\u2081a\u2082, b\u2081eq, b\u2082eq\u27e9,\n      let u : quot r \u2192 quot r' := quot.lift (\u03bb x : q.P.M \u03b1, quot.mk r' (g <$$> x))\n        (by { intros a\u2081 a\u2082 ra\u2081a\u2082, apply quot.sound, exact \u27e8a\u2081, a\u2082, ra\u2081a\u2082, rfl, rfl\u27e9 }),\n      have hu : (quot.mk r' \u2218 \u03bb x : q.P.M \u03b1, g <$$> x) = u \u2218 quot.mk r,\n        { ext x, refl },\n      rw [b\u2081eq, b\u2082eq, q.P.M_dest_map, q.P.M_dest_map, \u2190q.P.comp_map, \u2190q.P.comp_map],\n      rw [\u2190append_fun_comp, id_comp, hu, hu, \u2190comp_id g, append_fun_comp],\n      rw [q.P.comp_map, q.P.comp_map, abs_map, pr ra\u2081a\u2082, \u2190abs_map] },\n    show r' (g <$$> a\u2081) (g <$$> a\u2082), from \u27e8a\u2081, a\u2082, ra\u2081a\u2082, rfl, rfl\u27e9\n  end\n\ninstance cofix.mvfunctor : mvfunctor (cofix F) :=\n{ map := @cofix.map _ _ _ _}\n\ndef cofix.corec {\u03b1 : typevec n} {\u03b2 : Type u} (g : \u03b2 \u2192 F (\u03b1.append1 \u03b2)) : \u03b2 \u2192 cofix F \u03b1 :=\n\u03bb x, quot.mk  _ (corecF g x)\n\ndef cofix.dest {\u03b1 : typevec n} : cofix F \u03b1 \u2192 F (\u03b1.append1 (cofix F \u03b1)) :=\nquot.lift\n  (\u03bb x, append_fun id (quot.mk Mcongr) <$$> (abs (q.P.M_dest x)))\n  begin\n    rintros x y \u27e8r, pr, rxy\u27e9, dsimp,\n    have : \u2200 x y, r x y \u2192 Mcongr x y,\n    { intros x y h, exact \u27e8r, pr, h\u27e9 },\n    rw [\u2190quot.factor_mk_eq _ _ this], dsimp,\n    conv { to_lhs,\n      rw [append_fun_comp_id, comp_map, \u2190abs_map, pr rxy, abs_map, \u2190comp_map,\n        \u2190append_fun_comp_id] }\n  end\n\ntheorem cofix.dest_corec {\u03b1 : typevec n} {\u03b2 : Type u} (g : \u03b2 \u2192 F (\u03b1.append1 \u03b2)) (x : \u03b2) :\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, \u2190comp_map, \u2190append_fun_comp], reflexivity\nend\n\ndef cofix.mk {\u03b1 : typevec n} : F (\u03b1.append1 $ cofix F \u03b1) \u2192 cofix F \u03b1 :=\ncofix.corec (\u03bb x, append_fun id (\u03bb i : cofix F \u03b1, cofix.dest.{u} i) <$$> x)\n\nprivate theorem cofix.bisim_aux {\u03b1 : typevec n}\n    (r : cofix F \u03b1 \u2192 cofix F \u03b1 \u2192 Prop)\n    (h' : \u2200 x, r x x)\n    (h : \u2200 x y, r x y \u2192\n      append_fun id (quot.mk r) <$$> cofix.dest x = append_fun id (quot.mk r) <$$> cofix.dest y) :\n  \u2200 x y, r x y \u2192 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' := \u03bb x y, r (quot.mk _ x) (quot.mk _ y),\n  have : is_precongr r',\n  { intros a b r'ab,\n      have  h\u2080 :\n          append_fun id (quot.mk r \u2218 quot.mk Mcongr) <$$> abs (q.P.M_dest a) =\n          append_fun id (quot.mk r \u2218 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\u2081 : \u2200 u v : q.P.M \u03b1, Mcongr u v \u2192 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 \u2192 quot r' := quot.lift (quot.lift (quot.mk r') h\u2081)\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 \u2218 quot.mk r \u2218 quot.mk Mcongr = quot.mk r' := rfl,\n    rw [\u2190this, append_fun_comp_id, q.P.comp_map, q.P.comp_map, abs_map, abs_map, abs_map,\n         abs_map, h\u2080] },\n  refine \u27e8r', this, rxy\u27e9\nend\n\ntheorem cofix.bisim_rel {\u03b1 : typevec n}\n    (r : cofix F \u03b1 \u2192 cofix F \u03b1 \u2192 Prop)\n    (h : \u2200 x y, r x y \u2192\n      append_fun id (quot.mk r) <$$> cofix.dest x = append_fun id (quot.mk r) <$$> cofix.dest y) :\n  \u2200 x y, r x y \u2192 x = y :=\nlet r' x y := x = y \u2228 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 : \u2200 x y, r x y \u2192 r' x y := \u03bb x y h, or.inr h,\n    rw \u2190quot.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 {\u03b1 : typevec n}\n    (r : cofix F \u03b1 \u2192 cofix F \u03b1 \u2192 Prop)\n    (h : \u2200 x y, r x y \u2192 liftr (rel_last \u03b1 r) (cofix.dest x) (cofix.dest y)) :\n  \u2200 x y, r x y \u2192 x = y :=\nbegin\n  apply cofix.bisim_rel,\n  intros x y rxy,\n  rcases (liftr_iff (rel_last \u03b1 r) _ _).mp (h x y rxy) with \u27e8a, f\u2080, f\u2081, dxeq, dyeq, h'\u27e9,\n  rw [dxeq, dyeq, \u2190abs_map, \u2190abs_map, mvpfunctor.map_eq, mvpfunctor.map_eq],\n  rw [\u2190split_drop_fun_last_fun f\u2080, \u2190split_drop_fun_last_fun f\u2081],\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\u2080 _ j = f\u2081 _ j, apply h' _ j },\n  apply quot.sound,\n  apply h' _ j\nend\n\ntheorem cofix.bisim' {\u03b1 : typevec n} {\u03b2 : Type*} (Q : \u03b2 \u2192 Prop) (u v : \u03b2 \u2192 cofix F \u03b1)\n    (h : \u2200 x, Q x \u2192 \u2203 a f' f\u2080 f\u2081,\n      cofix.dest (u x) = abs \u27e8a, q.P.append_contents f' f\u2080\u27e9 \u2227\n      cofix.dest (v x) = abs \u27e8a, q.P.append_contents f' f\u2081\u27e9 \u2227\n      \u2200 i, \u2203 x', Q x' \u2227 f\u2080 i = u x' \u2227 f\u2081 i = v x') :\n  \u2200 x, Q x \u2192 u x = v x :=\n\u03bb x Qx,\nlet R := \u03bb w z : cofix F \u03b1, \u2203 x', Q x' \u2227 w = u x' \u2227 z = v x' in\ncofix.bisim R\n  (\u03bb x y \u27e8x', Qx', xeq, yeq\u27e9,\n    begin\n      rcases h x' Qx' with \u27e8a, f', f\u2080, f\u2081, ux'eq, vx'eq, h'\u27e9,\n      rw liftr_iff,\n      refine \u27e8a, q.P.append_contents f' f\u2080, q.P.append_contents f' f\u2081,\n        xeq.symm \u25b8 ux'eq, yeq.symm \u25b8 vx'eq, _\u27e9,\n      intro i, cases i,\n      { intro j, apply eq.refl },\n      apply h',\n    end)\n  _ _ \u27e8x, Qx, rfl, rfl\u27e9\n\nlemma cofix.mk_dest {\u03b1 : typevec n} (x : cofix F \u03b1) : cofix.mk (cofix.dest x) = x :=\nbegin\n  apply cofix.bisim_rel (\u03bb x y : cofix F \u03b1, 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 [\u2190comp_map, \u2190append_fun_comp, id_comp],\n  rw [\u2190comp_map, \u2190append_fun_comp, id_comp, \u2190cofix.mk],\n  congr' 2,\n  ext u, apply quot.sound, refl\nend\n\nlemma cofix.dest_mk {\u03b1 : typevec n} (x : F (\u03b1.append1 $ cofix F \u03b1)) : cofix.dest (cofix.mk x) = x :=\nbegin\n  have : cofix.mk \u2218 cofix.dest = @_root_.id (cofix F \u03b1) := funext cofix.mk_dest,\n  rw [cofix.mk, cofix.dest_corec, \u2190comp_map, \u2190cofix.mk, \u2190 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       := \u03bb \u03b1, quot.mk Mcongr,\n  repr'     := \u03bb \u03b1, quot.out,\n  abs_repr' := \u03bb \u03b1, quot.out_eq,\n  abs_map   := \u03bb \u03b1 \u03b2 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 {\u03b1 \u03b2 \u03b3 : Type}\nvariable {X Y Z : Type} [Hilbert X] [Hilbert Y] [Hilbert Z] \n\nexample (f : Y \u2192 Z) (g : X \u2192 Y) (z : Z) [HasAdjoint f] [HasAdjoint g] : (f \u2218 g)\u2020 z = g\u2020 (f\u2020 z) := by simp; done\nexample (f g : X \u2192 Y) [HasAdjoint f] [HasAdjoint g] (y : Y) : (\u03bb x => f x + g x)\u2020 y = f\u2020 y + g\u2020 y := by simp; done\n\nexample (y : Y) (r : \u211d) \n  : (\u03bb x => \u27eax,y\u27eb)\u2020 r = r*y := by simp; done\nexample (y : X) (r : \u211d) \n  : (\u03bb x => \u27eax,y\u27eb + \u27eay,x\u27eb)\u2020 r = r * y + r * y := by simp; done\nexample (r : \u211d) (x' : X) \n  : (\u03bb x : X => r*((\u03bb x'' => \u27eax', x''\u27eb) x))\u2020 = \u03bb s => (r * s) * x' := by simp; done\n\nexample {n : Nat} (a : Fin n) [Nonempty (Fin n)] \n  : (\u03bb (f : Fin n \u2192 \u211d) i => f (i - a))\u2020 = (\u03bb (f : Fin n \u2192 \u211d) x => f (x + a)) := \n  by funext f i; simp[sum_into_lambda]; done\nexample {\u03b9} [Enumtype \u03b9] \n  : (\u03bb x : \u03b9 \u2192 X => sum x)\u2020 = (\u03bb (x : X) (i : \u03b9) => x) := by simp done\nexample {n} (c : Fin n)  [Nonempty (Fin n)] \n  : (\u03bb (g : Fin n \u2192 \u211d) => (\u03bb i => g (i+c)))\u2020 = (fun f x => f (x - c)) := by simp[Function.comp,sum_into_lambda]; done\n\nexample {\u03b9} [Enumtype \u03b9] (f : \u03b9 \u2192 X \u2192 Y) [\u2200 i, HasAdjoint (f i)] \n  : (\u03bb x i => f i x)\u2020 = (\u03bb y => \u2211 i, (f i)\u2020 (y i)) := by funext y; simp done\nexample {\u03b9} [Enumtype \u03b9] [Nonempty \u03b9] (f : \u03b9 \u2192 X \u2192 Y) [\u2200 i, HasAdjoint (f i)] \n  : (\u03bb (g : \u03b9 \u2192 X) i => f i (g i))\u2020 = (\u03bb h i => (1:\u211d) * ((f i)\u2020 (h i))) := by funext h i; simp[sum_into_lambda]; done\n\nexample (y : \u211d) : (\u03bb x : \u211d => x * y)\u2020 1 = \u27ea1,y\u27eb := by simp done\nexample (y : \u211d) : (\u03bb x : \u211d => y * x)\u2020 1 = y := by simp done\n\n-- set_option trace.Meta.Tactic.simp.discharge true in\nexample (a b : \u211d) (x : X)\n  : (\u03bb dx : X => (a * \u27eax, dx\u27eb) * b)\u2020 1 = (a * \u27ea1,b\u27eb) * x := \nby simp; unfold hold; simp done\n\nexample {\u03b9} [Enumtype \u03b9] [Nonempty \u03b9] (i : \u03b9) (c : \u211d)\n  : (fun (x : \u03b9 \u2192 \u211d) => x i * c)\u2020 1 = (fun j => kron i j * \u27ea1,c\u27eb)\n  := by simp; unfold hold; simp done\n\nexample -- [NonZero n]\n  : (\u03bb (x : Fin n \u2192 \u211d) => sum \u03bb i => x i)\u2020 1 = (\u03bb i => (1 : \u211d)) := by simp done\n\nexample {n} (f : Fin n \u2192 \u211d) (c : Fin n) [Nonempty (Fin n)] \n  : (\u03bb (g : Fin n \u2192 \u211d) => sum (\u03bb i => (f i) * (g (i+c))))\u2020 (1 : \u211d) = (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 \u2192 \u211d) [Nonempty (Fin n)] \n--   : (fun df : Fin n \u2192 \u211d => \u2211 i, df i * f i + f i * df i)\u2020 1 = \u03bb i => \u27ea1,f i\u27eb + f i := by funext i; simp; unfold hold; simp; simp only [sum_into_lambda]; done\n\n-- example {n} (f : Fin n \u2192 \u211d) (i : Fin n) [Nonempty (Fin n)]\n--   : (\u03bb (x : Fin n \u2192 \u211d) => x i * f i)\u2020 = \u03bb (y : \u211d) j => kron i j * \u27eay, f i\u27eb\n--   := by funext x j; simp; unfold hold; simp done\n\n\nexample {X Y : Type} [Hilbert X] [Hilbert Y] : (Prod.fst : X \u00d7 Y \u2192 X)\u2020 = \u03bb x : X => (x, 0) := by simp\nexample {X Y : Type} [Hilbert X] [Hilbert Y] : (Prod.snd : X \u00d7 Y \u2192 Y)\u2020 = \u03bb y : Y => (0, y) := by simp\nexample {X Y : Type} [Hilbert X] [Hilbert Y] : (\u03bb ((x,y) : X \u00d7 Y) => x)\u2020 = \u03bb x : X => (x, (0:Y)) := by simp\nexample {X Y : Type} [Hilbert X] [Hilbert Y] : (\u03bb ((x,y) : X \u00d7 Y) => y)\u2020 = \u03bb y : Y => ((0:X), y) := by simp\n\n\nset_option trace.Meta.Tactic.simp.discharge true in\nexample : (\u03bb (x : Fin n \u2192 \u211d) => Function.comp (HMul.hMul 2) x)\u2020 = 0 := by rw[Function.comp.arg_g.adj_simp]; simp[comp]; admit\n\n@[simp (low-2) \u2193]\ntheorem asdf {\u03b9 : Type} [Enumtype \u03b9] (f : Y \u2192 Z) [HasAdjoint f] \n  : (\u03bb (g : \u03b9 \u2192 Y) i => f (g i))\u2020 = \u03bb (g' : \u03b9 \u2192 Z) i => f\u2020 (g' i)  := sorry\n\nexample : (\u03bb (x : Fin n \u2192 \u211d) => \u2211 i, x i)\u2020 = 0 := by simp; admit\nexample : (\u03bb (x : Fin n \u2192 \u211d) => \u2211 i, 1 * x i)\u2020 = 0 := by simp; admit\n\nexample : HasAdjoint (\u03bb x : \u211d => 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 : (\u03bb (x : Fin n \u2192 \u211d) i => 2 * x i)\u2020 = 0 := \nby\n  simp -- [-SciLean.swap.arg_y.adj_simp] \n  simp; admit\n\n\nexample : (\u03bb (x : Fin n \u2192 \u211d) i => 2 * x i)\u2020 = 0 := by simp; admit\n\nexample : (\u03bb (x : Fin n \u2192 \u211d) => \u2211 i, 2 * x i)\u2020 = 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": "import algebra.group.to_additive\nimport algebra.group.units\nimport tactic\n\n-- work in a namespace so that it doesn't matter if names clash\nnamespace test\n@[to_additive bar0]\ndef foo0 {\u03b1} [has_mul \u03b1] [has_one \u03b1] (x y : \u03b1) : \u03b1 := x * y * 1\n\nclass {u v} my_has_pow (\u03b1 : Type u) (\u03b2 : Type v) :=\n(pow : \u03b1 \u2192 \u03b2 \u2192 \u03b1)\n\nclass my_has_scalar (M : Type*) (\u03b1 : Type*) := (smul : M \u2192 \u03b1 \u2192 \u03b1)\n\nattribute [to_additive_reorder 1] my_has_pow\nattribute [to_additive_reorder 1 4] my_has_pow.pow\nattribute [to_additive test.my_has_scalar] my_has_pow\nattribute [to_additive test.my_has_scalar.smul] my_has_pow.pow\n\n-- set_option pp.universes true\n-- set_option pp.implicit true\n-- set_option pp.notation false\n\n@[priority 10000]\nlocal infix ` ^ `:80 := my_has_pow.pow\n\n@[to_additive bar1]\ndef foo1 {\u03b1} [my_has_pow \u03b1 \u2115] (x : \u03b1) (n : \u2115) : \u03b1 := @my_has_pow.pow \u03b1 \u2115 _ x n\n\ninstance dummy : my_has_pow \u2115 $ plift \u2124 := \u27e8\u03bb _ _, 0\u27e9\n\nset_option pp.universes true\n@[to_additive bar2]\ndef foo2 {\u03b1} [my_has_pow \u03b1 \u2115] (x : \u03b1) (n : \u2115) (m : plift \u2124) : \u03b1 := x ^ (n ^ m)\n\n@[to_additive bar3]\ndef foo3 {\u03b1} [my_has_pow \u03b1 \u2115] (x : \u03b1) : \u2115 \u2192 \u03b1 := @my_has_pow.pow \u03b1 \u2115 _ x\n\n@[to_additive bar4]\ndef {a b} foo4 {\u03b1 : Type a} : Type b \u2192 Type (max a b) := @my_has_pow \u03b1\n\n@[to_additive bar4_test]\nlemma foo4_test {\u03b1 \u03b2 : Type*} : @foo4 \u03b1 \u03b2 = @my_has_pow \u03b1 \u03b2 := rfl\n\n@[to_additive bar5]\ndef foo5 {\u03b1} [my_has_pow \u03b1 \u2115] [my_has_pow \u2115 \u2124] : true := trivial\n\n@[to_additive bar6]\ndef foo6 {\u03b1} [my_has_pow \u03b1 \u2115] : \u03b1 \u2192 \u2115 \u2192 \u03b1 := @my_has_pow.pow \u03b1 \u2115 _\n\n@[to_additive bar7]\ndef foo7 := @my_has_pow.pow\n\nopen tactic\n/- test the eta-expansion applied on `foo6`. -/\nrun_cmd do\nenv \u2190 get_env,\nreorder \u2190 to_additive.reorder_attr.get_cache,\nd \u2190 get_decl `test.foo6,\nlet e := d.value.eta_expand env reorder,\nlet t := d.type.eta_expand env reorder,\nlet decl := declaration.defn `test.barr6 d.univ_params t e d.reducibility_hints d.is_trusted,\nadd_decl decl,\nskip\n\n/-! Test the namespace bug (#8733). This code should *not* generate a lemma\n  `add_some_def.in_namespace`. -/\ndef some_def.in_namespace : bool := ff\n\ndef some_def {\u03b1 : Type*} [has_mul \u03b1] (x : \u03b1) : \u03b1 :=\nif some_def.in_namespace then x * x else x\n\n-- cannot apply `@[to_additive]` to `some_def` if `some_def.in_namespace` doesn't have the attribute\nrun_cmd do\n  dict \u2190 to_additive.aux_attr.get_cache,\n  success_if_fail\n    (transform_decl_with_prefix_dict dict ff tt mk_name_map mk_name_map mk_name_map\n      `some_def `add_some_def []),\n  skip\n\nattribute [to_additive some_other_name] some_def.in_namespace\nattribute [to_additive add_some_def] some_def\n\nrun_cmd success_if_fail (get_decl `add_some_def.in_namespace)\n\nexample : (add_units.mk_of_add_eq_zero 0 0 (by simp) : \u2115)\n        = (add_units.mk_of_add_eq_zero 0 0 (by simp) : \u2115) :=\nby norm_cast\n\n-- TODO test alias\n\n-- test @[to_additive_relevant_args] and to_additive.first_multiplicative_arg\n\n-- first multiplicative argument: f\ndef foo_mul {I J K : Type*} (n : \u2115) {f : I \u2192 Type*} (L : Type*) [\u2200 i (n : \u2115), bool \u2192 has_one (f i)]\n  [has_add I] [has_mul L] : true :=\ntrivial\n\n@[to_additive]\ninstance pi.has_one {I : Type*} {f : I \u2192 Type*} [\u2200 i, has_one $ f i] : has_one (\u03a0 i : I, f i) :=\n\u27e8\u03bb _, 1\u27e9\n\nrun_cmd do\n  n \u2190 to_additive.first_multiplicative_arg `test.pi.has_one,\n  guard $ n = 2,\n  n \u2190 to_additive.first_multiplicative_arg `test.foo_mul,\n  guard $ n = 5\n\n@[to_additive]\ndef nat_pi_has_one {\u03b1 : Type*} [has_one \u03b1] : has_one (\u03a0 x : \u2115, \u03b1) := by apply_instance\n\n@[to_additive]\ndef pi_nat_has_one {I : Type*} : has_one (\u03a0 x : I, \u2115) := by apply_instance\n\nend test\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/to_additive.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.749087201911703, "lm_q2_score": 0.6076631698328917, "lm_q1q2_score": 0.4551927035949168}}
{"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\u2081`.\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\u2081 v\u2082 v\u2083 u\u2081 u\u2082\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\u2081} [category.{v\u2081} J]\nvariables {C : Type u\u2082} [category.{u\u2081} C]\n\n/-- This type indexes the connected components of the category `J`. -/\ndef connected_components (J : Type u\u2081) [category.{v\u2081} J] : Type u\u2081 := quotient (zigzag.setoid J)\n\ninstance [inhabited J] : inhabited (connected_components J) := \u27e8quotient.mk' default\u27e9\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\u2081 := full_subcategory (\u03bb 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.\u03b9 (j) : component j \u2964 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 \u27e8\u27e8k, rfl\u27e9\u27e9,\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 \u27e8j\u2081, hj\u2081\u27e9 \u27e8j\u2082, rfl\u27e9,\n  -- We know that the underlying objects j\u2081 j\u2082 have some zigzag between them in `J`\n  have h\u2081\u2082 : zigzag j\u2081 j\u2082 := quotient.exact' hj\u2081,\n  -- Get an explicit zigzag as a list\n  rcases list.exists_chain_of_relation_refl_trans_gen h\u2081\u2082 with \u27e8l, hl\u2081, hl\u2082\u27e9,\n  -- Everything which has a zigzag to j\u2082 can be lifted to the same component as `j\u2082`.\n  let f : \u03a0 x, zigzag x j\u2082 \u2192 component (quotient.mk' j\u2082) := \u03bb x h, \u27e8x, quotient.sound' h\u27e9,\n  -- Everything in our chosen zigzag from `j\u2081` to `j\u2082` has a zigzag to `j\u2082`.\n  have hf : \u2200 (a : J), a \u2208 l \u2192 zigzag a j\u2082,\n  { intros i hi,\n    apply list.chain.induction (\u03bb t, zigzag t j\u2082) _ hl\u2081 hl\u2082 _ _ _ (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\u2081` to `j\u2082` in `J` to the same thing in `component j`.\n  refine \u27e8l.pmap f hf, _, _\u27e9,\n  { refine @@list.chain_pmap_of_chain _ _ _ f (\u03bb x y _ _ h, _) hl\u2081 h\u2081\u2082 _,\n    exact zag_of_zag_obj (component.\u03b9 _) h },\n  { erw list.last_pmap _ f (j\u2081 :: l) (by simpa [h\u2081\u2082] using hf) (list.cons_ne_nil _ _),\n    exact full_subcategory.ext _ _ hl\u2082 },\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\u2081) [category.{v\u2081} J] :=\n\u03a3 (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 \u2964 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\u2081) [category.{v\u2081} J] : decomposed J \u2964 J :=\nsigma.desc component.\u03b9\n\n@[simp]\nlemma inclusion_comp_decomposed_to (j : connected_components J) :\n  inclusion j \u22d9 decomposed_to J = component.\u03b9 j :=\nrfl\n\ninstance : full (decomposed_to J) :=\n{ preimage :=\n  begin\n    rintro \u27e8j', X, hX\u27e9 \u27e8k', Y, hY\u27e9 f,\n    dsimp at f,\n    have : j' = k',\n      rw [\u2190 hX, \u2190 hY, quotient.eq'],\n      exact relation.refl_trans_gen.single (or.inl \u27e8f\u27e9),\n    subst this,\n    refine sigma.sigma_hom.mk f,\n  end,\n  witness' :=\n  begin\n    rintro \u27e8j', X, hX\u27e9 \u27e8_, Y, rfl\u27e9 f,\n    have : quotient.mk' Y = j',\n    { rw [\u2190 hX, quotient.eq'],\n      exact relation.refl_trans_gen.single (or.inr \u27e8f\u27e9) },\n    subst this,\n    refl,\n  end }\n\ninstance : faithful (decomposed_to J) :=\n{ map_injective' :=\n  begin\n    rintro \u27e8_, j, rfl\u27e9 \u27e8_, k, hY\u27e9 \u27e8f\u27e9 \u27e8g\u27e9 e,\n    change f = g at e,\n    subst e,\n  end }\n\ninstance : ess_surj (decomposed_to J) :=\n{ mem_ess_image := \u03bb j, \u27e8\u27e8_, j, rfl\u27e9, \u27e8iso.refl _\u27e9\u27e9 }\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 \u224c 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 \u2022 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 \u2192\u2097[K] Y.obj):\n  left_unitor.hom K (module.dual K X.obj) \u2218\u2097\n  tensor_product.map (evaluation.hom K Y.obj) linear_map.id \u2218\u2097\n  associator.inv K _ _ _ \u2218\u2097\n  tensor_product.map linear_map.id (tensor_product.map f linear_map.id) \u2218\u2097\n  tensor_product.map linear_map.id (coevaluation.hom K X.obj) \u2218\u2097\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, \u2190map_sum], congr,\n  simp_rw [\u2190map_smul, \u2190map_sum], congr,\n  rw basis.sum_repr,\nend\n\nlemma right_adjoint_mate_eq_dual {X Y: FinVect K} (f: X \u27f6 Y):\n  f\u1601 = 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  ((\u03b4_ X Y).inv: _ \u2192\u2097[K] _) (g \u2297\u209c[K] f) = \u2191(tensor_product.lid K K) \u2218\u2097 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  \u21d1(module.eval_equiv K V) = module.dual.eval K V :=\nby rw [\u2190module.eval_equiv_to_linear_map, linear_equiv.coe_to_linear_map]\n\nnoncomputable def right_pivotor (X: FinVect K): X \u2245 X\u1601\u1601 := {\n  hom := right_pivotor.hom K X.obj,\n  inv := right_pivotor.inv K X.obj,\n  hom_inv_id' := by ext; simp [\u2190module.eval_equiv_to_linear_map],\n  inv_hom_id' := by ext; simp [\u2190module.eval_equiv_to_linear_map]\n}\n\nlemma right_pivotor_naturality (X Y: FinVect K) (f: X \u27f6 Y):\n  f \u226b (right_pivotor Y).hom = (right_pivotor X).hom \u226b f\u1601\u1601 :=\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 \u2297 Y)).hom = ((right_pivotor X).hom \u2297 (right_pivotor Y).hom) \u226b (\u03b4_ _ _).inv \u226b ((\u03b4_ _ _).hom)\u1601 :=\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 {\u03b1 : Type*} [add_comm_monoid \u03b1] (f : \u2115 \u2192 \u2115 \u2192 \u03b1) (n : \u2115) : series (\u03bb i, \nseries (\u03bb k, f k (i - k)) i) n = series (\u03bb i, series (\u03bb k, f i k) (n - i)) n := begin\n  have : \u2200 m : \u2115, m \u2264 n \u2192 series (\u03bb (i : \u2115), series (\u03bb k, f k (i - k)) (min m i)) n =\n      series (\u03bb i, series (\u03bb 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 \u2190hi (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\u2082,\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\u2082),min_eq_left mn,hi (le_of_lt_succ h)],rw [\u2190add_assoc,\u2190add_assoc],\n    suffices : series (f (succ m')) (n\u2082 - m') + series (\u03bb (k : \u2115), f k (succ (succ n\u2082) - k)) (succ m')\n    = series (f (succ m')) (succ n\u2082 - m') +\n        series (\u03bb (k : \u2115), f k (succ (succ n\u2082) - k)) (min m' (succ (succ n\u2082))),\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 (\u03bb (k : \u2115), f k (succ (succ n\u2082) - k)) m'),add_assoc],      \n    rw \u2190h,simp[nat.sub_self],clear hi mn h,simp[series_succ,nat.sub_self],\n    suffices : series (\u03bb (i : \u2115), series (\u03bb (k : \u2115), f k (i - k)) (min (succ m') i)) m' = series (\u03bb (i : \u2115), series (\u03bb (k : \u2115), f k (i - k)) (min m' i)) m',\n      rw [this,min_eq_left (le_succ _)],clear n\u2082,\n    have h\u2081 : \u2200 i \u2264 m', (\u03bb (i : \u2115), series (\u03bb (k : \u2115), f k (i - k)) (min (succ m') i)) i = (\u03bb (i : \u2115), series (\u03bb (k : \u2115), 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\u2081,\n  specialize this n (le_refl _),\n  rw \u2190this,refine series_congr _,assume i ni,rw min_eq_right ni,\nend\n\nlemma series_merten {\u03b1 \u03b2 : Type*} [discrete_linear_ordered_field \u03b1] [ring \u03b2] {a b : \u2115 \u2192 \u03b2}\n{abv : \u03b2 \u2192 \u03b1} [is_absolute_value abv] : is_cau_seq abs (series (\u03bb n, abv (a n))) \u2192 is_cau_seq abv (series b) \u2192 \n\u2200 \u03b5 : \u03b1, 0 < \u03b5 \u2192 \u2203 i : \u2115, \u2200 j \u2265 i, abv (series a j * series b j - series (\u03bb n, \nseries (\u03bb m, a m * b (n - m)) n) j) < \u03b5 := begin\n  assume ha hb \u03b5 \u03b50,\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\u03b50 := div_pos \u03b50 (mul_pos (show (2 : \u03b1) > 0, from by norm_num) P0),\n  cases cau_seq.cauchy\u2082 \u27e8_, hb\u27e9 P\u03b50 with N hN,simp at hN,\n  have Q\u03b50 := div_pos \u03b50 (mul_pos (show (4 : \u03b1) > 0, from by norm_num) (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0))),\n  cases cau_seq.cauchy\u2082 \u27e8_, ha\u27e9 Q\u03b50 with M hM,simp at hM,\n  existsi 2 * (max N M + 1),\n  assume K hK,have := diag_swap1 (\u03bb m n, a m * b n) K,simp at this,rw this,clear this,\n  have : (\u03bb (i : \u2115), series (\u03bb (k : \u2115), a i * b k) (K - i)) = (\u03bb (i : \u2115), a i * series (\u03bb (k : \u2115), b k) (K - i)),\n    {apply funext,assume i,rw series_mul_left},\n  rw this,clear this,simp,\n  have : series (\u03bb (i : \u2115), a i * series b (K - i)) K = series (\u03bb (i : \u2115), a i * (series b (K - i) - series b K))\n  K + series (\u03bb i, a i * series b K) K,\n    {rw \u2190series_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 (\u03bb (i : \u2115), abv (a i) * abv (series b (K - i) + -series b K)) (max N M + 1) + \n  (series (\u03bb (i : \u2115), abv (a i) * abv (series b (K - i) + -series b K)) K -series (\u03bb (i : \u2115), \n  abv (a i) * abv (series b (K - i) + -series b K)) (max N M + 1)) < \u03b5 / (2 * P) * P + \u03b5 / (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 : \u03b1) = 2 * 2),\u2190div_div_eq_div_mul,mul_comm (2 : \u03b1),\u2190mul_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 (\u03bb (i : \u2115), abv (a i) * abv (series b (K - i) + -series b K)) (max N M + 1) \u2264 series\n  (\u03bb (i : \u2115), abv (a i) * (\u03b5 / (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 \u2190one_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\u03b50).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,\u2190add_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 (\u03bb (i : \u2115), abv (a i) * abv (series b (K - i) + -series b K)) (max N M + 2) K \n  \u2264 nat.sum (\u03bb (i : \u2115), 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 \u2190(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 [\u2190series_sub_series _ hNMK,series_mul_right,series_mul_right,\u2190sub_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,\u2190add_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\u00f6lzl, Mario Carneiro, Anne Baanen,\n  Fr\u00e9d\u00e9ric 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 \u03c3 M M\u2082`, `M \u2243\u209b\u2097[\u03c3] M\u2082`: an invertible semilinear map. Here, `\u03c3` is a `ring_hom`\n  from `R` to `R\u2082` and an `e : M \u2243\u209b\u2097[\u03c3] M\u2082` satisfies `e (c \u2022 x) = (\u03c3 c) \u2022 (e x)`. The plain\n  linear version, with `\u03c3` being `ring_hom.id R`, is denoted by `M \u2243\u2097[R] M\u2082`, and the\n  star-linear version (with `\u03c3` begin `star_ring_aut`) is denoted by `M \u2243\u2097\u22c6[R] M\u2082`.\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\u2081 : Type*} {R\u2082 : Type*} {R\u2083 : Type*}\nvariables {k : Type*} {S : Type*} {M : Type*} {M\u2081 : Type*} {M\u2082 : Type*} {M\u2083 : Type*}\nvariables {N\u2081 : Type*} {N\u2082 : Type*} {N\u2083 : Type*} {N\u2084 : Type*} {\u03b9 : 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] (\u03c3 : R \u2192+* S)\n  {\u03c3' : S \u2192+* R} [ring_hom_inv_pair \u03c3 \u03c3'] [ring_hom_inv_pair \u03c3' \u03c3]\n  (M : Type*) (M\u2082 : Type*)\n  [add_comm_monoid M] [add_comm_monoid M\u2082] [module R M] [module S M\u2082]\n  extends linear_map \u03c3 M M\u2082, M \u2243+ M\u2082\nend\n\nattribute [nolint doc_blame] linear_equiv.to_linear_map\nattribute [nolint doc_blame] linear_equiv.to_add_equiv\n\nnotation M ` \u2243\u209b\u2097[`:50 \u03c3 `] ` M\u2082 := linear_equiv \u03c3 M M\u2082\nnotation M ` \u2243\u2097[`:50 R `] ` M\u2082 := linear_equiv (ring_hom.id R) M M\u2082\nnotation M ` \u2243\u2097\u22c6[`:50 R `] ` M\u2082 := linear_equiv (@star_ring_aut R _ _ : R \u2192+* R) M M\u2082\n\nnamespace linear_equiv\n\nsection add_comm_monoid\n\nvariables {M\u2084 : Type*}\nvariables [semiring R] [semiring S]\n\nsection\nvariables [add_comm_monoid M] [add_comm_monoid M\u2081] [add_comm_monoid M\u2082]\nvariables [module R M] [module S M\u2082] {\u03c3 : R \u2192+* S} {\u03c3' : S \u2192+* R}\nvariables [ring_hom_inv_pair \u03c3 \u03c3'] [ring_hom_inv_pair \u03c3' \u03c3]\n\ninclude R\n\ninclude \u03c3'\ninstance : has_coe (M \u2243\u209b\u2097[\u03c3] M\u2082) (M \u2192\u209b\u2097[\u03c3] M\u2082) := \u27e8to_linear_map\u27e9\n-- see Note [function coercion]\ninstance : has_coe_to_fun (M \u2243\u209b\u2097[\u03c3] M\u2082) (\u03bb _, M \u2192 M\u2082) := \u27e8to_fun\u27e9\n\n@[simp] lemma coe_mk {to_fun inv_fun map_add map_smul left_inv right_inv } :\n  \u21d1(\u27e8to_fun, map_add, map_smul, inv_fun, left_inv, right_inv\u27e9 : M \u2243\u209b\u2097[\u03c3] M\u2082) = to_fun :=\nrfl\n\n-- This exists for compatibility, previously `\u2243\u2097[R]` extended `\u2243` instead of `\u2243+`.\n@[nolint doc_blame]\ndef to_equiv : (M \u2243\u209b\u2097[\u03c3] M\u2082) \u2192 M \u2243 M\u2082 := \u03bb f, f.to_add_equiv.to_equiv\n\nlemma to_equiv_injective : function.injective (to_equiv : (M \u2243\u209b\u2097[\u03c3] M\u2082) \u2192 M \u2243 M\u2082) :=\n\u03bb \u27e8_, _, _, _, _, _\u27e9 \u27e8_, _, _, _, _, _\u27e9 h, linear_equiv.mk.inj_eq.mpr (equiv.mk.inj h)\n\n@[simp] lemma to_equiv_inj {e\u2081 e\u2082 : M \u2243\u209b\u2097[\u03c3] M\u2082} : e\u2081.to_equiv = e\u2082.to_equiv \u2194 e\u2081 = e\u2082 :=\nto_equiv_injective.eq_iff\n\nlemma to_linear_map_injective :\n  injective (coe : (M \u2243\u209b\u2097[\u03c3] M\u2082) \u2192 (M \u2192\u209b\u2097[\u03c3] M\u2082)) :=\n\u03bb e\u2081 e\u2082 H, to_equiv_injective $ equiv.ext $ linear_map.congr_fun H\n\n@[simp, norm_cast] lemma to_linear_map_inj {e\u2081 e\u2082 : M \u2243\u209b\u2097[\u03c3] M\u2082} :\n  (e\u2081 : M \u2192\u209b\u2097[\u03c3] M\u2082) = e\u2082 \u2194 e\u2081 = e\u2082 :=\nto_linear_map_injective.eq_iff\n\nlemma coe_injective :\n  @injective (M \u2243\u209b\u2097[\u03c3] M\u2082) (M \u2192 M\u2082) coe_fn :=\nlinear_map.coe_injective.comp to_linear_map_injective\n\nend\n\nsection\nvariables [semiring R\u2081] [semiring R\u2082] [semiring R\u2083]\nvariables [add_comm_monoid M] [add_comm_monoid M\u2081] [add_comm_monoid M\u2082]\nvariables [add_comm_monoid M\u2083] [add_comm_monoid M\u2084]\nvariables [add_comm_monoid N\u2081] [add_comm_monoid N\u2082]\nvariables {module_M : module R M} {module_S_M\u2082 : module S M\u2082} {\u03c3 : R \u2192+* S} {\u03c3' : S \u2192+* R}\nvariables {re\u2081 : ring_hom_inv_pair \u03c3 \u03c3'} {re\u2082 : ring_hom_inv_pair \u03c3' \u03c3}\nvariables (e e' : M \u2243\u209b\u2097[\u03c3] M\u2082)\n\nlemma to_linear_map_eq_coe : e.to_linear_map = (e : M \u2192\u209b\u2097[\u03c3] M\u2082) := rfl\n\n@[simp, norm_cast] theorem coe_coe : \u21d1(e : M \u2192\u209b\u2097[\u03c3] M\u2082) = e := rfl\n\n@[simp] lemma coe_to_equiv : \u21d1e.to_equiv = e := rfl\n\n@[simp] lemma coe_to_linear_map : \u21d1e.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 : \u2200 x, e x = e' x) : e = e' :=\ncoe_injective $ funext h\n\nprotected lemma congr_arg : \u03a0 {x x' : M}, x = x' \u2192 e x = e x'\n| _ _ rfl := rfl\n\nprotected lemma congr_fun (h : e = e') (x : M) : e x = e' x := h \u25b8 rfl\n\nlemma ext_iff : e = e' \u2194 \u2200 x, e x = e' x :=\n\u27e8\u03bb h x, h \u25b8 rfl, ext\u27e9\n\nend\n\nsection\nvariables (M R)\n\n/-- The identity map is a linear equivalence. -/\n@[refl]\ndef refl [module R M] : M \u2243\u2097[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\u2082 re\u2081 re\u2082\n/-- Linear equivalences are symmetric. -/\n@[symm]\ndef symm (e : M \u2243\u209b\u2097[\u03c3] M\u2082) : M\u2082 \u2243\u209b\u2097[\u03c3'] 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' := \u03bb 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\u2082 re\u2081 re\u2082\n\n/-- See Note [custom simps projection] -/\ndef simps.symm_apply {R : Type*} {S : Type*} [semiring R] [semiring S] {\u03c3 : R \u2192+* S}\n  {\u03c3' : S \u2192+* R} [ring_hom_inv_pair \u03c3 \u03c3'] [ring_hom_inv_pair \u03c3' \u03c3]\n  {M : Type*} {M\u2082 : Type*} [add_comm_monoid M] [add_comm_monoid M\u2082] [module R M] [module S M\u2082]\n  (e : M \u2243\u209b\u2097[\u03c3] M\u2082) : M\u2082 \u2192 M := e.symm\n\ninitialize_simps_projections linear_equiv (to_fun \u2192 apply, inv_fun \u2192 symm_apply)\n\ninclude \u03c3'\n@[simp] lemma inv_fun_eq_symm : e.inv_fun = e.symm := rfl\nomit \u03c3'\n\nvariables {module_M\u2081 : module R\u2081 M\u2081} {module_M\u2082 : module R\u2082 M\u2082} {module_M\u2083 : module R\u2083 M\u2083}\nvariables {module_N\u2081 : module R\u2081 N\u2081} {module_N\u2082 : module R\u2081 N\u2082}\nvariables {\u03c3\u2081\u2082 : R\u2081 \u2192+* R\u2082} {\u03c3\u2082\u2083 : R\u2082 \u2192+* R\u2083} {\u03c3\u2081\u2083 : R\u2081 \u2192+* R\u2083}\nvariables {\u03c3\u2082\u2081 : R\u2082 \u2192+* R\u2081} {\u03c3\u2083\u2082 : R\u2083 \u2192+* R\u2082} {\u03c3\u2083\u2081 : R\u2083 \u2192+* R\u2081}\nvariables [ring_hom_comp_triple \u03c3\u2081\u2082 \u03c3\u2082\u2083 \u03c3\u2081\u2083]\nvariables [ring_hom_comp_triple \u03c3\u2083\u2082 \u03c3\u2082\u2081 \u03c3\u2083\u2081]\nvariables {re\u2081\u2082 : ring_hom_inv_pair \u03c3\u2081\u2082 \u03c3\u2082\u2081} {re\u2082\u2083 : ring_hom_inv_pair \u03c3\u2082\u2083 \u03c3\u2083\u2082}\nvariables [ring_hom_inv_pair \u03c3\u2081\u2083 \u03c3\u2083\u2081] {re\u2082\u2081 : ring_hom_inv_pair \u03c3\u2082\u2081 \u03c3\u2081\u2082}\nvariables {re\u2083\u2082 : ring_hom_inv_pair \u03c3\u2083\u2082 \u03c3\u2082\u2083} [ring_hom_inv_pair \u03c3\u2083\u2081 \u03c3\u2081\u2083]\nvariables (e\u2081\u2082 : M\u2081 \u2243\u209b\u2097[\u03c3\u2081\u2082] M\u2082) (e\u2082\u2083 : M\u2082 \u2243\u209b\u2097[\u03c3\u2082\u2083] M\u2083)\n\ninclude \u03c3\u2083\u2081\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\u2081 \u2243\u209b\u2097[\u03c3\u2081\u2083] M\u2083 :=\n{ .. e\u2082\u2083.to_linear_map.comp e\u2081\u2082.to_linear_map,\n  .. e\u2081\u2082.to_equiv.trans e\u2082\u2083.to_equiv }\nomit \u03c3\u2083\u2081\n\ninfixl ` \u226a\u226b\u2097 `: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\u2081\u2082} {e\u2082\u2083}\n\n@[simp] lemma coe_to_add_equiv : \u21d1(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 \u03c3\u2083\u2081\n@[simp] theorem trans_apply (c : M\u2081) :\n  (e\u2081\u2082.trans e\u2082\u2083 : M\u2081 \u2243\u209b\u2097[\u03c3\u2081\u2083] M\u2083) c = e\u2082\u2083 (e\u2081\u2082 c) := rfl\nomit \u03c3\u2083\u2081\n\ninclude \u03c3'\n@[simp] theorem apply_symm_apply (c : M\u2082) : 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 \u03c3'\n\ninclude \u03c3\u2083\u2081 \u03c3\u2082\u2081 \u03c3\u2083\u2082\n@[simp] lemma symm_trans_apply\n  (c : M\u2083) : (e\u2081\u2082.trans e\u2082\u2083 : M\u2081 \u2243\u209b\u2097[\u03c3\u2081\u2083] M\u2083).symm c = e\u2081\u2082.symm (e\u2082\u2083.symm c) := rfl\nomit \u03c3\u2083\u2081 \u03c3\u2082\u2081 \u03c3\u2083\u2082\n\n@[simp] lemma trans_refl : e.trans (refl S M\u2082) = 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 \u03c3'\nlemma symm_apply_eq {x y} : e.symm x = y \u2194 x = e y := e.to_equiv.symm_apply_eq\n\nlemma eq_symm_apply {x y} : y = e.symm x \u2194 e y = x := e.to_equiv.eq_symm_apply\nomit \u03c3'\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\u2082] (f : M \u2243\u2097[R] M\u2082) :\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\u2082] (f : M \u2243\u2097[R] M\u2082) :\n  f.symm.trans f = linear_equiv.refl R M\u2082 :=\nby { ext x, simp }\n\n@[simp, norm_cast] lemma refl_to_linear_map [module R M] :\n  (linear_equiv.refl R M : M \u2192\u2097[R] M) = linear_map.id :=\nrfl\n\n@[simp, norm_cast]\nlemma comp_coe [module R M] [module R M\u2082] [module R M\u2083] (f :  M \u2243\u2097[R] M\u2082)\n  (f' :  M\u2082 \u2243\u2097[R] M\u2083) : (f' : M\u2082 \u2192\u2097[R] M\u2083).comp (f : M \u2192\u2097[R] M\u2082) = (f.trans f' : M \u2243\u2097[R] M\u2083) :=\nrfl\n\n@[simp] lemma mk_coe (h\u2081 h\u2082 f h\u2083 h\u2084) :\n  (linear_equiv.mk e h\u2081 h\u2082 f h\u2083 h\u2084 : M \u2243\u209b\u2097[\u03c3] M\u2082) = e := ext $ \u03bb _, 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\u209b\u2097 (c : R) (x : M) : e (c \u2022 x) = (\u03c3 c) \u2022 e x := e.map_smul' c x\n\ninclude module_N\u2081 module_N\u2082\ntheorem map_smul (e : N\u2081 \u2243\u2097[R\u2081] N\u2082) (c : R\u2081) (x : N\u2081) :\n  e (c \u2022 x) = c \u2022 e x := map_smul\u209b\u2097 _ _ _\nomit module_N\u2081 module_N\u2082\n\n@[simp] lemma map_sum {s : finset \u03b9} (u : \u03b9 \u2192 M) : e (\u2211 i in s, u i) = \u2211 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 \u2194 x = 0 :=\ne.to_add_equiv.map_eq_zero_iff\ntheorem map_ne_zero_iff {x : M} : e x \u2260 0 \u2194 x \u2260 0 :=\ne.to_add_equiv.map_ne_zero_iff\n\ninclude module_M module_S_M\u2082 re\u2081 re\u2082\n@[simp] theorem symm_symm (e : M \u2243\u209b\u2097[\u03c3] M\u2082): e.symm.symm = e :=\nby { cases e, refl }\nomit module_M module_S_M\u2082 re\u2081 re\u2082\n\nlemma symm_bijective [module R M] [module S M\u2082] [ring_hom_inv_pair \u03c3' \u03c3]\n  [ring_hom_inv_pair \u03c3 \u03c3'] : function.bijective (symm : (M \u2243\u209b\u2097[\u03c3] M\u2082) \u2192 (M\u2082 \u2243\u209b\u2097[\u03c3'] M)) :=\nequiv.bijective \u27e8(symm : (M \u2243\u209b\u2097[\u03c3] M\u2082) \u2192\n  (M\u2082 \u2243\u209b\u2097[\u03c3'] M)), (symm : (M\u2082 \u2243\u209b\u2097[\u03c3'] M) \u2192 (M \u2243\u209b\u2097[\u03c3] M\u2082)), symm_symm, symm_symm\u27e9\n\n@[simp] lemma mk_coe' (f h\u2081 h\u2082 h\u2083 h\u2084) : (linear_equiv.mk f h\u2081 h\u2082 \u21d1e h\u2083 h\u2084 :\n  M\u2082 \u2243\u209b\u2097[\u03c3'] M) = e.symm :=\nsymm_bijective.injective $ ext $ \u03bb x, rfl\n\ninclude \u03c3'\n@[simp] theorem symm_mk (f h\u2081 h\u2082 h\u2083 h\u2084) :\n  (\u27e8e, h\u2081, h\u2082, f, h\u2083, h\u2084\u27e9 : M \u2243\u209b\u2097[\u03c3] M\u2082).symm =\n  { to_fun := f, inv_fun := e,\n    ..(\u27e8e, h\u2081, h\u2082, f, h\u2083, h\u2084\u27e9 : M \u2243\u209b\u2097[\u03c3] M\u2082).symm } := rfl\nomit \u03c3'\n\n@[simp] lemma coe_symm_mk [module R M] [module R M\u2082]\n  {to_fun inv_fun map_add map_smul left_inv right_inv} :\n  \u21d1((\u27e8to_fun, map_add, map_smul, inv_fun, left_inv, right_inv\u27e9 : M \u2243\u2097[R] M\u2082).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 \u03c3'\nprotected lemma image_eq_preimage (s : set M) : e '' s = e.symm \u207b\u00b9' s :=\ne.to_equiv.image_eq_preimage s\nomit \u03c3'\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 \u2243+* S) :\n  by haveI := ring_hom_inv_pair.of_ring_equiv f;\n     haveI := ring_hom_inv_pair.symm (\u2191f : R \u2192+* S) (f.symm : S \u2192+* R);\n     exact (R \u2243\u209b\u2097[(\u2191f : R \u2192+* S)] S) :=\nby exact\n{ to_fun := f,\n  map_smul' := f.map_mul,\n  .. f}\n\nvariables [semiring R\u2081] [semiring R\u2082] [semiring R\u2083]\nvariables [add_comm_monoid M] [add_comm_monoid M\u2081] [add_comm_monoid M\u2082]\n\n/-- An involutive linear map is a linear equivalence. -/\ndef of_involutive {\u03c3 \u03c3' : R \u2192+* R} [ring_hom_inv_pair \u03c3 \u03c3'] [ring_hom_inv_pair \u03c3' \u03c3]\n  {module_M : module R M} (f : M \u2192\u209b\u2097[\u03c3] M) (hf : involutive f) :\n  M \u2243\u209b\u2097[\u03c3] M :=\n{ .. f, .. hf.to_equiv f }\n\n@[simp] lemma coe_of_involutive {\u03c3 \u03c3' : R \u2192+* R} [ring_hom_inv_pair \u03c3 \u03c3']\n  [ring_hom_inv_pair \u03c3' \u03c3] {module_M : module R M} (f : M \u2192\u209b\u2097[\u03c3] M) (hf : involutive f) :\n  \u21d1(of_involutive f hf) = f :=\nrfl\n\nsection restrict_scalars\n\nvariables (R) [module R M] [module R M\u2082] [module S M] [module S M\u2082]\n  [linear_map.compatible_smul M M\u2082 R S]\n\n/-- If `M` and `M\u2082` 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\u2082` is also an `R`-linear equivalence.\n\nSee also `linear_map.restrict_scalars`. -/\n@[simps]\ndef restrict_scalars (f : M \u2243\u2097[S] M\u2082) : M \u2243\u2097[R] M\u2082 :=\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 \u2243\u2097[S] M\u2082) \u2192 (M \u2243\u2097[R] M\u2082)) :=\n\u03bb f g h, ext (linear_equiv.congr_fun h : _)\n\n@[simp]\nlemma restrict_scalars_inj (f g : M \u2243\u2097[S] M\u2082) :\n  f.restrict_scalars R = g.restrict_scalars R \u2194 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 \u2243\u2097[R] M) :=\n{ mul := \u03bb f g, g.trans f,\n  one := linear_equiv.refl R M,\n  inv := \u03bb f, f.symm,\n  mul_assoc := \u03bb f g h, rfl,\n  mul_one := \u03bb f, ext $ \u03bb x, rfl,\n  one_mul := \u03bb f, ext $ \u03bb x, rfl,\n  mul_left_inv := \u03bb 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 \u2243\u2097[R] M) \u2192* (M \u2192\u2097[R] M) :=\n{ to_fun := coe,\n  map_one' := rfl,\n  map_mul' := \u03bb _ _, rfl }\n\n/-- The tautological action by `M \u2243\u2097[R] M` on `M`.\n\nThis generalizes `function.End.apply_mul_action`. -/\ninstance apply_distrib_mul_action : distrib_mul_action (M \u2243\u2097[R] M) M :=\n{ smul := ($),\n  smul_zero := linear_equiv.map_zero,\n  smul_add := linear_equiv.map_add,\n  one_smul := \u03bb _, rfl,\n  mul_smul := \u03bb _ _ _, rfl }\n\n@[simp] protected lemma smul_def (f : M \u2243\u2097[R] M) (a : M) :\n  f \u2022 a = f a := rfl\n\n/-- `linear_equiv.apply_distrib_mul_action` is faithful. -/\ninstance apply_has_faithful_scalar : has_faithful_scalar (M \u2243\u2097[R] M) M :=\n\u27e8\u03bb _ _, linear_equiv.ext\u27e9\n\ninstance apply_smul_comm_class : smul_comm_class R (M \u2243\u2097[R] M) M :=\n{ smul_comm := \u03bb r e m, (e.map_smul r m).symm }\n\ninstance apply_smul_comm_class' : smul_comm_class (M \u2243\u2097[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 \u2243+* 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 \u2243+* S) :\n  (by haveI := comp_hom S (\u2191g : R \u2192+* S); exact (R \u2243\u2097[R] S)) :=\nby exact\n{ to_fun := (g : R \u2192 S),\n  inv_fun := (g.symm : S \u2192 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 \u2243\u2097[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 \u2192* M \u2243\u2097[R] M :=\n{ to_fun := to_linear_equiv R M,\n  map_one' := linear_equiv.ext $ one_smul _,\n  map_mul' := \u03bb 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 `\u03bc` is a non-zero finite measure on `\u03b1`, `s` is a convex closed set\n  in `E`, and `f` is an integrable function sending `\u03bc`-a.e. points to `s`, then the average value\n  of `f` belongs to `s`: `(\u03bc univ).to_real\u207b\u00b9 \u2022 \u222b x, f x \u2202\u03bc \u2208 s`. See also `convex.center_mass_mem`\n  for a finite sum version of this lemma.\n\n* `convex.integral_mem`: if `\u03bc` is a probability measure on `\u03b1`, `s` is a convex closed set in `E`,\n  and `f` is an integrable function sending `\u03bc`-a.e. points to `s`, then the expected value of `f`\n  belongs to `s`: `\u222b x, f x \u2202\u03bc \u2208 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 \u2192 \u211d` is convex and\n  continuous on a convex closed set `s`, `\u03bc` is a finite non-zero measure on `\u03b1`, and `f : \u03b1 \u2192 E` is\n  a function sending `\u03bc`-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 \u2218 f` provided that both `f` and `g \u2218 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 \u2192 \u211d` is convex and\n  continuous on a convex closed set `s`, `\u03bc` is a probability measure on `\u03b1`, and `f : \u03b1 \u2192 E` is a\n  function sending `\u03bc`-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 \u2218 f` provided that both `f` and `g \u2218 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 `\u03bc` is a non-zero finite measure on `\u03b1`, `s` is a convex closed set in `E`, and `f` is an\nintegrable function sending `\u03bc`-a.e. points to `s`, then the average value of `f` belongs to `s`:\n`(\u03bc univ).to_real\u207b\u00b9 \u2022 \u222b x, f x \u2202\u03bc \u2208 s`. See also `convex.center_mass_mem` for a finite sum version\nof this lemma. -/\ntheorem convex.smul_integral_mem {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} [normed_group E] [normed_space \u211d E] [complete_space E] [topological_space.second_countable_topology E] [measurable_space E] [borel_space E] [measure_theory.finite_measure \u03bc] {s : set E} (hs : convex s) (hsc : is_closed s) (h\u03bc : \u03bc \u2260 0) {f : \u03b1 \u2192 E} (hfs : filter.eventually (fun (x : \u03b1) => f x \u2208 s) (measure_theory.measure.ae \u03bc)) (hfi : measure_theory.integrable f) : (ennreal.to_real (coe_fn \u03bc set.univ)\u207b\u00b9 \u2022 measure_theory.integral \u03bc fun (x : \u03b1) => f x) \u2208 s := sorry\n\n/-- If `\u03bc` is a probability measure on `\u03b1`, `s` is a convex closed set in `E`, and `f` is an\nintegrable function sending `\u03bc`-a.e. points to `s`, then the expected value of `f` belongs to `s`:\n`\u222b x, f x \u2202\u03bc \u2208 s`. See also `convex.sum_mem` for a finite sum version of this lemma. -/\ntheorem convex.integral_mem {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} [normed_group E] [normed_space \u211d E] [complete_space E] [topological_space.second_countable_topology E] [measurable_space E] [borel_space E] [measure_theory.probability_measure \u03bc] {s : set E} (hs : convex s) (hsc : is_closed s) {f : \u03b1 \u2192 E} (hf : filter.eventually (fun (x : \u03b1) => f x \u2208 s) (measure_theory.measure.ae \u03bc)) (hfi : measure_theory.integrable f) : (measure_theory.integral \u03bc fun (x : \u03b1) => f x) \u2208 s := sorry\n\n/-- Jensen's inequality: if a function `g : E \u2192 \u211d` is convex and continuous on a convex closed set\n`s`, `\u03bc` is a finite non-zero measure on `\u03b1`, and `f : \u03b1 \u2192 E` is a function sending `\u03bc`-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 \u2218 f` provided that both `f` and `g \u2218 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 {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} [normed_group E] [normed_space \u211d E] [complete_space E] [topological_space.second_countable_topology E] [measurable_space E] [borel_space E] [measure_theory.finite_measure \u03bc] {s : set E} {g : E \u2192 \u211d} (hg : convex_on s g) (hgc : continuous_on g s) (hsc : is_closed s) (h\u03bc : \u03bc \u2260 0) {f : \u03b1 \u2192 E} (hfs : filter.eventually (fun (x : \u03b1) => f x \u2208 s) (measure_theory.measure.ae \u03bc)) (hfi : measure_theory.integrable f) (hgi : measure_theory.integrable (g \u2218 f)) : g (ennreal.to_real (coe_fn \u03bc set.univ)\u207b\u00b9 \u2022 measure_theory.integral \u03bc fun (x : \u03b1) => f x) \u2264\n  ennreal.to_real (coe_fn \u03bc set.univ)\u207b\u00b9 \u2022 measure_theory.integral \u03bc fun (x : \u03b1) => g (f x) := sorry\n\n/-- Jensen's inequality: if a function `g : E \u2192 \u211d` is convex and continuous on a convex closed set\n`s`, `\u03bc` is a probability measure on `\u03b1`, and `f : \u03b1 \u2192 E` is a function sending `\u03bc`-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 \u2218 f` provided that both `f` and `g \u2218 f` are integrable. See also `convex.map_sum_le` for a\nfinite sum version of this lemma. -/\ntheorem convex_on.map_integral_le {\u03b1 : Type u_1} {E : Type u_2} [measurable_space \u03b1] {\u03bc : measure_theory.measure \u03b1} [normed_group E] [normed_space \u211d E] [complete_space E] [topological_space.second_countable_topology E] [measurable_space E] [borel_space E] [measure_theory.probability_measure \u03bc] {s : set E} {g : E \u2192 \u211d} (hg : convex_on s g) (hgc : continuous_on g s) (hsc : is_closed s) {f : \u03b1 \u2192 E} (hfs : filter.eventually (fun (x : \u03b1) => f x \u2208 s) (measure_theory.measure.ae \u03bc)) (hfi : measure_theory.integrable f) (hgi : measure_theory.integrable (g \u2218 f)) : g (measure_theory.integral \u03bc fun (x : \u03b1) => f x) \u2264 measure_theory.integral \u03bc fun (x : \u03b1) => 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\u1601 : Y\u1601 \u27f6 X\u1601` for a morphism `f : X \u27f6 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* `\u03b7_` and `\u03b5_` denote the coevaluation and evaluation morphism of an exact pairing.\n* `X\u1601` and `\u1601X` 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 \u2297 Y` and `Y\u1601 \u2297 X\u1601` 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\nnoncomputable theory\n\nnamespace category_theory\n\nvariables {C : Type u\u2081} [category.{v\u2081} 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 [] : \ud835\udfd9_ C \u27f6 X \u2297 Y)\n(evaluation [] : Y \u2297 X \u27f6 \ud835\udfd9_ C)\n(coevaluation_evaluation' [] :\n  (\ud835\udfd9 Y \u2297 coevaluation) \u226b (\u03b1_ _ _ _).inv \u226b (evaluation \u2297 \ud835\udfd9 Y)\n  = (\u03c1_ Y).hom \u226b (\u03bb_ Y).inv . obviously)\n(evaluation_coevaluation' [] :\n  (coevaluation \u2297 \ud835\udfd9 X) \u226b (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 X \u2297 evaluation)\n  = (\u03bb_ X).hom \u226b (\u03c1_ X).inv . obviously)\n\nopen exact_pairing\n\nnotation `\u03b7_` := exact_pairing.coevaluation\nnotation `\u03b5_` := 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 (\ud835\udfd9_ C) (\ud835\udfd9_ C) :=\n{ coevaluation := (\u03c1_ _).inv,\n  evaluation := (\u03c1_ _).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 `\u1601`:1025 := left_dual\npostfix `\u1601`:1025 := right_dual\n\ninstance has_right_dual_unit : has_right_dual (\ud835\udfd9_ C) :=\n{ right_dual := \ud835\udfd9_ C }\n\ninstance has_left_dual_unit : has_left_dual (\ud835\udfd9_ C) :=\n{ left_dual := \ud835\udfd9_ C }\n\ninstance has_right_dual_left_dual {X : C} [has_left_dual X] : has_right_dual (\u1601X) :=\n{ right_dual := X }\n\ninstance has_left_dual_right_dual {X : C} [has_right_dual X] : has_left_dual X\u1601 :=\n{ left_dual := X }\n\n@[simp]\nlemma left_dual_right_dual {X : C} [has_right_dual X] : \u1601(X\u1601) = X := rfl\n\n@[simp]\nlemma right_dual_left_dual {X : C} [has_left_dual X] : (\u1601X)\u1601 = X := rfl\n\n/-- The right adjoint mate `f\u1601 : X\u1601 \u27f6 Y\u1601` of a morphism `f : X \u27f6 Y`. -/\ndef right_adjoint_mate {X Y : C} [has_right_dual X] [has_right_dual Y] (f : X \u27f6 Y) : Y\u1601 \u27f6 X\u1601 :=\n(\u03c1_ _).inv \u226b (\ud835\udfd9 _ \u2297 \u03b7_ _ _) \u226b (\ud835\udfd9 _ \u2297 (f \u2297 \ud835\udfd9 _))\n \u226b (\u03b1_ _ _ _).inv \u226b ((\u03b5_ _ _) \u2297 \ud835\udfd9 _) \u226b (\u03bb_ _).hom\n\n/-- The left adjoint mate `\u1601f : \u1601Y \u27f6 \u1601X` of a morphism `f : X \u27f6 Y`. -/\ndef left_adjoint_mate {X Y : C} [has_left_dual X] [has_left_dual Y] (f : X \u27f6 Y) : \u1601Y \u27f6 \u1601X :=\n(\u03bb_ _).inv \u226b (\u03b7_ (\u1601X) X \u2297 \ud835\udfd9 _) \u226b ((\ud835\udfd9 _ \u2297 f) \u2297 \ud835\udfd9 _)\n \u226b (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 _ \u2297 \u03b5_ _ _) \u226b (\u03c1_ _).hom\n\nnotation f `\u1601` := right_adjoint_mate f\nnotation `\u1601` f := left_adjoint_mate f\n\n@[simp]\nlemma right_adjoint_mate_id {X : C} [has_right_dual X] : (\ud835\udfd9 X)\u1601 = \ud835\udfd9 (X\u1601) :=\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] : \u1601(\ud835\udfd9 X) = \ud835\udfd9 (\u1601X) :=\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 \u27f6 Y} {g : X\u1601 \u27f6 Z} :\n  f\u1601 \u226b g\n  = (\u03c1_ Y\u1601).inv \u226b (\ud835\udfd9 _ \u2297 \u03b7_ X X\u1601) \u226b (\ud835\udfd9 _ \u2297 f \u2297 g)\n    \u226b (\u03b1_ Y\u1601 Y Z).inv \u226b (\u03b5_ Y Y\u1601 \u2297 \ud835\udfd9 _) \u226b (\u03bb_ Z).hom :=\nbegin\n  dunfold right_adjoint_mate,\n  rw [category.assoc, category.assoc, associator_inv_naturality_assoc,\n    associator_inv_naturality_assoc, \u2190tensor_id_comp_id_tensor g, category.assoc, category.assoc,\n    category.assoc, category.assoc, id_tensor_comp_tensor_id_assoc, \u2190left_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 \u27f6 Y} {g : \u1601X \u27f6 Z} :\n  \u1601f \u226b g\n  = (\u03bb_ _).inv \u226b (\u03b7_ (\u1601X) X \u2297 \ud835\udfd9 _) \u226b ((g \u2297 f) \u2297 \ud835\udfd9 _)\n    \u226b (\u03b1_ _ _ _).hom \u226b (\ud835\udfd9 _ \u2297 \u03b5_ _ _) \u226b (\u03c1_ _).hom :=\nbegin\n  dunfold left_adjoint_mate,\n  rw [category.assoc, category.assoc, associator_naturality_assoc, associator_naturality_assoc,\n  \u2190id_tensor_comp_tensor_id _ g, category.assoc, category.assoc, category.assoc, category.assoc,\n  tensor_id_comp_id_tensor_assoc, \u2190right_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 \u27f6 Y} {g : Y \u27f6 Z} :\n  (f \u226b g)\u1601 = g\u1601 \u226b f\u1601 :=\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 [\u2190category.id_comp g, tensor_comp] },\n  rw \u2190category.assoc,\n  symmetry, iterate 2 { transitivity, rw \u2190category.assoc }, apply eq_whisker,\n  repeat { rw \u2190id_tensor_comp }, congr' 1,\n  rw [\u2190id_tensor_comp_tensor_id (\u03bb_ X\u1601).hom g, id_tensor_right_unitor_inv, category.assoc,\n    category.assoc, right_unitor_inv_naturality_assoc, \u2190associator_naturality_assoc, tensor_id,\n    tensor_id_comp_id_tensor_assoc, \u2190associator_naturality_assoc],\n  slice_rhs 2 3 { rw [\u2190tensor_comp, tensor_id, category.comp_id,\n    \u2190category.id_comp (\u03b7_ Y Y\u1601), tensor_comp] },\n  rw [\u2190id_tensor_comp_tensor_id _ (\u03b7_ Y Y\u1601), \u2190tensor_id],\n  repeat { rw category.assoc },\n  rw [pentagon_hom_inv_assoc, \u2190associator_naturality_assoc, associator_inv_naturality_assoc],\n  slice_rhs 5 7 { rw [\u2190comp_tensor_id, \u2190comp_tensor_id, evaluation_coevaluation, comp_tensor_id] },\n  rw associator_inv_naturality_assoc,\n  slice_rhs 4 5 { rw [\u2190tensor_comp, left_unitor_naturality, tensor_comp] },\n  repeat { rw category.assoc },\n  rw [triangle_assoc_comp_right_inv_assoc, \u2190left_unitor_tensor_assoc,\n    left_unitor_naturality_assoc, unitors_equal, \u2190category.assoc, \u2190category.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 \u27f6 Y} {g : Y \u27f6 Z} :\n  \u1601(f \u226b g) = \u1601g \u226b \u1601f :=\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 [\u2190category.id_comp g, tensor_comp] },\n  rw \u2190 category.assoc,\n  symmetry, iterate 2 { transitivity, rw \u2190category.assoc }, apply eq_whisker,\n  repeat { rw \u2190comp_tensor_id }, congr' 1,\n  rw [\u2190tensor_id_comp_id_tensor g (\u03c1_ (\u1601X)).hom, left_unitor_inv_tensor_id, category.assoc,\n    category.assoc, left_unitor_inv_naturality_assoc, \u2190associator_inv_naturality_assoc, tensor_id,\n    id_tensor_comp_tensor_id_assoc, \u2190associator_inv_naturality_assoc],\n  slice_rhs 2 3 { rw [\u2190tensor_comp, tensor_id, category.comp_id,\n    \u2190category.id_comp (\u03b7_ (\u1601Y) Y), tensor_comp] },\n  rw [\u2190tensor_id_comp_id_tensor (\u03b7_ (\u1601Y) Y), \u2190tensor_id],\n  repeat { rw category.assoc },\n  rw [pentagon_inv_hom_assoc, \u2190associator_inv_naturality_assoc, associator_naturality_assoc],\n  slice_rhs 5 7 { rw [\u2190id_tensor_comp, \u2190id_tensor_comp, coevaluation_evaluation, id_tensor_comp ]},\n  rw associator_naturality_assoc,\n  slice_rhs 4 5 { rw [\u2190tensor_comp, right_unitor_naturality, tensor_comp] },\n  repeat { rw category.assoc },\n  rw [triangle_assoc_comp_left_inv_assoc, \u2190right_unitor_tensor_assoc,\n    right_unitor_naturality_assoc, \u2190unitors_equal, \u2190category.assoc, \u2190category.assoc], simp\nend\n\n/-- Right duals are isomorphic. -/\ndef right_dual_iso {X Y\u2081 Y\u2082 : C} (_ : exact_pairing X Y\u2081) (_ : exact_pairing X Y\u2082) :\n  Y\u2081 \u2245 Y\u2082 :=\n{ hom := @right_adjoint_mate C _ _ X X \u27e8Y\u2082\u27e9 \u27e8Y\u2081\u27e9 (\ud835\udfd9 X),\n  inv := @right_adjoint_mate C _ _ X X \u27e8Y\u2081\u27e9 \u27e8Y\u2082\u27e9 (\ud835\udfd9 X),\n  hom_inv_id' := by rw [\u2190comp_right_adjoint_mate, category.comp_id, right_adjoint_mate_id],\n  inv_hom_id' := by rw [\u2190comp_right_adjoint_mate, category.comp_id, right_adjoint_mate_id] }\n\n/-- Left duals are isomorphic. -/\ndef left_dual_iso {X\u2081 X\u2082 Y : C} (p\u2081 : exact_pairing X\u2081 Y) (p\u2082 : exact_pairing X\u2082 Y) :\n  X\u2081 \u2245 X\u2082 :=\n{ hom := @left_adjoint_mate C _ _ Y Y \u27e8X\u2082\u27e9 \u27e8X\u2081\u27e9 (\ud835\udfd9 Y),\n  inv := @left_adjoint_mate C _ _ Y Y \u27e8X\u2081\u27e9 \u27e8X\u2082\u27e9 (\ud835\udfd9 Y),\n  hom_inv_id' := by rw [\u2190comp_left_adjoint_mate, category.comp_id, left_adjoint_mate_id],\n  inv_hom_id' := by rw [\u2190comp_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 : \u03a0 (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 : \u03a0 (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 \u2964 D` for the type of all functors from `C` to `D`.\n(Unfortunately the `\u21d2` 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\u2081 v\u2082 v\u2083 u u\u2081 u\u2082 u\u2083\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\u2081) [category.{v\u2081} C] (D : Type u\u2082) [category.{v\u2082} D]\n  extends prefunctor C D : Type (max v\u2081 v\u2082 u\u2081 u\u2082) :=\n(map_id'   : \u2200 (X : C), map (\ud835\udfd9 X) = \ud835\udfd9 (obj X) . obviously)\n(map_comp' : \u2200 {X Y Z : C} (f : X \u27f6 Y) (g : Y \u27f6 Z), map (f \u226b g) = (map f) \u226b (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 \u2964 a similar precedence to \u2192 (25).\n-- For example, `C \u00d7 D \u2964 E` should parse as `(C \u00d7 D) \u2964 E` not `C \u00d7 (D \u2964 E)`.\ninfixr ` \u2964 `: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\u2081) [category.{v\u2081} C]\n\n/-- `\ud835\udfed 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 \u2964 C :=\n{ obj := \u03bb X, X,\n  map := \u03bb _ _ f, f }\n\nnotation `\ud835\udfed` := functor.id -- Type this as `\\sb1`\n\ninstance : inhabited (C \u2964 C) := \u27e8functor.id C\u27e9\n\nvariable {C}\n\n@[simp] lemma id_obj (X : C) : (\ud835\udfed C).obj X = X := rfl\n@[simp] lemma id_map {X Y : C} (f : X \u27f6 Y) : (\ud835\udfed C).map f = f := rfl\n\nend\n\nsection\nvariables {C : Type u\u2081} [category.{v\u2081} C]\n          {D : Type u\u2082} [category.{v\u2082} D]\n          {E : Type u\u2083} [category.{v\u2083} E]\n\n/--\n`F \u22d9 G` is the composition of a functor `F` and a functor `G` (`F` first, then `G`).\n-/\n@[simps obj] def comp (F : C \u2964 D) (G : D \u2964 E) : C \u2964 E :=\n{ obj := \u03bb X, G.obj (F.obj X),\n  map := \u03bb _ _ f, G.map (F.map f) }\n\ninfixr ` \u22d9 `:80 := comp\n\n@[simp] lemma comp_map (F : C \u2964 D) (G : D \u2964 E) {X Y : C} (f : X \u27f6 Y) :\n  (F \u22d9 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 \u2964 D) : F \u22d9 (\ud835\udfed D) = F := by cases F; refl\nprotected lemma id_comp (F : C \u2964 D) : (\ud835\udfed C) \u22d9 F = F := by cases F; refl\n\n@[simp] lemma map_dite (F : C \u2964 D) {X Y : C} {P : Prop} [decidable P]\n  (f : P \u2192 (X \u27f6 Y)) (g : \u00acP \u2192 (X \u27f6 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 \u2964 D) (X : C) :\n  F.to_prefunctor.obj X = F.obj X := rfl\n\n@[simp] lemma to_prefunctor_map (F : C \u2964 D)\n  {X Y : C} (f : X \u27f6 Y) : F.to_prefunctor.map f = F.map f := rfl\n\n@[simp] lemma to_prefunctor_comp (F : C \u2964 D) (G : D \u2964 E) :\n  F.to_prefunctor.comp G.to_prefunctor = (F \u22d9 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 (\u2205 : ctx agents) equiv_class] : frame agents := \n{ \n  states := {x\u0393 : ctx agents // max_ax_consist x\u0393},\n  h := begin have h1 := max_ax_exists hax, choose \u0393 h1 using h1, exact \u27e8\u27e8\u0393, h1\u27e9\u27e9 end,\n  rel := \u03bb a, \u03bb x\u0393 y\u0394, \u2200 \u03c6 : form agents, K a \u03c6 \u2208 x\u0393.val \u2192 \u03c6 \u2208 y\u0394.val\n}\n\n\ndef val_canonical [hax : sem_cons (\u2205 : ctx agents) equiv_class] : \n  nat \u2192 canonical.states \u2192 Prop := \u03bb n, \u03bb x\u0393 : canonical.states, (form.var n) \u2208 (x\u0393.val : ctx agents)\n\n\nlemma existence (hax : sem_cons (\u2205 : ctx agents) equiv_class) (x\u0393 : canonical.states) :\n  \u2200 a, \u2200 \u03c6 : form agents, (\u00ac K a (\u00ac\u03c6)) \u2208 x\u0393.val \u2194 \u2203 y\u0394 : canonical.states, \u03c6 \u2208 y\u0394.val \u2227 canonical.rel a x\u0393 y\u0394 :=\nbegin\nintros a \u03c6, split,\nintro h1,\nlet \u0393box : ctx agents := {\u03c8 : form agents | K a \u03c8 \u2208 x\u0393.val},\nhave h1 : ax_consist (\u0393box \u222a {\u03c6}), \n{by_contradiction h2, simp at h2,\nhave h3 := five \u0393box \u03c6 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 : \u2200 \u03c8 \u2208 (list.map (form.box a) L), \u03c8 \u2208 x\u0393.1, \nintros \u03c8 h8, simp at *, cases h8 with a h8,\ncases h8 with h8l h8r,\nsubst h8r, exact h3 a h8l,\nspecialize h6 x\u0393.2 h7 h5,\nhave h8 := (six x\u0393.1 (max_imp_ax x\u0393.2)).mp x\u0393.2 (K a (\u00ac\u03c6)),\ncases h8 with h8l h8r, simp at *, \nexact absurd h1 (h8r h6),\n},\nhave h2 := lindenbaum (\u0393box \u222a {\u03c6}) h1,\ncases h2 with \u0394 h2, cases h2 with h2 h3,\nlet x\u0394 : canonical.states := \u27e8\u0394, h2\u27e9,\nexistsi (x\u0394 : canonical.states),\nhave h5 := set.union_subset_iff.mp h3,\ncases h5, split, simp at h5_right, exact h5_right,\nhave h3 : \u2200 \u03c6 : form agents, K a \u03c6 \u2208 x\u0393.val \u2192 \u03c6 \u2208 x\u0394.val,\nintros \u03c8 h4, apply h5_left, exact h4,\nexact h3,\nsimp at *,\nintros y\u0394 h1 h2,\nby_contradiction h4,\nhave h5 := (max_notiff x\u0393.1 x\u0393.2 (C a \u03c6)).mp h4,\nhave h6 := (max_dn x\u0393.1 x\u0393.2 (K a \u00ac\u03c6)).mpr h5,\nexact absurd h1 ((max_notiff y\u0394.1 y\u0394.2 \u03c6).mpr ((h2 (\u00ac\u03c6)) h6))\nend\n\n\nlemma truth (hax : sem_cons (\u2205 : ctx agents) equiv_class) (x\u0393 : canonical.states) : \n  \u2200 \u03c6 : form agents, forces canonical val_canonical x\u0393 \u03c6 \u2194 (\u03c6 \u2208 x\u0393.val) :=\nbegin\nintro \u03c6, induction \u03c6 with n \u03c6 \u03c8 ih_\u03c6 ih_\u03c8 \n\u03c6 \u03c8 ih_\u03c6 ih_\u03c8 \u03c6 ih_\u03c6 generalizing x\u0393,\nsplit, intro h1, exact false.elim h1,\nintro h1, rw forces, \nhave h2 := x\u0393.2,\ncases h2,\nspecialize h2_left [\u22a5],\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\u0393.2 (and.intro ((ih_\u03c6 x\u0393).mp h1) ((ih_\u03c8 x\u0393).mp h2)), \nintro h1, split,\napply (ih_\u03c6 x\u0393).mpr, exact max_conj_2 x\u0393.2 h1,\napply (ih_\u03c8 x\u0393).mpr, exact max_conj_3 x\u0393.2 h1,\nsplit, \nintro h1,\napply max_imp_1 x\u0393.2,\nintro h2,\nexact (ih_\u03c8 x\u0393).mp (h1 ((ih_\u03c6 x\u0393).mpr h2)),\nintros h1 h2,\napply (ih_\u03c8 x\u0393).mpr, \nexact max_imp_2 x\u0393.2 h1 ((ih_\u03c6 x\u0393).mp h2),\nrename \u03c6 a, rename ih_\u03c6 \u03c6,\nsplit, \nintros h1, by_contradiction h2,\nhave h4 := (existence hax x\u0393 a (\u00ac\u03c6)).mp,\nhave h5 := max_boxdn x\u0393.1 x\u0393.2 \u03c6 a ((max_notiff x\u0393.1 x\u0393.2 (K a \u03c6)).mp h2),\ncases h4 h5 with x\u0394 h4, cases h4 with h4 h6,\nhave h7 := max_notiff x\u0394.1 x\u0394.2 \u03c6,\ncases h7 with h7l h7r,\nexact absurd ((\u03c6_ih x\u0394).mp (h1 x\u0394 h6)) (h7r h4),\nintros h1 x\u0394 h2,\napply (\u03c6_ih x\u0394).mpr, exact (h2 \u03c6 h1),\nend\n\n\nlemma comphelper (\u03c6 : form agents) (hax : sem_cons (\u2205 : ctx agents) equiv_class) : \n  \u00ac prfS5 \u2205 \u03c6 \u2192 ax_consist ({\u00ac\u03c6} : 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 : (\u2200 \u03c8 \u2208 L_hd::L_tl, \u03c8 = \u00ac\u03c6) \u2192 prfS5 \u2205 (\u00acfin_conj (L_hd::L_tl)) \u2192 prfS5 \u2205 \u03c6, \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 (\u2205 : ctx agents) equiv_class) : \n  forces_ctx canonical val_canonical (\u2205 : ctx agents) :=\nbegin\nintros \u03c6 x\u0393 h1,\nhave h2 := mp prfS5.pl1 (ax h1),\nhave h3 : \u2200 \u03c8 \u2208 list.nil, \u03c8 \u2208 x\u0393.val, \n{intros \u03c8 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\u0393.2 h3 h2,\nexact (truth hax x\u0393 \u03c6).mpr h4\nend\n\n\nlemma euclid_dual {a : agents} {\u03c6 : form agents} : \n  prfS5 \u2205 ((C a (\u00ac\u03c6) \u2283 K a (C a (\u00ac\u03c6))) \u2283 (C a (K a \u03c6) \u2283 K a \u03c6)) :=\nbegin\nhave h1 := contrapos.mpr negintro,\nhave h2 := cut h1 (mp pl6 dual_equiv1),\nhave h3 : prfS5 \u2205 ((\u00acK a (C a \u00ac\u03c6)) \u2194 (\u00ac\u00acC a (\u00ac(C a \u00ac\u03c6)))),\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 (\u2205 : ctx agents) equiv_class) : \n  canonical \u2208 (equiv_class : set (frame agents)) :=\nbegin\nrw equiv_ref_euclid,\nsplit,\nintros a x \u03c6 h1,\nhave h2 : \u2200 a, (\u2200 \u03c8 \u2208 [(K a \u03c6)], \u03c8 \u2208 x.1) \u2192 prfS5 \u2205 (fin_conj [(K a \u03c6)] \u2283 \u03c6) \u2192 \u03c6 \u2208 x.1, \n  from \u03bb a, exercise1 x.2,\nhave h3 : prfS5 \u2205 (fin_conj [(K a \u03c6)] \u2283 \u03c6), \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 \u03c6 h3,\napply h2 \u03c6,\nhave h4 := mp euclid_dual negintro,\nhave h5 : \u2200 a, (\u2200 \u03c8 \u2208 [(C a (K a \u03c6))], \u03c8 \u2208 x.1) \u2192 \n  prfS5 \u2205 (fin_conj [(C a (K a \u03c6))] \u2283 K a \u03c6) \u2192 K a \u03c6 \u2208 x.1,\n  from \u03bb a, exercise1 x.2, \nsimp at *,\napply h5,\nby_contradiction h6,\nhave h7 := max_notiff x.1 x.2 (\u00acK a (\u00acK a \u03c6)),\nhave h8 := max_dn x.1 x.2 (K a (\u00acK a \u03c6)),\nhave h9 := (max_notiff y.1 y.2 (K a \u03c6)).mpr (h1 (\u00acK a \u03c6) (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 (\u2205 : ctx agents) equiv_class) (\u03c6 : form agents) : \n  global_sem_csq \u2205 equiv_class \u03c6 \u2192 prfS5 \u2205 \u03c6 :=\nbegin\nrw \u2190not_imp_not, intro h1,\nhave h2 := comphelper \u03c6 hax h1,\nhave h3 := lindenbaum {\u00ac\u03c6} h2,\nsimp at *,\ncases h3 with \u0393' 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\u0393' : f.states := \u27e8\u0393', h3\u27e9,\nsplit, \nexact forcesAX hax,\nuse x\u0393',\nhave h5 : forces f v x\u0393' (\u00ac\u03c6) \u2194 ((\u00ac\u03c6) \u2208 x\u0393'.val), \n  from truth hax x\u0393' \u00ac\u03c6,\ncases h5 with h5 h6,\nhave h7 : \u00acforces f v x\u0393' \u03c6 \u2194 forces f v x\u0393' \u00ac\u03c6, \n  from not_forces_imp f v x\u0393' \u03c6,\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 \u2208 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.\u03b9`.\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.\u03b9_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\u2082\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 \u2192 walking_parallel_pair \u2192 Type v\n| left : walking_parallel_pair_hom zero one\n| right : walking_parallel_pair_hom zero one\n| id : \u03a0 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  \u03a0 (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 = \ud835\udfd9 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 \u27f6 Y) : walking_parallel_pair.{v} \u2964 C :=\n{ obj := \u03bb x, match x with\n  | zero := X\n  | one := Y\n  end,\n  map := \u03bb x y h, match x, y, h with\n  | _, _, (id _) := \ud835\udfd9 _\n  | _, _, left := f\n  | _, _, right := g\n  end,\n  -- `tidy` can cope with this, but it's too slow:\n  map_comp' := begin rintros (\u27e8\u27e9|\u27e8\u27e9) (\u27e8\u27e9|\u27e8\u27e9) (\u27e8\u27e9|\u27e8\u27e9) \u27e8\u27e9\u27e8\u27e9; { unfold_aux, simp; refl }, end, }.\n\n@[simp] lemma parallel_pair_obj_zero (f g : X \u27f6 Y) : (parallel_pair f g).obj zero = X := rfl\n@[simp] lemma parallel_pair_obj_one (f g : X \u27f6 Y) : (parallel_pair f g).obj one = Y := rfl\n\n@[simp] lemma parallel_pair_map_left (f g : X \u27f6 Y) : (parallel_pair f g).map left = f := rfl\n@[simp] lemma parallel_pair_map_right (f g : X \u27f6 Y) : (parallel_pair f g).map right = g := rfl\n\n@[simp] lemma parallel_pair_functor_obj\n  {F : walking_parallel_pair \u2964 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 \u2964 C) :\n  F \u2245 parallel_pair (F.map left) (F.map right) :=\nnat_iso.of_components (\u03bb 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 \u27f6 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 \u27f6 Y) := cocone (parallel_pair f g)\n\nvariables {f g : X \u27f6 Y}\n\n/-- A fork `t` on the parallel pair `f g : X \u27f6 Y` consists of two morphisms `t.\u03c0.app zero : t.X \u27f6 X`\n    and `t.\u03c0.app one : t.X \u27f6 Y`. Of these, only the first one is interesting, and we give it the\n    shorter name `fork.\u03b9 t`. -/\nabbreviation fork.\u03b9 (t : fork f g) := t.\u03c0.app zero\n\n/-- A cofork `t` on the parallel_pair `f g : X \u27f6 Y` consists of two morphisms\n    `t.\u03b9.app zero : X \u27f6 t.X` and `t.\u03b9.app one : Y \u27f6 t.X`. Of these, only the second one is\n    interesting, and we give it the shorter name `cofork.\u03c0 t`. -/\nabbreviation cofork.\u03c0 (t : cofork f g) := t.\u03b9.app one\n\n@[simp] lemma fork.\u03b9_eq_app_zero (t : fork f g) : t.\u03b9 = t.\u03c0.app zero := rfl\n@[simp] lemma cofork.\u03c0_eq_app_one (t : cofork f g) : t.\u03c0 = t.\u03b9.app one := rfl\n\n@[simp, reassoc] lemma fork.app_zero_left (s : fork f g) :\n  s.\u03c0.app zero \u226b f = s.\u03c0.app one :=\nby rw [\u2190s.w left, parallel_pair_map_left]\n\n@[simp, reassoc] lemma fork.app_zero_right (s : fork f g) :\n  s.\u03c0.app zero \u226b g = s.\u03c0.app one :=\nby rw [\u2190s.w right, parallel_pair_map_right]\n\n@[simp, reassoc] lemma cofork.left_app_one (s : cofork f g) :\n  f \u226b s.\u03b9.app one = s.\u03b9.app zero :=\nby rw [\u2190s.w left, parallel_pair_map_left]\n\n@[simp, reassoc] lemma cofork.right_app_one (s : cofork f g) :\n  g \u226b s.\u03b9.app one = s.\u03b9.app zero :=\nby rw [\u2190s.w right, parallel_pair_map_right]\n\n/-- A fork on `f g : X \u27f6 Y` is determined by the morphism `\u03b9 : P \u27f6 X` satisfying `\u03b9 \u226b f = \u03b9 \u226b g`.\n-/\n@[simps]\ndef fork.of_\u03b9 {P : C} (\u03b9 : P \u27f6 X) (w : \u03b9 \u226b f = \u03b9 \u226b g) : fork f g :=\n{ X := P,\n  \u03c0 :=\n  { app := \u03bb X, begin cases X, exact \u03b9, exact \u03b9 \u226b f, end,\n    naturality' := \u03bb 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 \u27f6 Y` is determined by the morphism `\u03c0 : Y \u27f6 P` satisfying\n    `f \u226b \u03c0 = g \u226b \u03c0`. -/\n@[simps]\ndef cofork.of_\u03c0 {P : C} (\u03c0 : Y \u27f6 P) (w : f \u226b \u03c0 = g \u226b \u03c0) : cofork f g :=\n{ X := P,\n  \u03b9 :=\n  { app := \u03bb X, walking_parallel_pair.cases_on X (f \u226b \u03c0) \u03c0,\n    naturality' := \u03bb i j f, by { cases f; dsimp; simp [w] } } } -- See note [dsimp, simp]\n\nlemma fork.\u03b9_of_\u03b9 {P : C} (\u03b9 : P \u27f6 X) (w : \u03b9 \u226b f = \u03b9 \u226b g) :\n  (fork.of_\u03b9 \u03b9 w).\u03b9 = \u03b9 := rfl\nlemma cofork.\u03c0_of_\u03c0 {P : C} (\u03c0 : Y \u27f6 P) (w : f \u226b \u03c0 = g \u226b \u03c0) :\n  (cofork.of_\u03c0 \u03c0 w).\u03c0 = \u03c0 := rfl\n\n@[reassoc]\nlemma fork.condition (t : fork f g) : t.\u03b9 \u226b f = t.\u03b9 \u226b g :=\nby rw [t.app_zero_left, t.app_zero_right]\n@[reassoc]\nlemma cofork.condition (t : cofork f g) : f \u226b t.\u03c0 = g \u226b t.\u03c0 :=\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 \u27f6 s.X}\n  (h : k \u226b fork.\u03b9 s = l \u226b fork.\u03b9 s) : \u2200 (j : walking_parallel_pair),\n    k \u226b s.\u03c0.app j = l \u226b s.\u03c0.app j\n| zero := h\n| one := by rw [\u2190fork.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 \u27f6 s.X}\n  (h : k \u226b fork.\u03b9 s = l \u226b fork.\u03b9 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 \u27f6 W}\n  (h : cofork.\u03c0 s \u226b k = cofork.\u03c0 s \u226b 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 \u27f6 X` satisfying\n    `k \u226b f = k \u226b g` induces a morphism `l : W \u27f6 s.X` such that `l \u226b fork.\u03b9 s = k`. -/\ndef fork.is_limit.lift' {s : fork f g} (hs : is_limit s) {W : C} (k : W \u27f6 X) (h : k \u226b f = k \u226b g) :\n  {l : W \u27f6 s.X // l \u226b fork.\u03b9 s = k} :=\n\u27e8hs.lift $ fork.of_\u03b9 _ h, hs.fac _ _\u27e9\n\n/-- If `s` is a colimit cofork over `f` and `g`, then a morphism `k : Y \u27f6 W` satisfying\n    `f \u226b k = g \u226b k` induces a morphism `l : s.X \u27f6 W` such that `cofork.\u03c0 s \u226b l = k`. -/\ndef cofork.is_colimit.desc' {s : cofork f g} (hs : is_colimit s) {W : C} (k : Y \u27f6 W)\n  (h : f \u226b k = g \u226b k) : {l : s.X \u27f6 W // cofork.\u03c0 s \u226b l = k} :=\n\u27e8hs.desc $ cofork.of_\u03c0 _ h, hs.fac _ _\u27e9\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 : \u03a0 (s : fork f g), s.X \u27f6 t.X)\n  (fac : \u2200 (s : fork f g), lift s \u226b fork.\u03b9 t = fork.\u03b9 s)\n  (uniq : \u2200 (s : fork f g) (m : s.X \u27f6 t.X)\n    (w : \u2200 j : walking_parallel_pair, m \u226b t.\u03c0.app j = s.\u03c0.app j), m = lift s) :\n  is_limit t :=\n{ lift := lift,\n  fac' := \u03bb s j, walking_parallel_pair.cases_on j (fac s) $\n    by erw [\u2190s.w left, \u2190t.w left, \u2190category.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 \u27f6 Y} (t : fork f g)\n  (create : \u03a0 (s : fork f g), {l // l \u226b t.\u03b9 = s.\u03b9 \u2227 \u2200 {m}, m \u226b t.\u03b9 = s.\u03b9 \u2192 m = l}) :\nis_limit t :=\nfork.is_limit.mk t\n  (\u03bb s, (create s).1)\n  (\u03bb s, (create s).2.1)\n  (\u03bb 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 : \u03a0 (s : cofork f g), t.X \u27f6 s.X)\n  (fac : \u2200 (s : cofork f g), cofork.\u03c0 t \u226b desc s = cofork.\u03c0 s)\n  (uniq : \u2200 (s : cofork f g) (m : t.X \u27f6 s.X)\n    (w : \u2200 j : walking_parallel_pair, t.\u03b9.app j \u226b m = s.\u03b9.app j), m = desc s) :\n  is_colimit t :=\n{ desc := desc,\n  fac' := \u03bb s j, walking_parallel_pair.cases_on j\n    (by erw [\u2190s.w left, \u2190t.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 \u27f6 Y} (t : cofork f g)\n  (create : \u03a0 (s : cofork f g), {l : t.X \u27f6 s.X // t.\u03c0 \u226b l = s.\u03c0 \u2227 \u2200 {m}, t.\u03c0 \u226b m = s.\u03c0 \u2192 m = l}) :\nis_colimit t :=\ncofork.is_colimit.mk t\n  (\u03bb s, (create s).1)\n  (\u03bb s, (create s).2.1)\n  (\u03bb s m w, (create s).2.2 (w one))\n\n/--\nGiven a limit cone for the pair `f g : X \u27f6 Y`, for any `Z`, morphisms from `Z` to its point are in\nbijection with morphisms `h : Z \u27f6 X` such that `h \u226b f = h \u226b 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 \u27f6 Y} {t : fork f g} (ht : is_limit t) (Z : C) :\n  (Z \u27f6 t.X) \u2243 {h : Z \u27f6 X // h \u226b f = h \u226b g} :=\n{ to_fun := \u03bb k, \u27e8k \u226b t.\u03b9, by simp\u27e9,\n  inv_fun := \u03bb h, (fork.is_limit.lift' ht _ h.prop).1,\n  left_inv := \u03bb k, fork.is_limit.hom_ext ht (fork.is_limit.lift' _ _ _).prop,\n  right_inv := \u03bb 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 \u27f6 Y} {t : fork f g} (ht : is_limit t)\n  {Z Z' : C} (q : Z' \u27f6 Z) (k : Z \u27f6 t.X) :\n  (fork.is_limit.hom_iso ht _ (q \u226b k) : Z' \u27f6 X) = q \u226b (fork.is_limit.hom_iso ht _ k : Z \u27f6 X) :=\ncategory.assoc _ _ _\n\n/--\nGiven a colimit cocone for the pair `f g : X \u27f6 Y`, for any `Z`, morphisms from the cocone point\nto `Z` are in bijection with morphisms `h : Y \u27f6 Z` such that `f \u226b h = g \u226b 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 \u27f6 Y} {t : cofork f g} (ht : is_colimit t) (Z : C) :\n  (t.X \u27f6 Z) \u2243 {h : Y \u27f6 Z // f \u226b h = g \u226b h} :=\n{ to_fun := \u03bb k, \u27e8t.\u03c0 \u226b k, by simp\u27e9,\n  inv_fun := \u03bb h, (cofork.is_colimit.desc' ht _ h.prop).1,\n  left_inv := \u03bb k, cofork.is_colimit.hom_ext ht (cofork.is_colimit.desc' _ _ _).prop,\n  right_inv := \u03bb 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 \u27f6 Y} {t : cofork f g} {Z Z' : C}\n  (q : Z \u27f6 Z') (ht : is_colimit t) (k : t.X \u27f6 Z) :\n    (cofork.is_colimit.hom_iso ht _ (k \u226b q) : Y \u27f6 Z') =\n    (cofork.is_colimit.hom_iso ht _ k : Y \u27f6 Z) \u226b 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 \u2964 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 \u2964 C} (t : fork (F.map left) (F.map right)) : cone F :=\n{ X := t.X,\n  \u03c0 :=\n  { app := \u03bb X, t.\u03c0.app X \u226b eq_to_hom (by tidy),\n    naturality' := \u03bb 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 \u2964 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 \u2964 C} (t : cofork (F.map left) (F.map right)) : cocone F :=\n{ X := t.X,\n  \u03b9 :=\n  { app := \u03bb X, eq_to_hom (by tidy) \u226b t.\u03b9.app X,\n    naturality' := \u03bb j j' g, by { cases j; cases j'; cases g; dsimp; simp } } }\n\n@[simp] lemma cone.of_fork_\u03c0\n  {F : walking_parallel_pair \u2964 C} (t : fork (F.map left) (F.map right)) (j) :\n  (cone.of_fork t).\u03c0.app j = t.\u03c0.app j \u226b eq_to_hom (by tidy) := rfl\n\n@[simp] lemma cocone.of_cofork_\u03b9\n  {F : walking_parallel_pair \u2964 C} (t : cofork (F.map left) (F.map right)) (j) :\n  (cocone.of_cofork t).\u03b9.app j = eq_to_hom (by tidy) \u226b t.\u03b9.app j := rfl\n\n/-- Given `F : walking_parallel_pair \u2964 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 \u2964 C} (t : cone F) : fork (F.map left) (F.map right) :=\n{ X := t.X,\n  \u03c0 := { app := \u03bb X, t.\u03c0.app X \u226b eq_to_hom (by tidy) } }\n\n/-- Given `F : walking_parallel_pair \u2964 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 \u2964 C} (t : cocone F) : cofork (F.map left) (F.map right) :=\n{ X := t.X,\n  \u03b9 := { app := \u03bb X, eq_to_hom (by tidy) \u226b t.\u03b9.app X } }\n\n@[simp] lemma fork.of_cone_\u03c0 {F : walking_parallel_pair \u2964 C} (t : cone F) (j) :\n  (fork.of_cone t).\u03c0.app j = t.\u03c0.app j \u226b eq_to_hom (by tidy) := rfl\n@[simp] lemma cofork.of_cocone_\u03b9 {F : walking_parallel_pair \u2964 C} (t : cocone F) (j) :\n  (cofork.of_cocone t).\u03b9.app j = eq_to_hom (by tidy) \u226b t.\u03b9.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 \u27f6 t.X) (w : k \u226b t.\u03b9 = s.\u03b9) : s \u27f6 t :=\n{ hom := k,\n  w' :=\n  begin\n    rintro \u27e8_|_\u27e9,\n    { exact w },\n    { simpa using w =\u226b 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 `\u03b9` morphisms.\n-/\n@[simps]\ndef fork.ext {s t : fork f g} (i : s.X \u2245 t.X) (w : i.hom \u226b t.\u03b9 = s.\u03b9) : s \u2245 t :=\n{ hom := fork.mk_hom i.hom w,\n  inv := fork.mk_hom i.inv (by rw [\u2190 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 \u27f6 t.X) (w : s.\u03c0 \u226b k = t.\u03c0) : s \u27f6 t :=\n{ hom := k,\n  w' :=\n  begin\n    rintro \u27e8_|_\u27e9,\n    simpa using f \u226b= 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 `\u03c0` morphisms.\n-/\ndef cofork.ext {s t : cofork f g} (i : s.X \u2245 t.X) (w : s.\u03c0 \u226b i.hom = t.\u03c0) : s \u2245 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 \u27f6 X` by saying `equalizer.\u03b9 f g`. -/\nabbreviation equalizer.\u03b9 : equalizer f g \u27f6 X :=\nlimit.\u03c0 (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_\u03b9 :\n  (equalizer.fork f g).\u03b9 = equalizer.\u03b9 f g := rfl\n\n@[simp] lemma equalizer.fork_\u03c0_app_zero :\n  (equalizer.fork f g).\u03c0.app zero = equalizer.\u03b9 f g := rfl\n\n@[reassoc] lemma equalizer.condition : equalizer.\u03b9 f g \u226b f = equalizer.\u03b9 f g \u226b g :=\nfork.condition $ limit.cone $ parallel_pair f g\n\n/-- The equalizer built from `equalizer.\u03b9 f g` is limiting. -/\ndef equalizer_is_equalizer : is_limit (fork.of_\u03b9 (equalizer.\u03b9 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 \u27f6 X` satisfying `k \u226b f = k \u226b g` factors through the equalizer of `f` and `g`\n    via `equalizer.lift : W \u27f6 equalizer f g`. -/\nabbreviation equalizer.lift {W : C} (k : W \u27f6 X) (h : k \u226b f = k \u226b g) : W \u27f6 equalizer f g :=\nlimit.lift (parallel_pair f g) (fork.of_\u03b9 k h)\n\n@[simp, reassoc]\nlemma equalizer.lift_\u03b9 {W : C} (k : W \u27f6 X) (h : k \u226b f = k \u226b g) :\n  equalizer.lift k h \u226b equalizer.\u03b9 f g = k :=\nlimit.lift_\u03c0 _ _\n\n/-- A morphism `k : W \u27f6 X` satisfying `k \u226b f = k \u226b g` induces a morphism `l : W \u27f6 equalizer f g`\n    satisfying `l \u226b equalizer.\u03b9 f g = k`. -/\ndef equalizer.lift' {W : C} (k : W \u27f6 X) (h : k \u226b f = k \u226b g) :\n  {l : W \u27f6 equalizer f g // l \u226b equalizer.\u03b9 f g = k} :=\n\u27e8equalizer.lift k h, equalizer.lift_\u03b9 _ _\u27e9\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 \u27f6 equalizer f g}\n  (h : k \u226b equalizer.\u03b9 f g = l \u226b equalizer.\u03b9 f g) : k = l :=\nfork.is_limit.hom_ext (limit.is_limit _) h\n\n/-- An equalizer morphism is a monomorphism -/\ninstance equalizer.\u03b9_mono : mono (equalizer.\u03b9 f g) :=\n{ right_cancellation := \u03bb 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.\u03b9 c) :=\n{ right_cancellation := \u03bb 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_\u03b9 (\ud835\udfd9 X) $ h \u25b8 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  (\u03bb s, fork.\u03b9 s)\n  (\u03bb s, category.comp_id _)\n  (\u03bb 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\u2080 : f = g) {c : cone (parallel_pair f g)}\n  (h : is_limit c) : is_iso (c.\u03c0.app zero) :=\nis_iso.of_iso $ is_limit.cone_point_unique_up_to_iso h $ is_limit_id_fork h\u2080\n\n/-- The equalizer of `(f, g)`, where `f = g`, is an isomorphism. -/\nlemma equalizer.\u03b9_of_eq [has_equalizer f g] (h : f = g) : is_iso (equalizer.\u03b9 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.\u03c0.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.\u03c0.app zero)] : is_iso (c.\u03c0.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.\u03b9_of_self : is_iso (equalizer.\u03b9 f f) :=\nequalizer.\u03b9_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 \u2245 X :=\nas_iso (equalizer.\u03b9 f f)\n\n@[simp] lemma equalizer.iso_source_of_self_hom :\n  (equalizer.iso_source_of_self f).hom = equalizer.\u03b9 f f :=\nrfl\n\n@[simp] lemma equalizer.iso_source_of_self_inv :\n  (equalizer.iso_source_of_self f).inv = equalizer.lift (\ud835\udfd9 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.\u03c0 f g`. -/\nabbreviation coequalizer.\u03c0 : Y \u27f6 coequalizer f g :=\ncolimit.\u03b9 (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_\u03c0 :\n  (coequalizer.cofork f g).\u03c0 = coequalizer.\u03c0 f g := rfl\n\n@[simp] lemma coequalizer.cofork_\u03b9_app_one :\n  (coequalizer.cofork f g).\u03b9.app one = coequalizer.\u03c0 f g := rfl\n\n@[reassoc] lemma coequalizer.condition : f \u226b coequalizer.\u03c0 f g = g \u226b coequalizer.\u03c0 f g :=\ncofork.condition $ colimit.cocone $ parallel_pair f g\n\n/-- The cofork built from `coequalizer.\u03c0 f g` is colimiting. -/\ndef coequalizer_is_coequalizer :\n  is_colimit (cofork.of_\u03c0 (coequalizer.\u03c0 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 \u27f6 W` satisfying `f \u226b k = g \u226b k` factors through the coequalizer of `f`\n    and `g` via `coequalizer.desc : coequalizer f g \u27f6 W`. -/\nabbreviation coequalizer.desc {W : C} (k : Y \u27f6 W) (h : f \u226b k = g \u226b k) : coequalizer f g \u27f6 W :=\ncolimit.desc (parallel_pair f g) (cofork.of_\u03c0 k h)\n\n@[simp, reassoc]\nlemma coequalizer.\u03c0_desc {W : C} (k : Y \u27f6 W) (h : f \u226b k = g \u226b k) :\n  coequalizer.\u03c0 f g \u226b coequalizer.desc k h = k :=\ncolimit.\u03b9_desc _ _\n\n/-- Any morphism `k : Y \u27f6 W` satisfying `f \u226b k = g \u226b k` induces a morphism\n    `l : coequalizer f g \u27f6 W` satisfying `coequalizer.\u03c0 \u226b g = l`. -/\ndef coequalizer.desc' {W : C} (k : Y \u27f6 W) (h : f \u226b k = g \u226b k) :\n  {l : coequalizer f g \u27f6 W // coequalizer.\u03c0 f g \u226b l = k} :=\n\u27e8coequalizer.desc k h, coequalizer.\u03c0_desc _ _\u27e9\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 \u27f6 W}\n  (h : coequalizer.\u03c0 f g \u226b k = coequalizer.\u03c0 f g \u226b l) : k = l :=\ncofork.is_colimit.hom_ext (colimit.is_colimit _) h\n\n/-- A coequalizer morphism is an epimorphism -/\ninstance coequalizer.\u03c0_epi : epi (coequalizer.\u03c0 f g) :=\n{ left_cancellation := \u03bb 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.\u03b9.app one) :=\n{ left_cancellation := \u03bb 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_\u03c0 (\ud835\udfd9 Y) $ h \u25b8 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  (\u03bb s, cofork.\u03c0 s)\n  (\u03bb s, category.id_comp _)\n  (\u03bb 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\u2080 : f = g) {c : cocone (parallel_pair f g)}\n  (h : is_colimit c) : is_iso (c.\u03b9.app one) :=\nis_iso.of_iso $ is_colimit.cocone_point_unique_up_to_iso (is_colimit_id_cofork h\u2080) h\n\n/-- The coequalizer of `(f, g)`, where `f = g`, is an isomorphism. -/\nlemma coequalizer.\u03c0_of_eq [has_coequalizer f g] (h : f = g) :\n  is_iso (coequalizer.\u03c0 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.\u03b9.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.\u03b9.app one)] : is_iso (c.\u03b9.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.\u03c0_of_self : is_iso (coequalizer.\u03c0 f f) :=\ncoequalizer.\u03c0_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 \u2245 Y :=\n(as_iso (coequalizer.\u03c0 f f)).symm\n\n@[simp] lemma coequalizer.iso_target_of_self_hom :\n  (coequalizer.iso_target_of_self f).hom = coequalizer.desc (\ud835\udfd9 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.\u03c0 f f :=\nrfl\n\nsection comparison\n\nvariables {D : Type u\u2082} [category.{v} D] (G : C \u2964 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) \u27f6 equalizer (G.map f) (G.map g) :=\nequalizer.lift (G.map (equalizer.\u03b9 _ _)) (by simp only [\u2190G.map_comp, equalizer.condition])\n\n@[simp, reassoc]\nlemma equalizer_comparison_comp_\u03c0 [has_equalizer f g] [has_equalizer (G.map f) (G.map g)] :\n  equalizer_comparison f g G \u226b equalizer.\u03b9 (G.map f) (G.map g) = G.map (equalizer.\u03b9 f g) :=\nequalizer.lift_\u03b9 _ _\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 \u27f6 X} (w : h \u226b f = h \u226b g) :\n    G.map (equalizer.lift h w) \u226b equalizer_comparison f g G =\n      equalizer.lift (G.map h) (by simp only [\u2190G.map_comp, w]) :=\nby { ext, simp [\u2190 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) \u27f6 G.obj (coequalizer f g) :=\ncoequalizer.desc (G.map (coequalizer.\u03c0 _ _)) (by simp only [\u2190G.map_comp, coequalizer.condition])\n\n@[simp, reassoc]\nlemma \u03b9_comp_coequalizer_comparison [has_coequalizer f g] [has_coequalizer (G.map f) (G.map g)] :\n  coequalizer.\u03c0 _ _ \u226b coequalizer_comparison f g G = G.map (coequalizer.\u03c0 _ _) :=\ncoequalizer.\u03c0_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 \u27f6 Z} (w : f \u226b h = g \u226b h) :\n  coequalizer_comparison f g G \u226b G.map (coequalizer.desc h w) =\n    coequalizer.desc (G.map h) (by simp only [\u2190G.map_comp, w]) :=\nby { ext, simp [\u2190 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  [\u03a0 {X Y : C} {f g : X \u27f6 Y}, has_limit (parallel_pair f g)] : has_equalizers C :=\n{ has_limit := \u03bb 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  [\u03a0 {X Y : C} {f g : X \u27f6 Y}, has_colimit (parallel_pair f g)] : has_coequalizers C :=\n{ has_colimit := \u03bb 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 \u226b f)` and `(\ud835\udfd9 Y)`.\nvariables {C} [split_mono f]\n\n/--\nA split mono `f` equalizes `(retraction f \u226b f)` and `(\ud835\udfd9 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 (\ud835\udfd9 Y) (retraction f \u226b f)) :=\nfork.of_\u03b9 f (by simp)\n\n\n/--\nA split mono `f` equalizes `(retraction f \u226b f)` and `(\ud835\udfd9 Y)`.\n-/\ndef split_mono_equalizes {X Y : C} (f : X \u27f6 Y) [split_mono f] : is_limit (cone_of_split_mono f) :=\nfork.is_limit.mk' _ $ \u03bb s,\n\u27e8s.\u03b9 \u226b retraction f,\n by { dsimp, rw [category.assoc, \u2190s.condition], apply category.comp_id },\n \u03bb m hm, by simp [\u2190hm]\u27e9\n\nend\n\nsection\n-- In this section we show that a split epi `f` coequalizes `(f \u226b section_ f)` and `(\ud835\udfd9 X)`.\nvariables {C} [split_epi f]\n\n/--\nA split epi `f` coequalizes `(f \u226b section_ f)` and `(\ud835\udfd9 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 (\ud835\udfd9 X) (f \u226b section_ f)) :=\ncofork.of_\u03c0 f (by simp)\n\n/--\nA split epi `f` coequalizes `(f \u226b section_ f)` and `(\ud835\udfd9 X)`.\n-/\ndef split_epi_coequalizes {X Y : C} (f : X \u27f6 Y) [split_epi f] :\n  is_colimit (cocone_of_split_epi f) :=\ncofork.is_colimit.mk' _ $ \u03bb s,\n\u27e8section_ f \u226b s.\u03c0,\n by { dsimp, rw [\u2190 category.assoc, \u2190 s.condition, category.id_comp] },\n \u03bb m hm, by simp [\u2190 hm]\u27e9\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\u2081 w\u2082 w\u2083\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 `\u03c7 : L \u2192 R` is the simultaneous generalized eigenspace of the action of all `x : L` on `M`,\nwith eigenvalues `\u03c7 x`.\n\nSee also `lie_module.weight_space`. -/\ndef pre_weight_space (\u03c7 : L \u2192 R) : submodule R M :=\n\u2a05 (x : L), (to_endomorphism R L M x).maximal_generalized_eigenspace (\u03c7 x)\n\nlemma mem_pre_weight_space (\u03c7 : L \u2192 R) (m : M) :\n  m \u2208 pre_weight_space M \u03c7 \u2194 \u2200 x, \u2203 (k : \u2115), ((to_endomorphism R L M x - (\u03c7 x) \u2022 1)^k) m = 0 :=\nby simp [pre_weight_space, -linear_map.pow_apply]\n\nvariables (L)\n\n/-- See also `bourbaki1975b` Chapter VII \u00a71.1, Proposition 2 (ii). -/\nprotected lemma weight_vector_multiplication (M\u2081 : Type w\u2081) (M\u2082 : Type w\u2082) (M\u2083 : Type w\u2083)\n  [add_comm_group M\u2081] [module R M\u2081] [lie_ring_module L M\u2081] [lie_module R L M\u2081]\n  [add_comm_group M\u2082] [module R M\u2082] [lie_ring_module L M\u2082] [lie_module R L M\u2082]\n  [add_comm_group M\u2083] [module R M\u2083] [lie_ring_module L M\u2083] [lie_module R L M\u2083]\n (g : M\u2081 \u2297[R] M\u2082 \u2192\u2097\u2045R,L\u2046 M\u2083) (\u03c7\u2081 \u03c7\u2082 : L \u2192 R) :\n  ((g : M\u2081 \u2297[R] M\u2082 \u2192\u2097[R] M\u2083).comp\n  (map_incl (pre_weight_space M\u2081 \u03c7\u2081) (pre_weight_space M\u2082 \u03c7\u2082))).range \u2264\n    pre_weight_space M\u2083 (\u03c7\u2081 + \u03c7\u2082) :=\nbegin\n  /- Unpack the statement of the goal. -/\n  intros m\u2083,\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\u2083 := (to_endomorphism R L M\u2083 x) - (\u03c7\u2081 x + \u03c7\u2082 x) \u2022 1,\n  change \u2203 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\u2081 t\u2082 \u27e8k\u2081, hk\u2081\u27e9 \u27e8k\u2082, hk\u2082\u27e9, use max k\u2081 k\u2082,\n    simp only [lie_module_hom.map_add, linear_map.map_add,\n      linear_map.pow_map_zero_of_le (le_max_left k\u2081 k\u2082) hk\u2081,\n      linear_map.pow_map_zero_of_le (le_max_right k\u2081 k\u2082) hk\u2082, add_zero], },\n\n  /- Now the main argument: pure tensors. -/\n  rintros \u27e8m\u2081, hm\u2081\u27e9 \u27e8m\u2082, hm\u2082\u27e9,\n  change \u2203 k, (F^k) ((g : M\u2081 \u2297[R] M\u2082 \u2192\u2097[R] M\u2083) (m\u2081 \u2297\u209c m\u2082)) = 0,\n\n  /- Eliminate `g` from the picture. -/\n  let f\u2081 : module.End R (M\u2081 \u2297[R] M\u2082) := (to_endomorphism R L M\u2081 x - (\u03c7\u2081 x) \u2022 1).rtensor M\u2082,\n  let f\u2082 : module.End R (M\u2081 \u2297[R] M\u2082) := (to_endomorphism R L M\u2082 x - (\u03c7\u2082 x) \u2022 1).ltensor M\u2081,\n  have h_comm_square : F \u2218\u2097 \u2191g = (g : M\u2081 \u2297[R] M\u2082 \u2192\u2097[R] M\u2083).comp (f\u2081 + f\u2082),\n  { ext m\u2081 m\u2082, simp only [\u2190 g.map_lie x (m\u2081 \u2297\u209c m\u2082), 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 : \u2203 k, ((f\u2081 + f\u2082)^k) (m\u2081 \u2297\u209c m\u2082) = 0,\n  { obtain \u27e8k, hk\u27e9 := this, use k,\n    rw [\u2190 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\u2081`, `m\u2082`. -/\n  simp only [mem_pre_weight_space] at hm\u2081 hm\u2082,\n  obtain \u27e8k\u2081, hk\u2081\u27e9 := hm\u2081 x,\n  obtain \u27e8k\u2082, hk\u2082\u27e9 := hm\u2082 x,\n  have hf\u2081 : (f\u2081^k\u2081) (m\u2081 \u2297\u209c m\u2082) = 0,\n  { simp only [hk\u2081, zero_tmul, linear_map.rtensor_tmul, linear_map.rtensor_pow], },\n  have hf\u2082 : (f\u2082^k\u2082) (m\u2081 \u2297\u209c m\u2082) = 0,\n  { simp only [hk\u2082, 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\u2081 + k\u2082 - 1,\n  have hf_comm : commute f\u2081 f\u2082,\n  { ext m\u2081 m\u2082, 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 \u27e8i, j\u27e9 hij,\n\n  /- Eliminate the binomial coefficients from the picture. -/\n  suffices : (f\u2081^i * f\u2082^j) (m\u2081 \u2297\u209c m\u2082) = 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\u2081,\n    linear_map.map_zero], },\n  { rw [linear_map.mul_apply, linear_map.pow_map_zero_of_le hj hf\u2082, linear_map.map_zero], },\nend\n\nvariables {L M}\n\nlemma lie_mem_pre_weight_space_of_mem_pre_weight_space {\u03c7\u2081 \u03c7\u2082 : L \u2192 R} {x : L} {m : M}\n  (hx : x \u2208 pre_weight_space L \u03c7\u2081) (hm : m \u2208 pre_weight_space M \u03c7\u2082) :\n  \u2045x, m\u2046 \u2208 pre_weight_space M (\u03c7\u2081 + \u03c7\u2082) :=\nbegin\n  apply lie_module.weight_vector_multiplication L L M M (to_module_hom R L M) \u03c7\u2081 \u03c7\u2082,\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 [\u27e8x, hx\u27e9 \u2297\u209c \u27e8m, hm\u27e9],\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] (\u03c7 : L \u2192 R) : lie_submodule R L M :=\n{ lie_mem := \u03bb x m hm,\n  begin\n    rw \u2190 zero_add \u03c7,\n    refine lie_mem_pre_weight_space_of_mem_pre_weight_space _ hm,\n    suffices : pre_weight_space L (0 : L \u2192 R) = \u22a4, { 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 \u03c7 }\n\nlemma mem_weight_space [lie_algebra.is_nilpotent R L] (\u03c7 : L \u2192 R) (m : M) :\n  m \u2208 weight_space M \u03c7 \u2194 m \u2208 pre_weight_space M \u03c7 :=\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 \u2192 R) = \u22a4 :=\nbegin\n  rw [\u2190 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] (\u03c7 : L \u2192 R) :\n  (weight_space M (\u03c7 \u2218 (\u22a4 : lie_subalgebra R L).incl) : submodule R M) = weight_space M \u03c7 :=\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 \u27e8k, hk\u27e9 := h \u27e8x, set.mem_univ x\u27e9, use k, exact hk, },\n  { obtain \u27e8k, hk\u27e9 := 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 : (\u22a4 : lie_subalgebra R L) \u2192 R) = \u22a4 :=\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 (\u22a4 : lie_subalgebra R L) M` is equivalent to `is_nilpotent R L M`. -/\n  have h\u2080 : (0 : L \u2192 R) \u2218 (\u22a4 : lie_subalgebra R L).incl = 0, { ext, refl, },\n  rw [\u2190 lie_submodule.coe_to_submodule_eq_iff, lie_submodule.top_coe_submodule, \u2190 h\u2080,\n    coe_weight_space_of_top, \u2190 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 \u2286 L` is a Lie character whose corresponding weight space is non-empty. -/\ndef is_weight (\u03c7 : lie_character R H) : Prop := weight_space M \u03c7 \u2260 \u22a5\n\n/-- For a non-trivial nilpotent Lie module over a nilpotent Lie algebra, the zero character is a\nweight with respect to the `\u22a4` 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 (\u22a4 : 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 \u2286 L`, the root space of a map `\u03c7 : H \u2192 R` is the weight\nspace of `L` regarded as a module of `H` via the adjoint action. -/\nabbreviation root_space (\u03c7 : H \u2192 R) : lie_submodule R H L := weight_space L \u03c7\n\n@[simp] \n\n/-- A root of a Lie algebra `L` with respect to a nilpotent subalgebra `H \u2286 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 (\u03c7 : H \u2192 R) :\n  (root_space H \u03c7).comap H.incl' = weight_space H \u03c7 :=\nbegin\n  ext x,\n  let f : H \u2192 module.End R L := \u03bb y, to_endomorphism R H L y - (\u03c7 y) \u2022 1,\n  let g : H \u2192 module.End R H := \u03bb y, to_endomorphism R H H y - (\u03c7 y) \u2022 1,\n  suffices : (\u2200 (y : H), \u2203 (k : \u2115), ((f y)^k).comp (H.incl : H \u2192\u2097[R] L) x = 0) \u2194\n              \u2200 (y : H), \u2203 (k : \u2115), (H.incl : H \u2192\u2097[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 : \u2200 (y : H), (f y).comp (H.incl : H \u2192\u2097[R] L) = (H.incl : H \u2192\u2097[R] L).comp (g y),\n  { rintros \u27e8y, hy\u27e9, ext \u27e8z, hz\u27e9,\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 {\u03c7\u2081 \u03c7\u2082 : H \u2192 R} {x : L} {m : M}\n  (hx : x \u2208 root_space H \u03c7\u2081) (hm : m \u2208 weight_space M \u03c7\u2082) : \u2045x, m\u2046 \u2208 weight_space M (\u03c7\u2081 + \u03c7\u2082) :=\nbegin\n  apply lie_module.weight_vector_multiplication\n    H L M M ((to_module_hom R L M).restrict_lie H) \u03c7\u2081 \u03c7\u2082,\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 [\u27e8x, hx\u27e9 \u2297\u209c \u27e8m, hm\u27e9],\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 {\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R} (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) :\n  (root_space H \u03c7\u2081) \u2192\u2097[R] (weight_space M \u03c7\u2082) \u2192\u2097[R] (weight_space M \u03c7\u2083) :=\n{ to_fun    := \u03bb x,\n  { to_fun    :=\n      \u03bb m, \u27e8\u2045(x : L), (m : M)\u2046,\n            h\u03c7 \u25b8 (lie_mem_weight_space_of_mem_weight_space x.property m.property) \u27e9,\n    map_add'  := \u03bb m n, by { simp only [lie_submodule.coe_add, lie_add], refl, },\n    map_smul' := \u03bb t m, by { conv_lhs { congr, rw [lie_submodule.coe_smul, lie_smul], }, refl, }, },\n  map_add'  := \u03bb 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' := \u03bb 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 \u2286 L` together with `\u03c7\u2081 \u03c7\u2082 : H \u2192 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 (\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R) (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) :\n  (root_space H \u03c7\u2081) \u2297[R] (weight_space M \u03c7\u2082) \u2192\u2097\u2045R,H\u2046 weight_space M \u03c7\u2083 :=\nlift_lie R H (root_space H \u03c7\u2081) (weight_space M \u03c7\u2082) (weight_space M \u03c7\u2083)\n{ to_linear_map := root_space_weight_space_product_aux R L H M h\u03c7,\n  map_lie' := \u03bb 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  (\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R) (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) (x : root_space H \u03c7\u2081) (m : weight_space M \u03c7\u2082) :\n  (root_space_weight_space_product R L H M \u03c7\u2081 \u03c7\u2082 \u03c7\u2083 h\u03c7 (x \u2297\u209c m) : M) = \u2045(x : L), (m : M)\u2046 :=\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 \u2286 L` together with `\u03c7\u2081 \u03c7\u2082 : H \u2192 R`, there is a natural\n`R`-bilinear product of root vectors, compatible with the actions of `H`. -/\ndef root_space_product (\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R) (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) :\n  (root_space H \u03c7\u2081) \u2297[R] (root_space H \u03c7\u2082) \u2192\u2097\u2045R,H\u2046 root_space H \u03c7\u2083 :=\nroot_space_weight_space_product R L H L \u03c7\u2081 \u03c7\u2082 \u03c7\u2083 h\u03c7\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  (\u03c7\u2081 \u03c7\u2082 \u03c7\u2083 : H \u2192 R) (h\u03c7 : \u03c7\u2081 + \u03c7\u2082 = \u03c7\u2083) (x : root_space H \u03c7\u2081) (y : root_space H \u03c7\u2082) :\n  (root_space_product R L H \u03c7\u2081 \u03c7\u2082 \u03c7\u2083 h\u03c7 (x \u2297\u209c y) : L) = \u2045(x : L), (y : L)\u2046 :=\nby simp only [root_space_product_def, coe_root_space_weight_space_product_tmul]\n\n/-- Given a nilpotent Lie subalgebra `H \u2286 L`, the root space of the zero map `0 : H \u2192 R` is a Lie\nsubalgebra of `L`. -/\ndef zero_root_subalgebra : lie_subalgebra R L :=\n{ lie_mem' := \u03bb x y hx hy, by\n  { let xy : (root_space H 0) \u2297[R] (root_space H 0) := \u27e8x, hx\u27e9 \u2297\u209c \u27e8y, hy\u27e9,\n    suffices : (root_space_product R L H 0 0 0 (add_zero 0) xy : L) \u2208 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 \u2208 zero_root_subalgebra R L H \u2194 \u2200 (y : H), \u2203 (k : \u2115), ((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 \u2264 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 \u27e8k, hk\u27e9 := (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 \u27e8x, hx\u27e9 = 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 \u27e8x, hx\u27e9 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 \u2264 zero_root_subalgebra R L H :=\nbegin\n  rw [\u2190 lie_subalgebra.coe_submodule_le_coe_submodule, \u2190 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 \u27e8y, hy\u27e9,\n  specialize hx y (le_zero_root_subalgebra R L H hy),\n  rw mem_zero_root_subalgebra at hx,\n  obtain \u27e8k, hk\u27e9 := hx \u27e8y, hy\u27e9,\n  rw [\u2190 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 \u2194 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 \u2190 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' (\u03c7 : H \u2192 R) : lie_submodule R (zero_root_subalgebra R L H) M :=\n{ lie_mem := \u03bb x m hm, by\n  { have hx : (x : L) \u2208 root_space H 0,\n    { rw [\u2190 lie_submodule.mem_coe_submodule, \u2190 coe_zero_root_subalgebra], exact x.property, },\n    rw \u2190 zero_add \u03c7,\n    exact lie_mem_weight_space_of_mem_weight_space hx hm, },\n  .. (weight_space M \u03c7 : submodule R M) }\n\n@[simp] lemma coe_weight_space' (\u03c7 : H \u2192 R) :\n  (weight_space' M \u03c7 : submodule R M) = weight_space M \u03c7 :=\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 {\u03b1 M\u2080 G\u2080 M\u2080' G\u2080' F F' : Type _}\n\nvariable [MonoidWithZero M\u2080]\n\nnamespace Units\n\n/- warning: units.ne_zero -> Units.ne_zero is a dubious translation:\nlean 3 declaration is\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] [_inst_2 : Nontrivial.{u1} M\u2080] (u : Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)), Ne.{succ u1} M\u2080 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (Units.hasCoe.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1))))) u) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] [_inst_2 : Nontrivial.{u1} M\u2080] (u : Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)), Ne.{succ u1} M\u2080 (Units.val.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) u) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align units.ne_zero Units.ne_zero\u2093'. -/\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\u2080] (u : M\u2080\u02e3) : (u : M\u2080) \u2260 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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (u : Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) {a : M\u2080}, Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (Units.hasCoe.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1))))) u)) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))) (Eq.{succ u1} M\u2080 a (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (u : Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) {a : M\u2080}, Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) a (Units.val.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) u)) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))) (Eq.{succ u1} M\u2080 a (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align units.mul_left_eq_zero Units.mul_left_eq_zero\u2093'. -/\n-- We can't use `mul_eq_zero` + `units.ne_zero` in the next two lemmas because we don't assume\n-- `nonzero M\u2080`.\n@[simp]\ntheorem mul_left_eq_zero (u : M\u2080\u02e3) {a : M\u2080} : a * u = 0 \u2194 a = 0 :=\n  \u27e8fun h => by simpa using mul_eq_zero_of_left h \u2191u\u207b\u00b9, fun h => mul_eq_zero_of_left h u\u27e9\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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (u : Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) {a : M\u2080}, Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) M\u2080 (Units.hasCoe.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1))))) u) a) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))) (Eq.{succ u1} M\u2080 a (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (u : Units.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)) {a : M\u2080}, Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Units.val.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) u) a) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))) (Eq.{succ u1} M\u2080 a (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align units.mul_right_eq_zero Units.mul_right_eq_zero\u2093'. -/\n@[simp]\ntheorem mul_right_eq_zero (u : M\u2080\u02e3) {a : M\u2080} : \u2191u * a = 0 \u2194 a = 0 :=\n  \u27e8fun h => by simpa using mul_eq_zero_of_right (\u2191u\u207b\u00b9) h, mul_eq_zero_of_right u\u27e9\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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] [_inst_2 : Nontrivial.{u1} M\u2080] {a : M\u2080}, (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) a) -> (Ne.{succ u1} M\u2080 a (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] [_inst_2 : Nontrivial.{u1} M\u2080] {a : M\u2080}, (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) a) -> (Ne.{succ u1} M\u2080 a (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align is_unit.ne_zero IsUnit.ne_zero\u2093'. -/\ntheorem ne_zero [Nontrivial M\u2080] {a : M\u2080} (ha : IsUnit a) : a \u2260 0 :=\n  let \u27e8u, hu\u27e9 := ha\n  hu \u25b8 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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] {a : M\u2080} {b : M\u2080}, (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) a) -> (Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) a b) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))) (Eq.{succ u1} M\u2080 b (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] {a : M\u2080} {b : M\u2080}, (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) a) -> (Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) a b) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))) (Eq.{succ u1} M\u2080 b (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align is_unit.mul_right_eq_zero IsUnit.mul_right_eq_zero\u2093'. -/\ntheorem mul_right_eq_zero {a b : M\u2080} (ha : IsUnit a) : a * b = 0 \u2194 b = 0 :=\n  let \u27e8u, hu\u27e9 := ha\n  hu \u25b8 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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] {a : M\u2080} {b : M\u2080}, (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) b) -> (Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) a b) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))) (Eq.{succ u1} M\u2080 a (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] {a : M\u2080} {b : M\u2080}, (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) b) -> (Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) a b) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))) (Eq.{succ u1} M\u2080 a (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align is_unit.mul_left_eq_zero IsUnit.mul_left_eq_zero\u2093'. -/\ntheorem mul_left_eq_zero {a b : M\u2080} (hb : IsUnit b) : a * b = 0 \u2194 a = 0 :=\n  let \u27e8u, hu\u27e9 := hb\n  hu \u25b8 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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080], Iff (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))) (Eq.{succ u1} M\u2080 (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))) (OfNat.ofNat.{u1} M\u2080 1 (OfNat.mk.{u1} M\u2080 1 (One.one.{u1} M\u2080 (MulOneClass.toHasOne.{u1} M\u2080 (MulZeroOneClass.toMulOneClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080], Iff (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))) (Eq.{succ u1} M\u2080 (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1))) (OfNat.ofNat.{u1} M\u2080 1 (One.toOfNat1.{u1} M\u2080 (Monoid.toOne.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align is_unit_zero_iff isUnit_zero_iff\u2093'. -/\n@[simp]\ntheorem isUnit_zero_iff : IsUnit (0 : M\u2080) \u2194 (0 : M\u2080) = 1 :=\n  \u27e8fun \u27e8\u27e8_, a, (a0 : 0 * a = 1), _\u27e9, rfl\u27e9 => by rwa [MulZeroClass.zero_mul] at a0, fun h =>\n    @isUnit_of_subsingleton _ _ (subsingleton_of_zero_eq_one h) 0\u27e9\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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] [_inst_2 : Nontrivial.{u1} M\u2080], Not (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] [_inst_2 : Nontrivial.{u1} M\u2080], Not (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align not_is_unit_zero not_isUnit_zero\u2093'. -/\n@[simp]\ntheorem not_isUnit_zero [Nontrivial M\u2080] : \u00acIsUnit (0 : M\u2080) :=\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\u2080`, which sends `x` to `x\u207b\u00b9` 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\u2080` instead of `ring M\u2080`. -/\nnoncomputable def inverse : M\u2080 \u2192 M\u2080 := fun x => if h : IsUnit x then ((h.Unit\u207b\u00b9 : M\u2080\u02e3) : M\u2080) 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\u207b\u00b9`. -/\n@[simp]\ntheorem inverse_unit (u : M\u2080\u02e3) : inverse (u : M\u2080) = (u\u207b\u00b9 : M\u2080\u02e3) :=\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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080), (Not (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x)) -> (Eq.{succ u1} M\u2080 (Ring.inverse.{u1} M\u2080 _inst_1 x) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080), (Not (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x)) -> (Eq.{succ u1} M\u2080 (Ring.inverse.{u1} M\u2080 _inst_1 x) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_non_unit Ring.inverse_non_unit\u2093'. -/\n/-- By definition, if `x` is not invertible then `inverse x = 0`. -/\n@[simp]\ntheorem inverse_non_unit (x : M\u2080) (h : \u00acIsUnit 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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) x (Ring.inverse.{u1} M\u2080 _inst_1 x)) (OfNat.ofNat.{u1} M\u2080 1 (OfNat.mk.{u1} M\u2080 1 (One.one.{u1} M\u2080 (MulOneClass.toHasOne.{u1} M\u2080 (MulZeroOneClass.toMulOneClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) x (Ring.inverse.{u1} M\u2080 _inst_1 x)) (OfNat.ofNat.{u1} M\u2080 1 (One.toOfNat1.{u1} M\u2080 (Monoid.toOne.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align ring.mul_inverse_cancel Ring.mul_inverse_cancel\u2093'. -/\ntheorem mul_inverse_cancel (x : M\u2080) (h : IsUnit x) : x * inverse x = 1 :=\n  by\n  rcases h with \u27e8u, rfl\u27e9\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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Ring.inverse.{u1} M\u2080 _inst_1 x) x) (OfNat.ofNat.{u1} M\u2080 1 (OfNat.mk.{u1} M\u2080 1 (One.one.{u1} M\u2080 (MulOneClass.toHasOne.{u1} M\u2080 (MulZeroOneClass.toMulOneClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))))))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Ring.inverse.{u1} M\u2080 _inst_1 x) x) (OfNat.ofNat.{u1} M\u2080 1 (One.toOfNat1.{u1} M\u2080 (Monoid.toOne.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_mul_cancel Ring.inverse_mul_cancel\u2093'. -/\ntheorem inverse_mul_cancel (x : M\u2080) (h : IsUnit x) : inverse x * x = 1 :=\n  by\n  rcases h with \u27e8u, rfl\u27e9\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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) y x) (Ring.inverse.{u1} M\u2080 _inst_1 x)) y)\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) y x) (Ring.inverse.{u1} M\u2080 _inst_1 x)) y)\nCase conversion may be inaccurate. Consider using '#align ring.mul_inverse_cancel_right Ring.mul_inverse_cancel_right\u2093'. -/\ntheorem mul_inverse_cancel_right (x y : M\u2080) (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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) y (Ring.inverse.{u1} M\u2080 _inst_1 x)) x) y)\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) y (Ring.inverse.{u1} M\u2080 _inst_1 x)) x) y)\nCase conversion may be inaccurate. Consider using '#align ring.inverse_mul_cancel_right Ring.inverse_mul_cancel_right\u2093'. -/\ntheorem inverse_mul_cancel_right (x y : M\u2080) (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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) x (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Ring.inverse.{u1} M\u2080 _inst_1 x) y)) y)\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) x (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Ring.inverse.{u1} M\u2080 _inst_1 x) y)) y)\nCase conversion may be inaccurate. Consider using '#align ring.mul_inverse_cancel_left Ring.mul_inverse_cancel_left\u2093'. -/\ntheorem mul_inverse_cancel_left (x y : M\u2080) (h : IsUnit x) : x * (inverse x * y) = y := by\n  rw [\u2190 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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Ring.inverse.{u1} M\u2080 _inst_1 x) (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) x y)) y)\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Ring.inverse.{u1} M\u2080 _inst_1 x) (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) x y)) y)\nCase conversion may be inaccurate. Consider using '#align ring.inverse_mul_cancel_left Ring.inverse_mul_cancel_left\u2093'. -/\ntheorem inverse_mul_cancel_left (x y : M\u2080) (h : IsUnit x) : inverse x * (x * y) = y := by\n  rw [\u2190 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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080) (z : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Ring.inverse.{u1} M\u2080 _inst_1 x) y) z) (Eq.{succ u1} M\u2080 y (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) x z)))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080) (z : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) x) -> (Iff (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) (Ring.inverse.{u1} M\u2080 _inst_1 x) y) z) (Eq.{succ u1} M\u2080 y (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _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\u2093'. -/\ntheorem inverse_mul_eq_iff_eq_mul (x y z : M\u2080) (h : IsUnit x) : inverse x * y = z \u2194 y = x * z :=\n  \u27e8fun h1 => by rw [\u2190 h1, mul_inverse_cancel_left _ _ h], fun h1 => by\n    rw [h1, inverse_mul_cancel_left _ _ h]\u27e9\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\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080) (z : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) z) -> (Iff (Eq.{succ u1} M\u2080 x (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) y (Ring.inverse.{u1} M\u2080 _inst_1 z))) (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toHasMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) x z) y))\nbut is expected to have type\n  forall {M\u2080 : Type.{u1}} [_inst_1 : MonoidWithZero.{u1} M\u2080] (x : M\u2080) (y : M\u2080) (z : M\u2080), (IsUnit.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1) z) -> (Iff (Eq.{succ u1} M\u2080 x (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1)))) y (Ring.inverse.{u1} M\u2080 _inst_1 z))) (Eq.{succ u1} M\u2080 (HMul.hMul.{u1, u1, u1} M\u2080 M\u2080 M\u2080 (instHMul.{u1} M\u2080 (MulZeroClass.toMul.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _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\u2093'. -/\ntheorem eq_mul_inverse_iff_mul_eq (x y z : M\u2080) (h : IsUnit z) : x = y * inverse z \u2194 x * z = y :=\n  \u27e8fun h1 => by rw [h1, inverse_mul_cancel_right _ _ h], fun h1 => by\n    rw [\u2190 h1, mul_inverse_cancel_right _ _ h]\u27e9\n#align ring.eq_mul_inverse_iff_mul_eq Ring.eq_mul_inverse_iff_mul_eq\n\nvariable (M\u2080)\n\n/- warning: ring.inverse_one -> Ring.inverse_one is a dubious translation:\nlean 3 declaration is\n  forall (M\u2080 : Type.{u1}) [_inst_1 : MonoidWithZero.{u1} M\u2080], Eq.{succ u1} M\u2080 (Ring.inverse.{u1} M\u2080 _inst_1 (OfNat.ofNat.{u1} M\u2080 1 (OfNat.mk.{u1} M\u2080 1 (One.one.{u1} M\u2080 (MulOneClass.toHasOne.{u1} M\u2080 (MulZeroOneClass.toMulOneClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))) (OfNat.ofNat.{u1} M\u2080 1 (OfNat.mk.{u1} M\u2080 1 (One.one.{u1} M\u2080 (MulOneClass.toHasOne.{u1} M\u2080 (MulZeroOneClass.toMulOneClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))\nbut is expected to have type\n  forall (M\u2080 : Type.{u1}) [_inst_1 : MonoidWithZero.{u1} M\u2080], Eq.{succ u1} M\u2080 (Ring.inverse.{u1} M\u2080 _inst_1 (OfNat.ofNat.{u1} M\u2080 1 (One.toOfNat1.{u1} M\u2080 (Monoid.toOne.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1))))) (OfNat.ofNat.{u1} M\u2080 1 (One.toOfNat1.{u1} M\u2080 (Monoid.toOne.{u1} M\u2080 (MonoidWithZero.toMonoid.{u1} M\u2080 _inst_1))))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_one Ring.inverse_one\u2093'. -/\n@[simp]\ntheorem inverse_one : inverse (1 : M\u2080) = 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\u2080 : Type.{u1}) [_inst_1 : MonoidWithZero.{u1} M\u2080], Eq.{succ u1} M\u2080 (Ring.inverse.{u1} M\u2080 _inst_1 (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))) (OfNat.ofNat.{u1} M\u2080 0 (OfNat.mk.{u1} M\u2080 0 (Zero.zero.{u1} M\u2080 (MulZeroClass.toHasZero.{u1} M\u2080 (MulZeroOneClass.toMulZeroClass.{u1} M\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} M\u2080 _inst_1))))))\nbut is expected to have type\n  forall (M\u2080 : Type.{u1}) [_inst_1 : MonoidWithZero.{u1} M\u2080], Eq.{succ u1} M\u2080 (Ring.inverse.{u1} M\u2080 _inst_1 (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))) (OfNat.ofNat.{u1} M\u2080 0 (Zero.toOfNat0.{u1} M\u2080 (MonoidWithZero.toZero.{u1} M\u2080 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_zero Ring.inverse_zero\u2093'. -/\n@[simp]\ntheorem inverse_zero : inverse (0 : M\u2080) = 0 :=\n  by\n  nontriviality\n  exact inverse_non_unit _ not_isUnit_zero\n#align ring.inverse_zero Ring.inverse_zero\n\nvariable {M\u2080}\n\nend Ring\n\n#print IsUnit.ring_inverse /-\ntheorem IsUnit.ring_inverse {a : M\u2080} : IsUnit a \u2192 IsUnit (Ring.inverse a)\n  | \u27e8u, hu\u27e9 => hu \u25b8 \u27e8u\u207b\u00b9, (Ring.inverse_unit u).symm\u27e9\n#align is_unit.ring_inverse IsUnit.ring_inverse\n-/\n\n#print isUnit_ring_inverse /-\n@[simp]\ntheorem isUnit_ring_inverse {a : M\u2080} : IsUnit (Ring.inverse a) \u2194 IsUnit a :=\n  \u27e8fun h => by\n    cases subsingleton_or_nontrivial M\u2080\n    \u00b7 convert h\n    \u00b7 contrapose h\n      rw [Ring.inverse_non_unit _ h]\n      exact not_isUnit_zero, IsUnit.ring_inverse\u27e9\n#align is_unit_ring_inverse isUnit_ring_inverse\n-/\n\nnamespace Units\n\nvariable [GroupWithZero G\u2080]\n\nvariable {a b : G\u2080}\n\n/- warning: units.mk0 -> Units.mk0 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (a : G\u2080), (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) -> (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (a : G\u2080), (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) -> (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))\nCase conversion may be inaccurate. Consider using '#align units.mk0 Units.mk0\u2093'. -/\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 `/\u209a` operation, it is possible to write a division\n  as a partial function with three arguments. -/\ndef mk0 (a : G\u2080) (ha : a \u2260 0) : G\u2080\u02e3 :=\n  \u27e8a, a\u207b\u00b9, mul_inv_cancel ha, inv_mul_cancel ha\u27e9\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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (h : optParam.{0} (Ne.{succ u1} G\u2080 (OfNat.ofNat.{u1} G\u2080 1 (OfNat.mk.{u1} G\u2080 1 (One.one.{u1} G\u2080 (MulOneClass.toHasOne.{u1} G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (one_ne_zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))) (MulOneClass.toHasOne.{u1} G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))) (NeZero.one.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) (GroupWithZero.to_nontrivial.{u1} G\u2080 _inst_2)))), Eq.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mk0.{u1} G\u2080 _inst_2 (OfNat.ofNat.{u1} G\u2080 1 (OfNat.mk.{u1} G\u2080 1 (One.one.{u1} G\u2080 (MulOneClass.toHasOne.{u1} G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) h) (OfNat.ofNat.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) 1 (OfNat.mk.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) 1 (One.one.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (MulOneClass.toHasOne.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mulOneClass.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (h : optParam.{0} (Ne.{succ u1} G\u2080 (OfNat.ofNat.{u1} G\u2080 1 (One.toOfNat1.{u1} G\u2080 (InvOneClass.toOne.{u1} G\u2080 (DivInvOneMonoid.toInvOneClass.{u1} G\u2080 (DivisionMonoid.toDivInvOneMonoid.{u1} G\u2080 (GroupWithZero.toDivisionMonoid.{u1} G\u2080 _inst_2)))))) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (one_ne_zero.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) (InvOneClass.toOne.{u1} G\u2080 (DivInvOneMonoid.toInvOneClass.{u1} G\u2080 (DivisionMonoid.toDivInvOneMonoid.{u1} G\u2080 (GroupWithZero.toDivisionMonoid.{u1} G\u2080 _inst_2)))) (NeZero.one.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) (GroupWithZero.toNontrivial.{u1} G\u2080 _inst_2)))), Eq.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mk0.{u1} G\u2080 _inst_2 (OfNat.ofNat.{u1} G\u2080 1 (One.toOfNat1.{u1} G\u2080 (InvOneClass.toOne.{u1} G\u2080 (DivInvOneMonoid.toInvOneClass.{u1} G\u2080 (DivisionMonoid.toDivInvOneMonoid.{u1} G\u2080 (GroupWithZero.toDivisionMonoid.{u1} G\u2080 _inst_2)))))) h) (OfNat.ofNat.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) 1 (One.toOfNat1.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (InvOneClass.toOne.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (DivInvOneMonoid.toInvOneClass.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (DivisionMonoid.toDivInvOneMonoid.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Group.toDivisionMonoid.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.instGroupUnits.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))))\nCase conversion may be inaccurate. Consider using '#align units.mk0_one Units.mk0_one\u2093'. -/\n@[simp]\ntheorem mk0_one (h := one_ne_zero) : mk0 (1 : G\u2080) 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} (h : Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))), Eq.{succ u1} G\u2080 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) (Units.mk0.{u1} G\u2080 _inst_2 a h)) a\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} (h : Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))), Eq.{succ u1} G\u2080 (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) (Units.mk0.{u1} G\u2080 _inst_2 a h)) a\nCase conversion may be inaccurate. Consider using '#align units.coe_mk0 Units.val_mk0\u2093'. -/\n@[simp]\ntheorem val_mk0 {a : G\u2080} (h : a \u2260 0) : (mk0 a h : G\u2080) = 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (h : Ne.{succ u1} G\u2080 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) u) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))), Eq.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mk0.{u1} G\u2080 _inst_2 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) u) h) u\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (h : Ne.{succ u1} G\u2080 (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) u) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))), Eq.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mk0.{u1} G\u2080 _inst_2 (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) u) h) u\nCase conversion may be inaccurate. Consider using '#align units.mk0_coe Units.mk0_val\u2093'. -/\n@[simp]\ntheorem mk0_val (u : G\u2080\u02e3) (h : (u : G\u2080) \u2260 0) : mk0 (u : G\u2080) 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))), Eq.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) u) (Inv.inv.{u1} G\u2080 (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_2)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) u))) (OfNat.ofNat.{u1} G\u2080 1 (OfNat.mk.{u1} G\u2080 1 (One.one.{u1} G\u2080 (MulOneClass.toHasOne.{u1} G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))), Eq.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) u) (Inv.inv.{u1} G\u2080 (GroupWithZero.toInv.{u1} G\u2080 _inst_2) (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) u))) (OfNat.ofNat.{u1} G\u2080 1 (One.toOfNat1.{u1} G\u2080 (InvOneClass.toOne.{u1} G\u2080 (DivInvOneMonoid.toInvOneClass.{u1} G\u2080 (DivisionMonoid.toDivInvOneMonoid.{u1} G\u2080 (GroupWithZero.toDivisionMonoid.{u1} G\u2080 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align units.mul_inv' Units.mul_inv'\u2093'. -/\n@[simp]\ntheorem mul_inv' (u : G\u2080\u02e3) : (u : G\u2080) * u\u207b\u00b9 = 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))), Eq.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Inv.inv.{u1} G\u2080 (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_2)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) u)) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) u)) (OfNat.ofNat.{u1} G\u2080 1 (OfNat.mk.{u1} G\u2080 1 (One.one.{u1} G\u2080 (MulOneClass.toHasOne.{u1} G\u2080 (MulZeroOneClass.toMulOneClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))), Eq.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Inv.inv.{u1} G\u2080 (GroupWithZero.toInv.{u1} G\u2080 _inst_2) (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) u)) (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) u)) (OfNat.ofNat.{u1} G\u2080 1 (One.toOfNat1.{u1} G\u2080 (InvOneClass.toOne.{u1} G\u2080 (DivInvOneMonoid.toInvOneClass.{u1} G\u2080 (DivisionMonoid.toDivInvOneMonoid.{u1} G\u2080 (GroupWithZero.toDivisionMonoid.{u1} G\u2080 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align units.inv_mul' Units.inv_mul'\u2093'. -/\n@[simp]\ntheorem inv_mul' (u : G\u2080\u02e3) : (u\u207b\u00b9 : G\u2080) * 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} {b : G\u2080} (ha : Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (hb : Ne.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))), Iff (Eq.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mk0.{u1} G\u2080 _inst_2 a ha) (Units.mk0.{u1} G\u2080 _inst_2 b hb)) (Eq.{succ u1} G\u2080 a b)\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} {b : G\u2080} (ha : Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (hb : Ne.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))), Iff (Eq.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mk0.{u1} G\u2080 _inst_2 a ha) (Units.mk0.{u1} G\u2080 _inst_2 b hb)) (Eq.{succ u1} G\u2080 a b)\nCase conversion may be inaccurate. Consider using '#align units.mk0_inj Units.mk0_inj\u2093'. -/\n@[simp]\ntheorem mk0_inj {a b : G\u2080} (ha : a \u2260 0) (hb : b \u2260 0) : Units.mk0 a ha = Units.mk0 b hb \u2194 a = b :=\n  \u27e8fun h => by injection h, fun h => Units.ext h\u27e9\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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {p : (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) -> Prop}, Iff (Exists.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (fun (g : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) => p g)) (Exists.{succ u1} G\u2080 (fun (g : G\u2080) => Exists.{0} (Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (fun (hg : Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) => p (Units.mk0.{u1} G\u2080 _inst_2 g hg))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {p : (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) -> Prop}, Iff (Exists.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (fun (g : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) => p g)) (Exists.{succ u1} G\u2080 (fun (g : G\u2080) => Exists.{0} (Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (fun (hg : Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) => p (Units.mk0.{u1} G\u2080 _inst_2 g hg))))\nCase conversion may be inaccurate. Consider using '#align units.exists0 Units.exists0\u2093'. -/\n/-- In a group with zero, an existential over a unit can be rewritten in terms of `units.mk0`. -/\ntheorem exists0 {p : G\u2080\u02e3 \u2192 Prop} : (\u2203 g : G\u2080\u02e3, p g) \u2194 \u2203 (g : G\u2080)(hg : g \u2260 0), p (Units.mk0 g hg) :=\n  \u27e8fun \u27e8g, pg\u27e9 => \u27e8g, g.NeZero, (g.mk0_val g.NeZero).symm \u25b8 pg\u27e9, fun \u27e8g, hg, pg\u27e9 =>\n    \u27e8Units.mk0 g hg, pg\u27e9\u27e9\n#align units.exists0 Units.exists0\n\n/- warning: units.exists0' -> Units.exists0' is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {p : forall (g : G\u2080), (Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) -> Prop}, Iff (Exists.{succ u1} G\u2080 (fun (g : G\u2080) => Exists.{0} (Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (fun (hg : Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) => p g hg))) (Exists.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (fun (g : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) => p ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) g) (Units.ne_zero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2) (GroupWithZero.to_nontrivial.{u1} G\u2080 _inst_2) g)))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {p : forall (g : G\u2080), (Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) -> Prop}, Iff (Exists.{succ u1} G\u2080 (fun (g : G\u2080) => Exists.{0} (Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (fun (hg : Ne.{succ u1} G\u2080 g (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) => p g hg))) (Exists.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (fun (g : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) => p (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) g) (Units.ne_zero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2) (GroupWithZero.toNontrivial.{u1} G\u2080 _inst_2) g)))\nCase conversion may be inaccurate. Consider using '#align units.exists0' Units.exists0'\u2093'. -/\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 : \u2200 g : G\u2080, g \u2260 0 \u2192 Prop} :\n    (\u2203 (g : G\u2080)(hg : g \u2260 0), p g hg) \u2194 \u2203 g : G\u2080\u02e3, 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {x : G\u2080}, Iff (Exists.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (fun (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) => Eq.{succ u1} G\u2080 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) u) x)) (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {x : G\u2080}, Iff (Exists.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (fun (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) => Eq.{succ u1} G\u2080 (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) u) x)) (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align units.exists_iff_ne_zero Units.exists_iff_ne_zero\u2093'. -/\n@[simp]\ntheorem exists_iff_ne_zero {x : G\u2080} : (\u2203 u : G\u2080\u02e3, \u2191u = x) \u2194 x \u2260 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (a : G\u2080), Or (Eq.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Exists.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (fun (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) => Eq.{succ u1} G\u2080 a ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (HasLiftT.mk.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (CoeTC\u2093.coe.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (coeBase.{succ u1, succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) G\u2080 (Units.hasCoe.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))) u)))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (a : G\u2080), Or (Eq.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Exists.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (fun (u : Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) => Eq.{succ u1} G\u2080 a (Units.val.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) u)))\nCase conversion may be inaccurate. Consider using '#align group_with_zero.eq_zero_or_unit GroupWithZero.eq_zero_or_unit\u2093'. -/\ntheorem GroupWithZero.eq_zero_or_unit (a : G\u2080) : a = 0 \u2228 \u2203 u : G\u2080\u02e3, a = u :=\n  by\n  by_cases h : a = 0\n  \u00b7 left\n    exact h\n  \u00b7 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\u2080] {a b c : G\u2080}\n\n/- warning: is_unit.mk0 -> IsUnit.mk0 is a dubious translation:\nlean 3 declaration is\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (x : G\u2080), (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) -> (IsUnit.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) x)\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (x : G\u2080), (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) -> (IsUnit.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) x)\nCase conversion may be inaccurate. Consider using '#align is_unit.mk0 IsUnit.mk0\u2093'. -/\ntheorem IsUnit.mk0 (x : G\u2080) (hx : x \u2260 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080}, Iff (IsUnit.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) a) (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080}, Iff (IsUnit.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) a) (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align is_unit_iff_ne_zero isUnit_iff_ne_zero\u2093'. -/\ntheorem isUnit_iff_ne_zero : IsUnit a \u2194 a \u2260 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080}, (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) -> (IsUnit.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) a)\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080}, (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) -> (IsUnit.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) a)\nCase conversion may be inaccurate. Consider using '#align ne.is_unit Ne.isUnit\u2093'. -/\nalias isUnit_iff_ne_zero \u2194 _ 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080], NoZeroDivisors.{u1} G\u2080 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))) (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080], NoZeroDivisors.{u1} G\u2080 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))) (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))\nCase conversion may be inaccurate. Consider using '#align group_with_zero.no_zero_divisors GroupWithZero.noZeroDivisors\u2093'. -/\n-- see Note [lower instance priority]\ninstance (priority := 10) GroupWithZero.noZeroDivisors : NoZeroDivisors G\u2080 :=\n  { (\u2039_\u203a : GroupWithZero G\u2080) 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\u2080 :=\n  {\n    (\u2039_\u203a :\n      GroupWithZero\n        G\u2080) with\n    mul_left_cancel_of_ne_zero := fun x y z hx h => by\n      rw [\u2190 inv_mul_cancel_left\u2080 hx y, h, inv_mul_cancel_left\u2080 hx z]\n    mul_right_cancel_of_ne_zero := fun x y z hy h => by\n      rw [\u2190 mul_inv_cancel_right\u2080 hy x, h, mul_inv_cancel_right\u2080 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (x : G\u2080) (y : G\u2080) (hxy : Ne.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) x y) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))), Eq.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mk0.{u1} G\u2080 _inst_2 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) x y) hxy) (HMul.hMul.{u1, u1, u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (instHMul.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (MulOneClass.toHasMul.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mulOneClass.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Units.mk0.{u1} G\u2080 _inst_2 x (And.left (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Ne.{succ u1} G\u2080 y (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Iff.mp (Ne.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) x y) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (And (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Ne.{succ u1} G\u2080 y (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))))) (mul_ne_zero_iff.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (GroupWithZero.noZeroDivisors.{u1} G\u2080 _inst_2) x y) hxy))) (Units.mk0.{u1} G\u2080 _inst_2 y (And.right (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Ne.{succ u1} G\u2080 y (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Iff.mp (Ne.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toHasMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) x y) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (And (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Ne.{succ u1} G\u2080 y (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))))) (mul_ne_zero_iff.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (GroupWithZero.noZeroDivisors.{u1} G\u2080 _inst_2) x y) hxy))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (x : G\u2080) (y : G\u2080) (hxy : Ne.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) x y) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))), Eq.{succ u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.mk0.{u1} G\u2080 _inst_2 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) x y) hxy) (HMul.hMul.{u1, u1, u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (instHMul.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (MulOneClass.toMul.{u1} (Units.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (Units.instMulOneClassUnits.{u1} G\u2080 (MonoidWithZero.toMonoid.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Units.mk0.{u1} G\u2080 _inst_2 x (And.left (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (Ne.{succ u1} G\u2080 y (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (Iff.mp (Ne.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) x y) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (And (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (Ne.{succ u1} G\u2080 y (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (mul_ne_zero_iff.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (GroupWithZero.noZeroDivisors.{u1} G\u2080 _inst_2) x y) hxy))) (Units.mk0.{u1} G\u2080 _inst_2 y (And.right (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (Ne.{succ u1} G\u2080 y (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (Iff.mp (Ne.{succ u1} G\u2080 (HMul.hMul.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHMul.{u1} G\u2080 (MulZeroClass.toMul.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) x y) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (And (Ne.{succ u1} G\u2080 x (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))) (Ne.{succ u1} G\u2080 y (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MulZeroClass.toZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (mul_ne_zero_iff.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))) (GroupWithZero.noZeroDivisors.{u1} G\u2080 _inst_2) x y) hxy))))\nCase conversion may be inaccurate. Consider using '#align units.mk0_mul Units.mk0_mul\u2093'. -/\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\u2080) (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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} {b : G\u2080}, (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) -> (Ne.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) -> (Ne.{succ u1} G\u2080 (HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toHasDiv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_2))) a b) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} {b : G\u2080}, (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) -> (Ne.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) -> (Ne.{succ u1} G\u2080 (HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (GroupWithZero.toDiv.{u1} G\u2080 _inst_2)) a b) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))\nCase conversion may be inaccurate. Consider using '#align div_ne_zero div_ne_zero\u2093'. -/\ntheorem div_ne_zero (ha : a \u2260 0) (hb : b \u2260 0) : a / b \u2260 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} {b : G\u2080}, Iff (Eq.{succ u1} G\u2080 (HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toHasDiv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_2))) a b) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Or (Eq.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Eq.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} {b : G\u2080}, Iff (Eq.{succ u1} G\u2080 (HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (GroupWithZero.toDiv.{u1} G\u2080 _inst_2)) a b) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Or (Eq.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Eq.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align div_eq_zero_iff div_eq_zero_iff\u2093'. -/\n@[simp]\ntheorem div_eq_zero_iff : a / b = 0 \u2194 a = 0 \u2228 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} {b : G\u2080}, Iff (Ne.{succ u1} G\u2080 (HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (DivInvMonoid.toHasDiv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_2))) a b) (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (And (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))) (Ne.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (OfNat.mk.{u1} G\u2080 0 (Zero.zero.{u1} G\u2080 (MulZeroClass.toHasZero.{u1} G\u2080 (MulZeroOneClass.toMulZeroClass.{u1} G\u2080 (MonoidWithZero.toMulZeroOneClass.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)))))))))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] {a : G\u2080} {b : G\u2080}, Iff (Ne.{succ u1} G\u2080 (HDiv.hDiv.{u1, u1, u1} G\u2080 G\u2080 G\u2080 (instHDiv.{u1} G\u2080 (GroupWithZero.toDiv.{u1} G\u2080 _inst_2)) a b) (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (And (Ne.{succ u1} G\u2080 a (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))) (Ne.{succ u1} G\u2080 b (OfNat.ofNat.{u1} G\u2080 0 (Zero.toOfNat0.{u1} G\u2080 (MonoidWithZero.toZero.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2))))))\nCase conversion may be inaccurate. Consider using '#align div_ne_zero_iff div_ne_zero_iff\u2093'. -/\ntheorem div_ne_zero_iff : a / b \u2260 0 \u2194 a \u2260 0 \u2227 b \u2260 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (a : G\u2080), Eq.{succ u1} G\u2080 (Ring.inverse.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2) a) (Inv.inv.{u1} G\u2080 (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_2)) a)\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080] (a : G\u2080), Eq.{succ u1} G\u2080 (Ring.inverse.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2) a) (Inv.inv.{u1} G\u2080 (GroupWithZero.toInv.{u1} G\u2080 _inst_2) a)\nCase conversion may be inaccurate. Consider using '#align ring.inverse_eq_inv Ring.inverse_eq_inv\u2093'. -/\ntheorem Ring.inverse_eq_inv (a : G\u2080) : Ring.inverse a = a\u207b\u00b9 :=\n  by\n  obtain rfl | ha := eq_or_ne a 0\n  \u00b7 simp\n  \u00b7 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\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080], Eq.{succ u1} (G\u2080 -> G\u2080) (Ring.inverse.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) (Inv.inv.{u1} G\u2080 (DivInvMonoid.toHasInv.{u1} G\u2080 (GroupWithZero.toDivInvMonoid.{u1} G\u2080 _inst_2)))\nbut is expected to have type\n  forall {G\u2080 : Type.{u1}} [_inst_2 : GroupWithZero.{u1} G\u2080], Eq.{succ u1} (G\u2080 -> G\u2080) (Ring.inverse.{u1} G\u2080 (GroupWithZero.toMonoidWithZero.{u1} G\u2080 _inst_2)) (Inv.inv.{u1} G\u2080 (GroupWithZero.toInv.{u1} G\u2080 _inst_2))\nCase conversion may be inaccurate. Consider using '#align ring.inverse_eq_inv' Ring.inverse_eq_inv'\u2093'. -/\n@[simp]\ntheorem Ring.inverse_eq_inv' : (Ring.inverse : G\u2080 \u2192 G\u2080) = 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\u2080] {a b c d : G\u2080}\n\n#print CommGroupWithZero.cancelCommMonoidWithZero /-\n-- see Note [lower instance priority]\ninstance (priority := 10) CommGroupWithZero.cancelCommMonoidWithZero :\n    CancelCommMonoidWithZero G\u2080 :=\n  { GroupWithZero.cancelMonoidWithZero, CommGroupWithZero.toCommMonoidWithZero G\u2080 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\u2080 :=\n  { \u2039CommGroupWithZero G\u2080\u203a, 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\u2093'. -/\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 : \u2200 a : M, IsUnit a \u2228 a = 0) : GroupWithZero M :=\n  { hM with\n    inv := fun a => if h0 : a = 0 then 0 else \u2191((h a).resolve_right h0).Unit\u207b\u00b9\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 \u2191((h a).resolve_right h0).Unit\u207b\u00b9) = 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\u2093'. -/\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 : \u2200 a : M, IsUnit a \u2228 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.\u03b9 R` is the canonical R-linear map `M \u2192 tensor_algebra R M`.\n3. Given a linear map `f : M \u2192 A` to an R-algebra `A`, `lift R f` is the lift of `f` to an\n  `R`-algebra morphism `tensor_algebra R M \u2192 A`.\n\n## Theorems\n\n1. `\u03b9_comp_lift` states that the composition `(lift R f) \u2218 (\u03b9 R)` is identical to `f`.\n2. `lift_unique` states that whenever an R-algebra morphism `g : tensor_algebra R M \u2192 A` is\n  given whose composition with `\u03b9 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_\u03b9` is a combination of `\u03b9_comp_lift` and `lift_unique`. It states that the lift\n  of the composition of an algebra morphism with `\u03b9` 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 `\u03b9` 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 \u2192 free_algebra R M \u2192 Prop\n    where\n| add : \u2200 {a b : M}, rel R M (free_algebra.\u03b9 R (a + b)) (free_algebra.\u03b9 R a + free_algebra.\u03b9 R b)\n| smul :\n    \u2200 {r : R} {a : M},\n      rel R M (free_algebra.\u03b9 R (r \u2022 a))\n        (coe_fn (algebra_map R (free_algebra R M)) r * free_algebra.\u03b9 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 \u2192\u2097[R] tensor_algebra R M`.\n-/\ndef \u03b9 (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.\u03b9 R m))\n    sorry sorry\n\ntheorem ring_quot_mk_alg_hom_free_algebra_\u03b9_eq_\u03b9 (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.\u03b9 R m) = coe_fn (\u03b9 R) m :=\n  rfl\n\n/--\nGiven a linear map `f : M \u2192 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 \u2192 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 \u2243 alg_hom R (tensor_algebra R M) A :=\n  equiv.mk\n    (\u21d1(ring_quot.lift_alg_hom R) \u2218\n      fun (f : linear_map R M A) => { val := coe_fn (free_algebra.lift R) \u21d1f, property := sorry })\n    (fun (F : alg_hom R (tensor_algebra R M) A) => linear_map.comp (alg_hom.to_linear_map F) (\u03b9 R))\n    sorry sorry\n\n@[simp] theorem \u03b9_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)) (\u03b9 R) = f :=\n  equiv.symm_apply_apply (lift R) f\n\n@[simp] theorem lift_\u03b9_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 (\u03b9 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) (\u03b9 R) = f \u2194 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_\u03b9 {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) (\u03b9 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) (\u03b9 R) =\n        linear_map.comp (alg_hom.to_linear_map g) (\u03b9 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 \u21d1algebra_map_inv \u21d1(algebra_map R (tensor_algebra R M)) :=\n  sorry\n\n/-- The left-inverse of `\u03b9`.\n\nAs an implementation detail, we implement this using `triv_sq_zero_ext` which has a suitable\nalgebra structure. -/\ndef \u03b9_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 \u03b9_left_inverse {R : Type u_1} [comm_semiring R] {M : Type u_2} [add_comm_monoid M]\n    [semimodule R M] : function.left_inverse \u21d1\u03b9_inv \u21d1(\u03b9 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.\u03b9 R x` to `tensor_algebra.\u03b9 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) \u21d1(tensor_algebra.\u03b9 R)\n\n@[simp] theorem to_tensor_\u03b9 {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 (\u03b9 R m) = coe_fn (tensor_algebra.\u03b9 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 \u2264 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 \u2264 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 (\u03b1 : Type) [pd : PlainDataType \u03b1] where\n  byteData : ByteArray\n  size : Nat \n  h_size : pd.bytes size \u2264 byteData.size\n\nvariable {\u03b1 : Type} [pd : PlainDataType \u03b1]\nvariable {\u03b9} [Enumtype \u03b9]\n\ndef DataArray.get (arr : DataArray \u03b1) (i : Fin arr.size) : \u03b1 := -- 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 := \u27e8i.1 / perByte.toNat, sorry_proof\u27e9\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 \u03b1) (i : Fin arr.size) (val : \u03b1) : DataArray \u03b1 := -- \u27e8pd.set a.byteData i sorry_proof val, a.size, sorry_proof\u27e9\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  := \u27e8i.1 / perByte.toNat, sorry_proof\u27e9\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    \u27e8arr.byteData.set ofByte newByte, arr.size, sorry_proof\u27e9\n  | .inr byteType => \n    \u27e8byteType.toByteArray arr.byteData (byteType.bytes * i.1) sorry_proof val, arr.size, sorry_proof\u27e9\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 \u03b1) : Squash Nat := Quot.mk _ (pd.capacity (arr.byteData.size))\n/-- Makes sure that `arr` fits at least `n` elements of `\u03b1` -/\ndef DataArray.reserve  (arr : DataArray \u03b1) (n : Nat) : DataArray \u03b1 := \n  if (pd.capacity (arr.byteData.size)) \u2264 n then\n    arr\n  else Id.run do\n    let newBytes := pd.bytes n\n    let mut arr' : DataArray \u03b1 := \u27e8ByteArray.mkEmpty newBytes, arr.size, sorry_proof\u27e9\n    -- copy over the old data\n    for i in [0:arr.size] do\n      arr' := \u27e8arr'.byteData.push 0, arr.size, sorry_proof\u27e9\n      arr' := arr'.set \u27e8i,sorry_proof\u27e9 (arr.get \u27e8i,sorry_proof\u27e9)\n    arr'\n\n\ndef DataArray.drop (arr : DataArray \u03b1) (k : Nat) : DataArray \u03b1 := \u27e8arr.byteData, arr.size - k, sorry_proof\u27e9\n\ndef DataArray.push (arr : DataArray \u03b1) (k : Nat := 1) (val : \u03b1) : DataArray \u03b1 := Id.run do\n  let oldSize := arr.size\n  let newSize := arr.size + k\n  let mut arr' := arr.reserve newSize\n  arr' := \u27e8arr'.byteData, newSize, sorry_proof\u27e9\n  for i in [oldSize:newSize] do\n    arr' := arr'.set \u27e8i,sorry_proof\u27e9 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 \u03b1) : (h : d.size = d'.size) \u2192 (\u2200 i, d.get i = d'.get (h \u25b8 i)) \u2192 d = d' := sorry_proof\n\ndef DataArray.intro (f : \u03b9 \u2192 \u03b1) : DataArray \u03b1 := Id.run do\n  let bytes := (pd.bytes (numOf \u03b9))\n  let mut d : ByteArray := ByteArray.mkEmpty bytes\n  for _ in [0:bytes] do\n    d := d.push 0\n  let mut d' : DataArray \u03b1 := \u27e8d, (numOf \u03b9), sorry_proof\u27e9\n  for (i,li) in Enumtype.fullRange \u03b9 do\n    d' := d'.set \u27e8li,sorry_proof\u27e9 (f i)\n  d'\n\nstructure DataArrayN (\u03b1 : Type) [pd : PlainDataType \u03b1] (n : Nat) where\n  data : DataArray \u03b1\n  h_size : n = data.size\n\ninstance (n) : GetElem (DataArrayN \u03b1 n) (Fin n) \u03b1 (\u03bb _ _ => True) where\n  getElem xs i _ := xs.1.get (xs.2 \u25b8 i)\n\ninstance : GetElem (DataArrayN \u03b1 (numOf \u03b9)) \u03b9 \u03b1 (\u03bb _ _ => True) where\n  getElem xs i _ := xs.1.get (xs.2 \u25b8 toFin i)\n\ninstance : SetElem (DataArrayN \u03b1 n) (Fin n) \u03b1 where\n  setElem xs i xi := \u27e8xs.1.set (xs.2 \u25b8 i) xi, sorry_proof\u27e9\n\ninstance : SetElem (DataArrayN \u03b1 (numOf \u03b9)) \u03b9 \u03b1 where\n  setElem xs i xi := \u27e8xs.1.set (xs.2 \u25b8 toFin i) xi, sorry_proof\u27e9\n\ninstance : IntroElem (DataArrayN \u03b1 n) (Fin n) \u03b1 where\n  introElem f := \u27e8DataArray.intro f, sorry_proof\u27e9\n\ninstance : IntroElem (DataArrayN \u03b1 (numOf \u03b9)) \u03b9 \u03b1 where\n  introElem f := \u27e8DataArray.intro f, sorry_proof\u27e9\n\ninstance : PushElem (DataArrayN \u03b1) \u03b1 where\n  pushElem k val xs := \u27e8xs.1.push k val, sorry_proof\u27e9\n\ninstance : DropElem (DataArrayN \u03b1) \u03b1 where\n  dropElem k xs := \u27e8xs.1.drop k, sorry_proof\u27e9\n\ninstance : ReserveElem (DataArrayN \u03b1) \u03b1 where\n  reserveElem k xs := \u27e8xs.1.reserve k, sorry_proof\u27e9\n\ninstance : ArrayType (DataArrayN \u03b1 n) (Fin n) \u03b1  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 \u03b1) \u03b1  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 \u03b1 (numOf \u03b9)) \u03b9 \u03b1  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 \u03b9 \u03b1 : Type} [Enumtype \u03b9] [Inhabited \u03b1] [pd : PlainDataType \u03b1] [ArrayType Cont \u03b9 \u03b1] : PlainDataType Cont where\n  btype := match pd.btype with\n    | .inl \u03b1BitType => \n      -- TODO: Fixme !!!!\n      .inr {\n        bytes := 2\n        h_size := sorry_proof\n\n        fromByteArray := \u03bb b i h => \n          introElem (\u03bb j => default)\n        toByteArray   := \u03bb b i h c => b\n        toByteArray_size := sorry_proof\n        fromByteArray_toByteArray := sorry_proof\n        fromByteArray_toByteArray_other := sorry_proof\n      }\n    | .inr \u03b1ByteType => \n      .inr {\n        bytes := (numOf \u03b9) * \u03b1ByteType.bytes\n        h_size := sorry_proof\n\n        fromByteArray := \u03bb b i h => \n          introElem (\u03bb j => \n            let idx := (i + (toFin j).1*\u03b1ByteType.bytes)\n            \u03b1ByteType.fromByteArray b idx sorry_proof)\n        toByteArray   := \u03bb b i h c => Id.run do\n          let mut b := b\n          for (j,lj) in Enumtype.fullRange \u03b9 do\n            let idx := (i + lj.1*\u03b1ByteType.bytes)\n            b := \u03b1ByteType.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 \u2264 b.size) : \u03b1\n  -- toByteArray   (b : ByteArray) (i : Nat) (h : i+bytes \u2264 b.size) (a : \u03b1) : ByteArray\n\n  -- -- `toByteArray` does not modify ByteArray size\n  -- toByteArray_size : \u2200 b i h a, (toByteArray b i h a).size = b.size\n  -- -- we can recover `a` from bytes\n  -- fromByteArray_toByteArray : \u2200 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 : \u2200 a b i j h, (j < i) \u2228 (i+size) \u2264 j \u2192 (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 \u03b1 (numOf \u03b9)) \u03b9 \u03b1 := PowType.mk \n\n-- ShortOptDataArray is prefered for PowType\n-- @[defaultInstance]\n-- instance : LinearPowType (DataArrayN \u03b1) \u03b1 := LinearPowType.mk\n\n\n\n-- #check \u211d^(Fin 3)\n\n-- #eval ((\u03bb [i] => i.1.toReal ) : \u211d^(Fin 100)) |>.map Math.sqrt\n\n-- #eval ((\u03bb [i] => i) : (Fin 3 \u00d7 Fin 5)^(Fin 3 \u00d7 Fin 5))\n-- #eval ((\u03bb [i] => i) : (Fin 3 \u00d7 Fin 5)^(Fin 3 \u00d7 Fin 5)).data\n-- #eval ((\u03bb [i] => i) : (Fin 3 \u00d7 Fin 5)^(Fin 3 \u00d7 Fin 5)).data.byteData\n\n-- #eval (1,2,3,4)\n\n-- #eval ((\u03bb [i] => i) : (Fin 3 \u00d7 Fin 2 \u00d7 Fin 2)^(Fin 3 \u00d7 Fin 2 \u00d7 Fin 2))\n-- #eval ((\u03bb [i] => i) : (Fin 3 \u00d7 Fin 2 \u00d7 Fin 2)^(Fin 3 \u00d7 Fin 2 \u00d7 Fin 2)).data\n-- #eval ((\u03bb [i] => i) : (Fin 3 \u00d7 Fin 2 \u00d7 Fin 2)^(Fin 3 \u00d7 Fin 2 \u00d7 Fin 2)).data.byteData\n\n-- #eval ((\u03bb [i] => (i.1.toFloat, i.1.toFloat.sqrt)) : (Float \u00d7 Float)^(Fin 17))\n\n-- variable (x : \u211d^{n,m})\n\n-- #check x\n-- #check \u03bb (i,j) => x[i,j]\n-- #check \u2211 i, x[i]\n\n-- #check Id.run do\n--   let mut a : \u211d^{10} := \u03bb [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 : (\u211d\u00d7\u211d)^{3,3} := \u03bb [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 : \u211d^(Fin 3 \u00d7 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 \u2192 Type v`, a type-family `M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type v` is a Dijkstra monad if it is equipped with the following two operations:\n\n```lean\ndpure {\u03b1 : Type u} (a : \u03b1) :  M (pure a)\ndbind {\u03b1 \u03b2 : Type u} {wa : W \u03b1} {wf : \u03b1 \u2192 W \u03b2} : M \u03b1 wa \u2192 ((a : \u03b1) \u2192 M \u03b2 (wf a)) \u2192 M \u03b2 (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 : \u03b1`, `wb : W \u03b2`, and `f : \u03b1 \u2192 M \u03b2 wb`, we have\n\n```lean\n#check dbind (dpure a) f -- M \u03b2 (pure a >>= \u03bb _ => wb)\n#check f a               -- M \u03b2 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 \u2192 Type v) [Monad W] (M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type w) where\n  dpure {\u03b1 : Type u} (a : \u03b1) : M \u03b1 (return a)\n  dbind {\u03b1 \u03b2 : Type u} {wa : W \u03b1} {wf : \u03b1 \u2192 W \u03b2} : M \u03b1 wa \u2192 ((a : \u03b1) \u2192 M \u03b2 (wf a)) \u2192 M \u03b2 (wa >>= wf)\n\nexport DijkstraMonad (dpure dbind)\n\n/-- The dependent monad laws for Dijkstra monads. -/\nclass DijkstraMonad.Lawful (W : Type u \u2192 Type v) [Monad W] (M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type w) [DijkstraMonad W M] where\n  --- right unitality\n  dbind_dpure {\u03b1 : Type u} {wa : W \u03b1} {x : M \u03b1 wa} : DEq (M \u03b1) (dbind x dpure) x\n  --- left unitality\n  dpure_dbind {\u03b1 \u03b2 : Type u} {wf : \u03b1 \u2192 W \u03b2} (a : \u03b1) (f : (a : \u03b1) \u2192 M \u03b2 (wf a)) : DEq (M \u03b2) (dbind (dpure a) f) (f a)\n  --- associativity\n  dbind_assoc {\u03b1 \u03b2 \u03b3 : Type u} {wa : W \u03b1} {wf : \u03b1 \u2192 W \u03b2} {wg : \u03b2 \u2192 W \u03b3} (x : M \u03b1 wa) (f : (a : \u03b1) \u2192 M \u03b2 (wf a)) (g : (b : \u03b2) \u2192 M \u03b3 (wg b)) : DEq (M \u03b3) (dbind (dbind x f) g) (dbind x (\u03bb a => dbind (f a) g))\n\nnamespace DijkstraMonad\n\n\n/-!\n\n## Basic lemmas\n\n-/\n\ntheorem dbind_congr {W : Type u \u2192 Type v} [Monad W] {M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type w} [DijkstraMonad W M] {\u03b1 \u03b2 : Type u} : \u2200 {wa\u2081 wa\u2082 : W \u03b1} {wf\u2081 wf\u2082 : \u03b1 \u2192 W \u03b2} {x\u2081 : M \u03b1 wa\u2081} {x\u2082 : M \u03b1 wa\u2082} {f\u2081 : (a : \u03b1) \u2192 M \u03b2 (wf\u2081 a)} {f\u2082 : (a : \u03b1) \u2192 M \u03b2 (wf\u2082 a)}, DEq (M \u03b1) x\u2081 x\u2082 \u2192 (\u2200 a, DEq (M \u03b2) (f\u2081 a) (f\u2082 a)) \u2192 DEq (M \u03b2) (dbind x\u2081 f\u2081) (dbind x\u2082 f\u2082)\n| _, _, wf\u2081, wf\u2082, _, _, f\u2081, f\u2082, DEq.refl _, hf => by\n  have : wf\u2081 = wf\u2082 := by\n    funext a\n    exact (hf a).eq_param\n  cases this\n  have : f\u2081 = f\u2082 := 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 \u2192 Type v} [Monad W] {M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type w} [DijkstraMonad W M] {\u03b1 \u03b2 : Type u} : \u2200 {wa : W \u03b1} {wf\u2081 wf\u2082 : \u03b1 \u2192 W \u03b2} {x : M \u03b1 wa} {f\u2081 : (a : \u03b1) \u2192 M \u03b2 (wf\u2081 a)} {f\u2082 : (a : \u03b1) \u2192 M \u03b2 (wf\u2082 a)}, (\u2200 a, DEq (M \u03b2) (f\u2081 a) (f\u2082 a)) \u2192 DEq (M \u03b2) (dbind x f\u2081) (dbind x f\u2082) :=\n  dbind_congr (DEq.refl _) \n\ntheorem dbind_congrLeft {W : Type u \u2192 Type v} [Monad W] {M : (\u03b1 : Type u) \u2192 W \u03b1 \u2192 Type w} [DijkstraMonad W M] {\u03b1 \u03b2 : Type u} : \u2200 {wa\u2081 wa\u2082 : W \u03b1} {wf : \u03b1 \u2192 W \u03b2} {x\u2081 : M \u03b1 wa\u2081} {x\u2082 : M \u03b1 wa\u2082} {f : (a : \u03b1) \u2192 M \u03b2 (wf a)}, DEq (M \u03b1) x\u2081 x\u2082 \u2192 DEq (M \u03b2) (dbind x\u2081 f) (dbind x\u2082 f) :=\n  \u03bb h => dbind_congr h (\u03bb _ => 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\u2081 W\u2082`, we define the \"push-forward\" `DijkstraMonad W\u2081 M \u2192 DijkstraMonad W\u2082 (Push F M)` and the \"pull-back\" `DijkstraMonad W\u2082 M \u2192 DijkstraMonad W\u2081 (Pull F M)`.\n\n-/\n\nsection underlying\n\nuniverse v\u2081 v\u2082\n\nvariable {W\u2081 : Type u \u2192 Type v\u2081} [Monad W\u2081] {W\u2082 : Type u \u2192 Type v\u2082} [Monad W\u2082]\n\n/-- Pushforward of Dijkstra monads along a monad homomorphism. -/\nstructure Push (F : MonadHom W\u2081 W\u2082) (M : (\u03b1 : Type u) \u2192 W\u2081 \u03b1 \u2192 Type w) (\u03b1 : Type u) (wa\u2082 : W\u2082 \u03b1) : Type (max v\u2081 w) where\n  base : W\u2081 \u03b1\n  body : M \u03b1 base\n  underly : F.app base = wa\u2082\n\nnamespace Push\n\nvariable {F : MonadHom W\u2081 W\u2082} {M : (\u03b1 : Type u) \u2192 W\u2081 \u03b1 \u2192 Type w}\n\nprotected\ntheorem eq {\u03b1 : Type u} {wa\u2082 : W\u2082 \u03b1} : \u2200 {x y : Push F M \u03b1 wa\u2082}, x.base = y.base \u2192 DEq (M \u03b1) x.body y.body \u2192 x = y\n| mk _ _ _, mk _ _ _, rfl, DEq.refl _ => rfl\n\nprotected\ntheorem deq {\u03b1 : Type u} {wa\u2082 wa\u2082': W\u2082 \u03b1} : \u2200 {x : Push F M \u03b1 wa\u2082} {y : Push F M \u03b1 wa\u2082'}, x.base = y.base \u2192 DEq (M \u03b1) x.body y.body \u2192 DEq (Push F M \u03b1) 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\u2081 M] : DijkstraMonad W\u2082 (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 >>= (\u03bb a => (f a).base)\n    body := dbind x.body (\u03bb 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\u2081] [DijkstraMonad W\u2081 M] [DijkstraMonad.Lawful W\u2081 M] : DijkstraMonad.Lawful W\u2082 (Push F M) where\n  dbind_dpure := by\n    intro \u03b1 wa\u2082 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 \u03b1 \u03b2 wb\u2082 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 \u03b1 \u03b2 \u03b3 wa\u2082 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\u2081 W\u2082) (M : (\u03b1 : Type u) \u2192 W\u2082 \u03b1 \u2192 Type w) (\u03b1 : Type u) (wa\u2081 : W\u2081 \u03b1) : Type w :=\n  M \u03b1 (F.app wa\u2081)\n\nnamespace Pull\n\nvariable {F : MonadHom W\u2081 W\u2082} {M : (\u03b1 : Type u) \u2192 W\u2082 \u03b1 \u2192 Type w}\n\ninstance instDijkstraMonadPull [DijkstraMonad W\u2082 M] : DijkstraMonad W\u2081 (Pull F M) where\n  dpure {\u03b1} a := (F.app_pure a).symm.rec (motive:=\u03bb wa _ => M \u03b1 wa) (dpure a)\n  dbind {_} {\u03b2} {wa} {wf} x f :=\n    (F.app_bind wa wf).symm.rec (motive:=\u03bb wb _=> M \u03b2 wb) (dbind (M:=M) (wf:=\u03bb a => F.app (wf a)) x f)\n\nprotected\ntheorem deq {\u03b1 : Type u} : \u2200 {w\u2081 w\u2081' : W\u2081 \u03b1} {x : Pull F M \u03b1 w\u2081} {y : Pull F M \u03b1 w\u2081'}, w\u2081 = w\u2081' \u2192 DEq (M \u03b1) x y \u2192 DEq (Pull F M \u03b1) x y\n| _, _, _, _, rfl, DEq.refl _ => DEq.refl _\n\ntheorem dpure_deq [DijkstraMonad W\u2082 M] {\u03b1 : Type u} (a : \u03b1) : DEq (\u03b2:=M \u03b1) (dpure (M:=Pull F M) a) (dpure (M:=M) a) :=\n  DEq.subst_deq\n\ntheorem dbind_deq [DijkstraMonad W\u2082 M] {\u03b1 \u03b2 : Type u} {wa : W\u2081 \u03b1} {wf : \u03b1 \u2192 W\u2081 \u03b2} (x : Pull F M \u03b1 wa) (f : (a : \u03b1) \u2192 Pull F M \u03b2 (wf a)) : DEq (\u03b2:=M \u03b2) (dbind (M:=Pull F M) x f) (dbind (M:=M) x f) :=\n  DEq.subst_deq\n\ninstance instDijkstraMonadLawfulPull [LawfulMonad W\u2081] [DijkstraMonad W\u2082 M] [DijkstraMonad.Lawful W\u2082 M] : DijkstraMonad.Lawful W\u2081 (Pull F M) where\n  dbind_dpure := by\n    intro \u03b1 wa\u2081 x\n    apply Pull.deq (bind_pure _)\n    apply DEq.trans (Pull.dbind_deq x dpure) _\n    apply DEq.trans (dbind_congrRight (W:=W\u2082) (M:=M) Pull.dpure_deq) _\n    exact Lawful.dbind_dpure (M:=M)\n  dpure_dbind := by\n    intro \u03b1 \u03b2 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\u2082) (M:=M) (Pull.dpure_deq a))\n    exact Lawful.dpure_dbind (M:=M) a f\n  dbind_assoc := by\n    intro \u03b1 \u03b2 \u03b3 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\u2082) (M:=M) (Pull.dbind_deq _ _))\n    apply DEq.trans (Lawful.dbind_assoc (M:=M) _ _ _)\n    apply DEq.trans _ (Pull.dbind_deq x (\u03bb 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 \u2192 Type v` and `n : Type u \u2192 Type w`, the associated submonad of `m \u00d7 n` can be seen as a Dijkstra monad.\nAlthough its underlying monad is a priori the product `m \u00d7 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 \u2192 Type v} [Monad m] {W : Type u \u2192 Type w} [Monad W] (r : MonadRel m W) (\u03b1 : Type u) (wa : W \u03b1) : Type v :=\n  {x : m \u03b1 // r.rel x wa}\n\nnamespace Graph\n\nvariable {m : Type u \u2192 Type v} [Monad m] {W : Type u \u2192 Type v} [Monad W] {r : MonadRel m W}\n\nprotected\ntheorem deq {\u03b1 : Type u} {wa\u2081 wa\u2082 : W \u03b1} : \u2200 (x\u2081 : Graph r \u03b1 wa\u2081) (x\u2082 : Graph r \u03b1 wa\u2082), wa\u2081 = wa\u2082 \u2192 x\u2081.val = x\u2082.val \u2192 DEq (Graph r \u03b1) x\u2081 x\u2082\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 >>= (\u03bb a => (f a).val)) $ r.bind x.property (\u03bb a => (f a).property)\n\ninstance instDijkstraMonadLawfulGraph [LawfulMonad m] [LawfulMonad W] : DijkstraMonad.Lawful W (Graph r) where\n  dbind_dpure := by\n    intro \u03b1 wa x\n    exact Graph.deq _ _ (bind_pure wa) (bind_pure x.val)\n  dpure_dbind := by\n    intro \u03b1 \u03b2 wf a f\n    exact Graph.deq _ _ (pure_bind a wf) (pure_bind a (\u03bb a => (f a).val))\n  dbind_assoc := by\n    intro \u03b1 \u03b2 \u03b3 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 \u2964 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\u2093'. -/\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 \u2964 Over B) : F \u22d9 forget B \u27f6 (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 \u2964 Over B} (c : Cone (F \u22d9 forget B)) : Cone F\n    where\n  pt := Over.mk (c.\u03c0.app (Classical.arbitrary J) \u226b (F.obj (Classical.arbitrary J)).Hom)\n  \u03c0 :=\n    {\n      app := fun j =>\n        Over.homMk (c.\u03c0.app j) (nat_trans_from_is_connected (c.\u03c0 \u226b 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\u2093'. -/\ntheorem raised_cone_lowers_to_original [IsConnected J] {B : C} {F : J \u2964 Over B}\n    (c : Cone (F \u22d9 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 \u2964 Over B} {c : Cone (F \u22d9 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 [\u2190 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 \u2964 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 \u2964 discrete PUnit) (G : C \u2964 discrete PUnit) : F \u2245 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 \u2964 discrete PUnit) (G : C \u2964 discrete PUnit) : F = G :=\n  ext (fun (_x : C) => of_as_true trivial) fun (_x _x_1 : C) (_x_2 : _x \u27f6 _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 \u2964 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 \u2964 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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  { assume h1 : G.colorable 2,\n    obtain \u27e8f, hf\u27e9 := h1,\n    have h2 : \u2200 v, f v = 0 \u2228 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 \u2228 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 \u2295 B) = V, from by {\n      ext,\n      split,\n      { assume h4 : (A \u2295 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 \u2264 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 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B),\n    obtain \u27e8A, B, h2, h3\u27e9 := h1,\n    have h4 : (A \u2295 B) = V, from h2,\n    let f : V \u2192 \u2115 := \u03bb v, if v \u2208 A then 0 else 1,\n    have h5 : \u2200 v, f v < 2, from assume v, by {\n      cases h4.symm \u25b8 v,\n      { exact nat.lt_succ_self 0, },\n      { exact nat.lt_succ_self 0, }\n    },\n    have h6 : \u2200 x y, (f x = f y) \u2192 (x, y) \u2208 G, from assume x y h7, by {\n      cases h4.symm \u25b8 x,\n      { cases h4.symm \u25b8 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 \u25b8 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 \u2200 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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  {\n    assume h : G.colorable 2,\n    have h1 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from\n      begin\n        use (\u03bb v, v.1),\n        use (\u03bb v, v.2),\n        use (equiv.sum_congr_right (\u03bb v, v.1) (\u03bb v, v.2)),\n        show G \u2264 cast (congr_arg _ (equiv.sum_congr_right (\u03bb v, v.1) (\u03bb v, v.2))) (complete_bipartite_graph (\u03bb v, v.1) (\u03bb v, v.2)), from\n          begin\n            have h2 : \u2200 (v w : V), (v.1 = w.1 \u2228 v.1 = w.2 \u2228 v.2 = w.1 \u2228 v.2 = w.2) \u2192 (v, w) \u2208 G \u2192 (v.1, w.1) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb v, v.2) \u2228 (v.1, w.2) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb v, v.2) \u2228 (v.2, w.1) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb v, v.2) \u2228 (v.2, w.2) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb v, v.2), from\n              begin\n                assume v w : V,\n                assume h3 : (v.1 = w.1 \u2228 v.1 = w.2 \u2228 v.2 = w.1 \u2228 v.2 = w.2),\n                assume h4 : (v, w) \u2208 G,\n                have h5 : (v.1, w.1) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb v, v.2) \u2228 (v.1, w.2) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb v, v.2) \u2228 (v.2, w.1) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb v, v.2) \u2228 (v.2, w.2) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb 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) \u2208 complete_bipartite_graph (\u03bb v, v.1) (\u03bb 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) \u2208 G, from\n                          begin\n                            have h9 : (v, w) \u2208 G, from h4,\n                            have h10 : (v.1, w.1) \u2208 G, from\n                              begin\n                                have h11 : (v.1, w.1) \u2208 G, from\n                                  begin\n                                    have h12 : (v.1, w.1) \u2208 G, from\n                                      begin\n                                        have h13 : (v.1, w.1) \u2208 G, from\n                                          begin\n                                            have h14 : (v.1, w.1) \u2208 G, from\n                                              begin\n                                                have h15 : (v.1, w.1) \u2208 G, from\n                                                  begin\n                                                    have h16 : (v.1, w.1) \u2208 G, from\n                                                      begin\n                                                        have h17 : (v.1, w.1) \u2208 G, from\n                                                          begin\n                                                            have h18 : (v.1, w.1) \u2208 G, from\n                                                              begin\n                                                                have h19 : (v.1, w.1) \u2208 G, from\n                                                                  begin\n                                                                    have h20 : (v.1, w.1) \u2208 G, from\n                                                                      begin\n                                                                        have h21 : (v.1, w.1) \u2208 G, from\n                                                                          begin\n                                                                            have h22 : (v.1, w.1) \u2208 G, from\n                                                                              begin\n                                                                                have h23 : (v.1, w.1) \u2208 G, from\n                                                                                  begin\n                                                                                    have h24 : (v.1, w.1) \u2208 G, from\n                                                                                      begin\n                                                                                        have h25 : (v.1, w.1) \u2208 G, from\n                                                                                          begin\n                                                                                            have h26 : (v.1, w.1) \u2208 G, from\n                                                                                              begin\n                                                                                                have h27 : (v.1, w.1) \u2208 G, from\n                                                                                                  begin\n                                                                                                    have h28 : (v.1, w.1) \u2208 G, from\n                                                                                                      begin\n                                                                                                        have h29 : (v.1, w.1) \u2208 G, from\n                                                                                                          begin\n                                                                                                            have h30 : (v.1, w.1) \u2208 G, from\n                                                                                                              begin\n                                                                                                                have h31 : (v.1, w.1) \u2208 G, from\n                                                                                                                  begin\n                                                                                                                    have h32 : (v.1, w.1) \u2208 G, from\n                                                                                                                      begin\n                                                                                                                        have h33 : (v.1, w.1) \u2208 G, from\n                                                                                                                          begin\n                                                                                                                            have h34 : (v.1, w.1) \u2208 G, from\n                                                                                                                              begin\n                                                                                                                                have h35 : (v.1, w.1) \u2208 G, from\n                                                                                                                                  begin\n                                                                                                                                    have h36 : (v.1, w.1) \u2208 G, from\n                                                                                                                                      begin\n                                                                                                                                        have h37 : (v.1, w.1) \u2208 G, from\n                                                                                                                                          begin\n                                                                                                                                            have h38 : (v.1, w.1) \u2208 G, from\n                                                                                                                                              begin\n                                                                                                                                                have h39 : (v.1, w.1) \u2208 G, from\n                                                                                                                                                  begin\n                                                                                                                                                    have h40 : (v.1, w.1) \u2208 G, from\n                                                                                                                                                      begin\n                                                                                                                                                        have h41 : (v.1, w.1) \u2208 G, from\n                                                                                                                                                          begin\n                                                                                                                                                            have h42 : (v.1, w.1) \u2208 G, from\n                                                                                                                                                              begin\n                                                                                                                                                                have h43 : (v.1, w.1) \u2208 G, from\n                                                                                                                                                                  begin\n                                                                                                                                                                    have h44 : (v.1, w.1) \u2208 G, from\n                                                                                                                                                                      begin\n                                                                                                                                                                        have h45 : (v.1, w.1) \u2208 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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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 \u2192 fin 2) (hf : \u2200 (v w : V), v \u2260 w \u2192 f v \u2260 f w) (hf' : \u2200 (v : V), f v \u2260 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 : \u2200 (v w : V), v \u2260 w \u2192 v \u2208 A \u2192 w \u2208 A \u2192 false, from by {\n      assume (v w : V) (hvw : v \u2260 w) (hv : v \u2208 A) (hw : w \u2208 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 : \u2200 (v w : V), v \u2260 w \u2192 v \u2208 B \u2192 w \u2208 B \u2192 false, from by {\n      assume (v w : V) (hvw : v \u2260 w) (hv : v \u2208 B) (hw : w \u2208 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 : \u2200 (v w : V), v \u2260 w \u2192 (v \u2208 A \u2227 w \u2208 B) \u2228 (v \u2208 B \u2227 w \u2208 A), from by {\n      assume (v w : V) (hvw : v \u2260 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 \u2260 f w, from by {apply hf v w hvw},\n      have h2 : f v = 0 \u2228 f v = 1, from by {rw hv0, rw hv1, left, refl},\n      have h3 : f w = 0 \u2228 f w = 1, from by {rw hw0, rw hw1, left, refl},\n      have h4 : f v = 0 \u2227 f w = 1 \u2228 f v = 1 \u2227 f w = 0, from by {\n        rw h2, rw h3,\n        left,\n        exact \u27e8hv0, hw1\u27e9,\n        right,\n        exact \u27e8hv1, hw0\u27e9,\n      },\n      have h5 : f v = 0 \u2192 f w = 1, from by {rw h4, left, exact and.left},\n      have h6 : f v = 1 \u2192 f w = 0, from by {rw h4, right, exact and.left},\n      cases h4 with h4 h4,\n      {\n        left,\n        exact \u27e8by {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}\u27e9,\n      },\n      {\n        right,\n        exact \u27e8by {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}\u27e9,\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' : \u2200 (v w : V), v \u2260 w \u2192 (v \u2208 A \u2227 w \u2208 B) \u2228 (v \u2208 B \u2227 w \u2208 A), from by {\n      assume (v w : V) (hvw : v \u2260 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 \u2260 f w, from by {apply hf v w hvw},\n      have h2 : f v = 0 \u2228 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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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 : \u2200 u v : V, u \u2208 A \u2192 v \u2208 A \u2192 \u00ac(u,v) \u2208 G.E, from by {\n      assume (u v : V) (hu : u \u2208 A) (hv : v \u2208 A),\n      assume (huv : (u,v) \u2208 G.E),\n      have h2 : G.color u = G.color v, from by {\n        apply hcolorable,\n        exact \u27e8huv,hu,hv\u27e9,\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 : \u2200 u v : V, u \u2208 B \u2192 v \u2208 B \u2192 \u00ac(u,v) \u2208 G.E, from by {\n      assume (u v : V) (hu : u \u2208 B) (hv : v \u2208 B),\n      assume (huv : (u,v) \u2208 G.E),\n      have h2 : G.color u = G.color v, from by {\n        apply hcolorable,\n        exact \u27e8huv,hu,hv\u27e9,\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 : \u2200 u v : V, (u,v) \u2208 G.E \u2192 (u \u2208 A \u2227 v \u2208 B) \u2228 (u \u2208 B \u2227 v \u2208 A), from by {\n      assume (u v : V) (huv : (u,v) \u2208 G.E),\n      have h4 : G.color u = G.color v, from by {\n        apply hcolorable,\n        exact \u27e8huv,_,_\u27e9,\n      },\n      have h5 : G.color u = 0 \u2228 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 \u2208 A, from by {\n          apply set.mem_def.mpr h5,\n        },\n        have h8 : v \u2208 A, from by {\n          apply set.mem_def.mpr h6,\n        },\n        have h9 : \u00ac(u,v) \u2208 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 \u2208 B, from by {\n          apply set.mem_def.mpr h5,\n        },\n        have h8 : v \u2208 B, from by {\n          apply set.mem_def.mpr h6,\n        },\n        have h9 : \u00ac(u,v) \u2208 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 : \u2200 u v : V, (u,v) \u2208 G.E \u2192 (u \u2208 A \u2227 v \u2208 B), from by {\n      assume (u v : V) (huv : (u,v) \u2208 G.E),\n      have h5 : (u \u2208 A \u2227 v \u2208 B) \u2228 (u \u2208 B \u2227 v \u2208 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 \u2208 B, from by {\n          apply and.elim_left h5,\n        },\n        have h7 : v \u2208 A, from by {\n          apply and.elim_right h5,\n        },\n        have h8 : \u00ac(u,v) \u2208 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 : \u2200 u v : V, (u,v) \u2208 G.E \u2192 (u \u2208 B \u2227 v \u2208 A), from by {\n      assume (u v : V) (huv : (u,v) \u2208 G.E),\n      have h6 : (u \u2208 A \u2227 v \u2208 B), from by {\n        apply h4,\n        exact huv,\n      },\n      have h7 : u \u2208 A, from by {\n        apply and.elim_left h6,\n      },\n      have h8 : v \u2208 B, from by {\n        apply and.elim_right h6,\n      },\n      have h9 : \u00ac(u,v) \u2208 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 : \u2200 u v : V, (u,v) \u2208 G.E \u2194 (u \u2208 A \u2227 v \u2208 B), from by {\n      assume (u v : V),\n      split,\n      {\n        assume huv : (u,v) \u2208 G.E,\n        apply h4,\n        exact huv,\n      },\n      {\n        assume huv : (u \u2208 A \u2227 v \u2208 B),\n        have h7 : u \u2208 A, from by {\n          apply and.elim_left huv,\n        },\n        have h8 : v \u2208 B, from by {\n          apply and.elim_right huv,\n        },\n        have h9 : \u00ac(u,v) \u2208 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 : \u2200 u v : V, (u,v) \u2208 G.E \u2194 (u \u2208 B \u2227 v \u2208 A), from by {\n      assume (u v : V),\n      split,\n      {\n        assume huv : (u,v) \u2208 G.E,\n        apply h5,\n        exact huv,\n      },\n      {\n        assume huv : (u \u2208 B \u2227 v \u2208 A),\n        have h8 : u \u2208 B, from by {\n          apply and.elim_left huv,\n        },\n        have h9 : v \u2208 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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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) \u2192 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)), from\n    assume (h : G.colorable 2),\n    have h2 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n      have h3 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n        have h4 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n          have h5 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n            have h6 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n              have h7 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                have h8 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                  have h9 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                    have h10 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                      have h11 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                        have h12 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                          have h13 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                            have h14 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                              have h15 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                have h16 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                  have h17 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                    have h18 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                      have h19 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                        have h20 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                          have h21 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                            have h22 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                              have h23 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                have h24 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                  have h25 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                    have h26 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                      have h27 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                        have h28 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                          have h29 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                            have h30 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                              have h31 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                                have h32 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                                  have h33 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                                    have h34 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n                                                                      have h35 : \u2203 (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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B)) :=\nbegin\n  split,\n  {\n    assume h1 : G.colorable 2,\n    have h2 : \u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 cast (congr_arg _ h) (complete_bipartite_graph A B), from by {\n      obtain \u27e8f,hf\u27e9 : \u2203 f : V \u2192 fin 2, G.is_coloring f, from h1,\n      let f' : V \u2192 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 \u27e8V,\u03bb v, \u27e8f' v,by {rw fin.val_eq_coe,rw fin.coe_eq_zero,exact dec_trivial,}\u27e9,\u03bb v, \u27e8f' v,by {rw fin.val_eq_coe,rw fin.coe_eq_one,exact dec_trivial,}\u27e9,\u03bb v, rfl,\u03bb v, rfl\u27e9,\n      },\n      have hB : fintype B, from by {\n        apply fintype.of_equiv,\n        exact \u27e8V,\u03bb v, \u27e8f' v,by {rw fin.val_eq_coe,rw fin.coe_eq_zero,exact dec_trivial,}\u27e9,\u03bb v, \u27e8f' v,by {rw fin.val_eq_coe,rw fin.coe_eq_one,exact dec_trivial,}\u27e9,\u03bb v, rfl,\u03bb v, rfl\u27e9,\n      },\n      have h3 : \u2200 (x : V), (f' x = 0) \u2228 (f' x = 1), from assume x : V, \n        begin\n          have h4 : (f' x = 0) \u2228 (f' x = 1), from by apply fin.eq_zero_or_eq_one,\n          exact h4,\n        end,\n      have h4 : \u2200 (x : V), (x \u2208 A) \u2228 (x \u2208 B), from assume x : V, \n        begin\n          have h5 : (f' x = 0) \u2228 (f' x = 1), from h3 x,\n          have h6 : (x \u2208 A) \u2228 (x \u2208 B), from by {cases h5,left,exact h5,right,exact h5},\n          exact h6,\n        end,\n      have h5 : \u2200 (x : V), (x \u2208 A) \u2192 (x \u2208 B) \u2192 false, from assume x : V, assume h6 : x \u2208 A, assume h7 : x \u2208 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 : \u2200 (x : V), (x \u2208 A) \u2192 (x \u2208 B) \u2192 false, from assume x : V, assume h6 : x \u2208 A, assume h7 : x \u2208 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 : \u2200 (x : V), (x \u2208 B) \u2192 (x \u2208 A) \u2192 false, from assume x : V, assume h6 : x \u2208 B, assume h7 : x \u2208 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 : \u2200 (x y : V), (x \u2208 A) \u2192 (y \u2208 B) \u2192 (x \u2260 y), from assume x y : V, assume h9 : x \u2208 A, assume h10 : y \u2208 B,\n        begin\n          have h11 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h5 x y,\n          have h12 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h6 x y,\n          have h13 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h7 x y,\n          have h14 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h8 x y,\n          have h15 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h9 x y,\n          have h16 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h10 x y,\n          have h17 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h11 x y,\n          have h18 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h12 x y,\n          have h19 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h13 x y,\n          have h20 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h14 x y,\n          have h21 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h15 x y,\n          have h22 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h16 x y,\n          have h23 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h17 x y,\n          have h24 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h18 x y,\n          have h25 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h19 x y,\n          have h26 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h20 x y,\n          have h27 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h21 x y,\n          have h28 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h22 x y,\n          have h29 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h23 x y,\n          have h30 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h24 x y,\n          have h31 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h25 x y,\n          have h32 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h26 x y,\n          have h33 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h27 x y,\n          have h34 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h28 x y,\n          have h35 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h29 x y,\n          have h36 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h30 x y,\n          have h37 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h31 x y,\n          have h38 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h32 x y,\n          have h39 : (x \u2208 A) \u2192 (y \u2208 B) \u2192 false, from h33 x y,\n          have h40 : (x \u2208 A) \u2192 (y \u2208\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 {\u03b1 : Type*} (S : set \u03b1) : \u2200 A B \u2208 \ud835\udcab S, (A \u2229 B) \u2208 \ud835\udcab S :=\nbegin\n  -- $A$ and $B$ are sets. $A$ and $B$ belong to power set of $S$\n  assume (A : set \u03b1) (hA : A \u2208 \ud835\udcab S) (B : set \u03b1) (hB : B \u2208 \ud835\udcab S),\n  -- Then $A \u2286 S$ and $B \u2286 S$, by power set definition\n  have h1 : (A \u2286 S) \u2227 (B \u2286 S), from by {split,apply set.subset_of_mem_powerset,exact hA,apply set.subset_of_mem_powerset,exact hB},\n  -- Then $(A \u2229 B) \u2286 A$, by intersection of set is a subset\n  have h2 : (A \u2229 B) \u2286 A, from by apply set.inter_subset_left,\n  -- Then $(A \u2229 B) \u2286 S$, by subset relation is transitive \n  have h3 : (A \u2229 B) \u2286 S, from by {apply set.subset.trans h2 h1.left},\n  -- Hence $(A \u2229 B) \u2208  \ud835\udcab S$, by power set definition\n  show (A \u2229 B) \u2208  \ud835\udcab 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 : \u211d) : (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 \u2190 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] : \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a :=\nbegin\n  -- Group has Latin Square Property\n  have h1 : \u2200 a b : G, \u2203! x : G, a * x = b, from by {\n    assume a b : G, use a\u207b\u00b9 * b, obviously, },\n  have h2 : \u2200 a b : G, \u2203! y : G, y * a = b, from by {\n    assume a b : G, use b * a\u207b\u00b9, obviously, }, \n\n  -- Setting $b = a$, this becomes:\n  have h3 : \u2200 a : G, \u2203! x : G, a * x = a, from \n    assume a : G, h1 a a,\n  have h4 : \u2200 a : G, \u2203! 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 : \u2200 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 : \u2200 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 \u2203! e : G, \u2200 a : G, e * a = a \u2227 a * e = a, from by {\n    use (1 : G),\n    have h7 : \u2200 e : G, (\u2200 a : G, e * a = a \u2227 a * e = a) \u2192 e = 1, from by {\n      assume (e : G) (hident : \u2200 a : G, e * a = a \u2227 a * e = a),\n      have h8 : \u2200 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 : \u2200 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 \u27e8by obviously, h7\u27e9,\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) \u2194 (\u2203 (A B : Type*) (h : (A \u2295 B) = V), G \u2264 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": "import data.real.basic\nimport data.set.lattice\nimport topology.basic\nimport game.topology.union_open_sets\n\nopen set\n\n--begin hide\nnamespace xena\n-- end hide\n\ndef is_closed (X : set \u211d) := is_open {x : \u211d | x \u2209 X }\n\n-- begin hide\n-- Checking mathlib definitions\nvariable \u03b2 : Type*  -- finite unions only\nvariable [fintype \u03b2]\n-- end hide\n\n/- Lemma\nFinite union of closed sets is closed -- WIP, to do.\n-/\nlemma is_closed_fin_union_of_closed (X : \u03b2 \u2192 set \u211d ) ( hj : \u2200 j, is_closed (X j) )\n    : is_closed (Union X) :=\nbegin\n    sorry,\nend\n\n\nend xena -- hide", "meta": {"author": "ImperialCollegeLondon", "repo": "real-number-game", "sha": "f9dcb7d9255a79b57e62038228a23346c2dc301b", "save_path": "github-repos/lean/ImperialCollegeLondon-real-number-game", "path": "github-repos/lean/ImperialCollegeLondon-real-number-game/real-number-game-f9dcb7d9255a79b57e62038228a23346c2dc301b/src/game/topology/union_closed_sets.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.888758793492457, "lm_q2_score": 0.5117166047041654, "lm_q1q2_score": 0.45479263220693056}}
{"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 \u03b1} (h : as.push a = bs.push b) : as = bs \u2227 a = b := by\n  simp [push] at h\n  have \u27e8h\u2081, h\u2082\u27e9 := List.of_concat_eq_concat h\n  cases as; cases bs\n  simp_all\n\nprivate theorem List.size_toArrayAux (as : List \u03b1) (bs : Array \u03b1) : (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 \u03b1} {cs ds : Array \u03b1} (h : as.toArrayAux cs = bs.toArrayAux ds) (hlen : cs.size = ds.size) : as = bs \u2227 cs = ds := by\n  match as, bs with\n  | [], []    => simp [toArrayAux] at h; simp [h]\n  | a::as, [] => simp [toArrayAux] at h; rw [\u2190 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 \u27e8ih\u2081, ih\u2082\u27e9 := of_toArrayAux_eq_toArrayAux h this\n    simp [ih\u2081]\n    have := Array.of_push_eq_push ih\u2082\n    simp [this]\n\n@[simp] theorem List.toArray_eq_toArray_eq (as bs : List \u03b1) : (as.toArray = bs.toArray) = (as = bs) := by\n  apply propext; apply Iff.intro\n  \u00b7 intro h; simp [toArray] at h; have := of_toArrayAux_eq_toArrayAux h rfl; exact this.1\n  \u00b7 intro h; rw [h]\n\ndef Array.mapM' [Monad m] (f : \u03b1 \u2192 m \u03b2) (as : Array \u03b1) : m { bs : Array \u03b2 // bs.size = as.size } :=\n  go 0 \u27e8mkEmpty as.size, rfl\u27e9 (by simp_arith)\nwhere\n  go (i : Nat) (acc : { bs : Array \u03b2 // bs.size = i }) (hle : i \u2264 as.size) : m { bs : Array \u03b2 // bs.size = as.size } := do\n    if h : i = as.size then\n      return h \u25b8 acc\n    else\n      have hlt : i < as.size := Nat.lt_of_le_of_ne hle h\n      let b \u2190 f as[i]\n      go (i+1) \u27e8acc.val.push b, by simp [acc.property]\u27e9 hlt\ntermination_by go i _ _ => as.size - i\n\n@[inline] private unsafe def mapMonoMImp [Monad m] (as : Array \u03b1) (f : \u03b1 \u2192 m \u03b1) : m (Array \u03b1) :=\n  go 0 as\nwhere\n  @[specialize] go (i : Nat) (as : Array \u03b1) : m (Array \u03b1) := do\n    if h : i < as.size then\n      let a := as[i]\n      let b \u2190 f a\n      if ptrEq a b then\n        go (i+1) as\n      else\n        go (i+1) (as.set \u27e8i, h\u27e9 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 \u03b1) (f : \u03b1 \u2192 m \u03b1) : m (Array \u03b1) :=\n  as.mapM f\n\n@[inline] def Array.mapMono (as : Array \u03b1) (f : \u03b1 \u2192 \u03b1) : Array \u03b1 :=\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 : \u2200 {Y Z : C} {f : Y \u27f6 X} (g : Z \u27f6 Y), over.mk f \u2208 arrows \u2192 over.mk (g \u226b f) \u2208 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 \u27f6 X} (Hf : over.mk f \u2208 S.arrows) (g : Z \u27f6 Y) :\n  over.mk (g \u226b f) \u2208 S.arrows :=\nS.subs g Hf\n\nlemma arrow_ext : \u03a0 {R S : sieve X}, R.arrows = S.arrows \u2192 R = S\n| \u27e8Ra, _\u27e9 \u27e8Sa, _\u27e9 rfl := rfl\n\n@[ext] lemma ext_iff {R S : sieve X} : (\u2200 {Y} (f : Y \u27f6 X), over.mk f \u2208 R.arrows \u2194 over.mk f \u2208 S.arrows) \u2192 R = S :=\nbegin\n  intros a,\n  apply arrow_ext,\n  ext \u27e8_, _, _\u27e9,\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 (\ud835\udcae : set (sieve X)) : (sieve X) :=\n{ arrows := \u22c3 (S : {i // i \u2208 \ud835\udcae}), S.1.arrows,\n  subs :=\n  begin\n    rintros Y Z f g \u27e8R, \u27e8\u27e8S, hS\u27e9, rfl\u27e9, w\u27e9,\n    refine \u27e8_, \u27e8\u27e8S, hS\u27e9, rfl\u27e9, _\u27e9,\n    simp [w],\n  end }\n\n/-- The infimum of a collection of sieves: the intersection of them all. -/\nprotected def Inf (\ud835\udcae : set (sieve X)) : (sieve X) :=\n{ arrows := \u22c2 (S : {S // S \u2208 \ud835\udcae}), S.1.arrows,\n  subs :=\n  begin\n    rintros Y Z f g R _ \u27e8\u27e8S, hS\u27e9, rfl\u27e9,\n    simp [R _ \u27e8\u27e8S, hS\u27e9, rfl\u27e9],\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 \u222a 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 \u2229 R.arrows,\n  subs :=\n  begin\n    rintros Y Z f g \u27e8h\u2081, h\u2082\u27e9,\n    simp [h\u2081, h\u2082],\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           := \u03bb S R, \u2200 Y (f : Y \u27f6 X), over.mk f \u2208 S.arrows \u2192 over.mk f \u2208 R.arrows,\n  le_refl      := \u03bb S f q, id,\n  le_trans     := \u03bb S\u2081 S\u2082 S\u2083 S\u2081\u2082 S\u2082\u2083 Y f h, S\u2082\u2083 _ _ (S\u2081\u2082 _ _ h),\n  le_antisymm  := begin intros S R p q, ext, refine \u27e8p _ _, q _ _\u27e9 end,\n  top          := { arrows := set.univ, subs := \u03bb Y Z f g h, \u27e8\u27e9 },\n  bot          := { arrows := \u2205, subs := \u03bb 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       := \u03bb _ S hS _ _ h, \u27e8_, \u27e8\u27e8S, hS\u27e9, rfl\u27e9, h\u27e9,\n  Sup_le       := begin rintros \ud835\udcae S hS Y f \u27e8_, \u27e8\u27e8T, hT\u27e9, rfl\u27e9, q\u27e9, apply hS _ hT _ _ q end,\n  Inf_le       := \u03bb _ S hS _ _ h, h _ \u27e8\u27e8_, hS\u27e9, rfl\u27e9,\n  le_Inf       := begin rintros \ud835\udcae S hS Y f h q \u27e8\u27e8T, hT\u27e9, rfl\u27e9, apply hS _ hT _ _ h end,\n  le_sup_left  := \u03bb _ _ _ _, or.inl,\n  le_sup_right := \u03bb _ _ _ _, or.inr,\n  sup_le       := begin rintros _ _ _ a b _ _ (q | q), apply a _ _ q, apply b _ _ q end,\n  inf_le_left  := \u03bb _ _ _ _, and.left,\n  inf_le_right := \u03bb _ _ _ _, and.right,\n  le_inf       := begin intros _ _ _ p q _ _ z, exact \u27e8p _ _ z, q _ _ z\u27e9,  end,\n  le_top       := \u03bb _ _ _ _, trivial,\n  bot_le       := by { rintros _ _ _ \u27e8\u27e9 } }\n\n@[simp]\nlemma mem_inter {R S : sieve X} {Y} (f : Y \u27f6 X) :\n  over.mk f \u2208 (R \u2293 S).arrows \u2194 over.mk f \u2208 R.arrows \u2227 over.mk f \u2208 S.arrows :=\niff.rfl\n\n@[simp]\nlemma mem_union {R S : sieve X} {Y} (f : Y \u27f6 X) :\n  over.mk f \u2208 (R \u2294 S).arrows \u2194 over.mk f \u2208 R.arrows \u2228 over.mk f \u2208 S.arrows :=\niff.rfl\n\n@[simp]\nlemma mem_top (f : Y \u27f6 X) : over.mk f \u2208 (\u22a4 : sieve X).arrows := trivial\n\ninstance : preorder      (sieve X) := by apply_instance\ninstance : partial_order (sieve X) := by apply_instance\n\ninductive generate_sets (\ud835\udca2 : set (over X)) : over X \u2192 Prop\n| basic : \u03a0 {f : over X}, f \u2208 \ud835\udca2 \u2192 generate_sets f\n| subs  : \u03a0 {Y Z} {f : Y \u27f6 X} (g : Z \u27f6 Y), generate_sets (over.mk f) \u2192 generate_sets (over.mk (g \u226b f))\n\n/-- Generate the smallest sieve containing the given set of arrows. -/\ndef generate (\ud835\udca2 : set (over X)) : sieve X :=\n{ arrows := generate_sets \ud835\udca2,\n  subs   := \u03bb Y Z f g t, generate_sets.subs _ t }\n\nopen order lattice\n\nlemma sets_iff_generate {\ud835\udca2 : set (over X)} : generate \ud835\udca2 \u2264 S \u2194 \ud835\udca2 \u2286 S.arrows :=\niff.intro\n  (\u03bb 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 \u2190 this at *,\n      apply H,\n      apply generate_sets.basic hg,\n    end )\n  (\u03bb 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        := \u03bb s f, sets_iff_generate,\n    choice    := \u03bb \ud835\udca2 f, generate \ud835\udca2,\n    choice_eq := \u03bb \ud835\udca2 h, rfl,\n    le_l_u    := \u03bb _ _ _, generate_sets.basic }\n\n/-- Given a morphism `h : Y \u27f6 X`, send a sieve S on X to a sieve on Y\n    as the inverse image of S with `_ \u226b h`.\n    That is, `sieve.pullback S h := (\u226b h) '\u207b\u00b9 S`. -/\ndef pullback (S : sieve X) (h : Y \u27f6 X) : sieve Y :=\n{ arrows := {sl | over.mk (sl.hom \u226b h) \u2208 S.arrows },\n  subs := \u03bb f hf Z g k, by { dsimp at k, simp [k] } }\n\n@[simp] lemma mem_pullback (h : Y \u27f6 X) {f : Z \u27f6 Y} :\n  over.mk f \u2208 (pullback S h).arrows \u2194 over.mk (f \u226b h) \u2208 S.arrows := iff.rfl\n\n/--\nPush a sieve `R` on `Y` forward along an arrow `f : Y \u27f6 X`: `gf : Z \u27f6 X`\nis in the sieve if `gf` factors through some `g : Z \u27f6 Y` which is in `R`.\n-/\ndef comp (R : sieve Y) (f : Y \u27f6 X) : sieve X :=\n{ arrows := \u03bb gf, \u2203 (g : gf.left \u27f6 Y), over.mk g \u2208 R.arrows \u2227 g \u226b f = gf.hom,\n  subs :=\n  begin\n    rintros Z\u2081 Z\u2082 g h \u27e8j, k, z\u27e9,\n    refine \u27e8h \u226b j, _, _\u27e9,\n    simp [k],\n    simp [z],\n  end }\n\n-- def comps (R : \u03a0 (f : over X), sieve f.left) (S : sieve X) : sieve X :=\n--   \u2a06 (f \u2208 S.arrows), comp (R f) f.hom\n\n/-- Pullback is monotonic -/\nlemma pullback_le_map {S R : sieve X} (Hss : S \u2264 R) (f : Y \u27f6 X) : pullback S f \u2264 pullback R f :=\nbegin rintros Z H, apply Hss end\n\nlemma pullback_top {f : Y \u27f6 X} : pullback \u22a4 f = \u22a4 :=\ntop_unique (\u03bb _ g, id)\n\nlemma pullback_comp {f : Y \u27f6 X} {g : Z \u27f6 Y} (S : sieve X) : S.pullback (g \u226b f) = (S.pullback f).pullback g :=\nbegin\n  ext W h,\n  simp,\nend\nlemma pullback_inter {f : Y \u27f6 X} (S R : sieve X) : (S \u2293 R).pullback f = S.pullback f \u2293 R.pullback f :=\nbegin\n  ext Z g,\n  simp,\nend\n\nlemma le_pullback_comp {R : sieve Y} {f : Y \u27f6 X} :\n  R \u2264 pullback (comp R f) f :=\nbegin rintros Z g b, refine \u27e8_, _, rfl\u27e9, simpa end\n\n/-- If the identity arrow is in a sieve, the sieve is maximal. -/\nlemma id_mem_iff_eq_top : over.mk (\ud835\udfd9 X) \u2208 S.arrows \u2194 S = \u22a4 :=\n\u27e8begin\n  intro h,\n  rw eq_top_iff,\n  rintros Y f \u27e8\u27e9,\n  suffices : over.mk (f \u226b (\ud835\udfd9 _)) \u2208 S.arrows,\n    simpa using this,\n  apply downward_closed _ h,\nend,\nby { rintro rfl, trivial } \u27e9\n\nlemma pullback_eq_top_iff_mem (f : Y \u27f6 X) : over.mk f \u2208 S.arrows \u2194 S.pullback f = \u22a4 :=\nby rw [\u2190 id_mem_iff_eq_top, mem_pullback, category.id_comp]\n-- lemma comp_le_comps\n--   (R : \u03a0 (f : over X), sieve f.1)\n--   (S : sieve X)\n--   (f : over X)\n--   (H : f \u2208 S.arrows) :\n--   comp (R f) f.hom \u2264 comps R S  :=\n-- calc comp (R f) f.hom \u2264  \u2a06 (_ : f \u2208 S.arrows), comp (R f) f.hom : le_supr _ H\n--                   ... \u2264  comps R S                       : le_supr _ f\n\n-- lemma comps_le\n--   (R : \u03a0 (f : over X), sieve f.left)\n--   (S : sieve X) :\n--   comps R S \u2264 S :=\n-- begin\n--   apply supr_le _,\n--   rintros f,\n--   apply supr_le _,\n--   rintros H Y g,\n\n--   rintros \u27e8a,b,e\u27e9,\n\n--   -- suffices : over.mk (g.hom) \u2208 S.arrows, simp at this, apply this,\n--   -- rw \u2190 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\u1d52\u1d56 \u2964 Type v :=\n{ obj := \u03bb Y, {g : Y.unop \u27f6 X // over.mk g \u2208 S.arrows},\n  map := \u03bb Y Z f g, \u27e8f.unop \u226b g.1, downward_closed _ g.2 _\u27e9 }\n\n@[simps]\ndef le_as_functor {S T : sieve X} (h : S \u2264 T) : S.as_functor \u27f6 T.as_functor :=\n{ app := \u03bb Y f, \u27e8f.1, h _ _ f.2\u27e9 }.\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 \u27f6 yoneda.obj X :=\n{ app := \u03bb Y f, f.1 }.\n\nlemma le_as_functor_comm {S T : sieve X} (h : S \u2264 T) :\n  le_as_functor h \u226b 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\u27e8\u03bb Z f g h, begin\n  ext Y y,\n  have : (f \u226b functor_inclusion S).app Y y = (g \u226b functor_inclusion S).app Y y,\n    rw h,\n  exact this\nend\u27e9\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 `\u03b1 : Type` and `\u03b2 : \u03b1 \u2192 Type`, the W type determined by this data, `W_type \u03b2`, is the\ninductively defined type of trees where the nodes are labeled by elements of `\u03b1` and the children of\na node labeled `a` are indexed by elements of `\u03b2 a`.\n\nThis file is currently a stub, awaiting a full development of the theory. Currently, the main result\nis that if `\u03b1` is an encodable fintype and `\u03b2 a` is encodable for every `a : \u03b1`, then `W_type \u03b2` 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 `\u03b2 : \u03b1 \u2192 Type*`, `W_type \u03b2` is the type of finitely branching trees where nodes are labeled by\nelements of `\u03b1` and the children of a node labeled `a` are indexed by elements of `\u03b2 a`.\n-/\ninductive W_type {\u03b1 : Type u_1} (\u03b2 : \u03b1 \u2192 Type u_2) \nwhere\n| mk : (a : \u03b1) \u2192 (\u03b2 a \u2192 W_type \u03b2) \u2192 W_type \u03b2\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 {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} [(a : \u03b1) \u2192 fintype (\u03b2 a)] : W_type \u03b2 \u2192 \u2115 :=\n  sorry\n\ntheorem depth_pos {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} [(a : \u03b1) \u2192 fintype (\u03b2 a)] (t : W_type \u03b2) : 0 < depth t :=\n  W_type.cases_on t\n    fun (t_a : \u03b1) (t_f : \u03b2 t_a \u2192 W_type \u03b2) => nat.succ_pos (finset.sup finset.univ fun (n : \u03b2 t_a) => depth (t_f n))\n\ntheorem depth_lt_depth_mk {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} [(a : \u03b1) \u2192 fintype (\u03b2 a)] (a : \u03b1) (f : \u03b2 a \u2192 W_type \u03b2) (i : \u03b2 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 `\u03b1` is an encodable fintype and for every `a : \u03b1`, `\u03b2 a` is\nencodable.\n\nWe define an auxiliary type `W_type' \u03b2 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 `\u03b1` is an encodable fintype and for every `a : \u03b1`, `\u03b2 a` is\nencodable. -/\nprotected instance W_type.encodable {\u03b1 : Type u_1} {\u03b2 : \u03b1 \u2192 Type u_2} [(a : \u03b1) \u2192 fintype (\u03b2 a)] [(a : \u03b1) \u2192 encodable (\u03b2 a)] [encodable \u03b1] : encodable (W_type \u03b2) :=\n  let f : W_type \u03b2 \u2192 sigma fun (n : \u2115) => W_type' \u03b2 n :=\n    fun (t : W_type \u03b2) => sigma.mk (W_type.depth t) { val := t, property := sorry };\n  let finv : (sigma fun (n : \u2115) => W_type' \u03b2 n) \u2192 W_type \u03b2 :=\n    fun (p : sigma fun (n : \u2115) => W_type' \u03b2 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 \u2227 q \u2192 q \u2227 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\u00e9d\u00e9ric 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 \u2192+* R\u1d50\u1d52\u1d56`, 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\u1d50\u1d52\u1d56` 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem star_nat_cast_smul [Semiring R] [AddCommMonoid M] [Module R M] [StarAddMonoid M] (n : \u2115)\n    (x : M) : star ((n : R) \u2022 x) = (n : R) \u2022 star x :=\n  map_nat_cast_smul (starAddEquiv : M \u2243+ 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem star_int_cast_smul [Ring R] [AddCommGroup M] [Module R M] [StarAddMonoid M] (n : \u2124)\n    (x : M) : star ((n : R) \u2022 x) = (n : R) \u2022 star x :=\n  map_int_cast_smul (starAddEquiv : M \u2243+ 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem star_inv_nat_cast_smul [DivisionSemiring R] [AddCommMonoid M] [Module R M] [StarAddMonoid M]\n    (n : \u2115) (x : M) : star ((n\u207b\u00b9 : R) \u2022 x) = (n\u207b\u00b9 : R) \u2022 star x :=\n  map_inv_nat_cast_smul (starAddEquiv : M \u2243+ 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem star_inv_int_cast_smul [DivisionRing R] [AddCommGroup M] [Module R M] [StarAddMonoid M]\n    (n : \u2124) (x : M) : star ((n\u207b\u00b9 : R) \u2022 x) = (n\u207b\u00b9 : R) \u2022 star x :=\n  map_inv_int_cast_smul (starAddEquiv : M \u2243+ 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem star_rat_cast_smul [DivisionRing R] [AddCommGroup M] [Module R M] [StarAddMonoid M] (n : \u211a)\n    (x : M) : star ((n : R) \u2022 x) = (n : R) \u2022 star x :=\n  map_rat_cast_smul (starAddEquiv : M \u2243+ 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 \u211a R] (x : R) (n : \u211a) :\n    star (n \u2022 x) = n \u2022 star x :=\n  map_rat_smul (starAddEquiv : R \u2243+ 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 \u2243\u2097\u22c6[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\u2093'. -/\n/-- The self-adjoint part of an element of a star module, as a linear map. -/\n@[simps]\ndef selfAdjointPart : A \u2192\u2097[R] selfAdjoint A\n    where\n  toFun x :=\n    \u27e8(\u215f 2 : R) \u2022 (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]\u27e9\n  map_add' x y := by\n    ext\n    simp [add_add_add_comm]\n  map_smul' r x := by\n    ext\n    simp [\u2190 mul_smul, show \u215f 2 * r = r * \u215f 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\u2093'. -/\n/-- The skew-adjoint part of an element of a star module, as a linear map. -/\n@[simps]\ndef skewAdjointPart : A \u2192\u2097[R] skewAdjoint A\n    where\n  toFun x :=\n    \u27e8(\u215f 2 : R) \u2022 (x - star x), by\n      simp only [skewAdjoint.mem_iff, star_smul, star_sub, star_star, star_trivial, \u2190 smul_neg,\n        neg_sub]\u27e9\n  map_add' x y := by\n    ext\n    simp only [sub_add, \u2190 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 [\u2190 mul_smul, \u2190 smul_sub,\n      show r * \u215f 2 = \u215f 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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\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 \u2243\u2097[R] selfAdjoint A \u00d7 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\u2093'. -/\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 (\u00ac* p)).unsat \u2192 uniclo p (\u03bb _, 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 \u2192 tactic expr \n| (& m)    := return `(trivial)\n| (m ** n) := return `(trivial)\n| (t +* s) := \n  do x \u2190 preterm.expr_of_sub_free t,\n     y \u2190 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 \u2192 tactic expr \n| (t =* s) := return `(trivial)\n| (t \u2264* s) := return `(trivial)\n| (p \u2228* q) := \n  do x \u2190 expr_of_neg_free p,\n     y \u2190 expr_of_neg_free q,\n     return `(@and.intro (form.neg_free %%`(p)) \n       (form.neg_free %%`(q)) %%x %%y) \n| (p \u2227* q) := \n  do x \u2190 expr_of_neg_free p,\n     y \u2190 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 \u2192 tactic expr \n| (t =* s) := \n  do x \u2190 preterm.expr_of_sub_free t,\n     y \u2190 preterm.expr_of_sub_free s,\n     return `(@and.intro (preterm.sub_free %%`(t)) \n       (preterm.sub_free %%`(s)) %%x %%y) \n| (t \u2264* s) := \n  do x \u2190 preterm.expr_of_sub_free t,\n     y \u2190 preterm.expr_of_sub_free s,\n     return `(@and.intro (preterm.sub_free %%`(t)) \n       (preterm.sub_free %%`(s)) %%x %%y) \n| (\u00ac*p) := expr_of_sub_free p\n| (p \u2228* q) := \n  do x \u2190 expr_of_sub_free p,\n     y \u2190 expr_of_sub_free q,\n     return `(@and.intro (form.sub_free %%`(p)) \n       (form.sub_free %%`(q)) %%x %%y) \n| (p \u2227* q) := \n  do x \u2190 expr_of_sub_free p,\n     y \u2190 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 \u2190 expr_of_neg_free p,\n   y \u2190 expr_of_sub_free p,\n   z \u2190 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 \u2192 tactic expr | p := \nmatch p.sub_terms with \n| none         := expr_of_unsat_sf p\n| (some (t,s)) := \n  do x \u2190 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 \u2190 expr_of_unsat_nf (neg_elim (\u00ac*p)), \n   to_expr ``(uniclo_of_unsat_neg_elim_not %%`(m) %%`(p) %%x)\n\nmeta def expr_of_lna : tactic expr :=\ndo (p,m) \u2190 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 : \u2200(x : Nat){h : x = x}, Nat := by\n  intro x\n  match x with\n  | 0 => _\n  | n + 1 => _\n\nexample (x : Nat) : \u2200{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 : \u2115)\n  variables (h\u2081 : x = y) (h\u2082 : y = z)\n\n  section\n    variables {x y z}\n    include h\u2081 h\u2082\n    theorem foo : x = z :=\n    begin\n      rw [h\u2081, h\u2082]\n    end\n  end\n\n  theorem bar : x = z :=\n    eq.trans h\u2081 h\u2082\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 := \u2115\n\n@[reducible]\ndef heap := finmap (\u03bb _ : ptr, value)\n\nvariables {value}\n\ndef add (x y : option (heap value)) : option (heap value) :=\ndo x \u2190 x,\n   y \u2190 y,\n   if disjoint x y then pure $ x \u222a y else none\n\ninfixr ` \u2297 `:55 := add\n\ninstance {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Type*} : has_subset (finmap \u03b2) :=\n\u27e8 \u03bb x y, \u2200 a, a \u2208 x \u2192 a \u2208 y \u27e9\n\nlemma disjoint_mono' {ha hb ha' hb' : heap value} (H\u2080 : ha' \u2286 ha) (H\u2081 : hb' \u2286 hb) :\n  disjoint ha hb \u2192 disjoint ha' hb' :=\n\u03bb H\u2082 x H\u2083 H\u2084,  H\u2082 x (H\u2080 _ H\u2083) (H\u2081 _ H\u2084)\n\nlemma union_eq_add_of_disjoint {h h' : heap value} (H\u2080 : disjoint h h') :\n  some (h \u222a h') = some h \u2297 some h' :=\nby simp [add,if_pos H\u2080]; refl\n\nlemma add_assoc (h\u2080 h\u2081 h\u2082 : option (heap value)) : (h\u2080 \u2297 h\u2081) \u2297 h\u2082 = h\u2080 \u2297 (h\u2081 \u2297 h\u2082) :=\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 \u27e8h,h_1.1\u27e9 },\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\u2082,\n  { refl },\n  change none = pure h\u2082 >>= _, 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\u2080 h\u2081 : option (heap value)) : h\u2080 \u2297 h\u2081 = h\u2081 \u2297 h\u2080 :=\nbegin\n  cases h\u2080; cases h\u2081; try { refl },\n  simp only [add, @disjoint.symm_iff _ _ h\u2080, 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) := \u27e8 add_assoc \u27e9\ninstance : is_commutative _ (@add value) := \u27e8 add_comm \u27e9\n\n@[simp]\nlemma empty_add (h : option (heap value)) :\n  some \u2205 \u2297 h = h :=\nby cases h; [ simp [add], { rw [\u2190 union_eq_add_of_disjoint,empty_union]; apply disjoint_empty }]\n\n@[simp]\nlemma add_empty (h : option (heap value)) :\n  h \u2297 some \u2205 = h :=\nby cases h; [ simp [add], { rw [\u2190 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 \u2297 y \u2192 \u2203 x', some x' = x :=\nby intro h; cases x; [ { simp [add] at h, cases h }, exact \u27e8_,rfl\u27e9 ]\n\nlemma add_eq_some' (x y : option (heap value)) (z : heap value) : some z = x \u2297 y \u2192 \u2203 y', some y' = y :=\nassume h, add_eq_some y x z (@add_comm _ x y \u25b8 h)\n\nlemma disjoint_iff {h h' : heap value} : disjoint h h' \u2194 \u2203 h'', some h'' = some h \u2297 some h' :=\nby by_cases disjoint h h'; simp only [add, *, option.some_bind, exists_false, if_false, if_true, true_iff]; exact \u27e8_,rfl\u27e9\n\nlemma disjoint_of_add {h h' : heap value} (h'' : heap value) : some h'' = some h \u2297 some h' \u2192 disjoint h h' :=\n\u03bb HH, disjoint_iff.mpr \u27e8_, HH\u27e9\n\nlemma eq_union_of_eq_add {h h' h'' : heap value} : some h'' = some h \u2297 some h' \u2192 h'' = h \u222a h' :=\n\u03bb 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 \u211d 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 \u211d E] [normed_space \u211d F]\n  [normed_space \u211d G] {x v : E} {u : G} {f : E \u2192 F} (hf : differentiable_at \u211d f x) :\n  (fderiv \u211d (\u03bb y, (f y, u)) x v).2 = 0 :=\nbegin\n  have A : (fderiv \u211d (\u03bb y, (f y, u)) x v).2 = \n    (continuous_linear_map.snd \u211d F G).comp (fderiv \u211d (\u03bb y, (f y, u)) x) v := by simp,\n  rw A,\n  rw \u2190 (continuous_linear_map.snd \u211d F G).fderiv,\n  rw [\u2190 fderiv.comp, coe_snd'],\n  have B : prod.snd \u2218 (\u03bb y, (f y, u)) = \u03bb 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 \u211d E] [inner_product_space \u211d F] {f : E \u2192 F}\n  {s : set E} (hs : is_open s)\n\nlemma A {f' : E \u2192L[\u211d] F} (h : is_conformal_map f') {u v : E} :\n  \u27eau, v\u27eb = 0 \u2194 \u27eaf' u, f' v\u27eb = 0 :=\nbegin\n  rcases (is_conformal_map_iff _).mp h with \u27e8c, p, q\u27e9,\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 \u2192 (E \u2192L[\u211d] F)} {u v : E} (huv : \u27eau, v\u27eb = 0) \n  (h : \u2200\u1da0 x' in \ud835\udcdd x, is_conformal_map $ f' x') :\n  (\u03bb x, \u27eaf' x u, f' x v\u27eb) =\u1da0[\ud835\udcdd x] \u03bb x, (0 : \u211d) :=\nbegin\n  apply (filter.eventually_of_forall $ \u03bb x, huv).mp,\n  simp only [congr_arg],\n  rcases filter.eventually_iff_exists_mem.mp h with \u27e8s, hs, hys\u27e9,\n  exact filter.eventually_iff_exists_mem.mpr \u27e8s, hs, \u03bb y hy p, (A $ hys y hy).mp p\u27e9\nend\n\ninclude hs\n\nlemma eval_fderiv1 {u v x : E} (hx : x \u2208 s) {p : E \u2192 formal_multilinear_series \u211d E F}\n  (hf : has_ftaylor_series_up_to_on 2 f p s) : \n  fderiv \u211d (\u03bb y, p y 1 ![u]) x v = p x 2 ![u, v] :=\nbegin\n  have : (\u03bb y, p y 1 ![u]) = (\u03bb (q : (E \u2192L[\u211d] F) \u00d7 E), q.1 q.2) \u2218 \n    (\u03bb y, (continuous_multilinear_curry_fin1 \u211d _ _ (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 _ _ _ _ _ _ _ _ _ (\u03bb y, continuous_multilinear_curry_fin1 \u211d _ _ (p y 1)),\nend\n\n-- lemma eval_fderiv3 {u x : E} (hx : x \u2208 s)\n--   {n\u2080 : \u2115} (hf : times_cont_diff_at \u211d n\u2080 f x) {n : \u2115} (hn : n < n\u2080) {m : fin (n + 1) \u2192 E} :\n--   fderiv \u211d (\u03bb y, iterated_fderiv) x u = p x (n + 2) (fin.snoc m u)\n\nlemma diff_aux {f' : E \u2192 (E \u2192L[\u211d] F)} {x u : E} \n  (hf : \u2200\u1da0 (y : E) in \ud835\udcdd x, has_fderiv_at f (f' y) y) (hf' : differentiable_at \u211d f' x) :\n  fderiv \u211d (\u03bb y, f' y u) x = fderiv \u211d f' x u :=\nbegin\n  have : (\u03bb y, f' y u) = \u03bb y, ((apply \u211d F u) \u2218 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 \u2192 formal_multilinear_series \u211d E F}\n\nlemma D' (u v w : E) {x : E} (hx : x \u2208 s) (hf : has_ftaylor_series_up_to_on 2 f p s) :\n  fderiv \u211d (\u03bb y, \u27eafderiv \u211d f y u, fderiv \u211d f y v\u27eb) x w = \n  \u27eap x 2 ![u, w], fderiv \u211d f x v\u27eb + \n  \u27eafderiv \u211d f x u, iterated_fderiv \u211d 2 f x ![v, w]\u27eb :=\nbegin\n  rw fderiv_inner_apply,\n  have : \u2200\u1da0 (y : E) in \ud835\udcdd x, has_fderiv_at f (fderiv \u211d f y) y :=\n  begin\n    refine filter.eventually_iff_exists_mem.mpr \u27e8s, hs.mem_nhds hx, \u03bb y hy, _\u27e9,\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 \u2208 s) (hf : has_ftaylor_series_up_to_on 2 f p s)\n  (huv : \u27eau, v\u27eb = 0) (hwu : \u27eaw, u\u27eb = 0) (hvw : \u27eav, w\u27eb = 0) :\n  \u27eap x 2 ![u, v], p x 1 ![w]\u27eb = 0 :=\nbegin\n  have m\u2081 := D' u v w hx hf,\n  have m\u2082 := D' v w u hx hf,\n  have m\u2083 := D' w u v hx hf,\n  rw add_comm at m\u2081 m\u2083,\n  nth_rewrite 0 real_inner_comm at m\u2083 m\u2081,\n  nth_rewrite 1 real_inner_comm at m\u2081,\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 : \u2200 {t : term} {\u0393 : Environment} {\u0394 : SEnvironment},\n  wellTyped t \u2192 validWith \u0393 \u0394 (eq t t)\n  | t, \u0393, \u0394, wTt =>\n    match r: interpTerm t with\n    | some \u27e8 atom 0 , _ \u27e9               => by simp; rewrite [r]; exact rfl\n    | some \u27e8 atom 1 , _ \u27e9               => by simp; rewrite [r]; exact rfl\n    | some \u27e8 atom (succ (succ _)) , _ \u27e9 => by simp; rewrite [r]; simp; exact rfl\n    | some \u27e8 sort.undef, _ \u27e9            => by simp; rewrite [r]; exact rfl\n    | some \u27e8 sort.array _ _, _ \u27e9        => by simp; rewrite [r]; simp; exact rfl\n    | some \u27e8 sort.bv _, _ \u27e9             => by simp; rewrite [r]; simp; exact rfl\n    | some \u27e8 sort.arrow _ _, _ \u27e9        => by simp; rewrite [r]; simp; exact rfl\n    | some \u27e8 sort.dep, _ \u27e9              => 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 \u03b1)` quasiquotes a tree `(t: tree expr)` of quoted\nvalues of type `\u03b1` at level `u` into an `expr` which reifies to a `tree \u03b1`\ncontaining the reifications of the `expr`s from the original `t`. -/\nprotected unsafe def reflect' (u : level) (\u03b1 : expr) : Tree expr \u2192 expr\n  | Tree.nil => (expr.const `` Tree.nil [u] : expr) \u03b1\n  | Tree.node a t\u2081 t\u2082 => (expr.const `` Tree.node [u] : expr) \u03b1 a t\u2081.reflect' t\u2082.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 {\u03b1} [Zero \u03b1] (t : Tree \u03b1) (n : PosNum) : \u03b1 :=\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 \u03b1`. -/\n\n  | atom : PosNum \u2192 csring_expr/- (const n) is technically the csring's one, added n times.\nOr the zero if n is 0. -/\n\n  | const : Num \u2192 csring_expr\n  | add : csring_expr \u2192 csring_expr \u2192 csring_expr\n  | mul : csring_expr \u2192 csring_expr \u2192 csring_expr\n  | pow : csring_expr \u2192 Num \u2192 csring_expr\n  deriving has_reflect\n#align tactic.ring2.csring_expr Tactic.Ring2.CsringExpr\n\nnamespace CsringExpr\n\ninstance : Inhabited CsringExpr :=\n  \u27e8const 0\u27e9\n\n/-- Evaluates a reflected `csring_expr` into an element of the\noriginal `comm_semiring` type `\u03b1`, retrieving opaque elements\n(atoms) from the tree `t`. -/\ndef eval {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) : CsringExpr \u2192 \u03b1\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 : \u2115)\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 \u2192 horner_expr/- (horner a x n b) is a*x\u207f + b, where x is the x-th atom\nin the atom tree. -/\n\n  | horner : horner_expr \u2192 PosNum \u2192 Num \u2192 horner_expr \u2192 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 \u2192 Prop\n  | const n => \u2203 m : Num, n = m.toZNum\n  | horner a x n b => is_cs a \u2227 is_cs b\n#align tactic.ring2.horner_expr.is_cs Tactic.Ring2.HornerExpr.IsCs\n\ninstance : Zero HornerExpr :=\n  \u27e8const 0\u27e9\n\ninstance : One HornerExpr :=\n  \u27e8const 1\u27e9\n\ninstance : Inhabited HornerExpr :=\n  \u27e80\u27e9\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 \u2192 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  \u27e8toString\u27e9\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\u2081 x\u2081 n\u2081 b\u2081 => if x\u2081 = x \u2227 b\u2081 = 0 then horner a\u2081 x (n\u2081 + 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    \u00b7 exact const (k + n)\n    \u00b7 exact horner a x n B\n#align tactic.ring2.horner_expr.add_const Tactic.Ring2.HornerExpr.addConst\n\ndef addAux (a\u2081 : HornerExpr) (A\u2081 : HornerExpr \u2192 HornerExpr) (x\u2081 : PosNum) :\n    HornerExpr \u2192 Num \u2192 HornerExpr \u2192 (HornerExpr \u2192 HornerExpr) \u2192 HornerExpr\n  | const n\u2082, n\u2081, b\u2081, B\u2081 => addConst n\u2082 (horner a\u2081 x\u2081 n\u2081 b\u2081)\n  | horner a\u2082 x\u2082 n\u2082 b\u2082, n\u2081, b\u2081, B\u2081 =>\n    let e\u2082 := horner a\u2082 x\u2082 n\u2082 b\u2082\n    match PosNum.cmp x\u2081 x\u2082 with\n    | Ordering.lt => horner a\u2081 x\u2081 n\u2081 (B\u2081 e\u2082)\n    | Ordering.gt => horner a\u2082 x\u2082 n\u2082 (add_aux b\u2082 n\u2081 b\u2081 B\u2081)\n    | Ordering.eq =>\n      match Num.sub' n\u2081 n\u2082 with\n      | ZNum.zero => horner' (A\u2081 a\u2082) x\u2081 n\u2081 (B\u2081 b\u2082)\n      | ZNum.pos k => horner (add_aux a\u2082 k 0 id) x\u2081 n\u2082 (B\u2081 b\u2082)\n      | ZNum.neg k => horner (A\u2081 (horner a\u2082 x\u2081 k 0)) x\u2081 n\u2081 (B\u2081 b\u2082)\n#align tactic.ring2.horner_expr.add_aux Tactic.Ring2.HornerExpr.addAux\n\ndef add : HornerExpr \u2192 HornerExpr \u2192 HornerExpr\n  | const n\u2081, e\u2082 => addConst n\u2081 e\u2082\n  | horner a\u2081 x\u2081 n\u2081 b\u2081, e\u2082 => addAux a\u2081 (add a\u2081) x\u2081 e\u2082 n\u2081 b\u2081 (add b\u2081)\n#align tactic.ring2.horner_expr.add Tactic.Ring2.HornerExpr.add\n\n/-begin\n  induction e\u2081 with n\u2081 a\u2081 x\u2081 n\u2081 b\u2081 A\u2081 B\u2081 generalizing e\u2082,\n  { exact add_const n\u2081 e\u2082 },\n  exact match e\u2082 with e\u2082 := begin\n    induction e\u2082 with n\u2082 a\u2082 x\u2082 n\u2082 b\u2082 A\u2082 B\u2082 generalizing n\u2081 b\u2081;\n    let e\u2081 := horner a\u2081 x\u2081 n\u2081 b\u2081,\n    { exact add_const n\u2082 e\u2081 },\n    let e\u2082 := horner a\u2082 x\u2082 n\u2082 b\u2082,\n    exact match pos_num.cmp x\u2081 x\u2082 with\n    | ordering.lt := horner a\u2081 x\u2081 n\u2081 (B\u2081 e\u2082)\n    | ordering.gt := horner a\u2082 x\u2082 n\u2082 (B\u2082 n\u2081 b\u2081)\n    | ordering.eq :=\n      match num.sub' n\u2081 n\u2082 with\n      | znum.zero := horner' (A\u2081 a\u2082) x\u2081 n\u2081 (B\u2081 b\u2082)\n      | (znum.pos k) := horner (A\u2082 k 0) x\u2081 n\u2082 (B\u2081 b\u2082)\n      | (znum.neg k) := horner (A\u2081 (horner a\u2082 x\u2081 k 0)) x\u2081 n\u2081 (B\u2081 b\u2082)\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  \u00b7 exact const (-n)\n  \u00b7 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      \u00b7 exact const (n * k)\n      \u00b7 exact horner A x n B\n#align tactic.ring2.horner_expr.mul_const Tactic.Ring2.HornerExpr.mulConst\n\ndef mulAux (a\u2081 x\u2081 n\u2081 b\u2081) (A\u2081 B\u2081 : HornerExpr \u2192 HornerExpr) : HornerExpr \u2192 HornerExpr\n  | const n\u2082 => mulConst n\u2082 (horner a\u2081 x\u2081 n\u2081 b\u2081)\n  | e\u2082@(horner a\u2082 x\u2082 n\u2082 b\u2082) =>\n    match PosNum.cmp x\u2081 x\u2082 with\n    | Ordering.lt => horner (A\u2081 e\u2082) x\u2081 n\u2081 (B\u2081 e\u2082)\n    | Ordering.gt => horner (mul_aux a\u2082) x\u2082 n\u2082 (mul_aux b\u2082)\n    | Ordering.eq =>\n      let haa := horner' (mul_aux a\u2082) x\u2081 n\u2082 0\n      if b\u2082 = 0 then haa else haa.add (horner (A\u2081 b\u2082) x\u2081 n\u2081 (B\u2081 b\u2082))\n#align tactic.ring2.horner_expr.mul_aux Tactic.Ring2.HornerExpr.mulAux\n\ndef mul : HornerExpr \u2192 HornerExpr \u2192 HornerExpr\n  | const n\u2081 => mulConst n\u2081\n  | horner a\u2081 x\u2081 n\u2081 b\u2081 => mulAux a\u2081 x\u2081 n\u2081 b\u2081 (mul a\u2081) (mul b\u2081)\n#align tactic.ring2.horner_expr.mul Tactic.Ring2.HornerExpr.mul\n\n/-begin\n  induction e\u2081 with n\u2081 a\u2081 x\u2081 n\u2081 b\u2081 A\u2081 B\u2081 generalizing e\u2082,\n  { exact mul_const n\u2081 e\u2082 },\n  induction e\u2082 with n\u2082 a\u2082 x\u2082 n\u2082 b\u2082 A\u2082 B\u2082;\n  let e\u2081 := horner a\u2081 x\u2081 n\u2081 b\u2081,\n  { exact mul_const n\u2082 e\u2081 },\n  let e\u2082 := horner a\u2082 x\u2082 n\u2082 b\u2082,\n  cases pos_num.cmp x\u2081 x\u2082,\n  { exact horner (A\u2081 e\u2082) x\u2081 n\u2081 (B\u2081 e\u2082) },\n  { let haa := horner' A\u2082 x\u2081 n\u2082 0,\n    exact if b\u2082 = 0 then haa else\n      haa.add (horner (A\u2081 b\u2082) x\u2081 n\u2081 (B\u2081 b\u2082)) },\n  { exact horner A\u2082 x\u2082 n\u2082 B\u2082 }\nend-/\ninstance : Add HornerExpr :=\n  \u27e8add\u27e9\n\ninstance : Neg HornerExpr :=\n  \u27e8neg\u27e9\n\ninstance : Mul HornerExpr :=\n  \u27e8mul\u27e9\n\ndef pow (e : HornerExpr) : Num \u2192 HornerExpr\n  | 0 => 1\n  | Num.pos p => by\n    induction' p with p ep p ep\n    \u00b7 exact e\n    \u00b7 exact (ep.mul ep).mul e\n    \u00b7 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 \u2192 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 {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) : HornerExpr \u2192 \u03b1\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 {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) (n : PosNum) :\n    (atom n).IsCs \u2227 cseval t (atom n) = t.getOrZero n :=\n  \u27e8\u27e8\u27e81, rfl\u27e9, \u27e80, rfl\u27e9\u27e9, (Tactic.Ring.horner_atom _).symm\u27e9\n#align tactic.ring2.horner_expr.cseval_atom Tactic.Ring2.HornerExpr.cseval_atom\n\ntheorem cseval_addConst {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) (k : Num) {e : HornerExpr} (cs : e.IsCs) :\n    (addConst k.toZNum e).IsCs \u2227 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 \u2260 0 by decide]\n  induction' e with n a x n b A B <;> simp [*]\n  \u00b7 rcases cs with \u27e8n, rfl\u27e9\n    refine' \u27e8\u27e8n + Num.pos k, by simp [add_comm] <;> rfl\u27e9, _\u27e9\n    cases n <;> simp!\n  \u00b7 rcases B cs.2 with \u27e8csb, h\u27e9\n    simp! [*, cs.1]\n    rw [\u2190 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' {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) (a x n b) (h\u2081 : IsCs a) (h\u2082 : IsCs b) :\n    (horner' a x n b).IsCs \u2227\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\u2081 a\u2081 x\u2081 n\u2081 b\u2081 <;> simp [horner'] <;> split_ifs\n  \u00b7 simp! [*, Tactic.Ring.horner]\n  \u00b7 exact \u27e8\u27e8h\u2081, h\u2082\u27e9, rfl\u27e9\n  \u00b7 refine' \u27e8\u27e8h\u2081.1, h\u2082\u27e9, Eq.symm _\u27e9\n    simp! [*]\n    apply Tactic.Ring.horner_horner\n    simp\n  \u00b7 exact \u27e8\u27e8h\u2081, h\u2082\u27e9, rfl\u27e9\n#align tactic.ring2.horner_expr.cseval_horner' Tactic.Ring2.HornerExpr.cseval_horner'\n\ntheorem cseval_add {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) {e\u2081 e\u2082 : HornerExpr} (cs\u2081 : e\u2081.IsCs)\n    (cs\u2082 : e\u2082.IsCs) : (add e\u2081 e\u2082).IsCs \u2227 cseval t (add e\u2081 e\u2082) = cseval t e\u2081 + cseval t e\u2082 :=\n  by\n  induction' e\u2081 with n\u2081 a\u2081 x\u2081 n\u2081 b\u2081 A\u2081 B\u2081 generalizing e\u2082 <;> simp!\n  \u00b7 rcases cs\u2081 with \u27e8n\u2081, rfl\u27e9\n    simpa using cseval_add_const t n\u2081 cs\u2082\n  induction' e\u2082 with n\u2082 a\u2082 x\u2082 n\u2082 b\u2082 A\u2082 B\u2082 generalizing n\u2081 b\u2081\n  \u00b7 rcases cs\u2082 with \u27e8n\u2082, rfl\u27e9\n    simp! [cseval_add_const t n\u2082 cs\u2081, add_comm]\n  cases' cs\u2081 with csa\u2081 csb\u2081; cases' id cs\u2082 with csa\u2082 csb\u2082\n  simp! ; have C := PosNum.cmp_to_nat x\u2081 x\u2082\n  cases PosNum.cmp x\u2081 x\u2082 <;> simp!\n  \u00b7 rcases B\u2081 csb\u2081 cs\u2082 with \u27e8csh, h\u27e9\n    refine' \u27e8\u27e8csa\u2081, csh\u27e9, Eq.symm _\u27e9\n    apply Tactic.Ring.horner_add_const\n    exact h.symm\n  \u00b7 cases C\n    have B0 :\n      is_cs 0 \u2192\n        \u2200 {e\u2082 : horner_expr},\n          is_cs e\u2082 \u2192 is_cs (add 0 e\u2082) \u2227 cseval t (add 0 e\u2082) = cseval t 0 + cseval t e\u2082 :=\n      fun _ e\u2082 c => \u27e8c, (zero_add _).symm\u27e9\n    cases' e : Num.sub' n\u2081 n\u2082 with k k <;> simp!\n    \u00b7 have : n\u2081 = n\u2082 := by\n        have := congr_arg (coe : ZNum \u2192 \u2124) e\n        simp at this\n        have := sub_eq_zero.1 this\n        rw [\u2190 Num.to_nat_to_int, \u2190 Num.to_nat_to_int] at this\n        exact Num.to_nat_inj.1 (Int.ofNat.inj this)\n      subst n\u2082\n      rcases cseval_horner' _ _ _ _ _ _ _ with \u27e8csh, h\u27e9\n      \u00b7 refine' \u27e8csh, h.trans (Eq.symm _)\u27e9\n        simp [*]\n        apply Tactic.Ring.horner_add_horner_eq <;> try rfl\n      all_goals simp! [*]\n    \u00b7 simp [B\u2081 csb\u2081 csb\u2082, add_comm]\n      rcases A\u2082 csa\u2082 _ _ B0 \u27e8csa\u2081, 0, rfl\u27e9 with \u27e8csh, h\u27e9\n      refine' \u27e8csh, Eq.symm _\u27e9\n      rw [show id = add 0 from rfl, h]\n      apply Tactic.Ring.horner_add_horner_gt\n      \u00b7 change (_ + k : \u2115) = _\n        rw [\u2190 Int.coe_nat_inj', Int.ofNat_add, eq_comm, \u2190 sub_eq_iff_eq_add']\n        simpa using congr_arg (coe : ZNum \u2192 \u2124) e\n      \u00b7 rfl\n      \u00b7 apply add_comm\n    \u00b7 have : (horner a\u2082 x\u2081 (Num.pos k) 0).IsCs := \u27e8csa\u2082, 0, rfl\u27e9\n      simp [B\u2081 csb\u2081 csb\u2082, A\u2081 csa\u2081 this]\n      symm\n      apply Tactic.Ring.horner_add_horner_lt\n      \u00b7 change (_ + k : \u2115) = _\n        rw [\u2190 Int.coe_nat_inj', Int.ofNat_add, eq_comm, \u2190 sub_eq_iff_eq_add', \u2190 neg_inj, neg_sub]\n        simpa using congr_arg (coe : ZNum \u2192 \u2124) e\n      all_goals rfl\n  \u00b7 rcases B\u2082 csb\u2082 _ _ B\u2081 \u27e8csa\u2081, csb\u2081\u27e9 with \u27e8csh, h\u27e9\n    refine' \u27e8\u27e8csa\u2082, csh\u27e9, Eq.symm _\u27e9\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 {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) (k : Num) {e : HornerExpr} (cs : e.IsCs) :\n    (mulConst k.toZNum e).IsCs \u2227 cseval t (mulConst k.toZNum e) = cseval t e * k :=\n  by\n  simp [mul_const]\n  split_ifs with h h\n  \u00b7 cases (Num.toZNum_inj.1 h : k = 0)\n    exact \u27e8\u27e80, rfl\u27e9, (MulZeroClass.mul_zero _).symm\u27e9\n  \u00b7 cases (Num.toZNum_inj.1 h : k = 1)\n    exact \u27e8cs, (mul_one _).symm\u27e9\n  induction' e with n a x n b A B <;> simp [*]\n  \u00b7 rcases cs with \u27e8n, rfl\u27e9\n    suffices\n    refine' \u27e8\u27e8n * k, this\u27e9, _\u27e9\n    swap\n    \u00b7 cases n <;> cases k <;> rfl\n    rw [show _ from this]\n    simp!\n  \u00b7 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 {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) {e\u2081 e\u2082 : HornerExpr} (cs\u2081 : e\u2081.IsCs)\n    (cs\u2082 : e\u2082.IsCs) : (mul e\u2081 e\u2082).IsCs \u2227 cseval t (mul e\u2081 e\u2082) = cseval t e\u2081 * cseval t e\u2082 :=\n  by\n  induction' e\u2081 with n\u2081 a\u2081 x\u2081 n\u2081 b\u2081 A\u2081 B\u2081 generalizing e\u2082 <;> simp!\n  \u00b7 rcases cs\u2081 with \u27e8n\u2081, rfl\u27e9\n    simpa [mul_comm] using cseval_mul_const t n\u2081 cs\u2082\n  induction' e\u2082 with n\u2082 a\u2082 x\u2082 n\u2082 b\u2082 A\u2082 B\u2082\n  \u00b7 rcases cs\u2082 with \u27e8n\u2082, rfl\u27e9\n    simpa! using cseval_mul_const t n\u2082 cs\u2081\n  cases' cs\u2081 with csa\u2081 csb\u2081; cases' id cs\u2082 with csa\u2082 csb\u2082\n  simp! ; have C := PosNum.cmp_to_nat x\u2081 x\u2082\n  cases' A\u2082 csa\u2082 with csA\u2082 hA\u2082\n  cases PosNum.cmp x\u2081 x\u2082 <;> simp!\n  \u00b7 simp [A\u2081 csa\u2081 cs\u2082, B\u2081 csb\u2081 cs\u2082]\n    symm\n    apply Tactic.Ring.horner_mul_const <;> rfl\n  \u00b7 cases' cseval_horner' t _ x\u2081 n\u2082 0 csA\u2082 \u27e80, rfl\u27e9 with csh\u2081 h\u2081\n    cases C\n    split_ifs\n    \u00b7 subst b\u2082\n      refine' \u27e8csh\u2081, h\u2081.trans (Eq.symm _)\u27e9\n      apply Tactic.Ring.horner_mul_horner_zero <;> try rfl\n      simp! [hA\u2082]\n    \u00b7 cases' A\u2081 csa\u2081 csb\u2082 with csA\u2081 hA\u2081\n      cases' cseval_add t csh\u2081 _ with csh\u2082 h\u2082\n      \u00b7 refine' \u27e8csh\u2082, h\u2082.trans (Eq.symm _)\u27e9\n        apply Tactic.Ring.horner_mul_horner <;> try rfl\n        simp! [*]\n      exact \u27e8csA\u2081, (B\u2081 csb\u2081 csb\u2082).1\u27e9\n  \u00b7 simp [A\u2082 csa\u2082, B\u2082 csb\u2082]\n    rw [mul_comm, eq_comm]\n    apply Tactic.Ring.horner_const_mul\n    \u00b7 apply mul_comm\n    \u00b7 rfl\n#align tactic.ring2.horner_expr.cseval_mul Tactic.Ring2.HornerExpr.cseval_mul\n\ntheorem cseval_pow {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) {x : HornerExpr} (cs : x.IsCs) :\n    \u2200 n : Num, (pow x n).IsCs \u2227 cseval t (pow x n) = cseval t x ^ (n : \u2115)\n  | 0 => \u27e8\u27e81, rfl\u27e9, (pow_zero _).symm\u27e9\n  | Num.pos p => by\n    simp [pow]; induction' p with p ep p ep\n    \u00b7 simp [*]\n    \u00b7 simp [pow_bit1]\n      cases' cseval_mul t ep.1 ep.1 with cs\u2080 h\u2080\n      cases' cseval_mul t cs\u2080 cs with cs\u2081 h\u2081\n      simp [*]\n    \u00b7 simp [pow_bit0]\n      cases' cseval_mul t ep.1 ep.1 with cs\u2080 h\u2080\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 {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) :\n    \u2200 r : CsringExpr, (ofCsexpr r).IsCs \u2227 cseval t (ofCsexpr r) = r.eval t\n  | csring_expr.atom n => cseval_atom _ _\n  | csring_expr.const n => \u27e8\u27e8n, rfl\u27e9, by cases n <;> rfl\u27e9\n  | csring_expr.add x y =>\n    let \u27e8cs\u2081, h\u2081\u27e9 := cseval_of_csexpr x\n    let \u27e8cs\u2082, h\u2082\u27e9 := cseval_of_csexpr y\n    let \u27e8cs, h\u27e9 := cseval_add t cs\u2081 cs\u2082\n    \u27e8cs, by simp! [h, *]\u27e9\n  | csring_expr.mul x y =>\n    let \u27e8cs\u2081, h\u2081\u27e9 := cseval_of_csexpr x\n    let \u27e8cs\u2082, h\u2082\u27e9 := cseval_of_csexpr y\n    let \u27e8cs, h\u27e9 := cseval_mul t cs\u2081 cs\u2082\n    \u27e8cs, by simp! [h, *]\u27e9\n  | csring_expr.pow x n =>\n    let \u27e8cs, h\u27e9 := cseval_of_csexpr x\n    let \u27e8cs, h\u27e9 := cseval_pow t cs n\n    \u27e8cs, by simp! [h, *]\u27e9\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\u2081` and `r\u2082` 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 {\u03b1} [CommSemiring \u03b1] (t : Tree \u03b1) (r\u2081 r\u2082 : CsringExpr)\n    (H : HornerExpr.ofCsexpr r\u2081 = HornerExpr.ofCsexpr r\u2082) : r\u2081.eval t = r\u2082.eval t := by\n  repeat' rw [\u2190 (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 \u2192 CsringExpr \u00d7 Dlist expr\n    |\n        q( $ ( e\u2081 ) + $ ( e\u2082 ) )\n        =>\n        let\n          ( r\u2081 , l\u2081 ) := reflect_expr e\u2081\n          let ( r\u2082 , l\u2082 ) := reflect_expr e\u2082 ( r\u2081 . add r\u2082 , l\u2081 ++ l\u2082 )\n      |\n        q( $ ( e\u2081 ) * $ ( e\u2082 ) )\n        =>\n        let\n          ( r\u2081 , l\u2081 ) := reflect_expr e\u2081\n          let ( r\u2082 , l\u2082 ) := reflect_expr e\u2082 ( r\u2081 . mul r\u2082 , l\u2081 ++ l\u2082 )\n      |\n        e @ q( $ ( e\u2081 ) ^ $ ( e\u2082 ) )\n        =>\n        match\n          reflect_expr e\u2081 , expr.to_nat e\u2082\n          with\n          | ( r\u2081 , l\u2081 ) , some n\u2082 => ( r\u2081 . pow ( Num.ofNat' n\u2082 ) , l\u2081 )\n            | ( r\u2081 , l\u2081 ) , 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 \u2192 StateT (List expr) Option CsringExpr\n  | csring_expr.atom _ => do\n    let e \u2190 get\n    let p \u2190 monadLift (t.indexOf\u2093 (\u00b7 < \u00b7) 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\u2081 ) = $ ( e\u2082 ) )\n              \u2190\n              target\n              | fail \"ring2 tactic failed: the goal is not an equality\"\n          let \u03b1 \u2190 infer_type e\u2081\n          let expr.sort ( level.succ u ) \u2190 infer_type \u03b1\n          let ( r\u2081 , l\u2081 ) := reflect_expr e\u2081\n          let ( r\u2082 , l\u2082 ) := reflect_expr e\u2082\n          let L := ( l\u2081 ++ l\u2082 ) . toList\n          let s := Tree.ofRBNode ( rbtreeOf L ) . 1\n          let ( r\u2081 , L ) \u2190 ( StateT.run ( r\u2081 . replace s ) L : Option _ )\n          let ( r\u2082 , _ ) \u2190 ( StateT.run ( r\u2082 . replace s ) L : Option _ )\n          let se : expr := s . reflect' u \u03b1\n          let er\u2081 : expr := reflect r\u2081\n          let er\u2082 : expr := reflect r\u2082\n          let cs \u2190 mk_app ` ` CommSemiring [ \u03b1 ] >>= mk_instance\n          let\n            e\n              \u2190\n              to_expr ` `( correctness $ ( se ) $ ( er\u2081 ) $ ( er\u2082 ) rfl )\n                <|>\n                fail\n                  (\n                    \"ring2 tactic failed, cannot show equality:\\n\"\n                          ++\n                          toString ( HornerExpr.ofCsexpr r\u2081 )\n                        ++\n                        \"\\n  =?=\\n\"\n                      ++\n                      toString ( HornerExpr.ofCsexpr r\u2082 )\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 {\u03b1 : Type} [partial_order \u03b1] [decidable_eq \u03b1] (M : \u03b1) (M_is_lb : \u2200 a, M \u2264 a)\n\nopen classical\nlocal attribute [instance] prop_decidable\n\ntheorem double_not (p : Prop) : \u00ac\u00acp \u2194 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 (\u00ac \u2203 M', M' > M \u2227 \u2200 a, M' \u2264 a) (\u00ac\u00ac\u2200 M', (\u2200 a, M' \u2264 a) \u2192 M' = M) :=\n  begin\n  have : \u2200 M', (M' > M \u2227 \u2200 a, M' \u2264 a) \u2194 \u00ac ((\u2200 a, M' \u2264 a) \u2192 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 : \u2200 (a : \u03b1), M' \u2264 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 \u2243 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 \u2192 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} \u2295 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u211d 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 \u211d E]\n    {F : Type u_2} [normed_group F] [normed_space \u211d F] {f : E \u2192 F} {s : set E} {x : E}\n    {f' : continuous_linear_map \u211d E F} (f_diff : differentiable_on \u211d f s) (s_conv : convex s)\n    (s_open : is_open s) (f_cont : \u2200 (y : E), y \u2208 closure s \u2192 continuous_within_at f s y)\n    (h : filter.tendsto (fun (y : E) => fderiv \u211d 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 : \u211d`, 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 \u211d E] {s : set \u211d} {e : E} {a : \u211d} {f : \u211d \u2192 E} (f_diff : differentiable_on \u211d f s)\n    (f_lim : continuous_within_at f s a) (hs : s \u2208 nhds_within a (set.Ioi a))\n    (f_lim' : filter.tendsto (fun (x : \u211d) => 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 : \u211d`, 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 \u211d E] {s : set \u211d} {e : E} {a : \u211d} {f : \u211d \u2192 E} (f_diff : differentiable_on \u211d f s)\n    (f_lim : continuous_within_at f s a) (hs : s \u2208 nhds_within a (set.Iio a))\n    (f_lim' : filter.tendsto (fun (x : \u211d) => 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 \u211d E]\n    {f : \u211d \u2192 E} {g : \u211d \u2192 E} {x : \u211d} (f_diff : \u2200 (y : \u211d), y \u2260 x \u2192 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": "set_option pp.motives.pi false\n\n#print Nat.add\n\nset_option pp.motives.pi true\n\n#print Nat.add\n\ntheorem ex : \u2200 {\u03b1 \u03b2 : Sort u} (h : \u03b1 = \u03b2) (a : \u03b1), HEq (cast h a) a\n  | \u03b1, _, rfl, a => HEq.refl a\n\nset_option pp.motives.nonConst false\n\n#print ex\n\nset_option pp.motives.nonConst true\n\n#print ex\n\nnoncomputable def fact (n : Nat) : Nat :=\n  Nat.recOn n 1 (fun n acc => (n+1)*acc)\n\nset_option pp.motives.all false\n\n#print fact\n\nset_option pp.motives.all true\n\n#print fact\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/ppMotives.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.6757646010190477, "lm_q2_score": 0.6723316991792861, "lm_q1q2_score": 0.4543379624483487}}
{"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 (\u03b1 : Type*) extends fintype \u03b1, linear_order \u03b1 :=\n(nonempty : nonempty \u03b1 . tactic.apply_instance)\n\nattribute [instance] nonempty_fin_lin_ord.nonempty\n\n@[priority 100]\ninstance nonempty_fin_lin_ord.to_bounded_order (\u03b1 : Type*) [nonempty_fin_lin_ord \u03b1] :\n  bounded_order \u03b1 :=\nfintype.to_bounded_order \u03b1\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 : \u2115) : nonempty_fin_lin_ord (fin (n+1)) :=\n{ .. fin.fintype _,\n  .. fin.linear_order }\n\ninstance ulift.nonempty_fin_lin_ord (\u03b1 : Type u) [nonempty_fin_lin_ord \u03b1] :\n  nonempty_fin_lin_ord (ulift.{v} \u03b1) :=\n{ nonempty := \u27e8ulift.up \u22a5\u27e9,\n  .. linear_order.lift equiv.ulift (equiv.injective _),\n  .. ulift.fintype _ }\n\ninstance (\u03b1 : Type*) [nonempty_fin_lin_ord \u03b1] : nonempty_fin_lin_ord (order_dual \u03b1) :=\n{ ..order_dual.fintype \u03b1 }\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 := \u27e8\u27e9\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 (\u03b1 : Type*) [nonempty_fin_lin_ord \u03b1] : NonemptyFinLinOrd := bundled.of \u03b1\n\ninstance : inhabited NonemptyFinLinOrd := \u27e8of punit\u27e9\n\ninstance (\u03b1 : NonemptyFinLinOrd) : nonempty_fin_lin_ord \u03b1 := \u03b1.str\n\ninstance has_forget_to_LinearOrder : has_forget\u2082 NonemptyFinLinOrd LinearOrder :=\nbundled_hom.forget\u2082 _ _\n\n/-- Constructs an equivalence between nonempty finite linear orders from an order isomorphism\nbetween them. -/\n@[simps] def iso.mk {\u03b1 \u03b2 : NonemptyFinLinOrd.{u}} (e : \u03b1 \u2243o \u03b2) : \u03b1 \u2245 \u03b2 :=\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 \u2964 NonemptyFinLinOrd :=\n{ obj := \u03bb X, of (order_dual X), map := \u03bb 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 \u224c NonemptyFinLinOrd :=\nequivalence.mk to_dual to_dual\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n  (nat_iso.of_components (\u03bb X, iso.mk $ order_iso.dual_dual X) $ \u03bb X Y f, rfl)\n\nend NonemptyFinLinOrd\n\nlemma NonemptyFinLinOrd_dual_equiv_comp_forget_to_LinearOrder :\n  NonemptyFinLinOrd.dual_equiv.functor \u22d9 forget\u2082 NonemptyFinLinOrd LinearOrder\n  = forget\u2082 NonemptyFinLinOrd LinearOrder \u22d9 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 \u2190 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 \u2190 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 \u2192 list name \u2192 tactic simp_lemmas\n| s []      := return s\n| s (n::ns) := do s' \u2190 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 \u2200 f, (p \u2192 f) \u2192 f and introduce.\n-/\n\ntheorem by_contradiction_trick (p : Prop) (h : \u2200 f : Prop, (p \u2192 f) \u2192 f) : p :=\nh p id\n\nmeta def preprocess_goal (cfg : auto_config) : tactic unit :=\ndo repeat (intro1 >> skip),\n   tgt \u2190 target >>= whnf_reducible,\n   if (\u00ac (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 \u2192 b in favor of \u00ac a \u2228 b.\n\n  For efficiency, we push negations inwards from the top down. (For example, consider\n  simplifying \u00ac \u00ac (p \u2228 q).)\n-/\n\nsection\n\nuniverse u\nvariable  {\u03b1 : Type u}\nvariables (p q : Prop)\nvariable  (s : \u03b1 \u2192 Prop)\n\nlocal attribute [instance] classical.prop_decidable\ntheorem not_not_eq : (\u00ac \u00ac p) = p := propext not_not\ntheorem not_and_eq : (\u00ac (p \u2227 q)) = (\u00ac p \u2228 \u00ac q) := propext not_and_distrib\ntheorem not_or_eq : (\u00ac (p \u2228 q)) = (\u00ac p \u2227 \u00ac q) := propext not_or_distrib\ntheorem not_forall_eq : (\u00ac \u2200 x, s x) = (\u2203 x, \u00ac s x) := propext not_forall\ntheorem not_exists_eq : (\u00ac \u2203 x, s x) = (\u2200 x, \u00ac s x) := propext not_exists\ntheorem not_implies_eq : (\u00ac (p \u2192 q)) = (p \u2227 \u00ac q) := propext not_imp\n\ntheorem classical.implies_iff_not_or : (p \u2192 q) \u2194 (\u00ac p \u2228 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 \u00d7 expr)) :=\ndo e \u2190 whnf_reducible e,\n   match e with\n   | `(\u00ac %%ne) :=\n      (do ne \u2190 whnf_reducible ne,\n      match ne with\n      | `(\u00ac %%a)      := do pr \u2190 mk_app ``not_not_eq [a],\n                            return (some (a, pr))\n      | `(%%a \u2227 %%b)  := do pr \u2190 mk_app ``not_and_eq [a, b],\n                            return (some (`(\u00ac %%a \u2228 \u00ac %%b), pr))\n      | `(%%a \u2228 %%b)  := do pr \u2190 mk_app ``not_or_eq [a, b],\n                            return (some (`(\u00ac %%a \u2227 \u00ac %%b), pr))\n      | `(Exists %%p) := do pr \u2190 mk_app ``not_exists_eq [p],\n                            `(%%_ = %%e') \u2190 infer_type pr,\n                            return (some (e', pr))\n      | (pi n bi d p) := if \u00ac cfg.classical then return none\n                         else if p.has_var then do\n                            pr \u2190 mk_app ``not_forall_eq [lam n bi d (expr.abstract_local p n)],\n                            `(%%_ = %%e') \u2190 infer_type pr,\n                            return (some (e', pr))\n                         else do\n                            pr \u2190 mk_app ``not_implies_eq [d, p],\n                            `(%%_ = %%e') \u2190 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 \u2192 tactic (option (expr \u00d7 expr)) :=\n\u03bb e, do\n  opr \u2190 transform_negation_step cfg e,\n  match opr with\n  | (some (e', pr)) := do\n    opr' \u2190 transform_negation e',\n    match opr' with\n    | none              := return (some (e', pr))\n    | (some (e'', pr')) := do pr'' \u2190 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 \u2190 infer_type h,\n   (_, e, pr) \u2190 simplify_top_down ()\n                   (\u03bb _, \u03bb e, do\n                       oepr \u2190 transform_negation cfg e,\n                       match oepr with\n                       | (some (e', pr)) := return ((), e', pr)\n                       | none            := do pr \u2190 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 \u2190 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 \u2190 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 \u2190 local_context,\n   first $ ctx.map $ \u03bb h,\n     do t \u2190 infer_type h >>= whnf_reducible,\n        guard (is_app_of t ``Exists),\n        tgt \u2190 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 \u2190 local_context,\n   first $ ctx.map $ \u03bb h,\n     do t \u2190 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 \u2192 expr \u2192 tactic bool :=\n\u03bb pr t,\nlet assert_consequences := \u03bb e t, mcond (add_conjuncts e t) skip (assertv_fresh t e >> skip) in\ndo t' \u2190 whnf_reducible t,\n   match t' with\n   | `(%%a \u2227 %%b) :=\n     do e\u2081 \u2190 mk_app ``and.left [pr],\n        assert_consequences e\u2081 a,\n        e\u2082 \u2190 mk_app ``and.right [pr],\n        assert_consequences e\u2082 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 \u2190 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 \u2192 tactic bool\n| []        := return ff\n| (h :: hs) := do b\u2081 \u2190 split_hyp h,\n                  b\u2082 \u2190 split_hyps_aux hs,\n                  return (b\u2081 || b\u2082)\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 \u2192 smt_tactic hinst_lemmas\n| []        := -- return hinst_lemmas.mk\n               do get_hinst_lemmas_for_attr `ematch\n| (h :: hs) := do his \u2190 mk_hinst_lemmas hs,\n                  t \u2190 infer_type h,\n                  match t with\n                  | (pi _ _ _ _) :=\n                    do t' \u2190 infer_type t,\n                       if t' = `(Prop) then\n                          (do new_lemma \u2190 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 \u2190 local_context,\n             hs \u2190 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 \u2192 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 \u2192 tactic unit) : tactic bool :=\ndo t \u2190 infer_type h,\n   match t with\n   | `(%%a \u2228 %%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 \u2192 tactic unit) :\n  list expr \u2192 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 \u2192 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 \u00d7 list name) (cfg : auto_config) : case_option \u2192 tactic unit :=\n\u03bb 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 \u00d7 list name) (cfg : auto_config := {}) : tactic unit :=\n  safe_core s cfg case_option.at_most_one\nmeta def safe (s : simp_lemmas \u00d7 list name) (cfg : auto_config := {}) : tactic unit :=\n  safe_core s cfg case_option.accept\nmeta def finish (s : simp_lemmas \u00d7 list name) (cfg : auto_config := {}) : tactic unit :=\n  safe_core s cfg case_option.force\n\nmeta def iclarify (s : simp_lemmas \u00d7 list name) (cfg : auto_config := {}) : tactic unit :=\n  clarify s {classical := ff, ..cfg}\nmeta def isafe (s : simp_lemmas \u00d7 list name) (cfg : auto_config := {}) : tactic unit :=\n  safe s {classical := ff, ..cfg}\nmeta def ifinish (s : simp_lemmas \u00d7 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 \u2190 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 \u2190 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 \u2190 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 \u2190 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 \u2190 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 \u2190 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": "theorem my_first_theorem\n(P : Prop) : P \u2192 P :=\nbegin\nintro,\nassumption,\nend\n", "meta": {"author": "UVM-M52", "repo": "lean-hdthomas", "sha": "1d399a5bb22544831ff466b2fe4cec38832b8ba6", "save_path": "github-repos/lean/UVM-M52-lean-hdthomas", "path": "github-repos/lean/UVM-M52-lean-hdthomas/lean-hdthomas-1d399a5bb22544831ff466b2fe4cec38832b8ba6/Testforpush.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.8080672135527631, "lm_q2_score": 0.5621765008857981, "lm_q1q2_score": 0.4542763985956293}}
{"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\u00f6lzl\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 {\u03b1 : Type u} [uniform_space \u03b1] [HasZero \u03b1] : HasZero (uniform_space.completion \u03b1) :=\n  { zero := \u21910 }\n\nprotected instance uniform_space.completion.has_neg {\u03b1 : Type u} [uniform_space \u03b1] [Neg \u03b1] : Neg (uniform_space.completion \u03b1) :=\n  { neg := uniform_space.completion.map fun (a : \u03b1) => -a }\n\nprotected instance uniform_space.completion.has_add {\u03b1 : Type u} [uniform_space \u03b1] [Add \u03b1] : Add (uniform_space.completion \u03b1) :=\n  { add := uniform_space.completion.map\u2082 Add.add }\n\nprotected instance uniform_space.completion.has_sub {\u03b1 : Type u} [uniform_space \u03b1] [Sub \u03b1] : Sub (uniform_space.completion \u03b1) :=\n  { sub := uniform_space.completion.map\u2082 Sub.sub }\n\n-- TODO: switch sides once #1103 is fixed\n\ntheorem uniform_space.completion.coe_zero {\u03b1 : Type u} [uniform_space \u03b1] [HasZero \u03b1] : \u21910 = 0 :=\n  rfl\n\nnamespace uniform_space.completion\n\n\ntheorem coe_neg {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] (a : \u03b1) : \u2191(-a) = -\u2191a :=\n  Eq.symm (map_coe uniform_continuous_neg a)\n\ntheorem coe_sub {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] (a : \u03b1) (b : \u03b1) : \u2191(a - b) = \u2191a - \u2191b :=\n  Eq.symm (map\u2082_coe_coe a b Sub.sub uniform_continuous_sub)\n\ntheorem coe_add {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] (a : \u03b1) (b : \u03b1) : \u2191(a + b) = \u2191a + \u2191b :=\n  Eq.symm (map\u2082_coe_coe a b Add.add uniform_continuous_add)\n\nprotected instance sub_neg_monoid {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : sub_neg_monoid (completion \u03b1) :=\n  sub_neg_monoid.mk Add.add sorry 0 sorry sorry Neg.neg Sub.sub\n\nprotected instance add_group {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : add_group (completion \u03b1) :=\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 {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : uniform_add_group (completion \u03b1) :=\n  uniform_add_group.mk (uniform_continuous_map\u2082 Sub.sub)\n\nprotected instance is_add_group_hom_coe {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] : is_add_group_hom coe :=\n  is_add_group_hom.mk\n\ntheorem is_add_group_hom_extension {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] {\u03b2 : Type v} [uniform_space \u03b2] [add_group \u03b2] [uniform_add_group \u03b2] [complete_space \u03b2] [separated_space \u03b2] {f : \u03b1 \u2192 \u03b2} [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 {\u03b1 : Type u_1} [uniform_space \u03b1] [add_group \u03b1] [uniform_add_group \u03b1] {\u03b2 : Type v} [uniform_space \u03b2] [add_group \u03b2] [uniform_add_group \u03b2] {f : \u03b1 \u2192 \u03b2} [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 \u03b2) hf)\n\nprotected instance add_comm_group {\u03b1 : Type u} [uniform_space \u03b1] [add_comm_group \u03b1] [uniform_add_group \u03b1] : add_comm_group (completion \u03b1) :=\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 Hw5\nimport Lean.Elab.Print\nimport Lean.Elab.Command\n\ntheorem desiredType (A B : Prop) : (A \u2192 B) \u2194 \u00ac A \u2228 B := sorry \n\nopen Lean\nopen Lean.Meta\nopen Lean.Elab.Command\n\ndef collectAxiomsOf (constName : Name) : MetaM (List String) := do\n  let env \u2190 getEnv\n  let (_, s) := ((CollectAxioms.collect constName).run env).run {}\n  let a := s.axioms.toList.map toString\n  return a\n\n#eval isDefEq (Expr.const ``desiredType []) (Expr.const ``problem4 [])\n#eval collectAxiomsOf ``problem4\n", "meta": {"author": "UofSC-Fall-2022-Math-300-H01", "repo": "homework5", "sha": "9775e690c2ffbaf37992f8441e2772e837306f15", "save_path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-homework5", "path": "github-repos/lean/UofSC-Fall-2022-Math-300-H01-homework5/homework5-9775e690c2ffbaf37992f8441e2772e837306f15/_Tests/Problem4.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.734119526900183, "lm_q2_score": 0.6187804337438501, "lm_q1q2_score": 0.45425879927512525}}
{"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 \u2208 G` is an element, then `equiv.group_mul g` is the self-equivalence\nof `G` defined by `h \u21a6 g * h`. -/\n@[to_additive \"If `G` is an additive group and `g \u2208 G` is an element, then `equiv.add_group_add g`\nis the self-equivalence of `G` defined by `h \u21a6 g + h`.\"]\ndef equiv.group_mul (g : G) : G \u2243 G :=\n  \u27e8\u03bb x, g * x, \u03bb x, g\u207b\u00b9 * x, by { intro, simp }, by { intro, simp }\u27e9\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\u207b\u00b9 * h := rfl\n\nvariables [has_le G] [covariant_class G G ((*)) (\u2264)]\n\n@[to_additive]\nlemma aux_ineq_mul {d e x : G} (hx : d \u2264 x) : e \u2264 e * d\u207b\u00b9 * x :=\ncalc  e \u2264 e * (d\u207b\u00b9 * x) : le_mul_of_one_le_right' (le_inv_mul_iff_le.mpr hx)\n    ... = e * d\u207b\u00b9 * 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 \u2264 x}` to `{x // e \u2264 x}` defined by `x \u21a6 e * d\u207b\u00b9 * 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 \u2264 x}` to `{x // e \u2264 x}` defined by `x \u21a6 e + (- d) + x`.\"]\ndef mul_inv_fun (d e : G) : {x // d \u2264 x} \u2192 {x // e \u2264 x} :=\n\u03bb \u27e8x, hx\u27e9, \u27e8_, aux_ineq_mul hx\u27e9\n\n@[to_additive]\nlemma mul_inv_fun_def (d e : G) (z : {x // d \u2264 x}) :\n  mul_inv_fun d e z = \u27e8_, aux_ineq_mul z.2\u27e9 :=\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 \u2218 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 \u2218 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 \u2264 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 \u2264 x} \u2243 {x // e \u2264 x}`. -/\n@[to_additive \"The function `add_neg_fun d e` bundled as an equivalence\n`{x // d \u2264 x} \u2243 {x // e \u2264 x}`.\"]\ndef equiv.mul_inv (d e : G) : {x // d \u2264 x} \u2243 {x // e \u2264 x} :=\n{ to_fun    := mul_inv_fun d e,\n  inv_fun   := mul_inv_fun e d,\n  left_inv  := \u03bb z, by simp,\n  right_inv := \u03bb z, by simp }\n\n@[simp, to_additive]\nlemma equiv.mul_inv_eval (d e : G) (x : {x // d \u2264 x}) :\n  equiv.mul_inv d e x = \u27e8e * d\u207b\u00b9 * x, aux_ineq_mul x.2\u27e9 :=\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 : \u2124 // 0 \u2264 x} \u2243 \u2115 :=\n{ to_fun := begin\n    rintro \u27e8x | y, hx\u27e9,\n    { exact x },\n    { exact ((int.neg_succ_not_nonneg _).mp hx).elim }\n  end,\n  inv_fun := \u03bb x, \u27e8x, int.coe_zero_le x\u27e9,\n  left_inv := begin\n    rintro \u27e8x | y, hx\u27e9,\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 := \u03bb x, rfl }\n\n@[simp]\nlemma int_subtype_nonneg_equiv_eval {z : {x : \u2124 // 0 \u2264 x}} :\n  int_subtype_nonneg_equiv z = int.to_nat z :=\nbegin\n  rcases z with \u27e8x | y, hz\u27e9,\n  { refl },\n  { exact ((int.neg_succ_not_nonneg _).mp hz).elim }\nend\n\n@[simp]\nlemma int.to_nat_subtype_nonneg {z : {x : \u2124 // 0 \u2264 x}} :\n  ((z : \u2124).to_nat : \u2124) = 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 : \u2115} : (int_subtype_nonneg_equiv.symm n : \u2124) = n := rfl\n\n/--  The subtype of nonnegative integers is equivalent to the natural number. -/\ndef int.nonneg_equiv_nat (d : \u2124) : {x : \u2124 // d \u2264 x} \u2243 \u2115 :=\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 : \u2115) : {x // d \u2264 x} \u2243 \u2115 :=\n{ to_fun    := \u03bb x, x.1 - d,\n  inv_fun   := \u03bb x, \u27e8x + d, le_add_self\u27e9,\n  left_inv  := by { rintro \u27e8x, hx\u27e9, simp only [nat.sub_add_cancel hx] },\n  right_inv := \u03bb 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 : \u21a5(set_of ((\u2264) (0 : \u2124)))\u1d9c \u2243 {z : \u2124 // z < 0} :=\n{ to_fun    := by { rintro \u27e8a, ha\u27e9, exact \u27e8a, by simpa using ha\u27e9 },\n  inv_fun   := by { rintro \u27e8a, ha\u27e9, exact \u27e8a, by simpa using ha\u27e9 },\n  left_inv  := by { rintro \u27e8a, ha\u27e9, simp },\n  right_inv := by { rintro \u27e8a, ha\u27e9, simp } }\n\n@[simp]\nlemma compl_le_symm_eval {x : {z : \u2124 // z < 0}} :\n  (compl_le.symm x : \u2124) = x :=\nby { cases x with x hx, refl }\n\nsection group\nvariables (\u03b1 : Type*)\n\nsection one_lt\nvariables [group \u03b1] [has_lt \u03b1] [covariant_class \u03b1 \u03b1 (*) (<)]\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 : \u03b1 | z < 1} \u2243 {z : \u03b1 | 1 < z} :=\n{ to_fun    := by { rintro \u27e8z, hz\u27e9, exact \u27e8z\u207b\u00b9, by simpa\u27e9 },\n  inv_fun   := by { rintro \u27e8z, hz\u27e9, exact \u27e8z\u207b\u00b9, by simpa\u27e9 },\n  left_inv  := by { rintro \u27e8z, hz\u27e9, simp },\n  right_inv := by { rintro \u27e8z, hz\u27e9, simp } }\n\nvariable {\u03b1}\n@[simp, to_additive]\nlemma equiv.lt_one_gt_one_eval {x : {z : \u03b1 | z < 1}} :\n  ((equiv.lt_one_gt_one \u03b1) x : \u03b1) = x\u207b\u00b9 :=\nby { cases x with x hx, refl }\n\n@[simp, to_additive]\nlemma equiv.lt_one_gt_one_symm_eval {x : {z : \u03b1 | 1 < z}} :\n  ((equiv.lt_one_gt_one \u03b1).symm x : \u03b1) = x\u207b\u00b9 :=\nby { cases x with x hx, refl }\n\nend one_lt\n\nsection one_le\nvariables [group \u03b1] [has_le \u03b1] [covariant_class \u03b1 \u03b1 (*) (\u2264)]\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 : \u03b1 | z \u2264 1} \u2243 {z : \u03b1 | 1 \u2264 z} :=\n{ to_fun    := by { rintro \u27e8z, hz\u27e9, exact \u27e8z\u207b\u00b9, by simpa\u27e9 },\n  inv_fun   := by { rintro \u27e8z, hz\u27e9, exact \u27e8z\u207b\u00b9, by simpa\u27e9 },\n  left_inv  := by { rintro \u27e8z, hz\u27e9, simp },\n  right_inv := by { rintro \u27e8z, hz\u27e9, simp } }\n\n\nvariable {\u03b1}\n\n@[simp, to_additive]\nlemma equiv.le_one_ge_one_eval {x : {z : \u03b1 | z \u2264 1}} :\n  ((equiv.le_one_ge_one \u03b1) x : \u03b1) = x\u207b\u00b9 :=\nby { cases x with x hx, refl }\n\n@[simp, to_additive]\nlemma equiv.le_one_ge_one_symm_eval {x : {z : \u03b1 | 1 \u2264 z}} :\n  ((equiv.le_one_ge_one \u03b1).symm x : \u03b1) = x\u207b\u00b9 :=\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 : \u2124 | 0 \u2264 z}\u1d9c : set \u2124) \u2243 \u2115 :=\ncompl_le.trans $ (equiv.neg_gt_zero \u2124).trans $ (equiv.add_neg 1 0).trans int_subtype_nonneg_equiv\n\n@[simp]\nlemma oppo_symm_eval {n : \u2115} : (oppo.symm n : \u2124) = - n - 1 :=\nby simp [oppo]\n\nsection topological_space\nvariables {\u03b1 : Type*} [topological_space \u03b1]\n\nsection add_comm_monoid\nvariables [add_comm_monoid \u03b1] {f : \u2124 \u2192 \u03b1}\n\nlemma my_summable_shift (f : \u2124 \u2192 \u03b1) (N : \u2124) :\n  summable (\u03bb x : \u2115, f (x + N)) \u2194 summable (\u03bb x : {x // N \u2264 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 {\u03b1 : Type*} [uniform_space \u03b1] [add_comm_group \u03b1] [uniform_add_group \u03b1] [complete_space \u03b1]\nvariable {f : \u2124 \u2192 \u03b1}\n\nlemma int_summable_iff :\n  summable f \u2194 summable (\u03bb n : \u2115, f n) \u2227 summable (\u03bb n : \u2115, f (- n - 1)) :=\nbegin\n  refine (@summable_subtype_and_compl \u03b1 _ _ _ _ _ _ {z : \u2124 | 0 \u2264 z}).symm.trans _,\n  rw [\u2190 equiv.summable_iff int_subtype_nonneg_equiv, \u2190 equiv.summable_iff oppo.symm],\n  refine \u27e8_, _\u27e9;\n  rintro \u27e8h1, h2\u27e9;\n  refine \u27e8_, _\u27e9;\n  refine summable.congr \u2039_\u203a (\u03bb 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 : \u2115 \u2192 \u211d} {\u03c1 \u03c3 : \u211d\u22650}\n  (hf : summable (\u03bb n, f n * \u03c1 ^ n)) (\u03c3\u03c1 : \u03c3 \u2264 \u03c1) (f0 : \u2200 n, 0 \u2264 f n) :\n  summable (\u03bb n, f n * \u03c3 ^ n) :=\nbegin\n  refine summable_of_nonneg_of_le (\u03bb b, mul_nonneg (f0 _) (pow_nonneg zero_le_coe _)) _ hf,\n  exact \u03bb b, mul_le_mul rfl.le\n    (pow_le_pow_of_le_left zero_le_coe \u03c3\u03c1 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 : \u2115 \u00d7 \u2115 // x.2 \u2264 x.1} \u2243 \u2115 \u00d7 \u2115 :=\n{ to_fun    := \u03bb x, (x.1.1 - x.1.2, x.1.2 ),\n  inv_fun   := \u03bb x, \u27e8(x.1 + x.2, x.2), by simp\u27e9,\n  left_inv  := by { rintros \u27e8x, hx\u27e9, simp only [nat.sub_add_cancel hx, prod.mk.eta] },\n  right_inv := by { rintros \u27e8x, y\u27e9, simp only [add_tsub_cancel_right] } }\n\nlemma _root_.summable.prod_nat {f : \u2124 \u2192 \u211d} {g : \u2115 \u2192 \u211d} (hf : summable f) (f0 : \u2200 n, 0 \u2264 f n)\n  (hg : summable g) (g0 : \u2200 n, 0 \u2264 g n) :\n  summable (\u03bb lj: \u2115 \u00d7 \u2115, f (lj.fst + lj.snd) * g lj.snd) :=\nbegin\n  apply (equiv.summable_iff equiv_nat_diag).mp,\n  suffices : summable (\u03bb (lj : {x : \u2115 \u00d7 \u2115 // x.2 \u2264 x.1}), f lj.1.fst * g lj.1.snd),\n  { convert this,\n    ext \u27e8\u27e8x, y\u27e9, hx\u27e9,\n    suffices : f (\u2191(x - y) + \u2191y) * g y = f \u2191x * g y, by simpa [equiv_nat_diag],\n    rw_mod_cast nat.sub_add_cancel hx },\n  apply summable.subtype (_ : summable (\u03bb (lj : \u2115 \u00d7 \u2115), f lj.fst * g lj.snd)),\n  convert summable_mul_of_summable_norm (_ : summable (\u03bb i : \u2115, \u2225f i\u2225)) _,\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 : \u2124 \u2192 \u211d} {s r : \u211d\u22650}\n  (s1 : s < 1) (hf : summable (\u03bb n : \u2124, \u2225 f n \u2225 * r ^ n)) :\n  summable (\u03bb lj: \u2115 \u00d7 \u2115, \u2225(f (lj.fst + 1 + lj.snd)) * r ^ (lj.fst + 1 + lj.snd)\u2225 * s^ lj.snd) :=\nbegin\n  apply summable_of_summable_norm,\n  simp_rw [norm_mul, norm_norm],\n  convert (_ : summable (\u03bb n, \u2225f (n + 1)\u2225 * 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 : \u2124), add_right_comm _ 1 _] },\n  { let add_one : \u2124 \u2243 \u2124 := \u27e8\u03bb x, x - 1, \u03bb x, x + 1, \u03bb x, by simp, \u03bb x, by simp\u27e9,\n    apply add_one.summable_iff.mp,\n    convert hf,\n    ext,\n    simp },\n  { exact \u03bb 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 \u2192 (p \u2192 q) \u2192 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 \u2192 Q) \u2192 (\u00ac Q \u2192 \u00ac 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 ` \u2218 `:80 g:80 := g \u226b f\n\nuniverse u\n\nnamespace homotopy_theory.topological_spaces\n\nnamespace Set\nlocal notation `Set` := Type u\n\ndef mk_ob (\u03b1 : Set) : Set := \u03b1\n\ndef incl' {\u03b1 : Set} (A B : set \u03b1) (h : A \u2286 B) : mk_ob A \u27f6 mk_ob B :=\n\u03bb p, \u27e8p.val, h p.property\u27e9\n\nsection inter_union\nvariables {X : Set} {A\u2080 A\u2081 : set X}\n\nlocal notation `A\u2080\u2081` := A\u2080 \u2229 A\u2081\nlocal notation `A` := (A\u2080 \u222a A\u2081 : set X)\n\nlocal notation `i\u2080` := incl' A\u2080\u2081 A\u2080 (set.inter_subset_left A\u2080 A\u2081)\nlocal notation `i\u2081` := incl' A\u2080\u2081 A\u2081 (set.inter_subset_right A\u2080 A\u2081)\nlocal notation `j\u2080` := incl' A\u2080 A (set.subset_union_left A\u2080 A\u2081)\nlocal notation `j\u2081` := incl' A\u2081 A (set.subset_union_right A\u2080 A\u2081)\n\nsection glue\nvariables \u2983\u03b2 : Set\u2984 (h\u2080 : mk_ob A\u2080 \u27f6 \u03b2) (h\u2081 : mk_ob A\u2081 \u27f6 \u03b2)\nvariable (e : h\u2080 \u2218 i\u2080 = h\u2081 \u2218 i\u2081)\ninclude e\n\nlocal attribute [instance] classical.prop_decidable\n\nnoncomputable def glue : mk_ob A \u27f6 \u03b2 :=\n\u03bb a, if h : a.val \u2208 A\u2080 then h\u2080 \u27e8a.val, h\u27e9 else h\u2081 \u27e8a.val, a.property.resolve_left h\u27e9\n\nlemma glue_commutes\u2080 : glue h\u2080 h\u2081 e \u2218 j\u2080 = h\u2080 :=\nby funext a; have := a.property; simp [glue, incl', this]\n\nlemma glue_commutes\u2081 : glue h\u2080 h\u2081 e \u2218 j\u2081 = h\u2081 :=\nbegin\n  funext a, change (if h : _ then _ else _) = h\u2081 a, cases a with v p,\n  split_ifs, { exact congr_fun e \u27e8v, h, p\u27e9 }, { refl }\nend\n\nend glue\n\nlemma uniqueness \u2983\u03b2 : Set\u2984 (k k' : mk_ob A \u27f6 \u03b2)\n  (e\u2080 : k \u2218 j\u2080 = k' \u2218 j\u2080) (e\u2081 : k \u2218 j\u2081 = k' \u2218 j\u2081) : k = k' :=\nbegin\n  funext a, rcases a with \u27e8v, p\u2080|p\u2081\u27e9,\n  { exact @@congr_fun _ _ _ e\u2080 \u27e8v, p\u2080\u27e9 },\n  { exact @@congr_fun _ _ _ e\u2081 \u27e8v, p\u2081\u27e9 }\nend\n\nvariables (A\u2080 A\u2081)\ninclude A\u2080 A\u2081\nnoncomputable def Is_pushout_inter_union : Is_pushout i\u2080 i\u2081 j\u2080 j\u2081 :=\nIs_pushout.mk' rfl glue glue_commutes\u2080 glue_commutes\u2081 uniqueness\n\nend inter_union\n\nend \u00abSet\u00bb\n\n\nnamespace Top\nlocal notation `Top` := Top.{u}\n\nsection inter_union\nvariables {X : Top} {A\u2080 A\u2081 : set X} (ha\u2080 : is_closed A\u2080) (ha\u2081 : is_closed A\u2081)\n-- Other assumptions are possible, e.g., A\u2080, A\u2081 both open.\n\nlocal notation `A\u2080\u2081` := A\u2080 \u2229 A\u2081\nlocal notation `A` := (A\u2080 \u222a A\u2081 : set X)\n\nlocal notation `i\u2080` := incl' A\u2080\u2081 A\u2080 (set.inter_subset_left A\u2080 A\u2081)\nlocal notation `i\u2081` := incl' A\u2080\u2081 A\u2081 (set.inter_subset_right A\u2080 A\u2081)\nlocal notation `j\u2080` := incl' A\u2080 A (set.subset_union_left A\u2080 A\u2081)\nlocal notation `j\u2081` := incl' A\u2081 A (set.subset_union_right A\u2080 A\u2081)\nlocal notation `i'\u2080` := Set.incl' A\u2080\u2081 A\u2080 (set.inter_subset_left A\u2080 A\u2081)\nlocal notation `i'\u2081` := Set.incl' A\u2080\u2081 A\u2081 (set.inter_subset_right A\u2080 A\u2081)\nlocal notation `j'\u2080` := Set.incl' A\u2080 A (set.subset_union_left A\u2080 A\u2081)\nlocal notation `j'\u2081` := Set.incl' A\u2081 A (set.subset_union_right A\u2080 A\u2081)\n\nlocal notation [parsing_only] a ` ~~ ` b := Bij_on _ a b\n\ninstance Set.mk_ob.topological_space (\u03b1 : Type*) [t : topological_space \u03b1] :\n  topological_space (Set.mk_ob \u03b1) := t\n\nlemma continuous_iff {Z : Top} (k : A \u2192 Z) :\n  continuous k \u2194 continuous (k \u2218 j'\u2080) \u2227 continuous (k \u2218 j'\u2081) :=\niff.intro (assume h, \u27e8by continuity!, by continuity!\u27e9)\n  (assume \u27e8h\u2080, h\u2081\u27e9,\n    let c : bool \u2192 set A := \u03bb i, bool.rec_on i {a | a.val \u2208 A\u2080} {a | a.val \u2208 A\u2081} in\n    have h_lf : locally_finite c :=\n      locally_finite_of_finite \u27e8fintype.of_equiv _ (equiv.set.univ bool).symm\u27e9,\n    have h_is_closed : \u2200 i, is_closed (c i) :=\n      assume i, bool.rec_on i\n        (continuous_iff_is_closed.mp continuous_subtype_val _ ha\u2080)\n        (continuous_iff_is_closed.mp continuous_subtype_val _ ha\u2081),\n    have h_cover : \u2200 a, \u2203 i, a \u2208 c i :=\n      assume a, a.property.elim (\u03bb h, \u27e8ff, h\u27e9) (\u03bb h, \u27e8tt, h\u27e9),\n    have f_cont : \u2200 i, continuous (\u03bb (x : subtype (c i)), k x.val) :=\n      assume i, bool.rec_on i\n        (have continuous (function.comp (k \u2218 j'\u2080) (\u03bb (x : subtype (c ff)), \u27e8x.val.val, x.property\u27e9)),\n          by continuity, begin convert this, funext x, rcases x with \u27e8\u27e8_, _\u27e9, _\u27e9, refl end)\n        (have continuous (function.comp (k \u2218 j'\u2081) (\u03bb (x : subtype (c tt)), \u27e8x.val.val, x.property\u27e9)),\n          by continuity, begin convert this, funext x, rcases x with \u27e8\u27e8_, _\u27e9, _\u27e9, refl end),\n    continuous_subtype_is_closed_cover c h_lf h_is_closed h_cover f_cont)\n\nvariables (A\u2080 A\u2081)\ninclude A\u2080 A\u2081\nnoncomputable def Is_pushout_inter_union : Is_pushout i\u2080 i\u2081 j\u2080 j\u2081 :=\nIs_pushout.mk $ \u03bb Z, calc\n  univ ~~ {k : {k : A \u2192 Z // continuous k} | true}\n       : Bij_on.of_equiv (Top.hom_equiv_subtype (Top.mk_ob A) Z)\n   ... ~~ {k : {k : A \u2192 Z // continuous (k \u2218 j'\u2080) \u2227 continuous (k \u2218 j'\u2081)} | true}\n       : Bij_on.congr_subtype (ext (continuous_iff ha\u2080 ha\u2081))\n   ... ~~ {p : {p : (A\u2080 \u2192 Z) \u00d7 (A\u2081 \u2192 Z) // continuous p.1 \u2227 continuous p.2} | p.val.1 \u2218 i'\u2080 = p.val.2 \u2218 i'\u2081}\n       : ((Set.Is_pushout_inter_union A\u2080 A\u2081).universal Z).restrict_to_subtype (\u03bb p, continuous p.1 \u2227 continuous p.2)\n   ... ~~ {p : {f\u2080 : Top.mk_ob A\u2080 \u2192 Z // continuous f\u2080} \u00d7\n               {f\u2081 : Top.mk_ob A\u2081 \u2192 Z // continuous f\u2081} |\n           (Top.hom_equiv_subtype _ _).symm p.1 \u2218 i\u2080 = (Top.hom_equiv_subtype _ _).symm p.2 \u2218 i\u2081}\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\u2080 \u27f6 Z) \u00d7 (Top.mk_ob A\u2081 \u27f6 Z) | p.1 \u2218 i\u2080 = p.2 \u2218 i\u2081}\n       : by {\n           convert Bij_on.restrict_equiv\n             ((Top.hom_equiv_subtype (Top.mk_ob A\u2080) Z).prod_congr\n              (Top.hom_equiv_subtype (Top.mk_ob A\u2081) Z)).symm\n             _,\n           ext \u27e8_, _\u27e9, refl }\n\nlocal notation `k\u2080` := incl A\u2080\nlocal notation `k\u2081` := incl A\u2081\nvariables (h : A\u2080 \u222a A\u2081 = univ)\n\ninclude h\ndef union_is_X : homeomorphism (Top.mk_ob A) X :=\n{ hom := incl _,\n  inv := Top.mk_hom (\u03bb x, \u27e8x, by rw h; exact trivial\u27e9) (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\u2080 i\u2081 k\u2080 k\u2081 :=\nIs_pushout_of_isomorphic'\n  (Is_pushout_inter_union A\u2080 A\u2081 ha\u2080 ha\u2081) (union_is_X A\u2080 A\u2081 h)\n\nend inter_union\n\nend \u00abTop\u00bb\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 : \u2115} -- ^ Output length\n                (blen : \u2115) -- ^ Block length\n                (hash : list byte \u2192 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 \u2265 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 \u2192 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 := \u27e8 hash_algorithm.to_string \u27e9\n\n/- hash length in bytes -/\ndefinition hash_length : hash_algorithm \u2192 \u2115\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 \u2264 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) : \u2115 :=\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 : \u2115) (v : bitvec (8 * m)) : list byte := cast rfl (@bitvec.split_vector 8 m v)\n\nprotected\nlemma length_to_byte_list (m : \u2115) (v : bitvec (8 * m)) : (to_byte_list m v).length = m :=\nvector.length_split_vector _ _\n\ndef nat_224_decompose : bitvec 224 \u2192 list byte := @to_byte_list 28\ndef nat_256_decompose : bitvec 256 \u2192 list byte := @to_byte_list 32\ndef nat_384_decompose : bitvec 384 \u2192 list byte := @to_byte_list 48\ndef nat_512_decompose : bitvec 512 \u2192 list byte := @to_byte_list 64\n\ndefinition hash : hash_algorithm \u2192 list byte \u2192 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: \u2200 (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  \u27e8 hash algo data, length_hash_is_hash_length algo data \u27e9\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\u2081 path\u2082 : Path graph start) :=\n  path\u2081.prefix? = path\u2082\n\ninfix:35 \" \u227b \" => Succ\n\ntheorem Succ.isCons : (path\u2081 \u227b path\u2082) \u2192 path\u2081.isCons :=\n  fun h => prefix?_isSome_iff_isCons.mp (Option.isSome_iff_exists.mpr \u27e8_, h\u27e9)\n\ntheorem Succ.isCons' : (cons c\u2081 (cons c\u2082 path\u2081) \u227b path\u2082) \u2192 path\u2082.isCons := by\n  intro h\n  have \u27e8subpath, hp\u27e9 := prefix?_isSome_iff_isCons.mpr (@isCons_of_cons _ _ c\u2082 path\u2081) |> Option.isSome_iff_exists.mp\n  simp [Succ, prefix?, hp] at h\n  simp [isCons_def]\n  exists c\u2081, subpath\n  injection h with h\n  exact h.symm\n\ntheorem Succ.iff_cons_Succ {path\u2081 path\u2082} : \n  (path\u2081 \u227b path\u2082) \u2194 (cons child path\u2081) \u227b (cons child path\u2082) :=\n  prefix?_iff_cons_prefix?\n\ntheorem Succ.nil : (cons child nil) \u227b nil := rfl\n\ninstance : Decidable (path\u2081 \u227b path\u2082) := \n  if h : path\u2081.prefix? = path\u2082 then isTrue h else isFalse h\n\ntheorem Succ.cons (path\u2081) : \u2203 path\u2082, (cons child path\u2081) \u227b path\u2082 := by\n  cases h : (Path.cons child path\u2081).prefix?\n  case none =>\n    have h : \u00ac(Path.cons child path\u2081).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 \u27f6 B` and `g : B \u27f6 C`\nare exact if `f \u226b g = 0` and the natural map `image f \u27f6 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.\u03b9 f` is a kernel of `g` or that\nthe map `image f \u27f6 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.\u03b9 s \u226b cofork.\u03c0 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 \u226b i.hom` and `i.inv \u226b 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 \u27f6 B`, `g : B \u27f6 C` are called exact if `f \u226b g = 0` and the natural map\n    `image f \u27f6 kernel g` is an epimorphism. -/\nclass exact {A B C : V} (f : A \u27f6 B) (g : B \u27f6 C) : Prop :=\n(w : f \u226b 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 \u27f6 B} {g : B \u27f6 C} {h : C \u27f6 D}\n\nlemma exact_comp_hom_inv_comp [exact f g] (i : B \u2245 D) : exact (f \u226b i.hom) (i.inv \u226b g) :=\nbegin\n  refine \u27e8by simp, _\u27e9,\n  rw image_to_kernel_map_comp_hom_inv_comp,\n  haveI : epi (image_to_kernel_map f g exact.w \u226b (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 \u2245 D) : exact (f \u226b i.hom) (i.inv \u226b g) \u2194 exact f g :=\nbegin\n  refine \u27e8_, by { introI, exact exact_comp_hom_inv_comp i }\u27e9,\n  introI,\n  have : exact ((f \u226b i.hom) \u226b i.inv) (i.hom \u226b i.inv \u226b 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 \u226b g) h :=\nbegin\n  refine \u27e8by simp, _\u27e9,\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 \u226b h) :=\nbegin\n  refine \u27e8by simp, _\u27e9,\n  letI : is_iso (kernel.lift (g \u226b h) (kernel.\u03b9 g) (by simp)) :=\n    \u27e8\u27e8kernel.lift g (kernel.\u03b9 (g \u226b h)) (by simp [\u2190cancel_mono h]), by tidy\u27e9\u27e9,\n  rw image_to_kernel_map_comp_right f g h exact.w,\n  exact epi_comp _ _\nend\n\nlemma exact_kernel : exact (kernel.\u03b9 f) f :=\nbegin\n  refine \u27e8kernel.condition _, _\u27e9,\n  letI : is_iso (image_to_kernel_map (kernel.\u03b9 f) f (kernel.condition f)) :=\n    \u27e8\u27e8factor_thru_image (kernel.\u03b9 f),\n      \u27e8by simp [\u2190cancel_mono (image.\u03b9 (kernel.\u03b9 f))], by tidy\u27e9\u27e9\u27e9,\n  apply_instance\nend\n\nsection\nvariables (A)\n\nlemma kernel_\u03b9_eq_zero_of_exact_zero_left [exact (0 : A \u27f6 B) g] : kernel.\u03b9 g = 0 :=\nbegin\n  rw [\u2190cancel_epi (image_to_kernel_map (0 : A \u27f6 B) g exact.w),\n    \u2190cancel_epi (factor_thru_image (0 : A \u27f6 B))],\n  simp\nend\n\nlemma exact_zero_left_of_mono [has_zero_object V] [mono g] : exact (0 : A \u27f6 B) g :=\n\u27e8by simp, image_to_kernel_map_epi_of_zero_of_mono _\u27e9\n\nend\n\nend\n\nsection has_cokernels\nvariables [has_cokernels V] {A B C : V} (f : A \u27f6 B) (g : B \u27f6 C)\n\n@[simp, reassoc] lemma kernel_comp_cokernel [exact f g] : kernel.\u03b9 g \u226b cokernel.\u03c0 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} {\u03b9 : X \u27f6 B} (h\u03b9 : \u03b9 \u226b g = 0) {\u03c0 : B \u27f6 Y}\n  (h\u03c0 : f \u226b \u03c0 = 0) : \u03b9 \u226b \u03c0 = 0 :=\nby rw [\u2190kernel.lift_\u03b9 _ _ h\u03b9, \u2190cokernel.\u03c0_desc _ _ h\u03c0, category.assoc, kernel_comp_cokernel_assoc,\n  zero_comp, comp_zero]\n\n@[simp, reassoc] lemma fork_\u03b9_comp_cofork_\u03c0 [exact f g] (s : kernel_fork g)\n  (t : cokernel_cofork f) : fork.\u03b9 s \u226b cofork.\u03c0 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 \u27f6 0) (g : 0 \u27f6 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 \u2297[R] N)\n/-- (implementation) tensor product of morphisms R-modules -/\ndef tensor_hom {M N M' N' : Module R} (f : M \u27f6 N) (g : M' \u27f6 N') :\n  tensor_obj M M' \u27f6 tensor_obj N N' :=\ntensor_product.map f g\n\nlemma tensor_id (M N : Module R) : tensor_hom (\ud835\udfd9 M) (\ud835\udfd9 N) = \ud835\udfd9 (Module.of R (\u21a5M \u2297 \u21a5N)) :=\nby tidy\n\nlemma tensor_comp {X\u2081 Y\u2081 Z\u2081 X\u2082 Y\u2082 Z\u2082 : Module R}\n  (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (g\u2081 : Y\u2081 \u27f6 Z\u2081) (g\u2082 : Y\u2082 \u27f6 Z\u2082) :\n    tensor_hom (f\u2081 \u226b g\u2081) (f\u2082 \u226b g\u2082) = tensor_hom f\u2081 f\u2082 \u226b tensor_hom g\u2081 g\u2082 :=\nby tidy\n\n/-- (implementation) the associator for R-modules -/\ndef associator (M N K : Module R) : tensor_obj (tensor_obj M N) K \u2245 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\u2081 X\u2082 X\u2083 : Type*}\n  [add_comm_monoid X\u2081] [add_comm_monoid X\u2082] [add_comm_monoid X\u2083]\n  [module R X\u2081] [module R X\u2082] [module R X\u2083]\n  {Y\u2081 Y\u2082 Y\u2083 : Type*}\n  [add_comm_monoid Y\u2081] [add_comm_monoid Y\u2082] [add_comm_monoid Y\u2083]\n  [module R Y\u2081] [module R Y\u2082] [module R Y\u2083]\n  (f\u2081 : X\u2081 \u2192\u2097[R] Y\u2081) (f\u2082 : X\u2082 \u2192\u2097[R] Y\u2082) (f\u2083 : X\u2083 \u2192\u2097[R] Y\u2083) :\n  (\u2191(assoc R Y\u2081 Y\u2082 Y\u2083) \u2218\u2097 (map (map f\u2081 f\u2082) f\u2083)) = ((map f\u2081 (map f\u2082 f\u2083)) \u2218\u2097 \u2191(assoc R X\u2081 X\u2082 X\u2083)) :=\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 \u2192\u2097[R] W) (assoc R X Y Z).to_linear_map).comp (assoc R W (X \u2297[R] Y) Z).to_linear_map)\n    .comp (map \u2191(assoc R W X Y) (1 : Z \u2192\u2097[R] Z)) =\n  (assoc R W X (Y \u2297[R] Z)).to_linear_map.comp (assoc R (W \u2297[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\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : Module R}\n  (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083) :\n    tensor_hom (tensor_hom f\u2081 f\u2082) f\u2083 \u226b (associator Y\u2081 Y\u2082 Y\u2083).hom =\n    (associator X\u2081 X\u2082 X\u2083).hom \u226b tensor_hom f\u2081 (tensor_hom f\u2082 f\u2083) :=\nby convert associator_naturality_aux f\u2081 f\u2082 f\u2083 using 1\n\nlemma pentagon (W X Y Z : Module R) :\n  tensor_hom (associator W X Y).hom (\ud835\udfd9 Z) \u226b (associator W (tensor_obj X Y) Z).hom\n  \u226b tensor_hom (\ud835\udfd9 W) (associator X Y Z).hom =\n    (associator (tensor_obj W X) Y Z).hom \u226b (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 \u2297[R] M) \u2245 M :=\n(linear_equiv.to_Module_iso (tensor_product.lid R M) : of R (R \u2297 M) \u2245 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 \u2297[R] R) \u2245 M :=\n(linear_equiv.to_Module_iso (tensor_product.rid R M) : of R (M \u2297 R) \u2245 of R M).trans (of_self_iso M)\n\nlemma right_unitor_naturality {M N : Module R} (f : M \u27f6 N) :\n  tensor_hom f (\ud835\udfd9 (Module.of R R)) \u226b (right_unitor N).hom = (right_unitor M).hom \u226b 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 \u226b tensor_hom (\ud835\udfd9 M) (left_unitor N).hom =\n    tensor_hom (right_unitor M).hom (\ud835\udfd9 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'               := \u03bb M N, tensor_id M N,\n  tensor_comp'             := \u03bb M N K M' N' K' f g h, tensor_comp f g h,\n  associator_naturality'   := \u03bb M N K M' N' K' f g h, associator_naturality f g h,\n  left_unitor_naturality'  := \u03bb M N f, left_unitor_naturality f,\n  right_unitor_naturality' := \u03bb M N f, right_unitor_naturality f,\n  pentagon'                := \u03bb M N K L, pentagon M N K L,\n  triangle'                := \u03bb M N, triangle M N, }\n\n/-- Remind ourselves that the monoidal unit, being just `R`, is still a commutative ring. -/\ninstance : comm_ring ((\ud835\udfd9_ (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 \u27f6 L) (g : M \u27f6 N) (k : K) (m : M) :\n  (f \u2297 g) (k \u2297\u209c m) = f k \u2297\u209c g m := rfl\n\n@[simp]\nlemma left_unitor_hom_apply {M : Module.{u} R} (r : R) (m : M) :\n  ((\u03bb_ M).hom : \ud835\udfd9_ (Module R) \u2297 M \u27f6 M) (r \u2297\u209c[R] m) = r \u2022 m :=\ntensor_product.lid_tmul m r\n\n@[simp]\nlemma left_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((\u03bb_ M).inv : M \u27f6 \ud835\udfd9_ (Module.{u} R) \u2297 M) m = 1 \u2297\u209c[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  ((\u03c1_ M).hom : M \u2297 \ud835\udfd9_ (Module R) \u27f6 M) (m \u2297\u209c r) = r \u2022 m :=\ntensor_product.rid_tmul m r\n\n@[simp]\nlemma right_unitor_inv_apply {M : Module.{u} R} (m : M) :\n  ((\u03c1_ M).inv : M \u27f6 M \u2297 \ud835\udfd9_ (Module.{u} R)) m = m \u2297\u209c[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  ((\u03b1_ M N K).hom : (M \u2297 N) \u2297 K \u27f6 M \u2297 (N \u2297 K)) ((m \u2297\u209c n) \u2297\u209c k) = (m \u2297\u209c (n \u2297\u209c k)) := rfl\n\n@[simp]\nlemma associator_inv_apply {M N K : Module.{u} R} (m : M) (n : N) (k : K) :\n  ((\u03b1_ M N K).inv : M \u2297 (N \u2297 K) \u27f6 (M \u2297 N) \u2297 K) (m \u2297\u209c (n \u2297\u209c k)) = ((m \u2297\u209c n) \u2297\u209c k) := rfl\n\nend monoidal_category\n\n/-- (implementation) the braiding for R-modules -/\ndef braiding (M N : Module R) : tensor_obj M N \u2245 tensor_obj N M :=\nlinear_equiv.to_Module_iso (tensor_product.comm R M N)\n\n@[simp] lemma braiding_naturality {X\u2081 X\u2082 Y\u2081 Y\u2082 : Module.{u} R} (f : X\u2081 \u27f6 Y\u2081) (g : X\u2082 \u27f6 Y\u2082) :\n  (f \u2297 g) \u226b (Y\u2081.braiding Y\u2082).hom =\n    (X\u2081.braiding X\u2082).hom \u226b (g \u2297 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  (\u03b1_ X Y Z).hom \u226b (braiding X _).hom \u226b (\u03b1_ Y Z X).hom =\n  ((braiding X Y).hom \u2297 \ud835\udfd9 Z) \u226b (\u03b1_ Y X Z).hom \u226b (\ud835\udfd9 Y \u2297 (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  (\u03b1_ X Y Z).inv \u226b (braiding _ Z).hom \u226b (\u03b1_ Z X Y).inv =\n  (\ud835\udfd9 X \u2297 (Y.braiding Z).hom) \u226b (\u03b1_ X Z Y).inv \u226b ((X.braiding Z).hom \u2297 \ud835\udfd9 Y) :=\nbegin\n  apply (cancel_epi (\u03b1_ 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' := \u03bb X\u2081 X\u2082 Y\u2081 Y\u2082 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  ((\u03b2_ M N).hom : M \u2297 N \u27f6 N \u2297 M) (m \u2297\u209c n) = n \u2297\u209c m := rfl\n\n@[simp] lemma braiding_inv_apply {M N : Module.{u} R} (m : M) (n : N) :\n  ((\u03b2_ M N).inv : N \u2297 M \u27f6 M \u2297 N) (n \u2297\u209c m) = m \u2297\u209c 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 \u27f6 P) \u2243\n    (N \u27f6 ((linear_coyoneda R (Module R)).obj (op M)).obj P) :=\n{ to_fun := \u03bb f, linear_map.compr\u2082 (tensor_product.mk R N M) ((\u03b2_ N M).hom \u226b f),\n  inv_fun := \u03bb f, (\u03b2_ M N).hom \u226b tensor_product.lift f,\n  left_inv := \u03bb f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr\u2082_apply,\n      function.comp_app, coe_comp, monoidal_category.braiding_hom_apply],\n  end,\n  right_inv := \u03bb f, begin ext m n,\n    simp only [tensor_product.mk_apply, tensor_product.lift.tmul, linear_map.compr\u2082_apply,\n      symmetric_category.symmetry_assoc],\n  end, }\n\ninstance : monoidal_closed (Module.{u} R) :=\n{ closed' := \u03bb 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 := \u03bb 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 \u2297 N \u27f6 P) (x : M) (y : N) :\n  @coe_fn _ _ linear_map.has_coe_to_fun ((monoidal_closed.curry f : N \u2192\u2097[R] (M \u2192\u2097[R] P)) y) x =\n    f (x \u2297\u209c[R] y) :=\nrfl\n\n@[simp]\nlemma monoidal_closed_uncurry {M N P : Module.{u} R}\n  (f : N \u27f6 (M \u27f6[Module.{u} R] P)) (x : M) (y : N) :\n  monoidal_closed.uncurry f (x \u2297\u209c[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 \u2192 Y) (g : Y \u2192 Z) : surjective (g \u2218 f) \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 {\u03b1 \u03b2 \u03b3 \u03b9 \u03b9' : Type _} {r p q : \u03b1 \u2192 \u03b1 \u2192 Prop}\n\nsection Pairwise\n\nvariable {f g : \u03b9 \u2192 \u03b1} {s t u : Set \u03b1} {a b : \u03b1}\n\nnamespace Set\n\n/- warning: set.pairwise_Union -> Set.pairwise_union\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {r : \u03b1 -> \u03b1 -> Prop} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Directed.{u1, succ u2} (Set.{u1} \u03b1) \u03b9 (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1)) f) -> (Iff (Set.Pairwise.{u1} \u03b1 (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (n : \u03b9) => f n)) r) (forall (n : \u03b9), Set.Pairwise.{u1} \u03b1 (f n) r))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Type.{u1}} {r : \u03b1 -> \u03b1 -> Prop} {f : \u03b9 -> (Set.{u2} \u03b1)}, (Directed.{u2, succ u1} (Set.{u2} \u03b1) \u03b9 (fun (x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.120 : Set.{u2} \u03b1) (x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.122 : Set.{u2} \u03b1) => HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.120 x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.122) f) -> (Iff (Set.Pairwise.{u2} \u03b1 (Set.union\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (n : \u03b9) => f n)) r) (forall (n : \u03b9), Set.Pairwise.{u2} \u03b1 (f n) r))\nCase conversion may be inaccurate. Consider using '#align set.pairwise_Union Set.pairwise_union\u1d62\u2093'. -/\ntheorem pairwise_union\u1d62 {f : \u03b9 \u2192 Set \u03b1} (h : Directed (\u00b7 \u2286 \u00b7) f) :\n    (\u22c3 n, f n).Pairwise r \u2194 \u2200 n, (f n).Pairwise r :=\n  by\n  constructor\n  \u00b7 intro H n\n    exact Pairwise.mono (subset_Union _ _) H\n  \u00b7 intro H i hi j hj hij\n    rcases mem_Union.1 hi with \u27e8m, hm\u27e9\n    rcases mem_Union.1 hj with \u27e8n, hn\u27e9\n    rcases h m n with \u27e8p, mp, np\u27e9\n    exact H p (mp hm) (np hn) hij\n#align set.pairwise_Union Set.pairwise_union\u1d62\n\n#print Set.pairwise_union\u209b /-\ntheorem pairwise_union\u209b {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : Set (Set \u03b1)} (h : DirectedOn (\u00b7 \u2286 \u00b7) s) :\n    (\u22c3\u2080 s).Pairwise r \u2194 \u2200 a \u2208 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\u209b\n-/\n\nend Set\n\nend Pairwise\n\nnamespace Set\n\nsection PartialOrderBot\n\nvariable [PartialOrder \u03b1] [OrderBot \u03b1] {s t : Set \u03b9} {f g : \u03b9 \u2192 \u03b1}\n\n/- warning: set.pairwise_disjoint_Union -> Set.pairwiseDisjoint_union\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {\u03b9' : Type.{u3}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : OrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1))] {f : \u03b9 -> \u03b1} {g : \u03b9' -> (Set.{u2} \u03b9)}, (Directed.{u2, succ u3} (Set.{u2} \u03b9) \u03b9' (HasSubset.Subset.{u2} (Set.{u2} \u03b9) (Set.hasSubset.{u2} \u03b9)) g) -> (Iff (Set.PairwiseDisjoint.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_2 (Set.union\u1d62.{u2, succ u3} \u03b9 \u03b9' (fun (n : \u03b9') => g n)) f) (forall {{n : \u03b9'}}, Set.PairwiseDisjoint.{u1, u2} \u03b1 \u03b9 _inst_1 _inst_2 (g n) f))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u3}} {\u03b9' : Type.{u2}} [_inst_1 : PartialOrder.{u1} \u03b1] [_inst_2 : OrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 _inst_1))] {f : \u03b9 -> \u03b1} {g : \u03b9' -> (Set.{u3} \u03b9)}, (Directed.{u3, succ u2} (Set.{u3} \u03b9) \u03b9' (fun (x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.443 : Set.{u3} \u03b9) (x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.445 : Set.{u3} \u03b9) => HasSubset.Subset.{u3} (Set.{u3} \u03b9) (Set.instHasSubsetSet.{u3} \u03b9) x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.443 x._@.Mathlib.Data.Set.Pairwise.Lattice._hyg.445) g) -> (Iff (Set.PairwiseDisjoint.{u1, u3} \u03b1 \u03b9 _inst_1 _inst_2 (Set.union\u1d62.{u3, succ u2} \u03b9 \u03b9' (fun (n : \u03b9') => g n)) f) (forall {{n : \u03b9'}}, Set.PairwiseDisjoint.{u1, u3} \u03b1 \u03b9 _inst_1 _inst_2 (g n) f))\nCase conversion may be inaccurate. Consider using '#align set.pairwise_disjoint_Union Set.pairwiseDisjoint_union\u1d62\u2093'. -/\ntheorem pairwiseDisjoint_union\u1d62 {g : \u03b9' \u2192 Set \u03b9} (h : Directed (\u00b7 \u2286 \u00b7) g) :\n    (\u22c3 n, g n).PairwiseDisjoint f \u2194 \u2200 \u2983n\u2984, (g n).PairwiseDisjoint f :=\n  pairwise_union\u1d62 h\n#align set.pairwise_disjoint_Union Set.pairwiseDisjoint_union\u1d62\n\n#print Set.pairwiseDisjoint_union\u209b /-\ntheorem pairwiseDisjoint_union\u209b {s : Set (Set \u03b9)} (h : DirectedOn (\u00b7 \u2286 \u00b7) s) :\n    (\u22c3\u2080 s).PairwiseDisjoint f \u2194 \u2200 \u2983a\u2984, a \u2208 s \u2192 Set.PairwiseDisjoint a f :=\n  pairwise_union\u209b h\n#align set.pairwise_disjoint_sUnion Set.pairwiseDisjoint_union\u209b\n-/\n\nend PartialOrderBot\n\nsection CompleteLattice\n\nvariable [CompleteLattice \u03b1]\n\n/- warning: set.pairwise_disjoint.bUnion -> Set.PairwiseDisjoint.bunion\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {\u03b9' : Type.{u3}} [_inst_1 : CompleteLattice.{u1} \u03b1] {s : Set.{u3} \u03b9'} {g : \u03b9' -> (Set.{u2} \u03b9)} {f : \u03b9 -> \u03b1}, (Set.PairwiseDisjoint.{u1, u3} \u03b1 \u03b9' (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)) (BoundedOrder.toOrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} \u03b1 _inst_1)) s (fun (i' : \u03b9') => sup\u1d62.{u1, succ u2} \u03b1 (CompleteSemilatticeSup.toHasSup.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeSup.{u1} \u03b1 _inst_1)) \u03b9 (fun (i : \u03b9) => sup\u1d62.{u1, 0} \u03b1 (CompleteSemilatticeSup.toHasSup.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeSup.{u1} \u03b1 _inst_1)) (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i (g i')) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i (g i')) => f i)))) -> (forall (i : \u03b9'), (Membership.Mem.{u3, u3} \u03b9' (Set.{u3} \u03b9') (Set.hasMem.{u3} \u03b9') i s) -> (Set.PairwiseDisjoint.{u1, u2} \u03b1 \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)) (BoundedOrder.toOrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} \u03b1 _inst_1)) (g i) f)) -> (Set.PairwiseDisjoint.{u1, u2} \u03b1 \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)) (BoundedOrder.toOrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} \u03b1 _inst_1)) (Set.union\u1d62.{u2, succ u3} \u03b9 \u03b9' (fun (i : \u03b9') => Set.union\u1d62.{u2, 0} \u03b9 (Membership.Mem.{u3, u3} \u03b9' (Set.{u3} \u03b9') (Set.hasMem.{u3} \u03b9') i s) (fun (H : Membership.Mem.{u3, u3} \u03b9' (Set.{u3} \u03b9') (Set.hasMem.{u3} \u03b9') i s) => g i))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {\u03b9' : Type.{u3}} [_inst_1 : CompleteLattice.{u1} \u03b1] {s : Set.{u3} \u03b9'} {g : \u03b9' -> (Set.{u2} \u03b9)} {f : \u03b9 -> \u03b1}, (Set.PairwiseDisjoint.{u1, u3} \u03b1 \u03b9' (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)) (BoundedOrder.toOrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} \u03b1 _inst_1)) s (fun (i' : \u03b9') => sup\u1d62.{u1, succ u2} \u03b1 (CompleteLattice.toSupSet.{u1} \u03b1 _inst_1) \u03b9 (fun (i : \u03b9) => sup\u1d62.{u1, 0} \u03b1 (CompleteLattice.toSupSet.{u1} \u03b1 _inst_1) (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i (g i')) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i (g i')) => f i)))) -> (forall (i : \u03b9'), (Membership.mem.{u3, u3} \u03b9' (Set.{u3} \u03b9') (Set.instMembershipSet.{u3} \u03b9') i s) -> (Set.PairwiseDisjoint.{u1, u2} \u03b1 \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)) (BoundedOrder.toOrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} \u03b1 _inst_1)) (g i) f)) -> (Set.PairwiseDisjoint.{u1, u2} \u03b1 \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)) (BoundedOrder.toOrderBot.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (CompleteSemilatticeInf.toPartialOrder.{u1} \u03b1 (CompleteLattice.toCompleteSemilatticeInf.{u1} \u03b1 _inst_1)))) (CompleteLattice.toBoundedOrder.{u1} \u03b1 _inst_1)) (Set.union\u1d62.{u2, succ u3} \u03b9 \u03b9' (fun (i : \u03b9') => Set.union\u1d62.{u2, 0} \u03b9 (Membership.mem.{u3, u3} \u03b9' (Set.{u3} \u03b9') (Set.instMembershipSet.{u3} \u03b9') i s) (fun (H : Membership.mem.{u3, u3} \u03b9' (Set.{u3} \u03b9') (Set.instMembershipSet.{u3} \u03b9') i s) => g i))) f)\nCase conversion may be inaccurate. Consider using '#align set.pairwise_disjoint.bUnion Set.PairwiseDisjoint.bunion\u1d62\u2093'. -/\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\u1d62 {s : Set \u03b9'} {g : \u03b9' \u2192 Set \u03b9} {f : \u03b9 \u2192 \u03b1}\n    (hs : s.PairwiseDisjoint fun i' : \u03b9' => \u2a06 i \u2208 g i', f i)\n    (hg : \u2200 i \u2208 s, (g i).PairwiseDisjoint f) : (\u22c3 i \u2208 s, g i).PairwiseDisjoint f :=\n  by\n  rintro a ha b hb hab\n  simp_rw [Set.mem_union\u1d62] at ha hb\n  obtain \u27e8c, hc, ha\u27e9 := ha\n  obtain \u27e8d, hd, hb\u27e9 := hb\n  obtain hcd | hcd := eq_or_ne (g c) (g d)\n  \u00b7 exact hg d hd (hcd.subst ha) hb hab\n  \u00b7 exact (hs hc hd <| ne_of_apply_ne _ hcd).mono (le_sup\u1d62\u2082 a ha) (le_sup\u1d62\u2082 b hb)\n#align set.pairwise_disjoint.bUnion Set.PairwiseDisjoint.bunion\u1d62\n\nend CompleteLattice\n\n/- warning: set.bUnion_diff_bUnion_eq -> Set.bunion\u1d62_diff_bunion\u1d62_eq is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {s : Set.{u2} \u03b9} {t : Set.{u2} \u03b9} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} \u03b1) \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) (Union.union.{u2} (Set.{u2} \u03b9) (Set.hasUnion.{u2} \u03b9) s t) f) -> (Eq.{succ u1} (Set.{u1} \u03b1) (SDiff.sdiff.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toHasSdiff.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) => f i))) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i t) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i t) => f i)))) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i (SDiff.sdiff.{u2} (Set.{u2} \u03b9) (BooleanAlgebra.toHasSdiff.{u2} (Set.{u2} \u03b9) (Set.booleanAlgebra.{u2} \u03b9)) s t)) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i (SDiff.sdiff.{u2} (Set.{u2} \u03b9) (BooleanAlgebra.toHasSdiff.{u2} (Set.{u2} \u03b9) (Set.booleanAlgebra.{u2} \u03b9)) s t)) => f i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {s : Set.{u2} \u03b9} {t : Set.{u2} \u03b9} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} \u03b1) \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b1) (Preorder.toLE.{u1} (Set.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (Union.union.{u2} (Set.{u2} \u03b9) (Set.instUnionSet.{u2} \u03b9) s t) f) -> (Eq.{succ u1} (Set.{u1} \u03b1) (SDiff.sdiff.{u1} (Set.{u1} \u03b1) (Set.instSDiffSet.{u1} \u03b1) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) => f i))) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i t) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i t) => f i)))) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i (SDiff.sdiff.{u2} (Set.{u2} \u03b9) (Set.instSDiffSet.{u2} \u03b9) s t)) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i (SDiff.sdiff.{u2} (Set.{u2} \u03b9) (Set.instSDiffSet.{u2} \u03b9) s t)) => f i))))\nCase conversion may be inaccurate. Consider using '#align set.bUnion_diff_bUnion_eq Set.bunion\u1d62_diff_bunion\u1d62_eq\u2093'. -/\ntheorem bunion\u1d62_diff_bunion\u1d62_eq {s t : Set \u03b9} {f : \u03b9 \u2192 Set \u03b1} (h : (s \u222a t).PairwiseDisjoint f) :\n    ((\u22c3 i \u2208 s, f i) \\ \u22c3 i \u2208 t, f i) = \u22c3 i \u2208 s \\ t, f i :=\n  by\n  refine'\n    (bUnion_diff_bUnion_subset f s t).antisymm\n      (Union\u2082_subset fun i hi a ha => (mem_diff _).2 \u27e8mem_bUnion hi.1 ha, _\u27e9)\n  rw [mem_Union\u2082]; rintro \u27e8j, hj, haj\u27e9\n  exact (h (Or.inl hi.1) (Or.inr hj) (ne_of_mem_of_not_mem hj hi.2).symm).le_bot \u27e8ha, haj\u27e9\n#align set.bUnion_diff_bUnion_eq Set.bunion\u1d62_diff_bunion\u1d62_eq\n\n/- warning: set.bUnion_eq_sigma_of_disjoint -> Set.bunion\u1d62EqSigmaOfDisjoint is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {s : Set.{u2} \u03b9} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} \u03b1) \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) s f) -> (Equiv.{succ u1, max (succ u2) (succ u1)} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) => f i)))) (Sigma.{u2, u1} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} \u03b9) Type.{u2} (Set.hasCoeToSort.{u2} \u03b9) s) (fun (i : coeSort.{succ u2, succ (succ u2)} (Set.{u2} \u03b9) Type.{u2} (Set.hasCoeToSort.{u2} \u03b9) s) => coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) (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} \u03b9) Type.{u2} (Set.hasCoeToSort.{u2} \u03b9) s) \u03b9 (HasLiftT.mk.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} \u03b9) Type.{u2} (Set.hasCoeToSort.{u2} \u03b9) s) \u03b9 (CoeTC\u2093.coe.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} \u03b9) Type.{u2} (Set.hasCoeToSort.{u2} \u03b9) s) \u03b9 (coeBase.{succ u2, succ u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} \u03b9) Type.{u2} (Set.hasCoeToSort.{u2} \u03b9) s) \u03b9 (coeSubtype.{succ u2} \u03b9 (fun (x : \u03b9) => Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) x s))))) i)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {s : Set.{u2} \u03b9} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} \u03b1) \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b1) (Preorder.toLE.{u1} (Set.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) s f) -> (Equiv.{succ u1, max (succ u1) (succ u2)} (Set.Elem.{u1} \u03b1 (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) => f i)))) (Sigma.{u2, u1} (Set.Elem.{u2} \u03b9 s) (fun (i : Set.Elem.{u2} \u03b9 s) => Set.Elem.{u1} \u03b1 (f (Subtype.val.{succ u2} \u03b9 (fun (x : \u03b9) => Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) x s) i)))))\nCase conversion may be inaccurate. Consider using '#align set.bUnion_eq_sigma_of_disjoint Set.bunion\u1d62EqSigmaOfDisjoint\u2093'. -/\n/-- Equivalence between a disjoint bounded union and a dependent sum. -/\nnoncomputable def bunion\u1d62EqSigmaOfDisjoint {s : Set \u03b9} {f : \u03b9 \u2192 Set \u03b1} (h : s.PairwiseDisjoint f) :\n    (\u22c3 i \u2208 s, f i) \u2243 \u03a3i : s, f i :=\n  (Equiv.setCongr (bunion\u1d62_eq_union\u1d62 _ _)).trans <|\n    unionEqSigmaOfDisjoint fun \u27e8i, hi\u27e9 \u27e8j, hj\u27e9 ne => h hi hj fun eq => Ne <| Subtype.eq Eq\n#align set.bUnion_eq_sigma_of_disjoint Set.bunion\u1d62EqSigmaOfDisjoint\n\nend Set\n\nsection\n\nvariable {f : \u03b9 \u2192 Set \u03b1} {s t : Set \u03b9}\n\n/- warning: set.pairwise_disjoint.subset_of_bUnion_subset_bUnion -> Set.PairwiseDisjoint.subset_of_bunion\u1d62_subset_bunion\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {f : \u03b9 -> (Set.{u1} \u03b1)} {s : Set.{u2} \u03b9} {t : Set.{u2} \u03b9}, (Set.PairwiseDisjoint.{u1, u2} (Set.{u1} \u03b1) \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1))) (Union.union.{u2} (Set.{u2} \u03b9) (Set.hasUnion.{u2} \u03b9) s t) f) -> (forall (i : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) -> (Set.Nonempty.{u1} \u03b1 (f i))) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) => f i))) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i t) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i t) => f i)))) -> (HasSubset.Subset.{u2} (Set.{u2} \u03b9) (Set.hasSubset.{u2} \u03b9) s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b9 : Type.{u1}} {f : \u03b9 -> (Set.{u2} \u03b1)} {s : Set.{u1} \u03b9} {t : Set.{u1} \u03b9}, (Set.PairwiseDisjoint.{u2, u1} (Set.{u2} \u03b1) \u03b9 (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) (BoundedOrder.toOrderBot.{u2} (Set.{u2} \u03b1) (Preorder.toLE.{u2} (Set.{u2} \u03b1) (PartialOrder.toPreorder.{u2} (Set.{u2} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u2} (Set.{u2} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u2} (Set.{u2} \u03b1) (Order.Coframe.toCompleteLattice.{u2} (Set.{u2} \u03b1) (CompleteDistribLattice.toCoframe.{u2} (Set.{u2} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u2} (Set.{u2} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u2} \u03b1)))))) (Union.union.{u1} (Set.{u1} \u03b9) (Set.instUnionSet.{u1} \u03b9) s t) f) -> (forall (i : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.instMembershipSet.{u1} \u03b9) i s) -> (Set.Nonempty.{u2} \u03b1 (f i))) -> (HasSubset.Subset.{u2} (Set.{u2} \u03b1) (Set.instHasSubsetSet.{u2} \u03b1) (Set.union\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.instMembershipSet.{u1} \u03b9) i s) (fun (H : Membership.mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.instMembershipSet.{u1} \u03b9) i s) => f i))) (Set.union\u1d62.{u2, succ u1} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u2, 0} \u03b1 (Membership.mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.instMembershipSet.{u1} \u03b9) i t) (fun (H : Membership.mem.{u1, u1} \u03b9 (Set.{u1} \u03b9) (Set.instMembershipSet.{u1} \u03b9) i t) => f i)))) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b9) (Set.instHasSubsetSet.{u1} \u03b9) s t)\nCase conversion may be inaccurate. Consider using '#align set.pairwise_disjoint.subset_of_bUnion_subset_bUnion Set.PairwiseDisjoint.subset_of_bunion\u1d62_subset_bunion\u1d62\u2093'. -/\ntheorem Set.PairwiseDisjoint.subset_of_bunion\u1d62_subset_bunion\u1d62 (h\u2080 : (s \u222a t).PairwiseDisjoint f)\n    (h\u2081 : \u2200 i \u2208 s, (f i).Nonempty) (h : (\u22c3 i \u2208 s, f i) \u2286 \u22c3 i \u2208 t, f i) : s \u2286 t :=\n  by\n  rintro i hi\n  obtain \u27e8a, hai\u27e9 := h\u2081 i hi\n  obtain \u27e8j, hj, haj\u27e9 := mem_Union\u2082.1 (h <| mem_Union\u2082_of_mem hi hai)\n  rwa [h\u2080.eq (subset_union_left _ _ hi) (subset_union_right _ _ hj)\n      (not_disjoint_iff.2 \u27e8a, hai, haj\u27e9)]\n#align set.pairwise_disjoint.subset_of_bUnion_subset_bUnion Set.PairwiseDisjoint.subset_of_bunion\u1d62_subset_bunion\u1d62\n\n/- warning: pairwise.subset_of_bUnion_subset_bUnion -> Pairwise.subset_of_bunion\u1d62_subset_bunion\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {f : \u03b9 -> (Set.{u1} \u03b1)} {s : Set.{u2} \u03b9} {t : Set.{u2} \u03b9}, (Pairwise.{u2} \u03b9 (Function.onFun.{succ u2, succ u1, 1} \u03b9 (Set.{u1} \u03b1) Prop (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)))) f)) -> (forall (i : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) -> (Set.Nonempty.{u1} \u03b1 (f i))) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) => f i))) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i t) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i t) => f i)))) -> (HasSubset.Subset.{u2} (Set.{u2} \u03b9) (Set.hasSubset.{u2} \u03b9) s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {f : \u03b9 -> (Set.{u1} \u03b1)} {s : Set.{u2} \u03b9} {t : Set.{u2} \u03b9}, (Pairwise.{u2} \u03b9 (Function.onFun.{succ u2, succ u1, 1} \u03b9 (Set.{u1} \u03b1) Prop (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b1) (Preorder.toLE.{u1} (Set.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1))))))) f)) -> (forall (i : \u03b9), (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) -> (Set.Nonempty.{u1} \u03b1 (f i))) -> (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.instHasSubsetSet.{u1} \u03b1) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) => f i))) (Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i t) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i t) => f i)))) -> (HasSubset.Subset.{u2} (Set.{u2} \u03b9) (Set.instHasSubsetSet.{u2} \u03b9) s t)\nCase conversion may be inaccurate. Consider using '#align pairwise.subset_of_bUnion_subset_bUnion Pairwise.subset_of_bunion\u1d62_subset_bunion\u1d62\u2093'. -/\ntheorem Pairwise.subset_of_bunion\u1d62_subset_bunion\u1d62 (h\u2080 : Pairwise (Disjoint on f))\n    (h\u2081 : \u2200 i \u2208 s, (f i).Nonempty) (h : (\u22c3 i \u2208 s, f i) \u2286 \u22c3 i \u2208 t, f i) : s \u2286 t :=\n  Set.PairwiseDisjoint.subset_of_bunion\u1d62_subset_bunion\u1d62 (h\u2080.set_pairwise _) h\u2081 h\n#align pairwise.subset_of_bUnion_subset_bUnion Pairwise.subset_of_bunion\u1d62_subset_bunion\u1d62\n\n/- warning: pairwise.bUnion_injective -> Pairwise.bunion\u1d62_injective is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Pairwise.{u2} \u03b9 (Function.onFun.{succ u2, succ u1, 1} \u03b9 (Set.{u1} \u03b1) Prop (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.completeBooleanAlgebra.{u1} \u03b1)))))) (GeneralizedBooleanAlgebra.toOrderBot.{u1} (Set.{u1} \u03b1) (BooleanAlgebra.toGeneralizedBooleanAlgebra.{u1} (Set.{u1} \u03b1) (Set.booleanAlgebra.{u1} \u03b1)))) f)) -> (forall (i : \u03b9), Set.Nonempty.{u1} \u03b1 (f i)) -> (Function.Injective.{succ u2, succ u1} (Set.{u2} \u03b9) (Set.{u1} \u03b1) (fun (s : Set.{u2} \u03b9) => Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) (fun (H : Membership.Mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.hasMem.{u2} \u03b9) i s) => f i))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b9 : Type.{u2}} {f : \u03b9 -> (Set.{u1} \u03b1)}, (Pairwise.{u2} \u03b9 (Function.onFun.{succ u2, succ u1, 1} \u03b9 (Set.{u1} \u03b1) Prop (Disjoint.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))) (BoundedOrder.toOrderBot.{u1} (Set.{u1} \u03b1) (Preorder.toLE.{u1} (Set.{u1} \u03b1) (PartialOrder.toPreorder.{u1} (Set.{u1} \u03b1) (CompleteSemilatticeInf.toPartialOrder.{u1} (Set.{u1} \u03b1) (CompleteLattice.toCompleteSemilatticeInf.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1)))))))) (CompleteLattice.toBoundedOrder.{u1} (Set.{u1} \u03b1) (Order.Coframe.toCompleteLattice.{u1} (Set.{u1} \u03b1) (CompleteDistribLattice.toCoframe.{u1} (Set.{u1} \u03b1) (CompleteBooleanAlgebra.toCompleteDistribLattice.{u1} (Set.{u1} \u03b1) (Set.instCompleteBooleanAlgebraSet.{u1} \u03b1))))))) f)) -> (forall (i : \u03b9), Set.Nonempty.{u1} \u03b1 (f i)) -> (Function.Injective.{succ u2, succ u1} (Set.{u2} \u03b9) (Set.{u1} \u03b1) (fun (s : Set.{u2} \u03b9) => Set.union\u1d62.{u1, succ u2} \u03b1 \u03b9 (fun (i : \u03b9) => Set.union\u1d62.{u1, 0} \u03b1 (Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) (fun (H : Membership.mem.{u2, u2} \u03b9 (Set.{u2} \u03b9) (Set.instMembershipSet.{u2} \u03b9) i s) => f i))))\nCase conversion may be inaccurate. Consider using '#align pairwise.bUnion_injective Pairwise.bunion\u1d62_injective\u2093'. -/\ntheorem Pairwise.bunion\u1d62_injective (h\u2080 : Pairwise (Disjoint on f)) (h\u2081 : \u2200 i, (f i).Nonempty) :\n    Injective fun s : Set \u03b9 => \u22c3 i \u2208 s, f i := fun s t h =>\n  ((h\u2080.subset_of_bunion\u1d62_subset_bunion\u1d62 fun _ _ => h\u2081 _) <| h.Subset).antisymm <|\n    (h\u2080.subset_of_bunion\u1d62_subset_bunion\u1d62 fun _ _ => h\u2081 _) <| h.Superset\n#align pairwise.bUnion_injective Pairwise.bunion\u1d62_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    {\u2115 \u2124 : outParam Type} [Natural \u2115] [Integer (\u2115 := \u2115) \u2124]\n    (\u211a : Type) [Core (\u2124 := \u2124) \u211a]\n    :=\n  /-- Reciprocation of rational numbers. -/\n  reciprocal (p : \u211a) [AP (p \u2244 0)] : \u211a\n\nexport Reciprocation.Ops (reciprocal)\n\n/-- Enables the use of the `\u00b7\u207b\u00b9` operator for reciprocation. -/\npostfix:120 \"\u207b\u00b9\" => reciprocal\n\n/-- Properties of rational number reciprocation. -/\nclass Reciprocation.Props\n    {\u2115 \u2124 : outParam Type} [Natural \u2115] [Integer (\u2115 := \u2115) \u2124]\n    (\u211a : Type) [Core (\u2124 := \u2124) \u211a] [Addition \u211a] [Multiplication \u211a] [Ops \u211a]\n    :=\n  /-- Reciprocation respects equivalence over its operand. -/\n  recip_subst {p\u2081 p\u2082 : \u211a} [AP (p\u2081 \u2244 0)] [AP (p\u2082 \u2244 0)] : p\u2081 \u2243 p\u2082 \u2192 p\u2081\u207b\u00b9 \u2243 p\u2082\u207b\u00b9\n\n  /-- The reciprocal of a value is its left multiplicative inverse. -/\n  mul_inverseL {p : \u211a} [AP (p \u2244 0)] : p\u207b\u00b9 * p \u2243 1\n\n  /-- The reciprocal of a value is its right multiplicative inverse. -/\n  mul_inverseR {p : \u211a} [AP (p \u2244 0)] : p * p\u207b\u00b9 \u2243 1\n\nexport Reciprocation.Props (mul_inverseL mul_inverseR recip_subst)\n\n/-- All rational number reciprocation axioms. -/\nclass Reciprocation\n    {\u2115 \u2124 : outParam Type} [Natural \u2115] [Integer (\u2115 := \u2115) \u2124]\n    (\u211a : Type) [Core (\u2124 := \u2124) \u211a] [Addition \u211a] [Multiplication \u211a]\n    :=\n  toOps : Reciprocation.Ops \u211a\n  toProps : Reciprocation.Props \u211a\n\nattribute [instance] Reciprocation.toOps\nattribute [instance] Reciprocation.toProps\n\n/-- Operations pertaining to rational number division. -/\nclass Division.Ops\n    {\u2115 \u2124 : outParam Type} [Natural \u2115] [Integer (\u2115 := \u2115) \u2124]\n    (\u211a : Type) [Core (\u2124 := \u2124) \u211a]\n    :=\n  /-- Division of rational numbers. -/\n  div (p q : \u211a) [AP (q \u2244 0)] : \u211a\n\nexport Division.Ops (div)\n\n/--\nEnables the use of the `\u00b7 / \u00b7` 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    {\u2115 \u2124 : Type} [Natural \u2115] [Integer (\u2115 := \u2115) \u2124]\n    {\u211a : Type} [Core (\u2124 := \u2124) \u211a] [Division.Ops \u211a] (p : \u211a)\n    : Prop\n    :=\n  /-- Construct a value of `AsRatio p`. -/\n| intro\n    (a b : \u2124)\n    (b_nonzero : Integer.Nonzero b)\n    (eqv_ratio : p \u2243 a / b)\n\n/-- Properties of rational number division. -/\nclass Division.Props\n    {\u2115 \u2124 : outParam Type} [Natural \u2115] [Integer (\u2115 := \u2115) \u2124]\n    (\u211a : Type)\n      [Core (\u2124 := \u2124) \u211a] [Addition \u211a] [Multiplication \u211a] [Reciprocation \u211a]\n      [Ops \u211a]\n    :=\n  /--\n  Division is equivalent to multiplication by the reciprocal of the second\n  argument.\n  -/\n  div_mul_recip {p q : \u211a} [AP (q \u2244 0)] : p / q \u2243 p * q\u207b\u00b9\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 : \u211a) : AsRatio p\n\nexport Division.Props (as_ratio div_mul_recip)\n\n/-- All rational number division axioms. -/\nclass Division\n    {\u2115 \u2124 : outParam Type} [Natural \u2115] [Integer (\u2115 := \u2115) \u2124]\n    (\u211a : Type)\n      [Core (\u2124 := \u2124) \u211a] [Addition \u211a] [Multiplication \u211a] [Reciprocation \u211a]\n    :=\n  toOps : Division.Ops \u211a\n  toProps : Division.Props \u211a\n\nattribute [instance] Division.toOps\nattribute [instance] Division.toProps\n\n/-! ## Derived properties -/\n\nvariable {\u2115 \u2124 : Type} [Natural \u2115] [Integer (\u2115 := \u2115) \u2124]\nvariable {\u211a : Type}\n  [Core (\u2124 := \u2124) \u211a] [Addition \u211a] [Multiplication \u211a]\n  [Negation \u211a] [Reciprocation \u211a] [Division \u211a]\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 \u2243 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 : \u211a} [Sqrt1 s] : s\u207b\u00b9 \u2243 s := calc\n  s\u207b\u00b9           \u2243 _ := eqv_symm mul_identL\n  1 * s\u207b\u00b9       \u2243 _ := mul_substL (eqv_symm \u2039Sqrt1 s\u203a.elim)\n  (s * s) * s\u207b\u00b9 \u2243 _ := mul_assoc\n  s * (s * s\u207b\u00b9) \u2243 _ := mul_substR mul_inverseR\n  s * 1         \u2243 _ := mul_identR\n  s             \u2243 _ := 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\u2081 p\u2082 q : \u211a} [AP (q \u2244 0)] : p\u2081 \u2243 p\u2082 \u2192 p\u2081 / q \u2243 p\u2082 / q := by\n  intro (_ : p\u2081 \u2243 p\u2082)\n  show p\u2081 / q \u2243 p\u2082 / q\n  calc\n    p\u2081 / q   \u2243 _ := div_mul_recip\n    p\u2081 * q\u207b\u00b9 \u2243 _ := mul_substL \u2039p\u2081 \u2243 p\u2082\u203a\n    p\u2082 * q\u207b\u00b9 \u2243 _ := eqv_symm div_mul_recip\n    p\u2082 / q   \u2243 _ := 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\u2081 p\u2082 q : \u211a} [AP (p\u2081 \u2244 0)] [AP (p\u2082 \u2244 0)] : p\u2081 \u2243 p\u2082 \u2192 q / p\u2081 \u2243 q / p\u2082\n    := by\n  intro (_ : p\u2081 \u2243 p\u2082)\n  show q / p\u2081 \u2243 q / p\u2082\n  calc\n    q / p\u2081   \u2243 _ := div_mul_recip\n    q * p\u2081\u207b\u00b9 \u2243 _ := mul_substR (recip_subst \u2039p\u2081 \u2243 p\u2082\u203a)\n    q * p\u2082\u207b\u00b9 \u2243 _ := eqv_symm div_mul_recip\n    q / p\u2082   \u2243 _ := 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 \u00d7 K \u2964 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 \u00d7 K \u2964 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 \u27e8kx, x, rfl\u27e9 := jointly_surjective'.{v v} x,\n  obtain \u27e8ky, y, rfl\u27e9 := 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 := \u03bb j, congr_arg (limit.\u03c0 ((curry.obj F) \u22d9 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 := \u03bb j, (h j).some,\n  let f : \u03a0 j, kx \u27f6 k j := \u03bb j, (h j).some_spec.some,\n  let g : \u03a0 j, ky \u27f6 k j := \u03bb j, (h j).some_spec.some_spec.some,\n  -- where the images of the components of the representatives become equal:\n  have w : \u03a0 j,\n    F.map ((\ud835\udfd9 j, f j) : (j, kx) \u27f6 (j, k j)) (limit.\u03c0 ((curry.obj (swap K J \u22d9 F)).obj kx) j x) =\n    F.map ((\ud835\udfd9 j, g j) : (j, ky) \u27f6 (j, k j)) (limit.\u03c0 ((curry.obj (swap K J \u22d9 F)).obj ky) j y) :=\n    \u03bb 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 \u222a {kx, ky},\n  have kxO : kx \u2208 O := finset.mem_union.mpr (or.inr (by simp)),\n  have kyO : ky \u2208 O := finset.mem_union.mpr (or.inr (by simp)),\n  have kjO : \u2200 j, k j \u2208 O := \u03bb j, finset.mem_union.mpr (or.inl (by simp)),\n\n  let H : finset (\u03a3' (X Y : K) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y) :=\n    (finset.univ).image (\u03bb j : J, \u27e8kx, k j, kxO,\n      finset.mem_union.mpr (or.inl (by simp)),\n      f j\u27e9) \u222a\n    (finset.univ).image (\u03bb j : J, \u27e8ky, k j, kyO,\n      finset.mem_union.mpr (or.inl (by simp)),\n      g j\u27e9),\n  obtain \u27e8S, T, W\u27e9 := is_filtered.sup_exists O H,\n\n  have fH :\n    \u2200 j, (\u27e8kx, k j, kxO, kjO j, f j\u27e9 : (\u03a3' (X Y : K) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y)) \u2208 H :=\n    \u03bb 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 \u27e8j, rfl, _\u27e9,\n      simp only [heq_iff_eq],\n      exact \u27e8rfl, rfl, rfl\u27e9,\n    end)),\n  have gH :\n    \u2200 j, (\u27e8ky, k j, kyO, kjO j, g j\u27e9 : (\u03a3' (X Y : K) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y)) \u2208 H :=\n    \u03bb 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 \u27e8j, rfl, _\u27e9,\n      simp only [heq_iff_eq],\n      exact \u27e8rfl, rfl, rfl\u27e9,\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_\u03c0_apply, curry.obj_map_app, swap_map],\n  rw \u2190W _ _ (fH j),\n  rw \u2190W _ _ (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 := \u03bb j, jointly_surjective'.{v v} (limit.\u03c0 (curry.obj F \u22d9 limits.colim) j x),\n  -- `k : J \u27f6 K` records where the representative of the element in the `j`-th element of `x` lives\n  let k : J \u2192 K := \u03bb j, (z j).some,\n  -- `y j : F.obj (j, k j)` is the representative\n  let y : \u03a0 j, F.obj (j, k j) := \u03bb 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 : \u2200 j,\n    colimit.\u03b9 ((curry.obj F).obj j) (k j) (y j) =\n    limit.\u03c0 (curry.obj F \u22d9 limits.colim) j x := \u03bb 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) \u2205,\n  -- and name the morphisms as `g j : k j \u27f6 k'`.\n  have g : \u03a0 j, k j \u27f6 k' := \u03bb j, is_filtered.to_sup (finset.univ.image k) \u2205 (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 \u27f6 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 `(\ud835\udfd9 j', g j')`, both represent the same element in the colimit.\n  have w : \u2200 {j j' : J} (f : j \u27f6 j'),\n    colimit.\u03b9 ((curry.obj F).obj j') k' (F.map ((\ud835\udfd9 j', g j') : (j', k j') \u27f6 (j', k')) (y j')) =\n    colimit.\u03b9 ((curry.obj F).obj j') k' (F.map ((f, g j) : (j, k j) \u27f6 (j', k')) (y j)),\n  { intros j j' f,\n    have t : (f, g j) = (((f, \ud835\udfd9 (k j)) : (j, k j) \u27f6 (j', k j)) \u226b (\ud835\udfd9 j', g j) : (j, k j) \u27f6 (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      \u2190limit.w_apply' f, \u2190e],\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 : \u03a0 {j j'} (f : j \u27f6 j'), K := \u03bb _ _ f, (w f).some,\n  let gf : \u03a0 {j j'} (f : j \u27f6 j'), k' \u27f6 kf f := \u03bb _ _ f, (w f).some_spec.some,\n  let hf : \u03a0 {j j'} (f : j \u27f6 j'), k' \u27f6 kf f := \u03bb _ _ f, (w f).some_spec.some_spec.some,\n  have wf : \u03a0 {j j'} (f : j \u27f6 j'),\n    F.map ((\ud835\udfd9 j', g j' \u226b gf f) : (j', k j') \u27f6 (j', kf f)) (y j') =\n    F.map ((f, g j \u226b hf f) : (j, k j) \u27f6 (j', kf f)) (y j) := \u03bb 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 \u2190functor_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' \u27f6 kh f` and `hf f : k' \u27f6 kf f`.\n  -- At this point we're relying on there being only finitely morphisms in `J`.\n  let O := finset.univ.bUnion (\u03bb j, finset.univ.bUnion (\u03bb j', finset.univ.image (@kf j j'))) \u222a {k'},\n  have kfO : \u2200 {j j'} (f : j \u27f6 j'), kf f \u2208 O := \u03bb j j' f, finset.mem_union.mpr (or.inl (\n  begin\n    rw [finset.mem_bUnion],\n    refine \u27e8j, finset.mem_univ j, _\u27e9,\n    rw [finset.mem_bUnion],\n    refine \u27e8j', finset.mem_univ j', _\u27e9,\n    rw [finset.mem_image],\n    refine \u27e8f, finset.mem_univ _, _\u27e9,\n    refl,\n  end)),\n  have k'O : k' \u2208 O := finset.mem_union.mpr (or.inr (finset.mem_singleton.mpr rfl)),\n  let H : finset (\u03a3' (X Y : K) (mX : X \u2208 O) (mY : Y \u2208 O), X \u27f6 Y) :=\n    finset.univ.bUnion (\u03bb j : J, finset.univ.bUnion (\u03bb j' : J, finset.univ.bUnion (\u03bb f : j \u27f6 j',\n      {\u27e8k', kf f, k'O, kfO f, gf f\u27e9, \u27e8k', kf f, k'O, kfO f, hf f\u27e9}))),\n\n  obtain \u27e8k'', i', s'\u27e9 := is_filtered.sup_exists O H,\n  -- We then restate this slightly more conveniently, as a family of morphism `i f : kf f \u27f6 k''`,\n  -- satisfying `gf f \u226b i f = hf f' \u226b i f'`.\n  let i : \u03a0 {j j'} (f : j \u27f6 j'), kf f \u27f6 k'' := \u03bb j j' f, i' (kfO f),\n  have s : \u2200 {j\u2081 j\u2082 j\u2083 j\u2084} (f : j\u2081 \u27f6 j\u2082) (f' : j\u2083 \u27f6 j\u2084), gf f \u226b i f = hf f' \u226b 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 \u27e8j\u2081, finset.mem_univ _, _\u27e9,\n      rw [finset.mem_bUnion],\n      refine \u27e8j\u2082, finset.mem_univ _, _\u27e9,\n      rw [finset.mem_bUnion],\n      refine \u27e8f, finset.mem_univ _, _\u27e9,\n      simp only [true_or, eq_self_iff_true, and_self, finset.mem_insert, heq_iff_eq], },\n    { rw [finset.mem_bUnion],\n      refine \u27e8j\u2083, finset.mem_univ _, _\u27e9,\n      rw [finset.mem_bUnion],\n      refine \u27e8j\u2084, finset.mem_univ _, _\u27e9,\n      rw [finset.mem_bUnion],\n      refine \u27e8f', finset.mem_univ _, _\u27e9,\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.\u03b9 (curry.obj (swap K J \u22d9 F) \u22d9 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 \u03bb j, F.map (\u27e8\ud835\udfd9 j, g j \u226b gf (\ud835\udfd9 j) \u226b i (\ud835\udfd9 j)\u27e9 : (j, k j) \u27f6 (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 [\u2190functor_to_types.map_comp_apply, prod_comp, id_comp, comp_id],\n      calc F.map ((f, g j \u226b gf (\ud835\udfd9 j) \u226b i (\ud835\udfd9 j)) : (j, k j) \u27f6 (j', k'')) (y j)\n          = F.map ((f, g j \u226b hf f \u226b i f) : (j, k j) \u27f6 (j', k'')) (y j)\n                : by rw s (\ud835\udfd9 j) f\n      ... = F.map ((\ud835\udfd9 j', i f) : (j', kf f) \u27f6 (j', k''))\n              (F.map ((f, g j \u226b hf f) : (j, k j) \u27f6 (j', kf f)) (y j))\n                : by rw [\u2190functor_to_types.map_comp_apply, prod_comp, comp_id, assoc]\n      ... = F.map ((\ud835\udfd9 j', i f) : (j', kf f) \u27f6 (j', k''))\n              (F.map ((\ud835\udfd9 j', g j' \u226b gf f) : (j', k j') \u27f6 (j', kf f)) (y j'))\n                : by rw \u2190wf f\n      ... = F.map ((\ud835\udfd9 j', g j' \u226b gf f \u226b i f) : (j', k j') \u27f6 (j', k'')) (y j')\n                : by rw [\u2190functor_to_types.map_comp_apply, prod_comp, id_comp, assoc]\n      ... = F.map ((\ud835\udfd9 j', g j' \u226b gf (\ud835\udfd9 j') \u226b i (\ud835\udfd9 j')) : (j', k j') \u27f6 (j', k'')) (y j')\n                : by rw [s f (\ud835\udfd9 j'), \u2190s (\ud835\udfd9 j') (\ud835\udfd9 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 [\u2190e, colimit_eq_iff.{v v}, curry.obj_obj_map, limit.\u03c0_mk',\n      bifunctor.map_id_comp, id.def, types_comp_apply,\n      limits.\u03b9_colimit_limit_to_limit_colimit_\u03c0_apply],\n    refine \u27e8k'', \ud835\udfd9 k'', g j \u226b gf (\ud835\udfd9 j) \u226b i (\ud835\udfd9 j), _\u27e9,\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  \u27e8colimit_limit_to_limit_colimit_injective F, colimit_limit_to_limit_colimit_surjective F\u27e9\n\ninstance colimit_limit_to_limit_colimit_cone_iso (F : J \u2964 K \u2964 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 \u2964 Type v) \u2964 _) := \u27e8\u03bb J _ _, by exactI \u27e8\u03bb F, \u27e8\u03bb 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 \u27e9\u27e9\u27e9\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 \u2964 C) \u2964 _) :=\nbegin\n  haveI : preserves_limits_of_shape J ((colim : (K \u2964 C) \u2964 _) \u22d9 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 \u2964 C) \u2964 _) :=\n\u27e8\u03bb _ _ _, by exactI category_theory.limits.filtered_colim_preserves_finite_limits\u27e9\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 \u2964 K \u2964 C) :\n  colimit (limit F) \u2245 limit (colimit F.flip) :=\n(is_limit_of_preserves colim (limit.is_limit _)).cone_point_unique_up_to_iso (limit.is_limit _) \u226a\u226b\n  (has_limit.iso_of_nat_iso (colimit_flip_iso_comp_colim _).symm)\n\n@[simp, reassoc]\nlemma \u03b9_colimit_limit_iso_limit_\u03c0 (F : J \u2964 K \u2964 C) (a) (b) :\n  colimit.\u03b9 (limit F) a \u226b (colimit_limit_iso F).hom \u226b limit.\u03c0 (colimit F.flip) b =\n  (limit.\u03c0 F b).app a \u226b (colimit.\u03b9 F.flip a).app b :=\nbegin\n  dsimp [colimit_limit_iso],\n  simp only [functor.map_cone_\u03c0_app, iso.symm_hom,\n    limits.limit.cone_point_unique_up_to_iso_hom_comp_assoc, limits.limit.cone_\u03c0,\n    limits.colimit.\u03b9_map_assoc, limits.colimit_flip_iso_comp_colim_inv_app, assoc,\n    limits.has_limit.iso_of_nat_iso_hom_\u03c0],\n  congr' 1,\n  simp only [\u2190 category.assoc, iso.comp_inv_eq,\n    limits.colimit_obj_iso_colimit_comp_evaluation_\u03b9_app_hom,\n    limits.has_colimit.iso_of_nat_iso_\u03b9_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 \u03b1` is the type of \"partial values\" of type `\u03b1`. It\n  is similar to `option \u03b1` except the domain condition can be an\n  arbitrary proposition, not necessarily decidable. -/\nstructure {u} roption (\u03b1 : Type u) : Type u :=\n(dom : Prop)\n(get : dom \u2192 \u03b1)\n\nnamespace roption\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n\n/-- Convert an `roption \u03b1` with a decidable domain to an option -/\ndef to_option (o : roption \u03b1) [decidable o.dom] : option \u03b1 :=\nif h : dom o then some (o.get h) else none\n\n/-- `roption` extensionality -/\ntheorem ext' : \u2200 {o p : roption \u03b1}\n  (H1 : o.dom \u2194 p.dom)\n  (H2 : \u2200h\u2081 h\u2082, o.get h\u2081 = p.get h\u2082), o = p\n| \u27e8od, o\u27e9 \u27e8pd, p\u27e9 H1 H2 := have t : od = pd, from propext H1,\n  by cases t; rw [show o = p, from funext $ \u03bbp, H2 p p]\n\n/-- `roption` eta expansion -/\n@[simp] theorem eta : \u03a0 (o : roption \u03b1), (\u27e8o.dom, \u03bb h, o.get h\u27e9 : roption \u03b1) = o\n| \u27e8h, f\u27e9 := rfl\n\n/-- `a \u2208 o` means that `o` is defined and equal to `a` -/\nprotected def mem (a : \u03b1) (o : roption \u03b1) : Prop := \u2203 h, o.get h = a\n\ninstance : has_mem \u03b1 (roption \u03b1) := \u27e8roption.mem\u27e9\n\ntheorem mem_eq (a : \u03b1) (o : roption \u03b1) : (a \u2208 o) = (\u2203 h, o.get h = a) :=\nrfl\n\ntheorem dom_iff_mem : \u2200 {o : roption \u03b1}, o.dom \u2194 \u2203y, y \u2208 o\n| \u27e8p, f\u27e9 := \u27e8\u03bbh, \u27e8f h, h, rfl\u27e9, \u03bb\u27e8_, h, rfl\u27e9, h\u27e9\n\ntheorem get_mem {o : roption \u03b1} (h) : get o h \u2208 o := \u27e8_, rfl\u27e9\n\n/-- `roption` extensionality -/\n@[ext]\ntheorem ext {o p : roption \u03b1} (H : \u2200 a, a \u2208 o \u2194 a \u2208 p) : o = p :=\next' \u27e8\u03bb h, ((H _).1 \u27e8h, rfl\u27e9).fst,\n     \u03bb h, ((H _).2 \u27e8h, rfl\u27e9).fst\u27e9 $\n\u03bb a b, ((H _).2 \u27e8_, rfl\u27e9).snd\n\n/-- The `none` value in `roption` has a `false` domain and an empty function. -/\ndef none : roption \u03b1 := \u27e8false, false.rec _\u27e9\n\ninstance : inhabited (roption \u03b1) := \u27e8none\u27e9\n\n@[simp] theorem not_mem_none (a : \u03b1) : a \u2209 @none \u03b1 := \u03bb h, h.fst\n\n/-- The `some a` value in `roption` has a `true` domain and the\n  function returns `a`. -/\ndef some (a : \u03b1) : roption \u03b1 := \u27e8true, \u03bb_, a\u27e9\n\ntheorem mem_unique : \u2200 {a b : \u03b1} {o : roption \u03b1}, a \u2208 o \u2192 b \u2208 o \u2192 a = b\n| _ _ \u27e8p, f\u27e9 \u27e8h\u2081, rfl\u27e9 \u27e8h\u2082, rfl\u27e9 := rfl\n\ntheorem mem.left_unique : relator.left_unique ((\u2208) : \u03b1 \u2192 roption \u03b1 \u2192 Prop) :=\n\u27e8\u03bb a o b, mem_unique\u27e9\n\ntheorem get_eq_of_mem {o : roption \u03b1} {a} (h : a \u2208 o) (h') : get o h' = a :=\nmem_unique \u27e8_, rfl\u27e9 h\n\n@[simp] theorem get_some {a : \u03b1} (ha : (some a).dom) : get (some a) ha = a := rfl\n\ntheorem mem_some (a : \u03b1) : a \u2208 some a := \u27e8trivial, rfl\u27e9\n\n@[simp] theorem mem_some_iff {a b} : b \u2208 (some a : roption \u03b1) \u2194 b = a :=\n\u27e8\u03bb\u27e8h, e\u27e9, e.symm, \u03bb e, \u27e8trivial, e.symm\u27e9\u27e9\n\ntheorem eq_some_iff {a : \u03b1} {o : roption \u03b1} : o = some a \u2194 a \u2208 o :=\n\u27e8\u03bb e, e.symm \u25b8 mem_some _,\n \u03bb \u27e8h, e\u27e9, e \u25b8 ext' (iff_true_intro h) (\u03bb _ _, rfl)\u27e9\n\ntheorem eq_none_iff {o : roption \u03b1} : o = none \u2194 \u2200 a, a \u2209 o :=\n\u27e8\u03bb e, e.symm \u25b8 not_mem_none,\n \u03bb h, ext (by simpa [not_mem_none])\u27e9\n\ntheorem eq_none_iff' {o : roption \u03b1} : o = none \u2194 \u00ac o.dom :=\n\u27e8\u03bb e, e.symm \u25b8 id, \u03bb h, eq_none_iff.2 (\u03bb a h', h h'.fst)\u27e9\n\nlemma some_ne_none (x : \u03b1) : some x \u2260 none :=\nby { intro h, change none.dom, rw [\u2190 h], trivial }\n\nlemma ne_none_iff {o : roption \u03b1} : o \u2260 none \u2194 \u2203x, 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 \u27e8x, rfl\u27e9, apply some_ne_none }\nend\n\nlemma eq_none_or_eq_some (o : roption \u03b1) : o = none \u2228 \u2203 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 : \u03b1} : roption.some a = some b \u2194 a = b :=\nfunction.injective.eq_iff (\u03bb a b h, congr_fun (eq_of_heq (roption.mk.inj h).2) trivial)\n\n@[simp] lemma some_get {a : roption \u03b1} (ha : a.dom) :\n  roption.some (roption.get a ha) = a :=\neq.symm (eq_some_iff.2 \u27e8ha, rfl\u27e9)\n\nlemma get_eq_iff_eq_some {a : roption \u03b1} {ha : a.dom} {b : \u03b1} :\n  a.get ha = b \u2194 a = some b :=\n\u27e8\u03bb h, by simp [h.symm], \u03bb h, by simp [h]\u27e9\n\nlemma get_eq_get_of_eq (a : roption \u03b1) (ha : a.dom) {b : roption \u03b1} (h : a = b) :\n  a.get ha = b.get (h \u25b8 ha) :=\nby { congr, exact h }\n\ninstance none_decidable : decidable (@none \u03b1).dom := decidable.false\ninstance some_decidable (a : \u03b1) : decidable (some a).dom := decidable.true\n\ndef get_or_else (a : roption \u03b1) [decidable a.dom] (d : \u03b1) :=\nif ha : a.dom then a.get ha else d\n\n@[simp] lemma get_or_else_none (d : \u03b1) : get_or_else none d = d :=\ndif_neg id\n\n@[simp] lemma get_or_else_some (a : \u03b1) (d : \u03b1) : get_or_else (some a) d = a :=\ndif_pos trivial\n\n@[simp] theorem mem_to_option {o : roption \u03b1} [decidable o.dom] {a : \u03b1} :\n  a \u2208 to_option o \u2194 a \u2208 o :=\nbegin\n  unfold to_option,\n  by_cases h : o.dom; simp [h],\n  { exact \u27e8\u03bb h, \u27e8_, h\u27e9, \u03bb \u27e8_, h\u27e9, h\u27e9 },\n  { exact mt Exists.fst h }\nend\n\n/-- Convert an `option \u03b1` into an `roption \u03b1` -/\ndef of_option : option \u03b1 \u2192 roption \u03b1\n| option.none     := none\n| (option.some a) := some a\n\n@[simp] theorem mem_of_option {a : \u03b1} : \u2200 {o : option \u03b1}, a \u2208 of_option o \u2194 a \u2208 o\n| option.none     := \u27e8\u03bb h, h.fst.elim, \u03bb h, option.no_confusion h\u27e9\n| (option.some b) := \u27e8\u03bb h, congr_arg option.some h.snd,\n  \u03bb h, \u27e8trivial, option.some.inj h\u27e9\u27e9\n\n@[simp] theorem of_option_dom {\u03b1} : \u2200 (o : option \u03b1), (of_option o).dom \u2194 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 {\u03b1} (o : option \u03b1) : of_option o = \u27e8_, @option.get _ o\u27e9 :=\nroption.ext' (of_option_dom o) $ \u03bb h\u2081 h\u2082, by cases o; [cases h\u2081, refl]\n\ninstance : has_coe (option \u03b1) (roption \u03b1) := \u27e8of_option\u27e9\n\n@[simp] theorem mem_coe {a : \u03b1} {o : option \u03b1} :\n  a \u2208 (o : roption \u03b1) \u2194 a \u2208 o := mem_of_option\n\n@[simp] theorem coe_none : (@option.none \u03b1 : roption \u03b1) = none := rfl\n@[simp] theorem coe_some (a : \u03b1) : (option.some a : roption \u03b1) = some a := rfl\n\n@[elab_as_eliminator] protected lemma induction_on {P : roption \u03b1 \u2192 Prop}\n  (a : roption \u03b1) (hnone : P none) (hsome : \u2200 a : \u03b1, P (some a)) : P a :=\n(classical.em a.dom).elim\n  (\u03bb h, roption.some_get h \u25b8 hsome _)\n  (\u03bb h, (eq_none_iff'.2 h).symm \u25b8 hnone)\n\ninstance of_option_decidable : \u2200 o : option \u03b1, 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 \u03b1) : to_option (of_option o) = o :=\nby cases o; refl\n\n@[simp] theorem of_to_option (o : roption \u03b1) [decidable o.dom] : of_option (to_option o) = o :=\next $ \u03bb a, mem_of_option.trans mem_to_option\n\nnoncomputable def equiv_option : roption \u03b1 \u2243 option \u03b1 :=\nby haveI := classical.dec; exact\n\u27e8\u03bb o, to_option o, of_option, \u03bb o, of_to_option o,\n \u03bb o, eq.trans (by dsimp; congr) (to_of_option o)\u27e9\n\ninstance : order_bot (roption \u03b1) :=\n{ le := \u03bb x y, \u2200 i, i \u2208 x \u2192 i \u2208 y,\n  le_refl := \u03bb x y, id,\n  le_trans := \u03bb x y z f g i, g _ \u2218 f _,\n  le_antisymm := \u03bb x y f g, roption.ext $ \u03bb z, \u27e8f _, g _\u27e9,\n  bot := none,\n  bot_le := by { introv x, rintro \u27e8\u27e8_\u27e9,_\u27e9, } }\n\ninstance : preorder (roption \u03b1) :=\nby apply_instance\n\nlemma le_total_of_le_of_le {x y : roption \u03b1} (z : roption \u03b1) (hx : x \u2264 z) (hy : y \u2264 z) :\n  x \u2264 y \u2228 y \u2264 x :=\nbegin\n  rcases roption.eq_none_or_eq_some x with h | \u27e8b, h\u2080\u27e9,\n  { rw h, left, apply order_bot.bot_le _ },\n  right, intros b' h\u2081,\n  rw roption.eq_some_iff at h\u2080,\n  replace hx := hx _ h\u2080, replace hy := hy _ h\u2081,\n  replace hx := roption.mem_unique hx hy, subst hx,\n  exact h\u2080\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 \u2192 roption \u03b1) : roption \u03b1 :=\n\u27e8\u2203h : p, (f h).dom, \u03bbha, (f ha.fst).get ha.snd\u27e9\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 \u03b1) (g : \u03b1 \u2192 roption \u03b2) : roption \u03b2 :=\nassert (dom f) (\u03bbb, g (f.get b))\n\n/-- The map operation for `roption` just maps the value and maintains the same domain. -/\ndef map (f : \u03b1 \u2192 \u03b2) (o : roption \u03b1) : roption \u03b2 :=\n\u27e8o.dom, f \u2218 o.get\u27e9\n\ntheorem mem_map (f : \u03b1 \u2192 \u03b2) {o : roption \u03b1} :\n  \u2200 {a}, a \u2208 o \u2192 f a \u2208 map f o\n| _ \u27e8h, rfl\u27e9 := \u27e8_, rfl\u27e9\n\n@[simp] theorem mem_map_iff (f : \u03b1 \u2192 \u03b2) {o : roption \u03b1} {b} :\n  b \u2208 map f o \u2194 \u2203 a \u2208 o, f a = b :=\n\u27e8match b with _, \u27e8h, rfl\u27e9 := \u27e8_, \u27e8_, rfl\u27e9, rfl\u27e9 end,\n \u03bb \u27e8a, h\u2081, h\u2082\u27e9, h\u2082 \u25b8 mem_map f h\u2081\u27e9\n\n@[simp] theorem map_none (f : \u03b1 \u2192 \u03b2) :\n  map f none = none := eq_none_iff.2 $ \u03bb a, by simp\n\n@[simp] theorem map_some (f : \u03b1 \u2192 \u03b2) (a : \u03b1) : map f (some a) = some (f a) :=\neq_some_iff.2 $ mem_map f $ mem_some _\n\ntheorem mem_assert {p : Prop} {f : p \u2192 roption \u03b1}\n  : \u2200 {a} (h : p), a \u2208 f h \u2192 a \u2208 assert p f\n| _ x \u27e8h, rfl\u27e9 := \u27e8\u27e8x, h\u27e9, rfl\u27e9\n\n@[simp] theorem mem_assert_iff {p : Prop} {f : p \u2192 roption \u03b1} {a} :\n  a \u2208 assert p f \u2194 \u2203 h : p, a \u2208 f h :=\n\u27e8match a with _, \u27e8h, rfl\u27e9 := \u27e8_, \u27e8_, rfl\u27e9\u27e9 end,\n \u03bb \u27e8a, h\u27e9, mem_assert _ h\u27e9\n\nlemma assert_pos {p : Prop} {f : p \u2192 roption \u03b1} (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 \u2192 roption \u03b1} (h : \u00ac 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 \u03b1} {g : \u03b1 \u2192 roption \u03b2} :\n  \u2200 {a b}, a \u2208 f \u2192 b \u2208 g a \u2192 b \u2208 f.bind g\n| _ _ \u27e8h, rfl\u27e9 \u27e8h\u2082, rfl\u27e9 := \u27e8\u27e8h, h\u2082\u27e9, rfl\u27e9\n\n@[simp] theorem mem_bind_iff {f : roption \u03b1} {g : \u03b1 \u2192 roption \u03b2} {b} :\n  b \u2208 f.bind g \u2194 \u2203 a \u2208 f, b \u2208 g a :=\n\u27e8match b with _, \u27e8\u27e8h\u2081, h\u2082\u27e9, rfl\u27e9 := \u27e8_, \u27e8_, rfl\u27e9, \u27e8_, rfl\u27e9\u27e9 end,\n \u03bb \u27e8a, h\u2081, h\u2082\u27e9, mem_bind h\u2081 h\u2082\u27e9\n\n@[simp] theorem bind_none (f : \u03b1 \u2192 roption \u03b2) :\n  none.bind f = none := eq_none_iff.2 $ \u03bb a, by simp\n\n@[simp] theorem bind_some (a : \u03b1) (f : \u03b1 \u2192 roption \u03b2) :\n  (some a).bind f = f a := ext $ by simp\n\ntheorem bind_some_eq_map (f : \u03b1 \u2192 \u03b2) (x : roption \u03b1) :\n  x.bind (some \u2218 f) = map f x :=\next $ by simp [eq_comm]\n\ntheorem bind_assoc {\u03b3} (f : roption \u03b1) (g : \u03b1 \u2192 roption \u03b2) (k : \u03b2 \u2192 roption \u03b3) :\n  (f.bind g).bind k = f.bind (\u03bb x, (g x).bind k) :=\next $ \u03bb a, by simp; exact\n \u27e8\u03bb \u27e8_, \u27e8_, h\u2081, h\u2082\u27e9, h\u2083\u27e9, \u27e8_, h\u2081, _, h\u2082, h\u2083\u27e9,\n  \u03bb \u27e8_, h\u2081, _, h\u2082, h\u2083\u27e9, \u27e8_, \u27e8_, h\u2081, h\u2082\u27e9, h\u2083\u27e9\u27e9\n\n@[simp] theorem bind_map {\u03b3} (f : \u03b1 \u2192 \u03b2) (x) (g : \u03b2 \u2192 roption \u03b3) :\n  (map f x).bind g = x.bind (\u03bb y, g (f y)) :=\nby rw [\u2190 bind_some_eq_map, bind_assoc]; simp\n\n@[simp] theorem map_bind {\u03b3} (f : \u03b1 \u2192 roption \u03b2) (x : roption \u03b1) (g : \u03b2 \u2192 \u03b3) :\n  map g (x.bind f) = x.bind (\u03bb y, map g (f y)) :=\nby rw [\u2190 bind_some_eq_map, bind_assoc]; simp [bind_some_eq_map]\n\ntheorem map_map (g : \u03b2 \u2192 \u03b3) (f : \u03b1 \u2192 \u03b2) (o : roption \u03b1) :\n  map g (map f o) = map (g \u2218 f) o :=\nby rw [\u2190 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 := \u03bb \u03b2 f, by cases f; refl,\n  pure_bind := @bind_some,\n  bind_assoc := @bind_assoc }\n\ntheorem map_id' {f : \u03b1 \u2192 \u03b1} (H : \u2200 (x : \u03b1), 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 \u03b1) : x.bind some = x :=\nby rw [bind_some_eq_map]; simp [map_id']\n\n@[simp] theorem pure_eq_some (a : \u03b1) : pure a = some a := rfl\n@[simp] theorem ret_eq_some (a : \u03b1) : return a = some a := rfl\n\n@[simp] theorem map_eq_map {\u03b1 \u03b2} (f : \u03b1 \u2192 \u03b2) (o : roption \u03b1) :\n  f <$> o = map f o := rfl\n\n@[simp] theorem bind_eq_bind {\u03b1 \u03b2} (f : roption \u03b1) (g : \u03b1 \u2192 roption \u03b2) :\n  f >>= g = f.bind g := rfl\n\nlemma bind_le {\u03b1} (x : roption \u03b1) (f : \u03b1 \u2192 roption \u03b2) (y : roption \u03b2) :\n  x >>= f \u2264 y \u2194 (\u2200 a, a \u2208 x \u2192 f a \u2264 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 \u27e8a,h\u2080,h\u2081\u27e9, apply h _ h\u2080 _ h\u2081 },\nend\n\ninstance : monad_fail roption :=\n{ fail := \u03bb_ _, 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) : \u2200 (o : roption \u03b1), (p \u2192 o.dom) \u2192 roption \u03b1\n| \u27e8d, f\u27e9 H := \u27e8p, \u03bbh, f (H h)\u27e9\n\n@[simp]\ntheorem mem_restrict (p : Prop) (o : roption \u03b1) (h : p \u2192 o.dom) (a : \u03b1) :\n  a \u2208 restrict p o h \u2194 p \u2227 a \u2208 o :=\nbegin\n  cases o, dsimp [restrict, mem_eq], split,\n  { rintro \u27e8h\u2080, h\u2081\u27e9, exact \u27e8h\u2080, \u27e8_, h\u2081\u27e9\u27e9 },\n  rintro \u27e8h\u2080, h\u2081, h\u2082\u27e9, exact \u27e8h\u2080, h\u2082\u27e9\nend\n\n/-- `unwrap o` gets the value at `o`, ignoring the condition.\n  (This function is unsound.) -/\nmeta def unwrap (o : roption \u03b1) : \u03b1 := o.get undefined\n\ntheorem assert_defined {p : Prop} {f : p \u2192 roption \u03b1} :\n  \u2200 (h : p), (f h).dom \u2192 (assert p f).dom := exists.intro\n\ntheorem bind_defined {f : roption \u03b1} {g : \u03b1 \u2192 roption \u03b2} :\n  \u2200 (h : f.dom), (g (f.get h)).dom \u2192 (f.bind g).dom := assert_defined\n\n@[simp] theorem bind_dom {f : roption \u03b1} {g : \u03b1 \u2192 roption \u03b2} :\n  (f.bind g).dom \u2194 \u2203 h : f.dom, (g (f.get h)).dom := iff.rfl\n\nend roption\n\n/-- `pfun \u03b1 \u03b2`, or `\u03b1 \u2192. \u03b2`, is the type of partial functions from\n  `\u03b1` to `\u03b2`. It is defined as `\u03b1 \u2192 roption \u03b2`. -/\ndef pfun (\u03b1 : Type*) (\u03b2 : Type*) := \u03b1 \u2192 roption \u03b2\n\ninfixr ` \u2192. `:25 := pfun\n\nnamespace pfun\nvariables {\u03b1 : Type*} {\u03b2 : Type*} {\u03b3 : Type*}\n\ninstance : inhabited (\u03b1 \u2192. \u03b2) := \u27e8\u03bb a, roption.none\u27e9\n\n/-- The domain of a partial function -/\ndef dom (f : \u03b1 \u2192. \u03b2) : set \u03b1 := {a | (f a).dom}\n\ntheorem mem_dom (f : \u03b1 \u2192. \u03b2) (x : \u03b1) : x \u2208 dom f \u2194 \u2203 y, y \u2208 f x :=\nby simp [dom, roption.dom_iff_mem]\n\ntheorem dom_eq (f : \u03b1 \u2192. \u03b2) : dom f = {x | \u2203 y, y \u2208 f x} :=\nset.ext (mem_dom f)\n\n/-- Evaluate a partial function -/\ndef fn (f : \u03b1 \u2192. \u03b2) (x) (h : dom f x) : \u03b2 := (f x).get h\n\n/-- Evaluate a partial function to return an `option` -/\ndef eval_opt (f : \u03b1 \u2192. \u03b2) [D : decidable_pred (dom f)] (x : \u03b1) : option \u03b2 :=\n@roption.to_option _ _ (D x)\n\n/-- Partial function extensionality -/\ntheorem ext' {f g : \u03b1 \u2192. \u03b2}\n  (H1 : \u2200 a, a \u2208 dom f \u2194 a \u2208 dom g)\n  (H2 : \u2200 a p q, f.fn a p = g.fn a q) : f = g :=\nfunext $ \u03bb a, roption.ext' (H1 a) (H2 a)\n\ntheorem ext {f g : \u03b1 \u2192. \u03b2} (H : \u2200 a b, b \u2208 f a \u2194 b \u2208 g a) : f = g :=\nfunext $ \u03bb a, roption.ext (H a)\n\n/-- Turn a partial function into a function out of a subtype -/\ndef as_subtype (f : \u03b1 \u2192. \u03b2) (s : f.dom) : \u03b2 := f.fn s s.2\n\n/-- The set of partial functions `\u03b1 \u2192. \u03b2` is equivalent to\nthe set of pairs `(p : \u03b1 \u2192 Prop, f : subtype p \u2192 \u03b2)`. -/\ndef equiv_subtype : (\u03b1 \u2192. \u03b2) \u2243 (\u03a3 p : \u03b1 \u2192 Prop, subtype p \u2192 \u03b2) :=\n\u27e8\u03bb f, \u27e8\u03bb a, (f a).dom, as_subtype f\u27e9,\n \u03bb f x, \u27e8f.1 x, \u03bb h, f.2 \u27e8x, h\u27e9\u27e9,\n \u03bb f, funext $ \u03bb a, roption.eta _,\n \u03bb \u27e8p, f\u27e9, by dsimp; congr; funext a; cases a; refl\u27e9\n\ntheorem as_subtype_eq_of_mem {f : \u03b1 \u2192. \u03b2} {x : \u03b1} {y : \u03b2} (fxy : y \u2208 f x) (domx : x \u2208 f.dom) :\n  f.as_subtype \u27e8x, domx\u27e9 = y :=\nroption.mem_unique (roption.get_mem _) fxy\n\n/-- Turn a total function into a partial function -/\nprotected def lift (f : \u03b1 \u2192 \u03b2) : \u03b1 \u2192. \u03b2 := \u03bb a, roption.some (f a)\n\ninstance : has_coe (\u03b1 \u2192 \u03b2) (\u03b1 \u2192. \u03b2) := \u27e8pfun.lift\u27e9\n\n@[simp] theorem lift_eq_coe (f : \u03b1 \u2192 \u03b2) : pfun.lift f = f := rfl\n\n@[simp] theorem coe_val (f : \u03b1 \u2192 \u03b2) (a : \u03b1) :\n  (f : \u03b1 \u2192. \u03b2) 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 : \u03b1 \u2192. \u03b2) : set (\u03b1 \u00d7 \u03b2) := {p | p.2 \u2208 f p.1}\n\ndef graph' (f : \u03b1 \u2192. \u03b2) : rel \u03b1 \u03b2 := \u03bb x y, y \u2208 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 : \u03b1 \u2192. \u03b2) : set \u03b2 := {b | \u2203a, b \u2208 f a}\n\n/-- Restrict a partial function to a smaller domain. -/\ndef restrict (f : \u03b1 \u2192. \u03b2) {p : set \u03b1} (H : p \u2286 f.dom) : \u03b1 \u2192. \u03b2 :=\n\u03bb x, roption.restrict (x \u2208 p) (f x) (@H x)\n\n@[simp]\ntheorem mem_restrict {f : \u03b1 \u2192. \u03b2} {s : set \u03b1} (h : s \u2286 f.dom) (a : \u03b1) (b : \u03b2) :\n  b \u2208 restrict f h a \u2194 a \u2208 s \u2227 b \u2208 f a :=\nby simp [restrict]\n\ndef res (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) : \u03b1 \u2192. \u03b2 :=\nrestrict (pfun.lift f) (set.subset_univ s)\n\ntheorem mem_res (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (a : \u03b1) (b : \u03b2) :\n  b \u2208 res f s a \u2194 (a \u2208 s \u2227 f a = b) :=\nby simp [res, @eq_comm _ b]\n\ntheorem res_univ (f : \u03b1 \u2192 \u03b2) : pfun.res f set.univ = f :=\nrfl\n\ntheorem dom_iff_graph (f : \u03b1 \u2192. \u03b2) (x : \u03b1) : x \u2208 f.dom \u2194 \u2203y, (x, y) \u2208 f.graph :=\nroption.dom_iff_mem\n\ntheorem lift_graph {f : \u03b1 \u2192 \u03b2} {a b} : (a, b) \u2208 (f : \u03b1 \u2192. \u03b2).graph \u2194 f a = b :=\nshow (\u2203 (h : true), f a = b) \u2194 f a = b, by simp\n\n/-- The monad `pure` function, the total constant `x` function -/\nprotected def pure (x : \u03b2) : \u03b1 \u2192. \u03b2 := \u03bb_, roption.some x\n\n/-- The monad `bind` function, pointwise `roption.bind` -/\ndef bind (f : \u03b1 \u2192. \u03b2) (g : \u03b2 \u2192 \u03b1 \u2192. \u03b3) : \u03b1 \u2192. \u03b3 :=\n\u03bba, roption.bind (f a) (\u03bbb, g b a)\n\n/-- The monad `map` function, pointwise `roption.map` -/\ndef map (f : \u03b2 \u2192 \u03b3) (g : \u03b1 \u2192. \u03b2) : \u03b1 \u2192. \u03b3 :=\n\u03bba, roption.map f (g a)\n\ninstance : monad (pfun \u03b1) :=\n{ pure := @pfun.pure _,\n  bind := @pfun.bind _,\n  map := @pfun.map _ }\n\ninstance : is_lawful_monad (pfun \u03b1) :=\n{ bind_pure_comp_eq_map := \u03bb \u03b2 \u03b3 f x, funext $ \u03bb a, roption.bind_some_eq_map _ _,\n  id_map := \u03bb \u03b2 f, by funext a; dsimp [functor.map, pfun.map]; cases f a; refl,\n  pure_bind := \u03bb \u03b2 \u03b3 x f, funext $ \u03bb a, roption.bind_some.{u_1 u_2} _ (f x),\n  bind_assoc := \u03bb \u03b2 \u03b3 \u03b4 f g k,\n    funext $ \u03bb a, roption.bind_assoc (f a) (\u03bb b, g b a) (\u03bb b, k b a) }\n\ntheorem pure_defined (p : set \u03b1) (x : \u03b2) : p \u2286 (@pfun.pure \u03b1 _ x).dom := set.subset_univ p\n\ntheorem bind_defined {\u03b1 \u03b2 \u03b3} (p : set \u03b1) {f : \u03b1 \u2192. \u03b2} {g : \u03b2 \u2192 \u03b1 \u2192. \u03b3}\n  (H1 : p \u2286 f.dom) (H2 : \u2200x, p \u2286 (g x).dom) : p \u2286 (f >>= g).dom :=\n\u03bba ha, (\u27e8H1 ha, H2 _ ha\u27e9 : (f >>= g).dom a)\n\ndef fix (f : \u03b1 \u2192. \u03b2 \u2295 \u03b1) : \u03b1 \u2192. \u03b2 := \u03bb a,\nroption.assert (acc (\u03bb x y, sum.inr x \u2208 f y) a) $ \u03bb h,\n@well_founded.fix_F _ (\u03bb x y, sum.inr x \u2208 f y) _\n  (\u03bb a IH, roption.assert (f a).dom $ \u03bb hf,\n    by cases e : (f a).get hf with b a';\n      [exact roption.some b, exact IH _ \u27e8hf, e\u27e9])\n  a h\n\ntheorem dom_of_mem_fix {f : \u03b1 \u2192. \u03b2 \u2295 \u03b1} {a : \u03b1} {b : \u03b2}\n  (h : b \u2208 fix f a) : (f a).dom :=\nlet \u27e8h\u2081, h\u2082\u27e9 := roption.mem_assert_iff.1 h in\nby rw well_founded.fix_F_eq at h\u2082; exact h\u2082.fst.fst\n\ntheorem mem_fix_iff {f : \u03b1 \u2192. \u03b2 \u2295 \u03b1} {a : \u03b1} {b : \u03b2} :\n  b \u2208 fix f a \u2194 sum.inl b \u2208 f a \u2228 \u2203 a', sum.inr a' \u2208 f a \u2227 b \u2208 fix f a' :=\n\u27e8\u03bb h, let \u27e8h\u2081, h\u2082\u27e9 := roption.mem_assert_iff.1 h in\n  begin\n    rw well_founded.fix_F_eq at h\u2082,\n    simp at h\u2082,\n    cases h\u2082 with h\u2082 h\u2083,\n    cases e : (f a).get h\u2082 with b' a'; simp [e] at h\u2083,\n    { subst b', refine or.inl \u27e8h\u2082, e\u27e9 },\n    { exact or.inr \u27e8a', \u27e8_, e\u27e9, roption.mem_assert _ h\u2083\u27e9 }\n  end,\n\u03bb h, begin\n  simp [fix],\n  rcases h with \u27e8h\u2081, h\u2082\u27e9 | \u27e8a', h, h\u2083\u27e9,\n  { refine \u27e8\u27e8_, \u03bb y h', _\u27e9, _\u27e9,\n    { injection roption.mem_unique \u27e8h\u2081, h\u2082\u27e9 h' },\n    { rw well_founded.fix_F_eq, simp [h\u2081, h\u2082] } },\n  { simp [fix] at h\u2083, cases h\u2083 with h\u2083 h\u2084,\n    refine \u27e8\u27e8_, \u03bb y h', _\u27e9, _\u27e9,\n    { injection roption.mem_unique h h' with e,\n      exact e \u25b8 h\u2083 },\n    { cases h with h\u2081 h\u2082,\n      rw well_founded.fix_F_eq, simp [h\u2081, h\u2082, h\u2084] } }\nend\u27e9\n\n@[elab_as_eliminator] def fix_induction\n  {f : \u03b1 \u2192. \u03b2 \u2295 \u03b1} {b : \u03b2} {C : \u03b1 \u2192 Sort*} {a : \u03b1} (h : b \u2208 fix f a)\n  (H : \u2200 a, b \u2208 fix f a \u2192\n    (\u2200 a', b \u2208 fix f a' \u2192 sum.inr a' \u2208 f a \u2192 C a') \u2192 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\u2082,\n  refine H a (roption.mem_assert_iff.2 \u27e8\u27e8_, ha\u27e9, h\u2082\u27e9)\n    (\u03bb a' ha' fa', _),\n  have := (roption.mem_assert_iff.1 ha').snd,\n  exact IH _ fa' \u27e8ha _ fa', this\u27e9 this\nend\n\nend pfun\n\nnamespace pfun\n\nvariables {\u03b1 : Type*} {\u03b2 : Type*} (f : \u03b1 \u2192. \u03b2)\n\ndef image (s : set \u03b1) : set \u03b2 := rel.image f.graph' s\n\nlemma image_def (s : set \u03b1) : image f s = {y | \u2203 x \u2208 s, y \u2208 f x} := rfl\n\nlemma mem_image (y : \u03b2) (s : set \u03b1) : y \u2208 image f s \u2194 \u2203 x \u2208 s, y \u2208 f x :=\niff.rfl\n\nlemma image_mono {s t : set \u03b1} (h : s \u2286 t) : f.image s \u2286 f.image t :=\nrel.image_mono _ h\n\nlemma image_inter (s t : set \u03b1) : f.image (s \u2229 t) \u2286 f.image s \u2229 f.image t :=\nrel.image_inter _ s t\n\nlemma image_union (s t : set \u03b1) : f.image (s \u222a t) = f.image s \u222a f.image t :=\nrel.image_union _ s t\n\ndef preimage (s : set \u03b2) : set \u03b1 := rel.preimage (\u03bb x y, y \u2208 f x) s\n\nlemma preimage_def (s : set \u03b2) : preimage f s = {x | \u2203 y \u2208 s, y \u2208 f x} := rfl\n\nlemma mem_preimage (s : set \u03b2) (x : \u03b1) : x \u2208 preimage f s \u2194 \u2203 y \u2208 s, y \u2208 f x :=\niff.rfl\n\nlemma preimage_subset_dom (s : set \u03b2) : f.preimage s \u2286 f.dom :=\nassume x \u27e8y, ys, fxy\u27e9, roption.dom_iff_mem.mpr \u27e8y, fxy\u27e9\n\nlemma preimage_mono {s t : set \u03b2} (h : s \u2286 t) : f.preimage s \u2286 f.preimage t :=\nrel.preimage_mono _ h\n\nlemma preimage_inter (s t : set \u03b2) : f.preimage (s \u2229 t) \u2286 f.preimage s \u2229 f.preimage t :=\nrel.preimage_inter _ s t\n\nlemma preimage_union (s t : set \u03b2) : f.preimage (s \u222a t) = f.preimage s \u222a 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 \u03b2) : set \u03b1 := rel.core f.graph' s\n\nlemma core_def (s : set \u03b2) : core f s = {x | \u2200 y, y \u2208 f x \u2192 y \u2208 s} := rfl\n\nlemma mem_core (x : \u03b1) (s : set \u03b2) : x \u2208 core f s \u2194 (\u2200 y, y \u2208 f x \u2192 y \u2208 s) :=\niff.rfl\n\nlemma compl_dom_subset_core (s : set \u03b2) : f.dom\u1d9c \u2286 f.core s :=\nassume x hx y fxy,\nabsurd ((mem_dom f x).mpr \u27e8y, fxy\u27e9) hx\n\nlemma core_mono {s t : set \u03b2} (h : s \u2286 t) : f.core s \u2286 f.core t :=\nrel.core_mono _ h\n\nlemma core_inter (s t : set \u03b2) : f.core (s \u2229 t) = f.core s \u2229 f.core t :=\nrel.core_inter _ s t\n\nlemma mem_core_res (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (t : set \u03b2) (x : \u03b1) :\n  x \u2208 core (res f s) t \u2194 (x \u2208 s \u2192 f x \u2208 t) :=\nby simp [mem_core, mem_res]\n\nsection\nopen_locale classical\n\nlemma core_res (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) (t : set \u03b2) : core (res f s) t = s\u1d9c \u222a f \u207b\u00b9' t :=\nby { ext, rw mem_core_res, by_cases h : x \u2208 s; simp [h] }\n\nend\n\nlemma core_restrict (f : \u03b1 \u2192 \u03b2) (s : set \u03b2) : core (f : \u03b1 \u2192. \u03b2) s = set.preimage f s :=\nby ext x; simp [core_def]\n\nlemma preimage_subset_core (f : \u03b1 \u2192. \u03b2) (s : set \u03b2) : f.preimage s \u2286 f.core s :=\nassume x \u27e8y, ys, fxy\u27e9 y' fxy',\nhave y = y', from roption.mem_unique fxy fxy',\nthis \u25b8 ys\n\nlemma preimage_eq (f : \u03b1 \u2192. \u03b2) (s : set \u03b2) : f.preimage s = f.core s \u2229 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 \u27e8xcore, xdom\u27e9,\n    let y := (f x).get xdom in\n    have ys : y \u2208 s, from xcore _ (roption.get_mem _),\n    show x \u2208 preimage f s, from  \u27e8(f x).get xdom, ys, roption.get_mem _\u27e9)\n\nlemma core_eq (f : \u03b1 \u2192. \u03b2) (s : set \u03b2) : f.core s = f.preimage s \u222a f.dom\u1d9c :=\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 : \u03b1 \u2192. \u03b2) (s : set \u03b2) :\n  f.as_subtype \u207b\u00b9' s = subtype.val \u207b\u00b9' 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) _ \u2208 s \u2194 \u2203 y \u2208 s, y \u2208 f (x.val),\n  exact iff.intro\n    (assume h, \u27e8_, h, roption.get_mem _\u27e9)\n    (assume \u27e8y, ys, fxy\u27e9,\n      have f.fn x.val x.property \u2208 f x.val := roption.get_mem _,\n      roption.mem_unique fxy this \u25b8 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 \u2192\u2090[R] A`: the canonical map from `R` to `A`, as an `alg_hom`.\n\n## Notations\n\n* `A \u2192\u2090[R] B` : `R`-algebra homomorphism from `A` to `B`.\n-/\n\nopen_locale big_operators\n\nuniverses u v w u\u2081 v\u2081\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' : \u2200 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 ` \u2192\u2090 `:25 := alg_hom _\nnotation A ` \u2192\u2090[`: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 : \u2200 (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\u209b\u2097 := \u03bb f r x, by simp only [algebra.smul_def, map_mul, commutes, ring_hom.id_apply],\n  ..\u2039alg_hom_class F R A B\u203a }\n\ninstance {F : Type*} [alg_hom_class F R A B] : has_coe_t F (A \u2192\u2090[R] B) :=\n{ coe := \u03bb f,\n  { to_fun := f,\n    commutes' := alg_hom_class.commutes f,\n    .. (f : A \u2192+* B) } }\n\nend alg_hom_class\n\nnamespace alg_hom\n\nvariables {R : Type u} {A : Type v} {B : Type w} {C : Type u\u2081} {D : Type v\u2081}\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 \u2192\u2090[R] B) (\u03bb _, A \u2192 B) := \u27e8alg_hom.to_fun\u27e9\n\ninitialize_simps_projections alg_hom (to_fun \u2192 apply)\n\n@[simp, protected] lemma coe_coe {F : Type*} [alg_hom_class F R A B] (f : F) :\n  \u21d1(f : A \u2192\u2090[R] B) = f := rfl\n\n@[simp] lemma to_fun_eq_coe (f : A \u2192\u2090[R] B) : f.to_fun = f := rfl\n\ninstance : alg_hom_class (A \u2192\u2090[R] B) R A B :=\n{ coe := to_fun,\n  coe_injective' := \u03bb 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 := \u03bb f, f.commutes' }\n\ninstance coe_ring_hom : has_coe (A \u2192\u2090[R] B) (A \u2192+* B) := \u27e8alg_hom.to_ring_hom\u27e9\n\ninstance coe_monoid_hom : has_coe (A \u2192\u2090[R] B) (A \u2192* B) := \u27e8\u03bb f, \u2191(f : A \u2192+* B)\u27e9\n\ninstance coe_add_monoid_hom : has_coe (A \u2192\u2090[R] B) (A \u2192+ B) := \u27e8\u03bb f, \u2191(f : A \u2192+* B)\u27e9\n\n@[simp, norm_cast] lemma coe_mk {f : A \u2192 B} (h\u2081 h\u2082 h\u2083 h\u2084 h\u2085) :\n  \u21d1(\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085\u27e9 : A \u2192\u2090[R] B) = f := rfl\n\n-- make the coercion the simp-normal form\n@[simp] lemma to_ring_hom_eq_coe (f : A \u2192\u2090[R] B) : f.to_ring_hom = f := rfl\n\n@[simp, norm_cast] lemma coe_to_ring_hom (f : A \u2192\u2090[R] B) : \u21d1(f : A \u2192+* B) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_monoid_hom (f : A \u2192\u2090[R] B) : \u21d1(f : A \u2192* B) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_add_monoid_hom (f : A \u2192\u2090[R] B) : \u21d1(f : A \u2192+ B) = f := rfl\n\nvariables (\u03c6 : A \u2192\u2090[R] B)\n\ntheorem coe_fn_injective : @function.injective (A \u2192\u2090[R] B) (A \u2192 B) coe_fn := fun_like.coe_injective\n\ntheorem coe_fn_inj {\u03c6\u2081 \u03c6\u2082 : A \u2192\u2090[R] B} : (\u03c6\u2081 : A \u2192 B) = \u03c6\u2082 \u2194 \u03c6\u2081 = \u03c6\u2082 := fun_like.coe_fn_eq\n\ntheorem coe_ring_hom_injective : function.injective (coe : (A \u2192\u2090[R] B) \u2192 (A \u2192+* B)) :=\n\u03bb \u03c6\u2081 \u03c6\u2082 H, coe_fn_injective $ show ((\u03c6\u2081 : (A \u2192+* B)) : A \u2192 B) = ((\u03c6\u2082 : (A \u2192+* B)) : A \u2192 B),\n  from congr_arg _ H\n\ntheorem coe_monoid_hom_injective : function.injective (coe : (A \u2192\u2090[R] B)  \u2192 (A \u2192* B)) :=\nring_hom.coe_monoid_hom_injective.comp coe_ring_hom_injective\n\ntheorem coe_add_monoid_hom_injective : function.injective (coe : (A \u2192\u2090[R] B)  \u2192 (A \u2192+ B)) :=\nring_hom.coe_add_monoid_hom_injective.comp coe_ring_hom_injective\n\nprotected lemma congr_fun {\u03c6\u2081 \u03c6\u2082 : A \u2192\u2090[R] B} (H : \u03c6\u2081 = \u03c6\u2082) (x : A) : \u03c6\u2081 x = \u03c6\u2082 x :=\nfun_like.congr_fun H x\nprotected lemma congr_arg (\u03c6 : A \u2192\u2090[R] B) {x y : A} (h : x = y) : \u03c6 x = \u03c6 y :=\nfun_like.congr_arg \u03c6 h\n\n@[ext]\ntheorem ext {\u03c6\u2081 \u03c6\u2082 : A \u2192\u2090[R] B} (H : \u2200 x, \u03c6\u2081 x = \u03c6\u2082 x) : \u03c6\u2081 = \u03c6\u2082 := fun_like.ext _ _ H\n\ntheorem ext_iff {\u03c6\u2081 \u03c6\u2082 : A \u2192\u2090[R] B} : \u03c6\u2081 = \u03c6\u2082 \u2194 \u2200 x, \u03c6\u2081 x = \u03c6\u2082 x := fun_like.ext_iff\n\n@[simp] theorem mk_coe {f : A \u2192\u2090[R] B} (h\u2081 h\u2082 h\u2083 h\u2084 h\u2085) :\n  (\u27e8f, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085\u27e9 : A \u2192\u2090[R] B) = f := ext $ \u03bb _, rfl\n\n@[simp]\ntheorem commutes (r : R) : \u03c6 (algebra_map R A r) = algebra_map R B r := \u03c6.commutes' r\n\ntheorem comp_algebra_map : (\u03c6 : A \u2192+* B).comp (algebra_map R A) = algebra_map R B :=\nring_hom.ext $ \u03c6.commutes\n\nprotected lemma map_add (r s : A) : \u03c6 (r + s) = \u03c6 r + \u03c6 s := map_add _ _ _\nprotected lemma map_zero : \u03c6 0 = 0 := map_zero _\nprotected lemma map_mul (x y) : \u03c6 (x * y) = \u03c6 x * \u03c6 y := map_mul _ _ _\nprotected lemma map_one : \u03c6 1 = 1 := map_one _\nprotected lemma map_pow (x : A) (n : \u2115) : \u03c6 (x ^ n) = (\u03c6 x) ^ n := map_pow _ _ _\n\n@[simp] protected lemma map_smul (r : R) (x : A) : \u03c6 (r \u2022 x) = r \u2022 \u03c6 x := map_smul _ _ _\n\nprotected lemma map_sum {\u03b9 : Type*} (f : \u03b9 \u2192 A) (s : finset \u03b9) :\n  \u03c6 (\u2211 x in s, f x) = \u2211 x in s, \u03c6 (f x) := map_sum _ _ _\n\nprotected lemma map_finsupp_sum {\u03b1 : Type*} [has_zero \u03b1] {\u03b9 : Type*} (f : \u03b9 \u2192\u2080 \u03b1) (g : \u03b9 \u2192 \u03b1 \u2192 A) :\n  \u03c6 (f.sum g) = f.sum (\u03bb i a, \u03c6 (g i a)) := map_finsupp_sum _ _ _\n\nprotected lemma map_bit0 (x) : \u03c6 (bit0 x) = bit0 (\u03c6 x) := map_bit0 _ _\nprotected lemma map_bit1 (x) : \u03c6 (bit1 x) = bit1 (\u03c6 x) := map_bit1 _ _\n\n/-- If a `ring_hom` is `R`-linear, then it is an `alg_hom`. -/\ndef mk' (f : A \u2192+* B) (h : \u2200 (c : R) x, f (c \u2022 x) = c \u2022 f x) : A \u2192\u2090[R] B :=\n{ to_fun := f,\n  commutes' := \u03bb 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 \u2192\u2090[R] A :=\n{ commutes' := \u03bb _, rfl,\n  ..ring_hom.id A }\n\n@[simp] lemma coe_id : \u21d1(alg_hom.id R A) = id := rfl\n\n@[simp] lemma id_to_ring_hom : (alg_hom.id R A : A \u2192+* 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 (\u03c6\u2081 : B \u2192\u2090[R] C) (\u03c6\u2082 : A \u2192\u2090[R] B) : A \u2192\u2090[R] C :=\n{ commutes' := \u03bb r : R, by rw [\u2190 \u03c6\u2081.commutes, \u2190 \u03c6\u2082.commutes]; refl,\n  .. \u03c6\u2081.to_ring_hom.comp \u2191\u03c6\u2082 }\n\n@[simp] lemma coe_comp (\u03c6\u2081 : B \u2192\u2090[R] C) (\u03c6\u2082 : A \u2192\u2090[R] B) : \u21d1(\u03c6\u2081.comp \u03c6\u2082) = \u03c6\u2081 \u2218 \u03c6\u2082 := rfl\n\nlemma comp_apply (\u03c6\u2081 : B \u2192\u2090[R] C) (\u03c6\u2082 : A \u2192\u2090[R] B) (p : A) : \u03c6\u2081.comp \u03c6\u2082 p = \u03c6\u2081 (\u03c6\u2082 p) := rfl\n\nlemma comp_to_ring_hom (\u03c6\u2081 : B \u2192\u2090[R] C) (\u03c6\u2082 : A \u2192\u2090[R] B) :\n  (\u03c6\u2081.comp \u03c6\u2082 : A \u2192+* C) = (\u03c6\u2081 : B \u2192+* C).comp \u2191\u03c6\u2082 := rfl\n\n@[simp] theorem comp_id : \u03c6.comp (alg_hom.id R A) = \u03c6 :=\next $ \u03bb x, rfl\n\n@[simp] theorem id_comp : (alg_hom.id R B).comp \u03c6 = \u03c6 :=\next $ \u03bb x, rfl\n\ntheorem comp_assoc (\u03c6\u2081 : C \u2192\u2090[R] D) (\u03c6\u2082 : B \u2192\u2090[R] C) (\u03c6\u2083 : A \u2192\u2090[R] B) :\n  (\u03c6\u2081.comp \u03c6\u2082).comp \u03c6\u2083 = \u03c6\u2081.comp (\u03c6\u2082.comp \u03c6\u2083) :=\next $ \u03bb x, rfl\n\n/-- R-Alg \u2964 R-Mod -/\ndef to_linear_map : A \u2192\u2097[R] B :=\n{ to_fun := \u03c6,\n  map_add' := map_add _,\n  map_smul' := map_smul _ }\n\n@[simp] lemma to_linear_map_apply (p : A) : \u03c6.to_linear_map p = \u03c6 p := rfl\n\ntheorem to_linear_map_injective : function.injective (to_linear_map : _ \u2192 (A \u2192\u2097[R] B)) :=\n\u03bb \u03c6\u2081 \u03c6\u2082 h, ext $ linear_map.congr_fun h\n\n@[simp] lemma comp_to_linear_map (f : A \u2192\u2090[R] B) (g : B \u2192\u2090[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 $ \u03bb _, 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 \u2192\u2097[R] B) (map_one : f 1 = 1) (map_mul : \u2200 x y, f (x * y) = f x * f y) :\n  A \u2192\u2090[R] B :=\n{ to_fun := f,\n  map_one' := map_one,\n  map_mul' := map_mul,\n  commutes' := \u03bb 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 \u03c6.to_linear_map map_one map_mul = \u03c6 :=\nby { ext, refl }\n\n@[simp] lemma to_linear_map_of_linear_map (f : A \u2192\u2097[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 $ \u03bb _, 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) : \u03c6 (r \u2022 x) = r \u2022 \u03c6 x :=\n\u03c6.to_linear_map.map_smul_of_tower r x\n\nlemma map_list_prod (s : list A) :\n  \u03c6 s.prod = (s.map \u03c6).prod :=\n\u03c6.to_ring_hom.map_list_prod s\n\n@[simps mul one {attrs := []}] instance End : monoid (A \u2192\u2090[R] A) :=\n{ mul := comp,\n  mul_assoc := \u03bb \u03d5 \u03c8 \u03c7, rfl,\n  one := alg_hom.id R A,\n  one_mul := \u03bb \u03d5, ext $ \u03bb x, rfl,\n  mul_one := \u03bb \u03d5, ext $ \u03bb x, rfl }\n\n@[simp] lemma one_apply (x : A) : (1 : A \u2192\u2090[R] A) x = x := rfl\n\n@[simp] lemma mul_apply (\u03c6 \u03c8 : A \u2192\u2090[R] A) (x : A) : (\u03c6 * \u03c8) x = \u03c6 (\u03c8 x) := rfl\n\nlemma algebra_map_eq_apply (f : A \u2192\u2090[R] B) {y : R} {x : A} (h : algebra_map R A y = x) :\n  algebra_map R B y = f x :=\nh \u25b8 (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] (\u03c6 : A \u2192\u2090[R] B)\n\nprotected lemma map_multiset_prod (s : multiset A) :\n  \u03c6 s.prod = (s.map \u03c6).prod := map_multiset_prod _ _\n\nprotected lemma map_prod {\u03b9 : Type*} (f : \u03b9 \u2192 A) (s : finset \u03b9) :\n  \u03c6 (\u220f x in s, f x) = \u220f x in s, \u03c6 (f x) := map_prod _ _ _\n\nprotected lemma map_finsupp_prod {\u03b1 : Type*} [has_zero \u03b1] {\u03b9 : Type*} (f : \u03b9 \u2192\u2080 \u03b1) (g : \u03b9 \u2192 \u03b1 \u2192 A) :\n  \u03c6 (f.prod g) = f.prod (\u03bb i a, \u03c6 (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] (\u03c6 : A \u2192\u2090[R] B)\n\nprotected lemma map_neg (x) : \u03c6 (-x) = -\u03c6 x := map_neg _ _\nprotected lemma map_sub (x y) : \u03c6 (x - y) = \u03c6 x - \u03c6 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 `\u2115`-algebra homomorphism. -/\ndef to_nat_alg_hom [semiring R] [semiring S] (f : R \u2192+* S) :\n  R \u2192\u2090[\u2115] S :=\n{ to_fun := f, commutes' := \u03bb n, by simp, .. f }\n\n/-- Reinterpret a `ring_hom` as a `\u2124`-algebra homomorphism. -/\ndef to_int_alg_hom [ring R] [ring S] [algebra \u2124 R] [algebra \u2124 S] (f : R \u2192+* S) :\n  R \u2192\u2090[\u2124] S :=\n{ commutes' := \u03bb n, by simp, .. f }\n\n/-- Reinterpret a `ring_hom` as a `\u211a`-algebra homomorphism. This actually yields an equivalence,\nsee `ring_hom.equiv_rat_alg_hom`. -/\ndef to_rat_alg_hom [ring R] [ring S] [algebra \u211a R] [algebra \u211a S] (f : R \u2192+* S) :\n  R \u2192\u2090[\u211a] 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 \u211a R] [algebra \u211a S]\n  (f : R \u2192+* S) : \u2191f.to_rat_alg_hom = f :=\nring_hom.ext $ \u03bb 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 \u211a R] [algebra \u211a S]\n  (f : R \u2192\u2090[\u211a] S) : (f : R \u2192+* S).to_rat_alg_hom = f :=\nalg_hom.ext $ \u03bb x, rfl\n\n/-- The equivalence between `ring_hom` and `\u211a`-algebra homomorphisms. -/\n@[simps]\ndef ring_hom.equiv_rat_alg_hom [ring R] [ring S] [algebra \u211a R] [algebra \u211a S] :\n  (R \u2192+* S) \u2243 (R \u2192\u2090[\u211a] 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 \u2192\u2090[R] A :=\n{ commutes' := \u03bb _, 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 \u2192\u2090[R] A :=\n{ to_fun := \u03bb a, m \u2022 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 \u2192 A \u2192\u2090[R] A) :=\n\u03bb m\u2081 m\u2082 h, eq_of_smul_eq_smul $ \u03bb 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 \u2964 C` with a left adjoint `F` such\nthat `\u03b5_X : FUX \u27f6 X` is a regular epi. Then for any category `A` with coequalizers of reflexive\npairs, a functor `R : A \u2964 B` has a left adjoint if (and only if) the composite `R \u22d9 U` does.\nNote that the condition on `U` regarding `\u03b5_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 \u2964 B` has a left adjoint provided `R \u22d9 U` does.\n\nThe adjoint lifting theorem says that given a commutative square of functors (up to isomorphism):\n\n      Q\n    A \u2192 B\n  U \u2193   \u2193 V\n    C \u2192 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 `(\u03b7, \u03b5)` for the unit\nand counit of the adjunction `adj\u2081 : F \u22a3 U` and `(\u03b9, \u03b4)` for the unit and counit of the adjunction\n`adj\u2082 : F' \u22a3 R \u22d9 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\u2081 v\u2082 v\u2083 v\u2084 u\u2081 u\u2082 u\u2083 u\u2084\n\nvariables {A : Type u\u2081} {B : Type u\u2082} {C : Type u\u2083}\nvariables [category.{v\u2081} A] [category.{v\u2082} B] [category.{v\u2083} C]\n\n-- Hide implementation details in this namespace\nnamespace lift_adjoint\n\nvariables {U : B \u2964 C} {F : C \u2964 B} (R : A \u2964 B) (F' : C \u2964 A)\nvariables (adj\u2081 : F \u22a3 U) (adj\u2082 : F' \u22a3 R \u22d9 U)\n\n/--\nTo show that `\u03b5_X` is a coequalizer for `(FU\u03b5_X, \u03b5_FUX)`, it suffices to assume it's always a\ncoequalizer of something (i.e. a regular epi).\n-/\ndef counit_coequalises [\u2200 (X : B), regular_epi (adj\u2081.counit.app X)] (X : B) :\n  is_colimit (cofork.of_\u03c0 (adj\u2081.counit.app X) (adj\u2081.counit_naturality _)) :=\ncofork.is_colimit.mk' _ $ \u03bb s,\nbegin\n  refine \u27e8(regular_epi.desc' (adj\u2081.counit.app X) s.\u03c0 _).1, _, _\u27e9,\n  { rw \u2190 cancel_epi (adj\u2081.counit.app (regular_epi.W (adj\u2081.counit.app X))),\n    rw \u2190 adj\u2081.counit_naturality_assoc,\n    dsimp only [functor.comp_obj],\n    rw [\u2190 s.condition, \u2190 F.map_comp_assoc, \u2190 U.map_comp, regular_epi.w, U.map_comp,\n        F.map_comp_assoc, s.condition, \u2190 adj\u2081.counit_naturality_assoc] },\n  { apply (regular_epi.desc' (adj\u2081.counit.app X) s.\u03c0 _).2 },\n  { intros m hm,\n    rw \u2190 cancel_epi (adj\u2081.counit.app X),\n    apply hm.trans (regular_epi.desc' (adj\u2081.counit.app X) s.\u03c0 _).2.symm }\nend\n\ninclude adj\u2081 adj\u2082\n\n/--\n(Implementation)\nTo construct the left adjoint, we use the coequalizer of `F' U \u03b5_Y` with the composite\n\n`F' U F U X \u27f6 F' U F U R F U' X \u27f6 F' U R F' U X \u27f6 F' U X`\n\nwhere the first morphism is `F' U F \u03b9_UX`, the second is `F' U \u03b5_RF'UX`, and the third is `\u03b4_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))) \u27f6 F'.obj (U.obj X) :=\nF'.map (U.map (F.map (adj\u2082.unit.app _) \u226b adj\u2081.counit.app _)) \u226b adj\u2082.counit.app _\n\n/--\n`(F'U\u03b5_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\u2081.counit.app X))) (other_map _ _ adj\u2081 adj\u2082 X) :=\nis_reflexive_pair.mk'\n  (F'.map (adj\u2081.unit.app (U.obj X)))\n  (by {rw [\u2190 F'.map_comp, adj\u2081.right_triangle_components], apply F'.map_id })\n  begin\n    dsimp [other_map],\n    rw [\u2190 F'.map_comp_assoc, U.map_comp, adj\u2081.unit_naturality_assoc, adj\u2081.right_triangle_components,\n        comp_id, adj\u2082.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\u03b5_Y` with\n`other_map`.\n-/\nnoncomputable def construct_left_adjoint_obj (Y : B) : A :=\ncoequalizer (F'.map (U.map (adj\u2081.counit.app Y))) (other_map _ _ adj\u2081 adj\u2082 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 [\u2200 (X : B), regular_epi (adj\u2081.counit.app X)] (Y : A) (X : B) :\n  (construct_left_adjoint_obj _ _ adj\u2081 adj\u2082 X \u27f6 Y) \u2243 (X \u27f6 R.obj Y) :=\ncalc (construct_left_adjoint_obj _ _ adj\u2081 adj\u2082 X \u27f6 Y)\n        \u2243 {f : F'.obj (U.obj X) \u27f6 Y //\n              F'.map (U.map (adj\u2081.counit.app X)) \u226b f = other_map _ _ adj\u2081 adj\u2082 _ \u226b f} :\n                cofork.is_colimit.hom_iso (colimit.is_colimit _) _\n  ... \u2243 {g : U.obj X \u27f6 U.obj (R.obj Y) //\n          U.map (F.map g \u226b adj\u2081.counit.app _) = U.map (adj\u2081.counit.app _) \u226b g} :\n            begin\n              apply (adj\u2082.hom_equiv _ _).subtype_equiv _,\n              intro f,\n              rw [\u2190 (adj\u2082.hom_equiv _ _).injective.eq_iff, eq_comm, adj\u2082.hom_equiv_naturality_left,\n                  other_map, assoc, adj\u2082.hom_equiv_naturality_left, \u2190 adj\u2082.counit_naturality,\n                  adj\u2082.hom_equiv_naturality_left, adj\u2082.hom_equiv_unit,\n                  adj\u2082.right_triangle_components, comp_id, functor.comp_map, \u2190 U.map_comp, assoc,\n                  \u2190 adj\u2081.counit_naturality, adj\u2082.hom_equiv_unit, adj\u2082.hom_equiv_unit, F.map_comp,\n                  assoc],\n              refl,\n            end\n  ... \u2243 {z : F.obj (U.obj X) \u27f6 R.obj Y // _} :\n            begin\n              apply (adj\u2081.hom_equiv _ _).symm.subtype_equiv,\n              intro g,\n              rw [\u2190 (adj\u2081.hom_equiv _ _).symm.injective.eq_iff, adj\u2081.hom_equiv_counit,\n                  adj\u2081.hom_equiv_counit, adj\u2081.hom_equiv_counit, F.map_comp, assoc, U.map_comp,\n                  F.map_comp, assoc, adj\u2081.counit_naturality, adj\u2081.counit_naturality_assoc],\n              apply eq_comm,\n            end\n  ... \u2243 (X \u27f6 R.obj Y) : (cofork.is_colimit.hom_iso (counit_coequalises adj\u2081 X) _).symm\n\n/-- Construct the left adjoint to `R`, with object map `construct_left_adjoint_obj`. -/\nnoncomputable def construct_left_adjoint [\u2200 (X : B), regular_epi (adj\u2081.counit.app X)] : B \u2964 A :=\nbegin\n  refine adjunction.left_adjoint_of_equiv (\u03bb X Y, construct_left_adjoint_equiv R _ adj\u2081 adj\u2082 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, \u2190 adj\u2081.hom_equiv_naturality_right_symm,\n      cofork.is_colimit.hom_iso_natural, adj\u2082.hom_equiv_naturality_right, functor.comp_map],\nend\n\nend lift_adjoint\n\n/--\nThe adjoint triangle theorem: Suppose `U : B \u2964 C` has a left adjoint `F` such that each counit\n`\u03b5_X : FUX \u27f6 X` is a regular epimorphism. Then if a category `A` has coequalizers of reflexive\npairs, then a functor `R : A \u2964 B` has a left adjoint if the composite `R \u22d9 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 \u2964 C} {F : C \u2964 B} (R : A \u2964 B) (adj\u2081 : F \u22a3 U)\n  [\u03a0 (X : B), regular_epi (adj\u2081.counit.app X)]\n  [has_reflexive_coequalizers A]\n  [is_right_adjoint (R \u22d9 U)] : is_right_adjoint R :=\n{ left := lift_adjoint.construct_left_adjoint R _ adj\u2081 (adjunction.of_right_adjoint _),\n  adj := adjunction.adjunction_of_equiv_left _ _ }\n\n/--\nIf `R \u22d9 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 \u2964 C) [monadic_right_adjoint U] {R : A \u2964 B}\n  [has_reflexive_coequalizers A]\n  [is_right_adjoint (R \u22d9 U)] :\n  is_right_adjoint R :=\nbegin\n  let R' : A \u2964 _ := R \u22d9 monad.comparison (adjunction.of_right_adjoint U),\n  suffices : is_right_adjoint R',\n  { let : is_right_adjoint (R' \u22d9 (monad.comparison (adjunction.of_right_adjoint U)).inv),\n    { resetI,\n      apply_instance },\n    { let : R' \u22d9 (monad.comparison (adjunction.of_right_adjoint U)).inv \u2245 R :=\n        (iso_whisker_left R (monad.comparison _).as_equivalence.unit_iso.symm : _) \u226a\u226b\n          R.right_unitor,\n      exactI adjunction.right_adjoint_of_nat_iso this } },\n  let : is_right_adjoint (R' \u22d9 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 : \u03a0 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 \u27e8_, _, _, _, monad.beck_algebra_coequalizer X\u27e9 },\n  exact adjoint_triangle_lift R' (monad.adj _),\nend\n\nvariables {D : Type u\u2084}\nvariables [category.{v\u2084} D]\n\n/--\nSuppose we have a commutative square of functors\n\n      Q\n    A \u2192 B\n  U \u2193   \u2193 V\n    C \u2192 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 \u2964 B) (V : B \u2964 D) (U : A \u2964 C) (R : C \u2964 D)\n  (comm : U \u22d9 R \u2245 Q \u22d9 V)\n  [is_right_adjoint U] [is_right_adjoint V] [is_right_adjoint R]\n  [\u2200 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 \u2192 B\n  U \u2193   \u2193 V\n    C \u2192 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 \u2964 B) (V : B \u2964 D) (U : A \u2964 C) (R : C \u2964 D)\n  (comm : U \u22d9 R \u2245 Q \u22d9 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 {\u03b1 : Type u}\n\ntheorem get_congr {x y : List \u03b1} {i : Fin x.length} {j : Fin y.length} : x = y \u2192 i.val = j.val \u2192 get x i = get y j\n| rfl, h => by rw [Fin.eq_of_val_eq h]\n\ntheorem get_congrList {x y : List \u03b1} {i : Fin x.length} : (h : x = y) \u2192 get x i = get y \u27e8i.val, h\u25b8i.isLt\u27e9\n| rfl => rfl\n\ntheorem get_proof_irrev (x : List \u03b1) (i : Fin x.length) (h : i.val < x.length) : x.get i = x.get \u27e8i.val, h\u27e9 :=\n  get_congr rfl rfl\n\ntheorem get_head (a : \u03b1) (as : List \u03b1) : \u2200 {i : Fin (a::as).length}, i.val = 0 \u2192 (a::as).get i = a\n| Fin.mk i hi, h => by cases h; rfl\n\ntheorem get_tail (a : \u03b1) (as : List \u03b1) : \u2200 {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 : \u2200 (x : List \u03b1) (i : Nat) (v : \u03b1) (j : Fin (x.set i v).length), i = j.val \u2192 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 : \u2200 (x : List \u03b1) (i : Nat) (v : \u03b1) (j : Fin (x.set i v).length), i \u2260 j.val \u2192 get (x.set i v) j = get x \u27e8j.val, x.length_set i v \u25b8 j.isLt\u27e9\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 \u27e8k,_\u27e9 (h \u2218 congrArg Nat.succ)]\n\ntheorem foldl_comm {\u03b1 \u03b2 : Type _} {f : \u03b1 \u2192 \u03b2 \u2192 \u03b1} {g : \u03b1 \u2192 \u03b1} : (\u2200 a b, f (g a) b = g (f a b)) \u2192 \u2200 {init : \u03b1} {bs : List \u03b2}, 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 \u03bb {_} => 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 {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) : \u2200 (as : List \u03b1), as.map (g \u2218 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 {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 Option \u03b3) : \u2200 (as : List \u03b1), as.filterMap (g \u2218 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 {\u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u2200 (x : List \u03b2), List.zipWith f [] x = []\n| [] => rfl\n| (_::_) => rfl\n\ntheorem zipWith_nil_second {\u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) : \u2200 (x : List \u03b1), List.zipWith f x [] = []\n| [] => rfl\n| (_::_) => rfl\n\ntheorem reverseAux_append_left {\u03b1 : Type _} {as\u2081 as\u2082 bs : List \u03b1} : reverseAux (as\u2081 ++ as\u2082) bs = as\u2082.reverse ++ reverseAux as\u2081 bs := by\n  revert bs; induction as\u2081 <;> intro bs\n  case nil => rw [reverseAux_eq_append]; rfl\n  case cons a\u2081 as\u2081 h_ind =>\n    rw [cons_append]\n    unfold reverseAux\n    rw [h_ind]\n\ntheorem bind_congr {\u03b1 \u03b2 : Type _} : \u2200 {as\u2081 as\u2082 : List \u03b1} {f\u2081 f\u2082 : \u03b1 \u2192 List \u03b2}, as\u2081 = as\u2082 \u2192 (\u2200 a, f\u2081 a = f\u2082 a) \u2192 as\u2081.bind f\u2081 = as\u2082.bind f\u2082\n| as, _, _, _, rfl, h =>\n  congrArg (as.bind) (funext h)\n\ntheorem bind_map_binary_eq_map_bind_map {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (as : List \u03b1) (bs : List \u03b2) : 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 {\u03b1 : Type _} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : List \u03b1 \u2192 List \u03b1 \u2192 Prop\n| nil : (a : \u03b1) \u2192 (as : List \u03b1) \u2192 List.lex r [] (a::as)\n| head {a b : \u03b1} {as bs : List \u03b1} : r a b \u2192 List.lex r (a::as) (b::bs)\n| tail {a : \u03b1} {as bs : List \u03b1} : List.lex r as bs \u2192 List.lex r (a::as) (a::bs)\n\nnamespace lex\n\nvariable {\u03b1 : Type _} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n\nprotected\ntheorem trans [Trans r r r] : {as bs cs : List \u03b1} \u2192 List.lex r as bs \u2192 List.lex r bs cs \u2192 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] : \u2200 (as : List \u03b1), \u00ac 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] : \u2200 (as bs : List \u03b1), List.lex r as bs \u2192 \u00ac 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] : \u2200 (as bs : List \u03b1), as = bs \u2228 List.lex r as bs \u2228 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    (\u03bb a h_ind =>\n      Or.map (congrArg (List.cons a)) (Or.map List.lex.tail List.lex.tail) h_ind\n    )\n    (\u03bb _ _ h _ => Or.inr $ Or.inl $ List.lex.head h)\n    (\u03bb _ _ 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 \u03b1] [DecidableRel r] : DecidableRel (List.lex r)\n| [], [] => isFalse $ \u03bb hcontra => by cases hcontra\n| (a::as), [] => isFalse $ \u03bb 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 \u25b8 List.lex.tail htail\n    | isFalse htail => isFalse $ by\n      cases heq; intro hcontra; cases hcontra <;> contradiction\n  else\n    isFalse $ \u03bb 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 {\u03b1 : Type u} (t : tactic \u03b1) : tactic bool :=\n  \u03bb 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 \u2192 expr \u2192 tactic (option \u2115) := \u03bb fixed_type add_args_type, do\n  can_unify \u2190 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 \u2190 tactic.mk_meta_var arg_type,\n        let substituted_expr := body.instantiate_var arg_mvar,\n        recur_result \u2190 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 := \u03bb _, do\n    tar \u2190 tactic.target,\n    env \u2190 tactic.get_env,\n    ans \u2190 env.fold (return []) $ \u03bb decl accum, (do\n      accum_result \u2190 accum,\n      unify_with_args_result \u2190 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 \u2115\nexample := 1 + {! !}\n\ninductive MyType : \u2115 \u2192 \u2115 \u2192 Type\n| constr : \u2200 x y : \u2115, 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 : \u2115) : ((x + y) + z = x + (y + z)) := {! !}\n\n-- Doesn't work yet\nexample (\u03b1 : Type u) (x : \u03b1) : \u03b1 := {! !}", "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) 2020 Xi Wang. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthor: Xi Wang.\n-/\n\nimport arithcc\n\nnamespace arithcc\n\nsection test\n\nopen instruction\n\n/-- The example in the paper for compiling (x + 3) + (x + (y + 2)). -/\nexample (x y t : register) :\n  let map := \u03bb v, if v = \"x\" then x else if v = \"y\" then y else 0,\n      p   := expr.sum (expr.sum (expr.var \"x\") (expr.const 3))\n                      (expr.sum (expr.var \"x\") (expr.sum (expr.var \"y\") (expr.const 2))) in\n  compile map p t =\n  [ load x,\n    sto  t,\n    li   3,\n    add  t,\n    sto  t,\n    load x,\n    sto  (t + 1),\n    load y,\n    sto  (t + 2),\n    li   2,\n    add  (t + 2),\n    add  (t + 1),\n    add  t ] :=\nrfl\n\nend test\n\nend arithcc\n", "meta": {"author": "xiw", "repo": "arithcc", "sha": "f3e0e689d3d5b53b54005303e495e49019e77532", "save_path": "github-repos/lean/xiw-arithcc", "path": "github-repos/lean/xiw-arithcc/arithcc-f3e0e689d3d5b53b54005303e495e49019e77532/test/example.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) 2021 Ya\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 {\u03b1 \u03b2 : Type u} [\u2200 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 \u03b1 \u03b2 f s := s.image f\n\ninstance : LawfulFunctor Finset where\n  id_map \u03b1 s := image_id\n  comp_map \u03b1 \u03b2 \u03b3 f g s := image_image.symm\n\n#print Finset.fmap_def /-\n@[simp]\ntheorem fmap_def {s : Finset \u03b1} (f : \u03b1 \u2192 \u03b2) : 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  \u27e8fun \u03b1 x => {x}\u27e9\n\n#print Finset.pure_def /-\n@[simp]\ntheorem pure_def {\u03b1} : (pure : \u03b1 \u2192 Finset \u03b1) = singleton :=\n  rfl\n#align finset.pure_def Finset.pure_def\n-/\n\n/-! ### Applicative functor -/\n\n\nsection Applicative\n\nvariable {\u03b1 \u03b2 : Type u} [\u2200 P, Decidable P]\n\ninstance : Applicative Finset :=\n  { Finset.functor,\n    Finset.hasPure with\n    seq := fun \u03b1 \u03b2 t s => t.sup fun f => s.image f\n    seqLeft := fun \u03b1 \u03b2 s t => if t = \u2205 then \u2205 else s\n    seqRight := fun \u03b1 \u03b2 s t => if s = \u2205 then \u2205 else t }\n\n#print Finset.seq_def /-\n@[simp]\ntheorem seq_def (s : Finset \u03b1) (t : Finset (\u03b1 \u2192 \u03b2)) : 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 \u03b1) (t : Finset \u03b2) : s <* t = if t = \u2205 then \u2205 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 \u03b1) (t : Finset \u03b2) : s *> t = if s = \u2205 then \u2205 else t :=\n  rfl\n#align finset.seq_right_def Finset.seqRight_def\n-/\n\n#print Finset.image\u2082_def /-\n/-- `finset.image\u2082` in terms of monadic operations. Note that this can't be taken as the definition\nbecause of the lack of universe polymorphism. -/\ntheorem image\u2082_def {\u03b1 \u03b2 \u03b3 : Type _} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : Finset \u03b1) (t : Finset \u03b2) :\n    image\u2082 f s t = f <$> s <*> t := by\n  ext\n  simp [mem_sup]\n#align finset.image\u2082_def Finset.image\u2082_def\n-/\n\ninstance : LawfulApplicative Finset :=\n  {\n    Finset.lawfulFunctor with\n    seqLeft_eq := fun \u03b1 \u03b2 s t => by\n      rw [seq_def, fmap_def, seq_left_def]\n      obtain rfl | ht := t.eq_empty_or_nonempty\n      \u00b7 simp_rw [if_pos rfl, image_empty]\n        exact (sup_bot _).symm\n      \u00b7 ext a\n        rw [if_neg ht.ne_empty, mem_sup]\n        refine' \u27e8fun ha => \u27e8const \u03b2 a, mem_image_of_mem _ ha, mem_image_const_self.2 ht\u27e9, _\u27e9\n        rintro \u27e8f, hf, ha\u27e9\n        rw [mem_image] at hf ha\n        obtain \u27e8b, hb, rfl\u27e9 := hf\n        obtain \u27e8_, _, rfl\u27e9 := ha\n        exact hb\n    seqRight_eq := fun \u03b1 \u03b2 s t =>\n      by\n      rw [seq_def, fmap_def, seq_right_def]\n      obtain rfl | hs := s.eq_empty_or_nonempty\n      \u00b7 rw [if_pos rfl, image_empty, sup_empty, bot_eq_empty]\n      \u00b7 ext a\n        rw [if_neg hs.ne_empty, mem_sup]\n        refine' \u27e8fun ha => \u27e8id, mem_image_const_self.2 hs, by rwa [image_id]\u27e9, _\u27e9\n        rintro \u27e8f, hf, ha\u27e9\n        rw [mem_image] at hf ha\n        obtain \u27e8b, hb, rfl\u27e9 := ha\n        obtain \u27e8_, _, rfl\u27e9 := hf\n        exact hb\n    pure_seq := fun \u03b1 \u03b2 f s => sup_singleton\n    map_pure := fun \u03b1 \u03b2 f a => image_singleton _ _\n    seq_pure := fun \u03b1 \u03b2 s a => sup_singleton'' _ _\n    seq_assoc := fun \u03b1 \u03b2 \u03b3 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      \u00b7 rintro \u27e8g, hg, b, \u27e8f, hf, a, ha, rfl\u27e9, rfl\u27e9\n        exact \u27e8g \u2218 f, \u27e8comp g, \u27e8g, hg, rfl\u27e9, f, hf, rfl\u27e9, a, ha, rfl\u27e9\n      \u00b7 rintro \u27e8c, \u27e8_, \u27e8g, hg, rfl\u27e9, f, hf, rfl\u27e9, a, ha, rfl\u27e9\n        exact \u27e8g, hg, f a, \u27e8f, hf, a, ha, rfl\u27e9, rfl\u27e9 }\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ninstance : CommApplicative Finset :=\n  { Finset.lawfulApplicative with\n    commutative_prod := fun \u03b1 \u03b2 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 \u00d7\u02e2 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 [\u2200 P, Decidable P]\n\ninstance : Monad Finset :=\n  { Finset.applicative with bind := fun \u03b1 \u03b2 => @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] {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}}, Eq.{succ u1} ((Finset.{u1} \u03b2) -> (\u03b2 -> (Finset.{u1} \u03b1)) -> (Finset.{u1} \u03b1)) (Bind.bind.{u1, u1} Finset.{u1} (Monad.toHasBind.{u1, u1} Finset.{u1} (Finset.monad.{u1} (fun (P : Prop) => _inst_1 P))) \u03b2 \u03b1) (Finset.sup.{u1, u1} (Finset.{u1} \u03b1) \u03b2 (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b1) (Finset.lattice.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 (Eq.{succ u1} \u03b1 a b)))) (Finset.orderBot.{u1} \u03b1))\nbut is expected to have type\n  forall [_inst_1 : forall (P : Prop), Decidable P] {\u03b1 : Type.{u1}} {\u03b2 : Type.{u1}}, Eq.{succ u1} ((Finset.{u1} \u03b2) -> (\u03b2 -> (Finset.{u1} \u03b1)) -> (Finset.{u1} \u03b1)) (fun (x._@.Mathlib.Data.Finset.Functor._hyg.1288 : Finset.{u1} \u03b2) (x._@.Mathlib.Data.Finset.Functor._hyg.1290 : \u03b2 -> (Finset.{u1} \u03b1)) => Bind.bind.{u1, u1} Finset.{u1} (Monad.toBind.{u1, u1} Finset.{u1} (Finset.instMonadFinset.{u1} (fun (P : Prop) => _inst_1 P))) \u03b2 \u03b1 x._@.Mathlib.Data.Finset.Functor._hyg.1288 x._@.Mathlib.Data.Finset.Functor._hyg.1290) (Finset.sup.{u1, u1} (Finset.{u1} \u03b1) \u03b2 (Lattice.toSemilatticeSup.{u1} (Finset.{u1} \u03b1) (Finset.instLatticeFinset.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_1 (Eq.{succ u1} \u03b1 a b)))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} \u03b1))\nCase conversion may be inaccurate. Consider using '#align finset.bind_def Finset.bind_def\u2093'. -/\n@[simp]\ntheorem bind_def {\u03b1 \u03b2} : (\u00b7 >>= \u00b7) = @sup (Finset \u03b1) \u03b2 _ _ :=\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 \u03b1 \u03b2 f s => sup_singleton'' _ _\n    bind_map_eq_seq := fun \u03b1 \u03b2 t s => rfl\n    pure_bind := fun \u03b1 \u03b2 t s => sup_singleton\n    bind_assoc := fun \u03b1 \u03b2 \u03b3 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 [\u2200 P, Decidable P]\n\ninstance : Alternative Finset :=\n  { Finset.applicative with\n    orelse := fun \u03b1 => (\u00b7 \u222a \u00b7)\n    failure := fun \u03b1 => \u2205 }\n\nend Alternative\n\n/-! ### Traversable functor -/\n\n\nsection Traversable\n\nvariable {\u03b1 \u03b2 \u03b3 : Type u} {F G : Type u \u2192 Type u} [Applicative F] [Applicative G]\n  [CommApplicative F] [CommApplicative G]\n\n#print Finset.traverse /-\n/-- Traverse function for `finset`. -/\ndef traverse [DecidableEq \u03b2] (f : \u03b1 \u2192 F \u03b2) (s : Finset \u03b1) : F (Finset \u03b2) :=\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 {\u03b1 : Type.{u1}} [_inst_5 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (id.{succ (succ u1)} Type.{u1} (Finset.{u1} \u03b1)) (Finset.traverse.{u1} \u03b1 \u03b1 (id.{succ (succ u1)} Type.{u1}) (Monad.toApplicative.{u1, u1} (id.{succ (succ u1)} Type.{u1}) id.monad.{u1}) id.commApplicative.{u1} (fun (a : \u03b1) (b : \u03b1) => _inst_5 a b) (id.mk.{succ u1} \u03b1) s) s\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_5 : DecidableEq.{succ u1} \u03b1] (s : Finset.{u1} \u03b1), Eq.{succ u1} (Id.{u1} (Finset.{u1} \u03b1)) (Finset.traverse.{u1} \u03b1 \u03b1 Id.{u1} (Monad.toApplicative.{u1, u1} Id.{u1} Id.instMonadId.{u1}) instCommApplicativeIdToApplicativeInstMonadId.{u1} (fun (a : \u03b1) (b : \u03b1) => _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})) \u03b1) s) s\nCase conversion may be inaccurate. Consider using '#align finset.id_traverse Finset.id_traverse\u2093'. -/\n@[simp]\ntheorem id_traverse [DecidableEq \u03b1] (s : Finset \u03b1) : 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 : \u03b1 \u2192 \u03b2) :\n    Functor.map h \u2218 Multiset.toFinset = Multiset.toFinset \u2218 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 : \u03b1 \u2192 G \u03b2) (h : \u03b2 \u2192 \u03b3) (s : Finset \u03b1) :\n    Functor.map h <$> traverse g s = traverse (Functor.map h \u2218 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 `\u03b1`.\nIt is isomorphic to the polynomial ring over \u2124 with variables\nin `\u03b1`\n\n## Main definitions\n\n* `free_comm_ring \u03b1`     : the free commutative ring on a type \u03b1\n* `lift_hom (f : \u03b1 \u2192 R)` : the ring hom `free_comm_ring \u03b1 \u2192+* R` induced by functoriality from `f`.\n* `map (f : \u03b1 \u2192 \u03b2)`      : the ring hom `free_comm_ring \u03b1 \u2192*+ free_comm_ring \u03b2` 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 : \u03b1 \u2192 free_comm_ring \u03b1`\n* `lift_hom (f : \u03b1 \u2192 R) : free_comm_ring \u03b1 \u2192+* R`\n* `map (f : \u03b1 \u2192 \u03b2) : free_comm_ring \u03b1 \u2192+* free_comm_ring \u03b2`\n\n* `free_comm_ring_equiv_mv_polynomial_int : free_comm_ring \u03b1 \u2243+* mv_polynomial \u03b1 \u2124` :\n    `free_comm_ring \u03b1` is isomorphic to a polynomial ring.\n\n\n\n## Implementation notes\n\n`free_comm_ring \u03b1` is implemented not using `mv_polynomial` but\ndirectly as the free abelian group on `multiset \u03b1`, the type\nof monomials in this free commutative ring.\n\n## Tags\n\nfree commutative ring, free ring\n-/\n\n/-- `free_comm_ring \u03b1` is the free commutative ring on the type `\u03b1`. -/\ndef free_comm_ring (\u03b1 : Type u) :=\n  free_abelian_group (multiplicative (multiset \u03b1))\n\nnamespace free_comm_ring\n\n\n/-- The structure of a commutative ring on `free_comm_ring \u03b1`. -/\nprotected instance comm_ring (\u03b1 : Type u) : comm_ring (free_comm_ring \u03b1) :=\n  free_abelian_group.comm_ring (multiplicative (multiset \u03b1))\n\nprotected instance inhabited (\u03b1 : Type u) : Inhabited (free_comm_ring \u03b1) :=\n  { default := 0 }\n\n/-- The canonical map from `\u03b1` to the free commutative ring on `\u03b1`. -/\ndef of {\u03b1 : Type u} (x : \u03b1) : free_comm_ring \u03b1 :=\n  free_abelian_group.of \u2191[x]\n\ntheorem of_injective {\u03b1 : Type u} : function.injective of :=\n  function.injective.comp free_abelian_group.of_injective\n    fun (x y : \u03b1) => iff.mp (iff.trans multiset.coe_eq_coe list.singleton_perm_singleton)\n\nprotected theorem induction_on {\u03b1 : Type u} {C : free_comm_ring \u03b1 \u2192 Prop} (z : free_comm_ring \u03b1) (hn1 : C (-1)) (hb : \u2200 (b : \u03b1), C (of b)) (ha : \u2200 (x y : free_comm_ring \u03b1), C x \u2192 C y \u2192 C (x + y)) (hm : \u2200 (x y : free_comm_ring \u03b1), C x \u2192 C y \u2192 C (x * y)) : C z := sorry\n\n/-- Lift a map `\u03b1 \u2192 R` to a additive group homomorphism `free_comm_ring \u03b1 \u2192 R`.\nFor a version producing a bundled homomorphism, see `lift_hom`. -/\ndef lift {\u03b1 : Type u} {R : Type v} [comm_ring R] (f : \u03b1 \u2192 R) : free_comm_ring \u03b1 \u2192+* R :=\n  ring_hom.mk\n    (add_monoid_hom.to_fun\n      (free_abelian_group.lift\n        fun (s : multiplicative (multiset \u03b1)) => multiset.prod (multiset.map f (coe_fn multiplicative.to_add s))))\n    sorry sorry sorry sorry\n\n@[simp] theorem lift_of {\u03b1 : Type u} {R : Type v} [comm_ring R] (f : \u03b1 \u2192 R) (x : \u03b1) : coe_fn (lift f) (of x) = f x := sorry\n\n@[simp] theorem lift_comp_of {\u03b1 : Type u} {R : Type v} [comm_ring R] (f : free_comm_ring \u03b1 \u2192+* R) : lift (\u21d1f \u2218 of) = f := sorry\n\n/-- A map `f : \u03b1 \u2192 \u03b2` produces a ring homomorphism `free_comm_ring \u03b1 \u2192+* free_comm_ring \u03b2`. -/\ndef map {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) : free_comm_ring \u03b1 \u2192+* free_comm_ring \u03b2 :=\n  lift (of \u2218 f)\n\n@[simp] theorem map_of {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (x : \u03b1) : coe_fn (map f) (of x) = of (f x) :=\n  lift_of (of \u2218 f) x\n\n/-- `is_supported x s` means that all monomials showing up in `x` have variables in `s`. -/\ndef is_supported {\u03b1 : Type u} (x : free_comm_ring \u03b1) (s : set \u03b1) :=\n  x \u2208 ring.closure (of '' s)\n\ntheorem is_supported_upwards {\u03b1 : Type u} {x : free_comm_ring \u03b1} {s : set \u03b1} {t : set \u03b1} (hs : is_supported x s) (hst : s \u2286 t) : is_supported x t :=\n  ring.closure_mono (set.monotone_image hst) hs\n\ntheorem is_supported_add {\u03b1 : Type u} {x : free_comm_ring \u03b1} {y : free_comm_ring \u03b1} {s : set \u03b1} (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 {\u03b1 : Type u} {x : free_comm_ring \u03b1} {s : set \u03b1} (hxs : is_supported x s) : is_supported (-x) s :=\n  is_add_subgroup.neg_mem hxs\n\ntheorem is_supported_sub {\u03b1 : Type u} {x : free_comm_ring \u03b1} {y : free_comm_ring \u03b1} {s : set \u03b1} (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 {\u03b1 : Type u} {x : free_comm_ring \u03b1} {y : free_comm_ring \u03b1} {s : set \u03b1} (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 {\u03b1 : Type u} {s : set \u03b1} : is_supported 0 s :=\n  is_add_submonoid.zero_mem\n\ntheorem is_supported_one {\u03b1 : Type u} {s : set \u03b1} : is_supported 1 s :=\n  is_submonoid.one_mem\n\ntheorem is_supported_int {\u03b1 : Type u} {i : \u2124} {s : set \u03b1} : is_supported (\u2191i) s := sorry\n\n/-- The restriction map from `free_comm_ring \u03b1` to `free_comm_ring s` where `s : set \u03b1`, defined\n  by sending all variables not in `s` to zero. -/\ndef restriction {\u03b1 : Type u} (s : set \u03b1) [decidable_pred s] : free_comm_ring \u03b1 \u2192+* free_comm_ring \u21a5s :=\n  lift fun (p : \u03b1) => dite (p \u2208 s) (fun (H : p \u2208 s) => of { val := p, property := H }) fun (H : \u00acp \u2208 s) => 0\n\n@[simp] theorem restriction_of {\u03b1 : Type u} (s : set \u03b1) [decidable_pred s] (p : \u03b1) : coe_fn (restriction s) (of p) = dite (p \u2208 s) (fun (H : p \u2208 s) => of { val := p, property := H }) fun (H : \u00acp \u2208 s) => 0 :=\n  lift_of (fun (p : \u03b1) => dite (p \u2208 s) (fun (H : p \u2208 s) => of { val := p, property := H }) fun (H : \u00acp \u2208 s) => 0) p\n\ntheorem is_supported_of {\u03b1 : Type u} {p : \u03b1} {s : set \u03b1} : is_supported (of p) s \u2194 p \u2208 s := sorry\n\ntheorem map_subtype_val_restriction {\u03b1 : Type u} {x : free_comm_ring \u03b1} (s : set \u03b1) [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 {\u03b1 : Type u} (x : free_comm_ring \u03b1) : \u2203 (s : set \u03b1), set.finite s \u2227 is_supported x s := sorry\n\ntheorem exists_finset_support {\u03b1 : Type u} (x : free_comm_ring \u03b1) : \u2203 (s : finset \u03b1), is_supported x \u2191s := sorry\n\nend free_comm_ring\n\n\nnamespace free_ring\n\n\n/-- The canonical ring homomorphism from the free ring generated by `\u03b1` to the free commutative ring\n    generated by `\u03b1`. -/\ndef to_free_comm_ring {\u03b1 : Type u_1} : free_ring \u03b1 \u2192+* free_comm_ring \u03b1 :=\n  lift free_comm_ring.of\n\nprotected instance free_comm_ring.has_coe (\u03b1 : Type u) : has_coe (free_ring \u03b1) (free_comm_ring \u03b1) :=\n  has_coe.mk \u21d1to_free_comm_ring\n\nprotected instance coe.is_ring_hom (\u03b1 : Type u) : is_ring_hom coe :=\n  ring_hom.is_ring_hom to_free_comm_ring\n\n@[simp] protected theorem coe_zero (\u03b1 : Type u) : \u21910 = 0 :=\n  rfl\n\n@[simp] protected theorem coe_one (\u03b1 : Type u) : \u21911 = 1 :=\n  rfl\n\n@[simp] protected theorem coe_of {\u03b1 : Type u} (a : \u03b1) : \u2191(of a) = free_comm_ring.of a :=\n  lift_of free_comm_ring.of a\n\n@[simp] protected theorem coe_neg {\u03b1 : Type u} (x : free_ring \u03b1) : \u2191(-x) = -\u2191x :=\n  ring_hom.map_neg (lift free_comm_ring.of) x\n\n@[simp] protected theorem coe_add {\u03b1 : Type u} (x : free_ring \u03b1) (y : free_ring \u03b1) : \u2191(x + y) = \u2191x + \u2191y :=\n  ring_hom.map_add (lift free_comm_ring.of) x y\n\n@[simp] protected theorem coe_sub {\u03b1 : Type u} (x : free_ring \u03b1) (y : free_ring \u03b1) : \u2191(x - y) = \u2191x - \u2191y :=\n  ring_hom.map_sub (lift free_comm_ring.of) x y\n\n@[simp] protected theorem coe_mul {\u03b1 : Type u} (x : free_ring \u03b1) (y : free_ring \u03b1) : \u2191(x * y) = \u2191x * \u2191y :=\n  ring_hom.map_mul (lift free_comm_ring.of) x y\n\nprotected theorem coe_surjective (\u03b1 : Type u) : function.surjective coe := sorry\n\ntheorem coe_eq (\u03b1 : Type u) : coe = Functor.map fun (l : List \u03b1) => \u2191l := 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 \u2243 S` as a ring equivalence `R \u2243+* S`. -/\ndef of' {R : Type u_1} {S : Type u_2} [ring R] [ring S] (e : R \u2243 S) [is_ring_hom \u21d1e] : R \u2243+* 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 \u03b1 has size at most 1 then the natural map from the free ring on `\u03b1` to the\n    free commutative ring on `\u03b1` is an isomorphism of rings. -/\ndef subsingleton_equiv_free_comm_ring (\u03b1 : Type u) [subsingleton \u03b1] : free_ring \u03b1 \u2243+* free_comm_ring \u03b1 :=\n  of' (functor.map_equiv free_abelian_group (multiset.subsingleton_equiv \u03b1))\n\nprotected instance comm_ring (\u03b1 : Type u) [subsingleton \u03b1] : comm_ring (free_ring \u03b1) :=\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 `\u03b1` is isomorphic to the polynomial ring over \u2124 with\n    variables in `\u03b1` -/\ndef free_comm_ring_equiv_mv_polynomial_int (\u03b1 : Type u) : free_comm_ring \u03b1 \u2243+* mv_polynomial \u03b1 \u2124 :=\n  ring_equiv.mk (\u21d1(free_comm_ring.lift fun (a : \u03b1) => mv_polynomial.X a))\n    (mv_polynomial.eval\u2082 (int.cast_ring_hom (free_comm_ring \u03b1)) free_comm_ring.of) sorry sorry sorry sorry\n\n/-- The free commutative ring on the empty type is isomorphic to `\u2124`. -/\ndef free_comm_ring_pempty_equiv_int : free_comm_ring pempty \u2243+* \u2124 :=\n  ring_equiv.trans (free_comm_ring_equiv_mv_polynomial_int pempty) (mv_polynomial.pempty_ring_equiv \u2124)\n\n/-- The free commutative ring on a type with one term is isomorphic to `\u2124[X]`. -/\ndef free_comm_ring_punit_equiv_polynomial_int : free_comm_ring PUnit \u2243+* polynomial \u2124 :=\n  ring_equiv.trans (free_comm_ring_equiv_mv_polynomial_int PUnit) (mv_polynomial.punit_ring_equiv \u2124)\n\n/-- The free ring on the empty type is isomorphic to `\u2124`. -/\ndef free_ring_pempty_equiv_int : free_ring pempty \u2243+* \u2124 :=\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 `\u2124[X]`. -/\ndef free_ring_punit_equiv_polynomial_int : free_ring PUnit \u2243+* polynomial \u2124 :=\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} [\ud835\udc9e : category.{u v} C]\n-- include \ud835\udc9e\n\n-- structure is_zero (t : C) :=\n-- (lift : \u2200 (s : C), s \u27f6 t)\n-- (uniq_lift' : \u2200 (s : C) (m : s \u27f6 t), m = lift s . obviously)\n-- (desc : \u2200 (s : C), t \u27f6 s)\n-- (uniq_desc' : \u2200 (s : C) (m : t \u27f6 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 \u27f6 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 \u27f6 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} [\ud835\udc9e : category.{u v} C]\n-- include \ud835\udc9e\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 \u27f6 Y := (zero_is_zero.lift.{u v} X) \u226b (zero_is_zero.desc.{u v} Y)\n\n-- instance hom_has_zero (X Y : C) : _root_.has_zero (X \u27f6 Y) := { zero := zero_morphism X Y }\n\n-- @[extensionality] lemma ext.out (Y : C) (f g : zero_object.{u v} C \u27f6 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 \u27f6 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 \u27f6 Z) : (zero_morphism X Y) \u226b 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 \u27f6 Y) : f \u226b (zero_morphism Y Z) = zero_morphism X Z :=\n-- begin\n--   unfold zero_morphism,\n--   rw \u2190 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 {\u03b1 : Type*}\nvariables (s t u : set \u03b1)\n\n-- BEGIN\nexample : s \\ t \\ u \u2286 s \\ (t \u222a u) :=\nbegin\n  intros x xstu,\n  have xs : x \u2208 s := xstu.1.1,\n  have xnt : x \u2209 t := xstu.1.2,\n  have xnu : x \u2209 u := xstu.2,\n  split,\n  { exact xs }, dsimp,\n  intro xtu, -- x \u2208 t \u2228 x \u2208 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 \u2286 s \\ (t \u222a u) :=\nbegin\n  rintros x \u27e8\u27e8xs, xnt\u27e9, xnu\u27e9,\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\u00f6ckle\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 \u2192 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 `\u03b5`, `dual_pair e \u03b5` 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 `\u03b5` form a dual pair, `e` is a basis and\n  `\u03b5` 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 \u2192 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 \u2192 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 \u2192\u2097[R] M'` to\n`dual R M' \u2192\u2097[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} {\u03b9 : Type w} [field K] [add_comm_group V] [vector_space K V]\n    [de : DecidableEq \u03b9] (B : \u03b9 \u2192 V) (h : is_basis K B) : linear_map K V (module.dual K V) :=\n  constr h fun (v : \u03b9) => constr h fun (w : \u03b9) => ite (w = v) 1 0\n\ntheorem to_dual_apply {K : Type u} {V : Type v} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) (i : \u03b9) (j : \u03b9) :\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} {\u03b9 : Type w} [field K]\n    [add_comm_group V] [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B)\n    (f : \u03b9 \u2192\u2080 K) (i : \u03b9) :\n    coe_fn (coe_fn (to_dual B h) (coe_fn (finsupp.total \u03b9 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} {\u03b9 : Type w} [field K]\n    [add_comm_group V] [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B)\n    (f : \u03b9 \u2192\u2080 K) (i : \u03b9) :\n    coe_fn (coe_fn (to_dual B h) (B i)) (coe_fn (finsupp.total \u03b9 V K B) f) = coe_fn f i :=\n  sorry\n\ntheorem to_dual_apply_left {K : Type u} {V : Type v} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) (v : V) (i : \u03b9) :\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) (i : \u03b9) (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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] (B : \u03b9 \u2192 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} {\u03b9 : Type w} [field K] (i : \u03b9) : linear_map K (\u03b9 \u2192\u2080 K) K :=\n  linear_map.mk (fun (f : \u03b9 \u2192\u2080 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} {\u03b9 : Type w} [field K] [add_comm_group V] [vector_space K V]\n    {B : \u03b9 \u2192 V} (h : is_basis K B) (i : \u03b9) : 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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {B : \u03b9 \u2192 V} (h : is_basis K B) (v : V) (i : \u03b9) :\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) (v : V) (i : \u03b9) :\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) [fintype \u03b9] (v : V)\n    (i : \u03b9) : 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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) :\n    linear_map.ker (to_dual B h) = \u22a5 :=\n  iff.mpr linear_map.ker_eq_bot' (to_dual_inj h)\n\ntheorem to_dual_range {K : Type u} {V : Type v} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) [fin : fintype \u03b9] :\n    linear_map.range (to_dual B h) = \u22a4 :=\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) : \u03b9 \u2192 module.dual K V :=\n  fun (i : \u03b9) => coe_fn (to_dual B h) (B i)\n\ntheorem dual_lin_independent {K : Type u} {V : Type v} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 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} {\u03b9 : Type w} [field K]\n    [add_comm_group V] [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B)\n    (i : \u03b9) (j : \u03b9) : 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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] (B : \u03b9 \u2192 V) (h : is_basis K B) [fintype \u03b9] :\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) [fintype \u03b9] :\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) [fintype \u03b9] (f : \u03b9 \u2192\u2080 K)\n    (i : \u03b9) :\n    coe_fn (coe_fn (finsupp.total \u03b9 (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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) [fintype \u03b9]\n    (l : module.dual K V) (i : \u03b9) :\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) [fintype \u03b9]\n    (l : module.dual K V) (i : \u03b9) :\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) [fintype \u03b9] (i : \u03b9)\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] [de : DecidableEq \u03b9] {B : \u03b9 \u2192 V} (h : is_basis K B) [fintype \u03b9] :\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} {\u03b9 : Type w} [field K] [add_comm_group V]\n    [vector_space K V] {B : \u03b9 \u2192 V} (h : is_basis K B) [fintype \u03b9] :\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) = \u22a5 :=\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) = \u22a4 :=\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 `\u03b5` have characteristic properties of a basis and its dual -/\nstructure dual_pair {K : Type u} {V : Type v} {\u03b9 : Type w} [DecidableEq \u03b9] [field K]\n    [add_comm_group V] [vector_space K V] (e : \u03b9 \u2192 V) (\u03b5 : \u03b9 \u2192 module.dual K V)\n    where\n  eval : \u2200 (i j : \u03b9), coe_fn (\u03b5 i) (e j) = ite (i = j) 1 0\n  total : \u2200 {v : V}, (\u2200 (i : \u03b9), coe_fn (\u03b5 i) v = 0) \u2192 v = 0\n  finite : (v : V) \u2192 fintype \u21a5(set_of fun (i : \u03b9) => coe_fn (\u03b5 i) v \u2260 0)\n\nnamespace dual_pair\n\n\n/-- The coefficients of `v` on the basis `e` -/\ndef coeffs {K : Type u} {V : Type v} {\u03b9 : Type w} [d\u03b9 : DecidableEq \u03b9] [field K] [add_comm_group V]\n    [vector_space K V] {e : \u03b9 \u2192 V} {\u03b5 : \u03b9 \u2192 module.dual K V} (h : dual_pair e \u03b5) (v : V) : \u03b9 \u2192\u2080 K :=\n  finsupp.mk (set.to_finset (set_of fun (i : \u03b9) => coe_fn (\u03b5 i) v \u2260 0))\n    (fun (i : \u03b9) => coe_fn (\u03b5 i) v) sorry\n\n@[simp] theorem coeffs_apply {K : Type u} {V : Type v} {\u03b9 : Type w} [d\u03b9 : DecidableEq \u03b9] [field K]\n    [add_comm_group V] [vector_space K V] {e : \u03b9 \u2192 V} {\u03b5 : \u03b9 \u2192 module.dual K V} (h : dual_pair e \u03b5)\n    (v : V) (i : \u03b9) : coe_fn (coeffs h v) i = coe_fn (\u03b5 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} {\u03b9 : Type w} [field K] [add_comm_group V] [vector_space K V]\n    (e : \u03b9 \u2192 V) (l : \u03b9 \u2192\u2080 K) : V :=\n  finsupp.sum l fun (i : \u03b9) (a : K) => a \u2022 e i\n\ntheorem dual_lc {K : Type u} {V : Type v} {\u03b9 : Type w} [d\u03b9 : DecidableEq \u03b9] [field K]\n    [add_comm_group V] [vector_space K V] {e : \u03b9 \u2192 V} {\u03b5 : \u03b9 \u2192 module.dual K V} (h : dual_pair e \u03b5)\n    (l : \u03b9 \u2192\u2080 K) (i : \u03b9) : coe_fn (\u03b5 i) (lc e l) = coe_fn l i :=\n  sorry\n\n@[simp] theorem coeffs_lc {K : Type u} {V : Type v} {\u03b9 : Type w} [d\u03b9 : DecidableEq \u03b9] [field K]\n    [add_comm_group V] [vector_space K V] {e : \u03b9 \u2192 V} {\u03b5 : \u03b9 \u2192 module.dual K V} (h : dual_pair e \u03b5)\n    (l : \u03b9 \u2192\u2080 K) : coeffs h (lc e l) = l :=\n  sorry\n\n/-- For any v : V n, \\sum_{p \u2208 Q n} (\u03b5 p v) \u2022 e p = v -/\ntheorem decomposition {K : Type u} {V : Type v} {\u03b9 : Type w} [d\u03b9 : DecidableEq \u03b9] [field K]\n    [add_comm_group V] [vector_space K V] {e : \u03b9 \u2192 V} {\u03b5 : \u03b9 \u2192 module.dual K V} (h : dual_pair e \u03b5)\n    (v : V) : lc e (coeffs h v) = v :=\n  sorry\n\ntheorem mem_of_mem_span {K : Type u} {V : Type v} {\u03b9 : Type w} [d\u03b9 : DecidableEq \u03b9] [field K]\n    [add_comm_group V] [vector_space K V] {e : \u03b9 \u2192 V} {\u03b5 : \u03b9 \u2192 module.dual K V} (h : dual_pair e \u03b5)\n    {H : set \u03b9} {x : V} (hmem : x \u2208 submodule.span K (e '' H)) (i : \u03b9) :\n    coe_fn (\u03b5 i) x \u2260 0 \u2192 i \u2208 H :=\n  sorry\n\ntheorem is_basis {K : Type u} {V : Type v} {\u03b9 : Type w} [d\u03b9 : DecidableEq \u03b9] [field K]\n    [add_comm_group V] [vector_space K V] {e : \u03b9 \u2192 V} {\u03b5 : \u03b9 \u2192 module.dual K V}\n    (h : dual_pair e \u03b5) : is_basis K e :=\n  sorry\n\ntheorem eq_dual {K : Type u} {V : Type v} {\u03b9 : Type w} [d\u03b9 : DecidableEq \u03b9] [field K]\n    [add_comm_group V] [vector_space K V] {e : \u03b9 \u2192 V} {\u03b5 : \u03b9 \u2192 module.dual K V}\n    (h : dual_pair e \u03b5) : \u03b5 = 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": "-- tests for byContra' tactic\nimport Mathlib.Tactic.ByContra\nimport Mathlib.Tactic.Rename\nimport Mathlib.Data.Nat.Basic\n\nexample (a b : \u2115) (foo : False)  : a < b := by\n  by_contra'\n  guard_hyp this : b \u2264 a\n  exact foo\n\nexample (a b : \u2115) (h : False) : a < b := by\n  by_contra' foo\n  revert foo; change b \u2264 a \u2192 False; intro;\n  exact h\n\nexample (a b : \u2115) (h : False) : a < b := by\n  by_contra' foo : \u00ac a < b -- can avoid push_neg\n  guard_hyp foo : \u00ac a < b\n  exact h\n\nexample : 1 < 2 := by\n  by_contra'\n  guard_hyp this : 2 \u2264 1\n  contradiction\n\nexample (p : Prop) (bar : False) : \u00ac \u00ac \u00ac \u00ac \u00ac \u00ac P := by\n  by_contra' foo : \u00ac \u00ac \u00ac P -- normalises to \u00ac P, as does \u00ac (goal).\n  guard_hyp foo : \u00ac \u00ac \u00ac P\n  exact bar\n\nexample (p : Prop) (bar : False) : \u00ac \u00ac \u00ac \u00ac \u00ac \u00ac P := by\n  by_contra' : \u00ac \u00ac \u00ac P\n  guard_hyp this : \u00ac \u00ac \u00ac P\n  exact bar\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/byContra.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.6926419831347361, "lm_q2_score": 0.6548947290421275, "lm_q1q2_score": 0.45360758386822486}}
{"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 \u2192+* B` between commutative rings `A` and `B` is *formally unramified*\nif for every surjective square-zero extension of A-algebras `R' \u2192+* R`\n(meaning that the kernel I satisties I\u00b2 = 0)\nthe natural map Hom_A(B,R') \u2192 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 \u2192 B` is *formally unramified* if for every surjective square zero\nmorphism `\u03c6 : R \u2192 R'` of A-algebras, the natural map Hom_A(B,R') \u2192 Hom_A(B, R) is\nan injection. -/\ndef is_formally_unramified {A B : Type} [comm_ring A] [comm_ring B] (f : A \u2192+* 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\u2200 {{R R' : Type}} [comm_ring R] [comm_ring R'], by exactI\n\u2200 [algebra A R] [algebra A R'], by exactI\n-- and for all A-algebra morphisms \u03c6 : R' \u2192 R with square zero\n\u2200 {\u03c6 : R' \u2192\u2090[A] R} (h\u03c61 : \u2200 r : R, \u2203 r' : R', \u03c6 r' = r) \n  (h\u03c62 : \u2200 x y : R', \u03c6 x = 0 \u2192 \u03c6 y = 0 \u2192 x * y = 0),\n-- composing with \u03c6 is an injection Hom_A(B,R') \u2192 Hom_A(B, R)\nfunction.injective (\u03c6.comp : (B \u2192\u2090[A] R') \u2192 (B \u2192\u2090[A] R))\n\nlemma is_formally_unramified_id : is_formally_unramified (ring_hom.id A: A \u2192+* A) :=\nbegin\n  intros R R',\n  intro _,\n  intro _,\n  intros _ _,\n  intro \u03c6,\n  intro h\u03c6,\n  intro h\u03c6',\n  unfold function.injective,\n  intros a\u2081 a\u2082,\n  resetI,\n  intro h,\n  rw a\u2081.eq_of_id,\n  rw a\u2082.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 {\u03c6 : A \u2192+* B} (h\u03c6 : is_formally_unramified \u03c6)\n  {\u03c8 : B \u2192+* C} (h\u03c8 : is_formally_unramified \u03c8) : is_formally_unramified (\u03c8.comp \u03c6) :=\nbegin\n intros R R' _ _ _ _ f,\n intros hf1 hf2,\n  unfold function.injective,\n  intros a\u2081 a\u2082 hyp, \n  letI : algebra A B := \u03c6.to_algebra,\n  letI : algebra A C := (\u03c8.comp \u03c6).to_algebra,\n  let \u03c8' : B \u2192\u2090[A] C :=\n  { commutes' := \u03bb r, rfl, -- definitional abuse!\n    ..\u03c8 },\nhave h_5: f.comp (a\u2081.comp \u03c8') =  f.comp (a\u2082.comp \u03c8'),\n  begin \n  rw \u2190 alg_hom.comp_assoc,\n  rw \u2190 alg_hom.comp_assoc,\n  rw hyp, \n  end,\n have h_6: a\u2081.comp \u03c8' =  a\u2082.comp \u03c8', -- as phi is formally unramified\n  begin\n  apply h\u03c6 hf1 hf2,\n  apply h_5\n  end,\n let \u03c3 := a\u2081.comp \u03c8',\n let \u03c1 := f.comp (a\u2081.comp \u03c8'),\n letI : algebra B R' := \u03c3.to_ring_hom.to_algebra,\n letI : algebra B R := \u03c1.to_ring_hom.to_algebra,\n let f' : R' \u2192\u2090[B] R :=\n  { commutes' := \u03bb r, rfl,\n    ..f },\n-- now I want to tell lean that a\u2081 and a\u2082 are in fact B algbera maps using h_6.\nletI : algebra B C := \u03c8.to_algebra,\nlet a\u2081' : C \u2192\u2090[B] R' :=\n{ commutes' :=  \u03bb r, rfl,\n   ..a\u2081 },\nlet a\u2082' : C \u2192\u2090[B] R' :=\n{ commutes' := begin intro r, change (a\u2082.comp \u03c8') r = _, rw \u2190 h_6, refl,\nend, ..a\u2082 },\nhave h_7 : f'.comp a\u2081' = f'.comp a\u2082',\n  begin\n  ext r,\n  rw alg_hom.ext_iff at hyp,\n  specialize hyp r,\n  exact hyp,\n  end,\nhave hf1' : \u2200 (r : R), \u2203 (r' : R'), f' r' = r,\n  exact hf1,\nhave hf2' : \u2200 (x y : R'), f' x = 0 \u2192 f' y = 0 \u2192 x * y = 0,\n  exact hf2,\nhave h_8 : a\u2081' = a\u2082', \n  begin \n  specialize h\u03c8 hf1' hf2',\n  apply h\u03c8 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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\u2082`, 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\u2083` as its only purpose would be to prove properties of `finset.image\u2082`\nand `set.image2` already fulfills this task.\n-/\n\n\nopen Function Set\n\nvariable {\u03b1 \u03b1' \u03b2 \u03b2' \u03b3 \u03b3' \u03b4 \u03b4' \u03b5 \u03b5' \u03b6 \u03b6' \u03bd : Type _}\n\nnamespace Finset\n\nvariable [DecidableEq \u03b1'] [DecidableEq \u03b2'] [DecidableEq \u03b3] [DecidableEq \u03b3'] [DecidableEq \u03b4]\n  [DecidableEq \u03b4'] [DecidableEq \u03b5] [DecidableEq \u03b5'] {f f' : \u03b1 \u2192 \u03b2 \u2192 \u03b3} {g g' : \u03b1 \u2192 \u03b2 \u2192 \u03b3 \u2192 \u03b4}\n  {s s' : Finset \u03b1} {t t' : Finset \u03b2} {u u' : Finset \u03b3} {a a' : \u03b1} {b b' : \u03b2} {c : \u03b3}\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n#print Finset.image\u2082 /-\n/-- The image of a binary function `f : \u03b1 \u2192 \u03b2 \u2192 \u03b3` as a function `finset \u03b1 \u2192 finset \u03b2 \u2192 finset \u03b3`.\nMathematically this should be thought of as the image of the corresponding function `\u03b1 \u00d7 \u03b2 \u2192 \u03b3`. -/\ndef image\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : Finset \u03b1) (t : Finset \u03b2) : Finset \u03b3 :=\n  (s \u00d7\u02e2 t).image <| uncurry f\n#align finset.image\u2082 Finset.image\u2082\n-/\n\n/- warning: finset.mem_image\u2082 -> Finset.mem_image\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {c : \u03b3}, Iff (Membership.Mem.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.hasMem.{u3} \u03b3) c (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Exists.{succ u1} \u03b1 (fun (a : \u03b1) => Exists.{succ u2} \u03b2 (fun (b : \u03b2) => And (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) (And (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) b t) (Eq.{succ u3} \u03b3 (f a b) c)))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {c : \u03b3}, Iff (Membership.mem.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.instMembershipFinset.{u3} \u03b3) c (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Exists.{succ u2} \u03b1 (fun (a : \u03b1) => Exists.{succ u1} \u03b2 (fun (b : \u03b2) => And (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) a s) (And (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) b t) (Eq.{succ u3} \u03b3 (f a b) c)))))\nCase conversion may be inaccurate. Consider using '#align finset.mem_image\u2082 Finset.mem_image\u2082\u2093'. -/\n@[simp]\ntheorem mem_image\u2082 : c \u2208 image\u2082 f s t \u2194 \u2203 a b, a \u2208 s \u2227 b \u2208 t \u2227 f a b = c := by\n  simp [image\u2082, and_assoc']\n#align finset.mem_image\u2082 Finset.mem_image\u2082\n\n/- warning: finset.coe_image\u2082 -> Finset.coe_image\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ u3} (Set.{u3} \u03b3) ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (Finset.{u3} \u03b3) (Set.{u3} \u03b3) (HasLiftT.mk.{succ u3, succ u3} (Finset.{u3} \u03b3) (Set.{u3} \u03b3) (CoeTC\u2093.coe.{succ u3, succ u3} (Finset.{u3} \u03b3) (Set.{u3} \u03b3) (Finset.Set.hasCoeT.{u3} \u03b3))) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Set.image2.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (Finset.Set.hasCoeT.{u1} \u03b1))) s) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (Finset.Set.hasCoeT.{u2} \u03b2))) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Finset.{u3} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ u1} (Set.{u1} \u03b3) (Finset.toSet.{u1} \u03b3 (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Set.image2.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f (Finset.toSet.{u3} \u03b1 s) (Finset.toSet.{u2} \u03b2 t))\nCase conversion may be inaccurate. Consider using '#align finset.coe_image\u2082 Finset.coe_image\u2082\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_image\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : Finset \u03b1) (t : Finset \u03b2) :\n    (image\u2082 f s t : Set \u03b3) = Set.image2 f s t :=\n  Set.ext fun _ => mem_image\u2082\n#align finset.coe_image\u2082 Finset.coe_image\u2082\n\n/- warning: finset.card_image\u2082_le -> Finset.card_image\u2082_le is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), LE.le.{0} Nat Nat.hasLe (Finset.card.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} \u03b1 s) (Finset.card.{u2} \u03b2 t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Finset.{u3} \u03b1) (t : Finset.{u2} \u03b2), LE.le.{0} Nat instLENat (Finset.card.{u1} \u03b3 (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u3} \u03b1 s) (Finset.card.{u2} \u03b2 t))\nCase conversion may be inaccurate. Consider using '#align finset.card_image\u2082_le Finset.card_image\u2082_le\u2093'. -/\ntheorem card_image\u2082_le (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : Finset \u03b1) (t : Finset \u03b2) :\n    (image\u2082 f s t).card \u2264 s.card * t.card :=\n  card_image_le.trans_eq <| card_product _ _\n#align finset.card_image\u2082_le Finset.card_image\u2082_le\n\n/- warning: finset.card_image\u2082_iff -> Finset.card_image\u2082_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, Iff (Eq.{1} Nat (Finset.card.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} \u03b1 s) (Finset.card.{u2} \u03b2 t))) (Set.InjOn.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (fun (x : Prod.{u1, u2} \u03b1 \u03b2) => f (Prod.fst.{u1, u2} \u03b1 \u03b2 x) (Prod.snd.{u1, u2} \u03b1 \u03b2 x)) (Set.prod.{u1, u2} \u03b1 \u03b2 ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (Finset.Set.hasCoeT.{u1} \u03b1))) s) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (Finset.Set.hasCoeT.{u2} \u03b2))) t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, Iff (Eq.{1} Nat (Finset.card.{u3} \u03b3 (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u2} \u03b1 s) (Finset.card.{u1} \u03b2 t))) (Set.InjOn.{max u2 u1, u3} (Prod.{u2, u1} \u03b1 \u03b2) \u03b3 (fun (x : Prod.{u2, u1} \u03b1 \u03b2) => f (Prod.fst.{u2, u1} \u03b1 \u03b2 x) (Prod.snd.{u2, u1} \u03b1 \u03b2 x)) (Set.prod.{u2, u1} \u03b1 \u03b2 (Finset.toSet.{u2} \u03b1 s) (Finset.toSet.{u1} \u03b2 t)))\nCase conversion may be inaccurate. Consider using '#align finset.card_image\u2082_iff Finset.card_image\u2082_iff\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\ntheorem card_image\u2082_iff :\n    (image\u2082 f s t).card = s.card * t.card \u2194 (s \u00d7\u02e2 t : Set (\u03b1 \u00d7 \u03b2)).InjOn fun x => f x.1 x.2 :=\n  by\n  rw [\u2190 card_product, \u2190 coe_product]\n  exact card_image_iff\n#align finset.card_image\u2082_iff Finset.card_image\u2082_iff\n\n/- warning: finset.card_image\u2082 -> Finset.card_image\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3}, (Function.Injective2.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 f) -> (forall (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{1} Nat (Finset.card.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (Finset.card.{u1} \u03b1 s) (Finset.card.{u2} \u03b2 t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3}, (Function.Injective2.{succ u3, succ u2, succ u1} \u03b1 \u03b2 \u03b3 f) -> (forall (s : Finset.{u3} \u03b1) (t : Finset.{u2} \u03b2), Eq.{1} Nat (Finset.card.{u1} \u03b3 (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (Finset.card.{u3} \u03b1 s) (Finset.card.{u2} \u03b2 t)))\nCase conversion may be inaccurate. Consider using '#align finset.card_image\u2082 Finset.card_image\u2082\u2093'. -/\ntheorem card_image\u2082 (hf : Injective2 f) (s : Finset \u03b1) (t : Finset \u03b2) :\n    (image\u2082 f s t).card = s.card * t.card :=\n  (card_image_of_injective _ hf.uncurry).trans <| card_product _ _\n#align finset.card_image\u2082 Finset.card_image\u2082\n\n/- warning: finset.mem_image\u2082_of_mem -> Finset.mem_image\u2082_of_mem is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {a : \u03b1} {b : \u03b2}, (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) -> (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) b t) -> (Membership.Mem.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.hasMem.{u3} \u03b3) (f a b) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {a : \u03b1} {b : \u03b2}, (Membership.mem.{u3, u3} \u03b1 (Finset.{u3} \u03b1) (Finset.instMembershipFinset.{u3} \u03b1) a s) -> (Membership.mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.instMembershipFinset.{u2} \u03b2) b t) -> (Membership.mem.{u1, u1} \u03b3 (Finset.{u1} \u03b3) (Finset.instMembershipFinset.{u1} \u03b3) (f a b) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.mem_image\u2082_of_mem Finset.mem_image\u2082_of_mem\u2093'. -/\ntheorem mem_image\u2082_of_mem (ha : a \u2208 s) (hb : b \u2208 t) : f a b \u2208 image\u2082 f s t :=\n  mem_image\u2082.2 \u27e8a, b, ha, hb, rfl\u27e9\n#align finset.mem_image\u2082_of_mem Finset.mem_image\u2082_of_mem\n\n/- warning: finset.mem_image\u2082_iff -> Finset.mem_image\u2082_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {a : \u03b1} {b : \u03b2}, (Function.Injective2.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 f) -> (Iff (Membership.Mem.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.hasMem.{u3} \u03b3) (f a b) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (And (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) b t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {a : \u03b1} {b : \u03b2}, (Function.Injective2.{succ u3, succ u2, succ u1} \u03b1 \u03b2 \u03b3 f) -> (Iff (Membership.mem.{u1, u1} \u03b3 (Finset.{u1} \u03b3) (Finset.instMembershipFinset.{u1} \u03b3) (f a b) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (And (Membership.mem.{u3, u3} \u03b1 (Finset.{u3} \u03b1) (Finset.instMembershipFinset.{u3} \u03b1) a s) (Membership.mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.instMembershipFinset.{u2} \u03b2) b t)))\nCase conversion may be inaccurate. Consider using '#align finset.mem_image\u2082_iff Finset.mem_image\u2082_iff\u2093'. -/\ntheorem mem_image\u2082_iff (hf : Injective2 f) : f a b \u2208 image\u2082 f s t \u2194 a \u2208 s \u2227 b \u2208 t := by\n  rw [\u2190 mem_coe, coe_image\u2082, mem_image2_iff hf, mem_coe, mem_coe]\n#align finset.mem_image\u2082_iff Finset.mem_image\u2082_iff\n\n/- warning: finset.image\u2082_subset -> Finset.image\u2082_subset is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b1) (Finset.hasSubset.{u1} \u03b1) s s') -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b2) (Finset.hasSubset.{u2} \u03b2) t t') -> (HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {s' : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2}, (HasSubset.Subset.{u3} (Finset.{u3} \u03b1) (Finset.instHasSubsetFinset.{u3} \u03b1) s s') -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b2) (Finset.instHasSubsetFinset.{u2} \u03b2) t t') -> (HasSubset.Subset.{u1} (Finset.{u1} \u03b3) (Finset.instHasSubsetFinset.{u1} \u03b3) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t'))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_subset Finset.image\u2082_subset\u2093'. -/\ntheorem image\u2082_subset (hs : s \u2286 s') (ht : t \u2286 t') : image\u2082 f s t \u2286 image\u2082 f s' t' :=\n  by\n  rw [\u2190 coe_subset, coe_image\u2082, coe_image\u2082]\n  exact image2_subset hs ht\n#align finset.image\u2082_subset Finset.image\u2082_subset\n\n/- warning: finset.image\u2082_subset_left -> Finset.image\u2082_subset_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2}, (HasSubset.Subset.{u2} (Finset.{u2} \u03b2) (Finset.hasSubset.{u2} \u03b2) t t') -> (HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {t' : Finset.{u3} \u03b2}, (HasSubset.Subset.{u3} (Finset.{u3} \u03b2) (Finset.instHasSubsetFinset.{u3} \u03b2) t t') -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b3) (Finset.instHasSubsetFinset.{u2} \u03b3) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t'))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_subset_left Finset.image\u2082_subset_left\u2093'. -/\ntheorem image\u2082_subset_left (ht : t \u2286 t') : image\u2082 f s t \u2286 image\u2082 f s t' :=\n  image\u2082_subset Subset.rfl ht\n#align finset.image\u2082_subset_left Finset.image\u2082_subset_left\n\n/- warning: finset.image\u2082_subset_right -> Finset.image\u2082_subset_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (HasSubset.Subset.{u1} (Finset.{u1} \u03b1) (Finset.hasSubset.{u1} \u03b1) s s') -> (HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {s' : Finset.{u3} \u03b1} {t : Finset.{u1} \u03b2}, (HasSubset.Subset.{u3} (Finset.{u3} \u03b1) (Finset.instHasSubsetFinset.{u3} \u03b1) s s') -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b3) (Finset.instHasSubsetFinset.{u2} \u03b3) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_subset_right Finset.image\u2082_subset_right\u2093'. -/\ntheorem image\u2082_subset_right (hs : s \u2286 s') : image\u2082 f s t \u2286 image\u2082 f s' t :=\n  image\u2082_subset hs Subset.rfl\n#align finset.image\u2082_subset_right Finset.image\u2082_subset_right\n\n/- warning: finset.image_subset_image\u2082_left -> Finset.image_subset_image\u2082_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {b : \u03b2}, (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) b t) -> (HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) (Finset.image.{u1, u3} \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (fun (a : \u03b1) => f a b) s) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {b : \u03b2}, (Membership.mem.{u3, u3} \u03b2 (Finset.{u3} \u03b2) (Finset.instMembershipFinset.{u3} \u03b2) b t) -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b3) (Finset.instHasSubsetFinset.{u2} \u03b3) (Finset.image.{u1, u2} \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (fun (a : \u03b1) => f a b) s) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.image_subset_image\u2082_left Finset.image_subset_image\u2082_left\u2093'. -/\ntheorem image_subset_image\u2082_left (hb : b \u2208 t) : (s.image fun a => f a b) \u2286 image\u2082 f s t :=\n  image_subset_iff.2 fun a ha => mem_image\u2082_of_mem ha hb\n#align finset.image_subset_image\u2082_left Finset.image_subset_image\u2082_left\n\n/- warning: finset.image_subset_image\u2082_right -> Finset.image_subset_image\u2082_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {a : \u03b1}, (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) -> (HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) (Finset.image.{u2, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (f a) t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u1} \u03b2} {a : \u03b1}, (Membership.mem.{u3, u3} \u03b1 (Finset.{u3} \u03b1) (Finset.instMembershipFinset.{u3} \u03b1) a s) -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b3) (Finset.instHasSubsetFinset.{u2} \u03b3) (Finset.image.{u1, u2} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (f a) t) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.image_subset_image\u2082_right Finset.image_subset_image\u2082_right\u2093'. -/\ntheorem image_subset_image\u2082_right (ha : a \u2208 s) : t.image (f a) \u2286 image\u2082 f s t :=\n  image_subset_iff.2 fun b => mem_image\u2082_of_mem ha\n#align finset.image_subset_image\u2082_right Finset.image_subset_image\u2082_right\n\n/- warning: finset.forall_image\u2082_iff -> Finset.forall_image\u2082_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {p : \u03b3 -> Prop}, Iff (forall (z : \u03b3), (Membership.Mem.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.hasMem.{u3} \u03b3) z (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) -> (p z)) (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) x s) -> (forall (y : \u03b2), (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) y t) -> (p (f x y))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {p : \u03b3 -> Prop}, Iff (forall (z : \u03b3), (Membership.mem.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.instMembershipFinset.{u3} \u03b3) z (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) -> (p z)) (forall (x : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) x s) -> (forall (y : \u03b2), (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) y t) -> (p (f x y))))\nCase conversion may be inaccurate. Consider using '#align finset.forall_image\u2082_iff Finset.forall_image\u2082_iff\u2093'. -/\ntheorem forall_image\u2082_iff {p : \u03b3 \u2192 Prop} :\n    (\u2200 z \u2208 image\u2082 f s t, p z) \u2194 \u2200 x \u2208 s, \u2200 y \u2208 t, p (f x y) := by\n  simp_rw [\u2190 mem_coe, coe_image\u2082, forall_image2_iff]\n#align finset.forall_image\u2082_iff Finset.forall_image\u2082_iff\n\n/- warning: finset.image\u2082_subset_iff -> Finset.image\u2082_subset_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {u : Finset.{u3} \u03b3}, Iff (HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) u) (forall (x : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) x s) -> (forall (y : \u03b2), (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) y t) -> (Membership.Mem.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.hasMem.{u3} \u03b3) (f x y) u)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {u : Finset.{u3} \u03b3}, Iff (HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.instHasSubsetFinset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) u) (forall (x : \u03b1), (Membership.mem.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instMembershipFinset.{u2} \u03b1) x s) -> (forall (y : \u03b2), (Membership.mem.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instMembershipFinset.{u1} \u03b2) y t) -> (Membership.mem.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.instMembershipFinset.{u3} \u03b3) (f x y) u)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_subset_iff Finset.image\u2082_subset_iff\u2093'. -/\n@[simp]\ntheorem image\u2082_subset_iff : image\u2082 f s t \u2286 u \u2194 \u2200 x \u2208 s, \u2200 y \u2208 t, f x y \u2208 u :=\n  forall_image\u2082_iff\n#align finset.image\u2082_subset_iff Finset.image\u2082_subset_iff\n\n/- warning: finset.image\u2082_nonempty_iff -> Finset.image\u2082_nonempty_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, Iff (Finset.Nonempty.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (And (Finset.Nonempty.{u1} \u03b1 s) (Finset.Nonempty.{u2} \u03b2 t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, Iff (Finset.Nonempty.{u3} \u03b3 (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (And (Finset.Nonempty.{u2} \u03b1 s) (Finset.Nonempty.{u1} \u03b2 t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_nonempty_iff Finset.image\u2082_nonempty_iff\u2093'. -/\n@[simp]\ntheorem image\u2082_nonempty_iff : (image\u2082 f s t).Nonempty \u2194 s.Nonempty \u2227 t.Nonempty :=\n  by\n  rw [\u2190 coe_nonempty, coe_image\u2082]\n  exact image2_nonempty_iff\n#align finset.image\u2082_nonempty_iff Finset.image\u2082_nonempty_iff\n\n/- warning: finset.nonempty.image\u2082 -> Finset.Nonempty.image\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (Finset.Nonempty.{u1} \u03b1 s) -> (Finset.Nonempty.{u2} \u03b2 t) -> (Finset.Nonempty.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2}, (Finset.Nonempty.{u3} \u03b1 s) -> (Finset.Nonempty.{u2} \u03b2 t) -> (Finset.Nonempty.{u1} \u03b3 (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.image\u2082 Finset.Nonempty.image\u2082\u2093'. -/\ntheorem Nonempty.image\u2082 (hs : s.Nonempty) (ht : t.Nonempty) : (image\u2082 f s t).Nonempty :=\n  image\u2082_nonempty_iff.2 \u27e8hs, ht\u27e9\n#align finset.nonempty.image\u2082 Finset.Nonempty.image\u2082\n\n/- warning: finset.nonempty.of_image\u2082_left -> Finset.Nonempty.of_image\u2082_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (Finset.Nonempty.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) -> (Finset.Nonempty.{u1} \u03b1 s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (Finset.Nonempty.{u3} \u03b3 (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) -> (Finset.Nonempty.{u2} \u03b1 s)\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.of_image\u2082_left Finset.Nonempty.of_image\u2082_left\u2093'. -/\ntheorem Nonempty.of_image\u2082_left (h : (image\u2082 f s t).Nonempty) : s.Nonempty :=\n  (image\u2082_nonempty_iff.1 h).1\n#align finset.nonempty.of_image\u2082_left Finset.Nonempty.of_image\u2082_left\n\n/- warning: finset.nonempty.of_image\u2082_right -> Finset.Nonempty.of_image\u2082_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (Finset.Nonempty.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) -> (Finset.Nonempty.{u2} \u03b2 t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (Finset.Nonempty.{u3} \u03b3 (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) -> (Finset.Nonempty.{u1} \u03b2 t)\nCase conversion may be inaccurate. Consider using '#align finset.nonempty.of_image\u2082_right Finset.Nonempty.of_image\u2082_right\u2093'. -/\ntheorem Nonempty.of_image\u2082_right (h : (image\u2082 f s t).Nonempty) : t.Nonempty :=\n  (image\u2082_nonempty_iff.1 h).2\n#align finset.nonempty.of_image\u2082_right Finset.Nonempty.of_image\u2082_right\n\n/- warning: finset.image\u2082_empty_left -> Finset.image\u2082_empty_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {t : Finset.{u2} \u03b2}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b1) (Finset.hasEmptyc.{u1} \u03b1)) t) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} \u03b3) (Finset.hasEmptyc.{u3} \u03b3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {t : Finset.{u1} \u03b2}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b1) (Finset.instEmptyCollectionFinset.{u2} \u03b1)) t) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} \u03b3) (Finset.instEmptyCollectionFinset.{u3} \u03b3))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_empty_left Finset.image\u2082_empty_left\u2093'. -/\n@[simp]\ntheorem image\u2082_empty_left : image\u2082 f \u2205 t = \u2205 :=\n  coe_injective <| by simp\n#align finset.image\u2082_empty_left Finset.image\u2082_empty_left\n\n/- warning: finset.image\u2082_empty_right -> Finset.image\u2082_empty_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b2) (Finset.hasEmptyc.{u2} \u03b2))) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} \u03b3) (Finset.hasEmptyc.{u3} \u03b3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b2) (Finset.instEmptyCollectionFinset.{u1} \u03b2))) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} \u03b3) (Finset.instEmptyCollectionFinset.{u3} \u03b3))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_empty_right Finset.image\u2082_empty_right\u2093'. -/\n@[simp]\ntheorem image\u2082_empty_right : image\u2082 f s \u2205 = \u2205 :=\n  coe_injective <| by simp\n#align finset.image\u2082_empty_right Finset.image\u2082_empty_right\n\n/- warning: finset.image\u2082_eq_empty_iff -> Finset.image\u2082_eq_empty_iff is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, Iff (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} \u03b3) (Finset.hasEmptyc.{u3} \u03b3))) (Or (Eq.{succ u1} (Finset.{u1} \u03b1) s (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b1) (Finset.hasEmptyc.{u1} \u03b1))) (Eq.{succ u2} (Finset.{u2} \u03b2) t (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b2) (Finset.hasEmptyc.{u2} \u03b2))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, Iff (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (EmptyCollection.emptyCollection.{u3} (Finset.{u3} \u03b3) (Finset.instEmptyCollectionFinset.{u3} \u03b3))) (Or (Eq.{succ u2} (Finset.{u2} \u03b1) s (EmptyCollection.emptyCollection.{u2} (Finset.{u2} \u03b1) (Finset.instEmptyCollectionFinset.{u2} \u03b1))) (Eq.{succ u1} (Finset.{u1} \u03b2) t (EmptyCollection.emptyCollection.{u1} (Finset.{u1} \u03b2) (Finset.instEmptyCollectionFinset.{u1} \u03b2))))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_eq_empty_iff Finset.image\u2082_eq_empty_iff\u2093'. -/\n@[simp]\ntheorem image\u2082_eq_empty_iff : image\u2082 f s t = \u2205 \u2194 s = \u2205 \u2228 t = \u2205 := by\n  simp_rw [\u2190 not_nonempty_iff_eq_empty, image\u2082_nonempty_iff, not_and_or]\n#align finset.image\u2082_eq_empty_iff Finset.image\u2082_eq_empty_iff\n\n/- warning: finset.image\u2082_singleton_left -> Finset.image\u2082_singleton_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {t : Finset.{u2} \u03b2} {a : \u03b1}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) t) (Finset.image.{u2, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (fun (b : \u03b2) => f a b) t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {t : Finset.{u1} \u03b2} {a : \u03b1}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instSingletonFinset.{u2} \u03b1) a) t) (Finset.image.{u1, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (fun (b : \u03b2) => f a b) t)\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_singleton_left Finset.image\u2082_singleton_left\u2093'. -/\n@[simp]\ntheorem image\u2082_singleton_left : image\u2082 f {a} t = t.image fun b => f a b :=\n  ext fun x => by simp\n#align finset.image\u2082_singleton_left Finset.image\u2082_singleton_left\n\n/- warning: finset.image\u2082_singleton_right -> Finset.image\u2082_singleton_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {b : \u03b2}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Singleton.singleton.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasSingleton.{u2} \u03b2) b)) (Finset.image.{u1, u3} \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (fun (a : \u03b1) => f a b) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {b : \u03b2}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Singleton.singleton.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instSingletonFinset.{u1} \u03b2) b)) (Finset.image.{u2, u3} \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (fun (a : \u03b1) => f a b) s)\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_singleton_right Finset.image\u2082_singleton_right\u2093'. -/\n@[simp]\ntheorem image\u2082_singleton_right : image\u2082 f s {b} = s.image fun a => f a b :=\n  ext fun x => by simp\n#align finset.image\u2082_singleton_right Finset.image\u2082_singleton_right\n\n/- warning: finset.image\u2082_singleton_left' -> Finset.image\u2082_singleton_left' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {t : Finset.{u2} \u03b2} {a : \u03b1}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) t) (Finset.image.{u2, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (f a) t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {t : Finset.{u1} \u03b2} {a : \u03b1}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instSingletonFinset.{u2} \u03b1) a) t) (Finset.image.{u1, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (f a) t)\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_singleton_left' Finset.image\u2082_singleton_left'\u2093'. -/\ntheorem image\u2082_singleton_left' : image\u2082 f {a} t = t.image (f a) :=\n  image\u2082_singleton_left\n#align finset.image\u2082_singleton_left' Finset.image\u2082_singleton_left'\n\n/- warning: finset.image\u2082_singleton -> Finset.image\u2082_singleton is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {a : \u03b1} {b : \u03b2}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) (Singleton.singleton.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasSingleton.{u2} \u03b2) b)) (Singleton.singleton.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.hasSingleton.{u3} \u03b3) (f a b))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {a : \u03b1} {b : \u03b2}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u2, u2} \u03b1 (Finset.{u2} \u03b1) (Finset.instSingletonFinset.{u2} \u03b1) a) (Singleton.singleton.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instSingletonFinset.{u1} \u03b2) b)) (Singleton.singleton.{u3, u3} \u03b3 (Finset.{u3} \u03b3) (Finset.instSingletonFinset.{u3} \u03b3) (f a b))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_singleton Finset.image\u2082_singleton\u2093'. -/\ntheorem image\u2082_singleton : image\u2082 f {a} {b} = {f a b} := by simp\n#align finset.image\u2082_singleton Finset.image\u2082_singleton\n\n/- warning: finset.image\u2082_union_left -> Finset.image\u2082_union_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} [_inst_9 : DecidableEq.{succ u1} \u03b1], Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s s') t) (Union.union.{u3} (Finset.{u3} \u03b3) (Finset.hasUnion.{u3} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {s' : Finset.{u3} \u03b1} {t : Finset.{u1} \u03b2} [_inst_9 : DecidableEq.{succ u3} \u03b1], Eq.{succ u2} (Finset.{u2} \u03b3) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Union.union.{u3} (Finset.{u3} \u03b1) (Finset.instUnionFinset.{u3} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s s') t) (Union.union.{u2} (Finset.{u2} \u03b3) (Finset.instUnionFinset.{u2} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_union_left Finset.image\u2082_union_left\u2093'. -/\ntheorem image\u2082_union_left [DecidableEq \u03b1] : image\u2082 f (s \u222a s') t = image\u2082 f s t \u222a image\u2082 f s' t :=\n  coe_injective <| by\n    push_cast\n    exact image2_union_left\n#align finset.image\u2082_union_left Finset.image\u2082_union_left\n\n/- warning: finset.image\u2082_union_right -> Finset.image\u2082_union_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2} [_inst_9 : DecidableEq.{succ u2} \u03b2], Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Union.union.{u2} (Finset.{u2} \u03b2) (Finset.hasUnion.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_9 a b)) t t')) (Union.union.{u3} (Finset.{u3} \u03b3) (Finset.hasUnion.{u3} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {t' : Finset.{u3} \u03b2} [_inst_9 : DecidableEq.{succ u3} \u03b2], Eq.{succ u2} (Finset.{u2} \u03b3) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Union.union.{u3} (Finset.{u3} \u03b2) (Finset.instUnionFinset.{u3} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_9 a b)) t t')) (Union.union.{u2} (Finset.{u2} \u03b3) (Finset.instUnionFinset.{u2} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t'))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_union_right Finset.image\u2082_union_right\u2093'. -/\ntheorem image\u2082_union_right [DecidableEq \u03b2] : image\u2082 f s (t \u222a t') = image\u2082 f s t \u222a image\u2082 f s t' :=\n  coe_injective <| by\n    push_cast\n    exact image2_union_right\n#align finset.image\u2082_union_right Finset.image\u2082_union_right\n\n/- warning: finset.image\u2082_inter_left -> Finset.image\u2082_inter_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} [_inst_9 : DecidableEq.{succ u1} \u03b1], (Function.Injective2.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 f) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s s') t) (Inter.inter.{u3} (Finset.{u3} \u03b3) (Finset.hasInter.{u3} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {s' : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} [_inst_9 : DecidableEq.{succ u3} \u03b1], (Function.Injective2.{succ u3, succ u2, succ u1} \u03b1 \u03b2 \u03b3 f) -> (Eq.{succ u1} (Finset.{u1} \u03b3) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Inter.inter.{u3} (Finset.{u3} \u03b1) (Finset.instInterFinset.{u3} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s s') t) (Inter.inter.{u1} (Finset.{u1} \u03b3) (Finset.instInterFinset.{u1} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_inter_left Finset.image\u2082_inter_left\u2093'. -/\ntheorem image\u2082_inter_left [DecidableEq \u03b1] (hf : Injective2 f) :\n    image\u2082 f (s \u2229 s') t = image\u2082 f s t \u2229 image\u2082 f s' t :=\n  coe_injective <| by\n    push_cast\n    exact image2_inter_left hf\n#align finset.image\u2082_inter_left Finset.image\u2082_inter_left\n\n/- warning: finset.image\u2082_inter_right -> Finset.image\u2082_inter_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2} [_inst_9 : DecidableEq.{succ u2} \u03b2], (Function.Injective2.{succ u1, succ u2, succ u3} \u03b1 \u03b2 \u03b3 f) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Inter.inter.{u2} (Finset.{u2} \u03b2) (Finset.hasInter.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_9 a b)) t t')) (Inter.inter.{u3} (Finset.{u3} \u03b3) (Finset.hasInter.{u3} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t')))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u3} \u03b2} {t' : Finset.{u3} \u03b2} [_inst_9 : DecidableEq.{succ u3} \u03b2], (Function.Injective2.{succ u2, succ u3, succ u1} \u03b1 \u03b2 \u03b3 f) -> (Eq.{succ u1} (Finset.{u1} \u03b3) (Finset.image\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Inter.inter.{u3} (Finset.{u3} \u03b2) (Finset.instInterFinset.{u3} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_9 a b)) t t')) (Inter.inter.{u1} (Finset.{u1} \u03b3) (Finset.instInterFinset.{u1} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t')))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_inter_right Finset.image\u2082_inter_right\u2093'. -/\ntheorem image\u2082_inter_right [DecidableEq \u03b2] (hf : Injective2 f) :\n    image\u2082 f s (t \u2229 t') = image\u2082 f s t \u2229 image\u2082 f s t' :=\n  coe_injective <| by\n    push_cast\n    exact image2_inter_right hf\n#align finset.image\u2082_inter_right Finset.image\u2082_inter_right\n\n/- warning: finset.image\u2082_inter_subset_left -> Finset.image\u2082_inter_subset_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {s' : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} [_inst_9 : DecidableEq.{succ u1} \u03b1], HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s s') t) (Inter.inter.{u3} (Finset.{u3} \u03b3) (Finset.hasInter.{u3} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {s' : Finset.{u3} \u03b1} {t : Finset.{u1} \u03b2} [_inst_9 : DecidableEq.{succ u3} \u03b1], HasSubset.Subset.{u2} (Finset.{u2} \u03b3) (Finset.instHasSubsetFinset.{u2} \u03b3) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Inter.inter.{u3} (Finset.{u3} \u03b1) (Finset.instInterFinset.{u3} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s s') t) (Inter.inter.{u2} (Finset.{u2} \u03b3) (Finset.instInterFinset.{u2} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_inter_subset_left Finset.image\u2082_inter_subset_left\u2093'. -/\ntheorem image\u2082_inter_subset_left [DecidableEq \u03b1] :\n    image\u2082 f (s \u2229 s') t \u2286 image\u2082 f s t \u2229 image\u2082 f s' t :=\n  coe_subset.1 <| by\n    push_cast\n    exact image2_inter_subset_left\n#align finset.image\u2082_inter_subset_left Finset.image\u2082_inter_subset_left\n\n/- warning: finset.image\u2082_inter_subset_right -> Finset.image\u2082_inter_subset_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {t' : Finset.{u2} \u03b2} [_inst_9 : DecidableEq.{succ u2} \u03b2], HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Inter.inter.{u2} (Finset.{u2} \u03b2) (Finset.hasInter.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_9 a b)) t t')) (Inter.inter.{u3} (Finset.{u3} \u03b3) (Finset.hasInter.{u3} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t'))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {t' : Finset.{u3} \u03b2} [_inst_9 : DecidableEq.{succ u3} \u03b2], HasSubset.Subset.{u2} (Finset.{u2} \u03b3) (Finset.instHasSubsetFinset.{u2} \u03b3) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Inter.inter.{u3} (Finset.{u3} \u03b2) (Finset.instInterFinset.{u3} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_9 a b)) t t')) (Inter.inter.{u2} (Finset.{u2} \u03b3) (Finset.instInterFinset.{u2} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t'))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_inter_subset_right Finset.image\u2082_inter_subset_right\u2093'. -/\ntheorem image\u2082_inter_subset_right [DecidableEq \u03b2] :\n    image\u2082 f s (t \u2229 t') \u2286 image\u2082 f s t \u2229 image\u2082 f s t' :=\n  coe_subset.1 <| by\n    push_cast\n    exact image2_inter_subset_right\n#align finset.image\u2082_inter_subset_right Finset.image\u2082_inter_subset_right\n\n/- warning: finset.image\u2082_congr -> Finset.image\u2082_congr is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {f' : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (forall (a : \u03b1), (Membership.Mem.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasMem.{u1} \u03b1) a s) -> (forall (b : \u03b2), (Membership.Mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasMem.{u2} \u03b2) b t) -> (Eq.{succ u3} \u03b3 (f a b) (f' a b)))) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f' s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {f' : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2}, (forall (a : \u03b1), (Membership.mem.{u3, u3} \u03b1 (Finset.{u3} \u03b1) (Finset.instMembershipFinset.{u3} \u03b1) a s) -> (forall (b : \u03b2), (Membership.mem.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.instMembershipFinset.{u2} \u03b2) b t) -> (Eq.{succ u1} \u03b3 (f a b) (f' a b)))) -> (Eq.{succ u1} (Finset.{u1} \u03b3) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f' s t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_congr Finset.image\u2082_congr\u2093'. -/\ntheorem image\u2082_congr (h : \u2200 a \u2208 s, \u2200 b \u2208 t, f a b = f' a b) : image\u2082 f s t = image\u2082 f' s t :=\n  coe_injective <| by\n    push_cast\n    exact image2_congr h\n#align finset.image\u2082_congr Finset.image\u2082_congr\n\n/- warning: finset.image\u2082_congr' -> Finset.image\u2082_congr' is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {f' : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03b3 (f a b) (f' a b)) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f' s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {f' : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03b3 (f a b) (f' a b)) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f' s t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_congr' Finset.image\u2082_congr'\u2093'. -/\n/-- A common special case of `image\u2082_congr` -/\ntheorem image\u2082_congr' (h : \u2200 a b, f a b = f' a b) : image\u2082 f s t = image\u2082 f' s t :=\n  image\u2082_congr fun a _ b _ => h a b\n#align finset.image\u2082_congr' Finset.image\u2082_congr'\n\n/- warning: finset.subset_image\u2082 -> Finset.subset_image\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {u : Finset.{u3} \u03b3} {s : Set.{u1} \u03b1} {t : Set.{u2} \u03b2}, (HasSubset.Subset.{u3} (Set.{u3} \u03b3) (Set.hasSubset.{u3} \u03b3) ((fun (a : Type.{u3}) (b : Type.{u3}) [self : HasLiftT.{succ u3, succ u3} a b] => self.0) (Finset.{u3} \u03b3) (Set.{u3} \u03b3) (HasLiftT.mk.{succ u3, succ u3} (Finset.{u3} \u03b3) (Set.{u3} \u03b3) (CoeTC\u2093.coe.{succ u3, succ u3} (Finset.{u3} \u03b3) (Set.{u3} \u03b3) (Finset.Set.hasCoeT.{u3} \u03b3))) u) (Set.image2.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f s t)) -> (Exists.{succ u1} (Finset.{u1} \u03b1) (fun (s' : Finset.{u1} \u03b1) => Exists.{succ u2} (Finset.{u2} \u03b2) (fun (t' : Finset.{u2} \u03b2) => And (HasSubset.Subset.{u1} (Set.{u1} \u03b1) (Set.hasSubset.{u1} \u03b1) ((fun (a : Type.{u1}) (b : Type.{u1}) [self : HasLiftT.{succ u1, succ u1} a b] => self.0) (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (HasLiftT.mk.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (CoeTC\u2093.coe.{succ u1, succ u1} (Finset.{u1} \u03b1) (Set.{u1} \u03b1) (Finset.Set.hasCoeT.{u1} \u03b1))) s') s) (And (HasSubset.Subset.{u2} (Set.{u2} \u03b2) (Set.hasSubset.{u2} \u03b2) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (CoeTC\u2093.coe.{succ u2, succ u2} (Finset.{u2} \u03b2) (Set.{u2} \u03b2) (Finset.Set.hasCoeT.{u2} \u03b2))) t') t) (HasSubset.Subset.{u3} (Finset.{u3} \u03b3) (Finset.hasSubset.{u3} \u03b3) u (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t'))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {u : Finset.{u1} \u03b3} {s : Set.{u3} \u03b1} {t : Set.{u2} \u03b2}, (HasSubset.Subset.{u1} (Set.{u1} \u03b3) (Set.instHasSubsetSet.{u1} \u03b3) (Finset.toSet.{u1} \u03b3 u) (Set.image2.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f s t)) -> (Exists.{succ u3} (Finset.{u3} \u03b1) (fun (s' : Finset.{u3} \u03b1) => Exists.{succ u2} (Finset.{u2} \u03b2) (fun (t' : Finset.{u2} \u03b2) => And (HasSubset.Subset.{u3} (Set.{u3} \u03b1) (Set.instHasSubsetSet.{u3} \u03b1) (Finset.toSet.{u3} \u03b1 s') s) (And (HasSubset.Subset.{u2} (Set.{u2} \u03b2) (Set.instHasSubsetSet.{u2} \u03b2) (Finset.toSet.{u2} \u03b2 t') t) (HasSubset.Subset.{u1} (Finset.{u1} \u03b3) (Finset.instHasSubsetFinset.{u1} \u03b3) u (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s' t'))))))\nCase conversion may be inaccurate. Consider using '#align finset.subset_image\u2082 Finset.subset_image\u2082\u2093'. -/\ntheorem subset_image\u2082 {s : Set \u03b1} {t : Set \u03b2} (hu : \u2191u \u2286 image2 f s t) :\n    \u2203 (s' : Finset \u03b1)(t' : Finset \u03b2), \u2191s' \u2286 s \u2227 \u2191t' \u2286 t \u2227 u \u2286 image\u2082 f s' t' :=\n  by\n  apply Finset.induction_on' u\n  \u00b7 exact \u27e8\u2205, \u2205, Set.empty_subset _, Set.empty_subset _, empty_subset _\u27e9\n  rintro a u ha _ _ \u27e8s', t', hs, hs', h\u27e9\n  obtain \u27e8x, y, hx, hy, ha\u27e9 := hu ha\n  haveI := Classical.decEq \u03b1\n  haveI := Classical.decEq \u03b2\n  refine' \u27e8insert x s', insert y t', _\u27e9\n  simp_rw [coe_insert, Set.insert_subset]\n  exact\n    \u27e8\u27e8hx, hs\u27e9, \u27e8hy, hs'\u27e9,\n      insert_subset.2\n        \u27e8mem_image\u2082.2 \u27e8x, y, mem_insert_self _ _, mem_insert_self _ _, ha\u27e9,\n          h.trans <| image\u2082_subset (subset_insert _ _) <| subset_insert _ _\u27e9\u27e9\n#align finset.subset_image\u2082 Finset.subset_image\u2082\n\nvariable (s t)\n\n/- warning: finset.card_image\u2082_singleton_left -> Finset.card_image\u2082_singleton_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} (t : Finset.{u2} \u03b2) {a : \u03b1}, (Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (f a)) -> (Eq.{1} Nat (Finset.card.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) t)) (Finset.card.{u2} \u03b2 t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} (t : Finset.{u3} \u03b2) {a : \u03b1}, (Function.Injective.{succ u3, succ u2} \u03b2 \u03b3 (f a)) -> (Eq.{1} Nat (Finset.card.{u2} \u03b3 (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instSingletonFinset.{u1} \u03b1) a) t)) (Finset.card.{u3} \u03b2 t))\nCase conversion may be inaccurate. Consider using '#align finset.card_image\u2082_singleton_left Finset.card_image\u2082_singleton_left\u2093'. -/\ntheorem card_image\u2082_singleton_left (hf : Injective (f a)) : (image\u2082 f {a} t).card = t.card := by\n  rw [image\u2082_singleton_left, card_image_of_injective _ hf]\n#align finset.card_image\u2082_singleton_left Finset.card_image\u2082_singleton_left\n\n/- warning: finset.card_image\u2082_singleton_right -> Finset.card_image\u2082_singleton_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} (s : Finset.{u1} \u03b1) {b : \u03b2}, (Function.Injective.{succ u1, succ u3} \u03b1 \u03b3 (fun (a : \u03b1) => f a b)) -> (Eq.{1} Nat (Finset.card.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Singleton.singleton.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasSingleton.{u2} \u03b2) b))) (Finset.card.{u1} \u03b1 s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} (s : Finset.{u3} \u03b1) {b : \u03b2}, (Function.Injective.{succ u3, succ u2} \u03b1 \u03b3 (fun (a : \u03b1) => f a b)) -> (Eq.{1} Nat (Finset.card.{u2} \u03b3 (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Singleton.singleton.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instSingletonFinset.{u1} \u03b2) b))) (Finset.card.{u3} \u03b1 s))\nCase conversion may be inaccurate. Consider using '#align finset.card_image\u2082_singleton_right Finset.card_image\u2082_singleton_right\u2093'. -/\ntheorem card_image\u2082_singleton_right (hf : Injective fun a => f a b) :\n    (image\u2082 f s {b}).card = s.card := by rw [image\u2082_singleton_right, card_image_of_injective _ hf]\n#align finset.card_image\u2082_singleton_right Finset.card_image\u2082_singleton_right\n\n/- warning: finset.image\u2082_singleton_inter -> Finset.image\u2082_singleton_inter is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {a : \u03b1} [_inst_9 : DecidableEq.{succ u2} \u03b2] (t\u2081 : Finset.{u2} \u03b2) (t\u2082 : Finset.{u2} \u03b2), (Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (f a)) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) (Inter.inter.{u2} (Finset.{u2} \u03b2) (Finset.hasInter.{u2} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_9 a b)) t\u2081 t\u2082)) (Inter.inter.{u3} (Finset.{u3} \u03b3) (Finset.hasInter.{u3} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) t\u2081) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.hasSingleton.{u1} \u03b1) a) t\u2082)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {a : \u03b1} [_inst_9 : DecidableEq.{succ u3} \u03b2] (t\u2081 : Finset.{u3} \u03b2) (t\u2082 : Finset.{u3} \u03b2), (Function.Injective.{succ u3, succ u2} \u03b2 \u03b3 (f a)) -> (Eq.{succ u2} (Finset.{u2} \u03b3) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instSingletonFinset.{u1} \u03b1) a) (Inter.inter.{u3} (Finset.{u3} \u03b2) (Finset.instInterFinset.{u3} \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_9 a b)) t\u2081 t\u2082)) (Inter.inter.{u2} (Finset.{u2} \u03b3) (Finset.instInterFinset.{u2} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instSingletonFinset.{u1} \u03b1) a) t\u2081) (Finset.image\u2082.{u1, u3, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Singleton.singleton.{u1, u1} \u03b1 (Finset.{u1} \u03b1) (Finset.instSingletonFinset.{u1} \u03b1) a) t\u2082)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_singleton_inter Finset.image\u2082_singleton_inter\u2093'. -/\ntheorem image\u2082_singleton_inter [DecidableEq \u03b2] (t\u2081 t\u2082 : Finset \u03b2) (hf : Injective (f a)) :\n    image\u2082 f {a} (t\u2081 \u2229 t\u2082) = image\u2082 f {a} t\u2081 \u2229 image\u2082 f {a} t\u2082 := by\n  simp_rw [image\u2082_singleton_left, image_inter _ _ hf]\n#align finset.image\u2082_singleton_inter Finset.image\u2082_singleton_inter\n\n/- warning: finset.image\u2082_inter_singleton -> Finset.image\u2082_inter_singleton is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {b : \u03b2} [_inst_9 : DecidableEq.{succ u1} \u03b1] (s\u2081 : Finset.{u1} \u03b1) (s\u2082 : Finset.{u1} \u03b1), (Function.Injective.{succ u1, succ u3} \u03b1 \u03b3 (fun (a : \u03b1) => f a b)) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s\u2081 s\u2082) (Singleton.singleton.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasSingleton.{u2} \u03b2) b)) (Inter.inter.{u3} (Finset.{u3} \u03b3) (Finset.hasInter.{u3} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s\u2081 (Singleton.singleton.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasSingleton.{u2} \u03b2) b)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s\u2082 (Singleton.singleton.{u2, u2} \u03b2 (Finset.{u2} \u03b2) (Finset.hasSingleton.{u2} \u03b2) b))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} [_inst_3 : DecidableEq.{succ u2} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {b : \u03b2} [_inst_9 : DecidableEq.{succ u3} \u03b1] (s\u2081 : Finset.{u3} \u03b1) (s\u2082 : Finset.{u3} \u03b1), (Function.Injective.{succ u3, succ u2} \u03b1 \u03b3 (fun (a : \u03b1) => f a b)) -> (Eq.{succ u2} (Finset.{u2} \u03b3) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Inter.inter.{u3} (Finset.{u3} \u03b1) (Finset.instInterFinset.{u3} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s\u2081 s\u2082) (Singleton.singleton.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instSingletonFinset.{u1} \u03b2) b)) (Inter.inter.{u2} (Finset.{u2} \u03b3) (Finset.instInterFinset.{u2} \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b)) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s\u2081 (Singleton.singleton.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instSingletonFinset.{u1} \u03b2) b)) (Finset.image\u2082.{u3, u1, u2} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s\u2082 (Singleton.singleton.{u1, u1} \u03b2 (Finset.{u1} \u03b2) (Finset.instSingletonFinset.{u1} \u03b2) b))))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_inter_singleton Finset.image\u2082_inter_singleton\u2093'. -/\ntheorem image\u2082_inter_singleton [DecidableEq \u03b1] (s\u2081 s\u2082 : Finset \u03b1) (hf : Injective fun a => f a b) :\n    image\u2082 f (s\u2081 \u2229 s\u2082) {b} = image\u2082 f s\u2081 {b} \u2229 image\u2082 f s\u2082 {b} := by\n  simp_rw [image\u2082_singleton_right, image_inter _ _ hf]\n#align finset.image\u2082_inter_singleton Finset.image\u2082_inter_singleton\n\n/- warning: finset.card_le_card_image\u2082_left -> Finset.card_le_card_image\u2082_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} (t : Finset.{u2} \u03b2) {s : Finset.{u1} \u03b1}, (Finset.Nonempty.{u1} \u03b1 s) -> (forall (a : \u03b1), Function.Injective.{succ u2, succ u3} \u03b2 \u03b3 (f a)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u2} \u03b2 t) (Finset.card.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} (t : Finset.{u2} \u03b2) {s : Finset.{u3} \u03b1}, (Finset.Nonempty.{u3} \u03b1 s) -> (forall (a : \u03b1), Function.Injective.{succ u2, succ u1} \u03b2 \u03b3 (f a)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b2 t) (Finset.card.{u1} \u03b3 (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_image\u2082_left Finset.card_le_card_image\u2082_left\u2093'. -/\ntheorem card_le_card_image\u2082_left {s : Finset \u03b1} (hs : s.Nonempty) (hf : \u2200 a, Injective (f a)) :\n    t.card \u2264 (image\u2082 f s t).card := by\n  obtain \u27e8a, ha\u27e9 := hs\n  rw [\u2190 card_image\u2082_singleton_left _ (hf a)]\n  exact card_le_of_subset (image\u2082_subset_right <| singleton_subset_iff.2 ha)\n#align finset.card_le_card_image\u2082_left Finset.card_le_card_image\u2082_left\n\n/- warning: finset.card_le_card_image\u2082_right -> Finset.card_le_card_image\u2082_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} (s : Finset.{u1} \u03b1) {t : Finset.{u2} \u03b2}, (Finset.Nonempty.{u2} \u03b2 t) -> (forall (b : \u03b2), Function.Injective.{succ u1, succ u3} \u03b1 \u03b3 (fun (a : \u03b1) => f a b)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} \u03b1 s) (Finset.card.{u3} \u03b3 (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} (s : Finset.{u2} \u03b1) {t : Finset.{u3} \u03b2}, (Finset.Nonempty.{u3} \u03b2 t) -> (forall (b : \u03b2), Function.Injective.{succ u2, succ u1} \u03b1 \u03b3 (fun (a : \u03b1) => f a b)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} \u03b1 s) (Finset.card.{u1} \u03b3 (Finset.image\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)))\nCase conversion may be inaccurate. Consider using '#align finset.card_le_card_image\u2082_right Finset.card_le_card_image\u2082_right\u2093'. -/\ntheorem card_le_card_image\u2082_right {t : Finset \u03b2} (ht : t.Nonempty)\n    (hf : \u2200 b, Injective fun a => f a b) : s.card \u2264 (image\u2082 f s t).card :=\n  by\n  obtain \u27e8b, hb\u27e9 := ht\n  rw [\u2190 card_image\u2082_singleton_right _ (hf b)]\n  exact card_le_of_subset (image\u2082_subset_left <| singleton_subset_iff.2 hb)\n#align finset.card_le_card_image\u2082_right Finset.card_le_card_image\u2082_right\n\nvariable {s t}\n\n/- warning: finset.bUnion_image_left -> Finset.bunion\u1d62_image_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.bunion\u1d62.{u1, u3} \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) s (fun (a : \u03b1) => Finset.image.{u2, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (f a) t)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2}, Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.bunion\u1d62.{u2, u3} \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) s (fun (a : \u03b1) => Finset.image.{u1, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (f a) t)) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)\nCase conversion may be inaccurate. Consider using '#align finset.bUnion_image_left Finset.bunion\u1d62_image_left\u2093'. -/\ntheorem bunion\u1d62_image_left : (s.bunion\u1d62 fun a => t.image <| f a) = image\u2082 f s t :=\n  coe_injective <| by\n    push_cast\n    exact Set.union\u1d62_image_left _\n#align finset.bUnion_image_left Finset.bunion\u1d62_image_left\n\n#print Finset.bunion\u1d62_image_right /-\ntheorem bunion\u1d62_image_right : (t.bunion\u1d62 fun b => s.image fun a => f a b) = image\u2082 f s t :=\n  coe_injective <| by\n    push_cast\n    exact Set.union\u1d62_image_right _\n#align finset.bUnion_image_right Finset.bunion\u1d62_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\u2082` of those operations.\n\nThe proof pattern is `image\u2082_lemma operation_lemma`. For example, `image\u2082_comm mul_comm` proves that\n`image\u2082 (*) f g = image\u2082 (*) g f` in a `comm_semigroup`.\n-/\n\n\n/- warning: finset.image_image\u2082 -> Finset.image_image\u2082 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_3 : DecidableEq.{succ u3} \u03b3] [_inst_5 : DecidableEq.{succ u4} \u03b4] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} (f : \u03b1 -> \u03b2 -> \u03b3) (g : \u03b3 -> \u03b4), Eq.{succ u4} (Finset.{u4} \u03b4) (Finset.image.{u3, u4} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) (fun (a : \u03b1) (b : \u03b2) => g (f a b)) s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_3 : DecidableEq.{succ u3} \u03b3] [_inst_5 : DecidableEq.{succ u4} \u03b4] {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} (f : \u03b1 -> \u03b2 -> \u03b3) (g : \u03b3 -> \u03b4), Eq.{succ u4} (Finset.{u4} \u03b4) (Finset.image.{u3, u4} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u2, u1, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) (fun (a : \u03b1) (b : \u03b2) => g (f a b)) s t)\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082 Finset.image_image\u2082\u2093'. -/\ntheorem image_image\u2082 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (g : \u03b3 \u2192 \u03b4) :\n    (image\u2082 f s t).image g = image\u2082 (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\u2082 Finset.image_image\u2082\n\n#print Finset.image\u2082_image_left /-\ntheorem image\u2082_image_left (f : \u03b3 \u2192 \u03b2 \u2192 \u03b4) (g : \u03b1 \u2192 \u03b3) :\n    image\u2082 f (s.image g) t = image\u2082 (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\u2082_image_left Finset.image\u2082_image_left\n-/\n\n/- warning: finset.image\u2082_image_right -> Finset.image\u2082_image_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} {\u03b4 : Type.{u4}} [_inst_3 : DecidableEq.{succ u3} \u03b3] [_inst_5 : DecidableEq.{succ u4} \u03b4] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} (f : \u03b1 -> \u03b3 -> \u03b4) (g : \u03b2 -> \u03b3), Eq.{succ u4} (Finset.{u4} \u03b4) (Finset.image\u2082.{u1, u3, u4} \u03b1 \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f s (Finset.image.{u2, u3} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g t)) (Finset.image\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) (fun (a : \u03b1) (b : \u03b2) => f a (g b)) s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u2}} {\u03b4 : Type.{u4}} [_inst_3 : DecidableEq.{succ u2} \u03b3] [_inst_5 : DecidableEq.{succ u4} \u03b4] {s : Finset.{u3} \u03b1} {t : Finset.{u1} \u03b2} (f : \u03b1 -> \u03b3 -> \u03b4) (g : \u03b2 -> \u03b3), Eq.{succ u4} (Finset.{u4} \u03b4) (Finset.image\u2082.{u3, u2, u4} \u03b1 \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f s (Finset.image.{u1, u2} \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g t)) (Finset.image\u2082.{u3, u1, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) (fun (a : \u03b1) (b : \u03b2) => f a (g b)) s t)\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_image_right Finset.image\u2082_image_right\u2093'. -/\ntheorem image\u2082_image_right (f : \u03b1 \u2192 \u03b3 \u2192 \u03b4) (g : \u03b2 \u2192 \u03b3) :\n    image\u2082 f s (t.image g) = image\u2082 (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\u2082_image_right Finset.image\u2082_image_right\n\n/- warning: finset.image\u2082_swap -> Finset.image\u2082_swap is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u2, u1, u3} \u03b2 \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (fun (a : \u03b2) (b : \u03b1) => f b a) t s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Finset.{u3} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ u1} (Finset.{u1} \u03b3) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u2, u3, u1} \u03b2 \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (fun (a : \u03b2) (b : \u03b1) => f b a) t s)\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_swap Finset.image\u2082_swap\u2093'. -/\ntheorem image\u2082_swap (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : Finset \u03b1) (t : Finset \u03b2) :\n    image\u2082 f s t = image\u2082 (fun a b => f b a) t s :=\n  coe_injective <| by\n    push_cast\n    exact image2_swap _ _ _\n#align finset.image\u2082_swap Finset.image\u2082_swap\n\n/- warning: finset.image\u2082_mk_eq_product -> Finset.image\u2082_mk_eq_product is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_9 : DecidableEq.{succ u1} \u03b1] [_inst_10 : DecidableEq.{succ u2} \u03b2] (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ (max u1 u2)} (Finset.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2)) (Finset.image\u2082.{u1, u2, max u1 u2} \u03b1 \u03b2 (Prod.{u1, u2} \u03b1 \u03b2) (fun (a : Prod.{u1, u2} \u03b1 \u03b2) (b : Prod.{u1, u2} \u03b1 \u03b2) => Prod.decidableEq.{u1, u2} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) a b) (Prod.mk.{u1, u2} \u03b1 \u03b2) s t) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_9 : DecidableEq.{succ u2} \u03b1] [_inst_10 : DecidableEq.{succ u1} \u03b2] (s : Finset.{u2} \u03b1) (t : Finset.{u1} \u03b2), Eq.{max (succ u2) (succ u1)} (Finset.{max u1 u2} (Prod.{u2, u1} \u03b1 \u03b2)) (Finset.image\u2082.{u2, u1, max u1 u2} \u03b1 \u03b2 (Prod.{u2, u1} \u03b1 \u03b2) (fun (a : Prod.{u2, u1} \u03b1 \u03b2) (b : Prod.{u2, u1} \u03b1 \u03b2) => instDecidableEqProd.{u2, u1} \u03b1 \u03b2 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b) (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) a b) (Prod.mk.{u2, u1} \u03b1 \u03b2) s t) (Finset.product.{u2, u1} \u03b1 \u03b2 s t)\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_mk_eq_product Finset.image\u2082_mk_eq_product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem image\u2082_mk_eq_product [DecidableEq \u03b1] [DecidableEq \u03b2] (s : Finset \u03b1) (t : Finset \u03b2) :\n    image\u2082 Prod.mk s t = s \u00d7\u02e2 t := by ext <;> simp [Prod.ext_iff]\n#align finset.image\u2082_mk_eq_product Finset.image\u2082_mk_eq_product\n\n/- warning: finset.image\u2082_curry -> Finset.image\u2082_curry is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] (f : (Prod.{u1, u2} \u03b1 \u03b2) -> \u03b3) (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (Function.curry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f) s t) (Finset.image.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Finset.product.{u1, u2} \u03b1 \u03b2 s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] (f : (Prod.{u3, u2} \u03b1 \u03b2) -> \u03b3) (s : Finset.{u3} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ u1} (Finset.{u1} \u03b3) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (Function.curry.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f) s t) (Finset.image.{max u3 u2, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Finset.product.{u3, u2} \u03b1 \u03b2 s t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_curry Finset.image\u2082_curry\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem image\u2082_curry (f : \u03b1 \u00d7 \u03b2 \u2192 \u03b3) (s : Finset \u03b1) (t : Finset \u03b2) :\n    image\u2082 (curry f) s t = (s \u00d7\u02e2 t).image f := by\n  classical rw [\u2190 image\u2082_mk_eq_product, image_image\u2082, curry]\n#align finset.image\u2082_curry Finset.image\u2082_curry\n\n/- warning: finset.image_uncurry_product -> Finset.image_uncurry_product is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Finset.{u1} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image.{max u1 u2, u3} (Prod.{u1, u2} \u03b1 \u03b2) \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (Function.uncurry.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f) (Finset.product.{u1, u2} \u03b1 \u03b2 s t)) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_3 : DecidableEq.{succ u1} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Finset.{u3} \u03b1) (t : Finset.{u2} \u03b2), Eq.{succ u1} (Finset.{u1} \u03b3) (Finset.image.{max u2 u3, u1} (Prod.{u3, u2} \u03b1 \u03b2) \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) (Function.uncurry.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f) (Finset.product.{u3, u2} \u03b1 \u03b2 s t)) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)\nCase conversion may be inaccurate. Consider using '#align finset.image_uncurry_product Finset.image_uncurry_product\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n@[simp]\ntheorem image_uncurry_product (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : Finset \u03b1) (t : Finset \u03b2) :\n    (s \u00d7\u02e2 t).image (uncurry f) = image\u2082 f s t := by rw [\u2190 image\u2082_curry, curry_uncurry]\n#align finset.image_uncurry_product Finset.image_uncurry_product\n\n/- warning: finset.image\u2082_left -> Finset.image\u2082_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} [_inst_9 : DecidableEq.{succ u1} \u03b1], (Finset.Nonempty.{u2} \u03b2 t) -> (Eq.{succ u1} (Finset.{u1} \u03b1) (Finset.image\u2082.{u1, u2, u1} \u03b1 \u03b2 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b) (fun (x : \u03b1) (y : \u03b2) => x) s t) s)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} [_inst_9 : DecidableEq.{succ u2} \u03b1], (Finset.Nonempty.{u1} \u03b2 t) -> (Eq.{succ u2} (Finset.{u2} \u03b1) (Finset.image\u2082.{u2, u1, u2} \u03b1 \u03b2 \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b) (fun (x : \u03b1) (y : \u03b2) => x) s t) s)\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_left Finset.image\u2082_left\u2093'. -/\n@[simp]\ntheorem image\u2082_left [DecidableEq \u03b1] (h : t.Nonempty) : image\u2082 (fun x y => x) s t = s :=\n  coe_injective <| by\n    push_cast\n    exact image2_left h\n#align finset.image\u2082_left Finset.image\u2082_left\n\n#print Finset.image\u2082_right /-\n@[simp]\ntheorem image\u2082_right [DecidableEq \u03b2] (h : s.Nonempty) : image\u2082 (fun x y => y) s t = t :=\n  coe_injective <| by\n    push_cast\n    exact image2_right h\n#align finset.image\u2082_right Finset.image\u2082_right\n-/\n\n/- warning: finset.image\u2082_assoc -> Finset.image\u2082_assoc is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b4 : Type.{u3}} {\u03b5 : Type.{u4}} {\u03b5' : Type.{u5}} [_inst_5 : DecidableEq.{succ u3} \u03b4] [_inst_7 : DecidableEq.{succ u4} \u03b5] [_inst_8 : DecidableEq.{succ u5} \u03b5'] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u6}} {u : Finset.{u6} \u03b3} {f : \u03b4 -> \u03b3 -> \u03b5} {g : \u03b1 -> \u03b2 -> \u03b4} {f' : \u03b1 -> \u03b5' -> \u03b5} {g' : \u03b2 -> \u03b3 -> \u03b5'}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u4} \u03b5 (f (g a b) c) (f' a (g' b c))) -> (Eq.{succ u4} (Finset.{u4} \u03b5) (Finset.image\u2082.{u3, u6, u4} \u03b4 \u03b3 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g s t) u) (Finset.image\u2082.{u1, u5, u4} \u03b1 \u03b5' \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f' s (Finset.image\u2082.{u2, u6, u5} \u03b2 \u03b3 \u03b5' (fun (a : \u03b5') (b : \u03b5') => _inst_8 a b) g' t u)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b4 : Type.{u4}} {\u03b5 : Type.{u5}} {\u03b5' : Type.{u1}} [_inst_5 : DecidableEq.{succ u4} \u03b4] [_inst_7 : DecidableEq.{succ u5} \u03b5] [_inst_8 : DecidableEq.{succ u1} \u03b5'] {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u6}} {u : Finset.{u6} \u03b3} {f : \u03b4 -> \u03b3 -> \u03b5} {g : \u03b1 -> \u03b2 -> \u03b4} {f' : \u03b1 -> \u03b5' -> \u03b5} {g' : \u03b2 -> \u03b3 -> \u03b5'}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u5} \u03b5 (f (g a b) c) (f' a (g' b c))) -> (Eq.{succ u5} (Finset.{u5} \u03b5) (Finset.image\u2082.{u4, u6, u5} \u03b4 \u03b3 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f (Finset.image\u2082.{u3, u2, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g s t) u) (Finset.image\u2082.{u3, u1, u5} \u03b1 \u03b5' \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f' s (Finset.image\u2082.{u2, u6, u1} \u03b2 \u03b3 \u03b5' (fun (a : \u03b5') (b : \u03b5') => _inst_8 a b) g' t u)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_assoc Finset.image\u2082_assoc\u2093'. -/\ntheorem image\u2082_assoc {\u03b3 : Type _} {u : Finset \u03b3} {f : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b5' \u2192 \u03b5}\n    {g' : \u03b2 \u2192 \u03b3 \u2192 \u03b5'} (h_assoc : \u2200 a b c, f (g a b) c = f' a (g' b c)) :\n    image\u2082 f (image\u2082 g s t) u = image\u2082 f' s (image\u2082 g' t u) :=\n  coe_injective <| by\n    push_cast\n    exact image2_assoc h_assoc\n#align finset.image\u2082_assoc Finset.image\u2082_assoc\n\n/- warning: finset.image\u2082_comm -> Finset.image\u2082_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {g : \u03b2 -> \u03b1 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03b3 (f a b) (g b a)) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u2, u1, u3} \u03b2 \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g t s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} {\u03b3 : Type.{u3}} [_inst_3 : DecidableEq.{succ u3} \u03b3] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u2} \u03b1} {t : Finset.{u1} \u03b2} {g : \u03b2 -> \u03b1 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u3} \u03b3 (f a b) (g b a)) -> (Eq.{succ u3} (Finset.{u3} \u03b3) (Finset.image\u2082.{u2, u1, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t) (Finset.image\u2082.{u1, u2, u3} \u03b2 \u03b1 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g t s))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_comm Finset.image\u2082_comm\u2093'. -/\ntheorem image\u2082_comm {g : \u03b2 \u2192 \u03b1 \u2192 \u03b3} (h_comm : \u2200 a b, f a b = g b a) : image\u2082 f s t = image\u2082 g t s :=\n  (image\u2082_swap _ _ _).trans <| by simp_rw [h_comm]\n#align finset.image\u2082_comm Finset.image\u2082_comm\n\n/- warning: finset.image\u2082_left_comm -> Finset.image\u2082_left_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b4 : Type.{u3}} {\u03b4' : Type.{u4}} {\u03b5 : Type.{u5}} [_inst_5 : DecidableEq.{succ u3} \u03b4] [_inst_6 : DecidableEq.{succ u4} \u03b4'] [_inst_7 : DecidableEq.{succ u5} \u03b5] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u6}} {u : Finset.{u6} \u03b3} {f : \u03b1 -> \u03b4 -> \u03b5} {g : \u03b2 -> \u03b3 -> \u03b4} {f' : \u03b1 -> \u03b3 -> \u03b4'} {g' : \u03b2 -> \u03b4' -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u5} \u03b5 (f a (g b c)) (g' b (f' a c))) -> (Eq.{succ u5} (Finset.{u5} \u03b5) (Finset.image\u2082.{u1, u3, u5} \u03b1 \u03b4 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f s (Finset.image\u2082.{u2, u6, u3} \u03b2 \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g t u)) (Finset.image\u2082.{u2, u4, u5} \u03b2 \u03b4' \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g' t (Finset.image\u2082.{u1, u6, u4} \u03b1 \u03b3 \u03b4' (fun (a : \u03b4') (b : \u03b4') => _inst_6 a b) f' s u)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b2 : Type.{u2}} {\u03b4 : Type.{u3}} {\u03b4' : Type.{u1}} {\u03b5 : Type.{u5}} [_inst_5 : DecidableEq.{succ u3} \u03b4] [_inst_6 : DecidableEq.{succ u1} \u03b4'] [_inst_7 : DecidableEq.{succ u5} \u03b5] {s : Finset.{u4} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u6}} {u : Finset.{u6} \u03b3} {f : \u03b1 -> \u03b4 -> \u03b5} {g : \u03b2 -> \u03b3 -> \u03b4} {f' : \u03b1 -> \u03b3 -> \u03b4'} {g' : \u03b2 -> \u03b4' -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u5} \u03b5 (f a (g b c)) (g' b (f' a c))) -> (Eq.{succ u5} (Finset.{u5} \u03b5) (Finset.image\u2082.{u4, u3, u5} \u03b1 \u03b4 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f s (Finset.image\u2082.{u2, u6, u3} \u03b2 \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g t u)) (Finset.image\u2082.{u2, u1, u5} \u03b2 \u03b4' \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g' t (Finset.image\u2082.{u4, u6, u1} \u03b1 \u03b3 \u03b4' (fun (a : \u03b4') (b : \u03b4') => _inst_6 a b) f' s u)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_left_comm Finset.image\u2082_left_comm\u2093'. -/\ntheorem image\u2082_left_comm {\u03b3 : Type _} {u : Finset \u03b3} {f : \u03b1 \u2192 \u03b4 \u2192 \u03b5} {g : \u03b2 \u2192 \u03b3 \u2192 \u03b4}\n    {f' : \u03b1 \u2192 \u03b3 \u2192 \u03b4'} {g' : \u03b2 \u2192 \u03b4' \u2192 \u03b5} (h_left_comm : \u2200 a b c, f a (g b c) = g' b (f' a c)) :\n    image\u2082 f s (image\u2082 g t u) = image\u2082 g' t (image\u2082 f' s u) :=\n  coe_injective <| by\n    push_cast\n    exact image2_left_comm h_left_comm\n#align finset.image\u2082_left_comm Finset.image\u2082_left_comm\n\n/- warning: finset.image\u2082_right_comm -> Finset.image\u2082_right_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b4 : Type.{u3}} {\u03b4' : Type.{u4}} {\u03b5 : Type.{u5}} [_inst_5 : DecidableEq.{succ u3} \u03b4] [_inst_6 : DecidableEq.{succ u4} \u03b4'] [_inst_7 : DecidableEq.{succ u5} \u03b5] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u6}} {u : Finset.{u6} \u03b3} {f : \u03b4 -> \u03b3 -> \u03b5} {g : \u03b1 -> \u03b2 -> \u03b4} {f' : \u03b1 -> \u03b3 -> \u03b4'} {g' : \u03b4' -> \u03b2 -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u5} \u03b5 (f (g a b) c) (g' (f' a c) b)) -> (Eq.{succ u5} (Finset.{u5} \u03b5) (Finset.image\u2082.{u3, u6, u5} \u03b4 \u03b3 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g s t) u) (Finset.image\u2082.{u4, u2, u5} \u03b4' \u03b2 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g' (Finset.image\u2082.{u1, u6, u4} \u03b1 \u03b3 \u03b4' (fun (a : \u03b4') (b : \u03b4') => _inst_6 a b) f' s u) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b4 : Type.{u4}} {\u03b4' : Type.{u1}} {\u03b5 : Type.{u5}} [_inst_5 : DecidableEq.{succ u4} \u03b4] [_inst_6 : DecidableEq.{succ u1} \u03b4'] [_inst_7 : DecidableEq.{succ u5} \u03b5] {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u6}} {u : Finset.{u6} \u03b3} {f : \u03b4 -> \u03b3 -> \u03b5} {g : \u03b1 -> \u03b2 -> \u03b4} {f' : \u03b1 -> \u03b3 -> \u03b4'} {g' : \u03b4' -> \u03b2 -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u5} \u03b5 (f (g a b) c) (g' (f' a c) b)) -> (Eq.{succ u5} (Finset.{u5} \u03b5) (Finset.image\u2082.{u4, u6, u5} \u03b4 \u03b3 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f (Finset.image\u2082.{u3, u2, u4} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g s t) u) (Finset.image\u2082.{u1, u2, u5} \u03b4' \u03b2 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g' (Finset.image\u2082.{u3, u6, u1} \u03b1 \u03b3 \u03b4' (fun (a : \u03b4') (b : \u03b4') => _inst_6 a b) f' s u) t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_right_comm Finset.image\u2082_right_comm\u2093'. -/\ntheorem image\u2082_right_comm {\u03b3 : Type _} {u : Finset \u03b3} {f : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4}\n    {f' : \u03b1 \u2192 \u03b3 \u2192 \u03b4'} {g' : \u03b4' \u2192 \u03b2 \u2192 \u03b5} (h_right_comm : \u2200 a b c, f (g a b) c = g' (f' a c) b) :\n    image\u2082 f (image\u2082 g s t) u = image\u2082 g' (image\u2082 f' s u) t :=\n  coe_injective <| by\n    push_cast\n    exact image2_right_comm h_right_comm\n#align finset.image\u2082_right_comm Finset.image\u2082_right_comm\n\n/- warning: finset.image\u2082_image\u2082_image\u2082_comm -> Finset.image\u2082_image\u2082_image\u2082_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b5 : Type.{u3}} {\u03b5' : Type.{u4}} {\u03b6 : Type.{u5}} {\u03b6' : Type.{u6}} {\u03bd : Type.{u7}} [_inst_7 : DecidableEq.{succ u3} \u03b5] [_inst_8 : DecidableEq.{succ u4} \u03b5'] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u8}} {\u03b4 : Type.{u9}} {u : Finset.{u8} \u03b3} {v : Finset.{u9} \u03b4} [_inst_9 : DecidableEq.{succ u5} \u03b6] [_inst_10 : DecidableEq.{succ u6} \u03b6'] [_inst_11 : DecidableEq.{succ u7} \u03bd] {f : \u03b5 -> \u03b6 -> \u03bd} {g : \u03b1 -> \u03b2 -> \u03b5} {h : \u03b3 -> \u03b4 -> \u03b6} {f' : \u03b5' -> \u03b6' -> \u03bd} {g' : \u03b1 -> \u03b3 -> \u03b5'} {h' : \u03b2 -> \u03b4 -> \u03b6'}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3) (d : \u03b4), Eq.{succ u7} \u03bd (f (g a b) (h c d)) (f' (g' a c) (h' b d))) -> (Eq.{succ u7} (Finset.{u7} \u03bd) (Finset.image\u2082.{u3, u5, u7} \u03b5 \u03b6 \u03bd (fun (a : \u03bd) (b : \u03bd) => _inst_11 a b) f (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g s t) (Finset.image\u2082.{u8, u9, u5} \u03b3 \u03b4 \u03b6 (fun (a : \u03b6) (b : \u03b6) => _inst_9 a b) h u v)) (Finset.image\u2082.{u4, u6, u7} \u03b5' \u03b6' \u03bd (fun (a : \u03bd) (b : \u03bd) => _inst_11 a b) f' (Finset.image\u2082.{u1, u8, u4} \u03b1 \u03b3 \u03b5' (fun (a : \u03b5') (b : \u03b5') => _inst_8 a b) g' s u) (Finset.image\u2082.{u2, u9, u6} \u03b2 \u03b4 \u03b6' (fun (a : \u03b6') (b : \u03b6') => _inst_10 a b) h' t v)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b5 : Type.{u4}} {\u03b5' : Type.{u1}} {\u03b6 : Type.{u7}} {\u03b6' : Type.{u6}} {\u03bd : Type.{u5}} [_inst_7 : DecidableEq.{succ u4} \u03b5] [_inst_8 : DecidableEq.{succ u1} \u03b5'] {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u9}} {\u03b4 : Type.{u8}} {u : Finset.{u9} \u03b3} {v : Finset.{u8} \u03b4} [_inst_9 : DecidableEq.{succ u7} \u03b6] [_inst_10 : DecidableEq.{succ u6} \u03b6'] [_inst_11 : DecidableEq.{succ u5} \u03bd] {f : \u03b5 -> \u03b6 -> \u03bd} {g : \u03b1 -> \u03b2 -> \u03b5} {h : \u03b3 -> \u03b4 -> \u03b6} {f' : \u03b5' -> \u03b6' -> \u03bd} {g' : \u03b1 -> \u03b3 -> \u03b5'} {h' : \u03b2 -> \u03b4 -> \u03b6'}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3) (d : \u03b4), Eq.{succ u5} \u03bd (f (g a b) (h c d)) (f' (g' a c) (h' b d))) -> (Eq.{succ u5} (Finset.{u5} \u03bd) (Finset.image\u2082.{u4, u7, u5} \u03b5 \u03b6 \u03bd (fun (a : \u03bd) (b : \u03bd) => _inst_11 a b) f (Finset.image\u2082.{u3, u2, u4} \u03b1 \u03b2 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g s t) (Finset.image\u2082.{u9, u8, u7} \u03b3 \u03b4 \u03b6 (fun (a : \u03b6) (b : \u03b6) => _inst_9 a b) h u v)) (Finset.image\u2082.{u1, u6, u5} \u03b5' \u03b6' \u03bd (fun (a : \u03bd) (b : \u03bd) => _inst_11 a b) f' (Finset.image\u2082.{u3, u9, u1} \u03b1 \u03b3 \u03b5' (fun (a : \u03b5') (b : \u03b5') => _inst_8 a b) g' s u) (Finset.image\u2082.{u2, u8, u6} \u03b2 \u03b4 \u03b6' (fun (a : \u03b6') (b : \u03b6') => _inst_10 a b) h' t v)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_image\u2082_image\u2082_comm Finset.image\u2082_image\u2082_image\u2082_comm\u2093'. -/\ntheorem image\u2082_image\u2082_image\u2082_comm {\u03b3 \u03b4 : Type _} {u : Finset \u03b3} {v : Finset \u03b4} [DecidableEq \u03b6]\n    [DecidableEq \u03b6'] [DecidableEq \u03bd] {f : \u03b5 \u2192 \u03b6 \u2192 \u03bd} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b5} {h : \u03b3 \u2192 \u03b4 \u2192 \u03b6}\n    {f' : \u03b5' \u2192 \u03b6' \u2192 \u03bd} {g' : \u03b1 \u2192 \u03b3 \u2192 \u03b5'} {h' : \u03b2 \u2192 \u03b4 \u2192 \u03b6'}\n    (h_comm : \u2200 a b c d, f (g a b) (h c d) = f' (g' a c) (h' b d)) :\n    image\u2082 f (image\u2082 g s t) (image\u2082 h u v) = image\u2082 f' (image\u2082 g' s u) (image\u2082 h' t v) :=\n  coe_injective <| by\n    push_cast\n    exact image2_image2_image2_comm h_comm\n#align finset.image\u2082_image\u2082_image\u2082_comm Finset.image\u2082_image\u2082_image\u2082_comm\n\n/- warning: finset.image_image\u2082_distrib -> Finset.image_image\u2082_distrib is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u4}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_2 : DecidableEq.{succ u4} \u03b2'] [_inst_3 : DecidableEq.{succ u5} \u03b3] [_inst_5 : DecidableEq.{succ u6} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1' -> \u03b2' -> \u03b4} {g\u2081 : \u03b1 -> \u03b1'} {g\u2082 : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u6} \u03b4 (g (f a b)) (f' (g\u2081 a) (g\u2082 b))) -> (Eq.{succ u6} (Finset.{u6} \u03b4) (Finset.image.{u5, u6} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u1, u3, u5} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u2, u4, u6} \u03b1' \u03b2' \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' (Finset.image.{u1, u2} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g\u2081 s) (Finset.image.{u3, u4} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g\u2082 t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u1}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_2 : DecidableEq.{succ u1} \u03b2'] [_inst_3 : DecidableEq.{succ u5} \u03b3] [_inst_5 : DecidableEq.{succ u6} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u4} \u03b1} {t : Finset.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1' -> \u03b2' -> \u03b4} {g\u2081 : \u03b1 -> \u03b1'} {g\u2082 : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u6} \u03b4 (g (f a b)) (f' (g\u2081 a) (g\u2082 b))) -> (Eq.{succ u6} (Finset.{u6} \u03b4) (Finset.image.{u5, u6} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u4, u3, u5} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u2, u1, u6} \u03b1' \u03b2' \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' (Finset.image.{u4, u2} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g\u2081 s) (Finset.image.{u3, u1} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g\u2082 t)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082_distrib Finset.image_image\u2082_distrib\u2093'. -/\ntheorem image_image\u2082_distrib {g : \u03b3 \u2192 \u03b4} {f' : \u03b1' \u2192 \u03b2' \u2192 \u03b4} {g\u2081 : \u03b1 \u2192 \u03b1'} {g\u2082 : \u03b2 \u2192 \u03b2'}\n    (h_distrib : \u2200 a b, g (f a b) = f' (g\u2081 a) (g\u2082 b)) :\n    (image\u2082 f s t).image g = image\u2082 f' (s.image g\u2081) (t.image g\u2082) :=\n  coe_injective <| by\n    push_cast\n    exact image_image2_distrib h_distrib\n#align finset.image_image\u2082_distrib Finset.image_image\u2082_distrib\n\n/- warning: finset.image_image\u2082_distrib_left -> Finset.image_image\u2082_distrib_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1' -> \u03b2 -> \u03b4} {g' : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' (g' a) b)) -> (Eq.{succ u5} (Finset.{u5} \u03b4) (Finset.image.{u4, u5} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u1, u3, u4} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u2, u3, u5} \u03b1' \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' (Finset.image.{u1, u2} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g' s) t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b1' : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_1 : DecidableEq.{succ u1} \u03b1'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1' -> \u03b2 -> \u03b4} {g' : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' (g' a) b)) -> (Eq.{succ u5} (Finset.{u5} \u03b4) (Finset.image.{u4, u5} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u3, u2, u4} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u1, u2, u5} \u03b1' \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' (Finset.image.{u3, u1} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g' s) t))\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082_distrib_left Finset.image_image\u2082_distrib_left\u2093'. -/\n/-- Symmetric statement to `finset.image\u2082_image_left_comm`. -/\ntheorem image_image\u2082_distrib_left {g : \u03b3 \u2192 \u03b4} {f' : \u03b1' \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b1 \u2192 \u03b1'}\n    (h_distrib : \u2200 a b, g (f a b) = f' (g' a) b) :\n    (image\u2082 f s t).image g = image\u2082 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\u2082_distrib_left Finset.image_image\u2082_distrib_left\n\n/- warning: finset.image_image\u2082_distrib_right -> Finset.image_image\u2082_distrib_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_2 : DecidableEq.{succ u3} \u03b2'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1 -> \u03b2' -> \u03b4} {g' : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' a (g' b))) -> (Eq.{succ u5} (Finset.{u5} \u03b4) (Finset.image.{u4, u5} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u1, u3, u5} \u03b1 \u03b2' \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' s (Finset.image.{u2, u3} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g' t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u1}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_2 : DecidableEq.{succ u1} \u03b2'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b1 -> \u03b2' -> \u03b4} {g' : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' a (g' b))) -> (Eq.{succ u5} (Finset.{u5} \u03b4) (Finset.image.{u4, u5} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u3, u2, u4} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u3, u1, u5} \u03b1 \u03b2' \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' s (Finset.image.{u2, u1} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g' t)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082_distrib_right Finset.image_image\u2082_distrib_right\u2093'. -/\n/-- Symmetric statement to `finset.image_image\u2082_right_comm`. -/\ntheorem image_image\u2082_distrib_right {g : \u03b3 \u2192 \u03b4} {f' : \u03b1 \u2192 \u03b2' \u2192 \u03b4} {g' : \u03b2 \u2192 \u03b2'}\n    (h_distrib : \u2200 a b, g (f a b) = f' a (g' b)) :\n    (image\u2082 f s t).image g = image\u2082 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\u2082_distrib_right Finset.image_image\u2082_distrib_right\n\n/- warning: finset.image\u2082_image_left_comm -> Finset.image\u2082_image_left_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {f : \u03b1' -> \u03b2 -> \u03b3} {g : \u03b1 -> \u03b1'} {f' : \u03b1 -> \u03b2 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u4} \u03b3 (f (g a) b) (g' (f' a b))) -> (Eq.{succ u4} (Finset.{u4} \u03b3) (Finset.image\u2082.{u2, u3, u4} \u03b1' \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Finset.image.{u1, u2} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g s) t) (Finset.image.{u5, u4} \u03b4 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g' (Finset.image\u2082.{u1, u3, u5} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' s t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b1' : Type.{u4}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u1}} [_inst_1 : DecidableEq.{succ u4} \u03b1'] [_inst_3 : DecidableEq.{succ u5} \u03b3] [_inst_5 : DecidableEq.{succ u1} \u03b4] {s : Finset.{u2} \u03b1} {t : Finset.{u3} \u03b2} {f : \u03b1' -> \u03b2 -> \u03b3} {g : \u03b1 -> \u03b1'} {f' : \u03b1 -> \u03b2 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b3 (f (g a) b) (g' (f' a b))) -> (Eq.{succ u5} (Finset.{u5} \u03b3) (Finset.image\u2082.{u4, u3, u5} \u03b1' \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Finset.image.{u2, u4} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g s) t) (Finset.image.{u1, u5} \u03b4 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g' (Finset.image\u2082.{u2, u3, u1} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' s t)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_image_left_comm Finset.image\u2082_image_left_comm\u2093'. -/\n/-- Symmetric statement to `finset.image_image\u2082_distrib_left`. -/\ntheorem image\u2082_image_left_comm {f : \u03b1' \u2192 \u03b2 \u2192 \u03b3} {g : \u03b1 \u2192 \u03b1'} {f' : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_left_comm : \u2200 a b, f (g a) b = g' (f' a b)) :\n    image\u2082 f (s.image g) t = (image\u2082 f' s t).image g' :=\n  (image_image\u2082_distrib_left fun a b => (h_left_comm a b).symm).symm\n#align finset.image\u2082_image_left_comm Finset.image\u2082_image_left_comm\n\n/- warning: finset.image_image\u2082_right_comm -> Finset.image_image\u2082_right_comm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_2 : DecidableEq.{succ u3} \u03b2'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {f : \u03b1 -> \u03b2' -> \u03b3} {g : \u03b2 -> \u03b2'} {f' : \u03b1 -> \u03b2 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u4} \u03b3 (f a (g b)) (g' (f' a b))) -> (Eq.{succ u4} (Finset.{u4} \u03b3) (Finset.image\u2082.{u1, u3, u4} \u03b1 \u03b2' \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Finset.image.{u2, u3} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g t)) (Finset.image.{u5, u4} \u03b4 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g' (Finset.image\u2082.{u1, u2, u5} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' s t)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u1}} [_inst_2 : DecidableEq.{succ u3} \u03b2'] [_inst_3 : DecidableEq.{succ u5} \u03b3] [_inst_5 : DecidableEq.{succ u1} \u03b4] {s : Finset.{u4} \u03b1} {t : Finset.{u2} \u03b2} {f : \u03b1 -> \u03b2' -> \u03b3} {g : \u03b2 -> \u03b2'} {f' : \u03b1 -> \u03b2 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b3 (f a (g b)) (g' (f' a b))) -> (Eq.{succ u5} (Finset.{u5} \u03b3) (Finset.image\u2082.{u4, u3, u5} \u03b1 \u03b2' \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Finset.image.{u2, u3} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g t)) (Finset.image.{u1, u5} \u03b4 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g' (Finset.image\u2082.{u4, u2, u1} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' s t)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082_right_comm Finset.image_image\u2082_right_comm\u2093'. -/\n/-- Symmetric statement to `finset.image_image\u2082_distrib_right`. -/\ntheorem image_image\u2082_right_comm {f : \u03b1 \u2192 \u03b2' \u2192 \u03b3} {g : \u03b2 \u2192 \u03b2'} {f' : \u03b1 \u2192 \u03b2 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_right_comm : \u2200 a b, f a (g b) = g' (f' a b)) :\n    image\u2082 f s (t.image g) = (image\u2082 f' s t).image g' :=\n  (image_image\u2082_distrib_right fun a b => (h_right_comm a b).symm).symm\n#align finset.image_image\u2082_right_comm Finset.image_image\u2082_right_comm\n\n/- warning: finset.image\u2082_distrib_subset_left -> Finset.image\u2082_distrib_subset_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3' : Type.{u4}} {\u03b4 : Type.{u5}} {\u03b5 : Type.{u6}} [_inst_2 : DecidableEq.{succ u3} \u03b2'] [_inst_4 : DecidableEq.{succ u4} \u03b3'] [_inst_5 : DecidableEq.{succ u5} \u03b4] [_inst_7 : DecidableEq.{succ u6} \u03b5] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {\u03b3 : Type.{u7}} {u : Finset.{u7} \u03b3} {f : \u03b1 -> \u03b4 -> \u03b5} {g : \u03b2 -> \u03b3 -> \u03b4} {f\u2081 : \u03b1 -> \u03b2 -> \u03b2'} {f\u2082 : \u03b1 -> \u03b3 -> \u03b3'} {g' : \u03b2' -> \u03b3' -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u6} \u03b5 (f a (g b c)) (g' (f\u2081 a b) (f\u2082 a c))) -> (HasSubset.Subset.{u6} (Finset.{u6} \u03b5) (Finset.hasSubset.{u6} \u03b5) (Finset.image\u2082.{u1, u5, u6} \u03b1 \u03b4 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f s (Finset.image\u2082.{u2, u7, u5} \u03b2 \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g t u)) (Finset.image\u2082.{u3, u4, u6} \u03b2' \u03b3' \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g' (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) f\u2081 s t) (Finset.image\u2082.{u1, u7, u4} \u03b1 \u03b3 \u03b3' (fun (a : \u03b3') (b : \u03b3') => _inst_4 a b) f\u2082 s u)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u5}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u2}} {\u03b3' : Type.{u1}} {\u03b4 : Type.{u4}} {\u03b5 : Type.{u6}} [_inst_2 : DecidableEq.{succ u2} \u03b2'] [_inst_4 : DecidableEq.{succ u1} \u03b3'] [_inst_5 : DecidableEq.{succ u4} \u03b4] [_inst_7 : DecidableEq.{succ u6} \u03b5] {s : Finset.{u5} \u03b1} {t : Finset.{u3} \u03b2} {\u03b3 : Type.{u7}} {u : Finset.{u7} \u03b3} {f : \u03b1 -> \u03b4 -> \u03b5} {g : \u03b2 -> \u03b3 -> \u03b4} {f\u2081 : \u03b1 -> \u03b2 -> \u03b2'} {f\u2082 : \u03b1 -> \u03b3 -> \u03b3'} {g' : \u03b2' -> \u03b3' -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u6} \u03b5 (f a (g b c)) (g' (f\u2081 a b) (f\u2082 a c))) -> (HasSubset.Subset.{u6} (Finset.{u6} \u03b5) (Finset.instHasSubsetFinset.{u6} \u03b5) (Finset.image\u2082.{u5, u4, u6} \u03b1 \u03b4 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f s (Finset.image\u2082.{u3, u7, u4} \u03b2 \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g t u)) (Finset.image\u2082.{u2, u1, u6} \u03b2' \u03b3' \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g' (Finset.image\u2082.{u5, u3, u2} \u03b1 \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) f\u2081 s t) (Finset.image\u2082.{u5, u7, u1} \u03b1 \u03b3 \u03b3' (fun (a : \u03b3') (b : \u03b3') => _inst_4 a b) f\u2082 s u)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_distrib_subset_left Finset.image\u2082_distrib_subset_left\u2093'. -/\n/-- The other direction does not hold because of the `s`-`s` cross terms on the RHS. -/\ntheorem image\u2082_distrib_subset_left {\u03b3 : Type _} {u : Finset \u03b3} {f : \u03b1 \u2192 \u03b4 \u2192 \u03b5} {g : \u03b2 \u2192 \u03b3 \u2192 \u03b4}\n    {f\u2081 : \u03b1 \u2192 \u03b2 \u2192 \u03b2'} {f\u2082 : \u03b1 \u2192 \u03b3 \u2192 \u03b3'} {g' : \u03b2' \u2192 \u03b3' \u2192 \u03b5}\n    (h_distrib : \u2200 a b c, f a (g b c) = g' (f\u2081 a b) (f\u2082 a c)) :\n    image\u2082 f s (image\u2082 g t u) \u2286 image\u2082 g' (image\u2082 f\u2081 s t) (image\u2082 f\u2082 s u) :=\n  coe_subset.1 <| by\n    push_cast\n    exact Set.image2_distrib_subset_left h_distrib\n#align finset.image\u2082_distrib_subset_left Finset.image\u2082_distrib_subset_left\n\n/- warning: finset.image\u2082_distrib_subset_right -> Finset.image\u2082_distrib_subset_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u4}} {\u03b4 : Type.{u5}} {\u03b5 : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_2 : DecidableEq.{succ u4} \u03b2'] [_inst_5 : DecidableEq.{succ u5} \u03b4] [_inst_7 : DecidableEq.{succ u6} \u03b5] {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {\u03b3 : Type.{u7}} {u : Finset.{u7} \u03b3} {f : \u03b4 -> \u03b3 -> \u03b5} {g : \u03b1 -> \u03b2 -> \u03b4} {f\u2081 : \u03b1 -> \u03b3 -> \u03b1'} {f\u2082 : \u03b2 -> \u03b3 -> \u03b2'} {g' : \u03b1' -> \u03b2' -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u6} \u03b5 (f (g a b) c) (g' (f\u2081 a c) (f\u2082 b c))) -> (HasSubset.Subset.{u6} (Finset.{u6} \u03b5) (Finset.hasSubset.{u6} \u03b5) (Finset.image\u2082.{u5, u7, u6} \u03b4 \u03b3 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f (Finset.image\u2082.{u1, u3, u5} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g s t) u) (Finset.image\u2082.{u2, u4, u6} \u03b1' \u03b2' \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g' (Finset.image\u2082.{u1, u7, u2} \u03b1 \u03b3 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) f\u2081 s u) (Finset.image\u2082.{u3, u7, u4} \u03b2 \u03b3 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) f\u2082 t u)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u1}} {\u03b4 : Type.{u5}} {\u03b5 : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_2 : DecidableEq.{succ u1} \u03b2'] [_inst_5 : DecidableEq.{succ u5} \u03b4] [_inst_7 : DecidableEq.{succ u6} \u03b5] {s : Finset.{u4} \u03b1} {t : Finset.{u3} \u03b2} {\u03b3 : Type.{u7}} {u : Finset.{u7} \u03b3} {f : \u03b4 -> \u03b3 -> \u03b5} {g : \u03b1 -> \u03b2 -> \u03b4} {f\u2081 : \u03b1 -> \u03b3 -> \u03b1'} {f\u2082 : \u03b2 -> \u03b3 -> \u03b2'} {g' : \u03b1' -> \u03b2' -> \u03b5}, (forall (a : \u03b1) (b : \u03b2) (c : \u03b3), Eq.{succ u6} \u03b5 (f (g a b) c) (g' (f\u2081 a c) (f\u2082 b c))) -> (HasSubset.Subset.{u6} (Finset.{u6} \u03b5) (Finset.instHasSubsetFinset.{u6} \u03b5) (Finset.image\u2082.{u5, u7, u6} \u03b4 \u03b3 \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) f (Finset.image\u2082.{u4, u3, u5} \u03b1 \u03b2 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g s t) u) (Finset.image\u2082.{u2, u1, u6} \u03b1' \u03b2' \u03b5 (fun (a : \u03b5) (b : \u03b5) => _inst_7 a b) g' (Finset.image\u2082.{u4, u7, u2} \u03b1 \u03b3 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) f\u2081 s u) (Finset.image\u2082.{u3, u7, u1} \u03b2 \u03b3 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) f\u2082 t u)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_distrib_subset_right Finset.image\u2082_distrib_subset_right\u2093'. -/\n/-- The other direction does not hold because of the `u`-`u` cross terms on the RHS. -/\ntheorem image\u2082_distrib_subset_right {\u03b3 : Type _} {u : Finset \u03b3} {f : \u03b4 \u2192 \u03b3 \u2192 \u03b5} {g : \u03b1 \u2192 \u03b2 \u2192 \u03b4}\n    {f\u2081 : \u03b1 \u2192 \u03b3 \u2192 \u03b1'} {f\u2082 : \u03b2 \u2192 \u03b3 \u2192 \u03b2'} {g' : \u03b1' \u2192 \u03b2' \u2192 \u03b5}\n    (h_distrib : \u2200 a b c, f (g a b) c = g' (f\u2081 a c) (f\u2082 b c)) :\n    image\u2082 f (image\u2082 g s t) u \u2286 image\u2082 g' (image\u2082 f\u2081 s u) (image\u2082 f\u2082 t u) :=\n  coe_subset.1 <| by\n    push_cast\n    exact Set.image2_distrib_subset_right h_distrib\n#align finset.image\u2082_distrib_subset_right Finset.image\u2082_distrib_subset_right\n\n/- warning: finset.image_image\u2082_antidistrib -> Finset.image_image\u2082_antidistrib is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u4}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u6}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_2 : DecidableEq.{succ u4} \u03b2'] [_inst_3 : DecidableEq.{succ u5} \u03b3] [_inst_5 : DecidableEq.{succ u6} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2' -> \u03b1' -> \u03b4} {g\u2081 : \u03b2 -> \u03b2'} {g\u2082 : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u6} \u03b4 (g (f a b)) (f' (g\u2081 b) (g\u2082 a))) -> (Eq.{succ u6} (Finset.{u6} \u03b4) (Finset.image.{u5, u6} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u1, u3, u5} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u4, u2, u6} \u03b2' \u03b1' \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' (Finset.image.{u3, u4} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g\u2081 t) (Finset.image.{u1, u2} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g\u2082 s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b1' : Type.{u1}} {\u03b2 : Type.{u3}} {\u03b2' : Type.{u2}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u6}} [_inst_1 : DecidableEq.{succ u1} \u03b1'] [_inst_2 : DecidableEq.{succ u2} \u03b2'] [_inst_3 : DecidableEq.{succ u5} \u03b3] [_inst_5 : DecidableEq.{succ u6} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u4} \u03b1} {t : Finset.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2' -> \u03b1' -> \u03b4} {g\u2081 : \u03b2 -> \u03b2'} {g\u2082 : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u6} \u03b4 (g (f a b)) (f' (g\u2081 b) (g\u2082 a))) -> (Eq.{succ u6} (Finset.{u6} \u03b4) (Finset.image.{u5, u6} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u4, u3, u5} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u2, u1, u6} \u03b2' \u03b1' \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' (Finset.image.{u3, u2} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g\u2081 t) (Finset.image.{u4, u1} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g\u2082 s)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082_antidistrib Finset.image_image\u2082_antidistrib\u2093'. -/\ntheorem image_image\u2082_antidistrib {g : \u03b3 \u2192 \u03b4} {f' : \u03b2' \u2192 \u03b1' \u2192 \u03b4} {g\u2081 : \u03b2 \u2192 \u03b2'} {g\u2082 : \u03b1 \u2192 \u03b1'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' (g\u2081 b) (g\u2082 a)) :\n    (image\u2082 f s t).image g = image\u2082 f' (t.image g\u2081) (s.image g\u2082) :=\n  by\n  rw [image\u2082_swap f]\n  exact image_image\u2082_distrib fun _ _ => h_antidistrib _ _\n#align finset.image_image\u2082_antidistrib Finset.image_image\u2082_antidistrib\n\n/- warning: finset.image_image\u2082_antidistrib_left -> Finset.image_image\u2082_antidistrib_left is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_2 : DecidableEq.{succ u3} \u03b2'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2' -> \u03b1 -> \u03b4} {g' : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' (g' b) a)) -> (Eq.{succ u5} (Finset.{u5} \u03b4) (Finset.image.{u4, u5} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u1, u2, u4} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u3, u1, u5} \u03b2' \u03b1 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' (Finset.image.{u2, u3} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g' t) s))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u1}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_2 : DecidableEq.{succ u1} \u03b2'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2' -> \u03b1 -> \u03b4} {g' : \u03b2 -> \u03b2'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' (g' b) a)) -> (Eq.{succ u5} (Finset.{u5} \u03b4) (Finset.image.{u4, u5} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u3, u2, u4} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u1, u3, u5} \u03b2' \u03b1 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' (Finset.image.{u2, u1} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g' t) s))\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082_antidistrib_left Finset.image_image\u2082_antidistrib_left\u2093'. -/\n/-- Symmetric statement to `finset.image\u2082_image_left_anticomm`. -/\ntheorem image_image\u2082_antidistrib_left {g : \u03b3 \u2192 \u03b4} {f' : \u03b2' \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b2 \u2192 \u03b2'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' (g' b) a) :\n    (image\u2082 f s t).image g = image\u2082 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\u2082_antidistrib_left Finset.image_image\u2082_antidistrib_left\n\n/- warning: finset.image_image\u2082_antidistrib_right -> Finset.image_image\u2082_antidistrib_right is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2 -> \u03b1' -> \u03b4} {g' : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' b (g' a))) -> (Eq.{succ u5} (Finset.{u5} \u03b4) (Finset.image.{u4, u5} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u1, u3, u4} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u3, u2, u5} \u03b2 \u03b1' \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' t (Finset.image.{u1, u2} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g' s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b1' : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_1 : DecidableEq.{succ u1} \u03b1'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {f : \u03b1 -> \u03b2 -> \u03b3} {s : Finset.{u3} \u03b1} {t : Finset.{u2} \u03b2} {g : \u03b3 -> \u03b4} {f' : \u03b2 -> \u03b1' -> \u03b4} {g' : \u03b1 -> \u03b1'}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b4 (g (f a b)) (f' b (g' a))) -> (Eq.{succ u5} (Finset.{u5} \u03b4) (Finset.image.{u4, u5} \u03b3 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) g (Finset.image\u2082.{u3, u2, u4} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s t)) (Finset.image\u2082.{u2, u1, u5} \u03b2 \u03b1' \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' t (Finset.image.{u3, u1} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g' s)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082_antidistrib_right Finset.image_image\u2082_antidistrib_right\u2093'. -/\n/-- Symmetric statement to `finset.image_image\u2082_right_anticomm`. -/\ntheorem image_image\u2082_antidistrib_right {g : \u03b3 \u2192 \u03b4} {f' : \u03b2 \u2192 \u03b1' \u2192 \u03b4} {g' : \u03b1 \u2192 \u03b1'}\n    (h_antidistrib : \u2200 a b, g (f a b) = f' b (g' a)) :\n    (image\u2082 f s t).image g = image\u2082 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\u2082_antidistrib_right Finset.image_image\u2082_antidistrib_right\n\n/- warning: finset.image\u2082_image_left_anticomm -> Finset.image\u2082_image_left_anticomm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b1' : Type.{u2}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_1 : DecidableEq.{succ u2} \u03b1'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {s : Finset.{u1} \u03b1} {t : Finset.{u3} \u03b2} {f : \u03b1' -> \u03b2 -> \u03b3} {g : \u03b1 -> \u03b1'} {f' : \u03b2 -> \u03b1 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u4} \u03b3 (f (g a) b) (g' (f' b a))) -> (Eq.{succ u4} (Finset.{u4} \u03b3) (Finset.image\u2082.{u2, u3, u4} \u03b1' \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Finset.image.{u1, u2} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g s) t) (Finset.image.{u5, u4} \u03b4 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g' (Finset.image\u2082.{u3, u1, u5} \u03b2 \u03b1 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' t s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b1' : Type.{u4}} {\u03b2 : Type.{u3}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u1}} [_inst_1 : DecidableEq.{succ u4} \u03b1'] [_inst_3 : DecidableEq.{succ u5} \u03b3] [_inst_5 : DecidableEq.{succ u1} \u03b4] {s : Finset.{u2} \u03b1} {t : Finset.{u3} \u03b2} {f : \u03b1' -> \u03b2 -> \u03b3} {g : \u03b1 -> \u03b1'} {f' : \u03b2 -> \u03b1 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b3 (f (g a) b) (g' (f' b a))) -> (Eq.{succ u5} (Finset.{u5} \u03b3) (Finset.image\u2082.{u4, u3, u5} \u03b1' \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f (Finset.image.{u2, u4} \u03b1 \u03b1' (fun (a : \u03b1') (b : \u03b1') => _inst_1 a b) g s) t) (Finset.image.{u1, u5} \u03b4 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g' (Finset.image\u2082.{u3, u2, u1} \u03b2 \u03b1 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' t s)))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_image_left_anticomm Finset.image\u2082_image_left_anticomm\u2093'. -/\n/-- Symmetric statement to `finset.image_image\u2082_antidistrib_left`. -/\ntheorem image\u2082_image_left_anticomm {f : \u03b1' \u2192 \u03b2 \u2192 \u03b3} {g : \u03b1 \u2192 \u03b1'} {f' : \u03b2 \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_left_anticomm : \u2200 a b, f (g a) b = g' (f' b a)) :\n    image\u2082 f (s.image g) t = (image\u2082 f' t s).image g' :=\n  (image_image\u2082_antidistrib_left fun a b => (h_left_anticomm b a).symm).symm\n#align finset.image\u2082_image_left_anticomm Finset.image\u2082_image_left_anticomm\n\n/- warning: finset.image_image\u2082_right_anticomm -> Finset.image_image\u2082_right_anticomm is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u4}} {\u03b4 : Type.{u5}} [_inst_2 : DecidableEq.{succ u3} \u03b2'] [_inst_3 : DecidableEq.{succ u4} \u03b3] [_inst_5 : DecidableEq.{succ u5} \u03b4] {s : Finset.{u1} \u03b1} {t : Finset.{u2} \u03b2} {f : \u03b1 -> \u03b2' -> \u03b3} {g : \u03b2 -> \u03b2'} {f' : \u03b2 -> \u03b1 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u4} \u03b3 (f a (g b)) (g' (f' b a))) -> (Eq.{succ u4} (Finset.{u4} \u03b3) (Finset.image\u2082.{u1, u3, u4} \u03b1 \u03b2' \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Finset.image.{u2, u3} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g t)) (Finset.image.{u5, u4} \u03b4 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g' (Finset.image\u2082.{u2, u1, u5} \u03b2 \u03b1 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' t s)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u4}} {\u03b2 : Type.{u2}} {\u03b2' : Type.{u3}} {\u03b3 : Type.{u5}} {\u03b4 : Type.{u1}} [_inst_2 : DecidableEq.{succ u3} \u03b2'] [_inst_3 : DecidableEq.{succ u5} \u03b3] [_inst_5 : DecidableEq.{succ u1} \u03b4] {s : Finset.{u4} \u03b1} {t : Finset.{u2} \u03b2} {f : \u03b1 -> \u03b2' -> \u03b3} {g : \u03b2 -> \u03b2'} {f' : \u03b2 -> \u03b1 -> \u03b4} {g' : \u03b4 -> \u03b3}, (forall (a : \u03b1) (b : \u03b2), Eq.{succ u5} \u03b3 (f a (g b)) (g' (f' b a))) -> (Eq.{succ u5} (Finset.{u5} \u03b3) (Finset.image\u2082.{u4, u3, u5} \u03b1 \u03b2' \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) f s (Finset.image.{u2, u3} \u03b2 \u03b2' (fun (a : \u03b2') (b : \u03b2') => _inst_2 a b) g t)) (Finset.image.{u1, u5} \u03b4 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_3 a b) g' (Finset.image\u2082.{u2, u4, u1} \u03b2 \u03b1 \u03b4 (fun (a : \u03b4) (b : \u03b4) => _inst_5 a b) f' t s)))\nCase conversion may be inaccurate. Consider using '#align finset.image_image\u2082_right_anticomm Finset.image_image\u2082_right_anticomm\u2093'. -/\n/-- Symmetric statement to `finset.image_image\u2082_antidistrib_right`. -/\ntheorem image_image\u2082_right_anticomm {f : \u03b1 \u2192 \u03b2' \u2192 \u03b3} {g : \u03b2 \u2192 \u03b2'} {f' : \u03b2 \u2192 \u03b1 \u2192 \u03b4} {g' : \u03b4 \u2192 \u03b3}\n    (h_right_anticomm : \u2200 a b, f a (g b) = g' (f' b a)) :\n    image\u2082 f s (t.image g) = (image\u2082 f' t s).image g' :=\n  (image_image\u2082_antidistrib_right fun a b => (h_right_anticomm b a).symm).symm\n#align finset.image_image\u2082_right_anticomm Finset.image_image\u2082_right_anticomm\n\n#print Finset.image\u2082_left_identity /-\n/-- If `a` is a left identity for `f : \u03b1 \u2192 \u03b2 \u2192 \u03b2`, then `{a}` is a left identity for\n`finset.image\u2082 f`. -/\ntheorem image\u2082_left_identity {f : \u03b1 \u2192 \u03b3 \u2192 \u03b3} {a : \u03b1} (h : \u2200 b, f a b = b) (t : Finset \u03b3) :\n    image\u2082 f {a} t = t :=\n  coe_injective <| by rw [coe_image\u2082, coe_singleton, Set.image2_left_identity h]\n#align finset.image\u2082_left_identity Finset.image\u2082_left_identity\n-/\n\n#print Finset.image\u2082_right_identity /-\n/-- If `b` is a right identity for `f : \u03b1 \u2192 \u03b2 \u2192 \u03b1`, then `{b}` is a right identity for\n`finset.image\u2082 f`. -/\ntheorem image\u2082_right_identity {f : \u03b3 \u2192 \u03b2 \u2192 \u03b3} {b : \u03b2} (h : \u2200 a, f a b = a) (s : Finset \u03b3) :\n    image\u2082 f s {b} = s := by rw [image\u2082_singleton_right, funext h, image_id']\n#align finset.image\u2082_right_identity Finset.image\u2082_right_identity\n-/\n\nvariable [DecidableEq \u03b1] [DecidableEq \u03b2]\n\n/- warning: finset.image\u2082_inter_union_subset -> Finset.image\u2082_inter_union_subset is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_9 : DecidableEq.{succ u1} \u03b1] [_inst_10 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b1 -> \u03b2} {s : Finset.{u1} \u03b1} {t : Finset.{u1} \u03b1}, (forall (a : \u03b1) (b : \u03b1), Eq.{succ u2} \u03b2 (f a b) (f b a)) -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b2) (Finset.hasSubset.{u2} \u03b2) (Finset.image\u2082.{u1, u1, u2} \u03b1 \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) f (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s t) (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s t)) (Finset.image\u2082.{u1, u1, u2} \u03b1 \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) f s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_9 : DecidableEq.{succ u2} \u03b1] [_inst_10 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b1 -> \u03b2} {s : Finset.{u2} \u03b1} {t : Finset.{u2} \u03b1}, (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b2 (f a b) (f b a)) -> (HasSubset.Subset.{u1} (Finset.{u1} \u03b2) (Finset.instHasSubsetFinset.{u1} \u03b2) (Finset.image\u2082.{u2, u2, u1} \u03b1 \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) f (Inter.inter.{u2} (Finset.{u2} \u03b1) (Finset.instInterFinset.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s t) (Union.union.{u2} (Finset.{u2} \u03b1) (Finset.instUnionFinset.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s t)) (Finset.image\u2082.{u2, u2, u1} \u03b1 \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_inter_union_subset Finset.image\u2082_inter_union_subset\u2093'. -/\ntheorem image\u2082_inter_union_subset {f : \u03b1 \u2192 \u03b1 \u2192 \u03b2} {s t : Finset \u03b1} (hf : \u2200 a b, f a b = f b a) :\n    image\u2082 f (s \u2229 t) (s \u222a t) \u2286 image\u2082 f s t :=\n  coe_subset.1 <| by\n    push_cast\n    exact image2_inter_union_subset hf\n#align finset.image\u2082_inter_union_subset Finset.image\u2082_inter_union_subset\n\n/- warning: finset.image\u2082_union_inter_subset -> Finset.image\u2082_union_inter_subset is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_9 : DecidableEq.{succ u1} \u03b1] [_inst_10 : DecidableEq.{succ u2} \u03b2] {f : \u03b1 -> \u03b1 -> \u03b2} {s : Finset.{u1} \u03b1} {t : Finset.{u1} \u03b1}, (forall (a : \u03b1) (b : \u03b1), Eq.{succ u2} \u03b2 (f a b) (f b a)) -> (HasSubset.Subset.{u2} (Finset.{u2} \u03b2) (Finset.hasSubset.{u2} \u03b2) (Finset.image\u2082.{u1, u1, u2} \u03b1 \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) f (Union.union.{u1} (Finset.{u1} \u03b1) (Finset.hasUnion.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s t) (Inter.inter.{u1} (Finset.{u1} \u03b1) (Finset.hasInter.{u1} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s t)) (Finset.image\u2082.{u1, u1, u2} \u03b1 \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) f s t))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_9 : DecidableEq.{succ u2} \u03b1] [_inst_10 : DecidableEq.{succ u1} \u03b2] {f : \u03b1 -> \u03b1 -> \u03b2} {s : Finset.{u2} \u03b1} {t : Finset.{u2} \u03b1}, (forall (a : \u03b1) (b : \u03b1), Eq.{succ u1} \u03b2 (f a b) (f b a)) -> (HasSubset.Subset.{u1} (Finset.{u1} \u03b2) (Finset.instHasSubsetFinset.{u1} \u03b2) (Finset.image\u2082.{u2, u2, u1} \u03b1 \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) f (Union.union.{u2} (Finset.{u2} \u03b1) (Finset.instUnionFinset.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s t) (Inter.inter.{u2} (Finset.{u2} \u03b1) (Finset.instInterFinset.{u2} \u03b1 (fun (a : \u03b1) (b : \u03b1) => _inst_9 a b)) s t)) (Finset.image\u2082.{u2, u2, u1} \u03b1 \u03b1 \u03b2 (fun (a : \u03b2) (b : \u03b2) => _inst_10 a b) f s t))\nCase conversion may be inaccurate. Consider using '#align finset.image\u2082_union_inter_subset Finset.image\u2082_union_inter_subset\u2093'. -/\ntheorem image\u2082_union_inter_subset {f : \u03b1 \u2192 \u03b1 \u2192 \u03b2} {s t : Finset \u03b1} (hf : \u2200 a b, f a b = f b a) :\n    image\u2082 f (s \u222a t) (s \u2229 t) \u2286 image\u2082 f s t :=\n  coe_subset.1 <| by\n    push_cast\n    exact image2_union_inter_subset hf\n#align finset.image\u2082_union_inter_subset Finset.image\u2082_union_inter_subset\n\nend Finset\n\nnamespace Set\n\nvariable [DecidableEq \u03b3] {s : Set \u03b1} {t : Set \u03b2}\n\n/- warning: set.to_finset_image2 -> Set.toFinset_image2 is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : DecidableEq.{succ u3} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Set.{u1} \u03b1) (t : Set.{u2} \u03b2) [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} \u03b1) Type.{u1} (Set.hasCoeToSort.{u1} \u03b1) s)] [_inst_3 : Fintype.{u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} \u03b2) Type.{u2} (Set.hasCoeToSort.{u2} \u03b2) t)] [_inst_4 : Fintype.{u3} (coeSort.{succ u3, succ (succ u3)} (Set.{u3} \u03b3) Type.{u3} (Set.hasCoeToSort.{u3} \u03b3) (Set.image2.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f s t))], Eq.{succ u3} (Finset.{u3} \u03b3) (Set.toFinset.{u3} \u03b3 (Set.image2.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f s t) _inst_4) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) f (Set.toFinset.{u1} \u03b1 s _inst_2) (Set.toFinset.{u2} \u03b2 t _inst_3))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b3] (f : \u03b1 -> \u03b2 -> \u03b3) (s : Set.{u3} \u03b1) (t : Set.{u2} \u03b2) [_inst_2 : Fintype.{u3} (Set.Elem.{u3} \u03b1 s)] [_inst_3 : Fintype.{u2} (Set.Elem.{u2} \u03b2 t)] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} \u03b3 (Set.image2.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f s t))], Eq.{succ u1} (Finset.{u1} \u03b3) (Set.toFinset.{u1} \u03b3 (Set.image2.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f s t) _inst_4) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) f (Set.toFinset.{u3} \u03b1 s _inst_2) (Set.toFinset.{u2} \u03b2 t _inst_3))\nCase conversion may be inaccurate. Consider using '#align set.to_finset_image2 Set.toFinset_image2\u2093'. -/\n@[simp]\ntheorem toFinset_image2 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : Set \u03b1) (t : Set \u03b2) [Fintype s] [Fintype t]\n    [Fintype (image2 f s t)] : (image2 f s t).toFinset = Finset.image\u2082 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u3}} [_inst_1 : DecidableEq.{succ u3} \u03b3] {s : Set.{u1} \u03b1} {t : Set.{u2} \u03b2} (f : \u03b1 -> \u03b2 -> \u03b3) (hs : Set.Finite.{u1} \u03b1 s) (ht : Set.Finite.{u2} \u03b2 t) (hf : optParam.{0} (Set.Finite.{u3} \u03b3 (Set.image2.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f s t)) (Set.Finite.image2.{u1, u2, u3} \u03b1 \u03b2 \u03b3 s t f hs ht)), Eq.{succ u3} (Finset.{u3} \u03b3) (Set.Finite.toFinset.{u3} \u03b3 (Set.image2.{u1, u2, u3} \u03b1 \u03b2 \u03b3 f s t) hf) (Finset.image\u2082.{u1, u2, u3} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) f (Set.Finite.toFinset.{u1} \u03b1 s hs) (Set.Finite.toFinset.{u2} \u03b2 t ht))\nbut is expected to have type\n  forall {\u03b1 : Type.{u3}} {\u03b2 : Type.{u2}} {\u03b3 : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} \u03b3] {s : Set.{u3} \u03b1} {t : Set.{u2} \u03b2} (f : \u03b1 -> \u03b2 -> \u03b3) (hs : Set.Finite.{u3} \u03b1 s) (ht : Set.Finite.{u2} \u03b2 t) (hf : optParam.{0} (Set.Finite.{u1} \u03b3 (Set.image2.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f s t)) (Set.Finite.image2.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f s t hs ht)), Eq.{succ u1} (Finset.{u1} \u03b3) (Set.Finite.toFinset.{u1} \u03b3 (Set.image2.{u3, u2, u1} \u03b1 \u03b2 \u03b3 f s t) hf) (Finset.image\u2082.{u3, u2, u1} \u03b1 \u03b2 \u03b3 (fun (a : \u03b3) (b : \u03b3) => _inst_1 a b) f (Set.Finite.toFinset.{u3} \u03b1 s hs) (Set.Finite.toFinset.{u2} \u03b2 t ht))\nCase conversion may be inaccurate. Consider using '#align set.finite.to_finset_image2 Set.Finite.toFinset_image2\u2093'. -/\ntheorem Finite.toFinset_image2 (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (hs : s.Finite) (ht : t.Finite)\n    (hf := hs.image2 f ht) : hf.toFinset = Finset.image\u2082 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 \u03b1`: free magma (structure with binary operation without any axioms) over alphabet `\u03b1`,\n  defined inductively, with traversable instance and decidable equality.\n* `magma.free_semigroup \u03b1`: free semigroup over magma `\u03b1`.\n* `free_semigroup \u03b1`: free semigroup over alphabet `\u03b1`, defined as a synonym for `\u03b1 \u00d7 list \u03b1`\n  (i.e. nonempty lists), with traversable instance and decidable equality.\n* `free_semigroup_free_magma \u03b1`: isomorphism between `magma.free_semigroup (free_magma \u03b1)` and\n  `free_semigroup \u03b1`.\n-/\n\n/-- Free magma over a given alphabet. -/\ninductive free_magma (\u03b1 : Type u) where\n| of : \u03b1 \u2192 free_magma \u03b1\n| mul : free_magma \u03b1 \u2192 free_magma \u03b1 \u2192 free_magma \u03b1\n\n/-- Free nonabelian additive magma over a given alphabet. -/\ninductive free_add_magma (\u03b1 : Type u) where\n| of : \u03b1 \u2192 free_add_magma \u03b1\n| add : free_add_magma \u03b1 \u2192 free_add_magma \u03b1 \u2192 free_add_magma \u03b1\n\nnamespace free_magma\n\n\nprotected instance Mathlib.free_add_magma.inhabited {\u03b1 : Type u} [Inhabited \u03b1] :\n    Inhabited (free_add_magma \u03b1) :=\n  { default := free_add_magma.of Inhabited.default }\n\nprotected instance Mathlib.free_add_magma.has_add {\u03b1 : Type u} : Add (free_add_magma \u03b1) :=\n  { add := free_add_magma.add }\n\n@[simp] theorem Mathlib.free_add_magma.add_eq {\u03b1 : Type u} (x : free_add_magma \u03b1)\n    (y : free_add_magma \u03b1) : 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' {\u03b1 : Type u} {C : free_add_magma \u03b1 \u2192 Sort l}\n    (x : free_add_magma \u03b1) (ih1 : (x : \u03b1) \u2192 C (free_add_magma.of x))\n    (ih2 : (x y : free_add_magma \u03b1) \u2192 C x \u2192 C y \u2192 C (x + y)) : C x :=\n  free_add_magma.rec_on x ih1 ih2\n\nend free_magma\n\n\n/-- Lifts a function `\u03b1 \u2192 \u03b2` to a magma homomorphism `free_magma \u03b1 \u2192 \u03b2` given a magma `\u03b2`. -/\ndef free_magma.lift {\u03b1 : Type u} {\u03b2 : Type v} [Mul \u03b2] (f : \u03b1 \u2192 \u03b2) : free_magma \u03b1 \u2192 \u03b2 := sorry\n\n/-- Lifts a function `\u03b1 \u2192 \u03b2` to an additive magma homomorphism `free_add_magma \u03b1 \u2192 \u03b2` given\nan additive magma `\u03b2`. -/\ndef free_add_magma.lift {\u03b1 : Type u} {\u03b2 : Type v} [Add \u03b2] (f : \u03b1 \u2192 \u03b2) : free_add_magma \u03b1 \u2192 \u03b2 :=\n  sorry\n\nnamespace free_magma\n\n\n@[simp] theorem Mathlib.free_add_magma.lift_of {\u03b1 : Type u} {\u03b2 : Type v} [Add \u03b2] (f : \u03b1 \u2192 \u03b2)\n    (x : \u03b1) : free_add_magma.lift f (free_add_magma.of x) = f x :=\n  rfl\n\n@[simp] theorem lift_mul {\u03b1 : Type u} {\u03b2 : Type v} [Mul \u03b2] (f : \u03b1 \u2192 \u03b2) (x : free_magma \u03b1)\n    (y : free_magma \u03b1) : lift f (x * y) = lift f x * lift f y :=\n  rfl\n\ntheorem lift_unique {\u03b1 : Type u} {\u03b2 : Type v} [Mul \u03b2] (f : free_magma \u03b1 \u2192 \u03b2)\n    (hf : \u2200 (x y : free_magma \u03b1), f (x * y) = f x * f y) : f = lift (f \u2218 of) :=\n  sorry\n\nend free_magma\n\n\n/-- The unique magma homomorphism `free_magma \u03b1 \u2192 free_magma \u03b2` that sends\neach `of x` to `of (f x)`. -/\ndef free_magma.map {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) : free_magma \u03b1 \u2192 free_magma \u03b2 := sorry\n\n/-- The unique additive magma homomorphism `free_add_magma \u03b1 \u2192 free_add_magma \u03b2` that sends\neach `of x` to `of (f x)`. -/\ndef free_add_magma.map {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) :\n    free_add_magma \u03b1 \u2192 free_add_magma \u03b2 :=\n  sorry\n\nnamespace free_magma\n\n\n@[simp] theorem Mathlib.free_add_magma.map_of {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (x : \u03b1) :\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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2)\n    (x : free_add_magma \u03b1) (y : free_add_magma \u03b1) :\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'' {\u03b1 : Type u} {C : free_add_magma \u03b1 \u2192 Sort l}\n    (x : free_add_magma \u03b1) (ih1 : (x : \u03b1) \u2192 C (pure x))\n    (ih2 : (x y : free_add_magma \u03b1) \u2192 C x \u2192 C y \u2192 C (x + y)) : C x :=\n  free_add_magma.rec_on' x ih1 ih2\n\n@[simp] theorem Mathlib.free_add_magma.map_pure {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) (x : \u03b1) :\n    f <$> pure x = pure (f x) :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.map_add' {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 \u03b2)\n    (x : free_add_magma \u03b1) (y : free_add_magma \u03b1) : f <$> (x + y) = f <$> x + f <$> y :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.pure_bind {\u03b1 : Type u} {\u03b2 : Type u}\n    (f : \u03b1 \u2192 free_add_magma \u03b2) (x : \u03b1) : pure x >>= f = f x :=\n  rfl\n\n@[simp] theorem mul_bind {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 free_magma \u03b2) (x : free_magma \u03b1)\n    (y : free_magma \u03b1) : x * y >>= f = (x >>= f) * (y >>= f) :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.pure_seq {\u03b1 : Type u} {\u03b2 : Type u} {f : \u03b1 \u2192 \u03b2}\n    {x : free_add_magma \u03b1} : pure f <*> x = f <$> x :=\n  rfl\n\n@[simp] theorem mul_seq {\u03b1 : Type u} {\u03b2 : Type u} {f : free_magma (\u03b1 \u2192 \u03b2)} {g : free_magma (\u03b1 \u2192 \u03b2)}\n    {x : free_magma \u03b1} : 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 \u2192 Type u} [Applicative m] {\u03b1 : Type u} {\u03b2 : Type u}\n    (F : \u03b1 \u2192 m \u03b2) : free_magma \u03b1 \u2192 m (free_magma \u03b2) :=\n  sorry\n\n/-- `free_add_magma` is traversable. -/\nprotected def free_add_magma.traverse {m : Type u \u2192 Type u} [Applicative m] {\u03b1 : Type u}\n    {\u03b2 : Type u} (F : \u03b1 \u2192 m \u03b2) : free_add_magma \u03b1 \u2192 m (free_add_magma \u03b2) :=\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 {\u03b1 : Type u} {\u03b2 : Type u} {m : Type u \u2192 Type u}\n    [Applicative m] (F : \u03b1 \u2192 m \u03b2) (x : \u03b1) : traverse F (pure x) = pure <$> F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.traverse_pure' {\u03b1 : Type u} {\u03b2 : Type u}\n    {m : Type u \u2192 Type u} [Applicative m] (F : \u03b1 \u2192 m \u03b2) :\n    traverse F \u2218 pure = fun (x : \u03b1) => pure <$> F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.traverse_add {\u03b1 : Type u} {\u03b2 : Type u} {m : Type u \u2192 Type u}\n    [Applicative m] (F : \u03b1 \u2192 m \u03b2) (x : free_add_magma \u03b1) (y : free_add_magma \u03b1) :\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' {\u03b1 : Type u} {\u03b2 : Type u} {m : Type u \u2192 Type u}\n    [Applicative m] (F : \u03b1 \u2192 m \u03b2) :\n    function.comp (traverse F) \u2218 Add.add =\n        fun (x y : free_add_magma \u03b1) => Add.add <$> traverse F x <*> traverse F y :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_magma.traverse_eq {\u03b1 : Type u} {\u03b2 : Type u} {m : Type u \u2192 Type u}\n    [Applicative m] (F : \u03b1 \u2192 m \u03b2) (x : free_add_magma \u03b1) :\n    free_add_magma.traverse F x = traverse F x :=\n  rfl\n\n@[simp] theorem mul_map_seq {\u03b1 : Type u} (x : free_magma \u03b1) (y : free_magma \u03b1) :\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 {\u03b1 : Type u} [has_repr \u03b1] : free_magma \u03b1 \u2192 string := sorry\n\n/-- Representation of an element of a free additive magma. -/\nprotected def free_add_magma.repr {\u03b1 : Type u} [has_repr \u03b1] : free_add_magma \u03b1 \u2192 string := sorry\n\nprotected instance free_add_magma.has_repr {\u03b1 : Type u} [has_repr \u03b1] :\n    has_repr (free_add_magma \u03b1) :=\n  has_repr.mk free_add_magma.repr\n\n/-- Length of an element of a free magma. -/\ndef free_magma.length {\u03b1 : Type u} : free_magma \u03b1 \u2192 \u2115 := sorry\n\n/-- Length of an element of a free additive magma. -/\ndef free_add_magma.length {\u03b1 : Type u} : free_add_magma \u03b1 \u2192 \u2115 := sorry\n\n/-- Associativity relations for a magma. -/\ninductive magma.free_semigroup.r (\u03b1 : Type u) [Mul \u03b1] : \u03b1 \u2192 \u03b1 \u2192 Prop where\n| intro : \u2200 (x y z : \u03b1), magma.free_semigroup.r \u03b1 (x * y * z) (x * (y * z))\n| left : \u2200 (w x y z : \u03b1), magma.free_semigroup.r \u03b1 (w * (x * y * z)) (w * (x * (y * z)))\n\n/-- Associativity relations for an additive magma. -/\ninductive add_magma.free_add_semigroup.r (\u03b1 : Type u) [Add \u03b1] : \u03b1 \u2192 \u03b1 \u2192 Prop where\n| intro : \u2200 (x y z : \u03b1), add_magma.free_add_semigroup.r \u03b1 (x + y + z) (x + (y + z))\n| left : \u2200 (w x y z : \u03b1), add_magma.free_add_semigroup.r \u03b1 (w + (x + y + z)) (w + (x + (y + z)))\n\nnamespace magma\n\n\n/-- Free semigroup over a magma. -/\ndef free_semigroup (\u03b1 : Type u) [Mul \u03b1] := Quot sorry\n\nnamespace free_semigroup\n\n\n/-- Embedding from magma to its free semigroup. -/\ndef Mathlib.add_magma.free_add_semigroup.of {\u03b1 : Type u} [Add \u03b1] :\n    \u03b1 \u2192 add_magma.free_add_semigroup \u03b1 :=\n  Quot.mk (add_magma.free_add_semigroup.r \u03b1)\n\nprotected instance Mathlib.add_magma.free_add_semigroup.inhabited {\u03b1 : Type u} [Add \u03b1]\n    [Inhabited \u03b1] : Inhabited (add_magma.free_add_semigroup \u03b1) :=\n  { default := add_magma.free_add_semigroup.of Inhabited.default }\n\nprotected theorem Mathlib.add_magma.free_add_semigroup.induction_on {\u03b1 : Type u} [Add \u03b1]\n    {C : add_magma.free_add_semigroup \u03b1 \u2192 Prop} (x : add_magma.free_add_semigroup \u03b1)\n    (ih : \u2200 (x : \u03b1), C (add_magma.free_add_semigroup.of x)) : C x :=\n  quot.induction_on x ih\n\ntheorem of_mul_assoc {\u03b1 : Type u} [Mul \u03b1] (x : \u03b1) (y : \u03b1) (z : \u03b1) :\n    of (x * y * z) = of (x * (y * z)) :=\n  quot.sound (r.intro x y z)\n\ntheorem of_mul_assoc_left {\u03b1 : Type u} [Mul \u03b1] (w : \u03b1) (x : \u03b1) (y : \u03b1) (z : \u03b1) :\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 {\u03b1 : Type u} [Mul \u03b1] (w : \u03b1) (x : \u03b1) (y : \u03b1) (z : \u03b1) :\n    of (w * x * y * z) = of (w * (x * y) * z) :=\n  sorry\n\nprotected instance semigroup {\u03b1 : Type u} [Mul \u03b1] : semigroup (free_semigroup \u03b1) :=\n  semigroup.mk\n    (fun (x y : free_semigroup \u03b1) =>\n      quot.lift_on x (fun (p : \u03b1) => quot.lift_on y (fun (q : \u03b1) => Quot.mk (r \u03b1) (p * q)) sorry)\n        sorry)\n    sorry\n\ntheorem Mathlib.add_magma.free_add_semigroup.of_add {\u03b1 : Type u} [Add \u03b1] (x : \u03b1) (y : \u03b1) :\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 `\u03b1 \u2192 \u03b2` to a semigroup homomorphism `magma.free_semigroup \u03b1 \u2192 \u03b2`\ngiven a semigroup `\u03b2`. -/\ndef lift {\u03b1 : Type u} [Mul \u03b1] {\u03b2 : Type v} [semigroup \u03b2] (f : \u03b1 \u2192 \u03b2)\n    (hf : \u2200 (x y : \u03b1), f (x * y) = f x * f y) : free_semigroup \u03b1 \u2192 \u03b2 :=\n  Quot.lift f sorry\n\n@[simp] theorem lift_of {\u03b1 : Type u} [Mul \u03b1] {\u03b2 : Type v} [semigroup \u03b2] (f : \u03b1 \u2192 \u03b2)\n    {hf : \u2200 (x y : \u03b1), f (x * y) = f x * f y} (x : \u03b1) : lift f hf (of x) = f x :=\n  rfl\n\n@[simp] theorem lift_mul {\u03b1 : Type u} [Mul \u03b1] {\u03b2 : Type v} [semigroup \u03b2] (f : \u03b1 \u2192 \u03b2)\n    {hf : \u2200 (x y : \u03b1), f (x * y) = f x * f y} (x : free_semigroup \u03b1) (y : free_semigroup \u03b1) :\n    lift f hf (x * y) = lift f hf x * lift f hf y :=\n  quot.induction_on x fun (p : \u03b1) => quot.induction_on y fun (q : \u03b1) => hf p q\n\ntheorem Mathlib.add_magma.free_add_semigroup.lift_unique {\u03b1 : Type u} [Add \u03b1] {\u03b2 : Type v}\n    [add_semigroup \u03b2] (f : add_magma.free_add_semigroup \u03b1 \u2192 \u03b2)\n    (hf : \u2200 (x y : add_magma.free_add_semigroup \u03b1), f (x + y) = f x + f y) :\n    f =\n        add_magma.free_add_semigroup.lift (f \u2218 add_magma.free_add_semigroup.of)\n          fun (p q : \u03b1) =>\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 \u03b1) => quot.induction_on x fun (p : \u03b1) => rfl\n\n/-- From a magma homomorphism `\u03b1 \u2192 \u03b2` to a semigroup homomorphism\n`magma.free_semigroup \u03b1 \u2192 magma.free_semigroup \u03b2`. -/\ndef Mathlib.add_magma.free_add_semigroup.map {\u03b1 : Type u} [Add \u03b1] {\u03b2 : Type v} [Add \u03b2] (f : \u03b1 \u2192 \u03b2)\n    (hf : \u2200 (x y : \u03b1), f (x + y) = f x + f y) :\n    add_magma.free_add_semigroup \u03b1 \u2192 add_magma.free_add_semigroup \u03b2 :=\n  add_magma.free_add_semigroup.lift (add_magma.free_add_semigroup.of \u2218 f) sorry\n\n@[simp] theorem Mathlib.add_magma.free_add_semigroup.map_of {\u03b1 : Type u} [Add \u03b1] {\u03b2 : Type v}\n    [Add \u03b2] (f : \u03b1 \u2192 \u03b2) {hf : \u2200 (x y : \u03b1), f (x + y) = f x + f y} (x : \u03b1) :\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 {\u03b1 : Type u} [Mul \u03b1] {\u03b2 : Type v} [Mul \u03b2] (f : \u03b1 \u2192 \u03b2)\n    {hf : \u2200 (x y : \u03b1), f (x * y) = f x * f y} (x : free_semigroup \u03b1) (y : free_semigroup \u03b1) :\n    map f hf (x * y) = map f hf x * map f hf y :=\n  lift_mul (of \u2218 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 (\u03b1 : Type u) := \u03b1 \u00d7 List \u03b1\n\nnamespace free_semigroup\n\n\nprotected instance semigroup {\u03b1 : Type u} : semigroup (free_semigroup \u03b1) :=\n  semigroup.mk\n    (fun (L1 L2 : free_semigroup \u03b1) => (prod.fst L1, prod.snd L1 ++ prod.fst L2 :: prod.snd L2))\n    sorry\n\n/-- The embedding `\u03b1 \u2192 free_semigroup \u03b1`. -/\ndef Mathlib.free_add_semigroup.of {\u03b1 : Type u} (x : \u03b1) : free_add_semigroup \u03b1 := (x, [])\n\nprotected instance Mathlib.free_add_semigroup.inhabited {\u03b1 : Type u} [Inhabited \u03b1] :\n    Inhabited (free_add_semigroup \u03b1) :=\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 {\u03b1 : Type u} {C : free_add_semigroup \u03b1 \u2192 Sort l}\n    (x : free_add_semigroup \u03b1) (ih1 : (x : \u03b1) \u2192 C (free_add_semigroup.of x))\n    (ih2 :\n      (x : \u03b1) \u2192\n        (y : free_add_semigroup \u03b1) \u2192\n          C (free_add_semigroup.of x) \u2192 C y \u2192 C (free_add_semigroup.of x + y)) :\n    C x :=\n  prod.rec_on x\n    fun (f : \u03b1) (s : List \u03b1) =>\n      list.rec_on s ih1\n        (fun (hd : \u03b1) (tl : List \u03b1) (ih : (_a : \u03b1) \u2192 C (_a, tl)) (f : \u03b1) =>\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' {\u03b1 : Type u} {\u03b2 : Type v} [semigroup \u03b2] (f : \u03b1 \u2192 \u03b2) : \u03b1 \u2192 List \u03b1 \u2192 \u03b2 :=\n  sorry\n\n/-- Auxiliary function for `free_semigroup.lift`. -/\ndef free_add_semigroup.lift' {\u03b1 : Type u} {\u03b2 : Type v} [add_semigroup \u03b2] (f : \u03b1 \u2192 \u03b2) :\n    \u03b1 \u2192 List \u03b1 \u2192 \u03b2 :=\n  sorry\n\nnamespace free_semigroup\n\n\n/-- Lifts a function `\u03b1 \u2192 \u03b2` to a semigroup homomorphism `free_semigroup \u03b1 \u2192 \u03b2` given\na semigroup `\u03b2`. -/\ndef lift {\u03b1 : Type u} {\u03b2 : Type v} [semigroup \u03b2] (f : \u03b1 \u2192 \u03b2) (x : free_semigroup \u03b1) : \u03b2 :=\n  lift' f (prod.fst x) (prod.snd x)\n\n@[simp] theorem lift_of {\u03b1 : Type u} {\u03b2 : Type v} [semigroup \u03b2] (f : \u03b1 \u2192 \u03b2) (x : \u03b1) :\n    lift f (of x) = f x :=\n  rfl\n\ntheorem lift_of_mul {\u03b1 : Type u} {\u03b2 : Type v} [semigroup \u03b2] (f : \u03b1 \u2192 \u03b2) (x : \u03b1)\n    (y : free_semigroup \u03b1) : lift f (of x * y) = f x * lift f y :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.lift_add {\u03b1 : Type u} {\u03b2 : Type v} [add_semigroup \u03b2]\n    (f : \u03b1 \u2192 \u03b2) (x : free_add_semigroup \u03b1) (y : free_add_semigroup \u03b1) :\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 {\u03b1 : Type u} {\u03b2 : Type v} [add_semigroup \u03b2]\n    (f : free_add_semigroup \u03b1 \u2192 \u03b2) (hf : \u2200 (x y : free_add_semigroup \u03b1), f (x + y) = f x + f y) :\n    f = free_add_semigroup.lift (f \u2218 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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) :\n    free_add_semigroup \u03b1 \u2192 free_add_semigroup \u03b2 :=\n  free_add_semigroup.lift (free_add_semigroup.of \u2218 f)\n\n@[simp] theorem Mathlib.free_add_semigroup.map_of {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (x : \u03b1) :\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 {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2)\n    (x : free_add_semigroup \u03b1) (y : free_add_semigroup \u03b1) :\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 \u2218 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' {\u03b1 : Type u} {C : free_semigroup \u03b1 \u2192 Sort l} (x : free_semigroup \u03b1)\n    (ih1 : (x : \u03b1) \u2192 C (pure x))\n    (ih2 : (x : \u03b1) \u2192 (y : free_semigroup \u03b1) \u2192 C (pure x) \u2192 C y \u2192 C (pure x * y)) : C x :=\n  free_semigroup.rec_on x ih1 ih2\n\n@[simp] theorem map_pure {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) (x : \u03b1) :\n    f <$> pure x = pure (f x) :=\n  rfl\n\n@[simp] theorem map_mul' {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 \u03b2) (x : free_semigroup \u03b1)\n    (y : free_semigroup \u03b1) : f <$> (x * y) = f <$> x * f <$> y :=\n  map_mul f x y\n\n@[simp] theorem pure_bind {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 free_semigroup \u03b2) (x : \u03b1) :\n    pure x >>= f = f x :=\n  rfl\n\n@[simp] theorem mul_bind {\u03b1 : Type u} {\u03b2 : Type u} (f : \u03b1 \u2192 free_semigroup \u03b2) (x : free_semigroup \u03b1)\n    (y : free_semigroup \u03b1) : x * y >>= f = (x >>= f) * (y >>= f) :=\n  lift_mul f x y\n\n@[simp] theorem Mathlib.free_add_semigroup.pure_seq {\u03b1 : Type u} {\u03b2 : Type u} {f : \u03b1 \u2192 \u03b2}\n    {x : free_add_semigroup \u03b1} : pure f <*> x = f <$> x :=\n  rfl\n\n@[simp] theorem mul_seq {\u03b1 : Type u} {\u03b2 : Type u} {f : free_semigroup (\u03b1 \u2192 \u03b2)}\n    {g : free_semigroup (\u03b1 \u2192 \u03b2)} {x : free_semigroup \u03b1} : f * g <*> x = (f <*> x) * (g <*> x) :=\n  mul_bind\n    (fun (_x : \u03b1 \u2192 \u03b2) =>\n      (fun (\u03b1 \u03b2 : Type u) (f : \u03b1 \u2192 \u03b2) (x : free_semigroup \u03b1) => lift (of \u2218 f) x) \u03b1 \u03b2 _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 \u2192 Type u} [Applicative m] {\u03b1 : Type u}\n    {\u03b2 : Type u} (F : \u03b1 \u2192 m \u03b2) (x : free_add_semigroup \u03b1) : m (free_add_semigroup \u03b2) :=\n  free_add_semigroup.rec_on' x (fun (x : \u03b1) => pure <$> F x)\n    fun (x : \u03b1) (y : free_add_semigroup \u03b1) (ihx ihy : m (free_add_semigroup \u03b2)) =>\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 {\u03b1 : Type u} {\u03b2 : Type u} {m : Type u \u2192 Type u} [Applicative m]\n    (F : \u03b1 \u2192 m \u03b2) (x : \u03b1) : traverse F (pure x) = pure <$> F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.traverse_pure' {\u03b1 : Type u} {\u03b2 : Type u}\n    {m : Type u \u2192 Type u} [Applicative m] (F : \u03b1 \u2192 m \u03b2) :\n    traverse F \u2218 pure = fun (x : \u03b1) => pure <$> F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.traverse_add {\u03b1 : Type u} {\u03b2 : Type u}\n    {m : Type u \u2192 Type u} [Applicative m] (F : \u03b1 \u2192 m \u03b2) [is_lawful_applicative m]\n    (x : free_add_semigroup \u03b1) (y : free_add_semigroup \u03b1) :\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' {\u03b1 : Type u} {\u03b2 : Type u}\n    {m : Type u \u2192 Type u} [Applicative m] (F : \u03b1 \u2192 m \u03b2) [is_lawful_applicative m] :\n    function.comp (traverse F) \u2218 Add.add =\n        fun (x y : free_add_semigroup \u03b1) => Add.add <$> traverse F x <*> traverse F y :=\n  funext\n    fun (x : free_add_semigroup \u03b1) =>\n      funext fun (y : free_add_semigroup \u03b1) => free_add_semigroup.traverse_add F x y\n\n@[simp] theorem Mathlib.free_add_semigroup.traverse_eq {\u03b1 : Type u} {\u03b2 : Type u}\n    {m : Type u \u2192 Type u} [Applicative m] (F : \u03b1 \u2192 m \u03b2) (x : free_add_semigroup \u03b1) :\n    free_add_semigroup.traverse F x = traverse F x :=\n  rfl\n\n@[simp] theorem Mathlib.free_add_semigroup.add_map_seq {\u03b1 : Type u} (x : free_add_semigroup \u03b1)\n    (y : free_add_semigroup \u03b1) : 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 {\u03b1 : Type u} [DecidableEq \u03b1] :\n    DecidableEq (free_add_semigroup \u03b1) :=\n  prod.decidable_eq\n\nend free_semigroup\n\n\n/-- Isomorphism between `magma.free_semigroup (free_magma \u03b1)` and `free_semigroup \u03b1`. -/\ndef free_add_semigroup_free_add_magma (\u03b1 : Type u) :\n    add_magma.free_add_semigroup (free_add_magma \u03b1) \u2243 free_add_semigroup \u03b1 :=\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 \u2218 free_add_magma.of)) sorry sorry\n\n@[simp] theorem free_semigroup_free_magma_mul {\u03b1 : Type u} (x : magma.free_semigroup (free_magma \u03b1))\n    (y : magma.free_semigroup (free_magma \u03b1)) :\n    coe_fn (free_semigroup_free_magma \u03b1) (x * y) =\n        coe_fn (free_semigroup_free_magma \u03b1) x * coe_fn (free_semigroup_free_magma \u03b1) 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 \u00d7 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' : \u2200 {w x y z}, r w x \u2192 r y z \u2192 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' : \u2200 {w x y z}, r w x \u2192 r y z \u2192 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 \u2192 M \u2192 Prop) : M \u2192 M \u2192 Prop\n| of : \u03a0 x y, r x y \u2192 add_con_gen.rel x y\n| refl : \u03a0 x, add_con_gen.rel x x\n| symm : \u03a0 x y, add_con_gen.rel x y \u2192 add_con_gen.rel y x\n| trans : \u03a0 x y z, add_con_gen.rel x y \u2192 add_con_gen.rel y z \u2192 add_con_gen.rel x z\n| add : \u03a0 w x y z, add_con_gen.rel w x \u2192 add_con_gen.rel y z \u2192 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 \u2192 M \u2192 Prop) : M \u2192 M \u2192 Prop\n| of : \u03a0 x y, r x y \u2192 con_gen.rel x y\n| refl : \u03a0 x, con_gen.rel x x\n| symm : \u03a0 x y, con_gen.rel x y \u2192 con_gen.rel y x\n| trans : \u03a0 x y z, con_gen.rel x y \u2192 con_gen.rel y z \u2192 con_gen.rel x z\n| mul : \u03a0 w x y z, con_gen.rel w x \u2192 con_gen.rel y z \u2192 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 \u2192 M \u2192 Prop) : con M :=\n\u27e8\u27e8con_gen.rel r, \u27e8con_gen.rel.refl, con_gen.rel.symm, con_gen.rel.trans\u27e9\u27e9, con_gen.rel.mul\u27e9\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\u27e8con_gen empty_relation\u27e9\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) (\u03bb _, M \u2192 M \u2192 Prop) := \u27e8\u03bb c, \u03bb x y, @setoid.r _ c.to_setoid x y\u27e9\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 : \u2200 {x y}, c x y \u2192 c y x := \u03bb _ _ h, c.to_setoid.symm' h\n\n/-- Congruence relations are transitive. -/\n@[to_additive \"Additive congruence relations are transitive.\"]\nprotected lemma trans : \u2200 {x y z}, c x y \u2192 c y z \u2192 c x z :=\n\u03bb _ _ _ h, c.to_setoid.trans' h\n\n/-- Multiplicative congruence relations preserve multiplication. -/\n@[to_additive \"Additive congruence relations preserve addition.\"]\nprotected lemma mul : \u2200 {w x y z}, c w x \u2192 c y z \u2192 c (w * y) (x * z) :=\n\u03bb _ _ _ _ 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 \u2194 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) \u2208 M \u00d7 M` iff `x` is related to `y` by `c`. -/\n@[to_additive \"Given a type `M` with an addition, `x, y \u2208 M`, and an additive congruence relation\n`c` on `M`, `(x, y) \u2208 M \u00d7 M` iff `x` is related to `y` by `c`.\"]\ninstance : has_mem (M \u00d7 M) (con M) := \u27e8\u03bb x c, c x.1 x.2\u27e9\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 \u27e8\u27e8\u27e9\u27e9, rcases d with \u27e8\u27e8\u27e9\u27e9, 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 : \u2200 x y, c x y \u2194 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} : (\u2200 x y, c x y \u2194 d x y) \u2194 c = d :=\n\u27e8ext, \u03bb h _ _, h \u25b8 iff.rfl\u27e9\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 \u2194 c = d :=\n\u27e8ext', \u03bb h, h \u25b8 rfl\u27e9\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 \u2192 P) (h : \u2200 x y, f (x * y) = f x * f y) : con M :=\n{ to_setoid := setoid.ker f,\n  mul' := \u03bb _ _ _ _ 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\u2081, x\u2082), (y\u2081, y\u2082) \u2208 M \u00d7 N` are related by `c.prod d` iff `x\u2081` is related to `y\u2081`\n    by `c` and `x\u2082` is related to `y\u2082` 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\u2081, x\u2082), (y\u2081, y\u2082) \u2208 M \u00d7 N` are related by `c.prod d` iff `x\u2081`\nis related to `y\u2081` by `c` and `x\u2082` is related to `y\u2082` by `d`.\"]\nprotected def prod (c : con M) (d : con N) : con (M \u00d7 N) :=\n{ mul' := \u03bb _ _ _ _ h1 h2, \u27e8c.mul h1.1 h2.1, d.mul h1.2 h2.2\u27e9, ..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 {\u03b9 : Type*} {f : \u03b9 \u2192 Type*} [\u03a0 i, has_mul (f i)]\n  (C : \u03a0 i, con (f i)) : con (\u03a0 i, f i) :=\n{ mul' := \u03bb _ _ _ _ h1 h2 i, (C i).mul (h1 i) (h2 i), ..@pi_setoid _ _ $ \u03bb 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 := \u27e8@quotient.mk _ c.to_setoid\u27e9\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 : \u2200 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 {\u03b2} {c : con M} (q : c.quotient) (f : M \u2192 \u03b2)\n  (h : \u2200 a b, c a b \u2192 f a = f b) : \u03b2 := 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\u2082 {\u03b2} {c : con M} (q r : c.quotient) (f : M \u2192 M \u2192 \u03b2)\n  (h : \u2200 a\u2081 a\u2082 b\u2081 b\u2082, c a\u2081 b\u2081 \u2192 c a\u2082 b\u2082 \u2192 f a\u2081 a\u2082 = f b\u2081 b\u2082) : \u03b2 := quotient.lift_on\u2082' q r f h\n\n/-- A version of `quotient.hrec_on\u2082'` for quotients by `con`. -/\n@[to_additive \"A version of `quotient.hrec_on\u2082'` for quotients by `add_con`.\"]\nprotected def hrec_on\u2082 {cM : con M} {cN : con N} {\u03c6 : cM.quotient \u2192 cN.quotient \u2192 Sort*}\n  (a : cM.quotient) (b : cN.quotient)\n  (f : \u03a0 (x : M) (y : N), \u03c6 x y) (h : \u2200 x y x' y', cM x x' \u2192 cN y y' \u2192 f x y == f x' y') :\n  \u03c6 a b :=\nquotient.hrec_on\u2082' a b f h\n\n@[simp, to_additive] lemma hrec_on\u2082_coe {cM : con M} {cN : con N}\n  {\u03c6 : cM.quotient \u2192 cN.quotient \u2192 Sort*} (a : M) (b : N)\n  (f : \u03a0 (x : M) (y : N), \u03c6 x y) (h : \u2200 x y x' y', cM x x' \u2192 cN y y' \u2192 f x y == f x' y') :\n  con.hrec_on\u2082 \u2191a \u2191b 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 \u2192 Prop} (q : c.quotient) (H : \u2200 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\u2082 {d : con N} {C : c.quotient \u2192 d.quotient \u2192 Prop}\n  (p : c.quotient) (q : d.quotient) (H : \u2200 (x : M) (y : N), C x y) : C p q :=\nquotient.induction_on\u2082' 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 \u2194 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\u27e8\u03bb x y, quotient.lift_on\u2082' x y (\u03bb w z, ((w * z : M) : c.quotient))\n     $ \u03bb _ _ _ _ h1 h2, c.eq.2 $ c.mul h1 h2\u27e9\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 \u2192 c.quotient) (\u03bb x y, rfl) = c :=\next $ \u03bb 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) : (\u2191(x * y) : c.quotient) = \u2191x * \u2191y := 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 {\u03b2} (c : con M) (f : M \u2192 \u03b2)\n  (h : \u2200 a b, c a b \u2192 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 \u2243* d.quotient :=\n{ map_mul' := \u03bb 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 \u2264 d` iff `\u2200 x y \u2208 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 \u2264 d` iff\n`\u2200 x y \u2208 M`, `x` is related to `y` by `d` if `x` is related to `y` by `c`.\"]\ninstance : has_le (con M) := \u27e8\u03bb c d, \u2200 \u2983x y\u2984, c x y \u2192 d x y\u27e9\n\n/-- Definition of `\u2264` for congruence relations. -/\n@[to_additive \"Definition of `\u2264` for additive congruence relations.\"]\ntheorem le_def {c d : con M} : c \u2264 d \u2194 \u2200 {x y}, c x y \u2192 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\u27e8\u03bb S, \u27e8\u27e8\u03bb x y, \u2200 c : con M, c \u2208 S \u2192 c x y,\n\u27e8\u03bb x c hc, c.refl x, \u03bb _ _ h c hc, c.symm $ h c hc,\n \u03bb _ _ _ h1 h2 c hc, c.trans (h1 c hc) $ h2 c hc\u27e9\u27e9,\n \u03bb _ _ _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc\u27e9\u27e9\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' $ \u03bb x y, \u27e8\u03bb h r \u27e8c, hS, hr\u27e9, by rw \u2190hr; exact h c hS,\n  \u03bb h c hS, h c.to_setoid \u27e8c, hS, rfl\u27e9\u27e9\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)) : \u21d1(Inf S) = Inf (@set.image (con M) (M \u2192 M \u2192 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 := (\u2264),\n  lt := \u03bb c d, c \u2264 d \u2227 \u00acd \u2264 c,\n  le_refl := \u03bb c _ _, id,\n  le_trans := \u03bb c1 c2 c3 h1 h2 x y h, h2 $ h1 h,\n  lt_iff_le_not_le := \u03bb _ _, iff.rfl,\n  le_antisymm := \u03bb c d hc hd, ext $ \u03bb x y, \u27e8\u03bb h, hc h, \u03bb h, hd h\u27e9 }\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 := \u03bb c d, \u27e8(c.to_setoid \u2293 d.to_setoid), \u03bb _ _ _ _ h1 h2, \u27e8c.mul h1.1 h2.1, d.mul h1.2 h2.2\u27e9\u27e9,\n  inf_le_left := \u03bb _ _ _ _ h, h.1,\n  inf_le_right := \u03bb _ _ _ _ h, h.2,\n  le_inf := \u03bb _ _ _ hb hc _ _ h, \u27e8hb h, hc h\u27e9,\n  top := { mul' := by tauto, ..setoid.complete_lattice.top},\n  le_top := \u03bb _ _ _ h, trivial,\n  bot := { mul' := \u03bb _ _ _ _ h1 h2, h1 \u25b8 h2 \u25b8 rfl, ..setoid.complete_lattice.bot},\n  bot_le := \u03bb c x y h, h \u25b8 c.refl x,\n  .. complete_lattice_of_Inf (con M) $ assume s,\n    \u27e8\u03bb r hr x y h, (h : \u2200 r \u2208 s, (r : con M) x y) r hr, \u03bb r hr x y h r' hr', hr hr' h\u27e9 }\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 \u2293 d).r = c.r \u2293 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 \u2293 d) x y \u2194 c x y \u2227 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 \u2192 M \u2192 Prop) :\n  con_gen r = Inf {s : con M | \u2200 x y, r x y \u2192 s x y} :=\nle_antisymm\n  (\u03bb x y H, con_gen.rel.rec_on H (\u03bb _ _ h _ hs, hs _ _ h) (con.refl _) (\u03bb _ _ _, con.symm _)\n    (\u03bb _ _ _ _ _, con.trans _)\n    $ \u03bb w x y z _ _ h1 h2 c hc, c.mul (h1 c hc) $ h2 c hc)\n  (Inf_le (\u03bb _ _, 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 \u2192 M \u2192 Prop} {c : con M} (h : \u2200 x y, r x y \u2192 @setoid.r _ c.to_setoid x y) :\n  con_gen r \u2264 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 \u2192 M \u2192 Prop} (h : \u2200 x y, r x y \u2192 s x y) :\n  con_gen r \u2264 con_gen s :=\ncon_gen_le $ \u03bb 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 (\u03bb _ _, 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 \u2192 M \u2192 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 \u2294 d = con_gen (\u03bb x y, c x y \u2228 d x y) :=\nbegin\n  rw con_gen_eq,\n  apply congr_arg Inf,\n  simp only [le_def, or_imp_distrib, \u2190 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 \u2294 d = con_gen (c.r \u2294 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 \u2208 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 \u2208 S`\nsuch that `x` is related to `y` by `c`'.\"]\nlemma Sup_eq_con_gen (S : set (con M)) :\n  Sup S = con_gen (\u03bb x y, \u2203 c : con M, c \u2208 S \u2227 c x y) :=\nbegin\n  rw con_gen_eq,\n  apply congr_arg Inf,\n  ext,\n  exact \u27e8\u03bb h _ _ \u27e8r, hr\u27e9, h hr.1 hr.2,\n         \u03bb h r hS _ _ hr, h _ _ \u27e8r, hS, hr\u27e9\u27e9,\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 \u2192 M \u2192 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 \u2192 M \u2192 Prop) (con M) _ _ con_gen coe_fn :=\n{ choice := \u03bb r h, con_gen r,\n  gc := \u03bb r c, \u27e8\u03bb H _ _ h, H $ con_gen.rel.of _ _ h, \u03bb H, con_gen_of_con c \u25b8 con_gen_mono H\u27e9,\n  le_l_u := \u03bb x, (con_gen_of_con x).symm \u25b8 le_refl x,\n  choice_eq := \u03bb _ _, 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 \u2248 y` iff the elements of `f\u207b\u00b9(x)` are related to the elements of `f\u207b\u00b9(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 \u2248 y` iff the elements of `f\u207b\u00b9(x)` are related to the\nelements of `f\u207b\u00b9(y)` by an additive congruence relation `c`.'\"]\ndef map_gen (f : M \u2192 N) : con N :=\ncon_gen $ \u03bb x y, \u2203 a b, f a = x \u2227 f b = y \u2227 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 \u2248 y` iff the\n    elements of `f\u207b\u00b9(x)` are related to the elements of `f\u207b\u00b9(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 \u2248 y` iff the elements of `f\u207b\u00b9(x)` are related to the elements of `f\u207b\u00b9(y)` by `c`.'\"]\ndef map_of_surjective (f : M \u2192 N) (H : \u2200 x y, f (x * y) = f x * f y) (h : mul_ker f H \u2264 c)\n  (hf : surjective f) : con N :=\n{ mul' := \u03bb w x y z \u27e8a, b, hw, hx, h1\u27e9 \u27e8p, q, hy, hz, h2\u27e9,\n    \u27e8a * p, b * q, by rw [H, hw, hy], by rw [H, hx, hz], c.mul h1 h2\u27e9,\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 \u2192 N} (H : \u2200 x y, f (x * y) = f x * f y)\n  (h : mul_ker f H \u2264 c) (hf : surjective f) :\n  c.map_gen f = c.map_of_surjective f H h hf :=\nby rw \u2190con_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 \u2192 N` induces a congruence relation on `f`'s domain\n    defined by '`x \u2248 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 \u2192 N` induces an additive congruence relation on `f`'s domain\ndefined by '`x \u2248 y` iff `f(x)` is related to `f(y)` by `c`.' \"]\ndef comap (f : M \u2192 N) (H : \u2200 x y, f (x * y) = f x * f y) (c : con N) : con M :=\n{ mul' := \u03bb 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 \u2192 N} (H : \u2200 x y, f (x * y) = f x * f y)\n  {c : con N} {x y : M} :\n  comap f H c x y \u2194 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 \u2264 d} \u2243o (con c.quotient) :=\n{ to_fun := \u03bb 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 := \u03bb d, \u27e8comap (coe : M \u2192 c.quotient) (\u03bb x y, rfl) d, \u03bb _ _ h,\n    show d _ _, by rw c.eq.2 h; exact d.refl _ \u27e9,\n  left_inv := \u03bb d, subtype.ext_iff_val.2 $ ext $ \u03bb _ _,\n    \u27e8\u03bb h, let \u27e8a, b, hx, hy, H\u27e9 := 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     \u03bb h, \u27e8_, _, rfl, rfl, h\u27e9\u27e9,\n  right_inv := \u03bb d, let Hm : mul_ker (coe : M \u2192 c.quotient) (\u03bb x y, rfl) \u2264\n        comap (coe : M \u2192 c.quotient) (\u03bb x y, rfl) d :=\n      \u03bb x y h, show d _ _, by rw mul_ker_mk_eq at h; exact c.eq.2 h \u25b8 d.refl _ in\n    ext $ \u03bb x y, \u27e8\u03bb h, let \u27e8a, b, hx, hy, H\u27e9 := h in hx \u25b8 hy \u25b8 H,\n      con.induction_on\u2082 x y $ \u03bb w z h, \u27e8w, z, rfl, rfl, h\u27e9\u27e9,\n  map_rel_iff' := \u03bb s t, \u27e8\u03bb h _ _ hs, let \u27e8a, b, hx, hy, ht\u27e9 := h \u27e8_, _, rfl, rfl, hs\u27e9 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      \u03bb h _ _ hs, let \u27e8a, b, hx, hy, Hs\u27e9 := hs in \u27e8a, b, hx, hy, h Hs\u27e9\u27e9 }\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 := \u03bb x, quotient.induction_on' x $ \u03bb _, congr_arg coe $ mul_one _,\n  one_mul := \u03bb x, quotient.induction_on' x $ \u03bb _, 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 \u00d7 M` defined by a congruence relation on a monoid `M`. -/\n@[to_additive \"The `add_submonoid` of `M \u00d7 M` defined by an additive congruence\nrelation on an `add_monoid` `M`.\"]\nprotected def submonoid : submonoid (M \u00d7 M) :=\n{ carrier := { x | c x.1 x.2 },\n  one_mem' := c.iseqv.1 1,\n  mul_mem' := \u03bb _ _, c.mul }\n\nvariables {M c}\n\n/-- The congruence relation on a monoid `M` from a submonoid of `M \u00d7 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 \u00d7 M` for which membership is an equivalence relation.\"]\ndef of_submonoid (N : submonoid (M \u00d7 M)) (H : equivalence (\u03bb x y, (x, y) \u2208 N)) : con M :=\n{ r := \u03bb x y, (x, y) \u2208 N,\n  iseqv := H,\n  mul' := \u03bb _ _ _ _, N.mul_mem }\n\n/-- Coercion from a congruence relation `c` on a monoid `M` to the submonoid of `M \u00d7 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 \u00d7 M` whose elements are `(x, y)` such that `x`\nis related to `y` by `c`.\"]\ninstance to_submonoid : has_coe (con M) (submonoid (M \u00d7 M)) := \u27e8\u03bb c, c.submonoid M\u27e9\n\n@[to_additive] lemma mem_coe {c : con M} {x y} :\n  (x, y) \u2208 (\u2191c : submonoid (M \u00d7 M)) \u2194 (x, y) \u2208 c := iff.rfl\n\n@[to_additive]\ntheorem to_submonoid_inj (c d : con M) (H : (c : submonoid (M \u00d7 M)) = d) : c = d :=\next $ \u03bb x y, show (x, y) \u2208 (c : submonoid (M \u00d7 M)) \u2194 (x, y) \u2208 \u2191d, by rw H\n\n@[to_additive]\nlemma le_iff {c d : con M} : c \u2264 d \u2194 (c : submonoid (M \u00d7 M)) \u2264 d :=\n\u27e8\u03bb h x H, h H, \u03bb h x y hc, h $ show (x, y) \u2208 c, from hc\u27e9\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 \u2192* 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 \u2192* P) {x y} : ker f x y \u2194 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 := \u27e8((1 : M) : c.quotient)\u27e9\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 \u2192* c.quotient := \u27e8coe, rfl, \u03bb _ _, rfl\u27e9\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 $ \u03bb _ _, 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 \u2192 c.quotient) = coe := rfl\n\n/-- The elements related to `x \u2208 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 \u2208 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 \u2192* P} (x) : (ker f) x = f \u207b\u00b9' {f x} :=\nset.ext $ \u03bb x,\n  \u27e8\u03bb h, set.mem_preimage.2 $ set.mem_singleton_iff.2 h.symm,\n   \u03bb h, (set.mem_singleton_iff.1 $ set.mem_preimage.1 h).symm\u27e9\n\n/-- Given a monoid homomorphism `f : N \u2192 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 \u2192 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 \u2192* M} : comap f f.map_mul c = ker (c.mk'.comp f) :=\next $ \u03bb x y, show c _ _ \u2194 c.mk' _ = c.mk' _, by rw \u2190c.eq; refl\n\nvariables (c) (f : M \u2192* 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 \u2264 ker f) : c.quotient \u2192* P :=\n{ to_fun := \u03bb x, con.lift_on x f $ \u03bb _ _ h, H h,\n  map_one' := by rw \u2190f.map_one; refl,\n  map_mul' := \u03bb x y, con.induction_on\u2082 x y $ \u03bb m n, f.map_mul m n \u25b8 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 \u2264 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 \u2264 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 \u2264 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 \u2192* P) :\n  c.lift (f.comp c.mk') (\u03bb x y h, show f \u2191x = f \u2191y, 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 \u2192* P) (h : \u2200 a : M, f a = g a) : f = g :=\nbegin\n  rw [\u2190lift_apply_mk' f, \u2190lift_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 \u2264 ker f) (g : c.quotient \u2192* P)\n  (Hg : g.comp c.mk' = f) : g = c.lift f H :=\nlift_funext g (c.lift f H) $ \u03bb 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 \u2264 ker f) : (c.lift f H).mrange = f.mrange :=\nsubmonoid.ext $ \u03bb x, \u27e8by rintros \u27e8\u27e8y\u27e9, hy\u27e9; exact \u27e8y, hy\u27e9, \u03bb \u27e8y, hy\u27e9, \u27e8\u2191y, hy\u27e9\u27e9\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 \u2264 ker f) (hf : surjective f) :\n  surjective (c.lift f h) :=\n\u03bb y, exists.elim (hf y) $ \u03bb w hw, \u27e8w, (lift_mk' h w).symm \u25b8 hw\u27e9\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 \u2264 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 \u2192* P :=\n(ker f).lift f $ \u03bb _ _, 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 $ \u03bb _ _, 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 \u2192* P) : injective (ker_lift f) :=\n\u03bb x y, quotient.induction_on\u2082' x y $ \u03bb _ _, (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 \u2264 d) : c.quotient \u2192* d.quotient :=\nc.lift d.mk' $ \u03bb x y hc, show (ker d.mk') x y, from\n  (mk'_ker d).symm \u25b8 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 \u2264 d) (x) :\n  c.map d h x = c.lift d.mk' (\u03bb 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 \u2192* P) : (ker f).quotient \u2243* 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        \u27e8\u03bb x y h, ker_lift_injective f $ by rcases x; rcases y; injections,\n         \u03bb \u27e8w, z, hz\u27e9, \u27e8z, by rcases hz; rcases _x; refl\u27e9\u27e9 }\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 \u2192* P) (g : P \u2192 M)\n  (hf : function.right_inverse g f) :\n  (ker f).quotient \u2243* P :=\n{ to_fun := ker_lift f,\n  inv_fun := coe \u2218 g,\n  left_inv := \u03bb 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 \u2192* P) (hf : surjective f) :\n  (ker f).quotient \u2243* 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 \u2192* M) :\n  (comap f f.map_mul c).quotient \u2243* (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 \u2264 d) :\n  (ker (c.map d h)).quotient \u2243* d.quotient :=\n{ map_mul' := \u03bb x y, con.induction_on\u2082 x y $ \u03bb w z, con.induction_on\u2082 w z $ \u03bb a b,\n    show _ = d.mk' a * d.mk' b, by rw \u2190d.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 := \u03bb x y z, quotient.induction_on\u2083' x y z\n               $ \u03bb _ _ _, 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 := \u03bb x y, con.induction_on\u2082 x y $ \u03bb w z, by rw [\u2190coe_mul, \u2190coe_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 : \u2200 {w x}, c w x \u2192 c w\u207b\u00b9 x\u207b\u00b9 :=\n\u03bb x y h, by simpa using c.symm (c.mul (c.mul (c.refl x\u207b\u00b9) h) (c.refl y\u207b\u00b9))\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\u27e8\u03bb x, quotient.lift_on' x (\u03bb w, ((w\u207b\u00b9 : M) : c.quotient))\n     $ \u03bb x y h, c.eq.2 $ c.inv h\u27e9\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 := \u03bb x, x\u207b\u00b9,\n  mul_left_inv := \u03bb x, show x\u207b\u00b9 * x = 1,\n    from quotient.induction_on' x $ \u03bb _, congr_arg coe $ mul_left_inv _,\n  .. con.monoid c}\n\nend groups\n\nsection units\n\nvariables {\u03b1 : Type*} [monoid M] {c : con M}\n\n/-- In order to define a function `units (con.quotient c) \u2192 \u03b1` 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 `\u03b1` 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 : \u03a0 (x y : M), c (x * y) 1 \u2192 c (y * x) 1 \u2192 \u03b1)\n  (Hf : \u2200 x y hxy hyx x' y' hxy' hyx', c x x' \u2192 c y y' \u2192 f x y hxy hyx = f x' y' hxy' hyx') :\n  \u03b1 :=\nbegin\n  refine @con.hrec_on\u2082 M M _ _ c c (\u03bb x y, x * y = 1 \u2192 y * x = 1 \u2192 \u03b1)\n    (u : c.quotient) (\u2191u\u207b\u00b9 : c.quotient)\n    (\u03bb (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)) (\u03bb 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) \u2192 \u03b1` 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 `\u03b1` 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 : \u03a0 (x y : M), c (x * y) 1 \u2192 c (y * x) 1 \u2192 \u03b1)\n  (Hf : \u2200 x y hxy hyx x' y' hxy' hyx', c x x' \u2192 c y y' \u2192 f x y hxy hyx = f x' y' hxy' hyx')\n  (x y : M) (hxy hyx) :\n  lift_on_units \u27e8(x : c.quotient), y, hxy, hyx\u27e9 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 \u2192 Prop} (u : units c.quotient)\n  (H : \u2200 (x y : M) (hxy : c (x * y) 1) (hyx : c (y * x) 1), p \u27e8x, y, c.eq.2 hxy, c.eq.2 hyx\u27e9) :\n  p u :=\nbegin\n  rcases u with \u27e8\u27e8x\u27e9, \u27e8y\u27e9, h\u2081, h\u2082\u27e9,\n  exact H x y (c.eq.1 h\u2081) (c.eq.1 h\u2082)\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' : \u211d\u22650)\nvariables [fact (0 < r')] [fact (r < 1)]\nvariables (i : \u2115)\n\n-- move me\nlemma \u03ba_pos : \u2200 m, 0 < eg.\u03ba r r' m\n| 0 := zero_lt_one\n| (m+1) := begin\n  dsimp only [eg.\u03ba, data.\u03ba],\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 _) _) (\u03ba_pos _), }\nend\n\nvariables [fact (0 < r)] [fact (r < r')] [fact (r' < 1)]\n\nnoncomputable!\ndef \u03b9' : \u2115 \u2192 \u211d\u22650\n| 0 := max\n        (c\u2080 r r' eg (\u03bb (n : \u2115), eg.\u03ba r r' n) (eg.\u03ba' r r') (i + 1) \u27e8\u2124\u27e9)\n        (c\u2080 r r' eg (\u03bb (n : \u2115), eg.\u03ba r r' n) (eg.\u03ba' r r') (i + 1 + 1) \u27e8\u2124\u27e9)\n| (j+1) := max\n        (max (j+1) (\u03b9' j))\n        (max\n          (max\n            (k (eg.\u03ba' r r') i ^ 2 * \u03b9' j)\n            (k (eg.\u03ba' r r') (i+1) ^ 2 * \u03b9' j))\n            ((k (eg.\u03ba' r r') (i+1+1) ^ 2 * \u03b9' j)))\n\nlemma h\u03b9' : monotone (\u03b9' 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\u03b91 : \u2200 j,\n  c\u2080 r r' eg (\u03bb (n : \u2115), eg.\u03ba r r' n) (eg.\u03ba' r r') (i + 1) \u27e8\u2124\u27e9 \u2264 \u03b9' r r' i j\n| 0 := le_max_left _ _\n| (j+1) := (H\u03b91 j).trans $ by { apply h\u03b9', apply nat.le_succ }\n\nlemma H\u03b91' : \u2200 j,\n  c\u2080 r r' eg (\u03bb (n : \u2115), eg.\u03ba r r' n) (eg.\u03ba' r r') (i + 1 + 1) \u27e8\u2124\u27e9 \u2264 \u03b9' r r' i j\n| 0 := le_max_right _ _\n| (j+1) := (H\u03b91' j).trans $ by { apply h\u03b9', apply nat.le_succ }\n\nlemma H\u03b92a : \u2200 j,\n  k (eg.\u03ba' r r') i ^ 2 * \u03b9' r r' i j \u2264 \u03b9' r r' i (j + 1) :=\nby rintro (_|j); simp only [\u03b9', le_max_iff, le_rfl, true_or, or_true]\n\nlemma H\u03b92b : \u2200 j,\n  k (eg.\u03ba' r r') (i + 1) ^ 2 * \u03b9' r r' i j \u2264 \u03b9' r r' i (j + 1) :=\nby rintro (_|j); simp only [\u03b9', le_max_iff, le_rfl, true_or, or_true]\n\nlemma H\u03b92c : \u2200 j,\n  k (eg.\u03ba' r r') (i + 1 + 1) ^ 2 * \u03b9' r r' i j \u2264 \u03b9' r r' i (j + 1) :=\nby rintro (_|j); simp only [\u03b9', le_max_iff, le_rfl, true_or, or_true]\n\nnoncomputable\ndef \u03b9 : ulift.{1} \u2115 \u2192 \u211d\u22650 := \u03b9' r r' i \u2218 ulift.down\n\nlemma h\u03b9 : monotone (\u03b9 r r' i) :=\n\u03bb j\u2081 j\u2082 h, by { delta \u03b9, apply h\u03b9', exact h }\n\nlemma h\u03b9'_self_le : \u2200 j:\u2115, (j:\u211d\u22650) \u2264 \u03b9' r r' i j\n| 0 := by { norm_cast, exact zero_le' }\n| (j+1) := by simp only [\u03b9', le_max_iff, nat.cast_add, nat.cast_one, le_refl, true_or]\n\nlemma sufficiently_increasing_eg (s : \u211d\u22650) (m : \u2115) :\n  \u2203 n : \u2115, s \u2264 \u03b9' r r' i n * eg.\u03ba r r' m :=\nbegin\n  let \u03ba := eg.\u03ba r r' m,\n  let n := \u2308s * \u03ba\u207b\u00b9\u2309\u208a,\n  let \u03b9 := \u03b9' r r' i n,\n  refine \u27e8n, _\u27e9,\n  calc s = s * \u03ba\u207b\u00b9 * \u03ba : _\n     ... \u2264 \u03b9 * \u03ba : mul_le_mul' _ le_rfl,\n  { rw inv_mul_cancel_right\u2080, apply ne_of_gt, apply \u03ba_pos, },\n  { refine (nat.le_ceil _).trans (h\u03b9'_self_le _ _ _ _) }\nend\n\nlemma sufficiently_increasing_eg' (s : \u211d\u22650) (m : \u2115) :\n  \u2203 n : \u2115, s \u2264 r' * (\u03b9' r r' i n * eg.\u03ba r r' m) :=\nbegin\n  obtain \u27e8n,hn\u27e9 := 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' \u2260 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  (\u03ba : \u211d\u22650 \u2192 \u2115 \u2192 \u211d\u22650) (\u03b9 : ulift \u2115 \u2192 \u211d\u22650) : Prop :=\n\u2200 (r : \u211d\u22650) (m : \u2115), \u2203 n : \u2115, r \u2264 \u03ba (\u03b9 \u27e8n\u27e9) 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 {\u03b1 \u03b2 : Type*} (u : set \u03b1) :\n  @inl \u03b1 \u03b2 \u207b\u00b9' (@inl \u03b1 \u03b2 '' u) = u :=\nset.preimage_image_eq u (\u03bb _ _, inl.inj_iff.mp)\n\nlemma preimage_inl_image_inr {\u03b1 \u03b2 : Type*} (u : set \u03b2) :\n  @inl \u03b1 \u03b2 \u207b\u00b9' (@inr \u03b1 \u03b2 '' u) = \u2205 :=\nset.eq_empty_iff_forall_not_mem.mpr (assume b \u27e8a, _, h\u27e9, inr_ne_inl h)\n\nlemma preimage_inr_image_inl {\u03b1 \u03b2 : Type*} (u : set \u03b1) :\n  @inr \u03b1 \u03b2 \u207b\u00b9' (@inl \u03b1 \u03b2 '' u) = \u2205 :=\nset.eq_empty_iff_forall_not_mem.mpr (assume a \u27e8b, _, h\u27e9, inl_ne_inr h)\n\nlemma preimage_inr_image_inr {\u03b1 \u03b2 : Type*} (u : set \u03b2) :\n  @inr \u03b1 \u03b2 \u207b\u00b9' (@inr \u03b1 \u03b2 '' u) = u :=\nset.preimage_image_eq u (\u03bb _ _, 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) (\u03b1 : Type*) : premodel th (optree th.op \u03b1) :=\n  {\n    act := @optree.opnode th.op \u03b1\n  }\n\nend premodel\n\n\nnamespace morphism\n\n-- maps into premodels give rise to morphisms out of trees\ndefinition treelift (th : theory) {\u03b1 \u03b2: Type*} [premodel th \u03b2] (f : \u03b1 \u2192 \u03b2) : morphism th (optree th.op \u03b1) \u03b2 :=\n  subtype.mk (optree.elim (@premodel.act th \u03b2 _) f) $\n    by intros n \u03bc ts; unfold premodel.act; rw [optree.elim_opnode]\n\n-- Computation rule for treelift; treelift preserves the original map\ntheorem treelift_comp {th : theory} {\u03b1 \u03b2: Type*} [premodel th \u03b2] (f : \u03b1 \u2192 \u03b2) : \u2200 {a : \u03b1}, (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} {\u03b1 \u03b2 : Type*} [premodel th \u03b2] {f g : morphism th (optree th.op \u03b1) \u03b2} (h : \u2200 a, f.val (optree.varleaf a) = g.val (optree.varleaf a))\nwith tree_unique : \u2200 {t : optree th.op \u03b1}, 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 \u03b1) _ 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 : \u2200 t, (optree.opnode k t) = (@premodel.act th (optree th.op \u03b1) _ _ k) t,\n      from \u03bb_, 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 : \u2200 {n : \u2115} {ts : vect (optree th.op \u03b1) 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\u2081 g\u2082 : CF_grammar T) : CF_grammar T :=\nCF_grammar.mk (option (g\u2081.nt \u2295 g\u2082.nt)) none (\n  (none, [symbol.nonterminal (some (sum.inl (g\u2081.initial)))]) ::\n  (none, [symbol.nonterminal (some (sum.inr (g\u2082.initial)))]) ::\n  ((list.map rule_of_rule\u2081 g\u2081.rules) ++ (list.map rule_of_rule\u2082 g\u2082.rules))\n)\n\n\nvariables {g\u2081 g\u2082 : CF_grammar T}\n\nsection lifted_grammars\n\nprivate def oN\u2081_of_N : (union_grammar g\u2081 g\u2082).nt \u2192 (option g\u2081.nt)\n| none := none\n| (some (sum.inl nonte)) := some nonte\n| (some (sum.inr _)) := none\n\nprivate def oN\u2082_of_N : (union_grammar g\u2081 g\u2082).nt \u2192 (option g\u2082.nt)\n| none := none\n| (some (sum.inl _)) := none\n| (some (sum.inr nonte)) := some nonte\n\n\nprivate def g\u2081g : @lifted_grammar T :=\nlifted_grammar.mk g\u2081 (union_grammar g\u2081 g\u2082) (some \u2218 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\u2081,\n  unfold lift_rule,\n  norm_num,\n  unfold lift_string,\n  unfold lsTN_of_lsTN\u2081,\n  five_steps,\n}) oN\u2081_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\u2081_of_N] at ass,\n  apply congr_arg,\n  apply congr_arg,\n  exact ass,\n}) (by {\n  intro r,\n  rintro \u27e8r_in, r_ntype\u27e9,\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\u2080 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\u2080 imposs,\n    exact option.no_confusion imposs,\n  },\n  change r \u2208 (list.map rule_of_rule\u2081 g\u2081.rules ++ list.map rule_of_rule\u2082 g\u2082.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 \u27e8r\u2081, r\u2081_in, r\u2081_convert_r\u27e9,\n    use r\u2081,\n    split,\n    {\n      exact r\u2081_in,\n    },\n    rw \u2190r\u2081_convert_r,\n    simp only [\n      lift_rule, rule_of_rule\u2081, lift_string, lsTN_of_lsTN\u2081,\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 \u27e8r\u2082, r\u2082_in, r\u2082_convert_r\u27e9,\n    rw \u2190r\u2082_convert_r at r_ntype,\n    unfold rule_of_rule\u2082 at r_ntype,\n    dsimp only at r_ntype,\n    cases r_ntype with n\u2081 contr,\n    rw option.some_inj at contr,\n    exact sum.no_confusion contr,\n  },\n}) (by { intro, refl })\n\nprivate def g\u2082g : @lifted_grammar T :=\nlifted_grammar.mk g\u2082 (union_grammar g\u2081 g\u2082) (some \u2218 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\u2082,\n  unfold lift_rule,\n  norm_num,\n  unfold lift_string,\n  unfold lsTN_of_lsTN\u2082,\n  five_steps,\n}) oN\u2082_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\u2082_of_N] at ass,\n  apply congr_arg,\n  apply congr_arg,\n  exact ass,\n}) (by {\n  intro r,\n  rintro \u27e8r_in, r_ntype\u27e9,\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\u2080 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\u2080 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 \u27e8r\u2081, r\u2081_in, r\u2081_convert_r\u27e9,\n    rw \u2190r\u2081_convert_r at r_ntype,\n    unfold rule_of_rule\u2081 at r_ntype,\n    dsimp only at r_ntype,\n    cases r_ntype with n\u2082 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 \u27e8r\u2082, r\u2082_in, r\u2082_convert_r\u27e9,\n    use r\u2082,\n    split,\n    {\n      exact r\u2082_in,\n    },\n    rw \u2190r\u2082_convert_r,\n    simp only [\n      lift_rule, rule_of_rule\u2082, lift_string, lsTN_of_lsTN\u2082,\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\u2081_more (w : list (symbol T g\u2081.nt)) :\n  CF_derives g\u2081 [symbol.nonterminal g\u2081.initial] w \u2192\n    CF_derives\n      (union_grammar g\u2081 g\u2082)\n      (lsTN_of_lsTN\u2081 [symbol.nonterminal g\u2081.initial])\n      (lsTN_of_lsTN\u2081 w) :=\nbegin\n  intro ass,\n  let gg\u2081 := @g\u2081g T g\u2081 g\u2082,\n  change CF_derives gg\u2081.g (lsTN_of_lsTN\u2081 [symbol.nonterminal g\u2081.initial]) (lsTN_of_lsTN\u2081 w),\n  have techni : lsTN_of_lsTN\u2081 = lift_string gg\u2081.lift_nt,\n  {\n    unfold lsTN_of_lsTN\u2081,\n    unfold lift_string,\n    ext1 w,\n    five_steps,\n  },\n  rw techni,\n  exact lift_deri ass,\nend\n\nprivate lemma deri\u2082_more (w : list (symbol T g\u2082.nt)) :\n  CF_derives g\u2082 [symbol.nonterminal g\u2082.initial] w \u2192\n    CF_derives\n      (union_grammar g\u2081 g\u2082)\n      (lsTN_of_lsTN\u2082 [symbol.nonterminal g\u2082.initial])\n      (lsTN_of_lsTN\u2082 w) :=\nbegin\n  intro ass,\n  let gg\u2082 := @g\u2082g T g\u2081 g\u2082,\n  change CF_derives gg\u2082.g (lsTN_of_lsTN\u2082 [symbol.nonterminal g\u2082.initial]) (lsTN_of_lsTN\u2082 w),\n  have techni : lsTN_of_lsTN\u2082 = lift_string gg\u2082.lift_nt,\n  {\n    unfold lsTN_of_lsTN\u2082,\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 \u2208 CF_language g\u2081  \u2192  w \u2208 CF_language (union_grammar g\u2081 g\u2082)  :=\nbegin\n  intro assum,\n\n  have deri_start :\n    CF_derives\n      (union_grammar g\u2081 g\u2082)\n      [symbol.nonterminal none]\n      [symbol.nonterminal (some (sum.inl g\u2081.initial))],\n  {\n    apply CF_deri_of_tran,\n    use (none, [symbol.nonterminal (some (sum.inl (g\u2081.initial)))]),\n    split,\n    {\n      change (none, [symbol.nonterminal (some (sum.inl g\u2081.initial))]) \u2208 (\n        (none, [symbol.nonterminal (some (sum.inl (g\u2081.initial)))]) ::\n        (none, [symbol.nonterminal (some (sum.inr (g\u2082.initial)))]) ::\n        ((list.map rule_of_rule\u2081 g\u2081.rules) ++ (list.map rule_of_rule\u2082 g\u2082.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\u2081 g\u2082)\n      [symbol.nonterminal (some (sum.inl g\u2081.initial))]\n      (list.map symbol.terminal w),\n  {\n    have beginning :\n      [symbol.nonterminal (some (sum.inl g\u2081.initial))] =\n      lsTN_of_lsTN\u2081 [symbol.nonterminal g\u2081.initial],\n    {\n      unfold lsTN_of_lsTN\u2081,\n      change\n        [symbol.nonterminal (some (sum.inl g\u2081.initial))] =\n        [sTN_of_sTN\u2081 (symbol.nonterminal g\u2081.initial)],\n      unfold sTN_of_sTN\u2081,\n    },\n    have ending :\n      (list.map symbol.terminal w) =\n      lsTN_of_lsTN\u2081 (list.map symbol.terminal w),\n    {\n      ext1,\n      unfold lsTN_of_lsTN\u2081,\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\u2081_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 \u2208 CF_language g\u2082  \u2192  w \u2208 CF_language (union_grammar g\u2081 g\u2082)  :=\nbegin\n  intro assum,\n\n  have deri_start :\n    CF_derives\n      (union_grammar g\u2081 g\u2082)\n      [symbol.nonterminal none]\n      [symbol.nonterminal (some (sum.inr g\u2082.initial))],\n  {\n    apply CF_deri_of_tran,\n    use (none, [symbol.nonterminal (some (sum.inr (g\u2082.initial)))]),\n    split,\n    {\n      change (none, [symbol.nonterminal (some (sum.inr g\u2082.initial))]) \u2208 (\n        (none, [symbol.nonterminal (some (sum.inl (g\u2081.initial)))]) ::\n        (none, [symbol.nonterminal (some (sum.inr (g\u2082.initial)))]) ::\n        ((list.map rule_of_rule\u2081 g\u2081.rules) ++ (list.map rule_of_rule\u2082 g\u2082.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\u2081 g\u2082)\n      [symbol.nonterminal (some (sum.inr g\u2082.initial))]\n      (list.map symbol.terminal w),\n  {\n    have beginning :\n      [symbol.nonterminal (some (sum.inr g\u2082.initial))] =\n      lsTN_of_lsTN\u2082 [symbol.nonterminal g\u2082.initial],\n    {\n      unfold lsTN_of_lsTN\u2082,\n      change\n        [symbol.nonterminal (some (sum.inr g\u2082.initial))] =\n        [sTN_of_sTN\u2082 (symbol.nonterminal g\u2082.initial)],\n      unfold sTN_of_sTN\u2082,\n    },\n    have ending :\n      (list.map symbol.terminal w) =\n      lsTN_of_lsTN\u2082 (list.map symbol.terminal w),\n    {\n      ext1,\n      unfold lsTN_of_lsTN\u2082,\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\u2082_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\u2081 g\u2082)\n      [symbol.nonterminal (some (sum.inl g\u2081.initial))]\n      (list.map symbol.terminal w)) :\n  w \u2208 CF_language g\u2081 :=\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\u2081 := @g\u2081g T g\u2081 g\u2082,\n\n  have bar :\n    [symbol.nonterminal g\u2081.initial] =\n    (sink_string gg\u2081.sink_nt [symbol.nonterminal (some (sum.inl g\u2081.initial))]),\n  {\n    unfold sink_string,\n    refl,\n  },\n  rw bar,\n\n  have baz : list.map symbol.terminal w = sink_string gg\u2081.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 (\u03bb x, (sink_symbol gg\u2081.sink_nt \u2218 symbol.terminal) x) w,\n    convert_to list.map symbol.terminal w = list.filter_map (\u03bb x, option.some (symbol.terminal x)) w,\n    change list.map symbol.terminal w = list.filter_map (option.some \u2218 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 \u2218 symbol.terminal) l,\n    norm_num,\n    exact w_ih,\n  },\n  rw baz,\n\n  exact (sink_deri gg\u2081 [symbol.nonterminal (some (sum.inl g\u2081.initial))] (list.map symbol.terminal w) hypo (by {\n    good_singleton,\n    use g\u2081.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\u2081 g\u2082)\n      [symbol.nonterminal (some (sum.inr g\u2082.initial))]\n      (list.map symbol.terminal w)) :\n  w \u2208 CF_language g\u2082 :=\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\u2082 := @g\u2082g T g\u2081 g\u2082,\n\n  have bar :\n    [symbol.nonterminal g\u2082.initial] =\n    (sink_string gg\u2082.sink_nt [symbol.nonterminal (some (sum.inr g\u2082.initial))]),\n  {\n    unfold sink_string,\n    refl,\n  },\n  rw bar,\n\n  have baz : list.map symbol.terminal w = sink_string gg\u2082.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 (\u03bb x, (sink_symbol gg\u2082.sink_nt \u2218 symbol.terminal) x) w,\n    convert_to list.map symbol.terminal w = list.filter_map (\u03bb x, option.some (symbol.terminal x)) w,\n    change list.map symbol.terminal w = list.filter_map (option.some \u2218 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 \u2218 symbol.terminal) l,\n    norm_num,\n    exact w_ih,\n  },\n  rw baz,\n\n  exact (sink_deri gg\u2082 [symbol.nonterminal (some (sum.inr g\u2082.initial))] (list.map symbol.terminal w) hypo (by {\n    good_singleton,\n    use g\u2082.initial,\n    refl,\n  })).left,\nend\n\nprivate lemma both_empty\n    (u v: list (symbol T (union_grammar g\u2081 g\u2082).nt))\n    (a : (symbol T (union_grammar g\u2081 g\u2082).nt))\n    (bef: [symbol.nonterminal (union_grammar g\u2081 g\u2082).initial] = u ++ [a] ++ v) :\n  u = []  \u2227  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 \u2190list.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    ... \u2265 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    ... \u2265 1 + 1 + 0                 : le_self_add\n    ... = 2                         : rfl),\n  },\n  {\n    by_contradiction,\n    rw \u2190list.length_eq_zero at h,\n    exact nat.not_succ_le_self 1 (by calc\n      1 = (u.length + 1) + v.length : len\n    ... \u2265 (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    ... \u2265 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\u2081 g\u2082).nt \u00d7 list (symbol T (union_grammar g\u2081 g\u2082).nt))\n    (u v: list (symbol T (union_grammar g\u2081 g\u2082).nt))\n    (hu : u = []) (hv : v = [])\n    (bef: [symbol.nonterminal (union_grammar g\u2081 g\u2082).initial] = u ++ [symbol.nonterminal r.fst] ++ v)\n    (sbi : r \u2208 (list.map rule_of_rule\u2081 g\u2081.rules ++ list.map rule_of_rule\u2082 g\u2082.rules)) :\n  w \u2208 CF_language g\u2081 \u2228 w \u2208 CF_language g\u2082 :=\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 \u27e8r\u2081, -, imposs\u27e9,\n    unfold rule_of_rule\u2081 at imposs,\n    rw \u2190imposs 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 \u27e8r\u2082, -, imposs\u27e9,\n    unfold rule_of_rule\u2082 at imposs,\n    rw \u2190imposs 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 \u2208 CF_language (union_grammar g\u2081 g\u2082)   \u2192   w \u2208 CF_language g\u2081  \u2228  w \u2208 CF_language g\u2082   :=\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 (\u03bb 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 \u27e8S\u2081, deri_head, deri_tail\u27e9,\n  rcases deri_head with \u27e8rule, ruleok, u, v, h_bef, h_aft\u27e9,\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\u2081S r_rest,\n  {\n    left,\n    rw g\u2081S 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\u2082S r_imposs,\n  {\n    right,\n    rw g\u2082S 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\u2081 : language T) (L\u2082 : language T) :\n  is_CF L\u2081  \u2227  is_CF L\u2082   \u2192   is_CF (L\u2081 + L\u2082)   :=\nbegin\n  rintro \u27e8\u27e8g\u2081, eq_L\u2081\u27e9, \u27e8g\u2082, eq_L\u2082\u27e9\u27e9,\n\n  use union_grammar g\u2081 g\u2082,\n\n  apply set.eq_of_subset_of_subset,\n  {\n    -- prove `L\u2081 + L\u2082 \u2287 `\n    intros w hyp,\n    rw language.mem_add,\n    rw \u2190eq_L\u2081,\n    rw \u2190eq_L\u2082,\n    exact in_language_of_in_union w hyp,\n  },\n  {\n    -- prove `L\u2081 + L\u2082 \u2286 `\n    intros w hyp,\n    cases hyp with case\u2081 case\u2082,\n    {\n      rw \u2190eq_L\u2081 at case\u2081,\n      exact in_union_of_in_first w case\u2081,\n    },\n    {\n      rw \u2190eq_L\u2082 at case\u2082,\n      exact in_union_of_in_second w case\u2082,\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 : \u2200 x : G, of (x\u207b\u00b9) = (of x)\u207b\u00b9 :=\nbegin\n  intro x,\n  repeat {rw \u2190gpow_neg_one},\n  rw of_pow_eq_pow_of,\nend\n\ntheorem inner_aut_eq : \u2200 x y : pq_group G, x \u25b7 y = (of (counit x)) \u25b7 y :=\nbegin\n  intros x,\n  induction x,\n  {\n    rw quot_mk_helper,\n    induction x,\n    {\n      intro y,\n      rw \u2190unit_def,\n      apply congr_arg (\u03bb a, a \u25b7 y),\n      rw monoid_hom.map_one,\n      rw of_1_eq_unit,\n    },\n    {\n      intro y,\n      rw \u2190of_def,\n      rw counit_of,\n    },\n    {\n      intro y,\n\n      rw counit_mul,\n      rw \u2190mul_def,\n      \n      rw mul_rhd,\n      rw x_ih_b,\n      rw x_ih_a,\n\n      rw \u2190mul_rhd,\n      \n\n      induction y,\n      {\n        rw quot_mk_helper at *,\n        induction y,\n        {\n          rw \u2190unit_def,\n          repeat {rw power_quandle.rhd_one},\n        },\n        {\n          repeat {rw \u2190of_def at *},\n          rw rhd_def_group,\n          rw rhd_def_group,\n          have halg_rw_1 : \u2200 a b c : pq_group G, a*b*c*(a*b)\u207b\u00b9 = a*(b*c*b\u207b\u00b9)*a\u207b\u00b9,\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 \u2190mul_def,\n          rw rhd_mul,\n          rw rhd_mul,\n          rw y_ih_a,\n          rw y_ih_b,\n        },\n        {\n          rw \u2190inv_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 \u2190inv_def,\n      have hx := x_ih (\u27e6x_a\u27e7\u207b\u00b9\u25b7\u27e6x_a\u27e7\u207b\u00b9\u25b7y),\n      rw \u2190mul_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 \u2190inv_def,\n      have hx := x_ih (\u27e6x_a\u27e7\u207b\u00b9\u25b7y),\n      rw \u2190mul_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 \u2190mul_rhd ((of _) \u207b\u00b9),\n      simp only [mul_left_inv],\n      rw \u2190hx,\n      rw power_quandle.one_rhd,\n    }\n  },\n  {intro y, refl,},\nend \n\n\ntheorem counit_ker_center : \u2200 a : ((counit : pq_group G \u2192* G).ker), \u2200 b : pq_group G, \u2191a * 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 \u2190rhd_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 \u2192* G).ker) \u2264 subgroup.center (pq_group G) :=\nbegin\n  intros x hx,\n  intro y,\n  apply eq.symm,\n  apply counit_ker_center \u27e8x, hx\u27e9 y,\nend\n\ntheorem counit_ker_abelian : \u2200 a b : ((counit : pq_group G \u2192* 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 : \u2200 a b : ((counit : pq_group G \u2192* G).ker), a \u25b7 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 : \u2191(\u27e8a, ha\u27e9 : (counit : pq_group G \u2192* 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 \u2192* G).ker)) : counit (\u2191a : 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 \u25b7 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 \u25b7 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 \u2192* 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 := \u03bb x y, x,\n  triangle_right := \u03bb 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 := \u03bb x n, \u27e8x.g ^ n\u27e9,\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 : \u2200 a b : (deg G), a \u25b7 b = b :=\nbegin\n  intros a b,\n  refl,\nend\n\nlemma deg_pow_def : \u2200 a : (deg G), \u2200 n : \u2124, a ^ n = \u27e8a.g ^ n\u27e9 :=\nbegin\n  intros a n,\n  refl,\nend\n-/\nnotation `kerc` G := (counit : pq_group G \u2192* G).ker\n\n\ndef \u03c6' : G \u00d7 G \u2192 kerc G := \u03bb \u27e8x, y\u27e9, \u27e8of x * of y * (of (x*y))\u207b\u00b9, 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\u27e9 \n\n\ntheorem \u03c6'_is_cocycle : \u2200 g h k : G, \u03c6'(g, h) * \u03c6'(g * h, k) = \u03c6'(g, h * k) * \u03c6'(h ,k) :=\nbegin\n  intros g h k,\n  rw counit_ker_abelian (\u03c6' (g, h * k))  (\u03c6' (h, k)),\n  unfold \u03c6',\n  ext1,\n  simp only [subgroup.coe_mul, subgroup.coe_mk],\n  have alg_rw : of h * of k * (of (h * k))\u207b\u00b9 * (of g * of (h * k) * (of (g * (h * k)))\u207b\u00b9) = (of h * (of k * ((of (h * k))\u207b\u00b9 * of g * ((of (h * k))\u207b\u00b9)\u207b\u00b9) * (of k)\u207b\u00b9) * (of h)\u207b\u00b9 * of h * of k) * (of (g * (h * k)))\u207b\u00b9,\n  {\n    group,\n  },\n  rw alg_rw,\n  clear alg_rw,\n  rw \u2190rhd_def_group,\n  rw \u2190rhd_def_group,\n  rw \u2190rhd_def_group,\n  rw \u2190mul_assoc g h k,\n  group,\n  rw \u2190of_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) \u2192 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) \u2192* subgroup.center (G) := \u27e8center_LR_morph_fun, begin\n  have one_rw : (1 : subgroup.center (pq_group G)) = \u27e81, _\u27e9 := 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 : (\u27e8x, hx\u27e9 * \u27e8y, hy\u27e9 : subgroup.center (pq_group G)) = \u27e8x * y, _\u27e9 := 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\u27e9\n\n\nnoncomputable theorem counit_ker_iso_center_LR_morph_ker : (counit : pq_group G \u2192* G).ker \u2243* (center_LR_morph : subgroup.center (pq_group G) \u2192* 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 : (\u27e8x, hx\u27e9 * \u27e8y, hy\u27e9 : ((counit : pq_group G \u2192* G).ker)) = \u27e8x * y, _\u27e9 := 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 \u27e8x, _\u27e9 = 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 := \u27e80\u27e9\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 := \u27e8(dt.nanos.fdiv oneDayNanos) + 1\u27e9\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 \u2227 d <= m.numDays y := by decide) : NaiveDateTime := \n    \u27e8oneDayNanos * ((Ymd.mk y m d hd.left hd.right).toScalarDate.day - 1)\u27e9 \n\ndef NaiveDateTime.fromYmdsn \n  (y : Year) \n  (m : Month) \n  (d : Nat) \n  (s : Nat)\n  (n : Nat)\n  (hd : 1 <= d \u2227 d <= m.numDays y := by decide) : NaiveDateTime := \n    \u27e8(NaiveDateTime.fromYmd y m d hd).nanos + (oneSecondNanos * s) + n\u27e9 \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 : \u2200 {d1 d2 : NaiveDateTime} (h : d1.nanos = d2.nanos), d1 = d2\n| \u27e8_\u27e9, _, rfl => rfl\n\ntheorem NaiveDateTime.val_ne_of_ne : \u2200 {d1 d2 : NaiveDateTime} (h : d1 \u2260 d2), d1.nanos \u2260 d2.nanos\n| \u27e8x\u27e9, \u27e8y\u27e9, 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\u2081 d\u2082 : NaiveDateTime) : (d\u2081 <= d\u2082) = (d\u2081.nanos <= d\u2082.nanos) := rfl\n@[simp] theorem NaiveDateTime.lt_def (d\u2081 d\u2082 : NaiveDateTime) : (d\u2081 < d\u2082) = (d\u2081.nanos < d\u2082.nanos) := rfl\n\ninstance instDecidableLENaiveDateTime (d\u2081 d\u2082 : NaiveDateTime) : Decidable (d\u2081 <= d\u2082) := inferInstanceAs (Decidable <| d\u2081.nanos <= d\u2082.nanos)\ninstance instDecidableLTNaiveDateTime (d\u2081 d\u2082 : NaiveDateTime) : Decidable (d\u2081 < d\u2082) := inferInstanceAs (Decidable <| d\u2081.nanos < d\u2082.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 \u2192 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 \u27e8y, m, d, _, _\u27e9 := dt.toYmd\n    let t : String := ToString.toString <| NaiveClockTime.mk (Fin.ofInt'' (dt.nanos % (\u2191oneDayNanos)))\n    s!\"{y}/{m.toNat}/{d}; {t}\"\n\n@[reducible]\ndef NaiveDateTime.dateEq : NaiveDateTime \u2192 NaiveDateTime \u2192 Prop\n| n\u2081, n\u2082 => n\u2081.toScalarDate = n\u2082.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  \u27e8NaiveDateTime.dateEq, NaiveDateTime.dateEq.Equivalence\u27e9\n\ninstance (d\u2081 d\u2082 : NaiveDateTime) : Decidable <| d\u2081.dateEq d\u2082 := inferInstance\n\ninstance {n : Nat} : OfNat NaiveDateTime n where\n  ofNat := \u27e8n\u27e9\n\ninstance : HAdd NaiveDateTime SignedDuration NaiveDateTime where\n  hAdd da du := \u27e8da.nanos + du.val\u27e9\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 = \u27e8d.nanos + dur.val\u27e9 := rfl\ntheorem NaiveDateTime.hAdd_signed_def_rev (d : NaiveDateTime) (dur : SignedDuration) : dur + d = \u27e8d.nanos + dur.val\u27e9 := 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 := \u27e8da.nanos + du.val\u27e9\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 = \u27e8d.nanos + dur.val\u27e9 := rfl\n\ninstance : HSub NaiveDateTime UnsignedDuration NaiveDateTime where\n  hSub da du := \u27e8da.nanos - du.val\u27e9\n\ntheorem NaiveDateTime.hSub_unsigned_def (d : NaiveDateTime) (dur : UnsignedDuration) : d - dur = \u27e8d.nanos - dur.val\u27e9 := 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  \u27e8days + clockTime.nanos.val\u27e9\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 \u27f6 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 \u226b (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 \u27e8ring_hom.injective _, _\u27e9,\n  intro y,\n  obtain \u27e8y' : (Spec.structure_sheaf R).presheaf.stalk x, rfl\u27e9 := ideal.quotient.mk_surjective y,\n  obtain \u27e8y : R, s, rfl\u27e9 := is_localization.mk'_surjective x.as_ideal.prime_compl y',\n  have : (s : R) \u2260 0 := \u03bb e, s.prop (e.symm \u25b8 x.as_ideal.zero_mem),\n  refine \u27e8(y/s : _), _\u27e9,\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 \u226b X.residue_field_of_eq e =\n    X.presheaf.stalk_specializes (specializes_of_eq e) \u226b X.stalk_residue x := rfl\n\n@[simp, reassoc]\nlemma Scheme.stalk_residue_map {X Y : Scheme} (f : X \u27f6 Y) {x : X.carrier} : \n  Y.stalk_residue _ \u226b f.map_residue_field x = PresheafedSpace.stalk_map f.1 x \u226b X.stalk_residue x :=\nrfl\n\nlemma is_affine.hom_ext {X Y : Scheme} [is_affine Y] (f g : X \u27f6 Y) (e : Scheme.\u0393.map f.op = Scheme.\u0393.map g.op) :\n  f = g :=\nbegin\n  rw [\u2190 cancel_mono (\u0393_Spec.adjunction.unit.app Y), \u2190 \u0393_Spec.adjunction.unit_naturality f, \u2190 \u0393_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 }) \u226b 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 _ _ _ _ _ _ \u0393_Spec.adjunction ((Scheme.Spec.obj (op R)).restrict U.open_embedding),\n  rw [functor.right_op_map, \u2190 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, \u2190 this],\n  erw \u0393_Spec.adjunction.counit_naturality_assoc,\n  rw [\u2190 is_iso.comp_inv_eq, \u2190 cancel_mono (\u0393_Spec.adjunction.counit.app $ op $ CommRing.of R)],\n  conv_rhs { erw (\u0393_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.\u0393, inv_eq_to_hom] },\n  apply quiver.hom.unop_inj,\n  simp only [algebraic_geometry.\u0393_Spec.LocallyRingedSpace_adjunction_counit, nat_trans.op_app, quiver.hom.unop_op,\n    unop_inv, Scheme.Spec_map_2, Scheme.\u0393_map, Spec_\u0393_identity_inv_app, category.assoc,\n    \u0393_Spec.adjunction_counit_app, unop_comp, eq_to_hom_refl, to_Spec_\u0393, 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 _ _)  \u226b \n    (X.from_Spec_residue_field x).map_residue_field s = structure_sheaf.to_stalk _ s \u226b\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 [\u2190 (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 \u27e8ring_hom.injective _, _\u27e9,\n  intro y,\n  obtain \u27e8y' : (Spec.structure_sheaf _).presheaf.stalk s, rfl\u27e9 := ideal.quotient.mk_surjective y,\n  obtain \u27e8y, rfl\u27e9 : \u2203 y : X.residue_field x, structure_sheaf.to_stalk _ s y = y',\n  { obtain \u27e8y : X.residue_field x, t, rfl\u27e9 := is_localization.mk'_surjective s.as_ideal.prime_compl y',\n    refine \u27e8y/t.1, _\u27e9,\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, \u03bb e, t.prop (e.symm \u25b8 s.as_ideal.zero_mem)] },\n  refine \u27e8X.residue_field_of_eq (Scheme.from_Spec_residue_field_base _ _) y, _\u27e9,\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\u27e8\u27e8X.residue_field_of_eq e.symm, by simp, by simp\u27e9\u27e9\n\ndef Scheme.hom.fiber (f : X \u27f6 Y) (y : Y.carrier) : Scheme :=\npullback f (Y.from_Spec_residue_field y)\n\n@[derive is_preimmersion]\ndef Scheme.hom.fiber_\u03b9 (f : X \u27f6 Y) (y : Y.carrier) : f.fiber y \u27f6 X :=\npullback.fst\n\ndef Scheme.hom.fiber_to_residue_field (f : X \u27f6 Y) (y : Y.carrier) :\n  f.fiber y \u27f6 Scheme.Spec.obj (op $ Y.residue_field y) :=\npullback.snd\n\ndef Scheme.hom.fiber_residue_field_tensor_iso (f : X \u27f6 Y) (y : Y.carrier)\n  (T : pullback.triplet f (Y.from_Spec_residue_field y)) : \n  T.residue_field_tensor \u2245 X.residue_field T.x :=\n(as_iso pushout.inl).symm\n\ninstance (f : X \u27f6 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 \u27f6 Y) (y : Y.carrier) :\n  (f.fiber y).carrier \u2243\u209c { x : X.carrier // f.1.base x = y } :=\nbegin\n  refine (homeomorph.of_embedding _ (is_preimmersion.base_embedding $ f.fiber_\u03b9 y)).trans\n    (homeomorph.set_congr _),\n  ext x,\n  rw [Scheme.hom.fiber_\u03b9, 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 \u27f6 Y) (y : Y.carrier) (x) :\n  (f.fiber_carrier y x : X.carrier) = (f.fiber_\u03b9 y).1.base x := rfl\n\nlemma Scheme.hom.fiber_\u03b9_coe (f : X \u27f6 Y) (y : Y.carrier) :\n  \u21d1(f.fiber_\u03b9 y).1.base = (coe \u2218 (f.fiber_carrier y) : _ \u2192 X.carrier) :=\nfunext $ \u03bb x, (f.fiber_carrier_apply y x).symm\n\nlemma Scheme.hom.range_fiber_\u03b9 (f : X \u27f6 Y) (y : Y.carrier) :\n  set.range (f.fiber_\u03b9 y).1.base = f.1.base \u207b\u00b9' {y} :=\nbegin\n  rw [Scheme.hom.fiber_\u03b9_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 \u27f6 Y) (x : X.carrier) : \n  Scheme.Spec.obj (op $ X.residue_field x) \u27f6 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_\u03b9 (f : X \u27f6 Y) (x : X.carrier) : \n  f.Spec_residue_field_to_fiber x \u226b f.fiber_\u03b9 _ = 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 \u27f6 Y) (x : X.carrier) : \n  f.Spec_residue_field_to_fiber x \u226b f.fiber_to_residue_field _ =\n    Scheme.Spec.map (f.map_residue_field x).op :=\npullback.lift_snd _ _ _\n\ninstance (f : X \u27f6 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 \u2190 f.Spec_residue_field_to_fiber_\u03b9 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 : \u2115 \u2192 \u2115 \u2192 \u2115 :=\n  sorry\n\n@[simp] theorem choose_zero_right (n : \u2115) : choose n 0 = 1 :=\n  nat.cases_on n (Eq.refl (choose 0 0)) fun (n : \u2115) => Eq.refl (choose (Nat.succ n) 0)\n\n@[simp] theorem choose_zero_succ (k : \u2115) : choose 0 (Nat.succ k) = 0 :=\n  rfl\n\ntheorem choose_succ_succ (n : \u2115) (k : \u2115) : 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 : \u2115} {k : \u2115} : n < k \u2192 choose n k = 0 := sorry\n\n@[simp] theorem choose_self (n : \u2115) : choose n n = 1 := sorry\n\n@[simp] theorem choose_succ_self (n : \u2115) : choose n (Nat.succ n) = 0 :=\n  choose_eq_zero_of_lt (lt_succ_self n)\n\n@[simp] theorem choose_one_right (n : \u2115) : 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 : \u2115) : (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 : \u2115) : choose n (bit0 1) = n * (n - 1) / bit0 1 := sorry\n\ntheorem choose_pos {n : \u2115} {k : \u2115} : k \u2264 n \u2192 0 < choose n k := sorry\n\ntheorem succ_mul_choose_eq (n : \u2115) (k : \u2115) : 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 : \u2115} {k : \u2115} : k \u2264 n \u2192 choose n k * factorial k * factorial (n - k) = factorial n := sorry\n\ntheorem choose_eq_factorial_div_factorial {n : \u2115} {k : \u2115} (hk : k \u2264 n) : choose n k = factorial n / (factorial k * factorial (n - k)) := sorry\n\ntheorem factorial_mul_factorial_dvd_factorial {n : \u2115} {k : \u2115} (hk : k \u2264 n) : factorial k * factorial (n - k) \u2223 factorial n := sorry\n\n@[simp] theorem choose_symm {n : \u2115} {k : \u2115} (hk : k \u2264 n) : choose n (n - k) = choose n k := sorry\n\ntheorem choose_symm_of_eq_add {n : \u2115} {a : \u2115} {b : \u2115} (h : n = a + b) : choose n a = choose n b := sorry\n\ntheorem choose_symm_add {a : \u2115} {b : \u2115} : choose (a + b) a = choose (a + b) b :=\n  choose_symm_of_eq_add rfl\n\ntheorem choose_symm_half (m : \u2115) : choose (bit0 1 * m + 1) (m + 1) = choose (bit0 1 * m + 1) m := sorry\n\ntheorem choose_succ_right_eq (n : \u2115) (k : \u2115) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := sorry\n\n@[simp] theorem choose_succ_self_right (n : \u2115) : choose (n + 1) n = n + 1 := sorry\n\ntheorem choose_mul_succ_eq (n : \u2115) (k : \u2115) : 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 : \u2115} {n : \u2115} (h : r < n / bit0 1) : choose n r \u2264 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 : \u2115) (n : \u2115) : choose n r \u2264 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 : \u2102) :\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 {\u03b1 \u03b2 : Type _}\n\nnamespace Prod\n\nvariable [AddMonoidWithOne \u03b1] [AddMonoidWithOne \u03b2]\n\ninstance : AddMonoidWithOne (\u03b1 \u00d7 \u03b2) :=\n  { Prod.addMonoid, Prod.hasOne with\n    natCast := fun n => (n, n)\n    natCast_zero := congr_arg\u2082 Prod.mk Nat.cast_zero Nat.cast_zero\n    natCast_succ := fun n => congr_arg\u2082 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : AddMonoidWithOne.{u1} \u03b1] [_inst_2 : AddMonoidWithOne.{u2} \u03b2] (n : Nat), Eq.{succ u1} \u03b1 (Prod.fst.{u1, u2} \u03b1 \u03b2 ((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} \u03b1 \u03b2) (HasLiftT.mk.{1, max (succ u1) (succ u2)} Nat (Prod.{u1, u2} \u03b1 \u03b2) (CoeTC\u2093.coe.{1, max (succ u1) (succ u2)} Nat (Prod.{u1, u2} \u03b1 \u03b2) (Nat.castCoe.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (AddMonoidWithOne.toNatCast.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.addMonoidWithOne.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2))))) n)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 _inst_1)))) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : AddMonoidWithOne.{u2} \u03b1] [_inst_2 : AddMonoidWithOne.{u1} \u03b2] (n : Nat), Eq.{succ u2} \u03b1 (Prod.fst.{u2, u1} \u03b1 \u03b2 (Nat.cast.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (AddMonoidWithOne.toNatCast.{max u2 u1} (Prod.{u2, u1} \u03b1 \u03b2) (Prod.instAddMonoidWithOneProd.{u2, u1} \u03b1 \u03b2 _inst_1 _inst_2)) n)) (Nat.cast.{u2} \u03b1 (AddMonoidWithOne.toNatCast.{u2} \u03b1 _inst_1) n)\nCase conversion may be inaccurate. Consider using '#align prod.fst_nat_cast Prod.fst_natCast\u2093'. -/\n@[simp]\ntheorem fst_natCast (n : \u2115) : (n : \u03b1 \u00d7 \u03b2).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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : AddMonoidWithOne.{u1} \u03b1] [_inst_2 : AddMonoidWithOne.{u2} \u03b2] (n : Nat), Eq.{succ u2} \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 ((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} \u03b1 \u03b2) (HasLiftT.mk.{1, max (succ u1) (succ u2)} Nat (Prod.{u1, u2} \u03b1 \u03b2) (CoeTC\u2093.coe.{1, max (succ u1) (succ u2)} Nat (Prod.{u1, u2} \u03b1 \u03b2) (Nat.castCoe.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (AddMonoidWithOne.toNatCast.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.addMonoidWithOne.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2))))) n)) ((fun (a : Type) (b : Type.{u2}) [self : HasLiftT.{1, succ u2} a b] => self.0) Nat \u03b2 (HasLiftT.mk.{1, succ u2} Nat \u03b2 (CoeTC\u2093.coe.{1, succ u2} Nat \u03b2 (Nat.castCoe.{u2} \u03b2 (AddMonoidWithOne.toNatCast.{u2} \u03b2 _inst_2)))) n)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : AddMonoidWithOne.{u1} \u03b1] [_inst_2 : AddMonoidWithOne.{u2} \u03b2] (n : Nat), Eq.{succ u2} \u03b2 (Prod.snd.{u1, u2} \u03b1 \u03b2 (Nat.cast.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (AddMonoidWithOne.toNatCast.{max u1 u2} (Prod.{u1, u2} \u03b1 \u03b2) (Prod.instAddMonoidWithOneProd.{u1, u2} \u03b1 \u03b2 _inst_1 _inst_2)) n)) (Nat.cast.{u2} \u03b2 (AddMonoidWithOne.toNatCast.{u2} \u03b2 _inst_2) n)\nCase conversion may be inaccurate. Consider using '#align prod.snd_nat_cast Prod.snd_natCast\u2093'. -/\n@[simp]\ntheorem snd_natCast (n : \u2115) : (n : \u03b1 \u00d7 \u03b2).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 `\u03a6 : mv_polynomial idx \u2124` over the integers,\nwith polynomials variables indexed by an arbitrary type `idx`.\n\nThen there exists a unique family of polynomials `\u03c6 : \u2115 \u2192 mv_polynomial (idx \u00d7 \u2115) \u03a6`\nsuch that for all `n : \u2115` we have (`witt_structure_int_exists_unique`)\n```\nbind\u2081 \u03c6 (witt_polynomial p \u2124 n) = bind\u2081 (\u03bb i, (rename (prod.mk i) (witt_polynomial p \u2124 n))) \u03a6\n```\nIn other words: evaluating the `n`-th Witt polynomial on the family `\u03c6`\nis the same as evaluating `\u03a6` 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 \u201cWitt structure polynomials\u201d. 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 `\u03a6 = X tt + X ff` resp. `\u03a6 = X tt * X ff`\nwe obtain families of polynomials `witt_add` resp. `witt_mul`\n(with type `\u2115 \u2192 mv_polynomial (bool \u00d7 \u2115) \u2124`) 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 \u2115 \u211a`.\nWe therefore obtain a family of polynomials `witt_structure_rat \u03a6`\nfor every `\u03a6 : mv_polynomial idx \u211a`.\n\nIf `\u03a6` has integer coefficients, then the polynomials `witt_structure_rat \u03a6 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 \u03a6 n` from the integers to the rationals,\none obtains `witt_structure_rat \u03a6 n`.\nUltimately, the proof of `map_witt_structure_int` relies on\n```\ndvd_sub_pow_of_dvd_sub {R : Type*} [comm_ring R] {p : \u2115} {a b : R} :\n    (p : R) \u2223 a - b \u2192 \u2200 (k : \u2115), (p : R) ^ (k + 1) \u2223 a ^ p ^ k - b ^ p ^ k\n```\n\n## Main results\n\n* `witt_structure_rat \u03a6`: the family of polynomials `\u2115 \u2192 mv_polynomial (idx \u00d7 \u2115) \u211a`\n  associated with `\u03a6 : mv_polynomial idx \u211a` 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 \u03a6`: the family of polynomials `\u2115 \u2192 mv_polynomial (idx \u00d7 \u2115) \u2124`\n  associated with `\u03a6 : mv_polynomial idx \u2124` and satisfying the property explained above.\n* `map_witt_structure_int`: the proof that the integral polynomials `with_structure_int \u03a6`\n  are equal to `witt_structure_rat \u03a6` 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 `\u03bb 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 \u03a6` is a family of polynomials `\u2115 \u2192 mv_polynomial (idx \u00d7 \u2115) \u211a`\nthat are uniquely characterised by the property that\n```\nbind\u2081 (witt_structure_rat p \u03a6) (witt_polynomial p \u211a n) =\nbind\u2081 (\u03bb i, (rename (prod.mk i) (witt_polynomial p \u211a n))) \u03a6\n```\nIn other words: evaluating the `n`-th Witt polynomial on the family `witt_structure_rat \u03a6`\nis the same as evaluating `\u03a6` 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 : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u211a) (n : \u2115) : mv_polynomial (idx \u00d7 \u2115) \u211a :=\n  coe_fn\n    (mv_polynomial.bind\u2081\n      fun (k : \u2115) =>\n        coe_fn (mv_polynomial.bind\u2081 fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p \u211a k)) \u03a6)\n    (X_in_terms_of_W p \u211a n)\n\ntheorem witt_structure_rat_prop (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u211a) (n : \u2115) : coe_fn (mv_polynomial.bind\u2081 (witt_structure_rat p \u03a6)) (witt_polynomial p \u211a n) =\n  coe_fn (mv_polynomial.bind\u2081 fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p \u211a n)) \u03a6 := sorry\n\ntheorem witt_structure_rat_exists_unique (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u211a) : exists_unique\n  fun (\u03c6 : \u2115 \u2192 mv_polynomial (idx \u00d7 \u2115) \u211a) =>\n    \u2200 (n : \u2115),\n      coe_fn (mv_polynomial.bind\u2081 \u03c6) (witt_polynomial p \u211a n) =\n        coe_fn (mv_polynomial.bind\u2081 fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p \u211a n))\n          \u03a6 := sorry\n\ntheorem witt_structure_rat_rec_aux (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u211a) (n : \u2115) : witt_structure_rat p \u03a6 n * coe_fn mv_polynomial.C (\u2191p ^ n) =\n  coe_fn\n      (mv_polynomial.bind\u2081 fun (b : idx) => coe_fn (mv_polynomial.rename fun (i : \u2115) => (b, i)) (witt_polynomial p \u211a n))\n      \u03a6 -\n    finset.sum (finset.range n) fun (i : \u2115) => coe_fn mv_polynomial.C (\u2191p ^ i) * witt_structure_rat p \u03a6 i ^ p ^ (n - i) := sorry\n\n/-- Write `witt_structure_rat p \u03c6 n` in terms of `witt_structure_rat p \u03c6 i` for `i < n`. -/\ntheorem witt_structure_rat_rec (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u211a) (n : \u2115) : witt_structure_rat p \u03a6 n =\n  coe_fn mv_polynomial.C (1 / \u2191p ^ n) *\n    (coe_fn\n        (mv_polynomial.bind\u2081\n          fun (b : idx) => coe_fn (mv_polynomial.rename fun (i : \u2115) => (b, i)) (witt_polynomial p \u211a n))\n        \u03a6 -\n      finset.sum (finset.range n)\n        fun (i : \u2115) => coe_fn mv_polynomial.C (\u2191p ^ i) * witt_structure_rat p \u03a6 i ^ p ^ (n - i)) := sorry\n\n/-- `witt_structure_int \u03a6` is a family of polynomials `\u2115 \u2192 mv_polynomial (idx \u00d7 \u2115) \u211a`\nthat are uniquely characterised by the property that\n```\nbind\u2081 (witt_structure_int p \u03a6) (witt_polynomial p \u211a n) =\nbind\u2081 (\u03bb i, (rename (prod.mk i) (witt_polynomial p \u211a n))) \u03a6\n```\nIn other words: evaluating the `n`-th Witt polynomial on the family `witt_structure_int \u03a6`\nis the same as evaluating `\u03a6` 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 : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) (n : \u2115) : mv_polynomial (idx \u00d7 \u2115) \u2124 :=\n  finsupp.map_range rat.num sorry (witt_structure_rat p (coe_fn (mv_polynomial.map (int.cast_ring_hom \u211a)) \u03a6) n)\n\ntheorem bind\u2081_rename_expand_witt_polynomial {p : \u2115} {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) (n : \u2115) (IH : \u2200 (m : \u2115),\n  m < n + 1 \u2192\n    coe_fn (mv_polynomial.map (int.cast_ring_hom \u211a)) (witt_structure_int p \u03a6 m) =\n      witt_structure_rat p (coe_fn (mv_polynomial.map (int.cast_ring_hom \u211a)) \u03a6) m) : coe_fn\n    (mv_polynomial.bind\u2081\n      fun (b : idx) =>\n        coe_fn (mv_polynomial.rename fun (i : \u2115) => (b, i)) (coe_fn (mv_polynomial.expand p) (witt_polynomial p \u2124 n)))\n    \u03a6 =\n  coe_fn (mv_polynomial.bind\u2081 fun (i : \u2115) => coe_fn (mv_polynomial.expand p) (witt_structure_int p \u03a6 i))\n    (witt_polynomial p \u2124 n) := sorry\n\ntheorem C_p_pow_dvd_bind\u2081_rename_witt_polynomial_sub_sum {p : \u2115} {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) (n : \u2115) (IH : \u2200 (m : \u2115),\n  m < n \u2192\n    coe_fn (mv_polynomial.map (int.cast_ring_hom \u211a)) (witt_structure_int p \u03a6 m) =\n      witt_structure_rat p (coe_fn (mv_polynomial.map (int.cast_ring_hom \u211a)) \u03a6) m) : coe_fn mv_polynomial.C \u2191(p ^ n) \u2223\n  coe_fn\n      (mv_polynomial.bind\u2081 fun (b : idx) => coe_fn (mv_polynomial.rename fun (i : \u2115) => (b, i)) (witt_polynomial p \u2124 n))\n      \u03a6 -\n    finset.sum (finset.range n) fun (i : \u2115) => coe_fn mv_polynomial.C (\u2191p ^ i) * witt_structure_int p \u03a6 i ^ p ^ (n - i) := sorry\n\n@[simp] theorem map_witt_structure_int (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) (n : \u2115) : coe_fn (mv_polynomial.map (int.cast_ring_hom \u211a)) (witt_structure_int p \u03a6 n) =\n  witt_structure_rat p (coe_fn (mv_polynomial.map (int.cast_ring_hom \u211a)) \u03a6) n := sorry\n\ntheorem witt_structure_int_prop (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) (n : \u2115) : coe_fn (mv_polynomial.bind\u2081 (witt_structure_int p \u03a6)) (witt_polynomial p \u2124 n) =\n  coe_fn (mv_polynomial.bind\u2081 fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p \u2124 n)) \u03a6 := sorry\n\ntheorem eq_witt_structure_int (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) (\u03c6 : \u2115 \u2192 mv_polynomial (idx \u00d7 \u2115) \u2124) (h : \u2200 (n : \u2115),\n  coe_fn (mv_polynomial.bind\u2081 \u03c6) (witt_polynomial p \u2124 n) =\n    coe_fn (mv_polynomial.bind\u2081 fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p \u2124 n)) \u03a6) : \u03c6 = witt_structure_int p \u03a6 := sorry\n\ntheorem witt_structure_int_exists_unique (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) : exists_unique\n  fun (\u03c6 : \u2115 \u2192 mv_polynomial (idx \u00d7 \u2115) \u2124) =>\n    \u2200 (n : \u2115),\n      coe_fn (mv_polynomial.bind\u2081 \u03c6) (witt_polynomial p \u2124 n) =\n        coe_fn (mv_polynomial.bind\u2081 fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p \u2124 n))\n          \u03a6 :=\n  Exists.intro (witt_structure_int p \u03a6) { left := witt_structure_int_prop p \u03a6, right := eq_witt_structure_int p \u03a6 }\n\ntheorem witt_structure_prop (p : \u2115) {R : Type u_1} {idx : Type u_2} [comm_ring R] [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) (n : \u2115) : coe_fn (mv_polynomial.aeval fun (i : \u2115) => coe_fn (mv_polynomial.map (int.cast_ring_hom R)) (witt_structure_int p \u03a6 i))\n    (witt_polynomial p \u2124 n) =\n  coe_fn (mv_polynomial.aeval fun (i : idx) => coe_fn (mv_polynomial.rename (Prod.mk i)) (witt_polynomial p R n)) \u03a6 := sorry\n\ntheorem witt_structure_int_rename (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] {\u03c3 : Type u_1} (\u03a6 : mv_polynomial idx \u2124) (f : idx \u2192 \u03c3) (n : \u2115) : witt_structure_int p (coe_fn (mv_polynomial.rename f) \u03a6) n =\n  coe_fn (mv_polynomial.rename (prod.map f id)) (witt_structure_int p \u03a6 n) := sorry\n\n@[simp] theorem constant_coeff_witt_structure_rat_zero (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u211a) : coe_fn mv_polynomial.constant_coeff (witt_structure_rat p \u03a6 0) = coe_fn mv_polynomial.constant_coeff \u03a6 := sorry\n\ntheorem constant_coeff_witt_structure_rat (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u211a) (h : coe_fn mv_polynomial.constant_coeff \u03a6 = 0) (n : \u2115) : coe_fn mv_polynomial.constant_coeff (witt_structure_rat p \u03a6 n) = 0 := sorry\n\n@[simp] theorem constant_coeff_witt_structure_int_zero (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) : coe_fn mv_polynomial.constant_coeff (witt_structure_int p \u03a6 0) = coe_fn mv_polynomial.constant_coeff \u03a6 := sorry\n\ntheorem constant_coeff_witt_structure_int (p : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] (\u03a6 : mv_polynomial idx \u2124) (h : coe_fn mv_polynomial.constant_coeff \u03a6 = 0) (n : \u2115) : coe_fn mv_polynomial.constant_coeff (witt_structure_int p \u03a6 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 : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] [fintype idx] (\u03a6 : mv_polynomial idx \u211a) (n : \u2115) : mv_polynomial.vars (witt_structure_rat p \u03a6 n) \u2286 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 : \u2115) {idx : Type u_2} [hp : fact (nat.prime p)] [fintype idx] (\u03a6 : mv_polynomial idx \u2124) (n : \u2115) : mv_polynomial.vars (witt_structure_int p \u03a6 n) \u2286 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 \u2192 pos_num \u2192 pos_num := sorry\n\ndef land : pos_num \u2192 pos_num \u2192 num := sorry\n\ndef ldiff : pos_num \u2192 pos_num \u2192 num := sorry\n\ndef lxor : pos_num \u2192 pos_num \u2192 num := sorry\n\ndef test_bit : pos_num \u2192 \u2115 \u2192 Bool := sorry\n\ndef one_bits : pos_num \u2192 \u2115 \u2192 List \u2115 := sorry\n\ndef shiftl (p : pos_num) : \u2115 \u2192 pos_num := sorry\n\ndef shiftr : pos_num \u2192 \u2115 \u2192 num := sorry\n\nend pos_num\n\n\nnamespace num\n\n\ndef lor : num \u2192 num \u2192 num := sorry\n\ndef land : num \u2192 num \u2192 num := sorry\n\ndef ldiff : num \u2192 num \u2192 num := sorry\n\ndef lxor : num \u2192 num \u2192 num := sorry\n\ndef shiftl : num \u2192 \u2115 \u2192 num := sorry\n\ndef shiftr : num \u2192 \u2115 \u2192 num := sorry\n\ndef test_bit : num \u2192 \u2115 \u2192 Bool := sorry\n\ndef one_bits : num \u2192 List \u2115 := 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 \u2192 nzsnum\n| bit : Bool \u2192 nzsnum \u2192 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 \u2192 snum\n| nz : nzsnum \u2192 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 \u2192 Bool := sorry\n\ndef not : nzsnum \u2192 nzsnum := sorry\n\nprefix:40 \"~\" => Mathlib.nzsnum.not\n\ndef bit0 : nzsnum \u2192 nzsnum := bit false\n\ndef bit1 : nzsnum \u2192 nzsnum := bit tt\n\ndef head : nzsnum \u2192 Bool := sorry\n\ndef tail : nzsnum \u2192 snum := sorry\n\nend nzsnum\n\n\nnamespace snum\n\n\ndef sign : snum \u2192 Bool := sorry\n\ndef not : snum \u2192 snum := sorry\n\nprefix:40 \"~\" => Mathlib.snum.not\n\ndef bit : Bool \u2192 snum \u2192 snum := sorry\n\ninfixr:67 \" :: \" => Mathlib.snum.bit\n\ndef bit0 : snum \u2192 snum := bit false\n\ndef bit1 : snum \u2192 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) = \u2191(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 \u2192 Sort u_1} (z : (b : Bool) \u2192 C (snum.zero b))\n    (s : (b : Bool) \u2192 (p : snum) \u2192 C p \u2192 C (b :: p)) (p : nzsnum) : C \u2191p :=\n  sorry\n\nend nzsnum\n\n\nnamespace snum\n\n\ndef head : snum \u2192 Bool := sorry\n\ndef tail : snum \u2192 snum := sorry\n\ndef drec' {C : snum \u2192 Sort u_1} (z : (b : Bool) \u2192 C (zero b))\n    (s : (b : Bool) \u2192 (p : snum) \u2192 C p \u2192 C (b :: p)) (p : snum) : C p :=\n  sorry\n\ndef rec' {\u03b1 : Sort u_1} (z : Bool \u2192 \u03b1) (s : Bool \u2192 snum \u2192 \u03b1 \u2192 \u03b1) : snum \u2192 \u03b1 := drec' z s\n\ndef test_bit : \u2115 \u2192 snum \u2192 Bool := sorry\n\ndef succ : snum \u2192 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 \u2192 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 \u2192 Bool \u2192 snum \u2192 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 \u2192 (n : \u2115) \u2192 vector Bool n := sorry\n\ndef cadd : snum \u2192 snum \u2192 Bool \u2192 snum :=\n  rec' (fun (a : Bool) (p : snum) (c : Bool) => czadd c a p)\n    fun (a : Bool) (p : snum) (IH : snum \u2192 Bool \u2192 snum) =>\n      rec' (fun (b c : Bool) => czadd c b (a :: p))\n        fun (b : Bool) (q : snum) (_x : Bool \u2192 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 \u2192 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 \u2192 G \u2192 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\"\u207b\u00b9\" => 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 : \u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 (g * h * g\u207b\u00b9) \u2208 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 \u2192 G \u2192 G} [grpG : Group G lawG]\nvariable {H : Type} {lawH : H \u2192 H \u2192 H} [grpH : Group H lawH]\nvariable (\u03c6 : Morphism G lawG H lawH)\n\nlocal infixl:70 \" * \" => id' lawG\nlocal notation g\"\u207b\u00b9\" => grpG.inv g\nlocal infix:70 \" * \" => id' lawH\nlocal notation g\"\u207b\u00b9\" => grpH.inv g\n\ndef kernel : Set G := \u03bb g => \u03c6 g = grpH.one'\n\ndef kernelIsSubgroup : Subgroup G lawG (kernel \u03c6) := Subgroup.ofInhabitedMulInvStable lawG\n  (\u27e8 grpG.one', \u03c6.respectOne \u27e9)\n  (\u03bb {h} hIn h' h'In => by simp [kernel, Set.mem]; rw [hIn, h'In]; simp )\n\ninstance kernelIsNormal : Subgroup.Normal lawG (\u03c6.kernel) where\n  stable := \u03bb g k kIn => by\n    suffices p : \u03c6 (g * (k : G) * g\u207b\u00b9) = grpH.one'\n    by exact p\n    have p : \u03c6 k = grpH.one' := kIn\n    simp [\u03c6.respectMul, p]\n\nend Morphism\n\nnamespace Subgroup\n\nvariable {G : Type} {law : G \u2192 G \u2192 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\"\u207b\u00b9\" => 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\u2081 :\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 g * h * g\u207b\u00b9 \u2208 H) \u2194\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 \u2203 h', h' \u2208 H \u2227 g * h = h' * g) :=\nby\n  apply Iff.intro\n  focus\n    intro p g h hIn\n    suffices p : \u2203 h', h' \u2208 H \u2227 g * h * g\u207b\u00b9 = h'\n    from match p with\n      | \u27e8 h', \u27e8 h'In, p \u27e9 \u27e9 => \u27e8 h', \u27e8 h'In, by simp [p.symm] \u27e9 \u27e9\n    exact \u27e8 g * h * g\u207b\u00b9, \u27e8 p g hIn, rfl \u27e9 \u27e9\n  focus\n    intro p g h hIn\n    match p g hIn with\n    | \u27e8 h', \u27e8 h'In, p \u27e9 \u27e9 =>\n      rw [show g * h * g\u207b\u00b9 = h' by simp [p]]\n      simp [h'In]\n\ntheorem normalIff.lemma\u2082 :\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 \u2203 h', h' \u2208 H \u2227 g * h = h' * g) \u2192\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 \u2203 h', h' \u2208 H \u2227 g * h' = h * g) :=\nby\n  intro h g h\u2080 h\u2080In\n  match h (g\u207b\u00b9) (sg.invMem h\u2080In) with\n  | \u27e8 h', \u27e8 h'In, p \u27e9 \u27e9 =>\n    have \u2200 k k' : G, k = k' \u2192 k\u207b\u00b9 = k'\u207b\u00b9 by intro _ _ h; rw [h]\n    have p' := this _ _ p\n    simp at p'\n    exact \u27e8 h'\u207b\u00b9, \u27e8 sg.invMem h'In, p'.symm \u27e9 \u27e9\n\ntheorem normalIff.lemma\u2083 :\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 \u2203 h', h' \u2208 H \u2227 g * h = h' * g) \u2192\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 \u2203 h', h' \u2208 H \u2227 g * h' = h * g) \u2192\n  \u2200 (P : G \u2192 Prop), P \u2208 leftClasses law H \u2192 P \u2208 rightClasses law H :=\nby\n  intro h\u2080 h\u2081 p h'\n  match h' with\n  | \u27e8 g, h' \u27e9 =>\n    apply Exists.intro g\n    rw [h']\n    simp [Action.Remarkable.onSelf]\n    exact funext <| \u03bb x => propext \u27e8 (\u03bb h'' => match h'' with\n      | \u27e8 k, \u27e8 kIn, h'' \u27e9 \u27e9 => match h\u2080 g kIn with\n        | \u27e8 k', \u27e8 k'In, h''' \u27e9 \u27e9 => \u27e8 k', \u27e8 k'In,\n          by rw [h'']; simp [id'] at h'''; simp [id']; rw [h''']; rfl \u27e9 \u27e9),\n      (\u03bb h'' => match h'' with\n      | \u27e8 k, \u27e8 kIn, h'' \u27e9 \u27e9 => match h\u2081 g kIn with\n        | \u27e8 k', \u27e8 k'In, h''' \u27e9 \u27e9 => \u27e8 k', \u27e8 k'In,\n          by rw [h'']; simp [id'] at h'''; simp [id']; rw [h''']; rfl \u27e9 \u27e9) \u27e9\n\ntheorem normalIff.lemma\u2084 :\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 \u2203 h', h' \u2208 H \u2227 g * h = h' * g) \u2192\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 \u2203 h', h' \u2208 H \u2227 g * h' = h * g) \u2192\n  \u2200 (P : G \u2192 Prop), P \u2208 rightClasses law H \u2192 P \u2208 leftClasses law H :=\nby\n  rw [\u2190 leftClassesOnOp, \u2190 rightClassesOnOp]\n  exact \u03bb h\u2081 h\u2082 p h => @normalIff.lemma\u2083 _ (law\u1d52\u1d56) _ H\n    (\u03bb g h hIn => match h\u2082 g hIn with\n      | \u27e8 k, \u27e8 kIn, h\u2082 \u27e9 \u27e9 => \u27e8 k, \u27e8 kIn, h\u2082.symm \u27e9 \u27e9)\n    (\u03bb g h hIn => match h\u2081 g hIn with\n      | \u27e8 k, \u27e8 kIn, h\u2081 \u27e9 \u27e9 => \u27e8 k, \u27e8 kIn, h\u2081.symm \u27e9 \u27e9)\n    p h\n\ntheorem normalIff.lemma\u2085 :\n  (\u2200 (P : Set G), P \u2208 rightClasses law H \u2194 P \u2208 leftClasses law H) \u2192\n  (\u2200 (g : G), \u2200 {h}, h \u2208 H \u2192 \u2203 h', h' \u2208 H \u2227 g * h = h' * g) :=\nby\n  intro h g h\u2080 h\u2080In\n  have p := ((leftClassOf law H g).property)\n  rw [\u2190 h] at p\n  have p\u2081 := leftClassMemIff law H ((leftClassOf law H g).2)\n    (memOfLeftClassOf law H g) (g * h\u2080)\n  have p\u2082 := rightClassMemIff law H p\n    (memOfLeftClassOf law H g) (g * h\u2080)\n  exact (p\u2081.trans p\u2082).1 \u27e8 h\u2080, \u27e8 h\u2080In, rfl \u27e9 \u27e9\n\nsection\n\nvariable [normal : Normal law H]\n\nopen Action.Remarkable.OnSet\n\nlocal infix:70 \" \u2022\u2097 \" => leftTranslationOnSet law\nlocal notation:70 lhs:70 \" \u2022\u1d63 \" rhs:70 => rightTranslationOnSet law rhs lhs\nlocal infix:70 \" \u2022\u2022  \" => conjugationOnSet law\nlocal infixl:70 \" ** \" => mulOnSet law\n\ntheorem conjH (g : G) : g \u2022\u2022 H = H :=\nby\n  funext h\n  apply propext\n  suffices (\u2203 h', h' \u2208 H \u2227 h = g * h' * g\u207b\u00b9) \u2194 h \u2208 H by exact this\n  exact \u27e8 \u03bb p => match p with\n    | \u27e8 h', \u27e8 h'In, p \u27e9 \u27e9 => p \u25b8 normal.stable g h'In,\n    \u03bb p => \u27e8 (g\u207b\u00b9 * h * (g\u207b\u00b9\u207b\u00b9)), \u27e8 normal.stable (g\u207b\u00b9) p, by simp \u27e9 \u27e9 \u27e9\n\ntheorem moveLeft (g : G) : H \u2022\u1d63 g = g \u2022\u2097 H :=\nby\n  rw [show H \u2022\u1d63 g = (g \u2022\u2022 H) \u2022\u1d63 g by rw [conjH]]\n  rw [conjugationCompat, \u2190 rightTranslationCompat, invCancelLeft, rightTranslationIdentity]\n\ntheorem neutralRight (g : G) : (g \u2022\u2097 H) ** H = g \u2022\u2097 H :=\nby\n  funext x\n  apply propext\n  apply Iff.intro\n  exact \u03bb h => match h with\n  | \u27e8 res, \u27e8 h\u2081, h\u2081In, resEq \u27e9, h\u2082, h\u2082In, h\u2082Eq \u27e9 =>\n    \u27e8 h\u2081 * h\u2082, sg.mulMem h\u2081In h\u2082In, by\n      rw [h\u2082Eq, resEq]\n      suffices g * h\u2081 * h\u2082 = g * (h\u2081 * h\u2082) by exact this\n      simp \u27e9\n  exact \u03bb h => match h with\n    | \u27e8 h, hIn, xEq \u27e9 =>\n      \u27e8 g * h, \u27e8 h, hIn, rfl \u27e9, one, oneMem, by\n        rw [xEq]\n        suffices g * h = g * h * one by exact this\n        simp \u27e9\n\n/-! \"pseudo morphism\" because there is no notion of magma morphisms (yet !) -/\ntheorem pseudoMorphism (g : G) (g' : G) : (g \u2022\u2097 H) ** (g' \u2022\u2097 H) = (g * g') \u2022\u2097 H :=\nby\n  have p : g \u2022\u2097 (g' \u2022\u2097 H) = (g * g') \u2022\u2097 H\n  from ((leftActionOnSet law).compat g g' H).symm\n  rw [mulOnSetCompat\u2081, translationCompat, moveLeft, p, neutralRight]\n\ntheorem leftClassesStable {P Q : Set G}\n  (PIn : P \u2208 leftClasses law H) (QIn : Q \u2208 leftClasses law H) : P ** Q \u2208 leftClasses law H :=\nby\n  rw [leftClassIff] at PIn\n  rw [leftClassIff] at QIn\n  rw [leftClassIff]\n  match PIn, QIn with\n  | \u27e8 g, PIs \u27e9, \u27e8 g', QIs \u27e9 =>\n    rw [PIs, QIs]\n    rw [pseudoMorphism]\n    exact \u27e8 g * g', rfl \u27e9\n\ndef quotientLaw : leftClasses law H \u2192 leftClasses law H \u2192 leftClasses law H :=\n  \u03bb P Q => \u27e8 P ** Q, leftClassesStable H P.2 Q.2 \u27e9\n\ninstance quotientGroup : Group (leftClasses law H) (quotientLaw H) where\n  one' := subgroupAsLeftClass law H\n  assoc := \u03bb P\u2081 P\u2082 P\u2083 => by\n    apply Subtype.eq\n    simp [id', quotientLaw]\n    match (leftClassIff law _ _).2 P\u2081.2,\n      (leftClassIff law _ _).2 P\u2082.2,\n      (leftClassIff law _ _).2 P\u2083.2 with\n    | \u27e8 g\u2081, (P\u2081Is : P\u2081 = g\u2081 \u2022\u2097 H) \u27e9,\n      \u27e8 g\u2082, (P\u2082Is : P\u2082 = g\u2082 \u2022\u2097 H) \u27e9,\n      \u27e8 g\u2083, (P\u2083Is : P\u2083 = g\u2083 \u2022\u2097 H) \u27e9 =>\n      rw [P\u2081Is, P\u2082Is, P\u2083Is]\n      simp [pseudoMorphism]\n  oneNeutralRight := \u03bb P => by\n    apply Subtype.eq\n    simp only [id', quotientLaw]\n    exact match (leftClassIff law _ _).2 P.2 with\n    | \u27e8 g, PIs \u27e9 => PIs \u25b8 neutralRight _ _\n  invertible := \u03bb P => by\n    simp only [id', quotientLaw]\n    match (leftClassIff law _ _).2 P.2 with\n    | \u27e8 g, (PIs : P = g \u2022\u2097 H)\u27e9 =>\n      apply Exists.intro (leftClassOf law H (g\u207b\u00b9))\n      apply Subtype.eq\n      suffices P.1 ** (g\u207b\u00b9 \u2022\u2097 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 := \u03bb g => \u27e8 g \u2022\u2097 H, by\n    rw [leftClassIff]\n    exact \u27e8 g, rfl \u27e9 \u27e9\n  respectMul' := \u03bb 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 \u2964 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 \u224c discrete.{v} pempty :=\nequivalence.mk\n{ obj := pempty.elim \u2218 discrete.as, map := \u03bb x, x.as.elim }\n{ obj := pempty.elim \u2218 discrete.as, map := \u03bb x, x.as.elim }\n(by tidy) (by tidy)\n\n/-- The canonical functor out of the empty category. -/\ndef empty : discrete.{w} pempty \u2964 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 \u2964 C) : F \u2245 G :=\ndiscrete.nat_iso (\u03bb 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 \u2964 C) : F \u2245 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 \u2964 C) : F = G :=\nfunctor.ext (\u03bb x, x.as.elim) (\u03bb 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 \u2964 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 \u2964 D` to a category `D` with biproducts\nlifts to a functor `Mat_.lift F : Mat_ C \u2964 D`,\nMoreover, this functor is unique (up to natural isomorphisms) amongst functors `L : Mat_ C \u2964 D`\nsuch that `embedding C \u22d9 L \u2245 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 \u224c 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\u2081 v\u2082 u\u2081 u\u2082\nvariables (C : Type u\u2081) [category.{v\u2081} C] [preadditive C]\n\n/--\nAn object in `Mat_ C` is a finite tuple of objects in `C`.\n-/\nstructure Mat_ : Type (max (v\u2081+1) u\u2081) :=\n(\u03b9 : Type v\u2081)\n[F : fintype \u03b9]\n(X : \u03b9 \u2192 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\u2081 := dmatrix M.\u03b9 N.\u03b9 (\u03bb i j, M.X i \u27f6 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 := \u03bb 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\u03bb i k, \u2211 j : N.\u03b9, f i j \u226b g j k\n\nend hom\n\nsection\nlocal attribute [simp] hom.id hom.comp\n\ninstance : category.{v\u2081} (Mat_ C) :=\n{ hom := hom,\n  id := hom.id,\n  comp := \u03bb M N K f g, f.comp g,\n  id_comp' := \u03bb M N f, by simp [dite_comp],\n  comp_id' := \u03bb M N f, by simp [comp_dite],\n  assoc' := \u03bb 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  (\ud835\udfd9 M : hom M M) = \u03bb 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.\u03b9) :\n  (\ud835\udfd9 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.\u03b9) :\n  (\ud835\udfd9 M : hom M M) i i = \ud835\udfd9 _ :=\nby simp [id_apply]\n\n@[simp] lemma id_apply_of_ne (M : Mat_ C) (i j : M.\u03b9) (h : i \u2260 j) :\n  (\ud835\udfd9 M : hom M M) i j = 0 :=\nby simp [id_apply, h]\n\nlemma comp_def {M N K : Mat_ C} (f : M \u27f6 N) (g : N \u27f6 K) :\n  (f \u226b g) = \u03bb i k, \u2211 j : N.\u03b9, f i j \u226b g j k := rfl\n\n@[simp] lemma comp_apply {M N K : Mat_ C} (f : M \u27f6 N) (g : N \u27f6 K) (i k) :\n  (f \u226b g) i k = \u2211 j : N.\u03b9, f i j \u226b g j k := rfl\n\ninstance (M N : Mat_ C) : inhabited (M \u27f6 N) := \u27e8\u03bb i j, (0 : M.X i \u27f6 N.X j)\u27e9\n\nend\n\ninstance : preadditive (Mat_ C) :=\n{ hom_group := \u03bb M N, by { change add_comm_group (dmatrix M.\u03b9 N.\u03b9 _), apply_instance, },\n  add_comp' := \u03bb M N K f f' g, by { ext, simp [finset.sum_add_distrib], },\n  comp_add' := \u03bb 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 \u27f6 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 := \u03bb J \ud835\udc9f, by exactI\n  { has_biproduct := \u03bb f,\n    has_biproduct_of_total\n    { X := \u27e8\u03a3 j : J, (f j).\u03b9, \u03bb p, (f p.1).X p.2\u27e9,\n      \u03c0 := \u03bb j x y,\n      begin\n        dsimp at x \u22a2,\n        refine if h : x.1 = j then _ else 0,\n        refine if h' : (@eq.rec J x.1 (\u03bb j, (f j).\u03b9) 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      \u03b9 := \u03bb j x y,\n      begin\n        dsimp at y \u22a2,\n        refine if h : y.1 = j then _ else 0,\n        refine if h' : (@eq.rec J y.1 (\u03bb j, (f j).\u03b9) y.2 _ h) = x then _ else 0,\n        apply eq_to_hom,\n        substs h h',\n      end,\n      \u03b9_\u03c0 := \u03bb 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\u2081,\n      dsimp at i\u2081 \u22a2,\n      rcases i\u2081 with \u27e8j\u2081, i\u2081\u27e9,\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\u2082,\n        rcases i\u2082 with \u27e8j\u2082, i\u2082\u27e9,\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\u2081 = j\u2082,\n        { subst h, simp, },\n        { simp [h], }, },\n    end }}.\n\nend Mat_\n\nnamespace functor\nvariables {C} {D : Type*} [category.{v\u2081} 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 \u2964 D) [functor.additive F] : Mat_ C \u2964 Mat_ D :=\n{ obj := \u03bb M, \u27e8M.\u03b9, \u03bb i, F.obj (M.X i)\u27e9,\n  map := \u03bb M N f i j, F.map (f i j),\n  map_comp' := \u03bb 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 : (\ud835\udfed C).map_Mat_ \u2245 \ud835\udfed (Mat_ C) :=\nnat_iso.of_components (\u03bb M, eq_to_iso (by { cases M, refl, }))\n(\u03bb 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\u2081} E] [preadditive E]\n  (F : C \u2964 D) [functor.additive F] (G : D \u2964 E) [functor.additive G] :\n  (F \u22d9 G).map_Mat_ \u2245 F.map_Mat_ \u22d9 G.map_Mat_ :=\nnat_iso.of_components (\u03bb M, eq_to_iso (by { cases M, refl, }))\n(\u03bb 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 \u2964 Mat_ C :=\n{ obj := \u03bb X, \u27e8punit, \u03bb _, X\u27e9,\n  map := \u03bb X Y f, \u03bb _ _, f,\n  map_id' := \u03bb X, by { ext \u27e8\u27e9 \u27e8\u27e9, simp, },\n  map_comp' := \u03bb X Y Z f g, by { ext \u27e8\u27e9 \u27e8\u27e9, simp, }, }\n\nnamespace embedding\n\ninstance : faithful (embedding C) :=\n{ map_injective' := \u03bb X Y f g h, congr_fun (congr_fun h punit.star) punit.star, }\n\ninstance : full (embedding C) :=\n{ preimage := \u03bb X Y f, f punit.star punit.star, }\n\ninstance : functor.additive (embedding C) := {}\n\nend embedding\n\ninstance [inhabited C] : inhabited (Mat_ C) := \u27e8(embedding C).obj default\u27e9\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 \u2245 \u2a01 (\u03bb i, (embedding C).obj (M.X i)) :=\n{ hom := biproduct.lift (\u03bb i j k, if h : j = i then eq_to_hom (congr_arg M.X h) else 0),\n  inv := biproduct.desc (\u03bb 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_\u03c0, biproduct.\u03b9_desc_assoc, biproduct.\u03b9_\u03c0],\n    ext \u27e8\u27e9 \u27e8\u27e9,\n    simp [dite_comp, comp_dite],\n    split_ifs,\n    { subst h, simp, },\n    { simp [h], },\n  end, }.\n\nvariables {D : Type u\u2081} [category.{v\u2081} 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 \u2964 D) [functor.additive F] (M : Mat_ C) :\n  F.obj M \u2245 \u2a01 (\u03bb i, F.obj ((embedding C).obj (M.X i))) :=\n(F.map_iso (iso_biproduct_embedding M)) \u226a\u226b (F.map_biproduct _)\n\nvariables [has_finite_biproducts D]\n\n@[reassoc] lemma additive_obj_iso_biproduct_naturality (F : Mat_ C \u2964 D) [functor.additive F]\n  {M N : Mat_ C} (f : M \u27f6 N) :\n  F.map f \u226b (additive_obj_iso_biproduct F N).hom =\n    (additive_obj_iso_biproduct F M).hom \u226b\n      biproduct.matrix (\u03bb 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_\u03c0, functor.map_bicone_\u03c0,\n    biproduct.bicone_\u03c0, biproduct.lift_matrix],\n  dsimp [embedding],\n  simp only [\u2190F.map_comp, biproduct.lift_\u03c0, biproduct.matrix_\u03c0, category.assoc],\n  simp only [\u2190F.map_comp, \u2190F.map_sum, biproduct.lift_desc, biproduct.lift_\u03c0_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 \u2964 D) [functor.additive F]\n  {M N : Mat_ C} (f : M \u27f6 N) :\n  (additive_obj_iso_biproduct F M).inv \u226b F.map f =\n    biproduct.matrix (\u03bb i j, F.map ((embedding C).map (f i j)) : _) \u226b\n      (additive_obj_iso_biproduct F N).inv :=\nby rw [iso.inv_comp_eq, \u2190category.assoc, iso.eq_comp_inv, additive_obj_iso_biproduct_naturality]\n\n/-- Any additive functor `C \u2964 D` to a category `D` with finite biproducts extends to\na functor `Mat_ C \u2964 D`. -/\n@[simps]\ndef lift (F : C \u2964 D) [functor.additive F] : Mat_ C \u2964 D :=\n{ obj := \u03bb X, \u2a01 (\u03bb i, F.obj (X.X i)),\n  map := \u03bb X Y f, biproduct.matrix (\u03bb i j, F.map (f i j)),\n  map_id' := \u03bb 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' := \u03bb X Y Z f g, by { ext i j, simp, }, }.\n\ninstance lift_additive (F : C \u2964 D) [functor.additive F] : functor.additive (lift F) := {}\n\n/-- An additive functor `C \u2964 D` factors through its lift to `Mat_ C \u2964 D`. -/\n@[simps]\ndef embedding_lift_iso (F : C \u2964 D) [functor.additive F] : embedding C \u22d9 lift F \u2245 F :=\nnat_iso.of_components (\u03bb X,\n  { hom := biproduct.desc (\u03bb P, \ud835\udfd9 (F.obj X)),\n    inv := biproduct.lift (\u03bb P, \ud835\udfd9 (F.obj X)), })\n(\u03bb X Y f, begin\n  dsimp,\n  ext,\n  simp only [category.id_comp, biproduct.\u03b9_desc_assoc],\n  erw biproduct.\u03b9_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 \u2964 D` such that `F \u2245 embedding C \u22d9 L`.\n-/\ndef lift_unique (F : C \u2964 D) [functor.additive F] (L : Mat_ C \u2964 D) [functor.additive L]\n  (\u03b1 : embedding C \u22d9 L \u2245 F) :\n  L \u2245 lift F :=\nnat_iso.of_components\n  (\u03bb M, (additive_obj_iso_biproduct L M) \u226a\u226b\n    (biproduct.map_iso (\u03bb i, \u03b1.app (M.X i))) \u226a\u226b\n    (biproduct.map_iso (\u03bb i, (embedding_lift_iso F).symm.app (M.X i))) \u226a\u226b\n    (additive_obj_iso_biproduct (lift F) M).symm)\n(\u03bb 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 \u27e8\u27e9,\n  dsimp, simp,\n  exact \u03b1.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 \u2964 D` are naturally isomorphic if\ntheir precompositions with `embedding C` are naturally isomorphic as functors `C \u2964 D`. -/\n@[ext]\ndef ext {F G : Mat_ C \u2964 D} [functor.additive F] [functor.additive G]\n  (\u03b1 : embedding C \u22d9 F \u2245 embedding C \u22d9 G) : F \u2245 G :=\n(lift_unique (embedding C \u22d9 G) _ \u03b1) \u226a\u226b (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 \u22d9 \ud835\udfed (Mat_ C) \u2245 embedding C \u22d9 lift (\ud835\udfed C) \u22d9 embedding C :=\nfunctor.right_unitor _ \u226a\u226b\n  (functor.left_unitor _).symm \u226a\u226b\n  (iso_whisker_right (embedding_lift_iso _).symm _) \u226a\u226b\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\u2081+1)) [large_category C] [preadditive C] [has_finite_biproducts C] :\n  Mat_ C \u224c C :=\nequivalence.mk -- I suspect this is already an adjoint equivalence, but it seems painful to verify.\n  (lift (\ud835\udfed C))\n  (embedding C)\n  (ext equivalence_self_of_has_finite_biproducts_aux)\n  (embedding_lift_iso (\ud835\udfed C))\n\n@[simp] lemma equivalence_self_of_has_finite_biproducts_functor\n  {C : Type (u\u2081+1)} [large_category C] [preadditive C] [has_finite_biproducts C] :\n  (equivalence_self_of_has_finite_biproducts C).functor = lift (\ud835\udfed C) :=\nrfl\n\n@[simp] lemma equivalence_self_of_has_finite_biproducts_inverse\n  {C : Type (u\u2081+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 := \u03bb X Y, matrix X Y R,\n  id := \u03bb X, 1,\n  comp := \u03bb X Y Z f g, f \u2b1d 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  \ud835\udfd9 M = \u03bb i j, if h : i = j then 1 else 0 :=\nrfl\n\nlemma id_apply (M : Mat R) (i j : M) :\n  (\ud835\udfd9 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  (\ud835\udfd9 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 \u2260 j) :\n  (\ud835\udfd9 M : matrix M M R) i j = 0 :=\nby simp [id_apply, h]\n\nlemma comp_def {M N K : Mat R} (f : M \u27f6 N) (g : N \u27f6 K) :\n  (f \u226b g) = \u03bb i k, \u2211 j : N, f i j * g j k := rfl\n\n@[simp] lemma comp_apply {M N K : Mat R} (f : M \u27f6 N) (g : N \u27f6 K) (i k) :\n  (f \u226b g) i k = \u2211 j : N, f i j * g j k := rfl\n\ninstance (M N : Mat R) : inhabited (M \u27f6 N) := \u27e8\u03bb (i : M) (j : N), (0 : R)\u27e9\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\u1d50\u1d52\u1d56) \u2964 Mat R :=\n{ obj := \u03bb X, Fintype.of X.\u03b9,\n  map := \u03bb X Y f i j, mul_opposite.unop (f i j),\n  map_id' := \u03bb 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' := \u03bb 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 := \u03bb X Y f i j, mul_opposite.op (f i j), }\n\ninstance : ess_surj (equivalence_single_obj_inverse R) :=\n{ mem_ess_image := \u03bb X,\n  \u27e8{ \u03b9 := X, X := \u03bb _, punit.star }, \u27e8eq_to_iso (by { dsimp, cases X, congr, })\u27e9\u27e9, }\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 \u224c Mat_ (single_obj R\u1d50\u1d52\u1d56) :=\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 {\u03b1 : Type _} {\u03b2 : Type _} [Ring \u03b2] [LinearOrderedField \u03b1] [Archimedean \u03b1] {abv : \u03b2 \u2192 \u03b1}\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 {\u03b1 : Type.{u1}} [_inst_2 : LinearOrderedField.{u1} \u03b1] [_inst_3 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))] (f : Nat -> \u03b1) {a : \u03b1} {m : Nat}, (forall (n : Nat), (GE.ge.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))) (f n)) a)) -> (forall (n : Nat), (GE.ge.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))) (f (Nat.succ n)) (f n))) -> (IsCauSeq.{u1, u1} \u03b1 _inst_2 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_2 : LinearOrderedField.{u1} \u03b1] [_inst_3 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_2))))))] (f : Nat -> \u03b1) {a : \u03b1} {m : Nat}, (forall (n : Nat), (GE.ge.{0} Nat instLENat n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))))) (f n)) a)) -> (forall (n : Nat), (GE.ge.{0} Nat instLENat n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))) (f (Nat.succ n)) (f n))) -> (IsCauSeq.{u1, u1} \u03b1 _inst_2 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))))) f)\nCase conversion may be inaccurate. Consider using '#align is_cau_of_decreasing_bounded isCauSeq_of_decreasing_bounded\u2093'. -/\ntheorem isCauSeq_of_decreasing_bounded (f : \u2115 \u2192 \u03b1) {a : \u03b1} {m : \u2115} (ham : \u2200 n \u2265 m, |f n| \u2264 a)\n    (hnm : \u2200 n \u2265 m, f n.succ \u2264 f n) : IsCauSeq abs f := fun \u03b5 \u03b50 =>\n  by\n  let \u27e8k, hk\u27e9 := Archimedean.arch a \u03b50\n  have h : \u2203 l, \u2200 n \u2265 m, a - l \u2022 \u03b5 < f n :=\n    \u27e8k + k + 1, fun n hnm =>\n      lt_of_lt_of_le\n        (show a - (k + (k + 1)) \u2022 \u03b5 < -|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 _ \u03b50))))\n        (neg_le.2 <| abs_neg (f n) \u25b8 le_abs_self _)\u27e9\n  let l := Nat.find h\n  have hl : \u2200 n : \u2115, n \u2265 m \u2192 f n > a - l \u2022 \u03b5 := Nat.find_spec h\n  have hl0 : l \u2260 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 \u2264 f i := (Nat.rel_of_forall_rel_succ_of_le_of_le (\u00b7 \u2265 \u00b7) 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 \u2264 a - Nat.pred l \u2022 \u03b5 := hi.2\n    _ = a - l \u2022 \u03b5 + \u03b5 := by\n      conv =>\n        rhs\n        rw [\u2190 Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hl0), succ_nsmul', sub_add,\n          add_sub_cancel]\n    _ < f j + \u03b5 := 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 {\u03b1 : Type.{u1}} [_inst_2 : LinearOrderedField.{u1} \u03b1] [_inst_3 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))] (f : Nat -> \u03b1) {a : \u03b1} {m : Nat}, (forall (n : Nat), (GE.ge.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))) (f n)) a)) -> (forall (n : Nat), (GE.ge.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))) (f n) (f (Nat.succ n)))) -> (IsCauSeq.{u1, u1} \u03b1 _inst_2 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))))) f)\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_2 : LinearOrderedField.{u1} \u03b1] [_inst_3 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_2))))))] (f : Nat -> \u03b1) {a : \u03b1} {m : Nat}, (forall (n : Nat), (GE.ge.{0} Nat instLENat n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))))) (f n)) a)) -> (forall (n : Nat), (GE.ge.{0} Nat instLENat n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))) (f n) (f (Nat.succ n)))) -> (IsCauSeq.{u1, u1} \u03b1 _inst_2 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))))) f)\nCase conversion may be inaccurate. Consider using '#align is_cau_of_mono_bounded isCauSeq_of_mono_bounded\u2093'. -/\ntheorem isCauSeq_of_mono_bounded (f : \u2115 \u2192 \u03b1) {a : \u03b1} {m : \u2115} (ham : \u2200 n \u2265 m, |f n| \u2264 a)\n    (hnm : \u2200 n \u2265 m, f n \u2264 f n.succ) : IsCauSeq abs f :=\n  by\n  refine'\n    @Eq.recOn (\u2115 \u2192 \u03b1) _ (IsCauSeq abs) _ _\n      (-\u27e8_, @isCauSeq_of_decreasing_bounded _ _ _ (fun n => -f n) a m (by simpa) (by simpa)\u27e9 :\n          CauSeq \u03b1 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 {\u03b1 : Type _} {\u03b2 : Type _} [Ring \u03b2] [LinearOrderedField \u03b1] {abv : \u03b2 \u2192 \u03b1}\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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Ring.{u2} \u03b2] [_inst_2 : LinearOrderedField.{u1} \u03b1] {abv : \u03b2 -> \u03b1} [_inst_3 : IsAbsoluteValue.{u1, u2} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))) \u03b2 (Ring.toSemiring.{u2} \u03b2 _inst_1) abv] {f : Nat -> \u03b2} {g : Nat -> \u03b1} (n : Nat), (forall (m : Nat), (LE.le.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))) (abv (f m)) (g m))) -> (IsCauSeq.{u1, u1} \u03b1 _inst_2 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))))) (fun (n : Nat) => Finset.sum.{u1, 0} \u03b1 Nat (AddCommGroup.toAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))) (Finset.range n) (fun (i : Nat) => g i))) -> (IsCauSeq.{u1, u2} \u03b1 _inst_2 \u03b2 _inst_1 abv (fun (n : Nat) => Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_1)))) (Finset.range n) (fun (i : Nat) => f i)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Ring.{u1} \u03b2] [_inst_2 : LinearOrderedField.{u2} \u03b1] {abv : \u03b2 -> \u03b1} [_inst_3 : IsAbsoluteValue.{u2, u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u2} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_2))))) \u03b2 (Ring.toSemiring.{u1} \u03b2 _inst_1) abv] {f : Nat -> \u03b2} {g : Nat -> \u03b1} (n : Nat), (forall (m : Nat), (LE.le.{0} Nat instLENat n m) -> (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (StrictOrderedRing.toPartialOrder.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_2)))))) (abv (f m)) (g m))) -> (IsCauSeq.{u2, u2} \u03b1 _inst_2 \u03b1 (StrictOrderedRing.toRing.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_2)))) (Abs.abs.{u2} \u03b1 (Neg.toHasAbs.{u2} \u03b1 (Ring.toNeg.{u2} \u03b1 (StrictOrderedRing.toRing.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_2))))) (SemilatticeSup.toSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 (LinearOrderedRing.toLinearOrder.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_2))))))))) (fun (n : Nat) => Finset.sum.{u2, 0} \u03b1 Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_2)))))) (Finset.range n) (fun (i : Nat) => g i))) -> (IsCauSeq.{u2, u1} \u03b1 _inst_2 \u03b2 _inst_1 abv (fun (n : Nat) => Finset.sum.{u1, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _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\u2093'. -/\ntheorem isCauSeq_series_of_abv_le_of_isCauSeq {f : \u2115 \u2192 \u03b2} {g : \u2115 \u2192 \u03b1} (n : \u2115) :\n    (\u2200 m, n \u2264 m \u2192 abv (f m) \u2264 g m) \u2192\n      (IsCauSeq abs fun n => \u2211 i in range n, g i) \u2192 IsCauSeq abv fun n => \u2211 i in range n, f i :=\n  by\n  intro hm hg \u03b5 \u03b50\n  cases' hg (\u03b5 / 2) (div_pos \u03b50 (by norm_num)) with i hi\n  exists max n i\n  intro j ji\n  have hi\u2081 := hi j (le_trans (le_max_right n i) ji)\n  have hi\u2082 := hi (max n i) (le_max_right n i)\n  have sub_le :=\n    abs_sub_le (\u2211 k in range j, g k) (\u2211 k in range i, g k) (\u2211 k in range (max n i), g k)\n  have := add_lt_add hi\u2081 hi\u2082\n  rw [abs_sub_comm (\u2211 k in range (max n i), g k), add_halves \u03b5] 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\u2082 hi\u2081 hi \u03b50 \u03b5 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  \u00b7 simp [abv_zero abv]\n  \u00b7 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : Ring.{u2} \u03b2] [_inst_2 : LinearOrderedField.{u1} \u03b1] {abv : \u03b2 -> \u03b1} [_inst_3 : IsAbsoluteValue.{u1, u2} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))) \u03b2 (Ring.toSemiring.{u2} \u03b2 _inst_1) abv] {f : Nat -> \u03b2}, (IsCauSeq.{u1, u1} \u03b1 _inst_2 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))))) (fun (m : Nat) => Finset.sum.{u1, 0} \u03b1 Nat (AddCommGroup.toAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_2)))))) (Finset.range m) (fun (n : Nat) => abv (f n)))) -> (IsCauSeq.{u1, u2} \u03b1 _inst_2 \u03b2 _inst_1 abv (fun (m : Nat) => Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_1)))) (Finset.range m) (fun (n : Nat) => f n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : Ring.{u1} \u03b2] [_inst_2 : LinearOrderedField.{u2} \u03b1] {abv : \u03b2 -> \u03b1} [_inst_3 : IsAbsoluteValue.{u2, u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u2} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_2))))) \u03b2 (Ring.toSemiring.{u1} \u03b2 _inst_1) abv] {f : Nat -> \u03b2}, (IsCauSeq.{u2, u2} \u03b1 _inst_2 \u03b1 (StrictOrderedRing.toRing.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_2)))) (Abs.abs.{u2} \u03b1 (Neg.toHasAbs.{u2} \u03b1 (Ring.toNeg.{u2} \u03b1 (StrictOrderedRing.toRing.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_2))))) (SemilatticeSup.toSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 (LinearOrderedRing.toLinearOrder.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_2))))))))) (fun (m : Nat) => Finset.sum.{u2, 0} \u03b1 Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_2)))))) (Finset.range m) (fun (n : Nat) => abv (f n)))) -> (IsCauSeq.{u2, u1} \u03b1 _inst_2 \u03b2 _inst_1 abv (fun (m : Nat) => Finset.sum.{u1, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _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\u2093'. -/\ntheorem isCauSeq_series_of_abv_isCauSeq {f : \u2115 \u2192 \u03b2} :\n    (IsCauSeq abs fun m => \u2211 n in range m, abv (f n)) \u2192 IsCauSeq abv fun m => \u2211 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 {\u03b1 : Type _} [LinearOrderedField \u03b1] [Archimedean \u03b1]\n\n/- warning: is_cau_geo_series -> isCauSeq_geo_series is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))] {\u03b2 : Type.{u2}} [_inst_3 : Ring.{u2} \u03b2] [_inst_4 : Nontrivial.{u2} \u03b2] {abv : \u03b2 -> \u03b1} [_inst_5 : IsAbsoluteValue.{u1, u2} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) \u03b2 (Ring.toSemiring.{u2} \u03b2 _inst_3) abv] (x : \u03b2), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (abv x) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) -> (IsCauSeq.{u1, u2} \u03b1 _inst_1 \u03b2 _inst_3 abv (fun (n : Nat) => Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_3)))) (Finset.range n) (fun (m : Nat) => HPow.hPow.{u2, 0, u2} \u03b2 Nat \u03b2 (instHPow.{u2, 0} \u03b2 Nat (Monoid.Pow.{u2} \u03b2 (Ring.toMonoid.{u2} \u03b2 _inst_3))) x m)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))] {\u03b2 : Type.{u2}} [_inst_3 : Ring.{u2} \u03b2] [_inst_4 : Nontrivial.{u2} \u03b2] {abv : \u03b2 -> \u03b1} [_inst_5 : IsAbsoluteValue.{u1, u2} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))) \u03b2 (Ring.toSemiring.{u2} \u03b2 _inst_3) abv] (x : \u03b2), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (abv x) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) -> (IsCauSeq.{u1, u2} \u03b1 _inst_1 \u03b2 _inst_3 abv (fun (n : Nat) => Finset.sum.{u2, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_3)))) (Finset.range n) (fun (m : Nat) => HPow.hPow.{u2, 0, u2} \u03b2 Nat \u03b2 (instHPow.{u2, 0} \u03b2 Nat (Monoid.Pow.{u2} \u03b2 (MonoidWithZero.toMonoid.{u2} \u03b2 (Semiring.toMonoidWithZero.{u2} \u03b2 (Ring.toSemiring.{u2} \u03b2 _inst_3))))) x m)))\nCase conversion may be inaccurate. Consider using '#align is_cau_geo_series isCauSeq_geo_series\u2093'. -/\ntheorem isCauSeq_geo_series {\u03b2 : Type _} [Ring \u03b2] [Nontrivial \u03b2] {abv : \u03b2 \u2192 \u03b1} [IsAbsoluteValue abv]\n    (x : \u03b2) (hx1 : abv x < 1) : IsCauSeq abv fun n => \u2211 m in range n, x ^ m :=\n  have hx1' : abv x \u2260 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 [\u2190 neg_div_neg_eq, neg_sub, neg_sub]\n      refine' @isCauSeq_of_mono_bounded _ _ _ _ ((1 : \u03b1) / (1 - abv x)) 0 _ _\n      \u00b7 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 \u25b8 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        \u00b7 simp\n        \u00b7 rw [pow_succ, \u2190 one_mul (1 : \u03b1)]\n          refine' mul_le_mul (le_of_lt hx1) ih (abv_pow abv x n \u25b8 abv_nonneg _ _) (by norm_num)\n      \u00b7 intro n hn\n        refine' div_le_div_of_le (le_of_lt <| sub_pos.2 hx1) (sub_le_sub_left _ _)\n        rw [\u2190 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))] (a : \u03b1) {x : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) x) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) -> (IsCauSeq.{u1, u1} \u03b1 _inst_1 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (fun (m : Nat) => Finset.sum.{u1, 0} \u03b1 Nat (AddCommGroup.toAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Finset.range m) (fun (n : Nat) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) a (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (Ring.toMonoid.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) x n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))] (a : \u03b1) {x : \u03b1}, (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) x) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) -> (IsCauSeq.{u1, u1} \u03b1 _inst_1 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (Ring.toNeg.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (DistribLattice.toLattice.{u1} \u03b1 (instDistribLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (fun (m : Nat) => Finset.sum.{u1, 0} \u03b1 Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1)))))) (Finset.range m) (fun (n : Nat) => HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) a (HPow.hPow.{u1, 0, u1} \u03b1 Nat \u03b1 (instHPow.{u1, 0} \u03b1 Nat (Monoid.Pow.{u1} \u03b1 (MonoidWithZero.toMonoid.{u1} \u03b1 (Semiring.toMonoidWithZero.{u1} \u03b1 (StrictOrderedSemiring.toSemiring.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _inst_1))))))))) x n))))\nCase conversion may be inaccurate. Consider using '#align is_cau_geo_series_const isCauSeq_geo_series_const\u2093'. -/\ntheorem isCauSeq_geo_series_const (a : \u03b1) {x : \u03b1} (hx1 : |x| < 1) :\n    IsCauSeq abs fun m => \u2211 n in range m, a * x ^ n :=\n  by\n  have : IsCauSeq abs fun m => a * \u2211 n in range m, x ^ n :=\n    (CauSeq.const abs a * \u27e8_, isCauSeq_geo_series x hx1\u27e9).2\n  simpa only [mul_sum]\n#align is_cau_geo_series_const isCauSeq_geo_series_const\n\nvariable {\u03b2 : Type _} [Ring \u03b2] {abv : \u03b2 \u2192 \u03b1} [IsAbsoluteValue abv]\n\n/- warning: series_ratio_test -> series_ratio_test is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] [_inst_2 : Archimedean.{u1} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u1} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))] {\u03b2 : Type.{u2}} [_inst_3 : Ring.{u2} \u03b2] {abv : \u03b2 -> \u03b1} [_inst_4 : IsAbsoluteValue.{u1, u2} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) \u03b2 (Ring.toSemiring.{u2} \u03b2 _inst_3) abv] {f : Nat -> \u03b2} (n : Nat) (r : \u03b1), (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) r) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) r (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) -> (forall (m : Nat), (LE.le.{0} Nat Nat.hasLe n m) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (abv (f (Nat.succ m))) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) r (abv (f m))))) -> (IsCauSeq.{u1, u2} \u03b1 _inst_1 \u03b2 _inst_3 abv (fun (m : Nat) => Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_3)))) (Finset.range m) (fun (n : Nat) => f n)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} [_inst_1 : LinearOrderedField.{u2} \u03b1] [_inst_2 : Archimedean.{u2} \u03b1 (OrderedSemiring.toOrderedAddCommMonoid.{u2} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u2} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_1))))))] {\u03b2 : Type.{u1}} [_inst_3 : Ring.{u1} \u03b2] {abv : \u03b2 -> \u03b1} [_inst_4 : IsAbsoluteValue.{u2, u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u2} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_1))))) \u03b2 (Ring.toSemiring.{u1} \u03b2 _inst_3) abv] {f : Nat -> \u03b2} (n : Nat) (r : \u03b1), (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (StrictOrderedRing.toPartialOrder.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1)))))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (CommMonoidWithZero.toZero.{u2} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u2} \u03b1 (Semifield.toCommGroupWithZero.{u2} \u03b1 (LinearOrderedSemifield.toSemifield.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_1))))))) r) -> (LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (StrictOrderedRing.toPartialOrder.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1)))))) r (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 (NonAssocRing.toOne.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (StrictOrderedRing.toRing.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1))))))))) -> (forall (m : Nat), (LE.le.{0} Nat instLENat n m) -> (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (StrictOrderedRing.toPartialOrder.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1)))))) (abv (f (Nat.succ m))) (HMul.hMul.{u2, u2, u2} \u03b1 \u03b1 \u03b1 (instHMul.{u2} \u03b1 (NonUnitalNonAssocRing.toMul.{u2} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b1 (Ring.toNonAssocRing.{u2} \u03b1 (StrictOrderedRing.toRing.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1)))))))) r (abv (f m))))) -> (IsCauSeq.{u2, u1} \u03b1 _inst_1 \u03b2 _inst_3 abv (fun (m : Nat) => Finset.sum.{u1, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_3)))) (Finset.range m) (fun (n : Nat) => f n)))\nCase conversion may be inaccurate. Consider using '#align series_ratio_test series_ratio_test\u2093'. -/\ntheorem series_ratio_test {f : \u2115 \u2192 \u03b2} (n : \u2115) (r : \u03b1) (hr0 : 0 \u2264 r) (hr1 : r < 1)\n    (h : \u2200 m, n \u2264 m \u2192 abv (f m.succ) \u2264 r * abv (f m)) : IsCauSeq abv fun m => \u2211 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\u207b\u00b9 ^ n.succ) har1)\n  intro m hmn\n  cases' Classical.em (r = 0) with r_zero r_ne_zero\n  \u00b7 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  \u00b7 rw [hk, zero_add, mul_right_comm, inv_pow _ _, \u2190 div_eq_mul_inv, mul_div_cancel]\n    exact (ne_of_lt (pow_pos r_pos _)).symm\n  \u00b7 have kn : k + n.succ \u2265 n.succ := by\n      rw [\u2190 zero_add n.succ] <;> exact add_le_add (zero_le _) (by simp)\n    rw [hk, Nat.succ_add, pow_succ' r, \u2190 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 {\u03b1 : Type _} [AddCommMonoid \u03b1] (n : \u2115) (f : \u2115 \u2192 \u2115 \u2192 \u03b1) :\n    (\u2211 m in range n, \u2211 k in range (m + 1), f k (m - k)) =\n      \u2211 m in range n, \u2211 k in range (n - m), f m k :=\n  by\n  rw [sum_sigma', sum_sigma'] <;>\n    exact\n      sum_bij (fun a _ => \u27e8a.2, a.1 - a.2\u27e9)\n        (fun a ha =>\n          have h\u2081 : a.1 < n := mem_range.1 (mem_sigma.1 ha).1\n          have h\u2082 : a.2 < Nat.succ a.1 := mem_range.1 (mem_sigma.1 ha).2\n          mem_sigma.2\n            \u27e8mem_range.2 (lt_of_lt_of_le h\u2082 h\u2081),\n              mem_range.2 ((tsub_lt_tsub_iff_right (Nat.le_of_lt_succ h\u2082)).2 h\u2081)\u27e9)\n        (fun _ _ => rfl)\n        (fun \u27e8a\u2081, a\u2082\u27e9 \u27e8b\u2081, b\u2082\u27e9 ha hb h =>\n          have ha : a\u2081 < n \u2227 a\u2082 \u2264 a\u2081 :=\n            \u27e8mem_range.1 (mem_sigma.1 ha).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 ha).2)\u27e9\n          have hb : b\u2081 < n \u2227 b\u2082 \u2264 b\u2081 :=\n            \u27e8mem_range.1 (mem_sigma.1 hb).1, Nat.le_of_lt_succ (mem_range.1 (mem_sigma.1 hb).2)\u27e9\n          have h : a\u2082 = b\u2082 \u2227 _ := Sigma.mk.inj h\n          have h' : a\u2081 = b\u2081 - b\u2082 + a\u2082 := (tsub_eq_iff_eq_add_of_le ha.2).1 (eq_of_hEq h.2)\n          Sigma.mk.inj_iff.2 \u27e8tsub_add_cancel_of_le hb.2 \u25b8 h'.symm \u25b8 h.1 \u25b8 rfl, hEq_of_eq h.1\u27e9)\n        fun \u27e8a\u2081, a\u2082\u27e9 ha =>\n        have ha : a\u2081 < n \u2227 a\u2082 < n - a\u2081 :=\n          \u27e8mem_range.1 (mem_sigma.1 ha).1, mem_range.1 (mem_sigma.1 ha).2\u27e9\n        \u27e8\u27e8a\u2082 + a\u2081, a\u2081\u27e9,\n          \u27e8mem_sigma.2\n              \u27e8mem_range.2 (lt_tsub_iff_right.1 ha.2),\n                mem_range.2 (Nat.lt_succ_of_le (Nat.le_add_left _ _))\u27e9,\n            Sigma.mk.inj_iff.2 \u27e8rfl, hEq_of_eq (add_tsub_cancel_right _ _).symm\u27e9\u27e9\u27e9\n#align sum_range_diag_flip sum_range_diag_flip\n-/\n\nend\n\nsection NoArchimedean\n\nvariable {\u03b1 : Type _} {\u03b2 : Type _} [LinearOrderedField \u03b1] {abv : \u03b2 \u2192 \u03b1}\n\nsection\n\nvariable [Semiring \u03b2] [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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {abv : \u03b2 -> \u03b1} [_inst_2 : Semiring.{u2} \u03b2] [_inst_3 : IsAbsoluteValue.{u1, u2} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) \u03b2 _inst_2 abv] {\u03b3 : Type.{u3}} (f : \u03b3 -> \u03b2) (s : Finset.{u3} \u03b3), LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (abv (Finset.sum.{u2, u3} \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u2} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} \u03b2 (Semiring.toNonAssocSemiring.{u2} \u03b2 _inst_2))) s (fun (k : \u03b3) => f k))) (Finset.sum.{u1, u3} \u03b1 \u03b3 (AddCommGroup.toAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) s (fun (k : \u03b3) => abv (f k)))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} \u03b1] {abv : \u03b2 -> \u03b1} [_inst_2 : Semiring.{u1} \u03b2] [_inst_3 : IsAbsoluteValue.{u2, u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u2} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_1))))) \u03b2 _inst_2 abv] {\u03b3 : Type.{u3}} (f : \u03b3 -> \u03b2) (s : Finset.{u3} \u03b3), LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (StrictOrderedRing.toPartialOrder.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1)))))) (abv (Finset.sum.{u1, u3} \u03b2 \u03b3 (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} \u03b2 (Semiring.toNonAssocSemiring.{u1} \u03b2 _inst_2))) s (fun (k : \u03b3) => f k))) (Finset.sum.{u2, u3} \u03b1 \u03b3 (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_1)))))) s (fun (k : \u03b3) => abv (f k)))\nCase conversion may be inaccurate. Consider using '#align abv_sum_le_sum_abv abv_sum_le_sum_abv\u2093'. -/\ntheorem abv_sum_le_sum_abv {\u03b3 : Type _} (f : \u03b3 \u2192 \u03b2) (s : Finset \u03b3) :\n    abv (\u2211 k in s, f k) \u2264 \u2211 k in s, abv (f k) :=\n  haveI := Classical.decEq \u03b3\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 \u03b2] [IsAbsoluteValue abv]\n\n/- warning: cauchy_product -> cauchy_product is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : LinearOrderedField.{u1} \u03b1] {abv : \u03b2 -> \u03b1} [_inst_2 : Ring.{u2} \u03b2] [_inst_3 : IsAbsoluteValue.{u1, u2} \u03b1 (StrictOrderedSemiring.toOrderedSemiring.{u1} \u03b1 (StrictOrderedRing.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))) \u03b2 (Ring.toSemiring.{u2} \u03b2 _inst_2) abv] {a : Nat -> \u03b2} {b : Nat -> \u03b2}, (IsCauSeq.{u1, u1} \u03b1 _inst_1 \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))) (Abs.abs.{u1} \u03b1 (Neg.toHasAbs.{u1} \u03b1 (SubNegMonoid.toHasNeg.{u1} \u03b1 (AddGroup.toSubNegMonoid.{u1} \u03b1 (AddGroupWithOne.toAddGroup.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))) (SemilatticeSup.toHasSup.{u1} \u03b1 (Lattice.toSemilatticeSup.{u1} \u03b1 (LinearOrder.toLattice.{u1} \u03b1 (LinearOrderedRing.toLinearOrder.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (fun (m : Nat) => Finset.sum.{u1, 0} \u03b1 Nat (AddCommGroup.toAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Finset.range m) (fun (n : Nat) => abv (a n)))) -> (IsCauSeq.{u1, u2} \u03b1 _inst_1 \u03b2 _inst_2 abv (fun (m : Nat) => Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_2)))) (Finset.range m) (fun (n : Nat) => b n))) -> (forall (\u03b5 : \u03b1), (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (OfNat.ofNat.{u1} \u03b1 0 (OfNat.mk.{u1} \u03b1 0 (Zero.zero.{u1} \u03b1 (MulZeroClass.toHasZero.{u1} \u03b1 (NonUnitalNonAssocSemiring.toMulZeroClass.{u1} \u03b1 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))))))) \u03b5) -> (Exists.{1} Nat (fun (i : Nat) => forall (j : Nat), (GE.ge.{0} Nat Nat.hasLe j i) -> (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (abv (HSub.hSub.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHSub.{u2} \u03b2 (SubNegMonoid.toHasSub.{u2} \u03b2 (AddGroup.toSubNegMonoid.{u2} \u03b2 (AddGroupWithOne.toAddGroup.{u2} \u03b2 (AddCommGroupWithOne.toAddGroupWithOne.{u2} \u03b2 (Ring.toAddCommGroupWithOne.{u2} \u03b2 _inst_2)))))) (HMul.hMul.{u2, u2, u2} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 _inst_2))) (Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_2)))) (Finset.range j) (fun (k : Nat) => a k)) (Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_2)))) (Finset.range j) (fun (k : Nat) => b k))) (Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _inst_2)))) (Finset.range j) (fun (n : Nat) => Finset.sum.{u2, 0} \u03b2 Nat (AddCommGroup.toAddCommMonoid.{u2} \u03b2 (NonUnitalNonAssocRing.toAddCommGroup.{u2} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u2} \u03b2 (Ring.toNonAssocRing.{u2} \u03b2 _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} \u03b2 \u03b2 \u03b2 (instHMul.{u2} \u03b2 (Distrib.toHasMul.{u2} \u03b2 (Ring.toDistrib.{u2} \u03b2 _inst_2))) (a m) (b (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) n m))))))) \u03b5))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : LinearOrderedField.{u2} \u03b1] {abv : \u03b2 -> \u03b1} [_inst_2 : Ring.{u1} \u03b2] [_inst_3 : IsAbsoluteValue.{u2, u1} \u03b1 (OrderedCommSemiring.toOrderedSemiring.{u2} \u03b1 (StrictOrderedCommSemiring.toOrderedCommSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toStrictOrderedCommSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_1))))) \u03b2 (Ring.toSemiring.{u1} \u03b2 _inst_2) abv] {a : Nat -> \u03b2} {b : Nat -> \u03b2}, (IsCauSeq.{u2, u2} \u03b1 _inst_1 \u03b1 (StrictOrderedRing.toRing.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1)))) (Abs.abs.{u2} \u03b1 (Neg.toHasAbs.{u2} \u03b1 (Ring.toNeg.{u2} \u03b1 (StrictOrderedRing.toRing.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1))))) (SemilatticeSup.toSup.{u2} \u03b1 (Lattice.toSemilatticeSup.{u2} \u03b1 (DistribLattice.toLattice.{u2} \u03b1 (instDistribLattice.{u2} \u03b1 (LinearOrderedRing.toLinearOrder.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1))))))))) (fun (m : Nat) => Finset.sum.{u2, 0} \u03b1 Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u2} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u2} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u2} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u2} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_1)))))) (Finset.range m) (fun (n : Nat) => abv (a n)))) -> (IsCauSeq.{u2, u1} \u03b1 _inst_1 \u03b2 _inst_2 abv (fun (m : Nat) => Finset.sum.{u1, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_2)))) (Finset.range m) (fun (n : Nat) => b n))) -> (forall (\u03b5 : \u03b1), (LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (StrictOrderedRing.toPartialOrder.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1)))))) (OfNat.ofNat.{u2} \u03b1 0 (Zero.toOfNat0.{u2} \u03b1 (CommMonoidWithZero.toZero.{u2} \u03b1 (CommGroupWithZero.toCommMonoidWithZero.{u2} \u03b1 (Semifield.toCommGroupWithZero.{u2} \u03b1 (LinearOrderedSemifield.toSemifield.{u2} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u2} \u03b1 _inst_1))))))) \u03b5) -> (Exists.{1} Nat (fun (i : Nat) => forall (j : Nat), (GE.ge.{0} Nat instLENat j i) -> (LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 (PartialOrder.toPreorder.{u2} \u03b1 (StrictOrderedRing.toPartialOrder.{u2} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u2} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u2} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u2} \u03b1 _inst_1)))))) (abv (HSub.hSub.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHSub.{u1} \u03b2 (Ring.toSub.{u1} \u03b2 _inst_2)) (HMul.hMul.{u1, u1, u1} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (NonUnitalNonAssocRing.toMul.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_2)))) (Finset.sum.{u1, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_2)))) (Finset.range j) (fun (k : Nat) => a k)) (Finset.sum.{u1, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_2)))) (Finset.range j) (fun (k : Nat) => b k))) (Finset.sum.{u1, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_2)))) (Finset.range j) (fun (n : Nat) => Finset.sum.{u1, 0} \u03b2 Nat (NonUnitalNonAssocSemiring.toAddCommMonoid.{u1} \u03b2 (NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _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} \u03b2 \u03b2 \u03b2 (instHMul.{u1} \u03b2 (NonUnitalNonAssocRing.toMul.{u1} \u03b2 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b2 (Ring.toNonAssocRing.{u1} \u03b2 _inst_2)))) (a m) (b (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) n m))))))) \u03b5))))\nCase conversion may be inaccurate. Consider using '#align cauchy_product cauchy_product\u2093'. -/\ntheorem cauchy_product {a b : \u2115 \u2192 \u03b2} (ha : IsCauSeq abs fun m => \u2211 n in range m, abv (a n))\n    (hb : IsCauSeq abv fun m => \u2211 n in range m, b n) (\u03b5 : \u03b1) (\u03b50 : 0 < \u03b5) :\n    \u2203 i : \u2115,\n      \u2200 j \u2265 i,\n        abv\n            (((\u2211 k in range j, a k) * \u2211 k in range j, b k) -\n              \u2211 n in range j, \u2211 m in range (n + 1), a m * b (n - m)) <\n          \u03b5 :=\n  let \u27e8Q, hQ\u27e9 := CauSeq.bounded \u27e8_, hb\u27e9\n  let \u27e8P, hP\u27e9 := CauSeq.bounded \u27e8_, ha\u27e9\n  have hP0 : 0 < P := lt_of_le_of_lt (abs_nonneg _) (hP 0)\n  have hP\u03b50 : 0 < \u03b5 / (2 * P) := div_pos \u03b50 (mul_pos (show (2 : \u03b1) > 0 by norm_num) hP0)\n  let \u27e8N, hN\u27e9 := CauSeq.cauchy\u2082 \u27e8_, hb\u27e9 hP\u03b50\n  have hQ\u03b50 : 0 < \u03b5 / (4 * Q) :=\n    div_pos \u03b50 (mul_pos (show (0 : \u03b1) < 4 by norm_num) (lt_of_le_of_lt (abv_nonneg _ _) (hQ 0)))\n  let \u27e8M, hM\u27e9 := CauSeq.cauchy\u2082 \u27e8_, ha\u27e9 hQ\u03b50\n  \u27e82 * (max N M + 1), fun K hK =>\n    by\n    have h\u2081 :\n      (\u2211 m in range K, \u2211 k in range (m + 1), a k * b (m - k)) =\n        \u2211 m in range K, \u2211 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\u2082 :\n      (fun i => \u2211 k in range (K - i), a i * b k) = fun i => a i * \u2211 k in range (K - i), b k := by\n      simp [Finset.mul_sum]\n    have h\u2083 :\n      (\u2211 i in range K, a i * \u2211 k in range (K - i), b k) =\n        (\u2211 i in range K, a i * ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) +\n          \u2211 i in range K, a i * \u2211 k in range K, b k :=\n      by rw [\u2190 sum_add_distrib] <;> simp [(mul_add _ _ _).symm]\n    have two_mul_two : (4 : \u03b1) = 2 * 2 := by norm_num\n    have hQ0 : Q \u2260 0 := fun h => by simpa [h, lt_irrefl] using hQ\u03b50\n    have h2Q0 : 2 * Q \u2260 0 := mul_ne_zero two_ne_zero hQ0\n    have h\u03b5 : \u03b5 / (2 * P) * P + \u03b5 / (4 * Q) * (2 * Q) = \u03b5 := by\n      rw [\u2190 div_div, div_mul_cancel _ (Ne.symm (ne_of_lt hP0)), two_mul_two, mul_assoc, \u2190 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 \u2264 max N M := le_max_left _ _\n        _ < max N M + 1 := (Nat.lt_succ_self _)\n        _ < K := hNMK\n        \n    have hsumlesum :\n      (\u2211 i in range (max N M + 1),\n          abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) \u2264\n        \u2211 i in range (max N M + 1), abv (a i) * (\u03b5 / (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 : (\u2211 n in range (max N M + 1), abv (a n)) < P :=\n      calc\n        (\u2211 n in range (max N M + 1), abv (a n)) = |\u2211 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\u2081, h\u2082, h\u2083, sum_mul, \u2190 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      (\u2211 i in range (max N M + 1),\n            abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) +\n          ((\u2211 i in range K, abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) -\n            \u2211 i in range (max N M + 1),\n              abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) <\n        \u03b5 / (2 * P) * P + \u03b5 / (4 * Q) * (2 * Q)\n      by\n      rw [h\u03b5] at this\n      simpa [abv_mul abv]\n    refine'\n      add_lt_add\n        (lt_of_le_of_lt hsumlesum\n          (by rw [\u2190 sum_mul, mul_comm] <;> exact (mul_lt_mul_left hP\u03b50).mpr hsumltP))\n        _\n    rw [sum_range_sub_sum_range (le_of_lt hNMK)]\n    calc\n      (\u2211 i in (range K).filter\u2093 fun k => max N M + 1 \u2264 k,\n            abv (a i) * abv ((\u2211 k in range (K - i), b k) - \u2211 k in range K, b k)) \u2264\n          \u2211 i in (range K).filter\u2093 fun k => max N M + 1 \u2264 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      _ < \u03b5 / (4 * Q) * (2 * Q) := by\n        rw [\u2190 sum_mul, \u2190 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      \u27e9\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\u2093.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\u2093'. -/\ntheorem isCauSeq_abs_exp (z : \u2102) : IsCauSeq Abs.abs fun n => \u2211 m in range n, abs (z ^ m / m !) :=\n  let \u27e8n, hn\u27e9 := exists_nat_gt (abs z)\n  have hn0 : (0 : \u211d) < 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, \u2190 div_div,\n        mul_div_assoc, mul_div_right_comm, abs.map_mul, map_div\u2080, 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\u2093.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\u2093'. -/\ntheorem isCauSeq_exp (z : \u2102) : IsCauSeq abs fun n => \u2211 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'\u2093'. -/\n/-- The Cauchy sequence consisting of partial sums of the Taylor series of\nthe complex exponential function -/\n@[pp_nodot]\ndef exp' (z : \u2102) : CauSeq \u2102 Complex.abs :=\n  \u27e8fun n => \u2211 m in range n, z ^ m / m !, isCauSeq_exp z\u27e9\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u2102) : \u2102 :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\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 : \u211d) : \u211d :=\n  (tanh x).re\n#align real.tanh Real.tanh\n-/\n\nend Real\n\nnamespace Complex\n\nvariable (x y : \u2102)\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\u2093'. -/\n@[simp]\ntheorem exp_zero : exp 0 = 1 := by\n  rw [exp]\n  refine' lim_eq_of_equiv_const fun \u03b5 \u03b50 => \u27e81, fun j hj => _\u27e9\n  convert \u03b50\n  cases j\n  \u00b7 exact absurd hj (not_le_of_gt zero_lt_one)\n  \u00b7 dsimp [exp']\n    induction' j with j ih\n    \u00b7 dsimp [exp'] <;> simp\n    \u00b7 rw [\u2190 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\u2093'. -/\ntheorem exp_add : exp (x + y) = exp x * exp y :=\n  by\n  have hj :\n    \u2200 j : \u2115,\n      (\u2211 m in range j, (x + y) ^ m / m !) =\n        \u2211 i in range j, \u2211 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\u2081 : (m.choose i : \u2102) \u2260 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\u2082 := Nat.choose_mul_factorial_mul_factorial (Nat.le_of_lt_succ <| Finset.mem_range.1 hi)\n    rw [\u2190 h\u2082, Nat.cast_mul, Nat.cast_mul, mul_inv, mul_inv]\n    simp only [mul_left_comm (m.choose i : \u2102), mul_assoc, mul_left_comm (m.choose i : \u2102)\u207b\u00b9,\n      mul_comm (m.choose i : \u2102)]\n    rw [inv_mul_cancel h\u2081]\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 \u2102) : exp l.Sum = (l.map exp).Prod :=\n  @MonoidHom.map_list_prod (Multiplicative \u2102) \u2102 _ _ \u27e8exp, exp_zero, exp_add\u27e9 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 \u2102) : exp s.Sum = (s.map exp).Prod :=\n  @MonoidHom.map_multiset_prod (Multiplicative \u2102) \u2102 _ _ \u27e8exp, exp_zero, exp_add\u27e9 s\n#align complex.exp_multiset_sum Complex.exp_multiset_sum\n-/\n\n#print Complex.exp_sum /-\ntheorem exp_sum {\u03b1 : Type _} (s : Finset \u03b1) (f : \u03b1 \u2192 \u2102) :\n    exp (\u2211 x in s, f x) = \u220f x in s, exp (f x) :=\n  @MonoidHom.map_prod (Multiplicative \u2102) \u03b1 \u2102 _ _ \u27e8exp, exp_zero, exp_add\u27e9 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\u2093.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\u2093'. -/\ntheorem exp_nat_mul (x : \u2102) : \u2200 n : \u2115, 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, \u2190 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\u2093'. -/\ntheorem exp_ne_zero : exp x \u2260 0 := fun h =>\n  zero_ne_one <| by rw [\u2190 exp_zero, \u2190 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\u2093'. -/\ntheorem exp_neg : exp (-x) = (exp x)\u207b\u00b9 := by\n  rw [\u2190 mul_right_inj' (exp_ne_zero x), \u2190 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\u2093'. -/\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\u2093.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\u2093'. -/\ntheorem exp_int_mul (z : \u2102) (n : \u2124) : Complex.exp (n * z) = Complex.exp z ^ n :=\n  by\n  cases n\n  \u00b7 apply Complex.exp_nat_mul\n  \u00b7 simpa [Complex.exp_neg, add_comm, \u2190 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\u2093'. -/\n@[simp]\ntheorem exp_conj : exp (conj x) = conj (exp x) :=\n  by\n  dsimp [exp]\n  rw [\u2190 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\u2080, map_pow, \u2190 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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem ofReal_exp_ofReal_re (x : \u211d) : ((exp x).re : \u2102) = exp x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem ofReal_exp (x : \u211d) : (Real.exp x : \u2102) = 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\u2093.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\u2093'. -/\n@[simp]\ntheorem exp_ofReal_im (x : \u211d) : (exp x).im = 0 := by rw [\u2190 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\u2093.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\u2093'. -/\ntheorem exp_ofReal_re (x : \u211d) : (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\u2093'. -/\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\u2093'. -/\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 : \u2102} :\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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), two_sinh, exp_add, neg_add, exp_add, eq_comm, mul_add, \u2190\n    mul_assoc, two_sinh, mul_left_comm, two_sinh, \u2190 mul_right_inj' (two_ne_zero' \u2102), mul_add,\n    mul_left_comm, two_cosh, \u2190 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 : \u2102} :\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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), two_cosh, exp_add, neg_add, exp_add, eq_comm, mul_add, \u2190\n    mul_assoc, two_cosh, \u2190 mul_assoc, two_sinh, \u2190 mul_right_inj' (two_ne_zero' \u2102), 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, \u2190 RingHom.map_neg, exp_conj, exp_conj, \u2190 RingHom.map_sub, sinh, map_div\u2080, 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 : \u211d) : ((sinh x).re : \u2102) = sinh x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem ofReal_sinh (x : \u211d) : (Real.sinh x : \u2102) = 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 : \u211d) : (sinh x).im = 0 := by rw [\u2190 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 : \u211d) : (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, \u2190 RingHom.map_neg, exp_conj, exp_conj, \u2190 RingHom.map_add, cosh, map_div\u2080, 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 : \u211d) : ((cosh x).re : \u2102) = cosh x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem ofReal_cosh (x : \u211d) : (Real.cosh x : \u2102) = 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 : \u211d) : (cosh x).im = 0 := by rw [\u2190 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 : \u211d) : (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\u2093'. -/\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, \u2190 map_div\u2080, 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 : \u211d) : ((tanh x).re : \u2102) = tanh x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem ofReal_tanh (x : \u211d) : (Real.tanh x : \u2102) = 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 : \u211d) : (tanh x).im = 0 := by rw [\u2190 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 : \u211d) : (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\u2093'. -/\n@[simp]\ntheorem cosh_add_sinh : cosh x + sinh x = exp x := by\n  rw [\u2190 mul_right_inj' (two_ne_zero' \u2102), 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem cosh_sub_sinh : cosh x - sinh x = exp (-x) := by\n  rw [\u2190 mul_right_inj' (two_ne_zero' \u2102), 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\u2093'. -/\n@[simp]\ntheorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [\u2190 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\u2093'. -/\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, \u2190 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\u2093'. -/\ntheorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 :=\n  by\n  rw [\u2190 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 [\u2190 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 [\u2190 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\u2093'. -/\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\u2093'. -/\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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), two_sinh, \u2190 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 [\u2190 mul_right_inj' (two_ne_zero' \u2102), 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 [\u2190 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, \u2190 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 [\u2190 mul_left_inj' I_ne_zero, \u2190 sinh_mul_I, add_mul, add_mul, mul_right_comm, \u2190 sinh_mul_I,\n    mul_assoc, \u2190 sinh_mul_I, \u2190 cosh_mul_I, \u2190 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 : \u2102} :\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 [\u2190 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 : \u2102) : 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem sin_eq (z : \u2102) : 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 : \u2102) : 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem cos_eq (z : \u2102) : 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\u2093'. -/\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, \u2190 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\u2093'. -/\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, \u2190 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\u2093'. -/\ntheorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) :=\n  by\n  have h2 : (2 : \u2102) \u2260 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  \u00b7 congr <;> field_simp [h2] <;> ring\n  \u00b7 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 [\u2190 mul_left_inj' I_ne_zero, \u2190 sinh_mul_I, \u2190 conj_neg_I, \u2190 RingHom.map_mul, \u2190 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 : \u211d) : ((sin x).re : \u2102) = sin x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem ofReal_sin (x : \u211d) : (Real.sin x : \u2102) = 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 : \u211d) : (sin x).im = 0 := by rw [\u2190 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 : \u211d) : (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 [\u2190 cosh_mul_I, \u2190 conj_neg_I, \u2190 RingHom.map_mul, \u2190 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 : \u211d) : ((cos x).re : \u2102) = cos x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem ofReal_cos (x : \u211d) : (Real.cos x : \u2102) = 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 : \u211d) : (cos x).im = 0 := by rw [\u2190 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 : \u211d) : (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\u2093'. -/\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\u2093'. -/\ntheorem tan_mul_cos {x : \u2102} (hx : cos x \u2260 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, \u2190 map_div\u2080, 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 : \u211d) : ((tan x).re : \u2102) = tan x :=\n  eq_conj_iff_re.1 <| by rw [\u2190 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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem ofReal_tan (x : \u211d) : (Real.tan x : \u2102) = 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 : \u211d) : (tan x).im = 0 := by rw [\u2190 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 : \u211d) : (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\u2093'. -/\ntheorem cos_add_sin_I : cos x + sin x * I = exp (x * I) := by\n  rw [\u2190 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\u2093'. -/\ntheorem cos_sub_sin_I : cos x - sin x * I = exp (-x * I) := by\n  rw [neg_mul, \u2190 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\u2093'. -/\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\u2093'. -/\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, \u2190 sq, \u2190 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), \u2190 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\u2093'. -/\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'\u2093'. -/\ntheorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [\u2190 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\u2093'. -/\ntheorem sin_sq : sin x ^ 2 = 1 - cos x ^ 2 := by rw [\u2190 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\u2093'. -/\ntheorem inv_one_add_tan_sq {x : \u2102} (hx : cos x \u2260 0) : (1 + tan x ^ 2)\u207b\u00b9 = cos x ^ 2 :=\n  by\n  have : cos x ^ 2 \u2260 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\u2093'. -/\ntheorem tan_sq_div_one_add_tan_sq {x : \u2102} (hx : cos x \u2260 0) :\n    tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by\n  simp only [\u2190 tan_mul_cos hx, mul_pow, \u2190 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 [\u2190 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 [\u2190 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\u2093'. -/\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\u2093'. -/\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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem exp_eq_exp_re_mul_sin_add_cos : exp x = exp x.re * (cos x.im + sin x.im * I) := by\n  rw [\u2190 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\u2093'. -/\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\u2093'. -/\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\u2093.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\u2093'. -/\n@[simp]\ntheorem exp_ofReal_mul_I_re (x : \u211d) : (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\u2093.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\u2093'. -/\n@[simp]\ntheorem exp_ofReal_mul_I_im (x : \u211d) : (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\u2093.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\u2093.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\u2093'. -/\n/-- **De Moivre's formula** -/\ntheorem cos_add_sin_mul_I_pow (n : \u2115) (z : \u2102) :\n    (cos z + sin z * I) ^ n = cos (\u2191n * z) + sin (\u2191n * z) * I :=\n  by\n  rw [\u2190 exp_mul_I, \u2190 exp_mul_I]\n  induction' n with n ih\n  \u00b7 rw [pow_zero, Nat.cast_zero, MulZeroClass.zero_mul, MulZeroClass.zero_mul, exp_zero]\n  \u00b7 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 : \u211d)\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\u2093'. -/\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\u2093'. -/\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 \u211d) : exp l.Sum = (l.map exp).Prod :=\n  @MonoidHom.map_list_prod (Multiplicative \u211d) \u211d _ _ \u27e8exp, exp_zero, exp_add\u27e9 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 \u211d) : exp s.Sum = (s.map exp).Prod :=\n  @MonoidHom.map_multiset_prod (Multiplicative \u211d) \u211d _ _ \u27e8exp, exp_zero, exp_add\u27e9 s\n#align real.exp_multiset_sum Real.exp_multiset_sum\n-/\n\n#print Real.exp_sum /-\ntheorem exp_sum {\u03b1 : Type _} (s : Finset \u03b1) (f : \u03b1 \u2192 \u211d) :\n    exp (\u2211 x in s, f x) = \u220f x in s, exp (f x) :=\n  @MonoidHom.map_prod (Multiplicative \u211d) \u03b1 \u211d _ _ \u27e8exp, exp_zero, exp_add\u27e9 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\u2093.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\u2093'. -/\ntheorem exp_nat_mul (x : \u211d) : \u2200 n : \u2115, 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, \u2190 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\u2093'. -/\ntheorem exp_ne_zero : exp x \u2260 0 := fun h =>\n  exp_ne_zero x <| by rw [exp, \u2190 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\u2093'. -/\ntheorem exp_neg : exp (-x) = (exp x)\u207b\u00b9 := by\n  rw [\u2190 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\u2093'. -/\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 [\u2190 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 [\u2190 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\u2093'. -/\ntheorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem cos_sub_cos : cos x - cos y = -2 * sin ((x + y) / 2) * sin ((x - y) / 2) :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem cos_add_cos : cos x + cos y = 2 * cos ((x + y) / 2) * cos ((x - y) / 2) :=\n  by\n  rw [\u2190 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\u2093'. -/\ntheorem tan_eq_sin_div_cos : tan x = sin x / cos x := by\n  rw [\u2190 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\u2093'. -/\ntheorem tan_mul_cos {x : \u211d} (hx : cos x \u2260 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\ntheorem sin_sq_le_one : sin x ^ 2 \u2264 1 := by\n  rw [\u2190 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\u2093'. -/\ntheorem cos_sq_le_one : cos x ^ 2 \u2264 1 := by\n  rw [\u2190 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\u2093'. -/\ntheorem abs_sin_le_one : |sin x| \u2264 1 :=\n  abs_le_one_iff_mul_self_le_one.2 <| by simp only [\u2190 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\u2093'. -/\ntheorem abs_cos_le_one : |cos x| \u2264 1 :=\n  abs_le_one_iff_mul_self_le_one.2 <| by simp only [\u2190 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\u2093'. -/\ntheorem sin_le_one : sin x \u2264 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\u2093'. -/\ntheorem cos_le_one : cos x \u2264 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\u2093'. -/\ntheorem neg_one_le_sin : -1 \u2264 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\u2093'. -/\ntheorem neg_one_le_cos : -1 \u2264 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 [\u2190 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 [\u2190 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 [\u2190 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\u2093'. -/\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'\u2093'. -/\ntheorem cos_sq' : cos x ^ 2 = 1 - sin x ^ 2 := by rw [\u2190 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\u2093'. -/\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\u2093'. -/\ntheorem abs_sin_eq_sqrt_one_sub_cos_sq (x : \u211d) : |sin x| = sqrt (1 - cos x ^ 2) := by\n  rw [\u2190 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\u2093'. -/\ntheorem abs_cos_eq_sqrt_one_sub_sin_sq (x : \u211d) : |cos x| = sqrt (1 - sin x ^ 2) := by\n  rw [\u2190 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\u2093'. -/\ntheorem inv_one_add_tan_sq {x : \u211d} (hx : cos x \u2260 0) : (1 + tan x ^ 2)\u207b\u00b9 = cos x ^ 2 :=\n  have : Complex.cos x \u2260 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\u2093'. -/\ntheorem tan_sq_div_one_add_tan_sq {x : \u211d} (hx : cos x \u2260 0) :\n    tan x ^ 2 / (1 + tan x ^ 2) = sin x ^ 2 := by\n  simp only [\u2190 tan_mul_cos hx, mul_pow, \u2190 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\u2093'. -/\ntheorem inv_sqrt_one_add_tan_sq {x : \u211d} (hx : 0 < cos x) : (sqrt (1 + tan x ^ 2))\u207b\u00b9 = cos x := by\n  rw [\u2190 sqrt_sq hx.le, \u2190 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\u2093'. -/\ntheorem tan_div_sqrt_one_add_tan_sq {x : \u211d} (hx : 0 < cos x) :\n    tan x / sqrt (1 + tan x ^ 2) = sin x := by\n  rw [\u2190 tan_mul_cos hx.ne', \u2190 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 [\u2190 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 [\u2190 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\u2093'. -/\n/-- The definition of `sinh` in terms of `exp`. -/\ntheorem sinh_eq (x : \u211d) : 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, \u2190 Complex.add_re, \u2190 mul_two,\n      div_mul_cancel _ (two_ne_zero' \u2102), 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 [\u2190 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\u2093'. -/\n/-- The definition of `cosh` in terms of `exp`. -/\ntheorem cosh_eq (x : \u211d) : 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, \u2190 Complex.add_re, \u2190 mul_two,\n      div_mul_cancel _ (two_ne_zero' \u2102), 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 [\u2190 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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem cosh_add_sinh : cosh x + sinh x = exp x := by rw [\u2190 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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem cosh_sub_sinh : cosh x - sinh x = exp (-x) :=\n  by\n  rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem sinh_sub_cosh : sinh x - cosh x = -exp (-x) := by rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem cosh_sq_sub_sinh_sq (x : \u211d) : cosh x ^ 2 - sinh x ^ 2 = 1 := by rw [\u2190 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\u2093'. -/\ntheorem cosh_sq : cosh x ^ 2 = sinh x ^ 2 + 1 := by rw [\u2190 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'\u2093'. -/\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\u2093'. -/\ntheorem sinh_sq : sinh x ^ 2 = cosh x ^ 2 - 1 := by rw [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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 [\u2190 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\u2093'. -/\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 : \u211d} (hx : 0 \u2264 x) : x + 1 \u2264 exp x :=\n  calc\n    x + 1 \u2264 limUnder (\u27e8fun n : \u2115 => ((exp' x) n).re, isCauSeq_re (exp' x)\u27e9 : CauSeq \u211d Abs.abs) :=\n      le_lim\n        (CauSeq.le_of_exists\n          \u27e82, fun j hj =>\n            show x + (1 : \u211d) \u2264 (\u2211 m in range j, (x ^ m / m ! : \u2102)).re\n              by\n              have h\u2081 : (((fun m : \u2115 => (x ^ m / m ! : \u2102)) \u2218 Nat.succ) 0).re = x := by simp\n              have h\u2082 : ((x : \u2102) ^ 0 / 0!).re = 1 := by simp\n              rw [\u2190 tsub_add_cancel_of_le hj, sum_range_succ', sum_range_succ', add_re, add_re, h\u2081,\n                h\u2082, add_assoc, \u2190 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 [\u2190 of_real_pow, \u2190 of_real_nat_cast, \u2190 of_real_div, of_real_re]\n              exact div_nonneg (pow_nonneg hx _) (Nat.cast_nonneg _)\u27e9)\n    _ = exp x := by rw [exp, Complex.exp, \u2190 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\u2093'. -/\ntheorem one_le_exp {x : \u211d} (hx : 0 \u2264 x) : 1 \u2264 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\u2093'. -/\ntheorem exp_pos (x : \u211d) : 0 < exp x :=\n  (le_total 0 x).elim (lt_of_lt_of_le zero_lt_one \u2218 one_le_exp) fun h => by\n    rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem abs_exp (x : \u211d) : |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 [\u2190 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\u2093'. -/\n@[simp]\ntheorem exp_lt_exp {x y : \u211d} : exp x < exp y \u2194 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\u2093'. -/\n@[simp]\ntheorem exp_le_exp {x y : \u211d} : exp x \u2264 exp y \u2194 x \u2264 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 : \u211d} : exp x = exp y \u2194 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\u2093'. -/\n@[simp]\ntheorem exp_eq_one_iff : exp x = 1 \u2194 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\u2093'. -/\n@[simp]\ntheorem one_lt_exp_iff {x : \u211d} : 1 < exp x \u2194 0 < x := by rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem exp_lt_one_iff {x : \u211d} : exp x < 1 \u2194 x < 0 := by rw [\u2190 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\u2093'. -/\n@[simp]\ntheorem exp_le_one_iff {x : \u211d} : exp x \u2264 1 \u2194 x \u2264 0 :=\n  exp_zero \u25b8 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\u2093'. -/\n@[simp]\ntheorem one_le_exp_iff {x : \u211d} : 1 \u2264 exp x \u2194 0 \u2264 x :=\n  exp_zero \u25b8 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\u2093'. -/\n/-- `real.cosh` is always positive -/\ntheorem cosh_pos (x : \u211d) : 0 < Real.cosh x :=\n  (cosh_eq x).symm \u25b8 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\u2093'. -/\ntheorem sinh_lt_cosh : sinh x < cosh x :=\n  lt_of_pow_lt_pow 2 (cosh_pos _).le <| (cosh_sq x).symm \u25b8 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 {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (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} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (OrderedAddCommGroup.toPartialOrder.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) (Finset.sum.{u1, 0} \u03b1 Nat (AddCommGroup.toAddCommMonoid.{u1} \u03b1 (OrderedAddCommGroup.toAddCommGroup.{u1} \u03b1 (StrictOrderedRing.toOrderedAddCommGroup.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _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} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 (AddMonoidWithOne.toOne.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (Nat.factorial m)))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (DivInvMonoid.toHasDiv.{u1} \u03b1 (DivisionRing.toDivInvMonoid.{u1} \u03b1 (Field.toDivisionRing.{u1} \u03b1 (LinearOrderedField.toField.{u1} \u03b1 _inst_1))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (Nat.succ n)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (Distrib.toHasMul.{u1} \u03b1 (Ring.toDistrib.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) (Nat.factorial n)) ((fun (a : Type) (b : Type.{u1}) [self : HasLiftT.{1, succ u1} a b] => self.0) Nat \u03b1 (HasLiftT.mk.{1, succ u1} Nat \u03b1 (CoeTC\u2093.coe.{1, succ u1} Nat \u03b1 (Nat.castCoe.{u1} \u03b1 (AddMonoidWithOne.toNatCast.{u1} \u03b1 (AddGroupWithOne.toAddMonoidWithOne.{u1} \u03b1 (AddCommGroupWithOne.toAddGroupWithOne.{u1} \u03b1 (Ring.toAddCommGroupWithOne.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1))))))))))) n))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u1}} [_inst_1 : LinearOrderedField.{u1} \u03b1] (n : Nat) (j : Nat), (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)) n) -> (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 (PartialOrder.toPreorder.{u1} \u03b1 (StrictOrderedRing.toPartialOrder.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Finset.sum.{u1, 0} \u03b1 Nat (OrderedCancelAddCommMonoid.toAddCommMonoid.{u1} \u03b1 (StrictOrderedSemiring.toOrderedCancelAddCommMonoid.{u1} \u03b1 (LinearOrderedSemiring.toStrictOrderedSemiring.{u1} \u03b1 (LinearOrderedCommSemiring.toLinearOrderedSemiring.{u1} \u03b1 (LinearOrderedSemifield.toLinearOrderedCommSemiring.{u1} \u03b1 (LinearOrderedField.toLinearOrderedSemifield.{u1} \u03b1 _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} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (OfNat.ofNat.{u1} \u03b1 1 (One.toOfNat1.{u1} \u03b1 (NonAssocRing.toOne.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (Nat.cast.{u1} \u03b1 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Nat.factorial m)))) (HDiv.hDiv.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHDiv.{u1} \u03b1 (LinearOrderedField.toDiv.{u1} \u03b1 _inst_1)) (Nat.cast.{u1} \u03b1 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Nat.succ n)) (HMul.hMul.{u1, u1, u1} \u03b1 \u03b1 \u03b1 (instHMul.{u1} \u03b1 (NonUnitalNonAssocRing.toMul.{u1} \u03b1 (NonAssocRing.toNonUnitalNonAssocRing.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))))) (Nat.cast.{u1} \u03b1 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) (Nat.factorial n)) (Nat.cast.{u1} \u03b1 (NonAssocRing.toNatCast.{u1} \u03b1 (Ring.toNonAssocRing.{u1} \u03b1 (StrictOrderedRing.toRing.{u1} \u03b1 (LinearOrderedRing.toStrictOrderedRing.{u1} \u03b1 (LinearOrderedCommRing.toLinearOrderedRing.{u1} \u03b1 (LinearOrderedField.toLinearOrderedCommRing.{u1} \u03b1 _inst_1)))))) n))))\nCase conversion may be inaccurate. Consider using '#align complex.sum_div_factorial_le Complex.sum_div_factorial_le\u2093'. -/\ntheorem sum_div_factorial_le {\u03b1 : Type _} [LinearOrderedField \u03b1] (n j : \u2115) (hn : 0 < n) :\n    (\u2211 m in Filter (fun k => n \u2264 k) (range j), (1 / m ! : \u03b1)) \u2264 n.succ / (n ! * n) :=\n  calc\n    (\u2211 m in Filter (fun k => n \u2264 k) (range j), (1 / m ! : \u03b1)) =\n        \u2211 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\u2081 a\u2082 ha\u2081 ha\u2082 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        \u27e8b + n,\n          mem_filter.2 \u27e8mem_range.2 <| lt_tsub_iff_right.mp (mem_range.1 hb), Nat.le_add_left _ _\u27e9,\n          by rw [add_tsub_cancel_right]\u27e9\n    _ \u2264 \u2211 m in range (j - n), (n ! * n.succ ^ m)\u207b\u00b9 :=\n      by\n      refine' sum_le_sum fun m n => _\n      rw [one_div, inv_le_inv]\n      \u00b7 rw [\u2190 Nat.cast_pow, \u2190 Nat.cast_mul, Nat.cast_le, add_comm]\n        exact Nat.factorial_mul_pow_le_factorial\n      \u00b7 exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      \u00b7\n        exact\n          mul_pos (Nat.cast_pos.2 (Nat.factorial_pos _))\n            (pow_pos (Nat.cast_pos.2 (Nat.succ_pos _)) _)\n    _ = n !\u207b\u00b9 * \u2211 m in range (j - n), n.succ\u207b\u00b9 ^ 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\u207b\u00b9 ^ (j - n)) / (n ! * n) :=\n      by\n      have h\u2081 : (n.succ : \u03b1) \u2260 1 :=\n        @Nat.cast_one \u03b1 _ \u25b8 mt Nat.cast_inj.1 (mt Nat.succ.inj (pos_iff_ne_zero.1 hn))\n      have h\u2082 : (n.succ : \u03b1) \u2260 0 := Nat.cast_ne_zero.2 (Nat.succ_ne_zero _)\n      have h\u2083 : (n ! * n : \u03b1) \u2260 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\u2084 : (n.succ - 1 : \u03b1) = n := by simp\n      rw [geom_sum_inv h\u2081 h\u2082, eq_div_iff_mul_eq h\u2083, mul_comm _ (n ! * n : \u03b1), \u2190\n          mul_assoc (n !\u207b\u00b9 : \u03b1), \u2190 mul_inv_rev, h\u2084, \u2190 mul_assoc (n ! * n : \u03b1), mul_comm (n : \u03b1) n !,\n          mul_inv_cancel h\u2083] <;>\n        simp [mul_add, add_mul, mul_assoc, mul_comm]\n    _ \u2264 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem exp_bound {x : \u2102} (hx : abs x \u2264 1) {n : \u2115} (hn : 0 < n) :\n    abs (exp x - \u2211 m in range n, x ^ m / m !) \u2264 abs x ^ n * (n.succ * (n ! * n)\u207b\u00b9) :=\n  by\n  rw [\u2190 lim_const (\u2211 m in range n, _), exp, sub_eq_add_neg, \u2190 lim_neg, lim_add, \u2190 lim_abs]\n  refine' lim_le (CauSeq.le_of_exists \u27e8n, fun j hj => _\u27e9)\n  simp_rw [\u2190 sub_eq_add_neg]\n  show\n    abs ((\u2211 m in range j, x ^ m / m !) - \u2211 m in range n, x ^ m / m !) \u2264\n      abs x ^ n * (n.succ * (n ! * n)\u207b\u00b9)\n  rw [sum_range_sub_sum_range hj]\n  calc\n    abs (\u2211 m in (range j).filter\u2093 fun k => n \u2264 k, (x ^ m / m ! : \u2102)) =\n        abs (\u2211 m in (range j).filter\u2093 fun k => n \u2264 k, (x ^ n * (x ^ (m - n) / m !) : \u2102)) :=\n      by\n      refine' congr_arg abs (sum_congr rfl fun m hm => _)\n      rw [mem_filter, mem_range] at hm\n      rw [\u2190 mul_div_assoc, \u2190 pow_add, add_tsub_cancel_of_le hm.2]\n    _ \u2264 \u2211 m in Filter (fun k => n \u2264 k) (range j), abs (x ^ n * (_ / m !)) :=\n      (abv_sum_le_sum_abv _ _)\n    _ \u2264 \u2211 m in Filter (fun k => n \u2264 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\u2080, abs_cast_nat]\n      refine' mul_le_mul_of_nonneg_left ((div_le_div_right _).2 _) _\n      \u00b7 exact Nat.cast_pos.2 (Nat.factorial_pos _)\n      \u00b7 rw [abv_pow abs]\n        exact pow_le_one _ (abs.nonneg _) hx\n      \u00b7 exact pow_nonneg (abs.nonneg _) _\n    _ = abs x ^ n * \u2211 m in (range j).filter\u2093 fun k => n \u2264 k, (1 / m ! : \u211d) := by\n      simp [abs_mul, abv_pow abs, abs_div, mul_sum.symm]\n    _ \u2264 abs x ^ n * (n.succ * (n ! * n)\u207b\u00b9) :=\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\u2093.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\u2093.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\u2093.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'\u2093'. -/\ntheorem exp_bound' {x : \u2102} {n : \u2115} (hx : abs x / n.succ \u2264 1 / 2) :\n    abs (exp x - \u2211 m in range n, x ^ m / m !) \u2264 abs x ^ n / n ! * 2 :=\n  by\n  rw [\u2190 lim_const (\u2211 m in range n, _), exp, sub_eq_add_neg, \u2190 lim_neg, lim_add, \u2190 lim_abs]\n  refine' lim_le (CauSeq.le_of_exists \u27e8n, fun j hj => _\u27e9)\n  simp_rw [\u2190 sub_eq_add_neg]\n  show abs ((\u2211 m in range j, x ^ m / m !) - \u2211 m in range n, x ^ m / m !) \u2264 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 (\u2211 i : \u2115 in range k, x ^ (n + i) / ((n + i)! : \u2102)) \u2264\n        \u2211 i : \u2115 in range k, abs (x ^ (n + i) / ((n + i)! : \u2102)) :=\n      abv_sum_le_sum_abv _ _\n    _ \u2264 \u2211 i : \u2115 in range k, abs x ^ (n + i) / (n + i)! := by\n      simp only [Complex.abs_cast_nat, map_div\u2080, abv_pow abs]\n    _ \u2264 \u2211 i : \u2115 in range k, abs x ^ (n + i) / (n ! * n.succ ^ i) := _\n    _ = \u2211 i : \u2115 in range k, abs x ^ n / n ! * (abs x ^ i / n.succ ^ i) := _\n    _ \u2264 abs x ^ n / \u2191n ! * 2 := _\n    \n  \u00b7 refine' sum_le_sum fun m hm => div_le_div (pow_nonneg (abs.nonneg x) (n + m)) le_rfl _ _\n    \u00b7 exact_mod_cast mul_pos n.factorial_pos (pow_pos n.succ_pos _)\n    \u00b7 exact_mod_cast Nat.factorial_mul_pow_le_factorial\n  \u00b7 refine' Finset.sum_congr rfl fun _ _ => _\n    simp only [pow_add, div_eq_inv_mul, mul_inv, mul_left_comm, mul_assoc]\n  \u00b7 rw [\u2190 mul_sum]\n    apply mul_le_mul_of_nonneg_left\n    \u00b7 simp_rw [\u2190 div_pow]\n      rw [geom_sum_eq, div_le_iff_of_neg]\n      \u00b7 trans (-1 : \u211d)\n        \u00b7 linarith\n        \u00b7 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      \u00b7 linarith\n      \u00b7 linarith\n    \u00b7 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\u2093'. -/\ntheorem abs_exp_sub_one_le {x : \u2102} (hx : abs x \u2264 1) : abs (exp x - 1) \u2264 2 * abs x :=\n  calc\n    abs (exp x - 1) = abs (exp x - \u2211 m in range 1, x ^ m / m !) := by simp [sum_range_succ]\n    _ \u2264 abs x ^ 1 * (Nat.succ 1 * (1! * (1 : \u2115))\u207b\u00b9) := (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\u2093'. -/\ntheorem abs_exp_sub_one_sub_id_le {x : \u2102} (hx : abs x \u2264 1) : abs (exp x - 1 - x) \u2264 abs x ^ 2 :=\n  calc\n    abs (exp x - 1 - x) = abs (exp x - \u2211 m in range 2, x ^ m / m !) := by\n      simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc]\n    _ \u2264 abs x ^ 2 * (Nat.succ 2 * (2! * (2 : \u2115))\u207b\u00b9) := (exp_bound hx (by decide))\n    _ \u2264 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\u2093.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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem exp_bound {x : \u211d} (hx : |x| \u2264 1) {n : \u2115} (hn : 0 < n) :\n    |exp x - \u2211 m in range n, x ^ m / m !| \u2264 |x| ^ n * (n.succ / (n ! * n)) :=\n  by\n  have hxc : Complex.abs x \u2264 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\u2093.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\u2093.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\u2093.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\u2093.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'\u2093'. -/\ntheorem exp_bound' {x : \u211d} (h1 : 0 \u2264 x) (h2 : x \u2264 1) {n : \u2115} (hn : 0 < n) :\n    Real.exp x \u2264 (\u2211 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| \u2264 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\u2093'. -/\ntheorem abs_exp_sub_one_le {x : \u211d} (hx : |x| \u2264 1) : |exp x - 1| \u2264 2 * |x| :=\n  by\n  have : Complex.abs x \u2264 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\u2093'. -/\ntheorem abs_exp_sub_one_sub_id_le {x : \u211d} (hx : |x| \u2264 1) : |exp x - 1 - x| \u2264 x ^ 2 :=\n  by\n  rw [\u2190 _root_.sq_abs]\n  have : Complex.abs x \u2264 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 \u27f6 exp x` as `n \u27f6 \u221e`,\nfor any `r`. -/\ndef expNear (n : \u2115) (x r : \u211d) : \u211d :=\n  (\u2211 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\u2093.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\u2093'. -/\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\u2081 : Real) (r\u2082 : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) (Real.expNear n x r\u2081) (Real.expNear n x r\u2082)) (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\u2093.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\u2081 r\u2082))\nbut is expected to have type\n  forall (n : Nat) (x : Real) (r\u2081 : Real) (r\u2082 : Real), Eq.{1} Real (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) (Real.expNear n x r\u2081) (Real.expNear n x r\u2082)) (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\u2081 r\u2082))\nCase conversion may be inaccurate. Consider using '#align real.exp_near_sub Real.expNear_sub\u2093'. -/\ntheorem expNear_sub (n x r\u2081 r\u2082) : expNear n x r\u2081 - expNear n x r\u2082 = x ^ n / n ! * (r\u2081 - r\u2082) := 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\u2093.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\u2093.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\u2093.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\u2093'. -/\ntheorem exp_approx_end (n m : \u2115) (x : \u211d) (e\u2081 : n + 1 = m) (h : |x| \u2264 1) :\n    |exp x - expNear m x 0| \u2264 |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\u2081 : Real} {b\u2081 : 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\u2082 : Real) (b\u2082 : 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\u2093.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) m)) a\u2082)) a\u2081)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.hasSub) b\u2081 (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\u2093.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) m)) b\u2082))) -> (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\u2082))) (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\u2093.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial m))) b\u2082)) -> (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\u2081))) (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\u2093.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n))) b\u2081)))\nbut is expected to have type\n  forall {n : Nat} {x : Real} {a\u2081 : Real} {b\u2081 : 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\u2082 : Real) (b\u2082 : 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\u2082)) a\u2081)) (HSub.hSub.{0, 0, 0} Real Real Real (instHSub.{0} Real Real.instSubReal) b\u2081 (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\u2082))) -> (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\u2082))) (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\u2082)) -> (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\u2081))) (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\u2081)))\nCase conversion may be inaccurate. Consider using '#align real.exp_approx_succ Real.exp_approx_succ\u2093'. -/\ntheorem exp_approx_succ {n} {x a\u2081 b\u2081 : \u211d} (m : \u2115) (e\u2081 : n + 1 = m) (a\u2082 b\u2082 : \u211d)\n    (e : |1 + x / m * a\u2082 - a\u2081| \u2264 b\u2081 - |x| / m * b\u2082)\n    (h : |exp x - expNear m x a\u2082| \u2264 |x| ^ m / m ! * b\u2082) :\n    |exp x - expNear n x a\u2081| \u2264 |x| ^ n / n ! * b\u2081 :=\n  by\n  refine' (_root_.abs_sub_le _ _ _).trans ((add_le_add_right h _).trans _)\n  subst e\u2081; 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  \u00b7 simp [mul_add, pow_succ', div_eq_mul_inv, _root_.abs_mul, _root_.abs_inv, \u2190 pow_abs, mul_inv]\n    ac_rfl\n  \u00b7 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\u2093.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\u2093.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'\u2093'. -/\ntheorem exp_approx_end' {n} {x a b : \u211d} (m : \u2115) (e\u2081 : n + 1 = m) (rm : \u211d) (er : \u2191m = rm)\n    (h : |x| \u2264 1) (e : |1 - a| \u2264 b - |x| / rm * ((rm + 1) / rm)) :\n    |exp x - expNear n x a| \u2264 |x| ^ n / n ! * b := by\n  subst er <;> exact exp_approx_succ _ e\u2081 _ _ (by simpa using e) (exp_approx_end _ _ _ e\u2081 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\u2081 : Real} {b\u2081 : 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\u2093.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\u2081 (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\u2093.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\u2081 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\u2081))) (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\u2093.coe.{1, 1} Nat Real (Nat.castCoe.{0} Real Real.hasNatCast))) (Nat.factorial n))) b\u2081)))\nbut is expected to have type\n  forall {n : Nat} {a\u2081 : Real} {b\u2081 : 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\u2081 (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\u2081 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\u2081))) (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\u2081)))\nCase conversion may be inaccurate. Consider using '#align real.exp_1_approx_succ_eq Real.exp_1_approx_succ_eq\u2093'. -/\ntheorem exp_1_approx_succ_eq {n} {a\u2081 b\u2081 : \u211d} {m : \u2115} (en : n + 1 = m) {rm : \u211d} (er : \u2191m = rm)\n    (h : |exp 1 - expNear m 1 ((a\u2081 - 1) * rm)| \u2264 |1| ^ m / m ! * (b\u2081 * rm)) :\n    |exp 1 - expNear n 1 a\u2081| \u2264 |1| ^ n / n ! * b\u2081 :=\n  by\n  subst er\n  refine' exp_approx_succ _ en _ _ _ h\n  field_simp [show (m : \u211d) \u2260 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\u2093.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\u2093'. -/\ntheorem exp_approx_start (x a b : \u211d) (h : |exp x - expNear 0 x a| \u2264 |x| ^ 0 / 0! * b) :\n    |exp x - a| \u2264 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\u2093'. -/\ntheorem cos_bound {x : \u211d} (hx : |x| \u2264 1) : |cos x - (1 - x ^ 2 / 2)| \u2264 |x| ^ 4 * (5 / 96) :=\n  calc\n    |cos x - (1 - x ^ 2 / 2)| = abs (Complex.cos x - (1 - x ^ 2 / 2)) := by\n      rw [\u2190 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' \u2102)]\n    _ =\n        abs\n          (((Complex.exp (x * I) - \u2211 m in range 4, (x * I) ^ m / m !) +\n              (Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m !)) /\n            2) :=\n      (congr_arg abs\n        (congr_arg (fun x : \u2102 => 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    _ \u2264\n        abs ((Complex.exp (x * I) - \u2211 m in range 4, (x * I) ^ m / m !) / 2) +\n          abs ((Complex.exp (-x * I) - \u2211 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) - \u2211 m in range 4, (x * I) ^ m / m !) / 2 +\n          abs (Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m !) / 2 :=\n      by simp [map_div\u2080]\n    _ \u2264\n        Complex.abs (x * I) ^ 4 * (Nat.succ 4 * (4! * (4 : \u2115))\u207b\u00b9) / 2 +\n          Complex.abs (-x * I) ^ 4 * (Nat.succ 4 * (4! * (4 : \u2115))\u207b\u00b9) / 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    _ \u2264 |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\u2093'. -/\ntheorem sin_bound {x : \u211d} (hx : |x| \u2264 1) : |sin x - (x - x ^ 3 / 6)| \u2264 |x| ^ 4 * (5 / 96) :=\n  calc\n    |sin x - (x - x ^ 3 / 6)| = abs (Complex.sin x - (x - x ^ 3 / 6)) := by\n      rw [\u2190 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' \u2102), div_div,\n        show (3 : \u2102) * 2 = 6 by norm_num]\n    _ =\n        abs\n          (((Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m !) -\n                (Complex.exp (x * I) - \u2211 m in range 4, (x * I) ^ m / m !)) *\n              I /\n            2) :=\n      (congr_arg abs\n        (congr_arg (fun x : \u2102 => 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    _ \u2264\n        abs ((Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m !) * I / 2) +\n          abs (-((Complex.exp (x * I) - \u2211 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) - \u2211 m in range 4, (x * I) ^ m / m !) / 2 +\n          abs (Complex.exp (-x * I) - \u2211 m in range 4, (-x * I) ^ m / m !) / 2 :=\n      by simp [add_comm, map_div\u2080]\n    _ \u2264\n        Complex.abs (x * I) ^ 4 * (Nat.succ 4 * (4! * (4 : \u2115))\u207b\u00b9) / 2 +\n          Complex.abs (-x * I) ^ 4 * (Nat.succ 4 * (4! * (4 : \u2115))\u207b\u00b9) / 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    _ \u2264 |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\u2093'. -/\ntheorem cos_pos_of_le_one {x : \u211d} (hx : |x| \u2264 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 \u2264 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, \u2190 abs_mul_self, _root_.abs_mul] <;>\n                      exact mul_le_one hx (abs_nonneg _) hx))\n            _ < 1 := by norm_num\n            )\n    _ \u2264 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\u2093'. -/\ntheorem sin_pos_of_pos_of_le_one {x : \u211d} (hx0 : 0 < x) (hx : x \u2264 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 \u2264 x * (5 / 96) + x / 6 :=\n              add_le_add\n                (mul_le_mul_of_nonneg_right\n                  (calc\n                    |x| ^ 4 \u2264 |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 \u2264 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    _ \u2264 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\u2093'. -/\ntheorem sin_pos_of_pos_of_le_two {x : \u211d} (hx0 : 0 < x) (hx : x \u2264 2) : 0 < sin x :=\n  have : x / 2 \u2264 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 [\u2190 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\u2093'. -/\ntheorem cos_one_le : cos 1 \u2264 2 / 3 :=\n  calc\n    cos 1 \u2264 |(1 : \u211d)| ^ 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    _ \u2264 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\u2093'. -/\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\u2093'. -/\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    _ \u2264 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 : \u211d} (h1 : 0 \u2264 x) (h2 : x \u2264 1) :\n    (\u2211 j : \u2115 in Finset.range 3, x ^ j / j.factorial) +\n        x ^ 3 * ((3 : \u2115) + 1) / ((3 : \u2115).factorial * (3 : \u2115)) \u2264\n      \u2211 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), \u2190 add_assoc, add_le_add_iff_right, \u2190\n    add_le_add_iff_left (-(x ^ 2 / 2)), \u2190 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 \u2264 1 / 2 := by linarith\n  have i2 : 0 \u2264 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 [\u2190 mul_assoc]\n  rwa [mul_one_div, \u2190 mul_div_assoc, \u2190 mul_assoc] at t\n#align real.exp_bound_div_one_sub_of_interval_approx Real.exp_bound_div_one_sub_of_interval_approx\u2093\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\u2093'. -/\ntheorem exp_bound_div_one_sub_of_interval {x : \u211d} (h1 : 0 \u2264 x) (h2 : x < 1) :\n    Real.exp x \u2264 1 / (1 - x) :=\n  haveI h : (\u2211 j in Finset.range 3, x ^ j) \u2264 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 [\u2190 add_assoc, mul_sub_left_distrib, mul_one, add_mul, sub_add_eq_sub_sub,\n      pow_succ' x 2]\n    have hx3 : 0 \u2264 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\u2093'. -/\ntheorem one_sub_le_exp_minus_of_pos {y : \u211d} (h : 0 \u2264 y) : 1 - y \u2264 Real.exp (-y) :=\n  by\n  rw [Real.exp_neg]\n  have r1 : (1 - y) * Real.exp y \u2264 1 :=\n    by\n    cases le_or_lt (1 - y) 0\n    \u00b7 have h'' : (1 - y) * y.exp \u2264 0 := by\n        rw [mul_nonpos_iff]\n        right\n        exact \u27e8h_1, y.exp_pos.le\u27e9\n      linarith\n    have hy1 : y < 1 := by linarith\n    rw [\u2190 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\u2093'. -/\ntheorem add_one_le_exp_of_nonpos {x : \u211d} (h : x \u2264 0) : x + 1 \u2264 Real.exp x :=\n  by\n  rw [add_comm]\n  have h1 : 0 \u2264 -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\u2093'. -/\ntheorem add_one_le_exp (x : \u211d) : x + 1 \u2264 Real.exp x :=\n  by\n  cases le_or_lt 0 x\n  \u00b7 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\u2093.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\u2093.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\u2093'. -/\ntheorem one_sub_div_pow_le_exp_neg {n : \u2115} {t : \u211d} (ht' : t \u2264 n) : (1 - t / n) ^ n \u2264 exp (-t) :=\n  by\n  rcases eq_or_ne n 0 with (rfl | hn)\n  \u00b7 simp\n    rwa [Nat.cast_zero] at ht'\n  convert pow_le_pow_of_le_left _ (add_one_le_exp (-(t / n))) n\n  \u00b7 abel\n  \u00b7 rw [\u2190 Real.exp_nat_mul]\n    congr 1\n    field_simp [nat.cast_ne_zero.mpr hn]\n    ring\n  \u00b7 rwa [add_comm, \u2190 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 \u2192 tactic strictness\n  | q(Real.exp $(a)) => positive <$> mk_app `real.exp_pos [a]\n  | e => pp e >>= fail \u2218 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem abs_cos_add_sin_mul_I (x : \u211d) : 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\u2093.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\u2093'. -/\n@[simp]\ntheorem abs_exp_ofReal (x : \u211d) : abs (exp x) = Real.exp x := by\n  rw [\u2190 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\u2093.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\u2093'. -/\n@[simp]\ntheorem abs_exp_ofReal_mul_I (x : \u211d) : 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\u2093'. -/\ntheorem abs_exp (z : \u2102) : 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\u2093'. -/\ntheorem abs_exp_eq_iff_re_eq {x y : \u2102} : abs (exp x) = abs (exp y) \u2194 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 (\u03b1 : Type u) (S : sieve \u03b1) => \u2200 (x : \u03b1), 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 (\u03b1 : Type u) (\u03b2 : Type u) (f : \u03b2 \u27f6 \u03b1) :\n    coe_fn (discrete_sieve \u03b1) \u03b2 f = \u2203 (x : \u03b1), \u2200 (y : \u03b2), f y = x :=\n  Eq.refl (coe_fn (discrete_sieve \u03b1) \u03b2 f)\n\ntheorem discrete_sieve_mem (\u03b1 : Type u) : discrete_sieve \u03b1 \u2208 coe_fn types_grothendieck_topology \u03b1 :=\n  fun (x : \u03b1) => 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 (\u03b1 : Type u) : presieve \u03b1 :=\n  fun (\u03b2 : Type u) (f : \u03b2 \u27f6 \u03b1) => \u2203 (x : \u03b2), \u2200 (y : \u03b2), y = x\n\ntheorem generate_discrete_presieve_mem (\u03b1 : Type u) :\n    sieve.generate (discrete_presieve \u03b1) \u2208 coe_fn types_grothendieck_topology \u03b1 :=\n  sorry\n\ntheorem is_sheaf_yoneda' {\u03b1 : Type u} :\n    presieve.is_sheaf types_grothendieck_topology (functor.obj yoneda \u03b1) :=\n  sorry\n\n/-- The yoneda functor that sends a type to a sheaf over the category of types -/\n@[simp] theorem yoneda'_map (\u03b1 : Type u) (\u03b2 : Type u) (f : \u03b1 \u27f6 \u03b2) :\n    functor.map yoneda' f = functor.map yoneda f :=\n  Eq.refl (functor.map yoneda' f)\n\n@[simp] theorem yoneda'_comp : yoneda' \u22d9 induced_functor subtype.val = yoneda := rfl\n\n/-- Given a presheaf `P` on the category of types, construct\na map `P(\u03b1) \u2192 (\u03b1 \u2192 P(*))` for all type `\u03b1`. -/\ndef eval (P : Type u\u1d52\u1d56 \u2964 Type u) (\u03b1 : Type u) (s : functor.obj P (opposite.op \u03b1)) (x : \u03b1) :\n    functor.obj P (opposite.op PUnit) :=\n  functor.map P (has_hom.hom.op (\u21befun (_x : PUnit) => x)) s\n\n/-- Given a sheaf `S` on the category of types, construct a map\n`(\u03b1 \u2192 S(*)) \u2192 S(\u03b1)` that is inverse to `eval`. -/\ndef types_glue (S : Type u\u1d52\u1d56 \u2964 Type u) (hs : presieve.is_sheaf types_grothendieck_topology S)\n    (\u03b1 : Type u) (f : \u03b1 \u2192 functor.obj S (opposite.op PUnit)) : functor.obj S (opposite.op \u03b1) :=\n  presieve.is_sheaf_for.amalgamate sorry\n    (fun (\u03b2 : Type u) (g : \u03b2 \u27f6 \u03b1) (hg : discrete_presieve \u03b1 g) =>\n      functor.map S (has_hom.hom.op (\u21befun (x : \u03b2) => PUnit.unit)) (f (g (classical.some hg))))\n    sorry\n\ntheorem eval_types_glue {S : Type u\u1d52\u1d56 \u2964 Type u}\n    {hs : presieve.is_sheaf types_grothendieck_topology S} {\u03b1 : Type u}\n    (f : \u03b1 \u2192 functor.obj S (opposite.op PUnit)) : eval S \u03b1 (types_glue S hs \u03b1 f) = f :=\n  sorry\n\ntheorem types_glue_eval {S : Type u\u1d52\u1d56 \u2964 Type u}\n    {hs : presieve.is_sheaf types_grothendieck_topology S} {\u03b1 : Type u}\n    (s : functor.obj S (opposite.op \u03b1)) : types_glue S hs \u03b1 (eval S \u03b1 s) = s :=\n  sorry\n\n/-- Given a sheaf `S`, construct an equivalence `S(\u03b1) \u2243 (\u03b1 \u2192 S(*))`. -/\ndef eval_equiv (S : Type u\u1d52\u1d56 \u2964 Type u) (hs : presieve.is_sheaf types_grothendieck_topology S)\n    (\u03b1 : Type u) : functor.obj S (opposite.op \u03b1) \u2243 (\u03b1 \u2192 functor.obj S (opposite.op PUnit)) :=\n  equiv.mk (eval S \u03b1) (types_glue S hs \u03b1) types_glue_eval eval_types_glue\n\ntheorem eval_map (S : Type u\u1d52\u1d56 \u2964 Type u) (\u03b1 : Type u) (\u03b2 : Type u) (f : \u03b2 \u27f6 \u03b1)\n    (s : functor.obj S (opposite.op \u03b1)) (x : \u03b2) :\n    eval S \u03b2 (functor.map S (has_hom.hom.op f) s) x = eval S \u03b1 s (f x) :=\n  sorry\n\n/-- Given a sheaf `S`, construct an isomorphism `S \u2245 [-, S(*)]`. -/\ndef equiv_yoneda (S : Type u\u1d52\u1d56 \u2964 Type u) (hs : presieve.is_sheaf types_grothendieck_topology S) :\n    S \u2245 functor.obj yoneda (functor.obj S (opposite.op PUnit)) :=\n  nat_iso.of_components (fun (\u03b1 : Type u\u1d52\u1d56) => equiv.to_iso (eval_equiv S hs (opposite.unop \u03b1)))\n    sorry\n\n/-- Given a sheaf `S`, construct an isomorphism `S \u2245 [-, 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\u2081 : SheafOfTypes types_grothendieck_topology)\n    (S\u2082 : SheafOfTypes types_grothendieck_topology) (f : S\u2081 \u27f6 S\u2082) (\u03b1 : Type u)\n    (s : functor.obj (subtype.val S\u2081) (opposite.op \u03b1)) (x : \u03b1) :\n    eval (subtype.val S\u2082) \u03b1 (nat_trans.app f (opposite.op \u03b1) s) x =\n        nat_trans.app f (opposite.op PUnit) (eval (subtype.val S\u2081) \u03b1 s x) :=\n  Eq.symm (congr_fun (nat_trans.naturality' f (has_hom.hom.op (\u21befun (_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 (\u2191X) (opposite.op PUnit) :=\n  Eq.refl (functor.obj (\u2191X) (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 : \u2115) :\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 \u03b1` is classically a nonempty `set \u03b1`,\n  and in the VM is represented by an element of `\u03b1`; 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 (\u03b1 : Type u_1) \n  mk' ::\nwhere (s : set \u03b1) (val : trunc \u21a5s)\n\nnamespace semiquot\n\n\nprotected instance has_mem {\u03b1 : Type u_1} : has_mem \u03b1 (semiquot \u03b1) :=\n  has_mem.mk fun (a : \u03b1) (q : semiquot \u03b1) => a \u2208 s q\n\n/-- Construct a `semiquot \u03b1` from `h : a \u2208 s` where `s : set \u03b1`. -/\ndef mk {\u03b1 : Type u_1} {a : \u03b1} {s : set \u03b1} (h : a \u2208 s) : semiquot \u03b1 :=\n  mk' s (trunc.mk { val := a, property := h })\n\ntheorem ext_s {\u03b1 : Type u_1} {q\u2081 : semiquot \u03b1} {q\u2082 : semiquot \u03b1} : q\u2081 = q\u2082 \u2194 s q\u2081 = s q\u2082 := sorry\n\ntheorem ext {\u03b1 : Type u_1} {q\u2081 : semiquot \u03b1} {q\u2082 : semiquot \u03b1} : q\u2081 = q\u2082 \u2194 \u2200 (a : \u03b1), a \u2208 q\u2081 \u2194 a \u2208 q\u2082 :=\n  iff.trans ext_s set.ext_iff\n\ntheorem exists_mem {\u03b1 : Type u_1} (q : semiquot \u03b1) : \u2203 (a : \u03b1), a \u2208 q := sorry\n\ntheorem eq_mk_of_mem {\u03b1 : Type u_1} {q : semiquot \u03b1} {a : \u03b1} (h : a \u2208 q) : q = mk h :=\n  iff.mpr ext_s rfl\n\ntheorem nonempty {\u03b1 : Type u_1} (q : semiquot \u03b1) : set.nonempty (s q) :=\n  exists_mem q\n\n/-- `pure a` is `a` reinterpreted as an unspecified element of `{a}`. -/\nprotected def pure {\u03b1 : Type u_1} (a : \u03b1) : semiquot \u03b1 :=\n  mk (set.mem_singleton a)\n\n@[simp] theorem mem_pure' {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : a \u2208 semiquot.pure b \u2194 a = b :=\n  set.mem_singleton_iff\n\n/-- Replace `s` in a `semiquot` with a superset. -/\ndef blur' {\u03b1 : Type u_1} (q : semiquot \u03b1) {s : set \u03b1} (h : s q \u2286 s) : semiquot \u03b1 :=\n  mk' s (trunc.lift (fun (a : \u21a5(s q)) => trunc.mk { val := subtype.val a, property := sorry }) sorry (val q))\n\n/-- Replace `s` in a `q : semiquot \u03b1` with a union `s \u222a q.s` -/\ndef blur {\u03b1 : Type u_1} (s : set \u03b1) (q : semiquot \u03b1) : semiquot \u03b1 :=\n  blur' q sorry\n\ntheorem blur_eq_blur' {\u03b1 : Type u_1} (q : semiquot \u03b1) (s : set \u03b1) (h : s q \u2286 s) : blur s q = blur' q h := sorry\n\n@[simp] theorem mem_blur' {\u03b1 : Type u_1} (q : semiquot \u03b1) {s : set \u03b1} (h : s q \u2286 s) {a : \u03b1} : a \u2208 blur' q h \u2194 a \u2208 s :=\n  iff.rfl\n\n/-- Convert a `trunc \u03b1` to a `semiquot \u03b1`. -/\ndef of_trunc {\u03b1 : Type u_1} (q : trunc \u03b1) : semiquot \u03b1 :=\n  mk' set.univ (trunc.map (fun (a : \u03b1) => { val := a, property := trivial }) q)\n\n/-- Convert a `semiquot \u03b1` to a `trunc \u03b1`. -/\ndef to_trunc {\u03b1 : Type u_1} (q : semiquot \u03b1) : trunc \u03b1 :=\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (q : semiquot \u03b1) (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2208 q \u2192 b \u2208 q \u2192 f a = f b) : \u03b2 :=\n  trunc.lift_on (val q) (fun (x : \u21a5(s q)) => f (subtype.val x)) sorry\n\ntheorem lift_on_of_mem {\u03b1 : Type u_1} {\u03b2 : Type u_2} (q : semiquot \u03b1) (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), a \u2208 q \u2192 b \u2208 q \u2192 f a = f b) (a : \u03b1) (aq : a \u2208 q) : lift_on q f h = f a :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (\u2200 (h : \u2200 (a b : \u03b1), a \u2208 q \u2192 b \u2208 q \u2192 f a = f b), lift_on q f h = f a)) (eq_mk_of_mem aq)))\n    (fun (h : \u2200 (a_1 b : \u03b1), a_1 \u2208 mk aq \u2192 b \u2208 mk aq \u2192 f a_1 = f b) => Eq.refl (lift_on (mk aq) f h)) h\n\ndef map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (q : semiquot \u03b1) : semiquot \u03b2 :=\n  mk' (f '' s q) (trunc.map (fun (x : \u21a5(s q)) => { val := f (subtype.val x), property := sorry }) (val q))\n\n@[simp] theorem mem_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (q : semiquot \u03b1) (b : \u03b2) : b \u2208 map f q \u2194 \u2203 (a : \u03b1), a \u2208 q \u2227 f a = b :=\n  set.mem_image (fun (a : \u03b1) => f a) (s q) b\n\ndef bind {\u03b1 : Type u_1} {\u03b2 : Type u_2} (q : semiquot \u03b1) (f : \u03b1 \u2192 semiquot \u03b2) : semiquot \u03b2 :=\n  mk' (set.Union fun (a : \u03b1) => set.Union fun (H : a \u2208 s q) => s (f a))\n    (trunc.bind (val q)\n      fun (a : \u21a5(s q)) =>\n        trunc.map (fun (b : \u21a5(s (f (subtype.val a)))) => { val := subtype.val b, property := sorry })\n          (val (f (subtype.val a))))\n\n@[simp] theorem mem_bind {\u03b1 : Type u_1} {\u03b2 : Type u_2} (q : semiquot \u03b1) (f : \u03b1 \u2192 semiquot \u03b2) (b : \u03b2) : b \u2208 bind q f \u2194 \u2203 (a : \u03b1), \u2203 (H : a \u2208 q), b \u2208 f a :=\n  set.mem_bUnion_iff\n\nprotected instance monad : Monad semiquot :=\n  { toApplicative :=\n      { toFunctor := { map := map, mapConst := fun (\u03b1 \u03b2 : Type u_1) => map \u2218 function.const \u03b2 },\n        toPure := { pure := semiquot.pure },\n        toSeq :=\n          { seq := fun (\u03b1 \u03b2 : Type u_1) (f : semiquot (\u03b1 \u2192 \u03b2)) (x : semiquot \u03b1) => bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x },\n        toSeqLeft :=\n          { seqLeft :=\n              fun (\u03b1 \u03b2 : Type u_1) (a : semiquot \u03b1) (b : semiquot \u03b2) =>\n                (fun (\u03b1 \u03b2 : Type u_1) (f : semiquot (\u03b1 \u2192 \u03b2)) (x : semiquot \u03b1) => bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x) \u03b2 \u03b1\n                  (map (function.const \u03b2) a) b },\n        toSeqRight :=\n          { seqRight :=\n              fun (\u03b1 \u03b2 : Type u_1) (a : semiquot \u03b1) (b : semiquot \u03b2) =>\n                (fun (\u03b1 \u03b2 : Type u_1) (f : semiquot (\u03b1 \u2192 \u03b2)) (x : semiquot \u03b1) => bind f fun (_x : \u03b1 \u2192 \u03b2) => map _x x) \u03b2 \u03b2\n                  (map (function.const \u03b1 id) a) b } },\n    toBind := { bind := bind } }\n\n@[simp] theorem map_def {\u03b1 : Type u_1} {\u03b2 : Type u_1} : Functor.map = map :=\n  rfl\n\n@[simp] theorem bind_def {\u03b1 : Type u_1} {\u03b2 : Type u_1} : bind = bind :=\n  rfl\n\n@[simp] theorem mem_pure {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : a \u2208 pure b \u2194 a = b :=\n  set.mem_singleton_iff\n\ntheorem mem_pure_self {\u03b1 : Type u_1} (a : \u03b1) : a \u2208 pure a :=\n  set.mem_singleton a\n\n@[simp] theorem pure_inj {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : pure a = pure b \u2194 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 {\u03b1 : Type u_1} : HasLessEq (semiquot \u03b1) :=\n  { LessEq := fun (s t : semiquot \u03b1) => s s \u2286 s t }\n\nprotected instance partial_order {\u03b1 : Type u_1} : partial_order (semiquot \u03b1) :=\n  partial_order.mk (fun (s t : semiquot \u03b1) => \u2200 {x : \u03b1}, x \u2208 s \u2192 x \u2208 t)\n    (preorder.lt._default fun (s t : semiquot \u03b1) => \u2200 {x : \u03b1}, x \u2208 s \u2192 x \u2208 t) sorry sorry sorry\n\nprotected instance semilattice_sup {\u03b1 : Type u_1} : semilattice_sup (semiquot \u03b1) :=\n  semilattice_sup.mk (fun (s : semiquot \u03b1) => blur (s s)) partial_order.le partial_order.lt sorry sorry sorry sorry sorry\n    sorry\n\n@[simp] theorem pure_le {\u03b1 : Type u_1} {a : \u03b1} {s : semiquot \u03b1} : pure a \u2264 s \u2194 a \u2208 s :=\n  set.singleton_subset_iff\n\ndef is_pure {\u03b1 : Type u_1} (q : semiquot \u03b1) :=\n  \u2200 (a b : \u03b1), a \u2208 q \u2192 b \u2208 q \u2192 a = b\n\ndef get {\u03b1 : Type u_1} (q : semiquot \u03b1) (h : is_pure q) : \u03b1 :=\n  lift_on q id h\n\ntheorem get_mem {\u03b1 : Type u_1} {q : semiquot \u03b1} (p : is_pure q) : get q p \u2208 q := sorry\n\ntheorem eq_pure {\u03b1 : Type u_1} {q : semiquot \u03b1} (p : is_pure q) : q = pure (get q p) := sorry\n\n@[simp] theorem pure_is_pure {\u03b1 : Type u_1} (a : \u03b1) : is_pure (pure a) :=\n  fun (a_1 b : \u03b1) (H : a_1 \u2208 pure a) (H_1 : b \u2208 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 {\u03b1 : Type u_1} {s : semiquot \u03b1} : is_pure s \u2194 \u2203 (a : \u03b1), s = pure a := sorry\n\ntheorem is_pure.mono {\u03b1 : Type u_1} {s : semiquot \u03b1} {t : semiquot \u03b1} (st : s \u2264 t) (h : is_pure t) : is_pure s :=\n  fun (a b : \u03b1) (H : a \u2208 s) (H_1 : b \u2208 s) => idRhs (a = b) (h a b (st H) (st H_1))\n\ntheorem is_pure.min {\u03b1 : Type u_1} {s : semiquot \u03b1} {t : semiquot \u03b1} (h : is_pure t) : s \u2264 t \u2194 s = t := sorry\n\ntheorem is_pure_of_subsingleton {\u03b1 : Type u_1} [subsingleton \u03b1] (q : semiquot \u03b1) : is_pure q :=\n  fun (a b : \u03b1) (H : a \u2208 q) (H : b \u2208 q) => idRhs (a = b) (subsingleton.elim a b)\n\n/-- `univ : semiquot \u03b1` represents an unspecified element of `univ : set \u03b1`. -/\ndef univ {\u03b1 : Type u_1} [Inhabited \u03b1] : semiquot \u03b1 :=\n  mk sorry\n\nprotected instance inhabited {\u03b1 : Type u_1} [Inhabited \u03b1] : Inhabited (semiquot \u03b1) :=\n  { default := univ }\n\n@[simp] theorem mem_univ {\u03b1 : Type u_1} [Inhabited \u03b1] (a : \u03b1) : a \u2208 univ :=\n  set.mem_univ\n\ntheorem univ_unique {\u03b1 : Type u_1} (I : Inhabited \u03b1) (J : Inhabited \u03b1) : univ = univ := sorry\n\n@[simp] theorem is_pure_univ {\u03b1 : Type u_1} [Inhabited \u03b1] : is_pure univ \u2194 subsingleton \u03b1 := sorry\n\nprotected instance order_top {\u03b1 : Type u_1} [Inhabited \u03b1] : order_top (semiquot \u03b1) :=\n  order_top.mk univ partial_order.le partial_order.lt sorry sorry sorry sorry\n\nprotected instance semilattice_sup_top {\u03b1 : Type u_1} [Inhabited \u03b1] : semilattice_sup_top (semiquot \u03b1) :=\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 : \u00ac 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\u00f6lich, *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  {\u03b9 : Type*} [fintype \u03b9] [decidable_eq \u03b9] (b : basis \u03b9 K L)\n  (hb_int : \u2200 i, is_integral A (b i)) [is_integrally_closed A] :\n  ((algebra.linear_map C L).restrict_scalars A).range \u2264\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 _ \u27e8x, rfl\u27e9,\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 : \u2203 (c : \u03b9 \u2192 A), algebra_map C L x = \u2211 i, c i \u2022 db i,\n  { obtain \u27e8c, x_eq\u27e9 := this,\n    rw x_eq,\n    refine submodule.sum_mem _ (\u03bb i _, submodule.smul_mem _ _ (submodule.subset_span _)),\n    rw set.mem_range,\n    exact \u27e8i, rfl\u27e9 },\n  suffices : \u2203 (c : \u03b9 \u2192 K), ((\u2200 i, is_integral A (c i)) \u2227 algebra_map C L x = \u2211 i, c i \u2022 db i),\n  { obtain \u27e8c, hc, hx\u27e9 := this,\n    have hc' : \u2200 i, is_localization.is_integer A (c i) :=\n      \u03bb i, is_integrally_closed.is_integral_iff.mp (hc i),\n    use \u03bb i, classical.some (hc' i),\n    refine hx.trans (finset.sum_congr rfl (\u03bb i _, _)),\n    conv_lhs { rw [\u2190 classical.some_spec (hc' i)] },\n    rw [\u2190 is_scalar_tower.algebra_map_smul K (classical.some (hc' i)) (db i)] },\n  refine \u27e8\u03bb i, db.repr (algebra_map C L x) i, (\u03bb i, _), (db.sum_repr _).symm\u27e9,\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  {\u03b9 : Type*} [fintype \u03b9] [decidable_eq \u03b9] (b : basis \u03b9 K L)\n  (hb_int : \u2200 i, is_integral A (b i)) [is_integrally_closed A] :\n  (integral_closure A L).to_submodule \u2264 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 \u27e8\u27e8x, hx\u27e9, rfl\u27e9\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) \u2022 x \u2208 integral_closure R L`. -/\nlemma exists_integral_multiples (s : finset L) :\n  \u2203 (y \u2260 (0 : A)), \u2200 x \u2208 s, is_integral A (y \u2022 x) :=\nbegin\n  haveI := classical.dec_eq L,\n  refine s.induction _ _,\n  { use [1, one_ne_zero],\n    rintros x \u27e8\u27e9 },\n  { rintros x s hx \u27e8y, hy, hs\u27e9,\n    obtain \u27e8x', y', hy', hx'\u27e9 := 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 \u27e8y * y', mul_ne_zero hy hy', \u03bb x'' hx'', _\u27e9,\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  \u2203 (s : finset L) (b : basis s K L), (\u2200 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 \u27e8y, hy, his'\u27e9 := exists_integral_multiples A K (finset.univ.image bs'),\n  have hy' : algebra_map A L y \u2260 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 \u27e8s', bs'.map { to_fun := \u03bb x, algebra_map A L y * x,\n                        inv_fun := \u03bb x, (algebra_map A L y)\u207b\u00b9 * x,\n                        left_inv := _,\n                        right_inv := _,\n                        .. algebra.lmul _ _ (algebra_map A L y) },\n          _\u27e9,\n  { intros x, simp only [inv_mul_cancel_left\u2080 hy'] },\n  { intros x, simp only [mul_inv_cancel_left\u2080 hy'] },\n  { rintros \u27e8x', hx'\u27e9,\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' _ \u27e8_, rfl\u27e9 }\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 \u27e8s, b, hb_int\u27e9 := 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 \u2192\u2097[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  \u27e8is_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 (\u03bb x hx, \u27e8is_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' _ _ _\u27e9)\u27e9\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 := \u2115\nabbrev Val  := \u2115\nabbrev Ident := \u2115\ndef Heap  := Addr \u2192 Option \u2115\ninstance : EmptyCollection Heap := \u27e8 fun _ \u21a6 none \u27e9\ninstance : Membership (\u2115 \u00d7 Val) Heap where mem p s := s p.1 = some p.2\ninstance (a b : Type) : Membership (a \u00d7 b) (a \u2192 Option b) where mem p s := s p.1 = some p.2\n\ndef dom [DecidableEq \u03b1] : (\u03b1 \u2192 Option \u03b2) \u2192 Set \u03b1 := fun h \u21a6 { n | \u2203 v, h n = some v }\nlemma mem_dom_update [DecidableEq \u03b1] (h : \u03b1 \u2192 Option \u03b2) : a \u2208 dom (Function.update h a (some v)) := by simp [dom]\n\ninstance : Insert (Addr \u00d7 \u2115) Heap := \u27e8 fun p s \u21a6 Function.update s p.1 p.2 \u27e9\ninstance : Singleton (Addr \u00d7 \u2115) Heap := \u27e8 fun p \u21a6 Function.update (\u2205 : Heap) p.1 p.2 \u27e9\nnotation a \" \u21a6 \" b => (a, b)\n--notation:max h \"[\" x \" := \" y \"]\" => Function.update h x (some y)\n\nclass VariableType (Var : Type) where type : Var \u2192 Type\nattribute [reducible] VariableType.type\nopen VariableType\n\nvariable (V) [VariableType V] [DecidableEq V]\n\n@[ext]\nstructure TypedStore where\n  val : (v : V) \u2192 type v\n\nvariable {V}\n\ndef TypedStore.update (st : TypedStore V) (x : V) (y : type x) : TypedStore V :=\n\u27e8 Function.update st.val x y \u27e9\n\nnotation:max h \"[\" x \" := \" y \"]\" => TypedStore.update h x y\n\n-- todo move\n@[simps]\ndef Op.nat (n : \u2115) : Op \u2115 where\n  argTypes := ![]\n  spec := fun _ \u21a6 n\n  opName := \"nat_lit\"\n\nvariable (V)\ninductive E : Type \u2192 Type 1\n| call {\u03b1} (op : Op \u03b1) (args : (i : Fin op.arity) \u2192 E (op.argTypes i)) : E \u03b1\n| var    : (v : V) \u2192 E (type v)\n\nvariable {V}\ndef E.eval (st : TypedStore V) : {\u03b1 : Type} \u2192 E V \u03b1 \u2192 \u03b1\n| _, var v => st.val v\n| _, call op args => op.spec fun param \u21a6 (args param).eval st\n\n@[simp] theorem TypedStore.val_update_ne (x y : V) (v : type x) (l : TypedStore V) (h : x \u2260 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 \u2260 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 \u03b1) [Tagged \u03b1] [DecidableEq \u03b1] : E.eval l (E.call Op.eq ![a, b]) = decide (a.eval l = b.eval l) := rfl\n@[simp] theorem E.eval_lt {\u03b1} [Tagged \u03b1] [LT \u03b1] [DecidableRel (LT.lt : \u03b1 \u2192 \u03b1 \u2192 _) ] (a b : E V \u03b1) : (E.call .lt ![a, b]).eval st = true \u2194 a.eval st < b.eval st := by simp [E.eval, Op.lt]\n@[simp] theorem E.eval_lt_false {\u03b1} [Tagged \u03b1] [LT \u03b1] [DecidableRel (LT.lt : \u03b1 \u2192 \u03b1 \u2192 _) ] (a b : E V \u03b1) : (E.call .lt ![a, b]).eval st = false \u2194 \u00ac (a.eval st < b.eval st) := by simp [E.eval, Op.lt]\n\nvariable (V)\n\ninductive P\n| store {\u03b1} (lval : E V \u2115) (rval : E V \u03b1)\n| load  (lval : E V \u2115) (y : V)\n| put (x : V) (e : E V (type x))\n| seq (c\u2081 c\u2082 : P) : P\n| while (c : E V Bool) (body : P)\n| skip\n@[match_pattern] infixr:25 \";; \" => P.seq\n\ndef TypedConfigSet := Heap \u2192 TypedStore V \u2192 Prop\n\nvariable {V}\n\nclass Representable (\u03b1 : Type _) where\n  defines : \u03b1 \u2192 Addr \u2192 Heap \u2192 Prop\n\nclass Storable (\u03b1 : Type _) extends Representable \u03b1 where\n  store : Heap \u2192 Addr \u2192 \u03b1 \u2192 Heap\n  footprint : \u03b1 \u2192 Addr \u2192 Set Addr\n  valid (h a v) : defines v a (store h a v)\n  frame (a loc v h) : a \u2209 footprint v loc \u2192 (store h loc v) a = h a\n\ndef exprDefines [Representable \u03b1] : \u03b1 \u2192 E V Addr \u2192 Heap \u2192 TypedStore V \u2192 Prop :=\n  fun val a h s \u21a6 Representable.defines val (a.eval s) h\nnotation \"\u2983\" addr \" \u21aa \" val \"\u2984\" => exprDefines val addr\n\ninstance : Storable Val where\n  defines v addr h := (addr, v) \u2208 h\n  store   h addr v := Function.update h addr v\n  footprint _ addr := { addr }\n  --disjoint a\u2081 a\u2082 := a\u2081 \u2260 a\u2082\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 \u2192 TypedConfigSet V \u2192 Heap \u2192 TypedStore V \u2192 Prop\n| skip : Q h l \u2192 Sem .skip Q h l\n| put  : Q h l[x := y.eval l] \u2192 Sem (.put x y) Q h l\n| store {\u03b1} {rval : E V \u03b1} (hr : Storable \u03b1)\n        (h1 : lval.eval l \u2208 dom h)\n        : Q (Storable.store h (lval.eval l) (rval.eval l)) l \u2192\n          Sem (.store lval rval) Q h l\n| load (v : type y) {lval : E V \u2115} [hr : Representable (type y)]\n       (hv : \u2983lval \u21aa v\u2984 h l)\n       : Q h l[y := v] \u2192 Sem (.load lval y) Q h l\n| seq : Sem c\u2081 (Sem c\u2082 Q) h l \u2192 Sem (c\u2081;; c\u2082) Q h l\n| whileDone (condFalse : x.eval l = false)\n            : Q h l \u2192 Sem (.while x c) Q h l\n| whileLoop (condTrue  : x.eval l = true)\n            : Sem c (Sem (.while x c) Q) h l \u2192\n              Sem (.while x c) Q h l\n\nnotation c \" / \" h \", \" l \" \u21d3 \" Q => Sem c Q h l\n\nend defs\n\nsection instances\nvariable {V} [VariableType V] [DecidableEq V]\nopen VariableType\n\ninstance [Tagged \u03b1] [Add \u03b1] : Add (E V \u03b1) := \u27e8 \u03bb a b => E.call .add ![a, b] \u27e9\ninstance [Tagged \u03b1] [Sub \u03b1] : Sub (E V \u03b1) := \u27e8 \u03bb a b => E.call .sub ![a, b] \u27e9\ninstance [Tagged \u03b1] [Mul \u03b1] : Mul (E V \u03b1) := \u27e8 \u03bb a b => E.call .mul ![a, b] \u27e9\ninstance [Tagged \u03b1] [OfNat \u03b1 (nat_lit 1)] : OfNat (E V \u03b1) (nat_lit 1) := \u27e8 E.call .one ![] \u27e9\ninstance : OfNat (E V \u2115) n := \u27e8 E.call (.nat n) ![] \u27e9\nabbrev zero : E V \u2115 := 0\ninstance : Coe \u2115 (E V \u2115) := \u27e8 fun n => E.call (.nat n) ![] \u27e9\n\n@[simp] theorem E.eval_nat' : E.eval st (0 : E V \u2115) = 0 := rfl\n\ninfixr:35 \" \u2227\u2095 \" => fun a b h \u21a6 a h \u2227 b h\n\ndef List.defines [Representable \u03b1] (addr : Addr) : List \u03b1 \u2192 Heap \u2192 Prop\n| [] => fun _ \u21a6 True\n| v :: vs => Representable.defines v addr \u2227\u2095 defines (addr + 1) vs\n\ninstance [Representable \u03b1] : Representable (List \u03b1) where defines vec := vec.defines\ninstance [Representable \u03b1] : Representable (Vector \u03b1 n) where defines vec addr heap := \u2200 i, Representable.defines (vec.nth i) (addr + i) heap\n\ninfixr:40 \" << \" => \u03bb a b => E.call Op.lt ![a, b]\ninfixr:40 \" != \" => \u03bb a b => E.call Op.neg ![E.call Op.eq ![a, b]]\n\nnamespace tests\u2081\n\ninductive V\u2081 | x | y deriving DecidableEq\n@[reducible] instance : VariableType V\u2081 := \u27e8 fun | .x => \u2115 | .y => \u2115 \u27e9\ndef V\u2081.var : (v : V\u2081) \u2192 E V\u2081 (type v)  := E.var\nopen V\u2081\n\ndef l\u2081 : TypedStore V\u2081 := \u27e8fun |.x => 2 |.y => 7\u27e9\n\nexample : (.store x.var y.var;; .skip) / {2 \u21a6 0} , l\u2081 \u21d3 (fun h _ \u21a6 \u29832\u21aa7\u2984 h l\u2081) := 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 \u21a6 0} , l\u2081 \u21d3 (fun h _ \u21a6 \u29833\u21aa21\u2984 h l\u2081) := 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\u2081 \u2115)) (.put x (x.var + 1))) /  {}, \u27e8fun |x |y => (0 : \u2115)\u27e9 \u21d3 fun _ _ \u21a6 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\u2081 l\u2082) (hl : l\u2081 = l\u2082) : (c / h, l\u2081 \u21d3 Q) \u2194 (c / h, l\u2082 \u21d3 Q) := by rw [hl]\nexample (k : \u2115) : (.while (x.var != zero) (.put x (x.var - 1))) /  {}, \u27e8fun |x => k |y => (0 : \u2115)\u27e9 \u21d3 fun _ l \u21a6 l.val x = (0 : \u2115) := 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\u2081\nend instances\n\nsection tests\u2082\n\nopen VariableType\n\ninductive V | ctr | v | total | base deriving DecidableEq\n@[reducible] instance V.VariableType : VariableType V := \u27e8 fun | ctr => \u2115 | base => \u2115 | v => \u2115 | total => \u2115 \u27e9\n\ndef V.var : (v : V) \u2192 E V (type v)  := E.var\ndef V.initial : TypedStore V := \u27e8fun | ctr | v | total | base => (0 : \u2115)\u27e9\nopen V\n\n-- see \"bug?\" below\n@[simp] theorem duplicate_of_succ_sub_succ_eq_sub (l : List \u2115) : Nat.succ (List.length l) - 1 = (List.length l) := by simp\n\ndef List.sum [Zero \u03b1] [Add \u03b1] (l : List \u03b1) : \u03b1 := l.foldr (f := (. + .)) 0\n@[simp] theorem List.sum_cons [Zero \u03b1] [Add \u03b1] (x : \u03b1) : (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 \u2115) (hlen : ctr.var.eval l = array.length) (hArr : \u2983base.var \u21aa array\u2984 h l)\n  : loopSum / h, l \u21d3 fun _ l' \u21a6 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 [\u2190 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' \u21d3 _) -- 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 (\u03b1 \u03b2 : Type) := List (\u03b1 \u00d7 \u03b2)\n\nnamespace Map\n\ndef empty : Map \u03b1 \u03b2 := []\n\ndef update [DecidableEq \u03b1] (m : Map \u03b1 \u03b2) (k : \u03b1) (v : Option \u03b2) : Map \u03b1 \u03b2 :=\n  match v with\n  | none   => List.filter (\u00ac \u00b7.fst = k) m\n  | some v => (k,v) :: m\n\ndef lookup [DecidableEq \u03b1] (m : Map \u03b1 \u03b2) (k : \u03b1) : Option \u03b2 := \n  List.lookup k m \n\ndef dom (m : Map \u03b1 \u03b2) := \n  List.map Prod.fst m\n\nmacro:max m:term noWs \"[\" k:term \" \u21a6 \" 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 := \u27e8Lb.l0, Ub.u0\u27e9 \ndef c01 : Card := \u27e8Lb.l0, Ub.u1\u27e9 \ndef c0N : Card := \u27e8Lb.l0, Ub.uN\u27e9 \ndef c10 : Card := \u27e8Lb.l1, Ub.u0\u27e9 \ndef c11 : Card := \u27e8Lb.l1, Ub.u1\u27e9 \ndef c1N : Card := \u27e8Lb.l1, Ub.uN\u27e9 \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 \u00d7 (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 \u2192 Demand \u2192 Prop where\n    | bot : EquiD \u27e8c10, sd\u2081\u27e9 \u27e8c10, sd\u2082\u27e9\n    | abs : EquiD \u27e8c00, sd\u2081\u27e9 \u27e8c00, sd\u2082\u27e9\n    | cong : EquiSD sd\u2081 sd\u2082 \u2192 EquiD \u27e8n, sd\u2081\u27e9 \u27e8n, sd\u2082\u27e9\n  inductive EquiSD : SubDemand \u2192 SubDemand \u2192 Prop where\n    | ap_bot : EquiSD (SubDemand.ap c10 sd\u2081) (SubDemand.ap c10 sd\u2082)\n    | ap_abs : EquiSD (SubDemand.ap c00 sd\u2081) (SubDemand.ap c00 sd\u2082)\n    | ap_poly : {n \u2209 [c11,c1N]} \u2192 EquiSD (SubDemand.ap n (SubDemand.poly n)) (SubDemand.poly n)\n    | sel : {n : Card} \u2192 (\u2200c \u2208 Map.dom alts, \u2200d \u2208 Map.lookup c alts, d = Demand.mk n (SubDemand.poly n)) \u2192 EquiSD (SubDemand.sel alts) (SubDemand.poly n) \n    | cong_ap : EquiSD (SubDemand.ap n sd\u2081) (SubDemand.ap n sd\u2082) \nend    \n-/\n\nnamespace Card\n\n@[inline]\ndef concLb : Lb -> Set \u2115 \n  | Lb.l0 => { n | n >= 0 }\n  | Lb.l1 => { n | n >= 1 }\n\n@[inline]\ndef concUb : Ub -> Set \u2115 \n  | Ub.u0 => {0} \n  | Ub.u1 => {0,1}\n  | Ub.uN => { n | true }\n\n@[inline]\ndef conc : Card -> Set \u2115 \n  | \u27e8 l, u \u27e9 => concLb l \u2229 concUb u\n  \n@[inline]\ndef absLb (s : Set \u2115) : Lb := match infi s with\n  | 0 => Lb.l0 \n  | _ => Lb.l1\n  \n@[inline]\ndef absUb (s : Set \u2115) : Ub := match supr s with\n  | 0 => Ub.u0\n  | 1 => Ub.u1\n  | _ => Ub.uN\n\n@[inline]\ndef abs (s : Set \u2115) : Card := \u27e8 absLb s, absUb s \u27e9 \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 \u00ac ({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\u2081, a\u2082) 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\u2081 a\u2082 h\n  simp\n  \ndef conc_injective : Function.injective conc := by\n  intros a\u2081 a\u2082 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 \u2192+* 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 \u2192 subfield M` and coercion `coe : subfield M \u2192 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 \u00d7 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 \u2192+* 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 `\u207b\u00b9`.\n\nLattice inclusion (e.g. `\u2264` and `\u2293`) is used rather than set notation (`\u2286` and `\u2229`), although\n`\u2208` 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 \u2286 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\u2093.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\u2093'. -/\ntheorem coe_rat_mem (s : S) (x : \u211a) : (x : K) \u2208 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  \u27e8fun x => \u27e8\u2191x, coe_rat_mem s x\u27e9\u27e9\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_rat_cast (s : S) (x : \u211a) : ((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\u2093.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\u2093'. -/\ntheorem rat_smul_mem (s : S) (a : \u211a) (x : s) : (a \u2022 x : K) \u2208 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 \u211a s :=\n  \u27e8fun a x => \u27e8a \u2022 x, rat_smul_mem s a x\u27e9\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_rat_smul (s : S) (a : \u211a) (x : s) : (\u2191(a \u2022 x) : K) = a \u2022 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 \u2192 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' : \u2200 x \u2208 carrier, x\u207b\u00b9 \u2208 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\u2093'. -/\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  \u27e8Subfield.carrier, fun p q h => by cases p <;> cases q <;> congr \u27e9\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\u2093'. -/\n@[simp]\ntheorem mem_carrier {s : Subfield K} {x : K} : x \u2208 s.carrier \u2194 x \u2208 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\u2081 : 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\u2082 : 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\u2083 : 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\u2084 : 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\u2085 : 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\u2086 : 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\u2081 h\u2082 h\u2083 h\u2084 h\u2085 h\u2086)) (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\u2081 : 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\u2081)) (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\u2093'. -/\n@[simp]\ntheorem mem_mk {S : Set K} {x : K} (h\u2081 h\u2082 h\u2083 h\u2084 h\u2085 h\u2086) :\n    x \u2208 (\u27e8S, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085, h\u2086\u27e9 : Subfield K) \u2194 x \u2208 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\u2081 : 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\u2082 : 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\u2083 : 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\u2084 : 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\u2085 : 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\u2086 : 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\u2093.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\u2081 h\u2082 h\u2083 h\u2084 h\u2085 h\u2086)) 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\u2081 : 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\u2081)) (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\u2093'. -/\n@[simp]\ntheorem coe_set_mk (S : Set K) (h\u2081 h\u2082 h\u2083 h\u2084 h\u2085 h\u2086) :\n    ((\u27e8S, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085, h\u2086\u27e9 : 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\u2081 : 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\u2082 : 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\u2083 : 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\u2084 : 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\u2085 : 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\u2086 : 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\u2081' : 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\u2082' : 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\u2083' : 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\u2084' : 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\u2085' : 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\u2086' : 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\u2081 h\u2082 h\u2083 h\u2084 h\u2085 h\u2086) (Subfield.mk.{u1} K _inst_1 S' h\u2081' h\u2082' h\u2083' h\u2084' h\u2085' h\u2086')) (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\u2081 : 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\u2082 : 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\u2081) (Subfield.mk.{u1} K _inst_1 S' h\u2082)) (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\u2093'. -/\n@[simp]\ntheorem mk_le_mk {S S' : Set K} (h\u2081 h\u2082 h\u2083 h\u2084 h\u2085 h\u2086 h\u2081' h\u2082' h\u2083' h\u2084' h\u2085' h\u2086') :\n    (\u27e8S, h\u2081, h\u2082, h\u2083, h\u2084, h\u2085, h\u2086\u27e9 : Subfield K) \u2264 (\u27e8S', h\u2081', h\u2082', h\u2083', h\u2084', h\u2085', h\u2086'\u27e9 : Subfield K) \u2194\n      S \u2286 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\u2093'. -/\n/-- Two subfields are equal if they have the same elements. -/\n@[ext]\ntheorem ext {S T : Subfield K} (h : \u2200 x, x \u2208 S \u2194 x \u2208 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\u2093.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\u2093'. -/\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 = \u2191S) : Subfield K :=\n  { S.toSubring.copy s hs with\n    carrier := s\n    inv_mem' := hs.symm \u25b8 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_copy (S : Subfield K) (s : Set K) (hs : s = \u2191S) : (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\u2093.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\u2093'. -/\ntheorem copy_eq (S : Subfield K) (s : Set K) (hs : s = \u2191S) : 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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem mem_toSubring (s : Subfield K) (x : K) : x \u2208 s.toSubring \u2194 x \u2208 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\u2093'. -/\n/-- A `subring` containing inverses is a `subfield`. -/\ndef Subring.toSubfield (s : Subring K) (hinv : \u2200 x \u2208 s, x\u207b\u00b9 \u2208 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\u2093'. -/\n/-- A subfield contains the field's 1. -/\nprotected theorem one_mem : (1 : K) \u2208 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\u2093'. -/\n/-- A subfield contains the field's 0. -/\nprotected theorem zero_mem : (0 : K) \u2208 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\u2093'. -/\n/-- A subfield is closed under multiplication. -/\nprotected theorem mul_mem {x y : K} : x \u2208 s \u2192 y \u2208 s \u2192 x * y \u2208 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\u2093'. -/\n/-- A subfield is closed under addition. -/\nprotected theorem add_mem {x y : K} : x \u2208 s \u2192 y \u2208 s \u2192 x + y \u2208 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\u2093'. -/\n/-- A subfield is closed under negation. -/\nprotected theorem neg_mem {x : K} : x \u2208 s \u2192 -x \u2208 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\u2093'. -/\n/-- A subfield is closed under subtraction. -/\nprotected theorem sub_mem {x y : K} : x \u2208 s \u2192 y \u2208 s \u2192 x - y \u2208 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\u2093'. -/\n/-- A subfield is closed under inverses. -/\nprotected theorem inv_mem {x : K} : x \u2208 s \u2192 x\u207b\u00b9 \u2208 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\u2093'. -/\n/-- A subfield is closed under division. -/\nprotected theorem div_mem {x y : K} : x \u2208 s \u2192 y \u2208 s \u2192 x / y \u2208 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\u2093'. -/\n/-- Product of a list of elements in a subfield is in the subfield. -/\nprotected theorem list_prod_mem {l : List K} : (\u2200 x \u2208 l, x \u2208 s) \u2192 l.Prod \u2208 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\u2093'. -/\n/-- Sum of a list of elements in a subfield is in the subfield. -/\nprotected theorem list_sum_mem {l : List K} : (\u2200 x \u2208 l, x \u2208 s) \u2192 l.Sum \u2208 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\u2093'. -/\n/-- Product of a multiset of elements in a subfield is in the subfield. -/\nprotected theorem multiset_prod_mem (m : Multiset K) : (\u2200 a \u2208 m, a \u2208 s) \u2192 m.Prod \u2208 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\u2093'. -/\n/-- Sum of a multiset of elements in a `subfield` is in the `subfield`. -/\nprotected theorem multiset_sum_mem (m : Multiset K) : (\u2200 a \u2208 m, a \u2208 s) \u2192 m.Sum \u2208 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) {\u03b9 : Type.{u2}} {t : Finset.{u2} \u03b9} {f : \u03b9 -> K}, (forall (c : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.hasMem.{u2} \u03b9) 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 \u03b9 (CommRing.toCommMonoid.{u1} K (Field.toCommRing.{u1} K _inst_1)) t (fun (i : \u03b9) => 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) {\u03b9 : Type.{u1}} {t : Finset.{u1} \u03b9} {f : \u03b9 -> K}, (forall (c : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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 \u03b9 (CommRing.toCommMonoid.{u2} K (Field.toCommRing.{u2} K _inst_1)) t (fun (i : \u03b9) => f i)) s)\nCase conversion may be inaccurate. Consider using '#align subfield.prod_mem Subfield.prod_mem\u2093'. -/\n/-- Product of elements of a subfield indexed by a `finset` is in the subfield. -/\nprotected theorem prod_mem {\u03b9 : Type _} {t : Finset \u03b9} {f : \u03b9 \u2192 K} (h : \u2200 c \u2208 t, f c \u2208 s) :\n    (\u220f i in t, f i) \u2208 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) {\u03b9 : Type.{u2}} {t : Finset.{u2} \u03b9} {f : \u03b9 -> K}, (forall (c : \u03b9), (Membership.Mem.{u2, u2} \u03b9 (Finset.{u2} \u03b9) (Finset.hasMem.{u2} \u03b9) 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 \u03b9 (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 : \u03b9) => 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) {\u03b9 : Type.{u1}} {t : Finset.{u1} \u03b9} {f : \u03b9 -> K}, (forall (c : \u03b9), (Membership.mem.{u1, u1} \u03b9 (Finset.{u1} \u03b9) (Finset.instMembershipFinset.{u1} \u03b9) 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 \u03b9 (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 : \u03b9) => f i)) s)\nCase conversion may be inaccurate. Consider using '#align subfield.sum_mem Subfield.sum_mem\u2093'. -/\n/-- Sum of elements in a `subfield` indexed by a `finset` is in the `subfield`. -/\nprotected theorem sum_mem {\u03b9 : Type _} {t : Finset \u03b9} {f : \u03b9 \u2192 K} (h : \u2200 c \u2208 t, f c \u2208 s) :\n    (\u2211 i in t, f i) \u2208 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\u2093'. -/\nprotected theorem pow_mem {x : K} (hx : x \u2208 s) (n : \u2115) : x ^ n \u2208 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\u2093'. -/\nprotected theorem zsmul_mem {x : K} (hx : x \u2208 s) (n : \u2124) : n \u2022 x \u2208 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\u2093.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\u2093'. -/\nprotected theorem coe_int_mem (n : \u2124) : (n : K) \u2208 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\u2093'. -/\ntheorem zpow_mem {x : K} (hx : x \u2208 s) (n : \u2124) : x ^ n \u2208 s :=\n  by\n  cases n\n  \u00b7 simpa using s.pow_mem hx n\n  \u00b7 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  \u27e8fun x y => \u27e8x / y, s.div_mem x.2 y.2\u27e9\u27e9\n\ninstance : Inv s :=\n  \u27e8fun x => \u27e8x\u207b\u00b9, s.inv_mem x.2\u27e9\u27e9\n\ninstance : Pow s \u2124 :=\n  \u27e8fun x z => \u27e8x ^ z, s.zpow_mem x.2 z\u27e9\u27e9\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\u2093'. -/\n/-- A subfield inherits a field structure -/\ninstance toField : Field s :=\n  Subtype.coe_injective.Field (coe : s \u2192 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\u2093'. -/\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_add (x y : s) : (\u2191(x + y) : K) = \u2191x + \u2191y :=\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_sub (x y : s) : (\u2191(x - y) : K) = \u2191x - \u2191y :=\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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_neg (x : s) : (\u2191(-x) : K) = -\u2191x :=\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_mul (x y : s) : (\u2191(x * y) : K) = \u2191x * \u2191y :=\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_div (x y : s) : (\u2191(x / y) : K) = \u2191x / \u2191y :=\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\u2093.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\u2093.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\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_inv (x : s) : (\u2191x\u207b\u00b9 : K) = (\u2191x)\u207b\u00b9 :=\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\u2093.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\u2093'. -/\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\u2093.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\u2093'. -/\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\u2093'. -/\n/-- The embedding from a subfield of the field `K` to `K`. -/\ndef subtype (s : Subfield K) : s \u2192+* 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\u2093'. -/\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\u2093.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 (\u1fb0 : 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) \u1fb0) (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\u2093'. -/\n@[simp]\ntheorem coe_subtype : \u21d1s.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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem mem_toSubmonoid {s : Subfield K} {x : K} : x \u2208 s.toSubmonoid \u2194 x \u2208 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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem mem_toAddSubgroup {s : Subfield K} {x : K} : x \u2208 s.toAddSubgroup \u2194 x \u2208 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\u2093.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\u2093.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\u2093'. -/\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  \u27e8{ (\u22a4 : Subring K) with inv_mem' := fun x _ => Subring.mem_top x }\u27e9\n\ninstance : Inhabited (Subfield K) :=\n  \u27e8\u22a4\u27e9\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\u2093'. -/\n@[simp]\ntheorem mem_top (x : K) : x \u2208 (\u22a4 : 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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_top : ((\u22a4 : 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\u2093'. -/\n/-- The ring equiv between the top element of `subfield K` and `K`. -/\n@[simps]\ndef topEquiv : (\u22a4 : Subfield K) \u2243+* K :=\n  Subsemiring.topEquiv\n#align subfield.top_equiv Subfield.topEquiv\n\n/-! # comap -/\n\n\nvariable (f : K \u2192+* 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\u207b\u00b9 \u2208 s by\n        rw [map_inv\u2080 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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_comap (s : Subfield L) : (s.comap f : Set K) = f \u207b\u00b9' 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\u2093'. -/\n@[simp]\ntheorem mem_comap {s : Subfield L} {f : K \u2192+* L} {x : K} : x \u2208 s.comap f \u2194 f x \u2208 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 \u2192+* M) (f : K \u2192+* 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 _ \u27e8x, hx, rfl\u27e9\n      exact \u27e8x\u207b\u00b9, s.inv_mem hx, map_inv\u2080 f x\u27e9 }\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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem mem_map {f : K \u2192+* L} {s : Subfield K} {y : L} : y \u2208 s.map f \u2194 \u2203 x \u2208 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 \u2192+* M) (f : K \u2192+* 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\u2093'. -/\ntheorem map_le_iff_le_comap {f : K \u2192+* L} {s : Subfield K} {t : Subfield L} :\n    s.map f \u2264 t \u2194 s \u2264 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\u2093'. -/\ntheorem gc_map_comap (f : K \u2192+* 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 \u2192+* M) (f : K \u2192+* 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  ((\u22a4 : 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\u2093.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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem mem_fieldRange {f : K \u2192+* L} {y : L} : y \u2208 f.fieldRange \u2194 \u2203 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\u2093'. -/\ntheorem fieldRange_eq_map : f.fieldRange = Subfield.map f \u22a4 :=\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 (\u22a4 : 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\u2093'. -/\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 \u2192+* 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  \u27e8fun s t =>\n    { s.toSubring \u2293 t.toSubring with\n      inv_mem' := fun x hx =>\n        Subring.mem_inf.mpr\n          \u27e8s.inv_mem (Subring.mem_inf.mp hx).1, t.inv_mem (Subring.mem_inf.mp hx).2\u27e9 }\u27e9\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_inf (p p' : Subfield K) : ((p \u2293 p' : Subfield K) : Set K) = p \u2229 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\u2093'. -/\n@[simp]\ntheorem mem_inf {p p' : Subfield K} {x : K} : x \u2208 p \u2293 p' \u2194 x \u2208 p \u2227 x \u2208 p' :=\n  Iff.rfl\n#align subfield.mem_inf Subfield.mem_inf\n\ninstance : InfSet (Subfield K) :=\n  \u27e8fun S =>\n    { inf\u209b (Subfield.toSubring '' S) with\n      inv_mem' := by\n        rintro x hx\n        apply subring.mem_Inf.mpr\n        rintro _ \u27e8p, p_mem, rfl\u27e9\n        exact p.inv_mem (subring.mem_Inf.mp hx p.to_subring \u27e8p, p_mem, rfl\u27e9) }\u27e9\n\n/- warning: subfield.coe_Inf -> Subfield.coe_inf\u209b 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\u2093.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\u209b.{u1} (Subfield.{u1} K _inst_1) (Subfield.hasInf.{u1} K _inst_1) S)) (Set.inter\u1d62.{u1, succ u1} K (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Set.inter\u1d62.{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\u2093.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\u209b.{u1} (Subfield.{u1} K _inst_1) (Subfield.instInfSetSubfield.{u1} K _inst_1) S)) (Set.inter\u1d62.{u1, succ u1} K (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Set.inter\u1d62.{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\u209b\u2093'. -/\n@[simp, norm_cast]\ntheorem coe_inf\u209b (S : Set (Subfield K)) : ((inf\u209b S : Subfield K) : Set K) = \u22c2 s \u2208 S, \u2191s :=\n  show ((inf\u209b (Subfield.toSubring '' S) : Subring K) : Set K) = \u22c2 s \u2208 S, \u2191s\n    by\n    ext x\n    rw [Subring.coe_inf\u209b, Set.mem_inter\u1d62, Set.mem_inter\u1d62]\n    exact\n      \u27e8fun h s s' \u27e8s_mem, s'_eq\u27e9 => h s.toSubring _ \u27e8\u27e8s, s_mem, rfl\u27e9, s'_eq\u27e9,\n        fun h s s' \u27e8\u27e8s'', s''_mem, s_eq\u27e9, (s'_eq : \u2191s = s')\u27e9 =>\n        h s'' _ \u27e8s''_mem, by simp [\u2190 s_eq, \u2190 s'_eq]\u27e9\u27e9\n#align subfield.coe_Inf Subfield.coe_inf\u209b\n\n/- warning: subfield.mem_Inf -> Subfield.mem_inf\u209b 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\u209b.{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\u209b.{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\u209b\u2093'. -/\ntheorem mem_inf\u209b {S : Set (Subfield K)} {x : K} : x \u2208 inf\u209b S \u2194 \u2200 p \u2208 S, x \u2208 p :=\n  Subring.mem_inf\u209b.trans\n    \u27e8fun h p hp => h p.toSubring \u27e8p, hp, rfl\u27e9, fun h p \u27e8p', hp', p_eq\u27e9 => p_eq \u25b8 h p' hp'\u27e9\n#align subfield.mem_Inf Subfield.mem_inf\u209b\n\n#print Subfield.inf\u209b_toSubring /-\n@[simp]\ntheorem inf\u209b_toSubring (s : Set (Subfield K)) :\n    (inf\u209b s).toSubring = \u2a05 t \u2208 s, Subfield.toSubring t :=\n  by\n  ext x\n  rw [mem_to_subring, mem_Inf]\n  erw [Subring.mem_inf\u209b]\n  exact\n    \u27e8fun h p \u27e8p', hp\u27e9 => hp \u25b8 subring.mem_Inf.mpr fun p \u27e8hp', hp\u27e9 => hp \u25b8 h _ hp', fun h p hp =>\n      h p.toSubring\n        \u27e8p,\n          Subring.ext fun x =>\n            \u27e8fun hx => subring.mem_Inf.mp hx _ \u27e8hp, rfl\u27e9, fun hx =>\n              subring.mem_Inf.mpr fun p' \u27e8hp, p'_eq\u27e9 => p'_eq \u25b8 hx\u27e9\u27e9\u27e9\n#align subfield.Inf_to_subring Subfield.inf\u209b_toSubring\n-/\n\n#print Subfield.isGLB_inf\u209b /-\ntheorem isGLB_inf\u209b (S : Set (Subfield K)) : IsGLB S (inf\u209b S) :=\n  by\n  refine' IsGLB.of_image (fun s t => show (s : Set K) \u2264 t \u2194 s \u2264 t from SetLike.coe_subset_coe) _\n  convert isGLB_binf\u1d62\n  exact coe_Inf _\n#align subfield.is_glb_Inf Subfield.isGLB_inf\u209b\n-/\n\n/-- Subfields of a ring form a complete lattice. -/\ninstance : CompleteLattice (Subfield K) :=\n  {\n    completeLatticeOfInf (Subfield K) isGLB_inf\u209b with\n    top := \u22a4\n    le_top := fun s x hx => trivial\n    inf := (\u00b7 \u2293 \u00b7)\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\u2081 t\u2082 h\u2081 h\u2082 x hx => \u27e8h\u2081 hx, h\u2082 hx\u27e9 }\n\n/-! # subfield closure of a subset -/\n\n\n/- ./././Mathport/Syntax/Translate/Expr.lean:366:4: unsupported set replacement {(\u00abexpr / \u00bb(x, y)) | (x \u00abexpr \u2208 \u00bb subring.closure[subring.closure] s) (y \u00abexpr \u2208 \u00bb 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 {(\u00abexpr / \u00bb(x, y)) | (x \u00abexpr \u2208 \u00bb subring.closure[subring.closure] s) (y \u00abexpr \u2208 \u00bb subring.closure[subring.closure] s)}\"\n  zero_mem' := \u27e80, Subring.zero_mem _, 1, Subring.one_mem _, div_one _\u27e9\n  one_mem' := \u27e81, Subring.one_mem _, 1, Subring.one_mem _, div_one _\u27e9\n  neg_mem' := fun x \u27e8y, hy, z, hz, x_eq\u27e9 => \u27e8-y, Subring.neg_mem _ hy, z, hz, x_eq \u25b8 neg_div _ _\u27e9\n  inv_mem' := fun x \u27e8y, hy, z, hz, x_eq\u27e9 => \u27e8z, hz, y, hy, x_eq \u25b8 (inv_div _ _).symm\u27e9\n  add_mem' x y x_mem y_mem :=\n    by\n    obtain \u27e8nx, hnx, dx, hdx, rfl\u27e9 := id x_mem\n    obtain \u27e8ny, hny, dy, hdy, rfl\u27e9 := id y_mem\n    by_cases hx0 : dx = 0; \u00b7 rwa [hx0, div_zero, zero_add]\n    by_cases hy0 : dy = 0; \u00b7 rwa [hy0, div_zero, add_zero]\n    exact\n      \u27e8nx * 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\u27e9\n  mul_mem' x y x_mem y_mem :=\n    by\n    obtain \u27e8nx, hnx, dx, hdx, rfl\u27e9 := id x_mem\n    obtain \u27e8ny, hny, dy, hdy, rfl\u27e9 := id y_mem\n    exact\n      \u27e8nx * ny, Subring.mul_mem _ hnx hny, dx * dy, Subring.mul_mem _ hdx hdy,\n        (div_mul_div_comm _ _ _ _).symm\u27e9\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\u2093'. -/\ntheorem mem_closure_iff {s : Set K} {x} :\n    x \u2208 closure s \u2194 \u2203 y \u2208 Subring.closure s, \u2203 z \u2208 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\u2093'. -/\ntheorem subring_closure_le (s : Set K) : Subring.closure s \u2264 (closure s).toSubring := fun x hx =>\n  \u27e8x, hx, 1, Subring.one_mem _, div_one x\u27e9\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\u2093.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\u2093'. -/\n/-- The subfield generated by a set includes the set. -/\n@[simp]\ntheorem subset_closure {s : Set K} : s \u2286 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\u2093'. -/\ntheorem not_mem_of_not_mem_closure {s : Set K} {P : K} (hP : P \u2209 closure s) : P \u2209 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\u2093.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\u2093'. -/\ntheorem mem_closure {x : K} {s : Set K} : x \u2208 closure s \u2194 \u2200 S : Subfield K, s \u2286 S \u2192 x \u2208 S :=\n  \u27e8fun \u27e8y, hy, z, hz, x_eq\u27e9 t le =>\n    x_eq \u25b8\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\u27e9\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\u2093.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\u2093'. -/\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 \u2264 t \u2194 s \u2286 t :=\n  \u27e8Set.Subset.trans subset_closure, fun h x hx => mem_closure.mp hx t h\u27e9\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\u2093'. -/\n/-- Subfield closure of a set is monotone in its argument: if `s \u2286 t`,\nthen `closure s \u2264 closure t`. -/\ntheorem closure_mono \u2983s t : Set K\u2984 (h : s \u2286 t) : closure s \u2264 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\u2093.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\u2093'. -/\ntheorem closure_eq_of_le {s : Set K} {t : Subfield K} (h\u2081 : s \u2286 t) (h\u2082 : t \u2264 closure s) :\n    closure s = t :=\n  le_antisymm (closure_le.2 h\u2081) h\u2082\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\u2093'. -/\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 \u2192 Prop} {x} (h : x \u2208 closure s) (Hs : \u2200 x \u2208 s, p x)\n    (H1 : p 1) (Hadd : \u2200 x y, p x \u2192 p y \u2192 p (x + y)) (Hneg : \u2200 x, p x \u2192 p (-x))\n    (Hinv : \u2200 x, p x \u2192 p x\u207b\u00b9) (Hmul : \u2200 x y, p x \u2192 p y \u2192 p (x * y)) : p x :=\n  (@closure_le _ _ _\n        \u27e8p, Hmul, H1, Hadd, @add_neg_self K _ 1 \u25b8 Hadd _ _ H1 (Hneg _ H1), Hneg, Hinv\u27e9).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\u2093.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\u2093'. -/\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\u2093'. -/\n@[simp]\ntheorem closure_empty : closure (\u2205 : Set K) = \u22a5 :=\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\u2093'. -/\n@[simp]\ntheorem closure_univ : closure (Set.univ : Set K) = \u22a4 :=\n  @coe_top K _ \u25b8 closure_eq \u22a4\n#align subfield.closure_univ Subfield.closure_univ\n\n#print Subfield.closure_union /-\ntheorem closure_union (s t : Set K) : closure (s \u222a t) = closure s \u2294 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\u1d62 is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {\u03b9 : Sort.{u2}} (s : \u03b9 -> (Set.{u1} K)), Eq.{succ u1} (Subfield.{u1} K _inst_1) (Subfield.closure.{u1} K _inst_1 (Set.union\u1d62.{u1, u2} K \u03b9 (fun (i : \u03b9) => s i))) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => Subfield.closure.{u1} K _inst_1 (s i)))\nbut is expected to have type\n  forall {K : Type.{u2}} [_inst_1 : Field.{u2} K] {\u03b9 : Sort.{u1}} (s : \u03b9 -> (Set.{u2} K)), Eq.{succ u2} (Subfield.{u2} K _inst_1) (Subfield.closure.{u2} K _inst_1 (Set.union\u1d62.{u2, u1} K \u03b9 (fun (i : \u03b9) => s i))) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => Subfield.closure.{u2} K _inst_1 (s i)))\nCase conversion may be inaccurate. Consider using '#align subfield.closure_Union Subfield.closure_union\u1d62\u2093'. -/\ntheorem closure_union\u1d62 {\u03b9} (s : \u03b9 \u2192 Set K) : closure (\u22c3 i, s i) = \u2a06 i, closure (s i) :=\n  (Subfield.gi K).gc.l_sup\u1d62\n#align subfield.closure_Union Subfield.closure_union\u1d62\n\n/- warning: subfield.closure_sUnion -> Subfield.closure_union\u209b 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\u209b.{u1} K s)) (sup\u1d62.{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\u1d62.{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\u209b.{u1} K s)) (sup\u1d62.{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\u1d62.{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\u209b\u2093'. -/\ntheorem closure_union\u209b (s : Set (Set K)) : closure (\u22c3\u2080 s) = \u2a06 t \u2208 s, closure t :=\n  (Subfield.gi K).gc.l_sup\u209b\n#align subfield.closure_sUnion Subfield.closure_union\u209b\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\u2093'. -/\ntheorem map_sup (s t : Subfield K) (f : K \u2192+* L) : (s \u2294 t).map f = s.map f \u2294 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\u1d62 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] {\u03b9 : 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 : \u03b9 -> (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\u1d62.{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))) \u03b9 s)) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => 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] {\u03b9 : 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 : \u03b9 -> (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\u1d62.{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))) \u03b9 s)) (sup\u1d62.{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))) \u03b9 (fun (i : \u03b9) => 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\u1d62\u2093'. -/\ntheorem map_sup\u1d62 {\u03b9 : Sort _} (f : K \u2192+* L) (s : \u03b9 \u2192 Subfield K) :\n    (sup\u1d62 s).map f = \u2a06 i, (s i).map f :=\n  (gc_map_comap f).l_sup\u1d62\n#align subfield.map_supr Subfield.map_sup\u1d62\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\u2093'. -/\ntheorem comap_inf (s t : Subfield L) (f : K \u2192+* L) : (s \u2293 t).comap f = s.comap f \u2293 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\u1d62 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] {\u03b9 : 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 : \u03b9 -> (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\u1d62.{u2, u3} (Subfield.{u2} L _inst_2) (Subfield.hasInf.{u2} L _inst_2) \u03b9 s)) (inf\u1d62.{u1, u3} (Subfield.{u1} K _inst_1) (Subfield.hasInf.{u1} K _inst_1) \u03b9 (fun (i : \u03b9) => 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] {\u03b9 : 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 : \u03b9 -> (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\u1d62.{u3, u1} (Subfield.{u3} L _inst_2) (Subfield.instInfSetSubfield.{u3} L _inst_2) \u03b9 s)) (inf\u1d62.{u2, u1} (Subfield.{u2} K _inst_1) (Subfield.instInfSetSubfield.{u2} K _inst_1) \u03b9 (fun (i : \u03b9) => 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\u1d62\u2093'. -/\ntheorem comap_inf\u1d62 {\u03b9 : Sort _} (f : K \u2192+* L) (s : \u03b9 \u2192 Subfield L) :\n    (inf\u1d62 s).comap f = \u2a05 i, (s i).comap f :=\n  (gc_map_comap f).u_inf\u1d62\n#align subfield.comap_infi Subfield.comap_inf\u1d62\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\u2093'. -/\n@[simp]\ntheorem map_bot (f : K \u2192+* L) : (\u22a5 : Subfield K).map f = \u22a5 :=\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\u2093'. -/\n@[simp]\ntheorem comap_top (f : K \u2192+* L) : (\u22a4 : Subfield L).comap f = \u22a4 :=\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\u1d62_of_directed is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {\u03b9 : Sort.{u2}} [h\u03b9 : Nonempty.{u2} \u03b9] {S : \u03b9 -> (Subfield.{u1} K _inst_1)}, (Directed.{u1, u2} (Subfield.{u1} K _inst_1) \u03b9 (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\u1d62.{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))) \u03b9 (fun (i : \u03b9) => S i))) (Exists.{u2} \u03b9 (fun (i : \u03b9) => 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] {\u03b9 : Sort.{u1}} [h\u03b9 : Nonempty.{u1} \u03b9] {S : \u03b9 -> (Subfield.{u2} K _inst_1)}, (Directed.{u2, u1} (Subfield.{u2} K _inst_1) \u03b9 (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\u1d62.{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))) \u03b9 (fun (i : \u03b9) => S i))) (Exists.{u1} \u03b9 (fun (i : \u03b9) => 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\u1d62_of_directed\u2093'. -/\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\u1d62_of_directed {\u03b9} [h\u03b9 : Nonempty \u03b9] {S : \u03b9 \u2192 Subfield K} (hS : Directed (\u00b7 \u2264 \u00b7) S)\n    {x : K} : (x \u2208 \u2a06 i, S i) \u2194 \u2203 i, x \u2208 S i :=\n  by\n  refine' \u27e8_, fun \u27e8i, hi\u27e9 => (SetLike.le_def.1 <| le_sup\u1d62 S i) hi\u27e9\n  suffices x \u2208 closure (\u22c3 i, (S i : Set K)) \u2192 \u2203 i, x \u2208 S i by\n    simpa only [closure_union\u1d62, closure_eq]\n  refine' fun hx => closure_induction hx (fun x => set.mem_Union.mp) _ _ _ _ _\n  \u00b7 exact h\u03b9.elim fun i => \u27e8i, (S i).one_mem\u27e9\n  \u00b7 rintro x y \u27e8i, hi\u27e9 \u27e8j, hj\u27e9\n    obtain \u27e8k, hki, hkj\u27e9 := hS i j\n    exact \u27e8k, (S k).add_mem (hki hi) (hkj hj)\u27e9\n  \u00b7 rintro x \u27e8i, hi\u27e9\n    exact \u27e8i, (S i).neg_mem hi\u27e9\n  \u00b7 rintro x \u27e8i, hi\u27e9\n    exact \u27e8i, (S i).inv_mem hi\u27e9\n  \u00b7 rintro x y \u27e8i, hi\u27e9 \u27e8j, hj\u27e9\n    obtain \u27e8k, hki, hkj\u27e9 := hS i j\n    exact \u27e8k, (S k).mul_mem (hki hi) (hkj hj)\u27e9\n#align subfield.mem_supr_of_directed Subfield.mem_sup\u1d62_of_directed\n\n/- warning: subfield.coe_supr_of_directed -> Subfield.coe_sup\u1d62_of_directed is a dubious translation:\nlean 3 declaration is\n  forall {K : Type.{u1}} [_inst_1 : Field.{u1} K] {\u03b9 : Sort.{u2}} [h\u03b9 : Nonempty.{u2} \u03b9] {S : \u03b9 -> (Subfield.{u1} K _inst_1)}, (Directed.{u1, u2} (Subfield.{u1} K _inst_1) \u03b9 (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\u2093.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\u1d62.{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))) \u03b9 (fun (i : \u03b9) => S i))) (Set.union\u1d62.{u1, u2} K \u03b9 (fun (i : \u03b9) => (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\u2093.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] {\u03b9 : Sort.{u1}} [h\u03b9 : Nonempty.{u1} \u03b9] {S : \u03b9 -> (Subfield.{u2} K _inst_1)}, (Directed.{u2, u1} (Subfield.{u2} K _inst_1) \u03b9 (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\u1d62.{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))) \u03b9 (fun (i : \u03b9) => S i))) (Set.union\u1d62.{u2, u1} K \u03b9 (fun (i : \u03b9) => 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\u1d62_of_directed\u2093'. -/\ntheorem coe_sup\u1d62_of_directed {\u03b9} [h\u03b9 : Nonempty \u03b9] {S : \u03b9 \u2192 Subfield K} (hS : Directed (\u00b7 \u2264 \u00b7) S) :\n    ((\u2a06 i, S i : Subfield K) : Set K) = \u22c3 i, \u2191(S i) :=\n  Set.ext fun x => by simp [mem_supr_of_directed hS]\n#align subfield.coe_supr_of_directed Subfield.coe_sup\u1d62_of_directed\n\n/- warning: subfield.mem_Sup_of_directed_on -> Subfield.mem_sup\u209b_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\u209b.{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\u209b.{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\u209b_of_directedOn\u2093'. -/\ntheorem mem_sup\u209b_of_directedOn {S : Set (Subfield K)} (Sne : S.Nonempty) (hS : DirectedOn (\u00b7 \u2264 \u00b7) S)\n    {x : K} : x \u2208 sup\u209b S \u2194 \u2203 s \u2208 S, x \u2208 s :=\n  by\n  haveI : Nonempty S := Sne.to_subtype\n  simp only [sup\u209b_eq_sup\u1d62', mem_supr_of_directed hS.directed_coe, SetCoe.exists, Subtype.coe_mk]\n#align subfield.mem_Sup_of_directed_on Subfield.mem_sup\u209b_of_directedOn\n\n/- warning: subfield.coe_Sup_of_directed_on -> Subfield.coe_sup\u209b_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\u2093.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\u209b.{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\u1d62.{u1, succ u1} K (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Set.union\u1d62.{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\u2093.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\u209b.{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\u1d62.{u1, succ u1} K (Subfield.{u1} K _inst_1) (fun (s : Subfield.{u1} K _inst_1) => Set.union\u1d62.{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\u209b_of_directedOn\u2093'. -/\ntheorem coe_sup\u209b_of_directedOn {S : Set (Subfield K)} (Sne : S.Nonempty)\n    (hS : DirectedOn (\u00b7 \u2264 \u00b7) S) : (\u2191(sup\u209b S) : Set K) = \u22c3 s \u2208 S, \u2191s :=\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\u209b_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\u2093'. -/\n/-- Restriction of a ring homomorphism to its range interpreted as a subfield. -/\ndef rangeRestrictField (f : K \u2192+* L) : K \u2192+* 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\u2093.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\u2093'. -/\n@[simp]\ntheorem coe_rangeRestrictField (f : K \u2192+* 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 \u2192+* L) : Subfield K :=\n  {\n    (f : K \u2192+* L).eqLocus\n      g with\n    inv_mem' := fun x (hx : f x = g x) => show f x\u207b\u00b9 = g x\u207b\u00b9 by rw [map_inv\u2080 f, map_inv\u2080 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\u2093.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\u2093'. -/\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 \u2192+* L} {s : Set K} (h : Set.EqOn f g s) :\n    Set.EqOn f g (closure s) :=\n  show closure s \u2264 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\u2093.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\u2093'. -/\ntheorem eq_of_eqOn_subfield_top {f g : K \u2192+* L} (h : Set.EqOn f g (\u22a4 : 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\u2093'. -/\ntheorem eq_of_eqOn_of_field_closure_eq_top {s : Set K} (hs : closure s = \u22a4) {f g : K \u2192+* L}\n    (h : s.EqOn f g) : f = g :=\n  eq_of_eqOn_subfield_top <| hs \u25b8 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\u2093'. -/\ntheorem field_closure_preimage_le (f : K \u2192+* L) (s : Set L) :\n    closure (f \u207b\u00b9' s) \u2264 (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 \u2192+* 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\u2093'. -/\n/-- The ring homomorphism associated to an inclusion of subfields. -/\ndef inclusion {S T : Subfield K} (h : S \u2264 T) : S \u2192+* 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\u2093'. -/\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\u2093'. -/\n/-- Makes the identity isomorphism from a proof two subfields of a multiplicative\n    monoid are equal. -/\ndef subfieldCongr (h : s = t) : s \u2243+* 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\u2093'. -/\ntheorem closure_preimage_le (f : K \u2192+* L) (s : Set L) : closure (f \u207b\u00b9' s) \u2264 (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 (\u03bc : Type v) : \u2115 \u2192 Type (max u v) where\n  | verum  {n} : SubFormula \u03bc n\n  | falsum {n} : SubFormula \u03bc n\n  | rel    {n} : \u2200 {k}, L.rel k \u2192 (Fin k \u2192 SubTerm L \u03bc n) \u2192 SubFormula \u03bc n\n  | nrel   {n} : \u2200 {k}, L.rel k \u2192 (Fin k \u2192 SubTerm L \u03bc n) \u2192 SubFormula \u03bc n\n  | and    {n} : SubFormula \u03bc n \u2192 SubFormula \u03bc n \u2192 SubFormula \u03bc n\n  | or     {n} : SubFormula \u03bc n \u2192 SubFormula \u03bc n \u2192 SubFormula \u03bc n\n  | all    {n} : SubFormula \u03bc (n + 1) \u2192 SubFormula \u03bc n\n  | ex     {n} : SubFormula \u03bc (n + 1) \u2192 SubFormula \u03bc n\n\nvariable (\u03bc : Type v) (\u03bc\u2081 : Type v\u2081) (\u03bc\u2082 : Type v\u2082) (\u03bc\u2083 : Type v\u2083)\n\nabbrev Formula := SubFormula L \u03bc 0\n\nabbrev Sentence := Formula L Empty\n\nabbrev SyntacticSubFormula (n : \u2115) := SubFormula L \u2115 n\n\nabbrev SyntacticFormula := SyntacticSubFormula L 0\n\nvariable {L \u03bc \u03bc\u2081 \u03bc\u2082 \u03bc\u2083}\n\nnamespace SubFormula\nvariable {n n\u2081 n\u2082 : \u2115}\n\ndef neg {n} : SubFormula L \u03bc n \u2192 SubFormula L \u03bc 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 \u03bc n) : neg (neg p) = p :=\n  by induction p <;> simp[*, neg]\n\ninstance : HasLogicSymbols (SubFormula L \u03bc 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 \u03bc) := \u27e8all\u27e9\ninstance : HasEx (SubFormula L \u03bc) := \u27e8ex\u27e9\n\n@[simp] lemma neg_top : ~(\u22a4 : SubFormula L \u03bc n) = \u22a5 := rfl\n\n@[simp] lemma neg_bot : ~(\u22a5 : SubFormula L \u03bc n) = \u22a4 := rfl\n\n@[simp] lemma neg_rel {k} (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc n) : ~(rel r v) = nrel r v := rfl\n\n@[simp] lemma neg_nrel {k} (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc n) : ~(nrel r v) = rel r v := rfl\n\n@[simp] lemma neg_and (p q : SubFormula L \u03bc n) : ~(p \u22cf q) = ~p \u22ce ~q := rfl\n\n@[simp] lemma neg_or (p q : SubFormula L \u03bc n) : ~(p \u22ce q) = ~p \u22cf ~q := rfl\n\n@[simp] lemma neg_all (p : SubFormula L \u03bc (n + 1)) : ~(\u2200' p) = \u2203' ~p := rfl\n\n@[simp] lemma neg_ex (p : SubFormula L \u03bc (n + 1)) : ~(\u2203' p) = \u2200' ~p := rfl\n\n@[simp] lemma neg_neg' (p : SubFormula L \u03bc n) : ~~p = p := neg_neg p\n\nlemma neg_eq (p : SubFormula L \u03bc n) : ~p = neg p := rfl\n\nlemma imp_eq (p q : SubFormula L \u03bc n) : p \u27f6 q = ~p \u22ce q := rfl\n\nlemma iff_eq (p q : SubFormula L \u03bc n) : p \u27f7 q = (~p \u22ce q) \u22cf (~q \u22ce p) := rfl\n\n@[simp] lemma and_inj (p\u2081 q\u2081 p\u2082 q\u2082 : SubFormula L \u03bc n) : p\u2081 \u22cf p\u2082 = q\u2081 \u22cf q\u2082 \u2194 p\u2081 = q\u2081 \u2227 p\u2082 = q\u2082 :=\nby simp[HasAnd.and]\n\n@[simp] lemma or_inj (p\u2081 q\u2081 p\u2082 q\u2082 : SubFormula L \u03bc n) : p\u2081 \u22ce p\u2082 = q\u2081 \u22ce q\u2082 \u2194 p\u2081 = q\u2081 \u2227 p\u2082 = q\u2082 :=\nby simp[HasOr.or]\n\n@[simp] lemma all_inj (p q : SubFormula L \u03bc (n + 1)) : \u2200' p = \u2200' q \u2194 p = q :=\n  by simp[HasUniv.univ]\n\n@[simp] lemma ex_inj (p q : SubFormula L \u03bc (n + 1)) : \u2203' p = \u2203' q \u2194 p = q :=\n  by simp[HasEx.ex]\n\nvariable (L)\n\nabbrev rel! (k) (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc n) := rel r v\n\nabbrev nrel! (k) (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc n) := nrel r v\n\nvariable {L}\n\ndef complexity : {n : \u2115} \u2192 SubFormula L \u03bc n \u2192 \u2115\n| _, \u22a4        => 0\n| _, \u22a5        => 0\n| _, rel _ _  => 0\n| _, nrel _ _ => 0\n| _, p \u22cf q    => max p.complexity q.complexity + 1\n| _, p \u22ce q    => max p.complexity q.complexity + 1\n| _, \u2200' p     => p.complexity + 1\n| _, \u2203' p     => p.complexity + 1\n\n@[simp] lemma complexity_top : complexity (\u22a4 : SubFormula L \u03bc n) = 0 := rfl\n\n@[simp] lemma complexity_bot : complexity (\u22a5 : SubFormula L \u03bc n) = 0 := rfl\n\n@[simp] lemma complexity_rel {k} (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc n) : complexity (rel r v) = 0 := rfl\n\n@[simp] lemma complexity_nrel {k} (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc n) : complexity (nrel r v) = 0 := rfl\n\n@[simp] lemma complexity_and (p q : SubFormula L \u03bc n) : complexity (p \u22cf q) = max p.complexity q.complexity + 1 := rfl\n@[simp] lemma complexity_and' (p q : SubFormula L \u03bc n) : complexity (and p q) = max p.complexity q.complexity + 1 := rfl\n\n@[simp] lemma complexity_or (p q : SubFormula L \u03bc n) : complexity (p \u22ce q) = max p.complexity q.complexity + 1 := rfl\n@[simp] lemma complexity_or' (p q : SubFormula L \u03bc n) : complexity (or p q) = max p.complexity q.complexity + 1 := rfl\n\n@[simp] lemma complexity_all (p : SubFormula L \u03bc (n + 1)) : complexity (\u2200' p) = p.complexity + 1 := rfl\n@[simp] lemma complexity_all' (p : SubFormula L \u03bc (n + 1)) : complexity (all p) = p.complexity + 1 := rfl\n\n@[simp] lemma complexity_ex (p : SubFormula L \u03bc (n + 1)) : complexity (\u2203' p) = p.complexity + 1 := rfl\n@[simp] lemma complexity_ex' (p : SubFormula L \u03bc (n + 1)) : complexity (ex p) = p.complexity + 1 := rfl\n\n@[elab_as_elim]\ndef cases' {C : \u2200 n, SubFormula L \u03bc n \u2192 Sort _}\n  (hverum  : \u2200 {n : \u2115}, C n \u22a4)\n  (hfalsum : \u2200 {n : \u2115}, C n \u22a5)\n  (hrel    : \u2200 {n l : \u2115} (r : L.rel l) (v : Fin l \u2192 SubTerm L \u03bc n), C n (rel r v))\n  (hnrel   : \u2200 {n l : \u2115} (r : L.rel l) (v : Fin l \u2192 SubTerm L \u03bc n), C n (nrel r v))\n  (hand    : \u2200 {n : \u2115} (p q : SubFormula L \u03bc n), C n (p \u22cf q))\n  (hor     : \u2200 {n : \u2115} (p q : SubFormula L \u03bc n), C n (p \u22ce q))\n  (hall    : \u2200 {n : \u2115} (p : SubFormula L \u03bc (n + 1)), C n (\u2200' p))\n  (hex     : \u2200 {n : \u2115} (p : SubFormula L \u03bc (n + 1)), C n (\u2203' p)) :\n    \u2200 {n : \u2115} (p : SubFormula L \u03bc 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 : \u2200 n, SubFormula L \u03bc n \u2192 Sort _}\n  (hverum  : \u2200 {n : \u2115}, C n \u22a4)\n  (hfalsum : \u2200 {n : \u2115}, C n \u22a5)\n  (hrel    : \u2200 {n l : \u2115} (r : L.rel l) (v : Fin l \u2192 SubTerm L \u03bc n), C n (rel r v))\n  (hnrel   : \u2200 {n l : \u2115} (r : L.rel l) (v : Fin l \u2192 SubTerm L \u03bc n), C n (nrel r v))\n  (hand    : \u2200 {n : \u2115} (p q : SubFormula L \u03bc n), C n p \u2192 C n q \u2192 C n (p \u22cf q))\n  (hor     : \u2200 {n : \u2115} (p q : SubFormula L \u03bc n), C n p \u2192 C n q \u2192 C n (p \u22ce q))\n  (hall    : \u2200 {n : \u2115} (p : SubFormula L \u03bc (n + 1)), C (n + 1) p \u2192 C n (\u2200' p))\n  (hex     : \u2200 {n : \u2115} (p : SubFormula L \u03bc (n + 1)), C (n + 1) p \u2192 C n (\u2203' p)) :\n    \u2200 {n : \u2115} (p : SubFormula L \u03bc 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 [\u2200 k, ToString (L.func k)] [\u2200 k, ToString (L.rel k)] [ToString \u03bc]\n\ndef toStr : \u2200 {n}, SubFormula L \u03bc n \u2192 String\n  | _, \u22a4                     => \"\\\\top\"\n  | _, \u22a5                     => \"\\\\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 \u22cf q                 => \"\\\\left(\" ++ toStr p ++ \" \\\\land \" ++ toStr q ++ \"\\\\right)\"\n  | _, p \u22ce 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 \u03bc n) := \u27e8fun t _ => toStr t\u27e9\n\ninstance : ToString (SubFormula L \u03bc n) := \u27e8toStr\u27e9\n\nend SubFormula\n\nnamespace SubFormula\nvariable {n n\u2081 n\u2082 n\u2083 m m\u2081 m\u2082 m\u2083 : \u2115}\n\n@[simp] lemma complexity_neg (p : SubFormula L \u03bc n) : complexity (~p) = complexity p :=\nby induction p using rec' <;> simp[*]\n\n@[reducible]\ndef bind' : \u2200 {n\u2081 n\u2082}, (bound : Fin n\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) \u2192 (free : \u03bc\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) \u2192\n    SubFormula L \u03bc\u2081 n\u2081 \u2192 SubFormula L \u03bc\u2082 n\u2082\n  | _, _, _,     _,    \u22a4          => \u22a4\n  | _, _, _,     _,    \u22a5          => \u22a5\n  | _, _, bound, free, (rel r v)  => rel r (SubTerm.bind bound free \u2218 v)\n  | _, _, bound, free, (nrel r v) => nrel r (SubTerm.bind bound free \u2218 v)\n  | _, _, bound, free, (p \u22cf q)    => bind' bound free p \u22cf bind' bound free q\n  | _, _, bound, free, (p \u22ce q)    => bind' bound free p \u22ce bind' bound free q\n  | _, _, bound, free, (\u2200' p)     => \u2200' bind' (Fin.cases #0 $ SubTerm.bShift \u2218 bound) (SubTerm.bShift \u2218 free) p\n  | _, _, bound, free, (\u2203' p)     => \u2203' bind' (Fin.cases #0 $ SubTerm.bShift \u2218 bound) (SubTerm.bShift \u2218 free) p\n\nlemma bind'_neg {n\u2081 n\u2082} (bound : Fin n\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) (free : \u03bc\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) (p) :\n    bind' bound free (~p) = ~bind' bound free p :=\n  by induction p using rec' generalizing n\u2082 <;> simp[*, bind', \u2190neg_eq]\n\ndef bind (bound : Fin n\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) (free : \u03bc\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) : SubFormula L \u03bc\u2081 n\u2081 \u2192L SubFormula L \u03bc\u2082 n\u2082 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, \u2190neg_eq, bind']\n\nabbrev bind\u2080 (f : \u03bc\u2081 \u2192 SubTerm L \u03bc\u2082 n) : SubFormula L \u03bc\u2081 n \u2192L SubFormula L \u03bc\u2082 n := bind SubTerm.bvar f\n\ndef map (bound : Fin n\u2081 \u2192 Fin n\u2082) (free : \u03bc\u2081 \u2192 \u03bc\u2082) : SubFormula L \u03bc\u2081 n\u2081 \u2192L SubFormula L \u03bc\u2082 n\u2082 :=\n  bind (fun n => #(bound n)) (fun m => &(free m))\n\nabbrev map\u2080 (free : \u03bc\u2081 \u2192 \u03bc\u2082) : SubFormula L \u03bc\u2081 n \u2192L SubFormula L \u03bc\u2082 n := map id free\n\ndef subst (t : SubTerm L \u03bc n) : SubFormula L \u03bc (n + 1) \u2192L SubFormula L \u03bc n :=\n  bind (SubTerm.bvar <: t) SubTerm.fvar\n\ndef emb : SubFormula L Empty n \u2192L SubFormula L \u03bc n := map id Empty.elim\n\nsection bind\nvariable (bound : Fin n\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) (free : \u03bc\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082)\n\nlemma bind_rel {k} (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc\u2081 n\u2081) :\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 \u2192 SubTerm L \u03bc\u2081 n\u2081) :\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 \u03bc\u2081 (n\u2081 + 1)) :\n    bind bound free (\u2200' p) = \u2200' bind (#0 :> SubTerm.bShift \u2218 bound) (SubTerm.bShift \u2218 free) p := rfl\n\n@[simp] lemma bind_ex (p : SubFormula L \u03bc\u2081 (n\u2081 + 1)) :\n    bind bound free (\u2203' p) = \u2203' bind (#0 :> SubTerm.bShift \u2218 bound) (SubTerm.bShift \u2218 free) p := rfl\n\n@[simp] lemma complexity_bind (p : SubFormula L \u03bc\u2081 n\u2081) : complexity (bind bound free p) = complexity p :=\n  by induction p using rec' generalizing \u03bc\u2082 n\u2082 <;> simp[*, bind_rel, bind_nrel]\n\n@[simp] lemma bind_id (p) : @bind L \u03bc \u03bc 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 \u2192 SubTerm L \u03bc n) (free : \u03bc \u2192 SubTerm L \u03bc n)\n    (hbound : \u2200 x, bound x = #x) (hfree : \u2200 x, free x = &x) (p : SubFormula L \u03bc 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\u2081 : Fin n\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) (free\u2081 : \u03bc\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082)\n  (bound\u2082 : Fin n\u2082 \u2192 SubTerm L \u03bc\u2083 n\u2083) (free\u2082 : \u03bc\u2082 \u2192 SubTerm L \u03bc\u2083 n\u2083) (p : SubFormula L \u03bc\u2081 n\u2081) :\n    bind bound\u2082 free\u2082 (bind bound\u2081 free\u2081 p) = bind (fun n => (bound\u2081 n).bind bound\u2082 free\u2082) (fun m => (free\u2081 m).bind bound\u2082 free\u2082) p := by\n  induction p using rec' generalizing n\u2082 n\u2083 <;> 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\u2081 : Fin n\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) (free\u2081 : \u03bc\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082)\n  (bound\u2082 : Fin n\u2082 \u2192 SubTerm L \u03bc\u2083 n\u2083) (free\u2082 : \u03bc\u2082 \u2192 SubTerm L \u03bc\u2083 n\u2083) :\n    (bind bound\u2082 free\u2082).comp (bind bound\u2081 free\u2081) = bind (fun n => (bound\u2081 n).bind bound\u2082 free\u2082) (fun m => (free\u2081 m).bind bound\u2082 free\u2082) :=\n  by ext p; simp[bind_bind]\n\nsection map\nvariable (bound : Fin n\u2081 \u2192 Fin n\u2082) (free : \u03bc\u2081 \u2192 \u03bc\u2082)\n\nlemma map_rel {k} (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc\u2081 n\u2081) :\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 \u2192 SubTerm L \u03bc\u2081 n\u2081) :\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 \u03bc\u2081 (n\u2081 + 1)) :\n    map bound free (\u2200' p) = \u2200' map (0 :> Fin.succ \u2218 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 \u03bc\u2081 (n\u2081 + 1)) :\n    map bound free (\u2203' p) = \u2203' map (0 :> Fin.succ \u2218 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 \u03bc\u2081 n\u2081) : complexity (map bound free p) = complexity p :=\n  complexity_bind _ _ _\n\nend map\n\nlemma map_map\n  (bound\u2081 : Fin n\u2081 \u2192 Fin n\u2082) (free\u2081 : \u03bc\u2081 \u2192 \u03bc\u2082)\n  (bound\u2082 : Fin n\u2082 \u2192 Fin n\u2083) (free\u2082 : \u03bc\u2082 \u2192 \u03bc\u2083) (p : SubFormula L \u03bc\u2081 n\u2081) :\n    map bound\u2082 free\u2082 (map bound\u2081 free\u2081 p) = map (bound\u2082 \u2218 bound\u2081) (free\u2082 \u2218 free\u2081) p :=\n  bind_bind _ _ _ _ _\n\n@[simp] lemma map_id (p) : @map L \u03bc \u03bc n n id id p = p :=\n  bind_id _\n\nlemma map_inj : \u2200 {n\u2081 n\u2082 \u03bc\u2081 \u03bc\u2082} {bound : Fin n\u2081 \u2192 Fin n\u2082} {free : \u03bc\u2081 \u2192 \u03bc\u2082},\n    (hb : Function.Injective bound) \u2192 (hf : Function.Injective free) \u2192 Function.Injective $ map (L := L) bound free\n  | _, _, _, _, _,     _,    _,  _,  \u22a4,        p => by cases p using cases' <;> simp[map_rel, map_nrel]\n  | _, _, _, _, _,     _,    _,  _,  \u22a5,        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 \u22cf q,    r => by\n    cases r using cases' <;> simp[map_rel, map_nrel]\n    intro hp hq; exact \u27e8map_inj hb hf hp, map_inj hb hf hq\u27e9\n  | _, _, _, _, _,     _,    hb, hf, p \u22ce q,    r => by\n    cases r using cases' <;> simp[map_rel, map_nrel]\n    intro hp hq; exact \u27e8map_inj hb hf hp, map_inj hb hf hq\u27e9\n  | _, _, _, _, bound, free, hb, hf, \u2200' p,     q => by\n    cases q using cases' <;> simp[map_rel, map_nrel]\n    intro h; exact map_inj (bound := 0 :> Fin.succ \u2218 bound)\n      (Matrix.injective_vecCons ((Fin.succ_injective _).comp hb) (fun _ => (Fin.succ_ne_zero _).symm)) hf h\n  | _, _, _, _, bound, free, hb, hf, \u2203' p,     q => by\n    cases q using cases' <;> simp[map_rel, map_nrel]\n    intro h; exact map_inj (bound := 0 :> Fin.succ \u2218 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 \u03bc n} {k} (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc (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 \u03bc n} {k} (r : L.rel k) (v : Fin k \u2192 SubTerm L \u03bc (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 \u03bc n} (p : SubFormula L \u03bc (n + 1 + 1)) :\n    subst s (\u2200' p) = \u2200' 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 \u03bc n} (p : SubFormula L \u03bc (n + 1 + 1)) :\n    subst s (\u2203' p) = \u2203' 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 \u2192 SubTerm L Empty n) :\n    emb (\u03bc := \u03bc) (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 \u2192 SubTerm L Empty n) :\n    emb (\u03bc := \u03bc) (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 (\u03bc := \u03bc) (\u2200' p) = \u2200' emb p :=\n  by simp[emb]\n\n@[simp] lemma emb_ex (p : SubFormula L Empty (n + 1)) :\n    emb (\u03bc := \u03bc) (\u2203' p) = \u2203' emb p :=\n  by simp[emb]\n\nsection Syntactic\n\ndef shift : SyntacticSubFormula L n \u2192L SyntacticSubFormula L n :=\n  map id Nat.succ\n\ndef free : SyntacticSubFormula L (n + 1) \u2192L SyntacticSubFormula L n :=\n  bind (SubTerm.bvar <: &0) (fun m => &(Nat.succ m))\n\ndef fix : SyntacticSubFormula L n \u2192L SyntacticSubFormula L (n + 1) :=\n  bind (fun x => #(Fin.castSucc x)) (#(Fin.last n) :>\u2099 SubTerm.fvar)\n\nlemma shift_rel {k} (r : L.rel k) (v : Fin k \u2192 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 \u2192 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 (\u2200' p) = \u2200' shift p  := by simp[shift]\n\n@[simp] lemma shift_ex (p : SyntacticSubFormula L (n + 1)) :\n    shift (\u2203' p) = \u2203' 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 \u21aa 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 \u2192 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 \u2192 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 (\u2200' p) = \u2200' 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 (\u2203' p) = \u2203' 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 \u2192 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 \u2192 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 (\u2200' p) = \u2200' fix p := by\n  simp[fix]; congr\n  \u00b7 exact funext (Fin.cases (by simp) (by simp[Fin.succ_castSucc])) \n  \u00b7 exact funext (Nat.rec (by simp) (by simp))\n\n@[simp] lemma fix_ex (p : SyntacticSubFormula L (n + 1)) :\n    fix (\u2203' p) = \u2203' fix p := by\n  simp[fix]; congr\n  \u00b7 exact funext (Fin.cases (by simp) (by simp[Fin.succ_castSucc])) \n  \u00b7 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 \u2192 Sort _}\n  (hverum  : C \u22a4)\n  (hfalsum : C \u22a5)\n  (hrel    : \u2200 {l : \u2115} (r : L.rel l) (v : Fin l \u2192 SyntacticTerm L), C (rel r v))\n  (hnrel   : \u2200 {l : \u2115} (r : L.rel l) (v : Fin l \u2192 SyntacticTerm L), C (nrel r v))\n  (hand    : \u2200 (p q : SyntacticFormula L), C p \u2192 C q \u2192 C (p \u22cf q))\n  (hor     : \u2200 (p q : SyntacticFormula L), C p \u2192 C q \u2192 C (p \u22ce q))\n  (hall    : \u2200 (p : SyntacticSubFormula L 1), C (free p) \u2192 C (\u2200' p))\n  (hex     : \u2200 (p : SyntacticSubFormula L 1), C (free p) \u2192 C (\u2203' p)) :\n    \u2200 (p : SyntacticFormula L), C p\n  | \u22a4        => hverum\n  | \u22a5        => hfalsum\n  | rel r v  => hrel r v\n  | nrel r v => hnrel r v\n  | p \u22cf 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 \u22ce 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  | \u2200' p     => hall p (formulaRec hverum hfalsum hrel hnrel hand hor hall hex (free p))\n  | \u2203' 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 : \u2115} \u2192 SubFormula L \u03bc n \u2192 List \u03bc\n  | _, \u22a4        => []\n  | _, \u22a5        => []\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 \u22cf q    => p.fvarList ++ q.fvarList\n  | _, p \u22ce q    => p.fvarList ++ q.fvarList\n  | _, \u2200' p     => p.fvarList\n  | _, \u2203' p     => p.fvarList\n\nabbrev fvar? (p : SubFormula L \u03bc n) (x : \u03bc) : Prop := x \u2208 p.fvarList\n\nlemma bind_eq_of_funEqOn (bound : Fin n\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) (free\u2081 free\u2082 : \u03bc\u2081 \u2192 SubTerm L \u03bc\u2082 n\u2082) (p : SubFormula L \u03bc\u2081 n\u2081)\n  (h : Function.funEqOn (fvar? p) free\u2081 free\u2082) :\n    bind bound free\u2081 p = bind bound free\u2082 p := by\n  induction p using rec' generalizing n\u2082 <;> 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 \u27e8i, hx\u27e9))\n  case hnrel =>\n    funext i\n    exact SubTerm.bind_eq_of_funEqOn _ _ _ _ (h.of_subset (by simp[fvarList]; intro x hx; exact \u27e8i, hx\u27e9))\n  case hand ihp ihq =>\n    exact \u27e8ihp _ _ _ (h.of_subset (fun x hx => Or.inl hx)), ihq _ _ _ (h.of_subset (fun x hx => Or.inr hx))\u27e9\n  case hor ihp ihq =>\n    exact \u27e8ihp _ _ _ (h.of_subset (fun x hx => Or.inl hx)), ihq _ _ _ (h.of_subset (fun x hx => Or.inr hx))\u27e9\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\u2081 bound\u2082 : Fin n \u2192 SubTerm L \u03bc n} {free\u2081 free\u2082 : \u03bc \u2192 SubTerm L \u03bc n} (p : SubFormula L \u03bc n)\n  (hbound : bound\u2081 = bound\u2082)\n  (hfree : Function.funEqOn (fvar? p) free\u2081 free\u2082) :\n    bind bound\u2081 free\u2081 p = bind bound\u2082 free\u2082 p := by\n  rw[hbound]; exact bind_eq_of_funEqOn _ _ _ _ hfree\n\nlemma ne_of_ne_complexity {p q : SubFormula L \u03bc n} (h : p.complexity \u2260 q.complexity) : p \u2260 q :=\n  by rintro rfl; contradiction\n\ndeclare_syntax_cat subformula\nsyntax \"\u22a4\" : subformula\nsyntax \"\u22a5\" : subformula\nsyntax:45 subterm:45 \"=\" subterm:0 : subformula\nsyntax:45 subterm:45 \"\u2260\" subterm:0 : subformula\nsyntax:45 subterm:45 \"<\" subterm:0 : subformula\nsyntax:45 \"prop\" term:max : subformula\nsyntax:45 \"rel\u00b9\" term \"/[\" subterm:0 \"]\" : subformula\nsyntax:45 \"rel\u00b2\" term \"/[\" subterm:0 \",\" subterm:0 \"]\" : subformula\nsyntax:45 \"rel\u00b3\" term \"/[\" subterm:0 \",\" subterm:0 \",\" subterm:0 \"]\" : subformula\nsyntax:max \"\u00ac\" subformula:35 : subformula\nsyntax:32 subformula:32 \"\u2227\" subformula:33 : subformula\nsyntax:30 subformula:30 \"\u2228\" subformula:31 : subformula\nsyntax:25 \"\u2200\" subformula:24 : subformula\nsyntax:25 \"\u2203\" subformula:24 : subformula\nsyntax:25 \"\u2200*\" subformula:24 : subformula\nsyntax \"(\" subformula \")\" : subformula\nsyntax:max \"!\" term:max : subformula\nsyntax \"\u201c\" subformula \"\u201d\" : term\n \nmacro_rules\n  | `(\u201c \u22a4 \u201d)                                          => `(\u22a4)\n  | `(\u201c \u22a5 \u201d)                                          => `(\u22a5)\n  | `(\u201c ! $t:term \u201d)                                  => `($t)\n  | `(\u201c prop $s:term \u201d)                               => `(rel $s ![])\n  | `(\u201c rel\u00b9 $s:term /[ $t:subterm ] \u201d)               => `(rel $s ![T\u201c$t\u201d])\n  | `(\u201c rel\u00b2 $s:term /[ $t\u2081:subterm, $t\u2082:subterm ] \u201d) => `(rel $s ![T\u201c$t\u2081\u201d, T\u201c$t\u2082\u201d])\n  | `(\u201c rel\u00b3 $s:term /[ $t\u2081:subterm, $t\u2082:subterm, $t\u2083:subterm ] \u201d) => `(rel $s ![T\u201c$t\u2081\u201d, T\u201c$t\u2082\u201d, T\u201c$t\u2083\u201d])\n  | `(\u201c \u00ac $p:subformula \u201d)                            => `(~\u201c$p\u201d)\n  | `(\u201c $t:subterm = $u:subterm \u201d)                    => `(rel Language.HasEq.eq ![T\u201c$t\u201d, T\u201c$u\u201d])\n  | `(\u201c $t:subterm \u2260 $u:subterm \u201d)                    => `(nrel Language.HasEq.eq ![T\u201c$t\u201d, T\u201c$u\u201d])\n  | `(\u201c $t:subterm < $u:subterm \u201d)                    => `(rel Language.HasLt.lt ![T\u201c$t\u201d, T\u201c$u\u201d])\n  | `(\u201c $p:subformula \u2227 $q:subformula \u201d)              => `(\u201c$p\u201d \u22cf \u201c$q\u201d)\n  | `(\u201c $p:subformula \u2228 $q:subformula \u201d)              => `(\u201c$p\u201d \u22ce \u201c$q\u201d)\n  | `(\u201c \u2200 $p:subformula \u201d)                            => `(\u2200' \u201c$p\u201d)\n  | `(\u201c \u2203 $p:subformula \u201d)                            => `(\u2203' \u201c$p\u201d)\n  | `(\u201c \u2200* $p:subformula \u201d)                           => `(univClosure \u201c$p\u201d)\n  | `(\u201c ( $x ) \u201d)                                     => `(\u201c$x\u201d)\n\n#check (\u201c\u00ac prop (Language.toRelational 1)\u201d : Formula (Language.relational (fun _ => \u2115)) \u2115)\n#check (\u201crel\u00b9 Language.toRelational 1 /[&0]\u201d : Formula (Language.relational (fun _ => \u2115)) \u2115)\n#check (\u201c\u00ac rel\u00b2 Language.toRelational 1 /[&0, &1]\u201d : Formula (Language.relational (fun _ => \u2115)) \u2115)\n#check (\u201c\u00ac(\u2200 \u2200 (#0 + 1) * #1 < #0 + #1 \u2228 0 < 5)\u201d : Sentence Language.oring)\n#check (\u201c\u2200* \u00ac\u22a4 \u2228 \u00ac0 < 5\u201d : Sentence Language.oring)\n\nsyntax:10 subformula:9 \"\u2192\" subformula:10 : subformula\nsyntax:10 subformula:10 \"\u2194\" subformula:10 : subformula\n\nmacro_rules\n  | `(\u201c $p:subformula \u2192 $q:subformula \u201d) => `(\u201c$p\u201d \u27f6 \u201c$q\u201d)\n  | `(\u201c $p:subformula \u2194 $q:subformula \u201d) => `(\u201c$p\u201d \u27f7 \u201c$q\u201d)\n\n#reduce (\u201c(\u2203 \u22a4) \u2194 !(\u2203' \u22a4)\u201d : Sentence Language.oring)\n#check (\u201c0 < 0 \u2192 0 < 1 \u2192 0 < 2\u201d : Sentence Language.oring)\n\nend SubFormula\n\nabbrev Theory (L : Language) (\u03bc) := Set (Formula L \u03bc)\n\nabbrev CTheory (L : Language) := Set (Sentence L)\n\nclass SubTheory (T U : CTheory L) where\n  sub : T \u2286 U\n\nnamespace SubTheory\n\nvariable {T U T\u2081 T\u2082 T\u2083 : CTheory L}\n\ninstance : SubTheory T T := \u27e8by rfl\u27e9\n\ndef trans [SubTheory T\u2081 T\u2082] [SubTheory T\u2082 T\u2083] : SubTheory T\u2081 T\u2083 := \u27e8subset_trans (sub (T := T\u2081) (U := T\u2082)) sub\u27e9\n\nend SubTheory\n\nnamespace SubFormula\n\nvariable {L : Language} [\u2200 k, DecidableEq (L.func k)] [\u2200 k, DecidableEq (L.rel k)] [DecidableEq \u03bc]\n\ndef hasDecEq : (p q : SubFormula L \u03bc n) \u2192 Decidable (p = q)\n  | \u22a4,        q => by cases q using cases' <;>\n      { simp; try { exact isFalse not_false }; try { exact isTrue trivial } }\n  | \u22a5,        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\u2081 k\u2082 r\u2082 v\u2082 =>\n        by_cases e : k\u2081 = k\u2082\n        \u00b7 rcases e with rfl\n          exact match decEq r r\u2082 with\n          | isTrue h  => by simp[h]; exact Matrix.decVec _ _ (fun i => decEq (v i) (v\u2082 i))\n          | isFalse h => isFalse (by simp[h])\n        \u00b7 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\u2081 k\u2082 r\u2082 v\u2082 =>\n        by_cases e : k\u2081 = k\u2082\n        \u00b7 rcases e with rfl\n          exact match decEq r r\u2082 with\n          | isTrue h  => by simp[h]; exact Matrix.decVec _ _ (fun i => decEq (v i) (v\u2082 i))\n          | isFalse h => isFalse (by simp[h])\n        \u00b7 exact isFalse (by simp[e])\n  | p \u22cf 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 \u25b8 hq \u25b8 rfl)\n          | isFalse hq => isFalse (by simp[hp, hq])\n        | isFalse hp => isFalse (by simp[hp])\n  | p \u22ce 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 \u25b8 hq \u25b8 rfl)\n          | isFalse hq => isFalse (by simp[hp, hq])\n        | isFalse hp => isFalse (by simp[hp])\n  | \u2200' p,     q => by\n      cases q using cases' <;> try { simp; exact isFalse not_false }\n      case hall p' => simp; exact hasDecEq p p'\n  | \u2203' 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 \u03bc 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 {\u03b1} [decidable_linear_order \u03b1] {a b : \u03b1} (h : a \u2265 b) : a = b \u2228 a > b :=\nhave h1 : \u00ac b > a, from not_lt_of_ge h,\neq_or_lt_of_not_lt h1\n\ntheorem eq_or_lt_of_le {\u03b1} [decidable_linear_order \u03b1] {a b : \u03b1} (h : a \u2264 b) : a = b \u2228 a < b :=\nhave h1 : \u00ac b < a, from not_lt_of_ge h,\nhave h2 : b = a \u2228 a < b, from eq_or_lt_of_not_lt h1,\nh2.elim (\u03bb e, or.inl (e.symm)) or.inr\n\ntheorem le_of_eq_or_lt {\u03b1} [decidable_linear_order \u03b1] {a b : \u03b1} (h : a = b \u2228 a < b) : a \u2264 b :=\nh.elim (\u03bb e, by rw e; reflexivity) le_of_lt\n\ntheorem ge_of_eq_or_gt {\u03b1} [decidable_linear_order \u03b1] {a b : \u03b1} (h : a = b \u2228 a > b) : a \u2265 b :=\nh.elim (\u03bb e, by rw e; change b \u2264 b; reflexivity) le_of_lt\n\nclass comp_op (op : \u211a \u2192 \u211a \u2192 Prop) :=\n(rev_op : \u211a \u2192 \u211a \u2192 Prop)\n(rev_op_is_rev : \u2200 {x y}, rev_op y x \u2194 op x y)\n(rel_of_sub_rel_zero : \u2200 {x y : \u211a}, op (x-y) 0 \u2194 op x y)\n(op_mul : \u2200 {x y c : \u211a}, c > 0 \u2192 op x y \u2192 op (c*x) (c*y))\n(op_inv : \u2200 {x y z : \u211a}, x > 0 \u2192 op z (x*y) \u2192 op ((rat.pow x (-1))*z) y)\n\nclass weak_comp_op (op) extends comp_op op :=\n(strict_op : \u211a \u2192 \u211a \u2192 Prop)\n(disj : \u2200 {x y}, op x y \u2194 x = y \u2228 strict_op x y)\n(ne_of_str : \u2200 {x y}, strict_op x y \u2192 x \u2260 y)\n\ninstance colt : comp_op (@has_lt.lt \u211a _) :=\n{rev_op := @gt \u211a _,\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 [\u2190mul_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 \u211a _) :=\n{rev_op := @ge \u211a _,\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 \u211a _,\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 \u211a _,\n op_inv := begin intros, fapply le_of_mul_le_mul_left, exact x, rw [\u2190mul_assoc, rat.mul_pow_neg_one, one_mul], assumption, apply ne_of_gt, assumption, assumption end}\n\ninstance cogt : comp_op (@gt \u211a _) :=\n{rev_op := @has_lt.lt \u211a _,\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 [\u2190mul_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 \u211a _) :=\n{rev_op := @has_le.le \u211a _,\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 \u211a _,\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 \u211a _,\n op_inv := begin intros, fapply le_of_mul_le_mul_left, exact x, rw [\u2190mul_assoc, rat.mul_pow_neg_one, one_mul], assumption, apply ne_of_gt, assumption, assumption end}\n\ninstance coeq : comp_op (@eq \u211a) :=\n{rev_op := @eq \u211a,\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 [\u2190mul_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 \u2194 o x y := comp_op.rev_op_is_rev _ \n\nlemma op_mul_neg {o}  {x y c : \u211a} [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, \u2190neg_mul_eq_neg_mul, \u2190neg_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 : \u211a) < 0 :=\nbegin\napply neg_of_neg_pos, -- fails\n--apply (@neg_of_neg_pos \u211a _), -- succeeds\n--refine neg_of_neg_pos _, -- succeeds\nend\n\nexample : (-1 : \u2124) < 0 :=\nbegin\napply neg_of_neg_pos, -- succeeds\nend\n-/\n\nlemma op_neg {o} {x y : \u211a} [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 : \u211a} (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 [\u2190mul_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 : \u211a} (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 [\u2190mul_assoc, one_div_mul_cancel (ne_of_lt hc), one_mul] at h'; assumption\n\ntheorem diseq_sym {lhs rhs c : \u211a} (hc : c \u2260 0) (h : lhs \u2260 c*rhs) : rhs \u2260 (1/c) * lhs := \nsorry\n\ntheorem eq_sym {lhs rhs c : \u211a} (hc : c \u2260 0) (h : lhs = c*rhs) : rhs = (1/c) * lhs :=\nsorry\n\n/-section ineq_sym\nvariables {lhs rhs c : \u211a}\ntheorem ineq_sym_le_pos (hc : c > 0) (h : lhs \u2264 c*rhs) : rhs \u2265 (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 \u2265 c*rhs) : rhs \u2264 (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 \u2264 c*rhs) : rhs \u2264 (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 \u2265 c*rhs) : rhs \u2265 (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 \u2192 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 \u2192 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 : \u211a) (cmp : comp) : name :=\nif c \u2265 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 : \u211a} (hc : lhs \u2260 c*rhs) (h : lhs \u2264 c*rhs) : lhs < c*rhs :=\nor.elim (lt_or_eq_of_le h) (id) (\u03bb hp, absurd hp hc)\n\ntheorem ineq_diseq_ge {lhs rhs c : \u211a} (hc : lhs \u2260 c*rhs) (h : lhs \u2265 c*rhs) : lhs > c*rhs :=\nor.elim (lt_or_eq_of_le h) (id) (\u03bb hp, absurd (eq.symm hp) hc)-/\n\ntheorem ineq_diseq {lhs rhs c : \u211a} {o} [weak_comp_op o] (hc : lhs \u2260 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) (\u03bb t, absurd t hc) id\n\n/-theorem ineq_diseq_sign_lhs_le {lhs rhs : \u211a} (hc : lhs \u2260 0) (h : lhs \u2264 0*rhs) : lhs < 0*rhs :=\nsorry\n\ntheorem ineq_diseq_sign_lhs_ge {lhs rhs : \u211a} (hc : lhs \u2260 0) (h : lhs \u2265 0*rhs) : lhs > 0*rhs :=\nsorry-/\n\ntheorem ineq_diseq_sign_lhs {lhs rhs : \u211a} (hc : lhs \u2260 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 : \u211a} (hc : rhs \u2260 0) (h : rhs \u2264 0) : rhs < 0 :=\nsorry\n\ntheorem ineq_diseq_sign_rhs_ge {rhs : \u211a} (hc : rhs \u2260 0) (h : rhs \u2265 0) : rhs > 0 :=\nsorry-/\n\ntheorem ineq_diseq_sign_rhs {rhs : \u211a} (hc : rhs \u2260 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 : \u211a} (h1 : lhs \u2264 c*rhs) (h2 : lhs \u2265 c*rhs) : lhs = c*rhs :=\nhave h : lhs = c*rhs \u2228 lhs < c*rhs, from eq_or_lt_of_le h1,\nh.elim id (\u03bb e, absurd h2 (not_le_of_gt e))\n\ntheorem op_zero_of_zero_op_neg_mul {o} [comp_op o] {c q : \u211a} (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 [\u2190mul_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 : \u211a} (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 [\u2190mul_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 : \u211a} (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 [\u2190mul_assoc, one_div_mul_cancel, one_mul]; apply ne_of_gt h,\nby rw [hc', mul_zero] at h'; assumption\n\nsection\nvariables {lhs : \u211a} (rhs : \u211a)\n/-theorem zero_mul_le (h : lhs \u2264 0) : lhs \u2264 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 \u2265 0) : lhs \u2265 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 \u2192 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 \u2264 0*rhs) : lhs \u2264 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 \u2265 0*rhs) : lhs \u2265 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 \u2190(zero_mul rhs); assumption\n\n\n/-meta def zero_mul'_name_of_comp : comp \u2192 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 : \u211a} (h : lhs = 0*rhs) : lhs = 0 :=\nby rw \u2190(zero_mul rhs); assumption\n\ntheorem ne_zero_of_ne_mul_zero {lhs rhs : \u211a} (h : lhs \u2260 0*rhs) : lhs \u2260 0 :=\nby rw \u2190(zero_mul rhs); assumption\n\ntheorem eq_zero_of_two_eqs_rhs {lhs rhs c1 c2 : \u211a} (h : lhs = c1*rhs) (h2 : lhs = c2*rhs) (hc : c1 \u2260 c2) : rhs = 0 :=\nbegin\n rw h at h2,\n have h3 := sub_eq_zero_of_eq h2,\n rw \u2190sub_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 : \u211a} (h : lhs = c1*rhs) (h2 : lhs = c2*rhs) (hc : c1 \u2260 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 : \u211a} (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 : \u211a} \n--include h\n\n/- there are 16 possibilities here!\ntheorem sub_le_zero_of_le {a b : \u211a} (h : a \u2264 b) : a - b \u2264 0 := sorry\ntheorem sub_lt_zero_of_lt {a b : \u211a} (h : a < b) : a - b < 0 := sorry\ntheorem sub_ge_zero_of_ge {a b : \u211a} (h : a \u2265 b) : a - b \u2265 0 := sorry\ntheorem sub_gt_zero_of_gt {a b : \u211a} (h : a > b) : a - b > 0 := sorry-/\n\ntheorem sub_op_zero_of_op {a b : \u211a} {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 \u2190h; 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, \u2190mul_assoc, div_mul_cancel _ (ne_of_gt h2), one_mul] at cmp,\nassumption\nend\n\n/-theorem le_gt_rhs (h1 : lhs \u2264 c*rhs) (h2 : d - c > 0) : rhs \u2264 0 :=\nhave d*rhs \u2264 c*rhs, by rw -h; assumption,\nhave d*rhs - c*rhs \u2264 0, from sub_le_zero_of_le this,\nhave (d - c)*rhs \u2264 0, by rw sub_mul; assumption,\nshow rhs \u2264 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 \u2265 c*rhs) (h2 : d - c > 0) : rhs \u2265 0 :=\nhave d*rhs \u2265 c*rhs, by rw -h; assumption,\nhave d*rhs - c*rhs \u2265 0, from sub_ge_zero_of_ge this,\nhave (d - c)*rhs \u2265 0, by rw sub_mul; assumption,\nshow rhs \u2265 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 \u2264 c*rhs) : 1*lhs + (-c)*rhs \u2264 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, \u2190neg_mul_eq_neg_mul, one_mul],\n exact sub_neg_of_lt h1\nend\n\ntheorem sub_le_of_ge (h1 : lhs \u2265 c*rhs) : (-1)*lhs + c*rhs \u2264 0 :=\nbegin\n rw [add_comm, \u2190neg_mul_eq_neg_mul, one_mul],\n exact sub_nonpos_of_le h1\nend\n\ntheorem mul_lt_of_gt {rhs : \u211a} (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 : \u211a} (h1 : lhs \u2265 0*rhs) : (-1)*lhs \u2264 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 : \u211a} (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 : \u211a} (h1 : lhs \u2264 0*rhs) : 1*lhs \u2264 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 \u2192 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 \u2192 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 : \u211a} (h : e > 1*e) : false :=\nbegin apply lt_irrefl e, rw one_mul at h, assumption end\n\ntheorem lt_self_contr {e : \u211a} (h : e < 1*e) : false :=\nbegin apply lt_irrefl e, rw one_mul at h, assumption end\n\ntheorem le_gt_contr {e : \u211a} (h1 : e \u2264 0) (h2 : e > 0) : false :=\nnot_le_of_gt h2 h1\n\ntheorem ge_lt_contr {e : \u211a} (h1 : e \u2265 0) (h2 : e < 0) : false :=\nnot_le_of_gt h2 h1\n\ntheorem gt_lt_contr {e : \u211a} (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 : \u211a} (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 [\u2190mul_assoc, one_div_mul_cancel (ne_of_gt h2), one_mul, neg_mul_eq_neg_mul, \u2190mul_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 : \u211a} (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 [\u2190mul_assoc, \u2190neg_mul_eq_neg_mul, one_div_mul_cancel (ne_of_lt h2), \u2190neg_mul_eq_neg_mul, one_mul, neg_mul_neg, \u2190mul_assoc, div_mul_eq_mul_div, one_mul ] at np,\nrw [\u2190(neg_neg lhs), neg_div, \u2190neg_mul_eq_neg_mul],\napply op_neg,\nassumption\nend\n\ntheorem rev_op_zero_of_op {o} [comp_op o] {e : \u211a} (h : o e 0) : rev o (-e) 0 :=\nsuffices rev o (-e) (-0), by rw \u2190neg_zero; assumption,\nbegin\nrw [neg_eq_neg_one_mul, neg_eq_neg_one_mul (0 : \u211a)],\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 : \u211a \u2192 \u211a \u2192 Prop) :=\n(oood : \u2200 {x}, 0 < x \u2192 o x 1 \u2192 o 1 (rat.pow x (-1)))\n\ninstance ooodlt : one_op_one_div_class (@has_lt.lt rat _) :=\n\u27e8begin intro, rw rat.pow_neg_one, apply one_lt_one_div end\u27e9\n\ninstance ooodle : one_op_one_div_class (@has_le.le rat _) :=\n\u27e8begin intro, rw rat.pow_neg_one, apply one_le_one_div end\u27e9\n\ninstance ooodgt : one_op_one_div_class (@gt rat _) :=\n\u27e8begin 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\u27e9\n\ninstance ooodge : one_op_one_div_class (@ge rat _) :=\n\u27e8begin intros, rw rat.pow_neg_one, change 1/1 \u2265 1/x, apply one_div_le_one_div_of_le, apply zero_lt_one, assumption end\u27e9\n\n\ninstance {o} [comp_op o] [one_op_one_div_class o] : one_op_one_div_class (rev o) :=\n\u27e8begin\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\u27e9\n\ndef one_op_one_div {o : \u211a \u2192 \u211a \u2192 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 : \u211a} (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, \u2190 inv_eq_one_div] at \u22a2 this,\n  rw [rat.pow_one],\n  rw [inv_mul_cancel (ne_of_gt hp)] at this,\n  rw [mul_comm lhs\u207b\u00b9, \u2190 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 : \u211a} (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, \u2190 inv_eq_one_div] at \u22a2 this,\n  rw [rat.pow_one],\n  rw [inv_mul_cancel (ne_of_lt hp)] at this,\n  rw [mul_comm lhs\u207b\u00b9, \u2190 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 : \u211a} {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 \u22a2 this; rw [\u2190one_div_mul_one_div, \u2190one_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 : \u211a} {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 : \u211a} (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 : \u211a} (h : 1 \u2265 (c*((1/lhs)*rhs))) \n        (hl : lhs > 0) (hr : rhs > 0) (hc : c > 0) : 1 \u2264 ((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 \u2264 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 : \u211a} {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 \u22a2; rw [\u2190one_div_mul_one_div, \u2190one_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 : \u211a} (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 : \u211a} (h : 1 \u2265 (c*((1/lhs)*rhs))) \n        (hl : lhs > 0) (hr : rhs < 0) (hc : c < 0) : 1 \u2264 ((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 \u2264 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 : \u211a} {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 \u22a2 this; rw [\u2190one_div_mul_one_div, \u2190one_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 : \u211a} {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 \u22a2 this; rw [\u2190one_div_mul_one_div, \u2190one_div_mul_one_div, one_div_one_div] at this; assumption\n\n\ntheorem one_eq_div_of_eq {lhs rhs c : \u211a} (h : lhs = c*rhs) (hl : lhs \u2260 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 : \u211a} (h : 1 < a) : \u03a0 (n : \u2115), 1 < rat.pow a (int.of_nat (n+1))\n| 0 := by simp [*, rat.pow]\n| (k+1) := begin simp [*, rat.pow], rw \u2190(mul_one (1:\u211a)), 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 : \u211a} (h : 1 \u2264 a) : \u03a0 (n : \u2115), 1 \u2264 rat.pow a (int.of_nat (n+1))\n| 0 := by simp [*, rat.pow]\n| (k+1) := begin simp [*, rat.pow], rw \u2190(mul_one (1:\u211a)), 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 : \u211a} (h : 1 < a) : \u03a0 {z : \u2124} (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 : \u211a} (h : 1 \u2264 a) : \u03a0 {z : \u2124} (hz : z > 0), 1 \u2264 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 : \u211a} (h : 1 = a) (z : \u2124) : 1 = rat.pow a z :=\nhave rat.pow 1 z = 1, from rat.one_pow _,\nby cc\n\ntheorem eq_pow' {a b : \u211a} {z : \u2124} (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 : \u211a} (h : strict_op o a 0) : a \u2260 0 :=\nweak_comp_op.ne_of_str h\n\n/-theorem op_inv_n {o} [comp_op o] {x y z : \u211a} {p : \u2124} (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 : \u211a} (hlhs : lhs > 0) {el er : \u2124} (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 : \u211a} (hlhs : lhs < 0) {el er : \u2124} (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 : \u211a} (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 : \u211a} (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 : \u211a} (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 : \u211a} (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 : \u211a} (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 : \u211a} (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\u2081 w\u2082\n\nvariables (R : Type u) (L : Type v) (M : Type w) {L' : Type w\u2081}\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' \u2192\u2097\u2045R\u2046 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 : \u2115) : lie_ideal R L \u2192 lie_ideal R L := (\u03bb I, \u2045I, I\u2046)^[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 : \u2115) :\n  derived_series_of_ideal R L (k + 1) I =\n  \u2045derived_series_of_ideal R L k I, derived_series_of_ideal R L k I\u2046 :=\nfunction.iterate_succ_apply' (\u03bb I, \u2045I, I\u2046) k I\n\n/-- The derived series of Lie ideals of a Lie algebra. -/\nabbreviation derived_series (k : \u2115) : lie_ideal R L := derived_series_of_ideal R L k \u22a4\n\nlemma derived_series_def (k : \u2115) :\n  derived_series R L k = derived_series_of_ideal R L k \u22a4 := rfl\n\nvariables {R L}\n\nlocal notation `D` := derived_series_of_ideal R L\n\nlemma derived_series_of_ideal_add (k l : \u2115) : 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 : \u2115} (h\u2081 : I \u2264 J) (h\u2082 : l \u2264 k) :\n  D k I \u2264 D l J :=\nbegin\n  revert l, induction k with k ih; intros l h\u2082,\n  { rw le_zero_iff at h\u2082, rw [h\u2082, derived_series_of_ideal_zero], exact h\u2081, },\n  { have h : l = k.succ \u2228 l \u2264 k, by rwa [le_iff_eq_or_lt, nat.lt_succ_iff] at h\u2082,\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 : \u2115) : D (k + 1) I \u2264 D k I :=\nderived_series_of_ideal_le (le_refl I) k.le_succ\n\nlemma derived_series_of_ideal_le_self (k : \u2115) : D k I \u2264 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 \u2264 J) (k : \u2115) : D k I \u2264 D k J :=\nderived_series_of_ideal_le h (le_refl k)\n\nlemma derived_series_of_ideal_antitone {k l : \u2115} (h : l \u2264 k) : D k I \u2264 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 : \u2115) :\n  D (k + l) (I + J) \u2264 (D k I) + (D l J) :=\nbegin\n  let D\u2081 : lie_ideal R L \u2192o lie_ideal R L :=\n  { to_fun    := \u03bb I, \u2045I, I\u2046,\n    monotone' := \u03bb I J h, lie_submodule.mono_lie I J I J h h, },\n  have h\u2081 : \u2200 (I J : lie_ideal R L), D\u2081 (I \u2294 J) \u2264 (D\u2081 I) \u2294 J,\n  { simp [lie_submodule.lie_le_right, lie_submodule.lie_le_left, le_sup_of_le_right], },\n  rw \u2190 D\u2081.iterate_sup_le_sup_iff at h\u2081,\n  exact h\u2081 k l I J,\nend\n\nlemma derived_series_of_bot_eq_bot (k : \u2115) : derived_series_of_ideal R L k \u22a5 = \u22a5 :=\nby { rw eq_bot_iff, exact derived_series_of_ideal_le_self \u22a5 k, }\n\nlemma abelian_iff_derived_one_eq_bot : is_lie_abelian I \u2194 derived_series_of_ideal R L 1 I = \u22a5 :=\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 : \u2115) :\n  is_lie_abelian (derived_series_of_ideal R L k I) \u2194 derived_series_of_ideal R L (k + 1) I = \u22a5 :=\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 : \u2115) :\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 \u22a2 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 : \u2115) :\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 : \u2115) :\n  derived_series R I k = \u22a5 \u2194 derived_series_of_ideal R L k I = \u22a5 :=\nby rw [\u2190 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 : \u2115} {I J : lie_ideal R L}\n  (hI : derived_series R I k = \u22a5) (hJ : derived_series R J l = \u22a5) :\n  derived_series R \u21a5(I + J) (k + l) = \u22a5 :=\nbegin\n  rw lie_ideal.derived_series_eq_bot_iff at hI hJ \u22a2,\n  rw \u2190 le_bot_iff,\n  let D := derived_series_of_ideal R L, change D k I = \u22a5 at hI, change D l J = \u22a5 at hJ,\n  calc D (k + l) (I + J) \u2264 (D k I) + (D l J) : derived_series_of_ideal_add_le_add I J k l\n                     ... \u2264 \u22a5 : by { rw [hI, hJ], simp, },\nend\n\nlemma derived_series_map_le (k : \u2115) :\n  (derived_series R L' k).map f \u2264 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 \u22a2,\n    exact le_trans (map_bracket_le f) (lie_submodule.mono_lie _ _ _ _ ih ih), },\nend\n\nlemma derived_series_map_eq (k : \u2115) (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 (\u22a4 : lie_ideal R L').map f = \u22a4,\n    rw \u2190f.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 : \u2203 k, derived_series R L k = \u22a5)\n\ninstance is_solvable_bot : is_solvable R \u21a5(\u22a5 : lie_ideal R L) :=\n\u27e8\u27e80, subsingleton.elim _ \u22a5\u27e9\u27e9\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 \u21a5(I + J) :=\nbegin\n  obtain \u27e8k, hk\u27e9 := id hI, obtain \u27e8l, hl\u27e9 := id hJ,\n  exact \u27e8\u27e8k+l, lie_ideal.derived_series_add_eq_bot hk hl\u27e9\u27e9,\nend\n\nend lie_algebra\n\nvariables {R L}\n\nnamespace function\n\nopen lie_algebra\n\nlemma injective.lie_algebra_is_solvable [h\u2081 : is_solvable R L] (h\u2082 : injective f) :\n  is_solvable R L' :=\nbegin\n  obtain \u27e8k, hk\u27e9 := id h\u2081,\n  use k,\n  apply lie_ideal.bot_of_map_eq_bot h\u2082, rw [eq_bot_iff, \u2190 hk],\n  apply lie_ideal.derived_series_map_le,\nend\n\nlemma surjective.lie_algebra_is_solvable [h\u2081 : is_solvable R L'] (h\u2082 : surjective f) :\n  is_solvable R L :=\nbegin\n  obtain \u27e8k, hk\u27e9 := id h\u2081,\n  use k,\n  rw [\u2190 lie_ideal.derived_series_map_eq k h\u2082, 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' \u2192\u2097\u2045R\u2046 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' \u2243\u2097\u2045R\u2046 L) : is_solvable R L' \u2194 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\u2081 : I \u2264 J) (h\u2082 : is_solvable R J) :\n  is_solvable R I :=\n(lie_ideal.hom_of_le_injective h\u2081).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 [\u2190 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 \u2190 complete_lattice.is_sup_closed_compact_iff_well_founded at hwf,\n  refine hwf { I : lie_ideal R L | is_solvable R I } \u27e8\u22a5, _\u27e9 (\u03bb 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 `\u2192` 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 \u2194 I \u2264 radical R L :=\n\u27e8\u03bb h, le_Sup h, \u03bb h, le_solvable_ideal_solvable h infer_instance\u27e9\n\nlemma center_le_radical : center R L \u2264 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\u2080 \u2265 D\u2081 \u2265 \u22ef \u2265 D\u2096 = \u22a5`, 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) : \u2115 :=\nInf {k | derived_series_of_ideal R L k I = \u22a5}\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 : \u2115 := derived_length_of_ideal R L \u22a4\n\nlemma derived_series_of_derived_length_succ (I : lie_ideal R L) (k : \u2115) :\n  derived_length_of_ideal R L I = k + 1 \u2194\n  is_lie_abelian (derived_series_of_ideal R L k I) \u2227 derived_series_of_ideal R L k I \u2260 \u22a5 :=\nbegin\n  rw abelian_iff_derived_succ_eq_bot,\n  let s := {k | derived_series_of_ideal R L k I = \u22a5}, change Inf s = k + 1 \u2194 k + 1 \u2208 s \u2227 k \u2209 s,\n  have hs : \u2200 (k\u2081 k\u2082 : \u2115), k\u2081 \u2264 k\u2082 \u2192 k\u2081 \u2208 s \u2192 k\u2082 \u2208 s,\n  { intros k\u2081 k\u2082 h\u2081\u2082 h\u2081,\n    suffices : derived_series_of_ideal R L k\u2082 I \u2264 \u22a5, { exact eq_bot_iff.mpr this, },\n    change derived_series_of_ideal R L k\u2081 I = \u22a5 at h\u2081, rw \u2190 h\u2081,\n    exact derived_series_of_ideal_antitone I h\u2081\u2082, },\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\u2081 := {k | derived_series R I k = \u22a5},\n  let s\u2082 := {k | derived_series_of_ideal R L k I = \u22a5},\n  change Inf s\u2081 = Inf s\u2082,\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\u2080 \u2265 D\u2081 \u2265 \u22ef \u2265 D\u2096 = \u22a5`, 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, `\u22a5`. -/\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     := \u22a5\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 \u2194 I = \u22a5 :=\nbegin\n  let s := {k | derived_series_of_ideal R L k I = \u22a5}, change Inf s = 0 \u2194 _,\n  have hne : s \u2260 \u2205,\n  { obtain \u27e8k, hk\u27e9 := id hI,\n    refine set.nonempty.ne_empty \u27e8k, _\u27e9,\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 = \u22a5 \u2194 I = \u22a5 :=\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 \u27e8h\u2081, h\u2082\u27e9 := (derived_series_of_derived_length_succ R L I k).mp h,\n    have h\u2083 : I \u2260 \u22a5, { intros contra, apply h\u2082, rw contra, apply derived_series_of_bot_eq_bot, },\n    change derived_series_of_ideal R L k I = \u22a5 \u2194 I = \u22a5,\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' : \u2200 (c : R) {x : M}, x \u2208 carrier \u2192 c \u2022 x \u2208 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 \u2208 \u2191p\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 \u2208 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 \u2205 sorry)\n\nprotected instance inhabited {R : Type u} {M : Type v} [has_scalar R M] : Inhabited (sub_mul_action R M) :=\n  { default := \u22a5 }\n\n@[simp] theorem coe_sort_coe {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) : \u21a5\u2191p = \u21a5p :=\n  rfl\n\nprotected theorem exists {R : Type u} {M : Type v} [has_scalar R M] {p : sub_mul_action R M} {q : \u21a5p \u2192 Prop} : (\u2203 (x : \u21a5p), q x) \u2194 \u2203 (x : M), \u2203 (H : x \u2208 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 : \u21a5p \u2192 Prop} : (\u2200 (x : \u21a5p), q x) \u2194 \u2200 (x : M) (H : x \u2208 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} : \u2191p = \u2191q \u2194 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 \u2194 \u2191p = \u2191q :=\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 : \u2200 (x : M), x \u2208 p \u2194 x \u2208 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 \u2208 \u2191p \u2194 x \u2208 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 \u2208 p) : r \u2022 x \u2208 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 \u21a5p :=\n  has_scalar.mk fun (c : R) (x : \u21a5p) => { val := c \u2022 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 : \u21a5p} {y : \u21a5p} : \u2191x = \u2191y \u2194 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 : \u21a5p) : \u2191(r \u2022 x) = r \u2022 \u2191x :=\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 \u2208 p) : \u2191{ 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 : \u21a5p) : \u2191x \u2208 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 : \u21a5p) (hx : \u2191x \u2208 p) : { val := \u2191x, 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 (\u21a5p) 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 : \u21a5p) : coe_fn (sub_mul_action.subtype p) x = \u2191x :=\n  rfl\n\ntheorem subtype_eq_val {R : Type u} {M : Type v} [has_scalar R M] (p : sub_mul_action R M) : \u21d1(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) : \u2191u \u2022 x \u2208 p \u2194 x \u2208 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 \u21a5p :=\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 \u2191p) : 0 \u2208 p := sorry\n\n/-- If the scalar product forms a `semimodule`, and the `sub_mul_action` is not `\u22a5`, 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 \u21a5p] : HasZero \u21a5p :=\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 \u2208 p) : -x \u2208 p :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (-x \u2208 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 \u2208 p \u2194 x \u2208 p :=\n  { mp := fun (h : -x \u2208 p) => eq.mpr (id (Eq._oldrec (Eq.refl (x \u2208 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 \u21a5p :=\n  { neg := fun (x : \u21a5p) => { 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 : \u21a5p) : \u2191(-x) = -\u2191x :=\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 \u2260 0) : r \u2022 x \u2208 p \u2194 x \u2208 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 \u27f6 Y)\n  (hf : function.surjective f) (e : P.val.to_CompHaus \u27f6 Y) :\n  \u2203 g : P.val.to_CompHaus \u27f6 X, g \u226b 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 \u03c0 : B \u27f6 P.val := \u27e8_, continuous_ultrafilter_extend id\u27e9,\n  have : epi \u03c0,\n  { rw Profinite.epi_iff_surjective,\n    intro x, refine \u27e8(pure x : ultrafilter P.val), _\u27e9,\n    have := @ultrafilter_extend_extends P.val _ _ _ id,\n    exact congr_fun this x, },\n  resetI,\n  choose s hs using projective.factors (\ud835\udfd9 _) \u03c0,\n  let \u03c6 : CompHaus.of (ultrafilter P.val.to_CompHaus) \u27f6 Y := \u03c0 \u226b e,\n  choose g h using projective.factors \u03c6 f,\n  refine \u27e8s \u226b g, _\u27e9,\n  erw [category.assoc, h, \u2190 category.assoc, hs, category.id_comp],\nend\n\ndef lift' {X Y : CompHaus} {P : ExtrDisc} (f : X \u27f6 Y)\n  (hf : function.surjective f) (e : P.val.to_CompHaus \u27f6 Y) : P.val.to_CompHaus \u27f6 X :=\n(lift_exists' f hf e).some\n\n@[simp, reassoc]\nlemma lift_lifts' {X Y : CompHaus} {P : ExtrDisc} (f : X \u27f6 Y)\n  (hf : function.surjective f) (e : P.val.to_CompHaus \u27f6 Y) :\n  lift' f hf e \u226b 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 \u2192 !p || r \u2192 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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 `\u03b1` and a term of `\u03b3` if there is an intermediate\nterm of `\u03b2` related to both.\n-/\ndef comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) (p : \u03b2 \u2192 \u03b3 \u2192 Prop) (a : \u03b1)\n    (c : \u03b3) :=\n  \u2203 (b : \u03b2), r a b \u2227 p b c\n\ntheorem comp_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} : comp r Eq = r := sorry\n\ntheorem eq_comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} : comp Eq r = r := sorry\n\ntheorem iff_comp {\u03b1 : Type u_1} {r : Prop \u2192 \u03b1 \u2192 Prop} : comp Iff r = r := sorry\n\ntheorem comp_iff {\u03b1 : Type u_1} {r : \u03b1 \u2192 Prop \u2192 Prop} : comp r Iff = r := sorry\n\ntheorem comp_assoc {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} {r : \u03b1 \u2192 \u03b2 \u2192 Prop}\n    {p : \u03b2 \u2192 \u03b3 \u2192 Prop} {q : \u03b3 \u2192 \u03b4 \u2192 Prop} : comp (comp r p) q = comp r (comp p q) :=\n  sorry\n\ntheorem flip_comp {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {r : \u03b1 \u2192 \u03b2 \u2192 Prop}\n    {p : \u03b2 \u2192 \u03b3 \u2192 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {\u03b4 : Type u_4} (r : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) : \u03b3 \u2192 \u03b4 \u2192 Prop :=\n  fun (c : \u03b3) (d : \u03b4) => \u2203 (a : \u03b1), \u2203 (b : \u03b2), r a b \u2227 f a = c \u2227 g b = d\n\n/-- `refl_trans_gen r`: reflexive transitive closure of `r` -/\ninductive refl_trans_gen {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : \u03b1 \u2192 Prop where\n| refl : refl_trans_gen r a a\n| tail : \u2200 {b c : \u03b1}, refl_trans_gen r a b \u2192 r b c \u2192 refl_trans_gen r a c\n\n/-- `refl_gen r`: reflexive closure of `r` -/\ninductive refl_gen {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : \u03b1 \u2192 Prop where\n| refl : refl_gen r a a\n| single : \u2200 {b : \u03b1}, r a b \u2192 refl_gen r a b\n\n/-- `trans_gen r`: transitive closure of `r` -/\ninductive trans_gen {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : \u03b1 \u2192 Prop where\n| single : \u2200 {b : \u03b1}, r a b \u2192 trans_gen r a b\n| tail : \u2200 {b c : \u03b1}, trans_gen r a b \u2192 r b c \u2192 trans_gen r a c\n\ntheorem refl_gen.to_refl_trans_gen {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} :\n    refl_gen r a b \u2192 refl_trans_gen r a b :=\n  sorry\n\nnamespace refl_trans_gen\n\n\ntheorem trans {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1} (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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} (hab : r a b) :\n    refl_trans_gen r a b :=\n  tail refl hab\n\ntheorem head {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1} (hab : r a b)\n    (hbc : refl_trans_gen r b c) : refl_trans_gen r a c :=\n  sorry\n\ntheorem symmetric {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : symmetric r) :\n    symmetric (refl_trans_gen r) :=\n  sorry\n\ntheorem cases_tail {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} :\n    refl_trans_gen r a b \u2192 b = a \u2228 \u2203 (c : \u03b1), refl_trans_gen r a c \u2227 r c b :=\n  iff.mp (cases_tail_iff r a b)\n\ntheorem head_induction_on {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {b : \u03b1}\n    {P : (a : \u03b1) \u2192 refl_trans_gen r a b \u2192 Prop} {a : \u03b1} (h : refl_trans_gen r a b) (refl : P b refl)\n    (head : \u2200 {a c : \u03b1} (h' : r a c) (h : refl_trans_gen r c b), P c h \u2192 P a (head h' h)) : P a h :=\n  sorry\n\ntheorem trans_induction_on {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    {P : {a b : \u03b1} \u2192 refl_trans_gen r a b \u2192 Prop} {a : \u03b1} {b : \u03b1} (h : refl_trans_gen r a b)\n    (ih\u2081 : \u03b1 \u2192 P refl) (ih\u2082 : \u2200 {a b : \u03b1} (h : r a b), P (single h))\n    (ih\u2083 :\n      \u2200 {a b c : \u03b1} (h\u2081 : refl_trans_gen r a b) (h\u2082 : refl_trans_gen r b c),\n        P h\u2081 \u2192 P h\u2082 \u2192 P (trans h\u2081 h\u2082)) :\n    P h :=\n  sorry\n\ntheorem cases_head {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} (h : refl_trans_gen r a b) :\n    a = b \u2228 \u2203 (c : \u03b1), r a c \u2227 refl_trans_gen r c b :=\n  sorry\n\ntheorem cases_head_iff {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} :\n    refl_trans_gen r a b \u2194 a = b \u2228 \u2203 (c : \u03b1), r a c \u2227 refl_trans_gen r c b :=\n  sorry\n\ntheorem total_of_right_unique {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1}\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 \u2228 refl_trans_gen r c b :=\n  sorry\n\nend refl_trans_gen\n\n\nnamespace trans_gen\n\n\ntheorem to_refl {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} (h : trans_gen r a b) :\n    refl_trans_gen r a b :=\n  trans_gen.drec (fun {b : \u03b1} (h : r a b) => refl_trans_gen.single h)\n    (fun {b c : \u03b1} (h_\u1fb0 : 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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1} (hab : trans_gen r a b)\n    (hbc : refl_trans_gen r b c) : trans_gen r a c :=\n  sorry\n\ntheorem trans {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1} (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' {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1} (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' {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1} (hab : refl_trans_gen r a b)\n    (hbc : r b c) : trans_gen r a c :=\n  sorry\n\ntheorem trans_right {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1}\n    (hab : refl_trans_gen r a b) (hbc : trans_gen r b c) : trans_gen r a c :=\n  sorry\n\ntheorem head {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1} (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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {c : \u03b1} :\n    trans_gen r a c \u2194 \u2203 (b : \u03b1), refl_trans_gen r a b \u2227 r b c :=\n  sorry\n\ntheorem head'_iff {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {c : \u03b1} :\n    trans_gen r a c \u2194 \u2203 (b : \u03b1), r a b \u2227 refl_trans_gen r b c :=\n  sorry\n\ntheorem trans_gen_eq_self {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (trans : transitive r) :\n    trans_gen r = r :=\n  sorry\n\ntheorem transitive_trans_gen {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} : transitive (trans_gen r) :=\n  fun (a b c : \u03b1) => trans\n\ntheorem trans_gen_idem {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} : trans_gen (trans_gen r) = trans_gen r :=\n  trans_gen_eq_self transitive_trans_gen\n\ntheorem trans_gen_lift {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {p : \u03b2 \u2192 \u03b2 \u2192 Prop} {a : \u03b1}\n    {b : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), r a b \u2192 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' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {p : \u03b2 \u2192 \u03b2 \u2192 Prop} {a : \u03b1}\n    {b : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), r a b \u2192 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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {p : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n    (\u2200 (a b : \u03b1), r a b \u2192 trans_gen p a b) \u2192 trans_gen r a b \u2192 trans_gen p a b :=\n  trans_gen_lift' id\n\nend trans_gen\n\n\ntheorem refl_trans_gen_iff_eq {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1}\n    (h : \u2200 (b : \u03b1), \u00acr a b) : refl_trans_gen r a b \u2194 b = a :=\n  sorry\n\ntheorem refl_trans_gen_iff_eq_or_trans_gen {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} :\n    refl_trans_gen r a b \u2194 b = a \u2228 trans_gen r a b :=\n  sorry\n\ntheorem refl_trans_gen_lift {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {p : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    {a : \u03b1} {b : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), r a b \u2192 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 : \u03b1) => refl_trans_gen.refl)\n    (fun (a b : \u03b1) => refl_trans_gen.single \u2218 h a b)\n    fun (a b c : \u03b1) (_x : refl_trans_gen r a b) (_x : refl_trans_gen r b c) => refl_trans_gen.trans\n\ntheorem refl_trans_gen_mono {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {p : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n    (\u2200 (a b : \u03b1), r a b \u2192 p a b) \u2192 refl_trans_gen r a b \u2192 refl_trans_gen p a b :=\n  refl_trans_gen_lift id\n\ntheorem refl_trans_gen_eq_self {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (refl : reflexive r)\n    (trans : transitive r) : refl_trans_gen r = r :=\n  sorry\n\ntheorem reflexive_refl_trans_gen {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} : reflexive (refl_trans_gen r) :=\n  fun (a : \u03b1) => refl_trans_gen.refl\n\ntheorem transitive_refl_trans_gen {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n    transitive (refl_trans_gen r) :=\n  fun (a b c : \u03b1) => refl_trans_gen.trans\n\ntheorem refl_trans_gen_idem {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 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' {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {p : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    {a : \u03b1} {b : \u03b1} (f : \u03b1 \u2192 \u03b2) (h : \u2200 (a b : \u03b1), r a b \u2192 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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {p : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n    (\u2200 (a b : \u03b1), r a b \u2192 refl_trans_gen p a b) \u2192 refl_trans_gen r a b \u2192 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 {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) : \u03b1 \u2192 \u03b1 \u2192 Prop :=\n  fun (a b : \u03b1) => \u2203 (c : \u03b1), r a c \u2227 r b c\n\ntheorem church_rosser {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {c : \u03b1}\n    (h : \u2200 (a b c : \u03b1), r a b \u2192 r a c \u2192 \u2203 (d : \u03b1), refl_gen r b d \u2227 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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} (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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} : symmetric (join r) := sorry\n\ntheorem reflexive_join {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (h : reflexive r) : reflexive (join r) :=\n  fun (a : \u03b1) => Exists.intro a { left := h a, right := h a }\n\ntheorem transitive_join {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (ht : transitive r)\n    (h : \u2200 (a b c : \u03b1), r a b \u2192 r a c \u2192 join r b c) : transitive (join r) :=\n  sorry\n\ntheorem equivalence_join {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} (hr : reflexive r) (ht : transitive r)\n    (h : \u2200 (a b c : \u03b1), r a b \u2192 r a c \u2192 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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (h : \u2200 (a b c : \u03b1), r a b \u2192 r a c \u2192 \u2203 (d : \u03b1), refl_gen r b d \u2227 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 : \u03b1) => church_rosser h\n\ntheorem join_of_equivalence {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1} {r' : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (hr : equivalence r) (h : \u2200 (a b : \u03b1), r' a b \u2192 r a b) : join r' a b \u2192 r a b :=\n  sorry\n\ntheorem refl_trans_gen_of_transitive_reflexive {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1}\n    {r' : \u03b1 \u2192 \u03b1 \u2192 Prop} (hr : reflexive r) (ht : transitive r) (h : \u2200 (a b : \u03b1), r' a b \u2192 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 : \u03b1} (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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1}\n    {r' : \u03b1 \u2192 \u03b1 \u2192 Prop} (hr : equivalence r) :\n    (\u2200 (a b : \u03b1), r' a b \u2192 r a b) \u2192 refl_trans_gen r' a b \u2192 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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a : \u03b1} {b : \u03b1}\n    (h : equivalence r) : eqv_gen r a b \u2194 r a b :=\n  sorry\n\ntheorem eqv_gen_mono {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {p : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (hrp : \u2200 (a b : \u03b1), r a b \u2192 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  | \u27e8n\u27e9, \u27e8m\u27e9 =>\n    dite (Eq n m) (fun h => isTrue (h \u25b8 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  | \u27e8n\u27e9, \u27e8m\u27e9 => inferInstanceAs (Decidable (LT.lt n m))\n\ndef UInt256.decLe (a b : UInt256) : Decidable (LE.le a b) :=\n  match a, b with\n  | \u27e8n\u27e9, \u27e8m\u27e9 => 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 := \u27e8Fin.ofNat n\u27e9\ndef UInt256.ofNat (n : @& Nat) : UInt256 := \u27e8\u27e8n % UInt256.size , ofNat_lt n\u27e9\u27e9\ndef UInt256.ofNat' (n : Nat) (h : n < UInt256.size) : UInt256 := \u27e8\u27e8n, h\u27e9\u27e9\ndef UInt256.ofUInt8 (n : UInt8) : UInt256 := \u27e8\u27e8 n.val, by apply (Nat.lt_trans n.val.isLt); decide \u27e9\u27e9\nabbrev Nat.toUInt256 := UInt256.ofNat\n\n@[inline] abbrev wrapOp (f : Nat -> Nat -> Nat) :=\n  fun (a b : UInt256)  => UInt256.mk \u27e8 (f a.val.val b.val.val) % UInt256.size, ofNat_lt (f a.val.val b.val.val) \u27e9\n\ndef UInt256.add := wrapOp Nat.add\ndef UInt256.sub (a b : UInt256) : UInt256 := \u27e8\u27e8 (a.val.val + (UInt256.size - b.val.val)) % UInt256.size , ofNat_lt _\u27e9\u27e9\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 := \u27e8\u27e8 (2^256) - 1, by decide \u27e9\u27e9 \ndef UInt256.modn (a : UInt256) (n : @& Nat) : UInt256 := \u27e8\u27e8 (a.val.val % n) % UInt256.size, ofNat_lt _ \u27e9\u27e9\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 := \u27e8\u27e8 (a.val.val <<< (modn b 256).val.val) % UInt256.size, ofNat_lt _ \u27e9\u27e9\ndef UInt256.shiftRight (a b : UInt256) : UInt256 := \u27e8\u27e8 (a.val.val >>> (modn b 256).val.val) % UInt256.size, ofNat_lt _ \u27e9\u27e9\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   := \u27e8UInt256.ofNat n\u27e9\ninstance : Add UInt256       := \u27e8UInt256.add\u27e9\ninstance : Sub UInt256       := \u27e8UInt256.sub\u27e9\ninstance : Mul UInt256       := \u27e8UInt256.mul\u27e9\ninstance : Mod UInt256       := \u27e8UInt256.mod\u27e9\ninstance : HMod UInt256 Nat UInt256 := \u27e8UInt256.modn\u27e9\ninstance : Div UInt256       := \u27e8UInt256.div\u27e9\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 := \u27e8UInt256.complement\u27e9\ninstance : AndOp UInt256     := \u27e8UInt256.land\u27e9\ninstance : OrOp UInt256      := \u27e8UInt256.lor\u27e9\ninstance : Xor UInt256       := \u27e8UInt256.xor\u27e9\ninstance : ShiftLeft UInt256  := \u27e8UInt256.shiftLeft\u27e9\ninstance : ShiftRight UInt256 := \u27e8UInt256.shiftRight\u27e9\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 \u27e8 1, by simp [Nat.pow, Nat.mod_zero] \u27e9 \n                         | succ N => cases N with\n                          | zero => exact \u27e8 0, by simp [Nat.pow]\u27e9 \n                          | succ N => exact \u27e8 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 \u27e9 \n  | Nat.succ b => \n    if (Nat.succ b) % 2 == 0 then \u27e8 powmod_correct ((a * a) % N) ((Nat.succ b) / 2) N , sorry \u27e9 \n    else \u27e8 (a * powmod_correct ((a * a) % N) ((Nat.succ b) / 2) N) % N , sorry \u27e9 \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 \u27e8 val, prop \u27e9 := Nat.powmod_correct a b n\n  \u27e8 val, by subst prop; exact Nat.mod_lt (Nat.pow a.val b.val) h \u27e9 \n\n-- #eval Fin.pow \u27e8 Fin.mk 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF UInt256.size\n\n\n-- TODO make faster by modding intermediately\ndef UInt256.pow (a b:UInt256) : UInt256 := \u27e8 Fin.pow (h:=by simp) a.val b.val \u27e9\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 \u2964 AddCommGroup.{u} :=\n{ obj := \u03bb X, AddCommGroup.of $ X \u2192\u2080 \u2124,\n  map := \u03bb 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 \u2243+ B) : of A \u2245 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} \u2245 free'.{u} :=\ncategory_theory.nat_iso.of_components\n(\u03bb X, of_iso (free_abelian_group.equiv_finsupp X))\nbegin\n  intros X Y f, ext, dsimp, simp,\nend\n\ndef adj' : free'.{u} \u22a3 forget AddCommGroup.{u} :=\nAddCommGroup.adj.of_nat_iso_left $ free_iso_free'.{u}\n\nend AddCommGroup\n\ndef types.pt {\u03b1 : Type u} (a : \u03b1) : \u22a4_ _ \u27f6 \u03b1 :=\n\u03bb x, a\n\ndef types.punit_iso : (punit : Type u) \u2245 \u22a4_ _ :=\n{ hom := limits.terminal.from _,\n  inv := types.pt punit.star }\n\nnamespace AddCommGroup\n\ndef tunit : AddCommGroup.{u} :=\n  AddCommGroup.free'.obj (\u22a4_ _)\n\ndef tunit.lift {A : AddCommGroup.{u}} (e : \u22a4_ _ \u27f6 (forget _).obj A) :\n  tunit \u27f6 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) \u2192\u2080 M) \u2243+ M :=\n{ to_fun := \u03bb f, f punit.star,\n  inv_fun := \u03bb m, finsupp.single punit.star m,\n  left_inv := \u03bb x, by { ext, dsimp, simp },\n  right_inv := \u03bb x, by { dsimp, simp },\n  map_add' := \u03bb f g, by simp }\n\n-- Do we really not have this?!\ndef add_equiv_of_iso (A B : AddCommGroup.{u}) (e : A \u2245 B) :\n  A \u2243+ B :=\n{ to_fun := e.hom,\n  inv_fun := e.inv,\n  left_inv := \u03bb x, by simp,\n  right_inv := \u03bb x, by simp,\n  map_add' := \u03bb x y, e.hom.map_add _ _ }\n\ndef tunit_add_equiv : tunit.{u} \u2243+ \u2124 :=\nadd_equiv.trans (add_equiv_of_iso _ _ $ AddCommGroup.free'.map_iso\n  types.punit_iso.symm) (finsupp.punit_add_equiv \u2124)\n\ndef tunit.gen : tunit.{u} :=\nAddCommGroup.adj'.unit.app _ $\n  (limits.terminal.from (punit : Type u) : punit \u2192 \u22a4_ (Type u)) punit.star\n\nopen_locale classical\n\n-- Of course this is true without the fintype assumption...\ndef iso_of_basis {\u03b9 : Type u} [fintype \u03b9] {A : AddCommGroup.{u}} (\ud835\udcd1 : basis \u03b9 \u2124 A) :\n  (\u2210 (\u03bb i : \u03b9, tunit.{u})) \u2245 A :=\nbegin\n  -- This is very messy...\n  let e : (\u2210 (\u03bb i : \u03b9, tunit.{u})) \u2245 (\u2a01 (\u03bb i, tunit.{u})) :=\n    (limits.colimit.is_colimit _).cocone_point_unique_up_to_iso\n      (limits.biproduct.is_bilimit _).is_colimit,\n  refine e \u226a\u226b _,\n  refine biproduct_iso_pi _ \u226a\u226b _,\n  refine AddCommGroup.of_iso _ \u226a\u226b (AddCommGroup.of_iso \ud835\udcd1.repr.to_add_equiv).symm \u226a\u226b\n    \u27e8add_monoid_hom.id _, add_monoid_hom.id _, by { ext, refl }, by { ext, refl }\u27e9,\n  let q : tunit.{u} \u2243+ \u2124 := tunit_add_equiv,\n  let e : (\u03b9 \u2192\u2080 \u2124) \u2243+ (\u03b9 \u2192 \u2124),\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 \ud835\udcd1)\n\n@[derive partial_order]\ndef index_cat (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 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 \u2124 A] :\n  nonempty A.index_cat := \u27e8\u27e8\u22a5, \u2205, by simp\u27e9\u27e9\n\ninstance semilattice_sup_index_cat\n  (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A] :\n  semilattice_sup A.index_cat :=\n{ sup := \u03bb I J, \u27e8I.1 \u2294 J.1, begin\n    obtain \u27e8S,hS\u27e9 := I.2,\n    obtain \u27e8T,hT\u27e9 := J.2,\n    rw [\u2190 hS, \u2190 hT],\n    use S \u222a T,\n    simp only [finset.coe_union, add_subgroup.closure_union],\n  end\u27e9,\n  le_sup_left := \u03bb I J, @le_sup_left (add_subgroup A) _ _ _,\n  le_sup_right := \u03bb I J, @le_sup_right (add_subgroup A) _ _ _,\n  sup_le := \u03bb 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 \u2124 A] :\n  A.index_cat \u2964 AddCommGroup.{u} :=\n{ obj := \u03bb I, AddCommGroup.of I.1,\n  map := \u03bb I J h, add_subgroup.inclusion h.le }\n\ndef cocone (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A] :\n  limits.cocone A.diagram :=\n{ X := A,\n  \u03b9 := { app := \u03bb I, I.1.subtype } }\n\ndef is_colimit_cocone (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A] :\n  limits.is_colimit A.cocone :=\n{ desc := \u03bb S,\n  { to_fun := \u03bb a, S.\u03b9.app \u27e8add_subgroup.closure {a}, {a}, by simp\u27e9\n      \u27e8a, add_subgroup.subset_closure rfl\u27e9,\n    map_zero' := add_monoid_hom.map_zero _,\n    map_add' := \u03bb x y, begin\n      let I : A.index_cat := \u27e8add_subgroup.closure {x}, {x}, by simp\u27e9,\n      let J : A.index_cat := \u27e8add_subgroup.closure {y}, {y}, by simp\u27e9,\n      let K : A.index_cat := \u27e8add_subgroup.closure {x + y}, {x + y}, by simp\u27e9,\n      let IJ : A.index_cat := \u27e8add_subgroup.closure {x,y}, {x,y}, by simp\u27e9,\n      let iI : I \u27f6 IJ := hom_of_le (add_subgroup.closure_mono $ by simp),\n      let iJ : J \u27f6 IJ := hom_of_le (add_subgroup.closure_mono $ by simp),\n      let iK : K \u27f6 IJ := hom_of_le ((add_subgroup.closure_le _).2 _),\n      swap,\n      { rintro a (rfl : a = _), change x + y \u2208 IJ.1, apply IJ.1.add_mem,\n        { apply add_subgroup.subset_closure, simp },\n        { apply add_subgroup.subset_closure, simp } },\n      rw [\u2190 S.w iI, \u2190 S.w iJ, \u2190 S.w iK, comp_apply, comp_apply, comp_apply,\n        \u2190 add_monoid_hom.map_add],\n      refl,\n    end },\n  fac' := begin\n    rintros S J, ext \u27e8x,hx\u27e9,\n    let I : A.index_cat := \u27e8add_subgroup.closure {x}, {x}, by simp\u27e9,\n    let e : I \u27f6 J := hom_of_le ((add_subgroup.closure_le _).2 _),\n    { rw comp_apply, dsimp [cocone], rw \u2190 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 \u22a2,\n    let I : A.index_cat := \u27e8add_subgroup.closure {x}, {x}, by simp\u27e9,\n    specialize hm I,\n    let y : I.1 := \u27e8x, add_subgroup.subset_closure rfl\u27e9,\n    apply_fun (\u03bb e, e y) at hm, exact hm,\n  end }\n\ndef colimit_comparison (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A] :\n  limits.colimit A.diagram \u2245 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 \u2124 A]\n  (I : A.index_cat) : \u2203 (\u03b9 : Type u) [fintype \u03b9]\n  (\ud835\udcd1 : basis \u03b9 \u2124 (AddCommGroup.of I.1)), true :=\nbegin\n  obtain \u27e8S,hS\u27e9 := I.2,\n  let e : S \u2192 I.1 := \u03bb s, \u27e8s,_\u27e9,\n  swap, { rw \u2190 hS, apply add_subgroup.subset_closure, exact s.2 },\n  haveI : no_zero_smul_divisors \u2124 I.1,\n  { constructor, rintros c \u27e8x, hx\u27e9 h, apply_fun (\u03bb 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 \u27e8n,B\u27e9 := @module.free_of_finite_type_torsion_free S \u2124 _ _ _ I.1 _ _ _ e _ _,\n  { use [ulift (fin n), infer_instance],\n    refine \u27e8_, trivial\u27e9,\n    apply B.reindex,\n    exact equiv.ulift.symm },\n  { apply le_antisymm, { intros x hx, trivial },\n    rintros \u27e8x,hx\u27e9 -,\n    let J := (submodule.span \u2124 (set.range e)).to_add_subgroup,\n    change _ \u2208 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 [\u2190 hS, submodule.span_int_eq_add_subgroup_closure, add_monoid_hom.map_closure], congr' 1,\n    ext t,\n    split,\n    { rintros \u27e8t,\u27e8t,rfl\u27e9,rfl\u27e9, exact t.2 },\n    { intros ht, refine \u27e8\u27e8t, _\u27e9, \u27e8\u27e8t, ht\u27e9, rfl\u27e9, rfl\u27e9 } },\nend\n\nlemma exists_sigma_iso_of_index (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A]\n  (I : A.index_cat) : \u2203 (\u03b9 : Type u) [fintype \u03b9]\n  (e : (\u2210 (\u03bb i : \u03b9, tunit.{u})) \u2245 AddCommGroup.of I.1), true :=\nbegin\n  obtain \u27e8\u03b9,h\u03b9,\ud835\udcd1,-\u27e9 := exists_basis_of_index A I,\n  resetI,\n  use [\u03b9, h\u03b9, iso_of_basis \ud835\udcd1],\nend\n\nlemma exists_biprod_iso_of_index (A : AddCommGroup.{u}) [no_zero_smul_divisors \u2124 A]\n  (I : A.index_cat) : \u2203 (\u03b9 : Type u) [fintype \u03b9]\n  (e : by exactI (\u2a01 (\u03bb i : \u03b9, tunit.{u})) \u2245 AddCommGroup.of I.1), true :=\nbegin\n  obtain \u27e8\u03b9,h\u03b9,e,-\u27e9 := exists_sigma_iso_of_index A I,\n  resetI, use [\u03b9, h\u03b9],\n  use (limits.biproduct.is_bilimit _).is_colimit.cocone_point_unique_up_to_iso\n      (limits.colimit.is_colimit _) \u226a\u226b e,\nend\n\nuniverses u'\n\n\nlemma is_iso_of_preserves {\ud835\udcd0 : Type u'} [category.{u} \ud835\udcd0] [preadditive \ud835\udcd0]\n  (F G : AddCommGroup \u2964 \ud835\udcd0)\n  [F.additive]\n  [G.additive]\n  [limits.preserves_filtered_colimits F]\n  [limits.preserves_filtered_colimits G]\n  (\u03b7 : F \u27f6 G)\n  [h\u03b7 : is_iso (\u03b7.app tunit)]\n  (A : AddCommGroup.{u})\n  [no_zero_smul_divisors \u2124 A] :\n  is_iso (\u03b7.app A) :=\nbegin\n  let T := (limits.cocones.precompose (whisker_left A.diagram \u03b7)).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 : \u03b7.app A = hS.desc T,\n  { apply hS.hom_ext, intros j, rw hS.fac,\n    dsimp, apply \u03b7.naturality },\n  rw this, clear this,\n  suffices : \u2200 I : A.index_cat, is_iso (\u03b7.app (A.diagram.obj I)),\n  { resetI,\n    haveI : is_iso (whisker_left A.diagram \u03b7),\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 \u03b7))\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 \u27e8\u03b9,h\u03b9,e,-\u27e9 := 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 (\u2a01 \u03bb (i : \u03b9), tunit.{u}) \u2245 \u2a01 \u03bb (i : \u03b9), F.obj tunit :=\n    (limits.is_bilimit_of_preserves F\n    (limits.biproduct.is_bilimit (\u03bb i : \u03b9, tunit.{u}))).is_colimit.cocone_point_unique_up_to_iso\n    (limits.biproduct.is_bilimit (\u03bb i : \u03b9, F.obj tunit)).is_colimit,\n  let eG : G.obj (\u2a01 \u03bb (i : \u03b9), tunit.{u}) \u2245 \u2a01 \u03bb (i : \u03b9), G.obj tunit :=\n    (limits.is_bilimit_of_preserves G\n    (limits.biproduct.is_bilimit (\u03bb i : \u03b9, tunit.{u}))).is_colimit.cocone_point_unique_up_to_iso\n    (limits.biproduct.is_bilimit (\u03bb i : \u03b9, G.obj tunit)).is_colimit,\n  have : \u03b7.app (A.diagram.obj I) =\n    F.map e.inv \u226b eF.hom \u226b limits.biproduct.desc\n      (\u03bb i, \u03b7.app _ \u226b limits.biproduct.\u03b9 _ i) \u226b eG.inv \u226b G.map e.hom,\n  { rw [\u2190 functor.map_iso_inv, iso.eq_inv_comp, \u2190 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.\u03b9_desc_assoc, category.assoc],\n    erw [limits.biproduct.\u03b9_desc_assoc, limits.biproduct.\u03b9_desc_assoc],\n    dsimp, rw \u03b7.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      (\u03bb i, inv (\u03b7.app _) \u226b limits.biproduct.\u03b9 _ i),\n  split,\n  { ext, simp },\n  { ext, simp },\nend\n\ndef is_tensor_unit (A : AddCommGroup.{u}) : Prop :=\n\u2203 a : A, \u2200 (B : AddCommGroup.{u}), function.bijective\n  (\u03bb f : A \u27f6 B, (f : A \u2192 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 \u27f6 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 \u27f6 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 \u2245 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 _ \u226b (forget _).map f) _ =\n      (adj'.unit.app _ \u226b (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 _ \u226b\n      (forget _).map (free'.map (\u03bb (x : \u22a4_ Type u), t) \u226b 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 {\ud835\udcd0 : Type u'} [category.{u} \ud835\udcd0] [preadditive \ud835\udcd0]\n  (F G : AddCommGroup \u2964 \ud835\udcd0)\n  [F.additive]\n  [G.additive]\n  [limits.preserves_filtered_colimits F]\n  [limits.preserves_filtered_colimits G]\n  (\u03b7 : F \u27f6 G)\n  (U : AddCommGroup)\n  (hU : U.is_tensor_unit)\n  [h\u03b7 : is_iso (\u03b7.app U)]\n  (A : AddCommGroup.{u})\n  [no_zero_smul_divisors \u2124 A] :\n  is_iso (\u03b7.app A) :=\nbegin\n  suffices : is_iso (\u03b7.app tunit),\n  { resetI, apply is_iso_of_preserves },\n  let e : tunit \u2245 U := is_tensor_unit_tunit.iso hU,\n  suffices : \u03b7.app tunit = F.map e.hom \u226b \u03b7.app U \u226b G.map e.inv,\n  { rw this, apply is_iso.comp_is_iso, },\n  rw [\u2190 \u03b7.naturality, \u2190 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 : \u03b1 \u2192 \u03b1` is semiconjugate to an order embedding `fb : \u03b2 \u2192 \u03b2` by\n`g : \u03b1 \u2192 \u03b2`, then `fb` is semiconjugate to `fa` by `y \u21a6 Sup {x | g x \u2264 y}`, see\n`semiconj.symm_adjoint`.\n\nSecond, consider two actions `f\u2081 f\u2082 : G \u2192 \u03b1 \u2192 \u03b1` of a group on a complete lattice by order\nisomorphisms. Then the map `x \u21a6 \u2a06 g : G, (f\u2081 g)\u207b\u00b9 (f\u2082 g x)` semiconjugates each `f\u2081 g'` to `f\u2082 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\u2081 g)\u207b\u00b9 (f\u2082 g x) | g : G}` is\nbounded above, see `function.cSup_div_semiconj`.\n\nThe lemmas come from [\u00c9tienne 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 : \u03b2 \u2192 \u03b1` is an order right adjoint function for `f : \u03b1 \u2192 \u03b2` if it sends each `y`\nto a least upper bound for `{x | f x \u2264 y}`. If `\u03b1` is a partial order, and `f : \u03b1 \u2192 \u03b2` has\na right adjoint, then this right adjoint is unique. -/\ndef is_order_right_adjoint {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1) :=\n  \u2200 (y : \u03b2), is_lub (set_of fun (x : \u03b1) => f x \u2264 y) (g y)\n\ntheorem is_order_right_adjoint_Sup {\u03b1 : Type u_1} {\u03b2 : Type u_2} [complete_lattice \u03b1] [preorder \u03b2] (f : \u03b1 \u2192 \u03b2) : is_order_right_adjoint f fun (y : \u03b2) => Sup (set_of fun (x : \u03b1) => f x \u2264 y) :=\n  fun (y : \u03b2) => is_lub_Sup (set_of fun (x : \u03b1) => f x \u2264 y)\n\ntheorem is_order_right_adjoint_cSup {\u03b1 : Type u_1} {\u03b2 : Type u_2} [conditionally_complete_lattice \u03b1] [preorder \u03b2] (f : \u03b1 \u2192 \u03b2) (hne : \u2200 (y : \u03b2), \u2203 (x : \u03b1), f x \u2264 y) (hbdd : \u2200 (y : \u03b2), \u2203 (b : \u03b1), \u2200 (x : \u03b1), f x \u2264 y \u2192 x \u2264 b) : is_order_right_adjoint f fun (y : \u03b2) => Sup (set_of fun (x : \u03b1) => f x \u2264 y) :=\n  fun (y : \u03b2) => is_lub_cSup (hne y) (hbdd y)\n\ntheorem is_order_right_adjoint.unique {\u03b1 : Type u_1} {\u03b2 : Type u_2} [partial_order \u03b1] [preorder \u03b2] {f : \u03b1 \u2192 \u03b2} {g\u2081 : \u03b2 \u2192 \u03b1} {g\u2082 : \u03b2 \u2192 \u03b1} (h\u2081 : is_order_right_adjoint f g\u2081) (h\u2082 : is_order_right_adjoint f g\u2082) : g\u2081 = g\u2082 :=\n  funext fun (y : \u03b2) => is_lub.unique (h\u2081 y) (h\u2082 y)\n\ntheorem is_order_right_adjoint.right_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [preorder \u03b1] [preorder \u03b2] {f : \u03b1 \u2192 \u03b2} {g : \u03b2 \u2192 \u03b1} (h : is_order_right_adjoint f g) : monotone g :=\n  fun (y\u2081 y\u2082 : \u03b2) (hy : y\u2081 \u2264 y\u2082) =>\n    is_lub.mono (h y\u2081) (h y\u2082) fun (x : \u03b1) (hx : x \u2208 set_of fun (x : \u03b1) => f x \u2264 y\u2081) => 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 \u2264 y}`), then `fb` is\nsemiconjugate to `fa` by `g'`.\n\nThis is a version of Proposition 2.1 from [\u00c9tienne Ghys, Groupes d'homeomorphismes du cercle et\ncohomologie bornee][ghys87:groupes]. -/\ntheorem semiconj.symm_adjoint {\u03b1 : Type u_1} {\u03b2 : Type u_2} [partial_order \u03b1] [preorder \u03b2] {fa : \u03b1 \u2243o \u03b1} {fb : \u03b2 \u21aao \u03b2} {g : \u03b1 \u2192 \u03b2} (h : semiconj g \u21d1fa \u21d1fb) {g' : \u03b2 \u2192 \u03b1} (hg' : is_order_right_adjoint g g') : semiconj g' \u21d1fb \u21d1fa := sorry\n\ntheorem semiconj_of_is_lub {\u03b1 : Type u_1} {G : Type u_3} [partial_order \u03b1] [group G] (f\u2081 : G \u2192* \u03b1 \u2243o \u03b1) (f\u2082 : G \u2192* \u03b1 \u2243o \u03b1) {h : \u03b1 \u2192 \u03b1} (H : \u2200 (x : \u03b1), is_lub (set.range fun (g' : G) => coe_fn (coe_fn f\u2081 g'\u207b\u00b9) (coe_fn (coe_fn f\u2082 g') x)) (h x)) (g : G) : semiconj h \u21d1(coe_fn f\u2082 g) \u21d1(coe_fn f\u2081 g) := sorry\n\n/-- Consider two actions `f\u2081 f\u2082 : G \u2192 \u03b1 \u2192 \u03b1` of a group on a complete lattice by order\nisomorphisms. Then the map `x \u21a6 \u2a06 g : G, (f\u2081 g)\u207b\u00b9 (f\u2082 g x)` semiconjugates each `f\u2081 g'` to `f\u2082 g'`.\n\nThis is a version of Proposition 5.4 from [\u00c9tienne Ghys, Groupes d'homeomorphismes du cercle et\ncohomologie bornee][ghys87:groupes]. -/\ntheorem Sup_div_semiconj {\u03b1 : Type u_1} {G : Type u_3} [complete_lattice \u03b1] [group G] (f\u2081 : G \u2192* \u03b1 \u2243o \u03b1) (f\u2082 : G \u2192* \u03b1 \u2243o \u03b1) (g : G) : semiconj (fun (x : \u03b1) => supr fun (g' : G) => coe_fn (coe_fn f\u2081 g'\u207b\u00b9) (coe_fn (coe_fn f\u2082 g') x)) \u21d1(coe_fn f\u2082 g)\n  \u21d1(coe_fn f\u2081 g) :=\n  semiconj_of_is_lub f\u2081 f\u2082 (fun (x : \u03b1) => is_lub_supr) g\n\n/-- Consider two actions `f\u2081 f\u2082 : G \u2192 \u03b1 \u2192 \u03b1` 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 \u21a6 Sup s(x)` semiconjugates each `f\u2081 g'` to `f\u2082 g'`.\n\nThis is a version of Proposition 5.4 from [\u00c9tienne Ghys, Groupes d'homeomorphismes du cercle et\ncohomologie bornee][ghys87:groupes]. -/\ntheorem cSup_div_semiconj {\u03b1 : Type u_1} {G : Type u_3} [conditionally_complete_lattice \u03b1] [group G] (f\u2081 : G \u2192* \u03b1 \u2243o \u03b1) (f\u2082 : G \u2192* \u03b1 \u2243o \u03b1) (hbdd : \u2200 (x : \u03b1), bdd_above (set.range fun (g : G) => coe_fn (coe_fn f\u2081 g\u207b\u00b9) (coe_fn (coe_fn f\u2082 g) x))) (g : G) : semiconj (fun (x : \u03b1) => supr fun (g' : G) => coe_fn (coe_fn f\u2081 g'\u207b\u00b9) (coe_fn (coe_fn f\u2082 g') x)) \u21d1(coe_fn f\u2082 g)\n  \u21d1(coe_fn f\u2081 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 \u03b1) (ys : List \u03b2) : List (\u03b1 \u00d7 \u03b2) :=\n  let rec aux\n  | [], r => r\n  | x::xs, r =>\n    let rec aux\u2082\n    | [], r => r\n    | y::ys, r => (x, y) :: r\n    aux\u2082 ys (aux xs r)\n  aux xs []\n\ndef allPairsFixed (xs : List \u03b1) (ys : List \u03b2) : List (\u03b1 \u00d7 \u03b2) :=\n  let rec aux\n  | [], r => r\n  | x::xs, r =>\n    let rec aux\u2082\n    | [], r => r\n    | y::ys, r => aux\u2082 ys ((x, y) :: r)\n    aux\u2082 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 \u2265 3) {v : V} {\u03c4 : assignment V}\n\nlemma disjoint_fresh_of_disjoint : disjoint g.stock (clause.vars l) \u2192 \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 \u2265 3) :\n  length l > k \u2192 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 \u27e8x\u2081, x\u2082, rfl, hl\u2081\u27e9,\n  simp only [hl\u2081, length_drop, length_append],\n  rw [add_comm k x\u2082.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) \u2192 list (literal V)} (hp : \u2200 l, perm l (p l))\n\ndef tseitin_xor : list (literal V) \u2192 gensym V \u2192 cnf V\n| l g :=  if h : length l \u2264 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))))) \u25b8 \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 := \u03bb a b, `[exact \u27e8_, measure_wf (\u03bb \u03c3, list.length \u03c3.1)\u27e9],\n  dec_tac := tactic.assumption\n}\n\nlemma tseitin_base_case : length l \u2264 k \u2192 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 \u2208 (clause.vars l) \u2192 v \u2208 (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 \u2264 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 [\u2190 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\u2081 := drop_len_lt (Pos g.fresh.1) hk hl,\n      have h\u2082 := disjoint_fresh_of_disjoint hdis,\n      rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h\u2081,\n      rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h\u2082,\n      have := ih _ h\u2081 h\u2082,\n      rw \u2190 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 \u2209 (clause.vars l) \u2192 v \u2209 g.stock \u2192 v \u2209 (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 \u2264 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\u2081 := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),\n      have h\u2082 := disjoint_fresh_of_disjoint hdis,\n      have h\u2083 : v \u2209 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\u2084 : v \u2209 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\u2081,\n      rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h\u2082 h\u2083,\n      exact ih _ h\u2081 h\u2082 h\u2083 h\u2084 } }\nend\n\nlemma tseitin_forward (hdis : disjoint g.stock (clause.vars l)) : \n  Xor.eval \u03c4 l = tt \u2192 \u2203 (\u03c3 : assignment V),\n  (tseitin_xor hk hp l g).eval \u03c3 = tt \u2227 (eqod \u03c4 \u03c3 (clause.vars l)) :=\nbegin\n  intro he,\n  induction l using strong_induction_on_lists with l ih generalizing g \u03c4,\n  by_cases hl : length l \u2264 k,\n  { use \u03c4, rw [tseitin_base_case hk hp hl, eval_direct_xor_eq_eval_Xor], simp [he] },\n  {\n    rw [eval_eq_bodd_count_tt,\n      \u2190 (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\u2081 := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),\n    have h\u2082 := disjoint_fresh_of_disjoint hdis,\n    rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h\u2081,\n    rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h\u2082,\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 \u03c4 (take (k - 1) l)),\n    { rw [hc, bool.bxor_ff_left] at he,\n      rcases exists_eqod_and_eq_of_not_mem \u03c4 ff hnotmem with \u27e8\u03b3, heqod, hg\u27e9,\n      have : bodd (clause.count_tt \u03b3 (Pos g.fresh.1 :: drop (k - 1) l)) = tt,\n      { simp only [clause.count_tt_cons, literal.eval, hg, cond,\n          \u2190 count_tt_eq_of_eqod (eqod_subset hdropvars heqod), he] },\n      rw [\u2190 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\u2081 h\u2082 this) with \u27e8\u03b3\u2082, he\u2082, hg\u2082\u27e9,\n\n      have heqod\u2082 : eqod (assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) \u03b3\u2082 \u03b3) \u03b3 (clause.vars l),\n      { intros v hv,\n        by_cases hmem : v \u2208 clause.vars (l.drop (k - 1)),\n        { have h\u2083 := 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\u2083,\n          rw [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h\u2082 h\u2083), hg\u2082 v h\u2083] },\n        { have hdis\u2082 := set.disjoint_right.mp hdis hv,\n          have hne : v \u2260 g.fresh.1,\n          { intro hcon,\n            exact (hcon \u25b8 hdis\u2082) (fresh_mem_stock g) },\n          have : v \u2209 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 \u2209 g.fresh.2.stock,\n          { intro hcon,\n            exact hdis\u2082 ((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\u2082 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)) \u03b3\u2082 \u03b3,\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 \u2208 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\u2082 this), \n            \u2190 (hg\u2082 g.fresh.1 this), hg,\n            count_tt_eq_of_eqod (eqod_subset htakevars heqod\u2082),\n            \u2190 count_tt_eq_of_eqod (eqod_subset htakevars heqod), hc] },\n        { exact he\u2082 \u25b8 eval_eq_of_eqod (ite_eqod _ _ _) } },\n      { exact eqod.trans heqod (heqod\u2082.symm) } },\n    { simp only [hc, bnot_eq_true_eq_eq_ff, tt_bxor] at he,\n        rcases exists_eqod_and_eq_of_not_mem \u03c4 tt hnotmem with \u27e8\u03b3, heqod, hg\u27e9,\n        have : bodd (clause.count_tt \u03b3 (Pos g.fresh.1 :: drop (k - 1) l)) = tt,\n        { simp only [clause.count_tt_cons, literal.eval, hg, cond, \n            \u2190 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 [\u2190 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\u2081 h\u2082 this) with \u27e8\u03b3\u2082, he\u2082, hg\u2082\u27e9,\n\n        have heqod\u2082 : eqod (assignment.ite (cnf.vars (tseitin_xor hk hp (p (Pos g.fresh.1 :: (l.drop (k - 1)))) g.fresh.2)) \u03b3\u2082 \u03b3) \u03b3 (clause.vars l),\n        { intros v hv,\n          by_cases hmem : v \u2208 clause.vars (l.drop (k - 1)),\n          { have h\u2083 := 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\u2083,\n            rw [ite_pos (mem_tseitin_xor_vars_of_mem_vars hk hp h\u2082 h\u2083), hg\u2082 v h\u2083] },\n          { have hdis\u2082 := set.disjoint_right.mp hdis hv,\n            have hne : v \u2260 g.fresh.1,\n            { intro hcon,\n              exact (hcon \u25b8 hdis\u2082) (fresh_mem_stock g) },\n            have : v \u2209 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 \u2209 g.fresh.2.stock,\n            { intro hcon,\n              exact hdis\u2082 ((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\u2082 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)) \u03b3\u2082 \u03b3,\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 \u2208 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\u2082 this), \n              \u2190 (hg\u2082 g.fresh.1 this), hg,\n              count_tt_eq_of_eqod (eqod_subset htakevars heqod\u2082),\n              \u2190 count_tt_eq_of_eqod (eqod_subset htakevars heqod), hc] },\n          { exact he\u2082 \u25b8 eval_eq_of_eqod (ite_eqod _ _ _) } },\n        { exact eqod.trans heqod heqod\u2082.symm } } } \nend\n\nlemma tseitin_reverse (hdis : disjoint g.stock (clause.vars l)) :\n  cnf.eval \u03c4 (tseitin_xor hk hp l g) = tt \u2192 Xor.eval \u03c4 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 \u2264 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 \u27e8hdir, hrec\u27e9,\n    have h\u2081 := drop_len_lt (Pos g.fresh.1) hk (not_le.mp hl),\n    have h\u2082 := disjoint_fresh_of_disjoint hdis,\n    rw perm.length_eq (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h\u2081,\n    rw vars_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at h\u2082,\n    have ihred := ih _ h\u2081 h\u2082 hrec,\n    rw eval_direct_xor_eq_eval_Xor at hdir,\n    rw eval_eq_bodd_count_tt at ihred hdir |-,\n    rw \u2190 clause.count_tt_perm (hp (Pos g.fresh.1 :: drop (k - 1) l)) at ihred,\n    have := congr_arg ((clause.count_tt \u03c4)) (take_append_drop (k - 1) l).symm,\n    have := congr_arg bodd this,\n    cases hnew : (\u03c4 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 \u03c4,\n  split,\n  { exact tseitin_forward hk hp hdis },\n  { rintros \u27e8\u03c3, he, heqod\u27e9,\n    rw [\u2190 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 : \u2200 (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) \u2192 list (literal V)\n| []        := []\n| (x :: xs) := xs ++ [x]\n\nlemma pooled_perm_is_perm : \u2200 (l : list (literal V)), l ~ pooled_perm l :=\nbegin\n  intro l,\n  cases l,\n  { refl },\n  { rw [pooled_perm, \u2190 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 \u2192 U \u2192 U\nvariable P : U \u2192 Prop\n\ntheorem fol_19 : (\u2200 x, P (f x x)) \u2192 (\u2200 x, \u2203 y, P (f x y)) :=\nassume h1: \u2200 x, P (f x x),\nassume t: U,\nhave h2: P (f t t), from h1 t,\nshow \u2203 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 \u2192 xnat\n\nopen xnat\n\ndefinition lt : xnat \u2192 xnat \u2192 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 \u2192 b < c \u2192 a < c := \u03bb 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} [\ud835\udc9e : category.{v} C]\ninclude \ud835\udc9e\n\nvariables {J K : Type v} [small_category J] [small_category K]\n\n@[simp] lemma cone.functor_w {F : J \u2964 (K \u2964 C)} (c : cone F) {j j' : J} (f : j \u27f6 j') (k : K) :\n  (c.\u03c0.app j).app k \u226b (F.map f).app k = (c.\u03c0.app j').app k :=\nby convert \u2190nat_trans.congr_app (c.\u03c0.naturality f).symm k; apply id_comp\n\n@[simp] lemma cocone.functor_w {F : J \u2964 (K \u2964 C)} (c : cocone F) {j j' : J} (f : j \u27f6 j') (k : K) :\n  (F.map f).app k \u226b (c.\u03b9.app j').app k = (c.\u03b9.app j).app k :=\nby convert \u2190nat_trans.congr_app (c.\u03b9.naturality f) k; apply comp_id\n\n@[simp] def functor_category_limit_cone [has_limits_of_shape J C] (F : J \u2964 K \u2964 C) :\n  cone F :=\n{ X := F.flip \u22d9 lim,\n  \u03c0 :=\n  { app := \u03bb j,\n    { app := \u03bb k, limit.\u03c0 (F.flip.obj k) j },\n      naturality' := \u03bb 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 \u2964 K \u2964 C) :\n  cocone F :=\n{ X := F.flip \u22d9 colim,\n  \u03b9 :=\n  { app := \u03bb j,\n    { app := \u03bb k, colimit.\u03b9 (F.flip.obj k) j },\n      naturality' := \u03bb 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 \u2964 K \u2964 C) (k : K) :\n  ((evaluation K C).obj k).map_cone (functor_category_limit_cone F) \u2245\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 \u2964 K \u2964 C) (k : K) :\n  ((evaluation K C).obj k).map_cocone (functor_category_colimit_cocone F) \u2245\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 \u2964 K \u2964 C) :\n  is_limit (functor_category_limit_cone F) :=\n{ lift := \u03bb s,\n  { app := \u03bb k, limit.lift (F.flip.obj k) (((evaluation K C).obj k).map_cone s),\n    naturality' := \u03bb k k' f,\n      by ext; dsimp; simpa using (s.\u03c0.app j).naturality f },\n  uniq' := \u03bb 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) (\u03bb 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 \u2964 K \u2964 C) :\n  is_colimit (functor_category_colimit_cocone F) :=\n{ desc := \u03bb s,\n  { app := \u03bb k, colimit.desc (F.flip.obj k) (((evaluation K C).obj k).map_cocone s),\n    naturality' := \u03bb k k' f,\n    begin\n      ext,\n      rw [\u2190assoc, \u2190assoc],\n      dsimp [functor.flip],\n      simpa using (s.\u03b9.app j).naturality f\n    end },\n  uniq' := \u03bb 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) (\u03bb 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 \u2964 C) :=\n\u03bb 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 \u2964 C) :=\n\u03bb 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 \u2964 C) :=\n\u03bb J \ud835\udca5, by resetI; apply_instance\n\ninstance functor_category_has_colimits [has_colimits C] : has_colimits (K \u2964 C) :=\n\u03bb J \ud835\udca5, 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\u03bb 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\u03bb 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\u03bb J \ud835\udca5, by resetI; apply_instance\n\ninstance evaluation_preserves_colimits [has_colimits C] (k : K) :\n  preserves_colimits ((evaluation K C).obj k) :=\n\u03bb J \ud835\udca5, 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 \u2964 D` associated to\na function `C \u2192 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 \u2192 free_monoidal_category\n  | Unit : free_monoidal_category\n  | tensor : free_monoidal_category \u2192 free_monoidal_category \u2192 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 \u2192 F C \u2192 Type u\n  | id (X) : hom X X\n  | \u03b1_hom (X Y Z : F C) : hom ((X.tensor Y).tensor Z) (X.tensor (Y.tensor Z))\n  | \u03b1_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  | \u03c1_hom (X : F C) : hom (X.tensor unit) X\n  | \u03c1_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: \u00abexpr \u27f6\u1d50 \u00bb\nlocal infixr:10 \" \u27f6\u1d50 \" => 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 : \u2200 {X Y : F C}, (X \u27f6\u1d50 Y) \u2192 (X \u27f6\u1d50 Y) \u2192 Prop\n  | refl {X Y} (f : X \u27f6\u1d50 Y) : hom_equiv f f\n  | symm {X Y} (f g : X \u27f6\u1d50 Y) : hom_equiv f g \u2192 hom_equiv g f\n  | trans {X Y} {f g h : X \u27f6\u1d50 Y} : hom_equiv f g \u2192 hom_equiv g h \u2192 hom_equiv f h\n  |\n  comp {X Y Z} {f f' : X \u27f6\u1d50 Y} {g g' : Y \u27f6\u1d50 Z} :\n    hom_equiv f f' \u2192 hom_equiv g g' \u2192 hom_equiv (f.comp g) (f'.comp g')\n  |\n  tensor {W X Y Z} {f f' : W \u27f6\u1d50 X} {g g' : Y \u27f6\u1d50 Z} :\n    hom_equiv f f' \u2192 hom_equiv g g' \u2192 hom_equiv (f.tensor g) (f'.tensor g')\n  | comp_id {X Y} (f : X \u27f6\u1d50 Y) : hom_equiv (f.comp (Hom.id _)) f\n  | id_comp {X Y} (f : X \u27f6\u1d50 Y) : hom_equiv ((Hom.id _).comp f) f\n  |\n  assoc {X Y U V : F C} (f : X \u27f6\u1d50 U) (g : U \u27f6\u1d50 V) (h : V \u27f6\u1d50 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\u2081 Y\u2081 Z\u2081 X\u2082 Y\u2082 Z\u2082 : F C} (f\u2081 : X\u2081 \u27f6\u1d50 Y\u2081) (f\u2082 : X\u2082 \u27f6\u1d50 Y\u2082) (g\u2081 : Y\u2081 \u27f6\u1d50 Z\u2081)\n    (g\u2082 : Y\u2082 \u27f6\u1d50 Z\u2082) :\n    hom_equiv ((f\u2081.comp g\u2081).tensor (f\u2082.comp g\u2082)) ((f\u2081.tensor f\u2082).comp (g\u2081.tensor g\u2082))\n  | \u03b1_hom_inv {X Y Z} : hom_equiv ((Hom.\u03b1_hom X Y Z).comp (Hom.\u03b1_inv X Y Z)) (Hom.id _)\n  | \u03b1_inv_hom {X Y Z} : hom_equiv ((Hom.\u03b1_inv X Y Z).comp (Hom.\u03b1_hom X Y Z)) (Hom.id _)\n  |\n  associator_naturality {X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083} (f\u2081 : X\u2081 \u27f6\u1d50 Y\u2081) (f\u2082 : X\u2082 \u27f6\u1d50 Y\u2082) (f\u2083 : X\u2083 \u27f6\u1d50 Y\u2083) :\n    hom_equiv (((f\u2081.tensor f\u2082).tensor f\u2083).comp (Hom.\u03b1_hom Y\u2081 Y\u2082 Y\u2083))\n      ((Hom.\u03b1_hom X\u2081 X\u2082 X\u2083).comp (f\u2081.tensor (f\u2082.tensor f\u2083)))\n  | \u03c1_hom_inv {X} : hom_equiv ((Hom.\u03c1_hom X).comp (Hom.\u03c1_inv X)) (Hom.id _)\n  | \u03c1_inv_hom {X} : hom_equiv ((Hom.\u03c1_inv X).comp (Hom.\u03c1_hom X)) (Hom.id _)\n  |\n  \u03c1_naturality {X Y} (f : X \u27f6\u1d50 Y) :\n    hom_equiv ((f.tensor (Hom.id unit)).comp (Hom.\u03c1_hom Y)) ((Hom.\u03c1_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 \u27f6\u1d50 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.\u03b1_hom W X Y).tensor (Hom.id Z)).comp\n        ((Hom.\u03b1_hom W (X.tensor Y) Z).comp ((Hom.id W).tensor (Hom.\u03b1_hom X Y Z))))\n      ((Hom.\u03b1_hom (W.tensor X) Y Z).comp (Hom.\u03b1_hom W X (Y.tensor Z)))\n  |\n  triangle {X Y} :\n    hom_equiv ((Hom.\u03b1_hom X unit Y).comp ((Hom.id X).tensor (Hom.l_hom Y)))\n      ((Hom.\u03c1_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 \u27f6\u1d50 Y) :=\n  \u27e8HomEquiv,\n    \u27e8fun f => HomEquiv.refl f, fun f g => HomEquiv.symm f g, fun f g h hfg hgh =>\n      HomEquiv.trans hfg hgh\u27e9\u27e9\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 := \u27e6FreeMonoidalCategory.Hom.id _\u27e7\n  comp X Y Z f g :=\n    Quotient.map\u2082 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 \u27e8f\u27e9\n    exact Quotient.sound (id_comp f)\n  comp_id' := by\n    rintro X Y \u27e8f\u27e9\n    exact Quotient.sound (comp_id f)\n  assoc' := by\n    rintro W X Y Z \u27e8f\u27e9 \u27e8g\u27e9 \u27e8h\u27e9\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\u2081 Y\u2081 X\u2082 Y\u2082 :=\n    Quotient.map\u2082 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\u2081 Y\u2081 Z\u2081 X\u2082 Y\u2082 Z\u2082 := by\n    rintro \u27e8f\u2081\u27e9 \u27e8f\u2082\u27e9 \u27e8g\u2081\u27e9 \u27e8g\u2082\u27e9\n    exact Quotient.sound (tensor_comp _ _ _ _)\n  tensorUnit := FreeMonoidalCategory.unit\n  associator X Y Z :=\n    \u27e8\u27e6Hom.\u03b1_hom X Y Z\u27e7, \u27e6Hom.\u03b1_inv X Y Z\u27e7, Quotient.sound \u03b1_hom_inv, Quotient.sound \u03b1_inv_hom\u27e9\n  associator_naturality' X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 :=\n    by\n    rintro \u27e8f\u2081\u27e9 \u27e8f\u2082\u27e9 \u27e8f\u2083\u27e9\n    exact Quotient.sound (associator_naturality _ _ _)\n  leftUnitor X := \u27e8\u27e6Hom.l_hom X\u27e7, \u27e6Hom.l_inv X\u27e7, Quotient.sound l_hom_inv, Quotient.sound l_inv_hom\u27e9\n  leftUnitor_naturality' X Y := by\n    rintro \u27e8f\u27e9\n    exact Quotient.sound (l_naturality _)\n  rightUnitor X :=\n    \u27e8\u27e6Hom.\u03c1_hom X\u27e7, \u27e6Hom.\u03c1_inv X\u27e7, Quotient.sound \u03c1_hom_inv, Quotient.sound \u03c1_inv_hom\u27e9\n  rightUnitor_naturality' X Y := by\n    rintro \u27e8f\u27e9\n    exact Quotient.sound (\u03c1_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 \u27f6\u1d50 Y) (g : Y \u27f6\u1d50 Z) :\n    \u27e6f.comp g\u27e7 = @CategoryStruct.comp (F C) _ _ _ _ \u27e6f\u27e7 \u27e6g\u27e7 :=\n  rfl\n#align category_theory.free_monoidal_category.mk_comp CategoryTheory.FreeMonoidalCategory.mk'_comp\n\n@[simp]\ntheorem mk'_tensor {X\u2081 Y\u2081 X\u2082 Y\u2082 : F C} (f : X\u2081 \u27f6\u1d50 Y\u2081) (g : X\u2082 \u27f6\u1d50 Y\u2082) :\n    \u27e6f.tensor g\u27e7 = @MonoidalCategory.tensorHom (F C) _ _ _ _ _ _ \u27e6f\u27e7 \u27e6g\u27e7 :=\n  rfl\n#align category_theory.free_monoidal_category.mk_tensor CategoryTheory.FreeMonoidalCategory.mk'_tensor\n\n@[simp]\ntheorem mk'_id {X : F C} : \u27e6Hom.id X\u27e7 = \ud835\udfd9 X :=\n  rfl\n#align category_theory.free_monoidal_category.mk_id CategoryTheory.FreeMonoidalCategory.mk'_id\n\n@[simp]\ntheorem mk'_\u03b1_hom {X Y Z : F C} : \u27e6Hom.\u03b1_hom X Y Z\u27e7 = (\u03b1_ X Y Z).Hom :=\n  rfl\n#align category_theory.free_monoidal_category.mk_\u03b1_hom CategoryTheory.FreeMonoidalCategory.mk'_\u03b1_hom\n\n@[simp]\ntheorem mk'_\u03b1_inv {X Y Z : F C} : \u27e6Hom.\u03b1_inv X Y Z\u27e7 = (\u03b1_ X Y Z).inv :=\n  rfl\n#align category_theory.free_monoidal_category.mk_\u03b1_inv CategoryTheory.FreeMonoidalCategory.mk'_\u03b1_inv\n\n@[simp]\ntheorem mk'_\u03c1_hom {X : F C} : \u27e6Hom.\u03c1_hom X\u27e7 = (\u03c1_ X).Hom :=\n  rfl\n#align category_theory.free_monoidal_category.mk_\u03c1_hom CategoryTheory.FreeMonoidalCategory.mk'_\u03c1_hom\n\n@[simp]\ntheorem mk'_\u03c1_inv {X : F C} : \u27e6Hom.\u03c1_inv X\u27e7 = (\u03c1_ X).inv :=\n  rfl\n#align category_theory.free_monoidal_category.mk_\u03c1_inv CategoryTheory.FreeMonoidalCategory.mk'_\u03c1_inv\n\n@[simp]\ntheorem mk'_l_hom {X : F C} : \u27e6Hom.l_hom X\u27e7 = (\u03bb_ 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} : \u27e6Hom.l_inv X\u27e7 = (\u03bb_ 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 \u2297 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 = \ud835\udfd9_ (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 \u2192 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\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Auxiliary definition for `free_monoidal_category.project`. -/\ndef projectObj : F C \u2192 D\n  | free_monoidal_category.of X => f X\n  | free_monoidal_category.unit => \ud835\udfd9_ D\n  | free_monoidal_category.tensor X Y => project_obj X \u2297 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\u2093'. -/\n/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/\n/-- Auxiliary definition for `free_monoidal_category.project`. -/\n@[simp]\ndef projectMapAux : \u2200 {X Y : F C}, (X \u27f6\u1d50 Y) \u2192 (projectObj f X \u27f6 projectObj f Y)\n  | _, _, id _ => \ud835\udfd9 _\n  | _, _, \u03b1_hom _ _ _ => (\u03b1_ _ _ _).Hom\n  | _, _, \u03b1_inv _ _ _ => (\u03b1_ _ _ _).inv\n  | _, _, l_hom _ => (\u03bb_ _).Hom\n  | _, _, l_inv _ => (\u03bb_ _).inv\n  | _, _, \u03c1_hom _ => (\u03c1_ _).Hom\n  | _, _, \u03c1_inv _ => (\u03c1_ _).inv\n  | _, _, comp f g => project_map_aux f \u226b project_map_aux g\n  | _, _, hom.tensor f g => project_map_aux f \u2297 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 \u27f6 Y) \u2192 (projectObj f X \u27f6 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      \u00b7 rfl\n      \u00b7 exact hfg'.symm\n      \u00b7 exact hfg.trans hgh\n      \u00b7 simp only [project_map_aux, hf, hg]\n      \u00b7 simp only [project_map_aux, hfg, hfg']\n      \u00b7 simp only [project_map_aux, category.comp_id]\n      \u00b7 simp only [project_map_aux, category.id_comp]\n      \u00b7 simp only [project_map_aux, category.assoc]\n      \u00b7 simp only [project_map_aux, monoidal_category.tensor_id]\n        rfl\n      \u00b7 simp only [project_map_aux, monoidal_category.tensor_comp]\n      \u00b7 simp only [project_map_aux, iso.hom_inv_id]\n      \u00b7 simp only [project_map_aux, iso.inv_hom_id]\n      \u00b7 simp only [project_map_aux, monoidal_category.associator_naturality]\n      \u00b7 simp only [project_map_aux, iso.hom_inv_id]\n      \u00b7 simp only [project_map_aux, iso.inv_hom_id]\n      \u00b7 simp only [project_map_aux]\n        dsimp [project_obj]\n        exact monoidal_category.right_unitor_naturality _\n      \u00b7 simp only [project_map_aux, iso.hom_inv_id]\n      \u00b7 simp only [project_map_aux, iso.inv_hom_id]\n      \u00b7 simp only [project_map_aux]\n        dsimp [project_obj]\n        exact monoidal_category.left_unitor_naturality _\n      \u00b7 simp only [project_map_aux]\n        exact monoidal_category.pentagon _ _ _ _\n      \u00b7 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 \u2192 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  \u03b5 := \ud835\udfd9 _\n  \u03bc X Y := \ud835\udfd9 _\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 \u2192 submodule R M \u2192 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 \u2192\u2097[R] P) (h : function.injective f)\n  [is_artinian R P] : is_artinian R M :=\n\u27e8subrelation.wf\n  (\u03bb 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))\u27e9\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 \u2264 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 \u2192\u2097[R] P) (hf : function.surjective f)\n  [is_artinian R M] : is_artinian R P :=\n\u27e8subrelation.wf\n  (\u03bb 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 _ _))\u27e9\nvariable {M}\n\ntheorem is_artinian_of_linear_equiv (f : M \u2243\u2097[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 \u2192\u2097[R] N) (g : N \u2192\u2097[R] P)\n  (hf : function.injective f)\n  (hg : function.surjective g)\n  (h : f.range = g.ker) :\n  is_artinian R N :=\n\u27e8well_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])\u27e9\n\ninstance is_artinian_prod [is_artinian R M]\n  [is_artinian R P] : is_artinian R (M \u00d7 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\u27e8fintype.well_founded_of_trans_of_irrefl _\u27e9\n\nlocal attribute [elab_as_eliminator] fintype.induction_empty_option\n\ninstance is_artinian_pi {R \u03b9 : Type*} [fintype \u03b9] : \u03a0 {M : \u03b9 \u2192 Type*} [ring R]\n  [\u03a0 i, add_comm_group (M i)], by exactI \u03a0 [\u03a0 i, module R (M i)],\n  by exactI \u03a0 [\u2200 i, is_artinian R (M i)], is_artinian R (\u03a0 i, M i) :=\nfintype.induction_empty_option\n  (begin\n    introsI \u03b1 \u03b2 e h\u03b1 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 \u03b1 _ ih M _ _ _ _,\n     exact is_artinian_of_linear_equiv\n        (linear_equiv.pi_option_equiv_prod R).symm,\n  end)\n  \u03b9\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 `\u03b9 \u2192 \u211d` is finite dimensional over `\u211d`). -/\ninstance is_artinian_pi' {R \u03b9 M : Type*} [ring R] [add_comm_group M] [module R M] [fintype \u03b9]\n  [is_artinian R M] : is_artinian R (\u03b9 \u2192 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 \u2194 well_founded ((<) : submodule R M \u2192 submodule R M \u2192 Prop) :=\n\u27e8\u03bb h, h.1, is_artinian.mk\u27e9\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 \u2192 M)) : s.finite :=\nbegin\n  refine classical.by_contradiction (\u03bb hf, (rel_embedding.well_founded_iff_no_descending_seq.1\n    (well_founded_submodule_lt R M)).elim' _),\n  have f : \u2115 \u21aa s, from @infinite.nat_embedding s \u27e8\u03bb f, hf \u27e8f\u27e9\u27e9,\n  have : \u2200 n, (coe \u2218 f) '' {m | n \u2264 m} \u2286 s,\n  { rintros n x \u27e8y, hy\u2081, hy\u2082\u27e9, subst hy\u2082, exact (f y).2 },\n  have : \u2200 a b : \u2115, a \u2264 b \u2194\n    span R ((coe \u2218 f) '' {m | b \u2264 m}) \u2264 span R ((coe \u2218 f) '' {m | a \u2264 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 \u27e8\u03bb hab x, le_trans hab, \u03bb h, (h _ (le_refl _))\u27e9 },\n  exact \u27e8\u27e8\u03bb n, span R ((coe \u2218 f) '' {m | n \u2264 m}),\n      \u03bb x y, by simp [le_antisymm_iff, (this _ _).symm] {contextual := tt}\u27e9,\n    begin\n      intros a b,\n      conv_rhs { rw [gt, lt_iff_le_not_le, this, this, \u2190 lt_iff_le_not_le] },\n      simp\n    end\u27e9\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  (\u2200 a : set $ submodule R M, a.nonempty \u2192 \u2203 M' \u2208 a, \u2200 I \u2208 a, I \u2264 M' \u2192 I = M') \u2194\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  \u2203 M' \u2208 a, \u2200 I \u2208 a, I \u2264 M' \u2192 I = M' :=\nset_has_minimal_iff_artinian.mpr \u2039_\u203a a ha\n\n/-- A module is Artinian iff every decreasing chain of submodules stabilizes. -/\ntheorem monotone_stabilizes_iff_artinian :\n  (\u2200 (f : \u2115 \u2192\u2098 order_dual (submodule R M)), \u2203 n, \u2200 m, n \u2264 m \u2192 f n = f m)\n    \u2194 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 : \u2115 \u2192\u2098 order_dual (submodule R M)) :\n  \u2203 n, \u2200 m, n \u2264 m \u2192 f n = f m :=\nmonotone_stabilizes_iff_artinian.mpr \u2039_\u203a f\n\n/-- If `\u2200 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 \u2192 Prop}\n  (hgt : \u2200 I, (\u2200 J < I, P J) \u2192 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 \u2192\u2097[R] M) : \u2203 n : \u2115, n \u2260 0 \u2227 (f ^ n).ker \u2294 (f ^ n).range = \u22a4 :=\nbegin\n  obtain \u27e8n, w\u27e9 := monotone_stabilizes_iff_artinian.mpr I\n    (f.iterate_range.comp \u27e8\u03bb n, n+1, \u03bb n m w, by linarith\u27e9),\n  specialize w ((n + 1) + n) (by linarith),\n  dsimp at w,\n  refine \u27e8n + 1, nat.succ_ne_zero _, _\u27e9,\n  simp_rw [eq_top_iff', mem_sup],\n  intro x,\n  have : (f^(n + 1)) x \u2208 (f ^ ((n + 1) + n + 1)).range,\n  { rw \u2190 w, exact mem_range_self _ },\n  rcases this with \u27e8y, hy\u27e9,\n  use x - (f ^ (n+1)) y,\n  split,\n  { rw [linear_map.mem_ker, linear_map.map_sub, \u2190 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 \u2192\u2097[R] M) (s : injective f) : surjective f :=\nbegin\n  obtain \u27e8n, ne, w\u27e9 := 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 \u2192\u2097[R] M) (s : injective f) : bijective f :=\n\u27e8s, is_artinian.surjective_of_injective_endomorphism f s\u27e9\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 \u22a4,\nis eventually \u22a4.\n-/\nlemma is_artinian.disjoint_partial_infs_eventually_top [I : is_artinian R M]\n  (f : \u2115 \u2192 submodule R M) (h : \u2200 n, disjoint\n    (partial_sups (order_dual.to_dual \u2218 f) n) (order_dual.to_dual (f (n+1)))) :\n  \u2203 n : \u2115, \u2200 m, n \u2264 m \u2192 f m = \u22a4  :=\nbegin\n  -- A little off-by-one cleanup first:\n  suffices t : \u2203 n : \u2115, \u2200 m, n \u2264 m \u2192 order_dual.to_dual f (m+1) = \u22a4,\n  { obtain \u27e8n, w\u27e9 := 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 \u27e8n, w\u27e9 := monotone_stabilizes_iff_artinian.mpr I (partial_sups (order_dual.to_dual \u2218 f)),\n  exact \u27e8n, (\u03bb m p, eq_bot_of_disjoint_absorbs (h m)\n    ((eq.symm (w (m + 1) (le_add_right p))).trans (w m p)))\u27e9\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 \u2295 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 \u00d7 N \u2192\u2097[R] M) (i : injective f) : N \u2243\u2097[R] punit.{w+1} :=\n-- begin\n--   apply nonempty.some,\n--   obtain \u27e8n, w\u27e9 := 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 \u2194 is_artinian R R :=\n\u27e8\u03bb h, h.1, @is_artinian_ring.mk _ _\u27e9\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 \u29f8 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 \u22a2,\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 \u27e8s, hs\u27e9 := 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 : \u2200 x \u2208 s, x \u2208 N, from \u03bb x hx, hs \u25b8 submodule.subset_span hx,\n  refine @@is_artinian_of_surjective ((\u2191s : set M) \u2192 R) _ _ _ (pi.module _ _ _)\n    _ _ _ is_artinian_pi,\n  { fapply linear_map.mk,\n    { exact \u03bb f, \u27e8\u2211 i in s.attach, f i \u2022 i.1, N.sum_mem (\u03bb c _, N.smul_mem _ $ this _ c.2)\u27e9 },\n    { intros f g, apply subtype.eq,\n      change \u2211 i in s.attach, (f i + g i) \u2022 _ = _,\n      simp only [add_smul, finset.sum_add_distrib], refl },\n    { intros c f, apply subtype.eq,\n      change \u2211 i in s.attach, (c \u2022 f i) \u2022 _ = _,\n      simp only [smul_eq_mul, mul_smul],\n      exact finset.smul_sum.symm } },\n  rintro \u27e8n, hn\u27e9, change n \u2208 N at hn,\n  rw [\u2190 hs, \u2190 set.image_id \u2191s, finsupp.mem_span_image_iff_total] at hn,\n  rcases hn with \u27e8l, hl1, hl2\u27e9,\n  refine \u27e8\u03bb x, l x, subtype.ext _\u27e9,\n  change \u2211 i in s.attach, l i \u2022 (i : M) = n,\n  rw [@finset.sum_attach M M s _ (\u03bb i, l i \u2022 i), \u2190 hl2,\n      finsupp.total_apply, finsupp.sum, eq_comm],\n  refine finset.sum_subset hl1 (\u03bb 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 : (\u22a4 : submodule R M).fg) : is_artinian R M :=\nhave is_artinian R (\u22a4 : submodule R M), from is_artinian_of_fg_of_artinian _ h,\nby exactI is_artinian_of_linear_equiv (linear_equiv.of_top (\u22a4 : 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 \u27e8A, hA, rfl\u27e9)\n\ntheorem is_artinian_ring_of_surjective (R) [comm_ring R] (S) [comm_ring S]\n  (f : R \u2192+* 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 \u22a2,\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 \u2192+* 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 \u2243+* 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 (\u22a5 : ideal R)) :=\nbegin\n  let Jac := ideal.jacobson (\u22a5 : ideal R),\n  let f : \u2115 \u2192\u2098 order_dual (ideal R) := \u27e8\u03bb n, Jac ^ n, \u03bb _ _ h, ideal.pow_le_pow h\u27e9,\n  obtain \u27e8n, hn\u27e9 : \u2203 n, \u2200 m, n \u2264 m \u2192 Jac ^ n = Jac ^ m := is_artinian.monotone_stabilizes f,\n  refine \u27e8n, _\u27e9,\n  let J : ideal R := annihilator (Jac ^ n),\n  suffices : J = \u22a4,\n  { have hJ : J \u2022 Jac ^ n = \u22a5 := annihilator_smul (Jac ^ n),\n    simpa only [this, top_smul, ideal.zero_eq_bot] using hJ },\n  by_contradiction hJ, change J \u2260 \u22a4 at hJ,\n  rcases is_artinian.set_has_minimal {J' : ideal R | J < J'} \u27e8\u22a4, hJ.lt_top\u27e9\n    with \u27e8J', hJJ' : J < J', hJ' : \u2200 I, J < I \u2192 I \u2264 J' \u2192 I = J'\u27e9,\n  rcases set_like.exists_of_lt hJJ' with \u27e8x, hxJ', hxJ\u27e9,\n  obtain rfl : J \u2294 ideal.span {x} = J',\n  { refine hJ' (J \u2294 ideal.span {x}) _ _,\n    { rw set_like.lt_iff_le_and_exists,\n      exact \u27e8le_sup_left, \u27e8x, mem_sup_right (mem_span_singleton_self x), hxJ\u27e9\u27e9 },\n    { exact (sup_le hJJ'.le (span_le.2 (singleton_subset_iff.2 hxJ'))) } },\n  have : J \u2294 Jac \u2022 ideal.span {x} \u2264 J \u2294 ideal.span {x},\n    from sup_le_sup_left (smul_le.2 (\u03bb _ _ _, submodule.smul_mem _ _)) _,\n  have : Jac * ideal.span {x} \u2264 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 (\u03bb h, H $ h.symm \u25b8 le_sup_right) },\n  have : ideal.span {x} * Jac ^ (n + 1) \u2264 \u22a5,\n    calc ideal.span {x} * Jac ^ (n + 1) = ideal.span {x} * Jac * Jac ^ n :\n      by rw [pow_succ, \u2190 mul_assoc]\n    ... \u2264 J * Jac ^ n : mul_le_mul (by rwa mul_comm) (le_refl _)\n    ... = \u22a5 : by simp [J],\n  refine hxJ (mem_annihilator.2 (\u03bb y hy, (mem_bot R).1 _)),\n  refine this (mul_mem_mul (mem_span_singleton_self x) _),\n  rwa [\u2190 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\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory.functor\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} 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 \u2964 D) : Prop :=\n(map_zero' : \u2200 (X Y : C), F.map (0 : X \u27f6 Y) = 0 . obviously)\n\n@[simp]\nprotected lemma map_zero (F : C \u2964 D) [preserves_zero_morphisms F] (X Y : C) :\n  F.map (0 : X \u27f6 Y) = 0 :=\npreserves_zero_morphisms.map_zero' _ _\n\nlemma zero_of_map_zero (F : C \u2964 D) [preserves_zero_morphisms F] [faithful F] {X Y : C}\n  (f : X \u27f6 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 \u2964 D) [preserves_zero_morphisms F] [faithful F] {X Y : C} {f : X \u27f6 Y} :\n  F.map f = 0 \u2194 f = 0 :=\n\u27e8F.zero_of_map_zero _, by { rintro rfl, exact F.map_zero _ _ }\u27e9\n\n@[priority 100]\ninstance preserves_zero_morphisms_of_is_left_adjoint (F : C \u2964 D) [is_left_adjoint F] :\n  preserves_zero_morphisms F :=\n{ map_zero' := \u03bb X Y, let adj := adjunction.of_left_adjoint F in\n  begin\n    calc F.map (0 : X \u27f6 Y) = F.map 0 \u226b F.map (adj.unit.app Y) \u226b adj.counit.app (F.obj Y) : _\n    ... = F.map 0 \u226b F.map ((right_adjoint F).map (0 : F.obj X \u27f6 _)) \u226b adj.counit.app (F.obj Y) : _\n    ... = 0 : _,\n    { rw adjunction.left_triangle_components, exact (category.comp_id _).symm },\n    { simp only [\u2190 category.assoc, \u2190 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 \u2964 D) [is_right_adjoint G] :\n  preserves_zero_morphisms G :=\n{ map_zero' := \u03bb X Y, let adj := adjunction.of_right_adjoint G in\n  begin\n    calc G.map (0 : X \u27f6 Y) = adj.unit.app (G.obj X) \u226b G.map (adj.counit.app X) \u226b G.map 0 : _\n    ... = adj.unit.app (G.obj X) \u226b G.map ((left_adjoint G).map (0 : _ \u27f6 G.obj X)) \u226b G.map 0 : _\n    ... = 0 : _,\n    { rw adjunction.right_triangle_components_assoc },\n    { simp only [\u2190 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 \u2964 D) [full F] : preserves_zero_morphisms F :=\n{ map_zero' := \u03bb X Y, calc\n  F.map (0 : X \u27f6 Y) = F.map (0 \u226b (F.preimage (0 : F.obj Y \u27f6 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 \u2964 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 \u2245 0 :=\n{ hom := 0,\n  inv := 0,\n  hom_inv_id' := by rw [\u2190 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 \u2245 0) : preserves_zero_morphisms F :=\n{ map_zero' := \u03bb X Y, calc\n  F.map (0 : X \u27f6 Y) = F.map (0 : X \u27f6 0) \u226b F.map 0 : by rw [\u2190 functor.map_comp, comp_zero]\n                ... = F.map 0 \u226b (i.hom \u226b i.inv) \u226b 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\u2081} 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\u2081} 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 `\u2200 n : \u2115, prime n \u2192 n \u2264 100`,\n`slim_check` requires that `\u2115` 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 \u2115 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\u2264 100` will be tested. If it is false, `n` is a counter-example of `\u2200\nn : \u2115, prime n \u2192 n \u2264 100` and the test fails. If `n \u2264 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 \u03b1` provides ways of creating examples of type `\u03b1`,\nand given such an example `x : \u03b1`, 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 `\u2115 \u2192 \u2115`.\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 \u03b1` given a sampling function and a\nshrinking function for arbitrary `\u03b1`.\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 (\u03b1 : Type u)\n\nlocal infix ` \u227a `:50 := has_well_founded.r\n\n/-- `sizeof_lt x y` compares the sizes of `x` and `y`. -/\ndef sizeof_lt {\u03b1} [has_sizeof \u03b1] (x y : \u03b1) := sizeof x < sizeof y\n\n/-- `shrink_fn \u03b1` is the type of functions that shrink an\nargument of type `\u03b1` -/\n@[reducible]\ndef shrink_fn (\u03b1 : Type*) [has_sizeof \u03b1] := \u03a0 x : \u03b1, lazy_list { y : \u03b1 // sizeof_lt y x }\n\n/-- `sampleable \u03b1` provides ways of creating examples of type `\u03b1`,\nand given such an example `x : \u03b1`, gives us a way to shrink it\nand find simpler examples.  -/\nclass sampleable :=\n[wf : has_sizeof \u03b1]\n(sample [] : gen \u03b1)\n(shrink : \u03a0 x : \u03b1, lazy_list { y : \u03b1 // @sizeof _ wf y < @sizeof _ wf x } := \u03bb _, 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 \u03b1` given a sampling function and a shrinking function for\narbitrary `\u03b1` -/\nclass sampleable_functor (F : Type u \u2192 Type v) [functor F] :=\n[wf : \u03a0 \u03b1 [has_sizeof \u03b1], has_sizeof (F \u03b1)]\n(sample [] : \u2200 {\u03b1}, gen \u03b1 \u2192 gen (F \u03b1))\n(shrink : \u2200 \u03b1 [has_sizeof \u03b1], shrink_fn \u03b1 \u2192 shrink_fn (F \u03b1))\n(p_repr : \u2200 \u03b1, has_repr \u03b1 \u2192 has_repr (F \u03b1))\n\n/-- `sampleable_bifunctor F` makes it possible to create samples of\nand shrink `F \u03b1 \u03b2` given a sampling function and a shrinking function\nfor arbitrary `\u03b1` and `\u03b2` -/\nclass sampleable_bifunctor (F : Type u \u2192 Type v \u2192 Type w) [bifunctor F] :=\n[wf : \u03a0 \u03b1 \u03b2 [has_sizeof \u03b1] [has_sizeof \u03b2], has_sizeof (F \u03b1 \u03b2)]\n(sample [] : \u2200 {\u03b1 \u03b2}, gen \u03b1 \u2192 gen \u03b2 \u2192 gen (F \u03b1 \u03b2))\n(shrink : \u2200 \u03b1 \u03b2 [has_sizeof \u03b1] [has_sizeof \u03b2], shrink_fn \u03b1 \u2192 shrink_fn \u03b2 \u2192 shrink_fn (F \u03b1 \u03b2))\n(p_repr : \u2200 \u03b1 \u03b2, has_repr \u03b1 \u2192 has_repr \u03b2 \u2192 has_repr (F \u03b1 \u03b2))\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 `\u2115 \u2192 \u2115`.\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 (\u03b1 : Sort u) :=\n(proxy_repr : Type v)\n[wf : has_sizeof proxy_repr]\n(interp [] : proxy_repr \u2192 \u03b1 . 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 {\u03b1} [sampleable \u03b1] [has_repr \u03b1] : sampleable_ext \u03b1 :=\n{ proxy_repr := \u03b1,\n  sample := sampleable.sample \u03b1,\n  shrink := shrink }\n\ninstance sampleable.functor {\u03b1} {F} [functor F] [sampleable_functor F] [sampleable \u03b1] :\n  sampleable (F \u03b1) :=\n{ wf := _,\n  sample := sampleable_functor.sample F (sampleable.sample \u03b1),\n  shrink := sampleable_functor.shrink \u03b1 sampleable.shrink }\n\ninstance sampleable.bifunctor {\u03b1 \u03b2} {F} [bifunctor F] [sampleable_bifunctor F] [sampleable \u03b1]\n  [sampleable \u03b2] : sampleable (F \u03b1 \u03b2) :=\n{ wf := _,\n  sample := sampleable_bifunctor.sample F (sampleable.sample \u03b1) (sampleable.sample \u03b2),\n  shrink := sampleable_bifunctor.shrink \u03b1 \u03b2 sampleable.shrink sampleable.shrink }\n\nset_option default_priority 100\n\ninstance sampleable_ext.functor {\u03b1} {F} [functor F] [sampleable_functor F] [sampleable_ext \u03b1] :\n  sampleable_ext (F \u03b1) :=\n{ wf := _,\n  proxy_repr := F (proxy_repr \u03b1),\n  interp := functor.map (interp _),\n  sample := sampleable_functor.sample F (sampleable_ext.sample \u03b1),\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 {\u03b1 \u03b2} {F} [bifunctor F] [sampleable_bifunctor F]\n  [sampleable_ext \u03b1] [sampleable_ext \u03b2] : sampleable_ext (F \u03b1 \u03b2) :=\n{ wf := _,\n  proxy_repr := F (proxy_repr \u03b1) (proxy_repr \u03b2),\n  interp := bifunctor.bimap (interp _) (interp _),\n  sample := sampleable_bifunctor.sample F (sampleable_ext.sample \u03b1) (sampleable_ext.sample \u03b2),\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 : \u2115) : \u03a0 n : \u2115, n \u2264 k \u2192\n  list { m : \u2115 // has_well_founded.r m k } \u2192 list { m : \u2115 // has_well_founded.r m k }\n| n hn ls :=\nif h : n \u2264 1\n  then ls.reverse\n  else\n    have h\u2082 : 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\u2082),\n    have n / 2 < n, by simpa,\n    let m := n / 2 in\n    have h\u2080 : m \u2264 k, from le_trans (le_of_lt this) hn,\n    have h\u2083 : 0 < m,\n      by simp only [m, lt_iff_add_one_le, zero_add]; rw [le_div_iff_mul_le]; linarith,\n    have h\u2081 : k - m < k,\n      from nat.sub_lt (lt_of_lt_of_le h\u2082 hn) h\u2083,\n    nat.shrink' m h\u2080 (\u27e8k - m, h\u2081\u27e9 :: 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 : \u2115) : list { m : \u2115 // has_well_founded.r m n } :=\nif h : n > 0 then\n  have \u2200 k, 1 < k \u2192 n / k < n, from\n    \u03bb 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  \u27e8n/11, this _ (by norm_num)\u27e9 :: \u27e8n/3, this _ (by norm_num)\u27e9 :: nat.shrink' n n (le_refl _) []\nelse\n  []\n\nopen gen\n\n/--\nTransport a `sampleable` instance from a type `\u03b1` to a type `\u03b2` 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 (\u03b1 : Type u) {\u03b2 : Type u} [sampleable \u03b1] (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b1)\n  (h : \u2200 (a : \u03b1), sizeof (g (f a)) \u2264 sizeof a) : sampleable \u03b2 :=\n{ wf := \u27e8 sizeof \u2218 g \u27e9,\n  sample := f <$> sample \u03b1,\n  shrink := \u03bb x,\n    have \u2200 a,  sizeof a < sizeof (g x) \u2192 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 \u2115 :=\n{ sample := sized $ \u03bb sz, freq [(1, coe <$> choose_any (fin $ succ (sz^3))),\n                                (3, coe <$> choose_any (fin $ succ sz))] dec_trivial,\n  shrink :=  \u03bb 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 {\u03b1} [has_to_string \u03b1] [sampleable \u03b1]\n  (p : \u03b1 \u2192 Prop) [decidable_pred p] :\n  \u03b1 \u2192 option \u03b1 :=\nwell_founded.fix has_well_founded.wf $ \u03bb x f_rec,\n  do trace sformat!\"{x} : {(shrink x).to_list}\" $ pure (),\n     y \u2190 (shrink x).find (\u03bb 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 \u2115 fin.of_nat' subtype.val $\n\u03bb i, (mod_le _ _ : i % n \u2264 i)\n\n@[priority 100]\ninstance fin.sampleable' {n} : sampleable (fin (succ n)) :=\nsampleable.lift \u2115 fin.of_nat subtype.val $\n\u03bb i, (mod_le _ _ : i % succ n \u2264 i)\n\ninstance pnat.sampleable : sampleable \u2115+ :=\nsampleable.lift \u2115 nat.succ_pnat pnat.nat_pred $ \u03bb 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 \u2124 := \u27e8 int.nat_abs \u27e9\n\nlocal attribute [instance, priority 2000] int.has_sizeof\n\ninstance int.sampleable : sampleable \u2124 :=\n{ wf := _,\n  sample := sized $ \u03bb sz,\n          freq [(1, subtype.val <$> choose (-(sz^3 + 1) : \u2124) (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    \u03bb x, lazy_list.of_list $ (nat.shrink $ int.nat_abs x).bind $\n    \u03bb \u27e8y,h\u27e9, [\u27e8y, h\u27e9, \u27e8-y, by dsimp [sizeof,has_sizeof.sizeof]; rw int.nat_abs_neg; exact h \u27e9] }\n\ninstance bool.sampleable : sampleable bool :=\n{ wf := \u27e8 \u03bb b, if b then 1 else 0 \u27e9,\n  sample := do { x \u2190 choose_any bool,\n                 return x },\n  shrink := \u03bb b, if h : b then lazy_list.singleton \u27e8ff, by cases h; unfold_wf\u27e9\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 {\u03b1 \u03b2} [has_sizeof \u03b1] [has_sizeof \u03b2]\n  (shr_a : shrink_fn \u03b1) (shr_b : shrink_fn \u03b2) : shrink_fn (\u03b1 \u00d7 \u03b2)\n| \u27e8x\u2080,x\u2081\u27e9 :=\n  let xs\u2080 : lazy_list { y : \u03b1 \u00d7 \u03b2 // sizeof_lt y (x\u2080,x\u2081) } :=\n          (shr_a x\u2080).map $ subtype.map (\u03bb a, (a, x\u2081))\n                           (\u03bb x h, by dsimp [sizeof_lt]; unfold_wf; apply h),\n      xs\u2081 : lazy_list { y : \u03b1 \u00d7 \u03b2 // sizeof_lt y (x\u2080,x\u2081) } :=\n          (shr_b x\u2081).map $ subtype.map (\u03bb a, (x\u2080, a))\n                           (\u03bb x h, by dsimp [sizeof_lt]; unfold_wf; apply h) in\n  xs\u2080.append xs\u2081\n\ninstance prod.sampleable : sampleable_bifunctor.{u v} prod :=\n{ wf := _,\n  sample := \u03bb \u03b1 \u03b2 sama samb, do\n              { \u27e8x\u27e9 \u2190 (uliftable.up $ sama : gen (ulift.{max u v} \u03b1)),\n                \u27e8y\u27e9 \u2190 (uliftable.up $ samb : gen (ulift.{max u v} \u03b2)),\n                pure (x,y) },\n  shrink := @prod.shrink,\n  p_repr := @prod.has_repr }\n\ninstance sigma.sampleable {\u03b1 \u03b2} [sampleable \u03b1] [sampleable \u03b2] : sampleable (\u03a3 _ : \u03b1, \u03b2) :=\nsampleable.lift (\u03b1 \u00d7 \u03b2) (\u03bb \u27e8x,y\u27e9, \u27e8x,y\u27e9) (\u03bb \u27e8x,y\u27e9, \u27e8x,y\u27e9) $ \u03bb \u27e8x,y\u27e9, le_refl _\n\n/-- shrinking function for sum types -/\ndef sum.shrink {\u03b1 \u03b2} [has_sizeof \u03b1] [has_sizeof \u03b2] (shrink_\u03b1 : shrink_fn \u03b1)\n  (shrink_\u03b2 : shrink_fn \u03b2) : shrink_fn (\u03b1 \u2295 \u03b2)\n| (sum.inr x) := (shrink_\u03b2 x).map $ subtype.map sum.inr $ \u03bb a,\n  by dsimp [sizeof_lt]; unfold_wf; solve_by_elim\n| (sum.inl x) := (shrink_\u03b1 x).map $ subtype.map sum.inl $ \u03bb a,\n  by dsimp [sizeof_lt]; unfold_wf; solve_by_elim\n\ninstance sum.sampleable : sampleable_bifunctor.{u v} sum :=\n{ wf := _,\n  sample := \u03bb (\u03b1 : Type u) (\u03b2 : Type v) sam_\u03b1 sam_\u03b2,\n            (@uliftable.up_map gen.{u} gen.{max u v} _ _ _ _ (@sum.inl \u03b1 \u03b2) sam_\u03b1 <|>\n             @uliftable.up_map gen.{v} gen.{max v u} _ _ _ _ (@sum.inr \u03b1 \u03b2) sam_\u03b2),\n  shrink := \u03bb \u03b1 \u03b2 I\u03b1 I\u03b2 shr_\u03b1 shr_\u03b2, @sum.shrink _ _ I\u03b1 I\u03b2 shr_\u03b1 shr_\u03b2,\n  p_repr := @sum.has_repr }\n\ninstance rat.sampleable : sampleable \u211a :=\nsampleable.lift (\u2124 \u00d7 \u2115+) (\u03bb x, prod.cases_on x rat.mk_pnat) (\u03bb r, (r.num, \u27e8r.denom, r.pos\u27e9)) $\nbegin\n  intro i,\n  rcases i with \u27e8x,\u27e8y,hy\u27e9\u27e9; unfold_wf;\n  dsimp [rat.mk_pnat],\n  mono*,\n  { rw [\u2190 int.coe_nat_le, \u2190 int.abs_eq_nat_abs, \u2190 int.abs_eq_nat_abs],\n    apply int.abs_div_le_abs },\n  { change _ - 1 \u2264 y-1,\n    apply nat.sub_le_sub_right,\n    apply nat.div_le_of_le_mul,\n    suffices : 1 * y \u2264 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 \u2190 choose_nat 0 length dec_trivial,\n                 if x.val = 0 then do\n                   n \u2190 sample \u2115,\n                   pure $ char.of_nat n\n                 else do\n                   i \u2190 choose_nat 0 (characters.length - 1) dec_trivial,\n                   pure (characters.mk_iterator.nextn i).curr },\n  shrink := \u03bb _, lazy_list.nil }\n\ninstance char.sampleable : sampleable char :=\nsampleable_char 3 \" 0123abcABC:,;`\\\\/\"\n\nvariables {\u03b1}\n\nsection list_shrink\n\nvariables [has_sizeof \u03b1] (shr : \u03a0 x : \u03b1, lazy_list { y : \u03b1 // sizeof_lt y x })\n\n\n\nlemma list.sizeof_cons_lt_right (a b : \u03b1) {xs : list \u03b1} (h : sizeof a < sizeof b) :\n  sizeof (a :: xs) < sizeof (b :: xs) :=\nby unfold_wf; assumption\n\nlemma list.sizeof_cons_lt_left (x : \u03b1) {xs xs' : list \u03b1} (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 \u03b1} (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 \u03b1) : 1 \u2264 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 : \u2115) (hk : 0 < k) : \u03a0 (xs : list \u03b1) n,\n  n = xs.length \u2192 lazy_list { ys : list \u03b1 // 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 \u27e8[], this \u27e9\n  else\n    have h\u2082 : k < xs.length, from hn \u25b8 lt_of_le_of_ne (le_of_not_gt hkn) hkn',\n    match list.split_at k xs, rfl : \u03a0 ys, ys = list.split_at k xs \u2192 _ with\n    |  \u27e8xs\u2081,xs\u2082\u27e9, h :=\n      have h\u2084 : xs\u2081 = xs.take k,\n        by simp only [list.split_at_eq_take_drop, prod.mk.inj_iff] at h; tauto,\n      have h\u2083 : xs\u2082 = xs.drop k,\n        by simp only [list.split_at_eq_take_drop, prod.mk.inj_iff] at h; tauto,\n      have sizeof xs\u2082 < sizeof xs,\n        by rw h\u2083; solve_by_elim [list.sizeof_drop_lt_sizeof_of_lt_length],\n      have h\u2081 : n - k = xs\u2082.length,\n        by simp only [h\u2083, \u2190hn, list.length_drop],\n      have h\u2085 : \u2200 (a : list \u03b1), sizeof_lt a xs\u2082 \u2192 sizeof_lt (xs\u2081 ++ a) xs,\n        by intros a h; rw [\u2190 list.take_append_drop k xs, \u2190 h\u2083, \u2190 h\u2084];\n          solve_by_elim [list.sizeof_append_lt_left],\n      lazy_list.cons \u27e8xs\u2082, this\u27e9 $ subtype.map ((++) xs\u2081) h\u2085 <$> list.shrink_removes xs\u2082 (n - k) h\u2081\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 \u03b1)\n| [] := lazy_list.nil\n| (x :: xs) :=\n  lazy_list.append\n    (subtype.map (\u03bb x', x' :: xs) (\u03bb a,  list.sizeof_cons_lt_right _ _) <$> shr x)\n    (subtype.map ((::) x) (\u03bb _, 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 \u03b1) :\n  lazy_list { ys : list \u03b1 // sizeof_lt ys xs } :=\nlet n := xs.length in\nlazy_list.append\n  ((lazy_list.cons n $ (shrink n).reverse.map subtype.val).bind (\u03bb 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 := \u03bb \u03b1 sam_\u03b1, list_of sam_\u03b1,\n  shrink := \u03bb \u03b1 I\u03b1 shr_\u03b1, @list.shrink_with _ I\u03b1 shr_\u03b1,\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 := \u03bb _, 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 \u2124)`\nwill result in the list being cut down but individual\nintegers being kept as is. -/\ndef no_shrink (\u03b1 : Type*) := \u03b1\n\ninstance no_shrink.inhabited {\u03b1} [inhabited \u03b1] : inhabited (no_shrink \u03b1) :=\n\u27e8 (default \u03b1 : \u03b1) \u27e9\n\n/-- Introduction of the `no_shrink` type. -/\ndef no_shrink.mk {\u03b1} (x : \u03b1) : no_shrink \u03b1 := x\n\n/-- Selector of the `no_shrink` type. -/\ndef no_shrink.get {\u03b1} (x : no_shrink \u03b1) : \u03b1 := x\n\ninstance no_shrink.sampleable {\u03b1} [sampleable \u03b1] : sampleable (no_shrink \u03b1) :=\n{ sample := no_shrink.mk <$> sample \u03b1 }\n\ninstance string.sampleable : sampleable string :=\n{ sample := do { x \u2190 list_of (sample char), pure x.as_string },\n  .. sampleable.lift (list char) list.as_string string.to_list $ \u03bb _, le_refl _ }\n\n/-- implementation of `sampleable (tree \u03b1)` -/\ndef tree.sample (sample : gen \u03b1) : \u2115 \u2192 gen (tree \u03b1) | 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 {\u03b1 : Type*} [has_sizeof \u03b1] (t : \u03b1)\n  (sh : \u03a0 x : \u03b1, sizeof_lt x t \u2192 lazy_list { y : \u03b1 // sizeof_lt y x }) :\n  shrink_fn { t' : \u03b1 // sizeof_lt t' t }\n| \u27e8t',ht'\u27e9 := (\u03bb t'' : { y : \u03b1 // sizeof_lt y t' },\n    \u27e8\u27e8t''.val, lt_trans t''.property ht'\u27e9, t''.property\u27e9 ) <$> sh t' ht'\n\nlemma tree.one_le_sizeof {\u03b1} [has_sizeof \u03b1] (t : tree \u03b1) : 1 \u2264 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 \u03b1]\n  (shrink_a : \u03a0 x : \u03b1, shrink_fn { y : \u03b1 // sizeof_lt y x } \u2192\n    list (lazy_list { y : \u03b1 // sizeof_lt y x })) :\n  shrink_fn \u03b1 :=\nwell_founded.fix (sizeof_measure_wf _) $ \u03bb t f_rec,\nlazy_list.join\n    (lazy_list.of_list $\n      shrink_a t $ \u03bb \u27e8t', h\u27e9, rec_shrink _ f_rec _)\n\nlemma rec_shrink_with_eq [has_sizeof \u03b1]\n  (shrink_a : \u03a0 x : \u03b1, shrink_fn { y : \u03b1 // sizeof_lt y x } \u2192\n    list (lazy_list { y : \u03b1 // sizeof_lt y x }))\n  (x : \u03b1) :\n  rec_shrink_with shrink_a x =\n  lazy_list.join\n    (lazy_list.of_list $ shrink_a x $ \u03bb t', rec_shrink _ (\u03bb x h', rec_shrink_with shrink_a x) _) :=\nbegin\n  conv_lhs { rw [rec_shrink_with, well_founded.fix_eq], },\n  congr, ext \u27e8y, h\u27e9, 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 \u03b1] (shrink_a : shrink_fn \u03b1) : shrink_fn (tree \u03b1) :=\nrec_shrink_with $ \u03bb t,\nmatch t with\n| tree.nil := \u03bb f_rec, []\n| (tree.node x t\u2080 t\u2081) :=\n\u03bb f_rec,\n  have h\u2082 : sizeof_lt tree.nil (tree.node x t\u2080 t\u2081),\n    by clear _match; have := tree.one_le_sizeof t\u2080;\n       dsimp [sizeof_lt, sizeof, has_sizeof.sizeof] at *;\n       unfold_wf; linarith,\n  have h\u2080 : sizeof_lt t\u2080 (tree.node x t\u2080 t\u2081),\n    by dsimp [sizeof_lt]; unfold_wf; linarith,\n  have h\u2081 : sizeof_lt t\u2081 (tree.node x t\u2080 t\u2081),\n    by dsimp [sizeof_lt]; unfold_wf; linarith,\n  [lazy_list.of_list [\u27e8tree.nil, h\u2082\u27e9, \u27e8t\u2080, h\u2080\u27e9, \u27e8t\u2081, h\u2081\u27e9],\n   (prod.shrink shrink_a (prod.shrink f_rec f_rec) (x, \u27e8t\u2080, h\u2080\u27e9, \u27e8t\u2081, h\u2081\u27e9)).map\n    $ \u03bb \u27e8\u27e8y,\u27e8t'\u2080, _\u27e9,\u27e8t'\u2081, _\u27e9\u27e9,hy\u27e9, \u27e8tree.node y t'\u2080 t'\u2081,\n      by revert hy; dsimp [sizeof_lt]; unfold_wf; intro; linarith\u27e9]\nend\n\ninstance sampleable_tree : sampleable_functor tree :=\n{ wf := _,\n  sample := \u03bb \u03b1 sam_\u03b1, sized $ tree.sample sam_\u03b1,\n  shrink := \u03bb \u03b1 I\u03b1 shr_\u03b1, @tree.shrink_with _ I\u03b1 shr_\u03b1,\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 (\u03b1 : Type*) := \u03b1\n\n/-- Add the `small` type tag -/\ndef small.mk {\u03b1} (x : \u03b1) : small \u03b1 := x\n\n/-- Type tag that signals to `slim_check` to use large values for a given type. -/\ndef large (\u03b1 : Type*) := \u03b1\n\n/-- Add the `large` type tag -/\ndef large.mk {\u03b1} (x : \u03b1) : large \u03b1 := x\n\ninstance small.functor : functor small := id.monad.to_functor\ninstance large.functor : functor large := id.monad.to_functor\ninstance small.inhabited [inhabited \u03b1] : inhabited (small \u03b1) := \u27e8 (default \u03b1 : \u03b1) \u27e9\ninstance large.inhabited [inhabited \u03b1] : inhabited (large \u03b1) := \u27e8 (default \u03b1 : \u03b1) \u27e9\n\ninstance small.sampleable_functor : sampleable_functor small :=\n{ wf := _,\n  sample := \u03bb \u03b1 samp, gen.resize (\u03bb n, n / 5 + 5) samp,\n  shrink := \u03bb \u03b1 _, id,\n  p_repr := \u03bb \u03b1, id }\n\ninstance large.sampleable_functor : sampleable_functor large :=\n{ wf := _,\n  sample := \u03bb \u03b1 samp, gen.resize (\u03bb n, n * 5) samp,\n  shrink := \u03bb \u03b1 _, id,\n  p_repr := \u03bb \u03b1, id }\n\ninstance ulift.sampleable_functor : sampleable_functor ulift.{u v} :=\n{ wf := \u03bb \u03b1 h, \u27e8 \u03bb \u27e8x\u27e9, @sizeof \u03b1 h x \u27e9,\n  sample := \u03bb \u03b1 samp, uliftable.up_map ulift.up $ samp,\n  shrink := \u03bb \u03b1 _ shr \u27e8x\u27e9, (shr x).map (subtype.map ulift.up (\u03bb a h, h)),\n  p_repr := \u03bb \u03b1 h, \u27e8 @repr \u03b1 h \u2218 ulift.down \u27e9 }\n\n/-!\n## Subtype instances\n\nThe following instances are meant to improve the testing of properties of the form\n`\u2200 i j, i \u2264 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 `\u2115` -/\n\ninstance nat_le.sampleable {y} : slim_check.sampleable { x : \u2115 // x \u2264 y } :=\n{ sample :=\n         do { \u27e8x,h\u27e9 \u2190 slim_check.gen.choose_nat 0 y dec_trivial,\n              pure \u27e8x, h.2\u27e9},\n  shrink := \u03bb \u27e8x, h\u27e9, (\u03bb a : subtype _, subtype.rec_on a $\n    \u03bb x' h', \u27e8\u27e8x', le_trans (le_of_lt h') h\u27e9, h'\u27e9) <$> shrink x }\n\ninstance nat_ge.sampleable {x} : slim_check.sampleable { y : \u2115 // x \u2264 y } :=\n{ sample :=\n         do { (y : \u2115) \u2190 slim_check.sampleable.sample \u2115,\n              pure \u27e8x+y, by norm_num\u27e9 },\n  shrink := \u03bb \u27e8y, h\u27e9, (\u03bb a : { y' // sizeof y' < sizeof (y - x) },\n    subtype.rec_on a $ \u03bb \u03b4 h', \u27e8\u27e8x + \u03b4, nat.le_add_right _ _\u27e9, nat.add_lt_of_lt_sub_left h'\u27e9) <$>\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 : \u2115 // x < y } :=\n{ sample :=\n         do { (y : \u2115) \u2190 slim_check.sampleable.sample \u2115,\n              pure \u27e8x+y+1, by linarith\u27e9 },\n  shrink := \u03bb x, shrink _ }\n\n/-! ### Subtypes of any `linear_ordered_add_comm_group` -/\n\ninstance le.sampleable {y : \u03b1} [sampleable \u03b1] [linear_ordered_add_comm_group \u03b1] :\n  slim_check.sampleable { x : \u03b1 // x \u2264 y } :=\n{ sample :=\n         do { x \u2190 sample \u03b1,\n              pure \u27e8y - abs x, sub_le_self _ (abs_nonneg _) \u27e9 },\n  shrink := \u03bb _, lazy_list.nil }\n\ninstance ge.sampleable {x : \u03b1}  [sampleable \u03b1] [linear_ordered_add_comm_group \u03b1] :\n  slim_check.sampleable { y : \u03b1 // x \u2264 y } :=\n{ sample :=\n         do { y \u2190 sample \u03b1,\n              pure \u27e8x + abs y, by norm_num [abs_nonneg]\u27e9 },\n  shrink := \u03bb _, lazy_list.nil }\n\n\n/-!\n### Subtypes of `\u2124`\n\nSpecializations of `le.sampleable` and `ge.sampleable` for `\u2124` to help instance search.\n-/\n\ninstance int_le.sampleable {y : \u2124} : slim_check.sampleable { x : \u2124 // x \u2264 y } :=\nsampleable.lift \u2115 (\u03bb n, \u27e8y - n, int.sub_left_le_of_le_add $ by simp\u27e9) (\u03bb \u27e8i, h\u27e9, (y - i).nat_abs)\n  (\u03bb n, by unfold_wf; simp [int_le.sampleable._match_1]; ring)\n\ninstance int_ge.sampleable {x : \u2124} : slim_check.sampleable { y : \u2124 // x \u2264 y } :=\nsampleable.lift \u2115 (\u03bb n, \u27e8x + n, by simp\u27e9) (\u03bb \u27e8i, h\u27e9, (i - x).nat_abs)\n  (\u03bb n, by unfold_wf; simp [int_ge.sampleable._match_1]; ring)\n\ninstance int_lt.sampleable {y} : slim_check.sampleable { x : \u2124 // x < y } :=\nsampleable.lift \u2115 (\u03bb n, \u27e8y - (n+1), int.sub_left_lt_of_lt_add $\n    by linarith [int.coe_nat_nonneg n]\u27e9)\n  (\u03bb \u27e8i, h\u27e9, (y - i - 1).nat_abs)\n  (\u03bb n, by unfold_wf; simp [int_lt.sampleable._match_1]; ring)\n\ninstance int_gt.sampleable {x} : slim_check.sampleable { y : \u2124 // x < y } :=\nsampleable.lift \u2115 (\u03bb n, \u27e8x + (n+1), by linarith\u27e9) (\u03bb \u27e8i, h\u27e9, (i - x - 1).nat_abs)\n  (\u03bb n, by unfold_wf; simp [int_gt.sampleable._match_1]; ring)\n\n/-! ### Subtypes of any `list` -/\n\ninstance perm.slim_check {xs : list \u03b1} : slim_check.sampleable { ys : list \u03b1 // list.perm xs ys } :=\n{ sample := permutation_of xs,\n  shrink := \u03bb _, lazy_list.nil }\n\ninstance perm'.slim_check {xs : list \u03b1} :\n  slim_check.sampleable { ys : list \u03b1 // list.perm ys xs } :=\n{ sample := subtype.map id (@list.perm.symm \u03b1 _) <$> permutation_of xs,\n  shrink := \u03bb _, 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 \u2190 io.run_rand $ uliftable.down $\n  do { xs \u2190 (list.range 10).mmap $ g.run \u2218 ulift.up,\n       pure \u27e8xs.map repr\u27e9 },\nxs.mmap' io.put_str_ln\n\n/-- Create a `gen \u03b1` expression from the argument of `#sample` -/\nmeta def mk_generator (e : expr) : tactic (expr \u00d7 expr) := do\nt \u2190 infer_type e,\nmatch t with\n| `(gen %%t) := do\n  repr_inst \u2190 mk_app ``has_repr [t] >>= mk_instance,\n  pure (repr_inst, e)\n| _ := do\n  samp_inst \u2190 to_expr ``(sampleable_ext %%e) >>= mk_instance,\n  repr_inst \u2190 mk_mapp ``sampleable_ext.p_repr [e, samp_inst],\n  gen \u2190 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 \u2190 texpr,\n   of_tactic $ do\n     e \u2190 i_to_expr e,\n     (repr_inst, gen) \u2190 mk_generator e,\n     print_samples \u2190 mk_mapp ``print_samples [none, repr_inst, gen],\n     sample \u2190 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) (\u03b5 : \u211d) (\u03b5_pos : 0 < \u03b5)\n  {\u03d5 : X \u2192 \u211d} (cont : continuous \u03d5) (nonneg : \u2200 y, 0 \u2264 \u03d5 y) :\n  \u2203 (\u03b5' > 0) (x' : X), \u03b5' \u2264 \u03b5 \u2227\n                       d x' x \u2264 2*\u03b5 \u2227\n                       \u03b5 * \u03d5(x) \u2264 \u03b5' * \u03d5 x' \u2227\n                       \u2200 y, d x' y \u2264 \u03b5' \u2192 \u03d5 y \u2264 2*\u03d5 x' :=\nbegin\n  by_contradiction H,\n  have reformulation : \u2200 x' (k : \u2115), \u03b5 * \u03d5 x \u2264 \u03b5 / 2 ^ k * \u03d5 x' \u2194 2^k * \u03d5 x \u2264 \u03d5 x',\n  { intros x' k,\n    rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left \u03b5_pos, mul_comm],\n    exact pow_pos (by norm_num) k, },\n  -- Now let's specialize to `\u03b5/2^k`\n  replace H : \u2200 k : \u2115, \u2200 x', d x' x \u2264 2 * \u03b5 \u2227 2^k * \u03d5 x \u2264 \u03d5 x' \u2192\n    \u2203 y, d x' y \u2264 \u03b5/2^k \u2227 2 * \u03d5 x' < \u03d5 y,\n  { intros k x',\n    push_neg at H,\n    simpa [reformulation] using\n      H (\u03b5/2^k) (by simp [\u03b5_pos, zero_lt_two]) x' (by simp [\u03b5_pos, zero_lt_two, one_le_two]) },\n  clear reformulation,\n  haveI : nonempty X := \u27e8x\u27e9,\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 : \u2115 \u2192 X := \u03bb 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    \u2200 n,\n      d (u n) x \u2264 2 * \u03b5 \u2227 2^n * \u03d5 x \u2264 \u03d5 (u n) \u2192\n      d (u n) (u $ n + 1) \u2264 \u03b5 / 2 ^ n \u2227 2 * \u03d5 (u n) < \u03d5 (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 : \u2200 n, d (u n) (u (n + 1)) \u2264 \u03b5 / 2 ^ n \u2227 2 * \u03d5 (u n) < \u03d5 (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, \u03b5_pos.le, le_refl] using hu },\n    have A : d (u (n+1)) x \u2264 2 * \u03b5,\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          \u2264 \u2211 i in r, d (u i) (u $ i+1) : dist_le_range_sum_dist u (n + 1)\n      ... \u2264 \u2211 i in r, \u03b5/2^i             : sum_le_sum (\u03bb i i_in, (IH i $ nat.lt_succ_iff.mp $\n                                                                  finset.mem_range.mp i_in).1)\n      ... = \u2211 i in r, (1/2)^i*\u03b5         : by { congr' with i, field_simp }\n      ... = (\u2211 i in r, (1/2)^i)*\u03b5       : finset.sum_mul.symm\n      ... \u2264 2*\u03b5                         : mul_le_mul_of_nonneg_right (sum_geometric_two_le _)\n                                            (le_of_lt \u03b5_pos), },\n    have B : 2^(n+1) * \u03d5 x \u2264 \u03d5 (u (n + 1)),\n    { refine @geom_le (\u03d5 \u2218 u) _ zero_le_two (n + 1) (\u03bb m hm, _),\n      exact (IH _ $ nat.lt_add_one_iff.1 hm).2.le },\n    exact hu (n+1) \u27e8A, B\u27e9, },\n  cases forall_and_distrib.mp key with key\u2081 key\u2082,\n  clear hu key,\n  -- Hence u is Cauchy\n  have cauchy_u : cauchy_seq u,\n  { refine cauchy_seq_of_le_geometric _ \u03b5 one_half_lt_one (\u03bb n, _),\n    simpa only [one_div, inv_pow\u2080] using key\u2081 n },\n  -- So u converges to some y\n  obtain \u27e8y, limy\u27e9 : \u2203 y, tendsto u at_top (\ud835\udcdd y),\n    from complete_space.complete cauchy_u,\n  -- And \u03d5 \u2218 u goes to +\u221e\n  have lim_top : tendsto (\u03d5 \u2218 u) at_top at_top,\n  { let v := \u03bb n, (\u03d5 \u2218 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\u2080 : 0 < v 0,\n    { have : 0 \u2264 \u03d5 (u 0) := nonneg x,\n      calc 0 \u2264 2 * \u03d5 (u 0) : by linarith\n      ... < \u03d5 (u (0 + 1)) : key\u2082 0 },\n    apply tendsto_at_top_of_geom_le hv\u2080 one_lt_two,\n    exact \u03bb n, (key\u2082 (n+1)).le },\n  -- But \u03d5 \u2218 u also needs to go to \u03d5(y)\n  have lim : tendsto (\u03d5 \u2218 u) at_top (\ud835\udcdd (\u03d5 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 {\u03b1 : Type*} (p q r : \u03b1 \u2192 Prop) :\n  (\u2200 a, (p a \u2228 q a) \u2192 r a) \u2194 (\u2200 a, p a \u2192 r a) \u2227 (\u2200 a, q a \u2192 r a) :=\n\u27e8\u03bb H, \u27e8\u03bb a h, H a (or.inl h), \u03bb a h, H a (or.inr h)\u27e9,\n \u03bb H a o, o.cases_on (H.1 a) (H.2 a)\u27e9\n\nlemma exists_tInf {s : set R} (ts : tame s) (ne : s.nonempty) (bdd : bdd_below s) :\n  \u2203 m, is_glb s m :=\nbegin\n  revert ne bdd,\n  refine tame.induction _ _ ts; clear ts s,\n  { rintro \u27e8_, \u27e8\u27e9\u27e9 },\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 \u27e8z, hz\u27e9,\n      obtain \u27e8y, hy : y < z\u27e9 := no_bot z,\n      exact not_le_of_lt hy (hz (by simp)) },\n    swap 3,                     -- Iio\n    { exfalso,\n      rcases bdd with \u27e8z, hz\u27e9,\n      obtain \u27e8c, hc : c < b\u27e9 := no_bot b,\n      obtain \u27e8y, hy : y < min c z\u27e9 := 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       ...   \u2264 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 \u27e8_, is_glb_singleton\u27e9 },\n    { exact \u27e8_, is_glb.union is_glb_singleton IH\u27e9 },\n    { exact \u27e8_, is_glb_Ioi\u27e9 },\n    { exact \u27e8_, is_glb.union is_glb_Ioi IH\u27e9 },\n    { exact \u27e8_, is_glb_Ioo hab\u27e9 },\n    { exact \u27e8_, is_glb.union (is_glb_Ioo hab) IH\u27e9 } }\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  \u2203 m, is_lub s m :=\nbegin\n  revert ne bdd,\n  refine tame.induction _ _ ts; clear ts s,\n  { rintro \u27e8_, \u27e8\u27e9\u27e9 },\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 \u27e8z, hz\u27e9,\n      obtain \u27e8y, hy : y > z\u27e9 := no_top z,\n      exact not_le_of_lt hy (hz (by simp)) },\n    swap 2,                     -- Ioi\n    { exfalso,\n      rcases bdd with \u27e8z, hz\u27e9,\n      obtain \u27e8c, hc : c > a\u27e9 := no_top a,\n      obtain \u27e8y, hy : y > max c z\u27e9 := 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       ...   \u2265 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 \u27e8_, is_lub_singleton\u27e9 },\n    { exact \u27e8_, is_lub.union is_lub_singleton IH\u27e9 },\n    { exact \u27e8_, is_lub_Iio\u27e9 },\n    { exact \u27e8_, is_lub.union is_lub_Iio IH\u27e9 },\n    { exact \u27e8_, is_lub_Ioo hab\u27e9 },\n    { exact \u27e8_, is_lub.union (is_lub_Ioo hab) IH\u27e9 } }\nend\n\n/-- X \u21a6 inf X as a partial function. Defined when X is tame, nonempty and bounded below. -/\nnoncomputable def tInf : set R \u2192. R :=\n\u03bb X, { dom := tame X \u2227 X.nonempty \u2227 bdd_below X, get := \u03bb h, classical.some (exists_tInf h.1 h.2.1 h.2.2) }\n\n/-- X \u21a6 inf X as a partial function. Defined when X is tame, nonempty and bounded above. -/\nnoncomputable def tSup : set R \u2192. R :=\n\u03bb X, { dom := tame X \u2227 X.nonempty \u2227 bdd_above X, get := \u03bb 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\u2019s 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`, \u2115, \u2124, \u2124[i],  )\n- Groups (introduced as an extension of the strucute of monoids (monoids with inverses), e.g. integers and gaussian integers \u2124[i], group of auto-functions (functions `X \u2192 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 \u2192 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) \u2192 (Y, y : Y)` where `f x = y`)\n- Derivations of propositions (`P \u2192 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 \u2192\u2098* N) (f : L \u2192\u2098* M)  : L \u2192\u2098* N := \n{ to_fun := g \u2218 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 \u2192 obj \u2192 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       : \u03a0 X : obj, hom X X) -- specifies identity morphism for all types \n(comp     : \u03a0 {X Y Z : obj}, (hom X Y) \u2192 (hom Y Z) \u2192 (hom X Z) )\n-- ( id       : \u03a0 X : obj, hom X X )\n-- ( comp     : \u03a0 {X Y Z : obj}, (hom Y Z) \u2192 (hom X Y) \u2192 (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 \u27f6 Y` for the type `hom X Y`  of morphisms from `X` to `Y`.  Note: X \u27f6 Y is entirely different than the type X \u2192 Y of functions from `X` to `Y`.  \n  (To enter the special arrow `\u27f6`, type `\\h` or `\\hom`, or hover over the symbol to see the hint.)\n\n- `\ud835\udfd9 X` is a the identity morphisms on `X` (i.e., a term of type `X \u27f6 X`).  (To enter the special arrow `\ud835\udfd9`, type `\\b1` or hover over the symbol to see the hint.)\n\n- If `f : X \u27f6 Y` and `g : Y \u27f6 Z`, then we write `g \u229a f` for the composition, a morphism `X \u27f6 Z`. -- this is composition in every category_str, not necessarily in the category_str of types\n-/\n\n\n\ninfixr ` \u27f6 `:10 := precategory_str.hom -- type as \\h\nnotation `\ud835\udfd9` := precategory_str.id -- type as \\b1\n-- infixr ` \u229a `:80 := precategory_str.comp-- type as \\oo\n\nlocal notation f ` \u229a `:80 g:80 := precategory_str.comp g f    -- type as \\oo\n\n\n\nsection\nvariables {\ud835\udcd2 : Type} [precategory_str \ud835\udcd2]\nvariables W X Y Z : \ud835\udcd2 -- terms of type C can be regarded as objects of precategory_str \ud835\udcd2\n#check X \u27f6 Y\nvariables f\u2080 f\u2081 : X \u27f6 Y \nvariables g\u2080 g\u2081 : Y \u27f6 Z\n#check \ud835\udfd9 X\n--#check f\u2080 \u229a g\u2080 -- this does not type check because the composition goes the other way round.\n#check g\u2080 \u229a f\u2080 \n--#check f\u2080 \u229a g\u2081\n#check g\u2081 \u229a f\u2080\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' : \u2200 {X Y : obj} (f : hom X Y), f \u229a (\ud835\udfd9 X)  = f . obviously) -- naming based diagrammatic order of composition\n(comp_id' : \u2200 {X Y : obj} (f : hom X Y), (\ud835\udfd9 Y) \u229a f = f . obviously)\n(comp_assoc'   : \u2200 {W X Y Z : obj} (f : hom W X) (g : hom X Y) (h : hom Y Z),\n  (h \u229a g) \u229a f = h \u229a (g \u229a f) . obviously)\n\n\n#check category_str.id_comp'\n\n\nset_option trace.simp_lemmas true\n\n\n\ninstance : category_str \u2115 := \n{ hom := \u03bb x, \u03bb y, plift (x \u2264 y),\n  id := \u03bb x, \u27e8 le_refl x \u27e9,\n  comp := \u03bb x y z, \u03bb f, \u03bb g, \u27e8le_trans f.down g.down \u27e9,\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  \u2200  f : X \u27f6 Y ,  (\ud835\udfd9 X) \u229a 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 \u2192 hom,\n  to_precategory_str_comp \u2192 comp, to_precategory_str_id \u2192 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 := \u03bb X, \u03bb Y, X \u2192 Y,\n  id := \u03bb X, id,\n  comp := \u03bb X Y Z, \u03bb f, \u03bb g, g \u2218 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' (\u03bb x, (x + 1))\n\n\nsection \n\nvariables (\ud835\udcd2 : Type u) [category_str.{v} \ud835\udcd2] (X Y : \ud835\udcd2) (f : X \u27f6 Y) -- let \ud835\udcd2 be a category and `f : X \u27f6 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 (\ud835\udfd9 \u2115) \u229a (\ud835\udfd9 \u2115)\n\n\n\n\nexample  : \n  bool_of_nat \u229a (\ud835\udfd9 \u2115) = bool_of_nat := \nbegin\n  simp, \nend \n\n\n\n/-! ## Category of Pointed Types \nSee lecture 11 for definitions of `\u2192\u2022` and pointed_type.id, or simply command+click below. \n-/ \n\ninstance : large_category_str pointed_type :=\n{ \n  hom := \u03bb X, \u03bb Y, X \u2192\u2022 Y, -- really X is (A, a)\n  id := \u03bb X, pointed_type.id, -- id: (A,a) \u27f6 (A,a)  \n  comp := \u03bb X Y Z, \u03bb f, \u03bb g, g \u2218\u2022 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 \u2264 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 ( \u27e8 (rfl : 0 = 0) \u27e9 : plift (0 = 0) ) -- Since `rfl` is a proof of `0 = 0` we can lift it up to a term `\u27e8 (rfl : 0 = 0) \u27e9` 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 := \u03bb x, \u03bb y, (plift (x \u2264 y) : Type), \n  id := \u03bb x, \u27e8 le_refl x \u27e9, \n  comp := \u03bb x y z, \u03bb f, \u03bb g, \u27e8le_trans f.down g.down \u27e9,\n}\n\ndef two_to_three :  1 \u27f6 2 := \n\u27e8one_le_two\u27e9 \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 \u2115 := \ncategory_str.small_cat_of_preorder \u2115 \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 (\ud835\udcd2 : Type u)[category_str.{v} \ud835\udcd2]\n\n\nuniverse u'\n-- we can lift \ud835\udcd2 from universe `u` to a higher universe `u'`. \ninstance ulift_cat : category_str.{v} (ulift.{u'} \ud835\udcd2) :=\n{ hom  := \u03bb X Y, (X.down \u27f6 Y.down),\n  id   := \u03bb X, \ud835\udfd9 X.down,\n  comp := \u03bb _ _ _ f g, g \u229a f }\n\n-- We verify that this previous instance can lift small categories to large categories.\nexample (\ud835\udce2 : Type u) [small_category_str \ud835\udce2] : large_category_str (ulift.{u+1} \ud835\udce2) := \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 {\ud835\udcd2 : Type u} [category_str \ud835\udcd2] {W X Y Z : \ud835\udcd2} {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 := \u03bb _, \u03bb _, M,\n  id := 1,\n  comp := \u03bb _ _ _, (*),\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 := \u03bb _, \u03bb _, M,\n--   id := 1,\n--   comp := \u03bb _ _ _, (*),\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 := \u03bb _, \u03bb _, M,\n  id := 1,\n  comp := \u03bb _ _ _, (*),\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 \ud835\udcd2 -/\n\ndef End (X : \ud835\udcd2) := X \u27f6 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 {\ud835\udcd2 : Type}[small_category_str \ud835\udcd2] (X : \ud835\udcd2) : mult_monoid_str (X \u27f6 X) :=  \nsorry \n\n\n\n\n\n/-! ## Challenge: \nThe endomorphisms monoid of the only object in `single_obj \u03b1` is equivalent to the original\n     monoid \u03b1. -/\n-- def to_End {M : Type} [mult_monoid_str M] : M \u2243* End (_) :=\n-- sorry\n\n\n\n\n\n\n\nlemma eq_comp {f g : X \u27f6 Y} (e : f = g) (h : Y \u27f6 Z) : \n  h \u229a f = h \u229a g :=\nbegin\n-- we want to prove  `h \u229a f = h \u229a g`\n  rw e, -- we sub `f` for `g`\nend \n\n  \n\nlemma comp_eq (f : X \u27f6 Y) {g h : Y \u27f6 Z} (e : g = h) : \n  g \u229a f = h \u229a f :=\nbegin\n  rw e, \nend \n\n\nexample (f : W \u27f6 X) (g : X \u27f6 Y) (h : Y \u27f6 Z) :  \n(h  \u229a  (\ud835\udfd9 Y \u229a g)) \u229a  f = h \u229a (g \u229a f) :=\nbegin\n  simp, \nend\n\n\n\n\nstructure equiv (X Y : \ud835\udcd2) :=\n(to_mor    : X \u27f6 Y)\n(inv_mor   : Y \u27f6 X)\n(left_inv  : to_mor \u229a  inv_mor = (\ud835\udfd9 Y) ) \n(right_inv : inv_mor \u229a to_mor = (\ud835\udfd9 X)  )\n\n\nlocal notation ` \u2245 `: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 \u27f6 Y) := \n\u2203 (g h : Y \u27f6 X), (g \u229a f = \ud835\udfd9 X) \u2227 (f \u229a h = \ud835\udfd9 Y)\n\n\n/- ## Challenge:\nShow that an instance of equivalence `f : X \u2243 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 \u226b f = h \u226b f` implies `g = h`.\n-/\n@[simp] \ndef is_mono (f : X \u27f6 Y) :=\n\u2200 (W : \ud835\udcd2) (x\u2081 x\u2082 : W \u27f6 X), (f \u229a x\u2081 = f \u229a x\u2082) \u2192  (x\u2081 = x\u2082)\n\n@[simp]\nlemma cancel_mono {f : X \u27f6 Y} (mf : is_mono f) {x\u2081 x\u2082 : W \u27f6 X} : \n  (f \u229a x\u2081  = f \u229a x\u2082) \u2194 x\u2081 = x\u2082 :=\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 \u229a f = h \u229a f` implies `g = h`.\n-/\n\ndef is_epi (f : X \u27f6 Y) := \n\u2200 {Z : \ud835\udcd2} (g h : Y \u27f6 Z), (g \u229a f = h \u229a f) \u2192 g = h\n\n\n\n\n/- ## Challenge \nShow that every isomorphism is a monomorphism. \n-/\n\n\n\n/-! ## Opposite Category \nIf `\ud835\udcd2` is a category, then `\ud835\udcd2\u1d52\u1d56` is the __opposite category__, with objects the same but all arrows reversed. `\ud835\udcd2\u1d52\u1d56` is the mirror image of `\ud835\udcd2`. If `X \u27f6 Y \u27f6 Z` are morphisms in `\ud835\udcd2\u1d52\u1d56` then `Z \u27f6 Y \u27f6 X`  are maps in `\ud835\udcd2`. \n\nIn below we give `\ud835\udcd2\u1d52\u1d56` the structure of a category. See `opposite_cat`. \n-/\n\ndef opposite (\ud835\udcd2 : Type u) : Type u := \ud835\udcd2\n\n\nnotation X `\u1d52\u1d56`:std.prec.max_plus := opposite X\n\n\n/- The canonical map `\ud835\udcd2 \u2192 \ud835\udcd2\u1d52\u1d56`. \nWe need to write `op X` to explicitly move `X` to the opposite category-/\n@[pp_nodot]\ndef op : \ud835\udcd2 \u2192 \ud835\udcd2\u1d52\u1d56 := id \n\n\n\n/- The canonical map `\ud835\udcd2\u1d52\u1d56 \u2192 \ud835\udcd2`. -/\n@[pp_nodot]\ndef unop : \ud835\udcd2\u1d52\u1d56 \u2192 \ud835\udcd2 := id\n\nsection test \nvariable XX : \ud835\udcd2 \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 : \ud835\udcd2\u1d52\u1d56) : op (unop X) = X := rfl\n\n@[simp] \nlemma unop_op (x : \ud835\udcd2) : unop (op X) = X := rfl\n\n\n/- The type-level equivalence between a type and its opposite. -/\ndef equiv_to_opposite :  \ud835\udcd2 \u2245 \ud835\udcd2\u1d52\u1d56 :=\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 {\ud835\udcd2 : Type u} [category_str.{v} \ud835\udcd2] : category_str.{v} \ud835\udcd2\u1d52\u1d56 :=\n{ \n  hom := \u03bb X, \u03bb Y, (unop Y \u27f6 unop X), -- informally, hom_{\ud835\udcd2\u1d52\u1d56} X Y = hom_{\ud835\udcd2} Y X\n  id := \u03bb X, \ud835\udfd9 (unop X),\n  comp := \u03bb X Y Z, \u03bb f g, f \u229a 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 `\ud835\udcd2`.\n-/\ndef hom.op  {X Y : \ud835\udcd2} (f : X \u27f6 Y) : \nop Y \u27f6 op X := f\n\n/-\nGiven an arrow in `\ud835\udcd2\u1d52\u1d56`, we can take the \"unopposite\" back in `\ud835\udcd2`.\n-/\ndef hom.unop {X Y : \ud835\udcd2\u1d52\u1d56} (f : X \u27f6 Y) : \nunop Y \u27f6 unop X := f\n\n\n@[simp] \nlemma op_comp {X Y Z : \ud835\udcd2} {f : X \u27f6 Y} {g : Y \u27f6 Z} :\n  hom.op (g \u229a f) = hom.op f \u229a hom.op g := \nbegin \n  refl, \nend   \n\n@[simp] \nlemma unop_comp {X Y Z : \ud835\udcd2\u1d52\u1d56} {f : X \u27f6 Y} {g : Y \u27f6 Z} :\n  hom.unop (g \u229a f) = hom.unop f \u229a hom.unop g := \nbegin \n  refl, \nend   \n\n\n\n@[simp] \nlemma op_id {X : \ud835\udcd2} : hom.op (\ud835\udfd9 X) = \ud835\udfd9 (op X) := \nbegin\n  refl, \nend \n\n@[simp] \nlemma unop_id {X : \ud835\udcd2\u1d52\u1d56} : hom.unop (\ud835\udfd9 X) = \ud835\udfd9 (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 \u2192 Prop \u2192 Prop \u2192 Prop) (x x' y z z' : Prop)\n    (h\u2080 : x \u2194 x') (h\u2081 : z \u2194 z') : c x y z \u2194 c x' y z' := by\n  apply Iff.of_eq -- FIXME: not needed in lean 3\n  congr\n  \u00b7 guard_target =\u2090 x = x'\n    apply_ext_lemma\n    assumption\n  \u00b7 guard_target =\u2090 z = z'\n    ext\n    assumption\n\nexample {\u03b1 \u03b2 \u03b3 \u03b4} {F : \u2200 {\u03b1 \u03b2}, (\u03b1 \u2192 \u03b2) \u2192 \u03b3 \u2192 \u03b4} {f g : \u03b1 \u2192 \u03b2} {s : \u03b3}\n    (h : \u2200 x : \u03b1, 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 {\u03b1 \u03b2 : Type _} {f : _ \u2192 \u03b2} {x y : { x : { x : \u03b1 // 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 {\u03b1 \u03b2 : Type _} {F : _ \u2192 \u03b2} {f g : { f : \u03b1 \u2192 \u03b2 // f = f }}\n    (h : \u2200 x : \u03b1, (f : \u03b1 \u2192 \u03b2) x = (g : \u03b1 \u2192 \u03b2) 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 \u2192 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 =\u2090 1 + y = y.succ\n  rw [Nat.add_comm]\n\nexample {ls : List Nat} {f g : Nat \u2192 Nat} {h : \u2200 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 {\u03b1} (a : \u03b1) : a = a := by congr\n\n-- FIXME(?): congr doesn't fail\n-- example {\u03b1} (a b : \u03b1) (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 \u03b1 into binary relations on \u03b1, 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 {\u03b1 : Type u_1} (r : setoid \u03b1) : \u03b1 \u2192 \u03b1 \u2192 Prop := setoid.r\n\n/-- A version of `quotient.eq'` compatible with `setoid.rel`, to make rewriting possible. -/\ntheorem quotient.eq_rel {\u03b1 : Type u_1} {r : setoid \u03b1} {x : \u03b1} {y : \u03b1} :\n    quotient.mk x = quotient.mk y \u2194 setoid.rel r x y :=\n  quotient.eq'\n\nnamespace setoid\n\n\ntheorem ext' {\u03b1 : Type u_1} {r : setoid \u03b1} {s : setoid \u03b1} (H : \u2200 (a b : \u03b1), rel r a b \u2194 rel s a b) :\n    r = s :=\n  ext H\n\ntheorem ext_iff {\u03b1 : Type u_1} {r : setoid \u03b1} {s : setoid \u03b1} :\n    r = s \u2194 \u2200 (a b : \u03b1), rel r a b \u2194 rel s a b :=\n  { mp := fun (h : r = s) (a b : \u03b1) => h \u25b8 iff.rfl, mpr := ext' }\n\n/-- Two equivalence relations are equal iff their underlying binary operations are equal. -/\ntheorem eq_iff_rel_eq {\u03b1 : Type u_1} {r\u2081 : setoid \u03b1} {r\u2082 : setoid \u03b1} : r\u2081 = r\u2082 \u2194 rel r\u2081 = rel r\u2082 :=\n  { mp := fun (h : r\u2081 = r\u2082) => h \u25b8 rfl,\n    mpr := fun (h : rel r\u2081 = rel r\u2082) => ext' fun (x y : \u03b1) => h \u25b8 iff.rfl }\n\n/-- Defining `\u2264` for equivalence relations. -/\nprotected instance has_le {\u03b1 : Type u_1} : HasLessEq (setoid \u03b1) :=\n  { LessEq := fun (r s : setoid \u03b1) => \u2200 {x y : \u03b1}, rel r x y \u2192 rel s x y }\n\ntheorem le_def {\u03b1 : Type u_1} {r : setoid \u03b1} {s : setoid \u03b1} :\n    r \u2264 s \u2194 \u2200 {x y : \u03b1}, rel r x y \u2192 rel s x y :=\n  iff.rfl\n\ntheorem refl' {\u03b1 : Type u_1} (r : setoid \u03b1) (x : \u03b1) : rel r x x := and.left iseqv x\n\ntheorem symm' {\u03b1 : Type u_1} (r : setoid \u03b1) {x : \u03b1} {y : \u03b1} : rel r x y \u2192 rel r y x :=\n  fun (h : rel r _x\u271d _x) => and.left (and.right iseqv) _x\u271d _x h\n\ntheorem trans' {\u03b1 : Type u_1} (r : setoid \u03b1) {x : \u03b1} {y : \u03b1} {z : \u03b1} :\n    rel r x y \u2192 rel r y z \u2192 rel r x z :=\n  fun (hx : rel r _x\u271d\u00b9 _x\u271d) => and.right (and.right iseqv) _x\u271d\u00b9 _x\u271d _x hx\n\n/-- The kernel of a function is an equivalence relation. -/\ndef ker {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) : setoid \u03b1 :=\n  mk (fun (x y : \u03b1) => 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 {\u03b1 : Type u_1} (r : setoid \u03b1) : ker quotient.mk = r :=\n  ext' fun (x y : \u03b1) => quotient.eq\n\ntheorem ker_def {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {y : \u03b1} :\n    rel (ker f) x y \u2194 f x = f y :=\n  iff.rfl\n\n/-- Given types `\u03b1`, `\u03b2`, the product of two equivalence relations `r` on `\u03b1` and `s` on `\u03b2`:\n    `(x\u2081, x\u2082), (y\u2081, y\u2082) \u2208 \u03b1 \u00d7 \u03b2` are related by `r.prod s` iff `x\u2081` is related to `y\u2081`\n    by `r` and `x\u2082` is related to `y\u2082` by `s`. -/\nprotected def prod {\u03b1 : Type u_1} {\u03b2 : Type u_2} (r : setoid \u03b1) (s : setoid \u03b2) : setoid (\u03b1 \u00d7 \u03b2) :=\n  mk (fun (x y : \u03b1 \u00d7 \u03b2) => rel r (prod.fst x) (prod.fst y) \u2227 rel s (prod.snd x) (prod.snd y)) sorry\n\n/-- The infimum of two equivalence relations. -/\nprotected instance has_inf {\u03b1 : Type u_1} : has_inf (setoid \u03b1) :=\n  has_inf.mk fun (r s : setoid \u03b1) => mk (fun (x y : \u03b1) => rel r x y \u2227 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 {\u03b1 : Type u_1} {r : setoid \u03b1} {s : setoid \u03b1} : rel (r \u2293 s) = rel r \u2293 rel s := rfl\n\ntheorem inf_iff_and {\u03b1 : Type u_1} {r : setoid \u03b1} {s : setoid \u03b1} {x : \u03b1} {y : \u03b1} :\n    rel (r \u2293 s) x y \u2194 rel r x y \u2227 rel s x y :=\n  iff.rfl\n\n/-- The infimum of a set of equivalence relations. -/\nprotected instance has_Inf {\u03b1 : Type u_1} : has_Inf (setoid \u03b1) :=\n  has_Inf.mk\n    fun (S : set (setoid \u03b1)) => mk (fun (x y : \u03b1) => \u2200 (r : setoid \u03b1), r \u2208 S \u2192 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 {\u03b1 : Type u_1} {s : set (setoid \u03b1)} : rel (Inf s) = Inf (rel '' s) := sorry\n\nprotected instance partial_order {\u03b1 : Type u_1} : partial_order (setoid \u03b1) :=\n  partial_order.mk LessEq (fun (r s : setoid \u03b1) => r \u2264 s \u2227 \u00acs \u2264 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 {\u03b1 : Type u_1} : complete_lattice (setoid \u03b1) :=\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 : \u03b1) => 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 {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) :\n    eqv_gen.setoid r = Inf (set_of fun (s : setoid \u03b1) => \u2200 {x y : \u03b1}, r x y \u2192 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 {\u03b1 : Type u_1} (r : setoid \u03b1) (s : setoid \u03b1) :\n    r \u2294 s = eqv_gen.setoid fun (x y : \u03b1) => rel r x y \u2228 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 {\u03b1 : Type u_1} {r : setoid \u03b1} {s : setoid \u03b1} :\n    r \u2294 s = eqv_gen.setoid (rel r \u2294 rel s) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (r \u2294 s = eqv_gen.setoid (rel r \u2294 rel s))) (sup_eq_eqv_gen r s)))\n    (Eq.refl (eqv_gen.setoid fun (x y : \u03b1) => rel r x y \u2228 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 \u2208 S relating x and y`. -/\ntheorem Sup_eq_eqv_gen {\u03b1 : Type u_1} (S : set (setoid \u03b1)) :\n    Sup S = eqv_gen.setoid fun (x y : \u03b1) => \u2203 (r : setoid \u03b1), r \u2208 S \u2227 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 {\u03b1 : Type u_1} {s : set (setoid \u03b1)} : 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 {\u03b1 : Type u_1} (r : setoid \u03b1) : eqv_gen.setoid r = r :=\n  le_antisymm\n    (eq.mpr (id (Eq._oldrec (Eq.refl (eqv_gen.setoid r \u2264 r)) (eqv_gen_eq r)))\n      (Inf_le fun (_x _x_1 : \u03b1) => id))\n    eqv_gen.rel\n\n/-- Equivalence closure is idempotent. -/\n@[simp] theorem eqv_gen_idem {\u03b1 : Type u_1} (r : \u03b1 \u2192 \u03b1 \u2192 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 {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : setoid \u03b1}\n    (h : \u2200 (x y : \u03b1), r x y \u2192 rel s x y) : eqv_gen.setoid r \u2264 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (eqv_gen.setoid r \u2264 s)) (eqv_gen_eq r))) (Inf_le h)\n\n/-- Equivalence closure of binary relations is monotonic. -/\ntheorem eqv_gen_mono {\u03b1 : Type u_1} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {s : \u03b1 \u2192 \u03b1 \u2192 Prop}\n    (h : \u2200 (x y : \u03b1), r x y \u2192 s x y) : eqv_gen.setoid r \u2264 eqv_gen.setoid s :=\n  eqv_gen_le fun (_x _x_1 : \u03b1) (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 \u03b1 into binary relations\n    on \u03b1, with equivalence closure the lower adjoint. -/\ndef gi {\u03b1 : Type u_1} : galois_insertion eqv_gen.setoid rel :=\n  galois_insertion.mk (fun (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (h : rel (eqv_gen.setoid r) \u2264 r) => eqv_gen.setoid r)\n    sorry sorry sorry\n\n/-- A function from \u03b1 to \u03b2 is injective iff its kernel is the bottom element of the complete lattice\n    of equivalence relations on \u03b1. -/\ntheorem injective_iff_ker_bot {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) :\n    function.injective f \u2194 ker f = \u22a5 :=\n  iff.symm eq_bot_iff\n\n/-- The elements related to x \u2208 \u03b1 by the kernel of f are those in the preimage of f(x) under f. -/\ntheorem ker_iff_mem_preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {x : \u03b1} {y : \u03b1} :\n    rel (ker f) x y \u2194 x \u2208 f \u207b\u00b9' singleton (f y) :=\n  iff.rfl\n\n/-- Equivalence between functions `\u03b1 \u2192 \u03b2` such that `r x y \u2192 f x = f y` and functions\n`quotient r \u2192 \u03b2`. -/\ndef lift_equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} (r : setoid \u03b1) :\n    (Subtype fun (f : \u03b1 \u2192 \u03b2) => r \u2264 ker f) \u2243 (quotient r \u2192 \u03b2) :=\n  equiv.mk (fun (f : Subtype fun (f : \u03b1 \u2192 \u03b2) => r \u2264 ker f) => quotient.lift \u2191f sorry)\n    (fun (f : quotient r \u2192 \u03b2) => { val := f \u2218 quotient.mk, property := sorry }) sorry sorry\n\n/-- The uniqueness part of the universal property for quotients of an arbitrary type. -/\ntheorem lift_unique {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : setoid \u03b1} {f : \u03b1 \u2192 \u03b2} (H : r \u2264 ker f)\n    (g : quotient r \u2192 \u03b2) (Hg : f = g \u2218 quotient.mk) : quotient.lift f H = g :=\n  sorry\n\n/-- Given a map f from \u03b1 to \u03b2, the natural map from the quotient of \u03b1 by the kernel of f is\n    injective. -/\ntheorem ker_lift_injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) :\n    function.injective (quotient.lift f fun (_x _x_1 : \u03b1) (h : _x \u2248 _x_1) => h) :=\n  sorry\n\n/-- Given a map f from \u03b1 to \u03b2, the kernel of f is the unique equivalence relation on \u03b1 whose\n    induced map from the quotient of \u03b1 to \u03b2 is injective. -/\ntheorem ker_eq_lift_of_injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : setoid \u03b1} (f : \u03b1 \u2192 \u03b2)\n    (H : \u2200 (x y : \u03b1), rel r x y \u2192 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 \u03b1 by the kernel of a function f\n    bijects with f's image. -/\ndef quotient_ker_equiv_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) :\n    quotient (ker f) \u2243 \u21a5(set.range f) :=\n  equiv.of_bijective\n    (quotient.lift (fun (x : \u03b1) => { val := f x, property := set.mem_range_self x }) sorry) sorry\n\n/-- The quotient of \u03b1 by the kernel of a surjective function f bijects with f's codomain. -/\ndef quotient_ker_equiv_of_surjective {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2)\n    (hf : function.surjective f) : quotient (ker f) \u2243 \u03b2 :=\n  equiv.trans (quotient_ker_equiv_range f) (equiv.subtype_univ_equiv hf)\n\n/-- Given a function `f : \u03b1 \u2192 \u03b2` and equivalence relation `r` on `\u03b1`, the equivalence\n    closure of the relation on `f`'s image defined by '`x \u2248 y` iff the elements of `f\u207b\u00b9(x)` are\n    related to the elements of `f\u207b\u00b9(y)` by `r`.' -/\ndef map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (r : setoid \u03b1) (f : \u03b1 \u2192 \u03b2) : setoid \u03b2 :=\n  eqv_gen.setoid fun (x y : \u03b2) => \u2203 (a : \u03b1), \u2203 (b : \u03b1), f a = x \u2227 f b = y \u2227 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 \u2248 y \u2194 the elements of f\u207b\u00b9(x) are related to\n    the elements of f\u207b\u00b9(y) by r. -/\ndef map_of_surjective {\u03b1 : Type u_1} {\u03b2 : Type u_2} (r : setoid \u03b1) (f : \u03b1 \u2192 \u03b2) (h : ker f \u2264 r)\n    (hf : function.surjective f) : setoid \u03b2 :=\n  mk (fun (x y : \u03b2) => \u2203 (a : \u03b1), \u2203 (b : \u03b1), f a = x \u2227 f b = y \u2227 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : setoid \u03b1} {f : \u03b1 \u2192 \u03b2}\n    (h : ker f \u2264 r) (hf : function.surjective f) : map r f = map_of_surjective r f h hf :=\n  sorry\n\n/-- Given a function `f : \u03b1 \u2192 \u03b2`, an equivalence relation `r` on `\u03b2` induces an equivalence\n    relation on `\u03b1` defined by '`x \u2248 y` iff `f(x)` is related to `f(y)` by `r`'. -/\ndef comap {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (r : setoid \u03b2) : setoid \u03b1 :=\n  mk (fun (x y : \u03b1) => rel r (f x) (f y)) sorry\n\n/-- Given a map `f : N \u2192 M` and an equivalence relation `r` on `\u03b2`, the equivalence relation\n    induced on `\u03b1` by `f` equals the kernel of `r`'s quotient map composed with `f`. -/\ntheorem comap_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u2192 \u03b2} {r : setoid \u03b2} :\n    comap f r = ker (quotient.mk \u2218 f) :=\n  sorry\n\n/-- The second isomorphism theorem for sets. -/\ndef comap_quotient_equiv {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) (r : setoid \u03b2) :\n    quotient (comap f r) \u2243 \u21a5(set.range (quotient.mk \u2218 f)) :=\n  equiv.trans (quotient.congr_right sorry) (quotient_ker_equiv_range (quotient.mk \u2218 f))\n\n/-- The third isomorphism theorem for sets. -/\ndef quotient_quotient_equiv_quotient {\u03b1 : Type u_1} (r : setoid \u03b1) (s : setoid \u03b1) (h : r \u2264 s) :\n    quotient (ker (quot.map_right h)) \u2243 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 : \u03b1) => rel r x y) => quotient.lift_on' w quotient.mk sorry) sorry)\n    (fun (x : quotient s) => quotient.lift_on' x (fun (w : \u03b1) => quotient.mk (quotient.mk w)) sorry)\n    sorry sorry\n\n/-- Given an equivalence relation `r` on `\u03b1`, the order-preserving bijection between the set of\nequivalence relations containing `r` and the equivalence relations on the quotient of `\u03b1` by `r`. -/\ndef correspondence {\u03b1 : Type u_1} (r : setoid \u03b1) :\n    (Subtype fun (s : setoid \u03b1) => r \u2264 s) \u2243o setoid (quotient r) :=\n  rel_iso.mk\n    (equiv.mk\n      (fun (s : Subtype fun (s : setoid \u03b1) => r \u2264 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 \u2192 Q)\n(i : Q \u2192 R)\n(j : Q \u2192 T)\n(k : S \u2192 T)\n(l : T \u2192 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 \u27f6 Y) (e : C \u224c 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 \u226b f = h \u226b f \u2194 g = h ` whenever `f` is a mono\n  -- This is an iff, so we can either using `rw \u2190cancel_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 \u21a6 X \u2a3f Y` forms a monad, whose category of monads is equivalent to the under category\nof `X`. Similarly, `Y \u21a6 X \u2a2f 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 \u2964 C` is a comonadic left adjoint and `under.forget : under X \u2964 C`\nis a monadic right adjoint.\n-/\n\nnamespace category_theory\n\n\n/-- `X \u2a2f -` 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 \ud835\udfd9)\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) \u2964 over X :=\n  functor.mk\n    (fun (A : comonad.coalgebra (functor.obj limits.prod.functor X)) => over.mk (comonad.coalgebra.a A \u226b limits.prod.fst))\n    fun (A\u2081 A\u2082 : comonad.coalgebra (functor.obj limits.prod.functor X)) (f : A\u2081 \u27f6 A\u2082) =>\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\u2081 : over X) (f\u2082 : over X) (g : f\u2081 \u27f6 f\u2082) : 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) \u224c 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 \ud835\udfed 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 \u22d9 coalgebra_to_over X) f))))\n      sorry)\n\n/-- `X \u2a3f -` has a monad structure. This is sometimes called the either monad. -/\n@[simp] theorem obj.monad_\u03bc_app {C : Type u} [category C] (X : C) [limits.has_binary_coproducts C] (Y : C) : nat_trans.app \u03bc_ Y = limits.coprod.desc limits.coprod.inl \ud835\udfd9 :=\n  Eq.refl (nat_trans.app \u03bc_ 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) \u2964 under X :=\n  functor.mk\n    (fun (A : monad.algebra (functor.obj limits.coprod.functor X)) => under.mk (limits.coprod.inl \u226b monad.algebra.a A))\n    fun (A\u2081 A\u2082 : monad.algebra (functor.obj limits.coprod.functor X)) (f : A\u2081 \u27f6 A\u2082) =>\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 \ud835\udfed 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 \u211d\n\nWe introduce the necessary bits to be able to define manifolds modelled over `\u211d^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 \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n)` for the model space\n  used to define `n`-dimensional real manifolds with boundary\n* `model_with_corners \u211d (euclidean_space \u211d (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* `\ud835\udce1 n` for the identity model with corners on `euclidean_space \u211d (fin n)`\n* `\ud835\udce1\u2202 n` for `model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n)`.\n\nFor instance, if a manifold `M` is boundaryless, smooth and modelled on `euclidean_space \u211d (fin m)`,\nand `N` is smooth with boundary modelled on `euclidean_half_space n`, and `f : M \u2192 N` is a smooth\nmap, then the derivative of `f` can be written simply as `mfderiv (\ud835\udce1 m) (\ud835\udce1\u2202 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 `\u211d^n`, used to model manifolds with boundary. We only define it when\n`1 \u2264 n`, as the definition only makes sense in this case.\n-/\ndef euclidean_half_space (n : \u2115) [has_zero (fin n)] : Type :=\n{x : euclidean_space \u211d (fin n) // 0 \u2264 x 0}\n\n/--\nThe quadrant in `\u211d^n`, used to model manifolds with corners, made of all vectors with nonnegative\ncoordinates.\n-/\ndef euclidean_quadrant (n : \u2115) : Type := {x : euclidean_space \u211d (fin n) // \u2200i:fin n, 0 \u2264 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 : \u2115}\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) := \u27e8\u27e80, le_rfl\u27e9\u27e9\ninstance : inhabited (euclidean_quadrant n) := \u27e8\u27e80, \u03bb i, le_rfl\u27e9\u27e9\n\nlemma range_half_space (n : \u2115) [has_zero (fin n)] :\n  range (\u03bbx : euclidean_half_space n, x.val) = {y | 0 \u2264 y 0} :=\nby simp\n\nlemma range_quadrant (n : \u2115) :\n  range (\u03bbx : euclidean_quadrant n, x.val) = {y | \u2200i:fin n, 0 \u2264 y i} :=\nby simp\n\nend\n\n/--\nDefinition of the model with corners `(euclidean_space \u211d (fin n), euclidean_half_space n)`, used as\na model for manifolds with boundary. In the locale `manifold`, use the shortcut `\ud835\udce1\u2202 n`.\n-/\ndef model_with_corners_euclidean_half_space (n : \u2115) [has_zero (fin n)] :\n  model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_half_space n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := \u03bbx, \u27e8update x 0 (max (x 0) 0), by simp [le_refl]\u27e9,\n  source      := univ,\n  target      := {x | 0 \u2264 x 0},\n  map_source' := \u03bbx hx, x.property,\n  map_target' := \u03bbx hx, mem_univ _,\n  left_inv'   := \u03bb \u27e8xval, xprop\u27e9 hx, begin\n    rw [subtype.mk_eq_mk, update_eq_iff],\n    exact \u27e8max_eq_left xprop, \u03bb i _, rfl\u27e9\n  end,\n  right_inv'  := \u03bbx hx, update_eq_iff.2 \u27e8max_eq_left hx, \u03bb i _, rfl\u27e9,\n  source_eq    := rfl,\n  unique_diff' :=\n    have this : unique_diff_on \u211d _ :=\n      unique_diff_on.pi (fin n) (\u03bb _, \u211d) _ _ (\u03bb i \u2208 ({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 \u211d (fin n), euclidean_quadrant n)`, used as a\nmodel for manifolds with corners -/\ndef model_with_corners_euclidean_quadrant (n : \u2115) :\n  model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_quadrant n) :=\n{ to_fun      := subtype.val,\n  inv_fun     := \u03bbx, \u27e8\u03bbi, max (x i) 0, \u03bbi, by simp only [le_refl, or_true, le_max_iff]\u27e9,\n  source      := univ,\n  target      := {x | \u2200 i, 0 \u2264 x i},\n  map_source' := \u03bbx hx, by simpa only [subtype.range_val] using x.property,\n  map_target' := \u03bbx hx, mem_univ _,\n  left_inv'   := \u03bb \u27e8xval, xprop\u27e9 hx, by { ext i, simp only [subtype.coe_mk, xprop i, max_eq_left] },\n  right_inv' := \u03bb 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 \u211d _ :=\n      unique_diff_on.univ_pi (fin n) (\u03bb _, \u211d) _ (\u03bb 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 $ \u03bb i,\n    (continuous_id.max continuous_const).comp (continuous_apply i) }\n\nlocalized \"notation `\ud835\udce1 `n :=\n  (model_with_corners_self \u211d (euclidean_space \u211d (fin n)) :\n    model_with_corners \u211d (euclidean_space \u211d (fin n)) (euclidean_space \u211d (fin n)))\" in manifold\nlocalized \"notation `\ud835\udce1\u2202 `n :=\n  (model_with_corners_euclidean_half_space n :\n    model_with_corners \u211d (euclidean_space \u211d (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 : \u211d) [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      := \u03bb(z : Icc x y), \u27e8\u03bbi, z.val - x, sub_nonneg.mpr z.property.1\u27e9,\n  inv_fun     := \u03bbz, \u27e8min (z.val 0 + x) y, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y))]\u27e9,\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 \u27e8z, hz\u27e9 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 \u27e8z, hz\u27e9 h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x + z 0 \u2264 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 : \u211d | z < y} := is_open_Iio,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : \u211d | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space \u211d (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (\u03bb _, \u211d) _ 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 (\u03bb (z : \u211d) (i : fin 1), z - x) :=\n      continuous.sub (continuous_pi $ \u03bbi, 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 (\u03bb z : \u211d, min (z + x) y) :=\n      (continuous_id.add continuous_const).min continuous_const,\n    have B : continuous (\u03bbz : euclidean_space \u211d (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 : \u211d) [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      := \u03bb(z : Icc x y), \u27e8\u03bbi, y - z.val, sub_nonneg.mpr z.property.2\u27e9,\n  inv_fun     := \u03bbz,\n    \u27e8max (y - z.val 0) x, by simp [le_refl, z.prop, le_of_lt (fact.out (x < y)), sub_eq_add_neg]\u27e9,\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 \u27e8z, hz\u27e9 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 \u27e8z, hz\u27e9 h'z,\n    rw subtype.mk_eq_mk,\n    funext,\n    dsimp at hz h'z,\n    have A : x \u2264 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 : \u211d | x < z} := is_open_Ioi,\n    exact this.preimage continuous_subtype_val\n  end,\n  open_target := begin\n    have : is_open {z : \u211d | z < y - x} := is_open_Iio,\n    have : is_open {z : euclidean_space \u211d (fin 1) | z 0 < y - x} :=\n      this.preimage (@continuous_apply (fin 1) (\u03bb _, \u211d) _ 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 (\u03bb (z : \u211d) (i : fin 1), y - z) :=\n      continuous_const.sub (continuous_pi (\u03bbi, 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 (\u03bb z : \u211d, max (y - z) x) :=\n      (continuous_const.sub continuous_id).max continuous_const,\n    have B : continuous (\u03bbz : euclidean_space \u211d (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 : \u211d) [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 := \u03bbz, if z.val < y then Icc_left_chart x y else Icc_right_chart x y,\n  mem_chart_source := \u03bbz, 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 := \u03bb z, by by_cases h' : (z : \u211d) < y; simp [h'] }\n\n/--\nThe manifold structure on `[x, y]` is smooth.\n-/\ninstance Icc_smooth_manifold (x y : \u211d) [fact (x < y)] :\n  smooth_manifold_with_corners (\ud835\udce1\u2202 1) (Icc x y) :=\nbegin\n  have M : times_cont_diff_on \u211d \u221e (\u03bbz : euclidean_space \u211d (fin 1), - z + (\u03bbi, 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^\u221e` 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 _ \u27e8\u27e8hz\u2081, hz\u2082\u27e9, \u27e8\u27e8z, hz\u2080\u27e9, rfl\u27e9\u27e9,\n    simp only [model_with_corners_euclidean_half_space, Icc_left_chart, Icc_right_chart,\n      update_same, max_eq_left, hz\u2080, lt_sub_iff_add_lt] with mfld_simps at hz\u2081 hz\u2082,\n    rw [min_eq_left hz\u2081.le, lt_add_iff_pos_left] at hz\u2082,\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\u2081.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 _ \u27e8\u27e8hz\u2081, hz\u2082\u27e9, \u27e8z, hz\u2080\u27e9, rfl\u27e9,\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\u2080] with mfld_simps at hz\u2081 hz\u2082,\n    rw lt_sub at hz\u2081,\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\u2080, hz\u2081.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 : \u211d) < 1) := \u27e8zero_lt_one\u27e9\n\nlocal attribute [instance] fact_zero_lt_one\n\ninstance : charted_space (euclidean_half_space 1) (Icc (0 : \u211d) 1) := by apply_instance\ninstance : smooth_manifold_with_corners (\ud835\udce1\u2202 1) (Icc (0 : \u211d) 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 \u27f6 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 \u29f8 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   \u2243\u2097[R] f.ker.quotient  : (submodule.quot_equiv_of_eq_bot _ (ker_eq_bot_of_mono _)).symm\n        ... \u2243\u2097[R] f.range         : linear_map.quot_ker_equiv_range f\n        ... \u2243\u2097[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 \u226a\u226b\u2097\n          ((linear_map.quot_ker_equiv_range f) \u226a\u226b\u2097\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            \u2243\u2097[R] f.ker.quotient : submodule.quot_equiv_of_eq _ _ (submodule.range_subtype _)\n        ... \u2243\u2097[R] f.range        : linear_map.quot_ker_equiv_range f\n        ... \u2243\u2097[R] N              : linear_equiv.of_top _ (range_eq_top_of_epi _)\n        ```\n      -/\n        (((submodule.quot_equiv_of_eq _ _ (submodule.range_subtype _)) \u226a\u226b\u2097\n          (linear_map.quot_ker_equiv_range f)) \u226a\u226b\u2097\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 := \u27e8by apply_instance\u27e9,\n  has_kernels := by apply_instance,\n  has_cokernels := has_cokernels_Module,\n  normal_mono := \u03bb X Y, normal_mono,\n  normal_epi := \u03bb X Y, normal_epi }\n\nvariables {O : Module.{v} R} (g : N \u27f6 O)\n\nopen linear_map\nlocal attribute [instance] preadditive.has_equalizers_of_has_kernels\n\ntheorem exact_iff : exact f g \u2194 f.range = g.ker :=\nbegin\n  rw abelian.exact_iff' f g (kernel_is_limit _) (cokernel_is_colimit _),\n  exact \u27e8\u03bb h, le_antisymm (range_le_ker_iff.2 h.1) (ker_le_range_iff.2 h.2),\n    \u03bb h, \u27e8range_le_ker_iff.1 $ le_of_eq h, ker_le_range_iff.1 $ le_of_eq h.symm\u27e9\u27e9\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\u2081 v\u2082 u u\u2081 u\u2082\n\nnoncomputable theory\n\nopen category_theory category_theory.category category_theory.limits\n\nvariables {C : Type u\u2081} [category.{v\u2081} C]\nvariables {D : Type u\u2082} [category.{v\u2082} D]\nvariables (G : C \u2964 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\u2081} X)) \u2243 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\u2081} 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\u2081} 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\u2081} C) G] :\n  is_terminal (G.obj (\u22a4_ C)) :=\nterminal_is_terminal.is_terminal_obj G (\u22a4_ 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\u2081} C) G] :\n  has_terminal D :=\n\u27e8\u03bb F,\nbegin\n  haveI := has_limit.mk \u27e8_, is_limit_of_has_terminal_of_preserves_limit G\u27e9,\n  apply has_limit_of_iso F.unique_from_empty.symm,\nend\u27e9\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\u2082} D)),\n  apply i,\nend\n\n/-- If there is any isomorphism `G.obj \u22a4 \u27f6 \u22a4`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_is_iso\n  (f : G.obj (\u22a4_ C) \u27f6 \u22a4_ 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 \u22a4 \u2245 \u22a4`, then `G` preserves terminal objects. -/\ndef preserves_terminal_of_iso\n  (f : G.obj (\u22a4_ C) \u2245 \u22a4_ D) : preserves_limit (functor.empty C) G :=\npreserves_terminal_of_is_iso G f.hom\n\nvariables [preserves_limit (functor.empty.{v\u2081} 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 (\u22a4_ C) \u2245 \u22a4_ 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 \u2190 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\u2081} X)) \u2243 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\u2081} 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\u2081} 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\u2081} C) G] :\n  is_initial (G.obj (\u22a5_ C)) :=\ninitial_is_initial.is_initial_obj G (\u22a5_ 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\u2081} C) G] :\n  has_initial D :=\n\u27e8\u03bb F,\nbegin\n  haveI := has_colimit.mk \u27e8_, is_colimit_of_has_initial_of_preserves_colimit G\u27e9,\n  apply has_colimit_of_iso F.unique_from_empty,\nend\u27e9\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\u2082} D)),\n  apply i,\nend\n\n/-- If there is any isomorphism `\u22a5 \u27f6 G.obj \u22a5`, then `G` preserves initial objects. -/\ndef preserves_initial_of_is_iso\n  (f : \u22a5_ D \u27f6 G.obj (\u22a5_ 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 `\u22a5 \u2245 G.obj \u22a5 `, then `G` preserves initial objects. -/\ndef preserves_initial_of_iso\n  (f : \u22a5_ D \u2245 G.obj (\u22a5_ C)) : preserves_colimit (functor.empty C) G :=\npreserves_initial_of_is_iso G f.hom\n\nvariables [preserves_colimit (functor.empty.{v\u2081} 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 (\u22a5_ C) \u2245 \u22a5_ 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 \u2190 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 \u2192 List Nat \u2192 Bool \u2192 Bool \u2192 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 \u2192 List Nat \u2192 Bool \u2192 Bool \u2192 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 \u00b7.1)\n  let stx2 := s.map (mkIdent \u00b7.2)\n  elabCommand (\u2190 set_option hygiene false in `(\n    def Dim2.keller' : Dim2 \u2192 Dim2 \u2192 Bool\n    $[| $stx1, $stx2 => true]*\n    | _, _ => false\n\n    @[implementedBy Dim2.keller'] def Dim2.keller : Dim2 \u2192 Dim2 \u2192 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 \u2192 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 \u00d7 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\u2082 : Dim2 \u00d7 Dim2 \u2192 Dim2 \u00d7 Dim2 \u2192 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\u2082 : dim4.Pairwise (Dim2.ok\u2082 \u00b7 \u00b7) := 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 : \u2200 (f : bool \u2192 bool) b x y z,\n    x = f b \u2192 y = f x \u2192 z = f y \u2192 z = x :=\nbegin\n    intros f b x y z h1 h2 h3,\n    induction b,\n        induction x,\n            rw \u2190h1 at h2,\n            rw h2 at h3,\n            simp [h3],\n            rw \u2190h1,\n        rw h1,\n        induction y,\n            assumption,\n        simp * at *,\n        rw \u2190h2,\n    induction x,\n        induction y,\n            rw \u2190h2 at h3,\n            assumption,\n        rw h3,\n        rw \u2190h1,\n    rw \u2190h1 at h2,\n    rw [h2, \u2190h1] at h3,\n    assumption,\nend\n\nexample : \u2200 (f : bool \u2192 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 \u2192 X \u2192 Prop) : X \u2192 X \u2192 Prop := \u03bb x y, Q x y \u2227 \u00ac Q y x\n\n-- uniformily defines indifference for P and R relations\ndef I (Q : X \u2192 X \u2192 Prop) : X \u2192 X \u2192 Prop := \u03bb x y, x = y \u2228 (Q x y \u2227 Q y x)\n\ndef N (Q : X \u2192 X \u2192 Prop) : X \u2192 X \u2192 Prop := \u03bb x y, \u00acx = y \u2227 \u00ac Q x y \u2227 \u00ac Q y x\n\nlemma P_asymmetric (Q : X \u2192 X \u2192 Prop) {x y : X} : (P Q) x y \u2192 \u00ac (P Q) y x :=\nbegin\n  intros \u1fb0 \u1fb0_1, cases \u1fb0_1, cases \u1fb0, solve_by_elim,\nend\n\nlemma P_irrefl (Q : X \u2192 X \u2192 Prop) {x : X} : \u00ac (P Q) x x :=\nbegin\n  intros \u1fb0, cases \u1fb0, solve_by_elim,\nend\n\nlemma I_refl (Q : X \u2192 X \u2192 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 \u2192 X \u2192 Prop) {x : X} : \u00ac(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 \u2964 Set\nvariables (X : Presheaf)(Y : Presheaf)\n\nstructure open_imersion { Y X : Ring \u2964 Set} (\u03b9 : Y \u27f6  X)  := \n(\u03c7  : nat_trans X  \u03a9 ) \n(mono_\u03b9 : \u2200 A :  Ring, mono (\u03b9.app A))\n(Hyp_1 : \u2200 A : Ring, \u2200 y : Y.obj(A), \u03c7.app(A)  ( \u03b9.app(A) y ) = (\u22a4 : ideal A))\n(Hyp_2 : \u2200 A : Ring, \u2200 x : X.obj(A), \u03c7.app(A) x = (\u22a4 : ideal A) \u2192 \u2203 y : Y.obj(A), \u03b9.app A y = x)\n\nstructure closed_imersion {X Y : Ring \u2964 Set} (\u03b9 : nat_trans Y  X) := \n(\u03c7  : nat_trans X  \u03a9 ) \n(mono_\u03b9 : \u2200 A :  Ring, mono (\u03b9.app A))\n(Hyp_1 : \u2200 A : Ring, \u2200 y : Y.obj(A), (\u03c7.app(A) (\u03b9.app(A) y)) = (\u22a5  : ideal A))\n(Hyp_2 : \u2200 A : Ring, \u2200 x : X.obj(A), \u03c7.app(A) x = (\u22a5 : ideal A) \u2192 \u2203 y : Y.obj(A), \u03b9.app A y = x)\n\nlemma open_imersion_is_mono (\u03b9 : Y \u27f6  X) : open_imersion  \u03b9  \u2192  \u2200 A :  Ring, mono (\u03b9.app A)  :=\u03bb U, U.mono_\u03b9 \nlemma closed_imersion_is_mono (\u03b9 : Y \u27f6  X) : closed_imersion  \u03b9  \u2192  \u2200 A :  Ring, mono (\u03b9.app A)  :=\u03bb U, U.mono_\u03b9 \n\nstructure sieves (X : Presheaf) :=\n(Y : Presheaf)\n(\u03b9 : nat_trans Y X)\n(mono_\u03b9 : \u2200 A : Ring, mono (\u03b9.app A))\n\nstructure covering_familly (R : Ring) :=\n(U : sieves $ Spec R)\n(Hyp : \u2203 S : set R, \u2200 A : Ring, \u2200 y : U.Y.obj A, \u2203 s \u2208 S,  ((U.\u03b9.app A)(y)).to_fun (s) = 1)\n\n\nstructure matching_familly (X : Presheaf)(A : Ring) := \n(F : covering_familly A)\n(\u03b2 : nat_trans F.U.Y X)\n\n\n\n\n---  Je dois d\u00e9finir quoi ? \n---  Pour R un anneau, je dois d\u00e9finir la notion de sous-foncteur couvrant de (Spec R)\n--- C'est  \u222a (s : S) D(s) pour s \u2282 R \n--- definir la notion de topology de grothendieck sur Ring^(op) \u2243 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(\u03c7  :  nat_trans X \u03a9 ) \n(Hyp_1 : \u2200 A : Ring, \u2200 y : U.Y.obj(A), \u03c7.app(A)  ( U.\u03b9.app(A) y ) = (\u22a4 : ideal A))\n(Hyp_2 : \u2200 A : Ring, \u2200 x : X.obj(A), \u03c7.app(A) x = (\u22a4 : ideal A) \u2192 \u2203 y : U.Y.obj(A), U.\u03b9.app A y = x)\n\n\n\n\n\nvariables (\u03b9 : Y \u27f6  X)\n#check Open\n\n-- variables (U1 : Open X)(U2 : Open X)\n-- def  intersection : Open X \u2192 Open X \u2192  Open X := \u03bb 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\u00f6lzl. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Johannes H\u00f6lzl\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\u2081 u\u2082 v\u2081 v\u2082 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, \u03a0, \u03a3, set, and subtype types\n * proof composition and identity laws\n * implement method to derive relators from datatype\n-/\n\ndef lift_fun {\u03b1 : Sort u\u2081} {\u03b2 : Sort u\u2082} {\u03b3 : Sort v\u2081} {\u03b4 : Sort v\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    (S : \u03b3 \u2192 \u03b4 \u2192 Prop) (f : \u03b1 \u2192 \u03b3) (g : \u03b2 \u2192 \u03b4) :=\n  \u2200 {a : \u03b1} {b : \u03b2}, R a b \u2192 S (f a) (g b)\n\ninfixr:40 \" \u21d2 \" => Mathlib.relator.lift_fun\n\ndef right_total {\u03b1 : Type u\u2081} {\u03b2 : outParam (Type u\u2082)} (R : outParam (\u03b1 \u2192 \u03b2 \u2192 Prop)) :=\n  \u2200 (b : \u03b2), \u2203 (a : \u03b1), R a b\n\ndef left_total {\u03b1 : Type u\u2081} {\u03b2 : outParam (Type u\u2082)} (R : outParam (\u03b1 \u2192 \u03b2 \u2192 Prop)) :=\n  \u2200 (a : \u03b1), \u2203 (b : \u03b2), R a b\n\ndef bi_total {\u03b1 : Type u\u2081} {\u03b2 : outParam (Type u\u2082)} (R : outParam (\u03b1 \u2192 \u03b2 \u2192 Prop)) :=\n  left_total R \u2227 right_total R\n\ndef left_unique {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 {a : \u03b1} {b : \u03b2} {c : \u03b1}, R a b \u2192 R c b \u2192 a = c\n\ndef right_unique {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) :=\n  \u2200 {a : \u03b1} {b c : \u03b2}, R a b \u2192 R a c \u2192 b = c\n\ntheorem rel_forall_of_right_total {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop)\n    [t : right_total R] :\n    lift_fun (R \u21d2 implies) implies (fun (p : \u03b1 \u2192 Prop) => \u2200 (i : \u03b1), p i)\n        fun (q : \u03b2 \u2192 Prop) => \u2200 (i : \u03b2), q i :=\n  fun (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) (Hrel : lift_fun R implies p q) (H : \u2200 (i : \u03b1), p i) (b : \u03b2) =>\n    exists.elim (t b) fun (a : \u03b1) (Rab : R a b) => Hrel Rab (H a)\n\ntheorem rel_exists_of_left_total {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) [t : left_total R] :\n    lift_fun (R \u21d2 implies) implies (fun (p : \u03b1 \u2192 Prop) => \u2203 (i : \u03b1), p i)\n        fun (q : \u03b2 \u2192 Prop) => \u2203 (i : \u03b2), q i :=\n  sorry\n\ntheorem rel_forall_of_total {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) [t : bi_total R] :\n    lift_fun (R \u21d2 Iff) Iff (fun (p : \u03b1 \u2192 Prop) => \u2200 (i : \u03b1), p i)\n        fun (q : \u03b2 \u2192 Prop) => \u2200 (i : \u03b2), q i :=\n  sorry\n\ntheorem rel_exists_of_total {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) [t : bi_total R] :\n    lift_fun (R \u21d2 Iff) Iff (fun (p : \u03b1 \u2192 Prop) => \u2203 (i : \u03b1), p i)\n        fun (q : \u03b2 \u2192 Prop) => \u2203 (i : \u03b2), q i :=\n  sorry\n\ntheorem left_unique_of_rel_eq {\u03b1 : Type u\u2081} {\u03b2 : Type u\u2082} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) {eq' : \u03b2 \u2192 \u03b2 \u2192 Prop}\n    (he : lift_fun R (R \u21d2 Iff) Eq eq') : left_unique R :=\n  fun {a : \u03b1} {b : \u03b2} {c : \u03b1} (\u1fb0 : R a b) (\u1fb0_1 : R c b) =>\n    idRhs (a = c) ((fun (this : eq' b b) => iff.mpr (he \u1fb0 \u1fb0_1) this) (iff.mp (he \u1fb0 \u1fb0) rfl))\n\ntheorem rel_imp : lift_fun Iff (Iff \u21d2 Iff) implies implies :=\n  fun (p q : Prop) (h : p \u2194 q) (r s : Prop) (l : r \u2194 s) => imp_congr h l\n\ntheorem rel_not : lift_fun Iff Iff Not Not := fun (p q : Prop) (h : p \u2194 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 {\u03b1 : Type u\u2081} : bi_total Eq :=\n  { left := fun (a : \u03b1) => Exists.intro a rfl, right := fun (a : \u03b1) => Exists.intro a rfl }\n\ndef bi_unique {\u03b1 : Type u_1} {\u03b2 : Type u_2} (r : \u03b1 \u2192 \u03b2 \u2192 Prop) := left_unique r \u2227 right_unique r\n\ntheorem left_unique_flip {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (h : left_unique r) :\n    right_unique (flip r) :=\n  fun {a : \u03b2} {b c : \u03b1} (\u1fb0 : flip r a b) (\u1fb0_1 : flip r a c) => idRhs (b = c) (h \u1fb0 \u1fb0_1)\n\ntheorem rel_and : lift_fun Iff (Iff \u21d2 Iff) And And :=\n  fun (a b : Prop) (h\u2081 : a \u2194 b) (c d : Prop) (h\u2082 : c \u2194 d) => and_congr h\u2081 h\u2082\n\ntheorem rel_or : lift_fun Iff (Iff \u21d2 Iff) Or Or :=\n  fun (a b : Prop) (h\u2081 : a \u2194 b) (c d : Prop) (h\u2082 : c \u2194 d) => or_congr h\u2081 h\u2082\n\ntheorem rel_iff : lift_fun Iff (Iff \u21d2 Iff) Iff Iff :=\n  fun (a b : Prop) (h\u2081 : a \u2194 b) (c d : Prop) (h\u2082 : c \u2194 d) => iff_congr h\u2081 h\u2082\n\ntheorem rel_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (hr : bi_unique r) :\n    lift_fun r (r \u21d2 Iff) Eq Eq :=\n  fun (a : \u03b1) (b : \u03b2) (h\u2081 : r a b) (c : \u03b1) (d : \u03b2) (h\u2082 : r c d) =>\n    { mp := fun (h : a = c) => Eq._oldrec (fun (h\u2082 : r a d) => and.right hr a b d h\u2081 h\u2082) h h\u2082,\n      mpr := fun (h : b = d) => Eq._oldrec (fun (h\u2082 : r c b) => and.left hr a b c h\u2081 h\u2082) h h\u2082 }\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 \u2227 \u00ac p \u2192 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": "/-\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 : \u2115) (p : preform) :\n    clauses.unsat (dnf (preform.not p)) \u2192 univ_close p (fun (x : \u2115) => 0) m :=\n  fun (\u1fb0 : clauses.unsat (dnf (preform.not p))) =>\n    idRhs (univ_close p (fun (x : \u2115) => 0) m)\n      (univ_close_of_valid (valid_of_unsat_not (unsat_of_clauses_unsat \u1fb0)))\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/omega/int/main_auto.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": "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 : \u2115)\n    (X : Type u) \n    (K : Type v) \n    (V : Type w) \n    (n : \u2115) \n    (k : K)\n    (\u03b9 : Type*)\n    (s : finset \u03b9) \n    (g : \u03b9 \u2192 K) \n    (v : \u03b9 \u2192 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 : \u03b9 \u2192 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    (\u03b9 : 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 \u03b9 )\n: affine_frame\n-/\n/-\nstructure affine_frame  :=\n(origin : X) \n(basis : \u03b9 \u2192 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 : \u03b9 \u2192 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 : \u03b9 \u2192 V) \n(proof_is_basis : is_basis K basis)\n\ndef affine_tuple_frame \n    (K : Type v)\n    (n : \u2115)\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    \u27e8sorry, sorry\u27e9\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    := \u27e8sorry, sorry\u27e9\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--\u27e8aff_group_action K n, aff_zero_sadd K n, aff_add_sadd K n\u27e9\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 : \u2115}\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 : \u03b9 \u2192 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 : \u03b9 \u2192 aff_coord_vec) \n    (proof_is_basis : is_basis K basis) : affine_coordinate_frame-/\nwith aff_coord_pt :  aff_pt_coord_tuple K n \u2192 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 \u2192 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 \u03b9) 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 \u03b9) 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 \u03b9) :=\nmatch frame with\n| std_frame := _\n| gen_frame o b pf := o\nend\n\ndef frame_basis : affine_frame X K V \u03b9 \u2192 (\u03b9 \u2192 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 \u03b9) \n    (cv1 cv2 : aff_coord_vec X K V n \u03b9 fr) \n    (cp1 cp2 : aff_coord_pt  X K V n \u03b9 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 \u2260 [] := \nbegin\nintro h,\nhave f : 0 \u2260 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 : \u2203 x_hd : K, \u2203 x_tl : list K, x.1 = x_hd :: x_tl :=\nbegin\ncases x,\ncases x_l,\n{\n    have f : 0 \u2260 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 \u2260 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 \u2260 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\u2083 : nat.succ (n' + 1) = nat.succ n' + 1 := rfl,\nhave h\u2084 : length (zero_vector K (nat.succ n')) = nat.succ (n' + 1) :=\n    by {rw eq.symm n_ih, refl},\nrw eq.symm h\u2083,\nexact h\u2084,\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 \u03b9 fr \u2192 aff_coord_vec X K V n \u03b9 fr \u2192 aff_coord_vec X K V n \u03b9 fr :=\n    \u03bb x y, \u27e8\u27e8ladd x.1.l y.1.l, list_sum_fixed K n x.1 y.1, sum_fst_fixed K n x.1 y.1\u27e9\u27e9\ndef vec_zero_coord : aff_coord_vec X K V n \u03b9 fr := \u27e8\u27e8zero_vector K n, len_zero K n, head_zero K n\u27e9\u27e9\ndef vec_neg_coord : aff_coord_vec X K V n \u03b9 fr \u2192 aff_coord_vec X K V n \u03b9 fr\n| \u27e8\u27e8l, len, fst\u27e9\u27e9 := \u27e8\u27e8vecl_neg l, vec_len_neg K n \u27e8l, len, fst\u27e9, head_neg_0 K n \u27e8l, len, fst\u27e9\u27e9\u27e9\n\n\n/-! ### type class instances for the abelian group operations -/\ninstance : has_add (aff_coord_vec X K V n \u03b9 fr) := \u27e8vec_add_coord X K V n \u03b9 fr\u27e9\ninstance : has_zero (aff_coord_vec X K V n \u03b9 fr) := \u27e8vec_zero_coord X K V n \u03b9 fr\u27e9\ninstance : has_neg (aff_coord_vec X K V n \u03b9 fr) := \u27e8vec_neg_coord X K V n \u03b9 fr\u27e9\n@[ext]\ndef vec_scalar_coord : K \u2192 aff_coord_vec X K V n \u03b9 fr \u2192 aff_coord_vec X K V n \u03b9 fr :=\n    \u03bb a x, \u27e8\u27e8scalar_mul a x.1.1, trans (scale_len a x.1.1) x.1.2, sorry\u27e9\u27e9\n/-! ### Type class instance for abelian group -/\ninstance aff_comm_group_coord : add_comm_group (aff_coord_vec X K V n \u03b9 fr) :=\nbegin\n    sorry\nend\ninstance : has_scalar K (aff_coord_vec X K V n \u03b9 fr) := \u27e8vec_scalar_coord X K V n \u03b9 fr\u27e9\n\n/-\nlemma vec_one_smul_coord : (1 : K) \u2022 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 : \u2200 g h : K, \u2200 x : aff_coord_vec X K V n \u03b9 fr, (g * h) \u2022 x = g \u2022 h \u2022 x := sorry\n\n\ninstance : mul_action K (aff_coord_vec X K V n \u03b9 fr) := \n    \u27e8sorry, vec_mul_smul_coord X K V n \u03b9 fr\u27e9\n\n\ninstance : distrib_mul_action K (aff_coord_vec X K V n \u03b9 fr) := \n    sorry\ninstance aff_semimod_coord : semimodule K (aff_coord_vec X K V n \u03b9 fr)\n    --[distrib_mul_action K (aff_coord_vec X K V n \u03b9 fr)] \n    := \n    -- extremely odd that this doesnt work....\n    \u27e8sorry, sorry\u27e9\n\n\n\ndef aff_group_action_coord : (aff_coord_vec X K V n \u03b9 fr) \u2192 (aff_coord_pt X K V n \u03b9 fr) \u2192 (aff_coord_pt X K V n \u03b9 fr) :=\n    \u03bb x y, \u27e8\u27e8ladd x.1.1 y.1.1, sorry, sorry\u27e9\u27e9\n\ndef aff_group_sub_coord : (aff_coord_pt X K V n \u03b9 fr) \u2192 (aff_coord_pt X K V n \u03b9 fr) \u2192 (aff_coord_vec X K V n \u03b9 fr) :=\n    \u03bb x y, \u27e8\u27e8ladd x.1.1 (vecl_neg y.1.1), sorry, sorry\u27e9\u27e9\n\n\n\ninstance : has_vadd (aff_coord_vec X K V n \u03b9 fr) (aff_coord_pt X K V n \u03b9 fr) := \u27e8aff_group_action_coord X K V n \u03b9 fr\u27e9\n\ninstance : has_vsub (aff_coord_vec X K V n \u03b9 fr) (aff_coord_pt X K V n \u03b9 fr) := \u27e8aff_group_sub_coord X K V n \u03b9 fr\u27e9\n\ninstance : add_action (aff_coord_vec X K V n \u03b9 fr) (aff_coord_pt X K V n \u03b9 fr) := sorry--\u27e8aff_group_action K n, aff_zero_sadd K n, aff_add_sadd K n\u27e9\n\n/-\nWe need proof that given a frame f, \n\u27e8 aff_coord_pt f, aff_coord_vec f\u27e9 is \nan affine space,\n-/\n\n/-\n\ndef vecptadd := r3_der2_pt1 +\u1d65 r3_der2_vec2 --expected : pass\ndef vecptsub := r3_der2_pt1 -\u1d65 r3_der2_vec2 --expected : pass\ndef ptvecsub := r3_der2_vec2 -\u1d65 r3_der2_pt1 -- expected : pass\n-/\ndef pt_plus_vec\n    {X : Type u} \n    {K : Type v} \n    {V : Type w} \n    {n : \u2115}\n    {\u03b9 : 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 \u03b9} :\n    (aff_coord_pt X K V n \u03b9 fr) \u2192 \n    (aff_coord_vec X K V n \u03b9 fr) \u2192 \n    (aff_coord_pt X K V n \u03b9 fr) \n| p v := aff_group_action_coord X K V n \u03b9 fr v p\n\nnotation\n pt +\u1d65 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 : \u2115}\n    {\u03b9 : 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 \u03b9} :\n    (aff_coord_pt X K V n \u03b9 fr) \u2192 \n    (aff_coord_vec X K V n \u03b9 fr) \u2192 \n    (aff_coord_pt X K V n \u03b9 fr) \n| p v := aff_group_action_coord X K V n \u03b9 fr (vec_neg_coord X K V n \u03b9 fr v) p\n.\nnotation\n pt -\u1d65 v := pt_minus_vec pt v\n\n\ndef prf : affine_space (aff_coord_vec X K V n \u03b9 fr) (aff_coord_pt  X K V n \u03b9 fr) := sorry\n\ninstance afc : affine_space \n    (aff_coord_vec X K V n \u03b9 fr) \n    (aff_coord_pt  X K V n \u03b9 fr) := \n    prf X K V n \u03b9 fr\n\n\n/-\nKEEP?\n-/\ndef affine_coord_tuple_space_type (K : Type v) (n : \u2115) [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 \u2192 list K := \u03bb 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 \u2192 aff_vec_coord_tuple K n :=\n\u03bb x, \u27e8list.to_basis_vec K n x, len_basis_vec_fixed K n x, head_basis_vec_fixed K n x\u27e9\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        \u27e8pt_zero K n, std_basis K n, std_is_basis K n\u27e9\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\u27e8@uniform_continuous_id, @uniform_continuous.comp\u27e9\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 (\u03b1 : Type u) [uniform_space \u03b1] : UniformSpace := \u27e8\u03b1\u27e9\n\ninstance : inhabited UniformSpace := \u27e8UniformSpace.of empty\u27e9\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 \u27f6 Y) (\u03bb _, X \u2192 Y) :=\n\u27e8category_theory.functor.map (forget UniformSpace)\u27e9\n\n@[simp] lemma coe_comp {X Y Z : UniformSpace} (f : X \u27f6 Y) (g : Y \u27f6 Z) :\n  (f \u226b g : X \u2192 Z) = g \u2218 f := rfl\n@[simp] lemma coe_id (X : UniformSpace) : (\ud835\udfd9 X : X \u2192 X) = id := rfl\n@[simp] lemma coe_mk {X Y : UniformSpace} (f : X \u2192 Y) (hf : uniform_continuous f) :\n  ((\u27e8f, hf\u27e9 : X \u27f6 Y) : X \u2192 Y) = f := rfl\n\nlemma hom_ext {X Y : UniformSpace} {f g : X \u27f6 Y} : (f : X \u2192 Y) = g \u2192 f = g := subtype.eq\n\n/-- The forgetful functor from uniform spaces to topological spaces. -/\ninstance has_forget_to_Top : has_forget\u2082 UniformSpace.{u} Top.{u} :=\n{ forget\u2082 :=\n  { obj := \u03bb X, Top.of X,\n    map := \u03bb 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(\u03b1 : Type u)\n[is_uniform_space : uniform_space \u03b1]\n[is_complete_space : complete_space \u03b1]\n[is_separated : separated_space \u03b1]\n\nnamespace CpltSepUniformSpace\n\ninstance : has_coe_to_sort CpltSepUniformSpace (Type u) := \u27e8CpltSepUniformSpace.\u03b1\u27e9\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).\u03b1) :=\nCpltSepUniformSpace.is_complete_space X\n\ninstance separated_space (X : CpltSepUniformSpace) : separated_space ((to_UniformSpace X).\u03b1) :=\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 := \u27e8X\u27e9\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 \u27e8CpltSepUniformSpace.of empty\u27e9\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\u2082 CpltSepUniformSpace UniformSpace :=\ninduced_category.has_forget\u2082 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 \u2964 CpltSepUniformSpace :=\n{ obj := \u03bb X, CpltSepUniformSpace.of (completion X),\n  map := \u03bb X Y f, \u27e8completion.map f.1, completion.uniform_continuous_map\u27e9,\n  map_id' := \u03bb X, subtype.eq completion.map_id,\n  map_comp' := \u03bb 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 \u27f6 (forget\u2082 CpltSepUniformSpace UniformSpace).obj (completion_functor.obj X) :=\n{ val := (coe : X \u2192 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 \u27f6 (forget\u2082 CpltSepUniformSpace UniformSpace).obj Y) :\n  completion_functor.obj X \u27f6 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 \u27f6 (forget\u2082 _ _).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 \u22a3 forget\u2082 CpltSepUniformSpace UniformSpace :=\nadjunction.mk_of_hom_equiv\n{ hom_equiv := \u03bb X Y,\n  { to_fun := \u03bb f, completion_hom X \u226b f,\n    inv_fun := \u03bb f, extension_hom f,\n    left_inv := \u03bb f, by { dsimp, erw extension_comp_coe },\n    right_inv := \u03bb 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' := \u03bb X X' Y f g,\n  begin\n    apply hom_ext, funext x, dsimp,\n    erw [coe_comp, \u2190completion.extension_map],\n    refl, exact g.property, exact f.property,\n  end }\n\nnoncomputable instance : is_right_adjoint (forget\u2082 CpltSepUniformSpace UniformSpace) :=\n\u27e8completion_functor, adj\u27e9\nnoncomputable instance : reflective (forget\u2082 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\u2082 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 \u2192+* S) (g : S \u2192+* T)\n\n-- def ring_hom.essentially_surjective (f : R \u2192+* S) : Prop :=\n-- \u2200 x : S, \u2203 a b : R, is_unit (f b) \u2227 x * f b = f a\n\n-- lemma is_localization.range_lift_is_unit_submonoid_map {x} : \n--   x \u2208 (is_localization.lift (\u03bb x : (is_unit.submonoid S).comap f, x.2) :\n--     localization ((is_unit.submonoid S).comap f) \u2192+* S).range \u2194 \n--     \u2203 a b : R, is_unit (f b) \u2227 x * f b = f a :=\n-- begin\n--   split,\n--   { rintro \u27e8x, rfl\u27e9,\n--     obtain \u27e8x, s, rfl\u27e9 := is_localization.mk'_surjective ((is_unit.submonoid S).comap f) x,\n--     refine \u27e8x, s, s.2, _\u27e9,\n--     rw [mul_comm, is_localization.lift_mk', \u2190 mul_assoc, units.mul_inv_eq_iff_eq_mul, mul_comm],\n--     refl },\n--   { rintro \u27e8a, b, hb, e\u27e9,\n--     refine \u27e8is_localization.mk' _ a \u27e8b, show b \u2208 (is_unit.submonoid S).comap f, from hb\u27e9, _\u27e9,\n--     rw [is_localization.lift_mk', units.mul_inv_eq_iff_eq_mul, eq_comm, \u2190 e], refl }\n-- end\n\n-- def fraction_subring : subring S :=\n-- { ..(is_localization.lift (\u03bb x : (is_unit.submonoid S).comap f, x.2) :\n--   localization ((is_unit.submonoid S).comap f) \u2192+* S).range.copy\n--   { x | \u2203 a b : R, is_unit (f b) \u2227 x * f b = f a }\n--   (set.ext $ \u03bb 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' := \u03bb x, \u27e8x, 1, (algebra_map R S).map_one.symm \u25b8 is_unit_one,\n--     by rw [map_one, mul_one]\u27e9,\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 \u2194 \n--   \u2203 (M : submonoid R) (hM : \u2200 x : M, is_unit (f x)),\n--     function.surjective (is_localization.lift hM : localization M \u2192+* S) :=\n-- begin\n--   split,\n--   { intro H,\n--     refine \u27e8(is_unit.submonoid S).comap f, \u03bb x, x.2, \u03bb x, _\u27e9,\n--     obtain \u27e8a, b, hb, e\u27e9 := H x,\n--     refine \u27e8is_localization.mk' _ a \u27e8b, show b \u2208 (is_unit.submonoid S).comap f, from hb\u27e9, _\u27e9,\n--     rw [is_localization.lift_mk', units.mul_inv_eq_iff_eq_mul, eq_comm, \u2190 e],\n--     refl },\n--   { rintro \u27e8M, hM, hM'\u27e9 x,\n--     obtain \u27e8x, rfl\u27e9 := hM' x,\n--     obtain \u27e8x, s, rfl\u27e9 := is_localization.mk'_surjective M x,\n--     refine \u27e8x, s, hM s, _\u27e9,\n--     rw [mul_comm, is_localization.lift_mk', \u2190 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 \u2194 fraction_subring f = \u22a4 :=\n-- begin\n--   rw eq_top_iff,\n--   exact \u27e8\u03bb h x _, h x, \u03bb h x, h trivial\u27e9\n-- end\n\n-- lemma of_surjective (hf : function.surjective f) :\n--   f.essentially_surjective :=\n-- begin\n--   intro x, obtain \u27e8x, rfl\u27e9 := hf x, refine \u27e8x, 1, _, _\u27e9; 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 \u27e8\u27e8y, s\u27e9, e\u27e9 := is_localization.surj M x,\n--   exact \u27e8y, s, is_localization.map_units _ s, e\u27e9,\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 \u27e8y, s, hs, e\u2081\u27e9 := hg x, \n--   obtain \u27e8z, t, ht, e\u2082\u27e9 := hf y, \n--   obtain \u27e8u, v, hv, e\u2083\u27e9 := hf s, \n--   refine \u27e8z * v, t * u, _, _\u27e9,\n--   { apply_fun g at e\u2083, simp only [ring_hom.comp_apply, map_mul] at e\u2083 \u22a2, rw \u2190 e\u2083,\n--     exact (ht.map g).mul (hs.mul $ hv.map g) },\n--   { apply_fun g at e\u2082 e\u2083, simp only [ring_hom.comp_apply, map_mul] at e\u2082 e\u2083 \u22a2,\n--     rw [\u2190 e\u2082, \u2190 e\u2083, \u2190 e\u2081], 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 \u22a2,\n--   obtain \u27e8M, hM, hM'\u27e9 := h,\n--   refine \u27e8M.map (algebra_map R S), _, _\u27e9,\n--   { rintro \u27e8_, x, hx, rfl\u27e9, rw [subtype.coe_mk, \u2190 is_scalar_tower.algebra_map_apply,\n--     \u2190 algebra.tensor_product.include_right.comp_algebra_map, ring_hom.comp_apply],\n--     exact (hM \u27e8x, hx\u27e9).map _ },\n--   { intro x,\n--     induction x using tensor_product.induction_on with x y x y hx hy,\n--     { exact \u27e80, map_zero _\u27e9 },\n--     { obtain \u27e8y, rfl\u27e9 := hM' y,\n--       obtain \u27e8y, s, rfl\u27e9 := is_localization.mk'_surjective M y,\n--       refine \u27e8is_localization.mk' _ (y \u2022 x)\n--         \u27e8_, submonoid.mem_map_of_mem (algebra_map R S) s.prop\u27e9, _\u27e9,\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, \u2190 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 \u27e8\u27e8x, rfl\u27e9, \u27e8y, rfl\u27e9\u27e9 := \u27e8hx, hy\u27e9, exact \u27e8x + y, map_add _ _ _\u27e9 } }\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 \u22a2,\n--   obtain \u27e8M, hM, hM'\u27e9 := h,\n--   refine \u27e8M.map f, _, _\u27e9,\n--   { rintros \u27e8_, x, hx, rfl\u27e9, exact hM \u27e8x, hx\u27e9 },\n--   { intro x,\n--     obtain \u27e8x, rfl\u27e9 := hM' x,\n--     obtain \u27e8x, s, rfl\u27e9 := is_localization.mk'_surjective M x,\n--     refine \u27e8is_localization.mk' _ (f x) \u27e8_, submonoid.mem_map_of_mem f s.prop\u27e9, _\u27e9,\n--     rw [is_localization.lift_mk', units.mul_inv_eq_iff_eq_mul, \n--       mul_comm, is_localization.lift_mk', \u2190 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) \u2192+* localization.at_prime p :=\n-- is_localization.map (localization.at_prime p) f\n--       (show (p.comap f).prime_compl \u2264 p.prime_compl.comap f, from le_refl _)\n\n-- lemma iff_stalk :\n--   f.essentially_surjective \u2194 \u2200 (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 \u27e8a, b, hb, e\u27e9 := this x,\n--     obtain \u27e8a, s, rfl\u27e9 := is_localization.mk'_surjective (p.comap f).prime_compl a,\n--     obtain \u27e8b, t, rfl\u27e9 := is_localization.mk'_surjective (p.comap f).prime_compl b,\n--     replace hb : b \u2208 (ideal.comap f p).prime_compl,\n--     { rwa [is_localization.map_mk', is_localization.at_prime.is_unit_mk'_iff] at hb },\n--     refine \u27e8is_localization.mk' _ (a * t) \u27e8_, mul_mem s.prop hb\u27e9, _\u27e9,\n--     rw [is_localization.map_mk', is_localization.map_mk',\n--       is_localization.eq_mk'_iff_mul_eq, mul_right_comm, \u2190 (is_localization.map_units\n--       (localization.at_prime p) \u27e8f t, show f t \u2208 p.prime_compl, from t.2\u27e9).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, \u2190 map_mul] at e,\n--     rw [is_localization.map_mk', is_localization.mk'_eq_iff_eq_mul, \u2190 e],\n--     refl },\n--   { intros H x,\n--     have : \u2200 (p : ideal S) [p.is_prime], \u2203 a \u2209 p.comap f, f a * x \u2208 f.range,\n--     { introsI p hp,\n--       obtain \u27e8y, hy\u27e9 := H p (is_localization.mk' _ x (1 : p.prime_compl)),\n--       obtain \u27e8y, s, rfl\u27e9 := 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 \u27e8a, b, hb, e\u27e9 := H (algebra_map _ _ x),\n--   simp only [ring_hom.comp_apply, \u2190 map_mul] at e,\n--   obtain \u27e8\u27e8_, n, rfl\u27e9, e'\u27e9 := (is_localization.eq_iff_exists (submonoid.powers (f r)) _).mp e,\n--   have : \u2203 m : \u2115, is_unit (f (b * r ^ m)),\n--   { obtain \u27e8c, \u27e8_, m, rfl\u27e9, hc\u27e9 := is_localization.mk'_surjective\n--       (submonoid.powers (f r)) (\u2191(hb.unit\u207b\u00b9) : localization.away (f r)),\n--     rw [\u2190 mul_one (\u2191(hb.unit\u207b\u00b9) : 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 \u27e8m, is_unit_of_mul_eq_one _ c _\u27e9,\n\n--    },\n\n--   have := is_localization.at_prime.is_unit_mk'_iff,\n--   refine \u27e8n, a * r ^ n, _\u27e9,\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 \u27e8\u27e8_, n, rfl\u27e9, p, hp, hp'\u27e9 := 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), \u2190 map_mul] at hp',\n--   rw [eval\u2082_eq_eval_map, \u2190 map_map, eval_map, eval\u2082_at_apply, \u2190 @is_localization.mk'_one _ _\n--     (submonoid.powers $ f r), is_localization.mk'_eq_zero_iff] at hp',\n--   obtain \u27e8\u27e8_, m, rfl\u27e9, H'\u27e9 := hp',\n--   rw [subtype.coe_mk, mul_comm, \u2190 map_pow, \u2190 ring_hom.algebra_map_to_algebra f,\n--     eval_map, \u2190 eval\u2082_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 \u2022 p).leading_coeff = (r : R) ^ m,\n--   { have hp'' : ((r : R) ^ m \u2022 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 \u2022 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'', \u2190 algebra.smul_def, smul_smul, \u2190 pow_add] at this,\n--   exact \u27e8m+n, this\u27e9\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) \u2192 Type u\n| nil : HList []\n| cons {\u03b1 \u03b1s} : \u03b1 \u2192 HList \u03b1s \u2192 HList (\u03b1 :: \u03b1s)\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 {\u03b1 \u03b2} {\u03b1s \u03b2s : List (Sort _)} {a : \u03b1} {b : \u03b2} {as : HList \u03b1s} {bs : HList \u03b2s} : \u03b1 = \u03b2 \u2192 \u03b1s = \u03b2s \u2192 a \u2245 b \u2192 as \u2245 bs \u2192 HList.cons a as \u2245 HList.cons b bs\n| rfl, rfl, HEq.rfl, HEq.rfl => HEq.rfl\n\n-- FIXME\n-- def ofList {\u03b1 : Type _} : (as : List \u03b1) \u2192 HList (as.map fun x => \u03b1)\n-- | [] => []\n-- | a::as => a :: ofList as\n\nprotected def ofListHVal : (vs : List HVal) \u2192 HList (vs.map HVal.sort)\n| [] => []\n| v::vs => v.val :: HList.ofListHVal vs\n\n@[specialize, inline] protected def foldl : {\u03b1s : List (Sort _)} \u2192 {\u03b2 : Sort _} \u2192 HList \u03b1s \u2192 HList (\u03b1s.map fun \u03b1 => \u03b1 \u2192 \u03b2 \u2192 \u03b2) \u2192 \u03b2 \u2192 \u03b2\n| [], _, [], [], b => b\n| _::_, _, x :: xs, f :: fs, b => HList.foldl xs fs (f x b)\n\nprotected def foldr : {\u03b1s : List (Sort _)} \u2192 {\u03b2 : Sort _} \u2192 HList \u03b1s \u2192 HList (\u03b1s.map fun \u03b1 => \u03b1 \u2192 \u03b2 \u2192 \u03b2) \u2192 \u03b2 \u2192 \u03b2\n| [], _, [], [], b => b\n| _::_, _, x :: xs, f :: fs, b => f x (HList.foldr xs fs b)\n\nprotected def append : {\u03b1s \u03b2s : List (Sort _)} \u2192 HList \u03b1s \u2192 HList \u03b2s \u2192 HList (\u03b1s ++ \u03b2s)\n| [], _, [], bs => bs\n| \u03b1 :: \u03b1s, \u03b2s, a::as, bs => List.cons_append \u03b1 \u03b1s \u03b2s \u25b8 cons a (HList.append as bs)\n\nprotected theorem nil_append {\u03b2s : List (Sort _)} (bs : HList \u03b2s) : HList.append [] bs = bs := rfl\n\nprotected theorem cons_append {\u03b1 : Sort _} {\u03b1s \u03b2s : List (Sort _)} (a : \u03b1) (as : HList \u03b1s) (bs : HList \u03b2s) : HList.append (a :: as) bs = a :: HList.append as bs := rfl\n\nprotected theorem append_nil {\u03b1s : List (Sort _)} (as : HList \u03b1s) : HList.append as [] \u2245 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    \u00b7 reflexivity\n    \u00b7 rw [List.append_nil]\n    \u00b7 reflexivity using (.\u2245.)\n    \u00b7 exact ih\n\nprotected theorem append_assoc {\u03b1s \u03b2s \u03b3s : List (Sort _)} (as : HList \u03b1s) (bs : HList \u03b2s) (cs : HList \u03b3s) : HList.append (HList.append as bs) cs \u2245 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    \u00b7 reflexivity\n    \u00b7 rw [List.append_assoc]\n    \u00b7 reflexivity using (.\u2245.)\n    \u00b7 exact ih\n\nprotected def mk : {\u03b1s : List (Sort _)} \u2192 ((i : Index \u03b1s) \u2192 i.val) \u2192 HList \u03b1s\n| [], _ => []\n| _::_, v => v .head :: HList.mk \u03bb i => v (.tail i)\n\nprotected def eval : {\u03b1s : List (Sort _)} \u2192 HList \u03b1s \u2192 (i : Index \u03b1s) \u2192 i.val\n| _::_, a::_, .head => a\n| _::_, _::as, .tail i => HList.eval as i\n\ndef equiv (\u03b1s : List (Sort _)) : Equiv (HList \u03b1s) ((i : Index \u03b1s) \u2192 i.val) where\n  fwd := HList.eval\n  rev := HList.mk\n  spec := by\n    intros as f\n    constr\n    \u00b7 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    \u00b7 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 {\u03c3 : nat}\n\nnamespace prf\n\n/- identity implication -/\n\nlemma id {p : form \u03c3} {\u0393 : ctx \u03c3} :\n  \u0393 \u22a2\u209b\u2085 p \u2283 p :=\nmp (mp (@pl2 \u03c3 \u0393 p (p \u2283 p) p) pl1) pl1\n\n/- deduction metatheorem -/\n\ntheorem deduction {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  (\u0393 \u2e34 p \u22a2\u209b\u2085 q) \u2192 (\u0393 \u22a2\u209b\u2085 p \u2283 q) :=\nbegin\n  generalize eq : (\u0393 \u2e34 p) = \u0393',\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 {\u0393 \u0394 : ctx \u03c3} {p : form \u03c3} :\n  (\u0394 \u22a2\u209b\u2085 p) \u2192 (\u0394 \u2286 \u0393) \u2192 (\u0393 \u22a2\u209b\u2085 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 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 p) \u2192 (\u0393 \u2e34 q \u22a2\u209b\u2085 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 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  (\u0393 \u2e34 p \u2e34 p \u22a2\u209b\u2085 q) \u2192 (\u0393 \u2e34 p \u22a2\u209b\u2085 q) :=\nbegin\n  generalize eq : (\u0393 \u2e34 p \u2e34 p) = \u0393',\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 \u03c3} {\u0393 : ctx \u03c3} :\n  (\u0393 \u2e34 p \u2e34 q \u22a2\u209b\u2085 r) \u2192 (\u0393 \u2e34 q \u2e34 p \u22a2\u209b\u2085 r) :=\nbegin\n  generalize eq : (\u0393 \u2e34 p \u2e34 q) = \u0393',\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 {\u0393 \u0394 : ctx \u03c3} {p : form \u03c3} :\n   \u0394 \u2286 \u0393 \u2192 (\u0394 \u22a2\u209b\u2085 p) \u2192 (\u0393 \u22a2\u209b\u2085 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 {\u0393 \u0394 : ctx \u03c3} {p : form \u03c3}:\n   \u0394 \u2286 \u0393 \u2192 (\u0393 \u222a \u0394 \u22a2\u209b\u2085 p) \u2192 (\u0393 \u22a2\u209b\u2085 p) :=\nbegin\n  generalize eq : \u0393 \u222a \u0394 = \u0393',\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 {\u0393 : ctx \u03c3} {p : form \u03c3} :\n  \u0393 \u2e34 p \u22a2\u209b\u2085 p :=\nby apply ax; apply or.intro_left; simp\n\nlemma pr1 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  \u0393 \u2e34 p \u2e34 q \u22a2\u209b\u2085 p :=\nby apply ax; apply or.intro_right; apply or.intro_left; simp\n\nlemma pr2 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  \u0393 \u2e34 p \u2e34 q \u22a2\u209b\u2085 q :=\nby apply ax; apply or.intro_left; simp\n\nlemma by_mp1 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  \u0393 \u2e34 p \u2e34 p \u2283 q \u22a2\u209b\u2085 q :=\nmp pr2 pr1\n\nlemma by_mp2 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  \u0393 \u2e34 p \u2283 q \u2e34 p \u22a2\u209b\u2085 q :=\nmp pr1 pr2\n\nlemma cut {\u0393 : ctx \u03c3} {p q r : form \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 p \u2283 q) \u2192 (\u0393 \u22a2\u209b\u2085 q \u2283 r) \u2192 (\u0393 \u22a2\u209b\u2085 p \u2283 r) :=\n\u03bb hpq hqr, mp (mp pl2 (mp pl1 hqr)) hpq\n\nlemma conv_deduction {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 p \u2283 q) \u2192 (\u0393 \u2e34 p \u22a2\u209b\u2085 q) :=\n\u03bb h, mp (weak h) pr \n\n/- left-hand side basic rules of inference -/\n\nlemma mp_in_ctx_left {\u0393 : ctx \u03c3} {p q r : form \u03c3} :\n  (\u0393 \u2e34 p \u2e34 q \u22a2\u209b\u2085 r) \u2192 (\u0393 \u2e34 p \u2e34 p \u2283 q \u22a2\u209b\u2085 r) :=\nbegin\n  generalize eq : (\u0393 \u2e34 p \u2e34 q) = \u0393',\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 {\u0393 : ctx \u03c3} {p q r : form \u03c3} :\n  (\u0393 \u2e34 p \u2e34 p \u2283 q \u22a2\u209b\u2085 r) \u2192 (\u0393 \u2e34 p \u2e34 q \u22a2\u209b\u2085 r) :=\nbegin\n  generalize eq : (\u0393 \u2e34 p \u2e34 p \u2283 q) = \u0393',\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 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  \u0393 \u22a2\u209b\u2085 ((~q) \u2283 (~p)) \u2283 (p \u2283 q) :=\ndeduction (deduction (mp (mp pl3 pr1) (mp pl1 pr2) ))\n\nlemma not_impl {\u0393 : ctx \u03c3} {p q : form \u03c3} : \n  \u0393 \u22a2\u209b\u2085 (p \u2283 q) \u2283 ((~q) \u2283 (~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 \u03c3} {\u0393 : ctx \u03c3} :\n  \u0393 \u22a2\u209b\u2085 (~~p) \u2283 p :=\nhave h : \u0393 \u22a2\u209b\u2085 (~~p) \u2283 ((~p) \u2283 (~p)) := mp pl1 id,\nmp (mp pl2 (cut pl1 pl3)) h\n\nlemma dni {p : form \u03c3} {\u0393 : ctx \u03c3} :\n  \u0393 \u22a2\u209b\u2085 p \u2283 (~~p) :=\nmp contrap dne\n\nlemma lem {p : form \u03c3} {\u0393 : ctx \u03c3} :\n  \u0393 \u22a2\u209b\u2085 p \u2228 ~p :=\nmp dni (mp contrap dne)\n\nlemma not_impl_to_and {p q : form \u03c3} {\u0393 : ctx \u03c3} :\n  \u0393 \u22a2\u209b\u2085 (~(p \u2283 q)) \u2283 (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 \u03c3} {\u0393 : ctx \u03c3} :\n  \u0393 \u22a2\u209b\u2085 (p & (~q)) \u2283 ~(p \u2283 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 \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (\u25fb(p \u2283 q)) \u2283 (\u25fb((~q) \u2283 ~p)) :=\nprf.mp (prf.k) (prf.nec prf.not_impl)\n\nlemma diamond_k {p q : form \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (\u25fb(p \u2283 q)) \u2283 ((\u25c7p) \u2283 (\u25c7q)) :=\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 \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (\u25fb~~p) \u2283 (\u25fbp) :=\nprf.mp (prf.k) (prf.nec (prf.dne))\n\nlemma box_dni {p : form \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (\u25fbp) \u2283 (\u25fb~~p) :=\nprf.mp (prf.k) (prf.nec (prf.dni))\n\nlemma not_box_dni {p : form \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (~\u25fbp) \u2283 (~\u25fb~~p) :=\nprf.mp prf.not_impl box_dne\n\nlemma not_box_dne {p : form \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (~\u25fb~~p) \u2283 (~\u25fbp) :=\nprf.mp prf.not_impl box_dni\n\nlemma diamond_dne {p : form \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (\u25c7~~p) \u2283 (\u25c7p) :=\nnot_box_dne\n\nlemma diamond_dni {p : form \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (\u25c7p) \u2283 (\u25c7~~p) :=\nnot_box_dni\n\nlemma contrap_b {p : form \u03c3} :\n \u00b7 \u22a2\u209b\u2085 (\u25c7\u25fbp) \u2283 p :=\nbegin\n  apply prf.cut,\n  show (\u00b7 \u22a2\u209b\u2085 (\u25c7\u25fbp) \u2283 (~\u25fb~\u25fb~~p)),\n    from @prf.mp _ _ (\u25fb(\u25fbp \u2283 \u25fb(~~p))) _ diamond_k (prf.nec box_dni),\n  apply prf.cut,\n  show (\u00b7 \u22a2\u209b\u2085 (~\u25fb~\u25fb~~p) \u2283 ~~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 \u03c3} {\u0393 : ctx \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 p \u2283 q) \u2192 (\u0393 \u22a2\u209b\u2085 p \u2283 ~q) \u2192 (\u0393 \u22a2\u209b\u2085 ~p) :=\nhave h : \u2200 q, (\u0393 \u22a2\u209b\u2085 p \u2283 q) \u2192 (\u0393 \u22a2\u209b\u2085 (~~p) \u2283 q) := \u03bb q h, cut dne h,\n  \u03bb hp hnp, mp (mp pl3 (h (~q) hnp)) (h q hp)\n\nlemma ex_falso {\u0393 : ctx \u03c3} {p : form \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 \u22a5) \u2192 (\u0393 \u22a2\u209b\u2085 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 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  \u0393 \u22a2\u209b\u2085 (~p) \u2283 (p \u2283 q) :=\nbegin\n  repeat {apply deduction},\n  apply ex_falso,\n  exact (mp pr1 pr2)\nend\n\nlemma ex_falso_pos {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  \u0393 \u22a2\u209b\u2085 p \u2283 ((~p) \u2283 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 {\u0393 : ctx \u03c3} {p r : form \u03c3} :\n  \u0393 \u22a2\u209b\u2085 (p \u2283 r) \u2283 (((~p) \u2283 r) \u2283 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 \u03c3} {\u0393 : ctx \u03c3} (h : (\u0393 \u2e34 r \u22a2\u209b\u2085 p) \u2192 (\u0393 \u22a2\u209b\u2085 p)) :\n  ((\u0393 \u22a2\u209b\u2085 p) \u2192 (\u0393 \u22a2\u209b\u2085 q)) \u2192 ((\u0393 \u2e34 r \u22a2\u209b\u2085 p) \u2192 (\u0393 \u2e34 r \u22a2\u209b\u2085 q)) :=\n\u03bb hpq hp, weak (hpq (h hp))\n\nlemma and_intro {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 p) \u2192 (\u0393 \u22a2\u209b\u2085 q) \u2192 (\u0393 \u22a2\u209b\u2085 (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 \u03c3} {\u0393 : ctx \u03c3} :\n  (\u0393 \u2e34 (p & q) \u22a2\u209b\u2085 p) :=\nbegin\n  apply mp,\n  { apply dne },\n  { apply mp,\n    { apply mp,\n      { apply pl2, exact (p \u2283 (q \u2283 \u22a5)) },\n      { apply mp,\n        { apply pl1 },\n        { exact pr } } },\n    { exact ex_falso_and } }\nend\n\nlemma and_elim_right {p q : form \u03c3} {\u0393 : ctx \u03c3} :\n  (\u0393 \u2e34 (p & q) \u22a2\u209b\u2085 q) :=\nbegin\n  apply mp,\n  { apply dne },\n  { apply mp,\n    { apply mp,\n      { apply pl2, exact (p \u2283 (q \u2283 \u22a5)) },\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 {\u0393 : ctx \u03c3} {p q r : form \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 p) \u2192 (\u0393 \u22a2\u209b\u2085 (p \u2228 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 {\u0393 : ctx \u03c3} {p q r : form \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 q) \u2192 (\u0393 \u22a2\u209b\u2085 (p \u2228 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 {\u0393 : ctx \u03c3} {p q r : form \u03c3} :\n  (\u0393 \u22a2\u209b\u2085 (p \u2228 q)) \u2192 (\u0393 \u22a2\u209b\u2085 p \u2283 r) \u2192 (\u0393 \u22a2\u209b\u2085 q \u2283 r) \u2192 (\u0393 \u22a2\u209b\u2085 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 {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  (\u0393 \u2e34 p \u22a2\u209b\u2085 q) \u2192 (\u0393 \u2e34 ~p \u22a2\u209b\u2085 q) \u2192 (\u0393 \u22a2\u209b\u2085 q) :=\nbegin\n  intros hpq hnpq,\n  apply or_elim,\n  { apply lem },\n  repeat {apply deduction, assumption}\nend\n\nlemma detach_neg {\u0393 : ctx \u03c3} {p q : form \u03c3} :\n  (\u0393 \u2e34 ~p \u22a2\u209b\u2085 q) \u2192 (\u0393 \u2e34 p \u22a2\u209b\u2085 q) \u2192 (\u0393 \u22a2\u209b\u2085 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 \u03b2\u03b7\n\nlocal notation a `[` b `:=` c  `]` : 70 := has_substitution.substitution a b c\n\ntheorem \u03b2\u03b7_diamond_step {a b c: utlc}:\n   a \u2192\u03b2 b \u2192 a \u2192\u03b7 c \u2192\n   \u2203 x, b \u21a0\u03b7 x \u2227 (c = x \u2228 c \u2192\u03b2 x) :=\nbegin\n  induction a generalizing b c;\n  simp;\n  intros hab hac,\n  { rcases \u03b2.lambda_step_exists hab with \u27e8b\u2081, hb\u2081, hab\u27e9,\n    cases \u03b7.lambda_step_cases' hac with hac hac;\n    rcases hac with \u27e8c\u2081, hc\u2081, hac\u27e9;\n     rw [hb\u2081, hc\u2081],\n    { rcases a_ih hab hac with \u27e8x, hbx, hcx\u27e9,\n      use \u039b x,\n      refine \u27e8 \u03b7.lambda_reduction_lambda hbx, _ \u27e9,\n      simp [hcx] },\n    rw [hac] at hab,\n    obtain hab|hab|hab := \u03b2.dot_step_cases hab;\n    rcases hab with \u27e8b\u2082, hb\u2082, hab\u27e9,\n    { \n      cases shift_of_uses_zero (show b\u2082.uses 1 = 0, begin\n        rw [\u2190 lambda_uses, \u2190 hab],\n        exact shift_uses_self _ _,\n      end) with b\u2083 hb\u2083,\n      rw [hb\u2083, \u2190 lambda_shift, shift_inj_iff] at hab,\n      rw [hab, hb\u2082, hb\u2083, shift_succ_substitiution_down],\n      use \u039b b\u2083,\n      exact \u27e8 by refl, or.inl rfl\u27e9 },\n    { rw [hb\u2082],\n      cases shift_of_uses_zero (\u03b2.uses_zero_step hab (shift_uses_self _ _)) with b\u2083 hb\u2083,\n      rw [hb\u2083],\n      rw [hb\u2083] at hab,\n      use b\u2083,\n      split,\n      apply relation.refl_trans_gen.single,\n      apply \u03b7.lambda_step_head,\n      right,\n      apply (shift_reduction_step_shift_iff _).mp,\n      apply hab,\n      apply \u03b2.shift_head_step_shift },\n    { simp at hab, contradiction } },\n  { obtain hab|hab|hab := \u03b2.dot_step_cases hab;\n    cases \u03b7.dot_step_cases' hac with hac hac;\n    rcases hab with \u27e8x, hax, hxb\u27e9;\n    rcases hac with \u27e8y, z, hza, hcyz, hay\u27e9,\n    { rw [hax, \u2190hza, hcyz],\n      rw [hxb] at hay,\n      cases \u03b7.lambda_step_cases' hay with hay hay;\n      rcases hay with \u27e8y\u2081, hy\u2081, hxy\u2081\u27e9,\n      { rw [hy\u2081],\n        use y\u2081[0:=z],\n        split,\n        apply substitution_reduction_step_left,\n        apply \u03b7.head_step_substitution,\n        apply hxy\u2081,\n        right,\n        apply \u03b2.lambda_dot_step_substitution },\n      { simp [hxy\u2081, hy\u2081],\n        use y\u2081\u00b7z,\n        exact \u27e8by refl, or.inl rfl\u27e9 } },\n    { rw [hax, hcyz, hza, hxb],\n      use x[0:=z],\n      split,\n      apply substitution_reduction_step_right,\n      apply \u03b7.shift_head_step_shift,\n      apply hay,\n      right,\n      apply \u03b2.lambda_dot_step_substitution, },\n    { rw [hax, \u2190 hza, hcyz],\n      rcases a_ih_f hxb hay with \u27e8m, hxm, hym\u27e9,\n      use m\u00b7z,\n      split,\n      apply \u03b7.dot_reduction_dot_left hxm,\n      cases hym,\n      { simp [hym] },\n      right,\n      apply \u03b2.dot_step_dot_left hym },\n    { rw [hax, hcyz, hza],\n      use x\u00b7z,\n      split,\n      apply \u03b7.dot_reduction_dot_right,\n      apply relation.refl_trans_gen.single hay,\n      right,\n      apply \u03b2.dot_step_dot_left hxb },\n    { rw [hax, hcyz, hza],\n      use y\u00b7x,\n      split,\n      apply \u03b7.dot_reduction_dot_left,\n      apply relation.refl_trans_gen.single hay,\n      right,\n      apply \u03b2.dot_step_dot_right hxb },\n    { rw [hax, \u2190 hza, hcyz],\n      rcases a_ih_g hxb hay with \u27e8m, hxm, hym\u27e9,\n      use y\u00b7m,\n      split,\n      apply \u03b7.dot_reduction_dot_right hxm,\n      cases hym,\n      { simp [hym] },\n      right,\n      apply \u03b2.dot_step_dot_right hym },\n  }\nend\n\ntheorem \u03b2\u03b7_diamond_step_reduction {a b c: utlc}: a \u2192\u03b2 b \u2192 a \u21a0\u03b7 c \u2192\n  \u2203 x, b \u21a0\u03b7 x \u2227 c \u21a0\u03b2 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 \u27e8b, by refl, relation.refl_trans_gen.single hab \u27e9,\n  rcases \u03b2\u03b7_diamond_step hab haf with \u27e8g, hbg, hfg\u27e9,\n  cases hfg,\n  { refine \u27e8 c, trans hbg _, by refl \u27e9,\n    rw [\u2190 hfg],\n    exact hfc },\n  rcases ih hfg with \u27e8x, hgx, hcx\u27e9,\n  refine \u27e8x, trans hbg hgx, hcx\u27e9,\nend\n\ntheorem \u03b2\u03b7_diamond_reduction {a b c: utlc}: a \u21a0\u03b2 b \u2192 a \u21a0\u03b7 c \u2192\n  \u2203 x, b \u21a0\u03b7 x \u2227 c \u21a0\u03b2 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 \u27e8c, hac, by refl\u27e9,\n  rcases \u03b2\u03b7_diamond_step_reduction haf hac with \u27e8g, hfg, hcg\u27e9,\n  rcases ih hfg with \u27e8x, hbx, hgx\u27e9,\n  refine \u27e8x, hbx, trans hcg hgx\u27e9,\nend\n\ntheorem \u03b2_diamond_reduction {a b c: utlc}: a \u21a0\u03b2 b \u2192 a \u21a0\u03b2\u03b7 c \u2192\n  \u2203 x, b \u21a0\u03b2\u03b7 x \u2227 c \u21a0\u03b2 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 \u27e8b, by refl, hab\u27e9,\n  rw [step_iff] at haf,\n  cases haf,\n  { rcases \u03b2.church_rosser hab (relation.refl_trans_gen.single haf) with \u27e8x, hbx, hfx\u27e9,\n    rcases ih hfx with \u27e8y, hxy, hcy\u27e9,\n    refine \u27e8y, trans (reduction_of_beta hbx) hxy, hcy\u27e9 },\n  { rcases \u03b2\u03b7_diamond_reduction hab (relation.refl_trans_gen.single haf) with \u27e8x, hbx, hfx\u27e9,\n    rcases ih hfx with \u27e8y, hxy, hcy\u27e9,\n    refine \u27e8y, trans (reduction_of_eta hbx) hxy, hcy\u27e9 },\nend\n\ntheorem \u03b7_diamond_reduction {a b c: utlc}: a \u21a0\u03b7 b \u2192 a \u21a0\u03b2\u03b7 c \u2192\n  \u2203 x, b \u21a0\u03b2\u03b7 x \u2227 c \u21a0\u03b7 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 \u27e8b, by refl, hab\u27e9,\n  rw [step_iff] at haf,\n  cases haf,\n  { rcases \u03b2\u03b7_diamond_reduction (relation.refl_trans_gen.single haf) hab with \u27e8x, hfx, hbx\u27e9,\n    rcases ih hfx with \u27e8y, hxy, hcy\u27e9,\n    refine \u27e8y, trans (reduction_of_beta hbx) hxy, hcy\u27e9 },\n  { rcases \u03b7.church_rosser hab (relation.refl_trans_gen.single haf) with \u27e8x, hbx, hfx\u27e9,\n    rcases ih hfx with \u27e8y, hxy, hcy\u27e9,\n    refine \u27e8y, trans (reduction_of_eta hbx) hxy, hcy\u27e9 }\nend\n\ntheorem church_rosser {a b c : utlc}:\n  a \u21a0\u03b2\u03b7 b \u2192 a \u21a0\u03b2\u03b7 c \u2192 b \u2261\u03b2\u03b7 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 \u27e8 hac, by refl\u27e9, },\n  rw [step_iff] at haf,\n  cases haf,\n  { rcases \u03b2_diamond_reduction (relation.refl_trans_gen.single haf) hac with \u27e8x, hfx, hcx\u27e9,\n    rcases ih hfx with \u27e8y, hby, hxy\u27e9,\n    refine \u27e8y, hby, trans (reduction_of_beta hcx) hxy \u27e9 },\n  { rcases \u03b7_diamond_reduction (relation.refl_trans_gen.single haf) hac with \u27e8x, hfx, hcx\u27e9,\n    rcases ih hfx with \u27e8y, hby, hxy\u27e9,\n    refine \u27e8y, hby, trans (reduction_of_eta hcx) hxy \u27e9 }\nend\n\n\n@[refl]\ntheorem equiv_refl (f : utlc): f \u2261\u03b2\u03b7 f :=\n  \u27e8f, relation.refl_trans_gen.refl, relation.refl_trans_gen.refl\u27e9\n\n@[symm]\ntheorem equiv_symm {a b: utlc}: a \u2261\u03b2\u03b7 b \u2192 b \u2261\u03b2\u03b7 a :=\nbegin\n  apply relation.symmetric_join\nend\n\n@[trans]\ntheorem equiv_trans {a b c : utlc}: a \u2261\u03b2\u03b7 b \u2192 b \u2261\u03b2\u03b7 c \u2192 a \u2261\u03b2\u03b7 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 \u2192 f \u21a0\u03b2\u03b7 g \u2192 f = g :=\nbegin\n  intros hf p,\n  induction p with x y hx hy fx,\n  { refl },\n  rw [\u2190fx] at *,\n  exfalso,\n  apply reduced_iff_no_reduction.mp hf _ hy\nend\n\ntheorem reduced_equiv_inj {f g: utlc}: reduced f \u2192 reduced g \u2192 f \u2261\u03b2\u03b7 g \u2192 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 \u03b2\u03b7\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 \u2192 Type u} [hm : monad m] {\u03b1 \u03b2 : Type u} (x : \u03b1) (f : \u03b1 \u2192 m \u03b2) : pure x >>= f = f x :=\n  monad.pure_bind x f\n\nlemma bind_assoc {m : Type u \u2192 Type u} [hm : monad m] {\u03b1 \u03b2 \u03b3 : Type u} (x : m \u03b1) (f : \u03b1 \u2192 m \u03b2) (g : \u03b2 \u2192 m \u03b3) :\n  x >>= f >>= g = x >>= \u03bb x, f x >>= g := monad.bind_assoc x f g\n\nlemma when_false_unit {m : Type \u2192 Type} [monad m] {c : Prop} [h : decidable c]\n  {t : m unit} (H : \u00ac c) : when c t = pure ()\n:= begin\nunfold when, rw (if_neg H)\nend\n\nlemma when_false {m : Type \u2192 Type} [monad m] {c : Prop} [h : decidable c]\n  {t : m unit} {A : Type} {f : m A} (H : \u00ac c) : when c t >>= (\u03bb _, f) = f\n:= begin\nrw (when_false_unit H), rw pure_bind\nend\n\nlemma when_false_trans {m : Type \u2192 Type} [monad m] {c : Prop} [h : decidable c]\n  {t : m unit} {A : Type} {f g : m A} (H : \u00ac c)\n  (H' : f = g) : when c t >>= (\u03bb _, 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)\u1d52\u1d56 \u2964 C`,\nand inherit the category structure with natural transformations as morphisms.\n\nWe define\n* `pushforward_obj {X Y : Top.{w}} (f : X \u27f6 Y) (\u2131 : X.presheaf C) : Y.presheaf C`\nwith notation `f _* \u2131`\nand for `\u2131 : X.presheaf C` provide the natural isomorphisms\n* `pushforward.id : (\ud835\udfd9 X) _* \u2131 \u2245 \u2131`\n* `pushforward.comp : (f \u226b g) _* \u2131 \u2245 g _* (f _* \u2131)`\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)\u1d52\u1d56 \u2964 C\n\nvariables {C}\n\nnamespace presheaf\n\n/-- Pushforward a presheaf on `X` along a continuous map `f : X \u27f6 Y`, obtaining a presheaf\non `Y`. -/\ndef pushforward_obj {X Y : Top.{w}} (f : X \u27f6 Y) (\u2131 : X.presheaf C) : Y.presheaf C :=\n(opens.map f).op \u22d9 \u2131\n\ninfix ` _* `: 80 := pushforward_obj\n\n@[simp] lemma pushforward_obj_obj {X Y : Top.{w}} (f : X \u27f6 Y) (\u2131 : X.presheaf C) (U : (opens Y)\u1d52\u1d56) :\n  (f _* \u2131).obj U = \u2131.obj ((opens.map f).op.obj U) := rfl\n\n@[simp] lemma pushforward_obj_map {X Y : Top.{w}} (f : X \u27f6 Y) (\u2131 : X.presheaf C)\n  {U V : (opens Y)\u1d52\u1d56} (i : U \u27f6 V) :\n  (f _* \u2131).map i = \u2131.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 \u27f6 Y} (h : f = g) (\u2131 : X.presheaf C) :\n  f _* \u2131 \u2245 g _* \u2131 :=\niso_whisker_right (nat_iso.op (opens.map_iso f g h).symm) \u2131\n\nlemma pushforward_eq' {X Y : Top.{w}} {f g : X \u27f6 Y} (h : f = g) (\u2131 : X.presheaf C) :\n  f _* \u2131 = g _* \u2131 :=\nby rw h\n\n@[simp] lemma pushforward_eq_hom_app\n  {X Y : Top.{w}} {f g : X \u27f6 Y} (h : f = g) (\u2131 : X.presheaf C) (U) :\n  (pushforward_eq h \u2131).hom.app U =\n    \u2131.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 \u27f6 Y} (h : f = g) (\u2131 : X.presheaf C) (U) :\n  nat_trans.app (eq_to_hom (pushforward_eq' h \u2131)) U = \u2131.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 \u27f6 Y) (\u2131 : X.presheaf C) (U) :\n  (pushforward_eq (rfl : f = f) \u2131).hom.app (op U) = \ud835\udfd9 _ :=\nbegin\n  dsimp [pushforward_eq],\n  simp,\nend\n\nlemma pushforward_eq_eq {X Y : Top.{w}} {f g : X \u27f6 Y} (h\u2081 h\u2082 : f = g) (\u2131 : X.presheaf C) :\n  \u2131.pushforward_eq h\u2081 = \u2131.pushforward_eq h\u2082 :=\nrfl\n\nnamespace pushforward\nvariables {X : Top.{w}} (\u2131 : 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 : (\ud835\udfd9 X) _* \u2131 \u2245 \u2131 :=\n(iso_whisker_right (nat_iso.op (opens.map_id X).symm) \u2131) \u226a\u226b functor.left_unitor _\n\nlemma id_eq : (\ud835\udfd9 X) _* \u2131 = \u2131 :=\nby { unfold pushforward_obj, rw opens.map_id_eq, erw functor.id_comp }\n\n@[simp] lemma id_hom_app' (U) (p) :\n  (id \u2131).hom.app (op \u27e8U, p\u27e9) = \u2131.map (\ud835\udfd9 (op \u27e8U, p\u27e9)) :=\nby { dsimp [id], simp, }\n\nlocal attribute [tidy] tactic.op_induction'\n\n@[simp, priority 990] lemma id_hom_app (U) :\n  (id \u2131).hom.app U = \u2131.map (eq_to_hom (opens.op_map_id_obj U)) := by tidy\n\n@[simp] lemma id_inv_app' (U) (p) : (id \u2131).inv.app (op \u27e8U, p\u27e9) = \u2131.map (\ud835\udfd9 (op \u27e8U, p\u27e9)) :=\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 \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g) _* \u2131 \u2245 g _* (f _* \u2131) :=\niso_whisker_right (nat_iso.op (opens.map_comp f g).symm) \u2131\n\nlemma comp_eq {Y Z : Top.{w}} (f : X \u27f6 Y) (g : Y \u27f6 Z) : (f \u226b g) _* \u2131 = g _* (f _* \u2131) :=\nrfl\n\n@[simp] lemma comp_hom_app {Y Z : Top.{w}} (f : X \u27f6 Y) (g : Y \u27f6 Z) (U) :\n  (comp \u2131 f g).hom.app U = \ud835\udfd9 _ :=\nby { dsimp [comp], tidy, }\n\n@[simp] lemma comp_inv_app {Y Z : Top.{w}} (f : X \u27f6 Y) (g : Y \u27f6 Z) (U) :\n  (comp \u2131 f g).inv.app U = \ud835\udfd9 _ :=\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 \u27f6 Y) {\u2131 \ud835\udca2 : X.presheaf C} (\u03b1 : \u2131 \u27f6 \ud835\udca2) :\n  f _* \u2131 \u27f6 f _* \ud835\udca2 :=\n{ app := \u03bb U, \u03b1.app _,\n  naturality' := \u03bb U V i, by { erw \u03b1.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 \u27f6 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 \u27f6 Y) (\u2131 : Y.presheaf C) : X.presheaf C :=\n(Lan (opens.map f).op).obj \u2131\n\n/-- Pulling back along continuous maps is functorial. -/\ndef pullback_map {X Y : Top.{v}} (f : X \u27f6 Y) {\u2131 \ud835\udca2 : Y.presheaf C} (\u03b1 : \u2131 \u27f6 \ud835\udca2) :\n  pullback_obj f \u2131 \u27f6 pullback_obj f \ud835\udca2 :=\n(Lan (opens.map f).op).map \u03b1\n\n/-- If `f '' U` is open, then `f\u207b\u00b9\u2131 U \u2245 \u2131 (f '' U)`.  -/\n@[simps]\ndef pullback_obj_obj_of_image_open {X Y : Top.{v}} (f : X \u27f6 Y) (\u2131 : Y.presheaf C) (U : opens X)\n  (H : is_open (f '' U)) : (pullback_obj f \u2131).obj (op U) \u2245 \u2131.obj (op \u27e8_, H\u27e9) :=\nbegin\n  let x : costructured_arrow (opens.map f).op (op U) :=\n  { left := op \u27e8f '' U, H\u27e9,\n    hom := ((@hom_of_le _ _ _ ((opens.map f).obj \u27e8_, H\u27e9) (set.image_preimage.le_u_l _)).op :\n    op ((opens.map f).obj (\u27e8\u21d1f '' \u2191U, H\u27e9)) \u27f6 op U) },\n  have hx : is_terminal x :=\n  { lift := \u03bb s,\n    begin\n      fapply costructured_arrow.hom_mk,\n      change op (unop _) \u27f6 op (\u27e8_, H\u27e9 : 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 \u2191(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}} (\u2131 : Y.presheaf C)\n\n/-- The pullback along the identity is isomorphic to the original presheaf. -/\ndef id : pullback_obj (\ud835\udfd9 _) \u2131 \u2245 \u2131 :=\nnat_iso.of_components\n  (\u03bb U, pullback_obj_obj_of_image_open (\ud835\udfd9 _) \u2131 (unop U) (by simpa using U.unop.2) \u226a\u226b\n    \u2131.map_iso (eq_to_iso (by simp)))\n  (\u03bb U V i,\n  begin\n      ext, simp,\n      erw colimit.pre_desc_assoc,\n      erw colimit.\u03b9_desc_assoc,\n      erw colimit.\u03b9_desc_assoc,\n      dsimp, simp only [\u2190\u2131.map_comp], congr\n  end)\n\nlemma id_inv_app (U : opens Y) :\n  (id \u2131).inv.app (op U) = colimit.\u03b9 (Lan.diagram (opens.map (\ud835\udfd9 Y)).op \u2131 (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 \u2190 \u2131.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 \u27f6 Y) : X.presheaf C \u2964 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 \u27f6 Y)\n  {\u2131 \ud835\udca2 : X.presheaf C} (\u03b1 : \u2131 \u27f6 \ud835\udca2) {U : (opens Y)\u1d52\u1d56} :\n  ((pushforward C f).map \u03b1).app U = \u03b1.app (op $ (opens.map f).obj U.unop) := rfl\n\nlemma id_pushforward {X : Top.{v}} : pushforward C (\ud835\udfd9 X) = \ud835\udfed (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 \u2245 Y) :\n  X.presheaf C \u224c Y.presheaf C :=\nequivalence.congr_left (opens.map_map_iso H).symm.op\n\nvariable {C}\n\n/--\nIf `H : X \u2245 Y` is a homeomorphism,\nthen given an `H _* \u2131 \u27f6 \ud835\udca2`, we may obtain an `\u2131 \u27f6 H \u207b\u00b9 _* \ud835\udca2`.\n-/\ndef to_pushforward_of_iso {X Y : Top} (H : X \u2245 Y) {\u2131 : X.presheaf C} {\ud835\udca2 : Y.presheaf C}\n  (\u03b1 : H.hom _* \u2131 \u27f6 \ud835\udca2) : \u2131 \u27f6 H.inv _* \ud835\udca2 :=\n(presheaf_equiv_of_iso _ H).to_adjunction.hom_equiv \u2131 \ud835\udca2 \u03b1\n\n@[simp]\nlemma to_pushforward_of_iso_app {X Y : Top} (H\u2081 : X \u2245 Y) {\u2131 : X.presheaf C} {\ud835\udca2 : Y.presheaf C}\n  (H\u2082 : H\u2081.hom _* \u2131 \u27f6 \ud835\udca2) (U : (opens X)\u1d52\u1d56) :\n(to_pushforward_of_iso H\u2081 H\u2082).app U =\n  \u2131.map (eq_to_hom (by simp [opens.map, set.preimage_preimage])) \u226b\n  H\u2082.app (op ((opens.map H\u2081.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 \u2245 Y` is a homeomorphism,\nthen given an `H _* \u2131 \u27f6 \ud835\udca2`, we may obtain an `\u2131 \u27f6 H \u207b\u00b9 _* \ud835\udca2`.\n-/\ndef pushforward_to_of_iso {X Y : Top} (H\u2081 : X \u2245 Y) {\u2131 : Y.presheaf C} {\ud835\udca2 : X.presheaf C}\n  (H\u2082 : \u2131 \u27f6 H\u2081.hom _* \ud835\udca2) : H\u2081.inv _* \u2131 \u27f6 \ud835\udca2 :=\n((presheaf_equiv_of_iso _ H\u2081.symm).to_adjunction.hom_equiv \u2131 \ud835\udca2).symm H\u2082\n\n@[simp]\nlemma pushforward_to_of_iso_app {X Y : Top} (H\u2081 : X \u2245 Y) {\u2131 : Y.presheaf C} {\ud835\udca2 : X.presheaf C}\n  (H\u2082 : \u2131 \u27f6 H\u2081.hom _* \ud835\udca2) (U : (opens X)\u1d52\u1d56) :\n(pushforward_to_of_iso H\u2081 H\u2082).app U =\n  H\u2082.app (op ((opens.map H\u2081.inv).obj (unop U))) \u226b\n  \ud835\udca2.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 \u27f6 Y`, obtaining a presheaf\non `X`. -/\n@[simps map_app]\ndef pullback {X Y : Top.{v}} (f : X \u27f6 Y) : Y.presheaf C \u2964 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 \u27f6 Y) (\u2131 : Y.presheaf C) : (pullback C f).obj \u2131 = pullback_obj f \u2131 := 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 \u27f6 Y) :\n  pullback C f \u22a3 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 \u2245 Y) :\n  pullback C H.hom \u2245 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 \u2245 Y) :\n  pullback C H.inv \u2245 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 \u03b1`,\nmodelled as a `multiset \u03b1` 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 \u03b1`\n(which asserts that there is some `finset \u03b1` containing every term of type `\u03b1`)\nas well as the predicate `finite` on `s : set \u03b1` (which asserts `nonempty (fintype s)`).\n-/\n\n/-- `finset \u03b1` is the type of finite sets of elements of `\u03b1`. It is implemented\n  as a multiset (a list up to permutation) which has no duplicate elements. -/\nstructure finset (\u03b1 : Type u_4) where\n  val : multiset \u03b1\n  nodup : multiset.nodup val\n\nnamespace finset\n\n\ntheorem eq_of_veq {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} : val s = val t \u2192 s = t := sorry\n\n@[simp] theorem val_inj {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} : val s = val t \u2194 s = t :=\n  { mp := eq_of_veq, mpr := congr_arg fun {s : finset \u03b1} => val s }\n\n@[simp] theorem erase_dup_eq_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) :\n    multiset.erase_dup (val s) = val s :=\n  iff.mpr multiset.erase_dup_eq_self (nodup s)\n\nprotected instance has_decidable_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] : DecidableEq (finset \u03b1) := sorry\n\n/-! ### membership -/\n\nprotected instance has_mem {\u03b1 : Type u_1} : has_mem \u03b1 (finset \u03b1) :=\n  has_mem.mk fun (a : \u03b1) (s : finset \u03b1) => a \u2208 val s\n\ntheorem mem_def {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} : a \u2208 s \u2194 a \u2208 val s := iff.rfl\n\n@[simp] theorem mem_mk {\u03b1 : Type u_1} {a : \u03b1} {s : multiset \u03b1} {nd : multiset.nodup s} :\n    a \u2208 mk s nd \u2194 a \u2208 s :=\n  iff.rfl\n\nprotected instance decidable_mem {\u03b1 : Type u_1} [h : DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    Decidable (a \u2208 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 {\u03b1 : Type u_1} : has_coe_t (finset \u03b1) (set \u03b1) :=\n  has_coe_t.mk fun (s : finset \u03b1) => set_of fun (x : \u03b1) => x \u2208 s\n\n@[simp] theorem mem_coe {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} : a \u2208 \u2191s \u2194 a \u2208 s := iff.rfl\n\n@[simp] theorem set_of_mem {\u03b1 : Type u_1} {s : finset \u03b1} : (set_of fun (a : \u03b1) => a \u2208 s) = \u2191s := rfl\n\n@[simp] theorem coe_mem {\u03b1 : Type u_1} {s : finset \u03b1} (x : \u21a5\u2191s) : \u2191x \u2208 s := subtype.property x\n\n@[simp] theorem mk_coe {\u03b1 : Type u_1} {s : finset \u03b1} (x : \u21a5\u2191s) {h : \u2191x \u2208 \u2191s} :\n    { val := \u2191x, property := h } = x :=\n  subtype.coe_eta x h\n\nprotected instance decidable_mem' {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    Decidable (a \u2208 \u2191s) :=\n  finset.decidable_mem a s\n\n/-! ### extensionality -/\n\ntheorem ext_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    s\u2081 = s\u2082 \u2194 \u2200 (a : \u03b1), a \u2208 s\u2081 \u2194 a \u2208 s\u2082 :=\n  iff.trans (iff.symm val_inj) (multiset.nodup_ext (nodup s\u2081) (nodup s\u2082))\n\ntheorem ext {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    (\u2200 (a : \u03b1), a \u2208 s\u2081 \u2194 a \u2208 s\u2082) \u2192 s\u2081 = s\u2082 :=\n  iff.mpr ext_iff\n\n@[simp] theorem coe_inj {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : \u2191s\u2081 = \u2191s\u2082 \u2194 s\u2081 = s\u2082 :=\n  iff.trans set.ext_iff (iff.symm ext_iff)\n\ntheorem coe_injective {\u03b1 : Type u_1} : function.injective coe :=\n  fun (s t : finset \u03b1) => iff.mp coe_inj\n\n/-! ### subset -/\n\nprotected instance has_subset {\u03b1 : Type u_1} : has_subset (finset \u03b1) :=\n  has_subset.mk fun (s\u2081 s\u2082 : finset \u03b1) => \u2200 {a : \u03b1}, a \u2208 s\u2081 \u2192 a \u2208 s\u2082\n\ntheorem subset_def {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 \u2286 s\u2082 \u2194 val s\u2081 \u2286 val s\u2082 :=\n  iff.rfl\n\n@[simp] theorem subset.refl {\u03b1 : Type u_1} (s : finset \u03b1) : s \u2286 s := multiset.subset.refl (val s)\n\ntheorem subset_of_eq {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} (h : s = t) : s \u2286 t :=\n  h \u25b8 subset.refl s\n\ntheorem subset.trans {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {s\u2083 : finset \u03b1} :\n    s\u2081 \u2286 s\u2082 \u2192 s\u2082 \u2286 s\u2083 \u2192 s\u2081 \u2286 s\u2083 :=\n  multiset.subset.trans\n\ntheorem superset.trans {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {s\u2083 : finset \u03b1} :\n    s\u2081 \u2287 s\u2082 \u2192 s\u2082 \u2287 s\u2083 \u2192 s\u2081 \u2287 s\u2083 :=\n  fun (h' : s\u2081 \u2287 s\u2082) (h : s\u2082 \u2287 s\u2083) => subset.trans h h'\n\n-- TODO: these should be global attributes, but this will require fixing other files\n\ntheorem mem_of_subset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {a : \u03b1} :\n    s\u2081 \u2286 s\u2082 \u2192 a \u2208 s\u2081 \u2192 a \u2208 s\u2082 :=\n  multiset.mem_of_subset\n\ntheorem subset.antisymm {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (H\u2081 : s\u2081 \u2286 s\u2082)\n    (H\u2082 : s\u2082 \u2286 s\u2081) : s\u2081 = s\u2082 :=\n  ext fun (a : \u03b1) => { mp := H\u2081, mpr := H\u2082 }\n\ntheorem subset_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    s\u2081 \u2286 s\u2082 \u2194 \u2200 {x : \u03b1}, x \u2208 s\u2081 \u2192 x \u2208 s\u2082 :=\n  iff.rfl\n\n@[simp] theorem coe_subset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : \u2191s\u2081 \u2286 \u2191s\u2082 \u2194 s\u2081 \u2286 s\u2082 :=\n  iff.rfl\n\n@[simp] theorem val_le_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    val s\u2081 \u2264 val s\u2082 \u2194 s\u2081 \u2286 s\u2082 :=\n  multiset.le_iff_subset (nodup s\u2081)\n\nprotected instance has_ssubset {\u03b1 : Type u_1} : has_ssubset (finset \u03b1) :=\n  has_ssubset.mk fun (a b : finset \u03b1) => a \u2286 b \u2227 \u00acb \u2286 a\n\nprotected instance partial_order {\u03b1 : Type u_1} : partial_order (finset \u03b1) :=\n  partial_order.mk has_subset.subset has_ssubset.ssubset subset.refl subset.trans subset.antisymm\n\ntheorem subset.antisymm_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    s\u2081 = s\u2082 \u2194 s\u2081 \u2286 s\u2082 \u2227 s\u2082 \u2286 s\u2081 :=\n  le_antisymm_iff\n\n@[simp] theorem le_iff_subset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 \u2264 s\u2082 \u2194 s\u2081 \u2286 s\u2082 :=\n  iff.rfl\n\n@[simp] theorem lt_iff_ssubset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : s\u2081 < s\u2082 \u2194 s\u2081 \u2282 s\u2082 :=\n  iff.rfl\n\n@[simp] theorem coe_ssubset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} : \u2191s\u2081 \u2282 \u2191s\u2082 \u2194 s\u2081 \u2282 s\u2082 :=\n  sorry\n\n@[simp] theorem val_lt_iff {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    val s\u2081 < val s\u2082 \u2194 s\u2081 \u2282 s\u2082 :=\n  and_congr val_le_iff (not_congr val_le_iff)\n\ntheorem ssubset_iff_of_subset {\u03b1 : Type u_1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (h : s\u2081 \u2286 s\u2082) :\n    s\u2081 \u2282 s\u2082 \u2194 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s\u2082), \u00acx \u2208 s\u2081 :=\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 `\u2203 x, x \u2208 s` or `s \u2260 \u2205` as it gives access to a nice API thanks\nto the dot notation. -/\nprotected def nonempty {\u03b1 : Type u_1} (s : finset \u03b1) := \u2203 (x : \u03b1), x \u2208 s\n\n@[simp] theorem coe_nonempty {\u03b1 : Type u_1} {s : finset \u03b1} : set.nonempty \u2191s \u2194 finset.nonempty s :=\n  iff.rfl\n\ntheorem nonempty.bex {\u03b1 : Type u_1} {s : finset \u03b1} (h : finset.nonempty s) : \u2203 (x : \u03b1), x \u2208 s := h\n\ntheorem nonempty.mono {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} (hst : s \u2286 t)\n    (hs : finset.nonempty s) : finset.nonempty t :=\n  set.nonempty.mono hst hs\n\ntheorem nonempty.forall_const {\u03b1 : Type u_1} {s : finset \u03b1} (h : finset.nonempty s) {p : Prop} :\n    (\u2200 (x : \u03b1), x \u2208 s \u2192 p) \u2194 p :=\n  sorry\n\n/-! ### empty -/\n\n/-- The empty finset -/\nprotected def empty {\u03b1 : Type u_1} : finset \u03b1 := mk 0 multiset.nodup_zero\n\nprotected instance has_emptyc {\u03b1 : Type u_1} : has_emptyc (finset \u03b1) := has_emptyc.mk finset.empty\n\nprotected instance inhabited {\u03b1 : Type u_1} : Inhabited (finset \u03b1) := { default := \u2205 }\n\n@[simp] theorem empty_val {\u03b1 : Type u_1} : val \u2205 = 0 := rfl\n\n@[simp] theorem not_mem_empty {\u03b1 : Type u_1} (a : \u03b1) : \u00aca \u2208 \u2205 := id\n\n@[simp] theorem not_nonempty_empty {\u03b1 : Type u_1} : \u00acfinset.nonempty \u2205 :=\n  fun (_x : finset.nonempty \u2205) =>\n    (fun (_a : finset.nonempty \u2205) =>\n        Exists.dcases_on _a fun (w : \u03b1) (h : w \u2208 \u2205) => idRhs False (not_mem_empty w h))\n      _x\n\n@[simp] theorem mk_zero {\u03b1 : Type u_1} : mk 0 multiset.nodup_zero = \u2205 := rfl\n\ntheorem ne_empty_of_mem {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) : s \u2260 \u2205 :=\n  fun (e : s = \u2205) => not_mem_empty a (e \u25b8 h)\n\ntheorem nonempty.ne_empty {\u03b1 : Type u_1} {s : finset \u03b1} (h : finset.nonempty s) : s \u2260 \u2205 :=\n  exists.elim h fun (a : \u03b1) => ne_empty_of_mem\n\n@[simp] theorem empty_subset {\u03b1 : Type u_1} (s : finset \u03b1) : \u2205 \u2286 s := multiset.zero_subset (val s)\n\ntheorem eq_empty_of_forall_not_mem {\u03b1 : Type u_1} {s : finset \u03b1} (H : \u2200 (x : \u03b1), \u00acx \u2208 s) : s = \u2205 :=\n  eq_of_veq (multiset.eq_zero_of_forall_not_mem H)\n\ntheorem eq_empty_iff_forall_not_mem {\u03b1 : Type u_1} {s : finset \u03b1} : s = \u2205 \u2194 \u2200 (x : \u03b1), \u00acx \u2208 s :=\n  { mp := fun (\u1fb0 : s = \u2205) (x : \u03b1) => Eq._oldrec id (Eq.symm \u1fb0),\n    mpr := fun (h : \u2200 (x : \u03b1), \u00acx \u2208 s) => eq_empty_of_forall_not_mem h }\n\n@[simp] theorem val_eq_zero {\u03b1 : Type u_1} {s : finset \u03b1} : val s = 0 \u2194 s = \u2205 := val_inj\n\ntheorem subset_empty {\u03b1 : Type u_1} {s : finset \u03b1} : s \u2286 \u2205 \u2194 s = \u2205 :=\n  iff.trans multiset.subset_zero val_eq_zero\n\ntheorem nonempty_of_ne_empty {\u03b1 : Type u_1} {s : finset \u03b1} (h : s \u2260 \u2205) : finset.nonempty s :=\n  multiset.exists_mem_of_ne_zero (mt (iff.mp val_eq_zero) h)\n\ntheorem nonempty_iff_ne_empty {\u03b1 : Type u_1} {s : finset \u03b1} : finset.nonempty s \u2194 s \u2260 \u2205 :=\n  { mp := nonempty.ne_empty, mpr := nonempty_of_ne_empty }\n\n@[simp] theorem not_nonempty_iff_eq_empty {\u03b1 : Type u_1} {s : finset \u03b1} :\n    \u00acfinset.nonempty s \u2194 s = \u2205 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u00acfinset.nonempty s \u2194 s = \u2205)) (propext nonempty_iff_ne_empty)))\n    not_not\n\ntheorem eq_empty_or_nonempty {\u03b1 : Type u_1} (s : finset \u03b1) : s = \u2205 \u2228 finset.nonempty s :=\n  classical.by_cases Or.inl fun (h : \u00acs = \u2205) => Or.inr (nonempty_of_ne_empty h)\n\n@[simp] theorem coe_empty {\u03b1 : Type u_1} : \u2191\u2205 = \u2205 := rfl\n\n/-- A `finset` for an empty type is empty. -/\ntheorem eq_empty_of_not_nonempty {\u03b1 : Type u_1} (h : \u00acNonempty \u03b1) (s : finset \u03b1) : s = \u2205 :=\n  eq_empty_of_forall_not_mem fun (x : \u03b1) => 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 \u2205` in that it does not require a `decidable_eq` instance for `\u03b1`.\n-/\nprotected instance has_singleton {\u03b1 : Type u_1} : has_singleton \u03b1 (finset \u03b1) :=\n  has_singleton.mk fun (a : \u03b1) => mk (singleton a) (multiset.nodup_singleton a)\n\n@[simp] theorem singleton_val {\u03b1 : Type u_1} (a : \u03b1) : val (singleton a) = a ::\u2098 0 := rfl\n\n@[simp] theorem mem_singleton {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : b \u2208 singleton a \u2194 b = a :=\n  multiset.mem_singleton\n\ntheorem not_mem_singleton {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : \u00aca \u2208 singleton b \u2194 a \u2260 b :=\n  not_congr mem_singleton\n\ntheorem mem_singleton_self {\u03b1 : Type u_1} (a : \u03b1) : a \u2208 singleton a := Or.inl rfl\n\ntheorem singleton_inj {\u03b1 : Type u_1} {a : \u03b1} {b : \u03b1} : singleton a = singleton b \u2194 a = b :=\n  { mp := fun (h : singleton a = singleton b) => iff.mp mem_singleton (h \u25b8 mem_singleton_self a),\n    mpr := congr_arg fun {a : \u03b1} => singleton a }\n\n@[simp] theorem singleton_nonempty {\u03b1 : Type u_1} (a : \u03b1) : finset.nonempty (singleton a) :=\n  Exists.intro a (mem_singleton_self a)\n\n@[simp] theorem singleton_ne_empty {\u03b1 : Type u_1} (a : \u03b1) : singleton a \u2260 \u2205 :=\n  nonempty.ne_empty (singleton_nonempty a)\n\n@[simp] theorem coe_singleton {\u03b1 : Type u_1} (a : \u03b1) : \u2191(singleton a) = singleton a := sorry\n\ntheorem eq_singleton_iff_unique_mem {\u03b1 : Type u_1} {s : finset \u03b1} {a : \u03b1} :\n    s = singleton a \u2194 a \u2208 s \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 x = a :=\n  sorry\n\ntheorem eq_singleton_iff_nonempty_unique_mem {\u03b1 : Type u_1} {s : finset \u03b1} {a : \u03b1} :\n    s = singleton a \u2194 finset.nonempty s \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 x = a :=\n  sorry\n\ntheorem singleton_iff_unique_mem {\u03b1 : Type u_1} (s : finset \u03b1) :\n    (\u2203 (a : \u03b1), s = singleton a) \u2194 exists_unique fun (a : \u03b1) => a \u2208 s :=\n  sorry\n\ntheorem singleton_subset_set_iff {\u03b1 : Type u_1} {s : set \u03b1} {a : \u03b1} : \u2191(singleton a) \u2286 s \u2194 a \u2208 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2191(singleton a) \u2286 s \u2194 a \u2208 s)) (coe_singleton a)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a \u2286 s \u2194 a \u2208 s)) (propext set.singleton_subset_iff)))\n      (iff.refl (a \u2208 s)))\n\n@[simp] theorem singleton_subset_iff {\u03b1 : Type u_1} {s : finset \u03b1} {a : \u03b1} :\n    singleton a \u2286 s \u2194 a \u2208 s :=\n  singleton_subset_set_iff\n\n/-! ### cons -/\n\n/-- `cons a s h` is the set `{a} \u222a 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 \u03b1`,\nand the union is guaranteed to be disjoint.  -/\ndef cons {\u03b1 : Type u_1} (a : \u03b1) (s : finset \u03b1) (h : \u00aca \u2208 s) : finset \u03b1 := mk (a ::\u2098 val s) sorry\n\n@[simp] theorem mem_cons {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} {h : \u00aca \u2208 s} {b : \u03b1} :\n    b \u2208 cons a s h \u2194 b = a \u2228 b \u2208 s :=\n  sorry\n\n@[simp] theorem cons_val {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) :\n    val (cons a s h) = a ::\u2098 val s :=\n  rfl\n\n@[simp] theorem mk_cons {\u03b1 : Type u_1} {a : \u03b1} {s : multiset \u03b1} (h : multiset.nodup (a ::\u2098 s)) :\n    mk (a ::\u2098 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 {\u03b1 : Type u_1} {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 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 {\u03b1 : Type u_1} {l : List \u03b1} {hl : multiset.nodup \u2191l} :\n    finset.nonempty (mk (\u2191l) hl) \u2194 l \u2260 [] :=\n  sorry\n\n/-! ### disjoint union -/\n\n/-- `disj_union s t h` is the set such that `a \u2208 disj_union s t h` iff `a \u2208 s` or `a \u2208 t`.\nIt is the same as `s \u222a t`, but it does not require decidable equality on the type. The hypothesis\nensures that the sets are disjoint. -/\ndef disj_union {\u03b1 : Type u_1} (s : finset \u03b1) (t : finset \u03b1) (h : \u2200 (a : \u03b1), a \u2208 s \u2192 \u00aca \u2208 t) :\n    finset \u03b1 :=\n  mk (val s + val t) sorry\n\n@[simp] theorem mem_disj_union {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1}\n    {h : \u2200 (a : \u03b1), a \u2208 s \u2192 \u00aca \u2208 t} {a : \u03b1} : a \u2208 disj_union s t h \u2194 a \u2208 s \u2228 a \u2208 t :=\n  sorry\n\n/-! ### insert -/\n\n/-- `insert a s` is the set `{a} \u222a s` containing `a` and the elements of `s`. -/\nprotected instance has_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] : has_insert \u03b1 (finset \u03b1) :=\n  has_insert.mk fun (a : \u03b1) (s : finset \u03b1) => mk (multiset.ndinsert a (val s)) sorry\n\ntheorem insert_def {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    insert a s = mk (multiset.ndinsert a (val s)) (multiset.nodup_ndinsert a (nodup s)) :=\n  rfl\n\n@[simp] theorem insert_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    val (insert a s) = multiset.ndinsert a (val s) :=\n  rfl\n\ntheorem insert_val' {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    val (insert a s) = multiset.erase_dup (a ::\u2098 val s) :=\n  sorry\n\ntheorem insert_val_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) :\n    val (insert a s) = a ::\u2098 val s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (val (insert a s) = a ::\u2098 val s)) (insert_val a s)))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl (multiset.ndinsert a (val s) = a ::\u2098 val s))\n          (multiset.ndinsert_of_not_mem h)))\n      (Eq.refl (a ::\u2098 val s)))\n\n@[simp] theorem mem_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} :\n    a \u2208 insert b s \u2194 a = b \u2228 a \u2208 s :=\n  multiset.mem_ndinsert\n\ntheorem mem_insert_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : a \u2208 insert a s :=\n  multiset.mem_ndinsert_self a (val s)\n\ntheorem mem_insert_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1}\n    (h : a \u2208 s) : a \u2208 insert b s :=\n  multiset.mem_ndinsert_of_mem h\n\ntheorem mem_of_mem_insert_of_ne {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1}\n    (h : b \u2208 insert a s) : b \u2260 a \u2192 b \u2208 s :=\n  or.resolve_left (iff.mp mem_insert h)\n\n@[simp] theorem cons_eq_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (h : \u00aca \u2208 s) :\n    cons a s h = insert a s :=\n  sorry\n\n@[simp] theorem coe_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    \u2191(insert a s) = insert a \u2191s :=\n  sorry\n\ntheorem mem_insert_coe {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {x : \u03b1} {y : \u03b1} :\n    x \u2208 insert y s \u2194 x \u2208 insert y \u2191s :=\n  sorry\n\nprotected instance is_lawful_singleton {\u03b1 : Type u_1} [DecidableEq \u03b1] :\n    is_lawful_singleton \u03b1 (finset \u03b1) :=\n  is_lawful_singleton.mk\n    fun (a : \u03b1) =>\n      ext\n        fun (a_1 : \u03b1) =>\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 \u2208 insert a \u2205) (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 \u2208 \u2205) False\n                        (propext\n                          ((fun {\u03b1 : Type u_1} (a : \u03b1) => iff_false_intro (not_mem_empty a)) a_1))))\n                    (propext (or_false (a_1 = a))))\n                  (a_1 \u2208 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) :\n    insert a s = s :=\n  eq_of_veq (multiset.ndinsert_of_mem h)\n\n@[simp] theorem insert_singleton_self_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) :\n    insert a (singleton a) = singleton a :=\n  insert_eq_of_mem (mem_singleton_self a)\n\ntheorem insert.comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) (s : finset \u03b1) :\n    insert a (insert b s) = insert b (insert a s) :=\n  sorry\n\ntheorem insert_singleton_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (b : \u03b1) :\n    insert a (singleton b) = insert b (singleton a) :=\n  sorry\n\n@[simp] theorem insert_idem {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    insert a (insert a s) = insert a s :=\n  sorry\n\n@[simp] theorem insert_nonempty {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    finset.nonempty (insert a s) :=\n  Exists.intro a (mem_insert_self a s)\n\n@[simp] theorem insert_ne_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    insert a s \u2260 \u2205 :=\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 {\u03b1 : Type u} [DecidableEq \u03b1] (i : \u03b1) (s : finset \u03b1) :\n    Nonempty \u21a5\u2191(insert i s) :=\n  set.nonempty.to_subtype (iff.mpr coe_nonempty (insert_nonempty i s))\n\ntheorem ne_insert_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) {a : \u03b1}\n    (h : \u00aca \u2208 s) : s \u2260 insert a t :=\n  sorry\n\ntheorem insert_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} {t : finset \u03b1} :\n    insert a s \u2286 t \u2194 a \u2208 t \u2227 s \u2286 t :=\n  sorry\n\ntheorem subset_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : s \u2286 insert a s :=\n  fun (b : \u03b1) => mem_insert_of_mem\n\ntheorem insert_subset_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) {s : finset \u03b1} {t : finset \u03b1}\n    (h : s \u2286 t) : insert a s \u2286 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    s \u2282 t \u2194 \u2203 (a : \u03b1), \u2203 (H : \u00aca \u2208 s), insert a s \u2286 t :=\n  sorry\n\ntheorem ssubset_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {a : \u03b1} (h : \u00aca \u2208 s) :\n    s \u2282 insert a s :=\n  iff.mpr ssubset_iff (Exists.intro a (Exists.intro h (subset.refl (insert a s))))\n\nprotected theorem induction {\u03b1 : Type u_1} {p : finset \u03b1 \u2192 Prop} [DecidableEq \u03b1] (h\u2081 : p \u2205)\n    (h\u2082 : \u2200 {a : \u03b1} {s : finset \u03b1}, \u00aca \u2208 s \u2192 p s \u2192 p (insert a s)) (s : finset \u03b1) : p s :=\n  sorry\n\n/--\nTo prove a proposition about an arbitrary `finset \u03b1`,\nit suffices to prove it for the empty `finset`,\nand to show that if it holds for some `finset \u03b1`,\nthen it holds for the `finset` obtained by inserting a new element.\n-/\nprotected theorem induction_on {\u03b1 : Type u_1} {p : finset \u03b1 \u2192 Prop} [DecidableEq \u03b1] (s : finset \u03b1)\n    (h\u2081 : p \u2205) (h\u2082 : \u2200 {a : \u03b1} {s : finset \u03b1}, \u00aca \u2208 s \u2192 p s \u2192 p (insert a s)) : p s :=\n  finset.induction h\u2081 h\u2082 s\n\n/--\nTo prove a proposition about `S : finset \u03b1`,\nit suffices to prove it for the empty `finset`,\nand to show that if it holds for some `finset \u03b1 \u2286 S`,\nthen it holds for the `finset` obtained by inserting a new element of `S`.\n-/\ntheorem induction_on' {\u03b1 : Type u_1} {p : finset \u03b1 \u2192 Prop} [DecidableEq \u03b1] (S : finset \u03b1) (h\u2081 : p \u2205)\n    (h\u2082 : \u2200 {a : \u03b1} {s : finset \u03b1}, a \u2208 S \u2192 s \u2286 S \u2192 \u00aca \u2208 s \u2192 p s \u2192 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {t : finset \u03b1} {x : \u03b1} (h : \u00acx \u2208 t) :\n    (Subtype fun (i : \u03b1) => i \u2208 insert x t) \u2243 Option (Subtype fun (i : \u03b1) => i \u2208 t) :=\n  equiv.mk\n    (fun (y : Subtype fun (i : \u03b1) => i \u2208 insert x t) =>\n      dite (\u2191y = x) (fun (h : \u2191y = x) => none)\n        fun (h : \u00ac\u2191y = x) => some { val := \u2191y, property := sorry })\n    (fun (y : Option (Subtype fun (i : \u03b1) => i \u2208 t)) =>\n      option.elim y { val := x, property := sorry }\n        fun (z : Subtype fun (i : \u03b1) => i \u2208 t) => { val := \u2191z, property := sorry })\n    sorry sorry\n\n/-! ### union -/\n\n/-- `s \u222a t` is the set such that `a \u2208 s \u222a t` iff `a \u2208 s` or `a \u2208 t`. -/\nprotected instance has_union {\u03b1 : Type u_1} [DecidableEq \u03b1] : has_union (finset \u03b1) :=\n  has_union.mk fun (s\u2081 s\u2082 : finset \u03b1) => mk (multiset.ndunion (val s\u2081) (val s\u2082)) sorry\n\ntheorem union_val_nd {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    val (s\u2081 \u222a s\u2082) = multiset.ndunion (val s\u2081) (val s\u2082) :=\n  rfl\n\n@[simp] theorem union_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    val (s\u2081 \u222a s\u2082) = val s\u2081 \u222a val s\u2082 :=\n  multiset.ndunion_eq_union (nodup s\u2081)\n\n@[simp] theorem mem_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    a \u2208 s\u2081 \u222a s\u2082 \u2194 a \u2208 s\u2081 \u2228 a \u2208 s\u2082 :=\n  multiset.mem_ndunion\n\n@[simp] theorem disj_union_eq_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1)\n    (h : \u2200 (a : \u03b1), a \u2208 s \u2192 \u00aca \u2208 t) : disj_union s t h = s \u222a t :=\n  sorry\n\ntheorem mem_union_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} (s\u2082 : finset \u03b1)\n    (h : a \u2208 s\u2081) : a \u2208 s\u2081 \u222a s\u2082 :=\n  iff.mpr mem_union (Or.inl h)\n\ntheorem mem_union_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2082 : finset \u03b1} (s\u2081 : finset \u03b1)\n    (h : a \u2208 s\u2082) : a \u2208 s\u2081 \u222a s\u2082 :=\n  iff.mpr mem_union (Or.inr h)\n\ntheorem forall_mem_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    {p : \u03b1 \u2192 Prop} :\n    (\u2200 (ab : \u03b1), ab \u2208 s\u2081 \u222a s\u2082 \u2192 p ab) \u2194 (\u2200 (a : \u03b1), a \u2208 s\u2081 \u2192 p a) \u2227 \u2200 (b : \u03b1), b \u2208 s\u2082 \u2192 p b :=\n  sorry\n\ntheorem not_mem_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    \u00aca \u2208 s\u2081 \u222a s\u2082 \u2194 \u00aca \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u00aca \u2208 s\u2081 \u222a s\u2082 \u2194 \u00aca \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082)) (propext mem_union)))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (\u00ac(a \u2208 s\u2081 \u2228 a \u2208 s\u2082) \u2194 \u00aca \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082)) (propext not_or_distrib)))\n      (iff.refl (\u00aca \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082)))\n\n@[simp] theorem coe_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    \u2191(s\u2081 \u222a s\u2082) = \u2191s\u2081 \u222a \u2191s\u2082 :=\n  set.ext fun (x : \u03b1) => mem_union\n\ntheorem union_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} {s\u2083 : finset \u03b1}\n    (h\u2081 : s\u2081 \u2286 s\u2083) (h\u2082 : s\u2082 \u2286 s\u2083) : s\u2081 \u222a s\u2082 \u2286 s\u2083 :=\n  iff.mp val_le_iff (iff.mpr multiset.ndunion_le { left := h\u2081, right := iff.mpr val_le_iff h\u2082 })\n\ntheorem subset_union_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2081 \u2286 s\u2081 \u222a s\u2082 :=\n  fun (x : \u03b1) => mem_union_left s\u2082\n\ntheorem subset_union_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2082 \u2286 s\u2081 \u222a s\u2082 :=\n  fun (x : \u03b1) => mem_union_right s\u2081\n\ntheorem union_subset_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s1 : finset \u03b1} {t1 : finset \u03b1}\n    {s2 : finset \u03b1} {t2 : finset \u03b1} (h1 : s1 \u2286 t1) (h2 : s2 \u2286 t2) : s1 \u222a s2 \u2286 t1 \u222a t2 :=\n  sorry\n\ntheorem union_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2081 \u222a s\u2082 = s\u2082 \u222a s\u2081 :=\n  sorry\n\nprotected instance has_union.union.is_commutative {\u03b1 : Type u_1} [DecidableEq \u03b1] :\n    is_commutative (finset \u03b1) has_union.union :=\n  is_commutative.mk union_comm\n\n@[simp] theorem union_assoc {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1)\n    (s\u2083 : finset \u03b1) : s\u2081 \u222a s\u2082 \u222a s\u2083 = s\u2081 \u222a (s\u2082 \u222a s\u2083) :=\n  sorry\n\nprotected instance has_union.union.is_associative {\u03b1 : Type u_1} [DecidableEq \u03b1] :\n    is_associative (finset \u03b1) has_union.union :=\n  is_associative.mk union_assoc\n\n@[simp] theorem union_idempotent {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u222a s = s :=\n  ext fun (_x : \u03b1) => iff.trans mem_union (or_self (_x \u2208 s))\n\nprotected instance has_union.union.is_idempotent {\u03b1 : Type u_1} [DecidableEq \u03b1] :\n    is_idempotent (finset \u03b1) has_union.union :=\n  is_idempotent.mk union_idempotent\n\ntheorem union_left_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1)\n    (s\u2083 : finset \u03b1) : s\u2081 \u222a (s\u2082 \u222a s\u2083) = s\u2082 \u222a (s\u2081 \u222a s\u2083) :=\n  sorry\n\ntheorem union_right_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1)\n    (s\u2083 : finset \u03b1) : s\u2081 \u222a s\u2082 \u222a s\u2083 = s\u2081 \u222a s\u2083 \u222a s\u2082 :=\n  sorry\n\ntheorem union_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u222a s = s := union_idempotent s\n\n@[simp] theorem union_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u222a \u2205 = s :=\n  ext fun (x : \u03b1) => iff.trans mem_union (or_false (x \u2208 s))\n\n@[simp] theorem empty_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : \u2205 \u222a s = s :=\n  ext fun (x : \u03b1) => iff.trans mem_union (false_or (x \u2208 s))\n\ntheorem insert_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    insert a s = singleton a \u222a s :=\n  rfl\n\n@[simp] theorem insert_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (t : finset \u03b1) :\n    insert a s \u222a t = insert a (s \u222a t) :=\n  sorry\n\n@[simp] theorem union_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (t : finset \u03b1) :\n    s \u222a insert a t = insert a (s \u222a t) :=\n  sorry\n\ntheorem insert_union_distrib {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (t : finset \u03b1) :\n    insert a (s \u222a t) = insert a s \u222a insert a t :=\n  sorry\n\n@[simp] theorem union_eq_left_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t : finset \u03b1} : s \u222a t = s \u2194 t \u2286 s :=\n  { mp :=\n      fun (h : s \u222a t = s) => eq.mp (Eq._oldrec (Eq.refl (t \u2286 s \u222a t)) h) (subset_union_right s t),\n    mpr :=\n      fun (h : t \u2286 s) => subset.antisymm (union_subset (subset.refl s) h) (subset_union_left s t) }\n\n@[simp] theorem left_eq_union_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t : finset \u03b1} : s = s \u222a t \u2194 t \u2286 s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (s = s \u222a t \u2194 t \u2286 s)) (Eq.symm (propext union_eq_left_iff_subset))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s = s \u222a t \u2194 s \u222a t = s)) (propext eq_comm)))\n      (iff.refl (s \u222a t = s)))\n\n@[simp] theorem union_eq_right_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t : finset \u03b1} : t \u222a s = s \u2194 t \u2286 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (t \u222a s = s \u2194 t \u2286 s)) (union_comm t s)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \u222a t = s \u2194 t \u2286 s)) (propext union_eq_left_iff_subset)))\n      (iff.refl (t \u2286 s)))\n\n@[simp] theorem right_eq_union_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t : finset \u03b1} : s = t \u222a s \u2194 t \u2286 s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (s = t \u222a s \u2194 t \u2286 s)) (Eq.symm (propext union_eq_right_iff_subset))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s = t \u222a s \u2194 t \u222a s = s)) (propext eq_comm)))\n      (iff.refl (t \u222a 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 \u222a b, c]`.\n-/\ntheorem induction_on_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (P : finset \u03b1 \u2192 finset \u03b1 \u2192 Prop)\n    (symm : \u2200 {a b : finset \u03b1}, P a b \u2192 P b a) (empty_right : \u2200 {a : finset \u03b1}, P a \u2205)\n    (singletons : \u2200 {a b : \u03b1}, P (singleton a) (singleton b))\n    (union_of : \u2200 {a b c : finset \u03b1}, P a c \u2192 P b c \u2192 P (a \u222a b) c) (a : finset \u03b1) (b : finset \u03b1) :\n    P a b :=\n  sorry\n\n/-! ### inter -/\n\n/-- `s \u2229 t` is the set such that `a \u2208 s \u2229 t` iff `a \u2208 s` and `a \u2208 t`. -/\nprotected instance has_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] : has_inter (finset \u03b1) :=\n  has_inter.mk fun (s\u2081 s\u2082 : finset \u03b1) => mk (multiset.ndinter (val s\u2081) (val s\u2082)) sorry\n\ntheorem inter_val_nd {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    val (s\u2081 \u2229 s\u2082) = multiset.ndinter (val s\u2081) (val s\u2082) :=\n  rfl\n\n@[simp] theorem inter_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    val (s\u2081 \u2229 s\u2082) = val s\u2081 \u2229 val s\u2082 :=\n  multiset.ndinter_eq_inter (nodup s\u2081)\n\n@[simp] theorem mem_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    a \u2208 s\u2081 \u2229 s\u2082 \u2194 a \u2208 s\u2081 \u2227 a \u2208 s\u2082 :=\n  multiset.mem_ndinter\n\ntheorem mem_of_mem_inter_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    (h : a \u2208 s\u2081 \u2229 s\u2082) : a \u2208 s\u2081 :=\n  and.left (iff.mp mem_inter h)\n\ntheorem mem_of_mem_inter_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1}\n    {s\u2082 : finset \u03b1} (h : a \u2208 s\u2081 \u2229 s\u2082) : a \u2208 s\u2082 :=\n  and.right (iff.mp mem_inter h)\n\ntheorem mem_inter_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    a \u2208 s\u2081 \u2192 a \u2208 s\u2082 \u2192 a \u2208 s\u2081 \u2229 s\u2082 :=\n  iff.mp and_imp (iff.mpr mem_inter)\n\ntheorem inter_subset_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2081 \u2229 s\u2082 \u2286 s\u2081 :=\n  fun (a : \u03b1) => mem_of_mem_inter_left\n\ntheorem inter_subset_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2081 \u2229 s\u2082 \u2286 s\u2082 :=\n  fun (a : \u03b1) => mem_of_mem_inter_right\n\ntheorem subset_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    {s\u2083 : finset \u03b1} : s\u2081 \u2286 s\u2082 \u2192 s\u2081 \u2286 s\u2083 \u2192 s\u2081 \u2286 s\u2082 \u2229 s\u2083 :=\n  sorry\n\n@[simp] theorem coe_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    \u2191(s\u2081 \u2229 s\u2082) = \u2191s\u2081 \u2229 \u2191s\u2082 :=\n  set.ext fun (_x : \u03b1) => mem_inter\n\n@[simp] theorem union_inter_cancel_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t : finset \u03b1} : (s \u222a t) \u2229 s = s :=\n  sorry\n\n@[simp] theorem union_inter_cancel_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t : finset \u03b1} : (s \u222a t) \u2229 t = t :=\n  sorry\n\ntheorem inter_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2081 \u2229 s\u2082 = s\u2082 \u2229 s\u2081 :=\n  sorry\n\n@[simp] theorem inter_assoc {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1)\n    (s\u2083 : finset \u03b1) : s\u2081 \u2229 s\u2082 \u2229 s\u2083 = s\u2081 \u2229 (s\u2082 \u2229 s\u2083) :=\n  sorry\n\ntheorem inter_left_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1)\n    (s\u2083 : finset \u03b1) : s\u2081 \u2229 (s\u2082 \u2229 s\u2083) = s\u2082 \u2229 (s\u2081 \u2229 s\u2083) :=\n  sorry\n\ntheorem inter_right_comm {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1)\n    (s\u2083 : finset \u03b1) : s\u2081 \u2229 s\u2082 \u2229 s\u2083 = s\u2081 \u2229 s\u2083 \u2229 s\u2082 :=\n  sorry\n\n@[simp] theorem inter_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u2229 s = s :=\n  ext fun (_x : \u03b1) => iff.trans mem_inter (and_self (_x \u2208 s))\n\n@[simp] theorem inter_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : s \u2229 \u2205 = \u2205 :=\n  ext fun (_x : \u03b1) => iff.trans mem_inter (and_false (_x \u2208 s))\n\n@[simp] theorem empty_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : \u2205 \u2229 s = \u2205 :=\n  ext fun (_x : \u03b1) => iff.trans mem_inter (false_and (_x \u2208 s))\n\n@[simp] theorem inter_union_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    s \u2229 (t \u222a s) = s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \u2229 (t \u222a s) = s)) (inter_comm s (t \u222a s))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl ((t \u222a s) \u2229 s = s)) union_inter_cancel_right)) (Eq.refl s))\n\n@[simp] theorem insert_inter_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    {a : \u03b1} (h : a \u2208 s\u2082) : insert a s\u2081 \u2229 s\u2082 = insert a (s\u2081 \u2229 s\u2082) :=\n  sorry\n\n@[simp] theorem inter_insert_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    {a : \u03b1} (h : a \u2208 s\u2081) : s\u2081 \u2229 insert a s\u2082 = insert a (s\u2081 \u2229 s\u2082) :=\n  sorry\n\n@[simp] theorem insert_inter_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1}\n    {s\u2082 : finset \u03b1} {a : \u03b1} (h : \u00aca \u2208 s\u2082) : insert a s\u2081 \u2229 s\u2082 = s\u2081 \u2229 s\u2082 :=\n  sorry\n\n@[simp] theorem inter_insert_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1}\n    {s\u2082 : finset \u03b1} {a : \u03b1} (h : \u00aca \u2208 s\u2081) : s\u2081 \u2229 insert a s\u2082 = s\u2081 \u2229 s\u2082 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s\u2081 \u2229 insert a s\u2082 = s\u2081 \u2229 s\u2082)) (inter_comm s\u2081 (insert a s\u2082))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (insert a s\u2082 \u2229 s\u2081 = s\u2081 \u2229 s\u2082)) (insert_inter_of_not_mem h)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s\u2082 \u2229 s\u2081 = s\u2081 \u2229 s\u2082)) (inter_comm s\u2082 s\u2081)))\n        (Eq.refl (s\u2081 \u2229 s\u2082))))\n\n@[simp] theorem singleton_inter_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1}\n    (H : a \u2208 s) : singleton a \u2229 s = singleton a :=\n  (fun (this : insert a \u2205 \u2229 s = insert a \u2205) => this)\n    (eq.mpr (id (Eq._oldrec (Eq.refl (insert a \u2205 \u2229 s = insert a \u2205)) (insert_inter_of_mem H)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (insert a (\u2205 \u2229 s) = insert a \u2205)) (empty_inter s)))\n        (Eq.refl (insert a \u2205))))\n\n@[simp] theorem singleton_inter_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1}\n    (H : \u00aca \u2208 s) : singleton a \u2229 s = \u2205 :=\n  sorry\n\n@[simp] theorem inter_singleton_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1}\n    (h : a \u2208 s) : s \u2229 singleton a = singleton a :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \u2229 singleton a = singleton a)) (inter_comm s (singleton a))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a \u2229 s = singleton a)) (singleton_inter_of_mem h)))\n      (Eq.refl (singleton a)))\n\n@[simp] theorem inter_singleton_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1}\n    (h : \u00aca \u2208 s) : s \u2229 singleton a = \u2205 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \u2229 singleton a = \u2205)) (inter_comm s (singleton a))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (singleton a \u2229 s = \u2205)) (singleton_inter_of_not_mem h)))\n      (Eq.refl \u2205))\n\ntheorem inter_subset_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {x : finset \u03b1} {y : finset \u03b1}\n    {s : finset \u03b1} {t : finset \u03b1} (h : x \u2286 y) (h' : s \u2286 t) : x \u2229 s \u2286 y \u2229 t :=\n  sorry\n\ntheorem inter_subset_inter_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {x : finset \u03b1} {y : finset \u03b1}\n    {s : finset \u03b1} (h : x \u2286 y) : x \u2229 s \u2286 y \u2229 s :=\n  inter_subset_inter h (subset.refl s)\n\ntheorem inter_subset_inter_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {x : finset \u03b1} {y : finset \u03b1}\n    {s : finset \u03b1} (h : x \u2286 y) : s \u2229 x \u2286 s \u2229 y :=\n  inter_subset_inter (subset.refl s) h\n\n/-! ### lattice laws -/\n\nprotected instance lattice {\u03b1 : Type u_1} [DecidableEq \u03b1] : lattice (finset \u03b1) :=\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    s \u2294 t = s \u222a t :=\n  rfl\n\n@[simp] theorem inf_eq_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    s \u2293 t = s \u2229 t :=\n  rfl\n\nprotected instance semilattice_inf_bot {\u03b1 : Type u_1} [DecidableEq \u03b1] :\n    semilattice_inf_bot (finset \u03b1) :=\n  semilattice_inf_bot.mk \u2205 lattice.le lattice.lt sorry sorry sorry empty_subset lattice.inf sorry\n    sorry sorry\n\nprotected instance semilattice_sup_bot {\u03b1 : Type u_1} [DecidableEq \u03b1] :\n    semilattice_sup_bot (finset \u03b1) :=\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] : distrib_lattice (finset \u03b1) :=\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1)\n    (u : finset \u03b1) : s \u2229 (t \u222a u) = s \u2229 t \u222a s \u2229 u :=\n  inf_sup_left\n\ntheorem inter_distrib_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1)\n    (u : finset \u03b1) : (s \u222a t) \u2229 u = s \u2229 u \u222a t \u2229 u :=\n  inf_sup_right\n\ntheorem union_distrib_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1)\n    (u : finset \u03b1) : s \u222a t \u2229 u = (s \u222a t) \u2229 (s \u222a u) :=\n  sup_inf_left\n\ntheorem union_distrib_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1)\n    (u : finset \u03b1) : s \u2229 t \u222a u = (s \u222a u) \u2229 (t \u222a u) :=\n  sup_inf_right\n\ntheorem union_eq_empty_iff {\u03b1 : Type u_1} [DecidableEq \u03b1] (A : finset \u03b1) (B : finset \u03b1) :\n    A \u222a B = \u2205 \u2194 A = \u2205 \u2227 B = \u2205 :=\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (a : \u03b1) : finset \u03b1 :=\n  mk (multiset.erase (val s) a) sorry\n\n@[simp] theorem erase_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (a : \u03b1) :\n    val (erase s a) = multiset.erase (val s) a :=\n  rfl\n\n@[simp] theorem mem_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} :\n    a \u2208 erase s b \u2194 a \u2260 b \u2227 a \u2208 s :=\n  multiset.mem_erase_iff_of_nodup (nodup s)\n\ntheorem not_mem_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : \u00aca \u2208 erase s a :=\n  multiset.mem_erase_of_nodup (nodup s)\n\n@[simp] theorem erase_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) : erase \u2205 a = \u2205 := rfl\n\ntheorem ne_of_mem_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} :\n    b \u2208 erase s a \u2192 b \u2260 a :=\n  eq.mpr (id (imp_congr_eq (propext mem_erase) (Eq.refl (b \u2260 a)))) and.left\n\ntheorem mem_of_mem_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} :\n    b \u2208 erase s a \u2192 b \u2208 s :=\n  multiset.mem_of_mem_erase\n\ntheorem mem_erase_of_ne_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1} :\n    a \u2260 b \u2192 a \u2208 s \u2192 a \u2208 erase s b :=\n  eq.mpr (id (imp_congr_eq (Eq.refl (a \u2260 b)) (imp_congr_eq (Eq.refl (a \u2208 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {b : \u03b1} {s : finset \u03b1}\n    (hs : b \u2208 s) (hsa : \u00acb \u2208 erase s a) : b = a :=\n  sorry\n\ntheorem erase_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) :\n    erase (insert a s) a = s :=\n  sorry\n\ntheorem insert_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) :\n    insert a (erase s a) = s :=\n  sorry\n\ntheorem erase_subset_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) {s : finset \u03b1} {t : finset \u03b1}\n    (h : s \u2286 t) : erase s a \u2286 erase t a :=\n  iff.mp val_le_iff (multiset.erase_le_erase a (iff.mpr val_le_iff h))\n\ntheorem erase_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) : erase s a \u2286 s :=\n  multiset.erase_subset a (val s)\n\n@[simp] theorem coe_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    \u2191(erase s a) = \u2191s \\ singleton a :=\n  sorry\n\ntheorem erase_ssubset {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 s) :\n    erase s a \u2282 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : \u00aca \u2208 s) :\n    erase s a = s :=\n  eq_of_veq (multiset.erase_of_not_mem h)\n\ntheorem subset_insert_iff {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} {t : finset \u03b1} :\n    s \u2286 insert a t \u2194 erase s a \u2286 t :=\n  sorry\n\ntheorem erase_insert_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    erase (insert a s) a \u2286 s :=\n  iff.mp subset_insert_iff (subset.refl (insert a s))\n\ntheorem insert_erase_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    s \u2286 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] : has_sdiff (finset \u03b1) :=\n  has_sdiff.mk fun (s\u2081 s\u2082 : finset \u03b1) => mk (val s\u2081 - val s\u2082) sorry\n\n@[simp] theorem mem_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    a \u2208 s\u2081 \\ s\u2082 \u2194 a \u2208 s\u2081 \u2227 \u00aca \u2208 s\u2082 :=\n  multiset.mem_sub_of_nodup (nodup s\u2081)\n\ntheorem not_mem_sdiff_of_mem_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1}\n    {t : finset \u03b1} (h : a \u2208 t) : \u00aca \u2208 s \\ t :=\n  sorry\n\ntheorem sdiff_union_of_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    (h : s\u2081 \u2286 s\u2082) : s\u2082 \\ s\u2081 \u222a s\u2081 = s\u2082 :=\n  sorry\n\ntheorem union_sdiff_of_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    (h : s\u2081 \u2286 s\u2082) : s\u2081 \u222a s\u2082 \\ s\u2081 = s\u2082 :=\n  Eq.trans (union_comm s\u2081 (s\u2082 \\ s\u2081)) (sdiff_union_of_subset h)\n\ntheorem inter_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) (u : finset \u03b1) :\n    s \u2229 (t \\ u) = s \u2229 t \\ u :=\n  sorry\n\n@[simp] theorem inter_sdiff_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2081 \u2229 (s\u2082 \\ s\u2081) = \u2205 :=\n  sorry\n\n@[simp] theorem sdiff_inter_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2082 \\ s\u2081 \u2229 s\u2081 = \u2205 :=\n  Eq.trans (inter_comm (s\u2082 \\ s\u2081) s\u2081) (inter_sdiff_self s\u2081 s\u2082)\n\n@[simp] theorem sdiff_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) : s\u2081 \\ s\u2081 = \u2205 := sorry\n\ntheorem sdiff_inter_distrib_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1)\n    (s\u2083 : finset \u03b1) : s\u2081 \\ (s\u2082 \u2229 s\u2083) = s\u2081 \\ s\u2082 \u222a s\u2081 \\ s\u2083 :=\n  sorry\n\n@[simp] theorem sdiff_inter_self_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1)\n    (s\u2082 : finset \u03b1) : s\u2081 \\ (s\u2081 \u2229 s\u2082) = s\u2081 \\ s\u2082 :=\n  sorry\n\n@[simp] theorem sdiff_inter_self_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1)\n    (s\u2082 : finset \u03b1) : s\u2081 \\ (s\u2082 \u2229 s\u2081) = s\u2081 \\ s\u2082 :=\n  sorry\n\n@[simp] theorem sdiff_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} : s\u2081 \\ \u2205 = s\u2081 := sorry\n\ntheorem sdiff_subset_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    {t\u2081 : finset \u03b1} {t\u2082 : finset \u03b1} (h\u2081 : t\u2081 \u2286 t\u2082) (h\u2082 : s\u2082 \u2286 s\u2081) : t\u2081 \\ s\u2081 \u2286 t\u2082 \\ s\u2082 :=\n  sorry\n\ntheorem sdiff_subset_self {\u03b1 : Type u_1} [DecidableEq \u03b1] {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    s\u2081 \\ s\u2082 \u2286 s\u2081 :=\n  sorry\n\n@[simp] theorem coe_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    \u2191(s\u2081 \\ s\u2082) = \u2191s\u2081 \\ \u2191s\u2082 :=\n  set.ext fun (_x : \u03b1) => mem_sdiff\n\n@[simp] theorem union_sdiff_self_eq_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t : finset \u03b1} : s \u222a t \\ s = s \u222a t :=\n  sorry\n\n@[simp] theorem sdiff_union_self_eq_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t : finset \u03b1} : s \\ t \u222a t = s \u222a t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t \u222a t = s \u222a t)) (union_comm (s \\ t) t)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (t \u222a s \\ t = s \u222a t)) union_sdiff_self_eq_union))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (t \u222a s = s \u222a t)) (union_comm t s))) (Eq.refl (s \u222a t))))\n\ntheorem union_sdiff_symm {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    s \u222a t \\ s = t \u222a s \\ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (s \u222a t \\ s = t \u222a s \\ t)) union_sdiff_self_eq_union))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \u222a t = t \u222a s \\ t)) union_sdiff_self_eq_union))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s \u222a t = t \u222a s)) (union_comm s t))) (Eq.refl (t \u222a s))))\n\ntheorem sdiff_union_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    s \\ t \u222a s \u2229 t = s :=\n  sorry\n\n@[simp] theorem sdiff_idem {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    s \\ t \\ t = s \\ t :=\n  sorry\n\ntheorem sdiff_eq_empty_iff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    s \\ t = \u2205 \u2194 s \u2286 t :=\n  sorry\n\n@[simp] theorem empty_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : \u2205 \\ s = \u2205 :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u2205 \\ s = \u2205)) (propext sdiff_eq_empty_iff_subset)))\n    (empty_subset s)\n\ntheorem insert_sdiff_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) {t : finset \u03b1} {x : \u03b1}\n    (h : \u00acx \u2208 t) : insert x s \\ t = insert x (s \\ t) :=\n  sorry\n\ntheorem insert_sdiff_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) {t : finset \u03b1} {x : \u03b1}\n    (h : x \u2208 t) : insert x s \\ t = s \\ t :=\n  sorry\n\n@[simp] theorem insert_sdiff_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1)\n    (x : \u03b1) : 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {x : \u03b1} (h : \u00acx \u2208 s)\n    (t : finset \u03b1) : s \\ insert x t = s \\ t :=\n  sorry\n\n@[simp] theorem sdiff_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    s \\ t \u2286 s :=\n  sorry\n\ntheorem union_sdiff_distrib {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1)\n    (t : finset \u03b1) : (s\u2081 \u222a s\u2082) \\ t = s\u2081 \\ t \u222a s\u2082 \\ t :=\n  sorry\n\ntheorem sdiff_union_distrib {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t\u2081 : finset \u03b1)\n    (t\u2082 : finset \u03b1) : s \\ (t\u2081 \u222a t\u2082) = s \\ t\u2081 \u2229 (s \\ t\u2082) :=\n  sorry\n\ntheorem union_sdiff_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    (s \u222a t) \\ t = s \\ t :=\n  eq.mpr (id (Eq._oldrec (Eq.refl ((s \u222a t) \\ t = s \\ t)) (union_sdiff_distrib s t t)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t \u222a t \\ t = s \\ t)) (sdiff_self t)))\n      (eq.mpr (id (Eq._oldrec (Eq.refl (s \\ t \u222a \u2205 = s \\ t)) (union_empty (s \\ t))))\n        (Eq.refl (s \\ t))))\n\ntheorem sdiff_singleton_eq_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    s \\ singleton a = erase s a :=\n  sorry\n\ntheorem sdiff_sdiff_self_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    s \\ (s \\ t) = s \u2229 t :=\n  sorry\n\ntheorem inter_eq_inter_of_sdiff_eq_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1}\n    {t\u2081 : finset \u03b1} {t\u2082 : finset \u03b1} : s \\ t\u2081 = s \\ t\u2082 \u2192 s \u2229 t\u2081 = s \u2229 t\u2082 :=\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 \u2208 s}`. -/\ndef attach {\u03b1 : Type u_1} (s : finset \u03b1) : finset (Subtype fun (x : \u03b1) => x \u2208 s) :=\n  mk (multiset.attach (val s)) sorry\n\ntheorem sizeof_lt_sizeof_of_mem {\u03b1 : Type u_1} [SizeOf \u03b1] {x : \u03b1} {s : finset \u03b1} (hx : x \u2208 s) :\n    sizeof x < sizeof s :=\n  sorry\n\n@[simp] theorem attach_val {\u03b1 : Type u_1} (s : finset \u03b1) :\n    val (attach s) = multiset.attach (val s) :=\n  rfl\n\n@[simp] theorem mem_attach {\u03b1 : Type u_1} (s : finset \u03b1) (x : Subtype fun (x : \u03b1) => x \u2208 s) :\n    x \u2208 attach s :=\n  multiset.mem_attach (val s)\n\n@[simp] theorem attach_empty {\u03b1 : Type u_1} : attach \u2205 = \u2205 := 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 {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_2} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i)\n    (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] (i : \u03b1) : \u03b4 i :=\n  ite (i \u2208 s) (f i) (g i)\n\n@[simp] theorem piecewise_insert_self {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1)\n    (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [DecidableEq \u03b1] {j : \u03b1}\n    [(i : \u03b1) \u2192 Decidable (i \u2208 insert j s)] : piecewise (insert j s) f g j = f j :=\n  sorry\n\n@[simp] theorem piecewise_empty {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (f : (i : \u03b1) \u2192 \u03b4 i)\n    (g : (i : \u03b1) \u2192 \u03b4 i) [(i : \u03b1) \u2192 Decidable (i \u2208 \u2205)] : piecewise \u2205 f g = g :=\n  sorry\n\ntheorem piecewise_coe {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i)\n    (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [(j : \u03b1) \u2192 Decidable (j \u2208 \u2191s)] :\n    set.piecewise (\u2191s) f g = piecewise s f g :=\n  sorry\n\n@[simp] theorem piecewise_eq_of_mem {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1)\n    (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {i : \u03b1} (hi : i \u2208 s) :\n    piecewise s f g i = f i :=\n  sorry\n\n@[simp] theorem piecewise_eq_of_not_mem {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1)\n    (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {i : \u03b1} (hi : \u00aci \u2208 s) :\n    piecewise s f g i = g i :=\n  sorry\n\ntheorem piecewise_congr {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1)\n    [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {f : (i : \u03b1) \u2192 \u03b4 i} {f' : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i}\n    {g' : (i : \u03b1) \u2192 \u03b4 i} (hf : \u2200 (i : \u03b1), i \u2208 s \u2192 f i = f' i)\n    (hg : \u2200 (i : \u03b1), \u00aci \u2208 s \u2192 g i = g' i) : piecewise s f g = piecewise s f' g' :=\n  funext fun (i : \u03b1) => if_ctx_congr iff.rfl (hf i) (hg i)\n\n@[simp] theorem piecewise_insert_of_ne {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1)\n    (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] {i : \u03b1}\n    {j : \u03b1} [(i : \u03b1) \u2192 Decidable (i \u2208 insert j s)] (h : i \u2260 j) :\n    piecewise (insert j s) f g i = piecewise s f g i :=\n  sorry\n\ntheorem piecewise_insert {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i)\n    (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] (j : \u03b1)\n    [(i : \u03b1) \u2192 Decidable (i \u2208 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 {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i)\n    (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] {i : \u03b1} (p : \u03b4 i \u2192 Prop) (hf : p (f i))\n    (hg : p (g i)) : p (piecewise s f g i) :=\n  sorry\n\ntheorem piecewise_mem_set_pi {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)]\n    {\u03b4 : \u03b1 \u2192 Type u_2} {t : set \u03b1} {t' : (i : \u03b1) \u2192 set (\u03b4 i)} {f : (i : \u03b1) \u2192 \u03b4 i}\n    {g : (i : \u03b1) \u2192 \u03b4 i} (hf : f \u2208 set.pi t t') (hg : g \u2208 set.pi t t') :\n    piecewise s f g \u2208 set.pi t t' :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (piecewise s f g \u2208 set.pi t t')) (Eq.symm (piecewise_coe s f g))))\n    (set.piecewise_mem_pi (\u2191s) hf hg)\n\ntheorem piecewise_singleton {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (f : (i : \u03b1) \u2192 \u03b4 i)\n    (g : (i : \u03b1) \u2192 \u03b4 i) [DecidableEq \u03b1] (i : \u03b1) :\n    piecewise (singleton i) f g = function.update g i (f i) :=\n  sorry\n\ntheorem piecewise_piecewise_of_subset_left {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} {s : finset \u03b1}\n    {t : finset \u03b1} [(i : \u03b1) \u2192 Decidable (i \u2208 s)] [(i : \u03b1) \u2192 Decidable (i \u2208 t)] (h : s \u2286 t)\n    (f\u2081 : (a : \u03b1) \u2192 \u03b4 a) (f\u2082 : (a : \u03b1) \u2192 \u03b4 a) (g : (a : \u03b1) \u2192 \u03b4 a) :\n    piecewise s (piecewise t f\u2081 f\u2082) g = piecewise s f\u2081 g :=\n  piecewise_congr s (fun (i : \u03b1) (hi : i \u2208 s) => piecewise_eq_of_mem t f\u2081 f\u2082 (h hi))\n    fun (_x : \u03b1) (_x_1 : \u00ac_x \u2208 s) => rfl\n\n@[simp] theorem piecewise_idem_left {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1)\n    [(j : \u03b1) \u2192 Decidable (j \u2208 s)] (f\u2081 : (a : \u03b1) \u2192 \u03b4 a) (f\u2082 : (a : \u03b1) \u2192 \u03b4 a) (g : (a : \u03b1) \u2192 \u03b4 a) :\n    piecewise s (piecewise s f\u2081 f\u2082) g = piecewise s f\u2081 g :=\n  piecewise_piecewise_of_subset_left (subset.refl s) f\u2081 f\u2082 g\n\ntheorem piecewise_piecewise_of_subset_right {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} {s : finset \u03b1}\n    {t : finset \u03b1} [(i : \u03b1) \u2192 Decidable (i \u2208 s)] [(i : \u03b1) \u2192 Decidable (i \u2208 t)] (h : t \u2286 s)\n    (f : (a : \u03b1) \u2192 \u03b4 a) (g\u2081 : (a : \u03b1) \u2192 \u03b4 a) (g\u2082 : (a : \u03b1) \u2192 \u03b4 a) :\n    piecewise s f (piecewise t g\u2081 g\u2082) = piecewise s f g\u2082 :=\n  piecewise_congr s (fun (_x : \u03b1) (_x_1 : _x \u2208 s) => rfl)\n    fun (i : \u03b1) (hi : \u00aci \u2208 s) => piecewise_eq_of_not_mem t g\u2081 g\u2082 (mt h hi)\n\n@[simp] theorem piecewise_idem_right {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1)\n    [(j : \u03b1) \u2192 Decidable (j \u2208 s)] (f : (a : \u03b1) \u2192 \u03b4 a) (g\u2081 : (a : \u03b1) \u2192 \u03b4 a) (g\u2082 : (a : \u03b1) \u2192 \u03b4 a) :\n    piecewise s f (piecewise s g\u2081 g\u2082) = piecewise s f g\u2082 :=\n  piecewise_piecewise_of_subset_right (subset.refl s) f g\u2081 g\u2082\n\ntheorem update_eq_piecewise {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] (f : \u03b1 \u2192 \u03b2) (i : \u03b1)\n    (v : \u03b2) : function.update f i v = piecewise (singleton i) (fun (j : \u03b1) => v) f :=\n  Eq.symm (piecewise_singleton (fun (i : \u03b1) => v) f i)\n\ntheorem update_piecewise {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i)\n    (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] (i : \u03b1) (v : \u03b4 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 {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1) (f : (i : \u03b1) \u2192 \u03b4 i)\n    (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] {i : \u03b1} (hi : i \u2208 s)\n    (v : \u03b4 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 {\u03b1 : Type u_1} {\u03b4 : \u03b1 \u2192 Sort u_4} (s : finset \u03b1)\n    (f : (i : \u03b1) \u2192 \u03b4 i) (g : (i : \u03b1) \u2192 \u03b4 i) [(j : \u03b1) \u2192 Decidable (j \u2208 s)] [DecidableEq \u03b1] {i : \u03b1}\n    (hi : \u00aci \u2208 s) (v : \u03b4 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 {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)]\n    {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i}\n    {h : (i : \u03b1) \u2192 \u03b4 i} (Hf : f \u2264 h) (Hg : g \u2264 h) : piecewise s f g \u2264 h :=\n  fun (x : \u03b1) => piecewise_cases s f g (fun (_x : \u03b4 x) => _x \u2264 h x) (Hf x) (Hg x)\n\ntheorem le_piecewise_of_le_of_le {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)]\n    {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i}\n    {h : (i : \u03b1) \u2192 \u03b4 i} (Hf : h \u2264 f) (Hg : h \u2264 g) : h \u2264 piecewise s f g :=\n  fun (x : \u03b1) => piecewise_cases s f g (fun (y : \u03b4 x) => h x \u2264 y) (Hf x) (Hg x)\n\ntheorem piecewise_le_piecewise' {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)]\n    {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i}\n    {f' : (i : \u03b1) \u2192 \u03b4 i} {g' : (i : \u03b1) \u2192 \u03b4 i} (Hf : \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2264 f' x)\n    (Hg : \u2200 (x : \u03b1), \u00acx \u2208 s \u2192 g x \u2264 g' x) : piecewise s f g \u2264 piecewise s f' g' :=\n  sorry\n\ntheorem piecewise_le_piecewise {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)]\n    {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i}\n    {f' : (i : \u03b1) \u2192 \u03b4 i} {g' : (i : \u03b1) \u2192 \u03b4 i} (Hf : f \u2264 f') (Hg : g \u2264 g') :\n    piecewise s f g \u2264 piecewise s f' g' :=\n  piecewise_le_piecewise' s (fun (x : \u03b1) (_x : x \u2208 s) => Hf x) fun (x : \u03b1) (_x : \u00acx \u2208 s) => Hg x\n\ntheorem piecewise_mem_Icc_of_mem_of_mem {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)]\n    {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {f\u2081 : (i : \u03b1) \u2192 \u03b4 i}\n    {g : (i : \u03b1) \u2192 \u03b4 i} {g\u2081 : (i : \u03b1) \u2192 \u03b4 i} (hf : f \u2208 set.Icc f\u2081 g\u2081) (hg : g \u2208 set.Icc f\u2081 g\u2081) :\n    piecewise s f g \u2208 set.Icc f\u2081 g\u2081 :=\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 {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)]\n    {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i}\n    (h : f \u2264 g) : piecewise s f g \u2208 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' {\u03b1 : Type u_1} (s : finset \u03b1) [(j : \u03b1) \u2192 Decidable (j \u2208 s)]\n    {\u03b4 : \u03b1 \u2192 Type u_2} [(i : \u03b1) \u2192 preorder (\u03b4 i)] {f : (i : \u03b1) \u2192 \u03b4 i} {g : (i : \u03b1) \u2192 \u03b4 i}\n    (h : g \u2264 f) : piecewise s f g \u2208 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 {\u03b1 : Type u_1} {s : finset \u03b1}\n    {p : (a : \u03b1) \u2192 a \u2208 s \u2192 Prop} [hp : (a : \u03b1) \u2192 (h : a \u2208 s) \u2192 Decidable (p a h)] :\n    Decidable (\u2200 (a : \u03b1) (h : a \u2208 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 {\u03b1 : Type u_1} {s : finset \u03b1} {\u03b2 : \u03b1 \u2192 Type u_2}\n    [h : (a : \u03b1) \u2192 DecidableEq (\u03b2 a)] : DecidableEq ((a : \u03b1) \u2192 a \u2208 s \u2192 \u03b2 a) :=\n  multiset.decidable_eq_pi_multiset\n\nprotected instance decidable_dexists_finset {\u03b1 : Type u_1} {s : finset \u03b1}\n    {p : (a : \u03b1) \u2192 a \u2208 s \u2192 Prop} [hp : (a : \u03b1) \u2192 (h : a \u2208 s) \u2192 Decidable (p a h)] :\n    Decidable (\u2203 (a : \u03b1), \u2203 (h : a \u2208 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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) : finset \u03b1 :=\n  mk (multiset.filter p (val s)) sorry\n\n@[simp] theorem filter_val {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) :\n    val (filter p s) = multiset.filter p (val s) :=\n  rfl\n\n@[simp] theorem filter_subset {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) :\n    filter p s \u2286 s :=\n  multiset.filter_subset p (val s)\n\n@[simp] theorem mem_filter {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} {a : \u03b1} :\n    a \u2208 filter p s \u2194 a \u2208 s \u2227 p a :=\n  multiset.mem_filter\n\ntheorem filter_ssubset {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} :\n    filter p s \u2282 s \u2194 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), \u00acp x :=\n  sorry\n\ntheorem filter_filter {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) [decidable_pred p]\n    [decidable_pred q] (s : finset \u03b1) :\n    filter q (filter p s) = filter (fun (a : \u03b1) => p a \u2227 q a) s :=\n  sorry\n\ntheorem filter_true {\u03b1 : Type u_1} {s : finset \u03b1} [h : decidable_pred fun (_x : \u03b1) => True] :\n    filter (fun (_x : \u03b1) => True) s = s :=\n  sorry\n\n@[simp] theorem filter_false {\u03b1 : Type u_1} {h : decidable_pred fun (a : \u03b1) => False}\n    (s : finset \u03b1) : filter (fun (a : \u03b1) => False) s = \u2205 :=\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 {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1}\n    (h : \u2200 (x : \u03b1), x \u2208 s \u2192 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 `\u2205`. -/\ntheorem filter_false_of_mem {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1}\n    (h : \u2200 (x : \u03b1), x \u2208 s \u2192 \u00acp x) : filter p s = \u2205 :=\n  sorry\n\ntheorem filter_congr {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} [decidable_pred p]\n    [decidable_pred q] {s : finset \u03b1} (H : \u2200 (x : \u03b1), x \u2208 s \u2192 (p x \u2194 q x)) :\n    filter p s = filter q s :=\n  eq_of_veq (multiset.filter_congr H)\n\ntheorem filter_empty {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] : filter p \u2205 = \u2205 :=\n  iff.mp subset_empty (filter_subset p \u2205)\n\ntheorem filter_subset_filter {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] {s : finset \u03b1}\n    {t : finset \u03b1} (h : s \u2286 t) : filter p s \u2286 filter p t :=\n  fun (a : \u03b1) (ha : a \u2208 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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) :\n    \u2191(filter p s) = has_sep.sep (fun (x : \u03b1) => p x) \u2191s :=\n  set.ext fun (_x : \u03b1) => mem_filter\n\ntheorem filter_singleton {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (a : \u03b1) :\n    filter p (singleton a) = ite (p a) (singleton a) \u2205 :=\n  sorry\n\ntheorem filter_union {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1]\n    (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : filter p (s\u2081 \u222a s\u2082) = filter p s\u2081 \u222a filter p s\u2082 :=\n  sorry\n\ntheorem filter_union_right {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) [decidable_pred p]\n    [decidable_pred q] [DecidableEq \u03b1] (s : finset \u03b1) :\n    filter p s \u222a filter q s = filter (fun (x : \u03b1) => p x \u2228 q x) s :=\n  sorry\n\ntheorem filter_mem_eq_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    [(i : \u03b1) \u2192 Decidable (i \u2208 t)] : filter (fun (i : \u03b1) => i \u2208 t) s = s \u2229 t :=\n  sorry\n\ntheorem filter_inter {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] (s : finset \u03b1)\n    (t : finset \u03b1) : filter p s \u2229 t = filter p (s \u2229 t) :=\n  sorry\n\ntheorem inter_filter {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] (s : finset \u03b1)\n    (t : finset \u03b1) : s \u2229 filter p t = filter p (s \u2229 t) :=\n  sorry\n\ntheorem filter_insert {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1] (a : \u03b1)\n    (s : finset \u03b1) : filter p (insert a s) = ite (p a) (insert a (filter p s)) (filter p s) :=\n  sorry\n\ntheorem filter_or {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) [decidable_pred p] [decidable_pred q]\n    [DecidableEq \u03b1] [decidable_pred fun (a : \u03b1) => p a \u2228 q a] (s : finset \u03b1) :\n    filter (fun (a : \u03b1) => p a \u2228 q a) s = filter p s \u222a filter q s :=\n  sorry\n\ntheorem filter_and {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) (q : \u03b1 \u2192 Prop) [decidable_pred p]\n    [decidable_pred q] [DecidableEq \u03b1] [decidable_pred fun (a : \u03b1) => p a \u2227 q a] (s : finset \u03b1) :\n    filter (fun (a : \u03b1) => p a \u2227 q a) s = filter p s \u2229 filter q s :=\n  sorry\n\ntheorem filter_not {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1]\n    [decidable_pred fun (a : \u03b1) => \u00acp a] (s : finset \u03b1) :\n    filter (fun (a : \u03b1) => \u00acp a) s = s \\ filter p s :=\n  sorry\n\ntheorem sdiff_eq_filter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2081 \\ s\u2082 = filter (fun (_x : \u03b1) => \u00ac_x \u2208 s\u2082) s\u2081 :=\n  sorry\n\ntheorem sdiff_eq_self {\u03b1 : Type u_1} [DecidableEq \u03b1] (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) :\n    s\u2081 \\ s\u2082 = s\u2081 \u2194 s\u2081 \u2229 s\u2082 \u2286 \u2205 :=\n  sorry\n\ntheorem filter_union_filter_neg_eq {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1]\n    [decidable_pred fun (a : \u03b1) => \u00acp a] (s : finset \u03b1) :\n    filter p s \u222a filter (fun (a : \u03b1) => \u00acp a) s = s :=\n  sorry\n\ntheorem filter_inter_filter_neg_eq {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] [DecidableEq \u03b1]\n    (s : finset \u03b1) : filter p s \u2229 filter (fun (a : \u03b1) => \u00acp a) s = \u2205 :=\n  sorry\n\ntheorem subset_union_elim {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t\u2081 : set \u03b1} {t\u2082 : set \u03b1}\n    (h : \u2191s \u2286 t\u2081 \u222a t\u2082) :\n    \u2203 (s\u2081 : finset \u03b1), \u2203 (s\u2082 : finset \u03b1), s\u2081 \u222a s\u2082 = s \u2227 \u2191s\u2081 \u2286 t\u2081 \u2227 \u2191s\u2082 \u2286 t\u2082 \\ t\u2081 :=\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 {\u03b1 : Type u_1} (s : finset \u03b1) (p : \u03b1 \u2192 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 \u2208 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 \u2208 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 \u2208 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 {\u03b1 : Type u_1} : has_sep \u03b1 (finset \u03b1) :=\n  has_sep.mk fun (p : \u03b1 \u2192 Prop) (x : finset \u03b1) => filter p x\n\n@[simp] theorem sep_def {\u03b1 : Type u_1} (s : finset \u03b1) (p : \u03b1 \u2192 Prop) :\n    has_sep.sep (fun (x : \u03b1) => 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 \u2208 s.filter(eq b)`.\n\ntheorem filter_eq {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b2) (b : \u03b2) :\n    filter (Eq b) s = ite (b \u2208 s) (singleton b) \u2205 :=\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' {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b2) (b : \u03b2) :\n    filter (fun (a : \u03b2) => a = b) s = ite (b \u2208 s) (singleton b) \u2205 :=\n  trans (filter_congr fun (_x : \u03b2) (_x_1 : _x \u2208 s) => { mp := Eq.symm, mpr := Eq.symm })\n    (filter_eq s b)\n\ntheorem filter_ne {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b2) (b : \u03b2) :\n    filter (fun (a : \u03b2) => b \u2260 a) s = erase s b :=\n  sorry\n\ntheorem filter_ne' {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b2) (b : \u03b2) :\n    filter (fun (a : \u03b2) => a \u2260 b) s = erase s b :=\n  trans (filter_congr fun (_x : \u03b2) (_x_1 : _x \u2208 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 : \u2115) : finset \u2115 := mk (multiset.range n) (multiset.nodup_range n)\n\n@[simp] theorem range_coe (n : \u2115) : val (range n) = multiset.range n := rfl\n\n@[simp] theorem mem_range {n : \u2115} {m : \u2115} : m \u2208 range n \u2194 m < n := multiset.mem_range\n\n@[simp] theorem range_zero : range 0 = \u2205 := rfl\n\n@[simp] theorem range_one : range 1 = singleton 0 := rfl\n\ntheorem range_succ {n : \u2115} : 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 : \u2115} : range (n + 1) = insert n (range n) := range_succ\n\n@[simp] theorem not_mem_range_self {n : \u2115} : \u00acn \u2208 range n := multiset.not_mem_range_self\n\n@[simp] theorem self_mem_range_succ (n : \u2115) : n \u2208 range (n + 1) := multiset.self_mem_range_succ n\n\n@[simp] theorem range_subset {n : \u2115} {m : \u2115} : range n \u2286 range m \u2194 n \u2264 m := multiset.range_subset\n\ntheorem range_mono : monotone range := fun (_x _x_1 : \u2115) => iff.mpr range_subset\n\ntheorem mem_range_succ_iff {a : \u2115} {b : \u2115} : a \u2208 range (Nat.succ b) \u2194 a \u2264 b :=\n  iff.trans mem_range nat.lt_succ_iff\n\n/- useful rules for calculations with quantifiers -/\n\ntheorem exists_mem_empty_iff {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) : (\u2203 (x : \u03b1), x \u2208 \u2205 \u2227 p x) \u2194 False :=\n  sorry\n\ntheorem exists_mem_insert {\u03b1 : Type u_1} [d : DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (p : \u03b1 \u2192 Prop) :\n    (\u2203 (x : \u03b1), x \u2208 insert a s \u2227 p x) \u2194 p a \u2228 \u2203 (x : \u03b1), x \u2208 s \u2227 p x :=\n  sorry\n\ntheorem forall_mem_empty_iff {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) : (\u2200 (x : \u03b1), x \u2208 \u2205 \u2192 p x) \u2194 True :=\n  iff_true_intro fun (_x : \u03b1) => false.elim\n\ntheorem forall_mem_insert {\u03b1 : Type u_1} [d : DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) (p : \u03b1 \u2192 Prop) :\n    (\u2200 (x : \u03b1), x \u2208 insert a s \u2192 p x) \u2194 p a \u2227 \u2200 (x : \u03b1), x \u2208 s \u2192 p x :=\n  sorry\n\nend finset\n\n\n/-- Equivalence between the set of natural numbers which are `\u2265 k` and `\u2115`, given by `n \u2192 n - k`. -/\ndef not_mem_range_equiv (k : \u2115) : (Subtype fun (n : \u2115) => \u00acn \u2208 multiset.range k) \u2243 \u2115 :=\n  equiv.mk (fun (i : Subtype fun (n : \u2115) => \u00acn \u2208 multiset.range k) => subtype.val i - k)\n    (fun (j : \u2115) => { val := j + k, property := sorry }) sorry sorry\n\n@[simp] theorem coe_not_mem_range_equiv (k : \u2115) :\n    \u21d1(not_mem_range_equiv k) = fun (i : Subtype fun (n : \u2115) => \u00acn \u2208 multiset.range k) => \u2191i - k :=\n  rfl\n\n@[simp] theorem coe_not_mem_range_equiv_symm (k : \u2115) :\n    \u21d1(equiv.symm (not_mem_range_equiv k)) =\n        fun (j : \u2115) =>\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 \u2208 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 {\u03b1 : Type} (a : \u03b1) => 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 {\u03b1 : Type u_1} (o : Option \u03b1) : finset \u03b1 := sorry\n\n@[simp] theorem to_finset_none {\u03b1 : Type u_1} : to_finset none = \u2205 := rfl\n\n@[simp] theorem to_finset_some {\u03b1 : Type u_1} {a : \u03b1} : to_finset (some a) = singleton a := rfl\n\n@[simp] theorem mem_to_finset {\u03b1 : Type u_1} {a : \u03b1} {o : Option \u03b1} : a \u2208 to_finset o \u2194 a \u2208 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) : finset \u03b1 :=\n  finset.mk (erase_dup s) sorry\n\n@[simp] theorem to_finset_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) :\n    finset.val (to_finset s) = erase_dup s :=\n  rfl\n\ntheorem to_finset_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : multiset \u03b1} (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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : multiset \u03b1} :\n    a \u2208 to_finset s \u2194 a \u2208 s :=\n  mem_erase_dup\n\n@[simp] theorem to_finset_zero {\u03b1 : Type u_1} [DecidableEq \u03b1] : to_finset 0 = \u2205 := rfl\n\n@[simp] theorem to_finset_cons {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : multiset \u03b1) :\n    to_finset (a ::\u2098 s) = insert a (to_finset s) :=\n  finset.eq_of_veq erase_dup_cons\n\n@[simp] theorem to_finset_add {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) (t : multiset \u03b1) :\n    to_finset (s + t) = to_finset s \u222a to_finset t :=\n  sorry\n\n@[simp] theorem to_finset_nsmul {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) (n : \u2115)\n    (hn : n \u2260 0) : to_finset (n \u2022\u2115 s) = to_finset s :=\n  sorry\n\n@[simp] theorem to_finset_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) (t : multiset \u03b1) :\n    to_finset (s \u2229 t) = to_finset s \u2229 to_finset t :=\n  sorry\n\n@[simp] theorem to_finset_union {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : multiset \u03b1) (t : multiset \u03b1) :\n    to_finset (s \u222a t) = to_finset s \u222a to_finset t :=\n  sorry\n\ntheorem to_finset_eq_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] {m : multiset \u03b1} :\n    to_finset m = \u2205 \u2194 m = 0 :=\n  iff.trans (iff.symm finset.val_inj) erase_dup_eq_zero\n\n@[simp] theorem to_finset_subset {\u03b1 : Type u_1} [DecidableEq \u03b1] (m1 : multiset \u03b1)\n    (m2 : multiset \u03b1) : to_finset m1 \u2286 to_finset m2 \u2194 m1 \u2286 m2 :=\n  sorry\n\nend multiset\n\n\nnamespace finset\n\n\n@[simp] theorem val_to_finset {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) :\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (l : List \u03b1) : finset \u03b1 := multiset.to_finset \u2191l\n\n@[simp] theorem to_finset_val {\u03b1 : Type u_1} [DecidableEq \u03b1] (l : List \u03b1) :\n    finset.val (to_finset l) = \u2191(erase_dup l) :=\n  rfl\n\ntheorem to_finset_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] {l : List \u03b1} (n : nodup l) :\n    finset.mk (\u2191l) n = to_finset l :=\n  multiset.to_finset_eq n\n\n@[simp] theorem mem_to_finset {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {l : List \u03b1} :\n    a \u2208 to_finset l \u2194 a \u2208 l :=\n  mem_erase_dup\n\n@[simp] theorem to_finset_nil {\u03b1 : Type u_1} [DecidableEq \u03b1] : to_finset [] = \u2205 := rfl\n\n@[simp] theorem to_finset_cons {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {l : List \u03b1} :\n    to_finset (a :: l) = insert a (to_finset l) :=\n  sorry\n\ntheorem to_finset_surj_on {\u03b1 : Type u_1} [DecidableEq \u03b1] :\n    set.surj_on to_finset (set_of fun (l : List \u03b1) => nodup l) set.univ :=\n  sorry\n\ntheorem to_finset_surjective {\u03b1 : Type u_1} [DecidableEq \u03b1] : function.surjective to_finset := sorry\n\nend list\n\n\nnamespace finset\n\n\n/-! ### map -/\n\n/-- When `f` is an embedding of `\u03b1` in `\u03b2` and `s` is a finset in `\u03b1`, then `s.map f` is the image\nfinset in `\u03b2`. The embedding condition guarantees that there are no duplicates in the image. -/\ndef map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) : finset \u03b2 :=\n  mk (multiset.map (\u21d1f) (val s)) sorry\n\n@[simp] theorem map_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) :\n    val (map f s) = multiset.map (\u21d1f) (val s) :=\n  rfl\n\n@[simp] theorem map_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) : map f \u2205 = \u2205 := rfl\n\n@[simp] theorem mem_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} {b : \u03b2} :\n    b \u2208 map f s \u2194 \u2203 (a : \u03b1), \u2203 (H : a \u2208 s), coe_fn f a = b :=\n  sorry\n\ntheorem mem_map' {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) {a : \u03b1} {s : finset \u03b1} :\n    coe_fn f a \u2208 map f s \u2194 a \u2208 s :=\n  multiset.mem_map_of_injective (function.embedding.inj' f)\n\ntheorem mem_map_of_mem {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) {a : \u03b1} {s : finset \u03b1} :\n    a \u2208 s \u2192 coe_fn f a \u2208 map f s :=\n  iff.mpr (mem_map' f)\n\n@[simp] theorem coe_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) :\n    \u2191(map f s) = \u21d1f '' \u2191s :=\n  set.ext fun (x : \u03b2) => iff.trans mem_map (iff.symm set.mem_image_iff_bex)\n\ntheorem coe_map_subset_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) :\n    \u2191(map f s) \u2286 set.range \u21d1f :=\n  trans_rel_right has_subset.subset (coe_map f s) (set.image_subset_range \u21d1f \u2191s)\n\ntheorem map_to_finset {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    {s : multiset \u03b1} : map f (multiset.to_finset s) = multiset.to_finset (multiset.map (\u21d1f) s) :=\n  sorry\n\n@[simp] theorem map_refl {\u03b1 : Type u_1} {s : finset \u03b1} : map (function.embedding.refl \u03b1) s = s :=\n  sorry\n\ntheorem map_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1}\n    {g : \u03b2 \u21aa \u03b3} : map g (map f s) = map (function.embedding.trans f g) s :=\n  sorry\n\ntheorem map_subset_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    map f s\u2081 \u2286 map f s\u2082 \u2194 s\u2081 \u2286 s\u2082 :=\n  sorry\n\ntheorem map_inj {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} :\n    map f s\u2081 = map f s\u2082 \u2194 s\u2081 = s\u2082 :=\n  sorry\n\n/-- Associate to an embedding `f` from `\u03b1` to `\u03b2` the embedding that maps a finset to its image\nunder `f`. -/\ndef map_embedding {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) : finset \u03b1 \u21aa finset \u03b2 :=\n  function.embedding.mk (map f) sorry\n\n@[simp] theorem map_embedding_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} :\n    coe_fn (map_embedding f) s = map f s :=\n  rfl\n\ntheorem map_filter {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} {p : \u03b2 \u2192 Prop}\n    [decidable_pred p] : filter p (map f s) = map f (filter (p \u2218 \u21d1f) s) :=\n  sorry\n\ntheorem map_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u21aa \u03b2}\n    (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : map f (s\u2081 \u222a s\u2082) = map f s\u2081 \u222a map f s\u2082 :=\n  sorry\n\ntheorem map_inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] {f : \u03b1 \u21aa \u03b2}\n    (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : map f (s\u2081 \u2229 s\u2082) = map f s\u2081 \u2229 map f s\u2082 :=\n  sorry\n\n@[simp] theorem map_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) (a : \u03b1) :\n    map f (singleton a) = singleton (coe_fn f a) :=\n  sorry\n\n@[simp] theorem map_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2] (f : \u03b1 \u21aa \u03b2)\n    (a : \u03b1) (s : finset \u03b1) : map f (insert a s) = insert (coe_fn f a) (map f s) :=\n  sorry\n\n@[simp] theorem map_eq_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} {f : \u03b1 \u21aa \u03b2} {s : finset \u03b1} :\n    map f s = \u2205 \u2194 s = \u2205 :=\n  sorry\n\ntheorem attach_map_val {\u03b1 : Type u_1} {s : finset \u03b1} :\n    map (function.embedding.subtype fun (x : \u03b1) => x \u2208 s) (attach s) = s :=\n  sorry\n\ntheorem nonempty.map {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} (h : finset.nonempty s)\n    (f : \u03b1 \u21aa \u03b2) : finset.nonempty (map f s) :=\n  sorry\n\ntheorem range_add_one' (n : \u2115) :\n    range (n + 1) =\n        insert 0\n          (map (function.embedding.mk (fun (i : \u2115) => i + 1) fun (i j : \u2115) => 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) : finset \u03b2 :=\n  multiset.to_finset (multiset.map f (val s))\n\n@[simp] theorem image_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) :\n    val (image f s) = multiset.erase_dup (multiset.map f (val s)) :=\n  rfl\n\n@[simp] theorem image_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) :\n    image f \u2205 = \u2205 :=\n  rfl\n\n@[simp] theorem mem_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1}\n    {b : \u03b2} : b \u2208 image f s \u2194 \u2203 (a : \u03b1), \u2203 (H : a \u2208 s), f a = b :=\n  sorry\n\ntheorem mem_image_of_mem {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) {a : \u03b1}\n    {s : finset \u03b1} (h : a \u2208 s) : f a \u2208 image f s :=\n  iff.mpr mem_image (Exists.intro a (Exists.intro h rfl))\n\ntheorem filter_mem_image_eq_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2)\n    (s : finset \u03b1) (t : finset \u03b2) (h : \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2208 t) :\n    filter (fun (y : \u03b2) => y \u2208 image f s) t = image f s :=\n  sorry\n\ntheorem fiber_nonempty_iff_mem_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2)\n    (s : finset \u03b1) (y : \u03b2) : finset.nonempty (filter (fun (x : \u03b1) => f x = y) s) \u2194 y \u2208 image f s :=\n  sorry\n\n@[simp] theorem coe_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} :\n    \u2191(image f s) = f '' \u2191s :=\n  set.ext fun (_x : \u03b2) => iff.trans mem_image (iff.symm set.mem_image_iff_bex)\n\ntheorem nonempty.image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1}\n    (h : finset.nonempty s) (f : \u03b1 \u2192 \u03b2) : finset.nonempty (image f s) :=\n  sorry\n\ntheorem image_to_finset {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} [DecidableEq \u03b1]\n    {s : multiset \u03b1} : image f (multiset.to_finset s) = multiset.to_finset (multiset.map f s) :=\n  sorry\n\ntheorem image_val_of_inj_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1}\n    (H : \u2200 (x : \u03b1), x \u2208 s \u2192 \u2200 (y : \u03b1), y \u2208 s \u2192 f x = f y \u2192 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 {\u03b1 : Type u_1} {s : finset \u03b1} [DecidableEq \u03b1] : image id s = s := sorry\n\ntheorem image_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {s : finset \u03b1} [DecidableEq \u03b3] {g : \u03b2 \u2192 \u03b3} : image g (image f s) = image (g \u2218 f) s :=\n  sorry\n\ntheorem image_subset_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s\u2081 : finset \u03b1}\n    {s\u2082 : finset \u03b1} (h : s\u2081 \u2286 s\u2082) : image f s\u2081 \u2286 image f s\u2082 :=\n  sorry\n\ntheorem image_subset_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {t : finset \u03b2}\n    {f : \u03b1 \u2192 \u03b2} : image f s \u2286 t \u2194 \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2208 t :=\n  sorry\n\ntheorem image_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) : monotone (image f) :=\n  fun (_x _x_1 : finset \u03b1) => image_subset_image\n\ntheorem coe_image_subset_range {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {s : finset \u03b1} : \u2191(image f s) \u2286 set.range f :=\n  trans_rel_right has_subset.subset coe_image (set.image_subset_range f \u2191s)\n\ntheorem image_filter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1}\n    {p : \u03b2 \u2192 Prop} [decidable_pred p] : filter p (image f s) = image f (filter (p \u2218 f) s) :=\n  sorry\n\ntheorem image_union {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1] {f : \u03b1 \u2192 \u03b2}\n    (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) : image f (s\u2081 \u222a s\u2082) = image f s\u2081 \u222a image f s\u2082 :=\n  sorry\n\ntheorem image_inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} [DecidableEq \u03b1]\n    (s\u2081 : finset \u03b1) (s\u2082 : finset \u03b1) (hf : \u2200 (x y : \u03b1), f x = f y \u2192 x = y) :\n    image f (s\u2081 \u2229 s\u2082) = image f s\u2081 \u2229 image f s\u2082 :=\n  sorry\n\n@[simp] theorem image_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u2192 \u03b2) (a : \u03b1) :\n    image f (singleton a) = singleton (f a) :=\n  sorry\n\n@[simp] theorem image_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1]\n    (f : \u03b1 \u2192 \u03b2) (a : \u03b1) (s : finset \u03b1) : image f (insert a s) = insert (f a) (image f s) :=\n  sorry\n\n@[simp] theorem image_eq_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {s : finset \u03b1} : image f s = \u2205 \u2194 s = \u2205 :=\n  sorry\n\ntheorem attach_image_val {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} :\n    image subtype.val (attach s) = s :=\n  sorry\n\n@[simp] theorem attach_insert {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} :\n    attach (insert a s) =\n        insert { val := a, property := mem_insert_self a s }\n          (image\n            (fun (x : Subtype fun (x : \u03b1) => x \u2208 s) =>\n              { val := subtype.val x, property := mem_insert_of_mem (subtype.property x) })\n            (attach s)) :=\n  sorry\n\ntheorem map_eq_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (f : \u03b1 \u21aa \u03b2) (s : finset \u03b1) :\n    map f s = image (\u21d1f) s :=\n  eq_of_veq (Eq.symm (iff.mpr multiset.erase_dup_eq_self (nodup (map f s))))\n\ntheorem image_const {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1}\n    (h : finset.nonempty s) (b : \u03b2) : image (fun (a : \u03b1) => 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) \u2192 Decidable P] : Functor finset :=\n  { map := fun (\u03b1 \u03b2 : Type u_1) (f : \u03b1 \u2192 \u03b2) (s : finset \u03b1) => image f s,\n    mapConst :=\n      fun (\u03b1 \u03b2 : Type u_1) => (fun (f : \u03b2 \u2192 \u03b1) (s : finset \u03b2) => image f s) \u2218 function.const \u03b2 }\n\nprotected instance is_lawful_functor [(P : Prop) \u2192 Decidable P] : is_lawful_functor finset :=\n  is_lawful_functor.mk (fun (\u03b1 : Type u_1) (x : finset \u03b1) => image_id)\n    fun (\u03b1 \u03b2 \u03b3 : Type u_1) (f : \u03b1 \u2192 \u03b2) (g : \u03b2 \u2192 \u03b3) (s : finset \u03b1) => 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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) :\n    finset (Subtype p) :=\n  map\n    (function.embedding.mk\n      (fun (x : Subtype fun (x : \u03b1) => x \u2208 filter p s) =>\n        { val := subtype.val x, property := sorry })\n      sorry)\n    (attach (filter p s))\n\n@[simp] theorem mem_subtype {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1}\n    {a : Subtype p} : a \u2208 finset.subtype p s \u2194 \u2191a \u2208 s :=\n  sorry\n\ntheorem subtype_eq_empty {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop} [decidable_pred p] {s : finset \u03b1} :\n    finset.subtype p s = \u2205 \u2194 \u2200 (x : \u03b1), p x \u2192 \u00acx \u2208 s :=\n  sorry\n\n/-- `s.subtype p` converts back to `s.filter p` with\n`embedding.subtype`. -/\n@[simp] theorem subtype_map {\u03b1 : Type u_1} {s : finset \u03b1} (p : \u03b1 \u2192 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 {\u03b1 : Type u_1} {s : finset \u03b1} {p : \u03b1 \u2192 Prop} [decidable_pred p]\n    (h : \u2200 (x : \u03b1), x \u2208 s \u2192 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 {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop}\n    (s : finset (Subtype fun (x : \u03b1) => p x)) {a : \u03b1}\n    (h : a \u2208 map (function.embedding.subtype fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {p : \u03b1 \u2192 Prop}\n    (s : finset (Subtype fun (x : \u03b1) => p x)) {a : \u03b1} (h : \u00acp a) :\n    \u00aca \u2208 map (function.embedding.subtype fun (x : \u03b1) => 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 {\u03b1 : Type u_1} {t : set \u03b1} (s : finset \u21a5t) :\n    \u2191(map (function.embedding.subtype fun (x : \u03b1) => x \u2208 t) s) \u2286 t :=\n  sorry\n\ntheorem subset_image_iff {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b2}\n    {t : set \u03b1} : \u2191s \u2286 f '' t \u2194 \u2203 (s' : finset \u03b1), \u2191s' \u2286 t \u2227 image f s' = s :=\n  sorry\n\nend finset\n\n\ntheorem multiset.to_finset_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    (f : \u03b1 \u2192 \u03b2) (m : multiset \u03b1) :\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 {\u03b1 : Type u_1} (s : finset \u03b1) : \u2115 := coe_fn multiset.card (val s)\n\ntheorem card_def {\u03b1 : Type u_1} (s : finset \u03b1) : card s = coe_fn multiset.card (val s) := rfl\n\n@[simp] theorem card_mk {\u03b1 : Type u_1} {m : multiset \u03b1} {nodup : multiset.nodup m} :\n    card (mk m nodup) = coe_fn multiset.card m :=\n  rfl\n\n@[simp] theorem card_empty {\u03b1 : Type u_1} : card \u2205 = 0 := rfl\n\n@[simp] theorem card_eq_zero {\u03b1 : Type u_1} {s : finset \u03b1} : card s = 0 \u2194 s = \u2205 :=\n  iff.trans multiset.card_eq_zero val_eq_zero\n\ntheorem card_pos {\u03b1 : Type u_1} {s : finset \u03b1} : 0 < card s \u2194 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 {\u03b1 : Type u_1} {s : finset \u03b1} {a : \u03b1} (h : a \u2208 s) : card s \u2260 0 :=\n  iff.mpr (not_congr card_eq_zero) (ne_empty_of_mem h)\n\ntheorem card_eq_one {\u03b1 : Type u_1} {s : finset \u03b1} : card s = 1 \u2194 \u2203 (a : \u03b1), s = singleton a := sorry\n\n@[simp] theorem card_insert_of_not_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1}\n    (h : \u00aca \u2208 s) : card (insert a s) = card s + 1 :=\n  sorry\n\ntheorem card_insert_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} (h : a \u2208 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 {\u03b1 : Type u_1} [DecidableEq \u03b1] (a : \u03b1) (s : finset \u03b1) :\n    card (insert a s) \u2264 card s + 1 :=\n  sorry\n\n@[simp] theorem card_singleton {\u03b1 : Type u_1} (a : \u03b1) : card (singleton a) = 1 :=\n  multiset.card_singleton a\n\ntheorem card_singleton_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] {x : \u03b1} {s : finset \u03b1} :\n    card (singleton x \u2229 s) \u2264 1 :=\n  sorry\n\ntheorem card_erase_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} :\n    a \u2208 s \u2192 card (erase s a) = Nat.pred (card s) :=\n  multiset.card_erase_of_mem\n\ntheorem card_erase_lt_of_mem {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} :\n    a \u2208 s \u2192 card (erase s a) < card s :=\n  multiset.card_erase_lt_of_mem\n\ntheorem card_erase_le {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} :\n    card (erase s a) \u2264 card s :=\n  multiset.card_erase_le\n\ntheorem pred_card_le_card_erase {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1} :\n    card s - 1 \u2264 card (erase s a) :=\n  sorry\n\n@[simp] theorem card_range (n : \u2115) : card (range n) = n := multiset.card_range n\n\n@[simp] theorem card_attach {\u03b1 : Type u_1} {s : finset \u03b1} : card (attach s) = card s :=\n  multiset.card_attach\n\nend finset\n\n\ntheorem multiset.to_finset_card_le {\u03b1 : Type u_1} [DecidableEq \u03b1] (m : multiset \u03b1) :\n    finset.card (multiset.to_finset m) \u2264 coe_fn multiset.card m :=\n  multiset.card_le_of_le (multiset.erase_dup_le m)\n\ntheorem list.to_finset_card_le {\u03b1 : Type u_1} [DecidableEq \u03b1] (l : List \u03b1) :\n    finset.card (list.to_finset l) \u2264 list.length l :=\n  multiset.to_finset_card_le (quotient.mk l)\n\nnamespace finset\n\n\ntheorem card_image_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} :\n    card (image f s) \u2264 card s :=\n  sorry\n\ntheorem card_image_of_inj_on {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    {s : finset \u03b1} (H : \u2200 (x : \u03b1), x \u2208 s \u2192 \u2200 (y : \u03b1), y \u2208 s \u2192 f x = f y \u2192 x = y) :\n    card (image f s) = card s :=\n  sorry\n\ntheorem card_image_of_injective {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {f : \u03b1 \u2192 \u03b2}\n    (s : finset \u03b1) (H : function.injective f) : card (image f s) = card s :=\n  card_image_of_inj_on fun (x : \u03b1) (_x : x \u2208 s) (y : \u03b1) (_x : y \u2208 s) (h : f x = f y) => H h\n\ntheorem fiber_card_ne_zero_iff_mem_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : finset \u03b1) (f : \u03b1 \u2192 \u03b2)\n    [DecidableEq \u03b2] (y : \u03b2) : card (filter (fun (x : \u03b1) => f x = y) s) \u2260 0 \u2194 y \u2208 image f s :=\n  sorry\n\n@[simp] theorem card_map {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u21aa \u03b2) {s : finset \u03b1} :\n    card (map f s) = card s :=\n  multiset.card_map (\u21d1f) (val s)\n\n@[simp] theorem card_subtype {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (s : finset \u03b1) :\n    card (finset.subtype p s) = card (filter p s) :=\n  sorry\n\ntheorem card_eq_of_bijective {\u03b1 : Type u_1} {s : finset \u03b1} {n : \u2115} (f : (i : \u2115) \u2192 i < n \u2192 \u03b1)\n    (hf : \u2200 (a : \u03b1), a \u2208 s \u2192 \u2203 (i : \u2115), \u2203 (h : i < n), f i h = a)\n    (hf' : \u2200 (i : \u2115) (h : i < n), f i h \u2208 s)\n    (f_inj : \u2200 (i j : \u2115) (hi : i < n) (hj : j < n), f i hi = f j hj \u2192 i = j) : card s = n :=\n  sorry\n\ntheorem card_eq_succ {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {n : \u2115} :\n    card s = n + 1 \u2194 \u2203 (a : \u03b1), \u2203 (t : finset \u03b1), \u00aca \u2208 t \u2227 insert a t = s \u2227 card t = n :=\n  sorry\n\ntheorem card_le_of_subset {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} : s \u2286 t \u2192 card s \u2264 card t :=\n  multiset.card_le_of_le \u2218 iff.mpr val_le_iff\n\ntheorem eq_of_subset_of_card_le {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} (h : s \u2286 t)\n    (h\u2082 : card t \u2264 card s) : s = t :=\n  eq_of_veq (multiset.eq_of_le_of_card_le (iff.mpr val_le_iff h) h\u2082)\n\ntheorem card_lt_card {\u03b1 : Type u_1} {s : finset \u03b1} {t : finset \u03b1} (h : s \u2282 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2}\n    (f : \u03b1 \u2192 \u03b2) (hf : \u2200 (a : \u03b1), a \u2208 s \u2192 f a \u2208 t)\n    (f_inj : \u2200 (a\u2081 : \u03b1), a\u2081 \u2208 s \u2192 \u2200 (a\u2082 : \u03b1), a\u2082 \u2208 s \u2192 f a\u2081 = f a\u2082 \u2192 a\u2081 = a\u2082) : card s \u2264 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1}\n    {t : finset \u03b2} (hc : card t < card s) {f : \u03b1 \u2192 \u03b2} (hf : \u2200 (a : \u03b1), a \u2208 s \u2192 f a \u2208 t) :\n    \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), \u2203 (y : \u03b1), \u2203 (H : y \u2208 s), x \u2260 y \u2227 f x = f y :=\n  sorry\n\ntheorem card_le_of_inj_on {\u03b1 : Type u_1} {n : \u2115} {s : finset \u03b1} (f : \u2115 \u2192 \u03b1)\n    (hf : \u2200 (i : \u2115), i < n \u2192 f i \u2208 s) (f_inj : \u2200 (i j : \u2115), i < n \u2192 j < n \u2192 f i = f j \u2192 i = j) :\n    n \u2264 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 {\u03b1 : Type u_1} {p : finset \u03b1 \u2192 Sort u_2} (s : finset \u03b1) :\n    ((s : finset \u03b1) \u2192 ((t : finset \u03b1) \u2192 t \u2282 s \u2192 p t) \u2192 p s) \u2192 p s :=\n  sorry\n\ntheorem case_strong_induction_on {\u03b1 : Type u_1} [DecidableEq \u03b1] {p : finset \u03b1 \u2192 Prop} (s : finset \u03b1)\n    (h\u2080 : p \u2205)\n    (h\u2081 : \u2200 (a : \u03b1) (s : finset \u03b1), \u00aca \u2208 s \u2192 (\u2200 (t : finset \u03b1), t \u2286 s \u2192 p t) \u2192 p (insert a s)) :\n    p s :=\n  sorry\n\ntheorem card_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2}\n    (f : (a : \u03b1) \u2192 a \u2208 s \u2192 \u03b2) (h\u2081 : \u2200 (a : \u03b1) (ha : a \u2208 s), f a ha \u2208 t)\n    (h\u2082 : \u2200 (a b : \u03b1) (ha : a \u2208 s) (hb : b \u2208 s), f a ha = f b hb \u2192 a = b)\n    (h\u2083 : \u2200 (b : \u03b2), b \u2208 t \u2192 \u2203 (a : \u03b1), \u2203 (ha : a \u2208 s), f a ha = b) : card s = card t :=\n  sorry\n\ntheorem card_union_add_card_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    card (s \u222a t) + card (s \u2229 t) = card s + card t :=\n  sorry\n\ntheorem card_union_le {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    card (s \u222a t) \u2264 card s + card t :=\n  card_union_add_card_inter s t \u25b8 nat.le_add_right (card (s \u222a t)) (card (s \u2229 t))\n\ntheorem card_union_eq {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    (h : disjoint s t) : card (s \u222a t) = card s + card t :=\n  sorry\n\ntheorem surj_on_of_inj_on_of_card_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2}\n    (f : (a : \u03b1) \u2192 a \u2208 s \u2192 \u03b2) (hf : \u2200 (a : \u03b1) (ha : a \u2208 s), f a ha \u2208 t)\n    (hinj : \u2200 (a\u2081 a\u2082 : \u03b1) (ha\u2081 : a\u2081 \u2208 s) (ha\u2082 : a\u2082 \u2208 s), f a\u2081 ha\u2081 = f a\u2082 ha\u2082 \u2192 a\u2081 = a\u2082)\n    (hst : card t \u2264 card s) (b : \u03b2) (H : b \u2208 t) : \u2203 (a : \u03b1), \u2203 (ha : a \u2208 s), b = f a ha :=\n  sorry\n\ntheorem inj_on_of_surj_on_of_card_le {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2}\n    (f : (a : \u03b1) \u2192 a \u2208 s \u2192 \u03b2) (hf : \u2200 (a : \u03b1) (ha : a \u2208 s), f a ha \u2208 t)\n    (hsurj : \u2200 (b : \u03b2), b \u2208 t \u2192 \u2203 (a : \u03b1), \u2203 (ha : a \u2208 s), b = f a ha) (hst : card s \u2264 card t)\n    {a\u2081 : \u03b1} {a\u2082 : \u03b1} (ha\u2081 : a\u2081 \u2208 s) (ha\u2082 : a\u2082 \u2208 s) (ha\u2081a\u2082 : f a\u2081 ha\u2081 = f a\u2082 ha\u2082) : a\u2081 = a\u2082 :=\n  sorry\n\n/-!\n### bUnion\n\nThis section is about the bounded union of an indexed family `t : \u03b1 \u2192 finset \u03b2` of finite sets\nover a finite set `s : finset \u03b1`.\n-/\n\n/-- `bUnion s t` is the union of `t x` over `x \u2208 s`.\n(This was formerly `bind` due to the monad structure on types with `decidable_eq`.) -/\nprotected def bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b1)\n    (t : \u03b1 \u2192 finset \u03b2) : finset \u03b2 :=\n  multiset.to_finset (multiset.bind (val s) fun (a : \u03b1) => val (t a))\n\n@[simp] theorem bUnion_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b1)\n    (t : \u03b1 \u2192 finset \u03b2) :\n    val (finset.bUnion s t) = multiset.erase_dup (multiset.bind (val s) fun (a : \u03b1) => val (t a)) :=\n  rfl\n\n@[simp] theorem bUnion_empty {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {t : \u03b1 \u2192 finset \u03b2} :\n    finset.bUnion \u2205 t = \u2205 :=\n  rfl\n\n@[simp] theorem mem_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1}\n    {t : \u03b1 \u2192 finset \u03b2} {b : \u03b2} : b \u2208 finset.bUnion s t \u2194 \u2203 (a : \u03b1), \u2203 (H : a \u2208 s), b \u2208 t a :=\n  sorry\n\n@[simp] theorem bUnion_insert {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1}\n    {t : \u03b1 \u2192 finset \u03b2} [DecidableEq \u03b1] {a : \u03b1} :\n    finset.bUnion (insert a s) t = t a \u222a finset.bUnion s t :=\n  sorry\n\n-- ext $ \u03bb x, by simp [or_and_distrib_right, exists_or_distrib]\n\n@[simp] theorem singleton_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {t : \u03b1 \u2192 finset \u03b2}\n    {a : \u03b1} : finset.bUnion (singleton a) t = t a :=\n  sorry\n\ntheorem bUnion_inter {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (s : finset \u03b1) (f : \u03b1 \u2192 finset \u03b2)\n    (t : finset \u03b2) : finset.bUnion s f \u2229 t = finset.bUnion s fun (x : \u03b1) => f x \u2229 t :=\n  sorry\n\ntheorem inter_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] (t : finset \u03b2) (s : finset \u03b1)\n    (f : \u03b1 \u2192 finset \u03b2) : t \u2229 finset.bUnion s f = finset.bUnion s fun (x : \u03b1) => t \u2229 f x :=\n  sorry\n\ntheorem image_bUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [DecidableEq \u03b2] [DecidableEq \u03b3]\n    {f : \u03b1 \u2192 \u03b2} {s : finset \u03b1} {t : \u03b2 \u2192 finset \u03b3} :\n    finset.bUnion (image f s) t = finset.bUnion s fun (a : \u03b1) => t (f a) :=\n  sorry\n\ntheorem bUnion_image {\u03b1 : Type u_1} {\u03b2 : Type u_2} {\u03b3 : Type u_3} [DecidableEq \u03b2] [DecidableEq \u03b3]\n    {s : finset \u03b1} {t : \u03b1 \u2192 finset \u03b2} {f : \u03b2 \u2192 \u03b3} :\n    image f (finset.bUnion s t) = finset.bUnion s fun (a : \u03b1) => image f (t a) :=\n  sorry\n\ntheorem bind_to_finset {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1]\n    (s : multiset \u03b1) (t : \u03b1 \u2192 multiset \u03b2) :\n    multiset.to_finset (multiset.bind s t) =\n        finset.bUnion (multiset.to_finset s) fun (a : \u03b1) => multiset.to_finset (t a) :=\n  sorry\n\ntheorem bUnion_mono {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {t\u2081 : \u03b1 \u2192 finset \u03b2}\n    {t\u2082 : \u03b1 \u2192 finset \u03b2} (h : \u2200 (a : \u03b1), a \u2208 s \u2192 t\u2081 a \u2286 t\u2082 a) :\n    finset.bUnion s t\u2081 \u2286 finset.bUnion s t\u2082 :=\n  sorry\n\ntheorem bUnion_subset_bUnion_of_subset_left {\u03b2 : Type u_2} [DecidableEq \u03b2] {\u03b1 : Type u_1}\n    {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1} (t : \u03b1 \u2192 finset \u03b2) (h : s\u2081 \u2286 s\u2082) :\n    finset.bUnion s\u2081 t \u2286 finset.bUnion s\u2082 t :=\n  sorry\n\ntheorem bUnion_singleton {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] {s : finset \u03b1} {f : \u03b1 \u2192 \u03b2} :\n    (finset.bUnion s fun (a : \u03b1) => singleton (f a)) = image f s :=\n  sorry\n\n@[simp] theorem bUnion_singleton_eq_self {\u03b1 : Type u_1} {s : finset \u03b1} [DecidableEq \u03b1] :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1]\n    {s : finset \u03b1} {t : finset \u03b2} {f : \u03b1 \u2192 \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 f x \u2208 t) :\n    (finset.bUnion t fun (a : \u03b2) => filter (fun (c : \u03b1) => f c = a) s) = s :=\n  sorry\n\ntheorem image_bUnion_filter_eq {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b2] [DecidableEq \u03b1]\n    (s : finset \u03b2) (g : \u03b2 \u2192 \u03b1) :\n    (finset.bUnion (image g s) fun (a : \u03b1) => filter (fun (c : \u03b2) => g c = a) s) = s :=\n  bUnion_filter_eq_of_maps_to fun (x : \u03b2) => mem_image_of_mem g\n\n/-! ### prod -/\n\n/-- `product s t` is the set of pairs `(a, b)` such that `a \u2208 s` and `b \u2208 t`. -/\nprotected def product {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : finset \u03b1) (t : finset \u03b2) :\n    finset (\u03b1 \u00d7 \u03b2) :=\n  mk (multiset.product (val s) (val t)) sorry\n\n@[simp] theorem product_val {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} :\n    val (finset.product s t) = multiset.product (val s) (val t) :=\n  rfl\n\n@[simp] theorem mem_product {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2}\n    {p : \u03b1 \u00d7 \u03b2} : p \u2208 finset.product s t \u2194 prod.fst p \u2208 s \u2227 prod.snd p \u2208 t :=\n  multiset.mem_product\n\ntheorem subset_product {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    {s : finset (\u03b1 \u00d7 \u03b2)} : s \u2286 finset.product (image prod.fst s) (image prod.snd s) :=\n  fun (p : \u03b1 \u00d7 \u03b2) (hp : p \u2208 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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} [DecidableEq \u03b1] [DecidableEq \u03b2]\n    (s : finset \u03b1) (t : finset \u03b2) :\n    finset.product s t = finset.bUnion s fun (a : \u03b1) => image (fun (b : \u03b2) => (a, b)) t :=\n  sorry\n\n@[simp] theorem card_product {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : finset \u03b1) (t : finset \u03b2) :\n    card (finset.product s t) = card s * card t :=\n  multiset.card_product (val s) (val t)\n\ntheorem filter_product {\u03b1 : Type u_1} {\u03b2 : Type u_2} {s : finset \u03b1} {t : finset \u03b2} (p : \u03b1 \u2192 Prop)\n    (q : \u03b2 \u2192 Prop) [decidable_pred p] [decidable_pred q] :\n    filter (fun (x : \u03b1 \u00d7 \u03b2) => p (prod.fst x) \u2227 q (prod.snd x)) (finset.product s t) =\n        finset.product (filter p s) (filter q t) :=\n  sorry\n\ntheorem filter_product_card {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : finset \u03b1) (t : finset \u03b2)\n    (p : \u03b1 \u2192 Prop) (q : \u03b2 \u2192 Prop) [decidable_pred p] [decidable_pred q] :\n    card (filter (fun (x : \u03b1 \u00d7 \u03b2) => p (prod.fst x) \u2194 q (prod.snd x)) (finset.product s t)) =\n        card (filter p s) * card (filter q t) +\n          card (filter (Not \u2218 p) s) * card (filter (Not \u2218 q) t) :=\n  sorry\n\n/-! ### sigma -/\n\n/-- `sigma s t` is the set of dependent pairs `\u27e8a, b\u27e9` such that `a \u2208 s` and `b \u2208 t a`. -/\nprotected def sigma {\u03b1 : Type u_1} {\u03c3 : \u03b1 \u2192 Type u_4} (s : finset \u03b1) (t : (a : \u03b1) \u2192 finset (\u03c3 a)) :\n    finset (sigma fun (a : \u03b1) => \u03c3 a) :=\n  mk (multiset.sigma (val s) fun (a : \u03b1) => val (t a)) sorry\n\n@[simp] theorem mem_sigma {\u03b1 : Type u_1} {\u03c3 : \u03b1 \u2192 Type u_4} {s : finset \u03b1}\n    {t : (a : \u03b1) \u2192 finset (\u03c3 a)} {p : sigma \u03c3} :\n    p \u2208 finset.sigma s t \u2194 sigma.fst p \u2208 s \u2227 sigma.snd p \u2208 t (sigma.fst p) :=\n  multiset.mem_sigma\n\ntheorem sigma_mono {\u03b1 : Type u_1} {\u03c3 : \u03b1 \u2192 Type u_4} {s\u2081 : finset \u03b1} {s\u2082 : finset \u03b1}\n    {t\u2081 : (a : \u03b1) \u2192 finset (\u03c3 a)} {t\u2082 : (a : \u03b1) \u2192 finset (\u03c3 a)} (H1 : s\u2081 \u2286 s\u2082)\n    (H2 : \u2200 (a : \u03b1), t\u2081 a \u2286 t\u2082 a) : finset.sigma s\u2081 t\u2081 \u2286 finset.sigma s\u2082 t\u2082 :=\n  sorry\n\ntheorem sigma_eq_bUnion {\u03b1 : Type u_1} {\u03c3 : \u03b1 \u2192 Type u_4} [DecidableEq (sigma fun (a : \u03b1) => \u03c3 a)]\n    (s : finset \u03b1) (t : (a : \u03b1) \u2192 finset (\u03c3 a)) :\n    finset.sigma s t = finset.bUnion s fun (a : \u03b1) => map (function.embedding.sigma_mk a) (t a) :=\n  sorry\n\n/-! ### disjoint -/\n\ntheorem disjoint_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 s \u2192 \u00aca \u2208 t :=\n  sorry\n\ntheorem disjoint_val {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    disjoint s t \u2194 multiset.disjoint (val s) (val t) :=\n  disjoint_left\n\ntheorem disjoint_iff_inter_eq_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    disjoint s t \u2194 s \u2229 t = \u2205 :=\n  disjoint_iff\n\nprotected instance decidable_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] (U : finset \u03b1) (V : finset \u03b1) :\n    Decidable (disjoint U V) :=\n  decidable_of_decidable_of_iff (finset.has_decidable_eq (U \u2293 V) \u22a5) sorry\n\ntheorem disjoint_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)) (propext disjoint.comm)))\n    (eq.mpr\n      (id (Eq._oldrec (Eq.refl (disjoint t s \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)) (propext disjoint_left)))\n      (iff.refl (\u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)))\n\ntheorem disjoint_iff_ne {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    disjoint s t \u2194 \u2200 (a : \u03b1), a \u2208 s \u2192 \u2200 (b : \u03b1), b \u2208 t \u2192 a \u2260 b :=\n  sorry\n\ntheorem disjoint_of_subset_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    {u : finset \u03b1} (h : s \u2286 u) (d : disjoint u t) : disjoint s t :=\n  iff.mpr disjoint_left fun (x : \u03b1) (m\u2081 : x \u2208 s) => iff.mp disjoint_left d x (h m\u2081)\n\ntheorem disjoint_of_subset_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    {u : finset \u03b1} (h : t \u2286 u) (d : disjoint s u) : disjoint s t :=\n  iff.mpr disjoint_right fun (x : \u03b1) (m\u2081 : x \u2208 t) => iff.mp disjoint_right d x (h m\u2081)\n\n@[simp] theorem disjoint_empty_left {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : disjoint \u2205 s :=\n  disjoint_bot_left\n\n@[simp] theorem disjoint_empty_right {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) : disjoint s \u2205 :=\n  disjoint_bot_right\n\n@[simp] theorem singleton_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {a : \u03b1} :\n    disjoint (singleton a) s \u2194 \u00aca \u2208 s :=\n  sorry\n\n@[simp] theorem disjoint_singleton {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {a : \u03b1} :\n    disjoint s (singleton a) \u2194 \u00aca \u2208 s :=\n  iff.trans disjoint.comm singleton_disjoint\n\n@[simp] theorem disjoint_insert_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1}\n    {t : finset \u03b1} : disjoint (insert a s) t \u2194 \u00aca \u2208 t \u2227 disjoint s t :=\n  sorry\n\n@[simp] theorem disjoint_insert_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {a : \u03b1} {s : finset \u03b1}\n    {t : finset \u03b1} : disjoint s (insert a t) \u2194 \u00aca \u2208 s \u2227 disjoint s t :=\n  sorry\n\n@[simp] theorem disjoint_union_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    {u : finset \u03b1} : disjoint (s \u222a t) u \u2194 disjoint s u \u2227 disjoint t u :=\n  sorry\n\n@[simp] theorem disjoint_union_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    {u : finset \u03b1} : disjoint s (t \u222a u) \u2194 disjoint s t \u2227 disjoint s u :=\n  sorry\n\ntheorem sdiff_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    disjoint (t \\ s) s :=\n  iff.mpr disjoint_left fun (a : \u03b1) (ha : a \u2208 t \\ s) => and.right (iff.mp mem_sdiff ha)\n\ntheorem disjoint_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    disjoint s (t \\ s) :=\n  disjoint.symm sdiff_disjoint\n\ntheorem disjoint_sdiff_inter {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) (t : finset \u03b1) :\n    disjoint (s \\ t) (s \u2229 t) :=\n  disjoint_of_subset_right (inter_subset_right s t) sdiff_disjoint\n\ntheorem sdiff_eq_self_iff_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} :\n    s \\ t = s \u2194 disjoint s t :=\n  sorry\n\ntheorem sdiff_eq_self_of_disjoint {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    (h : disjoint s t) : s \\ t = s :=\n  iff.mpr sdiff_eq_self_iff_disjoint h\n\ntheorem disjoint_self_iff_empty {\u03b1 : Type u_1} [DecidableEq \u03b1] (s : finset \u03b1) :\n    disjoint s s \u2194 s = \u2205 :=\n  disjoint_self\n\ntheorem disjoint_bUnion_left {\u03b1 : Type u_1} [DecidableEq \u03b1] {\u03b9 : Type u_2} (s : finset \u03b9)\n    (f : \u03b9 \u2192 finset \u03b1) (t : finset \u03b1) :\n    disjoint (finset.bUnion s f) t \u2194 \u2200 (i : \u03b9), i \u2208 s \u2192 disjoint (f i) t :=\n  sorry\n\ntheorem disjoint_bUnion_right {\u03b1 : Type u_1} [DecidableEq \u03b1] {\u03b9 : Type u_2} (s : finset \u03b1)\n    (t : finset \u03b9) (f : \u03b9 \u2192 finset \u03b1) :\n    disjoint s (finset.bUnion t f) \u2194 \u2200 (i : \u03b9), i \u2208 t \u2192 disjoint s (f i) :=\n  sorry\n\n@[simp] theorem card_disjoint_union {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    (h : disjoint s t) : card (s \u222a t) = card s + card t :=\n  sorry\n\ntheorem card_sdiff {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1} (h : s \u2286 t) :\n    card (t \\ s) = card t - card s :=\n  sorry\n\ntheorem disjoint_filter {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop}\n    [decidable_pred p] [decidable_pred q] :\n    disjoint (filter p s) (filter q s) \u2194 \u2200 (x : \u03b1), x \u2208 s \u2192 p x \u2192 \u00acq x :=\n  sorry\n\ntheorem disjoint_filter_filter {\u03b1 : Type u_1} [DecidableEq \u03b1] {s : finset \u03b1} {t : finset \u03b1}\n    {p : \u03b1 \u2192 Prop} {q : \u03b1 \u2192 Prop} [decidable_pred p] [decidable_pred q] :\n    disjoint s t \u2192 disjoint (filter p s) (filter q t) :=\n  disjoint.mono (filter_subset p s) (filter_subset q t)\n\ntheorem disjoint_iff_disjoint_coe {\u03b1 : Type u_1} {a : finset \u03b1} {b : finset \u03b1} [DecidableEq \u03b1] :\n    disjoint a b \u2194 disjoint \u2191a \u2191b :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint a b \u2194 disjoint \u2191a \u2191b)) (propext disjoint_left)))\n    (eq.mpr\n      (id\n        (Eq._oldrec (Eq.refl ((\u2200 {a_1 : \u03b1}, a_1 \u2208 a \u2192 \u00aca_1 \u2208 b) \u2194 disjoint \u2191a \u2191b))\n          (propext set.disjoint_left)))\n      (iff.refl (\u2200 {a_1 : \u03b1}, a_1 \u2208 a \u2192 \u00aca_1 \u2208 b)))\n\ntheorem filter_card_add_filter_neg_card_eq_card {\u03b1 : Type u_1} {s : finset \u03b1} (p : \u03b1 \u2192 Prop)\n    [decidable_pred p] : card (filter p s) + card (filter (Not \u2218 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 \u2208 s`. -/\ndef diag {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] : finset (\u03b1 \u00d7 \u03b1) :=\n  filter (fun (a : \u03b1 \u00d7 \u03b1) => 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 \u2260 b`\nfor `a, b \u2208 s`. -/\ndef off_diag {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] : finset (\u03b1 \u00d7 \u03b1) :=\n  filter (fun (a : \u03b1 \u00d7 \u03b1) => prod.fst a \u2260 prod.snd a) (finset.product s s)\n\n@[simp] theorem mem_diag {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] (x : \u03b1 \u00d7 \u03b1) :\n    x \u2208 diag s \u2194 prod.fst x \u2208 s \u2227 prod.fst x = prod.snd x :=\n  sorry\n\n@[simp] theorem mem_off_diag {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] (x : \u03b1 \u00d7 \u03b1) :\n    x \u2208 off_diag s \u2194 prod.fst x \u2208 s \u2227 prod.snd x \u2208 s \u2227 prod.fst x \u2260 prod.snd x :=\n  sorry\n\n@[simp] theorem diag_card {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] : card (diag s) = card s :=\n  sorry\n\n@[simp] theorem off_diag_card {\u03b1 : Type u_1} (s : finset \u03b1) [DecidableEq \u03b1] :\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 {\u03b1 : Type u_1} {A : finset \u03b1} {B : finset \u03b1} (i : \u2115)\n    (h\u2081 : i + card B \u2264 card A) (h\u2082 : B \u2286 A) :\n    \u2203 (C : finset \u03b1), B \u2286 C \u2227 C \u2286 A \u2227 card C = i + card B :=\n  sorry\n\n/-- We can shrink A to any smaller size. -/\ntheorem exists_smaller_set {\u03b1 : Type u_1} (A : finset \u03b1) (i : \u2115) (h\u2081 : i \u2264 card A) :\n    \u2203 (B : finset \u03b1), B \u2286 A \u2227 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 : \u2115) : finset (fin k) := mk (\u2191(list.fin_range k)) (list.nodup_fin_range k)\n\n@[simp] theorem fin_range_card {k : \u2115} : card (fin_range k) = k := sorry\n\n@[simp] theorem mem_fin_range {k : \u2115} (m : fin k) : m \u2208 fin_range k := list.mem_fin_range m\n\n@[simp] theorem coe_fin_range (k : \u2115) : \u2191(fin_range k) = set.univ :=\n  set.eq_univ_of_forall mem_fin_range\n\n/-- Given a finset `s` of `\u2115` 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 \u2115) {n : \u2115} (h : \u2200 (m : \u2115), m \u2208 s \u2192 m < n) : finset (fin n) :=\n  mk (multiset.pmap (fun (a : \u2115) (ha : a < n) => { val := a, property := ha }) (val s) h) sorry\n\n@[simp] theorem mem_attach_fin {n : \u2115} {s : finset \u2115} (h : \u2200 (m : \u2115), m \u2208 s \u2192 m < n) {a : fin n} :\n    a \u2208 attach_fin s h \u2194 \u2191a \u2208 s :=\n  sorry\n\n@[simp] theorem card_attach_fin {n : \u2115} (s : finset \u2115) (h : \u2200 (m : \u2115), m \u2208 s \u2192 m < n) :\n    card (attach_fin s h) = card s :=\n  multiset.card_pmap (fun (a : \u2115) (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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1)\n    (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : Subtype fun (a : \u03b1) => a \u2208 l \u2227 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 {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1)\n    (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : \u03b1 :=\n  \u2191(choose_x p l hp)\n\ntheorem choose_spec {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1)\n    (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : choose p l hp \u2208 l \u2227 p (choose p l hp) :=\n  subtype.property (choose_x p l hp)\n\ntheorem choose_mem {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1)\n    (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : choose p l hp \u2208 l :=\n  and.left (choose_spec p l hp)\n\ntheorem choose_property {\u03b1 : Type u_1} (p : \u03b1 \u2192 Prop) [decidable_pred p] (l : finset \u03b1)\n    (hp : exists_unique fun (a : \u03b1) => a \u2208 l \u2227 p a) : p (choose p l hp) :=\n  and.right (choose_spec p l hp)\n\ntheorem lt_wf {\u03b1 : 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 \u03b1) (hxy : x < y) => card_lt_card hxy\n\nend finset\n\n\nnamespace equiv\n\n\n/-- Given an equivalence `\u03b1` to `\u03b2`, produce an equivalence between `finset \u03b1` and `finset \u03b2`. -/\nprotected def finset_congr {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) : finset \u03b1 \u2243 finset \u03b2 :=\n  mk (fun (s : finset \u03b1) => finset.map (equiv.to_embedding e) s)\n    (fun (s : finset \u03b2) => finset.map (equiv.to_embedding (equiv.symm e)) s) sorry sorry\n\n@[simp] theorem finset_congr_apply {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (s : finset \u03b1) :\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 {\u03b1 : Type u_1} {\u03b2 : Type u_2} (e : \u03b1 \u2243 \u03b2) (s : finset \u03b2) :\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 {\u03b1 : Type u_1} [DecidableEq \u03b1] {l : List \u03b1} (h : nodup l) :\n    finset.card (to_finset l) = length l :=\n  congr_arg (\u21d1multiset.card) (iff.mpr multiset.erase_dup_eq_self h)\n\nend list\n\n\nnamespace multiset\n\n\ntheorem to_finset_card_of_nodup {\u03b1 : Type u_1} [DecidableEq \u03b1] {l : multiset \u03b1} (h : nodup l) :\n    finset.card (to_finset l) = coe_fn card l :=\n  congr_arg (\u21d1card) (iff.mpr erase_dup_eq_self h)\n\ntheorem disjoint_to_finset {\u03b1 : Type u_1} [DecidableEq \u03b1] (m1 : multiset \u03b1) (m2 : multiset \u03b1) :\n    disjoint (to_finset m1) (to_finset m2) \u2194 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\u00e9bastien Gou\u00ebzel. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: S\u00e9bastien Gou\u00ebzel\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 `\ud835\udd5c` (with respective models with\ncorners `I` on `(E, H)` and `I'` on `(E', H')`), and let `f : M \u2192 M'`. We define the\nderivative of the function at a point, within a set or along the whole space, mimicking the API\nfor (Fr\u00e9chet) derivatives. It is denoted by `mfderiv I I' f x`, where \"m\" stands for \"manifold\" and\n\"f\" for \"Fr\u00e9chet\" (as in the usual derivative `fderiv \ud835\udd5c 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 \ud835\udd5c 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 \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] (s : set M) (x : M) :=\n  unique_diff_within_at \ud835\udd5c (\u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' s \u2229 set.range \u21d1I) (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] (s : set M) :=\n  \u2200 (x : M), x \u2208 s \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (x : M) (f : M \u2192 M') : E \u2192 E' :=\n  \u21d1(ext_chart_at I' (f x)) \u2218 f \u2218 \u21d1(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : M \u2192 M') (s : set M) (x : M) :=\n  continuous_within_at f s x \u2227\n    differentiable_within_at \ud835\udd5c (written_in_ext_chart_at I I' x f)\n      (\u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' s \u2229 set.range \u21d1I) (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : M \u2192 M') (x : M) :=\n  continuous_at f x \u2227\n    differentiable_within_at \ud835\udd5c (written_in_ext_chart_at I I' x f) (set.range \u21d1I) (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : M \u2192 M') (s : set M) :=\n  \u2200 (x : M), x \u2208 s \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : M \u2192 M') :=\n  \u2200 (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] (f : local_homeomorph M M') :=\n  mdifferentiable_on I I' (\u21d1f) (local_equiv.source (local_homeomorph.to_local_equiv f)) \u2227\n    mdifferentiable_on I' I (\u21d1(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 \u2192 M') (s : set M) (x : M) (f' : continuous_linear_map \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))) :=\n  continuous_within_at f s x \u2227\n    has_fderiv_within_at (written_in_ext_chart_at I I' x f) f'\n      (\u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' s \u2229 set.range \u21d1I) (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 \u2192 M') (x : M) (f' : continuous_linear_map \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))) :=\n  continuous_at f x \u2227\n    has_fderiv_within_at (written_in_ext_chart_at I I' x f) f' (set.range \u21d1I) (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 \u2192 M') (s : set M) (x : M) : continuous_linear_map \ud835\udd5c (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 \ud835\udd5c (written_in_ext_chart_at I I' x f) (\u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' s \u2229 set.range \u21d1I)\n        (coe_fn (ext_chart_at I x) x))\n    fun (h : \u00acmdifferentiable_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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 \u2192 M') (x : M) : continuous_linear_map \ud835\udd5c (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 \ud835\udd5c (written_in_ext_chart_at I I' x f) (set.range \u21d1I) (coe_fn (ext_chart_at I x) x))\n    fun (h : \u00acmdifferentiable_at I I' f x) => 0\n\n/-- The derivative within a set, as a map between the tangent bundles -/\ndef tangent_map_within {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 \u2192 M') (s : set M) : tangent_bundle I M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 \u2192 M') : tangent_bundle I M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \u2194\n  unique_diff_within_at \ud835\udd5c (\u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' s \u2229 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \u2286 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 \u21d1I)))\n\ntheorem unique_mdiff_within_at.inter' {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \u2208 nhds_within x s) : unique_mdiff_within_at I (s \u2229 t) x := sorry\n\ntheorem unique_mdiff_within_at.inter {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \u2208 nhds x) : unique_mdiff_within_at I (s \u2229 t) x := sorry\n\ntheorem is_open.unique_mdiff_within_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {x : M} {s : set M} (xs : x \u2208 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 \u2229 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \u2229 t) :=\n  fun (x : M) (hx : x \u2208 s \u2229 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \u2208 s) => is_open.unique_mdiff_within_at hx hs\n\ntheorem unique_mdiff_on_univ {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} {f\u2081' : continuous_linear_map \ud835\udd5c (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\u2081 : has_mfderiv_within_at I I' f s x f\u2081') : f' = f\u2081' :=\n  unique_diff_within_at.eq U (and.right h) (and.right h\u2081)\n\ntheorem unique_mdiff_on.eq {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} {f\u2081' : continuous_linear_map \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (U : unique_mdiff_on I s) (hx : x \u2208 s) (h : has_mfderiv_within_at I I' f s x f') (h\u2081 : has_mfderiv_within_at I I' f s x f\u2081') : f' = f\u2081' :=\n  unique_mdiff_within_at.eq (U x hx) h h\u2081\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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {s : set M} {x : M} : mdifferentiable_within_at I I' f s x \u2194\n  continuous_within_at f s x \u2227\n    differentiable_within_at \ud835\udd5c (written_in_ext_chart_at I I' x f)\n      (local_equiv.target (ext_chart_at I x) \u2229 \u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' s)\n      (coe_fn (ext_chart_at I x) x) := sorry\n\ntheorem mfderiv_within_zero_of_not_mdifferentiable_within_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : \u00acmdifferentiable_within_at I I' f s x) : mfderiv_within I I' f s x = 0 := sorry\n\ntheorem mfderiv_zero_of_not_mdifferentiable_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : \u00acmdifferentiable_at I I' f x) : mfderiv I I' f x = 0 := sorry\n\ntheorem has_mfderiv_within_at.mono {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f t x f') (hst : s \u2286 t) : has_mfderiv_within_at I I' f s x f' := sorry\n\ntheorem has_mfderiv_at.has_mfderiv_within_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map \ud835\udd5c (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} : has_mfderiv_within_at I I' f set.univ x f' \u2194 has_mfderiv_at I I' f x f' := sorry\n\ntheorem has_mfderiv_at_unique {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f\u2080' : continuous_linear_map \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} {f\u2081' : continuous_linear_map \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h\u2080 : has_mfderiv_at I I' f x f\u2080') (h\u2081 : has_mfderiv_at I I' f x f\u2081') : f\u2080' = f\u2081' :=\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\u2080')) (Eq.symm (propext has_mfderiv_within_at_univ))) h\u2080)\n    (eq.mp (Eq._oldrec (Eq.refl (has_mfderiv_at I I' f x f\u2081')) (Eq.symm (propext has_mfderiv_within_at_univ))) h\u2081)\n\ntheorem has_mfderiv_within_at_inter' {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h : t \u2208 nhds_within x s) : has_mfderiv_within_at I I' f (s \u2229 t) x f' \u2194 has_mfderiv_within_at I I' f s x f' := sorry\n\ntheorem has_mfderiv_within_at_inter {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h : t \u2208 nhds x) : has_mfderiv_within_at I I' f (s \u2229 t) x f' \u2194 has_mfderiv_within_at I I' f s x f' := sorry\n\ntheorem has_mfderiv_within_at.union {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (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 \u222a t) x f' := sorry\n\ntheorem has_mfderiv_within_at.nhds_within {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (ht : s \u2208 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (hs : s \u2208 nhds x) : has_mfderiv_at I I' f x f' := sorry\n\ntheorem mdifferentiable_within_at.has_mfderiv_within_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (written_in_ext_chart_at I I' x f) (\u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' s \u2229 set.range \u21d1I)\n    (coe_fn (ext_chart_at I x) x) := sorry\n\ntheorem mdifferentiable_at.has_mfderiv_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (written_in_ext_chart_at I I' x f) (set.range \u21d1I) (coe_fn (ext_chart_at I x) x) := sorry\n\ntheorem has_mfderiv_at.mfderiv {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map \ud835\udd5c (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \ud835\udd5c (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \u2286 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} {s : set M} {t : set M} (hst : s \u2286 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} : mdifferentiable_within_at I I' f set.univ x \u2194 mdifferentiable_at I I' f x := sorry\n\ntheorem mdifferentiable_within_at_inter {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} {s : set M} {t : set M} (ht : t \u2208 nhds x) : mdifferentiable_within_at I I' f (s \u2229 t) x \u2194 mdifferentiable_within_at I I' f s x := sorry\n\ntheorem mdifferentiable_within_at_inter' {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} {s : set M} {t : set M} (ht : t \u2208 nhds_within x s) : mdifferentiable_within_at I I' f (s \u2229 t) x \u2194 mdifferentiable_within_at I I' f s x := sorry\n\ntheorem mdifferentiable_at.mdifferentiable_within_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} {s : set M} (h : mdifferentiable_within_at I I' f s x) (hs : s \u2208 nhds x) : mdifferentiable_at I I' f x := sorry\n\ntheorem mdifferentiable_on.mono {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {s : set M} {t : set M} (h : mdifferentiable_on I I' f t) (st : s \u2286 t) : mdifferentiable_on I I' f s :=\n  fun (x : M) (hx : x \u2208 s) => mdifferentiable_within_at.mono st (h x (st hx))\n\ntheorem mdifferentiable_on_univ {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} : mdifferentiable_on I I' f set.univ \u2194 mdifferentiable I I' f := sorry\n\ntheorem mdifferentiable.mdifferentiable_on {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {s : set M} (h : \u2200 (x : M), x \u2208 s \u2192 \u2203 (u : set M), is_open u \u2227 x \u2208 u \u2227 mdifferentiable_on I I' f (s \u2229 u)) : mdifferentiable_on I I' f s := sorry\n\n@[simp] theorem mfderiv_within_univ {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \u2208 nhds x) (hs : unique_mdiff_within_at I s x) : mfderiv_within I I' f (s \u2229 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map \ud835\udd5c (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {x : M} (h : mdifferentiable_at I I' f x) : continuous_at f x :=\n  and.left h\n\ntheorem mdifferentiable_on.continuous_on {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {s : set M} (h : mdifferentiable_on I I' f s) : continuous_on f s :=\n  fun (x : M) (hx : x \u2208 s) => mdifferentiable_within_at.continuous_within_at (h x hx)\n\ntheorem mdifferentiable.continuous {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 \u2286 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (h\u2081 : filter.eventually_eq (nhds_within x s) f\u2081 f) (hx : f\u2081 x = f x) : has_mfderiv_within_at I I' f\u2081 s x f' := sorry\n\ntheorem has_mfderiv_within_at.congr_mono {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_within_at I I' f s x f') (ht : \u2200 (x : M), x \u2208 t \u2192 f\u2081 x = f x) (hx : f\u2081 x = f x) (h\u2081 : t \u2286 s) : has_mfderiv_within_at I I' f\u2081 t x f' :=\n  has_mfderiv_within_at.congr_of_eventually_eq (has_mfderiv_within_at.mono h h\u2081) (filter.mem_inf_sets_of_right ht) hx\n\ntheorem has_mfderiv_at.congr_of_eventually_eq {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 M'} {x : M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] {f' : continuous_linear_map \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} (h : has_mfderiv_at I I' f x f') (h\u2081 : filter.eventually_eq (nhds x) f\u2081 f) : has_mfderiv_at I I' f\u2081 x f' := sorry\n\ntheorem mdifferentiable_within_at.congr_of_eventually_eq {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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\u2081 : filter.eventually_eq (nhds_within x s) f\u2081 f) (hx : f\u2081 x = f x) : mdifferentiable_within_at I I' f\u2081 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\u2081 hx)\n\ntheorem filter.eventually_eq.mdifferentiable_within_at_iff {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c E' H') {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 M'} {x : M} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h\u2081 : filter.eventually_eq (nhds_within x s) f\u2081 f) (hx : f\u2081 x = f x) : mdifferentiable_within_at I I' f s x \u2194 mdifferentiable_within_at I I' f\u2081 s x := sorry\n\ntheorem mdifferentiable_within_at.congr_mono {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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 : \u2200 (x : M), x \u2208 t \u2192 f\u2081 x = f x) (hx : f\u2081 x = f x) (h\u2081 : t \u2286 s) : mdifferentiable_within_at I I' f\u2081 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\u2081)\n\ntheorem mdifferentiable_within_at.congr {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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 : \u2200 (x : M), x \u2208 s \u2192 f\u2081 x = f x) (hx : f\u2081 x = f x) : mdifferentiable_within_at I I' f\u2081 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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' : \u2200 (x : M), x \u2208 t \u2192 f\u2081 x = f x) (h\u2081 : t \u2286 s) : mdifferentiable_on I I' f\u2081 t :=\n  fun (x : M) (hx : x \u2208 t) => mdifferentiable_within_at.congr_mono (h x (h\u2081 hx)) h' (h' x hx) h\u2081\n\ntheorem mdifferentiable_at.congr_of_eventually_eq {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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\u2081 f) : mdifferentiable_at I I' f\u2081 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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 : \u2200 (x : M), x \u2208 t \u2192 f\u2081 x = f x) (hx : f\u2081 x = f x) (hxt : unique_mdiff_within_at I t x) (h\u2081 : t \u2286 s) : mfderiv_within I I' f\u2081 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\u2081) hxt\n\ntheorem filter.eventually_eq.mfderiv_within_eq {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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\u2081 f) (hx : f\u2081 x = f x) : mfderiv_within I I' f\u2081 s x = mfderiv_within I I' f s x := sorry\n\ntheorem mfderiv_within_congr {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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 : \u2200 (x : M), x \u2208 s \u2192 f\u2081 x = f x) (hx : f\u2081 x = f x) : mfderiv_within I I' f\u2081 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 M'} {s : set M} [Is : smooth_manifold_with_corners I M] [I's : smooth_manifold_with_corners I' M'] (h : \u2200 (x : M), x \u2208 s \u2192 f x = f\u2081 x) (p : tangent_bundle I M) (hp : sigma.fst p \u2208 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\u2081 s p := sorry\n\ntheorem filter.eventually_eq.mfderiv_eq {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {f : M \u2192 M'} {f\u2081 : M \u2192 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\u2081 f) : mfderiv I I' f\u2081 x = mfderiv I I' f x := sorry\n\n/-! ### Composition lemmas -/\n\ntheorem written_in_ext_chart_comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} {x : M} {s : set M} {g : M' \u2192 M''} (h : continuous_within_at f s x) : (set_of\n    fun (y : E) =>\n      written_in_ext_chart_at I I'' x (g \u2218 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) \u2208\n  nhds_within (coe_fn (ext_chart_at I x) x) (\u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' s \u2229 set.range \u21d1I) := sorry\n\ntheorem has_mfderiv_within_at.comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} (x : M) {s : set M} {g : M' \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} {g' : continuous_linear_map \ud835\udd5c (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 \u2286 f \u207b\u00b9' u) : has_mfderiv_within_at I I'' (g \u2218 f) s x (continuous_linear_map.comp g' f') := sorry\n\n/-- The chain rule. -/\ntheorem has_mfderiv_at.comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} (x : M) {g : M' \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} {g' : continuous_linear_map \ud835\udd5c (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 \u2218 f) x (continuous_linear_map.comp g' f') := sorry\n\ntheorem has_mfderiv_at.comp_has_mfderiv_within_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} (x : M) {s : set M} {g : M' \u2192 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 \ud835\udd5c (tangent_space I x) (tangent_space I' (f x))} {g' : continuous_linear_map \ud835\udd5c (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 \u2218 f) s x (continuous_linear_map.comp g' f') := sorry\n\ntheorem mdifferentiable_within_at.comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} (x : M) {s : set M} {g : M' \u2192 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 \u2286 f \u207b\u00b9' u) : mdifferentiable_within_at I I'' (g \u2218 f) s x := sorry\n\ntheorem mdifferentiable_at.comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} (x : M) {g : M' \u2192 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 \u2218 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} (x : M) {s : set M} {g : M' \u2192 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 \u2286 f \u207b\u00b9' u) (hxs : unique_mdiff_within_at I s x) : mfderiv_within I I'' (g \u2218 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} (x : M) {g : M' \u2192 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 \u2218 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} {s : set M} {g : M' \u2192 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 \u2286 f \u207b\u00b9' u) : mdifferentiable_on I I'' (g \u2218 f) s :=\n  fun (x : M) (hx : x \u2208 s) => mdifferentiable_within_at.comp x (hg (f x) (st hx)) (hf x hx) st\n\ntheorem mdifferentiable.comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} {g : M' \u2192 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 \u2218 f) :=\n  fun (x : M) => mdifferentiable_at.comp x (hg (f x)) (hf x)\n\ntheorem tangent_map_within_comp_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} {s : set M} {g : M' \u2192 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 \u2286 f \u207b\u00b9' u) (hps : unique_mdiff_within_at I s (sigma.fst p)) : tangent_map_within I I'' (g \u2218 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} {g : M' \u2192 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 \u2218 f) p = tangent_map I' I'' g (tangent_map I I' f p) := sorry\n\ntheorem tangent_map_comp {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c E'' H''} {M'' : Type u_10} [topological_space M''] [charted_space H'' M''] {f : M \u2192 M'} {g : M' \u2192 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 \u2218 f) = tangent_map I' I'' g \u2218 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c (tangent_space I x)) := sorry\n\ntheorem has_mfderiv_within_at_id {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c (tangent_space I x)) :=\n  has_mfderiv_at.has_mfderiv_within_at (has_mfderiv_at_id I x)\n\ntheorem mdifferentiable_at_id {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c (tangent_space I x) :=\n  has_mfderiv_at.mfderiv (has_mfderiv_at_id I x)\n\ntheorem mfderiv_within_id {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c (tangent_space I x) := sorry\n\n@[simp] theorem tangent_map_id {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] (I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) : mdifferentiable I (model_with_corners_self \ud835\udd5c E) \u21d1I := sorry\n\ntheorem model_with_corners.mdifferentiable_on_symm {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c E H) : mdifferentiable_on (model_with_corners_self \ud835\udd5c E) I (\u21d1(model_with_corners.symm I)) (set.range \u21d1I) := sorry\n\ntheorem mdifferentiable_at_atlas {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \u2208 charted_space.atlas H M) {x : M} (hx : x \u2208 local_equiv.source (local_homeomorph.to_local_equiv e)) : mdifferentiable_at I I (\u21d1e) x := sorry\n\ntheorem mdifferentiable_on_atlas {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \u2208 charted_space.atlas H M) : mdifferentiable_on I I (\u21d1e) (local_equiv.source (local_homeomorph.to_local_equiv e)) :=\n  fun (x : M) (hx : x \u2208 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \u2208 charted_space.atlas H M) {x : H} (hx : x \u2208 local_equiv.target (local_homeomorph.to_local_equiv e)) : mdifferentiable_at I I (\u21d1(local_homeomorph.symm e)) x := sorry\n\ntheorem mdifferentiable_on_atlas_symm {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \u2208 charted_space.atlas H M) : mdifferentiable_on I I (\u21d1(local_homeomorph.symm e)) (local_equiv.target (local_homeomorph.to_local_equiv e)) :=\n  fun (x : H) (hx : x \u2208 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \u2208 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.source (local_homeomorph.to_local_equiv (charted_space.chart_at H (sigma.fst p)))) : tangent_map I I (\u21d1(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] (I : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.target (local_homeomorph.to_local_equiv (charted_space.chart_at H (sigma.fst p)))) : tangent_map I I (\u21d1(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {s : set E} {x : E} : unique_mdiff_within_at (model_with_corners_self \ud835\udd5c E) s x \u2194 unique_diff_within_at \ud835\udd5c s x := sorry\n\ntheorem unique_mdiff_on_iff_unique_diff_on {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {s : set E} : unique_mdiff_on (model_with_corners_self \ud835\udd5c E) s \u2194 unique_diff_on \ud835\udd5c s := sorry\n\n@[simp] theorem written_in_ext_chart_model_space {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {E' : Type u_3} [normed_group E'] [normed_space \ud835\udd5c E'] {f : E \u2192 E'} {x : E} : written_in_ext_chart_at (model_with_corners_self \ud835\udd5c E) (model_with_corners_self \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {E' : Type u_3} [normed_group E'] [normed_space \ud835\udd5c E'] {f : E \u2192 E'} {s : set E} {x : E} : mdifferentiable_within_at (model_with_corners_self \ud835\udd5c E) (model_with_corners_self \ud835\udd5c E') f s x \u2194\n  differentiable_within_at \ud835\udd5c f s x := sorry\n\n/-- For maps between vector spaces, `mdifferentiable_at` and `differentiable_at` coincide -/\ntheorem mdifferentiable_at_iff_differentiable_at {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {E' : Type u_3} [normed_group E'] [normed_space \ud835\udd5c E'] {f : E \u2192 E'} {x : E} : mdifferentiable_at (model_with_corners_self \ud835\udd5c E) (model_with_corners_self \ud835\udd5c E') f x \u2194 differentiable_at \ud835\udd5c f x := sorry\n\n/-- For maps between vector spaces, `mdifferentiable_on` and `differentiable_on` coincide -/\ntheorem mdifferentiable_on_iff_differentiable_on {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {E' : Type u_3} [normed_group E'] [normed_space \ud835\udd5c E'] {f : E \u2192 E'} {s : set E} : mdifferentiable_on (model_with_corners_self \ud835\udd5c E) (model_with_corners_self \ud835\udd5c E') f s \u2194 differentiable_on \ud835\udd5c f s := sorry\n\n/-- For maps between vector spaces, `mdifferentiable` and `differentiable` coincide -/\ntheorem mdifferentiable_iff_differentiable {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {E' : Type u_3} [normed_group E'] [normed_space \ud835\udd5c E'] {f : E \u2192 E'} : mdifferentiable (model_with_corners_self \ud835\udd5c E) (model_with_corners_self \ud835\udd5c E') f \u2194 differentiable \ud835\udd5c f := sorry\n\n/-- For maps between vector spaces, `mfderiv_within` and `fderiv_within` coincide -/\ntheorem mfderiv_within_eq_fderiv_within {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {E' : Type u_3} [normed_group E'] [normed_space \ud835\udd5c E'] {f : E \u2192 E'} {s : set E} {x : E} : mfderiv_within (model_with_corners_self \ud835\udd5c E) (model_with_corners_self \ud835\udd5c E') f s x = fderiv_within \ud835\udd5c f s x := sorry\n\n/-- For maps between vector spaces, `mfderiv` and `fderiv` coincide -/\ntheorem mfderiv_eq_fderiv {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {E' : Type u_3} [normed_group E'] [normed_space \ud835\udd5c E'] {f : E \u2192 E'} {x : E} : mfderiv (model_with_corners_self \ud835\udd5c E) (model_with_corners_self \ud835\udd5c E') f x = fderiv \ud835\udd5c f x := sorry\n\n/-! ### Differentiable local homeomorphisms -/\n\nnamespace local_homeomorph.mdifferentiable\n\n\ntheorem symm {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.source (to_local_equiv e)) : mdifferentiable_at I I' (\u21d1e) x :=\n  mdifferentiable_within_at.mdifferentiable_at (and.left he x hx) (mem_nhds_sets (open_source e) hx)\n\ntheorem mdifferentiable_at_symm {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.target (to_local_equiv e)) : mdifferentiable_at I' I (\u21d1(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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.source (to_local_equiv e)) : continuous_linear_map.comp (mfderiv I' I (\u21d1(local_homeomorph.symm e)) (coe_fn e x)) (mfderiv I I' (\u21d1e) x) =\n  continuous_linear_map.id \ud835\udd5c (tangent_space I x) := sorry\n\ntheorem comp_symm_deriv {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.target (to_local_equiv e)) : continuous_linear_map.comp (mfderiv I I' (\u21d1e) (coe_fn (local_homeomorph.symm e) x))\n    (mfderiv I' I (\u21d1(local_homeomorph.symm e)) x) =\n  continuous_linear_map.id \ud835\udd5c (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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.source (to_local_equiv e)) : continuous_linear_equiv \ud835\udd5c (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' (\u21d1e) x))) sorry sorry\n      \u21d1(mfderiv I' I (\u21d1(local_homeomorph.symm e)) (coe_fn e x)) sorry sorry)\n\ntheorem mfderiv_bijective {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.source (to_local_equiv e)) : function.bijective \u21d1(mfderiv I I' (\u21d1e) x) :=\n  continuous_linear_equiv.bijective (mdifferentiable.mfderiv he hx)\n\ntheorem mfderiv_surjective {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.source (to_local_equiv e)) : function.surjective \u21d1(mfderiv I I' (\u21d1e) x) :=\n  continuous_linear_equiv.surjective (mdifferentiable.mfderiv he hx)\n\ntheorem range_mfderiv_eq_univ {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2208 local_equiv.source (to_local_equiv e)) : set.range \u21d1(mfderiv I I' (\u21d1e) x) = set.univ :=\n  function.surjective.range_eq (mfderiv_surjective he hx)\n\ntheorem trans {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c E H} {M : Type u_4} [topological_space M] [charted_space H M] {E' : Type u_5} [normed_group E'] [normed_space \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c E' H'} {M' : Type u_7} [topological_space M'] [charted_space H' M'] {E'' : Type u_8} [normed_group E''] [normed_space \ud835\udd5c E''] {H'' : Type u_9} [topological_space H''] {I'' : model_with_corners \ud835\udd5c 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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) \u2229 \u21d1(local_homeomorph.symm e) \u207b\u00b9' 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c (local_equiv.target (ext_chart_at I x) \u2229 \u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c E'] {H' : Type u_6} [topological_space H'] {I' : model_with_corners \ud835\udd5c 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 \u2192 M'} (hf : continuous_on f s) : unique_diff_on \ud835\udd5c\n  (local_equiv.target (ext_chart_at I x) \u2229\n    \u21d1(local_equiv.symm (ext_chart_at I x)) \u207b\u00b9' (s \u2229 f \u207b\u00b9' 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 {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \ud835\udd5c 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 \ud835\udd5c F))\n  (topological_fiber_bundle_core.proj (basic_smooth_bundle_core.to_topological_fiber_bundle_core Z) \u207b\u00b9' s) := sorry\n\ntheorem unique_mdiff_on.tangent_bundle_proj_preimage {\ud835\udd5c : Type u_1} [nondiscrete_normed_field \ud835\udd5c] {E : Type u_2} [normed_group E] [normed_space \ud835\udd5c E] {H : Type u_3} [topological_space H] {I : model_with_corners \ud835\udd5c 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 \u207b\u00b9' 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 {\ud835\udcd0 : Type*} [category \ud835\udcd0] [abelian \ud835\udcd0]\nvariables {A B C : \ud835\udcd0} (f : A \u27f6 B) (g : B \u27f6 C) (w : f \u226b g = 0)\n\nlemma homology.lift_desc (X Y Z : \ud835\udcd0) (f : X \u27f6 Y) (g : Y \u27f6 Z) (w)\n  (U : \ud835\udcd0) (e : _ \u27f6 U) (he : f \u226b e = 0) (V : \ud835\udcd0) (t : V \u27f6 _) (ht : t \u226b g = 0) :\n  homology.lift f g w (t \u226b cokernel.\u03c0 _) (by simp [ht]) \u226b\n  homology.desc' _ _ _ (kernel.\u03b9 _ \u226b e) (by simp [he]) =\n  t \u226b e :=\nbegin\n  let s := _, change s \u226b _ = _,\n  have hs : s = kernel.lift _ t ht \u226b homology.\u03c0' _ _ _,\n  { apply homology.hom_to_ext,\n    simp only [homology.lift_\u03b9, category.assoc, homology.\u03c0'_\u03b9, kernel.lift_\u03b9_assoc] },\n  simp [hs],\nend\n\nlemma homology.lift_desc' (X Y Z : \ud835\udcd0) (f : X \u27f6 Y) (g : Y \u27f6 Z) (w)\n  (U : \ud835\udcd0) (e : Y \u27f6 U) (he : f \u226b e = 0) (V : \ud835\udcd0) (t : V \u27f6 Y) (ht : t \u226b g = 0)\n  (u v) (hu : u = t \u226b cokernel.\u03c0 _) (hv : v = kernel.\u03b9 _ \u226b e) :\n  homology.lift f g w u (by simpa [hu]) \u226b homology.desc' _ _ _ v (by simpa [hv]) = t \u226b 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 \u2192 Type) \n  (\u03c1 : \u03a0 {X Y}, (X \u2192 Y \u2192 Prop) \u2192 (F X \u2192 F Y \u2192 Prop)) : Prop :=\n(symm : \u03a0 {X Y : Type} (R : X \u2192 Y \u2192 Prop) (x : F X) (y : F Y),\n  \u03c1 R x y \u2192 \u03c1 (swap R) y x)\n(trans : \u03a0 {X Y Z : Type} (R : X \u2192 Y \u2192 Prop) (R' : Y \u2192 Z \u2192 Prop) x y z,\n  \u03c1 R x y \u2192 \u03c1 R' y z \u2192 \u03c1 (\u03bb x z, \u2203 y, R x y \u2227 R' y z) x z)\n(desc : \u03a0 {X : Type} (R : setoid X) (s) (h : \u03c1 R.r s s),\n  \u2203! (s' : F (quotient R)), \u03c1 (\u03bb (x : X) (y : quotient R), quotient.mk x = y) s s')\n\ndef functional {X Y : Type} (R : X \u2192 Y \u2192 Prop) : Prop :=\n\u2200 x, \u2203! y, R x y\n\nlemma functional_iff_exists_function {X Y : Type} (R : X \u2192 Y \u2192 Prop) :\n  functional R \u2194 \u2203 f : X \u2192 Y, R = (\u03bb 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 \u27e8f, rfl\u27e9,\n    intro x,\n    use f x,\n    simp } \nend \n\ndef is_equivalence {X Y : Type} (R : X \u2192 Y \u2192 Prop) :=\nfunctional R \u2227 functional (function.swap R)\n\nlemma is_equivalence_iff_exists_equiv {X Y : Type} (R : X \u2192 Y \u2192 Prop) :\n  is_equivalence R \u2194 \u2203 f : X \u2243 Y, R = (\u03bb x y, f x = y) :=\nbegin\n  split,\n  { intro h,\n    rcases (functional_iff_exists_function _).1 h.1 with \u27e8f, rfl\u27e9,\n    rcases (functional_iff_exists_function _).1 h.2 with \u27e8g, hg\u27e9,\n    simp only [function.funext_iff, function.swap, eq_iff_iff] at hg,\n    refine \u27e8\u27e8f, g, \u03bb x, _, \u03bb y, _\u27e9, _\u27e9,\n    { rw \u2190 hg },\n    { rw hg },\n    { refl } },\n  { rintros \u27e8f, rfl\u27e9,\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 \u03c1) (hsuit : suitable F \u03c1) {X Y : Type}\n  (R : X \u2192 Y \u2192 Prop) (h : is_equivalence R) : functional (\u03c1 R) :=\nbegin\n  intro x,\n\n\nend\n\n-- \u03bb X, X \u2192 X does not map reflexive relations to reflexive relations.\nexample {X Y : Type} (f : X \u2192 Y) (hf : surjective f) :\n  functional (\u03bb (a : X \u2192 X) (b : Y \u2192 Y), \u2200 x, f (a x) = b (f x)) :=\nbegin\n  intro a,\n  have : (\u03bb (a b : X \u2192 X), \u2200 x y, f x = f y \u2192 f (a x) = f (b y)) a a,\n  { simp, },\n  dsimp only,\n  use f \u2218 a \u2218 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 \u27e8x, rfl\u27e9,\n    rw \u2190 hb,\n     }\n\nend\n\nlemma alt_def (F \u03c1) (hsuit : suitable F \u03c1) \n  {X Y : Type} (f : X \u2192 Y) (hf : surjective f)\n  (hrefl : reflexive (\u03c1 (setoid.ker f).r)) : \n  functional (\u03c1 (\u03bb x y, f x = y)) :=\nlet R : setoid X := setoid.ker f in\n\u03bb x, begin\n  cases hsuit.desc R x (hrefl x) with y hy,\n  dsimp at\n\nend\n\n \n\nexample (F \u03c1) (hsuit : suitable F \u03c1) {X Y : Type}\n  (R : X \u2192 Y \u2192 Prop) (h : square R) : square (\u03c1 R) :=\nbegin\n  intros x\u2081 x\u2082 y\u2081 y\u2082 h\u2081 h\u2082 h\u2083,\n  have := hsuit.trans R (swap R) _ _ _ h\u2081 (hsuit.symm _ _ _ h\u2082),\n  have := hsuit.trans _ _ _ _ _ this h\u2083,\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 \u27e8x', \u27e8y', hy\u27e9, hx'y\u27e9,\n    exact h _ _ _ _ hy.1 hy.2 hx'y }\nend \n\n-- structure positive (F : Type \u2192 Type)\n--   (\u03c1 : \u03a0 {X Y}, (X \u2192 Y \u2192 Prop) \u2192 (F X \u2192 F Y \u2192 Prop)) : Prop :=\n-- (refl : \u03a0 {X : Type}, \u03c1 (@eq X) = eq)\n-- (rev_trans : \u03a0 {X Y Z} (R : X \u2192 Y \u2192 Prop) (R' : Y \u2192 Z \u2192 Prop),\n--   \u03c1 R x z \u2192 \u03c1 (\u03bb x z, \u2203 y, R x y \u2227 R' y z) x z)\n\nexample : suitable (\u03bb X : Type, X \u2192 X) (\u03bb X Y R f g, \u2200 x y, R x y \u2192 R (f x) (g y)) :=\n{ symm := \u03bb X Y R x y h y x, h x y,\n  trans := \u03bb X Y Z R R' a b c h\u2081 h\u2082 x z, \n    begin\n      rintros \u27e8y, hxy, hyz\u27e9,\n      use b y,\n      split,\n      { exact h\u2081 _ _ hxy },\n      { exact h\u2082 _ _ hyz }\n    end,\n  desc := \u03bb X R a h, \n    \u27e8@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 \u2190 h x _ rfl,\n        refl } \n    end\u27e9 }\n\nexample {X Y : Type} (R : X \u2192 Y \u2192 Prop) (h : square R) : \n  square (\u03bb (f : (X \u2192 X) \u2192 X) (g : (Y \u2192 Y) \u2192 Y), \u2200 (a : X \u2192 X) (b : Y \u2192 Y),\n    (\u2200 x y, R x y \u2192 R (a x) (b y)) \u2192 R (f a) (g b)) :=\n\u03bb f\u2081 f\u2082 g\u2081 g\u2082 h\u2081 h\u2082 h\u2083 a b hab, begin\n  dsimp at *,\n  apply h,\n  apply h\u2081,\n  apply hab,\n  apply h\u2082,\n  apply hab,\n  apply h\u2083, \n  apply hab\nend\n\nexample : suitable (\u03bb X, (X \u2192 X) \u2192 X) \n  (\u03bb X Y R f g, \u2200 (a : X \u2192 X) (b : Y \u2192 Y), (\u2200 x y, R x y \u2192 R (a x) (b y)) \u2192 R (f a) (g b)) :=\n{ symm := \u03bb X Y R f g h\u2081 a b h\u2082, h\u2081 _ _ (\u03bb x y, h\u2082 y x),\n  trans := \u03bb X Y Z R R' f g i h\u2081 h\u2082 a b h\u2083, 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\u2093'. -/\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\u2082_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\u2093'. -/\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\u2082, \u2190 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\u2093'. -/\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 \u2194 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\u2093'. -/\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 \u2194 aeval x p = 0 := by\n  rw [aeval_algebra_map_apply, \u2190 (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\u2093.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\u2093.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\u2093'. -/\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 {\u03b1 : Type*}\n\n@[derive decidable_eq]\ninductive {u} lists' (\u03b1 : Type u) : bool \u2192 Type u\n| atom : \u03b1 \u2192 lists' ff\n| nil : lists' tt\n| cons' {b} : lists' b \u2192 lists' tt \u2192 lists' tt\n\ndef lists (\u03b1 : Type*) := \u03a3 b, lists' \u03b1 b\n\nnamespace lists'\n\ninstance [inhabited \u03b1] : \u2200 b, inhabited (lists' \u03b1 b)\n| tt := \u27e8nil\u27e9\n| ff := \u27e8atom (default _)\u27e9\n\ndef cons : lists \u03b1 \u2192 lists' \u03b1 tt \u2192 lists' \u03b1 tt\n| \u27e8b, a\u27e9 l := cons' a l\n\n@[simp] def to_list : \u2200 {b}, lists' \u03b1 b \u2192 list (lists \u03b1)\n| _ (atom a)    := []\n| _ nil         := []\n| _ (cons' a l) := \u27e8_, a\u27e9 :: l.to_list\n\n@[simp] theorem to_list_cons (a : lists \u03b1) (l) :\n  to_list (cons a l) = a :: l.to_list :=\nby cases a; simp [cons]\n\n@[simp] def of_list : list (lists \u03b1) \u2192 lists' \u03b1 tt\n| []       := nil\n| (a :: l) := cons a (of_list l)\n\n@[simp] theorem to_of_list (l : list (lists \u03b1)) : to_list (of_list l) = l :=\nby induction l; simp *\n\n@[simp] theorem of_to_list : \u2200 (l : lists' \u03b1 tt), of_list (to_list l) = l :=\nsuffices \u2200 b (h : tt = b) (l : lists' \u03b1 b),\n  let l' : lists' \u03b1 tt := by rw h; exact l in\n  of_list (to_list l') = l', from this _ rfl,\n\u03bb b h l, begin\n  induction l, {cases h}, {exact rfl},\n  case lists'.cons' : b a l IH\u2081 IH\u2082 {\n    intro, change l' with cons' a l,\n    simpa [cons] using IH\u2082 rfl }\nend\n\nend lists'\n\nmutual inductive lists.equiv, lists'.subset\nwith lists.equiv : lists \u03b1 \u2192 lists \u03b1 \u2192 Prop\n| refl (l) : lists.equiv l l\n| antisymm {l\u2081 l\u2082 : lists' \u03b1 tt} :\n  lists'.subset l\u2081 l\u2082 \u2192 lists'.subset l\u2082 l\u2081 \u2192 lists.equiv \u27e8_, l\u2081\u27e9 \u27e8_, l\u2082\u27e9\nwith lists'.subset : lists' \u03b1 tt \u2192 lists' \u03b1 tt \u2192 Prop\n| nil {l} : lists'.subset lists'.nil l\n| cons {a a' l l'} : lists.equiv a a' \u2192 a' \u2208 lists'.to_list l' \u2192\n  lists'.subset l l' \u2192 lists'.subset (lists'.cons a l) l'\nlocal infix ~ := lists.equiv\n\nnamespace lists'\n\ninstance : has_subset (lists' \u03b1 tt) := \u27e8lists'.subset\u27e9\n\ninstance {b} : has_mem (lists \u03b1) (lists' \u03b1 b) :=\n\u27e8\u03bb a l, \u2203 a' \u2208 l.to_list, a ~ a'\u27e9\n\ntheorem mem_def {b a} {l : lists' \u03b1 b} :\n  a \u2208 l \u2194 \u2203 a' \u2208 l.to_list, a ~ a' := iff.rfl\n\n@[simp] theorem mem_cons {a y l} : a \u2208 @cons \u03b1 y l \u2194 a ~ y \u2228 a \u2208 l :=\nby simp [mem_def, or_and_distrib_right, exists_or_distrib]\n\ntheorem cons_subset {a} {l\u2081 l\u2082 : lists' \u03b1 tt} :\n  lists'.cons a l\u2081 \u2286 l\u2082 \u2194 a \u2208 l\u2082 \u2227 l\u2081 \u2286 l\u2082 :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb \u27e8\u27e8a', m, e\u27e9, s\u27e9, subset.cons e m s\u27e9,\n  generalize_hyp h' : lists'.cons a l\u2081 = l\u2081' 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 \u27e8\u27e8_, m, e\u27e9, s\u27e9\nend\n\ntheorem of_list_subset {l\u2081 l\u2082 : list (lists \u03b1)} (h : l\u2081 \u2286 l\u2082) :\n  lists'.of_list l\u2081 \u2286 lists'.of_list l\u2082 :=\nbegin\n  induction l\u2081, {exact subset.nil},\n  refine subset.cons (lists.equiv.refl _) _ (l\u2081_ih (list.subset_of_cons_subset h)),\n  simp at h, simp [h]\nend\n\n@[refl] theorem subset.refl {l : lists' \u03b1 tt} : l \u2286 l :=\nby rw \u2190 lists'.of_to_list l; exact\n   of_list_subset (list.subset.refl _)\n\ntheorem subset_nil {l : lists' \u03b1 tt} :\n  l \u2286 lists'.nil \u2192 l = lists'.nil :=\nbegin\n  rw \u2190 of_to_list l,\n  induction to_list l; intro h, {refl},\n  rcases cons_subset.1 h with \u27e8\u27e8_, \u27e8\u27e9, _\u27e9, _\u27e9\nend\n\ntheorem mem_of_subset' {a} {l\u2081 l\u2082 : lists' \u03b1 tt}\n  (s : l\u2081 \u2286 l\u2082) (h : a \u2208 l\u2081.to_list) : a \u2208 l\u2082 :=\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 [\u27e8_, m, e\u27e9, IH h]\nend\n\ntheorem subset_def {l\u2081 l\u2082 : lists' \u03b1 tt} :\n  l\u2081 \u2286 l\u2082 \u2194 \u2200 a \u2208 l\u2081.to_list, a \u2208 l\u2082 :=\n\u27e8\u03bb H a, mem_of_subset' H, \u03bb H, begin\n  rw \u2190 of_to_list l\u2081,\n  revert H, induction to_list l\u2081; intro,\n  { exact subset.nil },\n  { simp at H, exact cons_subset.2 \u27e8H.1, ih H.2\u27e9 }\nend\u27e9\n\nend lists'\n\nnamespace lists\n\n@[pattern] def atom (a : \u03b1) : lists \u03b1 := \u27e8_, lists'.atom a\u27e9\n\n@[pattern] def of' (l : lists' \u03b1 tt) : lists \u03b1 := \u27e8_, l\u27e9\n\n@[simp] def to_list : lists \u03b1 \u2192 list (lists \u03b1)\n| \u27e8b, l\u27e9 := l.to_list\n\ndef is_list (l : lists \u03b1) : Prop := l.1\n\ndef of_list (l : list (lists \u03b1)) : lists \u03b1 := of' (lists'.of_list l)\n\ntheorem is_list_to_list (l : list (lists \u03b1)) : is_list (of_list l) :=\neq.refl _\n\ntheorem to_of_list (l : list (lists \u03b1)) : to_list (of_list l) = l :=\nby simp [of_list, of']\n\ntheorem of_to_list : \u2200 {l : lists \u03b1}, is_list l \u2192 of_list (to_list l) = l\n| \u27e8tt, l\u27e9 _ := by simp [of_list, of']\n\ninstance : inhabited (lists \u03b1) :=\n\u27e8of' lists'.nil\u27e9\n\ninstance [decidable_eq \u03b1] : decidable_eq (lists \u03b1) :=\nby unfold lists; apply_instance\n\ninstance [has_sizeof \u03b1] : has_sizeof (lists \u03b1) :=\nby unfold lists; apply_instance\n\ndef induction_mut (C : lists \u03b1 \u2192 Sort*) (D : lists' \u03b1 tt \u2192 Sort*)\n  (C0 : \u2200 a, C (atom a)) (C1 : \u2200 l, D l \u2192 C (of' l))\n  (D0 : D lists'.nil) (D1 : \u2200 a l, C a \u2192 D l \u2192 D (lists'.cons a l)) :\n  pprod (\u2200 l, C l) (\u2200 l, D l) :=\nbegin\n  suffices : \u2200 {b} (l : lists' \u03b1 b),\n    pprod (C \u27e8_, l\u27e9) (match b, l with\n    | tt, l := D l\n    | ff, l := punit\n    end),\n  { exact \u27e8\u03bb \u27e8b, l\u27e9, (this _).1, \u03bb l, (this l).2\u27e9 },\n  intros, induction l with a b a l IH\u2081 IH\u2082,\n  { exact \u27e8C0 _, \u27e8\u27e9\u27e9 },\n  { exact \u27e8C1 _ D0, D0\u27e9 },\n  { suffices, {exact \u27e8C1 _ this, this\u27e9},\n    exact D1 \u27e8_, _\u27e9 _ IH\u2081.1 IH\u2082.2 }\nend\n\ndef mem (a : lists \u03b1) : lists \u03b1 \u2192 Prop\n| \u27e8ff, l\u27e9 := false\n| \u27e8tt, l\u27e9 := a \u2208 l\n\ninstance : has_mem (lists \u03b1) (lists \u03b1) := \u27e8mem\u27e9\n\ntheorem is_list_of_mem {a : lists \u03b1} : \u2200 {l : lists \u03b1}, a \u2208 l \u2192 is_list l\n| \u27e8_, lists'.nil\u27e9       _ := rfl\n| \u27e8_, lists'.cons' _ _\u27e9 _ := rfl\n\ntheorem equiv.antisymm_iff {l\u2081 l\u2082 : lists' \u03b1 tt} :\n  of' l\u2081 ~ of' l\u2082 \u2194 l\u2081 \u2286 l\u2082 \u2227 l\u2082 \u2286 l\u2081 :=\nbegin\n  refine \u27e8\u03bb h, _, \u03bb \u27e8h\u2081, h\u2082\u27e9, equiv.antisymm h\u2081 h\u2082\u27e9,\n  cases h with _ _ _ h\u2081 h\u2082,\n  { simp [lists'.subset.refl] }, { exact \u27e8h\u2081, h\u2082\u27e9 }\nend\n\nattribute [refl] equiv.refl\n\ntheorem equiv_atom {a} {l : lists \u03b1} : atom a ~ l \u2194 atom a = l :=\n\u27e8\u03bb h, by cases h; refl, \u03bb h, h \u25b8 equiv.refl _\u27e9\n\ntheorem equiv.symm {l\u2081 l\u2082 : lists \u03b1} (h : l\u2081 ~ l\u2082) : l\u2082 ~ l\u2081 :=\nby cases h with _ _ _ h\u2081 h\u2082; [refl, exact equiv.antisymm h\u2082 h\u2081]\n\ntheorem equiv.trans : \u2200 {l\u2081 l\u2082 l\u2083 : lists \u03b1}, l\u2081 ~ l\u2082 \u2192 l\u2082 ~ l\u2083 \u2192 l\u2081 ~ l\u2083 :=\nbegin\n  let trans := \u03bb (l\u2081 : lists \u03b1), \u2200 \u2983l\u2082 l\u2083\u2984, l\u2081 ~ l\u2082 \u2192 l\u2082 ~ l\u2083 \u2192 l\u2081 ~ l\u2083,\n  suffices : pprod (\u2200 l\u2081, trans l\u2081)\n    (\u2200 (l : lists' \u03b1 tt) (l' \u2208 l.to_list), trans l'), {exact this.1},\n  apply induction_mut,\n  { intros a l\u2082 l\u2083 h\u2081 h\u2082,\n    rwa \u2190 equiv_atom.1 h\u2081 at h\u2082 },\n  { intros l\u2081 IH l\u2082 l\u2083 h\u2081 h\u2082,\n    cases h\u2081 with _ _ l\u2082, {exact h\u2082},\n    cases h\u2082 with _ _ l\u2083, {exact h\u2081},\n    cases equiv.antisymm_iff.1 h\u2081 with hl\u2081 hr\u2081,\n    cases equiv.antisymm_iff.1 h\u2082 with hl\u2082 hr\u2082,\n    apply equiv.antisymm_iff.2; split; apply lists'.subset_def.2,\n    { intros a\u2081 m\u2081,\n      rcases lists'.mem_of_subset' hl\u2081 m\u2081 with \u27e8a\u2082, m\u2082, e\u2081\u2082\u27e9,\n      rcases lists'.mem_of_subset' hl\u2082 m\u2082 with \u27e8a\u2083, m\u2083, e\u2082\u2083\u27e9,\n      exact \u27e8a\u2083, m\u2083, IH _ m\u2081 e\u2081\u2082 e\u2082\u2083\u27e9 },\n    { intros a\u2083 m\u2083,\n      rcases lists'.mem_of_subset' hr\u2082 m\u2083 with \u27e8a\u2082, m\u2082, e\u2083\u2082\u27e9,\n      rcases lists'.mem_of_subset' hr\u2081 m\u2082 with \u27e8a\u2081, m\u2081, e\u2082\u2081\u27e9,\n      exact \u27e8a\u2081, m\u2081, (IH _ m\u2081 e\u2082\u2081.symm e\u2083\u2082.symm).symm\u27e9 } },\n  { rintro _ \u27e8\u27e9 },\n  { intros a l IH\u2081 IH\u2082, simpa [IH\u2081] using IH\u2082 }\nend\n\ninstance : setoid (lists \u03b1) :=\n\u27e8(~), equiv.refl, @equiv.symm _, @equiv.trans _\u27e9\n\nsection decidable\n\n@[simp] def equiv.decidable_meas :\n  (psum (\u03a3' (l\u2081 : lists \u03b1), lists \u03b1) $\n   psum (\u03a3' (l\u2081 : lists' \u03b1 tt), lists' \u03b1 tt)\n   \u03a3' (a : lists \u03b1), lists' \u03b1 tt) \u2192 \u2115\n| (psum.inl \u27e8l\u2081, l\u2082\u27e9) := sizeof l\u2081 + sizeof l\u2082\n| (psum.inr $ psum.inl \u27e8l\u2081, l\u2082\u27e9) := sizeof l\u2081 + sizeof l\u2082\n| (psum.inr $ psum.inr \u27e8l\u2081, l\u2082\u27e9) := sizeof l\u2081 + sizeof l\u2082\n\nopen well_founded_tactics\n\ntheorem sizeof_pos {b} (l : lists' \u03b1 b) : 0 < sizeof l :=\nby cases l; unfold_sizeof; trivial_nat_lt\n\ntheorem lt_sizeof_cons' {b} (a : lists' \u03b1 b) (l) :\n  sizeof (\u27e8b, a\u27e9 : lists \u03b1) < sizeof (lists'.cons' a l) :=\nby {unfold_sizeof, apply sizeof_pos}\n\n@[instance] mutual def equiv.decidable, subset.decidable, mem.decidable [decidable_eq \u03b1]\nwith equiv.decidable : \u2200 l\u2081 l\u2082 : lists \u03b1, decidable (l\u2081 ~ l\u2082)\n| \u27e8ff, l\u2081\u27e9 \u27e8ff, l\u2082\u27e9 := decidable_of_iff' (l\u2081 = l\u2082) $\n  by cases l\u2081; refine equiv_atom.trans (by simp [atom])\n| \u27e8ff, l\u2081\u27e9 \u27e8tt, l\u2082\u27e9 := is_false $ by rintro \u27e8\u27e9\n| \u27e8tt, l\u2081\u27e9 \u27e8ff, l\u2082\u27e9 := is_false $ by rintro \u27e8\u27e9\n| \u27e8tt, l\u2081\u27e9 \u27e8tt, l\u2082\u27e9 := begin\n  haveI :=\n    have sizeof l\u2081 + sizeof l\u2082 <\n         sizeof (\u27e8tt, l\u2081\u27e9 : lists \u03b1) + sizeof (\u27e8tt, l\u2082\u27e9 : lists \u03b1),\n    by default_dec_tac,\n    subset.decidable l\u2081 l\u2082,\n  haveI :=\n    have sizeof l\u2082 + sizeof l\u2081 <\n         sizeof (\u27e8tt, l\u2081\u27e9 : lists \u03b1) + sizeof (\u27e8tt, l\u2082\u27e9 : lists \u03b1),\n    by default_dec_tac,\n    subset.decidable l\u2082 l\u2081,\n  exact decidable_of_iff' _ equiv.antisymm_iff,\nend\nwith subset.decidable : \u2200 l\u2081 l\u2082 : lists' \u03b1 tt, decidable (l\u2081 \u2286 l\u2082)\n| lists'.nil l\u2082 := is_true subset.nil\n| (@lists'.cons' _ b a l\u2081) l\u2082 := begin\n  haveI :=\n    have sizeof (\u27e8b, a\u27e9 : lists \u03b1) + sizeof l\u2082 <\n         sizeof (lists'.cons' a l\u2081) + sizeof l\u2082,\n    from add_lt_add_right (lt_sizeof_cons' _ _) _,\n    mem.decidable \u27e8b, a\u27e9 l\u2082,\n  haveI :=\n    have sizeof l\u2081 + sizeof l\u2082 <\n         sizeof (lists'.cons' a l\u2081) + sizeof l\u2082,\n    by default_dec_tac,\n    subset.decidable l\u2081 l\u2082,\n  exact decidable_of_iff' _ (@lists'.cons_subset _ \u27e8_, _\u27e9 _ _)\nend\nwith mem.decidable : \u2200 (a : lists \u03b1) (l : lists' \u03b1 tt), decidable (a \u2208 l)\n| a lists'.nil := is_false $ by rintro \u27e8_, \u27e8\u27e9, _\u27e9\n| a (lists'.cons' b l\u2082) := begin\n  haveI :=\n    have sizeof a + sizeof (\u27e8_, b\u27e9 : lists \u03b1) <\n         sizeof a + sizeof (lists'.cons' b l\u2082),\n    from add_lt_add_left (lt_sizeof_cons' _ _) _,\n    equiv.decidable a \u27e8_, b\u27e9,\n  haveI :=\n    have sizeof a + sizeof l\u2082 <\n         sizeof a + sizeof (lists'.cons' b l\u2082),\n    by default_dec_tac,\n    mem.decidable a l\u2082,\n  refine decidable_of_iff' (a ~ \u27e8_, b\u27e9 \u2228 a \u2208 l\u2082) _,\n  rw \u2190 lists'.mem_cons, refl\nend\nusing_well_founded {\n  rel_tac := \u03bb _ _, `[exact \u27e8_, measure_wf equiv.decidable_meas\u27e9],\n  dec_tac := `[assumption] }\n\nend decidable\n\nend lists\n\nnamespace lists'\n\ntheorem mem_equiv_left {l : lists' \u03b1 tt} :\n  \u2200 {a a'}, a ~ a' \u2192 (a \u2208 l \u2194 a' \u2208 l) :=\nsuffices \u2200 {a a'}, a ~ a' \u2192 a \u2208 l \u2192 a' \u2208 l,\n  from \u03bb a a' e, \u27e8this e, this e.symm\u27e9,\n\u03bb a\u2081 a\u2082 e\u2081 \u27e8a\u2083, m\u2083, e\u2082\u27e9, \u27e8_, m\u2083, e\u2081.symm.trans e\u2082\u27e9\n\ntheorem mem_of_subset {a} {l\u2081 l\u2082 : lists' \u03b1 tt}\n  (s : l\u2081 \u2286 l\u2082) : a \u2208 l\u2081 \u2192 a \u2208 l\u2082 | \u27e8a', m, e\u27e9 :=\n(mem_equiv_left e).2 (mem_of_subset' s m)\n\ntheorem subset.trans {l\u2081 l\u2082 l\u2083 : lists' \u03b1 tt}\n  (h\u2081 : l\u2081 \u2286 l\u2082) (h\u2082 : l\u2082 \u2286 l\u2083) : l\u2081 \u2286 l\u2083 :=\nsubset_def.2 $ \u03bb a\u2081 m\u2081, mem_of_subset h\u2082 $ mem_of_subset' h\u2081 m\u2081\n\nend lists'\n\ndef finsets (\u03b1 : Type*) := quotient (@lists.setoid \u03b1)\n\nnamespace finsets\n\ninstance : has_emptyc (finsets \u03b1) := \u27e8\u27e6lists.of' lists'.nil\u27e7\u27e9\n\ninstance : inhabited (finsets \u03b1) := \u27e8\u2205\u27e9\n\ninstance [decidable_eq \u03b1] : decidable_eq (finsets \u03b1) :=\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\u00f6lzl, Mario Carneiro\n\n-- QUESTION: can make the first argument in \u2200 x \u2208 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 {\u03b1 : Type u} : complete_lattice (set \u03b1) :=\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 \u03b1)) => set_of fun (a : \u03b1) => \u2203 (t : set \u03b1), \u2203 (H : t \u2208 s), a \u2208 t)\n    (fun (s : set (set \u03b1)) => set_of fun (a : \u03b1) => \u2200 (t : set \u03b1), t \u2208 s \u2192 a \u2208 t) sorry sorry sorry sorry\n\n/-- Image is monotone. See `set.image_image` for the statement in terms of `\u2286`. -/\ntheorem monotone_image {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} : monotone (image f) :=\n  fun (s t : set \u03b1) (h : s \u2286 t) => image_subset f h\n\ntheorem monotone_inter {\u03b1 : Type u} {\u03b2 : Type v} [preorder \u03b2] {f : \u03b2 \u2192 set \u03b1} {g : \u03b2 \u2192 set \u03b1} (hf : monotone f) (hg : monotone g) : monotone fun (x : \u03b2) => f x \u2229 g x :=\n  fun (b\u2081 b\u2082 : \u03b2) (h : b\u2081 \u2264 b\u2082) => inter_subset_inter (hf h) (hg h)\n\ntheorem monotone_union {\u03b1 : Type u} {\u03b2 : Type v} [preorder \u03b2] {f : \u03b2 \u2192 set \u03b1} {g : \u03b2 \u2192 set \u03b1} (hf : monotone f) (hg : monotone g) : monotone fun (x : \u03b2) => f x \u222a g x :=\n  fun (b\u2081 b\u2082 : \u03b2) (h : b\u2081 \u2264 b\u2082) => union_subset_union (hf h) (hg h)\n\ntheorem monotone_set_of {\u03b1 : Type u} {\u03b2 : Type v} [preorder \u03b1] {p : \u03b1 \u2192 \u03b2 \u2192 Prop} (hp : \u2200 (b : \u03b2), monotone fun (a : \u03b1) => p a b) : monotone fun (a : \u03b1) => set_of fun (b : \u03b2) => p a b :=\n  fun (a a' : \u03b1) (h : a \u2264 a') (b : \u03b2) => hp b h\n\nprotected theorem image_preimage {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} : galois_connection (image f) (preimage f) :=\n  fun (a : set \u03b1) (b : set \u03b2) => image_subset_iff\n\n/-- `kern_image f s` is the set of `y` such that `f \u207b\u00b9 y \u2286 s` -/\ndef kern_image {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) : set \u03b2 :=\n  set_of fun (y : \u03b2) => \u2200 {x : \u03b1}, f x = y \u2192 x \u2208 s\n\nprotected theorem preimage_kern_image {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} : 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 {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) : set \u03b2 :=\n  supr s\n\n/-- Indexed intersection of a family of sets -/\ndef Inter {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) : set \u03b2 :=\n  infi s\n\n@[simp] theorem mem_Union {\u03b2 : Type v} {\u03b9 : Sort x} {x : \u03b2} {s : \u03b9 \u2192 set \u03b2} : x \u2208 Union s \u2194 \u2203 (i : \u03b9), x \u2208 s i := sorry\n\n/- alternative proof: dsimp [Union, supr, Sup]; simp -/\n\ntheorem set_of_exists {\u03b2 : Type v} {\u03b9 : Sort x} (p : \u03b9 \u2192 \u03b2 \u2192 Prop) : (set_of fun (x : \u03b2) => \u2203 (i : \u03b9), p i x) = Union fun (i : \u03b9) => set_of fun (x : \u03b2) => p i x :=\n  ext fun (i : \u03b2) => iff.symm mem_Union\n\n@[simp] theorem mem_Inter {\u03b2 : Type v} {\u03b9 : Sort x} {x : \u03b2} {s : \u03b9 \u2192 set \u03b2} : x \u2208 Inter s \u2194 \u2200 (i : \u03b9), x \u2208 s i := sorry\n\ntheorem set_of_forall {\u03b2 : Type v} {\u03b9 : Sort x} (p : \u03b9 \u2192 \u03b2 \u2192 Prop) : (set_of fun (x : \u03b2) => \u2200 (i : \u03b9), p i x) = Inter fun (i : \u03b9) => set_of fun (x : \u03b2) => p i x :=\n  ext fun (i : \u03b2) => iff.symm mem_Inter\n\n-- TODO: should be simpler when sets' order is based on lattices\n\ntheorem Union_subset {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b2} {t : set \u03b2} (h : \u2200 (i : \u03b9), s i \u2286 t) : (Union fun (i : \u03b9) => s i) \u2286 t :=\n  supr_le h\n\ntheorem Union_subset_iff {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b2} {t : set \u03b2} : (Union fun (i : \u03b9) => s i) \u2286 t \u2194 \u2200 (i : \u03b9), s i \u2286 t :=\n  { mp := fun (h : (Union fun (i : \u03b9) => s i) \u2286 t) (i : \u03b9) => subset.trans (le_supr s i) h, mpr := Union_subset }\n\ntheorem mem_Inter_of_mem {\u03b2 : Type v} {\u03b9 : Sort x} {x : \u03b2} {s : \u03b9 \u2192 set \u03b2} : (\u2200 (i : \u03b9), x \u2208 s i) \u2192 x \u2208 Inter fun (i : \u03b9) => s i :=\n  iff.mpr mem_Inter\n\n-- TODO: should be simpler when sets' order is based on lattices\n\ntheorem subset_Inter {\u03b2 : Type v} {\u03b9 : Sort x} {t : set \u03b2} {s : \u03b9 \u2192 set \u03b2} (h : \u2200 (i : \u03b9), t \u2286 s i) : t \u2286 Inter fun (i : \u03b9) => s i :=\n  le_infi h\n\ntheorem subset_Inter_iff {\u03b2 : Type v} {\u03b9 : Sort x} {t : set \u03b2} {s : \u03b9 \u2192 set \u03b2} : (t \u2286 Inter fun (i : \u03b9) => s i) \u2194 \u2200 (i : \u03b9), t \u2286 s i :=\n  le_infi_iff\n\ntheorem subset_Union {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) (i : \u03b9) : s i \u2286 Union fun (i : \u03b9) => 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 {\u03b2 : Type v} {\u03b9 : Sort x} {A : set \u03b2} {s : \u03b9 \u2192 set \u03b2} (i : \u03b9) (h : A \u2286 s i) : A \u2286 Union fun (i : \u03b9) => s i :=\n  subset.trans h (subset_Union s i)\n\ntheorem Inter_subset {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) (i : \u03b9) : (Inter fun (i : \u03b9) => s i) \u2286 s i :=\n  infi_le\n\ntheorem Inter_subset_of_subset {\u03b1 : Type u} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} {t : set \u03b1} (i : \u03b9) (h : s i \u2286 t) : (Inter fun (i : \u03b9) => s i) \u2286 t :=\n  subset.trans (Inter_subset s i) h\n\ntheorem Inter_subset_Inter {\u03b1 : Type u} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b1} (h : \u2200 (i : \u03b9), s i \u2286 t i) : (Inter fun (i : \u03b9) => s i) \u2286 Inter fun (i : \u03b9) => t i :=\n  subset_Inter fun (i : \u03b9) => Inter_subset_of_subset i (h i)\n\ntheorem Inter_subset_Inter2 {\u03b1 : Type u} {\u03b9 : Sort x} {\u03b9' : Sort y} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9' \u2192 set \u03b1} (h : \u2200 (j : \u03b9'), \u2203 (i : \u03b9), s i \u2286 t j) : (Inter fun (i : \u03b9) => s i) \u2286 Inter fun (j : \u03b9') => t j := sorry\n\ntheorem Inter_set_of {\u03b1 : Type u} {\u03b9 : Sort x} (P : \u03b9 \u2192 \u03b1 \u2192 Prop) : (Inter fun (i : \u03b9) => set_of fun (x : \u03b1) => P i x) = set_of fun (x : \u03b1) => \u2200 (i : \u03b9), P i x := sorry\n\ntheorem Union_const {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] (s : set \u03b2) : (Union fun (i : \u03b9) => s) = s := sorry\n\ntheorem Inter_const {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] (s : set \u03b2) : (Inter fun (i : \u03b9) => s) = s := sorry\n\n@[simp] theorem compl_Union {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) : (Union fun (i : \u03b9) => s i)\u1d9c = Inter fun (i : \u03b9) => s i\u1d9c := sorry\n\n-- classical -- complete_boolean_algebra\n\ntheorem compl_Inter {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) : (Inter fun (i : \u03b9) => s i)\u1d9c = Union fun (i : \u03b9) => s i\u1d9c := sorry\n\n-- classical -- complete_boolean_algebra\n\ntheorem Union_eq_comp_Inter_comp {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) : (Union fun (i : \u03b9) => s i) = ((Inter fun (i : \u03b9) => s i\u1d9c)\u1d9c) := sorry\n\n-- classical -- complete_boolean_algebra\n\ntheorem Inter_eq_comp_Union_comp {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) : (Inter fun (i : \u03b9) => s i) = ((Union fun (i : \u03b9) => s i\u1d9c)\u1d9c) := sorry\n\ntheorem inter_Union {\u03b2 : Type v} {\u03b9 : Sort x} (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (s \u2229 Union fun (i : \u03b9) => t i) = Union fun (i : \u03b9) => s \u2229 t i := sorry\n\ntheorem Union_inter {\u03b2 : Type v} {\u03b9 : Sort x} (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (Union fun (i : \u03b9) => t i) \u2229 s = Union fun (i : \u03b9) => t i \u2229 s := sorry\n\ntheorem Union_union_distrib {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (Union fun (i : \u03b9) => s i \u222a t i) = (Union fun (i : \u03b9) => s i) \u222a Union fun (i : \u03b9) => t i := sorry\n\ntheorem Inter_inter_distrib {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (Inter fun (i : \u03b9) => s i \u2229 t i) = (Inter fun (i : \u03b9) => s i) \u2229 Inter fun (i : \u03b9) => t i := sorry\n\ntheorem union_Union {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (s \u222a Union fun (i : \u03b9) => t i) = Union fun (i : \u03b9) => s \u222a t i := sorry\n\ntheorem Union_union {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (Union fun (i : \u03b9) => t i) \u222a s = Union fun (i : \u03b9) => t i \u222a s := sorry\n\ntheorem inter_Inter {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (s \u2229 Inter fun (i : \u03b9) => t i) = Inter fun (i : \u03b9) => s \u2229 t i := sorry\n\ntheorem Inter_inter {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (Inter fun (i : \u03b9) => t i) \u2229 s = Inter fun (i : \u03b9) => t i \u2229 s := sorry\n\n-- classical\n\ntheorem union_Inter {\u03b2 : Type v} {\u03b9 : Sort x} (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (s \u222a Inter fun (i : \u03b9) => t i) = Inter fun (i : \u03b9) => s \u222a t i := sorry\n\ntheorem Union_diff {\u03b2 : Type v} {\u03b9 : Sort x} (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (Union fun (i : \u03b9) => t i) \\ s = Union fun (i : \u03b9) => t i \\ s :=\n  Union_inter (fun (a : \u03b2) => a \u2208 s \u2192 False) fun (i : \u03b9) => t i\n\ntheorem diff_Union {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (s \\ Union fun (i : \u03b9) => t i) = Inter fun (i : \u03b9) => s \\ t i := sorry\n\ntheorem diff_Inter {\u03b2 : Type v} {\u03b9 : Sort x} (s : set \u03b2) (t : \u03b9 \u2192 set \u03b2) : (s \\ Inter fun (i : \u03b9) => t i) = Union fun (i : \u03b9) => s \\ t i := sorry\n\ntheorem directed_on_Union {\u03b1 : Type u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {\u03b9 : Sort v} {f : \u03b9 \u2192 set \u03b1} (hd : directed has_subset.subset f) (h : \u2200 (x : \u03b9), directed_on r (f x)) : directed_on r (Union fun (x : \u03b9) => f x) := sorry\n\ntheorem Union_inter_subset {\u03b9 : Sort u_1} {\u03b1 : Type u_2} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b1} : (Union fun (i : \u03b9) => s i \u2229 t i) \u2286 (Union fun (i : \u03b9) => s i) \u2229 Union fun (i : \u03b9) => t i := sorry\n\ntheorem Union_inter_of_monotone {\u03b9 : Type u_1} {\u03b1 : Type u_2} [semilattice_sup \u03b9] {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b1} (hs : monotone s) (ht : monotone t) : (Union fun (i : \u03b9) => s i \u2229 t i) = (Union fun (i : \u03b9) => s i) \u2229 Union fun (i : \u03b9) => t i := sorry\n\n/-- An equality version of this lemma is `Union_Inter_of_monotone` in `data.set.finite`. -/\ntheorem Union_Inter_subset {\u03b9 : Sort u_1} {\u03b9' : Sort u_2} {\u03b1 : Type u_3} {s : \u03b9 \u2192 \u03b9' \u2192 set \u03b1} : (Union fun (j : \u03b9') => Inter fun (i : \u03b9) => s i j) \u2286 Inter fun (i : \u03b9) => Union fun (j : \u03b9') => s i j := sorry\n\n/- bounded unions and intersections -/\n\ntheorem mem_bUnion_iff {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {y : \u03b2} : (y \u2208 Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t x) \u2194 \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), y \u2208 t x := sorry\n\ntheorem mem_bInter_iff {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {y : \u03b2} : (y \u2208 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t x) \u2194 \u2200 (x : \u03b1), x \u2208 s \u2192 y \u2208 t x := sorry\n\ntheorem mem_bUnion {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {x : \u03b1} {y : \u03b2} (xs : x \u2208 s) (ytx : y \u2208 t x) : y \u2208 Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t x := sorry\n\ntheorem mem_bInter {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {y : \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 y \u2208 t x) : y \u2208 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t x :=\n  eq.mpr (id (Eq.trans (propext mem_Inter) (forall_congr_eq fun (i : \u03b1) => propext mem_Inter))) h\n\ntheorem bUnion_subset {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : set \u03b2} {u : \u03b1 \u2192 set \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 u x \u2286 t) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => u x) \u2286 t :=\n  (fun (this : (supr fun (x : \u03b1) => supr fun (H : x \u2208 s) => u x) \u2264 t) => this) (supr_le fun (x : \u03b1) => supr_le (h x))\n\ntheorem subset_bInter {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : set \u03b2} {u : \u03b1 \u2192 set \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 t \u2286 u x) : t \u2286 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => u x :=\n  subset_Inter fun (x : \u03b1) => subset_Inter (h x)\n\ntheorem subset_bUnion_of_mem {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {u : \u03b1 \u2192 set \u03b2} {x : \u03b1} (xs : x \u2208 s) : u x \u2286 Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => u x :=\n  (fun (this : u x \u2264 supr fun (x : \u03b1) => supr fun (H : x \u2208 s) => u x) => this)\n    (le_supr_of_le x (le_supr (fun (xs : x \u2208 s) => u x) xs))\n\ntheorem bInter_subset_of_mem {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {x : \u03b1} (xs : x \u2208 s) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t x) \u2286 t x :=\n  (fun (this : (infi fun (x : \u03b1) => infi fun (H : x \u2208 s) => t x) \u2264 t x) => this)\n    (infi_le_of_le x (infi_le (fun (H : x \u2208 s) => t x) xs))\n\ntheorem bUnion_subset_bUnion_left {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {s' : set \u03b1} {t : \u03b1 \u2192 set \u03b2} (h : s \u2286 s') : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t x) \u2286 Union fun (x : \u03b1) => Union fun (H : x \u2208 s') => t x :=\n  bUnion_subset fun (x : \u03b1) (xs : x \u2208 s) => subset_bUnion_of_mem (h xs)\n\ntheorem bInter_subset_bInter_left {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {s' : set \u03b1} {t : \u03b1 \u2192 set \u03b2} (h : s' \u2286 s) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t x) \u2286 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s') => t x :=\n  subset_bInter fun (x : \u03b1) (xs : x \u2208 s') => bInter_subset_of_mem (h xs)\n\ntheorem bUnion_subset_bUnion_right {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t1 : \u03b1 \u2192 set \u03b2} {t2 : \u03b1 \u2192 set \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 t1 x \u2286 t2 x) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t1 x) \u2286 Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t2 x :=\n  bUnion_subset fun (x : \u03b1) (xs : x \u2208 s) => subset.trans (h x xs) (subset_bUnion_of_mem xs)\n\ntheorem bInter_subset_bInter_right {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t1 : \u03b1 \u2192 set \u03b2} {t2 : \u03b1 \u2192 set \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 t1 x \u2286 t2 x) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t1 x) \u2286 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t2 x :=\n  subset_bInter fun (x : \u03b1) (xs : x \u2208 s) => subset.trans (bInter_subset_of_mem xs) (h x xs)\n\ntheorem bUnion_subset_bUnion {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type u_1} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {s' : set \u03b3} {t' : \u03b3 \u2192 set \u03b2} (h : \u2200 (x : \u03b1) (H : x \u2208 s), \u2203 (y : \u03b3), \u2203 (H : y \u2208 s'), t x \u2286 t' y) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t x) \u2286 Union fun (y : \u03b3) => Union fun (H : y \u2208 s') => t' y := sorry\n\ntheorem bInter_mono' {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {s' : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {t' : \u03b1 \u2192 set \u03b2} (hs : s \u2286 s') (h : \u2200 (x : \u03b1), x \u2208 s \u2192 t x \u2286 t' x) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s') => t x) \u2286 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t' x := sorry\n\ntheorem bInter_mono {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {t' : \u03b1 \u2192 set \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 t x \u2286 t' x) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t x) \u2286 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t' x :=\n  bInter_mono' (subset.refl s) h\n\ntheorem bUnion_mono {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} {t' : \u03b1 \u2192 set \u03b2} (h : \u2200 (x : \u03b1), x \u2208 s \u2192 t x \u2286 t' x) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t x) \u2286 Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t' x :=\n  bUnion_subset_bUnion fun (x : \u03b1) (x_in : x \u2208 s) => Exists.intro x (Exists.intro x_in (h x x_in))\n\ntheorem bUnion_eq_Union {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : (x : \u03b1) \u2192 x \u2208 s \u2192 set \u03b2) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t x H) = Union fun (x : \u21a5s) => t (\u2191x) (subtype.property x) :=\n  supr_subtype'\n\ntheorem bInter_eq_Inter {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : (x : \u03b1) \u2192 x \u2208 s \u2192 set \u03b2) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t x H) = Inter fun (x : \u21a5s) => t (\u2191x) (subtype.property x) :=\n  infi_subtype'\n\ntheorem bInter_empty {\u03b1 : Type u} {\u03b2 : Type v} (u : \u03b1 \u2192 set \u03b2) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 \u2205) => u x) = univ :=\n  (fun (this : (infi fun (x : \u03b1) => infi fun (H : x \u2208 \u2205) => u x) = \u22a4) => this) infi_emptyset\n\ntheorem bInter_univ {\u03b1 : Type u} {\u03b2 : Type v} (u : \u03b1 \u2192 set \u03b2) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 univ) => u x) = Inter fun (x : \u03b1) => 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 {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) (s : \u03b1 \u2192 set \u03b2) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 singleton a) => s x) = s a := sorry\n\ntheorem bInter_union {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : set \u03b1) (u : \u03b1 \u2192 set \u03b2) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s \u222a t) => u x) =\n  (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => u x) \u2229 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 t) => u x := sorry\n\n-- TODO(Jeremy): simp [insert_eq, bInter_union] doesn't work\n\n@[simp] theorem bInter_insert {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) (s : set \u03b1) (t : \u03b1 \u2192 set \u03b2) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 insert a s) => t x) = t a \u2229 Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => t x := sorry\n\n-- TODO(Jeremy): another example of where an annotation is needed\n\ntheorem bInter_pair {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) (b : \u03b1) (s : \u03b1 \u2192 set \u03b2) : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 insert a (singleton b)) => s x) = s a \u2229 s b := sorry\n\ntheorem bUnion_empty {\u03b1 : Type u} {\u03b2 : Type v} (s : \u03b1 \u2192 set \u03b2) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 \u2205) => s x) = \u2205 :=\n  supr_emptyset\n\ntheorem bUnion_univ {\u03b1 : Type u} {\u03b2 : Type v} (s : \u03b1 \u2192 set \u03b2) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 univ) => s x) = Union fun (x : \u03b1) => s x :=\n  supr_univ\n\n@[simp] theorem bUnion_singleton {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) (s : \u03b1 \u2192 set \u03b2) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 singleton a) => s x) = s a :=\n  supr_singleton\n\n@[simp] theorem bUnion_of_singleton {\u03b1 : Type u} (s : set \u03b1) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => singleton x) = s := sorry\n\ntheorem bUnion_union {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : set \u03b1) (u : \u03b1 \u2192 set \u03b2) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s \u222a t) => u x) =\n  (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => u x) \u222a Union fun (x : \u03b1) => Union fun (H : x \u2208 t) => u x :=\n  supr_union\n\n@[simp] theorem Union_subtype {\u03b1 : Type u_1} {\u03b2 : Type u_2} (s : set \u03b1) (f : \u03b1 \u2192 set \u03b2) : (Union fun (i : \u21a5s) => f \u2191i) = Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => f i :=\n  Eq.symm (bUnion_eq_Union s fun (x : \u03b1) (_x : x \u2208 s) => f x)\n\n-- TODO(Jeremy): once again, simp doesn't do it alone.\n\n@[simp] theorem bUnion_insert {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) (s : set \u03b1) (t : \u03b1 \u2192 set \u03b2) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 insert a s) => t x) = t a \u222a Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t x := sorry\n\ntheorem bUnion_pair {\u03b1 : Type u} {\u03b2 : Type v} (a : \u03b1) (b : \u03b1) (s : \u03b1 \u2192 set \u03b2) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 insert a (singleton b)) => s x) = s a \u222a s b := sorry\n\n@[simp] theorem compl_bUnion {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : \u03b1 \u2192 set \u03b2) : (Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => t i)\u1d9c = Inter fun (i : \u03b1) => Inter fun (H : i \u2208 s) => t i\u1d9c := sorry\n\n-- classical -- complete_boolean_algebra\n\ntheorem compl_bInter {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : \u03b1 \u2192 set \u03b2) : (Inter fun (i : \u03b1) => Inter fun (H : i \u2208 s) => t i)\u1d9c = Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => t i\u1d9c := sorry\n\ntheorem inter_bUnion {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : \u03b1 \u2192 set \u03b2) (u : set \u03b2) : (u \u2229 Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => t i) = Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => u \u2229 t i := sorry\n\ntheorem bUnion_inter {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : \u03b1 \u2192 set \u03b2) (u : set \u03b2) : (Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => t i) \u2229 u = Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => t i \u2229 u := sorry\n\n/-- Intersection of a set of sets. -/\ndef sInter {\u03b1 : Type u} (S : set (set \u03b1)) : set \u03b1 :=\n  Inf S\n\nprefix:110 \"\u22c2\u2080\" => Mathlib.set.sInter\n\ntheorem mem_sUnion_of_mem {\u03b1 : Type u} {x : \u03b1} {t : set \u03b1} {S : set (set \u03b1)} (hx : x \u2208 t) (ht : t \u2208 S) : x \u2208 \u22c3\u2080S :=\n  Exists.intro t (Exists.intro ht hx)\n\ntheorem mem_sUnion {\u03b1 : Type u} {x : \u03b1} {S : set (set \u03b1)} : x \u2208 \u22c3\u2080S \u2194 \u2203 (t : set \u03b1), \u2203 (H : t \u2208 S), x \u2208 t :=\n  iff.rfl\n\n-- is this theorem really necessary?\n\ntheorem not_mem_of_not_mem_sUnion {\u03b1 : Type u} {x : \u03b1} {t : set \u03b1} {S : set (set \u03b1)} (hx : \u00acx \u2208 \u22c3\u2080S) (ht : t \u2208 S) : \u00acx \u2208 t :=\n  fun (h : x \u2208 t) => hx (Exists.intro t (Exists.intro ht h))\n\n@[simp] theorem mem_sInter {\u03b1 : Type u} {x : \u03b1} {S : set (set \u03b1)} : x \u2208 \u22c2\u2080S \u2194 \u2200 (t : set \u03b1), t \u2208 S \u2192 x \u2208 t :=\n  iff.rfl\n\ntheorem sInter_subset_of_mem {\u03b1 : Type u} {S : set (set \u03b1)} {t : set \u03b1} (tS : t \u2208 S) : \u22c2\u2080S \u2286 t :=\n  Inf_le tS\n\ntheorem subset_sUnion_of_mem {\u03b1 : Type u} {S : set (set \u03b1)} {t : set \u03b1} (tS : t \u2208 S) : t \u2286 \u22c3\u2080S :=\n  le_Sup tS\n\ntheorem subset_sUnion_of_subset {\u03b1 : Type u} {s : set \u03b1} (t : set (set \u03b1)) (u : set \u03b1) (h\u2081 : s \u2286 u) (h\u2082 : u \u2208 t) : s \u2286 \u22c3\u2080t :=\n  subset.trans h\u2081 (subset_sUnion_of_mem h\u2082)\n\ntheorem sUnion_subset {\u03b1 : Type u} {S : set (set \u03b1)} {t : set \u03b1} (h : \u2200 (t' : set \u03b1), t' \u2208 S \u2192 t' \u2286 t) : \u22c3\u2080S \u2286 t :=\n  Sup_le h\n\ntheorem sUnion_subset_iff {\u03b1 : Type u} {s : set (set \u03b1)} {t : set \u03b1} : \u22c3\u2080s \u2286 t \u2194 \u2200 (t' : set \u03b1), t' \u2208 s \u2192 t' \u2286 t :=\n  { mp := fun (h : \u22c3\u2080s \u2286 t) (t' : set \u03b1) (ht' : t' \u2208 s) => subset.trans (subset_sUnion_of_mem ht') h,\n    mpr := sUnion_subset }\n\ntheorem subset_sInter {\u03b1 : Type u} {S : set (set \u03b1)} {t : set \u03b1} (h : \u2200 (t' : set \u03b1), t' \u2208 S \u2192 t \u2286 t') : t \u2286 \u22c2\u2080S :=\n  le_Inf h\n\ntheorem sUnion_subset_sUnion {\u03b1 : Type u} {S : set (set \u03b1)} {T : set (set \u03b1)} (h : S \u2286 T) : \u22c3\u2080S \u2286 \u22c3\u2080T :=\n  sUnion_subset fun (s : set \u03b1) (hs : s \u2208 S) => subset_sUnion_of_mem (h hs)\n\ntheorem sInter_subset_sInter {\u03b1 : Type u} {S : set (set \u03b1)} {T : set (set \u03b1)} (h : S \u2286 T) : \u22c2\u2080T \u2286 \u22c2\u2080S :=\n  subset_sInter fun (s : set \u03b1) (hs : s \u2208 S) => sInter_subset_of_mem (h hs)\n\n@[simp] theorem sUnion_empty {\u03b1 : Type u} : \u22c3\u2080\u2205 = \u2205 :=\n  Sup_empty\n\n@[simp] theorem sInter_empty {\u03b1 : Type u} : \u22c2\u2080\u2205 = univ :=\n  Inf_empty\n\n@[simp] theorem sUnion_singleton {\u03b1 : Type u} (s : set \u03b1) : \u22c3\u2080singleton s = s :=\n  Sup_singleton\n\n@[simp] theorem sInter_singleton {\u03b1 : Type u} (s : set \u03b1) : \u22c2\u2080singleton s = s :=\n  Inf_singleton\n\n@[simp] theorem sUnion_eq_empty {\u03b1 : Type u} {S : set (set \u03b1)} : \u22c3\u2080S = \u2205 \u2194 \u2200 (s : set \u03b1), s \u2208 S \u2192 s = \u2205 :=\n  Sup_eq_bot\n\n@[simp] theorem sInter_eq_univ {\u03b1 : Type u} {S : set (set \u03b1)} : \u22c2\u2080S = univ \u2194 \u2200 (s : set \u03b1), s \u2208 S \u2192 s = univ :=\n  Inf_eq_top\n\n@[simp] theorem nonempty_sUnion {\u03b1 : Type u} {S : set (set \u03b1)} : set.nonempty (\u22c3\u2080S) \u2194 \u2203 (s : set \u03b1), \u2203 (H : s \u2208 S), set.nonempty s := sorry\n\ntheorem nonempty.of_sUnion {\u03b1 : Type u} {s : set (set \u03b1)} (h : set.nonempty (\u22c3\u2080s)) : set.nonempty s := sorry\n\ntheorem nonempty.of_sUnion_eq_univ {\u03b1 : Type u} [Nonempty \u03b1] {s : set (set \u03b1)} (h : \u22c3\u2080s = univ) : set.nonempty s :=\n  nonempty.of_sUnion (Eq.symm h \u25b8 univ_nonempty)\n\ntheorem sUnion_union {\u03b1 : Type u} (S : set (set \u03b1)) (T : set (set \u03b1)) : \u22c3\u2080(S \u222a T) = \u22c3\u2080S \u222a \u22c3\u2080T :=\n  Sup_union\n\ntheorem sInter_union {\u03b1 : Type u} (S : set (set \u03b1)) (T : set (set \u03b1)) : \u22c2\u2080(S \u222a T) = \u22c2\u2080S \u2229 \u22c2\u2080T :=\n  Inf_union\n\ntheorem sInter_Union {\u03b1 : Type u} {\u03b9 : Sort x} (s : \u03b9 \u2192 set (set \u03b1)) : (\u22c2\u2080Union fun (i : \u03b9) => s i) = Inter fun (i : \u03b9) => \u22c2\u2080s i := sorry\n\n@[simp] theorem sUnion_insert {\u03b1 : Type u} (s : set \u03b1) (T : set (set \u03b1)) : \u22c3\u2080insert s T = s \u222a \u22c3\u2080T :=\n  Sup_insert\n\n@[simp] theorem sInter_insert {\u03b1 : Type u} (s : set \u03b1) (T : set (set \u03b1)) : \u22c2\u2080insert s T = s \u2229 \u22c2\u2080T :=\n  Inf_insert\n\ntheorem sUnion_pair {\u03b1 : Type u} (s : set \u03b1) (t : set \u03b1) : \u22c3\u2080insert s (singleton t) = s \u222a t :=\n  Sup_pair\n\ntheorem sInter_pair {\u03b1 : Type u} (s : set \u03b1) (t : set \u03b1) : \u22c2\u2080insert s (singleton t) = s \u2229 t :=\n  Inf_pair\n\n@[simp] theorem sUnion_image {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 set \u03b2) (s : set \u03b1) : \u22c3\u2080(f '' s) = Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => f x :=\n  Sup_image\n\n@[simp] theorem sInter_image {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 set \u03b2) (s : set \u03b1) : \u22c2\u2080(f '' s) = Inter fun (x : \u03b1) => Inter fun (H : x \u2208 s) => f x :=\n  Inf_image\n\n@[simp] theorem sUnion_range {\u03b2 : Type v} {\u03b9 : Sort x} (f : \u03b9 \u2192 set \u03b2) : \u22c3\u2080range f = Union fun (x : \u03b9) => f x :=\n  rfl\n\n@[simp] theorem sInter_range {\u03b2 : Type v} {\u03b9 : Sort x} (f : \u03b9 \u2192 set \u03b2) : \u22c2\u2080range f = Inter fun (x : \u03b9) => f x :=\n  rfl\n\ntheorem Union_eq_univ_iff {\u03b1 : Type u} {\u03b9 : Sort x} {f : \u03b9 \u2192 set \u03b1} : (Union fun (i : \u03b9) => f i) = univ \u2194 \u2200 (x : \u03b1), \u2203 (i : \u03b9), x \u2208 f i := sorry\n\ntheorem bUnion_eq_univ_iff {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 set \u03b2} {s : set \u03b1} : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => f x) = univ \u2194 \u2200 (y : \u03b2), \u2203 (x : \u03b1), \u2203 (H : x \u2208 s), y \u2208 f x := sorry\n\ntheorem sUnion_eq_univ_iff {\u03b1 : Type u} {c : set (set \u03b1)} : \u22c3\u2080c = univ \u2194 \u2200 (a : \u03b1), \u2203 (b : set \u03b1), \u2203 (H : b \u2208 c), a \u2208 b := sorry\n\ntheorem compl_sUnion {\u03b1 : Type u} (S : set (set \u03b1)) : \u22c3\u2080S\u1d9c = \u22c2\u2080(compl '' S) := sorry\n\n-- classical\n\ntheorem sUnion_eq_compl_sInter_compl {\u03b1 : Type u} (S : set (set \u03b1)) : \u22c3\u2080S = (\u22c2\u2080(compl '' S)\u1d9c) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u22c3\u2080S = (\u22c2\u2080(compl '' S)\u1d9c))) (Eq.symm (compl_compl (\u22c3\u2080S)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u22c3\u2080S\u1d9c\u1d9c = (\u22c2\u2080(compl '' S)\u1d9c))) (compl_sUnion S))) (Eq.refl (\u22c2\u2080(compl '' S)\u1d9c)))\n\n-- classical\n\ntheorem compl_sInter {\u03b1 : Type u} (S : set (set \u03b1)) : \u22c2\u2080S\u1d9c = \u22c3\u2080(compl '' S) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u22c2\u2080S\u1d9c = \u22c3\u2080(compl '' S))) (sUnion_eq_compl_sInter_compl (compl '' S))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u22c2\u2080S\u1d9c = (\u22c2\u2080(compl '' (compl '' S))\u1d9c))) (compl_compl_image S))) (Eq.refl (\u22c2\u2080S\u1d9c)))\n\n-- classical\n\ntheorem sInter_eq_comp_sUnion_compl {\u03b1 : Type u} (S : set (set \u03b1)) : \u22c2\u2080S = (\u22c3\u2080(compl '' S)\u1d9c) :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (\u22c2\u2080S = (\u22c3\u2080(compl '' S)\u1d9c))) (Eq.symm (compl_compl (\u22c2\u2080S)))))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (\u22c2\u2080S\u1d9c\u1d9c = (\u22c3\u2080(compl '' S)\u1d9c))) (compl_sInter S))) (Eq.refl (\u22c3\u2080(compl '' S)\u1d9c)))\n\ntheorem inter_empty_of_inter_sUnion_empty {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {S : set (set \u03b1)} (hs : t \u2208 S) (h : s \u2229 \u22c3\u2080S = \u2205) : s \u2229 t = \u2205 :=\n  eq_empty_of_subset_empty\n    (eq.mpr (id (Eq._oldrec (Eq.refl (s \u2229 t \u2286 \u2205)) (Eq.symm h))) (inter_subset_inter_right s (subset_sUnion_of_mem hs)))\n\ntheorem range_sigma_eq_Union_range {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : \u03b1 \u2192 Type u_1} (f : sigma \u03b3 \u2192 \u03b2) : range f = Union fun (a : \u03b1) => range fun (b : \u03b3 a) => f (sigma.mk a b) := sorry\n\ntheorem Union_eq_range_sigma {\u03b1 : Type u} {\u03b2 : Type v} (s : \u03b1 \u2192 set \u03b2) : (Union fun (i : \u03b1) => s i) = range fun (a : sigma fun (i : \u03b1) => \u21a5(s i)) => \u2191(sigma.snd a) := sorry\n\ntheorem Union_image_preimage_sigma_mk_eq_self {\u03b9 : Type u_1} {\u03c3 : \u03b9 \u2192 Type u_2} (s : set (sigma \u03c3)) : (Union fun (i : \u03b9) => sigma.mk i '' (sigma.mk i \u207b\u00b9' s)) = s := sorry\n\ntheorem sUnion_mono {\u03b1 : Type u} {s : set (set \u03b1)} {t : set (set \u03b1)} (h : s \u2286 t) : \u22c3\u2080s \u2286 \u22c3\u2080t :=\n  sUnion_subset fun (t' : set \u03b1) (ht' : t' \u2208 s) => subset_sUnion_of_mem (h ht')\n\ntheorem Union_subset_Union {\u03b1 : Type u} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b1} (h : \u2200 (i : \u03b9), s i \u2286 t i) : (Union fun (i : \u03b9) => s i) \u2286 Union fun (i : \u03b9) => t i :=\n  supr_le_supr h\n\ntheorem Union_subset_Union2 {\u03b1 : Type u} {\u03b9 : Sort x} {\u03b9\u2082 : Sort u_1} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9\u2082 \u2192 set \u03b1} (h : \u2200 (i : \u03b9), \u2203 (j : \u03b9\u2082), s i \u2286 t j) : (Union fun (i : \u03b9) => s i) \u2286 Union fun (i : \u03b9\u2082) => t i :=\n  supr_le_supr2 h\n\ntheorem Union_subset_Union_const {\u03b1 : Type u} {\u03b9 : Sort x} {\u03b9\u2082 : Sort x} {s : set \u03b1} (h : \u03b9 \u2192 \u03b9\u2082) : (Union fun (i : \u03b9) => s) \u2286 Union fun (j : \u03b9\u2082) => s :=\n  supr_le_supr_const h\n\n@[simp] theorem Union_of_singleton (\u03b1 : Type u) : (Union fun (x : \u03b1) => singleton x) = univ := sorry\n\n@[simp] theorem Union_of_singleton_coe {\u03b1 : Type u} (s : set \u03b1) : (Union fun (i : \u21a5s) => singleton \u2191i) = s := sorry\n\ntheorem bUnion_subset_Union {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : \u03b1 \u2192 set \u03b2) : (Union fun (x : \u03b1) => Union fun (H : x \u2208 s) => t x) \u2286 Union fun (x : \u03b1) => t x :=\n  Union_subset_Union fun (i : \u03b1) => Union_subset fun (h : i \u2208 s) => subset.refl (t i)\n\ntheorem sUnion_eq_bUnion {\u03b1 : Type u} {s : set (set \u03b1)} : \u22c3\u2080s = Union fun (i : set \u03b1) => Union fun (h : i \u2208 s) => i := sorry\n\ntheorem sInter_eq_bInter {\u03b1 : Type u} {s : set (set \u03b1)} : \u22c2\u2080s = Inter fun (i : set \u03b1) => Inter fun (h : i \u2208 s) => i := sorry\n\ntheorem sUnion_eq_Union {\u03b1 : Type u} {s : set (set \u03b1)} : \u22c3\u2080s = Union fun (i : \u21a5s) => \u2191i := sorry\n\ntheorem sInter_eq_Inter {\u03b1 : Type u} {s : set (set \u03b1)} : \u22c2\u2080s = Inter fun (i : \u21a5s) => \u2191i := sorry\n\ntheorem union_eq_Union {\u03b1 : Type u} {s\u2081 : set \u03b1} {s\u2082 : set \u03b1} : s\u2081 \u222a s\u2082 = Union fun (b : Bool) => cond b s\u2081 s\u2082 := sorry\n\ntheorem inter_eq_Inter {\u03b1 : Type u} {s\u2081 : set \u03b1} {s\u2082 : set \u03b1} : s\u2081 \u2229 s\u2082 = Inter fun (b : Bool) => cond b s\u2081 s\u2082 := sorry\n\nprotected instance complete_boolean_algebra {\u03b1 : Type u} : complete_boolean_algebra (set \u03b1) :=\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 {\u03b1 : Type u} {S : set (set \u03b1)} {T : set (set \u03b1)} : \u22c2\u2080S \u222a \u22c2\u2080T = Inter fun (p : set \u03b1 \u00d7 set \u03b1) => Inter fun (H : p \u2208 set.prod S T) => prod.fst p \u222a prod.snd p :=\n  Inf_sup_Inf\n\ntheorem sUnion_inter_sUnion {\u03b1 : Type u} {s : set (set \u03b1)} {t : set (set \u03b1)} : \u22c3\u2080s \u2229 \u22c3\u2080t = Union fun (p : set \u03b1 \u00d7 set \u03b1) => Union fun (H : p \u2208 set.prod s t) => prod.fst p \u2229 prod.snd p :=\n  Sup_inf_Sup\n\n/-- If `S` is a set of sets, and each `s \u2208 S` can be represented as an intersection\nof sets `T s hs`, then `\u22c2\u2080 S` is the intersection of the union of all `T s hs`. -/\ntheorem sInter_bUnion {\u03b1 : Type u} {S : set (set \u03b1)} {T : (s : set \u03b1) \u2192 s \u2208 S \u2192 set (set \u03b1)} (hT : \u2200 (s : set \u03b1) (H : s \u2208 S), s = \u22c2\u2080T s H) : (\u22c2\u2080Union fun (s : set \u03b1) => Union fun (H : s \u2208 S) => T s H) = \u22c2\u2080S := sorry\n\n/-- If `S` is a set of sets, and each `s \u2208 S` can be represented as an union\nof sets `T s hs`, then `\u22c3\u2080 S` is the union of the union of all `T s hs`. -/\ntheorem sUnion_bUnion {\u03b1 : Type u} {S : set (set \u03b1)} {T : (s : set \u03b1) \u2192 s \u2208 S \u2192 set (set \u03b1)} (hT : \u2200 (s : set \u03b1) (H : s \u2208 S), s = \u22c3\u2080T s H) : (\u22c3\u2080Union fun (s : set \u03b1) => Union fun (H : s \u2208 S) => T s H) = \u22c3\u2080S := sorry\n\ntheorem Union_range_eq_sUnion {\u03b1 : Type u_1} {\u03b2 : Type u_2} (C : set (set \u03b1)) {f : (s : \u21a5C) \u2192 \u03b2 \u2192 \u21a5s} (hf : \u2200 (s : \u21a5C), function.surjective (f s)) : (Union fun (y : \u03b2) => range fun (s : \u21a5C) => subtype.val (f s y)) = \u22c3\u2080C := sorry\n\ntheorem Union_range_eq_Union {\u03b9 : Type u_1} {\u03b1 : Type u_2} {\u03b2 : Type u_3} (C : \u03b9 \u2192 set \u03b1) {f : (x : \u03b9) \u2192 \u03b2 \u2192 \u21a5(C x)} (hf : \u2200 (x : \u03b9), function.surjective (f x)) : (Union fun (y : \u03b2) => range fun (x : \u03b9) => subtype.val (f x y)) = Union fun (x : \u03b9) => C x := sorry\n\ntheorem union_distrib_Inter_right {\u03b1 : Type u} {\u03b9 : Type u_1} (s : \u03b9 \u2192 set \u03b1) (t : set \u03b1) : (Inter fun (i : \u03b9) => s i) \u222a t = Inter fun (i : \u03b9) => s i \u222a t := sorry\n\ntheorem union_distrib_Inter_left {\u03b1 : Type u} {\u03b9 : Type u_1} (s : \u03b9 \u2192 set \u03b1) (t : set \u03b1) : (t \u222a Inter fun (i : \u03b9) => s i) = Inter fun (i : \u03b9) => t \u222a s i := sorry\n\n/-!\n### `maps_to`\n-/\n\ntheorem maps_to_sUnion {\u03b1 : Type u} {\u03b2 : Type v} {S : set (set \u03b1)} {t : set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (s : set \u03b1), s \u2208 S \u2192 maps_to f s t) : maps_to f (\u22c3\u2080S) t := sorry\n\ntheorem maps_to_Union {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} {t : set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), maps_to f (s i) t) : maps_to f (Union fun (i : \u03b9) => s i) t :=\n  maps_to_sUnion (iff.mpr forall_range_iff H)\n\ntheorem maps_to_bUnion {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {p : \u03b9 \u2192 Prop} {s : (i : \u03b9) \u2192 p i \u2192 set \u03b1} {t : set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9) (hi : p i), maps_to f (s i hi) t) : maps_to f (Union fun (i : \u03b9) => Union fun (hi : p i) => s i hi) t :=\n  maps_to_Union fun (i : \u03b9) => maps_to_Union (H i)\n\ntheorem maps_to_Union_Union {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), maps_to f (s i) (t i)) : maps_to f (Union fun (i : \u03b9) => s i) (Union fun (i : \u03b9) => t i) :=\n  maps_to_Union fun (i : \u03b9) => maps_to.mono (subset.refl (s i)) (subset_Union t i) (H i)\n\ntheorem maps_to_bUnion_bUnion {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {p : \u03b9 \u2192 Prop} {s : (i : \u03b9) \u2192 p i \u2192 set \u03b1} {t : (i : \u03b9) \u2192 p i \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9) (hi : p i), maps_to f (s i hi) (t i hi)) : maps_to f (Union fun (i : \u03b9) => Union fun (hi : p i) => s i hi) (Union fun (i : \u03b9) => Union fun (hi : p i) => t i hi) :=\n  maps_to_Union_Union fun (i : \u03b9) => maps_to_Union_Union (H i)\n\ntheorem maps_to_sInter {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {T : set (set \u03b2)} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (t : set \u03b2), t \u2208 T \u2192 maps_to f s t) : maps_to f s (\u22c2\u2080T) :=\n  fun (x : \u03b1) (hx : x \u2208 s) (t : set \u03b2) (ht : t \u2208 T) => H t ht hx\n\ntheorem maps_to_Inter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : set \u03b1} {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), maps_to f s (t i)) : maps_to f s (Inter fun (i : \u03b9) => t i) :=\n  fun (x : \u03b1) (hx : x \u2208 s) => iff.mpr mem_Inter fun (i : \u03b9) => H i hx\n\ntheorem maps_to_bInter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {p : \u03b9 \u2192 Prop} {s : set \u03b1} {t : (i : \u03b9) \u2192 p i \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9) (hi : p i), maps_to f s (t i hi)) : maps_to f s (Inter fun (i : \u03b9) => Inter fun (hi : p i) => t i hi) :=\n  maps_to_Inter fun (i : \u03b9) => maps_to_Inter (H i)\n\ntheorem maps_to_Inter_Inter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), maps_to f (s i) (t i)) : maps_to f (Inter fun (i : \u03b9) => s i) (Inter fun (i : \u03b9) => t i) :=\n  maps_to_Inter fun (i : \u03b9) => maps_to.mono (Inter_subset s i) (subset.refl (t i)) (H i)\n\ntheorem maps_to_bInter_bInter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {p : \u03b9 \u2192 Prop} {s : (i : \u03b9) \u2192 p i \u2192 set \u03b1} {t : (i : \u03b9) \u2192 p i \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9) (hi : p i), maps_to f (s i hi) (t i hi)) : maps_to f (Inter fun (i : \u03b9) => Inter fun (hi : p i) => s i hi) (Inter fun (i : \u03b9) => Inter fun (hi : p i) => t i hi) :=\n  maps_to_Inter_Inter fun (i : \u03b9) => maps_to_Inter_Inter (H i)\n\ntheorem image_Inter_subset {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} (s : \u03b9 \u2192 set \u03b1) (f : \u03b1 \u2192 \u03b2) : (f '' Inter fun (i : \u03b9) => s i) \u2286 Inter fun (i : \u03b9) => f '' s i :=\n  maps_to.image_subset (maps_to_Inter_Inter fun (i : \u03b9) => maps_to_image f (s i))\n\ntheorem image_bInter_subset {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {p : \u03b9 \u2192 Prop} (s : (i : \u03b9) \u2192 p i \u2192 set \u03b1) (f : \u03b1 \u2192 \u03b2) : (f '' Inter fun (i : \u03b9) => Inter fun (hi : p i) => s i hi) \u2286 Inter fun (i : \u03b9) => Inter fun (hi : p i) => f '' s i hi :=\n  maps_to.image_subset (maps_to_bInter_bInter fun (i : \u03b9) (hi : p i) => maps_to_image f (s i hi))\n\ntheorem image_sInter_subset {\u03b1 : Type u} {\u03b2 : Type v} (S : set (set \u03b1)) (f : \u03b1 \u2192 \u03b2) : f '' \u22c2\u2080S \u2286 Inter fun (s : set \u03b1) => Inter fun (H : s \u2208 S) => f '' s :=\n  eq.mpr\n    (id (Eq._oldrec (Eq.refl (f '' \u22c2\u2080S \u2286 Inter fun (s : set \u03b1) => Inter fun (H : s \u2208 S) => f '' s)) sInter_eq_bInter))\n    (image_bInter_subset (fun (i : set \u03b1) (hi : i \u2208 S) => i) f)\n\n/-!\n### `inj_on`\n-/\n\ntheorem inj_on.image_Inter_eq {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] {s : \u03b9 \u2192 set \u03b1} {f : \u03b1 \u2192 \u03b2} (h : inj_on f (Union fun (i : \u03b9) => s i)) : (f '' Inter fun (i : \u03b9) => s i) = Inter fun (i : \u03b9) => f '' s i := sorry\n\ntheorem inj_on.image_bInter_eq {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {p : \u03b9 \u2192 Prop} {s : (i : \u03b9) \u2192 p i \u2192 set \u03b1} (hp : \u2203 (i : \u03b9), p i) {f : \u03b1 \u2192 \u03b2} (h : inj_on f (Union fun (i : \u03b9) => Union fun (hi : p i) => s i hi)) : (f '' Inter fun (i : \u03b9) => Inter fun (hi : p i) => s i hi) = Inter fun (i : \u03b9) => Inter fun (hi : p i) => f '' s i hi := sorry\n\ntheorem inj_on_Union_of_directed {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} (hs : directed has_subset.subset s) {f : \u03b1 \u2192 \u03b2} (hf : \u2200 (i : \u03b9), inj_on f (s i)) : inj_on f (Union fun (i : \u03b9) => s i) := sorry\n\n/-!\n### `surj_on`\n-/\n\ntheorem surj_on_sUnion {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {T : set (set \u03b2)} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (t : set \u03b2), t \u2208 T \u2192 surj_on f s t) : surj_on f s (\u22c3\u2080T) := sorry\n\ntheorem surj_on_Union {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : set \u03b1} {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), surj_on f s (t i)) : surj_on f s (Union fun (i : \u03b9) => t i) :=\n  surj_on_sUnion (iff.mpr forall_range_iff H)\n\ntheorem surj_on_Union_Union {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), surj_on f (s i) (t i)) : surj_on f (Union fun (i : \u03b9) => s i) (Union fun (i : \u03b9) => t i) :=\n  surj_on_Union fun (i : \u03b9) => surj_on.mono (subset_Union s i) (subset.refl (t i)) (H i)\n\ntheorem surj_on_bUnion {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {p : \u03b9 \u2192 Prop} {s : set \u03b1} {t : (i : \u03b9) \u2192 p i \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9) (hi : p i), surj_on f s (t i hi)) : surj_on f s (Union fun (i : \u03b9) => Union fun (hi : p i) => t i hi) :=\n  surj_on_Union fun (i : \u03b9) => surj_on_Union (H i)\n\ntheorem surj_on_bUnion_bUnion {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {p : \u03b9 \u2192 Prop} {s : (i : \u03b9) \u2192 p i \u2192 set \u03b1} {t : (i : \u03b9) \u2192 p i \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9) (hi : p i), surj_on f (s i hi) (t i hi)) : surj_on f (Union fun (i : \u03b9) => Union fun (hi : p i) => s i hi) (Union fun (i : \u03b9) => Union fun (hi : p i) => t i hi) :=\n  surj_on_Union_Union fun (i : \u03b9) => surj_on_Union_Union (H i)\n\ntheorem surj_on_Inter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} [hi : Nonempty \u03b9] {s : \u03b9 \u2192 set \u03b1} {t : set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), surj_on f (s i) t) (Hinj : inj_on f (Union fun (i : \u03b9) => s i)) : surj_on f (Inter fun (i : \u03b9) => s i) t := sorry\n\ntheorem surj_on_Inter_Inter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} [hi : Nonempty \u03b9] {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), surj_on f (s i) (t i)) (Hinj : inj_on f (Union fun (i : \u03b9) => s i)) : surj_on f (Inter fun (i : \u03b9) => s i) (Inter fun (i : \u03b9) => t i) :=\n  surj_on_Inter (fun (i : \u03b9) => surj_on.mono (subset.refl (s i)) (Inter_subset (fun (i : \u03b9) => t i) i) (H i)) Hinj\n\n/-!\n### `bij_on`\n-/\n\ntheorem bij_on_Union {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), bij_on f (s i) (t i)) (Hinj : inj_on f (Union fun (i : \u03b9) => s i)) : bij_on f (Union fun (i : \u03b9) => s i) (Union fun (i : \u03b9) => t i) :=\n  { left := maps_to_Union_Union fun (i : \u03b9) => bij_on.maps_to (H i),\n    right := { left := Hinj, right := surj_on_Union_Union fun (i : \u03b9) => bij_on.surj_on (H i) } }\n\ntheorem bij_on_Inter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} [hi : Nonempty \u03b9] {s : \u03b9 \u2192 set \u03b1} {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), bij_on f (s i) (t i)) (Hinj : inj_on f (Union fun (i : \u03b9) => s i)) : bij_on f (Inter fun (i : \u03b9) => s i) (Inter fun (i : \u03b9) => t i) := sorry\n\ntheorem bij_on_Union_of_directed {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} (hs : directed has_subset.subset s) {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), bij_on f (s i) (t i)) : bij_on f (Union fun (i : \u03b9) => s i) (Union fun (i : \u03b9) => t i) :=\n  bij_on_Union H (inj_on_Union_of_directed hs fun (i : \u03b9) => bij_on.inj_on (H i))\n\ntheorem bij_on_Inter_of_directed {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} [Nonempty \u03b9] {s : \u03b9 \u2192 set \u03b1} (hs : directed has_subset.subset s) {t : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} (H : \u2200 (i : \u03b9), bij_on f (s i) (t i)) : bij_on f (Inter fun (i : \u03b9) => s i) (Inter fun (i : \u03b9) => t i) :=\n  bij_on_Inter H (inj_on_Union_of_directed hs fun (i : \u03b9) => bij_on.inj_on (H i))\n\n@[simp] theorem Inter_pos {\u03b1 : Type u} {p : Prop} {\u03bc : p \u2192 set \u03b1} (hp : p) : (Inter fun (h : p) => \u03bc h) = \u03bc hp :=\n  infi_pos hp\n\n@[simp] theorem Inter_neg {\u03b1 : Type u} {p : Prop} {\u03bc : p \u2192 set \u03b1} (hp : \u00acp) : (Inter fun (h : p) => \u03bc h) = univ :=\n  infi_neg hp\n\n@[simp] theorem Union_pos {\u03b1 : Type u} {p : Prop} {\u03bc : p \u2192 set \u03b1} (hp : p) : (Union fun (h : p) => \u03bc h) = \u03bc hp :=\n  supr_pos hp\n\n@[simp] theorem Union_neg {\u03b1 : Type u} {p : Prop} {\u03bc : p \u2192 set \u03b1} (hp : \u00acp) : (Union fun (h : p) => \u03bc h) = \u2205 :=\n  supr_neg hp\n\n@[simp] theorem Union_empty {\u03b1 : Type u} {\u03b9 : Sort x} : (Union fun (i : \u03b9) => \u2205) = \u2205 :=\n  supr_bot\n\n@[simp] theorem Inter_univ {\u03b1 : Type u} {\u03b9 : Sort x} : (Inter fun (i : \u03b9) => univ) = univ :=\n  infi_top\n\n@[simp] theorem Union_eq_empty {\u03b1 : Type u} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} : (Union fun (i : \u03b9) => s i) = \u2205 \u2194 \u2200 (i : \u03b9), s i = \u2205 :=\n  supr_eq_bot\n\n@[simp] theorem Inter_eq_univ {\u03b1 : Type u} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} : (Inter fun (i : \u03b9) => s i) = univ \u2194 \u2200 (i : \u03b9), s i = univ :=\n  infi_eq_top\n\n@[simp] theorem nonempty_Union {\u03b1 : Type u} {\u03b9 : Sort x} {s : \u03b9 \u2192 set \u03b1} : set.nonempty (Union fun (i : \u03b9) => s i) \u2194 \u2203 (i : \u03b9), set.nonempty (s i) := sorry\n\ntheorem image_Union {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {f : \u03b1 \u2192 \u03b2} {s : \u03b9 \u2192 set \u03b1} : (f '' Union fun (i : \u03b9) => s i) = Union fun (i : \u03b9) => f '' s i := sorry\n\ntheorem univ_subtype {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} : univ = Union fun (x : \u03b1) => Union fun (h : p x) => singleton { val := x, property := h } := sorry\n\ntheorem range_eq_Union {\u03b1 : Type u} {\u03b9 : Sort u_1} (f : \u03b9 \u2192 \u03b1) : range f = Union fun (i : \u03b9) => singleton (f i) := sorry\n\ntheorem image_eq_Union {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (s : set \u03b1) : f '' s = Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => singleton (f i) := sorry\n\n@[simp] theorem bUnion_range {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {f : \u03b9 \u2192 \u03b1} {g : \u03b1 \u2192 set \u03b2} : (Union fun (x : \u03b1) => Union fun (H : x \u2208 range f) => g x) = Union fun (y : \u03b9) => g (f y) :=\n  supr_range\n\n@[simp] theorem bInter_range {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort x} {f : \u03b9 \u2192 \u03b1} {g : \u03b1 \u2192 set \u03b2} : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 range f) => g x) = Inter fun (y : \u03b9) => g (f y) :=\n  infi_range\n\n@[simp] theorem bUnion_image {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {s : set \u03b3} {f : \u03b3 \u2192 \u03b1} {g : \u03b1 \u2192 set \u03b2} : (Union fun (x : \u03b1) => Union fun (H : x \u2208 f '' s) => g x) = Union fun (y : \u03b3) => Union fun (H : y \u2208 s) => g (f y) :=\n  supr_image\n\n@[simp] theorem bInter_image {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {s : set \u03b3} {f : \u03b3 \u2192 \u03b1} {g : \u03b1 \u2192 set \u03b2} : (Inter fun (x : \u03b1) => Inter fun (H : x \u2208 f '' s) => g x) = Inter fun (y : \u03b3) => Inter fun (H : y \u2208 s) => g (f y) :=\n  infi_image\n\ntheorem Union_image_left {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) {s : set \u03b1} {t : set \u03b2} : (Union fun (a : \u03b1) => Union fun (H : a \u2208 s) => f a '' t) = image2 f s t := sorry\n\ntheorem Union_image_right {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) {s : set \u03b1} {t : set \u03b2} : (Union fun (b : \u03b2) => Union fun (H : b \u2208 t) => (fun (a : \u03b1) => f a b) '' s) = image2 f s t := sorry\n\ntheorem monotone_preimage {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} : monotone (preimage f) :=\n  fun (a b : set \u03b2) (h : a \u2264 b) => preimage_mono h\n\n@[simp] theorem preimage_Union {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort w} {f : \u03b1 \u2192 \u03b2} {s : \u03b9 \u2192 set \u03b2} : (f \u207b\u00b9' Union fun (i : \u03b9) => s i) = Union fun (i : \u03b9) => f \u207b\u00b9' s i := sorry\n\ntheorem preimage_bUnion {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Type u_1} {f : \u03b1 \u2192 \u03b2} {s : set \u03b9} {t : \u03b9 \u2192 set \u03b2} : (f \u207b\u00b9' Union fun (i : \u03b9) => Union fun (H : i \u2208 s) => t i) = Union fun (i : \u03b9) => Union fun (H : i \u2208 s) => f \u207b\u00b9' t i := sorry\n\n@[simp] theorem preimage_sUnion {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} {s : set (set \u03b2)} : f \u207b\u00b9' \u22c3\u2080s = Union fun (t : set \u03b2) => Union fun (H : t \u2208 s) => f \u207b\u00b9' t := sorry\n\ntheorem preimage_Inter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort u_1} {s : \u03b9 \u2192 set \u03b2} {f : \u03b1 \u2192 \u03b2} : (f \u207b\u00b9' Inter fun (i : \u03b9) => s i) = Inter fun (i : \u03b9) => f \u207b\u00b9' s i := sorry\n\ntheorem preimage_bInter {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {s : \u03b3 \u2192 set \u03b2} {t : set \u03b3} {f : \u03b1 \u2192 \u03b2} : (f \u207b\u00b9' Inter fun (i : \u03b3) => Inter fun (H : i \u2208 t) => s i) = Inter fun (i : \u03b3) => Inter fun (H : i \u2208 t) => f \u207b\u00b9' s i := sorry\n\n@[simp] theorem bUnion_preimage_singleton {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (s : set \u03b2) : (Union fun (y : \u03b2) => Union fun (H : y \u2208 s) => f \u207b\u00b9' singleton y) = f \u207b\u00b9' s := sorry\n\ntheorem bUnion_range_preimage_singleton {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) : (Union fun (y : \u03b2) => Union fun (H : y \u2208 range f) => f \u207b\u00b9' singleton y) = univ := sorry\n\ntheorem monotone_prod {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} [preorder \u03b1] {f : \u03b1 \u2192 set \u03b2} {g : \u03b1 \u2192 set \u03b3} (hf : monotone f) (hg : monotone g) : monotone fun (x : \u03b1) => set.prod (f x) (g x) :=\n  fun (a b : \u03b1) (h : a \u2264 b) => prod_mono (hf h) (hg h)\n\ntheorem Mathlib.monotone.set_prod {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} [preorder \u03b1] {f : \u03b1 \u2192 set \u03b2} {g : \u03b1 \u2192 set \u03b3} (hf : monotone f) (hg : monotone g) : monotone fun (x : \u03b1) => set.prod (f x) (g x) :=\n  monotone_prod\n\ntheorem prod_Union {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort u_1} {s : set \u03b1} {t : \u03b9 \u2192 set \u03b2} : set.prod s (Union fun (i : \u03b9) => t i) = Union fun (i : \u03b9) => set.prod s (t i) := sorry\n\ntheorem prod_bUnion {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Type u_1} {u : set \u03b9} {s : set \u03b1} {t : \u03b9 \u2192 set \u03b2} : set.prod s (Union fun (i : \u03b9) => Union fun (H : i \u2208 u) => t i) =\n  Union fun (i : \u03b9) => Union fun (H : i \u2208 u) => set.prod s (t i) := sorry\n\ntheorem prod_sUnion {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {C : set (set \u03b2)} : set.prod s (\u22c3\u2080C) = \u22c3\u2080((fun (t : set \u03b2) => set.prod s t) '' C) := sorry\n\ntheorem Union_prod {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Sort u_1} {s : \u03b9 \u2192 set \u03b1} {t : set \u03b2} : set.prod (Union fun (i : \u03b9) => s i) t = Union fun (i : \u03b9) => set.prod (s i) t := sorry\n\ntheorem bUnion_prod {\u03b1 : Type u} {\u03b2 : Type v} {\u03b9 : Type u_1} {u : set \u03b9} {s : \u03b9 \u2192 set \u03b1} {t : set \u03b2} : set.prod (Union fun (i : \u03b9) => Union fun (H : i \u2208 u) => s i) t =\n  Union fun (i : \u03b9) => Union fun (H : i \u2208 u) => set.prod (s i) t := sorry\n\ntheorem sUnion_prod {\u03b1 : Type u} {\u03b2 : Type v} {C : set (set \u03b1)} {t : set \u03b2} : set.prod (\u22c3\u2080C) t = \u22c3\u2080((fun (s : set \u03b1) => set.prod s t) '' C) := sorry\n\ntheorem Union_prod_of_monotone {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} [semilattice_sup \u03b1] {s : \u03b1 \u2192 set \u03b2} {t : \u03b1 \u2192 set \u03b3} (hs : monotone s) (ht : monotone t) : (Union fun (x : \u03b1) => set.prod (s x) (t x)) = set.prod (Union fun (x : \u03b1) => s x) (Union fun (x : \u03b1) => t x) := sorry\n\n/-- Given a set `s` of functions `\u03b1 \u2192 \u03b2` and `t : set \u03b1`, `seq s t` is the union of `f '' t` over\nall `f \u2208 s`. -/\ndef seq {\u03b1 : Type u} {\u03b2 : Type v} (s : set (\u03b1 \u2192 \u03b2)) (t : set \u03b1) : set \u03b2 :=\n  set_of fun (b : \u03b2) => \u2203 (f : \u03b1 \u2192 \u03b2), \u2203 (H : f \u2208 s), \u2203 (a : \u03b1), \u2203 (H : a \u2208 t), f a = b\n\ntheorem seq_def {\u03b1 : Type u} {\u03b2 : Type v} {s : set (\u03b1 \u2192 \u03b2)} {t : set \u03b1} : seq s t = Union fun (f : \u03b1 \u2192 \u03b2) => Union fun (H : f \u2208 s) => f '' t := sorry\n\n@[simp] theorem mem_seq_iff {\u03b1 : Type u} {\u03b2 : Type v} {s : set (\u03b1 \u2192 \u03b2)} {t : set \u03b1} {b : \u03b2} : b \u2208 seq s t \u2194 \u2203 (f : \u03b1 \u2192 \u03b2), \u2203 (H : f \u2208 s), \u2203 (a : \u03b1), \u2203 (H : a \u2208 t), f a = b :=\n  iff.rfl\n\ntheorem seq_subset {\u03b1 : Type u} {\u03b2 : Type v} {s : set (\u03b1 \u2192 \u03b2)} {t : set \u03b1} {u : set \u03b2} : seq s t \u2286 u \u2194 \u2200 (f : \u03b1 \u2192 \u03b2), f \u2208 s \u2192 \u2200 (a : \u03b1), a \u2208 t \u2192 f a \u2208 u := sorry\n\ntheorem seq_mono {\u03b1 : Type u} {\u03b2 : Type v} {s\u2080 : set (\u03b1 \u2192 \u03b2)} {s\u2081 : set (\u03b1 \u2192 \u03b2)} {t\u2080 : set \u03b1} {t\u2081 : set \u03b1} (hs : s\u2080 \u2286 s\u2081) (ht : t\u2080 \u2286 t\u2081) : seq s\u2080 t\u2080 \u2286 seq s\u2081 t\u2081 := sorry\n\ntheorem singleton_seq {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} {t : set \u03b1} : seq (singleton f) t = f '' t := sorry\n\ntheorem seq_singleton {\u03b1 : Type u} {\u03b2 : Type v} {s : set (\u03b1 \u2192 \u03b2)} {a : \u03b1} : seq s (singleton a) = (fun (f : \u03b1 \u2192 \u03b2) => f a) '' s := sorry\n\ntheorem seq_seq {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {s : set (\u03b2 \u2192 \u03b3)} {t : set (\u03b1 \u2192 \u03b2)} {u : set \u03b1} : seq s (seq t u) = seq (seq (function.comp '' s) t) u := sorry\n\ntheorem image_seq {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {f : \u03b2 \u2192 \u03b3} {s : set (\u03b1 \u2192 \u03b2)} {t : set \u03b1} : f '' seq s t = seq (function.comp f '' s) t := sorry\n\ntheorem prod_eq_seq {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : set \u03b2} : set.prod s t = seq (Prod.mk '' s) t := sorry\n\ntheorem prod_image_seq_comm {\u03b1 : Type u} {\u03b2 : Type v} (s : set \u03b1) (t : set \u03b2) : seq (Prod.mk '' s) t = seq ((fun (b : \u03b2) (a : \u03b1) => (a, b)) '' t) s := sorry\n\ntheorem image2_eq_seq {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (s : set \u03b1) (t : set \u03b2) : image2 f s t = seq (f '' s) t := sorry\n\nprotected instance monad : Monad set :=\n  { toApplicative :=\n      { toFunctor := { map := fun (\u03b1 \u03b2 : Type u) => image, mapConst := fun (\u03b1 \u03b2 : Type u) => image \u2218 function.const \u03b2 },\n        toPure := { pure := fun (\u03b1 : Type u) (a : \u03b1) => singleton a }, toSeq := { seq := fun (\u03b1 \u03b2 : Type u) => seq },\n        toSeqLeft :=\n          { seqLeft :=\n              fun (\u03b1 \u03b2 : Type u) (a : set \u03b1) (b : set \u03b2) =>\n                (fun (\u03b1 \u03b2 : Type u) => seq) \u03b2 \u03b1 ((fun (\u03b1 \u03b2 : Type u) => image) \u03b1 (\u03b2 \u2192 \u03b1) (function.const \u03b2) a) b },\n        toSeqRight :=\n          { seqRight :=\n              fun (\u03b1 \u03b2 : Type u) (a : set \u03b1) (b : set \u03b2) =>\n                (fun (\u03b1 \u03b2 : Type u) => seq) \u03b2 \u03b2 ((fun (\u03b1 \u03b2 : Type u) => image) \u03b1 (\u03b2 \u2192 \u03b2) (function.const \u03b1 id) a) b } },\n    toBind :=\n      { bind := fun (\u03b1 \u03b2 : Type u) (s : set \u03b1) (f : \u03b1 \u2192 set \u03b2) => Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => f i } }\n\n@[simp] theorem bind_def {\u03b1' : Type u} {\u03b2' : Type u} {s : set \u03b1'} {f : \u03b1' \u2192 set \u03b2'} : s >>= f = Union fun (i : \u03b1') => Union fun (H : i \u2208 s) => f i :=\n  rfl\n\n@[simp] theorem fmap_eq_image {\u03b1' : Type u} {\u03b2' : Type u} {s : set \u03b1'} (f : \u03b1' \u2192 \u03b2') : f <$> s = f '' s :=\n  rfl\n\n@[simp] theorem seq_eq_set_seq {\u03b1 : Type u_1} {\u03b2 : Type u_1} (s : set (\u03b1 \u2192 \u03b2)) (t : set \u03b1) : s <*> t = seq s t :=\n  rfl\n\n@[simp] theorem pure_def {\u03b1 : Type u} (a : \u03b1) : 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 (\u03b1 \u03b2 : Type u) (s : set \u03b1) (t : set \u03b2) => prod_image_seq_comm s t\n\ntheorem pi_def {\u03b1 : Type u} {\u03c0 : \u03b1 \u2192 Type u_1} (i : set \u03b1) (s : (a : \u03b1) \u2192 set (\u03c0 a)) : pi i s = Inter fun (a : \u03b1) => Inter fun (H : a \u2208 i) => function.eval a \u207b\u00b9' s a := sorry\n\ntheorem pi_diff_pi_subset {\u03b1 : Type u} {\u03c0 : \u03b1 \u2192 Type u_1} (i : set \u03b1) (s : (a : \u03b1) \u2192 set (\u03c0 a)) (t : (a : \u03b1) \u2192 set (\u03c0 a)) : pi i s \\ pi i t \u2286 Union fun (a : \u03b1) => Union fun (H : a \u2208 i) => function.eval a \u207b\u00b9' (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 {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} (hs : disjoint s u) (ht : disjoint t u) : disjoint (s \u222a t) u :=\n  sup_left hs ht\n\ntheorem union_right {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} (ht : disjoint s t) (hu : disjoint s u) : disjoint s (t \u222a u) :=\n  sup_right ht hu\n\ntheorem preimage {\u03b1 : Type u_1} {\u03b2 : Type u_2} (f : \u03b1 \u2192 \u03b2) {s : set \u03b2} {t : set \u03b2} (h : disjoint s t) : disjoint (f \u207b\u00b9' s) (f \u207b\u00b9' t) :=\n  fun (x : \u03b1) (hx : x \u2208 f \u207b\u00b9' s \u2293 f \u207b\u00b9' t) => h hx\n\nend disjoint\n\n\nnamespace set\n\n\nprotected theorem disjoint_iff {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} : disjoint s t \u2194 s \u2229 t \u2286 \u2205 :=\n  iff.rfl\n\ntheorem disjoint_iff_inter_eq_empty {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} : disjoint s t \u2194 s \u2229 t = \u2205 :=\n  disjoint_iff\n\ntheorem not_disjoint_iff {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} : \u00acdisjoint s t \u2194 \u2203 (x : \u03b1), x \u2208 s \u2227 x \u2208 t :=\n  iff.trans not_forall (exists_congr fun (x : \u03b1) => not_not)\n\ntheorem disjoint_left {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} : disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 s \u2192 \u00aca \u2208 t :=\n  (fun (this : (\u2200 (x : \u03b1), \u00acx \u2208 s \u2229 t) \u2194 \u2200 (a : \u03b1), a \u2208 s \u2192 \u00aca \u2208 t) => this)\n    { mp := fun (h : \u2200 (x : \u03b1), \u00acx \u2208 s \u2229 t) (a : \u03b1) => iff.mp not_and (h a),\n      mpr := fun (h : \u2200 (a : \u03b1), a \u2208 s \u2192 \u00aca \u2208 t) (a : \u03b1) => iff.mpr not_and (h a) }\n\ntheorem disjoint_right {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} : disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint s t \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)) (propext disjoint.comm)))\n    (eq.mpr (id (Eq._oldrec (Eq.refl (disjoint t s \u2194 \u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)) (propext disjoint_left)))\n      (iff.refl (\u2200 {a : \u03b1}, a \u2208 t \u2192 \u00aca \u2208 s)))\n\ntheorem disjoint_of_subset_left {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} (h : s \u2286 u) (d : disjoint u t) : disjoint s t :=\n  disjoint.mono_left h d\n\ntheorem disjoint_of_subset_right {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} (h : t \u2286 u) (d : disjoint s u) : disjoint s t :=\n  disjoint.mono_right h d\n\ntheorem disjoint_of_subset {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} {v : set \u03b1} (h1 : s \u2286 u) (h2 : t \u2286 v) (d : disjoint u v) : disjoint s t :=\n  disjoint.mono h1 h2 d\n\n@[simp] theorem disjoint_union_left {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} : disjoint (s \u222a t) u \u2194 disjoint s u \u2227 disjoint t u :=\n  disjoint_sup_left\n\n@[simp] theorem disjoint_union_right {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} : disjoint s (t \u222a u) \u2194 disjoint s t \u2227 disjoint s u :=\n  disjoint_sup_right\n\ntheorem disjoint_diff {\u03b1 : Type u} {a : set \u03b1} {b : set \u03b1} : disjoint a (b \\ a) :=\n  iff.mpr disjoint_iff (inter_diff_self a b)\n\n@[simp] theorem disjoint_empty {\u03b1 : Type u} (s : set \u03b1) : disjoint s \u2205 :=\n  disjoint_bot_right\n\n@[simp] theorem empty_disjoint {\u03b1 : Type u} (s : set \u03b1) : disjoint \u2205 s :=\n  disjoint_bot_left\n\n@[simp] theorem univ_disjoint {\u03b1 : Type u} {s : set \u03b1} : disjoint univ s \u2194 s = \u2205 :=\n  top_disjoint\n\n@[simp] theorem disjoint_univ {\u03b1 : Type u} {s : set \u03b1} : disjoint s univ \u2194 s = \u2205 :=\n  disjoint_top\n\n@[simp] theorem disjoint_singleton_left {\u03b1 : Type u} {a : \u03b1} {s : set \u03b1} : disjoint (singleton a) s \u2194 \u00aca \u2208 s := sorry\n\n@[simp] theorem disjoint_singleton_right {\u03b1 : Type u} {a : \u03b1} {s : set \u03b1} : disjoint s (singleton a) \u2194 \u00aca \u2208 s :=\n  eq.mpr (id (Eq._oldrec (Eq.refl (disjoint s (singleton a) \u2194 \u00aca \u2208 s)) (propext disjoint.comm))) disjoint_singleton_left\n\ntheorem disjoint_image_image {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {f : \u03b2 \u2192 \u03b1} {g : \u03b3 \u2192 \u03b1} {s : set \u03b2} {t : set \u03b3} (h : \u2200 (b : \u03b2), b \u2208 s \u2192 \u2200 (c : \u03b3), c \u2208 t \u2192 f b \u2260 g c) : disjoint (f '' s) (g '' t) := sorry\n\ntheorem pairwise_on_disjoint_fiber {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 \u03b2) (s : set \u03b2) : pairwise_on s (disjoint on fun (y : \u03b2) => f \u207b\u00b9' singleton y) := sorry\n\ntheorem preimage_eq_empty {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} (h : disjoint s (range f)) : f \u207b\u00b9' s = \u2205 := sorry\n\ntheorem preimage_eq_empty_iff {\u03b1 : Type u} {\u03b2 : Type v} {f : \u03b1 \u2192 \u03b2} {s : set \u03b2} : disjoint s (range f) \u2194 f \u207b\u00b9' s = \u2205 := 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 {\u03b1 : Type u} (s : set (set \u03b1)) :=\n  pairwise_on s disjoint\n\ntheorem pairwise_disjoint.subset {\u03b1 : Type u} {s : set (set \u03b1)} {t : set (set \u03b1)} (h : s \u2286 t) (ht : pairwise_disjoint t) : pairwise_disjoint s :=\n  pairwise_on.mono h ht\n\ntheorem pairwise_disjoint.range {\u03b1 : Type u} {s : set (set \u03b1)} (f : \u21a5s \u2192 set \u03b1) (hf : \u2200 (x : \u21a5s), f x \u2286 subtype.val x) (ht : pairwise_disjoint s) : pairwise_disjoint (range f) := sorry\n\n/- classical -/\n\ntheorem pairwise_disjoint.elim {\u03b1 : Type u} {s : set (set \u03b1)} (h : pairwise_disjoint s) {x : set \u03b1} {y : set \u03b1} (hx : x \u2208 s) (hy : y \u2208 s) (z : \u03b1) (hzx : z \u2208 x) (hzy : z \u2208 y) : x = y :=\n  iff.mp not_not fun (h' : \u00acx = y) => h x hx y hy h' { left := hzx, right := hzy }\n\nend set\n\n\nnamespace set\n\n\ntheorem subset_diff {\u03b1 : Type u} {s : set \u03b1} {t : set \u03b1} {u : set \u03b1} : s \u2286 t \\ u \u2194 s \u2286 t \u2227 disjoint s u := sorry\n\n/-- If `t` is an indexed family of sets, then there is a natural map from `\u03a3 i, t i` to `\u22c3 i, t i`\nsending `\u27e8i, x\u27e9` to `x`. -/\ndef sigma_to_Union {\u03b1 : Type u} {\u03b2 : Type v} (t : \u03b1 \u2192 set \u03b2) (x : sigma fun (i : \u03b1) => \u21a5(t i)) : \u21a5(Union fun (i : \u03b1) => t i) :=\n  { val := \u2191(sigma.snd x), property := sorry }\n\ntheorem sigma_to_Union_surjective {\u03b1 : Type u} {\u03b2 : Type v} (t : \u03b1 \u2192 set \u03b2) : function.surjective (sigma_to_Union t) := sorry\n\ntheorem sigma_to_Union_injective {\u03b1 : Type u} {\u03b2 : Type v} (t : \u03b1 \u2192 set \u03b2) (h : \u2200 (i j : \u03b1), i \u2260 j \u2192 disjoint (t i) (t j)) : function.injective (sigma_to_Union t) := sorry\n\ntheorem sigma_to_Union_bijective {\u03b1 : Type u} {\u03b2 : Type v} (t : \u03b1 \u2192 set \u03b2) (h : \u2200 (i j : \u03b1), i \u2260 j \u2192 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 {\u03b1 : Type u} {\u03b2 : Type v} {t : \u03b1 \u2192 set \u03b2} (h : \u2200 (i j : \u03b1), i \u2260 j \u2192 disjoint (t i) (t j)) : \u21a5(Union fun (i : \u03b1) => t i) \u2243 sigma fun (i : \u03b1) => \u21a5(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 {\u03b1 : Type u} {\u03b2 : Type v} {s : set \u03b1} {t : \u03b1 \u2192 set \u03b2} (h : pairwise_on s (disjoint on t)) : \u21a5(Union fun (i : \u03b1) => Union fun (H : i \u2208 s) => t i) \u2243 sigma fun (i : \u21a5s) => \u21a5(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 {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n    [normalization_monoid \u03b1]\n    (p: \u03b1) [p_prime: fact (prime p)] (a: \u03b1): \u2115 :=\n  if a \u2260 0\n      then multiset.count (normalize p) (unique_factorization_monoid.factors a)\n      else 0\n\nlemma padic_val_mul {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n  [normalization_monoid \u03b1]\n  (p: \u03b1) [p_prime: fact (prime p)] (a b: \u03b1) (ha: a \u2260 0) (hb: b \u2260 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 {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n  [normalization_monoid \u03b1]\n  (p: \u03b1) [p_prime: fact (prime p)] {a b: \u03b1} (add_ne_zero: a + b \u2260 0):\n    padic_val p (a + b) \u2265 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) \u2265 min (multiplicity p a) (multiplicity p b),\n      from multiplicity.min_le_multiplicity_add,\n      have p\u2080 := \u03bb a: \u03b1, \u03bb p: a \u2260 0,\n        unique_factorization_monoid.multiplicity_eq_count_factors\n          (fact_iff.1 p_prime).irreducible p,\n      rw p\u2080 _ add_ne_zero at h,\n      rw p\u2080 _ ha at h,\n      rw p\u2080 _ hb at h,\n      finish,\n    },\nend\n\nlemma padic_val_primes {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n  [normalization_monoid \u03b1]\n  (p: \u03b1) [p_prime: fact (prime p)]: \u2200 q: \u03b1, prime q \u2192\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 \u2190 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      (\u03bb h, hpq (primes_associated_of_dvd (fact_iff.1 p_prime) q_prime h).symm)]\nend\n\nlemma padic_val_units {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n  [normalization_monoid \u03b1]\n  (p: \u03b1) [p_prime: fact (prime p)]: \u2200 u: units \u03b1, 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 \u2190 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 {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n    [normalization_monoid \u03b1]\n    (base: \u211d) (base_pos: 0 < base) (base_lt_one: base < 1)\n    (p: \u03b1) [p_prime: fact (prime p)]: \u03b1 \u2192 \u211d :=\n  \u03bb a: \u03b1, if a = 0 then 0 else base ^ padic_val p a\n\ninstance padic_abv_is_absolute_value {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n  [normalization_monoid \u03b1]\n  (base: \u211d) (base_pos: 0 < base) (base_lt_one: base < 1)\n  (p: \u03b1) [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\u2081: real.rpow base (padic_val p (x + y)) \u2264\n          max\n            (real.rpow base (padic_val p x))\n            (real.rpow base (padic_val p y)),\n        {\n          have p\u2082 := 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\u2081, },\n          simp [hx, hy, hxy, le_trans p\u2081 p\u2082],\n        },\n\n        set c := base\u207b\u00b9 with c_def,\n        obtain \u27e8 one_lt_c, base_rw, c_nonneg \u27e9: 1 < c \u2227 base = c\u207b\u00b9 \u2227 0 \u2264 c,\n        {\n          rw c_def,\n          rw inv_inv',\n          exact \u27e8 one_lt_inv base_pos base_lt_one, rfl,\n            inv_nonneg.2 $ le_of_lt base_pos \u27e9,\n        },\n        have pow_c_mono: monotone (pow c),\n        from \u03bb a b h, real.rpow_le_rpow_of_exponent_le (le_of_lt one_lt_c) h,\n        \n        have p\u2080 := (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 \u2190 real.rpow_neg c_nonneg, },\n        rw \u2190 monotone.map_max pow_c_mono,\n        rw \u2190 ge_iff_le at p\u2080,\n        rw max_neg_neg,\n        rw \u2190 monotone.map_min,\n        {\n          apply pow_c_mono,\n          exact_mod_cast p\u2080,\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 {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n    [normalization_monoid \u03b1]\n    (base: \u211d) (base_pos: 0 < base) (base_lt_one: base < 1)\n    (p: \u03b1) [p_prime: fact (prime p)]:\n      \u2200 q: \u03b1, prime q \u2192\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 {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n    [normalization_monoid \u03b1]\n    (base: \u211d) (base_pos: 0 < base) (base_lt_one: base < 1)\n    (p: \u03b1) [p_prime: fact (prime p)]:\n      \u2200 a: \u03b1, padic_abv base base_pos base_lt_one p a \u2264 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 \u25b8 zero_le_one) _ _,\n  {\n    rintros _ \u27e8 u, rfl \u27e9,\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 {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n  [normalization_monoid \u03b1]\n  (p: \u03b1) [p_prime: fact (prime p)]: \u03b1 \u2192 \u211d :=\n    padic_abv (1/2) one_half_pos one_half_lt_one p\n\ninstance sample_padic_abv_is_absolute_value {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n    [normalization_monoid \u03b1]\n    (p: \u03b1) [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 {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n    [normalization_monoid \u03b1] (p: \u03b1) [p_prime: fact (prime p)]:\n      \u2200 q: \u03b1, prime q \u2192\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 {\u03b1} [integral_domain \u03b1] [is_principal_ideal_ring \u03b1]\n    [normalization_monoid \u03b1] (p: \u03b1) [p_prime: fact (prime p)]:\n      \u2200 a: \u03b1, sample_padic_abv p a \u2264 1 :=\npadic_abv_bounded (1/2) one_half_pos one_half_lt_one p\n\ndef hom_of_abv {\u03b1} [linear_ordered_field \u03b1] {\u03b2} [ring \u03b2] [nontrivial \u03b2]\n  (abv: \u03b2 \u2192 \u03b1) [is_absolute_value abv]:\n  monoid_with_zero_hom \u03b2 \u03b1 :=\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 {\u03b1} [comm_ring \u03b1]\n  (\u03c6: monoid_with_zero_hom \u03b1 \u211d) (a: \u211d) (a_pos: 0 < a)\n  (nonneg: \u2200 a: \u03b1, 0 \u2264 \u03c6 a):\n  monoid_with_zero_hom \u03b1 \u211d :=\n{\n  to_fun := (\u03bb r, (\u03c6 r) ^ a),\n  map_zero' := by {\n    rw [\u2190 monoid_with_zero_hom.to_fun_eq_coe, \u03c6.map_zero'],\n    exact real.zero_rpow (ne.symm $ ne_of_lt a_pos),\n  },\n  map_one' := by {\n    rw [\u2190 monoid_with_zero_hom.to_fun_eq_coe, \u03c6.map_one'],\n    exact real.one_rpow a,\n  },\n  map_mul' := by {\n    intros x y,\n    rw [\u2190 monoid_with_zero_hom.to_fun_eq_coe, \u03c6.map_mul'],\n    have p: \u2200 a: \u03b1, 0 \u2264 \u03c6.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 \u211d E] [finite_dimensional \u211d E]\nvariables [measure_space E] [borel_space E] [(@volume E _).is_add_haar_measure]\nvariables [normed_add_comm_group F] [normed_space \u211d F] \n\n@[protected, measurability] lemma ae_strongly_measurable (f : \ud835\udce2(E, F)) : ae_strongly_measurable (f : E \u2192 F) volume :=\nf.continuous.ae_strongly_measurable\n\nlemma one_add_pow_smul_le (f : \ud835\udce2(E, F)) (x : E) (n : \u2115): \u2225(1 + \u2225x\u2225) ^ n \u2022 f x\u2225 \u2264\n  \u2211 (m : \u2115) in finset.range (n + 1), (n.choose m : \u211d) * (schwartz_map.seminorm \u211d 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 (\u03bb m hm, _),\n  rw mul_comm,\n  simp only [\u2190smul_smul, norm_smul, norm_coe_nat, norm_pow, norm_norm],\n  exact mul_le_mul_of_nonneg_left (f.norm_pow_mul_le_seminorm \u211d _ _) (by positivity),\nend\n\n/-- To be generalized to all p -/\n@[protected] lemma mem_\u2112p_one (f : \ud835\udce2(E, F)) : mem_\u2112p (f : E \u2192 F) 1 volume :=\nbegin\n  have hr : (finrank \u211d E : \u211d) < finrank \u211d E + 1 := lt_add_one (finrank \u211d E), \n  have h := mem_\u2112p_rpow_neg_one_add_norm hr,\n  let c := \u2211 (m : \u2115) in finset.range ((finrank \u211d E + 1) + 1),\n    ((finrank \u211d E + 1).choose m : \u211d) * (schwartz_map.seminorm \u211d m 0) f,\n  have h' : \u2200 x : E, \u2225f x\u2225 \u2264 c * \u2225(1 + \u2225x\u2225) ^ -((finrank \u211d E : \u211d) + 1)\u2225 :=\n  begin\n    intros x,\n    have hpos : 0 < 1 + \u2225x\u2225 := by positivity,\n    rw \u2190one_smul \u211d (f x),\n    nth_rewrite 0 \u2190real.rpow_zero (1 + \u2225x\u2225),\n    rw \u2190sub_self ((finrank \u211d E : \u211d) + 1),\n    rw sub_eq_neg_add,\n    rw real.rpow_add hpos,\n    rw \u2190smul_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 : \ud835\udce2(E, F)) : integrable (f : E \u2192 F) :=\nbegin\n  rw \u2190mem_\u2112p_one_iff_integrable,\n  exact f.mem_\u2112p_one,\nend\n\nend schwartz_map\n\nsection fourier_transform_aux\n\nvariables [inner_product_space \u211d E]\nvariables [normed_add_comm_group F] [normed_space \u211d F] [complete_space F] [finite_dimensional \u211d F]\nvariables [has_smul \u2102 F]\n\nlemma complex.differentiable_at_coe {f : E \u2192 \u211d} {x : E} (hf : differentiable_at \u211d f x) :\n  differentiable_at \u211d (\u03bb y, (f y : \u2102)) x :=\ncomplex.of_real_clm.differentiable_at.comp _ hf\n\nlemma complex.differentiable_coe {f : E \u2192 \u211d} (hf : differentiable \u211d f) :\n  differentiable \u211d (\u03bb x, (f x : \u2102)) :=\ncomplex.of_real_clm.differentiable.comp hf\n\nlemma complex.fderiv_coe {f : E \u2192 \u211d} {y : E} (hf : differentiable_at \u211d f y) :\n  fderiv \u211d (\u03bb x, (f x : \u2102)) y = complex.of_real_clm.comp (fderiv \u211d f y) :=\nbegin\n  change fderiv \u211d (\u03bb x, complex.of_real_clm (f x)) y = complex.of_real_clm.comp (fderiv \u211d 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 \u2192 \u2102} {x : E} (hc : differentiable_at \u211d f x) :\n  fderiv \u211d (\u03bb x, complex.exp (f x)) x = complex.exp (f x) \u2022 (fderiv \u211d f x) :=\nhc.has_fderiv_at.cexp.fderiv\n\nlemma inner_differentiable_at {y : E} {z : E} : differentiable_at \u211d (\u03bb x, @inner \u211d _ _ y x) z :=\n(@innerSL \u211d _ _ _ y).differentiable_at\n\nlemma inner_differentiable {y : E} : differentiable \u211d (\u03bb x, @inner \u211d _ _ y x) :=\n(@innerSL \u211d _ _ _ y).differentiable\n\nlemma fderiv_inner {y x\u2080 : E} : fderiv \u211d (\u03bb x, @inner \u211d _ _ y x) x\u2080 = innerSL y :=\n(@innerSL \u211d _ _ _ y).fderiv\n\nlemma fderiv_exp_inner_left (x\u2080 \u03be : E) : fderiv \u211d (\u03bb x, complex.exp (- complex.I * @inner \u211d _ _ x \u03be)) x\u2080 =\n  (complex.exp (-complex.I * (@inner \u211d _ _ x\u2080 \u03be)) * -complex.I) \u2022 complex.of_real_clm.comp (innerSL \u03be) :=\nbegin\n  have hdiff_inner : differentiable_at \u211d (\u03bb (x : E), \u2191(inner \u03be x)) x\u2080 :=\n  (complex.differentiable_coe inner_differentiable).differentiable_at,\n  have hdiff_inner' : differentiable_at \u211d (\u03bb (x : E), -complex.I * \u2191(inner \u03be x)) x\u2080 :=\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 \u2190mul_smul,\n  simp only [real_inner_comm x\u2080 \u03be],\n  /-simp_rw real_inner_comm,\n  rw \u2190fderiv_exp_inner_left \u03be\u2080 x,\n  congr,\n  ext1,\n  rw real_inner_comm,-/\nend\n\nlemma fderiv_exp_inner_right (\u03be\u2080 x : E) : fderiv \u211d (\u03bb \u03be, complex.exp (- complex.I * @inner \u211d _ _ x \u03be)) \u03be\u2080 =\n  (complex.exp (-complex.I * (@inner \u211d _ _ x \u03be\u2080)) * -complex.I) \u2022 complex.of_real_clm.comp (innerSL x) :=\nbegin\n  have hdiff_inner : differentiable_at \u211d (\u03bb (\u03be : E), \u2191(inner x \u03be)) \u03be\u2080 :=\n  (complex.differentiable_coe inner_differentiable).differentiable_at,\n  have hdiff_inner' : differentiable_at \u211d (\u03bb (\u03be : E), -complex.I * \u2191(inner x \u03be)) \u03be\u2080 :=\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 \u2190mul_smul,\nend\n\nend fourier_transform_aux\n\n.\n\nsection normedC\n\nvariables [inner_product_space \u211d E]\nvariables [normed_add_comm_group F] [normed_space \u211d F] [complete_space F] [finite_dimensional \u211d F]\nvariables [normed_space \u2102 F]\n\nvariables (c : \u2102)\n\ndef innerSL_mul (f : \ud835\udce2(E, F)) : \ud835\udce2(E, E \u2192L[\u211d] F) :=\n{ to_fun := \u03bb x, ((@continuous_linear_map.lsmul \u211d F _ _ _ \u211d _ _ _ _).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 : \ud835\udce2(E, F)) (g : \ud835\udce2(E, E\u2192L[\u211d] F))\n\n#check c \u2022 g\n\n#check complex.of_real_clm.comp (innerSL x)\n#check f x\n#check ((@continuous_linear_map.lsmul \u211d F _ _ _ \u211d _ _ _ _).flip (f x)).comp (innerSL x)\n#check (@continuous_linear_map.lsmul \u2102 F _ _ _ \u2102 _ _ _ _).flip (f x)--F \u2192L[\u211d] \u211d \u2192L[\u211d] F)\n\n\n#check \u03bb y, complex.of_real_clm.comp (innerSL x) y \u2022 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 \u2192 F) (\u03be : E) : F :=\n  (2 * real.pi)^(-(finrank \u211d E : \u211d) / 2) \u2022 \u222b x, complex.exp (- complex.I * (@inner \u211d _ _ x \u03be)) \u2022 f x\n\ndef fourier_transform (f : \ud835\udce2(E, F)) : \ud835\udce2(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 \u2192 X)\n\nexample (H : a = b) : f a + f a = f b + f b :=\nby congrm f _ + f _; exact H\n\nexample {g : X \u2192 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 \u2194 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 \u2194 q) :\n  ite p 0 1 = ite q 0 1 :=\nbegin\n  congrm ite _ 0 1,\n  exact h,\nend\n\nexample {a b : \u2115} (h : a = b) : (\u03bb y : \u2115, \u2200 z, a + a = z) = (\u03bb x, \u2200 z, b + a = z) :=\nbegin\n  congrm \u03bb x, \u2200 w, _ + a = w,\n  exact h,\nend\n\nexample (h : 5 = 3) : (\u27e85 + 1, dec_trivial\u27e9 : fin 10) = \u27e83 + 1, dec_trivial\u27e9 :=\nbegin\n  congrm \u27e8_ + 1, _\u27e9,\n  exact h,\nend\n\nexample : true \u2227 false \u2194 (true \u2227 true) \u2227 false :=\nbegin\n  congrm _ \u2227 _,\n  exact (true_and true).symm,\nend\n\nexample {f g : \u2115 \u2192 \u2115 \u2192 \u2115} (h : f = g) : (\u03bb i j, f i j) = (\u03bb i j, g i j) :=\nbegin\n  congrm \u03bb i j, _,\n  guard_target f i j = g i j,\n  rw h,\nend\n\nexample : true \u2227 false \u2194 (true \u2227 true) \u2227 false :=\nbegin\n  congrm _\u2082 _ _,\n  exact (true_and true).symm,\nend\n\nexample {g : X \u2192 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 _\u2082 (f (_\u2081 _)) (_\u2082 _ _),\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 \u2192 B \u2192 C \u2192 D \u2192 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 _\u2084 (_\u2082 _ _) _ (_\u2082 _ _) _; 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 \u2192 B \u2192 C \u2192 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 _\u2083 (_\u2082 _ _) _ (_\u2082 _ _); assumption\n\nexample {A : Type*} (s : A \u2192 \u2115) {a1 a3 : \u2115} {a4 a5 : A} (a45 : a4 = a5) :\n  (a1 + (s a4)) * a3 = (a1 + (s a5)) * a3 :=\nbegin\n  congrm _\u2082 (_ + (_\u2081 _)) _,\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 \u2192 B \u2192 C) (a23 : a2 = a3) (b13 : b1 = b3) :\n  r (a1 + a2) (b1 * b2) = r (a1 + a3) (b3 * b2) :=\nby congrm _\u2082 (_\u2082 _ _) (_\u2082 _ _); assumption\n\nexample {A B C : Type*} (r : A \u2192 B) (s : B \u2192 C) (a b : A) (ab : a = b) :\n  s (r a) = s (r b) :=\nbegin\n  congrm _\u2081 (_\u2081 _),\n  exact ab,\nend\n\nopen tactic\n\nexample {A : Type} [has_add A] (a b c d e f : A) (r : A \u2192 A \u2192 A \u2192 A) (s : A \u2192 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 _\u2083 _ (_ + (_\u2081 _)) _,\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 \u2192 A \u2192 A) (s : A \u2192 A) (bd : b = d) (bc : b = c) :\n  r b (a + s b) = r d (a + s c) :=\nbegin\n  congrm _\u2082 _ (_\u2082 _ (s _)),  exact bd, exact bc,\n/-  any one of these alternatives to the line above proves the goal\n  congrm _\u2082 _ (_\u2082 _ (_\u2081 _)), exact bd, exact bc,\n  congrm _\u2082 _ (_ + (_\u2081 _)),  exact bd, exact bc,\n  congrm _\u2082 _ (_ + (s _)),   exact bd, exact bc,\n  congrm r _ (_\u2082 _ (s _)),   exact bd, exact bc,\n  congrm r _ (_\u2082 _ (_\u2081 _)),  exact bd, exact bc,\n  congrm r _ (_ + (s _)),    exact bd, exact bc,\n  congrm r _ (_ + (_\u2081 _)),   exact bd, exact bc,\n-/\nend\n\nexample {W X Y Z : Type*} (w w' : W) (y y' : Y) (r : X \u2192 Y \u2192 Z) (s : W \u2192 X)\n  (hw : w = w') (hy : y = y') :\n  r (s w) y = r (s w') y' :=\nby congrm _\u2082 (_\u2081 _) _; assumption\n\nexample {W X Y : Type*} (w w' : W) (y y' : Y) (r : X \u2192 Y \u2192 \u2115) (s : W \u2192 X)\n  (hw : w = w') (hy : y = y') :\n  (2 + 2) + r (s w) y = 2 * 2 + r (s w') y' :=\nby congrm _\u2082 (_\u2082 _ _) (_\u2082 (_\u2081 _) _); assumption\n\nexample (h1 : 5 = 1) (h2 : 7 = 3) : nat.succ 5 + nat.pred 7 = nat.pred 3 * nat.succ 1 :=\nbegin\n  congrm _\u2082 (_\u2081 _) (_\u2081 _);\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 : \u2115} (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 _\u2082 (_\u2082 _ _) (_\u2082 _ (_\u2081 _)); 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 {\u03b1 \u03b2 : Type zfc_u}\n\n-- ideas around the concept of \u03b1 being canonically isomorphic to \u03b2\n\nnamespace zfc \n\n-- mod of equiv so I can save typing\nstructure equiv' (\u03b1 : Type zfc_u) (\u03b2 : Type zfc_u) :=\n(i    : \u03b1 \u2192 \u03b2)\n(j    : \u03b2 \u2192 \u03b1)\n(ij : \u2200 (x : \u03b1), j (i x) = x)\n(ji  : \u2200 (y : \u03b2), 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 \u2192 Type u\n--fields:\n--has_mul.mul : \u03a0 {\u03b1 : Type u} [c : has_mul \u03b1], \u03b1 \u2192 \u03b1 \u2192 \u03b1\n\n-- Fundamental theorem of has_mul\n\ndefinition mul_is_add {\u03b1 : Type zfc_u} : equiv' (has_mul \u03b1) (has_add \u03b1) :=\n{ i := \u03bb \u27e8mul\u27e9,\u27e8mul\u27e9,\n  j := \u03bb \u27e8mul\u27e9,\u27e8mul\u27e9,\n  ij := \u03bb \u27e8x\u27e9,rfl,\n  ji := \u03bb \u27e8x\u27e9, rfl,\n}\n\ndefinition equiv_mul {\u03b1 \u03b2 : Type zfc_u} : equiv' \u03b1 \u03b2 \u2192 equiv' (has_mul \u03b1) (has_mul \u03b2) := \u03bb E,\n{ i :=  \u03bb \u03b1mul,\u27e8\u03bb b1 b2, E.i (@has_mul.mul \u03b1 \u03b1mul (E.j b1) (E.j b2))\u27e9,\n  j := \u03bb \u03b2mul,\u27e8\u03bb a1 a2, E.j (@has_mul.mul \u03b2 \u03b2mul (E.i a1) (E.i a2))\u27e9, -- didn't I just write that?\n                                                                      -- should we introduce E-dual?\n  ij := \u03bb f, begin \n    cases f, -- aargh why do I struggle\n    suffices :  (\u03bb (a1 a2 : \u03b1), E.j (E.i (f (E.j (E.i a1)) (E.j (E.i a2))))) = (\u03bb 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 \u03bb \u27e8g\u27e9, 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 {\u03a9:Type*} {M:measurable_space \u03a9}\n  {\u03bc:measure_theory.measure \u03a9} {x y:\u03a9 \u2192 ennreal} \n  {S:set \u03a9}:\n  measurable_set S \u2192\n  (\u2200 \u03c9 \u2208 S, x \u03c9 \u2264 y \u03c9) \u2192  \n  \u03bc.with_density x S \u2264 \u03bc.with_density y S :=\nbegin\n  intros A3 A4,\n  rw measure_theory.with_density_apply2' \u03bc x S A3,\n  rw measure_theory.with_density_apply2' \u03bc y S A3,\n  apply measure_theory.lintegral_mono,\n\n  rw le_func_def2,\n  intros \u03c9,\n  cases (classical.em (\u03c9 \u2208 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 {\u03a9:Type*} {M:measurable_space \u03a9}\n  {\u03bc:measure_theory.measure \u03a9} {x y:\u03a9 \u2192 ennreal} \n  {S:set \u03a9}:measurable x \u2192 measurable y \u2192\n  measurable_set S \u2192\n  (\u2200 \u03c9 \u2208 S, x \u03c9 \u2264 y \u03c9) \u2192  \n  \u03bc.with_density (x\u2294y) S = \u03bc.with_density y S :=\nbegin\n  intros A1 A2 A3 A4,\n  rw measure_theory.with_density_apply2' \u03bc (x \u2294 y) S A3,\n  rw measure_theory.with_density_apply2' \u03bc y S A3,\n  have A5:set.indicator S (x \u2294 y) = set.indicator S y,\n  {\n    apply funext,\n    intro \u03c9,\n    cases (classical.em (\u03c9\u2208 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 {\u03a9:Type*}\n  {M:measurable_space \u03a9}\n  {\u03bc \u03bd m:measure_theory.measure \u03a9}\n  {S:set \u03a9}:measurable_set S \u2192\n  (\u03bc \u2264 m) \u2192\n  (\u03bd \u2264 m) \u2192 \n  (\u03bc \u2294 \u03bd) S \u2264 m S :=\nbegin\n  intros A1 A2 A3,\n  have A4:\u03bc \u2294 \u03bd \u2264 m := \n      @sup_le (measure_theory.measure \u03a9) _ \u03bc \u03bd 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\u2082 \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 \u00d7 -)` 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 \u00d7 -)` 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 \u2a2f 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 \u2a2f 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 (\u22a4_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 \u2964 C :=\n  is_left_adjoint.right (monoidal_category.tensor_left A)\n\n/-- The adjunction between A \u2a2f - 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 \u22a3 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 \u22d9 functor.obj limits.prod.functor A \u27f6 \ud835\udfed :=\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    \ud835\udfed \u27f6 functor.obj limits.prod.functor A \u22d9 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 \u27f6 Y) :\n    limits.prod.map \ud835\udfd9 (functor.map (exp A) f) \u226b nat_trans.app (ev A) Y =\n        nat_trans.app (ev A) X \u226b 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 \u27f6 Y) {X' : C}\n    (f' : functor.obj (functor.obj limits.prod.functor A \u22d9 exp A) Y \u27f6 X') :\n    f \u226b nat_trans.app (coev A) Y \u226b f' =\n        nat_trans.app (coev A) X \u226b functor.map (exp A) (limits.prod.map \ud835\udfd9 f) \u226b 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 \ud835\udfd9 (nat_trans.app (coev A) B) \u226b nat_trans.app (ev A) (A \u2a2f B) = \ud835\udfd9 :=\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) \u226b functor.map (exp A) (nat_trans.app (ev A) B) =\n        \ud835\udfd9 :=\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 \u2a2f Y \u27f6 X) \u2192 (Y \u27f6 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 \u27f6 functor.obj (exp A) X) \u2192 (A \u2a2f Y \u27f6 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 \u27f6 X') (g : A \u2a2f X' \u27f6 Y) :\n    \u2200 {X'_1 : C} (f' : functor.obj (exp A) Y \u27f6 X'_1),\n        cartesian_closed.curry (limits.prod.map \ud835\udfd9 f \u226b g) \u226b f' = f \u226b cartesian_closed.curry g \u226b 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 \u2a2f X \u27f6 Y) (g : Y \u27f6 Y') {X' : C}\n    (f' : functor.obj (exp A) Y' \u27f6 X') :\n    cartesian_closed.curry (f \u226b g) \u226b f' = cartesian_closed.curry f \u226b functor.map (exp A) g \u226b 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 \u27f6 functor.obj (exp A) Y) (g : Y \u27f6 Y') :\n    cartesian_closed.uncurry (f \u226b functor.map (exp A) g) = cartesian_closed.uncurry f \u226b 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 \u27f6 X') (g : X' \u27f6 functor.obj (exp A) Y) :\n    cartesian_closed.uncurry (f \u226b g) = limits.prod.map \ud835\udfd9 f \u226b 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 \u2a2f X \u27f6 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 \u27f6 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 \u2a2f Y \u27f6 X)\n    (g : Y \u27f6 functor.obj (exp A) X) :\n    cartesian_closed.curry f = g \u2194 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 \u2a2f Y \u27f6 X)\n    (g : Y \u27f6 functor.obj (exp A) X) :\n    g = cartesian_closed.curry f \u2194 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 \u27f6 functor.obj (exp A) X) :\n    cartesian_closed.uncurry g = limits.prod.map \ud835\udfd9 g \u226b 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 \u2a2f Y \u27f6 X) :\n    cartesian_closed.curry g = nat_trans.app (coev A) Y \u226b 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 \ud835\udfd9 = 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 \ud835\udfd9 = 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 \u2245 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 (\u22a4_C)] : functor.obj (exp (\u22a4_C)) X \u2245 X :=\n  yoneda.ext (functor.obj (exp (\u22a4_C)) X) X\n    (fun (Y : C) (f : Y \u27f6 functor.obj (exp (\u22a4_C)) X) =>\n      iso.inv (limits.prod.left_unitor Y) \u226b cartesian_closed.uncurry f)\n    (fun (Y : C) (f : Y \u27f6 X) => cartesian_closed.curry (iso.hom (limits.prod.left_unitor Y) \u226b 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 \u27f6 Y) : \u22a4_C \u27f6 functor.obj (exp A) Y :=\n  cartesian_closed.curry (limits.prod.fst \u226b 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 \u27f6 A) [exponentiable B] : exp A \u27f6 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 \u27f6 A) [exponentiable B] (X : C) :\n    limits.prod.map \ud835\udfd9 (nat_trans.app (pre f) X) \u226b nat_trans.app (ev B) X =\n        limits.prod.map f \ud835\udfd9 \u226b 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 \u27f6 A) [exponentiable B] (X : C) :\n    cartesian_closed.uncurry (nat_trans.app (pre f) X) =\n        limits.prod.map f \ud835\udfd9", "meta": {"author": "AurelienSaue", "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 {\u03b1 \u03b2 \u03b3 : Type*}\n\nopen finset function\n\ninstance {\u03b1 : Type*} (\u03b2 : \u03b1 \u2192 Type*)\n  [fintype \u03b1] [\u2200 a, fintype (\u03b2 a)] : fintype (sigma \u03b2) :=\n\u27e8univ.sigma (\u03bb _, univ), \u03bb \u27e8a, b\u27e9, by simp\u27e9\n\n@[simp] lemma finset.univ_sigma_univ {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Type*} [fintype \u03b1] [\u2200 a, fintype (\u03b2 a)] :\n  (univ : finset \u03b1).sigma (\u03bb a, (univ : finset (\u03b2 a))) = univ := rfl\n\ninstance psigma.fintype {\u03b1 : Type*} {\u03b2 : \u03b1 \u2192 Type*} [fintype \u03b1] [\u2200 a, fintype (\u03b2 a)] :\n  fintype (\u03a3' a, \u03b2 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 \u2192\u2097\u2045R\u2046 L'` for a morphism of Lie algebras,\n * `L \u2243\u2097\u2045R\u2046 L'` for an equivalence of Lie algebras,\n * `M \u2192\u2097\u2045R,L\u2046 N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`,\n * `M \u2243\u2097\u2045R,L\u2046 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\u2081 w\u2082\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  : \u2200 (x y z : L), \u2045x + y, z\u2046 = \u2045x, z\u2046 + \u2045y, z\u2046)\n(lie_add  : \u2200 (x y z : L), \u2045x, y + z\u2046 = \u2045x, y\u2046 + \u2045x, z\u2046)\n(lie_self : \u2200 (x : L), \u2045x, x\u2046 = 0)\n(leibniz_lie : \u2200 (x y z : L), \u2045x, \u2045y, z\u2046\u2046 = \u2045\u2045x, y\u2046, z\u2046 + \u2045y, \u2045x, z\u2046\u2046)\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 : \u2200 (t : R) (x y : L), \u2045x, t \u2022 y\u2046 = t \u2022 \u2045x, y\u2046)\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     : \u2200 (x y : L) (m : M), \u2045x + y, m\u2046 = \u2045x, m\u2046 + \u2045y, m\u2046)\n(lie_add     : \u2200 (x : L) (m n : M), \u2045x, m + n\u2046 = \u2045x, m\u2046 + \u2045x, n\u2046)\n(leibniz_lie : \u2200 (x y : L) (m : M), \u2045x, \u2045y, m\u2046\u2046 = \u2045\u2045x, y\u2046, m\u2046 + \u2045y, \u2045x, m\u2046\u2046)\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 : \u2200 (t : R) (x : L) (m : M), \u2045t \u2022 x, m\u2046 = t \u2022 \u2045x, m\u2046)\n(lie_smul : \u2200 (t : R) (x : L) (m : M), \u2045x, t \u2022 m\u2046 = t \u2022 \u2045x, m\u2046)\n\nsection basic_properties\n\nvariables {R : Type u} {L : Type v} {M : Type w} {N : Type w\u2081}\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 : \u2045x + y, m\u2046 = \u2045x, m\u2046 + \u2045y, m\u2046 := lie_ring_module.add_lie x y m\n\n@[simp] lemma lie_add : \u2045x, m + n\u2046 = \u2045x, m\u2046 + \u2045x, n\u2046 := lie_ring_module.lie_add x m n\n\n@[simp] lemma smul_lie : \u2045t \u2022 x, m\u2046 = t \u2022 \u2045x, m\u2046 := lie_module.smul_lie t x m\n\n@[simp] lemma lie_smul : \u2045x, t \u2022 m\u2046 = t \u2022 \u2045x, m\u2046 := lie_module.lie_smul t x m\n\nlemma leibniz_lie : \u2045x, \u2045y, m\u2046\u2046 = \u2045\u2045x, y\u2046, m\u2046 + \u2045y, \u2045x, m\u2046\u2046 := lie_ring_module.leibniz_lie x y m\n\n@[simp] lemma lie_zero : \u2045x, 0\u2046 = (0 : M) := (add_monoid_hom.mk' _ (lie_add x)).map_zero\n\n@[simp] lemma zero_lie : \u2045(0 : L), m\u2046 = 0 :=\n(add_monoid_hom.mk' (\u03bb (x : L), \u2045x, m\u2046) (\u03bb x y, add_lie x y m)).map_zero\n\n@[simp] lemma lie_self : \u2045x, x\u2046 = 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 : -\u2045y, x\u2046 = \u2045x, y\u2046 :=\nhave h : \u2045x + y, x\u2046 + \u2045x + y, y\u2046 = 0, { rw \u2190 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 := \u03bb t x m, by rw [\u2190lie_skew, \u2190lie_skew x m, lie_algebra.lie_smul, smul_neg],\n  lie_smul := by apply lie_algebra.lie_smul, }\n\n@[simp] lemma neg_lie : \u2045-x, m\u2046 = -\u2045x, m\u2046 :=\nby { rw [\u2190sub_eq_zero, sub_neg_eq_add, \u2190add_lie], simp, }\n\n@[simp] lemma lie_neg : \u2045x, -m\u2046 = -\u2045x, m\u2046 :=\nby { rw [\u2190sub_eq_zero, sub_neg_eq_add, \u2190lie_add], simp, }\n\n@[simp] lemma sub_lie : \u2045x - y, m\u2046 = \u2045x, m\u2046 - \u2045y, m\u2046 :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma lie_sub : \u2045x, m - n\u2046 = \u2045x, m\u2046 - \u2045x, n\u2046 :=\nby simp [sub_eq_add_neg]\n\n@[simp] lemma nsmul_lie (n : \u2115) : \u2045n \u2022 x, m\u2046 = n \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_nsmul \u27e8\u03bb (x : L), \u2045x, m\u2046, zero_lie m, \u03bb _ _, add_lie _ _ _\u27e9 _ _\n\n@[simp] lemma lie_nsmul (n : \u2115) : \u2045x, n \u2022 m\u2046 = n \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_nsmul \u27e8\u03bb (m : M), \u2045x, m\u2046, lie_zero x, \u03bb _ _, lie_add _ _ _\u27e9 _ _\n\n@[simp] lemma zsmul_lie (a : \u2124) : \u2045a \u2022 x, m\u2046 = a \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_zsmul \u27e8\u03bb (x : L), \u2045x, m\u2046, zero_lie m, \u03bb _ _, add_lie _ _ _\u27e9 _ _\n\n@[simp] lemma lie_zsmul (a : \u2124) : \u2045x, a \u2022 m\u2046 = a \u2022 \u2045x, m\u2046 :=\nadd_monoid_hom.map_zsmul \u27e8\u03bb (m : M), \u2045x, m\u2046, lie_zero x, \u03bb _ _, lie_add _ _ _\u27e9 _ _\n\n@[simp] lemma lie_lie : \u2045\u2045x, y\u2046, m\u2046 = \u2045x, \u2045y, m\u2046\u2046 - \u2045y, \u2045x, m\u2046\u2046 :=\nby rw [leibniz_lie, add_sub_cancel]\n\nlemma lie_jacobi : \u2045x, \u2045y, z\u2046\u2046 + \u2045y, \u2045z, x\u2046\u2046 + \u2045z, \u2045x, y\u2046\u2046 = 0 :=\nby { rw [\u2190 neg_neg \u2045x, y\u2046, lie_neg z, lie_skew y x, \u2190 lie_skew, lie_lie], abel, }\n\ninstance lie_ring.int_lie_algebra : lie_algebra \u2124 L :=\n{ lie_smul := \u03bb n x y, lie_zsmul x y n, }\n\ninstance : lie_ring_module L (M \u2192\u2097[R] N) :=\n{ bracket     := \u03bb x f,\n  { to_fun    := \u03bb m, \u2045x, f m\u2046 - f \u2045x, m\u2046,\n    map_add'  := \u03bb m n, by { simp only [lie_add, linear_map.map_add], abel, },\n    map_smul' := \u03bb t m, by simp only [smul_sub, linear_map.map_smul, lie_smul, ring_hom.id_apply] },\n  add_lie     := \u03bb 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     := \u03bb x f g, by\n    { ext n, simp only [linear_map.coe_mk, lie_add, linear_map.add_apply], abel, },\n  leibniz_lie := \u03bb 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 \u2192\u2097[R] N) (x : L) (m : M) :\n  \u2045x, f\u2046 m = \u2045x, f m\u2046 - f \u2045x, m\u2046 :=\nrfl\n\ninstance : lie_module R L (M \u2192\u2097[R] N) :=\n{ smul_lie := \u03bb 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 := \u03bb 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 \u2192\u2097[R] L' :=\n(map_lie' : \u2200 {x y : L}, to_fun \u2045x, y\u2046 = \u2045to_fun x, to_fun y\u2046)\n\nattribute [nolint doc_blame] lie_hom.to_linear_map\n\nnotation L ` \u2192\u2097\u2045`:25 R:25 `\u2046 `:0 L':0 := lie_hom R L L'\n\nnamespace lie_hom\n\nvariables {R : Type u} {L\u2081 : Type v} {L\u2082 : Type w} {L\u2083 : Type w\u2081}\nvariables [comm_ring R]\nvariables [lie_ring L\u2081] [lie_algebra R L\u2081]\nvariables [lie_ring L\u2082] [lie_algebra R L\u2082]\nvariables [lie_ring L\u2083] [lie_algebra R L\u2083]\n\ninstance : has_coe (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192\u2097[R] L\u2082) := \u27e8lie_hom.to_linear_map\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (\u03bb _, L\u2081 \u2192 L\u2082) := \u27e8\u03bb f, f.to_linear_map.to_fun\u27e9\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\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082 := h\n\ninitialize_simps_projections lie_hom (to_linear_map_to_fun \u2192 apply)\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : ((f : L\u2081 \u2192\u2097[R] L\u2082) : L\u2081 \u2192 L\u2082) = f :=\nrfl\n\n@[simp] lemma to_fun_eq_coe (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f.to_fun = \u21d1f := rfl\n\n@[simp] lemma map_smul (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (c : R) (x : L\u2081) : f (c \u2022 x) = c \u2022 f x :=\nlinear_map.map_smul (f : L\u2081 \u2192\u2097[R] L\u2082) c x\n\n@[simp] lemma map_add (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : L\u2081 \u2192\u2097[R] L\u2082) x y\n\n@[simp] lemma map_sub (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : L\u2081 \u2192\u2097[R] L\u2082) x y\n\n@[simp] lemma map_neg (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x : L\u2081) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : L\u2081 \u2192\u2097[R] L\u2082) x\n\n@[simp] lemma map_lie (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x y : L\u2081) : f \u2045x, y\u2046 = \u2045f x, f y\u2046 := lie_hom.map_lie' f\n\n@[simp] lemma map_zero (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f 0 = 0 := (f : L\u2081 \u2192\u2097[R] L\u2082).map_zero\n\n/-- The identity map is a morphism of Lie algebras. -/\ndef id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081 :=\n{ map_lie' := \u03bb x y, rfl,\n  .. (linear_map.id : L\u2081 \u2192\u2097[R] L\u2081) }\n\n@[simp] lemma coe_id : ((id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) : L\u2081 \u2192 L\u2081) = _root_.id := rfl\n\nlemma id_apply (x : L\u2081) : (id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) x = x := rfl\n\n/-- The constant 0 map is a Lie algebra morphism. -/\ninstance : has_zero (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e8{ map_lie' := by simp, ..(0 : L\u2081 \u2192\u2097[R] L\u2082)}\u27e9\n\n@[norm_cast, simp] lemma coe_zero : ((0 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = 0 := rfl\n\nlemma zero_apply (x : L\u2081) : (0 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) x = 0 := rfl\n\n/-- The identity map is a Lie algebra morphism. -/\ninstance : has_one (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) := \u27e8id\u27e9\n\n@[simp] lemma coe_one : ((1 : (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081)) : L\u2081 \u2192 L\u2081) = _root_.id := rfl\n\nlemma one_apply (x : L\u2081) : (1 : (L\u2081 \u2192\u2097\u2045R\u2046 L\u2081)) x = x := rfl\n\ninstance : inhabited (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e80\u27e9\n\nlemma coe_injective : @function.injective (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192 L\u2082) coe_fn :=\nby rintro \u27e8\u27e8f, _\u27e9\u27e9 \u27e8\u27e8g, _\u27e9\u27e9 \u27e8h\u27e9; congr\n\n@[ext] lemma ext {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} (h : \u2200 x, f x = g x) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} : f = g \u2194 \u2200 x, f x = g x :=\n\u27e8by { rintro rfl x, refl }, ext\u27e9\n\nlemma congr_fun {f g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082} (h : f = g) (x : L\u2081) : f x = g x := h \u25b8 rfl\n\n@[simp] lemma mk_coe (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (h\u2081 h\u2082 h\u2083) :\n  (\u27e8\u27e8f, h\u2081, h\u2082\u27e9, h\u2083\u27e9 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : L\u2081 \u2192 L\u2082) (h\u2081 h\u2082 h\u2083) :\n  ((\u27e8\u27e8f, h\u2081, h\u2082\u27e9, h\u2083\u27e9 : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = f := rfl\n\n/-- The composition of morphisms is a morphism. -/\ndef comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192\u2097\u2045R\u2046 L\u2083 :=\n{ map_lie' := \u03bb x y, by { change f (g \u2045x, y\u2046) = \u2045f (g x), f (g y)\u2046, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (x : L\u2081) :\n  f.comp g x = f (g x) := rfl\n\n@[norm_cast, simp]\nlemma coe_comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) :\n  (f.comp g : L\u2081 \u2192 L\u2083) = f \u2218 g :=\nrfl\n\n@[norm_cast, simp]\nlemma coe_linear_map_comp (f : L\u2082 \u2192\u2097\u2045R\u2046 L\u2083) (g : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) :\n  (f.comp g : L\u2081 \u2192\u2097[R] L\u2083) = (f : L\u2082 \u2192\u2097[R] L\u2083).comp (g : L\u2081 \u2192\u2097[R] L\u2082) :=\nrfl\n\n@[simp] lemma comp_id (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : f.comp (id : L\u2081 \u2192\u2097\u2045R\u2046 L\u2081) = f :=\nby { ext, refl, }\n\n@[simp] lemma id_comp (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : (id : L\u2082 \u2192\u2097\u2045R\u2046 L\u2082).comp f = f :=\nby { ext, refl, }\n\n/-- The inverse of a bijective morphism is a morphism. -/\ndef inverse (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (g : L\u2082 \u2192 L\u2081)\n  (h\u2081 : function.left_inverse g f) (h\u2082 : function.right_inverse g f) : L\u2082 \u2192\u2097\u2045R\u2046 L\u2081 :=\n{ map_lie' := \u03bb x y,\n  calc g \u2045x, y\u2046 = g \u2045f (g x), f (g y)\u2046 : by { conv_lhs { rw [\u2190h\u2082 x, \u2190h\u2082 y], }, }\n            ... = g (f \u2045g x, g y\u2046) : by rw map_lie\n            ... = \u2045g x, g y\u2046 : (h\u2081 _),\n  ..linear_map.inverse f.to_linear_map g h\u2081 h\u2082 }\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 \u2192\u2097\u2045R\u2046 L' :=\n(inv_fun   : L' \u2192 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 ` \u2243\u2097\u2045`:50 R `\u2046 ` L' := lie_equiv R L L'\n\nnamespace lie_equiv\n\nvariables {R : Type u} {L\u2081 : Type v} {L\u2082 : Type w} {L\u2083 : Type w\u2081}\nvariables [comm_ring R] [lie_ring L\u2081] [lie_ring L\u2082] [lie_ring L\u2083]\nvariables [lie_algebra R L\u2081] [lie_algebra R L\u2082] [lie_algebra R L\u2083]\n\n/-- Consider an equivalence of Lie algebras as a linear equivalence. -/\ndef to_linear_equiv (f : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2243\u2097[R] L\u2082 := { ..f.to_lie_hom, ..f }\n\ninstance has_coe_to_lie_hom : has_coe (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) := \u27e8to_lie_hom\u27e9\ninstance has_coe_to_linear_equiv : has_coe (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2243\u2097[R] L\u2082) := \u27e8to_linear_equiv\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (\u03bb _, L\u2081 \u2192 L\u2082) := \u27e8\u03bb e, e.to_lie_hom.to_fun\u27e9\n\n@[simp, norm_cast] lemma coe_to_lie_hom (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) = e :=\nrfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) :\n  ((e : L\u2081 \u2243\u2097[R] L\u2082) : L\u2081 \u2192 L\u2082) = e := rfl\n\n@[simp] lemma to_linear_equiv_mk (f : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) (g h\u2081 h\u2082) :\n  (mk f g h\u2081 h\u2082 : L\u2081 \u2243\u2097[R] L\u2082) = { inv_fun := g, left_inv := h\u2081, right_inv := h\u2082, .. f } := rfl\n\nlemma coe_linear_equiv_injective : injective (coe : (L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) \u2192 (L\u2081 \u2243\u2097[R] L\u2082)) :=\nbegin\n  intros f\u2081 f\u2082 h, cases f\u2081, cases f\u2082, 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\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (L\u2081 \u2192 L\u2082) coe_fn :=\nlinear_equiv.coe_injective.comp coe_linear_equiv_injective\n\n@[ext] lemma ext {f g : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082} (h : \u2200 x, f x = g x) : f = g := coe_injective $ funext h\n\ninstance : has_one (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) :=\n\u27e8{ map_lie' := \u03bb x y, rfl,\n  ..(1 : L\u2081 \u2243\u2097[R] L\u2081)}\u27e9\n\n@[simp] lemma one_apply (x : L\u2081) : (1 : (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081)) x = x := rfl\n\ninstance : inhabited (L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) := \u27e81\u27e9\n\n/-- Lie algebra equivalences are reflexive. -/\n@[refl]\ndef refl : L\u2081 \u2243\u2097\u2045R\u2046 L\u2081 := 1\n\n@[simp] lemma refl_apply (x : L\u2081) : (refl : L\u2081 \u2243\u2097\u2045R\u2046 L\u2081) x = x := rfl\n\n/-- Lie algebra equivalences are symmetric. -/\n@[symm]\ndef symm (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : L\u2082 \u2243\u2097\u2045R\u2046 L\u2081 :=\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\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.symm.symm = e :=\nby { ext, refl }\n\n@[simp] lemma apply_symm_apply (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : \u2200 x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : \u2200 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\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) : L\u2081 \u2243\u2097\u2045R\u2046 L\u2083 :=\n{ ..lie_hom.comp e\u2082.to_lie_hom e\u2081.to_lie_hom,\n  ..linear_equiv.trans e\u2081.to_linear_equiv e\u2082.to_linear_equiv }\n\n@[simp] lemma self_trans_symm (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.trans e.symm = refl :=\next e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : e.symm.trans e = refl :=\ne.symm.self_trans_symm\n\n@[simp] lemma trans_apply (e\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) (x : L\u2081) :\n  (e\u2081.trans e\u2082) x = e\u2082 (e\u2081 x) := rfl\n\n@[simp] lemma symm_trans (e\u2081 : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) (e\u2082 : L\u2082 \u2243\u2097\u2045R\u2046 L\u2083) :\n  (e\u2081.trans e\u2082).symm = e\u2082.symm.trans e\u2081.symm := rfl\n\nprotected lemma bijective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.bijective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\ne.to_linear_equiv.bijective\n\nprotected lemma injective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.injective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\ne.to_linear_equiv.injective\n\nprotected lemma surjective (e : L\u2081 \u2243\u2097\u2045R\u2046 L\u2082) : function.surjective ((e : L\u2081 \u2192\u2097\u2045R\u2046 L\u2082) : L\u2081 \u2192 L\u2082) :=\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\u2081) (P : Type w\u2082)\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 \u2192\u2097[R] N :=\n(map_lie' : \u2200 {x : L} {m : M}, to_fun \u2045x, m\u2046 = \u2045x, to_fun m\u2046)\n\nattribute [nolint doc_blame] lie_module_hom.to_linear_map\n\nnotation M ` \u2192\u2097\u2045`:25 R,L:25 `\u2046 `: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 \u2192\u2097\u2045R,L\u2046 N) (M \u2192\u2097[R] N) := \u27e8lie_module_hom.to_linear_map\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M \u2192\u2097\u2045R,L\u2046 N) (\u03bb _, M \u2192 N) := \u27e8\u03bb f, f.to_linear_map.to_fun\u27e9\n\n@[simp, norm_cast] lemma coe_to_linear_map (f : M \u2192\u2097\u2045R,L\u2046 N) : ((f : M \u2192\u2097[R] N) : M \u2192 N) = f :=\nrfl\n\n@[simp] lemma map_smul (f : M \u2192\u2097\u2045R,L\u2046 N) (c : R) (x : M) : f (c \u2022 x) = c \u2022 f x :=\nlinear_map.map_smul (f : M \u2192\u2097[R] N) c x\n\n@[simp] lemma map_add (f : M \u2192\u2097\u2045R,L\u2046 N) (x y : M) : f (x + y) = (f x) + (f y) :=\nlinear_map.map_add (f : M \u2192\u2097[R] N) x y\n\n@[simp] lemma map_sub (f : M \u2192\u2097\u2045R,L\u2046 N) (x y : M) : f (x - y) = (f x) - (f y) :=\nlinear_map.map_sub (f : M \u2192\u2097[R] N) x y\n\n@[simp] lemma map_neg (f : M \u2192\u2097\u2045R,L\u2046 N) (x : M) : f (-x) = -(f x) :=\nlinear_map.map_neg (f : M \u2192\u2097[R] N) x\n\n@[simp] lemma map_lie (f : M \u2192\u2097\u2045R,L\u2046 N) (x : L) (m : M) : f \u2045x, m\u2046 = \u2045x, f m\u2046 :=\nlie_module_hom.map_lie' f\n\nlemma map_lie\u2082 (f : M \u2192\u2097\u2045R,L\u2046 N \u2192\u2097[R] P) (x : L) (m : M) (n : N) :\n  \u2045x, f m n\u2046 = f \u2045x, m\u2046 n + f m \u2045x, n\u2046 :=\nby simp only [sub_add_cancel, map_lie, lie_hom.lie_apply]\n\n@[simp] lemma map_zero (f : M \u2192\u2097\u2045R,L\u2046 N) : f 0 = 0 :=\nlinear_map.map_zero (f : M \u2192\u2097[R] N)\n\n/-- The constant 0 map is a Lie module morphism. -/\ninstance : has_zero (M \u2192\u2097\u2045R,L\u2046 N) := \u27e8{ map_lie' := by simp, ..(0 : M \u2192\u2097[R] N) }\u27e9\n\n@[norm_cast, simp] lemma coe_zero : ((0 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = 0 := rfl\n\nlemma zero_apply (m : M) : (0 : M \u2192\u2097\u2045R,L\u2046 N) m = 0 := rfl\n\n/-- The identity map is a Lie module morphism. -/\ninstance : has_one (M \u2192\u2097\u2045R,L\u2046 M) := \u27e8{ map_lie' := by simp, ..(1 : M \u2192\u2097[R] M) }\u27e9\n\ninstance : inhabited (M \u2192\u2097\u2045R,L\u2046 N) := \u27e80\u27e9\n\nlemma coe_injective : @function.injective (M \u2192\u2097\u2045R,L\u2046 N) (M \u2192 N) coe_fn :=\nby { rintros \u27e8\u27e8f, _\u27e9\u27e9 \u27e8\u27e8g, _\u27e9\u27e9 \u27e8h\u27e9, congr, }\n\n@[ext] lemma ext {f g : M \u2192\u2097\u2045R,L\u2046 N} (h : \u2200 m, f m = g m) : f = g :=\ncoe_injective $ funext h\n\nlemma ext_iff {f g : M \u2192\u2097\u2045R,L\u2046 N} : f = g \u2194 \u2200 m, f m = g m :=\n\u27e8by { rintro rfl m, refl, }, ext\u27e9\n\nlemma congr_fun {f g : M \u2192\u2097\u2045R,L\u2046 N} (h : f = g) (x : M) : f x = g x := h \u25b8 rfl\n\n@[simp] lemma mk_coe (f : M \u2192\u2097\u2045R,L\u2046 N) (h) :\n  (\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) = f :=\nby { ext, refl, }\n\n@[simp] lemma coe_mk (f : M \u2192\u2097[R] N) (h) :\n  ((\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = f :=\nby { ext, refl, }\n\n@[norm_cast, simp] lemma coe_linear_mk (f : M \u2192\u2097[R] N) (h) :\n  ((\u27e8f, h\u27e9 : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192\u2097[R] N) = f :=\nby { ext, refl, }\n\n/-- The composition of Lie module morphisms is a morphism. -/\ndef comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192\u2097\u2045R,L\u2046 P :=\n{ map_lie' := \u03bb x m, by { change f (g \u2045x, m\u2046) = \u2045x, f (g m)\u2046, rw [map_lie, map_lie], },\n  ..linear_map.comp f.to_linear_map g.to_linear_map }\n\nlemma comp_apply (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) :\n  f.comp g m = f (g m) := rfl\n\n@[norm_cast, simp] lemma coe_comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) :\n  (f.comp g : M \u2192 P) = f \u2218 g :=\nrfl\n\n@[norm_cast, simp] lemma coe_linear_map_comp (f : N \u2192\u2097\u2045R,L\u2046 P) (g : M \u2192\u2097\u2045R,L\u2046 N) :\n  (f.comp g : M \u2192\u2097[R] P) = (f : N \u2192\u2097[R] P).comp (g : M \u2192\u2097[R] N) :=\nrfl\n\n/-- The inverse of a bijective morphism of Lie modules is a morphism of Lie modules. -/\ndef inverse (f : M \u2192\u2097\u2045R,L\u2046 N) (g : N \u2192 M)\n  (h\u2081 : function.left_inverse g f) (h\u2082 : function.right_inverse g f) : N \u2192\u2097\u2045R,L\u2046 M :=\n{ map_lie' := \u03bb x n,\n    calc g \u2045x, n\u2046 = g \u2045x, f (g n)\u2046 : by rw h\u2082\n              ... = g (f \u2045x, g n\u2046) : by rw map_lie\n              ... = \u2045x, g n\u2046 : (h\u2081 _),\n  ..linear_map.inverse f.to_linear_map g h\u2081 h\u2082 }\n\ninstance : has_add (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ add := \u03bb f g, { map_lie' := by simp, ..((f : M \u2192\u2097[R] N) + (g : M \u2192\u2097[R] N)) }, }\n\ninstance : has_sub (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ sub := \u03bb f g, { map_lie' := by simp, ..((f : M \u2192\u2097[R] N) - (g : M \u2192\u2097[R] N)) }, }\n\ninstance : has_neg (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ neg := \u03bb f, { map_lie' := by simp, ..(-(f : (M \u2192\u2097[R] N))) }, }\n\n@[norm_cast, simp] lemma coe_add (f g : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(f + g) = f + g := rfl\n\nlemma add_apply (f g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (f + g) m = f m + g m := rfl\n\n@[norm_cast, simp] lemma coe_sub (f g : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(f - g) = f - g := rfl\n\nlemma sub_apply (f g : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (f - g) m = f m - g m := rfl\n\n@[norm_cast, simp] lemma coe_neg (f : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(-f) = -f := rfl\n\nlemma neg_apply (f : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (-f) m = -(f m) := rfl\n\ninstance : add_comm_group (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ zero           := 0,\n  add            := (+),\n  neg            := has_neg.neg,\n  sub            := has_sub.sub,\n  nsmul          := \u03bb n f, { map_lie' := \u03bb x m, by simp, ..(n \u2022 (f : M \u2192\u2097[R] N)) },\n  nsmul_zero'    := \u03bb f, by { ext, simp, },\n  nsmul_succ'    := \u03bb 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 \u2192\u2097\u2045R,L\u2046 N)) }\n\ninstance : has_scalar R (M \u2192\u2097\u2045R,L\u2046 N) :=\n{ smul := \u03bb t f, { map_lie' := by simp, ..(t \u2022 (f : M \u2192\u2097[R] N)) }, }\n\n@[norm_cast, simp] lemma coe_smul (t : R) (f : M \u2192\u2097\u2045R,L\u2046 N) : \u21d1(t \u2022 f) = t \u2022 f := rfl\n\nlemma smul_apply (t : R) (f : M \u2192\u2097\u2045R,L\u2046 N) (m : M) : (t \u2022 f) m = t \u2022 (f m) := rfl\n\ninstance : module R (M \u2192\u2097\u2045R,L\u2046 N) :=\nfunction.injective.module R \u27e8\u03bb f, f.to_linear_map.to_fun, rfl, coe_add\u27e9 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 \u2192\u2097\u2045R,L\u2046 N :=\n(inv_fun   : N \u2192 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 ` \u2243\u2097\u2045`:25 R,L:25 `\u2046 `: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 \u2243\u2097\u2045R,L\u2046 N) : M \u2243\u2097[R] N := { ..e }\n\n/-- View an equivalence of Lie modules as a type level equivalence. -/\n@[ancestor]\ndef to_equiv (e : M \u2243\u2097\u2045R,L\u2046 N) : M \u2243 N := { ..e }\n\ninstance has_coe_to_equiv : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2243 N) := \u27e8to_equiv\u27e9\ninstance has_coe_to_lie_module_hom : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2192\u2097\u2045R,L\u2046 N) := \u27e8to_lie_module_hom\u27e9\ninstance has_coe_to_linear_equiv : has_coe (M \u2243\u2097\u2045R,L\u2046 N) (M \u2243\u2097[R] N) := \u27e8to_linear_equiv\u27e9\n\n/-- see Note [function coercion] -/\ninstance : has_coe_to_fun (M \u2243\u2097\u2045R,L\u2046 N) (\u03bb _, M \u2192 N) := \u27e8\u03bb e, e.to_lie_module_hom.to_fun\u27e9\n\nlemma injective (e : M \u2243\u2097\u2045R,L\u2046 N) : function.injective e := e.to_equiv.injective\n\n@[simp] lemma coe_mk (f : M \u2192\u2097\u2045R,L\u2046 N) (inv_fun h\u2081 h\u2082) :\n  ((\u27e8f, inv_fun, h\u2081, h\u2082\u27e9 : M \u2243\u2097\u2045R,L\u2046 N) : M \u2192 N) = f := rfl\n\n@[simp, norm_cast] lemma coe_to_lie_module_hom (e : M \u2243\u2097\u2045R,L\u2046 N) :\n  ((e : M \u2192\u2097\u2045R,L\u2046 N) : M \u2192 N) = e := rfl\n\n@[simp, norm_cast] lemma coe_to_linear_equiv (e : M \u2243\u2097\u2045R,L\u2046 N) : ((e : M \u2243\u2097[R] N) : M \u2192 N) = e :=\nrfl\n\nlemma to_equiv_injective : function.injective (to_equiv : (M \u2243\u2097\u2045R,L\u2046 N) \u2192 M \u2243 N) :=\n\u03bb e\u2081 e\u2082 h, begin\n  rcases e\u2081 with \u27e8\u27e8\u27e9\u27e9, rcases e\u2082 with \u27e8\u27e8\u27e9\u27e9,\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\u2081 e\u2082 : M \u2243\u2097\u2045R,L\u2046 N) (h : \u2200 m, e\u2081 m = e\u2082 m) : e\u2081 = e\u2082 :=\nto_equiv_injective (equiv.ext h)\n\ninstance : has_one (M \u2243\u2097\u2045R,L\u2046 M) := \u27e8{ map_lie' := \u03bb x m, rfl, ..(1 : M \u2243\u2097[R] M) }\u27e9\n\n@[simp] lemma one_apply (m : M) : (1 : (M \u2243\u2097\u2045R,L\u2046 M)) m = m := rfl\n\ninstance : inhabited (M \u2243\u2097\u2045R,L\u2046 M) := \u27e81\u27e9\n\n/-- Lie module equivalences are reflexive. -/\n@[refl] def refl : M \u2243\u2097\u2045R,L\u2046 M := 1\n\n@[simp] lemma refl_apply (m : M) : (refl : M \u2243\u2097\u2045R,L\u2046 M) m = m := rfl\n\n/-- Lie module equivalences are syemmtric. -/\n@[symm] def symm (e : M \u2243\u2097\u2045R,L\u2046 N) : N \u2243\u2097\u2045R,L\u2046 M :=\n{ ..lie_module_hom.inverse e.to_lie_module_hom e.inv_fun e.left_inv e.right_inv,\n  ..(e : M \u2243\u2097[R] N).symm }\n\n@[simp] lemma apply_symm_apply (e : M \u2243\u2097\u2045R,L\u2046 N) : \u2200 x, e (e.symm x) = x :=\n  e.to_linear_equiv.apply_symm_apply\n\n@[simp] lemma symm_apply_apply (e : M \u2243\u2097\u2045R,L\u2046 N) : \u2200 x, e.symm (e x) = x :=\n  e.to_linear_equiv.symm_apply_apply\n\n@[simp] lemma symm_symm (e : M \u2243\u2097\u2045R,L\u2046 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\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) : M \u2243\u2097\u2045R,L\u2046 P :=\n{ ..lie_module_hom.comp e\u2082.to_lie_module_hom e\u2081.to_lie_module_hom,\n  ..linear_equiv.trans e\u2081.to_linear_equiv e\u2082.to_linear_equiv }\n\n@[simp] lemma trans_apply (e\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) (m : M) :\n  (e\u2081.trans e\u2082) m = e\u2082 (e\u2081 m) := rfl\n\n@[simp] lemma symm_trans (e\u2081 : M \u2243\u2097\u2045R,L\u2046 N) (e\u2082 : N \u2243\u2097\u2045R,L\u2046 P) :\n  (e\u2081.trans e\u2082).symm = e\u2082.symm.trans e\u2081.symm := rfl\n\n@[simp] lemma self_trans_symm (e : M \u2243\u2097\u2045R,L\u2046 N) : e.trans e.symm = refl :=\next _ _ e.symm_apply_apply\n\n@[simp] lemma symm_trans_self (e : M \u2243\u2097\u2045R,L\u2046 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\u00ebl Riou. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jo\u00ebl 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 \u2964 D) : Prop := is_iso (F.map f.hom)\n\nnamespace is_inverted_by\n\nlemma of_is_iso {f : arrow C} {F : C \u2964 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\u2081 : f.left \u2245 g.left) (e\u2082 : f.right \u2245 g.right)\n  (fac : e\u2081.hom \u226b g.hom = f.hom \u226b e\u2082.hom) :\n  f \u2245 g :=\n{ hom :=\n  { left := e\u2081.hom,\n    right := e\u2082.hom,\n    w' := fac, },\n  inv :=\n  { left := e\u2081.inv,\n    right := e\u2082.inv,\n    w' := begin\n      rw [\u2190 comp_id f.hom],\n      dsimp,\n      rw [\u2190 e\u2082.hom_inv_id],\n      slice_lhs 2 3 { rw \u2190 fac, },\n      slice_lhs 1 2 { rw e\u2081.inv_hom_id, },\n      rw id_comp,\n    end, },\n  hom_inv_id' := begin\n    ext,\n    exacts [e\u2081.hom_inv_id, e\u2082.hom_inv_id],\n  end,\n  inv_hom_id' := begin\n    ext,\n    exacts [e\u2081.inv_hom_id, e\u2082.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 \u2a2f Y) \u2245 op X \u2a3f op Y :=\nbegin\n  let cofan : binary_cofan (op X) (op Y) :=\n    binary_cofan.mk (limits.prod.fst : X \u2a2f Y \u27f6 X).op ((limits.prod.snd : X \u2a2f Y \u27f6 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 := \u03bb s, (limits.prod.lift (s.\u03b9.app (discrete.mk walking_pair.left)).unop (s.\u03b9.app (discrete.mk walking_pair.right)).unop).op,\n    fac' := \u03bb s j, begin\n      cases j,\n      cases j; dsimp [cofan],\n      { rw [\u2190 op_comp, prod.lift_fst, quiver.hom.op_unop], },\n      { rw [\u2190 op_comp, prod.lift_snd, quiver.hom.op_unop], },\n    end,\n    uniq' := \u03bb 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 \u27f6 X) (g : A \u27f6 Y) :\n  arrow.mk (prod.lift f g).op \u2245 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, \u2190 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, \u2190 op_comp, prod.lift_snd, comp_id], },\nend\n\n@[simps]\ndef unop_prod (X Y : C\u1d52\u1d56) [has_binary_coproduct X.unop Y.unop] [has_binary_product X Y] :\n  unop (X \u2a2f Y) \u2245 X.unop \u2a3f Y.unop :=\nbegin\n  let cofan : binary_cofan X.unop Y.unop :=\n    binary_cofan.mk (limits.prod.fst : X \u2a2f Y \u27f6 X).unop ((limits.prod.snd : X \u2a2f Y \u27f6 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 := \u03bb s, (limits.prod.lift (s.\u03b9.app (discrete.mk walking_pair.left)).op (s.\u03b9.app (discrete.mk walking_pair.right)).op).unop,\n    fac' := \u03bb s j, begin\n      cases j,\n      cases j; dsimp [cofan],\n      { rw [\u2190 unop_comp, prod.lift_fst, quiver.hom.unop_op], },\n      { rw [\u2190 unop_comp, prod.lift_snd, quiver.hom.unop_op], },\n    end,\n    uniq' := \u03bb 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\u1d52\u1d56} [has_binary_product X Y]\n  [has_binary_coproduct (unop X) (unop Y)] (f : A \u27f6 X) (g : A \u27f6 Y) :\n  arrow.mk (prod.lift f g).unop \u2245 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, \u2190 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, \u2190 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} (\u03b1 : Type u) where\n  zero : \u03b1\n\ninstance Zero.toOfNat0 {\u03b1} [Zero \u03b1] : OfNat \u03b1 (nat_lit 0) where\n  ofNat := \u2039Zero \u03b1\u203a.1\n\ninstance Zero.ofOfNat0 {\u03b1} [OfNat \u03b1 (nat_lit 0)] : Zero \u03b1 where\n  zero := 0\n\nclass One (\u03b1 : Type u) where\n  one : \u03b1\n\ninstance One.toOfNat1 {\u03b1} [One \u03b1] : OfNat \u03b1 (nat_lit 1) where\n  ofNat := \u2039One \u03b1\u203a.1\n\ninstance One.ofOfNat1 {\u03b1} [OfNat \u03b1 (nat_lit 1)] : One \u03b1 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 \u2192* 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 \u2192+ M)\n    (n : \u2115) : nat.iterate (\u21d1f) 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 \u2192* M) (n : \u2115) (x : M) (y : M) :\n    nat.iterate (\u21d1f) n (x * y) = nat.iterate (\u21d1f) n x * nat.iterate (\u21d1f) n y :=\n  function.semiconj\u2082.iterate (map_mul f) n x y\n\n@[simp] theorem iterate_map_inv {G : Type u_3} [group G] (f : G \u2192* G) (n : \u2115) (x : G) :\n    nat.iterate (\u21d1f) n (x\u207b\u00b9) = (nat.iterate (\u21d1f) n x\u207b\u00b9) :=\n  function.commute.iterate_left (map_inv f) n x\n\ntheorem iterate_map_pow {M : Type u_1} [monoid M] (f : M \u2192* M) (a : M) (n : \u2115) (m : \u2115) :\n    nat.iterate (\u21d1f) n (a ^ m) = nat.iterate (\u21d1f) 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 \u2192* G) (a : G) (n : \u2115) (m : \u2124) :\n    nat.iterate (\u21d1f) n (a ^ m) = nat.iterate (\u21d1f) 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 \u2192+ G) (n : \u2115) (x : G) (y : G) :\n    nat.iterate (\u21d1f) n (x - y) = nat.iterate (\u21d1f) n x - nat.iterate (\u21d1f) n y :=\n  function.semiconj\u2082.iterate (map_sub f) n x y\n\ntheorem iterate_map_smul {M : Type u_1} [add_monoid M] (f : M \u2192+ M) (n : \u2115) (m : \u2115) (x : M) :\n    nat.iterate (\u21d1f) n (m \u2022\u2115 x) = m \u2022\u2115 nat.iterate (\u21d1f) 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 \u2192+ G) (n : \u2115) (m : \u2124) (x : G) :\n    nat.iterate (\u21d1f) n (m \u2022\u2124 x) = m \u2022\u2124 nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) : \u21d1(f ^ n) = nat.iterate (\u21d1f) n :=\n  sorry\n\ntheorem iterate_map_one {R : Type u_5} [semiring R] (f : R \u2192+* R) (n : \u2115) :\n    nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) :\n    nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (x : R) (y : R) :\n    nat.iterate (\u21d1f) n (x + y) = nat.iterate (\u21d1f) n x + nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (x : R) (y : R) :\n    nat.iterate (\u21d1f) n (x * y) = nat.iterate (\u21d1f) n x * nat.iterate (\u21d1f) 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 \u2192+* R) (a : R) (n : \u2115) (m : \u2115) :\n    nat.iterate (\u21d1f) n (a ^ m) = nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (m : \u2115) (x : R) :\n    nat.iterate (\u21d1f) n (m \u2022\u2115 x) = m \u2022\u2115 nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (x : R) (y : R) :\n    nat.iterate (\u21d1f) n (x - y) = nat.iterate (\u21d1f) n x - nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (x : R) :\n    nat.iterate (\u21d1f) n (-x) = -nat.iterate (\u21d1f) 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 \u2192+* R) (n : \u2115) (m : \u2124) (x : R) :\n    nat.iterate (\u21d1f) n (m \u2022\u2124 x) = m \u2022\u2124 nat.iterate (\u21d1f) 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 : \u2115) :\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 : \u2115) :\n    nat.iterate (Add.add a) n = Add.add (n \u2022\u2115 a) :=\n  mul_left_iterate a n\n\n@[simp] theorem mul_right_iterate {M : Type u_1} [monoid M] (a : M) (n : \u2115) :\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 : \u2115) :\n    nat.iterate (fun (x : M) => x + a) n = fun (x : M) => x + n \u2022\u2115 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 `(\u2022) : A i \u2192 M j \u2192 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 {\u03b9 : Type*}\n\nnamespace graded_monoid\n\n/-! ### Typeclasses -/\nsection defs\n\nvariables (A : \u03b9 \u2192 Type*) (M : \u03b9 \u2192 Type*)\n\n/-- A graded version of `has_smul`. Scalar multiplication combines grades additively, i.e.\nif `a \u2208 A i` and `m \u2208 M j`, then `a \u2022 b` must be in `M (i + j)`-/\nclass ghas_smul [has_add \u03b9] :=\n(smul {i j} : A i \u2192 M j \u2192 M (i + j))\n\n/-- A graded version of `has_mul.to_has_smul` -/\ninstance ghas_mul.to_ghas_smul [has_add \u03b9] [ghas_mul A] : ghas_smul A A :=\n{ smul := \u03bb _ _, ghas_mul.mul }\n\ninstance ghas_smul.to_has_smul [has_add \u03b9] [ghas_smul A M] :\n  has_smul (graded_monoid A) (graded_monoid M) :=\n\u27e8\u03bb (x : graded_monoid A) (y : graded_monoid M), \u27e8_, ghas_smul.smul x.snd y.snd\u27e9\u27e9\n\nlemma mk_smul_mk [has_add \u03b9] [ghas_smul A M] {i j} (a : A i) (b : M j) :\n  mk i a \u2022 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 \u03b9] [gmonoid A] extends ghas_smul A M :=\n(one_smul (b : graded_monoid M) : (1 : graded_monoid A) \u2022 b = b)\n(mul_smul (a a' : graded_monoid A) (b : graded_monoid M) : (a * a') \u2022 b = a \u2022 a' \u2022 b)\n\n/-- The graded version of `monoid.to_mul_action`. -/\ninstance gmonoid.to_gmul_action [add_monoid \u03b9] [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 \u03b9] [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 \u03b9] (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) : Prop :=\n(smul_mem : \u2200 \u2983i j : \u03b9\u2984 {ai bj}, ai \u2208 A i \u2192 bj \u2208 B j \u2192 ai \u2022 bj \u2208 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 \u03b9] (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) [set_like.has_graded_smul A B] :\n  graded_monoid.ghas_smul (\u03bb i, A i) (\u03bb i, B i) :=\n{ smul := \u03bb i j a b, \u27e8(a : R) \u2022 b, set_like.has_graded_smul.smul_mem a.2 b.2\u27e9 }\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 \u03b9] (A : \u03b9 \u2192 S) (B : \u03b9 \u2192 N) [set_like.has_graded_smul A B]\n  {i j : \u03b9} (x : A i) (y : B j) :\n  (@graded_monoid.ghas_smul.smul \u03b9 (\u03bb i, A i) (\u03bb i, B i) _ _ i j x y : M) = ((x : R) \u2022 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 \u03b9] [monoid R]\n  {S : Type*} [set_like S R] (A : \u03b9 \u2192 S) [set_like.graded_monoid A] :\n  set_like.has_graded_smul A A :=\n{ smul_mem := \u03bb 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 \u03b9] [has_smul R M] {A : \u03b9 \u2192 S} {B : \u03b9 \u2192 N}\n  [set_like.has_graded_smul A B] {a : R} {b : M} :\n  set_like.is_homogeneous A a \u2192 set_like.is_homogeneous B b \u2192 set_like.is_homogeneous B (a \u2022 b)\n| \u27e8i, hi\u27e9 \u27e8j, hj\u27e9 := \u27e8i + j, set_like.has_graded_smul.smul_mem hi hj\u27e9\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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 `\u03b1 \u2192. \u03b2` into a function\n`option \u03b1 \u2192 option \u03b2` 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 {\u03b1 \u03b2 : 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* := \u27e8id\u27e9\n\n/-- Turns a type into a `PartialFun`. -/\n@[nolint has_nonempty_instance] def of : Type* \u2192 PartialFun := id\n\n@[simp] lemma coe_of (X : Type*) : \u21a5(of X) = X := rfl\n\ninstance : inhabited PartialFun := \u27e8Type*\u27e9\n\ninstance large_category : large_category.{u} PartialFun :=\n{ hom := pfun,\n  id := pfun.id,\n  comp := \u03bb X Y Z f g, g.comp f,\n  id_comp' := @pfun.comp_id,\n  comp_id' := @pfun.id_comp,\n  assoc' := \u03bb 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 {\u03b1 \u03b2 : PartialFun.{u}} (e : \u03b1 \u2243 \u03b2) : \u03b1 \u2245 \u03b2 :=\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} \u2964 PartialFun :=\n{ obj := id,\n  map := @pfun.lift,\n  map_comp' := \u03bb _ _ _ _ _, pfun.coe_comp _ _ }\n\ninstance : faithful Type_to_PartialFun := \u27e8\u03bb X Y, pfun.coe_injective\u27e9\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} \u2964 PartialFun :=\n{ obj := \u03bb X, {x : X // x \u2260 X.point},\n  map := \u03bb X Y f, pfun.to_subtype _ f.to_fun \u2218 subtype.val,\n  map_id' := \u03bb X, pfun.ext $ \u03bb a b,\n    pfun.mem_to_subtype_iff.trans (subtype.coe_inj.trans part.mem_some_iff.symm),\n  map_comp' := \u03bb X Y Z f g, pfun.ext $ \u03bb 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 \u27e8\u03bb h, \u27e8f.to_fun a, \u03bb ha, c.2 $ h.trans\n      ((congr_arg g.to_fun ha : g.to_fun _ = _).trans g.map_point), rfl, h\u27e9, _\u27e9,\n    rintro \u27e8b, _, (rfl : b = _), h\u27e9,\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 \u2964 Pointed :=\nby classical; exact\n{ obj := \u03bb X, \u27e8option X, none\u27e9,\n  map := \u03bb X Y f, \u27e8option.elim none (\u03bb a, (f a).to_option), rfl\u27e9,\n  map_id' := \u03bb X, Pointed.hom.ext _ _ $ funext $ \u03bb o,\n    option.rec_on o rfl $ \u03bb a, part.some_to_option _,\n  map_comp' := \u03bb X Y Z f g, Pointed.hom.ext _ _ $ funext $ \u03bb o, option.rec_on o rfl $ \u03bb 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} \u224c Pointed :=\nby classical; exact\nequivalence.mk PartialFun_to_Pointed Pointed_to_PartialFun\n  (nat_iso.of_components (\u03bb X, PartialFun.iso.mk\n    { to_fun := \u03bb a, \u27e8some a, some_ne_none a\u27e9,\n      inv_fun := \u03bb a, get $ ne_none_iff_is_some.1 a.2,\n      left_inv := \u03bb a, get_some _ _,\n      right_inv := \u03bb a, by simp only [subtype.val_eq_coe, some_get, subtype.coe_eta] }) $ \u03bb X Y f,\n      pfun.ext $ \u03bb 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 \u27e8b | b, hb\u27e9 := 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 (\u03bb X, Pointed.iso.mk\n    { to_fun := option.elim X.point subtype.val,\n      inv_fun := \u03bb a, if h : a = X.point then none else some \u27e8_, h\u27e9,\n      left_inv := \u03bb a, option.rec_on a (dif_pos rfl) $ \u03bb a, (dif_neg a.2).trans $\n        by simp only [option.elim, subtype.val_eq_coe, subtype.coe_eta],\n      right_inv := \u03bb a, begin\n        change option.elim _ _ (dite _ _ _) = _,\n        split_ifs,\n        { rw h, refl },\n        { refl }\n      end } rfl) $ \u03bb X Y f, Pointed.hom.ext _ _ $ funext $ \u03bb a, option.rec_on a f.map_point.symm $\n    \u03bb 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 \u22d9 PartialFun_to_Pointed \u2245 Type_to_Pointed :=\nnat_iso.of_components (\u03bb X, { hom := \u27e8id, rfl\u27e9,\n                              inv := \u27e8id, rfl\u27e9,\n                              hom_inv_id' := rfl,\n                              inv_hom_id' := rfl }) $ \u03bb X Y f,\n  Pointed.hom.ext _ _ $ funext $ \u03bb a, option.rec_on a rfl $ \u03bb 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\u2082\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 \u2243 walking_pair :=\n{ to_fun := \u03bb j, walking_pair.rec_on j right left,\n  inv_fun := \u03bb j, walking_pair.rec_on j right left,\n  left_inv := \u03bb j, by { cases j; refl, },\n  right_inv := \u03bb 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 \u2243 bool :=\n{ to_fun := \u03bb j, walking_pair.rec_on j tt ff, -- to match equiv.sum_equiv_sigma_bool\n  inv_fun := \u03bb b, bool.rec_on b right left,\n  left_inv := \u03bb j, by { cases j; refl, },\n  right_inv := \u03bb 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 \u2964 C :=\ndiscrete.functor (\u03bb 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} \u2964 C} (f : F.obj left \u27f6 G.obj left)\n  (g : F.obj right \u27f6 G.obj right)\n\n/-- The natural transformation between two functors out of the walking pair, specified by its\ncomponents. -/\ndef map_pair : F \u27f6 G := { app := \u03bb 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 \u2245 G.obj left) (g : F.obj right \u2245 G.obj right) : F \u2245 G :=\nnat_iso.of_components (\u03bb 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 \u2964 C) :\n  F \u2245 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 \u22d9 F` and `pair (F.obj X) (F.obj Y)`. -/\ndef pair_comp (X Y : C) (F : C \u2964 D) : pair X Y \u22d9 F \u2245 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.\u03c0.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.\u03c0.app walking_pair.right\n\n@[simp] lemma binary_fan.\u03c0_app_left {X Y : C} (s : binary_fan X Y) :\n  s.\u03c0.app walking_pair.left = s.fst := rfl\n@[simp] lemma binary_fan.\u03c0_app_right {X Y : C} (s : binary_fan X Y) :\n  s.\u03c0.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 \u27f6 s.X} (h\u2081 : f \u226b s.fst = g \u226b s.fst) (h\u2082 : f \u226b s.snd = g \u226b s.snd) : f = g :=\nh.hom_ext $ \u03bb j, walking_pair.cases_on j h\u2081 h\u2082\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.\u03b9.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.\u03b9.app walking_pair.right\n\n@[simp] lemma binary_cofan.\u03b9_app_left {X Y : C} (s : binary_cofan X Y) :\n  s.\u03b9.app walking_pair.left = s.inl := rfl\n@[simp] lemma binary_cofan.\u03b9_app_right {X Y : C} (s : binary_cofan X Y) :\n  s.\u03b9.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 \u27f6 W} (h\u2081 : s.inl \u226b f = s.inl \u226b g) (h\u2082 : s.inr \u226b f = s.inr \u226b g) : f = g :=\nh.hom_ext $ \u03bb j, walking_pair.cases_on j h\u2081 h\u2082\n\nvariables {X Y : C}\n\n/-- A binary fan with vertex `P` consists of the two projections `\u03c0\u2081 : P \u27f6 X` and `\u03c0\u2082 : P \u27f6 Y`. -/\n@[simps X]\ndef binary_fan.mk {P : C} (\u03c0\u2081 : P \u27f6 X) (\u03c0\u2082 : P \u27f6 Y) : binary_fan X Y :=\n{ X := P,\n  \u03c0 := { app := \u03bb j, walking_pair.cases_on j \u03c0\u2081 \u03c0\u2082 }}\n\n/-- A binary cofan with vertex `P` consists of the two inclusions `\u03b9\u2081 : X \u27f6 P` and `\u03b9\u2082 : Y \u27f6 P`. -/\n@[simps X]\ndef binary_cofan.mk {P : C} (\u03b9\u2081 : X \u27f6 P) (\u03b9\u2082 : Y \u27f6 P) : binary_cofan X Y :=\n{ X := P,\n  \u03b9 := { app := \u03bb j, walking_pair.cases_on j \u03b9\u2081 \u03b9\u2082 }}\n\n@[simp] lemma binary_fan.mk_\u03c0_app_left {P : C} (\u03c0\u2081 : P \u27f6 X) (\u03c0\u2082 : P \u27f6 Y) :\n  (binary_fan.mk \u03c0\u2081 \u03c0\u2082).\u03c0.app walking_pair.left = \u03c0\u2081 := rfl\n@[simp] lemma binary_fan.mk_\u03c0_app_right {P : C} (\u03c0\u2081 : P \u27f6 X) (\u03c0\u2082 : P \u27f6 Y) :\n  (binary_fan.mk \u03c0\u2081 \u03c0\u2082).\u03c0.app walking_pair.right = \u03c0\u2082 := rfl\n@[simp] lemma binary_cofan.mk_\u03b9_app_left {P : C} (\u03b9\u2081 : X \u27f6 P) (\u03b9\u2082 : Y \u27f6 P) :\n  (binary_cofan.mk \u03b9\u2081 \u03b9\u2082).\u03b9.app walking_pair.left = \u03b9\u2081 := rfl\n@[simp] lemma binary_cofan.mk_\u03b9_app_right {P : C} (\u03b9\u2081 : X \u27f6 P) (\u03b9\u2082 : Y \u27f6 P) :\n  (binary_cofan.mk \u03b9\u2081 \u03b9\u2082).\u03b9.app walking_pair.right = \u03b9\u2082 := rfl\n\n/-- If `s` is a limit binary fan over `X` and `Y`, then every pair of morphisms `f : W \u27f6 X` and\n    `g : W \u27f6 Y` induces a morphism `l : W \u27f6 s.X` satisfying `l \u226b s.fst = f` and `l \u226b 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 \u27f6 X)\n  (g : W \u27f6 Y) : {l : W \u27f6 s.X // l \u226b s.fst = f \u2227 l \u226b s.snd = g} :=\n\u27e8h.lift $ binary_fan.mk f g, h.fac _ _, h.fac _ _\u27e9\n\n/-- If `s` is a colimit binary cofan over `X` and `Y`,, then every pair of morphisms `f : X \u27f6 W` and\n    `g : Y \u27f6 W` induces a morphism `l : s.X \u27f6 W` satisfying `s.inl \u226b l = f` and `s.inr \u226b 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 \u27f6 W)\n  (g : Y \u27f6 W) : {l : s.X \u27f6 W // s.inl \u226b l = f \u2227 s.inr \u226b l = g} :=\n\u27e8h.desc $ binary_cofan.mk f g, h.fac _ _, h.fac _ _\u27e9\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 \u2a2f 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 \u2a3f Y`. -/\nabbreviation coprod (X Y : C) [has_binary_coproduct X Y] := colimit (pair X Y)\n\nnotation X ` \u2a2f `:20 Y:20 := prod X Y\nnotation X ` \u2a3f `: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 \u2a2f Y \u27f6 X :=\nlimit.\u03c0 (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 \u2a2f Y \u27f6 Y :=\nlimit.\u03c0 (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 \u27f6 X \u2a3f Y :=\ncolimit.\u03b9 (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 \u27f6 X \u2a3f Y :=\ncolimit.\u03b9 (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 \u2a2f Y \u27f6 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 \u27f6 X \u2a3f 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 \u27f6 X \u2a2f Y}\n  (h\u2081 : f \u226b prod.fst = g \u226b prod.fst) (h\u2082 : f \u226b prod.snd = g \u226b prod.snd) : f = g :=\nbinary_fan.is_limit.hom_ext (limit.is_limit _) h\u2081 h\u2082\n\n@[ext] lemma coprod.hom_ext {W X Y : C} [has_binary_coproduct X Y] {f g : X \u2a3f Y \u27f6 W}\n  (h\u2081 : coprod.inl \u226b f = coprod.inl \u226b g) (h\u2082 : coprod.inr \u226b f = coprod.inr \u226b g) : f = g :=\nbinary_cofan.is_colimit.hom_ext (colimit.is_colimit _) h\u2081 h\u2082\n\n/-- If the product of `X` and `Y` exists, then every pair of morphisms `f : W \u27f6 X` and `g : W \u27f6 Y`\n    induces a morphism `prod.lift f g : W \u27f6 X \u2a2f Y`. -/\nabbreviation prod.lift {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 Y) : W \u27f6 X \u2a2f 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 \u27f6 X \u2a2f X :=\nprod.lift (\ud835\udfd9 _) (\ud835\udfd9 _)\n\n/-- If the coproduct of `X` and `Y` exists, then every pair of morphisms `f : X \u27f6 W` and\n    `g : Y \u27f6 W` induces a morphism `coprod.desc f g : X \u2a3f Y \u27f6 W`. -/\nabbreviation coprod.desc {W X Y : C} [has_binary_coproduct X Y] (f : X \u27f6 W) (g : Y \u27f6 W) :\n  X \u2a3f Y \u27f6 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 \u2a3f X \u27f6 X :=\ncoprod.desc (\ud835\udfd9 _) (\ud835\udfd9 _)\n\n@[simp, reassoc]\nlemma prod.lift_fst {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 Y) :\n  prod.lift f g \u226b prod.fst = f :=\nlimit.lift_\u03c0 _ _\n\n@[simp, reassoc]\nlemma prod.lift_snd {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 Y) :\n  prod.lift f g \u226b prod.snd = g :=\nlimit.lift_\u03c0 _ _\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 \u27f6 W) (g : Y \u27f6 W) :\n  coprod.inl \u226b coprod.desc f g = f :=\ncolimit.\u03b9_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 \u27f6 W) (g : Y \u27f6 W) :\n  coprod.inr \u226b coprod.desc f g = g :=\ncolimit.\u03b9_desc _ _\n\ninstance prod.mono_lift_of_mono_left {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 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 \u27f6 X) (g : W \u27f6 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 \u27f6 W) (g : Y \u27f6 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 \u27f6 W) (g : Y \u27f6 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 \u27f6 X` and `g : W \u27f6 Y`\n    induces a morphism `l : W \u27f6 X \u2a2f Y` satisfying `l \u226b prod.fst = f` and `l \u226b prod.snd = g`. -/\ndef prod.lift' {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 Y) :\n  {l : W \u27f6 X \u2a2f Y // l \u226b prod.fst = f \u2227 l \u226b prod.snd = g} :=\n\u27e8prod.lift f g, prod.lift_fst _ _, prod.lift_snd _ _\u27e9\n\n/-- If the coproduct of `X` and `Y` exists, then every pair of morphisms `f : X \u27f6 W` and\n    `g : Y \u27f6 W` induces a morphism `l : X \u2a3f Y \u27f6 W` satisfying `coprod.inl \u226b l = f` and\n    `coprod.inr \u226b l = g`. -/\ndef coprod.desc' {W X Y : C} [has_binary_coproduct X Y] (f : X \u27f6 W) (g : Y \u27f6 W) :\n  {l : X \u2a3f Y \u27f6 W // coprod.inl \u226b l = f \u2227 coprod.inr \u226b l = g} :=\n\u27e8coprod.desc f g, coprod.inl_desc _ _, coprod.inr_desc _ _\u27e9\n\n/-- If the products `W \u2a2f X` and `Y \u2a2f Z` exist, then every pair of morphisms `f : W \u27f6 Y` and\n    `g : X \u27f6 Z` induces a morphism `prod.map f g : W \u2a2f X \u27f6 Y \u2a2f Z`. -/\ndef prod.map {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W \u27f6 Y) (g : X \u27f6 Z) : W \u2a2f X \u27f6 Y \u2a2f Z :=\nlim_map (map_pair f g)\n\n/-- If the coproducts `W \u2a3f X` and `Y \u2a3f Z` exist, then every pair of morphisms `f : W \u27f6 Y` and\n    `g : W \u27f6 Z` induces a morphism `coprod.map f g : W \u2a3f X \u27f6 Y \u2a3f Z`. -/\ndef coprod.map {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W \u27f6 Y) (g : X \u27f6 Z) : W \u2a3f X \u27f6 Y \u2a3f 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 \u27f6 W) (g : W \u27f6 X) (h : W \u27f6 Y) :\n  f \u226b prod.lift g h = prod.lift (f \u226b g) (f \u226b h) :=\nby { ext; simp }\n\nlemma prod.comp_diag {X Y : C} [has_binary_product Y Y] (f : X \u27f6 Y) :\n  f \u226b 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 \u27f6 Y) (g : X \u27f6 Z) : prod.map f g \u226b prod.fst = prod.fst \u226b f :=\nlim_map_\u03c0 _ _\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 \u27f6 Y) (g : X \u27f6 Z) : prod.map f g \u226b prod.snd = prod.snd \u226b g :=\nlim_map_\u03c0 _ _\n\n@[simp] lemma prod.map_id_id {X Y : C} [has_binary_product X Y] :\n  prod.map (\ud835\udfd9 X) (\ud835\udfd9 Y) = \ud835\udfd9 _ :=\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 = \ud835\udfd9 (X \u2a2f 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 \u27f6 W) (g : V \u27f6 X) (h : W \u27f6 Y) (k : X \u27f6 Z) :\n  prod.lift f g \u226b prod.map h k = prod.lift (f \u226b h) (g \u226b 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 \u27f6 X) (g' : Y \u27f6 Z) :\n  prod.lift (prod.fst \u226b g) (prod.snd \u226b g') = prod.map g g' :=\nby { rw \u2190 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 \u226b h` and `g \u226b 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\u2081 A\u2082 A\u2083 B\u2081 B\u2082 B\u2083 : C}\n  [has_binary_product A\u2081 B\u2081] [has_binary_product A\u2082 B\u2082] [has_binary_product A\u2083 B\u2083]\n  (f : A\u2081 \u27f6 A\u2082) (g : B\u2081 \u27f6 B\u2082) (h : A\u2082 \u27f6 A\u2083) (k : B\u2082 \u27f6 B\u2083) :\n  prod.map f g \u226b prod.map h k = prod.map (f \u226b h) (g \u226b 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 \u27f6 B) (g : X \u27f6 Y)\n  [has_limits_of_shape (discrete walking_pair) C] :\n  prod.map (\ud835\udfd9 X) f \u226b prod.map g (\ud835\udfd9 B) = prod.map g (\ud835\udfd9 A) \u226b prod.map (\ud835\udfd9 Y) f :=\nby simp\n\n@[reassoc] lemma prod.map_comp_id {X Y Z W : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [has_binary_product X W] [has_binary_product Z W] [has_binary_product Y W] :\n  prod.map (f \u226b g) (\ud835\udfd9 W) = prod.map f (\ud835\udfd9 W) \u226b prod.map g (\ud835\udfd9 W) :=\nby simp\n\n@[reassoc] lemma prod.map_id_comp {X Y Z W : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [has_binary_product W X] [has_binary_product W Y] [has_binary_product W Z] :\n  prod.map (\ud835\udfd9 W) (f \u226b g) = prod.map (\ud835\udfd9 W) f \u226b prod.map (\ud835\udfd9 W) g :=\nby simp\n\n/-- If the products `W \u2a2f X` and `Y \u2a2f Z` exist, then every pair of isomorphisms `f : W \u2245 Y` and\n    `g : X \u2245 Z` induces an isomorphism `prod.map_iso f g : W \u2a2f X \u2245 Y \u2a2f 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 \u2245 Y) (g : X \u2245 Z) : W \u2a2f X \u2245 Y \u2a2f 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Y) [has_binary_product X X] [has_binary_product Y Y] :\n  diag X \u226b prod.map f f = f \u226b 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 \u2a2f Y) (X \u2a2f Y)] :\n  diag (X \u2a2f Y) \u226b prod.map prod.fst prod.snd = \ud835\udfd9 (X \u2a2f 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 \u27f6 Y) (g' : X' \u27f6 Y') :\n  diag (X \u2a2f X') \u226b prod.map (prod.fst \u226b g) (prod.snd \u226b 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 \u27f6 W) (g : X \u27f6 V)\n  (h : Y \u27f6 V) :\n  coprod.desc g h \u226b f = coprod.desc (g \u226b f) (h \u226b f) :=\nby { ext; simp }\n\nlemma coprod.diag_comp {X Y : C} [has_binary_coproduct X X] (f : X \u27f6 Y) :\n  codiag X \u226b 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 \u27f6 Y) (g : X \u27f6 Z) : coprod.inl \u226b coprod.map f g = f \u226b coprod.inl :=\n\u03b9_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 \u27f6 Y) (g : X \u27f6 Z) : coprod.inr \u226b coprod.map f g = g \u226b coprod.inr :=\n\u03b9_colim_map _ _\n\n@[simp]\nlemma coprod.map_id_id {X Y : C} [has_binary_coproduct X Y] :\n  coprod.map (\ud835\udfd9 X) (\ud835\udfd9 Y) = \ud835\udfd9 _ :=\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 = \ud835\udfd9 (X \u2a3f 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 \u27f6 S) (g : W \u27f6 S) (h : T \u27f6 U) (k : V \u27f6 W) :\n  coprod.map h k \u226b coprod.desc f g = coprod.desc (h \u226b f) (k \u226b 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 \u27f6 X) (g' : Y \u27f6 Z) :\n  coprod.desc (g \u226b coprod.inl) (g' \u226b coprod.inr) = coprod.map g g' :=\nby { rw \u2190 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 \u226b h` and `g \u226b 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\u2081 A\u2082 A\u2083 B\u2081 B\u2082 B\u2083 : C}\n  [has_binary_coproduct A\u2081 B\u2081] [has_binary_coproduct A\u2082 B\u2082] [has_binary_coproduct A\u2083 B\u2083]\n  (f : A\u2081 \u27f6 A\u2082) (g : B\u2081 \u27f6 B\u2082) (h : A\u2082 \u27f6 A\u2083) (k : B\u2082 \u27f6 B\u2083) :\n  coprod.map f g \u226b coprod.map h k = coprod.map (f \u226b h) (g \u226b 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 \u27f6 B) (g : X \u27f6 Y)\n  [has_colimits_of_shape (discrete walking_pair) C] :\n  coprod.map (\ud835\udfd9 X) f \u226b coprod.map g (\ud835\udfd9 B) = coprod.map g (\ud835\udfd9 A) \u226b coprod.map (\ud835\udfd9 Y) f :=\nby simp\n\n@[reassoc] lemma coprod.map_comp_id {X Y Z W : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [has_binary_coproduct Z W] [has_binary_coproduct Y W] [has_binary_coproduct X W] :\n  coprod.map (f \u226b g) (\ud835\udfd9 W) = coprod.map f (\ud835\udfd9 W) \u226b coprod.map g (\ud835\udfd9 W) :=\nby simp\n\n@[reassoc] lemma coprod.map_id_comp {X Y Z W : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [has_binary_coproduct W X] [has_binary_coproduct W Y] [has_binary_coproduct W Z] :\n  coprod.map (\ud835\udfd9 W) (f \u226b g) = coprod.map (\ud835\udfd9 W) f \u226b coprod.map (\ud835\udfd9 W) g :=\nby simp\n\n/-- If the coproducts `W \u2a3f X` and `Y \u2a3f Z` exist, then every pair of isomorphisms `f : W \u2245 Y` and\n    `g : W \u2245 Z` induces a isomorphism `coprod.map_iso f g : W \u2a3f X \u2245 Y \u2a3f 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 \u2245 Y) (g : X \u2245 Z) : W \u2a3f X \u2245 Y \u2a3f 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Y) [has_binary_coproduct X X]\n  [has_binary_coproduct Y Y] :\n  coprod.map f f \u226b codiag Y = codiag X \u226b 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 \u2a3f Y) (X \u2a3f Y)] :\n  coprod.map coprod.inl coprod.inr \u226b codiag (X \u2a3f Y) = \ud835\udfd9 (X \u2a3f 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 \u27f6 Y) (g' : X' \u27f6 Y') :\n  coprod.map (g \u226b coprod.inl) (g' \u226b coprod.inr) \u226b codiag (Y \u2a3f 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 [\u03a0 {X Y : C}, has_limit (pair X Y)] :\n  has_binary_products C :=\n{ has_limit := \u03bb 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 [\u03a0 {X Y : C}, has_colimit (pair X Y)] :\n  has_binary_coproducts C :=\n{ has_colimit := \u03bb 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 \u2a2f Q \u2245 Q \u2a2f 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 \u27f6 Y) (g : Z \u27f6 W) :\n  prod.map f g \u226b (prod.braiding _ _).hom = (prod.braiding _ _).hom \u226b 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 \u226b prod.lift prod.snd prod.fst = \ud835\udfd9 (P \u2a2f 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 \u226b (prod.braiding Q P).hom = \ud835\udfd9 _ :=\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 \u2a2f Q) \u2a2f R \u2245 P \u2a2f (Q \u2a2f R) :=\n{ hom :=\n  prod.lift\n    (prod.fst \u226b prod.fst)\n    (prod.lift (prod.fst \u226b prod.snd) prod.snd),\n  inv :=\n  prod.lift\n    (prod.lift prod.fst (prod.snd \u226b prod.fst))\n    (prod.snd \u226b 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) (\ud835\udfd9 Z) \u226b\n      (prod.associator W (X \u2a2f Y) Z).hom \u226b prod.map (\ud835\udfd9 W) ((prod.associator X Y Z).hom) =\n    (prod.associator (W \u2a2f X) Y Z).hom \u226b (prod.associator W X (Y \u2a2f Z)).hom :=\nby simp\n\n@[reassoc]\nlemma prod.associator_naturality [has_binary_products C] {X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : C}\n  (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083) :\n  prod.map (prod.map f\u2081 f\u2082) f\u2083 \u226b (prod.associator Y\u2081 Y\u2082 Y\u2083).hom =\n    (prod.associator X\u2081 X\u2082 X\u2083).hom \u226b prod.map f\u2081 (prod.map f\u2082 f\u2083) :=\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 (\u22a4_ C) P] :\n  \u22a4_ C \u2a2f P \u2245 P :=\n{ hom := prod.snd,\n  inv := prod.lift (terminal.from P) (\ud835\udfd9 _) }\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 (\u22a4_ C)] :\n  P \u2a2f \u22a4_ C \u2245 P :=\n{ hom := prod.fst,\n  inv := prod.lift (\ud835\udfd9 _) (terminal.from P) }\n\n@[reassoc]\nlemma prod.left_unitor_hom_naturality [has_binary_products C] (f : X \u27f6 Y) :\n  prod.map (\ud835\udfd9 _) f \u226b (prod.left_unitor Y).hom = (prod.left_unitor X).hom \u226b f :=\nprod.map_snd _ _\n\n@[reassoc]\nlemma prod.left_unitor_inv_naturality [has_binary_products C] (f : X \u27f6 Y) :\n  (prod.left_unitor X).inv \u226b prod.map (\ud835\udfd9 _) f = f \u226b (prod.left_unitor Y).inv :=\nby rw [iso.inv_comp_eq, \u2190 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 \u27f6 Y) :\n  prod.map f (\ud835\udfd9 _) \u226b (prod.right_unitor Y).hom = (prod.right_unitor X).hom \u226b f :=\nprod.map_fst _ _\n\n@[reassoc]\nlemma prod_right_unitor_inv_naturality [has_binary_products C] (f : X \u27f6 Y) :\n  (prod.right_unitor X).inv \u226b prod.map f (\ud835\udfd9 _) = f \u226b (prod.right_unitor Y).inv :=\nby rw [iso.inv_comp_eq, \u2190 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 (\u22a4_ C) Y).hom \u226b prod.map (\ud835\udfd9 X) ((prod.left_unitor Y).hom) =\n    prod.map ((prod.right_unitor X).hom) (\ud835\udfd9 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 \u2a3f Q \u2245 Q \u2a3f 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 \u226b coprod.desc coprod.inr coprod.inl = \ud835\udfd9 (P \u2a3f 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 \u226b (coprod.braiding Q P).hom = \ud835\udfd9 _ :=\ncoprod.symmetry' _ _\n\n/-- The associator isomorphism for binary coproducts. -/\n@[simps] def coprod.associator\n  (P Q R : C) : (P \u2a3f Q) \u2a3f R \u2245 P \u2a3f (Q \u2a3f R) :=\n{ hom :=\n  coprod.desc\n    (coprod.desc coprod.inl (coprod.inl \u226b coprod.inr))\n    (coprod.inr \u226b coprod.inr),\n  inv :=\n  coprod.desc\n    (coprod.inl \u226b coprod.inl)\n    (coprod.desc (coprod.inr \u226b coprod.inl) coprod.inr) }\n\nlemma coprod.pentagon (W X Y Z : C) :\n  coprod.map ((coprod.associator W X Y).hom) (\ud835\udfd9 Z) \u226b\n      (coprod.associator W (X \u2a3f Y) Z).hom \u226b coprod.map (\ud835\udfd9 W) ((coprod.associator X Y Z).hom) =\n    (coprod.associator (W \u2a3f X) Y Z).hom \u226b (coprod.associator W X (Y \u2a3f Z)).hom :=\nby simp\n\nlemma coprod.associator_naturality {X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082)\n  (f\u2083 : X\u2083 \u27f6 Y\u2083) :\n  coprod.map (coprod.map f\u2081 f\u2082) f\u2083 \u226b (coprod.associator Y\u2081 Y\u2082 Y\u2083).hom =\n    (coprod.associator X\u2081 X\u2082 X\u2083).hom \u226b coprod.map f\u2081 (coprod.map f\u2082 f\u2083) :=\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) : \u22a5_ C \u2a3f P \u2245 P :=\n{ hom := coprod.desc (initial.to P) (\ud835\udfd9 _),\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 \u2a3f \u22a5_ C \u2245 P :=\n{ hom := coprod.desc (\ud835\udfd9 _) (initial.to P),\n  inv := coprod.inl }\n\nlemma coprod.triangle (X Y : C) :\n  (coprod.associator X (\u22a5_ C) Y).hom \u226b coprod.map (\ud835\udfd9 X) ((coprod.left_unitor Y).hom) =\n    coprod.map ((coprod.right_unitor X).hom) (\ud835\udfd9 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 \u2964 C \u2964 C :=\n{ obj := \u03bb X, { obj := \u03bb Y, X \u2a2f Y, map := \u03bb Y Z, prod.map (\ud835\udfd9 X) },\n  map := \u03bb Y Z f, { app := \u03bb T, prod.map f (\ud835\udfd9 T) }}\n\n/-- The product functor can be decomposed. -/\ndef prod.functor_left_comp (X Y : C) :\n  prod.functor.obj (X \u2a2f Y) \u2245 prod.functor.obj Y \u22d9 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 \u2964 C \u2964 C :=\n{ obj := \u03bb X, { obj := \u03bb Y, X \u2a3f Y, map := \u03bb Y Z, coprod.map (\ud835\udfd9 X) },\n  map := \u03bb Y Z f, { app := \u03bb T, coprod.map f (\ud835\udfd9 T) }}\n\n/-- The coproduct functor can be decomposed. -/\ndef coprod.functor_left_comp (X Y : C) :\n  coprod.functor.obj (X \u2a3f Y) \u2245 coprod.functor.obj Y \u22d9 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\u2082} [category.{v} D]\nvariables (F : C \u2964 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 \u2964 D) (A B : C)\n  [has_binary_product A B] [has_binary_product (F.obj A) (F.obj B)] :\n  F.obj (A \u2a2f B) \u27f6 F.obj A \u2a2f 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 \u226b prod.fst = F.map prod.fst :=\nprod.lift_fst _ _\n\n@[simp, reassoc]\nlemma prod_comparison_snd :\n  prod_comparison F A B \u226b 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 \u27f6 A') (g : B \u27f6 B') :\n  F.map (prod.map f g) \u226b prod_comparison F A' B' =\n    prod_comparison F A B \u226b prod.map (F.map f) (F.map g) :=\nbegin\n  rw [prod_comparison, prod_comparison, prod.lift_map, \u2190 F.map_comp, \u2190 F.map_comp,\n      prod.comp_lift, \u2190 F.map_comp, prod.map_fst, \u2190 F.map_comp, prod.map_snd]\nend\n\n/--\nThe product comparison morphism from `F(A \u2a2f -)` to `FA \u2a2f 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 \u2964 D) (A : C) :\n  prod.functor.obj A \u22d9 F \u27f6 F \u22d9 prod.functor.obj (F.obj A) :=\n{ app := \u03bb B, prod_comparison F A B,\n  naturality' := \u03bb 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) \u226b 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) \u226b 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 \u27f6 A') (g : B \u27f6 B')\n  [is_iso (prod_comparison F A B)] [is_iso (prod_comparison F A' B')] :\n  inv (prod_comparison F A B) \u226b F.map (prod.map f g) =\n    prod.map (F.map f) (F.map g) \u226b 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 \u2a2f -) \u2245 FA \u2a2f 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) [\u2200 B, is_iso (prod_comparison F A B)] :\n  prod.functor.obj A \u22d9 F \u2245 F \u22d9 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 \u27e8_, _\u27e9)) }\n\nend prod_comparison\n\nsection coprod_comparison\n\nvariables {C} {D : Type u\u2082} [category.{v} D]\nvariables (F : C \u2964 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 \u2964 D) (A B : C)\n  [has_binary_coproduct A B] [has_binary_coproduct (F.obj A) (F.obj B)] :\n  F.obj A \u2a3f F.obj B \u27f6 F.obj (A \u2a3f B) :=\ncoprod.desc (F.map coprod.inl) (F.map coprod.inr)\n\n@[simp, reassoc]\nlemma coprod_comparison_inl :\n  coprod.inl \u226b 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 \u27f6 A') (g : B \u27f6 B') :\n  coprod_comparison F A B \u226b F.map (coprod.map f g) =\n    coprod.map (F.map f) (F.map g) \u226b coprod_comparison F A' B' :=\nbegin\n  rw [coprod_comparison, coprod_comparison, coprod.map_desc, \u2190 F.map_comp, \u2190 F.map_comp,\n      coprod.desc_comp, \u2190 F.map_comp, coprod.inl_map, \u2190 F.map_comp, coprod.inr_map]\nend\n\n/--\nThe coproduct comparison morphism from `FA \u2a3f F-` to `F(A \u2a3f -)`, 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 \u2964 D) (A : C) :\n  F \u22d9 coprod.functor.obj (F.obj A) \u27f6 coprod.functor.obj A \u22d9 F :=\n{ app := \u03bb B, coprod_comparison F A B,\n  naturality' := \u03bb 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 \u226b 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 \u226b 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 \u27f6 A') (g : B \u27f6 B')\n  [is_iso (coprod_comparison F A B)] [is_iso (coprod_comparison F A' B')] :\n  inv (coprod_comparison F A B) \u226b coprod.map (F.map f) (F.map g) =\n    F.map (coprod.map f g) \u226b 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 \u2a3f F- \u2245 F(A \u2a3f -)`, 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) [\u2200 B, is_iso (coprod_comparison F A B)] :\n  F \u22d9 coprod.functor.obj (F.obj A) \u2245 coprod.functor.obj A \u22d9 F :=\n{ hom := coprod_comparison_nat_trans F A\n  ..(@as_iso _ _ _ _ _ (nat_iso.is_iso_of_is_iso_app \u27e8_, _\u27e9)) }\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 \u2192 over A \u2964 over A := \u03bb f,\n{ obj := \u03bb g, over.mk (coprod.desc f.hom g.hom),\n  map := \u03bb g\u2081 g\u2082 k, over.hom_mk (coprod.map (\ud835\udfd9 _) 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 \u2964 over A \u2964 over A :=\n{ obj := \u03bb f, over.coprod_obj f,\n  map := \u03bb f\u2081 f\u2082 k,\n  { app := \u03bb g, over.hom_mk (coprod.map k.left (\ud835\udfd9 _))\n      (by { dsimp, rw [coprod.map_desc, category.id_comp, over.w k] }),\n    naturality' := \u03bb f g k, by ext; { dsimp, simp, }, },\n  map_id' := \u03bb X, by ext; { dsimp, simp, },\n  map_comp' := \u03bb 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) \u2260 (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 \u2192 Y :=\nf\n\n/-!\nA term `f` of `C(X,Y)` is continuous, when considered as a function `X \u2192 Y`.\n-/\nexample (f : C(X,Y)) : continuous f :=\nf.continuous\n\n/-!\nConversely, any continuous function `X \u2192 Y` yields an element of `C(X,Y)`.\n-/\nexample (f : X \u2192 Y) (hf : continuous f) : C(X,Y) :=\n\u27e8f,hf\u27e9\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 \u27f6 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}\u1d52\u1d56 \u2964 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  \u2194\n-- For any finite indexing type `\u03b1`,\n  \u2200 (\u03b1 : Fintype.{0})\n-- profinite set `B`,\n    (B : Profinite.{0})\n-- family of profinite sets `X` indexed by `\u03b1`\n    (X : \u03b1 \u2192 Profinite.{0})\n-- which map to `B` with a family of maps `\u03c0`,\n    (\u03c0 : \u03a0 i, X i \u27f6 B)\n-- such that `\u03c0` is jointly surjective,\n    (h\u03c0 : \u2200 b : B, \u2203 i (x : X i), \u03c0 i x = b)\n-- and all families of elements `x i : F (op (X i))`,\n    (x : \u03a0 i, F (op (X i)))\n-- which are compatible on pullbacks `X i \u00d7_{B} X j`\n    (hx : \u2200 i j : \u03b1,\n      F.map (pullback.fst : pullback (\u03c0 i) (\u03c0 j) \u27f6 X i).op (x i) =\n      F.map (pullback.snd : pullback (\u03c0 i) (\u03c0 j) \u27f6 X j).op (x j)),\n-- there is a unique `s : F (op B)`\n    \u2203! s : F (op B),\n-- which restricts to `x i` over `X i` for all `i`.\n      \u2200 i, F.map (\u03c0 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 \u22d9 forget Ab).is_proetale_sheaf_of_types_tfae.out 0 2],\n  split,\n  { intros H \u03b1, exact H _ },\n  { introsI H \u03b1 _, exact H \u27e8\u03b1\u27e9 }\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}\u1d52\u1d56 \u2964 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}\u1d52\u1d56 \u2964 Ab.{1}) (hF : presheaf.is_sheaf proetale_topology F) :\n  Condensed.{0} Ab.{1} :=\n\u27e8F,hF\u27e9\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 \u2192 Expr \u2192 Expr\nopen Expr\n\ninfixl ` ~ `:100 := app\n\ninstance : inhabited Expr := \u27e8K\u27e9\n\ndef step : Expr \u2192 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\u2081 e\u2082 : Expr) : Prop :=\n\u2203 (n : \u2115), (step^[n]) e\u2081 = e\u2082\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\u2081 : a > b) (h\u2082 : b > c) : a > c :=\nbegin\n  cases h\u2081 with n\u2081 h\u2081, cases h\u2082 with n\u2082 h\u2082, use n\u2082 + n\u2081,\n  rw function.iterate_add_apply, substs h\u2081 h\u2082,\nend\n\nlemma not_reduces {a b} : \u00aca > b \u2194 \u2200 (n : \u2115), (step^[n]) a \u2260 b :=\nby simp [reduces]\n\n-----\n\ndef Expr.comb : Expr \u2192 Prop\n| (_ ~ _) := false\n| _ := true\n\nlemma term_induct {P : Expr \u2192 Prop} {a : Expr}\n  (h\u2081 : a.comb) (h\u2082 : P K) (h\u2083 : P S) (h\u2084 : 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 \u2194 a = b :=\nbegin\n  split; intro h\u2081,\n  { contrapose h\u2081, rw not_reduces, intro n, induction n with n ih,\n    { tauto },\n    { simp [h, ih] } },\n  { subst h\u2081 },\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 \u2194 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 \u00d7 Expr)}\n  (h\u2081 : t.comb)\n  (h\u2082 : \u2200 (p : Expr \u00d7 Expr), p \u2208 args \u2192 p.1 > p.2) :\n  function.uncurry (\u03bb a b, a > t \u2194 b > t)\n    (list.foldl (\u03bb (a p : Expr \u00d7 Expr), (a.1 ~ p.1, a.2 ~ p.2)) \u27e8f, f\u27e9 args) :=\nbegin\n  let m : Expr \u00d7 Expr := _,\n  change function.uncurry _ m,\n  change _ \u2194 _,\n  simp_rw reduces,\n  sorry\nend\n\nlemma app_reduces_iff_arg_reduces {t f a b : Expr}\n  (h\u2081 : t.comb)\n  (h\u2082 : a > b) :\n  f ~ a > t \u2194 f ~ b > t :=\nbegin\n  apply @apps_reduce_iff_args_reduce t f [(a, b)] h\u2081,\n  rintro p h\u2084, rw list.mem_singleton at h\u2084, subst p, exact h\u2082,\nend\n\n-----\n\ndef I := S ~ K ~ K\n\nlemma I_id {a} : I ~ a > a :=\n\u27e82, rfl\u27e9\n\n-----\n\ndef Expr.mk_diff (a : Expr) : Expr :=\nK ~ a\n\nlemma mk_diff_ne {a : Expr} : a.mk_diff \u2260 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 \u2192 Expr) \u2192 Expr \u2192 Prop\n-- | id : Func id I\n-- | comb {a : Expr} : a.comb \u2192 Func (\u03bb _, a) (K ~ a)\n-- | app {f\u2081 f\u2082 : Expr \u2192 Expr} {e\u2081 e\u2082 : Expr} :\n--   Func f\u2081 e\u2081 \u2192 Func f\u2082 e\u2082 \u2192 Func (\u03bb a, f\u2081 a ~ f\u2082 a) (S ~ e\u2081 ~ e\u2082)\n\n-- def func_coe_raw (f : Expr \u2192 Expr) : Expr :=\n-- if h : \u2203 (e : Expr), Func f e then h.some else default\n\n-- lemma exi_func_coe : \u2203 (f : (Expr \u2192 Expr) \u2192 Expr),\n--   (f id = I) \u2227\n--   (\u2200 (a : Expr), a.comb \u2192 f (\u03bb _, a) = K ~ a) \u2227\n--   (\u2200 (g\u2081 g\u2082 : Expr \u2192 Expr), f (\u03bb a, g\u2081 a ~ g\u2082 a) = S ~ f g\u2081 ~ f g\u2082) :=\n-- begin\n--   refine \u27e8func_coe_raw, _, _, _\u27e9; 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\u2081 := h.some_spec,\n--     induction' h\u2081,\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\u2081,\n--     have h\u2082 := h\u2081.some_spec,\n--     induction' h\u2082,\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\u2081 g\u2082,\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 : \u2115}\n\nlocal notation `rvec`:2000 n := matrix (fin 1) (fin n) \u211a\nlocal notation `cvec`:2000 m := matrix (fin m) (fin 1) \u211a\nlocal infix ` \u2b1d `:70 := matrix.mul\nlocal postfix `\u1d40` : 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 (\u03bb c : fin n, T.to_matrix obj c \u2260 0 \u2227 T.to_partition.colg c \u2209 T.restricted\n    \u2227 c \u2209 T.dead))\n  (((list.fin_range n).filter (\u03bb c : fin n, 0 < T.to_matrix obj c \u2227 c \u2209 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 \u211a (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 \u2264 to_lex T c i' \u2194\n  abs (T.const i 0 / T.to_matrix i c) < abs (T.const i' 0 / T.to_matrix i' c) \u2228\n    (abs (T.const i 0 / T.to_matrix i c) = abs (T.const i' 0 / T.to_matrix i' c) \u2227\n    T.to_partition.rowg i \u2264 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 (\u03bb i : fin m, obj \u2260 i \u2227 T.to_partition.rowg i \u2208 T.restricted\n  \u2227 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 \u2208 pivot_col T obj \u2192 ((T.to_matrix obj c \u2260 0 \u2227 T.to_partition.colg c \u2209 T.restricted)\n  \u2228 (0 < T.to_matrix obj c \u2227 T.to_partition.colg c \u2208 T.restricted)) \u2227 c \u2209 T.dead :=\nbegin\n  dsimp only [pivot_col],\n  cases h : fin.find (\u03bb c : fin n, T.to_matrix obj c \u2260 0 \u2227 T.to_partition.colg c \u2209 T.restricted\n    \u2227 c \u2209 T.dead),\n  { have := not_and.1 (fin.find_eq_none_iff.1 h c) \u2218 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 \u2208 pivot_col T obj) (hcres : T.to_partition.colg c \u2208 T.restricted)\n  (hdead : j \u2209 T.dead) (hjc : T.to_partition.colg j < T.to_partition.colg c) :\n  T.to_matrix obj j \u2264 0 :=\nbegin\n  rw [pivot_col] at hc,\n  cases h : fin.find (\u03bb c, T.to_matrix obj c \u2260 0 \u2227 colg (T.to_partition) c \u2209 T.restricted\n    \u2227 c \u2209 T.dead),\n  { rw h at hc,\n    refine le_of_not_lt (\u03bb 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 \u2192 c \u2209 T.dead \u2192\n  ((T.to_matrix obj c = 0 \u2227 T.to_partition.colg c \u2209 T.restricted)\n    \u2228 (T.to_matrix obj c \u2264 0 \u2227 T.to_partition.colg c \u2208 T.restricted)) :=\nbegin\n  simp only [pivot_col],\n  cases h : fin.find (\u03bb c : fin n, T.to_matrix obj c \u2260 0 \u2227 T.to_partition.colg c \u2209 T.restricted\n    \u2227 c \u2209 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 \u2208 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(\u03bb 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 \u2208 pivot_row T obj c \u2192\n  obj \u2260 i \u2227 T.to_partition.rowg i \u2208 T.restricted \u2227\n  T.to_matrix obj c / T.to_matrix i c < 0 \u2227\n  (\u2200 i' : fin m, obj \u2260 i' \u2192 T.to_partition.rowg i' \u2208 T.restricted \u2192\n    T.to_matrix obj c / T.to_matrix i' c < 0 \u2192\n  abs (T.const i 0 / T.to_matrix i c) \u2264 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' \u2208 T.restricted)\n  (hc : c \u2208 pivot_col T obj) (hrow : i \u2208 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 \u2264 T.to_matrix i' c :=\nif hobj : obj = i' then le_of_lt $ hobj \u25b8 hc0\nelse\nle_of_not_gt $ \u03bb hic, not_le_of_lt hjc\nbegin\n  have := (list.argmin_eq_some_iff.1 hrow).2.1 i'\n    (list.mem_filter.2 \u27e8list.mem_fin_range _, hobj, hres, div_neg_of_pos_of_neg hc0 hic\u27e9),\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 \u2208 pivot_row T obj c) : T.to_matrix i c \u2260 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 \u2208 pivot_col T obj) : T.to_matrix obj c \u2260 0 :=\n\u03bb 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 \u2208 pivot_col T obj) :\n  \u2200 i, obj \u2260 i \u2192 T.to_partition.rowg i \u2208 T.restricted \u2192 0 \u2264 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 \u2208 pivot_col T obj) :\n  T.is_unbounded_above (T.to_partition.rowg obj) :=\nhave hrow : \u2200 i, obj \u2260 i \u2192 T.to_partition.rowg i \u2208 T.restricted \u2192\n    0 \u2264 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 \u2260 0 \u2227 T.to_partition.colg c \u2209 T.restricted)\n    \u2228 (0 < T.to_matrix obj c \u2227 T.to_partition.colg c \u2208 T.restricted)) \u2227 c \u2209 T.dead,\n  from pivot_col_spec hs,\nhave hToc : T.to_matrix obj c \u2260 0, from \u03bb h, by simpa [h, lt_irrefl] using hc,\n(lt_or_gt_of_ne hToc).elim\n  (\u03bb hToc : T.to_matrix obj c < 0, is_unbounded_above_rowg_of_nonpos hT c\n    (hc.1.elim and.right (\u03bb h, (not_lt_of_gt hToc h.1).elim)) hc.2\n    (\u03bb i hi, classical.by_cases\n      (\u03bb hoi : obj = i, le_of_lt (hoi \u25b8 hToc))\n      (\u03bb hoi : obj \u2260 i, inv_nonpos.1 $ nonpos_of_mul_nonneg_right (hrow _ hoi hi) hToc))\n    hToc)\n  (\u03bb hToc : 0 < T.to_matrix obj c, is_unbounded_above_rowg_of_nonneg hT c\n    (\u03bb i hi, classical.by_cases\n      (\u03bb hoi : obj = i, le_of_lt (hoi \u25b8 hToc))\n      (\u03bb hoi : obj \u2260 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 \u2208 pivot_col T obj) {i} (hr : i \u2208 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 \u2260 T'.to_partition.rowp v \u2228\nT.to_partition.colp v \u2260 T'.to_partition.colp v\n\nlemma fickle_symm {T T' : tableau m n} {v : fin (m + n)} :\n  fickle T T' v \u2194 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) \u2194\n  T.to_partition.colg j \u2260 T'.to_partition.colg j :=\n\u27e8\u03bb 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\u03bb h, or.inr $ \u03bb h', h begin\n  have : T'.to_partition.colp (T.to_partition.colg j) = some j,\n  { simpa [eq_comm] using h' },\n  rwa [\u2190 pequiv.eq_some_iff, colp_symm_eq_some_colg, option.some_inj, eq_comm] at this\nend\u27e9\n\nlemma fickle_rowg_iff_ne {T T' : tableau m n} {i : fin m} :\n  fickle T T' (T.to_partition.rowg i) \u2194\n  T.to_partition.rowg i \u2260 T'.to_partition.rowg i :=\n\u27e8\u03bb 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\u03bb h, or.inl $ \u03bb h', h begin\n  have : T'.to_partition.rowp (T.to_partition.rowg i) = some i,\n  { simpa [eq_comm] using h' },\n  rwa [\u2190 pequiv.eq_some_iff, rowp_symm_eq_some_rowg, option.some_inj, eq_comm] at this\nend\u27e9\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 : \u2200 i, (fickle T T' (T.to_partition.rowg i)) \u2192 T.const i 0 = 0)\n  (hobj : T.const obj 0 = T'.const obj 0)\n  (nonpos_of_colg_eq : \u2200 j, j \u2260 c' \u2192\n    T'.to_partition.colg j = T.to_partition.colg c \u2192 T'.to_matrix obj j \u2264 0)\n  (unique_col : \u2200 j,\n    (fickle T' T (T'.to_partition.colg j)) \u2192 j \u2260 c' \u2192 T'.to_matrix obj j \u2264 0)\n  (unique_row : \u2200 i' \u2260 i, T.const i' 0 = 0 \u2192 fickle T T' (T.to_partition.rowg i') \u2192\n    0 \u2264 T.to_matrix i' c) :\n  false :=\nlet objr := T.to_partition.rowg obj in\nlet x := \u03bb y : \u211a, T.of_col (y \u2022 (single c 0).to_matrix) in\nhave hxflatT' : \u2200 {y}, x y \u2208 flat T', from hflat \u25b8 \u03bb _, of_col_mem_flat _ _,\nhave hxrow : \u2200 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 : \u2200 {y j}, j \u2260 c \u2192 x y (T.to_partition.colg j) 0 = 0,\n  from \u03bb y j hjc, by simp [x, of_col_colg, pequiv.to_matrix, single_apply_of_ne hjc.symm],\nhave hxcolc : \u2200 {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) \u2192 \u211a := \u03bb v, option.cases_on (T'.to_partition.colp v) 0\n  (T'.to_matrix obj) in\nhave hxobj : \u2200 y, x y objr 0 = T.const obj 0 + y * T.to_matrix obj c, from \u03bb y, hxrow _ _,\nhave hgetr : \u2200 {y v}, c_star v * x y v 0 \u2260 0 \u2192 (T'.to_partition.colp v).is_some,\n  from \u03bb y v, by cases h : T'.to_partition.colp v; dsimp [c_star]; rw h; simp,\nhave c_star_eq_get : \u2200 {v} (hv : (T'.to_partition.colp v).is_some),\n    c_star v = T'.to_matrix obj (option.get hv),\n  from \u03bb v hv, by dsimp only [c_star]; conv_lhs{rw [\u2190 option.some_get hv]}; refl,\nhave hsummmn : \u2200 {y}, sum univ (\u03bb j, T'.to_matrix obj j * x y (T'.to_partition.colg j) 0) =\n    sum univ (\u03bb v, c_star v * x y v 0),\n  from \u03bb y, sum_bij_ne_zero (\u03bb j _ _, T'.to_partition.colg j) (\u03bb _ _ _, mem_univ _)\n    (\u03bb _ _ _ _ _ _ h, T'.to_partition.injective_colg h)\n    (\u03bb v _ h0, \u27e8option.get (hgetr h0), mem_univ _,\n      by rw [\u2190 c_star_eq_get (hgetr h0)]; simpa using h0, by simp\u27e9)\n    (\u03bb _ _ h0, by dsimp [c_star]; rw [colp_colg]),\nhave hgetc : \u2200 {y v}, c_star v * x y v 0 \u2260 0 \u2192 v \u2260 T.to_partition.colg c \u2192\n    (T.to_partition.rowp v).is_some,\n  from \u03bb y v, (eq_rowg_or_colg T.to_partition v).elim\n    (\u03bb \u27e8i, hi\u27e9, by rw [hi, rowp_rowg]; simp)\n    (\u03bb \u27e8j, hj\u27e9 h0 hvc,\n      by rw [hj, hxcol (mt (congr_arg T.to_partition.colg) (hvc \u2218 hj.trans)), mul_zero] at h0;\n        exact (h0 rfl).elim),\nhave hsummmnn : \u2200 {y}, (univ.erase (T.to_partition.colg c)).sum (\u03bb v, c_star v * x y v 0) =\n    univ.sum (\u03bb i, c_star (T.to_partition.rowg i) * x y (T.to_partition.rowg i) 0),\n  from \u03bb y, eq.symm $ sum_bij_ne_zero (\u03bb i _ _, T.to_partition.rowg i) (by simp)\n    (\u03bb _ _ _ _ _ _ h, T.to_partition.injective_rowg h)\n    (\u03bb v hvc h0, \u27e8option.get (hgetc h0 (mem_erase.1 hvc).1), mem_univ _, by simpa using h0\u27e9)\n    (by intros; refl),\nhave hsumm : \u2200 {y}, univ.sum (\u03bb i, c_star (T.to_partition.rowg i) * x y (T.to_partition.rowg i) 0) =\n    univ.sum (\u03bb i, c_star (T.to_partition.rowg i) * T.const i 0) +\n    y * univ.sum (\u03bb i, c_star (T.to_partition.rowg i) * T.to_matrix i c),\n  from \u03bb y, by simp only [hxrow, mul_add, add_mul, sum_add_distrib, mul_assoc,\n    mul_left_comm _ y, mul_sum.symm],\nhave hxobj' : \u2200 y, x y objr 0 = univ.sum (\u03bb v, c_star v * x y v 0) + T'.const obj 0,\n  from \u03bb y, by dsimp [objr]; rw [hrobj, mem_flat_iff.1 hxflatT', hsummmn],\nhave hy : \u2200 {y}, y * T.to_matrix obj c = c_star (T.to_partition.colg c) * y +\n    univ.sum (\u03bb i, c_star (T.to_partition.rowg i) * T.const i 0) +\n      y * univ.sum (\u03bb i, c_star (T.to_partition.rowg i) * T.to_matrix i c),\n  from \u03bb y, by rw [\u2190 add_left_inj (T.const obj 0), \u2190 hxobj, hxobj',\n    \u2190 insert_erase (mem_univ (T.to_partition.colg c)), sum_insert (not_mem_erase _ _),\n    hsummmnn, hobj, hsumm, hxcolc]; simp,\nhave hy' : \u2200 (y), y * (T.to_matrix obj c - c_star (T.to_partition.colg c) -\n    univ.sum (\u03bb i, c_star (T.to_partition.rowg i) * T.to_matrix i c)) =\n    univ.sum (\u03bb i, c_star (T.to_partition.rowg i) * T.const i 0),\n  from \u03bb 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 (\u03bb i, c_star (T.to_partition.rowg i) * T.to_matrix i c) = 0,\n  by rw [\u2190 (domain.mul_left_inj (@one_ne_zero \u211a _)), hy', \u2190 hy' 0, zero_mul, mul_zero],\nhave hcolnec' : T'.to_partition.colp (T.to_partition.colg c) \u2260 some c',\n  from \u03bb 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' : \u2200 {i'}, T'.to_partition.colp (T.to_partition.rowg i') = some c' \u2192 i' = i,\n  from \u03bb 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 (\u03bb i, c_star (T.to_partition.rowg i) * T.to_matrix i c),\n  by rw [\u2190 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 \u25b8 hcolnec'))\n          (by rw [\u2190 (option.eq_some_iff_get_eq.1 h).snd]; simp) }\n    end),\nhave hexi : \u2203 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    (\u03bb i', c_star (T.to_partition.rowg i') * T.to_matrix i' c) _ _) sumpos,\nlet \u27e8i', hi'\u27e9 := hexi in\nhave hi'0 : T.const i' 0 = 0, from hfickle i'\n  (fickle_rowg_iff_ne.2 $\n    \u03bb 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 (\u03bb 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 [\u2190 option.some_get hi'_some] at hi',\nhave hii : i' \u2260 i, from \u03bb hir, begin\n    have : option.get hi'_some = c', from T'.to_partition.injective_colg\n      (by rw [colg_get_colp_symm, \u2190 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 \u2260 c',\n  from \u03bb eq_c', hii $ @eq_of_roweqc' i' (eq_c' \u25b8 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, \u2190 colg_get_colp_symm _ _ hi'_some]; exact colg_ne_rowg _ _ _))\n\ninductive rel : tableau m n \u2192 tableau m n \u2192 Prop\n| pivot : \u2200 {T}, feasible T \u2192 \u2200 {i c}, c \u2208 pivot_col T obj \u2192\n  i \u2208 pivot_row T obj c \u2192 rel (T.pivot i c) T\n| trans_pivot : \u2200 {T\u2081 T\u2082 i c}, rel T\u2081 T\u2082 \u2192 c \u2208 pivot_col T\u2081 obj \u2192\n  i \u2208 pivot_row T\u2081 obj c \u2192 rel (T\u2081.pivot i c) T\u2082\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 (\u03bb _ hT _ _ hc hr, feasible_of_mem_pivot_row_and_col hT hc hr)\n  (\u03bb _ _ _ _ _ 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 \u2192 tableau m n \u2192 Prop} {T T' : tableau m n}\n  (hrel : rel obj T T')\n  (hpivot : \u2200 {T : tableau m n} {i : fin m} {c : fin n},\n     feasible T \u2192 c \u2208 pivot_col T obj \u2192 i \u2208 pivot_row T obj c \u2192 C (pivot T i c) T)\n  (hpivot_trans : \u2200 {T\u2081 T\u2082 : tableau m n} {i : fin m} {c : fin n},\n    rel obj (T\u2081.pivot i c) T\u2081 \u2192 rel obj T\u2081 T\u2082 \u2192\n     c \u2208 pivot_col T\u2081 obj \u2192\n     i \u2208 pivot_row T\u2081 obj c \u2192 C (T\u2081.pivot i c) T\u2081 \u2192 C T\u2081 T\u2082 \u2192 C (pivot T\u2081 i c) T\u2082) :\n  C T T' :=\nrel.rec_on hrel (\u03bb T hT i c  hc hr, hpivot hT hc hr) (\u03bb T\u2081 T\u2082 i c hrelT\u2081\u2082 hc hr ih, hpivot_trans\n  (rel.pivot (feasible_of_rel_left obj hrelT\u2081\u2082) hc hr) hrelT\u2081\u2082 hc hr\n  (hpivot (feasible_of_rel_left obj hrelT\u2081\u2082) hc hr) ih)\n\nlemma rel.trans {obj : fin m} {T\u2081 T\u2082 T\u2083 : tableau m n} (h\u2081\u2082 : rel obj T\u2081 T\u2082) :\n  rel obj T\u2082 T\u2083 \u2192 rel obj T\u2081 T\u2083 :=\nrel.rec_on h\u2081\u2082\n  (\u03bb T i c hT hc hr hrelT, rel.trans_pivot hrelT hc hr)\n  (\u03bb T\u2081 T\u2082 i c hrelT\u2081\u2082 hc hr ih hrelT\u2082\u2083, rel.trans_pivot (ih hrelT\u2082\u2083) hc hr)\n\ninstance : is_trans (tableau m n) (rel obj) := \u27e8@rel.trans _ _ obj\u27e9\n\nlemma flat_eq_of_rel {T T' : tableau m n} (h : rel obj T' T) : flat T' = flat T :=\nrel.rec_on' h (\u03bb _ _ _ _ _ hr, flat_pivot (ne_zero_of_mem_pivot_row hr))\n  (\u03bb _ _ _ _ _ _ _ _, 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 (\u03bb T i c hfT hc hr, by simp [rowg_swap_of_ne _ (pivot_row_spec hr).1])\n  (\u03bb _ _ _ _ _ _ _ _, 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 (\u03bb _ _ _ _ _ _, rfl) (\u03bb _ _ _ _ _ _ _ _, 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 (\u03bb _ _ _ _ _ _, rfl) (\u03bb _ _ _ _ _ _ _ _, eq.trans)\n\nlemma dead_eq_of_rel_or_eq {T T' : tableau m n} (h : T = T' \u2228 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  \u2203 i c, c \u2208 pivot_col T obj \u2227 i \u2208 pivot_row T obj c :=\nrel.rec_on' h (\u03bb _ i c _ hc hr, \u27e8i, c, hc, hr\u27e9) (\u03bb _ _ _ _ _ _ _ _ _, 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 \u2208 pivot_col T obj) : \u2203 i, i \u2208 pivot_row T obj c :=\nlet \u27e8i, c', hc', hr\u27e9 := exists_mem_pivot_row_col_of_rel obj h in \u27e8i, by simp * at *\u27e9\n\nlemma exists_mem_pivot_col_of_fickle {T\u2081 T\u2082 : tableau m n} (h : rel obj T\u2082 T\u2081) {c : fin n} :\n  fickle T\u2081 T\u2082 (T\u2081.to_partition.colg c) \u2192\n  \u2203 T\u2083, (T\u2083 = T\u2081 \u2228 rel obj T\u2083 T\u2081) \u2227 (rel obj T\u2082 T\u2083) \u2227\n  T\u2083.to_partition.colg c = T\u2081.to_partition.colg c \u2227\n  c \u2208 pivot_col T\u2083 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 \u03bb _, \u27e8T, or.inl rfl, rel.pivot hT hc' hr, rfl, hc'\u27e9 },\n    { simp [colg_swap_of_ne _ hcc] }\n  end\n  (\u03bb T\u2081 T\u2082 i c hrelp\u2081 hrel\u2081\u2082 hc hr ihp\u2081 ih\u2081\u2082,\n    (imp_iff_not_or.1 ih\u2081\u2082).elim\n      (\u03bb ih\u2081\u2082, (imp_iff_not_or.1 ihp\u2081).elim\n        (\u03bb ihp\u2081 hf, (fickle_colg_iff_ne.1 hf (by simp [*, fickle_colg_iff_ne] at *)).elim)\n        (\u03bb \u27e8T\u2083, hT\u2083\u27e9 hf, \u27e8T\u2083,\n          hT\u2083.1.elim (\u03bb h, h.symm \u25b8 or.inr hrel\u2081\u2082) (\u03bb h, or.inr $ h.trans hrel\u2081\u2082),\n          hT\u2083.2.1, hT\u2083.2.2.1.trans (by simpa [eq_comm, fickle_colg_iff_ne] using ih\u2081\u2082), hT\u2083.2.2.2\u27e9))\n      (\u03bb \u27e8T\u2083, hT\u2083\u27e9 hf, \u27e8T\u2083, hT\u2083.1, hrelp\u2081.trans hT\u2083.2.1, hT\u2083.2.2\u27e9))\n\nlemma exists_mem_pivot_row_of_fickle {T\u2081 T\u2082 : tableau m n} (h : rel obj T\u2082 T\u2081) (i : fin m) :\n  fickle T\u2081 T\u2082 (T\u2081.to_partition.rowg i) \u2192\n  \u2203 (T\u2083 : tableau m n) c, (T\u2083 = T\u2081 \u2228 rel obj T\u2083 T\u2081) \u2227 (rel obj T\u2082 T\u2083) \u2227\n    T\u2083.to_partition.rowg i = T\u2081.to_partition.rowg i \u2227\n    c \u2208 pivot_col T\u2083 obj \u2227 i \u2208 pivot_row T\u2083 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 \u03bb _, \u27e8T, c, or.inl rfl, rel.pivot hT hc hi', rfl, hc, hi'\u27e9 },\n    { simp [rowg_swap_of_ne _ hii] }\n  end\n  (\u03bb T\u2081 T\u2082 i c hrelp\u2081 hrel\u2081\u2082 hc hrow ihp\u2081 ih\u2081\u2082,\n    (imp_iff_not_or.1 ih\u2081\u2082).elim\n      (\u03bb ih\u2081\u2082, (imp_iff_not_or.1 ihp\u2081).elim\n        (\u03bb ihp\u2081 hf, (fickle_rowg_iff_ne.1 hf (by simp [*, fickle_rowg_iff_ne] at *)).elim)\n        (\u03bb \u27e8T\u2083, c', hT\u2083\u27e9 hf, \u27e8T\u2083, c', hT\u2083.1.elim (\u03bb h, h.symm \u25b8 or.inr hrel\u2081\u2082)\n          (\u03bb h, or.inr $ h.trans hrel\u2081\u2082),\n            hT\u2083.2.1,\n            hT\u2083.2.2.1.trans (by simpa [eq_comm, fickle_rowg_iff_ne] using ih\u2081\u2082),\n            by clear_aux_decl; tauto\u27e9))\n      (\u03bb \u27e8T\u2083, c', hT\u2083\u27e9 _, \u27e8T\u2083, c', hT\u2083.1,\n        (rel.pivot (feasible_of_rel_left _ hrel\u2081\u2082) hc hrow).trans hT\u2083.2.1, hT\u2083.2.2\u27e9))\n\nlemma eq_or_rel_pivot_of_rel {T\u2081 T\u2082 : tableau m n} (h : rel obj T\u2081 T\u2082) : \u2200 {i j}\n  (hcol : j \u2208 pivot_col T\u2082 obj) (hrow : i \u2208 pivot_row T\u2082 obj j),\n  T\u2081 = T\u2082.pivot i j \u2228 rel obj T\u2081 (T\u2082.pivot i j) :=\nrel.rec_on' h (\u03bb T i c hT hc hr r' c' hc' hr', by simp * at *)\n  (\u03bb T\u2081 T\u2082 i c hrelp\u2081 hrel\u2081\u2082 hc hr ihp\u2081 ih\u2081\u2082 r' c' hc' hr',\n    (ih\u2081\u2082 hc' hr').elim\n      (\u03bb ih\u2081\u2082, or.inr $ ih\u2081\u2082 \u25b8 rel.pivot (feasible_of_rel_left _ hrel\u2081\u2082) hc hr)\n      (\u03bb ih\u2081\u2082, or.inr $ (rel.pivot (feasible_of_rel_left _ hrel\u2081\u2082) hc hr).trans ih\u2081\u2082))\n\nlemma exists_mem_pivot_col_of_mem_pivot_row {T : tableau m n} (hrelTT : rel obj T T)\n  {i c} (hc : c \u2208 pivot_col T obj) (hrow : i \u2208 pivot_row T obj c) :\n  \u2203 (T' : tableau m n), c \u2208 pivot_col T' obj \u2227 T'.to_partition.colg c =\n  T.to_partition.rowg i \u2227 rel obj T' T \u2227 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 (\u03bb h, h \u25b8 hrelTT ) id,\nlet \u27e8T', hT'\u27e9 := exists_mem_pivot_col_of_fickle obj hrelTTp $ fickle_colg_iff_ne.2 $\n  (show (T.pivot i c).to_partition.colg c \u2260 T.to_partition.colg c, by simp) in\n\u27e8T', hT'.2.2.2, by simp [hT'.2.2.1], hT'.1.elim\n  (\u03bb h, h.symm \u25b8 rel.pivot (feasible_of_rel_left _ hrelTT) hc hrow)\n  (\u03bb h, h.trans $ rel.pivot (feasible_of_rel_left _ hrelTT) hc hrow), hT'.2.1\u27e9\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  \u2203 (T\u2083 : tableau m n) c, c \u2208 pivot_col T\u2083 obj \u2227 T\u2083.to_partition.colg c =\n  T.to_partition.rowg i \u2227 rel obj T\u2083 T \u2227 rel obj T T\u2083 :=\nlet \u27e8T\u2083, c, hT\u2083, hrelT\u2083T, hrow\u2083, hc, hr\u27e9 :=\n  exists_mem_pivot_row_of_fickle obj hrelT'T _ hrow in\nlet \u27e8T\u2084, hT\u2084\u27e9 := exists_mem_pivot_col_of_mem_pivot_row obj\n  (show rel obj T\u2083 T\u2083, from hT\u2083.elim (\u03bb h, h.symm \u25b8 hrelTT'.trans hrelT'T)\n    (\u03bb h, h.trans $ hrelTT'.trans hrelT\u2083T)) hc hr in\n\u27e8T\u2084, c, hT\u2084.1, hT\u2084.2.1.trans hrow\u2083, hT\u2084.2.2.1.trans $ hT\u2083.elim (\u03bb h, h.symm \u25b8 hrelTT'.trans hrelT'T)\n  (\u03bb h, h.trans $ hrelTT'.trans hrelT'T), hrelTT'.trans (hrelT\u2083T.trans hT\u2084.2.2.2)\u27e9\n\nlemma const_obj_le_of_rel {T\u2081 T\u2082 : tableau m n} (h : rel obj T\u2081 T\u2082) :\n  T\u2082.const obj 0 \u2264 T\u2081.const obj 0 :=\nrel.rec_on' h (\u03bb T i c hT hc hr,\n    have hr' : _ := pivot_row_spec hr,\n    simplex_const_obj_le hT (by tauto) (by tauto))\n  (\u03bb _ _ _ _ _ _ _ _ h\u2081 h\u2082, le_trans h\u2082 h\u2081)\n\nlemma const_obj_eq_of_rel_of_rel {T\u2081 T\u2082 : tableau m n} (h\u2081\u2082 : rel obj T\u2081 T\u2082)\n  (h\u2082\u2081 : rel obj T\u2082 T\u2081) : T\u2081.const obj 0 = T\u2082.const obj 0 :=\nle_antisymm (const_obj_le_of_rel _ h\u2082\u2081) (const_obj_le_of_rel _ h\u2081\u2082)\n\nlemma const_eq_const_of_const_obj_eq {T\u2081 T\u2082 : tableau m n} (h\u2081\u2082 : rel obj T\u2081 T\u2082) :\n  \u2200 (hobj : T\u2081.const obj 0 = T\u2082.const obj 0) (i : fin m), T\u2081.const i 0 = T\u2082.const i 0 :=\nrel.rec_on' h\u2081\u2082\n  (\u03bb 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  (\u03bb T\u2081 T\u2082 i c hrelp\u2081 hrel\u2081\u2082 hc hr ihp\u2081 ih\u2081\u2082 hobj i',\n    have hobjp : (pivot T\u2081 i c).const obj 0 = T\u2081.const obj 0,\n      from le_antisymm (hobj.symm \u25b8 const_obj_le_of_rel _ hrel\u2081\u2082)\n        (const_obj_le_of_rel _ hrelp\u2081),\n    by rw [ihp\u2081 hobjp, ih\u2081\u2082 (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 \u27e8T\u2083, c, hT\u2083\u2081, hT'\u2083, hrow\u2083, hc, hi\u27e9 := exists_mem_pivot_row_of_fickle obj hrelT'T _ hrow in\nhave T\u2083.const i 0 = 0, from const_eq_zero_of_const_obj_eq\n  (feasible_of_rel_right _ hT'\u2083) (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'\u2083) hc hi)\n    ((eq_or_rel_pivot_of_rel _ hT'\u2083 hc hi).elim\n      (\u03bb h, h \u25b8 hT\u2083\u2081.elim (\u03bb h, h.symm \u25b8 hrelTT') (\u03bb h, h.trans hrelTT'))\n      (\u03bb hrelT'p, hT\u2083\u2081.elim (\u03bb h, h.symm \u25b8 hrelTT'.trans (h \u25b8 hrelT'p))\n        (\u03bb h, h.trans $ hrelTT'.trans hrelT'p)))),\nhave hobj : T\u2083.const obj 0 = T.const obj 0,\n  from hT\u2083\u2081.elim (\u03bb h, h \u25b8 rfl) (\u03bb h, const_obj_eq_of_rel_of_rel _ h (hrelTT'.trans hT'\u2083)),\nhT\u2083\u2081.elim (\u03bb h, h \u25b8 this) (\u03bb h, const_eq_const_of_const_obj_eq obj h hobj i \u25b8 this)\n\nlemma colg_mem_restricted_of_rel_self {T : tableau m n} (hrelTT : rel obj T T)\n  {c} (hc : c \u2208 pivot_col T obj) : T.to_partition.colg c \u2208 T.restricted :=\nlet \u27e8i, hrow\u27e9 := exists_mem_pivot_row_of_rel obj hrelTT hc in\nlet \u27e8T', c', hT', hrelTT', hrowcol, _, hi'\u27e9 := exists_mem_pivot_row_of_fickle obj\n    ((eq_or_rel_pivot_of_rel _ hrelTT hc hrow).elim\n      (\u03bb h, show rel obj T (T.pivot i c), from h \u25b8 hrelTT) id) _\n  (fickle_rowg_iff_ne.2 $\n    show (T.pivot i c).to_partition.rowg i \u2260 T.to_partition.rowg i, by simp) in\n(restricted_eq_of_rel _ hrelTT').symm \u25b8 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 \u2209 T.restricted) (hdead : j \u2209 T.dead) : T.to_matrix obj j = 0 :=\nlet \u27e8r, c, hc, hr\u27e9 := exists_mem_pivot_row_col_of_rel obj hrelTT in\nhave hcres : T.to_partition.colg c \u2208 T.restricted,\n  from colg_mem_restricted_of_rel_self obj hrelTT hc,\nby_contradiction $ \u03bb h0,\nbegin\n  simp [pivot_col] at hc,\n  cases h : fin.find (\u03bb c, T.to_matrix obj c \u2260 0 \u2227 colg (T.to_partition) c \u2209 T.restricted\n    \u2227 c \u2209 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} : \u2200 (T : tableau m n), \u00ac rel obj T T :=\n\u03bb T1 hrelT1,\nlet \u27e8iT1 , cT1, hrT1, hcT1\u27e9 := exists_mem_pivot_row_col_of_rel obj hrelT1 in\nlet \u27e8t, ht\u27e9 := finset.max_of_mem\n  (show T1.to_partition.colg cT1 \u2208 univ.filter (\u03bb v, \u2203 (T' : tableau m n) (c : fin n),\n      rel obj T' T' \u2227 c \u2208 pivot_col T' obj \u2227 T'.to_partition.colg c = v),\n    by simp only [true_and, mem_filter, mem_univ, exists_and_distrib_left];\n      exact \u27e8T1, hrelT1, cT1, hrT1, rfl\u27e9) in\nlet \u27e8_, T', c', hrelTT'', hcT', hct\u27e9 := finset.mem_filter.1 (finset.mem_of_max ht) in\nhave htmax : \u2200 (s : fin (m + n)) (T : tableau m n),\n    rel obj T T \u2192 \u2200 (j : fin n), pivot_col T obj = some j \u2192\n      T.to_partition.colg j = s \u2192 s \u2264 t,\n  by simpa using \u03bb s (h : s \u2208 _), finset.le_max_of_mem h ht,\nlet \u27e8i, hiT'\u27e9 := 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 (\u03bb h, h \u25b8 hrelTT'') id,\nlet \u27e8T, c, hTT', hrelT'T, hT'Tr, hc, hr\u27e9 := 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 (\u03bb h, h.symm \u25b8 hrelT'pT') (\u03bb h, h.trans hrelT'pT'),\nhave hrelTT : rel obj T T, from hrelTT'.trans hrelT'T,\nhave hc't : T.to_partition.colg c \u2264 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 : \u2200 i, fickle T T' (T.to_partition.rowg i) \u2192 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' \u2208 T'.restricted,\n  from hs \u25b8 restricted_eq_of_rel _ hrelTT' \u25b8 (pivot_row_spec hr).2.1,\nhave hc'obj0 : 0 < T'.to_matrix obj c' \u2227 c' \u2209 T'.dead,\n  by simpa [hc'res] using pivot_col_spec hcT',\nhave hcres : T.to_partition.colg c \u2208 T.restricted,\n  from colg_mem_restricted_of_rel_self obj hrelTT hc,\nhave hcobj0 : 0 < to_matrix T obj c \u2227 c \u2209 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 : \u2200 j, (fickle T' T (T'.to_partition.colg j)) \u2192 j \u2260 c' \u2192\n    T'.to_matrix obj j \u2264 0,\n  from \u03bb j hj hjc',\n    let \u27e8T\u2083, hT\u2083\u27e9 := 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\u2083.1 \u25b8 (pivot_col_spec hT\u2083.2.2.2).2)\n      (lt_of_le_of_ne\n        (hct.symm \u25b8 hT\u2083.2.2.1 \u25b8 htmax _ T\u2083 (hT\u2083.1.elim (\u03bb h, h.symm \u25b8 hrelTT'')\n          (\u03bb h, h.trans (hrelT'T.trans hT\u2083.2.1))) _ hT\u2083.2.2.2 rfl)\n        (by rwa [ne.def, T'.to_partition.injective_colg.eq_iff])),\nhave nonpos_of_colg_eq : \u2200 j, j \u2260 c' \u2192\n    T'.to_partition.colg j = T.to_partition.colg c \u2192 T'.to_matrix obj j \u2264 0,\n  from \u03bb 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 \u25b8 hct.symm \u25b8 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 : \u2200 i' \u2260 i, T.const i' 0 = 0 \u2192 fickle T T' (T.to_partition.rowg i') \u2192\n    0 \u2264 T.to_matrix i' c,\n  from \u03bb i' hii hi0 hrow,\n    let \u27e8T\u2083, c\u2083, hc\u2083, hrow\u2083, hrelT\u2083T, hrelTT\u2083\u27e9 :=\n      exists_mem_pivot_col_of_fickle_row _ hrelTT' hrelT'T hrow in\n    have hrelT\u2083T\u2083 : rel obj T\u2083 T\u2083, from hrelT\u2083T.trans hrelTT\u2083,\n    nonneg_of_lt_pivot_row (by exact hcobj0.1)\n      (by rw [\u2190 hrow\u2083, \u2190 restricted_eq_of_rel _ hrelT\u2083T];\n        exact colg_mem_restricted_of_rel_self _ hrelT\u2083T\u2083 hc\u2083) hc hr hi0\n      (lt_of_le_of_ne (by rw [hs, hct, \u2190 hrow\u2083]; exact htmax _ _ hrelT\u2083T\u2083 _ hc\u2083 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 (\u03bb T', T'.val.to_partition)\n  (\u03bb T\u2081 T\u2082 h, subtype.eq $ tableau.ext\n    (by rw [flat_eq_of_rel _ T\u2081.2, flat_eq_of_rel _ T\u2082.2]) h\n    (by rw [dead_eq_of_rel _ T\u2081.2, dead_eq_of_rel _ T\u2082.2])\n    (by rw [restricted_eq_of_rel _ T\u2081.2, restricted_eq_of_rel _ T\u2082.2]))\n\nlemma rel_wf (m n : \u2115) (obj : fin m): well_founded (@rel m n obj) :=\nsubrelation.wf\n  (show subrelation (@rel m n obj) (measure (\u03bb T, fintype.card {T' | rel obj T' T})),\n    from assume T\u2081 T\u2082 h,\n    set.card_lt_card (set.ssubset_iff_subset_not_subset.2 \u27e8\u03bb T' hT', hT'.trans h,\n      not_forall_of_exists_not \u27e8T\u2081, \u03bb h', rel.irrefl _ (h' h)\u27e9\u27e9))\n  (measure_wf (\u03bb T, fintype.card {T' | rel obj T' T}))\n\nend blands_rule\n\ninductive termination (n : \u2115) : 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\u03bb _ _ h, by injection h\n\n@[simp] lemma unbounded_inj {c c' : fin n} : unbounded c = unbounded c' \u2194 c = c' :=\ninjective_unbounded.eq_iff\n\nend termination\n\nopen termination\n\ninstance {n : \u2115} : has_repr $ termination n :=\n\u27e8\u03bb t, termination.cases_on t\n  \"while\"\n  (\u03bb c, \"unbounded \" ++ repr c)\n  \"optimal\"\u27e9\n\nopen termination\n\n/-- The simplex algorithm -/\ndef simplex (w : tableau m n \u2192 bool) (obj : fin m) : \u03a0 (T : tableau m n) (hT : feasible T),\n  tableau m n \u00d7 termination n\n| T := \u03bb 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, (\u03bb 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 := \u03bb _ _, `[exact \u27e8_, rel_wf m n obj\u27e9],\n  dec_tac := tactic.assumption}\n\nlemma simplex_pivot {w : tableau m n \u2192 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 \u2208 pivot_col T obj) (hr : i \u2208 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 \u2192 bool) (obj : fin m) :\n  \u03a0 (T : tableau m n) (hT : feasible T),\n  ((T.simplex w obj hT).2 = while \u2227 w (T.simplex w obj hT).1 = ff) \u2228\n  ((T.simplex w obj hT).2 = optimal \u2227 w (T.simplex w obj hT).1 = tt \u2227\n    pivot_col (T.simplex w obj hT).1 obj = none) \u2228\n  \u2203 c, ((T.simplex w obj hT).2 = unbounded c \u2227 w (T.simplex w obj hT).1 = tt \u2227\n    c \u2208 pivot_col (T.simplex w obj hT).1 obj \u2227\n    pivot_row (T.simplex w obj hT).1 obj c = none)\n| T := \u03bb 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 [\u2190 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 := \u03bb _ _, `[exact \u27e8_, rel_wf m n obj\u27e9],\n  dec_tac := tactic.assumption}\n\nlemma simplex_while_eq_ff {w : tableau m n \u2192 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 \u2192 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 \u2192 bool} {T : tableau m n} {hT : feasible T}\n  {obj : fin m} (hw : w T = tt) {c} (hc : c \u2208 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 \u2192 Prop) (w : tableau m n \u2192 bool) (obj : fin m):\n  \u03a0 {T : tableau m n} (hT : feasible T)  (h0 : P T)\n  (hpivot : \u2200 {T' i c}, w T' = tt \u2192 c \u2208 pivot_col T' obj \u2192 i \u2208 pivot_row T' obj c\n    \u2192 feasible T' \u2192 P T' \u2192 P (T'.pivot i c)),\n  P (T.simplex w obj hT).1\n| T := \u03bb 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 [\u2190 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 := \u03bb _ _, `[exact \u27e8_, rel_wf m n obj\u27e9],\n  dec_tac := `[tauto]}\n\n@[simp] lemma feasible_simplex {w : tableau m n \u2192 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  (\u03bb _ _ _ _ hc hr _ hT', feasible_of_mem_pivot_row_and_col hT' hc hr)\n\n@[simp] lemma simplex_simplex {w : tableau m n \u2192 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 (\u03bb T', \u2200 (hT' : feasible T'), T'.simplex w obj hT' = T.simplex w obj hT) w _ _\n  (\u03bb _, rfl) (\u03bb 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 \u2192 bool)\n  (obj : fin m) : (T.simplex w obj hT).1.to_partition.rowg obj = T.to_partition.rowg obj :=\nsimplex_induction (\u03bb T', T'.to_partition.rowg obj = T.to_partition.rowg obj) _ _ _ rfl\n  (\u03bb 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 \u2192 bool)\n  (obj : fin m) : (T.simplex w obj hT).1.flat = T.flat :=\nsimplex_induction (\u03bb T', T'.flat = T.flat) w obj _ rfl\n  (\u03bb T' i c hw hc hr hT' ih,\n    have T'.to_matrix i c \u2260 0,\n      from \u03bb 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 \u2192 bool)\n  (obj : fin m) : (T.simplex w obj hT).1.restricted = T.restricted :=\nsimplex_induction (\u03bb 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 \u2192 bool)\n  (obj : fin m) : (T.simplex w obj hT).1.dead = T.dead :=\nsimplex_induction (\u03bb 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 \u2192 bool)\n  (obj : fin m) : (T.simplex w obj hT).1.res_set = T.res_set :=\nsimplex_induction (\u03bb T', T'.res_set = T.res_set) w obj _ rfl\n  (\u03bb 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 \u2192 bool)\n  (obj : fin m) : (T.simplex w obj hT).1.dead_set = T.dead_set :=\nsimplex_induction (\u03bb T', T'.dead_set = T.dead_set) w obj _ rfl\n  (\u03bb 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 \u2192 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 \u2192 bool} {T : tableau m n}\n  {hT : feasible T} {obj : fin m} : (T.simplex w obj hT).1.of_col 0 \u2208 sol_set T :=\nby rw [\u2190 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 \u2192 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 \u2b1d x + (T.simplex w obj hT).1.const) obj :=\nby rw [\u2190 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 \u2192 bool}\n  {obj : fin m} {v : fin (m + n)} : is_unbounded_above (T.simplex w obj hT).1 v \u2194\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 \u2192 bool}\n  {obj : fin m} {x : cvec (m + n)} {v : fin (m + n)} : is_optimal (T.simplex w obj hT).1 x v \u2194\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 \u2192 bool}\n  {obj : fin m} : (T.simplex w obj hT).2 = while \u2194 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 \u2192 bool} {obj : fin m} : (T.simplex w obj hT).2 = optimal \u2194\n  w (T.simplex w obj hT).1 = tt \u2227 pivot_col (T.simplex w obj hT).1 obj = none :=\nby rcases simplex_spec_aux w obj T hT with _ | \u27e8_, _, _\u27e9 | \u27e8\u27e8_, _\u27e9, _, _, _, _\u27e9; simp * at *\n\nlemma termination_eq_unbounded_iff_pivot_row_eq_none {T : tableau m n} {hT : feasible T}\n  {w : tableau m n \u2192 bool} {obj : fin m} {c : fin n} :\n  (T.simplex w obj hT).2 = unbounded c \u2194\n  w (T.simplex w obj hT).1 = tt \u2227 c \u2208 pivot_col (T.simplex w obj hT).1 obj \u2227\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  _ | \u27e8_, _, _\u27e9 | \u27e8\u27e8\u27e8_, _\u27e9, _\u27e9, _, _, _, _\u27e9; simp * at *\n\nlemma unbounded_of_termination_eq_unbounded {T : tableau m n} {hT : feasible T}\n  {w : tableau m n \u2192 bool} {obj : fin m} {c : fin n} : (T.simplex w obj hT).2 = unbounded c \u2192\n  w (T.simplex w obj hT).1 = tt \u2227\n  is_unbounded_above T (T.to_partition.rowg obj) :=\nbegin\n  rw termination_eq_unbounded_iff_pivot_row_eq_none,\n  rintros \u27e8_, hc\u27e9,\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 \u2192 bool} {obj : fin m} : (T.simplex w obj hT).2 = optimal \u2194\n  w (T.simplex w obj hT).1 = tt \u2227\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 \u27e8_, hc\u27e9,\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 \u2192 bool} {obj : fin m} {c : fin n}: (T.simplex w obj hT).2 = unbounded c \u2194\n  w (T.simplex w obj hT).1 = tt \u2227 is_unbounded_above T (T.to_partition.rowg obj)\n  \u2227 c \u2208 pivot_col (T.simplex w obj hT).1 obj :=\n\u27e8\u03bb hc, and.assoc.1 $ \u27e8unbounded_of_termination_eq_unbounded hc,\n  (termination_eq_unbounded_iff_pivot_row_eq_none.1 hc).2.1\u27e9,\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\u27e9\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 : \u2200 {x : \u03b1}, p x) : \u2200 {t : RBNode \u03b1}, t.All p\n  | nil => _root_.trivial\n  | node .. => \u27e8H, All.trivial H, All.trivial H\u27e9\n\ntheorem All_and {t : RBNode \u03b1} : t.All (fun a => p a \u2227 q a) \u2194 t.All p \u2227 t.All q := by\n  induction t <;> simp [*, and_assoc, and_left_comm]\n\ntheorem cmpLT.trans (h\u2081 : cmpLT cmp x y) (h\u2082 : cmpLT cmp y z) : cmpLT cmp x z :=\n  \u27e8TransCmp.lt_trans h\u2081.1 h\u2082.1\u27e9\n\ntheorem cmpLT.trans_l {cmp x y} (H : cmpLT cmp x y) {t : RBNode \u03b1}\n    (h : t.All (cmpLT cmp y \u00b7)) : t.All (cmpLT cmp x \u00b7) := h.imp fun h => H.trans h\n\ntheorem cmpLT.trans_r {cmp x y} (H : cmpLT cmp x y) {a : RBNode \u03b1}\n    (h : a.All (cmpLT cmp \u00b7 x)) : a.All (cmpLT cmp \u00b7 y) := h.imp fun h => h.trans H\n\ntheorem cmpEq.lt_congr_left (H : cmpEq cmp x y) : cmpLT cmp x z \u2194 cmpLT cmp y z :=\n  \u27e8fun \u27e8h\u27e9 => \u27e8TransCmp.cmp_congr_left H.1 \u25b8 h\u27e9, fun \u27e8h\u27e9 => \u27e8TransCmp.cmp_congr_left H.1 \u25b8 h\u27e9\u27e9\n\ntheorem cmpEq.lt_congr_right (H : cmpEq cmp y z) : cmpLT cmp x y \u2194 cmpLT cmp x z :=\n  \u27e8fun \u27e8h\u27e9 => \u27e8TransCmp.cmp_congr_right H.1 \u25b8 h\u27e9, fun \u27e8h\u27e9 => \u27e8TransCmp.cmp_congr_right H.1 \u25b8 h\u27e9\u27e9\n\n/-- The `balance1` function preserves the ordering invariants. -/\nprotected theorem Ordered.balance1 {l : RBNode \u03b1} {v : \u03b1} {r : RBNode \u03b1}\n    (lv : l.All (cmpLT cmp \u00b7 v)) (vr : r.All (cmpLT cmp v \u00b7))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balance1 l v r).Ordered cmp := by\n  unfold balance1; split\n  \u00b7 next a x b y c =>\n    have \u27e8yv, _, cv\u27e9 := lv; have \u27e8xy, yc, hx, hc\u27e9 := hl\n    exact \u27e8xy, \u27e8yv, yc, yv.trans_l vr\u27e9, hx, cv, vr, hc, hr\u27e9\n  \u00b7 next a x b y c _ =>\n    have \u27e8_, _, yv, _, cv\u27e9 := lv; have \u27e8ax, \u27e8xy, xb, _\u27e9, ha, by_, yc, hb, hc\u27e9 := hl\n    exact \u27e8\u27e8xy, xy.trans_r ax, by_\u27e9, \u27e8yv, yc, yv.trans_l vr\u27e9, \u27e8ax, xb, ha, hb\u27e9, cv, vr, hc, hr\u27e9\n  \u00b7 exact \u27e8lv, vr, hl, hr\u27e9\n\n@[simp] theorem balance1_All {l : RBNode \u03b1} {v : \u03b1} {r : RBNode \u03b1} :\n    (balance1 l v r).All p \u2194 p v \u2227 l.All p \u2227 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 \u03b1} {v : \u03b1} {r : RBNode \u03b1}\n    (lv : l.All (cmpLT cmp \u00b7 v)) (vr : r.All (cmpLT cmp v \u00b7))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balance2 l v r).Ordered cmp := by\n  unfold balance2; split\n  \u00b7 next b y c z d =>\n    have \u27e8_, \u27e8vy, vb, _\u27e9, _\u27e9 := vr; have \u27e8\u27e8yz, _, cz\u27e9, zd, \u27e8by_, yc, hy, hz\u27e9, hd\u27e9 := hr\n    exact \u27e8\u27e8vy, vy.trans_r lv, by_\u27e9, \u27e8yz, yc, yz.trans_l zd\u27e9, \u27e8lv, vb, hl, hy\u27e9, cz, zd, hz, hd\u27e9\n  \u00b7 next a x b y c _ =>\n    have \u27e8vx, va, _\u27e9 := vr; have \u27e8ax, xy, ha, hy\u27e9 := hr\n    exact \u27e8\u27e8vx, vx.trans_r lv, ax\u27e9, xy, \u27e8lv, va, hl, ha\u27e9, hy\u27e9\n  \u00b7 exact \u27e8lv, vr, hl, hr\u27e9\n\n@[simp] theorem balance2_All {l : RBNode \u03b1} {v : \u03b1} {r : RBNode \u03b1} :\n    (balance2 l v r).All p \u2194 p v \u2227 l.All p \u2227 r.All p := by\n  unfold balance2; split <;> simp [and_assoc, and_left_comm]\n\nprotected theorem Ordered.setBlack {t : RBNode \u03b1} : (setBlack t).Ordered cmp \u2194 t.Ordered cmp := by\n  unfold setBlack; split <;> simp [Ordered]\n\nprotected \n\ntheorem setBlack_idem {t : RBNode \u03b1} : t.setBlack.setBlack = t.setBlack := by cases t <;> rfl\n\ntheorem insert_setBlack {t : RBNode \u03b1} :\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 : \u03b1} {t : RBNode \u03b1}\n  (h\u2081 : p x) (h\u2082 : t.All p) : (ins cmp x t).All p := by\n  induction t <;> unfold ins <;> simp [*]\n  split <;> cases \u2039_=_\u203a <;> split <;> simp at h\u2082 <;> simp [*]\n\n/-- The `ins` function preserves the ordering invariants. -/\nprotected theorem Ordered.ins : \u2200 {t : RBNode \u03b1}, t.Ordered cmp \u2192 (ins cmp x t).Ordered cmp\n  | nil, _ => \u27e8\u27e8\u27e9, \u27e8\u27e9, \u27e8\u27e9, \u27e8\u27e9\u27e9\n  | node red a y b, \u27e8ay, yb, ha, hb\u27e9 => by\n    unfold ins; split\n    \u00b7 next h => exact \u27e8ay.ins \u27e8h\u27e9, yb, ha.ins, hb\u27e9\n    \u00b7 next h => exact \u27e8ay, yb.ins \u27e8OrientedCmp.cmp_eq_gt.1 h\u27e9, ha, hb.ins\u27e9\n    \u00b7 next h => exact (\u27e8\n        ay.imp fun \u27e8h'\u27e9 => \u27e8(TransCmp.cmp_congr_right h).trans h'\u27e9,\n        yb.imp fun \u27e8h'\u27e9 => \u27e8(TransCmp.cmp_congr_left h).trans h'\u27e9, ha, hb\u27e9)\n  | node black a y b, \u27e8ay, yb, ha, hb\u27e9 => by\n    unfold ins; split\n    \u00b7 next h => exact ha.ins.balance1 (ay.ins \u27e8h\u27e9) yb hb\n    \u00b7 next h => exact ha.balance2 ay (yb.ins \u27e8OrientedCmp.cmp_eq_gt.1 h\u27e9) hb.ins\n    \u00b7 next h => exact (\u27e8\n        ay.imp fun \u27e8h'\u27e9 => \u27e8(TransCmp.cmp_congr_right h).trans h'\u27e9,\n        yb.imp fun \u27e8h'\u27e9 => \u27e8(TransCmp.cmp_congr_left h).trans h'\u27e9, ha, hb\u27e9)\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 \u03b1 \u2192 Nat \u2192 Prop where\n  /-- A balanced tree has the red-red invariant. -/\n  | balanced : Balanced t c n \u2192 RedRed p t n\n  /-- A red node with balanced red children has the red-red invariant (if `p` is true). -/\n  | redred : p \u2192 Balanced a c\u2081 n \u2192 Balanced b c\u2082 n \u2192 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 : \u00acp) : RedRed p t n \u2192 \u2203 c, Balanced t c n\n  | .balanced h => \u27e8_, h\u27e9\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 \u2192\n    \u2203 c\u2081 c\u2082, Balanced a c\u2081 n \u2227 Balanced b c\u2082 n\n  | .balanced (.red ha hb) | .redred _ ha hb => \u27e8_, _, ha, hb\u27e9\n\n/-- The red-red invariant is monotonic in `p`. -/\nprotected theorem RedRed.imp (h : p \u2192 q) : RedRed p t n \u2192 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 \u2192 \u2203 n', (setBlack t).Balanced black n'\n  | .balanced h => h.setBlack\n  | .redred _ hl hr => \u27e8_, hl.black hr\u27e9\n\n/-- The `balance1` function repairs the balance invariant when the first argument is red-red. -/\nprotected theorem RedRed.balance1 {l : RBNode \u03b1} {v : \u03b1} {r : RBNode \u03b1}\n    (hl : l.RedRed p n) (hr : r.Balanced c n) : \u2203 c, (balance1 l v r).Balanced c (n + 1) := by\n  unfold balance1; split\n  \u00b7 have .redred _ (.red ha hb) hc := hl; exact \u27e8_, .red (.black ha hb) (.black hc hr)\u27e9\n  \u00b7 have .redred _ ha (.red hb hc) := hl; exact \u27e8_, .red (.black ha hb) (.black hc hr)\u27e9\n  \u00b7 next H1 H2 => match hl with\n    | .balanced hl => exact \u27e8_, .black hl hr\u27e9\n    | .redred _ (c\u2081 := black) (c\u2082 := black) ha hb => exact \u27e8_, .black (.red ha hb) hr\u27e9\n    | .redred _ (c\u2081 := red) (.red ..) _ => cases H1 _ _ _ _ _ rfl\n    | .redred _ (c\u2082 := 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 \u03b1} {v : \u03b1} {r : RBNode \u03b1}\n    (hl : l.Balanced c n) (hr : r.RedRed p n) : \u2203 c, (balance2 l v r).Balanced c (n + 1) := by\n  unfold balance2; split\n  \u00b7 have .redred _ (.red ha hb) hc := hr; exact \u27e8_, .red (.black hl ha) (.black hb hc)\u27e9\n  \u00b7 have .redred _ ha (.red hb hc) := hr; exact \u27e8_, .red (.black hl ha) (.black hb hc)\u27e9\n  \u00b7 next H1 H2 => match hr with\n    | .balanced hr => exact \u27e8_, .black hl hr\u27e9\n    | .redred _ (c\u2081 := black) (c\u2082 := black) ha hb => exact \u27e8_, .black hl (.red ha hb)\u27e9\n    | .redred _ (c\u2081 := red) (.red ..) _ => cases H1 _ _ _ _ _ rfl\n    | .redred _ (c\u2082 := red) _ (.red ..) => cases H2 _ _ _ _ _ rfl\n\n/-- The `balance1` function does nothing if the first argument is already balanced. -/\ntheorem balance1_eq {l : RBNode \u03b1} {v : \u03b1} {r : RBNode \u03b1}\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 \u03b1} {v : \u03b1} {r : RBNode \u03b1}\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 \u03b1}\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    \u00b7 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    \u00b7 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    \u00b7 exact .balanced (.red hl hr)\n  | @black a ca n b cb x hl hr ihl ihr =>\n    unfold ins; split\n    \u00b7 exact have \u27e8c, h\u27e9 := ihl.balance1 hr; .balanced h\n    \u00b7 exact have \u27e8c, h\u27e9 := ihr.balance2 hl; .balanced h\n    \u00b7 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 \u03b1} (h : t.Balanced c n) :\n    \u2203 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 \u27e8_, h.setBlack\u27e9, exact \u27e8_, _, h\u27e9]\n  | _, .redred _ ha hb => have .node red .. := t; exact \u27e8_, _, .black ha hb\u27e9\n\nprotected theorem All.setRed {t : RBNode \u03b1} (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 \u03b1} : (setRed t).Ordered cmp \u2194 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 \u03b1} {v : \u03b1} {r : RBNode \u03b1}\n    (lv : l.All (cmpLT cmp \u00b7 v)) (vr : r.All (cmpLT cmp v \u00b7))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balLeft l v r).Ordered cmp := by\n  unfold balLeft; split\n  \u00b7 exact \u27e8lv, vr, hl, hr\u27e9\n  split\n  \u00b7 exact hl.balance2 lv vr hr\n  \u00b7 have \u27e8vy, va, _\u27e9 := vr.2.1; have \u27e8\u27e8yz, _, bz\u27e9, zc, \u27e8ay, yb, ha, hb\u27e9, hc\u27e9 := hr\n    exact \u27e8\u27e8vy, vy.trans_r lv, ay\u27e9, balance2_All.2 \u27e8yz, yb, (yz.trans_l zc).setRed\u27e9,\n      \u27e8lv, va, hl, ha\u27e9, hb.balance2 bz zc.setRed (Ordered.setRed.2 hc)\u27e9\n  \u00b7 exact \u27e8lv, vr, hl, hr\u27e9\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  \u00b7 next a x b => exact\n    let \u27e8ca, cb, ha, hb\u27e9 := hl.of_red\n    match cr with\n    | red => .redred rfl (.black ha hb) hr\n    | black => .balanced (.red (.black ha hb) hr)\n  \u00b7 next H => exact match hl with\n    | .redred .. => nomatch H _ _ _ rfl\n    | .balanced hl => match hr with\n      | .black ha hb =>\n        let \u27e8c, h\u27e9 := RedRed.balance2 hl (.redred trivial ha hb); .balanced h\n      | .red (.black ha hb) (.black hc hd) =>\n        let \u27e8c, h\u27e9 := 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 \u03b1} {v : \u03b1} {r : RBNode \u03b1}\n    (lv : l.All (cmpLT cmp \u00b7 v)) (vr : r.All (cmpLT cmp v \u00b7))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (balRight l v r).Ordered cmp := by\n  unfold balRight; split\n  \u00b7 exact \u27e8lv, vr, hl, hr\u27e9\n  split\n  \u00b7 exact hl.balance1 lv vr hr\n  \u00b7 have \u27e8yv, _, cv\u27e9 := lv.2.2; have \u27e8ax, \u27e8xy, xb, _\u27e9, ha, by_, yc, hb, hc\u27e9 := hl\n    exact \u27e8balance1_All.2 \u27e8xy, (xy.trans_r ax).setRed, by_\u27e9, \u27e8yv, yc, yv.trans_l vr\u27e9,\n      (Ordered.setRed.2 ha).balance1 ax.setRed xb hb, cv, vr, hc, hr\u27e9\n  \u00b7 exact \u27e8lv, vr, hl, hr\u27e9\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  \u00b7 next b y c => exact\n    let \u27e8cb, cc, hb, hc\u27e9 := hr.of_red\n    match cl with\n    | red => .redred rfl hl (.black hb hc)\n    | black => .balanced (.red hl (.black hb hc))\n  \u00b7 next H => exact match hr with\n    | .redred .. => nomatch H _ _ _ rfl\n    | .balanced hr => match hl with\n      | .black hb hc =>\n        let \u27e8c, h\u27e9 := RedRed.balance1 (.redred trivial hb hc) hr; .balanced h\n      | .red (.black ha hb) (.black hc hd) =>\n        let \u27e8c, h\u27e9 := 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  \u00b7 have \u27e8hx, ha, hb\u27e9 := hl; have \u27e8hy, hc, hd\u27e9 := hr\n    have := hb.append hc; split <;> simp_all\n  \u00b7 have \u27e8hx, ha, hb\u27e9 := hl; have \u27e8hy, hc, hd\u27e9 := hr\n    have := hb.append hc; split <;> simp_all [All.balLeft]\n  \u00b7 simp_all [hl.append hr.2.1]\n  \u00b7 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 \u03b1} {v : \u03b1} {r : RBNode \u03b1}\n    (lv : l.All (cmpLT cmp \u00b7 v)) (vr : r.All (cmpLT cmp v \u00b7))\n    (hl : l.Ordered cmp) (hr : r.Ordered cmp) : (append l r).Ordered cmp := by\n  unfold append; split\n  \u00b7 exact hr\n  \u00b7 exact hl\n  \u00b7 have \u27e8xv, _, bv\u27e9 := lv; have \u27e8ax, xb, ha, hb\u27e9 := hl\n    have \u27e8vy, vc, _\u27e9 := vr; have \u27e8cy, yd, hc, hd\u27e9 := hr\n    have : _ \u2227 _ \u2227 _ := \u27e8hb.append bv vc hc, xb.append (xv.trans_l vc), (vy.trans_r bv).append cy\u27e9\n    split\n    \u00b7 next H =>\n      have \u27e8\u27e8b'z, c'z, hb', hc'\u27e9, \u27e8xz, xb', _\u27e9, zy, _, c'y\u27e9 := H \u25b8 this\n      have az := xz.trans_r ax; have zd := zy.trans_l yd\n      exact \u27e8\u27e8xz, az, b'z\u27e9, \u27e8zy, c'z, zd\u27e9, \u27e8ax, xb', ha, hb'\u27e9, c'y, yd, hc', hd\u27e9\n    \u00b7 have \u27e8hbc, xbc, bcy\u27e9 := this; have xy := xv.trans vy\n      exact \u27e8ax, \u27e8xy, xbc, xy.trans_l yd\u27e9, ha, bcy, yd, hbc, hd\u27e9\n  \u00b7 have \u27e8xv, _, bv\u27e9 := lv; have \u27e8ax, xb, ha, hb\u27e9 := hl\n    have \u27e8vy, vc, _\u27e9 := vr; have \u27e8cy, yd, hc, hd\u27e9 := hr\n    have : _ \u2227 _ \u2227 _ := \u27e8hb.append bv vc hc, xb.append (xv.trans_l vc), (vy.trans_r bv).append cy\u27e9\n    split\n    \u00b7 next H =>\n      have \u27e8\u27e8b'z, c'z, hb', hc'\u27e9, \u27e8xz, xb', _\u27e9, zy, _, c'y\u27e9 := H \u25b8 this\n      have az := xz.trans_r ax; have zd := zy.trans_l yd\n      exact \u27e8\u27e8xz, az, b'z\u27e9, \u27e8zy, c'z, zd\u27e9, \u27e8ax, xb', ha, hb'\u27e9, c'y, yd, hc', hd\u27e9\n    \u00b7 have \u27e8hbc, xbc, bcy\u27e9 := this; have xy := xv.trans vy\n      exact ha.balLeft ax \u27e8xy, xbc, xy.trans_l yd\u27e9 \u27e8bcy, yd, hbc, hd\u27e9\n  \u00b7 have \u27e8vx, vb, _\u27e9 := vr; have \u27e8bx, yc, hb, hc\u27e9 := hr\n    exact \u27e8(vx.trans_r lv).append bx, yc, hl.append lv vb hb, hc\u27e9\n  \u00b7 have \u27e8xv, _, bv\u27e9 := lv; have \u27e8ax, xb, ha, hb\u27e9 := hl\n    exact \u27e8ax, xb.append (xv.trans_l vr), ha, hb.append bv vr hr\u27e9\ntermination_by _ => l.size + r.size\n\n/-- The balance properties of the `append` function. -/\nprotected theorem Balanced.append {l r : RBNode \u03b1}\n    (hl : l.Balanced c\u2081 n) (hr : r.Balanced c\u2082 n) :\n    (l.append r).RedRed (c\u2081 = black \u2192 c\u2082 \u2260 black) n := by\n  unfold append; split\n  \u00b7 exact .balanced hr\n  \u00b7 exact .balanced hl\n  \u00b7 next b c _ _ =>\n    have .red ha hb := hl; have .red hc hd := hr\n    have \u27e8_, IH\u27e9 := (hb.append hc).of_false (\u00b7 rfl rfl); split\n    \u00b7 next e =>\n      have .red hb' hc' := e \u25b8 IH\n      exact .redred (fun.) (.red ha hb') (.red hc' hd)\n    \u00b7 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  \u00b7 next b c _ _ =>\n    have .black ha hb := hl; have .black hc hd := hr\n    have IH := hb.append hc; split\n    \u00b7 next e => match e \u25b8 IH with\n      | .balanced (.red hb' hc') | .redred _ hb' hc' =>\n        exact .balanced (.red (.black ha hb') (.black hc' hd))\n    \u00b7 next H =>\n      match append b c, IH, H with\n      | bc, .balanced hbc, _ =>\n        unfold balLeft; split\n        \u00b7 have .red ha' hb' := ha\n          exact .balanced (.red (.black ha' hb') (.black hbc hd))\n        \u00b7 exact have \u27e8c, h\u27e9 := RedRed.balance2 ha (.redred trivial hbc hd); .balanced h\n      | _, .redred .., H => cases H _ _ _ rfl\n  \u00b7 have .red hc hd := hr; have IH := hl.append hc\n    have .black ha hb := hl; have \u27e8c, IH\u27e9 := IH.of_false (\u00b7 rfl rfl)\n    exact .redred (fun.) IH hd\n  \u00b7 have .red ha hb := hl; have IH := hb.append hr\n    have .black hc hd := hr; have \u27e8c, IH\u27e9 := IH.of_false (\u00b7 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 \u03b1) (n : Nat) : Prop :=\n  match p with\n  | black => \u2203 n', n = n' + 1 \u2227 RedRed True t n'\n  | red => \u2203 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) : \u2203 n', RedRed (c = black) t n' := by\n  unfold DelProp at h\n  exact match c, h with\n  | red, \u27e8_, h\u27e9 => \u27e8_, .balanced h\u27e9\n  | black, \u27e8_, _, h\u27e9 => \u27e8_, h.imp fun _ => rfl\u27e9\n\nprotected theorem All.del : \u2200 {t : RBNode \u03b1}, t.All p \u2192 (del cut t).All p\n  | .nil, h => h\n  | .node .., \u27e8hy, ha, hb\u27e9 => by\n    unfold del; split\n    \u00b7 split\n      \u00b7 exact ha.del.balLeft hy hb\n      \u00b7 exact \u27e8hy, ha.del, hb\u27e9\n    \u00b7 split\n      \u00b7 exact ha.balRight hy hb.del\n      \u00b7 exact \u27e8hy, ha, hb.del\u27e9\n    \u00b7 exact ha.append hb\n\n/-- The `del` function preserves the ordering invariants. -/\nprotected theorem Ordered.del : \u2200 {t : RBNode \u03b1}, t.Ordered cmp \u2192 (del cut t).Ordered cmp\n  | .nil, _ => \u27e8\u27e9\n  | .node _ a y b, \u27e8ay, yb, ha, hb\u27e9 => by\n    unfold del; split\n    \u00b7 split\n      \u00b7 exact ha.del.balLeft ay.del yb hb\n      \u00b7 exact \u27e8ay.del, yb, ha.del, hb\u27e9\n    \u00b7 split\n      \u00b7 exact ha.balRight ay yb.del hb.del\n      \u00b7 exact \u27e8ay, yb.del, ha, hb.del\u27e9\n    \u00b7 exact ha.append ay yb hb\n\n/-- The `del` function has the `DelProp` property. -/\nprotected theorem Balanced.del {t : RBNode \u03b1} (h : t.Balanced c n) :\n    (t.del cut).DelProp t.isBlack n := by\n  induction h with\n  | nil => exact \u27e8_, .nil\u27e9\n  | @black a _ n b _ _ ha hb iha ihb =>\n    refine \u27e8_, rfl, ?_\u27e9\n    unfold del; split\n    \u00b7 exact match a, n, iha with\n      | .nil, _, \u27e8c, ha\u27e9 | .node red .., _, \u27e8c, ha\u27e9 => .redred \u27e8\u27e9 ha hb\n      | .node black .., _, \u27e8n, rfl, ha\u27e9 => (hb.balLeft ha).imp fun _ => \u27e8\u27e9\n    \u00b7 exact match b, n, ihb with\n      | .nil, _, \u27e8c, hb\u27e9 | .node .red .., _, \u27e8c, hb\u27e9 => .redred \u27e8\u27e9 ha hb\n      | .node black .., _, \u27e8n, rfl, hb\u27e9 => (ha.balRight hb).imp fun _ => \u27e8\u27e9\n    \u00b7 exact (ha.append hb).imp fun _ => \u27e8\u27e9\n  | @red a n b _ ha hb iha ihb =>\n    unfold del; split\n    \u00b7 exact match a, n, iha with\n      | .nil, _, _ => \u27e8_, .red ha hb\u27e9\n      | .node black .., _, \u27e8n, rfl, ha\u27e9 => (hb.balLeft ha).of_false (fun.)\n    \u00b7 exact match b, n, ihb with\n      | .nil, _, _ => \u27e8_, .red ha hb\u27e9\n      | .node black .., _, \u27e8n, rfl, hb\u27e9 => (ha.balRight hb).of_false (fun.)\n    \u00b7 exact (ha.append hb).of_false (\u00b7 rfl rfl)\n\n/-- The `erase` function preserves the ordering invariants. -/\nprotected theorem Ordered.erase {t : RBNode \u03b1} (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 \u03b1}\n    (h : t.Balanced c n) : \u2203 n, (t.erase cut).Balanced black n :=\n  have \u27e8_, h\u27e9 := h.del.redred; h.setBlack\n\n/-- The well-formedness invariant implies the ordering and balance properties. -/\ntheorem WF.out {t : RBNode \u03b1} (h : t.WF cmp) : t.Ordered cmp \u2227 \u2203 c n, t.Balanced c n := by\n  induction h with\n  | mk o h => exact \u27e8o, _, _, h\u27e9\n  | insert _ ih => have \u27e8o, _, _, h\u27e9 := ih; exact \u27e8o.insert, h.insert\u27e9\n  | erase _ ih => have \u27e8o, _, _, h\u27e9 := ih; exact \u27e8o.erase, _, h.erase\u27e9\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 \u03b1} : t.WF cmp \u2194 t.Ordered cmp \u2227 \u2203 c n, t.Balanced c n :=\n  \u27e8fun h => h.out, fun \u27e8o, _, _, h\u27e9 => .mk o h\u27e9\n\n/-- The `map` function preserves the balance invariants. -/\nprotected theorem Balanced.map {t : RBNode \u03b1} : t.Balanced c n \u2192 (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\u03b1 cmp\u03b2) (f : \u03b1 \u2192 \u03b2) : Prop where\n  /-- If `x < y` then `f x < f y`. -/\n  lt_mono : cmpLT cmp\u03b1 x y \u2192 cmpLT cmp\u03b2 (f x) (f y)\n\n/-- Sufficient condition for `map` to preserve an `All` quantifier. -/\nprotected theorem All.map {f : \u03b1 \u2192 \u03b2} (H : \u2200 {x}, p x \u2192 q (f x)) :\n    \u2200 {t : RBNode \u03b1}, t.All p \u2192 (t.map f).All q\n  | nil, _ => \u27e8\u27e9\n  | node .., \u27e8hx, ha, hb\u27e9 => \u27e8H hx, ha.map H, hb.map H\u27e9\n\n/-- The `map` function preserves the order invariants if `f` is monotone. -/\nprotected theorem Ordered.map (f : \u03b1 \u2192 \u03b2) [IsMonotone cmp\u03b1 cmp\u03b2 f] :\n    \u2200 {t : RBNode \u03b1}, t.Ordered cmp\u03b1 \u2192 (t.map f).Ordered cmp\u03b2\n  | nil, _ => \u27e8\u27e9\n  | node _ a x b, \u27e8ax, xb, ha, hb\u27e9 => by\n    refine \u27e8ax.map ?_, xb.map ?_, ha.map f, hb.map f\u27e9 <;> 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 : \u03b1 \u2192 \u03b2) [IsMonotone cmp\u03b1 cmp\u03b2 f] (t : RBSet \u03b1 cmp\u03b1) : RBSet \u03b2 cmp\u03b2 :=\n  \u27e8t.1.map f, have \u27e8h\u2081, _, _, h\u2082\u27e9 := t.2.out; .mk (h\u2081.map _) h\u2082.map\u27e9\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 : \u03b1 \u2192 \u03b2 \u2192 \u03b3) := fun (a, b) => (a, f a b)\n\ninstance (cmp : \u03b1 \u2192 \u03b1 \u2192 Ordering) (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) :\n    IsMonotone (byKey Prod.fst cmp) (byKey Prod.fst cmp) (mapSnd f) where\n  lt_mono | \u27e8h\u27e9 => \u27e8@fun _ => @h {\n    symm := fun (a\u2081, b\u2081) (a\u2082, b\u2082) =>\n      OrientedCmp.symm (cmp := byKey Prod.fst cmp) (a\u2081, f a\u2081 b\u2081) (a\u2082, f a\u2082 b\u2082)\n    le_trans := @fun (a\u2081, b\u2081) (a\u2082, b\u2082) (a\u2083, b\u2083) =>\n      TransCmp.le_trans (cmp := byKey Prod.fst cmp)\n        (x := (a\u2081, f a\u2081 b\u2081)) (y := (a\u2082, f a\u2082 b\u2082)) (z := (a\u2083, f a\u2083 b\u2083))\n  }\u27e9\n\nend Imp\n\n/-- `O(n)`. Map a function on the values in the map. -/\ndef mapVal (f : \u03b1 \u2192 \u03b2 \u2192 \u03b3) (t : RBMap \u03b1 \u03b2 cmp) : RBMap \u03b1 \u03b3 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\u2082\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 \u2243 walking_pair :=\n{ to_fun := \u03bb j, walking_pair.rec_on j right left,\n  inv_fun := \u03bb j, walking_pair.rec_on j right left,\n  left_inv := \u03bb j, by { cases j; refl, },\n  right_inv := \u03bb 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 \u2243 bool :=\n{ to_fun := \u03bb j, walking_pair.rec_on j tt ff, -- to match equiv.sum_equiv_sigma_bool\n  inv_fun := \u03bb b, bool.rec_on b right left,\n  left_inv := \u03bb j, by { cases j; refl, },\n  right_inv := \u03bb 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 \u2192 C := \u03bb 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 \u2964 C :=\ndiscrete.functor (\u03bb j, walking_pair.cases_on j X Y)\n\n@[simp] lemma pair_obj_left (X Y : C) : (pair X Y).obj \u27e8left\u27e9 = X := rfl\n@[simp] lemma pair_obj_right (X Y : C) : (pair X Y).obj \u27e8right\u27e9 = Y := rfl\n\nsection\nvariables {F G : discrete walking_pair \u2964 C} (f : F.obj \u27e8left\u27e9 \u27f6 G.obj \u27e8left\u27e9)\n  (g : F.obj \u27e8right\u27e9 \u27f6 G.obj \u27e8right\u27e9)\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 \u27f6 G := { app := \u03bb j, discrete.rec_on j (\u03bb j, walking_pair.cases_on j f g) }\n\n@[simp] lemma map_pair_left : (map_pair f g).app \u27e8left\u27e9 = f := rfl\n@[simp] lemma map_pair_right : (map_pair f g).app \u27e8right\u27e9 = 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 \u27e8left\u27e9 \u2245 G.obj \u27e8left\u27e9) (g : F.obj \u27e8right\u27e9 \u2245 G.obj \u27e8right\u27e9) : F \u2245 G :=\nnat_iso.of_components (\u03bb j, discrete.rec_on j (\u03bb 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 \u2964 C) :\n  F \u2245 pair (F.obj \u27e8walking_pair.left\u27e9) (F.obj \u27e8walking_pair.right\u27e9) :=\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 \u22d9 F` and `pair (F.obj X) (F.obj Y)`. -/\ndef pair_comp (X Y : C) (F : C \u2964 D) : pair X Y \u22d9 F \u2245 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.\u03c0.app \u27e8walking_pair.left\u27e9\n\n/-- The second projection of a binary fan. -/\nabbreviation binary_fan.snd {X Y : C} (s : binary_fan X Y) := s.\u03c0.app \u27e8walking_pair.right\u27e9\n\n@[simp] lemma binary_fan.\u03c0_app_left {X Y : C} (s : binary_fan X Y) :\n  s.\u03c0.app \u27e8walking_pair.left\u27e9 = s.fst := rfl\n@[simp] lemma binary_fan.\u03c0_app_right {X Y : C} (s : binary_fan X Y) :\n  s.\u03c0.app \u27e8walking_pair.right\u27e9 = 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 : \u03a0 {T : C} (f : T \u27f6 X) (g : T \u27f6 Y), T \u27f6 s.X)\n  (hl\u2081 : \u2200 {T : C} (f : T \u27f6 X) (g : T \u27f6 Y), lift f g \u226b s.fst = f)\n  (hl\u2082 : \u2200 {T : C} (f : T \u27f6 X) (g : T \u27f6 Y), lift f g \u226b s.snd = g)\n  (uniq : \u2200 {T : C} (f : T \u27f6 X) (g : T \u27f6 Y) (m : T \u27f6 s.X) (h\u2081 : m \u226b s.fst = f)\n    (h\u2082 : m \u226b s.snd = g), m = lift f g) : is_limit s := is_limit.mk\n  (\u03bb t, lift (binary_fan.fst t) (binary_fan.snd t))\n  (by { rintros t (rfl|rfl), { exact hl\u2081 _ _ }, { exact hl\u2082 _ _ } })\n  (\u03bb t m h, uniq _ _ _ (h \u27e8walking_pair.left\u27e9) (h \u27e8walking_pair.right\u27e9))\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 \u27f6 s.X} (h\u2081 : f \u226b s.fst = g \u226b s.fst) (h\u2082 : f \u226b s.snd = g \u226b s.snd) : f = g :=\nh.hom_ext $ \u03bb j, discrete.rec_on j (\u03bb j, walking_pair.cases_on j h\u2081 h\u2082)\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.\u03b9.app \u27e8walking_pair.left\u27e9\n\n/-- The second inclusion of a binary cofan. -/\nabbreviation binary_cofan.inr {X Y : C} (s : binary_cofan X Y) := s.\u03b9.app \u27e8walking_pair.right\u27e9\n\n@[simp] lemma binary_cofan.\u03b9_app_left {X Y : C} (s : binary_cofan X Y) :\n  s.\u03b9.app \u27e8walking_pair.left\u27e9 = s.inl := rfl\n@[simp] lemma binary_cofan.\u03b9_app_right {X Y : C} (s : binary_cofan X Y) :\n  s.\u03b9.app \u27e8walking_pair.right\u27e9 = 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 : \u03a0 {T : C} (f : X \u27f6 T) (g : Y \u27f6 T), s.X \u27f6 T)\n  (hd\u2081 : \u2200 {T : C} (f : X \u27f6 T) (g : Y \u27f6 T), s.inl \u226b desc f g = f)\n  (hd\u2082 : \u2200 {T : C} (f : X \u27f6 T) (g : Y \u27f6 T), s.inr \u226b desc f g = g)\n  (uniq : \u2200 {T : C} (f : X \u27f6 T) (g : Y \u27f6 T) (m : s.X \u27f6 T) (h\u2081 : s.inl \u226b m = f)\n    (h\u2082 : s.inr \u226b m = g), m = desc f g) : is_colimit s := is_colimit.mk\n    (\u03bb t, desc (binary_cofan.inl t) (binary_cofan.inr t))\n    (by { rintros t (rfl|rfl), { exact hd\u2081 _ _ }, { exact hd\u2082 _ _ }})\n    (\u03bb t m h, uniq _ _ _ (h \u27e8walking_pair.left\u27e9) (h \u27e8walking_pair.right\u27e9))\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 \u27f6 W} (h\u2081 : s.inl \u226b f = s.inl \u226b g) (h\u2082 : s.inr \u226b f = s.inr \u226b g) : f = g :=\nh.hom_ext $ \u03bb j, discrete.rec_on j (\u03bb j, walking_pair.cases_on j h\u2081 h\u2082)\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 `\u03c0\u2081 : P \u27f6 X` and `\u03c0\u2082 : P \u27f6 Y`. -/\n@[simps X]\ndef binary_fan.mk {P : C} (\u03c0\u2081 : P \u27f6 X) (\u03c0\u2082 : P \u27f6 Y) : binary_fan X Y :=\n{ X := P,\n  \u03c0 := { app := \u03bb j, discrete.rec_on j (\u03bb j, walking_pair.cases_on j \u03c0\u2081 \u03c0\u2082) }}\n\n/-- A binary cofan with vertex `P` consists of the two inclusions `\u03b9\u2081 : X \u27f6 P` and `\u03b9\u2082 : Y \u27f6 P`. -/\n@[simps X]\ndef binary_cofan.mk {P : C} (\u03b9\u2081 : X \u27f6 P) (\u03b9\u2082 : Y \u27f6 P) : binary_cofan X Y :=\n{ X := P,\n  \u03b9 := { app := \u03bb j, discrete.rec_on j (\u03bb j, walking_pair.cases_on j \u03b9\u2081 \u03b9\u2082) }}\n\nend\n\n@[simp] lemma binary_fan.mk_\u03c0_app_left {P : C} (\u03c0\u2081 : P \u27f6 X) (\u03c0\u2082 : P \u27f6 Y) :\n  (binary_fan.mk \u03c0\u2081 \u03c0\u2082).\u03c0.app \u27e8walking_pair.left\u27e9 = \u03c0\u2081 := rfl\n@[simp] lemma binary_fan.mk_\u03c0_app_right {P : C} (\u03c0\u2081 : P \u27f6 X) (\u03c0\u2082 : P \u27f6 Y) :\n  (binary_fan.mk \u03c0\u2081 \u03c0\u2082).\u03c0.app \u27e8walking_pair.right\u27e9 = \u03c0\u2082 := rfl\n@[simp] lemma binary_cofan.mk_\u03b9_app_left {P : C} (\u03b9\u2081 : X \u27f6 P) (\u03b9\u2082 : Y \u27f6 P) :\n  (binary_cofan.mk \u03b9\u2081 \u03b9\u2082).\u03b9.app \u27e8walking_pair.left\u27e9 = \u03b9\u2081 := rfl\n@[simp] lemma binary_cofan.mk_\u03b9_app_right {P : C} (\u03b9\u2081 : X \u27f6 P) (\u03b9\u2082 : Y \u27f6 P) :\n  (binary_cofan.mk \u03b9\u2081 \u03b9\u2082).\u03b9.app \u27e8walking_pair.right\u27e9 = \u03b9\u2082 := rfl\n\n/-- If `s` is a limit binary fan over `X` and `Y`, then every pair of morphisms `f : W \u27f6 X` and\n    `g : W \u27f6 Y` induces a morphism `l : W \u27f6 s.X` satisfying `l \u226b s.fst = f` and `l \u226b 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 \u27f6 X)\n  (g : W \u27f6 Y) : {l : W \u27f6 s.X // l \u226b s.fst = f \u2227 l \u226b s.snd = g} :=\n\u27e8h.lift $ binary_fan.mk f g, h.fac _ _, h.fac _ _\u27e9\n\n/-- If `s` is a colimit binary cofan over `X` and `Y`,, then every pair of morphisms `f : X \u27f6 W` and\n    `g : Y \u27f6 W` induces a morphism `l : s.X \u27f6 W` satisfying `s.inl \u226b l = f` and `s.inr \u226b 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 \u27f6 W)\n  (g : Y \u27f6 W) : {l : s.X \u27f6 W // s.inl \u226b l = f \u2227 s.inr \u226b l = g} :=\n\u27e8h.desc $ binary_cofan.mk f g, h.fac _ _, h.fac _ _\u27e9\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 \u2a2f 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 \u2a3f Y`. -/\nabbreviation coprod (X Y : C) [has_binary_coproduct X Y] := colimit (pair X Y)\n\nnotation X ` \u2a2f `:20 Y:20 := prod X Y\nnotation X ` \u2a3f `: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 \u2a2f Y \u27f6 X :=\nlimit.\u03c0 (pair X Y) \u27e8walking_pair.left\u27e9\n\n/-- The projecton map to the second component of the product. -/\nabbreviation prod.snd {X Y : C} [has_binary_product X Y] : X \u2a2f Y \u27f6 Y :=\nlimit.\u03c0 (pair X Y) \u27e8walking_pair.right\u27e9\n\n/-- The inclusion map from the first component of the coproduct. -/\nabbreviation coprod.inl {X Y : C} [has_binary_coproduct X Y] : X \u27f6 X \u2a3f Y :=\ncolimit.\u03b9 (pair X Y) \u27e8walking_pair.left\u27e9\n\n/-- The inclusion map from the second component of the coproduct. -/\nabbreviation coprod.inr {X Y : C} [has_binary_coproduct X Y] : Y \u27f6 X \u2a3f Y :=\ncolimit.\u03b9 (pair X Y) \u27e8walking_pair.right\u27e9\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 \u2a2f Y \u27f6 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 \u27f6 X \u2a3f 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 \u27f6 X \u2a2f Y}\n  (h\u2081 : f \u226b prod.fst = g \u226b prod.fst) (h\u2082 : f \u226b prod.snd = g \u226b prod.snd) : f = g :=\nbinary_fan.is_limit.hom_ext (limit.is_limit _) h\u2081 h\u2082\n\n@[ext] lemma coprod.hom_ext {W X Y : C} [has_binary_coproduct X Y] {f g : X \u2a3f Y \u27f6 W}\n  (h\u2081 : coprod.inl \u226b f = coprod.inl \u226b g) (h\u2082 : coprod.inr \u226b f = coprod.inr \u226b g) : f = g :=\nbinary_cofan.is_colimit.hom_ext (colimit.is_colimit _) h\u2081 h\u2082\n\n/-- If the product of `X` and `Y` exists, then every pair of morphisms `f : W \u27f6 X` and `g : W \u27f6 Y`\n    induces a morphism `prod.lift f g : W \u27f6 X \u2a2f Y`. -/\nabbreviation prod.lift {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 Y) : W \u27f6 X \u2a2f 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 \u27f6 X \u2a2f X :=\nprod.lift (\ud835\udfd9 _) (\ud835\udfd9 _)\n\n/-- If the coproduct of `X` and `Y` exists, then every pair of morphisms `f : X \u27f6 W` and\n    `g : Y \u27f6 W` induces a morphism `coprod.desc f g : X \u2a3f Y \u27f6 W`. -/\nabbreviation coprod.desc {W X Y : C} [has_binary_coproduct X Y] (f : X \u27f6 W) (g : Y \u27f6 W) :\n  X \u2a3f Y \u27f6 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 \u2a3f X \u27f6 X :=\ncoprod.desc (\ud835\udfd9 _) (\ud835\udfd9 _)\n\n@[simp, reassoc]\nlemma prod.lift_fst {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 Y) :\n  prod.lift f g \u226b prod.fst = f :=\nlimit.lift_\u03c0 _ _\n\n@[simp, reassoc]\nlemma prod.lift_snd {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 Y) :\n  prod.lift f g \u226b prod.snd = g :=\nlimit.lift_\u03c0 _ _\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 \u27f6 W) (g : Y \u27f6 W) :\n  coprod.inl \u226b coprod.desc f g = f :=\ncolimit.\u03b9_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 \u27f6 W) (g : Y \u27f6 W) :\n  coprod.inr \u226b coprod.desc f g = g :=\ncolimit.\u03b9_desc _ _\n\ninstance prod.mono_lift_of_mono_left {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 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 \u27f6 X) (g : W \u27f6 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 \u27f6 W) (g : Y \u27f6 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 \u27f6 W) (g : Y \u27f6 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 \u27f6 X` and `g : W \u27f6 Y`\n    induces a morphism `l : W \u27f6 X \u2a2f Y` satisfying `l \u226b prod.fst = f` and `l \u226b prod.snd = g`. -/\ndef prod.lift' {W X Y : C} [has_binary_product X Y] (f : W \u27f6 X) (g : W \u27f6 Y) :\n  {l : W \u27f6 X \u2a2f Y // l \u226b prod.fst = f \u2227 l \u226b prod.snd = g} :=\n\u27e8prod.lift f g, prod.lift_fst _ _, prod.lift_snd _ _\u27e9\n\n/-- If the coproduct of `X` and `Y` exists, then every pair of morphisms `f : X \u27f6 W` and\n    `g : Y \u27f6 W` induces a morphism `l : X \u2a3f Y \u27f6 W` satisfying `coprod.inl \u226b l = f` and\n    `coprod.inr \u226b l = g`. -/\ndef coprod.desc' {W X Y : C} [has_binary_coproduct X Y] (f : X \u27f6 W) (g : Y \u27f6 W) :\n  {l : X \u2a3f Y \u27f6 W // coprod.inl \u226b l = f \u2227 coprod.inr \u226b l = g} :=\n\u27e8coprod.desc f g, coprod.inl_desc _ _, coprod.inr_desc _ _\u27e9\n\n/-- If the products `W \u2a2f X` and `Y \u2a2f Z` exist, then every pair of morphisms `f : W \u27f6 Y` and\n    `g : X \u27f6 Z` induces a morphism `prod.map f g : W \u2a2f X \u27f6 Y \u2a2f Z`. -/\ndef prod.map {W X Y Z : C} [has_binary_product W X] [has_binary_product Y Z]\n  (f : W \u27f6 Y) (g : X \u27f6 Z) : W \u2a2f X \u27f6 Y \u2a2f Z :=\nlim_map (map_pair f g)\n\n/-- If the coproducts `W \u2a3f X` and `Y \u2a3f Z` exist, then every pair of morphisms `f : W \u27f6 Y` and\n    `g : W \u27f6 Z` induces a morphism `coprod.map f g : W \u2a3f X \u27f6 Y \u2a3f Z`. -/\ndef coprod.map {W X Y Z : C} [has_binary_coproduct W X] [has_binary_coproduct Y Z]\n  (f : W \u27f6 Y) (g : X \u27f6 Z) : W \u2a3f X \u27f6 Y \u2a3f 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 \u27f6 W) (g : W \u27f6 X) (h : W \u27f6 Y) :\n  f \u226b prod.lift g h = prod.lift (f \u226b g) (f \u226b h) :=\nby { ext; simp }\n\nlemma prod.comp_diag {X Y : C} [has_binary_product Y Y] (f : X \u27f6 Y) :\n  f \u226b 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 \u27f6 Y) (g : X \u27f6 Z) : prod.map f g \u226b prod.fst = prod.fst \u226b f :=\nlim_map_\u03c0 _ _\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 \u27f6 Y) (g : X \u27f6 Z) : prod.map f g \u226b prod.snd = prod.snd \u226b g :=\nlim_map_\u03c0 _ _\n\n@[simp] lemma prod.map_id_id {X Y : C} [has_binary_product X Y] :\n  prod.map (\ud835\udfd9 X) (\ud835\udfd9 Y) = \ud835\udfd9 _ :=\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 = \ud835\udfd9 (X \u2a2f 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 \u27f6 W) (g : V \u27f6 X) (h : W \u27f6 Y) (k : X \u27f6 Z) :\n  prod.lift f g \u226b prod.map h k = prod.lift (f \u226b h) (g \u226b 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 \u27f6 X) (g' : Y \u27f6 Z) :\n  prod.lift (prod.fst \u226b g) (prod.snd \u226b g') = prod.map g g' :=\nby { rw \u2190 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 \u226b h` and `g \u226b 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\u2081 A\u2082 A\u2083 B\u2081 B\u2082 B\u2083 : C}\n  [has_binary_product A\u2081 B\u2081] [has_binary_product A\u2082 B\u2082] [has_binary_product A\u2083 B\u2083]\n  (f : A\u2081 \u27f6 A\u2082) (g : B\u2081 \u27f6 B\u2082) (h : A\u2082 \u27f6 A\u2083) (k : B\u2082 \u27f6 B\u2083) :\n  prod.map f g \u226b prod.map h k = prod.map (f \u226b h) (g \u226b 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 \u27f6 B) (g : X \u27f6 Y)\n  [has_limits_of_shape (discrete walking_pair) C] :\n  prod.map (\ud835\udfd9 X) f \u226b prod.map g (\ud835\udfd9 B) = prod.map g (\ud835\udfd9 A) \u226b prod.map (\ud835\udfd9 Y) f :=\nby simp\n\n@[reassoc] lemma prod.map_comp_id {X Y Z W : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [has_binary_product X W] [has_binary_product Z W] [has_binary_product Y W] :\n  prod.map (f \u226b g) (\ud835\udfd9 W) = prod.map f (\ud835\udfd9 W) \u226b prod.map g (\ud835\udfd9 W) :=\nby simp\n\n@[reassoc] lemma prod.map_id_comp {X Y Z W : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [has_binary_product W X] [has_binary_product W Y] [has_binary_product W Z] :\n  prod.map (\ud835\udfd9 W) (f \u226b g) = prod.map (\ud835\udfd9 W) f \u226b prod.map (\ud835\udfd9 W) g :=\nby simp\n\n/-- If the products `W \u2a2f X` and `Y \u2a2f Z` exist, then every pair of isomorphisms `f : W \u2245 Y` and\n    `g : X \u2245 Z` induces an isomorphism `prod.map_iso f g : W \u2a2f X \u2245 Y \u2a2f 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 \u2245 Y) (g : X \u2245 Z) : W \u2a2f X \u2245 Y \u2a2f 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Y) (g : X \u27f6 Z) [mono f]\n  [mono g] [has_binary_product W X] [has_binary_product Y Z] : mono (prod.map f g) :=\n\u27e8\u03bb A i\u2081 i\u2082 h, begin\n  ext,\n  { rw \u2190 cancel_mono f, simpa using congr_arg (\u03bb f, f \u226b prod.fst) h },\n  { rw \u2190 cancel_mono g, simpa using congr_arg (\u03bb f, f \u226b prod.snd) h }\nend\u27e9\n\n@[simp, reassoc]\nlemma prod.diag_map {X Y : C} (f : X \u27f6 Y) [has_binary_product X X] [has_binary_product Y Y] :\n  diag X \u226b prod.map f f = f \u226b 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 \u2a2f Y) (X \u2a2f Y)] :\n  diag (X \u2a2f Y) \u226b prod.map prod.fst prod.snd = \ud835\udfd9 (X \u2a2f 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 \u27f6 Y) (g' : X' \u27f6 Y') :\n  diag (X \u2a2f X') \u226b prod.map (prod.fst \u226b g) (prod.snd \u226b 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 \u27f6 W) (g : X \u27f6 V)\n  (h : Y \u27f6 V) :\n  coprod.desc g h \u226b f = coprod.desc (g \u226b f) (h \u226b f) :=\nby { ext; simp }\n\nlemma coprod.diag_comp {X Y : C} [has_binary_coproduct X X] (f : X \u27f6 Y) :\n  codiag X \u226b 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 \u27f6 Y) (g : X \u27f6 Z) : coprod.inl \u226b coprod.map f g = f \u226b coprod.inl :=\n\u03b9_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 \u27f6 Y) (g : X \u27f6 Z) : coprod.inr \u226b coprod.map f g = g \u226b coprod.inr :=\n\u03b9_colim_map _ _\n\n@[simp]\nlemma coprod.map_id_id {X Y : C} [has_binary_coproduct X Y] :\n  coprod.map (\ud835\udfd9 X) (\ud835\udfd9 Y) = \ud835\udfd9 _ :=\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 = \ud835\udfd9 (X \u2a3f 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 \u27f6 S) (g : W \u27f6 S) (h : T \u27f6 U) (k : V \u27f6 W) :\n  coprod.map h k \u226b coprod.desc f g = coprod.desc (h \u226b f) (k \u226b 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 \u27f6 X) (g' : Y \u27f6 Z) :\n  coprod.desc (g \u226b coprod.inl) (g' \u226b coprod.inr) = coprod.map g g' :=\nby { rw \u2190 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 \u226b h` and `g \u226b 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\u2081 A\u2082 A\u2083 B\u2081 B\u2082 B\u2083 : C}\n  [has_binary_coproduct A\u2081 B\u2081] [has_binary_coproduct A\u2082 B\u2082] [has_binary_coproduct A\u2083 B\u2083]\n  (f : A\u2081 \u27f6 A\u2082) (g : B\u2081 \u27f6 B\u2082) (h : A\u2082 \u27f6 A\u2083) (k : B\u2082 \u27f6 B\u2083) :\n  coprod.map f g \u226b coprod.map h k = coprod.map (f \u226b h) (g \u226b 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 \u27f6 B) (g : X \u27f6 Y)\n  [has_colimits_of_shape (discrete walking_pair) C] :\n  coprod.map (\ud835\udfd9 X) f \u226b coprod.map g (\ud835\udfd9 B) = coprod.map g (\ud835\udfd9 A) \u226b coprod.map (\ud835\udfd9 Y) f :=\nby simp\n\n@[reassoc] lemma coprod.map_comp_id {X Y Z W : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [has_binary_coproduct Z W] [has_binary_coproduct Y W] [has_binary_coproduct X W] :\n  coprod.map (f \u226b g) (\ud835\udfd9 W) = coprod.map f (\ud835\udfd9 W) \u226b coprod.map g (\ud835\udfd9 W) :=\nby simp\n\n@[reassoc] lemma coprod.map_id_comp {X Y Z W : C} (f : X \u27f6 Y) (g : Y \u27f6 Z)\n  [has_binary_coproduct W X] [has_binary_coproduct W Y] [has_binary_coproduct W Z] :\n  coprod.map (\ud835\udfd9 W) (f \u226b g) = coprod.map (\ud835\udfd9 W) f \u226b coprod.map (\ud835\udfd9 W) g :=\nby simp\n\n/-- If the coproducts `W \u2a3f X` and `Y \u2a3f Z` exist, then every pair of isomorphisms `f : W \u2245 Y` and\n    `g : W \u2245 Z` induces a isomorphism `coprod.map_iso f g : W \u2a3f X \u2245 Y \u2a3f 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 \u2245 Y) (g : X \u2245 Z) : W \u2a3f X \u2245 Y \u2a3f 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 \u27f6 Y) (g : X \u27f6 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 \u27f6 Y) (g : X \u27f6 Z) [epi f]\n  [epi g] [has_binary_coproduct W X] [has_binary_coproduct Y Z] : epi (coprod.map f g) :=\n\u27e8\u03bb A i\u2081 i\u2082 h, begin\n  ext,\n  { rw \u2190 cancel_epi f, simpa using congr_arg (\u03bb f, coprod.inl \u226b f) h },\n  { rw \u2190 cancel_epi g, simpa using congr_arg (\u03bb f, coprod.inr \u226b f) h }\nend\u27e9\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 \u27f6 Y) [has_binary_coproduct X X]\n  [has_binary_coproduct Y Y] :\n  coprod.map f f \u226b codiag Y = codiag X \u226b 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 \u2a3f Y) (X \u2a3f Y)] :\n  coprod.map coprod.inl coprod.inr \u226b codiag (X \u2a3f Y) = \ud835\udfd9 (X \u2a3f 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 \u27f6 Y) (g' : X' \u27f6 Y') :\n  coprod.map (g \u226b coprod.inl) (g' \u226b coprod.inr) \u226b codiag (Y \u2a3f 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 [\u03a0 {X Y : C}, has_limit (pair X Y)] :\n  has_binary_products C :=\n{ has_limit := \u03bb 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 [\u03a0 {X Y : C}, has_colimit (pair X Y)] :\n  has_binary_coproducts C :=\n{ has_colimit := \u03bb 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 \u2a2f Q \u2245 Q \u2a2f 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 \u27f6 Y) (g : Z \u27f6 W) :\n  prod.map f g \u226b (prod.braiding _ _).hom = (prod.braiding _ _).hom \u226b 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 \u226b prod.lift prod.snd prod.fst = \ud835\udfd9 (P \u2a2f 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 \u226b (prod.braiding Q P).hom = \ud835\udfd9 _ :=\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 \u2a2f Q) \u2a2f R \u2245 P \u2a2f (Q \u2a2f R) :=\n{ hom :=\n  prod.lift\n    (prod.fst \u226b prod.fst)\n    (prod.lift (prod.fst \u226b prod.snd) prod.snd),\n  inv :=\n  prod.lift\n    (prod.lift prod.fst (prod.snd \u226b prod.fst))\n    (prod.snd \u226b 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) (\ud835\udfd9 Z) \u226b\n      (prod.associator W (X \u2a2f Y) Z).hom \u226b prod.map (\ud835\udfd9 W) ((prod.associator X Y Z).hom) =\n    (prod.associator (W \u2a2f X) Y Z).hom \u226b (prod.associator W X (Y \u2a2f Z)).hom :=\nby simp\n\n@[reassoc]\nlemma prod.associator_naturality [has_binary_products C] {X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : C}\n  (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082) (f\u2083 : X\u2083 \u27f6 Y\u2083) :\n  prod.map (prod.map f\u2081 f\u2082) f\u2083 \u226b (prod.associator Y\u2081 Y\u2082 Y\u2083).hom =\n    (prod.associator X\u2081 X\u2082 X\u2083).hom \u226b prod.map f\u2081 (prod.map f\u2082 f\u2083) :=\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 (\u22a4_ C) P] :\n  \u22a4_ C \u2a2f P \u2245 P :=\n{ hom := prod.snd,\n  inv := prod.lift (terminal.from P) (\ud835\udfd9 _) }\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 (\u22a4_ C)] :\n  P \u2a2f \u22a4_ C \u2245 P :=\n{ hom := prod.fst,\n  inv := prod.lift (\ud835\udfd9 _) (terminal.from P) }\n\n@[reassoc]\nlemma prod.left_unitor_hom_naturality [has_binary_products C] (f : X \u27f6 Y) :\n  prod.map (\ud835\udfd9 _) f \u226b (prod.left_unitor Y).hom = (prod.left_unitor X).hom \u226b f :=\nprod.map_snd _ _\n\n@[reassoc]\nlemma prod.left_unitor_inv_naturality [has_binary_products C] (f : X \u27f6 Y) :\n  (prod.left_unitor X).inv \u226b prod.map (\ud835\udfd9 _) f = f \u226b (prod.left_unitor Y).inv :=\nby rw [iso.inv_comp_eq, \u2190 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 \u27f6 Y) :\n  prod.map f (\ud835\udfd9 _) \u226b (prod.right_unitor Y).hom = (prod.right_unitor X).hom \u226b f :=\nprod.map_fst _ _\n\n@[reassoc]\nlemma prod_right_unitor_inv_naturality [has_binary_products C] (f : X \u27f6 Y) :\n  (prod.right_unitor X).inv \u226b prod.map f (\ud835\udfd9 _) = f \u226b (prod.right_unitor Y).inv :=\nby rw [iso.inv_comp_eq, \u2190 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 (\u22a4_ C) Y).hom \u226b prod.map (\ud835\udfd9 X) ((prod.left_unitor Y).hom) =\n    prod.map ((prod.right_unitor X).hom) (\ud835\udfd9 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 \u2a3f Q \u2245 Q \u2a3f 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 \u226b coprod.desc coprod.inr coprod.inl = \ud835\udfd9 (P \u2a3f 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 \u226b (coprod.braiding Q P).hom = \ud835\udfd9 _ :=\ncoprod.symmetry' _ _\n\n/-- The associator isomorphism for binary coproducts. -/\n@[simps] def coprod.associator\n  (P Q R : C) : (P \u2a3f Q) \u2a3f R \u2245 P \u2a3f (Q \u2a3f R) :=\n{ hom :=\n  coprod.desc\n    (coprod.desc coprod.inl (coprod.inl \u226b coprod.inr))\n    (coprod.inr \u226b coprod.inr),\n  inv :=\n  coprod.desc\n    (coprod.inl \u226b coprod.inl)\n    (coprod.desc (coprod.inr \u226b coprod.inl) coprod.inr) }\n\nlemma coprod.pentagon (W X Y Z : C) :\n  coprod.map ((coprod.associator W X Y).hom) (\ud835\udfd9 Z) \u226b\n      (coprod.associator W (X \u2a3f Y) Z).hom \u226b coprod.map (\ud835\udfd9 W) ((coprod.associator X Y Z).hom) =\n    (coprod.associator (W \u2a3f X) Y Z).hom \u226b (coprod.associator W X (Y \u2a3f Z)).hom :=\nby simp\n\nlemma coprod.associator_naturality {X\u2081 X\u2082 X\u2083 Y\u2081 Y\u2082 Y\u2083 : C} (f\u2081 : X\u2081 \u27f6 Y\u2081) (f\u2082 : X\u2082 \u27f6 Y\u2082)\n  (f\u2083 : X\u2083 \u27f6 Y\u2083) :\n  coprod.map (coprod.map f\u2081 f\u2082) f\u2083 \u226b (coprod.associator Y\u2081 Y\u2082 Y\u2083).hom =\n    (coprod.associator X\u2081 X\u2082 X\u2083).hom \u226b coprod.map f\u2081 (coprod.map f\u2082 f\u2083) :=\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) : \u22a5_ C \u2a3f P \u2245 P :=\n{ hom := coprod.desc (initial.to P) (\ud835\udfd9 _),\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 \u2a3f \u22a5_ C \u2245 P :=\n{ hom := coprod.desc (\ud835\udfd9 _) (initial.to P),\n  inv := coprod.inl }\n\nlemma coprod.triangle (X Y : C) :\n  (coprod.associator X (\u22a5_ C) Y).hom \u226b coprod.map (\ud835\udfd9 X) ((coprod.left_unitor Y).hom) =\n    coprod.map ((coprod.right_unitor X).hom) (\ud835\udfd9 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 \u2964 C \u2964 C :=\n{ obj := \u03bb X, { obj := \u03bb Y, X \u2a2f Y, map := \u03bb Y Z, prod.map (\ud835\udfd9 X) },\n  map := \u03bb Y Z f, { app := \u03bb T, prod.map f (\ud835\udfd9 T) }}\n\n/-- The product functor can be decomposed. -/\ndef prod.functor_left_comp (X Y : C) :\n  prod.functor.obj (X \u2a2f Y) \u2245 prod.functor.obj Y \u22d9 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 \u2964 C \u2964 C :=\n{ obj := \u03bb X, { obj := \u03bb Y, X \u2a3f Y, map := \u03bb Y Z, coprod.map (\ud835\udfd9 X) },\n  map := \u03bb Y Z f, { app := \u03bb T, coprod.map f (\ud835\udfd9 T) }}\n\n/-- The coproduct functor can be decomposed. -/\ndef coprod.functor_left_comp (X Y : C) :\n  coprod.functor.obj (X \u2a3f Y) \u2245 coprod.functor.obj Y \u22d9 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\u2082} [category.{w} D]\nvariables (F : C \u2964 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 \u2964 D) (A B : C)\n  [has_binary_product A B] [has_binary_product (F.obj A) (F.obj B)] :\n  F.obj (A \u2a2f B) \u27f6 F.obj A \u2a2f 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 \u226b prod.fst = F.map prod.fst :=\nprod.lift_fst _ _\n\n@[simp, reassoc]\nlemma prod_comparison_snd :\n  prod_comparison F A B \u226b 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 \u27f6 A') (g : B \u27f6 B') :\n  F.map (prod.map f g) \u226b prod_comparison F A' B' =\n    prod_comparison F A B \u226b prod.map (F.map f) (F.map g) :=\nbegin\n  rw [prod_comparison, prod_comparison, prod.lift_map, \u2190 F.map_comp, \u2190 F.map_comp,\n      prod.comp_lift, \u2190 F.map_comp, prod.map_fst, \u2190 F.map_comp, prod.map_snd]\nend\n\n/--\nThe product comparison morphism from `F(A \u2a2f -)` to `FA \u2a2f 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 \u2964 D) (A : C) :\n  prod.functor.obj A \u22d9 F \u27f6 F \u22d9 prod.functor.obj (F.obj A) :=\n{ app := \u03bb B, prod_comparison F A B,\n  naturality' := \u03bb 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) \u226b 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) \u226b 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 \u27f6 A') (g : B \u27f6 B')\n  [is_iso (prod_comparison F A B)] [is_iso (prod_comparison F A' B')] :\n  inv (prod_comparison F A B) \u226b F.map (prod.map f g) =\n    prod.map (F.map f) (F.map g) \u226b 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 \u2a2f -) \u2245 FA \u2a2f 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) [\u2200 B, is_iso (prod_comparison F A B)] :\n  prod.functor.obj A \u22d9 F \u2245 F \u22d9 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 \u27e8_, _\u27e9)) }\n\nend prod_comparison\n\nsection coprod_comparison\n\nuniverse w\n\nvariables {C} {D : Type u\u2082} [category.{w} D]\nvariables (F : C \u2964 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 \u2964 D) (A B : C)\n  [has_binary_coproduct A B] [has_binary_coproduct (F.obj A) (F.obj B)] :\n  F.obj A \u2a3f F.obj B \u27f6 F.obj (A \u2a3f B) :=\ncoprod.desc (F.map coprod.inl) (F.map coprod.inr)\n\n@[simp, reassoc]\nlemma coprod_comparison_inl :\n  coprod.inl \u226b coprod_comparison F A B  = F.map coprod.inl :=\ncoprod.inl_desc _ _\n\n@[simp, reassoc]\nlemma coprod_comparison_inr :\n  coprod.inr \u226b 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 \u27f6 A') (g : B \u27f6 B') :\n  coprod_comparison F A B \u226b F.map (coprod.map f g) =\n    coprod.map (F.map f) (F.map g) \u226b coprod_comparison F A' B' :=\nbegin\n  rw [coprod_comparison, coprod_comparison, coprod.map_desc, \u2190 F.map_comp, \u2190 F.map_comp,\n      coprod.desc_comp, \u2190 F.map_comp, coprod.inl_map, \u2190 F.map_comp, coprod.inr_map]\nend\n\n/--\nThe coproduct comparison morphism from `FA \u2a3f F-` to `F(A \u2a3f -)`, 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 \u2964 D) (A : C) :\n  F \u22d9 coprod.functor.obj (F.obj A) \u27f6 coprod.functor.obj A \u22d9 F :=\n{ app := \u03bb B, coprod_comparison F A B,\n  naturality' := \u03bb 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 \u226b 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 \u226b 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 \u27f6 A') (g : B \u27f6 B')\n  [is_iso (coprod_comparison F A B)] [is_iso (coprod_comparison F A' B')] :\n  inv (coprod_comparison F A B) \u226b coprod.map (F.map f) (F.map g) =\n    F.map (coprod.map f g) \u226b 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 \u2a3f F- \u2245 F(A \u2a3f -)`, 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) [\u2200 B, is_iso (coprod_comparison F A B)] :\n  F \u22d9 coprod.functor.obj (F.obj A) \u2245 coprod.functor.obj A \u22d9 F :=\n{ hom := coprod_comparison_nat_trans F A\n  ..(@as_iso _ _ _ _ _ (nat_iso.is_iso_of_is_iso_app \u27e8_, _\u27e9)) }\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 \u2192 over A \u2964 over A := \u03bb f,\n{ obj := \u03bb g, over.mk (coprod.desc f.hom g.hom),\n  map := \u03bb g\u2081 g\u2082 k, over.hom_mk (coprod.map (\ud835\udfd9 _) 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 \u2964 over A \u2964 over A :=\n{ obj := \u03bb f, over.coprod_obj f,\n  map := \u03bb f\u2081 f\u2082 k,\n  { app := \u03bb g, over.hom_mk (coprod.map k.left (\ud835\udfd9 _))\n      (by { dsimp, rw [coprod.map_desc, category.id_comp, over.w k] }),\n    naturality' := \u03bb f g k, by ext; { dsimp, simp, }, },\n  map_id' := \u03bb X, by ext; { dsimp, simp, },\n  map_comp' := \u03bb 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 {\u03b9 \u03b1 \u03b2 : Type _}\n\nvariable {I : Type u}\n\n-- The indexing type\nvariable {f : I \u2192 Type v}\n\n-- The family of types already equipped with instances\nvariable (x y : \u2200 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 {\u03b9 : Type _} {Z : \u03b9 \u2192 Type _} [\u2200 i, OrderedCommMonoid (Z i)] :\n    OrderedCommMonoid (\u2200 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 {\u03b9 : Type _} {\u03b1 : \u03b9 \u2192 Type _} [\u2200 i, LE (\u03b1 i)] [\u2200 i, Mul (\u03b1 i)] [\u2200 i, ExistsMulOfLE (\u03b1 i)] :\n    ExistsMulOfLE (\u2200 i, \u03b1 i) :=\n  \u27e8fun a b h =>\n    \u27e8fun i => (exists_mul_of_le <| h i).some,\n      funext fun i => (exists_mul_of_le <| h i).choose_spec\u27e9\u27e9\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 {\u03b9 : Type _} {Z : \u03b9 \u2192 Type _} [\u2200 i, CanonicallyOrderedMonoid (Z i)] :\n    CanonicallyOrderedMonoid (\u2200 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 [\u2200 i, OrderedCancelCommMonoid <| f i] :\n    OrderedCancelCommMonoid (\u2200 i : I, f i) := by\n  refine_struct\n      { Pi.partialOrder, Pi.monoid with\n        mul := (\u00b7 * \u00b7)\n        one := (1 : \u2200 i, f i)\n        le := (\u00b7 \u2264 \u00b7)\n        lt := (\u00b7 < \u00b7)\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 [\u2200 i, OrderedCommGroup <| f i] : OrderedCommGroup (\u2200 i : I, f i) :=\n  { Pi.commGroup, Pi.orderedCommMonoid with\n    mul := (\u00b7 * \u00b7)\n    one := (1 : \u2200 i, f i)\n    le := (\u00b7 \u2264 \u00b7)\n    lt := (\u00b7 < \u00b7)\n    npow := Monoid.npow }\n#align pi.ordered_comm_group Pi.orderedCommGroup\n#align pi.ordered_add_comm_group Pi.orderedAddCommGroup\n-/\n\ninstance [\u2200 i, OrderedSemiring (f i)] : OrderedSemiring (\u2200 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 [\u2200 i, OrderedCommSemiring (f i)] : OrderedCommSemiring (\u2200 i, f i) :=\n  { Pi.commSemiring, Pi.orderedSemiring with }\n\ninstance [\u2200 i, OrderedRing (f i)] : OrderedRing (\u2200 i, f i) :=\n  { Pi.ring, Pi.orderedSemiring with mul_nonneg := fun a b ha hb i => mul_nonneg (ha _) (hb _) }\n\ninstance [\u2200 i, OrderedCommRing (f i)] : OrderedCommRing (\u2200 i, f i) :=\n  { Pi.commRing, Pi.orderedRing with }\n\nend Pi\n\nnamespace Function\n\nvariable (\u03b2) [One \u03b1] [Preorder \u03b1] {a : \u03b1}\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 {\u03b1 : Type.{u1}} (\u03b2 : Type.{u2}) [_inst_1 : One.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))) a) -> (LE.le.{max u2 u1} (\u03b2 -> \u03b1) (Pi.hasLe.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => Preorder.toLE.{u1} \u03b1 _inst_2)) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (OfNat.mk.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.one.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1))))) (Function.const.{succ u1, succ u2} \u03b1 \u03b2 a))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (\u03b2 : Type.{u1}) [_inst_1 : One.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] {a : \u03b1}, (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 _inst_1)) a) -> (LE.le.{max u2 u1} (\u03b2 -> \u03b1) (Pi.hasLe.{u1, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => Preorder.toLE.{u2} \u03b1 _inst_2)) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.toOfNat1.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u1, u2} \u03b2 (fun (a._@.Init.Prelude._hyg.54 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1)))) (Function.const.{succ u2, succ u1} \u03b1 \u03b2 a))\nCase conversion may be inaccurate. Consider using '#align function.one_le_const_of_one_le Function.one_le_const_of_one_le\u2093'. -/\n@[to_additive const_nonneg_of_nonneg]\ntheorem one_le_const_of_one_le (ha : 1 \u2264 a) : 1 \u2264 const \u03b2 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 {\u03b1 : Type.{u1}} (\u03b2 : Type.{u2}) [_inst_1 : One.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] {a : \u03b1}, (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1)))) -> (LE.le.{max u2 u1} (\u03b2 -> \u03b1) (Pi.hasLe.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => Preorder.toLE.{u1} \u03b1 _inst_2)) (Function.const.{succ u1, succ u2} \u03b1 \u03b2 a) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (OfNat.mk.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.one.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1))))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} (\u03b2 : Type.{u1}) [_inst_1 : One.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] {a : \u03b1}, (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) a (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 _inst_1))) -> (LE.le.{max u2 u1} (\u03b2 -> \u03b1) (Pi.hasLe.{u1, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => Preorder.toLE.{u2} \u03b1 _inst_2)) (Function.const.{succ u2, succ u1} \u03b1 \u03b2 a) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.toOfNat1.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u1, u2} \u03b2 (fun (a._@.Init.Prelude._hyg.54 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1)))))\nCase conversion may be inaccurate. Consider using '#align function.const_le_one_of_le_one Function.const_le_one_of_le_one\u2093'. -/\n@[to_additive]\ntheorem const_le_one_of_le_one (ha : a \u2264 1) : const \u03b2 a \u2264 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 {\u03b2} [Nonempty \u03b2]\n\n/- warning: function.one_le_const -> Function.one_le_const is a dubious translation:\nlean 3 declaration is\n  forall {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] {a : \u03b1} [_inst_3 : Nonempty.{succ u2} \u03b2], Iff (LE.le.{max u2 u1} (\u03b2 -> \u03b1) (Pi.hasLe.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => Preorder.toLE.{u1} \u03b1 _inst_2)) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (OfNat.mk.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.one.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1))))) (Function.const.{succ u1, succ u2} \u03b1 \u03b2 a)) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : One.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] {a : \u03b1} [_inst_3 : Nonempty.{succ u1} \u03b2], Iff (LE.le.{max u2 u1} (\u03b2 -> \u03b1) (Pi.hasLe.{u1, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => Preorder.toLE.{u2} \u03b1 _inst_2)) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.toOfNat1.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u1, u2} \u03b2 (fun (a._@.Init.Prelude._hyg.54 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1)))) (Function.const.{succ u2, succ u1} \u03b1 \u03b2 a)) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align function.one_le_const Function.one_le_const\u2093'. -/\n@[simp, to_additive const_nonneg]\ntheorem one_le_const : 1 \u2264 const \u03b2 a \u2194 1 \u2264 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] {a : \u03b1} [_inst_3 : Nonempty.{succ u2} \u03b2], Iff (LT.lt.{max u2 u1} (\u03b2 -> \u03b1) (Preorder.toLT.{max u2 u1} (\u03b2 -> \u03b1) (Pi.preorder.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_2))) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (OfNat.mk.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.one.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1))))) (Function.const.{succ u1, succ u2} \u03b1 \u03b2 a)) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))) a)\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : One.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] {a : \u03b1} [_inst_3 : Nonempty.{succ u1} \u03b2], Iff (LT.lt.{max u2 u1} (\u03b2 -> \u03b1) (Preorder.toLT.{max u2 u1} (\u03b2 -> \u03b1) (Pi.preorder.{u1, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_2))) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.toOfNat1.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u1, u2} \u03b2 (fun (a._@.Init.Prelude._hyg.54 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1)))) (Function.const.{succ u2, succ u1} \u03b1 \u03b2 a)) (LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 _inst_2) (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 _inst_1)) a)\nCase conversion may be inaccurate. Consider using '#align function.one_lt_const Function.one_lt_const\u2093'. -/\n@[simp, to_additive const_pos]\ntheorem one_lt_const : 1 < const \u03b2 a \u2194 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] {a : \u03b1} [_inst_3 : Nonempty.{succ u2} \u03b2], Iff (LE.le.{max u2 u1} (\u03b2 -> \u03b1) (Pi.hasLe.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => Preorder.toLE.{u1} \u03b1 _inst_2)) (Function.const.{succ u1, succ u2} \u03b1 \u03b2 a) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (OfNat.mk.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.one.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1)))))) (LE.le.{u1} \u03b1 (Preorder.toLE.{u1} \u03b1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : One.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] {a : \u03b1} [_inst_3 : Nonempty.{succ u1} \u03b2], Iff (LE.le.{max u2 u1} (\u03b2 -> \u03b1) (Pi.hasLe.{u1, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => Preorder.toLE.{u2} \u03b1 _inst_2)) (Function.const.{succ u2, succ u1} \u03b1 \u03b2 a) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.toOfNat1.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u1, u2} \u03b2 (fun (a._@.Init.Prelude._hyg.54 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1))))) (LE.le.{u2} \u03b1 (Preorder.toLE.{u2} \u03b1 _inst_2) a (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align function.const_le_one Function.const_le_one\u2093'. -/\n@[simp, to_additive]\ntheorem const_le_one : const \u03b2 a \u2264 1 \u2194 a \u2264 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 {\u03b1 : Type.{u1}} {\u03b2 : Type.{u2}} [_inst_1 : One.{u1} \u03b1] [_inst_2 : Preorder.{u1} \u03b1] {a : \u03b1} [_inst_3 : Nonempty.{succ u2} \u03b2], Iff (LT.lt.{max u2 u1} (\u03b2 -> \u03b1) (Preorder.toLT.{max u2 u1} (\u03b2 -> \u03b1) (Pi.preorder.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_2))) (Function.const.{succ u1, succ u2} \u03b1 \u03b2 a) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (OfNat.mk.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.one.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u2, u1} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1)))))) (LT.lt.{u1} \u03b1 (Preorder.toLT.{u1} \u03b1 _inst_2) a (OfNat.ofNat.{u1} \u03b1 1 (OfNat.mk.{u1} \u03b1 1 (One.one.{u1} \u03b1 _inst_1))))\nbut is expected to have type\n  forall {\u03b1 : Type.{u2}} {\u03b2 : Type.{u1}} [_inst_1 : One.{u2} \u03b1] [_inst_2 : Preorder.{u2} \u03b1] {a : \u03b1} [_inst_3 : Nonempty.{succ u1} \u03b2], Iff (LT.lt.{max u2 u1} (\u03b2 -> \u03b1) (Preorder.toLT.{max u2 u1} (\u03b2 -> \u03b1) (Pi.preorder.{u1, u2} \u03b2 (fun (\u1fb0 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_2))) (Function.const.{succ u2, succ u1} \u03b1 \u03b2 a) (OfNat.ofNat.{max u2 u1} (\u03b2 -> \u03b1) 1 (One.toOfNat1.{max u2 u1} (\u03b2 -> \u03b1) (Pi.instOne.{u1, u2} \u03b2 (fun (a._@.Init.Prelude._hyg.54 : \u03b2) => \u03b1) (fun (i : \u03b2) => _inst_1))))) (LT.lt.{u2} \u03b1 (Preorder.toLT.{u2} \u03b1 _inst_2) a (OfNat.ofNat.{u2} \u03b1 1 (One.toOfNat1.{u2} \u03b1 _inst_1)))\nCase conversion may be inaccurate. Consider using '#align function.const_lt_one Function.const_lt_one\u2093'. -/\n@[simp, to_additive]\ntheorem const_lt_one : const \u03b2 a < 1 \u2194 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 (\u03b9) [Zero \u03b1] {a : \u03b1}\n\nprivate theorem function_const_nonneg_of_pos [Preorder \u03b1] (ha : 0 < a) : 0 \u2264 const \u03b9 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 \u03b9]\n\nprivate theorem function_const_ne_zero : a \u2260 0 \u2192 const \u03b9 a \u2260 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 \u03b1] : 0 < a \u2192 0 < const \u03b9 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 \u2192 tactic strictness\n  | q(Function.const $(\u03b9) $(a)) => do\n    let strict_a \u2190 core a\n    match strict_a with\n      | positive p =>\n        positive <$> to_expr ``(function_const_pos $(\u03b9) $(p)) <|>\n          nonnegative <$> to_expr ``(function_const_nonneg_of_pos $(\u03b9) $(p))\n      | nonnegative p => nonnegative <$> to_expr ``(const_nonneg_of_nonneg $(\u03b9) $(p))\n      | nonzero p => nonzero <$> to_expr ``(function_const_ne_zero $(\u03b9) $(p))\n  | e =>\n    pp e >>= fail \u2218 format.bracket \"The expression `\" \"` is not of the form `function.const \u03b9 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\u00ebl Dillies. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Ya\u00ebl 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 \u03b1 \u03b2 \u03b3 : Type*}\n\nnamespace sum\n\nsection has_smul\nvariables [has_smul M \u03b1] [has_smul M \u03b2] [has_smul N \u03b1] [has_smul N \u03b2] (a : M) (b : \u03b1)\n  (c : \u03b2) (x : \u03b1 \u2295 \u03b2)\n\n@[to_additive sum.has_vadd] instance : has_smul M (\u03b1 \u2295 \u03b2) := \u27e8\u03bb a, sum.map ((\u2022) a) ((\u2022) a)\u27e9\n\n@[to_additive] lemma smul_def : a \u2022 x = x.map ((\u2022) a) ((\u2022) a) := rfl\n@[simp, to_additive] lemma smul_inl : a \u2022 (inl b : \u03b1 \u2295 \u03b2) = inl (a \u2022 b) := rfl\n@[simp, to_additive] lemma smul_inr : a \u2022 (inr c : \u03b1 \u2295 \u03b2) = inr (a \u2022 c) := rfl\n@[simp, to_additive] lemma smul_swap : (a \u2022 x).swap = a \u2022 x.swap := by cases x; refl\n\ninstance [has_smul M N] [is_scalar_tower M N \u03b1] [is_scalar_tower M N \u03b2] :\n  is_scalar_tower M N (\u03b1 \u2295 \u03b2) :=\n\u27e8\u03bb a b x,\n  by { cases x, exacts [congr_arg inl (smul_assoc _ _ _), congr_arg inr (smul_assoc _ _ _)] }\u27e9\n\n@[to_additive] instance [smul_comm_class M N \u03b1] [smul_comm_class M N \u03b2] :\n  smul_comm_class M N (\u03b1 \u2295 \u03b2) :=\n\u27e8\u03bb a b x,\n  by { cases x, exacts [congr_arg inl (smul_comm _ _ _), congr_arg inr (smul_comm _ _ _)] }\u27e9\n\n@[to_additive]\ninstance [has_smul M\u1d50\u1d52\u1d56 \u03b1] [has_smul M\u1d50\u1d52\u1d56 \u03b2] [is_central_scalar M \u03b1] [is_central_scalar M \u03b2] :\n  is_central_scalar M (\u03b1 \u2295 \u03b2) :=\n\u27e8\u03bb a x,\n  by { cases x, exacts [congr_arg inl (op_smul_eq_smul _ _), congr_arg inr (op_smul_eq_smul _ _)] }\u27e9\n\n@[to_additive] instance has_faithful_smul_left [has_faithful_smul M \u03b1] :\n  has_faithful_smul M (\u03b1 \u2295 \u03b2) :=\n\u27e8\u03bb x y h, eq_of_smul_eq_smul $ \u03bb a : \u03b1, by injection h (inl a)\u27e9\n\n@[to_additive] instance has_faithful_smul_right [has_faithful_smul M \u03b2] :\n  has_faithful_smul M (\u03b1 \u2295 \u03b2) :=\n\u27e8\u03bb x y h, eq_of_smul_eq_smul $ \u03bb b : \u03b2, by injection h (inr b)\u27e9\n\nend has_smul\n\n@[to_additive] instance {m : monoid M} [mul_action M \u03b1] [mul_action M \u03b2] : mul_action M (\u03b1 \u2295 \u03b2) :=\n{ mul_smul := \u03bb a b x,\n    by { cases x, exacts [congr_arg inl (mul_smul _ _ _), congr_arg inr (mul_smul _ _ _)] },\n  one_smul := \u03bb 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": "/-\nCopyright (c) 2022 Jannis Limperg. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Jannis Limperg, Asta H. From\n-/\n\nimport Aesop\n\nset_option aesop.check.all true\n\ninductive All (P : \u03b1 \u2192 Prop) : List \u03b1 \u2192 Prop where\n  | none : All P []\n  | more {x xs} : P x \u2192 All P xs \u2192 All P (x :: xs)\n\n@[aesop unsafe]\naxiom weaken {\u03b1} (P Q : \u03b1 \u2192 Prop) (wk : \u2200 x, P x \u2192 Q x) (xs : List \u03b1)\n  (h : All P xs) : All Q xs\n\nexample : All (\u00b7 \u2208 []) (@List.nil \u03b1) := by\n  aesop (options := { maxRuleApplications := 50, terminal := true })\n", "meta": {"author": "JLimperg", "repo": "aesop", "sha": "c68fb1d5a9172498230d81d95c61f6461bea6722", "save_path": "github-repos/lean/JLimperg-aesop", "path": "github-repos/lean/JLimperg-aesop/aesop-c68fb1d5a9172498230d81d95c61f6461bea6722/tests/golden/AllWeaken.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7606506635289836, "lm_q2_score": 0.5926665999540698, "lm_q1q2_score": 0.45081224250652985}}
{"text": "abbrev VName := String\n\ninductive Ty where\n  | Bool\n  | Int\n\ndef Ctxt := VName \u2192 Option Ty\n\nvariable (\u0393 : Ctxt) in\ninductive Expr : Ty \u2192 Type where\n  | var (h : \u0393 x = some \u03c4) : Expr \u03c4\n\ndef Expr.constFold : Expr \u0393 \u03c4 \u2192 Option Unit\n  | var n   => none\n\ntheorem Expr.constFold_sound {e : Expr \u0393 \u03c4} : constFold e = some v \u2192 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 \u2964 CompHaus.{u}) (\u03b1 : F \u27f6 G)\nvariables (cF : cone F) (cG : cone G) (hcF : is_limit cF) (hcG : is_limit cG)\n\ndef pt {X : CompHaus.{u}} (x : X) : (\u22a4_ CompHaus) \u27f6 X :=\n\u27e8\u03bb _, x, continuous_const\u27e9\n\n@[simps] def diagram_of_pt (y : cG.X) : J \u2964 CompHaus.{u} :=\n{ obj := \u03bb j, pullback (\u03b1.app j) (pt y \u226b cG.\u03c0.app j),\n  map := \u03bb i j f, pullback.lift (pullback.fst \u226b F.map f) pullback.snd\n    (by rw [category.assoc, \u03b1.naturality, pullback.condition_assoc, category.assoc, cG.w]),\n  map_id' := \u03bb j, by apply pullback.hom_ext; dsimp; simp,\n  map_comp' := \u03bb 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 \u03b1 cG y) :=\n{ X := pullback (hcG.map cF \u03b1) (pt y),\n  \u03c0 :=\n  { app := \u03bb j, pullback.lift\n      (pullback.fst \u226b cF.\u03c0.app _)\n      pullback.snd\n      (by rw [category.assoc, \u2190 pullback.condition_assoc, is_limit.map_\u03c0]),\n    naturality' := \u03bb 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 \u03b1 cF cG hcG y) :=\n{ lift := \u03bb S, pullback.lift\n    (hcF.lift \u27e8S.X,\n    { app := \u03bb j, S.\u03c0.app j \u226b pullback.fst,\n      naturality' := begin\n        intros i j f,\n        dsimp,\n        rw \u2190 S.w f, dsimp [diagram_of_pt],\n        simp only [category.id_comp, category.assoc, pullback.lift_fst],\n      end }\u27e9)\n    (terminal.from _)\n    begin\n      apply hcG.hom_ext, intros j, dsimp,\n      simp only [category.assoc, is_limit.map_\u03c0, 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, \u2190 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\u03b1 : \u2200 j, function.surjective (\u03b1.app j)) :\n  function.surjective (hcG.map cF \u03b1) := \u03bb y,\nlet E := cone_of_pt F G \u03b1 cF cG hcG y,\n  hE : is_limit E := is_limit_cone_of_pt F G \u03b1 cF cG hcF hcG y in\nbegin\n  suffices : \u2203 (e : (\u22a4_ CompHaus.{u}) \u27f6 E.X),\n    e \u226b (pullback.fst : E.X \u27f6 cF.X) \u226b hcG.map cF \u03b1 = pt y,\n  { obtain \u27e8e,he\u27e9 := this,\n    use (terminal.from (CompHaus.of punit) \u226b e \u226b pullback.fst) punit.star,\n    rw \u2190 comp_apply,\n    have : y = (terminal.from (CompHaus.of punit) \u226b 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 [\u2190he, 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' \u2245 Top.limit_cone.{u u} _ :=\n    hE'.unique_up_to_iso (Top.limit_cone_is_limit _),\n  let e : E'.X \u2245 (Top.limit_cone.{u u} _).X :=\n    hE'.cone_point_unique_up_to_iso (Top.limit_cone_is_limit _),\n  haveI : \u2200 j : J, t2_space (((diagram_of_pt F G \u03b1 cG y \u22d9 CompHaus_to_Top).obj j)),\n  { intros j, change t2_space ((diagram_of_pt F G \u03b1 cG y).obj j), apply_instance },\n  haveI : \u2200 j : J, compact_space (((diagram_of_pt F G \u03b1 cG y \u22d9 CompHaus_to_Top).obj j)),\n  { intros j, change compact_space ((diagram_of_pt F G \u03b1 cG y).obj j), apply_instance },\n  haveI : \u2200 j : J, nonempty (((diagram_of_pt F G \u03b1 cG y \u22d9 CompHaus_to_Top).obj j)),\n  { intro j, change nonempty ((diagram_of_pt F G \u03b1 cG y).obj j),\n    dsimp only [diagram_of_pt_obj],\n    let y' := (terminal.from (CompHaus.of punit) \u226b pt y \u226b cG.\u03c0.app j) punit.star,\n    obtain \u27e8x', hx'\u27e9 := h\u03b1 j y',\n    refine \u27e8(terminal.from (CompHaus.of punit) \u226b pullback.lift (pt x') (\ud835\udfd9 _) _) punit.star\u27e9,\n    ext z, exact hx', },\n  have := Top.nonempty_limit_cone_of_compact_t2_cofiltered_system\n    (diagram_of_pt F G \u03b1 cG y \u22d9 CompHaus_to_Top),\n  obtain \u27e8a\u27e9 := 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\u03b1 : \u2200 j, function.surjective (\u03b1.app j)) :\n   function.surjective (lim_map \u03b1) :=\nis_limit.surjective_of_surjective _ _ _ _ _ (limit.is_limit _) _ h\u03b1\n\nend CompHaus\n\nnamespace CompHausFiltPseuNormGrp\u2081\n\n-- move this\ninstance : has_zero_morphisms (CompHausFiltPseuNormGrp\u2081.{u}) :=\n{ has_zero := \u03bb M\u2081 M\u2082, \u27e80\u27e9,\n  comp_zero' := \u03bb _ _ f _, rfl,\n  zero_comp' := \u03bb _ _ _ f, by { ext, exact f.map_zero } }\nvariables {A B C : CompHausFiltPseuNormGrp\u2081.{u}}\n\nstructure exact_with_constant (f : A \u27f6 B) (g : B \u27f6 C) (r : \u211d\u22650 \u2192 \u211d\u22650) : Prop :=\n(comp_eq_zero : f \u226b g = 0)\n(cond : \u2200 c : \u211d\u22650, g \u207b\u00b9' {0} \u2229 (filtration B c) \u2286 f '' (filtration A (r c)))\n(large : id \u2264 r)\n\nlemma exact_with_constant.exact {f : A \u27f6 B} {g : B \u27f6 C} {r : \u211d\u22650 \u2192 \u211d\u22650}\n  (h : exact_with_constant f g r) :\n  exact ((to_PNG\u2081 \u22d9 PseuNormGrp\u2081.to_Ab).map f) ((to_PNG\u2081 \u22d9 PseuNormGrp\u2081.to_Ab).map g) :=\nbegin\n  rw AddCommGroup.exact_iff',\n  split,\n  { ext x, have := h.comp_eq_zero, apply_fun (\u03bb \u03c6, \u03c6.to_fun) at this, exact congr_fun this x },\n  { intros y hy,\n    obtain \u27e8c, hc\u27e9 := B.exhaustive y,\n    obtain \u27e8a, ha, rfl\u27e9 := h.cond c \u27e8_, hc\u27e9,\n    { exact \u27e8a, rfl\u27e9 },\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 : \u211d\u22650 \u2964 CompHausFiltPseuNormGrp\u2081.{u} \u2964 CompHaus.{u} :=\nCompHausFiltPseuNormGrp\u2081.level\n\ninstance mono_Filtration_map_app (c\u2081 c\u2082 : \u211d\u22650) (h : c\u2081 \u27f6 c\u2082) (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 \u27f6 B) (g : B \u27f6 C) (r : \u211d\u22650 \u2192 \u211d\u22650) (c : \u211d\u22650) (hrc : c \u2264 r c)\n\nvariables {r c}\n\ndef c_le_rc : c \u27f6 r c := hom_of_le $ hrc\n\n/-- Given `f : A \u27f6 B`, `P1` is the pullback `B_c \u00d7_{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) : (\u22a4_ CompHaus) \u27f6 X :=\n\u27e8\u03bb _, x, continuous_const\u27e9\n\n/-- Given `g : B \u27f6 C`, `P2` is the pullback `B_c \u00d7_{C_c} {pt}`. -/\ndef P2 (c : \u211d\u22650) : CompHaus :=\npullback ((Filtration.obj c).map g) (pt (0 : pseudo_normed_group.filtration C c))\n\ndef P1_to_P2 (hfg : f \u226b g = 0) : P1 f hrc \u27f6 P2 g c :=\npullback.lift pullback.fst (terminal.from _)\nbegin\n  rw [\u2190 cancel_mono ((Filtration.map (c_le_rc hrc)).app C), category.assoc,\n    nat_trans.naturality, pullback.condition_assoc, \u2190 functor.map_comp, hfg],\n  refl,\nend\n\nlemma P1_to_P2_comp_fst (hfg : f \u226b g = 0) :\n  P1_to_P2 f g hrc hfg \u226b pullback.fst = pullback.fst :=\npullback.lift_fst _ _ _\n\nlemma surjective (h : exact_with_constant f g r) :\n  \u2203 (hfg : f \u226b g = 0), \u2200 c, function.surjective (P1_to_P2 f g (h.large c) hfg) :=\nbegin\n  have hfg : f \u226b g = 0,\n  { ext x, exact fun_like.congr_fun h.exact.w x },\n  refine \u27e8hfg, _\u27e9,\n  intros c y,\n  let \u03c0\u2081 : P2 g c \u27f6 (Filtration.obj c).obj B := pullback.fst,\n  have hy : (\u03c0\u2081 y).val \u2208 g \u207b\u00b9' {0} \u2229 filtration B c,\n  asyncI\n  { refine \u27e8_, (\u03c0\u2081 y).2\u27e9,\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 \u27e8x, hx, hfx\u27e9 := h.cond c hy,\n  let s : CompHaus.of punit \u27f6 P1 f (h.large c) :=\n  terminal.from _ \u226b pullback.lift (pt (\u03c0\u2081 y)) (pt \u27e8x, hx\u27e9) _,\n  swap, { ext t, exact hfx.symm },\n  refine \u27e8s punit.star, _\u27e9,\n  suffices : s \u226b P1_to_P2 f g (h.large c) hfg = terminal.from _ \u226b 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 \u226b g = 0) (hr : id \u2264 r)\n  (h : \u2200 c, function.surjective (P1_to_P2 f g (hr c) hfg)) :\n  exact_with_constant f g r :=\nbegin\n  suffices H : \u2200 (c : \u211d\u22650), g \u207b\u00b9' {0} \u2229 filtration B c \u2286 f '' filtration A (r c),\n  { refine \u27e8_, H, hr\u27e9,\n    ext x,\n    have := congr_arg (coe_fn : (A \u27f6 C) \u2192 (A \u2192 C)) hfg,\n    exact congr_fun this x },\n  rintro c y \u27e8hy, hyc\u27e9,\n  let t : CompHaus.of punit \u27f6 P2 g c :=\n  pullback.lift (terminal.from _ \u226b pt \u27e8y, hyc\u27e9) (terminal.from _) _,\n  swap, { ext, exact hy },\n  obtain \u27e8s, hs\u27e9 := h c (t punit.star),\n  let \u03c0\u2082 : P1 f (hr c) \u27f6 (Filtration.obj (r c)).obj A := pullback.snd,\n  refine \u27e8(\u03c0\u2082 s).val, _\u27e9,\n  let P := CompHaus.of punit,\n  suffices : terminal.from P \u226b pt s \u226b \u03c0\u2082 \u226b ((Filtration.obj (r c)).map f) =\n    terminal.from _ \u226b pt \u27e8y, filtration_mono (hr c) hyc\u27e9,\n  { have hs := fun_like.congr_fun this punit.star, exact \u27e8(\u03c0\u2082 s).2, congr_arg subtype.val hs\u27e9 },\n  have H : terminal.from P \u226b pt s \u226b P1_to_P2 f g (hr c) hfg = t,\n  { apply continuous_map.ext, rintro \u27e8\u27e9, exact hs },\n  erw [\u2190 pullback.condition, \u2190 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 \u2194\n  \u2203 (hfg : f \u226b g = 0) (hr : \u2200 c, c \u2264 r c),\n    \u2200 c, function.surjective (P1_to_P2 f g (hr c) hfg) :=\nbegin\n  split,\n  { intro h, obtain \u27e8hfg, H\u27e9 := surjective _ _ h, exact \u27e8hfg, h.large, H\u27e9 },\n  { rintro \u27e8hfg, hr, h\u27e9, 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 \u2964 CompHausFiltPseuNormGrp\u2081.{u}}\nvariables (f : A' \u27f6 B') (g : B' \u27f6 C') (r : \u211d\u22650 \u2192 \u211d\u22650) (c : \u211d\u22650) (hrc : c \u2264 r c)\n\nvariables {r c}\n\n@[simps obj obj_obj obj_map map map_app { fully_applied := ff }]\ndef P1_functor : J \u2964 walking_cospan \u2964 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 : \u211d\u22650) : J \u2964 walking_cospan \u2964 CompHaus.{u} :=\nfunctor.flip $ @cospan _ _ _ ((category_theory.functor.const _).obj (\u22a4_ _)) _\n  (whisker_right g (Filtration.obj c))\n  { app := \u03bb 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 \u226b g = 0) (X Y : J) (h : X \u27f6 Y) (w w') :\n  ((P1_functor f hrc \u22d9 lim).map h \u226b\n         lim_map (diagram_iso_cospan ((P1_functor f hrc).obj Y)).hom \u226b\n           P1_to_P2 (f.app Y) (g.app Y) hrc w \u226b\n             lim_map\n               (\ud835\udfd9 (cospan ((Filtration.obj c).map (g.app Y)) (pt 0)) \u226b\n                  (diagram_iso_cospan ((P2_functor g c).obj Y)).inv)) \u226b\n      limit.\u03c0 ((P2_functor g c).obj Y) none =\n    ((lim_map (diagram_iso_cospan ((P1_functor f hrc).obj X)).hom \u226b\n            P1_to_P2 (f.app X) (g.app X) hrc w' \u226b\n              lim_map\n                (\ud835\udfd9 (cospan ((Filtration.obj c).map (g.app X)) (pt 0)) \u226b\n                   (diagram_iso_cospan ((P2_functor g c).obj X)).inv)) \u226b\n         (P2_functor g c \u22d9 lim).map h) \u226b\n      limit.\u03c0 ((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_\u03c0, lim_map_\u03c0_assoc, limit.lift_\u03c0,\n    diagram_iso_cospan_hom_app, diagram_iso_cospan_inv_app,\n    pullback_cone.mk_\u03c0_app_one, limit.lift_map],\n  dsimp,\n  simp only [\u2190(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 \u226b g = 0) (X Y : J) (h : X \u27f6 Y) (w w') :\n  ((P1_functor f hrc \u22d9 lim).map h \u226b\n         lim_map (diagram_iso_cospan ((P1_functor f hrc).obj Y)).hom \u226b\n           P1_to_P2 (f.app Y) (g.app Y) hrc w \u226b\n             lim_map\n               (\ud835\udfd9 (cospan ((Filtration.obj c).map (g.app Y)) (pt 0)) \u226b\n                  (diagram_iso_cospan ((P2_functor g c).obj Y)).inv)) \u226b\n      limit.\u03c0 ((P2_functor g c).obj Y) (some walking_pair.left) =\n    ((lim_map (diagram_iso_cospan ((P1_functor f hrc).obj X)).hom \u226b\n            P1_to_P2 (f.app X) (g.app X) hrc w' \u226b\n              lim_map\n                (\ud835\udfd9 (cospan ((Filtration.obj c).map (g.app X)) (pt 0)) \u226b\n                   (diagram_iso_cospan ((P2_functor g c).obj X)).inv)) \u226b\n         (P2_functor g c \u22d9 lim).map h) \u226b\n      limit.\u03c0 ((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_\u03c0_app_left,\n    cones.postcompose_obj_\u03c0, lim_map_\u03c0_assoc, limit.lift_\u03c0, 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 \u226b g = 0) (X Y : J) (h : X \u27f6 Y) (w w') :\n  ((P1_functor f hrc \u22d9 lim).map h \u226b\n         lim_map (diagram_iso_cospan ((P1_functor f hrc).obj Y)).hom \u226b\n           P1_to_P2 (f.app Y) (g.app Y) hrc w \u226b\n             lim_map\n               (\ud835\udfd9 (cospan ((Filtration.obj c).map (g.app Y)) (pt 0)) \u226b\n                  (diagram_iso_cospan ((P2_functor g c).obj Y)).inv)) \u226b\n      limit.\u03c0 ((P2_functor g c).obj Y) (some walking_pair.right) =\n    ((lim_map (diagram_iso_cospan ((P1_functor f hrc).obj X)).hom \u226b\n            P1_to_P2 (f.app X) (g.app X) hrc w' \u226b\n              lim_map\n                (\ud835\udfd9 (cospan ((Filtration.obj c).map (g.app X)) (pt 0)) \u226b\n                   (diagram_iso_cospan ((P2_functor g c).obj X)).inv)) \u226b\n         (P2_functor g c \u22d9 lim).map h) \u226b\n      limit.\u03c0 ((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_\u03c0_app_right, cones.postcompose_obj_\u03c0, limit.lift_\u03c0, limit.lift_map,\n    diagram_iso_cospan_inv_app, eq_iff_true_of_subsingleton],\nend\n\ndef P1_to_P2_nat_trans (hfg : f \u226b g = 0) :\n  (P1_functor f hrc \u22d9 lim) \u27f6 (P2_functor g c \u22d9 lim) :=\n{ app := \u03bb j, begin\n    refine _ \u226b P1_to_P2 (f.app j) (g.app j) hrc (by { rw [\u2190 nat_trans.comp_app, hfg], refl }) \u226b _,\n    { refine lim_map (diagram_iso_cospan _).hom, },\n    { refine lim_map (_ \u226b (diagram_iso_cospan _).inv), exact \ud835\udfd9 _, }\n  end,\n  naturality' := \u03bb 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 (\u27e8\u27e9|\u27e8\u27e8\u27e9\u27e9),\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 : \u211d\u22650) : preserves_limits (Filtration.obj c) :=\nby { dsimp [Filtration], apply_instance, }\n\ndef P1_iso {A B : Fintype.{u} \u2964 CompHausFiltPseuNormGrp\u2081.{u}}\n  (f : A \u27f6 B) {r : \u211d\u22650 \u2192 \u211d\u22650} {c : \u211d\u22650} (hrc : c \u2264 r c) (S : Profinite) :\n  P1.{u} ((Profinite.extend_nat_trans.{u u+1} f).app S) hrc \u2245\n    limit (P1_functor.{u} (whisker_left S.fintype_diagram f) hrc \u22d9 lim) :=\nbegin\n  refine has_limit.iso_of_nat_iso (_ \u226a\u226b (cospan_comp_iso _ _ _).symm) \u226a\u226b\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 _ \u226a\u226b (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, \u2190(Filtration.obj (r c)).map_comp],\n    end)\nend\n\nopen category_theory.limits\n\ndef P2_iso {B C : Fintype.{u} \u2964 CompHausFiltPseuNormGrp\u2081.{u}}\n  (g : B \u27f6 C) (c : \u211d\u22650) (S : Profinite) :\n  P2.{u} ((Profinite.extend_nat_trans.{u u+1} g).app S) c \u2245\n    limit (P2_functor.{u} (whisker_left S.fintype_diagram g) c \u22d9 lim) :=\nbegin\n  refine has_limit.iso_of_nat_iso (_ \u226a\u226b (cospan_comp_iso _ _ _).symm) \u226a\u226b\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 _ \u226a\u226b (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, \u2190(Filtration.obj c).map_comp], },\n  { apply limit.hom_ext, intros, ext, simp, },\nend\n\n-- move me, generalize\nlemma extend_aux {A\u2081 B\u2081 A\u2082 B\u2082 : CompHaus}\n  (e\u2081 : A\u2081 \u2245 B\u2081) (e\u2082 : A\u2082 \u2245 B\u2082) (f : A\u2081 \u27f6 A\u2082) (g : B\u2081 \u27f6 B\u2082) (hf : epi f)\n  (H : e\u2081.inv \u226b f \u226b e\u2082.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\u2081 B\u2081 A\u2082 B\u2082 : CompHaus}\n  (e\u2081 : A\u2081 \u2245 B\u2081) (e\u2082 : A\u2082 \u2245 B\u2082) (f : A\u2081 \u27f6 A\u2082) (g : B\u2081 \u27f6 B\u2082) (hf : epi f)\n  (H : f = e\u2081.hom \u226b g \u226b e\u2082.inv) :\n  epi g :=\nby { rw [\u2190 iso.inv_comp_eq, iso.eq_comp_inv, category.assoc] at H, apply extend_aux e\u2081 e\u2082 f g hf H }\n\nlemma extend_aux_1 {A B C : Fintype.{u} \u2964 CompHausFiltPseuNormGrp\u2081.{u}} {r : \u211d\u22650 \u2192 \u211d\u22650} {c : \u211d\u22650}\n  (S : Profinite.{u}) (f : A \u27f6 B) (g : B \u27f6 C) (hrc : c \u2264 r c) (w w') :\n  ((P1_iso.{u} f hrc S).symm.inv \u226b\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) \u226b\n           (P2_iso.{u} g c S).symm.hom) \u226b\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' \u226b\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_\u03c0, 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_\u03c0,\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_\u03c0_assoc],\n    erw [limit_flip_comp_lim_iso_limit_comp_lim'_hom_\u03c0_\u03c0, lim_map_\u03c0_assoc],\n    simp only [category_theory.category.id_comp,\n      CompHausFiltPseuNormGrp\u2081.exact_with_constant.P1_to_P2_nat_trans_app,\n      category_theory.category.assoc],\n    erw [lim_map_\u03c0],\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_\u03c0,\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_\u03c0_\u03c0],\n    simp only [category_theory.limits.has_limit.iso_of_nat_iso_hom_\u03c0_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_\u03c0, category_theory.category.id_comp], },\n  all_goals { apply_instance, },\nend\n\nlemma extend {A B C : Fintype.{u} \u2964 CompHausFiltPseuNormGrp\u2081.{u}}\n  (f : A \u27f6 B) (g : B \u27f6 C) (r : \u211d\u22650 \u2192 \u211d\u22650)\n  (hfg : \u2200 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 \u2264 r := (hfg $ Fintype.of punit).large,\n  rw exact_with_constant.iff_surjective,\n  refine \u27e8_, hr, _\u27e9,\n  { rw [\u2190 nat_trans.comp_app, \u2190 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_\u03c0],\n    simp only [cones.postcompose_obj_\u03c0, whisker_left_comp, nat_trans.comp_app,\n      limit.cone_\u03c0, 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 \u226b\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) \u22d9 lim)\n    (P2_functor.{u} (whisker_left S.fintype_diagram g) c \u22d9 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 \u27e8aux', hr, hfg\u27e9, specialize hfg c,\n    rw \u2190 CompHaus.epi_iff_surjective at hfg \u22a2,\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 \u2190 CompHaus.epi_iff_surjective at key \u22a2,\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\u2081 {\ud835\udc9e : Type*} [category \ud835\udc9e]\n  (A B : \ud835\udc9e \u2964 CompHausFiltPseuNormGrp\u2081.{u}) :\n  has_zero (A \u27f6 B) :=\n\u27e8\u27e80, \u03bb S T f, by { ext t, exact (B.map f).map_zero.symm }\u27e9\u27e9\n\n@[simp] lemma zero_app {\ud835\udc9e : Type*} [category \ud835\udc9e] (A B : \ud835\udc9e \u2964 CompHausFiltPseuNormGrp\u2081.{u}) (S) :\n  (0 : A \u27f6 B).app S = 0 := rfl\n\n@[simp] lemma Profinite.extend_nat_trans_zero (A B : Fintype \u2964 CompHausFiltPseuNormGrp\u2081.{u}) :\n  Profinite.extend_nat_trans (0 : A \u27f6 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 \u2964 CompHausFiltPseuNormGrp\u2081.{u})\n  (g : B \u27f6 C) (r : \u211d\u22650 \u2192 \u211d\u22650)\n  (hfg : \u2200 S, exact_with_constant (0 : A.obj S \u27f6 B.obj S) (g.app S) r) (S : Profinite) :\n  exact_with_constant (0 : (Profinite.extend A).obj S \u27f6 (Profinite.extend B).obj S)\n    ((Profinite.extend_nat_trans g).app S) r :=\nbegin\n  have := exact_with_constant.extend (0 : A \u27f6 B) g r hfg S,\n  simpa,\nend\n\nlemma exact_with_constant_extend_zero_right (A B C : Fintype \u2964 CompHausFiltPseuNormGrp\u2081.{u})\n  (f : A \u27f6 B) (r : \u211d\u22650 \u2192 \u211d\u22650)\n  (hfg : \u2200 S, exact_with_constant (f.app S) (0 : B.obj S \u27f6 C.obj S) r) (S : Profinite) :\n  exact_with_constant ((Profinite.extend_nat_trans f).app S)\n    (0 : (Profinite.extend B).obj S \u27f6 (Profinite.extend C).obj S) r :=\nbegin\n  have := exact_with_constant.extend f (0 : B \u27f6 C) r hfg S,\n  simpa,\nend\n\nvariables (C)\n\nlemma exact_with_constant_of_epi (f : A \u27f6 B) (r : \u211d\u22650 \u2192 \u211d\u22650) (hr : id \u2264 r)\n  (hf : \u2200 c, filtration B c \u2286 f '' (filtration A (r c))) :\n  exact_with_constant f (0 : B \u27f6 C) r :=\nbegin\n  refine \u27e8_, _, hr\u27e9,\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 \u27f6 C) [hg : mono ((to_PNG\u2081 \u22d9 PseuNormGrp\u2081.to_Ab).map g)] :\n  exact_with_constant (0 : A \u27f6 B) g id :=\nbegin\n  refine \u27e8_, _, le_rfl\u27e9,\n  { rw zero_comp },\n  { rintro c x \u27e8hx, -\u27e9,\n    suffices : x = 0, { subst x, refine \u27e80, zero_mem_filtration _, rfl\u27e9, },\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\u2081\n\nnamespace Condensed\n\nopen CompHausFiltPseuNormGrp\u2081\n\nlemma zero_iff_ExtrDisc {A B : Condensed.{u} Ab.{u+1}} (f : A \u27f6 B) :\n  f = 0 \u2194 (\u2200 S : ExtrDisc, f.val.app (op S.val) = 0) :=\nbegin\n  split,\n  { rintros \u27e8rfl\u27e9, 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 \u27f6 B) (g : B \u27f6 C) :\n  exact f g \u2194 \u2200 (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 [\u2190 cancel_epi (kernel_iso g S).hom,\n    \u2190 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\u2081.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\u2081.{u}}\n  (f : A \u27f6 B) (g : B \u27f6 C) (r : \u211d\u22650 \u2192 \u211d\u22650)\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 \u27e8hfg, hr, H\u27e9,\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\u2081_to_CHFPNG\u2091\u2097.obj A) (CHFPNG\u2081_to_CHFPNG\u2091\u2097.obj C)\n      (@strict_comphaus_filtered_pseudo_normed_group_hom.to_chfpsng_hom.{u u} A C _ _ (f \u226b g))\n      (unop.{u+2} (ExtrDisc_to_Profinite.{u}.op.obj (op S))) = 0,\n    rw hfg, ext x s, refl, },\n  { rintro \u27e8_, c, y\u2080 : S.val \u2192 filtration B c, hy\u2080, rfl\u27e9 hy,\n    dsimp at hy \u22a2,\n    let y : CompHaus.of S.val \u27f6 (Filtration.obj c).obj B := \u27e8y\u2080, hy\u2080\u27e9,\n    let t : CompHaus.of S.val \u27f6 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 \u226b P1_to_P2 f g (hr c) hfg = t := ExtrDisc.lift_lifts' _ _ _,\n    let \u03c0\u2082 : P1 f (hr c) \u27f6 (Filtration.obj (r c)).obj A := pullback.snd,\n    let x\u2080 := (s \u226b \u03c0\u2082).1,\n    have hx\u2080 := (s \u226b \u03c0\u2082).2,\n    refine \u27e8\u27e8_, _, x\u2080, hx\u2080, rfl\u27e9, _\u27e9,\n    apply_fun (\u03bb \u03c6, \u03c6 \u226b pullback.fst) at hs,\n    erw [pullback.lift_fst y (terminal.from _)] at hs,\n    rw [category.assoc, P1_to_P2_comp_fst, \u2190 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\u2081.{u}) :\n  to_Condensed.map (0 : A \u27f6 B) = 0 :=\nby { ext S s x, refl, }\n\nlemma mono_to_Condensed_map {A B : CompHausFiltPseuNormGrp\u2081.{u}}\n  (f : A \u27f6 B) (hf : exact_with_constant (0 : A \u27f6 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 \u27f6 A) f id hf,\n  simpa only [to_Condensed_map_zero],\nend\n\nlemma epi_to_Condensed_map {A B : CompHausFiltPseuNormGrp\u2081.{u}}\n  (f : A \u27f6 B) (r : \u211d\u22650 \u2192 \u211d\u22650) (hf : exact_with_constant f (0 : B \u27f6 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 \u27f6 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)\u1d52\u1d56\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) \u2964 CondensedSet :=\nSheaf_compose _ (forget _)\n\n@[simps obj_val map]\ndef CondensedSet_to_CondensedMod : CondensedSet \u2964 (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 \u22a3 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 \u27f6 Y) :\n  ((CondensedMod_CondensedSet_adjunction A).hom_equiv _ _ e).val =\n  ((Module.adj A).whisker_right _).hom_equiv _ _ (proetale_topology.to_sheafify _ \u226b e.val) := rfl\n\n@[simp]\nlemma CondensedMod_CondensedSet_adjunction_hom_equiv_symm_apply (X : CondensedSet)\n  (Y : CondensedMod A) (e : X \u27f6 (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\u2081 : f x x = g x) (h\u2082 : g x = x) : f x (f x x) = x := by\n  simp\n  simp [*]\n\ntheorem ex2 (x : Nat) (h\u2081 : f x x = g x) (h\u2082 : 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\u2081 : f x x = g x) (h\u2082 : f x x < 5) : f x x + f x x = 0 := by\n  simp [*] at *\n  trace_state\n  have aux\u2081 : f x x = g x := h\u2081\n  have aux\u2082 : g x < 5     := h\u2082\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] \u2192 Z[a]).\n\nprivate def approxs : stream Z[a] :=\n  fix (\u03bb (o: stream Z[a]), \u2191\u2191R (z\u207b\u00b9 o)).\n\nlemma approxs_unfold :\n  approxs R = \u2191\u2191R (z\u207b\u00b9 (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  \u222b (D (approxs R)).\n\nlemma approxs_apply\n  (n: \u2115) :\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: \u2115) :\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: \u2115) (heqn: R^[n.succ] 0 = (R^[n]) 0) :\n  \u2200 m \u2265 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: \u2115) (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: \u2115) (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] \u2192 Z[a] \u2192 Z[a]).\n\nnoncomputable def naive : Z[b] \u2192 Z[a] :=\n  \u03bb i, \u222b (D (fix (\u03bb (o: stream Z[a]), \u2191\u00b2R (I (\u03b40 i)) (z\u207b\u00b9 o)))).\n\nnoncomputable def seminaive : Z[b] \u2192 Z[a] :=\n  \u03bb i, \u222b (fix (\u03bb (o: stream Z[a]), \u2191\u00b2R^\u03942 (\u03b40 i) (z\u207b\u00b9 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 (\u03bb (o : stream Z[a]), \u2191\u00b2R (I (\u03b40 x)) (z\u207b\u00b9 o)))) with\n    (\u03bb i, (fix (\u03bb (o : stream Z[a]), \u2191\u00b2R i (z\u207b\u00b9 o))))^\u0394 (\u03b40 x),\n  rw cycle_incremental (\u03bb i o, \u2191\u00b2R i o),\n  dsimp,\n  rw uncurry_op_lifting2,\n  apply lifting_causal,\nend\n\ntheorem naive_ok (i: Z[b])\n  (n: \u2115) (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: \u2115) (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 \u2297[R] B`, when `A` and `B` are both `R`-algebras,\nand provide the structure isomorphisms\n\n* `R \u2297[R] A \u2243\u2090[R] A`\n* `A \u2297[R] R \u2243\u2090[R] A`\n* `A \u2297[R] B \u2243\u2090[R] B \u2297[R] A`\n\nThe code for\n* `((A \u2297[R] B) \u2297[R] C) \u2243\u2090[R] (A \u2297[R] (B \u2297[R] C))`\nis written and compiles, but takes longer than the `-T100000` time limit,\nso is currently commented out.\n-/\n\nuniverses u v\u2081 v\u2082 v\u2083 v\u2084\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\u2081} [semiring A] [algebra R A]\nvariables {B : Type v\u2082} [semiring B] [algebra R B]\n\n/--\n(Implementation detail)\nThe multiplication map on `A \u2297[R] B`,\nfor a fixed pure tensor in the first argument,\nas an `R`-linear map.\n-/\ndef mul_aux (a\u2081 : A) (b\u2081 : B) : (A \u2297[R] B) \u2192\u2097[R] (A \u2297[R] B) :=\ntensor_product.map (lmul_left R a\u2081) (lmul_left R b\u2081)\n\n@[simp]\nlemma mul_aux_apply (a\u2081 a\u2082 : A) (b\u2081 b\u2082 : B) :\n  (mul_aux a\u2081 b\u2081) (a\u2082 \u2297\u209c[R] b\u2082) = (a\u2081 * a\u2082) \u2297\u209c[R] (b\u2081 * b\u2082) :=\nrfl\n\n/--\n(Implementation detail)\nThe multiplication map on `A \u2297[R] B`,\nas an `R`-bilinear map.\n-/\ndef mul : (A \u2297[R] B) \u2192\u2097[R] (A \u2297[R] B) \u2192\u2097[R] (A \u2297[R] B) :=\ntensor_product.lift $ linear_map.mk\u2082 R mul_aux\n  (\u03bb x\u2081 x\u2082 y, tensor_product.ext $ \u03bb x' y',\n    by simp only [mul_aux_apply, linear_map.add_apply, add_mul, add_tmul])\n  (\u03bb c x y, tensor_product.ext $ \u03bb x' y',\n    by simp only [mul_aux_apply, linear_map.smul_apply, smul_tmul', smul_mul_assoc])\n  (\u03bb x y\u2081 y\u2082, tensor_product.ext $ \u03bb x' y',\n    by simp only [mul_aux_apply, linear_map.add_apply, add_mul, tmul_add])\n  (\u03bb c x y, tensor_product.ext $ \u03bb 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\u2081 a\u2082 : A) (b\u2081 b\u2082 : B) :\n  mul (a\u2081 \u2297\u209c[R] b\u2081) (a\u2082 \u2297\u209c[R] b\u2082) = (a\u2081 * a\u2082) \u2297\u209c[R] (b\u2081 * b\u2082) :=\nrfl\n\nlemma mul_assoc' (mul : (A \u2297[R] B) \u2192\u2097[R] (A \u2297[R] B) \u2192\u2097[R] (A \u2297[R] B))\n  (h : \u2200 (a\u2081 a\u2082 a\u2083 : A) (b\u2081 b\u2082 b\u2083 : B),\n    mul (mul (a\u2081 \u2297\u209c[R] b\u2081) (a\u2082 \u2297\u209c[R] b\u2082)) (a\u2083 \u2297\u209c[R] b\u2083) =\n      mul (a\u2081 \u2297\u209c[R] b\u2081) (mul (a\u2082 \u2297\u209c[R] b\u2082) (a\u2083 \u2297\u209c[R] b\u2083))) :\n  \u2200 (x y z : A \u2297[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 \u2297[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 \u2297[R] B) : mul (1 \u2297\u209c 1) x = x :=\nbegin\n  apply tensor_product.induction_on x;\n  simp {contextual := tt},\nend\n\nlemma mul_one (x : A \u2297[R] B) : mul x (1 \u2297\u209c 1) = x :=\nbegin\n  apply tensor_product.induction_on x;\n  simp {contextual := tt},\nend\n\ninstance : semiring (A \u2297[R] B) :=\n{ zero := 0,\n  add := (+),\n  one := 1 \u2297\u209c 1,\n  mul := \u03bb 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 \u2297[R] B)) }.\n\nlemma one_def : (1 : A \u2297[R] B) = (1 : A) \u2297\u209c (1 : B) := rfl\n\n@[simp]\nlemma tmul_mul_tmul (a\u2081 a\u2082 : A) (b\u2081 b\u2082 : B) :\n  (a\u2081 \u2297\u209c[R] b\u2081) * (a\u2082 \u2297\u209c[R] b\u2082) = (a\u2081 * a\u2082) \u2297\u209c[R] (b\u2081 * b\u2082) :=\nrfl\n\n@[simp]\nlemma tmul_pow (a : A) (b : B) (k : \u2115) :\n  (a \u2297\u209c[R] b)^k = (a^k) \u2297\u209c[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 \u2192+* (A \u2297[R] B)` giving `A \u2297[R] B` the structure of an `R`-algebra.\n-/\ndef tensor_algebra_map : R \u2192+* (A \u2297[R] B) :=\n{ to_fun := \u03bb r, algebra_map R A r \u2297\u209c[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 \u2297[R] B) :=\n{ commutes' := \u03bb 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' := \u03bb r x,\n  begin\n    apply tensor_product.induction_on x,\n    { simp [smul_zero], },\n    { intros a b,\n      rw [tensor_algebra_map, \u2190tmul_smul, \u2190smul_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 \u2297[R] B)) }.\n\n@[simp]\nlemma algebra_map_apply (r : R) :\n  (algebra_map R (A \u2297[R] B)) r = ((algebra_map R A) r) \u2297\u209c[R] 1 := rfl\n\nvariables {C : Type v\u2083} [semiring C] [algebra R C]\n\n@[ext]\ntheorem ext {g h : (A \u2297[R] B) \u2192\u2090[R] C}\n  (H : \u2200 a b, g (a \u2297\u209c b) = h (a \u2297\u209c b)) : g = h :=\nbegin\n  apply @alg_hom.to_linear_map_inj R (A \u2297[R] B) C _ _ _ _ _ _ _ _,\n  ext,\n  simp [H],\nend\n\n/-- The algebra morphism `A \u2192\u2090[R] A \u2297[R] B` sending `a` to `a \u2297\u209c 1`. -/\ndef include_left : A \u2192\u2090[R] A \u2297[R] B :=\n{ to_fun := \u03bb a, a \u2297\u209c 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 \u2192\u2090[R] A \u2297[R] B) a = a \u2297\u209c 1 := rfl\n\n/-- The algebra morphism `B \u2192\u2090[R] A \u2297[R] B` sending `b` to `1 \u2297\u209c b`. -/\ndef include_right : B \u2192\u2090[R] A \u2297[R] B :=\n{ to_fun := \u03bb b, 1 \u2297\u209c b,\n  map_zero' := by simp,\n  map_add' := by simp [tmul_add],\n  map_one' := rfl,\n  map_mul' := by simp,\n  commutes' := \u03bb r,\n  begin\n    simp only [algebra_map_apply],\n    transitivity r \u2022 ((1 : A) \u2297\u209c[R] (1 : B)),\n    { rw [\u2190tmul_smul, algebra.smul_def], simp, },\n    { simp [algebra.smul_def], },\n  end, }\n\n@[simp]\nlemma include_right_apply (b : B) : (include_right : B \u2192\u2090[R] A \u2297[R] B) b = 1 \u2297\u209c b := rfl\n\nend semiring\n\nsection ring\n\nvariables {R : Type u} [comm_ring R]\nvariables {A : Type v\u2081} [ring A] [algebra R A]\nvariables {B : Type v\u2082} [ring B] [algebra R B]\n\ninstance : ring (A \u2297[R] B) :=\n{ .. (by apply_instance : add_comm_group (A \u2297[R] B)),\n  .. (by apply_instance : semiring (A \u2297[R] B)) }.\n\nend ring\n\nsection comm_ring\n\nvariables {R : Type u} [comm_ring R]\nvariables {A : Type v\u2081} [comm_ring A] [algebra R A]\nvariables {B : Type v\u2082} [comm_ring B] [algebra R B]\n\ninstance : comm_ring (A \u2297[R] B) :=\n{ mul_comm := \u03bb x y,\n  begin\n    apply tensor_product.induction_on x,\n    { simp, },\n    { intros a\u2081 b\u2081,\n      apply tensor_product.induction_on y,\n      { simp, },\n      { intros a\u2082 b\u2082,\n        simp [mul_comm], },\n      { intros a\u2082 b\u2082 ha hb,\n        simp [mul_add, add_mul, ha, hb], }, },\n    { intros x\u2081 x\u2082 h\u2081 h\u2082,\n      simp [mul_add, add_mul, h\u2081, h\u2082], },\n  end\n  .. (by apply_instance : ring (A \u2297[R] B)) }.\n\nend comm_ring\n\n/--\nVerify that typeclass search finds the ring structure on `A \u2297[\u2124] B`\nwhen `A` and `B` are merely rings, by treating both as `\u2124`-algebras.\n-/\nexample {A : Type v\u2081} [ring A] {B : Type v\u2082} [ring B] : ring (A \u2297[\u2124] B) :=\nby apply_instance\n\n/--\nVerify that typeclass search finds the comm_ring structure on `A \u2297[\u2124] B`\nwhen `A` and `B` are merely comm_rings, by treating both as `\u2124`-algebras.\n-/\nexample {A : Type v\u2081} [comm_ring A] {B : Type v\u2082} [comm_ring B] : comm_ring (A \u2297[\u2124] 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\u2081} [semiring A] [algebra R A]\nvariables {B : Type v\u2082} [semiring B] [algebra R B]\nvariables {C : Type v\u2083} [semiring C] [algebra R C]\nvariables {D : Type v\u2084} [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 \u2297[R] B \u2192\u2097[R] C)\n  (w\u2081 : \u2200 (a\u2081 a\u2082 : A) (b\u2081 b\u2082 : B), f ((a\u2081 * a\u2082) \u2297\u209c (b\u2081 * b\u2082)) = f (a\u2081 \u2297\u209c b\u2081) * f (a\u2082 \u2297\u209c b\u2082))\n  (w\u2082 : \u2200 r, f ((algebra_map R A) r \u2297\u209c[R] 1) = (algebra_map R C) r):\n  A \u2297[R] B \u2192\u2090[R] C :=\n{ map_one' := by simpa using w\u2082 1,\n  map_zero' := by simp,\n  map_mul' := \u03bb x y,\n  begin\n    apply tensor_product.induction_on x,\n    { simp, },\n    { intros a\u2081 b\u2081,\n      apply tensor_product.induction_on y,\n      { simp, },\n      { intros a\u2082 b\u2082,\n        simp [w\u2081], },\n      { intros x\u2081 x\u2082 h\u2081 h\u2082,\n        simp at h\u2081, simp at h\u2082,\n        simp [mul_add, add_mul, h\u2081, h\u2082], }, },\n    { intros x\u2081 x\u2082 h\u2081 h\u2082,\n      simp at h\u2081, simp at h\u2082,\n      simp [mul_add, add_mul, h\u2081, h\u2082], }\n  end,\n  commutes' := \u03bb r, by simp [w\u2082],\n  .. f }\n\n@[simp]\nlemma alg_hom_of_linear_map_tensor_product_apply (f w\u2081 w\u2082 x) :\n  (alg_hom_of_linear_map_tensor_product f w\u2081 w\u2082 : A \u2297[R] B \u2192\u2090[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 \u2297[R] B \u2243\u2097[R] C)\n  (w\u2081 : \u2200 (a\u2081 a\u2082 : A) (b\u2081 b\u2082 : B), f ((a\u2081 * a\u2082) \u2297\u209c (b\u2081 * b\u2082)) = f (a\u2081 \u2297\u209c b\u2081) * f (a\u2082 \u2297\u209c b\u2082))\n  (w\u2082 : \u2200 r, f ((algebra_map R A) r \u2297\u209c[R] 1) = (algebra_map R C) r):\n  A \u2297[R] B \u2243\u2090[R] C :=\n{ .. alg_hom_of_linear_map_tensor_product (f : A \u2297[R] B \u2192\u2097[R] C) w\u2081 w\u2082,\n  .. f }\n\n@[simp]\nlemma alg_equiv_of_linear_equiv_tensor_product_apply (f w\u2081 w\u2082 x) :\n  (alg_equiv_of_linear_equiv_tensor_product f w\u2081 w\u2082 : A \u2297[R] B \u2243\u2090[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 \u2297[R] B) \u2297[R] C) \u2243\u2097[R] D)\n  (w\u2081 : \u2200 (a\u2081 a\u2082 : A) (b\u2081 b\u2082 : B) (c\u2081 c\u2082 : C),\n    f ((a\u2081 * a\u2082) \u2297\u209c (b\u2081 * b\u2082) \u2297\u209c (c\u2081 * c\u2082)) = f (a\u2081 \u2297\u209c b\u2081 \u2297\u209c c\u2081) * f (a\u2082 \u2297\u209c b\u2082 \u2297\u209c c\u2082))\n  (w\u2082 : \u2200 r, f (((algebra_map R A) r \u2297\u209c[R] (1 : B)) \u2297\u209c[R] (1 : C)) = (algebra_map R D) r) :\n  (A \u2297[R] B) \u2297[R] C \u2243\u2090[R] D :=\n{ to_fun := f,\n  map_mul' := \u03bb x y,\n  begin\n    apply tensor_product.induction_on x,\n    { simp, },\n    { intros ab\u2081 c\u2081,\n      apply tensor_product.induction_on y,\n      { simp, },\n      { intros ab\u2082 c\u2082,\n        apply tensor_product.induction_on ab\u2081,\n        { simp, },\n        { intros a\u2081 b\u2081,\n          apply tensor_product.induction_on ab\u2082,\n          { simp, },\n          { simp [w\u2081], },\n          { intros x\u2081 x\u2082 h\u2081 h\u2082,\n            simp at h\u2081 h\u2082,\n            simp [mul_add, add_tmul, h\u2081, h\u2082], }, },\n        { intros x\u2081 x\u2082 h\u2081 h\u2082,\n          simp at h\u2081 h\u2082,\n          simp [add_mul, add_tmul, h\u2081, h\u2082], }, },\n      { intros x\u2081 x\u2082 h\u2081 h\u2082,\n        simp [mul_add, add_mul, h\u2081, h\u2082], }, },\n    { intros x\u2081 x\u2082 h\u2081 h\u2082,\n      simp [mul_add, add_mul, h\u2081, h\u2082], }\n  end,\n  commutes' := \u03bb r, by simp [w\u2082],\n  .. f }\n\n@[simp]\nlemma alg_equiv_of_linear_equiv_triple_tensor_product_apply (f w\u2081 w\u2082 x) :\n  (alg_equiv_of_linear_equiv_triple_tensor_product f w\u2081 w\u2082 : (A \u2297[R] B) \u2297[R] C \u2243\u2090[R] D) x = f x :=\nrfl\n\nend\n\nvariables {R : Type u} [comm_semiring R]\nvariables {A : Type v\u2081} [semiring A] [algebra R A]\nvariables {B : Type v\u2082} [semiring B] [algebra R B]\nvariables {C : Type v\u2083} [semiring C] [algebra R C]\nvariables {D : Type v\u2084} [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 \u2297[R] A \u2243\u2090[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 \u2297[R] R \u2243\u2090[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 \u2297 R \u2192 A)) (a \u2297\u209c r) = r \u2022 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 \u2297[R] B \u2243\u2090[R] B \u2297[R] A :=\nalg_equiv_of_linear_equiv_tensor_product (tensor_product.comm R A B)\n(by simp)\n(\u03bb r, begin\n  transitivity r \u2022 ((1 : B) \u2297\u209c[R] (1 : A)),\n  { rw [\u2190tmul_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 \u2297[R] B \u2192 B \u2297[R] A)) (a \u2297\u209c b) = (b \u2297\u209c a) :=\nby simp [tensor_product.comm]\n\nend\n\nsection\nvariables {R A B C}\n\nlemma assoc_aux_1 (a\u2081 a\u2082 : A) (b\u2081 b\u2082 : B) (c\u2081 c\u2082 : C) :\n  (tensor_product.assoc R A B C) (((a\u2081 * a\u2082) \u2297\u209c[R] (b\u2081 * b\u2082)) \u2297\u209c[R] (c\u2081 * c\u2082)) =\n    (tensor_product.assoc R A B C) ((a\u2081 \u2297\u209c[R] b\u2081) \u2297\u209c[R] c\u2081) *\n      (tensor_product.assoc R A B C) ((a\u2082 \u2297\u209c[R] b\u2082) \u2297\u209c[R] c\u2082) :=\nrfl\n\nlemma assoc_aux_2 (r : R) :\n  (tensor_product.assoc R A B C) (((algebra_map R A) r \u2297\u209c[R] 1) \u2297\u209c[R] 1) =\n    (algebra_map R (A \u2297 (B \u2297 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 \u2297[R] B) \u2297[R] C) \u2243\u2090[R] (A \u2297[R] (B \u2297[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 \u2297[R] B) \u2297[R] C \u2192 A \u2297[R] (B \u2297[R] C)) ((a \u2297\u209c b) \u2297\u209c c) = a \u2297\u209c (b \u2297\u209c 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 \u2192\u2090[R] B) (g : C \u2192\u2090[R] D) : A \u2297[R] C \u2192\u2090[R] B \u2297[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 \u2192\u2090[R] B) (g : C \u2192\u2090[R] D) (a : A) (c : C) :\n  map f g (a \u2297\u209c c) = f a \u2297\u209c 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 \u2243\u2090[R] B) (g : C \u2243\u2090[R] D) : A \u2297[R] C \u2243\u2090[R] B \u2297[R] D :=\nalg_equiv.of_alg_hom (map f g) (map f.symm g.symm)\n  (ext $ \u03bb b d, by simp)\n  (ext $ \u03bb a c, by simp)\n\n@[simp]\nlemma congr_apply (f : A \u2243\u2090[R] B) (g : C \u2243\u2090[R] D) (x) :\n  congr f g x = (map (f : A \u2192\u2090[R] B) (g : C \u2192\u2090[R] D)) x := rfl\n\n@[simp]\nlemma congr_symm_apply (f : A \u2243\u2090[R] B) (g : C \u2243\u2090[R] D) (x) :\n  (congr f g).symm x = (map (f.symm : B \u2192\u2090[R] A) (g.symm : D \u2192\u2090[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{\u03b9 : Type} [fintype \u03b9] [decidable_eq \u03b9]\n{\u210b : Type} [complex_hilbert_space \u210b]\n{\u03c1 : module.End \u2102 \u210b} [quantum_state \u03c1]\n{\u03c1' : module.End \u2102 \u210b} [quantum_state \u03c1']\n{\u03c3 : module.End \u2102 \u210b} [quantum_state \u03c3]\n{U : module.End \u2102 \u210b} [unitary U]\n-- {q : \u03b9 \u2192 \u211d} [rnd_var q]\n\ndef reachable_by_catalysis (\u03b5 : \u211d) (\u03c1 : module.End \u2102 \u210b) (\u03c1' : module.End \u2102 \u210b) :=\n\u2203 \u03c3 : module.End \u2102 \u210b, \u2203 U : module.End \u2102 \u210b,\nTr\u2081(U \u2218 (\u03c1 \u2297 \u03c3) \u2218 U\u2020) = \u03c3 \n\u2227\nD(Tr\u2082(U \u2218 (\u03c1 \u2297 \u03c3) \u2218 U\u2020), \u03c1') \u2264 \u03b5\n\n-- notation \u03c1 `\u2192\u03b5` \u03c1' := reachable_by_catalysis \u03b5 \u03c1 \u03c1'\nnotation `H` := entropy\n\n-- Choose catalytic state \u03c3\u2081\u2297\u03c3\u2082 according to two-step construction\n--  1. Define \u03c3\u2081 using (16). This requires choosing `n` and `U` (in order to define `\u03c7`). `n` can be estimated using (17). `U` is chosen such that the final state on `S` is as close to `\u03c1'` 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 \u2115 \u2192 quantum_state \u2192 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 \u03c3\u2081 (\u03c1) (n) (U) := (1/n) \u2022 \u2211 k in finset.range n, \u03c1^\u2297(n-k) \u2297 (Tr(list n-k n) (U \u2218 \u03c1 \u2218 U\u2020)) \u2297 |k\u27e9\u27e8k|\n\n--  2. Ancilla system R for the dephasing channel. This is just the ancilla in the Naimark/Stinespring dilation of the channel.\ndef \u03c3\u2082 := naimark_ancilla (dephasing_channel \u03c1')\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 \u03c1') \u2218 cycle_ancilla \u2218 cycle_s \u2218 (U \u2297 |n\u27e9\u27e8n| + (Id d*(n-1)) \u2297 \u2211 k in finset.range (n-1), |k\u27e9\u27e8k|)\n\n/--\nThis is the main theorem\n-/\ntheorem reachable_iff_higher_entropy : (\u2200 \u03b5>0, reachable_by_catalysis \u03b5 \u03c1 \u03c1') \u2194 H(\u03c1') \u2265 H(\u03c1) := \nbegin\n  split,\n  { -- \"The direction i) \u21d2 ii) follows directly from sub-additivity, \n    -- unitary invariance and continuity of von Neumann entropy:\"\n    intro h,\n    intro \u03b5,\n    let \u03c1\u03c3' := U \u2218 (\u03c1 \u2297 \u03c3) \u2218 U\u2020,\n    let \u03c1'\u03b5 := Tr\u2082 \u03c1\u03c3',\n    calc H(\u03c1'\u03b5) + H(\u03c3) \u2265 H(\u03c1\u03c3')              : by apply entropy_subadditive,\n                  ... = H(U \u2218 (\u03c1 \u2297 \u03c3) \u2218 U\u2020)     : by sorry -- def of \u03c1'\u03b5 and invariance of \u03c3 under transformation\n                  ... = H(\u03c1 \u2297 \u03c3)              : by apply entropy_unitary_evolution_eq_entropy_self,\n                  ... = H(\u03c1) + H(\u03c3)              : by apply entropy_tmul_eq_add_entropy,\n    -- then rw to cancel H(\u03c3) (\"by continuity\") and done\n    sorry\n  },\n  { \n    /-\n    \"The proof [of the ii) \u21d2 i) direction] proceeds in two parts:\n    -/\n\n    let \u03c7 := U \u2218 \u03c1^\u2297n \u2218 U\u2020,\n\n    /-\n    First we construct a catalyst \u03c3\u2081 for the exact transition from \u03c1 \n    to the equal mixture \u03c7_bar := 1/n * \u2211 k, (\u03c7 k) of states (\u03c7 k) = pTr_k_bar \u03c7.\" \n    -/\n\n    /-\n    \"Then we use a second catalyst R in state \u03c3\u2082 to implement the\n    dephasing map and obtain \ud835\udc9f_\u03c1'[\u03c7] , which is \u03b5-close to the target \u03c1'\n    The part R of the catalyst thus effectively acts as a source of randomness.\"\n    -/\n\n    let \u03c1'\u03b5 := \ud835\udc9f_\u03c1'[\u03c7],\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 \u03c3\u2082 only needs to have a dimension of \n    the order of \u221ad. Furthermore, note that by perturbing \u03c1' arbitrarily slightly, \n    we can always ensure that H(\u03c1) < H(\u03c1') 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 \u03c1 \u2192\u03b5=0 \u03c7_bar in the case H(\u03c1') > H(\u03c1).\"\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 \u03c3\u2081 \u2297 \u03c3\u2082,\n    -- use V,\n \n    -- have hyp_close : D(\u03c1', Tr (-S) evolve(V \u03c3\u2082 \u2297 \u03c1 \u2297 \u03c3\u2081)) \u2264 \u03b5, by sorry -- lemma 4\n    -- have hyp_catalysis : Tr S evolve(V \u03c3\u2082 \u2297 \u03c1 \u2297 \u03c3\u2081) = \u03c3\u2082 \u2297 \u03c3\u2081, 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\u00e9bastien Gou\u00ebzel\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 \u2192 F`\nhas an invertible strict derivative `f'` at `a`, then it is locally invertible,\nand the inverse function has derivative `f' \u207b\u00b9`.\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 \u2243L[\ud835\udd5c] 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'\u207b\u00b9`.\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`\u211d` or `\u2102` and implemented here assuming `is_R_or_C \ud835\udd42`.\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 `\u2016f'\u207b\u00b9\u2016`;\n* by `g` we denote the auxiliary contracting map `x \u21a6 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 {\ud835\udd5c : Type*} [nontrivially_normed_field \ud835\udd5c]\nvariables {E : Type*} [normed_add_comm_group E] [normed_space \ud835\udd5c E]\nvariables {F : Type*} [normed_add_comm_group F] [normed_space \ud835\udd5c F]\nvariables {G : Type*} [normed_add_comm_group G] [normed_space \ud835\udd5c G]\nvariables {G' : Type*} [normed_add_comm_group G'] [normed_space \ud835\udd5c G']\nvariables {\u03b5 : \u211d}\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 `\u2016f x - f y - f' (x - y)\u2016 \u2264 c * \u2016x - y\u2016` on an open set\n`s`, where `f' : E \u2192L[\ud835\udd5c] 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 \u2208 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 \u00d7 F \u2192 G` with estimates on `f x y\u2081 - f x y\u2082` but not on `f x\u2081 y - f x\u2082 y`.\n-/\n\n/-- We say that `f` approximates a continuous linear map `f'` on `s` with constant `c`,\nif `\u2016f x - f y - f' (x - y)\u2016 \u2264 c * \u2016x - y\u2016` whenever `x, y \u2208 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 \u2192 F) (f' : E \u2192L[\ud835\udd5c] F) (s : set E) (c : \u211d\u22650) : Prop :=\n\u2200 (x \u2208 s) (y \u2208 s), \u2016f x - f y - f' (x - y)\u2016 \u2264 c * \u2016x - y\u2016\n\n@[simp] lemma approximates_linear_on_empty (f : E \u2192 F) (f' : E \u2192L[\ud835\udd5c] F) (c : \u211d\u22650) :\n  approximates_linear_on f f' \u2205 c :=\nby simp [approximates_linear_on]\n\nnamespace approximates_linear_on\n\nvariables [cs : complete_space E] {f : E \u2192 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 \u2192L[\ud835\udd5c] F} {s t : set E} {c c' : \u211d\u22650}\n\ntheorem mono_num (hc : c \u2264 c') (hf : approximates_linear_on f f' s c) :\n  approximates_linear_on f f' s c' :=\n\u03bb 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 \u2286 t) (hf : approximates_linear_on f f' t c) :\n  approximates_linear_on f f' s c :=\n\u03bb x hx y hy, hf x (hst hx) y (hst hy)\n\nlemma approximates_linear_on_iff_lipschitz_on_with\n  {f : E \u2192 F} {f' : E \u2192L[\ud835\udd5c] F} {s : set E} {c : \u211d\u22650} :\n  approximates_linear_on f f' s c \u2194 lipschitz_on_with c (f - f') s :=\nbegin\n  have : \u2200 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 \u2194\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 (\u03bb x : s, f x - f' x) :=\nbegin\n  refine lipschitz_with.of_dist_le_mul (\u03bb 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 (\u2016f'\u2016\u208a + 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 : \u211d\u22650} {f' : E \u2192L[\ud835\udd5c] 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  {\u03b5 : \u211d} {b : E} (\u03b50 : 0 \u2264 \u03b5) (h\u03b5 : closed_ball b \u03b5 \u2286 s) :\n  surj_on f (closed_ball b \u03b5) (closed_ball (f b) (((f'symm.nnnorm : \u211d)\u207b\u00b9 - c) * \u03b5)) :=\nbegin\n  assume y hy,\n  cases le_or_lt (f'symm.nnnorm : \u211d) \u207b\u00b9 c with hc hc,\n  { refine \u27e8b, by simp [\u03b50], _\u27e9,\n    have : dist y (f b) \u2264 0 :=\n      (mem_closed_ball.1 hy).trans (mul_nonpos_of_nonpos_of_nonneg (by linarith) \u03b50),\n    simp only [dist_le_zero] at this,\n    rw this },\n  have If' : (0 : \u211d) < f'symm.nnnorm,\n    by { rw [\u2190 inv_pos], exact (nnreal.coe_nonneg _).trans_lt hc },\n  have Icf' : (c : \u211d) * f'symm.nnnorm < 1, by rwa [inv_eq_one_div, lt_div_iff If'] at hc,\n  have Jf' : (f'symm.nnnorm : \u211d) \u2260 0 := ne_of_gt If',\n  have Jcf' : (1 : \u211d) - c * f'symm.nnnorm \u2260 0, by { apply ne_of_gt, linarith },\n  /- We have to show that `y` can be written as `f x` for some `x \u2208 closed_ball b \u03b5`.\n  The idea of the proof is to apply the Banach contraction principle to the map\n  `g : x \u21a6 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\u2099 = g\u207f 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 := \u03bb x, x + f'symm (y - f x) with hg,\n  set u := \u03bb (n : \u2115), g ^[n] b with hu,\n  have usucc : \u2200 n, u (n + 1) = g (u n), by simp [hu, \u2190 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 : \u2200 z, dist (g z) z \u2264 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 : \u2200 z \u2208 closed_ball b \u03b5, g z \u2208 closed_ball b \u03b5 \u2192\n    dist (f (g z)) y \u2264 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 = \u2016f (z + v) - y\u2016 : by rw [dist_eq_norm]\n    ... = \u2016f (z + v) - f  z - f' v + f' v - (y - f z)\u2016 : by { congr' 1, abel }\n    ... = \u2016f (z + v) - f z - f' ((z + v) - z)\u2016 :\n      by simp only [continuous_linear_map.nonlinear_right_inverse.right_inv,\n                    add_sub_cancel', sub_add_cancel]\n    ... \u2264 c * \u2016(z + v) - z\u2016 : hf _ (h\u03b5 hgz) _ (h\u03b5 hz)\n    ... \u2264 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 : \u2200 (n : \u2115) (w : E),\n    dist w b \u2264 f'symm.nnnorm * (1 - (c * f'symm.nnnorm)^n) / (1 - c * f'symm.nnnorm) * dist (f b) y\n    \u2192 w \u2208 closed_ball b \u03b5,\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 : \u211d) * (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      ... \u2264 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    ... \u2264 f'symm.nnnorm * (((f'symm.nnnorm : \u211d)\u207b\u00b9 - c) * \u03b5) :\n      by { rw [mul_one],\n           exact mul_le_mul_of_nonneg_left (mem_closed_ball'.1 hy) (nnreal.coe_nonneg _) }\n    ... = \u03b5 * (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 : \u2200 (n : \u2115), dist (f (u n)) y \u2264 (c * f'symm.nnnorm)^n * dist (f b) y\n    \u2227 dist (u n) b \u2264 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 \u2264\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 \u2264 dist (g (u n)) (u n) + dist (u n) b : dist_triangle _ _ _\n      ... \u2264 f'symm.nnnorm * dist (f (u n)) y + dist (u n) b : add_le_add (A _) le_rfl\n      ... \u2264 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 \u27e8_, Ign\u27e9,\n    calc dist (f (g (u n))) y \u2264 c * f'symm.nnnorm * dist (f (u n)) y :\n      B _ (C n _ IH.2) (C n.succ _ Ign)\n    ... \u2264 (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\u2099` is a Cauchy sequence, therefore converging.\n  have : cauchy_seq u,\n  { have : \u2200 (n : \u2115), dist (u n) (u (n+1)) \u2264 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      ... \u2264 f'symm.nnnorm * dist (f (u n)) y : A _\n      ... \u2264 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 \u27e8x, hx\u27e9 : \u2203 x, tendsto u at_top (\ud835\udcdd x) := cauchy_seq_tendsto_of_complete this,\n  -- As all the `u\u2099` belong to the ball `closed_ball b \u03b5`, so does their limit `x`.\n  have xmem : x \u2208 closed_ball b \u03b5 :=\n    is_closed_ball.mem_of_tendsto hx (eventually_of_forall (\u03bb n, C n _ (D n).2)),\n  refine \u27e8x, xmem, _\u27e9,\n  -- It remains to check that `f x = y`. This follows from continuity of `f` on `closed_ball b \u03b5`\n  -- and from the fact that `f u\u2099` is converging to `y` by construction.\n  have hx' : tendsto u at_top (\ud835\udcdd[closed_ball b \u03b5] x),\n  { simp only [nhds_within, tendsto_inf, hx, true_and, ge_iff_le, tendsto_principal],\n    exact eventually_of_forall (\u03bb n, C n _ (D n).2) },\n  have T1 : tendsto (\u03bb n, f (u n)) at_top (\ud835\udcdd (f x)) :=\n    (hf.continuous_on.mono h\u03b5 x xmem).tendsto.comp hx',\n  have T2 : tendsto (\u03bb n, f (u n)) at_top (\ud835\udcdd y),\n  { rw tendsto_iff_dist_tendsto_zero,\n    refine squeeze_zero (\u03bb n, dist_nonneg) (\u03bb 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 \u2228 c < f'symm.nnnorm\u207b\u00b9) : 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 \u22a2,\n  intros x hx,\n  rcases hs x hx with \u27e8\u03b5, \u03b50, h\u03b5\u27e9,\n  refine \u27e8(f'symm.nnnorm\u207b\u00b9 - c) * \u03b5, mul_pos (sub_pos.2 hc) \u03b50, _\u27e9,\n  exact (hf.surj_on_closed_ball_of_nonlinear_right_inverse f'symm (le_of_lt \u03b50) h\u03b5).mono\n    h\u03b5 (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 \u2208 \ud835\udcdd x) (hc : subsingleton F \u2228 c < f'symm.nnnorm\u207b\u00b9) :\n  f '' s \u2208 \ud835\udcdd (f x) :=\nbegin\n  obtain \u27e8t, hts, ht, xt\u27e9 : \u2203 t \u2286 s, is_open t \u2227 x \u2208 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 \u2208 \ud835\udcdd x) (hc : subsingleton F \u2228 c < f'symm.nnnorm\u207b\u00b9) :\n  map f (\ud835\udcdd x) = \ud835\udcdd (f x) :=\nbegin\n  refine le_antisymm ((hf.continuous_on x (mem_of_mem_nhds hs)).continuous_at hs)\n    (le_map (\u03bb t ht, _)),\n  have : f '' (s \u2229 t) \u2208 \ud835\udcdd (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 \u2243L[\ud835\udd5c] F`.\n\nWe also assume that either `E = {0}`, or `c < \u2016f'\u207b\u00b9\u2016\u207b\u00b9`. We use `N` as an abbreviation for `\u2016f'\u207b\u00b9\u2016`.\n-/\n\nvariables {f' : E \u2243L[\ud835\udd5c] F} {s : set E} {c : \u211d\u22650}\n\nlocal notation `N` := \u2016(f'.symm : F \u2192L[\ud835\udd5c] E)\u2016\u208a\n\nprotected lemma antilipschitz (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\n  antilipschitz_with (N\u207b\u00b9 - c)\u207b\u00b9 (s.restrict f) :=\nbegin\n  cases hc with hE hc,\n  { haveI : subsingleton s := \u27e8\u03bb x y, subtype.eq $ @subsingleton.elim _ hE _ _\u27e9,\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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\n  injective (s.restrict f) :=\n(hf.antilipschitz hc).injective\n\nprotected lemma inj_on (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\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 \u2192L[\ud835\udd5c] F) univ c) (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\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 (\u03bb (y : F), \u2203 a, f a = y) (f 0) _,\n    have hc' : (0 : \u211d) < N\u207b\u00b9 - c, by { rw sub_pos, exact hc },\n    let p : \u211d \u2192 Prop := \u03bb R, closed_ball (f 0) R \u2286 set.range f,\n    have hp : \u2200\u1da0 (r:\u211d) in at_top, p ((N\u207b\u00b9 - c) * r),\n    { have hr : \u2200\u1da0 (r:\u211d) in at_top, 0 \u2264 r := eventually_ge_at_top 0,\n      refine hr.mono (\u03bb 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 \u03bb 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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) : 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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\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 (\u03bb 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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\n  approximates_linear_on (hf.to_local_equiv hc).symm (f'.symm : F \u2192L[\ud835\udd5c] E) (f '' s)\n    (N * (N\u207b\u00b9 - c)\u207b\u00b9 * c) :=\nbegin\n  assume x hx y hy,\n  set A := hf.to_local_equiv hc with hA,\n  have Af : \u2200 z, A z = f z := \u03bb z, rfl,\n  rcases (mem_image _ _ _).1 hx with \u27e8x', x's, rfl\u27e9,\n  rcases (mem_image _ _ _).1 hy with \u27e8y', y's, rfl\u27e9,\n  rw [\u2190 Af x', \u2190 Af y', A.left_inv x's, A.left_inv y's],\n  calc \u2016x' - y' - (f'.symm) (A x' - A y')\u2016\n      \u2264 N * \u2016f' (x' - y' - (f'.symm) (A x' - A y'))\u2016 :\n    (f' : E \u2192L[\ud835\udd5c] F).bound_of_antilipschitz f'.antilipschitz _\n  ... = N * \u2016A y' - A x' - f' (y' - x')\u2016 :\n    begin\n      congr' 2,\n      simp only [continuous_linear_equiv.apply_symm_apply, continuous_linear_equiv.map_sub],\n      abel,\n    end\n  ... \u2264 N * (c * \u2016y' - x'\u2016) :\n    mul_le_mul_of_nonneg_left (hf _ y's _ x's) (nnreal.coe_nonneg _)\n  ... \u2264 N * (c * (((N\u207b\u00b9 - c)\u207b\u00b9 : \u211d\u22650) * \u2016A y' - A x'\u2016)) :\n    begin\n      apply_rules [mul_le_mul_of_nonneg_left, nnreal.coe_nonneg],\n      rw [\u2190 dist_eq_norm, \u2190 dist_eq_norm],\n      exact (hf.antilipschitz hc).le_mul_dist \u27e8y', y's\u27e9 \u27e8x', x's\u27e9,\n    end\n  ... = (N * (N\u207b\u00b9 - c)\u207b\u00b9 * c : \u211d\u22650) * \u2016A x' - A y'\u2016 :\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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) univ c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) :\n  E \u2243\u209c 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 \u211d E]\n  {F : Type*} [normed_add_comm_group F] [normed_space \u211d F] [finite_dimensional \u211d F]\n  {s : set E} {f : E \u2192 F} {f' : E \u2243L[\u211d] F} {c : \u211d\u22650}\n  (hf : approximates_linear_on f (f' : E \u2192L[\u211d] F) s c)\n  (hc : subsingleton E \u2228 lipschitz_extension_constant F * c < (\u2016(f'.symm : F \u2192L[\u211d] E)\u2016\u208a)\u207b\u00b9) :\n  \u2203 g : E \u2243\u209c 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 \u27e8u, hu, uf\u27e9 : \u2203 (u : E \u2192 F), lipschitz_with (lipschitz_extension_constant F * c) u\n    \u2227 eq_on (f - f') u s := hf.lipschitz_on_with.extend_finite_dimension,\n  let g : E \u2192 F := \u03bb x, f' x + u x,\n  have fg : eq_on f g s := \u03bb x hx, by simp_rw [g, \u2190 uf hx, pi.sub_apply, add_sub_cancel'_right],\n  have hg : approximates_linear_on g (f' : E \u2192L[\u211d] 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 \u211d E := f'.symm.to_linear_equiv.finite_dimensional,\n  exact \u27e8hg.to_homeomorph g hc, fg\u27e9,\nend\n\nend\n\n@[simp] lemma to_local_homeomorph_coe (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (hs : is_open s) :\n  (hf.to_local_homeomorph f s hc hs : E \u2192 F) = f := rfl\n\n@[simp] lemma to_local_homeomorph_source (hf : approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (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 \u2192L[\ud835\udd5c] F) s c)\n  (hc : subsingleton E \u2228 c < N\u207b\u00b9) (hs : is_open s) {b : E} (\u03b50 : 0 \u2264 \u03b5) (h\u03b5 : closed_ball b \u03b5 \u2286 s) :\n  closed_ball (f b) ((N\u207b\u00b9 - c) * \u03b5) \u2286 (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  \u03b50 h\u03b5).mono h\u03b5 (subset.refl _)\n\nend approximates_linear_on\n\n/-!\n### Inverse function theorem\n\nNow we prove the inverse function theorem. Let `f : E \u2192 F` be a map defined on a complete vector\nspace `E`. Assume that `f` has an invertible derivative `f' : E \u2243L[\ud835\udd5c] 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 \u2192 F} {f' : E \u2192L[\ud835\udd5c] F} {a : E}\n  (hf : has_strict_fderiv_at f f' a) {c : \u211d\u22650} (hc : subsingleton E \u2228 0 < c) :\n  \u2203 s \u2208 \ud835\udcdd a, approximates_linear_on f f' s c :=\nbegin\n  cases hc with hE hc,\n  { refine \u27e8univ, is_open.mem_nhds is_open_univ trivial, \u03bb x hx y hy, _\u27e9,\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 \u27e8s, has, hs\u27e9,\n  exact \u27e8s, has, \u03bb x hx y hy, hs (mk_mem_prod hx hy)\u27e9\nend\n\nlemma map_nhds_eq_of_surj [complete_space E] [complete_space F]\n  {f : E \u2192 F} {f' : E \u2192L[\ud835\udd5c] F} {a : E}\n  (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) (h : linear_map.range f' = \u22a4) :\n  map f (\ud835\udcdd a) = \ud835\udcdd (f a) :=\nbegin\n  let f'symm := f'.nonlinear_right_inverse_of_surjective h,\n  set c : \u211d\u22650 := f'symm.nnnorm\u207b\u00b9 / 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 \u27e8s, s_nhds, hs\u27e9 : \u2203 s \u2208 \ud835\udcdd 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 \u2192 F} {f' : E \u2243L[\ud835\udd5c] F} {a : E}\n\nlemma approximates_deriv_on_open_nhds (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) :\n  \u2203 (s : set E) (hs : a \u2208 s \u2227 is_open s),\n    approximates_linear_on f (f' : E \u2192L[\ud835\udd5c] F) s (\u2016(f'.symm : F \u2192L[\ud835\udd5c] E)\u2016\u208a\u207b\u00b9 / 2) :=\nbegin\n  refine ((nhds_basis_opens a).exists_iff _).1 _,\n  exact (\u03bb s t, approximates_linear_on.mono_set),\n  exact (hf.approximates_deriv_on_nhds $ f'.subsingleton_or_nnnorm_symm_pos.imp id $\n    \u03bb 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 \u2208 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 \u2192L[\ud835\udd5c] 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 $ \u03bb 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 \u2192L[\ud835\udd5c] F) a) :\n  (hf.to_local_homeomorph f : E \u2192 F) = f := rfl\n\nlemma mem_to_local_homeomorph_source (hf : has_strict_fderiv_at f (f' : E \u2192L[\ud835\udd5c] F) a) :\n  a \u2208 (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 \u2192L[\ud835\udd5c] F) a) :\n  f a \u2208 (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 \u2192L[\ud835\udd5c] F) a) :\n  map f (\ud835\udcdd a) = \ud835\udcdd (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 \u2192L[\ud835\udd5c] F) a) : F \u2192 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 \u2192L[\ud835\udd5c] 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 \u2192L[\ud835\udd5c] F) a) :\n  \u2200\u1da0 x in \ud835\udcdd 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 \u2192L[\ud835\udd5c] F) a) :\n  \u2200\u1da0 y in \ud835\udcdd (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 \u2192L[\ud835\udd5c] 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 \u2192L[\ud835\udd5c] F) a) :\n  tendsto (hf.local_inverse f f' a) (\ud835\udcdd $ f a) (\ud835\udcdd 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 \u2192L[\ud835\udd5c] F) a) {g : F \u2192 E}\n  (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  \u2200\u1da0 y in \ud835\udcdd (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 \u2192L[\ud835\udd5c] F) a) :\n  has_strict_fderiv_at (hf.local_inverse f f' a) (f'.symm : F \u2192L[\ud835\udd5c] E) (f a) :=\n(hf.to_local_homeomorph f).has_strict_fderiv_at_symm hf.image_mem_to_local_homeomorph_target $\n  by simpa [\u2190 local_inverse_def] using hf\n\n/-- If `f : E \u2192 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 \u2192L[\ud835\udd5c] F) a) {g : F \u2192 E}\n  (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  has_strict_fderiv_at g (f'.symm : F \u2192L[\ud835\udd5c] E) (f a) :=\nhf.to_local_inverse.congr_of_eventually_eq $ (hf.local_inverse_unique hg).mono $ \u03bb _, 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 \u2192 F} {f' : E \u2192 E \u2243L[\ud835\udd5c] F}\n  (hf : \u2200 x, has_strict_fderiv_at f (f' x : E \u2192L[\ud835\udd5c] F) x) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ \u03bb 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 : \ud835\udd5c \u2192 \ud835\udd5c`.\nWe use `continuous_linear_equiv.units_equiv_aut` to translate `has_strict_deriv_at f f' a` and\n`f' \u2260 0` into `has_strict_fderiv_at f (_ : \ud835\udd5c \u2243L[\ud835\udd5c] \ud835\udd5c) a`.\n-/\n\nnamespace has_strict_deriv_at\n\nvariables [cs : complete_space \ud835\udd5c] {f : \ud835\udd5c \u2192 \ud835\udd5c} {f' a : \ud835\udd5c} (hf : has_strict_deriv_at f f' a)\n  (hf' : f' \u2260 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 : \ud835\udd5c \u2192 \ud835\udd5c :=\n(hf.has_strict_fderiv_at_equiv hf').local_inverse _ _ _\n\nvariables {f f' a}\n\nlemma map_nhds_eq : map f (\ud835\udcdd a) = \ud835\udcdd (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'\u207b\u00b9 (f a) :=\n(hf.has_strict_fderiv_at_equiv hf').to_local_inverse\n\ntheorem to_local_left_inverse {g : \ud835\udd5c \u2192 \ud835\udd5c} (hg : \u2200\u1da0 x in \ud835\udcdd a, g (f x) = x) :\n  has_strict_deriv_at g f'\u207b\u00b9 (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 \ud835\udd5c] {f f' : \ud835\udd5c \u2192 \ud835\udd5c}\n  (hf : \u2200 x, has_strict_deriv_at f (f' x) x) (h0 : \u2200 x, f' x \u2260 0) :\n  is_open_map f :=\nis_open_map_iff_nhds_le.2 $ \u03bb 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 {\ud835\udd42 : Type*} [is_R_or_C \ud835\udd42]\nvariables {E' : Type*} [normed_add_comm_group E'] [normed_space \ud835\udd42 E']\nvariables {F' : Type*} [normed_add_comm_group F'] [normed_space \ud835\udd42 F']\nvariables [complete_space E'] (f : E' \u2192 F') {f' : E' \u2243L[\ud835\udd42] F'} {a : E'}\n\n/-- Given a `cont_diff` function over `\ud835\udd42` (which is `\u211d` or `\u2102`) with an invertible\nderivative at `a`, returns a `local_homeomorph` with `to_fun = f` and `a \u2208 source`. -/\ndef to_local_homeomorph\n  {n : \u2115\u221e} (hf : cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 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 : \u2115\u221e} (hf : cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  (hf.to_local_homeomorph f hf' hn : E' \u2192 F') = f := rfl\n\nlemma mem_to_local_homeomorph_source\n  {n : \u2115\u221e} (hf : cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  a \u2208 (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 : \u2115\u221e} (hf : cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  f a \u2208 (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 `\ud835\udd42` (which is `\u211d` or `\u2102`) with an invertible derivative\nat `a`, returns a function that is locally inverse to `f`. -/\ndef local_inverse\n  {n : \u2115\u221e} (hf : cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  F' \u2192 E' :=\n(hf.has_strict_fderiv_at' hf' hn).local_inverse f f' a\n\nlemma local_inverse_apply_image\n  {n : \u2115\u221e} (hf : cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 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 `\ud835\udd42` (which is `\u211d` or `\u2102`) 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 : \u2115\u221e} (hf : cont_diff_at \ud835\udd42 n f a) (hf' : has_fderiv_at f (f' : E' \u2192L[\ud835\udd42] F') a)\n  (hn : 1 \u2264 n) :\n  cont_diff_at \ud835\udd42 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\u2081 w\u2082\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 : \u2200 N : LieSubmodule R L M, N \u2260 \u22a5 \u2192 N = \u22a4\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 : \u00acIsLieAbelian 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 = \u22a5\n#align lie_algebra.is_semisimple LieAlgebra.IsSemisimple\n\ntheorem isSemisimple_iff_no_solvable_ideals :\n    IsSemisimple R L \u2194 \u2200 I : LieIdeal R L, IsSolvable R I \u2192 I = \u22a5 :=\n  \u27e8fun h => sup\u209b_eq_bot.mp h.semisimple, fun h => \u27e8sup\u209b_eq_bot.mpr h\u27e9\u27e9\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 \u2194 \u2200 I : LieIdeal R L, IsLieAbelian I \u2192 I = \u22a5 :=\n  by\n  rw [is_semisimple_iff_no_solvable_ideals]\n  constructor <;> intro h\u2081 I h\u2082\n  \u00b7 haveI : IsLieAbelian I := h\u2082\n    apply h\u2081\n    exact LieAlgebra.ofAbelianIsSolvable R I\n  \u00b7 haveI : IsSolvable R I := h\u2082\n    rw [\u2190 abelian_of_solvable_ideal_eq_bot_iff]\n    apply h\u2081\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 = \u22a5 :=\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 @\u27e8\u27e8h\u2081\u27e9, h\u2082\u27e9 := id h\n  by_contra contra\n  rw [h\u2081 I contra, lie_abelian_iff_equiv_lie_abelian LieIdeal.topEquiv] at hI\n  exact h\u2082 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) \u2194 \u2200 I : LieIdeal R L, IsSolvable R I \u2192 IsLieAbelian I :=\n  by\n  constructor\n  \u00b7 rintro h\u2081 I h\u2082\n    rw [lie_ideal.solvable_iff_le_radical] at h\u2082\n    exact (LieIdeal.homOfLe_injective h\u2082).IsLieAbelian h\u2081\n  \u00b7 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 = \u22a5 := 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\u2081 w\u2082 v\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable theory\n\nopen category_theory\nopen category_theory.limits\n\nnamespace category_theory\n\nvariables {C : Type u\u2081} [category.{v\u2081} C] {D : Type u\u2082} [category.{v\u2082} D]\n\nsection has_zero_morphisms\nvariables [has_zero_morphisms C] [has_zero_morphisms D]\n\nnamespace functor\n\nsection map\nvariables (F : C \u2964 D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type w\u2081}\n\n/-- The image of a bicone under a functor. -/\n@[simps]\ndef map_bicone {f : J \u2192 C} (b : bicone f) : bicone (F.obj \u2218 f) :=\n{ X := F.obj b.X,\n  \u03c0 := \u03bb j, F.map (b.\u03c0 j),\n  \u03b9 := \u03bb j, F.map (b.\u03b9 j),\n  \u03b9_\u03c0 := \u03bb j j',\n  begin\n    rw \u2190 F.map_comp,\n    split_ifs,\n    { subst h,\n      simp only [bicone_\u03b9_\u03c0_self, category_theory.functor.map_id, eq_to_hom_refl] },\n    { rw [bicone_\u03b9_\u03c0_ne _ h, F.map_zero] }\n  end }\n\nlemma map_bicone_whisker {K : Type w\u2082} {g : K \u2243 J} {f : J \u2192 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 [\u2190 F.map_comp, b.inl_fst, F.map_id],\n  inl_snd' := by rw [\u2190 F.map_comp, b.inl_snd, F.map_zero],\n  inr_fst' := by rw [\u2190 F.map_comp, b.inr_fst, F.map_zero],\n  inr_snd' := by rw [\u2190 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\u2081} {K : Type w\u2082}\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 \u2218 f`. -/\nclass preserves_biproduct (f : J \u2192 C) (F : C \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {b : bicone f}, b.is_bilimit \u2192 (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 \u2218 f`. -/\ndef is_bilimit_of_preserves {f : J \u2192 C} (F : C \u2964 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 \u2192 C`. -/\nclass preserves_biproducts_of_shape (F : C \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {f : J \u2192 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {J : Type w\u2081}, 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 \u2964 D) [preserves_zero_morphisms F]\n  [hp : preserves_biproducts.{max w\u2081 w\u2082} F] : preserves_biproducts.{w\u2081} F :=\n\u27e8\u03bb J, \u27e8\u03bb f, \u27e8\u03bb 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\u2082}).inv_fun ib))\u27e9\u27e9\u27e9\n\n@[priority 100]\ninstance preserves_finite_biproducts_of_preserves_biproducts (F : C \u2964 D)\n  [preserves_zero_morphisms F] [preserves_biproducts.{w\u2081} F] : preserves_finite_biproducts F :=\n{ preserves := \u03bb 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {b : binary_bicone X Y}, b.is_bilimit \u2192 (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 \u2964 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D) [preserves_zero_morphisms F]\n  (X Y : C) [preserves_biproduct (pair_function X Y) F] : preserves_binary_biproduct X Y F :=\n{ preserves := \u03bb 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, 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 _) (\u03bb j, by { rcases j with \u27e8\u27e8\u27e9\u27e9, tidy, }) } }\n\n/-- A functor that preserves biproducts of a pair preserves binary biproducts. -/\ndef preserves_binary_biproducts_of_preserves_biproducts (F : C \u2964 D)\n  [preserves_zero_morphisms F] [preserves_biproducts_of_shape walking_pair F] :\n  preserves_binary_biproducts F :=\n{ preserves := \u03bb 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\u2081} (F : C \u2964 D) (f : J \u2192 C)\n  [has_biproduct f]\n\nsection\nvariables [has_biproduct (F.obj \u2218 f)]\n\n/-- As for products, any functor between categories with biproducts gives rise to a morphism\n    `F.obj (\u2a01 f) \u27f6 \u2a01 (F.obj \u2218 f)`. -/\ndef biproduct_comparison : F.obj (\u2a01 f) \u27f6 \u2a01 (F.obj \u2218 f) :=\nbiproduct.lift (\u03bb j, F.map (biproduct.\u03c0 f j))\n\n@[simp, reassoc] lemma biproduct_comparison_\u03c0 (j : J) :\n  biproduct_comparison F f \u226b biproduct.\u03c0 _ j = F.map (biproduct.\u03c0 f j) :=\nbiproduct.lift_\u03c0 _ _\n\n/-- As for coproducts, any functor between categories with biproducts gives rise to a morphism\n    `\u2a01 (F.obj \u2218 f) \u27f6 F.obj (\u2a01 f)` -/\ndef biproduct_comparison' : \u2a01 (F.obj \u2218 f) \u27f6 F.obj (\u2a01 f) :=\nbiproduct.desc (\u03bb j, F.map (biproduct.\u03b9 f j))\n\n@[simp, reassoc] lemma \u03b9_biproduct_comparison' (j : J) :\n  biproduct.\u03b9 _ j \u226b biproduct_comparison' F f = F.map (biproduct.\u03b9 f j) :=\nbiproduct.\u03b9_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 \u226b biproduct_comparison F f = \ud835\udfd9 (\u2a01 (F.obj \u2218 f)) :=\nby { classical, ext, simp [biproduct.\u03b9_\u03c0, \u2190 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\u27e8biproduct_comparison' F f\u27e9\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\u27e8biproduct_comparison F f\u27e9\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 \u2218 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 (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f)`. -/\n@[simp]\ndef map_biproduct : F.obj (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f) :=\nbiproduct.unique_up_to_iso _ (preserves_biproduct.preserves (biproduct.is_bilimit _))\n\nlemma map_biproduct_hom : (map_biproduct F f).hom = biproduct.lift (\u03bb j, F.map (biproduct.\u03c0 f j)) :=\nrfl\n\nlemma map_biproduct_inv : (map_biproduct F f).inv = biproduct.desc (\u03bb j, F.map (biproduct.\u03b9 f j)) :=\nrfl\n\nend bicone\n\nvariables (F : C \u2964 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 \u229e Y) \u27f6 F.obj X \u229e F.obj Y`. -/\ndef biprod_comparison : F.obj (X \u229e Y) \u27f6 F.obj X \u229e 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 \u226b biprod.fst = F.map biprod.fst :=\nbiprod.lift_fst _ _\n\n@[simp, reassoc] lemma biprod_comparison_snd :\n  biprod_comparison F X Y \u226b 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 \u229e F.obj Y \u27f6 F.obj (X \u229e Y)`. -/\ndef biprod_comparison' : F.obj X \u229e F.obj Y \u27f6 F.obj (X \u229e Y) :=\nbiprod.desc (F.map biprod.inl) (F.map biprod.inr)\n\n@[simp, reassoc] lemma inl_biprod_comparison' :\n  biprod.inl \u226b biprod_comparison' F X Y = F.map biprod.inl :=\nbiprod.inl_desc _ _\n\n@[simp, reassoc] lemma inr_biprod_comparison' :\n  biprod.inr \u226b 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\u27e8biprod_comparison' F X Y\u27e9\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\u27e8biprod_comparison F X Y\u27e9\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 \u229e Y) \u2245 F.obj X \u229e F.obj Y`. -/\n@[simp]\ndef map_biprod : F.obj (X \u229e Y) \u2245 F.obj X \u229e 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 \u2964 D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type w\u2081} (f : J \u2192 C) [has_biproduct f] [preserves_biproduct f F]\n  {W : C}\n\nlemma biproduct.map_lift_map_biprod (g : \u03a0 j, W \u27f6 f j) :\n  F.map (biproduct.lift g) \u226b (F.map_biproduct f).hom = biproduct.lift (\u03bb j, F.map (g j)) :=\nby { ext, simp [\u2190 F.map_comp] }\n\nlemma biproduct.map_biproduct_inv_map_desc (g : \u03a0 j, f j \u27f6 W) :\n  (F.map_biproduct f).inv \u226b F.map (biproduct.desc g) = biproduct.desc (\u03bb j, F.map (g j)) :=\nby { ext, simp [\u2190 F.map_comp] }\n\nlemma biproduct.map_biproduct_hom_desc (g : \u03a0 j, f j \u27f6 W) :\n  (F.map_biproduct f).hom \u226b biproduct.desc (\u03bb j, F.map (g j)) = F.map (biproduct.desc g) :=\nby rw [\u2190 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 \u27f6 X) (g : W \u27f6 Y) :\n  F.map (biprod.lift f g) \u226b (F.map_biprod X Y).hom = biprod.lift (F.map f) (F.map g) :=\nby ext; simp [\u2190 F.map_comp]\n\nlemma biprod.lift_map_biprod (f : W \u27f6 X) (g : W \u27f6 Y) :\n  biprod.lift (F.map f) (F.map g) \u226b (F.map_biprod X Y).inv = F.map (biprod.lift f g) :=\nby rw [\u2190 biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n\nlemma biprod.map_biprod_inv_map_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n  (F.map_biprod X Y).inv \u226b F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) :=\nby ext; simp [\u2190 F.map_comp]\n\nlemma biprod.map_biprod_hom_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n (F.map_biprod X Y).hom \u226b biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) :=\nby rw [\u2190 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": "import data.sym.sym2\n\nopen function\n\nvariables {\u03b1 \u03b2 : Type*} {e : sym2 \u03b1} {f : \u03b1 \u2192 \u03b2}\n\nnamespace sym2\n\nprotected lemma is_diag.map : e.is_diag \u2192 (e.map f).is_diag := sym2.ind (\u03bb x y, congr_arg f) e\n\nlemma is_diag_map (hf : injective f) : (e.map f).is_diag \u2194 e.is_diag :=\nsym2.ind (\u03bb x y, hf.eq_iff) e\n\nend sym2\n", "meta": {"author": "YaelDillies", "repo": "LeanCamCombi", "sha": "9f62375030cd2bd1be6ef10bba68b1b31aa98acf", "save_path": "github-repos/lean/YaelDillies-LeanCamCombi", "path": "github-repos/lean/YaelDillies-LeanCamCombi/LeanCamCombi-9f62375030cd2bd1be6ef10bba68b1b31aa98acf/src/mathlib/data/sym/sym2.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.7905303285397349, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.45048580374167263}}
{"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-/\nimport Aesop\n\nset_option aesop.check.all false\n-- With this option, the test becomes unbearably slow.\n\nabbrev State := String \u2192 Int\n\ninductive Com where\n| Skip : Com\n| Seq : Com \u2192 Com \u2192 Com\n\ndeclare_syntax_cat com\n\nsyntax \"SKIP\" : com\nsyntax com \";\" com : com\nsyntax \"(\" com \")\" : com\nsyntax term : com\n\nsyntax \"[Com|\" com \"]\" : term\n\nmacro_rules\n| `([Com| SKIP]) => `(Com.Skip)\n| `([Com| $x ; $y]) => `(Com.Seq [Com| $x] [Com| $y])\n| `([Com| ( $x:com )]) => `([Com| $x])\n| `([Com| $x:term ]) => `($x)\n\n@[aesop safe [constructors, -100 (cases (index := [hyp BigStep Com.Skip _ _, hyp BigStep [Com| _;_] _ _]))]]\ninductive BigStep : Com \u2192 State \u2192 State \u2192 Prop where\n| Skip : BigStep Com.Skip s s\n| Seq (h1 : BigStep c\u2081 s t) (h2 : BigStep c\u2082 t u) : BigStep [Com| c\u2081;c\u2082] s u\n\ntheorem seq_assoc :\n    BigStep [Com| (c1;c2);c3] s s' \u2194 BigStep [Com| c1;c2;c3] s s' := by\n  aesop\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/Com.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7905303186696748, "lm_q2_score": 0.5698526514141571, "lm_q1q2_score": 0.45048579811719275}}
{"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] : \u00ac\u00ac a \u2194 a :=\nby by_cases a; simp [h]\n\n@[simp] lemma and_imp_distrib (a b c : Prop) : (a \u2227 b \u2192 c) \u2194 (a \u2192 b \u2192 c) :=\niff.intro\n  (assume h ha hb, h \u27e8ha, hb\u27e9)\n  (assume h \u27e8ha, hb\u27e9, h ha hb)\n\n@[simp] lemma or_imp_distrib {a b c : Prop} : a \u2228 b \u2192 c \u2194 (a \u2192 c) \u2227 (b \u2192 c) :=\niff.intro\n  (assume h,\n   \u27e8assume ha, h (or.intro_left _ ha), assume hb, h (or.intro_right _ hb)\u27e9)\n  (assume \u27e8ha, hb\u27e9 h, match h with or.inl h := ha h | or.inr h := hb h end)\n\n@[simp] lemma exists_imp_distrib {\u03b1 : Sort*} {p : \u03b1 \u2192 Prop} {a : Prop} :\n  ((\u2203x, p x) \u2192 a) \u2194 (\u2200x, p x \u2192 a) :=\niff.intro\n  (assume h hp ha, h \u27e8hp, ha\u27e9)\n  (assume h \u27e8hp, ha\u27e9, h hp ha)\n\nlemma and_exists {\u03b1 : Sort*} {p : \u03b1 \u2192 Prop} {a : Prop} :\n  (a \u2227 (\u2203x, p x)) \u2194 (\u2203x, a \u2227 p x) :=\niff.intro\n  (assume \u27e8ha, x, hp\u27e9, \u27e8x, ha, hp\u27e9)\n  (assume \u27e8x, ha, hp\u27e9, \u27e8ha, x, hp\u27e9)\n\n@[simp] lemma exists_false {\u03b1 : Sort*} : (\u2203x : \u03b1, false) \u2194 false :=\niff.intro (assume \u27e8a, f\u27e9, f) (assume h, h.elim)\n\n\n/- Reflexive transitive closure of a relation -/\n\ninductive refl_trans {\u03b1 : Sort*} (r : \u03b1 \u2192 \u03b1 \u2192 Prop) (a : \u03b1) : \u03b1 \u2192 Prop\n| refl {} : refl_trans a\n| tail {b c} : refl_trans b \u2192 r b c \u2192 refl_trans c\n\nattribute [refl] refl_trans.refl\n\nnamespace refl_trans\n\nvariables {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {a b c d : \u03b1}\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 {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {b : \u03b1}\n  {P : \u2200a : \u03b1, refl_trans r a b \u2192 Prop} {a : \u03b1} (h : refl_trans r a b)\n  (refl : P b refl)\n  (head : \u2200{a c} (h' : r a c) (h : refl_trans r c b), P c h \u2192 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 \u2200a a', r a a' \u2192 refl_trans r a' b \u2192 P a' _ \u2192 P a _,\n      from assume a a' hab hbc, head hab _ }\nend\n\nlemma trans_induction_on {\u03b1 : Sort*} {r : \u03b1 \u2192 \u03b1 \u2192 Prop}\n  {P : \u2200{a b : \u03b1}, refl_trans r a b \u2192 Prop}\n  {a b : \u03b1} (h : refl_trans r a b)\n  (ih\u2081 : \u2200a, @P a a refl)\n  (ih\u2082 : \u2200{a b} (h : r a b), P (single h))\n  (ih\u2083 : \u2200{a b c} (h\u2081 : refl_trans r a b) (h\u2082 : refl_trans r b c), P h\u2081 \u2192 P h\u2082 \u2192\n    P (h\u2081.trans h\u2082)) :\n  P h :=\nbegin\n  induction h,\n  case refl_trans.refl { exact ih\u2081 a },\n  case refl_trans.tail : b c hab hbc ih {\n    exact ih\u2083 hab (single hbc) ih (ih\u2082 hbc) }\nend\n\nlemma lift {\u03b2 : Sort*} {p : \u03b2 \u2192 \u03b2 \u2192 Prop} (f : \u03b1 \u2192 \u03b2)\n  (h : \u2200a b, r a b \u2192 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 \u2218 h _ _)\n  (assume a b c _ _, trans)\n\nlemma mono {p : \u03b1 \u2192 \u03b1 \u2192 Prop} :\n  (\u2200a b, r a b \u2192 p a b) \u2192 refl_trans r a b \u2192 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 \u2192 \u2115\n\ndef state.update (name : string) (val : \u2115) (s : state) :\n  state :=\n\u03bbname', if name' = name then val else s name'\n\nnotation s `{` name ` \u21a6 ` val `}` := state.update name val s\n\ninstance : has_emptyc state := \u27e8\u03bb_, 0\u27e9\n\n@[simp] lemma update_apply (name : string) (val : \u2115)\n  (s : state) : s{name \u21a6 val} name = val :=\nif_pos rfl\n\n@[simp] lemma update_apply_ne (name name' : string) (val : \u2115)\n    (s : state) (h : name' \u2260 name . tactic.dec_trivial) :\n  s{name \u21a6 val} name' = s name' :=\nif_neg h\n\n@[simp] lemma update_override (name : string) (val\u2081 val\u2082 : \u2115)\n  (s : state) : s{name \u21a6 val\u2082}{name \u21a6 val\u2081} = s{name \u21a6 val\u2081} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name;\n    simp [h]\nend\n\n@[simp] lemma update_swap (name\u2081 name\u2082 : string) (val\u2081 val\u2082 : \u2115)\n  (s : state) (h : name\u2081 \u2260 name\u2082 . tactic.dec_trivial) :\n  s{name\u2082 \u21a6 val\u2082}{name\u2081 \u21a6 val\u2081} =\n  s{name\u2081 \u21a6 val\u2081}{name\u2082 \u21a6 val\u2082} :=\nbegin\n  apply funext,\n  intro name',\n  by_cases name' = name\u2081;\n    by_cases name' = name\u2082;\n    simp * at *\nend\n\n@[simp] lemma update_id (name : string) (s : state) :\n  s{name \u21a6 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\" \u21a6 0}{\"a\" \u21a6 2} = s{\"a\" \u21a6 2} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" \u21a6 0}{\"b\" \u21a6 2} = s{\"b\" \u21a6 2}{\"a\" \u21a6 0} :=\nby simp\n\nexample (s : state) :\n  s{\"a\" \u21a6 s \"a\"}{\"b\" \u21a6 0} = s{\"b\" \u21a6 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  \u2203F: Class,\u2203_: Function F,\u2200x: Class, \u2200_: Set x,\n    (\u00ac x\uff1d\u00f8 \u2192 (\u2203y: Class,\u2203hy: y\u2208x,\n      (@Pair_mk x y _ (Set.mk\u2081 hy)) \u2208 F))\n\n-- ex. AxiomChoice\ntheorem AxiomChoice:\n  \u2200x: Class, \u2200_: Set x,\n    \u2203f: Class, \u2203_: Function f, \u2200y: Class, \u2203hy: y\u2208x,\n      (\u00ac y\uff1d\u00f8 \u2192 (\u2203z: Class,\u2203hz: z\u2208y,\n        ((@Pair_mk y z (Set.mk\u2081 hy) (Set.mk\u2081 hz)) \u2208 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\u2081 w\u2082 v\u2081 v\u2082 u\u2081 u\u2082\n\nnoncomputable section\n\nopen CategoryTheory\n\nopen CategoryTheory.Limits\n\nnamespace CategoryTheory\n\nvariable {C : Type u\u2081} [Category.{v\u2081} C] {D : Type u\u2082} [Category.{v\u2082} D]\n\nsection HasZeroMorphisms\n\nvariable [HasZeroMorphisms C] [HasZeroMorphisms D]\n\nnamespace Functor\n\nsection Map\n\nvariable (F : C \u2964 D) [PreservesZeroMorphisms F]\n\nsection Bicone\n\nvariable {J : Type w\u2081}\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\u2093'. -/\n/-- The image of a bicone under a functor. -/\n@[simps]\ndef mapBicone {f : J \u2192 C} (b : Bicone f) : Bicone (F.obj \u2218 f)\n    where\n  pt := F.obj b.pt\n  \u03c0 j := F.map (b.\u03c0 j)\n  \u03b9 j := F.map (b.\u03b9 j)\n  \u03b9_\u03c0 j j' := by\n    rw [\u2190 F.map_comp]\n    split_ifs\n    \u00b7 subst h\n      simp only [bicone_\u03b9_\u03c0_self, CategoryTheory.Functor.map_id, eq_to_hom_refl]\n    \u00b7 rw [bicone_\u03b9_\u03c0_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\u2082} {g : K \u2243 J} {f : J \u2192 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\u2093'. -/\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 [\u2190 F.map_comp, b.inl_fst, F.map_id]\n  inl_snd := by rw [\u2190 F.map_comp, b.inl_snd, F.map_zero]\n  inr_fst := by rw [\u2190 F.map_comp, b.inr_fst, F.map_zero]\n  inr_snd := by rw [\u2190 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\u2081} {K : Type w\u2082}\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 \u2218 f`. -/\nclass PreservesBiproduct (f : J \u2192 C) (F : C \u2964 D) [PreservesZeroMorphisms F] where\n  preserves : \u2200 {b : Bicone f}, b.IsBilimit \u2192 (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\u2093'. -/\n/-- A functor `F` preserves biproducts of `f` if `F` maps every bilimit bicone over `f` to a\n    bilimit bicone over `F.obj \u2218 f`. -/\ndef isBilimitOfPreserves {f : J \u2192 C} (F : C \u2964 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 \u2192 C`. -/\nclass PreservesBiproductsOfShape (F : C \u2964 D) [PreservesZeroMorphisms F] where\n  preserves : \u2200 {f : J \u2192 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 \u2964 D) [PreservesZeroMorphisms F] where\n  preserves : \u2200 {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 \u2964 D) [PreservesZeroMorphisms F] where\n  preserves : \u2200 {J : Type w\u2081}, 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 \u2964 D) [PreservesZeroMorphisms F]\n    [hp : PreservesBiproducts.{max w\u2081 w\u2082} F] : PreservesBiproducts.{w\u2081} F :=\n  \u27e8fun J =>\n    \u27e8fun f =>\n      \u27e8fun b ib =>\n        ((F.mapBicone b).whiskerIsBilimitIff _).toFun\n          (isBilimitOfPreserves F ((b.whiskerIsBilimitIff Equiv.ulift.{w\u2082}).invFun ib))\u27e9\u27e9\u27e9\n#align category_theory.limits.preserves_biproducts_shrink CategoryTheory.Limits.preservesBiproductsShrink\n-/\n\n#print CategoryTheory.Limits.preservesFiniteBiproductsOfPreservesBiproducts /-\ninstance (priority := 100) preservesFiniteBiproductsOfPreservesBiproducts (F : C \u2964 D)\n    [PreservesZeroMorphisms F] [PreservesBiproducts.{w\u2081} 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 \u2964 D) [PreservesZeroMorphisms F] where\n  preserves : \u2200 {b : BinaryBicone X Y}, b.IsBilimit \u2192 (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\u2093'. -/\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 \u2964 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 \u2964 D) [PreservesZeroMorphisms F] where\n  preserves : \u2200 {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 \u2964 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 \u27e8\u27e8\u27e9\u27e9\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 \u27e8\u27e8\u27e9\u27e9\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 \u2964 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\u2081} (F : C \u2964 D) (f : J \u2192 C) [HasBiproduct f]\n\nsection\n\nvariable [HasBiproduct (F.obj \u2218 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\u2093'. -/\n/-- As for products, any functor between categories with biproducts gives rise to a morphism\n    `F.obj (\u2a01 f) \u27f6 \u2a01 (F.obj \u2218 f)`. -/\ndef biproductComparison : F.obj (\u2a01 f) \u27f6 \u2a01 F.obj \u2218 f :=\n  biproduct.lift fun j => F.map (biproduct.\u03c0 f j)\n#align category_theory.functor.biproduct_comparison CategoryTheory.Functor.biproductComparison\n\n/- warning: category_theory.functor.biproduct_comparison_\u03c0 -> CategoryTheory.Functor.biproductComparison_\u03c0 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.\u03c0.{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.\u03c0.{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.\u03c0.{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.\u03c0.{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_\u03c0 CategoryTheory.Functor.biproductComparison_\u03c0\u2093'. -/\n@[simp, reassoc.1]\ntheorem biproductComparison_\u03c0 (j : J) :\n    biproductComparison F f \u226b biproduct.\u03c0 _ j = F.map (biproduct.\u03c0 f j) :=\n  biproduct.lift_\u03c0 _ _\n#align category_theory.functor.biproduct_comparison_\u03c0 CategoryTheory.Functor.biproductComparison_\u03c0\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'\u2093'. -/\n/-- As for coproducts, any functor between categories with biproducts gives rise to a morphism\n    `\u2a01 (F.obj \u2218 f) \u27f6 F.obj (\u2a01 f)` -/\ndef biproductComparison' : \u2a01 F.obj \u2218 f \u27f6 F.obj (\u2a01 f) :=\n  biproduct.desc fun j => F.map (biproduct.\u03b9 f j)\n#align category_theory.functor.biproduct_comparison' CategoryTheory.Functor.biproductComparison'\n\n/- warning: category_theory.functor.\u03b9_biproduct_comparison' -> CategoryTheory.Functor.\u03b9_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.\u03b9.{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.\u03b9.{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.\u03b9.{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.\u03b9.{u1, u2, u4} J C _inst_1 _inst_3 f _inst_5 j))\nCase conversion may be inaccurate. Consider using '#align category_theory.functor.\u03b9_biproduct_comparison' CategoryTheory.Functor.\u03b9_biproductComparison'\u2093'. -/\n@[simp, reassoc.1]\ntheorem \u03b9_biproductComparison' (j : J) :\n    biproduct.\u03b9 _ j \u226b biproductComparison' F f = F.map (biproduct.\u03b9 f j) :=\n  biproduct.\u03b9_desc _ _\n#align category_theory.functor.\u03b9_biproduct_comparison' CategoryTheory.Functor.\u03b9_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\u2093'. -/\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 \u226b biproductComparison F f = \ud835\udfd9 (\u2a01 F.obj \u2218 f) := by\n  classical\n    ext\n    simp [biproduct.\u03b9_\u03c0, \u2190 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\u2093'. -/\n/-- `biproduct_comparison F f` is a split epimorphism. -/\n@[simps]\ndef splitEpiBiproductComparison : SplitEpi (biproductComparison F f) :=\n  \u27e8biproductComparison' F f\u27e9\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'\u2093'. -/\n/-- `biproduct_comparison' F f` is a split monomorphism. -/\n@[simps]\ndef splitMonoBiproductComparison' : SplitMono (biproductComparison' F f) :=\n  \u27e8biproductComparison F f\u27e9\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\u2093'. -/\ninstance hasBiproduct_of_preserves : HasBiproduct (F.obj \u2218 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\u2093'. -/\n/-- If `F` preserves a biproduct, we get a definitionally nice isomorphism\n    `F.obj (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f)`. -/\n@[simp]\ndef mapBiproduct : F.obj (\u2a01 f) \u2245 \u2a01 F.obj \u2218 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.\u03c0.{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.\u03c0.{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\u2093'. -/\ntheorem mapBiproduct_hom :\n    (mapBiproduct F f).hom = biproduct.lift fun j => F.map (biproduct.\u03c0 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.\u03b9.{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.\u03b9.{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\u2093'. -/\ntheorem mapBiproduct_inv :\n    (mapBiproduct F f).inv = biproduct.desc fun j => F.map (biproduct.\u03b9 f j) :=\n  rfl\n#align category_theory.functor.map_biproduct_inv CategoryTheory.Functor.mapBiproduct_inv\n\nend Bicone\n\nvariable (F : C \u2964 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\u2093'. -/\n/-- As for products, any functor between categories with binary biproducts gives rise to a\n    morphism `F.obj (X \u229e Y) \u27f6 F.obj X \u229e F.obj Y`. -/\ndef biprodComparison : F.obj (X \u229e Y) \u27f6 F.obj X \u229e 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\u2093'. -/\n@[simp, reassoc.1]\ntheorem biprodComparison_fst : biprodComparison F X Y \u226b 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\u2093'. -/\n@[simp, reassoc.1]\ntheorem biprodComparison_snd : biprodComparison F X Y \u226b 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'\u2093'. -/\n/-- As for coproducts, any functor between categories with binary biproducts gives rise to a\n    morphism `F.obj X \u229e F.obj Y \u27f6 F.obj (X \u229e Y)`. -/\ndef biprodComparison' : F.obj X \u229e F.obj Y \u27f6 F.obj (X \u229e 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'\u2093'. -/\n@[simp, reassoc.1]\ntheorem inl_biprodComparison' : biprod.inl \u226b 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'\u2093'. -/\n@[simp, reassoc.1]\ntheorem inr_biprodComparison' : biprod.inr \u226b 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\u2093'. -/\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 \u226b biprodComparison F X Y = \ud835\udfd9 (F.obj X \u229e F.obj Y) := by\n  ext <;> simp [\u2190 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\u2093'. -/\n/-- `biprod_comparison F X Y` is a split epi. -/\n@[simps]\ndef splitEpiBiprodComparison : SplitEpi (biprodComparison F X Y) :=\n  \u27e8biprodComparison' F X Y\u27e9\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'\u2093'. -/\n/-- `biprod_comparison' F X Y` is a split mono. -/\n@[simps]\ndef splitMonoBiprodComparison' : SplitMono (biprodComparison' F X Y) :=\n  \u27e8biprodComparison F X Y\u27e9\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\u2093'. -/\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\u2093'. -/\n/-- If `F` preserves a binary biproduct, we get a definitionally nice isomorphism\n    `F.obj (X \u229e Y) \u2245 F.obj X \u229e F.obj Y`. -/\n@[simp]\ndef mapBiprod : F.obj (X \u229e Y) \u2245 F.obj X \u229e 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\u2093'. -/\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\u2093'. -/\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 \u2964 D) [PreservesZeroMorphisms F]\n\nsection Bicone\n\nvariable {J : Type w\u2081} (f : J \u2192 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\u2093'. -/\ntheorem biproduct.map_lift_mapBiprod (g : \u2200 j, W \u27f6 f j) :\n    F.map (biproduct.lift g) \u226b (F.mapBiproduct f).hom = biproduct.lift fun j => F.map (g j) :=\n  by\n  ext\n  simp [\u2190 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\u2093'. -/\ntheorem biproduct.mapBiproduct_inv_map_desc (g : \u2200 j, f j \u27f6 W) :\n    (F.mapBiproduct f).inv \u226b F.map (biproduct.desc g) = biproduct.desc fun j => F.map (g j) :=\n  by\n  ext\n  simp [\u2190 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\u2093'. -/\ntheorem biproduct.mapBiproduct_hom_desc (g : \u2200 j, f j \u27f6 W) :\n    ((F.mapBiproduct f).hom \u226b biproduct.desc fun j => F.map (g j)) = F.map (biproduct.desc g) := by\n  rw [\u2190 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\u2093'. -/\ntheorem biprod.map_lift_mapBiprod (f : W \u27f6 X) (g : W \u27f6 Y) :\n    F.map (biprod.lift f g) \u226b (F.mapBiprod X Y).hom = biprod.lift (F.map f) (F.map g) := by\n  ext <;> simp [\u2190 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\u2093'. -/\ntheorem biprod.lift_mapBiprod (f : W \u27f6 X) (g : W \u27f6 Y) :\n    biprod.lift (F.map f) (F.map g) \u226b (F.mapBiprod X Y).inv = F.map (biprod.lift f g) := by\n  rw [\u2190 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\u2093'. -/\ntheorem biprod.mapBiprod_inv_map_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n    (F.mapBiprod X Y).inv \u226b F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) := by\n  ext <;> simp [\u2190 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\u2093'. -/\ntheorem biprod.mapBiprod_hom_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n    (F.mapBiprod X Y).hom \u226b biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) := by\n  rw [\u2190 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 \u2243 K) : (discrete J \u224c discrete K) :=\nequivalence.mk\n  (functor.of_function h.to_fun) -- C \u2964 D\n  (functor.of_function h.inv_fun) -- D \u2964 C\n  { hom := {\n      app := \u03bb 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' := \u03bb X Y f, dec_trivial },\n    inv := {\n      app := \u03bb 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' := \u03bb 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 := \u03bb 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' := \u03bb X Y f, dec_trivial },\n    inv := {\n      app := \u03bb 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' := \u03bb 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} [\ud835\udc9e : category.{v} C]\ninclude \ud835\udc9e\n\nlemma prod.lift_fst {X Y Z : C} [has_limit (pair X Y)] (f : Z \u27f6 X) (g : Z \u27f6 Y) : prod.lift f g \u226b prod.fst = f :=\nby simp only [binary_fan.mk_\u03c0_app_left, limit.lift_\u03c0]\n\nlemma prod.lift_snd {X Y Z : C} [has_limit (pair X Y)] (f : Z \u27f6 X) (g : Z \u27f6 Y) : prod.lift f g \u226b prod.snd = g :=\nby simp only [binary_fan.mk_\u03c0_app_right, limit.lift_\u03c0]\n\nlemma prod.lift_uniq {X Y Z : C} [has_limit (pair X Y)] (f : Z \u27f6 X) (g : Z \u27f6 Y) (m : Z \u27f6 X \u2a2f Y)\n  (hLeft : m \u226b prod.fst = f) (hRight : m \u226b 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_\u03c0, binary_fan.mk_\u03c0_app_left],\n  simp only [limit.lift_\u03c0, binary_fan.mk_\u03c0_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} [\ud835\udc9e : category.{v} C]\ninclude \ud835\udc9e\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 : \u2115} (F: discrete (pfin (nat.succ n)) \u2964 C) (limF': has_limit (discrete.lift pfin.succ \u22d9 F))\n  : \u03a0 (j: pfin (nat.succ n)), F.obj \u27e80, nat.succ_pos n\u27e9 \u2a2f limF'.cone.X \u27f6 F.obj j\n| \u27e80, _\u27e9 := prod.fst\n| w@\u27e8nat.succ j, _\u27e9 := prod.snd \u226b\n  limF'.cone.\u03c0.app (w.pred (\u03bb 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: \u03a0 {n: \u2115} (F: (discrete (pfin n)) \u2964 C)\n, has_limit F\n| 0 F :=\n  -- In the base case, the category of cones over a diagram of shape \u2205 is simply \ud835\udc9e, so\n  -- the limit cone is \ud835\udc9e's terminal object.\n  let absurdJ (x : pfin 0) : false := x.elim0 in\n  let myCone : cone F :=\n    { X := terminal C,\n      \u03c0 := nat_trans.of_homs (\u03bb j, (absurdJ j).elim) } in\n  { cone := myCone,\n    is_limit :=\n      { lift := \u03bb s, terminal.from s.X\n      , fac' := \u03bb s j, (absurdJ j).elim\n      , uniq' := \u03bb 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) \u2a2f (apex of smaller limit cone)\n  -- where the smaller cone is obtained from the below functor.\n  let F' : discrete (pfin n) \u2964 C := discrete.lift pfin.succ \u22d9 F in\n  let limF' : has_limit F' := has_limit_for_pfin_diagram F' in\n  let myCone : cone F :=\n    { X := (F.obj \u27e80, nat.succ_pos n\u27e9) \u2a2f limF'.cone.X\n    , \u03c0 := 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 := \u03bb 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            , \u03c0 := nat_trans.of_homs (\u03bb j, s.\u03c0.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.\u03c0.app $ \u27e80, nat.succ_pos n\u27e9)\n            (eq_to_hom rfl \u226b limF'.is_limit.lift s')\n      -- Show that lift is in fact a morphism of cones from s into myCone.\n      , fac' := \u03bb s j, begin\n        rcases j with \u27e8j, hj\u27e9, 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_\u03c0_assoc, is_limit.fac, nat_trans.of_homs_app,\n          binary_fan.mk_\u03c0_app_right], congr\n      end\n      -- Show that lift is the unique morphism into myCone.\n      , uniq' := \u03bb s m h, begin\n        have h0 := h \u27e80, nat.succ_pos n\u27e9,\n        simp [match_statement_lol] at h0,\n        let s' : cone F' :=\n          { X := s.X\n          , \u03c0 := nat_trans.of_homs (\u03bb j, s.\u03c0.app j.succ) },\n        have hS : m \u226b prod.snd = eq_to_hom rfl \u226b limF'.is_limit.lift s',\n        { -- m \u226b prod.snd is a morphism of cones over F' into limF'.X ..\n          have hN : \u2200 (j: discrete (pfin n)), (m \u226b prod.snd) \u226b limF'.cone.\u03c0.app j = s'.\u03c0.app j,\n          { intro j,\n            unfold_projs, simp [(h j.succ).symm],\n            rcases j with \u27e8j, hj\u27e9, refl },\n          -- .. and therefore unique.\n          have hUniq' : m \u226b prod.snd = limF'.is_limit.lift s',\n          from limF'.is_limit.uniq' s' (m \u226b 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 : \u2115)\n  : @has_limits_of_shape (discrete $ pfin n) _ C \ud835\udc9e :=\n\u27e8\u03bb F, has_limit_for_pfin_diagram F\u27e9\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  (\u03bb h,\n    let hIso : discrete (pfin $ fintype.card J) \u224c discrete J :=\n      discrete.equiv_of_iso h.symm in\n    let limsPfin : @has_limits_of_shape (discrete (pfin $ fintype.card J)) _ C \ud835\udc9e :=\n      by apply_instance in\n    trunc.mk $ has_limits_of_shape_of_equivalence hIso)\n  (\u03bb 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  {\u03b1 : Type u} [T\u03b1 : topological_space \u03b1]\n  {\u03b2 : Type u} [T\u03b2 : topological_space \u03b2]\n  (f : \u03b1 \u2192 \u03b2)\n  (fcont: continuous f)\n  (FPT : presheaf_of_types \u03b1) :\n  presheaf_of_types \u03b2 :=\n{ F := \u03bb V OV, FPT.F (fcont V OV),\n  res := \u03bb V\u2081 V\u2082 OV\u2081 OV\u2082 H, \n    FPT.res (f \u207b\u00b9' V\u2081) (f\u207b\u00b9' V\u2082) (fcont V\u2081 OV\u2081) (fcont V\u2082 OV\u2082) (\u03bb x Hx,H Hx),\n  Hid := \u03bb V OV, FPT.Hid (f \u207b\u00b9' V) (fcont V OV),\n  Hcomp := \u03bb U\u03b2 V\u03b2 W\u03b2 OU\u03b2 OV\u03b2 OW\u03b2 HUV HVW,\n    FPT.Hcomp (f \u207b\u00b9' U\u03b2)(f \u207b\u00b9' V\u03b2)(f \u207b\u00b9' W\u03b2) (fcont U\u03b2 OU\u03b2) (fcont V\u03b2 OV\u03b2) (fcont W\u03b2 OW\u03b2)\n    (\u03bb x Hx, HUV Hx) (\u03bb x Hx, HVW Hx) }\n\ndefinition presheaf_of_rings_pushforward\n  {\u03b1 : Type u} [T\u03b1 : topological_space \u03b1]\n  {\u03b2 : Type u} [T\u03b2 : topological_space \u03b2]\n  (f : \u03b1 \u2192 \u03b2)\n  (fcont: continuous f)\n  (FPR : presheaf_of_rings \u03b1) :\n  presheaf_of_rings \u03b2 :=\n{ Fring := \u03bb U OU,FPR.Fring (fcont U OU),\n  res_is_ring_morphism := \u03bb U V OU OV H,\n    FPR.res_is_ring_morphism (f \u207b\u00b9' U) (f \u207b\u00b9' V) (fcont U OU) (fcont V OV) (\u03bb 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  {\u03b1 : Type u} [T\u03b1 : topological_space \u03b1]\n  {\u03b2 : Type u} [T\u03b2 : topological_space \u03b2]\n  (PT : presheaf_of_types \u03b2)\n  (f : \u03b1 \u2192 \u03b2)\n  (H : topological_space.open_immersion f) :\n  presheaf_of_types \u03b1 :=\n{ F := \u03bb U HU,PT.F ((H.fopens U).1 HU),\n  res := \u03bb 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 := \u03bb _ _,PT.Hid _ _,\n  Hcomp := \u03bb 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  {\u03b1 : Type u} [T\u03b1 : topological_space \u03b1]\n  {\u03b2 : Type u} [T\u03b2 : topological_space \u03b2]\n  (PR : presheaf_of_rings \u03b2)\n  (f : \u03b1 \u2192 \u03b2)\n  (H : topological_space.open_immersion f) :\n  presheaf_of_rings \u03b1 := \n{ Fring := \u03bb U OU,PR.Fring (topological_space.open_of_open_immersion_open f H U OU),\n  res_is_ring_morphism := \u03bb 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\u27e8(1 : R),eq.symm $ set.univ_subset_iff.1 $ \u03bb \u27e8P,HP\u27e9 _,@@is_prime_ideal.one_not_mem _ P HP\u27e9\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\u27e8\u03bb s t,\u27e8\u03bb 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 \u2229 Ut,\n  existsi Ust,\n  let BUst := zariski.standard_basis_has_FIP R _ _ BUs BUt,\n  existsi BUst,\n  existsi (\u27e8HxUs,HxUt\u27e9 : x \u2208 Us \u2229 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 \u27e8HyU,Hy.2.1\u27e9,\n  have Hty := Ht y \u27e8HyU,Hy.2.2\u27e9,\n  rw [Hsy,Hty],\n  apply quotient.sound,\n  existsi Ust,\n  existsi Hy.2,\n  existsi BUst,\n  existsi (set.subset.refl _: Ust \u2286 Us \u2229 Ut),\n  existsi (set.subset.refl _: Ust \u2286 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 \u2190(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 \u2190(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 \u2190(zariski.structure_presheaf_of_types_on_basis_of_standard R).Hcomp',\n  rw \u2190(zariski.structure_presheaf_of_types_on_basis_of_standard R).Hcomp',\n  refl,\nend\n\u27e9\u27e9\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) := \u27e8\u27e8\u03bb 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\u27e9\u27e9\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\u27e8\u03bb s,\u27e8\u03bb x HUx,-(s.1 x HUx),begin\n  intros x HUx,\n  rcases (s.2 x HUx) with \u27e8Us,BUs,HxUs,sigmas,Hs\u27e9,\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\u27e9\u27e9\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\u27e8\u03bb s t,\u27e8\u03bb x HUx,s.1 x HUx * t.1 x HUx,begin\n  intros x HUx,\n  rcases (s.2 x HUx) with \u27e8Us,BUs,HxUs,sigmas,Hs\u27e9,\n  rcases (t.2 x HUx) with \u27e8Ut,BUt,HxUt,sigmat,Ht\u27e9,\n  let Ust := Us \u2229 Ut,\n  existsi Ust,\n  let BUst := zariski.standard_basis_has_FIP R _ _ BUs BUt,\n  existsi BUst,\n  existsi (\u27e8HxUs,HxUt\u27e9 : x \u2208 Us \u2229 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 \u27e8HyU,Hy.2.1\u27e9,\n  have Hty := Ht y \u27e8HyU,Hy.2.2\u27e9,\n  rw [Hsy,Hty],\n  apply quotient.sound,\n  existsi Ust,\n  existsi Hy.2,\n  existsi BUst,\n  existsi (set.subset.refl _: Ust \u2286 Us \u2229 Ut),\n  existsi (set.subset.refl _: Ust \u2286 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 \u2190(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 \u2190(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 \u2190(zariski.structure_presheaf_of_types_on_basis_of_standard R).Hcomp',\n  rw \u2190(zariski.structure_presheaf_of_types_on_basis_of_standard R).Hcomp',\n  refl,\nend\n\u27e9\u27e9\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) := \u27e8\u27e8\u03bb 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\u27e9\u27e9\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 := \u03bb _ _ _, subtype.eq $ by funext;exact add_assoc _ _ _,\n  zero := has_zero.zero _,\n  zero_add := \u03bb _, subtype.eq $ by funext;exact zero_add _,\n  add_zero := \u03bb _, subtype.eq $ by funext;exact add_zero _,\n  neg := has_neg.neg,\n  add_left_neg := \u03bb _, subtype.eq $ by funext;exact add_left_neg _,\n  add_comm := \u03bb _ _, subtype.eq $ by funext;exact add_comm _ _,\n  mul := has_mul.mul,\n  mul_assoc := \u03bb _ _ _,subtype.eq $ by funext;exact mul_assoc _ _ _,\n  one := has_one.one _,\n  one_mul := \u03bb _, subtype.eq $ by funext;exact one_mul _,\n  mul_one := \u03bb _, subtype.eq $ by funext;exact mul_one _,\n  left_distrib := \u03bb _ _ _,subtype.eq $ by funext;exact left_distrib _ _ _,\n  right_distrib := \u03bb _ _ _,subtype.eq $ by funext;exact right_distrib _ _ _,\n  mul_comm := \u03bb _ _,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(\u03b1 : Type u)\n(T : topological_space \u03b1)\n(O_X : presheaf_of_rings \u03b1)\n(O_X_sheaf : is_sheaf_of_rings O_X)\n(locally_affine : \u2203 \u03b2 : Type u,\n  \u2203 cov : \u03b2 \u2192 set \u03b1,\n  \u2203 cov_open : \u2200 b, T.is_open $ cov b, \n  (\u2200 x, \u2203 b, x \u2208 cov b) \u2227\n  \u2200 b : \u03b2, \u2203 R : Type u, \u2203 RR : comm_ring R, \u2203 fR : (X R) \u2192 \u03b1, \n    set.range fR = cov b \u2227 -- thanks Johan Commelin!!\n    \u2203 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{ \u03b1 := 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 (\u03bb _, set.univ),\n    existsi (\u03bb _, 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 \u2190presheaf_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 \u2190presheaf_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 \u2192 q := \u03bb Hp : p, Hq\ncheck th           -- th : p \u2192 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 \u2227 a \u2209 A \u2227 b \u2209 A \u2227 \u2203 t, t \u2208 A \u2227 B a t b\n\ntheorem nine1 {a p : point} {A : set point} : line A \u2192 a \u2208 A \u2192 p \u2209 A \u2192 Bl p A (S a p) :=\n\u03bb h h1 h2, \u27e8h, h2, (\u03bb h_2, h2 ((seven24 h h1).2 h_2)), a, h1, (seven5 a p).1\u27e9\n\ntheorem nine2 {a b : point} {A : set point} : Bl a A b \u2192 a \u2260 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 \u2192 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 \u2192 m \u2208 A \u2192 M a m c \u2192 r \u2208 A \u2192 \n\u2200 {b}, sided r a b \u2192 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 \u2208 A) (h4 : A \u22a5 l a r) (h5 : s \u2208 A) (h6 : A \u22a5 l c s) \n(h2 : Bl a A c) (ht : t \u2208 A \u2227 B a t c) (h_1 : \u00acr = s) (h_2 : distle s c r a) : \nM r m s \u2192 \u2200 {u}, (sided r u a \u2194 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) \u22a5 (l c s),\n  rwa g2 at h6,\nhave g4 : (l s r) \u22a5 (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 \u2208 A) (h4 : A \u22a5 l a r) (h5 : s \u2208 A) (h6 : A \u22a5 l c s) \n(h2 : Bl a A c) (ht : t \u2208 A \u2227 B a t c) (h_1 : \u00acr = s) (h_2 : distle s c r a) : \n\u2200 {u v}, sided r u a \u2192 sided s v c \u2192 Bl u A v :=\nbegin\nhave g2 := six18 h2.1 (ne.symm h_1) h5 h3,\nhave g3 : (l s r) \u22a5 (l c s),\n  rwa g2 at h6,\nhave g4 : (l s r) \u22a5 (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 \u27e8b, gb\u27e9 hm.1.symm,\nhave h8 := (h7).1 hu,\nhave h9 := sided.trans h8 hv.symm,\nhave h10 : u \u2209 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 \u2208 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 \u2192 r \u2208 A \u2192 perp A (l a r) \u2192 s \u2208 A \u2192 perp A (l c s) \u2192 \n(M r m s \u2192 \u2200 {u}, (sided r u a \u2194 sided s (S m u) c)) \u2227 \u2200 {u v}, sided r u a \u2192 sided s v c \u2192 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) \u22a5 (l c s),\n  rwa g2 at h6,\nhave g4 : (l r s) \u22a5 (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 \u2194 sided s (S m u) c,\n    simp at this,\n    exact this,\n  exact (nine4a h5 h6 h3 h4 h2.symm \u27e8ht.1, ht.2.symm\u27e9 (ne.symm h) \u27e8b, gb\u27e9 hm.1.symm).symm,\nintros u v hu hv,\napply Bl.symm,\napply nine4b h5 h6 h3 h4 h2.symm \u27e8ht.1, ht.2.symm\u27e9 (ne.symm h) \u27e8b, gb\u27e9 hv hu\nend\n\ntheorem nine5 {a b c r : point} {A : set point} : Bl a A c \u2192 r \u2208 A \u2192 sided r a b \u2192 Bl b A c :=\nbegin\nintros h h1 h2,\nhave h3 : b \u2209 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 \u2260 x,\n  intro h_1,\n  apply h.2.1,\n  rw h_1,\n  exact hx.1.2.2.1,\nhave h6 : b \u2260 y,\n  intro h_1,\n  apply h3,\n  rw h_1,\n  exact hy.1.2.2.1,\nhave h7 : c \u2260 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 \u27e8x, hx.1\u27e9 hz.1.2.2.1 \u27e8z, hz.1\u27e9,\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) \u2260 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 \u27e8y, hy.1\u27e9 h14.2.2.1 \u27e8z, h14\u27e9).2 (six5 h6) h9.symm,\nexact h15,\nexact a\nend\n\ntheorem nine6 {a b c p q : point} : B a c p \u2192 B b q c \u2192 \u2203 x, B a x b \u2227 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 \u27e8h_1, h_2\u27e9,\n  constructor,\n  split,\n    exact three1 a b,\n  exact (six6 h1 h_3.symm).symm,\ncases em (b \u2208 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 \u2208 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 \u25b8 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 := \u2203 c, Bl a A c \u2227 Bl b A c\n\ntheorem nine8 {a b c : point} {A : set point} : Bl a A c \u2192 (Bl b A c \u2194 side A a b) :=\nbegin\nintro h,\nsplit,\n  intro h1,\n  constructor,\n  exact \u27e8h, h1\u27e9,\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 \u2260 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 \u2260 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 \u2260 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 \u2192 \u00acside 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 \u2192 a \u2209 A \u2192 \u2203 b, Bl a A b :=\nbegin\nintros h h1,\nrcases h with \u27e8p, q, h\u27e9,\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 \u2192 a \u2208 A \u2192 p \u2209 A \u2192 Bl p A (S a p) :=\n\u03bb h h1 h2, \u27e8h, h2, \u03bb h_1, h2 ((seven24 h h1).2 h_1), a, h1, (seven5 a p).1\u27e9\n\ntheorem nine11 {p q : point} {A : set point} : side A p q \u2192 line A \u2227 p \u2209 A \u2227 q \u2209 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 \u2192 p \u2208 A \u2192 sided p a b \u2192 a \u2209 A \u2192 side A a b :=\n\u03bb h h1 h2 h3, let \u27e8c, hc\u27e9 := nine10 h h3 in \u27e8c, hc, nine5 hc h1 h2\u27e9\n\ntheorem side.refl {a : point} {A : set point} : line A \u2192 a \u2209 A \u2192 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} : \u00accol a b c \u2192 side (l a b) c c :=\n\u03bb h, side.refl (six14 (six26 h).1) h\n\ntheorem side.symm {a b : point} {A : set point} : side A a b \u2192 side A b a :=\nbegin\nintro h,\ncases h with c hc,\nconstructor,\nexact \u27e8hc.2, hc.1\u27e9\nend\n\ntheorem side.trans {a b c : point} {A : set point} : side A a b \u2192 side A b c \u2192 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 \u2208 hp A a \u2192 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 \u2192 a \u2209 A \u2192 p \u2208 A \u2192 Bl a A (S p a) :=\n\u03bb h h1 h2, \u27e8h, h1, \u03bb h_1, h1 ((seven24 h h2).2 h_1), p, h2, (seven5 p a).1\u27e9\n\ntheorem nine17 {a b c : point} {A : set point} : side A a b \u2192 B a c b \u2192 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 \u2208 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 \u2192 side A p c \u2192 B a b c \u2192 side A p b :=\n\u03bb h h1 h2, h.trans (nine17 (h.symm.trans h1) h2).symm\n\ntheorem nine18 {a b p : point} {A : set point} : line A \u2192 p \u2208 A \u2192 col a b p \u2192 \n(Bl a A b \u2194 B a p b \u2227 a \u2209 A \u2227 b \u2209 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 \u2192 p \u2208 A \u2192 col a b p \u2192 \nside A a b \u2192 sided p a b \u2227 a \u2209 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 \u2192 p \u2208 A \u2192 sided p b c \u2192 side A a c :=\n\u03bb h h1 h2, h.trans (nine12 (nine11 h).1 h1 h2 (nine11 h).2.2)\n\ntheorem nine15 {a b x y p : point} : \u00accol a b p \u2192 B a p x \u2192 B b p y \u2192 side (l a b) x y :=\n\u03bb 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 \u2228 x \u2208 A \u2228 Bl a A x}\n\ndef plane (P : set point) : Prop := \u2203 p q r, \u00accol p q r \u2227 P = pl (l p q) r\n\ntheorem nine20 {a : point} {A : set point} : line A \u2192 a \u2209 A \u2192 plane (pl A a) :=\nbegin\nintros h h1,\nrcases h with \u27e8p, q, h\u27e9,\nrw h.2 at *,\nrepeat {constructor},\nexact h1\nend\n\ntheorem nine21a {a b : point} {A : set point} : b \u2208 pl A a \u2192 b \u2209 A \u2192 line A \u2227 a \u2209 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 \u2208 pl A a \u2192 b \u2209 A \u2192 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' \u2192 a \u2208 A' \u2192 a \u2260 x \u2192 A' \u2286 pl A a :=\nbegin\nintros h h1 h2,\nintros p hp,\nhave h3 : a \u2209 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 \u2209 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 \u2260 c \u2192 \u00accol a b p \u2192 col a c p \u2192 planeof a b c = planeof a b p :=\nbegin\nintros h_1 h h1,\nunfold planeof,\napply nine21b,\n  suffices : l a c \u2286 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 \u2208 l a c,\n        rw \u2190h_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} : \u00accol a b c \u2192 side (l a b) x c \u2192 x \u2208 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 \u2190h_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 \u2190this,\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 \u2208 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 \u2208 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 \u2208 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} : \u00accol a b c \u2192 planeof a b c \u2286 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 \u2286 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 : \u00accol 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} : \u00accol a b c \u2192 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} : \u00accol a b c \u2192 planeof a b c = planeof a c b \u2227 planeof a b c = planeof b a c \n\u2227 planeof a b c = planeof b c a \u2227 planeof a b c = planeof c a b \u2227 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} : \u00accol a b c \u2192 l a b \u2286 planeof a b c \u2227 l b c \u2286 planeof a b c \u2227 l a c \u2286 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 : \u00accol p q r) (h1 : a \u2208 pl (l p q) r) (h2 : b \u2208 pl (l p q) r) (h3 : a \u2260 b)\n(h_2 : b \u2209 l p q) : l a b \u2286 pl (l p q) r \u2227 \u2203 c, pl (l p q) r = planeof a b c :=\nbegin\nhave h4 : p \u2260 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 \u2208 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 \u2209 l a b,\n    intro h_4,\n    rw \u2190h7 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 \u2192 a \u2208 P \u2192 b \u2208 P \u2192 a \u2260 b \u2192 l a b \u2286 P \u2227 \u2203 c, P = planeof a b c :=\nbegin\nintros h h1 h2 h3,\nunfold plane at h,\nrcases h with \u27e8p, q, r, h\u27e9,\nrw h.2 at *,\ncases em (a \u2208 l p q),\n  cases em (b \u2208 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 \u2190h4,\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} : \u00accol a b c \u2192 plane P \u2192 a \u2208 P \u2192 b \u2208 P \u2192 c \u2208 P \u2192 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 \u2208 planeof a b c \u2227 b \u2208 planeof a b c \u2227 c \u2208 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 \u2208 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 \u2192 plane (pl A p) \u2192 p \u2209 A :=\nbegin\nintros h h1 h2,\nrcases h1 with \u27e8x, y, z, h1\u27e9,\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 \u27e8A, h, h3\u27e9,\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 \u2192 side (l p r) s q \u2192 Bl q (l p s) r :=\nbegin\nintros h h1,\nhave h2 : \u00accol 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) \u2260 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 \u2260 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 {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} : (Subtype fun (x : \u03b1) => p x) \u2192 \u2203 (x : \u03b1), p x :=\n  sorry\n\ntheorem tag_irrelevant {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} {a : \u03b1} (h1 : p a) (h2 : p a) : { val := a, property := h1 } = { val := a, property := h2 } :=\n  rfl\n\nprotected theorem eq {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} {a1 : Subtype fun (x : \u03b1) => p x} {a2 : Subtype fun (x : \u03b1) => p x} : val a1 = val a2 \u2192 a1 = a2 := sorry\n\ntheorem ne_of_val_ne {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} {a1 : Subtype fun (x : \u03b1) => p x} {a2 : Subtype fun (x : \u03b1) => p x} : val a1 \u2260 val a2 \u2192 a1 \u2260 a2 :=\n  mt (congr_arg fun {a1 : Subtype fun (x : \u03b1) => p x} => val a1)\n\n@[simp] theorem eta {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} (a : Subtype fun (x : \u03b1) => 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 {\u03b1 : Type u} {p : \u03b1 \u2192 Prop} {a : \u03b1} (h : p a) : Inhabited (Subtype fun (x : \u03b1) => 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) 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.Meta\nimport Init.SizeOf\nimport Init.Data.Nat.Linear\n\n@[simp] theorem Fin.sizeOf (a : Fin n) : sizeOf a = a.val + 1 := by\n  cases a; simp_arith\n\n@[simp] theorem UInt8.sizeOf (a : UInt8) : sizeOf a = a.toNat + 2 := by\n  cases a; simp_arith [UInt8.toNat]\n\n@[simp] theorem UInt16.sizeOf (a : UInt16) : sizeOf a = a.toNat + 2 := by\n  cases a; simp_arith [UInt16.toNat]\n\n@[simp] theorem UInt32.sizeOf (a : UInt32) : sizeOf a = a.toNat + 2 := by\n  cases a; simp_arith [UInt32.toNat]\n\n@[simp] theorem UInt64.sizeOf (a : UInt64) : sizeOf a = a.toNat + 2 := by\n  cases a; simp_arith [UInt64.toNat]\n\n@[simp] theorem USize.sizeOf (a : USize) : sizeOf a = a.toNat + 2 := by\n  cases a; simp_arith [USize.toNat]\n\n@[simp] theorem Char.sizeOf (a : Char) : sizeOf a = a.toNat + 3 := by\n  cases a; simp_arith [Char.toNat]\n\n@[simp] theorem Subtype.sizeOf {\u03b1 : Sort u_1} {p : \u03b1 \u2192 Prop} (s : Subtype p) : sizeOf s = sizeOf s.val + 1 := by\n  cases s; simp_arith\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/SizeOfLemmas.lean", "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.7025300449389326, "lm_q2_score": 0.640635854839898, "lm_q1q2_score": 0.450065935890165}}
{"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\u00f6lzl\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\u2082 -/\n\ntheorem forall\u2082_iff {\u03b1 : Type u} {\u03b2 : Type v} (R : \u03b1 \u2192 \u03b2 \u2192 Prop) : \u2200 (\u1fb0 : List \u03b1) (\u1fb0_1 : List \u03b2),\n  forall\u2082 R \u1fb0 \u1fb0_1 \u2194\n    \u1fb0 = [] \u2227 \u1fb0_1 = [] \u2228\n      Exists\n        fun {a : \u03b1} =>\n          Exists\n            fun {b : \u03b2} =>\n              Exists\n                fun {l\u2081 : List \u03b1} => Exists fun {l\u2082 : List \u03b2} => R a b \u2227 forall\u2082 R l\u2081 l\u2082 \u2227 \u1fb0 = a :: l\u2081 \u2227 \u1fb0_1 = b :: l\u2082 := sorry\n\n@[simp] theorem forall\u2082_cons {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {a : \u03b1} {b : \u03b2} {l\u2081 : List \u03b1} {l\u2082 : List \u03b2} : forall\u2082 R (a :: l\u2081) (b :: l\u2082) \u2194 R a b \u2227 forall\u2082 R l\u2081 l\u2082 := sorry\n\ntheorem forall\u2082.imp {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {S : \u03b1 \u2192 \u03b2 \u2192 Prop} (H : \u2200 (a : \u03b1) (b : \u03b2), R a b \u2192 S a b) {l\u2081 : List \u03b1} {l\u2082 : List \u03b2} (h : forall\u2082 R l\u2081 l\u2082) : forall\u2082 S l\u2081 l\u2082 := sorry\n\ntheorem forall\u2082.mp {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {q : \u03b1 \u2192 \u03b2 \u2192 Prop} {s : \u03b1 \u2192 \u03b2 \u2192 Prop} (h : \u2200 (a : \u03b1) (b : \u03b2), r a b \u2192 q a b \u2192 s a b) {l\u2081 : List \u03b1} {l\u2082 : List \u03b2} : forall\u2082 r l\u2081 l\u2082 \u2192 forall\u2082 q l\u2081 l\u2082 \u2192 forall\u2082 s l\u2081 l\u2082 := sorry\n\ntheorem forall\u2082.flip {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {a : List \u03b1} {b : List \u03b2} : forall\u2082 (flip r) b a \u2192 forall\u2082 r a b := sorry\n\ntheorem forall\u2082_same {\u03b1 : Type u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} {l : List \u03b1} : (\u2200 (x : \u03b1), x \u2208 l \u2192 r x x) \u2192 forall\u2082 r l l := sorry\n\ntheorem forall\u2082_refl {\u03b1 : Type u} {r : \u03b1 \u2192 \u03b1 \u2192 Prop} [is_refl \u03b1 r] (l : List \u03b1) : forall\u2082 r l l :=\n  forall\u2082_same fun (a : \u03b1) (h : a \u2208 l) => is_refl.refl a\n\ntheorem forall\u2082_eq_eq_eq {\u03b1 : Type u} : forall\u2082 Eq = Eq := sorry\n\n@[simp] theorem forall\u2082_nil_left_iff {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {l : List \u03b2} : forall\u2082 r [] l \u2194 l = [] := sorry\n\n@[simp] theorem forall\u2082_nil_right_iff {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {l : List \u03b1} : forall\u2082 r l [] \u2194 l = [] := sorry\n\ntheorem forall\u2082_cons_left_iff {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {a : \u03b1} {l : List \u03b1} {u : List \u03b2} : forall\u2082 r (a :: l) u \u2194 \u2203 (b : \u03b2), \u2203 (u' : List \u03b2), r a b \u2227 forall\u2082 r l u' \u2227 u = b :: u' := sorry\n\ntheorem forall\u2082_cons_right_iff {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {b : \u03b2} {l : List \u03b2} {u : List \u03b1} : forall\u2082 r u (b :: l) \u2194 \u2203 (a : \u03b1), \u2203 (u' : List \u03b1), r a b \u2227 forall\u2082 r u' l \u2227 u = a :: u' := sorry\n\ntheorem forall\u2082_and_left {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b1 \u2192 Prop} (l : List \u03b1) (u : List \u03b2) : forall\u2082 (fun (a : \u03b1) (b : \u03b2) => p a \u2227 r a b) l u \u2194 (\u2200 (a : \u03b1), a \u2208 l \u2192 p a) \u2227 forall\u2082 r l u := sorry\n\n@[simp] theorem forall\u2082_map_left_iff {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {f : \u03b3 \u2192 \u03b1} {l : List \u03b3} {u : List \u03b2} : forall\u2082 r (map f l) u \u2194 forall\u2082 (fun (c : \u03b3) (b : \u03b2) => r (f c) b) l u := sorry\n\n@[simp] theorem forall\u2082_map_right_iff {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {f : \u03b3 \u2192 \u03b2} {l : List \u03b1} {u : List \u03b3} : forall\u2082 r l (map f u) \u2194 forall\u2082 (fun (a : \u03b1) (c : \u03b3) => r a (f c)) l u := sorry\n\ntheorem left_unique_forall\u2082 {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (hr : relator.left_unique r) : relator.left_unique (forall\u2082 r) := sorry\n\ntheorem right_unique_forall\u2082 {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (hr : relator.right_unique r) : relator.right_unique (forall\u2082 r) := sorry\n\ntheorem bi_unique_forall\u2082 {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (hr : relator.bi_unique r) : relator.bi_unique (forall\u2082 r) :=\n  { left := fun (a : List \u03b1) (b : List \u03b2) (c : List \u03b1) => left_unique_forall\u2082 (and.left hr),\n    right := fun (a : List \u03b1) (b c : List \u03b2) => right_unique_forall\u2082 (and.right hr) }\n\ntheorem forall\u2082_length_eq {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {l\u2081 : List \u03b1} {l\u2082 : List \u03b2} : forall\u2082 R l\u2081 l\u2082 \u2192 length l\u2081 = length l\u2082 := sorry\n\ntheorem forall\u2082_zip {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {l\u2081 : List \u03b1} {l\u2082 : List \u03b2} : forall\u2082 R l\u2081 l\u2082 \u2192 \u2200 {a : \u03b1} {b : \u03b2}, (a, b) \u2208 zip l\u2081 l\u2082 \u2192 R a b := sorry\n\ntheorem forall\u2082_iff_zip {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} {l\u2081 : List \u03b1} {l\u2082 : List \u03b2} : forall\u2082 R l\u2081 l\u2082 \u2194 length l\u2081 = length l\u2082 \u2227 \u2200 {a : \u03b1} {b : \u03b2}, (a, b) \u2208 zip l\u2081 l\u2082 \u2192 R a b := sorry\n\ntheorem forall\u2082_take {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} (n : \u2115) {l\u2081 : List \u03b1} {l\u2082 : List \u03b2} : forall\u2082 R l\u2081 l\u2082 \u2192 forall\u2082 R (take n l\u2081) (take n l\u2082) := sorry\n\ntheorem forall\u2082_drop {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} (n : \u2115) {l\u2081 : List \u03b1} {l\u2082 : List \u03b2} : forall\u2082 R l\u2081 l\u2082 \u2192 forall\u2082 R (drop n l\u2081) (drop n l\u2082) := sorry\n\ntheorem forall\u2082_take_append {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} (l : List \u03b1) (l\u2081 : List \u03b2) (l\u2082 : List \u03b2) (h : forall\u2082 R l (l\u2081 ++ l\u2082)) : forall\u2082 R (take (length l\u2081) l) l\u2081 :=\n  (fun (h' : forall\u2082 R (take (length l\u2081) l) (take (length l\u2081) (l\u2081 ++ l\u2082))) =>\n      eq.mp (Eq._oldrec (Eq.refl (forall\u2082 R (take (length l\u2081) l) (take (length l\u2081) (l\u2081 ++ l\u2082)))) (take_left l\u2081 l\u2082)) h')\n    (forall\u2082_take (length l\u2081) h)\n\ntheorem forall\u2082_drop_append {\u03b1 : Type u} {\u03b2 : Type v} {R : \u03b1 \u2192 \u03b2 \u2192 Prop} (l : List \u03b1) (l\u2081 : List \u03b2) (l\u2082 : List \u03b2) (h : forall\u2082 R l (l\u2081 ++ l\u2082)) : forall\u2082 R (drop (length l\u2081) l) l\u2082 :=\n  (fun (h' : forall\u2082 R (drop (length l\u2081) l) (drop (length l\u2081) (l\u2081 ++ l\u2082))) =>\n      eq.mp (Eq._oldrec (Eq.refl (forall\u2082 R (drop (length l\u2081) l) (drop (length l\u2081) (l\u2081 ++ l\u2082)))) (drop_left l\u2081 l\u2082)) h')\n    (forall\u2082_drop (length l\u2081) h)\n\ntheorem rel_mem {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} (hr : relator.bi_unique r) : relator.lift_fun r (forall\u2082 r \u21d2 Iff) has_mem.mem has_mem.mem := sorry\n\ntheorem rel_map {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b4 : Type z} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop} : relator.lift_fun (r \u21d2 p) (forall\u2082 r \u21d2 forall\u2082 p) map map := sorry\n\ntheorem rel_append {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} : relator.lift_fun (forall\u2082 r) (forall\u2082 r \u21d2 forall\u2082 r) append append := sorry\n\ntheorem rel_join {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} : relator.lift_fun (forall\u2082 (forall\u2082 r)) (forall\u2082 r) join join := sorry\n\ntheorem rel_bind {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b4 : Type z} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop} : relator.lift_fun (forall\u2082 r) ((r \u21d2 forall\u2082 p) \u21d2 forall\u2082 p) list.bind list.bind :=\n  fun (a : List \u03b1) (b : List \u03b2) (h\u2081 : forall\u2082 r a b) (f : \u03b1 \u2192 List \u03b3) (g : \u03b2 \u2192 List \u03b4)\n    (h\u2082 : relator.lift_fun r (forall\u2082 p) f g) => rel_join (rel_map h\u2082 h\u2081)\n\ntheorem rel_foldl {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b4 : Type z} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop} : relator.lift_fun (p \u21d2 r \u21d2 p) (p \u21d2 forall\u2082 r \u21d2 p) foldl foldl := sorry\n\ntheorem rel_foldr {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b4 : Type z} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop} : relator.lift_fun (r \u21d2 p \u21d2 p) (p \u21d2 forall\u2082 r \u21d2 p) foldr foldr := sorry\n\ntheorem rel_filter {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b1 \u2192 Prop} {q : \u03b2 \u2192 Prop} [decidable_pred p] [decidable_pred q] (hpq : relator.lift_fun r Iff p q) : relator.lift_fun (forall\u2082 r) (forall\u2082 r) (filter p) (filter q) := sorry\n\ntheorem filter_map_cons {\u03b1 : Type u} {\u03b2 : Type v} (f : \u03b1 \u2192 Option \u03b2) (a : \u03b1) (l : List \u03b1) : filter_map f (a :: l) = option.cases_on (f a) (filter_map f l) fun (b : \u03b2) => b :: filter_map f l := sorry\n\ntheorem rel_filter_map {\u03b1 : Type u} {\u03b2 : Type v} {\u03b3 : Type w} {\u03b4 : Type z} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} {p : \u03b3 \u2192 \u03b4 \u2192 Prop} : relator.lift_fun (r \u21d2 option.rel p) (forall\u2082 r \u21d2 forall\u2082 p) filter_map filter_map := sorry\n\ntheorem rel_sum {\u03b1 : Type u} {\u03b2 : Type v} {r : \u03b1 \u2192 \u03b2 \u2192 Prop} [add_monoid \u03b1] [add_monoid \u03b2] (h : r 0 0) (hf : relator.lift_fun r (r \u21d2 r) Add.add Add.add) : relator.lift_fun (forall\u2082 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\u2082\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\u2082} [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 \u2964 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 \u2192 C} (b : bicone f) : bicone (F.obj \u2218 f) :=\n{ X := F.obj b.X,\n  \u03c0 := \u03bb j, F.map (b.\u03c0 j),\n  \u03b9 := \u03bb j, F.map (b.\u03b9 j),\n  \u03b9_\u03c0 := \u03bb j j',\n  begin\n    rw \u2190 F.map_comp,\n    split_ifs,\n    { subst h,\n      simp only [bicone_\u03b9_\u03c0_self, category_theory.functor.map_id, eq_to_hom_refl] },\n    { rw [bicone_\u03b9_\u03c0_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 [\u2190 F.map_comp, b.inl_fst, F.map_id],\n  inl_snd' := by rw [\u2190 F.map_comp, b.inl_snd, F.map_zero],\n  inr_fst' := by rw [\u2190 F.map_comp, b.inr_fst, F.map_zero],\n  inr_snd' := by rw [\u2190 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 \u2218 f`. -/\nclass preserves_biproduct (f : J \u2192 C) (F : C \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {b : bicone f}, b.is_bilimit \u2192 (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 \u2218 f`. -/\ndef is_bilimit_of_preserves {f : J \u2192 C} (F : C \u2964 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 \u2192 C`. -/\nclass preserves_biproducts_of_shape (F : C \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {f : J \u2192 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D)\n  [preserves_zero_morphisms F] [preserves_biproducts F] : preserves_finite_biproducts F :=\n{ preserves := \u03bb 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {b : binary_bicone X Y}, b.is_bilimit \u2192 (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 \u2964 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 \u2964 D) [preserves_zero_morphisms F] :=\n(preserves : \u03a0 {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 \u2964 D) [preserves_zero_morphisms F]\n  (X Y : C) [preserves_biproduct (pair X Y).obj F] : preserves_binary_biproduct X Y F :=\n{ preserves := \u03bb 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 _) (\u03bb 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 _) (\u03bb 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 \u2964 D)\n  [preserves_zero_morphisms F] [preserves_biproducts_of_shape (discrete walking_pair.{v}) F] :\n  preserves_binary_biproducts F :=\n{ preserves := \u03bb 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 \u2964 D) [preserves_zero_morphisms F] (f : J \u2192 C)\n  [has_biproduct f] [preserves_biproduct f F]\n\ninstance has_biproduct_of_preserves : has_biproduct (F.obj \u2218 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 (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f)`. -/\n@[simp]\ndef map_biproduct : F.obj (\u2a01 f) \u2245 \u2a01 (F.obj \u2218 f) :=\nbiproduct.unique_up_to_iso _ (preserves_biproduct.preserves (biproduct.is_bilimit _))\n\nlemma map_biproduct_hom : (map_biproduct F f).hom = biproduct.lift (\u03bb j, F.map (biproduct.\u03c0 f j)) :=\nrfl\n\nlemma map_biproduct_inv : (map_biproduct F f).inv = biproduct.desc (\u03bb j, F.map (biproduct.\u03b9 f j)) :=\nrfl\n\nend bicone\n\nvariables (F : C \u2964 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 \u229e Y) \u2245 F.obj X \u229e F.obj Y`. -/\n@[simp]\ndef map_biprod : F.obj (X \u229e Y) \u2245 F.obj X \u229e 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 \u2964 D) [preserves_zero_morphisms F]\n\nsection bicone\nvariables {J : Type v} [decidable_eq J] (f : J \u2192 C) [has_biproduct f] [preserves_biproduct f F]\n  {W : C}\n\nlemma biproduct.map_lift_map_biprod (g : \u03a0 j, W \u27f6 f j) :\n  F.map (biproduct.lift g) \u226b (F.map_biproduct f).hom = biproduct.lift (\u03bb j, F.map (g j)) :=\nby { ext, simp [\u2190 F.map_comp] }\n\nlemma biproduct.map_biproduct_inv_map_desc (g : \u03a0 j, f j \u27f6 W) :\n  (F.map_biproduct f).inv \u226b F.map (biproduct.desc g) = biproduct.desc (\u03bb j, F.map (g j)) :=\nby { ext, simp [\u2190 F.map_comp] }\n\nlemma biproduct.map_biproduct_hom_desc (g : \u03a0 j, f j \u27f6 W) :\n  (F.map_biproduct f).hom \u226b biproduct.desc (\u03bb j, F.map (g j)) = F.map (biproduct.desc g) :=\nby rw [\u2190 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 \u27f6 X) (g : W \u27f6 Y) :\n  F.map (biprod.lift f g) \u226b (F.map_biprod X Y).hom = biprod.lift (F.map f) (F.map g) :=\nby ext; simp [\u2190 F.map_comp]\n\nlemma biprod.lift_map_biprod (f : W \u27f6 X) (g : W \u27f6 Y) :\n  biprod.lift (F.map f) (F.map g) \u226b (F.map_biprod X Y).inv = F.map (biprod.lift f g) :=\nby rw [\u2190 biprod.map_lift_map_biprod, category.assoc, iso.hom_inv_id, category.comp_id]\n\nlemma biprod.map_biprod_inv_map_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n  (F.map_biprod X Y).inv \u226b F.map (biprod.desc f g) = biprod.desc (F.map f) (F.map g) :=\nby ext; simp [\u2190 F.map_comp]\n\nlemma biprod.map_biprod_hom_desc (f : X \u27f6 W) (g : Y \u27f6 W) :\n (F.map_biprod X Y).hom \u226b biprod.desc (F.map f) (F.map g) = F.map (biprod.desc f g) :=\nby rw [\u2190 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 \u2964 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 \u2192 C} [preserves_biproduct f F] :\n  preserves_limit (discrete.functor f) F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C} [preserves_limit (discrete.functor f) F] :\n  preserves_biproduct f F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C} [preserves_biproduct f F] :\n  preserves_colimit (discrete.functor f) F :=\n{ preserves := \u03bb 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 := \u03bb 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 \u2192 C}\n  [preserves_colimit (discrete.functor f) F] : preserves_biproduct f F :=\n{ preserves := \u03bb 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 := \u03bb 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 := \u03bb 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 _) (\u03bb 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 := \u03bb 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 := \u03bb 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 _) (\u03bb 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 := \u03bb 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 := \u03bb 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 _) (\u03bb 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 := \u03bb 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 := \u03bb 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 _) (\u03bb 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 := \u03bb 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 \u2192* N`\nsince the inverses are unique. When `N \u2264 is_unit.submonoid M`, this is precisely\nthe pointwise inverse of `N`, and we may define `left_inv_equiv : S.left_inv \u2243* 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 => \u27e8_, x.Prop.Unit\u207b\u00b9.IsUnit\u27e9\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\u2093.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\u2093.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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem IsUnit.Submonoid.coe_inv [Monoid M] (x : IsUnit.submonoid M) :\n    \u2191x\u207b\u00b9 = (\u2191x.Prop.Unit\u207b\u00b9 : 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 | \u2203 y : S, x * y = 1 }\n  one_mem' := \u27e81, mul_one 1\u27e9\n  mul_mem' := fun a b \u27e8a', ha\u27e9 \u27e8b', hb\u27e9 =>\n    \u27e8b' * a', by rw [coe_mul, \u2190 mul_assoc, mul_assoc a, hb, mul_one, ha]\u27e9\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\u2093'. -/\n@[to_additive]\ntheorem leftInv_leftInv_le : S.left_inv.left_inv \u2264 S :=\n  by\n  rintro x \u27e8\u27e8y, z, h\u2081\u27e9, h\u2082 : x * y = 1\u27e9\n  convert z.prop\n  rw [\u2190 mul_one x, \u2190 h\u2081, \u2190 mul_assoc, h\u2082, 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\u2093.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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem unit_mem_leftInv (x : M\u02e3) (hx : (x : M) \u2208 S) : ((x\u207b\u00b9 : _) : M) \u2208 S.left_inv :=\n  \u27e8\u27e8x, hx\u27e9, x.inv_val\u27e9\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\u2093'. -/\n@[to_additive]\ntheorem leftInv_leftInv_eq (hS : S \u2264 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\u207b\u00b9\u207b\u00b9 : M\u02e3) :=\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\u2093'. -/\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 \u2192 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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\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\u2093'. -/\n@[to_additive]\ntheorem leftInv_le_isUnit : S.left_inv \u2264 IsUnit.submonoid M := fun x \u27e8y, hx\u27e9 =>\n  \u27e8\u27e8x, y, hx, mul_comm x y \u25b8 hx\u27e9, rfl\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[to_additive]\ntheorem fromLeftInv_eq_iff (a : S.left_inv) (b : M) : (S.fromLeftInv a : M) = b \u2194 (a : M) * b = 1 :=\n  by rw [\u2190 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\u2093'. -/\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 \u2192* 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, \u2190\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 \u2264 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\u2093'. -/\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 \u2243* S :=\n  {\n    S.fromCommLeftInv with\n    invFun := fun x => by\n      choose x' hx using hS x.prop\n      exact \u27e8x'.inv, x, hx \u25b8 x'.inv_val\u27e9\n    left_inv := fun x =>\n      Subtype.eq <| by\n        dsimp; generalize_proofs h; rw [\u2190 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\u2093'. -/\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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\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\u2093.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\u2093.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\u2093'. -/\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\u207b\u00b9 :=\n  Submonoid.ext fun x =>\n    \u27e8fun h => Submonoid.mem_inv.mpr ((inv_eq_of_mul_eq_one_right h.choose_spec).symm \u25b8 h.some.Prop),\n      fun h => \u27e8\u27e8_, h\u27e9, mul_right_inv _\u27e9\u27e9\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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem fromLeftInv_eq_inv (x : S.left_inv) : (S.fromLeftInv x : M) = x\u207b\u00b9 := by\n  rw [\u2190 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 \u2264 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\u2093.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\u2093.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\u2093'. -/\n@[simp, to_additive]\ntheorem leftInvEquiv_symm_eq_inv (x : S) : ((S.leftInvEquiv hS).symm x : M) = x\u207b\u00b9 := by\n  rw [\u2190 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}}
